commit 52a926b05ebd0fcd1b6943ec2f99c0e13761fa0f Author: sapient Date: Sun Mar 22 00:54:57 2026 -0700 chore: initial commit of OpenWRT diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a54a397 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.env +.env.* +*.log +node_modules/ +.venv/ diff --git a/docs/OPKG-REPO-README.md b/docs/OPKG-REPO-README.md new file mode 100755 index 0000000..85ef649 --- /dev/null +++ b/docs/OPKG-REPO-README.md @@ -0,0 +1,64 @@ +# opkg Repository - Quick Reference + +## πŸ“¦ Repository Ready! + +Your opkg-compatible repository is located at: +``` +/home/user/Public/Projects/OpenWRT/opkg-repo/ +``` + +## πŸš€ Quick Upload + +Upload to your HTTP server (`/srv/http`): +```bash +./upload-repo.sh SERVER_IP user /srv/http/opkg +``` + +Alternatively, manual upload: +```bash +scp -r opkg-repo/* user@SERVER_IP:/srv/http/opkg/ +``` + +## πŸ“‹ Available Packages + +- **btop-static** (1.4.3-1) - 1.0 MB - Resource monitor +- **mosh-static** (1.4.0-1) - 3.6 MB - Mobile Shell + +## πŸ”§ On Your OpenWRT Device + +```bash +# Add repository (replace SERVER_IP) +echo 'src/gz custom http://SERVER_IP/opkg/aarch64_cortex-a53/packages' > /etc/opkg/customfeeds.conf + +# Update and install +opkg update +opkg install btop-static mosh-static +``` + +## βž• Adding New Packages + +```bash +# 1. Copy package to repository +cp new-package.ipk opkg-repo/aarch64_cortex-a53/packages/ + +# 2. Regenerate index +./generate-index.sh opkg-repo/aarch64_cortex-a53/packages/ > opkg-repo/aarch64_cortex-a53/packages/Packages +gzip -9 -k opkg-repo/aarch64_cortex-a53/packages/Packages + +# 3. Upload to server +./upload-repo.sh SERVER_IP user /srv/http/opkg +``` + +## πŸ“ Files Created + +- `opkg-repo/` - Local repository directory +- `generate-index.sh` - Package index generator +- `upload-repo.sh` - Server upload script +- Full documentation in the artifacts + +## ⚠️ Notes + +- Repository is for **aarch64_cortex-a53** architecture only +- All packages are statically linked +- Index must be regenerated after changes +- Two btop variants failed indexing (missing control files) diff --git a/docs/PROJECT_README.md b/docs/PROJECT_README.md new file mode 100755 index 0000000..57b6829 --- /dev/null +++ b/docs/PROJECT_README.md @@ -0,0 +1,91 @@ +# OpenWRT Cross-Compilation Project + +Cross-compilation environment for GL.iNet routers: **Flint1 (GL-AX1800)** and **Flint2 (GL-MT6000)**. + +## Project Structure + +### Router-Specific Directories + +``` +OpenWRT/ +β”œβ”€β”€ flint1-armv7/ # GL-AX1800 (ARMv7, 32-bit) +β”‚ β”œβ”€β”€ sdk/ # ARMv7 cross-compilation toolchains +β”‚ β”œβ”€β”€ src/ # Source code for compilation +β”‚ └── build/ # Build scripts +β”‚ +β”œβ”€β”€ flint2-aarch64/ # GL-MT6000 (ARMv8/aarch64, 64-bit) +β”‚ β”œβ”€β”€ sdk/ # MediaTek OpenWrt SDKs +β”‚ β”œβ”€β”€ src/ # Source code (symlinked) +β”‚ └── build/ # Build scripts +β”‚ +β”œβ”€β”€ binaries/ # Compiled binaries +β”‚ β”œβ”€β”€ flint1/ # ARMv7 binaries +β”‚ └── flint2/ # aarch64 binaries +β”‚ +β”œβ”€β”€ packages/ # .ipk packages +β”‚ β”œβ”€β”€ flint1/ +β”‚ β”œβ”€β”€ flint2/ +β”‚ └── common/ +β”‚ +β”œβ”€β”€ src/ # Shared source code +β”‚ β”œβ”€β”€ btop/ +β”‚ └── mosh/ +β”‚ +└── agent-notes/ # Research and documentation +``` + +### Shared Directories + +- **`binaries/`** - Compiled binaries sorted by architecture +- **`packages/`** - OpenWrt `.ipk` packages +- **`src/`** - Original source code (shared reference) +- **`opkg-repo/`** - Package repository for deployment +- **`agent-notes/`** - Research, build results, SDK documentation + +## Architecture Overview + +| Router | Model | SoC | Architecture | Bits | OpenWrt Target | +|--------|-------|-----|--------------|------|----------------| +| **Flint1** | GL-AX1800 | Qualcomm IPQ6000 | ARMv7 rev 4 | 32-bit | ipq40xx | +| **Flint2** | GL-MT6000 | MediaTek MT7986A | ARMv8 rev 4 (aarch64) | 64-bit | mediatek-filogic | + +**Note:** Different architectures require **separate binaries**. + +## Quick Start + +### Flint1 (ARMv7) + +```bash +cd flint1-armv7/build +./download-armv7-toolchain.sh # First time only +./build-btop-armv7.sh +``` + +### Flint2 (aarch64) + +Binaries already built and available in `binaries/flint2/`. + +To rebuild: +```bash +cd flint2-aarch64/sdk/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/ +./scripts/feeds update -a +make package//compile +``` + +## Documentation + +- **Flint1 SDK Research:** `agent-notes/flint1-sdk-research.md` +- **Flint1 Build Results:** `agent-notes/glax1800-build-results.md` +- **Implementation Plan:** `.gemini/antigravity/brain/.../implementation_plan.md` + +## Build Scripts + +- `build-ipk.sh` - Create .ipk packages +- `build-verified-ipk.sh` - Build with verification +- `generate-index.sh` - Generate opkg repository index +- `upload-repo.sh` - Upload to repository server + +## Active Toolchains + +**Flint1:** musl.cc armv7l-linux-musleabihf (GCC 11.2.1) +**Flint2:** OpenWrt mediatek-filogic SDK (GCC 14.3.0) diff --git a/docs/README-dummy-pkg.md b/docs/README-dummy-pkg.md new file mode 100755 index 0000000..17aaa30 --- /dev/null +++ b/docs/README-dummy-pkg.md @@ -0,0 +1,121 @@ +# Dummy OPKG Package - hello-opkg + +## Package Information +- **Name:** hello-opkg +- **Version:** 1.0.0-1 +- **Architecture:** all (universal) +- **File:** `packages/hello-opkg_1.0.0-1_all.ipk` +- **Size:** ~812 bytes + +## What It Does +This is a minimal test package that installs a simple shell script at `/usr/bin/hello-opkg`. + +When executed, the script prints: +``` +Hello from the opkg dummy package! +Package: hello-opkg v1.0.0 +This package was installed successfully. +``` + +## Package Structure +The package follows standard IPK format: +``` +hello-opkg_1.0.0-1_all.ipk +β”œβ”€β”€ debian-binary (format version: 2.0) +β”œβ”€β”€ control.tar.gz (package metadata) +β”‚ └── control +└── data.tar.gz (installed files) + └── usr/bin/hello-opkg +``` + +## Installation +On an OpenWRT device: +```bash +opkg install hello-opkg_1.0.0-1_all.ipk +``` + +Or from your repository: +```bash +opkg update +opkg install hello-opkg +``` + +## Testing +```bash +# Run the installed script +hello-opkg + +# Check package info +opkg status hello-opkg + +# List installed files +opkg files hello-opkg +``` + +## Removal +```bash +opkg remove hello-opkg +``` + +## Troubleshooting "Malformed Package" Error + +If you encounter a "malformed package" error, try: + +1. **Check opkg version**: Some older opkg versions are picky about format + ```bash + opkg --version + ``` + +2. **Verify package structure**: + ```bash + ar t hello-opkg_1.0.0-1_all.ipk + # Should show: debian-binary, control.tar.gz, data.tar.gz + ``` + +3. **Check file permissions**: The script must be executable + ```bash + tar tzf <(ar p hello-opkg_1.0.0-1_all.ipk data.tar.gz) + ``` + +4. **Try verbose installation**: + ```bash + opkg install -V3 hello-opkg_1.0.0-1_all.ipk + ``` + +5. **Inspect control file**: + ```bash + ar p hello-opkg_1.0.0-1_all.ipk control.tar.gz | tar xzO ./control + ``` + +## Rebuilding the Package + +Use the included `build-ipk.sh` script: + +```bash +# Create package structure +mkdir -p my-package/CONTROL my-package/usr/bin + +# Create control file +cat > my-package/CONTROL/control << 'EOF' +Package: my-package +Version: 1.0.0 +Architecture: all +Maintainer: Your Name +Description: My test package +EOF + +# Add your files +echo '#!/bin/sh' > my-package/usr/bin/my-script +echo 'echo "Hello!"' >> my-package/usr/bin/my-script +chmod +x my-package/usr/bin/my-script + +# Build it +./build-ipk.sh my-package packages/ +``` + +## Use Cases +- Testing repository setup +- Verifying package index generation +- Testing upload scripts +- Debugging package installation issues +- CI/CD pipeline testing diff --git a/docs/agent-notes/reorganize_openwrt.py b/docs/agent-notes/reorganize_openwrt.py new file mode 100755 index 0000000..ef00c38 --- /dev/null +++ b/docs/agent-notes/reorganize_openwrt.py @@ -0,0 +1,53 @@ +import os +import shutil + +BASE_DIR = "/home/user/Public/Projects/OpenWRT" + +STRUCTURE = { + "sdk": [ + "openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64" + ], + "sources": [ + "btop" + ], + "packages": [ + "btop-flint2-package", + "btop-openwrt-package" + ], + "bin": [ + "btop-flint2" + ] +} + +def reorganize(): + print(f"Reorganizing {BASE_DIR}...") + + # Create new directories + for folder in STRUCTURE.keys(): + path = os.path.join(BASE_DIR, folder) + if not os.path.exists(path): + print(f"Creating directory: {path}") + os.makedirs(path) + else: + print(f"Directory exists: {path}") + + # Move items + for folder, items in STRUCTURE.items(): + dest_dir = os.path.join(BASE_DIR, folder) + for item in items: + src_path = os.path.join(BASE_DIR, item) + dest_path = os.path.join(dest_dir, item) + + if os.path.exists(src_path): + print(f"Moving {item} to {folder}/...") + try: + shutil.move(src_path, dest_path) + except Exception as e: + print(f"Error moving {item}: {e}") + else: + print(f"Warning: Source not found: {item}") + + print("Reorganization complete.") + +if __name__ == "__main__": + reorganize() diff --git a/docs/ax1800-firmware-guide.md b/docs/ax1800-firmware-guide.md new file mode 100755 index 0000000..fa770df --- /dev/null +++ b/docs/ax1800-firmware-guide.md @@ -0,0 +1,57 @@ +# GL-AX1800 (Flint) Firmware Research & Guide + +This guide provides current (2024/2025) information on building and downloading firmware for the GL.iNet AX1800 (Flint). + +## πŸ› οΈ Hardware Specifications +- **SoC**: Qualcomm IPQ6000 (A7 is for ipq40xx, this is A53) +- **Architecture**: `aarch64_cortex-a53` +- **OpenWrt Target**: `qualcommax / ipq60xx` (Note: older models use `ipq40xx`, but the Flint requires `qualcommax`) + +## 🧱 Building with `gl-infra-builder` + +The official tool used by GL.iNet to build firmware is `gl-infra-builder`. + +### ⚠️ Current Status (2024/2025) +- **Codeaurora Shutdown**: Many older SDKs depend on `source.codeaurora.org`, which is now offline. This causes build failures in the `qca-nss-client` and related packages. +- **Access**: GL.iNet has moved the repository to a more private or restricted access model in some cases, often returning 404s on previous public links. + +### Build Steps (Updated) +1. **Setup**: + ```bash + python3 setup.py -c configs/config-wlan-ap.yml + cd wlan-ap/openwrt + ``` +2. **Configure**: + Use the `barebones_ax1800` profile for a clean OpenWrt experience without the GL.iNet proprietary UI: + ```bash + ./scripts/gen_config.py target_wlan_ap-gl-ax1800 barebones_ax1800 + ``` +3. **Compile**: + ```bash + make V=s -j$(nproc) + ``` + +## πŸ“¦ Firmware Inventory + +The following firmwares are organized in the `firmware/flint1/` directory. + +### Official GL.iNet (OpenWrt 21.02 based) +- **Latest Stable**: 4.6.8 +- **Latest Beta**: 4.8.3 +- **Primary Use**: Best for stability and proprietary features (VPN performance, specific hardware drivers). + +### Vanilla OpenWrt (Mainline) +- **Status**: Currently only available via **Snapshots**. There is no official 22.03 or 23.05 stable release build for the GL-AX1800 on `downloads.openwrt.org` yet. +- **Snapshot Path**: `qualcommax/ipq60xx` +- **Pros**: Latest kernel (6.x), pure OpenWrt experience. +- **Cons**: No LuCI by default in many snapshots; potentially unstable. + +### ImmortalWrt (Community Fork) +- **Status**: Stable builds exist for some models, but AX1800 is primarily in **Snapshots**. +- **Pros**: Often includes more "Chinese-friendly" packages and performance tweaks. + +## πŸ“‚ Downloaded Files +Local copies are stored in: +- `firmware/flint1/official/`: 4.6.8 stable, 4.8.3 beta +- `firmware/flint1/vanilla/snapshots/`: Mainline OpenWrt +- `firmware/flint1/immortalwrt/`: ImmortalWrt snapshots diff --git a/docs/backporting-research.md b/docs/backporting-research.md new file mode 100755 index 0000000..0b46370 --- /dev/null +++ b/docs/backporting-research.md @@ -0,0 +1,76 @@ +# OpenWRT Package Backporting Guide + +## Overview +Backporting allows you to use a newer version of a package (from OpenWRT `master` or a newer release) on an older stable release (e.g., OpenWRT 21.02). + +## The Process + +1. **Prepare Build Environment** + - You need the **SDK** (Software Development Kit) for your **Target** version (the older version you are running). + - *Example:* If using OpenWRT 21.02 on x86/64, download the OpenWRT 21.02 SDK for x86/64. + +2. **Locate Source Package** + - Find the package in the *newer* source tree (e.g., GitHub `openwrt/packages` repository, `master` branch). + - Package definition consists of: + - `Makefile` + - `patches/` (directory, if any) + - `files/` (directory, optional configuration files) + +3. **Copy to SDK** + - Copy the package directory from the source to your SDK's `package/` directory. + - *Alternative:* Add the newer feed to `feeds.conf.default` but pin it to a specific commit (more complex due to dependencies). Manual copy is often easier for single packages. + +4. **Adjust Dependencies** + - Check `DEPENDS` line in `Makefile`. + - Older SDKs might have older libraries. + - *If dependency is missing:* You must backport the dependency package too. + - *If dependency is tool old:* You might need to relax the requirement or backport the library (risky). + +5. **Build** + - Run `make menuconfig` and select the package. + - Run `make package/refined-package/compile`. + +## Example: Backporting `elinks` + +**Scenario:** Backporting `elinks` from Master to OpenWRT 21.02. + +**1. Get 21.02 SDK:** +```bash +wget https://downloads.openwrt.org/releases/21.02.7/targets/x86/64/openwrt-sdk-21.02.7-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz +tar xJsOf openwrt-sdk-*.tar.xz +cd openwrt-sdk-* +``` + +**2. Get `elinks` from Master:** +You don't need the whole master repo, just the folder. +```bash +svn export https://github.com/openwrt/packages/trunk/net/elinks package/elinks +# OR strictly from git +git clone https://github.com/openwrt/packages.git /tmp/packages +cp -r /tmp/packages/net/elinks package/ +``` + +**3. Check Makefile (`package/elinks/Makefile`):** +```makefile +PKG_NAME:=elinks +PKG_VERSION:=0.16.1.1 # Newer version +... +DEPENDS:=+libopenssl +libexpat ... +``` +*Verification:* Check if `libopenssl` and `libexpat` are functional in your SDK. Usually they are standard. + +**4. Build:** +```bash +./scripts/feeds update -a +./scripts/feeds install -a +make menuconfig +# Select Network -> Web Servers/Browsers -> elinks +make package/elinks/compile V=s +``` + +**5. Result:** +The new IPK will be in `bin/packages/x86_64/base/elinks_*.ipk`. + +## Common Pitfalls +- **Kernel Dependencies:** Kmods are hard to backport (require kernel version match). Avoid backporting kernel modules if possible. +- **Library ABIs:** If a package needs `libfoo.so.2` but your system has `libfoo.so.1`, you need to backport the library, which might break other things. Static linking can sometimes solve this. diff --git a/docs/barebones-image-research.md b/docs/barebones-image-research.md new file mode 100755 index 0000000..e4eb15b --- /dev/null +++ b/docs/barebones-image-research.md @@ -0,0 +1,39 @@ +# Barebones OpenWrt Image Research (GL-AX1800) + +## Objectives +- Create a stripped-down image for GL-AX1800 (Flint 1). +- Accessible via SSH. +- No LuCI or GL.iNet UI. +- Use `gl-infra-builder` for hardware-specific optimizations. +- Ensure U-Boot compatible image output. + +## Tool Selection +- **Builder:** `FUjr/gl-infra-builder`. +- **Base Config:** `config-wlan-ap.yml` (Qualcomm SDK based). +- **Target Profile:** `target_wlan_ap-gl-ax1800`. + +## Findings +### 1. Reorganization +- Workspace reorganized into `firmware/`, `sdk/`, `docs/`, `scripts/`, `packages/`, `repo/`. +- Created `PROJECT_INDEX.md` as a master reference. + +### 2. gl-infra-builder Logic +- The builder uses YAML profiles in the `profiles/` directory. +- `gen_config.py` merges multiple profiles. +- Standard GL.iNet profiles (`glinet_ax1800.yml`) include a heavy set of proprietary services. +- A "Barebones" profile can be created by overriding these with `-package` or `CONFIG_PACKAGE_xxx=n` in the `diffconfig` section. + +### 3. OpenWrt Snapshots & Upgrade Path +- **V21.02 (GL 4.x):** Current base for most GL firmware. +- **V23.05:** Transitional, used `ipq40xx` target. +- **Master/V24/V25:** Native `qualcommax/ipq60xx` target (merged March 2025). +- **Upgrade Path:** + - From GL Stock -> Vanilla: Flash `factory.ubi` via U-Boot recovery (192.168.1.1). + - From Vanilla -> Newer Vanilla: Use `sysupgrade.bin`. + - **Note:** Partition layouts might change between 21.02 and 24.x. Using the `factory.ubi` is safest for major transitions. + +### 4. Barebones Configuration Plan +- Include `dropbear` (SSH), `opkg` (Package management). +- Include essential HW drivers: `kmod-gl-sdk4-hw-info`, `gl-sdk4-led`. +- Explicitly disable `luci`, `nginx`, and all `gl-sdk4-ui-*` packages. +- Ensure `ath11k` drivers are included for Wi-Fi (if using OpenWrt master) or the proprietary QSDK drivers (if using the builder). diff --git a/docs/cross_compilation_notes.md b/docs/cross_compilation_notes.md new file mode 100755 index 0000000..45046ba --- /dev/null +++ b/docs/cross_compilation_notes.md @@ -0,0 +1,36 @@ +# Cross-Compilation Notes + +## GL-iNet Flint 2 (GL-MT6000) +- **SoC**: MediaTek MT7986 (Filogic 830) +- **CPU**: Quad-core ARM Cortex-A53 @ 2.0GHz +- **Architecture**: `aarch64` +- **Target**: `mediatek/filogic` +- **SDK Path**: `../openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64` +- **Toolchain**: `gcc-14.3.0_musl` + +### Compiling for Flint 2 +1. Source the SDK environment (if using the full SDK wrapper) or add the staging_dir toolchain to PATH. +2. Export `STAGING_DIR`: + ```bash + export STAGING_DIR=/home/sapient/Projects/OpenWRT/openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/staging_dir + ``` +3. Add toolchain bin to PATH: + ```bash + export PATH=$PATH:$STAGING_DIR/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/bin + ``` +4. Compile with `aarch64-openwrt-linux-gcc`. + +## GL-iNet Flint 1 (GL-AX1800) +- **SoC**: Qualcomm IPQ6000 +- **CPU**: Quad-core ARM Cortex-A53 @ 1.2GHz +- **Architecture**: `aarch64` +- **Target**: `ipq807x/generic` or `ipq807x/ipq60xx` (check OpenWRT target mapping) + +### Compiling for Flint 1 +- Similar to Flint 2, this is an `aarch64` architecture. +- CAUTION: while the architecture is the same (`aarch64`), kernel headers and libc versions might differ if using a different OpenWRT version. +- Ideally, obtain the SDK for `ipq807x` if the application relies on kernel interfaces or specific libraries. for generic userspace apps, the Flint 2 toolchain *might* work but is not guaranteed. + +## General Notes +- Both devices are `aarch64`. +- Generic static binaries compiled for `aarch64-linux-musl` should likely work on both. diff --git a/docs/firmware-inventory.md b/docs/firmware-inventory.md new file mode 100755 index 0000000..ec447ea --- /dev/null +++ b/docs/firmware-inventory.md @@ -0,0 +1,56 @@ +# GL-AX1800 (Flint) Firmware Inventory + +This document catalogs all downloaded firmware images for the GL-AX1800 (Flint). + +## 🎯 AX1800 (IPQ6000 / qualcommax/ipq60xx) + +### GL.iNet Official Firmware +**Location**: `firmware/flint1/glinet-official/` + +- **gl-ax1800-4.6.8-stable.tar** (8.6M) - Latest stable release (OpenWrt 21.02-based) +- **gl-ax1800-4.6.8-uboot.img** - U-Boot recovery image for 4.6.8 +- **gl-ax1800-4.8.3-beta.tar** - Beta testing version +- **ax1800-4.8.3_beta1.img** - Beta U-Boot recovery + +### OpenWrt Official (Snapshots) +**Location**: `firmware/flint1/openwrt-official/snapshots/` + +- **openwrt-snapshot-factory.bin** (13M) - Latest mainline snapshot (factory install) +- **openwrt-snapshot-sysupgrade.bin** (12M) - Latest mainline snapshot (sysupgrade) + +**Location**: `firmware/flint1/openwrt-official/` +- **openwrt-master-factory.bin** (13M) - Master branch build +- **openwrt-master-sysupgrade.bin** (12M) +- **openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin** (13M) +- **openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin** (12M) + +### OpenWrt 25.12-rc2 +**Location**: `firmware/flint1/openwrt-official/25.12-rc2/` + +- **openwrt-25.12.0-rc2-factory.bin** - Release candidate 2 factory image +- **openwrt-25.12.0-rc2-sysupgrade.bin** - Release candidate 2 sysupgrade +- **openwrt-25.12.0-rc2-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.ubi** - UBI variant + +### ImmortalWrt +**Location**: `firmware/flint1/immortalwrt/` + +- **immortalwrt-snapshot-factory.bin** (13M) - ImmortalWrt snapshot build +- **immortalwrt-snapshot-sysupgrade.bin** (12M) + +### Community Builds (KWRT) +**Location**: `firmware/flint1/community-kwrt/` + +- **kwrt-01.10.2026-factory.bin** - KWRT community build + +--- + +## Summary + +| Source | Architecture | Device | Firmware Count | +|:-------|:-------------|:-------|:---------------| +| **qualcommax/ipq60xx** | aarch64_cortex-a53 | GL-AX1800 | 13 images | + +### Recommended Images +- **Production**: `gl-ax1800-4.6.8-stable.tar` (GL.iNet official) +- **Latest Features**: `openwrt-snapshot-factory.bin` (OpenWrt mainline snapshot) +- **Release Candidate**: `openwrt-25.12.0-rc2-factory.bin` (near-stable) diff --git a/docs/flint1-firmware-options.md b/docs/flint1-firmware-options.md new file mode 100755 index 0000000..e9df8d3 --- /dev/null +++ b/docs/flint1-firmware-options.md @@ -0,0 +1,319 @@ +# GL-AX1800 (Flint1) Firmware Options Research + +**Date:** 2026-01-12 +**Device:** GL-AX1800 (Flint 1) +**Current Firmware:** ApNos-3c11d1c4-devel, OpenWrt 23.05-SNAPSHOT +**Architecture:** ARMv7 rev 4 (v7l), IPQ6000 SoC + +--- + +## Executive Summary + +The GL-AX1800 has **three main firmware options** available in 2025-2026: + +1. **GL.iNet Official Firmware** (v4.6-4.8) - Custom OpenWrt with proprietary features +2. **Vanilla OpenWrt** (23.05.x stable, master snapshots) - Official community builds +3. **Alternative Firmware** (DD-WRT potential, NO Tomato support) + +**Key Finding:** GL-AX1800 was officially merged into OpenWrt master in March 2025, now under the `qualcommax/ipq60xx` target (NOT `ipq40xx` as in older 23.05 releases). + +--- + +## Option 1: GL.iNet Official Firmware + +### Latest Versions + +| Version | Status | Release Date | Notes | +|---------|--------|--------------|-------| +| **4.8.x** | Beta/Upcoming | Q3 2025 (planned) | Major VPN & UI improvements | +| **4.7.0** | **Pulled/Problematic** | March 2025 | Wi-Fi instability reported | +| **4.6.11** | **Stable (Current)** | 2024-2025 | Most stable production version | + +### Version 4.8.x Features (Upcoming) + +**Major Improvements:** +- **Multiple VPN instances** - Run multiple VPN clients simultaneously in policy mode +- **OpenVPN DCO** (Data Plane Offload) - Hardware-accelerated OpenVPN on AX1800 +- **Rebuilt cellular interface** - Better support for LTE/5G modems +- **Redesigned toggle switch** - Control Repeater, Wi-Fi, VPN, or LED +- **One-click log submission** - Improved troubleshooting +- **IPv6 VPN optimization** +- **Categorized log search** + +**Status:** Beta testing started April 2025, stable Q3 2025 +**AX1800 Support:** βœ… Confirmed + +**Concerns:** +- Early 4.8.0 beta had VPN traffic leak issues (expected fix in 4.8.1) +- Beta firmware may have stability issues + +--- + +### Version 4.7.0 (NOT RECOMMENDED) + +**Features:** +- New device setup wizard +- Enhanced WireGuard + AzireVPN integration +- Control D DNS support +- Improved repeater privacy (random MAC) + +**Problems:** +- ❌ **Wi-Fi instability** - Users reported connection drops +- ❌ Appears to have been **pulled/withdrawn** from download center +- ❌ Users downgraded to 4.6.8 for stability +- ❌ Missing package repositories (4.7.x) + +**Status:** **Avoid** - Known issues, likely discontinued + +--- + +### Version 4.6.x (STABLE - RECOMMENDED) + +**Latest:** 4.6.11 + +**Features:** +- Stable repeater mode enhancements +- Proven reliability +- Full package repository support + +**Security Note:** +- CVE-2025-67091 (moderate severity) in 4.6.4 and 4.6.8 +- Vulnerability in custom opkg wrapper script +- Fixed in later versions + +**Download:** https://dl.gl-inet.com/?model=ax1800 + +**Recommendation:** Use 4.6.11 until 4.8.x is proven stable + +--- + +## Option 2: Vanilla OpenWrt + +### Target Architecture Change + +**IMPORTANT:** The GL-AX1800 target changed between OpenWrt versions: + +| OpenWrt Version | Target | Architecture | +|-----------------|--------|--------------| +| **21.02** | `ipq40xx/generic` | ARMv7 (legacy support) | +| **23.05** | `ipq40xx/generic` | ARMv7 (transitional) | +| **Master/Snapshots** | **`qualcommax/ipq60xx`** | ARMv7 (proper IPQ6000 support) | + +**Explanation:** Earlier versions used the `ipq40xx` target as a workaround. Official IPQ6000 support was merged into OpenWrt master in **March 2025** under the new `qualcommax/ipq60xx` target. + +--- + +### 23.05.x Stable (What You're Running) + +**Latest:** 23.05.5 (September 2024) + +**Specs:** +- GCC 12.3.0 +- Target: `ipq40xx/generic` +- SDK Downloaded: βœ… `/flint1-armv7/sdk/openwrt-23.05-sdk/` + +**Download Paths:** +- Images: `https://downloads.openwrt.org/releases/23.05.5/targets/ipq40xx/generic/` +- SDK: βœ… Already downloaded + +**Pros:** +- βœ… Stable, tested release +- βœ… SDK/toolchain available +- βœ… Matches your current firmware base + +**Cons:** +- ⚠️ Uses legacy `ipq40xx` target (not native IPQ6000) +- ⚠️ Older kernel/packages vs snapshots + +--- + +### Master Snapshots (Latest Development) + +**Target:** `qualcommax/ipq60xx` (NEW as of March 2025) + +**Specs:** +- **GCC:** 14.3.0 (latest) +- **Kernel:** Linux 6.x (newest) +- **Features:** Bleeding-edge OpenWrt +- **SDK:** Available with GCC 14.3.0 + +**Download Paths:** +- **Images:** `https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/` +- **SDK:** `https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64.tar.zst` + +**Available Images:** +``` +openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin +openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin +``` + +**Firmware Selector:** https://firmware-selector.openwrt.org/ +(Search: "GL-AX1800", select "SNAPSHOT") + +**Pros:** +- βœ… **Native IPQ6000 support** (`qualcommax/ipq60xx`) +- βœ… **GCC 14.3.0** - Best C++23 support +- βœ… Latest kernel, drivers, features +- βœ… Active development, frequent updates +- βœ… Newer `ath11k` Wi-Fi driver + +**Cons:** +- ⚠️ **No LuCI web interface** by default (install via SSH) +- ⚠️ Development builds - less stable than releases +- ⚠️ `ath11k` open-source driver uses more RAM (~380MB free vs 512MB total) +- ⚠️ Doesn't include all Qualcomm proprietary SDK components +- ⚠️ Daily builds - version changes constantly + +**RAM Consideration:** +- GL.iNet firmware: Proprietary drivers, more free RAM +- Vanilla OpenWrt: Open-source `ath11k`, ~130MB used by driver firmware + +--- + +### Installation Methods + +**For Factory/Stock:** +``` +openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin +``` + +**For OpenWrtβ†’OpenWrt:** +``` +openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin +``` + +**Via U-Boot:** Flash at router boot (advanced users) + +--- + +## Option 3: Alternative Firmware + +### DD-WRT + +**Status:** **Potentially Supported** (unconfirmed) + +**Evidence:** +- DD-WRT database lists: `glinet-gl-ax1800 build 61557 20250531` +- Build number suggests May 31, 2025 release +- **NOT verified** - check DD-WRT forums for actual availability + +**Download (if available):** https://dd-wrt.com/support/router-database/ + +**Pros:** +- Different feature set than OpenWrt +- May have better QoS/VPN features + +**Cons:** +- ⚠️ **Unverified support** - database may be outdated +- ⚠️ DD-WRT warns their database can have inaccurate entries +- ⚠️ Less community support for this device +- ⚠️ Risk of bricking if not officially supported + +**Recommendation:** **Wait for confirmation** from DD-WRT community before attempting + +--- + +### Tomato / Tomato64 + +**Status:** ❌ **NO SUPPORT** + +- Tomato64 lists support for ARM64 devices like GL-MT6000 +- **GL-AX1800 is NOT listed** +- No indication of IPQ6000 support in Tomato ecosystem + +**Recommendation:** Not an option for this device + +--- + +### Other Firmware Options + +- **ImmortalWrt** - OpenWrt fork with Chinese focus, likely has GL-AX1800 support +- **OpenWISP** - Network management platform (not firmware replacement) +- **LEDE** - Merged back into OpenWrt in 2018 (no longer separate) + +--- + +## Comparison Matrix + +| Feature | GL.iNet 4.6.11 | GL.iNet 4.8 (Beta) | OpenWrt 23.05.5 | OpenWrt Master | DD-WRT | +|---------|----------------|--------------------|-----------------|--------------------|--------| +| **Stability** | ⭐⭐⭐⭐⭐ | ⭐⭐⚠️ Beta | ⭐⭐⭐⭐ | ⭐⭐⭐ Snapshots | ❓ Unknown | +| **Features** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ❓ | +| **GCC Version** | ~8.x-12.x | ~12.x | 12.3.0 | **14.3.0** | N/A | +| **Target** | Custom | Custom | `ipq40xx` | **`qualcommax/ipq60xx`** | Custom | +| **RAM Usage** | Better (proprietary) | Better | Higher (ath11k) | Higher (ath11k) | ❓ | +| **Updates** | Quarterly | TBD | Periodic | **Daily** | Rare | +| **LuCI Web UI** | Custom | Custom | βœ… Included | ❌ Install manually | βœ… | +| **Support** | GL.iNet + Community | GL.iNet + Community | Official OpenWrt | Official OpenWrt | DD-WRT forums | + +--- + +## Recommendations + +### For Stability & Features +**Use GL.iNet 4.6.11** +- Most stable current option +- All GL.iNet features (VPN, AdGuard, etc.) +- Good for production use + +### For Latest OpenWrt Features +**Use OpenWrt Master Snapshots** +- Native `qualcommax/ipq60xx` support +- GCC 14.3.0 for building packages +- Latest kernel & drivers +- **BUT:** Requires SSH comfort, less stable + +### For SDK Development +**You Already Have:** +- βœ… OpenWrt 23.05.5 SDK (GCC 12.3.0) - Downloaded +- βœ… musl.cc ARMv7 toolchain (GCC 11.2.1) - Downloaded + +**To Add:** +```bash +# Download latest snapshot SDK +cd flint1-armv7/sdk +wget https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64.tar.zst +``` + +**GCC 14.3.0 = Best C++23 support for btop compilation** + +--- + +## When to Upgrade + +### Stick with Current (23.05-SNAPSHOT) If: +- βœ… Everything works +- βœ… You value stability +- βœ… You already have SDK for development + +### Upgrade to GL.iNet 4.6.11 If: +- βœ… Want GL.iNet features (VPN, AdGuard, GUI) +- βœ… Need stable production firmware +- βœ… Want long-term support + +### Upgrade to OpenWrt Master If: +- βœ… Want bleeding-edge features +- βœ… Comfortable with SSH/command line +- βœ… Don't mind installing LuCI manually +- βœ… Want native `qualcommax/ipq60xx` support + +### Wait for GL.iNet 4.8.x If: +- βœ… Want multiple VPN instances +- βœ… Need OpenVPN DCO performance +- βœ… Can wait for stable release (Q3 2025) + +--- + +## Summary + +**You have excellent options:** + +1. **Stay Current** - Your 23.05-SNAPSHOT works, SDK available +2. **GL.iNet 4.6.11** - Most stable GL.iNet firmware +3. **OpenWrt Snapshots** - Latest qualcommax/ipq60xx with GCC 14.3.0 +4. **GL.iNet 4.8.x** - Wait for stable release (Q3 2025) + +**For development:** You're well-equipped with 23.05.5 SDK (GCC 12.3.0). Consider adding snapshot SDK (GCC 14.3.0) for maximum C++23 compatibility. + +**DD-WRT:** Unverified - wait for community confirmation +**Tomato:** Not supported for this device diff --git a/docs/flint1-sdk-research.md b/docs/flint1-sdk-research.md new file mode 100755 index 0000000..739ed6c --- /dev/null +++ b/docs/flint1-sdk-research.md @@ -0,0 +1,262 @@ +# GL-AX1800 (Flint1) SDK Research and Cross-Compilation Strategy + +**Date:** 2026-01-11 +**Device:** GL-AX1800 (Flint 1) +**SoC:** Qualcomm IPQ6000 (Quad-core ARM @ 1.2GHz) + +## Architecture Confirmation (CORRECTED) + +> [!IMPORTANT] +> **Confirmed from actual hardware:** +> - **Flint1 (GL-AX1800)**: ARMv7 rev 4 (v7l) - **32-bit ARM** +> - **Flint2 (GL-MT6000)**: ARMv8 rev 4 (v8l) - **64-bit ARM (aarch64)** +> +> These are **different architectures** and require **separate binaries**. + +### Architecture Details + +**GL-AX1800 (Flint1):** +- CPU: ARMv7 Processor rev 4 (v7l) +- Instruction set: 32-bit ARM +- Typical target triplet: `arm-linux-musleabihf` or `armv7l-linux-musleabihf` + +**GL-MT6000 (Flint2):** +- CPU: ARMv8 Processor rev 4 (v8l) +- Instruction set: 64-bit ARM (aarch64) +- Typical target triplet: `aarch64-linux-musl` + +--- + +## SDK Options for GL-AX1800 (ARMv7) + +### Option 1: Pre-built musl.cc Toolchain (RECOMMENDED for Quick Start) + +**Source:** https://musl.cc/ + +#### Relevant Toolchains +- `armv7l-linux-musleabihf-cross.tgz` (ARMv7, hard-float) +- `arm-linux-musleabihf-cross.tgz` (Generic ARM, hard-float) + +**Download:** +```bash +wget https://musl.cc/armv7l-linux-musleabihf-cross.tgz +tar -xzf armv7l-linux-musleabihf-cross.tgz +export PATH=$PWD/armv7l-linux-musleabihf-cross/bin:$PATH +``` + +#### Advantages +- Quick setup (download and extract) +- Modern GCC (13.2+) with C++23 support +- Proven for static binary compilation +- Small download (~40-50MB compressed) + +#### Disadvantages +- Not optimized for IPQ6000 specifically +- Generic ARMv7 (not Cortex-A7 specific) + +--- + +### Option 2: musl-cross-make (Build Your Own) + +**Source:** https://github.com/richfelker/musl-cross-make + +#### Configuration for ARMv7 +```makefile +TARGET = armv7l-linux-musleabihf +# or: arm-linux-musleabihf +GCC_VER = 14.2.0 +MUSL_VER = 1.2.5 +LINUX_VER = 6.6.y +GCC_CONFIG += --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard +``` + +#### Advantages +- Full control over toolchain versions +- Can build latest GCC 14+ for C++23 +- Optimize for Cortex-A7 specifically +- Creates musl-based static-friendly toolchain + +#### Disadvantages +- Time-consuming build (30-60 minutes) +- Requires build dependencies +- More complex setup + +--- + +### Option 3: GL.iNet SDK (NOT RECOMMENDED) + +**SDK:** `ipq807x-2102` +**GCC:** 5.5.0 (Too old) +**Architecture:** arm_cortex-a7 (32-bit) + +#### Why Not Use This? +- ❌ GCC 5.5.0 cannot compile C++23 (btop) +- ❌ Outdated toolchain from ~2017 +- ❌ Build failures documented in `agent-notes/glax1800-build-results.md` +- βœ… Correct architecture (ARMv7), but toolchain too old + +--- + +## Compilation Requirements + +### btop Requirements + +**Language:** C++23 +**Minimum GCC:** 11 (experimental), **14+ recommended** (full support) +**Dependencies:** None (headers only) +**Build System:** Make or CMake +**Static Linking:** Fully supported with musl + +#### Build Strategy +```bash +# With OpenWrt SDK +make STATIC=true VERBOSE=true CXX=aarch64-openwrt-linux-musl-g++ \ + CXXFLAGS="-static -std=c++23 -O3" LDFLAGS="-static" +``` + +--- + +### mosh Requirements + +**Language:** C++14 +**Build System:** Autotools (./configure) +**Dependencies (must be cross-compiled):** +- **protobuf** 3.x (C++ library, requires host protoc) +- **ncurses** 6.x (terminfo) +- **OpenSSL** 1.1.x (or omit with `--without-crypto`) +- **zlib** (compression) + +#### Build Strategy (Multi-Stage) + +1. **Build host protoc** (x86_64) + ```bash + cd protobuf-3.17.3 + ./configure --prefix=/usr/local + make && sudo make install + ``` + +2. **Cross-compile protobuf libraries** + ```bash + ./configure --host=aarch64-linux-musl --prefix=$PWD/sysroot \ + --with-protoc=/usr/local/bin/protoc \ + CXXFLAGS="-static" LDFLAGS="-static" + make && make install + ``` + +3. **Cross-compile ncurses** + ```bash + ./configure --host=aarch64-linux-musl --prefix=$PWD/sysroot \ + --without-shared --with-normal --without-debug + make && make install + ``` + +4. **Build mosh** (static) + ```bash + ./configure --host=aarch64-linux-musl \ + PKG_CONFIG_PATH=$PWD/sysroot/lib/pkgconfig \ + CXXFLAGS="-static" LDFLAGS="-static -pthread" \ + --without-crypto # Optional: skip OpenSSL + make + ``` + +#### Existing Build Environment +The `src/mosh/` directory already has: +- `env.sh` - Cross-compilation environment +- `sysroot/` - Custom libraries +- `host_protoc/` - Host protobuf compiler +- Built static binaries (for aarch64) + +βœ… **This can likely be reused or adapted!** + +--- + +## Recommended Approach (CORRECTED) + +### Phase 1: Toolchain Setup + +**Use musl.cc pre-built ARMv7 toolchain for fastest results:** + +```bash +cd /home/user/Public/Projects/OpenWRT/sdk/ + +# Download ARMv7 hard-float toolchain +wget https://musl.cc/armv7l-linux-musleabihf-cross.tgz +tar -xzf armv7l-linux-musleabihf-cross.tgz + +# Add to PATH +export PATH=$PWD/armv7l-linux-musleabihf-cross/bin:$PATH + +# Verify +armv7l-linux-musleabihf-gcc --version +``` + +--- + +### Phase 2: Build btop for ARMv7 + +```bash +cd /home/user/Public/Projects/OpenWRT/src/btop + +# Clean previous builds +make clean + +# Build static for ARMv7 +make STATIC=true \ + CXX=armv7l-linux-musleabihf-g++ \ + CXXFLAGS="-static -std=c++23 -O3 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" \ + LDFLAGS="-static" + +# Verify architecture +file bin/btop +# Should show: ELF 32-bit LSB executable, ARM, EABI5 + +# Copy to flint1 binaries +cp bin/btop /home/user/Public/Projects/OpenWRT/binaries/flint1/btop/ +``` + +--- + +### Phase 3: Build mosh for ARMv7 + +Mosh requires cross-compiling dependencies. Two options: + +#### Option A: Adapt Existing Environment + +The `src/mosh/` directory has a working setup for aarch64. Update it for ARMv7: + +```bash +cd /home/user/Public/Projects/OpenWRT/src/mosh + +# Update environment +export PATH=/path/to/armv7l-linux-musleabihf-cross/bin:$PATH +export CC=armv7l-linux-musleabihf-gcc +export CXX=armv7l-linux-musleabihf-g++ +export AR=armv7l-linux-musleabihf-ar +export RANLIB=armv7l-linux-musleabihf-ranlib + +# Rebuild protobuf for ARMv7 +# (Host protoc already built) + +# Configure mosh +./configure --host=armv7l-linux-musleabihf \ + CXXFLAGS="-static" \ + LDFLAGS="-static -pthread" \ + --without-crypto + +make clean && make +``` + +#### Option B: Fresh Build + +Follow multi-stage process from research document (protobuf β†’ ncurses β†’ mosh). + +--- + +## Next Steps + +1. βœ… **Verify architecture** - Confirmed ARMv7 (32-bit ARM) vs ARMv8 (aarch64) +2. ⏭️ **Download ARMv7 toolchain** - Use musl.cc armv7l-linux-musleabihf +3. ⏭️ **Build btop** - Static ARMv7 binary with modern GCC +4. ⏭️ **Build mosh** - Cross-compile dependencies + static linking +5. ⏭️ **Create .ipk packages** - Package for opkg installation +6. ⏭️ **Test on hardware** - Verify on actual GL-AX1800 diff --git a/docs/future-improvements-ax1800.md b/docs/future-improvements-ax1800.md new file mode 100755 index 0000000..8f79f20 --- /dev/null +++ b/docs/future-improvements-ax1800.md @@ -0,0 +1,25 @@ +# Future Improvements for AX1800 Barebones Firmware + +After the initial successful build, several areas can be optimized to make the "Barebones" experience even better. + +## 1. Performance & Resource Management +- **Zram Integration**: Enable `zram-swap` by default to better handle memory-intensive tasks like package updates or heavy VPN usage. +- **Kernel Slimming**: Review the default `ipq60xx` kernel configuration and disable unused filesystem drivers or legacy protocols to reduce the kernel footprint. +- **SQM (Smart Queue Management)**: Add `luci-app-sqm` and `cake` for better bufferbloat management. + +## 2. Security Enhancements +- **SSH Hardening**: Provide a profile that disables password authentication by default and injects a provided SSH key. +- **WireGuard Optimization**: Ensure `kmod-wireguard` is optimized for the IPQ6000's SIMD instructions if available. +- **DNS-over-HTTPS/TLS**: Include `https-dns-proxy` or `unbound` for encrypted DNS. + +## 3. Storage & Partitioning +- **U-Boot Custom Layout**: Research if a larger overlay partition can be achieved by resizing the factory GL.iNet layout (requires careful U-Boot interaction). +- **External Overlay**: Create a script or guide for using a USB drive as `overlayfs` (ExtRoot). + +## 4. Build Automation +- **CI/CD Integration**: Move the build process to a GitHub Action to ensure images are always up-to-date with the latest OpenWrt security patches. +- **Local Repo**: Host a local Opkg repository for custom packages like `btop` or `mosh` to avoid manual transfers. + +## 5. UI/UX +- **Modern Themes**: Swap the default LuCI theme for something more modern like `luci-theme-argon`. +- **Dashboard Utilities**: Add `luci-app-statistics` for better monitoring. diff --git a/docs/gl-ax1800-research-report.md b/docs/gl-ax1800-research-report.md new file mode 100755 index 0000000..788138e --- /dev/null +++ b/docs/gl-ax1800-research-report.md @@ -0,0 +1,57 @@ +# GL-AX1800 (Flint) Firmware History & Comparison + +## πŸ•°οΈ Firmware Evolution Timeline + +The GL-AX1800 (Flint) has undergone several major architectural shifts since its release: + +| Era | Base OpenWrt Version | Kernel Version | Notes | +|:---|:---|:---|:---| +| **Early (2021)** | **15.05 (Chaos Calmer)** | 4.4.x | Initial release used a legacy Qualcomm SDK (QSDK) base. | +| **Mid (2022-2024)** | **21.02 (Esmond)** | 4.4.x | The foundation for the "4.x" GL.iNet firmware series. Most 4.6.x builds are here. | +| **Official (March 2025)** | **Mainline / Master** | 6.x | Officially merged into OpenWrt mainline under `qualcommax/ipq60xx`. | +| **Current (2025-2026)** | **23.05+ / GL.iNet 4.8+** | 5.x / 6.x | GL.iNet is transitioning their proprietary UI over newer OpenWrt bases. | + +> [!NOTE] +> **Fork Point**: GL.iNet traditionally forks from OpenWrt stable releases (like 21.02) and replaces the standard network core with **Qualcomm's QSDK** to support proprietary Wi-Fi blobs and performance optimizations. + +--- + +## πŸ—οΈ GL.iNet Additions vs. Official OpenWrt + +GL.iNet's firmware is "OpenWrt-based" but contains significant deviations and proprietary layers. + +### 1. Proprietary UI & Middleware +- **Proprietary Dashboard**: A custom, user-friendly frontend (React/JS) that sits on top of OpenWrt. +- **Middleware API**: A custom C/Go backend (`gl-sdk`) that manages settings, bridging the UI to system files. + +### 2. Networking & Drivers +- **Qualcomm QSDK Drivers**: Unlike official OpenWrt's `ath11k` (open source), GL.iNet uses proprietary Qualcomm blobs. + - **Benefit**: Better stability, higher throughput, and lower CPU usage for Wi-Fi. + - **Trade-off**: Harder to update the kernel independently. +- **Hardware NPS (Network Processing Unit) Offload**: Specialized code to utilize Qualcomm's hardware acceleration for faster routing. + +### 3. Integrated Features (Not in Vanilla) +- **Advanced VPN Policies**: Easy-to-use UI for routing specific devices, IPs, or domains through VPN (WireGuard/OpenVPN). +- **AdGuard Home**: First-class integration with dedicated UI buttons and lifecycle management. +- **Multi-WAN / Failover**: Enhanced "Repeater" logic that handles Captive Portals and multi-interface failover more gracefully than standard OpenWrt. +- **GLDDNS**: Proprietary dynamic DNS service integrated with their cloud. +- **GoodCloud**: Remote management system for controlling the router over the internet. + +### 4. Hardware Customization +- **Flip-Switch Support**: Logic for the physical toggle switch (can be mapped to VPN, Wi-Fi, etc. via UI). +- **LED Patterns**: Proprietary logic for LED indication of system status. + +--- + +## βš–οΈ Summary Comparison + +| Feature | GL.iNet Firmware | Vanilla OpenWrt | +|:---|:---|:---| +| **Ease of Use** | ⭐⭐⭐⭐⭐ (Very Easy) | ⭐⭐ (Technical/LuCI) | +| **Wi-Fi Performance** | ⭐⭐⭐⭐⭐ (Highly Optimized) | ⭐⭐⭐ (Open Source `ath11k`) | +| **RAM Usage** | ~180MB Free | ~200MB+ Free (Less Bloat) | +| **Customizability** | Limited (Locked by UI/Plugins) | Infinite (Full Linux Control) | +| **Security Updates** | Vendor Dependent (Slow) | Community Driven (Fast) | + +> [!IMPORTANT] +> Official OpenWrt support for the AX1800 arrived late (March 2025) because the **Qualcomm IPQ6000** platform required significant upstream work for its Wi-Fi (ath11k) and interrupt handling before it was stable enough for mainline. diff --git a/docs/glax1800-build-results.md b/docs/glax1800-build-results.md new file mode 100755 index 0000000..d0f7326 --- /dev/null +++ b/docs/glax1800-build-results.md @@ -0,0 +1,45 @@ +# GL-AX1800 Package Build Results + +> [!IMPORTANT] +> **Architecture Confirmed (2026-01-11):** The GL-AX1800 uses **ARMv7 rev 4 (v7l)** - 32-bit ARM architecture. The GL.iNet SDK `ipq807x-2102` correctly targets 32-bit ARM, but uses an outdated GCC 5.5.0 toolchain that cannot compile modern C++23 code. + +**Date:** 2026-01-11 +**Target:** GL-AX1800 (Flint 1) - IPQ6000 SoC +**Architecture:** ARMv7 Processor rev 4 (v7l) - 32-bit ARM +**SDK Tested:** `ipq807x-2102` (GCC 5.5.0, ARM Cortex-A7, 32-bit) - **Correct arch, outdated compiler** + +## Summary + +Attempted to build `btop` and `mosh` packages using the GL.iNet SDK. Both failed due to the SDK's outdated GCC 5.5.0 toolchain. + +## Findings + +### SDK Architecture +The `ipq807x-2102` SDK targets **32-bit ARM** (`arm_cortex-a7`), which matches the actual hardware architecture (ARMv7). However, the toolchain is outdated (GCC 5.5.0 from ~2017) and cannot compile modern C++ standards. + +### btop (v1.4.6) +- **Error:** `error: unrecognized command line option '-std=c++23'` +- **Cause:** btop requires C++23, GCC 5.5.0 only supports up to C++14 +- **Resolution:** Would need GCC 11+ minimum (GCC 14 recommended) + +### mosh (protobuf dependency) +- **Error:** `constexpr constructor calls non-constexpr function` +- **Cause:** protobuf 3.17.3 uses C++14 constexpr features that GCC 5.5.0 doesn't fully implement +- **Resolution:** Would need GCC 7+ for full C++14 constexpr support + +### Successfully Built +- ncurses 6.2 +- OpenSSL 1.1.1v +- terminfo +- cryptodev-linux 1.12 +- Hundreds of kernel modules for ipq807x + +## Recommendations (Updated 2026-01-11) + +> [!NOTE] +> The GL-AX1800 uses ARMv7 (32-bit ARM), requiring modern ARMv7 toolchains: + +1. **Use musl.cc ARMv7 toolchain** - Pre-built `armv7l-linux-musleabihf` with modern GCC +2. **Alternative: musl-cross-make** - Build your own ARM v7 toolchain with GCC 14+ +3. **Not recommended: GL.iNet SDK** - Correct architecture but GCC too old (5.5.0) +4. **See detailed options in:** `agent-notes/flint1-sdk-research.md` diff --git a/docs/kwrt-vs-immortalwrt-guide.md b/docs/kwrt-vs-immortalwrt-guide.md new file mode 100755 index 0000000..4bfa3dd --- /dev/null +++ b/docs/kwrt-vs-immortalwrt-guide.md @@ -0,0 +1,472 @@ +# KWRT vs ImmortalWrt - Comprehensive Comparison + +**Created:** 2026-01-12 +**Purpose:** Deep dive into the two main community OpenWrt forks available for GL-AX1800 + +--- + +## 🌟 Executive Summary + +Both **KWRT** and **ImmortalWrt** are enhanced forks of OpenWrt that add features, packages, and optimizations beyond vanilla OpenWrt. However, they target different audiences and have distinct philosophies: + +- **KWRT (Koolshare OpenWrt by Kiddin9):** Chinese-focused, online firmware customization, bleeding-edge packages +- **ImmortalWrt:** International fork with performance optimizations, broader device support, more conservative approach + +--- + +## 1️⃣ KWRT (Koolshare OpenWrt / Kiddin9 OpenWrt) + +### What Is KWRT? + +**Full Name:** Koolshare OpenWrt (also known as Kiddin9's OpenWrt or just "Kwrt") +**Developer:** Kiddin9 +**Website:** https://openwrt.ai +**GitHub:** https://github.com/kiddin9/OpenWrt_x86-r2s-r4s + +### Philosophy + +KWRT aims to provide **maximum customization** through an online build platform while maintaining the latest OpenWrt code with extensive plugin/package support. It's particularly popular in the Chinese OpenWrt community but supports international users. + +### Key Features + +#### πŸ”§ Online Firmware Customization +- **Web-based Builder:** Visit openwrt.ai to customize firmware before download +- **Kernel Selection:** Choose from multiple kernel versions (5.15.x, 6.1.x, 6.6.x, 6.12.x) +- **Package Pre-selection:** Select packages to include before compilation +- **Theme Options:** Choose default LuCI theme +- **File System:** Ext4 support for sponsored users + +#### πŸ“¦ Extensive Package Repository +- Maintains comprehensive GitHub repos for OpenWrt packages +- **Vast collection** of open-source plugins +- Many packages commonly needed by Chinese users +- Third-party packages and tools not in official OpenWrt + +**Common Default Packages:** +- `autocore` - System auto-configuration +- `base-files` - Core system files +- `bash` - Full bash shell (not just busybox ash) +- `dnsmasq-full` - Enhanced DNS/DHCP server +- `firewall4` - NFTables firewall +- `luci-app-firewall` - Firewall web interface +- `openssh-sftp-server` - SFTP support + +**Optional Packages** (examples): +- `luci-app-accesscontrol-plus` - Access control +- `luci-app-adbyby-plus` / `luci-app-adguardhome` - Ad blocking +- `luci-app-aliyundrive-webdav` - Cloud drive integration +- `luci-app-aria2` - Download management +- Network proxy tools: `koolss` (SS/SSR), `v2ray`, `wireguard`, `brook` + +#### πŸ—οΈ Architecture Support +Unlike Koolshare's original X64-only focus, Kiddin9's KWRT supports: +- **X86_64** - Desktop/server platforms +- **i386_pentium4** - Older Intel platforms +- **aarch64** - Generic, Cortex-A72, Cortex-A53 (← **GL-AX1800 uses this**) +- **ARM** - Cortex-A9, Cortex-A7, ARM1176JZF-S +- **MIPS** - mipsel_24kc, mips_24kc +- Devices: Raspberry Pi, N1, various routers + +#### πŸš€ Build Frequency +- **Monthly snapshots** (typically around the 10th of each month) +- Based on latest OpenWrt master +- Dated builds (MM.DD.YYYY format) + +#### πŸ–₯️ Web Server +- Uses **Nginx** instead of Uhttpd +- Better performance for web services +- Enhanced HTTP server capabilities + +### For GL-AX1800 Specifically + +**Target:** `qualcommax/ipq60xx` +**Architecture:** aarch64_cortex-a53 +**Build Example:** `kwrt-01.10.2026-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin` + +**Installation:** +1. Enter U-Boot mode (hold reset, power on, 10 sec) +2. Browse to http://192.168.1.1 +3. Flash `.bin` or `.ubi` factory image +4. For upgrades: use `sysupgrade.bin` + +**Available Files:** +- **Factory.bin** - Standard factory image +- **Factory.ubi** - UBI format for NAND flash +- **Sysupgrade.bin** - For OpenWrtβ†’OpenWrt upgrades + +### Pros + +βœ… **Online customization** - Build exactly what you need +βœ… **Latest packages** - Bleeding-edge versions +βœ… **LuCI included** - Web interface by default +βœ… **Nginx** - Better web server +βœ… **More pre-installed** - Many useful packages out-of-box +βœ… **Regular builds** - Monthly updates +βœ… **Wide hardware support** - Many architectures +βœ… **Active development** - Frequent commits + +### Cons + +⚠️ **Chinese-focused** - Documentation/UI primarily Chinese +⚠️ **Less stable** - Monthly builds, less testing than releases +⚠️ **Non-upstreamable** - Custom patches not in official OpenWrt +⚠️ **Larger images** - More packages = bigger firmware +⚠️ **Slow download** - openwrt.ai server can be very slow +⚠️ **Less support** - Smaller international community + +### When to Choose KWRT + +**Choose KWRT if you:** +- Want maximum customization before download +- Need specific Chinese-region packages/tools +- Want the latest packages immediately +- Prefer pre-configured systems +- Are comfortable with monthly snapshot builds +- Like having many options/plugins available +- Can read/navigate Chinese interfaces + +--- + +## 2️⃣ ImmortalWrt + +### What Is ImmortalWrt? + +**Full Name:** ImmortalWrt +**Type:** OpenWrt fork +**Developer:** Chinese developer community +**Website:** https://immortalwrt.org +**GitHub:** https://github.com/immortalwrt/immortalwrt + +### Philosophy + +ImmortalWrt aims to **enhance OpenWrt** with better performance, more device support, and additional packages while maintaining a more traditional approach than KWRT. Focus on performance optimization and "non-upstreamable" improvements. + +### Key Features + +#### ⚑ Performance Optimization +- **Wireless driver optimization** - Enhanced Wi-Fi performance +- **Kernel optimization** - Tuned for better speed/stability +- **MediaTek focus** - Particularly good for MTK chips +- Users report better performance vs vanilla OpenWrt in many cases +- **High network speed** - Optimized for throughput + +#### πŸ”§ Out-of-the-Box Functionality +- More features **pre-enabled** vs official OpenWrt +- Less manual configuration needed +- Better defaults for common use cases + +#### πŸ“± Device Support +- **Wider range of devices** than official OpenWrt +- Particularly: Chinese-branded routers +- Single-board computers (SBCs) +- Devices not officially supported by mainstream OpenWrt +- **Faster adoption** of new hardware + +#### 🌍 Localization +- Default optimized profiles for mainland China +- Includes Chinese-specific optimizations +- More international than KWRT +- English documentation available + +#### πŸ“¦ Package Differences +- Uses `opkg` package manager (same as OpenWrt) +- **More packages ported** than vanilla +- Includes packages commonly needed by Chinese users +- Third-party packages addressing local internet requirements +- Approximately **8000+ packages** available + +#### πŸ”„ Release Model +- **Stable releases** - e.g., 23.05.7 +- **Snapshot builds** - Daily/regular updates +- More conservative than KWRT's monthly approach + +### For GL-AX1800 Specifically + +**Target:** `qualcommax/ipq60xx` +**Architecture:** aarch64_cortex-a53 +**GCC:** 12.3.0 (stable), 14.3.0 (snapshots) + +**Stable Release:** 23.05.7 +- **URL:** https://downloads.immortalwrt.org/releases/23.05.7/targets/qualcommax/ipq60xx/ +- **Note:** GL-AX1800 support may not be in stable yet (404 errors observed) + +**Snapshots:** +- **URL:** https://downloads.immortalwrt.org/snapshots/targets/qualcommax/ipq60xx/ +- Regular builds available + +**File Pattern:** +``` +immortalwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin +immortalwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin +``` + +### Pros + +βœ… **Performance** - Optimized for speed/stability +βœ… **Device support** - More hardware than vanilla +βœ… **Stable releases** - Not just snapshots +βœ… **LuCI included** - Web interface by default +βœ… **More international** - Better English support than KWRT +βœ… **Frequent updates** - Bug fixes come quickly +βœ… **Better drivers** - Enhanced wireless drivers +βœ… **Proven track record** - Established fork +βœ… **Less bloated** - More focused than KWRT + +### Cons + +⚠️ **Non-upstreamable** - Custom patches not in official OpenWrt +⚠️ **Less mainstream** - Smaller than vanilla OpenWrt community +⚠️ **Custom tweaks** - May conflict with official packages +⚠️ **Documentation** - Less comprehensive than vanilla +⚠️ **Update lag** - Sometimes behind vanilla on security updates +⚠️ **Regional focus** - Still Chinese-oriented + +### When to Choose ImmortalWrt + +**Choose ImmortalWrt if you:** +- Want **better performance** than vanilla OpenWrt +- Need support for Chinese/Asian hardware +- Prefer **stable releases** over snapshots +- Want more packages but not KWRT's full collection +- Like the balance between vanilla and heavily customized +- Need MediaTek optimization +- Want frequent bug fixes +- Prefer a more traditional OpenWrt experience + +--- + +## πŸ“Š Detailed Comparison Matrix + +| Feature | Vanilla OpenWrt | KWRT (Kiddin9) | ImmortalWrt | +|---------|----------------|----------------|-------------| +| **Philosophy** | Upstream-first, stability | Maximum customization | Performance + support | +| **Release Model** | Stable + snapshots | Monthly builds | Stable + snapshots | +| **Stability** | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | +| **Performance** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | +| **Device Support** | Wide | Very Wide | Widest | +| **Package Count** | ~8000 | ~10000+ | ~8000+ | +| **Pre-installed** | Minimal | Many | More than vanilla | +| **Customization** | Manual | **Online builder** | Manual | +| **LuCI Included** | Yes | Yes | Yes | +| **Web Server** | Uhttpd | **Nginx** | Uhttpd | +| **Chinese Focus** | No | Strong | Moderate | +| **International** | ⭐⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐⭐ | +| **Documentation** | Excellent | Limited | Good | +| **Community Size** | Huge | Small | Medium | +| **Update Speed** | Moderate | Fast (monthly) | Fast | +| **Build Frequency** | Daily snapshots | Monthly dated | Regular | +| **Security Updates** | Fastest | Moderate | Fast | +| **Upstream Compat.** | Perfect | Modified | Modified | +| **File Size** | Smallest | Largest | Medium | +| **Learning Curve** | Medium | Medium | Easy-Medium | + +--- + +## 🎯 Which Should You Choose for GL-AX1800? + +### Choose **Vanilla OpenWrt 25.12.0-rc2** If: +- Want official, well-supported firmware +- Value **stability** and security above all +- Need reliable security updates +- Want largest community support +- Comfortable with SSH/manual package installation +- βœ… **RECOMMENDED for most users** + +### Choose **KWRT** If: +- Want **online firmware customization** +- Need specific Chinese-region tools +- Want bleeding-edge packages immediately +- Like pre-configured systems with many options +- Don't mind monthly snapshot builds +- Can navigate Chinese interfaces +- Want Nginx web server +- Enjoy tinkering with latest features + +### Choose **ImmortalWrt** If: +- Want **best performance** optimization +- Need stable releases with extra features +- Want balance between vanilla and KWRT +- Prefer traditional OpenWrt feel with enhancements +- Like more international focus than KWRT +- Want enhanced wireless drivers +- Need quick bug fixes +- Want more packages than vanilla but not KWRT's full selection + +--- + +## πŸ” Technical Differences + +### Package Management + +**All three use `opkg`** but with different repositories: + +```bash +# Vanilla OpenWrt +opkg update +opkg install + +# KWRT +# Pre-configured with Kiddin9's repos +# Nginx instead of Uhttpd +# More packages available by default + +# ImmortalWrt +# Own package repos +# More packages ported +# Chinese-specific tools included +``` + +### Kernel Versions + +| Firmware | Kernel | Notes | +|----------|--------|-------| +| OpenWrt 25.12-rc2 | 6.6.x | LTS kernel | +| OpenWrt Master | 6.6.x+ | Latest stable | +| KWRT | 5.15.x -6.12.x | **User selectable!** | +| ImmortalWrt Stable | 5.15.x | Conservative | +| ImmortalWrt Snapshot | 6.6.x | Latest | + +### GCC Toolchain + +| Firmware | GCC Version | C++ Support | +|----------|-------------|-------------| +| OpenWrt 25.12-rc2 | 14.3.0 | C++23 | +| OpenWrt Master | 14.3.0 | C++23 | +| KWRT | 14.3.0 | C++23 | +| ImmortalWrt 23.05 | 12.3.0 | C++20 | +| ImmortalWrt Snapshot | 14.3.0 | C++23 | + +--- + +## πŸ“₯ Download Links for GL-AX1800 + +### KWRT +``` +https://dl.openwrt.ai/firmware/qualcommax-ipq60xx/glinet_gl-ax1800/ + +Latest: kwrt-01.10.2026-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin +``` + +### ImmortalWrt Snapshots +``` +https://downloads.immortalwrt.org/snapshots/targets/qualcommax/ipq60xx/ + +Latest: immortalwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-factory.bin +``` + +### ImmortalWrt Stable (if available) +``` +https://downloads.immortalwrt.org/releases/23.05.7/targets/qualcommax/ipq60xx/ +``` + +--- + +## πŸ’‘ Real-World Use Cases + +### Home Lab / Development +**Recommendation:** KWRT or OpenWrt Master +- Online customization for dev tools +- Latest GCC for compiling +- Many packages available + +### Production Router / Reliability +**Recommendation:** ImmortalWrt Stable or OpenWrt 25.12-rc2 +- Stable releases +- Performance optimized +- LuCI included + +### Chinese Internet / Region-Specific +**Recommendation:** KWRT +- Best Chinese tool support +- Optimized for region +- Custom packages included + +### Performance Testing / Benchmarking +**Recommendation:** ImmortalWrt +- Best wireless performance +- Kernel optimizations +- Proven speed improvements + +### Learning OpenWrt / First Time +**Recommendation:** OpenWrt 25.12-rc2 +- Official documentation +- Largest community +- Best learning resources + +--- + +## πŸš€ My Recommendation for Your GL-AX1800 + +Based on having downloaded multiple firmware variants: + +**1st Choice: OpenWrt 25.12.0-rc2** ⭐ +- Stable release candidate +- Native IPQ6000 support +- LuCI included +- GCC 14.3.0 +- Will become official stable soon + +**2nd Choice: ImmortalWrt Snapshot** +- If you need better performance +- Stable enough for daily use +- More packages than vanilla + +**3rd Choice: KWRT** +- If you want to experiment +- Try the online customization +- Test bleeding-edge packages + +**Avoid for Production: OpenWrt Master Snapshots** +- Too unstable (daily builds) +- Use 25.12-rc2 instead + +--- + +## πŸ› οΈ Installation Tips + +Both KWRT and ImmortalWrt install the same way as vanilla OpenWrt: + +### U-Boot Method (Recommended) +1. Power off router +2. Hold reset button while powering on +3. Hold 10 seconds until LED blinks +4. Set PC IP: 192.168.1.100 +5. Browse: http://192.168.1.1 +6. Upload factory.bin file +7. Wait 3-5 minutes + +### Via SSH (if already running OpenWrt) +```bash +scp firmware.bin root@192.168.x.1:/tmp/ +ssh root@192.168.x.1 +sysupgrade -n /tmp/firmware.bin +``` + +--- + +## πŸ“š Additional Resources + +### KWRT +- Website: https://openwrt.ai +- GitHub: https://github.com/kiddin9/OpenWrt_x86-r2s-r4s +- Packages: https://github.com/kiddin9/openwrt-packages + +### ImmortalWrt +- Website: https://immortalwrt.org +- GitHub: https://github.com/immortalwrt/immortalwrt +- Forum: Various Chinese and international forums + +### Community +- OpenWrt Forum: https://forum.openwrt.org +- Reddit: r/openwrt +- GL.iNet Forum: https://forum.gl-inet.com + +--- + +## πŸ“ Summary + +- **KWRT = Customization King** πŸ‘‘ (online builder, many packages, Chinese-focused) +- **ImmortalWrt = Performance Beast** ⚑ (optimized, stable, balanced) +- **Vanilla OpenWrt = Rock Solid** πŸ—Ώ (official, supported, stable) + +All three work great on GL-AX1800 with the `qualcommax/ipq60xx` target! diff --git a/docs/mawk_vs_gawk_report.md b/docs/mawk_vs_gawk_report.md new file mode 100755 index 0000000..18f7ff4 --- /dev/null +++ b/docs/mawk_vs_gawk_report.md @@ -0,0 +1,30 @@ +# Report: mawk vs gawk in OpenWRT SDK Context + +## Introduction +This report details the technical differences between `mawk` and `gawk` that led to the build failure of the Mosh package within the OpenWRT SDK environment. + +## The failure +The OpenWRT SDK build process failed with the following error: +``` +awk: include/scan.awk: line 21: function asort never defined +``` +This error occurred during the package scanning phase (`include/scan.mk`), which uses `awk` scripts to parse package definitions. + +## mawk (Mike's AWK) +- **Design Philosophy**: Built for speed and strict POSIX compliance. It is significantly faster than `gawk` for simple text processing tasks, which is why it is the default `awk` provider on many Debian-based minimal installations. +- **Limitation**: It generally implements only the features defined in the POSIX standard for AWK. It lacks many GNU-specific extensions. +- **Missing Feature**: complex sorting functions like `asort` and `asorti` are NOT part of the POSIX standard, and thus are absent in `mawk`. + +## gawk (GNU AWK) +- **design Philosophy**: The GNU implementation of AWK. It includes all POSIX features plus a vast array of extensions. +- **Key Features**: + - `asort()` / `asorti()`: Built-in functions for sorting arrays. + - Network capabilities (`/inet/tcp/...`). + - Bitwise operations (`and`, `or`, `xor`). + - Time functions (`mktime`, `strftime`). +- **OpenWRT Requirement**: The OpenWRT build system (scripts in `include/` and `scripts/`) relies heavily on these GNU extensions for dependency resolution and menu construction. Specifically, `asort` is used to deterministically order package lists. + +## Conclusion +The task was blocked because the system's `/usr/bin/awk` pointed to `mawk`. The OpenWRT SDK assumes a full-featured `gawk` environment. Although `mawk` is faster, it is functionally insufficient for the complex logic contained in OpenWRT's build scripts. + +Now that `gawk` is installed, the SDK scripts will be able to execute the `asort` function and proceed with the build. diff --git a/docs/organizational_checkup.md b/docs/organizational_checkup.md new file mode 100755 index 0000000..88035c5 --- /dev/null +++ b/docs/organizational_checkup.md @@ -0,0 +1,51 @@ +# Organizational Checkup Report +**Date:** 2025-12-12 +**Workspace:** `/home/user/Public/Projects/OpenWRT` + +## Executive Summary +An organizational checkup was performed to ensure the workspace has a structured layout for binaries, packages, source code, and SDKs. Missing directories were identified and created. Existing directories were audited, and legacy directories were consolidated. Mosh and Btop assets were organized into the standard structure. + +## Directory Status + +### 1. Binaries +- **Goal:** Dedicated folder for binaries. +- **Status:** `binaries/` verified. +- **Contents:** + - `binaries/btop-flint2/` + - `binaries/mosh/` (Added) + +### 2. Packages +- **Goal:** Dedicated folder for packages. +- **Status:** `packages/` verified. +- **Contents:** + - `btop-flint2-package/` + - `btop-openwrt-package/` + - `btop-package-build/` (Moved) + - `mosh-package-build/` (Moved) + - `*.ipk` files (Moved) + +### 3. Source Code +- **Goal:** Dedicated folder for source code (`src`). +- **Status:** `src/` verified. +- **Contents:** + - `src/btop/` + - `src/mosh/` (Moved from `mosh-static-build`) + +### 4. SDK +- **Goal:** Dedicated folder for SDKs. +- **Status:** `sdk/` verified. +- **Contents:** + - `openwrt-sdk-mediatek-filogic_gcc-14.3.0_musl.Linux-x86_64/` + +## Summary of Actions Taken +- Created new directory: `/home/user/Public/Projects/OpenWRT/binaries` +- Created new directory: `/home/user/Public/Projects/OpenWRT/src` +- Consolidated `sources/` contents to `src/`. +- Consolidated `bin/` contents to `binaries/`. +- Moved `mosh-static-build` to `src/mosh`. +- Copied `mosh-server` and `mosh-client` to `binaries/mosh`. +- Moved package build directories and artifact `.ipk` files to `packages/`. +- Removed legacy directories: `sources/`, `bin/`. + +## Next Steps +- Ensure all future build scripts point to these standard directories. diff --git a/docs/package-creation-procedure.md b/docs/package-creation-procedure.md new file mode 100755 index 0000000..1fcc61d --- /dev/null +++ b/docs/package-creation-procedure.md @@ -0,0 +1,17 @@ +# Package Creation Procedure + +## New Standard Workflow (as of 2025-12-13) + +1. **Build Format**: Always build packages as `.tar.gz` first. + - Do NOT build directly as `.ipk`. + - The `.tar.gz` must contain: `debian-binary`, `control.tar.gz`, `data.tar.gz`. + +2. **Verification**: + - Verify the `.tar.gz` can be extracted using standard `tar -xzf`. + - Check contents of extracted archive. + +3. **Finalize**: + - Only AFTER verification is successful, rename the `.tar.gz` file to `.ipk`. + +## Why? +This ensures the package structure is valid and compatible with standard archive tools before being deployed, preventing "malformed package" errors on some systems. diff --git a/docs/project_log.md b/docs/project_log.md new file mode 100755 index 0000000..bd36b3b --- /dev/null +++ b/docs/project_log.md @@ -0,0 +1,33 @@ +# Project Log - OpenWRT Agent + +## 2025-12-12 +- Initiated project tracking. +- Reviewed project directory `OpenWRT`. +- Created `agent-notes` directory. +- Started research on GL-iNet Flint2 and Flint1 hardware. +- **Flint 2 (GL-MT6000)** status: + - Confirmed CPU: Quad-core ARM Cortex-A53. + - Architecture: `aarch64`. + - SDK identified: `openwrt-sdk-mediatek-filogic`. +- **Flint 1 (GL-AX1800)** status: + - Likely CPU: Quad-core ARM Cortex-A53 (Qualcomm IPQ6000). + - Requires verification of specific SDK if different from generic aarch64. + +## 2026-01-14 +- **Flint 1 (GL-AX1800) Research Update:** + - Confirmed CPU: Qualcomm IPQ6000 (ARMv7). + - Best Build Tool: `FUjr/gl-infra-builder` (supports hardware patches). + - OpenWrt Path: Target changed from `ipq40xx/generic` (v23.05) to `qualcommax/ipq60xx` (Master/v24/v25). + - Barebones Image: Defined profile for SSH-only, no-UI firmware. +- **Project Reorganization:** + - Reorganized workspace into `firmware/`, `sdk/`, `docs/`, `scripts/`, `packages/`, `repo/`. + - Created `PROJECT_INDEX.md`. + - Consolidated research notes into `docs/`. + +## Tasks +- [x] Research GL-iNet Flint2 (GL-MT6000) CPU +- [x] Research GL-iNet Flint1 (GL-AX1800) CPU +- [x] Research gl-infra-builder forks and up-to-date options +- [x] Document upgrade paths to v24/v25 +- [/] Attempt barebones firmware creation for AX1800 +- [x] Reorganize project directory and create index diff --git a/docs/python313-compatibility-fix.md b/docs/python313-compatibility-fix.md new file mode 100755 index 0000000..fdd6801 --- /dev/null +++ b/docs/python313-compatibility-fix.md @@ -0,0 +1,31 @@ +# Python 3.13 Compatibility Fix for OpenWrt + +## Problem +The `gl-infra-builder` and OpenWrt build system encountered Python 3.13 compatibility issues: +1. OpenWrt's `prereq-build.mk` only checked for Python 3.5-3.10 +2. Python 3.13 removed the `distutils` module (deprecated since 3.10) + +## Solution Applied + +### 1. Updated Python Version Detection +Modified `/src/glbuilder/wlan-ap/openwrt/include/prereq-build.mk`: +- Changed regex from `Python 3\.([5-9]|10)\.?` to `Python 3\.([5-9]|1[0-9])\.?` +- This now accepts Python 3.5 through 3.19 + +### 2. Disabled Distutils Check +Commented out the distutils prerequisite check (lines 173-175): +```makefile +#$(eval $(call TestHostCommand,python3-distutils, \ +# Please install the Python3 distutils module, \ +# $(STAGING_DIR_HOST)/bin/python3 -c 'import setuptools')) +``` + +## Rationale +- Python 3.13 is fully functional and more advanced than the minimum required 3.5 +- `setuptools` provides the necessary functionality previously offered by `distutils` +- The build system doesn't actually require distutils features - it's a legacy check + +## Result +- Python prereqs now pass: `Checking 'python'... ok.` and `Checking 'python3'... ok.` +- Configuration generated successfully via `make defconfig` +- Build can proceed on Debian Trixie with Python 3.13 diff --git a/docs/upgrade-to-openwrt-master.md b/docs/upgrade-to-openwrt-master.md new file mode 100755 index 0000000..974e249 --- /dev/null +++ b/docs/upgrade-to-openwrt-master.md @@ -0,0 +1,235 @@ +# Upgrade to OpenWrt Master (GCC 14.3.0) - GL-AX1800 + +## Your Upgrade File + +**SYSUPGRADE Image (Use this one):** +``` +https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin +``` + +**SHA256 Checksums:** +``` +https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/sha256sums +``` + +**Size:** ~23 MB + +--- + +## What This Gives You + +- **Target:** `qualcommax/ipq60xx` (native IPQ6000 support) +- **GCC:** 14.3.0 (best C++23 support) +- **Kernel:** Latest Linux 6.x +- **Architecture:** ARMv7 (proper IPQ6000) +- **Updates:** Daily snapshots + +--- + +## Before You Upgrade + +### ⚠️ IMPORTANT WARNINGS + +1. **No LuCI by default** - Web interface NOT included + - You'll need SSH access to install it + - Command: `opkg update && opkg install luci` + +2. **Snapshot = development build** + - Less stable than release versions + - Daily updates (version changes constantly) + +3. **Different target** - Migration from `ipq40xx` β†’ `qualcommax/ipq60xx` + - Settings may not transfer cleanly + - Backup your configuration! + +4. **RAM usage** - Open-source ath11k driver + - ~130MB used by Wi-Fi firmware + - ~380MB free (vs 512MB total) + +--- + +## Upgrade Methods + +### Method 1: Web Interface (GL.iNet firmware) + +1. **Download the sysupgrade file:** + ```bash + wget https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin + ``` + +2. **Verify checksum:** + ```bash + wget https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/sha256sums + sha256sum -c sha256sums 2>&1 | grep glinet_gl-ax1800-squashfs-sysupgrade.bin + ``` + +3. **Upload via web interface:** + - Go to GL.iNet web panel (http://192.168.8.1) + - Navigate to: System β†’ Firmware Upgrade + - Upload: `openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin` + - **Do NOT keep settings** (recommended for target change) + +--- + +### Method 2: SSH/SCP (Advanced) + +1. **Copy file to router:** + ```bash + scp openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin root@192.168.8.1:/tmp/ + ``` + +2. **SSH into router:** + ```bash + ssh root@192.168.8.1 + ``` + +3. **Flash firmware:** + ```bash + cd /tmp + sysupgrade -n openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin + ``` + + **Options:** + - `-n` = Do NOT save settings (recommended for target change) + - `-F` = Force upgrade (if sysupgrade complains) + +--- + +### Method 3: OpenWrt Firmware Selector + +**URL:** https://firmware-selector.openwrt.org/ + +1. Search: "GL-AX1800" +2. Select version: "SNAPSHOT" +3. Download: "SYSUPGRADE" +4. Use web interface or SSH method above + +--- + +## After Upgrade + +### First Boot + +1. **Connect via Ethernet** (Wi-Fi disabled by default) + +2. **Default IP:** `192.168.1.1` + +3. **Set root password:** + ```bash + ssh root@192.168.1.1 + passwd + ``` + +4. **Install LuCI (Web Interface):** + ```bash + opkg update + opkg install luci luci-ssl + /etc/init.d/uhttpd start + /etc/init.d/uhttpd enable + ``` + +5. **Access web interface:** + - URL: https://192.168.1.1 + - Username: `root` + - Password: (what you set above) + +--- + +## Configure Wi-Fi + +Via SSH: +```bash +# Edit wireless config +vi /etc/config/wireless + +# Remove disabled lines for wifi devices +# Set your SSID and password + +# Enable Wi-Fi +uci set wireless.radio0.disabled=0 +uci set wireless.radio1.disabled=0 +uci commit wireless +wifi reload +``` + +Or use LuCI web interface: Network β†’ Wireless + +--- + +## Download Commands + +```bash +# Download sysupgrade image +wget https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/openwrt-qualcommax-ipq60xx-glinet_gl-ax1800-squashfs-sysupgrade.bin + +# Download checksums +wget https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq60xx/sha256sums + +# Verify +sha256sum -c sha256sums 2>&1 | grep glinet_gl-ax1800-squashfs-sysupgrade.bin + +# Should show: OK +``` + +--- + +## Backup Your Current System + +**Before upgrading, backup:** + +```bash +# Via SSH +ssh root@192.168.8.1 +sysupgrade -b /tmp/backup-$(date +%F).tar.gz +exit + +# Copy backup to your computer +scp root@192.168.8.1:/tmp/backup-*.tar.gz ./ +``` + +--- + +## Rollback Plan + +If you need to go back to GL.iNet firmware: + +1. Download GL.iNet 4.6.11 from: https://dl.gl-inet.com/?model=ax1800 +2. Use U-Boot recovery or sysupgrade back to GL.iNet firmware + +--- + +## Comparison: Current vs Master + +| Feature | Current (23.05-SNAPSHOT) | OpenWrt Master | +|---------|--------------------------|----------------| +| Target | `ipq40xx` | **`qualcommax/ipq60xx`** βœ… | +| GCC | 12.3.0 | **14.3.0** βœ… | +| Kernel | 5.15.x | **6.x** βœ… | +| LuCI | Included | **Manual install** ⚠️ | +| Stability | Good | **Snapshot** ⚠️ | +| Updates | Periodic | **Daily** | + +--- + +## Recommendation + +**Think twice before upgrading if:** +- ❌ You need stable firmware for production +- ❌ You're not comfortable with SSH/command line +- ❌ You rely on GL.iNet-specific features (VPN, AdGuard GUI, etc.) + +**Upgrade if:** +- βœ… You want latest OpenWrt features +- βœ… You need GCC 14.3.0 for development +- βœ… You want native `qualcommax/ipq60xx` support +- βœ… You're comfortable troubleshooting via SSH + +**Alternative:** Stay on your current firmware and use the OpenWrt 23.05.5 SDK (already downloaded) for development. It has GCC 12.3.0 which is good enough for most C++20 code. + +--- + +## Support + +- **OpenWrt Forum:** https://forum.openwrt.org/ +- **GL.iNet Forum:** https://forum.gl-inet.com/ +- **Wiki:** https://openwrt.org/toh/gl.inet/gl-ax1800 diff --git a/flint1-armv7/binaries/btop-static-armv7 b/flint1-armv7/binaries/btop-static-armv7 new file mode 100755 index 0000000..a0973d1 Binary files /dev/null and b/flint1-armv7/binaries/btop-static-armv7 differ diff --git a/flint1-armv7/binaries/mosh-client-static-armv7 b/flint1-armv7/binaries/mosh-client-static-armv7 new file mode 100755 index 0000000..9907a11 Binary files /dev/null and b/flint1-armv7/binaries/mosh-client-static-armv7 differ diff --git a/flint1-armv7/binaries/mosh-server-static-armv7 b/flint1-armv7/binaries/mosh-server-static-armv7 new file mode 100755 index 0000000..a706441 Binary files /dev/null and b/flint1-armv7/binaries/mosh-server-static-armv7 differ diff --git a/flint1-armv7/build/build-mosh-static.sh b/flint1-armv7/build/build-mosh-static.sh new file mode 100755 index 0000000..74b16c1 --- /dev/null +++ b/flint1-armv7/build/build-mosh-static.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +set -e + +CROSS=arm-linux-gnueabihf +CFLAGS_CROSS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" +CFLAGS_CROSS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard" +# Debian armhf packages use these paths +ARM_INCLUDE="-I/usr/include/arm-linux-gnueabihf -I/usr/include" +ARM_LIBDIR="/usr/lib/arm-linux-gnueabihf" +SYSROOT=/home/user/Public/Projects/OpenWRT/flint1-armv7/src/mosh-sysroot +BUILDDIR=/tmp/mosh-arm-build +SRCDIR=/home/user/Public/Projects/OpenWRT/flint1-armv7/src/mosh +BINDIR=/home/user/Public/Projects/OpenWRT/flint1-armv7/binaries + +mkdir -p "$SYSROOT" "$BUILDDIR" "$BINDIR" + +echo "=== [1/3] Building protobuf host tools + ARM library ===" +PROTO_VER=3.21.12 +cd "$BUILDDIR" +rm -rf protobuf-"${PROTO_VER}" +tar -xzf /tmp/protobuf-"${PROTO_VER}".tar.gz +cd protobuf-"${PROTO_VER}" + +# Build host protoc +./configure --prefix=/tmp/host-protoc +make -j$(nproc) +make install +HOST_PROTOC=/tmp/host-protoc/bin/protoc +echo " host protoc: $($HOST_PROTOC --version)" + +# Cross-compile protobuf library +make distclean +./configure \ + --host=${CROSS} \ + --prefix="$SYSROOT" \ + --with-protoc="$HOST_PROTOC" \ + CC=${CROSS}-gcc \ + CXX=${CROSS}-g++ \ + CFLAGS="-static ${CFLAGS_CROSS}" \ + CXXFLAGS="-static ${CFLAGS_CROSS} -std=c++14" \ + LDFLAGS="-static" +make -j$(nproc) +make install +echo " protobuf ARM OK: $SYSROOT/lib/libprotobuf.a" + +echo "=== [2/3] Configuring mosh ===" +cd "$SRCDIR" +[ -f configure ] || ./autogen.sh + +./configure \ + --host=${CROSS} \ + --prefix="$SYSROOT" \ + CC=${CROSS}-gcc \ + CXX=${CROSS}-g++ \ + CFLAGS="-static ${CFLAGS_CROSS}" \ + CXXFLAGS="-static ${CFLAGS_CROSS}" \ + LDFLAGS="-static -L${SYSROOT}/lib -L${ARM_LIBDIR}" \ + LIBS="-lz -lzstd -ldl" \ + CPPFLAGS="-I${SYSROOT}/include ${ARM_INCLUDE}" \ + PKG_CONFIG="pkg-config" \ + PKG_CONFIG_PATH="${SYSROOT}/lib/pkgconfig:${ARM_LIBDIR}/pkgconfig" \ + PKG_CONFIG_LIBDIR="${SYSROOT}/lib/pkgconfig:${ARM_LIBDIR}/pkgconfig" + +echo "=== [3/3] Compiling mosh ===" +make -j$(nproc) + +cp src/frontend/mosh-server "$BINDIR/mosh-server-static-armv7" 2>/dev/null || \ + cp src/frontend/mosh-server "$BINDIR/mosh-server-static-armv7" +cp src/frontend/mosh-client "$BINDIR/mosh-client-static-armv7" 2>/dev/null || \ + cp src/frontend/mosh-client "$BINDIR/mosh-client-static-armv7" + +echo "" +echo "=== Build Complete ===" +file "$BINDIR/mosh-server-static-armv7" +file "$BINDIR/mosh-client-static-armv7" +ls -lh "$BINDIR/" diff --git a/flint1-armv7/firmware/official/ax1800-4.8.3_beta1-930-1226-1766720311.img b/flint1-armv7/firmware/official/ax1800-4.8.3_beta1-930-1226-1766720311.img new file mode 100755 index 0000000..80115f1 Binary files /dev/null and b/flint1-armv7/firmware/official/ax1800-4.8.3_beta1-930-1226-1766720311.img differ diff --git a/flint1-armv7/firmware/official/openwrt-ax1800-4.5.16-0321-1711030388.img b/flint1-armv7/firmware/official/openwrt-ax1800-4.5.16-0321-1711030388.img new file mode 100755 index 0000000..50b2c60 Binary files /dev/null and b/flint1-armv7/firmware/official/openwrt-ax1800-4.5.16-0321-1711030388.img differ diff --git a/flint1-armv7/firmware/official/openwrt-ax1800-4.6.6-0926-1727315351.img b/flint1-armv7/firmware/official/openwrt-ax1800-4.6.6-0926-1727315351.img new file mode 100755 index 0000000..6909ee7 Binary files /dev/null and b/flint1-armv7/firmware/official/openwrt-ax1800-4.6.6-0926-1727315351.img differ diff --git a/flint1-armv7/firmware/official/openwrt-ax1800-4.6.8-1017-1729176012.img b/flint1-armv7/firmware/official/openwrt-ax1800-4.6.8-1017-1729176012.img new file mode 100755 index 0000000..63ede8d Binary files /dev/null and b/flint1-armv7/firmware/official/openwrt-ax1800-4.6.8-1017-1729176012.img differ diff --git a/flint1-armv7/firmware/official/qsdk-ax1800-3.214-0509.img b/flint1-armv7/firmware/official/qsdk-ax1800-3.214-0509.img new file mode 100755 index 0000000..1969345 Binary files /dev/null and b/flint1-armv7/firmware/official/qsdk-ax1800-3.214-0509.img differ diff --git a/flint1-armv7/firmware/official/qsdk-ax1800-3.216-0321-1679391158.img b/flint1-armv7/firmware/official/qsdk-ax1800-3.216-0321-1679391158.img new file mode 100755 index 0000000..0ae179a Binary files /dev/null and b/flint1-armv7/firmware/official/qsdk-ax1800-3.216-0321-1679391158.img differ diff --git a/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/cc1 b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/cc1 new file mode 100755 index 0000000..eea55cc Binary files /dev/null and b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/cc1 differ diff --git a/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/cc1plus b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/cc1plus new file mode 100755 index 0000000..a82c282 Binary files /dev/null and b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/cc1plus differ diff --git a/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/collect2 b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/collect2 new file mode 100755 index 0000000..a488a8b Binary files /dev/null and b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/collect2 differ diff --git a/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/f951 b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/f951 new file mode 100755 index 0000000..75ab9be Binary files /dev/null and b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/f951 differ diff --git a/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/lto1 b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/lto1 new file mode 100755 index 0000000..74a720e Binary files /dev/null and b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/libexec/gcc/armv7l-linux-musleabihf/11.2.1/lto1 differ diff --git a/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/usr b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/usr new file mode 100755 index 0000000..945c9b4 --- /dev/null +++ b/flint1-armv7/sdk/armv7l-linux-musleabihf-cross/usr @@ -0,0 +1 @@ +. \ No newline at end of file diff --git a/flint1-armv7/sdk/musl-toolchain.tgz b/flint1-armv7/sdk/musl-toolchain.tgz new file mode 100755 index 0000000..70c459f Binary files /dev/null and b/flint1-armv7/sdk/musl-toolchain.tgz differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/lib64 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/lib64 new file mode 100755 index 0000000..7951405 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/lib64 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/.llvm-version b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/.llvm-version new file mode 100755 index 0000000..e8ee04c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/.llvm-version @@ -0,0 +1 @@ +21.1.6 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-21.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-21.bin new file mode 100755 index 0000000..d95ba5e Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-21.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-check.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-check.bin new file mode 100755 index 0000000..a9b71bb Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-check.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-extdef-mapping.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-extdef-mapping.bin new file mode 100755 index 0000000..aa93572 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-extdef-mapping.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-format.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-format.bin new file mode 100755 index 0000000..c99a888 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-format.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-installapi.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-installapi.bin new file mode 100755 index 0000000..d6973fc Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-installapi.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-linker-wrapper.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-linker-wrapper.bin new file mode 100755 index 0000000..7f0f8ab Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-linker-wrapper.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-nvlink-wrapper.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-nvlink-wrapper.bin new file mode 100755 index 0000000..3be65b5 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-nvlink-wrapper.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-offload-bundler.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-offload-bundler.bin new file mode 100755 index 0000000..597ef4b Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-offload-bundler.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-offload-packager.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-offload-packager.bin new file mode 100755 index 0000000..9e766a9 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-offload-packager.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-refactor.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-refactor.bin new file mode 100755 index 0000000..355f3b1 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-refactor.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-repl.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-repl.bin new file mode 100755 index 0000000..c8ab4bb Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-repl.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-scan-deps.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-scan-deps.bin new file mode 100755 index 0000000..6e6aef8 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-scan-deps.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-sycl-linker.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-sycl-linker.bin new file mode 100755 index 0000000..3e12d04 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.clang-sycl-linker.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.diagtool.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.diagtool.bin new file mode 100755 index 0000000..2ead9e7 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.diagtool.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llc.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llc.bin new file mode 100755 index 0000000..4a77b3b Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llc.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.lld.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.lld.bin new file mode 100755 index 0000000..6281bde Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.lld.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-ar.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-ar.bin new file mode 100755 index 0000000..1f205d6 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-ar.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-as.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-as.bin new file mode 100755 index 0000000..a973357 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-as.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-dis.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-dis.bin new file mode 100755 index 0000000..b70dae8 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-dis.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-link.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-link.bin new file mode 100755 index 0000000..9b29658 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-link.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-nm.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-nm.bin new file mode 100755 index 0000000..b1619c4 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-nm.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-objcopy.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-objcopy.bin new file mode 100755 index 0000000..750e92c Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-objcopy.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-objdump.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-objdump.bin new file mode 100755 index 0000000..133b6a6 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.llvm-objdump.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.offload-arch.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.offload-arch.bin new file mode 100755 index 0000000..b119b8f Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.offload-arch.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.opt.bin b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.opt.bin new file mode 100755 index 0000000..a01ef6f Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/.opt.bin differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/amdgpu-arch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/amdgpu-arch new file mode 100755 index 0000000..f1049b8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/amdgpu-arch @@ -0,0 +1 @@ +offload-arch \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/analyze-build b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/analyze-build new file mode 100755 index 0000000..636b5aa --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/analyze-build @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import multiprocessing +import sys +import os.path +this_dir = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib')) + +from libscanbuild.analyze import analyze_build + +if __name__ == '__main__': + multiprocessing.freeze_support() + sys.exit(analyze_build()) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang new file mode 100755 index 0000000..355acb0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang @@ -0,0 +1 @@ +clang-21 \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang++ new file mode 100755 index 0000000..060d289 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang++ @@ -0,0 +1 @@ +clang \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-21 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-21 new file mode 100755 index 0000000..7ea84c2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-21 @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-21.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-check b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-check new file mode 100755 index 0000000..e4c011c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-check @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-check.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-cl b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-cl new file mode 100755 index 0000000..060d289 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-cl @@ -0,0 +1 @@ +clang \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-cpp b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-cpp new file mode 100755 index 0000000..060d289 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-cpp @@ -0,0 +1 @@ +clang \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-extdef-mapping b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-extdef-mapping new file mode 100755 index 0000000..5ccee7f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-extdef-mapping @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-extdef-mapping.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-format b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-format new file mode 100755 index 0000000..a680cdf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-format @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-format.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-installapi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-installapi new file mode 100755 index 0000000..0cda34c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-installapi @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-installapi.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-linker-wrapper b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-linker-wrapper new file mode 100755 index 0000000..5016cc0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-linker-wrapper @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-linker-wrapper.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-nvlink-wrapper b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-nvlink-wrapper new file mode 100755 index 0000000..3900b10 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-nvlink-wrapper @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-nvlink-wrapper.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-offload-bundler b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-offload-bundler new file mode 100755 index 0000000..66216e0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-offload-bundler @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-offload-bundler.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-offload-packager b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-offload-packager new file mode 100755 index 0000000..7cbe9fb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-offload-packager @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-offload-packager.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-refactor b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-refactor new file mode 100755 index 0000000..17c1964 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-refactor @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-refactor.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-repl b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-repl new file mode 100755 index 0000000..6692149 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-repl @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-repl.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-scan-deps b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-scan-deps new file mode 100755 index 0000000..9a41129 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-scan-deps @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-scan-deps.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-sycl-linker b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-sycl-linker new file mode 100755 index 0000000..9c1ea70 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/clang-sycl-linker @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.clang-sycl-linker.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/diagtool b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/diagtool new file mode 100755 index 0000000..92583b5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/diagtool @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.diagtool.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/git-clang-format b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/git-clang-format new file mode 100755 index 0000000..fe2dd28 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/git-clang-format @@ -0,0 +1,858 @@ +#!/usr/bin/env python3 +# +# ===- git-clang-format - ClangFormat Git Integration -------*- python -*--=== # +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +# ===----------------------------------------------------------------------=== # + +r""" +clang-format git integration +============================ + +This file provides a clang-format integration for git. Put it somewhere in your +path and ensure that it is executable. Then, "git clang-format" will invoke +clang-format on the changes in current files or a specific commit. + +For further details, run: +git clang-format -h + +Requires Python version >=3.8 +""" + +from __future__ import absolute_import, division, print_function +import argparse +import collections +import contextlib +import errno +import os +import re +import subprocess +import sys + +usage = "git clang-format [OPTIONS] [] [|--staged] [--] [...]" + +desc = """ +If zero or one commits are given, run clang-format on all lines that differ +between the working directory and , which defaults to HEAD. Changes are +only applied to the working directory, or in the stage/index. + +Examples: + To format staged changes, i.e everything that's been `git add`ed: + git clang-format + + To also format everything touched in the most recent commit: + git clang-format HEAD~1 + + If you're on a branch off main, to format everything touched on your branch: + git clang-format main + +If two commits are given (requires --diff), run clang-format on all lines in the +second that differ from the first . + +The following git-config settings set the default of the corresponding option: + clangFormat.binary + clangFormat.commit + clangFormat.extensions + clangFormat.style +""" + +# Name of the temporary index file in which save the output of clang-format. +# This file is created within the .git directory. +temp_index_basename = "clang-format-index" + + +Range = collections.namedtuple("Range", "start, count") + + +def main(): + config = load_git_config() + + # In order to keep '--' yet allow options after positionals, we need to + # check for '--' ourselves. (Setting nargs='*' throws away the '--', while + # nargs=argparse.REMAINDER disallows options after positionals.) + argv = sys.argv[1:] + try: + idx = argv.index("--") + except ValueError: + dash_dash = [] + else: + dash_dash = argv[idx:] + argv = argv[:idx] + + default_extensions = ",".join( + [ + # From clang/lib/Frontend/FrontendOptions.cpp, all lower case + "c", + "h", # C + "m", # ObjC + "mm", # ObjC++ + "cc", + "cp", + "cpp", + "c++", + "cxx", + "hh", + "hpp", + "hxx", + "inc", # C++ + "ccm", + "cppm", + "cxxm", + "c++m", # C++ Modules + "cu", + "cuh", # CUDA + "cl", # OpenCL + # Other languages that clang-format supports + "proto", + "protodevel", # Protocol Buffers + "java", # Java + "js", + "mjs", + "cjs", # JavaScript + "ts", # TypeScript + "cs", # C Sharp + "json", + "ipynb", # Json + "sv", + "svh", + "v", + "vh", # Verilog + "td", # TableGen + "txtpb", + "textpb", + "pb.txt", + "textproto", + "asciipb", # TextProto + ] + ) + + p = argparse.ArgumentParser( + usage=usage, + formatter_class=argparse.RawDescriptionHelpFormatter, + description=desc, + ) + p.add_argument( + "--binary", + default=config.get("clangformat.binary", "clang-format"), + help="path to clang-format", + ), + p.add_argument( + "--commit", + default=config.get("clangformat.commit", "HEAD"), + help="default commit to use if none is specified", + ), + p.add_argument( + "--diff", + action="store_true", + help="print a diff instead of applying the changes", + ) + p.add_argument( + "--diffstat", + action="store_true", + help="print a diffstat instead of applying the changes", + ) + p.add_argument( + "--extensions", + default=config.get("clangformat.extensions", default_extensions), + help=( + "comma-separated list of file extensions to format, " + "excluding the period and case-insensitive" + ), + ), + p.add_argument( + "-f", + "--force", + action="store_true", + help="allow changes to unstaged files", + ) + p.add_argument( + "-p", "--patch", action="store_true", help="select hunks interactively" + ) + p.add_argument( + "-q", + "--quiet", + action="count", + default=0, + help="print less information", + ) + p.add_argument( + "--staged", + "--cached", + action="store_true", + help="format lines in the stage instead of the working dir", + ) + p.add_argument( + "--style", + default=config.get("clangformat.style", None), + help="passed to clang-format", + ), + p.add_argument( + "-v", + "--verbose", + action="count", + default=0, + help="print extra information", + ) + p.add_argument( + "--diff_from_common_commit", + action="store_true", + help=( + "diff from the last common commit for commits in " + "separate branches rather than the exact point of the " + "commits" + ), + ) + # We gather all the remaining positional arguments into 'args' since we need + # to use some heuristics to determine whether or not was present. + # However, to print pretty messages, we make use of metavar and help. + p.add_argument( + "args", + nargs="*", + metavar="", + help="revision from which to compute the diff", + ) + p.add_argument( + "ignored", + nargs="*", + metavar="...", + help="if specified, only consider differences in these files", + ) + opts = p.parse_args(argv) + + opts.verbose -= opts.quiet + del opts.quiet + + commits, files = interpret_args(opts.args, dash_dash, opts.commit) + if len(commits) > 2: + die("at most two commits allowed; %d given" % len(commits)) + if len(commits) == 2: + if opts.staged: + die("--staged is not allowed when two commits are given") + if not opts.diff: + die("--diff is required when two commits are given") + elif opts.diff_from_common_commit: + die("--diff_from_common_commit is only allowed when two commits are given") + + if os.path.dirname(opts.binary): + opts.binary = os.path.abspath(opts.binary) + + changed_lines = compute_diff_and_extract_lines( + commits, files, opts.staged, opts.diff_from_common_commit + ) + if opts.verbose >= 1: + ignored_files = set(changed_lines) + filter_by_extension(changed_lines, opts.extensions.lower().split(",")) + # The computed diff outputs absolute paths, so we must cd before accessing + # those files. + cd_to_toplevel() + filter_symlinks(changed_lines) + filter_ignored_files(changed_lines, binary=opts.binary) + if opts.verbose >= 1: + ignored_files.difference_update(changed_lines) + if ignored_files: + print( + "Ignoring the following files (wrong extension, symlink, or " + "ignored by clang-format):" + ) + for filename in ignored_files: + print(" %s" % filename) + if changed_lines: + print("Running clang-format on the following files:") + for filename in changed_lines: + print(" %s" % filename) + + if not changed_lines: + if opts.verbose >= 0: + print("no modified files to format") + return 0 + + if len(commits) > 1: + old_tree = commits[1] + revision = old_tree + elif opts.staged: + old_tree = create_tree_from_index(changed_lines) + revision = "" + else: + old_tree = create_tree_from_workdir(changed_lines) + revision = None + new_tree = run_clang_format_and_save_to_tree( + changed_lines, revision, binary=opts.binary, style=opts.style + ) + if opts.verbose >= 1: + print("old tree: %s" % old_tree) + print("new tree: %s" % new_tree) + + if old_tree == new_tree: + if opts.verbose >= 0: + print("clang-format did not modify any files") + return 0 + + if opts.diff: + return print_diff(old_tree, new_tree) + if opts.diffstat: + return print_diffstat(old_tree, new_tree) + + changed_files = apply_changes( + old_tree, new_tree, force=opts.force, patch_mode=opts.patch + ) + if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1: + print("changed files:") + for filename in changed_files: + print(" %s" % filename) + + return 1 + + +def load_git_config(non_string_options=None): + """Return the git configuration as a dictionary. + + All options are assumed to be strings unless in `non_string_options`, in + which is a dictionary mapping option name (in lower case) to either "--bool" + or "--int".""" + if non_string_options is None: + non_string_options = {} + out = {} + for entry in run("git", "config", "--list", "--null").split("\0"): + if entry: + if "\n" in entry: + name, value = entry.split("\n", 1) + else: + # A setting with no '=' ('\n' with --null) is implicitly 'true' + name = entry + value = "true" + if name in non_string_options: + value = run("git", "config", non_string_options[name], name) + out[name] = value + return out + + +def interpret_args(args, dash_dash, default_commit): + """Interpret `args` as "[commits] [--] [files]" and return (commits, files). + + It is assumed that "--" and everything that follows has been removed from + args and placed in `dash_dash`. + + If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its + left (if present) are taken as commits. Otherwise, the arguments are + checked from left to right if they are commits or files. If commits are not + given, a list with `default_commit` is used.""" + if dash_dash: + if len(args) == 0: + commits = [default_commit] + else: + commits = args + for commit in commits: + object_type = get_object_type(commit) + if object_type not in ("commit", "tag"): + if object_type is None: + die("'%s' is not a commit" % commit) + else: + die( + "'%s' is a %s, but a commit was expected" + % (commit, object_type) + ) + files = dash_dash[1:] + elif args: + commits = [] + while args: + if not disambiguate_revision(args[0]): + break + commits.append(args.pop(0)) + if not commits: + commits = [default_commit] + files = args + else: + commits = [default_commit] + files = [] + return commits, files + + +def disambiguate_revision(value): + """Returns True if `value` is a revision, False if it is a file, or dies.""" + # If `value` is ambiguous (neither a commit nor a file), the following + # command will die with an appropriate error message. + run("git", "rev-parse", value, verbose=False) + object_type = get_object_type(value) + if object_type is None: + return False + if object_type in ("commit", "tag"): + return True + die("`%s` is a %s, but a commit or filename was expected" % (value, object_type)) + + +def get_object_type(value): + """Returns a string description of an object's type, or None if it is not + a valid git object.""" + cmd = ["git", "cat-file", "-t", value] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + if p.returncode != 0: + return None + return convert_string(stdout.strip()) + + +def compute_diff_and_extract_lines(commits, files, staged, diff_common_commit): + """Calls compute_diff() followed by extract_lines().""" + diff_process = compute_diff(commits, files, staged, diff_common_commit) + changed_lines = extract_lines(diff_process.stdout) + diff_process.stdout.close() + diff_process.wait() + if diff_process.returncode != 0: + # Assume error was already printed to stderr. + sys.exit(2) + return changed_lines + + +def compute_diff(commits, files, staged, diff_common_commit): + """Return a subprocess object producing the diff from `commits`. + + The return value's `stdin` file object will produce a patch with the + differences between the working directory (or stage if --staged is used) and + the first commit if a single one was specified, or the difference between + both specified commits, filtered on `files` (if non-empty). + Zero context lines are used in the patch.""" + git_tool = "diff-index" + extra_args = [] + if len(commits) == 2: + git_tool = "diff-tree" + if diff_common_commit: + extra_args += ["--merge-base"] + elif staged: + extra_args += ["--cached"] + + cmd = ["git", git_tool, "-p", "-U0"] + extra_args + commits + ["--"] + cmd.extend(files) + p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + p.stdin.close() + return p + + +def extract_lines(patch_file): + """Extract the changed lines in `patch_file`. + + The return value is a dictionary mapping filename to a list of (start_line, + line_count) pairs. + + The input must have been produced with ``-U0``, meaning unidiff format with + zero lines of context. The return value is a dict mapping filename to a + list of line `Range`s.""" + matches = {} + for line in patch_file: + line = convert_string(line) + match = re.search(r"^\+\+\+\ [^/]+/(.*)", line) + if match: + filename = match.group(1).rstrip("\r\n\t") + match = re.search(r"^@@ -[0-9,]+ \+(\d+)(,(\d+))?", line) + if match: + start_line = int(match.group(1)) + line_count = 1 + if match.group(3): + line_count = int(match.group(3)) + if line_count == 0: + line_count = 1 + if start_line == 0: + continue + matches.setdefault(filename, []).append(Range(start_line, line_count)) + return matches + + +def filter_by_extension(dictionary, allowed_extensions): + """Delete every key in `dictionary` that doesn't have an allowed extension. + + `allowed_extensions` must be a collection of lowercase file extensions, + excluding the period.""" + allowed_extensions = frozenset(allowed_extensions) + for filename in list(dictionary.keys()): + base_ext = filename.rsplit(".", 1) + if len(base_ext) == 1 and "" in allowed_extensions: + continue + if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions: + del dictionary[filename] + + +def filter_symlinks(dictionary): + """Delete every key in `dictionary` that is a symlink.""" + for filename in list(dictionary.keys()): + if os.path.islink(filename): + del dictionary[filename] + + +def filter_ignored_files(dictionary, binary): + """Delete every key in `dictionary` that is ignored by clang-format.""" + ignored_files = run(binary, "-list-ignored", *dictionary.keys()) + if not ignored_files: + return + ignored_files = ignored_files.split("\n") + for filename in ignored_files: + del dictionary[filename] + + +def cd_to_toplevel(): + """Change to the top level of the git repository.""" + toplevel = run("git", "rev-parse", "--show-toplevel") + os.chdir(toplevel) + + +def create_tree_from_workdir(filenames): + """Create a new git tree with the given files from the working directory. + + Returns the object ID (SHA-1) of the created tree.""" + return create_tree(filenames, "--stdin") + + +def create_tree_from_index(filenames): + # Copy the environment, because the files have to be read from the original + # index. + env = os.environ.copy() + + def index_contents_generator(): + for filename in filenames: + git_ls_files_cmd = [ + "git", + "ls-files", + "--stage", + "-z", + "--", + filename, + ] + git_ls_files = subprocess.Popen( + git_ls_files_cmd, + env=env, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + stdout = git_ls_files.communicate()[0] + yield convert_string(stdout.split(b"\0")[0]) + + return create_tree(index_contents_generator(), "--index-info") + + +def run_clang_format_and_save_to_tree( + changed_lines, revision=None, binary="clang-format", style=None +): + """Run clang-format on each file and save the result to a git tree. + + Returns the object ID (SHA-1) of the created tree.""" + # Copy the environment when formatting the files in the index, because the + # files have to be read from the original index. + env = os.environ.copy() if revision == "" else None + + def iteritems(container): + try: + return container.iteritems() # Python 2 + except AttributeError: + return container.items() # Python 3 + + def index_info_generator(): + for filename, line_ranges in iteritems(changed_lines): + if revision is not None: + if len(revision) > 0: + git_metadata_cmd = [ + "git", + "ls-tree", + "%s:%s" % (revision, os.path.dirname(filename)), + os.path.basename(filename), + ] + else: + git_metadata_cmd = [ + "git", + "ls-files", + "--stage", + "--", + filename, + ] + git_metadata = subprocess.Popen( + git_metadata_cmd, + env=env, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + stdout = git_metadata.communicate()[0] + mode = oct(int(stdout.split()[0], 8)) + else: + mode = oct(os.stat(filename).st_mode) + # Adjust python3 octal format so that it matches what git expects + if mode.startswith("0o"): + mode = "0" + mode[2:] + blob_id = clang_format_to_blob( + filename, + line_ranges, + revision=revision, + binary=binary, + style=style, + env=env, + ) + yield "%s %s\t%s" % (mode, blob_id, filename) + + return create_tree(index_info_generator(), "--index-info") + + +def create_tree(input_lines, mode): + """Create a tree object from the given input. + + If mode is '--stdin', it must be a list of filenames. If mode is + '--index-info' is must be a list of values suitable for "git update-index + --index-info", such as " ". Any other + mode is invalid.""" + assert mode in ("--stdin", "--index-info") + cmd = ["git", "update-index", "--add", "-z", mode] + with temporary_index_file(): + p = subprocess.Popen(cmd, stdin=subprocess.PIPE) + for line in input_lines: + p.stdin.write(to_bytes("%s\0" % line)) + p.stdin.close() + if p.wait() != 0: + die("`%s` failed" % " ".join(cmd)) + tree_id = run("git", "write-tree") + return tree_id + + +def clang_format_to_blob( + filename, + line_ranges, + revision=None, + binary="clang-format", + style=None, + env=None, +): + """Run clang-format on the given file and save the result to a git blob. + + Runs on the file in `revision` if not None, or on the file in the working + directory if `revision` is None. Revision can be set to an empty string to + run clang-format on the file in the index. + + Returns the object ID (SHA-1) of the created blob.""" + clang_format_cmd = [binary] + if style: + clang_format_cmd.extend(["--style=" + style]) + clang_format_cmd.extend( + [ + "--lines=%s:%s" % (start_line, start_line + line_count - 1) + for start_line, line_count in line_ranges + ] + ) + if revision is not None: + clang_format_cmd.extend(["--assume-filename=" + filename]) + git_show_cmd = [ + "git", + "cat-file", + "blob", + "%s:%s" % (revision, filename), + ] + git_show = subprocess.Popen( + git_show_cmd, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE + ) + git_show.stdin.close() + clang_format_stdin = git_show.stdout + else: + clang_format_cmd.extend([filename]) + git_show = None + clang_format_stdin = subprocess.PIPE + try: + clang_format = subprocess.Popen( + clang_format_cmd, stdin=clang_format_stdin, stdout=subprocess.PIPE + ) + if clang_format_stdin == subprocess.PIPE: + clang_format_stdin = clang_format.stdin + except OSError as e: + if e.errno == errno.ENOENT: + die('cannot find executable "%s"' % binary) + else: + raise + clang_format_stdin.close() + hash_object_cmd = [ + "git", + "hash-object", + "-w", + "--path=" + filename, + "--stdin", + ] + hash_object = subprocess.Popen( + hash_object_cmd, stdin=clang_format.stdout, stdout=subprocess.PIPE + ) + clang_format.stdout.close() + stdout = hash_object.communicate()[0] + if hash_object.returncode != 0: + die("`%s` failed" % " ".join(hash_object_cmd)) + if clang_format.wait() != 0: + die("`%s` failed" % " ".join(clang_format_cmd)) + if git_show and git_show.wait() != 0: + die("`%s` failed" % " ".join(git_show_cmd)) + return convert_string(stdout).rstrip("\r\n") + + +@contextlib.contextmanager +def temporary_index_file(tree=None): + """Context manager for setting GIT_INDEX_FILE to a temporary file and + deleting the file afterward.""" + index_path = create_temporary_index(tree) + old_index_path = os.environ.get("GIT_INDEX_FILE") + os.environ["GIT_INDEX_FILE"] = index_path + try: + yield + finally: + if old_index_path is None: + del os.environ["GIT_INDEX_FILE"] + else: + os.environ["GIT_INDEX_FILE"] = old_index_path + os.remove(index_path) + + +def create_temporary_index(tree=None): + """Create a temporary index file and return the created file's path. + + If `tree` is not None, use that as the tree to read in. Otherwise, an + empty index is created.""" + gitdir = run("git", "rev-parse", "--git-dir") + path = os.path.join(gitdir, temp_index_basename) + if tree is None: + tree = "--empty" + run("git", "read-tree", "--index-output=" + path, tree) + return path + + +def print_diff(old_tree, new_tree): + """Print the diff between the two trees to stdout.""" + # We use the porcelain 'diff' and not plumbing 'diff-tree' because the + # output is expected to be viewed by the user, and only the former does nice + # things like color and pagination. + # + # We also only print modified files since `new_tree` only contains the files + # that were modified, so unmodified files would show as deleted without the + # filter. + return subprocess.run( + ["git", "diff", "--diff-filter=M", "--exit-code", old_tree, new_tree] + ).returncode + + +def print_diffstat(old_tree, new_tree): + """Print the diffstat between the two trees to stdout.""" + # We use the porcelain 'diff' and not plumbing 'diff-tree' because the + # output is expected to be viewed by the user, and only the former does nice + # things like color and pagination. + # + # We also only print modified files since `new_tree` only contains the files + # that were modified, so unmodified files would show as deleted without the + # filter. + return subprocess.run( + [ + "git", + "diff", + "--diff-filter=M", + "--exit-code", + "--stat", + old_tree, + new_tree, + ] + ).returncode + + +def apply_changes(old_tree, new_tree, force=False, patch_mode=False): + """Apply the changes in `new_tree` to the working directory. + + Bails if there are local changes in those files and not `force`. If + `patch_mode`, runs `git checkout --patch` to select hunks interactively.""" + changed_files = ( + run( + "git", + "diff-tree", + "--diff-filter=M", + "-r", + "-z", + "--name-only", + old_tree, + new_tree, + ) + .rstrip("\0") + .split("\0") + ) + if not force: + unstaged_files = run("git", "diff-files", "--name-status", *changed_files) + if unstaged_files: + print( + "The following files would be modified but have unstaged changes:", + file=sys.stderr, + ) + print(unstaged_files, file=sys.stderr) + print("Please commit, stage, or stash them first.", file=sys.stderr) + sys.exit(2) + if patch_mode: + # In patch mode, we could just as well create an index from the new tree + # and checkout from that, but then the user will be presented with a + # message saying "Discard ... from worktree". Instead, we use the old + # tree as the index and checkout from new_tree, which gives the slightly + # better message, "Apply ... to index and worktree". This is not quite + # right, since it won't be applied to the user's index, but oh well. + with temporary_index_file(old_tree): + subprocess.run(["git", "checkout", "--patch", new_tree], check=True) + index_tree = old_tree + else: + with temporary_index_file(new_tree): + run("git", "checkout-index", "-f", "--", *changed_files) + return changed_files + + +def run(*args, **kwargs): + stdin = kwargs.pop("stdin", "") + verbose = kwargs.pop("verbose", True) + strip = kwargs.pop("strip", True) + for name in kwargs: + raise TypeError("run() got an unexpected keyword argument '%s'" % name) + p = subprocess.Popen( + args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + stdin=subprocess.PIPE, + ) + stdout, stderr = p.communicate(input=stdin) + + stdout = convert_string(stdout) + stderr = convert_string(stderr) + + if p.returncode == 0: + if stderr: + if verbose: + print("`%s` printed to stderr:" % " ".join(args), file=sys.stderr) + print(stderr.rstrip(), file=sys.stderr) + if strip: + stdout = stdout.rstrip("\r\n") + return stdout + if verbose: + print("`%s` returned %s" % (" ".join(args), p.returncode), file=sys.stderr) + if stderr: + print(stderr.rstrip(), file=sys.stderr) + sys.exit(2) + + +def die(message): + print("error:", message, file=sys.stderr) + sys.exit(2) + + +def to_bytes(str_input): + # Encode to UTF-8 to get binary data. + if isinstance(str_input, bytes): + return str_input + return str_input.encode("utf-8") + + +def to_string(bytes_input): + if isinstance(bytes_input, str): + return bytes_input + return bytes_input.encode("utf-8") + + +def convert_string(bytes_input): + try: + return to_string(bytes_input.decode("utf-8")) + except AttributeError: # 'str' object has no attribute 'decode'. + return str(bytes_input) + except UnicodeError: + return str(bytes_input) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/hmaptool b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/hmaptool new file mode 100755 index 0000000..d775463 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/hmaptool @@ -0,0 +1,297 @@ +#!/usr/bin/env python3 +from __future__ import absolute_import, division, print_function + +from ctypes import ArgumentError +import json +import optparse +import os +import struct +import sys + +### + +k_header_magic_LE = b'pamh' +k_header_magic_BE = b'hmap' + +def hmap_hash(str): + """hash(str) -> int + + Apply the "well-known" headermap hash function. + """ + + return sum((ord(c.lower()) * 13 + for c in str), 0) + +class HeaderMap(object): + @staticmethod + def frompath(path): + with open(path, 'rb') as f: + magic = f.read(4) + if magic == k_header_magic_LE: + endian_code = '<' + elif magic == k_header_magic_BE: + endian_code = '>' + else: + raise SystemExit("error: %s: not a headermap" % ( + path,)) + + # Read the header information. + header_fmt = endian_code + 'HHIIII' + header_size = struct.calcsize(header_fmt) + data = f.read(header_size) + if len(data) != header_size: + raise SystemExit("error: %s: truncated headermap header" % ( + path,)) + + (version, reserved, strtable_offset, num_entries, + num_buckets, _) = struct.unpack(header_fmt, data) + + if version != 1: + raise SystemExit("error: %s: unknown headermap version: %r" % ( + path, version)) + if reserved != 0: + raise SystemExit("error: %s: invalid reserved value in header" % ( + path,)) + + # The number of buckets must be a power of two. + if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0: + raise SystemExit("error: %s: invalid number of buckets" % ( + path,)) + + # Read all of the buckets. + bucket_fmt = endian_code + 'III' + bucket_size = struct.calcsize(bucket_fmt) + buckets_data = f.read(num_buckets * bucket_size) + if len(buckets_data) != num_buckets * bucket_size: + raise SystemExit("error: %s: truncated headermap buckets" % ( + path,)) + buckets = [struct.unpack(bucket_fmt, + buckets_data[i*bucket_size:(i+1)*bucket_size]) + for i in range(num_buckets)] + + # Read the string table; the format doesn't explicitly communicate the + # size of the string table (which is dumb), so assume it is the rest of + # the file. + f.seek(0, 2) + strtable_size = f.tell() - strtable_offset + f.seek(strtable_offset) + + if strtable_size == 0: + raise SystemExit("error: %s: unable to read zero-sized string table"%( + path,)) + strtable = f.read(strtable_size) + + if len(strtable) != strtable_size: + raise SystemExit("error: %s: unable to read complete string table"%( + path,)) + if strtable[-1] != 0: + raise SystemExit("error: %s: invalid string table in headermap" % ( + path,)) + + return HeaderMap(num_entries, buckets, strtable) + + def __init__(self, num_entries, buckets, strtable): + self.num_entries = num_entries + self.buckets = buckets + self.strtable = strtable + + def get_string(self, idx): + if idx >= len(self.strtable): + raise SystemExit("error: %s: invalid string index" % ( + idx,)) + end_idx = self.strtable.index(0, idx) + return self.strtable[idx:end_idx].decode() + + @property + def mappings(self): + for key_idx,prefix_idx,suffix_idx in self.buckets: + if key_idx == 0: + continue + yield (self.get_string(key_idx), + self.get_string(prefix_idx) + self.get_string(suffix_idx)) + +### + +def action_dump(name, args): + "dump a headermap file" + + parser = optparse.OptionParser("%%prog %s [options] " % ( + name,)) + parser.add_option("-v", "--verbose", dest="verbose", + help="show more verbose output [%default]", + action="store_true", default=False) + (opts, args) = parser.parse_args(args) + + if len(args) != 1: + parser.error("invalid number of arguments") + + path, = args + + hmap = HeaderMap.frompath(path) + + # Dump all of the buckets. + print ('Header Map: %s' % (path,)) + if opts.verbose: + print ('headermap: %r' % (path,)) + print (' num entries: %d' % (hmap.num_entries,)) + print (' num buckets: %d' % (len(hmap.buckets),)) + print (' string table size: %d' % (len(hmap.strtable),)) + for i,bucket in enumerate(hmap.buckets): + key_idx,prefix_idx,suffix_idx = bucket + + if key_idx == 0: + continue + + # Get the strings. + key = hmap.get_string(key_idx) + prefix = hmap.get_string(prefix_idx) + suffix = hmap.get_string(suffix_idx) + + print (" bucket[%d]: %r -> (%r, %r) -- %d" % ( + i, key, prefix, suffix, (hmap_hash(key) & (len(hmap.buckets) - 1)))) + else: + mappings = sorted(hmap.mappings) + for key,value in mappings: + print ("%s -> %s" % (key, value)) + print () + +def next_power_of_two(value): + if value < 0: + raise ArgumentError + return 1 if value == 0 else 2**(value - 1).bit_length() + +def action_write(name, args): + "write a headermap file from a JSON definition" + + parser = optparse.OptionParser("%%prog %s [options] " % ( + name,)) + (opts, args) = parser.parse_args(args) + + if len(args) != 2: + parser.error("invalid number of arguments") + + input_path,output_path = args + + with open(input_path, "r") as f: + input_data = json.load(f) + + # Compute the headermap contents, we make a table that is 1/3 full. + mappings = input_data['mappings'] + num_buckets = next_power_of_two(len(mappings) * 3) + + table = [(0, 0, 0) + for i in range(num_buckets)] + max_value_len = 0 + strtable = "\0" + for key,value in mappings.items(): + if not isinstance(key, str): + key = key.decode('utf-8') + if not isinstance(value, str): + value = value.decode('utf-8') + max_value_len = max(max_value_len, len(value)) + + key_idx = len(strtable) + strtable += key + '\0' + prefix = os.path.dirname(value) + '/' + suffix = os.path.basename(value) + prefix_idx = len(strtable) + strtable += prefix + '\0' + suffix_idx = len(strtable) + strtable += suffix + '\0' + + hash = hmap_hash(key) + for i in range(num_buckets): + idx = (hash + i) % num_buckets + if table[idx][0] == 0: + table[idx] = (key_idx, prefix_idx, suffix_idx) + break + else: + raise RuntimeError + + endian_code = '<' + magic = k_header_magic_LE + magic_size = 4 + header_fmt = endian_code + 'HHIIII' + header_size = struct.calcsize(header_fmt) + bucket_fmt = endian_code + 'III' + bucket_size = struct.calcsize(bucket_fmt) + strtable_offset = magic_size + header_size + num_buckets * bucket_size + header = (1, 0, strtable_offset, len(mappings), + num_buckets, max_value_len) + + # Write out the headermap. + with open(output_path, 'wb') as f: + f.write(magic) + f.write(struct.pack(header_fmt, *header)) + for bucket in table: + f.write(struct.pack(bucket_fmt, *bucket)) + f.write(strtable.encode()) + +def action_tovfs(name, args): + "convert a headermap to a VFS layout" + + parser = optparse.OptionParser("%%prog %s [options] " % ( + name,)) + parser.add_option("", "--build-path", dest="build_path", + help="build path prefix", + action="store", type=str) + (opts, args) = parser.parse_args(args) + + if len(args) != 2: + parser.error("invalid number of arguments") + if opts.build_path is None: + parser.error("--build-path is required") + + input_path,output_path = args + + hmap = HeaderMap.frompath(input_path) + + # Create the table for all the objects. + vfs = {} + vfs['version'] = 0 + build_dir_contents = [] + vfs['roots'] = [{ + 'name' : opts.build_path, + 'type' : 'directory', + 'contents' : build_dir_contents }] + + # We assume we are mapping framework paths, so a key of "Foo/Bar.h" maps to + # "/Foo.framework/Headers/Bar.h". + for key,value in hmap.mappings: + # If this isn't a framework style mapping, ignore it. + components = key.split('/') + if len(components) != 2: + continue + framework_name,header_name = components + build_dir_contents.append({ + 'name' : '%s.framework/Headers/%s' % (framework_name, + header_name), + 'type' : 'file', + 'external-contents' : value }) + + with open(output_path, 'w') as f: + json.dump(vfs, f, indent=2) + +commands = dict((name[7:].replace("_","-"), f) + for name,f in locals().items() + if name.startswith('action_')) + +def usage(): + print ("Usage: %s command [options]" % ( + os.path.basename(sys.argv[0])), file=sys.stderr) + print (file=sys.stderr) + print ("Available commands:", file=sys.stderr) + cmds_width = max(map(len, commands)) + for name,func in sorted(commands.items()): + print (" %-*s - %s" % (cmds_width, name, func.__doc__), file=sys.stderr) + sys.exit(1) + +def main(): + if len(sys.argv) < 2 or sys.argv[1] not in commands: + usage() + + cmd = sys.argv[1] + commands[cmd](cmd, sys.argv[2:]) + +if __name__ == '__main__': + main() diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/intercept-build b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/intercept-build new file mode 100755 index 0000000..dcd0473 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/intercept-build @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import multiprocessing +import sys +import os.path +this_dir = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib')) + +from libscanbuild.intercept import intercept_build + +if __name__ == '__main__': + multiprocessing.freeze_support() + sys.exit(intercept_build()) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/ld.lld b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/ld.lld new file mode 100755 index 0000000..02416ac --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/ld.lld @@ -0,0 +1 @@ +lld \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/ld64.lld b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/ld64.lld new file mode 100755 index 0000000..02416ac --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/ld64.lld @@ -0,0 +1 @@ +lld \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llc b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llc new file mode 100755 index 0000000..a399a89 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llc @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llc.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/lld b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/lld new file mode 100755 index 0000000..8235a08 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/lld @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.lld.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/lld-link b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/lld-link new file mode 100755 index 0000000..02416ac --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/lld-link @@ -0,0 +1 @@ +lld \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-ar b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-ar new file mode 100755 index 0000000..73f9272 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-ar @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-ar.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-as b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-as new file mode 100755 index 0000000..5a6778b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-as @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-as.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-dis b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-dis new file mode 100755 index 0000000..778eef9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-dis @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-dis.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-link b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-link new file mode 100755 index 0000000..229c977 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-link @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-link.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-nm b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-nm new file mode 100755 index 0000000..ae02925 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-nm @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-nm.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-objcopy b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-objcopy new file mode 100755 index 0000000..f88ea69 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-objcopy @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-objcopy.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-objdump b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-objdump new file mode 100755 index 0000000..fcc057d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-objdump @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.llvm-objdump.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-ranlib b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-ranlib new file mode 100755 index 0000000..3b94d1a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-ranlib @@ -0,0 +1 @@ +llvm-ar \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-strip b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-strip new file mode 100755 index 0000000..caea5a7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/llvm-strip @@ -0,0 +1 @@ +llvm-objcopy \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/nvptx-arch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/nvptx-arch new file mode 100755 index 0000000..f1049b8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/nvptx-arch @@ -0,0 +1 @@ +offload-arch \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/offload-arch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/offload-arch new file mode 100755 index 0000000..4c36c06 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/offload-arch @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.offload-arch.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/opt b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/opt new file mode 100755 index 0000000..813ba70 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/opt @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +dir="$(dirname "$0")" +export RUNAS_ARG0="$0" +export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$dir/../../lib/runas.so" +exec "$dir/../../lib/ld-linux-x86-64.so.2" --library-path "$dir/../../lib/" "$dir/.opt.bin" "$@" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-build b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-build new file mode 100755 index 0000000..da7fe94 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-build @@ -0,0 +1,1985 @@ +#!/usr/bin/env perl +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +##===----------------------------------------------------------------------===## +# +# A script designed to wrap a build so that all calls to gcc are intercepted +# and piped to the static analyzer. +# +##===----------------------------------------------------------------------===## + +use strict; +use warnings; +use FindBin qw($RealBin); +use File::Basename; +use File::Find; +use File::Copy qw(copy); +use File::Path qw( rmtree mkpath ); +use Term::ANSIColor; +use Term::ANSIColor qw(:constants); +use Cwd qw/ getcwd abs_path /; +use Sys::Hostname; +use Hash::Util qw(lock_keys); + +my $Prog = "scan-build"; +my $BuildName; +my $BuildDate; + +my $TERM = $ENV{'TERM'}; +my $UseColor = (defined $TERM and $TERM =~ 'xterm-.*color' and -t STDOUT + and defined $ENV{'SCAN_BUILD_COLOR'}); + +# Portability: getpwuid is not implemented for Win32 (see Perl language +# reference, perlport), use getlogin instead. +my $UserName = HtmlEscape(getlogin() || getpwuid($<) || 'unknown'); +my $HostName = HtmlEscape(hostname() || 'unknown'); +my $CurrentDir = HtmlEscape(getcwd()); + +my $CmdArgs; + +my $Date = localtime(); + +# Command-line/config arguments. +my %Options = ( + Verbose => 0, # Verbose output from this script. + AnalyzeHeaders => 0, + OutputDir => undef, # Parent directory to store HTML files. + HtmlTitle => basename($CurrentDir)." - scan-build results", + IgnoreErrors => 0, # Ignore build errors. + KeepCC => 0, # Do not override CC and CXX make variables + ViewResults => 0, # View results when the build terminates. + ExitStatusFoundBugs => 0, # Exit status reflects whether bugs were found + ShowDescription => 0, # Display the description of the defect in the list + KeepEmpty => 0, # Don't remove output directory even with 0 results. + EnableCheckers => {}, + DisableCheckers => {}, + SilenceCheckers => {}, + Excludes => [], + UseCC => undef, # C compiler to use for compilation. + UseCXX => undef, # C++ compiler to use for compilation. + AnalyzerTarget => undef, + ConstraintsModel => undef, + InternalStats => undef, + OutputFormat => "html", + ConfigOptions => [], # Options to pass through to the analyzer's -analyzer-config flag. + ReportFailures => undef, + AnalyzerStats => 0, + MaxLoop => 0, + PluginsToLoad => [], + AnalyzerDiscoveryMethod => undef, + OverrideCompiler => 0, # The flag corresponding to the --override-compiler command line option. + ForceAnalyzeDebugCode => 0, + GenerateIndex => 0 # Skip the analysis, only generate index.html. +); +lock_keys(%Options); + +##----------------------------------------------------------------------------## +# Diagnostics +##----------------------------------------------------------------------------## + +sub Diag { + if ($UseColor) { + print BOLD, MAGENTA "$Prog: @_"; + print RESET; + } + else { + print "$Prog: @_"; + } +} + +sub ErrorDiag { + if ($UseColor) { + print STDERR BOLD, RED "$Prog: "; + print STDERR RESET, RED @_; + print STDERR RESET; + } else { + print STDERR "$Prog: @_"; + } +} + +sub DiagCrashes { + my $Dir = shift; + Diag ("The analyzer encountered problems on some source files.\n"); + Diag ("Preprocessed versions of these sources were deposited in '$Dir/failures'.\n"); + Diag ("Please consider submitting a bug report using these files:\n"); + Diag (" http://clang-analyzer.llvm.org/filing_bugs.html\n") +} + +sub DieDiag { + if ($UseColor) { + print STDERR BOLD, RED "$Prog: "; + print STDERR RESET, RED @_; + print STDERR RESET; + } + else { + print STDERR "$Prog: ", @_; + } + exit 1; +} + +##----------------------------------------------------------------------------## +# Print default checker names +##----------------------------------------------------------------------------## + +if (grep /^--help-checkers$/, @ARGV) { + my @options = qx($0 -h); + foreach (@options) { + next unless /^ \+/; + s/^\s*//; + my ($sign, $name, @text) = split ' ', $_; + print $name, $/ if $sign eq '+'; + } + exit 0; +} + +##----------------------------------------------------------------------------## +# Declaration of Clang options. Populated later. +##----------------------------------------------------------------------------## + +my $Clang; +my $ClangSB; +my $ClangCXX; +my $ClangVersion; + +##----------------------------------------------------------------------------## +# GetHTMLRunDir - Construct an HTML directory name for the current sub-run. +##----------------------------------------------------------------------------## + +sub GetHTMLRunDir { + die "Not enough arguments." if (@_ == 0); + my $Dir = shift @_; + my $TmpMode = 0; + if (!defined $Dir) { + $Dir = $ENV{'TMPDIR'} || $ENV{'TEMP'} || $ENV{'TMP'} || "/tmp"; + $TmpMode = 1; + } + + # Chop off any trailing '/' characters. + while ($Dir =~ /\/$/) { chop $Dir; } + + # Get current date and time. + my @CurrentTime = localtime(); + my $year = $CurrentTime[5] + 1900; + my $day = $CurrentTime[3]; + my $month = $CurrentTime[4] + 1; + my $hour = $CurrentTime[2]; + my $min = $CurrentTime[1]; + my $sec = $CurrentTime[0]; + + my $TimeString = sprintf("%02d%02d%02d", $hour, $min, $sec); + my $DateString = sprintf("%d-%02d-%02d-%s-$$", + $year, $month, $day, $TimeString); + + # Determine the run number. + my $RunNumber; + + if (-d $Dir) { + if (! -r $Dir) { + DieDiag("directory '$Dir' exists but is not readable.\n"); + } + # Iterate over all files in the specified directory. + my $max = 0; + opendir(DIR, $Dir); + my @FILES = grep { -d "$Dir/$_" } readdir(DIR); + closedir(DIR); + + foreach my $f (@FILES) { + # Strip the prefix '$Prog-' if we are dumping files to /tmp. + if ($TmpMode) { + next if (!($f =~ /^$Prog-(.+)/)); + $f = $1; + } + + my @x = split/-/, $f; + next if (scalar(@x) != 4); + next if ($x[0] != $year); + next if ($x[1] != $month); + next if ($x[2] != $day); + next if ($x[3] != $TimeString); + next if ($x[4] != $$); + + if ($x[5] > $max) { + $max = $x[5]; + } + } + + $RunNumber = $max + 1; + } + else { + + if (-x $Dir) { + DieDiag("'$Dir' exists but is not a directory.\n"); + } + + if ($TmpMode) { + DieDiag("The directory '/tmp' does not exist or cannot be accessed.\n"); + } + + # $Dir does not exist. It will be automatically created by the + # clang driver. Set the run number to 1. + + $RunNumber = 1; + } + + die "RunNumber must be defined!" if (!defined $RunNumber); + + # Append the run number. + my $NewDir; + if ($TmpMode) { + $NewDir = "$Dir/$Prog-$DateString-$RunNumber"; + } + else { + $NewDir = "$Dir/$DateString-$RunNumber"; + } + + # Make sure that the directory does not exist in order to avoid hijack. + if (-e $NewDir) { + DieDiag("The directory '$NewDir' already exists.\n"); + } + + mkpath($NewDir); + return $NewDir; +} + +sub SetHtmlEnv { + + die "Wrong number of arguments." if (scalar(@_) != 2); + + my $Args = shift; + my $Dir = shift; + + die "No build command." if (scalar(@$Args) == 0); + + my $Cmd = $$Args[0]; + + if ($Cmd =~ /configure/ || $Cmd =~ /autogen/) { + return; + } + + if ($Options{Verbose}) { + Diag("Emitting reports for this run to '$Dir'.\n"); + } + + $ENV{'CCC_ANALYZER_HTML'} = $Dir; +} + +##----------------------------------------------------------------------------## +# UpdatePrefix - Compute the common prefix of files. +##----------------------------------------------------------------------------## + +my $Prefix; + +sub UpdatePrefix { + my $x = shift; + my $y = basename($x); + $x =~ s/\Q$y\E$//; + + if (!defined $Prefix) { + $Prefix = $x; + return; + } + + chop $Prefix while (!($x =~ /^\Q$Prefix/)); +} + +sub GetPrefix { + return $Prefix; +} + +##----------------------------------------------------------------------------## +# UpdateInFilePath - Update the path in the report file. +##----------------------------------------------------------------------------## + +sub UpdateInFilePath { + my $fname = shift; + my $regex = shift; + my $newtext = shift; + + open (RIN, $fname) or die "cannot open $fname"; + open (ROUT, ">", "$fname.tmp") or die "cannot open $fname.tmp"; + + while () { + s/$regex/$newtext/; + print ROUT $_; + } + + close (ROUT); + close (RIN); + rename("$fname.tmp", $fname) +} + +##----------------------------------------------------------------------------## +# AddStatLine - Decode and insert a statistics line into the database. +##----------------------------------------------------------------------------## + +sub AddStatLine { + my $Line = shift; + my $Stats = shift; + my $File = shift; + + print $Line . "\n"; + + my $Regex = qr/(.*?)\ ->\ Total\ CFGBlocks:\ (\d+)\ \|\ Unreachable + \ CFGBlocks:\ (\d+)\ \|\ Exhausted\ Block:\ (yes|no)\ \|\ Empty\ WorkList: + \ (yes|no)/x; + + if ($Line !~ $Regex) { + return; + } + + # Create a hash of the interesting fields + my $Row = { + Filename => $File, + Function => $1, + Total => $2, + Unreachable => $3, + Aborted => $4, + Empty => $5 + }; + + # Add them to the stats array + push @$Stats, $Row; +} + +##----------------------------------------------------------------------------## +# ScanFile - Scan a report file for various identifying attributes. +##----------------------------------------------------------------------------## + +# Sometimes a source file is scanned more than once, and thus produces +# multiple error reports. We use a cache to solve this problem. + +sub ScanFile { + + my $Index = shift; + my $Dir = shift; + my $FName = shift; + my $Stats = shift; + + # At this point the report file is not world readable. Make it happen. + chmod(0644, "$Dir/$FName"); + + # Scan the report file for tags. + open(IN, "$Dir/$FName") or DieDiag("Cannot open '$Dir/$FName'\n"); + + my $BugType = ""; + my $BugFile = ""; + my $BugFunction = ""; + my $BugCategory = ""; + my $BugDescription = ""; + my $BugPathLength = 1; + my $BugLine = 0; + + while () { + last if (//); + + if (/$/) { + $BugType = $1; + } + elsif (/$/) { + $BugFile = abs_path($1); + if (!defined $BugFile) { + # The file no longer exists: use the original path. + $BugFile = $1; + } + + # Get just the path + my $p = dirname($BugFile); + # Check if the path is found in the list of exclude + if (grep { $p =~ m/$_/ } @{$Options{Excludes}}) { + if ($Options{Verbose}) { + Diag("File '$BugFile' deleted: part of an ignored directory.\n"); + } + + # File in an ignored directory. Remove it + unlink("$Dir/$FName"); + return; + } + + UpdatePrefix($BugFile); + } + elsif (/$/) { + $BugPathLength = $1; + } + elsif (/$/) { + $BugLine = $1; + } + elsif (/$/) { + $BugCategory = $1; + } + elsif (/$/) { + $BugDescription = $1; + } + elsif (/$/) { + $BugFunction = $1; + } + + } + + + close(IN); + + if (!defined $BugCategory) { + $BugCategory = "Other"; + } + + # Don't add internal statistics to the bug reports + if ($BugCategory =~ /statistics/i) { + AddStatLine($BugDescription, $Stats, $BugFile); + return; + } + + push @$Index,[ $FName, $BugCategory, $BugType, $BugFile, $BugFunction, $BugLine, + $BugPathLength ]; + + if ($Options{ShowDescription}) { + push @{ $Index->[-1] }, $BugDescription + } +} + +##----------------------------------------------------------------------------## +# CopyFiles - Copy resource files to target directory. +##----------------------------------------------------------------------------## + +sub CopyFiles { + + my $Dir = shift; + + my $JS = Cwd::realpath("$RealBin/../share/scan-build/sorttable.js"); + + DieDiag("Cannot find 'sorttable.js'.\n") + if (! -r $JS); + + copy($JS, "$Dir"); + + DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n") + if (! -r "$Dir/sorttable.js"); + + my $CSS = Cwd::realpath("$RealBin/../share/scan-build/scanview.css"); + + DieDiag("Cannot find 'scanview.css'.\n") + if (! -r $CSS); + + copy($CSS, "$Dir"); + + DieDiag("Could not copy 'scanview.css' to '$Dir'.\n") + if (! -r $CSS); +} + +##----------------------------------------------------------------------------## +# CalcStats - Calculates visitation statistics and returns the string. +##----------------------------------------------------------------------------## + +sub CalcStats { + my $Stats = shift; + + my $TotalBlocks = 0; + my $UnreachedBlocks = 0; + my $TotalFunctions = scalar(@$Stats); + my $BlockAborted = 0; + my $WorkListAborted = 0; + my $Aborted = 0; + + # Calculate the unique files + my $FilesHash = {}; + + foreach my $Row (@$Stats) { + $FilesHash->{$Row->{Filename}} = 1; + $TotalBlocks += $Row->{Total}; + $UnreachedBlocks += $Row->{Unreachable}; + $BlockAborted++ if $Row->{Aborted} eq 'yes'; + $WorkListAborted++ if $Row->{Empty} eq 'no'; + $Aborted++ if $Row->{Aborted} eq 'yes' || $Row->{Empty} eq 'no'; + } + + my $TotalFiles = scalar(keys(%$FilesHash)); + + # Calculations + my $PercentAborted = sprintf("%.2f", $Aborted / $TotalFunctions * 100); + my $PercentBlockAborted = sprintf("%.2f", $BlockAborted / $TotalFunctions + * 100); + my $PercentWorkListAborted = sprintf("%.2f", $WorkListAborted / + $TotalFunctions * 100); + my $PercentBlocksUnreached = sprintf("%.2f", $UnreachedBlocks / $TotalBlocks + * 100); + + my $StatsString = "Analyzed $TotalBlocks blocks in $TotalFunctions functions" + . " in $TotalFiles files\n" + . "$Aborted functions aborted early ($PercentAborted%)\n" + . "$BlockAborted had aborted blocks ($PercentBlockAborted%)\n" + . "$WorkListAborted had unfinished worklists ($PercentWorkListAborted%)\n" + . "$UnreachedBlocks blocks were never reached ($PercentBlocksUnreached%)\n"; + + return $StatsString; +} + +##----------------------------------------------------------------------------## +# Postprocess - Postprocess the results of an analysis scan. +##----------------------------------------------------------------------------## + +my @filesFound; +my $baseDir; +sub FileWanted { + my $baseDirRegEx = quotemeta $baseDir; + my $file = $File::Find::name; + + # The name of the file is generated by clang binary (HTMLDiagnostics.cpp) + if ($file =~ /report-.*\.html$/) { + my $relative_file = $file; + $relative_file =~ s/$baseDirRegEx//g; + push @filesFound, $relative_file; + } +} + +sub Postprocess { + + my $Dir = shift; + my $BaseDir = shift; + my $AnalyzerStats = shift; + my $KeepEmpty = shift; + + die "No directory specified." if (!defined $Dir); + + if (! -d $Dir) { + Diag("No bugs found.\n"); + return 0; + } + + $baseDir = $Dir . "/"; + find({ wanted => \&FileWanted, follow => 0}, $Dir); + + if (scalar(@filesFound) == 0 and ! -e "$Dir/failures") { + if (! $KeepEmpty) { + Diag("Removing directory '$Dir' because it contains no reports.\n"); + rmtree($Dir) or die "Cannot rmtree '$Dir' : $!"; + } + Diag("No bugs found.\n"); + return 0; + } + + # Scan each report file, in alphabetical order, and build an index. + my @Index; + my @Stats; + + @filesFound = sort @filesFound; + foreach my $file (@filesFound) { ScanFile(\@Index, $Dir, $file, \@Stats); } + + # Scan the failures directory and use the information in the .info files + # to update the common prefix directory. + my @failures; + my @attributes_ignored; + if (-d "$Dir/failures") { + opendir(DIR, "$Dir/failures"); + @failures = grep { /[.]info.txt$/ && !/attribute_ignored/; } readdir(DIR); + closedir(DIR); + opendir(DIR, "$Dir/failures"); + @attributes_ignored = grep { /^attribute_ignored/; } readdir(DIR); + closedir(DIR); + foreach my $file (@failures) { + open IN, "$Dir/failures/$file" or DieDiag("cannot open $file\n"); + my $Path = ; + if (defined $Path) { UpdatePrefix($Path); } + close IN; + } + } + + # Generate an index.html file. + my $FName = "$Dir/index.html"; + open(OUT, ">", $FName) or DieDiag("Cannot create file '$FName'\n"); + + # Print out the header. + +print OUT < + +${Options{HtmlTitle}} + + + + + + +

${Options{HtmlTitle}}

+ + + + + + + +ENDTEXT + +print OUT "\n" + if (defined($BuildName) && defined($BuildDate)); + +print OUT < +ENDTEXT + + if (scalar(@filesFound)) { + # Print out the summary table. + my %Totals; + + for my $row ( @Index ) { + my $bug_type = ($row->[2]); + my $bug_category = ($row->[1]); + my $key = "$bug_category:$bug_type"; + + if (!defined $Totals{$key}) { $Totals{$key} = [1,$bug_category,$bug_type]; } + else { $Totals{$key}->[0]++; } + } + + print OUT "

Bug Summary

"; + + if (defined $BuildName) { + print OUT "\n

Results in this analysis run are based on analyzer build $BuildName.

\n" + } + + my $TotalBugs = scalar(@Index); +print OUT < +
+ +ENDTEXT + + my $last_category; + + for my $key ( + sort { + my $x = $Totals{$a}; + my $y = $Totals{$b}; + my $res = $x->[1] cmp $y->[1]; + $res = $x->[2] cmp $y->[2] if ($res == 0); + $res + } keys %Totals ) + { + my $val = $Totals{$key}; + my $category = $val->[1]; + if (!defined $last_category or $last_category ne $category) { + $last_category = $category; + print OUT "\n"; + } + my $x = lc $key; + $x =~ s/[ ,'":\/()]+/_/g; + print OUT "\n"; + } + + # Print out the table of errors. + +print OUT < + +

Filter Results by File

+ + +

Reports

+ +
User:${UserName}\@${HostName}
Working Directory:${CurrentDir}
Command Line:${CmdArgs}
Clang Version:${ClangVersion}
Date:${Date}
Version:${BuildName} (${BuildDate})
Bug TypeQuantityDisplay?
All Bugs$TotalBugs
$category
"; + print OUT $val->[2]; + print OUT ""; + print OUT $val->[0]; + print OUT "
+ + + + + + + +ENDTEXT + +if ($Options{ShowDescription}) { +print OUT <Description +ENDTEXT +} + +print OUT < + + + +ENDTEXT + + my $prefix = GetPrefix(); + my $regex; + my $InFileRegex; + my $InFilePrefix = "File:"; + print OUT ""; + print OUT ""; + + # Update the file prefix. + my $fname = $row->[3]; + + if (defined $regex) { + $fname =~ s/$regex//; + UpdateInFilePath("$Dir/$ReportFile", $InFileRegex, $InFilePrefix) + } + + print OUT ""; + + print OUT ""; + + # Print out the quantities. + for my $j ( 5 .. 6 ) { # Line & Path length + print OUT ""; + } + + # Print the rest of the columns. + for (my $j = 7; $j <= $#{$row}; ++$j) { + print OUT "" + } + + # Emit the "View" link. + my $EncodedReport = URLEscape($ReportFile); + print OUT ""; + + # Emit REPORTBUG markers. + print OUT "\n\n"; + + # End the row. + print OUT "\n"; + } + + print OUT "\n
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
"; + + if (defined $prefix) { + $regex = qr/^\Q$prefix\E/is; + $InFileRegex = qr/\Q$InFilePrefix$prefix\E/is; + } + + for my $row ( sort { $a->[2] cmp $b->[2] } @Index ) { + my $x = "$row->[1]:$row->[2]"; + $x = lc $x; + $x =~ s/[ ,'":\/()]+/_/g; + + my $ReportFile = $row->[0]; + + print OUT "
"; + print OUT $row->[1]; # $BugCategory + print OUT ""; + print OUT $row->[2]; # $BugType + print OUT ""; + my @fname = split /\//,$fname; + if ($#fname > 0) { + while ($#fname >= 0) { + my $x = shift @fname; + print OUT $x; + if ($#fname >= 0) { + print OUT "/"; + } + } + } + else { + print OUT $fname; + } + print OUT ""; + print OUT $row->[4]; # Function + print OUT "$row->[$j]$row->[$j]View Report
\n\n"; + } + + if (scalar (@failures) || scalar(@attributes_ignored)) { + print OUT "

Analyzer Failures

\n"; + + if (scalar @attributes_ignored) { + print OUT "The analyzer's parser ignored the following attributes:

\n"; + print OUT "\n"; + print OUT "\n"; + foreach my $file (sort @attributes_ignored) { + die "cannot demangle attribute name\n" if (! ($file =~ /^attribute_ignored_(.+).txt/)); + my $attribute = $1; + # Open the attribute file to get the first file that failed. + next if (!open (ATTR, "$Dir/failures/$file")); + my $ppfile = ; + chomp $ppfile; + close ATTR; + next if (! -e "$Dir/failures/$ppfile"); + # Open the info file and get the name of the source file. + open (INFO, "$Dir/failures/$ppfile.info.txt") or + die "Cannot open $Dir/failures/$ppfile.info.txt\n"; + my $srcfile = ; + chomp $srcfile; + close (INFO); + # Print the information in the table. + my $prefix = GetPrefix(); + if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; } + print OUT "\n"; + my $ppfile_clang = $ppfile; + $ppfile_clang =~ s/[.](.+)$/.clang.$1/; + print OUT " \n"; + } + print OUT "
AttributeSource FilePreprocessed FileSTDERR Output
$attribute$srcfile$ppfile$ppfile.stderr.txt
\n"; + } + + if (scalar @failures) { + print OUT "

The analyzer had problems processing the following files:

\n"; + print OUT "\n"; + print OUT "\n"; + foreach my $file (sort @failures) { + $file =~ /(.+).info.txt$/; + # Get the preprocessed file. + my $ppfile = $1; + # Open the info file and get the name of the source file. + open (INFO, "$Dir/failures/$file") or + die "Cannot open $Dir/failures/$file\n"; + my $srcfile = ; + chomp $srcfile; + my $problem = ; + chomp $problem; + close (INFO); + # Print the information in the table. + my $prefix = GetPrefix(); + if (defined $prefix) { $srcfile =~ s/^\Q$prefix//; } + print OUT "\n"; + my $ppfile_clang = $ppfile; + $ppfile_clang =~ s/[.](.+)$/.clang.$1/; + print OUT " \n"; + } + print OUT "
ProblemSource FilePreprocessed FileSTDERR Output
$problem$srcfile$ppfile$ppfile.stderr.txt
\n"; + } + print OUT "

Please consider submitting preprocessed files as bug reports.

\n"; + } + + print OUT "\n"; + close(OUT); + CopyFiles($Dir); + + # Make sure $Dir and $BaseDir are world readable/executable. + chmod(0755, $Dir); + if (defined $BaseDir) { chmod(0755, $BaseDir); } + + # Print statistics + print CalcStats(\@Stats) if $AnalyzerStats; + + my $Num = scalar(@Index); + if ($Num == 1) { + Diag("$Num bug found.\n"); + } else { + Diag("$Num bugs found.\n"); + } + if ($Num > 0 && -r "$Dir/index.html") { + Diag("Run 'scan-view $Dir' to examine bug reports.\n"); + } + + DiagCrashes($Dir) if (scalar @failures || scalar @attributes_ignored); + + return $Num; +} + +sub Finalize { + my $BaseDir = shift; + my $ExitStatus = shift; + + Diag "Analysis run complete.\n"; + if (defined $Options{OutputFormat}) { + if ($Options{OutputFormat} =~ /plist/ || + $Options{OutputFormat} =~ /sarif/) { + Diag "Analysis results (" . + ($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") . + " files) deposited in '$Options{OutputDir}'\n"; + } + if ($Options{OutputFormat} =~ /html/) { + # Postprocess the HTML directory. + my $NumBugs = Postprocess($Options{OutputDir}, $BaseDir, + $Options{AnalyzerStats}, $Options{KeepEmpty}); + + if ($Options{ViewResults} and -r "$Options{OutputDir}/index.html") { + Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n"; + my $ScanView = Cwd::realpath("$RealBin/scan-view"); + if (! -x $ScanView) { $ScanView = "scan-view"; } + if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); } + if (! -x $ScanView) { $ScanView = `which scan-view`; chomp $ScanView; } + exec $ScanView, "$Options{OutputDir}"; + } + + if ($Options{ExitStatusFoundBugs}) { + exit 1 if ($NumBugs > 0); + exit $ExitStatus; + } + } + } + + exit $ExitStatus; +} + +##----------------------------------------------------------------------------## +# RunBuildCommand - Run the build command. +##----------------------------------------------------------------------------## + +sub AddIfNotPresent { + my $Args = shift; + my $Arg = shift; + my $found = 0; + + foreach my $k (@$Args) { + if ($k eq $Arg) { + $found = 1; + last; + } + } + + if ($found == 0) { + push @$Args, $Arg; + } +} + +sub SetEnv { + my $EnvVars = shift @_; + foreach my $var ('CC', 'CXX', 'CLANG', 'CLANG_CXX', + 'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS', + 'CCC_ANALYZER_CONFIG') { + die "$var is undefined\n" if (!defined $var); + $ENV{$var} = $EnvVars->{$var}; + } + foreach my $var ('CCC_ANALYZER_CONSTRAINTS_MODEL', + 'CCC_ANALYZER_INTERNAL_STATS', + 'CCC_ANALYZER_OUTPUT_FORMAT', + 'CCC_CC', + 'CCC_CXX', + 'CCC_REPORT_FAILURES', + 'CLANG_ANALYZER_TARGET', + 'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE') { + my $x = $EnvVars->{$var}; + if (defined $x) { $ENV{$var} = $x } + } + my $Verbose = $EnvVars->{'VERBOSE'}; + if ($Verbose >= 2) { + $ENV{'CCC_ANALYZER_VERBOSE'} = 1; + } + if ($Verbose >= 3) { + $ENV{'CCC_ANALYZER_LOG'} = 1; + } +} + +sub RunXcodebuild { + my $Args = shift; + my $IgnoreErrors = shift; + my $CCAnalyzer = shift; + my $CXXAnalyzer = shift; + my $EnvVars = shift; + + if ($IgnoreErrors) { + AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES"); + } + + # Detect the version of Xcode. If Xcode 4.6 or higher, use new + # in situ support for analyzer interposition without needed to override + # the compiler. + open(DETECT_XCODE, "-|", $Args->[0], "-version") or + die "error: cannot detect version of xcodebuild\n"; + + my $oldBehavior = 1; + + while() { + if (/^Xcode (.+)$/) { + my $ver = $1; + if ($ver =~ /^([0-9]+[.][0-9]+)[^0-9]?/) { + if ($1 >= 4.6) { + $oldBehavior = 0; + last; + } + } + } + } + close(DETECT_XCODE); + + # If --override-compiler is explicitly requested, resort to the old + # behavior regardless of Xcode version. + if ($Options{OverrideCompiler}) { + $oldBehavior = 1; + } + + if ($oldBehavior == 0) { + my $OutputDir = $EnvVars->{"OUTPUT_DIR"}; + my $CLANG = $EnvVars->{"CLANG"}; + my $OtherFlags = $EnvVars->{"CCC_ANALYZER_ANALYSIS"} . " " + . $EnvVars->{"CCC_ANALYZER_CONFIG"}; + push @$Args, + "RUN_CLANG_STATIC_ANALYZER=YES", + "CLANG_ANALYZER_OUTPUT=plist-html", + "CLANG_ANALYZER_EXEC=$CLANG", + "CLANG_ANALYZER_OUTPUT_DIR=$OutputDir", + "CLANG_ANALYZER_OTHER_FLAGS=$OtherFlags"; + + return (system(@$Args) >> 8); + } + + # Default to old behavior where we insert a bogus compiler. + SetEnv($EnvVars); + + # Check if using iPhone SDK 3.0 (simulator). If so the compiler being + # used should be gcc-4.2. + if (!defined $ENV{"CCC_CC"}) { + for (my $i = 0 ; $i < scalar(@$Args); ++$i) { + if ($Args->[$i] eq "-sdk" && $i + 1 < scalar(@$Args)) { + if (@$Args[$i+1] =~ /^iphonesimulator3/) { + $ENV{"CCC_CC"} = "gcc-4.2"; + $ENV{"CCC_CXX"} = "g++-4.2"; + } + } + } + } + + # Disable PCH files until clang supports them. + AddIfNotPresent($Args,"GCC_PRECOMPILE_PREFIX_HEADER=NO"); + + # When 'CC' is set, xcodebuild uses it to do all linking, even if we are + # linking C++ object files. Set 'LDPLUSPLUS' so that xcodebuild uses 'g++' + # (via c++-analyzer) when linking such files. + $ENV{"LDPLUSPLUS"} = $CXXAnalyzer; + + return (system(@$Args) >> 8); +} + +sub RunBuildCommand { + my $Args = shift; + my $IgnoreErrors = shift; + my $KeepCC = shift; + my $Cmd = $Args->[0]; + my $CCAnalyzer = shift; + my $CXXAnalyzer = shift; + my $EnvVars = shift; + + if ($Cmd =~ /\bxcodebuild$/) { + return RunXcodebuild($Args, $IgnoreErrors, $CCAnalyzer, $CXXAnalyzer, $EnvVars); + } + + # Setup the environment. + SetEnv($EnvVars); + + if ($Cmd =~ /(.*\/?gcc[^\/]*$)/ or + $Cmd =~ /(.*\/?cc[^\/]*$)/ or + $Cmd =~ /(.*\/?llvm-gcc[^\/]*$)/ or + $Cmd =~ /(.*\/?clang[^\/]*$)/ or + $Cmd =~ /(.*\/?ccc-analyzer[^\/]*$)/) { + + if (!($Cmd =~ /ccc-analyzer/) and !defined $ENV{"CCC_CC"}) { + $ENV{"CCC_CC"} = $1; + } + + shift @$Args; + unshift @$Args, $CCAnalyzer; + } + elsif ($Cmd =~ /(.*\/?g\+\+[^\/]*$)/ or + $Cmd =~ /(.*\/?c\+\+[^\/]*$)/ or + $Cmd =~ /(.*\/?llvm-g\+\+[^\/]*$)/ or + $Cmd =~ /(.*\/?clang\+\+$)/ or + $Cmd =~ /(.*\/?c\+\+-analyzer[^\/]*$)/) { + if (!($Cmd =~ /c\+\+-analyzer/) and !defined $ENV{"CCC_CXX"}) { + $ENV{"CCC_CXX"} = $1; + } + shift @$Args; + unshift @$Args, $CXXAnalyzer; + } + elsif ($Cmd eq "make" or $Cmd eq "gmake" or $Cmd eq "mingw32-make") { + if (!$KeepCC) { + AddIfNotPresent($Args, "CC=$CCAnalyzer"); + AddIfNotPresent($Args, "CXX=$CXXAnalyzer"); + } + if ($IgnoreErrors) { + AddIfNotPresent($Args,"-k"); + AddIfNotPresent($Args,"-i"); + } + } + + return (system(@$Args) >> 8); +} + +##----------------------------------------------------------------------------## +# DisplayHelp - Utility function to display all help options. +##----------------------------------------------------------------------------## + +sub DisplayHelp { + + my $ArgClangNotFoundErrMsg = shift; +print < [build options] + +ENDTEXT + + if (defined $BuildName) { + print "ANALYZER BUILD: $BuildName ($BuildDate)\n\n"; + } + +print < + + Specifies the output directory for analyzer reports. Subdirectories will be + created as needed to represent separate "runs" of the analyzer. If this + option is not specified, a directory is created in /tmp (TMPDIR on Mac OS X) + to store the reports. + + -h + --help + + Display this message. + + -k + --keep-going + + Add a "keep on going" option to the specified build command. This option + currently supports make and xcodebuild. This is a convenience option; one + can specify this behavior directly using build options. + + --keep-cc + + Do not override CC and CXX make variables. Useful when running make in + autoconf-based (and similar) projects where configure can add extra flags + to those variables. + + --html-title [title] + --html-title=[title] + + Specify the title used on generated HTML pages. If not specified, a default + title will be used. + + --show-description + + Display the description of defects in the list + + -sarif + + By default the output of scan-build is a set of HTML files. This option + outputs the results in SARIF format. + + -plist + + By default the output of scan-build is a set of HTML files. This option + outputs the results as a set of .plist files. + + -plist-html + + By default the output of scan-build is a set of HTML files. This option + outputs the results as a set of HTML and .plist files. + + --status-bugs + + By default, the exit status of scan-build is the same as the executed build + command. Specifying this option causes the exit status of scan-build to be 1 + if it found potential bugs and the exit status of the build itself otherwise. + + --exclude + + Do not run static analyzer against files found in this + directory (You can specify this option multiple times). + Could be useful when project contains 3rd party libraries. + + --use-cc [compiler path] + --use-cc=[compiler path] + + scan-build analyzes a project by interposing a "fake compiler", which + executes a real compiler for compilation and the static analyzer for analysis. + Because of the current implementation of interposition, scan-build does not + know what compiler your project normally uses. Instead, it simply overrides + the CC environment variable, and guesses your default compiler. + + In the future, this interposition mechanism to be improved, but if you need + scan-build to use a specific compiler for *compilation* then you can use + this option to specify a path to that compiler. + + If the given compiler is a cross compiler, you may also need to provide + --analyzer-target option to properly analyze the source code because static + analyzer runs as if the code is compiled for the host machine by default. + + --use-c++ [compiler path] + --use-c++=[compiler path] + + This is the same as "--use-cc" but for C++ code. + + --analyzer-target [target triple name for analysis] + --analyzer-target=[target triple name for analysis] + + This provides target triple information to clang static analyzer. + It only changes the target for analysis but doesn't change the target of a + real compiler given by --use-cc and --use-c++ options. + + -v + + Enable verbose output from scan-build. A second and third '-v' increases + verbosity. + + -V + --view + + View analysis results in a web browser when the build completes. + + --generate-index-only + + Do not perform the analysis, but only regenerate the index.html file + from existing report.html files. Useful for making a custom Static Analyzer + integration into a build system that isn't otherwise supported by scan-build. + +ADVANCED OPTIONS: + + -no-failure-reports + + Do not create a 'failures' subdirectory that includes analyzer crash reports + and preprocessed source files. + + -stats + + Generates visitation statistics for the project being analyzed. + + -maxloop + + Specify the number of times a block can be visited before giving up. + Default is 4. Increase for more comprehensive coverage at a cost of speed. + + -internal-stats + + Generate internal analyzer statistics. + + --use-analyzer [Xcode|path to clang] + --use-analyzer=[Xcode|path to clang] + + scan-build uses the 'clang' executable relative to itself for static + analysis. One can override this behavior with this option by using the + 'clang' packaged with Xcode (on OS X) or from the PATH. + + --keep-empty + + Don't remove the build results directory even if no issues were reported. + + --override-compiler + Always resort to the ccc-analyzer even when better interposition methods + are available. + + -analyzer-config + + Provide options to pass through to the analyzer's -analyzer-config flag. + Several options are separated with comma: 'key1=val1,key2=val2' + + Available options: + * stable-report-filename=true or false (default) + Switch the page naming to: + report---.html + instead of report-XXXXXX.html + +CONTROLLING CHECKERS: + + A default group of checkers are always run unless explicitly disabled. + Checkers may be enabled/disabled using the following options: + + -enable-checker [checker name] + -disable-checker [checker name] + +LOADING CHECKERS: + + Loading external checkers using the clang plugin interface: + + -load-plugin [plugin library] +ENDTEXT + + if (defined $Clang && -x $Clang) { + # Query clang for list of checkers that are enabled. + + # create a list to load the plugins via the 'Xclang' command line + # argument + my @PluginLoadCommandline_xclang; + foreach my $param ( @{$Options{PluginsToLoad}} ) { + push ( @PluginLoadCommandline_xclang, "-Xclang" ); + push ( @PluginLoadCommandline_xclang, "-load" ); + push ( @PluginLoadCommandline_xclang, "-Xclang" ); + push ( @PluginLoadCommandline_xclang, $param ); + } + + my %EnabledCheckers; + foreach my $lang ("c", "objective-c", "objective-c++", "c++") { + my $ExecLine = join(' ', qq/"$Clang"/, @PluginLoadCommandline_xclang, "--analyze", "-x", $lang, "-", "-###", "2>&1", "|"); + open(PS, $ExecLine); + while () { + foreach my $val (split /\s+/) { + $val =~ s/\"//g; + if ($val =~ /-analyzer-checker\=([^\s]+)/) { + $EnabledCheckers{$1} = 1; + } + } + } + } + + # Query clang for complete list of checkers. + my @PluginLoadCommandline; + foreach my $param ( @{$Options{PluginsToLoad}} ) { + push ( @PluginLoadCommandline, "-load" ); + push ( @PluginLoadCommandline, $param ); + } + + my $ExecLine = join(' ', qq/"$Clang"/, "-cc1", @PluginLoadCommandline, "-analyzer-checker-help", "2>&1", "|"); + open(PS, $ExecLine); + my $foundCheckers = 0; + while () { + if (/CHECKERS:/) { + $foundCheckers = 1; + last; + } + } + if (!$foundCheckers) { + print " *** Could not query Clang for the list of available checkers."; + } + else { + print("\nAVAILABLE CHECKERS:\n\n"); + my $skip = 0; + while() { + if (/experimental/) { + $skip = 1; + next; + } + if ($skip) { + next if (!/^\s\s[^\s]/); + $skip = 0; + } + s/^\s\s//; + if (/^([^\s]+)/) { + # Is the checker enabled? + my $checker = $1; + my $enabled = 0; + my $aggregate = ""; + foreach my $domain (split /\./, $checker) { + $aggregate .= $domain; + if ($EnabledCheckers{$aggregate}) { + $enabled =1; + last; + } + # append a dot, if an additional domain is added in the next iteration + $aggregate .= "."; + } + + if ($enabled) { + print " + "; + } + else { + print " "; + } + } + else { + print " "; + } + print $_; + } + print "\nNOTE: \"+\" indicates that an analysis is enabled by default.\n"; + } + close PS; + } + else { + print " *** Could not query Clang for the list of available checkers.\n"; + if (defined $ArgClangNotFoundErrMsg) { + print " *** Reason: $ArgClangNotFoundErrMsg\n"; + } + } + +print </>/g; + return $tmp; +} + +##----------------------------------------------------------------------------## +# URLEscape - encode characters that are special in URLs +##----------------------------------------------------------------------------## + +sub URLEscape { + my $arg = shift || ''; + $arg =~ s/\+/%2B/g; + return $arg; +} + +##----------------------------------------------------------------------------## +# ShellEscape - backslash escape characters that are special to the shell +##----------------------------------------------------------------------------## + +sub ShellEscape { + # copy argument to new variable so we don't clobber the original + my $arg = shift || ''; + if ($arg =~ /["\s]/) { return "'" . $arg . "'"; } + return $arg; +} + +##----------------------------------------------------------------------------## +# FindXcrun - searches for the 'xcrun' executable. Returns "" if not found. +##----------------------------------------------------------------------------## + +sub FindXcrun { + my $xcrun = `which xcrun`; + chomp $xcrun; + return $xcrun; +} + +##----------------------------------------------------------------------------## +# FindClang - searches for 'clang' executable. +##----------------------------------------------------------------------------## + +sub FindClang { + if (!defined $Options{AnalyzerDiscoveryMethod}) { + $Clang = Cwd::realpath("$RealBin/bin/clang") if (-f "$RealBin/bin/clang"); + if (!defined $Clang || ! -x $Clang) { + $Clang = Cwd::realpath("$RealBin/clang") if (-f "$RealBin/clang"); + if (!defined $Clang || ! -x $Clang) { + # When an Xcode toolchain is present, look for a clang in the sibling bin + # of the parent of the bin directory. So if scan-build is at + # $TOOLCHAIN/usr/local/bin/scan-build look for clang at + # $TOOLCHAIN/usr/bin/clang. + my $has_xcode_toolchain = FindXcrun() ne ""; + if ($has_xcode_toolchain && -f "$RealBin/../../bin/clang") { + $Clang = Cwd::realpath("$RealBin/../../bin/clang"); + } + } + } + if (!defined $Clang || ! -x $Clang) { + return "error: Cannot find an executable 'clang' relative to" . + " scan-build. Consider using --use-analyzer to pick a version of" . + " 'clang' to use for static analysis.\n"; + } + } + else { + if ($Options{AnalyzerDiscoveryMethod} =~ /^[Xx]code$/) { + my $xcrun = FindXcrun(); + if ($xcrun eq "") { + return "Cannot find 'xcrun' to find 'clang' for analysis.\n"; + } + $Clang = `$xcrun -toolchain XcodeDefault -find clang`; + chomp $Clang; + if ($Clang eq "") { + return "No 'clang' executable found by 'xcrun'\n"; + } + } + else { + $Clang = $Options{AnalyzerDiscoveryMethod}; + if (!defined $Clang or not -x $Clang) { + return "Cannot find an executable clang at '$Options{AnalyzerDiscoveryMethod}'\n"; + } + } + } + return undef; +} + +##----------------------------------------------------------------------------## +# Process command-line arguments. +##----------------------------------------------------------------------------## + +my $RequestDisplayHelp = 0; +my $ForceDisplayHelp = 0; + +sub ProcessArgs { + my $Args = shift; + my $NumArgs = 0; + + while (@$Args) { + + $NumArgs++; + + # Scan for options we recognize. + + my $arg = $Args->[0]; + + if ($arg eq "-h" or $arg eq "--help") { + $RequestDisplayHelp = 1; + shift @$Args; + next; + } + + if ($arg eq '-analyze-headers') { + shift @$Args; + $Options{AnalyzeHeaders} = 1; + next; + } + + if ($arg eq "-o") { + if (defined($Options{OutputDir})) { + DieDiag("Only one of '-o' or '--generate-index-only' can be specified.\n"); + } + + shift @$Args; + + if (!@$Args) { + DieDiag("'-o' option requires a target directory name.\n"); + } + + # Construct an absolute path. Uses the current working directory + # as a base if the original path was not absolute. + my $OutDir = shift @$Args; + mkpath($OutDir) unless (-e $OutDir); # abs_path wants existing dir + $Options{OutputDir} = abs_path($OutDir); + + next; + } + + if ($arg eq "--generate-index-only") { + if (defined($Options{OutputDir})) { + DieDiag("Only one of '-o' or '--generate-index-only' can be specified.\n"); + } + + shift @$Args; + + if (!@$Args) { + DieDiag("'--generate-index-only' option requires a target directory name.\n"); + } + + # Construct an absolute path. Uses the current working directory + # as a base if the original path was not absolute. + my $OutDir = shift @$Args; + mkpath($OutDir) unless (-e $OutDir); # abs_path wants existing dir + $Options{OutputDir} = abs_path($OutDir); + $Options{GenerateIndex} = 1; + + next; + } + + if ($arg =~ /^--html-title(=(.+))?$/) { + shift @$Args; + + if (!defined $2 || $2 eq '') { + if (!@$Args) { + DieDiag("'--html-title' option requires a string.\n"); + } + + $Options{HtmlTitle} = shift @$Args; + } else { + $Options{HtmlTitle} = $2; + } + + next; + } + + if ($arg eq "-k" or $arg eq "--keep-going") { + shift @$Args; + $Options{IgnoreErrors} = 1; + next; + } + + if ($arg eq "--keep-cc") { + shift @$Args; + $Options{KeepCC} = 1; + next; + } + + if ($arg =~ /^--use-cc(=(.+))?$/) { + shift @$Args; + my $cc; + + if (!defined $2 || $2 eq "") { + if (!@$Args) { + DieDiag("'--use-cc' option requires a compiler executable name.\n"); + } + $cc = shift @$Args; + } + else { + $cc = $2; + } + + $Options{UseCC} = $cc; + next; + } + + if ($arg =~ /^--use-c\+\+(=(.+))?$/) { + shift @$Args; + my $cxx; + + if (!defined $2 || $2 eq "") { + if (!@$Args) { + DieDiag("'--use-c++' option requires a compiler executable name.\n"); + } + $cxx = shift @$Args; + } + else { + $cxx = $2; + } + + $Options{UseCXX} = $cxx; + next; + } + + if ($arg =~ /^--analyzer-target(=(.+))?$/) { + shift @ARGV; + my $AnalyzerTarget; + + if (!defined $2 || $2 eq "") { + if (!@ARGV) { + DieDiag("'--analyzer-target' option requires a target triple name.\n"); + } + $AnalyzerTarget = shift @ARGV; + } + else { + $AnalyzerTarget = $2; + } + + $Options{AnalyzerTarget} = $AnalyzerTarget; + next; + } + + if ($arg eq "-v") { + shift @$Args; + $Options{Verbose}++; + next; + } + + if ($arg eq "-V" or $arg eq "--view") { + shift @$Args; + $Options{ViewResults} = 1; + next; + } + + if ($arg eq "--status-bugs") { + shift @$Args; + $Options{ExitStatusFoundBugs} = 1; + next; + } + + if ($arg eq "--show-description") { + shift @$Args; + $Options{ShowDescription} = 1; + next; + } + + if ($arg eq "-constraints") { + shift @$Args; + $Options{ConstraintsModel} = shift @$Args; + next; + } + + if ($arg eq "-internal-stats") { + shift @$Args; + $Options{InternalStats} = 1; + next; + } + + if ($arg eq "-sarif") { + shift @$Args; + $Options{OutputFormat} = "sarif"; + next; + } + + if ($arg eq "-plist") { + shift @$Args; + $Options{OutputFormat} = "plist"; + next; + } + + if ($arg eq "-plist-html") { + shift @$Args; + $Options{OutputFormat} = "plist-html"; + next; + } + + if ($arg eq "-analyzer-config") { + shift @$Args; + push @{$Options{ConfigOptions}}, shift @$Args; + next; + } + + if ($arg eq "-no-failure-reports") { + shift @$Args; + $Options{ReportFailures} = 0; + next; + } + + if ($arg eq "-stats") { + shift @$Args; + $Options{AnalyzerStats} = 1; + next; + } + + if ($arg eq "-maxloop") { + shift @$Args; + $Options{MaxLoop} = shift @$Args; + next; + } + + if ($arg eq "-enable-checker") { + shift @$Args; + my $Checker = shift @$Args; + # Store $NumArgs to preserve the order the checkers were enabled. + $Options{EnableCheckers}{$Checker} = $NumArgs; + delete $Options{DisableCheckers}{$Checker}; + next; + } + + if ($arg eq "-disable-checker") { + shift @$Args; + my $Checker = shift @$Args; + # Store $NumArgs to preserve the order the checkers are disabled/silenced. + # See whether it is a core checker to disable. That means we do not want + # to emit a report from that checker so we have to silence it. + if (index($Checker, "core") == 0) { + $Options{SilenceCheckers}{$Checker} = $NumArgs; + } else { + $Options{DisableCheckers}{$Checker} = $NumArgs; + delete $Options{EnableCheckers}{$Checker}; + } + next; + } + + if ($arg eq "--exclude") { + shift @$Args; + my $arg = shift @$Args; + # Remove the trailing slash if any + $arg =~ s|/$||; + push @{$Options{Excludes}}, $arg; + next; + } + + if ($arg eq "-load-plugin") { + shift @$Args; + push @{$Options{PluginsToLoad}}, shift @$Args; + next; + } + + if ($arg eq "--use-analyzer") { + shift @$Args; + $Options{AnalyzerDiscoveryMethod} = shift @$Args; + next; + } + + if ($arg =~ /^--use-analyzer=(.+)$/) { + shift @$Args; + $Options{AnalyzerDiscoveryMethod} = $1; + next; + } + + if ($arg eq "--keep-empty") { + shift @$Args; + $Options{KeepEmpty} = 1; + next; + } + + if ($arg eq "--override-compiler") { + shift @$Args; + $Options{OverrideCompiler} = 1; + next; + } + + if ($arg eq "--force-analyze-debug-code") { + shift @$Args; + $Options{ForceAnalyzeDebugCode} = 1; + next; + } + + DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/); + + $NumArgs--; + last; + } + return $NumArgs; +} + +if (!@ARGV) { + $ForceDisplayHelp = 1 +} + +ProcessArgs(\@ARGV); +# All arguments are now shifted from @ARGV. The rest is a build command, if any. + +my $ClangNotFoundErrMsg = FindClang(); + +if ($ForceDisplayHelp || $RequestDisplayHelp) { + DisplayHelp($ClangNotFoundErrMsg); + exit $ForceDisplayHelp; +} + +$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV))); + +if ($Options{GenerateIndex}) { + $ClangVersion = "unknown"; + Finalize($Options{OutputDir}, 0); +} + +# Make sure to use "" to handle paths with spaces. +$ClangVersion = HtmlEscape(`"$Clang" --version`); + +if (!@ARGV and !$RequestDisplayHelp) { + ErrorDiag("No build command specified.\n\n"); + $ForceDisplayHelp = 1; +} + +# Determine the output directory for the HTML reports. +my $BaseDir = $Options{OutputDir}; +$Options{OutputDir} = GetHTMLRunDir($Options{OutputDir}); + +DieDiag($ClangNotFoundErrMsg) if (defined $ClangNotFoundErrMsg); + +$ClangCXX = $Clang; +if ($Clang !~ /\+\+(\.exe)?$/) { + # If $Clang holds the name of the clang++ executable then we leave + # $ClangCXX and $Clang equal, otherwise construct the name of the clang++ + # executable from the clang executable name. + + # Determine operating system under which this copy of Perl was built. + my $IsWinBuild = ($^O =~/msys|cygwin|MSWin32/); + if($IsWinBuild) { + $ClangCXX =~ s/\-\d+(\.\d+)?.exe$/++.exe/; + } + else { + $ClangCXX =~ s/\-\d+(\.\d+)?$//; + $ClangCXX .= "++"; + } +} + +# Determine the location of ccc-analyzer. +my $AbsRealBin = Cwd::realpath($RealBin); +my $Cmd = "$AbsRealBin/../libexec/ccc-analyzer"; +my $CmdCXX = "$AbsRealBin/../libexec/c++-analyzer"; + +# Portability: use less strict but portable check -e (file exists) instead of +# non-portable -x (file is executable). On some windows ports -x just checks +# file extension to determine if a file is executable (see Perl language +# reference, perlport) +if (!defined $Cmd || ! -e $Cmd) { + $Cmd = "$AbsRealBin/ccc-analyzer"; + DieDiag("'ccc-analyzer' does not exist at '$Cmd'\n") if(! -e $Cmd); +} +if (!defined $CmdCXX || ! -e $CmdCXX) { + $CmdCXX = "$AbsRealBin/c++-analyzer"; + DieDiag("'c++-analyzer' does not exist at '$CmdCXX'\n") if(! -e $CmdCXX); +} + +Diag("Using '$Clang' for static analysis\n"); + +SetHtmlEnv(\@ARGV, $Options{OutputDir}); + +my @AnalysesToRun; +foreach (sort { $Options{EnableCheckers}{$a} <=> $Options{EnableCheckers}{$b} } + keys %{$Options{EnableCheckers}}) { + # Push checkers in order they were enabled. + push @AnalysesToRun, "-analyzer-checker", $_; +} +foreach (sort { $Options{DisableCheckers}{$a} <=> $Options{DisableCheckers}{$b} } + keys %{$Options{DisableCheckers}}) { + # Push checkers in order they were disabled. + push @AnalysesToRun, "-analyzer-disable-checker", $_; +} +if ($Options{AnalyzeHeaders}) { push @AnalysesToRun, "-analyzer-opt-analyze-headers"; } +if ($Options{AnalyzerStats}) { push @AnalysesToRun, '-analyzer-checker=debug.Stats'; } +if ($Options{MaxLoop} > 0) { push @AnalysesToRun, "-analyzer-max-loop $Options{MaxLoop}"; } + +# Delay setting up other environment variables in case we can do true +# interposition. +my $CCC_ANALYZER_ANALYSIS = join ' ', @AnalysesToRun; +my $CCC_ANALYZER_PLUGINS = join ' ', map { "-load ".$_ } @{$Options{PluginsToLoad}}; +my $CCC_ANALYZER_CONFIG = join ' ', map { "-analyzer-config ".$_ } @{$Options{ConfigOptions}}; + +if (%{$Options{SilenceCheckers}}) { + $CCC_ANALYZER_CONFIG = + $CCC_ANALYZER_CONFIG." -analyzer-config silence-checkers=" + .join(';', sort { + $Options{SilenceCheckers}{$a} <=> + $Options{SilenceCheckers}{$b} + } keys %{$Options{SilenceCheckers}}); +} + +my %EnvVars = ( + 'CC' => $Cmd, + 'CXX' => $CmdCXX, + 'CLANG' => $Clang, + 'CLANG_CXX' => $ClangCXX, + 'VERBOSE' => $Options{Verbose}, + 'CCC_ANALYZER_ANALYSIS' => $CCC_ANALYZER_ANALYSIS, + 'CCC_ANALYZER_PLUGINS' => $CCC_ANALYZER_PLUGINS, + 'CCC_ANALYZER_CONFIG' => $CCC_ANALYZER_CONFIG, + 'OUTPUT_DIR' => $Options{OutputDir}, + 'CCC_CC' => $Options{UseCC}, + 'CCC_CXX' => $Options{UseCXX}, + 'CCC_REPORT_FAILURES' => $Options{ReportFailures}, + 'CCC_ANALYZER_CONSTRAINTS_MODEL' => $Options{ConstraintsModel}, + 'CCC_ANALYZER_INTERNAL_STATS' => $Options{InternalStats}, + 'CCC_ANALYZER_OUTPUT_FORMAT' => $Options{OutputFormat}, + 'CLANG_ANALYZER_TARGET' => $Options{AnalyzerTarget}, + 'CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE' => $Options{ForceAnalyzeDebugCode} +); + +# Run the build. +my $ExitStatus = RunBuildCommand(\@ARGV, $Options{IgnoreErrors}, $Options{KeepCC}, + $Cmd, $CmdCXX, \%EnvVars); + +Finalize($BaseDir, $ExitStatus); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-build-py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-build-py new file mode 100755 index 0000000..3e5a5ad --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-build-py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import multiprocessing +import sys +import os.path +this_dir = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(os.path.dirname(this_dir), 'lib')) + +from libscanbuild.analyze import scan_build + +if __name__ == '__main__': + multiprocessing.freeze_support() + sys.exit(scan_build()) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-view b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-view new file mode 100755 index 0000000..d01aebb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/scan-view @@ -0,0 +1,149 @@ +#!/usr/bin/env python + +from __future__ import print_function + +"""The clang static analyzer results viewer. +""" + +import sys +import os +import posixpath +import threading +import time +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen +import webbrowser + +# How long to wait for server to start. +kSleepTimeout = .05 +kMaxSleeps = int(60 / kSleepTimeout) + +# Default server parameters + +kDefaultHost = '127.0.0.1' +kDefaultPort = 8181 +kMaxPortsToTry = 100 + +### + + +def url_is_up(url): + try: + o = urlopen(url) + except IOError: + return False + o.close() + return True + + +def start_browser(port, options): + import webbrowser + + url = 'http://%s:%d' % (options.host, port) + + # Wait for server to start... + if options.debug: + sys.stderr.write('%s: Waiting for server.' % sys.argv[0]) + sys.stderr.flush() + for i in range(kMaxSleeps): + if url_is_up(url): + break + if options.debug: + sys.stderr.write('.') + sys.stderr.flush() + time.sleep(kSleepTimeout) + else: + print('WARNING: Unable to detect that server started.', file=sys.stderr) + + if options.debug: + print('%s: Starting webbrowser...' % sys.argv[0], file=sys.stderr) + webbrowser.open(url) + + +def run(port, options, root): + # Prefer to look relative to the installed binary + share = os.path.dirname(__file__) + "/../share/scan-view" + if not os.path.isdir(share): + # Otherwise look relative to the source + share = os.path.dirname(__file__) + "/../../scan-view/share" + sys.path.append(share) + + import ScanView + try: + print('Starting scan-view at: http://%s:%d' % (options.host, + port)) + print(' Use Ctrl-C to exit.') + httpd = ScanView.create_server((options.host, port), + options, root) + httpd.serve_forever() + except KeyboardInterrupt: + pass + + +def port_is_open(port): + try: + import socketserver + except ImportError: + import SocketServer as socketserver + try: + t = socketserver.TCPServer((kDefaultHost, port), None) + except: + return False + t.server_close() + return True + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="The clang static analyzer " + "results viewer.") + parser.add_argument("root", metavar="", type=str) + parser.add_argument( + '--host', dest="host", default=kDefaultHost, type=str, + help="Host interface to listen on. (default=%s)" % kDefaultHost) + parser.add_argument('--port', dest="port", default=None, type=int, + help="Port to listen on. (default=%s)" % kDefaultPort) + parser.add_argument("--debug", dest="debug", default=0, + action="count", + help="Print additional debugging information.") + parser.add_argument("--auto-reload", dest="autoReload", default=False, + action="store_true", + help="Automatically update module for each request.") + parser.add_argument("--no-browser", dest="startBrowser", default=True, + action="store_false", + help="Don't open a webbrowser on startup.") + parser.add_argument("--allow-all-hosts", dest="onlyServeLocal", + default=True, action="store_false", + help='Allow connections from any host (access ' + 'restricted to "127.0.0.1" by default)') + args = parser.parse_args() + + # Make sure this directory is in a reasonable state to view. + if not posixpath.exists(posixpath.join(args.root, 'index.html')): + parser.error('Invalid directory, analysis results not found!') + + # Find an open port. We aren't particularly worried about race + # conditions here. Note that if the user specified a port we only + # use that one. + if args.port is not None: + port = args.port + else: + for i in range(kMaxPortsToTry): + if port_is_open(kDefaultPort + i): + port = kDefaultPort + i + break + else: + parser.error('Unable to find usable port in [%d,%d)' % + (kDefaultPort, kDefaultPort+kMaxPortsToTry)) + + # Kick off thread to wait for server and start web browser, if + # requested. + if args.startBrowser: + threading.Thread(target=start_browser, args=(port, args)).start() + + run(port, args, args.root) + +if __name__ == '__main__': + main() diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/wasm-ld b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/wasm-ld new file mode 100755 index 0000000..02416ac --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/bin/wasm-ld @@ -0,0 +1 @@ +lld \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/BuildSystem.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/BuildSystem.h new file mode 100755 index 0000000..57e16af --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/BuildSystem.h @@ -0,0 +1,153 @@ +/*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides various utilities for use by build systems. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_BUILDSYSTEM_H +#define LLVM_CLANG_C_BUILDSYSTEM_H + +#include "clang-c/CXErrorCode.h" +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * \defgroup BUILD_SYSTEM Build system utilities + * @{ + */ + +/** + * Return the timestamp for use with Clang's + * \c -fbuild-session-timestamp= option. + */ +CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void); + +/** + * Object encapsulating information about overlaying virtual + * file/directories over the real file system. + */ +typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay; + +/** + * Create a \c CXVirtualFileOverlay object. + * Must be disposed with \c clang_VirtualFileOverlay_dispose(). + * + * \param options is reserved, always pass 0. + */ +CINDEX_LINKAGE CXVirtualFileOverlay +clang_VirtualFileOverlay_create(unsigned options); + +/** + * Map an absolute virtual file path to an absolute real one. + * The virtual path must be canonicalized (not contain "."/".."). + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay, + const char *virtualPath, + const char *realPath); + +/** + * Set the case sensitivity for the \c CXVirtualFileOverlay object. + * The \c CXVirtualFileOverlay object is case-sensitive by default, this + * option can be used to override the default. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay, + int caseSensitive); + +/** + * Write out the \c CXVirtualFileOverlay object to a char buffer. + * + * \param options is reserved, always pass 0. + * \param out_buffer_ptr pointer to receive the buffer pointer, which should be + * disposed using \c clang_free(). + * \param out_buffer_size pointer to receive the buffer size. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options, + char **out_buffer_ptr, + unsigned *out_buffer_size); + +/** + * free memory allocated by libclang, such as the buffer returned by + * \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer(). + * + * \param buffer memory pointer to free. + */ +CINDEX_LINKAGE void clang_free(void *buffer); + +/** + * Dispose a \c CXVirtualFileOverlay object. + */ +CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay); + +/** + * Object encapsulating information about a module.modulemap file. + */ +typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor; + +/** + * Create a \c CXModuleMapDescriptor object. + * Must be disposed with \c clang_ModuleMapDescriptor_dispose(). + * + * \param options is reserved, always pass 0. + */ +CINDEX_LINKAGE CXModuleMapDescriptor +clang_ModuleMapDescriptor_create(unsigned options); + +/** + * Sets the framework module name that the module.modulemap describes. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor, + const char *name); + +/** + * Sets the umbrella header name that the module.modulemap describes. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor, + const char *name); + +/** + * Write out the \c CXModuleMapDescriptor object to a char buffer. + * + * \param options is reserved, always pass 0. + * \param out_buffer_ptr pointer to receive the buffer pointer, which should be + * disposed using \c clang_free(). + * \param out_buffer_size pointer to receive the buffer size. + * \returns 0 for success, non-zero to indicate an error. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options, + char **out_buffer_ptr, + unsigned *out_buffer_size); + +/** + * Dispose a \c CXModuleMapDescriptor object. + */ +CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif /* CLANG_C_BUILD_SYSTEM_H */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXCompilationDatabase.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXCompilationDatabase.h new file mode 100755 index 0000000..2b336e5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXCompilationDatabase.h @@ -0,0 +1,174 @@ +/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a public interface to use CompilationDatabase without *| +|* the full Clang C++ API. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H +#define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H + +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** \defgroup COMPILATIONDB CompilationDatabase functions + * \ingroup CINDEX + * + * @{ + */ + +/** + * A compilation database holds all information used to compile files in a + * project. For each file in the database, it can be queried for the working + * directory or the command line used for the compiler invocation. + * + * Must be freed by \c clang_CompilationDatabase_dispose + */ +typedef void * CXCompilationDatabase; + +/** + * Contains the results of a search in the compilation database + * + * When searching for the compile command for a file, the compilation db can + * return several commands, as the file may have been compiled with + * different options in different places of the project. This choice of compile + * commands is wrapped in this opaque data structure. It must be freed by + * \c clang_CompileCommands_dispose. + */ +typedef void * CXCompileCommands; + +/** + * Represents the command line invocation to compile a specific file. + */ +typedef void * CXCompileCommand; + +/** + * Error codes for Compilation Database + */ +typedef enum { + /* + * No error occurred + */ + CXCompilationDatabase_NoError = 0, + + /* + * Database can not be loaded + */ + CXCompilationDatabase_CanNotLoadDatabase = 1 + +} CXCompilationDatabase_Error; + +/** + * Creates a compilation database from the database found in directory + * buildDir. For example, CMake can output a compile_commands.json which can + * be used to build the database. + * + * It must be freed by \c clang_CompilationDatabase_dispose. + */ +CINDEX_LINKAGE CXCompilationDatabase +clang_CompilationDatabase_fromDirectory(const char *BuildDir, + CXCompilationDatabase_Error *ErrorCode); + +/** + * Free the given compilation database + */ +CINDEX_LINKAGE void +clang_CompilationDatabase_dispose(CXCompilationDatabase); + +/** + * Find the compile commands used for a file. The compile commands + * must be freed by \c clang_CompileCommands_dispose. + */ +CINDEX_LINKAGE CXCompileCommands +clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase, + const char *CompleteFileName); + +/** + * Get all the compile commands in the given compilation database. + */ +CINDEX_LINKAGE CXCompileCommands +clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase); + +/** + * Free the given CompileCommands + */ +CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands); + +/** + * Get the number of CompileCommand we have for a file + */ +CINDEX_LINKAGE unsigned +clang_CompileCommands_getSize(CXCompileCommands); + +/** + * Get the I'th CompileCommand for a file + * + * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands) + */ +CINDEX_LINKAGE CXCompileCommand +clang_CompileCommands_getCommand(CXCompileCommands, unsigned I); + +/** + * Get the working directory where the CompileCommand was executed from + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getDirectory(CXCompileCommand); + +/** + * Get the filename associated with the CompileCommand. + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getFilename(CXCompileCommand); + +/** + * Get the number of arguments in the compiler invocation. + * + */ +CINDEX_LINKAGE unsigned +clang_CompileCommand_getNumArgs(CXCompileCommand); + +/** + * Get the I'th argument value in the compiler invocations + * + * Invariant : + * - argument 0 is the compiler executable + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getArg(CXCompileCommand, unsigned I); + +/** + * Get the number of source mappings for the compiler invocation. + */ +CINDEX_LINKAGE unsigned +clang_CompileCommand_getNumMappedSources(CXCompileCommand); + +/** + * Get the I'th mapped source path for the compiler invocation. + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I); + +/** + * Get the I'th mapped source content for the compiler invocation. + */ +CINDEX_LINKAGE CXString +clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXDiagnostic.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXDiagnostic.h new file mode 100755 index 0000000..911d001 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXDiagnostic.h @@ -0,0 +1,379 @@ +/*===-- clang-c/CXDiagnostic.h - C Index Diagnostics --------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the interface to C Index diagnostics. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXDIAGNOSTIC_H +#define LLVM_CLANG_C_CXDIAGNOSTIC_H + +#include "clang-c/CXSourceLocation.h" +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * \defgroup CINDEX_DIAG Diagnostic reporting + * + * @{ + */ + +/** + * Describes the severity of a particular diagnostic. + */ +enum CXDiagnosticSeverity { + /** + * A diagnostic that has been suppressed, e.g., by a command-line + * option. + */ + CXDiagnostic_Ignored = 0, + + /** + * This diagnostic is a note that should be attached to the + * previous (non-note) diagnostic. + */ + CXDiagnostic_Note = 1, + + /** + * This diagnostic indicates suspicious code that may not be + * wrong. + */ + CXDiagnostic_Warning = 2, + + /** + * This diagnostic indicates that the code is ill-formed. + */ + CXDiagnostic_Error = 3, + + /** + * This diagnostic indicates that the code is ill-formed such + * that future parser recovery is unlikely to produce useful + * results. + */ + CXDiagnostic_Fatal = 4 +}; + +/** + * A single diagnostic, containing the diagnostic's severity, + * location, text, source ranges, and fix-it hints. + */ +typedef void *CXDiagnostic; + +/** + * A group of CXDiagnostics. + */ +typedef void *CXDiagnosticSet; + +/** + * Determine the number of diagnostics in a CXDiagnosticSet. + */ +CINDEX_LINKAGE unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags); + +/** + * Retrieve a diagnostic associated with the given CXDiagnosticSet. + * + * \param Diags the CXDiagnosticSet to query. + * \param Index the zero-based diagnostic number to retrieve. + * + * \returns the requested diagnostic. This diagnostic must be freed + * via a call to \c clang_disposeDiagnostic(). + */ +CINDEX_LINKAGE CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, + unsigned Index); + +/** + * Describes the kind of error that occurred (if any) in a call to + * \c clang_loadDiagnostics. + */ +enum CXLoadDiag_Error { + /** + * Indicates that no error occurred. + */ + CXLoadDiag_None = 0, + + /** + * Indicates that an unknown error occurred while attempting to + * deserialize diagnostics. + */ + CXLoadDiag_Unknown = 1, + + /** + * Indicates that the file containing the serialized diagnostics + * could not be opened. + */ + CXLoadDiag_CannotLoad = 2, + + /** + * Indicates that the serialized diagnostics file is invalid or + * corrupt. + */ + CXLoadDiag_InvalidFile = 3 +}; + +/** + * Deserialize a set of diagnostics from a Clang diagnostics bitcode + * file. + * + * \param file The name of the file to deserialize. + * \param error A pointer to a enum value recording if there was a problem + * deserializing the diagnostics. + * \param errorString A pointer to a CXString for recording the error string + * if the file was not successfully loaded. + * + * \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These + * diagnostics should be released using clang_disposeDiagnosticSet(). + */ +CINDEX_LINKAGE CXDiagnosticSet clang_loadDiagnostics( + const char *file, enum CXLoadDiag_Error *error, CXString *errorString); + +/** + * Release a CXDiagnosticSet and all of its contained diagnostics. + */ +CINDEX_LINKAGE void clang_disposeDiagnosticSet(CXDiagnosticSet Diags); + +/** + * Retrieve the child diagnostics of a CXDiagnostic. + * + * This CXDiagnosticSet does not need to be released by + * clang_disposeDiagnosticSet. + */ +CINDEX_LINKAGE CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D); + +/** + * Destroy a diagnostic. + */ +CINDEX_LINKAGE void clang_disposeDiagnostic(CXDiagnostic Diagnostic); + +/** + * Options to control the display of diagnostics. + * + * The values in this enum are meant to be combined to customize the + * behavior of \c clang_formatDiagnostic(). + */ +enum CXDiagnosticDisplayOptions { + /** + * Display the source-location information where the + * diagnostic was located. + * + * When set, diagnostics will be prefixed by the file, line, and + * (optionally) column to which the diagnostic refers. For example, + * + * \code + * test.c:28: warning: extra tokens at end of #endif directive + * \endcode + * + * This option corresponds to the clang flag \c -fshow-source-location. + */ + CXDiagnostic_DisplaySourceLocation = 0x01, + + /** + * If displaying the source-location information of the + * diagnostic, also include the column number. + * + * This option corresponds to the clang flag \c -fshow-column. + */ + CXDiagnostic_DisplayColumn = 0x02, + + /** + * If displaying the source-location information of the + * diagnostic, also include information about source ranges in a + * machine-parsable format. + * + * This option corresponds to the clang flag + * \c -fdiagnostics-print-source-range-info. + */ + CXDiagnostic_DisplaySourceRanges = 0x04, + + /** + * Display the option name associated with this diagnostic, if any. + * + * The option name displayed (e.g., -Wconversion) will be placed in brackets + * after the diagnostic text. This option corresponds to the clang flag + * \c -fdiagnostics-show-option. + */ + CXDiagnostic_DisplayOption = 0x08, + + /** + * Display the category number associated with this diagnostic, if any. + * + * The category number is displayed within brackets after the diagnostic text. + * This option corresponds to the clang flag + * \c -fdiagnostics-show-category=id. + */ + CXDiagnostic_DisplayCategoryId = 0x10, + + /** + * Display the category name associated with this diagnostic, if any. + * + * The category name is displayed within brackets after the diagnostic text. + * This option corresponds to the clang flag + * \c -fdiagnostics-show-category=name. + */ + CXDiagnostic_DisplayCategoryName = 0x20 +}; + +/** + * Format the given diagnostic in a manner that is suitable for display. + * + * This routine will format the given diagnostic to a string, rendering + * the diagnostic according to the various options given. The + * \c clang_defaultDiagnosticDisplayOptions() function returns the set of + * options that most closely mimics the behavior of the clang compiler. + * + * \param Diagnostic The diagnostic to print. + * + * \param Options A set of options that control the diagnostic display, + * created by combining \c CXDiagnosticDisplayOptions values. + * + * \returns A new string containing for formatted diagnostic. + */ +CINDEX_LINKAGE CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, + unsigned Options); + +/** + * Retrieve the set of display options most similar to the + * default behavior of the clang compiler. + * + * \returns A set of display options suitable for use with \c + * clang_formatDiagnostic(). + */ +CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void); + +/** + * Determine the severity of the given diagnostic. + */ +CINDEX_LINKAGE enum CXDiagnosticSeverity + clang_getDiagnosticSeverity(CXDiagnostic); + +/** + * Retrieve the source location of the given diagnostic. + * + * This location is where Clang would print the caret ('^') when + * displaying the diagnostic on the command line. + */ +CINDEX_LINKAGE CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic); + +/** + * Retrieve the text of the given diagnostic. + */ +CINDEX_LINKAGE CXString clang_getDiagnosticSpelling(CXDiagnostic); + +/** + * Retrieve the name of the command-line option that enabled this + * diagnostic. + * + * \param Diag The diagnostic to be queried. + * + * \param Disable If non-NULL, will be set to the option that disables this + * diagnostic (if any). + * + * \returns A string that contains the command-line option used to enable this + * warning, such as "-Wconversion" or "-pedantic". + */ +CINDEX_LINKAGE CXString clang_getDiagnosticOption(CXDiagnostic Diag, + CXString *Disable); + +/** + * Retrieve the category number for this diagnostic. + * + * Diagnostics can be categorized into groups along with other, related + * diagnostics (e.g., diagnostics under the same warning flag). This routine + * retrieves the category number for the given diagnostic. + * + * \returns The number of the category that contains this diagnostic, or zero + * if this diagnostic is uncategorized. + */ +CINDEX_LINKAGE unsigned clang_getDiagnosticCategory(CXDiagnostic); + +/** + * Retrieve the name of a particular diagnostic category. This + * is now deprecated. Use clang_getDiagnosticCategoryText() + * instead. + * + * \param Category A diagnostic category number, as returned by + * \c clang_getDiagnosticCategory(). + * + * \returns The name of the given diagnostic category. + */ +CINDEX_DEPRECATED CINDEX_LINKAGE CXString +clang_getDiagnosticCategoryName(unsigned Category); + +/** + * Retrieve the diagnostic category text for a given diagnostic. + * + * \returns The text of the given diagnostic category. + */ +CINDEX_LINKAGE CXString clang_getDiagnosticCategoryText(CXDiagnostic); + +/** + * Determine the number of source ranges associated with the given + * diagnostic. + */ +CINDEX_LINKAGE unsigned clang_getDiagnosticNumRanges(CXDiagnostic); + +/** + * Retrieve a source range associated with the diagnostic. + * + * A diagnostic's source ranges highlight important elements in the source + * code. On the command line, Clang displays source ranges by + * underlining them with '~' characters. + * + * \param Diagnostic the diagnostic whose range is being extracted. + * + * \param Range the zero-based index specifying which range to + * + * \returns the requested source range. + */ +CINDEX_LINKAGE CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, + unsigned Range); + +/** + * Determine the number of fix-it hints associated with the + * given diagnostic. + */ +CINDEX_LINKAGE unsigned clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic); + +/** + * Retrieve the replacement information for a given fix-it. + * + * Fix-its are described in terms of a source range whose contents + * should be replaced by a string. This approach generalizes over + * three kinds of operations: removal of source code (the range covers + * the code to be removed and the replacement string is empty), + * replacement of source code (the range covers the code to be + * replaced and the replacement string provides the new code), and + * insertion (both the start and end of the range point at the + * insertion location, and the replacement string provides the text to + * insert). + * + * \param Diagnostic The diagnostic whose fix-its are being queried. + * + * \param FixIt The zero-based index of the fix-it. + * + * \param ReplacementRange The source range whose contents will be + * replaced with the returned replacement string. Note that source + * ranges are half-open ranges [a, b), so the source code should be + * replaced from a and up to (but not including) b. + * + * \returns A string containing text that should be replace the source + * code indicated by the \c ReplacementRange. + */ +CINDEX_LINKAGE CXString clang_getDiagnosticFixIt( + CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange *ReplacementRange); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXErrorCode.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXErrorCode.h new file mode 100755 index 0000000..b3a0b9d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXErrorCode.h @@ -0,0 +1,62 @@ +/*===-- clang-c/CXErrorCode.h - C Index Error Codes --------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the CXErrorCode enumerators. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXERRORCODE_H +#define LLVM_CLANG_C_CXERRORCODE_H + +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * Error codes returned by libclang routines. + * + * Zero (\c CXError_Success) is the only error code indicating success. Other + * error codes, including not yet assigned non-zero values, indicate errors. + */ +enum CXErrorCode { + /** + * No error. + */ + CXError_Success = 0, + + /** + * A generic error code, no further details are available. + * + * Errors of this kind can get their own specific error codes in future + * libclang versions. + */ + CXError_Failure = 1, + + /** + * libclang crashed while performing the requested operation. + */ + CXError_Crashed = 2, + + /** + * The function detected that the arguments violate the function + * contract. + */ + CXError_InvalidArguments = 3, + + /** + * An AST deserialization error has occurred. + */ + CXError_ASTReadError = 4 +}; + +LLVM_CLANG_C_EXTERN_C_END + +#endif + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXFile.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXFile.h new file mode 100755 index 0000000..c48f58c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXFile.h @@ -0,0 +1,83 @@ +/*===-- clang-c/CXFile.h - C Index File ---------------------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the interface to C Index files. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXFILE_H +#define LLVM_CLANG_C_CXFILE_H + +#include + +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * \defgroup CINDEX_FILES File manipulation routines + * + * @{ + */ + +/** + * A particular source file that is part of a translation unit. + */ +typedef void *CXFile; + +/** + * Retrieve the complete file and path name of the given file. + */ +CINDEX_LINKAGE CXString clang_getFileName(CXFile SFile); + +/** + * Retrieve the last modification time of the given file. + */ +CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile); + +/** + * Uniquely identifies a CXFile, that refers to the same underlying file, + * across an indexing session. + */ +typedef struct { + unsigned long long data[3]; +} CXFileUniqueID; + +/** + * Retrieve the unique ID for the given \c file. + * + * \param file the file to get the ID for. + * \param outID stores the returned CXFileUniqueID. + * \returns If there was a failure getting the unique ID, returns non-zero, + * otherwise returns 0. + */ +CINDEX_LINKAGE int clang_getFileUniqueID(CXFile file, CXFileUniqueID *outID); + +/** + * Returns non-zero if the \c file1 and \c file2 point to the same file, + * or they are both NULL. + */ +CINDEX_LINKAGE int clang_File_isEqual(CXFile file1, CXFile file2); + +/** + * Returns the real path name of \c file. + * + * An empty string may be returned. Use \c clang_getFileName() in that case. + */ +CINDEX_LINKAGE CXString clang_File_tryGetRealPathName(CXFile file); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXSourceLocation.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXSourceLocation.h new file mode 100755 index 0000000..4218021 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXSourceLocation.h @@ -0,0 +1,296 @@ +/*===-- clang-c/CXSourceLocation.h - C Index Source Location ------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the interface to C Index source locations. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXSOURCE_LOCATION_H +#define LLVM_CLANG_C_CXSOURCE_LOCATION_H + +#include "clang-c/CXFile.h" +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * \defgroup CINDEX_LOCATIONS Physical source locations + * + * Clang represents physical source locations in its abstract syntax tree in + * great detail, with file, line, and column information for the majority of + * the tokens parsed in the source code. These data types and functions are + * used to represent source location information, either for a particular + * point in the program or for a range of points in the program, and extract + * specific location information from those data types. + * + * @{ + */ + +/** + * Identifies a specific source location within a translation + * unit. + * + * Use clang_getExpansionLocation() or clang_getSpellingLocation() + * to map a source location to a particular file, line, and column. + */ +typedef struct { + const void *ptr_data[2]; + unsigned int_data; +} CXSourceLocation; + +/** + * Identifies a half-open character range in the source code. + * + * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the + * starting and end locations from a source range, respectively. + */ +typedef struct { + const void *ptr_data[2]; + unsigned begin_int_data; + unsigned end_int_data; +} CXSourceRange; + +/** + * Retrieve a NULL (invalid) source location. + */ +CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void); + +/** + * Determine whether two source locations, which must refer into + * the same translation unit, refer to exactly the same point in the source + * code. + * + * \returns non-zero if the source locations refer to the same location, zero + * if they refer to different locations. + */ +CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1, + CXSourceLocation loc2); + +/** + * Determine for two source locations if the first comes + * strictly before the second one in the source code. + * + * \returns non-zero if the first source location comes + * strictly before the second one, zero otherwise. + */ +CINDEX_LINKAGE unsigned clang_isBeforeInTranslationUnit(CXSourceLocation loc1, + CXSourceLocation loc2); + +/** + * Returns non-zero if the given source location is in a system header. + */ +CINDEX_LINKAGE int clang_Location_isInSystemHeader(CXSourceLocation location); + +/** + * Returns non-zero if the given source location is in the main file of + * the corresponding translation unit. + */ +CINDEX_LINKAGE int clang_Location_isFromMainFile(CXSourceLocation location); + +/** + * Retrieve a NULL (invalid) source range. + */ +CINDEX_LINKAGE CXSourceRange clang_getNullRange(void); + +/** + * Retrieve a source range given the beginning and ending source + * locations. + */ +CINDEX_LINKAGE CXSourceRange clang_getRange(CXSourceLocation begin, + CXSourceLocation end); + +/** + * Determine whether two ranges are equivalent. + * + * \returns non-zero if the ranges are the same, zero if they differ. + */ +CINDEX_LINKAGE unsigned clang_equalRanges(CXSourceRange range1, + CXSourceRange range2); + +/** + * Returns non-zero if \p range is null. + */ +CINDEX_LINKAGE int clang_Range_isNull(CXSourceRange range); + +/** + * Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro expansion, retrieves the + * location of the macro expansion. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CINDEX_LINKAGE void clang_getExpansionLocation(CXSourceLocation location, + CXFile *file, unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * Retrieve the file, line and column represented by the given source + * location, as specified in a # line directive. + * + * Example: given the following source code in a file somefile.c + * + * \code + * #123 "dummy.c" 1 + * + * static int func(void) + * { + * return 0; + * } + * \endcode + * + * the location information returned by this function would be + * + * File: dummy.c Line: 124 Column: 12 + * + * whereas clang_getExpansionLocation would have returned + * + * File: somefile.c Line: 3 Column: 12 + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param filename [out] if non-NULL, will be set to the filename of the + * source location. Note that filenames returned will be for "virtual" files, + * which don't necessarily exist on the machine running clang - e.g. when + * parsing preprocessed output obtained from a different environment. If + * a non-NULL value is passed in, remember to dispose of the returned value + * using \c clang_disposeString() once you've finished with it. For an invalid + * source location, an empty string is returned. + * + * \param line [out] if non-NULL, will be set to the line number of the + * source location. For an invalid source location, zero is returned. + * + * \param column [out] if non-NULL, will be set to the column number of the + * source location. For an invalid source location, zero is returned. + */ +CINDEX_LINKAGE void clang_getPresumedLocation(CXSourceLocation location, + CXString *filename, + unsigned *line, unsigned *column); + +/** + * Legacy API to retrieve the file, line, column, and offset represented + * by the given source location. + * + * This interface has been replaced by the newer interface + * #clang_getExpansionLocation(). See that interface's documentation for + * details. + */ +CINDEX_LINKAGE void clang_getInstantiationLocation(CXSourceLocation location, + CXFile *file, unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro instantiation, return where the + * location was originally spelled in the source file. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CINDEX_LINKAGE void clang_getSpellingLocation(CXSourceLocation location, + CXFile *file, unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * Retrieve the file, line, column, and offset represented by + * the given source location. + * + * If the location refers into a macro expansion, return where the macro was + * expanded or where the macro argument was written, if the location points at + * a macro argument. + * + * \param location the location within a source file that will be decomposed + * into its parts. + * + * \param file [out] if non-NULL, will be set to the file to which the given + * source location points. + * + * \param line [out] if non-NULL, will be set to the line to which the given + * source location points. + * + * \param column [out] if non-NULL, will be set to the column to which the given + * source location points. + * + * \param offset [out] if non-NULL, will be set to the offset into the + * buffer to which the given source location points. + */ +CINDEX_LINKAGE void clang_getFileLocation(CXSourceLocation location, + CXFile *file, unsigned *line, + unsigned *column, unsigned *offset); + +/** + * Retrieve a source location representing the first character within a + * source range. + */ +CINDEX_LINKAGE CXSourceLocation clang_getRangeStart(CXSourceRange range); + +/** + * Retrieve a source location representing the last character within a + * source range. + */ +CINDEX_LINKAGE CXSourceLocation clang_getRangeEnd(CXSourceRange range); + +/** + * Identifies an array of ranges. + */ +typedef struct { + /** The number of ranges in the \c ranges array. */ + unsigned count; + /** + * An array of \c CXSourceRanges. + */ + CXSourceRange *ranges; +} CXSourceRangeList; + +/** + * Destroy the given \c CXSourceRangeList. + */ +CINDEX_LINKAGE void clang_disposeSourceRangeList(CXSourceRangeList *ranges); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXString.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXString.h new file mode 100755 index 0000000..63dce4d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/CXString.h @@ -0,0 +1,73 @@ +/*===-- clang-c/CXString.h - C Index strings --------------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides the interface to C Index strings. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_CXSTRING_H +#define LLVM_CLANG_C_CXSTRING_H + +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * \defgroup CINDEX_STRING String manipulation routines + * \ingroup CINDEX + * + * @{ + */ + +/** + * A character string. + * + * The \c CXString type is used to return strings from the interface when + * the ownership of that string might differ from one call to the next. + * Use \c clang_getCString() to retrieve the string data and, once finished + * with the string data, call \c clang_disposeString() to free the string. + */ +typedef struct { + const void *data; + unsigned private_flags; +} CXString; + +typedef struct { + CXString *Strings; + unsigned Count; +} CXStringSet; + +/** + * Retrieve the character data associated with the given string. + * + * The returned data is a reference and not owned by the user. This data + * is only valid while the `CXString` is valid. This function is similar + * to `std::string::c_str()`. + */ +CINDEX_LINKAGE const char *clang_getCString(CXString string); + +/** + * Free the given string. + */ +CINDEX_LINKAGE void clang_disposeString(CXString string); + +/** + * Free the given string set. + */ +CINDEX_LINKAGE void clang_disposeStringSet(CXStringSet *set); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Documentation.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Documentation.h new file mode 100755 index 0000000..e04c50a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Documentation.h @@ -0,0 +1,619 @@ +/*==-- clang-c/Documentation.h - Utilities for comment processing -*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a supplementary interface for inspecting *| +|* documentation comments. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_DOCUMENTATION_H +#define LLVM_CLANG_C_DOCUMENTATION_H + +#include "clang-c/CXErrorCode.h" +#include "clang-c/ExternC.h" +#include "clang-c/Index.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * \defgroup CINDEX_COMMENT Comment introspection + * + * The routines in this group provide access to information in documentation + * comments. These facilities are distinct from the core and may be subject to + * their own schedule of stability and deprecation. + * + * @{ + */ + +/** + * A parsed comment. + */ +typedef struct { + const void *ASTNode; + CXTranslationUnit TranslationUnit; +} CXComment; + +/** + * Given a cursor that represents a documentable entity (e.g., + * declaration), return the associated parsed comment as a + * \c CXComment_FullComment AST node. + */ +CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C); + +/** + * Describes the type of the comment AST node (\c CXComment). A comment + * node can be considered block content (e. g., paragraph), inline content + * (plain text) or neither (the root AST node). + */ +enum CXCommentKind { + /** + * Null comment. No AST node is constructed at the requested location + * because there is no text or a syntax error. + */ + CXComment_Null = 0, + + /** + * Plain text. Inline content. + */ + CXComment_Text = 1, + + /** + * A command with word-like arguments that is considered inline content. + * + * For example: \\c command. + */ + CXComment_InlineCommand = 2, + + /** + * HTML start tag with attributes (name-value pairs). Considered + * inline content. + * + * For example: + * \verbatim + *

+ * \endverbatim + */ + CXComment_HTMLStartTag = 3, + + /** + * HTML end tag. Considered inline content. + * + * For example: + * \verbatim + * + * \endverbatim + */ + CXComment_HTMLEndTag = 4, + + /** + * A paragraph, contains inline comment. The paragraph itself is + * block content. + */ + CXComment_Paragraph = 5, + + /** + * A command that has zero or more word-like arguments (number of + * word-like arguments depends on command name) and a paragraph as an + * argument. Block command is block content. + * + * Paragraph argument is also a child of the block command. + * + * For example: \has 0 word-like arguments and a paragraph argument. + * + * AST nodes of special kinds that parser knows about (e. g., \\param + * command) have their own node kinds. + */ + CXComment_BlockCommand = 6, + + /** + * A \\param or \\arg command that describes the function parameter + * (name, passing direction, description). + * + * For example: \\param [in] ParamName description. + */ + CXComment_ParamCommand = 7, + + /** + * A \\tparam command that describes a template parameter (name and + * description). + * + * For example: \\tparam T description. + */ + CXComment_TParamCommand = 8, + + /** + * A verbatim block command (e. g., preformatted code). Verbatim + * block has an opening and a closing command and contains multiple lines of + * text (\c CXComment_VerbatimBlockLine child nodes). + * + * For example: + * \\verbatim + * aaa + * \\endverbatim + */ + CXComment_VerbatimBlockCommand = 9, + + /** + * A line of text that is contained within a + * CXComment_VerbatimBlockCommand node. + */ + CXComment_VerbatimBlockLine = 10, + + /** + * A verbatim line command. Verbatim line has an opening command, + * a single line of text (up to the newline after the opening command) and + * has no closing command. + */ + CXComment_VerbatimLine = 11, + + /** + * A full comment attached to a declaration, contains block content. + */ + CXComment_FullComment = 12 +}; + +/** + * The most appropriate rendering mode for an inline command, chosen on + * command semantics in Doxygen. + */ +enum CXCommentInlineCommandRenderKind { + /** + * Command argument should be rendered in a normal font. + */ + CXCommentInlineCommandRenderKind_Normal, + + /** + * Command argument should be rendered in a bold font. + */ + CXCommentInlineCommandRenderKind_Bold, + + /** + * Command argument should be rendered in a monospaced font. + */ + CXCommentInlineCommandRenderKind_Monospaced, + + /** + * Command argument should be rendered emphasized (typically italic + * font). + */ + CXCommentInlineCommandRenderKind_Emphasized, + + /** + * Command argument should not be rendered (since it only defines an anchor). + */ + CXCommentInlineCommandRenderKind_Anchor +}; + +/** + * Describes parameter passing direction for \\param or \\arg command. + */ +enum CXCommentParamPassDirection { + /** + * The parameter is an input parameter. + */ + CXCommentParamPassDirection_In, + + /** + * The parameter is an output parameter. + */ + CXCommentParamPassDirection_Out, + + /** + * The parameter is an input and output parameter. + */ + CXCommentParamPassDirection_InOut +}; + +/** + * \param Comment AST node of any kind. + * + * \returns the type of the AST node. + */ +CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment); + +/** + * \param Comment AST node of any kind. + * + * \returns number of children of the AST node. + */ +CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment); + +/** + * \param Comment AST node of any kind. + * + * \param ChildIdx child index (zero-based). + * + * \returns the specified child of the AST node. + */ +CINDEX_LINKAGE +CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx); + +/** + * A \c CXComment_Paragraph node is considered whitespace if it contains + * only \c CXComment_Text nodes that are empty or whitespace. + * + * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are + * never considered whitespace. + * + * \returns non-zero if \c Comment is whitespace. + */ +CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment); + +/** + * \returns non-zero if \c Comment is inline content and has a newline + * immediately following it in the comment text. Newlines between paragraphs + * do not count. + */ +CINDEX_LINKAGE +unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment); + +/** + * \param Comment a \c CXComment_Text AST node. + * + * \returns text contained in the AST node. + */ +CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \returns name of the inline command. + */ +CINDEX_LINKAGE +CXString clang_InlineCommandComment_getCommandName(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \returns the most appropriate rendering mode, chosen on command + * semantics in Doxygen. + */ +CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind +clang_InlineCommandComment_getRenderKind(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \returns number of command arguments. + */ +CINDEX_LINKAGE +unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment); + +/** + * \param Comment a \c CXComment_InlineCommand AST node. + * + * \param ArgIdx argument index (zero-based). + * + * \returns text of the specified argument. + */ +CINDEX_LINKAGE +CXString clang_InlineCommandComment_getArgText(CXComment Comment, + unsigned ArgIdx); + +/** + * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST + * node. + * + * \returns HTML tag name. + */ +CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \returns non-zero if tag is self-closing (for example, <br />). + */ +CINDEX_LINKAGE +unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \returns number of attributes (name-value pairs) attached to the start tag. + */ +CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \param AttrIdx attribute index (zero-based). + * + * \returns name of the specified attribute. + */ +CINDEX_LINKAGE +CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx); + +/** + * \param Comment a \c CXComment_HTMLStartTag AST node. + * + * \param AttrIdx attribute index (zero-based). + * + * \returns value of the specified attribute. + */ +CINDEX_LINKAGE +CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx); + +/** + * \param Comment a \c CXComment_BlockCommand AST node. + * + * \returns name of the block command. + */ +CINDEX_LINKAGE +CXString clang_BlockCommandComment_getCommandName(CXComment Comment); + +/** + * \param Comment a \c CXComment_BlockCommand AST node. + * + * \returns number of word-like arguments. + */ +CINDEX_LINKAGE +unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment); + +/** + * \param Comment a \c CXComment_BlockCommand AST node. + * + * \param ArgIdx argument index (zero-based). + * + * \returns text of the specified word-like argument. + */ +CINDEX_LINKAGE +CXString clang_BlockCommandComment_getArgText(CXComment Comment, + unsigned ArgIdx); + +/** + * \param Comment a \c CXComment_BlockCommand or + * \c CXComment_VerbatimBlockCommand AST node. + * + * \returns paragraph argument of the block command. + */ +CINDEX_LINKAGE +CXComment clang_BlockCommandComment_getParagraph(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns parameter name. + */ +CINDEX_LINKAGE +CXString clang_ParamCommandComment_getParamName(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns non-zero if the parameter that this AST node represents was found + * in the function prototype and \c clang_ParamCommandComment_getParamIndex + * function will return a meaningful value. + */ +CINDEX_LINKAGE +unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns zero-based parameter index in function prototype. + */ +CINDEX_LINKAGE +unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns non-zero if parameter passing direction was specified explicitly in + * the comment. + */ +CINDEX_LINKAGE +unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment); + +/** + * \param Comment a \c CXComment_ParamCommand AST node. + * + * \returns parameter passing direction. + */ +CINDEX_LINKAGE +enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection( + CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns template parameter name. + */ +CINDEX_LINKAGE +CXString clang_TParamCommandComment_getParamName(CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns non-zero if the parameter that this AST node represents was found + * in the template parameter list and + * \c clang_TParamCommandComment_getDepth and + * \c clang_TParamCommandComment_getIndex functions will return a meaningful + * value. + */ +CINDEX_LINKAGE +unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns zero-based nesting depth of this parameter in the template parameter list. + * + * For example, + * \verbatim + * template class TT> + * void test(TT aaa); + * \endverbatim + * for C and TT nesting depth is 0, + * for T nesting depth is 1. + */ +CINDEX_LINKAGE +unsigned clang_TParamCommandComment_getDepth(CXComment Comment); + +/** + * \param Comment a \c CXComment_TParamCommand AST node. + * + * \returns zero-based parameter index in the template parameter list at a + * given nesting depth. + * + * For example, + * \verbatim + * template class TT> + * void test(TT aaa); + * \endverbatim + * for C and TT nesting depth is 0, so we can ask for index at depth 0: + * at depth 0 C's index is 0, TT's index is 1. + * + * For T nesting depth is 1, so we can ask for index at depth 0 and 1: + * at depth 0 T's index is 1 (same as TT's), + * at depth 1 T's index is 0. + */ +CINDEX_LINKAGE +unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth); + +/** + * \param Comment a \c CXComment_VerbatimBlockLine AST node. + * + * \returns text contained in the AST node. + */ +CINDEX_LINKAGE +CXString clang_VerbatimBlockLineComment_getText(CXComment Comment); + +/** + * \param Comment a \c CXComment_VerbatimLine AST node. + * + * \returns text contained in the AST node. + */ +CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment); + +/** + * Convert an HTML tag AST node to string. + * + * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST + * node. + * + * \returns string containing an HTML tag. + */ +CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment); + +/** + * Convert a given full parsed comment to an HTML fragment. + * + * Specific details of HTML layout are subject to change. Don't try to parse + * this HTML back into an AST, use other APIs instead. + * + * Currently the following CSS classes are used: + * \li "para-brief" for \paragraph and equivalent commands; + * \li "para-returns" for \\returns paragraph and equivalent commands; + * \li "word-returns" for the "Returns" word in \\returns paragraph. + * + * Function argument documentation is rendered as a \ list with arguments + * sorted in function prototype order. CSS classes used: + * \li "param-name-index-NUMBER" for parameter name (\); + * \li "param-descr-index-NUMBER" for parameter description (\); + * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if + * parameter index is invalid. + * + * Template parameter documentation is rendered as a \ list with + * parameters sorted in template parameter list order. CSS classes used: + * \li "tparam-name-index-NUMBER" for parameter name (\); + * \li "tparam-descr-index-NUMBER" for parameter description (\); + * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for + * names inside template template parameters; + * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if + * parameter position is invalid. + * + * \param Comment a \c CXComment_FullComment AST node. + * + * \returns string containing an HTML fragment. + */ +CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment); + +/** + * Convert a given full parsed comment to an XML document. + * + * A Relax NG schema for the XML can be found in comment-xml-schema.rng file + * inside clang source tree. + * + * \param Comment a \c CXComment_FullComment AST node. + * + * \returns string containing an XML document. + */ +CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment); + +/** + * CXAPISet is an opaque type that represents a data structure containing all + * the API information for a given translation unit. This can be used for a + * single symbol symbol graph for a given symbol. + */ +typedef struct CXAPISetImpl *CXAPISet; + +/** + * Traverses the translation unit to create a \c CXAPISet. + * + * \param tu is the \c CXTranslationUnit to build the \c CXAPISet for. + * + * \param out_api is a pointer to the output of this function. It is needs to be + * disposed of by calling clang_disposeAPISet. + * + * \returns Error code indicating success or failure of the APISet creation. + */ +CINDEX_LINKAGE enum CXErrorCode clang_createAPISet(CXTranslationUnit tu, + CXAPISet *out_api); + +/** + * Dispose of an APISet. + * + * The provided \c CXAPISet can not be used after this function is called. + */ +CINDEX_LINKAGE void clang_disposeAPISet(CXAPISet api); + +/** + * Generate a single symbol symbol graph for the given USR. Returns a null + * string if the associated symbol can not be found in the provided \c CXAPISet. + * + * The output contains the symbol graph as well as some additional information + * about related symbols. + * + * \param usr is a string containing the USR of the symbol to generate the + * symbol graph for. + * + * \param api the \c CXAPISet to look for the symbol in. + * + * \returns a string containing the serialized symbol graph representation for + * the symbol being queried or a null string if it can not be found in the + * APISet. + */ +CINDEX_LINKAGE CXString clang_getSymbolGraphForUSR(const char *usr, + CXAPISet api); + +/** + * Generate a single symbol symbol graph for the declaration at the given + * cursor. Returns a null string if the AST node for the cursor isn't a + * declaration. + * + * The output contains the symbol graph as well as some additional information + * about related symbols. + * + * \param cursor the declaration for which to generate the single symbol symbol + * graph. + * + * \returns a string containing the serialized symbol graph representation for + * the symbol being queried or a null string if it can not be found in the + * APISet. + */ +CINDEX_LINKAGE CXString clang_getSymbolGraphForCursor(CXCursor cursor); + +/** + * @} + */ + +LLVM_CLANG_C_EXTERN_C_END + +#endif /* CLANG_C_DOCUMENTATION_H */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/ExternC.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/ExternC.h new file mode 100755 index 0000000..384f24d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/ExternC.h @@ -0,0 +1,39 @@ +/*===- clang-c/ExternC.h - Wrapper for 'extern "C"' ---------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This file defines an 'extern "C"' wrapper. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_EXTERN_C_H +#define LLVM_CLANG_C_EXTERN_C_H + +#ifdef __clang__ +#define LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic error \"-Wstrict-prototypes\"") +#define LLVM_CLANG_C_STRICT_PROTOTYPES_END _Pragma("clang diagnostic pop") +#else +#define LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN +#define LLVM_CLANG_C_STRICT_PROTOTYPES_END +#endif + +#ifdef __cplusplus +#define LLVM_CLANG_C_EXTERN_C_BEGIN \ + extern "C" { \ + LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN +#define LLVM_CLANG_C_EXTERN_C_END \ + LLVM_CLANG_C_STRICT_PROTOTYPES_END \ + } +#else +#define LLVM_CLANG_C_EXTERN_C_BEGIN LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN +#define LLVM_CLANG_C_EXTERN_C_END LLVM_CLANG_C_STRICT_PROTOTYPES_END +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/FatalErrorHandler.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/FatalErrorHandler.h new file mode 100755 index 0000000..4f18980 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/FatalErrorHandler.h @@ -0,0 +1,33 @@ +/*===-- clang-c/FatalErrorHandler.h - Fatal Error Handling --------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_FATAL_ERROR_HANDLER_H +#define LLVM_CLANG_C_FATAL_ERROR_HANDLER_H + +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** + * Installs error handler that prints error message to stderr and calls abort(). + * Replaces currently installed error handler (if any). + */ +CINDEX_LINKAGE void clang_install_aborting_llvm_fatal_error_handler(void); + +/** + * Removes currently installed error handler (if any). + * If no error handler is intalled, the default strategy is to print error + * message to stderr and call exit(1). + */ +CINDEX_LINKAGE void clang_uninstall_llvm_fatal_error_handler(void); + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Index.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Index.h new file mode 100755 index 0000000..b929585 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Index.h @@ -0,0 +1,6973 @@ +/*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a public interface to a Clang library for extracting *| +|* high-level symbol information from source files without exposing the full *| +|* Clang C++ API. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_INDEX_H +#define LLVM_CLANG_C_INDEX_H + +#include "clang-c/BuildSystem.h" +#include "clang-c/CXDiagnostic.h" +#include "clang-c/CXErrorCode.h" +#include "clang-c/CXFile.h" +#include "clang-c/CXSourceLocation.h" +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Platform.h" + +/** + * The version constants for the libclang API. + * CINDEX_VERSION_MINOR should increase when there are API additions. + * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. + * + * The policy about the libclang API was always to keep it source and ABI + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. + */ +#define CINDEX_VERSION_MAJOR 0 +#define CINDEX_VERSION_MINOR 64 + +#define CINDEX_VERSION_ENCODE(major, minor) (((major) * 10000) + ((minor) * 1)) + +#define CINDEX_VERSION \ + CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR) + +#define CINDEX_VERSION_STRINGIZE_(major, minor) #major "." #minor +#define CINDEX_VERSION_STRINGIZE(major, minor) \ + CINDEX_VERSION_STRINGIZE_(major, minor) + +#define CINDEX_VERSION_STRING \ + CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR) + +#ifndef __has_feature +#define __has_feature(feature) 0 +#endif + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/** \defgroup CINDEX libclang: C Interface to Clang + * + * The C Interface to Clang provides a relatively small API that exposes + * facilities for parsing source code into an abstract syntax tree (AST), + * loading already-parsed ASTs, traversing the AST, associating + * physical source locations with elements within the AST, and other + * facilities that support Clang-based development tools. + * + * This C interface to Clang will never provide all of the information + * representation stored in Clang's C++ AST, nor should it: the intent is to + * maintain an API that is relatively stable from one release to the next, + * providing only the basic functionality needed to support development tools. + * + * To avoid namespace pollution, data types are prefixed with "CX" and + * functions are prefixed with "clang_". + * + * @{ + */ + +/** + * An "index" that consists of a set of translation units that would + * typically be linked together into an executable or library. + */ +typedef void *CXIndex; + +/** + * An opaque type representing target information for a given translation + * unit. + */ +typedef struct CXTargetInfoImpl *CXTargetInfo; + +/** + * A single translation unit, which resides in an index. + */ +typedef struct CXTranslationUnitImpl *CXTranslationUnit; + +/** + * Opaque pointer representing client data that will be passed through + * to various callbacks and visitors. + */ +typedef void *CXClientData; + +/** + * Provides the contents of a file that has not yet been saved to disk. + * + * Each CXUnsavedFile instance provides the name of a file on the + * system along with the current contents of that file that have not + * yet been saved to disk. + */ +struct CXUnsavedFile { + /** + * The file whose contents have not yet been saved. + * + * This file must already exist in the file system. + */ + const char *Filename; + + /** + * A buffer containing the unsaved contents of this file. + */ + const char *Contents; + + /** + * The length of the unsaved contents of this buffer. + */ + unsigned long Length; +}; + +/** + * Describes the availability of a particular entity, which indicates + * whether the use of this entity will result in a warning or error due to + * it being deprecated or unavailable. + */ +enum CXAvailabilityKind { + /** + * The entity is available. + */ + CXAvailability_Available, + /** + * The entity is available, but has been deprecated (and its use is + * not recommended). + */ + CXAvailability_Deprecated, + /** + * The entity is not available; any use of it will be an error. + */ + CXAvailability_NotAvailable, + /** + * The entity is available, but not accessible; any use of it will be + * an error. + */ + CXAvailability_NotAccessible +}; + +/** + * Describes a version number of the form major.minor.subminor. + */ +typedef struct CXVersion { + /** + * The major version number, e.g., the '10' in '10.7.3'. A negative + * value indicates that there is no version number at all. + */ + int Major; + /** + * The minor version number, e.g., the '7' in '10.7.3'. This value + * will be negative if no minor version number was provided, e.g., for + * version '10'. + */ + int Minor; + /** + * The subminor version number, e.g., the '3' in '10.7.3'. This value + * will be negative if no minor or subminor version number was provided, + * e.g., in version '10' or '10.7'. + */ + int Subminor; +} CXVersion; + +/** + * Describes the exception specification of a cursor. + * + * A negative value indicates that the cursor is not a function declaration. + */ +enum CXCursor_ExceptionSpecificationKind { + /** + * The cursor has no exception specification. + */ + CXCursor_ExceptionSpecificationKind_None, + + /** + * The cursor has exception specification throw() + */ + CXCursor_ExceptionSpecificationKind_DynamicNone, + + /** + * The cursor has exception specification throw(T1, T2) + */ + CXCursor_ExceptionSpecificationKind_Dynamic, + + /** + * The cursor has exception specification throw(...). + */ + CXCursor_ExceptionSpecificationKind_MSAny, + + /** + * The cursor has exception specification basic noexcept. + */ + CXCursor_ExceptionSpecificationKind_BasicNoexcept, + + /** + * The cursor has exception specification computed noexcept. + */ + CXCursor_ExceptionSpecificationKind_ComputedNoexcept, + + /** + * The exception specification has not yet been evaluated. + */ + CXCursor_ExceptionSpecificationKind_Unevaluated, + + /** + * The exception specification has not yet been instantiated. + */ + CXCursor_ExceptionSpecificationKind_Uninstantiated, + + /** + * The exception specification has not been parsed yet. + */ + CXCursor_ExceptionSpecificationKind_Unparsed, + + /** + * The cursor has a __declspec(nothrow) exception specification. + */ + CXCursor_ExceptionSpecificationKind_NoThrow +}; + +/** + * Provides a shared context for creating translation units. + * + * It provides two options: + * + * - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" + * declarations (when loading any new translation units). A "local" declaration + * is one that belongs in the translation unit itself and not in a precompiled + * header that was used by the translation unit. If zero, all declarations + * will be enumerated. + * + * Here is an example: + * + * \code + * // excludeDeclsFromPCH = 1, displayDiagnostics=1 + * Idx = clang_createIndex(1, 1); + * + * // IndexTest.pch was produced with the following command: + * // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" + * TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); + * + * // This will load all the symbols from 'IndexTest.pch' + * clang_visitChildren(clang_getTranslationUnitCursor(TU), + * TranslationUnitVisitor, 0); + * clang_disposeTranslationUnit(TU); + * + * // This will load all the symbols from 'IndexTest.c', excluding symbols + * // from 'IndexTest.pch'. + * char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; + * TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, + * 0, 0); + * clang_visitChildren(clang_getTranslationUnitCursor(TU), + * TranslationUnitVisitor, 0); + * clang_disposeTranslationUnit(TU); + * \endcode + * + * This process of creating the 'pch', loading it separately, and using it (via + * -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks + * (which gives the indexer the same performance benefit as the compiler). + */ +CINDEX_LINKAGE CXIndex clang_createIndex(int excludeDeclarationsFromPCH, + int displayDiagnostics); + +/** + * Destroy the given index. + * + * The index must not be destroyed until all of the translation units created + * within that index have been destroyed. + */ +CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); + +typedef enum { + /** + * Use the default value of an option that may depend on the process + * environment. + */ + CXChoice_Default = 0, + /** + * Enable the option. + */ + CXChoice_Enabled = 1, + /** + * Disable the option. + */ + CXChoice_Disabled = 2 +} CXChoice; + +typedef enum { + /** + * Used to indicate that no special CXIndex options are needed. + */ + CXGlobalOpt_None = 0x0, + + /** + * Used to indicate that threads that libclang creates for indexing + * purposes should use background priority. + * + * Affects #clang_indexSourceFile, #clang_indexTranslationUnit, + * #clang_parseTranslationUnit, #clang_saveTranslationUnit. + */ + CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, + + /** + * Used to indicate that threads that libclang creates for editing + * purposes should use background priority. + * + * Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, + * #clang_annotateTokens + */ + CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, + + /** + * Used to indicate that all threads that libclang creates should use + * background priority. + */ + CXGlobalOpt_ThreadBackgroundPriorityForAll = + CXGlobalOpt_ThreadBackgroundPriorityForIndexing | + CXGlobalOpt_ThreadBackgroundPriorityForEditing + +} CXGlobalOptFlags; + +/** + * Index initialization options. + * + * 0 is the default value of each member of this struct except for Size. + * Initialize the struct in one of the following three ways to avoid adapting + * code each time a new member is added to it: + * \code + * CXIndexOptions Opts; + * memset(&Opts, 0, sizeof(Opts)); + * Opts.Size = sizeof(CXIndexOptions); + * \endcode + * or explicitly initialize the first data member and zero-initialize the rest: + * \code + * CXIndexOptions Opts = { sizeof(CXIndexOptions) }; + * \endcode + * or to prevent the -Wmissing-field-initializers warning for the above version: + * \code + * CXIndexOptions Opts{}; + * Opts.Size = sizeof(CXIndexOptions); + * \endcode + */ +typedef struct CXIndexOptions { + /** + * The size of struct CXIndexOptions used for option versioning. + * + * Always initialize this member to sizeof(CXIndexOptions), or assign + * sizeof(CXIndexOptions) to it right after creating a CXIndexOptions object. + */ + unsigned Size; + /** + * A CXChoice enumerator that specifies the indexing priority policy. + * \sa CXGlobalOpt_ThreadBackgroundPriorityForIndexing + */ + unsigned char ThreadBackgroundPriorityForIndexing; + /** + * A CXChoice enumerator that specifies the editing priority policy. + * \sa CXGlobalOpt_ThreadBackgroundPriorityForEditing + */ + unsigned char ThreadBackgroundPriorityForEditing; + /** + * \see clang_createIndex() + */ + unsigned ExcludeDeclarationsFromPCH : 1; + /** + * \see clang_createIndex() + */ + unsigned DisplayDiagnostics : 1; + /** + * Store PCH in memory. If zero, PCH are stored in temporary files. + */ + unsigned StorePreamblesInMemory : 1; + unsigned /*Reserved*/ : 13; + + /** + * The path to a directory, in which to store temporary PCH files. If null or + * empty, the default system temporary directory is used. These PCH files are + * deleted on clean exit but stay on disk if the program crashes or is killed. + * + * This option is ignored if \a StorePreamblesInMemory is non-zero. + * + * Libclang does not create the directory at the specified path in the file + * system. Therefore it must exist, or storing PCH files will fail. + */ + const char *PreambleStoragePath; + /** + * Specifies a path which will contain log files for certain libclang + * invocations. A null value implies that libclang invocations are not logged. + */ + const char *InvocationEmissionPath; +} CXIndexOptions; + +/** + * Provides a shared context for creating translation units. + * + * Call this function instead of clang_createIndex() if you need to configure + * the additional options in CXIndexOptions. + * + * \returns The created index or null in case of error, such as an unsupported + * value of options->Size. + * + * For example: + * \code + * CXIndex createIndex(const char *ApplicationTemporaryPath) { + * const int ExcludeDeclarationsFromPCH = 1; + * const int DisplayDiagnostics = 1; + * CXIndex Idx; + * #if CINDEX_VERSION_MINOR >= 64 + * CXIndexOptions Opts; + * memset(&Opts, 0, sizeof(Opts)); + * Opts.Size = sizeof(CXIndexOptions); + * Opts.ThreadBackgroundPriorityForIndexing = 1; + * Opts.ExcludeDeclarationsFromPCH = ExcludeDeclarationsFromPCH; + * Opts.DisplayDiagnostics = DisplayDiagnostics; + * Opts.PreambleStoragePath = ApplicationTemporaryPath; + * Idx = clang_createIndexWithOptions(&Opts); + * if (Idx) + * return Idx; + * fprintf(stderr, + * "clang_createIndexWithOptions() failed. " + * "CINDEX_VERSION_MINOR = %d, sizeof(CXIndexOptions) = %u\n", + * CINDEX_VERSION_MINOR, Opts.Size); + * #else + * (void)ApplicationTemporaryPath; + * #endif + * Idx = clang_createIndex(ExcludeDeclarationsFromPCH, DisplayDiagnostics); + * clang_CXIndex_setGlobalOptions( + * Idx, clang_CXIndex_getGlobalOptions(Idx) | + * CXGlobalOpt_ThreadBackgroundPriorityForIndexing); + * return Idx; + * } + * \endcode + * + * \sa clang_createIndex() + */ +CINDEX_LINKAGE CXIndex +clang_createIndexWithOptions(const CXIndexOptions *options); + +/** + * Sets general options associated with a CXIndex. + * + * This function is DEPRECATED. Set + * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or + * CXIndexOptions::ThreadBackgroundPriorityForEditing and call + * clang_createIndexWithOptions() instead. + * + * For example: + * \code + * CXIndex idx = ...; + * clang_CXIndex_setGlobalOptions(idx, + * clang_CXIndex_getGlobalOptions(idx) | + * CXGlobalOpt_ThreadBackgroundPriorityForIndexing); + * \endcode + * + * \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags. + */ +CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options); + +/** + * Gets the general options associated with a CXIndex. + * + * This function allows to obtain the final option values used by libclang after + * specifying the option policies via CXChoice enumerators. + * + * \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that + * are associated with the given CXIndex object. + */ +CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex); + +/** + * Sets the invocation emission path option in a CXIndex. + * + * This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and + * call clang_createIndexWithOptions() instead. + * + * The invocation emission path specifies a path which will contain log + * files for certain libclang invocations. A null value (default) implies that + * libclang invocations are not logged.. + */ +CINDEX_LINKAGE void +clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path); + +/** + * Determine whether the given header is guarded against + * multiple inclusions, either with the conventional + * \#ifndef/\#define/\#endif macro guards or with \#pragma once. + */ +CINDEX_LINKAGE unsigned clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, + CXFile file); + +/** + * Retrieve a file handle within the given translation unit. + * + * \param tu the translation unit + * + * \param file_name the name of the file. + * + * \returns the file handle for the named file in the translation unit \p tu, + * or a NULL file handle if the file was not a part of this translation unit. + */ +CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu, + const char *file_name); + +/** + * Retrieve the buffer associated with the given file. + * + * \param tu the translation unit + * + * \param file the file for which to retrieve the buffer. + * + * \param size [out] if non-NULL, will be set to the size of the buffer. + * + * \returns a pointer to the buffer in memory that holds the contents of + * \p file, or a NULL pointer when the file is not loaded. + */ +CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu, + CXFile file, size_t *size); + +/** + * Retrieves the source location associated with a given file/line/column + * in a particular translation unit. + */ +CINDEX_LINKAGE CXSourceLocation clang_getLocation(CXTranslationUnit tu, + CXFile file, unsigned line, + unsigned column); +/** + * Retrieves the source location associated with a given character offset + * in a particular translation unit. + */ +CINDEX_LINKAGE CXSourceLocation clang_getLocationForOffset(CXTranslationUnit tu, + CXFile file, + unsigned offset); + +/** + * Retrieve all ranges that were skipped by the preprocessor. + * + * The preprocessor will skip lines when they are surrounded by an + * if/ifdef/ifndef directive whose condition does not evaluate to true. + */ +CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu, + CXFile file); + +/** + * Retrieve all ranges from all files that were skipped by the + * preprocessor. + * + * The preprocessor will skip lines when they are surrounded by an + * if/ifdef/ifndef directive whose condition does not evaluate to true. + */ +CINDEX_LINKAGE CXSourceRangeList * +clang_getAllSkippedRanges(CXTranslationUnit tu); + +/** + * Determine the number of diagnostics produced for the given + * translation unit. + */ +CINDEX_LINKAGE unsigned clang_getNumDiagnostics(CXTranslationUnit Unit); + +/** + * Retrieve a diagnostic associated with the given translation unit. + * + * \param Unit the translation unit to query. + * \param Index the zero-based diagnostic number to retrieve. + * + * \returns the requested diagnostic. This diagnostic must be freed + * via a call to \c clang_disposeDiagnostic(). + */ +CINDEX_LINKAGE CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, + unsigned Index); + +/** + * Retrieve the complete set of diagnostics associated with a + * translation unit. + * + * \param Unit the translation unit to query. + */ +CINDEX_LINKAGE CXDiagnosticSet +clang_getDiagnosticSetFromTU(CXTranslationUnit Unit); + +/** + * \defgroup CINDEX_TRANSLATION_UNIT Translation unit manipulation + * + * The routines in this group provide the ability to create and destroy + * translation units from files, either by parsing the contents of the files or + * by reading in a serialized representation of a translation unit. + * + * @{ + */ + +/** + * Get the original translation unit source file name. + */ +CINDEX_LINKAGE CXString +clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit); + +/** + * Return the CXTranslationUnit for a given source file and the provided + * command line arguments one would pass to the compiler. + * + * Note: The 'source_filename' argument is optional. If the caller provides a + * NULL pointer, the name of the source file is expected to reside in the + * specified command line arguments. + * + * Note: When encountered in 'clang_command_line_args', the following options + * are ignored: + * + * '-c' + * '-emit-ast' + * '-fsyntax-only' + * '-o \' (both '-o' and '\' are ignored) + * + * \param CIdx The index object with which the translation unit will be + * associated. + * + * \param source_filename The name of the source file to load, or NULL if the + * source file is included in \p clang_command_line_args. + * + * \param num_clang_command_line_args The number of command-line arguments in + * \p clang_command_line_args. + * + * \param clang_command_line_args The command-line arguments that would be + * passed to the \c clang executable if it were being invoked out-of-process. + * These command-line options will be parsed and will affect how the translation + * unit is parsed. Note that the following options are ignored: '-c', + * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. + * + * \param num_unsaved_files the number of unsaved file entries in \p + * unsaved_files. + * + * \param unsaved_files the files that have not yet been saved to disk + * but may be required for code completion, including the contents of + * those files. The contents and name of these files (as specified by + * CXUnsavedFile) are copied when necessary, so the client only needs to + * guarantee their validity until the call to this function returns. + */ +CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile( + CXIndex CIdx, const char *source_filename, int num_clang_command_line_args, + const char *const *clang_command_line_args, unsigned num_unsaved_files, + struct CXUnsavedFile *unsaved_files); + +/** + * Same as \c clang_createTranslationUnit2, but returns + * the \c CXTranslationUnit instead of an error code. In case of an error this + * routine returns a \c NULL \c CXTranslationUnit, without further detailed + * error codes. + */ +CINDEX_LINKAGE CXTranslationUnit +clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename); + +/** + * Create a translation unit from an AST file (\c -emit-ast). + * + * \param[out] out_TU A non-NULL pointer to store the created + * \c CXTranslationUnit. + * + * \returns Zero on success, otherwise returns an error code. + */ +CINDEX_LINKAGE enum CXErrorCode +clang_createTranslationUnit2(CXIndex CIdx, const char *ast_filename, + CXTranslationUnit *out_TU); + +/** + * Flags that control the creation of translation units. + * + * The enumerators in this enumeration type are meant to be bitwise + * ORed together to specify which options should be used when + * constructing the translation unit. + */ +enum CXTranslationUnit_Flags { + /** + * Used to indicate that no special translation-unit options are + * needed. + */ + CXTranslationUnit_None = 0x0, + + /** + * Used to indicate that the parser should construct a "detailed" + * preprocessing record, including all macro definitions and instantiations. + * + * Constructing a detailed preprocessing record requires more memory + * and time to parse, since the information contained in the record + * is usually not retained. However, it can be useful for + * applications that require more detailed information about the + * behavior of the preprocessor. + */ + CXTranslationUnit_DetailedPreprocessingRecord = 0x01, + + /** + * Used to indicate that the translation unit is incomplete. + * + * When a translation unit is considered "incomplete", semantic + * analysis that is typically performed at the end of the + * translation unit will be suppressed. For example, this suppresses + * the completion of tentative declarations in C and of + * instantiation of implicitly-instantiation function templates in + * C++. This option is typically used when parsing a header with the + * intent of producing a precompiled header. + */ + CXTranslationUnit_Incomplete = 0x02, + + /** + * Used to indicate that the translation unit should be built with an + * implicit precompiled header for the preamble. + * + * An implicit precompiled header is used as an optimization when a + * particular translation unit is likely to be reparsed many times + * when the sources aren't changing that often. In this case, an + * implicit precompiled header will be built containing all of the + * initial includes at the top of the main file (what we refer to as + * the "preamble" of the file). In subsequent parses, if the + * preamble or the files in it have not changed, \c + * clang_reparseTranslationUnit() will re-use the implicit + * precompiled header to improve parsing performance. + */ + CXTranslationUnit_PrecompiledPreamble = 0x04, + + /** + * Used to indicate that the translation unit should cache some + * code-completion results with each reparse of the source file. + * + * Caching of code-completion results is a performance optimization that + * introduces some overhead to reparsing but improves the performance of + * code-completion operations. + */ + CXTranslationUnit_CacheCompletionResults = 0x08, + + /** + * Used to indicate that the translation unit will be serialized with + * \c clang_saveTranslationUnit. + * + * This option is typically used when parsing a header with the intent of + * producing a precompiled header. + */ + CXTranslationUnit_ForSerialization = 0x10, + + /** + * DEPRECATED: Enabled chained precompiled preambles in C++. + * + * Note: this is a *temporary* option that is available only while + * we are testing C++ precompiled preamble support. It is deprecated. + */ + CXTranslationUnit_CXXChainedPCH = 0x20, + + /** + * Used to indicate that function/method bodies should be skipped while + * parsing. + * + * This option can be used to search for declarations/definitions while + * ignoring the usages. + */ + CXTranslationUnit_SkipFunctionBodies = 0x40, + + /** + * Used to indicate that brief documentation comments should be + * included into the set of code completions returned from this translation + * unit. + */ + CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, + + /** + * Used to indicate that the precompiled preamble should be created on + * the first parse. Otherwise it will be created on the first reparse. This + * trades runtime on the first parse (serializing the preamble takes time) for + * reduced runtime on the second parse (can now reuse the preamble). + */ + CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, + + /** + * Do not stop processing when fatal errors are encountered. + * + * When fatal errors are encountered while parsing a translation unit, + * semantic analysis is typically stopped early when compiling code. A common + * source for fatal errors are unresolvable include files. For the + * purposes of an IDE, this is undesirable behavior and as much information + * as possible should be reported. Use this flag to enable this behavior. + */ + CXTranslationUnit_KeepGoing = 0x200, + + /** + * Sets the preprocessor in a mode for parsing a single file only. + */ + CXTranslationUnit_SingleFileParse = 0x400, + + /** + * Used in combination with CXTranslationUnit_SkipFunctionBodies to + * constrain the skipping of function bodies to the preamble. + * + * The function bodies of the main file are not skipped. + */ + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, + + /** + * Used to indicate that attributed types should be included in CXType. + */ + CXTranslationUnit_IncludeAttributedTypes = 0x1000, + + /** + * Used to indicate that implicit attributes should be visited. + */ + CXTranslationUnit_VisitImplicitAttributes = 0x2000, + + /** + * Used to indicate that non-errors from included files should be ignored. + * + * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from + * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for + * the case where these warnings are not of interest, as for an IDE for + * example, which typically shows only the diagnostics in the main file. + */ + CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000, + + /** + * Tells the preprocessor not to skip excluded conditional blocks. + */ + CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000 +}; + +/** + * Returns the set of flags that is suitable for parsing a translation + * unit that is being edited. + * + * The set of flags returned provide options for \c clang_parseTranslationUnit() + * to indicate that the translation unit is likely to be reparsed many times, + * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly + * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag + * set contains an unspecified set of optimizations (e.g., the precompiled + * preamble) geared toward improving the performance of these routines. The + * set of optimizations enabled may change from one version to the next. + */ +CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void); + +/** + * Same as \c clang_parseTranslationUnit2, but returns + * the \c CXTranslationUnit instead of an error code. In case of an error this + * routine returns a \c NULL \c CXTranslationUnit, without further detailed + * error codes. + */ +CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit( + CXIndex CIdx, const char *source_filename, + const char *const *command_line_args, int num_command_line_args, + struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, + unsigned options); + +/** + * Parse the given source file and the translation unit corresponding + * to that file. + * + * This routine is the main entry point for the Clang C API, providing the + * ability to parse a source file into a translation unit that can then be + * queried by other functions in the API. This routine accepts a set of + * command-line arguments so that the compilation can be configured in the same + * way that the compiler is configured on the command line. + * + * \param CIdx The index object with which the translation unit will be + * associated. + * + * \param source_filename The name of the source file to load, or NULL if the + * source file is included in \c command_line_args. + * + * \param command_line_args The command-line arguments that would be + * passed to the \c clang executable if it were being invoked out-of-process. + * These command-line options will be parsed and will affect how the translation + * unit is parsed. Note that the following options are ignored: '-c', + * '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. + * + * \param num_command_line_args The number of command-line arguments in + * \c command_line_args. + * + * \param unsaved_files the files that have not yet been saved to disk + * but may be required for parsing, including the contents of + * those files. The contents and name of these files (as specified by + * CXUnsavedFile) are copied when necessary, so the client only needs to + * guarantee their validity until the call to this function returns. + * + * \param num_unsaved_files the number of unsaved file entries in \p + * unsaved_files. + * + * \param options A bitmask of options that affects how the translation unit + * is managed but not its compilation. This should be a bitwise OR of the + * CXTranslationUnit_XXX flags. + * + * \param[out] out_TU A non-NULL pointer to store the created + * \c CXTranslationUnit, describing the parsed code and containing any + * diagnostics produced by the compiler. + * + * \returns Zero on success, otherwise returns an error code. + */ +CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2( + CXIndex CIdx, const char *source_filename, + const char *const *command_line_args, int num_command_line_args, + struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, + unsigned options, CXTranslationUnit *out_TU); + +/** + * Same as clang_parseTranslationUnit2 but requires a full command line + * for \c command_line_args including argv[0]. This is useful if the standard + * library paths are relative to the binary. + */ +CINDEX_LINKAGE enum CXErrorCode clang_parseTranslationUnit2FullArgv( + CXIndex CIdx, const char *source_filename, + const char *const *command_line_args, int num_command_line_args, + struct CXUnsavedFile *unsaved_files, unsigned num_unsaved_files, + unsigned options, CXTranslationUnit *out_TU); + +/** + * Flags that control how translation units are saved. + * + * The enumerators in this enumeration type are meant to be bitwise + * ORed together to specify which options should be used when + * saving the translation unit. + */ +enum CXSaveTranslationUnit_Flags { + /** + * Used to indicate that no special saving options are needed. + */ + CXSaveTranslationUnit_None = 0x0 +}; + +/** + * Returns the set of flags that is suitable for saving a translation + * unit. + * + * The set of flags returned provide options for + * \c clang_saveTranslationUnit() by default. The returned flag + * set contains an unspecified set of options that save translation units with + * the most commonly-requested data. + */ +CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU); + +/** + * Describes the kind of error that occurred (if any) in a call to + * \c clang_saveTranslationUnit(). + */ +enum CXSaveError { + /** + * Indicates that no error occurred while saving a translation unit. + */ + CXSaveError_None = 0, + + /** + * Indicates that an unknown error occurred while attempting to save + * the file. + * + * This error typically indicates that file I/O failed when attempting to + * write the file. + */ + CXSaveError_Unknown = 1, + + /** + * Indicates that errors during translation prevented this attempt + * to save the translation unit. + * + * Errors that prevent the translation unit from being saved can be + * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic(). + */ + CXSaveError_TranslationErrors = 2, + + /** + * Indicates that the translation unit to be saved was somehow + * invalid (e.g., NULL). + */ + CXSaveError_InvalidTU = 3 +}; + +/** + * Saves a translation unit into a serialized representation of + * that translation unit on disk. + * + * Any translation unit that was parsed without error can be saved + * into a file. The translation unit can then be deserialized into a + * new \c CXTranslationUnit with \c clang_createTranslationUnit() or, + * if it is an incomplete translation unit that corresponds to a + * header, used as a precompiled header when parsing other translation + * units. + * + * \param TU The translation unit to save. + * + * \param FileName The file to which the translation unit will be saved. + * + * \param options A bitmask of options that affects how the translation unit + * is saved. This should be a bitwise OR of the + * CXSaveTranslationUnit_XXX flags. + * + * \returns A value that will match one of the enumerators of the CXSaveError + * enumeration. Zero (CXSaveError_None) indicates that the translation unit was + * saved successfully, while a non-zero value indicates that a problem occurred. + */ +CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU, + const char *FileName, + unsigned options); + +/** + * Suspend a translation unit in order to free memory associated with it. + * + * A suspended translation unit uses significantly less memory but on the other + * side does not support any other calls than \c clang_reparseTranslationUnit + * to resume it or \c clang_disposeTranslationUnit to dispose it completely. + */ +CINDEX_LINKAGE unsigned clang_suspendTranslationUnit(CXTranslationUnit); + +/** + * Destroy the specified CXTranslationUnit object. + */ +CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit); + +/** + * Flags that control the reparsing of translation units. + * + * The enumerators in this enumeration type are meant to be bitwise + * ORed together to specify which options should be used when + * reparsing the translation unit. + */ +enum CXReparse_Flags { + /** + * Used to indicate that no special reparsing options are needed. + */ + CXReparse_None = 0x0 +}; + +/** + * Returns the set of flags that is suitable for reparsing a translation + * unit. + * + * The set of flags returned provide options for + * \c clang_reparseTranslationUnit() by default. The returned flag + * set contains an unspecified set of optimizations geared toward common uses + * of reparsing. The set of optimizations enabled may change from one version + * to the next. + */ +CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU); + +/** + * Reparse the source files that produced this translation unit. + * + * This routine can be used to re-parse the source files that originally + * created the given translation unit, for example because those source files + * have changed (either on disk or as passed via \p unsaved_files). The + * source code will be reparsed with the same command-line options as it + * was originally parsed. + * + * Reparsing a translation unit invalidates all cursors and source locations + * that refer into that translation unit. This makes reparsing a translation + * unit semantically equivalent to destroying the translation unit and then + * creating a new translation unit with the same command-line arguments. + * However, it may be more efficient to reparse a translation + * unit using this routine. + * + * \param TU The translation unit whose contents will be re-parsed. The + * translation unit must originally have been built with + * \c clang_createTranslationUnitFromSourceFile(). + * + * \param num_unsaved_files The number of unsaved file entries in \p + * unsaved_files. + * + * \param unsaved_files The files that have not yet been saved to disk + * but may be required for parsing, including the contents of + * those files. The contents and name of these files (as specified by + * CXUnsavedFile) are copied when necessary, so the client only needs to + * guarantee their validity until the call to this function returns. + * + * \param options A bitset of options composed of the flags in CXReparse_Flags. + * The function \c clang_defaultReparseOptions() produces a default set of + * options recommended for most uses, based on the translation unit. + * + * \returns 0 if the sources could be reparsed. A non-zero error code will be + * returned if reparsing was impossible, such that the translation unit is + * invalid. In such cases, the only valid call for \c TU is + * \c clang_disposeTranslationUnit(TU). The error codes returned by this + * routine are described by the \c CXErrorCode enum. + */ +CINDEX_LINKAGE int +clang_reparseTranslationUnit(CXTranslationUnit TU, unsigned num_unsaved_files, + struct CXUnsavedFile *unsaved_files, + unsigned options); + +/** + * Categorizes how memory is being used by a translation unit. + */ +enum CXTUResourceUsageKind { + CXTUResourceUsage_AST = 1, + CXTUResourceUsage_Identifiers = 2, + CXTUResourceUsage_Selectors = 3, + CXTUResourceUsage_GlobalCompletionResults = 4, + CXTUResourceUsage_SourceManagerContentCache = 5, + CXTUResourceUsage_AST_SideTables = 6, + CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, + CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, + CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, + CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, + CXTUResourceUsage_Preprocessor = 11, + CXTUResourceUsage_PreprocessingRecord = 12, + CXTUResourceUsage_SourceManager_DataStructures = 13, + CXTUResourceUsage_Preprocessor_HeaderSearch = 14, + CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, + CXTUResourceUsage_MEMORY_IN_BYTES_END = + CXTUResourceUsage_Preprocessor_HeaderSearch, + + CXTUResourceUsage_First = CXTUResourceUsage_AST, + CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch +}; + +/** + * Returns the human-readable null-terminated C string that represents + * the name of the memory category. This string should never be freed. + */ +CINDEX_LINKAGE +const char *clang_getTUResourceUsageName(enum CXTUResourceUsageKind kind); + +typedef struct CXTUResourceUsageEntry { + /* The memory usage category. */ + enum CXTUResourceUsageKind kind; + /* Amount of resources used. + The units will depend on the resource kind. */ + unsigned long amount; +} CXTUResourceUsageEntry; + +/** + * The memory usage of a CXTranslationUnit, broken into categories. + */ +typedef struct CXTUResourceUsage { + /* Private data member, used for queries. */ + void *data; + + /* The number of entries in the 'entries' array. */ + unsigned numEntries; + + /* An array of key-value pairs, representing the breakdown of memory + usage. */ + CXTUResourceUsageEntry *entries; + +} CXTUResourceUsage; + +/** + * Return the memory usage of a translation unit. This object + * should be released with clang_disposeCXTUResourceUsage(). + */ +CINDEX_LINKAGE CXTUResourceUsage +clang_getCXTUResourceUsage(CXTranslationUnit TU); + +CINDEX_LINKAGE void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage); + +/** + * Get target information for this translation unit. + * + * The CXTargetInfo object cannot outlive the CXTranslationUnit object. + */ +CINDEX_LINKAGE CXTargetInfo +clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit); + +/** + * Destroy the CXTargetInfo object. + */ +CINDEX_LINKAGE void clang_TargetInfo_dispose(CXTargetInfo Info); + +/** + * Get the normalized target triple as a string. + * + * Returns the empty string in case of any error. + */ +CINDEX_LINKAGE CXString clang_TargetInfo_getTriple(CXTargetInfo Info); + +/** + * Get the pointer width of the target in bits. + * + * Returns -1 in case of error. + */ +CINDEX_LINKAGE int clang_TargetInfo_getPointerWidth(CXTargetInfo Info); + +/** + * @} + */ + +/** + * Describes the kind of entity that a cursor refers to. + */ +enum CXCursorKind { + /* Declarations */ + /** + * A declaration whose specific kind is not exposed via this + * interface. + * + * Unexposed declarations have the same operations as any other kind + * of declaration; one can extract their location information, + * spelling, find their definitions, etc. However, the specific kind + * of the declaration is not reported. + */ + CXCursor_UnexposedDecl = 1, + /** A C or C++ struct. */ + CXCursor_StructDecl = 2, + /** A C or C++ union. */ + CXCursor_UnionDecl = 3, + /** A C++ class. */ + CXCursor_ClassDecl = 4, + /** An enumeration. */ + CXCursor_EnumDecl = 5, + /** + * A field (in C) or non-static data member (in C++) in a + * struct, union, or C++ class. + */ + CXCursor_FieldDecl = 6, + /** An enumerator constant. */ + CXCursor_EnumConstantDecl = 7, + /** A function. */ + CXCursor_FunctionDecl = 8, + /** A variable. */ + CXCursor_VarDecl = 9, + /** A function or method parameter. */ + CXCursor_ParmDecl = 10, + /** An Objective-C \@interface. */ + CXCursor_ObjCInterfaceDecl = 11, + /** An Objective-C \@interface for a category. */ + CXCursor_ObjCCategoryDecl = 12, + /** An Objective-C \@protocol declaration. */ + CXCursor_ObjCProtocolDecl = 13, + /** An Objective-C \@property declaration. */ + CXCursor_ObjCPropertyDecl = 14, + /** An Objective-C instance variable. */ + CXCursor_ObjCIvarDecl = 15, + /** An Objective-C instance method. */ + CXCursor_ObjCInstanceMethodDecl = 16, + /** An Objective-C class method. */ + CXCursor_ObjCClassMethodDecl = 17, + /** An Objective-C \@implementation. */ + CXCursor_ObjCImplementationDecl = 18, + /** An Objective-C \@implementation for a category. */ + CXCursor_ObjCCategoryImplDecl = 19, + /** A typedef. */ + CXCursor_TypedefDecl = 20, + /** A C++ class method. */ + CXCursor_CXXMethod = 21, + /** A C++ namespace. */ + CXCursor_Namespace = 22, + /** A linkage specification, e.g. 'extern "C"'. */ + CXCursor_LinkageSpec = 23, + /** A C++ constructor. */ + CXCursor_Constructor = 24, + /** A C++ destructor. */ + CXCursor_Destructor = 25, + /** A C++ conversion function. */ + CXCursor_ConversionFunction = 26, + /** A C++ template type parameter. */ + CXCursor_TemplateTypeParameter = 27, + /** A C++ non-type template parameter. */ + CXCursor_NonTypeTemplateParameter = 28, + /** A C++ template template parameter. */ + CXCursor_TemplateTemplateParameter = 29, + /** A C++ function template. */ + CXCursor_FunctionTemplate = 30, + /** A C++ class template. */ + CXCursor_ClassTemplate = 31, + /** A C++ class template partial specialization. */ + CXCursor_ClassTemplatePartialSpecialization = 32, + /** A C++ namespace alias declaration. */ + CXCursor_NamespaceAlias = 33, + /** A C++ using directive. */ + CXCursor_UsingDirective = 34, + /** A C++ using declaration. */ + CXCursor_UsingDeclaration = 35, + /** A C++ alias declaration */ + CXCursor_TypeAliasDecl = 36, + /** An Objective-C \@synthesize definition. */ + CXCursor_ObjCSynthesizeDecl = 37, + /** An Objective-C \@dynamic definition. */ + CXCursor_ObjCDynamicDecl = 38, + /** An access specifier. */ + CXCursor_CXXAccessSpecifier = 39, + + CXCursor_FirstDecl = CXCursor_UnexposedDecl, + CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, + + /* References */ + CXCursor_FirstRef = 40, /* Decl references */ + CXCursor_ObjCSuperClassRef = 40, + CXCursor_ObjCProtocolRef = 41, + CXCursor_ObjCClassRef = 42, + /** + * A reference to a type declaration. + * + * A type reference occurs anywhere where a type is named but not + * declared. For example, given: + * + * \code + * typedef unsigned size_type; + * size_type size; + * \endcode + * + * The typedef is a declaration of size_type (CXCursor_TypedefDecl), + * while the type of the variable "size" is referenced. The cursor + * referenced by the type of size is the typedef for size_type. + */ + CXCursor_TypeRef = 43, + CXCursor_CXXBaseSpecifier = 44, + /** + * A reference to a class template, function template, template + * template parameter, or class template partial specialization. + */ + CXCursor_TemplateRef = 45, + /** + * A reference to a namespace or namespace alias. + */ + CXCursor_NamespaceRef = 46, + /** + * A reference to a member of a struct, union, or class that occurs in + * some non-expression context, e.g., a designated initializer. + */ + CXCursor_MemberRef = 47, + /** + * A reference to a labeled statement. + * + * This cursor kind is used to describe the jump to "start_over" in the + * goto statement in the following example: + * + * \code + * start_over: + * ++counter; + * + * goto start_over; + * \endcode + * + * A label reference cursor refers to a label statement. + */ + CXCursor_LabelRef = 48, + + /** + * A reference to a set of overloaded functions or function templates + * that has not yet been resolved to a specific function or function template. + * + * An overloaded declaration reference cursor occurs in C++ templates where + * a dependent name refers to a function. For example: + * + * \code + * template void swap(T&, T&); + * + * struct X { ... }; + * void swap(X&, X&); + * + * template + * void reverse(T* first, T* last) { + * while (first < last - 1) { + * swap(*first, *--last); + * ++first; + * } + * } + * + * struct Y { }; + * void swap(Y&, Y&); + * \endcode + * + * Here, the identifier "swap" is associated with an overloaded declaration + * reference. In the template definition, "swap" refers to either of the two + * "swap" functions declared above, so both results will be available. At + * instantiation time, "swap" may also refer to other functions found via + * argument-dependent lookup (e.g., the "swap" function at the end of the + * example). + * + * The functions \c clang_getNumOverloadedDecls() and + * \c clang_getOverloadedDecl() can be used to retrieve the definitions + * referenced by this cursor. + */ + CXCursor_OverloadedDeclRef = 49, + + /** + * A reference to a variable that occurs in some non-expression + * context, e.g., a C++ lambda capture list. + */ + CXCursor_VariableRef = 50, + + CXCursor_LastRef = CXCursor_VariableRef, + + /* Error conditions */ + CXCursor_FirstInvalid = 70, + CXCursor_InvalidFile = 70, + CXCursor_NoDeclFound = 71, + CXCursor_NotImplemented = 72, + CXCursor_InvalidCode = 73, + CXCursor_LastInvalid = CXCursor_InvalidCode, + + /* Expressions */ + CXCursor_FirstExpr = 100, + + /** + * An expression whose specific kind is not exposed via this + * interface. + * + * Unexposed expressions have the same operations as any other kind + * of expression; one can extract their location information, + * spelling, children, etc. However, the specific kind of the + * expression is not reported. + */ + CXCursor_UnexposedExpr = 100, + + /** + * An expression that refers to some value declaration, such + * as a function, variable, or enumerator. + */ + CXCursor_DeclRefExpr = 101, + + /** + * An expression that refers to a member of a struct, union, + * class, Objective-C class, etc. + */ + CXCursor_MemberRefExpr = 102, + + /** An expression that calls a function. */ + CXCursor_CallExpr = 103, + + /** An expression that sends a message to an Objective-C + object or class. */ + CXCursor_ObjCMessageExpr = 104, + + /** An expression that represents a block literal. */ + CXCursor_BlockExpr = 105, + + /** An integer literal. + */ + CXCursor_IntegerLiteral = 106, + + /** A floating point number literal. + */ + CXCursor_FloatingLiteral = 107, + + /** An imaginary number literal. + */ + CXCursor_ImaginaryLiteral = 108, + + /** A string literal. + */ + CXCursor_StringLiteral = 109, + + /** A character literal. + */ + CXCursor_CharacterLiteral = 110, + + /** A parenthesized expression, e.g. "(1)". + * + * This AST node is only formed if full location information is requested. + */ + CXCursor_ParenExpr = 111, + + /** This represents the unary-expression's (except sizeof and + * alignof). + */ + CXCursor_UnaryOperator = 112, + + /** [C99 6.5.2.1] Array Subscripting. + */ + CXCursor_ArraySubscriptExpr = 113, + + /** A builtin binary operation expression such as "x + y" or + * "x <= y". + */ + CXCursor_BinaryOperator = 114, + + /** Compound assignment such as "+=". + */ + CXCursor_CompoundAssignOperator = 115, + + /** The ?: ternary operator. + */ + CXCursor_ConditionalOperator = 116, + + /** An explicit cast in C (C99 6.5.4) or a C-style cast in C++ + * (C++ [expr.cast]), which uses the syntax (Type)expr. + * + * For example: (int)f. + */ + CXCursor_CStyleCastExpr = 117, + + /** [C99 6.5.2.5] + */ + CXCursor_CompoundLiteralExpr = 118, + + /** Describes an C or C++ initializer list. + */ + CXCursor_InitListExpr = 119, + + /** The GNU address of label extension, representing &&label. + */ + CXCursor_AddrLabelExpr = 120, + + /** This is the GNU Statement Expression extension: ({int X=4; X;}) + */ + CXCursor_StmtExpr = 121, + + /** Represents a C11 generic selection. + */ + CXCursor_GenericSelectionExpr = 122, + + /** Implements the GNU __null extension, which is a name for a null + * pointer constant that has integral type (e.g., int or long) and is the same + * size and alignment as a pointer. + * + * The __null extension is typically only used by system headers, which define + * NULL as __null in C++ rather than using 0 (which is an integer that may not + * match the size of a pointer). + */ + CXCursor_GNUNullExpr = 123, + + /** C++'s static_cast<> expression. + */ + CXCursor_CXXStaticCastExpr = 124, + + /** C++'s dynamic_cast<> expression. + */ + CXCursor_CXXDynamicCastExpr = 125, + + /** C++'s reinterpret_cast<> expression. + */ + CXCursor_CXXReinterpretCastExpr = 126, + + /** C++'s const_cast<> expression. + */ + CXCursor_CXXConstCastExpr = 127, + + /** Represents an explicit C++ type conversion that uses "functional" + * notion (C++ [expr.type.conv]). + * + * Example: + * \code + * x = int(0.5); + * \endcode + */ + CXCursor_CXXFunctionalCastExpr = 128, + + /** A C++ typeid expression (C++ [expr.typeid]). + */ + CXCursor_CXXTypeidExpr = 129, + + /** [C++ 2.13.5] C++ Boolean Literal. + */ + CXCursor_CXXBoolLiteralExpr = 130, + + /** [C++0x 2.14.7] C++ Pointer Literal. + */ + CXCursor_CXXNullPtrLiteralExpr = 131, + + /** Represents the "this" expression in C++ + */ + CXCursor_CXXThisExpr = 132, + + /** [C++ 15] C++ Throw Expression. + * + * This handles 'throw' and 'throw' assignment-expression. When + * assignment-expression isn't present, Op will be null. + */ + CXCursor_CXXThrowExpr = 133, + + /** A new expression for memory allocation and constructor calls, e.g: + * "new CXXNewExpr(foo)". + */ + CXCursor_CXXNewExpr = 134, + + /** A delete expression for memory deallocation and destructor calls, + * e.g. "delete[] pArray". + */ + CXCursor_CXXDeleteExpr = 135, + + /** A unary expression. (noexcept, sizeof, or other traits) + */ + CXCursor_UnaryExpr = 136, + + /** An Objective-C string literal i.e. @"foo". + */ + CXCursor_ObjCStringLiteral = 137, + + /** An Objective-C \@encode expression. + */ + CXCursor_ObjCEncodeExpr = 138, + + /** An Objective-C \@selector expression. + */ + CXCursor_ObjCSelectorExpr = 139, + + /** An Objective-C \@protocol expression. + */ + CXCursor_ObjCProtocolExpr = 140, + + /** An Objective-C "bridged" cast expression, which casts between + * Objective-C pointers and C pointers, transferring ownership in the process. + * + * \code + * NSString *str = (__bridge_transfer NSString *)CFCreateString(); + * \endcode + */ + CXCursor_ObjCBridgedCastExpr = 141, + + /** Represents a C++0x pack expansion that produces a sequence of + * expressions. + * + * A pack expansion expression contains a pattern (which itself is an + * expression) followed by an ellipsis. For example: + * + * \code + * template + * void forward(F f, Types &&...args) { + * f(static_cast(args)...); + * } + * \endcode + */ + CXCursor_PackExpansionExpr = 142, + + /** Represents an expression that computes the length of a parameter + * pack. + * + * \code + * template + * struct count { + * static const unsigned value = sizeof...(Types); + * }; + * \endcode + */ + CXCursor_SizeOfPackExpr = 143, + + /* Represents a C++ lambda expression that produces a local function + * object. + * + * \code + * void abssort(float *x, unsigned N) { + * std::sort(x, x + N, + * [](float a, float b) { + * return std::abs(a) < std::abs(b); + * }); + * } + * \endcode + */ + CXCursor_LambdaExpr = 144, + + /** Objective-c Boolean Literal. + */ + CXCursor_ObjCBoolLiteralExpr = 145, + + /** Represents the "self" expression in an Objective-C method. + */ + CXCursor_ObjCSelfExpr = 146, + + /** OpenMP 5.0 [2.1.5, Array Section]. + * OpenACC 3.3 [2.7.1, Data Specification for Data Clauses (Sub Arrays)] + */ + CXCursor_ArraySectionExpr = 147, + + /** Represents an @available(...) check. + */ + CXCursor_ObjCAvailabilityCheckExpr = 148, + + /** + * Fixed point literal + */ + CXCursor_FixedPointLiteral = 149, + + /** OpenMP 5.0 [2.1.4, Array Shaping]. + */ + CXCursor_OMPArrayShapingExpr = 150, + + /** + * OpenMP 5.0 [2.1.6 Iterators] + */ + CXCursor_OMPIteratorExpr = 151, + + /** OpenCL's addrspace_cast<> expression. + */ + CXCursor_CXXAddrspaceCastExpr = 152, + + /** + * Expression that references a C++20 concept. + */ + CXCursor_ConceptSpecializationExpr = 153, + + /** + * Expression that references a C++20 requires expression. + */ + CXCursor_RequiresExpr = 154, + + /** + * Expression that references a C++20 parenthesized list aggregate + * initializer. + */ + CXCursor_CXXParenListInitExpr = 155, + + /** + * Represents a C++26 pack indexing expression. + */ + CXCursor_PackIndexingExpr = 156, + + CXCursor_LastExpr = CXCursor_PackIndexingExpr, + + /* Statements */ + CXCursor_FirstStmt = 200, + /** + * A statement whose specific kind is not exposed via this + * interface. + * + * Unexposed statements have the same operations as any other kind of + * statement; one can extract their location information, spelling, + * children, etc. However, the specific kind of the statement is not + * reported. + */ + CXCursor_UnexposedStmt = 200, + + /** A labelled statement in a function. + * + * This cursor kind is used to describe the "start_over:" label statement in + * the following example: + * + * \code + * start_over: + * ++counter; + * \endcode + * + */ + CXCursor_LabelStmt = 201, + + /** A group of statements like { stmt stmt }. + * + * This cursor kind is used to describe compound statements, e.g. function + * bodies. + */ + CXCursor_CompoundStmt = 202, + + /** A case statement. + */ + CXCursor_CaseStmt = 203, + + /** A default statement. + */ + CXCursor_DefaultStmt = 204, + + /** An if statement + */ + CXCursor_IfStmt = 205, + + /** A switch statement. + */ + CXCursor_SwitchStmt = 206, + + /** A while statement. + */ + CXCursor_WhileStmt = 207, + + /** A do statement. + */ + CXCursor_DoStmt = 208, + + /** A for statement. + */ + CXCursor_ForStmt = 209, + + /** A goto statement. + */ + CXCursor_GotoStmt = 210, + + /** An indirect goto statement. + */ + CXCursor_IndirectGotoStmt = 211, + + /** A continue statement. + */ + CXCursor_ContinueStmt = 212, + + /** A break statement. + */ + CXCursor_BreakStmt = 213, + + /** A return statement. + */ + CXCursor_ReturnStmt = 214, + + /** A GCC inline assembly statement extension. + */ + CXCursor_GCCAsmStmt = 215, + CXCursor_AsmStmt = CXCursor_GCCAsmStmt, + + /** Objective-C's overall \@try-\@catch-\@finally statement. + */ + CXCursor_ObjCAtTryStmt = 216, + + /** Objective-C's \@catch statement. + */ + CXCursor_ObjCAtCatchStmt = 217, + + /** Objective-C's \@finally statement. + */ + CXCursor_ObjCAtFinallyStmt = 218, + + /** Objective-C's \@throw statement. + */ + CXCursor_ObjCAtThrowStmt = 219, + + /** Objective-C's \@synchronized statement. + */ + CXCursor_ObjCAtSynchronizedStmt = 220, + + /** Objective-C's autorelease pool statement. + */ + CXCursor_ObjCAutoreleasePoolStmt = 221, + + /** Objective-C's collection statement. + */ + CXCursor_ObjCForCollectionStmt = 222, + + /** C++'s catch statement. + */ + CXCursor_CXXCatchStmt = 223, + + /** C++'s try statement. + */ + CXCursor_CXXTryStmt = 224, + + /** C++'s for (* : *) statement. + */ + CXCursor_CXXForRangeStmt = 225, + + /** Windows Structured Exception Handling's try statement. + */ + CXCursor_SEHTryStmt = 226, + + /** Windows Structured Exception Handling's except statement. + */ + CXCursor_SEHExceptStmt = 227, + + /** Windows Structured Exception Handling's finally statement. + */ + CXCursor_SEHFinallyStmt = 228, + + /** A MS inline assembly statement extension. + */ + CXCursor_MSAsmStmt = 229, + + /** The null statement ";": C99 6.8.3p3. + * + * This cursor kind is used to describe the null statement. + */ + CXCursor_NullStmt = 230, + + /** Adaptor class for mixing declarations with statements and + * expressions. + */ + CXCursor_DeclStmt = 231, + + /** OpenMP parallel directive. + */ + CXCursor_OMPParallelDirective = 232, + + /** OpenMP SIMD directive. + */ + CXCursor_OMPSimdDirective = 233, + + /** OpenMP for directive. + */ + CXCursor_OMPForDirective = 234, + + /** OpenMP sections directive. + */ + CXCursor_OMPSectionsDirective = 235, + + /** OpenMP section directive. + */ + CXCursor_OMPSectionDirective = 236, + + /** OpenMP single directive. + */ + CXCursor_OMPSingleDirective = 237, + + /** OpenMP parallel for directive. + */ + CXCursor_OMPParallelForDirective = 238, + + /** OpenMP parallel sections directive. + */ + CXCursor_OMPParallelSectionsDirective = 239, + + /** OpenMP task directive. + */ + CXCursor_OMPTaskDirective = 240, + + /** OpenMP master directive. + */ + CXCursor_OMPMasterDirective = 241, + + /** OpenMP critical directive. + */ + CXCursor_OMPCriticalDirective = 242, + + /** OpenMP taskyield directive. + */ + CXCursor_OMPTaskyieldDirective = 243, + + /** OpenMP barrier directive. + */ + CXCursor_OMPBarrierDirective = 244, + + /** OpenMP taskwait directive. + */ + CXCursor_OMPTaskwaitDirective = 245, + + /** OpenMP flush directive. + */ + CXCursor_OMPFlushDirective = 246, + + /** Windows Structured Exception Handling's leave statement. + */ + CXCursor_SEHLeaveStmt = 247, + + /** OpenMP ordered directive. + */ + CXCursor_OMPOrderedDirective = 248, + + /** OpenMP atomic directive. + */ + CXCursor_OMPAtomicDirective = 249, + + /** OpenMP for SIMD directive. + */ + CXCursor_OMPForSimdDirective = 250, + + /** OpenMP parallel for SIMD directive. + */ + CXCursor_OMPParallelForSimdDirective = 251, + + /** OpenMP target directive. + */ + CXCursor_OMPTargetDirective = 252, + + /** OpenMP teams directive. + */ + CXCursor_OMPTeamsDirective = 253, + + /** OpenMP taskgroup directive. + */ + CXCursor_OMPTaskgroupDirective = 254, + + /** OpenMP cancellation point directive. + */ + CXCursor_OMPCancellationPointDirective = 255, + + /** OpenMP cancel directive. + */ + CXCursor_OMPCancelDirective = 256, + + /** OpenMP target data directive. + */ + CXCursor_OMPTargetDataDirective = 257, + + /** OpenMP taskloop directive. + */ + CXCursor_OMPTaskLoopDirective = 258, + + /** OpenMP taskloop simd directive. + */ + CXCursor_OMPTaskLoopSimdDirective = 259, + + /** OpenMP distribute directive. + */ + CXCursor_OMPDistributeDirective = 260, + + /** OpenMP target enter data directive. + */ + CXCursor_OMPTargetEnterDataDirective = 261, + + /** OpenMP target exit data directive. + */ + CXCursor_OMPTargetExitDataDirective = 262, + + /** OpenMP target parallel directive. + */ + CXCursor_OMPTargetParallelDirective = 263, + + /** OpenMP target parallel for directive. + */ + CXCursor_OMPTargetParallelForDirective = 264, + + /** OpenMP target update directive. + */ + CXCursor_OMPTargetUpdateDirective = 265, + + /** OpenMP distribute parallel for directive. + */ + CXCursor_OMPDistributeParallelForDirective = 266, + + /** OpenMP distribute parallel for simd directive. + */ + CXCursor_OMPDistributeParallelForSimdDirective = 267, + + /** OpenMP distribute simd directive. + */ + CXCursor_OMPDistributeSimdDirective = 268, + + /** OpenMP target parallel for simd directive. + */ + CXCursor_OMPTargetParallelForSimdDirective = 269, + + /** OpenMP target simd directive. + */ + CXCursor_OMPTargetSimdDirective = 270, + + /** OpenMP teams distribute directive. + */ + CXCursor_OMPTeamsDistributeDirective = 271, + + /** OpenMP teams distribute simd directive. + */ + CXCursor_OMPTeamsDistributeSimdDirective = 272, + + /** OpenMP teams distribute parallel for simd directive. + */ + CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, + + /** OpenMP teams distribute parallel for directive. + */ + CXCursor_OMPTeamsDistributeParallelForDirective = 274, + + /** OpenMP target teams directive. + */ + CXCursor_OMPTargetTeamsDirective = 275, + + /** OpenMP target teams distribute directive. + */ + CXCursor_OMPTargetTeamsDistributeDirective = 276, + + /** OpenMP target teams distribute parallel for directive. + */ + CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, + + /** OpenMP target teams distribute parallel for simd directive. + */ + CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, + + /** OpenMP target teams distribute simd directive. + */ + CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, + + /** C++2a std::bit_cast expression. + */ + CXCursor_BuiltinBitCastExpr = 280, + + /** OpenMP master taskloop directive. + */ + CXCursor_OMPMasterTaskLoopDirective = 281, + + /** OpenMP parallel master taskloop directive. + */ + CXCursor_OMPParallelMasterTaskLoopDirective = 282, + + /** OpenMP master taskloop simd directive. + */ + CXCursor_OMPMasterTaskLoopSimdDirective = 283, + + /** OpenMP parallel master taskloop simd directive. + */ + CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284, + + /** OpenMP parallel master directive. + */ + CXCursor_OMPParallelMasterDirective = 285, + + /** OpenMP depobj directive. + */ + CXCursor_OMPDepobjDirective = 286, + + /** OpenMP scan directive. + */ + CXCursor_OMPScanDirective = 287, + + /** OpenMP tile directive. + */ + CXCursor_OMPTileDirective = 288, + + /** OpenMP canonical loop. + */ + CXCursor_OMPCanonicalLoop = 289, + + /** OpenMP interop directive. + */ + CXCursor_OMPInteropDirective = 290, + + /** OpenMP dispatch directive. + */ + CXCursor_OMPDispatchDirective = 291, + + /** OpenMP masked directive. + */ + CXCursor_OMPMaskedDirective = 292, + + /** OpenMP unroll directive. + */ + CXCursor_OMPUnrollDirective = 293, + + /** OpenMP metadirective directive. + */ + CXCursor_OMPMetaDirective = 294, + + /** OpenMP loop directive. + */ + CXCursor_OMPGenericLoopDirective = 295, + + /** OpenMP teams loop directive. + */ + CXCursor_OMPTeamsGenericLoopDirective = 296, + + /** OpenMP target teams loop directive. + */ + CXCursor_OMPTargetTeamsGenericLoopDirective = 297, + + /** OpenMP parallel loop directive. + */ + CXCursor_OMPParallelGenericLoopDirective = 298, + + /** OpenMP target parallel loop directive. + */ + CXCursor_OMPTargetParallelGenericLoopDirective = 299, + + /** OpenMP parallel masked directive. + */ + CXCursor_OMPParallelMaskedDirective = 300, + + /** OpenMP masked taskloop directive. + */ + CXCursor_OMPMaskedTaskLoopDirective = 301, + + /** OpenMP masked taskloop simd directive. + */ + CXCursor_OMPMaskedTaskLoopSimdDirective = 302, + + /** OpenMP parallel masked taskloop directive. + */ + CXCursor_OMPParallelMaskedTaskLoopDirective = 303, + + /** OpenMP parallel masked taskloop simd directive. + */ + CXCursor_OMPParallelMaskedTaskLoopSimdDirective = 304, + + /** OpenMP error directive. + */ + CXCursor_OMPErrorDirective = 305, + + /** OpenMP scope directive. + */ + CXCursor_OMPScopeDirective = 306, + + /** OpenMP reverse directive. + */ + CXCursor_OMPReverseDirective = 307, + + /** OpenMP interchange directive. + */ + CXCursor_OMPInterchangeDirective = 308, + + /** OpenMP assume directive. + */ + CXCursor_OMPAssumeDirective = 309, + + /** OpenMP assume directive. + */ + CXCursor_OMPStripeDirective = 310, + + /** OpenACC Compute Construct. + */ + CXCursor_OpenACCComputeConstruct = 320, + + /** OpenACC Loop Construct. + */ + CXCursor_OpenACCLoopConstruct = 321, + + /** OpenACC Combined Constructs. + */ + CXCursor_OpenACCCombinedConstruct = 322, + + /** OpenACC data Construct. + */ + CXCursor_OpenACCDataConstruct = 323, + + /** OpenACC enter data Construct. + */ + CXCursor_OpenACCEnterDataConstruct = 324, + + /** OpenACC exit data Construct. + */ + CXCursor_OpenACCExitDataConstruct = 325, + + /** OpenACC host_data Construct. + */ + CXCursor_OpenACCHostDataConstruct = 326, + + /** OpenACC wait Construct. + */ + CXCursor_OpenACCWaitConstruct = 327, + + /** OpenACC init Construct. + */ + CXCursor_OpenACCInitConstruct = 328, + + /** OpenACC shutdown Construct. + */ + CXCursor_OpenACCShutdownConstruct = 329, + + /** OpenACC set Construct. + */ + CXCursor_OpenACCSetConstruct = 330, + + /** OpenACC update Construct. + */ + CXCursor_OpenACCUpdateConstruct = 331, + + /** OpenACC atomic Construct. + */ + CXCursor_OpenACCAtomicConstruct = 332, + + /** OpenACC cache Construct. + */ + CXCursor_OpenACCCacheConstruct = 333, + + CXCursor_LastStmt = CXCursor_OpenACCCacheConstruct, + + /** + * Cursor that represents the translation unit itself. + * + * The translation unit cursor exists primarily to act as the root + * cursor for traversing the contents of a translation unit. + */ + CXCursor_TranslationUnit = 350, + + /* Attributes */ + CXCursor_FirstAttr = 400, + /** + * An attribute whose specific kind is not exposed via this + * interface. + */ + CXCursor_UnexposedAttr = 400, + + CXCursor_IBActionAttr = 401, + CXCursor_IBOutletAttr = 402, + CXCursor_IBOutletCollectionAttr = 403, + CXCursor_CXXFinalAttr = 404, + CXCursor_CXXOverrideAttr = 405, + CXCursor_AnnotateAttr = 406, + CXCursor_AsmLabelAttr = 407, + CXCursor_PackedAttr = 408, + CXCursor_PureAttr = 409, + CXCursor_ConstAttr = 410, + CXCursor_NoDuplicateAttr = 411, + CXCursor_CUDAConstantAttr = 412, + CXCursor_CUDADeviceAttr = 413, + CXCursor_CUDAGlobalAttr = 414, + CXCursor_CUDAHostAttr = 415, + CXCursor_CUDASharedAttr = 416, + CXCursor_VisibilityAttr = 417, + CXCursor_DLLExport = 418, + CXCursor_DLLImport = 419, + CXCursor_NSReturnsRetained = 420, + CXCursor_NSReturnsNotRetained = 421, + CXCursor_NSReturnsAutoreleased = 422, + CXCursor_NSConsumesSelf = 423, + CXCursor_NSConsumed = 424, + CXCursor_ObjCException = 425, + CXCursor_ObjCNSObject = 426, + CXCursor_ObjCIndependentClass = 427, + CXCursor_ObjCPreciseLifetime = 428, + CXCursor_ObjCReturnsInnerPointer = 429, + CXCursor_ObjCRequiresSuper = 430, + CXCursor_ObjCRootClass = 431, + CXCursor_ObjCSubclassingRestricted = 432, + CXCursor_ObjCExplicitProtocolImpl = 433, + CXCursor_ObjCDesignatedInitializer = 434, + CXCursor_ObjCRuntimeVisible = 435, + CXCursor_ObjCBoxable = 436, + CXCursor_FlagEnum = 437, + CXCursor_ConvergentAttr = 438, + CXCursor_WarnUnusedAttr = 439, + CXCursor_WarnUnusedResultAttr = 440, + CXCursor_AlignedAttr = 441, + CXCursor_LastAttr = CXCursor_AlignedAttr, + + /* Preprocessing */ + CXCursor_PreprocessingDirective = 500, + CXCursor_MacroDefinition = 501, + CXCursor_MacroExpansion = 502, + CXCursor_MacroInstantiation = CXCursor_MacroExpansion, + CXCursor_InclusionDirective = 503, + CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, + CXCursor_LastPreprocessing = CXCursor_InclusionDirective, + + /* Extra Declarations */ + /** + * A module import declaration. + */ + CXCursor_ModuleImportDecl = 600, + CXCursor_TypeAliasTemplateDecl = 601, + /** + * A static_assert or _Static_assert node + */ + CXCursor_StaticAssert = 602, + /** + * a friend declaration. + */ + CXCursor_FriendDecl = 603, + /** + * a concept declaration. + */ + CXCursor_ConceptDecl = 604, + + CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, + CXCursor_LastExtraDecl = CXCursor_ConceptDecl, + + /** + * A code completion overload candidate. + */ + CXCursor_OverloadCandidate = 700 +}; + +/** + * A cursor representing some element in the abstract syntax tree for + * a translation unit. + * + * The cursor abstraction unifies the different kinds of entities in a + * program--declaration, statements, expressions, references to declarations, + * etc.--under a single "cursor" abstraction with a common set of operations. + * Common operation for a cursor include: getting the physical location in + * a source file where the cursor points, getting the name associated with a + * cursor, and retrieving cursors for any child nodes of a particular cursor. + * + * Cursors can be produced in two specific ways. + * clang_getTranslationUnitCursor() produces a cursor for a translation unit, + * from which one can use clang_visitChildren() to explore the rest of the + * translation unit. clang_getCursor() maps from a physical source location + * to the entity that resides at that location, allowing one to map from the + * source code into the AST. + */ +typedef struct { + enum CXCursorKind kind; + int xdata; + const void *data[3]; +} CXCursor; + +/** + * \defgroup CINDEX_CURSOR_MANIP Cursor manipulations + * + * @{ + */ + +/** + * Retrieve the NULL cursor, which represents no entity. + */ +CINDEX_LINKAGE CXCursor clang_getNullCursor(void); + +/** + * Retrieve the cursor that represents the given translation unit. + * + * The translation unit cursor can be used to start traversing the + * various declarations within the given translation unit. + */ +CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); + +/** + * Determine whether two cursors are equivalent. + */ +CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); + +/** + * Returns non-zero if \p cursor is null. + */ +CINDEX_LINKAGE int clang_Cursor_isNull(CXCursor cursor); + +/** + * Compute a hash value for the given cursor. + */ +CINDEX_LINKAGE unsigned clang_hashCursor(CXCursor); + +/** + * Retrieve the kind of the given cursor. + */ +CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); + +/** + * Determine whether the given cursor kind represents a declaration. + */ +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); + +/** + * Determine whether the given declaration is invalid. + * + * A declaration is invalid if it could not be parsed successfully. + * + * \returns non-zero if the cursor represents a declaration and it is + * invalid, otherwise NULL. + */ +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); + +/** + * Determine whether the given cursor kind represents a simple + * reference. + * + * Note that other kinds of cursors (such as expressions) can also refer to + * other cursors. Use clang_getCursorReferenced() to determine whether a + * particular cursor refers to another entity. + */ +CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); + +/** + * Determine whether the given cursor kind represents an expression. + */ +CINDEX_LINKAGE unsigned clang_isExpression(enum CXCursorKind); + +/** + * Determine whether the given cursor kind represents a statement. + */ +CINDEX_LINKAGE unsigned clang_isStatement(enum CXCursorKind); + +/** + * Determine whether the given cursor kind represents an attribute. + */ +CINDEX_LINKAGE unsigned clang_isAttribute(enum CXCursorKind); + +/** + * Determine whether the given cursor has any attributes. + */ +CINDEX_LINKAGE unsigned clang_Cursor_hasAttrs(CXCursor C); + +/** + * Determine whether the given cursor kind represents an invalid + * cursor. + */ +CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); + +/** + * Determine whether the given cursor kind represents a translation + * unit. + */ +CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); + +/*** + * Determine whether the given cursor represents a preprocessing + * element, such as a preprocessor directive or macro instantiation. + */ +CINDEX_LINKAGE unsigned clang_isPreprocessing(enum CXCursorKind); + +/*** + * Determine whether the given cursor represents a currently + * unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). + */ +CINDEX_LINKAGE unsigned clang_isUnexposed(enum CXCursorKind); + +/** + * Describe the linkage of the entity referred to by a cursor. + */ +enum CXLinkageKind { + /** This value indicates that no linkage information is available + * for a provided CXCursor. */ + CXLinkage_Invalid, + /** + * This is the linkage for variables, parameters, and so on that + * have automatic storage. This covers normal (non-extern) local variables. + */ + CXLinkage_NoLinkage, + /** This is the linkage for static variables and static functions. */ + CXLinkage_Internal, + /** This is the linkage for entities with external linkage that live + * in C++ anonymous namespaces.*/ + CXLinkage_UniqueExternal, + /** This is the linkage for entities with true, external linkage. */ + CXLinkage_External +}; + +/** + * Determine the linkage of the entity referred to by a given cursor. + */ +CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); + +enum CXVisibilityKind { + /** This value indicates that no visibility information is available + * for a provided CXCursor. */ + CXVisibility_Invalid, + + /** Symbol not seen by the linker. */ + CXVisibility_Hidden, + /** Symbol seen by the linker but resolves to a symbol inside this object. */ + CXVisibility_Protected, + /** Symbol seen by the linker and acts like a normal symbol. */ + CXVisibility_Default +}; + +/** + * Describe the visibility of the entity referred to by a cursor. + * + * This returns the default visibility if not explicitly specified by + * a visibility attribute. The default visibility may be changed by + * commandline arguments. + * + * \param cursor The cursor to query. + * + * \returns The visibility of the cursor. + */ +CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); + +/** + * Determine the availability of the entity that this cursor refers to, + * taking the current target platform into account. + * + * \param cursor The cursor to query. + * + * \returns The availability of the cursor. + */ +CINDEX_LINKAGE enum CXAvailabilityKind +clang_getCursorAvailability(CXCursor cursor); + +/** + * Describes the availability of a given entity on a particular platform, e.g., + * a particular class might only be available on Mac OS 10.7 or newer. + */ +typedef struct CXPlatformAvailability { + /** + * A string that describes the platform for which this structure + * provides availability information. + * + * Possible values are "ios" or "macos". + */ + CXString Platform; + /** + * The version number in which this entity was introduced. + */ + CXVersion Introduced; + /** + * The version number in which this entity was deprecated (but is + * still available). + */ + CXVersion Deprecated; + /** + * The version number in which this entity was obsoleted, and therefore + * is no longer available. + */ + CXVersion Obsoleted; + /** + * Whether the entity is unconditionally unavailable on this platform. + */ + int Unavailable; + /** + * An optional message to provide to a user of this API, e.g., to + * suggest replacement APIs. + */ + CXString Message; +} CXPlatformAvailability; + +/** + * Determine the availability of the entity that this cursor refers to + * on any platforms for which availability information is known. + * + * \param cursor The cursor to query. + * + * \param always_deprecated If non-NULL, will be set to indicate whether the + * entity is deprecated on all platforms. + * + * \param deprecated_message If non-NULL, will be set to the message text + * provided along with the unconditional deprecation of this entity. The client + * is responsible for deallocating this string. + * + * \param always_unavailable If non-NULL, will be set to indicate whether the + * entity is unavailable on all platforms. + * + * \param unavailable_message If non-NULL, will be set to the message text + * provided along with the unconditional unavailability of this entity. The + * client is responsible for deallocating this string. + * + * \param availability If non-NULL, an array of CXPlatformAvailability instances + * that will be populated with platform availability information, up to either + * the number of platforms for which availability information is available (as + * returned by this function) or \c availability_size, whichever is smaller. + * + * \param availability_size The number of elements available in the + * \c availability array. + * + * \returns The number of platforms (N) for which availability information is + * available (which is unrelated to \c availability_size). + * + * Note that the client is responsible for calling + * \c clang_disposeCXPlatformAvailability to free each of the + * platform-availability structures returned. There are + * \c min(N, availability_size) such structures. + */ +CINDEX_LINKAGE int clang_getCursorPlatformAvailability( + CXCursor cursor, int *always_deprecated, CXString *deprecated_message, + int *always_unavailable, CXString *unavailable_message, + CXPlatformAvailability *availability, int availability_size); + +/** + * Free the memory associated with a \c CXPlatformAvailability structure. + */ +CINDEX_LINKAGE void +clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability); + +/** + * If cursor refers to a variable declaration and it has initializer returns + * cursor referring to the initializer otherwise return null cursor. + */ +CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor); + +/** + * If cursor refers to a variable declaration that has global storage returns 1. + * If cursor refers to a variable declaration that doesn't have global storage + * returns 0. Otherwise returns -1. + */ +CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor); + +/** + * If cursor refers to a variable declaration that has external storage + * returns 1. If cursor refers to a variable declaration that doesn't have + * external storage returns 0. Otherwise returns -1. + */ +CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor); + +/** + * Describe the "language" of the entity referred to by a cursor. + */ +enum CXLanguageKind { + CXLanguage_Invalid = 0, + CXLanguage_C, + CXLanguage_ObjC, + CXLanguage_CPlusPlus +}; + +/** + * Determine the "language" of the entity referred to by a given cursor. + */ +CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); + +/** + * Describe the "thread-local storage (TLS) kind" of the declaration + * referred to by a cursor. + */ +enum CXTLSKind { CXTLS_None = 0, CXTLS_Dynamic, CXTLS_Static }; + +/** + * Determine the "thread-local storage (TLS) kind" of the declaration + * referred to by a cursor. + */ +CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor); + +/** + * Returns the translation unit that a cursor originated from. + */ +CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); + +/** + * A fast container representing a set of CXCursors. + */ +typedef struct CXCursorSetImpl *CXCursorSet; + +/** + * Creates an empty CXCursorSet. + */ +CINDEX_LINKAGE CXCursorSet clang_createCXCursorSet(void); + +/** + * Disposes a CXCursorSet and releases its associated memory. + */ +CINDEX_LINKAGE void clang_disposeCXCursorSet(CXCursorSet cset); + +/** + * Queries a CXCursorSet to see if it contains a specific CXCursor. + * + * \returns non-zero if the set contains the specified cursor. + */ +CINDEX_LINKAGE unsigned clang_CXCursorSet_contains(CXCursorSet cset, + CXCursor cursor); + +/** + * Inserts a CXCursor into a CXCursorSet. + * + * \returns zero if the CXCursor was already in the set, and non-zero otherwise. + */ +CINDEX_LINKAGE unsigned clang_CXCursorSet_insert(CXCursorSet cset, + CXCursor cursor); + +/** + * Determine the semantic parent of the given cursor. + * + * The semantic parent of a cursor is the cursor that semantically contains + * the given \p cursor. For many declarations, the lexical and semantic parents + * are equivalent (the lexical parent is returned by + * \c clang_getCursorLexicalParent()). They diverge when declarations or + * definitions are provided out-of-line. For example: + * + * \code + * class C { + * void f(); + * }; + * + * void C::f() { } + * \endcode + * + * In the out-of-line definition of \c C::f, the semantic parent is + * the class \c C, of which this function is a member. The lexical parent is + * the place where the declaration actually occurs in the source code; in this + * case, the definition occurs in the translation unit. In general, the + * lexical parent for a given entity can change without affecting the semantics + * of the program, and the lexical parent of different declarations of the + * same entity may be different. Changing the semantic parent of a declaration, + * on the other hand, can have a major impact on semantics, and redeclarations + * of a particular entity should all have the same semantic context. + * + * In the example above, both declarations of \c C::f have \c C as their + * semantic context, while the lexical context of the first \c C::f is \c C + * and the lexical context of the second \c C::f is the translation unit. + * + * For global declarations, the semantic parent is the translation unit. + */ +CINDEX_LINKAGE CXCursor clang_getCursorSemanticParent(CXCursor cursor); + +/** + * Determine the lexical parent of the given cursor. + * + * The lexical parent of a cursor is the cursor in which the given \p cursor + * was actually written. For many declarations, the lexical and semantic parents + * are equivalent (the semantic parent is returned by + * \c clang_getCursorSemanticParent()). They diverge when declarations or + * definitions are provided out-of-line. For example: + * + * \code + * class C { + * void f(); + * }; + * + * void C::f() { } + * \endcode + * + * In the out-of-line definition of \c C::f, the semantic parent is + * the class \c C, of which this function is a member. The lexical parent is + * the place where the declaration actually occurs in the source code; in this + * case, the definition occurs in the translation unit. In general, the + * lexical parent for a given entity can change without affecting the semantics + * of the program, and the lexical parent of different declarations of the + * same entity may be different. Changing the semantic parent of a declaration, + * on the other hand, can have a major impact on semantics, and redeclarations + * of a particular entity should all have the same semantic context. + * + * In the example above, both declarations of \c C::f have \c C as their + * semantic context, while the lexical context of the first \c C::f is \c C + * and the lexical context of the second \c C::f is the translation unit. + * + * For declarations written in the global scope, the lexical parent is + * the translation unit. + */ +CINDEX_LINKAGE CXCursor clang_getCursorLexicalParent(CXCursor cursor); + +/** + * Determine the set of methods that are overridden by the given + * method. + * + * In both Objective-C and C++, a method (aka virtual member function, + * in C++) can override a virtual method in a base class. For + * Objective-C, a method is said to override any method in the class's + * base class, its protocols, or its categories' protocols, that has the same + * selector and is of the same kind (class or instance). + * If no such method exists, the search continues to the class's superclass, + * its protocols, and its categories, and so on. A method from an Objective-C + * implementation is considered to override the same methods as its + * corresponding method in the interface. + * + * For C++, a virtual member function overrides any virtual member + * function with the same signature that occurs in its base + * classes. With multiple inheritance, a virtual member function can + * override several virtual member functions coming from different + * base classes. + * + * In all cases, this function determines the immediate overridden + * method, rather than all of the overridden methods. For example, if + * a method is originally declared in a class A, then overridden in B + * (which in inherits from A) and also in C (which inherited from B), + * then the only overridden method returned from this function when + * invoked on C's method will be B's method. The client may then + * invoke this function again, given the previously-found overridden + * methods, to map out the complete method-override set. + * + * \param cursor A cursor representing an Objective-C or C++ + * method. This routine will compute the set of methods that this + * method overrides. + * + * \param overridden A pointer whose pointee will be replaced with a + * pointer to an array of cursors, representing the set of overridden + * methods. If there are no overridden methods, the pointee will be + * set to NULL. The pointee must be freed via a call to + * \c clang_disposeOverriddenCursors(). + * + * \param num_overridden A pointer to the number of overridden + * functions, will be set to the number of overridden functions in the + * array pointed to by \p overridden. + */ +CINDEX_LINKAGE void clang_getOverriddenCursors(CXCursor cursor, + CXCursor **overridden, + unsigned *num_overridden); + +/** + * Free the set of overridden cursors returned by \c + * clang_getOverriddenCursors(). + */ +CINDEX_LINKAGE void clang_disposeOverriddenCursors(CXCursor *overridden); + +/** + * Retrieve the file that is included by the given inclusion directive + * cursor. + */ +CINDEX_LINKAGE CXFile clang_getIncludedFile(CXCursor cursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CURSOR_SOURCE Mapping between cursors and source code + * + * Cursors represent a location within the Abstract Syntax Tree (AST). These + * routines help map between cursors and the physical locations where the + * described entities occur in the source code. The mapping is provided in + * both directions, so one can map from source code to the AST and back. + * + * @{ + */ + +/** + * Map a source location to the cursor that describes the entity at that + * location in the source code. + * + * clang_getCursor() maps an arbitrary source location within a translation + * unit down to the most specific cursor that describes the entity at that + * location. For example, given an expression \c x + y, invoking + * clang_getCursor() with a source location pointing to "x" will return the + * cursor for "x"; similarly for "y". If the cursor points anywhere between + * "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() + * will return a cursor referring to the "+" expression. + * + * \returns a cursor representing the entity at the given source location, or + * a NULL cursor if no such entity can be found. + */ +CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CXSourceLocation); + +/** + * Retrieve the physical location of the source constructor referenced + * by the given cursor. + * + * The location of a declaration is typically the location of the name of that + * declaration, where the name of that declaration would occur if it is + * unnamed, or some keyword that introduces that particular declaration. + * The location of a reference is where that reference occurs within the + * source code. + */ +CINDEX_LINKAGE CXSourceLocation clang_getCursorLocation(CXCursor); + +/** + * Retrieve the physical extent of the source construct referenced by + * the given cursor. + * + * The extent of a cursor starts with the file/line/column pointing at the + * first character within the source construct that the cursor refers to and + * ends with the last character within that source construct. For a + * declaration, the extent covers the declaration itself. For a reference, + * the extent covers the location of the reference (e.g., where the referenced + * entity was actually used). + */ +CINDEX_LINKAGE CXSourceRange clang_getCursorExtent(CXCursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_TYPES Type information for CXCursors + * + * @{ + */ + +/** + * Describes the kind of type + */ +enum CXTypeKind { + /** + * Represents an invalid type (e.g., where no type is available). + */ + CXType_Invalid = 0, + + /** + * A type whose specific kind is not exposed via this + * interface. + */ + CXType_Unexposed = 1, + + /* Builtin types */ + CXType_Void = 2, + CXType_Bool = 3, + CXType_Char_U = 4, + CXType_UChar = 5, + CXType_Char16 = 6, + CXType_Char32 = 7, + CXType_UShort = 8, + CXType_UInt = 9, + CXType_ULong = 10, + CXType_ULongLong = 11, + CXType_UInt128 = 12, + CXType_Char_S = 13, + CXType_SChar = 14, + CXType_WChar = 15, + CXType_Short = 16, + CXType_Int = 17, + CXType_Long = 18, + CXType_LongLong = 19, + CXType_Int128 = 20, + CXType_Float = 21, + CXType_Double = 22, + CXType_LongDouble = 23, + CXType_NullPtr = 24, + CXType_Overload = 25, + CXType_Dependent = 26, + CXType_ObjCId = 27, + CXType_ObjCClass = 28, + CXType_ObjCSel = 29, + CXType_Float128 = 30, + CXType_Half = 31, + CXType_Float16 = 32, + CXType_ShortAccum = 33, + CXType_Accum = 34, + CXType_LongAccum = 35, + CXType_UShortAccum = 36, + CXType_UAccum = 37, + CXType_ULongAccum = 38, + CXType_BFloat16 = 39, + CXType_Ibm128 = 40, + CXType_FirstBuiltin = CXType_Void, + CXType_LastBuiltin = CXType_Ibm128, + + CXType_Complex = 100, + CXType_Pointer = 101, + CXType_BlockPointer = 102, + CXType_LValueReference = 103, + CXType_RValueReference = 104, + CXType_Record = 105, + CXType_Enum = 106, + CXType_Typedef = 107, + CXType_ObjCInterface = 108, + CXType_ObjCObjectPointer = 109, + CXType_FunctionNoProto = 110, + CXType_FunctionProto = 111, + CXType_ConstantArray = 112, + CXType_Vector = 113, + CXType_IncompleteArray = 114, + CXType_VariableArray = 115, + CXType_DependentSizedArray = 116, + CXType_MemberPointer = 117, + CXType_Auto = 118, + + /** + * Represents a type that was referred to using an elaborated type keyword. + * + * E.g., struct S, or via a qualified name, e.g., N::M::type, or both. + */ + CXType_Elaborated = 119, + + /* OpenCL PipeType. */ + CXType_Pipe = 120, + + /* OpenCL builtin types. */ + CXType_OCLImage1dRO = 121, + CXType_OCLImage1dArrayRO = 122, + CXType_OCLImage1dBufferRO = 123, + CXType_OCLImage2dRO = 124, + CXType_OCLImage2dArrayRO = 125, + CXType_OCLImage2dDepthRO = 126, + CXType_OCLImage2dArrayDepthRO = 127, + CXType_OCLImage2dMSAARO = 128, + CXType_OCLImage2dArrayMSAARO = 129, + CXType_OCLImage2dMSAADepthRO = 130, + CXType_OCLImage2dArrayMSAADepthRO = 131, + CXType_OCLImage3dRO = 132, + CXType_OCLImage1dWO = 133, + CXType_OCLImage1dArrayWO = 134, + CXType_OCLImage1dBufferWO = 135, + CXType_OCLImage2dWO = 136, + CXType_OCLImage2dArrayWO = 137, + CXType_OCLImage2dDepthWO = 138, + CXType_OCLImage2dArrayDepthWO = 139, + CXType_OCLImage2dMSAAWO = 140, + CXType_OCLImage2dArrayMSAAWO = 141, + CXType_OCLImage2dMSAADepthWO = 142, + CXType_OCLImage2dArrayMSAADepthWO = 143, + CXType_OCLImage3dWO = 144, + CXType_OCLImage1dRW = 145, + CXType_OCLImage1dArrayRW = 146, + CXType_OCLImage1dBufferRW = 147, + CXType_OCLImage2dRW = 148, + CXType_OCLImage2dArrayRW = 149, + CXType_OCLImage2dDepthRW = 150, + CXType_OCLImage2dArrayDepthRW = 151, + CXType_OCLImage2dMSAARW = 152, + CXType_OCLImage2dArrayMSAARW = 153, + CXType_OCLImage2dMSAADepthRW = 154, + CXType_OCLImage2dArrayMSAADepthRW = 155, + CXType_OCLImage3dRW = 156, + CXType_OCLSampler = 157, + CXType_OCLEvent = 158, + CXType_OCLQueue = 159, + CXType_OCLReserveID = 160, + + CXType_ObjCObject = 161, + CXType_ObjCTypeParam = 162, + CXType_Attributed = 163, + + CXType_OCLIntelSubgroupAVCMcePayload = 164, + CXType_OCLIntelSubgroupAVCImePayload = 165, + CXType_OCLIntelSubgroupAVCRefPayload = 166, + CXType_OCLIntelSubgroupAVCSicPayload = 167, + CXType_OCLIntelSubgroupAVCMceResult = 168, + CXType_OCLIntelSubgroupAVCImeResult = 169, + CXType_OCLIntelSubgroupAVCRefResult = 170, + CXType_OCLIntelSubgroupAVCSicResult = 171, + CXType_OCLIntelSubgroupAVCImeResultSingleReferenceStreamout = 172, + CXType_OCLIntelSubgroupAVCImeResultDualReferenceStreamout = 173, + CXType_OCLIntelSubgroupAVCImeSingleReferenceStreamin = 174, + CXType_OCLIntelSubgroupAVCImeDualReferenceStreamin = 175, + + /* Old aliases for AVC OpenCL extension types. */ + CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172, + CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173, + CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174, + CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175, + + CXType_ExtVector = 176, + CXType_Atomic = 177, + CXType_BTFTagAttributed = 178, + + /* HLSL Types */ + CXType_HLSLResource = 179, + CXType_HLSLAttributedResource = 180, + CXType_HLSLInlineSpirv = 181 +}; + +/** + * Describes the calling convention of a function type + */ +enum CXCallingConv { + CXCallingConv_Default = 0, + CXCallingConv_C = 1, + CXCallingConv_X86StdCall = 2, + CXCallingConv_X86FastCall = 3, + CXCallingConv_X86ThisCall = 4, + CXCallingConv_X86Pascal = 5, + CXCallingConv_AAPCS = 6, + CXCallingConv_AAPCS_VFP = 7, + CXCallingConv_X86RegCall = 8, + CXCallingConv_IntelOclBicc = 9, + CXCallingConv_Win64 = 10, + /* Alias for compatibility with older versions of API. */ + CXCallingConv_X86_64Win64 = CXCallingConv_Win64, + CXCallingConv_X86_64SysV = 11, + CXCallingConv_X86VectorCall = 12, + CXCallingConv_Swift = 13, + CXCallingConv_PreserveMost = 14, + CXCallingConv_PreserveAll = 15, + CXCallingConv_AArch64VectorCall = 16, + CXCallingConv_SwiftAsync = 17, + CXCallingConv_AArch64SVEPCS = 18, + CXCallingConv_M68kRTD = 19, + CXCallingConv_PreserveNone = 20, + CXCallingConv_RISCVVectorCall = 21, + CXCallingConv_RISCVVLSCall_32 = 22, + CXCallingConv_RISCVVLSCall_64 = 23, + CXCallingConv_RISCVVLSCall_128 = 24, + CXCallingConv_RISCVVLSCall_256 = 25, + CXCallingConv_RISCVVLSCall_512 = 26, + CXCallingConv_RISCVVLSCall_1024 = 27, + CXCallingConv_RISCVVLSCall_2048 = 28, + CXCallingConv_RISCVVLSCall_4096 = 29, + CXCallingConv_RISCVVLSCall_8192 = 30, + CXCallingConv_RISCVVLSCall_16384 = 31, + CXCallingConv_RISCVVLSCall_32768 = 32, + CXCallingConv_RISCVVLSCall_65536 = 33, + + CXCallingConv_Invalid = 100, + CXCallingConv_Unexposed = 200 +}; + +/** + * The type of an element in the abstract syntax tree. + * + */ +typedef struct { + enum CXTypeKind kind; + void *data[2]; +} CXType; + +/** + * Retrieve the type of a CXCursor (if any). + */ +CINDEX_LINKAGE CXType clang_getCursorType(CXCursor C); + +/** + * Pretty-print the underlying type using the rules of the + * language of the translation unit from which it came. + * + * If the type is invalid, an empty string is returned. + */ +CINDEX_LINKAGE CXString clang_getTypeSpelling(CXType CT); + +/** + * Retrieve the underlying type of a typedef declaration. + * + * If the cursor does not reference a typedef declaration, an invalid type is + * returned. + */ +CINDEX_LINKAGE CXType clang_getTypedefDeclUnderlyingType(CXCursor C); + +/** + * Retrieve the integer type of an enum declaration. + * + * If the cursor does not reference an enum declaration, an invalid type is + * returned. + */ +CINDEX_LINKAGE CXType clang_getEnumDeclIntegerType(CXCursor C); + +/** + * Retrieve the integer value of an enum constant declaration as a signed + * long long. + * + * If the cursor does not reference an enum constant declaration, LLONG_MIN is + * returned. Since this is also potentially a valid constant value, the kind of + * the cursor must be verified before calling this function. + */ +CINDEX_LINKAGE long long clang_getEnumConstantDeclValue(CXCursor C); + +/** + * Retrieve the integer value of an enum constant declaration as an unsigned + * long long. + * + * If the cursor does not reference an enum constant declaration, ULLONG_MAX is + * returned. Since this is also potentially a valid constant value, the kind of + * the cursor must be verified before calling this function. + */ +CINDEX_LINKAGE unsigned long long +clang_getEnumConstantDeclUnsignedValue(CXCursor C); + +/** + * Returns non-zero if the cursor specifies a Record member that is a bit-field. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isBitField(CXCursor C); + +/** + * Retrieve the bit width of a bit-field declaration as an integer. + * + * If the cursor does not reference a bit-field, or if the bit-field's width + * expression cannot be evaluated, -1 is returned. + * + * For example: + * \code + * if (clang_Cursor_isBitField(Cursor)) { + * int Width = clang_getFieldDeclBitWidth(Cursor); + * if (Width != -1) { + * // The bit-field width is not value-dependent. + * } + * } + * \endcode + */ +CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C); + +/** + * Retrieve the number of non-variadic arguments associated with a given + * cursor. + * + * The number of arguments can be determined for calls as well as for + * declarations of functions or methods. For other cursors -1 is returned. + */ +CINDEX_LINKAGE int clang_Cursor_getNumArguments(CXCursor C); + +/** + * Retrieve the argument cursor of a function or method. + * + * The argument cursor can be determined for calls as well as for declarations + * of functions or methods. For other cursors and for invalid indices, an + * invalid cursor is returned. + */ +CINDEX_LINKAGE CXCursor clang_Cursor_getArgument(CXCursor C, unsigned i); + +/** + * Describes the kind of a template argument. + * + * See the definition of llvm::clang::TemplateArgument::ArgKind for full + * element descriptions. + */ +enum CXTemplateArgumentKind { + CXTemplateArgumentKind_Null, + CXTemplateArgumentKind_Type, + CXTemplateArgumentKind_Declaration, + CXTemplateArgumentKind_NullPtr, + CXTemplateArgumentKind_Integral, + CXTemplateArgumentKind_Template, + CXTemplateArgumentKind_TemplateExpansion, + CXTemplateArgumentKind_Expression, + CXTemplateArgumentKind_Pack, + /* Indicates an error case, preventing the kind from being deduced. */ + CXTemplateArgumentKind_Invalid +}; + +/** + * Returns the number of template args of a function, struct, or class decl + * representing a template specialization. + * + * If the argument cursor cannot be converted into a template function + * declaration, -1 is returned. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * The value 3 would be returned from this call. + */ +CINDEX_LINKAGE int clang_Cursor_getNumTemplateArguments(CXCursor C); + +/** + * Retrieve the kind of the I'th template argument of the CXCursor C. + * + * If the argument CXCursor does not represent a FunctionDecl, StructDecl, or + * ClassTemplatePartialSpecialization, an invalid template argument kind is + * returned. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * For I = 0, 1, and 2, Type, Integral, and Integral will be returned, + * respectively. + */ +CINDEX_LINKAGE enum CXTemplateArgumentKind +clang_Cursor_getTemplateArgumentKind(CXCursor C, unsigned I); + +/** + * Retrieve a CXType representing the type of a TemplateArgument of a + * function decl representing a template specialization. + * + * If the argument CXCursor does not represent a FunctionDecl, StructDecl, + * ClassDecl or ClassTemplatePartialSpecialization whose I'th template argument + * has a kind of CXTemplateArgKind_Integral, an invalid type is returned. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * If called with I = 0, "float", will be returned. + * Invalid types will be returned for I == 1 or 2. + */ +CINDEX_LINKAGE CXType clang_Cursor_getTemplateArgumentType(CXCursor C, + unsigned I); + +/** + * Retrieve the value of an Integral TemplateArgument (of a function + * decl representing a template specialization) as a signed long long. + * + * It is undefined to call this function on a CXCursor that does not represent a + * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization + * whose I'th template argument is not an integral value. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * If called with I = 1 or 2, -7 or true will be returned, respectively. + * For I == 0, this function's behavior is undefined. + */ +CINDEX_LINKAGE long long clang_Cursor_getTemplateArgumentValue(CXCursor C, + unsigned I); + +/** + * Retrieve the value of an Integral TemplateArgument (of a function + * decl representing a template specialization) as an unsigned long long. + * + * It is undefined to call this function on a CXCursor that does not represent a + * FunctionDecl, StructDecl, ClassDecl or ClassTemplatePartialSpecialization or + * whose I'th template argument is not an integral value. + * + * For example, for the following declaration and specialization: + * template + * void foo() { ... } + * + * template <> + * void foo(); + * + * If called with I = 1 or 2, 2147483649 or true will be returned, respectively. + * For I == 0, this function's behavior is undefined. + */ +CINDEX_LINKAGE unsigned long long +clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, unsigned I); + +/** + * Determine whether two CXTypes represent the same type. + * + * \returns non-zero if the CXTypes represent the same type and + * zero otherwise. + */ +CINDEX_LINKAGE unsigned clang_equalTypes(CXType A, CXType B); + +/** + * Return the canonical type for a CXType. + * + * Clang's type system explicitly models typedefs and all the ways + * a specific type can be represented. The canonical type is the underlying + * type with all the "sugar" removed. For example, if 'T' is a typedef + * for 'int', the canonical type for 'T' would be 'int'. + */ +CINDEX_LINKAGE CXType clang_getCanonicalType(CXType T); + +/** + * Determine whether a CXType has the "const" qualifier set, + * without looking through typedefs that may have added "const" at a + * different level. + */ +CINDEX_LINKAGE unsigned clang_isConstQualifiedType(CXType T); + +/** + * Determine whether a CXCursor that is a macro, is + * function like. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isMacroFunctionLike(CXCursor C); + +/** + * Determine whether a CXCursor that is a macro, is a + * builtin one. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isMacroBuiltin(CXCursor C); + +/** + * Determine whether a CXCursor that is a function declaration, is an + * inline declaration. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isFunctionInlined(CXCursor C); + +/** + * Determine whether a CXType has the "volatile" qualifier set, + * without looking through typedefs that may have added "volatile" at + * a different level. + */ +CINDEX_LINKAGE unsigned clang_isVolatileQualifiedType(CXType T); + +/** + * Determine whether a CXType has the "restrict" qualifier set, + * without looking through typedefs that may have added "restrict" at a + * different level. + */ +CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T); + +/** + * Returns the address space of the given type. + */ +CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T); + +/** + * Returns the typedef name of the given type. + */ +CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT); + +/** + * For pointer types, returns the type of the pointee. + */ +CINDEX_LINKAGE CXType clang_getPointeeType(CXType T); + +/** + * Retrieve the unqualified variant of the given type, removing as + * little sugar as possible. + * + * For example, given the following series of typedefs: + * + * \code + * typedef int Integer; + * typedef const Integer CInteger; + * typedef CInteger DifferenceType; + * \endcode + * + * Executing \c clang_getUnqualifiedType() on a \c CXType that + * represents \c DifferenceType, will desugar to a type representing + * \c Integer, that has no qualifiers. + * + * And, executing \c clang_getUnqualifiedType() on the type of the + * first argument of the following function declaration: + * + * \code + * void foo(const int); + * \endcode + * + * Will return a type representing \c int, removing the \c const + * qualifier. + * + * Sugar over array types is not desugared. + * + * A type can be checked for qualifiers with \c + * clang_isConstQualifiedType(), \c clang_isVolatileQualifiedType() + * and \c clang_isRestrictQualifiedType(). + * + * A type that resulted from a call to \c clang_getUnqualifiedType + * will return \c false for all of the above calls. + */ +CINDEX_LINKAGE CXType clang_getUnqualifiedType(CXType CT); + +/** + * For reference types (e.g., "const int&"), returns the type that the + * reference refers to (e.g "const int"). + * + * Otherwise, returns the type itself. + * + * A type that has kind \c CXType_LValueReference or + * \c CXType_RValueReference is a reference type. + */ +CINDEX_LINKAGE CXType clang_getNonReferenceType(CXType CT); + +/** + * Return the cursor for the declaration of the given type. + */ +CINDEX_LINKAGE CXCursor clang_getTypeDeclaration(CXType T); + +/** + * Returns the Objective-C type encoding for the specified declaration. + */ +CINDEX_LINKAGE CXString clang_getDeclObjCTypeEncoding(CXCursor C); + +/** + * Returns the Objective-C type encoding for the specified CXType. + */ +CINDEX_LINKAGE CXString clang_Type_getObjCEncoding(CXType type); + +/** + * Retrieve the spelling of a given CXTypeKind. + */ +CINDEX_LINKAGE CXString clang_getTypeKindSpelling(enum CXTypeKind K); + +/** + * Retrieve the calling convention associated with a function type. + * + * If a non-function type is passed in, CXCallingConv_Invalid is returned. + */ +CINDEX_LINKAGE enum CXCallingConv clang_getFunctionTypeCallingConv(CXType T); + +/** + * Retrieve the return type associated with a function type. + * + * If a non-function type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getResultType(CXType T); + +/** + * Retrieve the exception specification type associated with a function type. + * This is a value of type CXCursor_ExceptionSpecificationKind. + * + * If a non-function type is passed in, an error code of -1 is returned. + */ +CINDEX_LINKAGE int clang_getExceptionSpecificationType(CXType T); + +/** + * Retrieve the number of non-variadic parameters associated with a + * function type. + * + * If a non-function type is passed in, -1 is returned. + */ +CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); + +/** + * Retrieve the type of a parameter of a function type. + * + * If a non-function type is passed in or the function does not have enough + * parameters, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getArgType(CXType T, unsigned i); + +/** + * Retrieves the base type of the ObjCObjectType. + * + * If the type is not an ObjC object, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getObjCObjectBaseType(CXType T); + +/** + * Retrieve the number of protocol references associated with an ObjC object/id. + * + * If the type is not an ObjC object, 0 is returned. + */ +CINDEX_LINKAGE unsigned clang_Type_getNumObjCProtocolRefs(CXType T); + +/** + * Retrieve the decl for a protocol reference for an ObjC object/id. + * + * If the type is not an ObjC object or there are not enough protocol + * references, an invalid cursor is returned. + */ +CINDEX_LINKAGE CXCursor clang_Type_getObjCProtocolDecl(CXType T, unsigned i); + +/** + * Retrieve the number of type arguments associated with an ObjC object. + * + * If the type is not an ObjC object, 0 is returned. + */ +CINDEX_LINKAGE unsigned clang_Type_getNumObjCTypeArgs(CXType T); + +/** + * Retrieve a type argument associated with an ObjC object. + * + * If the type is not an ObjC or the index is not valid, + * an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getObjCTypeArg(CXType T, unsigned i); + +/** + * Return 1 if the CXType is a variadic function type, and 0 otherwise. + */ +CINDEX_LINKAGE unsigned clang_isFunctionTypeVariadic(CXType T); + +/** + * Retrieve the return type associated with a given cursor. + * + * This only returns a valid type if the cursor refers to a function or method. + */ +CINDEX_LINKAGE CXType clang_getCursorResultType(CXCursor C); + +/** + * Retrieve the exception specification type associated with a given cursor. + * This is a value of type CXCursor_ExceptionSpecificationKind. + * + * This only returns a valid result if the cursor refers to a function or + * method. + */ +CINDEX_LINKAGE int clang_getCursorExceptionSpecificationType(CXCursor C); + +/** + * Return 1 if the CXType is a POD (plain old data) type, and 0 + * otherwise. + */ +CINDEX_LINKAGE unsigned clang_isPODType(CXType T); + +/** + * Return the element type of an array, complex, or vector type. + * + * If a type is passed in that is not an array, complex, or vector type, + * an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getElementType(CXType T); + +/** + * Return the number of elements of an array or vector type. + * + * If a type is passed in that is not an array or vector type, + * -1 is returned. + */ +CINDEX_LINKAGE long long clang_getNumElements(CXType T); + +/** + * Return the element type of an array type. + * + * If a non-array type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_getArrayElementType(CXType T); + +/** + * Return the array size of a constant array. + * + * If a non-array type is passed in, -1 is returned. + */ +CINDEX_LINKAGE long long clang_getArraySize(CXType T); + +/** + * Retrieve the type named by the qualified-id. + * + * If a non-elaborated type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T); + +/** + * Determine if a typedef is 'transparent' tag. + * + * A typedef is considered 'transparent' if it shares a name and spelling + * location with its underlying tag type, as is the case with the NS_ENUM macro. + * + * \returns non-zero if transparent and zero otherwise. + */ +CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T); + +enum CXTypeNullabilityKind { + /** + * Values of this type can never be null. + */ + CXTypeNullability_NonNull = 0, + /** + * Values of this type can be null. + */ + CXTypeNullability_Nullable = 1, + /** + * Whether values of this type can be null is (explicitly) + * unspecified. This captures a (fairly rare) case where we + * can't conclude anything about the nullability of the type even + * though it has been considered. + */ + CXTypeNullability_Unspecified = 2, + /** + * Nullability is not applicable to this type. + */ + CXTypeNullability_Invalid = 3, + + /** + * Generally behaves like Nullable, except when used in a block parameter that + * was imported into a swift async method. There, swift will assume that the + * parameter can get null even if no error occurred. _Nullable parameters are + * assumed to only get null on error. + */ + CXTypeNullability_NullableResult = 4 +}; + +/** + * Retrieve the nullability kind of a pointer type. + */ +CINDEX_LINKAGE enum CXTypeNullabilityKind clang_Type_getNullability(CXType T); + +/** + * List the possible error codes for \c clang_Type_getSizeOf, + * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf, + * \c clang_Cursor_getOffsetOf, and \c clang_getOffsetOfBase. + * + * A value of this enumeration type can be returned if the target type is not + * a valid argument to sizeof, alignof or offsetof. + */ +enum CXTypeLayoutError { + /** + * Type is of kind CXType_Invalid. + */ + CXTypeLayoutError_Invalid = -1, + /** + * The type is an incomplete Type. + */ + CXTypeLayoutError_Incomplete = -2, + /** + * The type is a dependent Type. + */ + CXTypeLayoutError_Dependent = -3, + /** + * The type is not a constant size type. + */ + CXTypeLayoutError_NotConstantSize = -4, + /** + * The Field name is not valid for this record. + */ + CXTypeLayoutError_InvalidFieldName = -5, + /** + * The type is undeduced. + */ + CXTypeLayoutError_Undeduced = -6 +}; + +/** + * Return the alignment of a type in bytes as per C++[expr.alignof] + * standard. + * + * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + * is returned. + * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + * returned. + * If the type declaration is not a constant size type, + * CXTypeLayoutError_NotConstantSize is returned. + */ +CINDEX_LINKAGE long long clang_Type_getAlignOf(CXType T); + +/** + * Return the class type of an member pointer type. + * + * If a non-member-pointer type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getClassType(CXType T); + +/** + * Return the size of a type in bytes as per C++[expr.sizeof] standard. + * + * If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + * If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + * is returned. + * If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + * returned. + */ +CINDEX_LINKAGE long long clang_Type_getSizeOf(CXType T); + +/** + * Return the offset of a field named S in a record of type T in bits + * as it would be returned by __offsetof__ as per C++11[18.2p4] + * + * If the cursor is not a record field declaration, CXTypeLayoutError_Invalid + * is returned. + * If the field's type declaration is an incomplete type, + * CXTypeLayoutError_Incomplete is returned. + * If the field's type declaration is a dependent type, + * CXTypeLayoutError_Dependent is returned. + * If the field's name S is not found, + * CXTypeLayoutError_InvalidFieldName is returned. + */ +CINDEX_LINKAGE long long clang_Type_getOffsetOf(CXType T, const char *S); + +/** + * Return the type that was modified by this attributed type. + * + * If the type is not an attributed type, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getModifiedType(CXType T); + +/** + * Gets the type contained by this atomic type. + * + * If a non-atomic type is passed in, an invalid type is returned. + */ +CINDEX_LINKAGE CXType clang_Type_getValueType(CXType CT); + +/** + * Return the offset of the field represented by the Cursor. + * + * If the cursor is not a field declaration, -1 is returned. + * If the cursor semantic parent is not a record field declaration, + * CXTypeLayoutError_Invalid is returned. + * If the field's type declaration is an incomplete type, + * CXTypeLayoutError_Incomplete is returned. + * If the field's type declaration is a dependent type, + * CXTypeLayoutError_Dependent is returned. + * If the field's name S is not found, + * CXTypeLayoutError_InvalidFieldName is returned. + */ +CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C); + +/** + * Determine whether the given cursor represents an anonymous + * tag or namespace + */ +CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); + +/** + * Determine whether the given cursor represents an anonymous record + * declaration. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C); + +/** + * Determine whether the given cursor represents an inline namespace + * declaration. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C); + +enum CXRefQualifierKind { + /** No ref-qualifier was provided. */ + CXRefQualifier_None = 0, + /** An lvalue ref-qualifier was provided (\c &). */ + CXRefQualifier_LValue, + /** An rvalue ref-qualifier was provided (\c &&). */ + CXRefQualifier_RValue +}; + +/** + * Returns the number of template arguments for given template + * specialization, or -1 if type \c T is not a template specialization. + */ +CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T); + +/** + * Returns the type template argument of a template class specialization + * at given index. + * + * This function only returns template type arguments and does not handle + * template template arguments or variadic packs. + */ +CINDEX_LINKAGE CXType clang_Type_getTemplateArgumentAsType(CXType T, + unsigned i); + +/** + * Retrieve the ref-qualifier kind of a function or method. + * + * The ref-qualifier is returned for C++ functions or methods. For other types + * or non-C++ declarations, CXRefQualifier_None is returned. + */ +CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T); + +/** + * Returns 1 if the base class specified by the cursor with kind + * CX_CXXBaseSpecifier is virtual. + */ +CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); + +/** + * Returns the offset in bits of a CX_CXXBaseSpecifier relative to the parent + * class. + * + * Returns a small negative number if the offset cannot be computed. See + * CXTypeLayoutError for error codes. + */ +CINDEX_LINKAGE long long clang_getOffsetOfBase(CXCursor Parent, CXCursor Base); + +/** + * Represents the C++ access control level to a base class for a + * cursor with kind CX_CXXBaseSpecifier. + */ +enum CX_CXXAccessSpecifier { + CX_CXXInvalidAccessSpecifier, + CX_CXXPublic, + CX_CXXProtected, + CX_CXXPrivate +}; + +/** + * Returns the access control level for the referenced object. + * + * If the cursor refers to a C++ declaration, its access control level within + * its parent scope is returned. Otherwise, if the cursor refers to a base + * specifier or access specifier, the specifier itself is returned. + */ +CINDEX_LINKAGE enum CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor); + +/** + * Represents the storage classes as declared in the source. CX_SC_Invalid + * was added for the case that the passed cursor in not a declaration. + */ +enum CX_StorageClass { + CX_SC_Invalid, + CX_SC_None, + CX_SC_Extern, + CX_SC_Static, + CX_SC_PrivateExtern, + CX_SC_OpenCLWorkGroupLocal, + CX_SC_Auto, + CX_SC_Register +}; + +/** + * Represents a specific kind of binary operator which can appear at a cursor. + */ +enum CX_BinaryOperatorKind { + CX_BO_Invalid = 0, + CX_BO_PtrMemD = 1, + CX_BO_PtrMemI = 2, + CX_BO_Mul = 3, + CX_BO_Div = 4, + CX_BO_Rem = 5, + CX_BO_Add = 6, + CX_BO_Sub = 7, + CX_BO_Shl = 8, + CX_BO_Shr = 9, + CX_BO_Cmp = 10, + CX_BO_LT = 11, + CX_BO_GT = 12, + CX_BO_LE = 13, + CX_BO_GE = 14, + CX_BO_EQ = 15, + CX_BO_NE = 16, + CX_BO_And = 17, + CX_BO_Xor = 18, + CX_BO_Or = 19, + CX_BO_LAnd = 20, + CX_BO_LOr = 21, + CX_BO_Assign = 22, + CX_BO_MulAssign = 23, + CX_BO_DivAssign = 24, + CX_BO_RemAssign = 25, + CX_BO_AddAssign = 26, + CX_BO_SubAssign = 27, + CX_BO_ShlAssign = 28, + CX_BO_ShrAssign = 29, + CX_BO_AndAssign = 30, + CX_BO_XorAssign = 31, + CX_BO_OrAssign = 32, + CX_BO_Comma = 33, + CX_BO_LAST = CX_BO_Comma +}; + +/** + * \brief Returns the operator code for the binary operator. + * + * @deprecated: use clang_getCursorBinaryOperatorKind instead. + */ +CINDEX_LINKAGE enum CX_BinaryOperatorKind +clang_Cursor_getBinaryOpcode(CXCursor C); + +/** + * \brief Returns a string containing the spelling of the binary operator. + * + * @deprecated: use clang_getBinaryOperatorKindSpelling instead + */ +CINDEX_LINKAGE CXString +clang_Cursor_getBinaryOpcodeStr(enum CX_BinaryOperatorKind Op); + +/** + * Returns the storage class for a function or variable declaration. + * + * If the passed in Cursor is not a function or variable declaration, + * CX_SC_Invalid is returned else the storage class. + */ +CINDEX_LINKAGE enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor); + +/** + * Determine the number of overloaded declarations referenced by a + * \c CXCursor_OverloadedDeclRef cursor. + * + * \param cursor The cursor whose overloaded declarations are being queried. + * + * \returns The number of overloaded declarations referenced by \c cursor. If it + * is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. + */ +CINDEX_LINKAGE unsigned clang_getNumOverloadedDecls(CXCursor cursor); + +/** + * Retrieve a cursor for one of the overloaded declarations referenced + * by a \c CXCursor_OverloadedDeclRef cursor. + * + * \param cursor The cursor whose overloaded declarations are being queried. + * + * \param index The zero-based index into the set of overloaded declarations in + * the cursor. + * + * \returns A cursor representing the declaration referenced by the given + * \c cursor at the specified \c index. If the cursor does not have an + * associated set of overloaded declarations, or if the index is out of bounds, + * returns \c clang_getNullCursor(); + */ +CINDEX_LINKAGE CXCursor clang_getOverloadedDecl(CXCursor cursor, + unsigned index); + +/** + * @} + */ + +/** + * \defgroup CINDEX_ATTRIBUTES Information for attributes + * + * @{ + */ + +/** + * For cursors representing an iboutletcollection attribute, + * this function returns the collection element type. + * + */ +CINDEX_LINKAGE CXType clang_getIBOutletCollectionType(CXCursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CURSOR_TRAVERSAL Traversing the AST with cursors + * + * These routines provide the ability to traverse the abstract syntax tree + * using cursors. + * + * @{ + */ + +/** + * Describes how the traversal of the children of a particular + * cursor should proceed after visiting a particular child cursor. + * + * A value of this enumeration type should be returned by each + * \c CXCursorVisitor to indicate how clang_visitChildren() proceed. + */ +enum CXChildVisitResult { + /** + * Terminates the cursor traversal. + */ + CXChildVisit_Break, + /** + * Continues the cursor traversal with the next sibling of + * the cursor just visited, without visiting its children. + */ + CXChildVisit_Continue, + /** + * Recursively traverse the children of this cursor, using + * the same visitor and client data. + */ + CXChildVisit_Recurse +}; + +/** + * Visitor invoked for each cursor found by a traversal. + * + * This visitor function will be invoked for each cursor found by + * clang_visitCursorChildren(). Its first argument is the cursor being + * visited, its second argument is the parent visitor for that cursor, + * and its third argument is the client data provided to + * clang_visitCursorChildren(). + * + * The visitor should return one of the \c CXChildVisitResult values + * to direct clang_visitCursorChildren(). + */ +typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor, + CXCursor parent, + CXClientData client_data); + +/** + * Visit the children of a particular cursor. + * + * This function visits all the direct children of the given cursor, + * invoking the given \p visitor function with the cursors of each + * visited child. The traversal may be recursive, if the visitor returns + * \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if + * the visitor returns \c CXChildVisit_Break. + * + * \param parent the cursor whose child may be visited. All kinds of + * cursors can be visited, including invalid cursors (which, by + * definition, have no children). + * + * \param visitor the visitor function that will be invoked for each + * child of \p parent. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the visitor each time it is invoked. + * + * \returns a non-zero value if the traversal was terminated + * prematurely by the visitor returning \c CXChildVisit_Break. + */ +CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent, + CXCursorVisitor visitor, + CXClientData client_data); +/** + * Visitor invoked for each cursor found by a traversal. + * + * This visitor block will be invoked for each cursor found by + * clang_visitChildrenWithBlock(). Its first argument is the cursor being + * visited, its second argument is the parent visitor for that cursor. + * + * The visitor should return one of the \c CXChildVisitResult values + * to direct clang_visitChildrenWithBlock(). + */ +#if __has_feature(blocks) +typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor, + CXCursor parent); +#else +typedef struct _CXChildVisitResult *CXCursorVisitorBlock; +#endif + +/** + * Visits the children of a cursor using the specified block. Behaves + * identically to clang_visitChildren() in all other respects. + */ +CINDEX_LINKAGE unsigned +clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CURSOR_XREF Cross-referencing in the AST + * + * These routines provide the ability to determine references within and + * across translation units, by providing the names of the entities referenced + * by cursors, follow reference cursors to the declarations they reference, + * and associate declarations with their definitions. + * + * @{ + */ + +/** + * Retrieve a Unified Symbol Resolution (USR) for the entity referenced + * by the given cursor. + * + * A Unified Symbol Resolution (USR) is a string that identifies a particular + * entity (function, class, variable, etc.) within a program. USRs can be + * compared across translation units to determine, e.g., when references in + * one translation refer to an entity defined in another translation unit. + */ +CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); + +/** + * Construct a USR for a specified Objective-C class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCClass(const char *class_name); + +/** + * Construct a USR for a specified Objective-C category. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCCategory( + const char *class_name, const char *category_name); + +/** + * Construct a USR for a specified Objective-C protocol. + */ +CINDEX_LINKAGE CXString +clang_constructUSR_ObjCProtocol(const char *protocol_name); + +/** + * Construct a USR for a specified Objective-C instance variable and + * the USR for its containing class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCIvar(const char *name, + CXString classUSR); + +/** + * Construct a USR for a specified Objective-C method and + * the USR for its containing class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCMethod(const char *name, + unsigned isInstanceMethod, + CXString classUSR); + +/** + * Construct a USR for a specified Objective-C property and the USR + * for its containing class. + */ +CINDEX_LINKAGE CXString clang_constructUSR_ObjCProperty(const char *property, + CXString classUSR); + +/** + * Retrieve a name for the entity referenced by this cursor. + */ +CINDEX_LINKAGE CXString clang_getCursorSpelling(CXCursor); + +/** + * Retrieve a range for a piece that forms the cursors spelling name. + * Most of the times there is only one range for the complete spelling but for + * Objective-C methods and Objective-C message expressions, there are multiple + * pieces for each selector identifier. + * + * \param pieceIndex the index of the spelling name piece. If this is greater + * than the actual number of pieces, it will return a NULL (invalid) range. + * + * \param options Reserved. + */ +CINDEX_LINKAGE CXSourceRange clang_Cursor_getSpellingNameRange( + CXCursor, unsigned pieceIndex, unsigned options); + +/** + * Opaque pointer representing a policy that controls pretty printing + * for \c clang_getCursorPrettyPrinted. + */ +typedef void *CXPrintingPolicy; + +/** + * Properties for the printing policy. + * + * See \c clang::PrintingPolicy for more information. + */ +enum CXPrintingPolicyProperty { + CXPrintingPolicy_Indentation, + CXPrintingPolicy_SuppressSpecifiers, + CXPrintingPolicy_SuppressTagKeyword, + CXPrintingPolicy_IncludeTagDefinition, + CXPrintingPolicy_SuppressScope, + CXPrintingPolicy_SuppressUnwrittenScope, + CXPrintingPolicy_SuppressInitializers, + CXPrintingPolicy_ConstantArraySizeAsWritten, + CXPrintingPolicy_AnonymousTagLocations, + CXPrintingPolicy_SuppressStrongLifetime, + CXPrintingPolicy_SuppressLifetimeQualifiers, + CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + CXPrintingPolicy_Bool, + CXPrintingPolicy_Restrict, + CXPrintingPolicy_Alignof, + CXPrintingPolicy_UnderscoreAlignof, + CXPrintingPolicy_UseVoidForZeroParams, + CXPrintingPolicy_TerseOutput, + CXPrintingPolicy_PolishForDeclaration, + CXPrintingPolicy_Half, + CXPrintingPolicy_MSWChar, + CXPrintingPolicy_IncludeNewlines, + CXPrintingPolicy_MSVCFormatting, + CXPrintingPolicy_ConstantsAsWritten, + CXPrintingPolicy_SuppressImplicitBase, + CXPrintingPolicy_FullyQualifiedName, + + CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName +}; + +/** + * Get a property value for the given printing policy. + */ +CINDEX_LINKAGE unsigned +clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy, + enum CXPrintingPolicyProperty Property); + +/** + * Set a property value for the given printing policy. + */ +CINDEX_LINKAGE void +clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, + enum CXPrintingPolicyProperty Property, + unsigned Value); + +/** + * Retrieve the default policy for the cursor. + * + * The policy should be released after use with \c + * clang_PrintingPolicy_dispose. + */ +CINDEX_LINKAGE CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor); + +/** + * Release a printing policy. + */ +CINDEX_LINKAGE void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy); + +/** + * Pretty print declarations. + * + * \param Cursor The cursor representing a declaration. + * + * \param Policy The policy to control the entities being printed. If + * NULL, a default policy is used. + * + * \returns The pretty printed declaration or the empty string for + * other cursors. + */ +CINDEX_LINKAGE CXString clang_getCursorPrettyPrinted(CXCursor Cursor, + CXPrintingPolicy Policy); + +/** + * Pretty-print the underlying type using a custom printing policy. + * + * If the type is invalid, an empty string is returned. + */ +CINDEX_LINKAGE CXString clang_getTypePrettyPrinted(CXType CT, + CXPrintingPolicy cxPolicy); + +/** + * Get the fully qualified name for a type. + * + * This includes full qualification of all template parameters. + * + * Policy - Further refine the type formatting + * WithGlobalNsPrefix - If non-zero, function will prepend a '::' to qualified + * names + */ +CINDEX_LINKAGE CXString clang_getFullyQualifiedName( + CXType CT, CXPrintingPolicy Policy, unsigned WithGlobalNsPrefix); + +/** + * Retrieve the display name for the entity referenced by this cursor. + * + * The display name contains extra information that helps identify the cursor, + * such as the parameters of a function or template or the arguments of a + * class template specialization. + */ +CINDEX_LINKAGE CXString clang_getCursorDisplayName(CXCursor); + +/** For a cursor that is a reference, retrieve a cursor representing the + * entity that it references. + * + * Reference cursors refer to other entities in the AST. For example, an + * Objective-C superclass reference cursor refers to an Objective-C class. + * This function produces the cursor for the Objective-C class from the + * cursor for the superclass reference. If the input cursor is a declaration or + * definition, it returns that declaration or definition unchanged. + * Otherwise, returns the NULL cursor. + */ +CINDEX_LINKAGE CXCursor clang_getCursorReferenced(CXCursor); + +/** + * For a cursor that is either a reference to or a declaration + * of some entity, retrieve a cursor that describes the definition of + * that entity. + * + * Some entities can be declared multiple times within a translation + * unit, but only one of those declarations can also be a + * definition. For example, given: + * + * \code + * int f(int, int); + * int g(int x, int y) { return f(x, y); } + * int f(int a, int b) { return a + b; } + * int f(int, int); + * \endcode + * + * there are three declarations of the function "f", but only the + * second one is a definition. The clang_getCursorDefinition() + * function will take any cursor pointing to a declaration of "f" + * (the first or fourth lines of the example) or a cursor referenced + * that uses "f" (the call to "f' inside "g") and will return a + * declaration cursor pointing to the definition (the second "f" + * declaration). + * + * If given a cursor for which there is no corresponding definition, + * e.g., because there is no definition of that entity within this + * translation unit, returns a NULL cursor. + */ +CINDEX_LINKAGE CXCursor clang_getCursorDefinition(CXCursor); + +/** + * Determine whether the declaration pointed to by this cursor + * is also a definition of that entity. + */ +CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor); + +/** + * Retrieve the canonical cursor corresponding to the given cursor. + * + * In the C family of languages, many kinds of entities can be declared several + * times within a single translation unit. For example, a structure type can + * be forward-declared (possibly multiple times) and later defined: + * + * \code + * struct X; + * struct X; + * struct X { + * int member; + * }; + * \endcode + * + * The declarations and the definition of \c X are represented by three + * different cursors, all of which are declarations of the same underlying + * entity. One of these cursor is considered the "canonical" cursor, which + * is effectively the representative for the underlying entity. One can + * determine if two cursors are declarations of the same underlying entity by + * comparing their canonical cursors. + * + * \returns The canonical cursor for the entity referred to by the given cursor. + */ +CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor); + +/** + * If the cursor points to a selector identifier in an Objective-C + * method or message expression, this returns the selector index. + * + * After getting a cursor with #clang_getCursor, this can be called to + * determine if the location points to a selector identifier. + * + * \returns The selector index if the cursor is an Objective-C method or message + * expression and the cursor is pointing to a selector identifier, or -1 + * otherwise. + */ +CINDEX_LINKAGE int clang_Cursor_getObjCSelectorIndex(CXCursor); + +/** + * Given a cursor pointing to a C++ method call or an Objective-C + * message, returns non-zero if the method/message is "dynamic", meaning: + * + * For a C++ method: the call is virtual. + * For an Objective-C message: the receiver is an object instance, not 'super' + * or a specific class. + * + * If the method/message is "static" or the cursor does not point to a + * method/message, it will return zero. + */ +CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C); + +/** + * Given a cursor pointing to an Objective-C message or property + * reference, or C++ method call, returns the CXType of the receiver. + */ +CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C); + +/** + * Property attributes for a \c CXCursor_ObjCPropertyDecl. + */ +typedef enum { + CXObjCPropertyAttr_noattr = 0x00, + CXObjCPropertyAttr_readonly = 0x01, + CXObjCPropertyAttr_getter = 0x02, + CXObjCPropertyAttr_assign = 0x04, + CXObjCPropertyAttr_readwrite = 0x08, + CXObjCPropertyAttr_retain = 0x10, + CXObjCPropertyAttr_copy = 0x20, + CXObjCPropertyAttr_nonatomic = 0x40, + CXObjCPropertyAttr_setter = 0x80, + CXObjCPropertyAttr_atomic = 0x100, + CXObjCPropertyAttr_weak = 0x200, + CXObjCPropertyAttr_strong = 0x400, + CXObjCPropertyAttr_unsafe_unretained = 0x800, + CXObjCPropertyAttr_class = 0x1000 +} CXObjCPropertyAttrKind; + +/** + * Given a cursor that represents a property declaration, return the + * associated property attributes. The bits are formed from + * \c CXObjCPropertyAttrKind. + * + * \param reserved Reserved for future use, pass 0. + */ +CINDEX_LINKAGE unsigned +clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved); + +/** + * Given a cursor that represents a property declaration, return the + * name of the method that implements the getter. + */ +CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C); + +/** + * Given a cursor that represents a property declaration, return the + * name of the method that implements the setter, if any. + */ +CINDEX_LINKAGE CXString clang_Cursor_getObjCPropertySetterName(CXCursor C); + +/** + * 'Qualifiers' written next to the return and parameter types in + * Objective-C method declarations. + */ +typedef enum { + CXObjCDeclQualifier_None = 0x0, + CXObjCDeclQualifier_In = 0x1, + CXObjCDeclQualifier_Inout = 0x2, + CXObjCDeclQualifier_Out = 0x4, + CXObjCDeclQualifier_Bycopy = 0x8, + CXObjCDeclQualifier_Byref = 0x10, + CXObjCDeclQualifier_Oneway = 0x20 +} CXObjCDeclQualifierKind; + +/** + * Given a cursor that represents an Objective-C method or parameter + * declaration, return the associated Objective-C qualifiers for the return + * type or the parameter respectively. The bits are formed from + * CXObjCDeclQualifierKind. + */ +CINDEX_LINKAGE unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C); + +/** + * Given a cursor that represents an Objective-C method or property + * declaration, return non-zero if the declaration was affected by "\@optional". + * Returns zero if the cursor is not such a declaration or it is "\@required". + */ +CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C); + +/** + * Returns non-zero if the given cursor is a variadic function or method. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C); + +/** + * Returns non-zero if the given cursor points to a symbol marked with + * external_source_symbol attribute. + * + * \param language If non-NULL, and the attribute is present, will be set to + * the 'language' string from the attribute. + * + * \param definedIn If non-NULL, and the attribute is present, will be set to + * the 'definedIn' string from the attribute. + * + * \param isGenerated If non-NULL, and the attribute is present, will be set to + * non-zero if the 'generated_declaration' is set in the attribute. + */ +CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(CXCursor C, + CXString *language, + CXString *definedIn, + unsigned *isGenerated); + +/** + * Given a cursor that represents a declaration, return the associated + * comment's source range. The range may include multiple consecutive comments + * with whitespace in between. + */ +CINDEX_LINKAGE CXSourceRange clang_Cursor_getCommentRange(CXCursor C); + +/** + * Given a cursor that represents a declaration, return the associated + * comment text, including comment markers. + */ +CINDEX_LINKAGE CXString clang_Cursor_getRawCommentText(CXCursor C); + +/** + * Given a cursor that represents a documentable entity (e.g., + * declaration), return the associated \paragraph; otherwise return the + * first paragraph. + */ +CINDEX_LINKAGE CXString clang_Cursor_getBriefCommentText(CXCursor C); + +/** + * @} + */ + +/** \defgroup CINDEX_MANGLE Name Mangling API Functions + * + * @{ + */ + +/** + * Retrieve the CXString representing the mangled name of the cursor. + */ +CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor); + +/** + * Retrieve the CXStrings representing the mangled symbols of the C++ + * constructor or destructor at the cursor. + */ +CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor); + +/** + * Retrieve the CXStrings representing the mangled symbols of the ObjC + * class interface or implementation at the cursor. + */ +CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_MODULE Inline Assembly introspection + * + * The functions in this group provide access to information about GCC-style + * inline assembly statements. + * + * @{ + */ + +/** + * Given a CXCursor_GCCAsmStmt cursor, return the assembly template string. + * As per LLVM IR Assembly Template language, template placeholders for + * inputs and outputs are either of the form $N where N is a decimal number + * as an index into the input-output specification, + * or ${N:M} where N is a decimal number also as an index into the + * input-output specification and M is the template argument modifier. + * The index N in both cases points into the the total inputs and outputs, + * or more specifically, into the list of outputs followed by the inputs, + * starting from index 0 as the first available template argument. + * + * This function also returns a valid empty string if the cursor does not point + * at a GCC inline assembly block. + * + * Users are responsible for releasing the allocation of returned string via + * \c clang_disposeString. + */ + +CINDEX_LINKAGE CXString clang_Cursor_getGCCAssemblyTemplate(CXCursor); + +/** + * Given a CXCursor_GCCAsmStmt cursor, check if the assembly block has goto + * labels. + * This function also returns 0 if the cursor does not point at a GCC inline + * assembly block. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_isGCCAssemblyHasGoto(CXCursor); + +/** + * Given a CXCursor_GCCAsmStmt cursor, count the number of outputs. + * This function also returns 0 if the cursor does not point at a GCC inline + * assembly block. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyNumOutputs(CXCursor); + +/** + * Given a CXCursor_GCCAsmStmt cursor, count the number of inputs. + * This function also returns 0 if the cursor does not point at a GCC inline + * assembly block. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyNumInputs(CXCursor); + +/** + * Given a CXCursor_GCCAsmStmt cursor, get the constraint and expression cursor + * to the Index-th input. + * This function returns 1 when the cursor points at a GCC inline assembly + * statement, `Index` is within bounds and both the `Constraint` and `Expr` are + * not NULL. + * Otherwise, this function returns 0 but leaves `Constraint` and `Expr` + * intact. + * + * Users are responsible for releasing the allocation of `Constraint` via + * \c clang_disposeString. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyInput(CXCursor Cursor, + unsigned Index, + CXString *Constraint, + CXCursor *Expr); + +/** + * Given a CXCursor_GCCAsmStmt cursor, get the constraint and expression cursor + * to the Index-th output. + * This function returns 1 when the cursor points at a GCC inline assembly + * statement, `Index` is within bounds and both the `Constraint` and `Expr` are + * not NULL. + * Otherwise, this function returns 0 but leaves `Constraint` and `Expr` + * intact. + * + * Users are responsible for releasing the allocation of `Constraint` via + * \c clang_disposeString. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyOutput(CXCursor Cursor, + unsigned Index, + CXString *Constraint, + CXCursor *Expr); + +/** + * Given a CXCursor_GCCAsmStmt cursor, count the clobbers in it. + * This function also returns 0 if the cursor does not point at a GCC inline + * assembly block. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_getGCCAssemblyNumClobbers(CXCursor Cursor); + +/** + * Given a CXCursor_GCCAsmStmt cursor, get the Index-th clobber of it. + * This function returns a valid empty string if the cursor does not point + * at a GCC inline assembly block or `Index` is out of bounds. + * + * Users are responsible for releasing the allocation of returned string via + * \c clang_disposeString. + */ + +CINDEX_LINKAGE CXString clang_Cursor_getGCCAssemblyClobber(CXCursor Cursor, + unsigned Index); + +/** + * Given a CXCursor_GCCAsmStmt cursor, check if the inline assembly is + * `volatile`. + * This function returns 0 if the cursor does not point at a GCC inline + * assembly block. + */ + +CINDEX_LINKAGE unsigned clang_Cursor_isGCCAssemblyVolatile(CXCursor Cursor); + +/** + * @} + */ + +/** + * \defgroup CINDEX_MODULE Module introspection + * + * The functions in this group provide access to information about modules. + * + * @{ + */ + +typedef void *CXModule; + +/** + * Given a CXCursor_ModuleImportDecl cursor, return the associated module. + */ +CINDEX_LINKAGE CXModule clang_Cursor_getModule(CXCursor C); + +/** + * Given a CXFile header file, return the module that contains it, if one + * exists. + */ +CINDEX_LINKAGE CXModule clang_getModuleForFile(CXTranslationUnit, CXFile); + +/** + * \param Module a module object. + * + * \returns the module file where the provided module object came from. + */ +CINDEX_LINKAGE CXFile clang_Module_getASTFile(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the parent of a sub-module or NULL if the given module is top-level, + * e.g. for 'std.vector' it will return the 'std' module. + */ +CINDEX_LINKAGE CXModule clang_Module_getParent(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the name of the module, e.g. for the 'std.vector' sub-module it + * will return "vector". + */ +CINDEX_LINKAGE CXString clang_Module_getName(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the full name of the module, e.g. "std.vector". + */ +CINDEX_LINKAGE CXString clang_Module_getFullName(CXModule Module); + +/** + * \param Module a module object. + * + * \returns non-zero if the module is a system one. + */ +CINDEX_LINKAGE int clang_Module_isSystem(CXModule Module); + +/** + * \param Module a module object. + * + * \returns the number of top level headers associated with this module. + */ +CINDEX_LINKAGE unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit, + CXModule Module); + +/** + * \param Module a module object. + * + * \param Index top level header index (zero-based). + * + * \returns the specified top level header associated with the module. + */ +CINDEX_LINKAGE +CXFile clang_Module_getTopLevelHeader(CXTranslationUnit, CXModule Module, + unsigned Index); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CPP C++ AST introspection + * + * The routines in this group provide access information in the ASTs specific + * to C++ language features. + * + * @{ + */ + +/** + * Determine if a C++ constructor is a converting constructor. + */ +CINDEX_LINKAGE unsigned +clang_CXXConstructor_isConvertingConstructor(CXCursor C); + +/** + * Determine if a C++ constructor is a copy constructor. + */ +CINDEX_LINKAGE unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C); + +/** + * Determine if a C++ constructor is the default constructor. + */ +CINDEX_LINKAGE unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C); + +/** + * Determine if a C++ constructor is a move constructor. + */ +CINDEX_LINKAGE unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C); + +/** + * Determine if a C++ field is declared 'mutable'. + */ +CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C); + +/** + * Determine if a C++ method is declared '= default'. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C); + +/** + * Determine if a C++ method is declared '= delete'. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C); + +/** + * Determine if a C++ member function or member function template is + * pure virtual. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isPureVirtual(CXCursor C); + +/** + * Determine if a C++ member function or member function template is + * declared 'static'. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C); + +/** + * Determine if a C++ member function or member function template is + * explicitly declared 'virtual' or if it overrides a virtual method from + * one of the base classes. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C); + +/** + * Determine if a C++ member function is a copy-assignment operator, + * returning 1 if such is the case and 0 otherwise. + * + * > A copy-assignment operator `X::operator=` is a non-static, + * > non-template member function of _class_ `X` with exactly one + * > parameter of type `X`, `X&`, `const X&`, `volatile X&` or `const + * > volatile X&`. + * + * That is, for example, the `operator=` in: + * + * class Foo { + * bool operator=(const volatile Foo&); + * }; + * + * Is a copy-assignment operator, while the `operator=` in: + * + * class Bar { + * bool operator=(const int&); + * }; + * + * Is not. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isCopyAssignmentOperator(CXCursor C); + +/** + * Determine if a C++ member function is a move-assignment operator, + * returning 1 if such is the case and 0 otherwise. + * + * > A move-assignment operator `X::operator=` is a non-static, + * > non-template member function of _class_ `X` with exactly one + * > parameter of type `X&&`, `const X&&`, `volatile X&&` or `const + * > volatile X&&`. + * + * That is, for example, the `operator=` in: + * + * class Foo { + * bool operator=(const volatile Foo&&); + * }; + * + * Is a move-assignment operator, while the `operator=` in: + * + * class Bar { + * bool operator=(const int&&); + * }; + * + * Is not. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isMoveAssignmentOperator(CXCursor C); + +/** + * Determines if a C++ constructor or conversion function was declared + * explicit, returning 1 if such is the case and 0 otherwise. + * + * Constructors or conversion functions are declared explicit through + * the use of the explicit specifier. + * + * For example, the following constructor and conversion function are + * not explicit as they lack the explicit specifier: + * + * class Foo { + * Foo(); + * operator int(); + * }; + * + * While the following constructor and conversion function are + * explicit as they are declared with the explicit specifier. + * + * class Foo { + * explicit Foo(); + * explicit operator int(); + * }; + * + * This function will return 0 when given a cursor pointing to one of + * the former declarations and it will return 1 for a cursor pointing + * to the latter declarations. + * + * The explicit specifier allows the user to specify a + * conditional compile-time expression whose value decides + * whether the marked element is explicit or not. + * + * For example: + * + * constexpr bool foo(int i) { return i % 2 == 0; } + * + * class Foo { + * explicit(foo(1)) Foo(); + * explicit(foo(2)) operator int(); + * } + * + * This function will return 0 for the constructor and 1 for + * the conversion function. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isExplicit(CXCursor C); + +/** + * Determine if a C++ record is abstract, i.e. whether a class or struct + * has a pure virtual member function. + */ +CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C); + +/** + * Determine if an enum declaration refers to a scoped enum. + */ +CINDEX_LINKAGE unsigned clang_EnumDecl_isScoped(CXCursor C); + +/** + * Determine if a C++ member function or member function template is + * declared 'const'. + */ +CINDEX_LINKAGE unsigned clang_CXXMethod_isConst(CXCursor C); + +/** + * Given a cursor that represents a template, determine + * the cursor kind of the specializations would be generated by instantiating + * the template. + * + * This routine can be used to determine what flavor of function template, + * class template, or class template partial specialization is stored in the + * cursor. For example, it can describe whether a class template cursor is + * declared with "struct", "class" or "union". + * + * \param C The cursor to query. This cursor should represent a template + * declaration. + * + * \returns The cursor kind of the specializations that would be generated + * by instantiating the template \p C. If \p C is not a template, returns + * \c CXCursor_NoDeclFound. + */ +CINDEX_LINKAGE enum CXCursorKind clang_getTemplateCursorKind(CXCursor C); + +/** + * Given a cursor that may represent a specialization or instantiation + * of a template, retrieve the cursor that represents the template that it + * specializes or from which it was instantiated. + * + * This routine determines the template involved both for explicit + * specializations of templates and for implicit instantiations of the template, + * both of which are referred to as "specializations". For a class template + * specialization (e.g., \c std::vector), this routine will return + * either the primary template (\c std::vector) or, if the specialization was + * instantiated from a class template partial specialization, the class template + * partial specialization. For a class template partial specialization and a + * function template specialization (including instantiations), this + * this routine will return the specialized template. + * + * For members of a class template (e.g., member functions, member classes, or + * static data members), returns the specialized or instantiated member. + * Although not strictly "templates" in the C++ language, members of class + * templates have the same notions of specializations and instantiations that + * templates do, so this routine treats them similarly. + * + * \param C A cursor that may be a specialization of a template or a member + * of a template. + * + * \returns If the given cursor is a specialization or instantiation of a + * template or a member thereof, the template or member that it specializes or + * from which it was instantiated. Otherwise, returns a NULL cursor. + */ +CINDEX_LINKAGE CXCursor clang_getSpecializedCursorTemplate(CXCursor C); + +/** + * Given a cursor that references something else, return the source range + * covering that reference. + * + * \param C A cursor pointing to a member reference, a declaration reference, or + * an operator call. + * \param NameFlags A bitset with three independent flags: + * CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and + * CXNameRange_WantSinglePiece. + * \param PieceIndex For contiguous names or when passing the flag + * CXNameRange_WantSinglePiece, only one piece with index 0 is + * available. When the CXNameRange_WantSinglePiece flag is not passed for a + * non-contiguous names, this index can be used to retrieve the individual + * pieces of the name. See also CXNameRange_WantSinglePiece. + * + * \returns The piece of the name pointed to by the given cursor. If there is no + * name, or if the PieceIndex is out-of-range, a null-cursor will be returned. + */ +CINDEX_LINKAGE CXSourceRange clang_getCursorReferenceNameRange( + CXCursor C, unsigned NameFlags, unsigned PieceIndex); + +enum CXNameRefFlags { + /** + * Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the + * range. + */ + CXNameRange_WantQualifier = 0x1, + + /** + * Include the explicit template arguments, e.g. \ in x.f, + * in the range. + */ + CXNameRange_WantTemplateArgs = 0x2, + + /** + * If the name is non-contiguous, return the full spanning range. + * + * Non-contiguous names occur in Objective-C when a selector with two or more + * parameters is used, or in C++ when using an operator: + * \code + * [object doSomething:here withValue:there]; // Objective-C + * return some_vector[1]; // C++ + * \endcode + */ + CXNameRange_WantSinglePiece = 0x4 +}; + +/** + * @} + */ + +/** + * \defgroup CINDEX_LEX Token extraction and manipulation + * + * The routines in this group provide access to the tokens within a + * translation unit, along with a semantic mapping of those tokens to + * their corresponding cursors. + * + * @{ + */ + +/** + * Describes a kind of token. + */ +typedef enum CXTokenKind { + /** + * A token that contains some kind of punctuation. + */ + CXToken_Punctuation, + + /** + * A language keyword. + */ + CXToken_Keyword, + + /** + * An identifier (that is not a keyword). + */ + CXToken_Identifier, + + /** + * A numeric, string, or character literal. + */ + CXToken_Literal, + + /** + * A comment. + */ + CXToken_Comment +} CXTokenKind; + +/** + * Describes a single preprocessing token. + */ +typedef struct { + unsigned int_data[4]; + void *ptr_data; +} CXToken; + +/** + * Get the raw lexical token starting with the given location. + * + * \param TU the translation unit whose text is being tokenized. + * + * \param Location the source location with which the token starts. + * + * \returns The token starting with the given location or NULL if no such token + * exist. The returned pointer must be freed with clang_disposeTokens before the + * translation unit is destroyed. + */ +CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU, + CXSourceLocation Location); + +/** + * Determine the kind of the given token. + */ +CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); + +/** + * Determine the spelling of the given token. + * + * The spelling of a token is the textual representation of that token, e.g., + * the text of an identifier or keyword. + */ +CINDEX_LINKAGE CXString clang_getTokenSpelling(CXTranslationUnit, CXToken); + +/** + * Retrieve the source location of the given token. + */ +CINDEX_LINKAGE CXSourceLocation clang_getTokenLocation(CXTranslationUnit, + CXToken); + +/** + * Retrieve a source range that covers the given token. + */ +CINDEX_LINKAGE CXSourceRange clang_getTokenExtent(CXTranslationUnit, CXToken); + +/** + * Tokenize the source code described by the given range into raw + * lexical tokens. + * + * \param TU the translation unit whose text is being tokenized. + * + * \param Range the source range in which text should be tokenized. All of the + * tokens produced by tokenization will fall within this source range, + * + * \param Tokens this pointer will be set to point to the array of tokens + * that occur within the given source range. The returned pointer must be + * freed with clang_disposeTokens() before the translation unit is destroyed. + * + * \param NumTokens will be set to the number of tokens in the \c *Tokens + * array. + * + */ +CINDEX_LINKAGE void clang_tokenize(CXTranslationUnit TU, CXSourceRange Range, + CXToken **Tokens, unsigned *NumTokens); + +/** + * Annotate the given set of tokens by providing cursors for each token + * that can be mapped to a specific entity within the abstract syntax tree. + * + * This token-annotation routine is equivalent to invoking + * clang_getCursor() for the source locations of each of the + * tokens. The cursors provided are filtered, so that only those + * cursors that have a direct correspondence to the token are + * accepted. For example, given a function call \c f(x), + * clang_getCursor() would provide the following cursors: + * + * * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. + * * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. + * * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. + * + * Only the first and last of these cursors will occur within the + * annotate, since the tokens "f" and "x' directly refer to a function + * and a variable, respectively, but the parentheses are just a small + * part of the full syntax of the function call expression, which is + * not provided as an annotation. + * + * \param TU the translation unit that owns the given tokens. + * + * \param Tokens the set of tokens to annotate. + * + * \param NumTokens the number of tokens in \p Tokens. + * + * \param Cursors an array of \p NumTokens cursors, whose contents will be + * replaced with the cursors corresponding to each token. + */ +CINDEX_LINKAGE void clang_annotateTokens(CXTranslationUnit TU, CXToken *Tokens, + unsigned NumTokens, CXCursor *Cursors); + +/** + * Free the given set of tokens. + */ +CINDEX_LINKAGE void clang_disposeTokens(CXTranslationUnit TU, CXToken *Tokens, + unsigned NumTokens); + +/** + * @} + */ + +/** + * \defgroup CINDEX_DEBUG Debugging facilities + * + * These routines are used for testing and debugging, only, and should not + * be relied upon. + * + * @{ + */ + +/* for debug/testing */ +CINDEX_LINKAGE CXString clang_getCursorKindSpelling(enum CXCursorKind Kind); +CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent( + CXCursor, const char **startBuf, const char **endBuf, unsigned *startLine, + unsigned *startColumn, unsigned *endLine, unsigned *endColumn); +CINDEX_LINKAGE void clang_enableStackTraces(void); +CINDEX_LINKAGE void clang_executeOnThread(void (*fn)(void *), void *user_data, + unsigned stack_size); + +/** + * @} + */ + +/** + * \defgroup CINDEX_CODE_COMPLET Code completion + * + * Code completion involves taking an (incomplete) source file, along with + * knowledge of where the user is actively editing that file, and suggesting + * syntactically- and semantically-valid constructs that the user might want to + * use at that particular point in the source code. These data structures and + * routines provide support for code completion. + * + * @{ + */ + +/** + * A semantic string that describes a code-completion result. + * + * A semantic string that describes the formatting of a code-completion + * result as a single "template" of text that should be inserted into the + * source buffer when a particular code-completion result is selected. + * Each semantic string is made up of some number of "chunks", each of which + * contains some text along with a description of what that text means, e.g., + * the name of the entity being referenced, whether the text chunk is part of + * the template, or whether it is a "placeholder" that the user should replace + * with actual code,of a specific kind. See \c CXCompletionChunkKind for a + * description of the different kinds of chunks. + */ +typedef void *CXCompletionString; + +/** + * A single result of code completion. + */ +typedef struct { + /** + * The kind of entity that this completion refers to. + * + * The cursor kind will be a macro, keyword, or a declaration (one of the + * *Decl cursor kinds), describing the entity that the completion is + * referring to. + * + * \todo In the future, we would like to provide a full cursor, to allow + * the client to extract additional information from declaration. + */ + enum CXCursorKind CursorKind; + + /** + * The code-completion string that describes how to insert this + * code-completion result into the editing buffer. + */ + CXCompletionString CompletionString; +} CXCompletionResult; + +/** + * Describes a single piece of text within a code-completion string. + * + * Each "chunk" within a code-completion string (\c CXCompletionString) is + * either a piece of text with a specific "kind" that describes how that text + * should be interpreted by the client or is another completion string. + */ +enum CXCompletionChunkKind { + /** + * A code-completion string that describes "optional" text that + * could be a part of the template (but is not required). + * + * The Optional chunk is the only kind of chunk that has a code-completion + * string for its representation, which is accessible via + * \c clang_getCompletionChunkCompletionString(). The code-completion string + * describes an additional part of the template that is completely optional. + * For example, optional chunks can be used to describe the placeholders for + * arguments that match up with defaulted function parameters, e.g. given: + * + * \code + * void f(int x, float y = 3.14, double z = 2.71828); + * \endcode + * + * The code-completion string for this function would contain: + * - a TypedText chunk for "f". + * - a LeftParen chunk for "(". + * - a Placeholder chunk for "int x" + * - an Optional chunk containing the remaining defaulted arguments, e.g., + * - a Comma chunk for "," + * - a Placeholder chunk for "float y" + * - an Optional chunk containing the last defaulted argument: + * - a Comma chunk for "," + * - a Placeholder chunk for "double z" + * - a RightParen chunk for ")" + * + * There are many ways to handle Optional chunks. Two simple approaches are: + * - Completely ignore optional chunks, in which case the template for the + * function "f" would only include the first parameter ("int x"). + * - Fully expand all optional chunks, in which case the template for the + * function "f" would have all of the parameters. + */ + CXCompletionChunk_Optional, + /** + * Text that a user would be expected to type to get this + * code-completion result. + * + * There will be exactly one "typed text" chunk in a semantic string, which + * will typically provide the spelling of a keyword or the name of a + * declaration that could be used at the current code point. Clients are + * expected to filter the code-completion results based on the text in this + * chunk. + */ + CXCompletionChunk_TypedText, + /** + * Text that should be inserted as part of a code-completion result. + * + * A "text" chunk represents text that is part of the template to be + * inserted into user code should this particular code-completion result + * be selected. + */ + CXCompletionChunk_Text, + /** + * Placeholder text that should be replaced by the user. + * + * A "placeholder" chunk marks a place where the user should insert text + * into the code-completion template. For example, placeholders might mark + * the function parameters for a function declaration, to indicate that the + * user should provide arguments for each of those parameters. The actual + * text in a placeholder is a suggestion for the text to display before + * the user replaces the placeholder with real code. + */ + CXCompletionChunk_Placeholder, + /** + * Informative text that should be displayed but never inserted as + * part of the template. + * + * An "informative" chunk contains annotations that can be displayed to + * help the user decide whether a particular code-completion result is the + * right option, but which is not part of the actual template to be inserted + * by code completion. + */ + CXCompletionChunk_Informative, + /** + * Text that describes the current parameter when code-completion is + * referring to function call, message send, or template specialization. + * + * A "current parameter" chunk occurs when code-completion is providing + * information about a parameter corresponding to the argument at the + * code-completion point. For example, given a function + * + * \code + * int add(int x, int y); + * \endcode + * + * and the source code \c add(, where the code-completion point is after the + * "(", the code-completion string will contain a "current parameter" chunk + * for "int x", indicating that the current argument will initialize that + * parameter. After typing further, to \c add(17, (where the code-completion + * point is after the ","), the code-completion string will contain a + * "current parameter" chunk to "int y". + */ + CXCompletionChunk_CurrentParameter, + /** + * A left parenthesis ('('), used to initiate a function call or + * signal the beginning of a function parameter list. + */ + CXCompletionChunk_LeftParen, + /** + * A right parenthesis (')'), used to finish a function call or + * signal the end of a function parameter list. + */ + CXCompletionChunk_RightParen, + /** + * A left bracket ('['). + */ + CXCompletionChunk_LeftBracket, + /** + * A right bracket (']'). + */ + CXCompletionChunk_RightBracket, + /** + * A left brace ('{'). + */ + CXCompletionChunk_LeftBrace, + /** + * A right brace ('}'). + */ + CXCompletionChunk_RightBrace, + /** + * A left angle bracket ('<'). + */ + CXCompletionChunk_LeftAngle, + /** + * A right angle bracket ('>'). + */ + CXCompletionChunk_RightAngle, + /** + * A comma separator (','). + */ + CXCompletionChunk_Comma, + /** + * Text that specifies the result type of a given result. + * + * This special kind of informative chunk is not meant to be inserted into + * the text buffer. Rather, it is meant to illustrate the type that an + * expression using the given completion string would have. + */ + CXCompletionChunk_ResultType, + /** + * A colon (':'). + */ + CXCompletionChunk_Colon, + /** + * A semicolon (';'). + */ + CXCompletionChunk_SemiColon, + /** + * An '=' sign. + */ + CXCompletionChunk_Equal, + /** + * Horizontal space (' '). + */ + CXCompletionChunk_HorizontalSpace, + /** + * Vertical space ('\\n'), after which it is generally a good idea to + * perform indentation. + */ + CXCompletionChunk_VerticalSpace +}; + +/** + * Determine the kind of a particular chunk within a completion string. + * + * \param completion_string the completion string to query. + * + * \param chunk_number the 0-based index of the chunk in the completion string. + * + * \returns the kind of the chunk at the index \c chunk_number. + */ +CINDEX_LINKAGE enum CXCompletionChunkKind +clang_getCompletionChunkKind(CXCompletionString completion_string, + unsigned chunk_number); + +/** + * Retrieve the text associated with a particular chunk within a + * completion string. + * + * \param completion_string the completion string to query. + * + * \param chunk_number the 0-based index of the chunk in the completion string. + * + * \returns the text associated with the chunk at index \c chunk_number. + */ +CINDEX_LINKAGE CXString clang_getCompletionChunkText( + CXCompletionString completion_string, unsigned chunk_number); + +/** + * Retrieve the completion string associated with a particular chunk + * within a completion string. + * + * \param completion_string the completion string to query. + * + * \param chunk_number the 0-based index of the chunk in the completion string. + * + * \returns the completion string associated with the chunk at index + * \c chunk_number. + */ +CINDEX_LINKAGE CXCompletionString clang_getCompletionChunkCompletionString( + CXCompletionString completion_string, unsigned chunk_number); + +/** + * Retrieve the number of chunks in the given code-completion string. + */ +CINDEX_LINKAGE unsigned +clang_getNumCompletionChunks(CXCompletionString completion_string); + +/** + * Determine the priority of this code completion. + * + * The priority of a code completion indicates how likely it is that this + * particular completion is the completion that the user will select. The + * priority is selected by various internal heuristics. + * + * \param completion_string The completion string to query. + * + * \returns The priority of this completion string. Smaller values indicate + * higher-priority (more likely) completions. + */ +CINDEX_LINKAGE unsigned +clang_getCompletionPriority(CXCompletionString completion_string); + +/** + * Determine the availability of the entity that this code-completion + * string refers to. + * + * \param completion_string The completion string to query. + * + * \returns The availability of the completion string. + */ +CINDEX_LINKAGE enum CXAvailabilityKind +clang_getCompletionAvailability(CXCompletionString completion_string); + +/** + * Retrieve the number of annotations associated with the given + * completion string. + * + * \param completion_string the completion string to query. + * + * \returns the number of annotations associated with the given completion + * string. + */ +CINDEX_LINKAGE unsigned +clang_getCompletionNumAnnotations(CXCompletionString completion_string); + +/** + * Retrieve the annotation associated with the given completion string. + * + * \param completion_string the completion string to query. + * + * \param annotation_number the 0-based index of the annotation of the + * completion string. + * + * \returns annotation string associated with the completion at index + * \c annotation_number, or a NULL string if that annotation is not available. + */ +CINDEX_LINKAGE CXString clang_getCompletionAnnotation( + CXCompletionString completion_string, unsigned annotation_number); + +/** + * Retrieve the parent context of the given completion string. + * + * The parent context of a completion string is the semantic parent of + * the declaration (if any) that the code completion represents. For example, + * a code completion for an Objective-C method would have the method's class + * or protocol as its context. + * + * \param completion_string The code completion string whose parent is + * being queried. + * + * \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. + * + * \returns The name of the completion parent, e.g., "NSObject" if + * the completion string represents a method in the NSObject class. + */ +CINDEX_LINKAGE CXString clang_getCompletionParent( + CXCompletionString completion_string, enum CXCursorKind *kind); + +/** + * Retrieve the brief documentation comment attached to the declaration + * that corresponds to the given completion string. + */ +CINDEX_LINKAGE CXString +clang_getCompletionBriefComment(CXCompletionString completion_string); + +/** + * Retrieve a completion string for an arbitrary declaration or macro + * definition cursor. + * + * \param cursor The cursor to query. + * + * \returns A non-context-sensitive completion string for declaration and macro + * definition cursors, or NULL for other kinds of cursors. + */ +CINDEX_LINKAGE CXCompletionString +clang_getCursorCompletionString(CXCursor cursor); + +/** + * Contains the results of code-completion. + * + * This data structure contains the results of code completion, as + * produced by \c clang_codeCompleteAt(). Its contents must be freed by + * \c clang_disposeCodeCompleteResults. + */ +typedef struct { + /** + * The code-completion results. + */ + CXCompletionResult *Results; + + /** + * The number of code-completion results stored in the + * \c Results array. + */ + unsigned NumResults; +} CXCodeCompleteResults; + +/** + * Retrieve the number of fix-its for the given completion index. + * + * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts + * option was set. + * + * \param results The structure keeping all completion results + * + * \param completion_index The index of the completion + * + * \return The number of fix-its which must be applied before the completion at + * completion_index can be applied + */ +CINDEX_LINKAGE unsigned +clang_getCompletionNumFixIts(CXCodeCompleteResults *results, + unsigned completion_index); + +/** + * Fix-its that *must* be applied before inserting the text for the + * corresponding completion. + * + * By default, clang_codeCompleteAt() only returns completions with empty + * fix-its. Extra completions with non-empty fix-its should be explicitly + * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts. + * + * For the clients to be able to compute position of the cursor after applying + * fix-its, the following conditions are guaranteed to hold for + * replacement_range of the stored fix-its: + * - Ranges in the fix-its are guaranteed to never contain the completion + * point (or identifier under completion point, if any) inside them, except + * at the start or at the end of the range. + * - If a fix-it range starts or ends with completion point (or starts or + * ends after the identifier under completion point), it will contain at + * least one character. It allows to unambiguously recompute completion + * point after applying the fix-it. + * + * The intuition is that provided fix-its change code around the identifier we + * complete, but are not allowed to touch the identifier itself or the + * completion point. One example of completions with corrections are the ones + * replacing '.' with '->' and vice versa: + * + * std::unique_ptr> vec_ptr; + * In 'vec_ptr.^', one of the completions is 'push_back', it requires + * replacing '.' with '->'. + * In 'vec_ptr->^', one of the completions is 'release', it requires + * replacing '->' with '.'. + * + * \param results The structure keeping all completion results + * + * \param completion_index The index of the completion + * + * \param fixit_index The index of the fix-it for the completion at + * completion_index + * + * \param replacement_range The fix-it range that must be replaced before the + * completion at completion_index can be applied + * + * \returns The fix-it string that must replace the code at replacement_range + * before the completion at completion_index can be applied + */ +CINDEX_LINKAGE CXString clang_getCompletionFixIt( + CXCodeCompleteResults *results, unsigned completion_index, + unsigned fixit_index, CXSourceRange *replacement_range); + +/** + * Flags that can be passed to \c clang_codeCompleteAt() to + * modify its behavior. + * + * The enumerators in this enumeration can be bitwise-OR'd together to + * provide multiple options to \c clang_codeCompleteAt(). + */ +enum CXCodeComplete_Flags { + /** + * Whether to include macros within the set of code + * completions returned. + */ + CXCodeComplete_IncludeMacros = 0x01, + + /** + * Whether to include code patterns for language constructs + * within the set of code completions, e.g., for loops. + */ + CXCodeComplete_IncludeCodePatterns = 0x02, + + /** + * Whether to include brief documentation within the set of code + * completions returned. + */ + CXCodeComplete_IncludeBriefComments = 0x04, + + /** + * Whether to speed up completion by omitting top- or namespace-level entities + * defined in the preamble. There's no guarantee any particular entity is + * omitted. This may be useful if the headers are indexed externally. + */ + CXCodeComplete_SkipPreamble = 0x08, + + /** + * Whether to include completions with small + * fix-its, e.g. change '.' to '->' on member access, etc. + */ + CXCodeComplete_IncludeCompletionsWithFixIts = 0x10 +}; + +/** + * Bits that represent the context under which completion is occurring. + * + * The enumerators in this enumeration may be bitwise-OR'd together if multiple + * contexts are occurring simultaneously. + */ +enum CXCompletionContext { + /** + * The context for completions is unexposed, as only Clang results + * should be included. (This is equivalent to having no context bits set.) + */ + CXCompletionContext_Unexposed = 0, + + /** + * Completions for any possible type should be included in the results. + */ + CXCompletionContext_AnyType = 1 << 0, + + /** + * Completions for any possible value (variables, function calls, etc.) + * should be included in the results. + */ + CXCompletionContext_AnyValue = 1 << 1, + /** + * Completions for values that resolve to an Objective-C object should + * be included in the results. + */ + CXCompletionContext_ObjCObjectValue = 1 << 2, + /** + * Completions for values that resolve to an Objective-C selector + * should be included in the results. + */ + CXCompletionContext_ObjCSelectorValue = 1 << 3, + /** + * Completions for values that resolve to a C++ class type should be + * included in the results. + */ + CXCompletionContext_CXXClassTypeValue = 1 << 4, + + /** + * Completions for fields of the member being accessed using the dot + * operator should be included in the results. + */ + CXCompletionContext_DotMemberAccess = 1 << 5, + /** + * Completions for fields of the member being accessed using the arrow + * operator should be included in the results. + */ + CXCompletionContext_ArrowMemberAccess = 1 << 6, + /** + * Completions for properties of the Objective-C object being accessed + * using the dot operator should be included in the results. + */ + CXCompletionContext_ObjCPropertyAccess = 1 << 7, + + /** + * Completions for enum tags should be included in the results. + */ + CXCompletionContext_EnumTag = 1 << 8, + /** + * Completions for union tags should be included in the results. + */ + CXCompletionContext_UnionTag = 1 << 9, + /** + * Completions for struct tags should be included in the results. + */ + CXCompletionContext_StructTag = 1 << 10, + + /** + * Completions for C++ class names should be included in the results. + */ + CXCompletionContext_ClassTag = 1 << 11, + /** + * Completions for C++ namespaces and namespace aliases should be + * included in the results. + */ + CXCompletionContext_Namespace = 1 << 12, + /** + * Completions for C++ nested name specifiers should be included in + * the results. + */ + CXCompletionContext_NestedNameSpecifier = 1 << 13, + + /** + * Completions for Objective-C interfaces (classes) should be included + * in the results. + */ + CXCompletionContext_ObjCInterface = 1 << 14, + /** + * Completions for Objective-C protocols should be included in + * the results. + */ + CXCompletionContext_ObjCProtocol = 1 << 15, + /** + * Completions for Objective-C categories should be included in + * the results. + */ + CXCompletionContext_ObjCCategory = 1 << 16, + /** + * Completions for Objective-C instance messages should be included + * in the results. + */ + CXCompletionContext_ObjCInstanceMessage = 1 << 17, + /** + * Completions for Objective-C class messages should be included in + * the results. + */ + CXCompletionContext_ObjCClassMessage = 1 << 18, + /** + * Completions for Objective-C selector names should be included in + * the results. + */ + CXCompletionContext_ObjCSelectorName = 1 << 19, + + /** + * Completions for preprocessor macro names should be included in + * the results. + */ + CXCompletionContext_MacroName = 1 << 20, + + /** + * Natural language completions should be included in the results. + */ + CXCompletionContext_NaturalLanguage = 1 << 21, + + /** + * #include file completions should be included in the results. + */ + CXCompletionContext_IncludedFile = 1 << 22, + + /** + * The current context is unknown, so set all contexts. + */ + CXCompletionContext_Unknown = ((1 << 23) - 1) +}; + +/** + * Returns a default set of code-completion options that can be + * passed to\c clang_codeCompleteAt(). + */ +CINDEX_LINKAGE unsigned clang_defaultCodeCompleteOptions(void); + +/** + * Perform code completion at a given location in a translation unit. + * + * This function performs code completion at a particular file, line, and + * column within source code, providing results that suggest potential + * code snippets based on the context of the completion. The basic model + * for code completion is that Clang will parse a complete source file, + * performing syntax checking up to the location where code-completion has + * been requested. At that point, a special code-completion token is passed + * to the parser, which recognizes this token and determines, based on the + * current location in the C/Objective-C/C++ grammar and the state of + * semantic analysis, what completions to provide. These completions are + * returned via a new \c CXCodeCompleteResults structure. + * + * Code completion itself is meant to be triggered by the client when the + * user types punctuation characters or whitespace, at which point the + * code-completion location will coincide with the cursor. For example, if \c p + * is a pointer, code-completion might be triggered after the "-" and then + * after the ">" in \c p->. When the code-completion location is after the ">", + * the completion results will provide, e.g., the members of the struct that + * "p" points to. The client is responsible for placing the cursor at the + * beginning of the token currently being typed, then filtering the results + * based on the contents of the token. For example, when code-completing for + * the expression \c p->get, the client should provide the location just after + * the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the + * client can filter the results based on the current token text ("get"), only + * showing those results that start with "get". The intent of this interface + * is to separate the relatively high-latency acquisition of code-completion + * results from the filtering of results on a per-character basis, which must + * have a lower latency. + * + * \param TU The translation unit in which code-completion should + * occur. The source files for this translation unit need not be + * completely up-to-date (and the contents of those source files may + * be overridden via \p unsaved_files). Cursors referring into the + * translation unit may be invalidated by this invocation. + * + * \param complete_filename The name of the source file where code + * completion should be performed. This filename may be any file + * included in the translation unit. + * + * \param complete_line The line at which code-completion should occur. + * + * \param complete_column The column at which code-completion should occur. + * Note that the column should point just after the syntactic construct that + * initiated code completion, and not in the middle of a lexical token. + * + * \param unsaved_files the Files that have not yet been saved to disk + * but may be required for parsing or code completion, including the + * contents of those files. The contents and name of these files (as + * specified by CXUnsavedFile) are copied when necessary, so the + * client only needs to guarantee their validity until the call to + * this function returns. + * + * \param num_unsaved_files The number of unsaved file entries in \p + * unsaved_files. + * + * \param options Extra options that control the behavior of code + * completion, expressed as a bitwise OR of the enumerators of the + * CXCodeComplete_Flags enumeration. The + * \c clang_defaultCodeCompleteOptions() function returns a default set + * of code-completion options. + * + * \returns If successful, a new \c CXCodeCompleteResults structure + * containing code-completion results, which should eventually be + * freed with \c clang_disposeCodeCompleteResults(). If code + * completion fails, returns NULL. + */ +CINDEX_LINKAGE +CXCodeCompleteResults * +clang_codeCompleteAt(CXTranslationUnit TU, const char *complete_filename, + unsigned complete_line, unsigned complete_column, + struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, unsigned options); + +/** + * Sort the code-completion results in case-insensitive alphabetical + * order. + * + * \param Results The set of results to sort. + * \param NumResults The number of results in \p Results. + */ +CINDEX_LINKAGE +void clang_sortCodeCompletionResults(CXCompletionResult *Results, + unsigned NumResults); + +/** + * Free the given set of code-completion results. + */ +CINDEX_LINKAGE +void clang_disposeCodeCompleteResults(CXCodeCompleteResults *Results); + +/** + * Determine the number of diagnostics produced prior to the + * location where code completion was performed. + */ +CINDEX_LINKAGE +unsigned clang_codeCompleteGetNumDiagnostics(CXCodeCompleteResults *Results); + +/** + * Retrieve a diagnostic associated with the given code completion. + * + * \param Results the code completion results to query. + * \param Index the zero-based diagnostic number to retrieve. + * + * \returns the requested diagnostic. This diagnostic must be freed + * via a call to \c clang_disposeDiagnostic(). + */ +CINDEX_LINKAGE +CXDiagnostic clang_codeCompleteGetDiagnostic(CXCodeCompleteResults *Results, + unsigned Index); + +/** + * Determines what completions are appropriate for the context + * the given code completion. + * + * \param Results the code completion results to query + * + * \returns the kinds of completions that are appropriate for use + * along with the given code completion results. + */ +CINDEX_LINKAGE +unsigned long long +clang_codeCompleteGetContexts(CXCodeCompleteResults *Results); + +/** + * Returns the cursor kind for the container for the current code + * completion context. The container is only guaranteed to be set for + * contexts where a container exists (i.e. member accesses or Objective-C + * message sends); if there is not a container, this function will return + * CXCursor_InvalidCode. + * + * \param Results the code completion results to query + * + * \param IsIncomplete on return, this value will be false if Clang has complete + * information about the container. If Clang does not have complete + * information, this value will be true. + * + * \returns the container kind, or CXCursor_InvalidCode if there is not a + * container + */ +CINDEX_LINKAGE +enum CXCursorKind +clang_codeCompleteGetContainerKind(CXCodeCompleteResults *Results, + unsigned *IsIncomplete); + +/** + * Returns the USR for the container for the current code completion + * context. If there is not a container for the current context, this + * function will return the empty string. + * + * \param Results the code completion results to query + * + * \returns the USR for the container + */ +CINDEX_LINKAGE +CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *Results); + +/** + * Returns the currently-entered selector for an Objective-C message + * send, formatted like "initWithFoo:bar:". Only guaranteed to return a + * non-empty string for CXCompletionContext_ObjCInstanceMessage and + * CXCompletionContext_ObjCClassMessage. + * + * \param Results the code completion results to query + * + * \returns the selector (or partial selector) that has been entered thus far + * for an Objective-C message send. + */ +CINDEX_LINKAGE +CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *Results); + +/** + * @} + */ + +/** + * \defgroup CINDEX_MISC Miscellaneous utility functions + * + * @{ + */ + +/** + * Return a version string, suitable for showing to a user, but not + * intended to be parsed (the format is not guaranteed to be stable). + */ +CINDEX_LINKAGE CXString clang_getClangVersion(void); + +/** + * Enable/disable crash recovery. + * + * \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero + * value enables crash recovery, while 0 disables it. + */ +CINDEX_LINKAGE void clang_toggleCrashRecovery(unsigned isEnabled); + +/** + * Visitor invoked for each file in a translation unit + * (used with clang_getInclusions()). + * + * This visitor function will be invoked by clang_getInclusions() for each + * file included (either at the top-level or by \#include directives) within + * a translation unit. The first argument is the file being included, and + * the second and third arguments provide the inclusion stack. The + * array is sorted in order of immediate inclusion. For example, + * the first element refers to the location that included 'included_file'. + */ +typedef void (*CXInclusionVisitor)(CXFile included_file, + CXSourceLocation *inclusion_stack, + unsigned include_len, + CXClientData client_data); + +/** + * Visit the set of preprocessor inclusions in a translation unit. + * The visitor function is called with the provided data for every included + * file. This does not include headers included by the PCH file (unless one + * is inspecting the inclusions in the PCH file itself). + */ +CINDEX_LINKAGE void clang_getInclusions(CXTranslationUnit tu, + CXInclusionVisitor visitor, + CXClientData client_data); + +typedef enum { + CXEval_Int = 1, + CXEval_Float = 2, + CXEval_ObjCStrLiteral = 3, + CXEval_StrLiteral = 4, + CXEval_CFStr = 5, + CXEval_Other = 6, + + CXEval_UnExposed = 0 + +} CXEvalResultKind; + +/** + * Evaluation result of a cursor + */ +typedef void *CXEvalResult; + +/** + * If cursor is a statement declaration tries to evaluate the + * statement and if its variable, tries to evaluate its initializer, + * into its corresponding type. + * If it's an expression, tries to evaluate the expression. + */ +CINDEX_LINKAGE CXEvalResult clang_Cursor_Evaluate(CXCursor C); + +/** + * Returns the kind of the evaluated result. + */ +CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E); + +/** + * Returns the evaluation result as integer if the + * kind is Int. + */ +CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E); + +/** + * Returns the evaluation result as a long long integer if the + * kind is Int. This prevents overflows that may happen if the result is + * returned with clang_EvalResult_getAsInt. + */ +CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E); + +/** + * Returns a non-zero value if the kind is Int and the evaluation + * result resulted in an unsigned integer. + */ +CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E); + +/** + * Returns the evaluation result as an unsigned integer if + * the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. + */ +CINDEX_LINKAGE unsigned long long +clang_EvalResult_getAsUnsigned(CXEvalResult E); + +/** + * Returns the evaluation result as double if the + * kind is double. + */ +CINDEX_LINKAGE double clang_EvalResult_getAsDouble(CXEvalResult E); + +/** + * Returns the evaluation result as a constant string if the + * kind is other than Int or float. User must not free this pointer, + * instead call clang_EvalResult_dispose on the CXEvalResult returned + * by clang_Cursor_Evaluate. + */ +CINDEX_LINKAGE const char *clang_EvalResult_getAsStr(CXEvalResult E); + +/** + * Disposes the created Eval memory. + */ +CINDEX_LINKAGE void clang_EvalResult_dispose(CXEvalResult E); +/** + * @} + */ + +/** \defgroup CINDEX_HIGH Higher level API functions + * + * @{ + */ + +enum CXVisitorResult { CXVisit_Break, CXVisit_Continue }; + +typedef struct CXCursorAndRangeVisitor { + void *context; + enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); +} CXCursorAndRangeVisitor; + +typedef enum { + /** + * Function returned successfully. + */ + CXResult_Success = 0, + /** + * One of the parameters was invalid for the function. + */ + CXResult_Invalid = 1, + /** + * The function was terminated by a callback (e.g. it returned + * CXVisit_Break) + */ + CXResult_VisitBreak = 2 + +} CXResult; + +/** + * Find references of a declaration in a specific file. + * + * \param cursor pointing to a declaration or a reference of one. + * + * \param file to search for references. + * + * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + * each reference found. + * The CXSourceRange will point inside the file; if the reference is inside + * a macro (and not a macro argument) the CXSourceRange will be invalid. + * + * \returns one of the CXResult enumerators. + */ +CINDEX_LINKAGE CXResult clang_findReferencesInFile( + CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor); + +/** + * Find #import/#include directives in a specific file. + * + * \param TU translation unit containing the file to query. + * + * \param file to search for #import/#include directives. + * + * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + * each directive found. + * + * \returns one of the CXResult enumerators. + */ +CINDEX_LINKAGE CXResult clang_findIncludesInFile( + CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor); + +#if __has_feature(blocks) +typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor, + CXSourceRange); +#else +typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock; +#endif + +CINDEX_LINKAGE +CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile, + CXCursorAndRangeVisitorBlock); + +CINDEX_LINKAGE +CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile, + CXCursorAndRangeVisitorBlock); + +/** + * The client's data object that is associated with a CXFile. + */ +typedef void *CXIdxClientFile; + +/** + * The client's data object that is associated with a semantic entity. + */ +typedef void *CXIdxClientEntity; + +/** + * The client's data object that is associated with a semantic container + * of entities. + */ +typedef void *CXIdxClientContainer; + +/** + * The client's data object that is associated with an AST file (PCH + * or module). + */ +typedef void *CXIdxClientASTFile; + +/** + * Source location passed to index callbacks. + */ +typedef struct { + void *ptr_data[2]; + unsigned int_data; +} CXIdxLoc; + +/** + * Data for ppIncludedFile callback. + */ +typedef struct { + /** + * Location of '#' in the \#include/\#import directive. + */ + CXIdxLoc hashLoc; + /** + * Filename as written in the \#include/\#import directive. + */ + const char *filename; + /** + * The actual file that the \#include/\#import directive resolved to. + */ + CXFile file; + int isImport; + int isAngled; + /** + * Non-zero if the directive was automatically turned into a module + * import. + */ + int isModuleImport; +} CXIdxIncludedFileInfo; + +/** + * Data for IndexerCallbacks#importedASTFile. + */ +typedef struct { + /** + * Top level AST file containing the imported PCH, module or submodule. + */ + CXFile file; + /** + * The imported module or NULL if the AST file is a PCH. + */ + CXModule module; + /** + * Location where the file is imported. Applicable only for modules. + */ + CXIdxLoc loc; + /** + * Non-zero if an inclusion directive was automatically turned into + * a module import. Applicable only for modules. + */ + int isImplicit; + +} CXIdxImportedASTFileInfo; + +typedef enum { + CXIdxEntity_Unexposed = 0, + CXIdxEntity_Typedef = 1, + CXIdxEntity_Function = 2, + CXIdxEntity_Variable = 3, + CXIdxEntity_Field = 4, + CXIdxEntity_EnumConstant = 5, + + CXIdxEntity_ObjCClass = 6, + CXIdxEntity_ObjCProtocol = 7, + CXIdxEntity_ObjCCategory = 8, + + CXIdxEntity_ObjCInstanceMethod = 9, + CXIdxEntity_ObjCClassMethod = 10, + CXIdxEntity_ObjCProperty = 11, + CXIdxEntity_ObjCIvar = 12, + + CXIdxEntity_Enum = 13, + CXIdxEntity_Struct = 14, + CXIdxEntity_Union = 15, + + CXIdxEntity_CXXClass = 16, + CXIdxEntity_CXXNamespace = 17, + CXIdxEntity_CXXNamespaceAlias = 18, + CXIdxEntity_CXXStaticVariable = 19, + CXIdxEntity_CXXStaticMethod = 20, + CXIdxEntity_CXXInstanceMethod = 21, + CXIdxEntity_CXXConstructor = 22, + CXIdxEntity_CXXDestructor = 23, + CXIdxEntity_CXXConversionFunction = 24, + CXIdxEntity_CXXTypeAlias = 25, + CXIdxEntity_CXXInterface = 26, + CXIdxEntity_CXXConcept = 27 + +} CXIdxEntityKind; + +typedef enum { + CXIdxEntityLang_None = 0, + CXIdxEntityLang_C = 1, + CXIdxEntityLang_ObjC = 2, + CXIdxEntityLang_CXX = 3, + CXIdxEntityLang_Swift = 4 +} CXIdxEntityLanguage; + +/** + * Extra C++ template information for an entity. This can apply to: + * CXIdxEntity_Function + * CXIdxEntity_CXXClass + * CXIdxEntity_CXXStaticMethod + * CXIdxEntity_CXXInstanceMethod + * CXIdxEntity_CXXConstructor + * CXIdxEntity_CXXConversionFunction + * CXIdxEntity_CXXTypeAlias + */ +typedef enum { + CXIdxEntity_NonTemplate = 0, + CXIdxEntity_Template = 1, + CXIdxEntity_TemplatePartialSpecialization = 2, + CXIdxEntity_TemplateSpecialization = 3 +} CXIdxEntityCXXTemplateKind; + +typedef enum { + CXIdxAttr_Unexposed = 0, + CXIdxAttr_IBAction = 1, + CXIdxAttr_IBOutlet = 2, + CXIdxAttr_IBOutletCollection = 3 +} CXIdxAttrKind; + +typedef struct { + CXIdxAttrKind kind; + CXCursor cursor; + CXIdxLoc loc; +} CXIdxAttrInfo; + +typedef struct { + CXIdxEntityKind kind; + CXIdxEntityCXXTemplateKind templateKind; + CXIdxEntityLanguage lang; + const char *name; + const char *USR; + CXCursor cursor; + const CXIdxAttrInfo *const *attributes; + unsigned numAttributes; +} CXIdxEntityInfo; + +typedef struct { + CXCursor cursor; +} CXIdxContainerInfo; + +typedef struct { + const CXIdxAttrInfo *attrInfo; + const CXIdxEntityInfo *objcClass; + CXCursor classCursor; + CXIdxLoc classLoc; +} CXIdxIBOutletCollectionAttrInfo; + +typedef enum { CXIdxDeclFlag_Skipped = 0x1 } CXIdxDeclInfoFlags; + +typedef struct { + const CXIdxEntityInfo *entityInfo; + CXCursor cursor; + CXIdxLoc loc; + const CXIdxContainerInfo *semanticContainer; + /** + * Generally same as #semanticContainer but can be different in + * cases like out-of-line C++ member functions. + */ + const CXIdxContainerInfo *lexicalContainer; + int isRedeclaration; + int isDefinition; + int isContainer; + const CXIdxContainerInfo *declAsContainer; + /** + * Whether the declaration exists in code or was created implicitly + * by the compiler, e.g. implicit Objective-C methods for properties. + */ + int isImplicit; + const CXIdxAttrInfo *const *attributes; + unsigned numAttributes; + + unsigned flags; + +} CXIdxDeclInfo; + +typedef enum { + CXIdxObjCContainer_ForwardRef = 0, + CXIdxObjCContainer_Interface = 1, + CXIdxObjCContainer_Implementation = 2 +} CXIdxObjCContainerKind; + +typedef struct { + const CXIdxDeclInfo *declInfo; + CXIdxObjCContainerKind kind; +} CXIdxObjCContainerDeclInfo; + +typedef struct { + const CXIdxEntityInfo *base; + CXCursor cursor; + CXIdxLoc loc; +} CXIdxBaseClassInfo; + +typedef struct { + const CXIdxEntityInfo *protocol; + CXCursor cursor; + CXIdxLoc loc; +} CXIdxObjCProtocolRefInfo; + +typedef struct { + const CXIdxObjCProtocolRefInfo *const *protocols; + unsigned numProtocols; +} CXIdxObjCProtocolRefListInfo; + +typedef struct { + const CXIdxObjCContainerDeclInfo *containerInfo; + const CXIdxBaseClassInfo *superInfo; + const CXIdxObjCProtocolRefListInfo *protocols; +} CXIdxObjCInterfaceDeclInfo; + +typedef struct { + const CXIdxObjCContainerDeclInfo *containerInfo; + const CXIdxEntityInfo *objcClass; + CXCursor classCursor; + CXIdxLoc classLoc; + const CXIdxObjCProtocolRefListInfo *protocols; +} CXIdxObjCCategoryDeclInfo; + +typedef struct { + const CXIdxDeclInfo *declInfo; + const CXIdxEntityInfo *getter; + const CXIdxEntityInfo *setter; +} CXIdxObjCPropertyDeclInfo; + +typedef struct { + const CXIdxDeclInfo *declInfo; + const CXIdxBaseClassInfo *const *bases; + unsigned numBases; +} CXIdxCXXClassDeclInfo; + +/** + * Data for IndexerCallbacks#indexEntityReference. + * + * This may be deprecated in a future version as this duplicates + * the \c CXSymbolRole_Implicit bit in \c CXSymbolRole. + */ +typedef enum { + /** + * The entity is referenced directly in user's code. + */ + CXIdxEntityRef_Direct = 1, + /** + * An implicit reference, e.g. a reference of an Objective-C method + * via the dot syntax. + */ + CXIdxEntityRef_Implicit = 2 +} CXIdxEntityRefKind; + +/** + * Roles that are attributed to symbol occurrences. + * + * Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with + * higher bits zeroed. These high bits may be exposed in the future. + */ +typedef enum { + CXSymbolRole_None = 0, + CXSymbolRole_Declaration = 1 << 0, + CXSymbolRole_Definition = 1 << 1, + CXSymbolRole_Reference = 1 << 2, + CXSymbolRole_Read = 1 << 3, + CXSymbolRole_Write = 1 << 4, + CXSymbolRole_Call = 1 << 5, + CXSymbolRole_Dynamic = 1 << 6, + CXSymbolRole_AddressOf = 1 << 7, + CXSymbolRole_Implicit = 1 << 8 +} CXSymbolRole; + +/** + * Data for IndexerCallbacks#indexEntityReference. + */ +typedef struct { + CXIdxEntityRefKind kind; + /** + * Reference cursor. + */ + CXCursor cursor; + CXIdxLoc loc; + /** + * The entity that gets referenced. + */ + const CXIdxEntityInfo *referencedEntity; + /** + * Immediate "parent" of the reference. For example: + * + * \code + * Foo *var; + * \endcode + * + * The parent of reference of type 'Foo' is the variable 'var'. + * For references inside statement bodies of functions/methods, + * the parentEntity will be the function/method. + */ + const CXIdxEntityInfo *parentEntity; + /** + * Lexical container context of the reference. + */ + const CXIdxContainerInfo *container; + /** + * Sets of symbol roles of the reference. + */ + CXSymbolRole role; +} CXIdxEntityRefInfo; + +/** + * A group of callbacks used by #clang_indexSourceFile and + * #clang_indexTranslationUnit. + */ +typedef struct { + /** + * Called periodically to check whether indexing should be aborted. + * Should return 0 to continue, and non-zero to abort. + */ + int (*abortQuery)(CXClientData client_data, void *reserved); + + /** + * Called at the end of indexing; passes the complete diagnostic set. + */ + void (*diagnostic)(CXClientData client_data, CXDiagnosticSet, void *reserved); + + CXIdxClientFile (*enteredMainFile)(CXClientData client_data, CXFile mainFile, + void *reserved); + + /** + * Called when a file gets \#included/\#imported. + */ + CXIdxClientFile (*ppIncludedFile)(CXClientData client_data, + const CXIdxIncludedFileInfo *); + + /** + * Called when a AST file (PCH or module) gets imported. + * + * AST files will not get indexed (there will not be callbacks to index all + * the entities in an AST file). The recommended action is that, if the AST + * file is not already indexed, to initiate a new indexing job specific to + * the AST file. + */ + CXIdxClientASTFile (*importedASTFile)(CXClientData client_data, + const CXIdxImportedASTFileInfo *); + + /** + * Called at the beginning of indexing a translation unit. + */ + CXIdxClientContainer (*startedTranslationUnit)(CXClientData client_data, + void *reserved); + + void (*indexDeclaration)(CXClientData client_data, const CXIdxDeclInfo *); + + /** + * Called to index a reference of an entity. + */ + void (*indexEntityReference)(CXClientData client_data, + const CXIdxEntityRefInfo *); + +} IndexerCallbacks; + +CINDEX_LINKAGE int clang_index_isEntityObjCContainerKind(CXIdxEntityKind); +CINDEX_LINKAGE const CXIdxObjCContainerDeclInfo * +clang_index_getObjCContainerDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxObjCInterfaceDeclInfo * +clang_index_getObjCInterfaceDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE +const CXIdxObjCCategoryDeclInfo * +clang_index_getObjCCategoryDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxObjCProtocolRefListInfo * +clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxObjCPropertyDeclInfo * +clang_index_getObjCPropertyDeclInfo(const CXIdxDeclInfo *); + +CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo * +clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *); + +CINDEX_LINKAGE const CXIdxCXXClassDeclInfo * +clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *); + +/** + * For retrieving a custom CXIdxClientContainer attached to a + * container. + */ +CINDEX_LINKAGE CXIdxClientContainer +clang_index_getClientContainer(const CXIdxContainerInfo *); + +/** + * For setting a custom CXIdxClientContainer attached to a + * container. + */ +CINDEX_LINKAGE void clang_index_setClientContainer(const CXIdxContainerInfo *, + CXIdxClientContainer); + +/** + * For retrieving a custom CXIdxClientEntity attached to an entity. + */ +CINDEX_LINKAGE CXIdxClientEntity +clang_index_getClientEntity(const CXIdxEntityInfo *); + +/** + * For setting a custom CXIdxClientEntity attached to an entity. + */ +CINDEX_LINKAGE void clang_index_setClientEntity(const CXIdxEntityInfo *, + CXIdxClientEntity); + +/** + * An indexing action/session, to be applied to one or multiple + * translation units. + */ +typedef void *CXIndexAction; + +/** + * An indexing action/session, to be applied to one or multiple + * translation units. + * + * \param CIdx The index object with which the index action will be associated. + */ +CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx); + +/** + * Destroy the given index action. + * + * The index action must not be destroyed until all of the translation units + * created within that index action have been destroyed. + */ +CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction); + +typedef enum { + /** + * Used to indicate that no special indexing options are needed. + */ + CXIndexOpt_None = 0x0, + + /** + * Used to indicate that IndexerCallbacks#indexEntityReference should + * be invoked for only one reference of an entity per source file that does + * not also include a declaration/definition of the entity. + */ + CXIndexOpt_SuppressRedundantRefs = 0x1, + + /** + * Function-local symbols should be indexed. If this is not set + * function-local symbols will be ignored. + */ + CXIndexOpt_IndexFunctionLocalSymbols = 0x2, + + /** + * Implicit function/class template instantiations should be indexed. + * If this is not set, implicit instantiations will be ignored. + */ + CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, + + /** + * Suppress all compiler warnings when parsing for indexing. + */ + CXIndexOpt_SuppressWarnings = 0x8, + + /** + * Skip a function/method body that was already parsed during an + * indexing session associated with a \c CXIndexAction object. + * Bodies in system headers are always skipped. + */ + CXIndexOpt_SkipParsedBodiesInSession = 0x10 + +} CXIndexOptFlags; + +/** + * Index the given source file and the translation unit corresponding + * to that file via callbacks implemented through #IndexerCallbacks. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the invoked callbacks. + * + * \param index_callbacks Pointer to indexing callbacks that the client + * implements. + * + * \param index_callbacks_size Size of #IndexerCallbacks structure that gets + * passed in index_callbacks. + * + * \param index_options A bitmask of options that affects how indexing is + * performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. + * + * \param[out] out_TU pointer to store a \c CXTranslationUnit that can be + * reused after indexing is finished. Set to \c NULL if you do not require it. + * + * \returns 0 on success or if there were errors from which the compiler could + * recover. If there is a failure from which there is no recovery, returns + * a non-zero \c CXErrorCode. + * + * The rest of the parameters are the same as #clang_parseTranslationUnit. + */ +CINDEX_LINKAGE int clang_indexSourceFile( + CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, + unsigned index_callbacks_size, unsigned index_options, + const char *source_filename, const char *const *command_line_args, + int num_command_line_args, struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); + +/** + * Same as clang_indexSourceFile but requires a full command line + * for \c command_line_args including argv[0]. This is useful if the standard + * library paths are relative to the binary. + */ +CINDEX_LINKAGE int clang_indexSourceFileFullArgv( + CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, + unsigned index_callbacks_size, unsigned index_options, + const char *source_filename, const char *const *command_line_args, + int num_command_line_args, struct CXUnsavedFile *unsaved_files, + unsigned num_unsaved_files, CXTranslationUnit *out_TU, unsigned TU_options); + +/** + * Index the given translation unit via callbacks implemented through + * #IndexerCallbacks. + * + * The order of callback invocations is not guaranteed to be the same as + * when indexing a source file. The high level order will be: + * + * -Preprocessor callbacks invocations + * -Declaration/reference callbacks invocations + * -Diagnostic callback invocations + * + * The parameters are the same as #clang_indexSourceFile. + * + * \returns If there is a failure from which there is no recovery, returns + * non-zero, otherwise returns 0. + */ +CINDEX_LINKAGE int clang_indexTranslationUnit( + CXIndexAction, CXClientData client_data, IndexerCallbacks *index_callbacks, + unsigned index_callbacks_size, unsigned index_options, CXTranslationUnit); + +/** + * Retrieve the CXIdxFile, file, line, column, and offset represented by + * the given CXIdxLoc. + * + * If the location refers into a macro expansion, retrieves the + * location of the macro expansion and if it refers into a macro argument + * retrieves the location of the argument. + */ +CINDEX_LINKAGE void clang_indexLoc_getFileLocation(CXIdxLoc loc, + CXIdxClientFile *indexFile, + CXFile *file, unsigned *line, + unsigned *column, + unsigned *offset); + +/** + * Retrieve the CXSourceLocation represented by the given CXIdxLoc. + */ +CINDEX_LINKAGE +CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc); + +/** + * Visitor invoked for each field found by a traversal. + * + * This visitor function will be invoked for each field found by + * \c clang_Type_visitFields. Its first argument is the cursor being + * visited, its second argument is the client data provided to + * \c clang_Type_visitFields. + * + * The visitor should return one of the \c CXVisitorResult values + * to direct \c clang_Type_visitFields. + */ +typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor C, + CXClientData client_data); + +/** + * Visit the fields of a particular type. + * + * This function visits all the direct fields of the given cursor, + * invoking the given \p visitor function with the cursors of each + * visited field. The traversal may be ended prematurely, if + * the visitor returns \c CXFieldVisit_Break. + * + * \param T the record type whose field may be visited. + * + * \param visitor the visitor function that will be invoked for each + * field of \p T. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the visitor each time it is invoked. + * + * \returns a non-zero value if the traversal was terminated + * prematurely by the visitor returning \c CXFieldVisit_Break. + */ +CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor visitor, + CXClientData client_data); + +/** + * Visit the base classes of a type. + * + * This function visits all the direct base classes of a the given cursor, + * invoking the given \p visitor function with the cursors of each + * visited base. The traversal may be ended prematurely, if + * the visitor returns \c CXFieldVisit_Break. + * + * \param T the record type whose field may be visited. + * + * \param visitor the visitor function that will be invoked for each + * field of \p T. + * + * \param client_data pointer data supplied by the client, which will + * be passed to the visitor each time it is invoked. + * + * \returns a non-zero value if the traversal was terminated + * prematurely by the visitor returning \c CXFieldVisit_Break. + */ +CINDEX_LINKAGE unsigned clang_visitCXXBaseClasses(CXType T, + CXFieldVisitor visitor, + CXClientData client_data); + +/** + * Visit the class methods of a type. + * + * This function visits all the methods of the given cursor, + * invoking the given \p visitor function with the cursors of each + * visited method. The traversal may be ended prematurely, if + * the visitor returns \c CXFieldVisit_Break. + * + * \param T The record type whose field may be visited. + * + * \param visitor The visitor function that will be invoked for each + * field of \p T. + * + * \param client_data Pointer data supplied by the client, which will + * be passed to the visitor each time it is invoked. + * + * \returns A non-zero value if the traversal was terminated + * prematurely by the visitor returning \c CXFieldVisit_Break. + */ +CINDEX_LINKAGE unsigned clang_visitCXXMethods(CXType T, CXFieldVisitor visitor, + CXClientData client_data); + +/** + * Describes the kind of binary operators. + */ +enum CXBinaryOperatorKind { + /** This value describes cursors which are not binary operators. */ + CXBinaryOperator_Invalid = 0, + /** C++ Pointer - to - member operator. */ + CXBinaryOperator_PtrMemD = 1, + /** C++ Pointer - to - member operator. */ + CXBinaryOperator_PtrMemI = 2, + /** Multiplication operator. */ + CXBinaryOperator_Mul = 3, + /** Division operator. */ + CXBinaryOperator_Div = 4, + /** Remainder operator. */ + CXBinaryOperator_Rem = 5, + /** Addition operator. */ + CXBinaryOperator_Add = 6, + /** Subtraction operator. */ + CXBinaryOperator_Sub = 7, + /** Bitwise shift left operator. */ + CXBinaryOperator_Shl = 8, + /** Bitwise shift right operator. */ + CXBinaryOperator_Shr = 9, + /** C++ three-way comparison (spaceship) operator. */ + CXBinaryOperator_Cmp = 10, + /** Less than operator. */ + CXBinaryOperator_LT = 11, + /** Greater than operator. */ + CXBinaryOperator_GT = 12, + /** Less or equal operator. */ + CXBinaryOperator_LE = 13, + /** Greater or equal operator. */ + CXBinaryOperator_GE = 14, + /** Equal operator. */ + CXBinaryOperator_EQ = 15, + /** Not equal operator. */ + CXBinaryOperator_NE = 16, + /** Bitwise AND operator. */ + CXBinaryOperator_And = 17, + /** Bitwise XOR operator. */ + CXBinaryOperator_Xor = 18, + /** Bitwise OR operator. */ + CXBinaryOperator_Or = 19, + /** Logical AND operator. */ + CXBinaryOperator_LAnd = 20, + /** Logical OR operator. */ + CXBinaryOperator_LOr = 21, + /** Assignment operator. */ + CXBinaryOperator_Assign = 22, + /** Multiplication assignment operator. */ + CXBinaryOperator_MulAssign = 23, + /** Division assignment operator. */ + CXBinaryOperator_DivAssign = 24, + /** Remainder assignment operator. */ + CXBinaryOperator_RemAssign = 25, + /** Addition assignment operator. */ + CXBinaryOperator_AddAssign = 26, + /** Subtraction assignment operator. */ + CXBinaryOperator_SubAssign = 27, + /** Bitwise shift left assignment operator. */ + CXBinaryOperator_ShlAssign = 28, + /** Bitwise shift right assignment operator. */ + CXBinaryOperator_ShrAssign = 29, + /** Bitwise AND assignment operator. */ + CXBinaryOperator_AndAssign = 30, + /** Bitwise XOR assignment operator. */ + CXBinaryOperator_XorAssign = 31, + /** Bitwise OR assignment operator. */ + CXBinaryOperator_OrAssign = 32, + /** Comma operator. */ + CXBinaryOperator_Comma = 33, + CXBinaryOperator_Last = CXBinaryOperator_Comma +}; + +/** + * Retrieve the spelling of a given CXBinaryOperatorKind. + */ +CINDEX_LINKAGE CXString +clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind); + +/** + * Retrieve the binary operator kind of this cursor. + * + * If this cursor is not a binary operator then returns Invalid. + */ +CINDEX_LINKAGE enum CXBinaryOperatorKind +clang_getCursorBinaryOperatorKind(CXCursor cursor); + +/** + * Describes the kind of unary operators. + */ +enum CXUnaryOperatorKind { + /** This value describes cursors which are not unary operators. */ + CXUnaryOperator_Invalid, + /** Postfix increment operator. */ + CXUnaryOperator_PostInc, + /** Postfix decrement operator. */ + CXUnaryOperator_PostDec, + /** Prefix increment operator. */ + CXUnaryOperator_PreInc, + /** Prefix decrement operator. */ + CXUnaryOperator_PreDec, + /** Address of operator. */ + CXUnaryOperator_AddrOf, + /** Dereference operator. */ + CXUnaryOperator_Deref, + /** Plus operator. */ + CXUnaryOperator_Plus, + /** Minus operator. */ + CXUnaryOperator_Minus, + /** Not operator. */ + CXUnaryOperator_Not, + /** LNot operator. */ + CXUnaryOperator_LNot, + /** "__real expr" operator. */ + CXUnaryOperator_Real, + /** "__imag expr" operator. */ + CXUnaryOperator_Imag, + /** __extension__ marker operator. */ + CXUnaryOperator_Extension, + /** C++ co_await operator. */ + CXUnaryOperator_Coawait +}; + +/** + * Retrieve the spelling of a given CXUnaryOperatorKind. + */ +CINDEX_LINKAGE CXString +clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind); + +/** + * Retrieve the unary operator kind of this cursor. + * + * If this cursor is not a unary operator then returns Invalid. + */ +CINDEX_LINKAGE enum CXUnaryOperatorKind +clang_getCursorUnaryOperatorKind(CXCursor cursor); + +/** + * @} + */ + +/** + * @} + */ + +CINDEX_DEPRECATED +typedef void *CXRemapping; + +CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *); + +CINDEX_DEPRECATED CINDEX_LINKAGE CXRemapping +clang_getRemappingsFromFileList(const char **, unsigned); + +CINDEX_DEPRECATED CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping); + +CINDEX_DEPRECATED CINDEX_LINKAGE void +clang_remap_getFilenames(CXRemapping, unsigned, CXString *, CXString *); + +CINDEX_DEPRECATED CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Platform.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Platform.h new file mode 100755 index 0000000..8d341dd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Platform.h @@ -0,0 +1,53 @@ +/*===-- clang-c/Platform.h - C Index platform decls -------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides platform specific macros (dllimport, deprecated, ...) *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_PLATFORM_H +#define LLVM_CLANG_C_PLATFORM_H + +#include "clang-c/ExternC.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +/* Windows DLL import/export. */ +#ifndef CINDEX_NO_EXPORTS + #define CINDEX_EXPORTS +#endif +#if defined(_WIN32) || defined(__CYGWIN__) + #ifdef CINDEX_EXPORTS + #ifdef _CINDEX_LIB_ + #define CINDEX_LINKAGE __declspec(dllexport) + #else + #define CINDEX_LINKAGE __declspec(dllimport) + #endif + #endif +#elif defined(CINDEX_EXPORTS) && defined(__GNUC__) + #define CINDEX_LINKAGE __attribute__((visibility("default"))) +#endif + +#ifndef CINDEX_LINKAGE + #define CINDEX_LINKAGE +#endif + +#ifdef __GNUC__ + #define CINDEX_DEPRECATED __attribute__((deprecated)) +#else + #ifdef _MSC_VER + #define CINDEX_DEPRECATED __declspec(deprecated) + #else + #define CINDEX_DEPRECATED + #endif +#endif + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Rewrite.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Rewrite.h new file mode 100755 index 0000000..ce1b055 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/clang-c/Rewrite.h @@ -0,0 +1,63 @@ +/*===-- clang-c/Rewrite.h - C CXRewriter --------------------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_CLANG_C_REWRITE_H +#define LLVM_CLANG_C_REWRITE_H + +#include "clang-c/CXString.h" +#include "clang-c/ExternC.h" +#include "clang-c/Index.h" +#include "clang-c/Platform.h" + +LLVM_CLANG_C_EXTERN_C_BEGIN + +typedef void *CXRewriter; + +/** + * Create CXRewriter. + */ +CINDEX_LINKAGE CXRewriter clang_CXRewriter_create(CXTranslationUnit TU); + +/** + * Insert the specified string at the specified location in the original buffer. + */ +CINDEX_LINKAGE void clang_CXRewriter_insertTextBefore(CXRewriter Rew, CXSourceLocation Loc, + const char *Insert); + +/** + * Replace the specified range of characters in the input with the specified + * replacement. + */ +CINDEX_LINKAGE void clang_CXRewriter_replaceText(CXRewriter Rew, CXSourceRange ToBeReplaced, + const char *Replacement); + +/** + * Remove the specified range. + */ +CINDEX_LINKAGE void clang_CXRewriter_removeText(CXRewriter Rew, CXSourceRange ToBeRemoved); + +/** + * Save all changed files to disk. + * Returns 1 if any files were not saved successfully, returns 0 otherwise. + */ +CINDEX_LINKAGE int clang_CXRewriter_overwriteChangedFiles(CXRewriter Rew); + +/** + * Write out rewritten version of the main file to stdout. + */ +CINDEX_LINKAGE void clang_CXRewriter_writeMainFileToStdOut(CXRewriter Rew); + +/** + * Free the given CXRewriter. + */ +CINDEX_LINKAGE void clang_CXRewriter_dispose(CXRewriter Rew); + +LLVM_CLANG_C_EXTERN_C_END + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/llvm-c/Remarks.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/llvm-c/Remarks.h new file mode 100755 index 0000000..b3468a5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/llvm-c/Remarks.h @@ -0,0 +1,354 @@ +/*===-- llvm-c/Remarks.h - Remarks Public C Interface -------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides a public interface to a remark diagnostics library. *| +|* LLVM provides an implementation of this interface. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_REMARKS_H +#define LLVM_C_REMARKS_H + +#include "llvm-c/ExternC.h" +#include "llvm-c/Types.h" +#include "llvm-c/Visibility.h" +#ifdef __cplusplus +#include +#else +#include +#endif /* !defined(__cplusplus) */ + +LLVM_C_EXTERN_C_BEGIN + +/** + * @defgroup LLVMCREMARKS Remarks + * @ingroup LLVMC + * + * @{ + */ + +// 0 -> 1: Bitstream remarks support. +#define REMARKS_API_VERSION 1 + +/** + * The type of the emitted remark. + */ +enum LLVMRemarkType { + LLVMRemarkTypeUnknown, + LLVMRemarkTypePassed, + LLVMRemarkTypeMissed, + LLVMRemarkTypeAnalysis, + LLVMRemarkTypeAnalysisFPCommute, + LLVMRemarkTypeAnalysisAliasing, + LLVMRemarkTypeFailure +}; + +/** + * String containing a buffer and a length. The buffer is not guaranteed to be + * zero-terminated. + * + * \since REMARKS_API_VERSION=0 + */ +typedef struct LLVMRemarkOpaqueString *LLVMRemarkStringRef; + +/** + * Returns the buffer holding the string. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern const char * +LLVMRemarkStringGetData(LLVMRemarkStringRef String); + +/** + * Returns the size of the string. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern uint32_t LLVMRemarkStringGetLen(LLVMRemarkStringRef String); + +/** + * DebugLoc containing File, Line and Column. + * + * \since REMARKS_API_VERSION=0 + */ +typedef struct LLVMRemarkOpaqueDebugLoc *LLVMRemarkDebugLocRef; + +/** + * Return the path to the source file for a debug location. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkStringRef +LLVMRemarkDebugLocGetSourceFilePath(LLVMRemarkDebugLocRef DL); + +/** + * Return the line in the source file for a debug location. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern uint32_t +LLVMRemarkDebugLocGetSourceLine(LLVMRemarkDebugLocRef DL); + +/** + * Return the column in the source file for a debug location. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern uint32_t +LLVMRemarkDebugLocGetSourceColumn(LLVMRemarkDebugLocRef DL); + +/** + * Element of the "Args" list. The key might give more information about what + * the semantics of the value are, e.g. "Callee" will tell you that the value + * is a symbol that names a function. + * + * \since REMARKS_API_VERSION=0 + */ +typedef struct LLVMRemarkOpaqueArg *LLVMRemarkArgRef; + +/** + * Returns the key of an argument. The key defines what the value is, and the + * same key can appear multiple times in the list of arguments. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkStringRef LLVMRemarkArgGetKey(LLVMRemarkArgRef Arg); + +/** + * Returns the value of an argument. This is a string that can contain newlines. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkStringRef +LLVMRemarkArgGetValue(LLVMRemarkArgRef Arg); + +/** + * Returns the debug location that is attached to the value of this argument. + * + * If there is no debug location, the return value will be `NULL`. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkDebugLocRef +LLVMRemarkArgGetDebugLoc(LLVMRemarkArgRef Arg); + +/** + * A remark emitted by the compiler. + * + * \since REMARKS_API_VERSION=0 + */ +typedef struct LLVMRemarkOpaqueEntry *LLVMRemarkEntryRef; + +/** + * Free the resources used by the remark entry. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern void LLVMRemarkEntryDispose(LLVMRemarkEntryRef Remark); + +/** + * The type of the remark. For example, it can allow users to only keep the + * missed optimizations from the compiler. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern enum LLVMRemarkType +LLVMRemarkEntryGetType(LLVMRemarkEntryRef Remark); + +/** + * Get the name of the pass that emitted this remark. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkStringRef +LLVMRemarkEntryGetPassName(LLVMRemarkEntryRef Remark); + +/** + * Get an identifier of the remark. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkStringRef +LLVMRemarkEntryGetRemarkName(LLVMRemarkEntryRef Remark); + +/** + * Get the name of the function being processed when the remark was emitted. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkStringRef +LLVMRemarkEntryGetFunctionName(LLVMRemarkEntryRef Remark); + +/** + * Returns the debug location that is attached to this remark. + * + * If there is no debug location, the return value will be `NULL`. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkDebugLocRef +LLVMRemarkEntryGetDebugLoc(LLVMRemarkEntryRef Remark); + +/** + * Return the hotness of the remark. + * + * A hotness of `0` means this value is not set. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern uint64_t LLVMRemarkEntryGetHotness(LLVMRemarkEntryRef Remark); + +/** + * The number of arguments the remark holds. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern uint32_t LLVMRemarkEntryGetNumArgs(LLVMRemarkEntryRef Remark); + +/** + * Get a new iterator to iterate over a remark's argument. + * + * If there are no arguments in \p Remark, the return value will be `NULL`. + * + * The lifetime of the returned value is bound to the lifetime of \p Remark. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkArgRef +LLVMRemarkEntryGetFirstArg(LLVMRemarkEntryRef Remark); + +/** + * Get the next argument in \p Remark from the position of \p It. + * + * Returns `NULL` if there are no more arguments available. + * + * The lifetime of the returned value is bound to the lifetime of \p Remark. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkArgRef +LLVMRemarkEntryGetNextArg(LLVMRemarkArgRef It, LLVMRemarkEntryRef Remark); + +typedef struct LLVMRemarkOpaqueParser *LLVMRemarkParserRef; + +/** + * Creates a remark parser that can be used to parse the buffer located in \p + * Buf of size \p Size bytes. + * + * \p Buf cannot be `NULL`. + * + * This function should be paired with LLVMRemarkParserDispose() to avoid + * leaking resources. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkParserRef +LLVMRemarkParserCreateYAML(const void *Buf, uint64_t Size); + +/** + * Creates a remark parser that can be used to parse the buffer located in \p + * Buf of size \p Size bytes. + * + * \p Buf cannot be `NULL`. + * + * This function should be paired with LLVMRemarkParserDispose() to avoid + * leaking resources. + * + * \since REMARKS_API_VERSION=1 + */ +LLVM_C_ABI extern LLVMRemarkParserRef +LLVMRemarkParserCreateBitstream(const void *Buf, uint64_t Size); + +/** + * Returns the next remark in the file. + * + * The value pointed to by the return value needs to be disposed using a call to + * LLVMRemarkEntryDispose(). + * + * All the entries in the returned value that are of LLVMRemarkStringRef type + * will become invalidated once a call to LLVMRemarkParserDispose is made. + * + * If the parser reaches the end of the buffer, the return value will be `NULL`. + * + * In the case of an error, the return value will be `NULL`, and: + * + * 1) LLVMRemarkParserHasError() will return `1`. + * + * 2) LLVMRemarkParserGetErrorMessage() will return a descriptive error + * message. + * + * An error may occur if: + * + * 1) An argument is invalid. + * + * 2) There is a parsing error. This can occur on things like malformed YAML. + * + * 3) There is a Remark semantic error. This can occur on well-formed files with + * missing or extra fields. + * + * Here is a quick example of the usage: + * + * ``` + * LLVMRemarkParserRef Parser = LLVMRemarkParserCreateYAML(Buf, Size); + * LLVMRemarkEntryRef Remark = NULL; + * while ((Remark = LLVMRemarkParserGetNext(Parser))) { + * // use Remark + * LLVMRemarkEntryDispose(Remark); // Release memory. + * } + * bool HasError = LLVMRemarkParserHasError(Parser); + * LLVMRemarkParserDispose(Parser); + * ``` + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMRemarkEntryRef +LLVMRemarkParserGetNext(LLVMRemarkParserRef Parser); + +/** + * Returns `1` if the parser encountered an error while parsing the buffer. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern LLVMBool LLVMRemarkParserHasError(LLVMRemarkParserRef Parser); + +/** + * Returns a null-terminated string containing an error message. + * + * In case of no error, the result is `NULL`. + * + * The memory of the string is bound to the lifetime of \p Parser. If + * LLVMRemarkParserDispose() is called, the memory of the string will be + * released. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern const char * +LLVMRemarkParserGetErrorMessage(LLVMRemarkParserRef Parser); + +/** + * Releases all the resources used by \p Parser. + * + * \since REMARKS_API_VERSION=0 + */ +LLVM_C_ABI extern void LLVMRemarkParserDispose(LLVMRemarkParserRef Parser); + +/** + * Returns the version of the remarks library. + * + * \since REMARKS_API_VERSION=0 + */ +extern uint32_t LLVMRemarkVersion(void); + +/** + * @} // endgoup LLVMCREMARKS + */ + +LLVM_C_EXTERN_C_END + +#endif /* LLVM_C_REMARKS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/llvm-c/lto.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/llvm-c/lto.h new file mode 100755 index 0000000..91195b0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/include/llvm-c/lto.h @@ -0,0 +1,974 @@ +/*===-- llvm-c/lto.h - LTO Public C Interface ---------------------*- C -*-===*\ +|* *| +|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| +|* Exceptions. *| +|* See https://llvm.org/LICENSE.txt for license information. *| +|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides public interface to an abstract link time optimization*| +|* library. LLVM provides an implementation of this interface for use with *| +|* llvm bitcode files. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_LTO_H +#define LLVM_C_LTO_H + +#include "llvm-c/ExternC.h" + +#ifdef __cplusplus +#include +#else +#include +#endif +#include + +#ifndef __cplusplus +#if !defined(_MSC_VER) +#include +typedef bool lto_bool_t; +#else +/* MSVC in particular does not have anything like _Bool or bool in C, but we can + at least make sure the type is the same size. The implementation side will + use C++ bool. */ +typedef unsigned char lto_bool_t; +#endif +#else +typedef bool lto_bool_t; +#endif + +/** + * @defgroup LLVMCLTO LTO + * @ingroup LLVMC + * + * @{ + */ + +#define LTO_API_VERSION 30 + +/** + * \since prior to LTO_API_VERSION=3 + */ +typedef enum { + LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ + LTO_SYMBOL_PERMISSIONS_MASK = 0x000000E0, + LTO_SYMBOL_PERMISSIONS_CODE = 0x000000A0, + LTO_SYMBOL_PERMISSIONS_DATA = 0x000000C0, + LTO_SYMBOL_PERMISSIONS_RODATA = 0x00000080, + LTO_SYMBOL_DEFINITION_MASK = 0x00000700, + LTO_SYMBOL_DEFINITION_REGULAR = 0x00000100, + LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200, + LTO_SYMBOL_DEFINITION_WEAK = 0x00000300, + LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400, + LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500, + LTO_SYMBOL_SCOPE_MASK = 0x00003800, + LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800, + LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000, + LTO_SYMBOL_SCOPE_PROTECTED = 0x00002000, + LTO_SYMBOL_SCOPE_DEFAULT = 0x00001800, + LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800, + LTO_SYMBOL_COMDAT = 0x00004000, + LTO_SYMBOL_ALIAS = 0x00008000 +} lto_symbol_attributes; + +/** + * \since prior to LTO_API_VERSION=3 + */ +typedef enum { + LTO_DEBUG_MODEL_NONE = 0, + LTO_DEBUG_MODEL_DWARF = 1 +} lto_debug_model; + +/** + * \since prior to LTO_API_VERSION=3 + */ +typedef enum { + LTO_CODEGEN_PIC_MODEL_STATIC = 0, + LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1, + LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2, + LTO_CODEGEN_PIC_MODEL_DEFAULT = 3 +} lto_codegen_model; + +/** opaque reference to a loaded object module */ +typedef struct LLVMOpaqueLTOModule *lto_module_t; + +/** opaque reference to a code generator */ +typedef struct LLVMOpaqueLTOCodeGenerator *lto_code_gen_t; + +/** opaque reference to a thin code generator */ +typedef struct LLVMOpaqueThinLTOCodeGenerator *thinlto_code_gen_t; + +LLVM_C_EXTERN_C_BEGIN + +/** + * Returns a printable string. + * + * \since prior to LTO_API_VERSION=3 + */ +extern const char* +lto_get_version(void); + +/** + * Returns the last error string or NULL if last operation was successful. + * + * \since prior to LTO_API_VERSION=3 + */ +extern const char* +lto_get_error_message(void); + +/** + * Checks if a file is a loadable object file. + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t +lto_module_is_object_file(const char* path); + +/** + * Checks if a file is a loadable object compiled for requested target. + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t +lto_module_is_object_file_for_target(const char* path, + const char* target_triple_prefix); + +/** + * Return true if \p Buffer contains a bitcode file with ObjC code (category + * or class) in it. + * + * \since LTO_API_VERSION=20 + */ +extern lto_bool_t +lto_module_has_objc_category(const void *mem, size_t length); + +/** + * Checks if a buffer is a loadable object file. + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t lto_module_is_object_file_in_memory(const void *mem, + size_t length); + +/** + * Checks if a buffer is a loadable object compiled for requested target. + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t +lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, + const char* target_triple_prefix); + +/** + * Loads an object file from disk. + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_module_t +lto_module_create(const char* path); + +/** + * Loads an object file from memory. + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_module_t +lto_module_create_from_memory(const void* mem, size_t length); + +/** + * Loads an object file from memory with an extra path argument. + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=9 + */ +extern lto_module_t +lto_module_create_from_memory_with_path(const void* mem, size_t length, + const char *path); + +/** + * Loads an object file in its own context. + * + * Loads an object file in its own LLVMContext. This function call is + * thread-safe. However, modules created this way should not be merged into an + * lto_code_gen_t using \a lto_codegen_add_module(). + * + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=11 + */ +extern lto_module_t +lto_module_create_in_local_context(const void *mem, size_t length, + const char *path); + +/** + * Loads an object file in the codegen context. + * + * Loads an object file into the same context as \c cg. The module is safe to + * add using \a lto_codegen_add_module(). + * + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=11 + */ +extern lto_module_t +lto_module_create_in_codegen_context(const void *mem, size_t length, + const char *path, lto_code_gen_t cg); + +/** + * Loads an object file from disk. The seek point of fd is not preserved. + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=5 + */ +extern lto_module_t +lto_module_create_from_fd(int fd, const char *path, size_t file_size); + +/** + * Loads an object file from disk. The seek point of fd is not preserved. + * Returns NULL on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=5 + */ +extern lto_module_t +lto_module_create_from_fd_at_offset(int fd, const char *path, size_t file_size, + size_t map_size, off_t offset); + +/** + * Frees all memory internally allocated by the module. + * Upon return the lto_module_t is no longer valid. + * + * \since prior to LTO_API_VERSION=3 + */ +extern void +lto_module_dispose(lto_module_t mod); + +/** + * Returns triple string which the object module was compiled under. + * + * \since prior to LTO_API_VERSION=3 + */ +extern const char* +lto_module_get_target_triple(lto_module_t mod); + +/** + * Sets triple string with which the object will be codegened. + * + * \since LTO_API_VERSION=4 + */ +extern void +lto_module_set_target_triple(lto_module_t mod, const char *triple); + +/** + * Returns the number of symbols in the object module. + * + * \since prior to LTO_API_VERSION=3 + */ +extern unsigned int +lto_module_get_num_symbols(lto_module_t mod); + +/** + * Returns the name of the ith symbol in the object module. + * + * \since prior to LTO_API_VERSION=3 + */ +extern const char* +lto_module_get_symbol_name(lto_module_t mod, unsigned int index); + +/** + * Returns the attributes of the ith symbol in the object module. + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_symbol_attributes +lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); + +/** + * Returns the number of asm undefined symbols in the object module. + * + * \since prior to LTO_API_VERSION=30 + */ +extern unsigned int lto_module_get_num_asm_undef_symbols(lto_module_t mod); + +/** + * Returns the name of the ith asm undefined symbol in the object module. + * + * \since prior to LTO_API_VERSION=30 + */ +extern const char *lto_module_get_asm_undef_symbol_name(lto_module_t mod, + unsigned int index); + +/** + * Returns the module's linker options. + * + * The linker options may consist of multiple flags. It is the linker's + * responsibility to split the flags using a platform-specific mechanism. + * + * \since LTO_API_VERSION=16 + */ +extern const char* +lto_module_get_linkeropts(lto_module_t mod); + +/** + * If targeting mach-o on darwin, this function gets the CPU type and subtype + * that will end up being encoded in the mach-o header. These are the values + * that can be found in mach/machine.h. + * + * \p out_cputype and \p out_cpusubtype must be non-NULL. + * + * Returns true on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=27 + */ +extern lto_bool_t lto_module_get_macho_cputype(lto_module_t mod, + unsigned int *out_cputype, + unsigned int *out_cpusubtype); + +/** + * This function can be used by the linker to check if a given module has + * any constructor or destructor functions. + * + * Returns true if the module has either the @llvm.global_ctors or the + * @llvm.global_dtors symbol. Otherwise returns false. + * + * \since LTO_API_VERSION=29 + */ +extern lto_bool_t lto_module_has_ctor_dtor(lto_module_t mod); +/** + * Diagnostic severity. + * + * \since LTO_API_VERSION=7 + */ +typedef enum { + LTO_DS_ERROR = 0, + LTO_DS_WARNING = 1, + LTO_DS_REMARK = 3, // Added in LTO_API_VERSION=10. + LTO_DS_NOTE = 2 +} lto_codegen_diagnostic_severity_t; + +/** + * Diagnostic handler type. + * \p severity defines the severity. + * \p diag is the actual diagnostic. + * The diagnostic is not prefixed by any of severity keyword, e.g., 'error: '. + * \p ctxt is used to pass the context set with the diagnostic handler. + * + * \since LTO_API_VERSION=7 + */ +typedef void (*lto_diagnostic_handler_t)( + lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt); + +/** + * Set a diagnostic handler and the related context (void *). + * This is more general than lto_get_error_message, as the diagnostic handler + * can be called at anytime within lto. + * + * \since LTO_API_VERSION=7 + */ +extern void lto_codegen_set_diagnostic_handler(lto_code_gen_t, + lto_diagnostic_handler_t, + void *); + +/** + * Instantiates a code generator. + * Returns NULL on error (check lto_get_error_message() for details). + * + * All modules added using \a lto_codegen_add_module() must have been created + * in the same context as the codegen. + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_code_gen_t +lto_codegen_create(void); + +/** + * Instantiate a code generator in its own context. + * + * Instantiates a code generator in its own context. Modules added via \a + * lto_codegen_add_module() must have all been created in the same context, + * using \a lto_module_create_in_codegen_context(). + * + * \since LTO_API_VERSION=11 + */ +extern lto_code_gen_t +lto_codegen_create_in_local_context(void); + +/** + * Frees all code generator and all memory it internally allocated. + * Upon return the lto_code_gen_t is no longer valid. + * + * \since prior to LTO_API_VERSION=3 + */ +extern void +lto_codegen_dispose(lto_code_gen_t); + +/** + * Add an object module to the set of modules for which code will be generated. + * Returns true on error (check lto_get_error_message() for details). + * + * \c cg and \c mod must both be in the same context. See \a + * lto_codegen_create_in_local_context() and \a + * lto_module_create_in_codegen_context(). + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t +lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); + +/** + * Sets the object module for code generation. This will transfer the ownership + * of the module to the code generator. + * + * \c cg and \c mod must both be in the same context. + * + * \since LTO_API_VERSION=13 + */ +extern void +lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod); + +/** + * Sets if debug info should be generated. + * Returns true on error (check lto_get_error_message() for details). + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t +lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); + +/** + * Sets which PIC code model to generated. + * Returns true on error (check lto_get_error_message() for details). + * + * \since prior to LTO_API_VERSION=3 + */ +extern lto_bool_t +lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); + +/** + * Sets the cpu to generate code for. + * + * \since LTO_API_VERSION=4 + */ +extern void +lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu); + +/** + * Sets the location of the assembler tool to run. If not set, libLTO + * will use gcc to invoke the assembler. + * + * \since LTO_API_VERSION=3 + */ +extern void +lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path); + +/** + * Sets extra arguments that libLTO should pass to the assembler. + * + * \since LTO_API_VERSION=4 + */ +extern void +lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, + int nargs); + +/** + * Adds to a list of all global symbols that must exist in the final generated + * code. If a function is not listed there, it might be inlined into every usage + * and optimized away. + * + * \since prior to LTO_API_VERSION=3 + */ +extern void +lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol); + +/** + * Writes a new object file at the specified path that contains the + * merged contents of all modules added so far. + * Returns true on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=5 + */ +extern lto_bool_t +lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path); + +/** + * Generates code for all added modules into one native object file. + * This calls lto_codegen_optimize then lto_codegen_compile_optimized. + * + * On success returns a pointer to a generated mach-o/ELF buffer and + * length set to the buffer size. The buffer is owned by the + * lto_code_gen_t and will be freed when lto_codegen_dispose() + * is called, or lto_codegen_compile() is called again. + * On failure, returns NULL (check lto_get_error_message() for details). + * + * \since prior to LTO_API_VERSION=3 + */ +extern const void* +lto_codegen_compile(lto_code_gen_t cg, size_t* length); + +/** + * Generates code for all added modules into one native object file. + * This calls lto_codegen_optimize then lto_codegen_compile_optimized (instead + * of returning a generated mach-o/ELF buffer, it writes to a file). + * + * The name of the file is written to name. Returns true on error. + * + * \since LTO_API_VERSION=5 + */ +extern lto_bool_t +lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); + +/** + * Runs optimization for the merged module. Returns true on error. + * + * \since LTO_API_VERSION=12 + */ +extern lto_bool_t +lto_codegen_optimize(lto_code_gen_t cg); + +/** + * Generates code for the optimized merged module into one native object file. + * It will not run any IR optimizations on the merged module. + * + * On success returns a pointer to a generated mach-o/ELF buffer and length set + * to the buffer size. The buffer is owned by the lto_code_gen_t and will be + * freed when lto_codegen_dispose() is called, or + * lto_codegen_compile_optimized() is called again. On failure, returns NULL + * (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=12 + */ +extern const void* +lto_codegen_compile_optimized(lto_code_gen_t cg, size_t* length); + +/** + * Returns the runtime API version. + * + * \since LTO_API_VERSION=12 + */ +extern unsigned int +lto_api_version(void); + +/** + * Parses options immediately, making them available as early as possible. For + * example during executing codegen::InitTargetOptionsFromCodeGenFlags. Since + * parsing shud only happen once, only one of lto_codegen_debug_options or + * lto_set_debug_options should be called. + * + * This function takes one or more options separated by spaces. + * Warning: passing file paths through this function may confuse the argument + * parser if the paths contain spaces. + * + * \since LTO_API_VERSION=28 + */ +extern void lto_set_debug_options(const char *const *options, int number); + +/** + * Sets options to help debug codegen bugs. Since parsing shud only happen once, + * only one of lto_codegen_debug_options or lto_set_debug_options + * should be called. + * + * This function takes one or more options separated by spaces. + * Warning: passing file paths through this function may confuse the argument + * parser if the paths contain spaces. + * + * \since prior to LTO_API_VERSION=3 + */ +extern void +lto_codegen_debug_options(lto_code_gen_t cg, const char *); + +/** + * Same as the previous function, but takes every option separately through an + * array. + * + * \since prior to LTO_API_VERSION=26 + */ +extern void lto_codegen_debug_options_array(lto_code_gen_t cg, + const char *const *, int number); + +/** + * Initializes LLVM disassemblers. + * FIXME: This doesn't really belong here. + * + * \since LTO_API_VERSION=5 + */ +extern void +lto_initialize_disassembler(void); + +/** + * Sets if we should run internalize pass during optimization and code + * generation. + * + * \since LTO_API_VERSION=14 + */ +extern void +lto_codegen_set_should_internalize(lto_code_gen_t cg, + lto_bool_t ShouldInternalize); + +/** + * Set whether to embed uselists in bitcode. + * + * Sets whether \a lto_codegen_write_merged_modules() should embed uselists in + * output bitcode. This should be turned on for all -save-temps output. + * + * \since LTO_API_VERSION=15 + */ +extern void +lto_codegen_set_should_embed_uselists(lto_code_gen_t cg, + lto_bool_t ShouldEmbedUselists); + +/** Opaque reference to an LTO input file */ +typedef struct LLVMOpaqueLTOInput *lto_input_t; + +/** + * Creates an LTO input file from a buffer. The path + * argument is used for diagnotics as this function + * otherwise does not know which file the given buffer + * is associated with. + * + * \since LTO_API_VERSION=24 + */ +extern lto_input_t lto_input_create(const void *buffer, + size_t buffer_size, + const char *path); + +/** + * Frees all memory internally allocated by the LTO input file. + * Upon return the lto_module_t is no longer valid. + * + * \since LTO_API_VERSION=24 + */ +extern void lto_input_dispose(lto_input_t input); + +/** + * Returns the number of dependent library specifiers + * for the given LTO input file. + * + * \since LTO_API_VERSION=24 + */ +extern unsigned lto_input_get_num_dependent_libraries(lto_input_t input); + +/** + * Returns the ith dependent library specifier + * for the given LTO input file. The returned + * string is not null-terminated. + * + * \since LTO_API_VERSION=24 + */ +extern const char * lto_input_get_dependent_library(lto_input_t input, + size_t index, + size_t *size); + +/** + * Returns the list of libcall symbols that can be generated by LTO + * that might not be visible from the symbol table of bitcode files. + * + * \since prior to LTO_API_VERSION=25 + */ +extern const char *const *lto_runtime_lib_symbols_list(size_t *size); + +/** + * @} // endgoup LLVMCLTO + * @defgroup LLVMCTLTO ThinLTO + * @ingroup LLVMC + * + * @{ + */ + +/** + * Type to wrap a single object returned by ThinLTO. + * + * \since LTO_API_VERSION=18 + */ +typedef struct { + const char *Buffer; + size_t Size; +} LTOObjectBuffer; + +/** + * Instantiates a ThinLTO code generator. + * Returns NULL on error (check lto_get_error_message() for details). + * + * + * The ThinLTOCodeGenerator is not intended to be reuse for multiple + * compilation: the model is that the client adds modules to the generator and + * ask to perform the ThinLTO optimizations / codegen, and finally destroys the + * codegenerator. + * + * \since LTO_API_VERSION=18 + */ +extern thinlto_code_gen_t thinlto_create_codegen(void); + +/** + * Frees the generator and all memory it internally allocated. + * Upon return the thinlto_code_gen_t is no longer valid. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_dispose(thinlto_code_gen_t cg); + +/** + * Add a module to a ThinLTO code generator. Identifier has to be unique among + * all the modules in a code generator. The data buffer stays owned by the + * client, and is expected to be available for the entire lifetime of the + * thinlto_code_gen_t it is added to. + * + * On failure, returns NULL (check lto_get_error_message() for details). + * + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_add_module(thinlto_code_gen_t cg, + const char *identifier, const char *data, + int length); + +/** + * Optimize and codegen all the modules added to the codegenerator using + * ThinLTO. Resulting objects are accessible using thinlto_module_get_object(). + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_process(thinlto_code_gen_t cg); + +/** + * Returns the number of object files produced by the ThinLTO CodeGenerator. + * + * It usually matches the number of input files, but this is not a guarantee of + * the API and may change in future implementation, so the client should not + * assume it. + * + * \since LTO_API_VERSION=18 + */ +extern unsigned int thinlto_module_get_num_objects(thinlto_code_gen_t cg); + +/** + * Returns a reference to the ith object file produced by the ThinLTO + * CodeGenerator. + * + * Client should use \p thinlto_module_get_num_objects() to get the number of + * available objects. + * + * \since LTO_API_VERSION=18 + */ +extern LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg, + unsigned int index); + +/** + * Returns the number of object files produced by the ThinLTO CodeGenerator. + * + * It usually matches the number of input files, but this is not a guarantee of + * the API and may change in future implementation, so the client should not + * assume it. + * + * \since LTO_API_VERSION=21 + */ +unsigned int thinlto_module_get_num_object_files(thinlto_code_gen_t cg); + +/** + * Returns the path to the ith object file produced by the ThinLTO + * CodeGenerator. + * + * Client should use \p thinlto_module_get_num_object_files() to get the number + * of available objects. + * + * \since LTO_API_VERSION=21 + */ +const char *thinlto_module_get_object_file(thinlto_code_gen_t cg, + unsigned int index); + +/** + * Sets which PIC code model to generate. + * Returns true on error (check lto_get_error_message() for details). + * + * \since LTO_API_VERSION=18 + */ +extern lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg, + lto_codegen_model); + +/** + * Sets the path to a directory to use as a storage for temporary bitcode files. + * The intention is to make the bitcode files available for debugging at various + * stage of the pipeline. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg, + const char *save_temps_dir); + +/** + * Set the path to a directory where to save generated object files. This + * path can be used by a linker to request on-disk files instead of in-memory + * buffers. When set, results are available through + * thinlto_module_get_object_file() instead of thinlto_module_get_object(). + * + * \since LTO_API_VERSION=21 + */ +void thinlto_set_generated_objects_dir(thinlto_code_gen_t cg, + const char *save_temps_dir); + +/** + * Sets the cpu to generate code for. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu); + +/** + * Disable CodeGen, only run the stages till codegen and stop. The output will + * be bitcode. + * + * \since LTO_API_VERSION=19 + */ +extern void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg, + lto_bool_t disable); + +/** + * Perform CodeGen only: disable all other stages. + * + * \since LTO_API_VERSION=19 + */ +extern void thinlto_codegen_set_codegen_only(thinlto_code_gen_t cg, + lto_bool_t codegen_only); + +/** + * Parse -mllvm style debug options. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_debug_options(const char *const *options, int number); + +/** + * Test if a module has support for ThinLTO linking. + * + * \since LTO_API_VERSION=18 + */ +extern lto_bool_t lto_module_is_thinlto(lto_module_t mod); + +/** + * Adds a symbol to the list of global symbols that must exist in the final + * generated code. If a function is not listed there, it might be inlined into + * every usage and optimized away. For every single module, the functions + * referenced from code outside of the ThinLTO modules need to be added here. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_add_must_preserve_symbol(thinlto_code_gen_t cg, + const char *name, + int length); + +/** + * Adds a symbol to the list of global symbols that are cross-referenced between + * ThinLTO files. If the ThinLTO CodeGenerator can ensure that every + * references from a ThinLTO module to this symbol is optimized away, then + * the symbol can be discarded. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_add_cross_referenced_symbol(thinlto_code_gen_t cg, + const char *name, + int length); + +/** + * @} // endgoup LLVMCTLTO + * @defgroup LLVMCTLTO_CACHING ThinLTO Cache Control + * @ingroup LLVMCTLTO + * + * These entry points control the ThinLTO cache. The cache is intended to + * support incremental builds, and thus needs to be persistent across builds. + * The client enables the cache by supplying a path to an existing directory. + * The code generator will use this to store objects files that may be reused + * during a subsequent build. + * To avoid filling the disk space, a few knobs are provided: + * - The pruning interval limits the frequency at which the garbage collector + * will try to scan the cache directory to prune expired entries. + * Setting to a negative number disables the pruning. + * - The pruning expiration time indicates to the garbage collector how old an + * entry needs to be to be removed. + * - Finally, the garbage collector can be instructed to prune the cache until + * the occupied space goes below a threshold. + * @{ + */ + +/** + * Sets the path to a directory to use as a cache storage for incremental build. + * Setting this activates caching. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg, + const char *cache_dir); + +/** + * Sets the cache pruning interval (in seconds). A negative value disables the + * pruning. An unspecified default value will be applied, and a value of 0 will + * force prunning to occur. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cache_pruning_interval(thinlto_code_gen_t cg, + int interval); + +/** + * Sets the maximum cache size that can be persistent across build, in terms of + * percentage of the available space on the disk. Set to 100 to indicate + * no limit, 50 to indicate that the cache size will not be left over half the + * available space. A value over 100 will be reduced to 100, a value of 0 will + * be ignored. An unspecified default value will be applied. + * + * The formula looks like: + * AvailableSpace = FreeSpace + ExistingCacheSize + * NewCacheSize = AvailableSpace * P/100 + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_final_cache_size_relative_to_available_space( + thinlto_code_gen_t cg, unsigned percentage); + +/** + * Sets the expiration (in seconds) for an entry in the cache. An unspecified + * default value will be applied. A value of 0 will be ignored. + * + * \since LTO_API_VERSION=18 + */ +extern void thinlto_codegen_set_cache_entry_expiration(thinlto_code_gen_t cg, + unsigned expiration); + +/** + * Sets the maximum size of the cache directory (in bytes). A value over the + * amount of available space on the disk will be reduced to the amount of + * available space. An unspecified default value will be applied. A value of 0 + * will be ignored. + * + * \since LTO_API_VERSION=22 + */ +extern void thinlto_codegen_set_cache_size_bytes(thinlto_code_gen_t cg, + unsigned max_size_bytes); + +/** + * Same as thinlto_codegen_set_cache_size_bytes, except the maximum size is in + * megabytes (2^20 bytes). + * + * \since LTO_API_VERSION=23 + */ +extern void +thinlto_codegen_set_cache_size_megabytes(thinlto_code_gen_t cg, + unsigned max_size_megabytes); + +/** + * Sets the maximum number of files in the cache directory. An unspecified + * default value will be applied. A value of 0 will be ignored. + * + * \since LTO_API_VERSION=22 + */ +extern void thinlto_codegen_set_cache_size_files(thinlto_code_gen_t cg, + unsigned max_size_files); + +/** + * @} // endgroup LLVMCTLTO_CACHING + */ + +LLVM_C_EXTERN_C_END + +#endif /* LLVM_C_LTO_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_builtin_vars.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_builtin_vars.h new file mode 100755 index 0000000..412e823 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_builtin_vars.h @@ -0,0 +1,121 @@ +/*===---- cuda_builtin_vars.h - CUDA built-in variables ---------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CUDA_BUILTIN_VARS_H +#define __CUDA_BUILTIN_VARS_H + +// Forward declares from vector_types.h. +struct uint3; +struct dim3; + +// The file implements built-in CUDA variables using __declspec(property). +// https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx +// All read accesses of built-in variable fields get converted into calls to a +// getter function which in turn calls the appropriate builtin to fetch the +// value. +// +// Example: +// int x = threadIdx.x; +// IR output: +// %0 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() #3 +// PTX output: +// mov.u32 %r2, %tid.x; + +#define __CUDA_DEVICE_BUILTIN(FIELD, INTRINSIC) \ + __declspec(property(get = __fetch_builtin_##FIELD)) unsigned int FIELD; \ + static inline __attribute__((always_inline)) \ + __attribute__((device)) unsigned int __fetch_builtin_##FIELD(void) { \ + return INTRINSIC; \ + } + +#if __cplusplus >= 201103L +#define __DELETE =delete +#else +#define __DELETE +#endif + +// Make sure nobody can create instances of the special variable types. nvcc +// also disallows taking address of special variables, so we disable address-of +// operator as well. +#define __CUDA_DISALLOW_BUILTINVAR_ACCESS(TypeName) \ + __attribute__((device)) TypeName() __DELETE; \ + __attribute__((device)) TypeName(const TypeName &) __DELETE; \ + __attribute__((device)) void operator=(const TypeName &) const __DELETE; \ + __attribute__((device)) TypeName *operator&() const __DELETE + +struct __cuda_builtin_threadIdx_t { + __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_tid_x()); + __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_tid_y()); + __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_tid_z()); + // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a + // uint3). This function is defined after we pull in vector_types.h. + __attribute__((device)) operator dim3() const; + __attribute__((device)) operator uint3() const; + +private: + __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t); +}; + +struct __cuda_builtin_blockIdx_t { + __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_ctaid_x()); + __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_ctaid_y()); + __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ctaid_z()); + // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a + // uint3). This function is defined after we pull in vector_types.h. + __attribute__((device)) operator dim3() const; + __attribute__((device)) operator uint3() const; + +private: + __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t); +}; + +struct __cuda_builtin_blockDim_t { + __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_ntid_x()); + __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_ntid_y()); + __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ntid_z()); + // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a + // dim3). This function is defined after we pull in vector_types.h. + __attribute__((device)) operator dim3() const; + __attribute__((device)) operator uint3() const; + +private: + __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t); +}; + +struct __cuda_builtin_gridDim_t { + __CUDA_DEVICE_BUILTIN(x,__nvvm_read_ptx_sreg_nctaid_x()); + __CUDA_DEVICE_BUILTIN(y,__nvvm_read_ptx_sreg_nctaid_y()); + __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_nctaid_z()); + // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a + // dim3). This function is defined after we pull in vector_types.h. + __attribute__((device)) operator dim3() const; + __attribute__((device)) operator uint3() const; + +private: + __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t); +}; + +#define __CUDA_BUILTIN_VAR \ + extern const __attribute__((device)) __attribute__((weak)) +__CUDA_BUILTIN_VAR __cuda_builtin_threadIdx_t threadIdx; +__CUDA_BUILTIN_VAR __cuda_builtin_blockIdx_t blockIdx; +__CUDA_BUILTIN_VAR __cuda_builtin_blockDim_t blockDim; +__CUDA_BUILTIN_VAR __cuda_builtin_gridDim_t gridDim; + +// warpSize should translate to read of %WARP_SZ but there's currently no +// builtin to do so. According to PTX v4.2 docs 'to date, all target +// architectures have a WARP_SZ value of 32'. +__attribute__((device)) const int warpSize = 32; + +#undef __CUDA_DEVICE_BUILTIN +#undef __CUDA_BUILTIN_VAR +#undef __CUDA_DISALLOW_BUILTINVAR_ACCESS +#undef __DELETE + +#endif /* __CUDA_BUILTIN_VARS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_cmath.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_cmath.h new file mode 100755 index 0000000..5bbb59a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_cmath.h @@ -0,0 +1,512 @@ +/*===---- __clang_cuda_cmath.h - Device-side CUDA cmath support ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CLANG_CUDA_CMATH_H__ +#define __CLANG_CUDA_CMATH_H__ +#ifndef __CUDA__ +#error "This file is for CUDA compilation only." +#endif + +#ifndef __OPENMP_NVPTX__ +#include +#endif + +// CUDA lets us use various std math functions on the device side. This file +// works in concert with __clang_cuda_math_forward_declares.h to make this work. +// +// Specifically, the forward-declares header declares __device__ overloads for +// these functions in the global namespace, then pulls them into namespace std +// with 'using' statements. Then this file implements those functions, after +// their implementations have been pulled in. +// +// It's important that we declare the functions in the global namespace and pull +// them into namespace std with using statements, as opposed to simply declaring +// these functions in namespace std, because our device functions need to +// overload the standard library functions, which may be declared in the global +// namespace or in std, depending on the degree of conformance of the stdlib +// implementation. Declaring in the global namespace and pulling into namespace +// std covers all of the known knowns. + +#ifdef __OPENMP_NVPTX__ +#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) +#else +#define __DEVICE__ static __device__ __inline__ __attribute__((always_inline)) +#endif + +__DEVICE__ long long abs(long long __n) { return ::llabs(__n); } +__DEVICE__ long abs(long __n) { return ::labs(__n); } +__DEVICE__ float abs(float __x) { return ::fabsf(__x); } +__DEVICE__ double abs(double __x) { return ::fabs(__x); } +__DEVICE__ float acos(float __x) { return ::acosf(__x); } +__DEVICE__ float asin(float __x) { return ::asinf(__x); } +__DEVICE__ float atan(float __x) { return ::atanf(__x); } +__DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); } +__DEVICE__ float ceil(float __x) { return ::ceilf(__x); } +__DEVICE__ float cos(float __x) { return ::cosf(__x); } +__DEVICE__ float cosh(float __x) { return ::coshf(__x); } +__DEVICE__ float exp(float __x) { return ::expf(__x); } +__DEVICE__ float fabs(float __x) { return ::fabsf(__x); } +__DEVICE__ float floor(float __x) { return ::floorf(__x); } +__DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); } +__DEVICE__ int fpclassify(float __x) { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, + FP_ZERO, __x); +} +__DEVICE__ int fpclassify(double __x) { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, + FP_ZERO, __x); +} +__DEVICE__ float frexp(float __arg, int *__exp) { + return ::frexpf(__arg, __exp); +} + +// For inscrutable reasons, the CUDA headers define these functions for us on +// Windows. +#if !defined(_MSC_VER) || defined(__OPENMP_NVPTX__) + +// For OpenMP we work around some old system headers that have non-conforming +// `isinf(float)` and `isnan(float)` implementations that return an `int`. We do +// this by providing two versions of these functions, differing only in the +// return type. To avoid conflicting definitions we disable implicit base +// function generation. That means we will end up with two specializations, one +// per type, but only one has a base function defined by the system header. +#if defined(__OPENMP_NVPTX__) +#pragma omp begin declare variant match( \ + implementation = {extension(disable_implicit_base)}) + +// FIXME: We lack an extension to customize the mangling of the variants, e.g., +// add a suffix. This means we would clash with the names of the variants +// (note that we do not create implicit base functions here). To avoid +// this clash we add a new trait to some of them that is always true +// (this is LLVM after all ;)). It will only influence the mangled name +// of the variants inside the inner region and avoid the clash. +#pragma omp begin declare variant match(implementation = {vendor(llvm)}) + +__DEVICE__ int isinf(float __x) { return ::__isinff(__x); } +__DEVICE__ int isinf(double __x) { return ::__isinf(__x); } +__DEVICE__ int isfinite(float __x) { return ::__finitef(__x); } +__DEVICE__ int isfinite(double __x) { return ::__isfinited(__x); } +__DEVICE__ int isnan(float __x) { return ::__isnanf(__x); } +__DEVICE__ int isnan(double __x) { return ::__isnan(__x); } + +#pragma omp end declare variant + +#endif + +__DEVICE__ bool isinf(float __x) { return ::__isinff(__x); } +__DEVICE__ bool isinf(double __x) { return ::__isinf(__x); } +__DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); } +// For inscrutable reasons, __finite(), the double-precision version of +// __finitef, does not exist when compiling for MacOS. __isfinited is available +// everywhere and is just as good. +__DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); } +__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); } +__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); } + +#if defined(__OPENMP_NVPTX__) +#pragma omp end declare variant +#endif + +#endif + +__DEVICE__ bool isgreater(float __x, float __y) { + return __builtin_isgreater(__x, __y); +} +__DEVICE__ bool isgreater(double __x, double __y) { + return __builtin_isgreater(__x, __y); +} +__DEVICE__ bool isgreaterequal(float __x, float __y) { + return __builtin_isgreaterequal(__x, __y); +} +__DEVICE__ bool isgreaterequal(double __x, double __y) { + return __builtin_isgreaterequal(__x, __y); +} +__DEVICE__ bool isless(float __x, float __y) { + return __builtin_isless(__x, __y); +} +__DEVICE__ bool isless(double __x, double __y) { + return __builtin_isless(__x, __y); +} +__DEVICE__ bool islessequal(float __x, float __y) { + return __builtin_islessequal(__x, __y); +} +__DEVICE__ bool islessequal(double __x, double __y) { + return __builtin_islessequal(__x, __y); +} +__DEVICE__ bool islessgreater(float __x, float __y) { + return __builtin_islessgreater(__x, __y); +} +__DEVICE__ bool islessgreater(double __x, double __y) { + return __builtin_islessgreater(__x, __y); +} +__DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); } +__DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); } +__DEVICE__ bool isunordered(float __x, float __y) { + return __builtin_isunordered(__x, __y); +} +__DEVICE__ bool isunordered(double __x, double __y) { + return __builtin_isunordered(__x, __y); +} +__DEVICE__ float ldexp(float __arg, int __exp) { + return ::ldexpf(__arg, __exp); +} +__DEVICE__ float log(float __x) { return ::logf(__x); } +__DEVICE__ float log10(float __x) { return ::log10f(__x); } +__DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); } +__DEVICE__ float pow(float __base, float __exp) { + return ::powf(__base, __exp); +} +__DEVICE__ float pow(float __base, int __iexp) { + return ::powif(__base, __iexp); +} +__DEVICE__ double pow(double __base, int __iexp) { + return ::powi(__base, __iexp); +} +__DEVICE__ bool signbit(float __x) { return ::__signbitf(__x); } +__DEVICE__ bool signbit(double __x) { return ::__signbitd(__x); } +__DEVICE__ float sin(float __x) { return ::sinf(__x); } +__DEVICE__ float sinh(float __x) { return ::sinhf(__x); } +__DEVICE__ float sqrt(float __x) { return ::sqrtf(__x); } +__DEVICE__ float tan(float __x) { return ::tanf(__x); } +__DEVICE__ float tanh(float __x) { return ::tanhf(__x); } + +// There was a redefinition error for this this overload in CUDA mode. +// We restrict it to OpenMP mode for now, that is where it is actually needed +// anyway. +#ifdef __OPENMP_NVPTX__ +__DEVICE__ float remquo(float __n, float __d, int *__q) { + return ::remquof(__n, __d, __q); +} +#endif + +// Notably missing above is nexttoward. We omit it because +// libdevice doesn't provide an implementation, and we don't want to be in the +// business of implementing tricky libm functions in this header. + +#ifndef __OPENMP_NVPTX__ + +// Now we've defined everything we promised we'd define in +// __clang_cuda_math_forward_declares.h. We need to do two additional things to +// fix up our math functions. +// +// 1) Define __device__ overloads for e.g. sin(int). The CUDA headers define +// only sin(float) and sin(double), which means that e.g. sin(0) is +// ambiguous. +// +// 2) Pull the __device__ overloads of "foobarf" math functions into namespace +// std. These are defined in the CUDA headers in the global namespace, +// independent of everything else we've done here. + +// We can't use std::enable_if, because we want to be pre-C++11 compatible. But +// we go ahead and unconditionally define functions that are only available when +// compiling for C++11 to match the behavior of the CUDA headers. +template +struct __clang_cuda_enable_if {}; + +template struct __clang_cuda_enable_if { + typedef __T type; +}; + +// Defines an overload of __fn that accepts one integral argument, calls +// __fn((double)x), and returns __retty. +#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_1(__retty, __fn) \ + template \ + __DEVICE__ \ + typename __clang_cuda_enable_if::is_integer, \ + __retty>::type \ + __fn(__T __x) { \ + return ::__fn((double)__x); \ + } + +// Defines an overload of __fn that accepts one two arithmetic arguments, calls +// __fn((double)x, (double)y), and returns a double. +// +// Note this is different from OVERLOAD_1, which generates an overload that +// accepts only *integral* arguments. +#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_2(__retty, __fn) \ + template \ + __DEVICE__ typename __clang_cuda_enable_if< \ + std::numeric_limits<__T1>::is_specialized && \ + std::numeric_limits<__T2>::is_specialized, \ + __retty>::type \ + __fn(__T1 __x, __T2 __y) { \ + return __fn((double)__x, (double)__y); \ + } + +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, acos) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, acosh) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, asin) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, asinh) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, atan) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, atan2); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, atanh) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cbrt) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, ceil) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, copysign); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cos) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cosh) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, erf) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, erfc) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, exp) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, exp2) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, expm1) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, fabs) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fdim); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, floor) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmax); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmin); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmod); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(int, fpclassify) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, hypot); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(int, ilogb) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isfinite) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isgreater); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isgreaterequal); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isinf); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isless); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, islessequal); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, islessgreater); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isnan); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isnormal) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isunordered); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, lgamma) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log10) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log1p) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log2) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, logb) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long long, llrint) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long long, llround) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long, lrint) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long, lround) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, nearbyint); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, nextafter); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, pow); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, remainder); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, rint); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, round); +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, signbit) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sin) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sinh) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sqrt) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tan) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tanh) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tgamma) +__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, trunc); + +#undef __CUDA_CLANG_FN_INTEGER_OVERLOAD_1 +#undef __CUDA_CLANG_FN_INTEGER_OVERLOAD_2 + +// Overloads for functions that don't match the patterns expected by +// __CUDA_CLANG_FN_INTEGER_OVERLOAD_{1,2}. +template +__DEVICE__ typename __clang_cuda_enable_if< + std::numeric_limits<__T1>::is_specialized && + std::numeric_limits<__T2>::is_specialized && + std::numeric_limits<__T3>::is_specialized, + double>::type +fma(__T1 __x, __T2 __y, __T3 __z) { + return std::fma((double)__x, (double)__y, (double)__z); +} + +template +__DEVICE__ typename __clang_cuda_enable_if::is_integer, + double>::type +frexp(__T __x, int *__exp) { + return std::frexp((double)__x, __exp); +} + +template +__DEVICE__ typename __clang_cuda_enable_if::is_integer, + double>::type +ldexp(__T __x, int __exp) { + return std::ldexp((double)__x, __exp); +} + +template +__DEVICE__ typename __clang_cuda_enable_if< + std::numeric_limits<__T1>::is_specialized && + std::numeric_limits<__T2>::is_specialized, + double>::type +remquo(__T1 __x, __T2 __y, int *__quo) { + return std::remquo((double)__x, (double)__y, __quo); +} + +template +__DEVICE__ typename __clang_cuda_enable_if::is_integer, + double>::type +scalbln(__T __x, long __exp) { + return std::scalbln((double)__x, __exp); +} + +template +__DEVICE__ typename __clang_cuda_enable_if::is_integer, + double>::type +scalbn(__T __x, int __exp) { + return std::scalbn((double)__x, __exp); +} + +// We need to define these overloads in exactly the namespace our standard +// library uses (including the right inline namespace), otherwise they won't be +// picked up by other functions in the standard library (e.g. functions in +// ). Thus the ugliness below. +#ifdef _LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_BEGIN_NAMESPACE_STD +#else +namespace std { +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#endif +#endif + +// Pull the new overloads we defined above into namespace std. +using ::acos; +using ::acosh; +using ::asin; +using ::asinh; +using ::atan; +using ::atan2; +using ::atanh; +using ::cbrt; +using ::ceil; +using ::copysign; +using ::cos; +using ::cosh; +using ::erf; +using ::erfc; +using ::exp; +using ::exp2; +using ::expm1; +using ::fabs; +using ::fdim; +using ::floor; +using ::fma; +using ::fmax; +using ::fmin; +using ::fmod; +using ::fpclassify; +using ::frexp; +using ::hypot; +using ::ilogb; +using ::isfinite; +using ::isgreater; +using ::isgreaterequal; +using ::isless; +using ::islessequal; +using ::islessgreater; +using ::isnormal; +using ::isunordered; +using ::ldexp; +using ::lgamma; +using ::llrint; +using ::llround; +using ::log; +using ::log10; +using ::log1p; +using ::log2; +using ::logb; +using ::lrint; +using ::lround; +using ::nearbyint; +using ::nextafter; +using ::pow; +using ::remainder; +using ::remquo; +using ::rint; +using ::round; +using ::scalbln; +using ::scalbn; +using ::signbit; +using ::sin; +using ::sinh; +using ::sqrt; +using ::tan; +using ::tanh; +using ::tgamma; +using ::trunc; + +// Well this is fun: We need to pull these symbols in for libc++, but we can't +// pull them in with libstdc++, because its ::isinf and ::isnan are different +// than its std::isinf and std::isnan. +#ifndef __GLIBCXX__ +using ::isinf; +using ::isnan; +#endif + +// Finally, pull the "foobarf" functions that CUDA defines in its headers into +// namespace std. +using ::acosf; +using ::acoshf; +using ::asinf; +using ::asinhf; +using ::atan2f; +using ::atanf; +using ::atanhf; +using ::cbrtf; +using ::ceilf; +using ::copysignf; +using ::cosf; +using ::coshf; +using ::erfcf; +using ::erff; +using ::exp2f; +using ::expf; +using ::expm1f; +using ::fabsf; +using ::fdimf; +using ::floorf; +using ::fmaf; +using ::fmaxf; +using ::fminf; +using ::fmodf; +using ::frexpf; +using ::hypotf; +using ::ilogbf; +using ::ldexpf; +using ::lgammaf; +using ::llrintf; +using ::llroundf; +using ::log10f; +using ::log1pf; +using ::log2f; +using ::logbf; +using ::logf; +using ::lrintf; +using ::lroundf; +using ::modff; +using ::nearbyintf; +using ::nextafterf; +using ::powf; +using ::remainderf; +using ::remquof; +using ::rintf; +using ::roundf; +using ::scalblnf; +using ::scalbnf; +using ::sinf; +using ::sinhf; +using ::sqrtf; +using ::tanf; +using ::tanhf; +using ::tgammaf; +using ::truncf; + +#ifdef _LIBCPP_END_NAMESPACE_STD +_LIBCPP_END_NAMESPACE_STD +#else +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +#endif +} // namespace std +#endif + +#endif // __OPENMP_NVPTX__ + +#undef __DEVICE__ + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_complex_builtins.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_complex_builtins.h new file mode 100755 index 0000000..7bc7bc2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_complex_builtins.h @@ -0,0 +1,285 @@ +/*===-- __clang_cuda_complex_builtins - CUDA impls of runtime complex fns ---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_COMPLEX_BUILTINS +#define __CLANG_CUDA_COMPLEX_BUILTINS + +// This header defines __muldc3, __mulsc3, __divdc3, and __divsc3. These are +// libgcc functions that clang assumes are available when compiling c99 complex +// operations. (These implementations come from libc++, and have been modified +// to work with CUDA and OpenMP target offloading [in C and C++ mode].) + +#pragma push_macro("__DEVICE__") +#if defined(__OPENMP_NVPTX__) || defined(__OPENMP_AMDGCN__) +#pragma omp declare target +#define __DEVICE__ __attribute__((noinline, nothrow, cold, weak)) +#else +#define __DEVICE__ __device__ inline +#endif + +// To make the algorithms available for C and C++ in CUDA and OpenMP we select +// different but equivalent function versions. TODO: For OpenMP we currently +// select the native builtins as the overload support for templates is lacking. +#if !defined(__OPENMP_NVPTX__) && !defined(__OPENMP_AMDGCN__) +#define _ISNANd std::isnan +#define _ISNANf std::isnan +#define _ISINFd std::isinf +#define _ISINFf std::isinf +#define _ISFINITEd std::isfinite +#define _ISFINITEf std::isfinite +#define _COPYSIGNd std::copysign +#define _COPYSIGNf std::copysign +#define _SCALBNd std::scalbn +#define _SCALBNf std::scalbn +#define _ABSd std::abs +#define _ABSf std::abs +#define _LOGBd std::logb +#define _LOGBf std::logb +// Rather than pulling in std::max from algorithm everytime, use available ::max. +#define _fmaxd max +#define _fmaxf max +#else +#ifdef __AMDGCN__ +#define _ISNANd __ocml_isnan_f64 +#define _ISNANf __ocml_isnan_f32 +#define _ISINFd __ocml_isinf_f64 +#define _ISINFf __ocml_isinf_f32 +#define _ISFINITEd __ocml_isfinite_f64 +#define _ISFINITEf __ocml_isfinite_f32 +#define _COPYSIGNd __ocml_copysign_f64 +#define _COPYSIGNf __ocml_copysign_f32 +#define _SCALBNd __ocml_scalbn_f64 +#define _SCALBNf __ocml_scalbn_f32 +#define _ABSd __ocml_fabs_f64 +#define _ABSf __ocml_fabs_f32 +#define _LOGBd __ocml_logb_f64 +#define _LOGBf __ocml_logb_f32 +#define _fmaxd __ocml_fmax_f64 +#define _fmaxf __ocml_fmax_f32 +#else +#define _ISNANd __nv_isnand +#define _ISNANf __nv_isnanf +#define _ISINFd __nv_isinfd +#define _ISINFf __nv_isinff +#define _ISFINITEd __nv_isfinited +#define _ISFINITEf __nv_finitef +#define _COPYSIGNd __nv_copysign +#define _COPYSIGNf __nv_copysignf +#define _SCALBNd __nv_scalbn +#define _SCALBNf __nv_scalbnf +#define _ABSd __nv_fabs +#define _ABSf __nv_fabsf +#define _LOGBd __nv_logb +#define _LOGBf __nv_logbf +#define _fmaxd __nv_fmax +#define _fmaxf __nv_fmaxf +#endif +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +__DEVICE__ double _Complex __muldc3(double __a, double __b, double __c, + double __d) { + double __ac = __a * __c; + double __bd = __b * __d; + double __ad = __a * __d; + double __bc = __b * __c; + double _Complex z; + __real__(z) = __ac - __bd; + __imag__(z) = __ad + __bc; + if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) { + int __recalc = 0; + if (_ISINFd(__a) || _ISINFd(__b)) { + __a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a); + __b = _COPYSIGNd(_ISINFd(__b) ? 1 : 0, __b); + if (_ISNANd(__c)) + __c = _COPYSIGNd(0, __c); + if (_ISNANd(__d)) + __d = _COPYSIGNd(0, __d); + __recalc = 1; + } + if (_ISINFd(__c) || _ISINFd(__d)) { + __c = _COPYSIGNd(_ISINFd(__c) ? 1 : 0, __c); + __d = _COPYSIGNd(_ISINFd(__d) ? 1 : 0, __d); + if (_ISNANd(__a)) + __a = _COPYSIGNd(0, __a); + if (_ISNANd(__b)) + __b = _COPYSIGNd(0, __b); + __recalc = 1; + } + if (!__recalc && + (_ISINFd(__ac) || _ISINFd(__bd) || _ISINFd(__ad) || _ISINFd(__bc))) { + if (_ISNANd(__a)) + __a = _COPYSIGNd(0, __a); + if (_ISNANd(__b)) + __b = _COPYSIGNd(0, __b); + if (_ISNANd(__c)) + __c = _COPYSIGNd(0, __c); + if (_ISNANd(__d)) + __d = _COPYSIGNd(0, __d); + __recalc = 1; + } + if (__recalc) { + // Can't use std::numeric_limits::infinity() -- that doesn't have + // a device overload (and isn't constexpr before C++11, naturally). + __real__(z) = __builtin_huge_val() * (__a * __c - __b * __d); + __imag__(z) = __builtin_huge_val() * (__a * __d + __b * __c); + } + } + return z; +} + +__DEVICE__ float _Complex __mulsc3(float __a, float __b, float __c, float __d) { + float __ac = __a * __c; + float __bd = __b * __d; + float __ad = __a * __d; + float __bc = __b * __c; + float _Complex z; + __real__(z) = __ac - __bd; + __imag__(z) = __ad + __bc; + if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) { + int __recalc = 0; + if (_ISINFf(__a) || _ISINFf(__b)) { + __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a); + __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b); + if (_ISNANf(__c)) + __c = _COPYSIGNf(0, __c); + if (_ISNANf(__d)) + __d = _COPYSIGNf(0, __d); + __recalc = 1; + } + if (_ISINFf(__c) || _ISINFf(__d)) { + __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c); + __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d); + if (_ISNANf(__a)) + __a = _COPYSIGNf(0, __a); + if (_ISNANf(__b)) + __b = _COPYSIGNf(0, __b); + __recalc = 1; + } + if (!__recalc && + (_ISINFf(__ac) || _ISINFf(__bd) || _ISINFf(__ad) || _ISINFf(__bc))) { + if (_ISNANf(__a)) + __a = _COPYSIGNf(0, __a); + if (_ISNANf(__b)) + __b = _COPYSIGNf(0, __b); + if (_ISNANf(__c)) + __c = _COPYSIGNf(0, __c); + if (_ISNANf(__d)) + __d = _COPYSIGNf(0, __d); + __recalc = 1; + } + if (__recalc) { + __real__(z) = __builtin_huge_valf() * (__a * __c - __b * __d); + __imag__(z) = __builtin_huge_valf() * (__a * __d + __b * __c); + } + } + return z; +} + +__DEVICE__ double _Complex __divdc3(double __a, double __b, double __c, + double __d) { + int __ilogbw = 0; + // Can't use std::max, because that's defined in , and we don't + // want to pull that in for every compile. The CUDA headers define + // ::max(float, float) and ::max(double, double), which is sufficient for us. + double __logbw = _LOGBd(_fmaxd(_ABSd(__c), _ABSd(__d))); + if (_ISFINITEd(__logbw)) { + __ilogbw = (int)__logbw; + __c = _SCALBNd(__c, -__ilogbw); + __d = _SCALBNd(__d, -__ilogbw); + } + double __denom = __c * __c + __d * __d; + double _Complex z; + __real__(z) = _SCALBNd((__a * __c + __b * __d) / __denom, -__ilogbw); + __imag__(z) = _SCALBNd((__b * __c - __a * __d) / __denom, -__ilogbw); + if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) { + if ((__denom == 0.0) && (!_ISNANd(__a) || !_ISNANd(__b))) { + __real__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __a; + __imag__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __b; + } else if ((_ISINFd(__a) || _ISINFd(__b)) && _ISFINITEd(__c) && + _ISFINITEd(__d)) { + __a = _COPYSIGNd(_ISINFd(__a) ? 1.0 : 0.0, __a); + __b = _COPYSIGNd(_ISINFd(__b) ? 1.0 : 0.0, __b); + __real__(z) = __builtin_huge_val() * (__a * __c + __b * __d); + __imag__(z) = __builtin_huge_val() * (__b * __c - __a * __d); + } else if (_ISINFd(__logbw) && __logbw > 0.0 && _ISFINITEd(__a) && + _ISFINITEd(__b)) { + __c = _COPYSIGNd(_ISINFd(__c) ? 1.0 : 0.0, __c); + __d = _COPYSIGNd(_ISINFd(__d) ? 1.0 : 0.0, __d); + __real__(z) = 0.0 * (__a * __c + __b * __d); + __imag__(z) = 0.0 * (__b * __c - __a * __d); + } + } + return z; +} + +__DEVICE__ float _Complex __divsc3(float __a, float __b, float __c, float __d) { + int __ilogbw = 0; + float __logbw = _LOGBf(_fmaxf(_ABSf(__c), _ABSf(__d))); + if (_ISFINITEf(__logbw)) { + __ilogbw = (int)__logbw; + __c = _SCALBNf(__c, -__ilogbw); + __d = _SCALBNf(__d, -__ilogbw); + } + float __denom = __c * __c + __d * __d; + float _Complex z; + __real__(z) = _SCALBNf((__a * __c + __b * __d) / __denom, -__ilogbw); + __imag__(z) = _SCALBNf((__b * __c - __a * __d) / __denom, -__ilogbw); + if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) { + if ((__denom == 0) && (!_ISNANf(__a) || !_ISNANf(__b))) { + __real__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __a; + __imag__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __b; + } else if ((_ISINFf(__a) || _ISINFf(__b)) && _ISFINITEf(__c) && + _ISFINITEf(__d)) { + __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a); + __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b); + __real__(z) = __builtin_huge_valf() * (__a * __c + __b * __d); + __imag__(z) = __builtin_huge_valf() * (__b * __c - __a * __d); + } else if (_ISINFf(__logbw) && __logbw > 0 && _ISFINITEf(__a) && + _ISFINITEf(__b)) { + __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c); + __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d); + __real__(z) = 0 * (__a * __c + __b * __d); + __imag__(z) = 0 * (__b * __c - __a * __d); + } + } + return z; +} + +#if defined(__cplusplus) +} // extern "C" +#endif + +#undef _ISNANd +#undef _ISNANf +#undef _ISINFd +#undef _ISINFf +#undef _COPYSIGNd +#undef _COPYSIGNf +#undef _ISFINITEd +#undef _ISFINITEf +#undef _SCALBNd +#undef _SCALBNf +#undef _ABSd +#undef _ABSf +#undef _LOGBd +#undef _LOGBf +#undef _fmaxd +#undef _fmaxf + +#if defined(__OPENMP_NVPTX__) || defined(__OPENMP_AMDGCN__) +#pragma omp end declare target +#endif + +#pragma pop_macro("__DEVICE__") + +#endif // __CLANG_CUDA_COMPLEX_BUILTINS diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_device_functions.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_device_functions.h new file mode 100755 index 0000000..8612372 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_device_functions.h @@ -0,0 +1,1572 @@ +/*===---- __clang_cuda_device_functions.h - CUDA runtime support -----------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_DEVICE_FUNCTIONS_H__ +#define __CLANG_CUDA_DEVICE_FUNCTIONS_H__ + +#ifndef __OPENMP_NVPTX__ +#if CUDA_VERSION < 9000 +#error This file is intended to be used with CUDA-9+ only. +#endif +#endif + +// __DEVICE__ is a helper macro with common set of attributes for the wrappers +// we implement in this file. We need static in order to avoid emitting unused +// functions and __forceinline__ helps inlining these wrappers at -O1. +#pragma push_macro("__DEVICE__") +#ifdef __OPENMP_NVPTX__ +#define __DEVICE__ static __attribute__((always_inline, nothrow)) +#else +#define __DEVICE__ static __device__ __forceinline__ +#endif + +__DEVICE__ int __all(int __a) { return __nvvm_vote_all(__a); } +__DEVICE__ int __any(int __a) { return __nvvm_vote_any(__a); } +__DEVICE__ unsigned int __ballot(int __a) { return __nvvm_vote_ballot(__a); } +__DEVICE__ unsigned int __brev(unsigned int __a) { return __nv_brev(__a); } +__DEVICE__ unsigned long long __brevll(unsigned long long __a) { + return __nv_brevll(__a); +} +#if defined(__cplusplus) +__DEVICE__ void __brkpt() { __asm__ __volatile__("brkpt;"); } +__DEVICE__ void __brkpt(int __a) { __brkpt(); } +#else +__DEVICE__ void __attribute__((overloadable)) __brkpt(void) { + __asm__ __volatile__("brkpt;"); +} +__DEVICE__ void __attribute__((overloadable)) __brkpt(int __a) { __brkpt(); } +#endif +__DEVICE__ unsigned int __byte_perm(unsigned int __a, unsigned int __b, + unsigned int __c) { + return __nv_byte_perm(__a, __b, __c); +} +__DEVICE__ int __clz(int __a) { return __nv_clz(__a); } +__DEVICE__ int __clzll(long long __a) { return __nv_clzll(__a); } +__DEVICE__ float __cosf(float __a) { return __nv_fast_cosf(__a); } +__DEVICE__ double __dAtomicAdd(double *__p, double __v) { + return __nvvm_atom_add_gen_d(__p, __v); +} +__DEVICE__ double __dAtomicAdd_block(double *__p, double __v) { + return __nvvm_atom_cta_add_gen_d(__p, __v); +} +__DEVICE__ double __dAtomicAdd_system(double *__p, double __v) { + return __nvvm_atom_sys_add_gen_d(__p, __v); +} +__DEVICE__ double __dadd_rd(double __a, double __b) { + return __nv_dadd_rd(__a, __b); +} +__DEVICE__ double __dadd_rn(double __a, double __b) { + return __nv_dadd_rn(__a, __b); +} +__DEVICE__ double __dadd_ru(double __a, double __b) { + return __nv_dadd_ru(__a, __b); +} +__DEVICE__ double __dadd_rz(double __a, double __b) { + return __nv_dadd_rz(__a, __b); +} +__DEVICE__ double __ddiv_rd(double __a, double __b) { + return __nv_ddiv_rd(__a, __b); +} +__DEVICE__ double __ddiv_rn(double __a, double __b) { + return __nv_ddiv_rn(__a, __b); +} +__DEVICE__ double __ddiv_ru(double __a, double __b) { + return __nv_ddiv_ru(__a, __b); +} +__DEVICE__ double __ddiv_rz(double __a, double __b) { + return __nv_ddiv_rz(__a, __b); +} +__DEVICE__ double __dmul_rd(double __a, double __b) { + return __nv_dmul_rd(__a, __b); +} +__DEVICE__ double __dmul_rn(double __a, double __b) { + return __nv_dmul_rn(__a, __b); +} +__DEVICE__ double __dmul_ru(double __a, double __b) { + return __nv_dmul_ru(__a, __b); +} +__DEVICE__ double __dmul_rz(double __a, double __b) { + return __nv_dmul_rz(__a, __b); +} +__DEVICE__ float __double2float_rd(double __a) { + return __nv_double2float_rd(__a); +} +__DEVICE__ float __double2float_rn(double __a) { + return __nv_double2float_rn(__a); +} +__DEVICE__ float __double2float_ru(double __a) { + return __nv_double2float_ru(__a); +} +__DEVICE__ float __double2float_rz(double __a) { + return __nv_double2float_rz(__a); +} +__DEVICE__ int __double2hiint(double __a) { return __nv_double2hiint(__a); } +__DEVICE__ int __double2int_rd(double __a) { return __nv_double2int_rd(__a); } +__DEVICE__ int __double2int_rn(double __a) { return __nv_double2int_rn(__a); } +__DEVICE__ int __double2int_ru(double __a) { return __nv_double2int_ru(__a); } +__DEVICE__ int __double2int_rz(double __a) { return __nv_double2int_rz(__a); } +__DEVICE__ long long __double2ll_rd(double __a) { + return __nv_double2ll_rd(__a); +} +__DEVICE__ long long __double2ll_rn(double __a) { + return __nv_double2ll_rn(__a); +} +__DEVICE__ long long __double2ll_ru(double __a) { + return __nv_double2ll_ru(__a); +} +__DEVICE__ long long __double2ll_rz(double __a) { + return __nv_double2ll_rz(__a); +} +__DEVICE__ int __double2loint(double __a) { return __nv_double2loint(__a); } +__DEVICE__ unsigned int __double2uint_rd(double __a) { + return __nv_double2uint_rd(__a); +} +__DEVICE__ unsigned int __double2uint_rn(double __a) { + return __nv_double2uint_rn(__a); +} +__DEVICE__ unsigned int __double2uint_ru(double __a) { + return __nv_double2uint_ru(__a); +} +__DEVICE__ unsigned int __double2uint_rz(double __a) { + return __nv_double2uint_rz(__a); +} +__DEVICE__ unsigned long long __double2ull_rd(double __a) { + return __nv_double2ull_rd(__a); +} +__DEVICE__ unsigned long long __double2ull_rn(double __a) { + return __nv_double2ull_rn(__a); +} +__DEVICE__ unsigned long long __double2ull_ru(double __a) { + return __nv_double2ull_ru(__a); +} +__DEVICE__ unsigned long long __double2ull_rz(double __a) { + return __nv_double2ull_rz(__a); +} +__DEVICE__ long long __double_as_longlong(double __a) { + return __nv_double_as_longlong(__a); +} +__DEVICE__ double __drcp_rd(double __a) { return __nv_drcp_rd(__a); } +__DEVICE__ double __drcp_rn(double __a) { return __nv_drcp_rn(__a); } +__DEVICE__ double __drcp_ru(double __a) { return __nv_drcp_ru(__a); } +__DEVICE__ double __drcp_rz(double __a) { return __nv_drcp_rz(__a); } +__DEVICE__ double __dsqrt_rd(double __a) { return __nv_dsqrt_rd(__a); } +__DEVICE__ double __dsqrt_rn(double __a) { return __nv_dsqrt_rn(__a); } +__DEVICE__ double __dsqrt_ru(double __a) { return __nv_dsqrt_ru(__a); } +__DEVICE__ double __dsqrt_rz(double __a) { return __nv_dsqrt_rz(__a); } +__DEVICE__ double __dsub_rd(double __a, double __b) { + return __nv_dsub_rd(__a, __b); +} +__DEVICE__ double __dsub_rn(double __a, double __b) { + return __nv_dsub_rn(__a, __b); +} +__DEVICE__ double __dsub_ru(double __a, double __b) { + return __nv_dsub_ru(__a, __b); +} +__DEVICE__ double __dsub_rz(double __a, double __b) { + return __nv_dsub_rz(__a, __b); +} +__DEVICE__ float __exp10f(float __a) { return __nv_fast_exp10f(__a); } +__DEVICE__ float __expf(float __a) { return __nv_fast_expf(__a); } +__DEVICE__ float __fAtomicAdd(float *__p, float __v) { + return __nvvm_atom_add_gen_f(__p, __v); +} +__DEVICE__ float __fAtomicAdd_block(float *__p, float __v) { + return __nvvm_atom_cta_add_gen_f(__p, __v); +} +__DEVICE__ float __fAtomicAdd_system(float *__p, float __v) { + return __nvvm_atom_sys_add_gen_f(__p, __v); +} +__DEVICE__ float __fAtomicExch(float *__p, float __v) { + return __nv_int_as_float( + __nvvm_atom_xchg_gen_i((int *)__p, __nv_float_as_int(__v))); +} +__DEVICE__ float __fAtomicExch_block(float *__p, float __v) { + return __nv_int_as_float( + __nvvm_atom_cta_xchg_gen_i((int *)__p, __nv_float_as_int(__v))); +} +__DEVICE__ float __fAtomicExch_system(float *__p, float __v) { + return __nv_int_as_float( + __nvvm_atom_sys_xchg_gen_i((int *)__p, __nv_float_as_int(__v))); +} +__DEVICE__ float __fadd_rd(float __a, float __b) { + return __nv_fadd_rd(__a, __b); +} +__DEVICE__ float __fadd_rn(float __a, float __b) { + return __nv_fadd_rn(__a, __b); +} +__DEVICE__ float __fadd_ru(float __a, float __b) { + return __nv_fadd_ru(__a, __b); +} +__DEVICE__ float __fadd_rz(float __a, float __b) { + return __nv_fadd_rz(__a, __b); +} +__DEVICE__ float __fdiv_rd(float __a, float __b) { + return __nv_fdiv_rd(__a, __b); +} +__DEVICE__ float __fdiv_rn(float __a, float __b) { + return __nv_fdiv_rn(__a, __b); +} +__DEVICE__ float __fdiv_ru(float __a, float __b) { + return __nv_fdiv_ru(__a, __b); +} +__DEVICE__ float __fdiv_rz(float __a, float __b) { + return __nv_fdiv_rz(__a, __b); +} +__DEVICE__ float __fdividef(float __a, float __b) { + return __nv_fast_fdividef(__a, __b); +} +__DEVICE__ int __ffs(int __a) { return __nv_ffs(__a); } +__DEVICE__ int __ffsll(long long __a) { return __nv_ffsll(__a); } +__DEVICE__ int __finite(double __a) { return __nv_isfinited(__a); } +__DEVICE__ int __finitef(float __a) { return __nv_finitef(__a); } +#ifdef _MSC_VER +__DEVICE__ int __finitel(long double __a); +#endif +__DEVICE__ int __float2int_rd(float __a) { return __nv_float2int_rd(__a); } +__DEVICE__ int __float2int_rn(float __a) { return __nv_float2int_rn(__a); } +__DEVICE__ int __float2int_ru(float __a) { return __nv_float2int_ru(__a); } +__DEVICE__ int __float2int_rz(float __a) { return __nv_float2int_rz(__a); } +__DEVICE__ long long __float2ll_rd(float __a) { return __nv_float2ll_rd(__a); } +__DEVICE__ long long __float2ll_rn(float __a) { return __nv_float2ll_rn(__a); } +__DEVICE__ long long __float2ll_ru(float __a) { return __nv_float2ll_ru(__a); } +__DEVICE__ long long __float2ll_rz(float __a) { return __nv_float2ll_rz(__a); } +__DEVICE__ unsigned int __float2uint_rd(float __a) { + return __nv_float2uint_rd(__a); +} +__DEVICE__ unsigned int __float2uint_rn(float __a) { + return __nv_float2uint_rn(__a); +} +__DEVICE__ unsigned int __float2uint_ru(float __a) { + return __nv_float2uint_ru(__a); +} +__DEVICE__ unsigned int __float2uint_rz(float __a) { + return __nv_float2uint_rz(__a); +} +__DEVICE__ unsigned long long __float2ull_rd(float __a) { + return __nv_float2ull_rd(__a); +} +__DEVICE__ unsigned long long __float2ull_rn(float __a) { + return __nv_float2ull_rn(__a); +} +__DEVICE__ unsigned long long __float2ull_ru(float __a) { + return __nv_float2ull_ru(__a); +} +__DEVICE__ unsigned long long __float2ull_rz(float __a) { + return __nv_float2ull_rz(__a); +} +__DEVICE__ int __float_as_int(float __a) { return __nv_float_as_int(__a); } +__DEVICE__ unsigned int __float_as_uint(float __a) { + return __nv_float_as_uint(__a); +} +__DEVICE__ double __fma_rd(double __a, double __b, double __c) { + return __nv_fma_rd(__a, __b, __c); +} +__DEVICE__ double __fma_rn(double __a, double __b, double __c) { + return __nv_fma_rn(__a, __b, __c); +} +__DEVICE__ double __fma_ru(double __a, double __b, double __c) { + return __nv_fma_ru(__a, __b, __c); +} +__DEVICE__ double __fma_rz(double __a, double __b, double __c) { + return __nv_fma_rz(__a, __b, __c); +} +__DEVICE__ float __fmaf_ieee_rd(float __a, float __b, float __c) { + return __nv_fmaf_ieee_rd(__a, __b, __c); +} +__DEVICE__ float __fmaf_ieee_rn(float __a, float __b, float __c) { + return __nv_fmaf_ieee_rn(__a, __b, __c); +} +__DEVICE__ float __fmaf_ieee_ru(float __a, float __b, float __c) { + return __nv_fmaf_ieee_ru(__a, __b, __c); +} +__DEVICE__ float __fmaf_ieee_rz(float __a, float __b, float __c) { + return __nv_fmaf_ieee_rz(__a, __b, __c); +} +__DEVICE__ float __fmaf_rd(float __a, float __b, float __c) { + return __nv_fmaf_rd(__a, __b, __c); +} +__DEVICE__ float __fmaf_rn(float __a, float __b, float __c) { + return __nv_fmaf_rn(__a, __b, __c); +} +__DEVICE__ float __fmaf_ru(float __a, float __b, float __c) { + return __nv_fmaf_ru(__a, __b, __c); +} +__DEVICE__ float __fmaf_rz(float __a, float __b, float __c) { + return __nv_fmaf_rz(__a, __b, __c); +} +__DEVICE__ float __fmul_rd(float __a, float __b) { + return __nv_fmul_rd(__a, __b); +} +__DEVICE__ float __fmul_rn(float __a, float __b) { + return __nv_fmul_rn(__a, __b); +} +__DEVICE__ float __fmul_ru(float __a, float __b) { + return __nv_fmul_ru(__a, __b); +} +__DEVICE__ float __fmul_rz(float __a, float __b) { + return __nv_fmul_rz(__a, __b); +} +__DEVICE__ float __frcp_rd(float __a) { return __nv_frcp_rd(__a); } +__DEVICE__ float __frcp_rn(float __a) { return __nv_frcp_rn(__a); } +__DEVICE__ float __frcp_ru(float __a) { return __nv_frcp_ru(__a); } +__DEVICE__ float __frcp_rz(float __a) { return __nv_frcp_rz(__a); } +__DEVICE__ float __frsqrt_rn(float __a) { return __nv_frsqrt_rn(__a); } +__DEVICE__ float __fsqrt_rd(float __a) { return __nv_fsqrt_rd(__a); } +__DEVICE__ float __fsqrt_rn(float __a) { return __nv_fsqrt_rn(__a); } +__DEVICE__ float __fsqrt_ru(float __a) { return __nv_fsqrt_ru(__a); } +__DEVICE__ float __fsqrt_rz(float __a) { return __nv_fsqrt_rz(__a); } +__DEVICE__ float __fsub_rd(float __a, float __b) { + return __nv_fsub_rd(__a, __b); +} +__DEVICE__ float __fsub_rn(float __a, float __b) { + return __nv_fsub_rn(__a, __b); +} +__DEVICE__ float __fsub_ru(float __a, float __b) { + return __nv_fsub_ru(__a, __b); +} +__DEVICE__ float __fsub_rz(float __a, float __b) { + return __nv_fsub_rz(__a, __b); +} +__DEVICE__ int __hadd(int __a, int __b) { return __nv_hadd(__a, __b); } +__DEVICE__ double __hiloint2double(int __a, int __b) { + return __nv_hiloint2double(__a, __b); +} +__DEVICE__ int __iAtomicAdd(int *__p, int __v) { + return __nvvm_atom_add_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicAdd_block(int *__p, int __v) { + return __nvvm_atom_cta_add_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicAdd_system(int *__p, int __v) { + return __nvvm_atom_sys_add_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicAnd(int *__p, int __v) { + return __nvvm_atom_and_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicAnd_block(int *__p, int __v) { + return __nvvm_atom_cta_and_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicAnd_system(int *__p, int __v) { + return __nvvm_atom_sys_and_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicCAS(int *__p, int __cmp, int __v) { + return __nvvm_atom_cas_gen_i(__p, __cmp, __v); +} +__DEVICE__ int __iAtomicCAS_block(int *__p, int __cmp, int __v) { + return __nvvm_atom_cta_cas_gen_i(__p, __cmp, __v); +} +__DEVICE__ int __iAtomicCAS_system(int *__p, int __cmp, int __v) { + return __nvvm_atom_sys_cas_gen_i(__p, __cmp, __v); +} +__DEVICE__ int __iAtomicExch(int *__p, int __v) { + return __nvvm_atom_xchg_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicExch_block(int *__p, int __v) { + return __nvvm_atom_cta_xchg_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicExch_system(int *__p, int __v) { + return __nvvm_atom_sys_xchg_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicMax(int *__p, int __v) { + return __nvvm_atom_max_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicMax_block(int *__p, int __v) { + return __nvvm_atom_cta_max_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicMax_system(int *__p, int __v) { + return __nvvm_atom_sys_max_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicMin(int *__p, int __v) { + return __nvvm_atom_min_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicMin_block(int *__p, int __v) { + return __nvvm_atom_cta_min_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicMin_system(int *__p, int __v) { + return __nvvm_atom_sys_min_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicOr(int *__p, int __v) { + return __nvvm_atom_or_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicOr_block(int *__p, int __v) { + return __nvvm_atom_cta_or_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicOr_system(int *__p, int __v) { + return __nvvm_atom_sys_or_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicXor(int *__p, int __v) { + return __nvvm_atom_xor_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicXor_block(int *__p, int __v) { + return __nvvm_atom_cta_xor_gen_i(__p, __v); +} +__DEVICE__ int __iAtomicXor_system(int *__p, int __v) { + return __nvvm_atom_sys_xor_gen_i(__p, __v); +} +__DEVICE__ long long __illAtomicMax(long long *__p, long long __v) { + return __nvvm_atom_max_gen_ll(__p, __v); +} +__DEVICE__ long long __illAtomicMax_block(long long *__p, long long __v) { + return __nvvm_atom_cta_max_gen_ll(__p, __v); +} +__DEVICE__ long long __illAtomicMax_system(long long *__p, long long __v) { + return __nvvm_atom_sys_max_gen_ll(__p, __v); +} +__DEVICE__ long long __illAtomicMin(long long *__p, long long __v) { + return __nvvm_atom_min_gen_ll(__p, __v); +} +__DEVICE__ long long __illAtomicMin_block(long long *__p, long long __v) { + return __nvvm_atom_cta_min_gen_ll(__p, __v); +} +__DEVICE__ long long __illAtomicMin_system(long long *__p, long long __v) { + return __nvvm_atom_sys_min_gen_ll(__p, __v); +} +__DEVICE__ double __int2double_rn(int __a) { return __nv_int2double_rn(__a); } +__DEVICE__ float __int2float_rd(int __a) { return __nv_int2float_rd(__a); } +__DEVICE__ float __int2float_rn(int __a) { return __nv_int2float_rn(__a); } +__DEVICE__ float __int2float_ru(int __a) { return __nv_int2float_ru(__a); } +__DEVICE__ float __int2float_rz(int __a) { return __nv_int2float_rz(__a); } +__DEVICE__ float __int_as_float(int __a) { return __nv_int_as_float(__a); } +__DEVICE__ int __isfinited(double __a) { return __nv_isfinited(__a); } +__DEVICE__ int __isinf(double __a) { return __nv_isinfd(__a); } +__DEVICE__ int __isinff(float __a) { return __nv_isinff(__a); } +#ifdef _MSC_VER +__DEVICE__ int __isinfl(long double __a); +#endif +__DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } +__DEVICE__ int __isnanf(float __a) { return __nv_isnanf(__a); } +#ifdef _MSC_VER +__DEVICE__ int __isnanl(long double __a); +#endif +__DEVICE__ double __ll2double_rd(long long __a) { + return __nv_ll2double_rd(__a); +} +__DEVICE__ double __ll2double_rn(long long __a) { + return __nv_ll2double_rn(__a); +} +__DEVICE__ double __ll2double_ru(long long __a) { + return __nv_ll2double_ru(__a); +} +__DEVICE__ double __ll2double_rz(long long __a) { + return __nv_ll2double_rz(__a); +} +__DEVICE__ float __ll2float_rd(long long __a) { return __nv_ll2float_rd(__a); } +__DEVICE__ float __ll2float_rn(long long __a) { return __nv_ll2float_rn(__a); } +__DEVICE__ float __ll2float_ru(long long __a) { return __nv_ll2float_ru(__a); } +__DEVICE__ float __ll2float_rz(long long __a) { return __nv_ll2float_rz(__a); } +__DEVICE__ long long __llAtomicAnd(long long *__p, long long __v) { + return __nvvm_atom_and_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicAnd_block(long long *__p, long long __v) { + return __nvvm_atom_cta_and_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicAnd_system(long long *__p, long long __v) { + return __nvvm_atom_sys_and_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicOr(long long *__p, long long __v) { + return __nvvm_atom_or_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicOr_block(long long *__p, long long __v) { + return __nvvm_atom_cta_or_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicOr_system(long long *__p, long long __v) { + return __nvvm_atom_sys_or_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicXor(long long *__p, long long __v) { + return __nvvm_atom_xor_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicXor_block(long long *__p, long long __v) { + return __nvvm_atom_cta_xor_gen_ll(__p, __v); +} +__DEVICE__ long long __llAtomicXor_system(long long *__p, long long __v) { + return __nvvm_atom_sys_xor_gen_ll(__p, __v); +} +__DEVICE__ float __log10f(float __a) { return __nv_fast_log10f(__a); } +__DEVICE__ float __log2f(float __a) { return __nv_fast_log2f(__a); } +__DEVICE__ float __logf(float __a) { return __nv_fast_logf(__a); } +__DEVICE__ double __longlong_as_double(long long __a) { + return __nv_longlong_as_double(__a); +} +__DEVICE__ int __mul24(int __a, int __b) { return __nv_mul24(__a, __b); } +__DEVICE__ long long __mul64hi(long long __a, long long __b) { + return __nv_mul64hi(__a, __b); +} +__DEVICE__ int __mulhi(int __a, int __b) { return __nv_mulhi(__a, __b); } +__DEVICE__ unsigned int __pm0(void) { return __nvvm_read_ptx_sreg_pm0(); } +__DEVICE__ unsigned int __pm1(void) { return __nvvm_read_ptx_sreg_pm1(); } +__DEVICE__ unsigned int __pm2(void) { return __nvvm_read_ptx_sreg_pm2(); } +__DEVICE__ unsigned int __pm3(void) { return __nvvm_read_ptx_sreg_pm3(); } +__DEVICE__ int __popc(unsigned int __a) { return __nv_popc(__a); } +__DEVICE__ int __popcll(unsigned long long __a) { return __nv_popcll(__a); } +__DEVICE__ float __powf(float __a, float __b) { + return __nv_fast_powf(__a, __b); +} + +// Parameter must have a known integer value. +#define __prof_trigger(__a) __asm__ __volatile__("pmevent \t%0;" ::"i"(__a)) +__DEVICE__ int __rhadd(int __a, int __b) { return __nv_rhadd(__a, __b); } +__DEVICE__ unsigned int __sad(int __a, int __b, unsigned int __c) { + return __nv_sad(__a, __b, __c); +} +__DEVICE__ float __saturatef(float __a) { return __nv_saturatef(__a); } +__DEVICE__ int __signbitd(double __a) { return __nv_signbitd(__a); } +__DEVICE__ int __signbitf(float __a) { return __nv_signbitf(__a); } +__DEVICE__ void __sincosf(float __a, float *__s, float *__c) { + return __nv_fast_sincosf(__a, __s, __c); +} +__DEVICE__ float __sinf(float __a) { return __nv_fast_sinf(__a); } +__DEVICE__ int __syncthreads_and(int __a) { return __nvvm_bar0_and(__a); } +__DEVICE__ int __syncthreads_count(int __a) { return __nvvm_bar0_popc(__a); } +__DEVICE__ int __syncthreads_or(int __a) { return __nvvm_bar0_or(__a); } +__DEVICE__ float __tanf(float __a) { return __nv_fast_tanf(__a); } +__DEVICE__ void __threadfence(void) { __nvvm_membar_gl(); } +__DEVICE__ void __threadfence_block(void) { __nvvm_membar_cta(); }; +__DEVICE__ void __threadfence_system(void) { __nvvm_membar_sys(); }; +__DEVICE__ void __trap(void) { __asm__ __volatile__("trap;"); } +__DEVICE__ unsigned short +__usAtomicCAS(unsigned short *__p, unsigned short __cmp, unsigned short __v) { + return __nvvm_atom_cas_gen_us(__p, __cmp, __v); +} +__DEVICE__ unsigned short __usAtomicCAS_block(unsigned short *__p, + unsigned short __cmp, + unsigned short __v) { + return __nvvm_atom_cta_cas_gen_us(__p, __cmp, __v); +} +__DEVICE__ unsigned short __usAtomicCAS_system(unsigned short *__p, + unsigned short __cmp, + unsigned short __v) { + return __nvvm_atom_sys_cas_gen_us(__p, __cmp, __v); +} +__DEVICE__ unsigned int __uAtomicAdd(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_add_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicAdd_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_add_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicAdd_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_add_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicAnd(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_and_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicAnd_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_and_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicAnd_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_and_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicCAS(unsigned int *__p, unsigned int __cmp, + unsigned int __v) { + return __nvvm_atom_cas_gen_i((int *)__p, __cmp, __v); +} +__DEVICE__ unsigned int +__uAtomicCAS_block(unsigned int *__p, unsigned int __cmp, unsigned int __v) { + return __nvvm_atom_cta_cas_gen_i((int *)__p, __cmp, __v); +} +__DEVICE__ unsigned int +__uAtomicCAS_system(unsigned int *__p, unsigned int __cmp, unsigned int __v) { + return __nvvm_atom_sys_cas_gen_i((int *)__p, __cmp, __v); +} +__DEVICE__ unsigned int __uAtomicDec(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_dec_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicDec_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_dec_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicDec_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_dec_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicExch(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_xchg_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicExch_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_xchg_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicExch_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_xchg_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicInc(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_inc_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicInc_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_inc_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicInc_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_inc_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicMax(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_max_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicMax_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_max_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicMax_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_max_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicMin(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_min_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicMin_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_min_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicMin_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_min_gen_ui(__p, __v); +} +__DEVICE__ unsigned int __uAtomicOr(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_or_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicOr_block(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_cta_or_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicOr_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_or_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicXor(unsigned int *__p, unsigned int __v) { + return __nvvm_atom_xor_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicXor_block(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_cta_xor_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uAtomicXor_system(unsigned int *__p, + unsigned int __v) { + return __nvvm_atom_sys_xor_gen_i((int *)__p, __v); +} +__DEVICE__ unsigned int __uhadd(unsigned int __a, unsigned int __b) { + return __nv_uhadd(__a, __b); +} +__DEVICE__ double __uint2double_rn(unsigned int __a) { + return __nv_uint2double_rn(__a); +} +__DEVICE__ float __uint2float_rd(unsigned int __a) { + return __nv_uint2float_rd(__a); +} +__DEVICE__ float __uint2float_rn(unsigned int __a) { + return __nv_uint2float_rn(__a); +} +__DEVICE__ float __uint2float_ru(unsigned int __a) { + return __nv_uint2float_ru(__a); +} +__DEVICE__ float __uint2float_rz(unsigned int __a) { + return __nv_uint2float_rz(__a); +} +__DEVICE__ float __uint_as_float(unsigned int __a) { + return __nv_uint_as_float(__a); +} // +__DEVICE__ double __ull2double_rd(unsigned long long __a) { + return __nv_ull2double_rd(__a); +} +__DEVICE__ double __ull2double_rn(unsigned long long __a) { + return __nv_ull2double_rn(__a); +} +__DEVICE__ double __ull2double_ru(unsigned long long __a) { + return __nv_ull2double_ru(__a); +} +__DEVICE__ double __ull2double_rz(unsigned long long __a) { + return __nv_ull2double_rz(__a); +} +__DEVICE__ float __ull2float_rd(unsigned long long __a) { + return __nv_ull2float_rd(__a); +} +__DEVICE__ float __ull2float_rn(unsigned long long __a) { + return __nv_ull2float_rn(__a); +} +__DEVICE__ float __ull2float_ru(unsigned long long __a) { + return __nv_ull2float_ru(__a); +} +__DEVICE__ float __ull2float_rz(unsigned long long __a) { + return __nv_ull2float_rz(__a); +} +__DEVICE__ unsigned long long __ullAtomicAdd(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_add_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicAdd_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_add_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicAdd_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_add_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicAnd(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_and_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicAnd_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_and_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicAnd_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_and_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicCAS(unsigned long long *__p, + unsigned long long __cmp, + unsigned long long __v) { + return __nvvm_atom_cas_gen_ll((long long *)__p, __cmp, __v); +} +__DEVICE__ unsigned long long __ullAtomicCAS_block(unsigned long long *__p, + unsigned long long __cmp, + unsigned long long __v) { + return __nvvm_atom_cta_cas_gen_ll((long long *)__p, __cmp, __v); +} +__DEVICE__ unsigned long long __ullAtomicCAS_system(unsigned long long *__p, + unsigned long long __cmp, + unsigned long long __v) { + return __nvvm_atom_sys_cas_gen_ll((long long *)__p, __cmp, __v); +} +__DEVICE__ unsigned long long __ullAtomicExch(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_xchg_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicExch_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_xchg_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicExch_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_xchg_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicMax(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_max_gen_ull(__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicMax_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_max_gen_ull(__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicMax_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_max_gen_ull(__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicMin(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_min_gen_ull(__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicMin_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_min_gen_ull(__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicMin_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_min_gen_ull(__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicOr(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_or_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicOr_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_or_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicOr_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_or_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicXor(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_xor_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicXor_block(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_cta_xor_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned long long __ullAtomicXor_system(unsigned long long *__p, + unsigned long long __v) { + return __nvvm_atom_sys_xor_gen_ll((long long *)__p, __v); +} +__DEVICE__ unsigned int __umul24(unsigned int __a, unsigned int __b) { + return __nv_umul24(__a, __b); +} +__DEVICE__ unsigned long long __umul64hi(unsigned long long __a, + unsigned long long __b) { + return __nv_umul64hi(__a, __b); +} +__DEVICE__ unsigned int __umulhi(unsigned int __a, unsigned int __b) { + return __nv_umulhi(__a, __b); +} +__DEVICE__ unsigned int __urhadd(unsigned int __a, unsigned int __b) { + return __nv_urhadd(__a, __b); +} +__DEVICE__ unsigned int __usad(unsigned int __a, unsigned int __b, + unsigned int __c) { + return __nv_usad(__a, __b, __c); +} + +#if CUDA_VERSION >= 9000 && CUDA_VERSION < 9020 +__DEVICE__ unsigned int __vabs2(unsigned int __a) { return __nv_vabs2(__a); } +__DEVICE__ unsigned int __vabs4(unsigned int __a) { return __nv_vabs4(__a); } +__DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) { + return __nv_vabsdiffs2(__a, __b); +} +__DEVICE__ unsigned int __vabsdiffs4(unsigned int __a, unsigned int __b) { + return __nv_vabsdiffs4(__a, __b); +} +__DEVICE__ unsigned int __vabsdiffu2(unsigned int __a, unsigned int __b) { + return __nv_vabsdiffu2(__a, __b); +} +__DEVICE__ unsigned int __vabsdiffu4(unsigned int __a, unsigned int __b) { + return __nv_vabsdiffu4(__a, __b); +} +__DEVICE__ unsigned int __vabsss2(unsigned int __a) { + return __nv_vabsss2(__a); +} +__DEVICE__ unsigned int __vabsss4(unsigned int __a) { + return __nv_vabsss4(__a); +} +__DEVICE__ unsigned int __vadd2(unsigned int __a, unsigned int __b) { + return __nv_vadd2(__a, __b); +} +__DEVICE__ unsigned int __vadd4(unsigned int __a, unsigned int __b) { + return __nv_vadd4(__a, __b); +} +__DEVICE__ unsigned int __vaddss2(unsigned int __a, unsigned int __b) { + return __nv_vaddss2(__a, __b); +} +__DEVICE__ unsigned int __vaddss4(unsigned int __a, unsigned int __b) { + return __nv_vaddss4(__a, __b); +} +__DEVICE__ unsigned int __vaddus2(unsigned int __a, unsigned int __b) { + return __nv_vaddus2(__a, __b); +} +__DEVICE__ unsigned int __vaddus4(unsigned int __a, unsigned int __b) { + return __nv_vaddus4(__a, __b); +} +__DEVICE__ unsigned int __vavgs2(unsigned int __a, unsigned int __b) { + return __nv_vavgs2(__a, __b); +} +__DEVICE__ unsigned int __vavgs4(unsigned int __a, unsigned int __b) { + return __nv_vavgs4(__a, __b); +} +__DEVICE__ unsigned int __vavgu2(unsigned int __a, unsigned int __b) { + return __nv_vavgu2(__a, __b); +} +__DEVICE__ unsigned int __vavgu4(unsigned int __a, unsigned int __b) { + return __nv_vavgu4(__a, __b); +} +__DEVICE__ unsigned int __vcmpeq2(unsigned int __a, unsigned int __b) { + return __nv_vcmpeq2(__a, __b); +} +__DEVICE__ unsigned int __vcmpeq4(unsigned int __a, unsigned int __b) { + return __nv_vcmpeq4(__a, __b); +} +__DEVICE__ unsigned int __vcmpges2(unsigned int __a, unsigned int __b) { + return __nv_vcmpges2(__a, __b); +} +__DEVICE__ unsigned int __vcmpges4(unsigned int __a, unsigned int __b) { + return __nv_vcmpges4(__a, __b); +} +__DEVICE__ unsigned int __vcmpgeu2(unsigned int __a, unsigned int __b) { + return __nv_vcmpgeu2(__a, __b); +} +__DEVICE__ unsigned int __vcmpgeu4(unsigned int __a, unsigned int __b) { + return __nv_vcmpgeu4(__a, __b); +} +__DEVICE__ unsigned int __vcmpgts2(unsigned int __a, unsigned int __b) { + return __nv_vcmpgts2(__a, __b); +} +__DEVICE__ unsigned int __vcmpgts4(unsigned int __a, unsigned int __b) { + return __nv_vcmpgts4(__a, __b); +} +__DEVICE__ unsigned int __vcmpgtu2(unsigned int __a, unsigned int __b) { + return __nv_vcmpgtu2(__a, __b); +} +__DEVICE__ unsigned int __vcmpgtu4(unsigned int __a, unsigned int __b) { + return __nv_vcmpgtu4(__a, __b); +} +__DEVICE__ unsigned int __vcmples2(unsigned int __a, unsigned int __b) { + return __nv_vcmples2(__a, __b); +} +__DEVICE__ unsigned int __vcmples4(unsigned int __a, unsigned int __b) { + return __nv_vcmples4(__a, __b); +} +__DEVICE__ unsigned int __vcmpleu2(unsigned int __a, unsigned int __b) { + return __nv_vcmpleu2(__a, __b); +} +__DEVICE__ unsigned int __vcmpleu4(unsigned int __a, unsigned int __b) { + return __nv_vcmpleu4(__a, __b); +} +__DEVICE__ unsigned int __vcmplts2(unsigned int __a, unsigned int __b) { + return __nv_vcmplts2(__a, __b); +} +__DEVICE__ unsigned int __vcmplts4(unsigned int __a, unsigned int __b) { + return __nv_vcmplts4(__a, __b); +} +__DEVICE__ unsigned int __vcmpltu2(unsigned int __a, unsigned int __b) { + return __nv_vcmpltu2(__a, __b); +} +__DEVICE__ unsigned int __vcmpltu4(unsigned int __a, unsigned int __b) { + return __nv_vcmpltu4(__a, __b); +} +__DEVICE__ unsigned int __vcmpne2(unsigned int __a, unsigned int __b) { + return __nv_vcmpne2(__a, __b); +} +__DEVICE__ unsigned int __vcmpne4(unsigned int __a, unsigned int __b) { + return __nv_vcmpne4(__a, __b); +} +__DEVICE__ unsigned int __vhaddu2(unsigned int __a, unsigned int __b) { + return __nv_vhaddu2(__a, __b); +} +__DEVICE__ unsigned int __vhaddu4(unsigned int __a, unsigned int __b) { + return __nv_vhaddu4(__a, __b); +} +__DEVICE__ unsigned int __vmaxs2(unsigned int __a, unsigned int __b) { + return __nv_vmaxs2(__a, __b); +} +__DEVICE__ unsigned int __vmaxs4(unsigned int __a, unsigned int __b) { + return __nv_vmaxs4(__a, __b); +} +__DEVICE__ unsigned int __vmaxu2(unsigned int __a, unsigned int __b) { + return __nv_vmaxu2(__a, __b); +} +__DEVICE__ unsigned int __vmaxu4(unsigned int __a, unsigned int __b) { + return __nv_vmaxu4(__a, __b); +} +__DEVICE__ unsigned int __vmins2(unsigned int __a, unsigned int __b) { + return __nv_vmins2(__a, __b); +} +__DEVICE__ unsigned int __vmins4(unsigned int __a, unsigned int __b) { + return __nv_vmins4(__a, __b); +} +__DEVICE__ unsigned int __vminu2(unsigned int __a, unsigned int __b) { + return __nv_vminu2(__a, __b); +} +__DEVICE__ unsigned int __vminu4(unsigned int __a, unsigned int __b) { + return __nv_vminu4(__a, __b); +} +__DEVICE__ unsigned int __vneg2(unsigned int __a) { return __nv_vneg2(__a); } +__DEVICE__ unsigned int __vneg4(unsigned int __a) { return __nv_vneg4(__a); } +__DEVICE__ unsigned int __vnegss2(unsigned int __a) { + return __nv_vnegss2(__a); +} +__DEVICE__ unsigned int __vnegss4(unsigned int __a) { + return __nv_vnegss4(__a); +} +__DEVICE__ unsigned int __vsads2(unsigned int __a, unsigned int __b) { + return __nv_vsads2(__a, __b); +} +__DEVICE__ unsigned int __vsads4(unsigned int __a, unsigned int __b) { + return __nv_vsads4(__a, __b); +} +__DEVICE__ unsigned int __vsadu2(unsigned int __a, unsigned int __b) { + return __nv_vsadu2(__a, __b); +} +__DEVICE__ unsigned int __vsadu4(unsigned int __a, unsigned int __b) { + return __nv_vsadu4(__a, __b); +} +__DEVICE__ unsigned int __vseteq2(unsigned int __a, unsigned int __b) { + return __nv_vseteq2(__a, __b); +} +__DEVICE__ unsigned int __vseteq4(unsigned int __a, unsigned int __b) { + return __nv_vseteq4(__a, __b); +} +__DEVICE__ unsigned int __vsetges2(unsigned int __a, unsigned int __b) { + return __nv_vsetges2(__a, __b); +} +__DEVICE__ unsigned int __vsetges4(unsigned int __a, unsigned int __b) { + return __nv_vsetges4(__a, __b); +} +__DEVICE__ unsigned int __vsetgeu2(unsigned int __a, unsigned int __b) { + return __nv_vsetgeu2(__a, __b); +} +__DEVICE__ unsigned int __vsetgeu4(unsigned int __a, unsigned int __b) { + return __nv_vsetgeu4(__a, __b); +} +__DEVICE__ unsigned int __vsetgts2(unsigned int __a, unsigned int __b) { + return __nv_vsetgts2(__a, __b); +} +__DEVICE__ unsigned int __vsetgts4(unsigned int __a, unsigned int __b) { + return __nv_vsetgts4(__a, __b); +} +__DEVICE__ unsigned int __vsetgtu2(unsigned int __a, unsigned int __b) { + return __nv_vsetgtu2(__a, __b); +} +__DEVICE__ unsigned int __vsetgtu4(unsigned int __a, unsigned int __b) { + return __nv_vsetgtu4(__a, __b); +} +__DEVICE__ unsigned int __vsetles2(unsigned int __a, unsigned int __b) { + return __nv_vsetles2(__a, __b); +} +__DEVICE__ unsigned int __vsetles4(unsigned int __a, unsigned int __b) { + return __nv_vsetles4(__a, __b); +} +__DEVICE__ unsigned int __vsetleu2(unsigned int __a, unsigned int __b) { + return __nv_vsetleu2(__a, __b); +} +__DEVICE__ unsigned int __vsetleu4(unsigned int __a, unsigned int __b) { + return __nv_vsetleu4(__a, __b); +} +__DEVICE__ unsigned int __vsetlts2(unsigned int __a, unsigned int __b) { + return __nv_vsetlts2(__a, __b); +} +__DEVICE__ unsigned int __vsetlts4(unsigned int __a, unsigned int __b) { + return __nv_vsetlts4(__a, __b); +} +__DEVICE__ unsigned int __vsetltu2(unsigned int __a, unsigned int __b) { + return __nv_vsetltu2(__a, __b); +} +__DEVICE__ unsigned int __vsetltu4(unsigned int __a, unsigned int __b) { + return __nv_vsetltu4(__a, __b); +} +__DEVICE__ unsigned int __vsetne2(unsigned int __a, unsigned int __b) { + return __nv_vsetne2(__a, __b); +} +__DEVICE__ unsigned int __vsetne4(unsigned int __a, unsigned int __b) { + return __nv_vsetne4(__a, __b); +} +__DEVICE__ unsigned int __vsub2(unsigned int __a, unsigned int __b) { + return __nv_vsub2(__a, __b); +} +__DEVICE__ unsigned int __vsub4(unsigned int __a, unsigned int __b) { + return __nv_vsub4(__a, __b); +} +__DEVICE__ unsigned int __vsubss2(unsigned int __a, unsigned int __b) { + return __nv_vsubss2(__a, __b); +} +__DEVICE__ unsigned int __vsubss4(unsigned int __a, unsigned int __b) { + return __nv_vsubss4(__a, __b); +} +__DEVICE__ unsigned int __vsubus2(unsigned int __a, unsigned int __b) { + return __nv_vsubus2(__a, __b); +} +__DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) { + return __nv_vsubus4(__a, __b); +} +#else // CUDA_VERSION >= 9020 +// CUDA no longer provides inline assembly (or bitcode) implementation of these +// functions, so we have to reimplment them. The implementation is naive and is +// not optimized for performance. + +// Helper function to convert N-bit boolean subfields into all-0 or all-1. +// E.g. __bool2mask(0x01000100,8) -> 0xff00ff00 +// __bool2mask(0x00010000,16) -> 0xffff0000 +__DEVICE__ unsigned int __bool2mask(unsigned int __a, int shift) { + return (__a << shift) - __a; +} +__DEVICE__ unsigned int __vabs2(unsigned int __a) { + unsigned int r; + __asm__("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabs4(unsigned int __a) { + unsigned int r; + __asm__("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffs2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} + +__DEVICE__ unsigned int __vabsdiffs4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsdiffu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsss2(unsigned int __a) { + unsigned int r; + __asm__("vabsdiff2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vabsss4(unsigned int __a) { + unsigned int r; + __asm__("vabsdiff4.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(0), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vadd2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vadd2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vadd4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vadd4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddss2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vadd2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddss4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vadd4.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddus2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vadd2.u32.u32.u32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vaddus4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vadd4.u32.u32.u32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vavgs2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vavrg2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vavgs4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vavrg4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vavgu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vavrg2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vavgu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vavrg4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vseteq2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.u32.u32.eq %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpeq2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vseteq2(__a, __b), 16); +} +__DEVICE__ unsigned int __vseteq4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.u32.u32.eq %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpeq4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vseteq4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetges2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.s32.s32.ge %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpges2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetges2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetges4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.s32.s32.ge %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpges4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetges4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetgeu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.u32.u32.ge %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpgeu2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetgeu2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetgeu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.u32.u32.ge %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpgeu4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetgeu4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetgts2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.s32.s32.gt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpgts2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetgts2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetgts4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.s32.s32.gt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpgts4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetgts4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetgtu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.u32.u32.gt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpgtu2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetgtu2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetgtu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.u32.u32.gt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpgtu4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetgtu4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetles2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.s32.s32.le %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmples2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetles2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetles4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.s32.s32.le %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmples4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetles4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetleu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.u32.u32.le %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpleu2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetleu2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetleu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.u32.u32.le %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpleu4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetleu4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetlts2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.s32.s32.lt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmplts2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetlts2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetlts4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.s32.s32.lt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmplts4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetlts4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetltu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.u32.u32.lt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpltu2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetltu2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetltu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.u32.u32.lt %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpltu4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetltu4(__a, __b), 8); +} +__DEVICE__ unsigned int __vsetne2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset2.u32.u32.ne %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpne2(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetne2(__a, __b), 16); +} +__DEVICE__ unsigned int __vsetne4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vset4.u32.u32.ne %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vcmpne4(unsigned int __a, unsigned int __b) { + return __bool2mask(__vsetne4(__a, __b), 8); +} + +// Based on ITEM 23 in AIM-239: http://dspace.mit.edu/handle/1721.1/6086 +// (a & b) + (a | b) = a + b = (a ^ b) + 2 * (a & b) => +// (a + b) / 2 = ((a ^ b) >> 1) + (a & b) +// To operate on multiple sub-elements we need to make sure to mask out bits +// that crossed over into adjacent elements during the shift. +__DEVICE__ unsigned int __vhaddu2(unsigned int __a, unsigned int __b) { + return (((__a ^ __b) >> 1) & ~0x80008000u) + (__a & __b); +} +__DEVICE__ unsigned int __vhaddu4(unsigned int __a, unsigned int __b) { + return (((__a ^ __b) >> 1) & ~0x80808080u) + (__a & __b); +} + +__DEVICE__ unsigned int __vmaxs2(unsigned int __a, unsigned int __b) { + unsigned int r; + if ((__a & 0x8000) && (__b & 0x8000)) { + // Work around a bug in ptxas which produces invalid result if low element + // is negative. + unsigned mask = __vcmpgts2(__a, __b); + r = (__a & mask) | (__b & ~mask); + } else { + __asm__("vmax2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + } + return r; +} +__DEVICE__ unsigned int __vmaxs4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmax4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vmaxu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmax2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vmaxu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmax4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vmins2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmin2.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vmins4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmin4.s32.s32.s32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vminu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmin2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vminu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vmin4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vsads2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff2.s32.s32.s32.add %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vsads4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff4.s32.s32.s32.add %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vsadu2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff2.u32.u32.u32.add %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vsadu4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vabsdiff4.u32.u32.u32.add %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} + +__DEVICE__ unsigned int __vsub2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vsub2.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vneg2(unsigned int __a) { return __vsub2(0, __a); } + +__DEVICE__ unsigned int __vsub4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vsub4.u32.u32.u32 %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vneg4(unsigned int __a) { return __vsub4(0, __a); } +__DEVICE__ unsigned int __vsubss2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vsub2.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vnegss2(unsigned int __a) { + return __vsubss2(0, __a); +} +__DEVICE__ unsigned int __vsubss4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vsub4.s32.s32.s32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vnegss4(unsigned int __a) { + return __vsubss4(0, __a); +} +__DEVICE__ unsigned int __vsubus2(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vsub2.u32.u32.u32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +__DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) { + unsigned int r; + __asm__("vsub4.u32.u32.u32.sat %0,%1,%2,%3;" + : "=r"(r) + : "r"(__a), "r"(__b), "r"(0)); + return r; +} +#endif // CUDA_VERSION >= 9020 + +// For OpenMP we require the user to include as we need to know what +// clock_t is on the system. +#ifndef __OPENMP_NVPTX__ +__DEVICE__ /* clock_t= */ int clock() { return __nvvm_read_ptx_sreg_clock(); } +#endif +__DEVICE__ long long clock64() { return __nvvm_read_ptx_sreg_clock64(); } + +// These functions shouldn't be declared when including this header +// for math function resolution purposes. +#ifndef __OPENMP_NVPTX__ +__DEVICE__ void *memcpy(void *__a, const void *__b, size_t __c) { + return __builtin_memcpy(__a, __b, __c); +} +__DEVICE__ void *memset(void *__a, int __b, size_t __c) { + return __builtin_memset(__a, __b, __c); +} +#endif + +#pragma pop_macro("__DEVICE__") +#endif // __CLANG_CUDA_DEVICE_FUNCTIONS_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_intrinsics.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_intrinsics.h new file mode 100755 index 0000000..cca97cb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_intrinsics.h @@ -0,0 +1,994 @@ +/*===--- __clang_cuda_intrinsics.h - Device-side CUDA intrinsic wrappers ---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CLANG_CUDA_INTRINSICS_H__ +#define __CLANG_CUDA_INTRINSICS_H__ +#ifndef __CUDA__ +#error "This file is for CUDA compilation only." +#endif + +// sm_30 intrinsics: __shfl_{up,down,xor}. + +#define __SM_30_INTRINSICS_H__ +#define __SM_30_INTRINSICS_HPP__ + +#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 + +#pragma push_macro("__MAKE_SHUFFLES") +#define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask, \ + __Type) \ + inline __device__ int __FnName(int __val, __Type __offset, \ + int __width = warpSize) { \ + return __IntIntrinsic(__val, __offset, \ + ((warpSize - __width) << 8) | (__Mask)); \ + } \ + inline __device__ float __FnName(float __val, __Type __offset, \ + int __width = warpSize) { \ + return __FloatIntrinsic(__val, __offset, \ + ((warpSize - __width) << 8) | (__Mask)); \ + } \ + inline __device__ unsigned int __FnName(unsigned int __val, __Type __offset, \ + int __width = warpSize) { \ + return static_cast( \ + ::__FnName(static_cast(__val), __offset, __width)); \ + } \ + inline __device__ long long __FnName(long long __val, __Type __offset, \ + int __width = warpSize) { \ + struct __Bits { \ + int __a, __b; \ + }; \ + _Static_assert(sizeof(__val) == sizeof(__Bits)); \ + _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); \ + __Bits __tmp; \ + memcpy(&__tmp, &__val, sizeof(__val)); \ + __tmp.__a = ::__FnName(__tmp.__a, __offset, __width); \ + __tmp.__b = ::__FnName(__tmp.__b, __offset, __width); \ + long long __ret; \ + memcpy(&__ret, &__tmp, sizeof(__tmp)); \ + return __ret; \ + } \ + inline __device__ long __FnName(long __val, __Type __offset, \ + int __width = warpSize) { \ + _Static_assert(sizeof(long) == sizeof(long long) || \ + sizeof(long) == sizeof(int)); \ + if (sizeof(long) == sizeof(long long)) { \ + return static_cast( \ + ::__FnName(static_cast(__val), __offset, __width)); \ + } else if (sizeof(long) == sizeof(int)) { \ + return static_cast( \ + ::__FnName(static_cast(__val), __offset, __width)); \ + } \ + } \ + inline __device__ unsigned long __FnName( \ + unsigned long __val, __Type __offset, int __width = warpSize) { \ + return static_cast( \ + ::__FnName(static_cast(__val), __offset, __width)); \ + } \ + inline __device__ unsigned long long __FnName( \ + unsigned long long __val, __Type __offset, int __width = warpSize) { \ + return static_cast( \ + ::__FnName(static_cast(__val), __offset, __width)); \ + } \ + inline __device__ double __FnName(double __val, __Type __offset, \ + int __width = warpSize) { \ + long long __tmp; \ + _Static_assert(sizeof(__tmp) == sizeof(__val)); \ + memcpy(&__tmp, &__val, sizeof(__val)); \ + __tmp = ::__FnName(__tmp, __offset, __width); \ + double __ret; \ + memcpy(&__ret, &__tmp, sizeof(__ret)); \ + return __ret; \ + } + +__MAKE_SHUFFLES(__shfl, __nvvm_shfl_idx_i32, __nvvm_shfl_idx_f32, 0x1f, int); +// We use 0 rather than 31 as our mask, because shfl.up applies to lanes >= +// maxLane. +__MAKE_SHUFFLES(__shfl_up, __nvvm_shfl_up_i32, __nvvm_shfl_up_f32, 0, + unsigned int); +__MAKE_SHUFFLES(__shfl_down, __nvvm_shfl_down_i32, __nvvm_shfl_down_f32, 0x1f, + unsigned int); +__MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_bfly_i32, __nvvm_shfl_bfly_f32, 0x1f, + int); +#pragma pop_macro("__MAKE_SHUFFLES") + +#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 + +#if CUDA_VERSION >= 9000 +#if (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300) +// __shfl_sync_* variants available in CUDA-9 +#pragma push_macro("__MAKE_SYNC_SHUFFLES") +#define __MAKE_SYNC_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, \ + __Mask, __Type) \ + inline __device__ int __FnName(unsigned int __mask, int __val, \ + __Type __offset, int __width = warpSize) { \ + return __IntIntrinsic(__mask, __val, __offset, \ + ((warpSize - __width) << 8) | (__Mask)); \ + } \ + inline __device__ float __FnName(unsigned int __mask, float __val, \ + __Type __offset, int __width = warpSize) { \ + return __FloatIntrinsic(__mask, __val, __offset, \ + ((warpSize - __width) << 8) | (__Mask)); \ + } \ + inline __device__ unsigned int __FnName(unsigned int __mask, \ + unsigned int __val, __Type __offset, \ + int __width = warpSize) { \ + return static_cast( \ + ::__FnName(__mask, static_cast(__val), __offset, __width)); \ + } \ + inline __device__ long long __FnName(unsigned int __mask, long long __val, \ + __Type __offset, \ + int __width = warpSize) { \ + struct __Bits { \ + int __a, __b; \ + }; \ + _Static_assert(sizeof(__val) == sizeof(__Bits)); \ + _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); \ + __Bits __tmp; \ + memcpy(&__tmp, &__val, sizeof(__val)); \ + __tmp.__a = ::__FnName(__mask, __tmp.__a, __offset, __width); \ + __tmp.__b = ::__FnName(__mask, __tmp.__b, __offset, __width); \ + long long __ret; \ + memcpy(&__ret, &__tmp, sizeof(__tmp)); \ + return __ret; \ + } \ + inline __device__ unsigned long long __FnName( \ + unsigned int __mask, unsigned long long __val, __Type __offset, \ + int __width = warpSize) { \ + return static_cast( \ + ::__FnName(__mask, static_cast(__val), __offset, __width)); \ + } \ + inline __device__ long __FnName(unsigned int __mask, long __val, \ + __Type __offset, int __width = warpSize) { \ + _Static_assert(sizeof(long) == sizeof(long long) || \ + sizeof(long) == sizeof(int)); \ + if (sizeof(long) == sizeof(long long)) { \ + return static_cast(::__FnName( \ + __mask, static_cast(__val), __offset, __width)); \ + } else if (sizeof(long) == sizeof(int)) { \ + return static_cast( \ + ::__FnName(__mask, static_cast(__val), __offset, __width)); \ + } \ + } \ + inline __device__ unsigned long __FnName( \ + unsigned int __mask, unsigned long __val, __Type __offset, \ + int __width = warpSize) { \ + return static_cast( \ + ::__FnName(__mask, static_cast(__val), __offset, __width)); \ + } \ + inline __device__ double __FnName(unsigned int __mask, double __val, \ + __Type __offset, int __width = warpSize) { \ + long long __tmp; \ + _Static_assert(sizeof(__tmp) == sizeof(__val)); \ + memcpy(&__tmp, &__val, sizeof(__val)); \ + __tmp = ::__FnName(__mask, __tmp, __offset, __width); \ + double __ret; \ + memcpy(&__ret, &__tmp, sizeof(__ret)); \ + return __ret; \ + } +__MAKE_SYNC_SHUFFLES(__shfl_sync, __nvvm_shfl_sync_idx_i32, + __nvvm_shfl_sync_idx_f32, 0x1f, int); +// We use 0 rather than 31 as our mask, because shfl.up applies to lanes >= +// maxLane. +__MAKE_SYNC_SHUFFLES(__shfl_up_sync, __nvvm_shfl_sync_up_i32, + __nvvm_shfl_sync_up_f32, 0, unsigned int); +__MAKE_SYNC_SHUFFLES(__shfl_down_sync, __nvvm_shfl_sync_down_i32, + __nvvm_shfl_sync_down_f32, 0x1f, unsigned int); +__MAKE_SYNC_SHUFFLES(__shfl_xor_sync, __nvvm_shfl_sync_bfly_i32, + __nvvm_shfl_sync_bfly_f32, 0x1f, int); +#pragma pop_macro("__MAKE_SYNC_SHUFFLES") + +inline __device__ void __syncwarp(unsigned int mask = 0xffffffff) { + return __nvvm_bar_warp_sync(mask); +} + +inline __device__ void __barrier_sync(unsigned int id) { + __nvvm_barrier_sync(id); +} + +inline __device__ void __barrier_sync_count(unsigned int id, + unsigned int count) { + __nvvm_barrier_sync_cnt(id, count); +} + +inline __device__ int __all_sync(unsigned int mask, int pred) { + return __nvvm_vote_all_sync(mask, pred); +} + +inline __device__ int __any_sync(unsigned int mask, int pred) { + return __nvvm_vote_any_sync(mask, pred); +} + +inline __device__ int __uni_sync(unsigned int mask, int pred) { + return __nvvm_vote_uni_sync(mask, pred); +} + +inline __device__ unsigned int __ballot_sync(unsigned int mask, int pred) { + return __nvvm_vote_ballot_sync(mask, pred); +} + +inline __device__ unsigned int __activemask() { +#if CUDA_VERSION < 9020 + return __nvvm_vote_ballot(1); +#else + return __nvvm_activemask(); +#endif +} + +inline __device__ unsigned int __fns(unsigned mask, unsigned base, int offset) { + return __nvvm_fns(mask, base, offset); +} + +#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300 + +// Define __match* builtins CUDA-9 headers expect to see. +#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 +inline __device__ unsigned int __match32_any_sync(unsigned int mask, + unsigned int value) { + return __nvvm_match_any_sync_i32(mask, value); +} + +inline __device__ unsigned int +__match64_any_sync(unsigned int mask, unsigned long long value) { + return __nvvm_match_any_sync_i64(mask, value); +} + +inline __device__ unsigned int +__match32_all_sync(unsigned int mask, unsigned int value, int *pred) { + return __nvvm_match_all_sync_i32p(mask, value, pred); +} + +inline __device__ unsigned int +__match64_all_sync(unsigned int mask, unsigned long long value, int *pred) { + return __nvvm_match_all_sync_i64p(mask, value, pred); +} +#include "crt/sm_70_rt.hpp" + +#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 700 +#endif // __CUDA_VERSION >= 9000 + +// sm_32 intrinsics: __ldg and __funnelshift_{l,lc,r,rc}. + +// Prevent the vanilla sm_32 intrinsics header from being included. +#define __SM_32_INTRINSICS_H__ +#define __SM_32_INTRINSICS_HPP__ + +#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320 + +inline __device__ char __ldg(const char *ptr) { return __nvvm_ldg_c(ptr); } +inline __device__ short __ldg(const short *ptr) { return __nvvm_ldg_s(ptr); } +inline __device__ int __ldg(const int *ptr) { return __nvvm_ldg_i(ptr); } +inline __device__ long __ldg(const long *ptr) { return __nvvm_ldg_l(ptr); } +inline __device__ long long __ldg(const long long *ptr) { + return __nvvm_ldg_ll(ptr); +} +inline __device__ unsigned char __ldg(const unsigned char *ptr) { + return __nvvm_ldg_uc(ptr); +} +inline __device__ signed char __ldg(const signed char *ptr) { + return __nvvm_ldg_uc((const unsigned char *)ptr); +} +inline __device__ unsigned short __ldg(const unsigned short *ptr) { + return __nvvm_ldg_us(ptr); +} +inline __device__ unsigned int __ldg(const unsigned int *ptr) { + return __nvvm_ldg_ui(ptr); +} +inline __device__ unsigned long __ldg(const unsigned long *ptr) { + return __nvvm_ldg_ul(ptr); +} +inline __device__ unsigned long long __ldg(const unsigned long long *ptr) { + return __nvvm_ldg_ull(ptr); +} +inline __device__ float __ldg(const float *ptr) { return __nvvm_ldg_f(ptr); } +inline __device__ double __ldg(const double *ptr) { return __nvvm_ldg_d(ptr); } + +inline __device__ char2 __ldg(const char2 *ptr) { + typedef char c2 __attribute__((ext_vector_type(2))); + // We can assume that ptr is aligned at least to char2's alignment, but the + // load will assume that ptr is aligned to char2's alignment. This is only + // safe if alignof(c2) <= alignof(char2). + c2 rv = __nvvm_ldg_c2(reinterpret_cast(ptr)); + char2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ char4 __ldg(const char4 *ptr) { + typedef char c4 __attribute__((ext_vector_type(4))); + c4 rv = __nvvm_ldg_c4(reinterpret_cast(ptr)); + char4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ short2 __ldg(const short2 *ptr) { + typedef short s2 __attribute__((ext_vector_type(2))); + s2 rv = __nvvm_ldg_s2(reinterpret_cast(ptr)); + short2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ short4 __ldg(const short4 *ptr) { + typedef short s4 __attribute__((ext_vector_type(4))); + s4 rv = __nvvm_ldg_s4(reinterpret_cast(ptr)); + short4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ int2 __ldg(const int2 *ptr) { + typedef int i2 __attribute__((ext_vector_type(2))); + i2 rv = __nvvm_ldg_i2(reinterpret_cast(ptr)); + int2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ int4 __ldg(const int4 *ptr) { + typedef int i4 __attribute__((ext_vector_type(4))); + i4 rv = __nvvm_ldg_i4(reinterpret_cast(ptr)); + int4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ longlong2 __ldg(const longlong2 *ptr) { + typedef long long ll2 __attribute__((ext_vector_type(2))); + ll2 rv = __nvvm_ldg_ll2(reinterpret_cast(ptr)); + longlong2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} + +inline __device__ uchar2 __ldg(const uchar2 *ptr) { + typedef unsigned char uc2 __attribute__((ext_vector_type(2))); + uc2 rv = __nvvm_ldg_uc2(reinterpret_cast(ptr)); + uchar2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ uchar4 __ldg(const uchar4 *ptr) { + typedef unsigned char uc4 __attribute__((ext_vector_type(4))); + uc4 rv = __nvvm_ldg_uc4(reinterpret_cast(ptr)); + uchar4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ ushort2 __ldg(const ushort2 *ptr) { + typedef unsigned short us2 __attribute__((ext_vector_type(2))); + us2 rv = __nvvm_ldg_us2(reinterpret_cast(ptr)); + ushort2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ ushort4 __ldg(const ushort4 *ptr) { + typedef unsigned short us4 __attribute__((ext_vector_type(4))); + us4 rv = __nvvm_ldg_us4(reinterpret_cast(ptr)); + ushort4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ uint2 __ldg(const uint2 *ptr) { + typedef unsigned int ui2 __attribute__((ext_vector_type(2))); + ui2 rv = __nvvm_ldg_ui2(reinterpret_cast(ptr)); + uint2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ uint4 __ldg(const uint4 *ptr) { + typedef unsigned int ui4 __attribute__((ext_vector_type(4))); + ui4 rv = __nvvm_ldg_ui4(reinterpret_cast(ptr)); + uint4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ ulonglong2 __ldg(const ulonglong2 *ptr) { + typedef unsigned long long ull2 __attribute__((ext_vector_type(2))); + ull2 rv = __nvvm_ldg_ull2(reinterpret_cast(ptr)); + ulonglong2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} + +inline __device__ float2 __ldg(const float2 *ptr) { + typedef float f2 __attribute__((ext_vector_type(2))); + f2 rv = __nvvm_ldg_f2(reinterpret_cast(ptr)); + float2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} +inline __device__ float4 __ldg(const float4 *ptr) { + typedef float f4 __attribute__((ext_vector_type(4))); + f4 rv = __nvvm_ldg_f4(reinterpret_cast(ptr)); + float4 ret; + ret.x = rv[0]; + ret.y = rv[1]; + ret.z = rv[2]; + ret.w = rv[3]; + return ret; +} +inline __device__ double2 __ldg(const double2 *ptr) { + typedef double d2 __attribute__((ext_vector_type(2))); + d2 rv = __nvvm_ldg_d2(reinterpret_cast(ptr)); + double2 ret; + ret.x = rv[0]; + ret.y = rv[1]; + return ret; +} + +// TODO: Implement these as intrinsics, so the backend can work its magic on +// these. Alternatively, we could implement these as plain C and try to get +// llvm to recognize the relevant patterns. +inline __device__ unsigned __funnelshift_l(unsigned low32, unsigned high32, + unsigned shiftWidth) { + unsigned result; + asm("shf.l.wrap.b32 %0, %1, %2, %3;" + : "=r"(result) + : "r"(low32), "r"(high32), "r"(shiftWidth)); + return result; +} +inline __device__ unsigned __funnelshift_lc(unsigned low32, unsigned high32, + unsigned shiftWidth) { + unsigned result; + asm("shf.l.clamp.b32 %0, %1, %2, %3;" + : "=r"(result) + : "r"(low32), "r"(high32), "r"(shiftWidth)); + return result; +} +inline __device__ unsigned __funnelshift_r(unsigned low32, unsigned high32, + unsigned shiftWidth) { + unsigned result; + asm("shf.r.wrap.b32 %0, %1, %2, %3;" + : "=r"(result) + : "r"(low32), "r"(high32), "r"(shiftWidth)); + return result; +} +inline __device__ unsigned __funnelshift_rc(unsigned low32, unsigned high32, + unsigned shiftWidth) { + unsigned ret; + asm("shf.r.clamp.b32 %0, %1, %2, %3;" + : "=r"(ret) + : "r"(low32), "r"(high32), "r"(shiftWidth)); + return ret; +} + +#if defined(__cplusplus) && (__cplusplus >= 201103L) + +#pragma push_macro("__INTRINSIC_LOAD") +#define __INTRINSIC_LOAD(__FnName, __AsmOp, __DeclType, __TmpType, __AsmType, \ + __Clobber) \ + inline __device__ __DeclType __FnName(const __DeclType *__ptr) { \ + __TmpType __ret; \ + asm(__AsmOp " %0, [%1];" : __AsmType(__ret) : "l"(__ptr)__Clobber); \ + return (__DeclType)__ret; \ + } + +#pragma push_macro("__INTRINSIC_LOAD2") +#define __INTRINSIC_LOAD2(__FnName, __AsmOp, __DeclType, __TmpType, __AsmType, \ + __Clobber) \ + inline __device__ __DeclType __FnName(const __DeclType *__ptr) { \ + __DeclType __ret; \ + __TmpType __tmp; \ + asm(__AsmOp " {%0,%1}, [%2];" \ + : __AsmType(__tmp.x), __AsmType(__tmp.y) \ + : "l"(__ptr)__Clobber); \ + using __ElementType = decltype(__ret.x); \ + __ret.x = (__ElementType)(__tmp.x); \ + __ret.y = (__ElementType)__tmp.y; \ + return __ret; \ + } + +#pragma push_macro("__INTRINSIC_LOAD4") +#define __INTRINSIC_LOAD4(__FnName, __AsmOp, __DeclType, __TmpType, __AsmType, \ + __Clobber) \ + inline __device__ __DeclType __FnName(const __DeclType *__ptr) { \ + __DeclType __ret; \ + __TmpType __tmp; \ + asm(__AsmOp " {%0,%1,%2,%3}, [%4];" \ + : __AsmType(__tmp.x), __AsmType(__tmp.y), __AsmType(__tmp.z), \ + __AsmType(__tmp.w) \ + : "l"(__ptr)__Clobber); \ + using __ElementType = decltype(__ret.x); \ + __ret.x = (__ElementType)__tmp.x; \ + __ret.y = (__ElementType)__tmp.y; \ + __ret.z = (__ElementType)__tmp.z; \ + __ret.w = (__ElementType)__tmp.w; \ + return __ret; \ + } + +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.s8", char, unsigned int, "=r", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.s8", signed char, unsigned int, "=r", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.s16", short, unsigned short, "=h", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.s32", int, unsigned int, "=r", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.s64", long long, unsigned long long, + "=l", ); + +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.s8", char2, int2, "=r", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.s8", char4, int4, "=r", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.s16", short2, short2, "=h", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.s16", short4, short4, "=h", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.s32", int2, int2, "=r", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.s32", int4, int4, "=r", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.s64 ", longlong2, longlong2, "=l", ); + +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.u8", unsigned char, unsigned int, + "=r", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.u16", unsigned short, unsigned short, + "=h", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.u32", unsigned int, unsigned int, + "=r", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.u64", unsigned long long, + unsigned long long, "=l", ); + +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.u8", uchar2, int2, "=r", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.u8", uchar4, int4, "=r", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.u16", ushort2, ushort2, "=h", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.u16", ushort4, ushort4, "=h", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.u32", uint2, uint2, "=r", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.u32", uint4, uint4, "=r", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.u64", ulonglong2, ulonglong2, + "=l", ); + +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.f32", float, float, "=f", ); +__INTRINSIC_LOAD(__ldcg, "ld.global.cg.f64", double, double, "=d", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.f32", float2, float2, "=f", ); +__INTRINSIC_LOAD4(__ldcg, "ld.global.cg.v4.f32", float4, float4, "=f", ); +__INTRINSIC_LOAD2(__ldcg, "ld.global.cg.v2.f64", double2, double2, "=d", ); + +inline __device__ long __ldcg(const long *__ptr) { + unsigned long __ret; + if (sizeof(long) == 8) { + asm("ld.global.cg.s64 %0, [%1];" : "=l"(__ret) : "l"(__ptr)); + } else { + asm("ld.global.cg.s32 %0, [%1];" : "=r"(__ret) : "l"(__ptr)); + } + return (long)__ret; +} + +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.u8", unsigned char, unsigned int, + "=r", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.u16", unsigned short, unsigned short, + "=h", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.u32", unsigned int, unsigned int, + "=r", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.u64", unsigned long long, + unsigned long long, "=l", : "memory"); + +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.s8", char, unsigned int, + "=r", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.s8", signed char, unsigned int, + "=r", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.s16", short, unsigned short, + "=h", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.s32", int, unsigned int, + "=r", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.s64", long long, unsigned long long, + "=l", : "memory"); + +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.u8", uchar2, uint2, + "=r", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.u8", uchar4, uint4, + "=r", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.u16", ushort2, ushort2, + "=h", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.u16", ushort4, ushort4, + "=h", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.u32", uint2, uint2, + "=r", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.u32", uint4, uint4, + "=r", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.u64", ulonglong2, ulonglong2, + "=l", : "memory"); + +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.s8", char2, int2, "=r", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.s8", char4, int4, "=r", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.s16", short2, short2, + "=h", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.s16", short4, short4, + "=h", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.s32", int2, int2, "=r", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.s32", int4, int4, "=r", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.s64", longlong2, longlong2, + "=l", : "memory"); + +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.f32", float, float, "=f", : "memory"); +__INTRINSIC_LOAD(__ldcv, "ld.global.cv.f64", double, double, "=d", : "memory"); + +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.f32", float2, float2, + "=f", : "memory"); +__INTRINSIC_LOAD4(__ldcv, "ld.global.cv.v4.f32", float4, float4, + "=f", : "memory"); +__INTRINSIC_LOAD2(__ldcv, "ld.global.cv.v2.f64", double2, double2, + "=d", : "memory"); + +inline __device__ long __ldcv(const long *__ptr) { + unsigned long __ret; + if (sizeof(long) == 8) { + asm("ld.global.cv.s64 %0, [%1];" : "=l"(__ret) : "l"(__ptr)); + } else { + asm("ld.global.cv.s32 %0, [%1];" : "=r"(__ret) : "l"(__ptr)); + } + return (long)__ret; +} + +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.s8", char, unsigned int, "=r", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.s8", signed char, signed int, "=r", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.s16", short, unsigned short, "=h", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.s32", int, unsigned int, "=r", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.s64", long long, unsigned long long, + "=l", ); + +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.s8", char2, int2, "=r", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.s8", char4, int4, "=r", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.s16", short2, short2, "=h", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.s16", short4, short4, "=h", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.s32", int2, int2, "=r", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.s32", int4, int4, "=r", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.s64", longlong2, longlong2, "=l", ); + +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.u8", unsigned char, unsigned int, + "=r", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.u16", unsigned short, unsigned short, + "=h", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.u32", unsigned int, unsigned int, + "=r", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.u64", unsigned long long, + unsigned long long, "=l", ); + +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.u8", uchar2, uint2, "=r", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.u8", uchar4, uint4, "=r", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.u16", ushort2, ushort2, "=h", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.u16", ushort4, ushort4, "=h", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.u32", uint2, uint2, "=r", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.u32", uint4, uint4, "=r", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.u64", ulonglong2, ulonglong2, + "=l", ); + +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.f32", float, float, "=f", ); +__INTRINSIC_LOAD(__ldcs, "ld.global.cs.f64", double, double, "=d", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.f32", float2, float2, "=f", ); +__INTRINSIC_LOAD4(__ldcs, "ld.global.cs.v4.f32", float4, float4, "=f", ); +__INTRINSIC_LOAD2(__ldcs, "ld.global.cs.v2.f64", double2, double2, "=d", ); + +#pragma pop_macro("__INTRINSIC_LOAD") +#pragma pop_macro("__INTRINSIC_LOAD2") +#pragma pop_macro("__INTRINSIC_LOAD4") + +inline __device__ long __ldcs(const long *__ptr) { + unsigned long __ret; + if (sizeof(long) == 8) { + asm("ld.global.cs.s64 %0, [%1];" : "=l"(__ret) : "l"(__ptr)); + } else { + asm("ld.global.cs.s32 %0, [%1];" : "=r"(__ret) : "l"(__ptr)); + } + return (long)__ret; +} + +#pragma push_macro("__INTRINSIC_STORE") +#define __INTRINSIC_STORE(__FnName, __AsmOp, __DeclType, __TmpType, __AsmType) \ + inline __device__ void __FnName(__DeclType *__ptr, __DeclType __value) { \ + __TmpType __tmp = (__TmpType)__value; \ + asm(__AsmOp " [%0], %1;" ::"l"(__ptr), __AsmType(__tmp) : "memory"); \ + } + +#pragma push_macro("__INTRINSIC_STORE2") +#define __INTRINSIC_STORE2(__FnName, __AsmOp, __DeclType, __TmpType, \ + __AsmType) \ + inline __device__ void __FnName(__DeclType *__ptr, __DeclType __value) { \ + __TmpType __tmp; \ + using __ElementType = decltype(__tmp.x); \ + __tmp.x = (__ElementType)(__value.x); \ + __tmp.y = (__ElementType)(__value.y); \ + asm(__AsmOp " [%0], {%1,%2};" ::"l"(__ptr), __AsmType(__tmp.x), \ + __AsmType(__tmp.y) \ + : "memory"); \ + } + +#pragma push_macro("__INTRINSIC_STORE4") +#define __INTRINSIC_STORE4(__FnName, __AsmOp, __DeclType, __TmpType, \ + __AsmType) \ + inline __device__ void __FnName(__DeclType *__ptr, __DeclType __value) { \ + __TmpType __tmp; \ + using __ElementType = decltype(__tmp.x); \ + __tmp.x = (__ElementType)(__value.x); \ + __tmp.y = (__ElementType)(__value.y); \ + __tmp.z = (__ElementType)(__value.z); \ + __tmp.w = (__ElementType)(__value.w); \ + asm(__AsmOp " [%0], {%1,%2,%3,%4};" ::"l"(__ptr), __AsmType(__tmp.x), \ + __AsmType(__tmp.y), __AsmType(__tmp.z), __AsmType(__tmp.w) \ + : "memory"); \ + } + +__INTRINSIC_STORE(__stwt, "st.global.wt.s8", char, int, "r"); +__INTRINSIC_STORE(__stwt, "st.global.wt.s8", signed char, int, "r"); +__INTRINSIC_STORE(__stwt, "st.global.wt.s16", short, short, "h"); +__INTRINSIC_STORE(__stwt, "st.global.wt.s32", int, int, "r"); +__INTRINSIC_STORE(__stwt, "st.global.wt.s64", long long, long long, "l"); + +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.s8", char2, int2, "r"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.s8", char4, int4, "r"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.s16", short2, short2, "h"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.s16", short4, short4, "h"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.s32", int2, int2, "r"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.s32", int4, int4, "r"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.s64", longlong2, longlong2, "l"); + +__INTRINSIC_STORE(__stwt, "st.global.wt.u8", unsigned char, int, "r"); +__INTRINSIC_STORE(__stwt, "st.global.wt.u16", unsigned short, unsigned short, + "h"); +__INTRINSIC_STORE(__stwt, "st.global.wt.u32", unsigned int, unsigned int, "r"); +__INTRINSIC_STORE(__stwt, "st.global.wt.u64", unsigned long long, + unsigned long long, "l"); + +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.u8", uchar2, uchar2, "r"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.u8", uchar4, uint4, "r"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.u16", ushort2, ushort2, "h"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.u16", ushort4, ushort4, "h"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.u32", uint2, uint2, "r"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.u32", uint4, uint4, "r"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.u64", ulonglong2, ulonglong2, "l"); + +__INTRINSIC_STORE(__stwt, "st.global.wt.f32", float, float, "f"); +__INTRINSIC_STORE(__stwt, "st.global.wt.f64", double, double, "d"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.f32", float2, float2, "f"); +__INTRINSIC_STORE4(__stwt, "st.global.wt.v4.f32", float4, float4, "f"); +__INTRINSIC_STORE2(__stwt, "st.global.wt.v2.f64", double2, double2, "d"); + +#pragma pop_macro("__INTRINSIC_STORE") +#pragma pop_macro("__INTRINSIC_STORE2") +#pragma pop_macro("__INTRINSIC_STORE4") + +#endif // defined(__cplusplus) && (__cplusplus >= 201103L) +#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320 + +#if CUDA_VERSION >= 11000 +extern "C" { +__device__ inline size_t __nv_cvta_generic_to_global_impl(const void *__ptr) { + return (size_t)(void __attribute__((address_space(1))) *)__ptr; +} +__device__ inline size_t __nv_cvta_generic_to_shared_impl(const void *__ptr) { + return (size_t)(void __attribute__((address_space(3))) *)__ptr; +} +__device__ inline size_t __nv_cvta_generic_to_constant_impl(const void *__ptr) { + return (size_t)(void __attribute__((address_space(4))) *)__ptr; +} +__device__ inline size_t __nv_cvta_generic_to_local_impl(const void *__ptr) { + return (size_t)(void __attribute__((address_space(5))) *)__ptr; +} +__device__ inline void *__nv_cvta_global_to_generic_impl(size_t __ptr) { + return (void *)(void __attribute__((address_space(1))) *)__ptr; +} +__device__ inline void *__nv_cvta_shared_to_generic_impl(size_t __ptr) { + return (void *)(void __attribute__((address_space(3))) *)__ptr; +} +__device__ inline void *__nv_cvta_constant_to_generic_impl(size_t __ptr) { + return (void *)(void __attribute__((address_space(4))) *)__ptr; +} +__device__ inline void *__nv_cvta_local_to_generic_impl(size_t __ptr) { + return (void *)(void __attribute__((address_space(5))) *)__ptr; +} +__device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) { + return __nv_cvta_generic_to_shared_impl(__ptr); +} +} // extern "C" + +#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800 +__device__ inline unsigned __reduce_add_sync(unsigned __mask, + unsigned __value) { + return __nvvm_redux_sync_add(__value, __mask); +} +__device__ inline unsigned __reduce_min_sync(unsigned __mask, + unsigned __value) { + return __nvvm_redux_sync_umin(__value, __mask); +} +__device__ inline unsigned __reduce_max_sync(unsigned __mask, + unsigned __value) { + return __nvvm_redux_sync_umax(__value, __mask); +} +__device__ inline int __reduce_min_sync(unsigned __mask, int __value) { + return __nvvm_redux_sync_min(__value, __mask); +} +__device__ inline int __reduce_max_sync(unsigned __mask, int __value) { + return __nvvm_redux_sync_max(__value, __mask); +} +__device__ inline unsigned __reduce_or_sync(unsigned __mask, unsigned __value) { + return __nvvm_redux_sync_or(__value, __mask); +} +__device__ inline unsigned __reduce_and_sync(unsigned __mask, + unsigned __value) { + return __nvvm_redux_sync_and(__value, __mask); +} +__device__ inline unsigned __reduce_xor_sync(unsigned __mask, + unsigned __value) { + return __nvvm_redux_sync_xor(__value, __mask); +} + +__device__ inline void __nv_memcpy_async_shared_global_4(void *__dst, + const void *__src, + unsigned __src_size) { + __nvvm_cp_async_ca_shared_global_4( + (void __attribute__((address_space(3))) *)__dst, + (const void __attribute__((address_space(1))) *)__src, __src_size); +} +__device__ inline void __nv_memcpy_async_shared_global_8(void *__dst, + const void *__src, + unsigned __src_size) { + __nvvm_cp_async_ca_shared_global_8( + (void __attribute__((address_space(3))) *)__dst, + (const void __attribute__((address_space(1))) *)__src, __src_size); +} +__device__ inline void __nv_memcpy_async_shared_global_16(void *__dst, + const void *__src, + unsigned __src_size) { + __nvvm_cp_async_ca_shared_global_16( + (void __attribute__((address_space(3))) *)__dst, + (const void __attribute__((address_space(1))) *)__src, __src_size); +} + +__device__ inline void * +__nv_associate_access_property(const void *__ptr, unsigned long long __prop) { + // TODO: it appears to provide compiler with some sort of a hint. We do not + // know what exactly it is supposed to do. However, CUDA headers suggest that + // just passing through __ptr should not affect correctness. They do so on + // pre-sm80 GPUs where this builtin is not available. + return (void*)__ptr; +} +#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800 + +#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 900 +__device__ inline unsigned __isCtaShared(const void *ptr) { + return __isShared(ptr); +} + +__device__ inline unsigned __isClusterShared(const void *__ptr) { + return __nvvm_isspacep_shared_cluster(__ptr); +} + +__device__ inline void *__cluster_map_shared_rank(const void *__ptr, + unsigned __rank) { + return __nvvm_mapa((void *)__ptr, __rank); +} + +__device__ inline unsigned __cluster_query_shared_rank(const void *__ptr) { + return __nvvm_getctarank((void *)__ptr); +} + +__device__ inline uint2 +__cluster_map_shared_multicast(const void *__ptr, + unsigned int __cluster_cta_mask) { + return make_uint2((unsigned)__cvta_generic_to_shared(__ptr), + __cluster_cta_mask); +} + +__device__ inline unsigned __clusterDimIsSpecified() { + return __nvvm_is_explicit_cluster(); +} + +__device__ inline dim3 __clusterDim() { + return dim3(__nvvm_read_ptx_sreg_cluster_nctaid_x(), + __nvvm_read_ptx_sreg_cluster_nctaid_y(), + __nvvm_read_ptx_sreg_cluster_nctaid_z()); +} + +__device__ inline dim3 __clusterRelativeBlockIdx() { + return dim3(__nvvm_read_ptx_sreg_cluster_ctaid_x(), + __nvvm_read_ptx_sreg_cluster_ctaid_y(), + __nvvm_read_ptx_sreg_cluster_ctaid_z()); +} + +__device__ inline dim3 __clusterGridDimInClusters() { + return dim3(__nvvm_read_ptx_sreg_nclusterid_x(), + __nvvm_read_ptx_sreg_nclusterid_y(), + __nvvm_read_ptx_sreg_nclusterid_z()); +} + +__device__ inline dim3 __clusterIdx() { + return dim3(__nvvm_read_ptx_sreg_clusterid_x(), + __nvvm_read_ptx_sreg_clusterid_y(), + __nvvm_read_ptx_sreg_clusterid_z()); +} + +__device__ inline unsigned __clusterRelativeBlockRank() { + return __nvvm_read_ptx_sreg_cluster_ctarank(); +} + +__device__ inline unsigned __clusterSizeInBlocks() { + return __nvvm_read_ptx_sreg_cluster_nctarank(); +} + +__device__ inline void __cluster_barrier_arrive() { + __nvvm_barrier_cluster_arrive(); +} + +__device__ inline void __cluster_barrier_arrive_relaxed() { + __nvvm_barrier_cluster_arrive_relaxed(); +} + +__device__ inline void __cluster_barrier_wait() { + __nvvm_barrier_cluster_wait(); +} + +__device__ inline void __threadfence_cluster() { __nvvm_fence_sc_cluster(); } + +__device__ inline float2 atomicAdd(float2 *__ptr, float2 __val) { + float2 __ret; + __asm__("atom.add.v2.f32 {%0, %1}, [%2], {%3, %4};" + : "=f"(__ret.x), "=f"(__ret.y) + : "l"(__ptr), "f"(__val.x), "f"(__val.y)); + return __ret; +} + +__device__ inline float2 atomicAdd_block(float2 *__ptr, float2 __val) { + float2 __ret; + __asm__("atom.cta.add.v2.f32 {%0, %1}, [%2], {%3, %4};" + : "=f"(__ret.x), "=f"(__ret.y) + : "l"(__ptr), "f"(__val.x), "f"(__val.y)); + return __ret; +} + +__device__ inline float2 atomicAdd_system(float2 *__ptr, float2 __val) { + float2 __ret; + __asm__("atom.sys.add.v2.f32 {%0, %1}, [%2], {%3, %4};" + : "=f"(__ret.x), "=f"(__ret.y) + : "l"(__ptr), "f"(__val.x), "f"(__val.y)); + return __ret; +} + +__device__ inline float4 atomicAdd(float4 *__ptr, float4 __val) { + float4 __ret; + __asm__("atom.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};" + : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w) + : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w)); + return __ret; +} + +__device__ inline float4 atomicAdd_block(float4 *__ptr, float4 __val) { + float4 __ret; + __asm__( + "atom.cta.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};" + : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w) + : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w)); + return __ret; +} + +__device__ inline float4 atomicAdd_system(float4 *__ptr, float4 __val) { + float4 __ret; + __asm__( + "atom.sys.add.v4.f32 {%0, %1, %2, %3}, [%4], {%5, %6, %7, %8};" + : "=f"(__ret.x), "=f"(__ret.y), "=f"(__ret.z), "=f"(__ret.w) + : "l"(__ptr), "f"(__val.x), "f"(__val.y), "f"(__val.z), "f"(__val.w) + :); + return __ret; +} + +#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 900 +#endif // CUDA_VERSION >= 11000 + +#endif // defined(__CLANG_CUDA_INTRINSICS_H__) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_libdevice_declares.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_libdevice_declares.h new file mode 100755 index 0000000..ded0382 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_libdevice_declares.h @@ -0,0 +1,468 @@ +/*===-- __clang_cuda_libdevice_declares.h - decls for libdevice functions --=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_LIBDEVICE_DECLARES_H__ +#define __CLANG_CUDA_LIBDEVICE_DECLARES_H__ + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(__OPENMP_NVPTX__) +#define __DEVICE__ +#pragma omp begin assumes ext_spmd_amenable no_openmp +#elif defined(__CUDA__) +#define __DEVICE__ __device__ +#endif + +__DEVICE__ int __nv_abs(int __a); +__DEVICE__ double __nv_acos(double __a); +__DEVICE__ float __nv_acosf(float __a); +__DEVICE__ double __nv_acosh(double __a); +__DEVICE__ float __nv_acoshf(float __a); +__DEVICE__ double __nv_asin(double __a); +__DEVICE__ float __nv_asinf(float __a); +__DEVICE__ double __nv_asinh(double __a); +__DEVICE__ float __nv_asinhf(float __a); +__DEVICE__ double __nv_atan2(double __a, double __b); +__DEVICE__ float __nv_atan2f(float __a, float __b); +__DEVICE__ double __nv_atan(double __a); +__DEVICE__ float __nv_atanf(float __a); +__DEVICE__ double __nv_atanh(double __a); +__DEVICE__ float __nv_atanhf(float __a); +__DEVICE__ int __nv_brev(int __a); +__DEVICE__ long long __nv_brevll(long long __a); +__DEVICE__ int __nv_byte_perm(int __a, int __b, int __c); +__DEVICE__ double __nv_cbrt(double __a); +__DEVICE__ float __nv_cbrtf(float __a); +__DEVICE__ double __nv_ceil(double __a); +__DEVICE__ float __nv_ceilf(float __a); +__DEVICE__ int __nv_clz(int __a); +__DEVICE__ int __nv_clzll(long long __a); +__DEVICE__ double __nv_copysign(double __a, double __b); +__DEVICE__ float __nv_copysignf(float __a, float __b); +__DEVICE__ double __nv_cos(double __a); +__DEVICE__ float __nv_cosf(float __a); +__DEVICE__ double __nv_cosh(double __a); +__DEVICE__ float __nv_coshf(float __a); +__DEVICE__ double __nv_cospi(double __a); +__DEVICE__ float __nv_cospif(float __a); +__DEVICE__ double __nv_cyl_bessel_i0(double __a); +__DEVICE__ float __nv_cyl_bessel_i0f(float __a); +__DEVICE__ double __nv_cyl_bessel_i1(double __a); +__DEVICE__ float __nv_cyl_bessel_i1f(float __a); +__DEVICE__ double __nv_dadd_rd(double __a, double __b); +__DEVICE__ double __nv_dadd_rn(double __a, double __b); +__DEVICE__ double __nv_dadd_ru(double __a, double __b); +__DEVICE__ double __nv_dadd_rz(double __a, double __b); +__DEVICE__ double __nv_ddiv_rd(double __a, double __b); +__DEVICE__ double __nv_ddiv_rn(double __a, double __b); +__DEVICE__ double __nv_ddiv_ru(double __a, double __b); +__DEVICE__ double __nv_ddiv_rz(double __a, double __b); +__DEVICE__ double __nv_dmul_rd(double __a, double __b); +__DEVICE__ double __nv_dmul_rn(double __a, double __b); +__DEVICE__ double __nv_dmul_ru(double __a, double __b); +__DEVICE__ double __nv_dmul_rz(double __a, double __b); +__DEVICE__ float __nv_double2float_rd(double __a); +__DEVICE__ float __nv_double2float_rn(double __a); +__DEVICE__ float __nv_double2float_ru(double __a); +__DEVICE__ float __nv_double2float_rz(double __a); +__DEVICE__ int __nv_double2hiint(double __a); +__DEVICE__ int __nv_double2int_rd(double __a); +__DEVICE__ int __nv_double2int_rn(double __a); +__DEVICE__ int __nv_double2int_ru(double __a); +__DEVICE__ int __nv_double2int_rz(double __a); +__DEVICE__ long long __nv_double2ll_rd(double __a); +__DEVICE__ long long __nv_double2ll_rn(double __a); +__DEVICE__ long long __nv_double2ll_ru(double __a); +__DEVICE__ long long __nv_double2ll_rz(double __a); +__DEVICE__ int __nv_double2loint(double __a); +__DEVICE__ unsigned int __nv_double2uint_rd(double __a); +__DEVICE__ unsigned int __nv_double2uint_rn(double __a); +__DEVICE__ unsigned int __nv_double2uint_ru(double __a); +__DEVICE__ unsigned int __nv_double2uint_rz(double __a); +__DEVICE__ unsigned long long __nv_double2ull_rd(double __a); +__DEVICE__ unsigned long long __nv_double2ull_rn(double __a); +__DEVICE__ unsigned long long __nv_double2ull_ru(double __a); +__DEVICE__ unsigned long long __nv_double2ull_rz(double __a); +__DEVICE__ unsigned long long __nv_double_as_longlong(double __a); +__DEVICE__ double __nv_drcp_rd(double __a); +__DEVICE__ double __nv_drcp_rn(double __a); +__DEVICE__ double __nv_drcp_ru(double __a); +__DEVICE__ double __nv_drcp_rz(double __a); +__DEVICE__ double __nv_dsqrt_rd(double __a); +__DEVICE__ double __nv_dsqrt_rn(double __a); +__DEVICE__ double __nv_dsqrt_ru(double __a); +__DEVICE__ double __nv_dsqrt_rz(double __a); +__DEVICE__ double __nv_dsub_rd(double __a, double __b); +__DEVICE__ double __nv_dsub_rn(double __a, double __b); +__DEVICE__ double __nv_dsub_ru(double __a, double __b); +__DEVICE__ double __nv_dsub_rz(double __a, double __b); +__DEVICE__ double __nv_erfc(double __a); +__DEVICE__ float __nv_erfcf(float __a); +__DEVICE__ double __nv_erfcinv(double __a); +__DEVICE__ float __nv_erfcinvf(float __a); +__DEVICE__ double __nv_erfcx(double __a); +__DEVICE__ float __nv_erfcxf(float __a); +__DEVICE__ double __nv_erf(double __a); +__DEVICE__ float __nv_erff(float __a); +__DEVICE__ double __nv_erfinv(double __a); +__DEVICE__ float __nv_erfinvf(float __a); +__DEVICE__ double __nv_exp10(double __a); +__DEVICE__ float __nv_exp10f(float __a); +__DEVICE__ double __nv_exp2(double __a); +__DEVICE__ float __nv_exp2f(float __a); +__DEVICE__ double __nv_exp(double __a); +__DEVICE__ float __nv_expf(float __a); +__DEVICE__ double __nv_expm1(double __a); +__DEVICE__ float __nv_expm1f(float __a); +__DEVICE__ double __nv_fabs(double __a); +__DEVICE__ float __nv_fabsf(float __a); +__DEVICE__ float __nv_fadd_rd(float __a, float __b); +__DEVICE__ float __nv_fadd_rn(float __a, float __b); +__DEVICE__ float __nv_fadd_ru(float __a, float __b); +__DEVICE__ float __nv_fadd_rz(float __a, float __b); +__DEVICE__ float __nv_fast_cosf(float __a); +__DEVICE__ float __nv_fast_exp10f(float __a); +__DEVICE__ float __nv_fast_expf(float __a); +__DEVICE__ float __nv_fast_fdividef(float __a, float __b); +__DEVICE__ float __nv_fast_log10f(float __a); +__DEVICE__ float __nv_fast_log2f(float __a); +__DEVICE__ float __nv_fast_logf(float __a); +__DEVICE__ float __nv_fast_powf(float __a, float __b); +__DEVICE__ void __nv_fast_sincosf(float __a, float *__s, float *__c); +__DEVICE__ float __nv_fast_sinf(float __a); +__DEVICE__ float __nv_fast_tanf(float __a); +__DEVICE__ double __nv_fdim(double __a, double __b); +__DEVICE__ float __nv_fdimf(float __a, float __b); +__DEVICE__ float __nv_fdiv_rd(float __a, float __b); +__DEVICE__ float __nv_fdiv_rn(float __a, float __b); +__DEVICE__ float __nv_fdiv_ru(float __a, float __b); +__DEVICE__ float __nv_fdiv_rz(float __a, float __b); +__DEVICE__ int __nv_ffs(int __a); +__DEVICE__ int __nv_ffsll(long long __a); +__DEVICE__ int __nv_finitef(float __a); +__DEVICE__ unsigned short __nv_float2half_rn(float __a); +__DEVICE__ int __nv_float2int_rd(float __a); +__DEVICE__ int __nv_float2int_rn(float __a); +__DEVICE__ int __nv_float2int_ru(float __a); +__DEVICE__ int __nv_float2int_rz(float __a); +__DEVICE__ long long __nv_float2ll_rd(float __a); +__DEVICE__ long long __nv_float2ll_rn(float __a); +__DEVICE__ long long __nv_float2ll_ru(float __a); +__DEVICE__ long long __nv_float2ll_rz(float __a); +__DEVICE__ unsigned int __nv_float2uint_rd(float __a); +__DEVICE__ unsigned int __nv_float2uint_rn(float __a); +__DEVICE__ unsigned int __nv_float2uint_ru(float __a); +__DEVICE__ unsigned int __nv_float2uint_rz(float __a); +__DEVICE__ unsigned long long __nv_float2ull_rd(float __a); +__DEVICE__ unsigned long long __nv_float2ull_rn(float __a); +__DEVICE__ unsigned long long __nv_float2ull_ru(float __a); +__DEVICE__ unsigned long long __nv_float2ull_rz(float __a); +__DEVICE__ int __nv_float_as_int(float __a); +__DEVICE__ unsigned int __nv_float_as_uint(float __a); +__DEVICE__ double __nv_floor(double __a); +__DEVICE__ float __nv_floorf(float __a); +__DEVICE__ double __nv_fma(double __a, double __b, double __c); +__DEVICE__ float __nv_fmaf(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_ieee_rd(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_ieee_rn(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_ieee_ru(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_ieee_rz(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_rd(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_rn(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_ru(float __a, float __b, float __c); +__DEVICE__ float __nv_fmaf_rz(float __a, float __b, float __c); +__DEVICE__ double __nv_fma_rd(double __a, double __b, double __c); +__DEVICE__ double __nv_fma_rn(double __a, double __b, double __c); +__DEVICE__ double __nv_fma_ru(double __a, double __b, double __c); +__DEVICE__ double __nv_fma_rz(double __a, double __b, double __c); +__DEVICE__ double __nv_fmax(double __a, double __b); +__DEVICE__ float __nv_fmaxf(float __a, float __b); +__DEVICE__ double __nv_fmin(double __a, double __b); +__DEVICE__ float __nv_fminf(float __a, float __b); +__DEVICE__ double __nv_fmod(double __a, double __b); +__DEVICE__ float __nv_fmodf(float __a, float __b); +__DEVICE__ float __nv_fmul_rd(float __a, float __b); +__DEVICE__ float __nv_fmul_rn(float __a, float __b); +__DEVICE__ float __nv_fmul_ru(float __a, float __b); +__DEVICE__ float __nv_fmul_rz(float __a, float __b); +__DEVICE__ float __nv_frcp_rd(float __a); +__DEVICE__ float __nv_frcp_rn(float __a); +__DEVICE__ float __nv_frcp_ru(float __a); +__DEVICE__ float __nv_frcp_rz(float __a); +__DEVICE__ double __nv_frexp(double __a, int *__b); +__DEVICE__ float __nv_frexpf(float __a, int *__b); +__DEVICE__ float __nv_frsqrt_rn(float __a); +__DEVICE__ float __nv_fsqrt_rd(float __a); +__DEVICE__ float __nv_fsqrt_rn(float __a); +__DEVICE__ float __nv_fsqrt_ru(float __a); +__DEVICE__ float __nv_fsqrt_rz(float __a); +__DEVICE__ float __nv_fsub_rd(float __a, float __b); +__DEVICE__ float __nv_fsub_rn(float __a, float __b); +__DEVICE__ float __nv_fsub_ru(float __a, float __b); +__DEVICE__ float __nv_fsub_rz(float __a, float __b); +__DEVICE__ int __nv_hadd(int __a, int __b); +__DEVICE__ float __nv_half2float(unsigned short __h); +__DEVICE__ double __nv_hiloint2double(int __a, int __b); +__DEVICE__ double __nv_hypot(double __a, double __b); +__DEVICE__ float __nv_hypotf(float __a, float __b); +__DEVICE__ int __nv_ilogb(double __a); +__DEVICE__ int __nv_ilogbf(float __a); +__DEVICE__ double __nv_int2double_rn(int __a); +__DEVICE__ float __nv_int2float_rd(int __a); +__DEVICE__ float __nv_int2float_rn(int __a); +__DEVICE__ float __nv_int2float_ru(int __a); +__DEVICE__ float __nv_int2float_rz(int __a); +__DEVICE__ float __nv_int_as_float(int __a); +__DEVICE__ int __nv_isfinited(double __a); +__DEVICE__ int __nv_isinfd(double __a); +__DEVICE__ int __nv_isinff(float __a); +__DEVICE__ int __nv_isnand(double __a); +__DEVICE__ int __nv_isnanf(float __a); +__DEVICE__ double __nv_j0(double __a); +__DEVICE__ float __nv_j0f(float __a); +__DEVICE__ double __nv_j1(double __a); +__DEVICE__ float __nv_j1f(float __a); +__DEVICE__ float __nv_jnf(int __a, float __b); +__DEVICE__ double __nv_jn(int __a, double __b); +__DEVICE__ double __nv_ldexp(double __a, int __b); +__DEVICE__ float __nv_ldexpf(float __a, int __b); +__DEVICE__ double __nv_lgamma(double __a); +__DEVICE__ float __nv_lgammaf(float __a); +__DEVICE__ double __nv_ll2double_rd(long long __a); +__DEVICE__ double __nv_ll2double_rn(long long __a); +__DEVICE__ double __nv_ll2double_ru(long long __a); +__DEVICE__ double __nv_ll2double_rz(long long __a); +__DEVICE__ float __nv_ll2float_rd(long long __a); +__DEVICE__ float __nv_ll2float_rn(long long __a); +__DEVICE__ float __nv_ll2float_ru(long long __a); +__DEVICE__ float __nv_ll2float_rz(long long __a); +__DEVICE__ long long __nv_llabs(long long __a); +__DEVICE__ long long __nv_llmax(long long __a, long long __b); +__DEVICE__ long long __nv_llmin(long long __a, long long __b); +__DEVICE__ long long __nv_llrint(double __a); +__DEVICE__ long long __nv_llrintf(float __a); +__DEVICE__ long long __nv_llround(double __a); +__DEVICE__ long long __nv_llroundf(float __a); +__DEVICE__ double __nv_log10(double __a); +__DEVICE__ float __nv_log10f(float __a); +__DEVICE__ double __nv_log1p(double __a); +__DEVICE__ float __nv_log1pf(float __a); +__DEVICE__ double __nv_log2(double __a); +__DEVICE__ float __nv_log2f(float __a); +__DEVICE__ double __nv_logb(double __a); +__DEVICE__ float __nv_logbf(float __a); +__DEVICE__ double __nv_log(double __a); +__DEVICE__ float __nv_logf(float __a); +__DEVICE__ double __nv_longlong_as_double(long long __a); +__DEVICE__ int __nv_max(int __a, int __b); +__DEVICE__ int __nv_min(int __a, int __b); +__DEVICE__ double __nv_modf(double __a, double *__b); +__DEVICE__ float __nv_modff(float __a, float *__b); +__DEVICE__ int __nv_mul24(int __a, int __b); +__DEVICE__ long long __nv_mul64hi(long long __a, long long __b); +__DEVICE__ int __nv_mulhi(int __a, int __b); +__DEVICE__ double __nv_nan(const signed char *__a); +__DEVICE__ float __nv_nanf(const signed char *__a); +__DEVICE__ double __nv_nearbyint(double __a); +__DEVICE__ float __nv_nearbyintf(float __a); +__DEVICE__ double __nv_nextafter(double __a, double __b); +__DEVICE__ float __nv_nextafterf(float __a, float __b); +__DEVICE__ double __nv_norm3d(double __a, double __b, double __c); +__DEVICE__ float __nv_norm3df(float __a, float __b, float __c); +__DEVICE__ double __nv_norm4d(double __a, double __b, double __c, double __d); +__DEVICE__ float __nv_norm4df(float __a, float __b, float __c, float __d); +__DEVICE__ double __nv_normcdf(double __a); +__DEVICE__ float __nv_normcdff(float __a); +__DEVICE__ double __nv_normcdfinv(double __a); +__DEVICE__ float __nv_normcdfinvf(float __a); +__DEVICE__ float __nv_normf(int __a, const float *__b); +__DEVICE__ double __nv_norm(int __a, const double *__b); +__DEVICE__ int __nv_popc(unsigned int __a); +__DEVICE__ int __nv_popcll(unsigned long long __a); +__DEVICE__ double __nv_pow(double __a, double __b); +__DEVICE__ float __nv_powf(float __a, float __b); +__DEVICE__ double __nv_powi(double __a, int __b); +__DEVICE__ float __nv_powif(float __a, int __b); +__DEVICE__ double __nv_rcbrt(double __a); +__DEVICE__ float __nv_rcbrtf(float __a); +__DEVICE__ double __nv_rcp64h(double __a); +__DEVICE__ double __nv_remainder(double __a, double __b); +__DEVICE__ float __nv_remainderf(float __a, float __b); +__DEVICE__ double __nv_remquo(double __a, double __b, int *__c); +__DEVICE__ float __nv_remquof(float __a, float __b, int *__c); +__DEVICE__ int __nv_rhadd(int __a, int __b); +__DEVICE__ double __nv_rhypot(double __a, double __b); +__DEVICE__ float __nv_rhypotf(float __a, float __b); +__DEVICE__ double __nv_rint(double __a); +__DEVICE__ float __nv_rintf(float __a); +__DEVICE__ double __nv_rnorm3d(double __a, double __b, double __c); +__DEVICE__ float __nv_rnorm3df(float __a, float __b, float __c); +__DEVICE__ double __nv_rnorm4d(double __a, double __b, double __c, double __d); +__DEVICE__ float __nv_rnorm4df(float __a, float __b, float __c, float __d); +__DEVICE__ float __nv_rnormf(int __a, const float *__b); +__DEVICE__ double __nv_rnorm(int __a, const double *__b); +__DEVICE__ double __nv_round(double __a); +__DEVICE__ float __nv_roundf(float __a); +__DEVICE__ double __nv_rsqrt(double __a); +__DEVICE__ float __nv_rsqrtf(float __a); +__DEVICE__ int __nv_sad(int __a, int __b, int __c); +__DEVICE__ float __nv_saturatef(float __a); +__DEVICE__ double __nv_scalbn(double __a, int __b); +__DEVICE__ float __nv_scalbnf(float __a, int __b); +__DEVICE__ int __nv_signbitd(double __a); +__DEVICE__ int __nv_signbitf(float __a); +__DEVICE__ void __nv_sincos(double __a, double *__b, double *__c); +__DEVICE__ void __nv_sincosf(float __a, float *__b, float *__c); +__DEVICE__ void __nv_sincospi(double __a, double *__b, double *__c); +__DEVICE__ void __nv_sincospif(float __a, float *__b, float *__c); +__DEVICE__ double __nv_sin(double __a); +__DEVICE__ float __nv_sinf(float __a); +__DEVICE__ double __nv_sinh(double __a); +__DEVICE__ float __nv_sinhf(float __a); +__DEVICE__ double __nv_sinpi(double __a); +__DEVICE__ float __nv_sinpif(float __a); +__DEVICE__ double __nv_sqrt(double __a); +__DEVICE__ float __nv_sqrtf(float __a); +__DEVICE__ double __nv_tan(double __a); +__DEVICE__ float __nv_tanf(float __a); +__DEVICE__ double __nv_tanh(double __a); +__DEVICE__ float __nv_tanhf(float __a); +__DEVICE__ double __nv_tgamma(double __a); +__DEVICE__ float __nv_tgammaf(float __a); +__DEVICE__ double __nv_trunc(double __a); +__DEVICE__ float __nv_truncf(float __a); +__DEVICE__ int __nv_uhadd(unsigned int __a, unsigned int __b); +__DEVICE__ double __nv_uint2double_rn(unsigned int __i); +__DEVICE__ float __nv_uint2float_rd(unsigned int __a); +__DEVICE__ float __nv_uint2float_rn(unsigned int __a); +__DEVICE__ float __nv_uint2float_ru(unsigned int __a); +__DEVICE__ float __nv_uint2float_rz(unsigned int __a); +__DEVICE__ float __nv_uint_as_float(unsigned int __a); +__DEVICE__ double __nv_ull2double_rd(unsigned long long __a); +__DEVICE__ double __nv_ull2double_rn(unsigned long long __a); +__DEVICE__ double __nv_ull2double_ru(unsigned long long __a); +__DEVICE__ double __nv_ull2double_rz(unsigned long long __a); +__DEVICE__ float __nv_ull2float_rd(unsigned long long __a); +__DEVICE__ float __nv_ull2float_rn(unsigned long long __a); +__DEVICE__ float __nv_ull2float_ru(unsigned long long __a); +__DEVICE__ float __nv_ull2float_rz(unsigned long long __a); +__DEVICE__ unsigned long long __nv_ullmax(unsigned long long __a, + unsigned long long __b); +__DEVICE__ unsigned long long __nv_ullmin(unsigned long long __a, + unsigned long long __b); +__DEVICE__ unsigned int __nv_umax(unsigned int __a, unsigned int __b); +__DEVICE__ unsigned int __nv_umin(unsigned int __a, unsigned int __b); +__DEVICE__ unsigned int __nv_umul24(unsigned int __a, unsigned int __b); +__DEVICE__ unsigned long long __nv_umul64hi(unsigned long long __a, + unsigned long long __b); +__DEVICE__ unsigned int __nv_umulhi(unsigned int __a, unsigned int __b); +__DEVICE__ unsigned int __nv_urhadd(unsigned int __a, unsigned int __b); +__DEVICE__ unsigned int __nv_usad(unsigned int __a, unsigned int __b, + unsigned int __c); +#if CUDA_VERSION >= 9000 && CUDA_VERSION < 9020 +__DEVICE__ int __nv_vabs2(int __a); +__DEVICE__ int __nv_vabs4(int __a); +__DEVICE__ int __nv_vabsdiffs2(int __a, int __b); +__DEVICE__ int __nv_vabsdiffs4(int __a, int __b); +__DEVICE__ int __nv_vabsdiffu2(int __a, int __b); +__DEVICE__ int __nv_vabsdiffu4(int __a, int __b); +__DEVICE__ int __nv_vabsss2(int __a); +__DEVICE__ int __nv_vabsss4(int __a); +__DEVICE__ int __nv_vadd2(int __a, int __b); +__DEVICE__ int __nv_vadd4(int __a, int __b); +__DEVICE__ int __nv_vaddss2(int __a, int __b); +__DEVICE__ int __nv_vaddss4(int __a, int __b); +__DEVICE__ int __nv_vaddus2(int __a, int __b); +__DEVICE__ int __nv_vaddus4(int __a, int __b); +__DEVICE__ int __nv_vavgs2(int __a, int __b); +__DEVICE__ int __nv_vavgs4(int __a, int __b); +__DEVICE__ int __nv_vavgu2(int __a, int __b); +__DEVICE__ int __nv_vavgu4(int __a, int __b); +__DEVICE__ int __nv_vcmpeq2(int __a, int __b); +__DEVICE__ int __nv_vcmpeq4(int __a, int __b); +__DEVICE__ int __nv_vcmpges2(int __a, int __b); +__DEVICE__ int __nv_vcmpges4(int __a, int __b); +__DEVICE__ int __nv_vcmpgeu2(int __a, int __b); +__DEVICE__ int __nv_vcmpgeu4(int __a, int __b); +__DEVICE__ int __nv_vcmpgts2(int __a, int __b); +__DEVICE__ int __nv_vcmpgts4(int __a, int __b); +__DEVICE__ int __nv_vcmpgtu2(int __a, int __b); +__DEVICE__ int __nv_vcmpgtu4(int __a, int __b); +__DEVICE__ int __nv_vcmples2(int __a, int __b); +__DEVICE__ int __nv_vcmples4(int __a, int __b); +__DEVICE__ int __nv_vcmpleu2(int __a, int __b); +__DEVICE__ int __nv_vcmpleu4(int __a, int __b); +__DEVICE__ int __nv_vcmplts2(int __a, int __b); +__DEVICE__ int __nv_vcmplts4(int __a, int __b); +__DEVICE__ int __nv_vcmpltu2(int __a, int __b); +__DEVICE__ int __nv_vcmpltu4(int __a, int __b); +__DEVICE__ int __nv_vcmpne2(int __a, int __b); +__DEVICE__ int __nv_vcmpne4(int __a, int __b); +__DEVICE__ int __nv_vhaddu2(int __a, int __b); +__DEVICE__ int __nv_vhaddu4(int __a, int __b); +__DEVICE__ int __nv_vmaxs2(int __a, int __b); +__DEVICE__ int __nv_vmaxs4(int __a, int __b); +__DEVICE__ int __nv_vmaxu2(int __a, int __b); +__DEVICE__ int __nv_vmaxu4(int __a, int __b); +__DEVICE__ int __nv_vmins2(int __a, int __b); +__DEVICE__ int __nv_vmins4(int __a, int __b); +__DEVICE__ int __nv_vminu2(int __a, int __b); +__DEVICE__ int __nv_vminu4(int __a, int __b); +__DEVICE__ int __nv_vneg2(int __a); +__DEVICE__ int __nv_vneg4(int __a); +__DEVICE__ int __nv_vnegss2(int __a); +__DEVICE__ int __nv_vnegss4(int __a); +__DEVICE__ int __nv_vsads2(int __a, int __b); +__DEVICE__ int __nv_vsads4(int __a, int __b); +__DEVICE__ int __nv_vsadu2(int __a, int __b); +__DEVICE__ int __nv_vsadu4(int __a, int __b); +__DEVICE__ int __nv_vseteq2(int __a, int __b); +__DEVICE__ int __nv_vseteq4(int __a, int __b); +__DEVICE__ int __nv_vsetges2(int __a, int __b); +__DEVICE__ int __nv_vsetges4(int __a, int __b); +__DEVICE__ int __nv_vsetgeu2(int __a, int __b); +__DEVICE__ int __nv_vsetgeu4(int __a, int __b); +__DEVICE__ int __nv_vsetgts2(int __a, int __b); +__DEVICE__ int __nv_vsetgts4(int __a, int __b); +__DEVICE__ int __nv_vsetgtu2(int __a, int __b); +__DEVICE__ int __nv_vsetgtu4(int __a, int __b); +__DEVICE__ int __nv_vsetles2(int __a, int __b); +__DEVICE__ int __nv_vsetles4(int __a, int __b); +__DEVICE__ int __nv_vsetleu2(int __a, int __b); +__DEVICE__ int __nv_vsetleu4(int __a, int __b); +__DEVICE__ int __nv_vsetlts2(int __a, int __b); +__DEVICE__ int __nv_vsetlts4(int __a, int __b); +__DEVICE__ int __nv_vsetltu2(int __a, int __b); +__DEVICE__ int __nv_vsetltu4(int __a, int __b); +__DEVICE__ int __nv_vsetne2(int __a, int __b); +__DEVICE__ int __nv_vsetne4(int __a, int __b); +__DEVICE__ int __nv_vsub2(int __a, int __b); +__DEVICE__ int __nv_vsub4(int __a, int __b); +__DEVICE__ int __nv_vsubss2(int __a, int __b); +__DEVICE__ int __nv_vsubss4(int __a, int __b); +__DEVICE__ int __nv_vsubus2(int __a, int __b); +__DEVICE__ int __nv_vsubus4(int __a, int __b); +#endif // CUDA_VERSION +__DEVICE__ double __nv_y0(double __a); +__DEVICE__ float __nv_y0f(float __a); +__DEVICE__ double __nv_y1(double __a); +__DEVICE__ float __nv_y1f(float __a); +__DEVICE__ float __nv_ynf(int __a, float __b); +__DEVICE__ double __nv_yn(int __a, double __b); + +#if defined(__OPENMP_NVPTX__) +#pragma omp end assumes ext_spmd_amenable no_openmp +#endif + +#if defined(__cplusplus) +} // extern "C" +#endif +#endif // __CLANG_CUDA_LIBDEVICE_DECLARES_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_math.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_math.h new file mode 100755 index 0000000..44c6e9a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_math.h @@ -0,0 +1,353 @@ +/*===---- __clang_cuda_math.h - Device-side CUDA math support --------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CLANG_CUDA_MATH_H__ +#define __CLANG_CUDA_MATH_H__ +#ifndef __CUDA__ +#error "This file is for CUDA compilation only." +#endif + +// The __CLANG_GPU_DISABLE_MATH_WRAPPERS macro provides a way to let standard +// libcalls reach the link step instead of being eagerly replaced. +#ifndef __CLANG_GPU_DISABLE_MATH_WRAPPERS + +#ifndef __OPENMP_NVPTX__ +#if CUDA_VERSION < 9000 +#error This file is intended to be used with CUDA-9+ only. +#endif +#endif + +// __DEVICE__ is a helper macro with common set of attributes for the wrappers +// we implement in this file. We need static in order to avoid emitting unused +// functions and __forceinline__ helps inlining these wrappers at -O1. +#pragma push_macro("__DEVICE__") +#ifdef __OPENMP_NVPTX__ +#if defined(__cplusplus) +#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) +#else +#define __DEVICE__ static __attribute__((always_inline, nothrow)) +#endif +#else +#define __DEVICE__ static __device__ __forceinline__ +#endif + +// Specialized version of __DEVICE__ for functions with void return type. Needed +// because the OpenMP overlay requires constexpr functions here but prior to +// c++14 void return functions could not be constexpr. +#pragma push_macro("__DEVICE_VOID__") +#if defined(__OPENMP_NVPTX__) && defined(__cplusplus) && __cplusplus < 201402L +#define __DEVICE_VOID__ static __attribute__((always_inline, nothrow)) +#else +#define __DEVICE_VOID__ __DEVICE__ +#endif + +// libdevice provides fast low precision and slow full-recision implementations +// for some functions. Which one gets selected depends on +// __CLANG_CUDA_APPROX_TRANSCENDENTALS__ which gets defined by clang if +// -ffast-math or -fgpu-approx-transcendentals are in effect. +#pragma push_macro("__FAST_OR_SLOW") +#if defined(__CLANG_GPU_APPROX_TRANSCENDENTALS__) +#define __FAST_OR_SLOW(fast, slow) fast +#else +#define __FAST_OR_SLOW(fast, slow) slow +#endif + +__DEVICE__ int abs(int __a) { return __nv_abs(__a); } +__DEVICE__ double fabs(double __a) { return __nv_fabs(__a); } +__DEVICE__ double acos(double __a) { return __nv_acos(__a); } +__DEVICE__ float acosf(float __a) { return __nv_acosf(__a); } +__DEVICE__ double acosh(double __a) { return __nv_acosh(__a); } +__DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); } +__DEVICE__ double asin(double __a) { return __nv_asin(__a); } +__DEVICE__ float asinf(float __a) { return __nv_asinf(__a); } +__DEVICE__ double asinh(double __a) { return __nv_asinh(__a); } +__DEVICE__ float asinhf(float __a) { return __nv_asinhf(__a); } +__DEVICE__ double atan(double __a) { return __nv_atan(__a); } +__DEVICE__ double atan2(double __a, double __b) { return __nv_atan2(__a, __b); } +__DEVICE__ float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); } +__DEVICE__ float atanf(float __a) { return __nv_atanf(__a); } +__DEVICE__ double atanh(double __a) { return __nv_atanh(__a); } +__DEVICE__ float atanhf(float __a) { return __nv_atanhf(__a); } +__DEVICE__ double cbrt(double __a) { return __nv_cbrt(__a); } +__DEVICE__ float cbrtf(float __a) { return __nv_cbrtf(__a); } +__DEVICE__ double ceil(double __a) { return __nv_ceil(__a); } +__DEVICE__ float ceilf(float __a) { return __nv_ceilf(__a); } +__DEVICE__ double copysign(double __a, double __b) { + return __nv_copysign(__a, __b); +} +__DEVICE__ float copysignf(float __a, float __b) { + return __nv_copysignf(__a, __b); +} +__DEVICE__ double cos(double __a) { return __nv_cos(__a); } +__DEVICE__ float cosf(float __a) { + return __FAST_OR_SLOW(__nv_fast_cosf, __nv_cosf)(__a); +} +__DEVICE__ double cosh(double __a) { return __nv_cosh(__a); } +__DEVICE__ float coshf(float __a) { return __nv_coshf(__a); } +__DEVICE__ double cospi(double __a) { return __nv_cospi(__a); } +__DEVICE__ float cospif(float __a) { return __nv_cospif(__a); } +__DEVICE__ double cyl_bessel_i0(double __a) { return __nv_cyl_bessel_i0(__a); } +__DEVICE__ float cyl_bessel_i0f(float __a) { return __nv_cyl_bessel_i0f(__a); } +__DEVICE__ double cyl_bessel_i1(double __a) { return __nv_cyl_bessel_i1(__a); } +__DEVICE__ float cyl_bessel_i1f(float __a) { return __nv_cyl_bessel_i1f(__a); } +__DEVICE__ double erf(double __a) { return __nv_erf(__a); } +__DEVICE__ double erfc(double __a) { return __nv_erfc(__a); } +__DEVICE__ float erfcf(float __a) { return __nv_erfcf(__a); } +__DEVICE__ double erfcinv(double __a) { return __nv_erfcinv(__a); } +__DEVICE__ float erfcinvf(float __a) { return __nv_erfcinvf(__a); } +__DEVICE__ double erfcx(double __a) { return __nv_erfcx(__a); } +__DEVICE__ float erfcxf(float __a) { return __nv_erfcxf(__a); } +__DEVICE__ float erff(float __a) { return __nv_erff(__a); } +__DEVICE__ double erfinv(double __a) { return __nv_erfinv(__a); } +__DEVICE__ float erfinvf(float __a) { return __nv_erfinvf(__a); } +__DEVICE__ double exp(double __a) { return __nv_exp(__a); } +__DEVICE__ double exp10(double __a) { return __nv_exp10(__a); } +__DEVICE__ float exp10f(float __a) { return __nv_exp10f(__a); } +__DEVICE__ double exp2(double __a) { return __nv_exp2(__a); } +__DEVICE__ float exp2f(float __a) { return __nv_exp2f(__a); } +__DEVICE__ float expf(float __a) { return __nv_expf(__a); } +__DEVICE__ double expm1(double __a) { return __nv_expm1(__a); } +__DEVICE__ float expm1f(float __a) { return __nv_expm1f(__a); } +__DEVICE__ float fabsf(float __a) { return __nv_fabsf(__a); } +__DEVICE__ double fdim(double __a, double __b) { return __nv_fdim(__a, __b); } +__DEVICE__ float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); } +__DEVICE__ double fdivide(double __a, double __b) { return __a / __b; } +__DEVICE__ float fdividef(float __a, float __b) { +#if __FAST_MATH__ && !__CUDA_PREC_DIV + return __nv_fast_fdividef(__a, __b); +#else + return __a / __b; +#endif +} +__DEVICE__ double floor(double __f) { return __nv_floor(__f); } +__DEVICE__ float floorf(float __f) { return __nv_floorf(__f); } +__DEVICE__ double fma(double __a, double __b, double __c) { + return __nv_fma(__a, __b, __c); +} +__DEVICE__ float fmaf(float __a, float __b, float __c) { + return __nv_fmaf(__a, __b, __c); +} +__DEVICE__ double fmax(double __a, double __b) { return __nv_fmax(__a, __b); } +__DEVICE__ float fmaxf(float __a, float __b) { return __nv_fmaxf(__a, __b); } +__DEVICE__ double fmin(double __a, double __b) { return __nv_fmin(__a, __b); } +__DEVICE__ float fminf(float __a, float __b) { return __nv_fminf(__a, __b); } +__DEVICE__ double fmod(double __a, double __b) { return __nv_fmod(__a, __b); } +__DEVICE__ float fmodf(float __a, float __b) { return __nv_fmodf(__a, __b); } +__DEVICE__ double frexp(double __a, int *__b) { return __nv_frexp(__a, __b); } +__DEVICE__ float frexpf(float __a, int *__b) { return __nv_frexpf(__a, __b); } +__DEVICE__ double hypot(double __a, double __b) { return __nv_hypot(__a, __b); } +__DEVICE__ float hypotf(float __a, float __b) { return __nv_hypotf(__a, __b); } +__DEVICE__ int ilogb(double __a) { return __nv_ilogb(__a); } +__DEVICE__ int ilogbf(float __a) { return __nv_ilogbf(__a); } +__DEVICE__ double j0(double __a) { return __nv_j0(__a); } +__DEVICE__ float j0f(float __a) { return __nv_j0f(__a); } +__DEVICE__ double j1(double __a) { return __nv_j1(__a); } +__DEVICE__ float j1f(float __a) { return __nv_j1f(__a); } +__DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); } +__DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); } +#if defined(__LP64__) || defined(_WIN64) +__DEVICE__ long labs(long __a) { return __nv_llabs(__a); }; +#else +__DEVICE__ long labs(long __a) { return __nv_abs(__a); }; +#endif +__DEVICE__ double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); } +__DEVICE__ float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); } +__DEVICE__ double lgamma(double __a) { return __nv_lgamma(__a); } +__DEVICE__ float lgammaf(float __a) { return __nv_lgammaf(__a); } +__DEVICE__ long long llabs(long long __a) { return __nv_llabs(__a); } +__DEVICE__ long long llmax(long long __a, long long __b) { + return __nv_llmax(__a, __b); +} +__DEVICE__ long long llmin(long long __a, long long __b) { + return __nv_llmin(__a, __b); +} +__DEVICE__ long long llrint(double __a) { return __nv_llrint(__a); } +__DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); } +__DEVICE__ long long llround(double __a) { return __nv_llround(__a); } +__DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); } +__DEVICE__ double round(double __a) { return __nv_round(__a); } +__DEVICE__ float roundf(float __a) { return __nv_roundf(__a); } +__DEVICE__ double log(double __a) { return __nv_log(__a); } +__DEVICE__ double log10(double __a) { return __nv_log10(__a); } +__DEVICE__ float log10f(float __a) { return __nv_log10f(__a); } +__DEVICE__ double log1p(double __a) { return __nv_log1p(__a); } +__DEVICE__ float log1pf(float __a) { return __nv_log1pf(__a); } +__DEVICE__ double log2(double __a) { return __nv_log2(__a); } +__DEVICE__ float log2f(float __a) { + return __FAST_OR_SLOW(__nv_fast_log2f, __nv_log2f)(__a); +} +__DEVICE__ double logb(double __a) { return __nv_logb(__a); } +__DEVICE__ float logbf(float __a) { return __nv_logbf(__a); } +__DEVICE__ float logf(float __a) { + return __FAST_OR_SLOW(__nv_fast_logf, __nv_logf)(__a); +} +#if defined(__LP64__) || defined(_WIN64) +__DEVICE__ long lrint(double __a) { return llrint(__a); } +__DEVICE__ long lrintf(float __a) { return __float2ll_rn(__a); } +__DEVICE__ long lround(double __a) { return llround(__a); } +__DEVICE__ long lroundf(float __a) { return llroundf(__a); } +#else +__DEVICE__ long lrint(double __a) { return (long)rint(__a); } +__DEVICE__ long lrintf(float __a) { return __float2int_rn(__a); } +__DEVICE__ long lround(double __a) { return round(__a); } +__DEVICE__ long lroundf(float __a) { return roundf(__a); } +#endif +__DEVICE__ int max(int __a, int __b) { return __nv_max(__a, __b); } +__DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); } +__DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); } +__DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); } +__DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); } +__DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); } +__DEVICE__ double nextafter(double __a, double __b) { + return __nv_nextafter(__a, __b); +} +__DEVICE__ float nextafterf(float __a, float __b) { + return __nv_nextafterf(__a, __b); +} +__DEVICE__ double norm(int __dim, const double *__t) { + return __nv_norm(__dim, __t); +} +__DEVICE__ double norm3d(double __a, double __b, double __c) { + return __nv_norm3d(__a, __b, __c); +} +__DEVICE__ float norm3df(float __a, float __b, float __c) { + return __nv_norm3df(__a, __b, __c); +} +__DEVICE__ double norm4d(double __a, double __b, double __c, double __d) { + return __nv_norm4d(__a, __b, __c, __d); +} +__DEVICE__ float norm4df(float __a, float __b, float __c, float __d) { + return __nv_norm4df(__a, __b, __c, __d); +} +__DEVICE__ double normcdf(double __a) { return __nv_normcdf(__a); } +__DEVICE__ float normcdff(float __a) { return __nv_normcdff(__a); } +__DEVICE__ double normcdfinv(double __a) { return __nv_normcdfinv(__a); } +__DEVICE__ float normcdfinvf(float __a) { return __nv_normcdfinvf(__a); } +__DEVICE__ float normf(int __dim, const float *__t) { + return __nv_normf(__dim, __t); +} +__DEVICE__ double pow(double __a, double __b) { return __nv_pow(__a, __b); } +__DEVICE__ float powf(float __a, float __b) { return __nv_powf(__a, __b); } +__DEVICE__ double powi(double __a, int __b) { return __nv_powi(__a, __b); } +__DEVICE__ float powif(float __a, int __b) { return __nv_powif(__a, __b); } +__DEVICE__ double rcbrt(double __a) { return __nv_rcbrt(__a); } +__DEVICE__ float rcbrtf(float __a) { return __nv_rcbrtf(__a); } +__DEVICE__ double remainder(double __a, double __b) { + return __nv_remainder(__a, __b); +} +__DEVICE__ float remainderf(float __a, float __b) { + return __nv_remainderf(__a, __b); +} +__DEVICE__ double remquo(double __a, double __b, int *__c) { + return __nv_remquo(__a, __b, __c); +} +__DEVICE__ float remquof(float __a, float __b, int *__c) { + return __nv_remquof(__a, __b, __c); +} +__DEVICE__ double rhypot(double __a, double __b) { + return __nv_rhypot(__a, __b); +} +__DEVICE__ float rhypotf(float __a, float __b) { + return __nv_rhypotf(__a, __b); +} +// __nv_rint* in libdevice is buggy and produces incorrect results. +__DEVICE__ double rint(double __a) { return __builtin_rint(__a); } +__DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); } +__DEVICE__ double rnorm(int __a, const double *__b) { + return __nv_rnorm(__a, __b); +} +__DEVICE__ double rnorm3d(double __a, double __b, double __c) { + return __nv_rnorm3d(__a, __b, __c); +} +__DEVICE__ float rnorm3df(float __a, float __b, float __c) { + return __nv_rnorm3df(__a, __b, __c); +} +__DEVICE__ double rnorm4d(double __a, double __b, double __c, double __d) { + return __nv_rnorm4d(__a, __b, __c, __d); +} +__DEVICE__ float rnorm4df(float __a, float __b, float __c, float __d) { + return __nv_rnorm4df(__a, __b, __c, __d); +} +__DEVICE__ float rnormf(int __dim, const float *__t) { + return __nv_rnormf(__dim, __t); +} +__DEVICE__ double rsqrt(double __a) { return __nv_rsqrt(__a); } +__DEVICE__ float rsqrtf(float __a) { return __nv_rsqrtf(__a); } +__DEVICE__ double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); } +__DEVICE__ float scalbnf(float __a, int __b) { return __nv_scalbnf(__a, __b); } +__DEVICE__ double scalbln(double __a, long __b) { + if (__b > INT_MAX) + return __a > 0 ? HUGE_VAL : -HUGE_VAL; + if (__b < INT_MIN) + return __a > 0 ? 0.0 : -0.0; + return scalbn(__a, (int)__b); +} +__DEVICE__ float scalblnf(float __a, long __b) { + if (__b > INT_MAX) + return __a > 0 ? HUGE_VALF : -HUGE_VALF; + if (__b < INT_MIN) + return __a > 0 ? 0.f : -0.f; + return scalbnf(__a, (int)__b); +} +__DEVICE__ double sin(double __a) { return __nv_sin(__a); } +__DEVICE_VOID__ void sincos(double __a, double *__s, double *__c) { + return __nv_sincos(__a, __s, __c); +} +__DEVICE_VOID__ void sincosf(float __a, float *__s, float *__c) { + return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __s, __c); +} +__DEVICE_VOID__ void sincospi(double __a, double *__s, double *__c) { + return __nv_sincospi(__a, __s, __c); +} +__DEVICE_VOID__ void sincospif(float __a, float *__s, float *__c) { + return __nv_sincospif(__a, __s, __c); +} +__DEVICE__ float sinf(float __a) { + return __FAST_OR_SLOW(__nv_fast_sinf, __nv_sinf)(__a); +} +__DEVICE__ double sinh(double __a) { return __nv_sinh(__a); } +__DEVICE__ float sinhf(float __a) { return __nv_sinhf(__a); } +__DEVICE__ double sinpi(double __a) { return __nv_sinpi(__a); } +__DEVICE__ float sinpif(float __a) { return __nv_sinpif(__a); } +__DEVICE__ double sqrt(double __a) { return __nv_sqrt(__a); } +__DEVICE__ float sqrtf(float __a) { return __nv_sqrtf(__a); } +__DEVICE__ double tan(double __a) { return __nv_tan(__a); } +__DEVICE__ float tanf(float __a) { return __nv_tanf(__a); } +__DEVICE__ double tanh(double __a) { return __nv_tanh(__a); } +__DEVICE__ float tanhf(float __a) { return __nv_tanhf(__a); } +__DEVICE__ double tgamma(double __a) { return __nv_tgamma(__a); } +__DEVICE__ float tgammaf(float __a) { return __nv_tgammaf(__a); } +__DEVICE__ double trunc(double __a) { return __nv_trunc(__a); } +__DEVICE__ float truncf(float __a) { return __nv_truncf(__a); } +__DEVICE__ unsigned long long ullmax(unsigned long long __a, + unsigned long long __b) { + return __nv_ullmax(__a, __b); +} +__DEVICE__ unsigned long long ullmin(unsigned long long __a, + unsigned long long __b) { + return __nv_ullmin(__a, __b); +} +__DEVICE__ unsigned int umax(unsigned int __a, unsigned int __b) { + return __nv_umax(__a, __b); +} +__DEVICE__ unsigned int umin(unsigned int __a, unsigned int __b) { + return __nv_umin(__a, __b); +} +__DEVICE__ double y0(double __a) { return __nv_y0(__a); } +__DEVICE__ float y0f(float __a) { return __nv_y0f(__a); } +__DEVICE__ double y1(double __a) { return __nv_y1(__a); } +__DEVICE__ float y1f(float __a) { return __nv_y1f(__a); } +__DEVICE__ double yn(int __a, double __b) { return __nv_yn(__a, __b); } +__DEVICE__ float ynf(int __a, float __b) { return __nv_ynf(__a, __b); } + +#pragma pop_macro("__DEVICE__") +#pragma pop_macro("__DEVICE_VOID__") +#pragma pop_macro("__FAST_OR_SLOW") + +#endif // __CLANG_GPU_DISABLE_MATH_WRAPPERS +#endif // __CLANG_CUDA_MATH_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_math_forward_declares.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_math_forward_declares.h new file mode 100755 index 0000000..c0f1f47 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_math_forward_declares.h @@ -0,0 +1,284 @@ +/*===- __clang_math_forward_declares.h - Prototypes of __device__ math fns --=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CLANG__CUDA_MATH_FORWARD_DECLARES_H__ +#define __CLANG__CUDA_MATH_FORWARD_DECLARES_H__ +#if !defined(__CUDA__) && !__HIP__ +#error "This file is for CUDA/HIP compilation only." +#endif + +// This file forward-declares of some math functions we (or the CUDA headers) +// will define later. We need to do this, and do it before cmath is included, +// because the standard library may have constexpr math functions. In the +// absence of a prior __device__ decl, those constexpr functions may become +// implicitly host+device. host+device functions can't be overloaded, so that +// would preclude the use of our own __device__ overloads for these functions. + +#pragma push_macro("__DEVICE__") +#define __DEVICE__ \ + static __inline__ __attribute__((always_inline)) __attribute__((device)) + +__DEVICE__ long abs(long); +__DEVICE__ long long abs(long long); +__DEVICE__ double abs(double); +__DEVICE__ float abs(float); +__DEVICE__ int abs(int); +__DEVICE__ double acos(double); +__DEVICE__ float acos(float); +__DEVICE__ double acosh(double); +__DEVICE__ float acosh(float); +__DEVICE__ double asin(double); +__DEVICE__ float asin(float); +__DEVICE__ double asinh(double); +__DEVICE__ float asinh(float); +__DEVICE__ double atan2(double, double); +__DEVICE__ float atan2(float, float); +__DEVICE__ double atan(double); +__DEVICE__ float atan(float); +__DEVICE__ double atanh(double); +__DEVICE__ float atanh(float); +__DEVICE__ double cbrt(double); +__DEVICE__ float cbrt(float); +__DEVICE__ double ceil(double); +__DEVICE__ float ceil(float); +__DEVICE__ double copysign(double, double); +__DEVICE__ float copysign(float, float); +__DEVICE__ double cos(double); +__DEVICE__ float cos(float); +__DEVICE__ double cosh(double); +__DEVICE__ float cosh(float); +__DEVICE__ double erfc(double); +__DEVICE__ float erfc(float); +__DEVICE__ double erf(double); +__DEVICE__ float erf(float); +__DEVICE__ double exp2(double); +__DEVICE__ float exp2(float); +__DEVICE__ double exp(double); +__DEVICE__ float exp(float); +__DEVICE__ double expm1(double); +__DEVICE__ float expm1(float); +__DEVICE__ double fabs(double); +__DEVICE__ float fabs(float); +__DEVICE__ double fdim(double, double); +__DEVICE__ float fdim(float, float); +__DEVICE__ double floor(double); +__DEVICE__ float floor(float); +__DEVICE__ double fma(double, double, double); +__DEVICE__ float fma(float, float, float); +__DEVICE__ double fmax(double, double); +__DEVICE__ float fmax(float, float); +__DEVICE__ double fmin(double, double); +__DEVICE__ float fmin(float, float); +__DEVICE__ double fmod(double, double); +__DEVICE__ float fmod(float, float); +__DEVICE__ int fpclassify(double); +__DEVICE__ int fpclassify(float); +__DEVICE__ double frexp(double, int *); +__DEVICE__ float frexp(float, int *); +__DEVICE__ double hypot(double, double); +__DEVICE__ float hypot(float, float); +__DEVICE__ int ilogb(double); +__DEVICE__ int ilogb(float); +#ifdef _MSC_VER +__DEVICE__ bool isfinite(long double); +#endif +__DEVICE__ bool isfinite(double); +__DEVICE__ bool isfinite(float); +__DEVICE__ bool isgreater(double, double); +__DEVICE__ bool isgreaterequal(double, double); +__DEVICE__ bool isgreaterequal(float, float); +__DEVICE__ bool isgreater(float, float); +#ifdef _MSC_VER +__DEVICE__ bool isinf(long double); +#endif +__DEVICE__ bool isinf(double); +__DEVICE__ bool isinf(float); +__DEVICE__ bool isless(double, double); +__DEVICE__ bool islessequal(double, double); +__DEVICE__ bool islessequal(float, float); +__DEVICE__ bool isless(float, float); +__DEVICE__ bool islessgreater(double, double); +__DEVICE__ bool islessgreater(float, float); +#ifdef _MSC_VER +__DEVICE__ bool isnan(long double); +#endif +__DEVICE__ bool isnan(double); +__DEVICE__ bool isnan(float); +__DEVICE__ bool isnormal(double); +__DEVICE__ bool isnormal(float); +__DEVICE__ bool isunordered(double, double); +__DEVICE__ bool isunordered(float, float); +__DEVICE__ long labs(long); +__DEVICE__ double ldexp(double, int); +__DEVICE__ float ldexp(float, int); +__DEVICE__ double lgamma(double); +__DEVICE__ float lgamma(float); +__DEVICE__ long long llabs(long long); +__DEVICE__ long long llrint(double); +__DEVICE__ long long llrint(float); +__DEVICE__ double log10(double); +__DEVICE__ float log10(float); +__DEVICE__ double log1p(double); +__DEVICE__ float log1p(float); +__DEVICE__ double log2(double); +__DEVICE__ float log2(float); +__DEVICE__ double logb(double); +__DEVICE__ float logb(float); +__DEVICE__ double log(double); +__DEVICE__ float log(float); +__DEVICE__ long lrint(double); +__DEVICE__ long lrint(float); +__DEVICE__ long lround(double); +__DEVICE__ long lround(float); +__DEVICE__ long long llround(float); // No llround(double). +__DEVICE__ double modf(double, double *); +__DEVICE__ float modf(float, float *); +__DEVICE__ double nan(const char *); +__DEVICE__ float nanf(const char *); +__DEVICE__ double nearbyint(double); +__DEVICE__ float nearbyint(float); +__DEVICE__ double nextafter(double, double); +__DEVICE__ float nextafter(float, float); +__DEVICE__ double pow(double, double); +__DEVICE__ double pow(double, int); +__DEVICE__ float pow(float, float); +__DEVICE__ float pow(float, int); +__DEVICE__ double remainder(double, double); +__DEVICE__ float remainder(float, float); +__DEVICE__ double remquo(double, double, int *); +__DEVICE__ float remquo(float, float, int *); +__DEVICE__ double rint(double); +__DEVICE__ float rint(float); +__DEVICE__ double round(double); +__DEVICE__ float round(float); +__DEVICE__ double scalbln(double, long); +__DEVICE__ float scalbln(float, long); +__DEVICE__ double scalbn(double, int); +__DEVICE__ float scalbn(float, int); +#ifdef _MSC_VER +__DEVICE__ bool signbit(long double); +#endif +__DEVICE__ bool signbit(double); +__DEVICE__ bool signbit(float); +__DEVICE__ double sin(double); +__DEVICE__ float sin(float); +__DEVICE__ double sinh(double); +__DEVICE__ float sinh(float); +__DEVICE__ double sqrt(double); +__DEVICE__ float sqrt(float); +__DEVICE__ double tan(double); +__DEVICE__ float tan(float); +__DEVICE__ double tanh(double); +__DEVICE__ float tanh(float); +__DEVICE__ double tgamma(double); +__DEVICE__ float tgamma(float); +__DEVICE__ double trunc(double); +__DEVICE__ float trunc(float); + +// Notably missing above is nexttoward, which we don't define on +// the device side because libdevice doesn't give us an implementation, and we +// don't want to be in the business of writing one ourselves. + +// We need to define these overloads in exactly the namespace our standard +// library uses (including the right inline namespace), otherwise they won't be +// picked up by other functions in the standard library (e.g. functions in +// ). Thus the ugliness below. +#ifdef _LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_BEGIN_NAMESPACE_STD +#else +namespace std { +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#endif +#endif + +using ::abs; +using ::acos; +using ::acosh; +using ::asin; +using ::asinh; +using ::atan; +using ::atan2; +using ::atanh; +using ::cbrt; +using ::ceil; +using ::copysign; +using ::cos; +using ::cosh; +using ::erf; +using ::erfc; +using ::exp; +using ::exp2; +using ::expm1; +using ::fabs; +using ::fdim; +using ::floor; +using ::fma; +using ::fmax; +using ::fmin; +using ::fmod; +using ::fpclassify; +using ::frexp; +using ::hypot; +using ::ilogb; +using ::isfinite; +using ::isgreater; +using ::isgreaterequal; +using ::isinf; +using ::isless; +using ::islessequal; +using ::islessgreater; +using ::isnan; +using ::isnormal; +using ::isunordered; +using ::labs; +using ::ldexp; +using ::lgamma; +using ::llabs; +using ::llrint; +using ::log; +using ::log10; +using ::log1p; +using ::log2; +using ::logb; +using ::lrint; +using ::lround; +using ::llround; +using ::modf; +using ::nan; +using ::nanf; +using ::nearbyint; +using ::nextafter; +using ::pow; +using ::remainder; +using ::remquo; +using ::rint; +using ::round; +using ::scalbln; +using ::scalbn; +using ::signbit; +using ::sin; +using ::sinh; +using ::sqrt; +using ::tan; +using ::tanh; +using ::tgamma; +using ::trunc; + +#ifdef _LIBCPP_END_NAMESPACE_STD +_LIBCPP_END_NAMESPACE_STD +#else +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +#endif +} // namespace std +#endif + +#pragma pop_macro("__DEVICE__") + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_runtime_wrapper.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_runtime_wrapper.h new file mode 100755 index 0000000..44934ba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_runtime_wrapper.h @@ -0,0 +1,504 @@ +/*===---- __clang_cuda_runtime_wrapper.h - CUDA runtime support -------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * WARNING: This header is intended to be directly -include'd by + * the compiler and is not supposed to be included by users. + * + * CUDA headers are implemented in a way that currently makes it + * impossible for user code to #include directly when compiling with + * Clang. They present different view of CUDA-supplied functions + * depending on where in NVCC's compilation pipeline the headers are + * included. Neither of these modes provides function definitions with + * correct attributes, so we use preprocessor to force the headers + * into a form that Clang can use. + * + * Similarly to NVCC which -include's cuda_runtime.h, Clang -include's + * this file during every CUDA compilation. + */ + +#ifndef __CLANG_CUDA_RUNTIME_WRAPPER_H__ +#define __CLANG_CUDA_RUNTIME_WRAPPER_H__ + +#if defined(__CUDA__) && defined(__clang__) + +// Include some forward declares that must come before cmath. +#include <__clang_cuda_math_forward_declares.h> + +// Define __CUDACC__ early as libstdc++ standard headers with GNU extensions +// enabled depend on it to avoid using __float128, which is unsupported in +// CUDA. +#define __CUDACC__ + +// Include some standard headers to avoid CUDA headers including them +// while some required macros (like __THROW) are in a weird state. +#include +#include +#include +#include +#undef __CUDACC__ + +// Preserve common macros that will be changed below by us or by CUDA +// headers. +#pragma push_macro("__THROW") +#pragma push_macro("__CUDA_ARCH__") + +// WARNING: Preprocessor hacks below are based on specific details of +// CUDA-7.x headers and are not expected to work with any other +// version of CUDA headers. +#include "cuda.h" +#if !defined(CUDA_VERSION) +#error "cuda.h did not define CUDA_VERSION" +#elif CUDA_VERSION < 7000 +#error "Unsupported CUDA version!" +#endif + +#pragma push_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__") +#if CUDA_VERSION >= 10000 +#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__ +#endif + +// Make largest subset of device functions available during host +// compilation. +#ifndef __CUDA_ARCH__ +#define __CUDA_ARCH__ 9999 +#endif + +#include "__clang_cuda_builtin_vars.h" + +// No need for device_launch_parameters.h as __clang_cuda_builtin_vars.h above +// has taken care of builtin variables declared in the file. +#define __DEVICE_LAUNCH_PARAMETERS_H__ + +// {math,device}_functions.h only have declarations of the +// functions. We don't need them as we're going to pull in their +// definitions from .hpp files. +#define __DEVICE_FUNCTIONS_H__ +#define __MATH_FUNCTIONS_H__ +#define __COMMON_FUNCTIONS_H__ +// device_functions_decls is replaced by __clang_cuda_device_functions.h +// included below. +#define __DEVICE_FUNCTIONS_DECLS_H__ + +#undef __CUDACC__ +#if CUDA_VERSION < 9000 +#define __CUDABE__ +#else +#define __CUDACC__ +#define __CUDA_LIBDEVICE__ +#endif +// Disables definitions of device-side runtime support stubs in +// cuda_device_runtime_api.h +#include "host_defines.h" +#undef __CUDACC__ +#include "driver_types.h" +#include "host_config.h" + +// Temporarily replace "nv_weak" with weak, so __attribute__((nv_weak)) in +// cuda_device_runtime_api.h ends up being __attribute__((weak)) which is the +// functional equivalent of what we need. +#pragma push_macro("nv_weak") +#define nv_weak weak +#undef __CUDABE__ +#undef __CUDA_LIBDEVICE__ +#define __CUDACC__ +#include "cuda_runtime.h" + +#pragma pop_macro("nv_weak") +#undef __CUDACC__ +#define __CUDABE__ + +// CUDA headers use __nvvm_memcpy and __nvvm_memset which Clang does +// not have at the moment. Emulate them with a builtin memcpy/memset. +#define __nvvm_memcpy(s, d, n, a) __builtin_memcpy(s, d, n) +#define __nvvm_memset(d, c, n, a) __builtin_memset(d, c, n) + +#if CUDA_VERSION < 9000 +#include "crt/device_runtime.h" +#endif +#include "crt/host_runtime.h" +// device_runtime.h defines __cxa_* macros that will conflict with +// cxxabi.h. +// FIXME: redefine these as __device__ functions. +#undef __cxa_vec_ctor +#undef __cxa_vec_cctor +#undef __cxa_vec_dtor +#undef __cxa_vec_new +#undef __cxa_vec_new2 +#undef __cxa_vec_new3 +#undef __cxa_vec_delete2 +#undef __cxa_vec_delete +#undef __cxa_vec_delete3 +#undef __cxa_pure_virtual + +// math_functions.hpp expects this host function be defined on MacOS, but it +// ends up not being there because of the games we play here. Just define it +// ourselves; it's simple enough. +#ifdef __APPLE__ +inline __host__ double __signbitd(double x) { + return std::signbit(x); +} +#endif + +// CUDA 9.1 no longer provides declarations for libdevice functions, so we need +// to provide our own. +#include <__clang_cuda_libdevice_declares.h> + +// Wrappers for many device-side standard library functions, incl. math +// functions, became compiler builtins in CUDA-9 and have been removed from the +// CUDA headers. Clang now provides its own implementation of the wrappers. +#if CUDA_VERSION >= 9000 +#include <__clang_cuda_device_functions.h> +#include <__clang_cuda_math.h> +#endif + +// __THROW is redefined to be empty by device_functions_decls.h in CUDA. Clang's +// counterpart does not do it, so we need to make it empty here to keep +// following CUDA includes happy. +#undef __THROW +#define __THROW + +// CUDA 8.0.41 relies on __USE_FAST_MATH__ and __CUDA_PREC_DIV's values. +// Previous versions used to check whether they are defined or not. +// CU_DEVICE_INVALID macro is only defined in 8.0.41, so we use it +// here to detect the switch. + +#if defined(CU_DEVICE_INVALID) +#if !defined(__USE_FAST_MATH__) +#define __USE_FAST_MATH__ 0 +#endif + +#if !defined(__CUDA_PREC_DIV) +#define __CUDA_PREC_DIV 0 +#endif +#endif + +// Temporarily poison __host__ macro to ensure it's not used by any of +// the headers we're about to include. +#pragma push_macro("__host__") +#define __host__ UNEXPECTED_HOST_ATTRIBUTE + +// device_functions.hpp and math_functions*.hpp use 'static +// __forceinline__' (with no __device__) for definitions of device +// functions. Temporarily redefine __forceinline__ to include +// __device__. +#pragma push_macro("__forceinline__") +#define __forceinline__ __device__ __inline__ __attribute__((always_inline)) +#if CUDA_VERSION < 9000 +#include "device_functions.hpp" +#endif + +// math_function.hpp uses the __USE_FAST_MATH__ macro to determine whether we +// get the slow-but-accurate or fast-but-inaccurate versions of functions like +// sin and exp. This is controlled in clang by -fgpu-approx-transcendentals. +// +// device_functions.hpp uses __USE_FAST_MATH__ for a different purpose (fast vs. +// slow divides), so we need to scope our define carefully here. +#pragma push_macro("__USE_FAST_MATH__") +#if defined(__CLANG_GPU_APPROX_TRANSCENDENTALS__) +#define __USE_FAST_MATH__ 1 +#endif + +#if CUDA_VERSION >= 9000 +#include "crt/math_functions.hpp" +#else +#include "math_functions.hpp" +#endif + +#pragma pop_macro("__USE_FAST_MATH__") + +#if CUDA_VERSION < 9000 +#include "math_functions_dbl_ptx3.hpp" +#endif +#pragma pop_macro("__forceinline__") + +// Pull in host-only functions that are only available when neither +// __CUDACC__ nor __CUDABE__ are defined. +#undef __MATH_FUNCTIONS_HPP__ +#undef __CUDABE__ +#if CUDA_VERSION < 9000 +#include "math_functions.hpp" +#endif +// Alas, additional overloads for these functions are hard to get to. +// Considering that we only need these overloads for a few functions, +// we can provide them here. +static inline float rsqrt(float __a) { return rsqrtf(__a); } +static inline float rcbrt(float __a) { return rcbrtf(__a); } +static inline float sinpi(float __a) { return sinpif(__a); } +static inline float cospi(float __a) { return cospif(__a); } +static inline void sincospi(float __a, float *__b, float *__c) { + return sincospif(__a, __b, __c); +} +static inline float erfcinv(float __a) { return erfcinvf(__a); } +static inline float normcdfinv(float __a) { return normcdfinvf(__a); } +static inline float normcdf(float __a) { return normcdff(__a); } +static inline float erfcx(float __a) { return erfcxf(__a); } + +#if CUDA_VERSION < 9000 +// For some reason single-argument variant is not always declared by +// CUDA headers. Alas, device_functions.hpp included below needs it. +static inline __device__ void __brkpt(int __c) { __brkpt(); } +#endif + +// Now include *.hpp with definitions of various GPU functions. Alas, +// a lot of thins get declared/defined with __host__ attribute which +// we don't want and we have to define it out. We also have to include +// {device,math}_functions.hpp again in order to extract the other +// branch of #if/else inside. +#define __host__ +#undef __CUDABE__ +#define __CUDACC__ +#if CUDA_VERSION >= 9000 +// Some atomic functions became compiler builtins in CUDA-9 , so we need their +// declarations. +#include "device_atomic_functions.h" +#endif +#undef __DEVICE_FUNCTIONS_HPP__ +#include "device_atomic_functions.hpp" +#if CUDA_VERSION >= 9000 +#include "crt/device_functions.hpp" +#include "crt/device_double_functions.hpp" +#else +#include "device_functions.hpp" +#define __CUDABE__ +#include "device_double_functions.h" +#undef __CUDABE__ +#endif +#include "sm_20_atomic_functions.hpp" +// Predicate functions used in `__builtin_assume` need to have no side effect. +// However, sm_20_intrinsics.hpp doesn't define them with neither pure nor +// const attribute. Rename definitions from sm_20_intrinsics.hpp and re-define +// them as pure ones. +#pragma push_macro("__isGlobal") +#pragma push_macro("__isShared") +#pragma push_macro("__isConstant") +#pragma push_macro("__isLocal") +#define __isGlobal __ignored_cuda___isGlobal +#define __isShared __ignored_cuda___isShared +#define __isConstant __ignored_cuda___isConstant +#define __isLocal __ignored_cuda___isLocal +#include "sm_20_intrinsics.hpp" +#pragma pop_macro("__isGlobal") +#pragma pop_macro("__isShared") +#pragma pop_macro("__isConstant") +#pragma pop_macro("__isLocal") +#pragma push_macro("__DEVICE__") +#define __DEVICE__ static __device__ __forceinline__ __attribute__((const)) +__DEVICE__ unsigned int __isGlobal(const void *p) { + return __nvvm_isspacep_global(p); +} +__DEVICE__ unsigned int __isShared(const void *p) { + return __nvvm_isspacep_shared(p); +} +__DEVICE__ unsigned int __isConstant(const void *p) { + return __nvvm_isspacep_const(p); +} +__DEVICE__ unsigned int __isLocal(const void *p) { + return __nvvm_isspacep_local(p); +} +#pragma pop_macro("__DEVICE__") +#include "sm_32_atomic_functions.hpp" + +// Don't include sm_30_intrinsics.h and sm_32_intrinsics.h. These define the +// __shfl and __ldg intrinsics using inline (volatile) asm, but we want to +// define them using builtins so that the optimizer can reason about and across +// these instructions. In particular, using intrinsics for ldg gets us the +// [addr+imm] addressing mode, which, although it doesn't actually exist in the +// hardware, seems to generate faster machine code because ptxas can more easily +// reason about our code. + +#if CUDA_VERSION >= 8000 +#pragma push_macro("__CUDA_ARCH__") +#undef __CUDA_ARCH__ +#include "sm_60_atomic_functions.hpp" +#include "sm_61_intrinsics.hpp" +#pragma pop_macro("__CUDA_ARCH__") +#endif + +#undef __MATH_FUNCTIONS_HPP__ + +// math_functions.hpp defines ::signbit as a __host__ __device__ function. This +// conflicts with libstdc++'s constexpr ::signbit, so we have to rename +// math_function.hpp's ::signbit. It's guarded by #undef signbit, but that's +// conditional on __GNUC__. :) +#pragma push_macro("signbit") +#pragma push_macro("__GNUC__") +#undef __GNUC__ +#define signbit __ignored_cuda_signbit + +// CUDA-9 omits device-side definitions of some math functions if it sees +// include guard from math.h wrapper from libstdc++. We have to undo the header +// guard temporarily to get the definitions we need. +#pragma push_macro("_GLIBCXX_MATH_H") +#pragma push_macro("_LIBCPP_VERSION") +#if CUDA_VERSION >= 9000 +#undef _GLIBCXX_MATH_H +// We also need to undo another guard that checks for libc++ 3.8+ +#ifdef _LIBCPP_VERSION +#define _LIBCPP_VERSION 3700 +#endif +#endif + +#if CUDA_VERSION >= 9000 +#include "crt/math_functions.hpp" +#else +#include "math_functions.hpp" +#endif +#pragma pop_macro("_GLIBCXX_MATH_H") +#pragma pop_macro("_LIBCPP_VERSION") +#pragma pop_macro("__GNUC__") +#pragma pop_macro("signbit") + +#pragma pop_macro("__host__") + +// __clang_cuda_texture_intrinsics.h must be included first in order to provide +// implementation for __nv_tex_surf_handler that CUDA's headers depend on. +// The implementation requires c++11 and only works with CUDA-9 or newer. +#if __cplusplus >= 201103L && CUDA_VERSION >= 9000 +// clang-format off +#include <__clang_cuda_texture_intrinsics.h> +// clang-format on +#else +#if CUDA_VERSION >= 9000 +// Provide a hint that texture support needs C++11. +template struct __nv_tex_needs_cxx11 { + const static bool value = false; +}; +template +__host__ __device__ void __nv_tex_surf_handler(const char *name, T *ptr, + cudaTextureObject_t obj, + float x) { + _Static_assert(__nv_tex_needs_cxx11::value, + "Texture support requires C++11"); +} +#else +// Textures in CUDA-8 and older are not supported by clang.There's no +// convenient way to intercept texture use in these versions, so we can't +// produce a meaningful error. The source code that attempts to use textures +// will continue to fail as it does now. +#endif // CUDA_VERSION +#endif // __cplusplus >= 201103L && CUDA_VERSION >= 9000 +#include "surface_indirect_functions.h" +#include "texture_fetch_functions.h" +#include "texture_indirect_functions.h" + +// Restore state of __CUDA_ARCH__ and __THROW we had on entry. +#pragma pop_macro("__CUDA_ARCH__") +#pragma pop_macro("__THROW") + +// Set up compiler macros expected to be seen during compilation. +#undef __CUDABE__ +#define __CUDACC__ + +extern "C" { +// Device-side CUDA system calls. +// http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/index.html#system-calls +// We need these declarations and wrappers for device-side +// malloc/free/printf calls to work without relying on +// -fcuda-disable-target-call-checks option. +__device__ int vprintf(const char *, const char *); +__device__ void free(void *) __attribute((nothrow)); +__device__ void *malloc(size_t) __attribute((nothrow)) __attribute__((malloc)); + +// __assertfail() used to have a `noreturn` attribute. Unfortunately that +// contributed to triggering the longstanding bug in ptxas when assert was used +// in sufficiently convoluted code. See +// https://bugs.llvm.org/show_bug.cgi?id=27738 for the details. +__device__ void __assertfail(const char *__message, const char *__file, + unsigned __line, const char *__function, + size_t __charSize); + +// In order for standard assert() macro on linux to work we need to +// provide device-side __assert_fail() +__device__ static inline void __assert_fail(const char *__message, + const char *__file, unsigned __line, + const char *__function) { + __assertfail(__message, __file, __line, __function, sizeof(char)); +} + +// Clang will convert printf into vprintf, but we still need +// device-side declaration for it. +__device__ int printf(const char *, ...); +} // extern "C" + +// We also need device-side std::malloc and std::free. +namespace std { +__device__ static inline void free(void *__ptr) { ::free(__ptr); } +__device__ static inline void *malloc(size_t __size) { + return ::malloc(__size); +} +} // namespace std + +// Out-of-line implementations from __clang_cuda_builtin_vars.h. These need to +// come after we've pulled in the definition of uint3 and dim3. + +__device__ inline __cuda_builtin_threadIdx_t::operator dim3() const { + return dim3(x, y, z); +} + +__device__ inline __cuda_builtin_threadIdx_t::operator uint3() const { + return {x, y, z}; +} + +__device__ inline __cuda_builtin_blockIdx_t::operator dim3() const { + return dim3(x, y, z); +} + +__device__ inline __cuda_builtin_blockIdx_t::operator uint3() const { + return {x, y, z}; +} + +__device__ inline __cuda_builtin_blockDim_t::operator dim3() const { + return dim3(x, y, z); +} + +__device__ inline __cuda_builtin_blockDim_t::operator uint3() const { + return {x, y, z}; +} + +__device__ inline __cuda_builtin_gridDim_t::operator dim3() const { + return dim3(x, y, z); +} + +__device__ inline __cuda_builtin_gridDim_t::operator uint3() const { + return {x, y, z}; +} + +#include <__clang_cuda_cmath.h> +#include <__clang_cuda_intrinsics.h> +#include <__clang_cuda_complex_builtins.h> + +// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host +// mode, giving them their "proper" types of dim3 and uint3. This is +// incompatible with the types we give in __clang_cuda_builtin_vars.h. As as +// hack, force-include the header (nvcc doesn't include it by default) but +// redefine dim3 and uint3 to our builtin types. (Thankfully dim3 and uint3 are +// only used here for the redeclarations of blockDim and threadIdx.) +#pragma push_macro("dim3") +#pragma push_macro("uint3") +#define dim3 __cuda_builtin_blockDim_t +#define uint3 __cuda_builtin_threadIdx_t +#include "curand_mtgp32_kernel.h" +#pragma pop_macro("dim3") +#pragma pop_macro("uint3") +#pragma pop_macro("__USE_FAST_MATH__") +#pragma pop_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__") + +// CUDA runtime uses this undocumented function to access kernel launch +// configuration. The declaration is in crt/device_functions.h but that file +// includes a lot of other stuff we don't want. Instead, we'll provide our own +// declaration for it here. +#if CUDA_VERSION >= 9020 +extern "C" unsigned __cudaPushCallConfiguration(dim3 gridDim, dim3 blockDim, + size_t sharedMem = 0, + void *stream = 0); +#endif + +#endif // __CUDA__ +#endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_texture_intrinsics.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_texture_intrinsics.h new file mode 100755 index 0000000..8b914ed --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_cuda_texture_intrinsics.h @@ -0,0 +1,1177 @@ +/*===--- __clang_cuda_texture_intrinsics.h - Device-side texture support ---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + * + * This header provides in-header implmentations for NVCC's built-in + * __nv_tex_surf_handler() which is used by CUDA's texture-related headers. The + * built-in is unusual as it's actually a set of function overloads that use the + * first string literal argument as one of the overload parameters. + */ +#ifndef __CLANG_CUDA_TEXTURE_INTRINSICS_H__ +#define __CLANG_CUDA_TEXTURE_INTRINSICS_H__ +#ifndef __CUDA__ +#error "This file is for CUDA compilation only." +#endif + +// __nv_tex_surf_handler() provided by this header as a macro. +#define __nv_tex_surf_handler(__op, __ptr, ...) \ + ::__cuda_tex::__tex_fetch< \ + ::__cuda_tex::__Tag<::__cuda_tex::__tex_op_hash(__op)>>(__ptr, \ + __VA_ARGS__) + +#pragma push_macro("__ASM_OUT") +#pragma push_macro("__ASM_OUTP") +#pragma push_macro("__Args") +#pragma push_macro("__ID") +#pragma push_macro("__IDV") +#pragma push_macro("__OP_TYPE_SURFACE") +#pragma push_macro("__IMPL_2DGATHER") +#pragma push_macro("__IMPL_ALIAS") +#pragma push_macro("__IMPL_ALIASI") +#pragma push_macro("__IMPL_F1") +#pragma push_macro("__IMPL_F3") +#pragma push_macro("__IMPL_F3N") +#pragma push_macro("__IMPL_F3S") +#pragma push_macro("__IMPL_S") +#pragma push_macro("__IMPL_S3") +#pragma push_macro("__IMPL_S3I") +#pragma push_macro("__IMPL_S3N") +#pragma push_macro("__IMPL_S3NI") +#pragma push_macro("__IMPL_S3S") +#pragma push_macro("__IMPL_S3SI") +#pragma push_macro("__IMPL_SI") +#pragma push_macro("__L") +#pragma push_macro("__STRIP_PARENS") +#pragma push_macro("__SURF_WRITE_V2") +#pragma push_macro("__SW_ASM_ARGS") +#pragma push_macro("__SW_ASM_ARGS1") +#pragma push_macro("__SW_ASM_ARGS2") +#pragma push_macro("__SW_ASM_ARGS4") +#pragma push_macro("__SURF_WRITE_V2") +#pragma push_macro("__SURF_READ_V2") +#pragma push_macro("__SW_ASM_ARGS") +#pragma push_macro("__SW_ASM_ARGS1") +#pragma push_macro("__SW_ASM_ARGS2") +#pragma push_macro("__SW_ASM_ARGS4") +#pragma push_macro("__SURF_READ1D"); +#pragma push_macro("__SURF_READ2D"); +#pragma push_macro("__SURF_READ3D"); +#pragma push_macro("__SURF_READ1DLAYERED"); +#pragma push_macro("__SURF_READ2DLAYERED"); +#pragma push_macro("__SURF_READCUBEMAP"); +#pragma push_macro("__SURF_READCUBEMAPLAYERED"); +#pragma push_macro("__1DV1"); +#pragma push_macro("__1DV2"); +#pragma push_macro("__1DV4"); +#pragma push_macro("__2DV1"); +#pragma push_macro("__2DV2"); +#pragma push_macro("__2DV4"); +#pragma push_macro("__1DLAYERV1"); +#pragma push_macro("__1DLAYERV2"); +#pragma push_macro("__1DLAYERV4"); +#pragma push_macro("__3DV1"); +#pragma push_macro("__3DV2"); +#pragma push_macro("__3DV4"); +#pragma push_macro("__2DLAYERV1"); +#pragma push_macro("__2DLAYERV2"); +#pragma push_macro("__2DLAYERV4"); +#pragma push_macro("__CUBEMAPV1"); +#pragma push_macro("__CUBEMAPV2"); +#pragma push_macro("__CUBEMAPV4"); +#pragma push_macro("__CUBEMAPLAYERV1"); +#pragma push_macro("__CUBEMAPLAYERV2"); +#pragma push_macro("__CUBEMAPLAYERV4"); +#pragma push_macro("__SURF_READXD_ALL"); +#pragma push_macro("__SURF_WRITE1D_V2"); +#pragma push_macro("__SURF_WRITE1DLAYERED_V2"); +#pragma push_macro("__SURF_WRITE2D_V2"); +#pragma push_macro("__SURF_WRITE2DLAYERED_V2"); +#pragma push_macro("__SURF_WRITE3D_V2"); +#pragma push_macro("__SURF_CUBEMAPWRITE_V2"); +#pragma push_macro("__SURF_CUBEMAPLAYEREDWRITE_V2"); +#pragma push_macro("__SURF_WRITEXD_V2_ALL"); +#pragma push_macro("__1DV1"); +#pragma push_macro("__1DV2"); +#pragma push_macro("__1DV4"); +#pragma push_macro("__2DV1"); +#pragma push_macro("__2DV2"); +#pragma push_macro("__2DV4"); +#pragma push_macro("__3DV1"); +#pragma push_macro("__3DV2"); +#pragma push_macro("__3DV4"); + +// Put all functions into anonymous namespace so they have internal linkage. +// The device-only function here must be internal in order to avoid ODR +// violations in case they are used from the files compiled with +// -fgpu-rdc. E.g. a library and an app using it may be built with a different +// version of this header file. +namespace { + +// Put the implmentation into its own namespace so we don't pollute the TU. +namespace __cuda_tex { + +// First, we need a perfect hash function and a few constexpr helper functions +// for converting a string literal into a numeric value which can be used to +// parametrize a template. We can not use string literals for that as that would +// require C++20. +// +// The hash function was generated with 'gperf' and then manually converted into +// its constexpr equivalent. +// +// NOTE: the perfect hashing scheme comes with inherent self-test. If the hash +// function has a collision for any of the texture operations, the compilation +// will fail due to an attempt to redefine a tag with the same value. If the +// header compiles, then the hash function is good enough for the job. + +constexpr int __tex_len(const char *s) { + return (s[0] == 0) ? 0 + : (s[1] == 0) ? 1 + : (s[2] == 0) ? 2 + : (s[3] == 0) ? 3 + : (s[4] == 0) ? 4 + : (s[5] == 0) ? 5 + : (s[6] == 0) ? 6 + : (s[7] == 0) ? 7 + : (s[8] == 0) ? 8 + : (s[9] == 0) ? 9 + : (s[10] == 0) ? 10 + : (s[11] == 0) ? 11 + : (s[12] == 0) ? 12 + : (s[13] == 0) ? 13 + : (s[14] == 0) ? 14 + : (s[15] == 0) ? 15 + : (s[16] == 0) ? 16 + : (s[17] == 0) ? 17 + : (s[18] == 0) ? 18 + : (s[19] == 0) ? 19 + : (s[20] == 0) ? 20 + : (s[21] == 0) ? 21 + : (s[22] == 0) ? 22 + : (s[23] == 0) ? 23 + : (s[24] == 0) ? 24 + : (s[25] == 0) ? 25 + : (s[26] == 0) ? 26 + : (s[27] == 0) ? 27 + : (s[28] == 0) ? 28 + : (s[29] == 0) ? 29 + : (s[30] == 0) ? 30 + : (s[31] == 0) ? 31 + : 32; +} + +constexpr int __tex_hash_map(int c) { + return (c == 49) ? 10 + : (c == 50) ? 0 + : (c == 51) ? 100 + : (c == 52) ? 30 + : (c == 67) ? 10 + : (c == 68) ? 0 + : (c == 69) ? 25 + : (c == 72) ? 70 + : (c == 77) ? 0 + : (c == 96) ? 44 + : (c == 99) ? 10 + : (c == 100) ? 5 + : (c == 101) ? 60 + : (c == 102) ? 40 + : (c == 103) ? 70 + : (c == 104) ? 25 + : (c == 112) ? 0 + : (c == 114) ? 45 + : (c == 117) ? 5 + : (c == 118) ? 85 + : (c == 120) ? 20 + : 225; +} + +constexpr int __tex_op_hash(const char *str) { + return __tex_len(str) + __tex_hash_map(str[7] + 1) + __tex_hash_map(str[6]) + + __tex_hash_map(str[5]) + __tex_hash_map(str[__tex_len(str) - 1]); +} + +// Tag type to identify particular texture operation. +template struct __Tag; +#define __ID(__op) __Tag<__tex_op_hash(__op)> +// Tags for variants of particular operation. E.g. tex2Dgather can translate +// into 4 different instructions. +#define __IDV(__op, __variant) \ + __Tag<10000 + __tex_op_hash(__op) * 100 + __variant> + +// Helper classes for figuring out key data types for derived types. +// E.g. char2 has __base_t = char, __fetch_t = char4 +template struct __TypeInfoT; +// Type info for the fundamental types. +template <> struct __TypeInfoT { + using __base_t = float; + using __fetch_t = float4; +}; +template <> struct __TypeInfoT { + using __base_t = char; + using __fetch_t = int4; +}; +template <> struct __TypeInfoT { + using __base_t = signed char; + using __fetch_t = int4; +}; +template <> struct __TypeInfoT { + using __base_t = unsigned char; + using __fetch_t = uint4; +}; +template <> struct __TypeInfoT { + using __base_t = short; + using __fetch_t = int4; +}; +template <> struct __TypeInfoT { + using __base_t = unsigned short; + using __fetch_t = uint4; +}; +template <> struct __TypeInfoT { + using __base_t = int; + using __fetch_t = int4; +}; +template <> struct __TypeInfoT { + using __base_t = unsigned int; + using __fetch_t = uint4; +}; + +// Derived base/fetch types for N-element vectors. +template struct __TypeInfoT { + using __base_t = decltype(__T::x); + using __fetch_t = typename __TypeInfoT<__base_t>::__fetch_t; +}; + +// Tag structs to distinguish operation types +struct __texture_op_tag {}; +struct __surface_op_tag {}; + +// Template specialization to determine operation type based on tag value +template struct __op_type_traits { + using type = __texture_op_tag; +}; + +// Specialize for known surface operation tags +#define __OP_TYPE_SURFACE(__op) \ + template <> struct __op_type_traits<__op> { \ + using type = __surface_op_tag; \ + } + +// Classes that implement specific texture ops. +template struct __tex_fetch_v4; + +// Helper macros to strip parens from a macro argument. +#define __Args(...) __VA_ARGS__ +#define __STRIP_PARENS(__X) __X +#define __L(__X) __STRIP_PARENS(__Args __X) + +// Construct inline assembly output args. +// Results are stored in a temp var __r. +// isResident bool is pointed to by __ir +// Asm args for return values. It's a 4-element vector +#define __ASM_OUT(__t) \ + ("=" __t(__r.x), "=" __t(__r.y), "=" __t(__r.z), "=" __t(__r.w)) +// .. possibly combined with a predicate. +#define __ASM_OUTP(__t) (__L(__ASM_OUT(__t)), "=h"(*__ir)) + +// Implements a single variant of texture fetch instruction. +#define __IMPL_F1(__rt, __dt, __args, __asm_op, __asm_outs, __asm_args) \ + template <> \ + __device__ __rt __run<__dt>(cudaTextureObject_t __obj, __L(__args)) { \ + __rt __r; \ + asm(__asm_op : __L(__asm_outs) : "l"(__obj), __L(__asm_args)); \ + return __r; \ + } + +// Implements texture fetch instructions for int4/uint4/float4 data types. +#define __IMPL_F3(__args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + __IMPL_F1(int4, int4, __args, __asm_op ".s32." __ctype "\t" __asm_op_args, \ + __ASM_OUT("r"), __asm_args) \ + __IMPL_F1(uint4, uint4, __args, __asm_op ".u32." __ctype "\t" __asm_op_args, \ + __ASM_OUT("r"), __asm_args) \ + __IMPL_F1(float4, float4, __args, \ + __asm_op ".f32." __ctype "\t" __asm_op_args, __ASM_OUT("f"), \ + __asm_args) +// Implements 'sparse' texture fetch instructions for int4/uint4/float4 data +// types. Similar to above, but returns a boolean 'isPresent' value in addition +// to texture data, +#define __IMPL_F3S(__args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + __IMPL_F1(int4, int4, __args, __asm_op ".s32." __ctype "\t" __asm_op_args, \ + __ASM_OUTP("r"), __asm_args) \ + __IMPL_F1(uint4, uint4, __args, __asm_op ".u32." __ctype "\t" __asm_op_args, \ + __ASM_OUTP("r"), __asm_args) \ + __IMPL_F1(float4, float4, __args, \ + __asm_op ".f32." __ctype "\t" __asm_op_args, __ASM_OUTP("f"), \ + __asm_args) + +// Similar to F3, but for integer data which is returned as normalized floats. +// Only instantiates fetch functions for int4/uint4. +#define __IMPL_F3N(__args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + __IMPL_F1(float4, int4, __args, __asm_op ".s32." __ctype "\t" __asm_op_args, \ + __ASM_OUT("r"), __asm_args) \ + __IMPL_F1(float4, uint4, __args, \ + __asm_op ".u32." __ctype "\t" __asm_op_args, __ASM_OUT("r"), \ + __asm_args) + +// Instantiates __tex_fetch_v4 with regular fetch functions. +#define __IMPL_S3I(__op, __args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + template <> struct __tex_fetch_v4<__op> { \ + template \ + __device__ static T __run(cudaTextureObject_t __obj, __L(__args)); \ + __IMPL_F3(__args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + } + +// Same, but for sparse ops. Only available on sm_60+ +#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 600) +#define __IMPL_S3SI(__op, __args, __asm_op, __ctype, __asm_op_args, \ + __asm_args) \ + template <> struct __tex_fetch_v4<__op> { \ + template \ + __device__ static T __run(cudaTextureObject_t __obj, __L(__args)); \ + __IMPL_F3S(__args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + } +#else +#define __IMPL_S3SI(__op, __args, __asm_op, __ctype, __asm_op_args, __asm_args) +#endif + +// Same, but for normalized float ops. +#define __IMPL_S3NI(__op, __args, __asm_op, __ctype, __asm_op_args, \ + __asm_args) \ + template <> struct __tex_fetch_v4<__op> { \ + template \ + __device__ static float4 __run(cudaTextureObject_t __obj, __L(__args)); \ + __IMPL_F3N(__args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + } + +// Regular and normalized float ops share a lot of similarities. This macro +// instantiates both variants -- normal for __op and normalized for __opn. +#define __IMPL_SI(__op, __opn, __args, __asm_op, __ctype, __asm_op_args, \ + __asm_args) \ + __IMPL_S3I(__op, __args, __asm_op, __ctype, __asm_op_args, __asm_args); \ + __IMPL_S3NI(__opn, __args, __asm_op, __ctype, __asm_op_args, __asm_args) + +// Convenience macros which converts string literal __op into a __Tag, +#define __IMPL_S3(__op, __args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + __IMPL_S3I(__ID(__op), __args, __asm_op, __ctype, __asm_op_args, __asm_args) +#define __IMPL_S3S(__op, __args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + __IMPL_S3SI(__ID(__op), __args, __asm_op, __ctype, __asm_op_args, __asm_args) +#define __IMPL_S3N(__op, __args, __asm_op, __ctype, __asm_op_args, __asm_args) \ + __IMPL_S3NI(__ID(__op), __args, __asm_op, __ctype, __asm_op_args, __asm_args) +#define __IMPL_S(__op, __opn, __args, __asm_op, __ctype, __asm_op_args, \ + __asm_args) \ + __IMPL_SI(__ID(__op), __ID(__opn), __args, __asm_op, __ctype, __asm_op_args, \ + __asm_args) + +// CUDA headers have some 'legacy' texture oprerations that duplicate +// functionality. So, we just inherit it, instead of refining a copy. +#define __IMPL_ALIASI(__op, __opn) \ + template <> struct __tex_fetch_v4<__op> : __tex_fetch_v4<__opn> {} +#define __IMPL_ALIAS(__op, __opn) __IMPL_ALIASI(__ID(__op), __ID(__opn)) + +// Now we can instantiate everything we need for each specific texture fetch +// variant. +__IMPL_S("__tex1D_v2", "__tex1D_rmnf_v2", (float __x), "tex.1d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5}];", ("f"(__x))); +__IMPL_S("__tex1Dfetch_v2", "__tex1Dfetch_rmnf_v2", (int __x), "tex.1d.v4", + "s32", "{%0, %1, %2, %3}, [%4, {%5}];", ("r"(__x))); +__IMPL_ALIAS("__itex1D", "__tex1D_v2"); +__IMPL_ALIAS("__itex1Dfetch", "__tex1Dfetch_v2"); + +__IMPL_S("__tex1DGrad_v2", "__tex1DGrad_rmnf_v2", + (float __x, float __dPdx, float __dPdy), "tex.grad.1d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5}], {%6}, {%7};", + ("f"(__x), "f"(__dPdx), "f"(__dPdy))); +__IMPL_ALIAS("__itex1DGrad", "__tex1DGrad_v2"); + +__IMPL_S("__tex1DLayered_v2", "__tex1DLayered_rmnf_v2", + (float __x, int __layer), "tex.a1d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6}];", ("r"(__layer), "f"(__x))); +__IMPL_ALIAS("__itex1DLayered", "__tex1DLayered_v2"); + +__IMPL_S("__tex1DLayeredGrad_v2", "__tex1DLayeredGrad_rmnf_v2", + (float __x, int __layer, float __dPdx, float __dPdy), + "tex.grad.a1d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6}], {%7}, {%8};", + ("r"(__layer), "f"(__x), "f"(__dPdx), "f"(__dPdy))); +__IMPL_ALIAS("__itex1DLayeredGrad", "__tex1DLayeredGrad_v2"); + +__IMPL_S("__tex1DLayeredLod_v2", "__tex1DLayeredLod_rmnf_v2", + (float __x, int __layer, float __level), "tex.level.a1d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6}], %7;", + ("r"(__layer), "f"(__x), "f"(__level))); +__IMPL_ALIAS("__itex1DLayeredLod", "__tex1DLayeredLod_v2"); + +__IMPL_S("__tex1DLod_v2", "__tex1DLod_rmnf_v2", (float __x, float __level), + "tex.level.1d.v4", "f32", "{%0, %1, %2, %3}, [%4, {%5}], %6;", + ("f"(__x), "f"(__level))); +__IMPL_ALIAS("__itex1DLod", "__tex1DLod_v2"); + +// 2D +__IMPL_S("__tex2D_v2", "__tex2D_rmnf_v2", (float __x, float __y), "tex.2d.v4", + "f32", "{%0, %1, %2, %3}, [%4, {%5, %6}];", ("f"(__x), "f"(__y))); +__IMPL_ALIAS("__itex2D", "__tex2D_v2"); + +__IMPL_S3S("__itex2D_sparse", (float __x, float __y, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.2d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7}];\n\t" + " selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y))); + +__IMPL_S("__tex2DGrad_v2", "__tex2DGrad_rmnf_v2", + (float __x, float __y, const float2 *__dPdx, const float2 *__dPdy), + "tex.grad.2d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6}], {%7, %8}, {%9, %10};", + ("f"(__x), "f"(__y), "f"(__dPdx->x), "f"(__dPdx->y), "f"(__dPdy->x), + "f"(__dPdy->y))); +__IMPL_ALIAS("__itex2DGrad_v2", "__tex2DGrad_v2"); + +__IMPL_S3S("__itex2DGrad_sparse", + (float __x, float __y, const float2 *__dPdx, const float2 *__dPdy, + unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.grad.2d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7}], {%8, %9}, {%10, %11};\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y), "f"(__dPdx->x), "f"(__dPdx->y), "f"(__dPdy->x), + "f"(__dPdy->y))); + +__IMPL_S("__tex2DLayered_v2", "__tex2DLayered_rmnf_v2", + (float __x, float __y, int __layer), "tex.a2d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}];", + ("r"(__layer), "f"(__x), "f"(__y))); +__IMPL_ALIAS("__itex2DLayered", "__tex2DLayered_v2"); + +__IMPL_S3S("__itex2DLayered_sparse", + (float __x, float __y, int __layer, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.a2d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}];\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("r"(__layer), "f"(__x), "f"(__y))); + +__IMPL_S("__tex2DLayeredGrad_v2", "__tex2DLayeredGrad_rmnf_v2", + (float __x, float __y, int __layer, const float2 *__dPdx, + const float2 *__dPdy), + "tex.grad.a2d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}], {%8, %9}, {%10, %11};", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__dPdx->x), "f"(__dPdx->y), + "f"(__dPdy->x), "f"(__dPdy->y))); +__IMPL_ALIAS("__itex2DLayeredGrad_v2", "__tex2DLayeredGrad_v2"); + +__IMPL_S3S( + "__itex2DLayeredGrad_sparse", + (float __x, float __y, int __layer, const float2 *__dPdx, + const float2 *__dPdy, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.grad.a2d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}], {%9, %10}, {%11, %12};\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__dPdx->x), "f"(__dPdx->y), + "f"(__dPdy->x), "f"(__dPdy->y))); + +__IMPL_S("__tex2DLayeredLod_v2", "__tex2DLayeredLod_rmnf_v2", + (float __x, float __y, int __layer, float __level), "tex.level.a2d.v4", + "f32", "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}], %8;", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__level))); +__IMPL_ALIAS("__itex2DLayeredLod", "__tex2DLayeredLod_v2"); + +__IMPL_S3S("__itex2DLayeredLod_sparse", + (float __x, float __y, int __layer, float __level, + unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.level.a2d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}], %9;\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__level))); + +__IMPL_S("__tex2DLod_v2", "__tex2DLod_rmnf_v2", + (float __x, float __y, float __level), "tex.level.2d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6}], %7;", + ("f"(__x), "f"(__y), "f"(__level))); +__IMPL_ALIAS("__itex2DLod", "__tex2DLod_v2"); + +__IMPL_S3S("__itex2DLod_sparse", + (float __x, float __y, float __level, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.level.2d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7}], %8;\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y), "f"(__level))); + +// 2D gather is special. Unlike other variants that translate into exactly one +// asm instruction, it uses one of the four different instructions selected by +// __comp. We implement each instruction variant separately, and dispatch the +// right one from the manually implemented 'umbrella' fetch. +#define __IMPL_2DGATHER(variant, instr) \ + __IMPL_SI(__IDV("__tex2Dgather_v2", variant), \ + __IDV("__tex2Dgather_rmnf_v2", variant), \ + (float __x, float __y, int __comp), instr, "f32", \ + "{%0, %1, %2, %3}, [%4, {%5, %6}];", ("f"(__x), "f"(__y))); \ + __IMPL_ALIASI(__IDV("__itex2Dgather", variant), \ + __IDV("__tex2Dgather_v2", variant)); \ + __IMPL_S3SI(__IDV("__itex2Dgather_sparse", variant), \ + (float __x, float __y, unsigned char *__ir, int __comp), \ + "{.reg .pred %%p0;\n\t" instr, "f32", \ + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7}];\n\t" \ + "selp.u16 %4, 1, 0, %%p0; }", \ + ("f"(__x), "f"(__y))); +__IMPL_2DGATHER(0, "tld4.r.2d.v4"); +__IMPL_2DGATHER(1, "tld4.g.2d.v4"); +__IMPL_2DGATHER(2, "tld4.b.2d.v4"); +__IMPL_2DGATHER(3, "tld4.a.2d.v4"); + +// Umbrella dispatcher -- calls into specific 2Dgather variant. +template <> struct __tex_fetch_v4<__ID("__tex2Dgather_v2")> { + template + __device__ static __T __run(cudaTextureObject_t __obj, float __x, float __y, + int __comp) { + switch (__comp) { + case 0: + return __tex_fetch_v4<__IDV("__tex2Dgather_v2", 0)>::__run<__T>( + __obj, __x, __y, __comp); + case 1: + return __tex_fetch_v4<__IDV("__tex2Dgather_v2", 1)>::__run<__T>( + __obj, __x, __y, __comp); + case 2: + return __tex_fetch_v4<__IDV("__tex2Dgather_v2", 2)>::__run<__T>( + __obj, __x, __y, __comp); + case 3: + return __tex_fetch_v4<__IDV("__tex2Dgather_v2", 3)>::__run<__T>( + __obj, __x, __y, __comp); + } + } +}; +__IMPL_ALIAS("__itex2Dgather", "__tex2Dgather_v2"); + +template <> struct __tex_fetch_v4<__ID("__tex2Dgather_rmnf_v2")> { + template + __device__ static float4 __run(cudaTextureObject_t __obj, float __x, + float __y, int __comp) { + switch (__comp) { + case 0: + return __tex_fetch_v4<__IDV("__tex2Dgather_rmnf_v2", 0)>::__run<__T>( + __obj, __x, __y, __comp); + case 1: + return __tex_fetch_v4<__IDV("__tex2Dgather_rmnf_v2", 1)>::__run<__T>( + __obj, __x, __y, __comp); + case 2: + return __tex_fetch_v4<__IDV("__tex2Dgather_rmnf_v2", 2)>::__run<__T>( + __obj, __x, __y, __comp); + case 3: + return __tex_fetch_v4<__IDV("__tex2Dgather_rmnf_v2", 3)>::__run<__T>( + __obj, __x, __y, __comp); + } + } +}; + +#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 600) +template <> struct __tex_fetch_v4<__ID("__itex2Dgather_sparse")> { + template + __device__ static __T __run(cudaTextureObject_t __obj, float __x, float __y, + unsigned char *__ir, int __comp) { + switch (__comp) { + case 0: + return __tex_fetch_v4<__IDV("__itex2Dgather_sparse", 0)>::__run<__T>( + __obj, __x, __y, __ir, __comp); + case 1: + return __tex_fetch_v4<__IDV("__itex2Dgather_sparse", 1)>::__run<__T>( + __obj, __x, __y, __ir, __comp); + case 2: + return __tex_fetch_v4<__IDV("__itex2Dgather_sparse", 2)>::__run<__T>( + __obj, __x, __y, __ir, __comp); + case 3: + return __tex_fetch_v4<__IDV("__itex2Dgather_sparse", 3)>::__run<__T>( + __obj, __x, __y, __ir, __comp); + } + } +}; +#endif + +// 3D +__IMPL_S("__tex3D_v2", "__tex3D_rmnf_v2", (float __x, float __y, float __z), + "tex.3d.v4", "f32", "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}];", + ("f"(__x), "f"(__y), "f"(__z))); +__IMPL_ALIAS("__itex3D", "__tex3D_v2"); + +__IMPL_S3S("__itex3D_sparse", + (float __x, float __y, float __z, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.3d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}];\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y), "f"(__z))); + +__IMPL_S("__tex3DGrad_v2", "__tex3DGrad_rmnf_v2", + (float __x, float __y, float __z, const float4 *__dPdx, + const float4 *__dPdy), + "tex.grad.3d.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}], " + "{%8, %9, %10, %10}, {%11, %12, %13, %13};", + ("f"(__x), "f"(__y), "f"(__z), "f"(__dPdx->x), "f"(__dPdx->y), + "f"(__dPdx->z), "f"(__dPdy->x), "f"(__dPdy->y), "f"(__dPdy->z))); +__IMPL_ALIAS("__itex3DGrad_v2", "__tex3DGrad_v2"); + +__IMPL_S3S("__itex3DGrad_sparse", + (float __x, float __y, float __z, const float4 *__dPdx, + const float4 *__dPdy, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.grad.3d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}], " + "{%9, %10, %11, %11}, {%12, %13, %14, %14};\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y), "f"(__z), "f"(__dPdx->x), "f"(__dPdx->y), + "f"(__dPdx->z), "f"(__dPdy->x), "f"(__dPdy->y), "f"(__dPdy->z))); + +__IMPL_S("__tex3DLod_v2", "__tex3DLod_rmnf_v2", + (float __x, float __y, float __z, float __level), "tex.level.3d.v4", + "f32", "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}], %8;", + ("f"(__x), "f"(__y), "f"(__z), "f"(__level))); +__IMPL_ALIAS("__itex3DLod", "__tex3DLod_v2"); + +__IMPL_S3S("__itex3DLod_sparse", + (float __x, float __y, float __z, float __level, + unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.level.3d.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}], %9;\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y), "f"(__z), "f"(__level))); + +// Cubemap +__IMPL_S("__texCubemap_v2", "__texCubemap_rmnf_v2", + (float __x, float __y, float __z), "tex.cube.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}];", + ("f"(__x), "f"(__y), "f"(__z))); +__IMPL_ALIAS("__itexCubemap", "__texCubemap_v2"); + +__IMPL_S3S("__itexCubemap_sparse", + (float __x, float __y, float __z, unsigned char *__ir), + "{.reg .pred %%p0;\n\t" + "tex.cube.v4", + "f32", + "{%0, %1, %2, %3}|%%p0, [%5, {%6, %7, %8, %8}];\n\t" + "selp.u16 %4, 1, 0, %%p0; }", + ("f"(__x), "f"(__y), "f"(__z))); + +__IMPL_S("__texCubemapGrad_v2", "__texCubemapGrad_rmnf_v2", + (float __x, float __y, float __z, const float4 *__dPdx, + const float4 *__dPdy), + "tex.grad.cube.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}], " + "{%8, %9, %10, %10}, {%11, %12, %13, %13};", + ("f"(__x), "f"(__y), "f"(__z), "f"(__dPdx->x), "f"(__dPdx->y), + "f"(__dPdx->z), "f"(__dPdy->x), "f"(__dPdy->y), "f"(__dPdy->z))); +__IMPL_ALIAS("__itexCubemapGrad_v2", "__texCubemapGrad_v2"); + +__IMPL_S("__texCubemapLayered_v2", "__texCubemapLayered_rmnf_v2", + (float __x, float __y, float __z, int __layer), "tex.acube.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %8}];", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__z))); +__IMPL_ALIAS("__itexCubemapLayered", "__texCubemapLayered_v2"); + +__IMPL_S("__texCubemapLayeredGrad_v2", "__texCubemapLayeredGrad_rmnf_v2", + (float __x, float __y, float __z, int __layer, const float4 *__dPdx, + const float4 *__dPdy), + "tex.grad.acube.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %8}], " + "{%9, %10, %11, %11}, {%12, %13, %14, %14};", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__z), "f"(__dPdx->x), + "f"(__dPdx->y), "f"(__dPdx->z), "f"(__dPdy->x), "f"(__dPdy->y), + "f"(__dPdy->z))); +__IMPL_ALIAS("__itexCubemapLayeredGrad_v2", "__texCubemapLayeredGrad_v2"); + +__IMPL_S("__texCubemapLayeredLod_v2", "__texCubemapLayeredLod_rmnf_v2", + (float __x, float __y, float __z, int __layer, float __level), + "tex.level.acube.v4", "f32", + "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %8}], %9;", + ("r"(__layer), "f"(__x), "f"(__y), "f"(__z), "f"(__level))); +__IMPL_ALIAS("__itexCubemapLayeredLod", "__texCubemapLayeredLod_v2"); + +__IMPL_S("__texCubemapLod_v2", "__texCubemapLod_rmnf_v2", + (float __x, float __y, float __z, float __level), "tex.level.cube.v4", + "f32", "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}], %8;", + ("f"(__x), "f"(__y), "f"(__z), "f"(__level))); +__IMPL_ALIAS("__itexCubemapLod", "__texCubemapLod_v2"); + +// Helper class for extracting slice of data from V4 fetch results. +template struct __convert { + template ::__base_t)> + __device__ static __DestT __run(__SrcT __v); + template <> __device__ static __DestT __run<1>(__SrcT __v) { return {__v.x}; } + template <> __device__ static __DestT __run<2>(__SrcT __v) { + return {__v.x, __v.y}; + } + template <> __device__ static __DestT __run<3>(__SrcT __v) { + return {__v.x, __v.y, __v.z}; + } + template <> __device__ static __DestT __run<4>(__SrcT __v) { + return {__v.x, __v.y, __v.z, __v.w}; + } +}; + +// There are a couple of layers here. First, __op_type_traits is used to +// dispatch to either surface write calls, or to the texture read calls. +// +// Then, that dispatches to __tex_fetch_impl below, which dispatches by both tag +// and datatype to the appropriate +// __surf_read_write_v2. +// TODO(austin): Do the reads too. + +// Mark which of the ids we should be dispatching to surface write calls. +__OP_TYPE_SURFACE(__ID("__isurf1Dread")); +__OP_TYPE_SURFACE(__ID("__isurf2Dread")); +__OP_TYPE_SURFACE(__ID("__isurf3Dread")); +__OP_TYPE_SURFACE(__ID("__isurf1DLayeredread")); +__OP_TYPE_SURFACE(__ID("__isurf2DLayeredread")); +__OP_TYPE_SURFACE(__ID("__isurfCubemapread")); +__OP_TYPE_SURFACE(__ID("__isurfCubemapLayeredread")); +__OP_TYPE_SURFACE(__ID("__isurf1Dwrite_v2")); +__OP_TYPE_SURFACE(__ID("__isurf2Dwrite_v2")); +__OP_TYPE_SURFACE(__ID("__isurf3Dwrite_v2")); +__OP_TYPE_SURFACE(__ID("__isurf1DLayeredwrite_v2")); +__OP_TYPE_SURFACE(__ID("__isurf2DLayeredwrite_v2")); +__OP_TYPE_SURFACE(__ID("__isurfCubemapwrite_v2")); +__OP_TYPE_SURFACE(__ID("__isurfCubemapLayeredwrite_v2")); + +template struct __surf_read_write_v2; + +// For the various write calls, we need to be able to generate variations with +// different IDs, different numbers of arguments, and different numbers of +// outputs. + +#define __SURF_WRITE_V2(__op, __asm_dim, __asmtype, __type, __index_op_args, \ + __index_args, __index_asm_args, __asm_op_args, \ + __asm_args) \ + template <> struct __surf_read_write_v2<__op, __type> { \ + static __device__ void __run(__type *__ptr, cudaSurfaceObject_t obj, \ + __L(__index_args), \ + cudaSurfaceBoundaryMode mode) { \ + switch (mode) { \ + case cudaBoundaryModeZero: \ + asm volatile("sust.b." __asm_dim "." __asmtype \ + ".zero [%0, " __index_op_args "], " __asm_op_args ";" \ + : \ + : "l"(obj), __L(__index_asm_args), __L(__asm_args)); \ + break; \ + case cudaBoundaryModeClamp: \ + asm volatile("sust.b." __asm_dim "." __asmtype \ + ".clamp [%0, " __index_op_args "], " __asm_op_args ";" \ + : \ + : "l"(obj), __L(__index_asm_args), __L(__asm_args)); \ + break; \ + case cudaBoundaryModeTrap: \ + asm volatile("sust.b." __asm_dim "." __asmtype \ + ".trap [%0, " __index_op_args "], " __asm_op_args ";" \ + : \ + : "l"(obj), __L(__index_asm_args), __L(__asm_args)); \ + break; \ + } \ + } \ + } + +#define __SURF_READ_V2(__op, __asm_dim, __asmtype, __type, __asm_op_args, \ + __asm_args, __index_args, __index_asm_args) \ + template <> struct __surf_read_write_v2<__op, __type> { \ + static __device__ void __run(__type *__ptr, cudaSurfaceObject_t obj, \ + __L(__index_args), \ + cudaSurfaceBoundaryMode mode) { \ + switch (mode) { \ + case cudaBoundaryModeZero: \ + asm("suld.b." __asm_dim "." __asmtype ".zero " __asm_op_args ";" \ + : __L(__asm_args) \ + : "l"(obj), __L(__index_asm_args)); \ + break; \ + case cudaBoundaryModeClamp: \ + asm("suld.b." __asm_dim "." __asmtype ".clamp " __asm_op_args ";" \ + : __L(__asm_args) \ + : "l"(obj), __L(__index_asm_args)); \ + break; \ + case cudaBoundaryModeTrap: \ + asm("suld.b." __asm_dim "." __asmtype ".trap " __asm_op_args ";" \ + : __L(__asm_args) \ + : "l"(obj), __L(__index_asm_args)); \ + break; \ + } \ + } \ + } + +// Amazing, the read side should follow the same flow, I just need to change the +// generated assembly calls, and the rest should fall in line. + +#define __SW_ASM_ARGS(__type) (__type(*__ptr)) +#define __SW_ASM_ARGS1(__type) (__type(__ptr->x)) +#define __SW_ASM_ARGS2(__type) (__type(__ptr->x), __type(__ptr->y)) +#define __SW_ASM_ARGS4(__type) \ + (__type(__ptr->x), __type(__ptr->y), __type(__ptr->z), __type(__ptr->w)) + +#define __SURF_READ1D(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_READ_V2(__ID("__isurf1Dread"), "1d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x), ("r"(x))) +#define __SURF_READ2D(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_READ_V2(__ID("__isurf2Dread"), "2d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x, int y), ("r"(x), "r"(y))) +#define __SURF_READ3D(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_READ_V2(__ID("__isurf3Dread"), "3d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x, int y, int z), \ + ("r"(x), "r"(y), "r"(z))) + +#define __SURF_READ1DLAYERED(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_READ_V2(__ID("__isurf1DLayeredread"), "a1d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x, int layer), \ + ("r"(x), "r"(layer))) +#define __SURF_READ2DLAYERED(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_READ_V2(__ID("__isurf2DLayeredread"), "a2d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x, int y, int layer), \ + ("r"(x), "r"(y), "r"(layer))) +#define __SURF_READCUBEMAP(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_READ_V2(__ID("__isurfCubemapread"), "a2d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x, int y, int face), \ + ("r"(x), "r"(y), "r"(face))) +#define __SURF_READCUBEMAPLAYERED(__asmtype, __type, __asm_op_args, \ + __asm_args) \ + __SURF_READ_V2(__ID("__isurfCubemapLayeredread"), "a2d", __asmtype, __type, \ + __asm_op_args, __asm_args, (int x, int y, int layerface), \ + ("r"(x), "r"(y), "r"(layerface))) + +#define __1DV1 "{%0}, [%1, {%2}]" +#define __1DV2 "{%0, %1}, [%2, {%3}]" +#define __1DV4 "{%0, %1, %2, %3}, [%4, {%5}]" + +#define __2DV1 "{%0}, [%1, {%2, %3}]" +#define __2DV2 "{%0, %1}, [%2, {%3, %4}]" +#define __2DV4 "{%0, %1, %2, %3}, [%4, {%5, %6}]" + +#define __1DLAYERV1 "{%0}, [%1, {%3, %2}]" +#define __1DLAYERV2 "{%0, %1}, [%2, {%4, %3}]" +#define __1DLAYERV4 "{%0, %1, %2, %3}, [%4, {%6, %5}]" + +#define __3DV1 "{%0}, [%1, {%2, %3, %4, %4}]" +#define __3DV2 "{%0, %1}, [%2, {%3, %4, %5, %5}]" +#define __3DV4 "{%0, %1, %2, %3}, [%4, {%5, %6, %7, %7}]" + +#define __2DLAYERV1 "{%0}, [%1, {%4, %2, %3, %3}]" +#define __2DLAYERV2 "{%0, %1}, [%2, {%5, %3, %4, %4}]" +#define __2DLAYERV4 "{%0, %1, %2, %3}, [%4, {%7, %5, %6, %6}]" + +#define __CUBEMAPV1 "{%0}, [%1, {%4, %2, %3, %3}]" +#define __CUBEMAPV2 "{%0, %1}, [%2, {%5, %3, %4, %4}]" +#define __CUBEMAPV4 "{%0, %1, %2, %3}, [%4, {%7, %5, %6, %6}]" + +#define __CUBEMAPLAYERV1 "{%0}, [%1, {%4, %2, %3, %3}]" +#define __CUBEMAPLAYERV2 "{%0, %1}, [%2, {%5, %3, %4, %4}]" +#define __CUBEMAPLAYERV4 "{%0, %1, %2, %3}, [%4, {%7, %5, %6, %6}]" + +#define __SURF_READXD_ALL(__xdv1, __xdv2, __xdv4, __surf_readxd_v2) \ + __surf_readxd_v2("b8", char, __xdv1, __SW_ASM_ARGS("=h")); \ + __surf_readxd_v2("b8", signed char, __xdv1, __SW_ASM_ARGS("=h")); \ + __surf_readxd_v2("b8", char1, __xdv1, __SW_ASM_ARGS1("=h")); \ + __surf_readxd_v2("b8", unsigned char, __xdv1, __SW_ASM_ARGS("=h")); \ + __surf_readxd_v2("b8", uchar1, __xdv1, __SW_ASM_ARGS1("=h")); \ + __surf_readxd_v2("b16", short, __xdv1, __SW_ASM_ARGS("=h")); \ + __surf_readxd_v2("b16", short1, __xdv1, __SW_ASM_ARGS1("=h")); \ + __surf_readxd_v2("b16", unsigned short, __xdv1, __SW_ASM_ARGS("=h")); \ + __surf_readxd_v2("b16", ushort1, __xdv1, __SW_ASM_ARGS1("=h")); \ + __surf_readxd_v2("b32", int, __xdv1, __SW_ASM_ARGS("=r")); \ + __surf_readxd_v2("b32", int1, __xdv1, __SW_ASM_ARGS1("=r")); \ + __surf_readxd_v2("b32", unsigned int, __xdv1, __SW_ASM_ARGS("=r")); \ + __surf_readxd_v2("b32", uint1, __xdv1, __SW_ASM_ARGS1("=r")); \ + __surf_readxd_v2("b64", long long, __xdv1, __SW_ASM_ARGS("=l")); \ + __surf_readxd_v2("b64", longlong1, __xdv1, __SW_ASM_ARGS1("=l")); \ + __surf_readxd_v2("b64", unsigned long long, __xdv1, __SW_ASM_ARGS("=l")); \ + __surf_readxd_v2("b64", ulonglong1, __xdv1, __SW_ASM_ARGS1("=l")); \ + __surf_readxd_v2("b32", float, __xdv1, __SW_ASM_ARGS("=r")); \ + __surf_readxd_v2("b32", float1, __xdv1, __SW_ASM_ARGS1("=r")); \ + \ + __surf_readxd_v2("v2.b8", char2, __xdv2, __SW_ASM_ARGS2("=h")); \ + __surf_readxd_v2("v2.b8", uchar2, __xdv2, __SW_ASM_ARGS2("=h")); \ + __surf_readxd_v2("v2.b16", short2, __xdv2, __SW_ASM_ARGS2("=h")); \ + __surf_readxd_v2("v2.b16", ushort2, __xdv2, __SW_ASM_ARGS2("=h")); \ + __surf_readxd_v2("v2.b32", int2, __xdv2, __SW_ASM_ARGS2("=r")); \ + __surf_readxd_v2("v2.b32", uint2, __xdv2, __SW_ASM_ARGS2("=r")); \ + __surf_readxd_v2("v2.b64", longlong2, __xdv2, __SW_ASM_ARGS2("=l")); \ + __surf_readxd_v2("v2.b64", ulonglong2, __xdv2, __SW_ASM_ARGS2("=l")); \ + __surf_readxd_v2("v2.b32", float2, __xdv2, __SW_ASM_ARGS2("=r")); \ + \ + __surf_readxd_v2("v4.b8", char4, __xdv4, __SW_ASM_ARGS4("=h")); \ + __surf_readxd_v2("v4.b8", uchar4, __xdv4, __SW_ASM_ARGS4("=h")); \ + __surf_readxd_v2("v4.b16", short4, __xdv4, __SW_ASM_ARGS4("=h")); \ + __surf_readxd_v2("v4.b16", ushort4, __xdv4, __SW_ASM_ARGS4("=h")); \ + __surf_readxd_v2("v4.b32", int4, __xdv4, __SW_ASM_ARGS4("=r")); \ + __surf_readxd_v2("v4.b32", uint4, __xdv4, __SW_ASM_ARGS4("=r")); \ + __surf_readxd_v2("v4.b32", float4, __xdv4, __SW_ASM_ARGS4("=r")) + +__SURF_READXD_ALL(__1DV1, __1DV2, __1DV4, __SURF_READ1D); +__SURF_READXD_ALL(__2DV1, __2DV2, __2DV4, __SURF_READ2D); +__SURF_READXD_ALL(__3DV1, __3DV2, __3DV4, __SURF_READ3D); +__SURF_READXD_ALL(__1DLAYERV1, __1DLAYERV2, __1DLAYERV4, __SURF_READ1DLAYERED); +__SURF_READXD_ALL(__2DLAYERV1, __2DLAYERV2, __2DLAYERV4, __SURF_READ2DLAYERED); +__SURF_READXD_ALL(__CUBEMAPV1, __CUBEMAPV2, __CUBEMAPV4, __SURF_READCUBEMAP); +__SURF_READXD_ALL(__CUBEMAPLAYERV1, __CUBEMAPLAYERV2, __CUBEMAPLAYERV4, + __SURF_READCUBEMAPLAYERED); + +#define __SURF_WRITE1D_V2(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_WRITE_V2(__ID("__isurf1Dwrite_v2"), "1d", __asmtype, __type, "{%1}", \ + (int x), ("r"(x)), __asm_op_args, __asm_args) +#define __SURF_WRITE1DLAYERED_V2(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_WRITE_V2(__ID("__isurf1DLayeredwrite_v2"), "a1d", __asmtype, __type, \ + "{%2, %1}", (int x, int layer), ("r"(x), "r"(layer)), \ + __asm_op_args, __asm_args) +#define __SURF_WRITE2D_V2(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_WRITE_V2(__ID("__isurf2Dwrite_v2"), "2d", __asmtype, __type, \ + "{%1, %2}", (int x, int y), ("r"(x), "r"(y)), __asm_op_args, \ + __asm_args) +#define __SURF_WRITE2DLAYERED_V2(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_WRITE_V2(__ID("__isurf2DLayeredwrite_v2"), "a2d", __asmtype, __type, \ + "{%3, %1, %2, %2}", (int x, int y, int layer), \ + ("r"(x), "r"(y), "r"(layer)), __asm_op_args, __asm_args) +#define __SURF_WRITE3D_V2(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_WRITE_V2(__ID("__isurf3Dwrite_v2"), "3d", __asmtype, __type, \ + "{%1, %2, %3, %3}", (int x, int y, int z), \ + ("r"(x), "r"(y), "r"(z)), __asm_op_args, __asm_args) + +#define __SURF_CUBEMAPWRITE_V2(__asmtype, __type, __asm_op_args, __asm_args) \ + __SURF_WRITE_V2(__ID("__isurfCubemapwrite_v2"), "a2d", __asmtype, __type, \ + "{%3, %1, %2, %2}", (int x, int y, int face), \ + ("r"(x), "r"(y), "r"(face)), __asm_op_args, __asm_args) +#define __SURF_CUBEMAPLAYEREDWRITE_V2(__asmtype, __type, __asm_op_args, \ + __asm_args) \ + __SURF_WRITE_V2(__ID("__isurfCubemapLayeredwrite_v2"), "a2d", __asmtype, \ + __type, "{%3, %1, %2, %2}", (int x, int y, int layerface), \ + ("r"(x), "r"(y), "r"(layerface)), __asm_op_args, __asm_args) + +#define __SURF_WRITEXD_V2_ALL(__xdv1, __xdv2, __xdv4, __surf_writexd_v2) \ + __surf_writexd_v2("b8", char, __xdv1, __SW_ASM_ARGS("h")); \ + __surf_writexd_v2("b8", signed char, __xdv1, __SW_ASM_ARGS("h")); \ + __surf_writexd_v2("b8", char1, __xdv1, __SW_ASM_ARGS1("h")); \ + __surf_writexd_v2("b8", unsigned char, __xdv1, __SW_ASM_ARGS("h")); \ + __surf_writexd_v2("b8", uchar1, __xdv1, __SW_ASM_ARGS1("h")); \ + __surf_writexd_v2("b16", short, __xdv1, __SW_ASM_ARGS("h")); \ + __surf_writexd_v2("b16", short1, __xdv1, __SW_ASM_ARGS1("h")); \ + __surf_writexd_v2("b16", unsigned short, __xdv1, __SW_ASM_ARGS("h")); \ + __surf_writexd_v2("b16", ushort1, __xdv1, __SW_ASM_ARGS1("h")); \ + __surf_writexd_v2("b32", int, __xdv1, __SW_ASM_ARGS("r")); \ + __surf_writexd_v2("b32", int1, __xdv1, __SW_ASM_ARGS1("r")); \ + __surf_writexd_v2("b32", unsigned int, __xdv1, __SW_ASM_ARGS("r")); \ + __surf_writexd_v2("b32", uint1, __xdv1, __SW_ASM_ARGS1("r")); \ + __surf_writexd_v2("b64", long long, __xdv1, __SW_ASM_ARGS("l")); \ + __surf_writexd_v2("b64", longlong1, __xdv1, __SW_ASM_ARGS1("l")); \ + __surf_writexd_v2("b64", unsigned long long, __xdv1, __SW_ASM_ARGS("l")); \ + __surf_writexd_v2("b64", ulonglong1, __xdv1, __SW_ASM_ARGS1("l")); \ + __surf_writexd_v2("b32", float, __xdv1, __SW_ASM_ARGS("r")); \ + __surf_writexd_v2("b32", float1, __xdv1, __SW_ASM_ARGS1("r")); \ + \ + __surf_writexd_v2("v2.b8", char2, __xdv2, __SW_ASM_ARGS2("h")); \ + __surf_writexd_v2("v2.b8", uchar2, __xdv2, __SW_ASM_ARGS2("h")); \ + __surf_writexd_v2("v2.b16", short2, __xdv2, __SW_ASM_ARGS2("h")); \ + __surf_writexd_v2("v2.b16", ushort2, __xdv2, __SW_ASM_ARGS2("h")); \ + __surf_writexd_v2("v2.b32", int2, __xdv2, __SW_ASM_ARGS2("r")); \ + __surf_writexd_v2("v2.b32", uint2, __xdv2, __SW_ASM_ARGS2("r")); \ + __surf_writexd_v2("v2.b64", longlong2, __xdv2, __SW_ASM_ARGS2("l")); \ + __surf_writexd_v2("v2.b64", ulonglong2, __xdv2, __SW_ASM_ARGS2("l")); \ + __surf_writexd_v2("v2.b32", float2, __xdv2, __SW_ASM_ARGS2("r")); \ + \ + __surf_writexd_v2("v4.b8", char4, __xdv4, __SW_ASM_ARGS4("h")); \ + __surf_writexd_v2("v4.b8", uchar4, __xdv4, __SW_ASM_ARGS4("h")); \ + __surf_writexd_v2("v4.b16", short4, __xdv4, __SW_ASM_ARGS4("h")); \ + __surf_writexd_v2("v4.b16", ushort4, __xdv4, __SW_ASM_ARGS4("h")); \ + __surf_writexd_v2("v4.b32", int4, __xdv4, __SW_ASM_ARGS4("r")); \ + __surf_writexd_v2("v4.b32", uint4, __xdv4, __SW_ASM_ARGS4("r")); \ + __surf_writexd_v2("v4.b32", float4, __xdv4, __SW_ASM_ARGS4("r")) + +#define __1DV1 "{%2}" +#define __1DV2 "{%2, %3}" +#define __1DV4 "{%2, %3, %4, %5}" + +#define __2DV1 "{%3}" +#define __2DV2 "{%3, %4}" +#define __2DV4 "{%3, %4, %5, %6}" + +#define __3DV1 "{%4}" +#define __3DV2 "{%4, %5}" +#define __3DV4 "{%4, %5, %6, %7}" + +__SURF_WRITEXD_V2_ALL(__1DV1, __1DV2, __1DV4, __SURF_WRITE1D_V2); +__SURF_WRITEXD_V2_ALL(__2DV1, __2DV2, __2DV4, __SURF_WRITE2D_V2); +__SURF_WRITEXD_V2_ALL(__3DV1, __3DV2, __3DV4, __SURF_WRITE3D_V2); +__SURF_WRITEXD_V2_ALL(__2DV1, __2DV2, __2DV4, __SURF_WRITE1DLAYERED_V2); +__SURF_WRITEXD_V2_ALL(__3DV1, __3DV2, __3DV4, __SURF_WRITE2DLAYERED_V2); +__SURF_WRITEXD_V2_ALL(__3DV1, __3DV2, __3DV4, __SURF_CUBEMAPWRITE_V2); +__SURF_WRITEXD_V2_ALL(__3DV1, __3DV2, __3DV4, __SURF_CUBEMAPLAYEREDWRITE_V2); + +template +__device__ static void __tex_fetch_impl(__surface_op_tag, __DataT *__ptr, + cudaSurfaceObject_t __handle, + __Args... __args) { + __surf_read_write_v2<__op, __DataT>::__run(__ptr, __handle, __args...); +} + +// These are the top-level function overloads the __nv_tex_surf_handler expands +// to. Each overload deals with one of the several ways __nv_tex_surf_handler +// is called by CUDA headers. In the end, each of the overloads does the same +// job -- it figures out which `__tex_fetch_v4::run` variant should be used to +// fetch texture data and which `__convert::run` is needed to convert it into +// appropriate return type. + +// __nv_tex_surf_handler("__tex...", &ret, cudaTextureObject_t handle, args...); +// Data type and return type are based on ret. +template +__device__ static void __tex_fetch_impl(__texture_op_tag, __T *__ptr, + cudaTextureObject_t __handle, + __Args... __args) { + using __FetchT = typename __TypeInfoT<__T>::__fetch_t; + *__ptr = __convert<__T, __FetchT>::__run( + __tex_fetch_v4<__op>::template __run<__FetchT>(__handle, __args...)); +} + +template +__device__ static void __tex_fetch(__T *__ptr, cudaTextureObject_t __handle, + __Args... __args) { + using op_type = typename __op_type_traits<__op>::type; + __tex_fetch_impl<__op>(op_type{}, __ptr, __handle, __args...); +} + +#if CUDA_VERSION < 12000 +// texture<> objects get magically converted into a texture reference. However, +// there's no way to convert them to cudaTextureObject_t on C++ level. So, we +// cheat a bit and use inline assembly to do it. It costs us an extra register +// and a move, but that is easy for ptxas to optimize away. +template +__device__ cudaTextureObject_t __tex_handle_to_obj(__T __handle) { + cudaTextureObject_t __obj; + asm("mov.b64 %0, %1; " : "=l"(__obj) : "l"(__handle)); + return __obj; +} + +// __nv_tex_surf_handler ("__tex...", &ret, textureReference, args...); +// Data type and return type is based on ret. +template +__device__ static void __tex_fetch(__T *__ptr, __HandleT __handle, + __Args... __args) { + using __FetchT = typename __TypeInfoT<__T>::__fetch_t; + *__ptr = __convert<__T, __FetchT>::__run( + __tex_fetch_v4<__op>::template __run<__FetchT>( + __tex_handle_to_obj(__handle), __args...)); +} + +// __nv_tex_surf_handler ("__tex...", &type_dummy, &ret, texture<...>, args...); +// cudaReadModeNormalizedFloat fetches always return float4. +template +__device__ static void +__tex_fetch(__DataT *, __RetT *__ptr, + texture<__DataT, __TexT, cudaReadModeNormalizedFloat> __handle, + __Args... __args) { + using __FetchT = typename __TypeInfoT<__DataT>::__fetch_t; + *__ptr = __convert<__RetT, float4>::__run( + __tex_fetch_v4<__op>::template __run<__FetchT>( + __tex_handle_to_obj(__handle), __args...)); +} + +// __nv_tex_surf_handler ("__tex...", &type_dummy, &ret, texture<...>, args...); +// For cudaReadModeElementType fetch return type is based on type_dummy. +template +__device__ static void +__tex_fetch(__DataT *, __RetT *__ptr, + texture<__DataT, __TexT, cudaReadModeElementType> __handle, + __Args... __args) { + using __FetchT = typename __TypeInfoT<__DataT>::__fetch_t; + *__ptr = __convert<__RetT, __FetchT>::__run( + __tex_fetch_v4<__op>::template __run<__FetchT>( + __tex_handle_to_obj(__handle), __args...)); +} +#endif // CUDA_VERSION +} // namespace __cuda_tex +} // namespace +#pragma pop_macro("__ASM_OUT") +#pragma pop_macro("__ASM_OUTP") +#pragma pop_macro("__Args") +#pragma pop_macro("__ID") +#pragma pop_macro("__IDV") +#pragma pop_macro("__OP_TYPE_SURFACE") +#pragma pop_macro("__IMPL_2DGATHER") +#pragma pop_macro("__IMPL_ALIAS") +#pragma pop_macro("__IMPL_ALIASI") +#pragma pop_macro("__IMPL_F1") +#pragma pop_macro("__IMPL_F3") +#pragma pop_macro("__IMPL_F3N") +#pragma pop_macro("__IMPL_F3S") +#pragma pop_macro("__IMPL_S") +#pragma pop_macro("__IMPL_S3") +#pragma pop_macro("__IMPL_S3I") +#pragma pop_macro("__IMPL_S3N") +#pragma pop_macro("__IMPL_S3NI") +#pragma pop_macro("__IMPL_S3S") +#pragma pop_macro("__IMPL_S3SI") +#pragma pop_macro("__IMPL_SI") +#pragma pop_macro("__L") +#pragma pop_macro("__STRIP_PARENS") +#pragma pop_macro("__SURF_WRITE_V2") +#pragma pop_macro("__SW_ASM_ARGS") +#pragma pop_macro("__SW_ASM_ARGS1") +#pragma pop_macro("__SW_ASM_ARGS2") +#pragma pop_macro("__SW_ASM_ARGS4") +#pragma pop_macro("__SURF_WRITE_V2") +#pragma pop_macro("__SURF_READ_V2") +#pragma pop_macro("__SW_ASM_ARGS") +#pragma pop_macro("__SW_ASM_ARGS1") +#pragma pop_macro("__SW_ASM_ARGS2") +#pragma pop_macro("__SW_ASM_ARGS4") +#pragma pop_macro("__SURF_READ1D"); +#pragma pop_macro("__SURF_READ2D"); +#pragma pop_macro("__SURF_READ3D"); +#pragma pop_macro("__SURF_READ1DLAYERED"); +#pragma pop_macro("__SURF_READ2DLAYERED"); +#pragma pop_macro("__SURF_READCUBEMAP"); +#pragma pop_macro("__SURF_READCUBEMAPLAYERED"); +#pragma pop_macro("__1DV1"); +#pragma pop_macro("__1DV2"); +#pragma pop_macro("__1DV4"); +#pragma pop_macro("__2DV1"); +#pragma pop_macro("__2DV2"); +#pragma pop_macro("__2DV4"); +#pragma pop_macro("__1DLAYERV1"); +#pragma pop_macro("__1DLAYERV2"); +#pragma pop_macro("__1DLAYERV4"); +#pragma pop_macro("__3DV1"); +#pragma pop_macro("__3DV2"); +#pragma pop_macro("__3DV4"); +#pragma pop_macro("__2DLAYERV1"); +#pragma pop_macro("__2DLAYERV2"); +#pragma pop_macro("__2DLAYERV4"); +#pragma pop_macro("__CUBEMAPV1"); +#pragma pop_macro("__CUBEMAPV2"); +#pragma pop_macro("__CUBEMAPV4"); +#pragma pop_macro("__CUBEMAPLAYERV1"); +#pragma pop_macro("__CUBEMAPLAYERV2"); +#pragma pop_macro("__CUBEMAPLAYERV4"); +#pragma pop_macro("__SURF_READXD_ALL"); +#pragma pop_macro("__SURF_WRITE1D_V2"); +#pragma pop_macro("__SURF_WRITE1DLAYERED_V2"); +#pragma pop_macro("__SURF_WRITE2D_V2"); +#pragma pop_macro("__SURF_WRITE2DLAYERED_V2"); +#pragma pop_macro("__SURF_WRITE3D_V2"); +#pragma pop_macro("__SURF_CUBEMAPWRITE_V2"); +#pragma pop_macro("__SURF_CUBEMAPLAYEREDWRITE_V2"); +#pragma pop_macro("__SURF_WRITEXD_V2_ALL"); +#pragma pop_macro("__1DV1"); +#pragma pop_macro("__1DV2"); +#pragma pop_macro("__1DV4"); +#pragma pop_macro("__2DV1"); +#pragma pop_macro("__2DV2"); +#pragma pop_macro("__2DV4"); +#pragma pop_macro("__3DV1"); +#pragma pop_macro("__3DV2"); +#pragma pop_macro("__3DV4"); +#endif // __CLANG_CUDA_TEXTURE_INTRINSICS_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_cmath.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_cmath.h new file mode 100755 index 0000000..8dbde42 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_cmath.h @@ -0,0 +1,848 @@ +/*===---- __clang_hip_cmath.h - HIP cmath decls -----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_HIP_CMATH_H__ +#define __CLANG_HIP_CMATH_H__ + +#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__) +#error "This file is for HIP and OpenMP AMDGCN device compilation only." +#endif + +#if !defined(__HIPCC_RTC__) +#if defined(__cplusplus) +#include +#include +#include +#endif +#include +#include +#endif // !defined(__HIPCC_RTC__) + +#pragma push_macro("__DEVICE__") +#pragma push_macro("__CONSTEXPR__") +#ifdef __OPENMP_AMDGCN__ +#define __DEVICE__ static __attribute__((always_inline, nothrow)) +#define __CONSTEXPR__ constexpr +#else +#define __DEVICE__ static __device__ inline __attribute__((always_inline)) +#define __CONSTEXPR__ +#endif // __OPENMP_AMDGCN__ + +// Start with functions that cannot be defined by DEF macros below. +#if defined(__cplusplus) +#if defined __OPENMP_AMDGCN__ +__DEVICE__ __CONSTEXPR__ float fabs(float __x) { return ::fabsf(__x); } +__DEVICE__ __CONSTEXPR__ float sin(float __x) { return ::sinf(__x); } +__DEVICE__ __CONSTEXPR__ float cos(float __x) { return ::cosf(__x); } +#endif +__DEVICE__ __CONSTEXPR__ double abs(double __x) { return ::fabs(__x); } +__DEVICE__ __CONSTEXPR__ float abs(float __x) { return ::fabsf(__x); } +__DEVICE__ __CONSTEXPR__ long long abs(long long __n) { return ::llabs(__n); } +__DEVICE__ __CONSTEXPR__ long abs(long __n) { return ::labs(__n); } +__DEVICE__ __CONSTEXPR__ float fma(float __x, float __y, float __z) { + return ::fmaf(__x, __y, __z); +} +#if !defined(__HIPCC_RTC__) +// The value returned by fpclassify is platform dependent, therefore it is not +// supported by hipRTC. +__DEVICE__ __CONSTEXPR__ int fpclassify(float __x) { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, + FP_ZERO, __x); +} +__DEVICE__ __CONSTEXPR__ int fpclassify(double __x) { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, + FP_ZERO, __x); +} +#endif // !defined(__HIPCC_RTC__) + +__DEVICE__ __CONSTEXPR__ float frexp(float __arg, int *__exp) { + return ::frexpf(__arg, __exp); +} + +#if defined(__OPENMP_AMDGCN__) +// For OpenMP we work around some old system headers that have non-conforming +// `isinf(float)` and `isnan(float)` implementations that return an `int`. We do +// this by providing two versions of these functions, differing only in the +// return type. To avoid conflicting definitions we disable implicit base +// function generation. That means we will end up with two specializations, one +// per type, but only one has a base function defined by the system header. +#pragma omp begin declare variant match( \ + implementation = {extension(disable_implicit_base)}) + +// FIXME: We lack an extension to customize the mangling of the variants, e.g., +// add a suffix. This means we would clash with the names of the variants +// (note that we do not create implicit base functions here). To avoid +// this clash we add a new trait to some of them that is always true +// (this is LLVM after all ;)). It will only influence the mangled name +// of the variants inside the inner region and avoid the clash. +#pragma omp begin declare variant match(implementation = {vendor(llvm)}) + +__DEVICE__ __CONSTEXPR__ int isinf(float __x) { return ::__isinff(__x); } +__DEVICE__ __CONSTEXPR__ int isinf(double __x) { return ::__isinf(__x); } +__DEVICE__ __CONSTEXPR__ int isfinite(float __x) { return ::__finitef(__x); } +__DEVICE__ __CONSTEXPR__ int isfinite(double __x) { return ::__finite(__x); } +__DEVICE__ __CONSTEXPR__ int isnan(float __x) { return ::__isnanf(__x); } +__DEVICE__ __CONSTEXPR__ int isnan(double __x) { return ::__isnan(__x); } + +#pragma omp end declare variant +#endif // defined(__OPENMP_AMDGCN__) + +__DEVICE__ __CONSTEXPR__ bool isinf(float __x) { return ::__isinff(__x); } +__DEVICE__ __CONSTEXPR__ bool isinf(double __x) { return ::__isinf(__x); } +__DEVICE__ __CONSTEXPR__ bool isfinite(float __x) { return ::__finitef(__x); } +__DEVICE__ __CONSTEXPR__ bool isfinite(double __x) { return ::__finite(__x); } +__DEVICE__ __CONSTEXPR__ bool isnan(float __x) { return ::__isnanf(__x); } +__DEVICE__ __CONSTEXPR__ bool isnan(double __x) { return ::__isnan(__x); } + +#if defined(__OPENMP_AMDGCN__) +#pragma omp end declare variant +#endif // defined(__OPENMP_AMDGCN__) + +__DEVICE__ __CONSTEXPR__ bool isgreater(float __x, float __y) { + return __builtin_isgreater(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isgreater(double __x, double __y) { + return __builtin_isgreater(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isgreaterequal(float __x, float __y) { + return __builtin_isgreaterequal(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isgreaterequal(double __x, double __y) { + return __builtin_isgreaterequal(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isless(float __x, float __y) { + return __builtin_isless(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isless(double __x, double __y) { + return __builtin_isless(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool islessequal(float __x, float __y) { + return __builtin_islessequal(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool islessequal(double __x, double __y) { + return __builtin_islessequal(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool islessgreater(float __x, float __y) { + return __builtin_islessgreater(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool islessgreater(double __x, double __y) { + return __builtin_islessgreater(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isnormal(float __x) { + return __builtin_isnormal(__x); +} +__DEVICE__ __CONSTEXPR__ bool isnormal(double __x) { + return __builtin_isnormal(__x); +} +__DEVICE__ __CONSTEXPR__ bool isunordered(float __x, float __y) { + return __builtin_isunordered(__x, __y); +} +__DEVICE__ __CONSTEXPR__ bool isunordered(double __x, double __y) { + return __builtin_isunordered(__x, __y); +} +__DEVICE__ __CONSTEXPR__ float modf(float __x, float *__iptr) { + return ::modff(__x, __iptr); +} +__DEVICE__ __CONSTEXPR__ float pow(float __base, int __iexp) { + return ::powif(__base, __iexp); +} +__DEVICE__ __CONSTEXPR__ double pow(double __base, int __iexp) { + return ::powi(__base, __iexp); +} +__DEVICE__ __CONSTEXPR__ float remquo(float __x, float __y, int *__quo) { + return ::remquof(__x, __y, __quo); +} +__DEVICE__ __CONSTEXPR__ float scalbln(float __x, long int __n) { + return ::scalblnf(__x, __n); +} +__DEVICE__ __CONSTEXPR__ bool signbit(float __x) { return ::__signbitf(__x); } +__DEVICE__ __CONSTEXPR__ bool signbit(double __x) { return ::__signbit(__x); } + +// Notably missing above is nexttoward. We omit it because +// ocml doesn't provide an implementation, and we don't want to be in the +// business of implementing tricky libm functions in this header. + +// Other functions. +__DEVICE__ __CONSTEXPR__ _Float16 fma(_Float16 __x, _Float16 __y, + _Float16 __z) { + return __builtin_fmaf16(__x, __y, __z); +} +__DEVICE__ __CONSTEXPR__ _Float16 pow(_Float16 __base, int __iexp) { + return __ocml_pown_f16(__base, __iexp); +} + +#ifndef __OPENMP_AMDGCN__ +// BEGIN DEF_FUN and HIP_OVERLOAD + +// BEGIN DEF_FUN + +#pragma push_macro("__DEF_FUN1") +#pragma push_macro("__DEF_FUN2") +#pragma push_macro("__DEF_FUN2_FI") + +// Define cmath functions with float argument and returns __retty. +#define __DEF_FUN1(__retty, __func) \ + __DEVICE__ __CONSTEXPR__ __retty __func(float __x) { return __func##f(__x); } + +// Define cmath functions with two float arguments and returns __retty. +#define __DEF_FUN2(__retty, __func) \ + __DEVICE__ __CONSTEXPR__ __retty __func(float __x, float __y) { \ + return __func##f(__x, __y); \ + } + +// Define cmath functions with a float and an int argument and returns __retty. +#define __DEF_FUN2_FI(__retty, __func) \ + __DEVICE__ __CONSTEXPR__ __retty __func(float __x, int __y) { \ + return __func##f(__x, __y); \ + } + +__DEF_FUN1(float, acos) +__DEF_FUN1(float, acosh) +__DEF_FUN1(float, asin) +__DEF_FUN1(float, asinh) +__DEF_FUN1(float, atan) +__DEF_FUN2(float, atan2) +__DEF_FUN1(float, atanh) +__DEF_FUN1(float, cbrt) +__DEF_FUN1(float, ceil) +__DEF_FUN2(float, copysign) +__DEF_FUN1(float, cos) +__DEF_FUN1(float, cosh) +__DEF_FUN1(float, erf) +__DEF_FUN1(float, erfc) +__DEF_FUN1(float, exp) +__DEF_FUN1(float, exp2) +__DEF_FUN1(float, expm1) +__DEF_FUN1(float, fabs) +__DEF_FUN2(float, fdim) +__DEF_FUN1(float, floor) +__DEF_FUN2(float, fmax) +__DEF_FUN2(float, fmin) +__DEF_FUN2(float, fmod) +__DEF_FUN2(float, hypot) +__DEF_FUN1(int, ilogb) +__DEF_FUN2_FI(float, ldexp) +__DEF_FUN1(float, lgamma) +__DEF_FUN1(float, log) +__DEF_FUN1(float, log10) +__DEF_FUN1(float, log1p) +__DEF_FUN1(float, log2) +__DEF_FUN1(float, logb) +__DEF_FUN1(long long, llrint) +__DEF_FUN1(long long, llround) +__DEF_FUN1(long, lrint) +__DEF_FUN1(long, lround) +__DEF_FUN1(float, nearbyint) +__DEF_FUN2(float, nextafter) +__DEF_FUN2(float, pow) +__DEF_FUN2(float, remainder) +__DEF_FUN1(float, rint) +__DEF_FUN1(float, round) +__DEF_FUN2_FI(float, scalbn) +__DEF_FUN1(float, sin) +__DEF_FUN1(float, sinh) +__DEF_FUN1(float, sqrt) +__DEF_FUN1(float, tan) +__DEF_FUN1(float, tanh) +__DEF_FUN1(float, tgamma) +__DEF_FUN1(float, trunc) + +#pragma pop_macro("__DEF_FUN1") +#pragma pop_macro("__DEF_FUN2") +#pragma pop_macro("__DEF_FUN2_FI") + +// END DEF_FUN + +// BEGIN HIP_OVERLOAD + +#pragma push_macro("__HIP_OVERLOAD1") +#pragma push_macro("__HIP_OVERLOAD2") + +// __hip_enable_if::type is a type function which returns __T if __B is true. +template struct __hip_enable_if {}; + +template struct __hip_enable_if { typedef __T type; }; + +namespace __hip { +template struct is_integral { + enum { value = 0 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; +template <> struct is_integral { + enum { value = 1 }; +}; + +// ToDo: specializes is_arithmetic<_Float16> +template struct is_arithmetic { + enum { value = 0 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; +template <> struct is_arithmetic { + enum { value = 1 }; +}; + +struct true_type { + static const __constant__ bool value = true; +}; +struct false_type { + static const __constant__ bool value = false; +}; + +template struct is_same : public false_type {}; +template struct is_same<__T, __T> : public true_type {}; + +template struct add_rvalue_reference { typedef __T &&type; }; + +template typename add_rvalue_reference<__T>::type declval(); + +// decltype is only available in C++11 and above. +#if __cplusplus >= 201103L +// __hip_promote +template struct __numeric_type { + static void __test(...); + static _Float16 __test(_Float16); + static float __test(float); + static double __test(char); + static double __test(int); + static double __test(unsigned); + static double __test(long); + static double __test(unsigned long); + static double __test(long long); + static double __test(unsigned long long); + static double __test(double); + // No support for long double, use double instead. + static double __test(long double); + + template + static auto __test_impl(int) -> decltype(__test(declval<_U>())); + + template static void __test_impl(...); + + typedef decltype(__test_impl<_Tp>(0)) type; + static const bool value = !is_same::value; +}; + +template <> struct __numeric_type { static const bool value = true; }; + +template ::value &&__numeric_type<_A2>::value + &&__numeric_type<_A3>::value> +class __promote_imp { +public: + static const bool value = false; +}; + +template +class __promote_imp<_A1, _A2, _A3, true> { +private: + typedef typename __promote_imp<_A1>::type __type1; + typedef typename __promote_imp<_A2>::type __type2; + typedef typename __promote_imp<_A3>::type __type3; + +public: + typedef decltype(__type1() + __type2() + __type3()) type; + static const bool value = true; +}; + +template class __promote_imp<_A1, _A2, void, true> { +private: + typedef typename __promote_imp<_A1>::type __type1; + typedef typename __promote_imp<_A2>::type __type2; + +public: + typedef decltype(__type1() + __type2()) type; + static const bool value = true; +}; + +template class __promote_imp<_A1, void, void, true> { +public: + typedef typename __numeric_type<_A1>::type type; + static const bool value = true; +}; + +template +class __promote : public __promote_imp<_A1, _A2, _A3> {}; +#endif //__cplusplus >= 201103L +} // namespace __hip + +// __HIP_OVERLOAD1 is used to resolve function calls with integer argument to +// avoid compilation error due to ambiguity. e.g. floor(5) is resolved with +// floor(double). +#define __HIP_OVERLOAD1(__retty, __fn) \ + template \ + __DEVICE__ __CONSTEXPR__ \ + typename __hip_enable_if<__hip::is_integral<__T>::value, __retty>::type \ + __fn(__T __x) { \ + return ::__fn((double)__x); \ + } + +// __HIP_OVERLOAD2 is used to resolve function calls with mixed float/double +// or integer argument to avoid compilation error due to ambiguity. e.g. +// max(5.0f, 6.0) is resolved with max(double, double). +#if __cplusplus >= 201103L +#define __HIP_OVERLOAD2(__retty, __fn) \ + template \ + __DEVICE__ __CONSTEXPR__ \ + typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && \ + __hip::is_arithmetic<__T2>::value, \ + __retty>::type \ + __fn(__T1 __x, __T2 __y) { \ + typedef typename __hip::__promote<__T1, __T2>::type __arg_type; \ + return __fn((__arg_type)__x, (__arg_type)__y); \ + } +#else +#define __HIP_OVERLOAD2(__retty, __fn) \ + template \ + __DEVICE__ __CONSTEXPR__ \ + typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && \ + __hip::is_arithmetic<__T2>::value, \ + __retty>::type \ + __fn(__T1 __x, __T2 __y) { \ + return __fn((double)__x, (double)__y); \ + } +#endif + +__HIP_OVERLOAD1(double, acos) +__HIP_OVERLOAD1(double, acosh) +__HIP_OVERLOAD1(double, asin) +__HIP_OVERLOAD1(double, asinh) +__HIP_OVERLOAD1(double, atan) +__HIP_OVERLOAD2(double, atan2) +__HIP_OVERLOAD1(double, atanh) +__HIP_OVERLOAD1(double, cbrt) +__HIP_OVERLOAD1(double, ceil) +__HIP_OVERLOAD2(double, copysign) +__HIP_OVERLOAD1(double, cos) +__HIP_OVERLOAD1(double, cosh) +__HIP_OVERLOAD1(double, erf) +__HIP_OVERLOAD1(double, erfc) +__HIP_OVERLOAD1(double, exp) +__HIP_OVERLOAD1(double, exp2) +__HIP_OVERLOAD1(double, expm1) +__HIP_OVERLOAD1(double, fabs) +__HIP_OVERLOAD2(double, fdim) +__HIP_OVERLOAD1(double, floor) +__HIP_OVERLOAD2(double, fmax) +__HIP_OVERLOAD2(double, fmin) +__HIP_OVERLOAD2(double, fmod) +#if !defined(__HIPCC_RTC__) +__HIP_OVERLOAD1(int, fpclassify) +#endif // !defined(__HIPCC_RTC__) +__HIP_OVERLOAD2(double, hypot) +__HIP_OVERLOAD1(int, ilogb) +__HIP_OVERLOAD1(bool, isfinite) +__HIP_OVERLOAD2(bool, isgreater) +__HIP_OVERLOAD2(bool, isgreaterequal) +__HIP_OVERLOAD1(bool, isinf) +__HIP_OVERLOAD2(bool, isless) +__HIP_OVERLOAD2(bool, islessequal) +__HIP_OVERLOAD2(bool, islessgreater) +__HIP_OVERLOAD1(bool, isnan) +__HIP_OVERLOAD1(bool, isnormal) +__HIP_OVERLOAD2(bool, isunordered) +__HIP_OVERLOAD1(double, lgamma) +__HIP_OVERLOAD1(double, log) +__HIP_OVERLOAD1(double, log10) +__HIP_OVERLOAD1(double, log1p) +__HIP_OVERLOAD1(double, log2) +__HIP_OVERLOAD1(double, logb) +__HIP_OVERLOAD1(long long, llrint) +__HIP_OVERLOAD1(long long, llround) +__HIP_OVERLOAD1(long, lrint) +__HIP_OVERLOAD1(long, lround) +__HIP_OVERLOAD1(double, nearbyint) +__HIP_OVERLOAD2(double, nextafter) +__HIP_OVERLOAD2(double, pow) +__HIP_OVERLOAD2(double, remainder) +__HIP_OVERLOAD1(double, rint) +__HIP_OVERLOAD1(double, round) +__HIP_OVERLOAD1(bool, signbit) +__HIP_OVERLOAD1(double, sin) +__HIP_OVERLOAD1(double, sinh) +__HIP_OVERLOAD1(double, sqrt) +__HIP_OVERLOAD1(double, tan) +__HIP_OVERLOAD1(double, tanh) +__HIP_OVERLOAD1(double, tgamma) +__HIP_OVERLOAD1(double, trunc) + +// Overload these but don't add them to std, they are not part of cmath. +__HIP_OVERLOAD2(double, max) +__HIP_OVERLOAD2(double, min) + +// Additional Overloads that don't quite match HIP_OVERLOAD. +#if __cplusplus >= 201103L +template +__DEVICE__ __CONSTEXPR__ typename __hip_enable_if< + __hip::is_arithmetic<__T1>::value && __hip::is_arithmetic<__T2>::value && + __hip::is_arithmetic<__T3>::value, + typename __hip::__promote<__T1, __T2, __T3>::type>::type +fma(__T1 __x, __T2 __y, __T3 __z) { + typedef typename __hip::__promote<__T1, __T2, __T3>::type __result_type; + return ::fma((__result_type)__x, (__result_type)__y, (__result_type)__z); +} +#else +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && + __hip::is_arithmetic<__T2>::value && + __hip::is_arithmetic<__T3>::value, + double>::type + fma(__T1 __x, __T2 __y, __T3 __z) { + return ::fma((double)__x, (double)__y, (double)__z); +} +#endif + +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type + frexp(__T __x, int *__exp) { + return ::frexp((double)__x, __exp); +} + +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type + ldexp(__T __x, int __exp) { + return ::ldexp((double)__x, __exp); +} + +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type + modf(__T __x, double *__exp) { + return ::modf((double)__x, __exp); +} + +#if __cplusplus >= 201103L +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && + __hip::is_arithmetic<__T2>::value, + typename __hip::__promote<__T1, __T2>::type>::type + remquo(__T1 __x, __T2 __y, int *__quo) { + typedef typename __hip::__promote<__T1, __T2>::type __result_type; + return ::remquo((__result_type)__x, (__result_type)__y, __quo); +} +#else +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_arithmetic<__T1>::value && + __hip::is_arithmetic<__T2>::value, + double>::type + remquo(__T1 __x, __T2 __y, int *__quo) { + return ::remquo((double)__x, (double)__y, __quo); +} +#endif + +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type + scalbln(__T __x, long int __exp) { + return ::scalbln((double)__x, __exp); +} + +template +__DEVICE__ __CONSTEXPR__ + typename __hip_enable_if<__hip::is_integral<__T>::value, double>::type + scalbn(__T __x, int __exp) { + return ::scalbn((double)__x, __exp); +} + +#pragma pop_macro("__HIP_OVERLOAD1") +#pragma pop_macro("__HIP_OVERLOAD2") + +// END HIP_OVERLOAD + +// END DEF_FUN and HIP_OVERLOAD + +#endif // ifndef __OPENMP_AMDGCN__ +#endif // defined(__cplusplus) + +#ifndef __OPENMP_AMDGCN__ +// Define these overloads inside the namespace our standard library uses. +#if !defined(__HIPCC_RTC__) +#ifdef _LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_BEGIN_NAMESPACE_STD +#else +namespace std { +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#endif // _GLIBCXX_BEGIN_NAMESPACE_VERSION +#endif // _LIBCPP_BEGIN_NAMESPACE_STD + +// Pull the new overloads we defined above into namespace std. +// using ::abs; - This may be considered for C++. +using ::acos; +using ::acosh; +using ::asin; +using ::asinh; +using ::atan; +using ::atan2; +using ::atanh; +using ::cbrt; +using ::ceil; +using ::copysign; +using ::cos; +using ::cosh; +using ::erf; +using ::erfc; +using ::exp; +using ::exp2; +using ::expm1; +using ::fabs; +using ::fdim; +using ::floor; +using ::fma; +using ::fmax; +using ::fmin; +using ::fmod; +using ::fpclassify; +using ::frexp; +using ::hypot; +using ::ilogb; +using ::isfinite; +using ::isgreater; +using ::isgreaterequal; +using ::isless; +using ::islessequal; +using ::islessgreater; +using ::isnormal; +using ::isunordered; +using ::ldexp; +using ::lgamma; +using ::llrint; +using ::llround; +using ::log; +using ::log10; +using ::log1p; +using ::log2; +using ::logb; +using ::lrint; +using ::lround; +using ::modf; +// using ::nan; - This may be considered for C++. +// using ::nanf; - This may be considered for C++. +// using ::nanl; - This is not yet defined. +using ::nearbyint; +using ::nextafter; +// using ::nexttoward; - Omit this since we do not have a definition. +using ::pow; +using ::remainder; +using ::remquo; +using ::rint; +using ::round; +using ::scalbln; +using ::scalbn; +using ::signbit; +using ::sin; +using ::sinh; +using ::sqrt; +using ::tan; +using ::tanh; +using ::tgamma; +using ::trunc; + +// Well this is fun: We need to pull these symbols in for libc++, but we can't +// pull them in with libstdc++, because its ::isinf and ::isnan are different +// than its std::isinf and std::isnan. +#ifndef __GLIBCXX__ +using ::isinf; +using ::isnan; +#endif + +// Finally, pull the "foobarf" functions that HIP defines into std. +using ::acosf; +using ::acoshf; +using ::asinf; +using ::asinhf; +using ::atan2f; +using ::atanf; +using ::atanhf; +using ::cbrtf; +using ::ceilf; +using ::copysignf; +using ::cosf; +using ::coshf; +using ::erfcf; +using ::erff; +using ::exp2f; +using ::expf; +using ::expm1f; +using ::fabsf; +using ::fdimf; +using ::floorf; +using ::fmaf; +using ::fmaxf; +using ::fminf; +using ::fmodf; +using ::frexpf; +using ::hypotf; +using ::ilogbf; +using ::ldexpf; +using ::lgammaf; +using ::llrintf; +using ::llroundf; +using ::log10f; +using ::log1pf; +using ::log2f; +using ::logbf; +using ::logf; +using ::lrintf; +using ::lroundf; +using ::modff; +using ::nearbyintf; +using ::nextafterf; +// using ::nexttowardf; - Omit this since we do not have a definition. +using ::powf; +using ::remainderf; +using ::remquof; +using ::rintf; +using ::roundf; +using ::scalblnf; +using ::scalbnf; +using ::sinf; +using ::sinhf; +using ::sqrtf; +using ::tanf; +using ::tanhf; +using ::tgammaf; +using ::truncf; + +#ifdef _LIBCPP_END_NAMESPACE_STD +_LIBCPP_END_NAMESPACE_STD +#else +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +#endif // _GLIBCXX_BEGIN_NAMESPACE_VERSION +} // namespace std +#endif // _LIBCPP_END_NAMESPACE_STD +#endif // !defined(__HIPCC_RTC__) + +// Define device-side math functions from on MSVC. +#if !defined(__HIPCC_RTC__) +#if defined(_MSC_VER) + +// Before VS2019, `` is also included in `` and other headers. +// But, from VS2019, it's only included in ``. Need to include +// `` here to ensure C functions declared there won't be markded as +// `__host__` and `__device__` through `` wrapper. +#include + +#if defined(__cplusplus) +extern "C" { +#endif // defined(__cplusplus) +__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) double _Cosh(double x, + double y) { + return cosh(x) * y; +} +__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) float _FCosh(float x, + float y) { + return coshf(x) * y; +} +__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) short _Dtest(double *p) { + return fpclassify(*p); +} +__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) short _FDtest(float *p) { + return fpclassify(*p); +} +__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) double _Sinh(double x, + double y) { + return sinh(x) * y; +} +__DEVICE__ __CONSTEXPR__ __attribute__((overloadable)) float _FSinh(float x, + float y) { + return sinhf(x) * y; +} +#if defined(__cplusplus) +} +#endif // defined(__cplusplus) +#endif // defined(_MSC_VER) +#endif // !defined(__HIPCC_RTC__) +#endif // ifndef __OPENMP_AMDGCN__ + +#pragma pop_macro("__DEVICE__") +#pragma pop_macro("__CONSTEXPR__") + +#endif // __CLANG_HIP_CMATH_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_libdevice_declares.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_libdevice_declares.h new file mode 100755 index 0000000..fa8d918 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_libdevice_declares.h @@ -0,0 +1,345 @@ +/*===---- __clang_hip_libdevice_declares.h - HIP device library decls -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__ +#define __CLANG_HIP_LIBDEVICE_DECLARES_H__ + +#if !defined(__HIPCC_RTC__) && __has_include("hip/hip_version.h") +#include "hip/hip_version.h" +#endif // __has_include("hip/hip_version.h") + +#define __PRIVATE_AS __attribute__((opencl_private)) + +#ifdef __cplusplus +extern "C" { +#endif + +// BEGIN FLOAT +__device__ __attribute__((const)) float __ocml_acos_f32(float); +__device__ __attribute__((pure)) float __ocml_acosh_f32(float); +__device__ __attribute__((const)) float __ocml_asin_f32(float); +__device__ __attribute__((pure)) float __ocml_asinh_f32(float); +__device__ __attribute__((const)) float __ocml_atan2_f32(float, float); +__device__ __attribute__((const)) float __ocml_atan_f32(float); +__device__ __attribute__((pure)) float __ocml_atanh_f32(float); +__device__ __attribute__((pure)) float __ocml_cbrt_f32(float); +__device__ __attribute__((const)) float __ocml_ceil_f32(float); +__device__ __attribute__((const)) __device__ float __ocml_copysign_f32(float, + float); +__device__ float __ocml_cos_f32(float); +__device__ float __ocml_native_cos_f32(float); +__device__ __attribute__((pure)) __device__ float __ocml_cosh_f32(float); +__device__ float __ocml_cospi_f32(float); +__device__ float __ocml_i0_f32(float); +__device__ float __ocml_i1_f32(float); +__device__ __attribute__((pure)) float __ocml_erfc_f32(float); +__device__ __attribute__((pure)) float __ocml_erfcinv_f32(float); +__device__ __attribute__((pure)) float __ocml_erfcx_f32(float); +__device__ __attribute__((pure)) float __ocml_erf_f32(float); +__device__ __attribute__((pure)) float __ocml_erfinv_f32(float); +__device__ __attribute__((pure)) float __ocml_exp10_f32(float); +__device__ __attribute__((pure)) float __ocml_native_exp10_f32(float); +__device__ __attribute__((pure)) float __ocml_exp2_f32(float); +__device__ __attribute__((pure)) float __ocml_exp_f32(float); +__device__ __attribute__((pure)) float __ocml_native_exp_f32(float); +__device__ __attribute__((pure)) float __ocml_expm1_f32(float); +__device__ __attribute__((const)) float __ocml_fabs_f32(float); +__device__ __attribute__((const)) float __ocml_fdim_f32(float, float); +__device__ __attribute__((const)) float __ocml_floor_f32(float); +__device__ __attribute__((const)) float __ocml_fma_f32(float, float, float); +__device__ __attribute__((const)) float __ocml_fmax_f32(float, float); +__device__ __attribute__((const)) float __ocml_fmin_f32(float, float); +__device__ __attribute__((const)) __device__ float __ocml_fmod_f32(float, + float); +__device__ float __ocml_frexp_f32(float, __PRIVATE_AS int *); +__device__ __attribute__((const)) float __ocml_hypot_f32(float, float); +__device__ __attribute__((const)) int __ocml_ilogb_f32(float); +__device__ __attribute__((const)) int __ocml_isfinite_f32(float); +__device__ __attribute__((const)) int __ocml_isinf_f32(float); +__device__ __attribute__((const)) int __ocml_isnan_f32(float); +__device__ float __ocml_j0_f32(float); +__device__ float __ocml_j1_f32(float); +__device__ __attribute__((const)) float __ocml_ldexp_f32(float, int); +__device__ float __ocml_lgamma_f32(float); +__device__ __attribute__((pure)) float __ocml_log10_f32(float); +__device__ __attribute__((pure)) float __ocml_native_log10_f32(float); +__device__ __attribute__((pure)) float __ocml_log1p_f32(float); +__device__ __attribute__((pure)) float __ocml_log2_f32(float); +__device__ __attribute__((pure)) float __ocml_native_log2_f32(float); +__device__ __attribute__((const)) float __ocml_logb_f32(float); +__device__ __attribute__((pure)) float __ocml_log_f32(float); +__device__ __attribute__((pure)) float __ocml_native_log_f32(float); +__device__ float __ocml_modf_f32(float, __PRIVATE_AS float *); +__device__ __attribute__((const)) float __ocml_nearbyint_f32(float); +__device__ __attribute__((const)) float __ocml_nextafter_f32(float, float); +__device__ __attribute__((const)) float __ocml_len3_f32(float, float, float); +__device__ __attribute__((const)) float __ocml_len4_f32(float, float, float, + float); +__device__ __attribute__((pure)) float __ocml_ncdf_f32(float); +__device__ __attribute__((pure)) float __ocml_ncdfinv_f32(float); +__device__ __attribute__((pure)) float __ocml_pow_f32(float, float); +__device__ __attribute__((pure)) float __ocml_pown_f32(float, int); +__device__ __attribute__((pure)) float __ocml_rcbrt_f32(float); +__device__ __attribute__((const)) float __ocml_remainder_f32(float, float); +__device__ float __ocml_remquo_f32(float, float, __PRIVATE_AS int *); +__device__ __attribute__((const)) float __ocml_rhypot_f32(float, float); +__device__ __attribute__((const)) float __ocml_rint_f32(float); +__device__ __attribute__((const)) float __ocml_rlen3_f32(float, float, float); +__device__ __attribute__((const)) float __ocml_rlen4_f32(float, float, float, + float); +__device__ __attribute__((const)) float __ocml_round_f32(float); +__device__ __attribute__((pure)) float __ocml_rsqrt_f32(float); +__device__ __attribute__((const)) float __ocml_scalb_f32(float, float); +__device__ __attribute__((const)) float __ocml_scalbn_f32(float, int); +__device__ __attribute__((const)) int __ocml_signbit_f32(float); +__device__ float __ocml_sincos_f32(float, __PRIVATE_AS float *); +__device__ float __ocml_sincospi_f32(float, __PRIVATE_AS float *); +__device__ float __ocml_sin_f32(float); +__device__ float __ocml_native_sin_f32(float); +__device__ __attribute__((pure)) float __ocml_sinh_f32(float); +__device__ float __ocml_sinpi_f32(float); +__device__ __attribute__((const)) float __ocml_sqrt_f32(float); +__device__ __attribute__((const)) float __ocml_native_sqrt_f32(float); +__device__ float __ocml_tan_f32(float); +__device__ __attribute__((pure)) float __ocml_tanh_f32(float); +__device__ float __ocml_tgamma_f32(float); +__device__ __attribute__((const)) float __ocml_trunc_f32(float); +__device__ float __ocml_y0_f32(float); +__device__ float __ocml_y1_f32(float); + +// BEGIN INTRINSICS +__device__ __attribute__((const)) float __ocml_add_rte_f32(float, float); +__device__ __attribute__((const)) float __ocml_add_rtn_f32(float, float); +__device__ __attribute__((const)) float __ocml_add_rtp_f32(float, float); +__device__ __attribute__((const)) float __ocml_add_rtz_f32(float, float); +__device__ __attribute__((const)) float __ocml_sub_rte_f32(float, float); +__device__ __attribute__((const)) float __ocml_sub_rtn_f32(float, float); +__device__ __attribute__((const)) float __ocml_sub_rtp_f32(float, float); +__device__ __attribute__((const)) float __ocml_sub_rtz_f32(float, float); +__device__ __attribute__((const)) float __ocml_mul_rte_f32(float, float); +__device__ __attribute__((const)) float __ocml_mul_rtn_f32(float, float); +__device__ __attribute__((const)) float __ocml_mul_rtp_f32(float, float); +__device__ __attribute__((const)) float __ocml_mul_rtz_f32(float, float); +__device__ __attribute__((const)) float __ocml_div_rte_f32(float, float); +__device__ __attribute__((const)) float __ocml_div_rtn_f32(float, float); +__device__ __attribute__((const)) float __ocml_div_rtp_f32(float, float); +__device__ __attribute__((const)) float __ocml_div_rtz_f32(float, float); +__device__ __attribute__((const)) float __ocml_sqrt_rte_f32(float); +__device__ __attribute__((const)) float __ocml_sqrt_rtn_f32(float); +__device__ __attribute__((const)) float __ocml_sqrt_rtp_f32(float); +__device__ __attribute__((const)) float __ocml_sqrt_rtz_f32(float); +__device__ __attribute__((const)) float __ocml_fma_rte_f32(float, float, float); +__device__ __attribute__((const)) float __ocml_fma_rtn_f32(float, float, float); +__device__ __attribute__((const)) float __ocml_fma_rtp_f32(float, float, float); +__device__ __attribute__((const)) float __ocml_fma_rtz_f32(float, float, float); +// END INTRINSICS +// END FLOAT + +// BEGIN DOUBLE +__device__ __attribute__((const)) double __ocml_acos_f64(double); +__device__ __attribute__((pure)) double __ocml_acosh_f64(double); +__device__ __attribute__((const)) double __ocml_asin_f64(double); +__device__ __attribute__((pure)) double __ocml_asinh_f64(double); +__device__ __attribute__((const)) double __ocml_atan2_f64(double, double); +__device__ __attribute__((const)) double __ocml_atan_f64(double); +__device__ __attribute__((pure)) double __ocml_atanh_f64(double); +__device__ __attribute__((pure)) double __ocml_cbrt_f64(double); +__device__ __attribute__((const)) double __ocml_ceil_f64(double); +__device__ __attribute__((const)) double __ocml_copysign_f64(double, double); +__device__ double __ocml_cos_f64(double); +__device__ __attribute__((pure)) double __ocml_cosh_f64(double); +__device__ double __ocml_cospi_f64(double); +__device__ double __ocml_i0_f64(double); +__device__ double __ocml_i1_f64(double); +__device__ __attribute__((pure)) double __ocml_erfc_f64(double); +__device__ __attribute__((pure)) double __ocml_erfcinv_f64(double); +__device__ __attribute__((pure)) double __ocml_erfcx_f64(double); +__device__ __attribute__((pure)) double __ocml_erf_f64(double); +__device__ __attribute__((pure)) double __ocml_erfinv_f64(double); +__device__ __attribute__((pure)) double __ocml_exp10_f64(double); +__device__ __attribute__((pure)) double __ocml_exp2_f64(double); +__device__ __attribute__((pure)) double __ocml_exp_f64(double); +__device__ __attribute__((pure)) double __ocml_expm1_f64(double); +__device__ __attribute__((const)) double __ocml_fabs_f64(double); +__device__ __attribute__((const)) double __ocml_fdim_f64(double, double); +__device__ __attribute__((const)) double __ocml_floor_f64(double); +__device__ __attribute__((const)) double __ocml_fma_f64(double, double, double); +__device__ __attribute__((const)) double __ocml_fmax_f64(double, double); +__device__ __attribute__((const)) double __ocml_fmin_f64(double, double); +__device__ __attribute__((const)) double __ocml_fmod_f64(double, double); +__device__ double __ocml_frexp_f64(double, __PRIVATE_AS int *); +__device__ __attribute__((const)) double __ocml_hypot_f64(double, double); +__device__ __attribute__((const)) int __ocml_ilogb_f64(double); +__device__ __attribute__((const)) int __ocml_isfinite_f64(double); +__device__ __attribute__((const)) int __ocml_isinf_f64(double); +__device__ __attribute__((const)) int __ocml_isnan_f64(double); +__device__ double __ocml_j0_f64(double); +__device__ double __ocml_j1_f64(double); +__device__ __attribute__((const)) double __ocml_ldexp_f64(double, int); +__device__ double __ocml_lgamma_f64(double); +__device__ __attribute__((pure)) double __ocml_log10_f64(double); +__device__ __attribute__((pure)) double __ocml_log1p_f64(double); +__device__ __attribute__((pure)) double __ocml_log2_f64(double); +__device__ __attribute__((const)) double __ocml_logb_f64(double); +__device__ __attribute__((pure)) double __ocml_log_f64(double); +__device__ double __ocml_modf_f64(double, __PRIVATE_AS double *); +__device__ __attribute__((const)) double __ocml_nearbyint_f64(double); +__device__ __attribute__((const)) double __ocml_nextafter_f64(double, double); +__device__ __attribute__((const)) double __ocml_len3_f64(double, double, + double); +__device__ __attribute__((const)) double __ocml_len4_f64(double, double, double, + double); +__device__ __attribute__((pure)) double __ocml_ncdf_f64(double); +__device__ __attribute__((pure)) double __ocml_ncdfinv_f64(double); +__device__ __attribute__((pure)) double __ocml_pow_f64(double, double); +__device__ __attribute__((pure)) double __ocml_pown_f64(double, int); +__device__ __attribute__((pure)) double __ocml_rcbrt_f64(double); +__device__ __attribute__((const)) double __ocml_remainder_f64(double, double); +__device__ double __ocml_remquo_f64(double, double, __PRIVATE_AS int *); +__device__ __attribute__((const)) double __ocml_rhypot_f64(double, double); +__device__ __attribute__((const)) double __ocml_rint_f64(double); +__device__ __attribute__((const)) double __ocml_rlen3_f64(double, double, + double); +__device__ __attribute__((const)) double __ocml_rlen4_f64(double, double, + double, double); +__device__ __attribute__((const)) double __ocml_round_f64(double); +__device__ __attribute__((pure)) double __ocml_rsqrt_f64(double); +__device__ __attribute__((const)) double __ocml_scalb_f64(double, double); +__device__ __attribute__((const)) double __ocml_scalbn_f64(double, int); +__device__ __attribute__((const)) int __ocml_signbit_f64(double); +__device__ double __ocml_sincos_f64(double, __PRIVATE_AS double *); +__device__ double __ocml_sincospi_f64(double, __PRIVATE_AS double *); +__device__ double __ocml_sin_f64(double); +__device__ __attribute__((pure)) double __ocml_sinh_f64(double); +__device__ double __ocml_sinpi_f64(double); +__device__ __attribute__((const)) double __ocml_sqrt_f64(double); +__device__ double __ocml_tan_f64(double); +__device__ __attribute__((pure)) double __ocml_tanh_f64(double); +__device__ double __ocml_tgamma_f64(double); +__device__ __attribute__((const)) double __ocml_trunc_f64(double); +__device__ double __ocml_y0_f64(double); +__device__ double __ocml_y1_f64(double); + +// BEGIN INTRINSICS +__device__ __attribute__((const)) double __ocml_add_rte_f64(double, double); +__device__ __attribute__((const)) double __ocml_add_rtn_f64(double, double); +__device__ __attribute__((const)) double __ocml_add_rtp_f64(double, double); +__device__ __attribute__((const)) double __ocml_add_rtz_f64(double, double); +__device__ __attribute__((const)) double __ocml_sub_rte_f64(double, double); +__device__ __attribute__((const)) double __ocml_sub_rtn_f64(double, double); +__device__ __attribute__((const)) double __ocml_sub_rtp_f64(double, double); +__device__ __attribute__((const)) double __ocml_sub_rtz_f64(double, double); +__device__ __attribute__((const)) double __ocml_mul_rte_f64(double, double); +__device__ __attribute__((const)) double __ocml_mul_rtn_f64(double, double); +__device__ __attribute__((const)) double __ocml_mul_rtp_f64(double, double); +__device__ __attribute__((const)) double __ocml_mul_rtz_f64(double, double); +__device__ __attribute__((const)) double __ocml_div_rte_f64(double, double); +__device__ __attribute__((const)) double __ocml_div_rtn_f64(double, double); +__device__ __attribute__((const)) double __ocml_div_rtp_f64(double, double); +__device__ __attribute__((const)) double __ocml_div_rtz_f64(double, double); +__device__ __attribute__((const)) double __ocml_sqrt_rte_f64(double); +__device__ __attribute__((const)) double __ocml_sqrt_rtn_f64(double); +__device__ __attribute__((const)) double __ocml_sqrt_rtp_f64(double); +__device__ __attribute__((const)) double __ocml_sqrt_rtz_f64(double); +__device__ __attribute__((const)) double __ocml_fma_rte_f64(double, double, + double); +__device__ __attribute__((const)) double __ocml_fma_rtn_f64(double, double, + double); +__device__ __attribute__((const)) double __ocml_fma_rtp_f64(double, double, + double); +__device__ __attribute__((const)) double __ocml_fma_rtz_f64(double, double, + double); + +__device__ __attribute__((const)) _Float16 __ocml_ceil_f16(_Float16); +__device__ _Float16 __ocml_cos_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_cvtrtn_f16_f32(float); +__device__ __attribute__((const)) _Float16 __ocml_cvtrtp_f16_f32(float); +__device__ __attribute__((const)) _Float16 __ocml_cvtrtz_f16_f32(float); +__device__ __attribute__((pure)) _Float16 __ocml_exp_f16(_Float16); +__device__ __attribute__((pure)) _Float16 __ocml_exp10_f16(_Float16); +__device__ __attribute__((pure)) _Float16 __ocml_exp2_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_floor_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_fma_f16(_Float16, _Float16, + _Float16); +__device__ __attribute__((const)) _Float16 __ocml_fmax_f16(_Float16, _Float16); +__device__ __attribute__((const)) _Float16 __ocml_fmin_f16(_Float16, _Float16); +__device__ __attribute__((const)) _Float16 __ocml_fabs_f16(_Float16); +__device__ __attribute__((const)) int __ocml_isinf_f16(_Float16); +__device__ __attribute__((const)) int __ocml_isnan_f16(_Float16); +__device__ __attribute__((pure)) _Float16 __ocml_log_f16(_Float16); +__device__ __attribute__((pure)) _Float16 __ocml_log10_f16(_Float16); +__device__ __attribute__((pure)) _Float16 __ocml_log2_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_rint_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_rsqrt_f16(_Float16); +__device__ _Float16 __ocml_sin_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_sqrt_f16(_Float16); +__device__ __attribute__((const)) _Float16 __ocml_trunc_f16(_Float16); +__device__ __attribute__((pure)) _Float16 __ocml_pown_f16(_Float16, int); + +typedef _Float16 __2f16 __attribute__((ext_vector_type(2))); +typedef short __2i16 __attribute__((ext_vector_type(2))); + +// We need to match C99's bool and get an i1 in the IR. +#ifdef __cplusplus +typedef bool __ockl_bool; +#else +typedef _Bool __ockl_bool; +#endif + +__device__ __attribute__((const)) float __ockl_fdot2(__2f16 a, __2f16 b, + float c, __ockl_bool s); +__device__ __attribute__((const)) __2f16 __ocml_ceil_2f16(__2f16); +__device__ __attribute__((const)) __2f16 __ocml_fabs_2f16(__2f16); +__device__ __2f16 __ocml_cos_2f16(__2f16); +__device__ __attribute__((pure)) __2f16 __ocml_exp_2f16(__2f16); +__device__ __attribute__((pure)) __2f16 __ocml_exp10_2f16(__2f16); +__device__ __attribute__((pure)) __2f16 __ocml_exp2_2f16(__2f16); +__device__ __attribute__((const)) __2f16 __ocml_floor_2f16(__2f16); +__device__ __attribute__((const)) +__2f16 __ocml_fma_2f16(__2f16, __2f16, __2f16); +__device__ __attribute__((const)) __2i16 __ocml_isinf_2f16(__2f16); +__device__ __attribute__((const)) __2i16 __ocml_isnan_2f16(__2f16); +__device__ __attribute__((pure)) __2f16 __ocml_log_2f16(__2f16); +__device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16); +__device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16); + +#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 560 +#define __DEPRECATED_SINCE_HIP_560(X) __attribute__((deprecated(X))) +#else +#define __DEPRECATED_SINCE_HIP_560(X) +#endif + +// Deprecated, should be removed when rocm releases using it are no longer +// relevant. +__DEPRECATED_SINCE_HIP_560("use ((_Float16)1.0) / ") +__device__ inline _Float16 __llvm_amdgcn_rcp_f16(_Float16 x) { + return ((_Float16)1.0f) / x; +} + +__DEPRECATED_SINCE_HIP_560("use ((__2f16)1.0) / ") +__device__ inline __2f16 +__llvm_amdgcn_rcp_2f16(__2f16 __x) +{ + return ((__2f16)1.0f) / __x; +} + +#undef __DEPRECATED_SINCE_HIP_560 + +__device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16); +__device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16); +__device__ __2f16 __ocml_sin_2f16(__2f16); +__device__ __attribute__((const)) __2f16 __ocml_sqrt_2f16(__2f16); +__device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16); +__device__ __attribute__((const)) __2f16 __ocml_pown_2f16(__2f16, __2i16); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // __CLANG_HIP_LIBDEVICE_DECLARES_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_math.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_math.h new file mode 100755 index 0000000..759e742 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_math.h @@ -0,0 +1,1405 @@ +/*===---- __clang_hip_math.h - Device-side HIP math support ----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CLANG_HIP_MATH_H__ +#define __CLANG_HIP_MATH_H__ + +#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__) +#error "This file is for HIP and OpenMP AMDGCN device compilation only." +#endif + +// The __CLANG_GPU_DISABLE_MATH_WRAPPERS macro provides a way to let standard +// libcalls reach the link step instead of being eagerly replaced. +#ifndef __CLANG_GPU_DISABLE_MATH_WRAPPERS + +#if !defined(__HIPCC_RTC__) +#include +#include +#ifdef __OPENMP_AMDGCN__ +#include +#endif +#endif // !defined(__HIPCC_RTC__) + +#pragma push_macro("__DEVICE__") + +#ifdef __OPENMP_AMDGCN__ +#define __DEVICE__ static inline __attribute__((always_inline, nothrow)) +#else +#define __DEVICE__ static __device__ inline __attribute__((always_inline)) +#endif + +#pragma push_macro("__PRIVATE_AS") + +#define __PRIVATE_AS __attribute__((opencl_private)) +// Device library provides fast low precision and slow full-recision +// implementations for some functions. Which one gets selected depends on +// __CLANG_GPU_APPROX_TRANSCENDENTALS__ which gets defined by clang if +// -ffast-math or -fgpu-approx-transcendentals are in effect. +#pragma push_macro("__FAST_OR_SLOW") +#if defined(__CLANG_GPU_APPROX_TRANSCENDENTALS__) +#define __FAST_OR_SLOW(fast, slow) fast +#else +#define __FAST_OR_SLOW(fast, slow) slow +#endif + +// A few functions return bool type starting only in C++11. +#pragma push_macro("__RETURN_TYPE") +#ifdef __OPENMP_AMDGCN__ +#define __RETURN_TYPE int +#else +#if defined(__cplusplus) +#define __RETURN_TYPE bool +#else +#define __RETURN_TYPE int +#endif +#endif // __OPENMP_AMDGCN__ + +#if defined (__cplusplus) && __cplusplus < 201103L +// emulate static_assert on type sizes +template +struct __compare_result{}; +template<> +struct __compare_result { + static const __device__ bool valid; +}; + +__DEVICE__ +void __suppress_unused_warning(bool b){}; +template +__DEVICE__ void __static_assert_equal_size() { + __suppress_unused_warning(__compare_result::valid); +} + +#define __static_assert_type_size_equal(A, B) \ + __static_assert_equal_size() + +#else +#define __static_assert_type_size_equal(A,B) \ + static_assert((A) == (B), "") + +#endif + +__DEVICE__ +uint64_t __make_mantissa_base8(const char *__tagp __attribute__((nonnull))) { + uint64_t __r = 0; + while (*__tagp != '\0') { + char __tmp = *__tagp; + + if (__tmp >= '0' && __tmp <= '7') + __r = (__r * 8u) + __tmp - '0'; + else + return 0; + + ++__tagp; + } + + return __r; +} + +__DEVICE__ +uint64_t __make_mantissa_base10(const char *__tagp __attribute__((nonnull))) { + uint64_t __r = 0; + while (*__tagp != '\0') { + char __tmp = *__tagp; + + if (__tmp >= '0' && __tmp <= '9') + __r = (__r * 10u) + __tmp - '0'; + else + return 0; + + ++__tagp; + } + + return __r; +} + +__DEVICE__ +uint64_t __make_mantissa_base16(const char *__tagp __attribute__((nonnull))) { + uint64_t __r = 0; + while (*__tagp != '\0') { + char __tmp = *__tagp; + + if (__tmp >= '0' && __tmp <= '9') + __r = (__r * 16u) + __tmp - '0'; + else if (__tmp >= 'a' && __tmp <= 'f') + __r = (__r * 16u) + __tmp - 'a' + 10; + else if (__tmp >= 'A' && __tmp <= 'F') + __r = (__r * 16u) + __tmp - 'A' + 10; + else + return 0; + + ++__tagp; + } + + return __r; +} + +__DEVICE__ +uint64_t __make_mantissa(const char *__tagp __attribute__((nonnull))) { + if (*__tagp == '0') { + ++__tagp; + + if (*__tagp == 'x' || *__tagp == 'X') + return __make_mantissa_base16(__tagp); + else + return __make_mantissa_base8(__tagp); + } + + return __make_mantissa_base10(__tagp); +} + +// BEGIN FLOAT + +// BEGIN INTRINSICS + +__DEVICE__ +float __cosf(float __x) { return __ocml_native_cos_f32(__x); } + +__DEVICE__ +float __exp10f(float __x) { + const float __log2_10 = 0x1.a934f0p+1f; + return __builtin_amdgcn_exp2f(__log2_10 * __x); +} + +__DEVICE__ +float __expf(float __x) { + const float __log2_e = 0x1.715476p+0; + return __builtin_amdgcn_exp2f(__log2_e * __x); +} + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __fadd_rd(float __x, float __y) { return __ocml_add_rtn_f32(__x, __y); } +__DEVICE__ +float __fadd_rn(float __x, float __y) { return __ocml_add_rte_f32(__x, __y); } +__DEVICE__ +float __fadd_ru(float __x, float __y) { return __ocml_add_rtp_f32(__x, __y); } +__DEVICE__ +float __fadd_rz(float __x, float __y) { return __ocml_add_rtz_f32(__x, __y); } +#else +__DEVICE__ +float __fadd_rn(float __x, float __y) { return __x + __y; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __fdiv_rd(float __x, float __y) { return __ocml_div_rtn_f32(__x, __y); } +__DEVICE__ +float __fdiv_rn(float __x, float __y) { return __ocml_div_rte_f32(__x, __y); } +__DEVICE__ +float __fdiv_ru(float __x, float __y) { return __ocml_div_rtp_f32(__x, __y); } +__DEVICE__ +float __fdiv_rz(float __x, float __y) { return __ocml_div_rtz_f32(__x, __y); } +#else +__DEVICE__ +float __fdiv_rn(float __x, float __y) { return __x / __y; } +#endif + +__DEVICE__ +float __fdividef(float __x, float __y) { return __x / __y; } + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __fmaf_rd(float __x, float __y, float __z) { + return __ocml_fma_rtn_f32(__x, __y, __z); +} +__DEVICE__ +float __fmaf_rn(float __x, float __y, float __z) { + return __ocml_fma_rte_f32(__x, __y, __z); +} +__DEVICE__ +float __fmaf_ru(float __x, float __y, float __z) { + return __ocml_fma_rtp_f32(__x, __y, __z); +} +__DEVICE__ +float __fmaf_rz(float __x, float __y, float __z) { + return __ocml_fma_rtz_f32(__x, __y, __z); +} +#else +__DEVICE__ +float __fmaf_rn(float __x, float __y, float __z) { + return __builtin_fmaf(__x, __y, __z); +} +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __fmul_rd(float __x, float __y) { return __ocml_mul_rtn_f32(__x, __y); } +__DEVICE__ +float __fmul_rn(float __x, float __y) { return __ocml_mul_rte_f32(__x, __y); } +__DEVICE__ +float __fmul_ru(float __x, float __y) { return __ocml_mul_rtp_f32(__x, __y); } +__DEVICE__ +float __fmul_rz(float __x, float __y) { return __ocml_mul_rtz_f32(__x, __y); } +#else +__DEVICE__ +float __fmul_rn(float __x, float __y) { return __x * __y; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __frcp_rd(float __x) { return __ocml_div_rtn_f32(1.0f, __x); } +__DEVICE__ +float __frcp_rn(float __x) { return __ocml_div_rte_f32(1.0f, __x); } +__DEVICE__ +float __frcp_ru(float __x) { return __ocml_div_rtp_f32(1.0f, __x); } +__DEVICE__ +float __frcp_rz(float __x) { return __ocml_div_rtz_f32(1.0f, __x); } +#else +__DEVICE__ +float __frcp_rn(float __x) { return 1.0f / __x; } +#endif + +__DEVICE__ +float __frsqrt_rn(float __x) { return __builtin_amdgcn_rsqf(__x); } + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __fsqrt_rd(float __x) { return __ocml_sqrt_rtn_f32(__x); } +__DEVICE__ +float __fsqrt_rn(float __x) { return __ocml_sqrt_rte_f32(__x); } +__DEVICE__ +float __fsqrt_ru(float __x) { return __ocml_sqrt_rtp_f32(__x); } +__DEVICE__ +float __fsqrt_rz(float __x) { return __ocml_sqrt_rtz_f32(__x); } +#else +__DEVICE__ +float __fsqrt_rn(float __x) { return __ocml_native_sqrt_f32(__x); } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +float __fsub_rd(float __x, float __y) { return __ocml_sub_rtn_f32(__x, __y); } +__DEVICE__ +float __fsub_rn(float __x, float __y) { return __ocml_sub_rte_f32(__x, __y); } +__DEVICE__ +float __fsub_ru(float __x, float __y) { return __ocml_sub_rtp_f32(__x, __y); } +__DEVICE__ +float __fsub_rz(float __x, float __y) { return __ocml_sub_rtz_f32(__x, __y); } +#else +__DEVICE__ +float __fsub_rn(float __x, float __y) { return __x - __y; } +#endif + +__DEVICE__ +float __log10f(float __x) { return __builtin_log10f(__x); } + +__DEVICE__ +float __log2f(float __x) { return __builtin_amdgcn_logf(__x); } + +__DEVICE__ +float __logf(float __x) { return __builtin_logf(__x); } + +__DEVICE__ +float __powf(float __x, float __y) { return __ocml_pow_f32(__x, __y); } + +__DEVICE__ +float __saturatef(float __x) { return (__x < 0) ? 0 : ((__x > 1) ? 1 : __x); } + +__DEVICE__ +void __sincosf(float __x, float *__sinptr, float *__cosptr) { + *__sinptr = __ocml_native_sin_f32(__x); + *__cosptr = __ocml_native_cos_f32(__x); +} + +__DEVICE__ +float __sinf(float __x) { return __ocml_native_sin_f32(__x); } + +__DEVICE__ +float __tanf(float __x) { + return __sinf(__x) * __builtin_amdgcn_rcpf(__cosf(__x)); +} +// END INTRINSICS + +#if defined(__cplusplus) +__DEVICE__ +int abs(int __x) { + return __builtin_abs(__x); +} +__DEVICE__ +long labs(long __x) { + return __builtin_labs(__x); +} +__DEVICE__ +long long llabs(long long __x) { + return __builtin_llabs(__x); +} +#endif + +__DEVICE__ +float acosf(float __x) { return __ocml_acos_f32(__x); } + +__DEVICE__ +float acoshf(float __x) { return __ocml_acosh_f32(__x); } + +__DEVICE__ +float asinf(float __x) { return __ocml_asin_f32(__x); } + +__DEVICE__ +float asinhf(float __x) { return __ocml_asinh_f32(__x); } + +__DEVICE__ +float atan2f(float __x, float __y) { return __ocml_atan2_f32(__x, __y); } + +__DEVICE__ +float atanf(float __x) { return __ocml_atan_f32(__x); } + +__DEVICE__ +float atanhf(float __x) { return __ocml_atanh_f32(__x); } + +__DEVICE__ +float cbrtf(float __x) { return __ocml_cbrt_f32(__x); } + +__DEVICE__ +float ceilf(float __x) { return __builtin_ceilf(__x); } + +__DEVICE__ +float copysignf(float __x, float __y) { return __builtin_copysignf(__x, __y); } + +__DEVICE__ +float cosf(float __x) { return __FAST_OR_SLOW(__cosf, __ocml_cos_f32)(__x); } + +__DEVICE__ +float coshf(float __x) { return __ocml_cosh_f32(__x); } + +__DEVICE__ +float cospif(float __x) { return __ocml_cospi_f32(__x); } + +__DEVICE__ +float cyl_bessel_i0f(float __x) { return __ocml_i0_f32(__x); } + +__DEVICE__ +float cyl_bessel_i1f(float __x) { return __ocml_i1_f32(__x); } + +__DEVICE__ +float erfcf(float __x) { return __ocml_erfc_f32(__x); } + +__DEVICE__ +float erfcinvf(float __x) { return __ocml_erfcinv_f32(__x); } + +__DEVICE__ +float erfcxf(float __x) { return __ocml_erfcx_f32(__x); } + +__DEVICE__ +float erff(float __x) { return __ocml_erf_f32(__x); } + +__DEVICE__ +float erfinvf(float __x) { return __ocml_erfinv_f32(__x); } + +__DEVICE__ +float exp10f(float __x) { return __builtin_exp10f(__x); } + +__DEVICE__ +float exp2f(float __x) { return __builtin_exp2f(__x); } + +__DEVICE__ +float expf(float __x) { return __builtin_expf(__x); } + +__DEVICE__ +float expm1f(float __x) { return __ocml_expm1_f32(__x); } + +__DEVICE__ +float fabsf(float __x) { return __builtin_fabsf(__x); } + +__DEVICE__ +float fdimf(float __x, float __y) { return __ocml_fdim_f32(__x, __y); } + +__DEVICE__ +float fdividef(float __x, float __y) { return __x / __y; } + +__DEVICE__ +float floorf(float __x) { return __builtin_floorf(__x); } + +__DEVICE__ +float fmaf(float __x, float __y, float __z) { + return __builtin_fmaf(__x, __y, __z); +} + +__DEVICE__ +float fmaxf(float __x, float __y) { return __builtin_fmaxf(__x, __y); } + +__DEVICE__ +float fminf(float __x, float __y) { return __builtin_fminf(__x, __y); } + +__DEVICE__ +float fmodf(float __x, float __y) { return __ocml_fmod_f32(__x, __y); } + +__DEVICE__ +float frexpf(float __x, int *__nptr) { + return __builtin_frexpf(__x, __nptr); +} + +__DEVICE__ +float hypotf(float __x, float __y) { return __ocml_hypot_f32(__x, __y); } + +__DEVICE__ +int ilogbf(float __x) { return __ocml_ilogb_f32(__x); } + +__DEVICE__ +__RETURN_TYPE __finitef(float __x) { return __builtin_isfinite(__x); } + +__DEVICE__ +__RETURN_TYPE __isinff(float __x) { return __builtin_isinf(__x); } + +__DEVICE__ +__RETURN_TYPE __isnanf(float __x) { return __builtin_isnan(__x); } + +__DEVICE__ +float j0f(float __x) { return __ocml_j0_f32(__x); } + +__DEVICE__ +float j1f(float __x) { return __ocml_j1_f32(__x); } + +__DEVICE__ +float jnf(int __n, float __x) { // TODO: we could use Ahmes multiplication + // and the Miller & Brown algorithm + // for linear recurrences to get O(log n) steps, but it's unclear if + // it'd be beneficial in this case. + if (__n == 0) + return j0f(__x); + if (__n == 1) + return j1f(__x); + + float __x0 = j0f(__x); + float __x1 = j1f(__x); + for (int __i = 1; __i < __n; ++__i) { + float __x2 = (2 * __i) / __x * __x1 - __x0; + __x0 = __x1; + __x1 = __x2; + } + + return __x1; +} + +__DEVICE__ +float ldexpf(float __x, int __e) { return __builtin_amdgcn_ldexpf(__x, __e); } + +__DEVICE__ +float lgammaf(float __x) { return __ocml_lgamma_f32(__x); } + +__DEVICE__ +long long int llrintf(float __x) { return __builtin_rintf(__x); } + +__DEVICE__ +long long int llroundf(float __x) { return __builtin_roundf(__x); } + +__DEVICE__ +float log10f(float __x) { return __builtin_log10f(__x); } + +__DEVICE__ +float log1pf(float __x) { return __ocml_log1p_f32(__x); } + +__DEVICE__ +float log2f(float __x) { return __FAST_OR_SLOW(__log2f, __builtin_log2f)(__x); } + +__DEVICE__ +float logbf(float __x) { return __ocml_logb_f32(__x); } + +__DEVICE__ +float logf(float __x) { return __FAST_OR_SLOW(__logf, __builtin_logf)(__x); } + +__DEVICE__ +long int lrintf(float __x) { return __builtin_rintf(__x); } + +__DEVICE__ +long int lroundf(float __x) { return __builtin_roundf(__x); } + +__DEVICE__ +float modff(float __x, float *__iptr) { + float __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + float __r = __ocml_modf_f32(__x, (__PRIVATE_AS float *)&__tmp); + *__iptr = __tmp; + return __r; +} + +__DEVICE__ +float nanf(const char *__tagp __attribute__((nonnull))) { + union { + float val; + struct ieee_float { + unsigned int mantissa : 22; + unsigned int quiet : 1; + unsigned int exponent : 8; + unsigned int sign : 1; + } bits; + } __tmp; + __static_assert_type_size_equal(sizeof(__tmp.val), sizeof(__tmp.bits)); + + __tmp.bits.sign = 0u; + __tmp.bits.exponent = ~0u; + __tmp.bits.quiet = 1u; + __tmp.bits.mantissa = __make_mantissa(__tagp); + + return __tmp.val; +} + +__DEVICE__ +float nearbyintf(float __x) { return __builtin_nearbyintf(__x); } + +__DEVICE__ +float nextafterf(float __x, float __y) { + return __ocml_nextafter_f32(__x, __y); +} + +__DEVICE__ +float norm3df(float __x, float __y, float __z) { + return __ocml_len3_f32(__x, __y, __z); +} + +__DEVICE__ +float norm4df(float __x, float __y, float __z, float __w) { + return __ocml_len4_f32(__x, __y, __z, __w); +} + +__DEVICE__ +float normcdff(float __x) { return __ocml_ncdf_f32(__x); } + +__DEVICE__ +float normcdfinvf(float __x) { return __ocml_ncdfinv_f32(__x); } + +__DEVICE__ +float normf(int __dim, + const float *__a) { // TODO: placeholder until OCML adds support. + float __r = 0; + while (__dim--) { + __r += __a[0] * __a[0]; + ++__a; + } + + return __builtin_sqrtf(__r); +} + +__DEVICE__ +float powf(float __x, float __y) { return __ocml_pow_f32(__x, __y); } + +__DEVICE__ +float powif(float __x, int __y) { return __ocml_pown_f32(__x, __y); } + +__DEVICE__ +float rcbrtf(float __x) { return __ocml_rcbrt_f32(__x); } + +__DEVICE__ +float remainderf(float __x, float __y) { + return __ocml_remainder_f32(__x, __y); +} + +__DEVICE__ +float remquof(float __x, float __y, int *__quo) { + int __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + float __r = __ocml_remquo_f32(__x, __y, (__PRIVATE_AS int *)&__tmp); + *__quo = __tmp; + + return __r; +} + +__DEVICE__ +float rhypotf(float __x, float __y) { return __ocml_rhypot_f32(__x, __y); } + +__DEVICE__ +float rintf(float __x) { return __builtin_rintf(__x); } + +__DEVICE__ +float rnorm3df(float __x, float __y, float __z) { + return __ocml_rlen3_f32(__x, __y, __z); +} + +__DEVICE__ +float rnorm4df(float __x, float __y, float __z, float __w) { + return __ocml_rlen4_f32(__x, __y, __z, __w); +} + +__DEVICE__ +float rnormf(int __dim, + const float *__a) { // TODO: placeholder until OCML adds support. + float __r = 0; + while (__dim--) { + __r += __a[0] * __a[0]; + ++__a; + } + + return __ocml_rsqrt_f32(__r); +} + +__DEVICE__ +float roundf(float __x) { return __builtin_roundf(__x); } + +__DEVICE__ +float rsqrtf(float __x) { return __ocml_rsqrt_f32(__x); } + +__DEVICE__ +float scalblnf(float __x, long int __n) { + if (__n > INT_MAX) + __n = INT_MAX; + else if (__n < INT_MIN) + __n = INT_MIN; + return __builtin_ldexpf(__x, (int)__n); +} + +__DEVICE__ +float scalbnf(float __x, int __n) { return __builtin_amdgcn_ldexpf(__x, __n); } + +__DEVICE__ +__RETURN_TYPE __signbitf(float __x) { return __builtin_signbitf(__x); } + +__DEVICE__ +void sincosf(float __x, float *__sinptr, float *__cosptr) { + float __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif +#ifdef __CLANG_CUDA_APPROX_TRANSCENDENTALS__ + __sincosf(__x, __sinptr, __cosptr); +#else + *__sinptr = __ocml_sincos_f32(__x, (__PRIVATE_AS float *)&__tmp); + *__cosptr = __tmp; +#endif +} + +__DEVICE__ +void sincospif(float __x, float *__sinptr, float *__cosptr) { + float __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + *__sinptr = __ocml_sincospi_f32(__x, (__PRIVATE_AS float *)&__tmp); + *__cosptr = __tmp; +} + +__DEVICE__ +float sinf(float __x) { return __FAST_OR_SLOW(__sinf, __ocml_sin_f32)(__x); } + +__DEVICE__ +float sinhf(float __x) { return __ocml_sinh_f32(__x); } + +__DEVICE__ +float sinpif(float __x) { return __ocml_sinpi_f32(__x); } + +__DEVICE__ +float sqrtf(float __x) { return __builtin_sqrtf(__x); } + +__DEVICE__ +float tanf(float __x) { return __ocml_tan_f32(__x); } + +__DEVICE__ +float tanhf(float __x) { return __ocml_tanh_f32(__x); } + +__DEVICE__ +float tgammaf(float __x) { return __ocml_tgamma_f32(__x); } + +__DEVICE__ +float truncf(float __x) { return __builtin_truncf(__x); } + +__DEVICE__ +float y0f(float __x) { return __ocml_y0_f32(__x); } + +__DEVICE__ +float y1f(float __x) { return __ocml_y1_f32(__x); } + +__DEVICE__ +float ynf(int __n, float __x) { // TODO: we could use Ahmes multiplication + // and the Miller & Brown algorithm + // for linear recurrences to get O(log n) steps, but it's unclear if + // it'd be beneficial in this case. Placeholder until OCML adds + // support. + if (__n == 0) + return y0f(__x); + if (__n == 1) + return y1f(__x); + + float __x0 = y0f(__x); + float __x1 = y1f(__x); + for (int __i = 1; __i < __n; ++__i) { + float __x2 = (2 * __i) / __x * __x1 - __x0; + __x0 = __x1; + __x1 = __x2; + } + + return __x1; +} + + +// END FLOAT + +// BEGIN DOUBLE +__DEVICE__ +double acos(double __x) { return __ocml_acos_f64(__x); } + +__DEVICE__ +double acosh(double __x) { return __ocml_acosh_f64(__x); } + +__DEVICE__ +double asin(double __x) { return __ocml_asin_f64(__x); } + +__DEVICE__ +double asinh(double __x) { return __ocml_asinh_f64(__x); } + +__DEVICE__ +double atan(double __x) { return __ocml_atan_f64(__x); } + +__DEVICE__ +double atan2(double __x, double __y) { return __ocml_atan2_f64(__x, __y); } + +__DEVICE__ +double atanh(double __x) { return __ocml_atanh_f64(__x); } + +__DEVICE__ +double cbrt(double __x) { return __ocml_cbrt_f64(__x); } + +__DEVICE__ +double ceil(double __x) { return __builtin_ceil(__x); } + +__DEVICE__ +double copysign(double __x, double __y) { + return __builtin_copysign(__x, __y); +} + +__DEVICE__ +double cos(double __x) { return __ocml_cos_f64(__x); } + +__DEVICE__ +double cosh(double __x) { return __ocml_cosh_f64(__x); } + +__DEVICE__ +double cospi(double __x) { return __ocml_cospi_f64(__x); } + +__DEVICE__ +double cyl_bessel_i0(double __x) { return __ocml_i0_f64(__x); } + +__DEVICE__ +double cyl_bessel_i1(double __x) { return __ocml_i1_f64(__x); } + +__DEVICE__ +double erf(double __x) { return __ocml_erf_f64(__x); } + +__DEVICE__ +double erfc(double __x) { return __ocml_erfc_f64(__x); } + +__DEVICE__ +double erfcinv(double __x) { return __ocml_erfcinv_f64(__x); } + +__DEVICE__ +double erfcx(double __x) { return __ocml_erfcx_f64(__x); } + +__DEVICE__ +double erfinv(double __x) { return __ocml_erfinv_f64(__x); } + +__DEVICE__ +double exp(double __x) { return __ocml_exp_f64(__x); } + +__DEVICE__ +double exp10(double __x) { return __ocml_exp10_f64(__x); } + +__DEVICE__ +double exp2(double __x) { return __ocml_exp2_f64(__x); } + +__DEVICE__ +double expm1(double __x) { return __ocml_expm1_f64(__x); } + +__DEVICE__ +double fabs(double __x) { return __builtin_fabs(__x); } + +__DEVICE__ +double fdim(double __x, double __y) { return __ocml_fdim_f64(__x, __y); } + +__DEVICE__ +double floor(double __x) { return __builtin_floor(__x); } + +__DEVICE__ +double fma(double __x, double __y, double __z) { + return __builtin_fma(__x, __y, __z); +} + +__DEVICE__ +double fmax(double __x, double __y) { return __builtin_fmax(__x, __y); } + +__DEVICE__ +double fmin(double __x, double __y) { return __builtin_fmin(__x, __y); } + +__DEVICE__ +double fmod(double __x, double __y) { return __ocml_fmod_f64(__x, __y); } + +__DEVICE__ +double frexp(double __x, int *__nptr) { + return __builtin_frexp(__x, __nptr); +} + +__DEVICE__ +double hypot(double __x, double __y) { return __ocml_hypot_f64(__x, __y); } + +__DEVICE__ +int ilogb(double __x) { return __ocml_ilogb_f64(__x); } + +__DEVICE__ +__RETURN_TYPE __finite(double __x) { return __builtin_isfinite(__x); } + +__DEVICE__ +__RETURN_TYPE __isinf(double __x) { return __builtin_isinf(__x); } + +__DEVICE__ +__RETURN_TYPE __isnan(double __x) { return __builtin_isnan(__x); } + +__DEVICE__ +double j0(double __x) { return __ocml_j0_f64(__x); } + +__DEVICE__ +double j1(double __x) { return __ocml_j1_f64(__x); } + +__DEVICE__ +double jn(int __n, double __x) { // TODO: we could use Ahmes multiplication + // and the Miller & Brown algorithm + // for linear recurrences to get O(log n) steps, but it's unclear if + // it'd be beneficial in this case. Placeholder until OCML adds + // support. + if (__n == 0) + return j0(__x); + if (__n == 1) + return j1(__x); + + double __x0 = j0(__x); + double __x1 = j1(__x); + for (int __i = 1; __i < __n; ++__i) { + double __x2 = (2 * __i) / __x * __x1 - __x0; + __x0 = __x1; + __x1 = __x2; + } + return __x1; +} + +__DEVICE__ +double ldexp(double __x, int __e) { return __builtin_amdgcn_ldexp(__x, __e); } + +__DEVICE__ +double lgamma(double __x) { return __ocml_lgamma_f64(__x); } + +__DEVICE__ +long long int llrint(double __x) { return __builtin_rint(__x); } + +__DEVICE__ +long long int llround(double __x) { return __builtin_round(__x); } + +__DEVICE__ +double log(double __x) { return __ocml_log_f64(__x); } + +__DEVICE__ +double log10(double __x) { return __ocml_log10_f64(__x); } + +__DEVICE__ +double log1p(double __x) { return __ocml_log1p_f64(__x); } + +__DEVICE__ +double log2(double __x) { return __ocml_log2_f64(__x); } + +__DEVICE__ +double logb(double __x) { return __ocml_logb_f64(__x); } + +__DEVICE__ +long int lrint(double __x) { return __builtin_rint(__x); } + +__DEVICE__ +long int lround(double __x) { return __builtin_round(__x); } + +__DEVICE__ +double modf(double __x, double *__iptr) { + double __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + double __r = __ocml_modf_f64(__x, (__PRIVATE_AS double *)&__tmp); + *__iptr = __tmp; + + return __r; +} + +__DEVICE__ +double nan(const char *__tagp) { +#if !_WIN32 + union { + double val; + struct ieee_double { + uint64_t mantissa : 51; + uint32_t quiet : 1; + uint32_t exponent : 11; + uint32_t sign : 1; + } bits; + } __tmp; + __static_assert_type_size_equal(sizeof(__tmp.val), sizeof(__tmp.bits)); + + __tmp.bits.sign = 0u; + __tmp.bits.exponent = ~0u; + __tmp.bits.quiet = 1u; + __tmp.bits.mantissa = __make_mantissa(__tagp); + + return __tmp.val; +#else + __static_assert_type_size_equal(sizeof(uint64_t), sizeof(double)); + uint64_t __val = __make_mantissa(__tagp); + __val |= 0xFFF << 51; + return *reinterpret_cast(&__val); +#endif +} + +__DEVICE__ +double nearbyint(double __x) { return __builtin_nearbyint(__x); } + +__DEVICE__ +double nextafter(double __x, double __y) { + return __ocml_nextafter_f64(__x, __y); +} + +__DEVICE__ +double norm(int __dim, + const double *__a) { // TODO: placeholder until OCML adds support. + double __r = 0; + while (__dim--) { + __r += __a[0] * __a[0]; + ++__a; + } + + return __builtin_sqrt(__r); +} + +__DEVICE__ +double norm3d(double __x, double __y, double __z) { + return __ocml_len3_f64(__x, __y, __z); +} + +__DEVICE__ +double norm4d(double __x, double __y, double __z, double __w) { + return __ocml_len4_f64(__x, __y, __z, __w); +} + +__DEVICE__ +double normcdf(double __x) { return __ocml_ncdf_f64(__x); } + +__DEVICE__ +double normcdfinv(double __x) { return __ocml_ncdfinv_f64(__x); } + +__DEVICE__ +double pow(double __x, double __y) { return __ocml_pow_f64(__x, __y); } + +__DEVICE__ +double powi(double __x, int __y) { return __ocml_pown_f64(__x, __y); } + +__DEVICE__ +double rcbrt(double __x) { return __ocml_rcbrt_f64(__x); } + +__DEVICE__ +double remainder(double __x, double __y) { + return __ocml_remainder_f64(__x, __y); +} + +__DEVICE__ +double remquo(double __x, double __y, int *__quo) { + int __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + double __r = __ocml_remquo_f64(__x, __y, (__PRIVATE_AS int *)&__tmp); + *__quo = __tmp; + + return __r; +} + +__DEVICE__ +double rhypot(double __x, double __y) { return __ocml_rhypot_f64(__x, __y); } + +__DEVICE__ +double rint(double __x) { return __builtin_rint(__x); } + +__DEVICE__ +double rnorm(int __dim, + const double *__a) { // TODO: placeholder until OCML adds support. + double __r = 0; + while (__dim--) { + __r += __a[0] * __a[0]; + ++__a; + } + + return __ocml_rsqrt_f64(__r); +} + +__DEVICE__ +double rnorm3d(double __x, double __y, double __z) { + return __ocml_rlen3_f64(__x, __y, __z); +} + +__DEVICE__ +double rnorm4d(double __x, double __y, double __z, double __w) { + return __ocml_rlen4_f64(__x, __y, __z, __w); +} + +__DEVICE__ +double round(double __x) { return __builtin_round(__x); } + +__DEVICE__ +double rsqrt(double __x) { return __ocml_rsqrt_f64(__x); } + +__DEVICE__ +double scalbln(double __x, long int __n) { + if (__n > INT_MAX) + __n = INT_MAX; + else if (__n < INT_MIN) + __n = INT_MIN; + return __builtin_ldexp(__x, (int)__n); +} +__DEVICE__ +double scalbn(double __x, int __n) { return __builtin_amdgcn_ldexp(__x, __n); } + +__DEVICE__ +__RETURN_TYPE __signbit(double __x) { return __builtin_signbit(__x); } + +__DEVICE__ +double sin(double __x) { return __ocml_sin_f64(__x); } + +__DEVICE__ +void sincos(double __x, double *__sinptr, double *__cosptr) { + double __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + *__sinptr = __ocml_sincos_f64(__x, (__PRIVATE_AS double *)&__tmp); + *__cosptr = __tmp; +} + +__DEVICE__ +void sincospi(double __x, double *__sinptr, double *__cosptr) { + double __tmp; +#ifdef __OPENMP_AMDGCN__ +#pragma omp allocate(__tmp) allocator(omp_thread_mem_alloc) +#endif + *__sinptr = __ocml_sincospi_f64(__x, (__PRIVATE_AS double *)&__tmp); + *__cosptr = __tmp; +} + +__DEVICE__ +double sinh(double __x) { return __ocml_sinh_f64(__x); } + +__DEVICE__ +double sinpi(double __x) { return __ocml_sinpi_f64(__x); } + +__DEVICE__ +double sqrt(double __x) { return __builtin_sqrt(__x); } + +__DEVICE__ +double tan(double __x) { return __ocml_tan_f64(__x); } + +__DEVICE__ +double tanh(double __x) { return __ocml_tanh_f64(__x); } + +__DEVICE__ +double tgamma(double __x) { return __ocml_tgamma_f64(__x); } + +__DEVICE__ +double trunc(double __x) { return __builtin_trunc(__x); } + +__DEVICE__ +double y0(double __x) { return __ocml_y0_f64(__x); } + +__DEVICE__ +double y1(double __x) { return __ocml_y1_f64(__x); } + +__DEVICE__ +double yn(int __n, double __x) { // TODO: we could use Ahmes multiplication + // and the Miller & Brown algorithm + // for linear recurrences to get O(log n) steps, but it's unclear if + // it'd be beneficial in this case. Placeholder until OCML adds + // support. + if (__n == 0) + return y0(__x); + if (__n == 1) + return y1(__x); + + double __x0 = y0(__x); + double __x1 = y1(__x); + for (int __i = 1; __i < __n; ++__i) { + double __x2 = (2 * __i) / __x * __x1 - __x0; + __x0 = __x1; + __x1 = __x2; + } + + return __x1; +} + +// BEGIN INTRINSICS +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __dadd_rd(double __x, double __y) { + return __ocml_add_rtn_f64(__x, __y); +} +__DEVICE__ +double __dadd_rn(double __x, double __y) { + return __ocml_add_rte_f64(__x, __y); +} +__DEVICE__ +double __dadd_ru(double __x, double __y) { + return __ocml_add_rtp_f64(__x, __y); +} +__DEVICE__ +double __dadd_rz(double __x, double __y) { + return __ocml_add_rtz_f64(__x, __y); +} +#else +__DEVICE__ +double __dadd_rn(double __x, double __y) { return __x + __y; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __ddiv_rd(double __x, double __y) { + return __ocml_div_rtn_f64(__x, __y); +} +__DEVICE__ +double __ddiv_rn(double __x, double __y) { + return __ocml_div_rte_f64(__x, __y); +} +__DEVICE__ +double __ddiv_ru(double __x, double __y) { + return __ocml_div_rtp_f64(__x, __y); +} +__DEVICE__ +double __ddiv_rz(double __x, double __y) { + return __ocml_div_rtz_f64(__x, __y); +} +#else +__DEVICE__ +double __ddiv_rn(double __x, double __y) { return __x / __y; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __dmul_rd(double __x, double __y) { + return __ocml_mul_rtn_f64(__x, __y); +} +__DEVICE__ +double __dmul_rn(double __x, double __y) { + return __ocml_mul_rte_f64(__x, __y); +} +__DEVICE__ +double __dmul_ru(double __x, double __y) { + return __ocml_mul_rtp_f64(__x, __y); +} +__DEVICE__ +double __dmul_rz(double __x, double __y) { + return __ocml_mul_rtz_f64(__x, __y); +} +#else +__DEVICE__ +double __dmul_rn(double __x, double __y) { return __x * __y; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __drcp_rd(double __x) { return __ocml_div_rtn_f64(1.0, __x); } +__DEVICE__ +double __drcp_rn(double __x) { return __ocml_div_rte_f64(1.0, __x); } +__DEVICE__ +double __drcp_ru(double __x) { return __ocml_div_rtp_f64(1.0, __x); } +__DEVICE__ +double __drcp_rz(double __x) { return __ocml_div_rtz_f64(1.0, __x); } +#else +__DEVICE__ +double __drcp_rn(double __x) { return 1.0 / __x; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __dsqrt_rd(double __x) { return __ocml_sqrt_rtn_f64(__x); } +__DEVICE__ +double __dsqrt_rn(double __x) { return __ocml_sqrt_rte_f64(__x); } +__DEVICE__ +double __dsqrt_ru(double __x) { return __ocml_sqrt_rtp_f64(__x); } +__DEVICE__ +double __dsqrt_rz(double __x) { return __ocml_sqrt_rtz_f64(__x); } +#else +__DEVICE__ +double __dsqrt_rn(double __x) { return __builtin_sqrt(__x); } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __dsub_rd(double __x, double __y) { + return __ocml_sub_rtn_f64(__x, __y); +} +__DEVICE__ +double __dsub_rn(double __x, double __y) { + return __ocml_sub_rte_f64(__x, __y); +} +__DEVICE__ +double __dsub_ru(double __x, double __y) { + return __ocml_sub_rtp_f64(__x, __y); +} +__DEVICE__ +double __dsub_rz(double __x, double __y) { + return __ocml_sub_rtz_f64(__x, __y); +} +#else +__DEVICE__ +double __dsub_rn(double __x, double __y) { return __x - __y; } +#endif + +#if defined OCML_BASIC_ROUNDED_OPERATIONS +__DEVICE__ +double __fma_rd(double __x, double __y, double __z) { + return __ocml_fma_rtn_f64(__x, __y, __z); +} +__DEVICE__ +double __fma_rn(double __x, double __y, double __z) { + return __ocml_fma_rte_f64(__x, __y, __z); +} +__DEVICE__ +double __fma_ru(double __x, double __y, double __z) { + return __ocml_fma_rtp_f64(__x, __y, __z); +} +__DEVICE__ +double __fma_rz(double __x, double __y, double __z) { + return __ocml_fma_rtz_f64(__x, __y, __z); +} +#else +__DEVICE__ +double __fma_rn(double __x, double __y, double __z) { + return __builtin_fma(__x, __y, __z); +} +#endif +// END INTRINSICS +// END DOUBLE + +// C only macros +#if !defined(__cplusplus) && __STDC_VERSION__ >= 201112L +#define isfinite(__x) _Generic((__x), float : __finitef, double : __finite)(__x) +#define isinf(__x) _Generic((__x), float : __isinff, double : __isinf)(__x) +#define isnan(__x) _Generic((__x), float : __isnanf, double : __isnan)(__x) +#define signbit(__x) \ + _Generic((__x), float : __signbitf, double : __signbit)(__x) +#endif // !defined(__cplusplus) && __STDC_VERSION__ >= 201112L + +#if defined(__cplusplus) +template __DEVICE__ T min(T __arg1, T __arg2) { + return (__arg1 < __arg2) ? __arg1 : __arg2; +} + +template __DEVICE__ T max(T __arg1, T __arg2) { + return (__arg1 > __arg2) ? __arg1 : __arg2; +} + +__DEVICE__ int min(int __arg1, int __arg2) { + return (__arg1 < __arg2) ? __arg1 : __arg2; +} +__DEVICE__ int max(int __arg1, int __arg2) { + return (__arg1 > __arg2) ? __arg1 : __arg2; +} + +__DEVICE__ +float max(float __x, float __y) { return __builtin_fmaxf(__x, __y); } + +__DEVICE__ +double max(double __x, double __y) { return __builtin_fmax(__x, __y); } + +__DEVICE__ +float min(float __x, float __y) { return __builtin_fminf(__x, __y); } + +__DEVICE__ +double min(double __x, double __y) { return __builtin_fmin(__x, __y); } + +// Define host min/max functions. +#if !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__) && \ + !defined(__HIP_NO_HOST_MIN_MAX_IN_GLOBAL_NAMESPACE__) + +// TODO: make this default to 1 after existing HIP apps adopting this change. +#ifndef __HIP_DEFINE_EXTENDED_HOST_MIN_MAX__ +#define __HIP_DEFINE_EXTENDED_HOST_MIN_MAX__ 0 +#endif + +#ifndef __HIP_DEFINE_MIXED_HOST_MIN_MAX__ +#define __HIP_DEFINE_MIXED_HOST_MIN_MAX__ 0 +#endif + +#pragma push_macro("DEFINE_MIN_MAX_FUNCTIONS") +#pragma push_macro("DEFINE_MIN_MAX_FUNCTIONS") +#define DEFINE_MIN_MAX_FUNCTIONS(ret_type, type1, type2) \ + inline ret_type min(const type1 __a, const type2 __b) { \ + return (__a < __b) ? __a : __b; \ + } \ + inline ret_type max(const type1 __a, const type2 __b) { \ + return (__a > __b) ? __a : __b; \ + } + +// Define min and max functions for same type comparisons +DEFINE_MIN_MAX_FUNCTIONS(int, int, int) + +#if __HIP_DEFINE_EXTENDED_HOST_MIN_MAX__ +DEFINE_MIN_MAX_FUNCTIONS(unsigned int, unsigned int, unsigned int) +DEFINE_MIN_MAX_FUNCTIONS(long, long, long) +DEFINE_MIN_MAX_FUNCTIONS(unsigned long, unsigned long, unsigned long) +DEFINE_MIN_MAX_FUNCTIONS(long long, long long, long long) +DEFINE_MIN_MAX_FUNCTIONS(unsigned long long, unsigned long long, + unsigned long long) +#endif // if __HIP_DEFINE_EXTENDED_HOST_MIN_MAX__ + +// The host min/max functions below accept mixed signed/unsigned integer +// parameters and perform unsigned comparisons, which may produce unexpected +// results if a signed integer was passed unintentionally. To avoid this +// happening silently, these overloaded functions are not defined by default. +// However, for compatibility with CUDA, they will be defined if users define +// __HIP_DEFINE_MIXED_HOST_MIN_MAX__. +#if __HIP_DEFINE_MIXED_HOST_MIN_MAX__ +DEFINE_MIN_MAX_FUNCTIONS(unsigned int, int, unsigned int) +DEFINE_MIN_MAX_FUNCTIONS(unsigned int, unsigned int, int) +DEFINE_MIN_MAX_FUNCTIONS(unsigned long, long, unsigned long) +DEFINE_MIN_MAX_FUNCTIONS(unsigned long, unsigned long, long) +DEFINE_MIN_MAX_FUNCTIONS(unsigned long long, long long, unsigned long long) +DEFINE_MIN_MAX_FUNCTIONS(unsigned long long, unsigned long long, long long) +#endif // if __HIP_DEFINE_MIXED_HOST_MIN_MAX__ + +// Floating-point comparisons using built-in functions +#if __HIP_DEFINE_EXTENDED_HOST_MIN_MAX__ +inline float min(float const __a, float const __b) { + return __builtin_fminf(__a, __b); +} +inline double min(double const __a, double const __b) { + return __builtin_fmin(__a, __b); +} +inline double min(float const __a, double const __b) { + return __builtin_fmin(__a, __b); +} +inline double min(double const __a, float const __b) { + return __builtin_fmin(__a, __b); +} + +inline float max(float const __a, float const __b) { + return __builtin_fmaxf(__a, __b); +} +inline double max(double const __a, double const __b) { + return __builtin_fmax(__a, __b); +} +inline double max(float const __a, double const __b) { + return __builtin_fmax(__a, __b); +} +inline double max(double const __a, float const __b) { + return __builtin_fmax(__a, __b); +} +#endif // if __HIP_DEFINE_EXTENDED_HOST_MIN_MAX__ + +#pragma pop_macro("DEFINE_MIN_MAX_FUNCTIONS") + +#endif // !defined(__HIPCC_RTC__) && !defined(__OPENMP_AMDGCN__) && + // !defined(__HIP_NO_HOST_MIN_MAX_IN_GLOBAL_NAMESPACE__) +#endif + +#pragma pop_macro("__DEVICE__") +#pragma pop_macro("__PRIVATE_AS") +#pragma pop_macro("__RETURN_TYPE") +#pragma pop_macro("__FAST_OR_SLOW") + +#endif // __CLANG_GPU_DISABLE_MATH_WRAPPERS +#endif // __CLANG_HIP_MATH_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_runtime_wrapper.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_runtime_wrapper.h new file mode 100755 index 0000000..da1e39a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_runtime_wrapper.h @@ -0,0 +1,162 @@ +/*===---- __clang_hip_runtime_wrapper.h - HIP runtime support ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * WARNING: This header is intended to be directly -include'd by + * the compiler and is not supposed to be included by users. + * + */ + +#ifndef __CLANG_HIP_RUNTIME_WRAPPER_H__ +#define __CLANG_HIP_RUNTIME_WRAPPER_H__ + +#if __HIP__ + +#define __host__ __attribute__((host)) +#define __device__ __attribute__((device)) +#define __global__ __attribute__((global)) +#define __shared__ __attribute__((shared)) +#define __constant__ __attribute__((constant)) +#define __managed__ __attribute__((managed)) + +#if !defined(__cplusplus) || __cplusplus < 201103L + #define nullptr NULL; +#endif + +#ifdef __cplusplus +extern "C" { + __attribute__((__visibility__("default"))) + __attribute__((weak)) + __attribute__((noreturn)) + __device__ void __cxa_pure_virtual(void) { + __builtin_trap(); + } + __attribute__((__visibility__("default"))) + __attribute__((weak)) + __attribute__((noreturn)) + __device__ void __cxa_deleted_virtual(void) { + __builtin_trap(); + } +} +#endif //__cplusplus + +#if !defined(__HIPCC_RTC__) +#if __has_include("hip/hip_version.h") +#include "hip/hip_version.h" +#endif // __has_include("hip/hip_version.h") +#endif // __HIPCC_RTC__ + +typedef __SIZE_TYPE__ __hip_size_t; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 405 +__device__ unsigned long long __ockl_dm_alloc(unsigned long long __size); +__device__ void __ockl_dm_dealloc(unsigned long long __addr); +#if __has_feature(address_sanitizer) +__device__ unsigned long long __asan_malloc_impl(unsigned long long __size, + unsigned long long __pc); +__device__ void __asan_free_impl(unsigned long long __addr, + unsigned long long __pc); +__attribute__((noinline, weak)) __device__ void *malloc(__hip_size_t __size) { + unsigned long long __pc = (unsigned long long)__builtin_return_address(0); + return (void *)__asan_malloc_impl(__size, __pc); +} +__attribute__((noinline, weak)) __device__ void free(void *__ptr) { + unsigned long long __pc = (unsigned long long)__builtin_return_address(0); + __asan_free_impl((unsigned long long)__ptr, __pc); +} +#else // __has_feature(address_sanitizer) +__attribute__((weak)) inline __device__ void *malloc(__hip_size_t __size) { + return (void *) __ockl_dm_alloc(__size); +} +__attribute__((weak)) inline __device__ void free(void *__ptr) { + __ockl_dm_dealloc((unsigned long long)__ptr); +} +#endif // __has_feature(address_sanitizer) +#else // HIP version check +#if __HIP_ENABLE_DEVICE_MALLOC__ +__device__ void *__hip_malloc(__hip_size_t __size); +__device__ void *__hip_free(void *__ptr); +__attribute__((weak)) inline __device__ void *malloc(__hip_size_t __size) { + return __hip_malloc(__size); +} +__attribute__((weak)) inline __device__ void free(void *__ptr) { + __hip_free(__ptr); +} +#else // __HIP_ENABLE_DEVICE_MALLOC__ +__attribute__((weak)) inline __device__ void *malloc(__hip_size_t __size) { + __builtin_trap(); + return (void *)0; +} +__attribute__((weak)) inline __device__ void free(void *__ptr) { + __builtin_trap(); +} +#endif // __HIP_ENABLE_DEVICE_MALLOC__ +#endif // HIP version check + +#ifdef __cplusplus +} // extern "C" +#endif //__cplusplus + +#if !defined(__HIPCC_RTC__) +#include +#include +#include +#if __has_include("hip/hip_version.h") +#include "hip/hip_version.h" +#endif // __has_include("hip/hip_version.h") +#else +typedef __SIZE_TYPE__ size_t; +// Define macros which are needed to declare HIP device API's without standard +// C/C++ headers. This is for readability so that these API's can be written +// the same way as non-hipRTC use case. These macros need to be popped so that +// they do not pollute users' name space. +#pragma push_macro("NULL") +#pragma push_macro("uint32_t") +#pragma push_macro("uint64_t") +#pragma push_macro("CHAR_BIT") +#pragma push_macro("INT_MAX") +#pragma push_macro("INT_MIN") +#define NULL (void *)0 +#define uint32_t __UINT32_TYPE__ +#define uint64_t __UINT64_TYPE__ +#define CHAR_BIT __CHAR_BIT__ +#define INT_MAX __INTMAX_MAX__ +#define INT_MIN (-__INT_MAX__ - 1) +#endif // __HIPCC_RTC__ + +#include <__clang_hip_libdevice_declares.h> +#include <__clang_hip_math.h> +#include <__clang_hip_stdlib.h> + +#if defined(__HIPCC_RTC__) +#include <__clang_hip_cmath.h> +#else +#include <__clang_cuda_math_forward_declares.h> +#include <__clang_hip_cmath.h> +#include <__clang_cuda_complex_builtins.h> +#include +#include +#include +#endif // __HIPCC_RTC__ + +#define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1 +#if defined(__HIPCC_RTC__) +#pragma pop_macro("NULL") +#pragma pop_macro("uint32_t") +#pragma pop_macro("uint64_t") +#pragma pop_macro("CHAR_BIT") +#pragma pop_macro("INT_MAX") +#pragma pop_macro("INT_MIN") +#endif // __HIPCC_RTC__ +#endif // __HIP__ +#endif // __CLANG_HIP_RUNTIME_WRAPPER_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_stdlib.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_stdlib.h new file mode 100755 index 0000000..bd770e2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_hip_stdlib.h @@ -0,0 +1,43 @@ +/*===---- __clang_hip_stdlib.h - Device-side HIP math support --------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CLANG_HIP_STDLIB_H__ + +#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__) +#error "This file is for HIP and OpenMP AMDGCN device compilation only." +#endif + +#if !defined(__cplusplus) + +#include + +#ifdef __OPENMP_AMDGCN__ +#define __DEVICE__ static inline __attribute__((always_inline, nothrow)) +#else +#define __DEVICE__ static __device__ inline __attribute__((always_inline)) +#endif + +__DEVICE__ +int abs(int __x) { + int __sgn = __x >> (sizeof(int) * CHAR_BIT - 1); + return (__x ^ __sgn) - __sgn; +} +__DEVICE__ +long labs(long __x) { + long __sgn = __x >> (sizeof(long) * CHAR_BIT - 1); + return (__x ^ __sgn) - __sgn; +} +__DEVICE__ +long long llabs(long long __x) { + long long __sgn = __x >> (sizeof(long long) * CHAR_BIT - 1); + return (__x ^ __sgn) - __sgn; +} + +#endif // !defined(__cplusplus) + +#endif // #define __CLANG_HIP_STDLIB_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_spirv_builtins.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_spirv_builtins.h new file mode 100755 index 0000000..9915cdf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__clang_spirv_builtins.h @@ -0,0 +1,217 @@ +/*===---- spirv_builtin_vars.h - SPIR-V built-in ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __SPIRV_BUILTIN_VARS_H +#define __SPIRV_BUILTIN_VARS_H + +#if __cplusplus >= 201103L +#define __SPIRV_NOEXCEPT noexcept +#else +#define __SPIRV_NOEXCEPT +#endif + +#pragma push_macro("__size_t") +#pragma push_macro("__uint32_t") +#pragma push_macro("__uint64_t") +#define __size_t __SIZE_TYPE__ +#define __uint32_t __UINT32_TYPE__ + +#define __SPIRV_overloadable __attribute__((overloadable)) +#define __SPIRV_convergent __attribute__((convergent)) +#define __SPIRV_inline __attribute__((always_inline)) + +#define __global __attribute__((opencl_global)) +#define __local __attribute__((opencl_local)) +#define __private __attribute__((opencl_private)) +#define __constant __attribute__((opencl_constant)) +#ifdef __SYCL_DEVICE_ONLY__ +#define __generic +#else +#define __generic __attribute__((opencl_generic)) +#endif + +// Check if SPIR-V builtins are supported. +// As the translator doesn't use the LLVM intrinsics (which would be emitted if +// we use the SPIR-V builtins) we can't rely on the SPIRV32/SPIRV64 etc macros +// to establish if we can use the builtin alias. We disable builtin altogether +// if we do not intent to use the backend. So instead of use target macros, rely +// on a __has_builtin test. +#if (__has_builtin(__builtin_spirv_num_workgroups)) +#define __SPIRV_BUILTIN_ALIAS(builtin) \ + __attribute__((clang_builtin_alias(builtin))) +#else +#define __SPIRV_BUILTIN_ALIAS(builtin) +#endif + +// Builtin IDs and sizes + +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_num_workgroups) __size_t + __spirv_NumWorkgroups(int); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_workgroup_size) __size_t + __spirv_WorkgroupSize(int); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_workgroup_id) __size_t + __spirv_WorkgroupId(int); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_local_invocation_id) __size_t + __spirv_LocalInvocationId(int); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_global_invocation_id) __size_t + __spirv_GlobalInvocationId(int); + +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_global_size) __size_t + __spirv_GlobalSize(int); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_global_offset) __size_t + __spirv_GlobalOffset(int); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_subgroup_size) __uint32_t + __spirv_SubgroupSize(); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_subgroup_max_size) __uint32_t + __spirv_SubgroupMaxSize(); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_num_subgroups) __uint32_t + __spirv_NumSubgroups(); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_subgroup_id) __uint32_t + __spirv_SubgroupId(); +extern __SPIRV_BUILTIN_ALIAS(__builtin_spirv_subgroup_local_invocation_id) + __uint32_t __spirv_SubgroupLocalInvocationId(); + +// OpGenericCastToPtrExplicit + +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__global void *__spirv_GenericCastToPtrExplicit_ToGlobal(__generic void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__global const void * +__spirv_GenericCastToPtrExplicit_ToGlobal(__generic const void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__global volatile void * +__spirv_GenericCastToPtrExplicit_ToGlobal(__generic volatile void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__global const volatile void * +__spirv_GenericCastToPtrExplicit_ToGlobal(__generic const volatile void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__local void *__spirv_GenericCastToPtrExplicit_ToLocal(__generic void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__local const void * +__spirv_GenericCastToPtrExplicit_ToLocal(__generic const void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__local volatile void * +__spirv_GenericCastToPtrExplicit_ToLocal(__generic volatile void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__local const volatile void * +__spirv_GenericCastToPtrExplicit_ToLocal(__generic const volatile void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__private void * +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__private const void * +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic const void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__private volatile void * +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic volatile void *, + int) __SPIRV_NOEXCEPT; +extern __SPIRV_overloadable +__SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) +__private const volatile void * +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic const volatile void *, + int) __SPIRV_NOEXCEPT; + +// OpGenericCastToPtr + +static __SPIRV_overloadable __SPIRV_inline __global void * +__spirv_GenericCastToPtr_ToGlobal(__generic void *p, int) __SPIRV_NOEXCEPT { + return (__global void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __global const void * +__spirv_GenericCastToPtr_ToGlobal(__generic const void *p, + int) __SPIRV_NOEXCEPT { + return (__global const void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __global volatile void * +__spirv_GenericCastToPtr_ToGlobal(__generic volatile void *p, + int) __SPIRV_NOEXCEPT { + return (__global volatile void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __global const volatile void * +__spirv_GenericCastToPtr_ToGlobal(__generic const volatile void *p, + int) __SPIRV_NOEXCEPT { + return (__global const volatile void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __local void * +__spirv_GenericCastToPtr_ToLocal(__generic void *p, int) __SPIRV_NOEXCEPT { + return (__local void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __local const void * +__spirv_GenericCastToPtr_ToLocal(__generic const void *p, + int) __SPIRV_NOEXCEPT { + return (__local const void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __local volatile void * +__spirv_GenericCastToPtr_ToLocal(__generic volatile void *p, + int) __SPIRV_NOEXCEPT { + return (__local volatile void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __local const volatile void * +__spirv_GenericCastToPtr_ToLocal(__generic const volatile void *p, + int) __SPIRV_NOEXCEPT { + return (__local const volatile void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __private void * +__spirv_GenericCastToPtr_ToPrivate(__generic void *p, int) __SPIRV_NOEXCEPT { + return (__private void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __private const void * +__spirv_GenericCastToPtr_ToPrivate(__generic const void *p, + int) __SPIRV_NOEXCEPT { + return (__private const void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __private volatile void * +__spirv_GenericCastToPtr_ToPrivate(__generic volatile void *p, + int) __SPIRV_NOEXCEPT { + return (__private volatile void *)p; +} +static __SPIRV_overloadable __SPIRV_inline __private const volatile void * +__spirv_GenericCastToPtr_ToPrivate(__generic const volatile void *p, + int) __SPIRV_NOEXCEPT { + return (__private const volatile void *)p; +} + +#pragma pop_macro("__size_t") +#pragma pop_macro("__uint32_t") +#pragma pop_macro("__uint64_t") + +#undef __SPIRV_overloadable +#undef __SPIRV_convergent +#undef __SPIRV_inline + +#undef __global +#undef __local +#undef __constant +#undef __generic + +#undef __SPIRV_BUILTIN_ALIAS +#undef __SPIRV_NOEXCEPT + +#endif /* __SPIRV_BUILTIN_VARS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg___gnuc_va_list.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg___gnuc_va_list.h new file mode 100755 index 0000000..2a0a7e8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg___gnuc_va_list.h @@ -0,0 +1,13 @@ +/*===---- __stdarg___gnuc_va_list.h - Definition of __gnuc_va_list ---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST +typedef __builtin_va_list __gnuc_va_list; +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg___va_copy.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg___va_copy.h new file mode 100755 index 0000000..e433e18 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg___va_copy.h @@ -0,0 +1,12 @@ +/*===---- __stdarg___va_copy.h - Definition of __va_copy -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __va_copy +#define __va_copy(d, s) __builtin_va_copy(d, s) +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_header_macro.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_header_macro.h new file mode 100755 index 0000000..beb92ee --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_header_macro.h @@ -0,0 +1,12 @@ +/*===---- __stdarg_header_macro.h ------------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDARG_H +#define __STDARG_H +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_arg.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_arg.h new file mode 100755 index 0000000..ebdb6f9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_arg.h @@ -0,0 +1,22 @@ +/*===---- __stdarg_va_arg.h - Definitions of va_start, va_arg, va_end-------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef va_arg + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +/* C23 uses a special builtin. */ +#define va_start(...) __builtin_c23_va_start(__VA_ARGS__) +#else +/* Versions before C23 do require the second parameter. */ +#define va_start(ap, param) __builtin_va_start(ap, param) +#endif +#define va_end(ap) __builtin_va_end(ap) +#define va_arg(ap, type) __builtin_va_arg(ap, type) + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_copy.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_copy.h new file mode 100755 index 0000000..8645328 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_copy.h @@ -0,0 +1,12 @@ +/*===---- __stdarg_va_copy.h - Definition of va_copy------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef va_copy +#define va_copy(dest, src) __builtin_va_copy(dest, src) +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_list.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_list.h new file mode 100755 index 0000000..20c2e2c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stdarg_va_list.h @@ -0,0 +1,13 @@ +/*===---- __stdarg_va_list.h - Definition of va_list -----------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _VA_LIST +#define _VA_LIST +typedef __builtin_va_list va_list; +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_header_macro.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_header_macro.h new file mode 100755 index 0000000..db5fb3c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_header_macro.h @@ -0,0 +1,12 @@ +/*===---- __stddef_header_macro.h ------------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDDEF_H +#define __STDDEF_H +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_max_align_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_max_align_t.h new file mode 100755 index 0000000..512606a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_max_align_t.h @@ -0,0 +1,27 @@ +/*===---- __stddef_max_align_t.h - Definition of max_align_t ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_MAX_ALIGN_T_DEFINED +#define __CLANG_MAX_ALIGN_T_DEFINED + +#if defined(_MSC_VER) +typedef double max_align_t; +#elif defined(__APPLE__) +typedef long double max_align_t; +#else +// Define 'max_align_t' to match the GCC definition. +typedef struct { + long long __clang_max_align_nonce1 + __attribute__((__aligned__(__alignof__(long long)))); + long double __clang_max_align_nonce2 + __attribute__((__aligned__(__alignof__(long double)))); +} max_align_t; +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_null.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_null.h new file mode 100755 index 0000000..c10bd2d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_null.h @@ -0,0 +1,29 @@ +/*===---- __stddef_null.h - Definition of NULL -----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined(NULL) || !__building_module(_Builtin_stddef) + +/* linux/stddef.h will define NULL to 0. glibc (and other) headers then define + * __need_NULL and rely on stddef.h to redefine NULL to the correct value again. + * Modules don't support redefining macros like that, but support that pattern + * in the non-modules case. + */ +#undef NULL + +#ifdef __cplusplus +#if !defined(__MINGW32__) && !defined(_MSC_VER) +#define NULL __null +#else +#define NULL 0 +#endif +#else +#define NULL ((void*)0) +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_nullptr_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_nullptr_t.h new file mode 100755 index 0000000..7f3fbe6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_nullptr_t.h @@ -0,0 +1,29 @@ +/*===---- __stddef_nullptr_t.h - Definition of nullptr_t -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(_NULLPTR_T) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define _NULLPTR_T + +#ifdef __cplusplus +#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED) +namespace std { +typedef decltype(nullptr) nullptr_t; +} +using ::std::nullptr_t; +#endif +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +typedef typeof(nullptr) nullptr_t; +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_offsetof.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_offsetof.h new file mode 100755 index 0000000..84172c6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_offsetof.h @@ -0,0 +1,17 @@ +/*===---- __stddef_offsetof.h - Definition of offsetof ---------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(offsetof) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define offsetof(t, d) __builtin_offsetof(t, d) +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_ptrdiff_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_ptrdiff_t.h new file mode 100755 index 0000000..fd3c893 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_ptrdiff_t.h @@ -0,0 +1,20 @@ +/*===---- __stddef_ptrdiff_t.h - Definition of ptrdiff_t -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(_PTRDIFF_T) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define _PTRDIFF_T + +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_rsize_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_rsize_t.h new file mode 100755 index 0000000..dd433d4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_rsize_t.h @@ -0,0 +1,20 @@ +/*===---- __stddef_rsize_t.h - Definition of rsize_t -----------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(_RSIZE_T) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define _RSIZE_T + +typedef __SIZE_TYPE__ rsize_t; + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_size_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_size_t.h new file mode 100755 index 0000000..3dd7b1f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_size_t.h @@ -0,0 +1,20 @@ +/*===---- __stddef_size_t.h - Definition of size_t -------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(_SIZE_T) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define _SIZE_T + +typedef __SIZE_TYPE__ size_t; + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_unreachable.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_unreachable.h new file mode 100755 index 0000000..61df43e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_unreachable.h @@ -0,0 +1,21 @@ +/*===---- __stddef_unreachable.h - Definition of unreachable ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __cplusplus + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(unreachable) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define unreachable() __builtin_unreachable() +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_wchar_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_wchar_t.h new file mode 100755 index 0000000..bd69f63 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_wchar_t.h @@ -0,0 +1,28 @@ +/*===---- __stddef_wchar.h - Definition of wchar_t -------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined(__cplusplus) || (defined(_MSC_VER) && !_NATIVE_WCHAR_T_DEFINED) + +/* + * When -fbuiltin-headers-in-system-modules is set this is a non-modular header + * and needs to behave as if it was textual. + */ +#if !defined(_WCHAR_T) || \ + (__has_feature(modules) && !__building_module(_Builtin_stddef)) +#define _WCHAR_T + +#ifdef _MSC_EXTENSIONS +#define _WCHAR_T_DEFINED +#endif + +typedef __WCHAR_TYPE__ wchar_t; + +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_wint_t.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_wint_t.h new file mode 100755 index 0000000..0aa2915 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__stddef_wint_t.h @@ -0,0 +1,15 @@ +/*===---- __stddef_wint.h - Definition of wint_t ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _WINT_T +#define _WINT_T + +typedef __WINT_TYPE__ wint_t; + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__wmmintrin_aes.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__wmmintrin_aes.h new file mode 100755 index 0000000..3010b38 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__wmmintrin_aes.h @@ -0,0 +1,140 @@ +/*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __WMMINTRIN_H +#error "Never use <__wmmintrin_aes.h> directly; include instead." +#endif + +#ifndef __WMMINTRIN_AES_H +#define __WMMINTRIN_AES_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes"), __min_vector_width__(128))) + +/// Performs a single round of AES encryption using the Equivalent +/// Inverse Cipher, transforming the state value from the first source +/// operand using a 128-bit round key value contained in the second source +/// operand, and writes the result to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VAESENC instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the state value. +/// \param __R +/// A 128-bit integer vector containing the round key value. +/// \returns A 128-bit integer vector containing the encrypted value. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_aesenc_si128(__m128i __V, __m128i __R) +{ + return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R); +} + +/// Performs the final round of AES encryption using the Equivalent +/// Inverse Cipher, transforming the state value from the first source +/// operand using a 128-bit round key value contained in the second source +/// operand, and writes the result to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VAESENCLAST instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the state value. +/// \param __R +/// A 128-bit integer vector containing the round key value. +/// \returns A 128-bit integer vector containing the encrypted value. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_aesenclast_si128(__m128i __V, __m128i __R) +{ + return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R); +} + +/// Performs a single round of AES decryption using the Equivalent +/// Inverse Cipher, transforming the state value from the first source +/// operand using a 128-bit round key value contained in the second source +/// operand, and writes the result to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VAESDEC instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the state value. +/// \param __R +/// A 128-bit integer vector containing the round key value. +/// \returns A 128-bit integer vector containing the decrypted value. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_aesdec_si128(__m128i __V, __m128i __R) +{ + return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R); +} + +/// Performs the final round of AES decryption using the Equivalent +/// Inverse Cipher, transforming the state value from the first source +/// operand using a 128-bit round key value contained in the second source +/// operand, and writes the result to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VAESDECLAST instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the state value. +/// \param __R +/// A 128-bit integer vector containing the round key value. +/// \returns A 128-bit integer vector containing the decrypted value. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_aesdeclast_si128(__m128i __V, __m128i __R) +{ + return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R); +} + +/// Applies the AES InvMixColumns() transformation to an expanded key +/// contained in the source operand, and writes the result to the +/// destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VAESIMC instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the expanded key. +/// \returns A 128-bit integer vector containing the transformed value. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_aesimc_si128(__m128i __V) +{ + return (__m128i)__builtin_ia32_aesimc128((__v2di)__V); +} + +/// Generates a round key for AES encryption, operating on 128-bit data +/// specified in the first source operand and using an 8-bit round constant +/// specified by the second source operand, and writes the result to the +/// destination. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R); +/// \endcode +/// +/// This intrinsic corresponds to the AESKEYGENASSIST instruction. +/// +/// \param C +/// A 128-bit integer vector that is used to generate the AES encryption key. +/// \param R +/// An 8-bit round constant used to generate the AES encryption key. +/// \returns A 128-bit round key for AES encryption. +#define _mm_aeskeygenassist_si128(C, R) \ + ((__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R))) + +#undef __DEFAULT_FN_ATTRS + +#endif /* __WMMINTRIN_AES_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__wmmintrin_pclmul.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__wmmintrin_pclmul.h new file mode 100755 index 0000000..c9a6d50 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/__wmmintrin_pclmul.h @@ -0,0 +1,48 @@ +/*===---- __wmmintrin_pclmul.h - PCMUL intrinsics ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __WMMINTRIN_H +#error "Never use <__wmmintrin_pclmul.h> directly; include instead." +#endif + +#ifndef __WMMINTRIN_PCLMUL_H +#define __WMMINTRIN_PCLMUL_H + +/// Multiplies two 64-bit integer values, which are selected from source +/// operands using the immediate-value operand. The multiplication is a +/// carry-less multiplication, and the 128-bit integer product is stored in +/// the destination. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_clmulepi64_si128(__m128i X, __m128i Y, const int I); +/// \endcode +/// +/// This intrinsic corresponds to the VPCLMULQDQ instruction. +/// +/// \param X +/// A 128-bit vector of [2 x i64] containing one of the source operands. +/// \param Y +/// A 128-bit vector of [2 x i64] containing one of the source operands. +/// \param I +/// An immediate value specifying which 64-bit values to select from the +/// operands. Bit 0 is used to select a value from operand \a X, and bit +/// 4 is used to select a value from operand \a Y: \n +/// Bit[0]=0 indicates that bits[63:0] of operand \a X are used. \n +/// Bit[0]=1 indicates that bits[127:64] of operand \a X are used. \n +/// Bit[4]=0 indicates that bits[63:0] of operand \a Y are used. \n +/// Bit[4]=1 indicates that bits[127:64] of operand \a Y are used. +/// \returns The 128-bit integer vector containing the result of the carry-less +/// multiplication of the selected 64-bit values. +#define _mm_clmulepi64_si128(X, Y, I) \ + ((__m128i)__builtin_ia32_pclmulqdq128((__v2di)(__m128i)(X), \ + (__v2di)(__m128i)(Y), (char)(I))) + +#endif /* __WMMINTRIN_PCLMUL_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/adcintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/adcintrin.h new file mode 100755 index 0000000..5c68fce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/adcintrin.h @@ -0,0 +1,165 @@ +/*===---- adcintrin.h - ADC intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __ADCINTRIN_H +#define __ADCINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +/* Define the default attributes for the functions in this file. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__)) constexpr +#else +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) +#endif + +/* Use C++ inline semantics in C++, GNU inline for C mode. */ +#if defined(__cplusplus) +#define __INLINE __inline +#else +#define __INLINE static __inline +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated +/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory +/// at \a __p, and returns the 8-bit carry-out (carry flag). +/// +/// \code{.operation} +/// temp := (__cf == 0) ? 0 : 1 +/// Store32(__p, __x + __y + temp) +/// result := CF +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ADC instruction. +/// +/// \param __cf +/// The 8-bit unsigned carry flag; any non-zero value indicates carry. +/// \param __x +/// A 32-bit unsigned addend. +/// \param __y +/// A 32-bit unsigned addend. +/// \param __p +/// Pointer to memory for storing the sum. +/// \returns The 8-bit unsigned carry-out value. +__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarry_u32(unsigned char __cf, + unsigned int __x, + unsigned int __y, + unsigned int *__p) { + return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p); +} + +/// Adds unsigned 32-bit integer \a __y to 0 or 1 as indicated by the carry +/// flag \a __cf, and subtracts the result from unsigned 32-bit integer +/// \a __x. Stores the unsigned 32-bit difference in the memory at \a __p, +/// and returns the 8-bit carry-out (carry or overflow flag). +/// +/// \code{.operation} +/// temp := (__cf == 0) ? 0 : 1 +/// Store32(__p, __x - (__y + temp)) +/// result := CF +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SBB instruction. +/// +/// \param __cf +/// The 8-bit unsigned carry flag; any non-zero value indicates carry. +/// \param __x +/// The 32-bit unsigned minuend. +/// \param __y +/// The 32-bit unsigned subtrahend. +/// \param __p +/// Pointer to memory for storing the difference. +/// \returns The 8-bit unsigned carry-out value. +__INLINE unsigned char __DEFAULT_FN_ATTRS _subborrow_u32(unsigned char __cf, + unsigned int __x, + unsigned int __y, + unsigned int *__p) { + return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p); +} + +#ifdef __x86_64__ +/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated +/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory +/// at \a __p, and returns the 8-bit carry-out (carry flag). +/// +/// \code{.operation} +/// temp := (__cf == 0) ? 0 : 1 +/// Store64(__p, __x + __y + temp) +/// result := CF +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ADC instruction. +/// +/// \param __cf +/// The 8-bit unsigned carry flag; any non-zero value indicates carry. +/// \param __x +/// A 64-bit unsigned addend. +/// \param __y +/// A 64-bit unsigned addend. +/// \param __p +/// Pointer to memory for storing the sum. +/// \returns The 8-bit unsigned carry-out value. +__INLINE unsigned char __DEFAULT_FN_ATTRS +_addcarry_u64(unsigned char __cf, unsigned long long __x, + unsigned long long __y, unsigned long long *__p) { + return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); +} + +/// Adds unsigned 64-bit integer \a __y to 0 or 1 as indicated by the carry +/// flag \a __cf, and subtracts the result from unsigned 64-bit integer +/// \a __x. Stores the unsigned 64-bit difference in the memory at \a __p, +/// and returns the 8-bit carry-out (carry or overflow flag). +/// +/// \code{.operation} +/// temp := (__cf == 0) ? 0 : 1 +/// Store64(__p, __x - (__y + temp)) +/// result := CF +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ADC instruction. +/// +/// \param __cf +/// The 8-bit unsigned carry flag; any non-zero value indicates carry. +/// \param __x +/// The 64-bit unsigned minuend. +/// \param __y +/// The 64-bit unsigned subtrahend. +/// \param __p +/// Pointer to memory for storing the difference. +/// \returns The 8-bit unsigned carry-out value. +__INLINE unsigned char __DEFAULT_FN_ATTRS +_subborrow_u64(unsigned char __cf, unsigned long long __x, + unsigned long long __y, unsigned long long *__p) { + return __builtin_ia32_subborrow_u64(__cf, __x, __y, __p); +} +#endif + +#if defined(__cplusplus) +} +#endif + +#undef __INLINE +#undef __DEFAULT_FN_ATTRS + +#endif /* __ADCINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/adxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/adxintrin.h new file mode 100755 index 0000000..055e91f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/adxintrin.h @@ -0,0 +1,107 @@ +/*===---- adxintrin.h - ADX intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __ADXINTRIN_H +#define __ADXINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("adx"))) constexpr +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("adx"))) +#endif + +/* Use C++ inline semantics in C++, GNU inline for C mode. */ +#if defined(__cplusplus) +#define __INLINE __inline +#else +#define __INLINE static __inline +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +/* Intrinsics that are available only if __ADX__ is defined. */ + +/// Adds unsigned 32-bit integers \a __x and \a __y, plus 0 or 1 as indicated +/// by the carry flag \a __cf. Stores the unsigned 32-bit sum in the memory +/// at \a __p, and returns the 8-bit carry-out (carry flag). +/// +/// \code{.operation} +/// temp := (__cf == 0) ? 0 : 1 +/// Store32(__p, __x + __y + temp) +/// result := CF +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ADCX instruction. +/// +/// \param __cf +/// The 8-bit unsigned carry flag; any non-zero value indicates carry. +/// \param __x +/// A 32-bit unsigned addend. +/// \param __y +/// A 32-bit unsigned addend. +/// \param __p +/// Pointer to memory for storing the sum. +/// \returns The 8-bit unsigned carry-out value. +__INLINE unsigned char __DEFAULT_FN_ATTRS _addcarryx_u32(unsigned char __cf, + unsigned int __x, + unsigned int __y, + unsigned int *__p) { + return __builtin_ia32_addcarryx_u32(__cf, __x, __y, __p); +} + +#ifdef __x86_64__ +/// Adds unsigned 64-bit integers \a __x and \a __y, plus 0 or 1 as indicated +/// by the carry flag \a __cf. Stores the unsigned 64-bit sum in the memory +/// at \a __p, and returns the 8-bit carry-out (carry flag). +/// +/// \code{.operation} +/// temp := (__cf == 0) ? 0 : 1 +/// Store64(__p, __x + __y + temp) +/// result := CF +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ADCX instruction. +/// +/// \param __cf +/// The 8-bit unsigned carry flag; any non-zero value indicates carry. +/// \param __x +/// A 64-bit unsigned addend. +/// \param __y +/// A 64-bit unsigned addend. +/// \param __p +/// Pointer to memory for storing the sum. +/// \returns The 8-bit unsigned carry-out value. +__INLINE unsigned char __DEFAULT_FN_ATTRS +_addcarryx_u64(unsigned char __cf, unsigned long long __x, + unsigned long long __y, unsigned long long *__p) { + return __builtin_ia32_addcarryx_u64(__cf, __x, __y, __p); +} +#endif + +#if defined(__cplusplus) +} +#endif + +#undef __INLINE +#undef __DEFAULT_FN_ATTRS + +#endif /* __ADXINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/altivec.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/altivec.h new file mode 100755 index 0000000..71d8d3c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/altivec.h @@ -0,0 +1,19364 @@ +/*===---- altivec.h - Standard header for type generic math ---------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __ALTIVEC_H +#define __ALTIVEC_H + +#ifndef __ALTIVEC__ +#error "AltiVec support not enabled" +#endif + +/* Constants for mapping CR6 bits to predicate result. */ + +#define __CR6_EQ 0 +#define __CR6_EQ_REV 1 +#define __CR6_LT 2 +#define __CR6_LT_REV 3 +#define __CR6_GT 4 +#define __CR6_GT_REV 5 +#define __CR6_SO 6 +#define __CR6_SO_REV 7 + +/* Constants for vec_test_data_class */ +#define __VEC_CLASS_FP_SUBNORMAL_N (1 << 0) +#define __VEC_CLASS_FP_SUBNORMAL_P (1 << 1) +#define __VEC_CLASS_FP_SUBNORMAL (__VEC_CLASS_FP_SUBNORMAL_P | \ + __VEC_CLASS_FP_SUBNORMAL_N) +#define __VEC_CLASS_FP_ZERO_N (1<<2) +#define __VEC_CLASS_FP_ZERO_P (1<<3) +#define __VEC_CLASS_FP_ZERO (__VEC_CLASS_FP_ZERO_P | \ + __VEC_CLASS_FP_ZERO_N) +#define __VEC_CLASS_FP_INFINITY_N (1<<4) +#define __VEC_CLASS_FP_INFINITY_P (1<<5) +#define __VEC_CLASS_FP_INFINITY (__VEC_CLASS_FP_INFINITY_P | \ + __VEC_CLASS_FP_INFINITY_N) +#define __VEC_CLASS_FP_NAN (1<<6) +#define __VEC_CLASS_FP_NOT_NORMAL (__VEC_CLASS_FP_NAN | \ + __VEC_CLASS_FP_SUBNORMAL | \ + __VEC_CLASS_FP_ZERO | \ + __VEC_CLASS_FP_INFINITY) + +#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__)) + +#include + +static __inline__ vector signed char __ATTRS_o_ai vec_perm( + vector signed char __a, vector signed char __b, vector unsigned char __c); + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_perm(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c); + +static __inline__ vector bool char __ATTRS_o_ai +vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c); + +static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a, + vector signed short __b, + vector unsigned char __c); + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_perm(vector unsigned short __a, vector unsigned short __b, + vector unsigned char __c); + +static __inline__ vector bool short __ATTRS_o_ai vec_perm( + vector bool short __a, vector bool short __b, vector unsigned char __c); + +static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a, + vector pixel __b, + vector unsigned char __c); + +static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a, + vector signed int __b, + vector unsigned char __c); + +static __inline__ vector unsigned int __ATTRS_o_ai vec_perm( + vector unsigned int __a, vector unsigned int __b, vector unsigned char __c); + +static __inline__ vector bool int __ATTRS_o_ai +vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c); + +static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a, + vector float __b, + vector unsigned char __c); + +#ifdef __VSX__ +static __inline__ vector long long __ATTRS_o_ai +vec_perm(vector signed long long __a, vector signed long long __b, + vector unsigned char __c); + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_perm(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned char __c); + +static __inline__ vector bool long long __ATTRS_o_ai +vec_perm(vector bool long long __a, vector bool long long __b, + vector unsigned char __c); + +static __inline__ vector double __ATTRS_o_ai vec_perm(vector double __a, + vector double __b, + vector unsigned char __c); +#endif + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xor(vector unsigned char __a, vector unsigned char __b); + +/* vec_abs */ + +#define __builtin_altivec_abs_v16qi vec_abs +#define __builtin_altivec_abs_v8hi vec_abs +#define __builtin_altivec_abs_v4si vec_abs + +static __inline__ vector signed char __ATTRS_o_ai +vec_abs(vector signed char __a) { + return __builtin_altivec_vmaxsb(__a, -__a); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_abs(vector signed short __a) { + return __builtin_altivec_vmaxsh(__a, -__a); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_abs(vector signed int __a) { + return __builtin_altivec_vmaxsw(__a, -__a); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_abs(vector signed long long __a) { + return __builtin_altivec_vmaxsd(__a, -__a); +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_abs(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvabssp(__a); +#else + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)(0x7FFFFFFF); + return (vector float)__res; +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_abs(vector double __a) { + return __builtin_vsx_xvabsdp(__a); +} +#endif + +/* vec_abss */ +#define __builtin_altivec_abss_v16qi vec_abss +#define __builtin_altivec_abss_v8hi vec_abss +#define __builtin_altivec_abss_v4si vec_abss + +static __inline__ vector signed char __ATTRS_o_ai +vec_abss(vector signed char __a) { + return __builtin_altivec_vmaxsb( + __a, __builtin_altivec_vsubsbs((vector signed char)(0), __a)); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_abss(vector signed short __a) { + return __builtin_altivec_vmaxsh( + __a, __builtin_altivec_vsubshs((vector signed short)(0), __a)); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_abss(vector signed int __a) { + return __builtin_altivec_vmaxsw( + __a, __builtin_altivec_vsubsws((vector signed int)(0), __a)); +} + +/* vec_absd */ +#if defined(__POWER9_VECTOR__) + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_absd(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vabsdub(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_absd(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vabsduh(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_absd(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vabsduw(__a, __b); +} + +#endif /* End __POWER9_VECTOR__ */ + +/* vec_add */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_add(vector signed char __a, vector signed char __b) { + return __a + __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_add(vector bool char __a, vector signed char __b) { + return (vector signed char)__a + __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_add(vector signed char __a, vector bool char __b) { + return __a + (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_add(vector unsigned char __a, vector unsigned char __b) { + return __a + __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_add(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a + __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_add(vector unsigned char __a, vector bool char __b) { + return __a + (vector unsigned char)__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a, + vector short __b) { + return __a + __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_add(vector bool short __a, + vector short __b) { + return (vector short)__a + __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_add(vector short __a, + vector bool short __b) { + return __a + (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_add(vector unsigned short __a, vector unsigned short __b) { + return __a + __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_add(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a + __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_add(vector unsigned short __a, vector bool short __b) { + return __a + (vector unsigned short)__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a, + vector int __b) { + return __a + __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_add(vector bool int __a, + vector int __b) { + return (vector int)__a + __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_add(vector int __a, + vector bool int __b) { + return __a + (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_add(vector unsigned int __a, vector unsigned int __b) { + return __a + __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_add(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a + __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_add(vector unsigned int __a, vector bool int __b) { + return __a + (vector unsigned int)__b; +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_add(vector signed long long __a, vector signed long long __b) { + return __a + __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_add(vector unsigned long long __a, vector unsigned long long __b) { + return __a + __b; +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_add(vector signed __int128 __a, vector signed __int128 __b) { + return __a + __b; +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a + __b; +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_add_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vadduqm(__a, __b); +} +#elif defined(__VSX__) +static __inline__ vector signed long long __ATTRS_o_ai +vec_add(vector signed long long __a, vector signed long long __b) { +#ifdef __LITTLE_ENDIAN__ + // Little endian systems on CPU's prior to Power8 don't really exist + // so scalarizing is fine. + return __a + __b; +#else + vector unsigned int __res = + (vector unsigned int)__a + (vector unsigned int)__b; + vector unsigned int __carry = __builtin_altivec_vaddcuw( + (vector unsigned int)__a, (vector unsigned int)__b); + __carry = (vector unsigned int)__builtin_shufflevector( + (vector unsigned char)__carry, (vector unsigned char)__carry, 0, 0, 0, 7, + 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0); + return (vector signed long long)(__res + __carry); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_add(vector unsigned long long __a, vector unsigned long long __b) { + return (vector unsigned long long)vec_add((vector signed long long)__a, + (vector signed long long)__b); +} +#endif // __POWER8_VECTOR__ + +static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a, + vector float __b) { + return __a + __b; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_add(vector double __a, + vector double __b) { + return __a + __b; +} +#endif // __VSX__ + +/* vec_adde */ + +#ifdef __POWER8_VECTOR__ +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_adde(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vaddeuqm( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_adde(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vaddeuqm(__a, __b, __c); +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_adde_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vaddeuqm_c( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} +#endif + +static __inline__ vector signed int __ATTRS_o_ai +vec_adde(vector signed int __a, vector signed int __b, + vector signed int __c) { + vector signed int __mask = {1, 1, 1, 1}; + vector signed int __carry = __c & __mask; + return vec_add(vec_add(__a, __b), __carry); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_adde(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + vector unsigned int __mask = {1, 1, 1, 1}; + vector unsigned int __carry = __c & __mask; + return vec_add(vec_add(__a, __b), __carry); +} + +/* vec_addec */ + +#ifdef __POWER8_VECTOR__ +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_addec(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vaddecuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_addec(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vaddecuq(__a, __b, __c); +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_addec_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vaddecuq_c( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +#ifdef __powerpc64__ +static __inline__ vector signed int __ATTRS_o_ai +vec_addec(vector signed int __a, vector signed int __b, + vector signed int __c) { + + signed int __result[4]; + for (int i = 0; i < 4; i++) { + unsigned int __tempa = (unsigned int) __a[i]; + unsigned int __tempb = (unsigned int) __b[i]; + unsigned int __tempc = (unsigned int) __c[i]; + __tempc = __tempc & 0x00000001; + unsigned long long __longa = (unsigned long long) __tempa; + unsigned long long __longb = (unsigned long long) __tempb; + unsigned long long __longc = (unsigned long long) __tempc; + unsigned long long __sum = __longa + __longb + __longc; + unsigned long long __res = (__sum >> 32) & 0x01; + unsigned long long __tempres = (unsigned int) __res; + __result[i] = (signed int) __tempres; + } + + vector signed int ret = { __result[0], __result[1], __result[2], __result[3] }; + return ret; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_addec(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + + unsigned int __result[4]; + for (int i = 0; i < 4; i++) { + unsigned int __tempc = __c[i] & 1; + unsigned long long __longa = (unsigned long long) __a[i]; + unsigned long long __longb = (unsigned long long) __b[i]; + unsigned long long __longc = (unsigned long long) __tempc; + unsigned long long __sum = __longa + __longb + __longc; + unsigned long long __res = (__sum >> 32) & 0x01; + unsigned long long __tempres = (unsigned int) __res; + __result[i] = (signed int) __tempres; + } + + vector unsigned int ret = { __result[0], __result[1], __result[2], __result[3] }; + return ret; +} +#endif // __powerpc64__ +#endif // __POWER8_VECTOR__ + +/* vec_vaddubm */ + +#define __builtin_altivec_vaddubm vec_vaddubm + +static __inline__ vector signed char __ATTRS_o_ai +vec_vaddubm(vector signed char __a, vector signed char __b) { + return __a + __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vaddubm(vector bool char __a, vector signed char __b) { + return (vector signed char)__a + __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vaddubm(vector signed char __a, vector bool char __b) { + return __a + (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vaddubm(vector unsigned char __a, vector unsigned char __b) { + return __a + __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vaddubm(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a + __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vaddubm(vector unsigned char __a, vector bool char __b) { + return __a + (vector unsigned char)__b; +} + +/* vec_vadduhm */ + +#define __builtin_altivec_vadduhm vec_vadduhm + +static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a, + vector short __b) { + return __a + __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector bool short __a, + vector short __b) { + return (vector short)__a + __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vadduhm(vector short __a, + vector bool short __b) { + return __a + (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vadduhm(vector unsigned short __a, vector unsigned short __b) { + return __a + __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vadduhm(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a + __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vadduhm(vector unsigned short __a, vector bool short __b) { + return __a + (vector unsigned short)__b; +} + +/* vec_vadduwm */ + +#define __builtin_altivec_vadduwm vec_vadduwm + +static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a, + vector int __b) { + return __a + __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector bool int __a, + vector int __b) { + return (vector int)__a + __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vadduwm(vector int __a, + vector bool int __b) { + return __a + (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vadduwm(vector unsigned int __a, vector unsigned int __b) { + return __a + __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vadduwm(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a + __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vadduwm(vector unsigned int __a, vector bool int __b) { + return __a + (vector unsigned int)__b; +} + +/* vec_vaddfp */ + +#define __builtin_altivec_vaddfp vec_vaddfp + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vaddfp(vector float __a, vector float __b) { + return __a + __b; +} + +/* vec_addc */ + +static __inline__ vector signed int __ATTRS_o_ai +vec_addc(vector signed int __a, vector signed int __b) { + return (vector signed int)__builtin_altivec_vaddcuw((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_addc(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vaddcuw(__a, __b); +} + +#ifdef __POWER8_VECTOR__ +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_addc(vector signed __int128 __a, vector signed __int128 __b) { + return (vector signed __int128)__builtin_altivec_vaddcuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __builtin_altivec_vaddcuq(__a, __b); +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_addc_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vaddcuq_c( + (vector unsigned char)__a, (vector unsigned char)__b); +} +#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) + +/* vec_vaddcuw */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vaddcuw(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vaddcuw(__a, __b); +} + +/* vec_adds */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_adds(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vaddsbs(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_adds(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vaddsbs((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_adds(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vaddsbs(__a, (vector signed char)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_adds(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vaddubs(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_adds(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vaddubs((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_adds(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a, + vector short __b) { + return __builtin_altivec_vaddshs(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_adds(vector bool short __a, + vector short __b) { + return __builtin_altivec_vaddshs((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_adds(vector short __a, + vector bool short __b) { + return __builtin_altivec_vaddshs(__a, (vector short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_adds(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vadduhs(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_adds(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vadduhs((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_adds(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a, + vector int __b) { + return __builtin_altivec_vaddsws(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_adds(vector bool int __a, + vector int __b) { + return __builtin_altivec_vaddsws((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_adds(vector int __a, + vector bool int __b) { + return __builtin_altivec_vaddsws(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_adds(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vadduws(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_adds(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vadduws((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_adds(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vadduws(__a, (vector unsigned int)__b); +} + +/* vec_vaddsbs */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vaddsbs(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vaddsbs(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vaddsbs(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vaddsbs((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vaddsbs(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vaddsbs(__a, (vector signed char)__b); +} + +/* vec_vaddubs */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vaddubs(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vaddubs(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vaddubs(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vaddubs((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vaddubs(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vaddubs(__a, (vector unsigned char)__b); +} + +/* vec_vaddshs */ + +static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a, + vector short __b) { + return __builtin_altivec_vaddshs(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector bool short __a, + vector short __b) { + return __builtin_altivec_vaddshs((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vaddshs(vector short __a, + vector bool short __b) { + return __builtin_altivec_vaddshs(__a, (vector short)__b); +} + +/* vec_vadduhs */ + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vadduhs(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vadduhs(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vadduhs(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vadduhs((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vadduhs(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vadduhs(__a, (vector unsigned short)__b); +} + +/* vec_vaddsws */ + +static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a, + vector int __b) { + return __builtin_altivec_vaddsws(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector bool int __a, + vector int __b) { + return __builtin_altivec_vaddsws((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vaddsws(vector int __a, + vector bool int __b) { + return __builtin_altivec_vaddsws(__a, (vector int)__b); +} + +/* vec_vadduws */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vadduws(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vadduws(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vadduws(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vadduws((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vadduws(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vadduws(__a, (vector unsigned int)__b); +} + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +/* vec_vadduqm */ + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vadduqm(vector signed __int128 __a, vector signed __int128 __b) { + return __a + __b; +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vadduqm(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a + __b; +} + +/* vec_vaddeuqm */ + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vaddeuqm(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vaddeuqm( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vaddeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vaddeuqm(__a, __b, __c); +} + +/* vec_vaddcuq */ + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vaddcuq(vector signed __int128 __a, vector signed __int128 __b) { + return (vector signed __int128)__builtin_altivec_vaddcuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vaddcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __builtin_altivec_vaddcuq(__a, __b); +} + +/* vec_vaddecuq */ + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vaddecuq(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vaddecuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vaddecuq(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vaddecuq(__a, __b, __c); +} +#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) + +/* vec_and */ + +#define __builtin_altivec_vand vec_and + +static __inline__ vector signed char __ATTRS_o_ai +vec_and(vector signed char __a, vector signed char __b) { + return __a & __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_and(vector bool char __a, vector signed char __b) { + return (vector signed char)__a & __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_and(vector signed char __a, vector bool char __b) { + return __a & (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_and(vector unsigned char __a, vector unsigned char __b) { + return __a & __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_and(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a & __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_and(vector unsigned char __a, vector bool char __b) { + return __a & (vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_and(vector bool char __a, + vector bool char __b) { + return __a & __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a, + vector short __b) { + return __a & __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_and(vector bool short __a, + vector short __b) { + return (vector short)__a & __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_and(vector short __a, + vector bool short __b) { + return __a & (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_and(vector unsigned short __a, vector unsigned short __b) { + return __a & __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_and(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a & __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_and(vector unsigned short __a, vector bool short __b) { + return __a & (vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_and(vector bool short __a, vector bool short __b) { + return __a & __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a, + vector int __b) { + return __a & __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_and(vector bool int __a, + vector int __b) { + return (vector int)__a & __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_and(vector int __a, + vector bool int __b) { + return __a & (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_and(vector unsigned int __a, vector unsigned int __b) { + return __a & __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_and(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a & __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_and(vector unsigned int __a, vector bool int __b) { + return __a & (vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_and(vector bool int __a, + vector bool int __b) { + return __a & __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_and(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_and(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_and(vector bool long long __a, + vector double __b) { + vector unsigned long long __res = + (vector unsigned long long)__a & (vector unsigned long long)__b; + return (vector double)__res; +} + +static __inline__ vector double __ATTRS_o_ai +vec_and(vector double __a, vector bool long long __b) { + vector unsigned long long __res = + (vector unsigned long long)__a & (vector unsigned long long)__b; + return (vector double)__res; +} + +static __inline__ vector double __ATTRS_o_ai vec_and(vector double __a, + vector double __b) { + vector unsigned long long __res = + (vector unsigned long long)__a & (vector unsigned long long)__b; + return (vector double)__res; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_and(vector signed long long __a, vector signed long long __b) { + return __a & __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_and(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a & __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_and(vector signed long long __a, vector bool long long __b) { + return __a & (vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_and(vector unsigned long long __a, vector unsigned long long __b) { + return __a & __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_and(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a & __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_and(vector unsigned long long __a, vector bool long long __b) { + return __a & (vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_and(vector bool long long __a, vector bool long long __b) { + return __a & __b; +} +#endif + +/* vec_vand */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vand(vector signed char __a, vector signed char __b) { + return __a & __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vand(vector bool char __a, vector signed char __b) { + return (vector signed char)__a & __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vand(vector signed char __a, vector bool char __b) { + return __a & (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vand(vector unsigned char __a, vector unsigned char __b) { + return __a & __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vand(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a & __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vand(vector unsigned char __a, vector bool char __b) { + return __a & (vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vand(vector bool char __a, + vector bool char __b) { + return __a & __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a, + vector short __b) { + return __a & __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vand(vector bool short __a, + vector short __b) { + return (vector short)__a & __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vand(vector short __a, + vector bool short __b) { + return __a & (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vand(vector unsigned short __a, vector unsigned short __b) { + return __a & __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vand(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a & __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vand(vector unsigned short __a, vector bool short __b) { + return __a & (vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vand(vector bool short __a, vector bool short __b) { + return __a & __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a, + vector int __b) { + return __a & __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vand(vector bool int __a, + vector int __b) { + return (vector int)__a & __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vand(vector int __a, + vector bool int __b) { + return __a & (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vand(vector unsigned int __a, vector unsigned int __b) { + return __a & __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vand(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a & __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vand(vector unsigned int __a, vector bool int __b) { + return __a & (vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vand(vector bool int __a, + vector bool int __b) { + return __a & __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vand(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vand(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a & (vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_vand(vector signed long long __a, vector signed long long __b) { + return __a & __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vand(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a & __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vand(vector signed long long __a, vector bool long long __b) { + return __a & (vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vand(vector unsigned long long __a, vector unsigned long long __b) { + return __a & __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vand(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a & __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vand(vector unsigned long long __a, vector bool long long __b) { + return __a & (vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_vand(vector bool long long __a, vector bool long long __b) { + return __a & __b; +} +#endif + +/* vec_andc */ + +#define __builtin_altivec_vandc vec_andc + +static __inline__ vector signed char __ATTRS_o_ai +vec_andc(vector signed char __a, vector signed char __b) { + return __a & ~__b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_andc(vector bool char __a, vector signed char __b) { + return (vector signed char)__a & ~__b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_andc(vector signed char __a, vector bool char __b) { + return __a & ~(vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_andc(vector unsigned char __a, vector unsigned char __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_andc(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a & ~__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_andc(vector unsigned char __a, vector bool char __b) { + return __a & ~(vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_andc(vector bool char __a, + vector bool char __b) { + return __a & ~__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a, + vector short __b) { + return __a & ~__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_andc(vector bool short __a, + vector short __b) { + return (vector short)__a & ~__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_andc(vector short __a, + vector bool short __b) { + return __a & ~(vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_andc(vector unsigned short __a, vector unsigned short __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_andc(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a & ~__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_andc(vector unsigned short __a, vector bool short __b) { + return __a & ~(vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_andc(vector bool short __a, vector bool short __b) { + return __a & ~__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a, + vector int __b) { + return __a & ~__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_andc(vector bool int __a, + vector int __b) { + return (vector int)__a & ~__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_andc(vector int __a, + vector bool int __b) { + return __a & ~(vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_andc(vector unsigned int __a, vector unsigned int __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_andc(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a & ~__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_andc(vector unsigned int __a, vector bool int __b) { + return __a & ~(vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_andc(vector bool int __a, + vector bool int __b) { + return __a & ~__b; +} + +static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & ~(vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_andc(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & ~(vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_andc(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a & ~(vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_andc(vector bool long long __a, + vector double __b) { + vector unsigned long long __res = + (vector unsigned long long)__a & ~(vector unsigned long long)__b; + return (vector double)__res; +} + +static __inline__ vector double __ATTRS_o_ai +vec_andc(vector double __a, vector bool long long __b) { + vector unsigned long long __res = + (vector unsigned long long)__a & ~(vector unsigned long long)__b; + return (vector double)__res; +} + +static __inline__ vector double __ATTRS_o_ai vec_andc(vector double __a, + vector double __b) { + vector unsigned long long __res = + (vector unsigned long long)__a & ~(vector unsigned long long)__b; + return (vector double)__res; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_andc(vector signed long long __a, vector signed long long __b) { + return __a & ~__b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_andc(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a & ~__b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_andc(vector signed long long __a, vector bool long long __b) { + return __a & ~(vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_andc(vector unsigned long long __a, vector unsigned long long __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_andc(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a & ~__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_andc(vector unsigned long long __a, vector bool long long __b) { + return __a & ~(vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_andc(vector bool long long __a, vector bool long long __b) { + return __a & ~__b; +} +#endif + +/* vec_vandc */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vandc(vector signed char __a, vector signed char __b) { + return __a & ~__b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vandc(vector bool char __a, vector signed char __b) { + return (vector signed char)__a & ~__b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vandc(vector signed char __a, vector bool char __b) { + return __a & ~(vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vandc(vector unsigned char __a, vector unsigned char __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vandc(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a & ~__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vandc(vector unsigned char __a, vector bool char __b) { + return __a & ~(vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vandc(vector bool char __a, vector bool char __b) { + return __a & ~__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a, + vector short __b) { + return __a & ~__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vandc(vector bool short __a, + vector short __b) { + return (vector short)__a & ~__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vandc(vector short __a, + vector bool short __b) { + return __a & ~(vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vandc(vector unsigned short __a, vector unsigned short __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vandc(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a & ~__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vandc(vector unsigned short __a, vector bool short __b) { + return __a & ~(vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vandc(vector bool short __a, vector bool short __b) { + return __a & ~__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a, + vector int __b) { + return __a & ~__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vandc(vector bool int __a, + vector int __b) { + return (vector int)__a & ~__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vandc(vector int __a, + vector bool int __b) { + return __a & ~(vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vandc(vector unsigned int __a, vector unsigned int __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vandc(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a & ~__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vandc(vector unsigned int __a, vector bool int __b) { + return __a & ~(vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vandc(vector bool int __a, + vector bool int __b) { + return __a & ~__b; +} + +static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & ~(vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vandc(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a & ~(vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vandc(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a & ~(vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_vandc(vector signed long long __a, vector signed long long __b) { + return __a & ~__b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vandc(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a & ~__b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vandc(vector signed long long __a, vector bool long long __b) { + return __a & ~(vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vandc(vector unsigned long long __a, vector unsigned long long __b) { + return __a & ~__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vandc(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a & ~__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vandc(vector unsigned long long __a, vector bool long long __b) { + return __a & ~(vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_vandc(vector bool long long __a, vector bool long long __b) { + return __a & ~__b; +} +#endif + +/* vec_avg */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_avg(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vavgsb(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_avg(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vavgub(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_avg(vector short __a, + vector short __b) { + return __builtin_altivec_vavgsh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_avg(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vavguh(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_avg(vector int __a, + vector int __b) { + return __builtin_altivec_vavgsw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_avg(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vavguw(__a, __b); +} + +/* vec_vavgsb */ + +static __inline__ vector signed char __attribute__((__always_inline__)) +vec_vavgsb(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vavgsb(__a, __b); +} + +/* vec_vavgub */ + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_vavgub(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vavgub(__a, __b); +} + +/* vec_vavgsh */ + +static __inline__ vector short __attribute__((__always_inline__)) +vec_vavgsh(vector short __a, vector short __b) { + return __builtin_altivec_vavgsh(__a, __b); +} + +/* vec_vavguh */ + +static __inline__ vector unsigned short __attribute__((__always_inline__)) +vec_vavguh(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vavguh(__a, __b); +} + +/* vec_vavgsw */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vavgsw(vector int __a, vector int __b) { + return __builtin_altivec_vavgsw(__a, __b); +} + +/* vec_vavguw */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vavguw(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vavguw(__a, __b); +} + +/* vec_ceil */ + +static __inline__ vector float __ATTRS_o_ai vec_ceil(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvrspip(__a); +#else + return __builtin_altivec_vrfip(__a); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_ceil(vector double __a) { + return __builtin_vsx_xvrdpip(__a); +} +#endif + +/* vec_roundp */ +static __inline__ vector float __ATTRS_o_ai vec_roundp(vector float __a) { + return vec_ceil(__a); +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_roundp(vector double __a) { + return vec_ceil(__a); +} +#endif + +/* vec_vrfip */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vrfip(vector float __a) { + return __builtin_altivec_vrfip(__a); +} + +/* vec_cmpb */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_cmpb(vector float __a, vector float __b) { + return __builtin_altivec_vcmpbfp(__a, __b); +} + +/* vec_vcmpbfp */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vcmpbfp(vector float __a, vector float __b) { + return __builtin_altivec_vcmpbfp(__a, __b); +} + +/* vec_cmpeq */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpeq(vector signed char __a, vector signed char __b) { + return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpeq(vector unsigned char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpeq(vector bool char __a, vector bool char __b) { + return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a, + vector short __b) { + return (vector bool short)__builtin_altivec_vcmpequh(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpeq(vector unsigned short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpeq(vector bool short __a, vector bool short __b) { + return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a, + vector int __b) { + return (vector bool int)__builtin_altivec_vcmpequw(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpeq(vector unsigned int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a, + vector bool int __b) { + return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a, + (vector int)__b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector signed long long __a, vector signed long long __b) { + return (vector bool long long)__builtin_altivec_vcmpequd(__a, __b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) { + return (vector bool long long)__builtin_altivec_vcmpequd( + (vector long long)__a, (vector long long)__b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector bool long long __a, vector bool long long __b) { + return (vector bool long long)__builtin_altivec_vcmpequd( + (vector long long)__a, (vector long long)__b); +} +#elif defined(__VSX__) +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector signed long long __a, vector signed long long __b) { + vector bool int __wordcmp = + vec_cmpeq((vector signed int)__a, (vector signed int)__b); +#ifdef __LITTLE_ENDIAN__ + __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 3, 0, 1, 2); + return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 1, + 1, 3, 3); +#else + __wordcmp &= __builtin_shufflevector(__wordcmp, __wordcmp, 1, 2, 3, 0); + return (vector bool long long)__builtin_shufflevector(__wordcmp, __wordcmp, 0, + 0, 2, 2); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector unsigned long long __a, vector unsigned long long __b) { + return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector bool long long __a, vector bool long long __b) { + return vec_cmpeq((vector signed long long)__a, (vector signed long long)__b); +} +#endif + +static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a, + vector float __b) { +#ifdef __VSX__ + return (vector bool int)__builtin_vsx_xvcmpeqsp(__a, __b); +#else + return (vector bool int)__builtin_altivec_vcmpeqfp(__a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpeq(vector double __a, vector double __b) { + return (vector bool long long)__builtin_vsx_xvcmpeqdp(__a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpeq(vector signed __int128 __a, vector signed __int128 __b) { + return (vector bool __int128)__builtin_altivec_vcmpequq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpeq(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return (vector bool __int128)__builtin_altivec_vcmpequq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpeq(vector bool __int128 __a, vector bool __int128 __b) { + return (vector bool __int128)__builtin_altivec_vcmpequq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} +#endif + +#ifdef __POWER9_VECTOR__ +/* vec_cmpne */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpne(vector bool char __a, vector bool char __b) { + return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpne(vector signed char __a, vector signed char __b) { + return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpne(vector unsigned char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vcmpneb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpne(vector bool short __a, vector bool short __b) { + return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpne(vector signed short __a, vector signed short __b) { + return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpne(vector unsigned short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vcmpneh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector bool int __a, vector bool int __b) { + return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector signed int __a, vector signed int __b) { + return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector unsigned int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector float __a, vector float __b) { + return (vector bool int)__builtin_altivec_vcmpnew((vector int)__a, + (vector int)__b); +} + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpne(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return (vector bool __int128)~(__builtin_altivec_vcmpequq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b)); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpne(vector signed __int128 __a, vector signed __int128 __b) { + return (vector bool __int128)~(__builtin_altivec_vcmpequq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b)); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpne(vector bool __int128 __a, vector bool __int128 __b) { + return (vector bool __int128)~(__builtin_altivec_vcmpequq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b)); +} +#endif + +/* vec_cmpnez */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpnez(vector signed char __a, vector signed char __b) { + return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpnez(vector unsigned char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vcmpnezb((vector char)__a, + (vector char)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpnez(vector signed short __a, vector signed short __b) { + return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpnez(vector unsigned short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vcmpnezh((vector short)__a, + (vector short)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpnez(vector signed int __a, vector signed int __b) { + return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpnez(vector unsigned int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vcmpnezw((vector int)__a, + (vector int)__b); +} + +static __inline__ signed int __ATTRS_o_ai +vec_cntlz_lsbb(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vctzlsbb((vector unsigned char)__a); +#else + return __builtin_altivec_vclzlsbb((vector unsigned char)__a); +#endif +} + +static __inline__ signed int __ATTRS_o_ai +vec_cntlz_lsbb(vector unsigned char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vctzlsbb((vector unsigned char)__a); +#else + return __builtin_altivec_vclzlsbb(__a); +#endif +} + +static __inline__ signed int __ATTRS_o_ai +vec_cnttz_lsbb(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vclzlsbb((vector unsigned char)__a); +#else + return __builtin_altivec_vctzlsbb((vector unsigned char)__a); +#endif +} + +static __inline__ signed int __ATTRS_o_ai +vec_cnttz_lsbb(vector unsigned char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vclzlsbb(__a); +#else + return __builtin_altivec_vctzlsbb(__a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_parity_lsbb(vector unsigned int __a) { + return __builtin_altivec_vprtybw(__a); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_parity_lsbb(vector signed int __a) { + return __builtin_altivec_vprtybw((vector unsigned int)__a); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_parity_lsbb(vector unsigned __int128 __a) { + return __builtin_altivec_vprtybq(__a); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_parity_lsbb(vector signed __int128 __a) { + return __builtin_altivec_vprtybq((vector unsigned __int128)__a); +} +#endif + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_parity_lsbb(vector unsigned long long __a) { + return __builtin_altivec_vprtybd(__a); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_parity_lsbb(vector signed long long __a) { + return __builtin_altivec_vprtybd((vector unsigned long long)__a); +} + +#else +/* vec_cmpne */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpne(vector bool char __a, vector bool char __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpne(vector signed char __a, vector signed char __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpne(vector unsigned char __a, vector unsigned char __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpne(vector bool short __a, vector bool short __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpne(vector signed short __a, vector signed short __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpne(vector unsigned short __a, vector unsigned short __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector bool int __a, vector bool int __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector signed int __a, vector signed int __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector unsigned int __a, vector unsigned int __b) { + return ~(vec_cmpeq(__a, __b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpne(vector float __a, vector float __b) { + return ~(vec_cmpeq(__a, __b)); +} +#endif + +#ifdef __POWER8_VECTOR__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector bool long long __a, vector bool long long __b) { + return (vector bool long long) + ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector signed long long __a, vector signed long long __b) { + return (vector bool long long) + ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) { + return (vector bool long long) + ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b)); +} +#elif defined(__VSX__) +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector bool long long __a, vector bool long long __b) { + return (vector bool long long)~( + vec_cmpeq((vector signed long long)__a, (vector signed long long)__b)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector signed long long __a, vector signed long long __b) { + return (vector bool long long)~( + vec_cmpeq((vector signed long long)__a, (vector signed long long)__b)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector unsigned long long __a, vector unsigned long long __b) { + return (vector bool long long)~( + vec_cmpeq((vector signed long long)__a, (vector signed long long)__b)); +} +#endif + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpne(vector double __a, vector double __b) { + return (vector bool long long) + ~(__builtin_altivec_vcmpequd((vector long long)__a, (vector long long)__b)); +} +#endif + +/* vec_cmpgt */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpgt(vector signed char __a, vector signed char __b) { + return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpgt(vector unsigned char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai vec_cmpgt(vector short __a, + vector short __b) { + return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpgt(vector unsigned short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector int __a, + vector int __b) { + return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpgt(vector unsigned int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpgt(vector signed long long __a, vector signed long long __b) { + return (vector bool long long)__builtin_altivec_vcmpgtsd(__a, __b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) { + return (vector bool long long)__builtin_altivec_vcmpgtud(__a, __b); +} +#elif defined(__VSX__) +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpgt(vector signed long long __a, vector signed long long __b) { + vector signed int __sgtw = (vector signed int)vec_cmpgt( + (vector signed int)__a, (vector signed int)__b); + vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt( + (vector unsigned int)__a, (vector unsigned int)__b); + vector unsigned int __eqw = (vector unsigned int)vec_cmpeq( + (vector signed int)__a, (vector signed int)__b); +#ifdef __LITTLE_ENDIAN__ + __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw; + __sgtw |= (vector signed int)__ugtw; + return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 1, 1, 3, + 3); +#else + __ugtw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw; + __sgtw |= (vector signed int)__ugtw; + return (vector bool long long)__builtin_shufflevector(__sgtw, __sgtw, 0, 0, 2, + 2); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpgt(vector unsigned long long __a, vector unsigned long long __b) { + vector unsigned int __ugtw = (vector unsigned int)vec_cmpgt( + (vector unsigned int)__a, (vector unsigned int)__b); + vector unsigned int __eqw = (vector unsigned int)vec_cmpeq( + (vector signed int)__a, (vector signed int)__b); +#ifdef __LITTLE_ENDIAN__ + __eqw = __builtin_shufflevector(__ugtw, __ugtw, 3, 0, 1, 2) & __eqw; + __ugtw |= __eqw; + return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 1, 1, 3, + 3); +#else + __eqw = __builtin_shufflevector(__ugtw, __ugtw, 1, 2, 3, 0) & __eqw; + __ugtw |= __eqw; + return (vector bool long long)__builtin_shufflevector(__ugtw, __ugtw, 0, 0, 2, + 2); +#endif +} +#endif + +static __inline__ vector bool int __ATTRS_o_ai vec_cmpgt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return (vector bool int)__builtin_vsx_xvcmpgtsp(__a, __b); +#else + return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpgt(vector double __a, vector double __b) { + return (vector bool long long)__builtin_vsx_xvcmpgtdp(__a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpgt(vector signed __int128 __a, vector signed __int128 __b) { + return (vector bool __int128)__builtin_altivec_vcmpgtsq(__a, __b); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpgt(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return (vector bool __int128)__builtin_altivec_vcmpgtuq(__a, __b); +} +#endif + +/* vec_cmpge */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpge(vector signed char __a, vector signed char __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmpge(vector unsigned char __a, vector unsigned char __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpge(vector signed short __a, vector signed short __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmpge(vector unsigned short __a, vector unsigned short __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpge(vector signed int __a, vector signed int __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmpge(vector unsigned int __a, vector unsigned int __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmpge(vector float __a, + vector float __b) { +#ifdef __VSX__ + return (vector bool int)__builtin_vsx_xvcmpgesp(__a, __b); +#else + return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpge(vector double __a, vector double __b) { + return (vector bool long long)__builtin_vsx_xvcmpgedp(__a, __b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpge(vector signed long long __a, vector signed long long __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmpge(vector unsigned long long __a, vector unsigned long long __b) { + return ~(vec_cmpgt(__b, __a)); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpge(vector signed __int128 __a, vector signed __int128 __b) { + return ~(vec_cmpgt(__b, __a)); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmpge(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return ~(vec_cmpgt(__b, __a)); +} +#endif + +/* vec_vcmpgefp */ + +static __inline__ vector bool int __attribute__((__always_inline__)) +vec_vcmpgefp(vector float __a, vector float __b) { + return (vector bool int)__builtin_altivec_vcmpgefp(__a, __b); +} + +/* vec_vcmpgtsb */ + +static __inline__ vector bool char __attribute__((__always_inline__)) +vec_vcmpgtsb(vector signed char __a, vector signed char __b) { + return (vector bool char)__builtin_altivec_vcmpgtsb(__a, __b); +} + +/* vec_vcmpgtub */ + +static __inline__ vector bool char __attribute__((__always_inline__)) +vec_vcmpgtub(vector unsigned char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vcmpgtub(__a, __b); +} + +/* vec_vcmpgtsh */ + +static __inline__ vector bool short __attribute__((__always_inline__)) +vec_vcmpgtsh(vector short __a, vector short __b) { + return (vector bool short)__builtin_altivec_vcmpgtsh(__a, __b); +} + +/* vec_vcmpgtuh */ + +static __inline__ vector bool short __attribute__((__always_inline__)) +vec_vcmpgtuh(vector unsigned short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vcmpgtuh(__a, __b); +} + +/* vec_vcmpgtsw */ + +static __inline__ vector bool int __attribute__((__always_inline__)) +vec_vcmpgtsw(vector int __a, vector int __b) { + return (vector bool int)__builtin_altivec_vcmpgtsw(__a, __b); +} + +/* vec_vcmpgtuw */ + +static __inline__ vector bool int __attribute__((__always_inline__)) +vec_vcmpgtuw(vector unsigned int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vcmpgtuw(__a, __b); +} + +/* vec_vcmpgtfp */ + +static __inline__ vector bool int __attribute__((__always_inline__)) +vec_vcmpgtfp(vector float __a, vector float __b) { + return (vector bool int)__builtin_altivec_vcmpgtfp(__a, __b); +} + +/* vec_cmple */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmple(vector signed char __a, vector signed char __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmple(vector unsigned char __a, vector unsigned char __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmple(vector signed short __a, vector signed short __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmple(vector unsigned short __a, vector unsigned short __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmple(vector signed int __a, vector signed int __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmple(vector unsigned int __a, vector unsigned int __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmple(vector float __a, + vector float __b) { + return vec_cmpge(__b, __a); +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmple(vector double __a, vector double __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmple(vector signed long long __a, vector signed long long __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmple(vector unsigned long long __a, vector unsigned long long __b) { + return vec_cmpge(__b, __a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmple(vector signed __int128 __a, vector signed __int128 __b) { + return vec_cmpge(__b, __a); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmple(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return vec_cmpge(__b, __a); +} +#endif + +/* vec_cmplt */ + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmplt(vector signed char __a, vector signed char __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_cmplt(vector unsigned char __a, vector unsigned char __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool short __ATTRS_o_ai vec_cmplt(vector short __a, + vector short __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_cmplt(vector unsigned short __a, vector unsigned short __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector int __a, + vector int __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_cmplt(vector unsigned int __a, vector unsigned int __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_cmplt(vector float __a, + vector float __b) { + return vec_cmpgt(__b, __a); +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmplt(vector double __a, vector double __b) { + return vec_cmpgt(__b, __a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmplt(vector signed __int128 __a, vector signed __int128 __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool __int128 __ATTRS_o_ai +vec_cmplt(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return vec_cmpgt(__b, __a); +} +#endif + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmplt(vector signed long long __a, vector signed long long __b) { + return vec_cmpgt(__b, __a); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_cmplt(vector unsigned long long __a, vector unsigned long long __b) { + return vec_cmpgt(__b, __a); +} +#endif + +#ifdef __POWER8_VECTOR__ +/* vec_popcnt */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_popcnt(vector signed char __a) { + return (vector unsigned char)__builtin_elementwise_popcount( + (vector unsigned char)__a); +} +static __inline__ vector unsigned char __ATTRS_o_ai +vec_popcnt(vector unsigned char __a) { + return __builtin_elementwise_popcount(__a); +} +static __inline__ vector unsigned short __ATTRS_o_ai +vec_popcnt(vector signed short __a) { + return (vector unsigned short)__builtin_elementwise_popcount( + (vector unsigned short)__a); +} +static __inline__ vector unsigned short __ATTRS_o_ai +vec_popcnt(vector unsigned short __a) { + return __builtin_elementwise_popcount(__a); +} +static __inline__ vector unsigned int __ATTRS_o_ai +vec_popcnt(vector signed int __a) { + return __builtin_elementwise_popcount((vector unsigned int)__a); +} +static __inline__ vector unsigned int __ATTRS_o_ai +vec_popcnt(vector unsigned int __a) { + return __builtin_elementwise_popcount(__a); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_popcnt(vector signed long long __a) { + return __builtin_elementwise_popcount((vector unsigned long long)__a); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_popcnt(vector unsigned long long __a) { + return __builtin_elementwise_popcount(__a); +} + +#define vec_vclz vec_cntlz +/* vec_cntlz */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_cntlz(vector signed char __a) { + return (vector signed char)__builtin_altivec_vclzb((vector unsigned char)__a); +} +static __inline__ vector unsigned char __ATTRS_o_ai +vec_cntlz(vector unsigned char __a) { + return __builtin_altivec_vclzb(__a); +} +static __inline__ vector signed short __ATTRS_o_ai +vec_cntlz(vector signed short __a) { + return (vector signed short)__builtin_altivec_vclzh( + (vector unsigned short)__a); +} +static __inline__ vector unsigned short __ATTRS_o_ai +vec_cntlz(vector unsigned short __a) { + return __builtin_altivec_vclzh(__a); +} +static __inline__ vector signed int __ATTRS_o_ai +vec_cntlz(vector signed int __a) { + return (vector signed int)__builtin_altivec_vclzw((vector unsigned int)__a); +} +static __inline__ vector unsigned int __ATTRS_o_ai +vec_cntlz(vector unsigned int __a) { + return __builtin_altivec_vclzw(__a); +} +static __inline__ vector signed long long __ATTRS_o_ai +vec_cntlz(vector signed long long __a) { + return (vector signed long long)__builtin_altivec_vclzd( + (vector unsigned long long)__a); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_cntlz(vector unsigned long long __a) { + return __builtin_altivec_vclzd(__a); +} +#endif + +#ifdef __POWER9_VECTOR__ + +/* vec_cnttz */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_cnttz(vector signed char __a) { + return (vector signed char)__builtin_altivec_vctzb((vector unsigned char)__a); +} +static __inline__ vector unsigned char __ATTRS_o_ai +vec_cnttz(vector unsigned char __a) { + return __builtin_altivec_vctzb(__a); +} +static __inline__ vector signed short __ATTRS_o_ai +vec_cnttz(vector signed short __a) { + return (vector signed short)__builtin_altivec_vctzh( + (vector unsigned short)__a); +} +static __inline__ vector unsigned short __ATTRS_o_ai +vec_cnttz(vector unsigned short __a) { + return __builtin_altivec_vctzh(__a); +} +static __inline__ vector signed int __ATTRS_o_ai +vec_cnttz(vector signed int __a) { + return (vector signed int)__builtin_altivec_vctzw((vector unsigned int)__a); +} +static __inline__ vector unsigned int __ATTRS_o_ai +vec_cnttz(vector unsigned int __a) { + return __builtin_altivec_vctzw(__a); +} +static __inline__ vector signed long long __ATTRS_o_ai +vec_cnttz(vector signed long long __a) { + return (vector signed long long)__builtin_altivec_vctzd( + (vector unsigned long long)__a); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_cnttz(vector unsigned long long __a) { + return __builtin_altivec_vctzd(__a); +} + +/* vec_first_match_index */ + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_index(vector signed char __a, vector signed char __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_index(vector unsigned char __a, vector unsigned char __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_index(vector signed short __a, vector signed short __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_index(vector unsigned short __a, vector unsigned short __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_index(vector signed int __a, vector signed int __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_index(vector unsigned int __a, vector unsigned int __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpeq(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpeq(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +/* vec_first_match_or_eos_index */ + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_or_eos_index(vector signed char __a, vector signed char __b) { + /* Compare the result of the comparison of two vectors with either and OR the + result. Either the elements are equal or one will equal the comparison + result if either is zero. + */ + vector bool char __tmp1 = vec_cmpeq(__a, __b); + vector bool char __tmp2 = __tmp1 | + vec_cmpeq((vector signed char)__tmp1, __a) | + vec_cmpeq((vector signed char)__tmp1, __b); + + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)__tmp2); +#else + vec_cntlz((vector unsigned long long)__tmp2); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_or_eos_index(vector unsigned char __a, + vector unsigned char __b) { + vector bool char __tmp1 = vec_cmpeq(__a, __b); + vector bool char __tmp2 = __tmp1 | + vec_cmpeq((vector unsigned char)__tmp1, __a) | + vec_cmpeq((vector unsigned char)__tmp1, __b); + + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)__tmp2); +#else + vec_cntlz((vector unsigned long long)__tmp2); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_or_eos_index(vector signed short __a, vector signed short __b) { + vector bool short __tmp1 = vec_cmpeq(__a, __b); + vector bool short __tmp2 = __tmp1 | + vec_cmpeq((vector signed short)__tmp1, __a) | + vec_cmpeq((vector signed short)__tmp1, __b); + + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)__tmp2); +#else + vec_cntlz((vector unsigned long long)__tmp2); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_or_eos_index(vector unsigned short __a, + vector unsigned short __b) { + vector bool short __tmp1 = vec_cmpeq(__a, __b); + vector bool short __tmp2 = __tmp1 | + vec_cmpeq((vector unsigned short)__tmp1, __a) | + vec_cmpeq((vector unsigned short)__tmp1, __b); + + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)__tmp2); +#else + vec_cntlz((vector unsigned long long)__tmp2); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_or_eos_index(vector signed int __a, vector signed int __b) { + vector bool int __tmp1 = vec_cmpeq(__a, __b); + vector bool int __tmp2 = __tmp1 | vec_cmpeq((vector signed int)__tmp1, __a) | + vec_cmpeq((vector signed int)__tmp1, __b); + + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)__tmp2); +#else + vec_cntlz((vector unsigned long long)__tmp2); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_match_or_eos_index(vector unsigned int __a, vector unsigned int __b) { + vector bool int __tmp1 = vec_cmpeq(__a, __b); + vector bool int __tmp2 = __tmp1 | + vec_cmpeq((vector unsigned int)__tmp1, __a) | + vec_cmpeq((vector unsigned int)__tmp1, __b); + + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)__tmp2); +#else + vec_cntlz((vector unsigned long long)__tmp2); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +/* vec_first_mismatch_index */ + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_index(vector signed char __a, vector signed char __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_index(vector unsigned char __a, vector unsigned char __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_index(vector signed short __a, vector signed short __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_index(vector unsigned short __a, vector unsigned short __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_index(vector signed int __a, vector signed int __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_index(vector unsigned int __a, vector unsigned int __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpne(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpne(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +/* vec_first_mismatch_or_eos_index */ + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_or_eos_index(vector signed char __a, + vector signed char __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_or_eos_index(vector unsigned char __a, + vector unsigned char __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 3; + } + return __res[0] >> 3; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_or_eos_index(vector signed short __a, + vector signed short __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_or_eos_index(vector unsigned short __a, + vector unsigned short __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 4; + } + return __res[0] >> 4; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_or_eos_index(vector signed int __a, vector signed int __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +static __inline__ unsigned __ATTRS_o_ai +vec_first_mismatch_or_eos_index(vector unsigned int __a, + vector unsigned int __b) { + vector unsigned long long __res = +#ifdef __LITTLE_ENDIAN__ + vec_cnttz((vector unsigned long long)vec_cmpnez(__a, __b)); +#else + vec_cntlz((vector unsigned long long)vec_cmpnez(__a, __b)); +#endif + if (__res[0] == 64) { + return (__res[1] + 64) >> 5; + } + return __res[0] >> 5; +} + +static __inline__ vector double __ATTRS_o_ai +vec_insert_exp(vector double __a, vector unsigned long long __b) { + return __builtin_vsx_xviexpdp((vector unsigned long long)__a,__b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_insert_exp(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_vsx_xviexpdp(__a,__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_insert_exp(vector float __a, vector unsigned int __b) { + return __builtin_vsx_xviexpsp((vector unsigned int)__a,__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_insert_exp(vector unsigned int __a, vector unsigned int __b) { + return __builtin_vsx_xviexpsp(__a,__b); +} + +#if defined(__powerpc64__) +static __inline__ vector signed char __ATTRS_o_ai vec_xl_len(const signed char *__a, + size_t __b) { + return (vector signed char)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xl_len(const unsigned char *__a, size_t __b) { + return (vector unsigned char)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector signed short __ATTRS_o_ai vec_xl_len(const signed short *__a, + size_t __b) { + return (vector signed short)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_xl_len(const unsigned short *__a, size_t __b) { + return (vector unsigned short)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector signed int __ATTRS_o_ai vec_xl_len(const signed int *__a, + size_t __b) { + return (vector signed int)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_xl_len(const unsigned int *__a, + size_t __b) { + return (vector unsigned int)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector float __ATTRS_o_ai vec_xl_len(const float *__a, size_t __b) { + return (vector float)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_xl_len(const signed __int128 *__a, size_t __b) { + return (vector signed __int128)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_xl_len(const unsigned __int128 *__a, size_t __b) { + return (vector unsigned __int128)__builtin_vsx_lxvl(__a, (__b << 56)); +} +#endif + +static __inline__ vector signed long long __ATTRS_o_ai +vec_xl_len(const signed long long *__a, size_t __b) { + return (vector signed long long)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_xl_len(const unsigned long long *__a, size_t __b) { + return (vector unsigned long long)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector double __ATTRS_o_ai vec_xl_len(const double *__a, + size_t __b) { + return (vector double)__builtin_vsx_lxvl(__a, (__b << 56)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xl_len_r(const unsigned char *__a, size_t __b) { + vector unsigned char __res = + (vector unsigned char)__builtin_vsx_lxvll(__a, (__b << 56)); + vector unsigned char __mask = + (vector unsigned char)__builtin_altivec_lvsr(16 - __b, (int *)NULL); + return (vector unsigned char)__builtin_altivec_vperm_4si( + (vector int)__res, (vector int)__res, __mask); +} + +// vec_xst_len +static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned char __a, + unsigned char *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed char __a, + signed char *__b, size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed short __a, + signed short *__b, size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned short __a, + unsigned short *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed int __a, + signed int *__b, size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned int __a, + unsigned int *__b, size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector float __a, float *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed __int128 __a, + signed __int128 *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned __int128 __a, + unsigned __int128 *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} +#endif + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector signed long long __a, + signed long long *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector unsigned long long __a, + unsigned long long *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len(vector double __a, double *__b, + size_t __c) { + return __builtin_vsx_stxvl((vector int)__a, __b, (__c << 56)); +} + +static __inline__ void __ATTRS_o_ai vec_xst_len_r(vector unsigned char __a, + unsigned char *__b, + size_t __c) { + vector unsigned char __mask = + (vector unsigned char)__builtin_altivec_lvsl(16 - __c, (int *)NULL); + vector unsigned char __res = + (vector unsigned char)__builtin_altivec_vperm_4si( + (vector int)__a, (vector int)__a, __mask); + return __builtin_vsx_stxvll((vector int)__res, __b, (__c << 56)); +} +#endif +#endif + +#if defined(__POWER9_VECTOR__) && defined(__powerpc64__) +#define __vec_ldrmb(PTR, CNT) vec_xl_len_r((const unsigned char *)(PTR), (CNT)) +#define __vec_strmb(PTR, CNT, VAL) \ + vec_xst_len_r((VAL), (unsigned char *)(PTR), (CNT)) +#else +#define __vec_ldrmb __builtin_vsx_ldrmb +#define __vec_strmb __builtin_vsx_strmb +#endif + +/* vec_cpsgn */ + +#ifdef __VSX__ +static __inline__ vector float __ATTRS_o_ai vec_cpsgn(vector float __a, + vector float __b) { + return __builtin_vsx_xvcpsgnsp(__b, __a); +} + +static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a, + vector double __b) { + return __builtin_vsx_xvcpsgndp(__b, __a); +} +#endif + +/* vec_ctf */ + +#ifdef __VSX__ +// There are some functions that have different signatures with the XL compiler +// from those in Clang/GCC and documented in the PVIPR. This macro ensures that +// the XL-compatible signatures are used for those functions. +#ifdef __XL_COMPAT_ALTIVEC__ +#define vec_ctf(__a, __b) \ + _Generic((__a), \ + vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \ + ((__b)&0x1F)), \ + vector unsigned int: (vector float)__builtin_altivec_vcfux( \ + (vector unsigned int)(__a), ((__b)&0x1F)), \ + vector unsigned long long: ( \ + vector float)(__builtin_vsx_xvcvuxdsp( \ + (vector unsigned long long)(__a)) * \ + (vector float)(vector unsigned)((0x7f - \ + ((__b)&0x1F)) \ + << 23)), \ + vector signed long long: ( \ + vector float)(__builtin_vsx_xvcvsxdsp( \ + (vector signed long long)(__a)) * \ + (vector float)(vector unsigned)((0x7f - \ + ((__b)&0x1F)) \ + << 23))) +#else // __XL_COMPAT_ALTIVEC__ +#define vec_ctf(__a, __b) \ + _Generic( \ + (__a), \ + vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \ + ((__b)&0x1F)), \ + vector unsigned int: (vector float)__builtin_altivec_vcfux( \ + (vector unsigned int)(__a), ((__b)&0x1F)), \ + vector unsigned long long: ( \ + vector float)(__builtin_convertvector( \ + (vector unsigned long long)(__a), vector double) * \ + (vector double)(vector unsigned long long)((0x3ffULL - \ + ((__b)&0x1F)) \ + << 52)), \ + vector signed long long: ( \ + vector float)(__builtin_convertvector( \ + (vector signed long long)(__a), vector double) * \ + (vector double)(vector unsigned long long)((0x3ffULL - \ + ((__b)&0x1F)) \ + << 52))) +#endif // __XL_COMPAT_ALTIVEC__ +#else +#define vec_ctf(__a, __b) \ + _Generic((__a), \ + vector int: (vector float)__builtin_altivec_vcfsx((vector int)(__a), \ + ((__b)&0x1F)), \ + vector unsigned int: (vector float)__builtin_altivec_vcfux( \ + (vector unsigned int)(__a), ((__b)&0x1F))) +#endif + +/* vec_ctd */ +#ifdef __VSX__ +#define vec_ctd(__a, __b) \ + _Generic((__a), \ + vector signed int: ( \ + vec_doublee((vector signed int)(__a)) * \ + (vector double)(vector unsigned long long)((0x3ffULL - \ + ((__b)&0x1F)) \ + << 52)), \ + vector unsigned int: ( \ + vec_doublee((vector unsigned int)(__a)) * \ + (vector double)(vector unsigned long long)((0x3ffULL - \ + ((__b)&0x1F)) \ + << 52)), \ + vector unsigned long long: ( \ + __builtin_convertvector((vector unsigned long long)(__a), \ + vector double) * \ + (vector double)(vector unsigned long long)((0x3ffULL - \ + ((__b)&0x1F)) \ + << 52)), \ + vector signed long long: ( \ + __builtin_convertvector((vector signed long long)(__a), \ + vector double) * \ + (vector double)(vector unsigned long long)((0x3ffULL - \ + ((__b)&0x1F)) \ + << 52))) +#endif // __VSX__ + +/* vec_vcfsx */ + +#define vec_vcfux __builtin_altivec_vcfux +/* vec_vcfux */ + +#define vec_vcfsx(__a, __b) __builtin_altivec_vcfsx((vector int)(__a), (__b)) + +/* vec_cts */ + +#ifdef __VSX__ +#ifdef __XL_COMPAT_ALTIVEC__ +#define vec_cts(__a, __b) \ + _Generic((__a), \ + vector float: (vector signed int)__builtin_altivec_vctsxs( \ + (vector float)(__a), ((__b)&0x1F)), \ + vector double: __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + (vector signed long long)__builtin_vsx_xvcvdpsxws(__ret); \ + })) +#else // __XL_COMPAT_ALTIVEC__ +#define vec_cts(__a, __b) \ + _Generic((__a), \ + vector float: (vector signed int)__builtin_altivec_vctsxs( \ + (vector float)(__a), ((__b)&0x1F)), \ + vector double: __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + (vector signed long long)__builtin_convertvector( \ + __ret, vector signed long long); \ + })) +#endif // __XL_COMPAT_ALTIVEC__ +#else +#define vec_cts __builtin_altivec_vctsxs +#endif + +/* vec_vctsxs */ + +#define vec_vctsxs __builtin_altivec_vctsxs + +/* vec_ctu */ + +#ifdef __VSX__ +#ifdef __XL_COMPAT_ALTIVEC__ +#define vec_ctu(__a, __b) \ + _Generic((__a), \ + vector float: (vector unsigned int)__builtin_altivec_vctuxs( \ + (vector float)(__a), ((__b)&0x1F)), \ + vector double: __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + (vector unsigned long long)__builtin_vsx_xvcvdpuxws(__ret); \ + })) +#else // __XL_COMPAT_ALTIVEC__ +#define vec_ctu(__a, __b) \ + _Generic((__a), \ + vector float: (vector unsigned int)__builtin_altivec_vctuxs( \ + (vector float)(__a), ((__b)&0x1F)), \ + vector double: __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + (vector unsigned long long)__builtin_convertvector( \ + __ret, vector unsigned long long); \ + })) +#endif // __XL_COMPAT_ALTIVEC__ +#else +#define vec_ctu __builtin_altivec_vctuxs +#endif + +#ifdef __LITTLE_ENDIAN__ +/* vec_ctsl */ + +#ifdef __VSX__ +#define vec_ctsl(__a, __b) \ + _Generic( \ + (__a), vector float \ + : __extension__({ \ + vector float __ret = \ + (vector float)(__a) * \ + (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \ + __builtin_vsx_xvcvspsxds(__builtin_vsx_xxsldwi(__ret, __ret, 1)); \ + }), \ + vector double \ + : __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + __builtin_convertvector(__ret, vector signed long long); \ + })) + +/* vec_ctul */ + +#define vec_ctul(__a, __b) \ + _Generic( \ + (__a), vector float \ + : __extension__({ \ + vector float __ret = \ + (vector float)(__a) * \ + (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \ + __builtin_vsx_xvcvspuxds(__builtin_vsx_xxsldwi(__ret, __ret, 1)); \ + }), \ + vector double \ + : __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + __builtin_convertvector(__ret, vector unsigned long long); \ + })) +#endif +#else // __LITTLE_ENDIAN__ +/* vec_ctsl */ + +#ifdef __VSX__ +#define vec_ctsl(__a, __b) \ + _Generic((__a), \ + vector float: __extension__({ \ + vector float __ret = \ + (vector float)(__a) * \ + (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) << 23); \ + __builtin_vsx_xvcvspsxds(__ret); \ + }), \ + vector double: __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + __builtin_convertvector(__ret, vector signed long long); \ + })) + +/* vec_ctul */ + +#define vec_ctul(__a, __b) \ + _Generic((__a), vector float \ + : __extension__({ \ + vector float __ret = \ + (vector float)(__a) * \ + (vector float)(vector unsigned)((0x7f + ((__b)&0x1F)) \ + << 23); \ + __builtin_vsx_xvcvspuxds(__ret); \ + }), \ + vector double \ + : __extension__({ \ + vector double __ret = \ + (vector double)(__a) * \ + (vector double)(vector unsigned long long)((0x3ffULL + \ + ((__b)&0x1F)) \ + << 52); \ + __builtin_convertvector(__ret, vector unsigned long long); \ + })) +#endif +#endif // __LITTLE_ENDIAN__ + +/* vec_vctuxs */ + +#define vec_vctuxs __builtin_altivec_vctuxs + +/* vec_signext */ + +#ifdef __POWER9_VECTOR__ +static __inline__ vector signed int __ATTRS_o_ai +vec_signexti(vector signed char __a) { + return __builtin_altivec_vextsb2w(__a); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_signexti(vector signed short __a) { + return __builtin_altivec_vextsh2w(__a); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_signextll(vector signed char __a) { + return __builtin_altivec_vextsb2d(__a); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_signextll(vector signed short __a) { + return __builtin_altivec_vextsh2d(__a); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_signextll(vector signed int __a) { + return __builtin_altivec_vextsw2d(__a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_signextq(vector signed long long __a) { + return __builtin_altivec_vextsd2q(__a); +} +#endif + +/* vec_signed */ + +static __inline__ vector signed int __ATTRS_o_ai +vec_sld(vector signed int, vector signed int, unsigned const int __c); + +static __inline__ vector signed int __ATTRS_o_ai +vec_signed(vector float __a) { + return __builtin_convertvector(__a, vector signed int); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_signed(vector double __a) { + return __builtin_convertvector(__a, vector signed long long); +} + +static __inline__ vector signed int __attribute__((__always_inline__)) +vec_signed2(vector double __a, vector double __b) { + return (vector signed int) { __a[0], __a[1], __b[0], __b[1] }; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_signede(vector double __a) { +#ifdef __LITTLE_ENDIAN__ + vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a); + return vec_sld(__ret, __ret, 12); +#else + return __builtin_vsx_xvcvdpsxws(__a); +#endif +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_signedo(vector double __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvdpsxws(__a); +#else + vector signed int __ret = __builtin_vsx_xvcvdpsxws(__a); + return vec_sld(__ret, __ret, 12); +#endif +} +#endif + +/* vec_unsigned */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sld(vector unsigned int, vector unsigned int, unsigned const int __c); + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_unsigned(vector float __a) { + return __builtin_convertvector(__a, vector unsigned int); +} + +#ifdef __VSX__ +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_unsigned(vector double __a) { + return __builtin_convertvector(__a, vector unsigned long long); +} + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_unsigned2(vector double __a, vector double __b) { + return (vector unsigned int) { __a[0], __a[1], __b[0], __b[1] }; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_unsignede(vector double __a) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a); + return vec_sld(__ret, __ret, 12); +#else + return __builtin_vsx_xvcvdpuxws(__a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_unsignedo(vector double __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvdpuxws(__a); +#else + vector unsigned int __ret = __builtin_vsx_xvcvdpuxws(__a); + return vec_sld(__ret, __ret, 12); +#endif +} +#endif + +/* vec_float */ + +static __inline__ vector float __ATTRS_o_ai +vec_sld(vector float, vector float, unsigned const int __c); + +static __inline__ vector float __ATTRS_o_ai +vec_float(vector signed int __a) { + return __builtin_convertvector(__a, vector float); +} + +static __inline__ vector float __ATTRS_o_ai +vec_float(vector unsigned int __a) { + return __builtin_convertvector(__a, vector float); +} + +#ifdef __VSX__ +static __inline__ vector float __ATTRS_o_ai +vec_float2(vector signed long long __a, vector signed long long __b) { + return (vector float) { __a[0], __a[1], __b[0], __b[1] }; +} + +static __inline__ vector float __ATTRS_o_ai +vec_float2(vector unsigned long long __a, vector unsigned long long __b) { + return (vector float) { __a[0], __a[1], __b[0], __b[1] }; +} + +static __inline__ vector float __ATTRS_o_ai +vec_float2(vector double __a, vector double __b) { + return (vector float) { __a[0], __a[1], __b[0], __b[1] }; +} + +static __inline__ vector float __ATTRS_o_ai +vec_floate(vector signed long long __a) { +#ifdef __LITTLE_ENDIAN__ + vector float __ret = __builtin_vsx_xvcvsxdsp(__a); + return vec_sld(__ret, __ret, 12); +#else + return __builtin_vsx_xvcvsxdsp(__a); +#endif +} + +static __inline__ vector float __ATTRS_o_ai +vec_floate(vector unsigned long long __a) { +#ifdef __LITTLE_ENDIAN__ + vector float __ret = __builtin_vsx_xvcvuxdsp(__a); + return vec_sld(__ret, __ret, 12); +#else + return __builtin_vsx_xvcvuxdsp(__a); +#endif +} + +static __inline__ vector float __ATTRS_o_ai +vec_floate(vector double __a) { +#ifdef __LITTLE_ENDIAN__ + vector float __ret = __builtin_vsx_xvcvdpsp(__a); + return vec_sld(__ret, __ret, 12); +#else + return __builtin_vsx_xvcvdpsp(__a); +#endif +} + +static __inline__ vector float __ATTRS_o_ai +vec_floato(vector signed long long __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvsxdsp(__a); +#else + vector float __ret = __builtin_vsx_xvcvsxdsp(__a); + return vec_sld(__ret, __ret, 12); +#endif +} + +static __inline__ vector float __ATTRS_o_ai +vec_floato(vector unsigned long long __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvuxdsp(__a); +#else + vector float __ret = __builtin_vsx_xvcvuxdsp(__a); + return vec_sld(__ret, __ret, 12); +#endif +} + +static __inline__ vector float __ATTRS_o_ai +vec_floato(vector double __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvdpsp(__a); +#else + vector float __ret = __builtin_vsx_xvcvdpsp(__a); + return vec_sld(__ret, __ret, 12); +#endif +} +#endif + +/* vec_double */ + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai +vec_double(vector signed long long __a) { + return __builtin_convertvector(__a, vector double); +} + +static __inline__ vector double __ATTRS_o_ai +vec_double(vector unsigned long long __a) { + return __builtin_convertvector(__a, vector double); +} + +static __inline__ vector double __ATTRS_o_ai +vec_doublee(vector signed int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4)); +#else + return __builtin_vsx_xvcvsxwdp(__a); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_doublee(vector unsigned int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4)); +#else + return __builtin_vsx_xvcvuxwdp(__a); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_doublee(vector float __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4)); +#else + return __builtin_vsx_xvcvspdp(__a); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_doubleh(vector signed int __a) { + vector double __ret = {__a[0], __a[1]}; + return __ret; +} + +static __inline__ vector double __ATTRS_o_ai +vec_doubleh(vector unsigned int __a) { + vector double __ret = {__a[0], __a[1]}; + return __ret; +} + +static __inline__ vector double __ATTRS_o_ai +vec_doubleh(vector float __a) { + vector double __ret = {__a[0], __a[1]}; + return __ret; +} + +static __inline__ vector double __ATTRS_o_ai +vec_doublel(vector signed int __a) { + vector double __ret = {__a[2], __a[3]}; + return __ret; +} + +static __inline__ vector double __ATTRS_o_ai +vec_doublel(vector unsigned int __a) { + vector double __ret = {__a[2], __a[3]}; + return __ret; +} + +static __inline__ vector double __ATTRS_o_ai +vec_doublel(vector float __a) { + vector double __ret = {__a[2], __a[3]}; + return __ret; +} + +static __inline__ vector double __ATTRS_o_ai +vec_doubleo(vector signed int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvsxwdp(__a); +#else + return __builtin_vsx_xvcvsxwdp(vec_sld(__a, __a, 4)); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_doubleo(vector unsigned int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvuxwdp(__a); +#else + return __builtin_vsx_xvcvuxwdp(vec_sld(__a, __a, 4)); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_doubleo(vector float __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_vsx_xvcvspdp(__a); +#else + return __builtin_vsx_xvcvspdp(vec_sld(__a, __a, 4)); +#endif +} + +/* vec_cvf */ +static __inline__ vector double __ATTRS_o_ai vec_cvf(vector float __a) { + return vec_doublee(__a); +} + +static __inline__ vector float __ATTRS_o_ai vec_cvf(vector double __a) { + return vec_floate(__a); +} +#endif + +/* vec_div */ + +/* Integer vector divides (vectors are scalarized, elements divided + and the vectors reassembled). +*/ +static __inline__ vector signed char __ATTRS_o_ai +vec_div(vector signed char __a, vector signed char __b) { + return __a / __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_div(vector unsigned char __a, vector unsigned char __b) { + return __a / __b; +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_div(vector signed short __a, vector signed short __b) { + return __a / __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_div(vector unsigned short __a, vector unsigned short __b) { + return __a / __b; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_div(vector signed int __a, vector signed int __b) { + return __a / __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_div(vector unsigned int __a, vector unsigned int __b) { + return __a / __b; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_div(vector signed long long __a, vector signed long long __b) { + return __a / __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_div(vector unsigned long long __a, vector unsigned long long __b) { + return __a / __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_div(vector float __a, + vector float __b) { + return __a / __b; +} + +static __inline__ vector double __ATTRS_o_ai vec_div(vector double __a, + vector double __b) { + return __a / __b; +} +#endif + +/* vec_dive */ + +#ifdef __POWER10_VECTOR__ +static __inline__ vector signed int __ATTRS_o_ai +vec_dive(vector signed int __a, vector signed int __b) { + return __builtin_altivec_vdivesw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_dive(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vdiveuw(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_dive(vector signed long long __a, vector signed long long __b) { + return __builtin_altivec_vdivesd(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_dive(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vdiveud(__a, __b); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_dive(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __builtin_altivec_vdiveuq(__a, __b); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_dive(vector signed __int128 __a, vector signed __int128 __b) { + return __builtin_altivec_vdivesq(__a, __b); +} +#endif +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_div(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a / __b; +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_div(vector signed __int128 __a, vector signed __int128 __b) { + return __a / __b; +} +#endif /* __POWER10_VECTOR__ */ + +/* vec_xvtdiv */ + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_test_swdiv(vector double __a, + vector double __b) { + return __builtin_vsx_xvtdivdp(__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_test_swdivs(vector float __a, + vector float __b) { + return __builtin_vsx_xvtdivsp(__a, __b); +} +#endif + +/* vec_dss */ + +#define vec_dss __builtin_altivec_dss + +/* vec_dssall */ + +static __inline__ void __attribute__((__always_inline__)) vec_dssall(void) { + __builtin_altivec_dssall(); +} + +/* vec_dst */ +#define vec_dst(__PTR, __CW, __STR) \ + __builtin_altivec_dst((const void *)(__PTR), (__CW), (__STR)) + +/* vec_dstst */ +#define vec_dstst(__PTR, __CW, __STR) \ + __builtin_altivec_dstst((const void *)(__PTR), (__CW), (__STR)) + +/* vec_dststt */ +#define vec_dststt(__PTR, __CW, __STR) \ + __builtin_altivec_dststt((const void *)(__PTR), (__CW), (__STR)) + +/* vec_dstt */ +#define vec_dstt(__PTR, __CW, __STR) \ + __builtin_altivec_dstt((const void *)(__PTR), (__CW), (__STR)) + +/* vec_eqv */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed char __ATTRS_o_ai +vec_eqv(vector signed char __a, vector signed char __b) { + return (vector signed char)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_eqv(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_eqv(vector bool char __a, + vector bool char __b) { + return (vector bool char)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_eqv(vector signed short __a, vector signed short __b) { + return (vector signed short)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_eqv(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_eqv(vector bool short __a, vector bool short __b) { + return (vector bool short)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_eqv(vector signed int __a, vector signed int __b) { + return (vector signed int)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_eqv(vector unsigned int __a, vector unsigned int __b) { + return __builtin_vsx_xxleqv(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_eqv(vector bool int __a, + vector bool int __b) { + return (vector bool int)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_eqv(vector signed long long __a, vector signed long long __b) { + return (vector signed long long)__builtin_vsx_xxleqv( + (vector unsigned int)__a, (vector unsigned int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_eqv(vector unsigned long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__builtin_vsx_xxleqv( + (vector unsigned int)__a, (vector unsigned int)__b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_eqv(vector bool long long __a, vector bool long long __b) { + return (vector bool long long)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_eqv(vector float __a, + vector float __b) { + return (vector float)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} + +static __inline__ vector double __ATTRS_o_ai vec_eqv(vector double __a, + vector double __b) { + return (vector double)__builtin_vsx_xxleqv((vector unsigned int)__a, + (vector unsigned int)__b); +} +#endif + +/* vec_expte */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_expte(vector float __a) { + return __builtin_altivec_vexptefp(__a); +} + +/* vec_vexptefp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vexptefp(vector float __a) { + return __builtin_altivec_vexptefp(__a); +} + +/* vec_floor */ + +static __inline__ vector float __ATTRS_o_ai vec_floor(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvrspim(__a); +#else + return __builtin_altivec_vrfim(__a); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_floor(vector double __a) { + return __builtin_vsx_xvrdpim(__a); +} +#endif + +/* vec_roundm */ +static __inline__ vector float __ATTRS_o_ai vec_roundm(vector float __a) { + return vec_floor(__a); +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_roundm(vector double __a) { + return vec_floor(__a); +} +#endif + +/* vec_vrfim */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vrfim(vector float __a) { + return __builtin_altivec_vrfim(__a); +} + +/* vec_ld */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_ld(long __a, const vector signed char *__b) { + return (vector signed char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_ld(long __a, const signed char *__b) { + return (vector signed char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_ld(long __a, const vector unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_ld(long __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_ld(long __a, const vector bool char *__b) { + return (vector bool char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_ld(long __a, + const vector short *__b) { + return (vector short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_ld(long __a, const short *__b) { + return (vector short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_ld(long __a, const vector unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_ld(long __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_ld(long __a, const vector bool short *__b) { + return (vector bool short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_ld(long __a, + const vector pixel *__b) { + return (vector pixel)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_ld(long __a, + const vector int *__b) { + return (vector int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_ld(long __a, const int *__b) { + return (vector int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_ld(long __a, const vector unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_ld(long __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_ld(long __a, const vector bool int *__b) { + return (vector bool int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_ld(long __a, + const vector float *__b) { + return (vector float)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_ld(long __a, const float *__b) { + return (vector float)__builtin_altivec_lvx(__a, __b); +} + +/* vec_lvx */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvx(long __a, const vector signed char *__b) { + return (vector signed char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvx(long __a, const signed char *__b) { + return (vector signed char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvx(long __a, const vector unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvx(long __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_lvx(long __a, const vector bool char *__b) { + return (vector bool char)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvx(long __a, + const vector short *__b) { + return (vector short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvx(long __a, const short *__b) { + return (vector short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvx(long __a, const vector unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvx(long __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_lvx(long __a, const vector bool short *__b) { + return (vector bool short)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_lvx(long __a, + const vector pixel *__b) { + return (vector pixel)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvx(long __a, + const vector int *__b) { + return (vector int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvx(long __a, const int *__b) { + return (vector int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvx(long __a, const vector unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvx(long __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_lvx(long __a, const vector bool int *__b) { + return (vector bool int)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvx(long __a, + const vector float *__b) { + return (vector float)__builtin_altivec_lvx(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvx(long __a, const float *__b) { + return (vector float)__builtin_altivec_lvx(__a, __b); +} + +/* vec_lde */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lde(long __a, const signed char *__b) { + return (vector signed char)__builtin_altivec_lvebx(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lde(long __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvebx(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_lde(long __a, const short *__b) { + return (vector short)__builtin_altivec_lvehx(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lde(long __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvehx(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_lde(long __a, const int *__b) { + return (vector int)__builtin_altivec_lvewx(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lde(long __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvewx(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_lde(long __a, const float *__b) { + return (vector float)__builtin_altivec_lvewx(__a, __b); +} + +/* vec_lvebx */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvebx(long __a, const signed char *__b) { + return (vector signed char)__builtin_altivec_lvebx(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvebx(long __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvebx(__a, __b); +} + +/* vec_lvehx */ + +static __inline__ vector short __ATTRS_o_ai vec_lvehx(long __a, + const short *__b) { + return (vector short)__builtin_altivec_lvehx(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvehx(long __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvehx(__a, __b); +} + +/* vec_lvewx */ + +static __inline__ vector int __ATTRS_o_ai vec_lvewx(long __a, const int *__b) { + return (vector int)__builtin_altivec_lvewx(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvewx(long __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvewx(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvewx(long __a, + const float *__b) { + return (vector float)__builtin_altivec_lvewx(__a, __b); +} + +/* vec_ldl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_ldl(long __a, const vector signed char *__b) { + return (vector signed char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_ldl(long __a, const signed char *__b) { + return (vector signed char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_ldl(long __a, const vector unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_ldl(long __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_ldl(long __a, const vector bool char *__b) { + return (vector bool char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_ldl(long __a, + const vector short *__b) { + return (vector short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_ldl(long __a, const short *__b) { + return (vector short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_ldl(long __a, const vector unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_ldl(long __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_ldl(long __a, const vector bool short *__b) { + return (vector bool short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_ldl(long __a, + const vector pixel *__b) { + return (vector pixel short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_ldl(long __a, + const vector int *__b) { + return (vector int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_ldl(long __a, const int *__b) { + return (vector int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_ldl(long __a, const vector unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_ldl(long __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_ldl(long __a, const vector bool int *__b) { + return (vector bool int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_ldl(long __a, + const vector float *__b) { + return (vector float)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_ldl(long __a, const float *__b) { + return (vector float)__builtin_altivec_lvxl(__a, __b); +} + +/* vec_lvxl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvxl(long __a, const vector signed char *__b) { + return (vector signed char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvxl(long __a, const signed char *__b) { + return (vector signed char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvxl(long __a, const vector unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvxl(long __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_lvxl(long __a, const vector bool char *__b) { + return (vector bool char)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvxl(long __a, + const vector short *__b) { + return (vector short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvxl(long __a, + const short *__b) { + return (vector short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvxl(long __a, const vector unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvxl(long __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_lvxl(long __a, const vector bool short *__b) { + return (vector bool short)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_lvxl(long __a, + const vector pixel *__b) { + return (vector pixel)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvxl(long __a, + const vector int *__b) { + return (vector int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvxl(long __a, const int *__b) { + return (vector int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvxl(long __a, const vector unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvxl(long __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_lvxl(long __a, const vector bool int *__b) { + return (vector bool int)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvxl(long __a, + const vector float *__b) { + return (vector float)__builtin_altivec_lvxl(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvxl(long __a, + const float *__b) { + return (vector float)__builtin_altivec_lvxl(__a, __b); +} + +/* vec_loge */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_loge(vector float __a) { + return __builtin_altivec_vlogefp(__a); +} + +/* vec_vlogefp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vlogefp(vector float __a) { + return __builtin_altivec_vlogefp(__a); +} + +/* vec_lvsl */ + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const signed char *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsl(int __a, const signed char *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const unsigned char *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsl(int __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const short *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a, + const short *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const unsigned short *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsl(int __a, const unsigned short *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const int *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a, + const int *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const unsigned int *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsl(int __a, const unsigned int *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsl(int __a, const float *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsl(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsl(int __a, + const float *__b) { + return (vector unsigned char)__builtin_altivec_lvsl(__a, __b); +} +#endif + +/* vec_lvsr */ + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const signed char *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsr(int __a, const signed char *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const unsigned char *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsr(int __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const short *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a, + const short *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const unsigned short *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsr(int __a, const unsigned short *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const int *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a, + const int *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const unsigned int *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvsr(int __a, const unsigned int *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector unsigned char __ATTRS_o_ai + __attribute__((__deprecated__("use assignment for unaligned little endian \ +loads/stores"))) vec_lvsr(int __a, const float *__b) { + vector unsigned char mask = + (vector unsigned char)__builtin_altivec_lvsr(__a, __b); + vector unsigned char reverse = {15, 14, 13, 12, 11, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; + return vec_perm(mask, mask, reverse); +} +#else +static __inline__ vector unsigned char __ATTRS_o_ai vec_lvsr(int __a, + const float *__b) { + return (vector unsigned char)__builtin_altivec_lvsr(__a, __b); +} +#endif + +/* vec_madd */ +static __inline__ vector signed short __ATTRS_o_ai +vec_mladd(vector signed short, vector signed short, vector signed short); +static __inline__ vector signed short __ATTRS_o_ai +vec_mladd(vector signed short, vector unsigned short, vector unsigned short); +static __inline__ vector signed short __ATTRS_o_ai +vec_mladd(vector unsigned short, vector signed short, vector signed short); +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mladd(vector unsigned short, vector unsigned short, vector unsigned short); + +static __inline__ vector signed short __ATTRS_o_ai vec_madd( + vector signed short __a, vector signed short __b, vector signed short __c) { + return vec_mladd(__a, __b, __c); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_madd(vector signed short __a, vector unsigned short __b, + vector unsigned short __c) { + return vec_mladd(__a, __b, __c); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_madd(vector unsigned short __a, vector signed short __b, + vector signed short __c) { + return vec_mladd(__a, __b, __c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_madd(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return vec_mladd(__a, __b, __c); +} + +static __inline__ vector float __ATTRS_o_ai vec_madd(vector float __a, + vector float __b, + vector float __c) { +#ifdef __VSX__ + return __builtin_vsx_xvmaddasp(__a, __b, __c); +#else + return __builtin_altivec_vmaddfp(__a, __b, __c); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_madd(vector double __a, + vector double __b, + vector double __c) { + return __builtin_vsx_xvmaddadp(__a, __b, __c); +} +#endif + +/* vec_vmaddfp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vmaddfp(vector float __a, vector float __b, vector float __c) { + return __builtin_altivec_vmaddfp(__a, __b, __c); +} + +/* vec_madds */ + +static __inline__ vector signed short __attribute__((__always_inline__)) +vec_madds(vector signed short __a, vector signed short __b, + vector signed short __c) { + return __builtin_altivec_vmhaddshs(__a, __b, __c); +} + +/* vec_vmhaddshs */ +static __inline__ vector signed short __attribute__((__always_inline__)) +vec_vmhaddshs(vector signed short __a, vector signed short __b, + vector signed short __c) { + return __builtin_altivec_vmhaddshs(__a, __b, __c); +} + +/* vec_msub */ + +#ifdef __VSX__ +static __inline__ vector float __ATTRS_o_ai vec_msub(vector float __a, + vector float __b, + vector float __c) { + return __builtin_vsx_xvmsubasp(__a, __b, __c); +} + +static __inline__ vector double __ATTRS_o_ai vec_msub(vector double __a, + vector double __b, + vector double __c) { + return __builtin_vsx_xvmsubadp(__a, __b, __c); +} +#endif + +/* vec_max */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_max(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vmaxsb(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_max(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vmaxsb((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_max(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vmaxsb(__a, (vector signed char)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_max(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vmaxub(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_max(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vmaxub((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_max(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a, + vector short __b) { + return __builtin_altivec_vmaxsh(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_max(vector bool short __a, + vector short __b) { + return __builtin_altivec_vmaxsh((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_max(vector short __a, + vector bool short __b) { + return __builtin_altivec_vmaxsh(__a, (vector short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_max(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vmaxuh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_max(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_max(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a, + vector int __b) { + return __builtin_altivec_vmaxsw(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_max(vector bool int __a, + vector int __b) { + return __builtin_altivec_vmaxsw((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_max(vector int __a, + vector bool int __b) { + return __builtin_altivec_vmaxsw(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_max(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vmaxuw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_max(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_max(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_max(vector signed long long __a, vector signed long long __b) { + return __builtin_altivec_vmaxsd(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_max(vector bool long long __a, vector signed long long __b) { + return __builtin_altivec_vmaxsd((vector signed long long)__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_max(vector signed long long __a, vector bool long long __b) { + return __builtin_altivec_vmaxsd(__a, (vector signed long long)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_max(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vmaxud(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_max(vector bool long long __a, vector unsigned long long __b) { + return __builtin_altivec_vmaxud((vector unsigned long long)__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_max(vector unsigned long long __a, vector bool long long __b) { + return __builtin_altivec_vmaxud(__a, (vector unsigned long long)__b); +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_max(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvmaxsp(__a, __b); +#else + return __builtin_altivec_vmaxfp(__a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_max(vector double __a, + vector double __b) { + return __builtin_vsx_xvmaxdp(__a, __b); +} +#endif + +/* vec_vmaxsb */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vmaxsb(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vmaxsb(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vmaxsb(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vmaxsb((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vmaxsb(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vmaxsb(__a, (vector signed char)__b); +} + +/* vec_vmaxub */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vmaxub(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vmaxub(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vmaxub(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vmaxub((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vmaxub(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vmaxub(__a, (vector unsigned char)__b); +} + +/* vec_vmaxsh */ + +static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a, + vector short __b) { + return __builtin_altivec_vmaxsh(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector bool short __a, + vector short __b) { + return __builtin_altivec_vmaxsh((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vmaxsh(vector short __a, + vector bool short __b) { + return __builtin_altivec_vmaxsh(__a, (vector short)__b); +} + +/* vec_vmaxuh */ + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vmaxuh(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vmaxuh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vmaxuh(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vmaxuh((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vmaxuh(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vmaxuh(__a, (vector unsigned short)__b); +} + +/* vec_vmaxsw */ + +static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a, + vector int __b) { + return __builtin_altivec_vmaxsw(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector bool int __a, + vector int __b) { + return __builtin_altivec_vmaxsw((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vmaxsw(vector int __a, + vector bool int __b) { + return __builtin_altivec_vmaxsw(__a, (vector int)__b); +} + +/* vec_vmaxuw */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vmaxuw(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vmaxuw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vmaxuw(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vmaxuw((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vmaxuw(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vmaxuw(__a, (vector unsigned int)__b); +} + +/* vec_vmaxfp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vmaxfp(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvmaxsp(__a, __b); +#else + return __builtin_altivec_vmaxfp(__a, __b); +#endif +} + +/* vec_mergeh */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_mergeh(vector signed char __a, vector signed char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12, + 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, + 0x06, 0x16, 0x07, 0x17)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_mergeh(vector unsigned char __a, vector unsigned char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12, + 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, + 0x06, 0x16, 0x07, 0x17)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_mergeh(vector bool char __a, vector bool char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12, + 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, + 0x06, 0x16, 0x07, 0x17)); +} + +static __inline__ vector short __ATTRS_o_ai vec_mergeh(vector short __a, + vector short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mergeh(vector unsigned short __a, vector unsigned short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_mergeh(vector bool short __a, vector bool short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_mergeh(vector pixel __a, + vector pixel __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector int __ATTRS_o_ai vec_mergeh(vector int __a, + vector int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mergeh(vector unsigned int __a, vector unsigned int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_mergeh(vector bool int __a, + vector bool int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector float __ATTRS_o_ai vec_mergeh(vector float __a, + vector float __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergeh(vector signed long long __a, vector signed long long __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergeh(vector signed long long __a, vector bool long long __b) { + return vec_perm(__a, (vector signed long long)__b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergeh(vector bool long long __a, vector signed long long __b) { + return vec_perm((vector signed long long)__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergeh(vector unsigned long long __a, vector unsigned long long __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergeh(vector unsigned long long __a, vector bool long long __b) { + return vec_perm(__a, (vector unsigned long long)__b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergeh(vector bool long long __a, vector unsigned long long __b) { + return vec_perm((vector unsigned long long)__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_mergeh(vector bool long long __a, vector bool long long __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector double __ATTRS_o_ai vec_mergeh(vector double __a, + vector double __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} +static __inline__ vector double __ATTRS_o_ai +vec_mergeh(vector double __a, vector bool long long __b) { + return vec_perm(__a, (vector double)__b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} +static __inline__ vector double __ATTRS_o_ai +vec_mergeh(vector bool long long __a, vector double __b) { + return vec_perm((vector double)__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17)); +} +#endif + +/* vec_vmrghb */ + +#define __builtin_altivec_vmrghb vec_vmrghb + +static __inline__ vector signed char __ATTRS_o_ai +vec_vmrghb(vector signed char __a, vector signed char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12, + 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, + 0x06, 0x16, 0x07, 0x17)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vmrghb(vector unsigned char __a, vector unsigned char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12, + 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, + 0x06, 0x16, 0x07, 0x17)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vmrghb(vector bool char __a, vector bool char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x10, 0x01, 0x11, 0x02, 0x12, + 0x03, 0x13, 0x04, 0x14, 0x05, 0x15, + 0x06, 0x16, 0x07, 0x17)); +} + +/* vec_vmrghh */ + +#define __builtin_altivec_vmrghh vec_vmrghh + +static __inline__ vector short __ATTRS_o_ai vec_vmrghh(vector short __a, + vector short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vmrghh(vector unsigned short __a, vector unsigned short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vmrghh(vector bool short __a, vector bool short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vmrghh(vector pixel __a, + vector pixel __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, + 0x12, 0x13, 0x04, 0x05, 0x14, 0x15, + 0x06, 0x07, 0x16, 0x17)); +} + +/* vec_vmrghw */ + +#define __builtin_altivec_vmrghw vec_vmrghw + +static __inline__ vector int __ATTRS_o_ai vec_vmrghw(vector int __a, + vector int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vmrghw(vector unsigned int __a, vector unsigned int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vmrghw(vector bool int __a, + vector bool int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +static __inline__ vector float __ATTRS_o_ai vec_vmrghw(vector float __a, + vector float __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x04, 0x05, 0x06, 0x07, + 0x14, 0x15, 0x16, 0x17)); +} + +/* vec_mergel */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_mergel(vector signed char __a, vector signed char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, + 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, + 0x0E, 0x1E, 0x0F, 0x1F)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_mergel(vector unsigned char __a, vector unsigned char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, + 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, + 0x0E, 0x1E, 0x0F, 0x1F)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_mergel(vector bool char __a, vector bool char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, + 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, + 0x0E, 0x1E, 0x0F, 0x1F)); +} + +static __inline__ vector short __ATTRS_o_ai vec_mergel(vector short __a, + vector short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mergel(vector unsigned short __a, vector unsigned short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_mergel(vector bool short __a, vector bool short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_mergel(vector pixel __a, + vector pixel __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector int __ATTRS_o_ai vec_mergel(vector int __a, + vector int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mergel(vector unsigned int __a, vector unsigned int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_mergel(vector bool int __a, + vector bool int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector float __ATTRS_o_ai vec_mergel(vector float __a, + vector float __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergel(vector signed long long __a, vector signed long long __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergel(vector signed long long __a, vector bool long long __b) { + return vec_perm(__a, (vector signed long long)__b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergel(vector bool long long __a, vector signed long long __b) { + return vec_perm((vector signed long long)__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergel(vector unsigned long long __a, vector unsigned long long __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergel(vector unsigned long long __a, vector bool long long __b) { + return vec_perm(__a, (vector unsigned long long)__b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergel(vector bool long long __a, vector unsigned long long __b) { + return vec_perm((vector unsigned long long)__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector bool long long __ATTRS_o_ai +vec_mergel(vector bool long long __a, vector bool long long __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector double __ATTRS_o_ai vec_mergel(vector double __a, + vector double __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector double __ATTRS_o_ai +vec_mergel(vector double __a, vector bool long long __b) { + return vec_perm(__a, (vector double)__b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +static __inline__ vector double __ATTRS_o_ai +vec_mergel(vector bool long long __a, vector double __b) { + return vec_perm((vector double)__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x18, 0X19, 0x1A, 0x1B, + 0x1C, 0x1D, 0x1E, 0x1F)); +} +#endif + +/* vec_vmrglb */ + +#define __builtin_altivec_vmrglb vec_vmrglb + +static __inline__ vector signed char __ATTRS_o_ai +vec_vmrglb(vector signed char __a, vector signed char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, + 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, + 0x0E, 0x1E, 0x0F, 0x1F)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vmrglb(vector unsigned char __a, vector unsigned char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, + 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, + 0x0E, 0x1E, 0x0F, 0x1F)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vmrglb(vector bool char __a, vector bool char __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x18, 0x09, 0x19, 0x0A, 0x1A, + 0x0B, 0x1B, 0x0C, 0x1C, 0x0D, 0x1D, + 0x0E, 0x1E, 0x0F, 0x1F)); +} + +/* vec_vmrglh */ + +#define __builtin_altivec_vmrglh vec_vmrglh + +static __inline__ vector short __ATTRS_o_ai vec_vmrglh(vector short __a, + vector short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vmrglh(vector unsigned short __a, vector unsigned short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vmrglh(vector bool short __a, vector bool short __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vmrglh(vector pixel __a, + vector pixel __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x18, 0x19, 0x0A, 0x0B, + 0x1A, 0x1B, 0x0C, 0x0D, 0x1C, 0x1D, + 0x0E, 0x0F, 0x1E, 0x1F)); +} + +/* vec_vmrglw */ + +#define __builtin_altivec_vmrglw vec_vmrglw + +static __inline__ vector int __ATTRS_o_ai vec_vmrglw(vector int __a, + vector int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vmrglw(vector unsigned int __a, vector unsigned int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vmrglw(vector bool int __a, + vector bool int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector float __ATTRS_o_ai vec_vmrglw(vector float __a, + vector float __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x08, 0x09, 0x0A, 0x0B, 0x18, 0x19, + 0x1A, 0x1B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +#ifdef __POWER8_VECTOR__ +/* vec_mergee */ + +static __inline__ vector bool int __ATTRS_o_ai vec_mergee(vector bool int __a, + vector bool int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B, + 0x18, 0x19, 0x1A, 0x1B)); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_mergee(vector signed int __a, vector signed int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B, + 0x18, 0x19, 0x1A, 0x1B)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mergee(vector unsigned int __a, vector unsigned int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B, + 0x18, 0x19, 0x1A, 0x1B)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_mergee(vector bool long long __a, vector bool long long __b) { + return vec_mergeh(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergee(vector signed long long __a, vector signed long long __b) { + return vec_mergeh(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergee(vector unsigned long long __a, vector unsigned long long __b) { + return vec_mergeh(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_mergee(vector float __a, vector float __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x10, 0x11, + 0x12, 0x13, 0x08, 0x09, 0x0A, 0x0B, + 0x18, 0x19, 0x1A, 0x1B)); +} + +static __inline__ vector double __ATTRS_o_ai +vec_mergee(vector double __a, vector double __b) { + return vec_mergeh(__a, __b); +} + +/* vec_mergeo */ + +static __inline__ vector bool int __ATTRS_o_ai vec_mergeo(vector bool int __a, + vector bool int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15, + 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_mergeo(vector signed int __a, vector signed int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15, + 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mergeo(vector unsigned int __a, vector unsigned int __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15, + 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_mergeo(vector bool long long __a, vector bool long long __b) { + return vec_mergel(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_mergeo(vector signed long long __a, vector signed long long __b) { + return vec_mergel(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mergeo(vector unsigned long long __a, vector unsigned long long __b) { + return vec_mergel(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_mergeo(vector float __a, vector float __b) { + return vec_perm(__a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x14, 0x15, + 0x16, 0x17, 0x0C, 0x0D, 0x0E, 0x0F, + 0x1C, 0x1D, 0x1E, 0x1F)); +} + +static __inline__ vector double __ATTRS_o_ai +vec_mergeo(vector double __a, vector double __b) { + return vec_mergel(__a, __b); +} + +#endif + +/* vec_mfvscr */ + +static __inline__ vector unsigned short __attribute__((__always_inline__)) +vec_mfvscr(void) { + return __builtin_altivec_mfvscr(); +} + +/* vec_min */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_min(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vminsb(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_min(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vminsb((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_min(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vminsb(__a, (vector signed char)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_min(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vminub(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_min(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vminub((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_min(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vminub(__a, (vector unsigned char)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a, + vector short __b) { + return __builtin_altivec_vminsh(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_min(vector bool short __a, + vector short __b) { + return __builtin_altivec_vminsh((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_min(vector short __a, + vector bool short __b) { + return __builtin_altivec_vminsh(__a, (vector short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_min(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vminuh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_min(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vminuh((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_min(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vminuh(__a, (vector unsigned short)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a, + vector int __b) { + return __builtin_altivec_vminsw(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_min(vector bool int __a, + vector int __b) { + return __builtin_altivec_vminsw((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_min(vector int __a, + vector bool int __b) { + return __builtin_altivec_vminsw(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_min(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vminuw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_min(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vminuw((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_min(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vminuw(__a, (vector unsigned int)__b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_min(vector signed long long __a, vector signed long long __b) { + return __builtin_altivec_vminsd(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_min(vector bool long long __a, vector signed long long __b) { + return __builtin_altivec_vminsd((vector signed long long)__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_min(vector signed long long __a, vector bool long long __b) { + return __builtin_altivec_vminsd(__a, (vector signed long long)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_min(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vminud(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_min(vector bool long long __a, vector unsigned long long __b) { + return __builtin_altivec_vminud((vector unsigned long long)__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_min(vector unsigned long long __a, vector bool long long __b) { + return __builtin_altivec_vminud(__a, (vector unsigned long long)__b); +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_min(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvminsp(__a, __b); +#else + return __builtin_altivec_vminfp(__a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_min(vector double __a, + vector double __b) { + return __builtin_vsx_xvmindp(__a, __b); +} +#endif + +/* vec_vminsb */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vminsb(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vminsb(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vminsb(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vminsb((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vminsb(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vminsb(__a, (vector signed char)__b); +} + +/* vec_vminub */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vminub(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vminub(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vminub(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vminub((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vminub(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vminub(__a, (vector unsigned char)__b); +} + +/* vec_vminsh */ + +static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a, + vector short __b) { + return __builtin_altivec_vminsh(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector bool short __a, + vector short __b) { + return __builtin_altivec_vminsh((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vminsh(vector short __a, + vector bool short __b) { + return __builtin_altivec_vminsh(__a, (vector short)__b); +} + +/* vec_vminuh */ + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vminuh(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vminuh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vminuh(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vminuh((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vminuh(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vminuh(__a, (vector unsigned short)__b); +} + +/* vec_vminsw */ + +static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a, + vector int __b) { + return __builtin_altivec_vminsw(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector bool int __a, + vector int __b) { + return __builtin_altivec_vminsw((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vminsw(vector int __a, + vector bool int __b) { + return __builtin_altivec_vminsw(__a, (vector int)__b); +} + +/* vec_vminuw */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vminuw(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vminuw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vminuw(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vminuw((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vminuw(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vminuw(__a, (vector unsigned int)__b); +} + +/* vec_vminfp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vminfp(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvminsp(__a, __b); +#else + return __builtin_altivec_vminfp(__a, __b); +#endif +} + +/* vec_mladd */ + +#define __builtin_altivec_vmladduhm vec_mladd + +static __inline__ vector short __ATTRS_o_ai vec_mladd(vector short __a, + vector short __b, + vector short __c) { + return __a * __b + __c; +} + +static __inline__ vector short __ATTRS_o_ai vec_mladd( + vector short __a, vector unsigned short __b, vector unsigned short __c) { + return __a * (vector short)__b + (vector short)__c; +} + +static __inline__ vector short __ATTRS_o_ai vec_mladd(vector unsigned short __a, + vector short __b, + vector short __c) { + return (vector short)__a * __b + __c; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mladd(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return __a * __b + __c; +} + +/* vec_vmladduhm */ + +static __inline__ vector short __ATTRS_o_ai vec_vmladduhm(vector short __a, + vector short __b, + vector short __c) { + return __a * __b + __c; +} + +static __inline__ vector short __ATTRS_o_ai vec_vmladduhm( + vector short __a, vector unsigned short __b, vector unsigned short __c) { + return __a * (vector short)__b + (vector short)__c; +} + +static __inline__ vector short __ATTRS_o_ai +vec_vmladduhm(vector unsigned short __a, vector short __b, vector short __c) { + return (vector short)__a * __b + __c; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vmladduhm(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return __a * __b + __c; +} + +/* vec_mradds */ + +static __inline__ vector short __attribute__((__always_inline__)) +vec_mradds(vector short __a, vector short __b, vector short __c) { + return __builtin_altivec_vmhraddshs(__a, __b, __c); +} + +/* vec_vmhraddshs */ + +static __inline__ vector short __attribute__((__always_inline__)) +vec_vmhraddshs(vector short __a, vector short __b, vector short __c) { + return __builtin_altivec_vmhraddshs(__a, __b, __c); +} + +/* vec_msum */ + +static __inline__ vector int __ATTRS_o_ai vec_msum(vector signed char __a, + vector unsigned char __b, + vector int __c) { + return __builtin_altivec_vmsummbm(__a, __b, __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_msum(vector unsigned char __a, vector unsigned char __b, + vector unsigned int __c) { + return __builtin_altivec_vmsumubm(__a, __b, __c); +} + +static __inline__ vector int __ATTRS_o_ai vec_msum(vector short __a, + vector short __b, + vector int __c) { + return __builtin_altivec_vmsumshm(__a, __b, __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_msum(vector unsigned short __a, vector unsigned short __b, + vector unsigned int __c) { + return __builtin_altivec_vmsumuhm(__a, __b, __c); +} + +/* vec_msumc */ + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_msumc(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vmsumcud(__a, __b, __c); +} +#endif + +/* vec_vmsummbm */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vmsummbm(vector signed char __a, vector unsigned char __b, vector int __c) { + return __builtin_altivec_vmsummbm(__a, __b, __c); +} + +/* vec_vmsumubm */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vmsumubm(vector unsigned char __a, vector unsigned char __b, + vector unsigned int __c) { + return __builtin_altivec_vmsumubm(__a, __b, __c); +} + +/* vec_vmsumshm */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vmsumshm(vector short __a, vector short __b, vector int __c) { + return __builtin_altivec_vmsumshm(__a, __b, __c); +} + +/* vec_vmsumuhm */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vmsumuhm(vector unsigned short __a, vector unsigned short __b, + vector unsigned int __c) { + return __builtin_altivec_vmsumuhm(__a, __b, __c); +} + +/* vec_msums */ + +static __inline__ vector int __ATTRS_o_ai vec_msums(vector short __a, + vector short __b, + vector int __c) { + return __builtin_altivec_vmsumshs(__a, __b, __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_msums(vector unsigned short __a, vector unsigned short __b, + vector unsigned int __c) { + return __builtin_altivec_vmsumuhs(__a, __b, __c); +} + +/* vec_vmsumshs */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vmsumshs(vector short __a, vector short __b, vector int __c) { + return __builtin_altivec_vmsumshs(__a, __b, __c); +} + +/* vec_vmsumuhs */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vmsumuhs(vector unsigned short __a, vector unsigned short __b, + vector unsigned int __c) { + return __builtin_altivec_vmsumuhs(__a, __b, __c); +} + +/* vec_mtvscr */ + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector signed char __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned char __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool char __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector short __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned short __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool short __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector pixel __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector int __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector unsigned int __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector bool int __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +static __inline__ void __ATTRS_o_ai vec_mtvscr(vector float __a) { + __builtin_altivec_mtvscr((vector int)__a); +} + +/* vec_mul */ + +/* Integer vector multiplication will involve multiplication of the odd/even + elements separately, then truncating the results and moving to the + result vector. +*/ +static __inline__ vector signed char __ATTRS_o_ai +vec_mul(vector signed char __a, vector signed char __b) { + return __a * __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_mul(vector unsigned char __a, vector unsigned char __b) { + return __a * __b; +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_mul(vector signed short __a, vector signed short __b) { + return __a * __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mul(vector unsigned short __a, vector unsigned short __b) { + return __a * __b; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_mul(vector signed int __a, vector signed int __b) { + return __a * __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mul(vector unsigned int __a, vector unsigned int __b) { + return __a * __b; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_mul(vector signed long long __a, vector signed long long __b) { + return __a * __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mul(vector unsigned long long __a, vector unsigned long long __b) { + return __a * __b; +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_mul(vector float __a, + vector float __b) { + return __a * __b; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_mul(vector double __a, + vector double __b) { + return __a * __b; +} +#endif + +/* The vmulos* and vmules* instructions have a big endian bias, so + we must reverse the meaning of "even" and "odd" for little endian. */ + +/* vec_mule */ + +static __inline__ vector short __ATTRS_o_ai vec_mule(vector signed char __a, + vector signed char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulosb(__a, __b); +#else + return __builtin_altivec_vmulesb(__a, __b); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mule(vector unsigned char __a, vector unsigned char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuloub(__a, __b); +#else + return __builtin_altivec_vmuleub(__a, __b); +#endif +} + +static __inline__ vector int __ATTRS_o_ai vec_mule(vector short __a, + vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulosh(__a, __b); +#else + return __builtin_altivec_vmulesh(__a, __b); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mule(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulouh(__a, __b); +#else + return __builtin_altivec_vmuleuh(__a, __b); +#endif +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_mule(vector signed int __a, vector signed int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulosw(__a, __b); +#else + return __builtin_altivec_vmulesw(__a, __b); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mule(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulouw(__a, __b); +#else + return __builtin_altivec_vmuleuw(__a, __b); +#endif +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_mule(vector signed long long __a, vector signed long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulosd(__a, __b); +#else + return __builtin_altivec_vmulesd(__a, __b); +#endif +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_mule(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuloud(__a, __b); +#else + return __builtin_altivec_vmuleud(__a, __b); +#endif +} +#endif + +/* vec_vmulesb */ + +static __inline__ vector short __attribute__((__always_inline__)) +vec_vmulesb(vector signed char __a, vector signed char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulosb(__a, __b); +#else + return __builtin_altivec_vmulesb(__a, __b); +#endif +} + +/* vec_vmuleub */ + +static __inline__ vector unsigned short __attribute__((__always_inline__)) +vec_vmuleub(vector unsigned char __a, vector unsigned char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuloub(__a, __b); +#else + return __builtin_altivec_vmuleub(__a, __b); +#endif +} + +/* vec_vmulesh */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vmulesh(vector short __a, vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulosh(__a, __b); +#else + return __builtin_altivec_vmulesh(__a, __b); +#endif +} + +/* vec_vmuleuh */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vmuleuh(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulouh(__a, __b); +#else + return __builtin_altivec_vmuleuh(__a, __b); +#endif +} + +/* vec_mulh */ + +#ifdef __POWER10_VECTOR__ +static __inline__ vector signed int __ATTRS_o_ai +vec_mulh(vector signed int __a, vector signed int __b) { + return __builtin_altivec_vmulhsw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mulh(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vmulhuw(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_mulh(vector signed long long __a, vector signed long long __b) { + return __builtin_altivec_vmulhsd(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mulh(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vmulhud(__a, __b); +} +#endif + +/* vec_mulo */ + +static __inline__ vector short __ATTRS_o_ai vec_mulo(vector signed char __a, + vector signed char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulesb(__a, __b); +#else + return __builtin_altivec_vmulosb(__a, __b); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_mulo(vector unsigned char __a, vector unsigned char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuleub(__a, __b); +#else + return __builtin_altivec_vmuloub(__a, __b); +#endif +} + +static __inline__ vector int __ATTRS_o_ai vec_mulo(vector short __a, + vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulesh(__a, __b); +#else + return __builtin_altivec_vmulosh(__a, __b); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mulo(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuleuh(__a, __b); +#else + return __builtin_altivec_vmulouh(__a, __b); +#endif +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_mulo(vector signed int __a, vector signed int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulesw(__a, __b); +#else + return __builtin_altivec_vmulosw(__a, __b); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mulo(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuleuw(__a, __b); +#else + return __builtin_altivec_vmulouw(__a, __b); +#endif +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_mulo(vector signed long long __a, vector signed long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulesd(__a, __b); +#else + return __builtin_altivec_vmulosd(__a, __b); +#endif +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_mulo(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuleud(__a, __b); +#else + return __builtin_altivec_vmuloud(__a, __b); +#endif +} +#endif + +/* vec_vmulosb */ + +static __inline__ vector short __attribute__((__always_inline__)) +vec_vmulosb(vector signed char __a, vector signed char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulesb(__a, __b); +#else + return __builtin_altivec_vmulosb(__a, __b); +#endif +} + +/* vec_vmuloub */ + +static __inline__ vector unsigned short __attribute__((__always_inline__)) +vec_vmuloub(vector unsigned char __a, vector unsigned char __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuleub(__a, __b); +#else + return __builtin_altivec_vmuloub(__a, __b); +#endif +} + +/* vec_vmulosh */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vmulosh(vector short __a, vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmulesh(__a, __b); +#else + return __builtin_altivec_vmulosh(__a, __b); +#endif +} + +/* vec_vmulouh */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vmulouh(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vmuleuh(__a, __b); +#else + return __builtin_altivec_vmulouh(__a, __b); +#endif +} + +/* vec_nand */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed char __ATTRS_o_ai +vec_nand(vector signed char __a, vector signed char __b) { + return ~(__a & __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_nand(vector signed char __a, vector bool char __b) { + return ~(__a & (vector signed char)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_nand(vector bool char __a, vector signed char __b) { + return (vector signed char)~(__a & (vector bool char)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_nand(vector unsigned char __a, vector unsigned char __b) { + return ~(__a & __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_nand(vector unsigned char __a, vector bool char __b) { + return ~(__a & (vector unsigned char)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_nand(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)~(__a & (vector bool char)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_nand(vector bool char __a, + vector bool char __b) { + return ~(__a & __b); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_nand(vector signed short __a, vector signed short __b) { + return ~(__a & __b); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_nand(vector signed short __a, vector bool short __b) { + return ~(__a & (vector signed short)__b); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_nand(vector bool short __a, vector signed short __b) { + return (vector signed short)~(__a & (vector bool short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_nand(vector unsigned short __a, vector unsigned short __b) { + return ~(__a & __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_nand(vector unsigned short __a, vector bool short __b) { + return ~(__a & (vector unsigned short)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_nand(vector bool short __a, vector bool short __b) { + return ~(__a & __b); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_nand(vector signed int __a, vector signed int __b) { + return ~(__a & __b); +} + +static __inline__ vector signed int __ATTRS_o_ai vec_nand(vector signed int __a, + vector bool int __b) { + return ~(__a & (vector signed int)__b); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_nand(vector bool int __a, vector signed int __b) { + return (vector signed int)~(__a & (vector bool int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_nand(vector unsigned int __a, vector unsigned int __b) { + return ~(__a & __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_nand(vector unsigned int __a, vector bool int __b) { + return ~(__a & (vector unsigned int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_nand(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)~(__a & (vector bool int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_nand(vector bool int __a, + vector bool int __b) { + return ~(__a & __b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_nand(vector float __a, vector float __b) { + return (vector float)(~((vector unsigned int)__a & + (vector unsigned int)__b)); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_nand(vector signed long long __a, vector signed long long __b) { + return ~(__a & __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_nand(vector signed long long __a, vector bool long long __b) { + return ~(__a & (vector signed long long)__b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_nand(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)~(__a & (vector bool long long)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_nand(vector unsigned long long __a, vector unsigned long long __b) { + return ~(__a & __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_nand(vector unsigned long long __a, vector bool long long __b) { + return ~(__a & (vector unsigned long long)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_nand(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)~(__a & (vector bool long long)__b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_nand(vector bool long long __a, vector bool long long __b) { + return ~(__a & __b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_nand(vector double __a, vector double __b) { + return (vector double)(~((vector unsigned long long)__a & + (vector unsigned long long)__b)); +} + +#endif + +/* vec_nmadd */ + +#ifdef __VSX__ +static __inline__ vector float __ATTRS_o_ai vec_nmadd(vector float __a, + vector float __b, + vector float __c) { + return __builtin_vsx_xvnmaddasp(__a, __b, __c); +} + +static __inline__ vector double __ATTRS_o_ai vec_nmadd(vector double __a, + vector double __b, + vector double __c) { + return __builtin_vsx_xvnmaddadp(__a, __b, __c); +} +#endif + +/* vec_nmsub */ + +static __inline__ vector float __ATTRS_o_ai vec_nmsub(vector float __a, + vector float __b, + vector float __c) { +#ifdef __VSX__ + return __builtin_vsx_xvnmsubasp(__a, __b, __c); +#else + return __builtin_altivec_vnmsubfp(__a, __b, __c); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_nmsub(vector double __a, + vector double __b, + vector double __c) { + return __builtin_vsx_xvnmsubadp(__a, __b, __c); +} +#endif + +/* vec_vnmsubfp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vnmsubfp(vector float __a, vector float __b, vector float __c) { + return __builtin_altivec_vnmsubfp(__a, __b, __c); +} + +/* vec_nor */ + +#define __builtin_altivec_vnor vec_nor + +static __inline__ vector signed char __ATTRS_o_ai +vec_nor(vector signed char __a, vector signed char __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_nor(vector unsigned char __a, vector unsigned char __b) { + return ~(__a | __b); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_nor(vector bool char __a, + vector bool char __b) { + return ~(__a | __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_nor(vector short __a, + vector short __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_nor(vector unsigned short __a, vector unsigned short __b) { + return ~(__a | __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_nor(vector bool short __a, vector bool short __b) { + return ~(__a | __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_nor(vector int __a, + vector int __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_nor(vector unsigned int __a, vector unsigned int __b) { + return ~(__a | __b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_nor(vector bool int __a, + vector bool int __b) { + return ~(__a | __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_nor(vector float __a, + vector float __b) { + vector unsigned int __res = + ~((vector unsigned int)__a | (vector unsigned int)__b); + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_nor(vector double __a, + vector double __b) { + vector unsigned long long __res = + ~((vector unsigned long long)__a | (vector unsigned long long)__b); + return (vector double)__res; +} +#endif + +/* vec_vnor */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vnor(vector signed char __a, vector signed char __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vnor(vector unsigned char __a, vector unsigned char __b) { + return ~(__a | __b); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vnor(vector bool char __a, + vector bool char __b) { + return ~(__a | __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vnor(vector short __a, + vector short __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vnor(vector unsigned short __a, vector unsigned short __b) { + return ~(__a | __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vnor(vector bool short __a, vector bool short __b) { + return ~(__a | __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vnor(vector int __a, + vector int __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vnor(vector unsigned int __a, vector unsigned int __b) { + return ~(__a | __b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vnor(vector bool int __a, + vector bool int __b) { + return ~(__a | __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_vnor(vector float __a, + vector float __b) { + vector unsigned int __res = + ~((vector unsigned int)__a | (vector unsigned int)__b); + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_nor(vector signed long long __a, vector signed long long __b) { + return ~(__a | __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_nor(vector unsigned long long __a, vector unsigned long long __b) { + return ~(__a | __b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_nor(vector bool long long __a, vector bool long long __b) { + return ~(__a | __b); +} +#endif + +/* vec_or */ + +#define __builtin_altivec_vor vec_or + +static __inline__ vector signed char __ATTRS_o_ai +vec_or(vector signed char __a, vector signed char __b) { + return __a | __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_or(vector bool char __a, vector signed char __b) { + return (vector signed char)__a | __b; +} + +static __inline__ vector signed char __ATTRS_o_ai vec_or(vector signed char __a, + vector bool char __b) { + return __a | (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_or(vector unsigned char __a, vector unsigned char __b) { + return __a | __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_or(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a | __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_or(vector unsigned char __a, vector bool char __b) { + return __a | (vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_or(vector bool char __a, + vector bool char __b) { + return __a | __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a, + vector short __b) { + return __a | __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_or(vector bool short __a, + vector short __b) { + return (vector short)__a | __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_or(vector short __a, + vector bool short __b) { + return __a | (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_or(vector unsigned short __a, vector unsigned short __b) { + return __a | __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_or(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a | __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_or(vector unsigned short __a, vector bool short __b) { + return __a | (vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai vec_or(vector bool short __a, + vector bool short __b) { + return __a | __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a, + vector int __b) { + return __a | __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_or(vector bool int __a, + vector int __b) { + return (vector int)__a | __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_or(vector int __a, + vector bool int __b) { + return __a | (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_or(vector unsigned int __a, vector unsigned int __b) { + return __a | __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_or(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a | __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_or(vector unsigned int __a, vector bool int __b) { + return __a | (vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_or(vector bool int __a, + vector bool int __b) { + return __a | __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a | (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_or(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a | (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a | (vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_or(vector bool long long __a, + vector double __b) { + return (vector double)((vector unsigned long long)__a | + (vector unsigned long long)__b); +} + +static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a, + vector bool long long __b) { + return (vector double)((vector unsigned long long)__a | + (vector unsigned long long)__b); +} + +static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a, + vector double __b) { + return (vector double)((vector unsigned long long)__a | + (vector unsigned long long)__b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_or(vector signed long long __a, vector signed long long __b) { + return __a | __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_or(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a | __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_or(vector signed long long __a, vector bool long long __b) { + return __a | (vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_or(vector unsigned long long __a, vector unsigned long long __b) { + return __a | __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_or(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a | __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_or(vector unsigned long long __a, vector bool long long __b) { + return __a | (vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_or(vector bool long long __a, vector bool long long __b) { + return __a | __b; +} +#endif + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed char __ATTRS_o_ai +vec_orc(vector signed char __a, vector signed char __b) { + return __a | ~__b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_orc(vector signed char __a, vector bool char __b) { + return __a | (vector signed char)~__b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_orc(vector bool char __a, vector signed char __b) { + return (vector signed char)(__a | (vector bool char)~__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_orc(vector unsigned char __a, vector unsigned char __b) { + return __a | ~__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_orc(vector unsigned char __a, vector bool char __b) { + return __a | (vector unsigned char)~__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_orc(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)(__a | (vector bool char)~__b); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_orc(vector bool char __a, + vector bool char __b) { + return __a | ~__b; +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_orc(vector signed short __a, vector signed short __b) { + return __a | ~__b; +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_orc(vector signed short __a, vector bool short __b) { + return __a | (vector signed short)~__b; +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_orc(vector bool short __a, vector signed short __b) { + return (vector signed short)(__a | (vector bool short)~__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_orc(vector unsigned short __a, vector unsigned short __b) { + return __a | ~__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_orc(vector unsigned short __a, vector bool short __b) { + return __a | (vector unsigned short)~__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_orc(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)(__a | (vector bool short)~__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_orc(vector bool short __a, vector bool short __b) { + return __a | ~__b; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_orc(vector signed int __a, vector signed int __b) { + return __a | ~__b; +} + +static __inline__ vector signed int __ATTRS_o_ai vec_orc(vector signed int __a, + vector bool int __b) { + return __a | (vector signed int)~__b; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_orc(vector bool int __a, vector signed int __b) { + return (vector signed int)(__a | (vector bool int)~__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_orc(vector unsigned int __a, vector unsigned int __b) { + return __a | ~__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_orc(vector unsigned int __a, vector bool int __b) { + return __a | (vector unsigned int)~__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_orc(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)(__a | (vector bool int)~__b); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_orc(vector bool int __a, + vector bool int __b) { + return __a | ~__b; +} + +static __inline__ vector float __ATTRS_o_ai +vec_orc(vector bool int __a, vector float __b) { + return (vector float)(__a | ~(vector bool int)__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_orc(vector float __a, vector bool int __b) { + return (vector float)((vector bool int)__a | ~__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_orc(vector float __a, + vector float __b) { + return (vector float)((vector unsigned int)__a | ~(vector unsigned int)__b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_orc(vector signed long long __a, vector signed long long __b) { + return __a | ~__b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_orc(vector signed long long __a, vector bool long long __b) { + return __a | (vector signed long long)~__b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_orc(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)(__a | (vector bool long long)~__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_orc(vector unsigned long long __a, vector unsigned long long __b) { + return __a | ~__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_orc(vector unsigned long long __a, vector bool long long __b) { + return __a | (vector unsigned long long)~__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_orc(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)(__a | (vector bool long long)~__b); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_orc(vector bool long long __a, vector bool long long __b) { + return __a | ~__b; +} + +static __inline__ vector double __ATTRS_o_ai +vec_orc(vector double __a, vector bool long long __b) { + return (vector double)((vector bool long long)__a | ~__b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_orc(vector bool long long __a, vector double __b) { + return (vector double)(__a | ~(vector bool long long)__b); +} + +static __inline__ vector double __ATTRS_o_ai vec_orc(vector double __a, + vector double __b) { + return (vector double)((vector unsigned long long)__a | + ~(vector unsigned long long)__b); +} +#endif + +/* vec_vor */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vor(vector signed char __a, vector signed char __b) { + return __a | __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vor(vector bool char __a, vector signed char __b) { + return (vector signed char)__a | __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vor(vector signed char __a, vector bool char __b) { + return __a | (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vor(vector unsigned char __a, vector unsigned char __b) { + return __a | __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vor(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a | __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vor(vector unsigned char __a, vector bool char __b) { + return __a | (vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vor(vector bool char __a, + vector bool char __b) { + return __a | __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a, + vector short __b) { + return __a | __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vor(vector bool short __a, + vector short __b) { + return (vector short)__a | __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vor(vector short __a, + vector bool short __b) { + return __a | (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vor(vector unsigned short __a, vector unsigned short __b) { + return __a | __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vor(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a | __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vor(vector unsigned short __a, vector bool short __b) { + return __a | (vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vor(vector bool short __a, vector bool short __b) { + return __a | __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a, + vector int __b) { + return __a | __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vor(vector bool int __a, + vector int __b) { + return (vector int)__a | __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vor(vector int __a, + vector bool int __b) { + return __a | (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vor(vector unsigned int __a, vector unsigned int __b) { + return __a | __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vor(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a | __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vor(vector unsigned int __a, vector bool int __b) { + return __a | (vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vor(vector bool int __a, + vector bool int __b) { + return __a | __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a | (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vor(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a | (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vor(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a | (vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_vor(vector signed long long __a, vector signed long long __b) { + return __a | __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vor(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a | __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vor(vector signed long long __a, vector bool long long __b) { + return __a | (vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vor(vector unsigned long long __a, vector unsigned long long __b) { + return __a | __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vor(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a | __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vor(vector unsigned long long __a, vector bool long long __b) { + return __a | (vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_vor(vector bool long long __a, vector bool long long __b) { + return __a | __b; +} +#endif + +/* vec_pack */ + +/* The various vector pack instructions have a big-endian bias, so for + little endian we must handle reversed element numbering. */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_pack(vector signed short __a, vector signed short __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed char)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E)); +#else + return (vector signed char)vec_perm( + __a, __b, + (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, + 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F)); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_pack(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned char)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E)); +#else + return (vector unsigned char)vec_perm( + __a, __b, + (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, + 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F)); +#endif +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_pack(vector bool short __a, vector bool short __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool char)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E)); +#else + return (vector bool char)vec_perm( + __a, __b, + (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, + 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F)); +#endif +} + +static __inline__ vector short __ATTRS_o_ai vec_pack(vector int __a, + vector int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector short)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, + 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D)); +#else + return (vector short)vec_perm( + __a, __b, + (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, + 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_pack(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned short)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, + 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D)); +#else + return (vector unsigned short)vec_perm( + __a, __b, + (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, + 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai vec_pack(vector bool int __a, + vector bool int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool short)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, + 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D)); +#else + return (vector bool short)vec_perm( + __a, __b, + (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, + 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F)); +#endif +} + +#ifdef __VSX__ +static __inline__ vector signed int __ATTRS_o_ai +vec_pack(vector signed long long __a, vector signed long long __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed int)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, + 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B)); +#else + return (vector signed int)vec_perm( + __a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, + 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F)); +#endif +} +static __inline__ vector unsigned int __ATTRS_o_ai +vec_pack(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned int)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, + 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B)); +#else + return (vector unsigned int)vec_perm( + __a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, + 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_pack(vector bool long long __a, vector bool long long __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool int)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, + 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B)); +#else + return (vector bool int)vec_perm( + __a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, + 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector float __ATTRS_o_ai +vec_pack(vector double __a, vector double __b) { + return (vector float) (__a[0], __a[1], __b[0], __b[1]); +} +#endif + +#ifdef __POWER9_VECTOR__ +static __inline__ vector unsigned short __ATTRS_o_ai +vec_pack_to_short_fp32(vector float __a, vector float __b) { + vector float __resa = __builtin_vsx_xvcvsphp(__a); + vector float __resb = __builtin_vsx_xvcvsphp(__b); +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned short)vec_mergee(__resa, __resb); +#else + return (vector unsigned short)vec_mergeo(__resa, __resb); +#endif +} + +#endif +/* vec_vpkuhum */ + +#define __builtin_altivec_vpkuhum vec_vpkuhum + +static __inline__ vector signed char __ATTRS_o_ai +vec_vpkuhum(vector signed short __a, vector signed short __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed char)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E)); +#else + return (vector signed char)vec_perm( + __a, __b, + (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, + 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F)); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vpkuhum(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned char)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E)); +#else + return (vector unsigned char)vec_perm( + __a, __b, + (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, + 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F)); +#endif +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vpkuhum(vector bool short __a, vector bool short __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool char)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x1E)); +#else + return (vector bool char)vec_perm( + __a, __b, + (vector unsigned char)(0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, + 0x11, 0x13, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F)); +#endif +} + +/* vec_vpkuwum */ + +#define __builtin_altivec_vpkuwum vec_vpkuwum + +static __inline__ vector short __ATTRS_o_ai vec_vpkuwum(vector int __a, + vector int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector short)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, + 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D)); +#else + return (vector short)vec_perm( + __a, __b, + (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, + 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vpkuwum(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned short)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, + 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D)); +#else + return (vector unsigned short)vec_perm( + __a, __b, + (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, + 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vpkuwum(vector bool int __a, vector bool int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool short)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x04, 0x05, 0x08, 0x09, 0x0C, 0x0D, + 0x10, 0x11, 0x14, 0x15, 0x18, 0x19, 0x1C, 0x1D)); +#else + return (vector bool short)vec_perm( + __a, __b, + (vector unsigned char)(0x02, 0x03, 0x06, 0x07, 0x0A, 0x0B, 0x0E, 0x0F, + 0x12, 0x13, 0x16, 0x17, 0x1A, 0x1B, 0x1E, 0x1F)); +#endif +} + +/* vec_vpkudum */ + +#ifdef __POWER8_VECTOR__ +#define __builtin_altivec_vpkudum vec_vpkudum + +static __inline__ vector int __ATTRS_o_ai vec_vpkudum(vector long long __a, + vector long long __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector int)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, + 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B)); +#else + return (vector int)vec_perm( + __a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, + 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vpkudum(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned int)vec_perm( + __a, __b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, + 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B)); +#else + return (vector unsigned int)vec_perm( + __a, __b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, + 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F)); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vpkudum(vector bool long long __a, vector bool long long __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool int)vec_perm( + (vector long long)__a, (vector long long)__b, + (vector unsigned char)(0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, + 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B)); +#else + return (vector bool int)vec_perm( + (vector long long)__a, (vector long long)__b, + (vector unsigned char)(0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, 0x0E, 0x0F, + 0x14, 0x15, 0x16, 0x17, 0x1C, 0x1D, 0x1E, 0x1F)); +#endif +} +#endif + +/* vec_packpx */ + +static __inline__ vector pixel __attribute__((__always_inline__)) +vec_packpx(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector pixel)__builtin_altivec_vpkpx(__b, __a); +#else + return (vector pixel)__builtin_altivec_vpkpx(__a, __b); +#endif +} + +/* vec_vpkpx */ + +static __inline__ vector pixel __attribute__((__always_inline__)) +vec_vpkpx(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return (vector pixel)__builtin_altivec_vpkpx(__b, __a); +#else + return (vector pixel)__builtin_altivec_vpkpx(__a, __b); +#endif +} + +/* vec_packs */ + +static __inline__ vector signed char __ATTRS_o_ai vec_packs(vector short __a, + vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkshss(__b, __a); +#else + return __builtin_altivec_vpkshss(__a, __b); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_packs(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuhus(__b, __a); +#else + return __builtin_altivec_vpkuhus(__a, __b); +#endif +} + +static __inline__ vector signed short __ATTRS_o_ai vec_packs(vector int __a, + vector int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkswss(__b, __a); +#else + return __builtin_altivec_vpkswss(__a, __b); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_packs(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuwus(__b, __a); +#else + return __builtin_altivec_vpkuwus(__a, __b); +#endif +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector int __ATTRS_o_ai vec_packs(vector long long __a, + vector long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpksdss(__b, __a); +#else + return __builtin_altivec_vpksdss(__a, __b); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_packs(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkudus(__b, __a); +#else + return __builtin_altivec_vpkudus(__a, __b); +#endif +} +#endif + +/* vec_vpkshss */ + +static __inline__ vector signed char __attribute__((__always_inline__)) +vec_vpkshss(vector short __a, vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkshss(__b, __a); +#else + return __builtin_altivec_vpkshss(__a, __b); +#endif +} + +/* vec_vpksdss */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector int __ATTRS_o_ai vec_vpksdss(vector long long __a, + vector long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpksdss(__b, __a); +#else + return __builtin_altivec_vpksdss(__a, __b); +#endif +} +#endif + +/* vec_vpkuhus */ + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_vpkuhus(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuhus(__b, __a); +#else + return __builtin_altivec_vpkuhus(__a, __b); +#endif +} + +/* vec_vpkudus */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vpkudus(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkudus(__b, __a); +#else + return __builtin_altivec_vpkudus(__a, __b); +#endif +} +#endif + +/* vec_vpkswss */ + +static __inline__ vector signed short __attribute__((__always_inline__)) +vec_vpkswss(vector int __a, vector int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkswss(__b, __a); +#else + return __builtin_altivec_vpkswss(__a, __b); +#endif +} + +/* vec_vpkuwus */ + +static __inline__ vector unsigned short __attribute__((__always_inline__)) +vec_vpkuwus(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuwus(__b, __a); +#else + return __builtin_altivec_vpkuwus(__a, __b); +#endif +} + +/* vec_packsu */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_packsu(vector short __a, vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkshus(__b, __a); +#else + return __builtin_altivec_vpkshus(__a, __b); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_packsu(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuhus(__b, __a); +#else + return __builtin_altivec_vpkuhus(__a, __b); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_packsu(vector int __a, vector int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkswus(__b, __a); +#else + return __builtin_altivec_vpkswus(__a, __b); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_packsu(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuwus(__b, __a); +#else + return __builtin_altivec_vpkuwus(__a, __b); +#endif +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector unsigned int __ATTRS_o_ai +vec_packsu(vector long long __a, vector long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpksdus(__b, __a); +#else + return __builtin_altivec_vpksdus(__a, __b); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_packsu(vector unsigned long long __a, vector unsigned long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkudus(__b, __a); +#else + return __builtin_altivec_vpkudus(__a, __b); +#endif +} +#endif + +/* vec_vpkshus */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vpkshus(vector short __a, vector short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkshus(__b, __a); +#else + return __builtin_altivec_vpkshus(__a, __b); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vpkshus(vector unsigned short __a, vector unsigned short __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuhus(__b, __a); +#else + return __builtin_altivec_vpkuhus(__a, __b); +#endif +} + +/* vec_vpkswus */ + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vpkswus(vector int __a, vector int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkswus(__b, __a); +#else + return __builtin_altivec_vpkswus(__a, __b); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vpkswus(vector unsigned int __a, vector unsigned int __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpkuwus(__b, __a); +#else + return __builtin_altivec_vpkuwus(__a, __b); +#endif +} + +/* vec_vpksdus */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vpksdus(vector long long __a, vector long long __b) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vpksdus(__b, __a); +#else + return __builtin_altivec_vpksdus(__a, __b); +#endif +} +#endif + +/* vec_perm */ + +// The vperm instruction is defined architecturally with a big-endian bias. +// For little endian, we swap the input operands and invert the permute +// control vector. Only the rightmost 5 bits matter, so we could use +// a vector of all 31s instead of all 255s to perform the inversion. +// However, when the PCV is not a constant, using 255 has an advantage +// in that the vec_xor can be recognized as a vec_nor (and for P8 and +// later, possibly a vec_nand). + +static __inline__ vector signed char __ATTRS_o_ai vec_perm( + vector signed char __a, vector signed char __b, vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector signed char)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector signed char)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_perm(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector unsigned char)__builtin_altivec_vperm_4si( + (vector int)__b, (vector int)__a, __d); +#else + return (vector unsigned char)__builtin_altivec_vperm_4si( + (vector int)__a, (vector int)__b, __c); +#endif +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_perm(vector bool char __a, vector bool char __b, vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector bool char)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector bool char)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector short __ATTRS_o_ai vec_perm(vector signed short __a, + vector signed short __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector signed short)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector signed short)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_perm(vector unsigned short __a, vector unsigned short __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector unsigned short)__builtin_altivec_vperm_4si( + (vector int)__b, (vector int)__a, __d); +#else + return (vector unsigned short)__builtin_altivec_vperm_4si( + (vector int)__a, (vector int)__b, __c); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai vec_perm( + vector bool short __a, vector bool short __b, vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector bool short)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector bool short)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector pixel __ATTRS_o_ai vec_perm(vector pixel __a, + vector pixel __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector pixel)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector pixel)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector int __ATTRS_o_ai vec_perm(vector signed int __a, + vector signed int __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector signed int)__builtin_altivec_vperm_4si(__b, __a, __d); +#else + return (vector signed int)__builtin_altivec_vperm_4si(__a, __b, __c); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_perm(vector unsigned int __a, vector unsigned int __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector unsigned int)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_perm(vector bool int __a, vector bool int __b, vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector bool int)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector bool int)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +static __inline__ vector float __ATTRS_o_ai vec_perm(vector float __a, + vector float __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector float)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector float)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} + +#ifdef __VSX__ +static __inline__ vector long long __ATTRS_o_ai +vec_perm(vector signed long long __a, vector signed long long __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector signed long long)__builtin_altivec_vperm_4si( + (vector int)__b, (vector int)__a, __d); +#else + return (vector signed long long)__builtin_altivec_vperm_4si( + (vector int)__a, (vector int)__b, __c); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_perm(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector unsigned long long)__builtin_altivec_vperm_4si( + (vector int)__b, (vector int)__a, __d); +#else + return (vector unsigned long long)__builtin_altivec_vperm_4si( + (vector int)__a, (vector int)__b, __c); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_perm(vector bool long long __a, vector bool long long __b, + vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector bool long long)__builtin_altivec_vperm_4si( + (vector int)__b, (vector int)__a, __d); +#else + return (vector bool long long)__builtin_altivec_vperm_4si( + (vector int)__a, (vector int)__b, __c); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_perm(vector double __a, vector double __b, vector unsigned char __c) { +#ifdef __LITTLE_ENDIAN__ + vector unsigned char __d = {255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + __d = vec_xor(__c, __d); + return (vector double)__builtin_altivec_vperm_4si((vector int)__b, + (vector int)__a, __d); +#else + return (vector double)__builtin_altivec_vperm_4si((vector int)__a, + (vector int)__b, __c); +#endif +} +#endif + +/* vec_vperm */ + +static __inline__ vector signed char __ATTRS_o_ai vec_vperm( + vector signed char __a, vector signed char __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vperm(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vperm( + vector bool char __a, vector bool char __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector short __ATTRS_o_ai +vec_vperm(vector short __a, vector short __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vperm(vector unsigned short __a, vector unsigned short __b, + vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector bool short __ATTRS_o_ai vec_vperm( + vector bool short __a, vector bool short __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector pixel __ATTRS_o_ai +vec_vperm(vector pixel __a, vector pixel __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector int __ATTRS_o_ai vec_vperm(vector int __a, + vector int __b, + vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vperm(vector unsigned int __a, vector unsigned int __b, + vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vperm(vector bool int __a, vector bool int __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector float __ATTRS_o_ai +vec_vperm(vector float __a, vector float __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +#ifdef __VSX__ +static __inline__ vector long long __ATTRS_o_ai vec_vperm( + vector long long __a, vector long long __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vperm(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} + +static __inline__ vector double __ATTRS_o_ai +vec_vperm(vector double __a, vector double __b, vector unsigned char __c) { + return vec_perm(__a, __b, __c); +} +#endif + +/* vec_re */ + +static __inline__ vector float __ATTRS_o_ai vec_re(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvresp(__a); +#else + return __builtin_altivec_vrefp(__a); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_re(vector double __a) { + return __builtin_vsx_xvredp(__a); +} +#endif + +/* vec_vrefp */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vrefp(vector float __a) { + return __builtin_altivec_vrefp(__a); +} + +/* vec_rl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_rl(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_rl(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_rl(vector short __a, + vector unsigned short __b) { + return __builtin_altivec_vrlh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_rl(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_rl(vector int __a, + vector unsigned int __b) { + return __builtin_altivec_vrlw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_rl(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_rl(vector signed long long __a, vector unsigned long long __b) { + return __builtin_altivec_vrld(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_rl(vector unsigned long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__builtin_altivec_vrld( + (vector long long)__a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_rl(vector signed __int128 __a, vector unsigned __int128 __b) { + return (vector signed __int128)(((vector unsigned __int128)__b + << (vector unsigned __int128)__a) | + ((vector unsigned __int128)__b >> + ((__CHAR_BIT__ * + sizeof(vector unsigned __int128)) - + (vector unsigned __int128)__a))); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_rl(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return (__b << __a)|(__b >> ((__CHAR_BIT__ * sizeof(vector unsigned __int128)) - __a)); +} +#endif + +/* vec_rlmi */ +#ifdef __POWER9_VECTOR__ +static __inline__ vector unsigned int __ATTRS_o_ai +vec_rlmi(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + return __builtin_altivec_vrlwmi(__a, __c, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_rlmi(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned long long __c) { + return __builtin_altivec_vrldmi(__a, __c, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_rlmi(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vrlqmi(__a, __c, __b); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_rlmi(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vrlqmi( + (vector unsigned __int128)__a, (vector unsigned __int128)__c, + (vector unsigned __int128)__b); +} +#endif + +/* vec_rlnm */ +#ifdef __POWER9_VECTOR__ +static __inline__ vector unsigned int __ATTRS_o_ai +vec_rlnm(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + vector unsigned int OneByte = { 0x8, 0x8, 0x8, 0x8 }; + return __builtin_altivec_vrlwnm(__a, ((__c << OneByte) | __b)); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_rlnm(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned long long __c) { + vector unsigned long long OneByte = { 0x8, 0x8 }; + return __builtin_altivec_vrldnm(__a, ((__c << OneByte) | __b)); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_rlnm(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + // Merge __b and __c using an appropriate shuffle. + vector unsigned char TmpB = (vector unsigned char)__b; + vector unsigned char TmpC = (vector unsigned char)__c; + vector unsigned char MaskAndShift = +#ifdef __LITTLE_ENDIAN__ + __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, + 1, -1, -1, -1, -1, -1); +#else + __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 31, 30, 15, -1, + -1, -1, -1, -1, -1, -1, -1); +#endif + return __builtin_altivec_vrlqnm(__a, (vector unsigned __int128) MaskAndShift); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_rlnm(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + // Merge __b and __c using an appropriate shuffle. + vector unsigned char TmpB = (vector unsigned char)__b; + vector unsigned char TmpC = (vector unsigned char)__c; + vector unsigned char MaskAndShift = +#ifdef __LITTLE_ENDIAN__ + __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, + 1, -1, -1, -1, -1, -1); +#else + __builtin_shufflevector(TmpB, TmpC, -1, -1, -1, -1, -1, 31, 30, 15, -1, + -1, -1, -1, -1, -1, -1, -1); +#endif + return (vector signed __int128)__builtin_altivec_vrlqnm( + (vector unsigned __int128)__a, (vector unsigned __int128)MaskAndShift); +} +#endif + +/* vec_vrlb */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vrlb(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vrlb((vector char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vrlb(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vrlb((vector char)__a, __b); +} + +/* vec_vrlh */ + +static __inline__ vector short __ATTRS_o_ai +vec_vrlh(vector short __a, vector unsigned short __b) { + return __builtin_altivec_vrlh(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vrlh(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vrlh((vector short)__a, __b); +} + +/* vec_vrlw */ + +static __inline__ vector int __ATTRS_o_ai vec_vrlw(vector int __a, + vector unsigned int __b) { + return __builtin_altivec_vrlw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vrlw(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vrlw((vector int)__a, __b); +} + +/* vec_round */ + +static __inline__ vector float __ATTRS_o_ai vec_round(vector float __a) { + return __builtin_altivec_vrfin(__a); +} + +#ifdef __VSX__ +#ifdef __XL_COMPAT_ALTIVEC__ +static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a); +static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) { + double __fpscr = __builtin_readflm(); + __builtin_setrnd(0); + vector double __rounded = vec_rint(__a); + __builtin_setflm(__fpscr); + return __rounded; +} +#else +static __inline__ vector double __ATTRS_o_ai vec_round(vector double __a) { + return __builtin_vsx_xvrdpi(__a); +} +#endif + +/* vec_rint */ + +static __inline__ vector float __ATTRS_o_ai vec_rint(vector float __a) { + return __builtin_vsx_xvrspic(__a); +} + +static __inline__ vector double __ATTRS_o_ai vec_rint(vector double __a) { + return __builtin_vsx_xvrdpic(__a); +} + +/* vec_roundc */ + +static __inline__ vector float __ATTRS_o_ai vec_roundc(vector float __a) { + return __builtin_vsx_xvrspic(__a); +} + +static __inline__ vector double __ATTRS_o_ai vec_roundc(vector double __a) { + return __builtin_vsx_xvrdpic(__a); +} + +/* vec_nearbyint */ + +static __inline__ vector float __ATTRS_o_ai vec_nearbyint(vector float __a) { + return __builtin_vsx_xvrspi(__a); +} + +static __inline__ vector double __ATTRS_o_ai vec_nearbyint(vector double __a) { + return __builtin_vsx_xvrdpi(__a); +} +#endif + +/* vec_vrfin */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vrfin(vector float __a) { + return __builtin_altivec_vrfin(__a); +} + +/* vec_sqrt */ + +#ifdef __VSX__ +static __inline__ vector float __ATTRS_o_ai vec_sqrt(vector float __a) { + return __builtin_vsx_xvsqrtsp(__a); +} + +static __inline__ vector double __ATTRS_o_ai vec_sqrt(vector double __a) { + return __builtin_vsx_xvsqrtdp(__a); +} +#endif + +/* vec_rsqrte */ + +static __inline__ vector float __ATTRS_o_ai vec_rsqrte(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvrsqrtesp(__a); +#else + return __builtin_altivec_vrsqrtefp(__a); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_rsqrte(vector double __a) { + return __builtin_vsx_xvrsqrtedp(__a); +} +#endif + +static vector float __ATTRS_o_ai vec_rsqrt(vector float __a) { + return __builtin_ppc_rsqrtf(__a); +} + +#ifdef __VSX__ +static vector double __ATTRS_o_ai vec_rsqrt(vector double __a) { + return __builtin_ppc_rsqrtd(__a); +} +#endif + +/* vec_vrsqrtefp */ + +static __inline__ __vector float __attribute__((__always_inline__)) +vec_vrsqrtefp(vector float __a) { + return __builtin_altivec_vrsqrtefp(__a); +} + +/* vec_xvtsqrt */ + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_test_swsqrt(vector double __a) { + return __builtin_vsx_xvtsqrtdp(__a); +} + +static __inline__ int __ATTRS_o_ai vec_test_swsqrts(vector float __a) { + return __builtin_vsx_xvtsqrtsp(__a); +} +#endif + +/* vec_sel */ + +#define __builtin_altivec_vsel_4si vec_sel + +static __inline__ vector signed char __ATTRS_o_ai vec_sel( + vector signed char __a, vector signed char __b, vector unsigned char __c) { + return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sel(vector signed char __a, vector signed char __b, vector bool char __c) { + return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sel(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai vec_sel( + vector unsigned char __a, vector unsigned char __b, vector bool char __c) { + return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_sel(vector bool char __a, vector bool char __b, vector unsigned char __c) { + return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_sel(vector bool char __a, + vector bool char __b, + vector bool char __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a, + vector short __b, + vector unsigned short __c) { + return (__a & ~(vector short)__c) | (__b & (vector short)__c); +} + +static __inline__ vector short __ATTRS_o_ai vec_sel(vector short __a, + vector short __b, + vector bool short __c) { + return (__a & ~(vector short)__c) | (__b & (vector short)__c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sel(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sel(vector unsigned short __a, vector unsigned short __b, + vector bool short __c) { + return (__a & ~(vector unsigned short)__c) | + (__b & (vector unsigned short)__c); +} + +static __inline__ vector bool short __ATTRS_o_ai vec_sel( + vector bool short __a, vector bool short __b, vector unsigned short __c) { + return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_sel(vector bool short __a, vector bool short __b, vector bool short __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a, + vector int __b, + vector unsigned int __c) { + return (__a & ~(vector int)__c) | (__b & (vector int)__c); +} + +static __inline__ vector int __ATTRS_o_ai vec_sel(vector int __a, + vector int __b, + vector bool int __c) { + return (__a & ~(vector int)__c) | (__b & (vector int)__c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_sel( + vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sel(vector unsigned int __a, vector unsigned int __b, vector bool int __c) { + return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_sel(vector bool int __a, vector bool int __b, vector unsigned int __c) { + return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_sel(vector bool int __a, + vector bool int __b, + vector bool int __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a, + vector float __b, + vector unsigned int __c) { + vector int __res = ((vector int)__a & ~(vector int)__c) | + ((vector int)__b & (vector int)__c); + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_sel(vector float __a, + vector float __b, + vector bool int __c) { + vector int __res = ((vector int)__a & ~(vector int)__c) | + ((vector int)__b & (vector int)__c); + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai +vec_sel(vector double __a, vector double __b, vector bool long long __c) { + vector long long __res = ((vector long long)__a & ~(vector long long)__c) | + ((vector long long)__b & (vector long long)__c); + return (vector double)__res; +} + +static __inline__ vector double __ATTRS_o_ai +vec_sel(vector double __a, vector double __b, vector unsigned long long __c) { + vector long long __res = ((vector long long)__a & ~(vector long long)__c) | + ((vector long long)__b & (vector long long)__c); + return (vector double)__res; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_sel(vector bool long long __a, vector bool long long __b, + vector bool long long __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_sel(vector bool long long __a, vector bool long long __b, + vector unsigned long long __c) { + return (__a & ~(vector bool long long)__c) | + (__b & (vector bool long long)__c); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_sel(vector signed long long __a, vector signed long long __b, + vector bool long long __c) { + return (__a & ~(vector signed long long)__c) | + (__b & (vector signed long long)__c); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_sel(vector signed long long __a, vector signed long long __b, + vector unsigned long long __c) { + return (__a & ~(vector signed long long)__c) | + (__b & (vector signed long long)__c); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sel(vector unsigned long long __a, vector unsigned long long __b, + vector bool long long __c) { + return (__a & ~(vector unsigned long long)__c) | + (__b & (vector unsigned long long)__c); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sel(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned long long __c) { + return (__a & ~__c) | (__b & __c); +} +#endif + +/* vec_vsel */ + +static __inline__ vector signed char __ATTRS_o_ai vec_vsel( + vector signed char __a, vector signed char __b, vector unsigned char __c) { + return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsel(vector signed char __a, vector signed char __b, vector bool char __c) { + return (__a & ~(vector signed char)__c) | (__b & (vector signed char)__c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsel(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai vec_vsel( + vector unsigned char __a, vector unsigned char __b, vector bool char __c) { + return (__a & ~(vector unsigned char)__c) | (__b & (vector unsigned char)__c); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsel(vector bool char __a, vector bool char __b, vector unsigned char __c) { + return (__a & ~(vector bool char)__c) | (__b & (vector bool char)__c); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vsel(vector bool char __a, + vector bool char __b, + vector bool char __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector short __ATTRS_o_ai +vec_vsel(vector short __a, vector short __b, vector unsigned short __c) { + return (__a & ~(vector short)__c) | (__b & (vector short)__c); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsel(vector short __a, + vector short __b, + vector bool short __c) { + return (__a & ~(vector short)__c) | (__b & (vector short)__c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsel(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsel(vector unsigned short __a, vector unsigned short __b, + vector bool short __c) { + return (__a & ~(vector unsigned short)__c) | + (__b & (vector unsigned short)__c); +} + +static __inline__ vector bool short __ATTRS_o_ai vec_vsel( + vector bool short __a, vector bool short __b, vector unsigned short __c) { + return (__a & ~(vector bool short)__c) | (__b & (vector bool short)__c); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsel(vector bool short __a, vector bool short __b, vector bool short __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a, + vector int __b, + vector unsigned int __c) { + return (__a & ~(vector int)__c) | (__b & (vector int)__c); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsel(vector int __a, + vector int __b, + vector bool int __c) { + return (__a & ~(vector int)__c) | (__b & (vector int)__c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel( + vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_vsel( + vector unsigned int __a, vector unsigned int __b, vector bool int __c) { + return (__a & ~(vector unsigned int)__c) | (__b & (vector unsigned int)__c); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsel(vector bool int __a, vector bool int __b, vector unsigned int __c) { + return (__a & ~(vector bool int)__c) | (__b & (vector bool int)__c); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vsel(vector bool int __a, + vector bool int __b, + vector bool int __c) { + return (__a & ~__c) | (__b & __c); +} + +static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a, + vector float __b, + vector unsigned int __c) { + vector int __res = ((vector int)__a & ~(vector int)__c) | + ((vector int)__b & (vector int)__c); + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vsel(vector float __a, + vector float __b, + vector bool int __c) { + vector int __res = ((vector int)__a & ~(vector int)__c) | + ((vector int)__b & (vector int)__c); + return (vector float)__res; +} + +/* vec_sl */ + +// vec_sl does modulo arithmetic on __b first, so __b is allowed to be more +// than the length of __a. +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sl(vector unsigned char __a, vector unsigned char __b) { + return __a << (__b % + (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__)); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sl(vector signed char __a, vector unsigned char __b) { + return (vector signed char)vec_sl((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sl(vector unsigned short __a, vector unsigned short __b) { + return __a << (__b % (vector unsigned short)(sizeof(unsigned short) * + __CHAR_BIT__)); +} + +static __inline__ vector short __ATTRS_o_ai vec_sl(vector short __a, + vector unsigned short __b) { + return (vector short)vec_sl((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sl(vector unsigned int __a, vector unsigned int __b) { + return __a << (__b % + (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__)); +} + +static __inline__ vector int __ATTRS_o_ai vec_sl(vector int __a, + vector unsigned int __b) { + return (vector int)vec_sl((vector unsigned int)__a, __b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sl(vector unsigned long long __a, vector unsigned long long __b) { + return __a << (__b % (vector unsigned long long)(sizeof(unsigned long long) * + __CHAR_BIT__)); +} + +static __inline__ vector long long __ATTRS_o_ai +vec_sl(vector long long __a, vector unsigned long long __b) { + return (vector long long)vec_sl((vector unsigned long long)__a, __b); +} +#elif defined(__VSX__) +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vspltb(vector unsigned char __a, unsigned char __b); +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sl(vector unsigned long long __a, vector unsigned long long __b) { + __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__); + + // Big endian element one (the right doubleword) can be left shifted as-is. + // The other element needs to be swapped into the right doubleword and + // shifted. Then the right doublewords of the two result vectors are merged. + vector signed long long __rightelt = + (vector signed long long)__builtin_altivec_vslo((vector signed int)__a, + (vector signed int)__b); +#ifdef __LITTLE_ENDIAN__ + __rightelt = (vector signed long long)__builtin_altivec_vsl( + (vector signed int)__rightelt, + (vector signed int)vec_vspltb((vector unsigned char)__b, 0)); +#else + __rightelt = (vector signed long long)__builtin_altivec_vsl( + (vector signed int)__rightelt, + (vector signed int)vec_vspltb((vector unsigned char)__b, 15)); +#endif + __a = __builtin_shufflevector(__a, __a, 1, 0); + __b = __builtin_shufflevector(__b, __b, 1, 0); + vector signed long long __leftelt = + (vector signed long long)__builtin_altivec_vslo((vector signed int)__a, + (vector signed int)__b); +#ifdef __LITTLE_ENDIAN__ + __leftelt = (vector signed long long)__builtin_altivec_vsl( + (vector signed int)__leftelt, + (vector signed int)vec_vspltb((vector unsigned char)__b, 0)); + return (vector unsigned long long)__builtin_shufflevector(__rightelt, + __leftelt, 0, 2); +#else + __leftelt = (vector signed long long)__builtin_altivec_vsl( + (vector signed int)__leftelt, + (vector signed int)vec_vspltb((vector unsigned char)__b, 15)); + return (vector unsigned long long)__builtin_shufflevector(__leftelt, + __rightelt, 1, 3); +#endif +} + +static __inline__ vector long long __ATTRS_o_ai +vec_sl(vector long long __a, vector unsigned long long __b) { + return (vector long long)vec_sl((vector unsigned long long)__a, __b); +} +#endif /* __VSX__ */ + +/* vec_vslb */ + +#define __builtin_altivec_vslb vec_vslb + +static __inline__ vector signed char __ATTRS_o_ai +vec_vslb(vector signed char __a, vector unsigned char __b) { + return vec_sl(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vslb(vector unsigned char __a, vector unsigned char __b) { + return vec_sl(__a, __b); +} + +/* vec_vslh */ + +#define __builtin_altivec_vslh vec_vslh + +static __inline__ vector short __ATTRS_o_ai +vec_vslh(vector short __a, vector unsigned short __b) { + return vec_sl(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vslh(vector unsigned short __a, vector unsigned short __b) { + return vec_sl(__a, __b); +} + +/* vec_vslw */ + +#define __builtin_altivec_vslw vec_vslw + +static __inline__ vector int __ATTRS_o_ai vec_vslw(vector int __a, + vector unsigned int __b) { + return vec_sl(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vslw(vector unsigned int __a, vector unsigned int __b) { + return vec_sl(__a, __b); +} + +/* vec_sld */ + +#define __builtin_altivec_vsldoi_4si vec_sld + +static __inline__ vector signed char __ATTRS_o_ai vec_sld( + vector signed char __a, vector signed char __b, unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sld(vector unsigned char __a, vector unsigned char __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_sld(vector bool char __a, vector bool char __b, unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector signed short __ATTRS_o_ai vec_sld( + vector signed short __a, vector signed short __b, unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sld(vector unsigned short __a, vector unsigned short __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_sld(vector bool short __a, vector bool short __b, unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector pixel __ATTRS_o_ai vec_sld(vector pixel __a, + vector pixel __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_sld(vector signed int __a, vector signed int __b, unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_sld( + vector unsigned int __a, vector unsigned int __b, unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai vec_sld(vector bool int __a, + vector bool int __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector float __ATTRS_o_ai vec_sld(vector float __a, + vector float __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_sld(vector bool long long __a, vector bool long long __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_sld(vector signed long long __a, vector signed long long __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sld(vector unsigned long long __a, vector unsigned long long __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector double __ATTRS_o_ai vec_sld(vector double __a, + vector double __b, + unsigned const int __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} +#endif + +/* vec_sldw */ +static __inline__ vector signed char __ATTRS_o_ai vec_sldw( + vector signed char __a, vector signed char __b, unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sldw(vector unsigned char __a, vector unsigned char __b, + unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector signed short __ATTRS_o_ai vec_sldw( + vector signed short __a, vector signed short __b, unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sldw(vector unsigned short __a, vector unsigned short __b, + unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_sldw(vector signed int __a, vector signed int __b, unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_sldw( + vector unsigned int __a, vector unsigned int __b, unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector float __ATTRS_o_ai vec_sldw( + vector float __a, vector float __b, unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_sldw(vector signed long long __a, vector signed long long __b, + unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sldw(vector unsigned long long __a, vector unsigned long long __b, + unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} + +static __inline__ vector double __ATTRS_o_ai vec_sldw( + vector double __a, vector double __b, unsigned const int __c) { + return vec_sld(__a, __b, ((__c << 2) & 0x0F)); +} +#endif + +#ifdef __POWER9_VECTOR__ +/* vec_slv */ +static __inline__ vector unsigned char __ATTRS_o_ai +vec_slv(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vslv(__a, __b); +} + +/* vec_srv */ +static __inline__ vector unsigned char __ATTRS_o_ai +vec_srv(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vsrv(__a, __b); +} +#endif + +/* vec_vsldoi */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsldoi(vector signed char __a, vector signed char __b, unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai vec_vsldoi( + vector unsigned char __a, vector unsigned char __b, unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector short __ATTRS_o_ai vec_vsldoi(vector short __a, + vector short __b, + unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai vec_vsldoi( + vector unsigned short __a, vector unsigned short __b, unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsldoi(vector pixel __a, + vector pixel __b, + unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector int __ATTRS_o_ai vec_vsldoi(vector int __a, + vector int __b, + unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_vsldoi( + vector unsigned int __a, vector unsigned int __b, unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +static __inline__ vector float __ATTRS_o_ai vec_vsldoi(vector float __a, + vector float __b, + unsigned char __c) { + unsigned char __d = __c & 0x0F; +#ifdef __LITTLE_ENDIAN__ + return vec_perm( + __b, __a, (vector unsigned char)(16 - __d, 17 - __d, 18 - __d, 19 - __d, + 20 - __d, 21 - __d, 22 - __d, 23 - __d, + 24 - __d, 25 - __d, 26 - __d, 27 - __d, + 28 - __d, 29 - __d, 30 - __d, 31 - __d)); +#else + return vec_perm( + __a, __b, + (vector unsigned char)(__d, __d + 1, __d + 2, __d + 3, __d + 4, __d + 5, + __d + 6, __d + 7, __d + 8, __d + 9, __d + 10, + __d + 11, __d + 12, __d + 13, __d + 14, __d + 15)); +#endif +} + +/* vec_sll */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_sll(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sll(vector signed char __a, vector unsigned short __b) { + return (vector signed char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sll(vector signed char __a, vector unsigned int __b) { + return (vector signed char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sll(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sll(vector unsigned char __a, vector unsigned short __b) { + return (vector unsigned char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sll(vector unsigned char __a, vector unsigned int __b) { + return (vector unsigned char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_sll(vector bool char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_sll(vector bool char __a, vector unsigned short __b) { + return (vector bool char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_sll(vector bool char __a, vector unsigned int __b) { + return (vector bool char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a, + vector unsigned short __b) { + return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_sll(vector short __a, + vector unsigned int __b) { + return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sll(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sll(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sll(vector unsigned short __a, vector unsigned int __b) { + return (vector unsigned short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_sll(vector bool short __a, vector unsigned char __b) { + return (vector bool short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_sll(vector bool short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_sll(vector bool short __a, vector unsigned int __b) { + return (vector bool short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a, + vector unsigned short __b) { + return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_sll(vector pixel __a, + vector unsigned int __b) { + return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vsl(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a, + vector unsigned short __b) { + return (vector int)__builtin_altivec_vsl(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sll(vector int __a, + vector unsigned int __b) { + return (vector int)__builtin_altivec_vsl(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sll(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sll(vector unsigned int __a, vector unsigned short __b) { + return (vector unsigned int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sll(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_sll(vector bool int __a, vector unsigned char __b) { + return (vector bool int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_sll(vector bool int __a, vector unsigned short __b) { + return (vector bool int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_sll(vector bool int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_sll(vector signed long long __a, vector unsigned char __b) { + return (vector signed long long)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sll(vector unsigned long long __a, vector unsigned char __b) { + return (vector unsigned long long)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} +#endif + +/* vec_vsl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsl(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsl(vector signed char __a, vector unsigned short __b) { + return (vector signed char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsl(vector signed char __a, vector unsigned int __b) { + return (vector signed char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsl(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsl(vector unsigned char __a, vector unsigned short __b) { + return (vector unsigned char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsl(vector unsigned char __a, vector unsigned int __b) { + return (vector unsigned char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsl(vector bool char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsl(vector bool char __a, vector unsigned short __b) { + return (vector bool char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsl(vector bool char __a, vector unsigned int __b) { + return (vector bool char)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a, + vector unsigned short __b) { + return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsl(vector short __a, + vector unsigned int __b) { + return (vector short)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsl(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsl(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsl(vector unsigned short __a, vector unsigned int __b) { + return (vector unsigned short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsl(vector bool short __a, vector unsigned char __b) { + return (vector bool short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsl(vector bool short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsl(vector bool short __a, vector unsigned int __b) { + return (vector bool short)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a, + vector unsigned short __b) { + return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsl(vector pixel __a, + vector unsigned int __b) { + return (vector pixel)__builtin_altivec_vsl((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vsl(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a, + vector unsigned short __b) { + return (vector int)__builtin_altivec_vsl(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsl(vector int __a, + vector unsigned int __b) { + return (vector int)__builtin_altivec_vsl(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsl(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsl(vector unsigned int __a, vector unsigned short __b) { + return (vector unsigned int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsl(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsl(vector bool int __a, vector unsigned char __b) { + return (vector bool int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsl(vector bool int __a, vector unsigned short __b) { + return (vector bool int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsl(vector bool int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vsl((vector int)__a, + (vector int)__b); +} + +/* vec_slo */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_slo(vector signed char __a, vector signed char __b) { + return (vector signed char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_slo(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_slo(vector unsigned char __a, vector signed char __b) { + return (vector unsigned char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_slo(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a, + vector signed char __b) { + return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_slo(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_slo(vector unsigned short __a, vector signed char __b) { + return (vector unsigned short)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_slo(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a, + vector signed char __b) { + return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_slo(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a, + vector signed char __b) { + return (vector int)__builtin_altivec_vslo(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_slo(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vslo(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_slo(vector unsigned int __a, vector signed char __b) { + return (vector unsigned int)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_slo(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a, + vector signed char __b) { + return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_slo(vector float __a, + vector unsigned char __b) { + return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_slo(vector signed long long __a, vector signed char __b) { + return (vector signed long long)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_slo(vector signed long long __a, vector unsigned char __b) { + return (vector signed long long)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_slo(vector unsigned long long __a, vector signed char __b) { + return (vector unsigned long long)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_slo(vector unsigned long long __a, vector unsigned char __b) { + return (vector unsigned long long)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} +#endif + +/* vec_vslo */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vslo(vector signed char __a, vector signed char __b) { + return (vector signed char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vslo(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vslo(vector unsigned char __a, vector signed char __b) { + return (vector unsigned char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vslo(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a, + vector signed char __b) { + return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vslo(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vslo(vector unsigned short __a, vector signed char __b) { + return (vector unsigned short)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vslo(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a, + vector signed char __b) { + return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vslo(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a, + vector signed char __b) { + return (vector int)__builtin_altivec_vslo(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vslo(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vslo(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vslo(vector unsigned int __a, vector signed char __b) { + return (vector unsigned int)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vslo(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vslo((vector int)__a, + (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a, + vector signed char __b) { + return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_vslo(vector float __a, + vector unsigned char __b) { + return (vector float)__builtin_altivec_vslo((vector int)__a, (vector int)__b); +} + +/* vec_splat */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_splat(vector signed char __a, unsigned const int __b) { + return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_splat(vector unsigned char __a, unsigned const int __b) { + return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_splat(vector bool char __a, unsigned const int __b) { + return vec_perm(__a, __a, (vector unsigned char)(__b & 0x0F)); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_splat(vector signed short __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x07) * 2; + unsigned char b1 = b0 + 1; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, + b0, b1, b0, b1, b0, b1)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_splat(vector unsigned short __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x07) * 2; + unsigned char b1 = b0 + 1; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, + b0, b1, b0, b1, b0, b1)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_splat(vector bool short __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x07) * 2; + unsigned char b1 = b0 + 1; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, + b0, b1, b0, b1, b0, b1)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_splat(vector pixel __a, + unsigned const int __b) { + unsigned char b0 = (__b & 0x07) * 2; + unsigned char b1 = b0 + 1; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, + b0, b1, b0, b1, b0, b1)); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_splat(vector signed int __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x03) * 4; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, + b2, b3, b0, b1, b2, b3)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_splat(vector unsigned int __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x03) * 4; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, + b2, b3, b0, b1, b2, b3)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_splat(vector bool int __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x03) * 4; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, + b2, b3, b0, b1, b2, b3)); +} + +static __inline__ vector float __ATTRS_o_ai vec_splat(vector float __a, + unsigned const int __b) { + unsigned char b0 = (__b & 0x03) * 4; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, + b2, b3, b0, b1, b2, b3)); +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_splat(vector double __a, + unsigned const int __b) { + unsigned char b0 = (__b & 0x01) * 8; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5, + b6 = b0 + 6, b7 = b0 + 7; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1, + b2, b3, b4, b5, b6, b7)); +} +static __inline__ vector bool long long __ATTRS_o_ai +vec_splat(vector bool long long __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x01) * 8; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5, + b6 = b0 + 6, b7 = b0 + 7; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1, + b2, b3, b4, b5, b6, b7)); +} +static __inline__ vector signed long long __ATTRS_o_ai +vec_splat(vector signed long long __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x01) * 8; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5, + b6 = b0 + 6, b7 = b0 + 7; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1, + b2, b3, b4, b5, b6, b7)); +} +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_splat(vector unsigned long long __a, unsigned const int __b) { + unsigned char b0 = (__b & 0x01) * 8; + unsigned char b1 = b0 + 1, b2 = b0 + 2, b3 = b0 + 3, b4 = b0 + 4, b5 = b0 + 5, + b6 = b0 + 6, b7 = b0 + 7; + return vec_perm(__a, __a, + (vector unsigned char)(b0, b1, b2, b3, b4, b5, b6, b7, b0, b1, + b2, b3, b4, b5, b6, b7)); +} +#endif + +/* vec_vspltb */ + +#define __builtin_altivec_vspltb vec_vspltb + +static __inline__ vector signed char __ATTRS_o_ai +vec_vspltb(vector signed char __a, unsigned char __b) { + return vec_perm(__a, __a, (vector unsigned char)(__b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vspltb(vector unsigned char __a, unsigned char __b) { + return vec_perm(__a, __a, (vector unsigned char)(__b)); +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vspltb(vector bool char __a, + unsigned char __b) { + return vec_perm(__a, __a, (vector unsigned char)(__b)); +} + +/* vec_vsplth */ + +#define __builtin_altivec_vsplth vec_vsplth + +static __inline__ vector short __ATTRS_o_ai vec_vsplth(vector short __a, + unsigned char __b) { + __b *= 2; + unsigned char b1 = __b + 1; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1, + __b, b1, __b, b1, __b, b1, __b, b1)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsplth(vector unsigned short __a, unsigned char __b) { + __b *= 2; + unsigned char b1 = __b + 1; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1, + __b, b1, __b, b1, __b, b1, __b, b1)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsplth(vector bool short __a, unsigned char __b) { + __b *= 2; + unsigned char b1 = __b + 1; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1, + __b, b1, __b, b1, __b, b1, __b, b1)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsplth(vector pixel __a, + unsigned char __b) { + __b *= 2; + unsigned char b1 = __b + 1; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, __b, b1, __b, b1, __b, b1, + __b, b1, __b, b1, __b, b1, __b, b1)); +} + +/* vec_vspltw */ + +#define __builtin_altivec_vspltw vec_vspltw + +static __inline__ vector int __ATTRS_o_ai vec_vspltw(vector int __a, + unsigned char __b) { + __b *= 4; + unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b, + b1, b2, b3, __b, b1, b2, b3)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vspltw(vector unsigned int __a, unsigned char __b) { + __b *= 4; + unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b, + b1, b2, b3, __b, b1, b2, b3)); +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vspltw(vector bool int __a, + unsigned char __b) { + __b *= 4; + unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b, + b1, b2, b3, __b, b1, b2, b3)); +} + +static __inline__ vector float __ATTRS_o_ai vec_vspltw(vector float __a, + unsigned char __b) { + __b *= 4; + unsigned char b1 = __b + 1, b2 = __b + 2, b3 = __b + 3; + return vec_perm(__a, __a, + (vector unsigned char)(__b, b1, b2, b3, __b, b1, b2, b3, __b, + b1, b2, b3, __b, b1, b2, b3)); +} + +/* vec_splat_s8 */ + +#define __builtin_altivec_vspltisb vec_splat_s8 + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector signed char __ATTRS_o_ai +vec_splat_s8(signed char __a) { + return (vector signed char)(__a); +} + +/* vec_vspltisb */ + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector signed char __ATTRS_o_ai +vec_vspltisb(signed char __a) { + return (vector signed char)(__a); +} + +/* vec_splat_s16 */ + +#define __builtin_altivec_vspltish vec_splat_s16 + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector short __ATTRS_o_ai vec_splat_s16(signed char __a) { + return (vector short)(__a); +} + +/* vec_vspltish */ + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector short __ATTRS_o_ai vec_vspltish(signed char __a) { + return (vector short)(__a); +} + +/* vec_splat_s32 */ + +#define __builtin_altivec_vspltisw vec_splat_s32 + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector int __ATTRS_o_ai vec_splat_s32(signed char __a) { + return (vector int)(__a); +} + +/* vec_vspltisw */ + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector int __ATTRS_o_ai vec_vspltisw(signed char __a) { + return (vector int)(__a); +} + +/* vec_splat_u8 */ + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector unsigned char __ATTRS_o_ai +vec_splat_u8(unsigned char __a) { + return (vector unsigned char)(__a); +} + +/* vec_splat_u16 */ + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector unsigned short __ATTRS_o_ai +vec_splat_u16(signed char __a) { + return (vector unsigned short)(__a); +} + +/* vec_splat_u32 */ + +// FIXME: parameter should be treated as 5-bit signed literal +static __inline__ vector unsigned int __ATTRS_o_ai +vec_splat_u32(signed char __a) { + return (vector unsigned int)(__a); +} + +/* vec_sr */ + +// vec_sr does modulo arithmetic on __b first, so __b is allowed to be more +// than the length of __a. +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sr(vector unsigned char __a, vector unsigned char __b) { + return __a >> + (__b % (vector unsigned char)(sizeof(unsigned char) * __CHAR_BIT__)); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sr(vector signed char __a, vector unsigned char __b) { + return (vector signed char)vec_sr((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sr(vector unsigned short __a, vector unsigned short __b) { + return __a >> + (__b % (vector unsigned short)(sizeof(unsigned short) * __CHAR_BIT__)); +} + +static __inline__ vector short __ATTRS_o_ai vec_sr(vector short __a, + vector unsigned short __b) { + return (vector short)vec_sr((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sr(vector unsigned int __a, vector unsigned int __b) { + return __a >> + (__b % (vector unsigned int)(sizeof(unsigned int) * __CHAR_BIT__)); +} + +static __inline__ vector int __ATTRS_o_ai vec_sr(vector int __a, + vector unsigned int __b) { + return (vector int)vec_sr((vector unsigned int)__a, __b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sr(vector unsigned long long __a, vector unsigned long long __b) { + return __a >> (__b % (vector unsigned long long)(sizeof(unsigned long long) * + __CHAR_BIT__)); +} + +static __inline__ vector long long __ATTRS_o_ai +vec_sr(vector long long __a, vector unsigned long long __b) { + return (vector long long)vec_sr((vector unsigned long long)__a, __b); +} +#elif defined(__VSX__) +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sr(vector unsigned long long __a, vector unsigned long long __b) { + __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__); + + // Big endian element zero (the left doubleword) can be right shifted as-is. + // However the shift amount must be in the right doubleword. + // The other element needs to be swapped into the left doubleword and + // shifted. Then the left doublewords of the two result vectors are merged. + vector unsigned long long __swapshift = + __builtin_shufflevector(__b, __b, 1, 0); + vector unsigned long long __leftelt = + (vector unsigned long long)__builtin_altivec_vsro( + (vector signed int)__a, (vector signed int)__swapshift); +#ifdef __LITTLE_ENDIAN__ + __leftelt = (vector unsigned long long)__builtin_altivec_vsr( + (vector signed int)__leftelt, + (vector signed int)vec_vspltb((vector unsigned char)__swapshift, 0)); +#else + __leftelt = (vector unsigned long long)__builtin_altivec_vsr( + (vector signed int)__leftelt, + (vector signed int)vec_vspltb((vector unsigned char)__swapshift, 15)); +#endif + __a = __builtin_shufflevector(__a, __a, 1, 0); + vector unsigned long long __rightelt = + (vector unsigned long long)__builtin_altivec_vsro((vector signed int)__a, + (vector signed int)__b); +#ifdef __LITTLE_ENDIAN__ + __rightelt = (vector unsigned long long)__builtin_altivec_vsr( + (vector signed int)__rightelt, + (vector signed int)vec_vspltb((vector unsigned char)__b, 0)); + return __builtin_shufflevector(__rightelt, __leftelt, 1, 3); +#else + __rightelt = (vector unsigned long long)__builtin_altivec_vsr( + (vector signed int)__rightelt, + (vector signed int)vec_vspltb((vector unsigned char)__b, 15)); + return __builtin_shufflevector(__leftelt, __rightelt, 0, 2); +#endif +} + +static __inline__ vector long long __ATTRS_o_ai +vec_sr(vector long long __a, vector unsigned long long __b) { + return (vector long long)vec_sr((vector unsigned long long)__a, __b); +} +#endif /* __VSX__ */ + +/* vec_vsrb */ + +#define __builtin_altivec_vsrb vec_vsrb + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsrb(vector signed char __a, vector unsigned char __b) { + return vec_sr(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsrb(vector unsigned char __a, vector unsigned char __b) { + return vec_sr(__a, __b); +} + +/* vec_vsrh */ + +#define __builtin_altivec_vsrh vec_vsrh + +static __inline__ vector short __ATTRS_o_ai +vec_vsrh(vector short __a, vector unsigned short __b) { + return vec_sr(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsrh(vector unsigned short __a, vector unsigned short __b) { + return vec_sr(__a, __b); +} + +/* vec_vsrw */ + +#define __builtin_altivec_vsrw vec_vsrw + +static __inline__ vector int __ATTRS_o_ai vec_vsrw(vector int __a, + vector unsigned int __b) { + return vec_sr(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsrw(vector unsigned int __a, vector unsigned int __b) { + return vec_sr(__a, __b); +} + +/* vec_sra */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_sra(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sra(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_sra(vector short __a, + vector unsigned short __b) { + return __builtin_altivec_vsrah(__a, (vector unsigned short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sra(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sra(vector int __a, + vector unsigned int __b) { + return __builtin_altivec_vsraw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sra(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b); +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_sra(vector signed long long __a, vector unsigned long long __b) { + return __a >> __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sra(vector unsigned long long __a, vector unsigned long long __b) { + return (vector unsigned long long)((vector signed long long)__a >> __b); +} +#elif defined(__VSX__) +static __inline__ vector signed long long __ATTRS_o_ai +vec_sra(vector signed long long __a, vector unsigned long long __b) { + __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__); + return __a >> __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sra(vector unsigned long long __a, vector unsigned long long __b) { + __b %= (vector unsigned long long)(sizeof(unsigned long long) * __CHAR_BIT__); + return (vector unsigned long long)((vector signed long long)__a >> __b); +} +#endif /* __VSX__ */ + +/* vec_vsrab */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsrab(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsrab((vector char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsrab(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsrab((vector char)__a, __b); +} + +/* vec_vsrah */ + +static __inline__ vector short __ATTRS_o_ai +vec_vsrah(vector short __a, vector unsigned short __b) { + return __builtin_altivec_vsrah(__a, (vector unsigned short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsrah(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vsrah((vector short)__a, __b); +} + +/* vec_vsraw */ + +static __inline__ vector int __ATTRS_o_ai vec_vsraw(vector int __a, + vector unsigned int __b) { + return __builtin_altivec_vsraw(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsraw(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vsraw((vector int)__a, __b); +} + +/* vec_srl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_srl(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_srl(vector signed char __a, vector unsigned short __b) { + return (vector signed char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_srl(vector signed char __a, vector unsigned int __b) { + return (vector signed char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_srl(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_srl(vector unsigned char __a, vector unsigned short __b) { + return (vector unsigned char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_srl(vector unsigned char __a, vector unsigned int __b) { + return (vector unsigned char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_srl(vector bool char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_srl(vector bool char __a, vector unsigned short __b) { + return (vector bool char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_srl(vector bool char __a, vector unsigned int __b) { + return (vector bool char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a, + vector unsigned short __b) { + return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_srl(vector short __a, + vector unsigned int __b) { + return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_srl(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_srl(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_srl(vector unsigned short __a, vector unsigned int __b) { + return (vector unsigned short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_srl(vector bool short __a, vector unsigned char __b) { + return (vector bool short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_srl(vector bool short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_srl(vector bool short __a, vector unsigned int __b) { + return (vector bool short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a, + vector unsigned short __b) { + return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_srl(vector pixel __a, + vector unsigned int __b) { + return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vsr(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a, + vector unsigned short __b) { + return (vector int)__builtin_altivec_vsr(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_srl(vector int __a, + vector unsigned int __b) { + return (vector int)__builtin_altivec_vsr(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_srl(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_srl(vector unsigned int __a, vector unsigned short __b) { + return (vector unsigned int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_srl(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_srl(vector bool int __a, vector unsigned char __b) { + return (vector bool int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_srl(vector bool int __a, vector unsigned short __b) { + return (vector bool int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_srl(vector bool int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_srl(vector signed long long __a, vector unsigned char __b) { + return (vector signed long long)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_srl(vector unsigned long long __a, vector unsigned char __b) { + return (vector unsigned long long)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} +#endif + +/* vec_vsr */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsr(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsr(vector signed char __a, vector unsigned short __b) { + return (vector signed char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsr(vector signed char __a, vector unsigned int __b) { + return (vector signed char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsr(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsr(vector unsigned char __a, vector unsigned short __b) { + return (vector unsigned char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsr(vector unsigned char __a, vector unsigned int __b) { + return (vector unsigned char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsr(vector bool char __a, vector unsigned char __b) { + return (vector bool char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsr(vector bool char __a, vector unsigned short __b) { + return (vector bool char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsr(vector bool char __a, vector unsigned int __b) { + return (vector bool char)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a, + vector unsigned short __b) { + return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsr(vector short __a, + vector unsigned int __b) { + return (vector short)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsr(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsr(vector unsigned short __a, vector unsigned short __b) { + return (vector unsigned short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsr(vector unsigned short __a, vector unsigned int __b) { + return (vector unsigned short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsr(vector bool short __a, vector unsigned char __b) { + return (vector bool short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsr(vector bool short __a, vector unsigned short __b) { + return (vector bool short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsr(vector bool short __a, vector unsigned int __b) { + return (vector bool short)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a, + vector unsigned short __b) { + return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsr(vector pixel __a, + vector unsigned int __b) { + return (vector pixel)__builtin_altivec_vsr((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vsr(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a, + vector unsigned short __b) { + return (vector int)__builtin_altivec_vsr(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsr(vector int __a, + vector unsigned int __b) { + return (vector int)__builtin_altivec_vsr(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsr(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsr(vector unsigned int __a, vector unsigned short __b) { + return (vector unsigned int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsr(vector unsigned int __a, vector unsigned int __b) { + return (vector unsigned int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsr(vector bool int __a, vector unsigned char __b) { + return (vector bool int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsr(vector bool int __a, vector unsigned short __b) { + return (vector bool int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsr(vector bool int __a, vector unsigned int __b) { + return (vector bool int)__builtin_altivec_vsr((vector int)__a, + (vector int)__b); +} + +/* vec_sro */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_sro(vector signed char __a, vector signed char __b) { + return (vector signed char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sro(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sro(vector unsigned char __a, vector signed char __b) { + return (vector unsigned char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sro(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a, + vector signed char __b) { + return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_sro(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sro(vector unsigned short __a, vector signed char __b) { + return (vector unsigned short)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sro(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a, + vector signed char __b) { + return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_sro(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a, + vector signed char __b) { + return (vector int)__builtin_altivec_vsro(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sro(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vsro(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sro(vector unsigned int __a, vector signed char __b) { + return (vector unsigned int)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sro(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a, + vector signed char __b) { + return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_sro(vector float __a, + vector unsigned char __b) { + return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_sro(vector signed long long __a, vector signed char __b) { + return (vector signed long long)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_sro(vector signed long long __a, vector unsigned char __b) { + return (vector signed long long)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sro(vector unsigned long long __a, vector signed char __b) { + return (vector unsigned long long)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sro(vector unsigned long long __a, vector unsigned char __b) { + return (vector unsigned long long)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} +#endif + +/* vec_vsro */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsro(vector signed char __a, vector signed char __b) { + return (vector signed char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsro(vector signed char __a, vector unsigned char __b) { + return (vector signed char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsro(vector unsigned char __a, vector signed char __b) { + return (vector unsigned char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsro(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a, + vector signed char __b) { + return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsro(vector short __a, + vector unsigned char __b) { + return (vector short)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsro(vector unsigned short __a, vector signed char __b) { + return (vector unsigned short)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsro(vector unsigned short __a, vector unsigned char __b) { + return (vector unsigned short)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a, + vector signed char __b) { + return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_vsro(vector pixel __a, + vector unsigned char __b) { + return (vector pixel)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a, + vector signed char __b) { + return (vector int)__builtin_altivec_vsro(__a, (vector int)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsro(vector int __a, + vector unsigned char __b) { + return (vector int)__builtin_altivec_vsro(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsro(vector unsigned int __a, vector signed char __b) { + return (vector unsigned int)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsro(vector unsigned int __a, vector unsigned char __b) { + return (vector unsigned int)__builtin_altivec_vsro((vector int)__a, + (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a, + vector signed char __b) { + return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +static __inline__ vector float __ATTRS_o_ai vec_vsro(vector float __a, + vector unsigned char __b) { + return (vector float)__builtin_altivec_vsro((vector int)__a, (vector int)__b); +} + +/* vec_st */ + +static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, long __b, + vector signed char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector signed char __a, long __b, + signed char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, long __b, + vector unsigned char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector unsigned char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b, + signed char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool char __a, long __b, + vector bool char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector short __a, long __b, + vector short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector short __a, long __b, + short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, long __b, + vector unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector unsigned short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b, + short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool short __a, long __b, + vector bool short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b, + short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector pixel __a, long __b, + vector pixel *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector int __a, long __b, + vector int *__c) { + __builtin_altivec_stvx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector int __a, long __b, int *__c) { + __builtin_altivec_stvx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, long __b, + vector unsigned int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector unsigned int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b, + int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector bool int __a, long __b, + vector bool int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector float __a, long __b, + vector float *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_st(vector float __a, long __b, + float *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +/* vec_stvx */ + +static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, long __b, + vector signed char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector signed char __a, long __b, + signed char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, long __b, + vector unsigned char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b, + signed char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool char __a, long __b, + vector bool char *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, long __b, + vector short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector short __a, long __b, + short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, long __b, + vector unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b, + short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool short __a, long __b, + vector bool short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b, + short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector pixel __a, long __b, + vector pixel *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, long __b, + vector int *__c) { + __builtin_altivec_stvx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector int __a, long __b, + int *__c) { + __builtin_altivec_stvx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, long __b, + vector unsigned int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector unsigned int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b, + int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector bool int __a, long __b, + vector bool int *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, long __b, + vector float *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvx(vector float __a, long __b, + float *__c) { + __builtin_altivec_stvx((vector int)__a, __b, __c); +} + +/* vec_ste */ + +static __inline__ void __ATTRS_o_ai vec_ste(vector signed char __a, long __b, + signed char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, long __b, + signed char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector bool char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector short __a, long __b, + short *__c) { + __builtin_altivec_stvehx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, long __b, + short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector bool short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, long __b, + short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector pixel __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector int __a, long __b, int *__c) { + __builtin_altivec_stvewx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector unsigned int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, long __b, + int *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector bool int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_ste(vector float __a, long __b, + float *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +/* vec_stvebx */ + +static __inline__ void __ATTRS_o_ai vec_stvebx(vector signed char __a, long __b, + signed char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvebx(vector unsigned char __a, + long __b, unsigned char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, long __b, + signed char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvebx(vector bool char __a, long __b, + unsigned char *__c) { + __builtin_altivec_stvebx((vector char)__a, __b, __c); +} + +/* vec_stvehx */ + +static __inline__ void __ATTRS_o_ai vec_stvehx(vector short __a, long __b, + short *__c) { + __builtin_altivec_stvehx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvehx(vector unsigned short __a, + long __b, unsigned short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, long __b, + short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvehx(vector bool short __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, long __b, + short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvehx(vector pixel __a, long __b, + unsigned short *__c) { + __builtin_altivec_stvehx((vector short)__a, __b, __c); +} + +/* vec_stvewx */ + +static __inline__ void __ATTRS_o_ai vec_stvewx(vector int __a, long __b, + int *__c) { + __builtin_altivec_stvewx(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvewx(vector unsigned int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, long __b, + int *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvewx(vector bool int __a, long __b, + unsigned int *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvewx(vector float __a, long __b, + float *__c) { + __builtin_altivec_stvewx((vector int)__a, __b, __c); +} + +/* vec_stl */ + +static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b, + vector signed char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector signed char __a, int __b, + signed char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b, + vector unsigned char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned char __a, int __b, + unsigned char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b, + signed char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b, + unsigned char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool char __a, int __b, + vector bool char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b, + vector short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector short __a, int __b, + short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b, + vector unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned short __a, int __b, + unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b, + short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b, + unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool short __a, int __b, + vector bool short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b, + short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b, + unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector pixel __a, int __b, + vector pixel *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b, + vector int *__c) { + __builtin_altivec_stvxl(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector int __a, int __b, int *__c) { + __builtin_altivec_stvxl(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b, + vector unsigned int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector unsigned int __a, int __b, + unsigned int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b, + int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b, + unsigned int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector bool int __a, int __b, + vector bool int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b, + vector float *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stl(vector float __a, int __b, + float *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +/* vec_stvxl */ + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b, + vector signed char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector signed char __a, int __b, + signed char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b, + vector unsigned char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned char __a, int __b, + unsigned char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b, + signed char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b, + unsigned char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool char __a, int __b, + vector bool char *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b, + vector short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector short __a, int __b, + short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a, + int __b, + vector unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned short __a, + int __b, unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b, + short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b, + unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool short __a, int __b, + vector bool short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b, + short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b, + unsigned short *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector pixel __a, int __b, + vector pixel *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b, + vector int *__c) { + __builtin_altivec_stvxl(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector int __a, int __b, + int *__c) { + __builtin_altivec_stvxl(__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b, + vector unsigned int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector unsigned int __a, int __b, + unsigned int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b, + int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b, + unsigned int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector bool int __a, int __b, + vector bool int *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b, + vector float *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvxl(vector float __a, int __b, + float *__c) { + __builtin_altivec_stvxl((vector int)__a, __b, __c); +} + +/* vec_sub */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_sub(vector signed char __a, vector signed char __b) { + return __a - __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sub(vector bool char __a, vector signed char __b) { + return (vector signed char)__a - __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_sub(vector signed char __a, vector bool char __b) { + return __a - (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sub(vector unsigned char __a, vector unsigned char __b) { + return __a - __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sub(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a - __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_sub(vector unsigned char __a, vector bool char __b) { + return __a - (vector unsigned char)__b; +} + +static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a, + vector short __b) { + return __a - __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_sub(vector bool short __a, + vector short __b) { + return (vector short)__a - __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_sub(vector short __a, + vector bool short __b) { + return __a - (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sub(vector unsigned short __a, vector unsigned short __b) { + return __a - __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sub(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a - __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_sub(vector unsigned short __a, vector bool short __b) { + return __a - (vector unsigned short)__b; +} + +static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a, + vector int __b) { + return __a - __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_sub(vector bool int __a, + vector int __b) { + return (vector int)__a - __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_sub(vector int __a, + vector bool int __b) { + return __a - (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sub(vector unsigned int __a, vector unsigned int __b) { + return __a - __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sub(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a - __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sub(vector unsigned int __a, vector bool int __b) { + return __a - (vector unsigned int)__b; +} + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_sub(vector signed __int128 __a, vector signed __int128 __b) { + return __a - __b; +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_sub(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a - __b; +} +#endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) && + // defined(__SIZEOF_INT128__) + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_sub(vector signed long long __a, vector signed long long __b) { + return __a - __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_sub(vector unsigned long long __a, vector unsigned long long __b) { + return __a - __b; +} + +static __inline__ vector double __ATTRS_o_ai vec_sub(vector double __a, + vector double __b) { + return __a - __b; +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_sub(vector float __a, + vector float __b) { + return __a - __b; +} + +/* vec_vsububm */ + +#define __builtin_altivec_vsububm vec_vsububm + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsububm(vector signed char __a, vector signed char __b) { + return __a - __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsububm(vector bool char __a, vector signed char __b) { + return (vector signed char)__a - __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsububm(vector signed char __a, vector bool char __b) { + return __a - (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsububm(vector unsigned char __a, vector unsigned char __b) { + return __a - __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsububm(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a - __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsububm(vector unsigned char __a, vector bool char __b) { + return __a - (vector unsigned char)__b; +} + +/* vec_vsubuhm */ + +#define __builtin_altivec_vsubuhm vec_vsubuhm + +static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a, + vector short __b) { + return __a - __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector bool short __a, + vector short __b) { + return (vector short)__a - __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vsubuhm(vector short __a, + vector bool short __b) { + return __a - (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsubuhm(vector unsigned short __a, vector unsigned short __b) { + return __a - __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsubuhm(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a - __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsubuhm(vector unsigned short __a, vector bool short __b) { + return __a - (vector unsigned short)__b; +} + +/* vec_vsubuwm */ + +#define __builtin_altivec_vsubuwm vec_vsubuwm + +static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a, + vector int __b) { + return __a - __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector bool int __a, + vector int __b) { + return (vector int)__a - __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vsubuwm(vector int __a, + vector bool int __b) { + return __a - (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsubuwm(vector unsigned int __a, vector unsigned int __b) { + return __a - __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsubuwm(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a - __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsubuwm(vector unsigned int __a, vector bool int __b) { + return __a - (vector unsigned int)__b; +} + +/* vec_vsubfp */ + +#define __builtin_altivec_vsubfp vec_vsubfp + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vsubfp(vector float __a, vector float __b) { + return __a - __b; +} + +/* vec_subc */ + +static __inline__ vector signed int __ATTRS_o_ai +vec_subc(vector signed int __a, vector signed int __b) { + return (vector signed int)__builtin_altivec_vsubcuw((vector unsigned int)__a, + (vector unsigned int) __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_subc(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vsubcuw(__a, __b); +} + +#ifdef __POWER8_VECTOR__ +#ifdef __SIZEOF_INT128__ +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_subc(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __builtin_altivec_vsubcuq(__a, __b); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_subc(vector signed __int128 __a, vector signed __int128 __b) { + return (vector signed __int128)__builtin_altivec_vsubcuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_subc_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsubcuq_c( + (vector unsigned char)__a, (vector unsigned char)__b); +} +#endif // __POWER8_VECTOR__ + +/* vec_vsubcuw */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vsubcuw(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vsubcuw(__a, __b); +} + +/* vec_subs */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_subs(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vsubsbs(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_subs(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vsubsbs((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_subs(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vsubsbs(__a, (vector signed char)__b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_subs(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vsububs(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_subs(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vsububs((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_subs(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vsububs(__a, (vector unsigned char)__b); +} + +static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a, + vector short __b) { + return __builtin_altivec_vsubshs(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_subs(vector bool short __a, + vector short __b) { + return __builtin_altivec_vsubshs((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_subs(vector short __a, + vector bool short __b) { + return __builtin_altivec_vsubshs(__a, (vector short)__b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_subs(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vsubuhs(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_subs(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_subs(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b); +} + +static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a, + vector int __b) { + return __builtin_altivec_vsubsws(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_subs(vector bool int __a, + vector int __b) { + return __builtin_altivec_vsubsws((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_subs(vector int __a, + vector bool int __b) { + return __builtin_altivec_vsubsws(__a, (vector int)__b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_subs(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vsubuws(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_subs(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vsubuws((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_subs(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b); +} + +/* vec_vsubsbs */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsubsbs(vector signed char __a, vector signed char __b) { + return __builtin_altivec_vsubsbs(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsubsbs(vector bool char __a, vector signed char __b) { + return __builtin_altivec_vsubsbs((vector signed char)__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsubsbs(vector signed char __a, vector bool char __b) { + return __builtin_altivec_vsubsbs(__a, (vector signed char)__b); +} + +/* vec_vsububs */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsububs(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_vsububs(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsububs(vector bool char __a, vector unsigned char __b) { + return __builtin_altivec_vsububs((vector unsigned char)__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsububs(vector unsigned char __a, vector bool char __b) { + return __builtin_altivec_vsububs(__a, (vector unsigned char)__b); +} + +/* vec_vsubshs */ + +static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a, + vector short __b) { + return __builtin_altivec_vsubshs(__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector bool short __a, + vector short __b) { + return __builtin_altivec_vsubshs((vector short)__a, __b); +} + +static __inline__ vector short __ATTRS_o_ai vec_vsubshs(vector short __a, + vector bool short __b) { + return __builtin_altivec_vsubshs(__a, (vector short)__b); +} + +/* vec_vsubuhs */ + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsubuhs(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_vsubuhs(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsubuhs(vector bool short __a, vector unsigned short __b) { + return __builtin_altivec_vsubuhs((vector unsigned short)__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsubuhs(vector unsigned short __a, vector bool short __b) { + return __builtin_altivec_vsubuhs(__a, (vector unsigned short)__b); +} + +/* vec_vsubsws */ + +static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a, + vector int __b) { + return __builtin_altivec_vsubsws(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector bool int __a, + vector int __b) { + return __builtin_altivec_vsubsws((vector int)__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_vsubsws(vector int __a, + vector bool int __b) { + return __builtin_altivec_vsubsws(__a, (vector int)__b); +} + +/* vec_vsubuws */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsubuws(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_vsubuws(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsubuws(vector bool int __a, vector unsigned int __b) { + return __builtin_altivec_vsubuws((vector unsigned int)__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsubuws(vector unsigned int __a, vector bool int __b) { + return __builtin_altivec_vsubuws(__a, (vector unsigned int)__b); +} + +#ifdef __POWER8_VECTOR__ +/* vec_vsubuqm */ + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vsubuqm(vector signed __int128 __a, vector signed __int128 __b) { + return __a - __b; +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vsubuqm(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a - __b; +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_sub_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsubuqm(__a, __b); +} + +/* vec_vsubeuqm */ + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vsubeuqm(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vsubeuqm( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vsubeuqm(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vsubeuqm(__a, __b, __c); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_sube(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vsubeuqm( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_sube(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vsubeuqm(__a, __b, __c); +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_sube_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vsubeuqm_c( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +/* vec_vsubcuq */ + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vsubcuq(vector signed __int128 __a, vector signed __int128 __b) { + return (vector signed __int128)__builtin_altivec_vsubcuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vsubcuq(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __builtin_altivec_vsubcuq(__a, __b); +} + +/* vec_vsubecuq */ + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_vsubecuq(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vsubecuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_vsubecuq(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vsubecuq(__a, __b, __c); +} +#endif + +#ifdef __powerpc64__ +static __inline__ vector signed int __ATTRS_o_ai +vec_subec(vector signed int __a, vector signed int __b, + vector signed int __c) { + return vec_addec(__a, ~__b, __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_subec(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + return vec_addec(__a, ~__b, __c); +} +#endif + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_subec(vector signed __int128 __a, vector signed __int128 __b, + vector signed __int128 __c) { + return (vector signed __int128)__builtin_altivec_vsubecuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_subec(vector unsigned __int128 __a, vector unsigned __int128 __b, + vector unsigned __int128 __c) { + return __builtin_altivec_vsubecuq(__a, __b, __c); +} +#endif + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_subec_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vsubecuq_c( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} +#endif // __POWER8_VECTOR__ + +static __inline__ vector signed int __ATTRS_o_ai +vec_sube(vector signed int __a, vector signed int __b, + vector signed int __c) { + vector signed int __mask = {1, 1, 1, 1}; + vector signed int __carry = __c & __mask; + return vec_adde(__a, ~__b, __carry); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sube(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + vector unsigned int __mask = {1, 1, 1, 1}; + vector unsigned int __carry = __c & __mask; + return vec_adde(__a, ~__b, __carry); +} +/* vec_sum4s */ + +static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed char __a, + vector int __b) { + return __builtin_altivec_vsum4sbs(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_sum4s(vector unsigned char __a, vector unsigned int __b) { + return __builtin_altivec_vsum4ubs(__a, __b); +} + +static __inline__ vector int __ATTRS_o_ai vec_sum4s(vector signed short __a, + vector int __b) { + return __builtin_altivec_vsum4shs(__a, __b); +} + +/* vec_vsum4sbs */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vsum4sbs(vector signed char __a, vector int __b) { + return __builtin_altivec_vsum4sbs(__a, __b); +} + +/* vec_vsum4ubs */ + +static __inline__ vector unsigned int __attribute__((__always_inline__)) +vec_vsum4ubs(vector unsigned char __a, vector unsigned int __b) { + return __builtin_altivec_vsum4ubs(__a, __b); +} + +/* vec_vsum4shs */ + +static __inline__ vector int __attribute__((__always_inline__)) +vec_vsum4shs(vector signed short __a, vector int __b) { + return __builtin_altivec_vsum4shs(__a, __b); +} + +/* vec_sum2s */ + +/* The vsum2sws instruction has a big-endian bias, so that the second + input vector and the result always reference big-endian elements + 1 and 3 (little-endian element 0 and 2). For ease of porting the + programmer wants elements 1 and 3 in both cases, so for little + endian we must perform some permutes. */ + +static __inline__ vector signed int __attribute__((__always_inline__)) +vec_sum2s(vector int __a, vector int __b) { +#ifdef __LITTLE_ENDIAN__ + vector int __c = (vector signed int)vec_perm( + __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, + 8, 9, 10, 11)); + __c = __builtin_altivec_vsum2sws(__a, __c); + return (vector signed int)vec_perm( + __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, + 8, 9, 10, 11)); +#else + return __builtin_altivec_vsum2sws(__a, __b); +#endif +} + +/* vec_vsum2sws */ + +static __inline__ vector signed int __attribute__((__always_inline__)) +vec_vsum2sws(vector int __a, vector int __b) { +#ifdef __LITTLE_ENDIAN__ + vector int __c = (vector signed int)vec_perm( + __b, __b, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, + 8, 9, 10, 11)); + __c = __builtin_altivec_vsum2sws(__a, __c); + return (vector signed int)vec_perm( + __c, __c, (vector unsigned char)(4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, + 8, 9, 10, 11)); +#else + return __builtin_altivec_vsum2sws(__a, __b); +#endif +} + +/* vec_sums */ + +/* The vsumsws instruction has a big-endian bias, so that the second + input vector and the result always reference big-endian element 3 + (little-endian element 0). For ease of porting the programmer + wants element 3 in both cases, so for little endian we must perform + some permutes. */ + +static __inline__ vector signed int __attribute__((__always_inline__)) +vec_sums(vector signed int __a, vector signed int __b) { +#ifdef __LITTLE_ENDIAN__ + __b = (vector signed int)vec_splat(__b, 3); + __b = __builtin_altivec_vsumsws(__a, __b); + return (vector signed int)(0, 0, 0, __b[0]); +#else + return __builtin_altivec_vsumsws(__a, __b); +#endif +} + +/* vec_vsumsws */ + +static __inline__ vector signed int __attribute__((__always_inline__)) +vec_vsumsws(vector signed int __a, vector signed int __b) { +#ifdef __LITTLE_ENDIAN__ + __b = (vector signed int)vec_splat(__b, 3); + __b = __builtin_altivec_vsumsws(__a, __b); + return (vector signed int)(0, 0, 0, __b[0]); +#else + return __builtin_altivec_vsumsws(__a, __b); +#endif +} + +/* vec_trunc */ + +static __inline__ vector float __ATTRS_o_ai vec_trunc(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvrspiz(__a); +#else + return __builtin_altivec_vrfiz(__a); +#endif +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_trunc(vector double __a) { + return __builtin_vsx_xvrdpiz(__a); +} +#endif + +/* vec_roundz */ +static __inline__ vector float __ATTRS_o_ai vec_roundz(vector float __a) { + return vec_trunc(__a); +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_roundz(vector double __a) { + return vec_trunc(__a); +} +#endif + +/* vec_vrfiz */ + +static __inline__ vector float __attribute__((__always_inline__)) +vec_vrfiz(vector float __a) { + return __builtin_altivec_vrfiz(__a); +} + +/* vec_unpackh */ + +/* The vector unpack instructions all have a big-endian bias, so for + little endian we must reverse the meanings of "high" and "low." */ +#ifdef __LITTLE_ENDIAN__ +#define vec_vupkhpx(__a) __builtin_altivec_vupklpx((vector short)(__a)) +#define vec_vupklpx(__a) __builtin_altivec_vupkhpx((vector short)(__a)) +#else +#define vec_vupkhpx(__a) __builtin_altivec_vupkhpx((vector short)(__a)) +#define vec_vupklpx(__a) __builtin_altivec_vupklpx((vector short)(__a)) +#endif + +static __inline__ vector short __ATTRS_o_ai +vec_unpackh(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupklsb((vector char)__a); +#else + return __builtin_altivec_vupkhsb((vector char)__a); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_unpackh(vector bool char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool short)__builtin_altivec_vupklsb((vector char)__a); +#else + return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a); +#endif +} + +static __inline__ vector int __ATTRS_o_ai vec_unpackh(vector short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupklsh(__a); +#else + return __builtin_altivec_vupkhsh(__a); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_unpackh(vector bool short __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool int)__builtin_altivec_vupklsh((vector short)__a); +#else + return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_unpackh(vector pixel __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a); +#else + return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a); +#endif +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector long long __ATTRS_o_ai vec_unpackh(vector int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupklsw(__a); +#else + return __builtin_altivec_vupkhsw(__a); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_unpackh(vector bool int __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a); +#else + return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_unpackh(vector float __a) { + return (vector double)(__a[0], __a[1]); +} +#endif + +/* vec_vupkhsb */ + +static __inline__ vector short __ATTRS_o_ai +vec_vupkhsb(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupklsb((vector char)__a); +#else + return __builtin_altivec_vupkhsb((vector char)__a); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vupkhsb(vector bool char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool short)__builtin_altivec_vupklsb((vector char)__a); +#else + return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a); +#endif +} + +/* vec_vupkhsh */ + +static __inline__ vector int __ATTRS_o_ai vec_vupkhsh(vector short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupklsh(__a); +#else + return __builtin_altivec_vupkhsh(__a); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vupkhsh(vector bool short __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool int)__builtin_altivec_vupklsh((vector short)__a); +#else + return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vupkhsh(vector pixel __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a); +#else + return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a); +#endif +} + +/* vec_vupkhsw */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector long long __ATTRS_o_ai vec_vupkhsw(vector int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupklsw(__a); +#else + return __builtin_altivec_vupkhsw(__a); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_vupkhsw(vector bool int __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a); +#else + return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a); +#endif +} +#endif + +/* vec_unpackl */ + +static __inline__ vector short __ATTRS_o_ai +vec_unpackl(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupkhsb((vector char)__a); +#else + return __builtin_altivec_vupklsb((vector char)__a); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_unpackl(vector bool char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a); +#else + return (vector bool short)__builtin_altivec_vupklsb((vector char)__a); +#endif +} + +static __inline__ vector int __ATTRS_o_ai vec_unpackl(vector short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupkhsh(__a); +#else + return __builtin_altivec_vupklsh(__a); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_unpackl(vector bool short __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a); +#else + return (vector bool int)__builtin_altivec_vupklsh((vector short)__a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_unpackl(vector pixel __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a); +#else + return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a); +#endif +} + +#ifdef __POWER8_VECTOR__ +static __inline__ vector long long __ATTRS_o_ai vec_unpackl(vector int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupkhsw(__a); +#else + return __builtin_altivec_vupklsw(__a); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_unpackl(vector bool int __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a); +#else + return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a); +#endif +} + +static __inline__ vector double __ATTRS_o_ai +vec_unpackl(vector float __a) { + return (vector double)(__a[2], __a[3]); +} +#endif + +/* vec_vupklsb */ + +static __inline__ vector short __ATTRS_o_ai +vec_vupklsb(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupkhsb((vector char)__a); +#else + return __builtin_altivec_vupklsb((vector char)__a); +#endif +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vupklsb(vector bool char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool short)__builtin_altivec_vupkhsb((vector char)__a); +#else + return (vector bool short)__builtin_altivec_vupklsb((vector char)__a); +#endif +} + +/* vec_vupklsh */ + +static __inline__ vector int __ATTRS_o_ai vec_vupklsh(vector short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupkhsh(__a); +#else + return __builtin_altivec_vupklsh(__a); +#endif +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_vupklsh(vector bool short __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool int)__builtin_altivec_vupkhsh((vector short)__a); +#else + return (vector bool int)__builtin_altivec_vupklsh((vector short)__a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vupklsh(vector pixel __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned int)__builtin_altivec_vupkhpx((vector short)__a); +#else + return (vector unsigned int)__builtin_altivec_vupklpx((vector short)__a); +#endif +} + +/* vec_vupklsw */ + +#ifdef __POWER8_VECTOR__ +static __inline__ vector long long __ATTRS_o_ai vec_vupklsw(vector int __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vupkhsw(__a); +#else + return __builtin_altivec_vupklsw(__a); +#endif +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_vupklsw(vector bool int __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector bool long long)__builtin_altivec_vupkhsw((vector int)__a); +#else + return (vector bool long long)__builtin_altivec_vupklsw((vector int)__a); +#endif +} +#endif + +/* vec_vsx_ld */ + +#ifdef __VSX__ + +static __inline__ vector bool int __ATTRS_o_ai +vec_vsx_ld(int __a, const vector bool int *__b) { + return (vector bool int)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_vsx_ld(int __a, const vector signed int *__b) { + return (vector signed int)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_vsx_ld(int __a, const signed int *__b) { + return (vector signed int)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsx_ld(int __a, const vector unsigned int *__b) { + return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vsx_ld(int __a, const unsigned int *__b) { + return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_vsx_ld(int __a, const vector float *__b) { + return (vector float)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector float __ATTRS_o_ai vec_vsx_ld(int __a, + const float *__b) { + return (vector float)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vsx_ld(int __a, const vector signed long long *__b) { + return (vector signed long long)__builtin_vsx_lxvd2x(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vsx_ld(int __a, const vector unsigned long long *__b) { + return (vector unsigned long long)__builtin_vsx_lxvd2x(__a, __b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_vsx_ld(int __a, const vector double *__b) { + return (vector double)__builtin_vsx_lxvd2x(__a, __b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_vsx_ld(int __a, const double *__b) { + return (vector double)__builtin_vsx_lxvd2x(__a, __b); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vsx_ld(int __a, const vector bool short *__b) { + return (vector bool short)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_vsx_ld(int __a, const vector signed short *__b) { + return (vector signed short)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_vsx_ld(int __a, const signed short *__b) { + return (vector signed short)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsx_ld(int __a, const vector unsigned short *__b) { + return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vsx_ld(int __a, const unsigned short *__b) { + return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_vsx_ld(int __a, const vector bool char *__b) { + return (vector bool char)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsx_ld(int __a, const vector signed char *__b) { + return (vector signed char)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vsx_ld(int __a, const signed char *__b) { + return (vector signed char)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsx_ld(int __a, const vector unsigned char *__b) { + return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vsx_ld(int __a, const unsigned char *__b) { + return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b); +} + +#endif + +/* vec_vsx_st */ + +#ifdef __VSX__ + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b, + vector bool int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b, + signed int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b, + unsigned int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b, + vector signed int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b, + signed int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b, + vector unsigned int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b, + unsigned int *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b, + vector float *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b, + float *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed long long __a, + int __b, + vector signed long long *__c) { + __builtin_vsx_stxvd2x((vector double)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned long long __a, + int __b, + vector unsigned long long *__c) { + __builtin_vsx_stxvd2x((vector double)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b, + vector double *__c) { + __builtin_vsx_stxvd2x((vector double)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b, + double *__c) { + __builtin_vsx_stxvd2x((vector double)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b, + vector bool short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b, + signed short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b, + unsigned short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b, + vector signed short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b, + signed short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a, + int __b, + vector unsigned short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a, + int __b, unsigned short *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b, + vector bool char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b, + signed char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool char __a, int __b, + unsigned char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b, + vector signed char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b, + signed char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a, + int __b, + vector unsigned char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a, + int __b, unsigned char *__c) { + __builtin_vsx_stxvw4x((vector int)__a, __b, __c); +} + +#endif + +#ifdef __VSX__ +#define vec_xxpermdi __builtin_vsx_xxpermdi +#define vec_xxsldwi __builtin_vsx_xxsldwi +#define vec_permi(__a, __b, __c) \ + _Generic((__a), vector signed long long \ + : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \ + (((__c)&0x1) + 2)), \ + vector unsigned long long \ + : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \ + (((__c)&0x1) + 2)), \ + vector double \ + : __builtin_shufflevector((__a), (__b), (((__c) >> 1) & 0x1), \ + (((__c)&0x1) + 2))) +#endif + +/* vec_xor */ + +#define __builtin_altivec_vxor vec_xor + +static __inline__ vector signed char __ATTRS_o_ai +vec_xor(vector signed char __a, vector signed char __b) { + return __a ^ __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_xor(vector bool char __a, vector signed char __b) { + return (vector signed char)__a ^ __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_xor(vector signed char __a, vector bool char __b) { + return __a ^ (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xor(vector unsigned char __a, vector unsigned char __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xor(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a ^ __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xor(vector unsigned char __a, vector bool char __b) { + return __a ^ (vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_xor(vector bool char __a, + vector bool char __b) { + return __a ^ __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a, + vector short __b) { + return __a ^ __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_xor(vector bool short __a, + vector short __b) { + return (vector short)__a ^ __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_xor(vector short __a, + vector bool short __b) { + return __a ^ (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_xor(vector unsigned short __a, vector unsigned short __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_xor(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a ^ __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_xor(vector unsigned short __a, vector bool short __b) { + return __a ^ (vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_xor(vector bool short __a, vector bool short __b) { + return __a ^ __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a, + vector int __b) { + return __a ^ __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_xor(vector bool int __a, + vector int __b) { + return (vector int)__a ^ __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_xor(vector int __a, + vector bool int __b) { + return __a ^ (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_xor(vector unsigned int __a, vector unsigned int __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_xor(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a ^ __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_xor(vector unsigned int __a, vector bool int __b) { + return __a ^ (vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_xor(vector bool int __a, + vector bool int __b) { + return __a ^ __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a ^ (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_xor(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a ^ (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_xor(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a ^ (vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_xor(vector signed long long __a, vector signed long long __b) { + return __a ^ __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_xor(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a ^ __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_xor(vector signed long long __a, vector bool long long __b) { + return __a ^ (vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_xor(vector unsigned long long __a, vector unsigned long long __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_xor(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a ^ __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_xor(vector unsigned long long __a, vector bool long long __b) { + return __a ^ (vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_xor(vector bool long long __a, vector bool long long __b) { + return __a ^ __b; +} + +static __inline__ vector double __ATTRS_o_ai vec_xor(vector double __a, + vector double __b) { + return (vector double)((vector unsigned long long)__a ^ + (vector unsigned long long)__b); +} + +static __inline__ vector double __ATTRS_o_ai +vec_xor(vector double __a, vector bool long long __b) { + return (vector double)((vector unsigned long long)__a ^ + (vector unsigned long long)__b); +} + +static __inline__ vector double __ATTRS_o_ai vec_xor(vector bool long long __a, + vector double __b) { + return (vector double)((vector unsigned long long)__a ^ + (vector unsigned long long)__b); +} +#endif + +/* vec_vxor */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_vxor(vector signed char __a, vector signed char __b) { + return __a ^ __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vxor(vector bool char __a, vector signed char __b) { + return (vector signed char)__a ^ __b; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vxor(vector signed char __a, vector bool char __b) { + return __a ^ (vector signed char)__b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vxor(vector unsigned char __a, vector unsigned char __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vxor(vector bool char __a, vector unsigned char __b) { + return (vector unsigned char)__a ^ __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vxor(vector unsigned char __a, vector bool char __b) { + return __a ^ (vector unsigned char)__b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_vxor(vector bool char __a, + vector bool char __b) { + return __a ^ __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a, + vector short __b) { + return __a ^ __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vxor(vector bool short __a, + vector short __b) { + return (vector short)__a ^ __b; +} + +static __inline__ vector short __ATTRS_o_ai vec_vxor(vector short __a, + vector bool short __b) { + return __a ^ (vector short)__b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vxor(vector unsigned short __a, vector unsigned short __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vxor(vector bool short __a, vector unsigned short __b) { + return (vector unsigned short)__a ^ __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_vxor(vector unsigned short __a, vector bool short __b) { + return __a ^ (vector unsigned short)__b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_vxor(vector bool short __a, vector bool short __b) { + return __a ^ __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a, + vector int __b) { + return __a ^ __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vxor(vector bool int __a, + vector int __b) { + return (vector int)__a ^ __b; +} + +static __inline__ vector int __ATTRS_o_ai vec_vxor(vector int __a, + vector bool int __b) { + return __a ^ (vector int)__b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vxor(vector unsigned int __a, vector unsigned int __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vxor(vector bool int __a, vector unsigned int __b) { + return (vector unsigned int)__a ^ __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_vxor(vector unsigned int __a, vector bool int __b) { + return __a ^ (vector unsigned int)__b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_vxor(vector bool int __a, + vector bool int __b) { + return __a ^ __b; +} + +static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a ^ (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vxor(vector bool int __a, + vector float __b) { + vector unsigned int __res = + (vector unsigned int)__a ^ (vector unsigned int)__b; + return (vector float)__res; +} + +static __inline__ vector float __ATTRS_o_ai vec_vxor(vector float __a, + vector bool int __b) { + vector unsigned int __res = + (vector unsigned int)__a ^ (vector unsigned int)__b; + return (vector float)__res; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_vxor(vector signed long long __a, vector signed long long __b) { + return __a ^ __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vxor(vector bool long long __a, vector signed long long __b) { + return (vector signed long long)__a ^ __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_vxor(vector signed long long __a, vector bool long long __b) { + return __a ^ (vector signed long long)__b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vxor(vector unsigned long long __a, vector unsigned long long __b) { + return __a ^ __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vxor(vector bool long long __a, vector unsigned long long __b) { + return (vector unsigned long long)__a ^ __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_vxor(vector unsigned long long __a, vector bool long long __b) { + return __a ^ (vector unsigned long long)__b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_vxor(vector bool long long __a, vector bool long long __b) { + return __a ^ __b; +} +#endif + +/* ------------------------ extensions for CBEA ----------------------------- */ + +/* vec_extract */ + +static __inline__ signed char __ATTRS_o_ai vec_extract(vector signed char __a, + signed int __b) { + return __a[__b & 0xf]; +} + +static __inline__ unsigned char __ATTRS_o_ai +vec_extract(vector unsigned char __a, signed int __b) { + return __a[__b & 0xf]; +} + +static __inline__ unsigned char __ATTRS_o_ai vec_extract(vector bool char __a, + signed int __b) { + return __a[__b & 0xf]; +} + +static __inline__ signed short __ATTRS_o_ai vec_extract(vector signed short __a, + signed int __b) { + return __a[__b & 0x7]; +} + +static __inline__ unsigned short __ATTRS_o_ai +vec_extract(vector unsigned short __a, signed int __b) { + return __a[__b & 0x7]; +} + +static __inline__ unsigned short __ATTRS_o_ai vec_extract(vector bool short __a, + signed int __b) { + return __a[__b & 0x7]; +} + +static __inline__ signed int __ATTRS_o_ai vec_extract(vector signed int __a, + signed int __b) { + return __a[__b & 0x3]; +} + +static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector unsigned int __a, + signed int __b) { + return __a[__b & 0x3]; +} + +static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector bool int __a, + signed int __b) { + return __a[__b & 0x3]; +} + +#ifdef __VSX__ +static __inline__ signed long long __ATTRS_o_ai +vec_extract(vector signed long long __a, signed int __b) { + return __a[__b & 0x1]; +} + +static __inline__ unsigned long long __ATTRS_o_ai +vec_extract(vector unsigned long long __a, signed int __b) { + return __a[__b & 0x1]; +} + +static __inline__ unsigned long long __ATTRS_o_ai +vec_extract(vector bool long long __a, signed int __b) { + return __a[__b & 0x1]; +} + +static __inline__ double __ATTRS_o_ai vec_extract(vector double __a, + signed int __b) { + return __a[__b & 0x1]; +} +#endif + +static __inline__ float __ATTRS_o_ai vec_extract(vector float __a, + signed int __b) { + return __a[__b & 0x3]; +} + +#ifdef __POWER9_VECTOR__ + +#define vec_insert4b __builtin_vsx_insertword +#define vec_extract4b __builtin_vsx_extractuword + +/* vec_extract_exp */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_extract_exp(vector float __a) { + return __builtin_vsx_xvxexpsp(__a); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_extract_exp(vector double __a) { + return __builtin_vsx_xvxexpdp(__a); +} + +/* vec_extract_sig */ + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_extract_sig(vector float __a) { + return __builtin_vsx_xvxsigsp(__a); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_extract_sig (vector double __a) { + return __builtin_vsx_xvxsigdp(__a); +} + +static __inline__ vector float __ATTRS_o_ai +vec_extract_fp32_from_shorth(vector unsigned short __a) { + vector unsigned short __b = +#ifdef __LITTLE_ENDIAN__ + __builtin_shufflevector(__a, __a, 0, -1, 1, -1, 2, -1, 3, -1); +#else + __builtin_shufflevector(__a, __a, -1, 0, -1, 1, -1, 2, -1, 3); +#endif + return __builtin_vsx_xvcvhpsp(__b); +} + +static __inline__ vector float __ATTRS_o_ai +vec_extract_fp32_from_shortl(vector unsigned short __a) { + vector unsigned short __b = +#ifdef __LITTLE_ENDIAN__ + __builtin_shufflevector(__a, __a, 4, -1, 5, -1, 6, -1, 7, -1); +#else + __builtin_shufflevector(__a, __a, -1, 4, -1, 5, -1, 6, -1, 7); +#endif + return __builtin_vsx_xvcvhpsp(__b); +} +#endif /* __POWER9_VECTOR__ */ + +/* vec_insert */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_insert(signed char __a, vector signed char __b, int __c) { + __b[__c & 0xF] = __a; + return __b; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_insert(unsigned char __a, vector unsigned char __b, int __c) { + __b[__c & 0xF] = __a; + return __b; +} + +static __inline__ vector bool char __ATTRS_o_ai vec_insert(unsigned char __a, + vector bool char __b, + int __c) { + __b[__c & 0xF] = __a; + return __b; +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_insert(signed short __a, vector signed short __b, int __c) { + __b[__c & 0x7] = __a; + return __b; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_insert(unsigned short __a, vector unsigned short __b, int __c) { + __b[__c & 0x7] = __a; + return __b; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_insert(unsigned short __a, vector bool short __b, int __c) { + __b[__c & 0x7] = __a; + return __b; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_insert(signed int __a, vector signed int __b, int __c) { + __b[__c & 0x3] = __a; + return __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_insert(unsigned int __a, vector unsigned int __b, int __c) { + __b[__c & 0x3] = __a; + return __b; +} + +static __inline__ vector bool int __ATTRS_o_ai vec_insert(unsigned int __a, + vector bool int __b, + int __c) { + __b[__c & 0x3] = __a; + return __b; +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_insert(signed long long __a, vector signed long long __b, int __c) { + __b[__c & 0x1] = __a; + return __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_insert(unsigned long long __a, vector unsigned long long __b, int __c) { + __b[__c & 0x1] = __a; + return __b; +} + +static __inline__ vector bool long long __ATTRS_o_ai +vec_insert(unsigned long long __a, vector bool long long __b, int __c) { + __b[__c & 0x1] = __a; + return __b; +} +static __inline__ vector double __ATTRS_o_ai vec_insert(double __a, + vector double __b, + int __c) { + __b[__c & 0x1] = __a; + return __b; +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_insert(float __a, + vector float __b, + int __c) { + __b[__c & 0x3] = __a; + return __b; +} + +/* vec_lvlx */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvlx(int __a, const signed char *__b) { + return vec_perm(vec_ld(__a, __b), (vector signed char)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvlx(int __a, const vector signed char *__b) { + return vec_perm(vec_ld(__a, __b), (vector signed char)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvlx(int __a, const unsigned char *__b) { + return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvlx(int __a, const vector unsigned char *__b) { + return vec_perm(vec_ld(__a, __b), (vector unsigned char)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_lvlx(int __a, const vector bool char *__b) { + return vec_perm(vec_ld(__a, __b), (vector bool char)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a, + const short *__b) { + return vec_perm(vec_ld(__a, __b), (vector short)(0), vec_lvsl(__a, __b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvlx(int __a, + const vector short *__b) { + return vec_perm(vec_ld(__a, __b), (vector short)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvlx(int __a, const unsigned short *__b) { + return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvlx(int __a, const vector unsigned short *__b) { + return vec_perm(vec_ld(__a, __b), (vector unsigned short)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_lvlx(int __a, const vector bool short *__b) { + return vec_perm(vec_ld(__a, __b), (vector bool short)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_lvlx(int __a, + const vector pixel *__b) { + return vec_perm(vec_ld(__a, __b), (vector pixel)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a, const int *__b) { + return vec_perm(vec_ld(__a, __b), (vector int)(0), vec_lvsl(__a, __b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvlx(int __a, + const vector int *__b) { + return vec_perm(vec_ld(__a, __b), (vector int)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvlx(int __a, const unsigned int *__b) { + return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvlx(int __a, const vector unsigned int *__b) { + return vec_perm(vec_ld(__a, __b), (vector unsigned int)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_lvlx(int __a, const vector bool int *__b) { + return vec_perm(vec_ld(__a, __b), (vector bool int)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a, + const float *__b) { + return vec_perm(vec_ld(__a, __b), (vector float)(0), vec_lvsl(__a, __b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvlx(int __a, + const vector float *__b) { + return vec_perm(vec_ld(__a, __b), (vector float)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +/* vec_lvlxl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvlxl(int __a, const signed char *__b) { + return vec_perm(vec_ldl(__a, __b), (vector signed char)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvlxl(int __a, const vector signed char *__b) { + return vec_perm(vec_ldl(__a, __b), (vector signed char)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvlxl(int __a, const unsigned char *__b) { + return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvlxl(int __a, const vector unsigned char *__b) { + return vec_perm(vec_ldl(__a, __b), (vector unsigned char)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_lvlxl(int __a, const vector bool char *__b) { + return vec_perm(vec_ldl(__a, __b), (vector bool char)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a, + const short *__b) { + return vec_perm(vec_ldl(__a, __b), (vector short)(0), vec_lvsl(__a, __b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvlxl(int __a, + const vector short *__b) { + return vec_perm(vec_ldl(__a, __b), (vector short)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvlxl(int __a, const unsigned short *__b) { + return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvlxl(int __a, const vector unsigned short *__b) { + return vec_perm(vec_ldl(__a, __b), (vector unsigned short)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_lvlxl(int __a, const vector bool short *__b) { + return vec_perm(vec_ldl(__a, __b), (vector bool short)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_lvlxl(int __a, + const vector pixel *__b) { + return vec_perm(vec_ldl(__a, __b), (vector pixel)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a, const int *__b) { + return vec_perm(vec_ldl(__a, __b), (vector int)(0), vec_lvsl(__a, __b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvlxl(int __a, + const vector int *__b) { + return vec_perm(vec_ldl(__a, __b), (vector int)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvlxl(int __a, const unsigned int *__b) { + return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvlxl(int __a, const vector unsigned int *__b) { + return vec_perm(vec_ldl(__a, __b), (vector unsigned int)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_lvlxl(int __a, const vector bool int *__b) { + return vec_perm(vec_ldl(__a, __b), (vector bool int)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a, + const float *__b) { + return vec_perm(vec_ldl(__a, __b), (vector float)(0), vec_lvsl(__a, __b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvlxl(int __a, + vector float *__b) { + return vec_perm(vec_ldl(__a, __b), (vector float)(0), + vec_lvsl(__a, (unsigned char *)__b)); +} + +/* vec_lvrx */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvrx(int __a, const signed char *__b) { + return vec_perm((vector signed char)(0), vec_ld(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvrx(int __a, const vector signed char *__b) { + return vec_perm((vector signed char)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvrx(int __a, const unsigned char *__b) { + return vec_perm((vector unsigned char)(0), vec_ld(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvrx(int __a, const vector unsigned char *__b) { + return vec_perm((vector unsigned char)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_lvrx(int __a, const vector bool char *__b) { + return vec_perm((vector bool char)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a, + const short *__b) { + return vec_perm((vector short)(0), vec_ld(__a, __b), vec_lvsl(__a, __b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvrx(int __a, + const vector short *__b) { + return vec_perm((vector short)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvrx(int __a, const unsigned short *__b) { + return vec_perm((vector unsigned short)(0), vec_ld(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvrx(int __a, const vector unsigned short *__b) { + return vec_perm((vector unsigned short)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_lvrx(int __a, const vector bool short *__b) { + return vec_perm((vector bool short)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_lvrx(int __a, + const vector pixel *__b) { + return vec_perm((vector pixel)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a, const int *__b) { + return vec_perm((vector int)(0), vec_ld(__a, __b), vec_lvsl(__a, __b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvrx(int __a, + const vector int *__b) { + return vec_perm((vector int)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvrx(int __a, const unsigned int *__b) { + return vec_perm((vector unsigned int)(0), vec_ld(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvrx(int __a, const vector unsigned int *__b) { + return vec_perm((vector unsigned int)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_lvrx(int __a, const vector bool int *__b) { + return vec_perm((vector bool int)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a, + const float *__b) { + return vec_perm((vector float)(0), vec_ld(__a, __b), vec_lvsl(__a, __b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvrx(int __a, + const vector float *__b) { + return vec_perm((vector float)(0), vec_ld(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +/* vec_lvrxl */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvrxl(int __a, const signed char *__b) { + return vec_perm((vector signed char)(0), vec_ldl(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_lvrxl(int __a, const vector signed char *__b) { + return vec_perm((vector signed char)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvrxl(int __a, const unsigned char *__b) { + return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_lvrxl(int __a, const vector unsigned char *__b) { + return vec_perm((vector unsigned char)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool char __ATTRS_o_ai +vec_lvrxl(int __a, const vector bool char *__b) { + return vec_perm((vector bool char)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a, + const short *__b) { + return vec_perm((vector short)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b)); +} + +static __inline__ vector short __ATTRS_o_ai vec_lvrxl(int __a, + const vector short *__b) { + return vec_perm((vector short)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvrxl(int __a, const unsigned short *__b) { + return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_lvrxl(int __a, const vector unsigned short *__b) { + return vec_perm((vector unsigned short)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_lvrxl(int __a, const vector bool short *__b) { + return vec_perm((vector bool short)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector pixel __ATTRS_o_ai vec_lvrxl(int __a, + const vector pixel *__b) { + return vec_perm((vector pixel)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a, const int *__b) { + return vec_perm((vector int)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b)); +} + +static __inline__ vector int __ATTRS_o_ai vec_lvrxl(int __a, + const vector int *__b) { + return vec_perm((vector int)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvrxl(int __a, const unsigned int *__b) { + return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b), + vec_lvsl(__a, __b)); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_lvrxl(int __a, const vector unsigned int *__b) { + return vec_perm((vector unsigned int)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_lvrxl(int __a, const vector bool int *__b) { + return vec_perm((vector bool int)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a, + const float *__b) { + return vec_perm((vector float)(0), vec_ldl(__a, __b), vec_lvsl(__a, __b)); +} + +static __inline__ vector float __ATTRS_o_ai vec_lvrxl(int __a, + const vector float *__b) { + return vec_perm((vector float)(0), vec_ldl(__a, __b), + vec_lvsl(__a, (unsigned char *)__b)); +} + +/* vec_stvlx */ + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b, + signed char *__c) { + return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector signed char __a, int __b, + vector signed char *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b, + unsigned char *__c) { + return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned char __a, int __b, + vector unsigned char *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool char __a, int __b, + vector bool char *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b, + short *__c) { + return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector short __a, int __b, + vector short *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a, + int __b, unsigned short *__c) { + return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned short __a, + int __b, + vector unsigned short *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool short __a, int __b, + vector bool short *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector pixel __a, int __b, + vector pixel *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b, + int *__c) { + return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector int __a, int __b, + vector int *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b, + unsigned int *__c) { + return vec_st(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector unsigned int __a, int __b, + vector unsigned int *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector bool int __a, int __b, + vector bool int *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlx(vector float __a, int __b, + vector float *__c) { + return vec_st( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +/* vec_stvlxl */ + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b, + signed char *__c) { + return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector signed char __a, int __b, + vector signed char *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a, + int __b, unsigned char *__c) { + return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned char __a, + int __b, + vector unsigned char *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool char __a, int __b, + vector bool char *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b, + short *__c) { + return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector short __a, int __b, + vector short *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a, + int __b, unsigned short *__c) { + return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned short __a, + int __b, + vector unsigned short *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool short __a, int __b, + vector bool short *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector pixel __a, int __b, + vector pixel *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b, + int *__c) { + return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector int __a, int __b, + vector int *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b, + unsigned int *__c) { + return vec_stl(vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector unsigned int __a, int __b, + vector unsigned int *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector bool int __a, int __b, + vector bool int *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvlxl(vector float __a, int __b, + vector float *__c) { + return vec_stl( + vec_perm(vec_lvrx(__b, __c), __a, vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +/* vec_stvrx */ + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b, + signed char *__c) { + return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector signed char __a, int __b, + vector signed char *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b, + unsigned char *__c) { + return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned char __a, int __b, + vector unsigned char *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool char __a, int __b, + vector bool char *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b, + short *__c) { + return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector short __a, int __b, + vector short *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a, + int __b, unsigned short *__c) { + return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned short __a, + int __b, + vector unsigned short *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool short __a, int __b, + vector bool short *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector pixel __a, int __b, + vector pixel *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b, + int *__c) { + return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector int __a, int __b, + vector int *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b, + unsigned int *__c) { + return vec_st(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector unsigned int __a, int __b, + vector unsigned int *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector bool int __a, int __b, + vector bool int *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrx(vector float __a, int __b, + vector float *__c) { + return vec_st( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +/* vec_stvrxl */ + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b, + signed char *__c) { + return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector signed char __a, int __b, + vector signed char *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a, + int __b, unsigned char *__c) { + return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned char __a, + int __b, + vector unsigned char *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool char __a, int __b, + vector bool char *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b, + short *__c) { + return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector short __a, int __b, + vector short *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a, + int __b, unsigned short *__c) { + return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned short __a, + int __b, + vector unsigned short *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool short __a, int __b, + vector bool short *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector pixel __a, int __b, + vector pixel *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b, + int *__c) { + return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector int __a, int __b, + vector int *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b, + unsigned int *__c) { + return vec_stl(vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, __c)), __b, + __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector unsigned int __a, int __b, + vector unsigned int *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector bool int __a, int __b, + vector bool int *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +static __inline__ void __ATTRS_o_ai vec_stvrxl(vector float __a, int __b, + vector float *__c) { + return vec_stl( + vec_perm(__a, vec_lvlx(__b, __c), vec_lvsr(__b, (unsigned char *)__c)), + __b, __c); +} + +/* vec_promote */ + +static __inline__ vector signed char __ATTRS_o_ai vec_promote(signed char __a, + int __b) { + const vector signed char __zero = (vector signed char)0; + vector signed char __res = + __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1); + __res[__b & 0xf] = __a; + return __res; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_promote(unsigned char __a, int __b) { + const vector unsigned char __zero = (vector unsigned char)(0); + vector unsigned char __res = + __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1); + __res[__b & 0xf] = __a; + return __res; +} + +static __inline__ vector short __ATTRS_o_ai vec_promote(short __a, int __b) { + const vector short __zero = (vector short)(0); + vector short __res = + __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1, -1, -1, -1, -1); + __res[__b & 0x7] = __a; + return __res; +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_promote(unsigned short __a, int __b) { + const vector unsigned short __zero = (vector unsigned short)(0); + vector unsigned short __res = + __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1, -1, -1, -1, -1); + __res[__b & 0x7] = __a; + return __res; +} + +static __inline__ vector int __ATTRS_o_ai vec_promote(int __a, int __b) { + const vector int __zero = (vector int)(0); + vector int __res = __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1); + __res[__b & 0x3] = __a; + return __res; +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_promote(unsigned int __a, + int __b) { + const vector unsigned int __zero = (vector unsigned int)(0); + vector unsigned int __res = + __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1); + __res[__b & 0x3] = __a; + return __res; +} + +static __inline__ vector float __ATTRS_o_ai vec_promote(float __a, int __b) { + const vector float __zero = (vector float)(0); + vector float __res = __builtin_shufflevector(__zero, __zero, -1, -1, -1, -1); + __res[__b & 0x3] = __a; + return __res; +} + +#ifdef __VSX__ +static __inline__ vector double __ATTRS_o_ai vec_promote(double __a, int __b) { + const vector double __zero = (vector double)(0); + vector double __res = __builtin_shufflevector(__zero, __zero, -1, -1); + __res[__b & 0x1] = __a; + return __res; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_promote(signed long long __a, int __b) { + const vector signed long long __zero = (vector signed long long)(0); + vector signed long long __res = + __builtin_shufflevector(__zero, __zero, -1, -1); + __res[__b & 0x1] = __a; + return __res; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_promote(unsigned long long __a, int __b) { + const vector unsigned long long __zero = (vector unsigned long long)(0); + vector unsigned long long __res = + __builtin_shufflevector(__zero, __zero, -1, -1); + __res[__b & 0x1] = __a; + return __res; +} +#endif + +/* vec_splats */ + +static __inline__ vector signed char __ATTRS_o_ai vec_splats(signed char __a) { + return (vector signed char)(__a); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_splats(unsigned char __a) { + return (vector unsigned char)(__a); +} + +static __inline__ vector short __ATTRS_o_ai vec_splats(short __a) { + return (vector short)(__a); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_splats(unsigned short __a) { + return (vector unsigned short)(__a); +} + +static __inline__ vector int __ATTRS_o_ai vec_splats(int __a) { + return (vector int)(__a); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_splats(unsigned int __a) { + return (vector unsigned int)(__a); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_splats(signed long long __a) { + return (vector signed long long)(__a); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_splats(unsigned long long __a) { + return (vector unsigned long long)(__a); +} + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_splats(signed __int128 __a) { + return (vector signed __int128)(__a); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_splats(unsigned __int128 __a) { + return (vector unsigned __int128)(__a); +} + +#endif + +static __inline__ vector double __ATTRS_o_ai vec_splats(double __a) { + return (vector double)(__a); +} +#endif + +static __inline__ vector float __ATTRS_o_ai vec_splats(float __a) { + return (vector float)(__a); +} + +/* ----------------------------- predicates --------------------------------- */ + +/* vec_all_eq */ + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector pixel __a, + vector pixel __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a, vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)__a, + (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed long long __a, + vector signed long long __b) { +#ifdef __POWER8_VECTOR__ + return __builtin_altivec_vcmpequd_p(__CR6_LT, __a, __b); +#else + // No vcmpequd on Power7 so we xor the two vectors and compare against zero as + // 32-bit elements. + return vec_all_eq((vector signed int)vec_xor(__a, __b), (vector signed int)0); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector long long __a, + vector bool long long __b) { + return vec_all_eq((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a, + vector unsigned long long __b) { + return vec_all_eq((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned long long __a, + vector bool long long __b) { + return vec_all_eq((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a, + vector long long __b) { + return vec_all_eq((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a, + vector unsigned long long __b) { + return vec_all_eq((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool long long __a, + vector bool long long __b) { + return vec_all_eq((vector signed long long)__a, (vector signed long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __b); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_eq(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_all_eq(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_LT, (vector unsigned __int128)__a, + (vector signed __int128)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, + (vector signed __int128)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool __int128 __a, + vector bool __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_LT, (vector unsigned __int128)__a, + (vector signed __int128)__b); +} +#endif + +/* vec_all_ge */ + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __b, (vector signed char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __b, (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b, + (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector short)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __b, (vector signed short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector int)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __b, (vector signed int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __b, (vector unsigned int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__b, + (vector unsigned int)__a); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, __a); +} +static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __b, + (vector signed long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __b, + (vector unsigned long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b, + (vector unsigned long long)__a); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __a, __b); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_LT, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_ge(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_all_ge(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_EQ, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_ge(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_EQ, __b, __a); +} +#endif + +/* vec_all_gt */ + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __a, (vector signed char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, __a, (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a, + (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __a, (vector unsigned int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector signed int)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__a, + (vector unsigned int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a, __b); +} +static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, __a, + (vector unsigned long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__a, + (vector unsigned long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __a, __b); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_gt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_all_gt(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_LT, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_gt(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_LT, __a, __b); +} +#endif + +/* vec_all_in */ + +static __inline__ int __attribute__((__always_inline__)) +vec_all_in(vector float __a, vector float __b) { + return __builtin_altivec_vcmpbfp_p(__CR6_EQ, __a, __b); +} + +/* vec_all_le */ + +static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, __a, (vector signed char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, __a, (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__a, + (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, __a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector signed short)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, (vector unsigned short)__a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, __a, (vector unsigned int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector signed int)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, (vector unsigned int)__a, + (vector unsigned int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, __a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, __a, + (vector unsigned long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__a, + (vector unsigned long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_all_le(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_LT, __b, __a); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_LT, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_le(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_LT, __b, __a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_all_le(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_le(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_EQ, __a, __b); +} +#endif + +/* vec_all_lt */ + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT, __b, (vector signed char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, __b, (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__b, + (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector short)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT, __b, (vector signed short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, __b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT, (vector unsigned short)__b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, (vector int)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT, __b, (vector signed int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, __b, (vector unsigned int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT, (vector unsigned int)__b, + (vector unsigned int)__a); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT, (vector signed long long)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT, __b, + (vector signed long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, __b, + (vector unsigned long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT, (vector unsigned long long)__b, + (vector unsigned long long)__a); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_LT, __b, __a); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_LT, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_lt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_LT, __b, __a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_all_lt(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_LT, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_all_lt(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_LT, __b, __a); +} +#endif + +/* vec_all_nan */ + +static __inline__ int __ATTRS_o_ai vec_all_nan(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __a); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_nan(vector double __a) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __a); +} +#endif + +/* vec_all_ne */ + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector pixel __a, + vector pixel __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a, vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)__a, + (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector long long)__a, + (vector long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, __a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ, (vector signed long long)__a, + (vector signed long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ, __a, __b); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_ne(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_all_ne(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_EQ, (vector unsigned __int128)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, + (vector signed __int128)__b); +} + +static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool __int128 __a, + vector bool __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_EQ, (vector unsigned __int128)__a, + (vector signed __int128)__b); +} +#endif + +/* vec_all_nge */ + +static __inline__ int __ATTRS_o_ai vec_all_nge(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __a, __b); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_nge(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __a, __b); +} +#endif + +/* vec_all_ngt */ + +static __inline__ int __ATTRS_o_ai vec_all_ngt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __a, __b); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_ngt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __a, __b); +} +#endif + +/* vec_all_nle */ + +static __inline__ int __ATTRS_o_ai +vec_all_nle(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_EQ, __b, __a); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_EQ, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_nle(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_EQ, __b, __a); +} +#endif + +/* vec_all_nlt */ + +static __inline__ int __ATTRS_o_ai +vec_all_nlt(vector float __a, vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ, __b, __a); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_nlt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ, __b, __a); +} +#endif + +/* vec_all_numeric */ + +static __inline__ int __ATTRS_o_ai +vec_all_numeric(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_LT, __a, __a); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_LT, __a, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_all_numeric(vector double __a) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_LT, __a, __a); +} +#endif + +/* vec_any_eq */ + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector pixel __a, + vector pixel __b) { + return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a, vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)__a, + (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, (vector long long)__a, + (vector long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpequd_p(__CR6_EQ_REV, __a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpequd_p( + __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpequd_p( + __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpequd_p( + __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpequd_p( + __CR6_EQ_REV, (vector signed long long)__a, (vector signed long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __b); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_eq(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_any_eq(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, + (vector unsigned __int128)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, + (vector signed __int128)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool __int128 __a, + vector bool __int128 __b) { + return __builtin_altivec_vcmpequq_p( + __CR6_EQ_REV, (vector unsigned __int128)__a, (vector signed __int128)__b); +} +#endif + +/* vec_any_ge */ + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __b, + (vector signed char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __b, + (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__b, + (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector short)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __b, + (vector signed short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector int)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __b, + (vector signed int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __b, + (vector unsigned int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__b, + (vector unsigned int)__a); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, + (vector signed long long)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, + (vector unsigned long long)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __b, + (vector signed long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __b, + (vector unsigned long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, + (vector unsigned long long)__b, + (vector unsigned long long)__a); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __a, __b); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_ge(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_any_ge(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_LT_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_ge(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_LT_REV, __b, __a); +} +#endif + +/* vec_any_gt */ + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __a, + (vector signed char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __a, + (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__a, + (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector signed short)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __a, + (vector unsigned int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector signed int)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__a, + (vector unsigned int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __a, + (vector unsigned long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, + (vector signed long long)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, + (vector unsigned long long)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, + (vector unsigned long long)__a, + (vector unsigned long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __a, __b); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_gt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_any_gt(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_EQ_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_gt(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_EQ_REV, __a, __b); +} +#endif + +/* vec_any_le */ + +static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, __a, + (vector signed char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, __a, + (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, (vector signed char)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, (vector unsigned char)__a, + (vector unsigned char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, __a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, (vector signed short)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, (vector unsigned short)__a, + (vector unsigned short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, __a, + (vector unsigned int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, (vector signed int)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a, + __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, (vector unsigned int)__a, + (vector unsigned int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, __a, + (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, __a, + (vector unsigned long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_LT_REV, + (vector signed long long)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, + (vector unsigned long long)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_LT_REV, + (vector unsigned long long)__a, + (vector unsigned long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_any_le(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_EQ_REV, __b, __a); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_EQ_REV, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_le(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_EQ_REV, __b, __a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_any_le(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_le(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_LT_REV, __a, __b); +} +#endif + +/* vec_any_lt */ + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, (vector signed char)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, __b, + (vector signed char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, __b, + (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, (vector unsigned char)__b, + (vector unsigned char)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, (vector short)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, __b, + (vector signed short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, __b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, (vector unsigned short)__b, + (vector unsigned short)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a, vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, (vector int)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b, + __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, __b, + (vector signed int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, __b, + (vector unsigned int)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, (vector unsigned int)__b, + (vector unsigned int)__a); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, + (vector signed long long)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, + (vector unsigned long long)__b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a, + vector signed long long __b) { + return __builtin_altivec_vcmpgtsd_p(__CR6_EQ_REV, __b, + (vector signed long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a, + vector unsigned long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, __b, + (vector unsigned long long)__a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector bool long long __a, + vector bool long long __b) { + return __builtin_altivec_vcmpgtud_p(__CR6_EQ_REV, + (vector unsigned long long)__b, + (vector unsigned long long)__a); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_EQ_REV, __b, __a); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_lt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_EQ_REV, __b, __a); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_any_lt(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpgtsq_p(__CR6_EQ_REV, __b, __a); +} + +static __inline__ int __ATTRS_o_ai vec_any_lt(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpgtuq_p(__CR6_EQ_REV, __b, __a); +} +#endif + +/* vec_any_nan */ + +static __inline__ int __ATTRS_o_ai vec_any_nan(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __a); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __a); +#endif +} +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_nan(vector double __a) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __a); +} +#endif + +/* vec_any_ne */ + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a, + vector signed char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a, + vector unsigned char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool char __a, + vector bool char __b) { + return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)__a, + (vector char)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, __a, (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a, + vector short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a, + vector unsigned short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool short __a, + vector bool short __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector pixel __a, + vector pixel __b) { + return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)__a, + (vector short)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a, vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, __a, (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a, + vector int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a, + vector unsigned int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a, + (vector int)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool int __a, + vector bool int __b) { + return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)__a, + (vector int)__b); +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a, + vector signed long long __b) { +#ifdef __POWER8_VECTOR__ + return __builtin_altivec_vcmpequd_p(__CR6_LT_REV, __a, __b); +#else + // Take advantage of the optimized sequence for vec_all_eq when vcmpequd is + // not available. + return !vec_all_eq(__a, __b); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a, + vector unsigned long long __b) { + return vec_any_ne((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed long long __a, + vector bool long long __b) { + return vec_any_ne((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned long long __a, + vector bool long long __b) { + return vec_any_ne((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a, + vector signed long long __b) { + return vec_any_ne((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a, + vector unsigned long long __b) { + return vec_any_ne((vector signed long long)__a, (vector signed long long)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool long long __a, + vector bool long long __b) { + return vec_any_ne((vector signed long long)__a, (vector signed long long)__b); +} +#endif + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_LT_REV, __a, __b); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_ne(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_LT_REV, __a, __b); +} +#endif + +#if defined(__POWER10_VECTOR__) && defined(__SIZEOF_INT128__) +static __inline__ int __ATTRS_o_ai vec_any_ne(vector signed __int128 __a, + vector signed __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, + (vector unsigned __int128)__a, __b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned __int128 __a, + vector unsigned __int128 __b) { + return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, + (vector signed __int128)__b); +} + +static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool __int128 __a, + vector bool __int128 __b) { + return __builtin_altivec_vcmpequq_p( + __CR6_LT_REV, (vector unsigned __int128)__a, (vector signed __int128)__b); +} +#endif + +/* vec_any_nge */ + +static __inline__ int __ATTRS_o_ai vec_any_nge(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __a, __b); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_nge(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __a, __b); +} +#endif + +/* vec_any_ngt */ + +static __inline__ int __ATTRS_o_ai vec_any_ngt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __a, __b); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __a, __b); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_ngt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __a, __b); +} +#endif + +/* vec_any_nle */ + +static __inline__ int __ATTRS_o_ai vec_any_nle(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgesp_p(__CR6_LT_REV, __b, __a); +#else + return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_nle(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgedp_p(__CR6_LT_REV, __b, __a); +} +#endif + +/* vec_any_nlt */ + +static __inline__ int __ATTRS_o_ai vec_any_nlt(vector float __a, + vector float __b) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpgtsp_p(__CR6_LT_REV, __b, __a); +#else + return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, __b, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_nlt(vector double __a, + vector double __b) { + return __builtin_vsx_xvcmpgtdp_p(__CR6_LT_REV, __b, __a); +} +#endif + +/* vec_any_numeric */ + +static __inline__ int __ATTRS_o_ai vec_any_numeric(vector float __a) { +#ifdef __VSX__ + return __builtin_vsx_xvcmpeqsp_p(__CR6_EQ_REV, __a, __a); +#else + return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, __a, __a); +#endif +} + +#ifdef __VSX__ +static __inline__ int __ATTRS_o_ai vec_any_numeric(vector double __a) { + return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ_REV, __a, __a); +} +#endif + +/* vec_any_out */ + +static __inline__ int __attribute__((__always_inline__)) +vec_any_out(vector float __a, vector float __b) { + return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, __a, __b); +} + +/* Power 8 Crypto functions +Note: We diverge from the current GCC implementation with regard +to cryptography and related functions as follows: +- Only the SHA and AES instructions and builtins are disabled by -mno-crypto +- The remaining ones are only available on Power8 and up so + require -mpower8-vector +The justification for this is that export requirements require that +Category:Vector.Crypto is optional (i.e. compliant hardware may not provide +support). As a result, we need to be able to turn off support for those. +The remaining ones (currently controlled by -mcrypto for GCC) still +need to be provided on compliant hardware even if Vector.Crypto is not +provided. +*/ +#ifdef __CRYPTO__ +#define vec_sbox_be __builtin_altivec_crypto_vsbox +#define vec_cipher_be __builtin_altivec_crypto_vcipher +#define vec_cipherlast_be __builtin_altivec_crypto_vcipherlast +#define vec_ncipher_be __builtin_altivec_crypto_vncipher +#define vec_ncipherlast_be __builtin_altivec_crypto_vncipherlast + +#ifdef __VSX__ +static __inline__ vector unsigned char __attribute__((__always_inline__)) +__builtin_crypto_vsbox(vector unsigned char __a) { + return __builtin_altivec_crypto_vsbox(__a); +} + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +__builtin_crypto_vcipher(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_crypto_vcipher(__a, __b); +} + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +__builtin_crypto_vcipherlast(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_crypto_vcipherlast(__a, __b); +} + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +__builtin_crypto_vncipher(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_crypto_vncipher(__a, __b); +} + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +__builtin_crypto_vncipherlast(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_altivec_crypto_vncipherlast(__a, __b); +} +#endif /* __VSX__ */ + +#define __builtin_crypto_vshasigmad __builtin_altivec_crypto_vshasigmad +#define __builtin_crypto_vshasigmaw __builtin_altivec_crypto_vshasigmaw + +#define vec_shasigma_be(X, Y, Z) \ + _Generic((X), vector unsigned int \ + : __builtin_crypto_vshasigmaw, vector unsigned long long \ + : __builtin_crypto_vshasigmad)((X), (Y), (Z)) +#endif + +#ifdef __POWER8_VECTOR__ +static __inline__ vector bool char __ATTRS_o_ai +vec_permxor(vector bool char __a, vector bool char __b, + vector bool char __c) { + return (vector bool char)__builtin_altivec_crypto_vpermxor( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_permxor(vector signed char __a, vector signed char __b, + vector signed char __c) { + return (vector signed char)__builtin_altivec_crypto_vpermxor( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_permxor(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return __builtin_altivec_crypto_vpermxor(__a, __b, __c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +__builtin_crypto_vpermxor(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return __builtin_altivec_crypto_vpermxor(__a, __b, __c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +__builtin_crypto_vpermxor(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return (vector unsigned short)__builtin_altivec_crypto_vpermxor( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai __builtin_crypto_vpermxor( + vector unsigned int __a, vector unsigned int __b, vector unsigned int __c) { + return (vector unsigned int)__builtin_altivec_crypto_vpermxor( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +__builtin_crypto_vpermxor(vector unsigned long long __a, + vector unsigned long long __b, + vector unsigned long long __c) { + return (vector unsigned long long)__builtin_altivec_crypto_vpermxor( + (vector unsigned char)__a, (vector unsigned char)__b, + (vector unsigned char)__c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +__builtin_crypto_vpmsumb(vector unsigned char __a, vector unsigned char __b) { + return __builtin_altivec_crypto_vpmsumb(__a, __b); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +__builtin_crypto_vpmsumb(vector unsigned short __a, vector unsigned short __b) { + return __builtin_altivec_crypto_vpmsumh(__a, __b); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +__builtin_crypto_vpmsumb(vector unsigned int __a, vector unsigned int __b) { + return __builtin_altivec_crypto_vpmsumw(__a, __b); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +__builtin_crypto_vpmsumb(vector unsigned long long __a, + vector unsigned long long __b) { + return __builtin_altivec_crypto_vpmsumd(__a, __b); +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_vgbbd(vector signed char __a) { + return (vector signed char)__builtin_altivec_vgbbd((vector unsigned char)__a); +} + +#define vec_pmsum_be __builtin_crypto_vpmsumb +#define vec_gb __builtin_altivec_vgbbd + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_vgbbd(vector unsigned char __a) { + return __builtin_altivec_vgbbd(__a); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_gbb(vector signed long long __a) { + return (vector signed long long)__builtin_altivec_vgbbd( + (vector unsigned char)__a); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_gbb(vector unsigned long long __a) { + return (vector unsigned long long)__builtin_altivec_vgbbd( + (vector unsigned char)__a); +} + +static __inline__ vector long long __ATTRS_o_ai +vec_vbpermq(vector signed char __a, vector signed char __b) { + return (vector long long)__builtin_altivec_vbpermq((vector unsigned char)__a, + (vector unsigned char)__b); +} + +static __inline__ vector long long __ATTRS_o_ai +vec_vbpermq(vector unsigned char __a, vector unsigned char __b) { + return (vector long long)__builtin_altivec_vbpermq(__a, __b); +} + +#if defined(__powerpc64__) && defined(__SIZEOF_INT128__) +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_bperm(vector unsigned __int128 __a, vector unsigned char __b) { + return __builtin_altivec_vbpermq((vector unsigned char)__a, + (vector unsigned char)__b); +} +#endif +static __inline__ vector unsigned char __ATTRS_o_ai +vec_bperm(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vbpermq(__a, __b); +} +#endif // __POWER8_VECTOR__ +#ifdef __POWER9_VECTOR__ +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_bperm(vector unsigned long long __a, vector unsigned char __b) { + return __builtin_altivec_vbpermd(__a, __b); +} +#endif + + +/* vec_reve */ + +static __inline__ __ATTRS_o_ai vector bool char vec_reve(vector bool char __a) { + return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, + 5, 4, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector signed char +vec_reve(vector signed char __a) { + return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, + 5, 4, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector unsigned char +vec_reve(vector unsigned char __a) { + return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, + 5, 4, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector bool int vec_reve(vector bool int __a) { + return __builtin_shufflevector(__a, __a, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector signed int +vec_reve(vector signed int __a) { + return __builtin_shufflevector(__a, __a, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector unsigned int +vec_reve(vector unsigned int __a) { + return __builtin_shufflevector(__a, __a, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector bool short +vec_reve(vector bool short __a) { + return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector signed short +vec_reve(vector signed short __a) { + return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector unsigned short +vec_reve(vector unsigned short __a) { + return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector float vec_reve(vector float __a) { + return __builtin_shufflevector(__a, __a, 3, 2, 1, 0); +} + +#ifdef __VSX__ +static __inline__ __ATTRS_o_ai vector bool long long +vec_reve(vector bool long long __a) { + return __builtin_shufflevector(__a, __a, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector signed long long +vec_reve(vector signed long long __a) { + return __builtin_shufflevector(__a, __a, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector unsigned long long +vec_reve(vector unsigned long long __a) { + return __builtin_shufflevector(__a, __a, 1, 0); +} + +static __inline__ __ATTRS_o_ai vector double vec_reve(vector double __a) { + return __builtin_shufflevector(__a, __a, 1, 0); +} +#endif + +/* vec_revb */ +static __inline__ vector bool char __ATTRS_o_ai +vec_revb(vector bool char __a) { + return __a; +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_revb(vector signed char __a) { + return __a; +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_revb(vector unsigned char __a) { + return __a; +} + +static __inline__ vector bool short __ATTRS_o_ai +vec_revb(vector bool short __a) { + vector unsigned char __indices = + { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_revb(vector signed short __a) { + vector unsigned char __indices = + { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_revb(vector unsigned short __a) { + vector unsigned char __indices = + { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector bool int __ATTRS_o_ai +vec_revb(vector bool int __a) { + vector unsigned char __indices = + { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_revb(vector signed int __a) { + vector unsigned char __indices = + { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_revb(vector unsigned int __a) { + vector unsigned char __indices = + { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector float __ATTRS_o_ai +vec_revb(vector float __a) { + vector unsigned char __indices = + { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }; + return vec_perm(__a, __a, __indices); +} + +#ifdef __VSX__ +static __inline__ vector bool long long __ATTRS_o_ai +vec_revb(vector bool long long __a) { + vector unsigned char __indices = + { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_revb(vector signed long long __a) { + vector unsigned char __indices = + { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_revb(vector unsigned long long __a) { + vector unsigned char __indices = + { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }; + return vec_perm(__a, __a, __indices); +} + +static __inline__ vector double __ATTRS_o_ai +vec_revb(vector double __a) { + vector unsigned char __indices = + { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }; + return vec_perm(__a, __a, __indices); +} +#endif /* End __VSX__ */ + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_revb(vector signed __int128 __a) { + vector unsigned char __indices = + { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + return (vector signed __int128)vec_perm((vector signed int)__a, + (vector signed int)__a, + __indices); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_revb(vector unsigned __int128 __a) { + vector unsigned char __indices = + { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; + return (vector unsigned __int128)vec_perm((vector signed int)__a, + (vector signed int)__a, + __indices); +} +#endif /* END __POWER8_VECTOR__ && __powerpc64__ */ + +/* vec_xl */ + +#define vec_xld2 vec_xl +#define vec_xlw4 vec_xl +typedef vector signed char unaligned_vec_schar __attribute__((aligned(1))); +typedef vector unsigned char unaligned_vec_uchar __attribute__((aligned(1))); +typedef vector signed short unaligned_vec_sshort __attribute__((aligned(1))); +typedef vector unsigned short unaligned_vec_ushort __attribute__((aligned(1))); +typedef vector signed int unaligned_vec_sint __attribute__((aligned(1))); +typedef vector unsigned int unaligned_vec_uint __attribute__((aligned(1))); +typedef vector float unaligned_vec_float __attribute__((aligned(1))); + +static __inline__ __ATTRS_o_ai vector signed char +vec_xl(ptrdiff_t __offset, const signed char *__ptr) { + return *(unaligned_vec_schar *)(__ptr + __offset); +} + +static __inline__ __ATTRS_o_ai vector unsigned char +vec_xl(ptrdiff_t __offset, const unsigned char *__ptr) { + return *(unaligned_vec_uchar*)(__ptr + __offset); +} + +static __inline__ __ATTRS_o_ai vector signed short +vec_xl(ptrdiff_t __offset, const signed short *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_sshort *)__addr; +} + +static __inline__ __ATTRS_o_ai vector unsigned short +vec_xl(ptrdiff_t __offset, const unsigned short *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_ushort *)__addr; +} + +static __inline__ __ATTRS_o_ai vector signed int +vec_xl(ptrdiff_t __offset, const signed int *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_sint *)__addr; +} + +static __inline__ __ATTRS_o_ai vector unsigned int +vec_xl(ptrdiff_t __offset, const unsigned int *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_uint *)__addr; +} + +static __inline__ __ATTRS_o_ai vector float vec_xl(ptrdiff_t __offset, + const float *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_float *)__addr; +} + +#ifdef __VSX__ +typedef vector signed long long unaligned_vec_sll __attribute__((aligned(1))); +typedef vector unsigned long long unaligned_vec_ull __attribute__((aligned(1))); +typedef vector double unaligned_vec_double __attribute__((aligned(1))); + +static __inline__ __ATTRS_o_ai vector signed long long +vec_xl(ptrdiff_t __offset, const signed long long *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_sll *)__addr; +} + +static __inline__ __ATTRS_o_ai vector unsigned long long +vec_xl(ptrdiff_t __offset, const unsigned long long *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_ull *)__addr; +} + +static __inline__ __ATTRS_o_ai vector double vec_xl(ptrdiff_t __offset, + const double *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_double *)__addr; +} +#endif + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +typedef vector signed __int128 unaligned_vec_si128 __attribute__((aligned(1))); +typedef vector unsigned __int128 unaligned_vec_ui128 + __attribute__((aligned(1))); +static __inline__ __ATTRS_o_ai vector signed __int128 +vec_xl(ptrdiff_t __offset, const signed __int128 *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_si128 *)__addr; +} + +static __inline__ __ATTRS_o_ai vector unsigned __int128 +vec_xl(ptrdiff_t __offset, const unsigned __int128 *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + return *(unaligned_vec_ui128 *)__addr; +} +#endif + +/* vec_xl_be */ + +#ifdef __LITTLE_ENDIAN__ +static __inline__ vector signed char __ATTRS_o_ai +vec_xl_be(ptrdiff_t __offset, const signed char *__ptr) { + vector signed char __vec = (vector signed char)__builtin_vsx_lxvd2x_be(__offset, __ptr); + return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, + 13, 12, 11, 10, 9, 8); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xl_be(ptrdiff_t __offset, const unsigned char *__ptr) { + vector unsigned char __vec = (vector unsigned char)__builtin_vsx_lxvd2x_be(__offset, __ptr); + return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, + 13, 12, 11, 10, 9, 8); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_xl_be(ptrdiff_t __offset, const signed short *__ptr) { + vector signed short __vec = (vector signed short)__builtin_vsx_lxvd2x_be(__offset, __ptr); + return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_xl_be(ptrdiff_t __offset, const unsigned short *__ptr) { + vector unsigned short __vec = (vector unsigned short)__builtin_vsx_lxvd2x_be(__offset, __ptr); + return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_xl_be(signed long long __offset, const signed int *__ptr) { + return (vector signed int)__builtin_vsx_lxvw4x_be(__offset, __ptr); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_xl_be(signed long long __offset, const unsigned int *__ptr) { + return (vector unsigned int)__builtin_vsx_lxvw4x_be(__offset, __ptr); +} + +static __inline__ vector float __ATTRS_o_ai +vec_xl_be(signed long long __offset, const float *__ptr) { + return (vector float)__builtin_vsx_lxvw4x_be(__offset, __ptr); +} + +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_xl_be(signed long long __offset, const signed long long *__ptr) { + return (vector signed long long)__builtin_vsx_lxvd2x_be(__offset, __ptr); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_xl_be(signed long long __offset, const unsigned long long *__ptr) { + return (vector unsigned long long)__builtin_vsx_lxvd2x_be(__offset, __ptr); +} + +static __inline__ vector double __ATTRS_o_ai +vec_xl_be(signed long long __offset, const double *__ptr) { + return (vector double)__builtin_vsx_lxvd2x_be(__offset, __ptr); +} +#endif + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_xl_be(signed long long __offset, const signed __int128 *__ptr) { + return vec_xl(__offset, __ptr); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_xl_be(signed long long __offset, const unsigned __int128 *__ptr) { + return vec_xl(__offset, __ptr); +} +#endif +#else + #define vec_xl_be vec_xl +#endif + +#if defined(__POWER10_VECTOR__) && defined(__VSX__) && \ + defined(__SIZEOF_INT128__) + +/* vec_xl_sext */ + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_xl_sext(ptrdiff_t __offset, const signed char *__pointer) { + return (vector signed __int128)*(__pointer + __offset); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_xl_sext(ptrdiff_t __offset, const signed short *__pointer) { + return (vector signed __int128)*(__pointer + __offset); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_xl_sext(ptrdiff_t __offset, const signed int *__pointer) { + return (vector signed __int128)*(__pointer + __offset); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_xl_sext(ptrdiff_t __offset, const signed long long *__pointer) { + return (vector signed __int128)*(__pointer + __offset); +} + +/* vec_xl_zext */ + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_xl_zext(ptrdiff_t __offset, const unsigned char *__pointer) { + return (vector unsigned __int128)*(__pointer + __offset); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_xl_zext(ptrdiff_t __offset, const unsigned short *__pointer) { + return (vector unsigned __int128)*(__pointer + __offset); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_xl_zext(ptrdiff_t __offset, const unsigned int *__pointer) { + return (vector unsigned __int128)*(__pointer + __offset); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_xl_zext(ptrdiff_t __offset, const unsigned long long *__pointer) { + return (vector unsigned __int128)*(__pointer + __offset); +} + +#endif + +/* vec_xlds */ +#ifdef __VSX__ +static __inline__ vector signed long long __ATTRS_o_ai +vec_xlds(ptrdiff_t __offset, const signed long long *__ptr) { + signed long long *__addr = (signed long long*)((signed char *)__ptr + __offset); + return (vector signed long long) *__addr; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_xlds(ptrdiff_t __offset, const unsigned long long *__ptr) { + unsigned long long *__addr = (unsigned long long *)((signed char *)__ptr + __offset); + return (unaligned_vec_ull) *__addr; +} + +static __inline__ vector double __ATTRS_o_ai vec_xlds(ptrdiff_t __offset, + const double *__ptr) { + double *__addr = (double*)((signed char *)__ptr + __offset); + return (unaligned_vec_double) *__addr; +} + +/* vec_load_splats */ +static __inline__ vector signed int __ATTRS_o_ai +vec_load_splats(signed long long __offset, const signed int *__ptr) { + signed int *__addr = (signed int*)((signed char *)__ptr + __offset); + return (vector signed int)*__addr; +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_load_splats(unsigned long long __offset, const signed int *__ptr) { + signed int *__addr = (signed int*)((signed char *)__ptr + __offset); + return (vector signed int)*__addr; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_load_splats(signed long long __offset, const unsigned int *__ptr) { + unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset); + return (vector unsigned int)*__addr; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_load_splats(unsigned long long __offset, const unsigned int *__ptr) { + unsigned int *__addr = (unsigned int*)((signed char *)__ptr + __offset); + return (vector unsigned int)*__addr; +} + +static __inline__ vector float __ATTRS_o_ai +vec_load_splats(signed long long __offset, const float *__ptr) { + float *__addr = (float*)((signed char *)__ptr + __offset); + return (vector float)*__addr; +} + +static __inline__ vector float __ATTRS_o_ai +vec_load_splats(unsigned long long __offset, const float *__ptr) { + float *__addr = (float*)((signed char *)__ptr + __offset); + return (vector float)*__addr; +} +#endif + +/* vec_xst */ + +#define vec_xstd2 vec_xst +#define vec_xstw4 vec_xst +static __inline__ __ATTRS_o_ai void +vec_xst(vector signed char __vec, ptrdiff_t __offset, signed char *__ptr) { + *(unaligned_vec_schar *)(__ptr + __offset) = __vec; +} + +static __inline__ __ATTRS_o_ai void +vec_xst(vector unsigned char __vec, ptrdiff_t __offset, unsigned char *__ptr) { + *(unaligned_vec_uchar *)(__ptr + __offset) = __vec; +} + +static __inline__ __ATTRS_o_ai void +vec_xst(vector signed short __vec, ptrdiff_t __offset, signed short *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_sshort *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned short __vec, + ptrdiff_t __offset, + unsigned short *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_ushort *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void +vec_xst(vector signed int __vec, ptrdiff_t __offset, signed int *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_sint *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void +vec_xst(vector unsigned int __vec, ptrdiff_t __offset, unsigned int *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_uint *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void vec_xst(vector float __vec, + ptrdiff_t __offset, float *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_float *)__addr = __vec; +} + +#ifdef __VSX__ +static __inline__ __ATTRS_o_ai void vec_xst(vector signed long long __vec, + ptrdiff_t __offset, + signed long long *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_sll *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned long long __vec, + ptrdiff_t __offset, + unsigned long long *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_ull *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void vec_xst(vector double __vec, + ptrdiff_t __offset, double *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_double *)__addr = __vec; +} +#endif + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +static __inline__ __ATTRS_o_ai void vec_xst(vector signed __int128 __vec, + ptrdiff_t __offset, + signed __int128 *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_si128 *)__addr = __vec; +} + +static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec, + ptrdiff_t __offset, + unsigned __int128 *__ptr) { + signed char *__addr = (signed char *)__ptr + __offset; + *(unaligned_vec_ui128 *)__addr = __vec; +} +#endif + +/* vec_xst_trunc */ + +#if defined(__POWER10_VECTOR__) && defined(__VSX__) && \ + defined(__SIZEOF_INT128__) +static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec, + ptrdiff_t __offset, + signed char *__ptr) { + *(__ptr + __offset) = (signed char)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void +vec_xst_trunc(vector unsigned __int128 __vec, ptrdiff_t __offset, + unsigned char *__ptr) { + *(__ptr + __offset) = (unsigned char)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec, + ptrdiff_t __offset, + signed short *__ptr) { + *(__ptr + __offset) = (signed short)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void +vec_xst_trunc(vector unsigned __int128 __vec, ptrdiff_t __offset, + unsigned short *__ptr) { + *(__ptr + __offset) = (unsigned short)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec, + ptrdiff_t __offset, + signed int *__ptr) { + *(__ptr + __offset) = (signed int)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void +vec_xst_trunc(vector unsigned __int128 __vec, ptrdiff_t __offset, + unsigned int *__ptr) { + *(__ptr + __offset) = (unsigned int)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec, + ptrdiff_t __offset, + signed long long *__ptr) { + *(__ptr + __offset) = (signed long long)__vec[0]; +} + +static __inline__ __ATTRS_o_ai void +vec_xst_trunc(vector unsigned __int128 __vec, ptrdiff_t __offset, + unsigned long long *__ptr) { + *(__ptr + __offset) = (unsigned long long)__vec[0]; +} +#endif + +/* vec_xst_be */ + +#ifdef __LITTLE_ENDIAN__ +static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed char __vec, + signed long long __offset, + signed char *__ptr) { + vector signed char __tmp = + __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, + 13, 12, 11, 10, 9, 8); + typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double; + __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned char __vec, + signed long long __offset, + unsigned char *__ptr) { + vector unsigned char __tmp = + __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, + 13, 12, 11, 10, 9, 8); + typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double; + __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed short __vec, + signed long long __offset, + signed short *__ptr) { + vector signed short __tmp = + __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4); + typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double; + __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned short __vec, + signed long long __offset, + unsigned short *__ptr) { + vector unsigned short __tmp = + __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4); + typedef __attribute__((vector_size(sizeof(__tmp)))) double __vector_double; + __builtin_vsx_stxvd2x_be((__vector_double)__tmp, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed int __vec, + signed long long __offset, + signed int *__ptr) { + __builtin_vsx_stxvw4x_be(__vec, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned int __vec, + signed long long __offset, + unsigned int *__ptr) { + __builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector float __vec, + signed long long __offset, + float *__ptr) { + __builtin_vsx_stxvw4x_be((vector int)__vec, __offset, __ptr); +} + +#ifdef __VSX__ +static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed long long __vec, + signed long long __offset, + signed long long *__ptr) { + __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned long long __vec, + signed long long __offset, + unsigned long long *__ptr) { + __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector double __vec, + signed long long __offset, + double *__ptr) { + __builtin_vsx_stxvd2x_be((vector double)__vec, __offset, __ptr); +} +#endif + +#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \ + defined(__SIZEOF_INT128__) +static __inline__ void __ATTRS_o_ai vec_xst_be(vector signed __int128 __vec, + signed long long __offset, + signed __int128 *__ptr) { + vec_xst(__vec, __offset, __ptr); +} + +static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned __int128 __vec, + signed long long __offset, + unsigned __int128 *__ptr) { + vec_xst(__vec, __offset, __ptr); +} +#endif +#else + #define vec_xst_be vec_xst +#endif + +#ifdef __POWER9_VECTOR__ +#define vec_test_data_class(__a, __b) \ + _Generic( \ + (__a), vector float \ + : (vector bool int)__builtin_vsx_xvtstdcsp((vector float)(__a), (__b)), \ + vector double \ + : (vector bool long long)__builtin_vsx_xvtstdcdp((vector double)(__a), \ + (__b))) + +#endif /* #ifdef __POWER9_VECTOR__ */ + +static vector float __ATTRS_o_ai vec_neg(vector float __a) { + return -__a; +} + +#ifdef __VSX__ +static vector double __ATTRS_o_ai vec_neg(vector double __a) { + return -__a; +} + +#endif + +#ifdef __VSX__ +static vector long long __ATTRS_o_ai vec_neg(vector long long __a) { + return -__a; +} +#endif + +static vector signed int __ATTRS_o_ai vec_neg(vector signed int __a) { + return -__a; +} + +static vector signed short __ATTRS_o_ai vec_neg(vector signed short __a) { + return -__a; +} + +static vector signed char __ATTRS_o_ai vec_neg(vector signed char __a) { + return -__a; +} + +static vector float __ATTRS_o_ai vec_nabs(vector float __a) { + return - vec_abs(__a); +} + +#ifdef __VSX__ +static vector double __ATTRS_o_ai vec_nabs(vector double __a) { + return - vec_abs(__a); +} + +#endif + +#ifdef __POWER8_VECTOR__ +static vector long long __ATTRS_o_ai vec_nabs(vector long long __a) { + return __builtin_altivec_vminsd(__a, -__a); +} +#endif + +static vector signed int __ATTRS_o_ai vec_nabs(vector signed int __a) { + return __builtin_altivec_vminsw(__a, -__a); +} + +static vector signed short __ATTRS_o_ai vec_nabs(vector signed short __a) { + return __builtin_altivec_vminsh(__a, -__a); +} + +static vector signed char __ATTRS_o_ai vec_nabs(vector signed char __a) { + return __builtin_altivec_vminsb(__a, -__a); +} + +static vector float __ATTRS_o_ai vec_recipdiv(vector float __a, + vector float __b) { + return __builtin_ppc_recipdivf(__a, __b); +} + +#ifdef __VSX__ +static vector double __ATTRS_o_ai vec_recipdiv(vector double __a, + vector double __b) { + return __builtin_ppc_recipdivd(__a, __b); +} +#endif + +#ifdef __POWER10_VECTOR__ + +/* vec_extractm */ + +static __inline__ unsigned int __ATTRS_o_ai +vec_extractm(vector unsigned char __a) { + return __builtin_altivec_vextractbm(__a); +} + +static __inline__ unsigned int __ATTRS_o_ai +vec_extractm(vector unsigned short __a) { + return __builtin_altivec_vextracthm(__a); +} + +static __inline__ unsigned int __ATTRS_o_ai +vec_extractm(vector unsigned int __a) { + return __builtin_altivec_vextractwm(__a); +} + +static __inline__ unsigned int __ATTRS_o_ai +vec_extractm(vector unsigned long long __a) { + return __builtin_altivec_vextractdm(__a); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ unsigned int __ATTRS_o_ai +vec_extractm(vector unsigned __int128 __a) { + return __builtin_altivec_vextractqm(__a); +} +#endif + +/* vec_expandm */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_expandm(vector unsigned char __a) { + return __builtin_altivec_vexpandbm(__a); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_expandm(vector unsigned short __a) { + return __builtin_altivec_vexpandhm(__a); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_expandm(vector unsigned int __a) { + return __builtin_altivec_vexpandwm(__a); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_expandm(vector unsigned long long __a) { + return __builtin_altivec_vexpanddm(__a); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_expandm(vector unsigned __int128 __a) { + return __builtin_altivec_vexpandqm(__a); +} +#endif + +/* vec_cntm */ + +#define vec_cntm(__a, __mp) \ + _Generic((__a), vector unsigned char \ + : __builtin_altivec_vcntmbb((vector unsigned char)(__a), \ + (unsigned char)(__mp)), \ + vector unsigned short \ + : __builtin_altivec_vcntmbh((vector unsigned short)(__a), \ + (unsigned char)(__mp)), \ + vector unsigned int \ + : __builtin_altivec_vcntmbw((vector unsigned int)(__a), \ + (unsigned char)(__mp)), \ + vector unsigned long long \ + : __builtin_altivec_vcntmbd((vector unsigned long long)(__a), \ + (unsigned char)(__mp))) + +/* vec_gen[b|h|w|d|q]m */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_genbm(unsigned long long __bm) { + return __builtin_altivec_mtvsrbm(__bm); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_genhm(unsigned long long __bm) { + return __builtin_altivec_mtvsrhm(__bm); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_genwm(unsigned long long __bm) { + return __builtin_altivec_mtvsrwm(__bm); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_gendm(unsigned long long __bm) { + return __builtin_altivec_mtvsrdm(__bm); +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_genqm(unsigned long long __bm) { + return __builtin_altivec_mtvsrqm(__bm); +} +#endif + +/* vec_pdep */ + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_pdep(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vpdepd(__a, __b); +} + +/* vec_pext */ + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_pext(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vpextd(__a, __b); +} + +/* vec_cfuge */ + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_cfuge(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vcfuged(__a, __b); +} + +/* vec_gnb */ + +#define vec_gnb(__a, __b) __builtin_altivec_vgnb(__a, __b) + +/* vec_ternarylogic */ +#ifdef __VSX__ +#ifdef __SIZEOF_INT128__ +#define vec_ternarylogic(__a, __b, __c, __imm) \ + _Generic((__a), vector unsigned char \ + : (vector unsigned char)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned short \ + : (vector unsigned short)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned int \ + : (vector unsigned int)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned long long \ + : (vector unsigned long long)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned __int128 \ + : (vector unsigned __int128)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm))) +#else +#define vec_ternarylogic(__a, __b, __c, __imm) \ + _Generic((__a), vector unsigned char \ + : (vector unsigned char)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned short \ + : (vector unsigned short)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned int \ + : (vector unsigned int)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm)), \ + vector unsigned long long \ + : (vector unsigned long long)__builtin_vsx_xxeval( \ + (vector unsigned long long)(__a), \ + (vector unsigned long long)(__b), \ + (vector unsigned long long)(__c), (__imm))) +#endif /* __SIZEOF_INT128__ */ +#endif /* __VSX__ */ + +/* vec_genpcvm */ + +#ifdef __VSX__ +#define vec_genpcvm(__a, __imm) \ + _Generic( \ + (__a), vector unsigned char \ + : __builtin_vsx_xxgenpcvbm((vector unsigned char)(__a), (int)(__imm)), \ + vector unsigned short \ + : __builtin_vsx_xxgenpcvhm((vector unsigned short)(__a), (int)(__imm)), \ + vector unsigned int \ + : __builtin_vsx_xxgenpcvwm((vector unsigned int)(__a), (int)(__imm)), \ + vector unsigned long long \ + : __builtin_vsx_xxgenpcvdm((vector unsigned long long)(__a), \ + (int)(__imm))) +#endif /* __VSX__ */ + +/* vec_clr_first */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_clr_first(vector signed char __a, unsigned int __n) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed char)__builtin_altivec_vclrrb((vector unsigned char)__a, + __n); +#else + return (vector signed char)__builtin_altivec_vclrlb((vector unsigned char)__a, + __n); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_clr_first(vector unsigned char __a, unsigned int __n) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned char)__builtin_altivec_vclrrb( + (vector unsigned char)__a, __n); +#else + return (vector unsigned char)__builtin_altivec_vclrlb( + (vector unsigned char)__a, __n); +#endif +} + +/* vec_clr_last */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_clr_last(vector signed char __a, unsigned int __n) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed char)__builtin_altivec_vclrlb((vector unsigned char)__a, + __n); +#else + return (vector signed char)__builtin_altivec_vclrrb((vector unsigned char)__a, + __n); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_clr_last(vector unsigned char __a, unsigned int __n) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned char)__builtin_altivec_vclrlb( + (vector unsigned char)__a, __n); +#else + return (vector unsigned char)__builtin_altivec_vclrrb( + (vector unsigned char)__a, __n); +#endif +} + +/* vec_cntlzm */ + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_cntlzm(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vclzdm(__a, __b); +} + +/* vec_cnttzm */ + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_cnttzm(vector unsigned long long __a, vector unsigned long long __b) { + return __builtin_altivec_vctzdm(__a, __b); +} + +/* vec_mod */ + +static __inline__ vector signed int __ATTRS_o_ai +vec_mod(vector signed int __a, vector signed int __b) { + return __a % __b; +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_mod(vector unsigned int __a, vector unsigned int __b) { + return __a % __b; +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_mod(vector signed long long __a, vector signed long long __b) { + return __a % __b; +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_mod(vector unsigned long long __a, vector unsigned long long __b) { + return __a % __b; +} + +#ifdef __SIZEOF_INT128__ +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_mod(vector signed __int128 __a, vector signed __int128 __b) { + return __a % __b; +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_mod(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a % __b; +} +#endif + +/* vec_sldb */ +#define vec_sldb(__a, __b, __c) \ + _Generic( \ + (__a), vector unsigned char \ + : (vector unsigned char)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed char \ + : (vector signed char)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector unsigned short \ + : (vector unsigned short)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed short \ + : (vector signed short)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector unsigned int \ + : (vector unsigned int)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed int \ + : (vector signed int)__builtin_altivec_vsldbi((vector unsigned char)__a, \ + (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector unsigned long long \ + : (vector unsigned long long)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed long long \ + : (vector signed long long)__builtin_altivec_vsldbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, (__c & 0x7))) + +/* vec_srdb */ +#define vec_srdb(__a, __b, __c) \ + _Generic( \ + (__a), vector unsigned char \ + : (vector unsigned char)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed char \ + : (vector signed char)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector unsigned short \ + : (vector unsigned short)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed short \ + : (vector signed short)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector unsigned int \ + : (vector unsigned int)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed int \ + : (vector signed int)__builtin_altivec_vsrdbi((vector unsigned char)__a, \ + (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector unsigned long long \ + : (vector unsigned long long)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, \ + (__c & 0x7)), \ + vector signed long long \ + : (vector signed long long)__builtin_altivec_vsrdbi( \ + (vector unsigned char)__a, (vector unsigned char)__b, (__c & 0x7))) + +/* vec_insertl */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_insertl(unsigned char __a, vector unsigned char __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinsbrx(__b, __c, __a); +#else + return __builtin_altivec_vinsblx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_insertl(unsigned short __a, vector unsigned short __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinshrx(__b, __c, __a); +#else + return __builtin_altivec_vinshlx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_insertl(unsigned int __a, vector unsigned int __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinswrx(__b, __c, __a); +#else + return __builtin_altivec_vinswlx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_insertl(unsigned long long __a, vector unsigned long long __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinsdrx(__b, __c, __a); +#else + return __builtin_altivec_vinsdlx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_insertl(vector unsigned char __a, vector unsigned char __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinsbvrx(__b, __c, __a); +#else + return __builtin_altivec_vinsbvlx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_insertl(vector unsigned short __a, vector unsigned short __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinshvrx(__b, __c, __a); +#else + return __builtin_altivec_vinshvlx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_insertl(vector unsigned int __a, vector unsigned int __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinswvrx(__b, __c, __a); +#else + return __builtin_altivec_vinswvlx(__b, __c, __a); +#endif +} + +/* vec_inserth */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_inserth(unsigned char __a, vector unsigned char __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinsblx(__b, __c, __a); +#else + return __builtin_altivec_vinsbrx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_inserth(unsigned short __a, vector unsigned short __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinshlx(__b, __c, __a); +#else + return __builtin_altivec_vinshrx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_inserth(unsigned int __a, vector unsigned int __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinswlx(__b, __c, __a); +#else + return __builtin_altivec_vinswrx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_inserth(unsigned long long __a, vector unsigned long long __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinsdlx(__b, __c, __a); +#else + return __builtin_altivec_vinsdrx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_inserth(vector unsigned char __a, vector unsigned char __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinsbvlx(__b, __c, __a); +#else + return __builtin_altivec_vinsbvrx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_inserth(vector unsigned short __a, vector unsigned short __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinshvlx(__b, __c, __a); +#else + return __builtin_altivec_vinshvrx(__b, __c, __a); +#endif +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_inserth(vector unsigned int __a, vector unsigned int __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vinswvlx(__b, __c, __a); +#else + return __builtin_altivec_vinswvrx(__b, __c, __a); +#endif +} + +/* vec_extractl */ + +static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl( + vector unsigned char __a, vector unsigned char __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextdubvrx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextdubvlx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl( + vector unsigned short __a, vector unsigned short __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextduhvrx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextduhvlx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai vec_extractl( + vector unsigned int __a, vector unsigned int __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextduwvrx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextduwvlx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_extractl(vector unsigned long long __a, vector unsigned long long __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextddvrx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextddvlx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +/* vec_extracth */ + +static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth( + vector unsigned char __a, vector unsigned char __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextdubvlx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextdubvrx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth( + vector unsigned short __a, vector unsigned short __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextduhvlx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextduhvrx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai vec_extracth( + vector unsigned int __a, vector unsigned int __b, unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextduwvlx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextduwvrx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_extracth(vector unsigned long long __a, vector unsigned long long __b, + unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vextddvlx(__a, __b, __c); +#else + vector unsigned long long __ret = __builtin_altivec_vextddvrx(__a, __b, __c); + return vec_sld(__ret, __ret, 8); +#endif +} + +#ifdef __VSX__ + +/* vec_permx */ +#define vec_permx(__a, __b, __c, __d) \ + _Generic( \ + (__a), vector unsigned char \ + : (vector unsigned char)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector signed char \ + : (vector signed char)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector unsigned short \ + : (vector unsigned short)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector signed short \ + : (vector signed short)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector unsigned int \ + : (vector unsigned int)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector signed int \ + : (vector signed int)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector unsigned long long \ + : (vector unsigned long long)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector signed long long \ + : (vector signed long long)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector float \ + : (vector float)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d), \ + vector double \ + : (vector double)__builtin_vsx_xxpermx( \ + (vector unsigned char)__a, (vector unsigned char)__b, __c, __d)) + +/* vec_blendv */ + +static __inline__ vector signed char __ATTRS_o_ai +vec_blendv(vector signed char __a, vector signed char __b, + vector unsigned char __c) { + return (vector signed char)__builtin_vsx_xxblendvb( + (vector unsigned char)__a, (vector unsigned char)__b, __c); +} + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_blendv(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return __builtin_vsx_xxblendvb(__a, __b, __c); +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_blendv(vector signed short __a, vector signed short __b, + vector unsigned short __c) { + return (vector signed short)__builtin_vsx_xxblendvh( + (vector unsigned short)__a, (vector unsigned short)__b, __c); +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_blendv(vector unsigned short __a, vector unsigned short __b, + vector unsigned short __c) { + return __builtin_vsx_xxblendvh(__a, __b, __c); +} + +static __inline__ vector signed int __ATTRS_o_ai +vec_blendv(vector signed int __a, vector signed int __b, + vector unsigned int __c) { + return (vector signed int)__builtin_vsx_xxblendvw( + (vector unsigned int)__a, (vector unsigned int)__b, __c); +} + +static __inline__ vector unsigned int __ATTRS_o_ai +vec_blendv(vector unsigned int __a, vector unsigned int __b, + vector unsigned int __c) { + return __builtin_vsx_xxblendvw(__a, __b, __c); +} + +static __inline__ vector signed long long __ATTRS_o_ai +vec_blendv(vector signed long long __a, vector signed long long __b, + vector unsigned long long __c) { + return (vector signed long long)__builtin_vsx_xxblendvd( + (vector unsigned long long)__a, (vector unsigned long long)__b, __c); +} + +static __inline__ vector unsigned long long __ATTRS_o_ai +vec_blendv(vector unsigned long long __a, vector unsigned long long __b, + vector unsigned long long __c) { + return (vector unsigned long long)__builtin_vsx_xxblendvd(__a, __b, __c); +} + +static __inline__ vector float __ATTRS_o_ai +vec_blendv(vector float __a, vector float __b, vector unsigned int __c) { + return (vector float)__builtin_vsx_xxblendvw((vector unsigned int)__a, + (vector unsigned int)__b, __c); +} + +static __inline__ vector double __ATTRS_o_ai +vec_blendv(vector double __a, vector double __b, + vector unsigned long long __c) { + return (vector double)__builtin_vsx_xxblendvd( + (vector unsigned long long)__a, (vector unsigned long long)__b, __c); +} + +#define vec_replace_unaligned(__a, __b, __c) \ + _Generic((__a), vector signed int \ + : __builtin_altivec_vinsw((vector unsigned char)__a, \ + (unsigned int)__b, __c), \ + vector unsigned int \ + : __builtin_altivec_vinsw((vector unsigned char)__a, \ + (unsigned int)__b, __c), \ + vector unsigned long long \ + : __builtin_altivec_vinsd((vector unsigned char)__a, \ + (unsigned long long)__b, __c), \ + vector signed long long \ + : __builtin_altivec_vinsd((vector unsigned char)__a, \ + (unsigned long long)__b, __c), \ + vector float \ + : __builtin_altivec_vinsw((vector unsigned char)__a, \ + (unsigned int)__b, __c), \ + vector double \ + : __builtin_altivec_vinsd((vector unsigned char)__a, \ + (unsigned long long)__b, __c)) + +#define vec_replace_elt(__a, __b, __c) \ + _Generic((__a), vector signed int \ + : (vector signed int)__builtin_altivec_vinsw_elt( \ + (vector unsigned char)__a, (unsigned int)__b, __c), \ + vector unsigned int \ + : (vector unsigned int)__builtin_altivec_vinsw_elt( \ + (vector unsigned char)__a, (unsigned int)__b, __c), \ + vector unsigned long long \ + : (vector unsigned long long)__builtin_altivec_vinsd_elt( \ + (vector unsigned char)__a, (unsigned long long)__b, __c), \ + vector signed long long \ + : (vector signed long long)__builtin_altivec_vinsd_elt( \ + (vector unsigned char)__a, (unsigned long long)__b, __c), \ + vector float \ + : (vector float)__builtin_altivec_vinsw_elt( \ + (vector unsigned char)__a, (unsigned int)__b, __c), \ + vector double \ + : (vector double)__builtin_altivec_vinsd_elt( \ + (vector unsigned char)__a, (unsigned long long)__b, __c)) + +/* vec_splati */ + +#define vec_splati(__a) \ + _Generic((__a), signed int \ + : ((vector signed int)__a), unsigned int \ + : ((vector unsigned int)__a), float \ + : ((vector float)__a)) + +/* vec_spatid */ + +static __inline__ vector double __ATTRS_o_ai vec_splatid(const float __a) { + return ((vector double)((double)__a)); +} + +/* vec_splati_ins */ + +static __inline__ vector signed int __ATTRS_o_ai vec_splati_ins( + vector signed int __a, const unsigned int __b, const signed int __c) { + const unsigned int __d = __b & 0x01; +#ifdef __LITTLE_ENDIAN__ + __a[1 - __d] = __c; + __a[3 - __d] = __c; +#else + __a[__d] = __c; + __a[2 + __d] = __c; +#endif + return __a; +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_splati_ins( + vector unsigned int __a, const unsigned int __b, const unsigned int __c) { + const unsigned int __d = __b & 0x01; +#ifdef __LITTLE_ENDIAN__ + __a[1 - __d] = __c; + __a[3 - __d] = __c; +#else + __a[__d] = __c; + __a[2 + __d] = __c; +#endif + return __a; +} + +static __inline__ vector float __ATTRS_o_ai +vec_splati_ins(vector float __a, const unsigned int __b, const float __c) { + const unsigned int __d = __b & 0x01; +#ifdef __LITTLE_ENDIAN__ + __a[1 - __d] = __c; + __a[3 - __d] = __c; +#else + __a[__d] = __c; + __a[2 + __d] = __c; +#endif + return __a; +} + +/* vec_test_lsbb_all_ones */ + +static __inline__ int __ATTRS_o_ai +vec_test_lsbb_all_ones(vector unsigned char __a) { + return __builtin_vsx_xvtlsbb(__a, 1); +} + +/* vec_test_lsbb_all_zeros */ + +static __inline__ int __ATTRS_o_ai +vec_test_lsbb_all_zeros(vector unsigned char __a) { + return __builtin_vsx_xvtlsbb(__a, 0); +} +#endif /* __VSX__ */ + +/* vec_stril */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_stril(vector unsigned char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned char)__builtin_altivec_vstribr( + (vector unsigned char)__a); +#else + return (vector unsigned char)__builtin_altivec_vstribl( + (vector unsigned char)__a); +#endif +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_stril(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed char)__builtin_altivec_vstribr( + (vector unsigned char)__a); +#else + return (vector signed char)__builtin_altivec_vstribl( + (vector unsigned char)__a); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_stril(vector unsigned short __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned short)__builtin_altivec_vstrihr( + (vector signed short)__a); +#else + return (vector unsigned short)__builtin_altivec_vstrihl( + (vector signed short)__a); +#endif +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_stril(vector signed short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstrihr(__a); +#else + return __builtin_altivec_vstrihl(__a); +#endif +} + +/* vec_stril_p */ + +static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstribr_p(__CR6_EQ, (vector unsigned char)__a); +#else + return __builtin_altivec_vstribl_p(__CR6_EQ, (vector unsigned char)__a); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstribr_p(__CR6_EQ, (vector unsigned char)__a); +#else + return __builtin_altivec_vstribl_p(__CR6_EQ, (vector unsigned char)__a); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_stril_p(vector unsigned short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a); +#else + return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_stril_p(vector signed short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstrihr_p(__CR6_EQ, __a); +#else + return __builtin_altivec_vstrihl_p(__CR6_EQ, __a); +#endif +} + +/* vec_strir */ + +static __inline__ vector unsigned char __ATTRS_o_ai +vec_strir(vector unsigned char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned char)__builtin_altivec_vstribl( + (vector unsigned char)__a); +#else + return (vector unsigned char)__builtin_altivec_vstribr( + (vector unsigned char)__a); +#endif +} + +static __inline__ vector signed char __ATTRS_o_ai +vec_strir(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector signed char)__builtin_altivec_vstribl( + (vector unsigned char)__a); +#else + return (vector signed char)__builtin_altivec_vstribr( + (vector unsigned char)__a); +#endif +} + +static __inline__ vector unsigned short __ATTRS_o_ai +vec_strir(vector unsigned short __a) { +#ifdef __LITTLE_ENDIAN__ + return (vector unsigned short)__builtin_altivec_vstrihl( + (vector signed short)__a); +#else + return (vector unsigned short)__builtin_altivec_vstrihr( + (vector signed short)__a); +#endif +} + +static __inline__ vector signed short __ATTRS_o_ai +vec_strir(vector signed short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstrihl(__a); +#else + return __builtin_altivec_vstrihr(__a); +#endif +} + +/* vec_strir_p */ + +static __inline__ int __ATTRS_o_ai vec_strir_p(vector unsigned char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstribl_p(__CR6_EQ, (vector unsigned char)__a); +#else + return __builtin_altivec_vstribr_p(__CR6_EQ, (vector unsigned char)__a); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_strir_p(vector signed char __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstribl_p(__CR6_EQ, (vector unsigned char)__a); +#else + return __builtin_altivec_vstribr_p(__CR6_EQ, (vector unsigned char)__a); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_strir_p(vector unsigned short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstrihl_p(__CR6_EQ, (vector signed short)__a); +#else + return __builtin_altivec_vstrihr_p(__CR6_EQ, (vector signed short)__a); +#endif +} + +static __inline__ int __ATTRS_o_ai vec_strir_p(vector signed short __a) { +#ifdef __LITTLE_ENDIAN__ + return __builtin_altivec_vstrihl_p(__CR6_EQ, __a); +#else + return __builtin_altivec_vstrihr_p(__CR6_EQ, __a); +#endif +} + +/* vs[l | r | ra] */ + +#ifdef __SIZEOF_INT128__ +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_sl(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a << (__b % (vector unsigned __int128)(sizeof(unsigned __int128) * + __CHAR_BIT__)); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_sl(vector signed __int128 __a, vector unsigned __int128 __b) { + return __a << (__b % (vector unsigned __int128)(sizeof(unsigned __int128) * + __CHAR_BIT__)); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_sr(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return __a >> (__b % (vector unsigned __int128)(sizeof(unsigned __int128) * + __CHAR_BIT__)); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_sr(vector signed __int128 __a, vector unsigned __int128 __b) { + return ( + vector signed __int128)(((vector unsigned __int128)__a) >> + (__b % + (vector unsigned __int128)(sizeof( + unsigned __int128) * + __CHAR_BIT__))); +} + +static __inline__ vector unsigned __int128 __ATTRS_o_ai +vec_sra(vector unsigned __int128 __a, vector unsigned __int128 __b) { + return ( + vector unsigned __int128)(((vector signed __int128)__a) >> + (__b % + (vector unsigned __int128)(sizeof( + unsigned __int128) * + __CHAR_BIT__))); +} + +static __inline__ vector signed __int128 __ATTRS_o_ai +vec_sra(vector signed __int128 __a, vector unsigned __int128 __b) { + return __a >> (__b % (vector unsigned __int128)(sizeof(unsigned __int128) * + __CHAR_BIT__)); +} + +#endif /* __SIZEOF_INT128__ */ +#endif /* __POWER10_VECTOR__ */ + +#ifdef __POWER8_VECTOR__ +#define __bcdadd(__a, __b, __ps) __builtin_ppc_bcdadd((__a), (__b), (__ps)) +#define __bcdsub(__a, __b, __ps) __builtin_ppc_bcdsub((__a), (__b), (__ps)) + +static __inline__ long __bcdadd_ofl(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdadd_p(__CR6_SO, __a, __b); +} + +static __inline__ long __bcdsub_ofl(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __b); +} + +static __inline__ long __bcd_invalid(vector unsigned char __a) { + return __builtin_ppc_bcdsub_p(__CR6_SO, __a, __a); +} + +static __inline__ long __bcdcmpeq(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdsub_p(__CR6_EQ, __a, __b); +} + +static __inline__ long __bcdcmplt(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdsub_p(__CR6_LT, __a, __b); +} + +static __inline__ long __bcdcmpgt(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdsub_p(__CR6_GT, __a, __b); +} + +static __inline__ long __bcdcmple(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdsub_p(__CR6_GT_REV, __a, __b); +} + +static __inline__ long __bcdcmpge(vector unsigned char __a, + vector unsigned char __b) { + return __builtin_ppc_bcdsub_p(__CR6_LT_REV, __a, __b); +} + +#endif // __POWER8_VECTOR__ + +#undef __ATTRS_o_ai + +#endif /* __ALTIVEC_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amdgpuintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amdgpuintrin.h new file mode 100755 index 0000000..f7fb8e2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amdgpuintrin.h @@ -0,0 +1,191 @@ +//===-- amdgpuintrin.h - AMDPGU intrinsic functions -----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __AMDGPUINTRIN_H +#define __AMDGPUINTRIN_H + +#ifndef __AMDGPU__ +#error "This file is intended for AMDGPU targets or offloading to AMDGPU" +#endif + +#ifndef __GPUINTRIN_H +#error "Never use directly; include instead" +#endif + +_Pragma("omp begin declare target device_type(nohost)"); +_Pragma("omp begin declare variant match(device = {arch(amdgcn)})"); + +// Type aliases to the address spaces used by the AMDGPU backend. +#define __gpu_private __attribute__((address_space(5))) +#define __gpu_constant __attribute__((address_space(4))) +#define __gpu_local __attribute__((address_space(3))) +#define __gpu_global __attribute__((address_space(1))) +#define __gpu_generic __attribute__((address_space(0))) + +// Attribute to declare a function as a kernel. +#define __gpu_kernel __attribute__((amdgpu_kernel, visibility("protected"))) + +// Returns the number of workgroups in the 'x' dimension of the grid. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks_x(void) { + return __builtin_amdgcn_grid_size_x() / __builtin_amdgcn_workgroup_size_x(); +} + +// Returns the number of workgroups in the 'y' dimension of the grid. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks_y(void) { + return __builtin_amdgcn_grid_size_y() / __builtin_amdgcn_workgroup_size_y(); +} + +// Returns the number of workgroups in the 'z' dimension of the grid. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks_z(void) { + return __builtin_amdgcn_grid_size_z() / __builtin_amdgcn_workgroup_size_z(); +} + +// Returns the 'x' dimension of the current AMD workgroup's id. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id_x(void) { + return __builtin_amdgcn_workgroup_id_x(); +} + +// Returns the 'y' dimension of the current AMD workgroup's id. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id_y(void) { + return __builtin_amdgcn_workgroup_id_y(); +} + +// Returns the 'z' dimension of the current AMD workgroup's id. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id_z(void) { + return __builtin_amdgcn_workgroup_id_z(); +} + +// Returns the number of workitems in the 'x' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads_x(void) { + return __builtin_amdgcn_workgroup_size_x(); +} + +// Returns the number of workitems in the 'y' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads_y(void) { + return __builtin_amdgcn_workgroup_size_y(); +} + +// Returns the number of workitems in the 'z' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads_z(void) { + return __builtin_amdgcn_workgroup_size_z(); +} + +// Returns the 'x' dimension id of the workitem in the current AMD workgroup. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id_x(void) { + return __builtin_amdgcn_workitem_id_x(); +} + +// Returns the 'y' dimension id of the workitem in the current AMD workgroup. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id_y(void) { + return __builtin_amdgcn_workitem_id_y(); +} + +// Returns the 'z' dimension id of the workitem in the current AMD workgroup. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id_z(void) { + return __builtin_amdgcn_workitem_id_z(); +} + +// Returns the size of an AMD wavefront, either 32 or 64 depending on hardware +// and compilation options. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_lanes(void) { + return __builtin_amdgcn_wavefrontsize(); +} + +// Returns the id of the thread inside of an AMD wavefront executing together. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_lane_id(void) { + return __builtin_amdgcn_mbcnt_hi(~0u, __builtin_amdgcn_mbcnt_lo(~0u, 0u)); +} + +// Returns the bit-mask of active threads in the current wavefront. +_DEFAULT_FN_ATTRS static __inline__ uint64_t __gpu_lane_mask(void) { + return __builtin_amdgcn_read_exec(); +} + +// Copies the value from the first active thread in the wavefront to the rest. +_DEFAULT_FN_ATTRS static __inline__ uint32_t +__gpu_read_first_lane_u32(uint64_t __lane_mask, uint32_t __x) { + return __builtin_amdgcn_readfirstlane(__x); +} + +// Returns a bitmask of threads in the current lane for which \p x is true. +_DEFAULT_FN_ATTRS static __inline__ uint64_t __gpu_ballot(uint64_t __lane_mask, + bool __x) { + // The lane_mask & gives the nvptx semantics when lane_mask is a subset of + // the active threads + return __lane_mask & __builtin_amdgcn_ballot_w64(__x); +} + +// Waits for all the threads in the block to converge and issues a fence. +_DEFAULT_FN_ATTRS static __inline__ void __gpu_sync_threads(void) { + __builtin_amdgcn_s_barrier(); + __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "workgroup"); +} + +// Wait for all threads in the wavefront to converge, this is a noop on AMDGPU. +_DEFAULT_FN_ATTRS static __inline__ void __gpu_sync_lane(uint64_t __lane_mask) { + __builtin_amdgcn_wave_barrier(); +} + +// Shuffles the the lanes inside the wavefront according to the given index. +_DEFAULT_FN_ATTRS static __inline__ uint32_t +__gpu_shuffle_idx_u32(uint64_t __lane_mask, uint32_t __idx, uint32_t __x, + uint32_t __width) { + uint32_t __lane = __idx + (__gpu_lane_id() & ~(__width - 1)); + return __builtin_amdgcn_ds_bpermute(__lane << 2, __x); +} + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u32(uint64_t __lane_mask, uint32_t __x) { + return __gpu_match_any_u32_impl(__lane_mask, __x); +} + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u64(uint64_t __lane_mask, uint64_t __x) { + return __gpu_match_any_u64_impl(__lane_mask, __x); +} + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u32(uint64_t __lane_mask, uint32_t __x) { + return __gpu_match_all_u32_impl(__lane_mask, __x); +} + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u64(uint64_t __lane_mask, uint64_t __x) { + return __gpu_match_all_u64_impl(__lane_mask, __x); +} + +// Returns true if the flat pointer points to AMDGPU 'shared' memory. +_DEFAULT_FN_ATTRS static __inline__ bool __gpu_is_ptr_local(void *ptr) { + return __builtin_amdgcn_is_shared((void [[clang::address_space(0)]] *)(( + void [[clang::opencl_generic]] *)ptr)); +} + +// Returns true if the flat pointer points to AMDGPU 'private' memory. +_DEFAULT_FN_ATTRS static __inline__ bool __gpu_is_ptr_private(void *ptr) { + return __builtin_amdgcn_is_private((void [[clang::address_space(0)]] *)(( + void [[clang::opencl_generic]] *)ptr)); +} + +// Terminates execution of the associated wavefront. +_DEFAULT_FN_ATTRS [[noreturn]] static __inline__ void __gpu_exit(void) { + __builtin_amdgcn_endpgm(); +} + +// Suspend the thread briefly to assist the scheduler during busy loops. +_DEFAULT_FN_ATTRS static __inline__ void __gpu_thread_suspend(void) { + __builtin_amdgcn_s_sleep(2); +} + +_Pragma("omp end declare variant"); +_Pragma("omp end declare target"); + +#endif // __AMDGPUINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ammintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ammintrin.h new file mode 100755 index 0000000..f549ab8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ammintrin.h @@ -0,0 +1,183 @@ +/*===---- ammintrin.h - SSE4a intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __AMMINTRIN_H +#define __AMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse4a"), __min_vector_width__(128))) + +/// Extracts the specified bits from the lower 64 bits of the 128-bit +/// integer vector operand at the index \a idx and of the length \a len. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_extracti_si64(__m128i x, const int len, const int idx); +/// \endcode +/// +/// This intrinsic corresponds to the EXTRQ instruction. +/// +/// \param x +/// The value from which bits are extracted. +/// \param len +/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0] +/// are zero, the length is interpreted as 64. +/// \param idx +/// Bits [5:0] specify the index of the least significant bit; the other +/// bits are ignored. If the sum of the index and length is greater than 64, +/// the result is undefined. If the length and index are both zero, bits +/// [63:0] of parameter \a x are extracted. If the length is zero but the +/// index is non-zero, the result is undefined. +/// \returns A 128-bit integer vector whose lower 64 bits contain the bits +/// extracted from the source operand. +#define _mm_extracti_si64(x, len, idx) \ + ((__m128i)__builtin_ia32_extrqi((__v2di)(__m128i)(x), \ + (char)(len), (char)(idx))) + +/// Extracts the specified bits from the lower 64 bits of the 128-bit +/// integer vector operand at the index and of the length specified by +/// \a __y. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the EXTRQ instruction. +/// +/// \param __x +/// The value from which bits are extracted. +/// \param __y +/// Specifies the index of the least significant bit at [13:8] and the +/// length at [5:0]; all other bits are ignored. If bits [5:0] are zero, the +/// length is interpreted as 64. If the sum of the index and length is +/// greater than 64, the result is undefined. If the length and index are +/// both zero, bits [63:0] of parameter \a __x are extracted. If the length +/// is zero but the index is non-zero, the result is undefined. +/// \returns A 128-bit vector whose lower 64 bits contain the bits extracted +/// from the source operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_extract_si64(__m128i __x, __m128i __y) +{ + return (__m128i)__builtin_ia32_extrq((__v2di)__x, (__v16qi)__y); +} + +/// Inserts bits of a specified length from the source integer vector +/// \a y into the lower 64 bits of the destination integer vector \a x at +/// the index \a idx and of the length \a len. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_inserti_si64(__m128i x, __m128i y, const int len, +/// const int idx); +/// \endcode +/// +/// This intrinsic corresponds to the INSERTQ instruction. +/// +/// \param x +/// The destination operand where bits will be inserted. The inserted bits +/// are defined by the length \a len and by the index \a idx specifying the +/// least significant bit. +/// \param y +/// The source operand containing the bits to be extracted. The extracted +/// bits are the least significant bits of operand \a y of length \a len. +/// \param len +/// Bits [5:0] specify the length; the other bits are ignored. If bits [5:0] +/// are zero, the length is interpreted as 64. +/// \param idx +/// Bits [5:0] specify the index of the least significant bit; the other +/// bits are ignored. If the sum of the index and length is greater than 64, +/// the result is undefined. If the length and index are both zero, bits +/// [63:0] of parameter \a y are inserted into parameter \a x. If the length +/// is zero but the index is non-zero, the result is undefined. +/// \returns A 128-bit integer vector containing the original lower 64-bits of +/// destination operand \a x with the specified bitfields replaced by the +/// lower bits of source operand \a y. The upper 64 bits of the return value +/// are undefined. +#define _mm_inserti_si64(x, y, len, idx) \ + ((__m128i)__builtin_ia32_insertqi((__v2di)(__m128i)(x), \ + (__v2di)(__m128i)(y), \ + (char)(len), (char)(idx))) + +/// Inserts bits of a specified length from the source integer vector +/// \a __y into the lower 64 bits of the destination integer vector \a __x +/// at the index and of the length specified by \a __y. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the INSERTQ instruction. +/// +/// \param __x +/// The destination operand where bits will be inserted. The inserted bits +/// are defined by the length and by the index of the least significant bit +/// specified by operand \a __y. +/// \param __y +/// The source operand containing the bits to be extracted. The extracted +/// bits are the least significant bits of operand \a __y with length +/// specified by bits [69:64]. These are inserted into the destination at the +/// index specified by bits [77:72]; all other bits are ignored. If bits +/// [69:64] are zero, the length is interpreted as 64. If the sum of the +/// index and length is greater than 64, the result is undefined. If the +/// length and index are both zero, bits [63:0] of parameter \a __y are +/// inserted into parameter \a __x. If the length is zero but the index is +/// non-zero, the result is undefined. +/// \returns A 128-bit integer vector containing the original lower 64-bits of +/// destination operand \a __x with the specified bitfields replaced by the +/// lower bits of source operand \a __y. The upper 64 bits of the return +/// value are undefined. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_insert_si64(__m128i __x, __m128i __y) +{ + return (__m128i)__builtin_ia32_insertq((__v2di)__x, (__v2di)__y); +} + +/// Stores a 64-bit double-precision value in a 64-bit memory location. +/// To minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVNTSD instruction. +/// +/// \param __p +/// The 64-bit memory location used to store the register value. +/// \param __a +/// The 64-bit double-precision floating-point register value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_stream_sd(void *__p, __m128d __a) +{ + __builtin_ia32_movntsd((double *)__p, (__v2df)__a); +} + +/// Stores a 32-bit single-precision floating-point value in a 32-bit +/// memory location. To minimize caching, the data is flagged as +/// non-temporal (unlikely to be used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVNTSS instruction. +/// +/// \param __p +/// The 32-bit memory location used to store the register value. +/// \param __a +/// The 32-bit single-precision floating-point register value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_stream_ss(void *__p, __m128 __a) +{ + __builtin_ia32_movntss((float *)__p, (__v4sf)__a); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __AMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxavx512intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxavx512intrin.h new file mode 100755 index 0000000..bbde44f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxavx512intrin.h @@ -0,0 +1,382 @@ +/*===--------------------- amxavx512intrin.h - AMXAVX512 --------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AMX_AVX512INTRIN_H +#define __AMX_AVX512INTRIN_H +#if defined(__x86_64__) && defined(__SSE2__) + +#define __DEFAULT_FN_ATTRS_AVX512 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("amx-avx512,avx10.2-512"))) + +/// Moves a row from a tile register to a zmm destination register, converting +/// the int32 source elements to fp32. The row of the tile is selected by a +/// 32b GPR. +/// +/// \headerfile +/// +/// \code +/// __m512i _tile_cvtrowd2ps(__tile tsrc, unsigned int row); +/// \endcode +/// +/// \code{.operation} +/// VL := 512 +/// VL_bytes := VL >> 3 +/// row_index := row & 0xffff +/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes +/// FOR i := 0 TO (VL_bytes / 4) - 1 +/// IF i + row_chunk / 4 >= tsrc.colsb / 4 +/// dst.dword[i] := 0 +/// ELSE +/// dst.f32[i] := CONVERT_INT32_TO_FP32(tsrc.row[row_index].dword[row_chunk/4+i], RNE) +/// FI +/// ENDFOR +/// dst[MAX_VL-1:VL] := 0 +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCVTROWD2PS instruction. +/// +/// \param tsrc +/// The source tile. Max size is 1024 Bytes. +/// \param row +/// The row of the source tile +#define _tile_cvtrowd2ps(tsrc, row) __builtin_ia32_tcvtrowd2ps(tsrc, row) + +/// Moves a row from a tile register to a zmm destination register, converting +/// the fp32 source elements to bf16. It places the resulting bf16 elements +/// in the high 16 bits within each dword. The row of the tile is selected +/// by a 32b GPR. +/// +/// \headerfile +/// +/// \code +/// __m512i _tile_cvtrowps2bf16h(__tile tsrc, unsigned int row); +/// \endcode +/// +/// \code{.operation} +/// VL := 512 +/// VL_bytes := VL >> 3 +/// row_index := row & 0xffff +/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes +/// FOR i := 0 TO (VL_bytes / 4) - 1 +/// IF i + row_chunk / 4 >= tsrc.colsb / 4 +/// dst.dword[i] := 0 +/// ELSE +/// dst.word[2*i+0] := 0 +/// dst.bf16[2*i+1] := CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE) +/// FI +/// ENDFOR +/// dst[MAX_VL-1:VL] := 0 +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCVTROWPS2BF16H instruction. +/// +/// \param tsrc +/// The source tile. Max size is 1024 Bytes. +/// \param row +/// The the row of the source tile. +#define _tile_cvtrowps2bf16h(tsrc, row) \ + __builtin_ia32_tcvtrowps2bf16h(tsrc, row) + +/// Moves a row from a tile register to a zmm destination register, converting +/// the fp32 source elements to bf16. It places the resulting bf16 elements +/// in the low 16 bits within each dword. The row of the tile is selected +/// by a 32b GPR. +/// +/// \headerfile +/// +/// \code +/// __m512i _tile_cvtrowps2bf16l(__tile tsrc, unsigned int row); +/// \endcode +/// +/// \code{.operation} +/// VL := 512 +/// VL_bytes := VL >> 3 +/// row_index := row & 0xffff +/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes +/// FOR i := 0 TO (VL_bytes / 4) - 1 +/// IF i + row_chunk / 4 >= tsrc.colsb / 4 +/// dst.dword[i] := 0 +/// ELSE +/// dst.word[2*i+1] := 0 +/// dst.bf16[2*i+0] := CONVERT_FP32_TO_BF16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE) +/// FI +/// ENDFOR +/// dst[MAX_VL-1:VL] := 0 +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCVTROWPS2BF16L instruction. +/// +/// \param tsrc +/// The source tile. Max size is 1024 Bytes. +/// \param row +/// The the row of the source tile. +#define _tile_cvtrowps2bf16l(tsrc, row) \ + __builtin_ia32_tcvtrowps2bf16l(tsrc, row) + +/// Moves a row from a tile register to a zmm destination register, converting +/// the fp32 source elements to fp16. It places the resulting fp16 elements +/// in the high 16 bits within each dword. The row of the tile is selected +/// by a 32b GPR. +/// +/// \headerfile +/// +/// \code +/// __m512i _tile_cvtrowps2phh(__tile tsrc, unsigned int row); +/// \endcode +/// +/// \code{.operation} +/// VL := 512 +/// VL_bytes := VL >> 3 +/// row_index := row & 0xffff +/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes +/// FOR i := 0 TO (VL_bytes / 4) - 1 +/// IF i + row_chunk / 4 >= tsrc.colsb / 4 +/// dst.dword[i] := 0 +/// ELSE +/// dst.word[2*i+0] := 0 +/// dst.fp16[2*i+1] := CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE) +/// FI +/// ENDFOR +/// dst[MAX_VL-1:VL] := 0 +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCVTROWPS2PHH instruction. +/// +/// \param tsrc +/// The source tile. Max size is 1024 Bytes. +/// \param row +/// The the row of the source tile. +#define _tile_cvtrowps2phh(tsrc, row) __builtin_ia32_tcvtrowps2phh(tsrc, row) + +/// Moves a row from a tile register to a zmm destination register, converting +/// the fp32 source elements to fp16. It places the resulting fp16 elements +/// in the low 16 bits within each dword. The row of the tile is selected +/// by a 32b GPR. +/// +/// \headerfile +/// +/// \code +/// __m512i _tile_cvtrowps2phl(__tile tsrc, unsigned int row); +/// \endcode +/// +/// \code{.operation} +/// VL := 512 +/// VL_bytes := VL >> 3 +/// row_index := row & 0xffff +/// row_chunk := ((row >> 16) & 0xffff) * VL_bytes +/// FOR i := 0 TO (VL_bytes / 4) - 1 +/// IF i + row_chunk / 4 >= tsrc.colsb / 4 +/// dst.dword[i] := 0 +/// ELSE +/// dst.word[2*i+1] := 0 +/// dst.fp16[2*i+0] := CONVERT_FP32_TO_FP16(tsrc.row[row_index].fp32[row_chunk/4+i], RNE) +/// FI +/// ENDFOR +/// dst[MAX_VL-1:VL] := 0 +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCVTROWPS2PHL instruction. +/// +/// \param tsrc +/// The source tile. Max size is 1024 Bytes. +/// \param row +/// The the row of the source tile. +#define _tile_cvtrowps2phl(tsrc, row) __builtin_ia32_tcvtrowps2phl(tsrc, row) + +/// Move one row of a tile data to a v16f32 data. +/// The row of the tile is selected by a 32b GPR. +/// +/// \headerfile +/// +/// \code +/// __m512 _tile_movrow(__tile a, unsigned b); +/// \endcode +/// +/// This intrinsic corresponds to the TILEMOVROW instruction. +/// +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v16f32 data. Size is 64 Bytes. +/// +/// \code{.operation} +/// VL := 512 +/// VL_bytes := VL>>3 +/// row_index := b&0xffff +/// row_chunk := ((b>>16)&0xffff) * VL_bytes +/// FOR i := 0 TO (VL_bytes-1) +/// IF (row_chunk + i >= a.colsb) +/// dst.byte[i] := 0 +/// ELSE +/// dst.byte[i] := a.row[row_index].byte[row_chunk+i] +/// ENDFOR +/// \endcode +#define _tile_movrow(a, b) ((__m512i)__builtin_ia32_tilemovrow(a, b)) + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. + +static __inline__ __m512 __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowd2ps_internal( + unsigned short m, unsigned short n, _tile1024i src, unsigned u) { + return __builtin_ia32_tcvtrowd2ps_internal(m, n, src, u); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS_AVX512 +_tile_cvtrowps2bf16h_internal(unsigned short m, unsigned short n, + _tile1024i src, unsigned u) { + return __builtin_ia32_tcvtrowps2bf16h_internal(m, n, src, u); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS_AVX512 +_tile_cvtrowps2bf16l_internal(unsigned short m, unsigned short n, + _tile1024i src, unsigned u) { + return __builtin_ia32_tcvtrowps2bf16l_internal(m, n, src, u); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowps2phh_internal( + unsigned short m, unsigned short n, _tile1024i src, unsigned u) { + return __builtin_ia32_tcvtrowps2phh_internal(m, n, src, u); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS_AVX512 _tile_cvtrowps2phl_internal( + unsigned short m, unsigned short n, _tile1024i src, unsigned u) { + return __builtin_ia32_tcvtrowps2phl_internal(m, n, src, u); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_AVX512 _tile_movrow_internal( + unsigned short m, unsigned short n, _tile1024i src, unsigned u) { + return (__m512i)__builtin_ia32_tilemovrow_internal(m, n, src, u); +} + +/// Move a row from a tile (src0) to a v16f32 dst, converting the int32 source +/// elements to fp32. No SIMD exceptions are generated. Rounding is done as if +/// MXCSR.RC=RNE. Embedded rounding is not supported. +/// The row and chunk elements of tile is fetched from 32bit src1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCVTROWD2PS instruction. +/// +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v16f32 data. Size is 64 Bytes. +__DEFAULT_FN_ATTRS_AVX512 +static __m512 __tile_cvtrowd2ps(__tile1024i src0, unsigned src1) { + return _tile_cvtrowd2ps_internal(src0.row, src0.col, src0.tile, src1); +} + +/// Move a row from a tile (src0) to a v32bf16 dst, converting the fp32 source +/// elements to bf16 at high 16-bits of each dword. +/// The row and chunk elements of tile is fetched from 32bit src1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCVTROWPS2BF16H instruction. +/// +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v32bf16 data. Size is 64 Bytes. +__DEFAULT_FN_ATTRS_AVX512 +static __m512bh __tile_cvtrowps2bf16h(__tile1024i src0, unsigned src1) { + return _tile_cvtrowps2bf16h_internal(src0.row, src0.col, src0.tile, src1); +} + +/// Move a row from a tile (src0) to a v32bf16 dst, converting the fp32 source +/// elements to bf16 at low 16-bits of each dword. +/// The row and chunk elements of tile is fetched from 32bit src1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCVTROWPS2BF16L instruction. +/// +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v32bf16 data. Size is 64 Bytes. +__DEFAULT_FN_ATTRS_AVX512 +static __m512bh __tile_cvtrowps2bf16l(__tile1024i src0, unsigned src1) { + return _tile_cvtrowps2bf16l_internal(src0.row, src0.col, src0.tile, src1); +} + +/// Move a row from a tile (src0) to a v32fp16 dst, converting the fp32 source +/// elements to fp16 at high 16-bits of each dword. +/// The row and chunk elements of tile is fetched from 32bit src1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCVTROWPS2PHH instruction. +/// +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v32fp16 data. Size is 64 Bytes. +__DEFAULT_FN_ATTRS_AVX512 +static __m512h __tile_cvtrowps2phh(__tile1024i src0, unsigned src1) { + return _tile_cvtrowps2phh_internal(src0.row, src0.col, src0.tile, src1); +} + +/// Move a row from a tile (src0) to a v32fp16 dst, converting the fp32 source +/// elements to fp16 at low 16-bits of each dword. +/// The row and chunk elements of tile is fetched from 32bit src1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCVTROWPS2PHL instruction. +/// +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v32fp16 data. Size is 64 Bytes. +__DEFAULT_FN_ATTRS_AVX512 +static __m512h __tile_cvtrowps2phl(__tile1024i src0, unsigned src1) { + return _tile_cvtrowps2phl_internal(src0.row, src0.col, src0.tile, src1); +} + +/// Move one row of a tile data to a v16f32 data. +/// The row of the tile is selected by a 32b GPR. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILEMOVROW instruction. +/// +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source r32. Size is 4 Bytes. +/// \returns +/// The destination v16i32 data. Size is 64 Bytes. +__DEFAULT_FN_ATTRS_AVX512 +static __m512i __tile_movrow(__tile1024i src0, unsigned src1) { + return (__m512i)_tile_movrow_internal(src0.row, src0.col, src0.tile, src1); +} + +#endif // __x86_64__ && __SSE2__ +#endif // __AMX_AVX512INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxbf16transposeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxbf16transposeintrin.h new file mode 100755 index 0000000..86f09f2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxbf16transposeintrin.h @@ -0,0 +1,94 @@ +/*===----- amxbf16transposeintrin.h - AMX-BF16 and AMX-TRANSPOSE ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; use instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMX_BF16TRANSPOSEINTRIN_H +#define __AMX_BF16TRANSPOSEINTRIN_H +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("amx-bf16,amx-transpose"))) + +/// Compute transpose and dot-product of BF16 (16-bit) floating-point pairs in +/// tiles \a a and \a b, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in \a dst, and store the +/// 32-bit result back to tile \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_tdpbf16ps (__tile dst, __tile a, __tile b) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO (a.colsb / 4) - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.bf32[n] += FP32(a.row[m].bf16[2*k+0]) * +/// FP32(b.row[k].bf16[2*n+0]) +/// tmp.bf32[n] += FP32(a.row[m].bf16[2*k+1]) * +/// FP32(b.row[k].bf16[2*n+1]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TTDPBF16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_tdpbf16ps(dst, a, b) __builtin_ia32_ttdpbf16ps((dst), (a), (b)) + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS +_tile_tdpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_ttdpbf16ps_internal(m, n, k, dst, src1, src2); +} + +/// Compute transpose and dot-product of BF16 (16-bit) floating-point pairs in +/// tiles src0 and src1, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in "dst", and store the +/// 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TTDPBF16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static __inline__ void __tile_tdpbf16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_tdpbf16ps_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __x86_64__ */ +#endif /* __AMX_BF16TRANSPOSEINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxcomplexintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxcomplexintrin.h new file mode 100755 index 0000000..87ee8f3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxcomplexintrin.h @@ -0,0 +1,167 @@ +/*===--------- amxcomplexintrin.h - AMXCOMPLEX intrinsics -*- C++ -*---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AMX_COMPLEXINTRIN_H +#define __AMX_COMPLEXINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS_COMPLEX \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-complex"))) + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles \a a and \a b is interpreted as a complex number +/// with FP16 real part and FP16 imaginary part. +/// Calculates the imaginary part of the result. For each possible combination +/// of (row of \a a, column of \a b), it performs a set of multiplication +/// and accumulations on all corresponding complex numbers (one from \a a +/// and one from \a b). The imaginary part of the \a a element is multiplied +/// with the real part of the corresponding \a b element, and the real part +/// of the \a a element is multiplied with the imaginary part of the +/// corresponding \a b elements. The two accumulated results are added, and +/// then accumulated into the corresponding row and column of \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_cmmimfp16ps(__tile dst, __tile a, __tile b); +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO (a.colsb / 4) - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+1]) +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+0]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_cmmimfp16ps(dst, a, b) __builtin_ia32_tcmmimfp16ps(dst, a, b) + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles \a a and \a b is interpreted as a complex number +/// with FP16 real part and FP16 imaginary part. +/// Calculates the real part of the result. For each possible combination +/// of (row of \a a, column of \a b), it performs a set of multiplication +/// and accumulations on all corresponding complex numbers (one from \a a +/// and one from \a b). The real part of the \a a element is multiplied +/// with the real part of the corresponding \a b element, and the negated +/// imaginary part of the \a a element is multiplied with the imaginary +/// part of the corresponding \a b elements. The two accumulated results +/// are added, and then accumulated into the corresponding row and column +/// of \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_cmmrlfp16ps(__tile dst, __tile a, __tile b); +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO (a.colsb / 4) - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+0]) +/// tmp.fp32[n] += FP32(-a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+1]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_cmmrlfp16ps(dst, a, b) __builtin_ia32_tcmmrlfp16ps(dst, a, b) + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_COMPLEX +_tile_cmmimfp16ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tcmmimfp16ps_internal(m, n, k, dst, src1, src2); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_COMPLEX +_tile_cmmrlfp16ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tcmmrlfp16ps_internal(m, n, k, dst, src1, src2); +} + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles src0 and src1 is interpreted as a complex number with +/// FP16 real part and FP16 imaginary part. +/// This function calculates the imaginary part of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +static __inline__ void __DEFAULT_FN_ATTRS_COMPLEX +__tile_cmmimfp16ps(__tile1024i *dst, __tile1024i src0, __tile1024i src1) { + dst->tile = _tile_cmmimfp16ps_internal(src0.row, src1.col, src0.col, + dst->tile, src0.tile, src1.tile); +} + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles src0 and src1 is interpreted as a complex number with +/// FP16 real part and FP16 imaginary part. +/// This function calculates the real part of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCMMRLFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +static __inline__ void __DEFAULT_FN_ATTRS_COMPLEX +__tile_cmmrlfp16ps(__tile1024i *dst, __tile1024i src0, __tile1024i src1) { + dst->tile = _tile_cmmrlfp16ps_internal(src0.row, src1.col, src0.col, + dst->tile, src0.tile, src1.tile); +} + +#endif // __x86_64__ +#endif // __AMX_COMPLEXINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxcomplextransposeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxcomplextransposeintrin.h new file mode 100755 index 0000000..11abaf9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxcomplextransposeintrin.h @@ -0,0 +1,303 @@ +/*===----- amxcomplextransposeintrin.h - AMX-COMPLEX and AMX-TRANSPOSE ------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AMX_COMPLEXTRANSPOSEINTRIN_H +#define __AMX_COMPLEXTRANSPOSEINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("amx-complex,amx-transpose"))) + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles \a a and \a b is interpreted as a complex number +/// with FP16 real part and FP16 imaginary part. +/// Calculates the imaginary part of the result. For each possible combination +/// of (transposed column of \a a, column of \a b), it performs a set of +/// multiplication and accumulations on all corresponding complex numbers +/// (one from \a a and one from \a b). The imaginary part of the \a a element +/// is multiplied with the real part of the corresponding \a b element, and +/// the real part of the \a a element is multiplied with the imaginary part +/// of the corresponding \a b elements. The two accumulated results are +/// added, and then accumulated into the corresponding row and column of +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_tcmmimfp16ps(__tile dst, __tile a, __tile b); +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO a.rows - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+1]) +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+0]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TTCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_tcmmimfp16ps(dst, a, b) \ + __builtin_ia32_ttcmmimfp16ps((dst), (a), (b)) + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles \a a and \a b is interpreted as a complex number +/// with FP16 real part and FP16 imaginary part. +/// Calculates the real part of the result. For each possible combination +/// of (rtransposed colum of \a a, column of \a b), it performs a set of +/// multiplication and accumulations on all corresponding complex numbers +/// (one from \a a and one from \a b). The real part of the \a a element is +/// multiplied with the real part of the corresponding \a b element, and the +/// negated imaginary part of the \a a element is multiplied with the +/// imaginary part of the corresponding \a b elements. The two accumulated +/// results are added, and then accumulated into the corresponding row and +/// column of \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_tcmmrlfp16ps(__tile dst, __tile a, __tile b); +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO a.rows - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+0]) +/// tmp.fp32[n] += FP32(-a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+1]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TTCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_tcmmrlfp16ps(dst, a, b) \ + __builtin_ia32_ttcmmrlfp16ps((dst), (a), (b)) + +/// Perform matrix conjugate transpose and multiplication of two tiles +/// containing complex elements and accumulate the results into a packed +/// single precision tile. Each dword element in input tiles \a a and \a b +/// is interpreted as a complex number with FP16 real part and FP16 imaginary +/// part. +/// Calculates the imaginary part of the result. For each possible combination +/// of (transposed column of \a a, column of \a b), it performs a set of +/// multiplication and accumulations on all corresponding complex numbers +/// (one from \a a and one from \a b). The negated imaginary part of the \a a +/// element is multiplied with the real part of the corresponding \a b +/// element, and the real part of the \a a element is multiplied with the +/// imaginary part of the corresponding \a b elements. The two accumulated +/// results are added, and then accumulated into the corresponding row and +/// column of \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_conjtcmmimfp16ps(__tile dst, __tile a, __tile b); +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO a.rows - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * FP32(b.row[k].fp16[2*n+1]) +/// tmp.fp32[n] += FP32(-a.row[m].fp16[2*k+1]) * FP32(b.row[k].fp16[2*n+0]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCONJTCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_conjtcmmimfp16ps(dst, a, b) \ + __builtin_ia32_tconjtcmmimfp16ps((dst), (a), (b)) + +/// Perform conjugate transpose of an FP16-pair of complex elements from \a a +/// and writes the result to \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_conjtfp16(__tile dst, __tile a); +/// \endcode +/// +/// \code{.operation} +/// FOR i := 0 TO dst.rows - 1 +/// FOR j := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp16[2*j+0] := a.row[j].fp16[2*i+0] +/// tmp.fp16[2*j+1] := -a.row[j].fp16[2*i+1] +/// ENDFOR +/// write_row_and_zero(dst, i, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TCONJTFP16 instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The source tile. Max size is 1024 Bytes. +#define _tile_conjtfp16(dst, a) __builtin_ia32_tconjtfp16((dst), (a)) + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS _tile_tcmmimfp16ps_internal( + unsigned short m, unsigned short n, unsigned short k, _tile1024i dst, + _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_ttcmmimfp16ps_internal(m, n, k, dst, src1, src2); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS _tile_tcmmrlfp16ps_internal( + unsigned short m, unsigned short n, unsigned short k, _tile1024i dst, + _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_ttcmmrlfp16ps_internal(m, n, k, dst, src1, src2); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS _tile_conjtcmmimfp16ps_internal( + unsigned short m, unsigned short n, unsigned short k, _tile1024i dst, + _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tconjtcmmimfp16ps_internal(m, n, k, dst, src1, src2); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS +_tile_conjtfp16_internal(unsigned short m, unsigned short n, _tile1024i src) { + return __builtin_ia32_tconjtfp16_internal(m, n, src); +} + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles src0 and src1 is interpreted as a complex number +/// with FP16 real part and FP16 imaginary part. +/// This function calculates the imaginary part of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TTCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static void __tile_tcmmimfp16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_tcmmimfp16ps_internal(src0.row, src1.col, src0.col, + dst->tile, src0.tile, src1.tile); +} + +/// Perform matrix multiplication of two tiles containing complex elements and +/// accumulate the results into a packed single precision tile. Each dword +/// element in input tiles src0 and src1 is interpreted as a complex number +/// with FP16 real part and FP16 imaginary part. +/// This function calculates the real part of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TTCMMRLFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static void __tile_tcmmrlfp16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_tcmmrlfp16ps_internal(src0.row, src1.col, src0.col, + dst->tile, src0.tile, src1.tile); +} + +/// Perform matrix conjugate transpose and multiplication of two tiles +/// containing complex elements and accumulate the results into a packed +/// single precision tile. Each dword element in input tiles src0 and src1 +/// is interpreted as a complex number with FP16 real part and FP16 imaginary +/// part. +/// This function calculates the imaginary part of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCONJTCMMIMFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static void __tile_conjtcmmimfp16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_conjtcmmimfp16ps_internal(src0.row, src1.col, src0.col, + dst->tile, src0.tile, src1.tile); +} + +/// Perform conjugate transpose of an FP16-pair of complex elements from src and +/// writes the result to dst. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TCONJTFP16 instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src +/// The source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static void __tile_conjtfp16(__tile1024i *dst, __tile1024i src) { + dst->tile = _tile_conjtfp16_internal(src.row, src.col, src.tile); +} + +#undef __DEFAULT_FN_ATTRS + +#endif // __x86_64__ +#endif // __AMX_COMPLEXTRANSPOSEINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp16intrin.h new file mode 100755 index 0000000..bb4bc31 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp16intrin.h @@ -0,0 +1,93 @@ +/*===------------- amxfp16intrin.h - AMX_FP16 intrinsics -*- C++ -*---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; use instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMX_FP16INTRIN_H +#define __AMX_FP16INTRIN_H +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-fp16"))) + +/// Compute dot-product of FP16 (16-bit) floating-point pairs in tiles \a a +/// and \a b, accumulating the intermediate single-precision (32-bit) +/// floating-point elements with elements in \a dst, and store the 32-bit +/// result back to tile \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_dpfp16ps (__tile dst, __tile a, __tile b) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO (a.colsb / 4) - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * +/// FP32(b.row[k].fp16[2*n+0]) +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+1]) * +/// FP32(b.row[k].fp16[2*n+1]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TDPFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpfp16ps(dst, a, b) \ + __builtin_ia32_tdpfp16ps(dst, a, b) + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS +_tile_dpfp16ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpfp16ps_internal(m, n, k, dst, src1, src2); +} + +/// Compute dot-product of FP16 (16-bit) floating-point pairs in tiles src0 and +/// src1, accumulating the intermediate single-precision (32-bit) floating-point +/// elements with elements in "dst", and store the 32-bit result back to tile +/// "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static __inline__ void __tile_dpfp16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_dpfp16ps_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __x86_64__ */ +#endif /* __AMX_FP16INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp16transposeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp16transposeintrin.h new file mode 100755 index 0000000..191f8c6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp16transposeintrin.h @@ -0,0 +1,94 @@ +/*===----- amxfp16transposeintrin.h - AMX-FP16 and AMX-TRANSPOSE ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; use instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMX_FP16TRANSPOSEINTRIN_H +#define __AMX_FP16TRANSPOSEINTRIN_H +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("amx-fp16,amx-transpose"))) + +/// Compute transpose and dot-product of FP16 (16-bit) floating-point pairs in +/// tiles \a a and \a b, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in \a dst, and store the +/// 32-bit result back to tile \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_tdpfp16ps (__tile dst, __tile a, __tile b) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// tmp := dst.row[m] +/// FOR k := 0 TO (a.colsb / 4) - 1 +/// FOR n := 0 TO (dst.colsb / 4) - 1 +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+0]) * +/// FP32(b.row[k].fp16[2*n+0]) +/// tmp.fp32[n] += FP32(a.row[m].fp16[2*k+1]) * +/// FP32(b.row[k].fp16[2*n+1]) +/// ENDFOR +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// ENDFOR +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TTDPFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_tdpfp16ps(dst, a, b) __builtin_ia32_ttdpfp16ps((dst), (a), (b)) + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS +_tile_tdpfp16ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_ttdpfp16ps_internal(m, n, k, dst, src1, src2); +} + +/// Compute transpose and dot-product of FP16 (16-bit) floating-point pairs in +/// tiles src0 and src1, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in "dst", and store the +/// 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TTDPFP16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS +static __inline__ void __tile_tdpfp16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_tdpfp16ps_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __x86_64__ */ +#endif /* __AMX_FP16TRANSPOSEINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp8intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp8intrin.h new file mode 100755 index 0000000..92e7989 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxfp8intrin.h @@ -0,0 +1,230 @@ +/*===------------- amxfp8intrin.h - AMX intrinsics -*- C++ -*----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMXFP8INTRIN_H +#define __AMXFP8INTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS_FP8 \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-fp8"))) + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_FP8 +_tile_dpbf8ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbf8ps_internal(m, n, k, dst, src1, src2); +} + +/// Perform the dot product of a BF8 value \a src1 by a BF8 value \a src2 +/// accumulating into a Single Precision (FP32) source/dest \a dst. +/// +/// \headerfile +/// +/// \code +/// void __tile_dpbf8ps (__tile1024i *dst, __tile1024i src1, __tile1024i src2) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// temp1[(dst.colsb / 4 - 1) : 0] = 0 +/// FOR k := 0 TO src1.colsb / 4 - 1 +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// temp1[n] += +/// INT64(src1.row[m].float8[4*k+0]) * INT64(src2.row[k].float8[4*n+0]) +/// + INT64(src1.row[m].float8[4*k+1]) * INT64(src2.row[k].float8[4*n+1]) +/// + INT64(src1.row[m].float8[4*k+2]) * INT64(src2.row[k].float8[4*n+2]) +/// + INT64(src1.row[m].float8[4*k+3]) * INT64(src2.row[k].float8[4*n+3]) +/// ENDFOR +/// ENDFOR +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// tmp.row[m].fp32[n] = dst.row[m].fp32[n] + FP32(temp1[n]) +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TDPBF8PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src1 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src2 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_FP8 static void +__tile_dpbf8ps(__tile1024i *dst, __tile1024i src1, __tile1024i src2) { + dst->tile = _tile_dpbf8ps_internal(src1.row, src2.col, src1.col, dst->tile, + src1.tile, src2.tile); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_FP8 +_tile_dpbhf8ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbhf8ps_internal(m, n, k, dst, src1, src2); +} + +/// Perform the dot product of a BF8 value \a src1 by an HF8 value \a src2 +/// accumulating into a Single Precision (FP32) source/dest \a dst. +/// +/// \headerfile +/// +/// \code +/// void __tile_dpbhf8ps (__tile1024i dst, __tile1024i src1, __tile1024i src2) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// temp1[(dst.colsb / 4 - 1) : 0] = 0 +/// FOR k := 0 TO src1.colsb / 4 - 1 +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// temp1[n] += +/// INT64(src1.row[m].float8[4*k+0]) * INT64(src2.row[k].float8[4*n+0]) +/// + INT64(src1.row[m].float8[4*k+1]) * INT64(src2.row[k].float8[4*n+1]) +/// + INT64(src1.row[m].float8[4*k+2]) * INT64(src2.row[k].float8[4*n+2]) +/// + INT64(src1.row[m].float8[4*k+3]) * INT64(src2.row[k].float8[4*n+3]) +/// ENDFOR +/// ENDFOR +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// tmp.row[m].fp32[n] = dst.row[m].fp32[n] + FP32(temp1[n]) +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TDPBHF8PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src1 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src2 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_FP8 static void +__tile_dpbhf8ps(__tile1024i *dst, __tile1024i src1, __tile1024i src2) { + dst->tile = _tile_dpbhf8ps_internal(src1.row, src2.col, src1.col, dst->tile, + src1.tile, src2.tile); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_FP8 +_tile_dphbf8ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdphbf8ps_internal(m, n, k, dst, src1, src2); +} + +/// Perform the dot product of an HF8 value \a src1 by a BF8 value \a src2 +/// accumulating into a Single Precision (FP32) source/dest \a dst. +/// +/// \headerfile +/// +/// \code +/// void __tile_dphbf8ps (__tile1024i dst, __tile1024i src1, __tile1024i src2) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// temp1[(dst.colsb / 4 - 1) : 0] = 0 +/// FOR k := 0 TO src1.colsb / 4 - 1 +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// temp1[n] += +/// INT64(src1.row[m].float8[4*k+0]) * INT64(src2.row[k].float8[4*n+0]) +/// + INT64(src1.row[m].float8[4*k+1]) * INT64(src2.row[k].float8[4*n+1]) +/// + INT64(src1.row[m].float8[4*k+2]) * INT64(src2.row[k].float8[4*n+2]) +/// + INT64(src1.row[m].float8[4*k+3]) * INT64(src2.row[k].float8[4*n+3]) +/// ENDFOR +/// ENDFOR +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// tmp.row[m].fp32[n] = dst.row[m].fp32[n] + FP32(temp1[n]) +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TDPHBF8PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src1 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src2 +/// The 2nd source tile. Max size is 1024 Bytes. + +__DEFAULT_FN_ATTRS_FP8 static void +__tile_dphbf8ps(__tile1024i *dst, __tile1024i src1, __tile1024i src2) { + dst->tile = _tile_dphbf8ps_internal(src1.row, src2.col, src1.col, dst->tile, + src1.tile, src2.tile); +} + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_FP8 +_tile_dphf8ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdphf8ps_internal(m, n, k, dst, src1, src2); +} + +/// Perform the dot product of an HF8 value \a src1 by an HF8 value \a src2 +/// accumulating into a Single Precision (FP32) source/dest \a dst. +/// +/// \headerfile +/// +/// \code +/// void __tile_dphf8ps (__tile1024i dst, __tile1024i src1, __tile1024i src2) +/// \endcode +/// +/// \code{.operation} +/// FOR m := 0 TO dst.rows - 1 +/// temp1[(dst.colsb / 4 - 1) : 0] = 0 +/// FOR k := 0 TO src1.colsb / 4 - 1 +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// temp1[n] += +/// INT64(src1.row[m].float8[4*k+0]) * INT64(src2.row[k].float8[4*n+0]) +/// + INT64(src1.row[m].float8[4*k+1]) * INT64(src2.row[k].float8[4*n+1]) +/// + INT64(src1.row[m].float8[4*k+2]) * INT64(src2.row[k].float8[4*n+2]) +/// + INT64(src1.row[m].float8[4*k+3]) * INT64(src2.row[k].float8[4*n+3]) +/// ENDFOR +/// ENDFOR +/// FOR n := 0 TO dst.colsb / 4 - 1 +/// tmp.row[m].fp32[n] = dst.row[m].fp32[n] + FP32(temp1[n]) +/// ENDFOR +/// write_row_and_zero(dst, m, tmp, dst.colsb) +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +/// +/// This intrinsic corresponds to the \c TDPHF8PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src1 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src2 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_FP8 static void +__tile_dphf8ps(__tile1024i *dst, __tile1024i src1, __tile1024i src2) { + dst->tile = _tile_dphf8ps_internal(src1.row, src2.col, src1.col, dst->tile, + src1.tile, src2.tile); +} + +#define _tile_dpbf8ps(dst, src1, src2) \ + __builtin_ia32_tdpbf8ps((dst), (src1), (src2)) +#define _tile_dpbhf8ps(dst, src1, src2) \ + __builtin_ia32_tdpbhf8ps((dst), (src1), (src2)) +#define _tile_dphbf8ps(dst, src1, src2) \ + __builtin_ia32_tdphbf8ps((dst), (src1), (src2)) +#define _tile_dphf8ps(dst, src1, src2) \ + __builtin_ia32_tdphf8ps((dst), (src1), (src2)) + +#undef __DEFAULT_FN_ATTRS_FP8 + +#endif /* __x86_64__ */ +#endif /* __AMXFP8INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxintrin.h new file mode 100755 index 0000000..a7da10d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxintrin.h @@ -0,0 +1,494 @@ +/*===--------------- amxintrin.h - AMX intrinsics -*- C/C++ -*---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMXINTRIN_H +#define __AMXINTRIN_H +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS_TILE \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-tile"))) +#define __DEFAULT_FN_ATTRS_INT8 \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-int8"))) +#define __DEFAULT_FN_ATTRS_BF16 \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-bf16"))) + +/// Load tile configuration from a 64-byte memory location specified by +/// "mem_addr". The tile configuration includes the tile type palette, the +/// number of bytes per row, and the number of rows. If the specified +/// palette_id is zero, that signifies the init state for both the tile +/// config and the tile data, and the tiles are zeroed. Any invalid +/// configurations will result in #GP fault. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LDTILECFG instruction. +/// +/// \param __config +/// A pointer to 512-bits configuration +static __inline__ void __DEFAULT_FN_ATTRS_TILE +_tile_loadconfig(const void *__config) { + __builtin_ia32_tile_loadconfig(__config); +} + +/// Stores the current tile configuration to a 64-byte memory location +/// specified by "mem_addr". The tile configuration includes the tile type +/// palette, the number of bytes per row, and the number of rows. If tiles +/// are not configured, all zeroes will be stored to memory. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the STTILECFG instruction. +/// +/// \param __config +/// A pointer to 512-bits configuration +static __inline__ void __DEFAULT_FN_ATTRS_TILE +_tile_storeconfig(void *__config) { + __builtin_ia32_tile_storeconfig(__config); +} + +/// Release the tile configuration to return to the init state, which +/// releases all storage it currently holds. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILERELEASE instruction. +static __inline__ void __DEFAULT_FN_ATTRS_TILE _tile_release(void) { + __builtin_ia32_tilerelease(); +} + +/// Load tile rows from memory specifieid by "base" address and "stride" into +/// destination tile "dst" using the tile configuration previously configured +/// via "_tile_loadconfig". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILELOADD instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +#define _tile_loadd(dst, base, stride) \ + __builtin_ia32_tileloadd64((dst), ((const void *)(base)), \ + (__SIZE_TYPE__)(stride)) + +/// Load tile rows from memory specifieid by "base" address and "stride" into +/// destination tile "dst" using the tile configuration previously configured +/// via "_tile_loadconfig". This intrinsic provides a hint to the implementation +/// that the data will likely not be reused in the near future and the data +/// caching can be optimized accordingly. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILELOADDT1 instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +#define _tile_stream_loadd(dst, base, stride) \ + __builtin_ia32_tileloaddt164((dst), ((const void *)(base)), \ + (__SIZE_TYPE__)(stride)) + +/// Store the tile specified by "src" to memory specifieid by "base" address and +/// "stride" using the tile configuration previously configured via +/// "_tile_loadconfig". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILESTORED instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be stored in memory. +#define _tile_stored(dst, base, stride) \ + __builtin_ia32_tilestored64((dst), ((void *)(base)), (__SIZE_TYPE__)(stride)) + +/// Zero the tile specified by "tdest". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILEZERO instruction. +/// +/// \param tile +/// The destination tile to be zero. Max size is 1024 Bytes. +#define _tile_zero(tile) __builtin_ia32_tilezero((tile)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in src0 with +/// corresponding signed 8-bit integers in src1, producing 4 intermediate 32-bit +/// results. Sum these 4 results with the corresponding 32-bit integer in "dst", +/// and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBSSD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbssd(dst, src0, src1) \ + __builtin_ia32_tdpbssd((dst), (src0), (src1)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in src0 with +/// corresponding unsigned 8-bit integers in src1, producing 4 intermediate +/// 32-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in "dst", and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBSUD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbsud(dst, src0, src1) \ + __builtin_ia32_tdpbsud((dst), (src0), (src1)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in src0 with +/// corresponding signed 8-bit integers in src1, producing 4 intermediate 32-bit +/// results. Sum these 4 results with the corresponding 32-bit integer in "dst", +/// and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBUSD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbusd(dst, src0, src1) \ + __builtin_ia32_tdpbusd((dst), (src0), (src1)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in src0 with +/// corresponding unsigned 8-bit integers in src1, producing 4 intermediate +/// 32-bit results. Sum these 4 results with the corresponding 32-bit integer in +/// "dst", and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBUUD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbuud(dst, src0, src1) \ + __builtin_ia32_tdpbuud((dst), (src0), (src1)) + +/// Compute dot-product of BF16 (16-bit) floating-point pairs in tiles src0 and +/// src1, accumulating the intermediate single-precision (32-bit) floating-point +/// elements with elements in "dst", and store the 32-bit result back to tile +/// "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBF16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbf16ps(dst, src0, src1) \ + __builtin_ia32_tdpbf16ps((dst), (src0), (src1)) + +/// AMX tile register size can be configured, the maximum size is 16x64=1024 +/// bytes. Since there is no 2D type in llvm IR, we use vector type to +/// represent 2D tile and the fixed size is maximum amx tile register size. +typedef int _tile1024i __attribute__((__vector_size__(1024), __aligned__(64))); +typedef int _tile1024i_1024a + __attribute__((__vector_size__(1024), __aligned__(1024))); + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_TILE +_tile_loadd_internal(unsigned short m, unsigned short n, const void *base, + __SIZE_TYPE__ stride) { + return __builtin_ia32_tileloadd64_internal(m, n, base, + (__SIZE_TYPE__)(stride)); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_TILE +_tile_loaddt1_internal(unsigned short m, unsigned short n, const void *base, + __SIZE_TYPE__ stride) { + return __builtin_ia32_tileloaddt164_internal(m, n, base, + (__SIZE_TYPE__)(stride)); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8 +_tile_dpbssd_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbssd_internal(m, n, k, dst, src1, src2); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8 +_tile_dpbsud_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbsud_internal(m, n, k, dst, src1, src2); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8 +_tile_dpbusd_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbusd_internal(m, n, k, dst, src1, src2); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_INT8 +_tile_dpbuud_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbuud_internal(m, n, k, dst, src1, src2); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ void __DEFAULT_FN_ATTRS_TILE +_tile_stored_internal(unsigned short m, unsigned short n, void *base, + __SIZE_TYPE__ stride, _tile1024i tile) { + return __builtin_ia32_tilestored64_internal(m, n, base, + (__SIZE_TYPE__)(stride), tile); +} + +/// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_BF16 +_tile_dpbf16ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tdpbf16ps_internal(m, n, k, dst, src1, src2); +} + +/// This struct pack the shape and tile data together for user. We suggest +/// initializing the struct as early as possible, because compiler depends +/// on the shape information to do configure. The constant value is preferred +/// for optimization by compiler. +typedef struct __tile1024i_str { + const unsigned short row; + const unsigned short col; + _tile1024i tile; +} __tile1024i; + +/// Load tile rows from memory specifieid by "base" address and "stride" into +/// destination tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILELOADD instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS_TILE +static __inline__ void __tile_loadd(__tile1024i *dst, const void *base, + __SIZE_TYPE__ stride) { + dst->tile = _tile_loadd_internal(dst->row, dst->col, base, stride); +} + +/// Load tile rows from memory specifieid by "base" address and "stride" into +/// destination tile "dst". This intrinsic provides a hint to the implementation +/// that the data will likely not be reused in the near future and the data +/// caching can be optimized accordingly. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILELOADDT1 instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS_TILE +static __inline__ void __tile_stream_loadd(__tile1024i *dst, const void *base, + __SIZE_TYPE__ stride) { + dst->tile = _tile_loaddt1_internal(dst->row, dst->col, base, stride); +} + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in src0 with +/// corresponding signed 8-bit integers in src1, producing 4 intermediate 32-bit +/// results. Sum these 4 results with the corresponding 32-bit integer in "dst", +/// and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBSSD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_INT8 +static __inline__ void __tile_dpbssd(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_dpbssd_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in src0 with +/// corresponding unsigned 8-bit integers in src1, producing 4 intermediate +/// 32-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in "dst", and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBSUD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_INT8 +static __inline__ void __tile_dpbsud(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_dpbsud_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in src0 with +/// corresponding signed 8-bit integers in src1, producing 4 intermediate 32-bit +/// results. Sum these 4 results with the corresponding 32-bit integer in "dst", +/// and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBUSD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_INT8 +static __inline__ void __tile_dpbusd(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_dpbusd_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in src0 with +/// corresponding unsigned 8-bit integers in src1, producing 4 intermediate +/// 32-bit results. Sum these 4 results with the corresponding 32-bit integer in +/// "dst", and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBUUD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_INT8 +static __inline__ void __tile_dpbuud(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_dpbuud_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +/// Store the tile specified by "src" to memory specifieid by "base" address and +/// "stride". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILESTORED instruction. +/// +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be stored in memory. +__DEFAULT_FN_ATTRS_TILE +static __inline__ void __tile_stored(void *base, __SIZE_TYPE__ stride, + __tile1024i src) { + _tile_stored_internal(src.row, src.col, base, stride, src.tile); +} + +/// Zero the tile specified by "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILEZERO instruction. +/// +/// \param dst +/// The destination tile to be zero. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_TILE +static __inline__ void __tile_zero(__tile1024i *dst) { + dst->tile = __builtin_ia32_tilezero_internal(dst->row, dst->col); +} + +/// Compute dot-product of BF16 (16-bit) floating-point pairs in tiles src0 and +/// src1, accumulating the intermediate single-precision (32-bit) floating-point +/// elements with elements in "dst", and store the 32-bit result back to tile +/// "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBF16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_BF16 +static __inline__ void __tile_dpbf16ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_dpbf16ps_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +#undef __DEFAULT_FN_ATTRS_TILE +#undef __DEFAULT_FN_ATTRS_INT8 +#undef __DEFAULT_FN_ATTRS_BF16 + +#endif /* __x86_64__ */ +#endif /* __AMXINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxmovrsintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxmovrsintrin.h new file mode 100755 index 0000000..5fe2fde --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxmovrsintrin.h @@ -0,0 +1,48 @@ +/*===-------- amxmovrsintrin.h - AMX MOVRS intrinsics -*- C++ -*---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * ===-------------------------------------------------------------------=== */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMXMOVRSINTRIN_H +#define __AMXMOVRSINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS_MOVRS \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-movrs"))) + +#define _tile_loaddrs(dst, base, stride) \ + __builtin_ia32_tileloaddrs64((dst), ((const void *)(base)), \ + (__SIZE_TYPE__)(stride)) +#define _tile_stream_loaddrs(dst, base, stride) \ + __builtin_ia32_tileloaddrst164((dst), ((const void *)(base)), \ + (__SIZE_TYPE__)(stride)) +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_MOVRS +_tile_loaddrs_internal(unsigned short m, unsigned short n, const void *base, + __SIZE_TYPE__ stride) { + return __builtin_ia32_tileloaddrs64_internal(m, n, base, + (__SIZE_TYPE__)(stride)); +} +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_MOVRS +_tile_loaddrst1_internal(unsigned short m, unsigned short n, const void *base, + __SIZE_TYPE__ stride) { + return __builtin_ia32_tileloaddrst164_internal(m, n, base, + (__SIZE_TYPE__)(stride)); +} +static __inline__ void __DEFAULT_FN_ATTRS_MOVRS +__tile_loaddrs(__tile1024i *dst, const void *base, __SIZE_TYPE__ stride) { + dst->tile = _tile_loaddrs_internal(dst->row, dst->col, base, stride); +} +static __inline__ void __DEFAULT_FN_ATTRS_MOVRS __tile_stream_loaddrs( + __tile1024i *dst, const void *base, __SIZE_TYPE__ stride) { + dst->tile = _tile_loaddrst1_internal(dst->row, dst->col, base, stride); +} +#undef __DEFAULT_FN_ATTRS_MOVRS +#endif /* __x86_64__ */ +#endif /* __AMXMOVRSINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxmovrstransposeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxmovrstransposeintrin.h new file mode 100755 index 0000000..5f48cba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxmovrstransposeintrin.h @@ -0,0 +1,200 @@ +/* ===--- amxmovrstransposeintrin.h - AMX_MOVRS_TRANSPOSE intrinsics --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * ===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; use instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMX_MOVRS_TRANSPOSEINTRIN_H +#define __AMX_MOVRS_TRANSPOSEINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("amx-transpose,amx-movrs"))) + +#define _tile_2rpntlvwz0rs(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz0rs(tdst, base, stride) +#define _tile_2rpntlvwz0rst1(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz0rst1(tdst, base, stride) +#define _tile_2rpntlvwz1rs(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz1rs(tdst, base, stride) +#define _tile_2rpntlvwz1rst1(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz1rst1(tdst, base, stride) + +static __inline__ void __DEFAULT_FN_ATTRS _tile_2rpntlvwz0rs_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + // Use __tile1024i_1024a* to escape the alignment check in + // clang/test/Headers/x86-intrinsics-headers-clean.cpp + __builtin_ia32_t2rpntlvwz0rs_internal( + row, col0, col1, (_tile1024i_1024a *)dst0, (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +static __inline__ void __DEFAULT_FN_ATTRS _tile_2rpntlvwz0rst1_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + __builtin_ia32_t2rpntlvwz0rst1_internal( + row, col0, col1, (_tile1024i_1024a *)dst0, (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +static __inline__ void __DEFAULT_FN_ATTRS _tile_2rpntlvwz1rs_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + __builtin_ia32_t2rpntlvwz1rs_internal( + row, col0, col1, (_tile1024i_1024a *)dst0, (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +static __inline__ void __DEFAULT_FN_ATTRS _tile_2rpntlvwz1rst1_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + __builtin_ia32_t2rpntlvwz1rst1_internal( + row, col0, col1, (_tile1024i_1024a *)dst0, (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. +/// Provides a hint to the implementation that the data will likely become +/// read shared in the near future and the data caching can be optimized. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ0RS instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS +static void __tile_2rpntlvwz0rs(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz0rs_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ0T1RS instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS +static void __tile_2rpntlvwz0rst1(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz0rst1_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. The last row will be not be read from memory but instead +/// filled with zeros. +/// Provides a hint to the implementation that the data will likely become +/// read shared in the near future and the data caching can be optimized. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ1 instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS +static void __tile_2rpntlvwz1rs(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz1rs_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. The last row will be not be read from memory but instead +/// filled with zeros. +/// Provides a hint to the implementation that the data will likely become +/// read shared in the near future and the data caching can be optimized. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ1T1RS instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS +static void __tile_2rpntlvwz1rst1(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz1rst1_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +#undef __DEFAULT_FN_ATTRS +#endif /* __x86_64__ */ +#endif /* __AMX_MOVRS_TRANSPOSEINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtf32intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtf32intrin.h new file mode 100755 index 0000000..44d002c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtf32intrin.h @@ -0,0 +1,108 @@ +/*===------------- amxtf32intrin.h - AMX_TF32 intrinsics -*- C++ -*---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AMX_TF32INTRIN_H +#define __AMX_TF32INTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS_TF32 \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-tf32"))) + +/// Do Matrix Multiplication of \a a and \a b, and then do Matrix Plus +/// with \a srcdst. +/// All the calculation is base on float32 but with the lower 13-bit set to 0. +/// +/// \headerfile +/// +/// \code +/// void _tile_mmultf32ps(constexpr int srcdst, constexpr int a, \ +/// constexpr int b); +/// \endcode +/// +/// This intrinsic corresponds to the TMMULTF32PS instruction. +/// +/// \param srcdst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +/// +/// \code{.operation} +/// DEFINE zero_lower_mantissa_bits_fp32(x[31:0]) { +/// dword[12:0] := 0 +/// dword[31:13] := x[31:13] +/// return dword +/// } +/// +/// DEFINE silence_snan_fp32(x[31:0]) { +/// IF (x.exponent == 255 and x.fraction != 0 and x.fraction[22] == 0) +/// x.fraction[22] := 1 +/// return x +/// } +/// +/// elements_a := a.colsb / 4 +/// elements_dest := srcdst.colsb / 4 +/// +/// FOR m = 0 TO (srcdst.rows-1) +/// tmp[511:0] := 0 +/// FOR k = 0 TO (elements_a-1) +/// FOR n = 0 TO (elements_dest-1) +/// af := silence_snan_fp32(a.row[m].fp32[k]) +/// bf := silence_snan_fp32(b.row[k].fp32[n]) +/// tmp.fp32[n] += zero_lower_mantissa_bits_fp32(af) +/// * zero_lower_mantissa_bits_fp32(bf) +/// ENDFOR +/// ENDFOR +/// +/// FOR n = 0 TO (elements_dest-1) +/// tmp.fp32[n] += srcdst.row[m].fp32[n] +/// ENDFOR +/// write_row_and_zero(srcdst, m, tmp, srcdst.colsb) +/// +/// ENDFOR +/// +/// zero_upper_rows(srcdst, srcdst.rows) +/// zero_tileconfig_start() +/// \endcode +#define _tile_mmultf32ps(srcdst, a, b) \ + __builtin_ia32_tmmultf32ps((srcdst), (a), (b)) + +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_TF32 +_tile_mmultf32ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_tmmultf32ps_internal(m, n, k, dst, src1, src2); +} + +/// Do Matrix Multiplication of src0 and src1, and then do Matrix Plus with dst. +/// All the calculation is base on float32 but with the lower 13-bit set to 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TMMULTF32PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_TF32 +static void __tile_mmultf32ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_mmultf32ps_internal(src0.row, src1.col, src0.col, dst->tile, + src0.tile, src1.tile); +} + +#endif // __x86_64__ +#endif // __AMX_TF32INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtf32transposeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtf32transposeintrin.h new file mode 100755 index 0000000..e1b90c1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtf32transposeintrin.h @@ -0,0 +1,105 @@ +/*===--------- amxtf32transposeintrin.h - AMX-TF32 and AMX-TRANSPOSE --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AMX_TF32TRANSPOSEINTRIN_H +#define __AMX_TF32TRANSPOSEINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS_TF32_TRANSPOSE \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("amx-tf32,amx-transpose"))) + +/// \code +/// void _tile_tmmultf32ps(constexpr int srcdst, constexpr int a, \ +/// constexpr int b); +/// \endcode +/// +/// This intrinsic corresponds to the TTMMULTF32PS instruction. +/// +/// \param srcdst +/// The destination tile. Max size is 1024 Bytes. +/// \param a +/// The 1st source tile. Max size is 1024 Bytes. +/// \param b +/// The 2nd source tile. Max size is 1024 Bytes. +/// +/// \code{.operation} +/// DEFINE zero_lower_mantissa_bits_fp32(x[31:0]) { +/// dword[12:0] := 0 +/// dword[31:13] := x[31:13] +/// return dword +/// } +/// +/// DEFINE silence_snan_fp32(x[31:0]) { +/// IF (x.exponent == 255 and x.fraction != 0 and x.fraction[22] == 0) +/// x.fraction[22] := 1 +/// return x +/// } +/// +/// elements_dest:= srcdst.colsb/4 +/// +/// FOR m := 0 TO (srcdst.rows-1) +/// tmp[511:0] := 0 +/// FOR k := 0 TO (a.rows-1) +/// FOR n := 0 TO (elements_dest-1) +/// a1e := silence_snan_fp32(a.row[k].fp32[m]) +/// a2e := silence_snan_fp32(b.row[k].fp32[n]) +/// s1e := zero_lower_mantissa_bits_fp32(a1e) +/// s2e := zero_lower_mantissa_bits_fp32(a2e) +/// tmp.fp32[n] += s1e * s2e +/// ENDFOR +/// ENDFOR +/// +/// FOR n := 0 TO (elements_dest-1) +/// tmp.fp32[n] += srcdst.row[m].fp32[n] +/// ENDFOR +/// write_row_and_zero(srcdst, m, tmp, srcdst.colsb) +/// +/// ENDFOR +/// +/// zero_upper_rows(srcdst, srcdst.rows) +/// zero_tileconfig_start() +/// \endcode +#define _tile_tmmultf32ps(srcdst, a, b) \ + __builtin_ia32_ttmmultf32ps((srcdst), (a), (b)) + +// dst = m x n (srcdest), src1 = k x m, src2 = k x n +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_TF32_TRANSPOSE +_tile_tmmultf32ps_internal(unsigned short m, unsigned short n, unsigned short k, + _tile1024i dst, _tile1024i src1, _tile1024i src2) { + return __builtin_ia32_ttmmultf32ps_internal(m, n, k, dst, src1, src2); +} + +/// Compute transpose and do Matrix Multiplication of src0 and src1, and then do +/// Matrix Plus with dst. All the calculation is base on float32 but with the +/// lower 13-bit set to 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TTMMULTF32PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_TF32_TRANSPOSE +static void __tile_tmmultf32ps(__tile1024i *dst, __tile1024i src0, + __tile1024i src1) { + dst->tile = _tile_tmmultf32ps_internal(src0.row, src1.col, src0.col, + dst->tile, src0.tile, src1.tile); +} + +#endif // __x86_64__ +#endif // __AMX_TF32TRANSPOSEINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtransposeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtransposeintrin.h new file mode 100755 index 0000000..b3fa37d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/amxtransposeintrin.h @@ -0,0 +1,248 @@ +/* ===--- amxtransposeintrin.h - AMX_TRANSPOSE intrinsics -*- C++ -*---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * ===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; use instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMX_TRANSPOSEINTRIN_H +#define __AMX_TRANSPOSEINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS_TRANSPOSE \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-transpose"))) + +#define _tile_2rpntlvwz0(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz0(tdst, base, stride) +#define _tile_2rpntlvwz0t1(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz0t1(tdst, base, stride) +#define _tile_2rpntlvwz1(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz1(tdst, base, stride) +#define _tile_2rpntlvwz1t1(tdst, base, stride) \ + __builtin_ia32_t2rpntlvwz1t1(tdst, base, stride) + +/// Transpose 32-bit elements from \a src and write the result to \a dst. +/// +/// \headerfile +/// +/// \code +/// void _tile_transposed(__tile dst, __tile src); +/// \endcode +/// +/// This intrinsic corresponds to the TTRANSPOSED instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src +/// The source tile. Max size is 1024 Bytes. +/// +/// \code{.operation} +/// +/// FOR i := 0 TO (dst.rows-1) +/// tmp[511:0] := 0 +/// FOR j := 0 TO (dst.colsb/4-1) +/// tmp.dword[j] := src.row[j].dword[i] +/// ENDFOR +/// dst.row[i] := tmp +/// ENDFOR +/// +/// zero_upper_rows(dst, dst.rows) +/// zero_tileconfig_start() +/// \endcode +#define _tile_transposed(dst, src) __builtin_ia32_ttransposed(dst, src) + +static __inline__ void __DEFAULT_FN_ATTRS_TRANSPOSE _tile_2rpntlvwz0_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + // Use __tile1024i_1024a* to escape the alignment check in + // clang/test/Headers/x86-intrinsics-headers-clean.cpp + __builtin_ia32_t2rpntlvwz0_internal(row, col0, col1, (_tile1024i_1024a *)dst0, + (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +static __inline__ void __DEFAULT_FN_ATTRS_TRANSPOSE _tile_2rpntlvwz0t1_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + __builtin_ia32_t2rpntlvwz0t1_internal( + row, col0, col1, (_tile1024i_1024a *)dst0, (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +static __inline__ void __DEFAULT_FN_ATTRS_TRANSPOSE _tile_2rpntlvwz1_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + __builtin_ia32_t2rpntlvwz1_internal(row, col0, col1, (_tile1024i_1024a *)dst0, + (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +static __inline__ void __DEFAULT_FN_ATTRS_TRANSPOSE _tile_2rpntlvwz1t1_internal( + unsigned short row, unsigned short col0, unsigned short col1, + _tile1024i *dst0, _tile1024i *dst1, const void *base, + __SIZE_TYPE__ stride) { + __builtin_ia32_t2rpntlvwz1t1_internal( + row, col0, col1, (_tile1024i_1024a *)dst0, (_tile1024i_1024a *)dst1, base, + (__SIZE_TYPE__)(stride)); +} + +// This is internal intrinsic. C/C++ user should avoid calling it directly. +static __inline__ _tile1024i __DEFAULT_FN_ATTRS_TRANSPOSE +_tile_transposed_internal(unsigned short m, unsigned short n, _tile1024i src) { + return __builtin_ia32_ttransposed_internal(m, n, src); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. +/// Provides a hint to the implementation that the data will likely not be +/// reused in the near future and the data caching can be optimized. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ0 instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS_TRANSPOSE +static void __tile_2rpntlvwz0(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz0_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ0T1 instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS_TRANSPOSE +static void __tile_2rpntlvwz0t1(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz0t1_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. The last row will be not be read from memory but instead +/// filled with zeros. +/// Provides a hint to the implementation that the data will likely not be +/// reused in the near future and the data caching can be optimized. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ1 instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS_TRANSPOSE +static void __tile_2rpntlvwz1(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz1_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Converts a pair of tiles from memory into VNNI format, and places the +/// results in a pair of destinations specified by dst. The pair of tiles +/// in memory is specified via a tsib; the second tile is after the first +/// one, separated by the same stride that separates each row. +/// The tile configuration for the destination tiles indicates the amount +/// of data to read from memory. The instruction will load a number of rows +/// that is equal to twice the number of rows in tmm1. The size of each row +/// is equal to the average width of the destination tiles. If the second +/// tile is configured with zero rows and columns, only the first tile will +/// be written. The last row will be not be read from memory but instead +/// filled with zeros. +/// Provides a hint to the implementation that the data will likely not be +/// reused in the near future and the data caching can be optimized. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the T2RPNTLVWZ1T1 instruction. +/// +/// \param dst0 +/// First tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param dst1 +/// Second tile of destination tile pair. Max size is 1024i*2 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +__DEFAULT_FN_ATTRS_TRANSPOSE +static void __tile_2rpntlvwz1t1(__tile1024i *dst0, __tile1024i *dst1, + const void *base, __SIZE_TYPE__ stride) { + _tile_2rpntlvwz1t1_internal(dst0->row, dst0->col, dst1->col, &dst0->tile, + &dst1->tile, base, stride); +} + +/// Transpose 32-bit elements from src and write the result to dst. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TTRANSPOSED instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src +/// The source tile. Max size is 1024 Bytes. +__DEFAULT_FN_ATTRS_TRANSPOSE +static void __tile_transposed(__tile1024i *dst, __tile1024i src) { + dst->tile = _tile_transposed_internal(dst->row, dst->col, src.tile); +} + +#endif /* __x86_64__ */ +#endif /* __AMX_TRANSPOSEINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/andes_vector.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/andes_vector.h new file mode 100755 index 0000000..dc717e6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/andes_vector.h @@ -0,0 +1,16 @@ +//===----- andes_vector.h - Andes Vector definitions ----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _ANDES_VECTOR_H_ +#define _ANDES_VECTOR_H_ + +#include "riscv_vector.h" + +#pragma clang riscv intrinsic andes_vector + +#endif //_ANDES_VECTOR_H_ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm64intr.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm64intr.h new file mode 100755 index 0000000..4943b2d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm64intr.h @@ -0,0 +1,35 @@ +/*===---- arm64intr.h - ARM64 Windows intrinsics -------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Only include this if we're compiling for the windows platform. */ +#ifndef _MSC_VER +#include_next +#else + +#ifndef __ARM64INTR_H +#define __ARM64INTR_H + +typedef enum +{ + _ARM64_BARRIER_SY = 0xF, + _ARM64_BARRIER_ST = 0xE, + _ARM64_BARRIER_LD = 0xD, + _ARM64_BARRIER_ISH = 0xB, + _ARM64_BARRIER_ISHST = 0xA, + _ARM64_BARRIER_ISHLD = 0x9, + _ARM64_BARRIER_NSH = 0x7, + _ARM64_BARRIER_NSHST = 0x6, + _ARM64_BARRIER_NSHLD = 0x5, + _ARM64_BARRIER_OSH = 0x3, + _ARM64_BARRIER_OSHST = 0x2, + _ARM64_BARRIER_OSHLD = 0x1 +} _ARM64INTR_BARRIER_TYPE; + +#endif /* __ARM64INTR_H */ +#endif /* _MSC_VER */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_acle.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_acle.h new file mode 100755 index 0000000..5cfa3d0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_acle.h @@ -0,0 +1,855 @@ +/*===---- arm_acle.h - ARM Non-Neon intrinsics -----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * The Arm C Language Extensions specifications can be found in the following + * link: https://github.com/ARM-software/acle/releases + * + * The ACLE section numbers are subject to change. When consulting the + * specifications, it is recommended to search using section titles if + * the section numbers look outdated. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __ARM_ACLE_H +#define __ARM_ACLE_H + +#ifndef __ARM_ACLE +#error "ACLE intrinsics support not enabled." +#endif + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +/* 7 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */ +/* 7.3 Memory barriers */ +void __dmb(unsigned int); +void __dsb(unsigned int); +void __isb(unsigned int); + +/* 7.4 Hints */ +void __wfi(void); +void __wfe(void); +void __sev(void); +void __sevl(void); +void __yield(void); + +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE +#define __dbg(t) __builtin_arm_dbg(t) +#endif + +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +#define _CHKFEAT_GCS 1 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__chkfeat(uint64_t __features) { + return __builtin_arm_chkfeat(__features) ^ __features; +} +#endif + +/* 7.5 Swap */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__swp(uint32_t __x, volatile uint32_t *__p) { + uint32_t v; + do + v = __builtin_arm_ldrex(__p); + while (__builtin_arm_strex(__x, __p)); + return v; +} + +/* 7.6 Memory prefetch intrinsics */ +/* 7.6.1 Data prefetch */ +#define __pld(addr) __pldx(0, 0, 0, addr) + +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE +#define __pldx(access_kind, cache_level, retention_policy, addr) \ + __builtin_arm_prefetch(addr, access_kind, 1) +#else +#define __pldx(access_kind, cache_level, retention_policy, addr) \ + __builtin_arm_prefetch(addr, access_kind, cache_level, retention_policy, 1) +#endif + +/* 7.6.2 Instruction prefetch */ +#define __pli(addr) __plix(0, 0, addr) + +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE +#define __plix(cache_level, retention_policy, addr) \ + __builtin_arm_prefetch(addr, 0, 0) +#else +#define __plix(cache_level, retention_policy, addr) \ + __builtin_arm_prefetch(addr, 0, cache_level, retention_policy, 0) +#endif + +/* 7.7 NOP */ +#if !defined(_MSC_VER) || (!defined(__aarch64__) && !defined(__arm64ec__)) +static __inline__ void __attribute__((__always_inline__, __nodebug__)) __nop(void) { + __builtin_arm_nop(); +} +#endif + +/* 8 DATA-PROCESSING INTRINSICS */ +/* 8.2 Miscellaneous data-processing intrinsics */ +/* ROR */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__ror(uint32_t __x, uint32_t __y) { + __y %= 32; + if (__y == 0) + return __x; + return (__x >> __y) | (__x << (32 - __y)); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__rorll(uint64_t __x, uint32_t __y) { + __y %= 64; + if (__y == 0) + return __x; + return (__x >> __y) | (__x << (64 - __y)); +} + +static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) +__rorl(unsigned long __x, uint32_t __y) { +#if __SIZEOF_LONG__ == 4 + return __ror(__x, __y); +#else + return __rorll(__x, __y); +#endif +} + + +/* CLZ */ +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +__clz(uint32_t __t) { + return __builtin_arm_clz(__t); +} + +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +__clzl(unsigned long __t) { +#if __SIZEOF_LONG__ == 4 + return __builtin_arm_clz(__t); +#else + return __builtin_arm_clz64(__t); +#endif +} + +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +__clzll(uint64_t __t) { + return __builtin_arm_clz64(__t); +} + +/* CLS */ +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +__cls(uint32_t __t) { + return __builtin_arm_cls(__t); +} + +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +__clsl(unsigned long __t) { +#if __SIZEOF_LONG__ == 4 + return __builtin_arm_cls(__t); +#else + return __builtin_arm_cls64(__t); +#endif +} + +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__)) +__clsll(uint64_t __t) { + return __builtin_arm_cls64(__t); +} + +/* REV */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__rev(uint32_t __t) { + return __builtin_bswap32(__t); +} + +static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) +__revl(unsigned long __t) { +#if __SIZEOF_LONG__ == 4 + return __builtin_bswap32(__t); +#else + return __builtin_bswap64(__t); +#endif +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__revll(uint64_t __t) { + return __builtin_bswap64(__t); +} + +/* REV16 */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__rev16(uint32_t __t) { + return __ror(__rev(__t), 16); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__rev16ll(uint64_t __t) { + return (((uint64_t)__rev16(__t >> 32)) << 32) | (uint64_t)__rev16((uint32_t)__t); +} + +static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) +__rev16l(unsigned long __t) { +#if __SIZEOF_LONG__ == 4 + return __rev16(__t); +#else + return __rev16ll(__t); +#endif +} + +/* REVSH */ +static __inline__ int16_t __attribute__((__always_inline__, __nodebug__)) +__revsh(int16_t __t) { + return (int16_t)__builtin_bswap16((uint16_t)__t); +} + +/* RBIT */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__rbit(uint32_t __t) { + return __builtin_arm_rbit(__t); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__rbitll(uint64_t __t) { +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE + return (((uint64_t)__builtin_arm_rbit(__t)) << 32) | + __builtin_arm_rbit(__t >> 32); +#else + return __builtin_arm_rbit64(__t); +#endif +} + +static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__)) +__rbitl(unsigned long __t) { +#if __SIZEOF_LONG__ == 4 + return __rbit(__t); +#else + return __rbitll(__t); +#endif +} + +/* 8.3 16-bit multiplications */ +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE +static __inline__ int32_t __attribute__((__always_inline__,__nodebug__, target("dsp"))) +__smulbb(int32_t __a, int32_t __b) { + return __builtin_arm_smulbb(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__,__nodebug__, target("dsp"))) +__smulbt(int32_t __a, int32_t __b) { + return __builtin_arm_smulbt(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__,__nodebug__, target("dsp"))) +__smultb(int32_t __a, int32_t __b) { + return __builtin_arm_smultb(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__,__nodebug__, target("dsp"))) +__smultt(int32_t __a, int32_t __b) { + return __builtin_arm_smultt(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__,__nodebug__, target("dsp"))) +__smulwb(int32_t __a, int32_t __b) { + return __builtin_arm_smulwb(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__,__nodebug__, target("dsp"))) +__smulwt(int32_t __a, int32_t __b) { + return __builtin_arm_smulwt(__a, __b); +} +#endif + +/* + * 8.4 Saturating intrinsics + * + * FIXME: Change guard to their corresponding __ARM_FEATURE flag when Q flag + * intrinsics are implemented and the flag is enabled. + */ +/* 8.4.1 Width-specified saturation intrinsics */ +#if defined(__ARM_FEATURE_SAT) && __ARM_FEATURE_SAT +#define __ssat(x, y) __builtin_arm_ssat(x, y) +#define __usat(x, y) __builtin_arm_usat(x, y) +#endif + +/* 8.4.2 Saturating addition and subtraction intrinsics */ +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__qadd(int32_t __t, int32_t __v) { + return __builtin_arm_qadd(__t, __v); +} + +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__qsub(int32_t __t, int32_t __v) { + return __builtin_arm_qsub(__t, __v); +} + +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__qdbl(int32_t __t) { + return __builtin_arm_qadd(__t, __t); +} +#endif + +/* 8.4.3 Accumulating multiplications */ +#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__smlabb(int32_t __a, int32_t __b, int32_t __c) { + return __builtin_arm_smlabb(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__smlabt(int32_t __a, int32_t __b, int32_t __c) { + return __builtin_arm_smlabt(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__smlatb(int32_t __a, int32_t __b, int32_t __c) { + return __builtin_arm_smlatb(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__smlatt(int32_t __a, int32_t __b, int32_t __c) { + return __builtin_arm_smlatt(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__smlawb(int32_t __a, int32_t __b, int32_t __c) { + return __builtin_arm_smlawb(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("dsp"))) +__smlawt(int32_t __a, int32_t __b, int32_t __c) { + return __builtin_arm_smlawt(__a, __b, __c); +} +#endif + + +/* 8.5.4 Parallel 16-bit saturation */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +#define __ssat16(x, y) __builtin_arm_ssat16(x, y) +#define __usat16(x, y) __builtin_arm_usat16(x, y) +#endif + +/* 8.5.5 Packing and unpacking */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +typedef int32_t int8x4_t; +typedef int32_t int16x2_t; +typedef uint32_t uint8x4_t; +typedef uint32_t uint16x2_t; + +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__sxtab16(int16x2_t __a, int8x4_t __b) { + return __builtin_arm_sxtab16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__sxtb16(int8x4_t __a) { + return __builtin_arm_sxtb16(__a); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__uxtab16(int16x2_t __a, int8x4_t __b) { + return __builtin_arm_uxtab16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__uxtb16(int8x4_t __a) { + return __builtin_arm_uxtb16(__a); +} +#endif + +/* 8.5.6 Parallel selection */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__sel(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_sel(__a, __b); +} +#endif + +/* 8.5.7 Parallel 8-bit addition and subtraction */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +static __inline__ int8x4_t __attribute__((__always_inline__, __nodebug__)) +__qadd8(int8x4_t __a, int8x4_t __b) { + return __builtin_arm_qadd8(__a, __b); +} +static __inline__ int8x4_t __attribute__((__always_inline__, __nodebug__)) +__qsub8(int8x4_t __a, int8x4_t __b) { + return __builtin_arm_qsub8(__a, __b); +} +static __inline__ int8x4_t __attribute__((__always_inline__, __nodebug__)) +__sadd8(int8x4_t __a, int8x4_t __b) { + return __builtin_arm_sadd8(__a, __b); +} +static __inline__ int8x4_t __attribute__((__always_inline__, __nodebug__)) +__shadd8(int8x4_t __a, int8x4_t __b) { + return __builtin_arm_shadd8(__a, __b); +} +static __inline__ int8x4_t __attribute__((__always_inline__, __nodebug__)) +__shsub8(int8x4_t __a, int8x4_t __b) { + return __builtin_arm_shsub8(__a, __b); +} +static __inline__ int8x4_t __attribute__((__always_inline__, __nodebug__)) +__ssub8(int8x4_t __a, int8x4_t __b) { + return __builtin_arm_ssub8(__a, __b); +} +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__uadd8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_uadd8(__a, __b); +} +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__uhadd8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_uhadd8(__a, __b); +} +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__uhsub8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_uhsub8(__a, __b); +} +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__uqadd8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_uqadd8(__a, __b); +} +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__uqsub8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_uqsub8(__a, __b); +} +static __inline__ uint8x4_t __attribute__((__always_inline__, __nodebug__)) +__usub8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_usub8(__a, __b); +} +#endif + +/* 8.5.8 Sum of 8-bit absolute differences */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__usad8(uint8x4_t __a, uint8x4_t __b) { + return __builtin_arm_usad8(__a, __b); +} +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__usada8(uint8x4_t __a, uint8x4_t __b, uint32_t __c) { + return __builtin_arm_usada8(__a, __b, __c); +} +#endif + +/* 8.5.9 Parallel 16-bit addition and subtraction */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__qadd16(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_qadd16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__qasx(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_qasx(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__qsax(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_qsax(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__qsub16(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_qsub16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__sadd16(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_sadd16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__sasx(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_sasx(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__shadd16(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_shadd16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__shasx(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_shasx(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__shsax(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_shsax(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__shsub16(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_shsub16(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__ssax(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_ssax(__a, __b); +} +static __inline__ int16x2_t __attribute__((__always_inline__, __nodebug__)) +__ssub16(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_ssub16(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uadd16(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uadd16(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uasx(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uasx(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uhadd16(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uhadd16(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uhasx(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uhasx(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uhsax(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uhsax(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uhsub16(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uhsub16(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uqadd16(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uqadd16(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uqasx(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uqasx(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uqsax(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uqsax(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__uqsub16(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_uqsub16(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__usax(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_usax(__a, __b); +} +static __inline__ uint16x2_t __attribute__((__always_inline__, __nodebug__)) +__usub16(uint16x2_t __a, uint16x2_t __b) { + return __builtin_arm_usub16(__a, __b); +} +#endif + +/* 8.5.10 Parallel 16-bit multiplication */ +#if defined(__ARM_FEATURE_SIMD32) && __ARM_FEATURE_SIMD32 +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smlad(int16x2_t __a, int16x2_t __b, int32_t __c) { + return __builtin_arm_smlad(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smladx(int16x2_t __a, int16x2_t __b, int32_t __c) { + return __builtin_arm_smladx(__a, __b, __c); +} +static __inline__ int64_t __attribute__((__always_inline__, __nodebug__)) +__smlald(int16x2_t __a, int16x2_t __b, int64_t __c) { + return __builtin_arm_smlald(__a, __b, __c); +} +static __inline__ int64_t __attribute__((__always_inline__, __nodebug__)) +__smlaldx(int16x2_t __a, int16x2_t __b, int64_t __c) { + return __builtin_arm_smlaldx(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smlsd(int16x2_t __a, int16x2_t __b, int32_t __c) { + return __builtin_arm_smlsd(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smlsdx(int16x2_t __a, int16x2_t __b, int32_t __c) { + return __builtin_arm_smlsdx(__a, __b, __c); +} +static __inline__ int64_t __attribute__((__always_inline__, __nodebug__)) +__smlsld(int16x2_t __a, int16x2_t __b, int64_t __c) { + return __builtin_arm_smlsld(__a, __b, __c); +} +static __inline__ int64_t __attribute__((__always_inline__, __nodebug__)) +__smlsldx(int16x2_t __a, int16x2_t __b, int64_t __c) { + return __builtin_arm_smlsldx(__a, __b, __c); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smuad(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_smuad(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smuadx(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_smuadx(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smusd(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_smusd(__a, __b); +} +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__)) +__smusdx(int16x2_t __a, int16x2_t __b) { + return __builtin_arm_smusdx(__a, __b); +} +#endif + +/* 8.6 Floating-point data-processing intrinsics */ +#if (defined(__ARM_FEATURE_DIRECTED_ROUNDING) && \ + (__ARM_FEATURE_DIRECTED_ROUNDING)) && \ + (defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE) +static __inline__ double __attribute__((__always_inline__, __nodebug__)) +__rintn(double __a) { + return __builtin_roundeven(__a); +} + +static __inline__ float __attribute__((__always_inline__, __nodebug__)) +__rintnf(float __a) { + return __builtin_roundevenf(__a); +} +#endif + +/* 8.8 CRC32 intrinsics */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32b(uint32_t __a, uint8_t __b) { + return __builtin_arm_crc32b(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32h(uint32_t __a, uint16_t __b) { + return __builtin_arm_crc32h(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32w(uint32_t __a, uint32_t __b) { + return __builtin_arm_crc32w(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32d(uint32_t __a, uint64_t __b) { + return __builtin_arm_crc32d(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32cb(uint32_t __a, uint8_t __b) { + return __builtin_arm_crc32cb(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32ch(uint32_t __a, uint16_t __b) { + return __builtin_arm_crc32ch(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32cw(uint32_t __a, uint32_t __b) { + return __builtin_arm_crc32cw(__a, __b); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__, target("crc"))) +__crc32cd(uint32_t __a, uint64_t __b) { + return __builtin_arm_crc32cd(__a, __b); +} + +/* 8.6 Floating-point data-processing intrinsics */ +/* Armv8.3-A Javascript conversion intrinsic */ +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +static __inline__ int32_t __attribute__((__always_inline__, __nodebug__, target("v8.3a"))) +__jcvt(double __a) { + return __builtin_arm_jcvt(__a); +} +#endif + +/* Armv8.5-A FP rounding intrinsics */ +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +static __inline__ float __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint32zf(float __a) { + return __builtin_arm_rint32zf(__a); +} + +static __inline__ double __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint32z(double __a) { + return __builtin_arm_rint32z(__a); +} + +static __inline__ float __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint64zf(float __a) { + return __builtin_arm_rint64zf(__a); +} + +static __inline__ double __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint64z(double __a) { + return __builtin_arm_rint64z(__a); +} + +static __inline__ float __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint32xf(float __a) { + return __builtin_arm_rint32xf(__a); +} + +static __inline__ double __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint32x(double __a) { + return __builtin_arm_rint32x(__a); +} + +static __inline__ float __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint64xf(float __a) { + return __builtin_arm_rint64xf(__a); +} + +static __inline__ double __attribute__((__always_inline__, __nodebug__, target("v8.5a"))) +__rint64x(double __a) { + return __builtin_arm_rint64x(__a); +} +#endif + +/* 8.9 Armv8.7-A load/store 64-byte intrinsics */ +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +typedef struct { + uint64_t val[8]; +} data512_t; + +static __inline__ data512_t __attribute__((__always_inline__, __nodebug__, target("ls64"))) +__arm_ld64b(const void *__addr) { + data512_t __value; + __builtin_arm_ld64b(__addr, __value.val); + return __value; +} +static __inline__ void __attribute__((__always_inline__, __nodebug__, target("ls64"))) +__arm_st64b(void *__addr, data512_t __value) { + __builtin_arm_st64b(__addr, __value.val); +} +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__, target("ls64"))) +__arm_st64bv(void *__addr, data512_t __value) { + return __builtin_arm_st64bv(__addr, __value.val); +} +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__, target("ls64"))) +__arm_st64bv0(void *__addr, data512_t __value) { + return __builtin_arm_st64bv0(__addr, __value.val); +} +#endif + +/* 11.1 Special register intrinsics */ +#define __arm_rsr(sysreg) __builtin_arm_rsr(sysreg) +#define __arm_rsr64(sysreg) __builtin_arm_rsr64(sysreg) +#define __arm_rsr128(sysreg) __builtin_arm_rsr128(sysreg) +#define __arm_rsrp(sysreg) __builtin_arm_rsrp(sysreg) +#define __arm_rsrf(sysreg) __builtin_bit_cast(float, __arm_rsr(sysreg)) +#define __arm_rsrf64(sysreg) __builtin_bit_cast(double, __arm_rsr64(sysreg)) +#define __arm_wsr(sysreg, v) __builtin_arm_wsr(sysreg, v) +#define __arm_wsr64(sysreg, v) __builtin_arm_wsr64(sysreg, v) +#define __arm_wsr128(sysreg, v) __builtin_arm_wsr128(sysreg, v) +#define __arm_wsrp(sysreg, v) __builtin_arm_wsrp(sysreg, v) +#define __arm_wsrf(sysreg, v) __arm_wsr(sysreg, __builtin_bit_cast(uint32_t, v)) +#define __arm_wsrf64(sysreg, v) __arm_wsr64(sysreg, __builtin_bit_cast(uint64_t, v)) + +/* 10.3 MTE intrinsics */ +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +#define __arm_mte_create_random_tag(__ptr, __mask) __builtin_arm_irg(__ptr, __mask) +#define __arm_mte_increment_tag(__ptr, __tag_offset) __builtin_arm_addg(__ptr, __tag_offset) +#define __arm_mte_exclude_tag(__ptr, __excluded) __builtin_arm_gmi(__ptr, __excluded) +#define __arm_mte_get_tag(__ptr) __builtin_arm_ldg(__ptr) +#define __arm_mte_set_tag(__ptr) __builtin_arm_stg(__ptr) +#define __arm_mte_ptrdiff(__ptra, __ptrb) __builtin_arm_subp(__ptra, __ptrb) + +/* 18 memcpy family of operations intrinsics - MOPS */ +#define __arm_mops_memset_tag(__tagged_address, __value, __size) \ + __builtin_arm_mops_memset_tag(__tagged_address, __value, __size) +#endif + +/* 11.3 Coprocessor Intrinsics */ +#if defined(__ARM_FEATURE_COPROC) + +#if (__ARM_FEATURE_COPROC & 0x1) + +#if (__ARM_ARCH < 8) +#define __arm_cdp(coproc, opc1, CRd, CRn, CRm, opc2) \ + __builtin_arm_cdp(coproc, opc1, CRd, CRn, CRm, opc2) +#endif /* __ARM_ARCH < 8 */ + +#define __arm_ldc(coproc, CRd, p) __builtin_arm_ldc(coproc, CRd, p) +#define __arm_stc(coproc, CRd, p) __builtin_arm_stc(coproc, CRd, p) + +#define __arm_mcr(coproc, opc1, value, CRn, CRm, opc2) \ + __builtin_arm_mcr(coproc, opc1, value, CRn, CRm, opc2) +#define __arm_mrc(coproc, opc1, CRn, CRm, opc2) \ + __builtin_arm_mrc(coproc, opc1, CRn, CRm, opc2) + +#if (__ARM_ARCH != 4) && (__ARM_ARCH < 8) +#define __arm_ldcl(coproc, CRd, p) __builtin_arm_ldcl(coproc, CRd, p) +#define __arm_stcl(coproc, CRd, p) __builtin_arm_stcl(coproc, CRd, p) +#endif /* (__ARM_ARCH != 4) && (__ARM_ARCH != 8) */ + +#if (__ARM_ARCH_8M_MAIN__) || (__ARM_ARCH_8_1M_MAIN__) +#define __arm_cdp(coproc, opc1, CRd, CRn, CRm, opc2) \ + __builtin_arm_cdp(coproc, opc1, CRd, CRn, CRm, opc2) +#define __arm_ldcl(coproc, CRd, p) __builtin_arm_ldcl(coproc, CRd, p) +#define __arm_stcl(coproc, CRd, p) __builtin_arm_stcl(coproc, CRd, p) +#endif /* ___ARM_ARCH_8M_MAIN__ */ + +#endif /* __ARM_FEATURE_COPROC & 0x1 */ + +#if (__ARM_FEATURE_COPROC & 0x2) +#define __arm_cdp2(coproc, opc1, CRd, CRn, CRm, opc2) \ + __builtin_arm_cdp2(coproc, opc1, CRd, CRn, CRm, opc2) +#define __arm_ldc2(coproc, CRd, p) __builtin_arm_ldc2(coproc, CRd, p) +#define __arm_stc2(coproc, CRd, p) __builtin_arm_stc2(coproc, CRd, p) +#define __arm_ldc2l(coproc, CRd, p) __builtin_arm_ldc2l(coproc, CRd, p) +#define __arm_stc2l(coproc, CRd, p) __builtin_arm_stc2l(coproc, CRd, p) +#define __arm_mcr2(coproc, opc1, value, CRn, CRm, opc2) \ + __builtin_arm_mcr2(coproc, opc1, value, CRn, CRm, opc2) +#define __arm_mrc2(coproc, opc1, CRn, CRm, opc2) \ + __builtin_arm_mrc2(coproc, opc1, CRn, CRm, opc2) +#endif + +#if (__ARM_FEATURE_COPROC & 0x4) +#define __arm_mcrr(coproc, opc1, value, CRm) \ + __builtin_arm_mcrr(coproc, opc1, value, CRm) +#define __arm_mrrc(coproc, opc1, CRm) __builtin_arm_mrrc(coproc, opc1, CRm) +#endif + +#if (__ARM_FEATURE_COPROC & 0x8) +#define __arm_mcrr2(coproc, opc1, value, CRm) \ + __builtin_arm_mcrr2(coproc, opc1, value, CRm) +#define __arm_mrrc2(coproc, opc1, CRm) __builtin_arm_mrrc2(coproc, opc1, CRm) +#endif + +#endif // __ARM_FEATURE_COPROC + +/* 17 Transactional Memory Extension (TME) Intrinsics */ +#if defined(__ARM_FEATURE_TME) && __ARM_FEATURE_TME + +#define _TMFAILURE_REASON 0x00007fffu +#define _TMFAILURE_RTRY 0x00008000u +#define _TMFAILURE_CNCL 0x00010000u +#define _TMFAILURE_MEM 0x00020000u +#define _TMFAILURE_IMP 0x00040000u +#define _TMFAILURE_ERR 0x00080000u +#define _TMFAILURE_SIZE 0x00100000u +#define _TMFAILURE_NEST 0x00200000u +#define _TMFAILURE_DBG 0x00400000u +#define _TMFAILURE_INT 0x00800000u +#define _TMFAILURE_TRIVIAL 0x01000000u + +#define __tstart() __builtin_arm_tstart() +#define __tcommit() __builtin_arm_tcommit() +#define __tcancel(__arg) __builtin_arm_tcancel(__arg) +#define __ttest() __builtin_arm_ttest() + +#endif /* __ARM_FEATURE_TME */ + +/* 8.7 Armv8.5-A Random number generation intrinsics */ +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +static __inline__ int __attribute__((__always_inline__, __nodebug__, target("rand"))) +__rndr(uint64_t *__p) { + return __builtin_arm_rndr(__p); +} +static __inline__ int __attribute__((__always_inline__, __nodebug__, target("rand"))) +__rndrrs(uint64_t *__p) { + return __builtin_arm_rndrrs(__p); +} +#endif + +/* 11.2 Guarded Control Stack intrinsics */ +#if defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE +static __inline__ void * __attribute__((__always_inline__, __nodebug__)) +__gcspr() { + return (void *)__builtin_arm_rsr64("gcspr_el0"); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__, target("gcs"))) +__gcspopm() { + return __builtin_arm_gcspopm(0); +} + +static __inline__ void *__attribute__((__always_inline__, __nodebug__, + target("gcs"))) +__gcsss(void *__stack) { + return __builtin_arm_gcsss(__stack); +} +#endif + +#if defined(__cplusplus) +} +#endif + +#endif /* __ARM_ACLE_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_cmse.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_cmse.h new file mode 100755 index 0000000..ecf50ec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_cmse.h @@ -0,0 +1,217 @@ +//===---- arm_cmse.h - Arm CMSE support -----------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __ARM_CMSE_H +#define __ARM_CMSE_H + +#if (__ARM_FEATURE_CMSE & 0x1) +#include +#include + +#define __ARM_CMSE_SECURE_MODE (__ARM_FEATURE_CMSE & 0x2) +#define CMSE_MPU_READWRITE 1 /* checks if readwrite_ok field is set */ +#define CMSE_AU_NONSECURE 2 /* checks if permissions have secure field unset */ +#define CMSE_MPU_UNPRIV 4 /* sets T flag on TT insrtuction */ +#define CMSE_MPU_READ 8 /* checks if read_ok field is set */ +#define CMSE_MPU_NONSECURE 16 /* sets A flag, checks if secure field unset */ +#define CMSE_NONSECURE (CMSE_AU_NONSECURE | CMSE_MPU_NONSECURE) + +#define cmse_check_pointed_object(p, f) \ + cmse_check_address_range((p), sizeof(*(p)), (f)) + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef union { + struct cmse_address_info { +#ifdef __ARM_BIG_ENDIAN + /* __ARM_BIG_ENDIAN */ +#if (__ARM_CMSE_SECURE_MODE) + unsigned idau_region : 8; + unsigned idau_region_valid : 1; + unsigned secure : 1; + unsigned nonsecure_readwrite_ok : 1; + unsigned nonsecure_read_ok : 1; +#else + unsigned : 12; +#endif + unsigned readwrite_ok : 1; + unsigned read_ok : 1; +#if (__ARM_CMSE_SECURE_MODE) + unsigned sau_region_valid : 1; +#else + unsigned : 1; +#endif + unsigned mpu_region_valid : 1; +#if (__ARM_CMSE_SECURE_MODE) + unsigned sau_region : 8; +#else + unsigned : 8; +#endif + unsigned mpu_region : 8; + +#else /* __ARM_LITTLE_ENDIAN */ + unsigned mpu_region : 8; +#if (__ARM_CMSE_SECURE_MODE) + unsigned sau_region : 8; +#else + unsigned : 8; +#endif + unsigned mpu_region_valid : 1; +#if (__ARM_CMSE_SECURE_MODE) + unsigned sau_region_valid : 1; +#else + unsigned : 1; +#endif + unsigned read_ok : 1; + unsigned readwrite_ok : 1; +#if (__ARM_CMSE_SECURE_MODE) + unsigned nonsecure_read_ok : 1; + unsigned nonsecure_readwrite_ok : 1; + unsigned secure : 1; + unsigned idau_region_valid : 1; + unsigned idau_region : 8; +#else + unsigned : 12; +#endif +#endif /*__ARM_LITTLE_ENDIAN */ + } flags; + unsigned value; +} cmse_address_info_t; + +static cmse_address_info_t __attribute__((__always_inline__, __nodebug__)) +cmse_TT(void *__p) { + cmse_address_info_t __u; + __u.value = __builtin_arm_cmse_TT(__p); + return __u; +} +static cmse_address_info_t __attribute__((__always_inline__, __nodebug__)) +cmse_TTT(void *__p) { + cmse_address_info_t __u; + __u.value = __builtin_arm_cmse_TTT(__p); + return __u; +} + +#if __ARM_CMSE_SECURE_MODE +static cmse_address_info_t __attribute__((__always_inline__, __nodebug__)) +cmse_TTA(void *__p) { + cmse_address_info_t __u; + __u.value = __builtin_arm_cmse_TTA(__p); + return __u; +} +static cmse_address_info_t __attribute__((__always_inline__, __nodebug__)) +cmse_TTAT(void *__p) { + cmse_address_info_t __u; + __u.value = __builtin_arm_cmse_TTAT(__p); + return __u; +} +#endif + +#define cmse_TT_fptr(p) cmse_TT(__builtin_bit_cast(void *, (p))) +#define cmse_TTT_fptr(p) cmse_TTT(__builtin_bit_cast(void *, (p))) + +#if __ARM_CMSE_SECURE_MODE +#define cmse_TTA_fptr(p) cmse_TTA(__builtin_bit_cast(void *, (p))) +#define cmse_TTAT_fptr(p) cmse_TTAT(__builtin_bit_cast(void *, (p))) +#endif + +static void *__attribute__((__always_inline__)) +cmse_check_address_range(void *__pb, size_t __s, int __flags) { + uintptr_t __begin = (uintptr_t)__pb; + uintptr_t __end = __begin + __s - 1; + + if (__end < __begin) + return NULL; /* wrap around check */ + + /* Check whether the range crosses a 32-bytes aligned address */ + const int __single_check = (__begin ^ __end) < 0x20u; + + /* execute the right variant of the TT instructions */ + void *__pe = (void *)__end; + cmse_address_info_t __permb, __perme; + switch (__flags & (CMSE_MPU_UNPRIV | CMSE_MPU_NONSECURE)) { + case 0: + __permb = cmse_TT(__pb); + __perme = __single_check ? __permb : cmse_TT(__pe); + break; + case CMSE_MPU_UNPRIV: + __permb = cmse_TTT(__pb); + __perme = __single_check ? __permb : cmse_TTT(__pe); + break; +#if __ARM_CMSE_SECURE_MODE + case CMSE_MPU_NONSECURE: + __permb = cmse_TTA(__pb); + __perme = __single_check ? __permb : cmse_TTA(__pe); + break; + case CMSE_MPU_UNPRIV | CMSE_MPU_NONSECURE: + __permb = cmse_TTAT(__pb); + __perme = __single_check ? __permb : cmse_TTAT(__pe); + break; +#endif + /* if CMSE_NONSECURE is specified w/o __ARM_CMSE_SECURE_MODE */ + default: + return NULL; + } + + /* check that the range does not cross MPU, SAU, or IDAU region boundaries */ + if (__permb.value != __perme.value) + return NULL; +#if !(__ARM_CMSE_SECURE_MODE) + /* CMSE_AU_NONSECURE is only supported when __ARM_FEATURE_CMSE & 0x2 */ + if (__flags & CMSE_AU_NONSECURE) + return NULL; +#endif + + /* check the permission on the range */ + switch (__flags & ~(CMSE_MPU_UNPRIV | CMSE_MPU_NONSECURE)) { +#if (__ARM_CMSE_SECURE_MODE) + case CMSE_MPU_READ | CMSE_MPU_READWRITE | CMSE_AU_NONSECURE: + case CMSE_MPU_READWRITE | CMSE_AU_NONSECURE: + return __permb.flags.nonsecure_readwrite_ok ? __pb : NULL; + + case CMSE_MPU_READ | CMSE_AU_NONSECURE: + return __permb.flags.nonsecure_read_ok ? __pb : NULL; + + case CMSE_AU_NONSECURE: + return __permb.flags.secure ? NULL : __pb; +#endif + case CMSE_MPU_READ | CMSE_MPU_READWRITE: + case CMSE_MPU_READWRITE: + return __permb.flags.readwrite_ok ? __pb : NULL; + + case CMSE_MPU_READ: + return __permb.flags.read_ok ? __pb : NULL; + + default: + return NULL; + } +} + +#if __ARM_CMSE_SECURE_MODE +static int __attribute__((__always_inline__, __nodebug__)) +cmse_nonsecure_caller(void) { + return !((uintptr_t)__builtin_return_address(0) & 1); +} + +#define cmse_nsfptr_create(p) \ + __builtin_bit_cast(__typeof__(p), \ + (__builtin_bit_cast(uintptr_t, p) & ~(uintptr_t)1)) + +#define cmse_is_nsfptr(p) ((__builtin_bit_cast(uintptr_t, p) & 1) == 0) + +#endif /* __ARM_CMSE_SECURE_MODE */ + +void __attribute__((__noreturn__)) cmse_abort(void); +#if defined(__cplusplus) +} +#endif + +#endif /* (__ARM_FEATURE_CMSE & 0x1) */ + +#endif /* __ARM_CMSE_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_neon_sve_bridge.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_neon_sve_bridge.h new file mode 100755 index 0000000..a9fbdba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/arm_neon_sve_bridge.h @@ -0,0 +1,182 @@ +/*===---- arm_neon_sve_bridge.h - ARM NEON SVE Bridge intrinsics -----------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __ARM_NEON_SVE_BRIDGE_H +#define __ARM_NEON_SVE_BRIDGE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Function attributes */ +#define __ai static __inline__ __attribute__((__always_inline__, __nodebug__)) +#define __aio \ + static __inline__ \ + __attribute__((__always_inline__, __nodebug__, __overloadable__)) + +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s8))) +svint8_t svset_neonq(svint8_t, int8x16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s16))) +svint16_t svset_neonq(svint16_t, int16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s32))) +svint32_t svset_neonq(svint32_t, int32x4_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s64))) +svint64_t svset_neonq(svint64_t, int64x2_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u8))) +svuint8_t svset_neonq(svuint8_t, uint8x16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u16))) +svuint16_t svset_neonq(svuint16_t, uint16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u32))) +svuint32_t svset_neonq(svuint32_t, uint32x4_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u64))) +svuint64_t svset_neonq(svuint64_t, uint64x2_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_f16))) +svfloat16_t svset_neonq(svfloat16_t, float16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_f32))) +svfloat32_t svset_neonq(svfloat32_t, float32x4_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_f64))) +svfloat64_t svset_neonq(svfloat64_t, float64x2_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s8))) +svint8_t svset_neonq_s8(svint8_t, int8x16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s16))) +svint16_t svset_neonq_s16(svint16_t, int16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s32))) +svint32_t svset_neonq_s32(svint32_t, int32x4_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_s64))) +svint64_t svset_neonq_s64(svint64_t, int64x2_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u8))) +svuint8_t svset_neonq_u8(svuint8_t, uint8x16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u16))) +svuint16_t svset_neonq_u16(svuint16_t, uint16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u32))) +svuint32_t svset_neonq_u32(svuint32_t, uint32x4_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_u64))) +svuint64_t svset_neonq_u64(svuint64_t, uint64x2_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_f16))) +svfloat16_t svset_neonq_f16(svfloat16_t, float16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_f32))) +svfloat32_t svset_neonq_f32(svfloat32_t, float32x4_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_f64))) +svfloat64_t svset_neonq_f64(svfloat64_t, float64x2_t); + +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s8))) +int8x16_t svget_neonq(svint8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s16))) +int16x8_t svget_neonq(svint16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s32))) +int32x4_t svget_neonq(svint32_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s64))) +int64x2_t svget_neonq(svint64_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u8))) +uint8x16_t svget_neonq(svuint8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u16))) +uint16x8_t svget_neonq(svuint16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u32))) +uint32x4_t svget_neonq(svuint32_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u64))) +uint64x2_t svget_neonq(svuint64_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_f16))) +float16x8_t svget_neonq(svfloat16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_f32))) +float32x4_t svget_neonq(svfloat32_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_f64))) +float64x2_t svget_neonq(svfloat64_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s8))) +int8x16_t svget_neonq_s8(svint8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s16))) +int16x8_t svget_neonq_s16(svint16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s32))) +int32x4_t svget_neonq_s32(svint32_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_s64))) +int64x2_t svget_neonq_s64(svint64_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u8))) +uint8x16_t svget_neonq_u8(svuint8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u16))) +uint16x8_t svget_neonq_u16(svuint16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u32))) +uint32x4_t svget_neonq_u32(svuint32_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_u64))) +uint64x2_t svget_neonq_u64(svuint64_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_f16))) +float16x8_t svget_neonq_f16(svfloat16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_f32))) +float32x4_t svget_neonq_f32(svfloat32_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_f64))) +float64x2_t svget_neonq_f64(svfloat64_t); + +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s8))) +svint8_t svdup_neonq(int8x16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s16))) +svint16_t svdup_neonq(int16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s32))) +svint32_t svdup_neonq(int32x4_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s64))) +svint64_t svdup_neonq(int64x2_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u8))) +svuint8_t svdup_neonq(uint8x16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u16))) +svuint16_t svdup_neonq(uint16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u32))) +svuint32_t svdup_neonq(uint32x4_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u64))) +svuint64_t svdup_neonq(uint64x2_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f16))) +svfloat16_t svdup_neonq(float16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f32))) +svfloat32_t svdup_neonq(float32x4_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f64))) +svfloat64_t svdup_neonq(float64x2_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s8))) +svint8_t svdup_neonq_s8(int8x16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s16))) +svint16_t svdup_neonq_s16(int16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s32))) +svint32_t svdup_neonq_s32(int32x4_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_s64))) +svint64_t svdup_neonq_s64(int64x2_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u8))) +svuint8_t svdup_neonq_u8(uint8x16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u16))) +svuint16_t svdup_neonq_u16(uint16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u32))) +svuint32_t svdup_neonq_u32(uint32x4_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_u64))) +svuint64_t svdup_neonq_u64(uint64x2_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f16))) +svfloat16_t svdup_neonq_f16(float16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f32))) +svfloat32_t svdup_neonq_f32(float32x4_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_f64))) +svfloat64_t svdup_neonq_f64(float64x2_t); + +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_bf16))) +svbfloat16_t svset_neonq(svbfloat16_t, bfloat16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svset_neonq_bf16))) +svbfloat16_t svset_neonq_bf16(svbfloat16_t, bfloat16x8_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_bf16))) +bfloat16x8_t svget_neonq(svbfloat16_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svget_neonq_bf16))) +bfloat16x8_t svget_neonq_bf16(svbfloat16_t); +__aio __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_bf16))) +svbfloat16_t svdup_neonq(bfloat16x8_t); +__ai __attribute__((__clang_arm_builtin_alias(__builtin_sve_svdup_neonq_bf16))) +svbfloat16_t svdup_neonq_bf16(bfloat16x8_t); + +#undef __ai +#undef __aio + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif //__ARM_NEON_SVE_BRIDGE_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/armintr.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/armintr.h new file mode 100755 index 0000000..300ed4e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/armintr.h @@ -0,0 +1,31 @@ +/*===---- armintr.h - ARM Windows intrinsics -------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Only include this if we're compiling for the windows platform. */ +#ifndef _MSC_VER +#include_next +#else + +#ifndef __ARMINTR_H +#define __ARMINTR_H + +typedef enum +{ + _ARM_BARRIER_SY = 0xF, + _ARM_BARRIER_ST = 0xE, + _ARM_BARRIER_ISH = 0xB, + _ARM_BARRIER_ISHST = 0xA, + _ARM_BARRIER_NSH = 0x7, + _ARM_BARRIER_NSHST = 0x6, + _ARM_BARRIER_OSH = 0x3, + _ARM_BARRIER_OSHST = 0x2 +} _ARMINTR_BARRIER_TYPE; + +#endif /* __ARMINTR_H */ +#endif /* _MSC_VER */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512bf16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512bf16intrin.h new file mode 100755 index 0000000..75290d2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512bf16intrin.h @@ -0,0 +1,561 @@ +/*===----------- avx10_2_512bf16intrin.h - AVX10-BF16 intrinsics ---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX10_2_512BF16INTRIN_H +#define __AVX10_2_512BF16INTRIN_H + +/* Define the default attributes for the functions in this file. */ +typedef __bf16 __m512bh_u __attribute__((__vector_size__(64), __aligned__(1))); + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-512"), \ + __min_vector_width__(512))) + +static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_setzero_pbh(void) { + return __builtin_bit_cast(__m512bh, _mm512_setzero_ps()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_undefined_pbh(void) { + return (__m512bh)__builtin_ia32_undef512(); +} + +static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_set1_pbh(__bf16 bf) { + return (__m512bh)(__v32bf){bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, + bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, bf, + bf, bf, bf, bf, bf, bf, bf, bf, bf, bf}; +} + +static __inline __m512bh __DEFAULT_FN_ATTRS512 _mm512_set_pbh( + __bf16 bf1, __bf16 bf2, __bf16 bf3, __bf16 bf4, __bf16 bf5, __bf16 bf6, + __bf16 bf7, __bf16 bf8, __bf16 bf9, __bf16 bf10, __bf16 bf11, __bf16 bf12, + __bf16 bf13, __bf16 bf14, __bf16 bf15, __bf16 bf16, __bf16 bf17, + __bf16 bf18, __bf16 bf19, __bf16 bf20, __bf16 bf21, __bf16 bf22, + __bf16 bf23, __bf16 bf24, __bf16 bf25, __bf16 bf26, __bf16 bf27, + __bf16 bf28, __bf16 bf29, __bf16 bf30, __bf16 bf31, __bf16 bf32) { + return (__m512bh)(__v32bf){bf32, bf31, bf30, bf29, bf28, bf27, bf26, bf25, + bf24, bf23, bf22, bf21, bf20, bf19, bf18, bf17, + bf16, bf15, bf14, bf13, bf12, bf11, bf10, bf9, + bf8, bf7, bf6, bf5, bf4, bf3, bf2, bf1}; +} + +#define _mm512_setr_pbh(bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8, bf9, bf10, \ + bf11, bf12, bf13, bf14, bf15, bf16, bf17, bf18, bf19, \ + bf20, bf21, bf22, bf23, bf24, bf25, bf26, bf27, bf28, \ + bf29, bf30, bf31, bf32) \ + _mm512_set_pbh((bf32), (bf31), (bf30), (bf29), (bf28), (bf27), (bf26), \ + (bf25), (bf24), (bf23), (bf22), (bf21), (bf20), (bf19), \ + (bf18), (bf17), (bf16), (bf15), (bf14), (bf13), (bf12), \ + (bf11), (bf10), (bf9), (bf8), (bf7), (bf6), (bf5), (bf4), \ + (bf3), (bf2), (bf1)) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_castbf16_ps(__m512bh __a) { + return (__m512)__a; +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_castbf16_pd(__m512bh __a) { + return (__m512d)__a; +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_castbf16_si512(__m512bh __a) { + return (__m512i)__a; +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_castps_pbh(__m512 __a) { + return (__m512bh)__a; +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_castpd_pbh(__m512d __a) { + return (__m512bh)__a; +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_castsi512_pbh(__m512i __a) { + return (__m512bh)__a; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS512 +_mm512_castbf16512_pbh128(__m512bh __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS512 +_mm512_castbf16512_pbh256(__m512bh __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_castbf16128_pbh512(__m128bh __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_castbf16256_pbh512(__m256bh __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_zextbf16128_pbh512(__m128bh __a) { + return __builtin_shufflevector( + __a, (__v8bf)_mm_setzero_pbh(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_zextbf16256_pbh512(__m256bh __a) { + return __builtin_shufflevector(__a, (__v16bf)_mm256_setzero_pbh(), 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_abs_pbh(__m512bh __A) { + return (__m512bh)_mm512_and_epi32(_mm512_set1_epi32(0x7FFF7FFF), + (__m512i)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_load_pbh(void const *__p) { + return *(const __m512bh *)__p; +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_loadu_pbh(void const *__p) { + struct __loadu_pbh { + __m512bh_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_pbh *)__p)->__v; +} + +static __inline__ void __DEFAULT_FN_ATTRS512 _mm512_store_pbh(void *__P, + __m512bh __A) { + *(__m512bh *)__P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS512 _mm512_storeu_pbh(void *__P, + __m512bh __A) { + struct __storeu_pbh { + __m512bh_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_pbh *)__P)->__v = __A; +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_pbh(__mmask32 __U, __m512bh __A, __m512bh __W) { + return (__m512bh)__builtin_ia32_selectpbf_512((__mmask32)__U, (__v32bf)__W, + (__v32bf)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_pbh(__m512bh __A, __m512i __I, __m512bh __B) { + return (__m512bh)__builtin_ia32_vpermi2varhi512((__v32hi)__A, (__v32hi)__I, + (__v32hi)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_pbh(__m512i __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_permvarhi512((__v32hi)__B, (__v32hi)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_add_pbh(__m512bh __A, + __m512bh __B) { + return (__m512bh)((__v32bf)__A + (__v32bf)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_add_pbh(__m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_add_pbh(__A, __B), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_add_pbh(__A, __B), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_sub_pbh(__m512bh __A, + __m512bh __B) { + return (__m512bh)((__v32bf)__A - (__v32bf)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_pbh(__m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_sub_pbh(__A, __B), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_sub_pbh(__A, __B), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mul_pbh(__m512bh __A, + __m512bh __B) { + return (__m512bh)((__v32bf)__A * (__v32bf)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_mul_pbh(__m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_mul_pbh(__A, __B), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_mul_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_mul_pbh(__A, __B), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_div_pbh(__m512bh __A, + __m512bh __B) { + return (__m512bh)((__v32bf)__A / (__v32bf)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_div_pbh(__m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_div_pbh(__A, __B), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_div_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_div_pbh(__A, __B), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_max_pbh(__m512bh __A, + __m512bh __B) { + return (__m512bh)__builtin_ia32_vmaxbf16512((__v32bf)__A, (__v32bf)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_max_pbh(__m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_max_pbh(__A, __B), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_max_pbh(__A, __B), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_min_pbh(__m512bh __A, + __m512bh __B) { + return (__m512bh)__builtin_ia32_vminbf16512((__v32bf)__A, (__v32bf)__B); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_min_pbh(__m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_min_pbh(__A, __B), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_min_pbh(__A, __B), + (__v32bf)_mm512_setzero_pbh()); +} + +#define _mm512_cmp_pbh_mask(__A, __B, __P) \ + ((__mmask32)__builtin_ia32_vcmpbf16512_mask((__v32bf)(__m512bh)(__A), \ + (__v32bf)(__m512bh)(__B), \ + (int)(__P), (__mmask32) - 1)) + +#define _mm512_mask_cmp_pbh_mask(__U, __A, __B, __P) \ + ((__mmask32)__builtin_ia32_vcmpbf16512_mask((__v32bf)(__m512bh)(__A), \ + (__v32bf)(__m512bh)(__B), \ + (int)(__P), (__mmask32)(__U))) + +#define _mm512_mask_fpclass_pbh_mask(__U, __A, imm) \ + ((__mmask32)__builtin_ia32_vfpclassbf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__mmask32)(__U))) + +#define _mm512_fpclass_pbh_mask(__A, imm) \ + ((__mmask32)__builtin_ia32_vfpclassbf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__mmask32) - 1)) + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_scalef_pbh(__m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_vscalefbf16512_mask( + (__v32bf)__A, (__v32bf)__B, (__v32bf)_mm512_undefined_pbh(), + (__mmask32)-1); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask_scalef_pbh( + __m512bh __W, __mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_vscalefbf16512_mask( + (__v32bf)__A, (__v32bf)__B, (__v32bf)__W, (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_scalef_pbh(__mmask32 __U, __m512bh __A, __m512bh __B) { + return (__m512bh)__builtin_ia32_vscalefbf16512_mask( + (__v32bf)__A, (__v32bf)__B, (__v32bf)_mm512_setzero_pbh(), + (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_rcp_pbh(__m512bh __A) { + return (__m512bh)__builtin_ia32_vrcpbf16512_mask( + (__v32bf)__A, (__v32bf)_mm512_undefined_pbh(), (__mmask32)-1); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_rcp_pbh(__m512bh __W, __mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_vrcpbf16512_mask((__v32bf)__A, (__v32bf)__W, + (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_rcp_pbh(__mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_vrcpbf16512_mask( + (__v32bf)__A, (__v32bf)_mm512_setzero_pbh(), (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_getexp_pbh(__m512bh __A) { + return (__m512bh)__builtin_ia32_vgetexpbf16512_mask( + (__v32bf)__A, (__v32bf)_mm512_undefined_pbh(), (__mmask32)-1); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_getexp_pbh(__m512bh __W, __mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_vgetexpbf16512_mask( + (__v32bf)__A, (__v32bf)__W, (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_getexp_pbh(__mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_vgetexpbf16512_mask( + (__v32bf)__A, (__v32bf)_mm512_setzero_pbh(), (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_rsqrt_pbh(__m512bh __A) { + return (__m512bh)__builtin_ia32_vrsqrtbf16512_mask( + (__v32bf)__A, (__v32bf)_mm512_undefined_pbh(), (__mmask32)-1); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_rsqrt_pbh(__m512bh __W, __mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_vrsqrtbf16512_mask((__v32bf)__A, (__v32bf)__W, + (__mmask32)__U); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_rsqrt_pbh(__mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_vrsqrtbf16512_mask( + (__v32bf)__A, (__v32bf)_mm512_setzero_pbh(), (__mmask32)__U); +} + +#define _mm512_reduce_pbh(__A, imm) \ + ((__m512bh)__builtin_ia32_vreducebf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__v32bf)_mm512_undefined_pbh(), \ + (__mmask32) - 1)) + +#define _mm512_mask_reduce_pbh(__W, __U, __A, imm) \ + ((__m512bh)__builtin_ia32_vreducebf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__v32bf)(__m512bh)(__W), \ + (__mmask32)(__U))) + +#define _mm512_maskz_reduce_pbh(__U, __A, imm) \ + ((__m512bh)__builtin_ia32_vreducebf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__v32bf)_mm512_setzero_pbh(), \ + (__mmask32)(__U))) + +#define _mm512_roundscale_pbh(__A, imm) \ + ((__m512bh)__builtin_ia32_vrndscalebf16_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__v32bf)_mm512_setzero_pbh(), \ + (__mmask32) - 1)) + +#define _mm512_mask_roundscale_pbh(__W, __U, __A, imm) \ + ((__m512bh)__builtin_ia32_vrndscalebf16_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__v32bf)(__m512bh)(__W), \ + (__mmask32)(__U))) + +#define _mm512_maskz_roundscale_pbh(__U, __A, imm) \ + ((__m512bh)__builtin_ia32_vrndscalebf16_mask( \ + (__v32bf)(__m512bh)(__A), (int)(imm), (__v32bf)_mm512_setzero_pbh(), \ + (__mmask32)(__U))) + +#define _mm512_getmant_pbh(__A, __B, __C) \ + ((__m512bh)__builtin_ia32_vgetmantbf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v32bf)_mm512_undefined_pbh(), (__mmask32) - 1)) + +#define _mm512_mask_getmant_pbh(__W, __U, __A, __B, __C) \ + ((__m512bh)__builtin_ia32_vgetmantbf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v32bf)(__m512bh)(__W), (__mmask32)(__U))) + +#define _mm512_maskz_getmant_pbh(__U, __A, __B, __C) \ + ((__m512bh)__builtin_ia32_vgetmantbf16512_mask( \ + (__v32bf)(__m512bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v32bf)_mm512_setzero_pbh(), (__mmask32)(__U))) + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_sqrt_pbh(__m512bh __A) { + return (__m512bh)__builtin_ia32_vsqrtbf16512((__v32bf)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_sqrt_pbh(__m512bh __W, __mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, (__v32bf)_mm512_sqrt_pbh(__A), (__v32bf)__W); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_sqrt_pbh(__mmask32 __U, __m512bh __A) { + return (__m512bh)__builtin_ia32_selectpbf_512((__mmask32)__U, + (__v32bf)_mm512_sqrt_pbh(__A), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_fmadd_pbh(__m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_vfmaddbf16512((__v32bf)__A, (__v32bf)__B, + (__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_fmadd_pbh(__m512bh __A, __mmask32 __U, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fmadd_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), (__v32bf)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask3_fmadd_pbh( + __m512bh __A, __m512bh __B, __m512bh __C, __mmask32 __U) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fmadd_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), (__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_maskz_fmadd_pbh( + __mmask32 __U, __m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fmadd_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_fmsub_pbh(__m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_vfmaddbf16512((__v32bf)__A, (__v32bf)__B, + -(__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsub_pbh(__m512bh __A, __mmask32 __U, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fmsub_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), (__v32bf)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask3_fmsub_pbh( + __m512bh __A, __m512bh __B, __m512bh __C, __mmask32 __U) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fmsub_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), (__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_maskz_fmsub_pbh( + __mmask32 __U, __m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fmsub_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_fnmadd_pbh(__m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_vfmaddbf16512((__v32bf)__A, -(__v32bf)__B, + (__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask_fnmadd_pbh( + __m512bh __A, __mmask32 __U, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fnmadd_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask3_fnmadd_pbh( + __m512bh __A, __m512bh __B, __m512bh __C, __mmask32 __U) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fnmadd_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_maskz_fnmadd_pbh( + __mmask32 __U, __m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fnmadd_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)_mm512_setzero_pbh()); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_fnmsub_pbh(__m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_vfmaddbf16512((__v32bf)__A, -(__v32bf)__B, + -(__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask_fnmsub_pbh( + __m512bh __A, __mmask32 __U, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fnmsub_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)__A); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_mask3_fnmsub_pbh( + __m512bh __A, __m512bh __B, __m512bh __C, __mmask32 __U) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fnmsub_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)__C); +} + +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 _mm512_maskz_fnmsub_pbh( + __mmask32 __U, __m512bh __A, __m512bh __B, __m512bh __C) { + return (__m512bh)__builtin_ia32_selectpbf_512( + (__mmask32)__U, + _mm512_fnmsub_pbh((__v32bf)__A, (__v32bf)__B, (__v32bf)__C), + (__v32bf)_mm512_setzero_pbh()); +} + +#undef __DEFAULT_FN_ATTRS512 + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512convertintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512convertintrin.h new file mode 100755 index 0000000..ee8cbf2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512convertintrin.h @@ -0,0 +1,322 @@ +/*===--------- avx10_2_512convertintrin.h - AVX10_2_512CONVERT -------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifdef __SSE2__ + +#ifndef __AVX10_2_512CONVERTINTRIN_H +#define __AVX10_2_512CONVERTINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-512"), \ + __min_vector_width__(512))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvtx2ps_ph(__m512 __A, + __m512 __B) { + return (__m512h)__builtin_ia32_vcvt2ps2phx512_mask( + (__v16sf)__A, (__v16sf)__B, (__v32hf)_mm512_setzero_ph(), (__mmask32)(-1), + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtx2ps_ph(__m512h __W, __mmask32 __U, __m512 __A, __m512 __B) { + return (__m512h)__builtin_ia32_vcvt2ps2phx512_mask( + (__v16sf)__A, (__v16sf)__B, (__v32hf)__W, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtx2ps_ph(__mmask32 __U, __m512 __A, __m512 __B) { + return (__m512h)__builtin_ia32_vcvt2ps2phx512_mask( + (__v16sf)__A, (__v16sf)__B, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtx_round2ps_ph(A, B, R) \ + ((__m512h)__builtin_ia32_vcvt2ps2phx512_mask( \ + (__v16sf)(A), (__v16sf)(B), (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)(-1), (const int)(R))) + +#define _mm512_mask_cvtx_round2ps_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_vcvt2ps2phx512_mask((__v16sf)(A), (__v16sf)(B), \ + (__v32hf)(W), (__mmask32)(U), \ + (const int)(R))) + +#define _mm512_maskz_cvtx_round2ps_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_vcvt2ps2phx512_mask( \ + (__v16sf)(A), (__v16sf)(B), (__v32hf)_mm512_setzero_ph(), \ + (__mmask32)(U), (const int)(R))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtbiasph_bf8(__m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2bf8_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)_mm256_undefined_si256(), + (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 _mm512_mask_cvtbiasph_bf8( + __m256i __W, __mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2bf8_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtbiasph_bf8(__mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2bf8_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)_mm256_setzero_si256(), + (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvts_biasph_bf8(__m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2bf8s_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)_mm256_undefined_si256(), + (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 _mm512_mask_cvts_biasph_bf8( + __m256i __W, __mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2bf8s_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvts_biasph_bf8(__mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2bf8s_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)_mm256_setzero_si256(), + (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtbiasph_hf8(__m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2hf8_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)_mm256_undefined_si256(), + (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 _mm512_mask_cvtbiasph_hf8( + __m256i __W, __mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2hf8_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtbiasph_hf8(__mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2hf8_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)_mm256_setzero_si256(), + (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvts_biasph_hf8(__m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2hf8s_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)_mm256_undefined_si256(), + (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 _mm512_mask_cvts_biasph_hf8( + __m256i __W, __mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2hf8s_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvts_biasph_hf8(__mmask32 __U, __m512i __A, __m512h __B) { + return (__m256i)__builtin_ia32_vcvtbiasph2hf8s_512_mask( + (__v64qi)__A, (__v32hf)__B, (__v32qi)(__m256i)_mm256_setzero_si256(), + (__mmask32)__U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 _mm512_cvt2ph_bf8(__m512h __A, + __m512h __B) { + return (__m512i)__builtin_ia32_vcvt2ph2bf8_512((__v32hf)(__A), + (__v32hf)(__B)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvt2ph_bf8(__m512i __W, __mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvt2ph_bf8(__A, __B), (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvt2ph_bf8(__mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvt2ph_bf8(__A, __B), + (__v64qi)(__m512i)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvts_2ph_bf8(__m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_vcvt2ph2bf8s_512((__v32hf)(__A), + (__v32hf)(__B)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvts_2ph_bf8(__m512i __W, __mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvts_2ph_bf8(__A, __B), (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvts_2ph_bf8(__mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvts_2ph_bf8(__A, __B), + (__v64qi)(__m512i)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 _mm512_cvt2ph_hf8(__m512h __A, + __m512h __B) { + return (__m512i)__builtin_ia32_vcvt2ph2hf8_512((__v32hf)(__A), + (__v32hf)(__B)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvt2ph_hf8(__m512i __W, __mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvt2ph_hf8(__A, __B), (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvt2ph_hf8(__mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvt2ph_hf8(__A, __B), + (__v64qi)(__m512i)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvts_2ph_hf8(__m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_vcvt2ph2hf8s_512((__v32hf)(__A), + (__v32hf)(__B)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvts_2ph_hf8(__m512i __W, __mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvts_2ph_hf8(__A, __B), (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvts_2ph_hf8(__mmask64 __U, __m512h __A, __m512h __B) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_cvts_2ph_hf8(__A, __B), + (__v64qi)(__m512i)_mm512_setzero_si512()); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_cvthf8_ph(__m256i __A) { + return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask( + (__v32qi)__A, (__v32hf)(__m512h)_mm512_undefined_ph(), (__mmask32)-1); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvthf8_ph(__m512h __W, __mmask32 __U, __m256i __A) { + return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask( + (__v32qi)__A, (__v32hf)(__m512h)__W, (__mmask32)__U); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvthf8_ph(__mmask32 __U, __m256i __A) { + return (__m512h)__builtin_ia32_vcvthf8_2ph512_mask( + (__v32qi)__A, (__v32hf)(__m512h)_mm512_setzero_ph(), (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 _mm512_cvtph_bf8(__m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2bf8_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_undefined_si256(), (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_bf8(__m256i __W, __mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2bf8_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_bf8(__mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2bf8_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_setzero_si256(), (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvts_ph_bf8(__m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2bf8s_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_undefined_si256(), (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvts_ph_bf8(__m256i __W, __mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2bf8s_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvts_ph_bf8(__mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2bf8s_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_setzero_si256(), (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 _mm512_cvtph_hf8(__m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2hf8_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_undefined_si256(), (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_hf8(__m256i __W, __mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2hf8_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_hf8(__mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2hf8_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_setzero_si256(), (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvts_ph_hf8(__m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2hf8s_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_undefined_si256(), (__mmask32)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvts_ph_hf8(__m256i __W, __mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2hf8s_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)__W, (__mmask32)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvts_ph_hf8(__mmask32 __U, __m512h __A) { + return (__m256i)__builtin_ia32_vcvtph2hf8s_512_mask( + (__v32hf)__A, (__v32qi)(__m256i)_mm256_setzero_si256(), (__mmask32)__U); +} + +static __inline __m512h __DEFAULT_FN_ATTRS512 _mm512_cvtbf8_ph(__m256i __A) { + return _mm512_castsi512_ph(_mm512_slli_epi16(_mm512_cvtepi8_epi16(__A), 8)); +} + +static __inline __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtbf8_ph(__m512h __S, __mmask32 __U, __m256i __A) { + return _mm512_castsi512_ph( + _mm512_mask_slli_epi16((__m512i)__S, __U, _mm512_cvtepi8_epi16(__A), 8)); +} + +static __inline __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtbf8_ph(__mmask32 __U, __m256i __A) { + return _mm512_castsi512_ph( + _mm512_slli_epi16(_mm512_maskz_cvtepi8_epi16(__U, __A), 8)); +} + +#undef __DEFAULT_FN_ATTRS512 + +#endif // __AVX10_2_512CONVERTINTRIN_H +#endif // __SSE2__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512minmaxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512minmaxintrin.h new file mode 100755 index 0000000..fbc7fba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512minmaxintrin.h @@ -0,0 +1,127 @@ +/*===---- avx10_2_512minmaxintrin.h - AVX10_2_512MINMAX intrinsics ---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2_512MINMAXINTRIN_H +#define __AVX10_2_512MINMAXINTRIN_H + +#define _mm512_minmax_pbh(A, B, C) \ + ((__m512bh)__builtin_ia32_vminmaxbf16512((__v32bf)(__m512bh)(A), \ + (__v32bf)(__m512bh)(A), (int)(C))) + +#define _mm512_mask_minmax_pbh(W, U, A, B, C) \ + ((__m512bh)__builtin_ia32_selectpbf_512( \ + (__mmask32)(U), \ + (__v32bf)_mm512_minmax_pbh((__v32bf)(__m512bh)(A), \ + (__v32bf)(__m512bh)(B), (int)(C)), \ + (__v32bf)(__m512bh)(W))) + +#define _mm512_maskz_minmax_pbh(U, A, B, C) \ + ((__m512bh)__builtin_ia32_selectpbf_512( \ + (__mmask32)(U), \ + (__v32bf)_mm512_minmax_pbh((__v32bf)(__m512bh)(A), \ + (__v32bf)(__m512bh)(B), (int)(C)), \ + (__v32bf) __builtin_bit_cast(__m512bh, _mm512_setzero_ps()))) + +#define _mm512_minmax_pd(A, B, C) \ + ((__m512d)__builtin_ia32_vminmaxpd512_round_mask( \ + (__v8df)(__m512d)(A), (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_undefined_pd(), (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_minmax_pd(W, U, A, B, C) \ + ((__m512d)__builtin_ia32_vminmaxpd512_round_mask( \ + (__v8df)(__m512d)(A), (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)(__m512d)(W), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_minmax_pd(U, A, B, C) \ + ((__m512d)__builtin_ia32_vminmaxpd512_round_mask( \ + (__v8df)(__m512d)(A), (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_setzero_pd(), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_minmax_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vminmaxpd512_round_mask( \ + (__v8df)(__m512d)(A), (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_undefined_pd(), (__mmask8)-1, (int)(R))) + +#define _mm512_mask_minmax_round_pd(W, U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vminmaxpd512_round_mask( \ + (__v8df)(__m512d)(A), (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)(__m512d)(W), (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_minmax_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vminmaxpd512_round_mask( \ + (__v8df)(__m512d)(A), (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_setzero_pd(), (__mmask8)(U), (int)(R))) + +#define _mm512_minmax_ph(A, B, C) \ + ((__m512h)__builtin_ia32_vminmaxph512_round_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (int)(C), \ + (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_minmax_ph(W, U, A, B, C) \ + ((__m512h)__builtin_ia32_vminmaxph512_round_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (int)(C), \ + (__v32hf)(__m512h)(W), (__mmask32)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_minmax_ph(U, A, B, C) \ + ((__m512h)__builtin_ia32_vminmaxph512_round_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (int)(C), \ + (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_minmax_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vminmaxph512_round_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (int)(C), \ + (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, (int)(R))) + +#define _mm512_mask_minmax_round_ph(W, U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vminmaxph512_round_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (int)(C), \ + (__v32hf)(__m512h)(W), (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_minmax_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vminmaxph512_round_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (int)(C), \ + (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), (int)(R))) + +#define _mm512_minmax_ps(A, B, C) \ + ((__m512)__builtin_ia32_vminmaxps512_round_mask( \ + (__v16sf)(__m512)(A), (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_undefined_ps(), (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_minmax_ps(W, U, A, B, C) \ + ((__m512)__builtin_ia32_vminmaxps512_round_mask( \ + (__v16sf)(__m512)(A), (__v16sf)(__m512)(B), (int)(C), (__v16sf)(W), \ + (__mmask16)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_minmax_ps(U, A, B, C) \ + ((__m512)__builtin_ia32_vminmaxps512_round_mask( \ + (__v16sf)(__m512)(A), (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_setzero_ps(), (__mmask16)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_minmax_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vminmaxps512_round_mask( \ + (__v16sf)(__m512)(A), (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_undefined_ps(), (__mmask16)-1, (int)(R))) + +#define _mm512_mask_minmax_round_ps(W, U, A, B, C, R) \ + ((__m512)__builtin_ia32_vminmaxps512_round_mask( \ + (__v16sf)(__m512)(A), (__v16sf)(__m512)(B), (int)(C), (__v16sf)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_minmax_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vminmaxps512_round_mask( \ + (__v16sf)(__m512)(A), (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_setzero_ps(), (__mmask16)(U), (int)(R))) +#endif // __AVX10_2_512MINMAXINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512niintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512niintrin.h new file mode 100755 index 0000000..9d96e36 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512niintrin.h @@ -0,0 +1,314 @@ +/*===---- avx10_2_512niintrin.h - AVX10.2-512 new instruction intrinsics ---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX10_2_512NIINTRIN_H +#define __AVX10_2_512NIINTRIN_H + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-512"), \ + __min_vector_width__(512))) + +/* VNNI FP16 */ +static __inline__ __m512 __DEFAULT_FN_ATTRS _mm512_dpph_ps(__m512 __W, + __m512h __A, + __m512h __B) { + return (__m512)__builtin_ia32_vdpphps512((__v16sf)__W, (__v32hf)__A, + (__v32hf)__B); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS _mm512_mask_dpph_ps(__m512 __W, + __mmask16 __U, + __m512h __A, + __m512h __B) { + return (__m512)__builtin_ia32_selectps_512( + (__mmask16)__U, (__v16sf)_mm512_dpph_ps(__W, __A, __B), (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS _mm512_maskz_dpph_ps(__mmask16 __U, + __m512 __W, + __m512h __A, + __m512h __B) { + return (__m512)__builtin_ia32_selectps_512( + (__mmask16)__U, (__v16sf)_mm512_dpph_ps(__W, __A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +/* VMPSADBW */ +#define _mm512_mpsadbw_epu8(A, B, imm) \ + ((__m512i)__builtin_ia32_mpsadbw512((__v64qi)(__m512i)(A), \ + (__v64qi)(__m512i)(B), (int)(imm))) + +#define _mm512_mask_mpsadbw_epu8(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectw_512( \ + (__mmask32)(U), (__v32hi)_mm512_mpsadbw_epu8((A), (B), (imm)), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_mpsadbw_epu8(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectw_512( \ + (__mmask32)(U), (__v32hi)_mm512_mpsadbw_epu8((A), (B), (imm)), \ + (__v32hi)_mm512_setzero_si512())) + +/* VNNI INT8 */ +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpbssd_epi32(__m512i __W, + __m512i __A, + __m512i __B) { + return (__m512i)__builtin_ia32_vpdpbssd512((__v16si)__W, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpbssd_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbssd_epi32(__W, __A, __B), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpbssd_epi32( + __mmask16 __U, __m512i __W, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbssd_epi32(__W, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpbssds_epi32(__m512i __W, + __m512i __A, + __m512i __B) { + return (__m512i)__builtin_ia32_vpdpbssds512((__v16si)__W, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_dpbssds_epi32( + __m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbssds_epi32(__W, __A, __B), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpbssds_epi32( + __mmask16 __U, __m512i __W, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbssds_epi32(__W, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpbsud_epi32(__m512i __W, + __m512i __A, + __m512i __B) { + return (__m512i)__builtin_ia32_vpdpbsud512((__v16si)__W, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpbsud_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbsud_epi32(__W, __A, __B), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpbsud_epi32( + __mmask16 __U, __m512i __W, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbsud_epi32(__W, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpbsuds_epi32(__m512i __W, + __m512i __A, + __m512i __B) { + return (__m512i)__builtin_ia32_vpdpbsuds512((__v16si)__W, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_dpbsuds_epi32( + __m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbsuds_epi32(__W, __A, __B), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpbsuds_epi32( + __mmask16 __U, __m512i __W, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbsuds_epi32(__W, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpbuud_epi32(__m512i __W, + __m512i __A, + __m512i __B) { + return (__m512i)__builtin_ia32_vpdpbuud512((__v16si)__W, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpbuud_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbuud_epi32(__W, __A, __B), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpbuud_epi32( + __mmask16 __U, __m512i __W, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbuud_epi32(__W, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpbuuds_epi32(__m512i __W, + __m512i __A, + __m512i __B) { + return (__m512i)__builtin_ia32_vpdpbuuds512((__v16si)__W, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_dpbuuds_epi32( + __m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbuuds_epi32(__W, __A, __B), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpbuuds_epi32( + __mmask16 __U, __m512i __W, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512( + __U, (__v16si)_mm512_dpbuuds_epi32(__W, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +/* VNNI INT16 */ +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpwsud_epi32(__m512i __A, + __m512i __B, + __m512i __C) { + return (__m512i)__builtin_ia32_vpdpwsud512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpwsud_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwsud_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpwsud_epi32( + __mmask16 __U, __m512i __A, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwsud_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpwsuds_epi32(__m512i __A, + __m512i __B, + __m512i __C) { + return (__m512i)__builtin_ia32_vpdpwsuds512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_dpwsuds_epi32( + __m512i __A, __mmask16 __U, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwsuds_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpwsuds_epi32( + __mmask16 __U, __m512i __A, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwsuds_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpwusd_epi32(__m512i __A, + __m512i __B, + __m512i __C) { + return (__m512i)__builtin_ia32_vpdpwusd512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpwusd_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwusd_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpwusd_epi32( + __mmask16 __U, __m512i __A, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwusd_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpwusds_epi32(__m512i __A, + __m512i __B, + __m512i __C) { + return (__m512i)__builtin_ia32_vpdpwusds512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_dpwusds_epi32( + __m512i __A, __mmask16 __U, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwusds_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpwusds_epi32( + __mmask16 __U, __m512i __A, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwusds_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpwuud_epi32(__m512i __A, + __m512i __B, + __m512i __C) { + return (__m512i)__builtin_ia32_vpdpwuud512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpwuud_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwuud_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpwuud_epi32( + __mmask16 __U, __m512i __A, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwuud_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_dpwuuds_epi32(__m512i __A, + __m512i __B, + __m512i __C) { + return (__m512i)__builtin_ia32_vpdpwuuds512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_mask_dpwuuds_epi32( + __m512i __A, __mmask16 __U, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwuuds_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_maskz_dpwuuds_epi32( + __mmask16 __U, __m512i __A, __m512i __B, __m512i __C) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_dpwuuds_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __SSE2__ */ +#endif /* __AVX10_2_512NIINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512satcvtdsintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512satcvtdsintrin.h new file mode 100755 index 0000000..012a628 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512satcvtdsintrin.h @@ -0,0 +1,307 @@ +/*===----- avx10_2_512satcvtdsintrin.h - AVX10_2_512SATCVTDS intrinsics ----=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifndef __AVX10_2_512SATCVTDSINTRIN_H +#define __AVX10_2_512SATCVTDSINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-512"), \ + __min_vector_width__(512))) + +// 512 bit : Double -> Int +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm512_cvtts_pd_epi32(__m512d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2dqs512_round_mask( + (__v8df)__A, (__v8si)_mm256_undefined_si256(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_pd_epi32(__m256i __W, __mmask8 __U, __m512d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2dqs512_round_mask( + (__v8df)__A, (__v8si)__W, __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_pd_epi32(__mmask8 __U, __m512d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2dqs512_round_mask( + (__v8df)__A, (__v8si)_mm256_setzero_si256(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundpd_epi32(__A, __R) \ + ((__m256i)__builtin_ia32_vcvttpd2dqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8si)_mm256_undefined_si256(), \ + (__mmask8) - 1, (const int)(__R))) + +#define _mm512_mask_cvtts_roundpd_epi32(__W, __U, __A, __R) \ + ((__m256i)__builtin_ia32_vcvttpd2dqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8si)(__m256i)(__W), (__mmask8)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundpd_epi32(__U, __A, __R) \ + ((__m256i)__builtin_ia32_vcvttpd2dqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8si)_mm256_setzero_si256(), (__mmask8)(__U), \ + (const int)(__R))) + +// 512 bit : Double -> uInt +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm512_cvtts_pd_epu32(__m512d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2udqs512_round_mask( + (__v8df)__A, (__v8si)_mm256_undefined_si256(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_pd_epu32(__m256i __W, __mmask8 __U, __m512d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2udqs512_round_mask( + (__v8df)__A, (__v8si)__W, __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_pd_epu32(__mmask8 __U, __m512d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2udqs512_round_mask( + (__v8df)__A, (__v8si)_mm256_setzero_si256(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundpd_epu32(__A, __R) \ + ((__m256i)__builtin_ia32_vcvttpd2udqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8si)_mm256_undefined_si256(), \ + (__mmask8) - 1, (const int)(__R))) + +#define _mm512_mask_cvtts_roundpd_epu32(__W, __U, __A, __R) \ + ((__m256i)__builtin_ia32_vcvttpd2udqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8si)(__m256i)(__W), (__mmask8)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundpd_epu32(__U, __A, __R) \ + ((__m256i)__builtin_ia32_vcvttpd2udqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8si)_mm256_setzero_si256(), (__mmask8)(__U), \ + (const int)(__R))) + +// 512 bit : Double -> Long + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_cvtts_pd_epi64(__m512d __A) { + return ((__m512i)__builtin_ia32_vcvttpd2qqs512_round_mask( + (__v8df)__A, (__v8di)_mm512_undefined_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION)); +} +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_pd_epi64(__m512i __W, __mmask8 __U, __m512d __A) { + return ((__m512i)__builtin_ia32_vcvttpd2qqs512_round_mask( + (__v8df)__A, (__v8di)__W, __U, _MM_FROUND_CUR_DIRECTION)); +} +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_pd_epi64(__mmask8 __U, __m512d __A) { + return ((__m512i)__builtin_ia32_vcvttpd2qqs512_round_mask( + (__v8df)__A, (__v8di)_mm512_setzero_si512(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundpd_epi64(__A, __R) \ + ((__m512i)__builtin_ia32_vcvttpd2qqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8di)_mm512_undefined_epi32(), \ + (__mmask8) - 1, (const int)(__R))) + +#define _mm512_mask_cvtts_roundpd_epi64(__W, __U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttpd2qqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8di)(__m512i)(__W), (__mmask8)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundpd_epi64(__U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttpd2qqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8di)_mm512_setzero_si512(), (__mmask8)(__U), \ + (const int)(__R))) + +// 512 bit : Double -> ULong + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_cvtts_pd_epu64(__m512d __A) { + return ((__m512i)__builtin_ia32_vcvttpd2uqqs512_round_mask( + (__v8df)__A, (__v8di)_mm512_undefined_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_pd_epu64(__m512i __W, __mmask8 __U, __m512d __A) { + return ((__m512i)__builtin_ia32_vcvttpd2uqqs512_round_mask( + (__v8df)__A, (__v8di)__W, __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_pd_epu64(__mmask8 __U, __m512d __A) { + return ((__m512i)__builtin_ia32_vcvttpd2uqqs512_round_mask( + (__v8df)__A, (__v8di)_mm512_setzero_si512(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundpd_epu64(__A, __R) \ + ((__m512i)__builtin_ia32_vcvttpd2uqqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8di)_mm512_undefined_epi32(), \ + (__mmask8) - 1, (const int)(__R))) + +#define _mm512_mask_cvtts_roundpd_epu64(__W, __U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttpd2uqqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8di)(__m512i)(__W), (__mmask8)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundpd_epu64(__U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttpd2uqqs512_round_mask( \ + (__v8df)(__m512d)(__A), (__v8di)_mm512_setzero_si512(), (__mmask8)(__U), \ + (const int)(__R))) + +// 512 bit: Float -> int +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_cvtts_ps_epi32(__m512 __A) { + return ((__m512i)__builtin_ia32_vcvttps2dqs512_round_mask( + (__v16sf)(__A), (__v16si)_mm512_undefined_epi32(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_ps_epi32(__m512i __W, __mmask16 __U, __m512 __A) { + return ((__m512i)__builtin_ia32_vcvttps2dqs512_round_mask( + (__v16sf)(__A), (__v16si)(__W), __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_ps_epi32(__mmask16 __U, __m512 __A) { + return ((__m512i)__builtin_ia32_vcvttps2dqs512_round_mask( + (__v16sf)(__A), (__v16si)_mm512_setzero_si512(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundps_epi32(__A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2dqs512_round_mask( \ + (__v16sf)(__m512)(__A), (__v16si)_mm512_undefined_epi32(), \ + (__mmask16) - 1, (const int)(__R))) + +#define _mm512_mask_cvtts_roundps_epi32(__W, __U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2dqs512_round_mask( \ + (__v16sf)(__m512)(__A), (__v16si)(__m512i)(__W), (__mmask16)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundps_epi32(__U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2dqs512_round_mask( \ + (__v16sf)(__m512)(__A), (__v16si)_mm512_setzero_si512(), \ + (__mmask16)(__U), (const int)(__R))) + +// 512 bit: Float -> uint +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_cvtts_ps_epu32(__m512 __A) { + return ((__m512i)__builtin_ia32_vcvttps2udqs512_round_mask( + (__v16sf)(__A), (__v16si)_mm512_undefined_epi32(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_ps_epu32(__m512i __W, __mmask16 __U, __m512 __A) { + return ((__m512i)__builtin_ia32_vcvttps2udqs512_round_mask( + (__v16sf)(__A), (__v16si)(__W), __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_ps_epu32(__mmask16 __U, __m512 __A) { + return ((__m512i)__builtin_ia32_vcvttps2udqs512_round_mask( + (__v16sf)(__A), (__v16si)_mm512_setzero_si512(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundps_epu32(__A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2udqs512_round_mask( \ + (__v16sf)(__m512)(__A), (__v16si)_mm512_undefined_epi32(), \ + (__mmask16) - 1, (const int)(__R))) + +#define _mm512_mask_cvtts_roundps_epu32(__W, __U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2udqs512_round_mask( \ + (__v16sf)(__m512)(__A), (__v16si)(__m512i)(__W), (__mmask16)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundps_epu32(__U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2udqs512_round_mask( \ + (__v16sf)(__m512)(__A), (__v16si)_mm512_setzero_si512(), \ + (__mmask16)(__U), (const int)(__R))) + +// 512 bit : float -> long +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_cvtts_ps_epi64(__m256 __A) { + return ((__m512i)__builtin_ia32_vcvttps2qqs512_round_mask( + (__v8sf)__A, (__v8di)_mm512_undefined_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_ps_epi64(__m512i __W, __mmask8 __U, __m256 __A) { + return ((__m512i)__builtin_ia32_vcvttps2qqs512_round_mask( + (__v8sf)__A, (__v8di)__W, __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_ps_epi64(__mmask8 __U, __m256 __A) { + return ((__m512i)__builtin_ia32_vcvttps2qqs512_round_mask( + (__v8sf)__A, (__v8di)_mm512_setzero_si512(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundps_epi64(__A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2qqs512_round_mask( \ + (__v8sf)(__m256)(__A), (__v8di)_mm512_undefined_epi32(), (__mmask8) - 1, \ + (const int)(__R))) + +#define _mm512_mask_cvtts_roundps_epi64(__W, __U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2qqs512_round_mask( \ + (__v8sf)(__m256)(__A), (__v8di)(__m512i)(__W), (__mmask8)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundps_epi64(__U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2qqs512_round_mask( \ + (__v8sf)(__m256)(__A), (__v8di)_mm512_setzero_si512(), (__mmask8)(__U), \ + (const int)(__R))) + +// 512 bit : float -> ulong +static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_cvtts_ps_epu64(__m256 __A) { + return ((__m512i)__builtin_ia32_vcvttps2uqqs512_round_mask( + (__v8sf)__A, (__v8di)_mm512_undefined_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_cvtts_ps_epu64(__m512i __W, __mmask8 __U, __m256 __A) { + return ((__m512i)__builtin_ia32_vcvttps2uqqs512_round_mask( + (__v8sf)__A, (__v8di)__W, __U, _MM_FROUND_CUR_DIRECTION)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_cvtts_ps_epu64(__mmask8 __U, __m256 __A) { + return ((__m512i)__builtin_ia32_vcvttps2uqqs512_round_mask( + (__v8sf)__A, (__v8di)_mm512_setzero_si512(), __U, + _MM_FROUND_CUR_DIRECTION)); +} + +#define _mm512_cvtts_roundps_epu64(__A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2uqqs512_round_mask( \ + (__v8sf)(__m256)(__A), (__v8di)_mm512_undefined_epi32(), (__mmask8) - 1, \ + (const int)(__R))) + +#define _mm512_mask_cvtts_roundps_epu64(__W, __U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2uqqs512_round_mask( \ + (__v8sf)(__m256)(__A), (__v8di)(__m512i)(__W), (__mmask8)(__U), \ + (const int)(__R))) + +#define _mm512_maskz_cvtts_roundps_epu64(__U, __A, __R) \ + ((__m512i)__builtin_ia32_vcvttps2uqqs512_round_mask( \ + (__v8sf)(__m256)(__A), (__v8di)_mm512_setzero_si512(), (__mmask8)(__U), \ + (const int)(__R))) + +#undef __DEFAULT_FN_ATTRS +#endif // __AVX10_2_512SATCVTDSINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512satcvtintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512satcvtintrin.h new file mode 100755 index 0000000..b58e3db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2_512satcvtintrin.h @@ -0,0 +1,301 @@ +/*===------ avx10_2_512satcvtintrin.h - AVX10_2_512SATCVT intrinsics -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2_512SATCVTINTRIN_H +#define __AVX10_2_512SATCVTINTRIN_H + +#define _mm512_ipcvts_bf16_epi8(A) \ + ((__m512i)__builtin_ia32_vcvtbf162ibs512((__v32bf)(__m512bh)(A))) + +#define _mm512_mask_ipcvts_bf16_epi8(W, U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvts_bf16_epi8(A), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_ipcvts_bf16_epi8(U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvts_bf16_epi8(A), \ + (__v32hi)_mm512_setzero_si512())) + +#define _mm512_ipcvts_bf16_epu8(A) \ + ((__m512i)__builtin_ia32_vcvtbf162iubs512((__v32bf)(__m512bh)(A))) + +#define _mm512_mask_ipcvts_bf16_epu8(W, U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvts_bf16_epu8(A), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_ipcvts_bf16_epu8(U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvts_bf16_epu8(A), \ + (__v32hi)_mm512_setzero_si512())) + +#define _mm512_ipcvtts_bf16_epi8(A) \ + ((__m512i)__builtin_ia32_vcvttbf162ibs512((__v32bf)(__m512bh)(A))) + +#define _mm512_mask_ipcvtts_bf16_epi8(W, U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvtts_bf16_epi8(A), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_ipcvtts_bf16_epi8(U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvtts_bf16_epi8(A), \ + (__v32hi)_mm512_setzero_si512())) + +#define _mm512_ipcvtts_bf16_epu8(A) \ + ((__m512i)__builtin_ia32_vcvttbf162iubs512((__v32bf)(__m512bh)(A))) + +#define _mm512_mask_ipcvtts_bf16_epu8(W, U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvtts_bf16_epu8(A), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_ipcvtts_bf16_epu8(U, A) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_ipcvtts_bf16_epu8(A), \ + (__v32hi)_mm512_setzero_si512())) + +#define _mm512_ipcvts_ph_epi8(A) \ + ((__m512i)__builtin_ia32_vcvtph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvts_ph_epi8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvtph2ibs512_mask((__v32hf)(__m512h)(A), \ + (__v32hu)(W), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvts_ph_epi8(U, A) \ + ((__m512i)__builtin_ia32_vcvtph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvts_roundph_epi8(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2ibs512_mask((__v32hf)(__m512h)(A), \ + (__v32hu)_mm512_setzero_si512(), \ + (__mmask32) - 1, (const int)R)) + +#define _mm512_mask_ipcvts_roundph_epi8(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)(W), (__mmask32)(U), (const int)R)) + +#define _mm512_maskz_ipcvts_roundph_epi8(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2ibs512_mask((__v32hf)(__m512h)(A), \ + (__v32hu)_mm512_setzero_si512(), \ + (__mmask32)(U), (const int)R)) + +#define _mm512_ipcvts_ph_epu8(A) \ + ((__m512i)__builtin_ia32_vcvtph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvts_ph_epu8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvtph2iubs512_mask((__v32hf)(__m512h)(A), \ + (__v32hu)(W), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvts_ph_epu8(U, A) \ + ((__m512i)__builtin_ia32_vcvtph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvts_roundph_epu8(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + (const int)R)) + +#define _mm512_mask_ipcvts_roundph_epu8(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)(W), (__mmask32)(U), (const int)R)) + +#define _mm512_maskz_ipcvts_roundph_epu8(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + (const int)R)) + +#define _mm512_ipcvts_ps_epi8(A) \ + ((__m512i)__builtin_ia32_vcvtps2ibs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvts_ps_epi8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvtps2ibs512_mask((__v16sf)(__m512)(A), \ + (__v16su)(W), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvts_ps_epi8(U, A) \ + ((__m512i)__builtin_ia32_vcvtps2ibs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvts_roundps_epi8(A, R) \ + ((__m512i)__builtin_ia32_vcvtps2ibs512_mask((__v16sf)(__m512)(A), \ + (__v16su)_mm512_setzero_si512(), \ + (__mmask16) - 1, (const int)R)) + +#define _mm512_mask_ipcvts_roundps_epi8(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtps2ibs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)(W), (__mmask16)(U), (const int)R)) + +#define _mm512_maskz_ipcvts_roundps_epi8(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtps2ibs512_mask((__v16sf)(__m512)(A), \ + (__v16su)_mm512_setzero_si512(), \ + (__mmask16)(U), (const int)R)) + +#define _mm512_ipcvts_ps_epu8(A) \ + ((__m512i)__builtin_ia32_vcvtps2iubs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvts_ps_epu8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvtps2iubs512_mask((__v16sf)(__m512)(A), \ + (__v16su)(W), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvts_ps_epu8(U, A) \ + ((__m512i)__builtin_ia32_vcvtps2iubs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvts_roundps_epu8(A, R) \ + ((__m512i)__builtin_ia32_vcvtps2iubs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + (const int)R)) + +#define _mm512_mask_ipcvts_roundps_epu8(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtps2iubs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)(W), (__mmask16)(U), (const int)R)) + +#define _mm512_maskz_ipcvts_roundps_epu8(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtps2iubs512_mask( \ + (__v16sf)(__m512)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + (const int)R)) + +#define _mm512_ipcvtts_ph_epi8(A) \ + ((__m512i)__builtin_ia32_vcvttph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvtts_ph_epi8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvttph2ibs512_mask((__v32hf)(__m512h)(A), \ + (__v32hu)(W), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvtts_ph_epi8(U, A) \ + ((__m512i)__builtin_ia32_vcvttph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvtts_roundph_epi8(A, S) \ + ((__m512i)__builtin_ia32_vcvttph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + S)) + +#define _mm512_mask_ipcvtts_roundph_epi8(W, U, A, S) \ + ((__m512i)__builtin_ia32_vcvttph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)(W), (__mmask32)(U), S)) + +#define _mm512_maskz_ipcvtts_roundph_epi8(U, A, S) \ + ((__m512i)__builtin_ia32_vcvttph2ibs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + S)) + +#define _mm512_ipcvtts_ph_epu8(A) \ + ((__m512i)__builtin_ia32_vcvttph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvtts_ph_epu8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvttph2iubs512_mask((__v32hf)(__m512h)(A), \ + (__v32hu)(W), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvtts_ph_epu8(U, A) \ + ((__m512i)__builtin_ia32_vcvttph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvtts_roundph_epu8(A, S) \ + ((__m512i)__builtin_ia32_vcvttph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32) - 1, \ + S)) + +#define _mm512_mask_ipcvtts_roundph_epu8(W, U, A, S) \ + ((__m512i)__builtin_ia32_vcvttph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)(W), (__mmask32)(U), S)) + +#define _mm512_maskz_ipcvtts_roundph_epu8(U, A, S) \ + ((__m512i)__builtin_ia32_vcvttph2iubs512_mask( \ + (__v32hf)(__m512h)(A), (__v32hu)_mm512_setzero_si512(), (__mmask32)(U), \ + S)) + +#define _mm512_ipcvtts_ps_epi8(A) \ + ((__m512i)__builtin_ia32_vcvttps2ibs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvtts_ps_epi8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvttps2ibs512_mask((__v16sf)(__m512h)(A), \ + (__v16su)(W), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvtts_ps_epi8(U, A) \ + ((__m512i)__builtin_ia32_vcvttps2ibs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvtts_roundps_epi8(A, S) \ + ((__m512i)__builtin_ia32_vcvttps2ibs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + S)) + +#define _mm512_mask_ipcvtts_roundps_epi8(W, U, A, S) \ + ((__m512i)__builtin_ia32_vcvttps2ibs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)(W), (__mmask16)(U), S)) + +#define _mm512_maskz_ipcvtts_roundps_epi8(U, A, S) \ + ((__m512i)__builtin_ia32_vcvttps2ibs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + S)) + +#define _mm512_ipcvtts_ps_epu8(A) \ + ((__m512i)__builtin_ia32_vcvttps2iubs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_ipcvtts_ps_epu8(W, U, A) \ + ((__m512i)__builtin_ia32_vcvttps2iubs512_mask((__v16sf)(__m512h)(A), \ + (__v16su)(W), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_ipcvtts_ps_epu8(U, A) \ + ((__m512i)__builtin_ia32_vcvttps2iubs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_ipcvtts_roundps_epu8(A, S) \ + ((__m512i)__builtin_ia32_vcvttps2iubs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16) - 1, \ + S)) + +#define _mm512_mask_ipcvtts_roundps_epu8(W, U, A, S) \ + ((__m512i)__builtin_ia32_vcvttps2iubs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)(W), (__mmask16)(U), S)) + +#define _mm512_maskz_ipcvtts_roundps_epu8(U, A, S) \ + ((__m512i)__builtin_ia32_vcvttps2iubs512_mask( \ + (__v16sf)(__m512h)(A), (__v16su)_mm512_setzero_si512(), (__mmask16)(U), \ + S)) + +#endif // __AVX10_2_512SATCVTINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2bf16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2bf16intrin.h new file mode 100755 index 0000000..0ca5380 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2bf16intrin.h @@ -0,0 +1,1085 @@ +/*===-------------- avx10_2bf16intrin.h - AVX10-BF16 intrinsics ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX10_2BF16INTRIN_H +#define __AVX10_2BF16INTRIN_H + +typedef __bf16 __m128bh_u __attribute__((__vector_size__(16), __aligned__(1))); +typedef __bf16 __m256bh_u __attribute__((__vector_size__(32), __aligned__(1))); + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(128))) + +static __inline __m256bh __DEFAULT_FN_ATTRS256 _mm256_setzero_pbh(void) { + return __builtin_bit_cast(__m256bh, _mm256_setzero_ps()); +} + +static __inline __m128bh __DEFAULT_FN_ATTRS128 _mm_setzero_pbh(void) { + return __builtin_bit_cast(__m128bh, _mm_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_castbf16_ps(__m128bh __a) { + return (__m128)__a; +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_castbf16_ps(__m256bh __a) { + return (__m256)__a; +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_castbf16_pd(__m256bh __a) { + return (__m256d)__a; +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 _mm_castbf16_pd(__m128bh __a) { + return (__m128d)__a; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_castbf16_si128(__m128bh __a) { + return (__m128i)__a; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_castbf16_si256(__m256bh __a) { + return (__m256i)__a; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_castps_pbh(__m128 __a) { + return (__m128bh)__a; +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_castps_pbh(__m256 __a) { + return (__m256bh)__a; +} + +static __inline__ __bf16 __DEFAULT_FN_ATTRS128 _mm_cvtsbh_bf16(__m128bh __a) { + return __a[0]; +} + +static __inline__ __bf16 __DEFAULT_FN_ATTRS256 +_mm256_cvtsbh_bf16(__m256bh __a) { + return __a[0]; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_castpd_pbh(__m128d __a) { + return (__m128bh)__a; +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_castpd_pbh(__m256d __a) { + return (__m256bh)__a; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_castsi128_pbh(__m128i __a) { + return (__m128bh)__a; +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_castsi256_pbh(__m256i __a) { + return (__m256bh)__a; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS256 +_mm256_castbf16256_pbh128(__m256bh __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_castbf16128_pbh256(__m128bh __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, -1, -1, -1, + -1, -1, -1, -1, -1); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_zextbf16128_pbh256(__m128bh __a) { + return __builtin_shufflevector(__a, (__v8bf)_mm_setzero_pbh(), 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_undefined_pbh(void) { + return (__m256bh)__builtin_ia32_undef256(); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_load_sbh(void const *__dp) { + __m128bh src = (__v8bf)_mm_setzero_pbh(); + return (__m128bh)__builtin_ia32_loadsbf16128_mask((const __v8bf *)__dp, src, + 1); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_load_sbh(__m128bh __W, __mmask8 __U, const void *__A) { + __m128bh src = (__v8bf)__builtin_shufflevector( + (__v8bf)__W, (__v8bf)_mm_setzero_pbh(), 0, 8, 8, 8, 8, 8, 8, 8); + + return (__m128bh)__builtin_ia32_loadsbf16128_mask((const __v8bf *)__A, src, + __U & 1); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_load_sbh(__mmask8 __U, const void *__A) { + return (__m128bh)__builtin_ia32_loadsbf16128_mask( + (const __v8bf *)__A, (__v8bf)_mm_setzero_pbh(), __U & 1); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_load_pbh(void const *__p) { + return *(const __m256bh *)__p; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_load_pbh(void const *__p) { + return *(const __m128bh *)__p; +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_loadu_pbh(void const *__p) { + struct __loadu_pbh { + __m256bh_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_pbh *)__p)->__v; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_loadu_pbh(void const *__p) { + struct __loadu_pbh { + __m128bh_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_pbh *)__p)->__v; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_store_sbh(void *__dp, + __m128bh __a) { + struct __mm_store_sbh_struct { + __bf16 __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_store_sbh_struct *)__dp)->__u = __a[0]; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_mask_store_sbh(void *__W, + __mmask8 __U, + __m128bh __A) { + __builtin_ia32_storesbf16128_mask((__v8bf *)__W, __A, __U & 1); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 _mm256_store_pbh(void *__P, + __m256bh __A) { + *(__m256bh *)__P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_store_pbh(void *__P, + __m128bh __A) { + *(__m128bh *)__P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 _mm256_storeu_pbh(void *__P, + __m256bh __A) { + struct __storeu_pbh { + __m256bh_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_pbh *)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_storeu_pbh(void *__P, + __m128bh __A) { + struct __storeu_pbh { + __m128bh_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_pbh *)__P)->__v = __A; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_move_sbh(__m128bh __a, + __m128bh __b) { + __a[0] = __b[0]; + return __a; +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_move_sbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return __builtin_ia32_selectsbf_128(__U, _mm_move_sbh(__A, __B), __W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_move_sbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return __builtin_ia32_selectsbf_128(__U, _mm_move_sbh(__A, __B), + _mm_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_undefined_pbh(void) { + return (__m128bh)__builtin_ia32_undef128(); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_set_sbh(__bf16 bf) { + return (__v8bf)__builtin_shufflevector( + (__v8bf){bf, bf, bf, bf, bf, bf, bf, bf}, (__v8bf)_mm_setzero_pbh(), 0, 8, + 8, 8, 8, 8, 8, 8); +} + +static __inline __m128bh __DEFAULT_FN_ATTRS128 _mm_set1_pbh(__bf16 bf) { + return (__m128bh)(__v8bf){bf, bf, bf, bf, bf, bf, bf, bf}; +} + +static __inline __m256bh __DEFAULT_FN_ATTRS256 _mm256_set1_pbh(__bf16 bf) { + return (__m256bh)(__v16bf){bf, bf, bf, bf, bf, bf, bf, bf, + bf, bf, bf, bf, bf, bf, bf, bf}; +} + +static __inline __m128bh __DEFAULT_FN_ATTRS128 +_mm_set_pbh(__bf16 bf1, __bf16 bf2, __bf16 bf3, __bf16 bf4, __bf16 bf5, + __bf16 bf6, __bf16 bf7, __bf16 bf8) { + return (__m128bh)(__v8bf){bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8}; +} + +static __inline __m256bh __DEFAULT_FN_ATTRS256 _mm256_set_pbh( + __bf16 bf1, __bf16 bf2, __bf16 bf3, __bf16 bf4, __bf16 bf5, __bf16 bf6, + __bf16 bf7, __bf16 bf8, __bf16 bf9, __bf16 bf10, __bf16 bf11, __bf16 bf12, + __bf16 bf13, __bf16 bf14, __bf16 bf15, __bf16 bf16) { + return (__m256bh)(__v16bf){bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8, + bf9, bf10, bf11, bf12, bf13, bf14, bf15, bf16}; +} + +#define _mm_setr_pbh(bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8) \ + _mm_set_pbh((bf8), (bf7), (bf6), (bf5), (bf4), (bf3), (bf2), (bf1)) + +#define _mm256_setr_pbh(bf1, bf2, bf3, bf4, bf5, bf6, bf7, bf8, bf9, bf10, \ + bf11, bf12, bf13, bf14, bf15, bf16) \ + _mm256_set_pbh((bf16), (bf15), (bf14), (bf13), (bf12), (bf11), (bf10), \ + (bf9), (bf8), (bf7), (bf6), (bf5), (bf4), (bf3), (bf2), \ + (bf1)) + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_abs_pbh(__m256bh __A) { + return (__m256bh)_mm256_and_epi32(_mm256_set1_epi32(0x7FFF7FFF), + (__m256i)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_abs_pbh(__m128bh __A) { + return (__m128bh)_mm_and_epi32(_mm_set1_epi32(0x7FFF7FFF), (__m128i)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_blend_pbh(__mmask8 __U, __m128bh __A, __m128bh __W) { + return (__m128bh)__builtin_ia32_selectpbf_128((__mmask8)__U, (__v8bf)__W, + (__v8bf)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_pbh(__mmask16 __U, __m256bh __A, __m256bh __W) { + return (__m256bh)__builtin_ia32_selectpbf_256((__mmask16)__U, (__v16bf)__W, + (__v16bf)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_permutex2var_pbh(__m128bh __A, __m128i __I, __m128bh __B) { + return (__m128bh)__builtin_ia32_vpermi2varhi128((__v8hi)__A, (__v8hi)__I, + (__v8hi)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_permutex2var_pbh(__m256bh __A, __m256i __I, __m256bh __B) { + return (__m256bh)__builtin_ia32_vpermi2varhi256((__v16hi)__A, (__v16hi)__I, + (__v16hi)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_permutexvar_pbh(__m128i __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_permvarhi128((__v8hi)__B, (__v8hi)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_permutexvar_pbh(__m256i __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_permvarhi256((__v16hi)__B, (__v16hi)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_add_pbh(__m256bh __A, + __m256bh __B) { + return (__m256bh)((__v16bf)__A + (__v16bf)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_add_pbh(__m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_add_pbh(__A, __B), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_add_pbh(__A, __B), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_add_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)((__v8bf)__A + (__v8bf)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_add_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_add_pbh(__A, __B), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_add_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_add_pbh(__A, __B), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_sub_pbh(__m256bh __A, + __m256bh __B) { + return (__m256bh)((__v16bf)__A - (__v16bf)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_sub_pbh(__m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_sub_pbh(__A, __B), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_sub_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_sub_pbh(__A, __B), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_sub_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)((__v8bf)__A - (__v8bf)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_sub_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_sub_pbh(__A, __B), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_sub_pbh(__A, __B), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mul_pbh(__m256bh __A, + __m256bh __B) { + return (__m256bh)((__v16bf)__A * (__v16bf)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_mul_pbh(__m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_mul_pbh(__A, __B), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_mul_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_mul_pbh(__A, __B), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_mul_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)((__v8bf)__A * (__v8bf)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_mul_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_mul_pbh(__A, __B), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_mul_pbh(__A, __B), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_div_pbh(__m256bh __A, + __m256bh __B) { + return (__m256bh)((__v16bf)__A / (__v16bf)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_div_pbh(__m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_div_pbh(__A, __B), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_div_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_div_pbh(__A, __B), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_div_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)((__v8bf)__A / (__v8bf)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_div_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_div_pbh(__A, __B), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_div_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_div_pbh(__A, __B), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_max_pbh(__m256bh __A, + __m256bh __B) { + return (__m256bh)__builtin_ia32_vmaxbf16256((__v16bf)__A, (__v16bf)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_max_pbh(__m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_max_pbh(__A, __B), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_max_pbh(__A, __B), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_max_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)__builtin_ia32_vmaxbf16128((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_max_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_max_pbh(__A, __B), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_max_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_max_pbh(__A, __B), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_min_pbh(__m256bh __A, + __m256bh __B) { + return (__m256bh)__builtin_ia32_vminbf16256((__v16bf)__A, (__v16bf)__B); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_min_pbh(__m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_min_pbh(__A, __B), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_min_pbh(__A, __B), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_min_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)__builtin_ia32_vminbf16128((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_min_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_min_pbh(__A, __B), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_min_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_min_pbh(__A, __B), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comieq_sbh(__m128bh __A, + __m128bh __B) { + return __builtin_ia32_vcomisbf16eq((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comilt_sbh(__m128bh __A, + __m128bh __B) { + return __builtin_ia32_vcomisbf16lt((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comile_sbh(__m128bh __A, + __m128bh __B) { + return __builtin_ia32_vcomisbf16le((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comigt_sbh(__m128bh __A, + __m128bh __B) { + return __builtin_ia32_vcomisbf16gt((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comige_sbh(__m128bh __A, + __m128bh __B) { + return __builtin_ia32_vcomisbf16ge((__v8bf)__A, (__v8bf)__B); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comineq_sbh(__m128bh __A, + __m128bh __B) { + return __builtin_ia32_vcomisbf16neq((__v8bf)__A, (__v8bf)__B); +} + +#define _mm256_cmp_pbh_mask(__A, __B, __P) \ + ((__mmask16)__builtin_ia32_vcmpbf16256_mask((__v16bf)(__m256bh)(__A), \ + (__v16bf)(__m256bh)(__B), \ + (int)(__P), (__mmask16) - 1)) + +#define _mm256_mask_cmp_pbh_mask(__U, __A, __B, __P) \ + ((__mmask16)__builtin_ia32_vcmpbf16256_mask((__v16bf)(__m256bh)(__A), \ + (__v16bf)(__m256bh)(__B), \ + (int)(__P), (__mmask16)(__U))) + +#define _mm_cmp_pbh_mask(__A, __B, __P) \ + ((__mmask8)__builtin_ia32_vcmpbf16128_mask((__v8bf)(__m128bh)(__A), \ + (__v8bf)(__m128bh)(__B), \ + (int)(__P), (__mmask8) - 1)) + +#define _mm_mask_cmp_pbh_mask(__U, __A, __B, __P) \ + ((__mmask8)__builtin_ia32_vcmpbf16128_mask((__v8bf)(__m128bh)(__A), \ + (__v8bf)(__m128bh)(__B), \ + (int)(__P), (__mmask8)(__U))) + +#define _mm256_mask_fpclass_pbh_mask(__U, __A, imm) \ + ((__mmask16)__builtin_ia32_vfpclassbf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__mmask16)(__U))) + +#define _mm256_fpclass_pbh_mask(__A, imm) \ + ((__mmask16)__builtin_ia32_vfpclassbf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__mmask16) - 1)) + +#define _mm_mask_fpclass_pbh_mask(__U, __A, imm) \ + ((__mmask8)__builtin_ia32_vfpclassbf16128_mask((__v8bf)(__m128bh)(__A), \ + (int)(imm), (__mmask8)(__U))) + +#define _mm_fpclass_pbh_mask(__A, imm) \ + ((__mmask8)__builtin_ia32_vfpclassbf16128_mask((__v8bf)(__m128bh)(__A), \ + (int)(imm), (__mmask8) - 1)) + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_scalef_pbh(__m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_vscalefbf16256_mask( + (__v16bf)__A, (__v16bf)__B, (__v16bf)_mm256_undefined_pbh(), + (__mmask16)-1); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask_scalef_pbh( + __m256bh __W, __mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_vscalefbf16256_mask( + (__v16bf)__A, (__v16bf)__B, (__v16bf)__W, (__mmask16)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_scalef_pbh(__mmask16 __U, __m256bh __A, __m256bh __B) { + return (__m256bh)__builtin_ia32_vscalefbf16256_mask( + (__v16bf)__A, (__v16bf)__B, (__v16bf)_mm256_setzero_pbh(), + (__mmask16)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_scalef_pbh(__m128bh __A, + __m128bh __B) { + return (__m128bh)__builtin_ia32_vscalefbf16128_mask( + (__v8bf)__A, (__v8bf)__B, (__v8bf)_mm_undefined_pbh(), (__mmask8)-1); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_pbh(__m128bh __W, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_vscalefbf16128_mask( + (__v8bf)__A, (__v8bf)__B, (__v8bf)__W, (__mmask8)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_pbh(__mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128bh)__builtin_ia32_vscalefbf16128_mask( + (__v8bf)__A, (__v8bf)__B, (__v8bf)_mm_setzero_pbh(), (__mmask8)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_rcp_pbh(__m256bh __A) { + return (__m256bh)__builtin_ia32_vrcpbf16256_mask( + (__v16bf)__A, (__v16bf)_mm256_undefined_pbh(), (__mmask16)-1); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_rcp_pbh(__m256bh __W, __mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_vrcpbf16256_mask((__v16bf)__A, (__v16bf)__W, + (__mmask16)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_rcp_pbh(__mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_vrcpbf16256_mask( + (__v16bf)__A, (__v16bf)_mm256_setzero_pbh(), (__mmask16)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_rcp_pbh(__m128bh __A) { + return (__m128bh)__builtin_ia32_vrcpbf16128_mask( + (__v8bf)__A, (__v8bf)_mm_undefined_pbh(), (__mmask8)-1); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_rcp_pbh(__m128bh __W, __mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_vrcpbf16128_mask((__v8bf)__A, (__v8bf)__W, + (__mmask8)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_rcp_pbh(__mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_vrcpbf16128_mask( + (__v8bf)__A, (__v8bf)_mm_setzero_pbh(), (__mmask8)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_getexp_pbh(__m256bh __A) { + return (__m256bh)__builtin_ia32_vgetexpbf16256_mask( + (__v16bf)__A, (__v16bf)_mm256_undefined_pbh(), (__mmask16)-1); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_getexp_pbh(__m256bh __W, __mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_vgetexpbf16256_mask( + (__v16bf)__A, (__v16bf)__W, (__mmask16)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_getexp_pbh(__mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_vgetexpbf16256_mask( + (__v16bf)__A, (__v16bf)_mm256_setzero_pbh(), (__mmask16)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_getexp_pbh(__m128bh __A) { + return (__m128bh)__builtin_ia32_vgetexpbf16128_mask( + (__v8bf)__A, (__v8bf)_mm_undefined_pbh(), (__mmask8)-1); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_pbh(__m128bh __W, __mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_vgetexpbf16128_mask((__v8bf)__A, (__v8bf)__W, + (__mmask8)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_pbh(__mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_vgetexpbf16128_mask( + (__v8bf)__A, (__v8bf)_mm_setzero_pbh(), (__mmask8)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_rsqrt_pbh(__m256bh __A) { + return (__m256bh)__builtin_ia32_vrsqrtbf16256_mask( + (__v16bf)__A, (__v16bf)_mm256_undefined_pbh(), (__mmask16)-1); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_rsqrt_pbh(__m256bh __W, __mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_vrsqrtbf16256_mask((__v16bf)__A, (__v16bf)__W, + (__mmask16)__U); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_rsqrt_pbh(__mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_vrsqrtbf16256_mask( + (__v16bf)__A, (__v16bf)_mm256_setzero_pbh(), (__mmask16)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_rsqrt_pbh(__m128bh __A) { + return (__m128bh)__builtin_ia32_vrsqrtbf16128_mask( + (__v8bf)__A, (__v8bf)_mm_undefined_pbh(), (__mmask8)-1); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_rsqrt_pbh(__m128bh __W, __mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_vrsqrtbf16128_mask((__v8bf)__A, (__v8bf)__W, + (__mmask8)__U); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt_pbh(__mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_vrsqrtbf16128_mask( + (__v8bf)__A, (__v8bf)_mm_setzero_pbh(), (__mmask8)__U); +} + +#define _mm256_reduce_pbh(__A, imm) \ + ((__m256bh)__builtin_ia32_vreducebf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__v16bf)_mm256_undefined_pbh(), \ + (__mmask16) - 1)) + +#define _mm256_mask_reduce_pbh(__W, __U, __A, imm) \ + ((__m256bh)__builtin_ia32_vreducebf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__v16bf)(__m256bh)(__W), \ + (__mmask16)(__U))) + +#define _mm256_maskz_reduce_pbh(__U, __A, imm) \ + ((__m256bh)__builtin_ia32_vreducebf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__v16bf)_mm256_setzero_pbh(), \ + (__mmask16)(__U))) + +#define _mm_reduce_pbh(__A, imm) \ + ((__m128bh)__builtin_ia32_vreducebf16128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(imm), (__v8bf)_mm_undefined_pbh(), \ + (__mmask8) - 1)) + +#define _mm_mask_reduce_pbh(__W, __U, __A, imm) \ + ((__m128bh)__builtin_ia32_vreducebf16128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(imm), (__v8bf)(__m128bh)(__W), \ + (__mmask8)(__U))) + +#define _mm_maskz_reduce_pbh(__U, __A, imm) \ + ((__m128bh)__builtin_ia32_vreducebf16128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(imm), (__v8bf)_mm_setzero_pbh(), \ + (__mmask8)(__U))) + +#define _mm256_roundscale_pbh(__A, imm) \ + ((__m256bh)__builtin_ia32_vrndscalebf16_256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__v16bf)_mm256_setzero_pbh(), \ + (__mmask16) - 1)) + +#define _mm256_mask_roundscale_pbh(__W, __U, __A, imm) \ + ((__m256bh)__builtin_ia32_vrndscalebf16_256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__v16bf)(__m256bh)(__W), \ + (__mmask16)(__U))) + +#define _mm256_maskz_roundscale_pbh(__U, __A, imm) \ + ((__m256bh)__builtin_ia32_vrndscalebf16_256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(imm), (__v16bf)_mm256_setzero_pbh(), \ + (__mmask16)(__U))) + +#define _mm_roundscale_pbh(__A, imm) \ + ((__m128bh)__builtin_ia32_vrndscalebf16_128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(imm), (__v8bf)_mm_setzero_pbh(), \ + (__mmask8) - 1)) + +#define _mm_mask_roundscale_pbh(__W, __U, __A, imm) \ + ((__m128bh)__builtin_ia32_vrndscalebf16_128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(imm), (__v8bf)(__m128bh)(__W), \ + (__mmask8)(__U))) + +#define _mm_maskz_roundscale_pbh(__U, __A, imm) \ + ((__m128bh)__builtin_ia32_vrndscalebf16_128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(imm), (__v8bf)_mm_setzero_pbh(), \ + (__mmask8)(__U))) + +#define _mm256_getmant_pbh(__A, __B, __C) \ + ((__m256bh)__builtin_ia32_vgetmantbf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v16bf)_mm256_undefined_pbh(), (__mmask16) - 1)) + +#define _mm256_mask_getmant_pbh(__W, __U, __A, __B, __C) \ + ((__m256bh)__builtin_ia32_vgetmantbf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v16bf)(__m256bh)(__W), (__mmask16)(__U))) + +#define _mm256_maskz_getmant_pbh(__U, __A, __B, __C) \ + ((__m256bh)__builtin_ia32_vgetmantbf16256_mask( \ + (__v16bf)(__m256bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v16bf)_mm256_setzero_pbh(), (__mmask16)(__U))) + +#define _mm_getmant_pbh(__A, __B, __C) \ + ((__m128bh)__builtin_ia32_vgetmantbf16128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v8bf)_mm_undefined_pbh(), (__mmask8) - 1)) + +#define _mm_mask_getmant_pbh(__W, __U, __A, __B, __C) \ + ((__m128bh)__builtin_ia32_vgetmantbf16128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v8bf)(__m128bh)(__W), (__mmask8)(__U))) + +#define _mm_maskz_getmant_pbh(__U, __A, __B, __C) \ + ((__m128bh)__builtin_ia32_vgetmantbf16128_mask( \ + (__v8bf)(__m128bh)(__A), (int)(((__C) << 2) | (__B)), \ + (__v8bf)_mm_setzero_pbh(), (__mmask8)(__U))) + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_sqrt_pbh(__m256bh __A) { + return (__m256bh)__builtin_ia32_vsqrtbf16256((__v16bf)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_sqrt_pbh(__m256bh __W, __mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, (__v16bf)_mm256_sqrt_pbh(__A), (__v16bf)__W); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_sqrt_pbh(__mmask16 __U, __m256bh __A) { + return (__m256bh)__builtin_ia32_selectpbf_256((__mmask16)__U, + (__v16bf)_mm256_sqrt_pbh(__A), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_sqrt_pbh(__m128bh __A) { + return (__m128bh)__builtin_ia32_vsqrtbf16((__v8bf)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_sqrt_pbh(__m128bh __W, __mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_sqrt_pbh(__A), (__v8bf)__W); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_sqrt_pbh(__mmask8 __U, __m128bh __A) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, (__v8bf)_mm_sqrt_pbh(__A), (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_fmadd_pbh(__m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_vfmaddbf16256((__v16bf)__A, (__v16bf)__B, + (__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_fmadd_pbh(__m256bh __A, __mmask16 __U, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fmadd_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), (__v16bf)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask3_fmadd_pbh( + __m256bh __A, __m256bh __B, __m256bh __C, __mmask16 __U) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fmadd_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), (__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_maskz_fmadd_pbh( + __mmask16 __U, __m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fmadd_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_fmsub_pbh(__m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_vfmaddbf16256((__v16bf)__A, (__v16bf)__B, + -(__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsub_pbh(__m256bh __A, __mmask16 __U, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fmsub_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), (__v16bf)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask3_fmsub_pbh( + __m256bh __A, __m256bh __B, __m256bh __C, __mmask16 __U) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fmsub_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), (__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_maskz_fmsub_pbh( + __mmask16 __U, __m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fmsub_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_fnmadd_pbh(__m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_vfmaddbf16256((__v16bf)__A, -(__v16bf)__B, + (__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask_fnmadd_pbh( + __m256bh __A, __mmask16 __U, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fnmadd_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask3_fnmadd_pbh( + __m256bh __A, __m256bh __B, __m256bh __C, __mmask16 __U) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fnmadd_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_maskz_fnmadd_pbh( + __mmask16 __U, __m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fnmadd_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_fnmsub_pbh(__m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_vfmaddbf16256((__v16bf)__A, -(__v16bf)__B, + -(__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask_fnmsub_pbh( + __m256bh __A, __mmask16 __U, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fnmsub_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)__A); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_mask3_fnmsub_pbh( + __m256bh __A, __m256bh __B, __m256bh __C, __mmask16 __U) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fnmsub_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)__C); +} + +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 _mm256_maskz_fnmsub_pbh( + __mmask16 __U, __m256bh __A, __m256bh __B, __m256bh __C) { + return (__m256bh)__builtin_ia32_selectpbf_256( + (__mmask16)__U, + _mm256_fnmsub_pbh((__v16bf)__A, (__v16bf)__B, (__v16bf)__C), + (__v16bf)_mm256_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_fmadd_pbh(__m128bh __A, + __m128bh __B, + __m128bh __C) { + return (__m128bh)__builtin_ia32_vfmaddbf16128((__v8bf)__A, (__v8bf)__B, + (__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_pbh(__m128bh __A, __mmask8 __U, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fmadd_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_pbh(__m128bh __A, __m128bh __B, __m128bh __C, __mmask8 __U) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fmadd_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_pbh(__mmask8 __U, __m128bh __A, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fmadd_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_fmsub_pbh(__m128bh __A, + __m128bh __B, + __m128bh __C) { + return (__m128bh)__builtin_ia32_vfmaddbf16128((__v8bf)__A, (__v8bf)__B, + -(__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_fmsub_pbh(__m128bh __A, __mmask8 __U, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fmsub_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_pbh(__m128bh __A, __m128bh __B, __m128bh __C, __mmask8 __U) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fmsub_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_pbh(__mmask8 __U, __m128bh __A, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fmsub_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_fnmadd_pbh(__m128bh __A, + __m128bh __B, + __m128bh __C) { + return (__m128bh)__builtin_ia32_vfmaddbf16128((__v8bf)__A, -(__v8bf)__B, + (__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_pbh(__m128bh __A, __mmask8 __U, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fnmadd_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_pbh(__m128bh __A, __m128bh __B, __m128bh __C, __mmask8 __U) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fnmadd_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_pbh(__mmask8 __U, __m128bh __A, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fnmadd_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)_mm_setzero_pbh()); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 _mm_fnmsub_pbh(__m128bh __A, + __m128bh __B, + __m128bh __C) { + return (__m128bh)__builtin_ia32_vfmaddbf16128((__v8bf)__A, -(__v8bf)__B, + -(__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_pbh(__m128bh __A, __mmask8 __U, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fnmsub_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__A); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_pbh(__m128bh __A, __m128bh __B, __m128bh __C, __mmask8 __U) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fnmsub_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)__C); +} + +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_pbh(__mmask8 __U, __m128bh __A, __m128bh __B, __m128bh __C) { + return (__m128bh)__builtin_ia32_selectpbf_128( + (__mmask8)__U, _mm_fnmsub_pbh((__v8bf)__A, (__v8bf)__B, (__v8bf)__C), + (__v8bf)_mm_setzero_pbh()); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2convertintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2convertintrin.h new file mode 100755 index 0000000..19d91d4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2convertintrin.h @@ -0,0 +1,3257 @@ +/*===--------------- avx10_2convertintrin.h - AVX10_2CONVERT ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifdef __SSE2__ + +#ifndef __AVX10_2CONVERTINTRIN_H +#define __AVX10_2CONVERTINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(256))) + +// clang-format off + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed +/// single-precision (32-bit) floating-point elements to a 128-bit vector +/// containing FP16 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF i < 4 +/// dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i]) +/// ELSE +/// dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4]) +/// FI +/// +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __B +/// A 128-bit vector of [4 x float]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Lower 4 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtx2ps_ph(__m128 __A, + __m128 __B) { + return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask( + (__v4sf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)(-1)); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed +/// single-precision (32-bit) floating-point elements to a 128-bit vector +/// containing FP16 elements. Merging mask \a __U is used to determine if given +/// element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// IF i < 4 +/// dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i]) +/// ELSE +/// dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4]) +/// FI +/// ELSE +/// dst.fp16[i] := __W.fp16[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction. +/// +/// \param __W +/// A 128-bit vector of [8 x fp16]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __B +/// A 128-bit vector of [4 x float]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Lower elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtx2ps_ph(__m128h __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask( + (__v4sf)__A, (__v4sf)__B, (__v8hf)__W, (__mmask8)__U); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed +/// single-precision (32-bit) floating-point elements to a 128-bit vector +/// containing FP16 elements. Zeroing mask \a __U is used to determine if given +/// element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// IF i < 4 +/// dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i]) +/// ELSE +/// dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 4]) +/// FI +/// ELSE +/// dst.fp16[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __B +/// A 128-bit vector of [4 x float]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Lower elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// then zero is taken instead. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtx2ps_ph(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128h)__builtin_ia32_vcvt2ps2phx128_mask( + (__v4sf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed +/// single-precision (32-bit) floating-point elements to a 256-bit vector +/// containing FP16 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF i < 8 +/// dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i]) +/// ELSE +/// dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 8]) +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __B +/// A 256-bit vector of [8 x float]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Lower elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvtx2ps_ph(__m256 __A, + __m256 __B) { + return (__m256h)__builtin_ia32_vcvt2ps2phx256_mask( + (__v8sf)__A, (__v8sf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)(-1)); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed +/// single-precision (32-bit) floating-point elements to a 256-bit vector +/// containing FP16 elements. Merging mask \a __U is used to determine if given +/// element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i]) +/// ELSE +/// dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 8]) +/// FI +/// ELSE +/// dst.fp16[i] := __W.fp16[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction. +/// +/// \param __W +/// A 256-bit vector of [16 x fp16]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __B +/// A 256-bit vector of [8 x float]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Lower elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtx2ps_ph(__m256h __W, __mmask16 __U, __m256 __A, __m256 __B) { + return (__m256h)__builtin_ia32_vcvt2ps2phx256_mask( + (__v8sf)__A, (__v8sf)__B, (__v16hf)__W, (__mmask16)__U); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed +/// single-precision (32-bit) floating-point elements to a 256-bit vector +/// containing FP16 elements. Zeroing mask \a __U is used to determine if given +/// element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i]) +/// ELSE +/// dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 8]) +/// FI +/// ELSE +/// dst.fp16[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __B +/// A 256-bit vector of [8 x float]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Lower elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// then zero is taken instead. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtx2ps_ph(__mmask16 __U, __m256 __A, __m256 __B) { + return (__m256h)__builtin_ia32_vcvt2ps2phx256_mask( + (__v8sf)__A, (__v8sf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// converted elements from \a __B using biases from \a __A; higher order +/// elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtbiasph_bf8(__m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Merging mask \a __U is used to determine if +/// given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtbiasph_bf8(__m128i __W, __mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Zeroing mask \a __U is used to determine if +/// given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtbiasph_bf8(__mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask8)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Elements correspond to the +/// converted elements from \a __B using biases from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtbiasph_bf8(__m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_undefined_si128(), + (__mmask16)-1); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Merging mask \a __U is used to determine if +/// given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 _mm256_mask_cvtbiasph_bf8( + __m128i __W, __mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Zeroing mask \a __U is used to determine if +/// given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtbiasph_bf8(__mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask16)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// converted elements from \a __B using biases from \a __A; higher order +/// elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvts_biasph_bf8(__m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8s_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Merging mask \a __U +/// is used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_mask_cvts_biasph_bf8(__m128i + __W, __mmask8 __U, __m128i __A, __m128h __B) { return + (__m128i)__builtin_ia32_vcvtbiasph2bf8s_128_mask( (__v16qi)__A, + (__v8hf)__B, (__v16qi)(__m128i)__W, (__mmask8)__U); } + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Zeroing mask \a __U +/// is used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8S instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvts_biasph_bf8(__mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8s_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask8)__U); +} + + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8S instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Elements correspond to the +/// converted elements from \a __B using biases from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvts_biasph_bf8(__m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8s_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_undefined_si128(), + (__mmask16)-1); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Merging mask \a __U +/// is used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 _mm256_mask_cvts_biasph_bf8( + __m128i __W, __mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8s_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E5M2 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Zeroing mask \a __U +/// is used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2BF8S instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvts_biasph_bf8(__mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2bf8s_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask16)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// converted elements from \a __B using biases from \a __A; higher order +/// elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtbiasph_hf8(__m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Merging mask \a __U is used to determine if +/// given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtbiasph_hf8(__m128i __W, __mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Zeroing mask \a __U is used to determine if +/// given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8 instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtbiasph_hf8(__mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask8)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8 instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x half]. +/// \param __B +/// A 256-bit vector of [16 x i16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Elements correspond to the +/// converted elements from \a __B using biases from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtbiasph_hf8(__m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_undefined_si128(), + (__mmask16)-1); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Merging mask \a __U is used to determine if +/// given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 _mm256_mask_cvtbiasph_hf8( + __m128i __W, __mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Zeroing mask \a __U is used to determine if +/// given element should be taken zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8 instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x half]. +/// \param __B +/// A 256-bit vector of [16 x i16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtbiasph_hf8(__mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask16)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8S`instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// converted elements from \a __B using biases from \a __A; higher order +/// elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvts_biasph_hf8(__m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8s_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Merging mask \a __U +/// is used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvts_biasph_hf8(__m128i __W, __mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8s_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Zeroing mask \a __U +/// is used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8S instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x int16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// converted elements from \a __B, using biases from \a __A; higher order +/// elements are zeroed. If corresponding mask bit is not set, then element +/// is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvts_biasph_hf8(__mmask8 __U, __m128i __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8s_128_mask( + (__v16qi)__A, (__v8hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask8)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8S instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Elements correspond to the +/// converted elements from \a __B using biases from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvts_biasph_hf8(__m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8s_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_undefined_si128(), + (__mmask16)-1); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Merging mask \a __U +/// is used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 _mm256_mask_cvts_biasph_hf8( + __m128i __W, __mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8s_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __B containing packed FP16 floating-point elements +/// to FP8 E4M3 numbers, using conversion biases stored in lower 8 bits of each +/// 16-bit integer stored in \a __B. Results are saturated. Zeroing mask \a __U +/// is used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_with_bias_saturate(__A.int8[2 * i], __B.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTBIASPH2HF8S instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x int16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Elements correspond to the converted +/// elements from \a __B, using biases from \a __A. If corresponding mask bit +/// is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvts_biasph_hf8(__mmask16 __U, __m256i __A, __m256h __B) { + return (__m128i)__builtin_ia32_vcvtbiasph2hf8s_256_mask( + (__v32qi)__A, (__v16hf)__B, (__v16qi)(__m128i)_mm_setzero_si128(), + (__mmask16)__U); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E5M2 FP8 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF i < 8 +/// dst.bf8[i] := convert_fp16_to_bf8(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i - 8]) +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvt2ph_bf8(__m128h __A, + __m128h __B) { + return (__m128i)__builtin_ia32_vcvt2ph2bf8_128((__v8hf)(__A), + (__v8hf)(__B)); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E5M2 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.bf8[i] := convert_fp16_to_bf8(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvt2ph_bf8(__m128i __W, __mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvt2ph_bf8(__A, __B), (__v16qi)__W); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E5M2 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.bf8[i] := convert_fp16_to_bf8(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8 instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvt2ph_bf8(__mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvt2ph_bf8(__A, __B), + (__v16qi)(__m128i)_mm_setzero_si128()); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E5M2 FP8 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF i < 16 +/// dst.bf8[i] := convert_fp16_to_bf8(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i - 16]) +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8 instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x bf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvt2ph_bf8(__m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_vcvt2ph2bf8_256((__v16hf)(__A), + (__v16hf)(__B)); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E5M2 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.bf8[i] := convert_fp16_to_bf8(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8 instruction. +/// +/// \param __W +/// A 256-bit vector of [32 x bf8]. +/// \param __U +/// A 32-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x bf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvt2ph_bf8( + __m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), (__v32qi)__W); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E5M2 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.bf8[i] := convert_fp16_to_bf8(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8 instruction. +/// +/// \param __U +/// A 32-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x bf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// zero is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvt2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_bf8(__A, __B), + (__v32qi)(__m256i)_mm256_setzero_si256()); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E5M2 FP8 elements. +/// Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF i < 8 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i - 8]) +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8S instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvts_2ph_bf8(__m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvt2ph2bf8s_128((__v8hf)(__A), + (__v8hf)(__B)); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E5M2 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvts_2ph_bf8(__m128i __W, __mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvts_2ph_bf8(__A, __B), (__v16qi)__W); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E5M2 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8S instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvts_2ph_bf8(__mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvts_2ph_bf8(__A, __B), + (__v16qi)(__m128i)_mm_setzero_si128()); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E5M2 FP8 elements. +/// Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF i < 16 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i - 16]) +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8S instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x bf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvts_2ph_bf8(__m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_vcvt2ph2bf8s_256((__v16hf)(__A), + (__v16hf)(__B)); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E5M2 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8S instruction. +/// +/// \param __W +/// A 256-bit vector of [32 x bf8]. +/// \param __U +/// A 32-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x bf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvts_2ph_bf8( + __m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvts_2ph_bf8(__A, __B), (__v32qi)__W); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E5M2 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2BF8S instruction. +/// +/// \param __U +/// A 32-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x bf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// zero is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvts_2ph_bf8(__mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvts_2ph_bf8(__A, __B), + (__v32qi)(__m256i)_mm256_setzero_si256()); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E4M3 FP8 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF i < 8 +/// dst.hf8[i] := convert_fp16_to_hf8(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i - 8]) +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvt2ph_hf8(__m128h __A, + __m128h __B) { + return (__m128i)__builtin_ia32_vcvt2ph2hf8_128((__v8hf)(__A), + (__v8hf)(__B)); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E4M3 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.hf8[i] := convert_fp16_to_hf8(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvt2ph_hf8(__m128i __W, __mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvt2ph_hf8(__A, __B), (__v16qi)__W); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E4M3 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.hf8[i] := convert_fp16_to_hf8(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8 instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvt2ph_hf8(__mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvt2ph_hf8(__A, __B), + (__v16qi)(__m128i)_mm_setzero_si128()); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E4M3 FP8 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF i < 16 +/// dst.hf8[i] := convert_fp16_to_hf8(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i - 16]) +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8 instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x hf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvt2ph_hf8(__m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_vcvt2ph2hf8_256((__v16hf)(__A), + (__v16hf)(__B)); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E4M3 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.hf8[i] := convert_fp16_to_hf8(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8 instruction. +/// +/// \param __W +/// A 256-bit vector of [32 x hf8]. +/// \param __U +/// A 32-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x hf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvt2ph_hf8( + __m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), (__v32qi)__W); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E4M3 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.hf8[i] := convert_fp16_to_hf8(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8 instruction. +/// +/// \param __U +/// A 32-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x hf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// zero is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvt2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvt2ph_hf8(__A, __B), + (__v32qi)(__m256i)_mm256_setzero_si256()); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E4M3 FP8 elements. +/// Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF i < 8 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i - 8]) +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8S instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvts_2ph_hf8(__m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_vcvt2ph2hf8s_128((__v8hf)(__A), + (__v8hf)(__B)); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E4M3 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvts_2ph_hf8(__m128i __W, __mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvts_2ph_hf8(__A, __B), (__v16qi)__W); +} + +/// Convert two 128-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 128-bit vector containing E4M3 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// IF i < 8 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i - 8]) +/// FI +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8S instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \param __B +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower 8 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvts_2ph_hf8(__mmask16 __U, __m128h __A, __m128h __B) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_cvts_2ph_hf8(__A, __B), + (__v16qi)(__m128i)_mm_setzero_si128()); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E4M3 FP8 elements. +/// Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF i < 16 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i - 16]) +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8S instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x hf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvts_2ph_hf8(__m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_vcvt2ph2hf8s_256((__v16hf)(__A), + (__v16hf)(__B)); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E4M3 FP8 elements. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8S instruction. +/// +/// \param __W +/// A 256-bit vector of [32 x hf8]. +/// \param __U +/// A 32-bit merging mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x hf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_mask_cvts_2ph_hf8( + __m256i __W, __mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvts_2ph_hf8(__A, __B), (__v32qi)__W); +} + +/// Convert two 256-bit vectors, \a __A and \a __B, containing packed FP16 +/// floating-point elements to a 256-bit vector containing E4M3 FP8 elements. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. Resulting elements are saturated in case of overflow. +/// +/// \code{.operation} +/// FOR i := 0 to 31 +/// IF __U[i] +/// IF i < 16 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__B.fp16[i]) +/// ELSE +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i - 16]) +/// FI +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVT2PH2HF8S instruction. +/// +/// \param __U +/// A 32-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \param __B +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 256-bit vector of [32 x hf8]. Lower 16 elements correspond to the +/// (converted) elements from \a __B; higher order elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// zero is taken instead. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvts_2ph_hf8(__mmask32 __U, __m256h __A, __m256h __B) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_cvts_2ph_hf8(__A, __B), + (__v32qi)(__m256i)_mm256_setzero_si256()); +} + +/// Convert 128-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 128-bit vector containing FP16 elements. The conversion is exact. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.fp16[i] := convert_hf8_to_fp16(__A.hf8[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTHF82PH instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x hf8]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvthf8_ph(__m128i __A) { + return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask( + (__v16qi)__A, (__v8hf)(__m128h)_mm_undefined_ph(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 128-bit vector containing FP16 elements. The conversion is +/// exact. Merging mask \a __U is used to determine if given element should be +/// taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.fp16[i] := convert_hf8_to_fp16(__A.hf8[i]) +/// ELSE +/// dst.fp16[i] := __W.fp16[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTHF82PH instruction. +/// +/// \param __W +/// A 128-bit vector of [8 x fp16]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [16 x hf8]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvthf8_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask( + (__v16qi)__A, (__v8hf)(__m128h)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 128-bit vector containing FP16 elements. The conversion is +/// exact. Zeroing mask \a __U is used to determine if given element should be +/// zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.fp16[i] := convert_hf8_to_fp16(__A.hf8[i]) +/// ELSE +/// dst.fp16[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTHF82PH instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [16 x hf8]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvthf8_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvthf8_2ph128_mask( + (__v16qi)__A, (__v8hf)(__m128h)_mm_setzero_ph(), (__mmask8)__U); +} + +/// Convert 256-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 256-bit vector containing FP16 elements. The conversion is exact. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.fp16[i] := convert_hf8_to_fp16(__A.hf8[i]) +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTHF82PH instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x hf8]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvthf8_ph(__m128i __A) { + return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask( + (__v16qi)__A, (__v16hf)(__m256h)_mm256_undefined_ph(), (__mmask16)-1); +} + +/// Convert 256-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 256-bit vector containing FP16 elements. The conversion is +/// exact. Merging mask \a __U is used to determine if given element should be +/// taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.fp16[i] := convert_hf8_to_fp16(__A.hf8[i]) +/// ELSE +/// dst.fp16[i] := __W.fp16[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTHF82PH instruction. +/// +/// \param __W +/// A 256-bit vector of [16 x fp16]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [32 x hf8]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvthf8_ph(__m256h __W, __mmask16 __U, __m128i __A) { + return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask( + (__v16qi)__A, (__v16hf)(__m256h)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 256-bit vector containing FP16 elements. The conversion is +/// exact. Zeroing mask \a __U is used to determine if given element should be +/// zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.fp16[i] := convert_hf8_to_fp16(__A.hf8[i]) +/// ELSE +/// dst.fp16[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:256] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTHF82PH instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [32 x hf8]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvthf8_ph(__mmask16 __U, __m128i __A) { + return (__m256h)__builtin_ia32_vcvthf8_2ph256_mask( + (__v16qi)__A, (__v16hf)(__m256h)_mm256_setzero_ph(), (__mmask16)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the (converted) +/// elements from \a __A; upper elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_bf8(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. Merging mask \a __U is used to determine if +/// given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_bf8(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. Zeroing mask \a __U is used to determine if +/// given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8 instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_bf8(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask8)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8 instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Resulting elements correspond to the (converted) +/// elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_bf8(__m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask16)-1); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Merging mask \a __U is +/// used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_bf8(__m128i __W, __mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Zeroing mask \a __U is +/// used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8 instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// then element is zeroed instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_bf8(__mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask16)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8S instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the (converted) +/// elements from \a __A; upper elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvts_ph_bf8(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8s_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. Results are saturated. Merging mask \a __U is +/// used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvts_ph_bf8(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8s_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. Results are saturated. Zeroing mask \a __U is +/// used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8S instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvts_ph_bf8(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8s_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask8)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8S instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Resulting elements correspond to the (converted) +/// elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvts_ph_bf8(__m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8s_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask16)-1); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Results are saturated. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := __W.bf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x bf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvts_ph_bf8(__m128i __W, __mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8s_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Results are saturated. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.bf8[i] := convert_fp16_to_bf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.bf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2BF8S instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x bf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// then element is zeroed instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvts_ph_bf8(__mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2bf8s_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask16)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E5M2 FP8 elements. Upper elements of +/// resulting vector are zeroed. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8 instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the (converted) +/// elements from \a __A; upper elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_hf8(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Upper elements of +/// resulting vector are zeroed. Merging mask \a __U is used to determine if +/// given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_hf8(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Upper elements of +/// resulting vector are zeroed. Zeroing mask \a __U is used to determine if +/// given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8 instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_hf8(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask8)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8 instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Resulting elements correspond to the (converted) +/// elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_hf8(__m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask16)-1); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Merging mask \a __U is +/// used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8 instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_hf8(__m128i __W, __mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Zeroing mask \a __U is +/// used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8 instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// then element is zeroed instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_hf8(__mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask16)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Upper elements of +/// resulting vector are zeroed. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8S instruction. +/// +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the (converted) +/// elements from \a __A; upper elements are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvts_ph_hf8(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8s_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask8)-1); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Upper elements of +/// resulting vector are zeroed. Results are saturated. Merging mask \a __U is +/// used to determine if given element should be taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvts_ph_hf8(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8s_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)__W, (__mmask8)__U); +} + +/// Convert 128-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Upper elements of +/// resulting vector are zeroed. Results are saturated. Zeroing mask \a __U is +/// used to determine if given element should be zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8S instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Lower elements correspond to the +/// (converted) elements from \a __A; upper elements are zeroed. If +/// corresponding mask bit is not set, then element is zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvts_ph_hf8(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8s_128_mask( + (__v8hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask8)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Results are saturated. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i]) +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8S instruction. +/// +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Resulting elements correspond to the (converted) +/// elements from \a __A. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvts_ph_hf8(__m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8s_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_undefined_si128(), (__mmask16)-1); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Results are saturated. +/// Merging mask \a __U is used to determine if given element should be taken +/// from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := __W.hf8[i] +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8S instruction. +/// +/// \param __W +/// A 128-bit vector of [16 x hf8]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [8 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If +/// corresponding mask bit is not set, then element from \a __W is taken instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvts_ph_hf8(__m128i __W, __mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8s_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)__W, (__mmask16)__U); +} + +/// Convert 256-bit vector \a __A containing packed FP16 floating-point elements +/// to a 128-bit vector containing E4M3 FP8 elements. Results are saturated. +/// Zeroing mask \a __U is used to determine if given element should be zeroed +/// instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.hf8[i] := convert_fp16_to_hf8_saturate(__A.fp16[i]) +/// ELSE +/// dst.hf8[i] := 0 +/// FI +/// ENDFOR +/// +/// dst[MAX:128] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VCVTPH2HF8S instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [16 x fp16]. +/// \returns +/// A 128-bit vector of [16 x hf8]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, +/// then element is zeroed instead. +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvts_ph_hf8(__mmask16 __U, __m256h __A) { + return (__m128i)__builtin_ia32_vcvtph2hf8s_256_mask( + (__v16hf)__A, (__v16qi)(__m128i)_mm_setzero_si128(), (__mmask16)__U); +} + +/// Convert 128-bit vector \a __A, containing packed FP8 E5M2 floating-point +/// elements to a 128-bit vector containing FP16 elements. The conversion is exact. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// dst.fp16[i] := convert_bf8_to_fp16(__A.bf8[i]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a single instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x bf8]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtbf8_ph(__m128i __A) { + return _mm_castsi128_ph(_mm_slli_epi16(_mm_cvtepi8_epi16(__A), 8)); +} + +/// Convert 128-bit vector \a __A, containing packed FP8 E5M2 floating-point +/// elements to a 128-bit vector containing FP16 elements. The conversion is +/// exact. Merging mask \a __U is used to determine if given element should be +/// taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.fp16[i] := convert_bf8_to_fp16(__A.bf8[i]) +/// ELSE +/// dst.fp16[i] := __W.fp16[i] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a single instruction. +/// +/// \param __W +/// A 128-bit vector of [8 x fp16]. +/// \param __U +/// A 8-bit merging mask. +/// \param __A +/// A 128-bit vector of [16 x bf8]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtbf8_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return _mm_castsi128_ph( + _mm_mask_slli_epi16((__m128i)__W, __U, _mm_cvtepi8_epi16(__A), 8)); +} + +/// Convert 128-bit vector \a __A, containing packed FP8 E5M2 floating-point +/// elements to a 128-bit vector containing FP16 elements. The conversion is +/// exact. Zeroing mask \a __U is used to determine if given element should be +/// zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 7 +/// IF __U[i] +/// dst.fp16[i] := convert_bf8_to_fp16(__A.bf8[i]) +/// ELSE +/// dst.fp16[i] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a single instruction. +/// +/// \param __U +/// A 8-bit zeroing mask. +/// \param __A +/// A 128-bit vector of [16 x bf8]. +/// \returns +/// A 128-bit vector of [8 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtbf8_ph(__mmask8 __U, __m128i __A) { + return _mm_castsi128_ph(_mm_slli_epi16(_mm_maskz_cvtepi8_epi16(__U, __A), 8)); +} + +/// Convert 256-bit vector \a __A, containing packed FP8 E4M3 floating-point +/// elements to a 256-bit vector containing FP16 elements. The conversion is exact. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// dst.fp16[i] := convert_bf8_to_fp16(__A.bf8[i]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a single instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x bf8]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvtbf8_ph(__m128i __A) { + return _mm256_castsi256_ph(_mm256_slli_epi16(_mm256_cvtepi8_epi16(__A), 8)); +} + +/// Convert 256-bit vector \a __A, containing packed FP8 E5M2 floating-point +/// elements to a 256-bit vector containing FP16 elements. The conversion is +/// exact. Merging mask \a __U is used to determine if given element should be +/// taken from \a __W instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.fp16[i] := convert_bf8_to_fp16(__A.bf8[i]) +/// ELSE +/// dst.fp16[i] := __W.fp16[i] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a single instruction. +/// +/// \param __W +/// A 256-bit vector of [16 x fp16]. +/// \param __U +/// A 16-bit merging mask. +/// \param __A +/// A 256-bit vector of [32 x bf8]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// element from \a __W is taken instead. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtbf8_ph(__m256h __W, __mmask16 __U, __m128i __A) { + return _mm256_castsi256_ph( + _mm256_mask_slli_epi16((__m256i)__W, __U, _mm256_cvtepi8_epi16(__A), 8)); +} + +/// Convert 256-bit vector \a __A, containing packed FP8 E5M2 floating-point +/// elements to a 256-bit vector containing FP16 elements. The conversion is +/// exact. Zeroing mask \a __U is used to determine if given element should be +/// zeroed instead. +/// +/// \code{.operation} +/// FOR i := 0 to 15 +/// IF __U[i] +/// dst.fp16[i] := convert_bf8_to_fp16(__A.bf8[i]) +/// ELSE +/// dst.fp16[i] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a single instruction. +/// +/// \param __U +/// A 16-bit zeroing mask. +/// \param __A +/// A 256-bit vector of [32 x bf8]. +/// \returns +/// A 256-bit vector of [16 x fp16]. Resulting elements correspond to the +/// (converted) elements from \a __A. If corresponding mask bit is not set, then +/// zero is taken instead. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtbf8_ph(__mmask16 __U, __m128i __A) { + return _mm256_castsi256_ph( + _mm256_slli_epi16(_mm256_maskz_cvtepi8_epi16(__U, __A), 8)); +} + +// clang-format on + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif // __AVX10_2CONVERTINTRIN_H +#endif // __SSE2__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2copyintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2copyintrin.h new file mode 100755 index 0000000..76b8f8c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2copyintrin.h @@ -0,0 +1,66 @@ +/*===---- avx10_2copyintrin.h - AVX10.2 Copy intrinsics -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2COPYINTRIN_H +#define __AVX10_2COPYINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(128))) + +/// Constructs a 128-bit integer vector, setting the lower 32 bits to the +/// lower 32 bits of the parameter \a __A; the upper bits are zeoroed. +/// +/// \code{.operation} +/// result[31:0] := __A[31:0] +/// result[MAX:32] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVD instruction. +/// +/// \param __A +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector. The lower 32 bits are copied from the +/// parameter \a __A; the upper bits are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi32(__m128i __A) { + return (__m128i)__builtin_shufflevector( + (__v4si)__A, (__v4si)_mm_setzero_si128(), 0, 4, 4, 4); +} + +/// Constructs a 128-bit integer vector, setting the lower 16 bits to the +/// lower 16 bits of the parameter \a __A; the upper bits are zeoroed. +/// +/// \code{.operation} +/// result[15:0] := __A[15:0] +/// result[MAX:16] := 0 +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVW instruction. +/// +/// \param __A +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector. The lower 16 bits are copied from the +/// parameter \a __A; the upper bits are zeroed. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi16(__m128i __A) { + return (__m128i)__builtin_shufflevector( + (__v8hi)__A, (__v8hi)_mm_setzero_si128(), 0, 8, 8, 8, 8, 8, 8, 8); +} + +#undef __DEFAULT_FN_ATTRS128 + +#endif // __AVX10_2COPYINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2minmaxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2minmaxintrin.h new file mode 100755 index 0000000..809a01b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2minmaxintrin.h @@ -0,0 +1,232 @@ +/*===-------- avx10_2minmaxintrin.h - AVX10_2MINMAX intrinsics -------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2MINMAXINTRIN_H +#define __AVX10_2MINMAXINTRIN_H + +#define _mm_minmax_pbh(A, B, C) \ + ((__m128bh)__builtin_ia32_vminmaxbf16128((__m128bh)(__v8bf)(A), \ + (__m128bh)(__v8bf)(B), (int)(C))) + +#define _mm_mask_minmax_pbh(W, U, A, B, C) \ + ((__m128bh)__builtin_ia32_selectpbf_128( \ + (__mmask8)(U), \ + (__v8bf)_mm_minmax_pbh((__m128bh)(__v8bf)(A), (__m128bh)(__v8bf)(B), \ + (int)(C)), \ + (__v8bf)(W))) + +#define _mm_maskz_minmax_pbh(U, A, B, C) \ + ((__m128bh)__builtin_ia32_selectpbf_128( \ + (__mmask8)(U), \ + (__v8bf)_mm_minmax_pbh((__m128bh)(__v8bf)(A), (__m128bh)(__v8bf)(B), \ + (int)(C)), \ + (__v8bf) __builtin_bit_cast(__m128bh, _mm_setzero_ps()))) + +#define _mm256_minmax_pbh(A, B, C) \ + ((__m256bh)__builtin_ia32_vminmaxbf16256((__m256bh)(__v16bf)(A), \ + (__m256bh)(__v16bf)(B), (int)(C))) + +#define _mm256_mask_minmax_pbh(W, U, A, B, C) \ + ((__m256bh)__builtin_ia32_selectpbf_256( \ + (__mmask16)(U), \ + (__v16bf)_mm256_minmax_pbh((__m256bh)(__v16bf)(A), \ + (__m256bh)(__v16bf)(B), (int)(C)), \ + (__v16bf)(W))) + +#define _mm256_maskz_minmax_pbh(U, A, B, C) \ + ((__m256bh)__builtin_ia32_selectpbf_256( \ + (__mmask16)(U), \ + (__v16bf)_mm256_minmax_pbh((__m256bh)(__v16bf)(A), \ + (__m256bh)(__v16bf)(B), (int)(C)), \ + (__v16bf) __builtin_bit_cast(__m256bh, _mm256_setzero_ps()))) + +#define _mm_minmax_pd(A, B, C) \ + ((__m128d)__builtin_ia32_vminmaxpd128_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_setzero_pd(), (__mmask8)-1)) + +#define _mm_mask_minmax_pd(W, U, A, B, C) \ + ((__m128d)__builtin_ia32_vminmaxpd128_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)(__m128d)(W), (__mmask8)(U))) + +#define _mm_maskz_minmax_pd(U, A, B, C) \ + ((__m128d)__builtin_ia32_vminmaxpd128_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_setzero_pd(), (__mmask8)(U))) + +#define _mm256_minmax_pd(A, B, C) \ + ((__m256d)__builtin_ia32_vminmaxpd256_mask( \ + (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C), \ + (__v4df)_mm256_setzero_pd(), (__mmask8)-1)) + +#define _mm256_mask_minmax_pd(W, U, A, B, C) \ + ((__m256d)__builtin_ia32_vminmaxpd256_mask( \ + (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C), \ + (__v4df)(__m256d)(W), (__mmask8)(U))) + +#define _mm256_maskz_minmax_pd(U, A, B, C) \ + ((__m256d)__builtin_ia32_vminmaxpd256_mask( \ + (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C), \ + (__v4df)_mm256_setzero_pd(), (__mmask8)(U))) + +#define _mm_minmax_ph(A, B, C) \ + ((__m128h)__builtin_ia32_vminmaxph128_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)-1)) + +#define _mm_mask_minmax_ph(W, U, A, B, C) \ + ((__m128h)__builtin_ia32_vminmaxph128_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)(__m128h)(W), (__mmask16)-1)) + +#define _mm_maskz_minmax_ph(U, A, B, C) \ + ((__m128h)__builtin_ia32_vminmaxph128_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)(U))) + +#define _mm256_minmax_ph(A, B, C) \ + ((__m256h)__builtin_ia32_vminmaxph256_mask( \ + (__v16hf)(__m256h)(A), (__v16hf)(__m256h)(B), (int)(C), \ + (__v16hf)_mm256_setzero_ph(), (__mmask16)-1)) + +#define _mm256_mask_minmax_ph(W, U, A, B, C) \ + ((__m256h)__builtin_ia32_vminmaxph256_mask( \ + (__v16hf)(__m256h)(A), (__v16hf)(__m256h)(B), (int)(C), \ + (__v16hf)(__m256h)(W), (__mmask16)(U))) + +#define _mm256_maskz_minmax_ph(U, A, B, C) \ + ((__m256h)__builtin_ia32_vminmaxph256_mask( \ + (__v16hf)(__m256h)(A), (__v16hf)(__m256h)(B), (int)(C), \ + (__v16hf)_mm256_setzero_ph(), (__mmask16)(U))) + +#define _mm_minmax_ps(A, B, C) \ + ((__m128)__builtin_ia32_vminmaxps128_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_setzero_ps(), (__mmask8)-1)) + +#define _mm_mask_minmax_ps(W, U, A, B, C) \ + ((__m128)__builtin_ia32_vminmaxps128_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), (__v4sf)(__m128)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_minmax_ps(U, A, B, C) \ + ((__m128)__builtin_ia32_vminmaxps128_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_setzero_ps(), (__mmask8)(U))) + +#define _mm256_minmax_ps(A, B, C) \ + ((__m256)__builtin_ia32_vminmaxps256_mask( \ + (__v8sf)(__m256)(A), (__v8sf)(__m256)(B), (int)(C), \ + (__v8sf)_mm256_setzero_ps(), (__mmask8)-1)) + +#define _mm256_mask_minmax_ps(W, U, A, B, C) \ + ((__m256)__builtin_ia32_vminmaxps256_mask( \ + (__v8sf)(__m256)(A), (__v8sf)(__m256)(B), (int)(C), (__v8sf)(__m256)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_minmax_ps(U, A, B, C) \ + ((__m256)__builtin_ia32_vminmaxps256_mask( \ + (__v8sf)(__m256)(A), (__v8sf)(__m256)(B), (int)(C), \ + (__v8sf)_mm256_setzero_ps(), (__mmask8)(U))) + +#define _mm_minmax_sd(A, B, C) \ + ((__m128d)__builtin_ia32_vminmaxsd_round_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_undefined_pd(), (__mmask8)-1, _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_minmax_sd(W, U, A, B, C) \ + ((__m128d)__builtin_ia32_vminmaxsd_round_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)(__m128d)(W), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_minmax_sd(U, A, B, C) \ + ((__m128d)__builtin_ia32_vminmaxsd_round_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_setzero_pd(), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_minmax_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_vminmaxsd_round_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_undefined_pd(), (__mmask8)-1, (int)(R))) + +#define _mm_mask_minmax_round_sd(W, U, A, B, C, R) \ + ((__m128d)__builtin_ia32_vminmaxsd_round_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)(__m128d)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_minmax_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_vminmaxsd_round_mask( \ + (__v2df)(__m128d)(A), (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_setzero_pd(), (__mmask8)(U), (int)(R))) + +#define _mm_minmax_sh(A, B, C) \ + ((__m128h)__builtin_ia32_vminmaxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)_mm_undefined_ph(), (__mmask8)-1, _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_minmax_sh(W, U, A, B, C) \ + ((__m128h)__builtin_ia32_vminmaxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)(__m128h)(W), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_minmax_sh(U, A, B, C) \ + ((__m128h)__builtin_ia32_vminmaxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_minmax_round_sh(A, B, C, R) \ + ((__m128h)__builtin_ia32_vminmaxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)_mm_undefined_ph(), (__mmask8)-1, (int)(R))) + +#define _mm_mask_minmax_round_sh(W, U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vminmaxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)(__m128h)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_minmax_round_sh(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vminmaxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(C), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +#define _mm_minmax_ss(A, B, C) \ + ((__m128)__builtin_ia32_vminmaxss_round_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_undefined_ps(), (__mmask8)-1, _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_minmax_ss(W, U, A, B, C) \ + ((__m128)__builtin_ia32_vminmaxss_round_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), (__v4sf)(W), \ + (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_minmax_ss(U, A, B, C) \ + ((__m128)__builtin_ia32_vminmaxss_round_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_setzero_ps(), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_minmax_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_vminmaxss_round_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_undefined_ps(), (__mmask8)-1, (int)(R))) + +#define _mm_mask_minmax_round_ss(W, U, A, B, C, R) \ + ((__m128)__builtin_ia32_vminmaxss_round_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), (__v4sf)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_minmax_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_vminmaxss_round_mask( \ + (__v4sf)(__m128)(A), (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_setzero_ps(), (__mmask8)(U), (int)(R))) +#endif // __AVX10_2MINMAXINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2niintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2niintrin.h new file mode 100755 index 0000000..d5a66cf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2niintrin.h @@ -0,0 +1,409 @@ +/*===---- avx10_2niintrin.h - AVX10.2 new instruction intrinsics -----------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX10_2NIINTRIN_H +#define __AVX10_2NIINTRIN_H + +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(256))) + +/* VNNI FP16 */ +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_dpph_ps(__m128 __W, + __m128h __A, + __m128h __B) { + return (__m128)__builtin_ia32_vdpphps128((__v4sf)__W, (__v8hf)__A, + (__v8hf)__B); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_mask_dpph_ps(__m128 __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128)__builtin_ia32_selectps_128( + (__mmask8)__U, (__v4sf)_mm_dpph_ps(__W, __A, __B), (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_maskz_dpph_ps(__mmask8 __U, + __m128 __W, + __m128h __A, + __m128h __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_dpph_ps(__W, __A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_dpph_ps(__m256 __W, + __m256h __A, + __m256h __B) { + return (__m256)__builtin_ia32_vdpphps256((__v8sf)__W, (__v16hf)__A, + (__v16hf)__B); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_dpph_ps(__m256 __W, __mmask8 __U, __m256h __A, __m256h __B) { + return (__m256)__builtin_ia32_selectps_256( + (__mmask8)__U, (__v8sf)_mm256_dpph_ps(__W, __A, __B), (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpph_ps(__mmask8 __U, __m256 __W, __m256h __A, __m256h __B) { + return (__m256)__builtin_ia32_selectps_256( + (__mmask8)__U, (__v8sf)_mm256_dpph_ps(__W, __A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +/* VMPSADBW */ +#define _mm_mask_mpsadbw_epu8(W, U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectw_128( \ + (__mmask8)(U), (__v8hi)_mm_mpsadbw_epu8((A), (B), (imm)), \ + (__v8hi)(__m128i)(W))) + +#define _mm_maskz_mpsadbw_epu8(U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectw_128( \ + (__mmask8)(U), (__v8hi)_mm_mpsadbw_epu8((A), (B), (imm)), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_mask_mpsadbw_epu8(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectw_256( \ + (__mmask16)(U), (__v16hi)_mm256_mpsadbw_epu8((A), (B), (imm)), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_mpsadbw_epu8(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectw_256( \ + (__mmask16)(U), (__v16hi)_mm256_mpsadbw_epu8((A), (B), (imm)), \ + (__v16hi)_mm256_setzero_si256())) + +/* VNNI INT8 */ +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbssd_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbssd_epi32(__W, __A, __B), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbssd_epi32(__mmask8 __U, __m128i __W, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbssd_epi32(__W, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbssd_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbssd_epi32(__W, __A, __B), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpbssd_epi32(__mmask8 __U, __m256i __W, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbssd_epi32(__W, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbssds_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbssds_epi32(__W, __A, __B), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbssds_epi32(__mmask8 __U, __m128i __W, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbssds_epi32(__W, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbssds_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbssds_epi32(__W, __A, __B), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_dpbssds_epi32( + __mmask8 __U, __m256i __W, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbssds_epi32(__W, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbsud_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbsud_epi32(__W, __A, __B), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbsud_epi32(__mmask8 __U, __m128i __W, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbsud_epi32(__W, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbsud_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbsud_epi32(__W, __A, __B), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpbsud_epi32(__mmask8 __U, __m256i __W, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbsud_epi32(__W, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbsuds_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbsuds_epi32(__W, __A, __B), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbsuds_epi32(__mmask8 __U, __m128i __W, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbsuds_epi32(__W, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbsuds_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbsuds_epi32(__W, __A, __B), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_dpbsuds_epi32( + __mmask8 __U, __m256i __W, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbsuds_epi32(__W, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbuud_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbuud_epi32(__W, __A, __B), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbuud_epi32(__mmask8 __U, __m128i __W, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbuud_epi32(__W, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbuud_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbuud_epi32(__W, __A, __B), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpbuud_epi32(__mmask8 __U, __m256i __W, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbuud_epi32(__W, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbuuds_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbuuds_epi32(__W, __A, __B), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbuuds_epi32(__mmask8 __U, __m128i __W, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128( + __U, (__v4si)_mm_dpbuuds_epi32(__W, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbuuds_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbuuds_epi32(__W, __A, __B), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_dpbuuds_epi32( + __mmask8 __U, __m256i __W, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256( + __U, (__v8si)_mm256_dpbuuds_epi32(__W, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +/* VNNI INT16 */ +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwsud_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwsud_epi32(__A, __B, __C), (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwsud_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwsud_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwsud_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwsud_epi32(__A, __B, __C), (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpwsud_epi32(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwsud_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwsuds_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwsuds_epi32(__A, __B, __C), (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwsuds_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwsuds_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwsuds_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwsuds_epi32(__A, __B, __C), (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_dpwsuds_epi32( + __mmask8 __U, __m256i __A, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwsuds_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwusd_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwusd_epi32(__A, __B, __C), (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwusd_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwusd_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwusd_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwusd_epi32(__A, __B, __C), (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpwusd_epi32(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwusd_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwusds_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwusds_epi32(__A, __B, __C), (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwusds_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwusds_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwusds_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwusds_epi32(__A, __B, __C), (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_dpwusds_epi32( + __mmask8 __U, __m256i __A, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwusds_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwuud_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwuud_epi32(__A, __B, __C), (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwuud_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwuud_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwuud_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwuud_epi32(__A, __B, __C), (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpwuud_epi32(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwuud_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwuuds_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwuuds_epi32(__A, __B, __C), (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwuuds_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_dpwuuds_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwuuds_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwuuds_epi32(__A, __B, __C), (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 _mm256_maskz_dpwuuds_epi32( + __mmask8 __U, __m256i __A, __m256i __B, __m256i __C) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_dpwuuds_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +#undef __DEFAULT_FN_ATTRS256 +#undef __DEFAULT_FN_ATTRS128 + +#endif /* __AVX10_2NIINTRIN_H */ +#endif /* __SSE2__ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2satcvtdsintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2satcvtdsintrin.h new file mode 100755 index 0000000..cc84036 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2satcvtdsintrin.h @@ -0,0 +1,376 @@ +/*===----------- avx10_2satcvtdsintrin.h - AVX512SATCVTDS intrinsics --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2SATCVTDSINTRIN_H +#define __AVX10_2SATCVTDSINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(256))) + +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"), \ + __min_vector_width__(128))) + +#define _mm_cvtts_roundsd_i32(__A, __R) \ + ((int)__builtin_ia32_vcvttsd2sis32((__v2df)(__m128)(__A), (const int)(__R))) + +#define _mm_cvtts_roundsd_si32(__A, __R) \ + ((int)__builtin_ia32_vcvttsd2sis32((__v2df)(__m128d)(__A), (const int)(__R))) + +#define _mm_cvtts_roundsd_u32(__A, __R) \ + ((unsigned int)__builtin_ia32_vcvttsd2usis32((__v2df)(__m128d)(__A), \ + (const int)(__R))) + +#define _mm_cvtts_roundss_i32(__A, __R) \ + ((int)__builtin_ia32_vcvttss2sis32((__v4sf)(__m128)(__A), (const int)(__R))) + +#define _mm_cvtts_roundss_si32(__A, __R) \ + ((int)__builtin_ia32_vcvttss2sis32((__v4sf)(__m128)(__A), (const int)(__R))) + +#define _mm_cvtts_roundss_u32(__A, __R) \ + ((unsigned int)__builtin_ia32_vcvttss2usis32((__v4sf)(__m128)(__A), \ + (const int)(__R))) + +#ifdef __x86_64__ +#define _mm_cvtts_roundss_u64(__A, __R) \ + ((unsigned long long)__builtin_ia32_vcvttss2usis64((__v4sf)(__m128)(__A), \ + (const int)(__R))) + +#define _mm_cvtts_roundsd_u64(__A, __R) \ + ((unsigned long long)__builtin_ia32_vcvttsd2usis64((__v2df)(__m128d)(__A), \ + (const int)(__R))) + +#define _mm_cvtts_roundss_i64(__A, __R) \ + ((long long)__builtin_ia32_vcvttss2sis64((__v4sf)(__m128)(__A), \ + (const int)(__R))) + +#define _mm_cvtts_roundss_si64(__A, __R) \ + ((long long)__builtin_ia32_vcvttss2sis64((__v4sf)(__m128)(__A), \ + (const int)(__R))) + +#define _mm_cvtts_roundsd_si64(__A, __R) \ + ((long long)__builtin_ia32_vcvttsd2sis64((__v2df)(__m128d)(__A), \ + (const int)(__R))) + +#define _mm_cvtts_roundsd_i64(__A, __R) \ + ((long long)__builtin_ia32_vcvttsd2sis64((__v2df)(__m128d)(__A), \ + (const int)(__R))) +#endif /* __x86_64__ */ + +// 128 Bit : Double -> int +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtts_pd_epi32(__m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2dqs128_mask( + (__v2df)__A, (__v4si)(__m128i)_mm_undefined_si128(), (__mmask8)(-1))); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_pd_epi32(__m128i __W, __mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2dqs128_mask((__v2df)__A, (__v4si)__W, + __U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_pd_epi32(__mmask16 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2dqs128_mask( + (__v2df)__A, (__v4si)(__m128i)_mm_setzero_si128(), __U)); +} + +// 256 Bit : Double -> int +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_pd_epi32(__m256d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2dqs256_mask( + (__v4df)__A, (__v4si)_mm_undefined_si128(), (__mmask8)-1)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_pd_epi32(__m128i __W, __mmask8 __U, __m256d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2dqs256_mask((__v4df)__A, (__v4si)__W, + __U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_pd_epi32(__mmask8 __U, __m256d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2dqs256_mask( + (__v4df)__A, (__v4si)_mm_setzero_si128(), __U)); +} + +// 128 Bit : Double -> uint +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtts_pd_epu32(__m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2udqs128_mask( + (__v2df)__A, (__v4si)(__m128i)_mm_undefined_si128(), (__mmask8)(-1))); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_pd_epu32(__m128i __W, __mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2udqs128_mask( + (__v2df)__A, (__v4si)(__m128i)__W, (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_pd_epu32(__mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2udqs128_mask( + (__v2df)__A, (__v4si)(__m128i)_mm_setzero_si128(), __U)); +} + +// 256 Bit : Double -> uint +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_pd_epu32(__m256d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2udqs256_mask( + (__v4df)__A, (__v4si)_mm_undefined_si128(), (__mmask8)-1)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_pd_epu32(__m128i __W, __mmask8 __U, __m256d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2udqs256_mask((__v4df)__A, (__v4si)__W, + __U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_pd_epu32(__mmask8 __U, __m256d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2udqs256_mask( + (__v4df)__A, (__v4si)_mm_setzero_si128(), __U)); +} + +// 128 Bit : Double -> long +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtts_pd_epi64(__m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2qqs128_mask( + (__v2df)__A, (__v2di)_mm_undefined_si128(), (__mmask8)-1)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_pd_epi64(__m128i __W, __mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2qqs128_mask((__v2df)__A, (__v2di)__W, + (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_pd_epi64(__mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2qqs128_mask( + (__v2df)__A, (__v2di)_mm_setzero_si128(), (__mmask8)__U)); +} + +// 256 Bit : Double -> long +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_pd_epi64(__m256d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2qqs256_mask( + (__v4df)__A, (__v4di)_mm256_undefined_si256(), (__mmask8)-1)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_pd_epi64(__m256i __W, __mmask8 __U, __m256d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2qqs256_mask((__v4df)__A, (__v4di)__W, + __U)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_pd_epi64(__mmask8 __U, __m256d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2qqs256_mask( + (__v4df)__A, (__v4di)_mm256_setzero_si256(), __U)); +} + +// 128 Bit : Double -> ulong +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtts_pd_epu64(__m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2uqqs128_mask( + (__v2df)__A, (__v2di)_mm_undefined_si128(), (__mmask8)-1)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_pd_epu64(__m128i __W, __mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2uqqs128_mask((__v2df)__A, (__v2di)__W, + (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_pd_epu64(__mmask8 __U, __m128d __A) { + return ((__m128i)__builtin_ia32_vcvttpd2uqqs128_mask( + (__v2df)__A, (__v2di)_mm_setzero_si128(), (__mmask8)__U)); +} + +// 256 Bit : Double -> ulong + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_pd_epu64(__m256d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2uqqs256_mask( + (__v4df)__A, (__v4di)_mm256_undefined_si256(), (__mmask8)-1)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_pd_epu64(__m256i __W, __mmask8 __U, __m256d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2uqqs256_mask((__v4df)__A, (__v4di)__W, + __U)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_pd_epu64(__mmask8 __U, __m256d __A) { + return ((__m256i)__builtin_ia32_vcvttpd2uqqs256_mask( + (__v4df)__A, (__v4di)_mm256_setzero_si256(), __U)); +} + +// 128 Bit : float -> int +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtts_ps_epi32(__m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2dqs128_mask( + (__v4sf)__A, (__v4si)(__m128i)_mm_undefined_si128(), (__mmask8)(-1))); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_ps_epi32(__m128i __W, __mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2dqs128_mask((__v4sf)__A, (__v4si)__W, + (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_ps_epi32(__mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2dqs128_mask( + (__v4sf)__A, (__v4si)(__m128i)_mm_setzero_si128(), (__mmask8)__U)); +} + +// 256 Bit : float -> int +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_ps_epi32(__m256 __A) { + return ((__m256i)__builtin_ia32_vcvttps2dqs256_mask( + (__v8sf)__A, (__v8si)_mm256_undefined_si256(), (__mmask8)-1)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_ps_epi32(__m256i __W, __mmask8 __U, __m256 __A) { + return ((__m256i)__builtin_ia32_vcvttps2dqs256_mask((__v8sf)__A, (__v8si)__W, + __U)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_ps_epi32(__mmask8 __U, __m256 __A) { + return ((__m256i)__builtin_ia32_vcvttps2dqs256_mask( + (__v8sf)__A, (__v8si)_mm256_setzero_si256(), __U)); +} + +// 128 Bit : float -> uint +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtts_ps_epu32(__m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2udqs128_mask( + (__v4sf)__A, (__v4si)(__m128i)_mm_undefined_si128(), (__mmask8)(-1))); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_ps_epu32(__m128i __W, __mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2udqs128_mask((__v4sf)__A, (__v4si)__W, + (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_ps_epu32(__mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2udqs128_mask( + (__v4sf)__A, (__v4si)_mm_setzero_si128(), (__mmask8)__U)); +} + +// 256 Bit : float -> uint + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_ps_epu32(__m256 __A) { + return ((__m256i)__builtin_ia32_vcvttps2udqs256_mask( + (__v8sf)__A, (__v8si)_mm256_undefined_si256(), (__mmask8)-1)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_ps_epu32(__m256i __W, __mmask8 __U, __m256 __A) { + return ((__m256i)__builtin_ia32_vcvttps2udqs256_mask((__v8sf)__A, (__v8si)__W, + __U)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_ps_epu32(__mmask8 __U, __m256 __A) { + return ((__m256i)__builtin_ia32_vcvttps2udqs256_mask( + (__v8sf)__A, (__v8si)_mm256_setzero_si256(), __U)); +} + +// 128 bit : float -> long +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtts_ps_epi64(__m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2qqs128_mask( + (__v4sf)__A, (__v2di)_mm_undefined_si128(), (__mmask8)-1)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_ps_epi64(__m128i __W, __mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2qqs128_mask( + (__v4sf)__A, (__v2di)(__m128i)__W, (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_ps_epi64(__mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2qqs128_mask( + (__v4sf)__A, (__v2di)_mm_setzero_si128(), (__mmask8)__U)); +} +// 256 bit : float -> long + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_ps_epi64(__m128 __A) { + return ((__m256i)__builtin_ia32_vcvttps2qqs256_mask( + (__v4sf)__A, (__v4di)_mm256_undefined_si256(), (__mmask8)-1)); +} +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_ps_epi64(__m256i __W, __mmask8 __U, __m128 __A) { + return ((__m256i)__builtin_ia32_vcvttps2qqs256_mask((__v4sf)__A, (__v4di)__W, + __U)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_ps_epi64(__mmask8 __U, __m128 __A) { + return ((__m256i)__builtin_ia32_vcvttps2qqs256_mask( + (__v4sf)__A, (__v4di)_mm256_setzero_si256(), __U)); +} + +// 128 bit : float -> ulong +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtts_ps_epu64(__m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2uqqs128_mask( + (__v4sf)__A, (__v2di)_mm_undefined_si128(), (__mmask8)-1)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtts_ps_epu64(__m128i __W, __mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2uqqs128_mask( + (__v4sf)__A, (__v2di)(__m128i)__W, (__mmask8)__U)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtts_ps_epu64(__mmask8 __U, __m128 __A) { + return ((__m128i)__builtin_ia32_vcvttps2uqqs128_mask( + (__v4sf)__A, (__v2di)_mm_setzero_si128(), (__mmask8)__U)); +} +// 256 bit : float -> ulong + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtts_ps_epu64(__m128 __A) { + return ((__m256i)__builtin_ia32_vcvttps2uqqs256_mask( + (__v4sf)__A, (__v4di)_mm256_undefined_si256(), (__mmask8)-1)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtts_ps_epu64(__m256i __W, __mmask8 __U, __m128 __A) { + return ((__m256i)__builtin_ia32_vcvttps2uqqs256_mask((__v4sf)__A, (__v4di)__W, + __U)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtts_ps_epu64(__mmask8 __U, __m128 __A) { + return ((__m256i)__builtin_ia32_vcvttps2uqqs256_mask( + (__v4sf)__A, (__v4di)_mm256_setzero_si256(), __U)); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 +#endif // __AVX10_2SATCVTDSINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2satcvtintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2satcvtintrin.h new file mode 100755 index 0000000..2f1fad9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx10_2satcvtintrin.h @@ -0,0 +1,312 @@ +/*===----------- avx10_2satcvtintrin.h - AVX10_2SATCVT intrinsics ----------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVX10_2SATCVTINTRIN_H +#define __AVX10_2SATCVTINTRIN_H + +#define _mm_ipcvts_bf16_epi8(A) \ + ((__m128i)__builtin_ia32_vcvtbf162ibs128((__v8bf)(__m128bh)(A))) + +#define _mm_mask_ipcvts_bf16_epi8(W, U, A) \ + ((__m128i)__builtin_ia32_selectw_128( \ + (__mmask8)(U), (__v8hi)_mm_ipcvts_bf16_epi8(A), (__v8hi)(__m128i)(W))) + +#define _mm_maskz_ipcvts_bf16_epi8(U, A) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_ipcvts_bf16_epi8(A), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_ipcvts_bf16_epi8(A) \ + ((__m256i)__builtin_ia32_vcvtbf162ibs256((__v16bf)(__m256bh)(A))) + +#define _mm256_mask_ipcvts_bf16_epi8(W, U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvts_bf16_epi8(A), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_ipcvts_bf16_epi8(U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvts_bf16_epi8(A), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_ipcvts_bf16_epu8(A) \ + ((__m128i)__builtin_ia32_vcvtbf162iubs128((__v8bf)(__m128bh)(A))) + +#define _mm_mask_ipcvts_bf16_epu8(W, U, A) \ + ((__m128i)__builtin_ia32_selectw_128( \ + (__mmask8)(U), (__v8hi)_mm_ipcvts_bf16_epu8(A), (__v8hi)(__m128i)(W))) + +#define _mm_maskz_ipcvts_bf16_epu8(U, A) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_ipcvts_bf16_epu8(A), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_ipcvts_bf16_epu8(A) \ + ((__m256i)__builtin_ia32_vcvtbf162iubs256((__v16bf)(__m256bh)(A))) + +#define _mm256_mask_ipcvts_bf16_epu8(W, U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvts_bf16_epu8(A), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_ipcvts_bf16_epu8(U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvts_bf16_epu8(A), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_ipcvts_ph_epi8(A) \ + ((__m128i)__builtin_ia32_vcvtph2ibs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvts_ph_epi8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvtph2ibs128_mask((__v8hf)(__m128h)(A), \ + (__v8hu)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvts_ph_epi8(U, A) \ + ((__m128i)__builtin_ia32_vcvtph2ibs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvts_ph_epi8(A) \ + ((__m256i)__builtin_ia32_vcvtph2ibs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)_mm256_setzero_si256(), (__mmask16)-1)) + +#define _mm256_mask_ipcvts_ph_epi8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvtph2ibs256_mask((__v16hf)(__m256h)(A), \ + (__v16hu)(W), (__mmask16)(U))) + +#define _mm256_maskz_ipcvts_ph_epi8(U, A) \ + ((__m256i)__builtin_ia32_vcvtph2ibs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)(_mm256_setzero_si256()), \ + (__mmask16)(U))) + +#define _mm_ipcvts_ph_epu8(A) \ + ((__m128i)__builtin_ia32_vcvtph2iubs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvts_ph_epu8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvtph2iubs128_mask((__v8hf)(__m128h)(A), \ + (__v8hu)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvts_ph_epu8(U, A) \ + ((__m128i)__builtin_ia32_vcvtph2iubs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvts_ph_epu8(A) \ + ((__m256i)__builtin_ia32_vcvtph2iubs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)_mm256_setzero_si256(), (__mmask16)-1)) + +#define _mm256_mask_ipcvts_ph_epu8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvtph2iubs256_mask((__v16hf)(__m256h)(A), \ + (__v16hu)(W), (__mmask16)(U))) + +#define _mm256_maskz_ipcvts_ph_epu8(U, A) \ + ((__m256i)__builtin_ia32_vcvtph2iubs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)(_mm256_setzero_si256()), \ + (__mmask16)(U))) + +#define _mm_ipcvts_ps_epi8(A) \ + ((__m128i)__builtin_ia32_vcvtps2ibs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvts_ps_epi8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvtps2ibs128_mask((__v4sf)(__m128)(A), \ + (__v4su)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvts_ps_epi8(U, A) \ + ((__m128i)__builtin_ia32_vcvtps2ibs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvts_ps_epi8(A) \ + ((__m256i)__builtin_ia32_vcvtps2ibs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)_mm256_setzero_si256(), (__mmask8)-1)) + +#define _mm256_mask_ipcvts_ps_epi8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvtps2ibs256_mask((__v8sf)(__m256)(A), \ + (__v8su)(W), (__mmask8)(U))) + +#define _mm256_maskz_ipcvts_ps_epi8(U, A) \ + ((__m256i)__builtin_ia32_vcvtps2ibs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)(_mm256_setzero_si256()), (__mmask8)(U))) + +#define _mm_ipcvts_ps_epu8(A) \ + ((__m128i)__builtin_ia32_vcvtps2iubs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvts_ps_epu8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvtps2iubs128_mask((__v4sf)(__m128)(A), \ + (__v4su)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvts_ps_epu8(U, A) \ + ((__m128i)__builtin_ia32_vcvtps2iubs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvts_ps_epu8(A) \ + ((__m256i)__builtin_ia32_vcvtps2iubs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)_mm256_setzero_si256(), (__mmask8)-1)) + +#define _mm256_mask_ipcvts_ps_epu8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvtps2iubs256_mask((__v8sf)(__m256)(A), \ + (__v8su)(W), (__mmask8)(U))) + +#define _mm256_maskz_ipcvts_ps_epu8(U, A) \ + ((__m256i)__builtin_ia32_vcvtps2iubs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)(_mm256_setzero_si256()), (__mmask8)(U))) + +#define _mm_ipcvtts_bf16_epi8(A) \ + ((__m128i)__builtin_ia32_vcvttbf162ibs128((__v8bf)(__m128bh)(A))) + +#define _mm_mask_ipcvtts_bf16_epi8(W, U, A) \ + ((__m128i)__builtin_ia32_selectw_128( \ + (__mmask8)(U), (__v8hi)_mm_ipcvtts_bf16_epi8(A), (__v8hi)(__m128i)(W))) + +#define _mm_maskz_ipcvtts_bf16_epi8(U, A) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_ipcvtts_bf16_epi8(A), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_ipcvtts_bf16_epi8(A) \ + ((__m256i)__builtin_ia32_vcvttbf162ibs256((__v16bf)(__m256bh)(A))) + +#define _mm256_mask_ipcvtts_bf16_epi8(W, U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvtts_bf16_epi8(A), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_ipcvtts_bf16_epi8(U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvtts_bf16_epi8(A), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_ipcvtts_bf16_epu8(A) \ + ((__m128i)__builtin_ia32_vcvttbf162iubs128((__v8bf)(__m128bh)(A))) + +#define _mm_mask_ipcvtts_bf16_epu8(W, U, A) \ + ((__m128i)__builtin_ia32_selectw_128( \ + (__mmask8)(U), (__v8hi)_mm_ipcvtts_bf16_epu8(A), (__v8hi)(__m128i)(W))) + +#define _mm_maskz_ipcvtts_bf16_epu8(U, A) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_ipcvtts_bf16_epu8(A), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_ipcvtts_bf16_epu8(A) \ + ((__m256i)__builtin_ia32_vcvttbf162iubs256((__v16bf)(__m256bh)(A))) + +#define _mm256_mask_ipcvtts_bf16_epu8(W, U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvtts_bf16_epu8(A), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_ipcvtts_bf16_epu8(U, A) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_ipcvtts_bf16_epu8(A), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_ipcvtts_ph_epi8(A) \ + ((__m128i)__builtin_ia32_vcvttph2ibs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvtts_ph_epi8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvttph2ibs128_mask((__v8hf)(__m128h)(A), \ + (__v8hu)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvtts_ph_epi8(U, A) \ + ((__m128i)__builtin_ia32_vcvttph2ibs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvtts_ph_epi8(A) \ + ((__m256i)__builtin_ia32_vcvttph2ibs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)_mm256_setzero_si256(), (__mmask16)-1)) + +#define _mm256_mask_ipcvtts_ph_epi8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvttph2ibs256_mask((__v16hf)(__m256h)(A), \ + (__v16hu)(W), (__mmask16)(U))) + +#define _mm256_maskz_ipcvtts_ph_epi8(U, A) \ + ((__m256i)__builtin_ia32_vcvttph2ibs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)(_mm256_setzero_si256()), \ + (__mmask16)(U))) + +#define _mm_ipcvtts_ph_epu8(A) \ + ((__m128i)__builtin_ia32_vcvttph2iubs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvtts_ph_epu8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvttph2iubs128_mask((__v8hf)(__m128h)(A), \ + (__v8hu)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvtts_ph_epu8(U, A) \ + ((__m128i)__builtin_ia32_vcvttph2iubs128_mask( \ + (__v8hf)(__m128h)(A), (__v8hu)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvtts_ph_epu8(A) \ + ((__m256i)__builtin_ia32_vcvttph2iubs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)_mm256_setzero_si256(), (__mmask16)-1)) + +#define _mm256_mask_ipcvtts_ph_epu8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvttph2iubs256_mask((__v16hf)(__m256h)(A), \ + (__v16hu)(W), (__mmask16)(U))) + +#define _mm256_maskz_ipcvtts_ph_epu8(U, A) \ + ((__m256i)__builtin_ia32_vcvttph2iubs256_mask( \ + (__v16hf)(__m256h)(A), (__v16hu)(_mm256_setzero_si256()), \ + (__mmask16)(U))) + +#define _mm_ipcvtts_ps_epi8(A) \ + ((__m128i)__builtin_ia32_vcvttps2ibs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvtts_ps_epi8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvttps2ibs128_mask((__v4sf)(__m128)(A), \ + (__v4su)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvtts_ps_epi8(U, A) \ + ((__m128i)__builtin_ia32_vcvttps2ibs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvtts_ps_epi8(A) \ + ((__m256i)__builtin_ia32_vcvttps2ibs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)_mm256_setzero_si256(), (__mmask8)-1)) + +#define _mm256_mask_ipcvtts_ps_epi8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvttps2ibs256_mask((__v8sf)(__m256)(A), \ + (__v8su)(W), (__mmask8)(U))) + +#define _mm256_maskz_ipcvtts_ps_epi8(U, A) \ + ((__m256i)__builtin_ia32_vcvttps2ibs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)(_mm256_setzero_si256()), (__mmask8)(U))) + +#define _mm_ipcvtts_ps_epu8(A) \ + ((__m128i)__builtin_ia32_vcvttps2iubs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)_mm_setzero_si128(), (__mmask8)-1)) + +#define _mm_mask_ipcvtts_ps_epu8(W, U, A) \ + ((__m128i)__builtin_ia32_vcvttps2iubs128_mask((__v4sf)(__m128)(A), \ + (__v4su)(W), (__mmask8)(U))) + +#define _mm_maskz_ipcvtts_ps_epu8(U, A) \ + ((__m128i)__builtin_ia32_vcvttps2iubs128_mask( \ + (__v4sf)(__m128)(A), (__v4su)(_mm_setzero_si128()), (__mmask8)(U))) + +#define _mm256_ipcvtts_ps_epu8(A) \ + ((__m256i)__builtin_ia32_vcvttps2iubs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)_mm256_setzero_si256(), (__mmask8)-1)) + +#define _mm256_mask_ipcvtts_ps_epu8(W, U, A) \ + ((__m256i)__builtin_ia32_vcvttps2iubs256_mask((__v8sf)(__m256)(A), \ + (__v8su)(W), (__mmask8)(U))) + +#define _mm256_maskz_ipcvtts_ps_epu8(U, A) \ + ((__m256i)__builtin_ia32_vcvttps2iubs256_mask( \ + (__v8sf)(__m256)(A), (__v8su)(_mm256_setzero_si256()), (__mmask8)(U))) +#endif // __AVX10_2SATCVTINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx2intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx2intrin.h new file mode 100755 index 0000000..dc9fc07 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx2intrin.h @@ -0,0 +1,5293 @@ +/*===---- avx2intrin.h - AVX2 intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX2INTRIN_H +#define __AVX2INTRIN_H + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx2,no-evex512"), __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx2,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx2"), \ + __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx2"), \ + __min_vector_width__(128))) +#endif + +/* SSE4 Multiple Packed Sums of Absolute Difference. */ +/// Computes sixteen sum of absolute difference (SAD) operations on sets of +/// four unsigned 8-bit integers from the 256-bit integer vectors \a X and +/// \a Y. +/// +/// Eight SAD results are computed using the lower half of the input +/// vectors, and another eight using the upper half. These 16-bit values +/// are returned in the lower and upper halves of the 256-bit result, +/// respectively. +/// +/// A single SAD operation selects four bytes from \a X and four bytes from +/// \a Y as input. It computes the differences between each \a X byte and +/// the corresponding \a Y byte, takes the absolute value of each +/// difference, and sums these four values to form one 16-bit result. The +/// intrinsic computes 16 of these results with different sets of input +/// bytes. +/// +/// For each set of eight results, the SAD operations use the same four +/// bytes from \a Y; the starting bit position for these four bytes is +/// specified by \a M[1:0] times 32. The eight operations use successive +/// sets of four bytes from \a X; the starting bit position for the first +/// set of four bytes is specified by \a M[2] times 32. These bit positions +/// are all relative to the 128-bit lane for each set of eight operations. +/// +/// \code{.operation} +/// r := 0 +/// FOR i := 0 TO 1 +/// j := i*3 +/// Ybase := M[j+1:j]*32 + i*128 +/// Xbase := M[j+2]*32 + i*128 +/// FOR k := 0 TO 3 +/// temp0 := ABS(X[Xbase+7:Xbase] - Y[Ybase+7:Ybase]) +/// temp1 := ABS(X[Xbase+15:Xbase+8] - Y[Ybase+15:Ybase+8]) +/// temp2 := ABS(X[Xbase+23:Xbase+16] - Y[Ybase+23:Ybase+16]) +/// temp3 := ABS(X[Xbase+31:Xbase+24] - Y[Ybase+31:Ybase+24]) +/// result[r+15:r] := temp0 + temp1 + temp2 + temp3 +/// Xbase := Xbase + 8 +/// r := r + 16 +/// ENDFOR +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_mpsadbw_epu8(__m256i X, __m256i Y, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VMPSADBW instruction. +/// +/// \param X +/// A 256-bit integer vector containing one of the inputs. +/// \param Y +/// A 256-bit integer vector containing one of the inputs. +/// \param M +/// An unsigned immediate value specifying the starting positions of the +/// bytes to operate on. +/// \returns A 256-bit vector of [16 x i16] containing the result. +#define _mm256_mpsadbw_epu8(X, Y, M) \ + ((__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \ + (__v32qi)(__m256i)(Y), (int)(M))) + +/// Computes the absolute value of each signed byte in the 256-bit integer +/// vector \a __a and returns each value in the corresponding byte of +/// the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPABSB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_abs_epi8(__m256i __a) +{ + return (__m256i)__builtin_elementwise_abs((__v32qs)__a); +} + +/// Computes the absolute value of each signed 16-bit element in the 256-bit +/// vector of [16 x i16] in \a __a and returns each value in the +/// corresponding element of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPABSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_abs_epi16(__m256i __a) +{ + return (__m256i)__builtin_elementwise_abs((__v16hi)__a); +} + +/// Computes the absolute value of each signed 32-bit element in the 256-bit +/// vector of [8 x i32] in \a __a and returns each value in the +/// corresponding element of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPABSD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_abs_epi32(__m256i __a) +{ + return (__m256i)__builtin_elementwise_abs((__v8si)__a); +} + +/// Converts the elements of two 256-bit vectors of [16 x i16] to 8-bit +/// integers using signed saturation, and returns the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*16 +/// k := i*8 +/// result[7+k:k] := SATURATE8(__a[15+j:j]) +/// result[71+k:64+k] := SATURATE8(__b[15+j:j]) +/// result[135+k:128+k] := SATURATE8(__a[143+j:128+j]) +/// result[199+k:192+k] := SATURATE8(__b[143+j:128+j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPACKSSWB instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] used to generate result[63:0] and +/// result[191:128]. +/// \param __b +/// A 256-bit vector of [16 x i16] used to generate result[127:64] and +/// result[255:192]. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_packs_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_packsswb256((__v16hi)__a, (__v16hi)__b); +} + +/// Converts the elements of two 256-bit vectors of [8 x i32] to 16-bit +/// integers using signed saturation, and returns the resulting 256-bit +/// vector of [16 x i16]. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*32 +/// k := i*16 +/// result[15+k:k] := SATURATE16(__a[31+j:j]) +/// result[79+k:64+k] := SATURATE16(__b[31+j:j]) +/// result[143+k:128+k] := SATURATE16(__a[159+j:128+j]) +/// result[207+k:192+k] := SATURATE16(__b[159+j:128+j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPACKSSDW instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] used to generate result[63:0] and +/// result[191:128]. +/// \param __b +/// A 256-bit vector of [8 x i32] used to generate result[127:64] and +/// result[255:192]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_packs_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_packssdw256((__v8si)__a, (__v8si)__b); +} + +/// Converts elements from two 256-bit vectors of [16 x i16] to 8-bit integers +/// using unsigned saturation, and returns the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*16 +/// k := i*8 +/// result[7+k:k] := SATURATE8U(__a[15+j:j]) +/// result[71+k:64+k] := SATURATE8U(__b[15+j:j]) +/// result[135+k:128+k] := SATURATE8U(__a[143+j:128+j]) +/// result[199+k:192+k] := SATURATE8U(__b[143+j:128+j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPACKUSWB instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] used to generate result[63:0] and +/// result[191:128]. +/// \param __b +/// A 256-bit vector of [16 x i16] used to generate result[127:64] and +/// result[255:192]. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_packus_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_packuswb256((__v16hi)__a, (__v16hi)__b); +} + +/// Converts elements from two 256-bit vectors of [8 x i32] to 16-bit integers +/// using unsigned saturation, and returns the resulting 256-bit vector of +/// [16 x i16]. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*32 +/// k := i*16 +/// result[15+k:k] := SATURATE16U(__V1[31+j:j]) +/// result[79+k:64+k] := SATURATE16U(__V2[31+j:j]) +/// result[143+k:128+k] := SATURATE16U(__V1[159+j:128+j]) +/// result[207+k:192+k] := SATURATE16U(__V2[159+j:128+j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPACKUSDW instruction. +/// +/// \param __V1 +/// A 256-bit vector of [8 x i32] used to generate result[63:0] and +/// result[191:128]. +/// \param __V2 +/// A 256-bit vector of [8 x i32] used to generate result[127:64] and +/// result[255:192]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_packus_epi32(__m256i __V1, __m256i __V2) +{ + return (__m256i) __builtin_ia32_packusdw256((__v8si)__V1, (__v8si)__V2); +} + +/// Adds 8-bit integers from corresponding bytes of two 256-bit integer +/// vectors and returns the lower 8 bits of each sum in the corresponding +/// byte of the 256-bit integer vector result (overflow is ignored). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing one of the source operands. +/// \param __b +/// A 256-bit integer vector containing one of the source operands. +/// \returns A 256-bit integer vector containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_add_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)((__v32qu)__a + (__v32qu)__b); +} + +/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of +/// [16 x i16] and returns the lower 16 bits of each sum in the +/// corresponding element of the [16 x i16] result (overflow is ignored). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_add_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)((__v16hu)__a + (__v16hu)__b); +} + +/// Adds 32-bit integers from corresponding elements of two 256-bit vectors of +/// [8 x i32] and returns the lower 32 bits of each sum in the corresponding +/// element of the [8 x i32] result (overflow is ignored). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \returns A 256-bit vector of [8 x i32] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_add_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8su)__a + (__v8su)__b); +} + +/// Adds 64-bit integers from corresponding elements of two 256-bit vectors of +/// [4 x i64] and returns the lower 64 bits of each sum in the corresponding +/// element of the [4 x i64] result (overflow is ignored). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [4 x i64] containing one of the source operands. +/// \returns A 256-bit vector of [4 x i64] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_add_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a + (__v4du)__b); +} + +/// Adds 8-bit integers from corresponding bytes of two 256-bit integer +/// vectors using signed saturation, and returns each sum in the +/// corresponding byte of the 256-bit integer vector result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDSB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing one of the source operands. +/// \param __b +/// A 256-bit integer vector containing one of the source operands. +/// \returns A 256-bit integer vector containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_adds_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_add_sat((__v32qs)__a, (__v32qs)__b); +} + +/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of +/// [16 x i16] using signed saturation, and returns the [16 x i16] result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_adds_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_add_sat((__v16hi)__a, (__v16hi)__b); +} + +/// Adds 8-bit integers from corresponding bytes of two 256-bit integer +/// vectors using unsigned saturation, and returns each sum in the +/// corresponding byte of the 256-bit integer vector result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDUSB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing one of the source operands. +/// \param __b +/// A 256-bit integer vector containing one of the source operands. +/// \returns A 256-bit integer vector containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_adds_epu8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_add_sat((__v32qu)__a, (__v32qu)__b); +} + +/// Adds 16-bit integers from corresponding elements of two 256-bit vectors of +/// [16 x i16] using unsigned saturation, and returns the [16 x i16] result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPADDUSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_adds_epu16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_add_sat((__v16hu)__a, (__v16hu)__b); +} + +/// Uses the lower half of the 256-bit vector \a a as the upper half of a +/// temporary 256-bit value, and the lower half of the 256-bit vector \a b +/// as the lower half of the temporary value. Right-shifts the temporary +/// value by \a n bytes, and uses the lower 16 bytes of the shifted value +/// as the lower 16 bytes of the result. Uses the upper halves of \a a and +/// \a b to make another temporary value, right shifts by \a n, and uses +/// the lower 16 bytes of the shifted value as the upper 16 bytes of the +/// result. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_alignr_epi8(__m256i a, __m256i b, const int n); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPALIGNR instruction. +/// +/// \param a +/// A 256-bit integer vector containing source values. +/// \param b +/// A 256-bit integer vector containing source values. +/// \param n +/// An immediate value specifying the number of bytes to shift. +/// \returns A 256-bit integer vector containing the result. +#define _mm256_alignr_epi8(a, b, n) \ + ((__m256i)__builtin_ia32_palignr256((__v32qi)(__m256i)(a), \ + (__v32qi)(__m256i)(b), (n))) + +/// Computes the bitwise AND of the 256-bit integer vectors in \a __a and +/// \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPAND instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_and_si256(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a & (__v4du)__b); +} + +/// Computes the bitwise AND of the 256-bit integer vector in \a __b with +/// the bitwise NOT of the 256-bit integer vector in \a __a. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPANDN instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_andnot_si256(__m256i __a, __m256i __b) +{ + return (__m256i)(~(__v4du)__a & (__v4du)__b); +} + +/// Computes the averages of the corresponding unsigned bytes in the two +/// 256-bit integer vectors in \a __a and \a __b and returns each +/// average in the corresponding byte of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[j+7:j] := (__a[j+7:j] + __b[j+7:j] + 1) >> 1 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPAVGB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_avg_epu8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pavgb256((__v32qi)__a, (__v32qi)__b); +} + +/// Computes the averages of the corresponding unsigned 16-bit integers in +/// the two 256-bit vectors of [16 x i16] in \a __a and \a __b and returns +/// each average in the corresponding element of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// result[j+15:j] := (__a[j+15:j] + __b[j+15:j] + 1) >> 1 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPAVGW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \param __b +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_avg_epu16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pavgw256((__v16hi)__a, (__v16hi)__b); +} + +/// Merges 8-bit integer values from either of the two 256-bit vectors +/// \a __V1 or \a __V2, as specified by the 256-bit mask \a __M and returns +/// the resulting 256-bit integer vector. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// IF __M[7+i] == 0 +/// result[7+j:j] := __V1[7+j:j] +/// ELSE +/// result[7+j:j] := __V2[7+j:j] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBLENDVB instruction. +/// +/// \param __V1 +/// A 256-bit integer vector containing source values. +/// \param __V2 +/// A 256-bit integer vector containing source values. +/// \param __M +/// A 256-bit integer vector, with bit [7] of each byte specifying the +/// source for each corresponding byte of the result. When the mask bit +/// is 0, the byte is copied from \a __V1; otherwise, it is copied from +/// \a __V2. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_blendv_epi8(__m256i __V1, __m256i __V2, __m256i __M) +{ + return (__m256i)__builtin_ia32_pblendvb256((__v32qi)__V1, (__v32qi)__V2, + (__v32qi)__M); +} + +/// Merges 16-bit integer values from either of the two 256-bit vectors +/// \a V1 or \a V2, as specified by the immediate integer operand \a M, +/// and returns the resulting 256-bit vector of [16 x i16]. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*16 +/// IF M[i] == 0 +/// result[7+j:j] := V1[7+j:j] +/// result[135+j:128+j] := V1[135+j:128+j] +/// ELSE +/// result[7+j:j] := V2[7+j:j] +/// result[135+j:128+j] := V2[135+j:128+j] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_blend_epi16(__m256i V1, __m256i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPBLENDW instruction. +/// +/// \param V1 +/// A 256-bit vector of [16 x i16] containing source values. +/// \param V2 +/// A 256-bit vector of [16 x i16] containing source values. +/// \param M +/// An immediate 8-bit integer operand, with bits [7:0] specifying the +/// source for each element of the result. The position of the mask bit +/// corresponds to the index of a copied value. When a mask bit is 0, the +/// element is copied from \a V1; otherwise, it is copied from \a V2. +/// \a M[0] determines the source for elements 0 and 8, \a M[1] for +/// elements 1 and 9, and so forth. +/// \returns A 256-bit vector of [16 x i16] containing the result. +#define _mm256_blend_epi16(V1, V2, M) \ + ((__m256i)__builtin_ia32_pblendw256((__v16hi)(__m256i)(V1), \ + (__v16hi)(__m256i)(V2), (int)(M))) + +/// Compares corresponding bytes in the 256-bit integer vectors in \a __a and +/// \a __b for equality and returns the outcomes in the corresponding +/// bytes of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[j+7:j] := (__a[j+7:j] == __b[j+7:j]) ? 0xFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPEQB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing one of the inputs. +/// \param __b +/// A 256-bit integer vector containing one of the inputs. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpeq_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)((__v32qi)__a == (__v32qi)__b); +} + +/// Compares corresponding elements in the 256-bit vectors of [16 x i16] in +/// \a __a and \a __b for equality and returns the outcomes in the +/// corresponding elements of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// result[j+15:j] := (__a[j+15:j] == __b[j+15:j]) ? 0xFFFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPEQW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the inputs. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the inputs. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpeq_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)((__v16hi)__a == (__v16hi)__b); +} + +/// Compares corresponding elements in the 256-bit vectors of [8 x i32] in +/// \a __a and \a __b for equality and returns the outcomes in the +/// corresponding elements of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// result[j+31:j] := (__a[j+31:j] == __b[j+31:j]) ? 0xFFFFFFFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPEQD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the inputs. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the inputs. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpeq_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8si)__a == (__v8si)__b); +} + +/// Compares corresponding elements in the 256-bit vectors of [4 x i64] in +/// \a __a and \a __b for equality and returns the outcomes in the +/// corresponding elements of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// result[j+63:j] := (__a[j+63:j] == __b[j+63:j]) ? 0xFFFFFFFFFFFFFFFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPEQQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] containing one of the inputs. +/// \param __b +/// A 256-bit vector of [4 x i64] containing one of the inputs. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpeq_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4di)__a == (__v4di)__b); +} + +/// Compares corresponding signed bytes in the 256-bit integer vectors in +/// \a __a and \a __b for greater-than and returns the outcomes in the +/// corresponding bytes of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[j+7:j] := (__a[j+7:j] > __b[j+7:j]) ? 0xFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPGTB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing one of the inputs. +/// \param __b +/// A 256-bit integer vector containing one of the inputs. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpgt_epi8(__m256i __a, __m256i __b) +{ + /* This function always performs a signed comparison, but __v32qi is a char + which may be signed or unsigned, so use __v32qs. */ + return (__m256i)((__v32qs)__a > (__v32qs)__b); +} + +/// Compares corresponding signed elements in the 256-bit vectors of +/// [16 x i16] in \a __a and \a __b for greater-than and returns the +/// outcomes in the corresponding elements of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// result[j+15:j] := (__a[j+15:j] > __b[j+15:j]) ? 0xFFFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPGTW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the inputs. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the inputs. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpgt_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)((__v16hi)__a > (__v16hi)__b); +} + +/// Compares corresponding signed elements in the 256-bit vectors of +/// [8 x i32] in \a __a and \a __b for greater-than and returns the +/// outcomes in the corresponding elements of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// result[j+31:j] := (__a[j+31:j] > __b[j+31:j]) ? 0xFFFFFFFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPGTD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the inputs. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the inputs. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpgt_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8si)__a > (__v8si)__b); +} + +/// Compares corresponding signed elements in the 256-bit vectors of +/// [4 x i64] in \a __a and \a __b for greater-than and returns the +/// outcomes in the corresponding elements of the 256-bit result. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// result[j+63:j] := (__a[j+63:j] > __b[j+63:j]) ? 0xFFFFFFFFFFFFFFFF : 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPCMPGTQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] containing one of the inputs. +/// \param __b +/// A 256-bit vector of [4 x i64] containing one of the inputs. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmpgt_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4di)__a > (__v4di)__b); +} + +/// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit +/// vectors of [16 x i16] and returns the lower 16 bits of each sum in an +/// element of the [16 x i16] result (overflow is ignored). Sums from +/// \a __a are returned in the lower 64 bits of each 128-bit half of the +/// result; sums from \a __b are returned in the upper 64 bits of each +/// 128-bit half of the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// result[j+15:j] := __a[j+15:j] + __a[j+31:j+16] +/// result[j+31:j+16] := __a[j+47:j+32] + __a[j+63:j+48] +/// result[j+47:j+32] := __a[j+79:j+64] + __a[j+95:j+80] +/// result[j+63:j+48] := __a[j+111:j+96] + __a[j+127:j+112] +/// result[j+79:j+64] := __b[j+15:j] + __b[j+31:j+16] +/// result[j+95:j+80] := __b[j+47:j+32] + __b[j+63:j+48] +/// result[j+111:j+96] := __b[j+79:j+64] + __b[j+95:j+80] +/// result[j+127:j+112] := __b[j+111:j+96] + __b[j+127:j+112] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHADDW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_hadd_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b); +} + +/// Horizontally adds the adjacent pairs of 32-bit integers from two 256-bit +/// vectors of [8 x i32] and returns the lower 32 bits of each sum in an +/// element of the [8 x i32] result (overflow is ignored). Sums from \a __a +/// are returned in the lower 64 bits of each 128-bit half of the result; +/// sums from \a __b are returned in the upper 64 bits of each 128-bit half +/// of the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// result[j+31:j] := __a[j+31:j] + __a[j+63:j+32] +/// result[j+63:j+32] := __a[j+95:j+64] + __a[j+127:j+96] +/// result[j+95:j+64] := __b[j+31:j] + __b[j+63:j+32] +/// result[j+127:j+96] := __b[j+95:j+64] + __b[j+127:j+96] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHADDD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \returns A 256-bit vector of [8 x i32] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_hadd_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b); +} + +/// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit +/// vectors of [16 x i16] using signed saturation and returns each sum in +/// an element of the [16 x i16] result. Sums from \a __a are returned in +/// the lower 64 bits of each 128-bit half of the result; sums from \a __b +/// are returned in the upper 64 bits of each 128-bit half of the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// result[j+15:j] := SATURATE16(__a[j+15:j] + __a[j+31:j+16]) +/// result[j+31:j+16] := SATURATE16(__a[j+47:j+32] + __a[j+63:j+48]) +/// result[j+47:j+32] := SATURATE16(__a[j+79:j+64] + __a[j+95:j+80]) +/// result[j+63:j+48] := SATURATE16(__a[j+111:j+96] + __a[j+127:j+112]) +/// result[j+79:j+64] := SATURATE16(__b[j+15:j] + __b[j+31:j+16]) +/// result[j+95:j+80] := SATURATE16(__b[j+47:j+32] + __b[j+63:j+48]) +/// result[j+111:j+96] := SATURATE16(__b[j+79:j+64] + __b[j+95:j+80]) +/// result[j+127:j+112] := SATURATE16(__b[j+111:j+96] + __b[j+127:j+112]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHADDSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the sums. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_hadds_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b); +} + +/// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit +/// vectors of [16 x i16] and returns the lower 16 bits of each difference +/// in an element of the [16 x i16] result (overflow is ignored). +/// Differences from \a __a are returned in the lower 64 bits of each +/// 128-bit half of the result; differences from \a __b are returned in the +/// upper 64 bits of each 128-bit half of the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// result[j+15:j] := __a[j+15:j] - __a[j+31:j+16] +/// result[j+31:j+16] := __a[j+47:j+32] - __a[j+63:j+48] +/// result[j+47:j+32] := __a[j+79:j+64] - __a[j+95:j+80] +/// result[j+63:j+48] := __a[j+111:j+96] - __a[j+127:j+112] +/// result[j+79:j+64] := __b[j+15:j] - __b[j+31:j+16] +/// result[j+95:j+80] := __b[j+47:j+32] - __b[j+63:j+48] +/// result[j+111:j+96] := __b[j+79:j+64] - __b[j+95:j+80] +/// result[j+127:j+112] := __b[j+111:j+96] - __b[j+127:j+112] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHSUBW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_hsub_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b); +} + +/// Horizontally subtracts adjacent pairs of 32-bit integers from two 256-bit +/// vectors of [8 x i32] and returns the lower 32 bits of each difference in +/// an element of the [8 x i32] result (overflow is ignored). Differences +/// from \a __a are returned in the lower 64 bits of each 128-bit half of +/// the result; differences from \a __b are returned in the upper 64 bits +/// of each 128-bit half of the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// result[j+31:j] := __a[j+31:j] - __a[j+63:j+32] +/// result[j+63:j+32] := __a[j+95:j+64] - __a[j+127:j+96] +/// result[j+95:j+64] := __b[j+31:j] - __b[j+63:j+32] +/// result[j+127:j+96] := __b[j+95:j+64] - __b[j+127:j+96] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHSUBD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \returns A 256-bit vector of [8 x i32] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_hsub_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b); +} + +/// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit +/// vectors of [16 x i16] using signed saturation and returns each sum in +/// an element of the [16 x i16] result. Differences from \a __a are +/// returned in the lower 64 bits of each 128-bit half of the result; +/// differences from \a __b are returned in the upper 64 bits of each +/// 128-bit half of the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// result[j+15:j] := SATURATE16(__a[j+15:j] - __a[j+31:j+16]) +/// result[j+31:j+16] := SATURATE16(__a[j+47:j+32] - __a[j+63:j+48]) +/// result[j+47:j+32] := SATURATE16(__a[j+79:j+64] - __a[j+95:j+80]) +/// result[j+63:j+48] := SATURATE16(__a[j+111:j+96] - __a[j+127:j+112]) +/// result[j+79:j+64] := SATURATE16(__b[j+15:j] - __b[j+31:j+16]) +/// result[j+95:j+80] := SATURATE16(__b[j+47:j+32] - __b[j+63:j+48]) +/// result[j+111:j+96] := SATURATE16(__b[j+79:j+64] - __b[j+95:j+80]) +/// result[j+127:j+112] := SATURATE16(__b[j+111:j+96] - __b[j+127:j+112]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHSUBSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_hsubs_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_phsubsw256((__v16hi)__a, (__v16hi)__b); +} + +/// Multiplies each unsigned byte from the 256-bit integer vector in \a __a +/// with the corresponding signed byte from the 256-bit integer vector in +/// \a __b, forming signed 16-bit intermediate products. Adds adjacent +/// pairs of those products using signed saturation to form 16-bit sums +/// returned as elements of the [16 x i16] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// temp1 := __a[j+7:j] * __b[j+7:j] +/// temp2 := __a[j+15:j+8] * __b[j+15:j+8] +/// result[j+15:j] := SATURATE16(temp1 + temp2) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMADDUBSW instruction. +/// +/// \param __a +/// A 256-bit vector containing one of the source operands. +/// \param __b +/// A 256-bit vector containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maddubs_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pmaddubsw256((__v32qi)__a, (__v32qi)__b); +} + +/// Multiplies corresponding 16-bit elements of two 256-bit vectors of +/// [16 x i16], forming 32-bit intermediate products, and adds pairs of +/// those products to form 32-bit sums returned as elements of the +/// [8 x i32] result. +/// +/// There is only one wraparound case: when all four of the 16-bit sources +/// are \c 0x8000, the result will be \c 0x80000000. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// temp1 := __a[j+15:j] * __b[j+15:j] +/// temp2 := __a[j+31:j+16] * __b[j+31:j+16] +/// result[j+31:j] := temp1 + temp2 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMADDWD instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_madd_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pmaddwd256((__v16hi)__a, (__v16hi)__b); +} + +/// Compares the corresponding signed bytes in the two 256-bit integer vectors +/// in \a __a and \a __b and returns the larger of each pair in the +/// corresponding byte of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMAXSB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_max((__v32qs)__a, (__v32qs)__b); +} + +/// Compares the corresponding signed 16-bit integers in the two 256-bit +/// vectors of [16 x i16] in \a __a and \a __b and returns the larger of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMAXSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \param __b +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_max((__v16hi)__a, (__v16hi)__b); +} + +/// Compares the corresponding signed 32-bit integers in the two 256-bit +/// vectors of [8 x i32] in \a __a and \a __b and returns the larger of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMAXSD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \param __b +/// A 256-bit vector of [8 x i32]. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_max((__v8si)__a, (__v8si)__b); +} + +/// Compares the corresponding unsigned bytes in the two 256-bit integer +/// vectors in \a __a and \a __b and returns the larger of each pair in +/// the corresponding byte of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMAXUB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epu8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_max((__v32qu)__a, (__v32qu)__b); +} + +/// Compares the corresponding unsigned 16-bit integers in the two 256-bit +/// vectors of [16 x i16] in \a __a and \a __b and returns the larger of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMAXUW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \param __b +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epu16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_max((__v16hu)__a, (__v16hu)__b); +} + +/// Compares the corresponding unsigned 32-bit integers in the two 256-bit +/// vectors of [8 x i32] in \a __a and \a __b and returns the larger of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMAXUD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \param __b +/// A 256-bit vector of [8 x i32]. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epu32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_max((__v8su)__a, (__v8su)__b); +} + +/// Compares the corresponding signed bytes in the two 256-bit integer vectors +/// in \a __a and \a __b and returns the smaller of each pair in the +/// corresponding byte of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMINSB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_min((__v32qs)__a, (__v32qs)__b); +} + +/// Compares the corresponding signed 16-bit integers in the two 256-bit +/// vectors of [16 x i16] in \a __a and \a __b and returns the smaller of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMINSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \param __b +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_min((__v16hi)__a, (__v16hi)__b); +} + +/// Compares the corresponding signed 32-bit integers in the two 256-bit +/// vectors of [8 x i32] in \a __a and \a __b and returns the smaller of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMINSD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \param __b +/// A 256-bit vector of [8 x i32]. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_min((__v8si)__a, (__v8si)__b); +} + +/// Compares the corresponding unsigned bytes in the two 256-bit integer +/// vectors in \a __a and \a __b and returns the smaller of each pair in +/// the corresponding byte of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMINUB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epu8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_min((__v32qu)__a, (__v32qu)__b); +} + +/// Compares the corresponding unsigned 16-bit integers in the two 256-bit +/// vectors of [16 x i16] in \a __a and \a __b and returns the smaller of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMINUW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \param __b +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epu16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_min((__v16hu)__a, (__v16hu)__b); +} + +/// Compares the corresponding unsigned 32-bit integers in the two 256-bit +/// vectors of [8 x i32] in \a __a and \a __b and returns the smaller of +/// each pair in the corresponding element of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMINUD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \param __b +/// A 256-bit vector of [8 x i32]. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epu32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_min((__v8su)__a, (__v8su)__b); +} + +/// Creates a 32-bit integer mask from the most significant bit of each byte +/// in the 256-bit integer vector in \a __a and returns the result. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[i] := __a[j+7] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVMSKB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing the source bytes. +/// \returns The 32-bit integer mask. +static __inline__ int __DEFAULT_FN_ATTRS256 +_mm256_movemask_epi8(__m256i __a) +{ + return __builtin_ia32_pmovmskb256((__v32qi)__a); +} + +/// Sign-extends bytes from the 128-bit integer vector in \a __V and returns +/// the 16-bit values in the corresponding elements of a 256-bit vector +/// of [16 x i16]. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*8 +/// k := i*16 +/// result[k+15:k] := SignExtend(__V[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXBW instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the source bytes. +/// \returns A 256-bit vector of [16 x i16] containing the sign-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi8_epi16(__m128i __V) +{ + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m256i)__builtin_convertvector((__v16qs)__V, __v16hi); +} + +/// Sign-extends bytes from the lower half of the 128-bit integer vector in +/// \a __V and returns the 32-bit values in the corresponding elements of a +/// 256-bit vector of [8 x i32]. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*8 +/// k := i*32 +/// result[k+31:k] := SignExtend(__V[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXBD instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the source bytes. +/// \returns A 256-bit vector of [8 x i32] containing the sign-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi8_epi32(__m128i __V) +{ + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si); +} + +/// Sign-extends the first four bytes from the 128-bit integer vector in +/// \a __V and returns the 64-bit values in the corresponding elements of a +/// 256-bit vector of [4 x i64]. +/// +/// \code{.operation} +/// result[63:0] := SignExtend(__V[7:0]) +/// result[127:64] := SignExtend(__V[15:8]) +/// result[191:128] := SignExtend(__V[23:16]) +/// result[255:192] := SignExtend(__V[31:24]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXBQ instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the source bytes. +/// \returns A 256-bit vector of [4 x i64] containing the sign-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi8_epi64(__m128i __V) +{ + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4di); +} + +/// Sign-extends 16-bit elements from the 128-bit vector of [8 x i16] in +/// \a __V and returns the 32-bit values in the corresponding elements of a +/// 256-bit vector of [8 x i32]. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*16 +/// k := i*32 +/// result[k+31:k] := SignExtend(__V[j+15:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXWD instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16] containing the source values. +/// \returns A 256-bit vector of [8 x i32] containing the sign-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi16_epi32(__m128i __V) +{ + return (__m256i)__builtin_convertvector((__v8hi)__V, __v8si); +} + +/// Sign-extends 16-bit elements from the lower half of the 128-bit vector of +/// [8 x i16] in \a __V and returns the 64-bit values in the corresponding +/// elements of a 256-bit vector of [4 x i64]. +/// +/// \code{.operation} +/// result[63:0] := SignExtend(__V[15:0]) +/// result[127:64] := SignExtend(__V[31:16]) +/// result[191:128] := SignExtend(__V[47:32]) +/// result[255:192] := SignExtend(__V[64:48]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXWQ instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16] containing the source values. +/// \returns A 256-bit vector of [4 x i64] containing the sign-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi16_epi64(__m128i __V) +{ + return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4di); +} + +/// Sign-extends 32-bit elements from the 128-bit vector of [4 x i32] in +/// \a __V and returns the 64-bit values in the corresponding elements of a +/// 256-bit vector of [4 x i64]. +/// +/// \code{.operation} +/// result[63:0] := SignExtend(__V[31:0]) +/// result[127:64] := SignExtend(__V[63:32]) +/// result[191:128] := SignExtend(__V[95:64]) +/// result[255:192] := SignExtend(__V[127:96]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXDQ instruction. +/// +/// \param __V +/// A 128-bit vector of [4 x i32] containing the source values. +/// \returns A 256-bit vector of [4 x i64] containing the sign-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi32_epi64(__m128i __V) +{ + return (__m256i)__builtin_convertvector((__v4si)__V, __v4di); +} + +/// Zero-extends bytes from the 128-bit integer vector in \a __V and returns +/// the 16-bit values in the corresponding elements of a 256-bit vector +/// of [16 x i16]. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*8 +/// k := i*16 +/// result[k+15:k] := ZeroExtend(__V[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVZXBW instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the source bytes. +/// \returns A 256-bit vector of [16 x i16] containing the zero-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepu8_epi16(__m128i __V) +{ + return (__m256i)__builtin_convertvector((__v16qu)__V, __v16hi); +} + +/// Zero-extends bytes from the lower half of the 128-bit integer vector in +/// \a __V and returns the 32-bit values in the corresponding elements of a +/// 256-bit vector of [8 x i32]. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*8 +/// k := i*32 +/// result[k+31:k] := ZeroExtend(__V[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVZXBD instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the source bytes. +/// \returns A 256-bit vector of [8 x i32] containing the zero-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepu8_epi32(__m128i __V) +{ + return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, 7), __v8si); +} + +/// Zero-extends the first four bytes from the 128-bit integer vector in +/// \a __V and returns the 64-bit values in the corresponding elements of a +/// 256-bit vector of [4 x i64]. +/// +/// \code{.operation} +/// result[63:0] := ZeroExtend(__V[7:0]) +/// result[127:64] := ZeroExtend(__V[15:8]) +/// result[191:128] := ZeroExtend(__V[23:16]) +/// result[255:192] := ZeroExtend(__V[31:24]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVZXBQ instruction. +/// +/// \param __V +/// A 128-bit integer vector containing the source bytes. +/// \returns A 256-bit vector of [4 x i64] containing the zero-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepu8_epi64(__m128i __V) +{ + return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4di); +} + +/// Zero-extends 16-bit elements from the 128-bit vector of [8 x i16] in +/// \a __V and returns the 32-bit values in the corresponding elements of a +/// 256-bit vector of [8 x i32]. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*16 +/// k := i*32 +/// result[k+31:k] := ZeroExtend(__V[j+15:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVZXWD instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16] containing the source values. +/// \returns A 256-bit vector of [8 x i32] containing the zero-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepu16_epi32(__m128i __V) +{ + return (__m256i)__builtin_convertvector((__v8hu)__V, __v8si); +} + +/// Zero-extends 16-bit elements from the lower half of the 128-bit vector of +/// [8 x i16] in \a __V and returns the 64-bit values in the corresponding +/// elements of a 256-bit vector of [4 x i64]. +/// +/// \code{.operation} +/// result[63:0] := ZeroExtend(__V[15:0]) +/// result[127:64] := ZeroExtend(__V[31:16]) +/// result[191:128] := ZeroExtend(__V[47:32]) +/// result[255:192] := ZeroExtend(__V[64:48]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVSXWQ instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16] containing the source values. +/// \returns A 256-bit vector of [4 x i64] containing the zero-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepu16_epi64(__m128i __V) +{ + return (__m256i)__builtin_convertvector(__builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4di); +} + +/// Zero-extends 32-bit elements from the 128-bit vector of [4 x i32] in +/// \a __V and returns the 64-bit values in the corresponding elements of a +/// 256-bit vector of [4 x i64]. +/// +/// \code{.operation} +/// result[63:0] := ZeroExtend(__V[31:0]) +/// result[127:64] := ZeroExtend(__V[63:32]) +/// result[191:128] := ZeroExtend(__V[95:64]) +/// result[255:192] := ZeroExtend(__V[127:96]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMOVZXDQ instruction. +/// +/// \param __V +/// A 128-bit vector of [4 x i32] containing the source values. +/// \returns A 256-bit vector of [4 x i64] containing the zero-extended +/// values. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtepu32_epi64(__m128i __V) +{ + return (__m256i)__builtin_convertvector((__v4su)__V, __v4di); +} + +/// Multiplies signed 32-bit integers from even-numbered elements of two +/// 256-bit vectors of [8 x i32] and returns the 64-bit products in the +/// [4 x i64] result. +/// +/// \code{.operation} +/// result[63:0] := __a[31:0] * __b[31:0] +/// result[127:64] := __a[95:64] * __b[95:64] +/// result[191:128] := __a[159:128] * __b[159:128] +/// result[255:192] := __a[223:192] * __b[223:192] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \returns A 256-bit vector of [4 x i64] containing the products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mul_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pmuldq256((__v8si)__a, (__v8si)__b); +} + +/// Multiplies signed 16-bit integer elements of two 256-bit vectors of +/// [16 x i16], truncates the 32-bit results to the most significant 18 +/// bits, rounds by adding 1, and returns bits [16:1] of each rounded +/// product in the [16 x i16] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// temp := ((__a[j+15:j] * __b[j+15:j]) >> 14) + 1 +/// result[j+15:j] := temp[16:1] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULHRSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the rounded products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mulhrs_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pmulhrsw256((__v16hi)__a, (__v16hi)__b); +} + +/// Multiplies unsigned 16-bit integer elements of two 256-bit vectors of +/// [16 x i16], and returns the upper 16 bits of each 32-bit product in the +/// [16 x i16] result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULHUW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mulhi_epu16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pmulhuw256((__v16hi)__a, (__v16hi)__b); +} + +/// Multiplies signed 16-bit integer elements of two 256-bit vectors of +/// [16 x i16], and returns the upper 16 bits of each 32-bit product in the +/// [16 x i16] result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULHW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mulhi_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pmulhw256((__v16hi)__a, (__v16hi)__b); +} + +/// Multiplies signed 16-bit integer elements of two 256-bit vectors of +/// [16 x i16], and returns the lower 16 bits of each 32-bit product in the +/// [16 x i16] result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULLW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [16 x i16] containing one of the source operands. +/// \returns A 256-bit vector of [16 x i16] containing the products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mullo_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)((__v16hu)__a * (__v16hu)__b); +} + +/// Multiplies signed 32-bit integer elements of two 256-bit vectors of +/// [8 x i32], and returns the lower 32 bits of each 64-bit product in the +/// [8 x i32] result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULLD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \returns A 256-bit vector of [8 x i32] containing the products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mullo_epi32 (__m256i __a, __m256i __b) +{ + return (__m256i)((__v8su)__a * (__v8su)__b); +} + +/// Multiplies unsigned 32-bit integers from even-numered elements of two +/// 256-bit vectors of [8 x i32] and returns the 64-bit products in the +/// [4 x i64] result. +/// +/// \code{.operation} +/// result[63:0] := __a[31:0] * __b[31:0] +/// result[127:64] := __a[95:64] * __b[95:64] +/// result[191:128] := __a[159:128] * __b[159:128] +/// result[255:192] := __a[223:192] * __b[223:192] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULUDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x i32] containing one of the source operands. +/// \returns A 256-bit vector of [4 x i64] containing the products. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mul_epu32(__m256i __a, __m256i __b) +{ + return __builtin_ia32_pmuludq256((__v8si)__a, (__v8si)__b); +} + +/// Computes the bitwise OR of the 256-bit integer vectors in \a __a and +/// \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPOR instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_or_si256(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a | (__v4du)__b); +} + +/// Computes four sum of absolute difference (SAD) operations on sets of eight +/// unsigned 8-bit integers from the 256-bit integer vectors \a __a and +/// \a __b. +/// +/// One SAD result is computed for each set of eight bytes from \a __a and +/// eight bytes from \a __b. The zero-extended SAD value is returned in the +/// corresponding 64-bit element of the result. +/// +/// A single SAD operation takes the differences between the corresponding +/// bytes of \a __a and \a __b, takes the absolute value of each difference, +/// and sums these eight values to form one 16-bit result. This operation +/// is repeated four times with successive sets of eight bytes. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// temp0 := ABS(__a[j+7:j] - __b[j+7:j]) +/// temp1 := ABS(__a[j+15:j+8] - __b[j+15:j+8]) +/// temp2 := ABS(__a[j+23:j+16] - __b[j+23:j+16]) +/// temp3 := ABS(__a[j+31:j+24] - __b[j+31:j+24]) +/// temp4 := ABS(__a[j+39:j+32] - __b[j+39:j+32]) +/// temp5 := ABS(__a[j+47:j+40] - __b[j+47:j+40]) +/// temp6 := ABS(__a[j+55:j+48] - __b[j+55:j+48]) +/// temp7 := ABS(__a[j+63:j+56] - __b[j+63:j+56]) +/// result[j+15:j] := temp0 + temp1 + temp2 + temp3 + +/// temp4 + temp5 + temp6 + temp7 +/// result[j+63:j+16] := 0 +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSADBW instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sad_epu8(__m256i __a, __m256i __b) +{ + return __builtin_ia32_psadbw256((__v32qi)__a, (__v32qi)__b); +} + +/// Shuffles 8-bit integers in the 256-bit integer vector \a __a according +/// to control information in the 256-bit integer vector \a __b, and +/// returns the 256-bit result. In effect there are two separate 128-bit +/// shuffles in the lower and upper halves. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// IF __b[j+7] == 1 +/// result[j+7:j] := 0 +/// ELSE +/// k := __b[j+3:j] * 8 +/// IF i > 15 +/// k := k + 128 +/// FI +/// result[j+7:j] := __a[k+7:k] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSHUFB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing source values. +/// \param __b +/// A 256-bit integer vector containing control information to determine +/// what goes into the corresponding byte of the result. If bit 7 of the +/// control byte is 1, the result byte is 0; otherwise, bits 3:0 of the +/// control byte specify the index (within the same 128-bit half) of \a __a +/// to copy to the result byte. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shuffle_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_pshufb256((__v32qi)__a, (__v32qi)__b); +} + +/// Shuffles 32-bit integers from the 256-bit vector of [8 x i32] in \a a +/// according to control information in the integer literal \a imm, and +/// returns the 256-bit result. In effect there are two parallel 128-bit +/// shuffles in the lower and upper halves. +/// +/// \code{.operation} +/// FOR i := 0 to 3 +/// j := i*32 +/// k := (imm >> i*2)[1:0] * 32 +/// result[j+31:j] := a[k+31:k] +/// result[128+j+31:128+j] := a[128+k+31:128+k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_shuffle_epi32(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSHUFB instruction. +/// +/// \param a +/// A 256-bit vector of [8 x i32] containing source values. +/// \param imm +/// An immediate 8-bit value specifying which elements to copy from \a a. +/// \a imm[1:0] specifies the index in \a a for elements 0 and 4 of the +/// result, \a imm[3:2] specifies the index for elements 1 and 5, and so +/// forth. +/// \returns A 256-bit vector of [8 x i32] containing the result. +#define _mm256_shuffle_epi32(a, imm) \ + ((__m256i)__builtin_ia32_pshufd256((__v8si)(__m256i)(a), (int)(imm))) + +/// Shuffles 16-bit integers from the 256-bit vector of [16 x i16] in \a a +/// according to control information in the integer literal \a imm, and +/// returns the 256-bit result. The upper 64 bits of each 128-bit half +/// are shuffled in parallel; the lower 64 bits of each 128-bit half are +/// copied from \a a unchanged. +/// +/// \code{.operation} +/// result[63:0] := a[63:0] +/// result[191:128] := a[191:128] +/// FOR i := 0 TO 3 +/// j := i * 16 + 64 +/// k := (imm >> i*2)[1:0] * 16 + 64 +/// result[j+15:j] := a[k+15:k] +/// result[128+j+15:128+j] := a[128+k+15:128+k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_shufflehi_epi16(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSHUFHW instruction. +/// +/// \param a +/// A 256-bit vector of [16 x i16] containing source values. +/// \param imm +/// An immediate 8-bit value specifying which elements to copy from \a a. +/// \a imm[1:0] specifies the index in \a a for elements 4 and 8 of the +/// result, \a imm[3:2] specifies the index for elements 5 and 9, and so +/// forth. Indexes are offset by 4 (so 0 means index 4, and so forth). +/// \returns A 256-bit vector of [16 x i16] containing the result. +#define _mm256_shufflehi_epi16(a, imm) \ + ((__m256i)__builtin_ia32_pshufhw256((__v16hi)(__m256i)(a), (int)(imm))) + +/// Shuffles 16-bit integers from the 256-bit vector of [16 x i16] \a a +/// according to control information in the integer literal \a imm, and +/// returns the 256-bit [16 x i16] result. The lower 64 bits of each +/// 128-bit half are shuffled; the upper 64 bits of each 128-bit half are +/// copied from \a a unchanged. +/// +/// \code{.operation} +/// result[127:64] := a[127:64] +/// result[255:192] := a[255:192] +/// FOR i := 0 TO 3 +/// j := i * 16 +/// k := (imm >> i*2)[1:0] * 16 +/// result[j+15:j] := a[k+15:k] +/// result[128+j+15:128+j] := a[128+k+15:128+k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_shufflelo_epi16(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSHUFLW instruction. +/// +/// \param a +/// A 256-bit vector of [16 x i16] to use as a source of data for the +/// result. +/// \param imm +/// An immediate 8-bit value specifying which elements to copy from \a a. +/// \a imm[1:0] specifies the index in \a a for elements 0 and 8 of the +/// result, \a imm[3:2] specifies the index for elements 1 and 9, and so +/// forth. +/// \returns A 256-bit vector of [16 x i16] containing the result. +#define _mm256_shufflelo_epi16(a, imm) \ + ((__m256i)__builtin_ia32_pshuflw256((__v16hi)(__m256i)(a), (int)(imm))) + +/// Sets each byte of the result to the corresponding byte of the 256-bit +/// integer vector in \a __a, the negative of that byte, or zero, depending +/// on whether the corresponding byte of the 256-bit integer vector in +/// \a __b is greater than zero, less than zero, or equal to zero, +/// respectively. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSIGNB instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector]. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sign_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_psignb256((__v32qi)__a, (__v32qi)__b); +} + +/// Sets each element of the result to the corresponding element of the +/// 256-bit vector of [16 x i16] in \a __a, the negative of that element, +/// or zero, depending on whether the corresponding element of the 256-bit +/// vector of [16 x i16] in \a __b is greater than zero, less than zero, or +/// equal to zero, respectively. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSIGNW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16]. +/// \param __b +/// A 256-bit vector of [16 x i16]. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sign_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_psignw256((__v16hi)__a, (__v16hi)__b); +} + +/// Sets each element of the result to the corresponding element of the +/// 256-bit vector of [8 x i32] in \a __a, the negative of that element, or +/// zero, depending on whether the corresponding element of the 256-bit +/// vector of [8 x i32] in \a __b is greater than zero, less than zero, or +/// equal to zero, respectively. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSIGND instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \param __b +/// A 256-bit vector of [8 x i32]. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sign_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_psignd256((__v8si)__a, (__v8si)__b); +} + +/// Shifts each 128-bit half of the 256-bit integer vector \a a left by +/// \a imm bytes, shifting in zero bytes, and returns the result. If \a imm +/// is greater than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_slli_si256(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSLLDQ instruction. +/// +/// \param a +/// A 256-bit integer vector to be shifted. +/// \param imm +/// An unsigned immediate value specifying the shift count (in bytes). +/// \returns A 256-bit integer vector containing the result. +#define _mm256_slli_si256(a, imm) \ + ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm))) + +/// Shifts each 128-bit half of the 256-bit integer vector \a a left by +/// \a imm bytes, shifting in zero bytes, and returns the result. If \a imm +/// is greater than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_bslli_epi128(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSLLDQ instruction. +/// +/// \param a +/// A 256-bit integer vector to be shifted. +/// \param imm +/// An unsigned immediate value specifying the shift count (in bytes). +/// \returns A 256-bit integer vector containing the result. +#define _mm256_bslli_epi128(a, imm) \ + ((__m256i)__builtin_ia32_pslldqi256_byteshift((__v4di)(__m256i)(a), (int)(imm))) + +/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a +/// left by \a __count bits, shifting in zero bits, and returns the result. +/// If \a __count is greater than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_slli_epi16(__m256i __a, int __count) +{ + return (__m256i)__builtin_ia32_psllwi256((__v16hi)__a, __count); +} + +/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a +/// left by the number of bits specified by the lower 64 bits of \a __count, +/// shifting in zero bits, and returns the result. If \a __count is greater +/// than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sll_epi16(__m256i __a, __m128i __count) +{ + return (__m256i)__builtin_ia32_psllw256((__v16hi)__a, (__v8hi)__count); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a +/// left by \a __count bits, shifting in zero bits, and returns the result. +/// If \a __count is greater than 31, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_slli_epi32(__m256i __a, int __count) +{ + return (__m256i)__builtin_ia32_pslldi256((__v8si)__a, __count); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a +/// left by the number of bits given in the lower 64 bits of \a __count, +/// shifting in zero bits, and returns the result. If \a __count is greater +/// than 31, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sll_epi32(__m256i __a, __m128i __count) +{ + return (__m256i)__builtin_ia32_pslld256((__v8si)__a, (__v4si)__count); +} + +/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a +/// left by \a __count bits, shifting in zero bits, and returns the result. +/// If \a __count is greater than 63, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_slli_epi64(__m256i __a, int __count) +{ + return __builtin_ia32_psllqi256((__v4di)__a, __count); +} + +/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a +/// left by the number of bits given in the lower 64 bits of \a __count, +/// shifting in zero bits, and returns the result. If \a __count is greater +/// than 63, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sll_epi64(__m256i __a, __m128i __count) +{ + return __builtin_ia32_psllq256((__v4di)__a, __count); +} + +/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a +/// right by \a __count bits, shifting in sign bits, and returns the result. +/// If \a __count is greater than 15, each element of the result is either +/// 0 or -1 according to the corresponding input sign bit. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRAW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srai_epi16(__m256i __a, int __count) +{ + return (__m256i)__builtin_ia32_psrawi256((__v16hi)__a, __count); +} + +/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a +/// right by the number of bits given in the lower 64 bits of \a __count, +/// shifting in sign bits, and returns the result. If \a __count is greater +/// than 15, each element of the result is either 0 or -1 according to the +/// corresponding input sign bit. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRAW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sra_epi16(__m256i __a, __m128i __count) +{ + return (__m256i)__builtin_ia32_psraw256((__v16hi)__a, (__v8hi)__count); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a +/// right by \a __count bits, shifting in sign bits, and returns the result. +/// If \a __count is greater than 31, each element of the result is either +/// 0 or -1 according to the corresponding input sign bit. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRAD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srai_epi32(__m256i __a, int __count) +{ + return (__m256i)__builtin_ia32_psradi256((__v8si)__a, __count); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a +/// right by the number of bits given in the lower 64 bits of \a __count, +/// shifting in sign bits, and returns the result. If \a __count is greater +/// than 31, each element of the result is either 0 or -1 according to the +/// corresponding input sign bit. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRAD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sra_epi32(__m256i __a, __m128i __count) +{ + return (__m256i)__builtin_ia32_psrad256((__v8si)__a, (__v4si)__count); +} + +/// Shifts each 128-bit half of the 256-bit integer vector in \a a right by +/// \a imm bytes, shifting in zero bytes, and returns the result. If +/// \a imm is greater than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_srli_si256(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSRLDQ instruction. +/// +/// \param a +/// A 256-bit integer vector to be shifted. +/// \param imm +/// An unsigned immediate value specifying the shift count (in bytes). +/// \returns A 256-bit integer vector containing the result. +#define _mm256_srli_si256(a, imm) \ + ((__m256i)__builtin_ia32_psrldqi256_byteshift((__m256i)(a), (int)(imm))) + +/// Shifts each 128-bit half of the 256-bit integer vector in \a a right by +/// \a imm bytes, shifting in zero bytes, and returns the result. If +/// \a imm is greater than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_bsrli_epi128(__m256i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPSRLDQ instruction. +/// +/// \param a +/// A 256-bit integer vector to be shifted. +/// \param imm +/// An unsigned immediate value specifying the shift count (in bytes). +/// \returns A 256-bit integer vector containing the result. +#define _mm256_bsrli_epi128(a, imm) \ + ((__m256i)__builtin_ia32_psrldqi256_byteshift((__m256i)(a), (int)(imm))) + +/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a +/// right by \a __count bits, shifting in zero bits, and returns the result. +/// If \a __count is greater than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srli_epi16(__m256i __a, int __count) +{ + return (__m256i)__builtin_ia32_psrlwi256((__v16hi)__a, __count); +} + +/// Shifts each 16-bit element of the 256-bit vector of [16 x i16] in \a __a +/// right by the number of bits given in the lower 64 bits of \a __count, +/// shifting in zero bits, and returns the result. If \a __count is greater +/// than 15, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srl_epi16(__m256i __a, __m128i __count) +{ + return (__m256i)__builtin_ia32_psrlw256((__v16hi)__a, (__v8hi)__count); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a +/// right by \a __count bits, shifting in zero bits, and returns the result. +/// If \a __count is greater than 31, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srli_epi32(__m256i __a, int __count) +{ + return (__m256i)__builtin_ia32_psrldi256((__v8si)__a, __count); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __a +/// right by the number of bits given in the lower 64 bits of \a __count, +/// shifting in zero bits, and returns the result. If \a __count is greater +/// than 31, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srl_epi32(__m256i __a, __m128i __count) +{ + return (__m256i)__builtin_ia32_psrld256((__v8si)__a, (__v4si)__count); +} + +/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a +/// right by \a __count bits, shifting in zero bits, and returns the result. +/// If \a __count is greater than 63, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] to be shifted. +/// \param __count +/// An unsigned integer value specifying the shift count (in bits). +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srli_epi64(__m256i __a, int __count) +{ + return __builtin_ia32_psrlqi256((__v4di)__a, __count); +} + +/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __a +/// right by the number of bits given in the lower 64 bits of \a __count, +/// shifting in zero bits, and returns the result. If \a __count is greater +/// than 63, the returned result is all zeroes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] to be shifted. +/// \param __count +/// A 128-bit vector of [2 x i64] whose lower element gives the unsigned +/// shift count (in bits). The upper element is ignored. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srl_epi64(__m256i __a, __m128i __count) +{ + return __builtin_ia32_psrlq256((__v4di)__a, __count); +} + +/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer +/// vectors. Returns the lower 8 bits of each difference in the +/// corresponding byte of the 256-bit integer vector result (overflow is +/// ignored). +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[j+7:j] := __a[j+7:j] - __b[j+7:j] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing the minuends. +/// \param __b +/// A 256-bit integer vector containing the subtrahends. +/// \returns A 256-bit integer vector containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sub_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)((__v32qu)__a - (__v32qu)__b); +} + +/// Subtracts 16-bit integers from corresponding elements of two 256-bit +/// vectors of [16 x i16]. Returns the lower 16 bits of each difference in +/// the corresponding element of the [16 x i16] result (overflow is +/// ignored). +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// result[j+15:j] := __a[j+15:j] - __b[j+15:j] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing the minuends. +/// \param __b +/// A 256-bit vector of [16 x i16] containing the subtrahends. +/// \returns A 256-bit vector of [16 x i16] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sub_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)((__v16hu)__a - (__v16hu)__b); +} + +/// Subtracts 32-bit integers from corresponding elements of two 256-bit +/// vectors of [8 x i32]. Returns the lower 32 bits of each difference in +/// the corresponding element of the [8 x i32] result (overflow is ignored). +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// result[j+31:j] := __a[j+31:j] - __b[j+31:j] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing the minuends. +/// \param __b +/// A 256-bit vector of [8 x i32] containing the subtrahends. +/// \returns A 256-bit vector of [8 x i32] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sub_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8su)__a - (__v8su)__b); +} + +/// Subtracts 64-bit integers from corresponding elements of two 256-bit +/// vectors of [4 x i64]. Returns the lower 64 bits of each difference in +/// the corresponding element of the [4 x i64] result (overflow is ignored). +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// result[j+63:j] := __a[j+63:j] - __b[j+63:j] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] containing the minuends. +/// \param __b +/// A 256-bit vector of [4 x i64] containing the subtrahends. +/// \returns A 256-bit vector of [4 x i64] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sub_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a - (__v4du)__b); +} + +/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer +/// vectors using signed saturation, and returns each differences in the +/// corresponding byte of the 256-bit integer vector result. +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[j+7:j] := SATURATE8(__a[j+7:j] - __b[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBSB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing the minuends. +/// \param __b +/// A 256-bit integer vector containing the subtrahends. +/// \returns A 256-bit integer vector containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_subs_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_sub_sat((__v32qs)__a, (__v32qs)__b); +} + +/// Subtracts 16-bit integers from corresponding elements of two 256-bit +/// vectors of [16 x i16] using signed saturation, and returns each +/// difference in the corresponding element of the [16 x i16] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// result[j+7:j] := SATURATE16(__a[j+7:j] - __b[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing the minuends. +/// \param __b +/// A 256-bit vector of [16 x i16] containing the subtrahends. +/// \returns A 256-bit vector of [16 x i16] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_subs_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_sub_sat((__v16hi)__a, (__v16hi)__b); +} + +/// Subtracts 8-bit integers from corresponding bytes of two 256-bit integer +/// vectors using unsigned saturation, and returns each difference in the +/// corresponding byte of the 256-bit integer vector result. For each byte, +/// computes result = __a - __b . +/// +/// \code{.operation} +/// FOR i := 0 TO 31 +/// j := i*8 +/// result[j+7:j] := SATURATE8U(__a[j+7:j] - __b[j+7:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBUSB instruction. +/// +/// \param __a +/// A 256-bit integer vector containing the minuends. +/// \param __b +/// A 256-bit integer vector containing the subtrahends. +/// \returns A 256-bit integer vector containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_subs_epu8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_sub_sat((__v32qu)__a, (__v32qu)__b); +} + +/// Subtracts 16-bit integers from corresponding elements of two 256-bit +/// vectors of [16 x i16] using unsigned saturation, and returns each +/// difference in the corresponding element of the [16 x i16] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 15 +/// j := i*16 +/// result[j+15:j] := SATURATE16U(__a[j+15:j] - __b[j+15:j]) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSUBUSW instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] containing the minuends. +/// \param __b +/// A 256-bit vector of [16 x i16] containing the subtrahends. +/// \returns A 256-bit vector of [16 x i16] containing the differences. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_subs_epu16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_elementwise_sub_sat((__v16hu)__a, (__v16hu)__b); +} + +/// Unpacks and interleaves 8-bit integers from parts of the 256-bit integer +/// vectors in \a __a and \a __b to form the 256-bit result. Specifically, +/// uses the upper 64 bits of each 128-bit half of \a __a and \a __b as +/// input; other bits in these parameters are ignored. +/// +/// \code{.operation} +/// result[7:0] := __a[71:64] +/// result[15:8] := __b[71:64] +/// result[23:16] := __a[79:72] +/// result[31:24] := __b[79:72] +/// . . . +/// result[127:120] := __b[127:120] +/// result[135:128] := __a[199:192] +/// . . . +/// result[255:248] := __b[255:248] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKHBW instruction. +/// +/// \param __a +/// A 256-bit integer vector used as the source for the even-numbered bytes +/// of the result. +/// \param __b +/// A 256-bit integer vector used as the source for the odd-numbered bytes +/// of the result. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpackhi_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 8, 32+8, 9, 32+9, 10, 32+10, 11, 32+11, 12, 32+12, 13, 32+13, 14, 32+14, 15, 32+15, 24, 32+24, 25, 32+25, 26, 32+26, 27, 32+27, 28, 32+28, 29, 32+29, 30, 32+30, 31, 32+31); +} + +/// Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors +/// of [16 x i16] in \a __a and \a __b to return the resulting 256-bit +/// vector of [16 x i16]. Specifically, uses the upper 64 bits of each +/// 128-bit half of \a __a and \a __b as input; other bits in these +/// parameters are ignored. +/// +/// \code{.operation} +/// result[15:0] := __a[79:64] +/// result[31:16] := __b[79:64] +/// result[47:32] := __a[95:80] +/// result[63:48] := __b[95:80] +/// . . . +/// result[127:112] := __b[127:112] +/// result[143:128] := __a[211:196] +/// . . . +/// result[255:240] := __b[255:240] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKHWD instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] used as the source for the even-numbered +/// elements of the result. +/// \param __b +/// A 256-bit vector of [16 x i16] used as the source for the odd-numbered +/// elements of the result. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpackhi_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15); +} + +/// Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors +/// of [8 x i32] in \a __a and \a __b to return the resulting 256-bit vector +/// of [8 x i32]. Specifically, uses the upper 64 bits of each 128-bit half +/// of \a __a and \a __b as input; other bits in these parameters are +/// ignored. +/// +/// \code{.operation} +/// result[31:0] := __a[95:64] +/// result[63:32] := __b[95:64] +/// result[95:64] := __a[127:96] +/// result[127:96] := __b[127:96] +/// result[159:128] := __a[223:192] +/// result[191:160] := __b[223:192] +/// result[223:192] := __a[255:224] +/// result[255:224] := __b[255:224] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKHDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] used as the source for the even-numbered +/// elements of the result. +/// \param __b +/// A 256-bit vector of [8 x i32] used as the source for the odd-numbered +/// elements of the result. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpackhi_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 2, 8+2, 3, 8+3, 6, 8+6, 7, 8+7); +} + +/// Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors +/// of [4 x i64] in \a __a and \a __b to return the resulting 256-bit vector +/// of [4 x i64]. Specifically, uses the upper 64 bits of each 128-bit half +/// of \a __a and \a __b as input; other bits in these parameters are +/// ignored. +/// +/// \code{.operation} +/// result[63:0] := __a[127:64] +/// result[127:64] := __b[127:64] +/// result[191:128] := __a[255:192] +/// result[255:192] := __b[255:192] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKHQDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] used as the source for the even-numbered +/// elements of the result. +/// \param __b +/// A 256-bit vector of [4 x i64] used as the source for the odd-numbered +/// elements of the result. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpackhi_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 1, 4+1, 3, 4+3); +} + +/// Unpacks and interleaves 8-bit integers from parts of the 256-bit integer +/// vectors in \a __a and \a __b to form the 256-bit result. Specifically, +/// uses the lower 64 bits of each 128-bit half of \a __a and \a __b as +/// input; other bits in these parameters are ignored. +/// +/// \code{.operation} +/// result[7:0] := __a[7:0] +/// result[15:8] := __b[7:0] +/// result[23:16] := __a[15:8] +/// result[31:24] := __b[15:8] +/// . . . +/// result[127:120] := __b[63:56] +/// result[135:128] := __a[135:128] +/// . . . +/// result[255:248] := __b[191:184] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKLBW instruction. +/// +/// \param __a +/// A 256-bit integer vector used as the source for the even-numbered bytes +/// of the result. +/// \param __b +/// A 256-bit integer vector used as the source for the odd-numbered bytes +/// of the result. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpacklo_epi8(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v32qi)__a, (__v32qi)__b, 0, 32+0, 1, 32+1, 2, 32+2, 3, 32+3, 4, 32+4, 5, 32+5, 6, 32+6, 7, 32+7, 16, 32+16, 17, 32+17, 18, 32+18, 19, 32+19, 20, 32+20, 21, 32+21, 22, 32+22, 23, 32+23); +} + +/// Unpacks and interleaves 16-bit integers from parts of the 256-bit vectors +/// of [16 x i16] in \a __a and \a __b to return the resulting 256-bit +/// vector of [16 x i16]. Specifically, uses the lower 64 bits of each +/// 128-bit half of \a __a and \a __b as input; other bits in these +/// parameters are ignored. +/// +/// \code{.operation} +/// result[15:0] := __a[15:0] +/// result[31:16] := __b[15:0] +/// result[47:32] := __a[31:16] +/// result[63:48] := __b[31:16] +/// . . . +/// result[127:112] := __b[63:48] +/// result[143:128] := __a[143:128] +/// . . . +/// result[255:239] := __b[191:176] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKLWD instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x i16] used as the source for the even-numbered +/// elements of the result. +/// \param __b +/// A 256-bit vector of [16 x i16] used as the source for the odd-numbered +/// elements of the result. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpacklo_epi16(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v16hi)__a, (__v16hi)__b, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11); +} + +/// Unpacks and interleaves 32-bit integers from parts of the 256-bit vectors +/// of [8 x i32] in \a __a and \a __b to return the resulting 256-bit vector +/// of [8 x i32]. Specifically, uses the lower 64 bits of each 128-bit half +/// of \a __a and \a __b as input; other bits in these parameters are +/// ignored. +/// +/// \code{.operation} +/// result[31:0] := __a[31:0] +/// result[63:32] := __b[31:0] +/// result[95:64] := __a[63:32] +/// result[127:96] := __b[63:32] +/// result[159:128] := __a[159:128] +/// result[191:160] := __b[159:128] +/// result[223:192] := __a[191:160] +/// result[255:224] := __b[191:190] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKLDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] used as the source for the even-numbered +/// elements of the result. +/// \param __b +/// A 256-bit vector of [8 x i32] used as the source for the odd-numbered +/// elements of the result. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpacklo_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v8si)__a, (__v8si)__b, 0, 8+0, 1, 8+1, 4, 8+4, 5, 8+5); +} + +/// Unpacks and interleaves 64-bit integers from parts of the 256-bit vectors +/// of [4 x i64] in \a __a and \a __b to return the resulting 256-bit vector +/// of [4 x i64]. Specifically, uses the lower 64 bits of each 128-bit half +/// of \a __a and \a __b as input; other bits in these parameters are +/// ignored. +/// +/// \code{.operation} +/// result[63:0] := __a[63:0] +/// result[127:64] := __b[63:0] +/// result[191:128] := __a[191:128] +/// result[255:192] := __b[191:128] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPUNPCKLQDQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64] used as the source for the even-numbered +/// elements of the result. +/// \param __b +/// A 256-bit vector of [4 x i64] used as the source for the odd-numbered +/// elements of the result. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_unpacklo_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_shufflevector((__v4di)__a, (__v4di)__b, 0, 4+0, 2, 4+2); +} + +/// Computes the bitwise XOR of the 256-bit integer vectors in \a __a and +/// \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPXOR instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_xor_si256(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a ^ (__v4du)__b); +} + +/// Loads the 256-bit integer vector from memory \a __V using a non-temporal +/// memory hint and returns the vector. \a __V must be aligned on a 32-byte +/// boundary. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VMOVNTDQA instruction. +/// +/// \param __V +/// A pointer to the 32-byte aligned memory containing the vector to load. +/// \returns A 256-bit integer vector loaded from memory. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_stream_load_si256(const void *__V) +{ + typedef __v4di __v4di_aligned __attribute__((aligned(32))); + return (__m256i)__builtin_nontemporal_load((const __v4di_aligned *)__V); +} + +/// Broadcasts the 32-bit floating-point value from the low element of the +/// 128-bit vector of [4 x float] in \a __X to all elements of the result's +/// 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VBROADCASTSS instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x float] whose low element will be broadcast. +/// \returns A 128-bit vector of [4 x float] containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_broadcastss_ps(__m128 __X) +{ + return (__m128)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0); +} + +/// Broadcasts the 64-bit floating-point value from the low element of the +/// 128-bit vector of [2 x double] in \a __a to both elements of the +/// result's 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MOVDDUP instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] whose low element will be broadcast. +/// \returns A 128-bit vector of [2 x double] containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_broadcastsd_pd(__m128d __a) +{ + return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0); +} + +/// Broadcasts the 32-bit floating-point value from the low element of the +/// 128-bit vector of [4 x float] in \a __X to all elements of the +/// result's 256-bit vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VBROADCASTSS instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x float] whose low element will be broadcast. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_broadcastss_ps(__m128 __X) +{ + return (__m256)__builtin_shufflevector((__v4sf)__X, (__v4sf)__X, 0, 0, 0, 0, 0, 0, 0, 0); +} + +/// Broadcasts the 64-bit floating-point value from the low element of the +/// 128-bit vector of [2 x double] in \a __X to all elements of the +/// result's 256-bit vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VBROADCASTSD instruction. +/// +/// \param __X +/// A 128-bit vector of [2 x double] whose low element will be broadcast. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_broadcastsd_pd(__m128d __X) +{ + return (__m256d)__builtin_shufflevector((__v2df)__X, (__v2df)__X, 0, 0, 0, 0); +} + +/// Broadcasts the 128-bit integer data from \a __X to both the lower and +/// upper halves of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VBROADCASTI128 instruction. +/// +/// \param __X +/// A 128-bit integer vector to be broadcast. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastsi128_si256(__m128i __X) +{ + return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 1); +} + +#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X) + +/// Merges 32-bit integer elements from either of the two 128-bit vectors of +/// [4 x i32] in \a V1 or \a V2 to the result's 128-bit vector of [4 x i32], +/// as specified by the immediate integer operand \a M. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*32 +/// IF M[i] == 0 +/// result[31+j:j] := V1[31+j:j] +/// ELSE +/// result[31+j:j] := V2[32+j:j] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_blend_epi32(__m128i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPBLENDDD instruction. +/// +/// \param V1 +/// A 128-bit vector of [4 x i32] containing source values. +/// \param V2 +/// A 128-bit vector of [4 x i32] containing source values. +/// \param M +/// An immediate 8-bit integer operand, with bits [3:0] specifying the +/// source for each element of the result. The position of the mask bit +/// corresponds to the index of a copied value. When a mask bit is 0, the +/// element is copied from \a V1; otherwise, it is copied from \a V2. +/// \returns A 128-bit vector of [4 x i32] containing the result. +#define _mm_blend_epi32(V1, V2, M) \ + ((__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \ + (__v4si)(__m128i)(V2), (int)(M))) + +/// Merges 32-bit integer elements from either of the two 256-bit vectors of +/// [8 x i32] in \a V1 or \a V2 to return a 256-bit vector of [8 x i32], +/// as specified by the immediate integer operand \a M. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// IF M[i] == 0 +/// result[31+j:j] := V1[31+j:j] +/// ELSE +/// result[31+j:j] := V2[32+j:j] +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_blend_epi32(__m256i V1, __m256i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPBLENDDD instruction. +/// +/// \param V1 +/// A 256-bit vector of [8 x i32] containing source values. +/// \param V2 +/// A 256-bit vector of [8 x i32] containing source values. +/// \param M +/// An immediate 8-bit integer operand, with bits [7:0] specifying the +/// source for each element of the result. The position of the mask bit +/// corresponds to the index of a copied value. When a mask bit is 0, the +/// element is copied from \a V1; otherwise, it is is copied from \a V2. +/// \returns A 256-bit vector of [8 x i32] containing the result. +#define _mm256_blend_epi32(V1, V2, M) \ + ((__m256i)__builtin_ia32_pblendd256((__v8si)(__m256i)(V1), \ + (__v8si)(__m256i)(V2), (int)(M))) + +/// Broadcasts the low byte from the 128-bit integer vector in \a __X to all +/// bytes of the 256-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTB instruction. +/// +/// \param __X +/// A 128-bit integer vector whose low byte will be broadcast. +/// \returns A 256-bit integer vector containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastb_epi8(__m128i __X) +{ + return (__m256i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 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); +} + +/// Broadcasts the low element from the 128-bit vector of [8 x i16] in \a __X +/// to all elements of the result's 256-bit vector of [16 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTW instruction. +/// +/// \param __X +/// A 128-bit vector of [8 x i16] whose low element will be broadcast. +/// \returns A 256-bit vector of [16 x i16] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastw_epi16(__m128i __X) +{ + return (__m256i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +/// Broadcasts the low element from the 128-bit vector of [4 x i32] in \a __X +/// to all elements of the result's 256-bit vector of [8 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTD instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] whose low element will be broadcast. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastd_epi32(__m128i __X) +{ + return (__m256i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0, 0, 0, 0, 0); +} + +/// Broadcasts the low element from the 128-bit vector of [2 x i64] in \a __X +/// to all elements of the result's 256-bit vector of [4 x i64]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTQ instruction. +/// +/// \param __X +/// A 128-bit vector of [2 x i64] whose low element will be broadcast. +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastq_epi64(__m128i __X) +{ + return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0, 0, 0); +} + +/// Broadcasts the low byte from the 128-bit integer vector in \a __X to all +/// bytes of the 128-bit result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTB instruction. +/// +/// \param __X +/// A 128-bit integer vector whose low byte will be broadcast. +/// \returns A 128-bit integer vector containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcastb_epi8(__m128i __X) +{ + return (__m128i)__builtin_shufflevector((__v16qi)__X, (__v16qi)__X, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +/// Broadcasts the low element from the 128-bit vector of [8 x i16] in +/// \a __X to all elements of the result's 128-bit vector of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTW instruction. +/// +/// \param __X +/// A 128-bit vector of [8 x i16] whose low element will be broadcast. +/// \returns A 128-bit vector of [8 x i16] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcastw_epi16(__m128i __X) +{ + return (__m128i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0); +} + +/// Broadcasts the low element from the 128-bit vector of [4 x i32] in \a __X +/// to all elements of the result's vector of [4 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTD instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] whose low element will be broadcast. +/// \returns A 128-bit vector of [4 x i32] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcastd_epi32(__m128i __X) +{ + return (__m128i)__builtin_shufflevector((__v4si)__X, (__v4si)__X, 0, 0, 0, 0); +} + +/// Broadcasts the low element from the 128-bit vector of [2 x i64] in \a __X +/// to both elements of the result's 128-bit vector of [2 x i64]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPBROADCASTQ instruction. +/// +/// \param __X +/// A 128-bit vector of [2 x i64] whose low element will be broadcast. +/// \returns A 128-bit vector of [2 x i64] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcastq_epi64(__m128i __X) +{ + return (__m128i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 0); +} + +/// Sets the result's 256-bit vector of [8 x i32] to copies of elements of the +/// 256-bit vector of [8 x i32] in \a __a as specified by indexes in the +/// elements of the 256-bit vector of [8 x i32] in \a __b. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// k := __b[j+2:j] * 32 +/// result[j+31:j] := __a[k+31:k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPERMD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32] containing the source values. +/// \param __b +/// A 256-bit vector of [8 x i32] containing indexes of values to use from +/// \a __a. +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_permutevar8x32_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)__builtin_ia32_permvarsi256((__v8si)__a, (__v8si)__b); +} + +/// Sets the result's 256-bit vector of [4 x double] to copies of elements of +/// the 256-bit vector of [4 x double] in \a V as specified by the +/// immediate value \a M. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// k := (M >> i*2)[1:0] * 64 +/// result[j+63:j] := V[k+63:k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_permute4x64_pd(__m256d V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPERMPD instruction. +/// +/// \param V +/// A 256-bit vector of [4 x double] containing the source values. +/// \param M +/// An immediate 8-bit value specifying which elements to copy from \a V. +/// \a M[1:0] specifies the index in \a a for element 0 of the result, +/// \a M[3:2] specifies the index for element 1, and so forth. +/// \returns A 256-bit vector of [4 x double] containing the result. +#define _mm256_permute4x64_pd(V, M) \ + ((__m256d)__builtin_ia32_permdf256((__v4df)(__m256d)(V), (int)(M))) + +/// Sets the result's 256-bit vector of [8 x float] to copies of elements of +/// the 256-bit vector of [8 x float] in \a __a as specified by indexes in +/// the elements of the 256-bit vector of [8 x i32] in \a __b. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// k := __b[j+2:j] * 32 +/// result[j+31:j] := __a[k+31:k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPERMPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing the source values. +/// \param __b +/// A 256-bit vector of [8 x i32] containing indexes of values to use from +/// \a __a. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_permutevar8x32_ps(__m256 __a, __m256i __b) +{ + return (__m256)__builtin_ia32_permvarsf256((__v8sf)__a, (__v8si)__b); +} + +/// Sets the result's 256-bit vector of [4 x i64] result to copies of elements +/// of the 256-bit vector of [4 x i64] in \a V as specified by the +/// immediate value \a M. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// k := (M >> i*2)[1:0] * 64 +/// result[j+63:j] := V[k+63:k] +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_permute4x64_epi64(__m256i V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPERMQ instruction. +/// +/// \param V +/// A 256-bit vector of [4 x i64] containing the source values. +/// \param M +/// An immediate 8-bit value specifying which elements to copy from \a V. +/// \a M[1:0] specifies the index in \a a for element 0 of the result, +/// \a M[3:2] specifies the index for element 1, and so forth. +/// \returns A 256-bit vector of [4 x i64] containing the result. +#define _mm256_permute4x64_epi64(V, M) \ + ((__m256i)__builtin_ia32_permdi256((__v4di)(__m256i)(V), (int)(M))) + +/// Sets each half of the 256-bit result either to zero or to one of the +/// four possible 128-bit halves of the 256-bit vectors \a V1 and \a V2, +/// as specified by the immediate value \a M. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*128 +/// k := M >> (i*4) +/// IF k[3] == 0 +/// CASE (k[1:0]) OF +/// 0: result[127+j:j] := V1[127:0] +/// 1: result[127+j:j] := V1[255:128] +/// 2: result[127+j:j] := V2[127:0] +/// 3: result[127+j:j] := V2[255:128] +/// ESAC +/// ELSE +/// result[127+j:j] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_permute2x128_si256(__m256i V1, __m256i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPERM2I128 instruction. +/// +/// \param V1 +/// A 256-bit integer vector containing source values. +/// \param V2 +/// A 256-bit integer vector containing source values. +/// \param M +/// An immediate value specifying how to form the result. Bits [3:0] +/// control the lower half of the result, bits [7:4] control the upper half. +/// Within each 4-bit control value, if bit 3 is 1, the result is zero, +/// otherwise bits [1:0] determine the source as follows. \n +/// 0: the lower half of \a V1 \n +/// 1: the upper half of \a V1 \n +/// 2: the lower half of \a V2 \n +/// 3: the upper half of \a V2 +/// \returns A 256-bit integer vector containing the result. +#define _mm256_permute2x128_si256(V1, V2, M) \ + ((__m256i)__builtin_ia32_permti256((__m256i)(V1), (__m256i)(V2), (int)(M))) + +/// Extracts half of the 256-bit vector \a V to the 128-bit result. If bit 0 +/// of the immediate \a M is zero, extracts the lower half of the result; +/// otherwise, extracts the upper half. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm256_extracti128_si256(__m256i V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VEXTRACTI128 instruction. +/// +/// \param V +/// A 256-bit integer vector containing the source values. +/// \param M +/// An immediate value specifying which half of \a V to extract. +/// \returns A 128-bit integer vector containing the result. +#define _mm256_extracti128_si256(V, M) \ + ((__m128i)__builtin_ia32_extract128i256((__v4di)(__m256i)(V), (int)(M))) + +/// Copies the 256-bit vector \a V1 to the result, then overwrites half of the +/// result with the 128-bit vector \a V2. If bit 0 of the immediate \a M +/// is zero, overwrites the lower half of the result; otherwise, +/// overwrites the upper half. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_inserti128_si256(__m256i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c VINSERTI128 instruction. +/// +/// \param V1 +/// A 256-bit integer vector containing a source value. +/// \param V2 +/// A 128-bit integer vector containing a source value. +/// \param M +/// An immediate value specifying where to put \a V2 in the result. +/// \returns A 256-bit integer vector containing the result. +#define _mm256_inserti128_si256(V1, V2, M) \ + ((__m256i)__builtin_ia32_insert128i256((__v4di)(__m256i)(V1), \ + (__v2di)(__m128i)(V2), (int)(M))) + +/// Conditionally loads eight 32-bit integer elements from memory \a __X, if +/// the most significant bit of the corresponding element in the mask +/// \a __M is set; otherwise, sets that element of the result to zero. +/// Returns the 256-bit [8 x i32] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// IF __M[j+31] == 1 +/// result[j+31:j] := Load32(__X+(i*4)) +/// ELSE +/// result[j+31:j] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVD instruction. +/// +/// \param __X +/// A pointer to the memory used for loading values. +/// \param __M +/// A 256-bit vector of [8 x i32] containing the mask bits. +/// \returns A 256-bit vector of [8 x i32] containing the loaded or zeroed +/// elements. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskload_epi32(int const *__X, __m256i __M) +{ + return (__m256i)__builtin_ia32_maskloadd256((const __v8si *)__X, (__v8si)__M); +} + +/// Conditionally loads four 64-bit integer elements from memory \a __X, if +/// the most significant bit of the corresponding element in the mask +/// \a __M is set; otherwise, sets that element of the result to zero. +/// Returns the 256-bit [4 x i64] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// IF __M[j+63] == 1 +/// result[j+63:j] := Load64(__X+(i*8)) +/// ELSE +/// result[j+63:j] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVQ instruction. +/// +/// \param __X +/// A pointer to the memory used for loading values. +/// \param __M +/// A 256-bit vector of [4 x i64] containing the mask bits. +/// \returns A 256-bit vector of [4 x i64] containing the loaded or zeroed +/// elements. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskload_epi64(long long const *__X, __m256i __M) +{ + return (__m256i)__builtin_ia32_maskloadq256((const __v4di *)__X, (__v4di)__M); +} + +/// Conditionally loads four 32-bit integer elements from memory \a __X, if +/// the most significant bit of the corresponding element in the mask +/// \a __M is set; otherwise, sets that element of the result to zero. +/// Returns the 128-bit [4 x i32] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*32 +/// IF __M[j+31] == 1 +/// result[j+31:j] := Load32(__X+(i*4)) +/// ELSE +/// result[j+31:j] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVD instruction. +/// +/// \param __X +/// A pointer to the memory used for loading values. +/// \param __M +/// A 128-bit vector of [4 x i32] containing the mask bits. +/// \returns A 128-bit vector of [4 x i32] containing the loaded or zeroed +/// elements. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskload_epi32(int const *__X, __m128i __M) +{ + return (__m128i)__builtin_ia32_maskloadd((const __v4si *)__X, (__v4si)__M); +} + +/// Conditionally loads two 64-bit integer elements from memory \a __X, if +/// the most significant bit of the corresponding element in the mask +/// \a __M is set; otherwise, sets that element of the result to zero. +/// Returns the 128-bit [2 x i64] result. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*64 +/// IF __M[j+63] == 1 +/// result[j+63:j] := Load64(__X+(i*8)) +/// ELSE +/// result[j+63:j] := 0 +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVQ instruction. +/// +/// \param __X +/// A pointer to the memory used for loading values. +/// \param __M +/// A 128-bit vector of [2 x i64] containing the mask bits. +/// \returns A 128-bit vector of [2 x i64] containing the loaded or zeroed +/// elements. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskload_epi64(long long const *__X, __m128i __M) +{ + return (__m128i)__builtin_ia32_maskloadq((const __v2di *)__X, (__v2di)__M); +} + +/// Conditionally stores eight 32-bit integer elements from the 256-bit vector +/// of [8 x i32] in \a __Y to memory \a __X, if the most significant bit of +/// the corresponding element in the mask \a __M is set; otherwise, the +/// memory element is unchanged. +/// +/// \code{.operation} +/// FOR i := 0 TO 7 +/// j := i*32 +/// IF __M[j+31] == 1 +/// Store32(__X+(i*4), __Y[j+31:j]) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVD instruction. +/// +/// \param __X +/// A pointer to the memory used for storing values. +/// \param __M +/// A 256-bit vector of [8 x i32] containing the mask bits. +/// \param __Y +/// A 256-bit vector of [8 x i32] containing the values to store. +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_maskstore_epi32(int *__X, __m256i __M, __m256i __Y) +{ + __builtin_ia32_maskstored256((__v8si *)__X, (__v8si)__M, (__v8si)__Y); +} + +/// Conditionally stores four 64-bit integer elements from the 256-bit vector +/// of [4 x i64] in \a __Y to memory \a __X, if the most significant bit of +/// the corresponding element in the mask \a __M is set; otherwise, the +/// memory element is unchanged. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*64 +/// IF __M[j+63] == 1 +/// Store64(__X+(i*8), __Y[j+63:j]) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVQ instruction. +/// +/// \param __X +/// A pointer to the memory used for storing values. +/// \param __M +/// A 256-bit vector of [4 x i64] containing the mask bits. +/// \param __Y +/// A 256-bit vector of [4 x i64] containing the values to store. +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_maskstore_epi64(long long *__X, __m256i __M, __m256i __Y) +{ + __builtin_ia32_maskstoreq256((__v4di *)__X, (__v4di)__M, (__v4di)__Y); +} + +/// Conditionally stores four 32-bit integer elements from the 128-bit vector +/// of [4 x i32] in \a __Y to memory \a __X, if the most significant bit of +/// the corresponding element in the mask \a __M is set; otherwise, the +/// memory element is unchanged. +/// +/// \code{.operation} +/// FOR i := 0 TO 3 +/// j := i*32 +/// IF __M[j+31] == 1 +/// Store32(__X+(i*4), __Y[j+31:j]) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVD instruction. +/// +/// \param __X +/// A pointer to the memory used for storing values. +/// \param __M +/// A 128-bit vector of [4 x i32] containing the mask bits. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing the values to store. +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_maskstore_epi32(int *__X, __m128i __M, __m128i __Y) +{ + __builtin_ia32_maskstored((__v4si *)__X, (__v4si)__M, (__v4si)__Y); +} + +/// Conditionally stores two 64-bit integer elements from the 128-bit vector +/// of [2 x i64] in \a __Y to memory \a __X, if the most significant bit of +/// the corresponding element in the mask \a __M is set; otherwise, the +/// memory element is unchanged. +/// +/// \code{.operation} +/// FOR i := 0 TO 1 +/// j := i*64 +/// IF __M[j+63] == 1 +/// Store64(__X+(i*8), __Y[j+63:j]) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMASKMOVQ instruction. +/// +/// \param __X +/// A pointer to the memory used for storing values. +/// \param __M +/// A 128-bit vector of [2 x i64] containing the mask bits. +/// \param __Y +/// A 128-bit vector of [2 x i64] containing the values to store. +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_maskstore_epi64(long long *__X, __m128i __M, __m128i __Y) +{ + __builtin_ia32_maskstoreq(( __v2di *)__X, (__v2di)__M, (__v2di)__Y); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X +/// left by the number of bits given in the corresponding element of the +/// 256-bit vector of [8 x i32] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 31, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLVD instruction. +/// +/// \param __X +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __Y +/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in +/// bits). +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sllv_epi32(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_psllv8si((__v8si)__X, (__v8si)__Y); +} + +/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X +/// left by the number of bits given in the corresponding element of the +/// 128-bit vector of [4 x i32] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 31, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLVD instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] to be shifted. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in +/// bits). +/// \returns A 128-bit vector of [4 x i32] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_sllv_epi32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_psllv4si((__v4si)__X, (__v4si)__Y); +} + +/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __X +/// left by the number of bits given in the corresponding element of the +/// 128-bit vector of [4 x i64] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 63, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLVQ instruction. +/// +/// \param __X +/// A 256-bit vector of [4 x i64] to be shifted. +/// \param __Y +/// A 256-bit vector of [4 x i64] containing the unsigned shift counts (in +/// bits). +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sllv_epi64(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_psllv4di((__v4di)__X, (__v4di)__Y); +} + +/// Shifts each 64-bit element of the 128-bit vector of [2 x i64] in \a __X +/// left by the number of bits given in the corresponding element of the +/// 128-bit vector of [2 x i64] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 63, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSLLVQ instruction. +/// +/// \param __X +/// A 128-bit vector of [2 x i64] to be shifted. +/// \param __Y +/// A 128-bit vector of [2 x i64] containing the unsigned shift counts (in +/// bits). +/// \returns A 128-bit vector of [2 x i64] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_sllv_epi64(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_psllv2di((__v2di)__X, (__v2di)__Y); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X +/// right by the number of bits given in the corresponding element of the +/// 256-bit vector of [8 x i32] in \a __Y, shifting in sign bits, and +/// returns the result. If the shift count for any element is greater than +/// 31, the result for that element is 0 or -1 according to the sign bit +/// for that element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRAVD instruction. +/// +/// \param __X +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __Y +/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in +/// bits). +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srav_epi32(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_psrav8si((__v8si)__X, (__v8si)__Y); +} + +/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X +/// right by the number of bits given in the corresponding element of the +/// 128-bit vector of [4 x i32] in \a __Y, shifting in sign bits, and +/// returns the result. If the shift count for any element is greater than +/// 31, the result for that element is 0 or -1 according to the sign bit +/// for that element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRAVD instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] to be shifted. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in +/// bits). +/// \returns A 128-bit vector of [4 x i32] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srav_epi32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_psrav4si((__v4si)__X, (__v4si)__Y); +} + +/// Shifts each 32-bit element of the 256-bit vector of [8 x i32] in \a __X +/// right by the number of bits given in the corresponding element of the +/// 256-bit vector of [8 x i32] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 31, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLVD instruction. +/// +/// \param __X +/// A 256-bit vector of [8 x i32] to be shifted. +/// \param __Y +/// A 256-bit vector of [8 x i32] containing the unsigned shift counts (in +/// bits). +/// \returns A 256-bit vector of [8 x i32] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srlv_epi32(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_psrlv8si((__v8si)__X, (__v8si)__Y); +} + +/// Shifts each 32-bit element of the 128-bit vector of [4 x i32] in \a __X +/// right by the number of bits given in the corresponding element of the +/// 128-bit vector of [4 x i32] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 31, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLVD instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] to be shifted. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing the unsigned shift counts (in +/// bits). +/// \returns A 128-bit vector of [4 x i32] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srlv_epi32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_psrlv4si((__v4si)__X, (__v4si)__Y); +} + +/// Shifts each 64-bit element of the 256-bit vector of [4 x i64] in \a __X +/// right by the number of bits given in the corresponding element of the +/// 128-bit vector of [4 x i64] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 63, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLVQ instruction. +/// +/// \param __X +/// A 256-bit vector of [4 x i64] to be shifted. +/// \param __Y +/// A 256-bit vector of [4 x i64] containing the unsigned shift counts (in +/// bits). +/// \returns A 256-bit vector of [4 x i64] containing the result. +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srlv_epi64(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_psrlv4di((__v4di)__X, (__v4di)__Y); +} + +/// Shifts each 64-bit element of the 128-bit vector of [2 x i64] in \a __X +/// right by the number of bits given in the corresponding element of the +/// 128-bit vector of [2 x i64] in \a __Y, shifting in zero bits, and +/// returns the result. If the shift count for any element is greater than +/// 63, the result for that element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSRLVQ instruction. +/// +/// \param __X +/// A 128-bit vector of [2 x i64] to be shifted. +/// \param __Y +/// A 128-bit vector of [2 x i64] containing the unsigned shift counts (in +/// bits). +/// \returns A 128-bit vector of [2 x i64] containing the result. +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srlv_epi64(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_psrlv2di((__v2di)__X, (__v2di)__Y); +} + +/// Conditionally gathers two 64-bit floating-point values, either from the +/// 128-bit vector of [2 x double] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector +/// of [2 x double] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*32 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_mask_i32gather_pd(__m128d a, const double *m, __m128i i, +/// __m128d mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only +/// the first two elements are used. +/// \param mask +/// A 128-bit vector of [2 x double] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x double] containing the gathered values. +#define _mm_mask_i32gather_pd(a, m, i, mask, s) \ + ((__m128d)__builtin_ia32_gatherd_pd((__v2df)(__m128i)(a), \ + (double const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v2df)(__m128d)(mask), (s))) + +/// Conditionally gathers four 64-bit floating-point values, either from the +/// 256-bit vector of [4 x double] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector +/// of [4 x double] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*32 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_mask_i32gather_pd(__m256d a, const double *m, __m128i i, +/// __m256d mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPD instruction. +/// +/// \param a +/// A 256-bit vector of [4 x double] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param mask +/// A 256-bit vector of [4 x double] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x double] containing the gathered values. +#define _mm256_mask_i32gather_pd(a, m, i, mask, s) \ + ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)(__m256d)(a), \ + (double const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4df)(__m256d)(mask), (s))) + +/// Conditionally gathers two 64-bit floating-point values, either from the +/// 128-bit vector of [2 x double] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector +/// of [2 x double] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*64 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_mask_i64gather_pd(__m128d a, const double *m, __m128i i, +/// __m128d mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [2 x double] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x double] containing the gathered values. +#define _mm_mask_i64gather_pd(a, m, i, mask, s) \ + ((__m128d)__builtin_ia32_gatherq_pd((__v2df)(__m128d)(a), \ + (double const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v2df)(__m128d)(mask), (s))) + +/// Conditionally gathers four 64-bit floating-point values, either from the +/// 256-bit vector of [4 x double] in \a a, or from memory \a m using scaled +/// indexes from the 256-bit vector of [4 x i64] in \a i. The 256-bit vector +/// of [4 x double] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*64 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_mask_i64gather_pd(__m256d a, const double *m, __m256i i, +/// __m256d mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPD instruction. +/// +/// \param a +/// A 256-bit vector of [4 x double] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param mask +/// A 256-bit vector of [4 x double] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x double] containing the gathered values. +#define _mm256_mask_i64gather_pd(a, m, i, mask, s) \ + ((__m256d)__builtin_ia32_gatherq_pd256((__v4df)(__m256d)(a), \ + (double const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4df)(__m256d)(mask), (s))) + +/// Conditionally gathers four 32-bit floating-point values, either from the +/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector +/// of [4 x float] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*32 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_mask_i32gather_ps(__m128 a, const float *m, __m128i i, +/// __m128 mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [4 x float] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x float] containing the gathered values. +#define _mm_mask_i32gather_ps(a, m, i, mask, s) \ + ((__m128)__builtin_ia32_gatherd_ps((__v4sf)(__m128)(a), \ + (float const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4sf)(__m128)(mask), (s))) + +/// Conditionally gathers eight 32-bit floating-point values, either from the +/// 256-bit vector of [8 x float] in \a a, or from memory \a m using scaled +/// indexes from the 256-bit vector of [8 x i32] in \a i. The 256-bit vector +/// of [8 x float] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 7 +/// j := element*32 +/// k := element*32 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_mask_i32gather_ps(__m256 a, const float *m, __m256i i, +/// __m256 mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPS instruction. +/// +/// \param a +/// A 256-bit vector of [8 x float] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [8 x i32] containing signed indexes into \a m. +/// \param mask +/// A 256-bit vector of [8 x float] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [8 x float] containing the gathered values. +#define _mm256_mask_i32gather_ps(a, m, i, mask, s) \ + ((__m256)__builtin_ia32_gatherd_ps256((__v8sf)(__m256)(a), \ + (float const *)(m), \ + (__v8si)(__m256i)(i), \ + (__v8sf)(__m256)(mask), (s))) + +/// Conditionally gathers two 32-bit floating-point values, either from the +/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector +/// of [4 x float] in \a mask determines the source for the lower two +/// elements. The upper two elements of the result are zeroed. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*32 +/// k := element*64 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// result[127:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_mask_i64gather_ps(__m128 a, const float *m, __m128i i, +/// __m128 mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float] used as the source when a mask bit is +/// zero. Only the first two elements are used. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [4 x float] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. Only the first +/// two elements are used. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x float] containing the gathered values. +#define _mm_mask_i64gather_ps(a, m, i, mask, s) \ + ((__m128)__builtin_ia32_gatherq_ps((__v4sf)(__m128)(a), \ + (float const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v4sf)(__m128)(mask), (s))) + +/// Conditionally gathers four 32-bit floating-point values, either from the +/// 128-bit vector of [4 x float] in \a a, or from memory \a m using scaled +/// indexes from the 256-bit vector of [4 x i64] in \a i. The 128-bit vector +/// of [4 x float] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*64 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128 _mm256_mask_i64gather_ps(__m128 a, const float *m, __m256i i, +/// __m128 mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [4 x float] containing the mask. The most +/// significant bit of each element in the mask vector represents the mask +/// bits. If a mask bit is zero, the corresponding value from vector \a a +/// is gathered; otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x float] containing the gathered values. +#define _mm256_mask_i64gather_ps(a, m, i, mask, s) \ + ((__m128)__builtin_ia32_gatherq_ps256((__v4sf)(__m128)(a), \ + (float const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4sf)(__m128)(mask), (s))) + +/// Conditionally gathers four 32-bit integer values, either from the +/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector +/// of [4 x i32] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*32 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_mask_i32gather_epi32(__m128i a, const int *m, __m128i i, +/// __m128i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDD instruction. +/// +/// \param a +/// A 128-bit vector of [4 x i32] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [4 x i32] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x i32] containing the gathered values. +#define _mm_mask_i32gather_epi32(a, m, i, mask, s) \ + ((__m128i)__builtin_ia32_gatherd_d((__v4si)(__m128i)(a), \ + (int const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4si)(__m128i)(mask), (s))) + +/// Conditionally gathers eight 32-bit integer values, either from the +/// 256-bit vector of [8 x i32] in \a a, or from memory \a m using scaled +/// indexes from the 256-bit vector of [8 x i32] in \a i. The 256-bit vector +/// of [8 x i32] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 7 +/// j := element*32 +/// k := element*32 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_mask_i32gather_epi32(__m256i a, const int *m, __m256i i, +/// __m256i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDD instruction. +/// +/// \param a +/// A 256-bit vector of [8 x i32] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [8 x i32] containing signed indexes into \a m. +/// \param mask +/// A 256-bit vector of [8 x i32] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [8 x i32] containing the gathered values. +#define _mm256_mask_i32gather_epi32(a, m, i, mask, s) \ + ((__m256i)__builtin_ia32_gatherd_d256((__v8si)(__m256i)(a), \ + (int const *)(m), \ + (__v8si)(__m256i)(i), \ + (__v8si)(__m256i)(mask), (s))) + +/// Conditionally gathers two 32-bit integer values, either from the +/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector +/// of [4 x i32] in \a mask determines the source for the lower two +/// elements. The upper two elements of the result are zeroed. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*32 +/// k := element*64 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// result[127:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_mask_i64gather_epi32(__m128i a, const int *m, __m128i i, +/// __m128i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQD instruction. +/// +/// \param a +/// A 128-bit vector of [4 x i32] used as the source when a mask bit is +/// zero. Only the first two elements are used. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing indexes into \a m. +/// \param mask +/// A 128-bit vector of [4 x i32] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. Only the first two elements +/// are used. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x i32] containing the gathered values. +#define _mm_mask_i64gather_epi32(a, m, i, mask, s) \ + ((__m128i)__builtin_ia32_gatherq_d((__v4si)(__m128i)(a), \ + (int const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v4si)(__m128i)(mask), (s))) + +/// Conditionally gathers four 32-bit integer values, either from the +/// 128-bit vector of [4 x i32] in \a a, or from memory \a m using scaled +/// indexes from the 256-bit vector of [4 x i64] in \a i. The 128-bit vector +/// of [4 x i32] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*64 +/// IF mask[j+31] == 0 +/// result[j+31:j] := a[j+31:j] +/// ELSE +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm256_mask_i64gather_epi32(__m128i a, const int *m, __m256i i, +/// __m128i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQD instruction. +/// +/// \param a +/// A 128-bit vector of [4 x i32] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [4 x i32] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x i32] containing the gathered values. +#define _mm256_mask_i64gather_epi32(a, m, i, mask, s) \ + ((__m128i)__builtin_ia32_gatherq_d256((__v4si)(__m128i)(a), \ + (int const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4si)(__m128i)(mask), (s))) + +/// Conditionally gathers two 64-bit integer values, either from the +/// 128-bit vector of [2 x i64] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector +/// of [2 x i64] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*32 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_mask_i32gather_epi64(__m128i a, const long long *m, __m128i i, +/// __m128i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDQ instruction. +/// +/// \param a +/// A 128-bit vector of [2 x i64] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only +/// the first two elements are used. +/// \param mask +/// A 128-bit vector of [2 x i64] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x i64] containing the gathered values. +#define _mm_mask_i32gather_epi64(a, m, i, mask, s) \ + ((__m128i)__builtin_ia32_gatherd_q((__v2di)(__m128i)(a), \ + (long long const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v2di)(__m128i)(mask), (s))) + +/// Conditionally gathers four 64-bit integer values, either from the +/// 256-bit vector of [4 x i64] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector +/// of [4 x i64] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*32 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_mask_i32gather_epi64(__m256i a, const long long *m, +/// __m128i i, __m256i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDQ instruction. +/// +/// \param a +/// A 256-bit vector of [4 x i64] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param mask +/// A 256-bit vector of [4 x i64] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x i64] containing the gathered values. +#define _mm256_mask_i32gather_epi64(a, m, i, mask, s) \ + ((__m256i)__builtin_ia32_gatherd_q256((__v4di)(__m256i)(a), \ + (long long const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4di)(__m256i)(mask), (s))) + +/// Conditionally gathers two 64-bit integer values, either from the +/// 128-bit vector of [2 x i64] in \a a, or from memory \a m using scaled +/// indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector +/// of [2 x i64] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*64 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_mask_i64gather_epi64(__m128i a, const long long *m, __m128i i, +/// __m128i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQQ instruction. +/// +/// \param a +/// A 128-bit vector of [2 x i64] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param mask +/// A 128-bit vector of [2 x i64] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x i64] containing the gathered values. +#define _mm_mask_i64gather_epi64(a, m, i, mask, s) \ + ((__m128i)__builtin_ia32_gatherq_q((__v2di)(__m128i)(a), \ + (long long const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v2di)(__m128i)(mask), (s))) + +/// Conditionally gathers four 64-bit integer values, either from the +/// 256-bit vector of [4 x i64] in \a a, or from memory \a m using scaled +/// indexes from the 256-bit vector of [4 x i64] in \a i. The 256-bit vector +/// of [4 x i64] in \a mask determines the source for each element. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*64 +/// IF mask[j+63] == 0 +/// result[j+63:j] := a[j+63:j] +/// ELSE +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// FI +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_mask_i64gather_epi64(__m256i a, const long long *m, +/// __m256i i, __m256i mask, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQQ instruction. +/// +/// \param a +/// A 256-bit vector of [4 x i64] used as the source when a mask bit is +/// zero. +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param mask +/// A 256-bit vector of [4 x i64] containing the mask. The most significant +/// bit of each element in the mask vector represents the mask bits. If a +/// mask bit is zero, the corresponding value from vector \a a is gathered; +/// otherwise the value is loaded from memory. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x i64] containing the gathered values. +#define _mm256_mask_i64gather_epi64(a, m, i, mask, s) \ + ((__m256i)__builtin_ia32_gatherq_q256((__v4di)(__m256i)(a), \ + (long long const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4di)(__m256i)(mask), (s))) + +/// Gathers two 64-bit floating-point values from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*32 +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_i32gather_pd(const double *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only +/// the first two elements are used. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x double] containing the gathered values. +#define _mm_i32gather_pd(m, i, s) \ + ((__m128d)__builtin_ia32_gatherd_pd((__v2df)_mm_undefined_pd(), \ + (double const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v2df)_mm_cmpeq_pd(_mm_setzero_pd(), \ + _mm_setzero_pd()), \ + (s))) + +/// Gathers four 64-bit floating-point values from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*32 +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_i32gather_pd(const double *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x double] containing the gathered values. +#define _mm256_i32gather_pd(m, i, s) \ + ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)_mm256_undefined_pd(), \ + (double const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4df)_mm256_cmp_pd(_mm256_setzero_pd(), \ + _mm256_setzero_pd(), \ + _CMP_EQ_OQ), \ + (s))) + +/// Gathers two 64-bit floating-point values from memory \a m using scaled +/// indexes from the 128-bit vector of [2 x i64] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*64 +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_i64gather_pd(const double *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x double] containing the gathered values. +#define _mm_i64gather_pd(m, i, s) \ + ((__m128d)__builtin_ia32_gatherq_pd((__v2df)_mm_undefined_pd(), \ + (double const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v2df)_mm_cmpeq_pd(_mm_setzero_pd(), \ + _mm_setzero_pd()), \ + (s))) + +/// Gathers four 64-bit floating-point values from memory \a m using scaled +/// indexes from the 256-bit vector of [4 x i64] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*64 +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_i64gather_pd(const double *m, __m256i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x double] containing the gathered values. +#define _mm256_i64gather_pd(m, i, s) \ + ((__m256d)__builtin_ia32_gatherq_pd256((__v4df)_mm256_undefined_pd(), \ + (double const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4df)_mm256_cmp_pd(_mm256_setzero_pd(), \ + _mm256_setzero_pd(), \ + _CMP_EQ_OQ), \ + (s))) + +/// Gathers four 32-bit floating-point values from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*32 +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_i32gather_ps(const float *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPS instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x float] containing the gathered values. +#define _mm_i32gather_ps(m, i, s) \ + ((__m128)__builtin_ia32_gatherd_ps((__v4sf)_mm_undefined_ps(), \ + (float const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \ + _mm_setzero_ps()), \ + (s))) + +/// Gathers eight 32-bit floating-point values from memory \a m using scaled +/// indexes from the 256-bit vector of [8 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 7 +/// j := element*32 +/// k := element*32 +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_i32gather_ps(const float *m, __m256i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERDPS instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [8 x i32] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [8 x float] containing the gathered values. +#define _mm256_i32gather_ps(m, i, s) \ + ((__m256)__builtin_ia32_gatherd_ps256((__v8sf)_mm256_undefined_ps(), \ + (float const *)(m), \ + (__v8si)(__m256i)(i), \ + (__v8sf)_mm256_cmp_ps(_mm256_setzero_ps(), \ + _mm256_setzero_ps(), \ + _CMP_EQ_OQ), \ + (s))) + +/// Gathers two 32-bit floating-point values from memory \a m using scaled +/// indexes from the 128-bit vector of [2 x i64] in \a i. The upper two +/// elements of the result are zeroed. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*32 +/// k := element*64 +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// result[127:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_i64gather_ps(const float *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPS instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x float] containing the gathered values. +#define _mm_i64gather_ps(m, i, s) \ + ((__m128)__builtin_ia32_gatherq_ps((__v4sf)_mm_undefined_ps(), \ + (float const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \ + _mm_setzero_ps()), \ + (s))) + +/// Gathers four 32-bit floating-point values from memory \a m using scaled +/// indexes from the 256-bit vector of [4 x i64] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*64 +/// result[j+31:j] := Load32(m + SignExtend(i[k+64:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128 _mm256_i64gather_ps(const float *m, __m256i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VGATHERQPS instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x float] containing the gathered values. +#define _mm256_i64gather_ps(m, i, s) \ + ((__m128)__builtin_ia32_gatherq_ps256((__v4sf)_mm_undefined_ps(), \ + (float const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4sf)_mm_cmpeq_ps(_mm_setzero_ps(), \ + _mm_setzero_ps()), \ + (s))) + +/// Gathers four 32-bit floating-point values from memory \a m using scaled +/// indexes from the 128-bit vector of [4 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*32 +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_i32gather_epi32(const int *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x i32] containing the gathered values. +#define _mm_i32gather_epi32(m, i, s) \ + ((__m128i)__builtin_ia32_gatherd_d((__v4si)_mm_undefined_si128(), \ + (int const *)(m), (__v4si)(__m128i)(i), \ + (__v4si)_mm_set1_epi32(-1), (s))) + +/// Gathers eight 32-bit floating-point values from memory \a m using scaled +/// indexes from the 256-bit vector of [8 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 7 +/// j := element*32 +/// k := element*32 +/// result[j+31:j] := Load32(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_i32gather_epi32(const int *m, __m256i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [8 x i32] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [8 x i32] containing the gathered values. +#define _mm256_i32gather_epi32(m, i, s) \ + ((__m256i)__builtin_ia32_gatherd_d256((__v8si)_mm256_undefined_si256(), \ + (int const *)(m), (__v8si)(__m256i)(i), \ + (__v8si)_mm256_set1_epi32(-1), (s))) + +/// Gathers two 32-bit integer values from memory \a m using scaled indexes +/// from the 128-bit vector of [2 x i64] in \a i. The upper two elements +/// of the result are zeroed. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*32 +/// k := element*64 +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// result[127:64] := 0 +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_i64gather_epi32(const int *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x i32] containing the gathered values. +#define _mm_i64gather_epi32(m, i, s) \ + ((__m128i)__builtin_ia32_gatherq_d((__v4si)_mm_undefined_si128(), \ + (int const *)(m), (__v2di)(__m128i)(i), \ + (__v4si)_mm_set1_epi32(-1), (s))) + +/// Gathers four 32-bit integer values from memory \a m using scaled indexes +/// from the 256-bit vector of [4 x i64] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*32 +/// k := element*64 +/// result[j+31:j] := Load32(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm256_i64gather_epi32(const int *m, __m256i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQD instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [4 x i32] containing the gathered values. +#define _mm256_i64gather_epi32(m, i, s) \ + ((__m128i)__builtin_ia32_gatherq_d256((__v4si)_mm_undefined_si128(), \ + (int const *)(m), (__v4di)(__m256i)(i), \ + (__v4si)_mm_set1_epi32(-1), (s))) + +/// Gathers two 64-bit integer values from memory \a m using scaled indexes +/// from the 128-bit vector of [4 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*32 +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_i32gather_epi64(const long long *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDQ instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only +/// the first two elements are used. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x i64] containing the gathered values. +#define _mm_i32gather_epi64(m, i, s) \ + ((__m128i)__builtin_ia32_gatherd_q((__v2di)_mm_undefined_si128(), \ + (long long const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v2di)_mm_set1_epi64x(-1), (s))) + +/// Gathers four 64-bit integer values from memory \a m using scaled indexes +/// from the 128-bit vector of [4 x i32] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*32 +/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_i32gather_epi64(const long long *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERDQ instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [4 x i32] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x i64] containing the gathered values. +#define _mm256_i32gather_epi64(m, i, s) \ + ((__m256i)__builtin_ia32_gatherd_q256((__v4di)_mm256_undefined_si256(), \ + (long long const *)(m), \ + (__v4si)(__m128i)(i), \ + (__v4di)_mm256_set1_epi64x(-1), (s))) + +/// Gathers two 64-bit integer values from memory \a m using scaled indexes +/// from the 128-bit vector of [2 x i64] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 1 +/// j := element*64 +/// k := element*64 +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_i64gather_epi64(const long long *m, __m128i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQQ instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 128-bit vector of [2 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 128-bit vector of [2 x i64] containing the gathered values. +#define _mm_i64gather_epi64(m, i, s) \ + ((__m128i)__builtin_ia32_gatherq_q((__v2di)_mm_undefined_si128(), \ + (long long const *)(m), \ + (__v2di)(__m128i)(i), \ + (__v2di)_mm_set1_epi64x(-1), (s))) + +/// Gathers four 64-bit integer values from memory \a m using scaled indexes +/// from the 256-bit vector of [4 x i64] in \a i. +/// +/// \code{.operation} +/// FOR element := 0 to 3 +/// j := element*64 +/// k := element*64 +/// result[j+63:j] := Load64(m + SignExtend(i[k+63:k])*s) +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_i64gather_epi64(const long long *m, __m256i i, const int s); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPGATHERQQ instruction. +/// +/// \param m +/// A pointer to the memory used for loading values. +/// \param i +/// A 256-bit vector of [4 x i64] containing signed indexes into \a m. +/// \param s +/// A literal constant scale factor for the indexes in \a i. Must be +/// 1, 2, 4, or 8. +/// \returns A 256-bit vector of [4 x i64] containing the gathered values. +#define _mm256_i64gather_epi64(m, i, s) \ + ((__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_undefined_si256(), \ + (long long const *)(m), \ + (__v4di)(__m256i)(i), \ + (__v4di)_mm256_set1_epi64x(-1), (s))) + +#undef __DEFAULT_FN_ATTRS256 +#undef __DEFAULT_FN_ATTRS128 + +#endif /* __AVX2INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bf16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bf16intrin.h new file mode 100755 index 0000000..b28d2e2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bf16intrin.h @@ -0,0 +1,283 @@ +/*===------------ avx512bf16intrin.h - AVX512_BF16 intrinsics --------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX512BF16INTRIN_H +#define __AVX512BF16INTRIN_H + +typedef __bf16 __v32bf __attribute__((__vector_size__(64), __aligned__(64))); +typedef __bf16 __m512bh __attribute__((__vector_size__(64), __aligned__(64))); +typedef __bf16 __bfloat16 __attribute__((deprecated("use __bf16 instead"))); + +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx512bf16,evex512"), \ + __min_vector_width__(512))) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bf16,no-evex512"))) + +/// Convert One BF16 Data to One Single Float Data. +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a specific instruction. +/// +/// \param __A +/// A bfloat data. +/// \returns A float data whose sign field and exponent field keep unchanged, +/// and fraction field is extended to 23 bits. +static __inline__ float __DEFAULT_FN_ATTRS _mm_cvtsbh_ss(__bf16 __A) { + return __builtin_ia32_cvtsbf162ss_32(__A); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 512-bit vector of [16 x float]. +/// \param __B +/// A 512-bit vector of [16 x float]. +/// \returns A 512-bit vector of [32 x bfloat] whose lower 256 bits come from +/// conversion of __B, and higher 256 bits come from conversion of __A. +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_cvtne2ps_pbh(__m512 __A, __m512 __B) { + return (__m512bh)__builtin_ia32_cvtne2ps2bf16_512((__v16sf) __A, + (__v16sf) __B); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 512-bit vector of [16 x float]. +/// \param __B +/// A 512-bit vector of [16 x float]. +/// \param __W +/// A 512-bit vector of [32 x bfloat]. +/// \param __U +/// A 32-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A or __B. A 0 means element from __W. +/// \returns A 512-bit vector of [32 x bfloat] whose lower 256 bits come from +/// conversion of __B, and higher 256 bits come from conversion of __A. +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtne2ps_pbh(__m512bh __W, __mmask32 __U, __m512 __A, __m512 __B) { + return (__m512bh)__builtin_ia32_selectpbf_512((__mmask32)__U, + (__v32bf)_mm512_cvtne2ps_pbh(__A, __B), + (__v32bf)__W); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 512-bit vector of [16 x float]. +/// \param __B +/// A 512-bit vector of [16 x float]. +/// \param __U +/// A 32-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A or __B. A 0 means element is zero. +/// \returns A 512-bit vector of [32 x bfloat] whose lower 256 bits come from +/// conversion of __B, and higher 256 bits come from conversion of __A. +static __inline__ __m512bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtne2ps_pbh(__mmask32 __U, __m512 __A, __m512 __B) { + return (__m512bh)__builtin_ia32_selectpbf_512((__mmask32)__U, + (__v32bf)_mm512_cvtne2ps_pbh(__A, __B), + (__v32bf)_mm512_setzero_si512()); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 512-bit vector of [16 x float]. +/// \returns A 256-bit vector of [16 x bfloat] come from conversion of __A. +static __inline__ __m256bh __DEFAULT_FN_ATTRS512 +_mm512_cvtneps_pbh(__m512 __A) { + return (__m256bh)__builtin_ia32_cvtneps2bf16_512_mask((__v16sf)__A, + (__v16bf)_mm256_undefined_si256(), + (__mmask16)-1); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 512-bit vector of [16 x float]. +/// \param __W +/// A 256-bit vector of [16 x bfloat]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A. A 0 means element from __W. +/// \returns A 256-bit vector of [16 x bfloat] come from conversion of __A. +static __inline__ __m256bh __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtneps_pbh(__m256bh __W, __mmask16 __U, __m512 __A) { + return (__m256bh)__builtin_ia32_cvtneps2bf16_512_mask((__v16sf)__A, + (__v16bf)__W, + (__mmask16)__U); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 512-bit vector of [16 x float]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A. A 0 means element is zero. +/// \returns A 256-bit vector of [16 x bfloat] come from conversion of __A. +static __inline__ __m256bh __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtneps_pbh(__mmask16 __U, __m512 __A) { + return (__m256bh)__builtin_ia32_cvtneps2bf16_512_mask((__v16sf)__A, + (__v16bf)_mm256_setzero_si256(), + (__mmask16)__U); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 512-bit vector of [32 x bfloat]. +/// \param __B +/// A 512-bit vector of [32 x bfloat]. +/// \param __D +/// A 512-bit vector of [16 x float]. +/// \returns A 512-bit vector of [16 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_dpbf16_ps(__m512 __D, __m512bh __A, __m512bh __B) { + return (__m512)__builtin_ia32_dpbf16ps_512((__v16sf) __D, + (__v32bf) __A, + (__v32bf) __B); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 512-bit vector of [32 x bfloat]. +/// \param __B +/// A 512-bit vector of [32 x bfloat]. +/// \param __D +/// A 512-bit vector of [16 x float]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means __A and __B's dot product accumulated with __D. A 0 means __D. +/// \returns A 512-bit vector of [16 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_dpbf16_ps(__m512 __D, __mmask16 __U, __m512bh __A, __m512bh __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_dpbf16_ps(__D, __A, __B), + (__v16sf)__D); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 512-bit vector of [32 x bfloat]. +/// \param __B +/// A 512-bit vector of [32 x bfloat]. +/// \param __D +/// A 512-bit vector of [16 x float]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means __A and __B's dot product accumulated with __D. A 0 means 0. +/// \returns A 512-bit vector of [16 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_dpbf16_ps(__mmask16 __U, __m512 __D, __m512bh __A, __m512bh __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_dpbf16_ps(__D, __A, __B), + (__v16sf)_mm512_setzero_si512()); +} + +/// Convert Packed BF16 Data to Packed float Data. +/// +/// \headerfile +/// +/// \param __A +/// A 256-bit vector of [16 x bfloat]. +/// \returns A 512-bit vector of [16 x float] come from conversion of __A +static __inline__ __m512 __DEFAULT_FN_ATTRS512 _mm512_cvtpbh_ps(__m256bh __A) { + return _mm512_castsi512_ps((__m512i)_mm512_slli_epi32( + (__m512i)_mm512_cvtepi16_epi32((__m256i)__A), 16)); +} + +/// Convert Packed BF16 Data to Packed float Data using zeroing mask. +/// +/// \headerfile +/// +/// \param __U +/// A 16-bit mask. Elements are zeroed out when the corresponding mask +/// bit is not set. +/// \param __A +/// A 256-bit vector of [16 x bfloat]. +/// \returns A 512-bit vector of [16 x float] come from conversion of __A +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpbh_ps(__mmask16 __U, __m256bh __A) { + return _mm512_castsi512_ps((__m512i)_mm512_slli_epi32( + (__m512i)_mm512_maskz_cvtepi16_epi32((__mmask16)__U, (__m256i)__A), 16)); +} + +/// Convert Packed BF16 Data to Packed float Data using merging mask. +/// +/// \headerfile +/// +/// \param __S +/// A 512-bit vector of [16 x float]. Elements are copied from __S when +/// the corresponding mask bit is not set. +/// \param __U +/// A 16-bit mask. +/// \param __A +/// A 256-bit vector of [16 x bfloat]. +/// \returns A 512-bit vector of [16 x float] come from conversion of __A +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpbh_ps(__m512 __S, __mmask16 __U, __m256bh __A) { + return _mm512_castsi512_ps((__m512i)_mm512_mask_slli_epi32( + (__m512i)__S, (__mmask16)__U, + (__m512i)_mm512_cvtepi16_epi32((__m256i)__A), 16)); +} + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS512 + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bitalgintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bitalgintrin.h new file mode 100755 index 0000000..3c446b3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bitalgintrin.h @@ -0,0 +1,86 @@ +/*===------------- avx512bitalgintrin.h - BITALG intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512BITALGINTRIN_H +#define __AVX512BITALGINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bitalg,evex512"), \ + __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_popcnt_epi16(__m512i __A) +{ + return (__m512i)__builtin_elementwise_popcount((__v32hu)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_popcnt_epi16(__m512i __A, __mmask32 __U, __m512i __B) +{ + return (__m512i) __builtin_ia32_selectw_512((__mmask32) __U, + (__v32hi) _mm512_popcnt_epi16(__B), + (__v32hi) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_popcnt_epi16(__mmask32 __U, __m512i __B) +{ + return _mm512_mask_popcnt_epi16((__m512i) _mm512_setzero_si512(), + __U, + __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_popcnt_epi8(__m512i __A) +{ + return (__m512i)__builtin_elementwise_popcount((__v64qu)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_popcnt_epi8(__m512i __A, __mmask64 __U, __m512i __B) +{ + return (__m512i) __builtin_ia32_selectb_512((__mmask64) __U, + (__v64qi) _mm512_popcnt_epi8(__B), + (__v64qi) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_popcnt_epi8(__mmask64 __U, __m512i __B) +{ + return _mm512_mask_popcnt_epi8((__m512i) _mm512_setzero_si512(), + __U, + __B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS +_mm512_mask_bitshuffle_epi64_mask(__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__mmask64) __builtin_ia32_vpshufbitqmb512_mask((__v64qi) __A, + (__v64qi) __B, + __U); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS +_mm512_bitshuffle_epi64_mask(__m512i __A, __m512i __B) +{ + return _mm512_mask_bitshuffle_epi64_mask((__mmask64) -1, + __A, + __B); +} + + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bwintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bwintrin.h new file mode 100755 index 0000000..c854720 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512bwintrin.h @@ -0,0 +1,2014 @@ +/*===------------- avx512bwintrin.h - AVX512BW intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512BWINTRIN_H +#define __AVX512BWINTRIN_H + +typedef unsigned int __mmask32; +typedef unsigned long long __mmask64; + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,evex512"), __min_vector_width__(512))) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,no-evex512"))) + +static __inline __mmask32 __DEFAULT_FN_ATTRS +_knot_mask32(__mmask32 __M) +{ + return __builtin_ia32_knotsi(__M); +} + +static __inline __mmask64 __DEFAULT_FN_ATTRS _knot_mask64(__mmask64 __M) { + return __builtin_ia32_knotdi(__M); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_kand_mask32(__mmask32 __A, __mmask32 __B) +{ + return (__mmask32)__builtin_ia32_kandsi((__mmask32)__A, (__mmask32)__B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _kand_mask64(__mmask64 __A, + __mmask64 __B) { + return (__mmask64)__builtin_ia32_kanddi((__mmask64)__A, (__mmask64)__B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_kandn_mask32(__mmask32 __A, __mmask32 __B) +{ + return (__mmask32)__builtin_ia32_kandnsi((__mmask32)__A, (__mmask32)__B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _kandn_mask64(__mmask64 __A, + __mmask64 __B) { + return (__mmask64)__builtin_ia32_kandndi((__mmask64)__A, (__mmask64)__B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_kor_mask32(__mmask32 __A, __mmask32 __B) +{ + return (__mmask32)__builtin_ia32_korsi((__mmask32)__A, (__mmask32)__B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _kor_mask64(__mmask64 __A, + __mmask64 __B) { + return (__mmask64)__builtin_ia32_kordi((__mmask64)__A, (__mmask64)__B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_kxnor_mask32(__mmask32 __A, __mmask32 __B) +{ + return (__mmask32)__builtin_ia32_kxnorsi((__mmask32)__A, (__mmask32)__B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _kxnor_mask64(__mmask64 __A, + __mmask64 __B) { + return (__mmask64)__builtin_ia32_kxnordi((__mmask64)__A, (__mmask64)__B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_kxor_mask32(__mmask32 __A, __mmask32 __B) +{ + return (__mmask32)__builtin_ia32_kxorsi((__mmask32)__A, (__mmask32)__B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _kxor_mask64(__mmask64 __A, + __mmask64 __B) { + return (__mmask64)__builtin_ia32_kxordi((__mmask64)__A, (__mmask64)__B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestc_mask32_u8(__mmask32 __A, __mmask32 __B) +{ + return (unsigned char)__builtin_ia32_kortestcsi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestz_mask32_u8(__mmask32 __A, __mmask32 __B) +{ + return (unsigned char)__builtin_ia32_kortestzsi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortest_mask32_u8(__mmask32 __A, __mmask32 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_kortestcsi(__A, __B); + return (unsigned char)__builtin_ia32_kortestzsi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestc_mask64_u8(__mmask64 __A, __mmask64 __B) { + return (unsigned char)__builtin_ia32_kortestcdi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestz_mask64_u8(__mmask64 __A, __mmask64 __B) { + return (unsigned char)__builtin_ia32_kortestzdi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortest_mask64_u8(__mmask64 __A, __mmask64 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_kortestcdi(__A, __B); + return (unsigned char)__builtin_ia32_kortestzdi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestc_mask32_u8(__mmask32 __A, __mmask32 __B) +{ + return (unsigned char)__builtin_ia32_ktestcsi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestz_mask32_u8(__mmask32 __A, __mmask32 __B) +{ + return (unsigned char)__builtin_ia32_ktestzsi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktest_mask32_u8(__mmask32 __A, __mmask32 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_ktestcsi(__A, __B); + return (unsigned char)__builtin_ia32_ktestzsi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestc_mask64_u8(__mmask64 __A, __mmask64 __B) { + return (unsigned char)__builtin_ia32_ktestcdi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestz_mask64_u8(__mmask64 __A, __mmask64 __B) { + return (unsigned char)__builtin_ia32_ktestzdi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktest_mask64_u8(__mmask64 __A, __mmask64 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_ktestcdi(__A, __B); + return (unsigned char)__builtin_ia32_ktestzdi(__A, __B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_kadd_mask32(__mmask32 __A, __mmask32 __B) +{ + return (__mmask32)__builtin_ia32_kaddsi((__mmask32)__A, (__mmask32)__B); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _kadd_mask64(__mmask64 __A, + __mmask64 __B) { + return (__mmask64)__builtin_ia32_kadddi((__mmask64)__A, (__mmask64)__B); +} + +#define _kshiftli_mask32(A, I) \ + ((__mmask32)__builtin_ia32_kshiftlisi((__mmask32)(A), (unsigned int)(I))) + +#define _kshiftri_mask32(A, I) \ + ((__mmask32)__builtin_ia32_kshiftrisi((__mmask32)(A), (unsigned int)(I))) + +#define _kshiftli_mask64(A, I) \ + ((__mmask64)__builtin_ia32_kshiftlidi((__mmask64)(A), (unsigned int)(I))) + +#define _kshiftri_mask64(A, I) \ + ((__mmask64)__builtin_ia32_kshiftridi((__mmask64)(A), (unsigned int)(I))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_cvtmask32_u32(__mmask32 __A) { + return (unsigned int)__builtin_ia32_kmovd((__mmask32)__A); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_cvtmask64_u64(__mmask64 __A) { + return (unsigned long long)__builtin_ia32_kmovq((__mmask64)__A); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_cvtu32_mask32(unsigned int __A) { + return (__mmask32)__builtin_ia32_kmovd((__mmask32)__A); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS +_cvtu64_mask64(unsigned long long __A) { + return (__mmask64)__builtin_ia32_kmovq((__mmask64)__A); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_load_mask32(__mmask32 *__A) { + return (__mmask32)__builtin_ia32_kmovd(*(__mmask32 *)__A); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _load_mask64(__mmask64 *__A) { + return (__mmask64)__builtin_ia32_kmovq(*(__mmask64 *)__A); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_store_mask32(__mmask32 *__A, __mmask32 __B) { + *(__mmask32 *)__A = __builtin_ia32_kmovd((__mmask32)__B); +} + +static __inline__ void __DEFAULT_FN_ATTRS _store_mask64(__mmask64 *__A, + __mmask64 __B) { + *(__mmask64 *)__A = __builtin_ia32_kmovq((__mmask64)__B); +} + +/* Integer compare */ + +#define _mm512_cmp_epi8_mask(a, b, p) \ + ((__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \ + (__v64qi)(__m512i)(b), (int)(p), \ + (__mmask64)-1)) + +#define _mm512_mask_cmp_epi8_mask(m, a, b, p) \ + ((__mmask64)__builtin_ia32_cmpb512_mask((__v64qi)(__m512i)(a), \ + (__v64qi)(__m512i)(b), (int)(p), \ + (__mmask64)(m))) + +#define _mm512_cmp_epu8_mask(a, b, p) \ + ((__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)(__m512i)(a), \ + (__v64qi)(__m512i)(b), (int)(p), \ + (__mmask64)-1)) + +#define _mm512_mask_cmp_epu8_mask(m, a, b, p) \ + ((__mmask64)__builtin_ia32_ucmpb512_mask((__v64qi)(__m512i)(a), \ + (__v64qi)(__m512i)(b), (int)(p), \ + (__mmask64)(m))) + +#define _mm512_cmp_epi16_mask(a, b, p) \ + ((__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)(__m512i)(a), \ + (__v32hi)(__m512i)(b), (int)(p), \ + (__mmask32)-1)) + +#define _mm512_mask_cmp_epi16_mask(m, a, b, p) \ + ((__mmask32)__builtin_ia32_cmpw512_mask((__v32hi)(__m512i)(a), \ + (__v32hi)(__m512i)(b), (int)(p), \ + (__mmask32)(m))) + +#define _mm512_cmp_epu16_mask(a, b, p) \ + ((__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)(__m512i)(a), \ + (__v32hi)(__m512i)(b), (int)(p), \ + (__mmask32)-1)) + +#define _mm512_mask_cmp_epu16_mask(m, a, b, p) \ + ((__mmask32)__builtin_ia32_ucmpw512_mask((__v32hi)(__m512i)(a), \ + (__v32hi)(__m512i)(b), (int)(p), \ + (__mmask32)(m))) + +#define _mm512_cmpeq_epi8_mask(A, B) \ + _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epi8_mask(k, A, B) \ + _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epi8_mask(A, B) \ + _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epi8_mask(k, A, B) \ + _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epi8_mask(A, B) \ + _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epi8_mask(k, A, B) \ + _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epi8_mask(A, B) \ + _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epi8_mask(k, A, B) \ + _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epi8_mask(A, B) \ + _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epi8_mask(k, A, B) \ + _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epi8_mask(A, B) \ + _mm512_cmp_epi8_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epi8_mask(k, A, B) \ + _mm512_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm512_cmpeq_epu8_mask(A, B) \ + _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epu8_mask(k, A, B) \ + _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epu8_mask(A, B) \ + _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epu8_mask(k, A, B) \ + _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epu8_mask(A, B) \ + _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epu8_mask(k, A, B) \ + _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epu8_mask(A, B) \ + _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epu8_mask(k, A, B) \ + _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epu8_mask(A, B) \ + _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epu8_mask(k, A, B) \ + _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epu8_mask(A, B) \ + _mm512_cmp_epu8_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epu8_mask(k, A, B) \ + _mm512_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm512_cmpeq_epi16_mask(A, B) \ + _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epi16_mask(k, A, B) \ + _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epi16_mask(A, B) \ + _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epi16_mask(k, A, B) \ + _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epi16_mask(A, B) \ + _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epi16_mask(k, A, B) \ + _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epi16_mask(A, B) \ + _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epi16_mask(k, A, B) \ + _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epi16_mask(A, B) \ + _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epi16_mask(k, A, B) \ + _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epi16_mask(A, B) \ + _mm512_cmp_epi16_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epi16_mask(k, A, B) \ + _mm512_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm512_cmpeq_epu16_mask(A, B) \ + _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epu16_mask(k, A, B) \ + _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epu16_mask(A, B) \ + _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epu16_mask(k, A, B) \ + _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epu16_mask(A, B) \ + _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epu16_mask(k, A, B) \ + _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epu16_mask(A, B) \ + _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epu16_mask(k, A, B) \ + _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epu16_mask(A, B) \ + _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epu16_mask(k, A, B) \ + _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epu16_mask(A, B) \ + _mm512_cmp_epu16_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epu16_mask(k, A, B) \ + _mm512_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_add_epi8 (__m512i __A, __m512i __B) { + return (__m512i) ((__v64qu) __A + (__v64qu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_add_epi8(__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_add_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_epi8(__mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_add_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sub_epi8 (__m512i __A, __m512i __B) { + return (__m512i) ((__v64qu) __A - (__v64qu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_epi8(__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_sub_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_epi8(__mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_sub_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_add_epi16 (__m512i __A, __m512i __B) { + return (__m512i) ((__v32hu) __A + (__v32hu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_add_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_add_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_epi16(__mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_add_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sub_epi16 (__m512i __A, __m512i __B) { + return (__m512i) ((__v32hu) __A - (__v32hu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sub_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_epi16(__mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sub_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mullo_epi16 (__m512i __A, __m512i __B) { + return (__m512i) ((__v32hu) __A * (__v32hu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mullo_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mullo_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mullo_epi16(__mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mullo_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_epi8 (__mmask64 __U, __m512i __A, __m512i __W) +{ + return (__m512i) __builtin_ia32_selectb_512 ((__mmask64) __U, + (__v64qi) __W, + (__v64qi) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_epi16 (__mmask32 __U, __m512i __A, __m512i __W) +{ + return (__m512i) __builtin_ia32_selectw_512 ((__mmask32) __U, + (__v32hi) __W, + (__v32hi) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_abs_epi8 (__m512i __A) +{ + return (__m512i)__builtin_elementwise_abs((__v64qs)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_abs_epi8 (__m512i __W, __mmask64 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_abs_epi8(__A), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_abs_epi8 (__mmask64 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_abs_epi8(__A), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_abs_epi16 (__m512i __A) +{ + return (__m512i)__builtin_elementwise_abs((__v32hi)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_abs_epi16 (__m512i __W, __mmask32 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_abs_epi16(__A), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_abs_epi16 (__mmask32 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_abs_epi16(__A), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_packs_epi32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_packssdw512((__v16si)__A, (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_packs_epi32(__mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_packs_epi32(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_packs_epi32(__m512i __W, __mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_packs_epi32(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_packs_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_packsswb512((__v32hi)__A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_packs_epi16(__m512i __W, __mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_packs_epi16(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_packs_epi16(__mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_packs_epi16(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_packus_epi32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_packusdw512((__v16si) __A, (__v16si) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_packus_epi32(__mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_packus_epi32(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_packus_epi32(__m512i __W, __mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_packus_epi32(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_packus_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_packuswb512((__v32hi) __A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_packus_epi16(__m512i __W, __mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_packus_epi16(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_packus_epi16(__mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_packus_epi16(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_adds_epi8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_add_sat((__v64qs)__A, (__v64qs)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_adds_epi8 (__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_adds_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_adds_epi8 (__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_adds_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_adds_epi16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_add_sat((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_adds_epi16 (__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_adds_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_adds_epi16 (__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_adds_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_adds_epu8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_add_sat((__v64qu) __A, (__v64qu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_adds_epu8 (__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_adds_epu8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_adds_epu8 (__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_adds_epu8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_adds_epu16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_add_sat((__v32hu) __A, (__v32hu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_adds_epu16 (__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_adds_epu16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_adds_epu16 (__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_adds_epu16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_avg_epu8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_pavgb512((__v64qi)__A, (__v64qi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_avg_epu8 (__m512i __W, __mmask64 __U, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_avg_epu8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_avg_epu8 (__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_avg_epu8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_avg_epu16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_pavgw512((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_avg_epu16 (__m512i __W, __mmask32 __U, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_avg_epu16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_avg_epu16 (__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_avg_epu16(__A, __B), + (__v32hi) _mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epi8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v64qs) __A, (__v64qs) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epi8 (__mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_max_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epi8 (__m512i __W, __mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_max_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epi16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v32hi) __A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epi16 (__mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_max_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epi16 (__m512i __W, __mmask32 __M, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_max_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epu8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v64qu)__A, (__v64qu)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epu8 (__mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_max_epu8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epu8 (__m512i __W, __mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_max_epu8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epu16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v32hu)__A, (__v32hu)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epu16 (__mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_max_epu16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epu16 (__m512i __W, __mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_max_epu16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epi8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v64qs) __A, (__v64qs) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epi8 (__mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_min_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epi8 (__m512i __W, __mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_min_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epi16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v32hi) __A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epi16 (__mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_min_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epi16 (__m512i __W, __mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_min_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epu8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v64qu)__A, (__v64qu)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epu8 (__mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_min_epu8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epu8 (__m512i __W, __mmask64 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_min_epu8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epu16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v32hu)__A, (__v32hu)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epu16 (__mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_min_epu16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epu16 (__m512i __W, __mmask32 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_min_epu16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_shuffle_epi8(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_pshufb512((__v64qi)__A,(__v64qi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_shuffle_epi8(__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_shuffle_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_shuffle_epi8(__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_shuffle_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_subs_epi8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_sub_sat((__v64qs)__A, (__v64qs)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_subs_epi8 (__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_subs_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_subs_epi8 (__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_subs_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_subs_epi16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_sub_sat((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_subs_epi16 (__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_subs_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_subs_epi16 (__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_subs_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_subs_epu8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_sub_sat((__v64qu) __A, (__v64qu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_subs_epu8 (__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_subs_epu8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_subs_epu8 (__mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_subs_epu8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_subs_epu16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_sub_sat((__v32hu) __A, (__v32hu) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_subs_epu16 (__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_subs_epu16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_subs_epu16 (__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_subs_epu16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_epi16(__m512i __A, __m512i __I, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpermi2varhi512((__v32hi)__A, (__v32hi)__I, + (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_permutex2var_epi16(__m512i __A, __mmask32 __U, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_permutex2var_epi16(__A, __I, __B), + (__v32hi)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask2_permutex2var_epi16(__m512i __A, __m512i __I, __mmask32 __U, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_permutex2var_epi16(__A, __I, __B), + (__v32hi)__I); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutex2var_epi16(__mmask32 __U, __m512i __A, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_permutex2var_epi16(__A, __I, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mulhrs_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_pmulhrsw512((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mulhrs_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mulhrs_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mulhrs_epi16(__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mulhrs_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mulhi_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_pmulhw512((__v32hi) __A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mulhi_epi16(__m512i __W, __mmask32 __U, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mulhi_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mulhi_epi16(__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mulhi_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mulhi_epu16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_pmulhuw512((__v32hi) __A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mulhi_epu16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mulhi_epu16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mulhi_epu16 (__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_mulhi_epu16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maddubs_epi16(__m512i __X, __m512i __Y) { + return (__m512i)__builtin_ia32_pmaddubsw512((__v64qi)__X, (__v64qi)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_maddubs_epi16(__m512i __W, __mmask32 __U, __m512i __X, + __m512i __Y) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32) __U, + (__v32hi)_mm512_maddubs_epi16(__X, __Y), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_maddubs_epi16(__mmask32 __U, __m512i __X, __m512i __Y) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32) __U, + (__v32hi)_mm512_maddubs_epi16(__X, __Y), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_madd_epi16(__m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_pmaddwd512((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_madd_epi16(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_madd_epi16(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_madd_epi16(__mmask16 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_madd_epi16(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtsepi16_epi8 (__m512i __A) { + return (__m256i) __builtin_ia32_pmovswb512_mask ((__v32hi) __A, + (__v32qi)_mm256_setzero_si256(), + (__mmask32) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi16_epi8 (__m256i __O, __mmask32 __M, __m512i __A) { + return (__m256i) __builtin_ia32_pmovswb512_mask ((__v32hi) __A, + (__v32qi)__O, + __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtsepi16_epi8 (__mmask32 __M, __m512i __A) { + return (__m256i) __builtin_ia32_pmovswb512_mask ((__v32hi) __A, + (__v32qi) _mm256_setzero_si256(), + __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtusepi16_epi8 (__m512i __A) { + return (__m256i) __builtin_ia32_pmovuswb512_mask ((__v32hi) __A, + (__v32qi) _mm256_setzero_si256(), + (__mmask32) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi16_epi8 (__m256i __O, __mmask32 __M, __m512i __A) { + return (__m256i) __builtin_ia32_pmovuswb512_mask ((__v32hi) __A, + (__v32qi) __O, + __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtusepi16_epi8 (__mmask32 __M, __m512i __A) { + return (__m256i) __builtin_ia32_pmovuswb512_mask ((__v32hi) __A, + (__v32qi) _mm256_setzero_si256(), + __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi16_epi8 (__m512i __A) { + return (__m256i) __builtin_ia32_pmovwb512_mask ((__v32hi) __A, + (__v32qi) _mm256_undefined_si256(), + (__mmask32) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi16_epi8 (__m256i __O, __mmask32 __M, __m512i __A) { + return (__m256i) __builtin_ia32_pmovwb512_mask ((__v32hi) __A, + (__v32qi) __O, + __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi16_epi8 (__mmask32 __M, __m512i __A) { + return (__m256i) __builtin_ia32_pmovwb512_mask ((__v32hi) __A, + (__v32qi) _mm256_setzero_si256(), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi16_storeu_epi8 (void * __P, __mmask32 __M, __m512i __A) +{ + __builtin_ia32_pmovwb512mem_mask ((__v32qi *) __P, (__v32hi) __A, __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi16_storeu_epi8 (void * __P, __mmask32 __M, __m512i __A) +{ + __builtin_ia32_pmovswb512mem_mask ((__v32qi *) __P, (__v32hi) __A, __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi16_storeu_epi8 (void * __P, __mmask32 __M, __m512i __A) +{ + __builtin_ia32_pmovuswb512mem_mask ((__v32qi *) __P, (__v32hi) __A, __M); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpackhi_epi8(__m512i __A, __m512i __B) { + return (__m512i)__builtin_shufflevector((__v64qi)__A, (__v64qi)__B, + 8, 64+8, 9, 64+9, + 10, 64+10, 11, 64+11, + 12, 64+12, 13, 64+13, + 14, 64+14, 15, 64+15, + 24, 64+24, 25, 64+25, + 26, 64+26, 27, 64+27, + 28, 64+28, 29, 64+29, + 30, 64+30, 31, 64+31, + 40, 64+40, 41, 64+41, + 42, 64+42, 43, 64+43, + 44, 64+44, 45, 64+45, + 46, 64+46, 47, 64+47, + 56, 64+56, 57, 64+57, + 58, 64+58, 59, 64+59, + 60, 64+60, 61, 64+61, + 62, 64+62, 63, 64+63); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpackhi_epi8(__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_unpackhi_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpackhi_epi8(__mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_unpackhi_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpackhi_epi16(__m512i __A, __m512i __B) { + return (__m512i)__builtin_shufflevector((__v32hi)__A, (__v32hi)__B, + 4, 32+4, 5, 32+5, + 6, 32+6, 7, 32+7, + 12, 32+12, 13, 32+13, + 14, 32+14, 15, 32+15, + 20, 32+20, 21, 32+21, + 22, 32+22, 23, 32+23, + 28, 32+28, 29, 32+29, + 30, 32+30, 31, 32+31); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpackhi_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_unpackhi_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpackhi_epi16(__mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_unpackhi_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpacklo_epi8(__m512i __A, __m512i __B) { + return (__m512i)__builtin_shufflevector((__v64qi)__A, (__v64qi)__B, + 0, 64+0, 1, 64+1, + 2, 64+2, 3, 64+3, + 4, 64+4, 5, 64+5, + 6, 64+6, 7, 64+7, + 16, 64+16, 17, 64+17, + 18, 64+18, 19, 64+19, + 20, 64+20, 21, 64+21, + 22, 64+22, 23, 64+23, + 32, 64+32, 33, 64+33, + 34, 64+34, 35, 64+35, + 36, 64+36, 37, 64+37, + 38, 64+38, 39, 64+39, + 48, 64+48, 49, 64+49, + 50, 64+50, 51, 64+51, + 52, 64+52, 53, 64+53, + 54, 64+54, 55, 64+55); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpacklo_epi8(__m512i __W, __mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_unpacklo_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpacklo_epi8(__mmask64 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_unpacklo_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpacklo_epi16(__m512i __A, __m512i __B) { + return (__m512i)__builtin_shufflevector((__v32hi)__A, (__v32hi)__B, + 0, 32+0, 1, 32+1, + 2, 32+2, 3, 32+3, + 8, 32+8, 9, 32+9, + 10, 32+10, 11, 32+11, + 16, 32+16, 17, 32+17, + 18, 32+18, 19, 32+19, + 24, 32+24, 25, 32+25, + 26, 32+26, 27, 32+27); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpacklo_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_unpacklo_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpacklo_epi16(__mmask32 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_unpacklo_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi8_epi16(__m256i __A) +{ + /* This function always performs a signed extension, but __v32qi is a char + which may be signed or unsigned, so use __v32qs. */ + return (__m512i)__builtin_convertvector((__v32qs)__A, __v32hi); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi8_epi16(__m512i __W, __mmask32 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_cvtepi8_epi16(__A), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi8_epi16(__mmask32 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_cvtepi8_epi16(__A), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepu8_epi16(__m256i __A) +{ + return (__m512i)__builtin_convertvector((__v32qu)__A, __v32hi); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu8_epi16(__m512i __W, __mmask32 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_cvtepu8_epi16(__A), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu8_epi16(__mmask32 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_cvtepu8_epi16(__A), + (__v32hi)_mm512_setzero_si512()); +} + + +#define _mm512_shufflehi_epi16(A, imm) \ + ((__m512i)__builtin_ia32_pshufhw512((__v32hi)(__m512i)(A), (int)(imm))) + +#define _mm512_mask_shufflehi_epi16(W, U, A, imm) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shufflehi_epi16((A), \ + (imm)), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_shufflehi_epi16(U, A, imm) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shufflehi_epi16((A), \ + (imm)), \ + (__v32hi)_mm512_setzero_si512())) + +#define _mm512_shufflelo_epi16(A, imm) \ + ((__m512i)__builtin_ia32_pshuflw512((__v32hi)(__m512i)(A), (int)(imm))) + + +#define _mm512_mask_shufflelo_epi16(W, U, A, imm) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shufflelo_epi16((A), \ + (imm)), \ + (__v32hi)(__m512i)(W))) + + +#define _mm512_maskz_shufflelo_epi16(U, A, imm) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shufflelo_epi16((A), \ + (imm)), \ + (__v32hi)_mm512_setzero_si512())) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sllv_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_psllv32hi((__v32hi) __A, (__v32hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sllv_epi16 (__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sllv_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sllv_epi16(__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sllv_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sll_epi16(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psllw512((__v32hi) __A, (__v8hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sll_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sll_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sll_epi16(__mmask32 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sll_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_slli_epi16(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psllwi512((__v32hi)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_slli_epi16(__m512i __W, __mmask32 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_slli_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_slli_epi16(__mmask32 __U, __m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_slli_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +#define _mm512_bslli_epi128(a, imm) \ + ((__m512i)__builtin_ia32_pslldqi512_byteshift((__v8di)(__m512i)(a), (int)(imm))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srlv_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_psrlv32hi((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srlv_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srlv_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srlv_epi16(__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srlv_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srav_epi16(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_psrav32hi((__v32hi)__A, (__v32hi)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srav_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srav_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srav_epi16(__mmask32 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srav_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sra_epi16(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psraw512((__v32hi) __A, (__v8hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sra_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sra_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sra_epi16(__mmask32 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_sra_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srai_epi16(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psrawi512((__v32hi)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srai_epi16(__m512i __W, __mmask32 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srai_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srai_epi16(__mmask32 __U, __m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srai_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srl_epi16(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psrlw512((__v32hi) __A, (__v8hi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srl_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srl_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srl_epi16(__mmask32 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srl_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srli_epi16(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psrlwi512((__v32hi)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srli_epi16(__m512i __W, __mmask32 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srli_epi16(__A, __B), + (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srli_epi16(__mmask32 __U, __m512i __A, int __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_srli_epi16(__A, (unsigned int)__B), + (__v32hi)_mm512_setzero_si512()); +} + +#define _mm512_bsrli_epi128(a, imm) \ + ((__m512i)__builtin_ia32_psrldqi512_byteshift((__v8di)(__m512i)(a), (int)(imm))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mov_epi16 (__m512i __W, __mmask32 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectw_512 ((__mmask32) __U, + (__v32hi) __A, + (__v32hi) __W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mov_epi16 (__mmask32 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectw_512 ((__mmask32) __U, + (__v32hi) __A, + (__v32hi) _mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mov_epi8 (__m512i __W, __mmask64 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectb_512 ((__mmask64) __U, + (__v64qi) __A, + (__v64qi) __W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mov_epi8 (__mmask64 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectb_512 ((__mmask64) __U, + (__v64qi) __A, + (__v64qi) _mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_set1_epi8 (__m512i __O, __mmask64 __M, char __A) +{ + return (__m512i) __builtin_ia32_selectb_512(__M, + (__v64qi)_mm512_set1_epi8(__A), + (__v64qi) __O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_set1_epi8 (__mmask64 __M, char __A) +{ + return (__m512i) __builtin_ia32_selectb_512(__M, + (__v64qi) _mm512_set1_epi8(__A), + (__v64qi) _mm512_setzero_si512()); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS _mm512_kunpackd(__mmask64 __A, + __mmask64 __B) { + return (__mmask64) __builtin_ia32_kunpckdi ((__mmask64) __A, + (__mmask64) __B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS +_mm512_kunpackw (__mmask32 __A, __mmask32 __B) +{ + return (__mmask32) __builtin_ia32_kunpcksi ((__mmask32) __A, + (__mmask32) __B); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadu_epi16 (void const *__P) +{ + struct __loadu_epi16 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi16*)__P)->__v; +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadu_epi16 (__m512i __W, __mmask32 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddquhi512_mask ((const __v32hi *) __P, + (__v32hi) __W, + (__mmask32) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadu_epi16 (__mmask32 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddquhi512_mask ((const __v32hi *) __P, + (__v32hi) + _mm512_setzero_si512 (), + (__mmask32) __U); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadu_epi8 (void const *__P) +{ + struct __loadu_epi8 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi8*)__P)->__v; +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadu_epi8 (__m512i __W, __mmask64 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddquqi512_mask ((const __v64qi *) __P, + (__v64qi) __W, + (__mmask64) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadu_epi8 (__mmask64 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddquqi512_mask ((const __v64qi *) __P, + (__v64qi) + _mm512_setzero_si512 (), + (__mmask64) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_epi16 (void *__P, __m512i __A) +{ + struct __storeu_epi16 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi16*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_storeu_epi16 (void *__P, __mmask32 __U, __m512i __A) +{ + __builtin_ia32_storedquhi512_mask ((__v32hi *) __P, + (__v32hi) __A, + (__mmask32) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_epi8 (void *__P, __m512i __A) +{ + struct __storeu_epi8 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi8*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_storeu_epi8 (void *__P, __mmask64 __U, __m512i __A) +{ + __builtin_ia32_storedquqi512_mask ((__v64qi *) __P, + (__v64qi) __A, + (__mmask64) __U); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS512 +_mm512_test_epi8_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpneq_epi8_mask (_mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS512 +_mm512_mask_test_epi8_mask (__mmask64 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpneq_epi8_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS512 +_mm512_test_epi16_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpneq_epi16_mask (_mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS512 +_mm512_mask_test_epi16_mask (__mmask32 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpneq_epi16_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS512 +_mm512_testn_epi8_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpeq_epi8_mask (_mm512_and_epi32 (__A, __B), _mm512_setzero_si512()); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS512 +_mm512_mask_testn_epi8_mask (__mmask64 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpeq_epi8_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS512 +_mm512_testn_epi16_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpeq_epi16_mask (_mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS512 +_mm512_mask_testn_epi16_mask (__mmask32 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpeq_epi16_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask64 __DEFAULT_FN_ATTRS512 +_mm512_movepi8_mask (__m512i __A) +{ + return (__mmask64) __builtin_ia32_cvtb2mask512 ((__v64qi) __A); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS512 +_mm512_movepi16_mask (__m512i __A) +{ + return (__mmask32) __builtin_ia32_cvtw2mask512 ((__v32hi) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_movm_epi8 (__mmask64 __A) +{ + return (__m512i) __builtin_ia32_cvtmask2b512 (__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_movm_epi16 (__mmask32 __A) +{ + return (__m512i) __builtin_ia32_cvtmask2w512 (__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcastb_epi8 (__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v16qi) __A, (__v16qi) __A, + 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); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcastb_epi8 (__m512i __O, __mmask64 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectb_512(__M, + (__v64qi) _mm512_broadcastb_epi8(__A), + (__v64qi) __O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcastb_epi8 (__mmask64 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectb_512(__M, + (__v64qi) _mm512_broadcastb_epi8(__A), + (__v64qi) _mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_set1_epi16 (__m512i __O, __mmask32 __M, short __A) +{ + return (__m512i) __builtin_ia32_selectw_512(__M, + (__v32hi) _mm512_set1_epi16(__A), + (__v32hi) __O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_set1_epi16 (__mmask32 __M, short __A) +{ + return (__m512i) __builtin_ia32_selectw_512(__M, + (__v32hi) _mm512_set1_epi16(__A), + (__v32hi) _mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcastw_epi16 (__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v8hi) __A, (__v8hi) __A, + 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); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcastw_epi16 (__m512i __O, __mmask32 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectw_512(__M, + (__v32hi) _mm512_broadcastw_epi16(__A), + (__v32hi) __O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcastw_epi16 (__mmask32 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectw_512(__M, + (__v32hi) _mm512_broadcastw_epi16(__A), + (__v32hi) _mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_epi16 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_permvarhi512((__v32hi)__B, (__v32hi)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutexvar_epi16 (__mmask32 __M, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_permutexvar_epi16(__A, __B), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_permutexvar_epi16 (__m512i __W, __mmask32 __M, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__M, + (__v32hi)_mm512_permutexvar_epi16(__A, __B), + (__v32hi)__W); +} + +#define _mm512_alignr_epi8(A, B, N) \ + ((__m512i)__builtin_ia32_palignr512((__v64qi)(__m512i)(A), \ + (__v64qi)(__m512i)(B), (int)(N))) + +#define _mm512_mask_alignr_epi8(W, U, A, B, N) \ + ((__m512i)__builtin_ia32_selectb_512((__mmask64)(U), \ + (__v64qi)_mm512_alignr_epi8((A), (B), (int)(N)), \ + (__v64qi)(__m512i)(W))) + +#define _mm512_maskz_alignr_epi8(U, A, B, N) \ + ((__m512i)__builtin_ia32_selectb_512((__mmask64)(U), \ + (__v64qi)_mm512_alignr_epi8((A), (B), (int)(N)), \ + (__v64qi)(__m512i)_mm512_setzero_si512())) + +#define _mm512_dbsad_epu8(A, B, imm) \ + ((__m512i)__builtin_ia32_dbpsadbw512((__v64qi)(__m512i)(A), \ + (__v64qi)(__m512i)(B), (int)(imm))) + +#define _mm512_mask_dbsad_epu8(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_dbsad_epu8((A), (B), (imm)), \ + (__v32hi)(__m512i)(W))) + +#define _mm512_maskz_dbsad_epu8(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_dbsad_epu8((A), (B), (imm)), \ + (__v32hi)_mm512_setzero_si512())) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sad_epu8 (__m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_psadbw512 ((__v64qi) __A, + (__v64qi) __B); +} + +#undef __DEFAULT_FN_ATTRS512 +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512cdintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512cdintrin.h new file mode 100755 index 0000000..33b552f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512cdintrin.h @@ -0,0 +1,125 @@ +/*===------------- avx512cdintrin.h - AVX512CD intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512CDINTRIN_H +#define __AVX512CDINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512cd,evex512"), __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_conflict_epi64 (__m512i __A) +{ + return (__m512i) __builtin_ia32_vpconflictdi_512 ((__v8di) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_conflict_epi64 (__m512i __W, __mmask8 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_conflict_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_conflict_epi64 (__mmask8 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_conflict_epi64(__A), + (__v8di)_mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_conflict_epi32 (__m512i __A) +{ + return (__m512i) __builtin_ia32_vpconflictsi_512 ((__v16si) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_conflict_epi32 (__m512i __W, __mmask16 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_conflict_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_conflict_epi32 (__mmask16 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_conflict_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_lzcnt_epi32 (__m512i __A) +{ + return (__m512i) __builtin_ia32_vplzcntd_512 ((__v16si) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_lzcnt_epi32 (__m512i __W, __mmask16 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_lzcnt_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_lzcnt_epi32 (__mmask16 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_lzcnt_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_lzcnt_epi64 (__m512i __A) +{ + return (__m512i) __builtin_ia32_vplzcntq_512 ((__v8di) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_lzcnt_epi64 (__m512i __W, __mmask8 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_lzcnt_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_lzcnt_epi64 (__mmask8 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_lzcnt_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_broadcastmb_epi64 (__mmask8 __A) +{ + return (__m512i) _mm512_set1_epi64((long long) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_broadcastmw_epi32 (__mmask16 __A) +{ + return (__m512i) _mm512_set1_epi32((int) __A); + +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512dqintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512dqintrin.h new file mode 100755 index 0000000..88b48e3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512dqintrin.h @@ -0,0 +1,1379 @@ +/*===---- avx512dqintrin.h - AVX512DQ intrinsics ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512DQINTRIN_H +#define __AVX512DQINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 __attribute__((__always_inline__, __nodebug__, __target__("avx512dq,evex512"), __min_vector_width__(512))) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512dq,no-evex512"))) + +static __inline __mmask8 __DEFAULT_FN_ATTRS +_knot_mask8(__mmask8 __M) +{ + return __builtin_ia32_knotqi(__M); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_kand_mask8(__mmask8 __A, __mmask8 __B) +{ + return (__mmask8)__builtin_ia32_kandqi((__mmask8)__A, (__mmask8)__B); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_kandn_mask8(__mmask8 __A, __mmask8 __B) +{ + return (__mmask8)__builtin_ia32_kandnqi((__mmask8)__A, (__mmask8)__B); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_kor_mask8(__mmask8 __A, __mmask8 __B) +{ + return (__mmask8)__builtin_ia32_korqi((__mmask8)__A, (__mmask8)__B); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_kxnor_mask8(__mmask8 __A, __mmask8 __B) +{ + return (__mmask8)__builtin_ia32_kxnorqi((__mmask8)__A, (__mmask8)__B); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_kxor_mask8(__mmask8 __A, __mmask8 __B) +{ + return (__mmask8)__builtin_ia32_kxorqi((__mmask8)__A, (__mmask8)__B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestc_mask8_u8(__mmask8 __A, __mmask8 __B) +{ + return (unsigned char)__builtin_ia32_kortestcqi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestz_mask8_u8(__mmask8 __A, __mmask8 __B) +{ + return (unsigned char)__builtin_ia32_kortestzqi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortest_mask8_u8(__mmask8 __A, __mmask8 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_kortestcqi(__A, __B); + return (unsigned char)__builtin_ia32_kortestzqi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestc_mask8_u8(__mmask8 __A, __mmask8 __B) +{ + return (unsigned char)__builtin_ia32_ktestcqi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestz_mask8_u8(__mmask8 __A, __mmask8 __B) +{ + return (unsigned char)__builtin_ia32_ktestzqi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktest_mask8_u8(__mmask8 __A, __mmask8 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_ktestcqi(__A, __B); + return (unsigned char)__builtin_ia32_ktestzqi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestc_mask16_u8(__mmask16 __A, __mmask16 __B) +{ + return (unsigned char)__builtin_ia32_ktestchi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktestz_mask16_u8(__mmask16 __A, __mmask16 __B) +{ + return (unsigned char)__builtin_ia32_ktestzhi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_ktest_mask16_u8(__mmask16 __A, __mmask16 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_ktestchi(__A, __B); + return (unsigned char)__builtin_ia32_ktestzhi(__A, __B); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_kadd_mask8(__mmask8 __A, __mmask8 __B) +{ + return (__mmask8)__builtin_ia32_kaddqi((__mmask8)__A, (__mmask8)__B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_kadd_mask16(__mmask16 __A, __mmask16 __B) +{ + return (__mmask16)__builtin_ia32_kaddhi((__mmask16)__A, (__mmask16)__B); +} + +#define _kshiftli_mask8(A, I) \ + ((__mmask8)__builtin_ia32_kshiftliqi((__mmask8)(A), (unsigned int)(I))) + +#define _kshiftri_mask8(A, I) \ + ((__mmask8)__builtin_ia32_kshiftriqi((__mmask8)(A), (unsigned int)(I))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_cvtmask8_u32(__mmask8 __A) { + return (unsigned int)__builtin_ia32_kmovb((__mmask8)__A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_cvtu32_mask8(unsigned int __A) { + return (__mmask8)__builtin_ia32_kmovb((__mmask8)__A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS +_load_mask8(__mmask8 *__A) { + return (__mmask8)__builtin_ia32_kmovb(*(__mmask8 *)__A); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_store_mask8(__mmask8 *__A, __mmask8 __B) { + *(__mmask8 *)__A = __builtin_ia32_kmovb((__mmask8)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mullo_epi64 (__m512i __A, __m512i __B) { + return (__m512i) ((__v8du) __A * (__v8du) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mullo_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_mullo_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mullo_epi64(__mmask8 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_mullo_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_xor_pd(__m512d __A, __m512d __B) { + return (__m512d)((__v8du)__A ^ (__v8du)__B); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_xor_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_xor_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_xor_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_xor_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_xor_ps (__m512 __A, __m512 __B) { + return (__m512)((__v16su)__A ^ (__v16su)__B); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_xor_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_xor_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_xor_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_xor_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_or_pd(__m512d __A, __m512d __B) { + return (__m512d)((__v8du)__A | (__v8du)__B); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_or_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_or_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_or_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_or_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_or_ps(__m512 __A, __m512 __B) { + return (__m512)((__v16su)__A | (__v16su)__B); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_or_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_or_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_or_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_or_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_and_pd(__m512d __A, __m512d __B) { + return (__m512d)((__v8du)__A & (__v8du)__B); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_and_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_and_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_and_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_and_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_and_ps(__m512 __A, __m512 __B) { + return (__m512)((__v16su)__A & (__v16su)__B); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_and_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_and_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_and_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_and_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_andnot_pd(__m512d __A, __m512d __B) { + return (__m512d)(~(__v8du)__A & (__v8du)__B); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_andnot_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_andnot_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_andnot_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_andnot_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_andnot_ps(__m512 __A, __m512 __B) { + return (__m512)(~(__v16su)__A & (__v16su)__B); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_andnot_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_andnot_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_andnot_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_andnot_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtpd_epi64 (__m512d __A) { + return (__m512i) __builtin_ia32_cvtpd2qq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_epi64 (__m512i __W, __mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvtpd2qq512_mask ((__v8df) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpd_epi64 (__mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvtpd2qq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundpd_epi64(A, R) \ + ((__m512i)__builtin_ia32_cvtpd2qq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundpd_epi64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvtpd2qq512_mask((__v8df)(__m512d)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundpd_epi64(U, A, R) \ + ((__m512i)__builtin_ia32_cvtpd2qq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtpd_epu64 (__m512d __A) { + return (__m512i) __builtin_ia32_cvtpd2uqq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_epu64 (__m512i __W, __mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvtpd2uqq512_mask ((__v8df) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpd_epu64 (__mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvtpd2uqq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundpd_epu64(A, R) \ + ((__m512i)__builtin_ia32_cvtpd2uqq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundpd_epu64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvtpd2uqq512_mask((__v8df)(__m512d)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundpd_epu64(U, A, R) \ + ((__m512i)__builtin_ia32_cvtpd2uqq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtps_epi64 (__m256 __A) { + return (__m512i) __builtin_ia32_cvtps2qq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtps_epi64 (__m512i __W, __mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvtps2qq512_mask ((__v8sf) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtps_epi64 (__mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvtps2qq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundps_epi64(A, R) \ + ((__m512i)__builtin_ia32_cvtps2qq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundps_epi64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2qq512_mask((__v8sf)(__m256)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundps_epi64(U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2qq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtps_epu64 (__m256 __A) { + return (__m512i) __builtin_ia32_cvtps2uqq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtps_epu64 (__m512i __W, __mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvtps2uqq512_mask ((__v8sf) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtps_epu64 (__mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvtps2uqq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundps_epu64(A, R) \ + ((__m512i)__builtin_ia32_cvtps2uqq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundps_epu64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2uqq512_mask((__v8sf)(__m256)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundps_epu64(U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2uqq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtepi64_pd (__m512i __A) { + return (__m512d)__builtin_convertvector((__v8di)__A, __v8df); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_pd (__m512d __W, __mmask8 __U, __m512i __A) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_cvtepi64_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi64_pd (__mmask8 __U, __m512i __A) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_cvtepi64_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +#define _mm512_cvt_roundepi64_pd(A, R) \ + ((__m512d)__builtin_ia32_cvtqq2pd512_mask((__v8di)(__m512i)(A), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundepi64_pd(W, U, A, R) \ + ((__m512d)__builtin_ia32_cvtqq2pd512_mask((__v8di)(__m512i)(A), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepi64_pd(U, A, R) \ + ((__m512d)__builtin_ia32_cvtqq2pd512_mask((__v8di)(__m512i)(A), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_cvtepi64_ps (__m512i __A) { + return (__m256) __builtin_ia32_cvtqq2ps512_mask ((__v8di) __A, + (__v8sf) _mm256_setzero_ps(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_ps (__m256 __W, __mmask8 __U, __m512i __A) { + return (__m256) __builtin_ia32_cvtqq2ps512_mask ((__v8di) __A, + (__v8sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi64_ps (__mmask8 __U, __m512i __A) { + return (__m256) __builtin_ia32_cvtqq2ps512_mask ((__v8di) __A, + (__v8sf) _mm256_setzero_ps(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepi64_ps(A, R) \ + ((__m256)__builtin_ia32_cvtqq2ps512_mask((__v8di)(__m512i)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundepi64_ps(W, U, A, R) \ + ((__m256)__builtin_ia32_cvtqq2ps512_mask((__v8di)(__m512i)(A), \ + (__v8sf)(__m256)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm512_maskz_cvt_roundepi64_ps(U, A, R) \ + ((__m256)__builtin_ia32_cvtqq2ps512_mask((__v8di)(__m512i)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttpd_epi64 (__m512d __A) { + return (__m512i) __builtin_ia32_cvttpd2qq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttpd_epi64 (__m512i __W, __mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvttpd2qq512_mask ((__v8df) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttpd_epi64 (__mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvttpd2qq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundpd_epi64(A, R) \ + ((__m512i)__builtin_ia32_cvttpd2qq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundpd_epi64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvttpd2qq512_mask((__v8df)(__m512d)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundpd_epi64(U, A, R) \ + ((__m512i)__builtin_ia32_cvttpd2qq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttpd_epu64 (__m512d __A) { + return (__m512i) __builtin_ia32_cvttpd2uqq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttpd_epu64 (__m512i __W, __mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvttpd2uqq512_mask ((__v8df) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttpd_epu64 (__mmask8 __U, __m512d __A) { + return (__m512i) __builtin_ia32_cvttpd2uqq512_mask ((__v8df) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundpd_epu64(A, R) \ + ((__m512i)__builtin_ia32_cvttpd2uqq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundpd_epu64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvttpd2uqq512_mask((__v8df)(__m512d)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundpd_epu64(U, A, R) \ + ((__m512i)__builtin_ia32_cvttpd2uqq512_mask((__v8df)(__m512d)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttps_epi64 (__m256 __A) { + return (__m512i) __builtin_ia32_cvttps2qq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttps_epi64 (__m512i __W, __mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvttps2qq512_mask ((__v8sf) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttps_epi64 (__mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvttps2qq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundps_epi64(A, R) \ + ((__m512i)__builtin_ia32_cvttps2qq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundps_epi64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2qq512_mask((__v8sf)(__m256)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundps_epi64(U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2qq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttps_epu64 (__m256 __A) { + return (__m512i) __builtin_ia32_cvttps2uqq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttps_epu64 (__m512i __W, __mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvttps2uqq512_mask ((__v8sf) __A, + (__v8di) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttps_epu64 (__mmask8 __U, __m256 __A) { + return (__m512i) __builtin_ia32_cvttps2uqq512_mask ((__v8sf) __A, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundps_epu64(A, R) \ + ((__m512i)__builtin_ia32_cvttps2uqq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundps_epu64(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2uqq512_mask((__v8sf)(__m256)(A), \ + (__v8di)(__m512i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundps_epu64(U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2uqq512_mask((__v8sf)(__m256)(A), \ + (__v8di)_mm512_setzero_si512(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtepu64_pd (__m512i __A) { + return (__m512d)__builtin_convertvector((__v8du)__A, __v8df); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu64_pd (__m512d __W, __mmask8 __U, __m512i __A) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_cvtepu64_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu64_pd (__mmask8 __U, __m512i __A) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_cvtepu64_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +#define _mm512_cvt_roundepu64_pd(A, R) \ + ((__m512d)__builtin_ia32_cvtuqq2pd512_mask((__v8di)(__m512i)(A), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundepu64_pd(W, U, A, R) \ + ((__m512d)__builtin_ia32_cvtuqq2pd512_mask((__v8di)(__m512i)(A), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_maskz_cvt_roundepu64_pd(U, A, R) \ + ((__m512d)__builtin_ia32_cvtuqq2pd512_mask((__v8di)(__m512i)(A), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_cvtepu64_ps (__m512i __A) { + return (__m256) __builtin_ia32_cvtuqq2ps512_mask ((__v8di) __A, + (__v8sf) _mm256_setzero_ps(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu64_ps (__m256 __W, __mmask8 __U, __m512i __A) { + return (__m256) __builtin_ia32_cvtuqq2ps512_mask ((__v8di) __A, + (__v8sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu64_ps (__mmask8 __U, __m512i __A) { + return (__m256) __builtin_ia32_cvtuqq2ps512_mask ((__v8di) __A, + (__v8sf) _mm256_setzero_ps(), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepu64_ps(A, R) \ + ((__m256)__builtin_ia32_cvtuqq2ps512_mask((__v8di)(__m512i)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundepu64_ps(W, U, A, R) \ + ((__m256)__builtin_ia32_cvtuqq2ps512_mask((__v8di)(__m512i)(A), \ + (__v8sf)(__m256)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm512_maskz_cvt_roundepu64_ps(U, A, R) \ + ((__m256)__builtin_ia32_cvtuqq2ps512_mask((__v8di)(__m512i)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_range_pd(A, B, C) \ + ((__m512d)__builtin_ia32_rangepd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_range_pd(W, U, A, B, C) \ + ((__m512d)__builtin_ia32_rangepd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)(__m512d)(W), (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_range_pd(U, A, B, C) \ + ((__m512d)__builtin_ia32_rangepd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_range_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_rangepd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_range_round_pd(W, U, A, B, C, R) \ + ((__m512d)__builtin_ia32_rangepd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)(__m512d)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm512_maskz_range_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_rangepd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(C), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_range_ps(A, B, C) \ + ((__m512)__builtin_ia32_rangeps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_range_ps(W, U, A, B, C) \ + ((__m512)__builtin_ia32_rangeps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)(__m512)(W), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_range_ps(U, A, B, C) \ + ((__m512)__builtin_ia32_rangeps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_range_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_rangeps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_range_round_ps(W, U, A, B, C, R) \ + ((__m512)__builtin_ia32_rangeps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)(__m512)(W), (__mmask16)(U), \ + (int)(R))) + +#define _mm512_maskz_range_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_rangeps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(C), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +#define _mm_range_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_rangess128_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8) -1, (int)(C),\ + (int)(R))) + +#define _mm_range_ss(A ,B , C) _mm_range_round_ss(A, B, C ,_MM_FROUND_CUR_DIRECTION) + +#define _mm_mask_range_round_ss(W, U, A, B, C, R) \ + ((__m128)__builtin_ia32_rangess128_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W),\ + (__mmask8)(U), (int)(C),\ + (int)(R))) + +#define _mm_mask_range_ss(W , U, A, B, C) _mm_mask_range_round_ss(W, U, A, B, C , _MM_FROUND_CUR_DIRECTION) + +#define _mm_maskz_range_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_rangess128_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(C),\ + (int)(R))) + +#define _mm_maskz_range_ss(U, A ,B , C) _mm_maskz_range_round_ss(U, A, B, C ,_MM_FROUND_CUR_DIRECTION) + +#define _mm_range_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_rangesd128_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8) -1, (int)(C),\ + (int)(R))) + +#define _mm_range_sd(A ,B , C) _mm_range_round_sd(A, B, C ,_MM_FROUND_CUR_DIRECTION) + +#define _mm_mask_range_round_sd(W, U, A, B, C, R) \ + ((__m128d)__builtin_ia32_rangesd128_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W),\ + (__mmask8)(U), (int)(C),\ + (int)(R))) + +#define _mm_mask_range_sd(W, U, A, B, C) _mm_mask_range_round_sd(W, U, A, B, C ,_MM_FROUND_CUR_DIRECTION) + +#define _mm_maskz_range_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_rangesd128_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(C),\ + (int)(R))) + +#define _mm_maskz_range_sd(U, A, B, C) _mm_maskz_range_round_sd(U, A, B, C ,_MM_FROUND_CUR_DIRECTION) + +#define _mm512_reduce_pd(A, B) \ + ((__m512d)__builtin_ia32_reducepd512_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_reduce_pd(W, U, A, B) \ + ((__m512d)__builtin_ia32_reducepd512_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_reduce_pd(U, A, B) \ + ((__m512d)__builtin_ia32_reducepd512_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_reduce_ps(A, B) \ + ((__m512)__builtin_ia32_reduceps512_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_reduce_ps(W, U, A, B) \ + ((__m512)__builtin_ia32_reduceps512_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_reduce_ps(U, A, B) \ + ((__m512)__builtin_ia32_reduceps512_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_reduce_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_reducepd512_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_reduce_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_reducepd512_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_reduce_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_reducepd512_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_reduce_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_reduceps512_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_reduce_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_reduceps512_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_reduce_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_reduceps512_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +#define _mm_reduce_ss(A, B, C) \ + ((__m128)__builtin_ia32_reducess_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), (__mmask8)-1, \ + (int)(C), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_reduce_ss(W, U, A, B, C) \ + ((__m128)__builtin_ia32_reducess_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(C), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_reduce_ss(U, A, B, C) \ + ((__m128)__builtin_ia32_reducess_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(C), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_reduce_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_reducess_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), (__mmask8)-1, \ + (int)(C), (int)(R))) + +#define _mm_mask_reduce_round_ss(W, U, A, B, C, R) \ + ((__m128)__builtin_ia32_reducess_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(C), (int)(R))) + +#define _mm_maskz_reduce_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_reducess_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(C), (int)(R))) + +#define _mm_reduce_sd(A, B, C) \ + ((__m128d)__builtin_ia32_reducesd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(C), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_reduce_sd(W, U, A, B, C) \ + ((__m128d)__builtin_ia32_reducesd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), (__mmask8)(U), \ + (int)(C), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_reduce_sd(U, A, B, C) \ + ((__m128d)__builtin_ia32_reducesd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(C), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_reduce_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_reducesd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(C), (int)(R))) + +#define _mm_mask_reduce_round_sd(W, U, A, B, C, R) \ + ((__m128d)__builtin_ia32_reducesd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), (__mmask8)(U), \ + (int)(C), (int)(R))) + +#define _mm_maskz_reduce_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_reducesd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(C), (int)(R))) + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS512 +_mm512_movepi32_mask (__m512i __A) +{ + return (__mmask16) __builtin_ia32_cvtd2mask512 ((__v16si) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_movm_epi32 (__mmask16 __A) +{ + return (__m512i) __builtin_ia32_cvtmask2d512 (__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_movm_epi64 (__mmask8 __A) +{ + return (__m512i) __builtin_ia32_cvtmask2q512 (__A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS512 +_mm512_movepi64_mask (__m512i __A) +{ + return (__mmask8) __builtin_ia32_cvtq2mask512 ((__v8di) __A); +} + + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_broadcast_f32x2 (__m128 __A) +{ + return (__m512)__builtin_shufflevector((__v4sf)__A, (__v4sf)__A, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_f32x2 (__m512 __O, __mmask16 __M, __m128 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__M, + (__v16sf)_mm512_broadcast_f32x2(__A), + (__v16sf)__O); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_f32x2 (__mmask16 __M, __m128 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__M, + (__v16sf)_mm512_broadcast_f32x2(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_broadcast_f32x8(__m256 __A) +{ + return (__m512)__builtin_shufflevector((__v8sf)__A, (__v8sf)__A, + 0, 1, 2, 3, 4, 5, 6, 7, + 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_f32x8(__m512 __O, __mmask16 __M, __m256 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__M, + (__v16sf)_mm512_broadcast_f32x8(__A), + (__v16sf)__O); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_f32x8(__mmask16 __M, __m256 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__M, + (__v16sf)_mm512_broadcast_f32x8(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_broadcast_f64x2(__m128d __A) +{ + return (__m512d)__builtin_shufflevector((__v2df)__A, (__v2df)__A, + 0, 1, 0, 1, 0, 1, 0, 1); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_f64x2(__m512d __O, __mmask8 __M, __m128d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__M, + (__v8df)_mm512_broadcast_f64x2(__A), + (__v8df)__O); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_f64x2(__mmask8 __M, __m128d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__M, + (__v8df)_mm512_broadcast_f64x2(__A), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcast_i32x2 (__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v4si)__A, (__v4si)__A, + 0, 1, 0, 1, 0, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, 1); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_i32x2 (__m512i __O, __mmask16 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_broadcast_i32x2(__A), + (__v16si)__O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_i32x2 (__mmask16 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_broadcast_i32x2(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcast_i32x8(__m256i __A) +{ + return (__m512i)__builtin_shufflevector((__v8si)__A, (__v8si)__A, + 0, 1, 2, 3, 4, 5, 6, 7, + 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_i32x8(__m512i __O, __mmask16 __M, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_broadcast_i32x8(__A), + (__v16si)__O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_i32x8(__mmask16 __M, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_broadcast_i32x8(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcast_i64x2(__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v2di)__A, (__v2di)__A, + 0, 1, 0, 1, 0, 1, 0, 1); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_i64x2(__m512i __O, __mmask8 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_broadcast_i64x2(__A), + (__v8di)__O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_i64x2(__mmask8 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_broadcast_i64x2(__A), + (__v8di)_mm512_setzero_si512()); +} + +#define _mm512_extractf32x8_ps(A, imm) \ + ((__m256)__builtin_ia32_extractf32x8_mask((__v16sf)(__m512)(A), (int)(imm), \ + (__v8sf)_mm256_undefined_ps(), \ + (__mmask8)-1)) + +#define _mm512_mask_extractf32x8_ps(W, U, A, imm) \ + ((__m256)__builtin_ia32_extractf32x8_mask((__v16sf)(__m512)(A), (int)(imm), \ + (__v8sf)(__m256)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extractf32x8_ps(U, A, imm) \ + ((__m256)__builtin_ia32_extractf32x8_mask((__v16sf)(__m512)(A), (int)(imm), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm512_extractf64x2_pd(A, imm) \ + ((__m128d)__builtin_ia32_extractf64x2_512_mask((__v8df)(__m512d)(A), \ + (int)(imm), \ + (__v2df)_mm_undefined_pd(), \ + (__mmask8)-1)) + +#define _mm512_mask_extractf64x2_pd(W, U, A, imm) \ + ((__m128d)__builtin_ia32_extractf64x2_512_mask((__v8df)(__m512d)(A), \ + (int)(imm), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extractf64x2_pd(U, A, imm) \ + ((__m128d)__builtin_ia32_extractf64x2_512_mask((__v8df)(__m512d)(A), \ + (int)(imm), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm512_extracti32x8_epi32(A, imm) \ + ((__m256i)__builtin_ia32_extracti32x8_mask((__v16si)(__m512i)(A), (int)(imm), \ + (__v8si)_mm256_undefined_si256(), \ + (__mmask8)-1)) + +#define _mm512_mask_extracti32x8_epi32(W, U, A, imm) \ + ((__m256i)__builtin_ia32_extracti32x8_mask((__v16si)(__m512i)(A), (int)(imm), \ + (__v8si)(__m256i)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extracti32x8_epi32(U, A, imm) \ + ((__m256i)__builtin_ia32_extracti32x8_mask((__v16si)(__m512i)(A), (int)(imm), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)(U))) + +#define _mm512_extracti64x2_epi64(A, imm) \ + ((__m128i)__builtin_ia32_extracti64x2_512_mask((__v8di)(__m512i)(A), \ + (int)(imm), \ + (__v2di)_mm_undefined_si128(), \ + (__mmask8)-1)) + +#define _mm512_mask_extracti64x2_epi64(W, U, A, imm) \ + ((__m128i)__builtin_ia32_extracti64x2_512_mask((__v8di)(__m512i)(A), \ + (int)(imm), \ + (__v2di)(__m128i)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extracti64x2_epi64(U, A, imm) \ + ((__m128i)__builtin_ia32_extracti64x2_512_mask((__v8di)(__m512i)(A), \ + (int)(imm), \ + (__v2di)_mm_setzero_si128(), \ + (__mmask8)(U))) + +#define _mm512_insertf32x8(A, B, imm) \ + ((__m512)__builtin_ia32_insertf32x8((__v16sf)(__m512)(A), \ + (__v8sf)(__m256)(B), (int)(imm))) + +#define _mm512_mask_insertf32x8(W, U, A, B, imm) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_insertf32x8((A), (B), (imm)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_insertf32x8(U, A, B, imm) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_insertf32x8((A), (B), (imm)), \ + (__v16sf)_mm512_setzero_ps())) + +#define _mm512_insertf64x2(A, B, imm) \ + ((__m512d)__builtin_ia32_insertf64x2_512((__v8df)(__m512d)(A), \ + (__v2df)(__m128d)(B), (int)(imm))) + +#define _mm512_mask_insertf64x2(W, U, A, B, imm) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_insertf64x2((A), (B), (imm)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_insertf64x2(U, A, B, imm) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_insertf64x2((A), (B), (imm)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_inserti32x8(A, B, imm) \ + ((__m512i)__builtin_ia32_inserti32x8((__v16si)(__m512i)(A), \ + (__v8si)(__m256i)(B), (int)(imm))) + +#define _mm512_mask_inserti32x8(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_inserti32x8((A), (B), (imm)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_inserti32x8(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_inserti32x8((A), (B), (imm)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_inserti64x2(A, B, imm) \ + ((__m512i)__builtin_ia32_inserti64x2_512((__v8di)(__m512i)(A), \ + (__v2di)(__m128i)(B), (int)(imm))) + +#define _mm512_mask_inserti64x2(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_inserti64x2((A), (B), (imm)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_inserti64x2(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_inserti64x2((A), (B), (imm)), \ + (__v8di)_mm512_setzero_si512())) + +#define _mm512_mask_fpclass_ps_mask(U, A, imm) \ + ((__mmask16)__builtin_ia32_fpclassps512_mask((__v16sf)(__m512)(A), \ + (int)(imm), (__mmask16)(U))) + +#define _mm512_fpclass_ps_mask(A, imm) \ + ((__mmask16)__builtin_ia32_fpclassps512_mask((__v16sf)(__m512)(A), \ + (int)(imm), (__mmask16)-1)) + +#define _mm512_mask_fpclass_pd_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclasspd512_mask((__v8df)(__m512d)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm512_fpclass_pd_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclasspd512_mask((__v8df)(__m512d)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_fpclass_sd_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclasssd_mask((__v2df)(__m128d)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_mask_fpclass_sd_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclasssd_mask((__v2df)(__m128d)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm_fpclass_ss_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclassss_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_mask_fpclass_ss_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclassss_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__mmask8)(U))) + +#undef __DEFAULT_FN_ATTRS512 +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512fintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512fintrin.h new file mode 100755 index 0000000..45e7eeb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512fintrin.h @@ -0,0 +1,9787 @@ +/*===---- avx512fintrin.h - AVX512F intrinsics -----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512FINTRIN_H +#define __AVX512FINTRIN_H + +typedef char __v64qi __attribute__((__vector_size__(64))); +typedef short __v32hi __attribute__((__vector_size__(64))); +typedef double __v8df __attribute__((__vector_size__(64))); +typedef float __v16sf __attribute__((__vector_size__(64))); +typedef long long __v8di __attribute__((__vector_size__(64))); +typedef int __v16si __attribute__((__vector_size__(64))); + +/* Unsigned types */ +typedef unsigned char __v64qu __attribute__((__vector_size__(64))); +typedef unsigned short __v32hu __attribute__((__vector_size__(64))); +typedef unsigned long long __v8du __attribute__((__vector_size__(64))); +typedef unsigned int __v16su __attribute__((__vector_size__(64))); + +/* We need an explicitly signed variant for char. Note that this shouldn't + * appear in the interface though. */ +typedef signed char __v64qs __attribute__((__vector_size__(64))); + +typedef float __m512 __attribute__((__vector_size__(64), __aligned__(64))); +typedef double __m512d __attribute__((__vector_size__(64), __aligned__(64))); +typedef long long __m512i __attribute__((__vector_size__(64), __aligned__(64))); + +typedef float __m512_u __attribute__((__vector_size__(64), __aligned__(1))); +typedef double __m512d_u __attribute__((__vector_size__(64), __aligned__(1))); +typedef long long __m512i_u __attribute__((__vector_size__(64), __aligned__(1))); + +typedef unsigned char __mmask8; +typedef unsigned short __mmask16; + +/* Rounding mode macros. */ +#define _MM_FROUND_TO_NEAREST_INT 0x00 +#define _MM_FROUND_TO_NEG_INF 0x01 +#define _MM_FROUND_TO_POS_INF 0x02 +#define _MM_FROUND_TO_ZERO 0x03 +#define _MM_FROUND_CUR_DIRECTION 0x04 + +/* Constants for integer comparison predicates */ +typedef enum { + _MM_CMPINT_EQ, /* Equal */ + _MM_CMPINT_LT, /* Less than */ + _MM_CMPINT_LE, /* Less than or Equal */ + _MM_CMPINT_UNUSED, + _MM_CMPINT_NE, /* Not Equal */ + _MM_CMPINT_NLT, /* Not Less than */ +#define _MM_CMPINT_GE _MM_CMPINT_NLT /* Greater than or Equal */ + _MM_CMPINT_NLE /* Not Less than or Equal */ +#define _MM_CMPINT_GT _MM_CMPINT_NLE /* Greater than */ +} _MM_CMPINT_ENUM; + +typedef enum +{ + _MM_PERM_AAAA = 0x00, _MM_PERM_AAAB = 0x01, _MM_PERM_AAAC = 0x02, + _MM_PERM_AAAD = 0x03, _MM_PERM_AABA = 0x04, _MM_PERM_AABB = 0x05, + _MM_PERM_AABC = 0x06, _MM_PERM_AABD = 0x07, _MM_PERM_AACA = 0x08, + _MM_PERM_AACB = 0x09, _MM_PERM_AACC = 0x0A, _MM_PERM_AACD = 0x0B, + _MM_PERM_AADA = 0x0C, _MM_PERM_AADB = 0x0D, _MM_PERM_AADC = 0x0E, + _MM_PERM_AADD = 0x0F, _MM_PERM_ABAA = 0x10, _MM_PERM_ABAB = 0x11, + _MM_PERM_ABAC = 0x12, _MM_PERM_ABAD = 0x13, _MM_PERM_ABBA = 0x14, + _MM_PERM_ABBB = 0x15, _MM_PERM_ABBC = 0x16, _MM_PERM_ABBD = 0x17, + _MM_PERM_ABCA = 0x18, _MM_PERM_ABCB = 0x19, _MM_PERM_ABCC = 0x1A, + _MM_PERM_ABCD = 0x1B, _MM_PERM_ABDA = 0x1C, _MM_PERM_ABDB = 0x1D, + _MM_PERM_ABDC = 0x1E, _MM_PERM_ABDD = 0x1F, _MM_PERM_ACAA = 0x20, + _MM_PERM_ACAB = 0x21, _MM_PERM_ACAC = 0x22, _MM_PERM_ACAD = 0x23, + _MM_PERM_ACBA = 0x24, _MM_PERM_ACBB = 0x25, _MM_PERM_ACBC = 0x26, + _MM_PERM_ACBD = 0x27, _MM_PERM_ACCA = 0x28, _MM_PERM_ACCB = 0x29, + _MM_PERM_ACCC = 0x2A, _MM_PERM_ACCD = 0x2B, _MM_PERM_ACDA = 0x2C, + _MM_PERM_ACDB = 0x2D, _MM_PERM_ACDC = 0x2E, _MM_PERM_ACDD = 0x2F, + _MM_PERM_ADAA = 0x30, _MM_PERM_ADAB = 0x31, _MM_PERM_ADAC = 0x32, + _MM_PERM_ADAD = 0x33, _MM_PERM_ADBA = 0x34, _MM_PERM_ADBB = 0x35, + _MM_PERM_ADBC = 0x36, _MM_PERM_ADBD = 0x37, _MM_PERM_ADCA = 0x38, + _MM_PERM_ADCB = 0x39, _MM_PERM_ADCC = 0x3A, _MM_PERM_ADCD = 0x3B, + _MM_PERM_ADDA = 0x3C, _MM_PERM_ADDB = 0x3D, _MM_PERM_ADDC = 0x3E, + _MM_PERM_ADDD = 0x3F, _MM_PERM_BAAA = 0x40, _MM_PERM_BAAB = 0x41, + _MM_PERM_BAAC = 0x42, _MM_PERM_BAAD = 0x43, _MM_PERM_BABA = 0x44, + _MM_PERM_BABB = 0x45, _MM_PERM_BABC = 0x46, _MM_PERM_BABD = 0x47, + _MM_PERM_BACA = 0x48, _MM_PERM_BACB = 0x49, _MM_PERM_BACC = 0x4A, + _MM_PERM_BACD = 0x4B, _MM_PERM_BADA = 0x4C, _MM_PERM_BADB = 0x4D, + _MM_PERM_BADC = 0x4E, _MM_PERM_BADD = 0x4F, _MM_PERM_BBAA = 0x50, + _MM_PERM_BBAB = 0x51, _MM_PERM_BBAC = 0x52, _MM_PERM_BBAD = 0x53, + _MM_PERM_BBBA = 0x54, _MM_PERM_BBBB = 0x55, _MM_PERM_BBBC = 0x56, + _MM_PERM_BBBD = 0x57, _MM_PERM_BBCA = 0x58, _MM_PERM_BBCB = 0x59, + _MM_PERM_BBCC = 0x5A, _MM_PERM_BBCD = 0x5B, _MM_PERM_BBDA = 0x5C, + _MM_PERM_BBDB = 0x5D, _MM_PERM_BBDC = 0x5E, _MM_PERM_BBDD = 0x5F, + _MM_PERM_BCAA = 0x60, _MM_PERM_BCAB = 0x61, _MM_PERM_BCAC = 0x62, + _MM_PERM_BCAD = 0x63, _MM_PERM_BCBA = 0x64, _MM_PERM_BCBB = 0x65, + _MM_PERM_BCBC = 0x66, _MM_PERM_BCBD = 0x67, _MM_PERM_BCCA = 0x68, + _MM_PERM_BCCB = 0x69, _MM_PERM_BCCC = 0x6A, _MM_PERM_BCCD = 0x6B, + _MM_PERM_BCDA = 0x6C, _MM_PERM_BCDB = 0x6D, _MM_PERM_BCDC = 0x6E, + _MM_PERM_BCDD = 0x6F, _MM_PERM_BDAA = 0x70, _MM_PERM_BDAB = 0x71, + _MM_PERM_BDAC = 0x72, _MM_PERM_BDAD = 0x73, _MM_PERM_BDBA = 0x74, + _MM_PERM_BDBB = 0x75, _MM_PERM_BDBC = 0x76, _MM_PERM_BDBD = 0x77, + _MM_PERM_BDCA = 0x78, _MM_PERM_BDCB = 0x79, _MM_PERM_BDCC = 0x7A, + _MM_PERM_BDCD = 0x7B, _MM_PERM_BDDA = 0x7C, _MM_PERM_BDDB = 0x7D, + _MM_PERM_BDDC = 0x7E, _MM_PERM_BDDD = 0x7F, _MM_PERM_CAAA = 0x80, + _MM_PERM_CAAB = 0x81, _MM_PERM_CAAC = 0x82, _MM_PERM_CAAD = 0x83, + _MM_PERM_CABA = 0x84, _MM_PERM_CABB = 0x85, _MM_PERM_CABC = 0x86, + _MM_PERM_CABD = 0x87, _MM_PERM_CACA = 0x88, _MM_PERM_CACB = 0x89, + _MM_PERM_CACC = 0x8A, _MM_PERM_CACD = 0x8B, _MM_PERM_CADA = 0x8C, + _MM_PERM_CADB = 0x8D, _MM_PERM_CADC = 0x8E, _MM_PERM_CADD = 0x8F, + _MM_PERM_CBAA = 0x90, _MM_PERM_CBAB = 0x91, _MM_PERM_CBAC = 0x92, + _MM_PERM_CBAD = 0x93, _MM_PERM_CBBA = 0x94, _MM_PERM_CBBB = 0x95, + _MM_PERM_CBBC = 0x96, _MM_PERM_CBBD = 0x97, _MM_PERM_CBCA = 0x98, + _MM_PERM_CBCB = 0x99, _MM_PERM_CBCC = 0x9A, _MM_PERM_CBCD = 0x9B, + _MM_PERM_CBDA = 0x9C, _MM_PERM_CBDB = 0x9D, _MM_PERM_CBDC = 0x9E, + _MM_PERM_CBDD = 0x9F, _MM_PERM_CCAA = 0xA0, _MM_PERM_CCAB = 0xA1, + _MM_PERM_CCAC = 0xA2, _MM_PERM_CCAD = 0xA3, _MM_PERM_CCBA = 0xA4, + _MM_PERM_CCBB = 0xA5, _MM_PERM_CCBC = 0xA6, _MM_PERM_CCBD = 0xA7, + _MM_PERM_CCCA = 0xA8, _MM_PERM_CCCB = 0xA9, _MM_PERM_CCCC = 0xAA, + _MM_PERM_CCCD = 0xAB, _MM_PERM_CCDA = 0xAC, _MM_PERM_CCDB = 0xAD, + _MM_PERM_CCDC = 0xAE, _MM_PERM_CCDD = 0xAF, _MM_PERM_CDAA = 0xB0, + _MM_PERM_CDAB = 0xB1, _MM_PERM_CDAC = 0xB2, _MM_PERM_CDAD = 0xB3, + _MM_PERM_CDBA = 0xB4, _MM_PERM_CDBB = 0xB5, _MM_PERM_CDBC = 0xB6, + _MM_PERM_CDBD = 0xB7, _MM_PERM_CDCA = 0xB8, _MM_PERM_CDCB = 0xB9, + _MM_PERM_CDCC = 0xBA, _MM_PERM_CDCD = 0xBB, _MM_PERM_CDDA = 0xBC, + _MM_PERM_CDDB = 0xBD, _MM_PERM_CDDC = 0xBE, _MM_PERM_CDDD = 0xBF, + _MM_PERM_DAAA = 0xC0, _MM_PERM_DAAB = 0xC1, _MM_PERM_DAAC = 0xC2, + _MM_PERM_DAAD = 0xC3, _MM_PERM_DABA = 0xC4, _MM_PERM_DABB = 0xC5, + _MM_PERM_DABC = 0xC6, _MM_PERM_DABD = 0xC7, _MM_PERM_DACA = 0xC8, + _MM_PERM_DACB = 0xC9, _MM_PERM_DACC = 0xCA, _MM_PERM_DACD = 0xCB, + _MM_PERM_DADA = 0xCC, _MM_PERM_DADB = 0xCD, _MM_PERM_DADC = 0xCE, + _MM_PERM_DADD = 0xCF, _MM_PERM_DBAA = 0xD0, _MM_PERM_DBAB = 0xD1, + _MM_PERM_DBAC = 0xD2, _MM_PERM_DBAD = 0xD3, _MM_PERM_DBBA = 0xD4, + _MM_PERM_DBBB = 0xD5, _MM_PERM_DBBC = 0xD6, _MM_PERM_DBBD = 0xD7, + _MM_PERM_DBCA = 0xD8, _MM_PERM_DBCB = 0xD9, _MM_PERM_DBCC = 0xDA, + _MM_PERM_DBCD = 0xDB, _MM_PERM_DBDA = 0xDC, _MM_PERM_DBDB = 0xDD, + _MM_PERM_DBDC = 0xDE, _MM_PERM_DBDD = 0xDF, _MM_PERM_DCAA = 0xE0, + _MM_PERM_DCAB = 0xE1, _MM_PERM_DCAC = 0xE2, _MM_PERM_DCAD = 0xE3, + _MM_PERM_DCBA = 0xE4, _MM_PERM_DCBB = 0xE5, _MM_PERM_DCBC = 0xE6, + _MM_PERM_DCBD = 0xE7, _MM_PERM_DCCA = 0xE8, _MM_PERM_DCCB = 0xE9, + _MM_PERM_DCCC = 0xEA, _MM_PERM_DCCD = 0xEB, _MM_PERM_DCDA = 0xEC, + _MM_PERM_DCDB = 0xED, _MM_PERM_DCDC = 0xEE, _MM_PERM_DCDD = 0xEF, + _MM_PERM_DDAA = 0xF0, _MM_PERM_DDAB = 0xF1, _MM_PERM_DDAC = 0xF2, + _MM_PERM_DDAD = 0xF3, _MM_PERM_DDBA = 0xF4, _MM_PERM_DDBB = 0xF5, + _MM_PERM_DDBC = 0xF6, _MM_PERM_DDBD = 0xF7, _MM_PERM_DDCA = 0xF8, + _MM_PERM_DDCB = 0xF9, _MM_PERM_DDCC = 0xFA, _MM_PERM_DDCD = 0xFB, + _MM_PERM_DDDA = 0xFC, _MM_PERM_DDDB = 0xFD, _MM_PERM_DDDC = 0xFE, + _MM_PERM_DDDD = 0xFF +} _MM_PERM_ENUM; + +typedef enum +{ + _MM_MANT_NORM_1_2, /* interval [1, 2) */ + _MM_MANT_NORM_p5_2, /* interval [0.5, 2) */ + _MM_MANT_NORM_p5_1, /* interval [0.5, 1) */ + _MM_MANT_NORM_p75_1p5 /* interval [0.75, 1.5) */ +} _MM_MANTISSA_NORM_ENUM; + +typedef enum +{ + _MM_MANT_SIGN_src, /* sign = sign(SRC) */ + _MM_MANT_SIGN_zero, /* sign = 0 */ + _MM_MANT_SIGN_nan /* DEST = NaN if sign(SRC) = 1 */ +} _MM_MANTISSA_SIGN_ENUM; + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 __attribute__((__always_inline__, __nodebug__, __target__("avx512f,evex512"), __min_vector_width__(512))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512f,no-evex512"), __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512f,no-evex512"))) + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#define __DEFAULT_FN_ATTRS512_CONSTEXPR __DEFAULT_FN_ATTRS512 constexpr +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr +#else +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS128 +#define __DEFAULT_FN_ATTRS512_CONSTEXPR __DEFAULT_FN_ATTRS512 +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS +#endif + +/* Create vectors with repeated elements */ + +static __inline __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_setzero_si512(void) { + return __extension__(__m512i)(__v8di){0, 0, 0, 0, 0, 0, 0, 0}; +} + +#define _mm512_setzero_epi32 _mm512_setzero_si512 + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_undefined_pd(void) +{ + return (__m512d)__builtin_ia32_undef512(); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_undefined(void) +{ + return (__m512)__builtin_ia32_undef512(); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_undefined_ps(void) +{ + return (__m512)__builtin_ia32_undef512(); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_undefined_epi32(void) +{ + return (__m512i)__builtin_ia32_undef512(); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcastd_epi32 (__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v4si) __A, (__v4si) __A, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcastd_epi32 (__m512i __O, __mmask16 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512(__M, + (__v16si) _mm512_broadcastd_epi32(__A), + (__v16si) __O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcastd_epi32 (__mmask16 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512(__M, + (__v16si) _mm512_broadcastd_epi32(__A), + (__v16si) _mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcastq_epi64 (__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v2di) __A, (__v2di) __A, + 0, 0, 0, 0, 0, 0, 0, 0); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcastq_epi64 (__m512i __O, __mmask8 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di) _mm512_broadcastq_epi64(__A), + (__v8di) __O); + +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcastq_epi64 (__mmask8 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di) _mm512_broadcastq_epi64(__A), + (__v8di) _mm512_setzero_si512()); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_setzero_ps(void) { + return __extension__(__m512){0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; +} + +#define _mm512_setzero _mm512_setzero_ps + +static __inline __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_setzero_pd(void) { + return __extension__(__m512d){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_set1_ps(float __w) +{ + return __extension__ (__m512){ __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w }; +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_set1_pd(double __w) +{ + return __extension__ (__m512d){ __w, __w, __w, __w, __w, __w, __w, __w }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set1_epi8(char __w) +{ + return __extension__ (__m512i)(__v64qi){ + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set1_epi16(short __w) +{ + return __extension__ (__m512i)(__v32hi){ + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set1_epi32(int __s) +{ + return __extension__ (__m512i)(__v16si){ + __s, __s, __s, __s, __s, __s, __s, __s, + __s, __s, __s, __s, __s, __s, __s, __s }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_set1_epi32(__mmask16 __M, int __A) +{ + return (__m512i)__builtin_ia32_selectd_512(__M, + (__v16si)_mm512_set1_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set1_epi64(long long __d) +{ + return __extension__(__m512i)(__v8di){ __d, __d, __d, __d, __d, __d, __d, __d }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_set1_epi64(__mmask8 __M, long long __A) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di)_mm512_set1_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_broadcastss_ps(__m128 __A) +{ + return (__m512)__builtin_shufflevector((__v4sf) __A, (__v4sf) __A, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set4_epi32 (int __A, int __B, int __C, int __D) +{ + return __extension__ (__m512i)(__v16si) + { __D, __C, __B, __A, __D, __C, __B, __A, + __D, __C, __B, __A, __D, __C, __B, __A }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set4_epi64 (long long __A, long long __B, long long __C, + long long __D) +{ + return __extension__ (__m512i) (__v8di) + { __D, __C, __B, __A, __D, __C, __B, __A }; +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_set4_pd (double __A, double __B, double __C, double __D) +{ + return __extension__ (__m512d) + { __D, __C, __B, __A, __D, __C, __B, __A }; +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_set4_ps (float __A, float __B, float __C, float __D) +{ + return __extension__ (__m512) + { __D, __C, __B, __A, __D, __C, __B, __A, + __D, __C, __B, __A, __D, __C, __B, __A }; +} + +#define _mm512_setr4_epi32(e0,e1,e2,e3) \ + _mm512_set4_epi32((e3),(e2),(e1),(e0)) + +#define _mm512_setr4_epi64(e0,e1,e2,e3) \ + _mm512_set4_epi64((e3),(e2),(e1),(e0)) + +#define _mm512_setr4_pd(e0,e1,e2,e3) \ + _mm512_set4_pd((e3),(e2),(e1),(e0)) + +#define _mm512_setr4_ps(e0,e1,e2,e3) \ + _mm512_set4_ps((e3),(e2),(e1),(e0)) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_broadcastsd_pd(__m128d __A) +{ + return (__m512d)__builtin_shufflevector((__v2df) __A, (__v2df) __A, + 0, 0, 0, 0, 0, 0, 0, 0); +} + +/* Cast between vector types */ + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_castpd256_pd512(__m256d __a) +{ + return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), 0, + 1, 2, 3, 4, 5, 6, 7); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_castps256_ps512(__m256 __a) +{ + return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +static __inline __m128d __DEFAULT_FN_ATTRS512 +_mm512_castpd512_pd128(__m512d __a) +{ + return __builtin_shufflevector(__a, __a, 0, 1); +} + +static __inline __m256d __DEFAULT_FN_ATTRS512 +_mm512_castpd512_pd256 (__m512d __A) +{ + return __builtin_shufflevector(__A, __A, 0, 1, 2, 3); +} + +static __inline __m128 __DEFAULT_FN_ATTRS512 +_mm512_castps512_ps128(__m512 __a) +{ + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3); +} + +static __inline __m256 __DEFAULT_FN_ATTRS512 +_mm512_castps512_ps256 (__m512 __A) +{ + return __builtin_shufflevector(__A, __A, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_castpd_ps (__m512d __A) +{ + return (__m512) (__A); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_castpd_si512 (__m512d __A) +{ + return (__m512i) (__A); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_castpd128_pd512 (__m128d __A) +{ + __m256d __B = __builtin_nondeterministic_value(__B); + return __builtin_shufflevector( + __builtin_shufflevector(__A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3), + __B, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_castps_pd (__m512 __A) +{ + return (__m512d) (__A); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_castps_si512 (__m512 __A) +{ + return (__m512i) (__A); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_castps128_ps512 (__m128 __A) +{ + __m256 __B = __builtin_nondeterministic_value(__B); + return __builtin_shufflevector( + __builtin_shufflevector(__A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3, 4, 5, 6, 7), + __B, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_castsi128_si512 (__m128i __A) +{ + __m256i __B = __builtin_nondeterministic_value(__B); + return __builtin_shufflevector( + __builtin_shufflevector(__A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3), + __B, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_castsi256_si512 (__m256i __A) +{ + return __builtin_shufflevector( __A, __builtin_nondeterministic_value(__A), 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_castsi512_ps (__m512i __A) +{ + return (__m512) (__A); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_castsi512_pd (__m512i __A) +{ + return (__m512d) (__A); +} + +static __inline __m128i __DEFAULT_FN_ATTRS512 +_mm512_castsi512_si128 (__m512i __A) +{ + return (__m128i)__builtin_shufflevector(__A, __A , 0, 1); +} + +static __inline __m256i __DEFAULT_FN_ATTRS512 +_mm512_castsi512_si256 (__m512i __A) +{ + return (__m256i)__builtin_shufflevector(__A, __A , 0, 1, 2, 3); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_int2mask(int __a) +{ + return (__mmask16)__a; +} + +static __inline__ int __DEFAULT_FN_ATTRS +_mm512_mask2int(__mmask16 __a) +{ + return (int)__a; +} + +/// Constructs a 512-bit floating-point vector of [8 x double] from a +/// 128-bit floating-point vector of [2 x double]. The lower 128 bits +/// contain the value of the source vector. The upper 384 bits are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 512-bit floating-point vector of [8 x double]. The lower 128 bits +/// contain the value of the parameter. The upper 384 bits are set to zero. +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_zextpd128_pd512(__m128d __a) +{ + return __builtin_shufflevector((__v2df)__a, (__v2df)_mm_setzero_pd(), 0, 1, 2, 3, 2, 3, 2, 3); +} + +/// Constructs a 512-bit floating-point vector of [8 x double] from a +/// 256-bit floating-point vector of [4 x double]. The lower 256 bits +/// contain the value of the source vector. The upper 256 bits are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \returns A 512-bit floating-point vector of [8 x double]. The lower 256 bits +/// contain the value of the parameter. The upper 256 bits are set to zero. +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_zextpd256_pd512(__m256d __a) +{ + return __builtin_shufflevector((__v4df)__a, (__v4df)_mm256_setzero_pd(), 0, 1, 2, 3, 4, 5, 6, 7); +} + +/// Constructs a 512-bit floating-point vector of [16 x float] from a +/// 128-bit floating-point vector of [4 x float]. The lower 128 bits contain +/// the value of the source vector. The upper 384 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 512-bit floating-point vector of [16 x float]. The lower 128 bits +/// contain the value of the parameter. The upper 384 bits are set to zero. +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_zextps128_ps512(__m128 __a) +{ + return __builtin_shufflevector((__v4sf)__a, (__v4sf)_mm_setzero_ps(), 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7); +} + +/// Constructs a 512-bit floating-point vector of [16 x float] from a +/// 256-bit floating-point vector of [8 x float]. The lower 256 bits contain +/// the value of the source vector. The upper 256 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 512-bit floating-point vector of [16 x float]. The lower 256 bits +/// contain the value of the parameter. The upper 256 bits are set to zero. +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_zextps256_ps512(__m256 __a) +{ + return __builtin_shufflevector((__v8sf)__a, (__v8sf)_mm256_setzero_ps(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +/// Constructs a 512-bit integer vector from a 128-bit integer vector. +/// The lower 128 bits contain the value of the source vector. The upper +/// 384 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \returns A 512-bit integer vector. The lower 128 bits contain the value of +/// the parameter. The upper 384 bits are set to zero. +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_zextsi128_si512(__m128i __a) +{ + return __builtin_shufflevector((__v2di)__a, (__v2di)_mm_setzero_si128(), 0, 1, 2, 3, 2, 3, 2, 3); +} + +/// Constructs a 512-bit integer vector from a 256-bit integer vector. +/// The lower 256 bits contain the value of the source vector. The upper +/// 256 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \returns A 512-bit integer vector. The lower 256 bits contain the value of +/// the parameter. The upper 256 bits are set to zero. +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_zextsi256_si512(__m256i __a) +{ + return __builtin_shufflevector((__v4di)__a, (__v4di)_mm256_setzero_si256(), 0, 1, 2, 3, 4, 5, 6, 7); +} + +/* Bitwise operators */ +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_and_epi32(__m512i __a, __m512i __b) +{ + return (__m512i)((__v16su)__a & (__v16su)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_and_epi32(__m512i __src, __mmask16 __k, __m512i __a, __m512i __b) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__k, + (__v16si) _mm512_and_epi32(__a, __b), + (__v16si) __src); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_and_epi32(__mmask16 __k, __m512i __a, __m512i __b) +{ + return (__m512i) _mm512_mask_and_epi32(_mm512_setzero_si512 (), + __k, __a, __b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_and_epi64(__m512i __a, __m512i __b) +{ + return (__m512i)((__v8du)__a & (__v8du)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_and_epi64(__m512i __src, __mmask8 __k, __m512i __a, __m512i __b) +{ + return (__m512i) __builtin_ia32_selectq_512 ((__mmask8) __k, + (__v8di) _mm512_and_epi64(__a, __b), + (__v8di) __src); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_and_epi64(__mmask8 __k, __m512i __a, __m512i __b) +{ + return (__m512i) _mm512_mask_and_epi64(_mm512_setzero_si512 (), + __k, __a, __b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_andnot_si512 (__m512i __A, __m512i __B) +{ + return (__m512i)(~(__v8du)__A & (__v8du)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_andnot_epi32 (__m512i __A, __m512i __B) +{ + return (__m512i)(~(__v16su)__A & (__v16su)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_andnot_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_andnot_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_andnot_epi32(__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)_mm512_mask_andnot_epi32(_mm512_setzero_si512(), + __U, __A, __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_andnot_epi64(__m512i __A, __m512i __B) +{ + return (__m512i)(~(__v8du)__A & (__v8du)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_andnot_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_andnot_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_andnot_epi64(__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)_mm512_mask_andnot_epi64(_mm512_setzero_si512(), + __U, __A, __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_or_epi32(__m512i __a, __m512i __b) +{ + return (__m512i)((__v16su)__a | (__v16su)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_or_epi32(__m512i __src, __mmask16 __k, __m512i __a, __m512i __b) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__k, + (__v16si)_mm512_or_epi32(__a, __b), + (__v16si)__src); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_or_epi32(__mmask16 __k, __m512i __a, __m512i __b) +{ + return (__m512i)_mm512_mask_or_epi32(_mm512_setzero_si512(), __k, __a, __b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_or_epi64(__m512i __a, __m512i __b) +{ + return (__m512i)((__v8du)__a | (__v8du)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_or_epi64(__m512i __src, __mmask8 __k, __m512i __a, __m512i __b) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__k, + (__v8di)_mm512_or_epi64(__a, __b), + (__v8di)__src); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_or_epi64(__mmask8 __k, __m512i __a, __m512i __b) +{ + return (__m512i)_mm512_mask_or_epi64(_mm512_setzero_si512(), __k, __a, __b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_xor_epi32(__m512i __a, __m512i __b) +{ + return (__m512i)((__v16su)__a ^ (__v16su)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_xor_epi32(__m512i __src, __mmask16 __k, __m512i __a, __m512i __b) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__k, + (__v16si)_mm512_xor_epi32(__a, __b), + (__v16si)__src); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_xor_epi32(__mmask16 __k, __m512i __a, __m512i __b) +{ + return (__m512i)_mm512_mask_xor_epi32(_mm512_setzero_si512(), __k, __a, __b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_xor_epi64(__m512i __a, __m512i __b) +{ + return (__m512i)((__v8du)__a ^ (__v8du)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_xor_epi64(__m512i __src, __mmask8 __k, __m512i __a, __m512i __b) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__k, + (__v8di)_mm512_xor_epi64(__a, __b), + (__v8di)__src); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_xor_epi64(__mmask8 __k, __m512i __a, __m512i __b) +{ + return (__m512i)_mm512_mask_xor_epi64(_mm512_setzero_si512(), __k, __a, __b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_and_si512(__m512i __a, __m512i __b) +{ + return (__m512i)((__v8du)__a & (__v8du)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_or_si512(__m512i __a, __m512i __b) +{ + return (__m512i)((__v8du)__a | (__v8du)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_xor_si512(__m512i __a, __m512i __b) +{ + return (__m512i)((__v8du)__a ^ (__v8du)__b); +} + +/* Arithmetic */ + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_add_pd(__m512d __a, __m512d __b) +{ + return (__m512d)((__v8df)__a + (__v8df)__b); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_add_ps(__m512 __a, __m512 __b) +{ + return (__m512)((__v16sf)__a + (__v16sf)__b); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_mul_pd(__m512d __a, __m512d __b) +{ + return (__m512d)((__v8df)__a * (__v8df)__b); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_mul_ps(__m512 __a, __m512 __b) +{ + return (__m512)((__v16sf)__a * (__v16sf)__b); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_sub_pd(__m512d __a, __m512d __b) +{ + return (__m512d)((__v8df)__a - (__v8df)__b); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_sub_ps(__m512 __a, __m512 __b) +{ + return (__m512)((__v16sf)__a - (__v16sf)__b); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_add_epi64 (__m512i __A, __m512i __B) +{ + return (__m512i) ((__v8du) __A + (__v8du) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_add_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_add_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_epi64(__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_add_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sub_epi64 (__m512i __A, __m512i __B) +{ + return (__m512i) ((__v8du) __A - (__v8du) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sub_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_epi64(__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sub_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_add_epi32 (__m512i __A, __m512i __B) +{ + return (__m512i) ((__v16su) __A + (__v16su) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_add_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_add_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_epi32 (__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_add_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sub_epi32 (__m512i __A, __m512i __B) +{ + return (__m512i) ((__v16su) __A - (__v16su) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sub_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_epi32(__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sub_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +#define _mm512_max_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_maxpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(R))) + +#define _mm512_mask_max_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_max_round_pd((A), (B), (R)), \ + (__v8df)(W))) + +#define _mm512_maskz_max_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_max_round_pd((A), (B), (R)), \ + (__v8df)_mm512_setzero_pd())) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_max_pd(__m512d __A, __m512d __B) +{ + return (__m512d) __builtin_ia32_maxpd512((__v8df) __A, (__v8df) __B, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_max_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_max_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_pd (__mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_max_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +#define _mm512_max_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_maxps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(R))) + +#define _mm512_mask_max_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_max_round_ps((A), (B), (R)), \ + (__v16sf)(W))) + +#define _mm512_maskz_max_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_max_round_ps((A), (B), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_max_ps(__m512 __A, __m512 __B) +{ + return (__m512) __builtin_ia32_maxps512((__v16sf) __A, (__v16sf) __B, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_max_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_max_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_ps (__mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_max_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_max_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_maxss_round_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_max_ss(__mmask8 __U,__m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_maxss_round_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_max_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_maxss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_max_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_maxss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm_maskz_max_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_maxss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_max_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) { + return (__m128d) __builtin_ia32_maxsd_round_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_max_sd(__mmask8 __U,__m128d __A, __m128d __B) { + return (__m128d) __builtin_ia32_maxsd_round_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_max_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_maxsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_max_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_maxsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_max_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_maxsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline __m512i +__DEFAULT_FN_ATTRS512 +_mm512_max_epi32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v16si)__A, (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epi32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_max_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epi32 (__mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_max_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epu32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v16su)__A, (__v16su)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epu32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_max_epu32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epu32 (__mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_max_epu32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epi64(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v8di)__A, (__v8di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epi64 (__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_max_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epi64 (__mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_max_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_max_epu64(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_max((__v8du)__A, (__v8du)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_max_epu64 (__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_max_epu64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_epu64 (__mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_max_epu64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +#define _mm512_min_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_minpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(R))) + +#define _mm512_mask_min_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_min_round_pd((A), (B), (R)), \ + (__v8df)(W))) + +#define _mm512_maskz_min_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_min_round_pd((A), (B), (R)), \ + (__v8df)_mm512_setzero_pd())) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_min_pd(__m512d __A, __m512d __B) +{ + return (__m512d) __builtin_ia32_minpd512((__v8df) __A, (__v8df) __B, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_min_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_min_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_pd (__mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_min_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +#define _mm512_min_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_minps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(R))) + +#define _mm512_mask_min_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_min_round_ps((A), (B), (R)), \ + (__v16sf)(W))) + +#define _mm512_maskz_min_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_min_round_ps((A), (B), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_min_ps(__m512 __A, __m512 __B) +{ + return (__m512) __builtin_ia32_minps512((__v16sf) __A, (__v16sf) __B, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_min_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_min_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_ps (__mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_min_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_min_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_minss_round_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_min_ss(__mmask8 __U,__m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_minss_round_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_min_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_minss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_min_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_minss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm_maskz_min_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_minss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_min_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) { + return (__m128d) __builtin_ia32_minsd_round_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_min_sd(__mmask8 __U,__m128d __A, __m128d __B) { + return (__m128d) __builtin_ia32_minsd_round_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_min_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_minsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_min_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_minsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_min_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_minsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline __m512i +__DEFAULT_FN_ATTRS512 +_mm512_min_epi32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v16si)__A, (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epi32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_min_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epi32 (__mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_min_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epu32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v16su)__A, (__v16su)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epu32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_min_epu32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epu32 (__mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_min_epu32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epi64(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v8di)__A, (__v8di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epi64 (__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_min_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epi64 (__mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_min_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_min_epu64(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_elementwise_min((__v8du)__A, (__v8du)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_min_epu64 (__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_min_epu64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_epu64 (__mmask8 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_min_epu64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mul_epi32(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_pmuldq512((__v16si)__X, (__v16si) __Y); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mul_epi32(__m512i __W, __mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_mul_epi32(__X, __Y), + (__v8di)__W); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mul_epi32(__mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_mul_epi32(__X, __Y), + (__v8di)_mm512_setzero_si512 ()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mul_epu32(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_pmuludq512((__v16si)__X, (__v16si)__Y); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mul_epu32(__m512i __W, __mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_mul_epu32(__X, __Y), + (__v8di)__W); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mul_epu32(__mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_mul_epu32(__X, __Y), + (__v8di)_mm512_setzero_si512 ()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mullo_epi32 (__m512i __A, __m512i __B) +{ + return (__m512i) ((__v16su) __A * (__v16su) __B); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mullo_epi32(__mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_mullo_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mullo_epi32(__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_mullo_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mullox_epi64 (__m512i __A, __m512i __B) { + return (__m512i) ((__v8du) __A * (__v8du) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mullox_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_mullox_epi64(__A, __B), + (__v8di)__W); +} + +#define _mm512_sqrt_round_pd(A, R) \ + ((__m512d)__builtin_ia32_sqrtpd512((__v8df)(__m512d)(A), (int)(R))) + +#define _mm512_mask_sqrt_round_pd(W, U, A, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_sqrt_round_pd((A), (R)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_sqrt_round_pd(U, A, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_sqrt_round_pd((A), (R)), \ + (__v8df)_mm512_setzero_pd())) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_sqrt_pd(__m512d __A) +{ + return (__m512d)__builtin_ia32_sqrtpd512((__v8df)__A, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_sqrt_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_sqrt_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_sqrt_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_sqrt_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +#define _mm512_sqrt_round_ps(A, R) \ + ((__m512)__builtin_ia32_sqrtps512((__v16sf)(__m512)(A), (int)(R))) + +#define _mm512_mask_sqrt_round_ps(W, U, A, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_sqrt_round_ps((A), (R)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_sqrt_round_ps(U, A, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_sqrt_round_ps((A), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_sqrt_ps(__m512 __A) +{ + return (__m512)__builtin_ia32_sqrtps512((__v16sf)__A, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_sqrt_ps(__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_sqrt_ps(__A), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_sqrt_ps( __mmask16 __U, __m512 __A) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_sqrt_ps(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_rsqrt14_pd(__m512d __A) +{ + return (__m512d) __builtin_ia32_rsqrt14pd512_mask ((__v8df) __A, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) -1);} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_rsqrt14_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_rsqrt14pd512_mask ((__v8df) __A, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_rsqrt14_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_rsqrt14pd512_mask ((__v8df) __A, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_rsqrt14_ps(__m512 __A) +{ + return (__m512) __builtin_ia32_rsqrt14ps512_mask ((__v16sf) __A, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) -1); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_rsqrt14_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_rsqrt14ps512_mask ((__v16sf) __A, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_rsqrt14_ps (__mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_rsqrt14ps512_mask ((__v16sf) __A, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_rsqrt14_ss(__m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_rsqrt14ss_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_rsqrt14_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_rsqrt14ss_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt14_ss (__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_rsqrt14ss_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_rsqrt14_sd(__m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_rsqrt14sd_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) + _mm_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_rsqrt14_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_rsqrt14sd_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt14_sd (__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_rsqrt14sd_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_rcp14_pd(__m512d __A) +{ + return (__m512d) __builtin_ia32_rcp14pd512_mask ((__v8df) __A, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_rcp14_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_rcp14pd512_mask ((__v8df) __A, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_rcp14_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_rcp14pd512_mask ((__v8df) __A, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_rcp14_ps(__m512 __A) +{ + return (__m512) __builtin_ia32_rcp14ps512_mask ((__v16sf) __A, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) -1); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_rcp14_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_rcp14ps512_mask ((__v16sf) __A, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_rcp14_ps (__mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_rcp14ps512_mask ((__v16sf) __A, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_rcp14_ss(__m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_rcp14ss_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_rcp14_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_rcp14ss_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_rcp14_ss (__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_rcp14ss_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_rcp14_sd(__m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_rcp14sd_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) + _mm_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_rcp14_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_rcp14sd_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_rcp14_sd (__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_rcp14sd_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_floor_ps(__m512 __A) +{ + return (__m512) __builtin_ia32_rndscaleps_mask ((__v16sf) __A, + _MM_FROUND_FLOOR, + (__v16sf) __A, (unsigned short)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_floor_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_rndscaleps_mask ((__v16sf) __A, + _MM_FROUND_FLOOR, + (__v16sf) __W, __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_floor_pd(__m512d __A) +{ + return (__m512d) __builtin_ia32_rndscalepd_mask ((__v8df) __A, + _MM_FROUND_FLOOR, + (__v8df) __A, (unsigned char)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_floor_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_rndscalepd_mask ((__v8df) __A, + _MM_FROUND_FLOOR, + (__v8df) __W, __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_ceil_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_rndscaleps_mask ((__v16sf) __A, + _MM_FROUND_CEIL, + (__v16sf) __W, __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_ceil_ps(__m512 __A) +{ + return (__m512) __builtin_ia32_rndscaleps_mask ((__v16sf) __A, + _MM_FROUND_CEIL, + (__v16sf) __A, (unsigned short)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_ceil_pd(__m512d __A) +{ + return (__m512d) __builtin_ia32_rndscalepd_mask ((__v8df) __A, + _MM_FROUND_CEIL, + (__v8df) __A, (unsigned char)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_ceil_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_rndscalepd_mask ((__v8df) __A, + _MM_FROUND_CEIL, + (__v8df) __W, __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_abs_epi64(__m512i __A) +{ + return (__m512i)__builtin_elementwise_abs((__v8di)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_abs_epi64 (__m512i __W, __mmask8 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_abs_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_abs_epi64 (__mmask8 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_abs_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_abs_epi32(__m512i __A) +{ + return (__m512i)__builtin_elementwise_abs((__v16si) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_abs_epi32 (__m512i __W, __mmask16 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_abs_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_abs_epi32 (__mmask16 __U, __m512i __A) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_abs_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_add_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_add_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, __W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_add_ss(__mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_add_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, _mm_setzero_ps()); +} + +#define _mm_add_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_addss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_add_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_addss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm_maskz_add_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_addss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_add_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_add_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, __W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_add_sd(__mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_add_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, _mm_setzero_pd()); +} +#define _mm_add_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_addsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_add_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_addsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_add_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_addsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_add_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_add_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_add_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_add_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_add_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_add_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +#define _mm512_add_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_addpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(R))) + +#define _mm512_mask_add_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_add_round_pd((A), (B), (R)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_add_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_add_round_pd((A), (B), (R)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_add_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_addps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(R))) + +#define _mm512_mask_add_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_add_round_ps((A), (B), (R)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_add_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_add_round_ps((A), (B), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_sub_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_sub_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, __W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_ss(__mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_sub_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, _mm_setzero_ps()); +} +#define _mm_sub_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_subss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_sub_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_subss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm_maskz_sub_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_subss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_sub_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_sub_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, __W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_sd(__mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_sub_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, _mm_setzero_pd()); +} + +#define _mm_sub_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_subsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_sub_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_subsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_sub_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_subsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_sub_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_sub_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_sub_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_sub_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +#define _mm512_sub_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_subpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(R))) + +#define _mm512_mask_sub_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_sub_round_pd((A), (B), (R)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_sub_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_sub_round_pd((A), (B), (R)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_sub_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_subps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(R))) + +#define _mm512_mask_sub_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_sub_round_ps((A), (B), (R)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_sub_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_sub_round_ps((A), (B), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_mul_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_mul_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, __W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_ss(__mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_mul_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, _mm_setzero_ps()); +} +#define _mm_mul_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_mulss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_mul_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_mulss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm_maskz_mul_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_mulss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_mul_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_mul_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, __W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_sd(__mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_mul_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, _mm_setzero_pd()); +} + +#define _mm_mul_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_mulsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_mul_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_mulsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_mul_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_mulsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_mul_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_mul_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_mul_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_mul_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_mul_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_mul_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_mul_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_mul_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +#define _mm512_mul_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_mulpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(R))) + +#define _mm512_mask_mul_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_mul_round_pd((A), (B), (R)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_mul_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_mul_round_pd((A), (B), (R)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_mul_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_mulps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(R))) + +#define _mm512_mask_mul_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_mul_round_ps((A), (B), (R)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_mul_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_mul_round_ps((A), (B), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_div_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_div_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, __W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_div_ss(__mmask8 __U,__m128 __A, __m128 __B) { + __A = _mm_div_ss(__A, __B); + return __builtin_ia32_selectss_128(__U, __A, _mm_setzero_ps()); +} + +#define _mm_div_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_divss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_div_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_divss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm_maskz_div_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_divss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_div_sd(__m128d __W, __mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_div_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, __W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_div_sd(__mmask8 __U,__m128d __A, __m128d __B) { + __A = _mm_div_sd(__A, __B); + return __builtin_ia32_selectsd_128(__U, __A, _mm_setzero_pd()); +} + +#define _mm_div_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_divsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_div_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_divsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_div_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_divsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_div_pd(__m512d __a, __m512d __b) +{ + return (__m512d)((__v8df)__a/(__v8df)__b); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_div_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_div_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_div_pd(__mmask8 __U, __m512d __A, __m512d __B) { + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_div_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_div_ps(__m512 __a, __m512 __b) +{ + return (__m512)((__v16sf)__a/(__v16sf)__b); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_div_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_div_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_div_ps(__mmask16 __U, __m512 __A, __m512 __B) { + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_div_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +#define _mm512_div_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_divpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(R))) + +#define _mm512_mask_div_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_div_round_pd((A), (B), (R)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_div_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_div_round_pd((A), (B), (R)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_div_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_divps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(R))) + +#define _mm512_mask_div_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_div_round_ps((A), (B), (R)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_div_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_div_round_ps((A), (B), (R)), \ + (__v16sf)_mm512_setzero_ps())) + +#define _mm512_roundscale_ps(A, B) \ + ((__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(A), (int)(B), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_roundscale_ps(A, B, C, imm) \ + ((__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(C), (int)(imm), \ + (__v16sf)(__m512)(A), (__mmask16)(B), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_roundscale_ps(A, B, imm) \ + ((__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(B), (int)(imm), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(A), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_roundscale_round_ps(A, B, C, imm, R) \ + ((__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(C), (int)(imm), \ + (__v16sf)(__m512)(A), (__mmask16)(B), \ + (int)(R))) + +#define _mm512_maskz_roundscale_round_ps(A, B, imm, R) \ + ((__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(B), (int)(imm), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(A), (int)(R))) + +#define _mm512_roundscale_round_ps(A, imm, R) \ + ((__m512)__builtin_ia32_rndscaleps_mask((__v16sf)(__m512)(A), (int)(imm), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_roundscale_pd(A, B) \ + ((__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(A), (int)(B), \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_roundscale_pd(A, B, C, imm) \ + ((__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(C), (int)(imm), \ + (__v8df)(__m512d)(A), (__mmask8)(B), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_roundscale_pd(A, B, imm) \ + ((__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(B), (int)(imm), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(A), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_roundscale_round_pd(A, B, C, imm, R) \ + ((__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(C), (int)(imm), \ + (__v8df)(__m512d)(A), (__mmask8)(B), \ + (int)(R))) + +#define _mm512_maskz_roundscale_round_pd(A, B, imm, R) \ + ((__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(B), (int)(imm), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(A), (int)(R))) + +#define _mm512_roundscale_round_pd(A, imm, R) \ + ((__m512d)__builtin_ia32_rndscalepd_mask((__v8df)(__m512d)(A), (int)(imm), \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_fmadd_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)-1, (int)(R))) + + +#define _mm512_mask_fmadd_round_pd(A, U, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_mask3_fmadd_round_pd(A, B, C, U, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask3((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_maskz_fmadd_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_maskz((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_fmsub_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)-1, (int)(R))) + + +#define _mm512_mask_fmsub_round_pd(A, U, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_maskz_fmsub_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_maskz((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_fnmadd_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask(-(__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)-1, (int)(R))) + + +#define _mm512_mask3_fnmadd_round_pd(A, B, C, U, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask3(-(__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_maskz_fnmadd_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_maskz(-(__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_fnmsub_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask(-(__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)-1, (int)(R))) + + +#define _mm512_maskz_fnmsub_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_maskz(-(__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_fmadd_pd(__m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_fmadd_pd(__m512d __A, __mmask8 __U, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmadd_pd(__m512d __A, __m512d __B, __m512d __C, __mmask8 __U) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask3 ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmadd_pd(__mmask8 __U, __m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_maskz ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_fmsub_pd(__m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsub_pd(__m512d __A, __mmask8 __U, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmsub_pd(__mmask8 __U, __m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_maskz ((__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_fnmadd_pd(__m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + -(__v8df) __B, + (__v8df) __C, + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask3_fnmadd_pd(__m512d __A, __m512d __B, __m512d __C, __mmask8 __U) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask3 (-(__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_fnmadd_pd(__mmask8 __U, __m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_maskz (-(__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_fnmsub_pd(__m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + -(__v8df) __B, + -(__v8df) __C, + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_fnmsub_pd(__mmask8 __U, __m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_maskz (-(__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmadd_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)-1, (int)(R))) + + +#define _mm512_mask_fmadd_round_ps(A, U, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_mask3_fmadd_round_ps(A, B, C, U, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask3((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_maskz_fmadd_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_maskz((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_fmsub_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)-1, (int)(R))) + + +#define _mm512_mask_fmsub_round_ps(A, U, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_maskz_fmsub_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_maskz((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_fnmadd_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + -(__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)-1, (int)(R))) + + +#define _mm512_mask3_fnmadd_round_ps(A, B, C, U, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask3(-(__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_maskz_fnmadd_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_maskz(-(__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_fnmsub_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + -(__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)-1, (int)(R))) + + +#define _mm512_maskz_fnmsub_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_maskz(-(__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_fmadd_ps(__m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_fmadd_ps(__m512 __A, __mmask16 __U, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmadd_ps(__m512 __A, __m512 __B, __m512 __C, __mmask16 __U) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask3 ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmadd_ps(__mmask16 __U, __m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_maskz ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_fmsub_ps(__m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsub_ps(__m512 __A, __mmask16 __U, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmsub_ps(__mmask16 __U, __m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_maskz ((__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_fnmadd_ps(__m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + -(__v16sf) __B, + (__v16sf) __C, + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask3_fnmadd_ps(__m512 __A, __m512 __B, __m512 __C, __mmask16 __U) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask3 (-(__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_fnmadd_ps(__mmask16 __U, __m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_maskz (-(__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_fnmsub_ps(__m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + -(__v16sf) __B, + -(__v16sf) __C, + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_fnmsub_ps(__mmask16 __U, __m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_maskz (-(__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmaddsub_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)-1, (int)(R))) + + +#define _mm512_mask_fmaddsub_round_pd(A, U, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_mask3_fmaddsub_round_pd(A, B, C, U, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_mask3((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_maskz_fmaddsub_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_maskz((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_fmsubadd_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)-1, (int)(R))) + + +#define _mm512_mask_fmsubadd_round_pd(A, U, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_maskz_fmsubadd_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddsubpd512_maskz((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_fmaddsub_pd(__m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_fmaddsub_pd(__m512d __A, __mmask8 __U, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmaddsub_pd(__m512d __A, __m512d __B, __m512d __C, __mmask8 __U) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_mask3 ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmaddsub_pd(__mmask8 __U, __m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_maskz ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_fmsubadd_pd(__m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_mask ((__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsubadd_pd(__m512d __A, __mmask8 __U, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_mask ((__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmsubadd_pd(__mmask8 __U, __m512d __A, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddsubpd512_maskz ((__v8df) __A, + (__v8df) __B, + -(__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmaddsub_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)-1, (int)(R))) + + +#define _mm512_mask_fmaddsub_round_ps(A, U, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_mask3_fmaddsub_round_ps(A, B, C, U, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_mask3((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_maskz_fmaddsub_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_maskz((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_fmsubadd_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)-1, (int)(R))) + + +#define _mm512_mask_fmsubadd_round_ps(A, U, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_maskz_fmsubadd_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddsubps512_maskz((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_fmaddsub_ps(__m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_fmaddsub_ps(__m512 __A, __mmask16 __U, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmaddsub_ps(__m512 __A, __m512 __B, __m512 __C, __mmask16 __U) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_mask3 ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmaddsub_ps(__mmask16 __U, __m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_maskz ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_fmsubadd_ps(__m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_mask ((__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsubadd_ps(__m512 __A, __mmask16 __U, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_mask ((__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmsubadd_ps(__mmask16 __U, __m512 __A, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddsubps512_maskz ((__v16sf) __A, + (__v16sf) __B, + -(__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask3_fmsub_round_pd(A, B, C, U, R) \ + ((__m512d)__builtin_ia32_vfmsubpd512_mask3((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmsub_pd(__m512d __A, __m512d __B, __m512d __C, __mmask8 __U) +{ + return (__m512d)__builtin_ia32_vfmsubpd512_mask3 ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask3_fmsub_round_ps(A, B, C, U, R) \ + ((__m512)__builtin_ia32_vfmsubps512_mask3((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmsub_ps(__m512 __A, __m512 __B, __m512 __C, __mmask16 __U) +{ + return (__m512)__builtin_ia32_vfmsubps512_mask3 ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask3_fmsubadd_round_pd(A, B, C, U, R) \ + ((__m512d)__builtin_ia32_vfmsubaddpd512_mask3((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmsubadd_pd(__m512d __A, __m512d __B, __m512d __C, __mmask8 __U) +{ + return (__m512d)__builtin_ia32_vfmsubaddpd512_mask3 ((__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask3_fmsubadd_round_ps(A, B, C, U, R) \ + ((__m512)__builtin_ia32_vfmsubaddps512_mask3((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmsubadd_ps(__m512 __A, __m512 __B, __m512 __C, __mmask16 __U) +{ + return (__m512)__builtin_ia32_vfmsubaddps512_mask3 ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fnmadd_round_pd(A, U, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \ + -(__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_fnmadd_pd(__m512d __A, __mmask8 __U, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + -(__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fnmadd_round_ps(A, U, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + -(__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_fnmadd_ps(__m512 __A, __mmask16 __U, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + -(__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fnmsub_round_pd(A, U, B, C, R) \ + ((__m512d)__builtin_ia32_vfmaddpd512_mask((__v8df)(__m512d)(A), \ + -(__v8df)(__m512d)(B), \ + -(__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +#define _mm512_mask3_fnmsub_round_pd(A, B, C, U, R) \ + ((__m512d)__builtin_ia32_vfmsubpd512_mask3(-(__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(C), \ + (__mmask8)(U), (int)(R))) + + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_fnmsub_pd(__m512d __A, __mmask8 __U, __m512d __B, __m512d __C) +{ + return (__m512d) __builtin_ia32_vfmaddpd512_mask ((__v8df) __A, + -(__v8df) __B, + -(__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask3_fnmsub_pd(__m512d __A, __m512d __B, __m512d __C, __mmask8 __U) +{ + return (__m512d) __builtin_ia32_vfmsubpd512_mask3 (-(__v8df) __A, + (__v8df) __B, + (__v8df) __C, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fnmsub_round_ps(A, U, B, C, R) \ + ((__m512)__builtin_ia32_vfmaddps512_mask((__v16sf)(__m512)(A), \ + -(__v16sf)(__m512)(B), \ + -(__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +#define _mm512_mask3_fnmsub_round_ps(A, B, C, U, R) \ + ((__m512)__builtin_ia32_vfmsubps512_mask3(-(__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(C), \ + (__mmask16)(U), (int)(R))) + + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_fnmsub_ps(__m512 __A, __mmask16 __U, __m512 __B, __m512 __C) +{ + return (__m512) __builtin_ia32_vfmaddps512_mask ((__v16sf) __A, + -(__v16sf) __B, + -(__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask3_fnmsub_ps(__m512 __A, __m512 __B, __m512 __C, __mmask16 __U) +{ + return (__m512) __builtin_ia32_vfmsubps512_mask3 (-(__v16sf) __A, + (__v16sf) __B, + (__v16sf) __C, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + + + +/* Vector permutations */ + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_epi32(__m512i __A, __m512i __I, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpermi2vard512((__v16si)__A, (__v16si) __I, + (__v16si) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_permutex2var_epi32(__m512i __A, __mmask16 __U, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_permutex2var_epi32(__A, __I, __B), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask2_permutex2var_epi32(__m512i __A, __m512i __I, __mmask16 __U, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_permutex2var_epi32(__A, __I, __B), + (__v16si)__I); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutex2var_epi32(__mmask16 __U, __m512i __A, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_permutex2var_epi32(__A, __I, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_epi64(__m512i __A, __m512i __I, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpermi2varq512((__v8di)__A, (__v8di) __I, + (__v8di) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_permutex2var_epi64(__m512i __A, __mmask8 __U, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_permutex2var_epi64(__A, __I, __B), + (__v8di)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask2_permutex2var_epi64(__m512i __A, __m512i __I, __mmask8 __U, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_permutex2var_epi64(__A, __I, __B), + (__v8di)__I); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutex2var_epi64(__mmask8 __U, __m512i __A, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_permutex2var_epi64(__A, __I, __B), + (__v8di)_mm512_setzero_si512()); +} + +#define _mm512_alignr_epi64(A, B, I) \ + ((__m512i)__builtin_ia32_alignq512((__v8di)(__m512i)(A), \ + (__v8di)(__m512i)(B), (int)(I))) + +#define _mm512_mask_alignr_epi64(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_alignr_epi64((A), (B), (imm)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_alignr_epi64(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_alignr_epi64((A), (B), (imm)), \ + (__v8di)_mm512_setzero_si512())) + +#define _mm512_alignr_epi32(A, B, I) \ + ((__m512i)__builtin_ia32_alignd512((__v16si)(__m512i)(A), \ + (__v16si)(__m512i)(B), (int)(I))) + +#define _mm512_mask_alignr_epi32(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_alignr_epi32((A), (B), (imm)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_alignr_epi32(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_alignr_epi32((A), (B), (imm)), \ + (__v16si)_mm512_setzero_si512())) +/* Vector Extract */ + +#define _mm512_extractf64x4_pd(A, I) \ + ((__m256d)__builtin_ia32_extractf64x4_mask((__v8df)(__m512d)(A), (int)(I), \ + (__v4df)_mm256_undefined_pd(), \ + (__mmask8)-1)) + +#define _mm512_mask_extractf64x4_pd(W, U, A, imm) \ + ((__m256d)__builtin_ia32_extractf64x4_mask((__v8df)(__m512d)(A), (int)(imm), \ + (__v4df)(__m256d)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extractf64x4_pd(U, A, imm) \ + ((__m256d)__builtin_ia32_extractf64x4_mask((__v8df)(__m512d)(A), (int)(imm), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm512_extractf32x4_ps(A, I) \ + ((__m128)__builtin_ia32_extractf32x4_mask((__v16sf)(__m512)(A), (int)(I), \ + (__v4sf)_mm_undefined_ps(), \ + (__mmask8)-1)) + +#define _mm512_mask_extractf32x4_ps(W, U, A, imm) \ + ((__m128)__builtin_ia32_extractf32x4_mask((__v16sf)(__m512)(A), (int)(imm), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extractf32x4_ps(U, A, imm) \ + ((__m128)__builtin_ia32_extractf32x4_mask((__v16sf)(__m512)(A), (int)(imm), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U))) + +/* Vector Blend */ + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_pd(__mmask8 __U, __m512d __A, __m512d __W) +{ + return (__m512d) __builtin_ia32_selectpd_512 ((__mmask8) __U, + (__v8df) __W, + (__v8df) __A); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_ps(__mmask16 __U, __m512 __A, __m512 __W) +{ + return (__m512) __builtin_ia32_selectps_512 ((__mmask16) __U, + (__v16sf) __W, + (__v16sf) __A); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_epi64(__mmask8 __U, __m512i __A, __m512i __W) +{ + return (__m512i) __builtin_ia32_selectq_512 ((__mmask8) __U, + (__v8di) __W, + (__v8di) __A); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_epi32(__mmask16 __U, __m512i __A, __m512i __W) +{ + return (__m512i) __builtin_ia32_selectd_512 ((__mmask16) __U, + (__v16si) __W, + (__v16si) __A); +} + +/* Compare */ + +#define _mm512_cmp_round_ps_mask(A, B, P, R) \ + ((__mmask16)__builtin_ia32_cmpps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(P), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cmp_round_ps_mask(U, A, B, P, R) \ + ((__mmask16)__builtin_ia32_cmpps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(P), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_cmp_ps_mask(A, B, P) \ + _mm512_cmp_round_ps_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION) +#define _mm512_mask_cmp_ps_mask(U, A, B, P) \ + _mm512_mask_cmp_round_ps_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION) + +#define _mm512_cmpeq_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_EQ_OQ) +#define _mm512_mask_cmpeq_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_EQ_OQ) + +#define _mm512_cmplt_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_LT_OS) +#define _mm512_mask_cmplt_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_LT_OS) + +#define _mm512_cmple_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_LE_OS) +#define _mm512_mask_cmple_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_LE_OS) + +#define _mm512_cmpunord_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_UNORD_Q) +#define _mm512_mask_cmpunord_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_UNORD_Q) + +#define _mm512_cmpneq_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_NEQ_UQ) +#define _mm512_mask_cmpneq_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NEQ_UQ) + +#define _mm512_cmpnlt_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_NLT_US) +#define _mm512_mask_cmpnlt_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NLT_US) + +#define _mm512_cmpnle_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_NLE_US) +#define _mm512_mask_cmpnle_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_NLE_US) + +#define _mm512_cmpord_ps_mask(A, B) \ + _mm512_cmp_ps_mask((A), (B), _CMP_ORD_Q) +#define _mm512_mask_cmpord_ps_mask(k, A, B) \ + _mm512_mask_cmp_ps_mask((k), (A), (B), _CMP_ORD_Q) + +#define _mm512_cmp_round_pd_mask(A, B, P, R) \ + ((__mmask8)__builtin_ia32_cmppd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(P), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cmp_round_pd_mask(U, A, B, P, R) \ + ((__mmask8)__builtin_ia32_cmppd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(P), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_cmp_pd_mask(A, B, P) \ + _mm512_cmp_round_pd_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION) +#define _mm512_mask_cmp_pd_mask(U, A, B, P) \ + _mm512_mask_cmp_round_pd_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION) + +#define _mm512_cmpeq_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_EQ_OQ) +#define _mm512_mask_cmpeq_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_EQ_OQ) + +#define _mm512_cmplt_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_LT_OS) +#define _mm512_mask_cmplt_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_LT_OS) + +#define _mm512_cmple_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_LE_OS) +#define _mm512_mask_cmple_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_LE_OS) + +#define _mm512_cmpunord_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_UNORD_Q) +#define _mm512_mask_cmpunord_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_UNORD_Q) + +#define _mm512_cmpneq_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_NEQ_UQ) +#define _mm512_mask_cmpneq_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NEQ_UQ) + +#define _mm512_cmpnlt_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_NLT_US) +#define _mm512_mask_cmpnlt_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NLT_US) + +#define _mm512_cmpnle_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_NLE_US) +#define _mm512_mask_cmpnle_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_NLE_US) + +#define _mm512_cmpord_pd_mask(A, B) \ + _mm512_cmp_pd_mask((A), (B), _CMP_ORD_Q) +#define _mm512_mask_cmpord_pd_mask(k, A, B) \ + _mm512_mask_cmp_pd_mask((k), (A), (B), _CMP_ORD_Q) + +/* Conversion */ + +#define _mm512_cvtt_roundps_epu32(A, R) \ + ((__m512i)__builtin_ia32_cvttps2udq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_undefined_epi32(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundps_epu32(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2udq512_mask((__v16sf)(__m512)(A), \ + (__v16si)(__m512i)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundps_epu32(U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2udq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)(U), (int)(R))) + + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttps_epu32(__m512 __A) +{ + return (__m512i) __builtin_ia32_cvttps2udq512_mask ((__v16sf) __A, + (__v16si) + _mm512_setzero_si512 (), + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttps_epu32 (__m512i __W, __mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvttps2udq512_mask ((__v16sf) __A, + (__v16si) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttps_epu32 (__mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvttps2udq512_mask ((__v16sf) __A, + (__v16si) _mm512_setzero_si512 (), + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepi32_ps(A, R) \ + ((__m512)__builtin_ia32_cvtdq2ps512_mask((__v16si)(__m512i)(A), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvt_roundepi32_ps(W, U, A, R) \ + ((__m512)__builtin_ia32_cvtdq2ps512_mask((__v16si)(__m512i)(A), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepi32_ps(U, A, R) \ + ((__m512)__builtin_ia32_cvtdq2ps512_mask((__v16si)(__m512i)(A), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_cvt_roundepu32_ps(A, R) \ + ((__m512)__builtin_ia32_cvtudq2ps512_mask((__v16si)(__m512i)(A), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvt_roundepu32_ps(W, U, A, R) \ + ((__m512)__builtin_ia32_cvtudq2ps512_mask((__v16si)(__m512i)(A), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepu32_ps(U, A, R) \ + ((__m512)__builtin_ia32_cvtudq2ps512_mask((__v16si)(__m512i)(A), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_cvtepu32_ps (__m512i __A) +{ + return (__m512)__builtin_convertvector((__v16su)__A, __v16sf); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu32_ps (__m512 __W, __mmask16 __U, __m512i __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_cvtepu32_ps(__A), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu32_ps (__mmask16 __U, __m512i __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_cvtepu32_ps(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32_pd(__m256i __A) +{ + return (__m512d)__builtin_convertvector((__v8si)__A, __v8df); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_pd (__m512d __W, __mmask8 __U, __m256i __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_cvtepi32_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi32_pd (__mmask8 __U, __m256i __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_cvtepi32_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32lo_pd(__m512i __A) +{ + return (__m512d) _mm512_cvtepi32_pd(_mm512_castsi512_si256(__A)); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32lo_pd(__m512d __W, __mmask8 __U,__m512i __A) +{ + return (__m512d) _mm512_mask_cvtepi32_pd(__W, __U, _mm512_castsi512_si256(__A)); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32_ps (__m512i __A) +{ + return (__m512)__builtin_convertvector((__v16si)__A, __v16sf); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_ps (__m512 __W, __mmask16 __U, __m512i __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_cvtepi32_ps(__A), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi32_ps (__mmask16 __U, __m512i __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_cvtepi32_ps(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtepu32_pd(__m256i __A) +{ + return (__m512d)__builtin_convertvector((__v8su)__A, __v8df); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu32_pd (__m512d __W, __mmask8 __U, __m256i __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_cvtepu32_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu32_pd (__mmask8 __U, __m256i __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_cvtepu32_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtepu32lo_pd(__m512i __A) +{ + return (__m512d) _mm512_cvtepu32_pd(_mm512_castsi512_si256(__A)); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu32lo_pd(__m512d __W, __mmask8 __U,__m512i __A) +{ + return (__m512d) _mm512_mask_cvtepu32_pd(__W, __U, _mm512_castsi512_si256(__A)); +} + +#define _mm512_cvt_roundpd_ps(A, R) \ + ((__m256)__builtin_ia32_cvtpd2ps512_mask((__v8df)(__m512d)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundpd_ps(W, U, A, R) \ + ((__m256)__builtin_ia32_cvtpd2ps512_mask((__v8df)(__m512d)(A), \ + (__v8sf)(__m256)(W), (__mmask8)(U), \ + (int)(R))) + +#define _mm512_maskz_cvt_roundpd_ps(U, A, R) \ + ((__m256)__builtin_ia32_cvtpd2ps512_mask((__v8df)(__m512d)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_cvtpd_ps (__m512d __A) +{ + return (__m256) __builtin_ia32_cvtpd2ps512_mask ((__v8df) __A, + (__v8sf) _mm256_undefined_ps (), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_ps (__m256 __W, __mmask8 __U, __m512d __A) +{ + return (__m256) __builtin_ia32_cvtpd2ps512_mask ((__v8df) __A, + (__v8sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpd_ps (__mmask8 __U, __m512d __A) +{ + return (__m256) __builtin_ia32_cvtpd2ps512_mask ((__v8df) __A, + (__v8sf) _mm256_setzero_ps (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_cvtpd_pslo (__m512d __A) +{ + return (__m512) __builtin_shufflevector((__v8sf) _mm512_cvtpd_ps(__A), + (__v8sf) _mm256_setzero_ps (), + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_pslo (__m512 __W, __mmask8 __U,__m512d __A) +{ + return (__m512) __builtin_shufflevector ( + (__v8sf) _mm512_mask_cvtpd_ps (_mm512_castps512_ps256(__W), + __U, __A), + (__v8sf) _mm256_setzero_ps (), + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +#define _mm512_cvt_roundps_ph(A, I) \ + ((__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \ + (__v16hi)_mm256_undefined_si256(), \ + (__mmask16)-1)) + +#define _mm512_mask_cvt_roundps_ph(U, W, A, I) \ + ((__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \ + (__v16hi)(__m256i)(U), \ + (__mmask16)(W))) + +#define _mm512_maskz_cvt_roundps_ph(W, A, I) \ + ((__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \ + (__v16hi)_mm256_setzero_si256(), \ + (__mmask16)(W))) + +#define _mm512_cvtps_ph _mm512_cvt_roundps_ph +#define _mm512_mask_cvtps_ph _mm512_mask_cvt_roundps_ph +#define _mm512_maskz_cvtps_ph _mm512_maskz_cvt_roundps_ph + +#define _mm512_cvt_roundph_ps(A, R) \ + ((__m512)__builtin_ia32_vcvtph2ps512_mask((__v16hi)(__m256i)(A), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvt_roundph_ps(W, U, A, R) \ + ((__m512)__builtin_ia32_vcvtph2ps512_mask((__v16hi)(__m256i)(A), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_ps(U, A, R) \ + ((__m512)__builtin_ia32_vcvtph2ps512_mask((__v16hi)(__m256i)(A), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_cvtph_ps(__m256i __A) +{ + return (__m512) __builtin_ia32_vcvtph2ps512_mask ((__v16hi) __A, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_ps (__m512 __W, __mmask16 __U, __m256i __A) +{ + return (__m512) __builtin_ia32_vcvtph2ps512_mask ((__v16hi) __A, + (__v16sf) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_ps (__mmask16 __U, __m256i __A) +{ + return (__m512) __builtin_ia32_vcvtph2ps512_mask ((__v16hi) __A, + (__v16sf) _mm512_setzero_ps (), + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundpd_epi32(A, R) \ + ((__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundpd_epi32(W, U, A, R) \ + ((__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ + (__v8si)(__m256i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundpd_epi32(U, A, R) \ + ((__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)(U), (int)(R))) + +static __inline __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvttpd_epi32(__m512d __a) +{ + return (__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df) __a, + (__v8si)_mm256_setzero_si256(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttpd_epi32 (__m256i __W, __mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvttpd2dq512_mask ((__v8df) __A, + (__v8si) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttpd_epi32 (__mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvttpd2dq512_mask ((__v8df) __A, + (__v8si) _mm256_setzero_si256 (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundps_epi32(A, R) \ + ((__m512i)__builtin_ia32_cvttps2dq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundps_epi32(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2dq512_mask((__v16sf)(__m512)(A), \ + (__v16si)(__m512i)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundps_epi32(U, A, R) \ + ((__m512i)__builtin_ia32_cvttps2dq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)(U), (int)(R))) + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttps_epi32(__m512 __a) +{ + return (__m512i) + __builtin_ia32_cvttps2dq512_mask((__v16sf) __a, + (__v16si) _mm512_setzero_si512 (), + (__mmask16) -1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttps_epi32 (__m512i __W, __mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvttps2dq512_mask ((__v16sf) __A, + (__v16si) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttps_epi32 (__mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvttps2dq512_mask ((__v16sf) __A, + (__v16si) _mm512_setzero_si512 (), + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundps_epi32(A, R) \ + ((__m512i)__builtin_ia32_cvtps2dq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvt_roundps_epi32(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2dq512_mask((__v16sf)(__m512)(A), \ + (__v16si)(__m512i)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundps_epi32(U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2dq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtps_epi32 (__m512 __A) +{ + return (__m512i) __builtin_ia32_cvtps2dq512_mask ((__v16sf) __A, + (__v16si) _mm512_undefined_epi32 (), + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtps_epi32 (__m512i __W, __mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvtps2dq512_mask ((__v16sf) __A, + (__v16si) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtps_epi32 (__mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvtps2dq512_mask ((__v16sf) __A, + (__v16si) + _mm512_setzero_si512 (), + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundpd_epi32(A, R) \ + ((__m256i)__builtin_ia32_cvtpd2dq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundpd_epi32(W, U, A, R) \ + ((__m256i)__builtin_ia32_cvtpd2dq512_mask((__v8df)(__m512d)(A), \ + (__v8si)(__m256i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundpd_epi32(U, A, R) \ + ((__m256i)__builtin_ia32_cvtpd2dq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtpd_epi32 (__m512d __A) +{ + return (__m256i) __builtin_ia32_cvtpd2dq512_mask ((__v8df) __A, + (__v8si) + _mm256_undefined_si256 (), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_epi32 (__m256i __W, __mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvtpd2dq512_mask ((__v8df) __A, + (__v8si) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpd_epi32 (__mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvtpd2dq512_mask ((__v8df) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundps_epu32(A, R) \ + ((__m512i)__builtin_ia32_cvtps2udq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_cvt_roundps_epu32(W, U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2udq512_mask((__v16sf)(__m512)(A), \ + (__v16si)(__m512i)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundps_epu32(U, A, R) \ + ((__m512i)__builtin_ia32_cvtps2udq512_mask((__v16sf)(__m512)(A), \ + (__v16si)_mm512_setzero_si512(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtps_epu32 ( __m512 __A) +{ + return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A,\ + (__v16si)\ + _mm512_undefined_epi32 (), + (__mmask16) -1,\ + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtps_epu32 (__m512i __W, __mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A, + (__v16si) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtps_epu32 ( __mmask16 __U, __m512 __A) +{ + return (__m512i) __builtin_ia32_cvtps2udq512_mask ((__v16sf) __A, + (__v16si) + _mm512_setzero_si512 (), + (__mmask16) __U , + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundpd_epu32(A, R) \ + ((__m256i)__builtin_ia32_cvtpd2udq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundpd_epu32(W, U, A, R) \ + ((__m256i)__builtin_ia32_cvtpd2udq512_mask((__v8df)(__m512d)(A), \ + (__v8si)(__m256i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundpd_epu32(U, A, R) \ + ((__m256i)__builtin_ia32_cvtpd2udq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtpd_epu32 (__m512d __A) +{ + return (__m256i) __builtin_ia32_cvtpd2udq512_mask ((__v8df) __A, + (__v8si) + _mm256_undefined_si256 (), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_epu32 (__m256i __W, __mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvtpd2udq512_mask ((__v8df) __A, + (__v8si) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpd_epu32 (__mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvtpd2udq512_mask ((__v8df) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_cvtsd_f64(__m512d __a) +{ + return __a[0]; +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_cvtss_f32(__m512 __a) +{ + return __a[0]; +} + +/* Unpack and Interleave */ + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_unpackhi_pd(__m512d __a, __m512d __b) +{ + return (__m512d)__builtin_shufflevector((__v8df)__a, (__v8df)__b, + 1, 9, 1+2, 9+2, 1+4, 9+4, 1+6, 9+6); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_unpackhi_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_unpackhi_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpackhi_pd(__mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_unpackhi_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_unpacklo_pd(__m512d __a, __m512d __b) +{ + return (__m512d)__builtin_shufflevector((__v8df)__a, (__v8df)__b, + 0, 8, 0+2, 8+2, 0+4, 8+4, 0+6, 8+6); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_unpacklo_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_unpacklo_pd(__A, __B), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpacklo_pd (__mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8) __U, + (__v8df)_mm512_unpacklo_pd(__A, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_unpackhi_ps(__m512 __a, __m512 __b) +{ + return (__m512)__builtin_shufflevector((__v16sf)__a, (__v16sf)__b, + 2, 18, 3, 19, + 2+4, 18+4, 3+4, 19+4, + 2+8, 18+8, 3+8, 19+8, + 2+12, 18+12, 3+12, 19+12); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_unpackhi_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16) __U, + (__v16sf)_mm512_unpackhi_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpackhi_ps (__mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16) __U, + (__v16sf)_mm512_unpackhi_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_unpacklo_ps(__m512 __a, __m512 __b) +{ + return (__m512)__builtin_shufflevector((__v16sf)__a, (__v16sf)__b, + 0, 16, 1, 17, + 0+4, 16+4, 1+4, 17+4, + 0+8, 16+8, 1+8, 17+8, + 0+12, 16+12, 1+12, 17+12); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_unpacklo_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16) __U, + (__v16sf)_mm512_unpacklo_ps(__A, __B), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpacklo_ps (__mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16) __U, + (__v16sf)_mm512_unpacklo_ps(__A, __B), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpackhi_epi32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_shufflevector((__v16si)__A, (__v16si)__B, + 2, 18, 3, 19, + 2+4, 18+4, 3+4, 19+4, + 2+8, 18+8, 3+8, 19+8, + 2+12, 18+12, 3+12, 19+12); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpackhi_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16) __U, + (__v16si)_mm512_unpackhi_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpackhi_epi32(__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16) __U, + (__v16si)_mm512_unpackhi_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpacklo_epi32(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_shufflevector((__v16si)__A, (__v16si)__B, + 0, 16, 1, 17, + 0+4, 16+4, 1+4, 17+4, + 0+8, 16+8, 1+8, 17+8, + 0+12, 16+12, 1+12, 17+12); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpacklo_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16) __U, + (__v16si)_mm512_unpacklo_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpacklo_epi32(__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16) __U, + (__v16si)_mm512_unpacklo_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpackhi_epi64(__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_shufflevector((__v8di)__A, (__v8di)__B, + 1, 9, 1+2, 9+2, 1+4, 9+4, 1+6, 9+6); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpackhi_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8) __U, + (__v8di)_mm512_unpackhi_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpackhi_epi64(__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8) __U, + (__v8di)_mm512_unpackhi_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_unpacklo_epi64 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_shufflevector((__v8di)__A, (__v8di)__B, + 0, 8, 0+2, 8+2, 0+4, 8+4, 0+6, 8+6); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_unpacklo_epi64 (__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8) __U, + (__v8di)_mm512_unpacklo_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_unpacklo_epi64 (__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8) __U, + (__v8di)_mm512_unpacklo_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + + +/* SIMD load ops */ + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadu_si512 (void const *__P) +{ + struct __loadu_si512 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_si512*)__P)->__v; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadu_epi32 (void const *__P) +{ + struct __loadu_epi32 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi32*)__P)->__v; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadu_epi32 (__m512i __W, __mmask16 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddqusi512_mask ((const int *) __P, + (__v16si) __W, + (__mmask16) __U); +} + + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadu_epi32(__mmask16 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddqusi512_mask ((const int *)__P, + (__v16si) + _mm512_setzero_si512 (), + (__mmask16) __U); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadu_epi64 (void const *__P) +{ + struct __loadu_epi64 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi64*)__P)->__v; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadu_epi64 (__m512i __W, __mmask8 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddqudi512_mask ((const long long *) __P, + (__v8di) __W, + (__mmask8) __U); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadu_epi64(__mmask8 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_loaddqudi512_mask ((const long long *)__P, + (__v8di) + _mm512_setzero_si512 (), + (__mmask8) __U); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_loadu_ps (__m512 __W, __mmask16 __U, void const *__P) +{ + return (__m512) __builtin_ia32_loadups512_mask ((const float *) __P, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadu_ps(__mmask16 __U, void const *__P) +{ + return (__m512) __builtin_ia32_loadups512_mask ((const float *)__P, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) __U); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_loadu_pd (__m512d __W, __mmask8 __U, void const *__P) +{ + return (__m512d) __builtin_ia32_loadupd512_mask ((const double *) __P, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadu_pd(__mmask8 __U, void const *__P) +{ + return (__m512d) __builtin_ia32_loadupd512_mask ((const double *)__P, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) __U); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_loadu_pd(void const *__p) +{ + struct __loadu_pd { + __m512d_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_pd*)__p)->__v; +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_loadu_ps(void const *__p) +{ + struct __loadu_ps { + __m512_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_ps*)__p)->__v; +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_load_ps(void const *__p) +{ + return *(const __m512*)__p; +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_load_ps (__m512 __W, __mmask16 __U, void const *__P) +{ + return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf *) __P, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_load_ps(__mmask16 __U, void const *__P) +{ + return (__m512) __builtin_ia32_loadaps512_mask ((const __v16sf *)__P, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) __U); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_load_pd(void const *__p) +{ + return *(const __m512d*)__p; +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_load_pd (__m512d __W, __mmask8 __U, void const *__P) +{ + return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df *) __P, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_load_pd(__mmask8 __U, void const *__P) +{ + return (__m512d) __builtin_ia32_loadapd512_mask ((const __v8df *)__P, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) __U); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_load_si512 (void const *__P) +{ + return *(const __m512i *) __P; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_load_epi32 (void const *__P) +{ + return *(const __m512i *) __P; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_load_epi64 (void const *__P) +{ + return *(const __m512i *) __P; +} + +/* SIMD store ops */ + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_epi64 (void *__P, __m512i __A) +{ + struct __storeu_epi64 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi64*)__P)->__v = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_mask_storeu_epi64(void *__P, __mmask8 __U, __m512i __A) +{ + __builtin_ia32_storedqudi512_mask ((long long *)__P, (__v8di) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_si512 (void *__P, __m512i __A) +{ + struct __storeu_si512 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_si512*)__P)->__v = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_epi32 (void *__P, __m512i __A) +{ + struct __storeu_epi32 { + __m512i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi32*)__P)->__v = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_mask_storeu_epi32(void *__P, __mmask16 __U, __m512i __A) +{ + __builtin_ia32_storedqusi512_mask ((int *)__P, (__v16si) __A, + (__mmask16) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_mask_storeu_pd(void *__P, __mmask8 __U, __m512d __A) +{ + __builtin_ia32_storeupd512_mask ((double *)__P, (__v8df) __A, (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_pd(void *__P, __m512d __A) +{ + struct __storeu_pd { + __m512d_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_pd*)__P)->__v = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_mask_storeu_ps(void *__P, __mmask16 __U, __m512 __A) +{ + __builtin_ia32_storeups512_mask ((float *)__P, (__v16sf) __A, + (__mmask16) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_storeu_ps(void *__P, __m512 __A) +{ + struct __storeu_ps { + __m512_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_ps*)__P)->__v = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_mask_store_pd(void *__P, __mmask8 __U, __m512d __A) +{ + __builtin_ia32_storeapd512_mask ((__v8df *)__P, (__v8df) __A, (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_store_pd(void *__P, __m512d __A) +{ + *(__m512d*)__P = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_mask_store_ps(void *__P, __mmask16 __U, __m512 __A) +{ + __builtin_ia32_storeaps512_mask ((__v16sf *)__P, (__v16sf) __A, + (__mmask16) __U); +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_store_ps(void *__P, __m512 __A) +{ + *(__m512*)__P = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_store_si512 (void *__P, __m512i __A) +{ + *(__m512i *) __P = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_store_epi32 (void *__P, __m512i __A) +{ + *(__m512i *) __P = __A; +} + +static __inline void __DEFAULT_FN_ATTRS512 +_mm512_store_epi64 (void *__P, __m512i __A) +{ + *(__m512i *) __P = __A; +} + +/* Mask ops */ + +static __inline __mmask16 __DEFAULT_FN_ATTRS +_mm512_knot(__mmask16 __M) +{ + return __builtin_ia32_knothi(__M); +} + +/* Integer compare */ + +#define _mm512_cmpeq_epi32_mask(A, B) \ + _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epi32_mask(k, A, B) \ + _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epi32_mask(A, B) \ + _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epi32_mask(k, A, B) \ + _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epi32_mask(A, B) \ + _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epi32_mask(k, A, B) \ + _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epi32_mask(A, B) \ + _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epi32_mask(k, A, B) \ + _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epi32_mask(A, B) \ + _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epi32_mask(k, A, B) \ + _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epi32_mask(A, B) \ + _mm512_cmp_epi32_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epi32_mask(k, A, B) \ + _mm512_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm512_cmpeq_epu32_mask(A, B) \ + _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epu32_mask(k, A, B) \ + _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epu32_mask(A, B) \ + _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epu32_mask(k, A, B) \ + _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epu32_mask(A, B) \ + _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epu32_mask(k, A, B) \ + _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epu32_mask(A, B) \ + _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epu32_mask(k, A, B) \ + _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epu32_mask(A, B) \ + _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epu32_mask(k, A, B) \ + _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epu32_mask(A, B) \ + _mm512_cmp_epu32_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epu32_mask(k, A, B) \ + _mm512_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm512_cmpeq_epi64_mask(A, B) \ + _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epi64_mask(k, A, B) \ + _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epi64_mask(A, B) \ + _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epi64_mask(k, A, B) \ + _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epi64_mask(A, B) \ + _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epi64_mask(k, A, B) \ + _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epi64_mask(A, B) \ + _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epi64_mask(k, A, B) \ + _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epi64_mask(A, B) \ + _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epi64_mask(k, A, B) \ + _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epi64_mask(A, B) \ + _mm512_cmp_epi64_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epi64_mask(k, A, B) \ + _mm512_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm512_cmpeq_epu64_mask(A, B) \ + _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_EQ) +#define _mm512_mask_cmpeq_epu64_mask(k, A, B) \ + _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm512_cmpge_epu64_mask(A, B) \ + _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_GE) +#define _mm512_mask_cmpge_epu64_mask(k, A, B) \ + _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm512_cmpgt_epu64_mask(A, B) \ + _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_GT) +#define _mm512_mask_cmpgt_epu64_mask(k, A, B) \ + _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm512_cmple_epu64_mask(A, B) \ + _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_LE) +#define _mm512_mask_cmple_epu64_mask(k, A, B) \ + _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm512_cmplt_epu64_mask(A, B) \ + _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_LT) +#define _mm512_mask_cmplt_epu64_mask(k, A, B) \ + _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm512_cmpneq_epu64_mask(A, B) \ + _mm512_cmp_epu64_mask((A), (B), _MM_CMPINT_NE) +#define _mm512_mask_cmpneq_epu64_mask(k, A, B) \ + _mm512_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_NE) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi8_epi32(__m128i __A) +{ + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m512i)__builtin_convertvector((__v16qs)__A, __v16si); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi8_epi32(__m512i __W, __mmask16 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepi8_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi8_epi32(__mmask16 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepi8_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi8_epi64(__m128i __A) +{ + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m512i)__builtin_convertvector(__builtin_shufflevector((__v16qs)__A, (__v16qs)__A, 0, 1, 2, 3, 4, 5, 6, 7), __v8di); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi8_epi64(__m512i __W, __mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepi8_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi8_epi64(__mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepi8_epi64(__A), + (__v8di)_mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32_epi64(__m256i __X) +{ + return (__m512i)__builtin_convertvector((__v8si)__X, __v8di); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_epi64(__m512i __W, __mmask8 __U, __m256i __X) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepi32_epi64(__X), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi32_epi64(__mmask8 __U, __m256i __X) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepi32_epi64(__X), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi16_epi32(__m256i __A) +{ + return (__m512i)__builtin_convertvector((__v16hi)__A, __v16si); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi16_epi32(__m512i __W, __mmask16 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepi16_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi16_epi32(__mmask16 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepi16_epi32(__A), + (__v16si)_mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi16_epi64(__m128i __A) +{ + return (__m512i)__builtin_convertvector((__v8hi)__A, __v8di); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi16_epi64(__m512i __W, __mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepi16_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi16_epi64(__mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepi16_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepu8_epi32(__m128i __A) +{ + return (__m512i)__builtin_convertvector((__v16qu)__A, __v16si); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu8_epi32(__m512i __W, __mmask16 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepu8_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu8_epi32(__mmask16 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepu8_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepu8_epi64(__m128i __A) +{ + return (__m512i)__builtin_convertvector(__builtin_shufflevector((__v16qu)__A, (__v16qu)__A, 0, 1, 2, 3, 4, 5, 6, 7), __v8di); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu8_epi64(__m512i __W, __mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepu8_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu8_epi64(__mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepu8_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepu32_epi64(__m256i __X) +{ + return (__m512i)__builtin_convertvector((__v8su)__X, __v8di); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu32_epi64(__m512i __W, __mmask8 __U, __m256i __X) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepu32_epi64(__X), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu32_epi64(__mmask8 __U, __m256i __X) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepu32_epi64(__X), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepu16_epi32(__m256i __A) +{ + return (__m512i)__builtin_convertvector((__v16hu)__A, __v16si); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu16_epi32(__m512i __W, __mmask16 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepu16_epi32(__A), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu16_epi32(__mmask16 __U, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_cvtepu16_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtepu16_epi64(__m128i __A) +{ + return (__m512i)__builtin_convertvector((__v8hu)__A, __v8di); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu16_epi64(__m512i __W, __mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepu16_epi64(__A), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu16_epi64(__mmask8 __U, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_cvtepu16_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_rorv_epi32 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_prorvd512((__v16si)__A, (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_rorv_epi32 (__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_rorv_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_rorv_epi32 (__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_rorv_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_rorv_epi64 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_prorvq512((__v8di)__A, (__v8di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_rorv_epi64 (__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_rorv_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_rorv_epi64 (__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_rorv_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + + + +#define _mm512_cmp_epi32_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_cmpd512_mask((__v16si)(__m512i)(a), \ + (__v16si)(__m512i)(b), (int)(p), \ + (__mmask16)-1)) + +#define _mm512_cmp_epu32_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)(__m512i)(a), \ + (__v16si)(__m512i)(b), (int)(p), \ + (__mmask16)-1)) + +#define _mm512_cmp_epi64_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpq512_mask((__v8di)(__m512i)(a), \ + (__v8di)(__m512i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm512_cmp_epu64_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)(__m512i)(a), \ + (__v8di)(__m512i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm512_mask_cmp_epi32_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_cmpd512_mask((__v16si)(__m512i)(a), \ + (__v16si)(__m512i)(b), (int)(p), \ + (__mmask16)(m))) + +#define _mm512_mask_cmp_epu32_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_ucmpd512_mask((__v16si)(__m512i)(a), \ + (__v16si)(__m512i)(b), (int)(p), \ + (__mmask16)(m))) + +#define _mm512_mask_cmp_epi64_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpq512_mask((__v8di)(__m512i)(a), \ + (__v8di)(__m512i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm512_mask_cmp_epu64_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpq512_mask((__v8di)(__m512i)(a), \ + (__v8di)(__m512i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm512_rol_epi32(a, b) \ + ((__m512i)__builtin_ia32_prold512((__v16si)(__m512i)(a), (int)(b))) + +#define _mm512_mask_rol_epi32(W, U, a, b) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_rol_epi32((a), (b)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_rol_epi32(U, a, b) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_rol_epi32((a), (b)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_rol_epi64(a, b) \ + ((__m512i)__builtin_ia32_prolq512((__v8di)(__m512i)(a), (int)(b))) + +#define _mm512_mask_rol_epi64(W, U, a, b) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_rol_epi64((a), (b)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_rol_epi64(U, a, b) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_rol_epi64((a), (b)), \ + (__v8di)_mm512_setzero_si512())) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_rolv_epi32 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_prolvd512((__v16si)__A, (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_rolv_epi32 (__m512i __W, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_rolv_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_rolv_epi32 (__mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_rolv_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_rolv_epi64 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_prolvq512((__v8di)__A, (__v8di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_rolv_epi64 (__m512i __W, __mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_rolv_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_rolv_epi64 (__mmask8 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_rolv_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +#define _mm512_ror_epi32(A, B) \ + ((__m512i)__builtin_ia32_prord512((__v16si)(__m512i)(A), (int)(B))) + +#define _mm512_mask_ror_epi32(W, U, A, B) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_ror_epi32((A), (B)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_ror_epi32(U, A, B) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_ror_epi32((A), (B)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_ror_epi64(A, B) \ + ((__m512i)__builtin_ia32_prorq512((__v8di)(__m512i)(A), (int)(B))) + +#define _mm512_mask_ror_epi64(W, U, A, B) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_ror_epi64((A), (B)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_ror_epi64(U, A, B) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_ror_epi64((A), (B)), \ + (__v8di)_mm512_setzero_si512())) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_slli_epi32(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_pslldi512((__v16si)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_slli_epi32(__m512i __W, __mmask16 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_slli_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_slli_epi32(__mmask16 __U, __m512i __A, unsigned int __B) { + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_slli_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_slli_epi64(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psllqi512((__v8di)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_slli_epi64(__m512i __W, __mmask8 __U, __m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_slli_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_slli_epi64(__mmask8 __U, __m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_slli_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srli_epi32(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psrldi512((__v16si)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srli_epi32(__m512i __W, __mmask16 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srli_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srli_epi32(__mmask16 __U, __m512i __A, unsigned int __B) { + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srli_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srli_epi64(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psrlqi512((__v8di)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srli_epi64(__m512i __W, __mmask8 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srli_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srli_epi64(__mmask8 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srli_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_load_epi32 (__m512i __W, __mmask16 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_movdqa32load512_mask ((const __v16si *) __P, + (__v16si) __W, + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_load_epi32 (__mmask16 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_movdqa32load512_mask ((const __v16si *) __P, + (__v16si) + _mm512_setzero_si512 (), + (__mmask16) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_store_epi32 (void *__P, __mmask16 __U, __m512i __A) +{ + __builtin_ia32_movdqa32store512_mask ((__v16si *) __P, (__v16si) __A, + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mov_epi32 (__m512i __W, __mmask16 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectd_512 ((__mmask16) __U, + (__v16si) __A, + (__v16si) __W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mov_epi32 (__mmask16 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectd_512 ((__mmask16) __U, + (__v16si) __A, + (__v16si) _mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_mov_epi64 (__m512i __W, __mmask8 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectq_512 ((__mmask8) __U, + (__v8di) __A, + (__v8di) __W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_mov_epi64 (__mmask8 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_selectq_512 ((__mmask8) __U, + (__v8di) __A, + (__v8di) _mm512_setzero_si512 ()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_load_epi64 (__m512i __W, __mmask8 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_movdqa64load512_mask ((const __v8di *) __P, + (__v8di) __W, + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_load_epi64 (__mmask8 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_movdqa64load512_mask ((const __v8di *) __P, + (__v8di) + _mm512_setzero_si512 (), + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_store_epi64 (void *__P, __mmask8 __U, __m512i __A) +{ + __builtin_ia32_movdqa64store512_mask ((__v8di *) __P, (__v8di) __A, + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_movedup_pd (__m512d __A) +{ + return (__m512d)__builtin_shufflevector((__v8df)__A, (__v8df)__A, + 0, 0, 2, 2, 4, 4, 6, 6); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_movedup_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_movedup_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_movedup_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_movedup_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +#define _mm512_fixupimm_round_pd(A, B, C, imm, R) \ + ((__m512d)__builtin_ia32_fixupimmpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8di)(__m512i)(C), (int)(imm), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_fixupimm_round_pd(A, U, B, C, imm, R) \ + ((__m512d)__builtin_ia32_fixupimmpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8di)(__m512i)(C), (int)(imm), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_fixupimm_pd(A, B, C, imm) \ + ((__m512d)__builtin_ia32_fixupimmpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8di)(__m512i)(C), (int)(imm), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_fixupimm_pd(A, U, B, C, imm) \ + ((__m512d)__builtin_ia32_fixupimmpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8di)(__m512i)(C), (int)(imm), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_fixupimm_round_pd(U, A, B, C, imm, R) \ + ((__m512d)__builtin_ia32_fixupimmpd512_maskz((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8di)(__m512i)(C), \ + (int)(imm), (__mmask8)(U), \ + (int)(R))) + +#define _mm512_maskz_fixupimm_pd(U, A, B, C, imm) \ + ((__m512d)__builtin_ia32_fixupimmpd512_maskz((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8di)(__m512i)(C), \ + (int)(imm), (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_fixupimm_round_ps(A, B, C, imm, R) \ + ((__m512)__builtin_ia32_fixupimmps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16si)(__m512i)(C), (int)(imm), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_fixupimm_round_ps(A, U, B, C, imm, R) \ + ((__m512)__builtin_ia32_fixupimmps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16si)(__m512i)(C), (int)(imm), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_fixupimm_ps(A, B, C, imm) \ + ((__m512)__builtin_ia32_fixupimmps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16si)(__m512i)(C), (int)(imm), \ + (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_fixupimm_ps(A, U, B, C, imm) \ + ((__m512)__builtin_ia32_fixupimmps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16si)(__m512i)(C), (int)(imm), \ + (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_fixupimm_round_ps(U, A, B, C, imm, R) \ + ((__m512)__builtin_ia32_fixupimmps512_maskz((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16si)(__m512i)(C), \ + (int)(imm), (__mmask16)(U), \ + (int)(R))) + +#define _mm512_maskz_fixupimm_ps(U, A, B, C, imm) \ + ((__m512)__builtin_ia32_fixupimmps512_maskz((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16si)(__m512i)(C), \ + (int)(imm), (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_fixupimm_round_sd(A, B, C, imm, R) \ + ((__m128d)__builtin_ia32_fixupimmsd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fixupimm_round_sd(A, U, B, C, imm, R) \ + ((__m128d)__builtin_ia32_fixupimmsd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), (int)(R))) + +#define _mm_fixupimm_sd(A, B, C, imm) \ + ((__m128d)__builtin_ia32_fixupimmsd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_fixupimm_sd(A, U, B, C, imm) \ + ((__m128d)__builtin_ia32_fixupimmsd_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_fixupimm_round_sd(U, A, B, C, imm, R) \ + ((__m128d)__builtin_ia32_fixupimmsd_maskz((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_fixupimm_sd(U, A, B, C, imm) \ + ((__m128d)__builtin_ia32_fixupimmsd_maskz((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_fixupimm_round_ss(A, B, C, imm, R) \ + ((__m128)__builtin_ia32_fixupimmss_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fixupimm_round_ss(A, U, B, C, imm, R) \ + ((__m128)__builtin_ia32_fixupimmss_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), (int)(R))) + +#define _mm_fixupimm_ss(A, B, C, imm) \ + ((__m128)__builtin_ia32_fixupimmss_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_fixupimm_ss(A, U, B, C, imm) \ + ((__m128)__builtin_ia32_fixupimmss_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_fixupimm_round_ss(U, A, B, C, imm, R) \ + ((__m128)__builtin_ia32_fixupimmss_maskz((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_fixupimm_ss(U, A, B, C, imm) \ + ((__m128)__builtin_ia32_fixupimmss_maskz((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_getexp_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_getexpsd128_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_getexp_sd (__m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_getexpsd128_round_mask ((__v2df) __A, + (__v2df) __B, (__v2df) _mm_setzero_pd(), (__mmask8) -1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_getexpsd128_round_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_getexp_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_getexpsd128_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_sd (__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_getexpsd128_round_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_getexp_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_getexpsd128_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_getexp_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_getexpss128_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_getexp_ss (__m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_getexpss128_round_mask ((__v4sf) __A, + (__v4sf) __B, (__v4sf) _mm_setzero_ps(), (__mmask8) -1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_getexpss128_round_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_getexp_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_getexpss128_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_ss (__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_getexpss128_round_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_getexp_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_getexpss128_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_getmant_round_sd(A, B, C, D, R) \ + ((__m128d)__builtin_ia32_getmantsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (int)(((D)<<2) | (C)), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_getmant_sd(A, B, C, D) \ + ((__m128d)__builtin_ia32_getmantsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (int)(((D)<<2) | (C)), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_getmant_sd(W, U, A, B, C, D) \ + ((__m128d)__builtin_ia32_getmantsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (int)(((D)<<2) | (C)), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_getmant_round_sd(W, U, A, B, C, D, R) \ + ((__m128d)__builtin_ia32_getmantsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (int)(((D)<<2) | (C)), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_getmant_sd(U, A, B, C, D) \ + ((__m128d)__builtin_ia32_getmantsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (int)(((D)<<2) | (C)), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_getmant_round_sd(U, A, B, C, D, R) \ + ((__m128d)__builtin_ia32_getmantsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (int)(((D)<<2) | (C)), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_getmant_round_ss(A, B, C, D, R) \ + ((__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (int)(((D)<<2) | (C)), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_getmant_ss(A, B, C, D) \ + ((__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (int)(((D)<<2) | (C)), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_getmant_ss(W, U, A, B, C, D) \ + ((__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (int)(((D)<<2) | (C)), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_getmant_round_ss(W, U, A, B, C, D, R) \ + ((__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (int)(((D)<<2) | (C)), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_getmant_ss(U, A, B, C, D) \ + ((__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (int)(((D)<<2) | (C)), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_getmant_round_ss(U, A, B, C, D, R) \ + ((__m128)__builtin_ia32_getmantss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (int)(((D)<<2) | (C)), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kmov (__mmask16 __A) +{ + return __A; +} + +#define _mm_comi_round_sd(A, B, P, R) \ + ((int)__builtin_ia32_vcomisd((__v2df)(__m128d)(A), (__v2df)(__m128d)(B), \ + (int)(P), (int)(R))) + +#define _mm_comi_round_ss(A, B, P, R) \ + ((int)__builtin_ia32_vcomiss((__v4sf)(__m128)(A), (__v4sf)(__m128)(B), \ + (int)(P), (int)(R))) + +#ifdef __x86_64__ +#define _mm_cvt_roundsd_si64(A, R) \ + ((long long)__builtin_ia32_vcvtsd2si64((__v2df)(__m128d)(A), (int)(R))) +#endif + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sll_epi32(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_pslld512((__v16si) __A, (__v4si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sll_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sll_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sll_epi32(__mmask16 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sll_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sll_epi64(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psllq512((__v8di)__A, (__v2di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sll_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sll_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sll_epi64(__mmask8 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sll_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sllv_epi32(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_psllv16si((__v16si)__X, (__v16si)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sllv_epi32(__m512i __W, __mmask16 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sllv_epi32(__X, __Y), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sllv_epi32(__mmask16 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sllv_epi32(__X, __Y), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sllv_epi64(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_psllv8di((__v8di)__X, (__v8di)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sllv_epi64(__m512i __W, __mmask8 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sllv_epi64(__X, __Y), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sllv_epi64(__mmask8 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sllv_epi64(__X, __Y), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sra_epi32(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psrad512((__v16si) __A, (__v4si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sra_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sra_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sra_epi32(__mmask16 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_sra_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sra_epi64(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psraq512((__v8di)__A, (__v2di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_sra_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sra_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_sra_epi64(__mmask8 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_sra_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srav_epi32(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_psrav16si((__v16si)__X, (__v16si)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srav_epi32(__m512i __W, __mmask16 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srav_epi32(__X, __Y), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srav_epi32(__mmask16 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srav_epi32(__X, __Y), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srav_epi64(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_psrav8di((__v8di)__X, (__v8di)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srav_epi64(__m512i __W, __mmask8 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srav_epi64(__X, __Y), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srav_epi64(__mmask8 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srav_epi64(__X, __Y), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srl_epi32(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psrld512((__v16si) __A, (__v4si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srl_epi32(__m512i __W, __mmask16 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srl_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srl_epi32(__mmask16 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srl_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srl_epi64(__m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_psrlq512((__v8di)__A, (__v2di)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srl_epi64(__m512i __W, __mmask8 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srl_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srl_epi64(__mmask8 __U, __m512i __A, __m128i __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srl_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srlv_epi32(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_psrlv16si((__v16si)__X, (__v16si)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srlv_epi32(__m512i __W, __mmask16 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srlv_epi32(__X, __Y), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srlv_epi32(__mmask16 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srlv_epi32(__X, __Y), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srlv_epi64 (__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_psrlv8di((__v8di)__X, (__v8di)__Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srlv_epi64(__m512i __W, __mmask8 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srlv_epi64(__X, __Y), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srlv_epi64(__mmask8 __U, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srlv_epi64(__X, __Y), + (__v8di)_mm512_setzero_si512()); +} + +/// \enum _MM_TERNLOG_ENUM +/// A helper to represent the ternary logic operations among vector \a A, +/// \a B and \a C. The representation is passed to \a imm. +typedef enum { + _MM_TERNLOG_A = 0xF0, + _MM_TERNLOG_B = 0xCC, + _MM_TERNLOG_C = 0xAA +} _MM_TERNLOG_ENUM; + +#define _mm512_ternarylogic_epi32(A, B, C, imm) \ + ((__m512i)__builtin_ia32_pternlogd512_mask( \ + (__v16si)(__m512i)(A), (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), \ + (unsigned char)(imm), (__mmask16)-1)) + +#define _mm512_mask_ternarylogic_epi32(A, U, B, C, imm) \ + ((__m512i)__builtin_ia32_pternlogd512_mask( \ + (__v16si)(__m512i)(A), (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), \ + (unsigned char)(imm), (__mmask16)(U))) + +#define _mm512_maskz_ternarylogic_epi32(U, A, B, C, imm) \ + ((__m512i)__builtin_ia32_pternlogd512_maskz( \ + (__v16si)(__m512i)(A), (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), \ + (unsigned char)(imm), (__mmask16)(U))) + +#define _mm512_ternarylogic_epi64(A, B, C, imm) \ + ((__m512i)__builtin_ia32_pternlogq512_mask( \ + (__v8di)(__m512i)(A), (__v8di)(__m512i)(B), (__v8di)(__m512i)(C), \ + (unsigned char)(imm), (__mmask8)-1)) + +#define _mm512_mask_ternarylogic_epi64(A, U, B, C, imm) \ + ((__m512i)__builtin_ia32_pternlogq512_mask( \ + (__v8di)(__m512i)(A), (__v8di)(__m512i)(B), (__v8di)(__m512i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm512_maskz_ternarylogic_epi64(U, A, B, C, imm) \ + ((__m512i)__builtin_ia32_pternlogq512_maskz( \ + (__v8di)(__m512i)(A), (__v8di)(__m512i)(B), (__v8di)(__m512i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#ifdef __x86_64__ +#define _mm_cvt_roundsd_i64(A, R) \ + ((long long)__builtin_ia32_vcvtsd2si64((__v2df)(__m128d)(A), (int)(R))) +#endif + +#define _mm_cvt_roundsd_si32(A, R) \ + ((int)__builtin_ia32_vcvtsd2si32((__v2df)(__m128d)(A), (int)(R))) + +#define _mm_cvt_roundsd_i32(A, R) \ + ((int)__builtin_ia32_vcvtsd2si32((__v2df)(__m128d)(A), (int)(R))) + +#define _mm_cvt_roundsd_u32(A, R) \ + ((unsigned int)__builtin_ia32_vcvtsd2usi32((__v2df)(__m128d)(A), (int)(R))) + +static __inline__ unsigned __DEFAULT_FN_ATTRS128 +_mm_cvtsd_u32 (__m128d __A) +{ + return (unsigned) __builtin_ia32_vcvtsd2usi32 ((__v2df) __A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvt_roundsd_u64(A, R) \ + ((unsigned long long)__builtin_ia32_vcvtsd2usi64((__v2df)(__m128d)(A), \ + (int)(R))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS128 +_mm_cvtsd_u64 (__m128d __A) +{ + return (unsigned long long) __builtin_ia32_vcvtsd2usi64 ((__v2df) + __A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm_cvt_roundss_si32(A, R) \ + ((int)__builtin_ia32_vcvtss2si32((__v4sf)(__m128)(A), (int)(R))) + +#define _mm_cvt_roundss_i32(A, R) \ + ((int)__builtin_ia32_vcvtss2si32((__v4sf)(__m128)(A), (int)(R))) + +#ifdef __x86_64__ +#define _mm_cvt_roundss_si64(A, R) \ + ((long long)__builtin_ia32_vcvtss2si64((__v4sf)(__m128)(A), (int)(R))) + +#define _mm_cvt_roundss_i64(A, R) \ + ((long long)__builtin_ia32_vcvtss2si64((__v4sf)(__m128)(A), (int)(R))) +#endif + +#define _mm_cvt_roundss_u32(A, R) \ + ((unsigned int)__builtin_ia32_vcvtss2usi32((__v4sf)(__m128)(A), (int)(R))) + +static __inline__ unsigned __DEFAULT_FN_ATTRS128 +_mm_cvtss_u32 (__m128 __A) +{ + return (unsigned) __builtin_ia32_vcvtss2usi32 ((__v4sf) __A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvt_roundss_u64(A, R) \ + ((unsigned long long)__builtin_ia32_vcvtss2usi64((__v4sf)(__m128)(A), \ + (int)(R))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS128 +_mm_cvtss_u64 (__m128 __A) +{ + return (unsigned long long) __builtin_ia32_vcvtss2usi64 ((__v4sf) + __A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm_cvtt_roundsd_i32(A, R) \ + ((int)__builtin_ia32_vcvttsd2si32((__v2df)(__m128d)(A), (int)(R))) + +#define _mm_cvtt_roundsd_si32(A, R) \ + ((int)__builtin_ia32_vcvttsd2si32((__v2df)(__m128d)(A), (int)(R))) + +static __inline__ int __DEFAULT_FN_ATTRS128 +_mm_cvttsd_i32 (__m128d __A) +{ + return (int) __builtin_ia32_vcvttsd2si32 ((__v2df) __A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvtt_roundsd_si64(A, R) \ + ((long long)__builtin_ia32_vcvttsd2si64((__v2df)(__m128d)(A), (int)(R))) + +#define _mm_cvtt_roundsd_i64(A, R) \ + ((long long)__builtin_ia32_vcvttsd2si64((__v2df)(__m128d)(A), (int)(R))) + +static __inline__ long long __DEFAULT_FN_ATTRS128 +_mm_cvttsd_i64 (__m128d __A) +{ + return (long long) __builtin_ia32_vcvttsd2si64 ((__v2df) __A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm_cvtt_roundsd_u32(A, R) \ + ((unsigned int)__builtin_ia32_vcvttsd2usi32((__v2df)(__m128d)(A), (int)(R))) + +static __inline__ unsigned __DEFAULT_FN_ATTRS128 +_mm_cvttsd_u32 (__m128d __A) +{ + return (unsigned) __builtin_ia32_vcvttsd2usi32 ((__v2df) __A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvtt_roundsd_u64(A, R) \ + ((unsigned long long)__builtin_ia32_vcvttsd2usi64((__v2df)(__m128d)(A), \ + (int)(R))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS128 +_mm_cvttsd_u64 (__m128d __A) +{ + return (unsigned long long) __builtin_ia32_vcvttsd2usi64 ((__v2df) + __A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm_cvtt_roundss_i32(A, R) \ + ((int)__builtin_ia32_vcvttss2si32((__v4sf)(__m128)(A), (int)(R))) + +#define _mm_cvtt_roundss_si32(A, R) \ + ((int)__builtin_ia32_vcvttss2si32((__v4sf)(__m128)(A), (int)(R))) + +static __inline__ int __DEFAULT_FN_ATTRS128 +_mm_cvttss_i32 (__m128 __A) +{ + return (int) __builtin_ia32_vcvttss2si32 ((__v4sf) __A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvtt_roundss_i64(A, R) \ + ((long long)__builtin_ia32_vcvttss2si64((__v4sf)(__m128)(A), (int)(R))) + +#define _mm_cvtt_roundss_si64(A, R) \ + ((long long)__builtin_ia32_vcvttss2si64((__v4sf)(__m128)(A), (int)(R))) + +static __inline__ long long __DEFAULT_FN_ATTRS128 +_mm_cvttss_i64 (__m128 __A) +{ + return (long long) __builtin_ia32_vcvttss2si64 ((__v4sf) __A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm_cvtt_roundss_u32(A, R) \ + ((unsigned int)__builtin_ia32_vcvttss2usi32((__v4sf)(__m128)(A), (int)(R))) + +static __inline__ unsigned __DEFAULT_FN_ATTRS128 +_mm_cvttss_u32 (__m128 __A) +{ + return (unsigned) __builtin_ia32_vcvttss2usi32 ((__v4sf) __A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvtt_roundss_u64(A, R) \ + ((unsigned long long)__builtin_ia32_vcvttss2usi64((__v4sf)(__m128)(A), \ + (int)(R))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS128 +_mm_cvttss_u64 (__m128 __A) +{ + return (unsigned long long) __builtin_ia32_vcvttss2usi64 ((__v4sf) + __A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm512_permute_pd(X, C) \ + ((__m512d)__builtin_ia32_vpermilpd512((__v8df)(__m512d)(X), (int)(C))) + +#define _mm512_mask_permute_pd(W, U, X, C) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_permute_pd((X), (C)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_permute_pd(U, X, C) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_permute_pd((X), (C)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_permute_ps(X, C) \ + ((__m512)__builtin_ia32_vpermilps512((__v16sf)(__m512)(X), (int)(C))) + +#define _mm512_mask_permute_ps(W, U, X, C) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_permute_ps((X), (C)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_permute_ps(U, X, C) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_permute_ps((X), (C)), \ + (__v16sf)_mm512_setzero_ps())) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_permutevar_pd(__m512d __A, __m512i __C) +{ + return (__m512d)__builtin_ia32_vpermilvarpd512((__v8df)__A, (__v8di)__C); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_permutevar_pd(__m512d __W, __mmask8 __U, __m512d __A, __m512i __C) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_permutevar_pd(__A, __C), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutevar_pd(__mmask8 __U, __m512d __A, __m512i __C) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_permutevar_pd(__A, __C), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_permutevar_ps(__m512 __A, __m512i __C) +{ + return (__m512)__builtin_ia32_vpermilvarps512((__v16sf)__A, (__v16si)__C); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_permutevar_ps(__m512 __W, __mmask16 __U, __m512 __A, __m512i __C) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_permutevar_ps(__A, __C), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutevar_ps(__mmask16 __U, __m512 __A, __m512i __C) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_permutevar_ps(__A, __C), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline __m512d __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_pd(__m512d __A, __m512i __I, __m512d __B) +{ + return (__m512d)__builtin_ia32_vpermi2varpd512((__v8df)__A, (__v8di)__I, + (__v8df)__B); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_permutex2var_pd(__m512d __A, __mmask8 __U, __m512i __I, __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_permutex2var_pd(__A, __I, __B), + (__v8df)__A); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask2_permutex2var_pd(__m512d __A, __m512i __I, __mmask8 __U, + __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_permutex2var_pd(__A, __I, __B), + (__v8df)(__m512d)__I); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutex2var_pd(__mmask8 __U, __m512d __A, __m512i __I, + __m512d __B) +{ + return (__m512d)__builtin_ia32_selectpd_512(__U, + (__v8df)_mm512_permutex2var_pd(__A, __I, __B), + (__v8df)_mm512_setzero_pd()); +} + +static __inline __m512 __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_ps(__m512 __A, __m512i __I, __m512 __B) +{ + return (__m512)__builtin_ia32_vpermi2varps512((__v16sf)__A, (__v16si)__I, + (__v16sf) __B); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_permutex2var_ps(__m512 __A, __mmask16 __U, __m512i __I, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_permutex2var_ps(__A, __I, __B), + (__v16sf)__A); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask2_permutex2var_ps(__m512 __A, __m512i __I, __mmask16 __U, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_permutex2var_ps(__A, __I, __B), + (__v16sf)(__m512)__I); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutex2var_ps(__mmask16 __U, __m512 __A, __m512i __I, __m512 __B) +{ + return (__m512)__builtin_ia32_selectps_512(__U, + (__v16sf)_mm512_permutex2var_ps(__A, __I, __B), + (__v16sf)_mm512_setzero_ps()); +} + + +#define _mm512_cvtt_roundpd_epu32(A, R) \ + ((__m256i)__builtin_ia32_cvttpd2udq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_undefined_si256(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvtt_roundpd_epu32(W, U, A, R) \ + ((__m256i)__builtin_ia32_cvttpd2udq512_mask((__v8df)(__m512d)(A), \ + (__v8si)(__m256i)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundpd_epu32(U, A, R) \ + ((__m256i)__builtin_ia32_cvttpd2udq512_mask((__v8df)(__m512d)(A), \ + (__v8si)_mm256_setzero_si256(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvttpd_epu32 (__m512d __A) +{ + return (__m256i) __builtin_ia32_cvttpd2udq512_mask ((__v8df) __A, + (__v8si) + _mm256_undefined_si256 (), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttpd_epu32 (__m256i __W, __mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvttpd2udq512_mask ((__v8df) __A, + (__v8si) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttpd_epu32 (__mmask8 __U, __m512d __A) +{ + return (__m256i) __builtin_ia32_cvttpd2udq512_mask ((__v8df) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_roundscale_round_sd(A, B, imm, R) \ + ((__m128d)__builtin_ia32_rndscalesd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(imm), \ + (int)(R))) + +#define _mm_roundscale_sd(A, B, imm) \ + ((__m128d)__builtin_ia32_rndscalesd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(imm), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_roundscale_sd(W, U, A, B, imm) \ + ((__m128d)__builtin_ia32_rndscalesd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(imm), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_roundscale_round_sd(W, U, A, B, I, R) \ + ((__m128d)__builtin_ia32_rndscalesd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(I), \ + (int)(R))) + +#define _mm_maskz_roundscale_sd(U, A, B, I) \ + ((__m128d)__builtin_ia32_rndscalesd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(I), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_roundscale_round_sd(U, A, B, I, R) \ + ((__m128d)__builtin_ia32_rndscalesd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(I), \ + (int)(R))) + +#define _mm_roundscale_round_ss(A, B, imm, R) \ + ((__m128)__builtin_ia32_rndscaless_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(imm), \ + (int)(R))) + +#define _mm_roundscale_ss(A, B, imm) \ + ((__m128)__builtin_ia32_rndscaless_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(imm), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_roundscale_ss(W, U, A, B, I) \ + ((__m128)__builtin_ia32_rndscaless_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), (int)(I), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_roundscale_round_ss(W, U, A, B, I, R) \ + ((__m128)__builtin_ia32_rndscaless_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), (int)(I), \ + (int)(R))) + +#define _mm_maskz_roundscale_ss(U, A, B, I) \ + ((__m128)__builtin_ia32_rndscaless_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(I), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_roundscale_round_ss(U, A, B, I, R) \ + ((__m128)__builtin_ia32_rndscaless_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(I), \ + (int)(R))) + +#define _mm512_scalef_round_pd(A, B, R) \ + ((__m512d)__builtin_ia32_scalefpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_scalef_round_pd(W, U, A, B, R) \ + ((__m512d)__builtin_ia32_scalefpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_scalef_round_pd(U, A, B, R) \ + ((__m512d)__builtin_ia32_scalefpd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_scalef_pd (__m512d __A, __m512d __B) +{ + return (__m512d) __builtin_ia32_scalefpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) + _mm512_undefined_pd (), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_scalef_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d) __builtin_ia32_scalefpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_scalef_pd (__mmask8 __U, __m512d __A, __m512d __B) +{ + return (__m512d) __builtin_ia32_scalefpd512_mask ((__v8df) __A, + (__v8df) __B, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_scalef_round_ps(A, B, R) \ + ((__m512)__builtin_ia32_scalefps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_scalef_round_ps(W, U, A, B, R) \ + ((__m512)__builtin_ia32_scalefps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_scalef_round_ps(U, A, B, R) \ + ((__m512)__builtin_ia32_scalefps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_scalef_ps (__m512 __A, __m512 __B) +{ + return (__m512) __builtin_ia32_scalefps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) + _mm512_undefined_ps (), + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_scalef_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512) __builtin_ia32_scalefps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_scalef_ps (__mmask16 __U, __m512 __A, __m512 __B) +{ + return (__m512) __builtin_ia32_scalefps512_mask ((__v16sf) __A, + (__v16sf) __B, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_scalef_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_scalefsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_scalef_sd (__m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_scalefsd_round_mask ((__v2df) __A, + (__v2df)( __B), (__v2df) _mm_setzero_pd(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_scalefsd_round_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_scalef_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_scalefsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_sd (__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_scalefsd_round_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_scalef_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_scalefsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_scalef_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_scalefss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_scalef_ss (__m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_scalefss_round_mask ((__v4sf) __A, + (__v4sf)( __B), (__v4sf) _mm_setzero_ps(), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_scalefss_round_mask ( (__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_scalef_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_scalefss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_ss (__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_scalefss_round_mask ( (__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_scalef_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_scalefss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srai_epi32(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psradi512((__v16si)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srai_epi32(__m512i __W, __mmask16 __U, __m512i __A, + unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srai_epi32(__A, __B), + (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srai_epi32(__mmask16 __U, __m512i __A, + unsigned int __B) { + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_srai_epi32(__A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_srai_epi64(__m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_psraqi512((__v8di)__A, (int)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_srai_epi64(__m512i __W, __mmask8 __U, __m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srai_epi64(__A, __B), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_srai_epi64(__mmask8 __U, __m512i __A, unsigned int __B) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_srai_epi64(__A, __B), + (__v8di)_mm512_setzero_si512()); +} + +#define _mm512_shuffle_f32x4(A, B, imm) \ + ((__m512)__builtin_ia32_shuf_f32x4((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(imm))) + +#define _mm512_mask_shuffle_f32x4(W, U, A, B, imm) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_shuffle_f32x4((A), (B), (imm)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_shuffle_f32x4(U, A, B, imm) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_shuffle_f32x4((A), (B), (imm)), \ + (__v16sf)_mm512_setzero_ps())) + +#define _mm512_shuffle_f64x2(A, B, imm) \ + ((__m512d)__builtin_ia32_shuf_f64x2((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(imm))) + +#define _mm512_mask_shuffle_f64x2(W, U, A, B, imm) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_shuffle_f64x2((A), (B), (imm)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_shuffle_f64x2(U, A, B, imm) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_shuffle_f64x2((A), (B), (imm)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_shuffle_i32x4(A, B, imm) \ + ((__m512i)__builtin_ia32_shuf_i32x4((__v16si)(__m512i)(A), \ + (__v16si)(__m512i)(B), (int)(imm))) + +#define _mm512_mask_shuffle_i32x4(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shuffle_i32x4((A), (B), (imm)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_shuffle_i32x4(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shuffle_i32x4((A), (B), (imm)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_shuffle_i64x2(A, B, imm) \ + ((__m512i)__builtin_ia32_shuf_i64x2((__v8di)(__m512i)(A), \ + (__v8di)(__m512i)(B), (int)(imm))) + +#define _mm512_mask_shuffle_i64x2(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_shuffle_i64x2((A), (B), (imm)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_shuffle_i64x2(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_shuffle_i64x2((A), (B), (imm)), \ + (__v8di)_mm512_setzero_si512())) + +#define _mm512_shuffle_pd(A, B, M) \ + ((__m512d)__builtin_ia32_shufpd512((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(B), (int)(M))) + +#define _mm512_mask_shuffle_pd(W, U, A, B, M) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_shuffle_pd((A), (B), (M)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_shuffle_pd(U, A, B, M) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_shuffle_pd((A), (B), (M)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_shuffle_ps(A, B, M) \ + ((__m512)__builtin_ia32_shufps512((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(B), (int)(M))) + +#define _mm512_mask_shuffle_ps(W, U, A, B, M) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_shuffle_ps((A), (B), (M)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_shuffle_ps(U, A, B, M) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_shuffle_ps((A), (B), (M)), \ + (__v16sf)_mm512_setzero_ps())) + +#define _mm_sqrt_round_sd(A, B, R) \ + ((__m128d)__builtin_ia32_sqrtsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_sqrt_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_sqrtsd_round_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_sqrt_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_sqrtsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_sqrt_sd (__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d) __builtin_ia32_sqrtsd_round_mask ( (__v2df) __A, + (__v2df) __B, + (__v2df) _mm_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_sqrt_round_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_sqrtsd_round_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_sqrt_round_ss(A, B, R) \ + ((__m128)__builtin_ia32_sqrtss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_sqrt_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_sqrtss_round_mask ( (__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_sqrt_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_sqrtss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(W), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_sqrt_ss (__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128) __builtin_ia32_sqrtss_round_mask ( (__v4sf) __A, + (__v4sf) __B, + (__v4sf) _mm_setzero_ps (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_sqrt_round_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_sqrtss_round_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_broadcast_f32x4(__m128 __A) +{ + return (__m512)__builtin_shufflevector((__v4sf)__A, (__v4sf)__A, + 0, 1, 2, 3, 0, 1, 2, 3, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_f32x4(__m512 __O, __mmask16 __M, __m128 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__M, + (__v16sf)_mm512_broadcast_f32x4(__A), + (__v16sf)__O); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_f32x4(__mmask16 __M, __m128 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__M, + (__v16sf)_mm512_broadcast_f32x4(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_broadcast_f64x4(__m256d __A) +{ + return (__m512d)__builtin_shufflevector((__v4df)__A, (__v4df)__A, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_f64x4(__m512d __O, __mmask8 __M, __m256d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__M, + (__v8df)_mm512_broadcast_f64x4(__A), + (__v8df)__O); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_f64x4(__mmask8 __M, __m256d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__M, + (__v8df)_mm512_broadcast_f64x4(__A), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcast_i32x4(__m128i __A) +{ + return (__m512i)__builtin_shufflevector((__v4si)__A, (__v4si)__A, + 0, 1, 2, 3, 0, 1, 2, 3, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_i32x4(__m512i __O, __mmask16 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_broadcast_i32x4(__A), + (__v16si)__O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_i32x4(__mmask16 __M, __m128i __A) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_broadcast_i32x4(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_broadcast_i64x4(__m256i __A) +{ + return (__m512i)__builtin_shufflevector((__v4di)__A, (__v4di)__A, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcast_i64x4(__m512i __O, __mmask8 __M, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_broadcast_i64x4(__A), + (__v8di)__O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcast_i64x4(__mmask8 __M, __m256i __A) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_broadcast_i64x4(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcastsd_pd (__m512d __O, __mmask8 __M, __m128d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512(__M, + (__v8df) _mm512_broadcastsd_pd(__A), + (__v8df) __O); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcastsd_pd (__mmask8 __M, __m128d __A) +{ + return (__m512d)__builtin_ia32_selectpd_512(__M, + (__v8df) _mm512_broadcastsd_pd(__A), + (__v8df) _mm512_setzero_pd()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_broadcastss_ps (__m512 __O, __mmask16 __M, __m128 __A) +{ + return (__m512)__builtin_ia32_selectps_512(__M, + (__v16sf) _mm512_broadcastss_ps(__A), + (__v16sf) __O); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_broadcastss_ps (__mmask16 __M, __m128 __A) +{ + return (__m512)__builtin_ia32_selectps_512(__M, + (__v16sf) _mm512_broadcastss_ps(__A), + (__v16sf) _mm512_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtsepi32_epi8 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb512_mask ((__v16si) __A, + (__v16qi) _mm_undefined_si128 (), + (__mmask16) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb512_mask ((__v16si) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtsepi32_epi8 (__mmask16 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb512_mask ((__v16si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi32_storeu_epi8 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovsdb512mem_mask ((__v16qi *) __P, (__v16si) __A, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtsepi32_epi16 (__m512i __A) +{ + return (__m256i) __builtin_ia32_pmovsdw512_mask ((__v16si) __A, + (__v16hi) _mm256_undefined_si256 (), + (__mmask16) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi32_epi16 (__m256i __O, __mmask16 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovsdw512_mask ((__v16si) __A, + (__v16hi) __O, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtsepi32_epi16 (__mmask16 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovsdw512_mask ((__v16si) __A, + (__v16hi) _mm256_setzero_si256 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi32_storeu_epi16 (void *__P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovsdw512mem_mask ((__v16hi*) __P, (__v16si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtsepi64_epi8 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb512_mask ((__v8di) __A, + (__v16qi) _mm_undefined_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi64_epi8 (__m128i __O, __mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb512_mask ((__v8di) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtsepi64_epi8 (__mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb512_mask ((__v8di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi64_storeu_epi8 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovsqb512mem_mask ((__v16qi *) __P, (__v8di) __A, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtsepi64_epi32 (__m512i __A) +{ + return (__m256i) __builtin_ia32_pmovsqd512_mask ((__v8di) __A, + (__v8si) _mm256_undefined_si256 (), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi64_epi32 (__m256i __O, __mmask8 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovsqd512_mask ((__v8di) __A, + (__v8si) __O, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtsepi64_epi32 (__mmask8 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovsqd512_mask ((__v8di) __A, + (__v8si) _mm256_setzero_si256 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi64_storeu_epi32 (void *__P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovsqd512mem_mask ((__v8si *) __P, (__v8di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtsepi64_epi16 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw512_mask ((__v8di) __A, + (__v8hi) _mm_undefined_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi64_epi16 (__m128i __O, __mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw512_mask ((__v8di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtsepi64_epi16 (__mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw512_mask ((__v8di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtsepi64_storeu_epi16 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovsqw512mem_mask ((__v8hi *) __P, (__v8di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtusepi32_epi8 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb512_mask ((__v16si) __A, + (__v16qi) _mm_undefined_si128 (), + (__mmask16) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb512_mask ((__v16si) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtusepi32_epi8 (__mmask16 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb512_mask ((__v16si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi32_storeu_epi8 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovusdb512mem_mask ((__v16qi *) __P, (__v16si) __A, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtusepi32_epi16 (__m512i __A) +{ + return (__m256i) __builtin_ia32_pmovusdw512_mask ((__v16si) __A, + (__v16hi) _mm256_undefined_si256 (), + (__mmask16) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi32_epi16 (__m256i __O, __mmask16 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovusdw512_mask ((__v16si) __A, + (__v16hi) __O, + __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtusepi32_epi16 (__mmask16 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovusdw512_mask ((__v16si) __A, + (__v16hi) _mm256_setzero_si256 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi32_storeu_epi16 (void *__P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovusdw512mem_mask ((__v16hi*) __P, (__v16si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtusepi64_epi8 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb512_mask ((__v8di) __A, + (__v16qi) _mm_undefined_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi64_epi8 (__m128i __O, __mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb512_mask ((__v8di) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtusepi64_epi8 (__mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb512_mask ((__v8di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi64_storeu_epi8 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovusqb512mem_mask ((__v16qi *) __P, (__v8di) __A, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtusepi64_epi32 (__m512i __A) +{ + return (__m256i) __builtin_ia32_pmovusqd512_mask ((__v8di) __A, + (__v8si) _mm256_undefined_si256 (), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi64_epi32 (__m256i __O, __mmask8 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovusqd512_mask ((__v8di) __A, + (__v8si) __O, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtusepi64_epi32 (__mmask8 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovusqd512_mask ((__v8di) __A, + (__v8si) _mm256_setzero_si256 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi64_storeu_epi32 (void* __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovusqd512mem_mask ((__v8si*) __P, (__v8di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtusepi64_epi16 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw512_mask ((__v8di) __A, + (__v8hi) _mm_undefined_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi64_epi16 (__m128i __O, __mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw512_mask ((__v8di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtusepi64_epi16 (__mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw512_mask ((__v8di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtusepi64_storeu_epi16 (void *__P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovusqw512mem_mask ((__v8hi*) __P, (__v8di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32_epi8 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovdb512_mask ((__v16si) __A, + (__v16qi) _mm_undefined_si128 (), + (__mmask16) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovdb512_mask ((__v16si) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi32_epi8 (__mmask16 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovdb512_mask ((__v16si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_storeu_epi8 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovdb512mem_mask ((__v16qi *) __P, (__v16si) __A, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32_epi16 (__m512i __A) +{ + return (__m256i) __builtin_ia32_pmovdw512_mask ((__v16si) __A, + (__v16hi) _mm256_undefined_si256 (), + (__mmask16) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_epi16 (__m256i __O, __mmask16 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovdw512_mask ((__v16si) __A, + (__v16hi) __O, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi32_epi16 (__mmask16 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovdw512_mask ((__v16si) __A, + (__v16hi) _mm256_setzero_si256 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_storeu_epi16 (void * __P, __mmask16 __M, __m512i __A) +{ + __builtin_ia32_pmovdw512mem_mask ((__v16hi *) __P, (__v16si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi64_epi8 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovqb512_mask ((__v8di) __A, + (__v16qi) _mm_undefined_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_epi8 (__m128i __O, __mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovqb512_mask ((__v8di) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi64_epi8 (__mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovqb512_mask ((__v8di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_storeu_epi8 (void * __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovqb512mem_mask ((__v16qi *) __P, (__v8di) __A, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi64_epi32 (__m512i __A) +{ + return (__m256i) __builtin_ia32_pmovqd512_mask ((__v8di) __A, + (__v8si) _mm256_undefined_si256 (), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_epi32 (__m256i __O, __mmask8 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovqd512_mask ((__v8di) __A, + (__v8si) __O, __M); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi64_epi32 (__mmask8 __M, __m512i __A) +{ + return (__m256i) __builtin_ia32_pmovqd512_mask ((__v8di) __A, + (__v8si) _mm256_setzero_si256 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_storeu_epi32 (void* __P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovqd512mem_mask ((__v8si *) __P, (__v8di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_cvtepi64_epi16 (__m512i __A) +{ + return (__m128i) __builtin_ia32_pmovqw512_mask ((__v8di) __A, + (__v8hi) _mm_undefined_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_epi16 (__m128i __O, __mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovqw512_mask ((__v8di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi64_epi16 (__mmask8 __M, __m512i __A) +{ + return (__m128i) __builtin_ia32_pmovqw512_mask ((__v8di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_storeu_epi16 (void *__P, __mmask8 __M, __m512i __A) +{ + __builtin_ia32_pmovqw512mem_mask ((__v8hi *) __P, (__v8di) __A, __M); +} + +#define _mm512_extracti32x4_epi32(A, imm) \ + ((__m128i)__builtin_ia32_extracti32x4_mask((__v16si)(__m512i)(A), (int)(imm), \ + (__v4si)_mm_undefined_si128(), \ + (__mmask8)-1)) + +#define _mm512_mask_extracti32x4_epi32(W, U, A, imm) \ + ((__m128i)__builtin_ia32_extracti32x4_mask((__v16si)(__m512i)(A), (int)(imm), \ + (__v4si)(__m128i)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extracti32x4_epi32(U, A, imm) \ + ((__m128i)__builtin_ia32_extracti32x4_mask((__v16si)(__m512i)(A), (int)(imm), \ + (__v4si)_mm_setzero_si128(), \ + (__mmask8)(U))) + +#define _mm512_extracti64x4_epi64(A, imm) \ + ((__m256i)__builtin_ia32_extracti64x4_mask((__v8di)(__m512i)(A), (int)(imm), \ + (__v4di)_mm256_undefined_si256(), \ + (__mmask8)-1)) + +#define _mm512_mask_extracti64x4_epi64(W, U, A, imm) \ + ((__m256i)__builtin_ia32_extracti64x4_mask((__v8di)(__m512i)(A), (int)(imm), \ + (__v4di)(__m256i)(W), \ + (__mmask8)(U))) + +#define _mm512_maskz_extracti64x4_epi64(U, A, imm) \ + ((__m256i)__builtin_ia32_extracti64x4_mask((__v8di)(__m512i)(A), (int)(imm), \ + (__v4di)_mm256_setzero_si256(), \ + (__mmask8)(U))) + +#define _mm512_insertf64x4(A, B, imm) \ + ((__m512d)__builtin_ia32_insertf64x4((__v8df)(__m512d)(A), \ + (__v4df)(__m256d)(B), (int)(imm))) + +#define _mm512_mask_insertf64x4(W, U, A, B, imm) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_insertf64x4((A), (B), (imm)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_insertf64x4(U, A, B, imm) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_insertf64x4((A), (B), (imm)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_inserti64x4(A, B, imm) \ + ((__m512i)__builtin_ia32_inserti64x4((__v8di)(__m512i)(A), \ + (__v4di)(__m256i)(B), (int)(imm))) + +#define _mm512_mask_inserti64x4(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_inserti64x4((A), (B), (imm)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_inserti64x4(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_inserti64x4((A), (B), (imm)), \ + (__v8di)_mm512_setzero_si512())) + +#define _mm512_insertf32x4(A, B, imm) \ + ((__m512)__builtin_ia32_insertf32x4((__v16sf)(__m512)(A), \ + (__v4sf)(__m128)(B), (int)(imm))) + +#define _mm512_mask_insertf32x4(W, U, A, B, imm) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_insertf32x4((A), (B), (imm)), \ + (__v16sf)(__m512)(W))) + +#define _mm512_maskz_insertf32x4(U, A, B, imm) \ + ((__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ + (__v16sf)_mm512_insertf32x4((A), (B), (imm)), \ + (__v16sf)_mm512_setzero_ps())) + +#define _mm512_inserti32x4(A, B, imm) \ + ((__m512i)__builtin_ia32_inserti32x4((__v16si)(__m512i)(A), \ + (__v4si)(__m128i)(B), (int)(imm))) + +#define _mm512_mask_inserti32x4(W, U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_inserti32x4((A), (B), (imm)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_inserti32x4(U, A, B, imm) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_inserti32x4((A), (B), (imm)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_getmant_round_pd(A, B, C, R) \ + ((__m512d)__builtin_ia32_getmantpd512_mask((__v8df)(__m512d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_getmant_round_pd(W, U, A, B, C, R) \ + ((__m512d)__builtin_ia32_getmantpd512_mask((__v8df)(__m512d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_getmant_round_pd(U, A, B, C, R) \ + ((__m512d)__builtin_ia32_getmantpd512_mask((__v8df)(__m512d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_getmant_pd(A, B, C) \ + ((__m512d)__builtin_ia32_getmantpd512_mask((__v8df)(__m512d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_getmant_pd(W, U, A, B, C) \ + ((__m512d)__builtin_ia32_getmantpd512_mask((__v8df)(__m512d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_getmant_pd(U, A, B, C) \ + ((__m512d)__builtin_ia32_getmantpd512_mask((__v8df)(__m512d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_getmant_round_ps(A, B, C, R) \ + ((__m512)__builtin_ia32_getmantps512_mask((__v16sf)(__m512)(A), \ + (int)(((C)<<2) | (B)), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_getmant_round_ps(W, U, A, B, C, R) \ + ((__m512)__builtin_ia32_getmantps512_mask((__v16sf)(__m512)(A), \ + (int)(((C)<<2) | (B)), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_getmant_round_ps(U, A, B, C, R) \ + ((__m512)__builtin_ia32_getmantps512_mask((__v16sf)(__m512)(A), \ + (int)(((C)<<2) | (B)), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_getmant_ps(A, B, C) \ + ((__m512)__builtin_ia32_getmantps512_mask((__v16sf)(__m512)(A), \ + (int)(((C)<<2)|(B)), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_getmant_ps(W, U, A, B, C) \ + ((__m512)__builtin_ia32_getmantps512_mask((__v16sf)(__m512)(A), \ + (int)(((C)<<2)|(B)), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_getmant_ps(U, A, B, C) \ + ((__m512)__builtin_ia32_getmantps512_mask((__v16sf)(__m512)(A), \ + (int)(((C)<<2)|(B)), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_getexp_round_pd(A, R) \ + ((__m512d)__builtin_ia32_getexppd512_mask((__v8df)(__m512d)(A), \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_getexp_round_pd(W, U, A, R) \ + ((__m512d)__builtin_ia32_getexppd512_mask((__v8df)(__m512d)(A), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_getexp_round_pd(U, A, R) \ + ((__m512d)__builtin_ia32_getexppd512_mask((__v8df)(__m512d)(A), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_getexp_pd (__m512d __A) +{ + return (__m512d) __builtin_ia32_getexppd512_mask ((__v8df) __A, + (__v8df) _mm512_undefined_pd (), + (__mmask8) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_getexp_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_getexppd512_mask ((__v8df) __A, + (__v8df) __W, + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_getexp_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_getexppd512_mask ((__v8df) __A, + (__v8df) _mm512_setzero_pd (), + (__mmask8) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_getexp_round_ps(A, R) \ + ((__m512)__builtin_ia32_getexpps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_getexp_round_ps(W, U, A, R) \ + ((__m512)__builtin_ia32_getexpps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)(__m512)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_getexp_round_ps(U, A, R) \ + ((__m512)__builtin_ia32_getexpps512_mask((__v16sf)(__m512)(A), \ + (__v16sf)_mm512_setzero_ps(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_getexp_ps (__m512 __A) +{ + return (__m512) __builtin_ia32_getexpps512_mask ((__v16sf) __A, + (__v16sf) _mm512_undefined_ps (), + (__mmask16) -1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_getexp_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_getexpps512_mask ((__v16sf) __A, + (__v16sf) __W, + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_getexp_ps (__mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_getexpps512_mask ((__v16sf) __A, + (__v16sf) _mm512_setzero_ps (), + (__mmask16) __U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_i64gather_ps(index, addr, scale) \ + ((__m256)__builtin_ia32_gatherdiv16sf((__v8sf)_mm256_undefined_ps(), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), (__mmask8)-1, \ + (int)(scale))) + +#define _mm512_mask_i64gather_ps(v1_old, mask, index, addr, scale) \ + ((__m256)__builtin_ia32_gatherdiv16sf((__v8sf)(__m256)(v1_old),\ + (void const *)(addr), \ + (__v8di)(__m512i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm512_i64gather_epi32(index, addr, scale) \ + ((__m256i)__builtin_ia32_gatherdiv16si((__v8si)_mm256_undefined_si256(), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), \ + (__mmask8)-1, (int)(scale))) + +#define _mm512_mask_i64gather_epi32(v1_old, mask, index, addr, scale) \ + ((__m256i)__builtin_ia32_gatherdiv16si((__v8si)(__m256i)(v1_old), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm512_i64gather_pd(index, addr, scale) \ + ((__m512d)__builtin_ia32_gatherdiv8df((__v8df)_mm512_undefined_pd(), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), (__mmask8)-1, \ + (int)(scale))) + +#define _mm512_mask_i64gather_pd(v1_old, mask, index, addr, scale) \ + ((__m512d)__builtin_ia32_gatherdiv8df((__v8df)(__m512d)(v1_old), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm512_i64gather_epi64(index, addr, scale) \ + ((__m512i)__builtin_ia32_gatherdiv8di((__v8di)_mm512_undefined_epi32(), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), (__mmask8)-1, \ + (int)(scale))) + +#define _mm512_mask_i64gather_epi64(v1_old, mask, index, addr, scale) \ + ((__m512i)__builtin_ia32_gatherdiv8di((__v8di)(__m512i)(v1_old), \ + (void const *)(addr), \ + (__v8di)(__m512i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm512_i32gather_ps(index, addr, scale) \ + ((__m512)__builtin_ia32_gathersiv16sf((__v16sf)_mm512_undefined_ps(), \ + (void const *)(addr), \ + (__v16si)(__m512)(index), \ + (__mmask16)-1, (int)(scale))) + +#define _mm512_mask_i32gather_ps(v1_old, mask, index, addr, scale) \ + ((__m512)__builtin_ia32_gathersiv16sf((__v16sf)(__m512)(v1_old), \ + (void const *)(addr), \ + (__v16si)(__m512)(index), \ + (__mmask16)(mask), (int)(scale))) + +#define _mm512_i32gather_epi32(index, addr, scale) \ + ((__m512i)__builtin_ia32_gathersiv16si((__v16si)_mm512_undefined_epi32(), \ + (void const *)(addr), \ + (__v16si)(__m512i)(index), \ + (__mmask16)-1, (int)(scale))) + +#define _mm512_mask_i32gather_epi32(v1_old, mask, index, addr, scale) \ + ((__m512i)__builtin_ia32_gathersiv16si((__v16si)(__m512i)(v1_old), \ + (void const *)(addr), \ + (__v16si)(__m512i)(index), \ + (__mmask16)(mask), (int)(scale))) + +#define _mm512_i32gather_pd(index, addr, scale) \ + ((__m512d)__builtin_ia32_gathersiv8df((__v8df)_mm512_undefined_pd(), \ + (void const *)(addr), \ + (__v8si)(__m256i)(index), (__mmask8)-1, \ + (int)(scale))) + +#define _mm512_mask_i32gather_pd(v1_old, mask, index, addr, scale) \ + ((__m512d)__builtin_ia32_gathersiv8df((__v8df)(__m512d)(v1_old), \ + (void const *)(addr), \ + (__v8si)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm512_i32gather_epi64(index, addr, scale) \ + ((__m512i)__builtin_ia32_gathersiv8di((__v8di)_mm512_undefined_epi32(), \ + (void const *)(addr), \ + (__v8si)(__m256i)(index), (__mmask8)-1, \ + (int)(scale))) + +#define _mm512_mask_i32gather_epi64(v1_old, mask, index, addr, scale) \ + ((__m512i)__builtin_ia32_gathersiv8di((__v8di)(__m512i)(v1_old), \ + (void const *)(addr), \ + (__v8si)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm512_i64scatter_ps(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv16sf((void *)(addr), (__mmask8)-1, \ + (__v8di)(__m512i)(index), \ + (__v8sf)(__m256)(v1), (int)(scale)) + +#define _mm512_mask_i64scatter_ps(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv16sf((void *)(addr), (__mmask8)(mask), \ + (__v8di)(__m512i)(index), \ + (__v8sf)(__m256)(v1), (int)(scale)) + +#define _mm512_i64scatter_epi32(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv16si((void *)(addr), (__mmask8)-1, \ + (__v8di)(__m512i)(index), \ + (__v8si)(__m256i)(v1), (int)(scale)) + +#define _mm512_mask_i64scatter_epi32(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv16si((void *)(addr), (__mmask8)(mask), \ + (__v8di)(__m512i)(index), \ + (__v8si)(__m256i)(v1), (int)(scale)) + +#define _mm512_i64scatter_pd(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv8df((void *)(addr), (__mmask8)-1, \ + (__v8di)(__m512i)(index), \ + (__v8df)(__m512d)(v1), (int)(scale)) + +#define _mm512_mask_i64scatter_pd(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv8df((void *)(addr), (__mmask8)(mask), \ + (__v8di)(__m512i)(index), \ + (__v8df)(__m512d)(v1), (int)(scale)) + +#define _mm512_i64scatter_epi64(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv8di((void *)(addr), (__mmask8)-1, \ + (__v8di)(__m512i)(index), \ + (__v8di)(__m512i)(v1), (int)(scale)) + +#define _mm512_mask_i64scatter_epi64(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv8di((void *)(addr), (__mmask8)(mask), \ + (__v8di)(__m512i)(index), \ + (__v8di)(__m512i)(v1), (int)(scale)) + +#define _mm512_i32scatter_ps(addr, index, v1, scale) \ + __builtin_ia32_scattersiv16sf((void *)(addr), (__mmask16)-1, \ + (__v16si)(__m512i)(index), \ + (__v16sf)(__m512)(v1), (int)(scale)) + +#define _mm512_mask_i32scatter_ps(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv16sf((void *)(addr), (__mmask16)(mask), \ + (__v16si)(__m512i)(index), \ + (__v16sf)(__m512)(v1), (int)(scale)) + +#define _mm512_i32scatter_epi32(addr, index, v1, scale) \ + __builtin_ia32_scattersiv16si((void *)(addr), (__mmask16)-1, \ + (__v16si)(__m512i)(index), \ + (__v16si)(__m512i)(v1), (int)(scale)) + +#define _mm512_mask_i32scatter_epi32(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv16si((void *)(addr), (__mmask16)(mask), \ + (__v16si)(__m512i)(index), \ + (__v16si)(__m512i)(v1), (int)(scale)) + +#define _mm512_i32scatter_pd(addr, index, v1, scale) \ + __builtin_ia32_scattersiv8df((void *)(addr), (__mmask8)-1, \ + (__v8si)(__m256i)(index), \ + (__v8df)(__m512d)(v1), (int)(scale)) + +#define _mm512_mask_i32scatter_pd(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv8df((void *)(addr), (__mmask8)(mask), \ + (__v8si)(__m256i)(index), \ + (__v8df)(__m512d)(v1), (int)(scale)) + +#define _mm512_i32scatter_epi64(addr, index, v1, scale) \ + __builtin_ia32_scattersiv8di((void *)(addr), (__mmask8)-1, \ + (__v8si)(__m256i)(index), \ + (__v8di)(__m512i)(v1), (int)(scale)) + +#define _mm512_mask_i32scatter_epi64(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv8di((void *)(addr), (__mmask8)(mask), \ + (__v8si)(__m256i)(index), \ + (__v8di)(__m512i)(v1), (int)(scale)) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return __builtin_ia32_vfmaddss3_mask((__v4sf)__W, + (__v4sf)__A, + (__v4sf)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmadd_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fmadd_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \ + (__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return __builtin_ia32_vfmaddss3_maskz((__v4sf)__A, + (__v4sf)__B, + (__v4sf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fmadd_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_maskz((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(C), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmaddss3_mask3((__v4sf)__W, + (__v4sf)__X, + (__v4sf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fmadd_round_ss(W, X, Y, U, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask3((__v4sf)(__m128)(W), \ + (__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return __builtin_ia32_vfmaddss3_mask((__v4sf)__W, + (__v4sf)__A, + -(__v4sf)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmsub_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + -(__v4sf)(__m128)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fmsub_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \ + (__v4sf)(__m128)(A), \ + -(__v4sf)(__m128)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return __builtin_ia32_vfmaddss3_maskz((__v4sf)__A, + (__v4sf)__B, + -(__v4sf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fmsub_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_maskz((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + -(__v4sf)(__m128)(C), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmsubss3_mask3((__v4sf)__W, + (__v4sf)__X, + (__v4sf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fmsub_round_ss(W, X, Y, U, R) \ + ((__m128)__builtin_ia32_vfmsubss3_mask3((__v4sf)(__m128)(W), \ + (__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return __builtin_ia32_vfmaddss3_mask((__v4sf)__W, + -(__v4sf)__A, + (__v4sf)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fnmadd_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \ + -(__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fnmadd_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \ + -(__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return __builtin_ia32_vfmaddss3_maskz((__v4sf)__A, + -(__v4sf)__B, + (__v4sf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fnmadd_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_maskz((__v4sf)(__m128)(A), \ + -(__v4sf)(__m128)(B), \ + (__v4sf)(__m128)(C), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmaddss3_mask3((__v4sf)__W, + -(__v4sf)__X, + (__v4sf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fnmadd_round_ss(W, X, Y, U, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask3((__v4sf)(__m128)(W), \ + -(__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return __builtin_ia32_vfmaddss3_mask((__v4sf)__W, + -(__v4sf)__A, + -(__v4sf)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fnmsub_round_ss(A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \ + -(__v4sf)(__m128)(B), \ + -(__v4sf)(__m128)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fnmsub_round_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \ + -(__v4sf)(__m128)(A), \ + -(__v4sf)(__m128)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_ss (__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return __builtin_ia32_vfmaddss3_maskz((__v4sf)__A, + -(__v4sf)__B, + -(__v4sf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fnmsub_round_ss(U, A, B, C, R) \ + ((__m128)__builtin_ia32_vfmaddss3_maskz((__v4sf)(__m128)(A), \ + -(__v4sf)(__m128)(B), \ + -(__v4sf)(__m128)(C), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_ss (__m128 __W, __m128 __X, __m128 __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmsubss3_mask3((__v4sf)__W, + -(__v4sf)__X, + (__v4sf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fnmsub_round_ss(W, X, Y, U, R) \ + ((__m128)__builtin_ia32_vfmsubss3_mask3((__v4sf)(__m128)(W), \ + -(__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return __builtin_ia32_vfmaddsd3_mask((__v2df)__W, + (__v2df)__A, + (__v2df)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmadd_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fmadd_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(W), \ + (__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_sd (__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return __builtin_ia32_vfmaddsd3_maskz((__v2df)__A, + (__v2df)__B, + (__v2df)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fmadd_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_maskz((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(C), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_sd (__m128d __W, __m128d __X, __m128d __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmaddsd3_mask3((__v2df)__W, + (__v2df)__X, + (__v2df)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fmadd_round_sd(W, X, Y, U, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask3((__v2df)(__m128d)(W), \ + (__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fmsub_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return __builtin_ia32_vfmaddsd3_mask((__v2df)__W, + (__v2df)__A, + -(__v2df)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmsub_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + -(__v2df)(__m128d)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fmsub_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(W), \ + (__v2df)(__m128d)(A), \ + -(__v2df)(__m128d)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_sd (__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return __builtin_ia32_vfmaddsd3_maskz((__v2df)__A, + (__v2df)__B, + -(__v2df)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fmsub_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_maskz((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + -(__v2df)(__m128d)(C), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_sd (__m128d __W, __m128d __X, __m128d __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmsubsd3_mask3((__v2df)__W, + (__v2df)__X, + (__v2df)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fmsub_round_sd(W, X, Y, U, R) \ + ((__m128d)__builtin_ia32_vfmsubsd3_mask3((__v2df)(__m128d)(W), \ + (__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return __builtin_ia32_vfmaddsd3_mask((__v2df)__W, + -(__v2df)__A, + (__v2df)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fnmadd_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(A), \ + -(__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fnmadd_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(W), \ + -(__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_sd (__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return __builtin_ia32_vfmaddsd3_maskz((__v2df)__A, + -(__v2df)__B, + (__v2df)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fnmadd_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_maskz((__v2df)(__m128d)(A), \ + -(__v2df)(__m128d)(B), \ + (__v2df)(__m128d)(C), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_sd (__m128d __W, __m128d __X, __m128d __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmaddsd3_mask3((__v2df)__W, + -(__v2df)__X, + (__v2df)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fnmadd_round_sd(W, X, Y, U, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask3((__v2df)(__m128d)(W), \ + -(__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return __builtin_ia32_vfmaddsd3_mask((__v2df)__W, + -(__v2df)__A, + -(__v2df)__B, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fnmsub_round_sd(A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(A), \ + -(__v2df)(__m128d)(B), \ + -(__v2df)(__m128d)(C), (__mmask8)-1, \ + (int)(R))) + +#define _mm_mask_fnmsub_round_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_mask((__v2df)(__m128d)(W), \ + -(__v2df)(__m128d)(A), \ + -(__v2df)(__m128d)(B), (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_sd (__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return __builtin_ia32_vfmaddsd3_maskz((__v2df)__A, + -(__v2df)__B, + -(__v2df)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fnmsub_round_sd(U, A, B, C, R) \ + ((__m128d)__builtin_ia32_vfmaddsd3_maskz((__v2df)(__m128d)(A), \ + -(__v2df)(__m128d)(B), \ + -(__v2df)(__m128d)(C), \ + (__mmask8)(U), \ + (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_sd (__m128d __W, __m128d __X, __m128d __Y, __mmask8 __U) +{ + return __builtin_ia32_vfmsubsd3_mask3((__v2df)__W, + -(__v2df)__X, + (__v2df)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fnmsub_round_sd(W, X, Y, U, R) \ + ((__m128d)__builtin_ia32_vfmsubsd3_mask3((__v2df)(__m128d)(W), \ + -(__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_permutex_pd(X, C) \ + ((__m512d)__builtin_ia32_permdf512((__v8df)(__m512d)(X), (int)(C))) + +#define _mm512_mask_permutex_pd(W, U, X, C) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_permutex_pd((X), (C)), \ + (__v8df)(__m512d)(W))) + +#define _mm512_maskz_permutex_pd(U, X, C) \ + ((__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ + (__v8df)_mm512_permutex_pd((X), (C)), \ + (__v8df)_mm512_setzero_pd())) + +#define _mm512_permutex_epi64(X, C) \ + ((__m512i)__builtin_ia32_permdi512((__v8di)(__m512i)(X), (int)(C))) + +#define _mm512_mask_permutex_epi64(W, U, X, C) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_permutex_epi64((X), (C)), \ + (__v8di)(__m512i)(W))) + +#define _mm512_maskz_permutex_epi64(U, X, C) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_permutex_epi64((X), (C)), \ + (__v8di)_mm512_setzero_si512())) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_pd (__m512i __X, __m512d __Y) +{ + return (__m512d)__builtin_ia32_permvardf512((__v8df) __Y, (__v8di) __X); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_permutexvar_pd (__m512d __W, __mmask8 __U, __m512i __X, __m512d __Y) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_permutexvar_pd(__X, __Y), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutexvar_pd (__mmask8 __U, __m512i __X, __m512d __Y) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_permutexvar_pd(__X, __Y), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_epi64 (__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_permvardi512((__v8di)__Y, (__v8di)__X); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutexvar_epi64 (__mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_permutexvar_epi64(__X, __Y), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_permutexvar_epi64 (__m512i __W, __mmask8 __M, __m512i __X, + __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, + (__v8di)_mm512_permutexvar_epi64(__X, __Y), + (__v8di)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_ps (__m512i __X, __m512 __Y) +{ + return (__m512)__builtin_ia32_permvarsf512((__v16sf)__Y, (__v16si)__X); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_permutexvar_ps (__m512 __W, __mmask16 __U, __m512i __X, __m512 __Y) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_permutexvar_ps(__X, __Y), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutexvar_ps (__mmask16 __U, __m512i __X, __m512 __Y) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_permutexvar_ps(__X, __Y), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_epi32 (__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_permvarsi512((__v16si)__Y, (__v16si)__X); +} + +#define _mm512_permutevar_epi32 _mm512_permutexvar_epi32 + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_permutexvar_epi32 (__mmask16 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_permutexvar_epi32(__X, __Y), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_permutexvar_epi32 (__m512i __W, __mmask16 __M, __m512i __X, + __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, + (__v16si)_mm512_permutexvar_epi32(__X, __Y), + (__v16si)__W); +} + +#define _mm512_mask_permutevar_epi32 _mm512_mask_permutexvar_epi32 + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kand (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kandhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kandn (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kandnhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kor (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_korhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ int __DEFAULT_FN_ATTRS +_mm512_kortestc (__mmask16 __A, __mmask16 __B) +{ + return __builtin_ia32_kortestchi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ int __DEFAULT_FN_ATTRS +_mm512_kortestz (__mmask16 __A, __mmask16 __B) +{ + return __builtin_ia32_kortestzhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestc_mask16_u8(__mmask16 __A, __mmask16 __B) +{ + return (unsigned char)__builtin_ia32_kortestchi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortestz_mask16_u8(__mmask16 __A, __mmask16 __B) +{ + return (unsigned char)__builtin_ia32_kortestzhi(__A, __B); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_kortest_mask16_u8(__mmask16 __A, __mmask16 __B, unsigned char *__C) { + *__C = (unsigned char)__builtin_ia32_kortestchi(__A, __B); + return (unsigned char)__builtin_ia32_kortestzhi(__A, __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kunpackb (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kunpckhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kxnor (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kxnorhi ((__mmask16) __A, (__mmask16) __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_mm512_kxor (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kxorhi ((__mmask16) __A, (__mmask16) __B); +} + +#define _kand_mask16 _mm512_kand +#define _kandn_mask16 _mm512_kandn +#define _knot_mask16 _mm512_knot +#define _kor_mask16 _mm512_kor +#define _kxnor_mask16 _mm512_kxnor +#define _kxor_mask16 _mm512_kxor + +#define _kshiftli_mask16(A, I) \ + ((__mmask16)__builtin_ia32_kshiftlihi((__mmask16)(A), (unsigned int)(I))) + +#define _kshiftri_mask16(A, I) \ + ((__mmask16)__builtin_ia32_kshiftrihi((__mmask16)(A), (unsigned int)(I))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_cvtmask16_u32(__mmask16 __A) { + return (unsigned int)__builtin_ia32_kmovw((__mmask16)__A); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_cvtu32_mask16(unsigned int __A) { + return (__mmask16)__builtin_ia32_kmovw((__mmask16)__A); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS +_load_mask16(__mmask16 *__A) { + return (__mmask16)__builtin_ia32_kmovw(*(__mmask16 *)__A); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_store_mask16(__mmask16 *__A, __mmask16 __B) { + *(__mmask16 *)__A = __builtin_ia32_kmovw((__mmask16)__B); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_stream_si512 (void * __P, __m512i __A) +{ + typedef __v8di __v8di_aligned __attribute__((aligned(64))); + __builtin_nontemporal_store((__v8di_aligned)__A, (__v8di_aligned*)__P); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_stream_load_si512 (void const *__P) +{ + typedef __v8di __v8di_aligned __attribute__((aligned(64))); + return (__m512i) __builtin_nontemporal_load((const __v8di_aligned *)__P); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_stream_pd (void *__P, __m512d __A) +{ + typedef __v8df __v8df_aligned __attribute__((aligned(64))); + __builtin_nontemporal_store((__v8df_aligned)__A, (__v8df_aligned*)__P); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_stream_ps (void *__P, __m512 __A) +{ + typedef __v16sf __v16sf_aligned __attribute__((aligned(64))); + __builtin_nontemporal_store((__v16sf_aligned)__A, (__v16sf_aligned*)__P); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_compress_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_compressdf512_mask ((__v8df) __A, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_compress_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_compressdf512_mask ((__v8df) __A, + (__v8df) + _mm512_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_compress_epi64 (__m512i __W, __mmask8 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_compressdi512_mask ((__v8di) __A, + (__v8di) __W, + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_compress_epi64 (__mmask8 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_compressdi512_mask ((__v8di) __A, + (__v8di) + _mm512_setzero_si512 (), + (__mmask8) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_compress_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_compresssf512_mask ((__v16sf) __A, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_compress_ps (__mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_compresssf512_mask ((__v16sf) __A, + (__v16sf) + _mm512_setzero_ps (), + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_compress_epi32 (__m512i __W, __mmask16 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_compresssi512_mask ((__v16si) __A, + (__v16si) __W, + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_compress_epi32 (__mmask16 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_compresssi512_mask ((__v16si) __A, + (__v16si) + _mm512_setzero_si512 (), + (__mmask16) __U); +} + +#define _mm_cmp_round_ss_mask(X, Y, P, R) \ + ((__mmask8)__builtin_ia32_cmpss_mask((__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (int)(P), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_cmp_round_ss_mask(M, X, Y, P, R) \ + ((__mmask8)__builtin_ia32_cmpss_mask((__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (int)(P), \ + (__mmask8)(M), (int)(R))) + +#define _mm_cmp_ss_mask(X, Y, P) \ + ((__mmask8)__builtin_ia32_cmpss_mask((__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (int)(P), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_cmp_ss_mask(M, X, Y, P) \ + ((__mmask8)__builtin_ia32_cmpss_mask((__v4sf)(__m128)(X), \ + (__v4sf)(__m128)(Y), (int)(P), \ + (__mmask8)(M), \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_cmp_round_sd_mask(X, Y, P, R) \ + ((__mmask8)__builtin_ia32_cmpsd_mask((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (int)(P), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_cmp_round_sd_mask(M, X, Y, P, R) \ + ((__mmask8)__builtin_ia32_cmpsd_mask((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (int)(P), \ + (__mmask8)(M), (int)(R))) + +#define _mm_cmp_sd_mask(X, Y, P) \ + ((__mmask8)__builtin_ia32_cmpsd_mask((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (int)(P), \ + (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_cmp_sd_mask(M, X, Y, P) \ + ((__mmask8)__builtin_ia32_cmpsd_mask((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), (int)(P), \ + (__mmask8)(M), \ + _MM_FROUND_CUR_DIRECTION)) + +/* Bit Test */ + +static __inline __mmask16 __DEFAULT_FN_ATTRS512 +_mm512_test_epi32_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpneq_epi32_mask (_mm512_and_epi32(__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS512 +_mm512_mask_test_epi32_mask (__mmask16 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpneq_epi32_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline __mmask8 __DEFAULT_FN_ATTRS512 +_mm512_test_epi64_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpneq_epi64_mask (_mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS512 +_mm512_mask_test_epi64_mask (__mmask8 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpneq_epi64_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS512 +_mm512_testn_epi32_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpeq_epi32_mask (_mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS512 +_mm512_mask_testn_epi32_mask (__mmask16 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpeq_epi32_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS512 +_mm512_testn_epi64_mask (__m512i __A, __m512i __B) +{ + return _mm512_cmpeq_epi64_mask (_mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS512 +_mm512_mask_testn_epi64_mask (__mmask8 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_cmpeq_epi64_mask (__U, _mm512_and_epi32 (__A, __B), + _mm512_setzero_si512()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_movehdup_ps (__m512 __A) +{ + return (__m512)__builtin_shufflevector((__v16sf)__A, (__v16sf)__A, + 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_movehdup_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_movehdup_ps(__A), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_movehdup_ps (__mmask16 __U, __m512 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_movehdup_ps(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_moveldup_ps (__m512 __A) +{ + return (__m512)__builtin_shufflevector((__v16sf)__A, (__v16sf)__A, + 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_moveldup_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_moveldup_ps(__A), + (__v16sf)__W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_moveldup_ps (__mmask16 __U, __m512 __A) +{ + return (__m512)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_moveldup_ps(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return __builtin_ia32_selectss_128(__U, _mm_move_ss(__A, __B), __W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B) +{ + return __builtin_ia32_selectss_128(__U, _mm_move_ss(__A, __B), + _mm_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_move_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return __builtin_ia32_selectsd_128(__U, _mm_move_sd(__A, __B), __W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B) +{ + return __builtin_ia32_selectsd_128(__U, _mm_move_sd(__A, __B), + _mm_setzero_pd()); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __A) +{ + __builtin_ia32_storess128_mask ((__v4sf *)__W, __A, __U & 1); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_store_sd (double * __W, __mmask8 __U, __m128d __A) +{ + __builtin_ia32_storesd128_mask ((__v2df *)__W, __A, __U & 1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_load_ss (__m128 __W, __mmask8 __U, const float* __A) +{ + __m128 src = (__v4sf) __builtin_shufflevector((__v4sf) __W, + (__v4sf)_mm_setzero_ps(), + 0, 4, 4, 4); + + return (__m128) __builtin_ia32_loadss128_mask ((const __v4sf *) __A, src, __U & 1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_load_ss (__mmask8 __U, const float* __A) +{ + return (__m128)__builtin_ia32_loadss128_mask ((const __v4sf *) __A, + (__v4sf) _mm_setzero_ps(), + __U & 1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_load_sd (__m128d __W, __mmask8 __U, const double* __A) +{ + __m128d src = (__v2df) __builtin_shufflevector((__v2df) __W, + (__v2df)_mm_setzero_pd(), + 0, 2); + + return (__m128d) __builtin_ia32_loadsd128_mask ((const __v2df *) __A, src, __U & 1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_load_sd (__mmask8 __U, const double* __A) +{ + return (__m128d) __builtin_ia32_loadsd128_mask ((const __v2df *) __A, + (__v2df) _mm_setzero_pd(), + __U & 1); +} + +#define _mm512_shuffle_epi32(A, I) \ + ((__m512i)__builtin_ia32_pshufd512((__v16si)(__m512i)(A), (int)(I))) + +#define _mm512_mask_shuffle_epi32(W, U, A, I) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shuffle_epi32((A), (I)), \ + (__v16si)(__m512i)(W))) + +#define _mm512_maskz_shuffle_epi32(U, A, I) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shuffle_epi32((A), (I)), \ + (__v16si)_mm512_setzero_si512())) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_expand_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_expanddf512_mask ((__v8df) __A, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_expand_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_expanddf512_mask ((__v8df) __A, + (__v8df) _mm512_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_expand_epi64 (__m512i __W, __mmask8 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_expanddi512_mask ((__v8di) __A, + (__v8di) __W, + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_expand_epi64 ( __mmask8 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_expanddi512_mask ((__v8di) __A, + (__v8di) _mm512_setzero_si512 (), + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_expandloadu_pd(__m512d __W, __mmask8 __U, void const *__P) +{ + return (__m512d) __builtin_ia32_expandloaddf512_mask ((const __v8df *)__P, + (__v8df) __W, + (__mmask8) __U); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_expandloadu_pd(__mmask8 __U, void const *__P) +{ + return (__m512d) __builtin_ia32_expandloaddf512_mask ((const __v8df *)__P, + (__v8df) _mm512_setzero_pd(), + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_expandloadu_epi64(__m512i __W, __mmask8 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloaddi512_mask ((const __v8di *)__P, + (__v8di) __W, + (__mmask8) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_expandloadu_epi64(__mmask8 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloaddi512_mask ((const __v8di *)__P, + (__v8di) _mm512_setzero_si512(), + (__mmask8) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_expandloadu_ps(__m512 __W, __mmask16 __U, void const *__P) +{ + return (__m512) __builtin_ia32_expandloadsf512_mask ((const __v16sf *)__P, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_expandloadu_ps(__mmask16 __U, void const *__P) +{ + return (__m512) __builtin_ia32_expandloadsf512_mask ((const __v16sf *)__P, + (__v16sf) _mm512_setzero_ps(), + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_expandloadu_epi32(__m512i __W, __mmask16 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloadsi512_mask ((const __v16si *)__P, + (__v16si) __W, + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_expandloadu_epi32(__mmask16 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloadsi512_mask ((const __v16si *)__P, + (__v16si) _mm512_setzero_si512(), + (__mmask16) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_expand_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_expandsf512_mask ((__v16sf) __A, + (__v16sf) __W, + (__mmask16) __U); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_expand_ps (__mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_expandsf512_mask ((__v16sf) __A, + (__v16sf) _mm512_setzero_ps(), + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_expand_epi32 (__m512i __W, __mmask16 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_expandsi512_mask ((__v16si) __A, + (__v16si) __W, + (__mmask16) __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_expand_epi32 (__mmask16 __U, __m512i __A) +{ + return (__m512i) __builtin_ia32_expandsi512_mask ((__v16si) __A, + (__v16si) _mm512_setzero_si512(), + (__mmask16) __U); +} + +#define _mm512_cvt_roundps_pd(A, R) \ + ((__m512d)__builtin_ia32_cvtps2pd512_mask((__v8sf)(__m256)(A), \ + (__v8df)_mm512_undefined_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm512_mask_cvt_roundps_pd(W, U, A, R) \ + ((__m512d)__builtin_ia32_cvtps2pd512_mask((__v8sf)(__m256)(A), \ + (__v8df)(__m512d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundps_pd(U, A, R) \ + ((__m512d)__builtin_ia32_cvtps2pd512_mask((__v8sf)(__m256)(A), \ + (__v8df)_mm512_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtps_pd (__m256 __A) +{ + return (__m512d) __builtin_convertvector((__v8sf)__A, __v8df); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtps_pd (__m512d __W, __mmask8 __U, __m256 __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_cvtps_pd(__A), + (__v8df)__W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtps_pd (__mmask8 __U, __m256 __A) +{ + return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, + (__v8df)_mm512_cvtps_pd(__A), + (__v8df)_mm512_setzero_pd()); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_cvtpslo_pd (__m512 __A) +{ + return (__m512d) _mm512_cvtps_pd(_mm512_castps512_ps256(__A)); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpslo_pd (__m512d __W, __mmask8 __U, __m512 __A) +{ + return (__m512d) _mm512_mask_cvtps_pd(__W, __U, _mm512_castps512_ps256(__A)); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_mov_pd (__m512d __W, __mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_selectpd_512 ((__mmask8) __U, + (__v8df) __A, + (__v8df) __W); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_mov_pd (__mmask8 __U, __m512d __A) +{ + return (__m512d) __builtin_ia32_selectpd_512 ((__mmask8) __U, + (__v8df) __A, + (__v8df) _mm512_setzero_pd ()); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_mov_ps (__m512 __W, __mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_selectps_512 ((__mmask16) __U, + (__v16sf) __A, + (__v16sf) __W); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_mov_ps (__mmask16 __U, __m512 __A) +{ + return (__m512) __builtin_ia32_selectps_512 ((__mmask16) __U, + (__v16sf) __A, + (__v16sf) _mm512_setzero_ps ()); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_compressstoreu_pd (void *__P, __mmask8 __U, __m512d __A) +{ + __builtin_ia32_compressstoredf512_mask ((__v8df *) __P, (__v8df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_compressstoreu_epi64 (void *__P, __mmask8 __U, __m512i __A) +{ + __builtin_ia32_compressstoredi512_mask ((__v8di *) __P, (__v8di) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_compressstoreu_ps (void *__P, __mmask16 __U, __m512 __A) +{ + __builtin_ia32_compressstoresf512_mask ((__v16sf *) __P, (__v16sf) __A, + (__mmask16) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 +_mm512_mask_compressstoreu_epi32 (void *__P, __mmask16 __U, __m512i __A) +{ + __builtin_ia32_compressstoresi512_mask ((__v16si *) __P, (__v16si) __A, + (__mmask16) __U); +} + +#define _mm_cvt_roundsd_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtsd2ss_round_mask((__v4sf)(__m128)(A), \ + (__v2df)(__m128d)(B), \ + (__v4sf)_mm_undefined_ps(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_cvt_roundsd_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_cvtsd2ss_round_mask((__v4sf)(__m128)(A), \ + (__v2df)(__m128d)(B), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_cvt_roundsd_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_cvtsd2ss_round_mask((__v4sf)(__m128)(A), \ + (__v2df)(__m128d)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128d __B) +{ + return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)__A, + (__v2df)__B, + (__v4sf)__W, + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsd_ss (__mmask8 __U, __m128 __A, __m128d __B) +{ + return __builtin_ia32_cvtsd2ss_round_mask ((__v4sf)__A, + (__v2df)__B, + (__v4sf)_mm_setzero_ps(), + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvtss_i32 _mm_cvtss_si32 +#define _mm_cvtsd_i32 _mm_cvtsd_si32 +#define _mm_cvti32_sd _mm_cvtsi32_sd +#define _mm_cvti32_ss _mm_cvtsi32_ss +#ifdef __x86_64__ +#define _mm_cvtss_i64 _mm_cvtss_si64 +#define _mm_cvtsd_i64 _mm_cvtsd_si64 +#define _mm_cvti64_sd _mm_cvtsi64_sd +#define _mm_cvti64_ss _mm_cvtsi64_ss +#endif + +#ifdef __x86_64__ +#define _mm_cvt_roundi64_sd(A, B, R) \ + ((__m128d)__builtin_ia32_cvtsi2sd64((__v2df)(__m128d)(A), (long long)(B), \ + (int)(R))) + +#define _mm_cvt_roundsi64_sd(A, B, R) \ + ((__m128d)__builtin_ia32_cvtsi2sd64((__v2df)(__m128d)(A), (long long)(B), \ + (int)(R))) +#endif + +#define _mm_cvt_roundsi32_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtsi2ss32((__v4sf)(__m128)(A), (int)(B), (int)(R))) + +#define _mm_cvt_roundi32_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtsi2ss32((__v4sf)(__m128)(A), (int)(B), (int)(R))) + +#ifdef __x86_64__ +#define _mm_cvt_roundsi64_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtsi2ss64((__v4sf)(__m128)(A), (long long)(B), \ + (int)(R))) + +#define _mm_cvt_roundi64_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtsi2ss64((__v4sf)(__m128)(A), (long long)(B), \ + (int)(R))) +#endif + +#define _mm_cvt_roundss_sd(A, B, R) \ + ((__m128d)__builtin_ia32_cvtss2sd_round_mask((__v2df)(__m128d)(A), \ + (__v4sf)(__m128)(B), \ + (__v2df)_mm_undefined_pd(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_cvt_roundss_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_cvtss2sd_round_mask((__v2df)(__m128d)(A), \ + (__v4sf)(__m128)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_cvt_roundss_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_cvtss2sd_round_mask((__v2df)(__m128d)(A), \ + (__v4sf)(__m128)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_cvtss_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128 __B) +{ + return __builtin_ia32_cvtss2sd_round_mask((__v2df)__A, + (__v4sf)__B, + (__v2df)__W, + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtss_sd (__mmask8 __U, __m128d __A, __m128 __B) +{ + return __builtin_ia32_cvtss2sd_round_mask((__v2df)__A, + (__v4sf)__B, + (__v2df)_mm_setzero_pd(), + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_cvtu32_sd (__m128d __A, unsigned __B) +{ + __A[0] = __B; + return __A; +} + +#ifdef __x86_64__ +#define _mm_cvt_roundu64_sd(A, B, R) \ + ((__m128d)__builtin_ia32_cvtusi2sd64((__v2df)(__m128d)(A), \ + (unsigned long long)(B), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_cvtu64_sd (__m128d __A, unsigned long long __B) +{ + __A[0] = __B; + return __A; +} +#endif + +#define _mm_cvt_roundu32_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtusi2ss32((__v4sf)(__m128)(A), (unsigned int)(B), \ + (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtu32_ss (__m128 __A, unsigned __B) +{ + __A[0] = __B; + return __A; +} + +#ifdef __x86_64__ +#define _mm_cvt_roundu64_ss(A, B, R) \ + ((__m128)__builtin_ia32_cvtusi2ss64((__v4sf)(__m128)(A), \ + (unsigned long long)(B), (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtu64_ss (__m128 __A, unsigned long long __B) +{ + __A[0] = __B; + return __A; +} +#endif + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_set1_epi32 (__m512i __O, __mmask16 __M, int __A) +{ + return (__m512i) __builtin_ia32_selectd_512(__M, + (__v16si) _mm512_set1_epi32(__A), + (__v16si) __O); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_set1_epi64 (__m512i __O, __mmask8 __M, long long __A) +{ + return (__m512i) __builtin_ia32_selectq_512(__M, + (__v8di) _mm512_set1_epi64(__A), + (__v8di) __O); +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set_epi8 (char __e63, char __e62, char __e61, char __e60, char __e59, + char __e58, char __e57, char __e56, char __e55, char __e54, char __e53, + char __e52, char __e51, char __e50, char __e49, char __e48, char __e47, + char __e46, char __e45, char __e44, char __e43, char __e42, char __e41, + char __e40, char __e39, char __e38, char __e37, char __e36, char __e35, + char __e34, char __e33, char __e32, char __e31, char __e30, char __e29, + char __e28, char __e27, char __e26, char __e25, char __e24, char __e23, + char __e22, char __e21, char __e20, char __e19, char __e18, char __e17, + char __e16, char __e15, char __e14, char __e13, char __e12, char __e11, + char __e10, char __e9, char __e8, char __e7, char __e6, char __e5, + char __e4, char __e3, char __e2, char __e1, char __e0) { + + return __extension__ (__m512i)(__v64qi) + {__e0, __e1, __e2, __e3, __e4, __e5, __e6, __e7, + __e8, __e9, __e10, __e11, __e12, __e13, __e14, __e15, + __e16, __e17, __e18, __e19, __e20, __e21, __e22, __e23, + __e24, __e25, __e26, __e27, __e28, __e29, __e30, __e31, + __e32, __e33, __e34, __e35, __e36, __e37, __e38, __e39, + __e40, __e41, __e42, __e43, __e44, __e45, __e46, __e47, + __e48, __e49, __e50, __e51, __e52, __e53, __e54, __e55, + __e56, __e57, __e58, __e59, __e60, __e61, __e62, __e63}; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set_epi16(short __e31, short __e30, short __e29, short __e28, + short __e27, short __e26, short __e25, short __e24, short __e23, + short __e22, short __e21, short __e20, short __e19, short __e18, + short __e17, short __e16, short __e15, short __e14, short __e13, + short __e12, short __e11, short __e10, short __e9, short __e8, + short __e7, short __e6, short __e5, short __e4, short __e3, + short __e2, short __e1, short __e0) { + return __extension__ (__m512i)(__v32hi) + {__e0, __e1, __e2, __e3, __e4, __e5, __e6, __e7, + __e8, __e9, __e10, __e11, __e12, __e13, __e14, __e15, + __e16, __e17, __e18, __e19, __e20, __e21, __e22, __e23, + __e24, __e25, __e26, __e27, __e28, __e29, __e30, __e31 }; +} + +static __inline __m512i __DEFAULT_FN_ATTRS512 +_mm512_set_epi32 (int __A, int __B, int __C, int __D, + int __E, int __F, int __G, int __H, + int __I, int __J, int __K, int __L, + int __M, int __N, int __O, int __P) +{ + return __extension__ (__m512i)(__v16si) + { __P, __O, __N, __M, __L, __K, __J, __I, + __H, __G, __F, __E, __D, __C, __B, __A }; +} + +#define _mm512_setr_epi32(e0,e1,e2,e3,e4,e5,e6,e7, \ + e8,e9,e10,e11,e12,e13,e14,e15) \ + _mm512_set_epi32((e15),(e14),(e13),(e12),(e11),(e10),(e9),(e8),(e7),(e6), \ + (e5),(e4),(e3),(e2),(e1),(e0)) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_set_epi64 (long long __A, long long __B, long long __C, + long long __D, long long __E, long long __F, + long long __G, long long __H) +{ + return __extension__ (__m512i) (__v8di) + { __H, __G, __F, __E, __D, __C, __B, __A }; +} + +#define _mm512_setr_epi64(e0,e1,e2,e3,e4,e5,e6,e7) \ + _mm512_set_epi64((e7),(e6),(e5),(e4),(e3),(e2),(e1),(e0)) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_set_pd (double __A, double __B, double __C, double __D, + double __E, double __F, double __G, double __H) +{ + return __extension__ (__m512d) + { __H, __G, __F, __E, __D, __C, __B, __A }; +} + +#define _mm512_setr_pd(e0,e1,e2,e3,e4,e5,e6,e7) \ + _mm512_set_pd((e7),(e6),(e5),(e4),(e3),(e2),(e1),(e0)) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_set_ps (float __A, float __B, float __C, float __D, + float __E, float __F, float __G, float __H, + float __I, float __J, float __K, float __L, + float __M, float __N, float __O, float __P) +{ + return __extension__ (__m512) + { __P, __O, __N, __M, __L, __K, __J, __I, + __H, __G, __F, __E, __D, __C, __B, __A }; +} + +#define _mm512_setr_ps(e0,e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15) \ + _mm512_set_ps((e15),(e14),(e13),(e12),(e11),(e10),(e9),(e8),(e7),(e6),(e5), \ + (e4),(e3),(e2),(e1),(e0)) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_abs_ps(__m512 __A) +{ + return (__m512)_mm512_and_epi32(_mm512_set1_epi32(0x7FFFFFFF),(__m512i)__A) ; +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_abs_ps(__m512 __W, __mmask16 __K, __m512 __A) +{ + return (__m512)_mm512_mask_and_epi32((__m512i)__W, __K, _mm512_set1_epi32(0x7FFFFFFF),(__m512i)__A) ; +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_abs_pd(__m512d __A) +{ + return (__m512d)_mm512_and_epi64(_mm512_set1_epi64(0x7FFFFFFFFFFFFFFF),(__v8di)__A) ; +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_abs_pd(__m512d __W, __mmask8 __K, __m512d __A) +{ + return (__m512d)_mm512_mask_and_epi64((__v8di)__W, __K, _mm512_set1_epi64(0x7FFFFFFFFFFFFFFF),(__v8di)__A); +} + +/* Vector-reduction arithmetic accepts vectors as inputs and produces scalars as + * outputs. This class of vector operation forms the basis of many scientific + * computations. In vector-reduction arithmetic, the evaluation order is + * independent of the order of the input elements of V. + + * For floating-point intrinsics: + * 1. When using fadd/fmul intrinsics, the order of operations within the + * vector is unspecified (associative math). + * 2. When using fmin/fmax intrinsics, NaN or -0.0 elements within the vector + * produce unspecified results. + + * Used bisection method. At each step, we partition the vector with previous + * step in half, and the operation is performed on its two halves. + * This takes log2(n) steps where n is the number of elements in the vector. + */ + +static __inline__ long long __DEFAULT_FN_ATTRS512 _mm512_reduce_add_epi64(__m512i __W) { + return __builtin_reduce_add((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 _mm512_reduce_mul_epi64(__m512i __W) { + return __builtin_reduce_mul((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 _mm512_reduce_and_epi64(__m512i __W) { + return __builtin_reduce_and((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 _mm512_reduce_or_epi64(__m512i __W) { + return __builtin_reduce_or((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_add_epi64(__mmask8 __M, __m512i __W) { + __W = _mm512_maskz_mov_epi64(__M, __W); + return __builtin_reduce_add((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_mul_epi64(__mmask8 __M, __m512i __W) { + __W = _mm512_mask_mov_epi64(_mm512_set1_epi64(1), __M, __W); + return __builtin_reduce_mul((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_and_epi64(__mmask8 __M, __m512i __W) { + __W = _mm512_mask_mov_epi64(_mm512_set1_epi64(-1LL), __M, __W); + return __builtin_reduce_and((__v8di)__W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_or_epi64(__mmask8 __M, __m512i __W) { + __W = _mm512_maskz_mov_epi64(__M, __W); + return __builtin_reduce_or((__v8di)__W); +} + +// -0.0 is used to ignore the start value since it is the neutral value of +// floating point addition. For more information, please refer to +// https://llvm.org/docs/LangRef.html#llvm-vector-reduce-fadd-intrinsic +static __inline__ double __DEFAULT_FN_ATTRS512 _mm512_reduce_add_pd(__m512d __W) { + return __builtin_ia32_reduce_fadd_pd512(-0.0, __W); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 _mm512_reduce_mul_pd(__m512d __W) { + return __builtin_ia32_reduce_fmul_pd512(1.0, __W); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_add_pd(__mmask8 __M, __m512d __W) { + __W = _mm512_maskz_mov_pd(__M, __W); + return __builtin_ia32_reduce_fadd_pd512(-0.0, __W); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_mul_pd(__mmask8 __M, __m512d __W) { + __W = _mm512_mask_mov_pd(_mm512_set1_pd(1.0), __M, __W); + return __builtin_ia32_reduce_fmul_pd512(1.0, __W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_reduce_add_epi32(__m512i __W) { + return __builtin_reduce_add((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_reduce_mul_epi32(__m512i __W) { + return __builtin_reduce_mul((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_reduce_and_epi32(__m512i __W) { + return __builtin_reduce_and((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_reduce_or_epi32(__m512i __W) { + return __builtin_reduce_or((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_add_epi32( __mmask16 __M, __m512i __W) { + __W = _mm512_maskz_mov_epi32(__M, __W); + return __builtin_reduce_add((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_mul_epi32( __mmask16 __M, __m512i __W) { + __W = _mm512_mask_mov_epi32(_mm512_set1_epi32(1), __M, __W); + return __builtin_reduce_mul((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_and_epi32( __mmask16 __M, __m512i __W) { + __W = _mm512_mask_mov_epi32(_mm512_set1_epi32(-1), __M, __W); + return __builtin_reduce_and((__v16si)__W); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_or_epi32(__mmask16 __M, __m512i __W) { + __W = _mm512_maskz_mov_epi32(__M, __W); + return __builtin_reduce_or((__v16si)__W); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_reduce_add_ps(__m512 __W) { + return __builtin_ia32_reduce_fadd_ps512(-0.0f, __W); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_reduce_mul_ps(__m512 __W) { + return __builtin_ia32_reduce_fmul_ps512(1.0f, __W); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_add_ps(__mmask16 __M, __m512 __W) { + __W = _mm512_maskz_mov_ps(__M, __W); + return __builtin_ia32_reduce_fadd_ps512(-0.0f, __W); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_mul_ps(__mmask16 __M, __m512 __W) { + __W = _mm512_mask_mov_ps(_mm512_set1_ps(1.0f), __M, __W); + return __builtin_ia32_reduce_fmul_ps512(1.0f, __W); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_epi64(__m512i __V) { + return __builtin_reduce_max((__v8di)__V); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_epu64(__m512i __V) { + return __builtin_reduce_max((__v8du)__V); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_epi64(__m512i __V) { + return __builtin_reduce_min((__v8di)__V); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_epu64(__m512i __V) { + return __builtin_reduce_min((__v8du)__V); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_max_epi64(__mmask8 __M, __m512i __V) { + __V = _mm512_mask_mov_epi64(_mm512_set1_epi64(-__LONG_LONG_MAX__ - 1LL), __M, __V); + return __builtin_reduce_max((__v8di)__V); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_max_epu64(__mmask8 __M, __m512i __V) { + __V = _mm512_maskz_mov_epi64(__M, __V); + return __builtin_reduce_max((__v8du)__V); +} + +static __inline__ long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_min_epi64(__mmask8 __M, __m512i __V) { + __V = _mm512_mask_mov_epi64(_mm512_set1_epi64(__LONG_LONG_MAX__), __M, __V); + return __builtin_reduce_min((__v8di)__V); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_min_epu64(__mmask8 __M, __m512i __V) { + __V = _mm512_mask_mov_epi64(_mm512_set1_epi64(-1LL), __M, __V); + return __builtin_reduce_min((__v8du)__V); +} +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_epi32(__m512i __V) { + return __builtin_reduce_max((__v16si)__V); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_epu32(__m512i __V) { + return __builtin_reduce_max((__v16su)__V); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_epi32(__m512i __V) { + return __builtin_reduce_min((__v16si)__V); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_epu32(__m512i __V) { + return __builtin_reduce_min((__v16su)__V); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_max_epi32(__mmask16 __M, __m512i __V) { + __V = _mm512_mask_mov_epi32(_mm512_set1_epi32(-__INT_MAX__ - 1), __M, __V); + return __builtin_reduce_max((__v16si)__V); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_max_epu32(__mmask16 __M, __m512i __V) { + __V = _mm512_maskz_mov_epi32(__M, __V); + return __builtin_reduce_max((__v16su)__V); +} + +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_min_epi32(__mmask16 __M, __m512i __V) { + __V = _mm512_mask_mov_epi32(_mm512_set1_epi32(__INT_MAX__), __M, __V); + return __builtin_reduce_min((__v16si)__V); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_min_epu32(__mmask16 __M, __m512i __V) { + __V = _mm512_mask_mov_epi32(_mm512_set1_epi32(-1), __M, __V); + return __builtin_reduce_min((__v16su)__V); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_pd(__m512d __V) { + return __builtin_ia32_reduce_fmax_pd512(__V); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_pd(__m512d __V) { + return __builtin_ia32_reduce_fmin_pd512(__V); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_max_pd(__mmask8 __M, __m512d __V) { + __V = _mm512_mask_mov_pd(_mm512_set1_pd(-__builtin_inf()), __M, __V); + return __builtin_ia32_reduce_fmax_pd512(__V); +} + +static __inline__ double __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_min_pd(__mmask8 __M, __m512d __V) { + __V = _mm512_mask_mov_pd(_mm512_set1_pd(__builtin_inf()), __M, __V); + return __builtin_ia32_reduce_fmin_pd512(__V); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_ps(__m512 __V) { + return __builtin_ia32_reduce_fmax_ps512(__V); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_ps(__m512 __V) { + return __builtin_ia32_reduce_fmin_ps512(__V); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_max_ps(__mmask16 __M, __m512 __V) { + __V = _mm512_mask_mov_ps(_mm512_set1_ps(-__builtin_inff()), __M, __V); + return __builtin_ia32_reduce_fmax_ps512(__V); +} + +static __inline__ float __DEFAULT_FN_ATTRS512 +_mm512_mask_reduce_min_ps(__mmask16 __M, __m512 __V) { + __V = _mm512_mask_mov_ps(_mm512_set1_ps(__builtin_inff()), __M, __V); + return __builtin_ia32_reduce_fmin_ps512(__V); +} + +/// Moves the least significant 32 bits of a vector of [16 x i32] to a +/// 32-bit signed integer value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVD / MOVD instruction. +/// +/// \param __A +/// A vector of [16 x i32]. The least significant 32 bits are moved to the +/// destination. +/// \returns A 32-bit signed integer containing the moved value. +static __inline__ int __DEFAULT_FN_ATTRS512 +_mm512_cvtsi512_si32(__m512i __A) { + __v16si __b = (__v16si)__A; + return __b[0]; +} + +/// Loads 8 double-precision (64-bit) floating-point elements stored at memory +/// locations starting at location \a base_addr at packed 32-bit integer indices +/// stored in the lower half of \a vindex scaled by \a scale them in dst. +/// +/// This intrinsic corresponds to the VGATHERDPD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// dst[i+63:i] := MEM[addr+63:addr] +/// ENDFOR +/// dst[MAX:512] := 0 +/// \endcode +#define _mm512_i32logather_pd(vindex, base_addr, scale) \ + _mm512_i32gather_pd(_mm512_castsi512_si256(vindex), (base_addr), (scale)) + +/// Loads 8 double-precision (64-bit) floating-point elements from memory +/// starting at location \a base_addr at packed 32-bit integer indices stored in +/// the lower half of \a vindex scaled by \a scale into dst using writemask +/// \a mask (elements are copied from \a src when the corresponding mask bit is +/// not set). +/// +/// This intrinsic corresponds to the VGATHERDPD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// IF mask[j] +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// dst[i+63:i] := MEM[addr+63:addr] +/// ELSE +/// dst[i+63:i] := src[i+63:i] +/// FI +/// ENDFOR +/// dst[MAX:512] := 0 +/// \endcode +#define _mm512_mask_i32logather_pd(src, mask, vindex, base_addr, scale) \ + _mm512_mask_i32gather_pd((src), (mask), _mm512_castsi512_si256(vindex), \ + (base_addr), (scale)) + +/// Loads 8 64-bit integer elements from memory starting at location \a base_addr +/// at packed 32-bit integer indices stored in the lower half of \a vindex +/// scaled by \a scale and stores them in dst. +/// +/// This intrinsic corresponds to the VPGATHERDQ instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// dst[i+63:i] := MEM[addr+63:addr] +/// ENDFOR +/// dst[MAX:512] := 0 +/// \endcode +#define _mm512_i32logather_epi64(vindex, base_addr, scale) \ + _mm512_i32gather_epi64(_mm512_castsi512_si256(vindex), (base_addr), (scale)) + +/// Loads 8 64-bit integer elements from memory starting at location \a base_addr +/// at packed 32-bit integer indices stored in the lower half of \a vindex +/// scaled by \a scale and stores them in dst using writemask \a mask (elements +/// are copied from \a src when the corresponding mask bit is not set). +/// +/// This intrinsic corresponds to the VPGATHERDQ instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// IF mask[j] +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// dst[i+63:i] := MEM[addr+63:addr] +/// ELSE +/// dst[i+63:i] := src[i+63:i] +/// FI +/// ENDFOR +/// dst[MAX:512] := 0 +/// \endcode +#define _mm512_mask_i32logather_epi64(src, mask, vindex, base_addr, scale) \ + _mm512_mask_i32gather_epi64((src), (mask), _mm512_castsi512_si256(vindex), \ + (base_addr), (scale)) + +/// Stores 8 packed double-precision (64-bit) floating-point elements in \a v1 +/// and to memory locations starting at location \a base_addr at packed 32-bit +/// integer indices stored in \a vindex scaled by \a scale. +/// +/// This intrinsic corresponds to the VSCATTERDPD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// MEM[addr+63:addr] := v1[i+63:i] +/// ENDFOR +/// \endcode +#define _mm512_i32loscatter_pd(base_addr, vindex, v1, scale) \ + _mm512_i32scatter_pd((base_addr), _mm512_castsi512_si256(vindex), (v1), (scale)) + +/// Stores 8 packed double-precision (64-bit) floating-point elements in \a v1 +/// to memory locations starting at location \a base_addr at packed 32-bit +/// integer indices stored in \a vindex scaled by \a scale. Only those elements +/// whose corresponding mask bit is set in writemask \a mask are written to +/// memory. +/// +/// This intrinsic corresponds to the VSCATTERDPD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// IF mask[j] +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// MEM[addr+63:addr] := a[i+63:i] +/// FI +/// ENDFOR +/// \endcode +#define _mm512_mask_i32loscatter_pd(base_addr, mask, vindex, v1, scale) \ + _mm512_mask_i32scatter_pd((base_addr), (mask), \ + _mm512_castsi512_si256(vindex), (v1), (scale)) + +/// Stores 8 packed 64-bit integer elements located in \a v1 and stores them in +/// memory locations starting at location \a base_addr at packed 32-bit integer +/// indices stored in \a vindex scaled by \a scale. +/// +/// This intrinsic corresponds to the VPSCATTERDQ instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// MEM[addr+63:addr] := a[i+63:i] +/// ENDFOR +/// \endcode +#define _mm512_i32loscatter_epi64(base_addr, vindex, v1, scale) \ + _mm512_i32scatter_epi64((base_addr), \ + _mm512_castsi512_si256(vindex), (v1), (scale)) + +/// Stores 8 packed 64-bit integer elements located in a and stores them in +/// memory locations starting at location \a base_addr at packed 32-bit integer +/// indices stored in \a vindex scaled by scale using writemask \a mask (elements +/// whose corresponding mask bit is not set are not written to memory). +/// +/// This intrinsic corresponds to the VPSCATTERDQ instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// i := j*64 +/// m := j*32 +/// IF mask[j] +/// addr := base_addr + SignExtend64(vindex[m+31:m]) * ZeroExtend64(scale) * 8 +/// MEM[addr+63:addr] := a[i+63:i] +/// FI +/// ENDFOR +/// \endcode +#define _mm512_mask_i32loscatter_epi64(base_addr, mask, vindex, v1, scale) \ + _mm512_mask_i32scatter_epi64((base_addr), (mask), \ + _mm512_castsi512_si256(vindex), (v1), (scale)) + +#undef __DEFAULT_FN_ATTRS512 +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS512_CONSTEXPR +#undef __DEFAULT_FN_ATTRS128_CONSTEXPR +#undef __DEFAULT_FN_ATTRS_CONSTEXPR + +#endif /* __AVX512FINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512fp16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512fp16intrin.h new file mode 100755 index 0000000..92df320 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512fp16intrin.h @@ -0,0 +1,3353 @@ +/*===----------- avx512fp16intrin.h - AVX512-FP16 intrinsics ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX512FP16INTRIN_H +#define __AVX512FP16INTRIN_H + +/* Define the default attributes for the functions in this file. */ +typedef _Float16 __v32hf __attribute__((__vector_size__(64), __aligned__(64))); +typedef _Float16 __m512h __attribute__((__vector_size__(64), __aligned__(64))); +typedef _Float16 __m512h_u __attribute__((__vector_size__(64), __aligned__(1))); + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512fp16,evex512"), __min_vector_width__(512))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512fp16,no-evex512"), \ + __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512fp16,no-evex512"), \ + __min_vector_width__(128))) + +static __inline__ _Float16 __DEFAULT_FN_ATTRS512 _mm512_cvtsh_h(__m512h __a) { + return __a[0]; +} + +static __inline __m128h __DEFAULT_FN_ATTRS128 _mm_setzero_ph(void) { + return (__m128h){0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; +} + +static __inline __m256h __DEFAULT_FN_ATTRS256 _mm256_setzero_ph(void) { + return (__m256h){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}; +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_undefined_ph(void) { + return (__m256h)__builtin_ia32_undef256(); +} + +static __inline __m512h __DEFAULT_FN_ATTRS512 _mm512_setzero_ph(void) { + return (__m512h){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}; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_undefined_ph(void) { + return (__m128h)__builtin_ia32_undef128(); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_undefined_ph(void) { + return (__m512h)__builtin_ia32_undef512(); +} + +static __inline __m512h __DEFAULT_FN_ATTRS512 _mm512_set1_ph(_Float16 __h) { + return (__m512h)(__v32hf){__h, __h, __h, __h, __h, __h, __h, __h, + __h, __h, __h, __h, __h, __h, __h, __h, + __h, __h, __h, __h, __h, __h, __h, __h, + __h, __h, __h, __h, __h, __h, __h, __h}; +} + +static __inline __m512h __DEFAULT_FN_ATTRS512 +_mm512_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, + _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, + _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12, + _Float16 __h13, _Float16 __h14, _Float16 __h15, _Float16 __h16, + _Float16 __h17, _Float16 __h18, _Float16 __h19, _Float16 __h20, + _Float16 __h21, _Float16 __h22, _Float16 __h23, _Float16 __h24, + _Float16 __h25, _Float16 __h26, _Float16 __h27, _Float16 __h28, + _Float16 __h29, _Float16 __h30, _Float16 __h31, _Float16 __h32) { + return (__m512h)(__v32hf){__h32, __h31, __h30, __h29, __h28, __h27, __h26, + __h25, __h24, __h23, __h22, __h21, __h20, __h19, + __h18, __h17, __h16, __h15, __h14, __h13, __h12, + __h11, __h10, __h9, __h8, __h7, __h6, __h5, + __h4, __h3, __h2, __h1}; +} + +#define _mm512_setr_ph(h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, \ + h14, h15, h16, h17, h18, h19, h20, h21, h22, h23, h24, \ + h25, h26, h27, h28, h29, h30, h31, h32) \ + _mm512_set_ph((h32), (h31), (h30), (h29), (h28), (h27), (h26), (h25), (h24), \ + (h23), (h22), (h21), (h20), (h19), (h18), (h17), (h16), (h15), \ + (h14), (h13), (h12), (h11), (h10), (h9), (h8), (h7), (h6), \ + (h5), (h4), (h3), (h2), (h1)) + +static __inline __m512h __DEFAULT_FN_ATTRS512 +_mm512_set1_pch(_Float16 _Complex __h) { + return (__m512h)_mm512_set1_ps(__builtin_bit_cast(float, __h)); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_castph_ps(__m128h __a) { + return (__m128)__a; +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_castph_ps(__m256h __a) { + return (__m256)__a; +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 _mm512_castph_ps(__m512h __a) { + return (__m512)__a; +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 _mm_castph_pd(__m128h __a) { + return (__m128d)__a; +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 _mm256_castph_pd(__m256h __a) { + return (__m256d)__a; +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 _mm512_castph_pd(__m512h __a) { + return (__m512d)__a; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_castph_si128(__m128h __a) { + return (__m128i)__a; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_castph_si256(__m256h __a) { + return (__m256i)__a; +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_castph_si512(__m512h __a) { + return (__m512i)__a; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_castps_ph(__m128 __a) { + return (__m128h)__a; +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_castps_ph(__m256 __a) { + return (__m256h)__a; +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_castps_ph(__m512 __a) { + return (__m512h)__a; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_castpd_ph(__m128d __a) { + return (__m128h)__a; +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_castpd_ph(__m256d __a) { + return (__m256h)__a; +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_castpd_ph(__m512d __a) { + return (__m512h)__a; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_castsi128_ph(__m128i __a) { + return (__m128h)__a; +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_castsi256_ph(__m256i __a) { + return (__m256h)__a; +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_castsi512_ph(__m512i __a) { + return (__m512h)__a; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_castph256_ph128(__m256h __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_castph512_ph128(__m512h __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_castph512_ph256(__m512h __a) { + return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_castph128_ph256(__m128h __a) { + return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_castph128_ph512(__m128h __a) { + __m256h __b = __builtin_nondeterministic_value(__b); + return __builtin_shufflevector( + __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), + __b, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_castph256_ph512(__m256h __a) { + return __builtin_shufflevector(__a, __builtin_nondeterministic_value(__a), 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31); +} + +/// Constructs a 256-bit floating-point vector of [16 x half] from a +/// 128-bit floating-point vector of [8 x half]. The lower 128 bits +/// contain the value of the source vector. The upper 384 bits are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x half]. +/// \returns A 512-bit floating-point vector of [16 x half]. The lower 128 bits +/// contain the value of the parameter. The upper 384 bits are set to zero. +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_zextph128_ph256(__m128h __a) { + return __builtin_shufflevector(__a, (__v8hf)_mm_setzero_ph(), 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); +} + +/// Constructs a 512-bit floating-point vector of [32 x half] from a +/// 128-bit floating-point vector of [8 x half]. The lower 128 bits +/// contain the value of the source vector. The upper 384 bits are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x half]. +/// \returns A 512-bit floating-point vector of [32 x half]. The lower 128 bits +/// contain the value of the parameter. The upper 384 bits are set to zero. +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_zextph128_ph512(__m128h __a) { + return __builtin_shufflevector( + __a, (__v8hf)_mm_setzero_ph(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15, 8, 9, 10, 11, 12, 13, 14, 15); +} + +/// Constructs a 512-bit floating-point vector of [32 x half] from a +/// 256-bit floating-point vector of [16 x half]. The lower 256 bits +/// contain the value of the source vector. The upper 256 bits are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit vector of [16 x half]. +/// \returns A 512-bit floating-point vector of [32 x half]. The lower 256 bits +/// contain the value of the parameter. The upper 256 bits are set to zero. +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_zextph256_ph512(__m256h __a) { + return __builtin_shufflevector(__a, (__v16hf)_mm256_setzero_ph(), 0, 1, 2, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31); +} + +#define _mm_comi_round_sh(A, B, P, R) \ + __builtin_ia32_vcomish((__v8hf)A, (__v8hf)B, (int)(P), (int)(R)) + +#define _mm_comi_sh(A, B, pred) \ + _mm_comi_round_sh((A), (B), (pred), _MM_FROUND_CUR_DIRECTION) + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comieq_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_EQ_OS, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comilt_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_LT_OS, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comile_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_LE_OS, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comigt_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_GT_OS, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comige_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_GE_OS, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_comineq_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_NEQ_US, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_ucomieq_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_EQ_OQ, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_ucomilt_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_LT_OQ, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_ucomile_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_LE_OQ, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_ucomigt_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_GT_OQ, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_ucomige_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_GE_OQ, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_ucomineq_sh(__m128h __A, + __m128h __B) { + return __builtin_ia32_vcomish((__v8hf)__A, (__v8hf)__B, _CMP_NEQ_UQ, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_add_ph(__m512h __A, + __m512h __B) { + return (__m512h)((__v32hf)__A + (__v32hf)__B); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_add_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)__U, (__v32hf)_mm512_add_ph(__A, __B), (__v32hf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_add_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, + (__v32hf)_mm512_add_ph(__A, __B), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm512_add_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_addph512((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(R))) + +#define _mm512_mask_add_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_add_round_ph((A), (B), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_add_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_add_round_ph((A), (B), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_sub_ph(__m512h __A, + __m512h __B) { + return (__m512h)((__v32hf)__A - (__v32hf)__B); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_sub_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)__U, (__v32hf)_mm512_sub_ph(__A, __B), (__v32hf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_sub_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, + (__v32hf)_mm512_sub_ph(__A, __B), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm512_sub_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_subph512((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(R))) + +#define _mm512_mask_sub_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_sub_round_ph((A), (B), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_sub_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_sub_round_ph((A), (B), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_mul_ph(__m512h __A, + __m512h __B) { + return (__m512h)((__v32hf)__A * (__v32hf)__B); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_mul_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)__U, (__v32hf)_mm512_mul_ph(__A, __B), (__v32hf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_mul_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, + (__v32hf)_mm512_mul_ph(__A, __B), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm512_mul_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_mulph512((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(R))) + +#define _mm512_mask_mul_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_mul_round_ph((A), (B), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_mul_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_mul_round_ph((A), (B), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_div_ph(__m512h __A, + __m512h __B) { + return (__m512h)((__v32hf)__A / (__v32hf)__B); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_div_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)__U, (__v32hf)_mm512_div_ph(__A, __B), (__v32hf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_div_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, + (__v32hf)_mm512_div_ph(__A, __B), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm512_div_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_divph512((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(R))) + +#define _mm512_mask_div_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_div_round_ph((A), (B), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_div_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_div_round_ph((A), (B), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_min_ph(__m512h __A, + __m512h __B) { + return (__m512h)__builtin_ia32_minph512((__v32hf)__A, (__v32hf)__B, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_min_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)__U, (__v32hf)_mm512_min_ph(__A, __B), (__v32hf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_min_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, + (__v32hf)_mm512_min_ph(__A, __B), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm512_min_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_minph512((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(R))) + +#define _mm512_mask_min_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_min_round_ph((A), (B), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_min_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_min_round_ph((A), (B), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_max_ph(__m512h __A, + __m512h __B) { + return (__m512h)__builtin_ia32_maxph512((__v32hf)__A, (__v32hf)__B, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_max_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)__U, (__v32hf)_mm512_max_ph(__A, __B), (__v32hf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_max_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, + (__v32hf)_mm512_max_ph(__A, __B), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm512_max_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_maxph512((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(R))) + +#define _mm512_mask_max_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_max_round_ph((A), (B), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_max_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_max_round_ph((A), (B), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_abs_ph(__m512h __A) { + return (__m512h)_mm512_and_epi32(_mm512_set1_epi32(0x7FFF7FFF), (__m512i)__A); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_conj_pch(__m512h __A) { + return (__m512h)_mm512_xor_epi32((__m512i)__A, + _mm512_set1_epi32(-2147483648)); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_conj_pch(__m512h __W, __mmask16 __U, __m512h __A) { + return (__m512h)__builtin_ia32_selectps_512( + (__mmask16)__U, (__v16sf)_mm512_conj_pch(__A), (__v16sf)__W); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_conj_pch(__mmask16 __U, __m512h __A) { + return (__m512h)__builtin_ia32_selectps_512((__mmask16)__U, + (__v16sf)_mm512_conj_pch(__A), + (__v16sf)_mm512_setzero_ps()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_add_sh(__m128h __A, + __m128h __B) { + __A[0] += __B[0]; + return __A; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_add_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_add_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, __W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_add_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_add_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, _mm_setzero_ph()); +} + +#define _mm_add_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_addsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_add_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_addsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_add_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_addsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_sub_sh(__m128h __A, + __m128h __B) { + __A[0] -= __B[0]; + return __A; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_sub_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_sub_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, __W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_sub_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_sub_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, _mm_setzero_ph()); +} + +#define _mm_sub_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_subsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_sub_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_subsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_sub_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_subsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mul_sh(__m128h __A, + __m128h __B) { + __A[0] *= __B[0]; + return __A; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_mul_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_mul_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, __W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_mul_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_mul_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, _mm_setzero_ph()); +} + +#define _mm_mul_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_mulsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_mul_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_mulsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_mul_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_mulsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_div_sh(__m128h __A, + __m128h __B) { + __A[0] /= __B[0]; + return __A; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_div_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_div_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, __W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_div_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + __A = _mm_div_sh(__A, __B); + return __builtin_ia32_selectsh_128(__U, __A, _mm_setzero_ph()); +} + +#define _mm_div_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_divsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_div_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_divsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_div_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_divsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_min_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_minsh_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_min_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_minsh_round_mask((__v8hf)__A, (__v8hf)__B, + (__v8hf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_min_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_minsh_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_min_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_minsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_min_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_minsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_min_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_minsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_max_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_maxsh_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_max_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_maxsh_round_mask((__v8hf)__A, (__v8hf)__B, + (__v8hf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_max_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_maxsh_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_max_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_maxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_max_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_maxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_max_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_maxsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_cmp_round_ph_mask(A, B, P, R) \ + ((__mmask32)__builtin_ia32_cmpph512_mask((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(P), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask_cmp_round_ph_mask(U, A, B, P, R) \ + ((__mmask32)__builtin_ia32_cmpph512_mask((__v32hf)(__m512h)(A), \ + (__v32hf)(__m512h)(B), (int)(P), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_cmp_ph_mask(A, B, P) \ + _mm512_cmp_round_ph_mask((A), (B), (P), _MM_FROUND_CUR_DIRECTION) + +#define _mm512_mask_cmp_ph_mask(U, A, B, P) \ + _mm512_mask_cmp_round_ph_mask((U), (A), (B), (P), _MM_FROUND_CUR_DIRECTION) + +#define _mm_cmp_round_sh_mask(X, Y, P, R) \ + ((__mmask8)__builtin_ia32_cmpsh_mask((__v8hf)(__m128h)(X), \ + (__v8hf)(__m128h)(Y), (int)(P), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_cmp_round_sh_mask(M, X, Y, P, R) \ + ((__mmask8)__builtin_ia32_cmpsh_mask((__v8hf)(__m128h)(X), \ + (__v8hf)(__m128h)(Y), (int)(P), \ + (__mmask8)(M), (int)(R))) + +#define _mm_cmp_sh_mask(X, Y, P) \ + ((__mmask8)__builtin_ia32_cmpsh_mask( \ + (__v8hf)(__m128h)(X), (__v8hf)(__m128h)(Y), (int)(P), (__mmask8)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_cmp_sh_mask(M, X, Y, P) \ + ((__mmask8)__builtin_ia32_cmpsh_mask( \ + (__v8hf)(__m128h)(X), (__v8hf)(__m128h)(Y), (int)(P), (__mmask8)(M), \ + _MM_FROUND_CUR_DIRECTION)) +// loads with vmovsh: +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_load_sh(void const *__dp) { + struct __mm_load_sh_struct { + _Float16 __u; + } __attribute__((__packed__, __may_alias__)); + _Float16 __u = ((const struct __mm_load_sh_struct *)__dp)->__u; + return (__m128h){__u, 0, 0, 0, 0, 0, 0, 0}; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_load_sh(__m128h __W, __mmask8 __U, const void *__A) { + __m128h src = (__v8hf)__builtin_shufflevector( + (__v8hf)__W, (__v8hf)_mm_setzero_ph(), 0, 8, 8, 8, 8, 8, 8, 8); + + return (__m128h)__builtin_ia32_loadsh128_mask((const __v8hf *)__A, src, __U & 1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_load_sh(__mmask8 __U, const void *__A) { + return (__m128h)__builtin_ia32_loadsh128_mask( + (const __v8hf *)__A, (__v8hf)_mm_setzero_ph(), __U & 1); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_load_ph(void const *__p) { + return *(const __m512h *)__p; +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_load_ph(void const *__p) { + return *(const __m256h *)__p; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_load_ph(void const *__p) { + return *(const __m128h *)__p; +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_loadu_ph(void const *__p) { + struct __loadu_ph { + __m512h_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_ph *)__p)->__v; +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_loadu_ph(void const *__p) { + struct __loadu_ph { + __m256h_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_ph *)__p)->__v; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_loadu_ph(void const *__p) { + struct __loadu_ph { + __m128h_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_ph *)__p)->__v; +} + +// stores with vmovsh: +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_store_sh(void *__dp, + __m128h __a) { + struct __mm_store_sh_struct { + _Float16 __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_store_sh_struct *)__dp)->__u = __a[0]; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_mask_store_sh(void *__W, + __mmask8 __U, + __m128h __A) { + __builtin_ia32_storesh128_mask((__v8hf *)__W, __A, __U & 1); +} + +static __inline__ void __DEFAULT_FN_ATTRS512 _mm512_store_ph(void *__P, + __m512h __A) { + *(__m512h *)__P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 _mm256_store_ph(void *__P, + __m256h __A) { + *(__m256h *)__P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_store_ph(void *__P, + __m128h __A) { + *(__m128h *)__P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS512 _mm512_storeu_ph(void *__P, + __m512h __A) { + struct __storeu_ph { + __m512h_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_ph *)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 _mm256_storeu_ph(void *__P, + __m256h __A) { + struct __storeu_ph { + __m256h_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_ph *)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 _mm_storeu_ph(void *__P, + __m128h __A) { + struct __storeu_ph { + __m128h_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_ph *)__P)->__v = __A; +} + +// moves with vmovsh: +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_move_sh(__m128h __a, + __m128h __b) { + __a[0] = __b[0]; + return __a; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_move_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return __builtin_ia32_selectsh_128(__U, _mm_move_sh(__A, __B), __W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_move_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + return __builtin_ia32_selectsh_128(__U, _mm_move_sh(__A, __B), + _mm_setzero_ph()); +} + +// vmovw: +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtsi16_si128(short __a) { + return (__m128i)(__v8hi){__a, 0, 0, 0, 0, 0, 0, 0}; +} + +static __inline__ short __DEFAULT_FN_ATTRS128 _mm_cvtsi128_si16(__m128i __a) { + __v8hi __b = (__v8hi)__a; + return __b[0]; +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_rcp_ph(__m512h __A) { + return (__m512h)__builtin_ia32_rcpph512_mask( + (__v32hf)__A, (__v32hf)_mm512_undefined_ph(), (__mmask32)-1); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_rcp_ph(__m512h __W, __mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_rcpph512_mask((__v32hf)__A, (__v32hf)__W, + (__mmask32)__U); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_rcp_ph(__mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_rcpph512_mask( + (__v32hf)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_rsqrt_ph(__m512h __A) { + return (__m512h)__builtin_ia32_rsqrtph512_mask( + (__v32hf)__A, (__v32hf)_mm512_undefined_ph(), (__mmask32)-1); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_rsqrt_ph(__m512h __W, __mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_rsqrtph512_mask((__v32hf)__A, (__v32hf)__W, + (__mmask32)__U); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_rsqrt_ph(__mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_rsqrtph512_mask( + (__v32hf)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U); +} + +#define _mm512_getmant_ph(A, B, C) \ + ((__m512h)__builtin_ia32_getmantph512_mask( \ + (__v32hf)(__m512h)(A), (int)(((C) << 2) | (B)), \ + (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_getmant_ph(W, U, A, B, C) \ + ((__m512h)__builtin_ia32_getmantph512_mask( \ + (__v32hf)(__m512h)(A), (int)(((C) << 2) | (B)), (__v32hf)(__m512h)(W), \ + (__mmask32)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_getmant_ph(U, A, B, C) \ + ((__m512h)__builtin_ia32_getmantph512_mask( \ + (__v32hf)(__m512h)(A), (int)(((C) << 2) | (B)), \ + (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_getmant_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_getmantph512_mask( \ + (__v32hf)(__m512h)(A), (int)(((C) << 2) | (B)), \ + (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, (int)(R))) + +#define _mm512_mask_getmant_round_ph(W, U, A, B, C, R) \ + ((__m512h)__builtin_ia32_getmantph512_mask( \ + (__v32hf)(__m512h)(A), (int)(((C) << 2) | (B)), (__v32hf)(__m512h)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_getmant_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_getmantph512_mask( \ + (__v32hf)(__m512h)(A), (int)(((C) << 2) | (B)), \ + (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_getexp_ph(__m512h __A) { + return (__m512h)__builtin_ia32_getexpph512_mask( + (__v32hf)__A, (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_getexp_ph(__m512h __W, __mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_getexpph512_mask( + (__v32hf)__A, (__v32hf)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_getexp_ph(__mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_getexpph512_mask( + (__v32hf)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_getexp_round_ph(A, R) \ + ((__m512h)__builtin_ia32_getexpph512_mask((__v32hf)(__m512h)(A), \ + (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask_getexp_round_ph(W, U, A, R) \ + ((__m512h)__builtin_ia32_getexpph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(W), (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_getexp_round_ph(U, A, R) \ + ((__m512h)__builtin_ia32_getexpph512_mask((__v32hf)(__m512h)(A), \ + (__v32hf)_mm512_setzero_ph(), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_scalef_ph(__m512h __A, + __m512h __B) { + return (__m512h)__builtin_ia32_scalefph512_mask( + (__v32hf)__A, (__v32hf)__B, (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_scalef_ph(__m512h __W, __mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_scalefph512_mask((__v32hf)__A, (__v32hf)__B, + (__v32hf)__W, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_scalef_ph(__mmask32 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_scalefph512_mask( + (__v32hf)__A, (__v32hf)__B, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_scalef_round_ph(A, B, R) \ + ((__m512h)__builtin_ia32_scalefph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), \ + (__v32hf)_mm512_undefined_ph(), (__mmask32)-1, (int)(R))) + +#define _mm512_mask_scalef_round_ph(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_scalefph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_scalef_round_ph(U, A, B, R) \ + ((__m512h)__builtin_ia32_scalefph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), \ + (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), (int)(R))) + +#define _mm512_roundscale_ph(A, B) \ + ((__m512h)__builtin_ia32_rndscaleph_mask( \ + (__v32hf)(__m512h)(A), (int)(B), (__v32hf)(__m512h)(A), (__mmask32)-1, \ + _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_roundscale_ph(A, B, C, imm) \ + ((__m512h)__builtin_ia32_rndscaleph_mask( \ + (__v32hf)(__m512h)(C), (int)(imm), (__v32hf)(__m512h)(A), \ + (__mmask32)(B), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_roundscale_ph(A, B, imm) \ + ((__m512h)__builtin_ia32_rndscaleph_mask( \ + (__v32hf)(__m512h)(B), (int)(imm), (__v32hf)_mm512_setzero_ph(), \ + (__mmask32)(A), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_roundscale_round_ph(A, B, C, imm, R) \ + ((__m512h)__builtin_ia32_rndscaleph_mask((__v32hf)(__m512h)(C), (int)(imm), \ + (__v32hf)(__m512h)(A), \ + (__mmask32)(B), (int)(R))) + +#define _mm512_maskz_roundscale_round_ph(A, B, imm, R) \ + ((__m512h)__builtin_ia32_rndscaleph_mask((__v32hf)(__m512h)(B), (int)(imm), \ + (__v32hf)_mm512_setzero_ph(), \ + (__mmask32)(A), (int)(R))) + +#define _mm512_roundscale_round_ph(A, imm, R) \ + ((__m512h)__builtin_ia32_rndscaleph_mask((__v32hf)(__m512h)(A), (int)(imm), \ + (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_reduce_ph(A, imm) \ + ((__m512h)__builtin_ia32_reduceph512_mask( \ + (__v32hf)(__m512h)(A), (int)(imm), (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)-1, _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_reduce_ph(W, U, A, imm) \ + ((__m512h)__builtin_ia32_reduceph512_mask( \ + (__v32hf)(__m512h)(A), (int)(imm), (__v32hf)(__m512h)(W), \ + (__mmask32)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_maskz_reduce_ph(U, A, imm) \ + ((__m512h)__builtin_ia32_reduceph512_mask( \ + (__v32hf)(__m512h)(A), (int)(imm), (__v32hf)_mm512_setzero_ph(), \ + (__mmask32)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm512_mask_reduce_round_ph(W, U, A, imm, R) \ + ((__m512h)__builtin_ia32_reduceph512_mask((__v32hf)(__m512h)(A), (int)(imm), \ + (__v32hf)(__m512h)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_reduce_round_ph(U, A, imm, R) \ + ((__m512h)__builtin_ia32_reduceph512_mask((__v32hf)(__m512h)(A), (int)(imm), \ + (__v32hf)_mm512_setzero_ph(), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_reduce_round_ph(A, imm, R) \ + ((__m512h)__builtin_ia32_reduceph512_mask((__v32hf)(__m512h)(A), (int)(imm), \ + (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)-1, (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_rcp_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_rcpsh_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_rcp_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_rcpsh_mask((__v8hf)__A, (__v8hf)__B, + (__v8hf)__W, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_rcp_sh(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_rcpsh_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_rsqrt_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_rsqrtsh_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_rsqrt_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_rsqrtsh_mask((__v8hf)__A, (__v8hf)__B, + (__v8hf)__W, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt_sh(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_rsqrtsh_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +#define _mm_getmant_round_sh(A, B, C, D, R) \ + ((__m128h)__builtin_ia32_getmantsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(((D) << 2) | (C)), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)-1, (int)(R))) + +#define _mm_getmant_sh(A, B, C, D) \ + ((__m128h)__builtin_ia32_getmantsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(((D) << 2) | (C)), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)-1, _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_getmant_sh(W, U, A, B, C, D) \ + ((__m128h)__builtin_ia32_getmantsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(((D) << 2) | (C)), \ + (__v8hf)(__m128h)(W), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_getmant_round_sh(W, U, A, B, C, D, R) \ + ((__m128h)__builtin_ia32_getmantsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(((D) << 2) | (C)), \ + (__v8hf)(__m128h)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_getmant_sh(U, A, B, C, D) \ + ((__m128h)__builtin_ia32_getmantsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(((D) << 2) | (C)), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)(U), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_getmant_round_sh(U, A, B, C, D, R) \ + ((__m128h)__builtin_ia32_getmantsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (int)(((D) << 2) | (C)), \ + (__v8hf)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +#define _mm_getexp_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_getexpsh128_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_getexp_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_getexpsh128_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_sh(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_getexpsh128_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_getexp_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_getexpsh128_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_sh(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_getexpsh128_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_getexp_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_getexpsh128_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_scalef_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_scalefsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_scalef_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_scalefsh_round_mask( + (__v8hf)__A, (__v8hf)(__B), (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_sh(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_scalefsh_round_mask((__v8hf)__A, (__v8hf)__B, + (__v8hf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask_scalef_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_scalefsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_sh(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_scalefsh_round_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_scalef_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_scalefsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +#define _mm_roundscale_round_sh(A, B, imm, R) \ + ((__m128h)__builtin_ia32_rndscalesh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(imm), (int)(R))) + +#define _mm_roundscale_sh(A, B, imm) \ + ((__m128h)__builtin_ia32_rndscalesh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(imm), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_roundscale_sh(W, U, A, B, I) \ + ((__m128h)__builtin_ia32_rndscalesh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(I), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_roundscale_round_sh(W, U, A, B, I, R) \ + ((__m128h)__builtin_ia32_rndscalesh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(I), (int)(R))) + +#define _mm_maskz_roundscale_sh(U, A, B, I) \ + ((__m128h)__builtin_ia32_rndscalesh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(I), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_roundscale_round_sh(U, A, B, I, R) \ + ((__m128h)__builtin_ia32_rndscalesh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(I), (int)(R))) + +#define _mm_reduce_sh(A, B, C) \ + ((__m128h)__builtin_ia32_reducesh_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(C), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_mask_reduce_sh(W, U, A, B, C) \ + ((__m128h)__builtin_ia32_reducesh_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(C), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_maskz_reduce_sh(U, A, B, C) \ + ((__m128h)__builtin_ia32_reducesh_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(C), _MM_FROUND_CUR_DIRECTION)) + +#define _mm_reduce_round_sh(A, B, C, R) \ + ((__m128h)__builtin_ia32_reducesh_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(C), (int)(R))) + +#define _mm_mask_reduce_round_sh(W, U, A, B, C, R) \ + ((__m128h)__builtin_ia32_reducesh_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(C), (int)(R))) + +#define _mm_maskz_reduce_round_sh(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_reducesh_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(C), (int)(R))) + +#define _mm512_sqrt_round_ph(A, R) \ + ((__m512h)__builtin_ia32_sqrtph512((__v32hf)(__m512h)(A), (int)(R))) + +#define _mm512_mask_sqrt_round_ph(W, U, A, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_sqrt_round_ph((A), (R)), \ + (__v32hf)(__m512h)(W))) + +#define _mm512_maskz_sqrt_round_ph(U, A, R) \ + ((__m512h)__builtin_ia32_selectph_512( \ + (__mmask32)(U), (__v32hf)_mm512_sqrt_round_ph((A), (R)), \ + (__v32hf)_mm512_setzero_ph())) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_sqrt_ph(__m512h __A) { + return (__m512h)__builtin_ia32_sqrtph512((__v32hf)__A, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_sqrt_ph(__m512h __W, __mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)(__U), + (__v32hf)__builtin_ia32_sqrtph512((__A), (_MM_FROUND_CUR_DIRECTION)), + (__v32hf)(__m512h)(__W)); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_sqrt_ph(__mmask32 __U, __m512h __A) { + return (__m512h)__builtin_ia32_selectph_512( + (__mmask32)(__U), + (__v32hf)__builtin_ia32_sqrtph512((__A), (_MM_FROUND_CUR_DIRECTION)), + (__v32hf)_mm512_setzero_ph()); +} + +#define _mm_sqrt_round_sh(A, B, R) \ + ((__m128h)__builtin_ia32_sqrtsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_sqrt_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_sqrtsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_sqrt_round_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_sqrtsh_round_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_sqrt_sh(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_sqrtsh_round_mask( + (__v8hf)(__m128h)(__A), (__v8hf)(__m128h)(__B), (__v8hf)_mm_setzero_ph(), + (__mmask8)-1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_sqrt_sh(__m128h __W, + __mmask32 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_sqrtsh_round_mask( + (__v8hf)(__m128h)(__A), (__v8hf)(__m128h)(__B), (__v8hf)(__m128h)(__W), + (__mmask8)(__U), _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_sqrt_sh(__mmask32 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_sqrtsh_round_mask( + (__v8hf)(__m128h)(__A), (__v8hf)(__m128h)(__B), (__v8hf)_mm_setzero_ph(), + (__mmask8)(__U), _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fpclass_ph_mask(U, A, imm) \ + ((__mmask32)__builtin_ia32_fpclassph512_mask((__v32hf)(__m512h)(A), \ + (int)(imm), (__mmask32)(U))) + +#define _mm512_fpclass_ph_mask(A, imm) \ + ((__mmask32)__builtin_ia32_fpclassph512_mask((__v32hf)(__m512h)(A), \ + (int)(imm), (__mmask32)-1)) + +#define _mm_fpclass_sh_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclasssh_mask((__v8hf)(__m128h)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_mask_fpclass_sh_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclasssh_mask((__v8hf)(__m128h)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm512_cvt_roundpd_ph(A, R) \ + ((__m128h)__builtin_ia32_vcvtpd2ph512_mask( \ + (__v8df)(A), (__v8hf)_mm_undefined_ph(), (__mmask8)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundpd_ph(W, U, A, R) \ + ((__m128h)__builtin_ia32_vcvtpd2ph512_mask((__v8df)(A), (__v8hf)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundpd_ph(U, A, R) \ + ((__m128h)__builtin_ia32_vcvtpd2ph512_mask( \ + (__v8df)(A), (__v8hf)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 _mm512_cvtpd_ph(__m512d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph512_mask( + (__v8df)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtpd_ph(__m128h __W, __mmask8 __U, __m512d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph512_mask( + (__v8df)__A, (__v8hf)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtpd_ph(__mmask8 __U, __m512d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph512_mask( + (__v8df)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_pd(A, R) \ + ((__m512d)__builtin_ia32_vcvtph2pd512_mask( \ + (__v8hf)(A), (__v8df)_mm512_undefined_pd(), (__mmask8)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundph_pd(W, U, A, R) \ + ((__m512d)__builtin_ia32_vcvtph2pd512_mask((__v8hf)(A), (__v8df)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_pd(U, A, R) \ + ((__m512d)__builtin_ia32_vcvtph2pd512_mask( \ + (__v8hf)(A), (__v8df)_mm512_setzero_pd(), (__mmask8)(U), (int)(R))) + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 _mm512_cvtph_pd(__m128h __A) { + return (__m512d)__builtin_ia32_vcvtph2pd512_mask( + (__v8hf)__A, (__v8df)_mm512_setzero_pd(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_pd(__m512d __W, __mmask8 __U, __m128h __A) { + return (__m512d)__builtin_ia32_vcvtph2pd512_mask( + (__v8hf)__A, (__v8df)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512d __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_pd(__mmask8 __U, __m128h __A) { + return (__m512d)__builtin_ia32_vcvtph2pd512_mask( + (__v8hf)__A, (__v8df)_mm512_setzero_pd(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundsh_ss(A, B, R) \ + ((__m128)__builtin_ia32_vcvtsh2ss_round_mask((__v4sf)(A), (__v8hf)(B), \ + (__v4sf)_mm_undefined_ps(), \ + (__mmask8)(-1), (int)(R))) + +#define _mm_mask_cvt_roundsh_ss(W, U, A, B, R) \ + ((__m128)__builtin_ia32_vcvtsh2ss_round_mask( \ + (__v4sf)(A), (__v8hf)(B), (__v4sf)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_cvt_roundsh_ss(U, A, B, R) \ + ((__m128)__builtin_ia32_vcvtsh2ss_round_mask((__v4sf)(A), (__v8hf)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtsh_ss(__m128 __A, + __m128h __B) { + return (__m128)__builtin_ia32_vcvtsh2ss_round_mask( + (__v4sf)__A, (__v8hf)__B, (__v4sf)_mm_undefined_ps(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_mask_cvtsh_ss(__m128 __W, + __mmask8 __U, + __m128 __A, + __m128h __B) { + return (__m128)__builtin_ia32_vcvtsh2ss_round_mask((__v4sf)__A, (__v8hf)__B, + (__v4sf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_maskz_cvtsh_ss(__mmask8 __U, + __m128 __A, + __m128h __B) { + return (__m128)__builtin_ia32_vcvtsh2ss_round_mask( + (__v4sf)__A, (__v8hf)__B, (__v4sf)_mm_setzero_ps(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundss_sh(A, B, R) \ + ((__m128h)__builtin_ia32_vcvtss2sh_round_mask((__v8hf)(A), (__v4sf)(B), \ + (__v8hf)_mm_undefined_ph(), \ + (__mmask8)(-1), (int)(R))) + +#define _mm_mask_cvt_roundss_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vcvtss2sh_round_mask( \ + (__v8hf)(A), (__v4sf)(B), (__v8hf)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_cvt_roundss_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_vcvtss2sh_round_mask((__v8hf)(A), (__v4sf)(B), \ + (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtss_sh(__m128h __A, + __m128 __B) { + return (__m128h)__builtin_ia32_vcvtss2sh_round_mask( + (__v8hf)__A, (__v4sf)__B, (__v8hf)_mm_undefined_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvtss_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128 __B) { + return (__m128h)__builtin_ia32_vcvtss2sh_round_mask( + (__v8hf)__A, (__v4sf)__B, (__v8hf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_cvtss_sh(__mmask8 __U, + __m128h __A, + __m128 __B) { + return (__m128h)__builtin_ia32_vcvtss2sh_round_mask( + (__v8hf)__A, (__v4sf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundsd_sh(A, B, R) \ + ((__m128h)__builtin_ia32_vcvtsd2sh_round_mask((__v8hf)(A), (__v2df)(B), \ + (__v8hf)_mm_undefined_ph(), \ + (__mmask8)(-1), (int)(R))) + +#define _mm_mask_cvt_roundsd_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vcvtsd2sh_round_mask( \ + (__v8hf)(A), (__v2df)(B), (__v8hf)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_cvt_roundsd_sh(U, A, B, R) \ + ((__m128h)__builtin_ia32_vcvtsd2sh_round_mask((__v8hf)(A), (__v2df)(B), \ + (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtsd_sh(__m128h __A, + __m128d __B) { + return (__m128h)__builtin_ia32_vcvtsd2sh_round_mask( + (__v8hf)__A, (__v2df)__B, (__v8hf)_mm_undefined_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvtsd_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128d __B) { + return (__m128h)__builtin_ia32_vcvtsd2sh_round_mask( + (__v8hf)__A, (__v2df)__B, (__v8hf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsd_sh(__mmask8 __U, __m128h __A, __m128d __B) { + return (__m128h)__builtin_ia32_vcvtsd2sh_round_mask( + (__v8hf)__A, (__v2df)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundsh_sd(A, B, R) \ + ((__m128d)__builtin_ia32_vcvtsh2sd_round_mask((__v2df)(A), (__v8hf)(B), \ + (__v2df)_mm_undefined_pd(), \ + (__mmask8)(-1), (int)(R))) + +#define _mm_mask_cvt_roundsh_sd(W, U, A, B, R) \ + ((__m128d)__builtin_ia32_vcvtsh2sd_round_mask( \ + (__v2df)(A), (__v8hf)(B), (__v2df)(W), (__mmask8)(U), (int)(R))) + +#define _mm_maskz_cvt_roundsh_sd(U, A, B, R) \ + ((__m128d)__builtin_ia32_vcvtsh2sd_round_mask((__v2df)(A), (__v8hf)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 _mm_cvtsh_sd(__m128d __A, + __m128h __B) { + return (__m128d)__builtin_ia32_vcvtsh2sd_round_mask( + (__v2df)__A, (__v8hf)__B, (__v2df)_mm_undefined_pd(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 _mm_mask_cvtsh_sd(__m128d __W, + __mmask8 __U, + __m128d __A, + __m128h __B) { + return (__m128d)__builtin_ia32_vcvtsh2sd_round_mask( + (__v2df)__A, (__v8hf)__B, (__v2df)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsh_sd(__mmask8 __U, __m128d __A, __m128h __B) { + return (__m128d)__builtin_ia32_vcvtsh2sd_round_mask( + (__v2df)__A, (__v8hf)__B, (__v2df)_mm_setzero_pd(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_epi16(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2w512_mask((__v32hf)(A), \ + (__v32hi)_mm512_undefined_epi32(), \ + (__mmask32)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundph_epi16(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2w512_mask((__v32hf)(A), (__v32hi)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_epi16(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2w512_mask((__v32hf)(A), \ + (__v32hi)_mm512_setzero_epi32(), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtph_epi16(__m512h __A) { + return (__m512i)__builtin_ia32_vcvtph2w512_mask( + (__v32hf)__A, (__v32hi)_mm512_setzero_epi32(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_epi16(__m512i __W, __mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvtph2w512_mask( + (__v32hf)__A, (__v32hi)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_epi16(__mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvtph2w512_mask( + (__v32hf)__A, (__v32hi)_mm512_setzero_epi32(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundph_epi16(A, R) \ + ((__m512i)__builtin_ia32_vcvttph2w512_mask( \ + (__v32hf)(A), (__v32hi)_mm512_undefined_epi32(), (__mmask32)(-1), \ + (int)(R))) + +#define _mm512_mask_cvtt_roundph_epi16(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2w512_mask((__v32hf)(A), (__v32hi)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundph_epi16(U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2w512_mask((__v32hf)(A), \ + (__v32hi)_mm512_setzero_epi32(), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttph_epi16(__m512h __A) { + return (__m512i)__builtin_ia32_vcvttph2w512_mask( + (__v32hf)__A, (__v32hi)_mm512_setzero_epi32(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttph_epi16(__m512i __W, __mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvttph2w512_mask( + (__v32hf)__A, (__v32hi)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttph_epi16(__mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvttph2w512_mask( + (__v32hf)__A, (__v32hi)_mm512_setzero_epi32(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepi16_ph(A, R) \ + ((__m512h)__builtin_ia32_vcvtw2ph512_mask((__v32hi)(A), \ + (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundepi16_ph(W, U, A, R) \ + ((__m512h)__builtin_ia32_vcvtw2ph512_mask((__v32hi)(A), (__v32hf)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepi16_ph(U, A, R) \ + ((__m512h)__builtin_ia32_vcvtw2ph512_mask( \ + (__v32hi)(A), (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_cvtepi16_ph(__m512i __A) { + return (__m512h)__builtin_ia32_vcvtw2ph512_mask( + (__v32hi)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi16_ph(__m512h __W, __mmask32 __U, __m512i __A) { + return (__m512h)__builtin_ia32_vcvtw2ph512_mask( + (__v32hi)__A, (__v32hf)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi16_ph(__mmask32 __U, __m512i __A) { + return (__m512h)__builtin_ia32_vcvtw2ph512_mask( + (__v32hi)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_epu16(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2uw512_mask( \ + (__v32hf)(A), (__v32hu)_mm512_undefined_epi32(), (__mmask32)(-1), \ + (int)(R))) + +#define _mm512_mask_cvt_roundph_epu16(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2uw512_mask((__v32hf)(A), (__v32hu)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_epu16(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2uw512_mask((__v32hf)(A), \ + (__v32hu)_mm512_setzero_epi32(), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtph_epu16(__m512h __A) { + return (__m512i)__builtin_ia32_vcvtph2uw512_mask( + (__v32hf)__A, (__v32hu)_mm512_setzero_epi32(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_epu16(__m512i __W, __mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvtph2uw512_mask( + (__v32hf)__A, (__v32hu)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_epu16(__mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvtph2uw512_mask( + (__v32hf)__A, (__v32hu)_mm512_setzero_epi32(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundph_epu16(A, R) \ + ((__m512i)__builtin_ia32_vcvttph2uw512_mask( \ + (__v32hf)(A), (__v32hu)_mm512_undefined_epi32(), (__mmask32)(-1), \ + (int)(R))) + +#define _mm512_mask_cvtt_roundph_epu16(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2uw512_mask((__v32hf)(A), (__v32hu)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundph_epu16(U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2uw512_mask((__v32hf)(A), \ + (__v32hu)_mm512_setzero_epi32(), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttph_epu16(__m512h __A) { + return (__m512i)__builtin_ia32_vcvttph2uw512_mask( + (__v32hf)__A, (__v32hu)_mm512_setzero_epi32(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttph_epu16(__m512i __W, __mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvttph2uw512_mask( + (__v32hf)__A, (__v32hu)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttph_epu16(__mmask32 __U, __m512h __A) { + return (__m512i)__builtin_ia32_vcvttph2uw512_mask( + (__v32hf)__A, (__v32hu)_mm512_setzero_epi32(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepu16_ph(A, R) \ + ((__m512h)__builtin_ia32_vcvtuw2ph512_mask((__v32hu)(A), \ + (__v32hf)_mm512_undefined_ph(), \ + (__mmask32)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundepu16_ph(W, U, A, R) \ + ((__m512h)__builtin_ia32_vcvtuw2ph512_mask((__v32hu)(A), (__v32hf)(W), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepu16_ph(U, A, R) \ + ((__m512h)__builtin_ia32_vcvtuw2ph512_mask( \ + (__v32hu)(A), (__v32hf)_mm512_setzero_ph(), (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_cvtepu16_ph(__m512i __A) { + return (__m512h)__builtin_ia32_vcvtuw2ph512_mask( + (__v32hu)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu16_ph(__m512h __W, __mmask32 __U, __m512i __A) { + return (__m512h)__builtin_ia32_vcvtuw2ph512_mask( + (__v32hu)__A, (__v32hf)__W, (__mmask32)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu16_ph(__mmask32 __U, __m512i __A) { + return (__m512h)__builtin_ia32_vcvtuw2ph512_mask( + (__v32hu)__A, (__v32hf)_mm512_setzero_ph(), (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_epi32(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2dq512_mask( \ + (__v16hf)(A), (__v16si)_mm512_undefined_epi32(), (__mmask16)(-1), \ + (int)(R))) + +#define _mm512_mask_cvt_roundph_epi32(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2dq512_mask((__v16hf)(A), (__v16si)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_epi32(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2dq512_mask((__v16hf)(A), \ + (__v16si)_mm512_setzero_epi32(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtph_epi32(__m256h __A) { + return (__m512i)__builtin_ia32_vcvtph2dq512_mask( + (__v16hf)__A, (__v16si)_mm512_setzero_epi32(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_epi32(__m512i __W, __mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvtph2dq512_mask( + (__v16hf)__A, (__v16si)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_epi32(__mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvtph2dq512_mask( + (__v16hf)__A, (__v16si)_mm512_setzero_epi32(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_epu32(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2udq512_mask( \ + (__v16hf)(A), (__v16su)_mm512_undefined_epi32(), (__mmask16)(-1), \ + (int)(R))) + +#define _mm512_mask_cvt_roundph_epu32(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2udq512_mask((__v16hf)(A), (__v16su)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_epu32(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2udq512_mask((__v16hf)(A), \ + (__v16su)_mm512_setzero_epi32(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtph_epu32(__m256h __A) { + return (__m512i)__builtin_ia32_vcvtph2udq512_mask( + (__v16hf)__A, (__v16su)_mm512_setzero_epi32(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_epu32(__m512i __W, __mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvtph2udq512_mask( + (__v16hf)__A, (__v16su)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_epu32(__mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvtph2udq512_mask( + (__v16hf)__A, (__v16su)_mm512_setzero_epi32(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepi32_ph(A, R) \ + ((__m256h)__builtin_ia32_vcvtdq2ph512_mask((__v16si)(A), \ + (__v16hf)_mm256_undefined_ph(), \ + (__mmask16)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundepi32_ph(W, U, A, R) \ + ((__m256h)__builtin_ia32_vcvtdq2ph512_mask((__v16si)(A), (__v16hf)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepi32_ph(U, A, R) \ + ((__m256h)__builtin_ia32_vcvtdq2ph512_mask( \ + (__v16si)(A), (__v16hf)_mm256_setzero_ph(), (__mmask16)(U), (int)(R))) + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_cvtepi32_ph(__m512i __A) { + return (__m256h)__builtin_ia32_vcvtdq2ph512_mask( + (__v16si)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi32_ph(__m256h __W, __mmask16 __U, __m512i __A) { + return (__m256h)__builtin_ia32_vcvtdq2ph512_mask( + (__v16si)__A, (__v16hf)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi32_ph(__mmask16 __U, __m512i __A) { + return (__m256h)__builtin_ia32_vcvtdq2ph512_mask( + (__v16si)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepu32_ph(A, R) \ + ((__m256h)__builtin_ia32_vcvtudq2ph512_mask((__v16su)(A), \ + (__v16hf)_mm256_undefined_ph(), \ + (__mmask16)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundepu32_ph(W, U, A, R) \ + ((__m256h)__builtin_ia32_vcvtudq2ph512_mask((__v16su)(A), (__v16hf)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepu32_ph(U, A, R) \ + ((__m256h)__builtin_ia32_vcvtudq2ph512_mask( \ + (__v16su)(A), (__v16hf)_mm256_setzero_ph(), (__mmask16)(U), (int)(R))) + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_cvtepu32_ph(__m512i __A) { + return (__m256h)__builtin_ia32_vcvtudq2ph512_mask( + (__v16su)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu32_ph(__m256h __W, __mmask16 __U, __m512i __A) { + return (__m256h)__builtin_ia32_vcvtudq2ph512_mask( + (__v16su)__A, (__v16hf)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu32_ph(__mmask16 __U, __m512i __A) { + return (__m256h)__builtin_ia32_vcvtudq2ph512_mask( + (__v16su)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundph_epi32(A, R) \ + ((__m512i)__builtin_ia32_vcvttph2dq512_mask( \ + (__v16hf)(A), (__v16si)_mm512_undefined_epi32(), (__mmask16)(-1), \ + (int)(R))) + +#define _mm512_mask_cvtt_roundph_epi32(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2dq512_mask((__v16hf)(A), (__v16si)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundph_epi32(U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2dq512_mask((__v16hf)(A), \ + (__v16si)_mm512_setzero_epi32(), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttph_epi32(__m256h __A) { + return (__m512i)__builtin_ia32_vcvttph2dq512_mask( + (__v16hf)__A, (__v16si)_mm512_setzero_epi32(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttph_epi32(__m512i __W, __mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvttph2dq512_mask( + (__v16hf)__A, (__v16si)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttph_epi32(__mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvttph2dq512_mask( + (__v16hf)__A, (__v16si)_mm512_setzero_epi32(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundph_epu32(A, R) \ + ((__m512i)__builtin_ia32_vcvttph2udq512_mask( \ + (__v16hf)(A), (__v16su)_mm512_undefined_epi32(), (__mmask16)(-1), \ + (int)(R))) + +#define _mm512_mask_cvtt_roundph_epu32(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2udq512_mask((__v16hf)(A), (__v16su)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundph_epu32(U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2udq512_mask( \ + (__v16hf)(A), (__v16su)_mm512_setzero_epi32(), (__mmask16)(U), \ + (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttph_epu32(__m256h __A) { + return (__m512i)__builtin_ia32_vcvttph2udq512_mask( + (__v16hf)__A, (__v16su)_mm512_setzero_epi32(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttph_epu32(__m512i __W, __mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvttph2udq512_mask( + (__v16hf)__A, (__v16su)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttph_epu32(__mmask16 __U, __m256h __A) { + return (__m512i)__builtin_ia32_vcvttph2udq512_mask( + (__v16hf)__A, (__v16su)_mm512_setzero_epi32(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepi64_ph(A, R) \ + ((__m128h)__builtin_ia32_vcvtqq2ph512_mask( \ + (__v8di)(A), (__v8hf)_mm_undefined_ph(), (__mmask8)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundepi64_ph(W, U, A, R) \ + ((__m128h)__builtin_ia32_vcvtqq2ph512_mask((__v8di)(A), (__v8hf)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepi64_ph(U, A, R) \ + ((__m128h)__builtin_ia32_vcvtqq2ph512_mask( \ + (__v8di)(A), (__v8hf)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_cvtepi64_ph(__m512i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph512_mask( + (__v8di)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepi64_ph(__m128h __W, __mmask8 __U, __m512i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph512_mask( + (__v8di)__A, (__v8hf)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepi64_ph(__mmask8 __U, __m512i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph512_mask( + (__v8di)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_epi64(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2qq512_mask((__v8hf)(A), \ + (__v8di)_mm512_undefined_epi32(), \ + (__mmask8)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundph_epi64(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2qq512_mask((__v8hf)(A), (__v8di)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_epi64(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2qq512_mask( \ + (__v8hf)(A), (__v8di)_mm512_setzero_epi32(), (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtph_epi64(__m128h __A) { + return (__m512i)__builtin_ia32_vcvtph2qq512_mask( + (__v8hf)__A, (__v8di)_mm512_setzero_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_epi64(__m512i __W, __mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvtph2qq512_mask( + (__v8hf)__A, (__v8di)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_epi64(__mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvtph2qq512_mask( + (__v8hf)__A, (__v8di)_mm512_setzero_epi32(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundepu64_ph(A, R) \ + ((__m128h)__builtin_ia32_vcvtuqq2ph512_mask( \ + (__v8du)(A), (__v8hf)_mm_undefined_ph(), (__mmask8)(-1), (int)(R))) + +#define _mm512_mask_cvt_roundepu64_ph(W, U, A, R) \ + ((__m128h)__builtin_ia32_vcvtuqq2ph512_mask((__v8du)(A), (__v8hf)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundepu64_ph(U, A, R) \ + ((__m128h)__builtin_ia32_vcvtuqq2ph512_mask( \ + (__v8du)(A), (__v8hf)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_cvtepu64_ph(__m512i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph512_mask( + (__v8du)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtepu64_ph(__m128h __W, __mmask8 __U, __m512i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph512_mask( + (__v8du)__A, (__v8hf)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtepu64_ph(__mmask8 __U, __m512i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph512_mask( + (__v8du)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvt_roundph_epu64(A, R) \ + ((__m512i)__builtin_ia32_vcvtph2uqq512_mask( \ + (__v8hf)(A), (__v8du)_mm512_undefined_epi32(), (__mmask8)(-1), \ + (int)(R))) + +#define _mm512_mask_cvt_roundph_epu64(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2uqq512_mask((__v8hf)(A), (__v8du)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvt_roundph_epu64(U, A, R) \ + ((__m512i)__builtin_ia32_vcvtph2uqq512_mask( \ + (__v8hf)(A), (__v8du)_mm512_setzero_epi32(), (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvtph_epu64(__m128h __A) { + return (__m512i)__builtin_ia32_vcvtph2uqq512_mask( + (__v8hf)__A, (__v8du)_mm512_setzero_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtph_epu64(__m512i __W, __mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvtph2uqq512_mask( + (__v8hf)__A, (__v8du)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtph_epu64(__mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvtph2uqq512_mask( + (__v8hf)__A, (__v8du)_mm512_setzero_epi32(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundph_epi64(A, R) \ + ((__m512i)__builtin_ia32_vcvttph2qq512_mask( \ + (__v8hf)(A), (__v8di)_mm512_undefined_epi32(), (__mmask8)(-1), \ + (int)(R))) + +#define _mm512_mask_cvtt_roundph_epi64(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2qq512_mask((__v8hf)(A), (__v8di)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundph_epi64(U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2qq512_mask( \ + (__v8hf)(A), (__v8di)_mm512_setzero_epi32(), (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttph_epi64(__m128h __A) { + return (__m512i)__builtin_ia32_vcvttph2qq512_mask( + (__v8hf)__A, (__v8di)_mm512_setzero_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttph_epi64(__m512i __W, __mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvttph2qq512_mask( + (__v8hf)__A, (__v8di)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttph_epi64(__mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvttph2qq512_mask( + (__v8hf)__A, (__v8di)_mm512_setzero_epi32(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtt_roundph_epu64(A, R) \ + ((__m512i)__builtin_ia32_vcvttph2uqq512_mask( \ + (__v8hf)(A), (__v8du)_mm512_undefined_epi32(), (__mmask8)(-1), \ + (int)(R))) + +#define _mm512_mask_cvtt_roundph_epu64(W, U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2uqq512_mask((__v8hf)(A), (__v8du)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm512_maskz_cvtt_roundph_epu64(U, A, R) \ + ((__m512i)__builtin_ia32_vcvttph2uqq512_mask( \ + (__v8hf)(A), (__v8du)_mm512_setzero_epi32(), (__mmask8)(U), (int)(R))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_cvttph_epu64(__m128h __A) { + return (__m512i)__builtin_ia32_vcvttph2uqq512_mask( + (__v8hf)__A, (__v8du)_mm512_setzero_epi32(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_cvttph_epu64(__m512i __W, __mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvttph2uqq512_mask( + (__v8hf)__A, (__v8du)__W, (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvttph_epu64(__mmask8 __U, __m128h __A) { + return (__m512i)__builtin_ia32_vcvttph2uqq512_mask( + (__v8hf)__A, (__v8du)_mm512_setzero_epi32(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundsh_i32(A, R) \ + ((int)__builtin_ia32_vcvtsh2si32((__v8hf)(A), (int)(R))) + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_cvtsh_i32(__m128h __A) { + return (int)__builtin_ia32_vcvtsh2si32((__v8hf)__A, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundsh_u32(A, R) \ + ((unsigned int)__builtin_ia32_vcvtsh2usi32((__v8hf)(A), (int)(R))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS128 +_mm_cvtsh_u32(__m128h __A) { + return (unsigned int)__builtin_ia32_vcvtsh2usi32((__v8hf)__A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvt_roundsh_i64(A, R) \ + ((long long)__builtin_ia32_vcvtsh2si64((__v8hf)(A), (int)(R))) + +static __inline__ long long __DEFAULT_FN_ATTRS128 _mm_cvtsh_i64(__m128h __A) { + return (long long)__builtin_ia32_vcvtsh2si64((__v8hf)__A, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_cvt_roundsh_u64(A, R) \ + ((unsigned long long)__builtin_ia32_vcvtsh2usi64((__v8hf)(A), (int)(R))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS128 +_mm_cvtsh_u64(__m128h __A) { + return (unsigned long long)__builtin_ia32_vcvtsh2usi64( + (__v8hf)__A, _MM_FROUND_CUR_DIRECTION); +} +#endif // __x86_64__ + +#define _mm_cvt_roundu32_sh(A, B, R) \ + ((__m128h)__builtin_ia32_vcvtusi2sh((__v8hf)(A), (unsigned int)(B), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_cvtu32_sh(__m128h __A, unsigned int __B) { + __A[0] = __B; + return __A; +} + +#ifdef __x86_64__ +#define _mm_cvt_roundu64_sh(A, B, R) \ + ((__m128h)__builtin_ia32_vcvtusi642sh((__v8hf)(A), (unsigned long long)(B), \ + (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_cvtu64_sh(__m128h __A, unsigned long long __B) { + __A[0] = __B; + return __A; +} +#endif + +#define _mm_cvt_roundi32_sh(A, B, R) \ + ((__m128h)__builtin_ia32_vcvtsi2sh((__v8hf)(A), (int)(B), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvti32_sh(__m128h __A, + int __B) { + __A[0] = __B; + return __A; +} + +#ifdef __x86_64__ +#define _mm_cvt_roundi64_sh(A, B, R) \ + ((__m128h)__builtin_ia32_vcvtsi642sh((__v8hf)(A), (long long)(B), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvti64_sh(__m128h __A, + long long __B) { + __A[0] = __B; + return __A; +} +#endif + +#define _mm_cvtt_roundsh_i32(A, R) \ + ((int)__builtin_ia32_vcvttsh2si32((__v8hf)(A), (int)(R))) + +static __inline__ int __DEFAULT_FN_ATTRS128 _mm_cvttsh_i32(__m128h __A) { + return (int)__builtin_ia32_vcvttsh2si32((__v8hf)__A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvtt_roundsh_i64(A, R) \ + ((long long)__builtin_ia32_vcvttsh2si64((__v8hf)(A), (int)(R))) + +static __inline__ long long __DEFAULT_FN_ATTRS128 _mm_cvttsh_i64(__m128h __A) { + return (long long)__builtin_ia32_vcvttsh2si64((__v8hf)__A, + _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm_cvtt_roundsh_u32(A, R) \ + ((unsigned int)__builtin_ia32_vcvttsh2usi32((__v8hf)(A), (int)(R))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS128 +_mm_cvttsh_u32(__m128h __A) { + return (unsigned int)__builtin_ia32_vcvttsh2usi32((__v8hf)__A, + _MM_FROUND_CUR_DIRECTION); +} + +#ifdef __x86_64__ +#define _mm_cvtt_roundsh_u64(A, R) \ + ((unsigned long long)__builtin_ia32_vcvttsh2usi64((__v8hf)(A), (int)(R))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS128 +_mm_cvttsh_u64(__m128h __A) { + return (unsigned long long)__builtin_ia32_vcvttsh2usi64( + (__v8hf)__A, _MM_FROUND_CUR_DIRECTION); +} +#endif + +#define _mm512_cvtx_roundph_ps(A, R) \ + ((__m512)__builtin_ia32_vcvtph2psx512_mask((__v16hf)(A), \ + (__v16sf)_mm512_undefined_ps(), \ + (__mmask16)(-1), (int)(R))) + +#define _mm512_mask_cvtx_roundph_ps(W, U, A, R) \ + ((__m512)__builtin_ia32_vcvtph2psx512_mask((__v16hf)(A), (__v16sf)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvtx_roundph_ps(U, A, R) \ + ((__m512)__builtin_ia32_vcvtph2psx512_mask( \ + (__v16hf)(A), (__v16sf)_mm512_setzero_ps(), (__mmask16)(U), (int)(R))) + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 _mm512_cvtxph_ps(__m256h __A) { + return (__m512)__builtin_ia32_vcvtph2psx512_mask( + (__v16hf)__A, (__v16sf)_mm512_setzero_ps(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtxph_ps(__m512 __W, __mmask16 __U, __m256h __A) { + return (__m512)__builtin_ia32_vcvtph2psx512_mask( + (__v16hf)__A, (__v16sf)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtxph_ps(__mmask16 __U, __m256h __A) { + return (__m512)__builtin_ia32_vcvtph2psx512_mask( + (__v16hf)__A, (__v16sf)_mm512_setzero_ps(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_cvtx_roundps_ph(A, R) \ + ((__m256h)__builtin_ia32_vcvtps2phx512_mask((__v16sf)(A), \ + (__v16hf)_mm256_undefined_ph(), \ + (__mmask16)(-1), (int)(R))) + +#define _mm512_mask_cvtx_roundps_ph(W, U, A, R) \ + ((__m256h)__builtin_ia32_vcvtps2phx512_mask((__v16sf)(A), (__v16hf)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_cvtx_roundps_ph(U, A, R) \ + ((__m256h)__builtin_ia32_vcvtps2phx512_mask( \ + (__v16sf)(A), (__v16hf)_mm256_setzero_ph(), (__mmask16)(U), (int)(R))) + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 _mm512_cvtxps_ph(__m512 __A) { + return (__m256h)__builtin_ia32_vcvtps2phx512_mask( + (__v16sf)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_mask_cvtxps_ph(__m256h __W, __mmask16 __U, __m512 __A) { + return (__m256h)__builtin_ia32_vcvtps2phx512_mask( + (__v16sf)__A, (__v16hf)__W, (__mmask16)__U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS512 +_mm512_maskz_cvtxps_ph(__mmask16 __U, __m512 __A) { + return (__m256h)__builtin_ia32_vcvtps2phx512_mask( + (__v16sf)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmadd_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask_fmadd_round_ph(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_mask3_fmadd_round_ph(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask3( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_fmadd_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_maskz( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_fmsub_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask_fmsub_round_ph(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_fmsub_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_maskz( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_fnmadd_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), -(__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask3_fnmadd_round_ph(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask3( \ + -(__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_fnmadd_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_maskz( \ + -(__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_fnmsub_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), -(__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_maskz_fnmsub_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_maskz( \ + -(__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fmadd_ph(__m512h __A, + __m512h __B, + __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fmadd_ph(__m512h __A, __mmask32 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmadd_ph(__m512h __A, __m512h __B, __m512h __C, __mmask32 __U) { + return (__m512h)__builtin_ia32_vfmaddph512_mask3((__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmadd_ph(__mmask32 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_maskz((__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fmsub_ph(__m512h __A, + __m512h __B, + __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, (__v32hf)__B, + -(__v32hf)__C, (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsub_ph(__m512h __A, __mmask32 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, (__v32hf)__B, + -(__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmsub_ph(__mmask32 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_maskz( + (__v32hf)__A, (__v32hf)__B, -(__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fnmadd_ph(__m512h __A, + __m512h __B, + __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, -(__v32hf)__B, + (__v32hf)__C, (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fnmadd_ph(__m512h __A, __m512h __B, __m512h __C, __mmask32 __U) { + return (__m512h)__builtin_ia32_vfmaddph512_mask3(-(__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fnmadd_ph(__mmask32 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_maskz(-(__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fnmsub_ph(__m512h __A, + __m512h __B, + __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, -(__v32hf)__B, + -(__v32hf)__C, (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fnmsub_ph(__mmask32 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_maskz( + -(__v32hf)__A, (__v32hf)__B, -(__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmaddsub_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask_fmaddsub_round_ph(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_mask3_fmaddsub_round_ph(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_mask3( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_fmaddsub_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_maskz( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_fmsubadd_round_ph(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)-1, (int)(R))) + +#define _mm512_mask_fmsubadd_round_ph(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_mask( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_maskz_fmsubadd_round_ph(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddsubph512_maskz( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_fmaddsub_ph(__m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddsubph512_mask( + (__v32hf)__A, (__v32hf)__B, (__v32hf)__C, (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fmaddsub_ph(__m512h __A, __mmask32 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddsubph512_mask( + (__v32hf)__A, (__v32hf)__B, (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmaddsub_ph(__m512h __A, __m512h __B, __m512h __C, __mmask32 __U) { + return (__m512h)__builtin_ia32_vfmaddsubph512_mask3( + (__v32hf)__A, (__v32hf)__B, (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmaddsub_ph(__mmask32 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddsubph512_maskz( + (__v32hf)__A, (__v32hf)__B, (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_fmsubadd_ph(__m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddsubph512_mask( + (__v32hf)__A, (__v32hf)__B, -(__v32hf)__C, (__mmask32)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fmsubadd_ph(__m512h __A, __mmask32 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddsubph512_mask( + (__v32hf)__A, (__v32hf)__B, -(__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmsubadd_ph(__mmask32 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddsubph512_maskz( + (__v32hf)__A, (__v32hf)__B, -(__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask3_fmsub_round_ph(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmsubph512_mask3( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmsub_ph(__m512h __A, __m512h __B, __m512h __C, __mmask32 __U) { + return (__m512h)__builtin_ia32_vfmsubph512_mask3((__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask3_fmsubadd_round_ph(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmsubaddph512_mask3( \ + (__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmsubadd_ph(__m512h __A, __m512h __B, __m512h __C, __mmask32 __U) { + return (__m512h)__builtin_ia32_vfmsubaddph512_mask3( + (__v32hf)__A, (__v32hf)__B, (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fnmadd_round_ph(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), -(__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fnmadd_ph(__m512h __A, __mmask32 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, -(__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_mask_fnmsub_round_ph(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddph512_mask( \ + (__v32hf)(__m512h)(A), -(__v32hf)(__m512h)(B), -(__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +#define _mm512_mask3_fnmsub_round_ph(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmsubph512_mask3( \ + -(__v32hf)(__m512h)(A), (__v32hf)(__m512h)(B), (__v32hf)(__m512h)(C), \ + (__mmask32)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fnmsub_ph(__m512h __A, __mmask32 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddph512_mask((__v32hf)__A, -(__v32hf)__B, + -(__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fnmsub_ph(__m512h __A, __m512h __B, __m512h __C, __mmask32 __U) { + return (__m512h)__builtin_ia32_vfmsubph512_mask3(-(__v32hf)__A, (__v32hf)__B, + (__v32hf)__C, (__mmask32)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmadd_sh(__m128h __W, + __m128h __A, + __m128h __B) { + return __builtin_ia32_vfmaddsh3_mask((__v8hf)__W, (__v8hf)__A, (__v8hf)__B, + (__mmask8)-1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_fmadd_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return __builtin_ia32_vfmaddsh3_mask((__v8hf)__W, (__v8hf)__A, (__v8hf)__B, + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmadd_round_sh(A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(C), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fmadd_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(W), (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_sh(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return __builtin_ia32_vfmaddsh3_maskz((__v8hf)__A, (__v8hf)__B, (__v8hf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fmadd_round_sh(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_maskz( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), (__v8hf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_sh(__m128h __W, __m128h __X, __m128h __Y, __mmask8 __U) { + return __builtin_ia32_vfmaddsh3_mask3((__v8hf)__W, (__v8hf)__X, (__v8hf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fmadd_round_sh(W, X, Y, U, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask3( \ + (__v8hf)(__m128h)(W), (__v8hf)(__m128h)(X), (__v8hf)(__m128h)(Y), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmsub_sh(__m128h __W, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfmaddsh3_mask((__v8hf)__W, (__v8hf)__A, + -(__v8hf)__B, (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_fmsub_sh(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfmaddsh3_mask((__v8hf)__W, (__v8hf)__A, + -(__v8hf)__B, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmsub_round_sh(A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), -(__v8hf)(__m128h)(C), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fmsub_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(W), (__v8hf)(__m128h)(A), -(__v8hf)(__m128h)(B), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_sh(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddsh3_maskz((__v8hf)__A, (__v8hf)__B, + -(__v8hf)__C, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fmsub_round_sh(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_maskz( \ + (__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), -(__v8hf)(__m128h)(C), \ + (__mmask8)(U), (int)R)) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_sh(__m128h __W, __m128h __X, __m128h __Y, __mmask8 __U) { + return __builtin_ia32_vfmsubsh3_mask3((__v8hf)__W, (__v8hf)__X, (__v8hf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fmsub_round_sh(W, X, Y, U, R) \ + ((__m128h)__builtin_ia32_vfmsubsh3_mask3( \ + (__v8hf)(__m128h)(W), (__v8hf)(__m128h)(X), (__v8hf)(__m128h)(Y), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fnmadd_sh(__m128h __W, + __m128h __A, + __m128h __B) { + return __builtin_ia32_vfmaddsh3_mask((__v8hf)__W, -(__v8hf)__A, (__v8hf)__B, + (__mmask8)-1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_sh(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return __builtin_ia32_vfmaddsh3_mask((__v8hf)__W, -(__v8hf)__A, (__v8hf)__B, + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fnmadd_round_sh(A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(A), -(__v8hf)(__m128h)(B), (__v8hf)(__m128h)(C), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fnmadd_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(W), -(__v8hf)(__m128h)(A), (__v8hf)(__m128h)(B), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_sh(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return __builtin_ia32_vfmaddsh3_maskz((__v8hf)__A, -(__v8hf)__B, (__v8hf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fnmadd_round_sh(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_maskz( \ + (__v8hf)(__m128h)(A), -(__v8hf)(__m128h)(B), (__v8hf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_sh(__m128h __W, __m128h __X, __m128h __Y, __mmask8 __U) { + return __builtin_ia32_vfmaddsh3_mask3((__v8hf)__W, -(__v8hf)__X, (__v8hf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fnmadd_round_sh(W, X, Y, U, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask3( \ + (__v8hf)(__m128h)(W), -(__v8hf)(__m128h)(X), (__v8hf)(__m128h)(Y), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fnmsub_sh(__m128h __W, + __m128h __A, + __m128h __B) { + return __builtin_ia32_vfmaddsh3_mask((__v8hf)__W, -(__v8hf)__A, -(__v8hf)__B, + (__mmask8)-1, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_sh(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return __builtin_ia32_vfmaddsh3_mask((__v8hf)__W, -(__v8hf)__A, -(__v8hf)__B, + (__mmask8)__U, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fnmsub_round_sh(A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(A), -(__v8hf)(__m128h)(B), -(__v8hf)(__m128h)(C), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fnmsub_round_sh(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_mask( \ + (__v8hf)(__m128h)(W), -(__v8hf)(__m128h)(A), -(__v8hf)(__m128h)(B), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_sh(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return __builtin_ia32_vfmaddsh3_maskz((__v8hf)__A, -(__v8hf)__B, -(__v8hf)__C, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_maskz_fnmsub_round_sh(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddsh3_maskz( \ + (__v8hf)(__m128h)(A), -(__v8hf)(__m128h)(B), -(__v8hf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_sh(__m128h __W, __m128h __X, __m128h __Y, __mmask8 __U) { + return __builtin_ia32_vfmsubsh3_mask3((__v8hf)__W, -(__v8hf)__X, (__v8hf)__Y, + (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_mask3_fnmsub_round_sh(W, X, Y, U, R) \ + ((__m128h)__builtin_ia32_vfmsubsh3_mask3( \ + (__v8hf)(__m128h)(W), -(__v8hf)(__m128h)(X), (__v8hf)(__m128h)(Y), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fcmadd_sch(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfcmaddcsh_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fcmadd_sch(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfcmaddcsh_round_mask( + (__v4sf)__A, (__v4sf)(__B), (__v4sf)(__C), __U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fcmadd_sch(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfcmaddcsh_maskz((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fcmadd_sch(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_vfcmaddcsh_round_mask3( + (__v4sf)__A, (__v4sf)__B, (__v4sf)__C, __U, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fcmadd_round_sch(A, B, C, R) \ + ((__m128h)__builtin_ia32_vfcmaddcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fcmadd_round_sch(A, U, B, C, R) \ + ((__m128h)__builtin_ia32_vfcmaddcsh_round_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_fcmadd_round_sch(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vfcmaddcsh_maskz( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +#define _mm_mask3_fcmadd_round_sch(A, B, C, U, R) \ + ((__m128h)__builtin_ia32_vfcmaddcsh_round_mask3( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmadd_sch(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddcsh_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_sch(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddcsh_round_mask( + (__v4sf)__A, (__v4sf)(__B), (__v4sf)(__C), __U, _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_sch(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddcsh_maskz((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_sch(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_vfmaddcsh_round_mask3( + (__v4sf)__A, (__v4sf)__B, (__v4sf)__C, __U, _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmadd_round_sch(A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)-1, (int)(R))) + +#define _mm_mask_fmadd_round_sch(A, U, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddcsh_round_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_fmadd_round_sch(U, A, B, C, R) \ + ((__m128h)__builtin_ia32_vfmaddcsh_maskz( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +#define _mm_mask3_fmadd_round_sch(A, B, C, U, R) \ + ((__m128h)__builtin_ia32_vfmaddcsh_round_mask3( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(C), \ + (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fcmul_sch(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfcmulcsh_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_undefined_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fcmul_sch(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_vfcmulcsh_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fcmul_sch(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_vfcmulcsh_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fcmul_round_sch(A, B, R) \ + ((__m128h)__builtin_ia32_vfcmulcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), \ + (__v4sf)(__m128h)_mm_undefined_ph(), (__mmask8)-1, (int)(R))) + +#define _mm_mask_fcmul_round_sch(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vfcmulcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_fcmul_round_sch(U, A, B, R) \ + ((__m128h)__builtin_ia32_vfcmulcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), \ + (__v4sf)(__m128h)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmul_sch(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfmulcsh_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_undefined_ph(), (__mmask8)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_fmul_sch(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfmulcsh_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__W, (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmul_sch(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_vfmulcsh_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_setzero_ph(), (__mmask8)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm_fmul_round_sch(A, B, R) \ + ((__m128h)__builtin_ia32_vfmulcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), \ + (__v4sf)(__m128h)_mm_undefined_ph(), (__mmask8)-1, (int)(R))) + +#define _mm_mask_fmul_round_sch(W, U, A, B, R) \ + ((__m128h)__builtin_ia32_vfmulcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), (__v4sf)(__m128h)(W), \ + (__mmask8)(U), (int)(R))) + +#define _mm_maskz_fmul_round_sch(U, A, B, R) \ + ((__m128h)__builtin_ia32_vfmulcsh_mask( \ + (__v4sf)(__m128h)(A), (__v4sf)(__m128h)(B), \ + (__v4sf)(__m128h)_mm_setzero_ph(), (__mmask8)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fcmul_pch(__m512h __A, + __m512h __B) { + return (__m512h)__builtin_ia32_vfcmulcph512_mask( + (__v16sf)__A, (__v16sf)__B, (__v16sf)_mm512_undefined_ph(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fcmul_pch(__m512h __W, __mmask16 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_vfcmulcph512_mask((__v16sf)__A, (__v16sf)__B, + (__v16sf)__W, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fcmul_pch(__mmask16 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_vfcmulcph512_mask( + (__v16sf)__A, (__v16sf)__B, (__v16sf)_mm512_setzero_ph(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fcmul_round_pch(A, B, R) \ + ((__m512h)__builtin_ia32_vfcmulcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), \ + (__v16sf)(__m512h)_mm512_undefined_ph(), (__mmask16)-1, (int)(R))) + +#define _mm512_mask_fcmul_round_pch(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_vfcmulcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_fcmul_round_pch(U, A, B, R) \ + ((__m512h)__builtin_ia32_vfcmulcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), \ + (__v16sf)(__m512h)_mm512_setzero_ph(), (__mmask16)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fmul_pch(__m512h __A, + __m512h __B) { + return (__m512h)__builtin_ia32_vfmulcph512_mask( + (__v16sf)__A, (__v16sf)__B, (__v16sf)_mm512_undefined_ph(), (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fmul_pch(__m512h __W, __mmask16 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_vfmulcph512_mask((__v16sf)__A, (__v16sf)__B, + (__v16sf)__W, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmul_pch(__mmask16 __U, __m512h __A, __m512h __B) { + return (__m512h)__builtin_ia32_vfmulcph512_mask( + (__v16sf)__A, (__v16sf)__B, (__v16sf)_mm512_setzero_ph(), (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmul_round_pch(A, B, R) \ + ((__m512h)__builtin_ia32_vfmulcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), \ + (__v16sf)(__m512h)_mm512_undefined_ph(), (__mmask16)-1, (int)(R))) + +#define _mm512_mask_fmul_round_pch(W, U, A, B, R) \ + ((__m512h)__builtin_ia32_vfmulcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(W), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_fmul_round_pch(U, A, B, R) \ + ((__m512h)__builtin_ia32_vfmulcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), \ + (__v16sf)(__m512h)_mm512_setzero_ph(), (__mmask16)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fcmadd_pch(__m512h __A, + __m512h __B, + __m512h __C) { + return (__m512h)__builtin_ia32_vfcmaddcph512_mask3( + (__v16sf)__A, (__v16sf)__B, (__v16sf)__C, (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fcmadd_pch(__m512h __A, __mmask16 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfcmaddcph512_mask( + (__v16sf)__A, (__v16sf)__B, (__v16sf)__C, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fcmadd_pch(__m512h __A, __m512h __B, __m512h __C, __mmask16 __U) { + return (__m512h)__builtin_ia32_vfcmaddcph512_mask3( + (__v16sf)__A, (__v16sf)__B, (__v16sf)__C, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fcmadd_pch(__mmask16 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfcmaddcph512_maskz( + (__v16sf)__A, (__v16sf)__B, (__v16sf)__C, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fcmadd_round_pch(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfcmaddcph512_mask3( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_fcmadd_round_pch(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfcmaddcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_mask3_fcmadd_round_pch(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfcmaddcph512_mask3( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_fcmadd_round_pch(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfcmaddcph512_maskz( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)(U), (int)(R))) + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 _mm512_fmadd_pch(__m512h __A, + __m512h __B, + __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddcph512_mask3((__v16sf)__A, (__v16sf)__B, + (__v16sf)__C, (__mmask16)-1, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_fmadd_pch(__m512h __A, __mmask16 __U, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddcph512_mask((__v16sf)__A, (__v16sf)__B, + (__v16sf)__C, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask3_fmadd_pch(__m512h __A, __m512h __B, __m512h __C, __mmask16 __U) { + return (__m512h)__builtin_ia32_vfmaddcph512_mask3( + (__v16sf)__A, (__v16sf)__B, (__v16sf)__C, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_maskz_fmadd_pch(__mmask16 __U, __m512h __A, __m512h __B, __m512h __C) { + return (__m512h)__builtin_ia32_vfmaddcph512_maskz( + (__v16sf)__A, (__v16sf)__B, (__v16sf)__C, (__mmask16)__U, + _MM_FROUND_CUR_DIRECTION); +} + +#define _mm512_fmadd_round_pch(A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddcph512_mask3( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)-1, (int)(R))) + +#define _mm512_mask_fmadd_round_pch(A, U, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddcph512_mask( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_mask3_fmadd_round_pch(A, B, C, U, R) \ + ((__m512h)__builtin_ia32_vfmaddcph512_mask3( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)(U), (int)(R))) + +#define _mm512_maskz_fmadd_round_pch(U, A, B, C, R) \ + ((__m512h)__builtin_ia32_vfmaddcph512_maskz( \ + (__v16sf)(__m512h)(A), (__v16sf)(__m512h)(B), (__v16sf)(__m512h)(C), \ + (__mmask16)(U), (int)(R))) + +static __inline__ _Float16 __DEFAULT_FN_ATTRS512 +_mm512_reduce_add_ph(__m512h __W) { + return __builtin_ia32_reduce_fadd_ph512(-0.0f16, __W); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS512 +_mm512_reduce_mul_ph(__m512h __W) { + return __builtin_ia32_reduce_fmul_ph512(1.0f16, __W); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS512 +_mm512_reduce_max_ph(__m512h __V) { + return __builtin_ia32_reduce_fmax_ph512(__V); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS512 +_mm512_reduce_min_ph(__m512h __V) { + return __builtin_ia32_reduce_fmin_ph512(__V); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_mask_blend_ph(__mmask32 __U, __m512h __A, __m512h __W) { + return (__m512h)__builtin_ia32_selectph_512((__mmask32)__U, (__v32hf)__W, + (__v32hf)__A); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_permutex2var_ph(__m512h __A, __m512i __I, __m512h __B) { + return (__m512h)__builtin_ia32_vpermi2varhi512((__v32hi)__A, (__v32hi)__I, + (__v32hi)__B); +} + +static __inline__ __m512h __DEFAULT_FN_ATTRS512 +_mm512_permutexvar_ph(__m512i __A, __m512h __B) { + return (__m512h)__builtin_ia32_permvarhi512((__v32hi)__B, (__v32hi)__A); +} + +// intrinsics below are alias for f*mul_*ch +#define _mm512_mul_pch(A, B) _mm512_fmul_pch(A, B) +#define _mm512_mask_mul_pch(W, U, A, B) _mm512_mask_fmul_pch(W, U, A, B) +#define _mm512_maskz_mul_pch(U, A, B) _mm512_maskz_fmul_pch(U, A, B) +#define _mm512_mul_round_pch(A, B, R) _mm512_fmul_round_pch(A, B, R) +#define _mm512_mask_mul_round_pch(W, U, A, B, R) \ + _mm512_mask_fmul_round_pch(W, U, A, B, R) +#define _mm512_maskz_mul_round_pch(U, A, B, R) \ + _mm512_maskz_fmul_round_pch(U, A, B, R) + +#define _mm512_cmul_pch(A, B) _mm512_fcmul_pch(A, B) +#define _mm512_mask_cmul_pch(W, U, A, B) _mm512_mask_fcmul_pch(W, U, A, B) +#define _mm512_maskz_cmul_pch(U, A, B) _mm512_maskz_fcmul_pch(U, A, B) +#define _mm512_cmul_round_pch(A, B, R) _mm512_fcmul_round_pch(A, B, R) +#define _mm512_mask_cmul_round_pch(W, U, A, B, R) \ + _mm512_mask_fcmul_round_pch(W, U, A, B, R) +#define _mm512_maskz_cmul_round_pch(U, A, B, R) \ + _mm512_maskz_fcmul_round_pch(U, A, B, R) + +#define _mm_mul_sch(A, B) _mm_fmul_sch(A, B) +#define _mm_mask_mul_sch(W, U, A, B) _mm_mask_fmul_sch(W, U, A, B) +#define _mm_maskz_mul_sch(U, A, B) _mm_maskz_fmul_sch(U, A, B) +#define _mm_mul_round_sch(A, B, R) _mm_fmul_round_sch(A, B, R) +#define _mm_mask_mul_round_sch(W, U, A, B, R) \ + _mm_mask_fmul_round_sch(W, U, A, B, R) +#define _mm_maskz_mul_round_sch(U, A, B, R) _mm_maskz_fmul_round_sch(U, A, B, R) + +#define _mm_cmul_sch(A, B) _mm_fcmul_sch(A, B) +#define _mm_mask_cmul_sch(W, U, A, B) _mm_mask_fcmul_sch(W, U, A, B) +#define _mm_maskz_cmul_sch(U, A, B) _mm_maskz_fcmul_sch(U, A, B) +#define _mm_cmul_round_sch(A, B, R) _mm_fcmul_round_sch(A, B, R) +#define _mm_mask_cmul_round_sch(W, U, A, B, R) \ + _mm_mask_fcmul_round_sch(W, U, A, B, R) +#define _mm_maskz_cmul_round_sch(U, A, B, R) \ + _mm_maskz_fcmul_round_sch(U, A, B, R) + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 +#undef __DEFAULT_FN_ATTRS512 + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512ifmaintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512ifmaintrin.h new file mode 100755 index 0000000..9468d17 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512ifmaintrin.h @@ -0,0 +1,70 @@ +/*===------------- avx512ifmaintrin.h - IFMA intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __IFMAINTRIN_H +#define __IFMAINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512ifma,evex512"), __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_madd52hi_epu64 (__m512i __X, __m512i __Y, __m512i __Z) +{ + return (__m512i)__builtin_ia32_vpmadd52huq512((__v8di) __X, (__v8di) __Y, + (__v8di) __Z); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_madd52hi_epu64 (__m512i __W, __mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di)_mm512_madd52hi_epu64(__W, __X, __Y), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_madd52hi_epu64 (__mmask8 __M, __m512i __X, __m512i __Y, __m512i __Z) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di)_mm512_madd52hi_epu64(__X, __Y, __Z), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_madd52lo_epu64 (__m512i __X, __m512i __Y, __m512i __Z) +{ + return (__m512i)__builtin_ia32_vpmadd52luq512((__v8di) __X, (__v8di) __Y, + (__v8di) __Z); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_madd52lo_epu64 (__m512i __W, __mmask8 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di)_mm512_madd52lo_epu64(__W, __X, __Y), + (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_madd52lo_epu64 (__mmask8 __M, __m512i __X, __m512i __Y, __m512i __Z) +{ + return (__m512i)__builtin_ia32_selectq_512(__M, + (__v8di)_mm512_madd52lo_epu64(__X, __Y, __Z), + (__v8di)_mm512_setzero_si512()); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512ifmavlintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512ifmavlintrin.h new file mode 100755 index 0000000..8787cd4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512ifmavlintrin.h @@ -0,0 +1,111 @@ +/*===------------- avx512ifmavlintrin.h - IFMA intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __IFMAVLINTRIN_H +#define __IFMAVLINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512ifma,avx512vl,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512ifma,avx512vl,no-evex512"), \ + __min_vector_width__(256))) + +#define _mm_madd52hi_epu64(X, Y, Z) \ + ((__m128i)__builtin_ia32_vpmadd52huq128((__v2di)(X), (__v2di)(Y), \ + (__v2di)(Z))) + +#define _mm256_madd52hi_epu64(X, Y, Z) \ + ((__m256i)__builtin_ia32_vpmadd52huq256((__v4di)(X), (__v4di)(Y), \ + (__v4di)(Z))) + +#define _mm_madd52lo_epu64(X, Y, Z) \ + ((__m128i)__builtin_ia32_vpmadd52luq128((__v2di)(X), (__v2di)(Y), \ + (__v2di)(Z))) + +#define _mm256_madd52lo_epu64(X, Y, Z) \ + ((__m256i)__builtin_ia32_vpmadd52luq256((__v4di)(X), (__v4di)(Y), \ + (__v4di)(Z))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_madd52hi_epu64 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128(__M, + (__v2di)_mm_madd52hi_epu64(__W, __X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_madd52hi_epu64 (__mmask8 __M, __m128i __X, __m128i __Y, __m128i __Z) +{ + return (__m128i)__builtin_ia32_selectq_128(__M, + (__v2di)_mm_madd52hi_epu64(__X, __Y, __Z), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_madd52hi_epu64 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256(__M, + (__v4di)_mm256_madd52hi_epu64(__W, __X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_madd52hi_epu64 (__mmask8 __M, __m256i __X, __m256i __Y, __m256i __Z) +{ + return (__m256i)__builtin_ia32_selectq_256(__M, + (__v4di)_mm256_madd52hi_epu64(__X, __Y, __Z), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_madd52lo_epu64 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128(__M, + (__v2di)_mm_madd52lo_epu64(__W, __X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_madd52lo_epu64 (__mmask8 __M, __m128i __X, __m128i __Y, __m128i __Z) +{ + return (__m128i)__builtin_ia32_selectq_128(__M, + (__v2di)_mm_madd52lo_epu64(__X, __Y, __Z), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_madd52lo_epu64 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256(__M, + (__v4di)_mm256_madd52lo_epu64(__W, __X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_madd52lo_epu64 (__mmask8 __M, __m256i __X, __m256i __Y, __m256i __Z) +{ + return (__m256i)__builtin_ia32_selectq_256(__M, + (__v4di)_mm256_madd52lo_epu64(__X, __Y, __Z), + (__v4di)_mm256_setzero_si256()); +} + + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmi2intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmi2intrin.h new file mode 100755 index 0000000..11598c8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmi2intrin.h @@ -0,0 +1,357 @@ +/*===------------- avx512vbmi2intrin.h - VBMI2 intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VBMI2INTRIN_H +#define __AVX512VBMI2INTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512vbmi2,evex512"), __min_vector_width__(512))) + + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_compress_epi16(__m512i __S, __mmask32 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_compresshi512_mask ((__v32hi) __D, + (__v32hi) __S, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_compress_epi16(__mmask32 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_compresshi512_mask ((__v32hi) __D, + (__v32hi) _mm512_setzero_si512(), + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_compress_epi8(__m512i __S, __mmask64 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_compressqi512_mask ((__v64qi) __D, + (__v64qi) __S, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_compress_epi8(__mmask64 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_compressqi512_mask ((__v64qi) __D, + (__v64qi) _mm512_setzero_si512(), + __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_mm512_mask_compressstoreu_epi16(void *__P, __mmask32 __U, __m512i __D) +{ + __builtin_ia32_compressstorehi512_mask ((__v32hi *) __P, (__v32hi) __D, + __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_mm512_mask_compressstoreu_epi8(void *__P, __mmask64 __U, __m512i __D) +{ + __builtin_ia32_compressstoreqi512_mask ((__v64qi *) __P, (__v64qi) __D, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_expand_epi16(__m512i __S, __mmask32 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_expandhi512_mask ((__v32hi) __D, + (__v32hi) __S, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_expand_epi16(__mmask32 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_expandhi512_mask ((__v32hi) __D, + (__v32hi) _mm512_setzero_si512(), + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_expand_epi8(__m512i __S, __mmask64 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_expandqi512_mask ((__v64qi) __D, + (__v64qi) __S, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_expand_epi8(__mmask64 __U, __m512i __D) +{ + return (__m512i) __builtin_ia32_expandqi512_mask ((__v64qi) __D, + (__v64qi) _mm512_setzero_si512(), + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_expandloadu_epi16(__m512i __S, __mmask32 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloadhi512_mask ((const __v32hi *)__P, + (__v32hi) __S, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_expandloadu_epi16(__mmask32 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloadhi512_mask ((const __v32hi *)__P, + (__v32hi) _mm512_setzero_si512(), + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_expandloadu_epi8(__m512i __S, __mmask64 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloadqi512_mask ((const __v64qi *)__P, + (__v64qi) __S, + __U); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_expandloadu_epi8(__mmask64 __U, void const *__P) +{ + return (__m512i) __builtin_ia32_expandloadqi512_mask ((const __v64qi *)__P, + (__v64qi) _mm512_setzero_si512(), + __U); +} + +#define _mm512_shldi_epi64(A, B, I) \ + ((__m512i)__builtin_ia32_vpshldq512((__v8di)(__m512i)(A), \ + (__v8di)(__m512i)(B), (int)(I))) + +#define _mm512_mask_shldi_epi64(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_shldi_epi64((A), (B), (I)), \ + (__v8di)(__m512i)(S))) + +#define _mm512_maskz_shldi_epi64(U, A, B, I) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_shldi_epi64((A), (B), (I)), \ + (__v8di)_mm512_setzero_si512())) + +#define _mm512_shldi_epi32(A, B, I) \ + ((__m512i)__builtin_ia32_vpshldd512((__v16si)(__m512i)(A), \ + (__v16si)(__m512i)(B), (int)(I))) + +#define _mm512_mask_shldi_epi32(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shldi_epi32((A), (B), (I)), \ + (__v16si)(__m512i)(S))) + +#define _mm512_maskz_shldi_epi32(U, A, B, I) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shldi_epi32((A), (B), (I)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_shldi_epi16(A, B, I) \ + ((__m512i)__builtin_ia32_vpshldw512((__v32hi)(__m512i)(A), \ + (__v32hi)(__m512i)(B), (int)(I))) + +#define _mm512_mask_shldi_epi16(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shldi_epi16((A), (B), (I)), \ + (__v32hi)(__m512i)(S))) + +#define _mm512_maskz_shldi_epi16(U, A, B, I) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shldi_epi16((A), (B), (I)), \ + (__v32hi)_mm512_setzero_si512())) + +#define _mm512_shrdi_epi64(A, B, I) \ + ((__m512i)__builtin_ia32_vpshrdq512((__v8di)(__m512i)(A), \ + (__v8di)(__m512i)(B), (int)(I))) + +#define _mm512_mask_shrdi_epi64(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_shrdi_epi64((A), (B), (I)), \ + (__v8di)(__m512i)(S))) + +#define _mm512_maskz_shrdi_epi64(U, A, B, I) \ + ((__m512i)__builtin_ia32_selectq_512((__mmask8)(U), \ + (__v8di)_mm512_shrdi_epi64((A), (B), (I)), \ + (__v8di)_mm512_setzero_si512())) + +#define _mm512_shrdi_epi32(A, B, I) \ + ((__m512i)__builtin_ia32_vpshrdd512((__v16si)(__m512i)(A), \ + (__v16si)(__m512i)(B), (int)(I))) + +#define _mm512_mask_shrdi_epi32(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shrdi_epi32((A), (B), (I)), \ + (__v16si)(__m512i)(S))) + +#define _mm512_maskz_shrdi_epi32(U, A, B, I) \ + ((__m512i)__builtin_ia32_selectd_512((__mmask16)(U), \ + (__v16si)_mm512_shrdi_epi32((A), (B), (I)), \ + (__v16si)_mm512_setzero_si512())) + +#define _mm512_shrdi_epi16(A, B, I) \ + ((__m512i)__builtin_ia32_vpshrdw512((__v32hi)(__m512i)(A), \ + (__v32hi)(__m512i)(B), (int)(I))) + +#define _mm512_mask_shrdi_epi16(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shrdi_epi16((A), (B), (I)), \ + (__v32hi)(__m512i)(S))) + +#define _mm512_maskz_shrdi_epi16(U, A, B, I) \ + ((__m512i)__builtin_ia32_selectw_512((__mmask32)(U), \ + (__v32hi)_mm512_shrdi_epi16((A), (B), (I)), \ + (__v32hi)_mm512_setzero_si512())) + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_shldv_epi64(__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_vpshldvq512((__v8di)__A, (__v8di)__B, + (__v8di)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_shldv_epi64(__m512i __A, __mmask8 __U, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_shldv_epi64(__A, __B, __C), + (__v8di)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_shldv_epi64(__mmask8 __U, __m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_shldv_epi64(__A, __B, __C), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_shldv_epi32(__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_vpshldvd512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_shldv_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_shldv_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_shldv_epi32(__mmask16 __U, __m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_shldv_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_shldv_epi16(__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_vpshldvw512((__v32hi)__A, (__v32hi)__B, + (__v32hi)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_shldv_epi16(__m512i __A, __mmask32 __U, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_shldv_epi16(__A, __B, __C), + (__v32hi)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_shldv_epi16(__mmask32 __U, __m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_shldv_epi16(__A, __B, __C), + (__v32hi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_shrdv_epi64(__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_vpshrdvq512((__v8di)__A, (__v8di)__B, + (__v8di)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_shrdv_epi64(__m512i __A, __mmask8 __U, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_shrdv_epi64(__A, __B, __C), + (__v8di)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_shrdv_epi64(__mmask8 __U, __m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectq_512(__U, + (__v8di)_mm512_shrdv_epi64(__A, __B, __C), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_shrdv_epi32(__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_vpshrdvd512((__v16si)__A, (__v16si)__B, + (__v16si)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_shrdv_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) +{ + return (__m512i) __builtin_ia32_selectd_512(__U, + (__v16si)_mm512_shrdv_epi32(__A, __B, __C), + (__v16si)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_shrdv_epi32(__mmask16 __U, __m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i) __builtin_ia32_selectd_512(__U, + (__v16si)_mm512_shrdv_epi32(__A, __B, __C), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_shrdv_epi16(__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_vpshrdvw512((__v32hi)__A, (__v32hi)__B, + (__v32hi)__C); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_shrdv_epi16(__m512i __A, __mmask32 __U, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_shrdv_epi16(__A, __B, __C), + (__v32hi)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_shrdv_epi16(__mmask32 __U, __m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i)__builtin_ia32_selectw_512(__U, + (__v32hi)_mm512_shrdv_epi16(__A, __B, __C), + (__v32hi)_mm512_setzero_si512()); +} + + +#undef __DEFAULT_FN_ATTRS + +#endif + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmiintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmiintrin.h new file mode 100755 index 0000000..e47cd5c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmiintrin.h @@ -0,0 +1,106 @@ +/*===------------- avx512vbmiintrin.h - VBMI intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __VBMIINTRIN_H +#define __VBMIINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vbmi,evex512"), __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_permutex2var_epi8(__m512i __A, __m512i __I, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpermi2varqi512((__v64qi)__A, (__v64qi)__I, + (__v64qi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_permutex2var_epi8(__m512i __A, __mmask64 __U, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512(__U, + (__v64qi)_mm512_permutex2var_epi8(__A, __I, __B), + (__v64qi)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask2_permutex2var_epi8(__m512i __A, __m512i __I, __mmask64 __U, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512(__U, + (__v64qi)_mm512_permutex2var_epi8(__A, __I, __B), + (__v64qi)__I); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_permutex2var_epi8(__mmask64 __U, __m512i __A, __m512i __I, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512(__U, + (__v64qi)_mm512_permutex2var_epi8(__A, __I, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_permutexvar_epi8 (__m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_permvarqi512((__v64qi) __B, (__v64qi) __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_permutexvar_epi8 (__mmask64 __M, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_permutexvar_epi8(__A, __B), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_permutexvar_epi8 (__m512i __W, __mmask64 __M, __m512i __A, + __m512i __B) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_permutexvar_epi8(__A, __B), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_multishift_epi64_epi8(__m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_vpmultishiftqb512((__v64qi)__X, (__v64qi) __Y); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_multishift_epi64_epi8(__m512i __W, __mmask64 __M, __m512i __X, + __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_multishift_epi64_epi8(__X, __Y), + (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_multishift_epi64_epi8(__mmask64 __M, __m512i __X, __m512i __Y) +{ + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__M, + (__v64qi)_mm512_multishift_epi64_epi8(__X, __Y), + (__v64qi)_mm512_setzero_si512()); +} + + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmivlintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmivlintrin.h new file mode 100755 index 0000000..848ca2d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vbmivlintrin.h @@ -0,0 +1,193 @@ +/*===------------- avx512vbmivlintrin.h - VBMI intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __VBMIVLINTRIN_H +#define __VBMIVLINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vbmi,avx512vl,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vbmi,avx512vl,no-evex512"), \ + __min_vector_width__(256))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_permutex2var_epi8(__m128i __A, __m128i __I, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpermi2varqi128((__v16qi)__A, + (__v16qi)__I, + (__v16qi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_permutex2var_epi8(__m128i __A, __mmask16 __U, __m128i __I, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128(__U, + (__v16qi)_mm_permutex2var_epi8(__A, __I, __B), + (__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask2_permutex2var_epi8(__m128i __A, __m128i __I, __mmask16 __U, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128(__U, + (__v16qi)_mm_permutex2var_epi8(__A, __I, __B), + (__v16qi)__I); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_permutex2var_epi8(__mmask16 __U, __m128i __A, __m128i __I, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128(__U, + (__v16qi)_mm_permutex2var_epi8(__A, __I, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_permutex2var_epi8(__m256i __A, __m256i __I, __m256i __B) +{ + return (__m256i)__builtin_ia32_vpermi2varqi256((__v32qi)__A, (__v32qi)__I, + (__v32qi)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_permutex2var_epi8(__m256i __A, __mmask32 __U, __m256i __I, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256(__U, + (__v32qi)_mm256_permutex2var_epi8(__A, __I, __B), + (__v32qi)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask2_permutex2var_epi8(__m256i __A, __m256i __I, __mmask32 __U, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256(__U, + (__v32qi)_mm256_permutex2var_epi8(__A, __I, __B), + (__v32qi)__I); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutex2var_epi8(__mmask32 __U, __m256i __A, __m256i __I, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256(__U, + (__v32qi)_mm256_permutex2var_epi8(__A, __I, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_permutexvar_epi8 (__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_permvarqi128((__v16qi)__B, (__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_permutexvar_epi8 (__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_permutexvar_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_permutexvar_epi8 (__m128i __W, __mmask16 __M, __m128i __A, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_permutexvar_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_permutexvar_epi8 (__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_permvarqi256((__v32qi) __B, (__v32qi) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutexvar_epi8 (__mmask32 __M, __m256i __A, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_permutexvar_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_permutexvar_epi8 (__m256i __W, __mmask32 __M, __m256i __A, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_permutexvar_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_multishift_epi64_epi8(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_vpmultishiftqb128((__v16qi)__X, (__v16qi)__Y); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_multishift_epi64_epi8(__m128i __W, __mmask16 __M, __m128i __X, + __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_multishift_epi64_epi8(__X, __Y), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_multishift_epi64_epi8(__mmask16 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_multishift_epi64_epi8(__X, __Y), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_multishift_epi64_epi8(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_vpmultishiftqb256((__v32qi)__X, (__v32qi)__Y); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_multishift_epi64_epi8(__m256i __W, __mmask32 __M, __m256i __X, + __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_multishift_epi64_epi8(__X, __Y), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_multishift_epi64_epi8(__mmask32 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_multishift_epi64_epi8(__X, __Y), + (__v32qi)_mm256_setzero_si256()); +} + + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbf16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbf16intrin.h new file mode 100755 index 0000000..89c9f49 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbf16intrin.h @@ -0,0 +1,517 @@ +/*===--------- avx512vlbf16intrin.h - AVX512_BF16 intrinsics ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX512VLBF16INTRIN_H +#define __AVX512VLBF16INTRIN_H + +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512bf16,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512bf16,no-evex512"), \ + __min_vector_width__(256))) + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __B +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [8 x bfloat] whose lower 64 bits come from +/// conversion of __B, and higher 64 bits come from conversion of __A. +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_cvtne2ps_pbh(__m128 __A, __m128 __B) { + return (__m128bh)__builtin_ia32_cvtne2ps2bf16_128((__v4sf) __A, + (__v4sf) __B); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __B +/// A 128-bit vector of [4 x float]. +/// \param __W +/// A 128-bit vector of [8 x bfloat]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A or __B. A 0 means element from __W. +/// \returns A 128-bit vector of [8 x bfloat] whose lower 64 bits come from +/// conversion of __B, and higher 64 bits come from conversion of __A. +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_cvtne2ps_pbh(__m128bh __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128bh)__builtin_ia32_selectpbf_128((__mmask8)__U, + (__v8bf)_mm_cvtne2ps_pbh(__A, __B), + (__v8bf)__W); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __B +/// A 128-bit vector of [4 x float]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A or __B. A 0 means element is zero. +/// \returns A 128-bit vector of [8 x bfloat] whose lower 64 bits come from +/// conversion of __B, and higher 64 bits come from conversion of __A. +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtne2ps_pbh(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128bh)__builtin_ia32_selectpbf_128((__mmask8)__U, + (__v8bf)_mm_cvtne2ps_pbh(__A, __B), + (__v8bf)_mm_setzero_si128()); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __B +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [16 x bfloat] whose lower 128 bits come from +/// conversion of __B, and higher 128 bits come from conversion of __A. +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_cvtne2ps_pbh(__m256 __A, __m256 __B) { + return (__m256bh)__builtin_ia32_cvtne2ps2bf16_256((__v8sf) __A, + (__v8sf) __B); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __B +/// A 256-bit vector of [8 x float]. +/// \param __W +/// A 256-bit vector of [16 x bfloat]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A or __B. A 0 means element from __W. +/// \returns A 256-bit vector of [16 x bfloat] whose lower 128 bits come from +/// conversion of __B, and higher 128 bits come from conversion of __A. +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtne2ps_pbh(__m256bh __W, __mmask16 __U, __m256 __A, __m256 __B) { + return (__m256bh)__builtin_ia32_selectpbf_256((__mmask16)__U, + (__v16bf)_mm256_cvtne2ps_pbh(__A, __B), + (__v16bf)__W); +} + +/// Convert Two Packed Single Data to One Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNE2PS2BF16 instructions. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __B +/// A 256-bit vector of [8 x float]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A or __B. A 0 means element is zero. +/// \returns A 256-bit vector of [16 x bfloat] whose lower 128 bits come from +/// conversion of __B, and higher 128 bits come from conversion of __A. +static __inline__ __m256bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtne2ps_pbh(__mmask16 __U, __m256 __A, __m256 __B) { + return (__m256bh)__builtin_ia32_selectpbf_256((__mmask16)__U, + (__v16bf)_mm256_cvtne2ps_pbh(__A, __B), + (__v16bf)_mm256_setzero_si256()); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [8 x bfloat] whose lower 64 bits come from +/// conversion of __A, and higher 64 bits are 0. +#define _mm_cvtneps_pbh(A) \ + ((__m128bh)__builtin_ia32_vcvtneps2bf16128((__v4sf)(A))) + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __W +/// A 128-bit vector of [8 x bfloat]. +/// \param __U +/// A 4-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A. A 0 means element from __W. +/// \returns A 128-bit vector of [8 x bfloat] whose lower 64 bits come from +/// conversion of __A, and higher 64 bits are 0. +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_mask_cvtneps_pbh(__m128bh __W, __mmask8 __U, __m128 __A) { + return (__m128bh)__builtin_ia32_cvtneps2bf16_128_mask((__v4sf) __A, + (__v8bf)__W, + (__mmask8)__U); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \param __U +/// A 4-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A. A 0 means element is zero. +/// \returns A 128-bit vector of [8 x bfloat] whose lower 64 bits come from +/// conversion of __A, and higher 64 bits are 0. +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtneps_pbh(__mmask8 __U, __m128 __A) { + return (__m128bh)__builtin_ia32_cvtneps2bf16_128_mask((__v4sf) __A, + (__v8bf)_mm_setzero_si128(), + (__mmask8)__U); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \returns A 128-bit vector of [8 x bfloat] comes from conversion of __A. +#define _mm256_cvtneps_pbh(A) \ + ((__m128bh)__builtin_ia32_vcvtneps2bf16256((__v8sf)(A))) + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __W +/// A 256-bit vector of [8 x bfloat]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A. A 0 means element from __W. +/// \returns A 128-bit vector of [8 x bfloat] comes from conversion of __A. +static __inline__ __m128bh __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtneps_pbh(__m128bh __W, __mmask8 __U, __m256 __A) { + return (__m128bh)__builtin_ia32_cvtneps2bf16_256_mask((__v8sf)__A, + (__v8bf)__W, + (__mmask8)__U); +} + +/// Convert Packed Single Data to Packed BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means conversion of __A. A 0 means element is zero. +/// \returns A 128-bit vector of [8 x bfloat] comes from conversion of __A. +static __inline__ __m128bh __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtneps_pbh(__mmask8 __U, __m256 __A) { + return (__m128bh)__builtin_ia32_cvtneps2bf16_256_mask((__v8sf)__A, + (__v8bf)_mm_setzero_si128(), + (__mmask8)__U); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 128-bit vector of [8 x bfloat]. +/// \param __B +/// A 128-bit vector of [8 x bfloat]. +/// \param __D +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_dpbf16_ps(__m128 __D, __m128bh __A, __m128bh __B) { + return (__m128)__builtin_ia32_dpbf16ps_128((__v4sf)__D, + (__v8bf)__A, + (__v8bf)__B); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 128-bit vector of [8 x bfloat]. +/// \param __B +/// A 128-bit vector of [8 x bfloat]. +/// \param __D +/// A 128-bit vector of [4 x float]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means __A and __B's dot product accumulated with __D. A 0 means __D. +/// \returns A 128-bit vector of [4 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_dpbf16_ps(__m128 __D, __mmask8 __U, __m128bh __A, __m128bh __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_dpbf16_ps(__D, __A, __B), + (__v4sf)__D); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 128-bit vector of [8 x bfloat]. +/// \param __B +/// A 128-bit vector of [8 x bfloat]. +/// \param __D +/// A 128-bit vector of [4 x float]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means __A and __B's dot product accumulated with __D. A 0 means 0. +/// \returns A 128-bit vector of [4 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbf16_ps(__mmask8 __U, __m128 __D, __m128bh __A, __m128bh __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_dpbf16_ps(__D, __A, __B), + (__v4sf)_mm_setzero_si128()); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 256-bit vector of [16 x bfloat]. +/// \param __B +/// A 256-bit vector of [16 x bfloat]. +/// \param __D +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_dpbf16_ps(__m256 __D, __m256bh __A, __m256bh __B) { + return (__m256)__builtin_ia32_dpbf16ps_256((__v8sf)__D, + (__v16bf)__A, + (__v16bf)__B); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 256-bit vector of [16 x bfloat]. +/// \param __B +/// A 256-bit vector of [16 x bfloat]. +/// \param __D +/// A 256-bit vector of [8 x float]. +/// \param __U +/// A 16-bit mask value specifying what is chosen for each element. +/// A 1 means __A and __B's dot product accumulated with __D. A 0 means __D. +/// \returns A 256-bit vector of [8 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbf16_ps(__m256 __D, __mmask8 __U, __m256bh __A, __m256bh __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_dpbf16_ps(__D, __A, __B), + (__v8sf)__D); +} + +/// Dot Product of BF16 Pairs Accumulated into Packed Single Precision. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDPBF16PS instructions. +/// +/// \param __A +/// A 256-bit vector of [16 x bfloat]. +/// \param __B +/// A 256-bit vector of [16 x bfloat]. +/// \param __D +/// A 256-bit vector of [8 x float]. +/// \param __U +/// A 8-bit mask value specifying what is chosen for each element. +/// A 1 means __A and __B's dot product accumulated with __D. A 0 means 0. +/// \returns A 256-bit vector of [8 x float] comes from Dot Product of +/// __A, __B and __D +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpbf16_ps(__mmask8 __U, __m256 __D, __m256bh __A, __m256bh __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_dpbf16_ps(__D, __A, __B), + (__v8sf)_mm256_setzero_si256()); +} + +/// Convert One Single float Data to One BF16 Data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTNEPS2BF16 instructions. +/// +/// \param __A +/// A float data. +/// \returns A bf16 data whose sign field and exponent field keep unchanged, +/// and fraction field is truncated to 7 bits. +static __inline__ __bf16 __DEFAULT_FN_ATTRS128 _mm_cvtness_sbh(float __A) { + __v4sf __V = {__A, 0, 0, 0}; + __v8bf __R = __builtin_ia32_cvtneps2bf16_128_mask( + (__v4sf)__V, (__v8bf)_mm_undefined_si128(), (__mmask8)-1); + return (__bf16)__R[0]; +} + +/// Convert Packed BF16 Data to Packed float Data. +/// +/// \headerfile +/// +/// \param __A +/// A 128-bit vector of [4 x bfloat]. +/// \returns A 128-bit vector of [4 x float] come from conversion of __A +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) { + return _mm_castsi128_ps( + (__m128i)_mm_slli_epi32((__m128i)_mm_cvtepi16_epi32((__m128i)__A), 16)); +} + +/// Convert Packed BF16 Data to Packed float Data. +/// +/// \headerfile +/// +/// \param __A +/// A 128-bit vector of [8 x bfloat]. +/// \returns A 256-bit vector of [8 x float] come from conversion of __A +static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_cvtpbh_ps(__m128bh __A) { + return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32( + (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), 16)); +} + +/// Convert Packed BF16 Data to Packed float Data using zeroing mask. +/// +/// \headerfile +/// +/// \param __U +/// A 4-bit mask. Elements are zeroed out when the corresponding mask +/// bit is not set. +/// \param __A +/// A 128-bit vector of [4 x bfloat]. +/// \returns A 128-bit vector of [4 x float] come from conversion of __A +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) { + return _mm_castsi128_ps((__m128i)_mm_slli_epi32( + (__m128i)_mm_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16)); +} + +/// Convert Packed BF16 Data to Packed float Data using zeroing mask. +/// +/// \headerfile +/// +/// \param __U +/// A 8-bit mask. Elements are zeroed out when the corresponding mask +/// bit is not set. +/// \param __A +/// A 128-bit vector of [8 x bfloat]. +/// \returns A 256-bit vector of [8 x float] come from conversion of __A +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) { + return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32( + (__m256i)_mm256_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16)); +} + +/// Convert Packed BF16 Data to Packed float Data using merging mask. +/// +/// \headerfile +/// +/// \param __S +/// A 128-bit vector of [4 x float]. Elements are copied from __S when +/// the corresponding mask bit is not set. +/// \param __U +/// A 4-bit mask. Elements are zeroed out when the corresponding mask +/// bit is not set. +/// \param __A +/// A 128-bit vector of [4 x bfloat]. +/// \returns A 128-bit vector of [4 x float] come from conversion of __A +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtpbh_ps(__m128 __S, __mmask8 __U, __m128bh __A) { + return _mm_castsi128_ps((__m128i)_mm_mask_slli_epi32( + (__m128i)__S, (__mmask8)__U, (__m128i)_mm_cvtepi16_epi32((__m128i)__A), + 16)); +} + +/// Convert Packed BF16 Data to Packed float Data using merging mask. +/// +/// \headerfile +/// +/// \param __S +/// A 256-bit vector of [8 x float]. Elements are copied from __S when +/// the corresponding mask bit is not set. +/// \param __U +/// A 8-bit mask. Elements are zeroed out when the corresponding mask +/// bit is not set. +/// \param __A +/// A 128-bit vector of [8 x bfloat]. +/// \returns A 256-bit vector of [8 x float] come from conversion of __A +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpbh_ps(__m256 __S, __mmask8 __U, __m128bh __A) { + return _mm256_castsi256_ps((__m256i)_mm256_mask_slli_epi32( + (__m256i)__S, (__mmask8)__U, (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), + 16)); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbitalgintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbitalgintrin.h new file mode 100755 index 0000000..1b01fe0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbitalgintrin.h @@ -0,0 +1,151 @@ +/*===---- avx512vlbitalgintrin.h - BITALG intrinsics -----------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLBITALGINTRIN_H +#define __AVX512VLBITALGINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512bitalg,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512bitalg,no-evex512"), \ + __min_vector_width__(256))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_popcnt_epi16(__m256i __A) +{ + return (__m256i)__builtin_elementwise_popcount((__v16hu)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_popcnt_epi16(__m256i __A, __mmask16 __U, __m256i __B) +{ + return (__m256i) __builtin_ia32_selectw_256((__mmask16) __U, + (__v16hi) _mm256_popcnt_epi16(__B), + (__v16hi) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_popcnt_epi16(__mmask16 __U, __m256i __B) +{ + return _mm256_mask_popcnt_epi16((__m256i) _mm256_setzero_si256(), + __U, + __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_popcnt_epi16(__m128i __A) +{ + return (__m128i)__builtin_elementwise_popcount((__v8hu)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_popcnt_epi16(__m128i __A, __mmask8 __U, __m128i __B) +{ + return (__m128i) __builtin_ia32_selectw_128((__mmask8) __U, + (__v8hi) _mm_popcnt_epi16(__B), + (__v8hi) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_popcnt_epi16(__mmask8 __U, __m128i __B) +{ + return _mm_mask_popcnt_epi16((__m128i) _mm_setzero_si128(), + __U, + __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_popcnt_epi8(__m256i __A) +{ + return (__m256i)__builtin_elementwise_popcount((__v32qu)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_popcnt_epi8(__m256i __A, __mmask32 __U, __m256i __B) +{ + return (__m256i) __builtin_ia32_selectb_256((__mmask32) __U, + (__v32qi) _mm256_popcnt_epi8(__B), + (__v32qi) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_popcnt_epi8(__mmask32 __U, __m256i __B) +{ + return _mm256_mask_popcnt_epi8((__m256i) _mm256_setzero_si256(), + __U, + __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_popcnt_epi8(__m128i __A) +{ + return (__m128i)__builtin_elementwise_popcount((__v16qu)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_popcnt_epi8(__m128i __A, __mmask16 __U, __m128i __B) +{ + return (__m128i) __builtin_ia32_selectb_128((__mmask16) __U, + (__v16qi) _mm_popcnt_epi8(__B), + (__v16qi) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_popcnt_epi8(__mmask16 __U, __m128i __B) +{ + return _mm_mask_popcnt_epi8((__m128i) _mm_setzero_si128(), + __U, + __B); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_mask_bitshuffle_epi64_mask(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__mmask32) __builtin_ia32_vpshufbitqmb256_mask((__v32qi) __A, + (__v32qi) __B, + __U); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_bitshuffle_epi64_mask(__m256i __A, __m256i __B) +{ + return _mm256_mask_bitshuffle_epi64_mask((__mmask32) -1, + __A, + __B); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_mask_bitshuffle_epi64_mask(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__mmask16) __builtin_ia32_vpshufbitqmb128_mask((__v16qi) __A, + (__v16qi) __B, + __U); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_bitshuffle_epi64_mask(__m128i __A, __m128i __B) +{ + return _mm_mask_bitshuffle_epi64_mask((__mmask16) -1, + __A, + __B); +} + + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbwintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbwintrin.h new file mode 100755 index 0000000..9aedba0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlbwintrin.h @@ -0,0 +1,3167 @@ +/*===---- avx512vlbwintrin.h - AVX512VL and AVX512BW intrinsics ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLBWINTRIN_H +#define __AVX512VLBWINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512bw,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512bw,no-evex512"), \ + __min_vector_width__(256))) + +/* Integer compare */ + +#define _mm_cmp_epi8_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)(__m128i)(a), \ + (__v16qi)(__m128i)(b), (int)(p), \ + (__mmask16)-1)) + +#define _mm_mask_cmp_epi8_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_cmpb128_mask((__v16qi)(__m128i)(a), \ + (__v16qi)(__m128i)(b), (int)(p), \ + (__mmask16)(m))) + +#define _mm_cmp_epu8_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)(__m128i)(a), \ + (__v16qi)(__m128i)(b), (int)(p), \ + (__mmask16)-1)) + +#define _mm_mask_cmp_epu8_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_ucmpb128_mask((__v16qi)(__m128i)(a), \ + (__v16qi)(__m128i)(b), (int)(p), \ + (__mmask16)(m))) + +#define _mm256_cmp_epi8_mask(a, b, p) \ + ((__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)(__m256i)(a), \ + (__v32qi)(__m256i)(b), (int)(p), \ + (__mmask32)-1)) + +#define _mm256_mask_cmp_epi8_mask(m, a, b, p) \ + ((__mmask32)__builtin_ia32_cmpb256_mask((__v32qi)(__m256i)(a), \ + (__v32qi)(__m256i)(b), (int)(p), \ + (__mmask32)(m))) + +#define _mm256_cmp_epu8_mask(a, b, p) \ + ((__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)(__m256i)(a), \ + (__v32qi)(__m256i)(b), (int)(p), \ + (__mmask32)-1)) + +#define _mm256_mask_cmp_epu8_mask(m, a, b, p) \ + ((__mmask32)__builtin_ia32_ucmpb256_mask((__v32qi)(__m256i)(a), \ + (__v32qi)(__m256i)(b), (int)(p), \ + (__mmask32)(m))) + +#define _mm_cmp_epi16_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)(__m128i)(a), \ + (__v8hi)(__m128i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_epi16_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpw128_mask((__v8hi)(__m128i)(a), \ + (__v8hi)(__m128i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm_cmp_epu16_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)(__m128i)(a), \ + (__v8hi)(__m128i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_epu16_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpw128_mask((__v8hi)(__m128i)(a), \ + (__v8hi)(__m128i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_epi16_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)(__m256i)(a), \ + (__v16hi)(__m256i)(b), (int)(p), \ + (__mmask16)-1)) + +#define _mm256_mask_cmp_epi16_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_cmpw256_mask((__v16hi)(__m256i)(a), \ + (__v16hi)(__m256i)(b), (int)(p), \ + (__mmask16)(m))) + +#define _mm256_cmp_epu16_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)(__m256i)(a), \ + (__v16hi)(__m256i)(b), (int)(p), \ + (__mmask16)-1)) + +#define _mm256_mask_cmp_epu16_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_ucmpw256_mask((__v16hi)(__m256i)(a), \ + (__v16hi)(__m256i)(b), (int)(p), \ + (__mmask16)(m))) + +#define _mm_cmpeq_epi8_mask(A, B) \ + _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epi8_mask(k, A, B) \ + _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epi8_mask(A, B) \ + _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epi8_mask(k, A, B) \ + _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epi8_mask(A, B) \ + _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epi8_mask(k, A, B) \ + _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epi8_mask(A, B) \ + _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epi8_mask(k, A, B) \ + _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epi8_mask(A, B) \ + _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epi8_mask(k, A, B) \ + _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epi8_mask(A, B) \ + _mm_cmp_epi8_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epi8_mask(k, A, B) \ + _mm_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epi8_mask(A, B) \ + _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epi8_mask(k, A, B) \ + _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epi8_mask(A, B) \ + _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epi8_mask(k, A, B) \ + _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epi8_mask(A, B) \ + _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epi8_mask(k, A, B) \ + _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epi8_mask(A, B) \ + _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epi8_mask(k, A, B) \ + _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epi8_mask(A, B) \ + _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epi8_mask(k, A, B) \ + _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epi8_mask(A, B) \ + _mm256_cmp_epi8_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epi8_mask(k, A, B) \ + _mm256_mask_cmp_epi8_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm_cmpeq_epu8_mask(A, B) \ + _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epu8_mask(k, A, B) \ + _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epu8_mask(A, B) \ + _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epu8_mask(k, A, B) \ + _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epu8_mask(A, B) \ + _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epu8_mask(k, A, B) \ + _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epu8_mask(A, B) \ + _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epu8_mask(k, A, B) \ + _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epu8_mask(A, B) \ + _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epu8_mask(k, A, B) \ + _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epu8_mask(A, B) \ + _mm_cmp_epu8_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epu8_mask(k, A, B) \ + _mm_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epu8_mask(A, B) \ + _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epu8_mask(k, A, B) \ + _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epu8_mask(A, B) \ + _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epu8_mask(k, A, B) \ + _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epu8_mask(A, B) \ + _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epu8_mask(k, A, B) \ + _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epu8_mask(A, B) \ + _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epu8_mask(k, A, B) \ + _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epu8_mask(A, B) \ + _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epu8_mask(k, A, B) \ + _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epu8_mask(A, B) \ + _mm256_cmp_epu8_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epu8_mask(k, A, B) \ + _mm256_mask_cmp_epu8_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm_cmpeq_epi16_mask(A, B) \ + _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epi16_mask(k, A, B) \ + _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epi16_mask(A, B) \ + _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epi16_mask(k, A, B) \ + _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epi16_mask(A, B) \ + _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epi16_mask(k, A, B) \ + _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epi16_mask(A, B) \ + _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epi16_mask(k, A, B) \ + _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epi16_mask(A, B) \ + _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epi16_mask(k, A, B) \ + _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epi16_mask(A, B) \ + _mm_cmp_epi16_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epi16_mask(k, A, B) \ + _mm_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epi16_mask(A, B) \ + _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epi16_mask(k, A, B) \ + _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epi16_mask(A, B) \ + _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epi16_mask(k, A, B) \ + _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epi16_mask(A, B) \ + _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epi16_mask(k, A, B) \ + _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epi16_mask(A, B) \ + _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epi16_mask(k, A, B) \ + _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epi16_mask(A, B) \ + _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epi16_mask(k, A, B) \ + _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epi16_mask(A, B) \ + _mm256_cmp_epi16_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epi16_mask(k, A, B) \ + _mm256_mask_cmp_epi16_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm_cmpeq_epu16_mask(A, B) \ + _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epu16_mask(k, A, B) \ + _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epu16_mask(A, B) \ + _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epu16_mask(k, A, B) \ + _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epu16_mask(A, B) \ + _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epu16_mask(k, A, B) \ + _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epu16_mask(A, B) \ + _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epu16_mask(k, A, B) \ + _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epu16_mask(A, B) \ + _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epu16_mask(k, A, B) \ + _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epu16_mask(A, B) \ + _mm_cmp_epu16_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epu16_mask(k, A, B) \ + _mm_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epu16_mask(A, B) \ + _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epu16_mask(k, A, B) \ + _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epu16_mask(A, B) \ + _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epu16_mask(k, A, B) \ + _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epu16_mask(A, B) \ + _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epu16_mask(k, A, B) \ + _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epu16_mask(A, B) \ + _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epu16_mask(k, A, B) \ + _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epu16_mask(A, B) \ + _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epu16_mask(k, A, B) \ + _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epu16_mask(A, B) \ + _mm256_cmp_epu16_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epu16_mask(k, A, B) \ + _mm256_mask_cmp_epu16_mask((k), (A), (B), _MM_CMPINT_NE) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_add_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B){ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_add_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_epi8(__mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_add_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_add_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_add_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_epi16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_add_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sub_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_sub_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sub_epi8(__mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_sub_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sub_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sub_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sub_epi16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sub_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_add_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_add_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_add_epi8(__mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_add_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_add_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_add_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_add_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_add_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sub_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_sub_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_epi8(__mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_sub_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sub_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sub_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sub_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mullo_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mullo_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mullo_epi16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mullo_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mullo_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mullo_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mullo_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mullo_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_blend_epi8 (__mmask16 __U, __m128i __A, __m128i __W) +{ + return (__m128i) __builtin_ia32_selectb_128 ((__mmask16) __U, + (__v16qi) __W, + (__v16qi) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_epi8 (__mmask32 __U, __m256i __A, __m256i __W) +{ + return (__m256i) __builtin_ia32_selectb_256 ((__mmask32) __U, + (__v32qi) __W, + (__v32qi) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_blend_epi16 (__mmask8 __U, __m128i __A, __m128i __W) +{ + return (__m128i) __builtin_ia32_selectw_128 ((__mmask8) __U, + (__v8hi) __W, + (__v8hi) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_epi16 (__mmask16 __U, __m256i __A, __m256i __W) +{ + return (__m256i) __builtin_ia32_selectw_256 ((__mmask16) __U, + (__v16hi) __W, + (__v16hi) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_abs_epi8(__m128i __W, __mmask16 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_abs_epi8(__A), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_abs_epi8(__mmask16 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_abs_epi8(__A), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_abs_epi8(__m256i __W, __mmask32 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_abs_epi8(__A), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_abs_epi8 (__mmask32 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_abs_epi8(__A), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_abs_epi16(__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_abs_epi16(__A), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_abs_epi16(__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_abs_epi16(__A), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_abs_epi16(__m256i __W, __mmask16 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_abs_epi16(__A), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_abs_epi16(__mmask16 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_abs_epi16(__A), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_packs_epi32(__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_packs_epi32(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_packs_epi32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_packs_epi32(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_packs_epi32(__mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_packs_epi32(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_packs_epi32(__m256i __W, __mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_packs_epi32(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_packs_epi16(__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_packs_epi16(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_packs_epi16(__m128i __W, __mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_packs_epi16(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_packs_epi16(__mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_packs_epi16(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_packs_epi16(__m256i __W, __mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_packs_epi16(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_packus_epi32(__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_packus_epi32(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_packus_epi32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_packus_epi32(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_packus_epi32(__mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_packus_epi32(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_packus_epi32(__m256i __W, __mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_packus_epi32(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_packus_epi16(__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_packus_epi16(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_packus_epi16(__m128i __W, __mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_packus_epi16(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_packus_epi16(__mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_packus_epi16(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_packus_epi16(__m256i __W, __mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_packus_epi16(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_adds_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_adds_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_adds_epi8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_adds_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_adds_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_adds_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_adds_epi8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_adds_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_adds_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_adds_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_adds_epi16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_adds_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_adds_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_adds_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_adds_epi16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_adds_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_adds_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_adds_epu8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_adds_epu8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_adds_epu8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_adds_epu8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_adds_epu8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_adds_epu8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_adds_epu8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_adds_epu16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_adds_epu16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_adds_epu16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_adds_epu16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_adds_epu16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_adds_epu16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_adds_epu16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_adds_epu16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_avg_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_avg_epu8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_avg_epu8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_avg_epu8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_avg_epu8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_avg_epu8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_avg_epu8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_avg_epu8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_avg_epu16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_avg_epu16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_avg_epu16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_avg_epu16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_avg_epu16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_avg_epu16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_avg_epu16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_avg_epu16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epi8(__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_max_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epi8(__m128i __W, __mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_max_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epi8(__mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_max_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epi8(__m256i __W, __mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_max_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epi16(__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_max_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epi16(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_max_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epi16(__mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_max_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epi16(__m256i __W, __mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_max_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epu8(__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_max_epu8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epu8(__m128i __W, __mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_max_epu8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epu8 (__mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_max_epu8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epu8(__m256i __W, __mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_max_epu8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epu16(__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_max_epu16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epu16(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_max_epu16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epu16(__mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_max_epu16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epu16(__m256i __W, __mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_max_epu16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epi8(__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_min_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epi8(__m128i __W, __mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_min_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epi8(__mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_min_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epi8(__m256i __W, __mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_min_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epi16(__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_min_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epi16(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_min_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epi16(__mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_min_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epi16(__m256i __W, __mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_min_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epu8(__mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_min_epu8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epu8(__m128i __W, __mmask16 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm_min_epu8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epu8 (__mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_min_epu8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epu8(__m256i __W, __mmask32 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__M, + (__v32qi)_mm256_min_epu8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epu16(__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_min_epu16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epu16(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_min_epu16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epu16(__mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_min_epu16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epu16(__m256i __W, __mmask16 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_min_epu16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shuffle_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_shuffle_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shuffle_epi8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_shuffle_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shuffle_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_shuffle_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shuffle_epi8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_shuffle_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_subs_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_subs_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_subs_epi8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_subs_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_subs_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_subs_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_subs_epi8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_subs_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_subs_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_subs_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_subs_epi16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_subs_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_subs_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_subs_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_subs_epi16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_subs_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_subs_epu8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_subs_epu8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_subs_epu8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_subs_epu8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_subs_epu8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_subs_epu8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_subs_epu8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_subs_epu8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_subs_epu16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_subs_epu16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_subs_epu16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_subs_epu16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_subs_epu16(__m256i __W, __mmask16 __U, __m256i __A, + __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_subs_epu16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_subs_epu16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_subs_epu16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_permutex2var_epi16(__m128i __A, __m128i __I, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpermi2varhi128((__v8hi)__A, (__v8hi)__I, + (__v8hi) __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_permutex2var_epi16(__m128i __A, __mmask8 __U, __m128i __I, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_permutex2var_epi16(__A, __I, __B), + (__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask2_permutex2var_epi16(__m128i __A, __m128i __I, __mmask8 __U, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_permutex2var_epi16(__A, __I, __B), + (__v8hi)__I); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_permutex2var_epi16 (__mmask8 __U, __m128i __A, __m128i __I, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_permutex2var_epi16(__A, __I, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_permutex2var_epi16(__m256i __A, __m256i __I, __m256i __B) +{ + return (__m256i)__builtin_ia32_vpermi2varhi256((__v16hi)__A, (__v16hi)__I, + (__v16hi)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_permutex2var_epi16(__m256i __A, __mmask16 __U, __m256i __I, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_permutex2var_epi16(__A, __I, __B), + (__v16hi)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask2_permutex2var_epi16(__m256i __A, __m256i __I, __mmask16 __U, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_permutex2var_epi16(__A, __I, __B), + (__v16hi)__I); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutex2var_epi16 (__mmask16 __U, __m256i __A, __m256i __I, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_permutex2var_epi16(__A, __I, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_maddubs_epi16(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_maddubs_epi16(__X, __Y), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_maddubs_epi16(__mmask8 __U, __m128i __X, __m128i __Y) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_maddubs_epi16(__X, __Y), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_maddubs_epi16(__m256i __W, __mmask16 __U, __m256i __X, + __m256i __Y) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_maddubs_epi16(__X, __Y), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_maddubs_epi16(__mmask16 __U, __m256i __X, __m256i __Y) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_maddubs_epi16(__X, __Y), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_madd_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_madd_epi16(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_madd_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_madd_epi16(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_madd_epi16(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_madd_epi16(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_madd_epi16(__mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_madd_epi16(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtsepi16_epi8 (__m128i __A) { + return (__m128i) __builtin_ia32_pmovswb128_mask ((__v8hi) __A, + (__v16qi) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi16_epi8 (__m128i __O, __mmask8 __M, __m128i __A) { + return (__m128i) __builtin_ia32_pmovswb128_mask ((__v8hi) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsepi16_epi8 (__mmask8 __M, __m128i __A) { + return (__m128i) __builtin_ia32_pmovswb128_mask ((__v8hi) __A, + (__v16qi) _mm_setzero_si128(), + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtsepi16_epi8 (__m256i __A) { + return (__m128i) __builtin_ia32_pmovswb256_mask ((__v16hi) __A, + (__v16qi) _mm_setzero_si128(), + (__mmask16) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi16_epi8 (__m128i __O, __mmask16 __M, __m256i __A) { + return (__m128i) __builtin_ia32_pmovswb256_mask ((__v16hi) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtsepi16_epi8 (__mmask16 __M, __m256i __A) { + return (__m128i) __builtin_ia32_pmovswb256_mask ((__v16hi) __A, + (__v16qi) _mm_setzero_si128(), + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtusepi16_epi8 (__m128i __A) { + return (__m128i) __builtin_ia32_pmovuswb128_mask ((__v8hi) __A, + (__v16qi) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi16_epi8 (__m128i __O, __mmask8 __M, __m128i __A) { + return (__m128i) __builtin_ia32_pmovuswb128_mask ((__v8hi) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtusepi16_epi8 (__mmask8 __M, __m128i __A) { + return (__m128i) __builtin_ia32_pmovuswb128_mask ((__v8hi) __A, + (__v16qi) _mm_setzero_si128(), + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtusepi16_epi8 (__m256i __A) { + return (__m128i) __builtin_ia32_pmovuswb256_mask ((__v16hi) __A, + (__v16qi) _mm_setzero_si128(), + (__mmask16) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi16_epi8 (__m128i __O, __mmask16 __M, __m256i __A) { + return (__m128i) __builtin_ia32_pmovuswb256_mask ((__v16hi) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtusepi16_epi8 (__mmask16 __M, __m256i __A) { + return (__m128i) __builtin_ia32_pmovuswb256_mask ((__v16hi) __A, + (__v16qi) _mm_setzero_si128(), + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtepi16_epi8 (__m128i __A) { + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v8hi)__A, __v8qi), + (__v8qi){0, 0, 0, 0, 0, 0, 0, 0}, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi16_epi8 (__m128i __O, __mmask8 __M, __m128i __A) { + return (__m128i) __builtin_ia32_pmovwb128_mask ((__v8hi) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi16_epi8 (__mmask8 __M, __m128i __A) { + return (__m128i) __builtin_ia32_pmovwb128_mask ((__v8hi) __A, + (__v16qi) _mm_setzero_si128(), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi16_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovwb128mem_mask ((__v16qi *) __P, (__v8hi) __A, __M); +} + + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi16_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovswb128mem_mask ((__v16qi *) __P, (__v8hi) __A, __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi16_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovuswb128mem_mask ((__v16qi *) __P, (__v8hi) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi16_epi8 (__m256i __A) { + return (__m128i)__builtin_convertvector((__v16hi) __A, __v16qi); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi16_epi8 (__m128i __O, __mmask16 __M, __m256i __A) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm256_cvtepi16_epi8(__A), + (__v16qi)__O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi16_epi8 (__mmask16 __M, __m256i __A) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__M, + (__v16qi)_mm256_cvtepi16_epi8(__A), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi16_storeu_epi8 (void * __P, __mmask16 __M, __m256i __A) +{ + __builtin_ia32_pmovwb256mem_mask ((__v16qi *) __P, (__v16hi) __A, __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi16_storeu_epi8 (void * __P, __mmask16 __M, __m256i __A) +{ + __builtin_ia32_pmovswb256mem_mask ((__v16qi *) __P, (__v16hi) __A, __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi16_storeu_epi8 (void * __P, __mmask16 __M, __m256i __A) +{ + __builtin_ia32_pmovuswb256mem_mask ((__v16qi*) __P, (__v16hi) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mulhrs_epi16(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mulhrs_epi16(__X, __Y), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mulhrs_epi16(__mmask8 __U, __m128i __X, __m128i __Y) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mulhrs_epi16(__X, __Y), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mulhrs_epi16(__m256i __W, __mmask16 __U, __m256i __X, __m256i __Y) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mulhrs_epi16(__X, __Y), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mulhrs_epi16(__mmask16 __U, __m256i __X, __m256i __Y) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mulhrs_epi16(__X, __Y), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mulhi_epu16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mulhi_epu16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mulhi_epu16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mulhi_epu16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mulhi_epu16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mulhi_epu16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mulhi_epu16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mulhi_epu16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mulhi_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mulhi_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mulhi_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_mulhi_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mulhi_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mulhi_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mulhi_epi16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_mulhi_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpackhi_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_unpackhi_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpackhi_epi8(__mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_unpackhi_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpackhi_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_unpackhi_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpackhi_epi8(__mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_unpackhi_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpackhi_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_unpackhi_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpackhi_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_unpackhi_epi16(__A, __B), + (__v8hi) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpackhi_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_unpackhi_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpackhi_epi16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_unpackhi_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpacklo_epi8(__m128i __W, __mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_unpacklo_epi8(__A, __B), + (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpacklo_epi8(__mmask16 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_unpacklo_epi8(__A, __B), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpacklo_epi8(__m256i __W, __mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_unpacklo_epi8(__A, __B), + (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpacklo_epi8(__mmask32 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_unpacklo_epi8(__A, __B), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpacklo_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_unpacklo_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpacklo_epi16(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_unpacklo_epi16(__A, __B), + (__v8hi) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpacklo_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_unpacklo_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpacklo_epi16(__mmask16 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_unpacklo_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi8_epi16(__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_cvtepi8_epi16(__A), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi8_epi16(__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_cvtepi8_epi16(__A), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi8_epi16(__m256i __W, __mmask16 __U, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_cvtepi8_epi16(__A), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi8_epi16(__mmask16 __U, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_cvtepi8_epi16(__A), + (__v16hi)_mm256_setzero_si256()); +} + + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu8_epi16(__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_cvtepu8_epi16(__A), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu8_epi16(__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_cvtepu8_epi16(__A), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu8_epi16(__m256i __W, __mmask16 __U, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_cvtepu8_epi16(__A), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu8_epi16 (__mmask16 __U, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_cvtepu8_epi16(__A), + (__v16hi)_mm256_setzero_si256()); +} + + +#define _mm_mask_shufflehi_epi16(W, U, A, imm) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shufflehi_epi16((A), (imm)), \ + (__v8hi)(__m128i)(W))) + +#define _mm_maskz_shufflehi_epi16(U, A, imm) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shufflehi_epi16((A), (imm)), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_mask_shufflehi_epi16(W, U, A, imm) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shufflehi_epi16((A), (imm)), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_shufflehi_epi16(U, A, imm) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shufflehi_epi16((A), (imm)), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_mask_shufflelo_epi16(W, U, A, imm) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shufflelo_epi16((A), (imm)), \ + (__v8hi)(__m128i)(W))) + +#define _mm_maskz_shufflelo_epi16(U, A, imm) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shufflelo_epi16((A), (imm)), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_mask_shufflelo_epi16(W, U, A, imm) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shufflelo_epi16((A), \ + (imm)), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_shufflelo_epi16(U, A, imm) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shufflelo_epi16((A), \ + (imm)), \ + (__v16hi)_mm256_setzero_si256())) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sllv_epi16(__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_psllv16hi((__v16hi)__A, (__v16hi)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sllv_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sllv_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sllv_epi16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sllv_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_sllv_epi16(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_psllv8hi((__v8hi)__A, (__v8hi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sllv_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sllv_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sllv_epi16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sllv_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sll_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sll_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sll_epi16 (__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sll_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sll_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sll_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sll_epi16(__mmask16 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sll_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_slli_epi16(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_slli_epi16(__A, (int)__B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_slli_epi16 (__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_slli_epi16(__A, (int)__B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_slli_epi16(__m256i __W, __mmask16 __U, __m256i __A, + unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_slli_epi16(__A, (int)__B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_slli_epi16(__mmask16 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_slli_epi16(__A, (int)__B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srlv_epi16(__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_psrlv16hi((__v16hi)__A, (__v16hi)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srlv_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srlv_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srlv_epi16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srlv_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srlv_epi16(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_psrlv8hi((__v8hi)__A, (__v8hi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srlv_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srlv_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srlv_epi16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srlv_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srav_epi16(__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_psrav16hi((__v16hi)__A, (__v16hi)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srav_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srav_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srav_epi16(__mmask16 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srav_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srav_epi16(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_psrav8hi((__v8hi)__A, (__v8hi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srav_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srav_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srav_epi16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srav_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sra_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sra_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sra_epi16(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_sra_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sra_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sra_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sra_epi16(__mmask16 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_sra_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srai_epi16(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srai_epi16(__A, (int)__B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srai_epi16(__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srai_epi16(__A, (int)__B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srai_epi16(__m256i __W, __mmask16 __U, __m256i __A, + unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srai_epi16(__A, (int)__B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srai_epi16(__mmask16 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srai_epi16(__A, (int)__B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srl_epi16(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srl_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srl_epi16 (__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srl_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srl_epi16(__m256i __W, __mmask16 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srl_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srl_epi16(__mmask16 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srl_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srli_epi16(__m128i __W, __mmask8 __U, __m128i __A, int __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srli_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srli_epi16 (__mmask8 __U, __m128i __A, int __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_srli_epi16(__A, __B), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srli_epi16(__m256i __W, __mmask16 __U, __m256i __A, int __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srli_epi16(__A, __B), + (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srli_epi16(__mmask16 __U, __m256i __A, int __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_srli_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mov_epi16 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectw_128 ((__mmask8) __U, + (__v8hi) __A, + (__v8hi) __W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mov_epi16 (__mmask8 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectw_128 ((__mmask8) __U, + (__v8hi) __A, + (__v8hi) _mm_setzero_si128 ()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mov_epi16 (__m256i __W, __mmask16 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectw_256 ((__mmask16) __U, + (__v16hi) __A, + (__v16hi) __W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mov_epi16 (__mmask16 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectw_256 ((__mmask16) __U, + (__v16hi) __A, + (__v16hi) _mm256_setzero_si256 ()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mov_epi8 (__m128i __W, __mmask16 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectb_128 ((__mmask16) __U, + (__v16qi) __A, + (__v16qi) __W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mov_epi8 (__mmask16 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectb_128 ((__mmask16) __U, + (__v16qi) __A, + (__v16qi) _mm_setzero_si128 ()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mov_epi8 (__m256i __W, __mmask32 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectb_256 ((__mmask32) __U, + (__v32qi) __A, + (__v32qi) __W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mov_epi8 (__mmask32 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectb_256 ((__mmask32) __U, + (__v32qi) __A, + (__v32qi) _mm256_setzero_si256 ()); +} + + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_set1_epi8 (__m128i __O, __mmask16 __M, char __A) +{ + return (__m128i) __builtin_ia32_selectb_128(__M, + (__v16qi) _mm_set1_epi8(__A), + (__v16qi) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_set1_epi8 (__mmask16 __M, char __A) +{ + return (__m128i) __builtin_ia32_selectb_128(__M, + (__v16qi) _mm_set1_epi8(__A), + (__v16qi) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_set1_epi8 (__m256i __O, __mmask32 __M, char __A) +{ + return (__m256i) __builtin_ia32_selectb_256(__M, + (__v32qi) _mm256_set1_epi8(__A), + (__v32qi) __O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_set1_epi8 (__mmask32 __M, char __A) +{ + return (__m256i) __builtin_ia32_selectb_256(__M, + (__v32qi) _mm256_set1_epi8(__A), + (__v32qi) _mm256_setzero_si256()); +} + +static __inline __m128i __DEFAULT_FN_ATTRS128 +_mm_loadu_epi16 (void const *__P) +{ + struct __loadu_epi16 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi16*)__P)->__v; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadu_epi16 (__m128i __W, __mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddquhi128_mask ((const __v8hi *) __P, + (__v8hi) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadu_epi16 (__mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddquhi128_mask ((const __v8hi *) __P, + (__v8hi) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadu_epi16 (void const *__P) +{ + struct __loadu_epi16 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi16*)__P)->__v; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadu_epi16 (__m256i __W, __mmask16 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddquhi256_mask ((const __v16hi *) __P, + (__v16hi) __W, + (__mmask16) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadu_epi16 (__mmask16 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddquhi256_mask ((const __v16hi *) __P, + (__v16hi) + _mm256_setzero_si256 (), + (__mmask16) __U); +} + +static __inline __m128i __DEFAULT_FN_ATTRS128 +_mm_loadu_epi8 (void const *__P) +{ + struct __loadu_epi8 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi8*)__P)->__v; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadu_epi8 (__m128i __W, __mmask16 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddquqi128_mask ((const __v16qi *) __P, + (__v16qi) __W, + (__mmask16) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadu_epi8 (__mmask16 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddquqi128_mask ((const __v16qi *) __P, + (__v16qi) + _mm_setzero_si128 (), + (__mmask16) __U); +} + +static __inline __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadu_epi8 (void const *__P) +{ + struct __loadu_epi8 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi8*)__P)->__v; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadu_epi8 (__m256i __W, __mmask32 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddquqi256_mask ((const __v32qi *) __P, + (__v32qi) __W, + (__mmask32) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadu_epi8 (__mmask32 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddquqi256_mask ((const __v32qi *) __P, + (__v32qi) + _mm256_setzero_si256 (), + (__mmask32) __U); +} + +static __inline void __DEFAULT_FN_ATTRS128 +_mm_storeu_epi16 (void *__P, __m128i __A) +{ + struct __storeu_epi16 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi16*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_storeu_epi16 (void *__P, __mmask8 __U, __m128i __A) +{ + __builtin_ia32_storedquhi128_mask ((__v8hi *) __P, + (__v8hi) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS256 +_mm256_storeu_epi16 (void *__P, __m256i __A) +{ + struct __storeu_epi16 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi16*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_storeu_epi16 (void *__P, __mmask16 __U, __m256i __A) +{ + __builtin_ia32_storedquhi256_mask ((__v16hi *) __P, + (__v16hi) __A, + (__mmask16) __U); +} + +static __inline void __DEFAULT_FN_ATTRS128 +_mm_storeu_epi8 (void *__P, __m128i __A) +{ + struct __storeu_epi8 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi8*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_storeu_epi8 (void *__P, __mmask16 __U, __m128i __A) +{ + __builtin_ia32_storedquqi128_mask ((__v16qi *) __P, + (__v16qi) __A, + (__mmask16) __U); +} + +static __inline void __DEFAULT_FN_ATTRS256 +_mm256_storeu_epi8 (void *__P, __m256i __A) +{ + struct __storeu_epi8 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi8*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_storeu_epi8 (void *__P, __mmask32 __U, __m256i __A) +{ + __builtin_ia32_storedquqi256_mask ((__v32qi *) __P, + (__v32qi) __A, + (__mmask32) __U); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_test_epi8_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpneq_epi8_mask (_mm_and_si128(__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_mask_test_epi8_mask (__mmask16 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpneq_epi8_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_test_epi8_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpneq_epi8_mask (_mm256_and_si256(__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_mask_test_epi8_mask (__mmask32 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpneq_epi8_mask (__U, _mm256_and_si256(__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_test_epi16_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpneq_epi16_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_mask_test_epi16_mask (__mmask8 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpneq_epi16_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS256 +_mm256_test_epi16_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpneq_epi16_mask (_mm256_and_si256 (__A, __B), + _mm256_setzero_si256 ()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS256 +_mm256_mask_test_epi16_mask (__mmask16 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpneq_epi16_mask (__U, _mm256_and_si256(__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_testn_epi8_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpeq_epi8_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_mask_testn_epi8_mask (__mmask16 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpeq_epi8_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_testn_epi8_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpeq_epi8_mask (_mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_mask_testn_epi8_mask (__mmask32 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpeq_epi8_mask (__U, _mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_testn_epi16_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpeq_epi16_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_mask_testn_epi16_mask (__mmask8 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpeq_epi16_mask (__U, _mm_and_si128(__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS256 +_mm256_testn_epi16_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpeq_epi16_mask (_mm256_and_si256(__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS256 +_mm256_mask_testn_epi16_mask (__mmask16 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpeq_epi16_mask (__U, _mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS128 +_mm_movepi8_mask (__m128i __A) +{ + return (__mmask16) __builtin_ia32_cvtb2mask128 ((__v16qi) __A); +} + +static __inline__ __mmask32 __DEFAULT_FN_ATTRS256 +_mm256_movepi8_mask (__m256i __A) +{ + return (__mmask32) __builtin_ia32_cvtb2mask256 ((__v32qi) __A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_movepi16_mask (__m128i __A) +{ + return (__mmask8) __builtin_ia32_cvtw2mask128 ((__v8hi) __A); +} + +static __inline__ __mmask16 __DEFAULT_FN_ATTRS256 +_mm256_movepi16_mask (__m256i __A) +{ + return (__mmask16) __builtin_ia32_cvtw2mask256 ((__v16hi) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_movm_epi8 (__mmask16 __A) +{ + return (__m128i) __builtin_ia32_cvtmask2b128 (__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_movm_epi8 (__mmask32 __A) +{ + return (__m256i) __builtin_ia32_cvtmask2b256 (__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_movm_epi16 (__mmask8 __A) +{ + return (__m128i) __builtin_ia32_cvtmask2w128 (__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_movm_epi16 (__mmask16 __A) +{ + return (__m256i) __builtin_ia32_cvtmask2w256 (__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_broadcastb_epi8 (__m128i __O, __mmask16 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectb_128(__M, + (__v16qi) _mm_broadcastb_epi8(__A), + (__v16qi) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_broadcastb_epi8 (__mmask16 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectb_128(__M, + (__v16qi) _mm_broadcastb_epi8(__A), + (__v16qi) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcastb_epi8 (__m256i __O, __mmask32 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectb_256(__M, + (__v32qi) _mm256_broadcastb_epi8(__A), + (__v32qi) __O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcastb_epi8 (__mmask32 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectb_256(__M, + (__v32qi) _mm256_broadcastb_epi8(__A), + (__v32qi) _mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_broadcastw_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128(__M, + (__v8hi) _mm_broadcastw_epi16(__A), + (__v8hi) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_broadcastw_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectw_128(__M, + (__v8hi) _mm_broadcastw_epi16(__A), + (__v8hi) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcastw_epi16 (__m256i __O, __mmask16 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectw_256(__M, + (__v16hi) _mm256_broadcastw_epi16(__A), + (__v16hi) __O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcastw_epi16 (__mmask16 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectw_256(__M, + (__v16hi) _mm256_broadcastw_epi16(__A), + (__v16hi) _mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_set1_epi16 (__m256i __O, __mmask16 __M, short __A) +{ + return (__m256i) __builtin_ia32_selectw_256 (__M, + (__v16hi) _mm256_set1_epi16(__A), + (__v16hi) __O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_set1_epi16 (__mmask16 __M, short __A) +{ + return (__m256i) __builtin_ia32_selectw_256(__M, + (__v16hi)_mm256_set1_epi16(__A), + (__v16hi) _mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_set1_epi16 (__m128i __O, __mmask8 __M, short __A) +{ + return (__m128i) __builtin_ia32_selectw_128(__M, + (__v8hi) _mm_set1_epi16(__A), + (__v8hi) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_set1_epi16 (__mmask8 __M, short __A) +{ + return (__m128i) __builtin_ia32_selectw_128(__M, + (__v8hi) _mm_set1_epi16(__A), + (__v8hi) _mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_permutexvar_epi16 (__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_permvarhi128((__v8hi) __B, (__v8hi) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_permutexvar_epi16 (__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_permutexvar_epi16(__A, __B), + (__v8hi) _mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_permutexvar_epi16 (__m128i __W, __mmask8 __M, __m128i __A, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__M, + (__v8hi)_mm_permutexvar_epi16(__A, __B), + (__v8hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_permutexvar_epi16 (__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_permvarhi256((__v16hi) __B, (__v16hi) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutexvar_epi16 (__mmask16 __M, __m256i __A, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_permutexvar_epi16(__A, __B), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_permutexvar_epi16 (__m256i __W, __mmask16 __M, __m256i __A, + __m256i __B) +{ + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__M, + (__v16hi)_mm256_permutexvar_epi16(__A, __B), + (__v16hi)__W); +} + +#define _mm_mask_alignr_epi8(W, U, A, B, N) \ + ((__m128i)__builtin_ia32_selectb_128((__mmask16)(U), \ + (__v16qi)_mm_alignr_epi8((A), (B), (int)(N)), \ + (__v16qi)(__m128i)(W))) + +#define _mm_maskz_alignr_epi8(U, A, B, N) \ + ((__m128i)__builtin_ia32_selectb_128((__mmask16)(U), \ + (__v16qi)_mm_alignr_epi8((A), (B), (int)(N)), \ + (__v16qi)_mm_setzero_si128())) + +#define _mm256_mask_alignr_epi8(W, U, A, B, N) \ + ((__m256i)__builtin_ia32_selectb_256((__mmask32)(U), \ + (__v32qi)_mm256_alignr_epi8((A), (B), (int)(N)), \ + (__v32qi)(__m256i)(W))) + +#define _mm256_maskz_alignr_epi8(U, A, B, N) \ + ((__m256i)__builtin_ia32_selectb_256((__mmask32)(U), \ + (__v32qi)_mm256_alignr_epi8((A), (B), (int)(N)), \ + (__v32qi)_mm256_setzero_si256())) + +#define _mm_dbsad_epu8(A, B, imm) \ + ((__m128i)__builtin_ia32_dbpsadbw128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(imm))) + +#define _mm_mask_dbsad_epu8(W, U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_dbsad_epu8((A), (B), (imm)), \ + (__v8hi)(__m128i)(W))) + +#define _mm_maskz_dbsad_epu8(U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_dbsad_epu8((A), (B), (imm)), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_dbsad_epu8(A, B, imm) \ + ((__m256i)__builtin_ia32_dbpsadbw256((__v32qi)(__m256i)(A), \ + (__v32qi)(__m256i)(B), (int)(imm))) + +#define _mm256_mask_dbsad_epu8(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_dbsad_epu8((A), (B), (imm)), \ + (__v16hi)(__m256i)(W))) + +#define _mm256_maskz_dbsad_epu8(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_dbsad_epu8((A), (B), (imm)), \ + (__v16hi)_mm256_setzero_si256())) + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_reduce_add_epi16(__m128i __W) { + return __builtin_reduce_add((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_reduce_mul_epi16(__m128i __W) { + return __builtin_reduce_mul((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_reduce_and_epi16(__m128i __W) { + return __builtin_reduce_and((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_reduce_or_epi16(__m128i __W) { + return __builtin_reduce_or((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_add_epi16( __mmask8 __M, __m128i __W) { + __W = _mm_maskz_mov_epi16(__M, __W); + return __builtin_reduce_add((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_mul_epi16( __mmask8 __M, __m128i __W) { + __W = _mm_mask_mov_epi16(_mm_set1_epi16(1), __M, __W); + return __builtin_reduce_mul((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_and_epi16( __mmask8 __M, __m128i __W) { + __W = _mm_mask_mov_epi16(_mm_set1_epi16(-1), __M, __W); + return __builtin_reduce_and((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_or_epi16(__mmask8 __M, __m128i __W) { + __W = _mm_maskz_mov_epi16(__M, __W); + return __builtin_reduce_or((__v8hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_reduce_max_epi16(__m128i __V) { + return __builtin_reduce_max((__v8hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS128 +_mm_reduce_max_epu16(__m128i __V) { + return __builtin_reduce_max((__v8hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_reduce_min_epi16(__m128i __V) { + return __builtin_reduce_min((__v8hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS128 +_mm_reduce_min_epu16(__m128i __V) { + return __builtin_reduce_min((__v8hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_max_epi16(__mmask16 __M, __m128i __V) { + __V = _mm_mask_mov_epi16(_mm_set1_epi16(-32767-1), __M, __V); + return __builtin_reduce_max((__v8hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_max_epu16(__mmask16 __M, __m128i __V) { + __V = _mm_maskz_mov_epi16(__M, __V); + return __builtin_reduce_max((__v8hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_min_epi16(__mmask16 __M, __m128i __V) { + __V = _mm_mask_mov_epi16(_mm_set1_epi16(32767), __M, __V); + return __builtin_reduce_min((__v8hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_min_epu16(__mmask16 __M, __m128i __V) { + __V = _mm_mask_mov_epi16(_mm_set1_epi16(-1), __M, __V); + return __builtin_reduce_min((__v8hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_reduce_add_epi16(__m256i __W) { + return __builtin_reduce_add((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_reduce_mul_epi16(__m256i __W) { + return __builtin_reduce_mul((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_reduce_and_epi16(__m256i __W) { + return __builtin_reduce_and((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_reduce_or_epi16(__m256i __W) { + return __builtin_reduce_or((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_add_epi16( __mmask16 __M, __m256i __W) { + __W = _mm256_maskz_mov_epi16(__M, __W); + return __builtin_reduce_add((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_mul_epi16( __mmask16 __M, __m256i __W) { + __W = _mm256_mask_mov_epi16(_mm256_set1_epi16(1), __M, __W); + return __builtin_reduce_mul((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_and_epi16( __mmask16 __M, __m256i __W) { + __W = _mm256_mask_mov_epi16(_mm256_set1_epi16(-1), __M, __W); + return __builtin_reduce_and((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_or_epi16(__mmask16 __M, __m256i __W) { + __W = _mm256_maskz_mov_epi16(__M, __W); + return __builtin_reduce_or((__v16hi)__W); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_reduce_max_epi16(__m256i __V) { + return __builtin_reduce_max((__v16hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS256 +_mm256_reduce_max_epu16(__m256i __V) { + return __builtin_reduce_max((__v16hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_reduce_min_epi16(__m256i __V) { + return __builtin_reduce_min((__v16hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS256 +_mm256_reduce_min_epu16(__m256i __V) { + return __builtin_reduce_min((__v16hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_max_epi16(__mmask16 __M, __m256i __V) { + __V = _mm256_mask_mov_epi16(_mm256_set1_epi16(-32767-1), __M, __V); + return __builtin_reduce_max((__v16hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_max_epu16(__mmask16 __M, __m256i __V) { + __V = _mm256_maskz_mov_epi16(__M, __V); + return __builtin_reduce_max((__v16hu)__V); +} + +static __inline__ short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_min_epi16(__mmask16 __M, __m256i __V) { + __V = _mm256_mask_mov_epi16(_mm256_set1_epi16(32767), __M, __V); + return __builtin_reduce_min((__v16hi)__V); +} + +static __inline__ unsigned short __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_min_epu16(__mmask16 __M, __m256i __V) { + __V = _mm256_mask_mov_epi16(_mm256_set1_epi16(-1), __M, __V); + return __builtin_reduce_min((__v16hu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_reduce_add_epi8(__m128i __W) { + return __builtin_reduce_add((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_reduce_mul_epi8(__m128i __W) { + return __builtin_reduce_mul((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_reduce_and_epi8(__m128i __W) { + return __builtin_reduce_and((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_reduce_or_epi8(__m128i __W) { + return __builtin_reduce_or((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_add_epi8(__mmask16 __M, __m128i __W) { + __W = _mm_maskz_mov_epi8(__M, __W); + return __builtin_reduce_add((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_mul_epi8(__mmask16 __M, __m128i __W) { + __W = _mm_mask_mov_epi8(_mm_set1_epi8(1), __M, __W); + return __builtin_reduce_mul((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_and_epi8(__mmask16 __M, __m128i __W) { + __W = _mm_mask_mov_epi8(_mm_set1_epi8(-1), __M, __W); + return __builtin_reduce_and((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_or_epi8(__mmask16 __M, __m128i __W) { + __W = _mm_maskz_mov_epi8(__M, __W); + return __builtin_reduce_or((__v16qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_reduce_max_epi8(__m128i __V) { + return __builtin_reduce_max((__v16qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS128 +_mm_reduce_max_epu8(__m128i __V) { + return __builtin_reduce_max((__v16qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_reduce_min_epi8(__m128i __V) { + return __builtin_reduce_min((__v16qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS128 +_mm_reduce_min_epu8(__m128i __V) { + return __builtin_reduce_min((__v16qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_max_epi8(__mmask16 __M, __m128i __V) { + __V = _mm_mask_mov_epi8(_mm_set1_epi8(-127-1), __M, __V); + return __builtin_reduce_max((__v16qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_max_epu8(__mmask16 __M, __m128i __V) { + __V = _mm_maskz_mov_epi8(__M, __V); + return __builtin_reduce_max((__v16qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_min_epi8(__mmask16 __M, __m128i __V) { + __V = _mm_mask_mov_epi8(_mm_set1_epi8(127), __M, __V); + return __builtin_reduce_min((__v16qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS128 +_mm_mask_reduce_min_epu8(__mmask16 __M, __m128i __V) { + __V = _mm_mask_mov_epi8(_mm_set1_epi8(-1), __M, __V); + return __builtin_reduce_min((__v16qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_reduce_add_epi8(__m256i __W) { + return __builtin_reduce_add((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_reduce_mul_epi8(__m256i __W) { + return __builtin_reduce_mul((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_reduce_and_epi8(__m256i __W) { + return __builtin_reduce_and((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_reduce_or_epi8(__m256i __W) { + return __builtin_reduce_or((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_add_epi8(__mmask32 __M, __m256i __W) { + __W = _mm256_maskz_mov_epi8(__M, __W); + return __builtin_reduce_add((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_mul_epi8(__mmask32 __M, __m256i __W) { + __W = _mm256_mask_mov_epi8(_mm256_set1_epi8(1), __M, __W); + return __builtin_reduce_mul((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_and_epi8(__mmask32 __M, __m256i __W) { + __W = _mm256_mask_mov_epi8(_mm256_set1_epi8(-1), __M, __W); + return __builtin_reduce_and((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_or_epi8(__mmask32 __M, __m256i __W) { + __W = _mm256_maskz_mov_epi8(__M, __W); + return __builtin_reduce_or((__v32qs)__W); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_reduce_max_epi8(__m256i __V) { + return __builtin_reduce_max((__v32qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS256 +_mm256_reduce_max_epu8(__m256i __V) { + return __builtin_reduce_max((__v32qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_reduce_min_epi8(__m256i __V) { + return __builtin_reduce_min((__v32qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS256 +_mm256_reduce_min_epu8(__m256i __V) { + return __builtin_reduce_min((__v32qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_max_epi8(__mmask32 __M, __m256i __V) { + __V = _mm256_mask_mov_epi8(_mm256_set1_epi8(-127-1), __M, __V); + return __builtin_reduce_max((__v32qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_max_epu8(__mmask32 __M, __m256i __V) { + __V = _mm256_maskz_mov_epi8(__M, __V); + return __builtin_reduce_max((__v32qu)__V); +} + +static __inline__ signed char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_min_epi8(__mmask32 __M, __m256i __V) { + __V = _mm256_mask_mov_epi8(_mm256_set1_epi8(127), __M, __V); + return __builtin_reduce_min((__v32qs)__V); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS256 +_mm256_mask_reduce_min_epu8(__mmask32 __M, __m256i __V) { + __V = _mm256_mask_mov_epi8(_mm256_set1_epi8(-1), __M, __V); + return __builtin_reduce_min((__v32qu)__V); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __AVX512VLBWINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlcdintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlcdintrin.h new file mode 100755 index 0000000..923e2c5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlcdintrin.h @@ -0,0 +1,230 @@ +/*===---- avx512vlcdintrin.h - AVX512VL and AVX512CD intrinsics ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLCDINTRIN_H +#define __AVX512VLCDINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512cd,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512cd,no-evex512"), \ + __min_vector_width__(256))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcastmb_epi64 (__mmask8 __A) +{ + return (__m128i) _mm_set1_epi64x((long long) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastmb_epi64 (__mmask8 __A) +{ + return (__m256i) _mm256_set1_epi64x((long long)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcastmw_epi32 (__mmask16 __A) +{ + return (__m128i) _mm_set1_epi32((int)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcastmw_epi32 (__mmask16 __A) +{ + return (__m256i) _mm256_set1_epi32((int)__A); +} + + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_conflict_epi64 (__m128i __A) +{ + return (__m128i) __builtin_ia32_vpconflictdi_128 ((__v2di) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_conflict_epi64 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_conflict_epi64(__A), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_conflict_epi64 (__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_conflict_epi64(__A), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_conflict_epi64 (__m256i __A) +{ + return (__m256i) __builtin_ia32_vpconflictdi_256 ((__v4di) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_conflict_epi64 (__m256i __W, __mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_conflict_epi64(__A), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_conflict_epi64 (__mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_conflict_epi64(__A), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_conflict_epi32 (__m128i __A) +{ + return (__m128i) __builtin_ia32_vpconflictsi_128 ((__v4si) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_conflict_epi32 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_conflict_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_conflict_epi32 (__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_conflict_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_conflict_epi32 (__m256i __A) +{ + return (__m256i) __builtin_ia32_vpconflictsi_256 ((__v8si) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_conflict_epi32 (__m256i __W, __mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_conflict_epi32(__A), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_conflict_epi32 (__mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_conflict_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_lzcnt_epi32 (__m128i __A) +{ + return (__m128i) __builtin_ia32_vplzcntd_128 ((__v4si) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_lzcnt_epi32 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_lzcnt_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_lzcnt_epi32 (__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_lzcnt_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_lzcnt_epi32 (__m256i __A) +{ + return (__m256i) __builtin_ia32_vplzcntd_256 ((__v8si) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_lzcnt_epi32 (__m256i __W, __mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_lzcnt_epi32(__A), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_lzcnt_epi32 (__mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_lzcnt_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_lzcnt_epi64 (__m128i __A) +{ + return (__m128i) __builtin_ia32_vplzcntq_128 ((__v2di) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_lzcnt_epi64 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_lzcnt_epi64(__A), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_lzcnt_epi64 (__mmask8 __U, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_lzcnt_epi64(__A), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_lzcnt_epi64 (__m256i __A) +{ + return (__m256i) __builtin_ia32_vplzcntq_256 ((__v4di) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_lzcnt_epi64 (__m256i __W, __mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_lzcnt_epi64(__A), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_lzcnt_epi64 (__mmask8 __U, __m256i __A) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_lzcnt_epi64(__A), + (__v4di)_mm256_setzero_si256()); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __AVX512VLCDINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vldqintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vldqintrin.h new file mode 100755 index 0000000..272cdd8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vldqintrin.h @@ -0,0 +1,1173 @@ +/*===---- avx512vldqintrin.h - AVX512VL and AVX512DQ intrinsics ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLDQINTRIN_H +#define __AVX512VLDQINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512dq,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512dq,no-evex512"), \ + __min_vector_width__(256))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mullo_epi64 (__m256i __A, __m256i __B) { + return (__m256i) ((__v4du) __A * (__v4du) __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mullo_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_mullo_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mullo_epi64(__mmask8 __U, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_mullo_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mullo_epi64 (__m128i __A, __m128i __B) { + return (__m128i) ((__v2du) __A * (__v2du) __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mullo_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_mullo_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mullo_epi64(__mmask8 __U, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_mullo_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_andnot_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_andnot_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_andnot_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_andnot_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_andnot_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_andnot_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_andnot_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_andnot_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_andnot_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_andnot_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_andnot_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_andnot_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_andnot_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_andnot_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_andnot_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_andnot_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_and_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_and_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_and_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_and_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_and_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_and_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_and_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_and_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_and_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_and_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_and_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_and_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_and_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_and_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_and_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_and_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_xor_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_xor_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_xor_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_xor_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_xor_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_xor_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_xor_pd (__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_xor_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_xor_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_xor_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_xor_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_xor_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_xor_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_xor_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_xor_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_xor_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_or_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_or_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_or_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_or_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_or_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_or_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_or_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_or_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_or_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_or_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_or_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_or_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_or_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_or_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_or_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_or_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtpd_epi64 (__m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2qq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtpd_epi64 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2qq128_mask ((__v2df) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpd_epi64 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2qq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtpd_epi64 (__m256d __A) { + return (__m256i) __builtin_ia32_cvtpd2qq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpd_epi64 (__m256i __W, __mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvtpd2qq256_mask ((__v4df) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpd_epi64 (__mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvtpd2qq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtpd_epu64 (__m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2uqq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtpd_epu64 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2uqq128_mask ((__v2df) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpd_epu64 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2uqq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtpd_epu64 (__m256d __A) { + return (__m256i) __builtin_ia32_cvtpd2uqq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpd_epu64 (__m256i __W, __mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvtpd2uqq256_mask ((__v4df) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpd_epu64 (__mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvtpd2uqq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtps_epi64 (__m128 __A) { + return (__m128i) __builtin_ia32_cvtps2qq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtps_epi64 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvtps2qq128_mask ((__v4sf) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtps_epi64 (__mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvtps2qq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtps_epi64 (__m128 __A) { + return (__m256i) __builtin_ia32_cvtps2qq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtps_epi64 (__m256i __W, __mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvtps2qq256_mask ((__v4sf) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtps_epi64 (__mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvtps2qq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtps_epu64 (__m128 __A) { + return (__m128i) __builtin_ia32_cvtps2uqq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtps_epu64 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvtps2uqq128_mask ((__v4sf) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtps_epu64 (__mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvtps2uqq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtps_epu64 (__m128 __A) { + return (__m256i) __builtin_ia32_cvtps2uqq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtps_epu64 (__m256i __W, __mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvtps2uqq256_mask ((__v4sf) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtps_epu64 (__mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvtps2uqq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_cvtepi64_pd (__m128i __A) { + return (__m128d)__builtin_convertvector((__v2di)__A, __v2df); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_pd (__m128d __W, __mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_cvtepi64_pd(__A), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi64_pd (__mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_cvtepi64_pd(__A), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_cvtepi64_pd (__m256i __A) { + return (__m256d)__builtin_convertvector((__v4di)__A, __v4df); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_pd (__m256d __W, __mmask8 __U, __m256i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_cvtepi64_pd(__A), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi64_pd (__mmask8 __U, __m256i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_cvtepi64_pd(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtepi64_ps (__m128i __A) { + return (__m128) __builtin_ia32_cvtqq2ps128_mask ((__v2di) __A, + (__v4sf) _mm_setzero_ps(), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_ps (__m128 __W, __mmask8 __U, __m128i __A) { + return (__m128) __builtin_ia32_cvtqq2ps128_mask ((__v2di) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi64_ps (__mmask8 __U, __m128i __A) { + return (__m128) __builtin_ia32_cvtqq2ps128_mask ((__v2di) __A, + (__v4sf) _mm_setzero_ps(), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_cvtepi64_ps (__m256i __A) { + return (__m128)__builtin_convertvector((__v4di)__A, __v4sf); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_ps (__m128 __W, __mmask8 __U, __m256i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm256_cvtepi64_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi64_ps (__mmask8 __U, __m256i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm256_cvtepi64_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvttpd_epi64 (__m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2qq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttpd_epi64 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2qq128_mask ((__v2df) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttpd_epi64 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2qq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttpd_epi64 (__m256d __A) { + return (__m256i) __builtin_ia32_cvttpd2qq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttpd_epi64 (__m256i __W, __mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvttpd2qq256_mask ((__v4df) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttpd_epi64 (__mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvttpd2qq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvttpd_epu64 (__m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2uqq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttpd_epu64 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2uqq128_mask ((__v2df) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttpd_epu64 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2uqq128_mask ((__v2df) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttpd_epu64 (__m256d __A) { + return (__m256i) __builtin_ia32_cvttpd2uqq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttpd_epu64 (__m256i __W, __mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvttpd2uqq256_mask ((__v4df) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttpd_epu64 (__mmask8 __U, __m256d __A) { + return (__m256i) __builtin_ia32_cvttpd2uqq256_mask ((__v4df) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvttps_epi64 (__m128 __A) { + return (__m128i) __builtin_ia32_cvttps2qq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttps_epi64 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvttps2qq128_mask ((__v4sf) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttps_epi64 (__mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvttps2qq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttps_epi64 (__m128 __A) { + return (__m256i) __builtin_ia32_cvttps2qq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttps_epi64 (__m256i __W, __mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvttps2qq256_mask ((__v4sf) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttps_epi64 (__mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvttps2qq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvttps_epu64 (__m128 __A) { + return (__m128i) __builtin_ia32_cvttps2uqq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttps_epu64 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvttps2uqq128_mask ((__v4sf) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttps_epu64 (__mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvttps2uqq128_mask ((__v4sf) __A, + (__v2di) _mm_setzero_si128(), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttps_epu64 (__m128 __A) { + return (__m256i) __builtin_ia32_cvttps2uqq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttps_epu64 (__m256i __W, __mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvttps2uqq256_mask ((__v4sf) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttps_epu64 (__mmask8 __U, __m128 __A) { + return (__m256i) __builtin_ia32_cvttps2uqq256_mask ((__v4sf) __A, + (__v4di) _mm256_setzero_si256(), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_cvtepu64_pd (__m128i __A) { + return (__m128d)__builtin_convertvector((__v2du)__A, __v2df); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu64_pd (__m128d __W, __mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_cvtepu64_pd(__A), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu64_pd (__mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_cvtepu64_pd(__A), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_cvtepu64_pd (__m256i __A) { + return (__m256d)__builtin_convertvector((__v4du)__A, __v4df); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu64_pd (__m256d __W, __mmask8 __U, __m256i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_cvtepu64_pd(__A), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu64_pd (__mmask8 __U, __m256i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_cvtepu64_pd(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtepu64_ps (__m128i __A) { + return (__m128) __builtin_ia32_cvtuqq2ps128_mask ((__v2di) __A, + (__v4sf) _mm_setzero_ps(), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu64_ps (__m128 __W, __mmask8 __U, __m128i __A) { + return (__m128) __builtin_ia32_cvtuqq2ps128_mask ((__v2di) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu64_ps (__mmask8 __U, __m128i __A) { + return (__m128) __builtin_ia32_cvtuqq2ps128_mask ((__v2di) __A, + (__v4sf) _mm_setzero_ps(), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_cvtepu64_ps (__m256i __A) { + return (__m128)__builtin_convertvector((__v4du)__A, __v4sf); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu64_ps (__m128 __W, __mmask8 __U, __m256i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm256_cvtepu64_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu64_ps (__mmask8 __U, __m256i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm256_cvtepu64_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +#define _mm_range_pd(A, B, C) \ + ((__m128d)__builtin_ia32_rangepd128_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1)) + +#define _mm_mask_range_pd(W, U, A, B, C) \ + ((__m128d)__builtin_ia32_rangepd128_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_range_pd(U, A, B, C) \ + ((__m128d)__builtin_ia32_rangepd128_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), (int)(C), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm256_range_pd(A, B, C) \ + ((__m256d)__builtin_ia32_rangepd256_mask((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), (int)(C), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)-1)) + +#define _mm256_mask_range_pd(W, U, A, B, C) \ + ((__m256d)__builtin_ia32_rangepd256_mask((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), (int)(C), \ + (__v4df)(__m256d)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_range_pd(U, A, B, C) \ + ((__m256d)__builtin_ia32_rangepd256_mask((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), (int)(C), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm_range_ps(A, B, C) \ + ((__m128)__builtin_ia32_rangeps128_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm_mask_range_ps(W, U, A, B, C) \ + ((__m128)__builtin_ia32_rangeps128_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)(__m128)(W), (__mmask8)(U))) + +#define _mm_maskz_range_ps(U, A, B, C) \ + ((__m128)__builtin_ia32_rangeps128_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), (int)(C), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm256_range_ps(A, B, C) \ + ((__m256)__builtin_ia32_rangeps256_mask((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), (int)(C), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm256_mask_range_ps(W, U, A, B, C) \ + ((__m256)__builtin_ia32_rangeps256_mask((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), (int)(C), \ + (__v8sf)(__m256)(W), (__mmask8)(U))) + +#define _mm256_maskz_range_ps(U, A, B, C) \ + ((__m256)__builtin_ia32_rangeps256_mask((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), (int)(C), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm_reduce_pd(A, B) \ + ((__m128d)__builtin_ia32_reducepd128_mask((__v2df)(__m128d)(A), (int)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1)) + +#define _mm_mask_reduce_pd(W, U, A, B) \ + ((__m128d)__builtin_ia32_reducepd128_mask((__v2df)(__m128d)(A), (int)(B), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_reduce_pd(U, A, B) \ + ((__m128d)__builtin_ia32_reducepd128_mask((__v2df)(__m128d)(A), (int)(B), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm256_reduce_pd(A, B) \ + ((__m256d)__builtin_ia32_reducepd256_mask((__v4df)(__m256d)(A), (int)(B), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)-1)) + +#define _mm256_mask_reduce_pd(W, U, A, B) \ + ((__m256d)__builtin_ia32_reducepd256_mask((__v4df)(__m256d)(A), (int)(B), \ + (__v4df)(__m256d)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_reduce_pd(U, A, B) \ + ((__m256d)__builtin_ia32_reducepd256_mask((__v4df)(__m256d)(A), (int)(B), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm_reduce_ps(A, B) \ + ((__m128)__builtin_ia32_reduceps128_mask((__v4sf)(__m128)(A), (int)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm_mask_reduce_ps(W, U, A, B) \ + ((__m128)__builtin_ia32_reduceps128_mask((__v4sf)(__m128)(A), (int)(B), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_reduce_ps(U, A, B) \ + ((__m128)__builtin_ia32_reduceps128_mask((__v4sf)(__m128)(A), (int)(B), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm256_reduce_ps(A, B) \ + ((__m256)__builtin_ia32_reduceps256_mask((__v8sf)(__m256)(A), (int)(B), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm256_mask_reduce_ps(W, U, A, B) \ + ((__m256)__builtin_ia32_reduceps256_mask((__v8sf)(__m256)(A), (int)(B), \ + (__v8sf)(__m256)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_reduce_ps(U, A, B) \ + ((__m256)__builtin_ia32_reduceps256_mask((__v8sf)(__m256)(A), (int)(B), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U))) + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_movepi32_mask (__m128i __A) +{ + return (__mmask8) __builtin_ia32_cvtd2mask128 ((__v4si) __A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_movepi32_mask (__m256i __A) +{ + return (__mmask8) __builtin_ia32_cvtd2mask256 ((__v8si) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_movm_epi32 (__mmask8 __A) +{ + return (__m128i) __builtin_ia32_cvtmask2d128 (__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_movm_epi32 (__mmask8 __A) +{ + return (__m256i) __builtin_ia32_cvtmask2d256 (__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_movm_epi64 (__mmask8 __A) +{ + return (__m128i) __builtin_ia32_cvtmask2q128 (__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_movm_epi64 (__mmask8 __A) +{ + return (__m256i) __builtin_ia32_cvtmask2q256 (__A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_movepi64_mask (__m128i __A) +{ + return (__mmask8) __builtin_ia32_cvtq2mask128 ((__v2di) __A); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_movepi64_mask (__m256i __A) +{ + return (__mmask8) __builtin_ia32_cvtq2mask256 ((__v4di) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_broadcast_f32x2 (__m128 __A) +{ + return (__m256)__builtin_shufflevector((__v4sf)__A, (__v4sf)__A, + 0, 1, 0, 1, 0, 1, 0, 1); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcast_f32x2 (__m256 __O, __mmask8 __M, __m128 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__M, + (__v8sf)_mm256_broadcast_f32x2(__A), + (__v8sf)__O); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcast_f32x2 (__mmask8 __M, __m128 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__M, + (__v8sf)_mm256_broadcast_f32x2(__A), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_broadcast_f64x2(__m128d __A) +{ + return (__m256d)__builtin_shufflevector((__v2df)__A, (__v2df)__A, + 0, 1, 0, 1); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcast_f64x2(__m256d __O, __mmask8 __M, __m128d __A) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__M, + (__v4df)_mm256_broadcast_f64x2(__A), + (__v4df)__O); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcast_f64x2 (__mmask8 __M, __m128d __A) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__M, + (__v4df)_mm256_broadcast_f64x2(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_broadcast_i32x2 (__m128i __A) +{ + return (__m128i)__builtin_shufflevector((__v4si)__A, (__v4si)__A, + 0, 1, 0, 1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_broadcast_i32x2 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_broadcast_i32x2(__A), + (__v4si)__O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_broadcast_i32x2 (__mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_broadcast_i32x2(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcast_i32x2 (__m128i __A) +{ + return (__m256i)__builtin_shufflevector((__v4si)__A, (__v4si)__A, + 0, 1, 0, 1, 0, 1, 0, 1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcast_i32x2 (__m256i __O, __mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_broadcast_i32x2(__A), + (__v8si)__O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcast_i32x2 (__mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_broadcast_i32x2(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcast_i64x2(__m128i __A) +{ + return (__m256i)__builtin_shufflevector((__v2di)__A, (__v2di)__A, + 0, 1, 0, 1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcast_i64x2(__m256i __O, __mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_broadcast_i64x2(__A), + (__v4di)__O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcast_i64x2 (__mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_broadcast_i64x2(__A), + (__v4di)_mm256_setzero_si256()); +} + +#define _mm256_extractf64x2_pd(A, imm) \ + ((__m128d)__builtin_ia32_extractf64x2_256_mask((__v4df)(__m256d)(A), \ + (int)(imm), \ + (__v2df)_mm_undefined_pd(), \ + (__mmask8)-1)) + +#define _mm256_mask_extractf64x2_pd(W, U, A, imm) \ + ((__m128d)__builtin_ia32_extractf64x2_256_mask((__v4df)(__m256d)(A), \ + (int)(imm), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_extractf64x2_pd(U, A, imm) \ + ((__m128d)__builtin_ia32_extractf64x2_256_mask((__v4df)(__m256d)(A), \ + (int)(imm), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm256_extracti64x2_epi64(A, imm) \ + ((__m128i)__builtin_ia32_extracti64x2_256_mask((__v4di)(__m256i)(A), \ + (int)(imm), \ + (__v2di)_mm_undefined_si128(), \ + (__mmask8)-1)) + +#define _mm256_mask_extracti64x2_epi64(W, U, A, imm) \ + ((__m128i)__builtin_ia32_extracti64x2_256_mask((__v4di)(__m256i)(A), \ + (int)(imm), \ + (__v2di)(__m128i)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_extracti64x2_epi64(U, A, imm) \ + ((__m128i)__builtin_ia32_extracti64x2_256_mask((__v4di)(__m256i)(A), \ + (int)(imm), \ + (__v2di)_mm_setzero_si128(), \ + (__mmask8)(U))) + +#define _mm256_insertf64x2(A, B, imm) \ + ((__m256d)__builtin_ia32_insertf64x2_256((__v4df)(__m256d)(A), \ + (__v2df)(__m128d)(B), (int)(imm))) + +#define _mm256_mask_insertf64x2(W, U, A, B, imm) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_insertf64x2((A), (B), (imm)), \ + (__v4df)(__m256d)(W))) + +#define _mm256_maskz_insertf64x2(U, A, B, imm) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_insertf64x2((A), (B), (imm)), \ + (__v4df)_mm256_setzero_pd())) + +#define _mm256_inserti64x2(A, B, imm) \ + ((__m256i)__builtin_ia32_inserti64x2_256((__v4di)(__m256i)(A), \ + (__v2di)(__m128i)(B), (int)(imm))) + +#define _mm256_mask_inserti64x2(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_inserti64x2((A), (B), (imm)), \ + (__v4di)(__m256i)(W))) + +#define _mm256_maskz_inserti64x2(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_inserti64x2((A), (B), (imm)), \ + (__v4di)_mm256_setzero_si256())) + +#define _mm_mask_fpclass_pd_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclasspd128_mask((__v2df)(__m128d)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm_fpclass_pd_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclasspd128_mask((__v2df)(__m128d)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm256_mask_fpclass_pd_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclasspd256_mask((__v4df)(__m256d)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm256_fpclass_pd_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclasspd256_mask((__v4df)(__m256d)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_mask_fpclass_ps_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclassps128_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm_fpclass_ps_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclassps128_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__mmask8)-1)) + +#define _mm256_mask_fpclass_ps_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclassps256_mask((__v8sf)(__m256)(A), (int)(imm), \ + (__mmask8)(U))) + +#define _mm256_fpclass_ps_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclassps256_mask((__v8sf)(__m256)(A), (int)(imm), \ + (__mmask8)-1)) + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlfp16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlfp16intrin.h new file mode 100755 index 0000000..a12acb7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlfp16intrin.h @@ -0,0 +1,2071 @@ +/*===---------- avx512vlfp16intrin.h - AVX512-FP16 intrinsics --------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifdef __SSE2__ + +#ifndef __AVX512VLFP16INTRIN_H +#define __AVX512VLFP16INTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512fp16,avx512vl,no-evex512"), \ + __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512fp16,avx512vl,no-evex512"), \ + __min_vector_width__(128))) + +static __inline__ _Float16 __DEFAULT_FN_ATTRS128 _mm_cvtsh_h(__m128h __a) { + return __a[0]; +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS256 _mm256_cvtsh_h(__m256h __a) { + return __a[0]; +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_set_sh(_Float16 __h) { + return __extension__(__m128h){__h, 0, 0, 0, 0, 0, 0, 0}; +} + +static __inline __m128h __DEFAULT_FN_ATTRS128 _mm_set1_ph(_Float16 __h) { + return (__m128h)(__v8hf){__h, __h, __h, __h, __h, __h, __h, __h}; +} + +static __inline __m256h __DEFAULT_FN_ATTRS256 _mm256_set1_ph(_Float16 __h) { + return (__m256h)(__v16hf){__h, __h, __h, __h, __h, __h, __h, __h, + __h, __h, __h, __h, __h, __h, __h, __h}; +} + +static __inline __m128h __DEFAULT_FN_ATTRS128 +_mm_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, + _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8) { + return (__m128h)(__v8hf){__h8, __h7, __h6, __h5, __h4, __h3, __h2, __h1}; +} + +static __inline __m256h __DEFAULT_FN_ATTRS256 +_mm256_set1_pch(_Float16 _Complex h) { + return (__m256h)_mm256_set1_ps(__builtin_bit_cast(float, h)); +} + +static __inline __m128h __DEFAULT_FN_ATTRS128 +_mm_set1_pch(_Float16 _Complex h) { + return (__m128h)_mm_set1_ps(__builtin_bit_cast(float, h)); +} + +static __inline __m256h __DEFAULT_FN_ATTRS256 +_mm256_set_ph(_Float16 __h1, _Float16 __h2, _Float16 __h3, _Float16 __h4, + _Float16 __h5, _Float16 __h6, _Float16 __h7, _Float16 __h8, + _Float16 __h9, _Float16 __h10, _Float16 __h11, _Float16 __h12, + _Float16 __h13, _Float16 __h14, _Float16 __h15, _Float16 __h16) { + return (__m256h)(__v16hf){__h16, __h15, __h14, __h13, __h12, __h11, + __h10, __h9, __h8, __h7, __h6, __h5, + __h4, __h3, __h2, __h1}; +} + +#define _mm_setr_ph(h1, h2, h3, h4, h5, h6, h7, h8) \ + _mm_set_ph((h8), (h7), (h6), (h5), (h4), (h3), (h2), (h1)) + +#define _mm256_setr_ph(h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11, h12, h13, \ + h14, h15, h16) \ + _mm256_set_ph((h16), (h15), (h14), (h13), (h12), (h11), (h10), (h9), (h8), \ + (h7), (h6), (h5), (h4), (h3), (h2), (h1)) + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_add_ph(__m256h __A, + __m256h __B) { + return (__m256h)((__v16hf)__A + (__v16hf)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_add_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_add_ph(__A, __B), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_add_ph(__A, __B), (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_add_ph(__m128h __A, + __m128h __B) { + return (__m128h)((__v8hf)__A + (__v8hf)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_add_ph(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_add_ph(__A, __B), + (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_add_ph(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_add_ph(__A, __B), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_sub_ph(__m256h __A, + __m256h __B) { + return (__m256h)((__v16hf)__A - (__v16hf)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_sub_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_sub_ph(__A, __B), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_sub_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_sub_ph(__A, __B), (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_sub_ph(__m128h __A, + __m128h __B) { + return (__m128h)((__v8hf)__A - (__v8hf)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_sub_ph(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_sub_ph(__A, __B), + (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_sub_ph(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_sub_ph(__A, __B), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_mul_ph(__m256h __A, + __m256h __B) { + return (__m256h)((__v16hf)__A * (__v16hf)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_mul_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_mul_ph(__A, __B), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_mul_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_mul_ph(__A, __B), (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mul_ph(__m128h __A, + __m128h __B) { + return (__m128h)((__v8hf)__A * (__v8hf)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_mul_ph(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_mul_ph(__A, __B), + (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_mul_ph(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_mul_ph(__A, __B), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_div_ph(__m256h __A, + __m256h __B) { + return (__m256h)((__v16hf)__A / (__v16hf)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_div_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_div_ph(__A, __B), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_div_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + __U, (__v16hf)_mm256_div_ph(__A, __B), (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_div_ph(__m128h __A, + __m128h __B) { + return (__m128h)((__v8hf)__A / (__v8hf)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_div_ph(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_div_ph(__A, __B), + (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_div_ph(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128(__U, (__v8hf)_mm_div_ph(__A, __B), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_min_ph(__m256h __A, + __m256h __B) { + return (__m256h)__builtin_ia32_minph256((__v16hf)__A, (__v16hf)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_min_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + (__v16hf)__builtin_ia32_minph256((__v16hf)__A, (__v16hf)__B), + (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + (__v16hf)__builtin_ia32_minph256((__v16hf)__A, (__v16hf)__B), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_min_ph(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_minph128((__v8hf)__A, (__v8hf)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_min_ph(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)__builtin_ia32_minph128((__v8hf)__A, (__v8hf)__B), + (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_min_ph(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)__builtin_ia32_minph128((__v8hf)__A, (__v8hf)__B), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_max_ph(__m256h __A, + __m256h __B) { + return (__m256h)__builtin_ia32_maxph256((__v16hf)__A, (__v16hf)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_max_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + (__v16hf)__builtin_ia32_maxph256((__v16hf)__A, (__v16hf)__B), + (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + (__v16hf)__builtin_ia32_maxph256((__v16hf)__A, (__v16hf)__B), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_max_ph(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_maxph128((__v8hf)__A, (__v8hf)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_max_ph(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)__builtin_ia32_maxph128((__v8hf)__A, (__v8hf)__B), + (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_max_ph(__mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)__builtin_ia32_maxph128((__v8hf)__A, (__v8hf)__B), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_abs_ph(__m256h __A) { + return (__m256h)_mm256_and_epi32(_mm256_set1_epi32(0x7FFF7FFF), (__m256i)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_abs_ph(__m128h __A) { + return (__m128h)_mm_and_epi32(_mm_set1_epi32(0x7FFF7FFF), (__m128i)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_conj_pch(__m256h __A) { + return (__m256h)_mm256_xor_ps((__m256)__A, _mm256_set1_ps(-0.0f)); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_conj_pch(__m256h __W, __mmask8 __U, __m256h __A) { + return (__m256h)__builtin_ia32_selectps_256( + (__mmask8)__U, (__v8sf)_mm256_conj_pch(__A), (__v8sf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_conj_pch(__mmask8 __U, __m256h __A) { + return (__m256h)__builtin_ia32_selectps_256( + (__mmask8)__U, (__v8sf)_mm256_conj_pch(__A), (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_conj_pch(__m128h __A) { + return (__m128h)_mm_xor_ps((__m128)__A, _mm_set1_ps(-0.0f)); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_conj_pch(__m128h __W, + __mmask8 __U, + __m128h __A) { + return (__m128h)__builtin_ia32_selectps_128( + (__mmask8)__U, (__v4sf)_mm_conj_pch(__A), (__v4sf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_conj_pch(__mmask8 __U, __m128h __A) { + return (__m128h)__builtin_ia32_selectps_128( + (__mmask8)__U, (__v4sf)_mm_conj_pch(__A), (__v4sf)_mm_setzero_ps()); +} + +#define _mm256_cmp_ph_mask(a, b, p) \ + ((__mmask16)__builtin_ia32_cmpph256_mask( \ + (__v16hf)(__m256h)(a), (__v16hf)(__m256h)(b), (int)(p), (__mmask16)-1)) + +#define _mm256_mask_cmp_ph_mask(m, a, b, p) \ + ((__mmask16)__builtin_ia32_cmpph256_mask( \ + (__v16hf)(__m256h)(a), (__v16hf)(__m256h)(b), (int)(p), (__mmask16)(m))) + +#define _mm_cmp_ph_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpph128_mask( \ + (__v8hf)(__m128h)(a), (__v8hf)(__m128h)(b), (int)(p), (__mmask8)-1)) + +#define _mm_mask_cmp_ph_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpph128_mask( \ + (__v8hf)(__m128h)(a), (__v8hf)(__m128h)(b), (int)(p), (__mmask8)(m))) + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_rcp_ph(__m256h __A) { + return (__m256h)__builtin_ia32_rcpph256_mask( + (__v16hf)__A, (__v16hf)_mm256_undefined_ph(), (__mmask16)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_rcp_ph(__m256h __W, __mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_rcpph256_mask((__v16hf)__A, (__v16hf)__W, + (__mmask16)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_rcp_ph(__mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_rcpph256_mask( + (__v16hf)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_rcp_ph(__m128h __A) { + return (__m128h)__builtin_ia32_rcpph128_mask( + (__v8hf)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_rcp_ph(__m128h __W, + __mmask8 __U, + __m128h __A) { + return (__m128h)__builtin_ia32_rcpph128_mask((__v8hf)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_rcp_ph(__mmask8 __U, + __m128h __A) { + return (__m128h)__builtin_ia32_rcpph128_mask( + (__v8hf)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_rsqrt_ph(__m256h __A) { + return (__m256h)__builtin_ia32_rsqrtph256_mask( + (__v16hf)__A, (__v16hf)_mm256_undefined_ph(), (__mmask16)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_rsqrt_ph(__m256h __W, __mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_rsqrtph256_mask((__v16hf)__A, (__v16hf)__W, + (__mmask16)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_rsqrt_ph(__mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_rsqrtph256_mask( + (__v16hf)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_rsqrt_ph(__m128h __A) { + return (__m128h)__builtin_ia32_rsqrtph128_mask( + (__v8hf)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_rsqrt_ph(__m128h __W, + __mmask8 __U, + __m128h __A) { + return (__m128h)__builtin_ia32_rsqrtph128_mask((__v8hf)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt_ph(__mmask8 __U, __m128h __A) { + return (__m128h)__builtin_ia32_rsqrtph128_mask( + (__v8hf)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_getexp_ph(__m128h __A) { + return (__m128h)__builtin_ia32_getexpph128_mask( + (__v8hf)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_ph(__m128h __W, __mmask8 __U, __m128h __A) { + return (__m128h)__builtin_ia32_getexpph128_mask((__v8hf)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_ph(__mmask8 __U, __m128h __A) { + return (__m128h)__builtin_ia32_getexpph128_mask( + (__v8hf)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_getexp_ph(__m256h __A) { + return (__m256h)__builtin_ia32_getexpph256_mask( + (__v16hf)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_getexp_ph(__m256h __W, __mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_getexpph256_mask((__v16hf)__A, (__v16hf)__W, + (__mmask16)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_getexp_ph(__mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_getexpph256_mask( + (__v16hf)__A, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U); +} + +#define _mm_getmant_ph(A, B, C) \ + ((__m128h)__builtin_ia32_getmantph128_mask( \ + (__v8hf)(__m128h)(A), (int)(((C) << 2) | (B)), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1)) + +#define _mm_mask_getmant_ph(W, U, A, B, C) \ + ((__m128h)__builtin_ia32_getmantph128_mask( \ + (__v8hf)(__m128h)(A), (int)(((C) << 2) | (B)), (__v8hf)(__m128h)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_getmant_ph(U, A, B, C) \ + ((__m128h)__builtin_ia32_getmantph128_mask( \ + (__v8hf)(__m128h)(A), (int)(((C) << 2) | (B)), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U))) + +#define _mm256_getmant_ph(A, B, C) \ + ((__m256h)__builtin_ia32_getmantph256_mask( \ + (__v16hf)(__m256h)(A), (int)(((C) << 2) | (B)), \ + (__v16hf)_mm256_setzero_ph(), (__mmask16)-1)) + +#define _mm256_mask_getmant_ph(W, U, A, B, C) \ + ((__m256h)__builtin_ia32_getmantph256_mask( \ + (__v16hf)(__m256h)(A), (int)(((C) << 2) | (B)), (__v16hf)(__m256h)(W), \ + (__mmask16)(U))) + +#define _mm256_maskz_getmant_ph(U, A, B, C) \ + ((__m256h)__builtin_ia32_getmantph256_mask( \ + (__v16hf)(__m256h)(A), (int)(((C) << 2) | (B)), \ + (__v16hf)_mm256_setzero_ph(), (__mmask16)(U))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_scalef_ph(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_scalefph128_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_ph(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_scalefph128_mask((__v8hf)__A, (__v8hf)__B, + (__v8hf)__W, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_ph(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_scalefph128_mask( + (__v8hf)__A, (__v8hf)__B, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_scalef_ph(__m256h __A, + __m256h __B) { + return (__m256h)__builtin_ia32_scalefph256_mask( + (__v16hf)__A, (__v16hf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_scalef_ph(__m256h __W, __mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_scalefph256_mask((__v16hf)__A, (__v16hf)__B, + (__v16hf)__W, (__mmask16)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_scalef_ph(__mmask16 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_scalefph256_mask( + (__v16hf)__A, (__v16hf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U); +} + +#define _mm_roundscale_ph(A, imm) \ + ((__m128h)__builtin_ia32_rndscaleph_128_mask( \ + (__v8hf)(__m128h)(A), (int)(imm), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1)) + +#define _mm_mask_roundscale_ph(W, U, A, imm) \ + ((__m128h)__builtin_ia32_rndscaleph_128_mask( \ + (__v8hf)(__m128h)(A), (int)(imm), (__v8hf)(__m128h)(W), (__mmask8)(U))) + +#define _mm_maskz_roundscale_ph(U, A, imm) \ + ((__m128h)__builtin_ia32_rndscaleph_128_mask( \ + (__v8hf)(__m128h)(A), (int)(imm), (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U))) + +#define _mm256_roundscale_ph(A, imm) \ + ((__m256h)__builtin_ia32_rndscaleph_256_mask( \ + (__v16hf)(__m256h)(A), (int)(imm), (__v16hf)_mm256_setzero_ph(), \ + (__mmask16)-1)) + +#define _mm256_mask_roundscale_ph(W, U, A, imm) \ + ((__m256h)__builtin_ia32_rndscaleph_256_mask( \ + (__v16hf)(__m256h)(A), (int)(imm), (__v16hf)(__m256h)(W), \ + (__mmask16)(U))) + +#define _mm256_maskz_roundscale_ph(U, A, imm) \ + ((__m256h)__builtin_ia32_rndscaleph_256_mask( \ + (__v16hf)(__m256h)(A), (int)(imm), (__v16hf)_mm256_setzero_ph(), \ + (__mmask16)(U))) + +#define _mm_reduce_ph(A, imm) \ + ((__m128h)__builtin_ia32_reduceph128_mask((__v8hf)(__m128h)(A), (int)(imm), \ + (__v8hf)_mm_setzero_ph(), \ + (__mmask8)-1)) + +#define _mm_mask_reduce_ph(W, U, A, imm) \ + ((__m128h)__builtin_ia32_reduceph128_mask( \ + (__v8hf)(__m128h)(A), (int)(imm), (__v8hf)(__m128h)(W), (__mmask8)(U))) + +#define _mm_maskz_reduce_ph(U, A, imm) \ + ((__m128h)__builtin_ia32_reduceph128_mask((__v8hf)(__m128h)(A), (int)(imm), \ + (__v8hf)_mm_setzero_ph(), \ + (__mmask8)(U))) + +#define _mm256_reduce_ph(A, imm) \ + ((__m256h)__builtin_ia32_reduceph256_mask((__v16hf)(__m256h)(A), (int)(imm), \ + (__v16hf)_mm256_setzero_ph(), \ + (__mmask16)-1)) + +#define _mm256_mask_reduce_ph(W, U, A, imm) \ + ((__m256h)__builtin_ia32_reduceph256_mask((__v16hf)(__m256h)(A), (int)(imm), \ + (__v16hf)(__m256h)(W), \ + (__mmask16)(U))) + +#define _mm256_maskz_reduce_ph(U, A, imm) \ + ((__m256h)__builtin_ia32_reduceph256_mask((__v16hf)(__m256h)(A), (int)(imm), \ + (__v16hf)_mm256_setzero_ph(), \ + (__mmask16)(U))) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_sqrt_ph(__m128h __a) { + return __builtin_ia32_sqrtph((__v8hf)__a); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_sqrt_ph(__m128h __W, + __mmask8 __U, + __m128h __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm_sqrt_ph(__A), (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_maskz_sqrt_ph(__mmask8 __U, + __m128h __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm_sqrt_ph(__A), (__v8hf)_mm_setzero_ph()); +} + +static __inline __m256h __DEFAULT_FN_ATTRS256 _mm256_sqrt_ph(__m256h __a) { + return (__m256h)__builtin_ia32_sqrtph256((__v16hf)__a); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_sqrt_ph(__m256h __W, __mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, (__v16hf)_mm256_sqrt_ph(__A), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_sqrt_ph(__mmask16 __U, __m256h __A) { + return (__m256h)__builtin_ia32_selectph_256((__mmask16)__U, + (__v16hf)_mm256_sqrt_ph(__A), + (__v16hf)_mm256_setzero_ph()); +} + +#define _mm_mask_fpclass_ph_mask(U, A, imm) \ + ((__mmask8)__builtin_ia32_fpclassph128_mask((__v8hf)(__m128h)(A), \ + (int)(imm), (__mmask8)(U))) + +#define _mm_fpclass_ph_mask(A, imm) \ + ((__mmask8)__builtin_ia32_fpclassph128_mask((__v8hf)(__m128h)(A), \ + (int)(imm), (__mmask8)-1)) + +#define _mm256_mask_fpclass_ph_mask(U, A, imm) \ + ((__mmask16)__builtin_ia32_fpclassph256_mask((__v16hf)(__m256h)(A), \ + (int)(imm), (__mmask16)(U))) + +#define _mm256_fpclass_ph_mask(A, imm) \ + ((__mmask16)__builtin_ia32_fpclassph256_mask((__v16hf)(__m256h)(A), \ + (int)(imm), (__mmask16)-1)) + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtpd_ph(__m128d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph128_mask( + (__v2df)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvtpd_ph(__m128h __W, + __mmask8 __U, + __m128d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph128_mask((__v2df)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpd_ph(__mmask8 __U, __m128d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph128_mask( + (__v2df)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 _mm256_cvtpd_ph(__m256d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph256_mask( + (__v4df)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpd_ph(__m128h __W, __mmask8 __U, __m256d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph256_mask((__v4df)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpd_ph(__mmask8 __U, __m256d __A) { + return (__m128h)__builtin_ia32_vcvtpd2ph256_mask( + (__v4df)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 _mm_cvtph_pd(__m128h __A) { + return (__m128d)__builtin_ia32_vcvtph2pd128_mask( + (__v8hf)__A, (__v2df)_mm_undefined_pd(), (__mmask8)-1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 _mm_mask_cvtph_pd(__m128d __W, + __mmask8 __U, + __m128h __A) { + return (__m128d)__builtin_ia32_vcvtph2pd128_mask((__v8hf)__A, (__v2df)__W, + (__mmask8)__U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_pd(__mmask8 __U, __m128h __A) { + return (__m128d)__builtin_ia32_vcvtph2pd128_mask( + (__v8hf)__A, (__v2df)_mm_setzero_pd(), (__mmask8)__U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 _mm256_cvtph_pd(__m128h __A) { + return (__m256d)__builtin_ia32_vcvtph2pd256_mask( + (__v8hf)__A, (__v4df)_mm256_undefined_pd(), (__mmask8)-1); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_pd(__m256d __W, __mmask8 __U, __m128h __A) { + return (__m256d)__builtin_ia32_vcvtph2pd256_mask((__v8hf)__A, (__v4df)__W, + (__mmask8)__U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_pd(__mmask8 __U, __m128h __A) { + return (__m256d)__builtin_ia32_vcvtph2pd256_mask( + (__v8hf)__A, (__v4df)_mm256_setzero_pd(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_epi16(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2w128_mask( + (__v8hf)__A, (__v8hi)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_epi16(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2w128_mask((__v8hf)__A, (__v8hi)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_epi16(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2w128_mask( + (__v8hf)__A, (__v8hi)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_epi16(__m256h __A) { + return (__m256i)__builtin_ia32_vcvtph2w256_mask( + (__v16hf)__A, (__v16hi)_mm256_undefined_si256(), (__mmask16)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_epi16(__m256i __W, __mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvtph2w256_mask((__v16hf)__A, (__v16hi)__W, + (__mmask16)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_epi16(__mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvtph2w256_mask( + (__v16hf)__A, (__v16hi)_mm256_setzero_si256(), (__mmask16)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvttph_epi16(__m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2w128_mask( + (__v8hf)__A, (__v8hi)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttph_epi16(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2w128_mask((__v8hf)__A, (__v8hi)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttph_epi16(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2w128_mask( + (__v8hf)__A, (__v8hi)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttph_epi16(__m256h __A) { + return (__m256i)__builtin_ia32_vcvttph2w256_mask( + (__v16hf)__A, (__v16hi)_mm256_undefined_si256(), (__mmask16)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttph_epi16(__m256i __W, __mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvttph2w256_mask((__v16hf)__A, (__v16hi)__W, + (__mmask16)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttph_epi16(__mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvttph2w256_mask( + (__v16hf)__A, (__v16hi)_mm256_setzero_si256(), (__mmask16)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtepi16_ph(__m128i __A) { + return (__m128h) __builtin_convertvector((__v8hi)__A, __v8hf); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi16_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm_cvtepi16_ph(__A), (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi16_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm_cvtepi16_ph(__A), (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_cvtepi16_ph(__m256i __A) { + return (__m256h) __builtin_convertvector((__v16hi)__A, __v16hf); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi16_ph(__m256h __W, __mmask16 __U, __m256i __A) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, (__v16hf)_mm256_cvtepi16_ph(__A), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi16_ph(__mmask16 __U, __m256i __A) { + return (__m256h)__builtin_ia32_selectph_256((__mmask16)__U, + (__v16hf)_mm256_cvtepi16_ph(__A), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_epu16(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2uw128_mask( + (__v8hf)__A, (__v8hu)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_epu16(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2uw128_mask((__v8hf)__A, (__v8hu)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_epu16(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2uw128_mask( + (__v8hf)__A, (__v8hu)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_epu16(__m256h __A) { + return (__m256i)__builtin_ia32_vcvtph2uw256_mask( + (__v16hf)__A, (__v16hu)_mm256_undefined_si256(), (__mmask16)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_epu16(__m256i __W, __mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvtph2uw256_mask((__v16hf)__A, (__v16hu)__W, + (__mmask16)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_epu16(__mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvtph2uw256_mask( + (__v16hf)__A, (__v16hu)_mm256_setzero_si256(), (__mmask16)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvttph_epu16(__m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2uw128_mask( + (__v8hf)__A, (__v8hu)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttph_epu16(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2uw128_mask((__v8hf)__A, (__v8hu)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttph_epu16(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2uw128_mask( + (__v8hf)__A, (__v8hu)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttph_epu16(__m256h __A) { + return (__m256i)__builtin_ia32_vcvttph2uw256_mask( + (__v16hf)__A, (__v16hu)_mm256_undefined_si256(), (__mmask16)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttph_epu16(__m256i __W, __mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvttph2uw256_mask((__v16hf)__A, (__v16hu)__W, + (__mmask16)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttph_epu16(__mmask16 __U, __m256h __A) { + return (__m256i)__builtin_ia32_vcvttph2uw256_mask( + (__v16hf)__A, (__v16hu)_mm256_setzero_si256(), (__mmask16)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtepu16_ph(__m128i __A) { + return (__m128h) __builtin_convertvector((__v8hu)__A, __v8hf); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu16_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm_cvtepu16_ph(__A), (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu16_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm_cvtepu16_ph(__A), (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_cvtepu16_ph(__m256i __A) { + return (__m256h) __builtin_convertvector((__v16hu)__A, __v16hf); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu16_ph(__m256h __W, __mmask16 __U, __m256i __A) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, (__v16hf)_mm256_cvtepu16_ph(__A), (__v16hf)__W); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu16_ph(__mmask16 __U, __m256i __A) { + return (__m256h)__builtin_ia32_selectph_256((__mmask16)__U, + (__v16hf)_mm256_cvtepu16_ph(__A), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_epi32(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2dq128_mask( + (__v8hf)__A, (__v4si)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_epi32(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2dq128_mask((__v8hf)__A, (__v4si)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_epi32(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2dq128_mask( + (__v8hf)__A, (__v4si)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_epi32(__m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2dq256_mask( + (__v8hf)__A, (__v8si)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_epi32(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2dq256_mask((__v8hf)__A, (__v8si)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_epi32(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2dq256_mask( + (__v8hf)__A, (__v8si)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_epu32(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2udq128_mask( + (__v8hf)__A, (__v4su)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_epu32(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2udq128_mask((__v8hf)__A, (__v4su)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_epu32(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2udq128_mask( + (__v8hf)__A, (__v4su)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_epu32(__m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2udq256_mask( + (__v8hf)__A, (__v8su)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_epu32(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2udq256_mask((__v8hf)__A, (__v8su)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_epu32(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2udq256_mask( + (__v8hf)__A, (__v8su)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtepi32_ph(__m128i __A) { + return (__m128h)__builtin_ia32_vcvtdq2ph128_mask( + (__v4si)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtdq2ph128_mask((__v4si)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi32_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtdq2ph128_mask( + (__v4si)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_cvtepi32_ph(__m256i __A) { + return (__m128h) __builtin_convertvector((__v8si)__A, __v8hf); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_ph(__m128h __W, __mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm256_cvtepi32_ph(__A), (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi32_ph(__mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm256_cvtepi32_ph(__A), (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtepu32_ph(__m128i __A) { + return (__m128h)__builtin_ia32_vcvtudq2ph128_mask( + (__v4su)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu32_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtudq2ph128_mask((__v4su)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu32_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtudq2ph128_mask( + (__v4su)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_cvtepu32_ph(__m256i __A) { + return (__m128h) __builtin_convertvector((__v8su)__A, __v8hf); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu32_ph(__m128h __W, __mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm256_cvtepu32_ph(__A), (__v8hf)__W); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu32_ph(__mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, (__v8hf)_mm256_cvtepu32_ph(__A), (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvttph_epi32(__m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2dq128_mask( + (__v8hf)__A, (__v4si)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttph_epi32(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2dq128_mask((__v8hf)__A, (__v4si)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttph_epi32(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2dq128_mask( + (__v8hf)__A, (__v4si)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttph_epi32(__m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2dq256_mask( + (__v8hf)__A, (__v8si)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttph_epi32(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2dq256_mask((__v8hf)__A, (__v8si)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttph_epi32(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2dq256_mask( + (__v8hf)__A, (__v8si)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvttph_epu32(__m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2udq128_mask( + (__v8hf)__A, (__v4su)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttph_epu32(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2udq128_mask((__v8hf)__A, (__v4su)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttph_epu32(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2udq128_mask( + (__v8hf)__A, (__v4su)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttph_epu32(__m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2udq256_mask( + (__v8hf)__A, (__v8su)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttph_epu32(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2udq256_mask((__v8hf)__A, (__v8su)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttph_epu32(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2udq256_mask( + (__v8hf)__A, (__v8su)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtepi64_ph(__m128i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph128_mask( + (__v2di)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph128_mask((__v2di)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi64_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph128_mask( + (__v2di)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_cvtepi64_ph(__m256i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph256_mask( + (__v4di)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_ph(__m128h __W, __mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph256_mask((__v4di)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi64_ph(__mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_vcvtqq2ph256_mask( + (__v4di)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_epi64(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2qq128_mask( + (__v8hf)__A, (__v2di)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_epi64(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2qq128_mask((__v8hf)__A, (__v2di)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_epi64(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2qq128_mask( + (__v8hf)__A, (__v2di)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_epi64(__m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2qq256_mask( + (__v8hf)__A, (__v4di)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_epi64(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2qq256_mask((__v8hf)__A, (__v4di)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_epi64(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2qq256_mask( + (__v8hf)__A, (__v4di)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtepu64_ph(__m128i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph128_mask( + (__v2du)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu64_ph(__m128h __W, __mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph128_mask((__v2du)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu64_ph(__mmask8 __U, __m128i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph128_mask( + (__v2du)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_cvtepu64_ph(__m256i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph256_mask( + (__v4du)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu64_ph(__m128h __W, __mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph256_mask((__v4du)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu64_ph(__mmask8 __U, __m256i __A) { + return (__m128h)__builtin_ia32_vcvtuqq2ph256_mask( + (__v4du)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvtph_epu64(__m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2uqq128_mask( + (__v8hf)__A, (__v2du)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_epu64(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2uqq128_mask((__v8hf)__A, (__v2du)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_epu64(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvtph2uqq128_mask( + (__v8hf)__A, (__v2du)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtph_epu64(__m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2uqq256_mask( + (__v8hf)__A, (__v4du)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_epu64(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2uqq256_mask((__v8hf)__A, (__v4du)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_epu64(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvtph2uqq256_mask( + (__v8hf)__A, (__v4du)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvttph_epi64(__m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2qq128_mask( + (__v8hf)__A, (__v2di)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttph_epi64(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2qq128_mask((__v8hf)__A, (__v2di)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttph_epi64(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2qq128_mask( + (__v8hf)__A, (__v2di)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttph_epi64(__m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2qq256_mask( + (__v8hf)__A, (__v4di)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttph_epi64(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2qq256_mask((__v8hf)__A, (__v4di)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttph_epi64(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2qq256_mask( + (__v8hf)__A, (__v4di)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_cvttph_epu64(__m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2uqq128_mask( + (__v8hf)__A, (__v2du)_mm_undefined_si128(), (__mmask8)-1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttph_epu64(__m128i __W, __mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2uqq128_mask((__v8hf)__A, (__v2du)__W, + (__mmask8)__U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttph_epu64(__mmask8 __U, __m128h __A) { + return (__m128i)__builtin_ia32_vcvttph2uqq128_mask( + (__v8hf)__A, (__v2du)_mm_setzero_si128(), (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttph_epu64(__m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2uqq256_mask( + (__v8hf)__A, (__v4du)_mm256_undefined_si256(), (__mmask8)-1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttph_epu64(__m256i __W, __mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2uqq256_mask((__v8hf)__A, (__v4du)__W, + (__mmask8)__U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttph_epu64(__mmask8 __U, __m128h __A) { + return (__m256i)__builtin_ia32_vcvttph2uqq256_mask( + (__v8hf)__A, (__v4du)_mm256_setzero_si256(), (__mmask8)__U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtxph_ps(__m128h __A) { + return (__m128)__builtin_ia32_vcvtph2psx128_mask( + (__v8hf)__A, (__v4sf)_mm_undefined_ps(), (__mmask8)-1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_mask_cvtxph_ps(__m128 __W, + __mmask8 __U, + __m128h __A) { + return (__m128)__builtin_ia32_vcvtph2psx128_mask((__v8hf)__A, (__v4sf)__W, + (__mmask8)__U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtxph_ps(__mmask8 __U, __m128h __A) { + return (__m128)__builtin_ia32_vcvtph2psx128_mask( + (__v8hf)__A, (__v4sf)_mm_setzero_ps(), (__mmask8)__U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_cvtxph_ps(__m128h __A) { + return (__m256)__builtin_ia32_vcvtph2psx256_mask( + (__v8hf)__A, (__v8sf)_mm256_undefined_ps(), (__mmask8)-1); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtxph_ps(__m256 __W, __mmask8 __U, __m128h __A) { + return (__m256)__builtin_ia32_vcvtph2psx256_mask((__v8hf)__A, (__v8sf)__W, + (__mmask8)__U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtxph_ps(__mmask8 __U, __m128h __A) { + return (__m256)__builtin_ia32_vcvtph2psx256_mask( + (__v8hf)__A, (__v8sf)_mm256_setzero_ps(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_cvtxps_ph(__m128 __A) { + return (__m128h)__builtin_ia32_vcvtps2phx128_mask( + (__v4sf)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_cvtxps_ph(__m128h __W, + __mmask8 __U, + __m128 __A) { + return (__m128h)__builtin_ia32_vcvtps2phx128_mask((__v4sf)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtxps_ph(__mmask8 __U, __m128 __A) { + return (__m128h)__builtin_ia32_vcvtps2phx128_mask( + (__v4sf)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 _mm256_cvtxps_ph(__m256 __A) { + return (__m128h)__builtin_ia32_vcvtps2phx256_mask( + (__v8sf)__A, (__v8hf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtxps_ph(__m128h __W, __mmask8 __U, __m256 __A) { + return (__m128h)__builtin_ia32_vcvtps2phx256_mask((__v8sf)__A, (__v8hf)__W, + (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtxps_ph(__mmask8 __U, __m256 __A) { + return (__m128h)__builtin_ia32_vcvtps2phx256_mask( + (__v8sf)__A, (__v8hf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmadd_ph(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddph((__v8hf)__A, (__v8hf)__B, + (__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_fmadd_ph(__m128h __A, + __mmask8 __U, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_ph(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_ph(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmsub_ph(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddph((__v8hf)__A, (__v8hf)__B, + -(__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_fmsub_ph(__m128h __A, + __mmask8 __U, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, _mm_fmsub_ph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_ph(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, _mm_fmsub_ph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_ph(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph(-(__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_ph(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph(-(__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_ph(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph(-(__v8hf)__A, (__v8hf)__B, -(__v8hf)__C), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fmadd_ph(__m256h __A, + __m256h __B, + __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, + (__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fmadd_ph(__m256h __A, __mmask16 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmadd_ph(__m256h __A, __m256h __B, __m256h __C, __mmask16 __U) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmadd_ph(__mmask16 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fmsub_ph(__m256h __A, + __m256h __B, + __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, + -(__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsub_ph(__m256h __A, __mmask16 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmsub_ph(__mmask16 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fnmadd_ph(__m256h __A, __m256h __B, __m256h __C, __mmask16 __U) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256(-(__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fnmadd_ph(__mmask16 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256(-(__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fnmsub_ph(__mmask16 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256(-(__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmaddsub_ph(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, + (__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fmaddsub_ph(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmaddsub_ph(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmaddsub_ph(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, (__v8hf)__C), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmsubadd_ph(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, + -(__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fmsubadd_ph(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, -(__v8hf)__C), + (__v8hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsubadd_ph(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, -(__v8hf)__C), + (__v8hf)_mm_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_fmaddsub_ph(__m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, + (__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fmaddsub_ph(__m256h __A, __mmask16 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmaddsub_ph(__m256h __A, __m256h __B, __m256h __C, __mmask16 __U) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmaddsub_ph(__mmask16 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, (__v16hf)__C), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_fmsubadd_ph(__m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, + -(__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsubadd_ph(__m256h __A, __mmask16 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmsubadd_ph(__mmask16 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)_mm256_setzero_ph()); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_ph(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, (__v8hf)__B, -(__v8hf)__C), + (__v8hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmsub_ph(__m256h __A, __m256h __B, __m256h __C, __mmask16 __U) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsubadd_ph(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddsubph((__v8hf)__A, (__v8hf)__B, -(__v8hf)__C), + (__v8hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmsubadd_ph(__m256h __A, __m256h __B, __m256h __C, __mmask16 __U) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddsubph256((__v16hf)__A, (__v16hf)__B, -(__v16hf)__C), + (__v16hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fnmadd_ph(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddph((__v8hf)__A, -(__v8hf)__B, + (__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_ph(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, -(__v8hf)__B, (__v8hf)__C), + (__v8hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fnmadd_ph(__m256h __A, + __m256h __B, + __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddph256((__v16hf)__A, -(__v16hf)__B, + (__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fnmadd_ph(__m256h __A, __mmask16 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, -(__v16hf)__B, (__v16hf)__C), + (__v16hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fnmsub_ph(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddph((__v8hf)__A, -(__v8hf)__B, + -(__v8hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_ph(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, -(__v8hf)__B, -(__v8hf)__C), + (__v8hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_ph(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_selectph_128( + (__mmask8)__U, + __builtin_ia32_vfmaddph((__v8hf)__A, -(__v8hf)__B, -(__v8hf)__C), + (__v8hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fnmsub_ph(__m256h __A, + __m256h __B, + __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddph256((__v16hf)__A, -(__v16hf)__B, + -(__v16hf)__C); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fnmsub_ph(__m256h __A, __mmask16 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, -(__v16hf)__B, -(__v16hf)__C), + (__v16hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fnmsub_ph(__m256h __A, __m256h __B, __m256h __C, __mmask16 __U) { + return (__m256h)__builtin_ia32_selectph_256( + (__mmask16)__U, + __builtin_ia32_vfmaddph256((__v16hf)__A, -(__v16hf)__B, -(__v16hf)__C), + (__v16hf)__C); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fcmul_pch(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfcmulcph128_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fcmul_pch(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_vfcmulcph128_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__W, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fcmul_pch(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_vfcmulcph128_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS128 _mm256_fcmul_pch(__m256h __A, + __m256h __B) { + return (__m256h)__builtin_ia32_vfcmulcph256_mask( + (__v8sf)__A, (__v8sf)__B, (__v8sf)_mm256_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fcmul_pch(__m256h __W, __mmask8 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_vfcmulcph256_mask((__v8sf)__A, (__v8sf)__B, + (__v8sf)__W, (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fcmul_pch(__mmask8 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_vfcmulcph256_mask( + (__v8sf)__A, (__v8sf)__B, (__v8sf)_mm256_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fcmadd_pch(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfcmaddcph128_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fcmadd_pch(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectps_128( + __U, + __builtin_ia32_vfcmaddcph128_mask((__v4sf)__A, (__v4sf)(__m128h)__B, + (__v4sf)__C, (__mmask8)__U), + (__v4sf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fcmadd_pch(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_vfcmaddcph128_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fcmadd_pch(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfcmaddcph128_maskz( + (__v4sf)__A, (__v4sf)__B, (__v4sf)__C, (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fcmadd_pch(__m256h __A, + __m256h __B, + __m256h __C) { + return (__m256h)__builtin_ia32_vfcmaddcph256_mask((__v8sf)__A, (__v8sf)__B, + (__v8sf)__C, (__mmask8)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fcmadd_pch(__m256h __A, __mmask8 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectps_256( + __U, + __builtin_ia32_vfcmaddcph256_mask((__v8sf)__A, (__v8sf)__B, (__v8sf)__C, + (__mmask8)__U), + (__v8sf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fcmadd_pch(__m256h __A, __m256h __B, __m256h __C, __mmask8 __U) { + return (__m256h)__builtin_ia32_vfcmaddcph256_mask((__v8sf)__A, (__v8sf)__B, + (__v8sf)__C, (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fcmadd_pch(__mmask8 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_vfcmaddcph256_maskz( + (__v8sf)__A, (__v8sf)__B, (__v8sf)__C, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmul_pch(__m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfmulcph128_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_fmul_pch(__m128h __W, + __mmask8 __U, + __m128h __A, + __m128h __B) { + return (__m128h)__builtin_ia32_vfmulcph128_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__W, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmul_pch(__mmask8 __U, __m128h __A, __m128h __B) { + return (__m128h)__builtin_ia32_vfmulcph128_mask( + (__v4sf)__A, (__v4sf)__B, (__v4sf)_mm_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fmul_pch(__m256h __A, + __m256h __B) { + return (__m256h)__builtin_ia32_vfmulcph256_mask( + (__v8sf)__A, (__v8sf)__B, (__v8sf)_mm256_undefined_ph(), (__mmask8)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fmul_pch(__m256h __W, __mmask8 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_vfmulcph256_mask((__v8sf)__A, (__v8sf)__B, + (__v8sf)__W, (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmul_pch(__mmask8 __U, __m256h __A, __m256h __B) { + return (__m256h)__builtin_ia32_vfmulcph256_mask( + (__v8sf)__A, (__v8sf)__B, (__v8sf)_mm256_setzero_ph(), (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_fmadd_pch(__m128h __A, + __m128h __B, + __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddcph128_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)-1); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_pch(__m128h __A, __mmask8 __U, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_selectps_128( + __U, + __builtin_ia32_vfmaddcph128_mask((__v4sf)__A, (__v4sf)__B, (__v4sf)__C, + (__mmask8)__U), + (__v4sf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_pch(__m128h __A, __m128h __B, __m128h __C, __mmask8 __U) { + return (__m128h)__builtin_ia32_vfmaddcph128_mask((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_pch(__mmask8 __U, __m128h __A, __m128h __B, __m128h __C) { + return (__m128h)__builtin_ia32_vfmaddcph128_maskz((__v4sf)__A, (__v4sf)__B, + (__v4sf)__C, (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_fmadd_pch(__m256h __A, + __m256h __B, + __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddcph256_mask((__v8sf)__A, (__v8sf)__B, + (__v8sf)__C, (__mmask8)-1); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_fmadd_pch(__m256h __A, __mmask8 __U, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_selectps_256( + __U, + __builtin_ia32_vfmaddcph256_mask((__v8sf)__A, (__v8sf)__B, (__v8sf)__C, + (__mmask8)__U), + (__v8sf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmadd_pch(__m256h __A, __m256h __B, __m256h __C, __mmask8 __U) { + return (__m256h)__builtin_ia32_vfmaddcph256_mask((__v8sf)__A, (__v8sf)__B, + (__v8sf)__C, (__mmask8)__U); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmadd_pch(__mmask8 __U, __m256h __A, __m256h __B, __m256h __C) { + return (__m256h)__builtin_ia32_vfmaddcph256_maskz((__v8sf)__A, (__v8sf)__B, + (__v8sf)__C, (__mmask8)__U); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 _mm_mask_blend_ph(__mmask8 __U, + __m128h __A, + __m128h __W) { + return (__m128h)__builtin_ia32_selectph_128((__mmask8)__U, (__v8hf)__W, + (__v8hf)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_ph(__mmask16 __U, __m256h __A, __m256h __W) { + return (__m256h)__builtin_ia32_selectph_256((__mmask16)__U, (__v16hf)__W, + (__v16hf)__A); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_permutex2var_ph(__m128h __A, __m128i __I, __m128h __B) { + return (__m128h)__builtin_ia32_vpermi2varhi128((__v8hi)__A, (__v8hi)__I, + (__v8hi)__B); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_permutex2var_ph(__m256h __A, __m256i __I, __m256h __B) { + return (__m256h)__builtin_ia32_vpermi2varhi256((__v16hi)__A, (__v16hi)__I, + (__v16hi)__B); +} + +static __inline__ __m128h __DEFAULT_FN_ATTRS128 +_mm_permutexvar_ph(__m128i __A, __m128h __B) { + return (__m128h)__builtin_ia32_permvarhi128((__v8hi)__B, (__v8hi)__A); +} + +static __inline__ __m256h __DEFAULT_FN_ATTRS256 +_mm256_permutexvar_ph(__m256i __A, __m256h __B) { + return (__m256h)__builtin_ia32_permvarhi256((__v16hi)__B, (__v16hi)__A); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS256 +_mm256_reduce_add_ph(__m256h __W) { + return __builtin_ia32_reduce_fadd_ph256(-0.0f16, __W); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS256 +_mm256_reduce_mul_ph(__m256h __W) { + return __builtin_ia32_reduce_fmul_ph256(1.0f16, __W); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS256 +_mm256_reduce_max_ph(__m256h __V) { + return __builtin_ia32_reduce_fmax_ph256(__V); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS256 +_mm256_reduce_min_ph(__m256h __V) { + return __builtin_ia32_reduce_fmin_ph256(__V); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS128 +_mm_reduce_add_ph(__m128h __W) { + return __builtin_ia32_reduce_fadd_ph128(-0.0f16, __W); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS128 +_mm_reduce_mul_ph(__m128h __W) { + return __builtin_ia32_reduce_fmul_ph128(1.0f16, __W); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS128 +_mm_reduce_max_ph(__m128h __V) { + return __builtin_ia32_reduce_fmax_ph128(__V); +} + +static __inline__ _Float16 __DEFAULT_FN_ATTRS128 +_mm_reduce_min_ph(__m128h __V) { + return __builtin_ia32_reduce_fmin_ph128(__V); +} + +// intrinsics below are alias for f*mul_*ch +#define _mm_mul_pch(A, B) _mm_fmul_pch(A, B) +#define _mm_mask_mul_pch(W, U, A, B) _mm_mask_fmul_pch(W, U, A, B) +#define _mm_maskz_mul_pch(U, A, B) _mm_maskz_fmul_pch(U, A, B) +#define _mm256_mul_pch(A, B) _mm256_fmul_pch(A, B) +#define _mm256_mask_mul_pch(W, U, A, B) _mm256_mask_fmul_pch(W, U, A, B) +#define _mm256_maskz_mul_pch(U, A, B) _mm256_maskz_fmul_pch(U, A, B) + +#define _mm_cmul_pch(A, B) _mm_fcmul_pch(A, B) +#define _mm_mask_cmul_pch(W, U, A, B) _mm_mask_fcmul_pch(W, U, A, B) +#define _mm_maskz_cmul_pch(U, A, B) _mm_maskz_fcmul_pch(U, A, B) +#define _mm256_cmul_pch(A, B) _mm256_fcmul_pch(A, B) +#define _mm256_mask_cmul_pch(W, U, A, B) _mm256_mask_fcmul_pch(W, U, A, B) +#define _mm256_maskz_cmul_pch(U, A, B) _mm256_maskz_fcmul_pch(U, A, B) + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlintrin.h new file mode 100755 index 0000000..2a5f7b4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlintrin.h @@ -0,0 +1,8437 @@ +/*===---- avx512vlintrin.h - AVX512VL intrinsics ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLINTRIN_H +#define __AVX512VLINTRIN_H + +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,no-evex512"), \ + __min_vector_width__(256))) + +typedef short __v2hi __attribute__((__vector_size__(4))); +typedef char __v4qi __attribute__((__vector_size__(4))); +typedef char __v2qi __attribute__((__vector_size__(2))); + +/* Integer compare */ + +#define _mm_cmpeq_epi32_mask(A, B) \ + _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epi32_mask(k, A, B) \ + _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epi32_mask(A, B) \ + _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epi32_mask(k, A, B) \ + _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epi32_mask(A, B) \ + _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epi32_mask(k, A, B) \ + _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epi32_mask(A, B) \ + _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epi32_mask(k, A, B) \ + _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epi32_mask(A, B) \ + _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epi32_mask(k, A, B) \ + _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epi32_mask(A, B) \ + _mm_cmp_epi32_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epi32_mask(k, A, B) \ + _mm_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epi32_mask(A, B) \ + _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epi32_mask(k, A, B) \ + _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epi32_mask(A, B) \ + _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epi32_mask(k, A, B) \ + _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epi32_mask(A, B) \ + _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epi32_mask(k, A, B) \ + _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epi32_mask(A, B) \ + _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epi32_mask(k, A, B) \ + _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epi32_mask(A, B) \ + _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epi32_mask(k, A, B) \ + _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epi32_mask(A, B) \ + _mm256_cmp_epi32_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epi32_mask(k, A, B) \ + _mm256_mask_cmp_epi32_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm_cmpeq_epu32_mask(A, B) \ + _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epu32_mask(k, A, B) \ + _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epu32_mask(A, B) \ + _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epu32_mask(k, A, B) \ + _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epu32_mask(A, B) \ + _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epu32_mask(k, A, B) \ + _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epu32_mask(A, B) \ + _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epu32_mask(k, A, B) \ + _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epu32_mask(A, B) \ + _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epu32_mask(k, A, B) \ + _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epu32_mask(A, B) \ + _mm_cmp_epu32_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epu32_mask(k, A, B) \ + _mm_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epu32_mask(A, B) \ + _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epu32_mask(k, A, B) \ + _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epu32_mask(A, B) \ + _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epu32_mask(k, A, B) \ + _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epu32_mask(A, B) \ + _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epu32_mask(k, A, B) \ + _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epu32_mask(A, B) \ + _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epu32_mask(k, A, B) \ + _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epu32_mask(A, B) \ + _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epu32_mask(k, A, B) \ + _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epu32_mask(A, B) \ + _mm256_cmp_epu32_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epu32_mask(k, A, B) \ + _mm256_mask_cmp_epu32_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm_cmpeq_epi64_mask(A, B) \ + _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epi64_mask(k, A, B) \ + _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epi64_mask(A, B) \ + _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epi64_mask(k, A, B) \ + _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epi64_mask(A, B) \ + _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epi64_mask(k, A, B) \ + _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epi64_mask(A, B) \ + _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epi64_mask(k, A, B) \ + _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epi64_mask(A, B) \ + _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epi64_mask(k, A, B) \ + _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epi64_mask(A, B) \ + _mm_cmp_epi64_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epi64_mask(k, A, B) \ + _mm_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epi64_mask(A, B) \ + _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epi64_mask(k, A, B) \ + _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epi64_mask(A, B) \ + _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epi64_mask(k, A, B) \ + _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epi64_mask(A, B) \ + _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epi64_mask(k, A, B) \ + _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epi64_mask(A, B) \ + _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epi64_mask(k, A, B) \ + _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epi64_mask(A, B) \ + _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epi64_mask(k, A, B) \ + _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epi64_mask(A, B) \ + _mm256_cmp_epi64_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epi64_mask(k, A, B) \ + _mm256_mask_cmp_epi64_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm_cmpeq_epu64_mask(A, B) \ + _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_EQ) +#define _mm_mask_cmpeq_epu64_mask(k, A, B) \ + _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm_cmpge_epu64_mask(A, B) \ + _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_GE) +#define _mm_mask_cmpge_epu64_mask(k, A, B) \ + _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm_cmpgt_epu64_mask(A, B) \ + _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_GT) +#define _mm_mask_cmpgt_epu64_mask(k, A, B) \ + _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm_cmple_epu64_mask(A, B) \ + _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_LE) +#define _mm_mask_cmple_epu64_mask(k, A, B) \ + _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm_cmplt_epu64_mask(A, B) \ + _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_LT) +#define _mm_mask_cmplt_epu64_mask(k, A, B) \ + _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm_cmpneq_epu64_mask(A, B) \ + _mm_cmp_epu64_mask((A), (B), _MM_CMPINT_NE) +#define _mm_mask_cmpneq_epu64_mask(k, A, B) \ + _mm_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_NE) + +#define _mm256_cmpeq_epu64_mask(A, B) \ + _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_EQ) +#define _mm256_mask_cmpeq_epu64_mask(k, A, B) \ + _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_EQ) +#define _mm256_cmpge_epu64_mask(A, B) \ + _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_GE) +#define _mm256_mask_cmpge_epu64_mask(k, A, B) \ + _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GE) +#define _mm256_cmpgt_epu64_mask(A, B) \ + _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_GT) +#define _mm256_mask_cmpgt_epu64_mask(k, A, B) \ + _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_GT) +#define _mm256_cmple_epu64_mask(A, B) \ + _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_LE) +#define _mm256_mask_cmple_epu64_mask(k, A, B) \ + _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LE) +#define _mm256_cmplt_epu64_mask(A, B) \ + _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_LT) +#define _mm256_mask_cmplt_epu64_mask(k, A, B) \ + _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_LT) +#define _mm256_cmpneq_epu64_mask(A, B) \ + _mm256_cmp_epu64_mask((A), (B), _MM_CMPINT_NE) +#define _mm256_mask_cmpneq_epu64_mask(k, A, B) \ + _mm256_mask_cmp_epu64_mask((k), (A), (B), _MM_CMPINT_NE) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_add_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_add_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_add_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_add_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_add_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_add_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sub_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sub_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sub_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sub_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sub_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_sub_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sub_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_sub_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_add_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_add_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_add_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_add_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_add_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_add_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_add_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_add_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sub_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sub_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sub_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sub_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_sub_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sub_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_sub_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mul_epi32(__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_mul_epi32(__X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mul_epi32(__mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_mul_epi32(__X, __Y), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mul_epi32(__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_mul_epi32(__X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_epi32(__mmask8 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_mul_epi32(__X, __Y), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mul_epu32(__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_mul_epu32(__X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mul_epu32(__mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_mul_epu32(__X, __Y), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mul_epu32(__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_mul_epu32(__X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_epu32(__mmask8 __M, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_mul_epu32(__X, __Y), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mullo_epi32(__mmask8 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_mullo_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mullo_epi32(__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_mullo_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mullo_epi32(__mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_mullo_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mullo_epi32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_mullo_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_and_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8su)__a & (__v8su)__b); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_and_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_and_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_and_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_and_epi32(_mm256_setzero_si256(), __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_and_epi32(__m128i __a, __m128i __b) +{ + return (__m128i)((__v4su)__a & (__v4su)__b); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_and_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_and_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_and_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_and_epi32(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_andnot_epi32(__m256i __A, __m256i __B) +{ + return (__m256i)(~(__v8su)__A & (__v8su)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_andnot_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_andnot_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_andnot_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_andnot_epi32(_mm256_setzero_si256(), + __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_andnot_epi32(__m128i __A, __m128i __B) +{ + return (__m128i)(~(__v4su)__A & (__v4su)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_andnot_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_andnot_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_andnot_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_andnot_epi32(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_or_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8su)__a | (__v8su)__b); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_or_epi32 (__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_or_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_or_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_or_epi32(_mm256_setzero_si256(), __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_or_epi32(__m128i __a, __m128i __b) +{ + return (__m128i)((__v4su)__a | (__v4su)__b); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_or_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_or_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_or_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_or_epi32(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_xor_epi32(__m256i __a, __m256i __b) +{ + return (__m256i)((__v8su)__a ^ (__v8su)__b); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_xor_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_xor_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_xor_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_xor_epi32(_mm256_setzero_si256(), __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_xor_epi32(__m128i __a, __m128i __b) +{ + return (__m128i)((__v4su)__a ^ (__v4su)__b); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_xor_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_xor_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_xor_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_xor_epi32(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_and_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a & (__v4du)__b); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_and_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_and_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_and_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_and_epi64(_mm256_setzero_si256(), __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_and_epi64(__m128i __a, __m128i __b) +{ + return (__m128i)((__v2du)__a & (__v2du)__b); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_and_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_and_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_and_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_and_epi64(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_andnot_epi64(__m256i __A, __m256i __B) +{ + return (__m256i)(~(__v4du)__A & (__v4du)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_andnot_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_andnot_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_andnot_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_andnot_epi64(_mm256_setzero_si256(), + __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_andnot_epi64(__m128i __A, __m128i __B) +{ + return (__m128i)(~(__v2du)__A & (__v2du)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_andnot_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_andnot_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_andnot_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_andnot_epi64(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_or_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a | (__v4du)__b); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_or_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_or_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_or_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_or_epi64(_mm256_setzero_si256(), __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_or_epi64(__m128i __a, __m128i __b) +{ + return (__m128i)((__v2du)__a | (__v2du)__b); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_or_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_or_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_or_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_or_epi64(_mm_setzero_si128(), __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_xor_epi64(__m256i __a, __m256i __b) +{ + return (__m256i)((__v4du)__a ^ (__v4du)__b); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_xor_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_xor_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_xor_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)_mm256_mask_xor_epi64(_mm256_setzero_si256(), __U, __A, __B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_xor_epi64(__m128i __a, __m128i __b) +{ + return (__m128i)((__v2du)__a ^ (__v2du)__b); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_xor_epi64(__m128i __W, __mmask8 __U, __m128i __A, + __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_xor_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_xor_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)_mm_mask_xor_epi64(_mm_setzero_si128(), __U, __A, __B); +} + +#define _mm_cmp_epi32_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpd128_mask((__v4si)(__m128i)(a), \ + (__v4si)(__m128i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_epi32_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpd128_mask((__v4si)(__m128i)(a), \ + (__v4si)(__m128i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm_cmp_epu32_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)(__m128i)(a), \ + (__v4si)(__m128i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_epu32_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpd128_mask((__v4si)(__m128i)(a), \ + (__v4si)(__m128i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_epi32_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpd256_mask((__v8si)(__m256i)(a), \ + (__v8si)(__m256i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm256_mask_cmp_epi32_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpd256_mask((__v8si)(__m256i)(a), \ + (__v8si)(__m256i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_epu32_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)(__m256i)(a), \ + (__v8si)(__m256i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm256_mask_cmp_epu32_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpd256_mask((__v8si)(__m256i)(a), \ + (__v8si)(__m256i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm_cmp_epi64_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpq128_mask((__v2di)(__m128i)(a), \ + (__v2di)(__m128i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_epi64_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpq128_mask((__v2di)(__m128i)(a), \ + (__v2di)(__m128i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm_cmp_epu64_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)(__m128i)(a), \ + (__v2di)(__m128i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_epu64_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpq128_mask((__v2di)(__m128i)(a), \ + (__v2di)(__m128i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_epi64_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpq256_mask((__v4di)(__m256i)(a), \ + (__v4di)(__m256i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm256_mask_cmp_epi64_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpq256_mask((__v4di)(__m256i)(a), \ + (__v4di)(__m256i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_epu64_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)(__m256i)(a), \ + (__v4di)(__m256i)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm256_mask_cmp_epu64_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_ucmpq256_mask((__v4di)(__m256i)(a), \ + (__v4di)(__m256i)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_ps_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpps256_mask((__v8sf)(__m256)(a), \ + (__v8sf)(__m256)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm256_mask_cmp_ps_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpps256_mask((__v8sf)(__m256)(a), \ + (__v8sf)(__m256)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm256_cmp_pd_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmppd256_mask((__v4df)(__m256d)(a), \ + (__v4df)(__m256d)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm256_mask_cmp_pd_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmppd256_mask((__v4df)(__m256d)(a), \ + (__v4df)(__m256d)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm_cmp_ps_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmpps128_mask((__v4sf)(__m128)(a), \ + (__v4sf)(__m128)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_ps_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmpps128_mask((__v4sf)(__m128)(a), \ + (__v4sf)(__m128)(b), (int)(p), \ + (__mmask8)(m))) + +#define _mm_cmp_pd_mask(a, b, p) \ + ((__mmask8)__builtin_ia32_cmppd128_mask((__v2df)(__m128d)(a), \ + (__v2df)(__m128d)(b), (int)(p), \ + (__mmask8)-1)) + +#define _mm_mask_cmp_pd_mask(m, a, b, p) \ + ((__mmask8)__builtin_ia32_cmppd128_mask((__v2df)(__m128d)(a), \ + (__v2df)(__m128d)(b), (int)(p), \ + (__mmask8)(m))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_pd(__m128d __A, __mmask8 __U, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_pd(__m128d __A, __m128d __B, __m128d __C, __mmask8 __U) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df) __C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_pd(__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fmsub_pd(__m128d __A, __mmask8 __U, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_pd(__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_pd(__m128d __A, __m128d __B, __m128d __C, __mmask8 __U) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd (-(__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df) __C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_pd(__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd (-(__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_pd(__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd (-(__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_fmadd_pd(__m256d __A, __mmask8 __U, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmadd_pd(__m256d __A, __m256d __B, __m256d __C, __mmask8 __U) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df) __C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmadd_pd(__mmask8 __U, __m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsub_pd(__m256d __A, __mmask8 __U, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmsub_pd(__mmask8 __U, __m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask3_fnmadd_pd(__m256d __A, __m256d __B, __m256d __C, __mmask8 __U) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 (-(__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df) __C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_fnmadd_pd(__mmask8 __U, __m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 (-(__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_fnmsub_pd(__mmask8 __U, __m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 (-(__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fmadd_ps(__m128 __A, __mmask8 __U, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fmadd_ps(__m128 __A, __m128 __B, __m128 __C, __mmask8 __U) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf) __C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fmadd_ps(__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fmsub_ps(__m128 __A, __mmask8 __U, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsub_ps(__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmadd_ps(__m128 __A, __m128 __B, __m128 __C, __mmask8 __U) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps (-(__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf) __C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmadd_ps(__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps (-(__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fnmsub_ps(__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps (-(__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_fmadd_ps(__m256 __A, __mmask8 __U, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmadd_ps(__m256 __A, __m256 __B, __m256 __C, __mmask8 __U) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf) __C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmadd_ps(__mmask8 __U, __m256 __A, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsub_ps(__m256 __A, __mmask8 __U, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmsub_ps(__mmask8 __U, __m256 __A, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask3_fnmadd_ps(__m256 __A, __m256 __B, __m256 __C, __mmask8 __U) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 (-(__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf) __C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_fnmadd_ps(__mmask8 __U, __m256 __A, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 (-(__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_fnmsub_ps(__mmask8 __U, __m256 __A, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 (-(__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fmaddsub_pd(__m128d __A, __mmask8 __U, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddsubpd ((__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fmaddsub_pd(__m128d __A, __m128d __B, __m128d __C, __mmask8 __U) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddsubpd ((__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df) __C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fmaddsub_pd(__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddsubpd ((__v2df) __A, + (__v2df) __B, + (__v2df) __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fmsubadd_pd(__m128d __A, __mmask8 __U, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddsubpd ((__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsubadd_pd(__mmask8 __U, __m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddsubpd ((__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_fmaddsub_pd(__m256d __A, __mmask8 __U, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddsubpd256 ((__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmaddsub_pd(__m256d __A, __m256d __B, __m256d __C, __mmask8 __U) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddsubpd256 ((__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df) __C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmaddsub_pd(__mmask8 __U, __m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddsubpd256 ((__v4df) __A, + (__v4df) __B, + (__v4df) __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsubadd_pd(__m256d __A, __mmask8 __U, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddsubpd256 ((__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmsubadd_pd(__mmask8 __U, __m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddsubpd256 ((__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fmaddsub_ps(__m128 __A, __mmask8 __U, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddsubps ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fmaddsub_ps(__m128 __A, __m128 __B, __m128 __C, __mmask8 __U) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddsubps ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf) __C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fmaddsub_ps(__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddsubps ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fmsubadd_ps(__m128 __A, __mmask8 __U, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddsubps ((__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_fmsubadd_ps(__mmask8 __U, __m128 __A, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddsubps ((__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_fmaddsub_ps(__m256 __A, __mmask8 __U, __m256 __B, + __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddsubps256 ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmaddsub_ps(__m256 __A, __m256 __B, __m256 __C, __mmask8 __U) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddsubps256 ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf) __C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmaddsub_ps(__mmask8 __U, __m256 __A, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddsubps256 ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_fmsubadd_ps(__m256 __A, __mmask8 __U, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddsubps256 ((__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_fmsubadd_ps(__mmask8 __U, __m256 __A, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddsubps256 ((__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_pd(__m128d __A, __m128d __B, __m128d __C, __mmask8 __U) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df) __C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmsub_pd(__m256d __A, __m256d __B, __m256d __C, __mmask8 __U) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df) __C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsub_ps(__m128 __A, __m128 __B, __m128 __C, __mmask8 __U) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf) __C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmsub_ps(__m256 __A, __m256 __B, __m256 __C, __mmask8 __U) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf) __C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsubadd_pd(__m128d __A, __m128d __B, __m128d __C, __mmask8 __U) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddsubpd ((__v2df) __A, + (__v2df) __B, + -(__v2df) __C), + (__v2df) __C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmsubadd_pd(__m256d __A, __m256d __B, __m256d __C, __mmask8 __U) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddsubpd256 ((__v4df) __A, + (__v4df) __B, + -(__v4df) __C), + (__v4df) __C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fmsubadd_ps(__m128 __A, __m128 __B, __m128 __C, __mmask8 __U) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddsubps ((__v4sf) __A, + (__v4sf) __B, + -(__v4sf) __C), + (__v4sf) __C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask3_fmsubadd_ps(__m256 __A, __m256 __B, __m256 __C, __mmask8 __U) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddsubps256 ((__v8sf) __A, + (__v8sf) __B, + -(__v8sf) __C), + (__v8sf) __C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_pd(__m128d __A, __mmask8 __U, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + -(__v2df) __B, + (__v2df) __C), + (__v2df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_fnmadd_pd(__m256d __A, __mmask8 __U, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + -(__v4df) __B, + (__v4df) __C), + (__v4df) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fnmadd_ps(__m128 __A, __mmask8 __U, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + -(__v4sf) __B, + (__v4sf) __C), + (__v4sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_fnmadd_ps(__m256 __A, __mmask8 __U, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + -(__v8sf) __B, + (__v8sf) __C), + (__v8sf) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_pd(__m128d __A, __mmask8 __U, __m128d __B, __m128d __C) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + -(__v2df) __B, + -(__v2df) __C), + (__v2df) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_pd(__m128d __A, __m128d __B, __m128d __C, __mmask8 __U) +{ + return (__m128d) __builtin_ia32_selectpd_128((__mmask8) __U, + __builtin_ia32_vfmaddpd ((__v2df) __A, + -(__v2df) __B, + -(__v2df) __C), + (__v2df) __C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_fnmsub_pd(__m256d __A, __mmask8 __U, __m256d __B, __m256d __C) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + -(__v4df) __B, + -(__v4df) __C), + (__v4df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask3_fnmsub_pd(__m256d __A, __m256d __B, __m256d __C, __mmask8 __U) +{ + return (__m256d) __builtin_ia32_selectpd_256((__mmask8) __U, + __builtin_ia32_vfmaddpd256 ((__v4df) __A, + -(__v4df) __B, + -(__v4df) __C), + (__v4df) __C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_fnmsub_ps(__m128 __A, __mmask8 __U, __m128 __B, __m128 __C) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + -(__v4sf) __B, + -(__v4sf) __C), + (__v4sf) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask3_fnmsub_ps(__m128 __A, __m128 __B, __m128 __C, __mmask8 __U) +{ + return (__m128) __builtin_ia32_selectps_128((__mmask8) __U, + __builtin_ia32_vfmaddps ((__v4sf) __A, + -(__v4sf) __B, + -(__v4sf) __C), + (__v4sf) __C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_fnmsub_ps(__m256 __A, __mmask8 __U, __m256 __B, __m256 __C) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + -(__v8sf) __B, + -(__v8sf) __C), + (__v8sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask3_fnmsub_ps(__m256 __A, __m256 __B, __m256 __C, __mmask8 __U) +{ + return (__m256) __builtin_ia32_selectps_256((__mmask8) __U, + __builtin_ia32_vfmaddps256 ((__v8sf) __A, + -(__v8sf) __B, + -(__v8sf) __C), + (__v8sf) __C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_add_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_add_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_add_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_add_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_add_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_add_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_add_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_add_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_add_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_add_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_add_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_add_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_add_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_add_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_add_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_blend_epi32 (__mmask8 __U, __m128i __A, __m128i __W) { + return (__m128i) __builtin_ia32_selectd_128 ((__mmask8) __U, + (__v4si) __W, + (__v4si) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_epi32 (__mmask8 __U, __m256i __A, __m256i __W) { + return (__m256i) __builtin_ia32_selectd_256 ((__mmask8) __U, + (__v8si) __W, + (__v8si) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_blend_pd (__mmask8 __U, __m128d __A, __m128d __W) { + return (__m128d) __builtin_ia32_selectpd_128 ((__mmask8) __U, + (__v2df) __W, + (__v2df) __A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_pd (__mmask8 __U, __m256d __A, __m256d __W) { + return (__m256d) __builtin_ia32_selectpd_256 ((__mmask8) __U, + (__v4df) __W, + (__v4df) __A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_blend_ps (__mmask8 __U, __m128 __A, __m128 __W) { + return (__m128) __builtin_ia32_selectps_128 ((__mmask8) __U, + (__v4sf) __W, + (__v4sf) __A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_ps (__mmask8 __U, __m256 __A, __m256 __W) { + return (__m256) __builtin_ia32_selectps_256 ((__mmask8) __U, + (__v8sf) __W, + (__v8sf) __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_blend_epi64 (__mmask8 __U, __m128i __A, __m128i __W) { + return (__m128i) __builtin_ia32_selectq_128 ((__mmask8) __U, + (__v2di) __W, + (__v2di) __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_blend_epi64 (__mmask8 __U, __m256i __A, __m256i __W) { + return (__m256i) __builtin_ia32_selectq_256 ((__mmask8) __U, + (__v4di) __W, + (__v4di) __A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_compress_pd (__m128d __W, __mmask8 __U, __m128d __A) { + return (__m128d) __builtin_ia32_compressdf128_mask ((__v2df) __A, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_compress_pd (__mmask8 __U, __m128d __A) { + return (__m128d) __builtin_ia32_compressdf128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_compress_pd (__m256d __W, __mmask8 __U, __m256d __A) { + return (__m256d) __builtin_ia32_compressdf256_mask ((__v4df) __A, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_compress_pd (__mmask8 __U, __m256d __A) { + return (__m256d) __builtin_ia32_compressdf256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_compress_epi64 (__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_compressdi128_mask ((__v2di) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_compress_epi64 (__mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_compressdi128_mask ((__v2di) __A, + (__v2di) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_compress_epi64 (__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_compressdi256_mask ((__v4di) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_compress_epi64 (__mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_compressdi256_mask ((__v4di) __A, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_compress_ps (__m128 __W, __mmask8 __U, __m128 __A) { + return (__m128) __builtin_ia32_compresssf128_mask ((__v4sf) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_compress_ps (__mmask8 __U, __m128 __A) { + return (__m128) __builtin_ia32_compresssf128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_compress_ps (__m256 __W, __mmask8 __U, __m256 __A) { + return (__m256) __builtin_ia32_compresssf256_mask ((__v8sf) __A, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_compress_ps (__mmask8 __U, __m256 __A) { + return (__m256) __builtin_ia32_compresssf256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_compress_epi32 (__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_compresssi128_mask ((__v4si) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_compress_epi32 (__mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_compresssi128_mask ((__v4si) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_compress_epi32 (__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_compresssi256_mask ((__v8si) __A, + (__v8si) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_compress_epi32 (__mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_compresssi256_mask ((__v8si) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_compressstoreu_pd (void *__P, __mmask8 __U, __m128d __A) { + __builtin_ia32_compressstoredf128_mask ((__v2df *) __P, + (__v2df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_compressstoreu_pd (void *__P, __mmask8 __U, __m256d __A) { + __builtin_ia32_compressstoredf256_mask ((__v4df *) __P, + (__v4df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_compressstoreu_epi64 (void *__P, __mmask8 __U, __m128i __A) { + __builtin_ia32_compressstoredi128_mask ((__v2di *) __P, + (__v2di) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_compressstoreu_epi64 (void *__P, __mmask8 __U, __m256i __A) { + __builtin_ia32_compressstoredi256_mask ((__v4di *) __P, + (__v4di) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_compressstoreu_ps (void *__P, __mmask8 __U, __m128 __A) { + __builtin_ia32_compressstoresf128_mask ((__v4sf *) __P, + (__v4sf) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_compressstoreu_ps (void *__P, __mmask8 __U, __m256 __A) { + __builtin_ia32_compressstoresf256_mask ((__v8sf *) __P, + (__v8sf) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_compressstoreu_epi32 (void *__P, __mmask8 __U, __m128i __A) { + __builtin_ia32_compressstoresi128_mask ((__v4si *) __P, + (__v4si) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_compressstoreu_epi32 (void *__P, __mmask8 __U, __m256i __A) { + __builtin_ia32_compressstoresi256_mask ((__v8si *) __P, + (__v8si) __A, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_pd (__m128d __W, __mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8) __U, + (__v2df)_mm_cvtepi32_pd(__A), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi32_pd (__mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8) __U, + (__v2df)_mm_cvtepi32_pd(__A), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_pd (__m256d __W, __mmask8 __U, __m128i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8) __U, + (__v4df)_mm256_cvtepi32_pd(__A), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi32_pd (__mmask8 __U, __m128i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8) __U, + (__v4df)_mm256_cvtepi32_pd(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_ps (__m128 __W, __mmask8 __U, __m128i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_cvtepi32_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi32_ps (__mmask8 __U, __m128i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_cvtepi32_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_ps (__m256 __W, __mmask8 __U, __m256i __A) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_cvtepi32_ps(__A), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi32_ps (__mmask8 __U, __m256i __A) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_cvtepi32_ps(__A), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtpd_epi32 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2dq128_mask ((__v2df) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpd_epi32 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2dq128_mask ((__v2df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpd_epi32 (__m128i __W, __mmask8 __U, __m256d __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm256_cvtpd_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpd_epi32 (__mmask8 __U, __m256d __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm256_cvtpd_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtpd_ps (__m128 __W, __mmask8 __U, __m128d __A) { + return (__m128) __builtin_ia32_cvtpd2ps_mask ((__v2df) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpd_ps (__mmask8 __U, __m128d __A) { + return (__m128) __builtin_ia32_cvtpd2ps_mask ((__v2df) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpd_ps (__m128 __W, __mmask8 __U, __m256d __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm256_cvtpd_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpd_ps (__mmask8 __U, __m256d __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm256_cvtpd_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtpd_epu32 (__m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2udq128_mask ((__v2df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtpd_epu32 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2udq128_mask ((__v2df) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtpd_epu32 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvtpd2udq128_mask ((__v2df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtpd_epu32 (__m256d __A) { + return (__m128i) __builtin_ia32_cvtpd2udq256_mask ((__v4df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtpd_epu32 (__m128i __W, __mmask8 __U, __m256d __A) { + return (__m128i) __builtin_ia32_cvtpd2udq256_mask ((__v4df) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtpd_epu32 (__mmask8 __U, __m256d __A) { + return (__m128i) __builtin_ia32_cvtpd2udq256_mask ((__v4df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtps_epi32 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtps_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtps_epi32 (__mmask8 __U, __m128 __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtps_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtps_epi32 (__m256i __W, __mmask8 __U, __m256 __A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtps_epi32(__A), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtps_epi32 (__mmask8 __U, __m256 __A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtps_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_cvtps_pd (__m128d __W, __mmask8 __U, __m128 __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_cvtps_pd(__A), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtps_pd (__mmask8 __U, __m128 __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_cvtps_pd(__A), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtps_pd (__m256d __W, __mmask8 __U, __m128 __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_cvtps_pd(__A), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtps_pd (__mmask8 __U, __m128 __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_cvtps_pd(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtps_epu32 (__m128 __A) { + return (__m128i) __builtin_ia32_cvtps2udq128_mask ((__v4sf) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtps_epu32 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvtps2udq128_mask ((__v4sf) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtps_epu32 (__mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvtps2udq128_mask ((__v4sf) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvtps_epu32 (__m256 __A) { + return (__m256i) __builtin_ia32_cvtps2udq256_mask ((__v8sf) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtps_epu32 (__m256i __W, __mmask8 __U, __m256 __A) { + return (__m256i) __builtin_ia32_cvtps2udq256_mask ((__v8sf) __A, + (__v8si) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtps_epu32 (__mmask8 __U, __m256 __A) { + return (__m256i) __builtin_ia32_cvtps2udq256_mask ((__v8sf) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttpd_epi32 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2dq128_mask ((__v2df) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttpd_epi32 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2dq128_mask ((__v2df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttpd_epi32 (__m128i __W, __mmask8 __U, __m256d __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm256_cvttpd_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttpd_epi32 (__mmask8 __U, __m256d __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm256_cvttpd_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvttpd_epu32 (__m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2udq128_mask ((__v2df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttpd_epu32 (__m128i __W, __mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2udq128_mask ((__v2df) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttpd_epu32 (__mmask8 __U, __m128d __A) { + return (__m128i) __builtin_ia32_cvttpd2udq128_mask ((__v2df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvttpd_epu32 (__m256d __A) { + return (__m128i) __builtin_ia32_cvttpd2udq256_mask ((__v4df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttpd_epu32 (__m128i __W, __mmask8 __U, __m256d __A) { + return (__m128i) __builtin_ia32_cvttpd2udq256_mask ((__v4df) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttpd_epu32 (__mmask8 __U, __m256d __A) { + return (__m128i) __builtin_ia32_cvttpd2udq256_mask ((__v4df) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttps_epi32 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvttps_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttps_epi32 (__mmask8 __U, __m128 __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvttps_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttps_epi32 (__m256i __W, __mmask8 __U, __m256 __A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvttps_epi32(__A), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttps_epi32 (__mmask8 __U, __m256 __A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvttps_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvttps_epu32 (__m128 __A) { + return (__m128i) __builtin_ia32_cvttps2udq128_mask ((__v4sf) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvttps_epu32 (__m128i __W, __mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvttps2udq128_mask ((__v4sf) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvttps_epu32 (__mmask8 __U, __m128 __A) { + return (__m128i) __builtin_ia32_cvttps2udq128_mask ((__v4sf) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cvttps_epu32 (__m256 __A) { + return (__m256i) __builtin_ia32_cvttps2udq256_mask ((__v8sf) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) -1); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvttps_epu32 (__m256i __W, __mmask8 __U, __m256 __A) { + return (__m256i) __builtin_ia32_cvttps2udq256_mask ((__v8sf) __A, + (__v8si) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvttps_epu32 (__mmask8 __U, __m256 __A) { + return (__m256i) __builtin_ia32_cvttps2udq256_mask ((__v8sf) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_cvtepu32_pd (__m128i __A) { + return (__m128d) __builtin_convertvector( + __builtin_shufflevector((__v4su)__A, (__v4su)__A, 0, 1), __v2df); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu32_pd (__m128d __W, __mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8) __U, + (__v2df)_mm_cvtepu32_pd(__A), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu32_pd (__mmask8 __U, __m128i __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8) __U, + (__v2df)_mm_cvtepu32_pd(__A), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_cvtepu32_pd (__m128i __A) { + return (__m256d)__builtin_convertvector((__v4su)__A, __v4df); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu32_pd (__m256d __W, __mmask8 __U, __m128i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8) __U, + (__v4df)_mm256_cvtepu32_pd(__A), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu32_pd (__mmask8 __U, __m128i __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8) __U, + (__v4df)_mm256_cvtepu32_pd(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtepu32_ps (__m128i __A) { + return (__m128)__builtin_convertvector((__v4su)__A, __v4sf); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepu32_ps (__m128 __W, __mmask8 __U, __m128i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_cvtepu32_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepu32_ps (__mmask8 __U, __m128i __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_cvtepu32_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_cvtepu32_ps (__m256i __A) { + return (__m256)__builtin_convertvector((__v8su)__A, __v8sf); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepu32_ps (__m256 __W, __mmask8 __U, __m256i __A) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_cvtepu32_ps(__A), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepu32_ps (__mmask8 __U, __m256i __A) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_cvtepu32_ps(__A), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_div_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_div_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_div_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_div_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_div_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_div_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_div_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_div_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_div_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_div_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_div_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_div_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_div_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_div_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_div_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_div_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_expand_pd (__m128d __W, __mmask8 __U, __m128d __A) { + return (__m128d) __builtin_ia32_expanddf128_mask ((__v2df) __A, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_expand_pd (__mmask8 __U, __m128d __A) { + return (__m128d) __builtin_ia32_expanddf128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_expand_pd (__m256d __W, __mmask8 __U, __m256d __A) { + return (__m256d) __builtin_ia32_expanddf256_mask ((__v4df) __A, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_expand_pd (__mmask8 __U, __m256d __A) { + return (__m256d) __builtin_ia32_expanddf256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expand_epi64 (__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_expanddi128_mask ((__v2di) __A, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expand_epi64 (__mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_expanddi128_mask ((__v2di) __A, + (__v2di) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expand_epi64 (__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_expanddi256_mask ((__v4di) __A, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expand_epi64 (__mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_expanddi256_mask ((__v4di) __A, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_expandloadu_pd (__m128d __W, __mmask8 __U, void const *__P) { + return (__m128d) __builtin_ia32_expandloaddf128_mask ((const __v2df *) __P, + (__v2df) __W, + (__mmask8) + __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_expandloadu_pd (__mmask8 __U, void const *__P) { + return (__m128d) __builtin_ia32_expandloaddf128_mask ((const __v2df *) __P, + (__v2df) + _mm_setzero_pd (), + (__mmask8) + __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_expandloadu_pd (__m256d __W, __mmask8 __U, void const *__P) { + return (__m256d) __builtin_ia32_expandloaddf256_mask ((const __v4df *) __P, + (__v4df) __W, + (__mmask8) + __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_expandloadu_pd (__mmask8 __U, void const *__P) { + return (__m256d) __builtin_ia32_expandloaddf256_mask ((const __v4df *) __P, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expandloadu_epi64 (__m128i __W, __mmask8 __U, void const *__P) { + return (__m128i) __builtin_ia32_expandloaddi128_mask ((const __v2di *) __P, + (__v2di) __W, + (__mmask8) + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expandloadu_epi64 (__mmask8 __U, void const *__P) { + return (__m128i) __builtin_ia32_expandloaddi128_mask ((const __v2di *) __P, + (__v2di) + _mm_setzero_si128 (), + (__mmask8) + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expandloadu_epi64 (__m256i __W, __mmask8 __U, + void const *__P) { + return (__m256i) __builtin_ia32_expandloaddi256_mask ((const __v4di *) __P, + (__v4di) __W, + (__mmask8) + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expandloadu_epi64 (__mmask8 __U, void const *__P) { + return (__m256i) __builtin_ia32_expandloaddi256_mask ((const __v4di *) __P, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) + __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_expandloadu_ps (__m128 __W, __mmask8 __U, void const *__P) { + return (__m128) __builtin_ia32_expandloadsf128_mask ((const __v4sf *) __P, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_expandloadu_ps (__mmask8 __U, void const *__P) { + return (__m128) __builtin_ia32_expandloadsf128_mask ((const __v4sf *) __P, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) + __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_expandloadu_ps (__m256 __W, __mmask8 __U, void const *__P) { + return (__m256) __builtin_ia32_expandloadsf256_mask ((const __v8sf *) __P, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_expandloadu_ps (__mmask8 __U, void const *__P) { + return (__m256) __builtin_ia32_expandloadsf256_mask ((const __v8sf *) __P, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expandloadu_epi32 (__m128i __W, __mmask8 __U, void const *__P) { + return (__m128i) __builtin_ia32_expandloadsi128_mask ((const __v4si *) __P, + (__v4si) __W, + (__mmask8) + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expandloadu_epi32 (__mmask8 __U, void const *__P) { + return (__m128i) __builtin_ia32_expandloadsi128_mask ((const __v4si *) __P, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expandloadu_epi32 (__m256i __W, __mmask8 __U, + void const *__P) { + return (__m256i) __builtin_ia32_expandloadsi256_mask ((const __v8si *) __P, + (__v8si) __W, + (__mmask8) + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expandloadu_epi32 (__mmask8 __U, void const *__P) { + return (__m256i) __builtin_ia32_expandloadsi256_mask ((const __v8si *) __P, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) + __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_expand_ps (__m128 __W, __mmask8 __U, __m128 __A) { + return (__m128) __builtin_ia32_expandsf128_mask ((__v4sf) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_expand_ps (__mmask8 __U, __m128 __A) { + return (__m128) __builtin_ia32_expandsf128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_expand_ps (__m256 __W, __mmask8 __U, __m256 __A) { + return (__m256) __builtin_ia32_expandsf256_mask ((__v8sf) __A, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_expand_ps (__mmask8 __U, __m256 __A) { + return (__m256) __builtin_ia32_expandsf256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expand_epi32 (__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_expandsi128_mask ((__v4si) __A, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expand_epi32 (__mmask8 __U, __m128i __A) { + return (__m128i) __builtin_ia32_expandsi128_mask ((__v4si) __A, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expand_epi32 (__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_expandsi256_mask ((__v8si) __A, + (__v8si) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expand_epi32 (__mmask8 __U, __m256i __A) { + return (__m256i) __builtin_ia32_expandsi256_mask ((__v8si) __A, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_getexp_pd (__m128d __A) { + return (__m128d) __builtin_ia32_getexppd128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_pd (__m128d __W, __mmask8 __U, __m128d __A) { + return (__m128d) __builtin_ia32_getexppd128_mask ((__v2df) __A, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_pd (__mmask8 __U, __m128d __A) { + return (__m128d) __builtin_ia32_getexppd128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_getexp_pd (__m256d __A) { + return (__m256d) __builtin_ia32_getexppd256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_getexp_pd (__m256d __W, __mmask8 __U, __m256d __A) { + return (__m256d) __builtin_ia32_getexppd256_mask ((__v4df) __A, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_getexp_pd (__mmask8 __U, __m256d __A) { + return (__m256d) __builtin_ia32_getexppd256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_getexp_ps (__m128 __A) { + return (__m128) __builtin_ia32_getexpps128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_getexp_ps (__m128 __W, __mmask8 __U, __m128 __A) { + return (__m128) __builtin_ia32_getexpps128_mask ((__v4sf) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_getexp_ps (__mmask8 __U, __m128 __A) { + return (__m128) __builtin_ia32_getexpps128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_getexp_ps (__m256 __A) { + return (__m256) __builtin_ia32_getexpps256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_getexp_ps (__m256 __W, __mmask8 __U, __m256 __A) { + return (__m256) __builtin_ia32_getexpps256_mask ((__v8sf) __A, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_getexp_ps (__mmask8 __U, __m256 __A) { + return (__m256) __builtin_ia32_getexpps256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_max_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_max_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_max_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_max_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_max_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_max_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_max_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_max_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_max_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_max_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_max_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_max_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_max_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_max_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_min_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_min_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_min_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_min_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_min_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_min_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_min_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_min_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_min_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_min_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_min_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_min_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_min_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_min_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_mul_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_mul_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_mul_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_mul_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_mul_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_mul_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_mul_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_mul_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_mul_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_mul_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_mul_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_mul_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_mul_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_mul_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_mul_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_abs_epi32(__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_abs_epi32(__A), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_abs_epi32(__mmask8 __U, __m128i __A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_abs_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_abs_epi32(__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_abs_epi32(__A), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_abs_epi32(__mmask8 __U, __m256i __A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_abs_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_abs_epi64 (__m128i __A) { + return (__m128i)__builtin_elementwise_abs((__v2di)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_abs_epi64 (__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_abs_epi64(__A), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_abs_epi64 (__mmask8 __U, __m128i __A) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_abs_epi64(__A), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_abs_epi64 (__m256i __A) { + return (__m256i)__builtin_elementwise_abs((__v4di)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_abs_epi64 (__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_abs_epi64(__A), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_abs_epi64 (__mmask8 __U, __m256i __A) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_abs_epi64(__A), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epi32(__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_max_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epi32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_max_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epi32(__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_max_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epi32(__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_max_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_max_epi64 (__m128i __A, __m128i __B) { + return (__m128i)__builtin_elementwise_max((__v2di)__A, (__v2di)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epi64 (__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_max_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epi64 (__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_max_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epi64 (__m256i __A, __m256i __B) { + return (__m256i)__builtin_elementwise_max((__v4di)__A, (__v4di)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epi64 (__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_max_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epi64 (__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_max_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epu32(__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_max_epu32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epu32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_max_epu32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epu32(__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_max_epu32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epu32(__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_max_epu32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_max_epu64 (__m128i __A, __m128i __B) { + return (__m128i)__builtin_elementwise_max((__v2du)__A, (__v2du)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_max_epu64 (__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_max_epu64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_max_epu64 (__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_max_epu64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_max_epu64 (__m256i __A, __m256i __B) { + return (__m256i)__builtin_elementwise_max((__v4du)__A, (__v4du)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_max_epu64 (__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_max_epu64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_max_epu64 (__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_max_epu64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epi32(__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_min_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epi32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_min_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epi32(__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_min_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epi32(__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_min_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_min_epi64 (__m128i __A, __m128i __B) { + return (__m128i)__builtin_elementwise_min((__v2di)__A, (__v2di)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epi64 (__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_min_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epi64 (__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_min_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epi64 (__m256i __A, __m256i __B) { + return (__m256i)__builtin_elementwise_min((__v4di)__A, (__v4di)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epi64 (__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_min_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epi64 (__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_min_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epu32(__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_min_epu32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epu32(__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm_min_epu32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epu32(__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_min_epu32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epu32(__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_min_epu32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_min_epu64 (__m128i __A, __m128i __B) { + return (__m128i)__builtin_elementwise_min((__v2du)__A, (__v2du)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_min_epu64 (__m128i __W, __mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_min_epu64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_min_epu64 (__mmask8 __M, __m128i __A, __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__M, + (__v2di)_mm_min_epu64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_min_epu64 (__m256i __A, __m256i __B) { + return (__m256i)__builtin_elementwise_min((__v4du)__A, (__v4du)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_min_epu64 (__m256i __W, __mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_min_epu64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_min_epu64 (__mmask8 __M, __m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_min_epu64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +#define _mm_roundscale_pd(A, imm) \ + ((__m128d)__builtin_ia32_rndscalepd_128_mask((__v2df)(__m128d)(A), \ + (int)(imm), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1)) + + +#define _mm_mask_roundscale_pd(W, U, A, imm) \ + ((__m128d)__builtin_ia32_rndscalepd_128_mask((__v2df)(__m128d)(A), \ + (int)(imm), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U))) + + +#define _mm_maskz_roundscale_pd(U, A, imm) \ + ((__m128d)__builtin_ia32_rndscalepd_128_mask((__v2df)(__m128d)(A), \ + (int)(imm), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U))) + + +#define _mm256_roundscale_pd(A, imm) \ + ((__m256d)__builtin_ia32_rndscalepd_256_mask((__v4df)(__m256d)(A), \ + (int)(imm), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)-1)) + + +#define _mm256_mask_roundscale_pd(W, U, A, imm) \ + ((__m256d)__builtin_ia32_rndscalepd_256_mask((__v4df)(__m256d)(A), \ + (int)(imm), \ + (__v4df)(__m256d)(W), \ + (__mmask8)(U))) + + +#define _mm256_maskz_roundscale_pd(U, A, imm) \ + ((__m256d)__builtin_ia32_rndscalepd_256_mask((__v4df)(__m256d)(A), \ + (int)(imm), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm_roundscale_ps(A, imm) \ + ((__m128)__builtin_ia32_rndscaleps_128_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1)) + + +#define _mm_mask_roundscale_ps(W, U, A, imm) \ + ((__m128)__builtin_ia32_rndscaleps_128_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U))) + + +#define _mm_maskz_roundscale_ps(U, A, imm) \ + ((__m128)__builtin_ia32_rndscaleps_128_mask((__v4sf)(__m128)(A), (int)(imm), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm256_roundscale_ps(A, imm) \ + ((__m256)__builtin_ia32_rndscaleps_256_mask((__v8sf)(__m256)(A), (int)(imm), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm256_mask_roundscale_ps(W, U, A, imm) \ + ((__m256)__builtin_ia32_rndscaleps_256_mask((__v8sf)(__m256)(A), (int)(imm), \ + (__v8sf)(__m256)(W), \ + (__mmask8)(U))) + + +#define _mm256_maskz_roundscale_ps(U, A, imm) \ + ((__m256)__builtin_ia32_rndscaleps_256_mask((__v8sf)(__m256)(A), (int)(imm), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_scalef_pd (__m128d __A, __m128d __B) { + return (__m128d) __builtin_ia32_scalefpd128_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) + _mm_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_pd (__m128d __W, __mmask8 __U, __m128d __A, + __m128d __B) { + return (__m128d) __builtin_ia32_scalefpd128_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_pd (__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d) __builtin_ia32_scalefpd128_mask ((__v2df) __A, + (__v2df) __B, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_scalef_pd (__m256d __A, __m256d __B) { + return (__m256d) __builtin_ia32_scalefpd256_mask ((__v4df) __A, + (__v4df) __B, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_scalef_pd (__m256d __W, __mmask8 __U, __m256d __A, + __m256d __B) { + return (__m256d) __builtin_ia32_scalefpd256_mask ((__v4df) __A, + (__v4df) __B, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_scalef_pd (__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d) __builtin_ia32_scalefpd256_mask ((__v4df) __A, + (__v4df) __B, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_scalef_ps (__m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_scalefps128_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_scalef_ps (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_scalefps128_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_scalef_ps (__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_scalefps128_mask ((__v4sf) __A, + (__v4sf) __B, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_scalef_ps (__m256 __A, __m256 __B) { + return (__m256) __builtin_ia32_scalefps256_mask ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_scalef_ps (__m256 __W, __mmask8 __U, __m256 __A, + __m256 __B) { + return (__m256) __builtin_ia32_scalefps256_mask ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_scalef_ps (__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256) __builtin_ia32_scalefps256_mask ((__v8sf) __A, + (__v8sf) __B, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +#define _mm_i64scatter_pd(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv2df((void *)(addr), (__mmask8)-1, \ + (__v2di)(__m128i)(index), \ + (__v2df)(__m128d)(v1), (int)(scale)) + +#define _mm_mask_i64scatter_pd(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv2df((void *)(addr), (__mmask8)(mask), \ + (__v2di)(__m128i)(index), \ + (__v2df)(__m128d)(v1), (int)(scale)) + +#define _mm_i64scatter_epi64(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv2di((void *)(addr), (__mmask8)-1, \ + (__v2di)(__m128i)(index), \ + (__v2di)(__m128i)(v1), (int)(scale)) + +#define _mm_mask_i64scatter_epi64(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv2di((void *)(addr), (__mmask8)(mask), \ + (__v2di)(__m128i)(index), \ + (__v2di)(__m128i)(v1), (int)(scale)) + +#define _mm256_i64scatter_pd(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv4df((void *)(addr), (__mmask8)-1, \ + (__v4di)(__m256i)(index), \ + (__v4df)(__m256d)(v1), (int)(scale)) + +#define _mm256_mask_i64scatter_pd(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv4df((void *)(addr), (__mmask8)(mask), \ + (__v4di)(__m256i)(index), \ + (__v4df)(__m256d)(v1), (int)(scale)) + +#define _mm256_i64scatter_epi64(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv4di((void *)(addr), (__mmask8)-1, \ + (__v4di)(__m256i)(index), \ + (__v4di)(__m256i)(v1), (int)(scale)) + +#define _mm256_mask_i64scatter_epi64(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv4di((void *)(addr), (__mmask8)(mask), \ + (__v4di)(__m256i)(index), \ + (__v4di)(__m256i)(v1), (int)(scale)) + +#define _mm_i64scatter_ps(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv4sf((void *)(addr), (__mmask8)-1, \ + (__v2di)(__m128i)(index), (__v4sf)(__m128)(v1), \ + (int)(scale)) + +#define _mm_mask_i64scatter_ps(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv4sf((void *)(addr), (__mmask8)(mask), \ + (__v2di)(__m128i)(index), (__v4sf)(__m128)(v1), \ + (int)(scale)) + +#define _mm_i64scatter_epi32(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv4si((void *)(addr), (__mmask8)-1, \ + (__v2di)(__m128i)(index), \ + (__v4si)(__m128i)(v1), (int)(scale)) + +#define _mm_mask_i64scatter_epi32(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv4si((void *)(addr), (__mmask8)(mask), \ + (__v2di)(__m128i)(index), \ + (__v4si)(__m128i)(v1), (int)(scale)) + +#define _mm256_i64scatter_ps(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv8sf((void *)(addr), (__mmask8)-1, \ + (__v4di)(__m256i)(index), (__v4sf)(__m128)(v1), \ + (int)(scale)) + +#define _mm256_mask_i64scatter_ps(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv8sf((void *)(addr), (__mmask8)(mask), \ + (__v4di)(__m256i)(index), (__v4sf)(__m128)(v1), \ + (int)(scale)) + +#define _mm256_i64scatter_epi32(addr, index, v1, scale) \ + __builtin_ia32_scatterdiv8si((void *)(addr), (__mmask8)-1, \ + (__v4di)(__m256i)(index), \ + (__v4si)(__m128i)(v1), (int)(scale)) + +#define _mm256_mask_i64scatter_epi32(addr, mask, index, v1, scale) \ + __builtin_ia32_scatterdiv8si((void *)(addr), (__mmask8)(mask), \ + (__v4di)(__m256i)(index), \ + (__v4si)(__m128i)(v1), (int)(scale)) + +#define _mm_i32scatter_pd(addr, index, v1, scale) \ + __builtin_ia32_scattersiv2df((void *)(addr), (__mmask8)-1, \ + (__v4si)(__m128i)(index), \ + (__v2df)(__m128d)(v1), (int)(scale)) + +#define _mm_mask_i32scatter_pd(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv2df((void *)(addr), (__mmask8)(mask), \ + (__v4si)(__m128i)(index), \ + (__v2df)(__m128d)(v1), (int)(scale)) + +#define _mm_i32scatter_epi64(addr, index, v1, scale) \ + __builtin_ia32_scattersiv2di((void *)(addr), (__mmask8)-1, \ + (__v4si)(__m128i)(index), \ + (__v2di)(__m128i)(v1), (int)(scale)) + +#define _mm_mask_i32scatter_epi64(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv2di((void *)(addr), (__mmask8)(mask), \ + (__v4si)(__m128i)(index), \ + (__v2di)(__m128i)(v1), (int)(scale)) + +#define _mm256_i32scatter_pd(addr, index, v1, scale) \ + __builtin_ia32_scattersiv4df((void *)(addr), (__mmask8)-1, \ + (__v4si)(__m128i)(index), \ + (__v4df)(__m256d)(v1), (int)(scale)) + +#define _mm256_mask_i32scatter_pd(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv4df((void *)(addr), (__mmask8)(mask), \ + (__v4si)(__m128i)(index), \ + (__v4df)(__m256d)(v1), (int)(scale)) + +#define _mm256_i32scatter_epi64(addr, index, v1, scale) \ + __builtin_ia32_scattersiv4di((void *)(addr), (__mmask8)-1, \ + (__v4si)(__m128i)(index), \ + (__v4di)(__m256i)(v1), (int)(scale)) + +#define _mm256_mask_i32scatter_epi64(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv4di((void *)(addr), (__mmask8)(mask), \ + (__v4si)(__m128i)(index), \ + (__v4di)(__m256i)(v1), (int)(scale)) + +#define _mm_i32scatter_ps(addr, index, v1, scale) \ + __builtin_ia32_scattersiv4sf((void *)(addr), (__mmask8)-1, \ + (__v4si)(__m128i)(index), (__v4sf)(__m128)(v1), \ + (int)(scale)) + +#define _mm_mask_i32scatter_ps(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv4sf((void *)(addr), (__mmask8)(mask), \ + (__v4si)(__m128i)(index), (__v4sf)(__m128)(v1), \ + (int)(scale)) + +#define _mm_i32scatter_epi32(addr, index, v1, scale) \ + __builtin_ia32_scattersiv4si((void *)(addr), (__mmask8)-1, \ + (__v4si)(__m128i)(index), \ + (__v4si)(__m128i)(v1), (int)(scale)) + +#define _mm_mask_i32scatter_epi32(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv4si((void *)(addr), (__mmask8)(mask), \ + (__v4si)(__m128i)(index), \ + (__v4si)(__m128i)(v1), (int)(scale)) + +#define _mm256_i32scatter_ps(addr, index, v1, scale) \ + __builtin_ia32_scattersiv8sf((void *)(addr), (__mmask8)-1, \ + (__v8si)(__m256i)(index), (__v8sf)(__m256)(v1), \ + (int)(scale)) + +#define _mm256_mask_i32scatter_ps(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv8sf((void *)(addr), (__mmask8)(mask), \ + (__v8si)(__m256i)(index), (__v8sf)(__m256)(v1), \ + (int)(scale)) + +#define _mm256_i32scatter_epi32(addr, index, v1, scale) \ + __builtin_ia32_scattersiv8si((void *)(addr), (__mmask8)-1, \ + (__v8si)(__m256i)(index), \ + (__v8si)(__m256i)(v1), (int)(scale)) + +#define _mm256_mask_i32scatter_epi32(addr, mask, index, v1, scale) \ + __builtin_ia32_scattersiv8si((void *)(addr), (__mmask8)(mask), \ + (__v8si)(__m256i)(index), \ + (__v8si)(__m256i)(v1), (int)(scale)) + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_mask_sqrt_pd(__m128d __W, __mmask8 __U, __m128d __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_sqrt_pd(__A), + (__v2df)__W); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_maskz_sqrt_pd(__mmask8 __U, __m128d __A) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_sqrt_pd(__A), + (__v2df)_mm_setzero_pd()); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_mask_sqrt_pd(__m256d __W, __mmask8 __U, __m256d __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_sqrt_pd(__A), + (__v4df)__W); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_maskz_sqrt_pd(__mmask8 __U, __m256d __A) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_sqrt_pd(__A), + (__v4df)_mm256_setzero_pd()); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_mask_sqrt_ps(__m128 __W, __mmask8 __U, __m128 __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_sqrt_ps(__A), + (__v4sf)__W); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_maskz_sqrt_ps(__mmask8 __U, __m128 __A) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_sqrt_ps(__A), + (__v4sf)_mm_setzero_ps()); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_mask_sqrt_ps(__m256 __W, __mmask8 __U, __m256 __A) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_sqrt_ps(__A), + (__v8sf)__W); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_maskz_sqrt_ps(__mmask8 __U, __m256 __A) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_sqrt_ps(__A), + (__v8sf)_mm256_setzero_ps()); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_mask_sub_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_sub_pd(__A, __B), + (__v2df)__W); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_maskz_sub_pd(__mmask8 __U, __m128d __A, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_sub_pd(__A, __B), + (__v2df)_mm_setzero_pd()); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_mask_sub_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_sub_pd(__A, __B), + (__v4df)__W); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_maskz_sub_pd(__mmask8 __U, __m256d __A, __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_sub_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_mask_sub_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_sub_ps(__A, __B), + (__v4sf)__W); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_maskz_sub_ps(__mmask8 __U, __m128 __A, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_sub_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_mask_sub_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_sub_ps(__A, __B), + (__v8sf)__W); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_maskz_sub_ps(__mmask8 __U, __m256 __A, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_sub_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_permutex2var_epi32(__m128i __A, __m128i __I, __m128i __B) { + return (__m128i)__builtin_ia32_vpermi2vard128((__v4si) __A, (__v4si)__I, + (__v4si)__B); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_permutex2var_epi32(__m128i __A, __mmask8 __U, __m128i __I, + __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_permutex2var_epi32(__A, __I, __B), + (__v4si)__A); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask2_permutex2var_epi32(__m128i __A, __m128i __I, __mmask8 __U, + __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_permutex2var_epi32(__A, __I, __B), + (__v4si)__I); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_permutex2var_epi32(__mmask8 __U, __m128i __A, __m128i __I, + __m128i __B) { + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_permutex2var_epi32(__A, __I, __B), + (__v4si)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_permutex2var_epi32(__m256i __A, __m256i __I, __m256i __B) { + return (__m256i)__builtin_ia32_vpermi2vard256((__v8si)__A, (__v8si) __I, + (__v8si) __B); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_permutex2var_epi32(__m256i __A, __mmask8 __U, __m256i __I, + __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_permutex2var_epi32(__A, __I, __B), + (__v8si)__A); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask2_permutex2var_epi32(__m256i __A, __m256i __I, __mmask8 __U, + __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_permutex2var_epi32(__A, __I, __B), + (__v8si)__I); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_permutex2var_epi32(__mmask8 __U, __m256i __A, __m256i __I, + __m256i __B) { + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_permutex2var_epi32(__A, __I, __B), + (__v8si)_mm256_setzero_si256()); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_permutex2var_pd(__m128d __A, __m128i __I, __m128d __B) { + return (__m128d)__builtin_ia32_vpermi2varpd128((__v2df)__A, (__v2di)__I, + (__v2df)__B); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_mask_permutex2var_pd(__m128d __A, __mmask8 __U, __m128i __I, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128(__U, + (__v2df)_mm_permutex2var_pd(__A, __I, __B), + (__v2df)__A); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_mask2_permutex2var_pd(__m128d __A, __m128i __I, __mmask8 __U, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128(__U, + (__v2df)_mm_permutex2var_pd(__A, __I, __B), + (__v2df)(__m128d)__I); + } + + static __inline__ __m128d __DEFAULT_FN_ATTRS128 + _mm_maskz_permutex2var_pd(__mmask8 __U, __m128d __A, __m128i __I, __m128d __B) { + return (__m128d)__builtin_ia32_selectpd_128(__U, + (__v2df)_mm_permutex2var_pd(__A, __I, __B), + (__v2df)_mm_setzero_pd()); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_permutex2var_pd(__m256d __A, __m256i __I, __m256d __B) { + return (__m256d)__builtin_ia32_vpermi2varpd256((__v4df)__A, (__v4di)__I, + (__v4df)__B); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_mask_permutex2var_pd(__m256d __A, __mmask8 __U, __m256i __I, + __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256(__U, + (__v4df)_mm256_permutex2var_pd(__A, __I, __B), + (__v4df)__A); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_mask2_permutex2var_pd(__m256d __A, __m256i __I, __mmask8 __U, + __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256(__U, + (__v4df)_mm256_permutex2var_pd(__A, __I, __B), + (__v4df)(__m256d)__I); + } + + static __inline__ __m256d __DEFAULT_FN_ATTRS256 + _mm256_maskz_permutex2var_pd(__mmask8 __U, __m256d __A, __m256i __I, + __m256d __B) { + return (__m256d)__builtin_ia32_selectpd_256(__U, + (__v4df)_mm256_permutex2var_pd(__A, __I, __B), + (__v4df)_mm256_setzero_pd()); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_permutex2var_ps(__m128 __A, __m128i __I, __m128 __B) { + return (__m128)__builtin_ia32_vpermi2varps128((__v4sf)__A, (__v4si)__I, + (__v4sf)__B); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_mask_permutex2var_ps(__m128 __A, __mmask8 __U, __m128i __I, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128(__U, + (__v4sf)_mm_permutex2var_ps(__A, __I, __B), + (__v4sf)__A); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_mask2_permutex2var_ps(__m128 __A, __m128i __I, __mmask8 __U, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128(__U, + (__v4sf)_mm_permutex2var_ps(__A, __I, __B), + (__v4sf)(__m128)__I); + } + + static __inline__ __m128 __DEFAULT_FN_ATTRS128 + _mm_maskz_permutex2var_ps(__mmask8 __U, __m128 __A, __m128i __I, __m128 __B) { + return (__m128)__builtin_ia32_selectps_128(__U, + (__v4sf)_mm_permutex2var_ps(__A, __I, __B), + (__v4sf)_mm_setzero_ps()); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_permutex2var_ps(__m256 __A, __m256i __I, __m256 __B) { + return (__m256)__builtin_ia32_vpermi2varps256((__v8sf)__A, (__v8si)__I, + (__v8sf) __B); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_mask_permutex2var_ps(__m256 __A, __mmask8 __U, __m256i __I, __m256 __B) { + return (__m256)__builtin_ia32_selectps_256(__U, + (__v8sf)_mm256_permutex2var_ps(__A, __I, __B), + (__v8sf)__A); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_mask2_permutex2var_ps(__m256 __A, __m256i __I, __mmask8 __U, + __m256 __B) { + return (__m256)__builtin_ia32_selectps_256(__U, + (__v8sf)_mm256_permutex2var_ps(__A, __I, __B), + (__v8sf)(__m256)__I); + } + + static __inline__ __m256 __DEFAULT_FN_ATTRS256 + _mm256_maskz_permutex2var_ps(__mmask8 __U, __m256 __A, __m256i __I, + __m256 __B) { + return (__m256)__builtin_ia32_selectps_256(__U, + (__v8sf)_mm256_permutex2var_ps(__A, __I, __B), + (__v8sf)_mm256_setzero_ps()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_permutex2var_epi64(__m128i __A, __m128i __I, __m128i __B) { + return (__m128i)__builtin_ia32_vpermi2varq128((__v2di)__A, (__v2di)__I, + (__v2di)__B); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_permutex2var_epi64(__m128i __A, __mmask8 __U, __m128i __I, + __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_permutex2var_epi64(__A, __I, __B), + (__v2di)__A); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask2_permutex2var_epi64(__m128i __A, __m128i __I, __mmask8 __U, + __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_permutex2var_epi64(__A, __I, __B), + (__v2di)__I); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_permutex2var_epi64(__mmask8 __U, __m128i __A, __m128i __I, + __m128i __B) { + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_permutex2var_epi64(__A, __I, __B), + (__v2di)_mm_setzero_si128()); + } + + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_permutex2var_epi64(__m256i __A, __m256i __I, __m256i __B) { + return (__m256i)__builtin_ia32_vpermi2varq256((__v4di)__A, (__v4di) __I, + (__v4di) __B); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_permutex2var_epi64(__m256i __A, __mmask8 __U, __m256i __I, + __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_permutex2var_epi64(__A, __I, __B), + (__v4di)__A); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask2_permutex2var_epi64(__m256i __A, __m256i __I, __mmask8 __U, + __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_permutex2var_epi64(__A, __I, __B), + (__v4di)__I); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_permutex2var_epi64(__mmask8 __U, __m256i __A, __m256i __I, + __m256i __B) { + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_permutex2var_epi64(__A, __I, __B), + (__v4di)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepi8_epi32(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepi8_epi32(__A), + (__v4si)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepi8_epi32(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepi8_epi32(__A), + (__v4si)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepi8_epi32 (__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepi8_epi32(__A), + (__v8si)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepi8_epi32 (__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepi8_epi32(__A), + (__v8si)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepi8_epi64(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepi8_epi64(__A), + (__v2di)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepi8_epi64(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepi8_epi64(__A), + (__v2di)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepi8_epi64(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepi8_epi64(__A), + (__v4di)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepi8_epi64(__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepi8_epi64(__A), + (__v4di)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepi32_epi64(__m128i __W, __mmask8 __U, __m128i __X) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepi32_epi64(__X), + (__v2di)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepi32_epi64(__mmask8 __U, __m128i __X) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepi32_epi64(__X), + (__v2di)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepi32_epi64(__m256i __W, __mmask8 __U, __m128i __X) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepi32_epi64(__X), + (__v4di)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepi32_epi64(__mmask8 __U, __m128i __X) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepi32_epi64(__X), + (__v4di)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepi16_epi32(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepi16_epi32(__A), + (__v4si)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepi16_epi32(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepi16_epi32(__A), + (__v4si)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepi16_epi32(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepi16_epi32(__A), + (__v8si)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepi16_epi32 (__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepi16_epi32(__A), + (__v8si)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepi16_epi64(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepi16_epi64(__A), + (__v2di)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepi16_epi64(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepi16_epi64(__A), + (__v2di)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepi16_epi64(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepi16_epi64(__A), + (__v4di)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepi16_epi64(__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepi16_epi64(__A), + (__v4di)_mm256_setzero_si256()); + } + + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepu8_epi32(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepu8_epi32(__A), + (__v4si)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepu8_epi32(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepu8_epi32(__A), + (__v4si)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepu8_epi32(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepu8_epi32(__A), + (__v8si)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepu8_epi32(__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepu8_epi32(__A), + (__v8si)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepu8_epi64(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepu8_epi64(__A), + (__v2di)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepu8_epi64(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepu8_epi64(__A), + (__v2di)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepu8_epi64(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepu8_epi64(__A), + (__v4di)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepu8_epi64 (__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepu8_epi64(__A), + (__v4di)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepu32_epi64(__m128i __W, __mmask8 __U, __m128i __X) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepu32_epi64(__X), + (__v2di)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepu32_epi64(__mmask8 __U, __m128i __X) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepu32_epi64(__X), + (__v2di)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepu32_epi64(__m256i __W, __mmask8 __U, __m128i __X) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepu32_epi64(__X), + (__v4di)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepu32_epi64(__mmask8 __U, __m128i __X) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepu32_epi64(__X), + (__v4di)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepu16_epi32(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepu16_epi32(__A), + (__v4si)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepu16_epi32(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_cvtepu16_epi32(__A), + (__v4si)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepu16_epi32(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepu16_epi32(__A), + (__v8si)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepu16_epi32(__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_cvtepu16_epi32(__A), + (__v8si)_mm256_setzero_si256()); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_mask_cvtepu16_epi64(__m128i __W, __mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepu16_epi64(__A), + (__v2di)__W); + } + + static __inline__ __m128i __DEFAULT_FN_ATTRS128 + _mm_maskz_cvtepu16_epi64(__mmask8 __U, __m128i __A) + { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_cvtepu16_epi64(__A), + (__v2di)_mm_setzero_si128()); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_mask_cvtepu16_epi64(__m256i __W, __mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepu16_epi64(__A), + (__v4di)__W); + } + + static __inline__ __m256i __DEFAULT_FN_ATTRS256 + _mm256_maskz_cvtepu16_epi64(__mmask8 __U, __m128i __A) + { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_cvtepu16_epi64(__A), + (__v4di)_mm256_setzero_si256()); + } + + +#define _mm_rol_epi32(a, b) \ + ((__m128i)__builtin_ia32_prold128((__v4si)(__m128i)(a), (int)(b))) + +#define _mm_mask_rol_epi32(w, u, a, b) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(u), \ + (__v4si)_mm_rol_epi32((a), (b)), \ + (__v4si)(__m128i)(w))) + +#define _mm_maskz_rol_epi32(u, a, b) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(u), \ + (__v4si)_mm_rol_epi32((a), (b)), \ + (__v4si)_mm_setzero_si128())) + +#define _mm256_rol_epi32(a, b) \ + ((__m256i)__builtin_ia32_prold256((__v8si)(__m256i)(a), (int)(b))) + +#define _mm256_mask_rol_epi32(w, u, a, b) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(u), \ + (__v8si)_mm256_rol_epi32((a), (b)), \ + (__v8si)(__m256i)(w))) + +#define _mm256_maskz_rol_epi32(u, a, b) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(u), \ + (__v8si)_mm256_rol_epi32((a), (b)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_rol_epi64(a, b) \ + ((__m128i)__builtin_ia32_prolq128((__v2di)(__m128i)(a), (int)(b))) + +#define _mm_mask_rol_epi64(w, u, a, b) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(u), \ + (__v2di)_mm_rol_epi64((a), (b)), \ + (__v2di)(__m128i)(w))) + +#define _mm_maskz_rol_epi64(u, a, b) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(u), \ + (__v2di)_mm_rol_epi64((a), (b)), \ + (__v2di)_mm_setzero_si128())) + +#define _mm256_rol_epi64(a, b) \ + ((__m256i)__builtin_ia32_prolq256((__v4di)(__m256i)(a), (int)(b))) + +#define _mm256_mask_rol_epi64(w, u, a, b) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(u), \ + (__v4di)_mm256_rol_epi64((a), (b)), \ + (__v4di)(__m256i)(w))) + +#define _mm256_maskz_rol_epi64(u, a, b) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(u), \ + (__v4di)_mm256_rol_epi64((a), (b)), \ + (__v4di)_mm256_setzero_si256())) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_rolv_epi32 (__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_prolvd128((__v4si)__A, (__v4si)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_rolv_epi32 (__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_rolv_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_rolv_epi32 (__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_rolv_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_rolv_epi32 (__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_prolvd256((__v8si)__A, (__v8si)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_rolv_epi32 (__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_rolv_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_rolv_epi32 (__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_rolv_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_rolv_epi64 (__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_prolvq128((__v2di)__A, (__v2di)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_rolv_epi64 (__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_rolv_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_rolv_epi64 (__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_rolv_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_rolv_epi64 (__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_prolvq256((__v4di)__A, (__v4di)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_rolv_epi64 (__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_rolv_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_rolv_epi64 (__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_rolv_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +#define _mm_ror_epi32(a, b) \ + ((__m128i)__builtin_ia32_prord128((__v4si)(__m128i)(a), (int)(b))) + +#define _mm_mask_ror_epi32(w, u, a, b) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(u), \ + (__v4si)_mm_ror_epi32((a), (b)), \ + (__v4si)(__m128i)(w))) + +#define _mm_maskz_ror_epi32(u, a, b) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(u), \ + (__v4si)_mm_ror_epi32((a), (b)), \ + (__v4si)_mm_setzero_si128())) + +#define _mm256_ror_epi32(a, b) \ + ((__m256i)__builtin_ia32_prord256((__v8si)(__m256i)(a), (int)(b))) + +#define _mm256_mask_ror_epi32(w, u, a, b) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(u), \ + (__v8si)_mm256_ror_epi32((a), (b)), \ + (__v8si)(__m256i)(w))) + +#define _mm256_maskz_ror_epi32(u, a, b) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(u), \ + (__v8si)_mm256_ror_epi32((a), (b)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_ror_epi64(a, b) \ + ((__m128i)__builtin_ia32_prorq128((__v2di)(__m128i)(a), (int)(b))) + +#define _mm_mask_ror_epi64(w, u, a, b) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(u), \ + (__v2di)_mm_ror_epi64((a), (b)), \ + (__v2di)(__m128i)(w))) + +#define _mm_maskz_ror_epi64(u, a, b) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(u), \ + (__v2di)_mm_ror_epi64((a), (b)), \ + (__v2di)_mm_setzero_si128())) + +#define _mm256_ror_epi64(a, b) \ + ((__m256i)__builtin_ia32_prorq256((__v4di)(__m256i)(a), (int)(b))) + +#define _mm256_mask_ror_epi64(w, u, a, b) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(u), \ + (__v4di)_mm256_ror_epi64((a), (b)), \ + (__v4di)(__m256i)(w))) + +#define _mm256_maskz_ror_epi64(u, a, b) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(u), \ + (__v4di)_mm256_ror_epi64((a), (b)), \ + (__v4di)_mm256_setzero_si256())) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sll_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sll_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sll_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sll_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sll_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sll_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sll_epi32(__mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sll_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_slli_epi32(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_slli_epi32(__A, (int)__B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_slli_epi32(__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_slli_epi32(__A, (int)__B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_slli_epi32(__m256i __W, __mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_slli_epi32(__A, (int)__B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_slli_epi32(__mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_slli_epi32(__A, (int)__B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sll_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_sll_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sll_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_sll_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sll_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_sll_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sll_epi64(__mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_sll_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_slli_epi64(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_slli_epi64(__A, (int)__B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_slli_epi64(__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_slli_epi64(__A, (int)__B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_slli_epi64(__m256i __W, __mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_slli_epi64(__A, (int)__B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_slli_epi64(__mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_slli_epi64(__A, (int)__B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_rorv_epi32 (__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_prorvd128((__v4si)__A, (__v4si)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_rorv_epi32 (__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_rorv_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_rorv_epi32 (__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_rorv_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_rorv_epi32 (__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_prorvd256((__v8si)__A, (__v8si)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_rorv_epi32 (__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_rorv_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_rorv_epi32 (__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_rorv_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_rorv_epi64 (__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_prorvq128((__v2di)__A, (__v2di)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_rorv_epi64 (__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_rorv_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_rorv_epi64 (__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_rorv_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_rorv_epi64 (__m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_prorvq256((__v4di)__A, (__v4di)__B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_rorv_epi64 (__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_rorv_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_rorv_epi64 (__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_rorv_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sllv_epi64(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_sllv_epi64(__X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sllv_epi64(__mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_sllv_epi64(__X, __Y), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sllv_epi64(__m256i __W, __mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_sllv_epi64(__X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sllv_epi64(__mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_sllv_epi64(__X, __Y), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sllv_epi32(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sllv_epi32(__X, __Y), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sllv_epi32(__mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sllv_epi32(__X, __Y), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sllv_epi32(__m256i __W, __mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sllv_epi32(__X, __Y), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sllv_epi32(__mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sllv_epi32(__X, __Y), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srlv_epi64(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srlv_epi64(__X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srlv_epi64(__mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srlv_epi64(__X, __Y), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srlv_epi64(__m256i __W, __mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srlv_epi64(__X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srlv_epi64(__mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srlv_epi64(__X, __Y), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srlv_epi32(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srlv_epi32(__X, __Y), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srlv_epi32(__mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srlv_epi32(__X, __Y), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srlv_epi32(__m256i __W, __mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srlv_epi32(__X, __Y), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srlv_epi32(__mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srlv_epi32(__X, __Y), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srl_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srl_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srl_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srl_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srl_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srl_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srl_epi32(__mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srl_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srli_epi32(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srli_epi32(__A, (int)__B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srli_epi32(__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srli_epi32(__A, (int)__B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srli_epi32(__m256i __W, __mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srli_epi32(__A, (int)__B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srli_epi32(__mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srli_epi32(__A, (int)__B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srl_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srl_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srl_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srl_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srl_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srl_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srl_epi64(__mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srl_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srli_epi64(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srli_epi64(__A, (int)__B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srli_epi64(__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srli_epi64(__A, (int)__B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srli_epi64(__m256i __W, __mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srli_epi64(__A, (int)__B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srli_epi64(__mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srli_epi64(__A, (int)__B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srav_epi32(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srav_epi32(__X, __Y), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srav_epi32(__mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srav_epi32(__X, __Y), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srav_epi32(__m256i __W, __mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srav_epi32(__X, __Y), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srav_epi32(__mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srav_epi32(__X, __Y), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srav_epi64(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_psravq128((__v2di)__X, (__v2di)__Y); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srav_epi64(__m128i __W, __mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srav_epi64(__X, __Y), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srav_epi64(__mmask8 __U, __m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_srav_epi64(__X, __Y), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srav_epi64(__m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_psravq256((__v4di)__X, (__v4di) __Y); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srav_epi64(__m256i __W, __mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srav_epi64(__X, __Y), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srav_epi64 (__mmask8 __U, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_srav_epi64(__X, __Y), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mov_epi32 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectd_128 ((__mmask8) __U, + (__v4si) __A, + (__v4si) __W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mov_epi32 (__mmask8 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectd_128 ((__mmask8) __U, + (__v4si) __A, + (__v4si) _mm_setzero_si128 ()); +} + + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mov_epi32 (__m256i __W, __mmask8 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectd_256 ((__mmask8) __U, + (__v8si) __A, + (__v8si) __W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mov_epi32 (__mmask8 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectd_256 ((__mmask8) __U, + (__v8si) __A, + (__v8si) _mm256_setzero_si256 ()); +} + +static __inline __m128i __DEFAULT_FN_ATTRS128 +_mm_load_epi32 (void const *__P) +{ + return *(const __m128i *) __P; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_load_epi32 (__m128i __W, __mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_movdqa32load128_mask ((const __v4si *) __P, + (__v4si) __W, + (__mmask8) + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_load_epi32 (__mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_movdqa32load128_mask ((const __v4si *) __P, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) + __U); +} + +static __inline __m256i __DEFAULT_FN_ATTRS256 +_mm256_load_epi32 (void const *__P) +{ + return *(const __m256i *) __P; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_load_epi32 (__m256i __W, __mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_movdqa32load256_mask ((const __v8si *) __P, + (__v8si) __W, + (__mmask8) + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_load_epi32 (__mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_movdqa32load256_mask ((const __v8si *) __P, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) + __U); +} + +static __inline void __DEFAULT_FN_ATTRS128 +_mm_store_epi32 (void *__P, __m128i __A) +{ + *(__m128i *) __P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_store_epi32 (void *__P, __mmask8 __U, __m128i __A) +{ + __builtin_ia32_movdqa32store128_mask ((__v4si *) __P, + (__v4si) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS256 +_mm256_store_epi32 (void *__P, __m256i __A) +{ + *(__m256i *) __P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_store_epi32 (void *__P, __mmask8 __U, __m256i __A) +{ + __builtin_ia32_movdqa32store256_mask ((__v8si *) __P, + (__v8si) __A, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_mov_epi64 (__m128i __W, __mmask8 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectq_128 ((__mmask8) __U, + (__v2di) __A, + (__v2di) __W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_mov_epi64 (__mmask8 __U, __m128i __A) +{ + return (__m128i) __builtin_ia32_selectq_128 ((__mmask8) __U, + (__v2di) __A, + (__v2di) _mm_setzero_si128 ()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_mov_epi64 (__m256i __W, __mmask8 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectq_256 ((__mmask8) __U, + (__v4di) __A, + (__v4di) __W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_mov_epi64 (__mmask8 __U, __m256i __A) +{ + return (__m256i) __builtin_ia32_selectq_256 ((__mmask8) __U, + (__v4di) __A, + (__v4di) _mm256_setzero_si256 ()); +} + +static __inline __m128i __DEFAULT_FN_ATTRS128 +_mm_load_epi64 (void const *__P) +{ + return *(const __m128i *) __P; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_load_epi64 (__m128i __W, __mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_movdqa64load128_mask ((const __v2di *) __P, + (__v2di) __W, + (__mmask8) + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_load_epi64 (__mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_movdqa64load128_mask ((const __v2di *) __P, + (__v2di) + _mm_setzero_si128 (), + (__mmask8) + __U); +} + +static __inline __m256i __DEFAULT_FN_ATTRS256 +_mm256_load_epi64 (void const *__P) +{ + return *(const __m256i *) __P; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_load_epi64 (__m256i __W, __mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_movdqa64load256_mask ((const __v4di *) __P, + (__v4di) __W, + (__mmask8) + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_load_epi64 (__mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_movdqa64load256_mask ((const __v4di *) __P, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) + __U); +} + +static __inline void __DEFAULT_FN_ATTRS128 +_mm_store_epi64 (void *__P, __m128i __A) +{ + *(__m128i *) __P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_store_epi64 (void *__P, __mmask8 __U, __m128i __A) +{ + __builtin_ia32_movdqa64store128_mask ((__v2di *) __P, + (__v2di) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS256 +_mm256_store_epi64 (void *__P, __m256i __A) +{ + *(__m256i *) __P = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_store_epi64 (void *__P, __mmask8 __U, __m256i __A) +{ + __builtin_ia32_movdqa64store256_mask ((__v4di *) __P, + (__v4di) __A, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_movedup_pd (__m128d __W, __mmask8 __U, __m128d __A) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_movedup_pd(__A), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_movedup_pd (__mmask8 __U, __m128d __A) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_movedup_pd(__A), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_movedup_pd (__m256d __W, __mmask8 __U, __m256d __A) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_movedup_pd(__A), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_movedup_pd (__mmask8 __U, __m256d __A) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_movedup_pd(__A), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_set1_epi32(__m128i __O, __mmask8 __M, int __A) +{ + return (__m128i)__builtin_ia32_selectd_128(__M, + (__v4si) _mm_set1_epi32(__A), + (__v4si)__O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_set1_epi32( __mmask8 __M, int __A) +{ + return (__m128i)__builtin_ia32_selectd_128(__M, + (__v4si) _mm_set1_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_set1_epi32(__m256i __O, __mmask8 __M, int __A) +{ + return (__m256i)__builtin_ia32_selectd_256(__M, + (__v8si) _mm256_set1_epi32(__A), + (__v8si)__O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_set1_epi32( __mmask8 __M, int __A) +{ + return (__m256i)__builtin_ia32_selectd_256(__M, + (__v8si) _mm256_set1_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_set1_epi64 (__m128i __O, __mmask8 __M, long long __A) +{ + return (__m128i) __builtin_ia32_selectq_128(__M, + (__v2di) _mm_set1_epi64x(__A), + (__v2di) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_set1_epi64 (__mmask8 __M, long long __A) +{ + return (__m128i) __builtin_ia32_selectq_128(__M, + (__v2di) _mm_set1_epi64x(__A), + (__v2di) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_set1_epi64 (__m256i __O, __mmask8 __M, long long __A) +{ + return (__m256i) __builtin_ia32_selectq_256(__M, + (__v4di) _mm256_set1_epi64x(__A), + (__v4di) __O) ; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_set1_epi64 (__mmask8 __M, long long __A) +{ + return (__m256i) __builtin_ia32_selectq_256(__M, + (__v4di) _mm256_set1_epi64x(__A), + (__v4di) _mm256_setzero_si256()); +} + +#define _mm_fixupimm_pd(A, B, C, imm) \ + ((__m128d)__builtin_ia32_fixupimmpd128_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_mask_fixupimm_pd(A, U, B, C, imm) \ + ((__m128d)__builtin_ia32_fixupimmpd128_mask((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), (int)(imm), \ + (__mmask8)(U))) + +#define _mm_maskz_fixupimm_pd(U, A, B, C, imm) \ + ((__m128d)__builtin_ia32_fixupimmpd128_maskz((__v2df)(__m128d)(A), \ + (__v2df)(__m128d)(B), \ + (__v2di)(__m128i)(C), \ + (int)(imm), (__mmask8)(U))) + +#define _mm256_fixupimm_pd(A, B, C, imm) \ + ((__m256d)__builtin_ia32_fixupimmpd256_mask((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), \ + (__v4di)(__m256i)(C), (int)(imm), \ + (__mmask8)-1)) + +#define _mm256_mask_fixupimm_pd(A, U, B, C, imm) \ + ((__m256d)__builtin_ia32_fixupimmpd256_mask((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), \ + (__v4di)(__m256i)(C), (int)(imm), \ + (__mmask8)(U))) + +#define _mm256_maskz_fixupimm_pd(U, A, B, C, imm) \ + ((__m256d)__builtin_ia32_fixupimmpd256_maskz((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), \ + (__v4di)(__m256i)(C), \ + (int)(imm), (__mmask8)(U))) + +#define _mm_fixupimm_ps(A, B, C, imm) \ + ((__m128)__builtin_ia32_fixupimmps128_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)-1)) + +#define _mm_mask_fixupimm_ps(A, U, B, C, imm) \ + ((__m128)__builtin_ia32_fixupimmps128_mask((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)(U))) + +#define _mm_maskz_fixupimm_ps(U, A, B, C, imm) \ + ((__m128)__builtin_ia32_fixupimmps128_maskz((__v4sf)(__m128)(A), \ + (__v4sf)(__m128)(B), \ + (__v4si)(__m128i)(C), (int)(imm), \ + (__mmask8)(U))) + +#define _mm256_fixupimm_ps(A, B, C, imm) \ + ((__m256)__builtin_ia32_fixupimmps256_mask((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), \ + (__v8si)(__m256i)(C), (int)(imm), \ + (__mmask8)-1)) + +#define _mm256_mask_fixupimm_ps(A, U, B, C, imm) \ + ((__m256)__builtin_ia32_fixupimmps256_mask((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), \ + (__v8si)(__m256i)(C), (int)(imm), \ + (__mmask8)(U))) + +#define _mm256_maskz_fixupimm_ps(U, A, B, C, imm) \ + ((__m256)__builtin_ia32_fixupimmps256_maskz((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), \ + (__v8si)(__m256i)(C), (int)(imm), \ + (__mmask8)(U))) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_load_pd (__m128d __W, __mmask8 __U, void const *__P) +{ + return (__m128d) __builtin_ia32_loadapd128_mask ((const __v2df *) __P, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_load_pd (__mmask8 __U, void const *__P) +{ + return (__m128d) __builtin_ia32_loadapd128_mask ((const __v2df *) __P, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_load_pd (__m256d __W, __mmask8 __U, void const *__P) +{ + return (__m256d) __builtin_ia32_loadapd256_mask ((const __v4df *) __P, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_load_pd (__mmask8 __U, void const *__P) +{ + return (__m256d) __builtin_ia32_loadapd256_mask ((const __v4df *) __P, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_load_ps (__m128 __W, __mmask8 __U, void const *__P) +{ + return (__m128) __builtin_ia32_loadaps128_mask ((const __v4sf *) __P, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_load_ps (__mmask8 __U, void const *__P) +{ + return (__m128) __builtin_ia32_loadaps128_mask ((const __v4sf *) __P, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_load_ps (__m256 __W, __mmask8 __U, void const *__P) +{ + return (__m256) __builtin_ia32_loadaps256_mask ((const __v8sf *) __P, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_load_ps (__mmask8 __U, void const *__P) +{ + return (__m256) __builtin_ia32_loadaps256_mask ((const __v8sf *) __P, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +static __inline __m128i __DEFAULT_FN_ATTRS128 +_mm_loadu_epi64 (void const *__P) +{ + struct __loadu_epi64 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi64*)__P)->__v; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadu_epi64 (__m128i __W, __mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddqudi128_mask ((const __v2di *) __P, + (__v2di) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadu_epi64 (__mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddqudi128_mask ((const __v2di *) __P, + (__v2di) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadu_epi64 (void const *__P) +{ + struct __loadu_epi64 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi64*)__P)->__v; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadu_epi64 (__m256i __W, __mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddqudi256_mask ((const __v4di *) __P, + (__v4di) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadu_epi64 (__mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddqudi256_mask ((const __v4di *) __P, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline __m128i __DEFAULT_FN_ATTRS128 +_mm_loadu_epi32 (void const *__P) +{ + struct __loadu_epi32 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi32*)__P)->__v; +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadu_epi32 (__m128i __W, __mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddqusi128_mask ((const __v4si *) __P, + (__v4si) __W, + (__mmask8) __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadu_epi32 (__mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_loaddqusi128_mask ((const __v4si *) __P, + (__v4si) + _mm_setzero_si128 (), + (__mmask8) __U); +} + +static __inline __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadu_epi32 (void const *__P) +{ + struct __loadu_epi32 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_epi32*)__P)->__v; +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadu_epi32 (__m256i __W, __mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddqusi256_mask ((const __v8si *) __P, + (__v8si) __W, + (__mmask8) __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadu_epi32 (__mmask8 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_loaddqusi256_mask ((const __v8si *) __P, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_loadu_pd (__m128d __W, __mmask8 __U, void const *__P) +{ + return (__m128d) __builtin_ia32_loadupd128_mask ((const __v2df *) __P, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_loadu_pd (__mmask8 __U, void const *__P) +{ + return (__m128d) __builtin_ia32_loadupd128_mask ((const __v2df *) __P, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_loadu_pd (__m256d __W, __mmask8 __U, void const *__P) +{ + return (__m256d) __builtin_ia32_loadupd256_mask ((const __v4df *) __P, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadu_pd (__mmask8 __U, void const *__P) +{ + return (__m256d) __builtin_ia32_loadupd256_mask ((const __v4df *) __P, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_loadu_ps (__m128 __W, __mmask8 __U, void const *__P) +{ + return (__m128) __builtin_ia32_loadups128_mask ((const __v4sf *) __P, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_loadu_ps (__mmask8 __U, void const *__P) +{ + return (__m128) __builtin_ia32_loadups128_mask ((const __v4sf *) __P, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_loadu_ps (__m256 __W, __mmask8 __U, void const *__P) +{ + return (__m256) __builtin_ia32_loadups256_mask ((const __v8sf *) __P, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadu_ps (__mmask8 __U, void const *__P) +{ + return (__m256) __builtin_ia32_loadups256_mask ((const __v8sf *) __P, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_store_pd (void *__P, __mmask8 __U, __m128d __A) +{ + __builtin_ia32_storeapd128_mask ((__v2df *) __P, + (__v2df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_store_pd (void *__P, __mmask8 __U, __m256d __A) +{ + __builtin_ia32_storeapd256_mask ((__v4df *) __P, + (__v4df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_store_ps (void *__P, __mmask8 __U, __m128 __A) +{ + __builtin_ia32_storeaps128_mask ((__v4sf *) __P, + (__v4sf) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_store_ps (void *__P, __mmask8 __U, __m256 __A) +{ + __builtin_ia32_storeaps256_mask ((__v8sf *) __P, + (__v8sf) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS128 +_mm_storeu_epi64 (void *__P, __m128i __A) +{ + struct __storeu_epi64 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi64*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_storeu_epi64 (void *__P, __mmask8 __U, __m128i __A) +{ + __builtin_ia32_storedqudi128_mask ((__v2di *) __P, + (__v2di) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS256 +_mm256_storeu_epi64 (void *__P, __m256i __A) +{ + struct __storeu_epi64 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi64*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_storeu_epi64 (void *__P, __mmask8 __U, __m256i __A) +{ + __builtin_ia32_storedqudi256_mask ((__v4di *) __P, + (__v4di) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS128 +_mm_storeu_epi32 (void *__P, __m128i __A) +{ + struct __storeu_epi32 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi32*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_storeu_epi32 (void *__P, __mmask8 __U, __m128i __A) +{ + __builtin_ia32_storedqusi128_mask ((__v4si *) __P, + (__v4si) __A, + (__mmask8) __U); +} + +static __inline void __DEFAULT_FN_ATTRS256 +_mm256_storeu_epi32 (void *__P, __m256i __A) +{ + struct __storeu_epi32 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_epi32*)__P)->__v = __A; +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_storeu_epi32 (void *__P, __mmask8 __U, __m256i __A) +{ + __builtin_ia32_storedqusi256_mask ((__v8si *) __P, + (__v8si) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_storeu_pd (void *__P, __mmask8 __U, __m128d __A) +{ + __builtin_ia32_storeupd128_mask ((__v2df *) __P, + (__v2df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_storeu_pd (void *__P, __mmask8 __U, __m256d __A) +{ + __builtin_ia32_storeupd256_mask ((__v4df *) __P, + (__v4df) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_storeu_ps (void *__P, __mmask8 __U, __m128 __A) +{ + __builtin_ia32_storeups128_mask ((__v4sf *) __P, + (__v4sf) __A, + (__mmask8) __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_storeu_ps (void *__P, __mmask8 __U, __m256 __A) +{ + __builtin_ia32_storeups256_mask ((__v8sf *) __P, + (__v8sf) __A, + (__mmask8) __U); +} + + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_unpackhi_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_unpackhi_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_unpackhi_pd(__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_unpackhi_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_unpackhi_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_unpackhi_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpackhi_pd(__mmask8 __U, __m256d __A, __m256d __B) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_unpackhi_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_unpackhi_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_unpackhi_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_unpackhi_ps(__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_unpackhi_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_unpackhi_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_unpackhi_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpackhi_ps(__mmask8 __U, __m256 __A, __m256 __B) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_unpackhi_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_unpacklo_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_unpacklo_pd(__A, __B), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_unpacklo_pd(__mmask8 __U, __m128d __A, __m128d __B) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_unpacklo_pd(__A, __B), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_unpacklo_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_unpacklo_pd(__A, __B), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpacklo_pd(__mmask8 __U, __m256d __A, __m256d __B) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_unpacklo_pd(__A, __B), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_unpacklo_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_unpacklo_ps(__A, __B), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_unpacklo_ps(__mmask8 __U, __m128 __A, __m128 __B) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_unpacklo_ps(__A, __B), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_unpacklo_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_unpacklo_ps(__A, __B), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpacklo_ps(__mmask8 __U, __m256 __A, __m256 __B) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_unpacklo_ps(__A, __B), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_rcp14_pd (__m128d __A) +{ + return (__m128d) __builtin_ia32_rcp14pd128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_rcp14_pd (__m128d __W, __mmask8 __U, __m128d __A) +{ + return (__m128d) __builtin_ia32_rcp14pd128_mask ((__v2df) __A, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_rcp14_pd (__mmask8 __U, __m128d __A) +{ + return (__m128d) __builtin_ia32_rcp14pd128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_rcp14_pd (__m256d __A) +{ + return (__m256d) __builtin_ia32_rcp14pd256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_rcp14_pd (__m256d __W, __mmask8 __U, __m256d __A) +{ + return (__m256d) __builtin_ia32_rcp14pd256_mask ((__v4df) __A, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_rcp14_pd (__mmask8 __U, __m256d __A) +{ + return (__m256d) __builtin_ia32_rcp14pd256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_rcp14_ps (__m128 __A) +{ + return (__m128) __builtin_ia32_rcp14ps128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_rcp14_ps (__m128 __W, __mmask8 __U, __m128 __A) +{ + return (__m128) __builtin_ia32_rcp14ps128_mask ((__v4sf) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_rcp14_ps (__mmask8 __U, __m128 __A) +{ + return (__m128) __builtin_ia32_rcp14ps128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_rcp14_ps (__m256 __A) +{ + return (__m256) __builtin_ia32_rcp14ps256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_rcp14_ps (__m256 __W, __mmask8 __U, __m256 __A) +{ + return (__m256) __builtin_ia32_rcp14ps256_mask ((__v8sf) __A, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_rcp14_ps (__mmask8 __U, __m256 __A) +{ + return (__m256) __builtin_ia32_rcp14ps256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +#define _mm_mask_permute_pd(W, U, X, C) \ + ((__m128d)__builtin_ia32_selectpd_128((__mmask8)(U), \ + (__v2df)_mm_permute_pd((X), (C)), \ + (__v2df)(__m128d)(W))) + +#define _mm_maskz_permute_pd(U, X, C) \ + ((__m128d)__builtin_ia32_selectpd_128((__mmask8)(U), \ + (__v2df)_mm_permute_pd((X), (C)), \ + (__v2df)_mm_setzero_pd())) + +#define _mm256_mask_permute_pd(W, U, X, C) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_permute_pd((X), (C)), \ + (__v4df)(__m256d)(W))) + +#define _mm256_maskz_permute_pd(U, X, C) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_permute_pd((X), (C)), \ + (__v4df)_mm256_setzero_pd())) + +#define _mm_mask_permute_ps(W, U, X, C) \ + ((__m128)__builtin_ia32_selectps_128((__mmask8)(U), \ + (__v4sf)_mm_permute_ps((X), (C)), \ + (__v4sf)(__m128)(W))) + +#define _mm_maskz_permute_ps(U, X, C) \ + ((__m128)__builtin_ia32_selectps_128((__mmask8)(U), \ + (__v4sf)_mm_permute_ps((X), (C)), \ + (__v4sf)_mm_setzero_ps())) + +#define _mm256_mask_permute_ps(W, U, X, C) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_permute_ps((X), (C)), \ + (__v8sf)(__m256)(W))) + +#define _mm256_maskz_permute_ps(U, X, C) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_permute_ps((X), (C)), \ + (__v8sf)_mm256_setzero_ps())) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_permutevar_pd(__m128d __W, __mmask8 __U, __m128d __A, __m128i __C) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_permutevar_pd(__A, __C), + (__v2df)__W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_permutevar_pd(__mmask8 __U, __m128d __A, __m128i __C) +{ + return (__m128d)__builtin_ia32_selectpd_128((__mmask8)__U, + (__v2df)_mm_permutevar_pd(__A, __C), + (__v2df)_mm_setzero_pd()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_permutevar_pd(__m256d __W, __mmask8 __U, __m256d __A, __m256i __C) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_permutevar_pd(__A, __C), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutevar_pd(__mmask8 __U, __m256d __A, __m256i __C) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_permutevar_pd(__A, __C), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_permutevar_ps(__m128 __W, __mmask8 __U, __m128 __A, __m128i __C) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_permutevar_ps(__A, __C), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_permutevar_ps(__mmask8 __U, __m128 __A, __m128i __C) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_permutevar_ps(__A, __C), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_permutevar_ps(__m256 __W, __mmask8 __U, __m256 __A, __m256i __C) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_permutevar_ps(__A, __C), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutevar_ps(__mmask8 __U, __m256 __A, __m256i __C) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_permutevar_ps(__A, __C), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_test_epi32_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpneq_epi32_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_mask_test_epi32_mask (__mmask8 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpneq_epi32_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_test_epi32_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpneq_epi32_mask (_mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_mask_test_epi32_mask (__mmask8 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpneq_epi32_mask (__U, _mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_test_epi64_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpneq_epi64_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_mask_test_epi64_mask (__mmask8 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpneq_epi64_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_test_epi64_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpneq_epi64_mask (_mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_mask_test_epi64_mask (__mmask8 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpneq_epi64_mask (__U, _mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_testn_epi32_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpeq_epi32_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_mask_testn_epi32_mask (__mmask8 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpeq_epi32_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_testn_epi32_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpeq_epi32_mask (_mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_mask_testn_epi32_mask (__mmask8 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpeq_epi32_mask (__U, _mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_testn_epi64_mask (__m128i __A, __m128i __B) +{ + return _mm_cmpeq_epi64_mask (_mm_and_si128 (__A, __B), _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS128 +_mm_mask_testn_epi64_mask (__mmask8 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_cmpeq_epi64_mask (__U, _mm_and_si128 (__A, __B), + _mm_setzero_si128()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_testn_epi64_mask (__m256i __A, __m256i __B) +{ + return _mm256_cmpeq_epi64_mask (_mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __mmask8 __DEFAULT_FN_ATTRS256 +_mm256_mask_testn_epi64_mask (__mmask8 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_cmpeq_epi64_mask (__U, _mm256_and_si256 (__A, __B), + _mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpackhi_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_unpackhi_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpackhi_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_unpackhi_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpackhi_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_unpackhi_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpackhi_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_unpackhi_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpackhi_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_unpackhi_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpackhi_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_unpackhi_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpackhi_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_unpackhi_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpackhi_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_unpackhi_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpacklo_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_unpacklo_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpacklo_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_unpacklo_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpacklo_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_unpacklo_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpacklo_epi32(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_unpacklo_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_unpacklo_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_unpacklo_epi64(__A, __B), + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_unpacklo_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_unpacklo_epi64(__A, __B), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_unpacklo_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_unpacklo_epi64(__A, __B), + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_unpacklo_epi64(__mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_unpacklo_epi64(__A, __B), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sra_epi32(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sra_epi32(__A, __B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sra_epi32(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_sra_epi32(__A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sra_epi32(__m256i __W, __mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sra_epi32(__A, __B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sra_epi32(__mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_sra_epi32(__A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srai_epi32(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srai_epi32(__A, (int)__B), + (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srai_epi32(__mmask8 __U, __m128i __A, unsigned int __B) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_srai_epi32(__A, (int)__B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srai_epi32(__m256i __W, __mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srai_epi32(__A, (int)__B), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srai_epi32(__mmask8 __U, __m256i __A, unsigned int __B) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_srai_epi32(__A, (int)__B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_sra_epi64(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_psraq128((__v2di)__A, (__v2di)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_sra_epi64(__m128i __W, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, \ + (__v2di)_mm_sra_epi64(__A, __B), \ + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_sra_epi64(__mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, \ + (__v2di)_mm_sra_epi64(__A, __B), \ + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sra_epi64(__m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_psraq256((__v4di) __A, (__v2di) __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_sra_epi64(__m256i __W, __mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, \ + (__v4di)_mm256_sra_epi64(__A, __B), \ + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_sra_epi64(__mmask8 __U, __m256i __A, __m128i __B) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, \ + (__v4di)_mm256_sra_epi64(__A, __B), \ + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_srai_epi64(__m128i __A, unsigned int __imm) +{ + return (__m128i)__builtin_ia32_psraqi128((__v2di)__A, (int)__imm); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_srai_epi64(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __imm) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, \ + (__v2di)_mm_srai_epi64(__A, __imm), \ + (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_srai_epi64(__mmask8 __U, __m128i __A, unsigned int __imm) +{ + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, \ + (__v2di)_mm_srai_epi64(__A, __imm), \ + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_srai_epi64(__m256i __A, unsigned int __imm) +{ + return (__m256i)__builtin_ia32_psraqi256((__v4di)__A, (int)__imm); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_srai_epi64(__m256i __W, __mmask8 __U, __m256i __A, + unsigned int __imm) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, \ + (__v4di)_mm256_srai_epi64(__A, __imm), \ + (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_srai_epi64(__mmask8 __U, __m256i __A, unsigned int __imm) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, \ + (__v4di)_mm256_srai_epi64(__A, __imm), \ + (__v4di)_mm256_setzero_si256()); +} + +#define _mm_ternarylogic_epi32(A, B, C, imm) \ + ((__m128i)__builtin_ia32_pternlogd128_mask( \ + (__v4si)(__m128i)(A), (__v4si)(__m128i)(B), (__v4si)(__m128i)(C), \ + (unsigned char)(imm), (__mmask8)-1)) + +#define _mm_mask_ternarylogic_epi32(A, U, B, C, imm) \ + ((__m128i)__builtin_ia32_pternlogd128_mask( \ + (__v4si)(__m128i)(A), (__v4si)(__m128i)(B), (__v4si)(__m128i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm_maskz_ternarylogic_epi32(U, A, B, C, imm) \ + ((__m128i)__builtin_ia32_pternlogd128_maskz( \ + (__v4si)(__m128i)(A), (__v4si)(__m128i)(B), (__v4si)(__m128i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm256_ternarylogic_epi32(A, B, C, imm) \ + ((__m256i)__builtin_ia32_pternlogd256_mask( \ + (__v8si)(__m256i)(A), (__v8si)(__m256i)(B), (__v8si)(__m256i)(C), \ + (unsigned char)(imm), (__mmask8)-1)) + +#define _mm256_mask_ternarylogic_epi32(A, U, B, C, imm) \ + ((__m256i)__builtin_ia32_pternlogd256_mask( \ + (__v8si)(__m256i)(A), (__v8si)(__m256i)(B), (__v8si)(__m256i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm256_maskz_ternarylogic_epi32(U, A, B, C, imm) \ + ((__m256i)__builtin_ia32_pternlogd256_maskz( \ + (__v8si)(__m256i)(A), (__v8si)(__m256i)(B), (__v8si)(__m256i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm_ternarylogic_epi64(A, B, C, imm) \ + ((__m128i)__builtin_ia32_pternlogq128_mask( \ + (__v2di)(__m128i)(A), (__v2di)(__m128i)(B), (__v2di)(__m128i)(C), \ + (unsigned char)(imm), (__mmask8)-1)) + +#define _mm_mask_ternarylogic_epi64(A, U, B, C, imm) \ + ((__m128i)__builtin_ia32_pternlogq128_mask( \ + (__v2di)(__m128i)(A), (__v2di)(__m128i)(B), (__v2di)(__m128i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm_maskz_ternarylogic_epi64(U, A, B, C, imm) \ + ((__m128i)__builtin_ia32_pternlogq128_maskz( \ + (__v2di)(__m128i)(A), (__v2di)(__m128i)(B), (__v2di)(__m128i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm256_ternarylogic_epi64(A, B, C, imm) \ + ((__m256i)__builtin_ia32_pternlogq256_mask( \ + (__v4di)(__m256i)(A), (__v4di)(__m256i)(B), (__v4di)(__m256i)(C), \ + (unsigned char)(imm), (__mmask8)-1)) + +#define _mm256_mask_ternarylogic_epi64(A, U, B, C, imm) \ + ((__m256i)__builtin_ia32_pternlogq256_mask( \ + (__v4di)(__m256i)(A), (__v4di)(__m256i)(B), (__v4di)(__m256i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm256_maskz_ternarylogic_epi64(U, A, B, C, imm) \ + ((__m256i)__builtin_ia32_pternlogq256_maskz( \ + (__v4di)(__m256i)(A), (__v4di)(__m256i)(B), (__v4di)(__m256i)(C), \ + (unsigned char)(imm), (__mmask8)(U))) + +#define _mm256_shuffle_f32x4(A, B, imm) \ + ((__m256)__builtin_ia32_shuf_f32x4_256((__v8sf)(__m256)(A), \ + (__v8sf)(__m256)(B), (int)(imm))) + +#define _mm256_mask_shuffle_f32x4(W, U, A, B, imm) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_shuffle_f32x4((A), (B), (imm)), \ + (__v8sf)(__m256)(W))) + +#define _mm256_maskz_shuffle_f32x4(U, A, B, imm) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_shuffle_f32x4((A), (B), (imm)), \ + (__v8sf)_mm256_setzero_ps())) + +#define _mm256_shuffle_f64x2(A, B, imm) \ + ((__m256d)__builtin_ia32_shuf_f64x2_256((__v4df)(__m256d)(A), \ + (__v4df)(__m256d)(B), (int)(imm))) + +#define _mm256_mask_shuffle_f64x2(W, U, A, B, imm) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_shuffle_f64x2((A), (B), (imm)), \ + (__v4df)(__m256d)(W))) + +#define _mm256_maskz_shuffle_f64x2(U, A, B, imm) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_shuffle_f64x2((A), (B), (imm)), \ + (__v4df)_mm256_setzero_pd())) + +#define _mm256_shuffle_i32x4(A, B, imm) \ + ((__m256i)__builtin_ia32_shuf_i32x4_256((__v8si)(__m256i)(A), \ + (__v8si)(__m256i)(B), (int)(imm))) + +#define _mm256_mask_shuffle_i32x4(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shuffle_i32x4((A), (B), (imm)), \ + (__v8si)(__m256i)(W))) + +#define _mm256_maskz_shuffle_i32x4(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shuffle_i32x4((A), (B), (imm)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm256_shuffle_i64x2(A, B, imm) \ + ((__m256i)__builtin_ia32_shuf_i64x2_256((__v4di)(__m256i)(A), \ + (__v4di)(__m256i)(B), (int)(imm))) + +#define _mm256_mask_shuffle_i64x2(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_shuffle_i64x2((A), (B), (imm)), \ + (__v4di)(__m256i)(W))) + + +#define _mm256_maskz_shuffle_i64x2(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_shuffle_i64x2((A), (B), (imm)), \ + (__v4di)_mm256_setzero_si256())) + +#define _mm_mask_shuffle_pd(W, U, A, B, M) \ + ((__m128d)__builtin_ia32_selectpd_128((__mmask8)(U), \ + (__v2df)_mm_shuffle_pd((A), (B), (M)), \ + (__v2df)(__m128d)(W))) + +#define _mm_maskz_shuffle_pd(U, A, B, M) \ + ((__m128d)__builtin_ia32_selectpd_128((__mmask8)(U), \ + (__v2df)_mm_shuffle_pd((A), (B), (M)), \ + (__v2df)_mm_setzero_pd())) + +#define _mm256_mask_shuffle_pd(W, U, A, B, M) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_shuffle_pd((A), (B), (M)), \ + (__v4df)(__m256d)(W))) + +#define _mm256_maskz_shuffle_pd(U, A, B, M) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_shuffle_pd((A), (B), (M)), \ + (__v4df)_mm256_setzero_pd())) + +#define _mm_mask_shuffle_ps(W, U, A, B, M) \ + ((__m128)__builtin_ia32_selectps_128((__mmask8)(U), \ + (__v4sf)_mm_shuffle_ps((A), (B), (M)), \ + (__v4sf)(__m128)(W))) + +#define _mm_maskz_shuffle_ps(U, A, B, M) \ + ((__m128)__builtin_ia32_selectps_128((__mmask8)(U), \ + (__v4sf)_mm_shuffle_ps((A), (B), (M)), \ + (__v4sf)_mm_setzero_ps())) + +#define _mm256_mask_shuffle_ps(W, U, A, B, M) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_shuffle_ps((A), (B), (M)), \ + (__v8sf)(__m256)(W))) + +#define _mm256_maskz_shuffle_ps(U, A, B, M) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_shuffle_ps((A), (B), (M)), \ + (__v8sf)_mm256_setzero_ps())) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_rsqrt14_pd (__m128d __A) +{ + return (__m128d) __builtin_ia32_rsqrt14pd128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_rsqrt14_pd (__m128d __W, __mmask8 __U, __m128d __A) +{ + return (__m128d) __builtin_ia32_rsqrt14pd128_mask ((__v2df) __A, + (__v2df) __W, + (__mmask8) __U); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt14_pd (__mmask8 __U, __m128d __A) +{ + return (__m128d) __builtin_ia32_rsqrt14pd128_mask ((__v2df) __A, + (__v2df) + _mm_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_rsqrt14_pd (__m256d __A) +{ + return (__m256d) __builtin_ia32_rsqrt14pd256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) -1); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_rsqrt14_pd (__m256d __W, __mmask8 __U, __m256d __A) +{ + return (__m256d) __builtin_ia32_rsqrt14pd256_mask ((__v4df) __A, + (__v4df) __W, + (__mmask8) __U); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_rsqrt14_pd (__mmask8 __U, __m256d __A) +{ + return (__m256d) __builtin_ia32_rsqrt14pd256_mask ((__v4df) __A, + (__v4df) + _mm256_setzero_pd (), + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_rsqrt14_ps (__m128 __A) +{ + return (__m128) __builtin_ia32_rsqrt14ps128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_rsqrt14_ps (__m128 __W, __mmask8 __U, __m128 __A) +{ + return (__m128) __builtin_ia32_rsqrt14ps128_mask ((__v4sf) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_rsqrt14_ps (__mmask8 __U, __m128 __A) +{ + return (__m128) __builtin_ia32_rsqrt14ps128_mask ((__v4sf) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_rsqrt14_ps (__m256 __A) +{ + return (__m256) __builtin_ia32_rsqrt14ps256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) -1); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_rsqrt14_ps (__m256 __W, __mmask8 __U, __m256 __A) +{ + return (__m256) __builtin_ia32_rsqrt14ps256_mask ((__v8sf) __A, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_rsqrt14_ps (__mmask8 __U, __m256 __A) +{ + return (__m256) __builtin_ia32_rsqrt14ps256_mask ((__v8sf) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_broadcast_f32x4(__m128 __A) +{ + return (__m256)__builtin_shufflevector((__v4sf)__A, (__v4sf)__A, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcast_f32x4(__m256 __O, __mmask8 __M, __m128 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__M, + (__v8sf)_mm256_broadcast_f32x4(__A), + (__v8sf)__O); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcast_f32x4 (__mmask8 __M, __m128 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__M, + (__v8sf)_mm256_broadcast_f32x4(__A), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_broadcast_i32x4(__m128i __A) +{ + return (__m256i)__builtin_shufflevector((__v4si)__A, (__v4si)__A, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcast_i32x4(__m256i __O, __mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_broadcast_i32x4(__A), + (__v8si)__O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcast_i32x4(__mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_broadcast_i32x4(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcastsd_pd (__m256d __O, __mmask8 __M, __m128d __A) +{ + return (__m256d)__builtin_ia32_selectpd_256(__M, + (__v4df) _mm256_broadcastsd_pd(__A), + (__v4df) __O); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcastsd_pd (__mmask8 __M, __m128d __A) +{ + return (__m256d)__builtin_ia32_selectpd_256(__M, + (__v4df) _mm256_broadcastsd_pd(__A), + (__v4df) _mm256_setzero_pd()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_broadcastss_ps (__m128 __O, __mmask8 __M, __m128 __A) +{ + return (__m128)__builtin_ia32_selectps_128(__M, + (__v4sf) _mm_broadcastss_ps(__A), + (__v4sf) __O); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_broadcastss_ps (__mmask8 __M, __m128 __A) +{ + return (__m128)__builtin_ia32_selectps_128(__M, + (__v4sf) _mm_broadcastss_ps(__A), + (__v4sf) _mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcastss_ps (__m256 __O, __mmask8 __M, __m128 __A) +{ + return (__m256)__builtin_ia32_selectps_256(__M, + (__v8sf) _mm256_broadcastss_ps(__A), + (__v8sf) __O); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcastss_ps (__mmask8 __M, __m128 __A) +{ + return (__m256)__builtin_ia32_selectps_256(__M, + (__v8sf) _mm256_broadcastss_ps(__A), + (__v8sf) _mm256_setzero_ps()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_broadcastd_epi32 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128(__M, + (__v4si) _mm_broadcastd_epi32(__A), + (__v4si) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_broadcastd_epi32 (__mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectd_128(__M, + (__v4si) _mm_broadcastd_epi32(__A), + (__v4si) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcastd_epi32 (__m256i __O, __mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectd_256(__M, + (__v8si) _mm256_broadcastd_epi32(__A), + (__v8si) __O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcastd_epi32 (__mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectd_256(__M, + (__v8si) _mm256_broadcastd_epi32(__A), + (__v8si) _mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_broadcastq_epi64 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectq_128(__M, + (__v2di) _mm_broadcastq_epi64(__A), + (__v2di) __O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_broadcastq_epi64 (__mmask8 __M, __m128i __A) +{ + return (__m128i)__builtin_ia32_selectq_128(__M, + (__v2di) _mm_broadcastq_epi64(__A), + (__v2di) _mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_broadcastq_epi64 (__m256i __O, __mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectq_256(__M, + (__v4di) _mm256_broadcastq_epi64(__A), + (__v4di) __O); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_broadcastq_epi64 (__mmask8 __M, __m128i __A) +{ + return (__m256i)__builtin_ia32_selectq_256(__M, + (__v4di) _mm256_broadcastq_epi64(__A), + (__v4di) _mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtsepi32_epi8 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb128_mask ((__v4si) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi32_epi8 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb128_mask ((__v4si) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsepi32_epi8 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb128_mask ((__v4si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi32_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovsdb128mem_mask ((__v16qi *) __P, (__v4si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtsepi32_epi8 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb256_mask ((__v8si) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi32_epi8 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb256_mask ((__v8si) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtsepi32_epi8 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsdb256_mask ((__v8si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi32_storeu_epi8 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovsdb256mem_mask ((__v16qi *) __P, (__v8si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtsepi32_epi16 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsdw128_mask ((__v4si) __A, + (__v8hi)_mm_setzero_si128 (), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi32_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsdw128_mask ((__v4si) __A, + (__v8hi)__O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsepi32_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsdw128_mask ((__v4si) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi32_storeu_epi16 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovsdw128mem_mask ((__v8hi *) __P, (__v4si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtsepi32_epi16 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsdw256_mask ((__v8si) __A, + (__v8hi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi32_epi16 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsdw256_mask ((__v8si) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtsepi32_epi16 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsdw256_mask ((__v8si) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi32_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovsdw256mem_mask ((__v8hi *) __P, (__v8si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtsepi64_epi8 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb128_mask ((__v2di) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi64_epi8 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb128_mask ((__v2di) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsepi64_epi8 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb128_mask ((__v2di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi64_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovsqb128mem_mask ((__v16qi *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtsepi64_epi8 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb256_mask ((__v4di) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi64_epi8 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb256_mask ((__v4di) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtsepi64_epi8 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqb256_mask ((__v4di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi64_storeu_epi8 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovsqb256mem_mask ((__v16qi *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtsepi64_epi32 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqd128_mask ((__v2di) __A, + (__v4si)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi64_epi32 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqd128_mask ((__v2di) __A, + (__v4si) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsepi64_epi32 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqd128_mask ((__v2di) __A, + (__v4si) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi64_storeu_epi32 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovsqd128mem_mask ((__v4si *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtsepi64_epi32 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqd256_mask ((__v4di) __A, + (__v4si)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi64_epi32 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqd256_mask ((__v4di) __A, + (__v4si)__O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtsepi64_epi32 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqd256_mask ((__v4di) __A, + (__v4si) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi64_storeu_epi32 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovsqd256mem_mask ((__v4si *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtsepi64_epi16 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw128_mask ((__v2di) __A, + (__v8hi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi64_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw128_mask ((__v2di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtsepi64_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw128_mask ((__v2di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtsepi64_storeu_epi16 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovsqw128mem_mask ((__v8hi *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtsepi64_epi16 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw256_mask ((__v4di) __A, + (__v8hi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi64_epi16 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw256_mask ((__v4di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtsepi64_epi16 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovsqw256_mask ((__v4di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtsepi64_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovsqw256mem_mask ((__v8hi *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtusepi32_epi8 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb128_mask ((__v4si) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi32_epi8 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb128_mask ((__v4si) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtusepi32_epi8 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb128_mask ((__v4si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi32_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovusdb128mem_mask ((__v16qi *) __P, (__v4si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtusepi32_epi8 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb256_mask ((__v8si) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi32_epi8 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb256_mask ((__v8si) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtusepi32_epi8 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusdb256_mask ((__v8si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi32_storeu_epi8 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovusdb256mem_mask ((__v16qi*) __P, (__v8si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtusepi32_epi16 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusdw128_mask ((__v4si) __A, + (__v8hi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi32_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusdw128_mask ((__v4si) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtusepi32_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusdw128_mask ((__v4si) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi32_storeu_epi16 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovusdw128mem_mask ((__v8hi *) __P, (__v4si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtusepi32_epi16 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusdw256_mask ((__v8si) __A, + (__v8hi) _mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi32_epi16 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusdw256_mask ((__v8si) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtusepi32_epi16 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusdw256_mask ((__v8si) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi32_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovusdw256mem_mask ((__v8hi *) __P, (__v8si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtusepi64_epi8 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb128_mask ((__v2di) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi64_epi8 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb128_mask ((__v2di) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtusepi64_epi8 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb128_mask ((__v2di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi64_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovusqb128mem_mask ((__v16qi *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtusepi64_epi8 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb256_mask ((__v4di) __A, + (__v16qi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi64_epi8 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb256_mask ((__v4di) __A, + (__v16qi) __O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtusepi64_epi8 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqb256_mask ((__v4di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi64_storeu_epi8 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovusqb256mem_mask ((__v16qi *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtusepi64_epi32 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqd128_mask ((__v2di) __A, + (__v4si)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi64_epi32 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqd128_mask ((__v2di) __A, + (__v4si) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtusepi64_epi32 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqd128_mask ((__v2di) __A, + (__v4si) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi64_storeu_epi32 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovusqd128mem_mask ((__v4si *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtusepi64_epi32 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqd256_mask ((__v4di) __A, + (__v4si)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi64_epi32 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqd256_mask ((__v4di) __A, + (__v4si) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtusepi64_epi32 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqd256_mask ((__v4di) __A, + (__v4si) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi64_storeu_epi32 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovusqd256mem_mask ((__v4si *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtusepi64_epi16 (__m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw128_mask ((__v2di) __A, + (__v8hi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi64_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw128_mask ((__v2di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtusepi64_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw128_mask ((__v2di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtusepi64_storeu_epi16 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovusqw128mem_mask ((__v8hi *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtusepi64_epi16 (__m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw256_mask ((__v4di) __A, + (__v8hi)_mm_undefined_si128(), + (__mmask8) -1); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi64_epi16 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw256_mask ((__v4di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtusepi64_epi16 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovusqw256_mask ((__v4di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtusepi64_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovusqw256mem_mask ((__v8hi *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtepi32_epi8 (__m128i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v4si)__A, __v4qi), (__v4qi){0, 0, 0, 0}, 0, 1, + 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_epi8 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovdb128_mask ((__v4si) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi32_epi8 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovdb128_mask ((__v4si) __A, + (__v16qi) + _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovdb128mem_mask ((__v16qi *) __P, (__v4si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi32_epi8 (__m256i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v8si)__A, __v8qi), + (__v8qi){0, 0, 0, 0, 0, 0, 0, 0}, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_epi8 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovdb256_mask ((__v8si) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi32_epi8 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovdb256_mask ((__v8si) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_storeu_epi8 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovdb256mem_mask ((__v16qi *) __P, (__v8si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtepi32_epi16 (__m128i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v4si)__A, __v4hi), (__v4hi){0, 0, 0, 0}, 0, 1, + 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovdw128_mask ((__v4si) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi32_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovdw128_mask ((__v4si) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi32_storeu_epi16 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovdw128mem_mask ((__v8hi *) __P, (__v4si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi32_epi16 (__m256i __A) +{ + return (__m128i)__builtin_convertvector((__v8si)__A, __v8hi); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_epi16 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovdw256_mask ((__v8si) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi32_epi16 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovdw256_mask ((__v8si) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi32_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovdw256mem_mask ((__v8hi *) __P, (__v8si) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtepi64_epi8 (__m128i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v2di)__A, __v2qi), (__v2qi){0, 0}, 0, 1, 2, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_epi8 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovqb128_mask ((__v2di) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi64_epi8 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovqb128_mask ((__v2di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_storeu_epi8 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovqb128mem_mask ((__v16qi *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi64_epi8 (__m256i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v4di)__A, __v4qi), (__v4qi){0, 0, 0, 0}, 0, 1, + 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_epi8 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovqb256_mask ((__v4di) __A, + (__v16qi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi64_epi8 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovqb256_mask ((__v4di) __A, + (__v16qi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_storeu_epi8 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovqb256mem_mask ((__v16qi *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtepi64_epi32 (__m128i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v2di)__A, __v2si), (__v2si){0, 0}, 0, 1, 2, 3); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_epi32 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovqd128_mask ((__v2di) __A, + (__v4si) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi64_epi32 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovqd128_mask ((__v2di) __A, + (__v4si) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_storeu_epi32 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovqd128mem_mask ((__v4si *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi64_epi32 (__m256i __A) +{ + return (__m128i)__builtin_convertvector((__v4di)__A, __v4si); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_epi32 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm256_cvtepi64_epi32(__A), + (__v4si)__O); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi64_epi32 (__mmask8 __M, __m256i __A) +{ + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__M, + (__v4si)_mm256_cvtepi64_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_storeu_epi32 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovqd256mem_mask ((__v4si *) __P, (__v4di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_cvtepi64_epi16 (__m128i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v2di)__A, __v2hi), (__v2hi){0, 0}, 0, 1, 2, 3, + 3, 3, 3, 3); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_epi16 (__m128i __O, __mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovqw128_mask ((__v2di) __A, + (__v8hi)__O, + __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtepi64_epi16 (__mmask8 __M, __m128i __A) +{ + return (__m128i) __builtin_ia32_pmovqw128_mask ((__v2di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_cvtepi64_storeu_epi16 (void * __P, __mmask8 __M, __m128i __A) +{ + __builtin_ia32_pmovqw128mem_mask ((__v8hi *) __P, (__v2di) __A, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_cvtepi64_epi16 (__m256i __A) +{ + return (__m128i)__builtin_shufflevector( + __builtin_convertvector((__v4di)__A, __v4hi), (__v4hi){0, 0, 0, 0}, 0, 1, + 2, 3, 4, 5, 6, 7); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_epi16 (__m128i __O, __mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovqw256_mask ((__v4di) __A, + (__v8hi) __O, __M); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtepi64_epi16 (__mmask8 __M, __m256i __A) +{ + return (__m128i) __builtin_ia32_pmovqw256_mask ((__v4di) __A, + (__v8hi) _mm_setzero_si128 (), + __M); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtepi64_storeu_epi16 (void * __P, __mmask8 __M, __m256i __A) +{ + __builtin_ia32_pmovqw256mem_mask ((__v8hi *) __P, (__v4di) __A, __M); +} + +#define _mm256_extractf32x4_ps(A, imm) \ + ((__m128)__builtin_ia32_extractf32x4_256_mask((__v8sf)(__m256)(A), \ + (int)(imm), \ + (__v4sf)_mm_undefined_ps(), \ + (__mmask8)-1)) + +#define _mm256_mask_extractf32x4_ps(W, U, A, imm) \ + ((__m128)__builtin_ia32_extractf32x4_256_mask((__v8sf)(__m256)(A), \ + (int)(imm), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_extractf32x4_ps(U, A, imm) \ + ((__m128)__builtin_ia32_extractf32x4_256_mask((__v8sf)(__m256)(A), \ + (int)(imm), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm256_extracti32x4_epi32(A, imm) \ + ((__m128i)__builtin_ia32_extracti32x4_256_mask((__v8si)(__m256i)(A), \ + (int)(imm), \ + (__v4si)_mm_undefined_si128(), \ + (__mmask8)-1)) + +#define _mm256_mask_extracti32x4_epi32(W, U, A, imm) \ + ((__m128i)__builtin_ia32_extracti32x4_256_mask((__v8si)(__m256i)(A), \ + (int)(imm), \ + (__v4si)(__m128i)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_extracti32x4_epi32(U, A, imm) \ + ((__m128i)__builtin_ia32_extracti32x4_256_mask((__v8si)(__m256i)(A), \ + (int)(imm), \ + (__v4si)_mm_setzero_si128(), \ + (__mmask8)(U))) + +#define _mm256_insertf32x4(A, B, imm) \ + ((__m256)__builtin_ia32_insertf32x4_256((__v8sf)(__m256)(A), \ + (__v4sf)(__m128)(B), (int)(imm))) + +#define _mm256_mask_insertf32x4(W, U, A, B, imm) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_insertf32x4((A), (B), (imm)), \ + (__v8sf)(__m256)(W))) + +#define _mm256_maskz_insertf32x4(U, A, B, imm) \ + ((__m256)__builtin_ia32_selectps_256((__mmask8)(U), \ + (__v8sf)_mm256_insertf32x4((A), (B), (imm)), \ + (__v8sf)_mm256_setzero_ps())) + +#define _mm256_inserti32x4(A, B, imm) \ + ((__m256i)__builtin_ia32_inserti32x4_256((__v8si)(__m256i)(A), \ + (__v4si)(__m128i)(B), (int)(imm))) + +#define _mm256_mask_inserti32x4(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_inserti32x4((A), (B), (imm)), \ + (__v8si)(__m256i)(W))) + +#define _mm256_maskz_inserti32x4(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_inserti32x4((A), (B), (imm)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_getmant_pd(A, B, C) \ + ((__m128d)__builtin_ia32_getmantpd128_mask((__v2df)(__m128d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)-1)) + +#define _mm_mask_getmant_pd(W, U, A, B, C) \ + ((__m128d)__builtin_ia32_getmantpd128_mask((__v2df)(__m128d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v2df)(__m128d)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_getmant_pd(U, A, B, C) \ + ((__m128d)__builtin_ia32_getmantpd128_mask((__v2df)(__m128d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v2df)_mm_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm256_getmant_pd(A, B, C) \ + ((__m256d)__builtin_ia32_getmantpd256_mask((__v4df)(__m256d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)-1)) + +#define _mm256_mask_getmant_pd(W, U, A, B, C) \ + ((__m256d)__builtin_ia32_getmantpd256_mask((__v4df)(__m256d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v4df)(__m256d)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_getmant_pd(U, A, B, C) \ + ((__m256d)__builtin_ia32_getmantpd256_mask((__v4df)(__m256d)(A), \ + (int)(((C)<<2) | (B)), \ + (__v4df)_mm256_setzero_pd(), \ + (__mmask8)(U))) + +#define _mm_getmant_ps(A, B, C) \ + ((__m128)__builtin_ia32_getmantps128_mask((__v4sf)(__m128)(A), \ + (int)(((C)<<2) | (B)), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm_mask_getmant_ps(W, U, A, B, C) \ + ((__m128)__builtin_ia32_getmantps128_mask((__v4sf)(__m128)(A), \ + (int)(((C)<<2) | (B)), \ + (__v4sf)(__m128)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_getmant_ps(U, A, B, C) \ + ((__m128)__builtin_ia32_getmantps128_mask((__v4sf)(__m128)(A), \ + (int)(((C)<<2) | (B)), \ + (__v4sf)_mm_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm256_getmant_ps(A, B, C) \ + ((__m256)__builtin_ia32_getmantps256_mask((__v8sf)(__m256)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)-1)) + +#define _mm256_mask_getmant_ps(W, U, A, B, C) \ + ((__m256)__builtin_ia32_getmantps256_mask((__v8sf)(__m256)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8sf)(__m256)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_getmant_ps(U, A, B, C) \ + ((__m256)__builtin_ia32_getmantps256_mask((__v8sf)(__m256)(A), \ + (int)(((C)<<2) | (B)), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U))) + +#define _mm_mmask_i64gather_pd(v1_old, mask, index, addr, scale) \ + ((__m128d)__builtin_ia32_gather3div2df((__v2df)(__m128d)(v1_old), \ + (void const *)(addr), \ + (__v2di)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i64gather_epi64(v1_old, mask, index, addr, scale) \ + ((__m128i)__builtin_ia32_gather3div2di((__v2di)(__m128i)(v1_old), \ + (void const *)(addr), \ + (__v2di)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i64gather_pd(v1_old, mask, index, addr, scale) \ + ((__m256d)__builtin_ia32_gather3div4df((__v4df)(__m256d)(v1_old), \ + (void const *)(addr), \ + (__v4di)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i64gather_epi64(v1_old, mask, index, addr, scale) \ + ((__m256i)__builtin_ia32_gather3div4di((__v4di)(__m256i)(v1_old), \ + (void const *)(addr), \ + (__v4di)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i64gather_ps(v1_old, mask, index, addr, scale) \ + ((__m128)__builtin_ia32_gather3div4sf((__v4sf)(__m128)(v1_old), \ + (void const *)(addr), \ + (__v2di)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i64gather_epi32(v1_old, mask, index, addr, scale) \ + ((__m128i)__builtin_ia32_gather3div4si((__v4si)(__m128i)(v1_old), \ + (void const *)(addr), \ + (__v2di)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i64gather_ps(v1_old, mask, index, addr, scale) \ + ((__m128)__builtin_ia32_gather3div8sf((__v4sf)(__m128)(v1_old), \ + (void const *)(addr), \ + (__v4di)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i64gather_epi32(v1_old, mask, index, addr, scale) \ + ((__m128i)__builtin_ia32_gather3div8si((__v4si)(__m128i)(v1_old), \ + (void const *)(addr), \ + (__v4di)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i32gather_pd(v1_old, mask, index, addr, scale) \ + ((__m128d)__builtin_ia32_gather3siv2df((__v2df)(__m128d)(v1_old), \ + (void const *)(addr), \ + (__v4si)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i32gather_epi64(v1_old, mask, index, addr, scale) \ + ((__m128i)__builtin_ia32_gather3siv2di((__v2di)(__m128i)(v1_old), \ + (void const *)(addr), \ + (__v4si)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i32gather_pd(v1_old, mask, index, addr, scale) \ + ((__m256d)__builtin_ia32_gather3siv4df((__v4df)(__m256d)(v1_old), \ + (void const *)(addr), \ + (__v4si)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i32gather_epi64(v1_old, mask, index, addr, scale) \ + ((__m256i)__builtin_ia32_gather3siv4di((__v4di)(__m256i)(v1_old), \ + (void const *)(addr), \ + (__v4si)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i32gather_ps(v1_old, mask, index, addr, scale) \ + ((__m128)__builtin_ia32_gather3siv4sf((__v4sf)(__m128)(v1_old), \ + (void const *)(addr), \ + (__v4si)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm_mmask_i32gather_epi32(v1_old, mask, index, addr, scale) \ + ((__m128i)__builtin_ia32_gather3siv4si((__v4si)(__m128i)(v1_old), \ + (void const *)(addr), \ + (__v4si)(__m128i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i32gather_ps(v1_old, mask, index, addr, scale) \ + ((__m256)__builtin_ia32_gather3siv8sf((__v8sf)(__m256)(v1_old), \ + (void const *)(addr), \ + (__v8si)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_mmask_i32gather_epi32(v1_old, mask, index, addr, scale) \ + ((__m256i)__builtin_ia32_gather3siv8si((__v8si)(__m256i)(v1_old), \ + (void const *)(addr), \ + (__v8si)(__m256i)(index), \ + (__mmask8)(mask), (int)(scale))) + +#define _mm256_permutex_pd(X, C) \ + ((__m256d)__builtin_ia32_permdf256((__v4df)(__m256d)(X), (int)(C))) + +#define _mm256_mask_permutex_pd(W, U, X, C) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_permutex_pd((X), (C)), \ + (__v4df)(__m256d)(W))) + +#define _mm256_maskz_permutex_pd(U, X, C) \ + ((__m256d)__builtin_ia32_selectpd_256((__mmask8)(U), \ + (__v4df)_mm256_permutex_pd((X), (C)), \ + (__v4df)_mm256_setzero_pd())) + +#define _mm256_permutex_epi64(X, C) \ + ((__m256i)__builtin_ia32_permdi256((__v4di)(__m256i)(X), (int)(C))) + +#define _mm256_mask_permutex_epi64(W, U, X, C) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_permutex_epi64((X), (C)), \ + (__v4di)(__m256i)(W))) + +#define _mm256_maskz_permutex_epi64(U, X, C) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_permutex_epi64((X), (C)), \ + (__v4di)_mm256_setzero_si256())) + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_permutexvar_pd (__m256i __X, __m256d __Y) +{ + return (__m256d)__builtin_ia32_permvardf256((__v4df)__Y, (__v4di)__X); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_permutexvar_pd (__m256d __W, __mmask8 __U, __m256i __X, + __m256d __Y) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_permutexvar_pd(__X, __Y), + (__v4df)__W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutexvar_pd (__mmask8 __U, __m256i __X, __m256d __Y) +{ + return (__m256d)__builtin_ia32_selectpd_256((__mmask8)__U, + (__v4df)_mm256_permutexvar_pd(__X, __Y), + (__v4df)_mm256_setzero_pd()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_permutexvar_epi64 ( __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_permvardi256((__v4di) __Y, (__v4di) __X); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutexvar_epi64 (__mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_permutexvar_epi64(__X, __Y), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_permutexvar_epi64 (__m256i __W, __mmask8 __M, __m256i __X, + __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__M, + (__v4di)_mm256_permutexvar_epi64(__X, __Y), + (__v4di)__W); +} + +#define _mm256_permutexvar_ps(A, B) _mm256_permutevar8x32_ps((B), (A)) + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_permutexvar_ps(__m256 __W, __mmask8 __U, __m256i __X, __m256 __Y) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_permutexvar_ps(__X, __Y), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutexvar_ps(__mmask8 __U, __m256i __X, __m256 __Y) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_permutexvar_ps(__X, __Y), + (__v8sf)_mm256_setzero_ps()); +} + +#define _mm256_permutexvar_epi32(A, B) _mm256_permutevar8x32_epi32((B), (A)) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_permutexvar_epi32(__m256i __W, __mmask8 __M, __m256i __X, + __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_permutexvar_epi32(__X, __Y), + (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_permutexvar_epi32(__mmask8 __M, __m256i __X, __m256i __Y) +{ + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__M, + (__v8si)_mm256_permutexvar_epi32(__X, __Y), + (__v8si)_mm256_setzero_si256()); +} + +#define _mm_alignr_epi32(A, B, imm) \ + ((__m128i)__builtin_ia32_alignd128((__v4si)(__m128i)(A), \ + (__v4si)(__m128i)(B), (int)(imm))) + +#define _mm_mask_alignr_epi32(W, U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_alignr_epi32((A), (B), (imm)), \ + (__v4si)(__m128i)(W))) + +#define _mm_maskz_alignr_epi32(U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_alignr_epi32((A), (B), (imm)), \ + (__v4si)_mm_setzero_si128())) + +#define _mm256_alignr_epi32(A, B, imm) \ + ((__m256i)__builtin_ia32_alignd256((__v8si)(__m256i)(A), \ + (__v8si)(__m256i)(B), (int)(imm))) + +#define _mm256_mask_alignr_epi32(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_alignr_epi32((A), (B), (imm)), \ + (__v8si)(__m256i)(W))) + +#define _mm256_maskz_alignr_epi32(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_alignr_epi32((A), (B), (imm)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_alignr_epi64(A, B, imm) \ + ((__m128i)__builtin_ia32_alignq128((__v2di)(__m128i)(A), \ + (__v2di)(__m128i)(B), (int)(imm))) + +#define _mm_mask_alignr_epi64(W, U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(U), \ + (__v2di)_mm_alignr_epi64((A), (B), (imm)), \ + (__v2di)(__m128i)(W))) + +#define _mm_maskz_alignr_epi64(U, A, B, imm) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(U), \ + (__v2di)_mm_alignr_epi64((A), (B), (imm)), \ + (__v2di)_mm_setzero_si128())) + +#define _mm256_alignr_epi64(A, B, imm) \ + ((__m256i)__builtin_ia32_alignq256((__v4di)(__m256i)(A), \ + (__v4di)(__m256i)(B), (int)(imm))) + +#define _mm256_mask_alignr_epi64(W, U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_alignr_epi64((A), (B), (imm)), \ + (__v4di)(__m256i)(W))) + +#define _mm256_maskz_alignr_epi64(U, A, B, imm) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_alignr_epi64((A), (B), (imm)), \ + (__v4di)_mm256_setzero_si256())) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_movehdup_ps (__m128 __W, __mmask8 __U, __m128 __A) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_movehdup_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_movehdup_ps (__mmask8 __U, __m128 __A) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_movehdup_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_movehdup_ps (__m256 __W, __mmask8 __U, __m256 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_movehdup_ps(__A), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_movehdup_ps (__mmask8 __U, __m256 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_movehdup_ps(__A), + (__v8sf)_mm256_setzero_ps()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_moveldup_ps (__m128 __W, __mmask8 __U, __m128 __A) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_moveldup_ps(__A), + (__v4sf)__W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_moveldup_ps (__mmask8 __U, __m128 __A) +{ + return (__m128)__builtin_ia32_selectps_128((__mmask8)__U, + (__v4sf)_mm_moveldup_ps(__A), + (__v4sf)_mm_setzero_ps()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_moveldup_ps (__m256 __W, __mmask8 __U, __m256 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_moveldup_ps(__A), + (__v8sf)__W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_moveldup_ps (__mmask8 __U, __m256 __A) +{ + return (__m256)__builtin_ia32_selectps_256((__mmask8)__U, + (__v8sf)_mm256_moveldup_ps(__A), + (__v8sf)_mm256_setzero_ps()); +} + +#define _mm256_mask_shuffle_epi32(W, U, A, I) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shuffle_epi32((A), (I)), \ + (__v8si)(__m256i)(W))) + +#define _mm256_maskz_shuffle_epi32(U, A, I) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shuffle_epi32((A), (I)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_mask_shuffle_epi32(W, U, A, I) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_shuffle_epi32((A), (I)), \ + (__v4si)(__m128i)(W))) + +#define _mm_maskz_shuffle_epi32(U, A, I) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_shuffle_epi32((A), (I)), \ + (__v4si)_mm_setzero_si128())) + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_mask_mov_pd (__m128d __W, __mmask8 __U, __m128d __A) +{ + return (__m128d) __builtin_ia32_selectpd_128 ((__mmask8) __U, + (__v2df) __A, + (__v2df) __W); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maskz_mov_pd (__mmask8 __U, __m128d __A) +{ + return (__m128d) __builtin_ia32_selectpd_128 ((__mmask8) __U, + (__v2df) __A, + (__v2df) _mm_setzero_pd ()); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_mask_mov_pd (__m256d __W, __mmask8 __U, __m256d __A) +{ + return (__m256d) __builtin_ia32_selectpd_256 ((__mmask8) __U, + (__v4df) __A, + (__v4df) __W); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maskz_mov_pd (__mmask8 __U, __m256d __A) +{ + return (__m256d) __builtin_ia32_selectpd_256 ((__mmask8) __U, + (__v4df) __A, + (__v4df) _mm256_setzero_pd ()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_mov_ps (__m128 __W, __mmask8 __U, __m128 __A) +{ + return (__m128) __builtin_ia32_selectps_128 ((__mmask8) __U, + (__v4sf) __A, + (__v4sf) __W); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_mov_ps (__mmask8 __U, __m128 __A) +{ + return (__m128) __builtin_ia32_selectps_128 ((__mmask8) __U, + (__v4sf) __A, + (__v4sf) _mm_setzero_ps ()); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_mov_ps (__m256 __W, __mmask8 __U, __m256 __A) +{ + return (__m256) __builtin_ia32_selectps_256 ((__mmask8) __U, + (__v8sf) __A, + (__v8sf) __W); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_mov_ps (__mmask8 __U, __m256 __A) +{ + return (__m256) __builtin_ia32_selectps_256 ((__mmask8) __U, + (__v8sf) __A, + (__v8sf) _mm256_setzero_ps ()); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_mask_cvtph_ps (__m128 __W, __mmask8 __U, __m128i __A) +{ + return (__m128) __builtin_ia32_vcvtph2ps_mask ((__v8hi) __A, + (__v4sf) __W, + (__mmask8) __U); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maskz_cvtph_ps (__mmask8 __U, __m128i __A) +{ + return (__m128) __builtin_ia32_vcvtph2ps_mask ((__v8hi) __A, + (__v4sf) + _mm_setzero_ps (), + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_mask_cvtph_ps (__m256 __W, __mmask8 __U, __m128i __A) +{ + return (__m256) __builtin_ia32_vcvtph2ps256_mask ((__v8hi) __A, + (__v8sf) __W, + (__mmask8) __U); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maskz_cvtph_ps (__mmask8 __U, __m128i __A) +{ + return (__m256) __builtin_ia32_vcvtph2ps256_mask ((__v8hi) __A, + (__v8sf) + _mm256_setzero_ps (), + (__mmask8) __U); +} + +#define _mm_mask_cvt_roundps_ph(W, U, A, I) \ + ((__m128i)__builtin_ia32_vcvtps2ph_mask((__v4sf)(__m128)(A), (int)(I), \ + (__v8hi)(__m128i)(W), \ + (__mmask8)(U))) + +#define _mm_maskz_cvt_roundps_ph(U, A, I) \ + ((__m128i)__builtin_ia32_vcvtps2ph_mask((__v4sf)(__m128)(A), (int)(I), \ + (__v8hi)_mm_setzero_si128(), \ + (__mmask8)(U))) + +#define _mm_mask_cvtps_ph _mm_mask_cvt_roundps_ph +#define _mm_maskz_cvtps_ph _mm_maskz_cvt_roundps_ph + +#define _mm256_mask_cvt_roundps_ph(W, U, A, I) \ + ((__m128i)__builtin_ia32_vcvtps2ph256_mask((__v8sf)(__m256)(A), (int)(I), \ + (__v8hi)(__m128i)(W), \ + (__mmask8)(U))) + +#define _mm256_maskz_cvt_roundps_ph(U, A, I) \ + ((__m128i)__builtin_ia32_vcvtps2ph256_mask((__v8sf)(__m256)(A), (int)(I), \ + (__v8hi)_mm_setzero_si128(), \ + (__mmask8)(U))) + +#define _mm256_mask_cvtps_ph _mm256_mask_cvt_roundps_ph +#define _mm256_maskz_cvtps_ph _mm256_maskz_cvt_roundps_ph + + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __AVX512VLINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvbmi2intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvbmi2intrin.h new file mode 100755 index 0000000..77af2d5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvbmi2intrin.h @@ -0,0 +1,695 @@ +/*===------------- avx512vlvbmi2intrin.h - VBMI2 intrinsics -----------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLVBMI2INTRIN_H +#define __AVX512VLVBMI2INTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512vbmi2,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512vbmi2,no-evex512"), \ + __min_vector_width__(256))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_compress_epi16(__m128i __S, __mmask8 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_compresshi128_mask ((__v8hi) __D, + (__v8hi) __S, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_compress_epi16(__mmask8 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_compresshi128_mask ((__v8hi) __D, + (__v8hi) _mm_setzero_si128(), + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_compress_epi8(__m128i __S, __mmask16 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_compressqi128_mask ((__v16qi) __D, + (__v16qi) __S, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_compress_epi8(__mmask16 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_compressqi128_mask ((__v16qi) __D, + (__v16qi) _mm_setzero_si128(), + __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_compressstoreu_epi16(void *__P, __mmask8 __U, __m128i __D) +{ + __builtin_ia32_compressstorehi128_mask ((__v8hi *) __P, (__v8hi) __D, + __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_mask_compressstoreu_epi8(void *__P, __mmask16 __U, __m128i __D) +{ + __builtin_ia32_compressstoreqi128_mask ((__v16qi *) __P, (__v16qi) __D, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expand_epi16(__m128i __S, __mmask8 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_expandhi128_mask ((__v8hi) __D, + (__v8hi) __S, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expand_epi16(__mmask8 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_expandhi128_mask ((__v8hi) __D, + (__v8hi) _mm_setzero_si128(), + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expand_epi8(__m128i __S, __mmask16 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_expandqi128_mask ((__v16qi) __D, + (__v16qi) __S, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expand_epi8(__mmask16 __U, __m128i __D) +{ + return (__m128i) __builtin_ia32_expandqi128_mask ((__v16qi) __D, + (__v16qi) _mm_setzero_si128(), + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expandloadu_epi16(__m128i __S, __mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_expandloadhi128_mask ((const __v8hi *)__P, + (__v8hi) __S, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expandloadu_epi16(__mmask8 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_expandloadhi128_mask ((const __v8hi *)__P, + (__v8hi) _mm_setzero_si128(), + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_expandloadu_epi8(__m128i __S, __mmask16 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_expandloadqi128_mask ((const __v16qi *)__P, + (__v16qi) __S, + __U); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_expandloadu_epi8(__mmask16 __U, void const *__P) +{ + return (__m128i) __builtin_ia32_expandloadqi128_mask ((const __v16qi *)__P, + (__v16qi) _mm_setzero_si128(), + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_compress_epi16(__m256i __S, __mmask16 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_compresshi256_mask ((__v16hi) __D, + (__v16hi) __S, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_compress_epi16(__mmask16 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_compresshi256_mask ((__v16hi) __D, + (__v16hi) _mm256_setzero_si256(), + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_compress_epi8(__m256i __S, __mmask32 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_compressqi256_mask ((__v32qi) __D, + (__v32qi) __S, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_compress_epi8(__mmask32 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_compressqi256_mask ((__v32qi) __D, + (__v32qi) _mm256_setzero_si256(), + __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_compressstoreu_epi16(void *__P, __mmask16 __U, __m256i __D) +{ + __builtin_ia32_compressstorehi256_mask ((__v16hi *) __P, (__v16hi) __D, + __U); +} + +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_mask_compressstoreu_epi8(void *__P, __mmask32 __U, __m256i __D) +{ + __builtin_ia32_compressstoreqi256_mask ((__v32qi *) __P, (__v32qi) __D, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expand_epi16(__m256i __S, __mmask16 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_expandhi256_mask ((__v16hi) __D, + (__v16hi) __S, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expand_epi16(__mmask16 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_expandhi256_mask ((__v16hi) __D, + (__v16hi) _mm256_setzero_si256(), + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expand_epi8(__m256i __S, __mmask32 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_expandqi256_mask ((__v32qi) __D, + (__v32qi) __S, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expand_epi8(__mmask32 __U, __m256i __D) +{ + return (__m256i) __builtin_ia32_expandqi256_mask ((__v32qi) __D, + (__v32qi) _mm256_setzero_si256(), + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expandloadu_epi16(__m256i __S, __mmask16 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_expandloadhi256_mask ((const __v16hi *)__P, + (__v16hi) __S, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expandloadu_epi16(__mmask16 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_expandloadhi256_mask ((const __v16hi *)__P, + (__v16hi) _mm256_setzero_si256(), + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_expandloadu_epi8(__m256i __S, __mmask32 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_expandloadqi256_mask ((const __v32qi *)__P, + (__v32qi) __S, + __U); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_expandloadu_epi8(__mmask32 __U, void const *__P) +{ + return (__m256i) __builtin_ia32_expandloadqi256_mask ((const __v32qi *)__P, + (__v32qi) _mm256_setzero_si256(), + __U); +} + +#define _mm256_shldi_epi64(A, B, I) \ + ((__m256i)__builtin_ia32_vpshldq256((__v4di)(__m256i)(A), \ + (__v4di)(__m256i)(B), (int)(I))) + +#define _mm256_mask_shldi_epi64(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_shldi_epi64((A), (B), (I)), \ + (__v4di)(__m256i)(S))) + +#define _mm256_maskz_shldi_epi64(U, A, B, I) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_shldi_epi64((A), (B), (I)), \ + (__v4di)_mm256_setzero_si256())) + +#define _mm_shldi_epi64(A, B, I) \ + ((__m128i)__builtin_ia32_vpshldq128((__v2di)(__m128i)(A), \ + (__v2di)(__m128i)(B), (int)(I))) + +#define _mm_mask_shldi_epi64(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(U), \ + (__v2di)_mm_shldi_epi64((A), (B), (I)), \ + (__v2di)(__m128i)(S))) + +#define _mm_maskz_shldi_epi64(U, A, B, I) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(U), \ + (__v2di)_mm_shldi_epi64((A), (B), (I)), \ + (__v2di)_mm_setzero_si128())) + +#define _mm256_shldi_epi32(A, B, I) \ + ((__m256i)__builtin_ia32_vpshldd256((__v8si)(__m256i)(A), \ + (__v8si)(__m256i)(B), (int)(I))) + +#define _mm256_mask_shldi_epi32(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shldi_epi32((A), (B), (I)), \ + (__v8si)(__m256i)(S))) + +#define _mm256_maskz_shldi_epi32(U, A, B, I) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shldi_epi32((A), (B), (I)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_shldi_epi32(A, B, I) \ + ((__m128i)__builtin_ia32_vpshldd128((__v4si)(__m128i)(A), \ + (__v4si)(__m128i)(B), (int)(I))) + +#define _mm_mask_shldi_epi32(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_shldi_epi32((A), (B), (I)), \ + (__v4si)(__m128i)(S))) + +#define _mm_maskz_shldi_epi32(U, A, B, I) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_shldi_epi32((A), (B), (I)), \ + (__v4si)_mm_setzero_si128())) + +#define _mm256_shldi_epi16(A, B, I) \ + ((__m256i)__builtin_ia32_vpshldw256((__v16hi)(__m256i)(A), \ + (__v16hi)(__m256i)(B), (int)(I))) + +#define _mm256_mask_shldi_epi16(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shldi_epi16((A), (B), (I)), \ + (__v16hi)(__m256i)(S))) + +#define _mm256_maskz_shldi_epi16(U, A, B, I) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shldi_epi16((A), (B), (I)), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_shldi_epi16(A, B, I) \ + ((__m128i)__builtin_ia32_vpshldw128((__v8hi)(__m128i)(A), \ + (__v8hi)(__m128i)(B), (int)(I))) + +#define _mm_mask_shldi_epi16(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shldi_epi16((A), (B), (I)), \ + (__v8hi)(__m128i)(S))) + +#define _mm_maskz_shldi_epi16(U, A, B, I) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shldi_epi16((A), (B), (I)), \ + (__v8hi)_mm_setzero_si128())) + +#define _mm256_shrdi_epi64(A, B, I) \ + ((__m256i)__builtin_ia32_vpshrdq256((__v4di)(__m256i)(A), \ + (__v4di)(__m256i)(B), (int)(I))) + +#define _mm256_mask_shrdi_epi64(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_shrdi_epi64((A), (B), (I)), \ + (__v4di)(__m256i)(S))) + +#define _mm256_maskz_shrdi_epi64(U, A, B, I) \ + ((__m256i)__builtin_ia32_selectq_256((__mmask8)(U), \ + (__v4di)_mm256_shrdi_epi64((A), (B), (I)), \ + (__v4di)_mm256_setzero_si256())) + +#define _mm_shrdi_epi64(A, B, I) \ + ((__m128i)__builtin_ia32_vpshrdq128((__v2di)(__m128i)(A), \ + (__v2di)(__m128i)(B), (int)(I))) + +#define _mm_mask_shrdi_epi64(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(U), \ + (__v2di)_mm_shrdi_epi64((A), (B), (I)), \ + (__v2di)(__m128i)(S))) + +#define _mm_maskz_shrdi_epi64(U, A, B, I) \ + ((__m128i)__builtin_ia32_selectq_128((__mmask8)(U), \ + (__v2di)_mm_shrdi_epi64((A), (B), (I)), \ + (__v2di)_mm_setzero_si128())) + +#define _mm256_shrdi_epi32(A, B, I) \ + ((__m256i)__builtin_ia32_vpshrdd256((__v8si)(__m256i)(A), \ + (__v8si)(__m256i)(B), (int)(I))) + +#define _mm256_mask_shrdi_epi32(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shrdi_epi32((A), (B), (I)), \ + (__v8si)(__m256i)(S))) + +#define _mm256_maskz_shrdi_epi32(U, A, B, I) \ + ((__m256i)__builtin_ia32_selectd_256((__mmask8)(U), \ + (__v8si)_mm256_shrdi_epi32((A), (B), (I)), \ + (__v8si)_mm256_setzero_si256())) + +#define _mm_shrdi_epi32(A, B, I) \ + ((__m128i)__builtin_ia32_vpshrdd128((__v4si)(__m128i)(A), \ + (__v4si)(__m128i)(B), (int)(I))) + +#define _mm_mask_shrdi_epi32(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_shrdi_epi32((A), (B), (I)), \ + (__v4si)(__m128i)(S))) + +#define _mm_maskz_shrdi_epi32(U, A, B, I) \ + ((__m128i)__builtin_ia32_selectd_128((__mmask8)(U), \ + (__v4si)_mm_shrdi_epi32((A), (B), (I)), \ + (__v4si)_mm_setzero_si128())) + +#define _mm256_shrdi_epi16(A, B, I) \ + ((__m256i)__builtin_ia32_vpshrdw256((__v16hi)(__m256i)(A), \ + (__v16hi)(__m256i)(B), (int)(I))) + +#define _mm256_mask_shrdi_epi16(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shrdi_epi16((A), (B), (I)), \ + (__v16hi)(__m256i)(S))) + +#define _mm256_maskz_shrdi_epi16(U, A, B, I) \ + ((__m256i)__builtin_ia32_selectw_256((__mmask16)(U), \ + (__v16hi)_mm256_shrdi_epi16((A), (B), (I)), \ + (__v16hi)_mm256_setzero_si256())) + +#define _mm_shrdi_epi16(A, B, I) \ + ((__m128i)__builtin_ia32_vpshrdw128((__v8hi)(__m128i)(A), \ + (__v8hi)(__m128i)(B), (int)(I))) + +#define _mm_mask_shrdi_epi16(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shrdi_epi16((A), (B), (I)), \ + (__v8hi)(__m128i)(S))) + +#define _mm_maskz_shrdi_epi16(U, A, B, I) \ + ((__m128i)__builtin_ia32_selectw_128((__mmask8)(U), \ + (__v8hi)_mm_shrdi_epi16((A), (B), (I)), \ + (__v8hi)_mm_setzero_si128())) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shldv_epi64(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_vpshldvq256((__v4di)__A, (__v4di)__B, + (__v4di)__C); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shldv_epi64(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_shldv_epi64(__A, __B, __C), + (__v4di)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shldv_epi64(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_shldv_epi64(__A, __B, __C), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_shldv_epi64(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpshldvq128((__v2di)__A, (__v2di)__B, + (__v2di)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shldv_epi64(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_shldv_epi64(__A, __B, __C), + (__v2di)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shldv_epi64(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_shldv_epi64(__A, __B, __C), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shldv_epi32(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_vpshldvd256((__v8si)__A, (__v8si)__B, + (__v8si)__C); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shldv_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_shldv_epi32(__A, __B, __C), + (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shldv_epi32(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_shldv_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_shldv_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpshldvd128((__v4si)__A, (__v4si)__B, + (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shldv_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_shldv_epi32(__A, __B, __C), + (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shldv_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_shldv_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shldv_epi16(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_vpshldvw256((__v16hi)__A, (__v16hi)__B, + (__v16hi)__C); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shldv_epi16(__m256i __A, __mmask16 __U, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_shldv_epi16(__A, __B, __C), + (__v16hi)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shldv_epi16(__mmask16 __U, __m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_shldv_epi16(__A, __B, __C), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_shldv_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpshldvw128((__v8hi)__A, (__v8hi)__B, + (__v8hi)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shldv_epi16(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_shldv_epi16(__A, __B, __C), + (__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shldv_epi16(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_shldv_epi16(__A, __B, __C), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shrdv_epi64(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_vpshrdvq256((__v4di)__A, (__v4di)__B, + (__v4di)__C); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shrdv_epi64(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_shrdv_epi64(__A, __B, __C), + (__v4di)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shrdv_epi64(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectq_256(__U, + (__v4di)_mm256_shrdv_epi64(__A, __B, __C), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_shrdv_epi64(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpshrdvq128((__v2di)__A, (__v2di)__B, + (__v2di)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shrdv_epi64(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_shrdv_epi64(__A, __B, __C), + (__v2di)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shrdv_epi64(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectq_128(__U, + (__v2di)_mm_shrdv_epi64(__A, __B, __C), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shrdv_epi32(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_vpshrdvd256((__v8si)__A, (__v8si)__B, + (__v8si)__C); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shrdv_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_shrdv_epi32(__A, __B, __C), + (__v8si)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shrdv_epi32(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_shrdv_epi32(__A, __B, __C), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_shrdv_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpshrdvd128((__v4si)__A, (__v4si)__B, + (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shrdv_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_shrdv_epi32(__A, __B, __C), + (__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shrdv_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_shrdv_epi32(__A, __B, __C), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_shrdv_epi16(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_vpshrdvw256((__v16hi)__A, (__v16hi)__B, + (__v16hi)__C); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_shrdv_epi16(__m256i __A, __mmask16 __U, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_shrdv_epi16(__A, __B, __C), + (__v16hi)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_shrdv_epi16(__mmask16 __U, __m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)__builtin_ia32_selectw_256(__U, + (__v16hi)_mm256_shrdv_epi16(__A, __B, __C), + (__v16hi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_shrdv_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpshrdvw128((__v8hi)__A, (__v8hi)__B, + (__v8hi)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_shrdv_epi16(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_shrdv_epi16(__A, __B, __C), + (__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_shrdv_epi16(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_selectw_128(__U, + (__v8hi)_mm_shrdv_epi16(__A, __B, __C), + (__v8hi)_mm_setzero_si128()); +} + + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvnniintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvnniintrin.h new file mode 100755 index 0000000..d1e5cd9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvnniintrin.h @@ -0,0 +1,310 @@ +/*===------------- avx512vlvnniintrin.h - VNNI intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VLVNNIINTRIN_H +#define __AVX512VLVNNIINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512vnni,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512vnni,no-evex512"), \ + __min_vector_width__(256))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a A with +/// corresponding signed 8-bit integers in \a B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a S, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := Signed(ZeroExtend16(A.byte[4*j]) * SignExtend16(B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(A.byte[4*j+1]) * SignExtend16(B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(A.byte[4*j+2]) * SignExtend16(B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(A.byte[4*j+3]) * SignExtend16(B.byte[4*j+3])) +/// DST.dword[j] := S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +#define _mm256_dpbusd_epi32(S, A, B) \ + ((__m256i)__builtin_ia32_vpdpbusd256((__v8si)(S), (__v8si)(A), (__v8si)(B))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a A with +/// corresponding signed 8-bit integers in \a B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a S using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := Signed(ZeroExtend16(A.byte[4*j]) * SignExtend16(B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(A.byte[4*j+1]) * SignExtend16(B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(A.byte[4*j+2]) * SignExtend16(B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(A.byte[4*j+3]) * SignExtend16(B.byte[4*j+3])) +/// DST.dword[j] := Saturate32(S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +#define _mm256_dpbusds_epi32(S, A, B) \ + ((__m256i)__builtin_ia32_vpdpbusds256((__v8si)(S), (__v8si)(A), (__v8si)(B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a A with +/// corresponding 16-bit integers in \a B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a S, +/// and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := SignExtend32(A.word[2*j]) * SignExtend32(B.word[2*j]) +/// tmp2.dword := SignExtend32(A.word[2*j+1]) * SignExtend32(B.word[2*j+1]) +/// DST.dword[j] := S.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +#define _mm256_dpwssd_epi32(S, A, B) \ + ((__m256i)__builtin_ia32_vpdpwssd256((__v8si)(S), (__v8si)(A), (__v8si)(B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a A with +/// corresponding 16-bit integers in \a B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a S +/// using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := SignExtend32(A.word[2*j]) * SignExtend32(B.word[2*j]) +/// tmp2.dword := SignExtend32(A.word[2*j+1]) * SignExtend32(B.word[2*j+1]) +/// DST.dword[j] := Saturate32(S.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +#define _mm256_dpwssds_epi32(S, A, B) \ + ((__m256i)__builtin_ia32_vpdpwssds256((__v8si)(S), (__v8si)(A), (__v8si)(B))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a A with +/// corresponding signed 8-bit integers in \a B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a S, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := Signed(ZeroExtend16(A.byte[4*j]) * SignExtend16(B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(A.byte[4*j+1]) * SignExtend16(B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(A.byte[4*j+2]) * SignExtend16(B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(A.byte[4*j+3]) * SignExtend16(B.byte[4*j+3])) +/// DST.dword[j] := S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +#define _mm_dpbusd_epi32(S, A, B) \ + ((__m128i)__builtin_ia32_vpdpbusd128((__v4si)(S), (__v4si)(A), (__v4si)(B))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a A with +/// corresponding signed 8-bit integers in \a B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a S using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := Signed(ZeroExtend16(A.byte[4*j]) * SignExtend16(B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(A.byte[4*j+1]) * SignExtend16(B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(A.byte[4*j+2]) * SignExtend16(B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(A.byte[4*j+3]) * SignExtend16(B.byte[4*j+3])) +/// DST.dword[j] := Saturate32(S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +#define _mm_dpbusds_epi32(S, A, B) \ + ((__m128i)__builtin_ia32_vpdpbusds128((__v4si)(S), (__v4si)(A), (__v4si)(B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a A with +/// corresponding 16-bit integers in \a B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a S, +/// and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := SignExtend32(A.word[2*j]) * SignExtend32(B.word[2*j]) +/// tmp2.dword := SignExtend32(A.word[2*j+1]) * SignExtend32(B.word[2*j+1]) +/// DST.dword[j] := S.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +#define _mm_dpwssd_epi32(S, A, B) \ + ((__m128i)__builtin_ia32_vpdpwssd128((__v4si)(S), (__v4si)(A), (__v4si)(B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a A with +/// corresponding 16-bit integers in \a B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a S +/// using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := SignExtend32(A.word[2*j]) * SignExtend32(B.word[2*j]) +/// tmp2.dword := SignExtend32(A.word[2*j+1]) * SignExtend32(B.word[2*j+1]) +/// DST.dword[j] := Saturate32(S.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +#define _mm_dpwssds_epi32(S, A, B) \ + ((__m128i)__builtin_ia32_vpdpwssds128((__v4si)(S), (__v4si)(A), (__v4si)(B))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbusd_epi32(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpbusd_epi32(__S, __A, __B), + (__v8si)__S); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpbusd_epi32(__mmask8 __U, __m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpbusd_epi32(__S, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpbusds_epi32(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpbusds_epi32(__S, __A, __B), + (__v8si)__S); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpbusds_epi32(__mmask8 __U, __m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpbusds_epi32(__S, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwssd_epi32(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpwssd_epi32(__S, __A, __B), + (__v8si)__S); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpwssd_epi32(__mmask8 __U, __m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpwssd_epi32(__S, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_dpwssds_epi32(__m256i __S, __mmask8 __U, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpwssds_epi32(__S, __A, __B), + (__v8si)__S); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_dpwssds_epi32(__mmask8 __U, __m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_selectd_256(__U, + (__v8si)_mm256_dpwssds_epi32(__S, __A, __B), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbusd_epi32(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpbusd_epi32(__S, __A, __B), + (__v4si)__S); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbusd_epi32(__mmask8 __U, __m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpbusd_epi32(__S, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpbusds_epi32(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpbusds_epi32(__S, __A, __B), + (__v4si)__S); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpbusds_epi32(__mmask8 __U, __m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpbusds_epi32(__S, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwssd_epi32(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpwssd_epi32(__S, __A, __B), + (__v4si)__S); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwssd_epi32(__mmask8 __U, __m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpwssd_epi32(__S, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_dpwssds_epi32(__m128i __S, __mmask8 __U, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpwssds_epi32(__S, __A, __B), + (__v4si)__S); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_dpwssds_epi32(__mmask8 __U, __m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_selectd_128(__U, + (__v4si)_mm_dpwssds_epi32(__S, __A, __B), + (__v4si)_mm_setzero_si128()); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvp2intersectintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvp2intersectintrin.h new file mode 100755 index 0000000..63a3124 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vlvp2intersectintrin.h @@ -0,0 +1,123 @@ +/*===------ avx512vlvp2intersectintrin.h - VL VP2INTERSECT intrinsics ------=== + * + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef _AVX512VLVP2INTERSECT_H +#define _AVX512VLVP2INTERSECT_H + +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512vp2intersect,no-evex512"), \ + __min_vector_width__(128))) + +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vl,avx512vp2intersect,no-evex512"), \ + __min_vector_width__(256))) +/// Store, in an even/odd pair of mask registers, the indicators of the +/// locations of value matches between dwords in operands __a and __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VP2INTERSECTD instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \param __b +/// A 256-bit vector of [8 x i32] +/// \param __m0 +/// A pointer point to 8-bit mask +/// \param __m1 +/// A pointer point to 8-bit mask +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_2intersect_epi32(__m256i __a, __m256i __b, __mmask8 *__m0, __mmask8 *__m1) { + __builtin_ia32_vp2intersect_d_256((__v8si)__a, (__v8si)__b, __m0, __m1); +} + +/// Store, in an even/odd pair of mask registers, the indicators of the +/// locations of value matches between quadwords in operands __a and __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VP2INTERSECTQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x i64]. +/// \param __b +/// A 256-bit vector of [4 x i64] +/// \param __m0 +/// A pointer point to 8-bit mask +/// \param __m1 +/// A pointer point to 8-bit mask +static __inline__ void __DEFAULT_FN_ATTRS256 +_mm256_2intersect_epi64(__m256i __a, __m256i __b, __mmask8 *__m0, __mmask8 *__m1) { + __builtin_ia32_vp2intersect_q_256((__v4di)__a, (__v4di)__b, __m0, __m1); +} + +/// Store, in an even/odd pair of mask registers, the indicators of the +/// locations of value matches between dwords in operands __a and __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VP2INTERSECTD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32]. +/// \param __b +/// A 128-bit vector of [4 x i32] +/// \param __m0 +/// A pointer point to 8-bit mask +/// \param __m1 +/// A pointer point to 8-bit mask +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_2intersect_epi32(__m128i __a, __m128i __b, __mmask8 *__m0, __mmask8 *__m1) { + __builtin_ia32_vp2intersect_d_128((__v4si)__a, (__v4si)__b, __m0, __m1); +} + +/// Store, in an even/odd pair of mask registers, the indicators of the +/// locations of value matches between quadwords in operands __a and __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VP2INTERSECTQ instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x i64]. +/// \param __b +/// A 128-bit vector of [2 x i64] +/// \param __m0 +/// A pointer point to 8-bit mask +/// \param __m1 +/// A pointer point to 8-bit mask +static __inline__ void __DEFAULT_FN_ATTRS128 +_mm_2intersect_epi64(__m128i __a, __m128i __b, __mmask8 *__m0, __mmask8 *__m1) { + __builtin_ia32_vp2intersect_q_128((__v2di)__a, (__v2di)__b, __m0, __m1); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vnniintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vnniintrin.h new file mode 100755 index 0000000..0fb381a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vnniintrin.h @@ -0,0 +1,116 @@ +/*===------------- avx512vnniintrin.h - VNNI intrinsics ------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVX512VNNIINTRIN_H +#define __AVX512VNNIINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vnni,evex512"), __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_dpbusd_epi32(__m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpdpbusd512((__v16si)__S, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpbusd_epi32(__m512i __S, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpbusd_epi32(__S, __A, __B), + (__v16si)__S); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_dpbusd_epi32(__mmask16 __U, __m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpbusd_epi32(__S, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_dpbusds_epi32(__m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpdpbusds512((__v16si)__S, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpbusds_epi32(__m512i __S, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpbusds_epi32(__S, __A, __B), + (__v16si)__S); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_dpbusds_epi32(__mmask16 __U, __m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpbusds_epi32(__S, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_dpwssd_epi32(__m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpdpwssd512((__v16si)__S, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpwssd_epi32(__m512i __S, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpwssd_epi32(__S, __A, __B), + (__v16si)__S); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_dpwssd_epi32(__mmask16 __U, __m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpwssd_epi32(__S, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_dpwssds_epi32(__m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_vpdpwssds512((__v16si)__S, (__v16si)__A, + (__v16si)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_dpwssds_epi32(__m512i __S, __mmask16 __U, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpwssds_epi32(__S, __A, __B), + (__v16si)__S); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_dpwssds_epi32(__mmask16 __U, __m512i __S, __m512i __A, __m512i __B) +{ + return (__m512i)__builtin_ia32_selectd_512(__U, + (__v16si)_mm512_dpwssds_epi32(__S, __A, __B), + (__v16si)_mm512_setzero_si512()); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vp2intersectintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vp2intersectintrin.h new file mode 100755 index 0000000..16552ca --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vp2intersectintrin.h @@ -0,0 +1,78 @@ +/*===------- avx512vpintersectintrin.h - VP2INTERSECT intrinsics ------------=== + * + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef _AVX512VP2INTERSECT_H +#define _AVX512VP2INTERSECT_H + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vp2intersect,evex512"), \ + __min_vector_width__(512))) + +/// Store, in an even/odd pair of mask registers, the indicators of the +/// locations of value matches between dwords in operands __a and __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VP2INTERSECTD instruction. +/// +/// \param __a +/// A 512-bit vector of [16 x i32]. +/// \param __b +/// A 512-bit vector of [16 x i32] +/// \param __m0 +/// A pointer point to 16-bit mask +/// \param __m1 +/// A pointer point to 16-bit mask +static __inline__ void __DEFAULT_FN_ATTRS +_mm512_2intersect_epi32(__m512i __a, __m512i __b, __mmask16 *__m0, __mmask16 *__m1) { + __builtin_ia32_vp2intersect_d_512((__v16si)__a, (__v16si)__b, __m0, __m1); +} + +/// Store, in an even/odd pair of mask registers, the indicators of the +/// locations of value matches between quadwords in operands __a and __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VP2INTERSECTQ instruction. +/// +/// \param __a +/// A 512-bit vector of [8 x i64]. +/// \param __b +/// A 512-bit vector of [8 x i64] +/// \param __m0 +/// A pointer point to 8-bit mask +/// \param __m1 +/// A pointer point to 8-bit mask +static __inline__ void __DEFAULT_FN_ATTRS +_mm512_2intersect_epi64(__m512i __a, __m512i __b, __mmask8 *__m0, __mmask8 *__m1) { + __builtin_ia32_vp2intersect_q_512((__v8di)__a, (__v8di)__b, __m0, __m1); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vpopcntdqintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vpopcntdqintrin.h new file mode 100755 index 0000000..e24c2c5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vpopcntdqintrin.h @@ -0,0 +1,64 @@ +/*===----- avx512vpopcntdqintrin.h - AVX512VPOPCNTDQ intrinsics-------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifndef __AVX512VPOPCNTDQINTRIN_H +#define __AVX512VPOPCNTDQINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vpopcntdq,evex512"), \ + __min_vector_width__(512))) + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#else +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS +#endif + +static __inline__ __m512i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm512_popcnt_epi64(__m512i __A) { + return (__m512i)__builtin_elementwise_popcount((__v8du)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_popcnt_epi64(__m512i __W, __mmask8 __U, __m512i __A) { + return (__m512i)__builtin_ia32_selectq_512( + (__mmask8)__U, (__v8di)_mm512_popcnt_epi64(__A), (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_popcnt_epi64(__mmask8 __U, __m512i __A) { + return _mm512_mask_popcnt_epi64((__m512i)_mm512_setzero_si512(), __U, __A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm512_popcnt_epi32(__m512i __A) { + return (__m512i)__builtin_elementwise_popcount((__v16su)__A); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_mask_popcnt_epi32(__m512i __W, __mmask16 __U, __m512i __A) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_popcnt_epi32(__A), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_maskz_popcnt_epi32(__mmask16 __U, __m512i __A) { + return _mm512_mask_popcnt_epi32((__m512i)_mm512_setzero_si512(), __U, __A); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vpopcntdqvlintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vpopcntdqvlintrin.h new file mode 100755 index 0000000..b6c819b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avx512vpopcntdqvlintrin.h @@ -0,0 +1,103 @@ +/*===---- avx512vpopcntdqintrin.h - AVX512VPOPCNTDQ intrinsics -------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifndef __AVX512VPOPCNTDQVLINTRIN_H +#define __AVX512VPOPCNTDQVLINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vpopcntdq,avx512vl,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512vpopcntdq,avx512vl,no-evex512"), \ + __min_vector_width__(256))) + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr +#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 constexpr +#else +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 +#define __DEFAULT_FN_ATTRS256_CONSTEXPR __DEFAULT_FN_ATTRS256 +#endif + +static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_popcnt_epi64(__m128i __A) { + return (__m128i)__builtin_elementwise_popcount((__v2du)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_popcnt_epi64(__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i)__builtin_ia32_selectq_128( + (__mmask8)__U, (__v2di)_mm_popcnt_epi64(__A), (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_popcnt_epi64(__mmask8 __U, __m128i __A) { + return _mm_mask_popcnt_epi64((__m128i)_mm_setzero_si128(), __U, __A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_popcnt_epi32(__m128i __A) { + return (__m128i)__builtin_elementwise_popcount((__v4su)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_popcnt_epi32(__m128i __W, __mmask8 __U, __m128i __A) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_popcnt_epi32(__A), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_popcnt_epi32(__mmask8 __U, __m128i __A) { + return _mm_mask_popcnt_epi32((__m128i)_mm_setzero_si128(), __U, __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_popcnt_epi64(__m256i __A) { + return (__m256i)__builtin_elementwise_popcount((__v4du)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_popcnt_epi64(__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i)__builtin_ia32_selectq_256( + (__mmask8)__U, (__v4di)_mm256_popcnt_epi64(__A), (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_popcnt_epi64(__mmask8 __U, __m256i __A) { + return _mm256_mask_popcnt_epi64((__m256i)_mm256_setzero_si256(), __U, __A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_popcnt_epi32(__m256i __A) { + return (__m256i)__builtin_elementwise_popcount((__v8su)__A); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_popcnt_epi32(__m256i __W, __mmask8 __U, __m256i __A) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_popcnt_epi32(__A), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_popcnt_epi32(__mmask8 __U, __m256i __A) { + return _mm256_mask_popcnt_epi32((__m256i)_mm256_setzero_si256(), __U, __A); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxifmaintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxifmaintrin.h new file mode 100755 index 0000000..5c782d2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxifmaintrin.h @@ -0,0 +1,177 @@ +/*===----------------- avxifmaintrin.h - IFMA intrinsics -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVXIFMAINTRIN_H +#define __AVXIFMAINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avxifma"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avxifma"), \ + __min_vector_width__(256))) + +// must vex-encoding + +/// Multiply packed unsigned 52-bit integers in each 64-bit element of \a __Y +/// and \a __Z to form a 104-bit intermediate result. Add the high 52-bit +/// unsigned integer from the intermediate result with the corresponding +/// unsigned 64-bit integer in \a __X, and store the results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i +/// _mm_madd52hi_avx_epu64 (__m128i __X, __m128i __Y, __m128i __Z) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPMADD52HUQ instruction. +/// +/// \return +/// return __m128i dst. +/// \param __X +/// A 128-bit vector of [2 x i64] +/// \param __Y +/// A 128-bit vector of [2 x i64] +/// \param __Z +/// A 128-bit vector of [2 x i64] +/// +/// \code{.operation} +/// FOR j := 0 to 1 +/// i := j*64 +/// tmp[127:0] := ZeroExtend64(__Y[i+51:i]) * ZeroExtend64(__Z[i+51:i]) +/// dst[i+63:i] := __X[i+63:i] + ZeroExtend64(tmp[103:52]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_madd52hi_avx_epu64(__m128i __X, __m128i __Y, __m128i __Z) { + return (__m128i)__builtin_ia32_vpmadd52huq128((__v2di)__X, (__v2di)__Y, + (__v2di)__Z); +} + +/// Multiply packed unsigned 52-bit integers in each 64-bit element of \a __Y +/// and \a __Z to form a 104-bit intermediate result. Add the high 52-bit +/// unsigned integer from the intermediate result with the corresponding +/// unsigned 64-bit integer in \a __X, and store the results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i +/// _mm256_madd52hi_avx_epu64 (__m256i __X, __m256i __Y, __m256i __Z) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPMADD52HUQ instruction. +/// +/// \return +/// return __m256i dst. +/// \param __X +/// A 256-bit vector of [4 x i64] +/// \param __Y +/// A 256-bit vector of [4 x i64] +/// \param __Z +/// A 256-bit vector of [4 x i64] +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// i := j*64 +/// tmp[127:0] := ZeroExtend64(__Y[i+51:i]) * ZeroExtend64(__Z[i+51:i]) +/// dst[i+63:i] := __X[i+63:i] + ZeroExtend64(tmp[103:52]) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_madd52hi_avx_epu64(__m256i __X, __m256i __Y, __m256i __Z) { + return (__m256i)__builtin_ia32_vpmadd52huq256((__v4di)__X, (__v4di)__Y, + (__v4di)__Z); +} + +/// Multiply packed unsigned 52-bit integers in each 64-bit element of \a __Y +/// and \a __Z to form a 104-bit intermediate result. Add the low 52-bit +/// unsigned integer from the intermediate result with the corresponding +/// unsigned 64-bit integer in \a __X, and store the results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i +/// _mm_madd52lo_avx_epu64 (__m128i __X, __m128i __Y, __m128i __Z) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPMADD52LUQ instruction. +/// +/// \return +/// return __m128i dst. +/// \param __X +/// A 128-bit vector of [2 x i64] +/// \param __Y +/// A 128-bit vector of [2 x i64] +/// \param __Z +/// A 128-bit vector of [2 x i64] +/// +/// \code{.operation} +/// FOR j := 0 to 1 +/// i := j*64 +/// tmp[127:0] := ZeroExtend64(__Y[i+51:i]) * ZeroExtend64(__Z[i+51:i]) +/// dst[i+63:i] := __X[i+63:i] + ZeroExtend64(tmp[51:0]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_madd52lo_avx_epu64(__m128i __X, __m128i __Y, __m128i __Z) { + return (__m128i)__builtin_ia32_vpmadd52luq128((__v2di)__X, (__v2di)__Y, + (__v2di)__Z); +} + +/// Multiply packed unsigned 52-bit integers in each 64-bit element of \a __Y +/// and \a __Z to form a 104-bit intermediate result. Add the low 52-bit +/// unsigned integer from the intermediate result with the corresponding +/// unsigned 64-bit integer in \a __X, and store the results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i +/// _mm256_madd52lo_avx_epu64 (__m256i __X, __m256i __Y, __m256i __Z) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPMADD52LUQ instruction. +/// +/// \return +/// return __m256i dst. +/// \param __X +/// A 256-bit vector of [4 x i64] +/// \param __Y +/// A 256-bit vector of [4 x i64] +/// \param __Z +/// A 256-bit vector of [4 x i64] +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// i := j*64 +/// tmp[127:0] := ZeroExtend64(__Y[i+51:i]) * ZeroExtend64(__Z[i+51:i]) +/// dst[i+63:i] := __X[i+63:i] + ZeroExtend64(tmp[51:0]) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_madd52lo_avx_epu64(__m256i __X, __m256i __Y, __m256i __Z) { + return (__m256i)__builtin_ia32_vpmadd52luq256((__v4di)__X, (__v4di)__Y, + (__v4di)__Z); +} +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif // __AVXIFMAINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxintrin.h new file mode 100755 index 0000000..8e497a9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxintrin.h @@ -0,0 +1,5140 @@ +/*===---- avxintrin.h - AVX intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVXINTRIN_H +#define __AVXINTRIN_H + +typedef double __v4df __attribute__ ((__vector_size__ (32))); +typedef float __v8sf __attribute__ ((__vector_size__ (32))); +typedef long long __v4di __attribute__ ((__vector_size__ (32))); +typedef int __v8si __attribute__ ((__vector_size__ (32))); +typedef short __v16hi __attribute__ ((__vector_size__ (32))); +typedef char __v32qi __attribute__ ((__vector_size__ (32))); + +/* Unsigned types */ +typedef unsigned long long __v4du __attribute__ ((__vector_size__ (32))); +typedef unsigned int __v8su __attribute__ ((__vector_size__ (32))); +typedef unsigned short __v16hu __attribute__ ((__vector_size__ (32))); +typedef unsigned char __v32qu __attribute__ ((__vector_size__ (32))); + +/* We need an explicitly signed variant for char. Note that this shouldn't + * appear in the interface though. */ +typedef signed char __v32qs __attribute__((__vector_size__(32))); + +typedef float __m256 __attribute__ ((__vector_size__ (32), __aligned__(32))); +typedef double __m256d __attribute__((__vector_size__(32), __aligned__(32))); +typedef long long __m256i __attribute__((__vector_size__(32), __aligned__(32))); + +typedef float __m256_u __attribute__ ((__vector_size__ (32), __aligned__(1))); +typedef double __m256d_u __attribute__((__vector_size__(32), __aligned__(1))); +typedef long long __m256i_u __attribute__((__vector_size__(32), __aligned__(1))); + +#ifdef __SSE2__ +/* Both _Float16 and __bf16 require SSE2 being enabled. */ +typedef _Float16 __v16hf __attribute__((__vector_size__(32), __aligned__(32))); +typedef _Float16 __m256h __attribute__((__vector_size__(32), __aligned__(32))); +typedef _Float16 __m256h_u __attribute__((__vector_size__(32), __aligned__(1))); + +typedef __bf16 __v16bf __attribute__((__vector_size__(32), __aligned__(32))); +typedef __bf16 __m256bh __attribute__((__vector_size__(32), __aligned__(32))); +#endif + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("avx,no-evex512"), \ + __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx,no-evex512"), \ + __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("avx"), \ + __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avx"), \ + __min_vector_width__(128))) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS128 constexpr +#else +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS128 +#define __DEFAULT_FN_ATTRS128_CONSTEXPR __DEFAULT_FN_ATTRS +#endif + +/* Arithmetic */ +/// Adds two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \returns A 256-bit vector of [4 x double] containing the sums of both +/// operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_add_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4df)__a+(__v4df)__b); +} + +/// Adds two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \returns A 256-bit vector of [8 x float] containing the sums of both +/// operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_add_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8sf)__a+(__v8sf)__b); +} + +/// Subtracts two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSUBPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing the minuend. +/// \param __b +/// A 256-bit vector of [4 x double] containing the subtrahend. +/// \returns A 256-bit vector of [4 x double] containing the differences between +/// both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_sub_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4df)__a-(__v4df)__b); +} + +/// Subtracts two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSUBPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing the minuend. +/// \param __b +/// A 256-bit vector of [8 x float] containing the subtrahend. +/// \returns A 256-bit vector of [8 x float] containing the differences between +/// both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_sub_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8sf)__a-(__v8sf)__b); +} + +/// Adds the even-indexed values and subtracts the odd-indexed values of +/// two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDSUBPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing the left source operand. +/// \param __b +/// A 256-bit vector of [4 x double] containing the right source operand. +/// \returns A 256-bit vector of [4 x double] containing the alternating sums +/// and differences between both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_addsub_pd(__m256d __a, __m256d __b) +{ + return (__m256d)__builtin_ia32_addsubpd256((__v4df)__a, (__v4df)__b); +} + +/// Adds the even-indexed values and subtracts the odd-indexed values of +/// two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDSUBPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing the left source operand. +/// \param __b +/// A 256-bit vector of [8 x float] containing the right source operand. +/// \returns A 256-bit vector of [8 x float] containing the alternating sums and +/// differences between both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_addsub_ps(__m256 __a, __m256 __b) +{ + return (__m256)__builtin_ia32_addsubps256((__v8sf)__a, (__v8sf)__b); +} + +/// Divides two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDIVPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing the dividend. +/// \param __b +/// A 256-bit vector of [4 x double] containing the divisor. +/// \returns A 256-bit vector of [4 x double] containing the quotients of both +/// operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_div_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4df)__a/(__v4df)__b); +} + +/// Divides two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDIVPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing the dividend. +/// \param __b +/// A 256-bit vector of [8 x float] containing the divisor. +/// \returns A 256-bit vector of [8 x float] containing the quotients of both +/// operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_div_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8sf)__a/(__v8sf)__b); +} + +/// Compares two 256-bit vectors of [4 x double] and returns the greater +/// of each pair of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMAXPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the operands. +/// \returns A 256-bit vector of [4 x double] containing the maximum values +/// between both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_max_pd(__m256d __a, __m256d __b) +{ + return (__m256d)__builtin_ia32_maxpd256((__v4df)__a, (__v4df)__b); +} + +/// Compares two 256-bit vectors of [8 x float] and returns the greater +/// of each pair of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMAXPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the operands. +/// \returns A 256-bit vector of [8 x float] containing the maximum values +/// between both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_max_ps(__m256 __a, __m256 __b) +{ + return (__m256)__builtin_ia32_maxps256((__v8sf)__a, (__v8sf)__b); +} + +/// Compares two 256-bit vectors of [4 x double] and returns the lesser +/// of each pair of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMINPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the operands. +/// \returns A 256-bit vector of [4 x double] containing the minimum values +/// between both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_min_pd(__m256d __a, __m256d __b) +{ + return (__m256d)__builtin_ia32_minpd256((__v4df)__a, (__v4df)__b); +} + +/// Compares two 256-bit vectors of [8 x float] and returns the lesser +/// of each pair of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMINPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the operands. +/// \returns A 256-bit vector of [8 x float] containing the minimum values +/// between both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_min_ps(__m256 __a, __m256 __b) +{ + return (__m256)__builtin_ia32_minps256((__v8sf)__a, (__v8sf)__b); +} + +/// Multiplies two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMULPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the operands. +/// \returns A 256-bit vector of [4 x double] containing the products of both +/// operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_mul_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4df)__a * (__v4df)__b); +} + +/// Multiplies two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMULPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the operands. +/// \returns A 256-bit vector of [8 x float] containing the products of both +/// operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_mul_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8sf)__a * (__v8sf)__b); +} + +/// Calculates the square roots of the values in a 256-bit vector of +/// [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSQRTPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \returns A 256-bit vector of [4 x double] containing the square roots of the +/// values in the operand. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_sqrt_pd(__m256d __a) +{ + return (__m256d)__builtin_ia32_sqrtpd256((__v4df)__a); +} + +/// Calculates the square roots of the values in a 256-bit vector of +/// [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSQRTPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the square roots of the +/// values in the operand. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_sqrt_ps(__m256 __a) +{ + return (__m256)__builtin_ia32_sqrtps256((__v8sf)__a); +} + +/// Calculates the reciprocal square roots of the values in a 256-bit +/// vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VRSQRTPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the reciprocal square +/// roots of the values in the operand. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_rsqrt_ps(__m256 __a) +{ + return (__m256)__builtin_ia32_rsqrtps256((__v8sf)__a); +} + +/// Calculates the reciprocals of the values in a 256-bit vector of +/// [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VRCPPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the reciprocals of the +/// values in the operand. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_rcp_ps(__m256 __a) +{ + return (__m256)__builtin_ia32_rcpps256((__v8sf)__a); +} + +/// Rounds the values in a 256-bit vector of [4 x double] as specified +/// by the byte operand. The source values are rounded to integer values and +/// returned as 64-bit double-precision floating-point values. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_round_pd(__m256d V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPD instruction. +/// +/// \param V +/// A 256-bit vector of [4 x double]. +/// \param M +/// An integer value that specifies the rounding operation. \n +/// Bits [7:4] are reserved. \n +/// Bit [3] is a precision exception value: \n +/// 0: A normal PE exception is used. \n +/// 1: The PE field is not updated. \n +/// Bit [2] is the rounding control source: \n +/// 0: Use bits [1:0] of \a M. \n +/// 1: Use the current MXCSR setting. \n +/// Bits [1:0] contain the rounding control definition: \n +/// 00: Nearest. \n +/// 01: Downward (toward negative infinity). \n +/// 10: Upward (toward positive infinity). \n +/// 11: Truncated. +/// \returns A 256-bit vector of [4 x double] containing the rounded values. +#define _mm256_round_pd(V, M) \ + ((__m256d)__builtin_ia32_roundpd256((__v4df)(__m256d)(V), (M))) + +/// Rounds the values stored in a 256-bit vector of [8 x float] as +/// specified by the byte operand. The source values are rounded to integer +/// values and returned as floating-point values. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_round_ps(__m256 V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPS instruction. +/// +/// \param V +/// A 256-bit vector of [8 x float]. +/// \param M +/// An integer value that specifies the rounding operation. \n +/// Bits [7:4] are reserved. \n +/// Bit [3] is a precision exception value: \n +/// 0: A normal PE exception is used. \n +/// 1: The PE field is not updated. \n +/// Bit [2] is the rounding control source: \n +/// 0: Use bits [1:0] of \a M. \n +/// 1: Use the current MXCSR setting. \n +/// Bits [1:0] contain the rounding control definition: \n +/// 00: Nearest. \n +/// 01: Downward (toward negative infinity). \n +/// 10: Upward (toward positive infinity). \n +/// 11: Truncated. +/// \returns A 256-bit vector of [8 x float] containing the rounded values. +#define _mm256_round_ps(V, M) \ + ((__m256)__builtin_ia32_roundps256((__v8sf)(__m256)(V), (M))) + +/// Rounds up the values stored in a 256-bit vector of [4 x double]. The +/// source values are rounded up to integer values and returned as 64-bit +/// double-precision floating-point values. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_ceil_pd(__m256d V); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPD instruction. +/// +/// \param V +/// A 256-bit vector of [4 x double]. +/// \returns A 256-bit vector of [4 x double] containing the rounded up values. +#define _mm256_ceil_pd(V) _mm256_round_pd((V), _MM_FROUND_CEIL) + +/// Rounds down the values stored in a 256-bit vector of [4 x double]. +/// The source values are rounded down to integer values and returned as +/// 64-bit double-precision floating-point values. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_floor_pd(__m256d V); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPD instruction. +/// +/// \param V +/// A 256-bit vector of [4 x double]. +/// \returns A 256-bit vector of [4 x double] containing the rounded down +/// values. +#define _mm256_floor_pd(V) _mm256_round_pd((V), _MM_FROUND_FLOOR) + +/// Rounds up the values stored in a 256-bit vector of [8 x float]. The +/// source values are rounded up to integer values and returned as +/// floating-point values. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_ceil_ps(__m256 V); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPS instruction. +/// +/// \param V +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the rounded up values. +#define _mm256_ceil_ps(V) _mm256_round_ps((V), _MM_FROUND_CEIL) + +/// Rounds down the values stored in a 256-bit vector of [8 x float]. The +/// source values are rounded down to integer values and returned as +/// floating-point values. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_floor_ps(__m256 V); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPS instruction. +/// +/// \param V +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the rounded down values. +#define _mm256_floor_ps(V) _mm256_round_ps((V), _MM_FROUND_FLOOR) + +/* Logical */ +/// Performs a bitwise AND of two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VANDPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \returns A 256-bit vector of [4 x double] containing the bitwise AND of the +/// values between both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_and_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4du)__a & (__v4du)__b); +} + +/// Performs a bitwise AND of two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VANDPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \returns A 256-bit vector of [8 x float] containing the bitwise AND of the +/// values between both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_and_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8su)__a & (__v8su)__b); +} + +/// Performs a bitwise AND of two 256-bit vectors of [4 x double], using +/// the one's complement of the values contained in the first source operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VANDNPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing the left source operand. The +/// one's complement of this value is used in the bitwise AND. +/// \param __b +/// A 256-bit vector of [4 x double] containing the right source operand. +/// \returns A 256-bit vector of [4 x double] containing the bitwise AND of the +/// values of the second operand and the one's complement of the first +/// operand. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_andnot_pd(__m256d __a, __m256d __b) +{ + return (__m256d)(~(__v4du)__a & (__v4du)__b); +} + +/// Performs a bitwise AND of two 256-bit vectors of [8 x float], using +/// the one's complement of the values contained in the first source operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VANDNPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing the left source operand. The +/// one's complement of this value is used in the bitwise AND. +/// \param __b +/// A 256-bit vector of [8 x float] containing the right source operand. +/// \returns A 256-bit vector of [8 x float] containing the bitwise AND of the +/// values of the second operand and the one's complement of the first +/// operand. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_andnot_ps(__m256 __a, __m256 __b) +{ + return (__m256)(~(__v8su)__a & (__v8su)__b); +} + +/// Performs a bitwise OR of two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VORPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \returns A 256-bit vector of [4 x double] containing the bitwise OR of the +/// values between both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_or_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4du)__a | (__v4du)__b); +} + +/// Performs a bitwise OR of two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VORPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \returns A 256-bit vector of [8 x float] containing the bitwise OR of the +/// values between both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_or_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8su)__a | (__v8su)__b); +} + +/// Performs a bitwise XOR of two 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// \returns A 256-bit vector of [4 x double] containing the bitwise XOR of the +/// values between both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_xor_pd(__m256d __a, __m256d __b) +{ + return (__m256d)((__v4du)__a ^ (__v4du)__b); +} + +/// Performs a bitwise XOR of two 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// \returns A 256-bit vector of [8 x float] containing the bitwise XOR of the +/// values between both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_xor_ps(__m256 __a, __m256 __b) +{ + return (__m256)((__v8su)__a ^ (__v8su)__b); +} + +/* Horizontal arithmetic */ +/// Horizontally adds the adjacent pairs of values contained in two +/// 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHADDPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// The horizontal sums of the values are returned in the even-indexed +/// elements of a vector of [4 x double]. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// The horizontal sums of the values are returned in the odd-indexed +/// elements of a vector of [4 x double]. +/// \returns A 256-bit vector of [4 x double] containing the horizontal sums of +/// both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_hadd_pd(__m256d __a, __m256d __b) +{ + return (__m256d)__builtin_ia32_haddpd256((__v4df)__a, (__v4df)__b); +} + +/// Horizontally adds the adjacent pairs of values contained in two +/// 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHADDPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// The horizontal sums of the values are returned in the elements with +/// index 0, 1, 4, 5 of a vector of [8 x float]. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// The horizontal sums of the values are returned in the elements with +/// index 2, 3, 6, 7 of a vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the horizontal sums of +/// both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_hadd_ps(__m256 __a, __m256 __b) +{ + return (__m256)__builtin_ia32_haddps256((__v8sf)__a, (__v8sf)__b); +} + +/// Horizontally subtracts the adjacent pairs of values contained in two +/// 256-bit vectors of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHSUBPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// The horizontal differences between the values are returned in the +/// even-indexed elements of a vector of [4 x double]. +/// \param __b +/// A 256-bit vector of [4 x double] containing one of the source operands. +/// The horizontal differences between the values are returned in the +/// odd-indexed elements of a vector of [4 x double]. +/// \returns A 256-bit vector of [4 x double] containing the horizontal +/// differences of both operands. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_hsub_pd(__m256d __a, __m256d __b) +{ + return (__m256d)__builtin_ia32_hsubpd256((__v4df)__a, (__v4df)__b); +} + +/// Horizontally subtracts the adjacent pairs of values contained in two +/// 256-bit vectors of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHSUBPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// The horizontal differences between the values are returned in the +/// elements with index 0, 1, 4, 5 of a vector of [8 x float]. +/// \param __b +/// A 256-bit vector of [8 x float] containing one of the source operands. +/// The horizontal differences between the values are returned in the +/// elements with index 2, 3, 6, 7 of a vector of [8 x float]. +/// \returns A 256-bit vector of [8 x float] containing the horizontal +/// differences of both operands. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_hsub_ps(__m256 __a, __m256 __b) +{ + return (__m256)__builtin_ia32_hsubps256((__v8sf)__a, (__v8sf)__b); +} + +/* Vector permutations */ +/// Copies the values in a 128-bit vector of [2 x double] as specified +/// by the 128-bit integer vector operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __c +/// A 128-bit integer vector operand specifying how the values are to be +/// copied. \n +/// Bit [1]: \n +/// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned +/// vector. \n +/// 1: Bits [127:64] of the source are copied to bits [63:0] of the +/// returned vector. \n +/// Bit [65]: \n +/// 0: Bits [63:0] of the source are copied to bits [127:64] of the +/// returned vector. \n +/// 1: Bits [127:64] of the source are copied to bits [127:64] of the +/// returned vector. +/// \returns A 128-bit vector of [2 x double] containing the copied values. +static __inline __m128d __DEFAULT_FN_ATTRS128 +_mm_permutevar_pd(__m128d __a, __m128i __c) +{ + return (__m128d)__builtin_ia32_vpermilvarpd((__v2df)__a, (__v2di)__c); +} + +/// Copies the values in a 256-bit vector of [4 x double] as specified +/// by the 256-bit integer vector operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \param __c +/// A 256-bit integer vector operand specifying how the values are to be +/// copied. \n +/// Bit [1]: \n +/// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned +/// vector. \n +/// 1: Bits [127:64] of the source are copied to bits [63:0] of the +/// returned vector. \n +/// Bit [65]: \n +/// 0: Bits [63:0] of the source are copied to bits [127:64] of the +/// returned vector. \n +/// 1: Bits [127:64] of the source are copied to bits [127:64] of the +/// returned vector. \n +/// Bit [129]: \n +/// 0: Bits [191:128] of the source are copied to bits [191:128] of the +/// returned vector. \n +/// 1: Bits [255:192] of the source are copied to bits [191:128] of the +/// returned vector. \n +/// Bit [193]: \n +/// 0: Bits [191:128] of the source are copied to bits [255:192] of the +/// returned vector. \n +/// 1: Bits [255:192] of the source are copied to bits [255:192] of the +/// returned vector. +/// \returns A 256-bit vector of [4 x double] containing the copied values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_permutevar_pd(__m256d __a, __m256i __c) +{ + return (__m256d)__builtin_ia32_vpermilvarpd256((__v4df)__a, (__v4di)__c); +} + +/// Copies the values stored in a 128-bit vector of [4 x float] as +/// specified by the 128-bit integer vector operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __c +/// A 128-bit integer vector operand specifying how the values are to be +/// copied. \n +/// Bits [1:0]: \n +/// 00: Bits [31:0] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// Bits [33:32]: \n +/// 00: Bits [31:0] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// Bits [65:64]: \n +/// 00: Bits [31:0] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// Bits [97:96]: \n +/// 00: Bits [31:0] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [127:96] of the +/// returned vector. +/// \returns A 128-bit vector of [4 x float] containing the copied values. +static __inline __m128 __DEFAULT_FN_ATTRS128 +_mm_permutevar_ps(__m128 __a, __m128i __c) +{ + return (__m128)__builtin_ia32_vpermilvarps((__v4sf)__a, (__v4si)__c); +} + +/// Copies the values stored in a 256-bit vector of [8 x float] as +/// specified by the 256-bit integer vector operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \param __c +/// A 256-bit integer vector operand specifying how the values are to be +/// copied. \n +/// Bits [1:0]: \n +/// 00: Bits [31:0] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// Bits [33:32]: \n +/// 00: Bits [31:0] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// Bits [65:64]: \n +/// 00: Bits [31:0] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// Bits [97:96]: \n +/// 00: Bits [31:0] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// Bits [129:128]: \n +/// 00: Bits [159:128] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// Bits [161:160]: \n +/// 00: Bits [159:128] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// Bits [193:192]: \n +/// 00: Bits [159:128] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// Bits [225:224]: \n +/// 00: Bits [159:128] of the source are copied to bits [255:224] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [255:224] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [255:224] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [255:224] of the +/// returned vector. +/// \returns A 256-bit vector of [8 x float] containing the copied values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_permutevar_ps(__m256 __a, __m256i __c) +{ + return (__m256)__builtin_ia32_vpermilvarps256((__v8sf)__a, (__v8si)__c); +} + +/// Copies the values in a 128-bit vector of [2 x double] as specified +/// by the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_permute_pd(__m128d A, const int C); +/// \endcode +/// +/// This intrinsic corresponds to the VPERMILPD instruction. +/// +/// \param A +/// A 128-bit vector of [2 x double]. +/// \param C +/// An immediate integer operand specifying how the values are to be +/// copied. \n +/// Bit [0]: \n +/// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned +/// vector. \n +/// 1: Bits [127:64] of the source are copied to bits [63:0] of the +/// returned vector. \n +/// Bit [1]: \n +/// 0: Bits [63:0] of the source are copied to bits [127:64] of the +/// returned vector. \n +/// 1: Bits [127:64] of the source are copied to bits [127:64] of the +/// returned vector. +/// \returns A 128-bit vector of [2 x double] containing the copied values. +#define _mm_permute_pd(A, C) \ + ((__m128d)__builtin_ia32_vpermilpd((__v2df)(__m128d)(A), (int)(C))) + +/// Copies the values in a 256-bit vector of [4 x double] as specified by +/// the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_permute_pd(__m256d A, const int C); +/// \endcode +/// +/// This intrinsic corresponds to the VPERMILPD instruction. +/// +/// \param A +/// A 256-bit vector of [4 x double]. +/// \param C +/// An immediate integer operand specifying how the values are to be +/// copied. \n +/// Bit [0]: \n +/// 0: Bits [63:0] of the source are copied to bits [63:0] of the returned +/// vector. \n +/// 1: Bits [127:64] of the source are copied to bits [63:0] of the +/// returned vector. \n +/// Bit [1]: \n +/// 0: Bits [63:0] of the source are copied to bits [127:64] of the +/// returned vector. \n +/// 1: Bits [127:64] of the source are copied to bits [127:64] of the +/// returned vector. \n +/// Bit [2]: \n +/// 0: Bits [191:128] of the source are copied to bits [191:128] of the +/// returned vector. \n +/// 1: Bits [255:192] of the source are copied to bits [191:128] of the +/// returned vector. \n +/// Bit [3]: \n +/// 0: Bits [191:128] of the source are copied to bits [255:192] of the +/// returned vector. \n +/// 1: Bits [255:192] of the source are copied to bits [255:192] of the +/// returned vector. +/// \returns A 256-bit vector of [4 x double] containing the copied values. +#define _mm256_permute_pd(A, C) \ + ((__m256d)__builtin_ia32_vpermilpd256((__v4df)(__m256d)(A), (int)(C))) + +/// Copies the values in a 128-bit vector of [4 x float] as specified by +/// the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_permute_ps(__m128 A, const int C); +/// \endcode +/// +/// This intrinsic corresponds to the VPERMILPS instruction. +/// +/// \param A +/// A 128-bit vector of [4 x float]. +/// \param C +/// An immediate integer operand specifying how the values are to be +/// copied. \n +/// Bits [1:0]: \n +/// 00: Bits [31:0] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// Bits [3:2]: \n +/// 00: Bits [31:0] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// Bits [5:4]: \n +/// 00: Bits [31:0] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// Bits [7:6]: \n +/// 00: Bits [31:0] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [127:96] of the +/// returned vector. +/// \returns A 128-bit vector of [4 x float] containing the copied values. +#define _mm_permute_ps(A, C) \ + ((__m128)__builtin_ia32_vpermilps((__v4sf)(__m128)(A), (int)(C))) + +/// Copies the values in a 256-bit vector of [8 x float] as specified by +/// the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_permute_ps(__m256 A, const int C); +/// \endcode +/// +/// This intrinsic corresponds to the VPERMILPS instruction. +/// +/// \param A +/// A 256-bit vector of [8 x float]. +/// \param C +/// An immediate integer operand specifying how the values are to be +/// copied. \n +/// Bits [1:0]: \n +/// 00: Bits [31:0] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [31:0] of the +/// returned vector. \n +/// Bits [3:2]: \n +/// 00: Bits [31:0] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [63:32] of the +/// returned vector. \n +/// Bits [5:4]: \n +/// 00: Bits [31:0] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [95:64] of the +/// returned vector. \n +/// Bits [7:6]: \n +/// 00: Bits [31:0] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 01: Bits [63:32] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 10: Bits [95:64] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// 11: Bits [127:96] of the source are copied to bits [127:96] of the +/// returned vector. \n +/// Bits [1:0]: \n +/// 00: Bits [159:128] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [159:128] of the +/// returned vector. \n +/// Bits [3:2]: \n +/// 00: Bits [159:128] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [191:160] of the +/// returned vector. \n +/// Bits [5:4]: \n +/// 00: Bits [159:128] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [223:192] of the +/// returned vector. \n +/// Bits [7:6]: \n +/// 00: Bits [159:128] of the source are copied to bits [255:224] of the +/// returned vector. \n +/// 01: Bits [191:160] of the source are copied to bits [255:224] of the +/// returned vector. \n +/// 10: Bits [223:192] of the source are copied to bits [255:224] of the +/// returned vector. \n +/// 11: Bits [255:224] of the source are copied to bits [255:224] of the +/// returned vector. +/// \returns A 256-bit vector of [8 x float] containing the copied values. +#define _mm256_permute_ps(A, C) \ + ((__m256)__builtin_ia32_vpermilps256((__v8sf)(__m256)(A), (int)(C))) + +/// Permutes 128-bit data values stored in two 256-bit vectors of +/// [4 x double], as specified by the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_permute2f128_pd(__m256d V1, __m256d V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPERM2F128 instruction. +/// +/// \param V1 +/// A 256-bit vector of [4 x double]. +/// \param V2 +/// A 256-bit vector of [4 x double. +/// \param M +/// An immediate integer operand specifying how the values are to be +/// permuted. \n +/// Bits [1:0]: \n +/// 00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the +/// destination. \n +/// 01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the +/// destination. \n +/// 10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the +/// destination. \n +/// 11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the +/// destination. \n +/// Bits [5:4]: \n +/// 00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the +/// destination. \n +/// 01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the +/// destination. \n +/// 10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the +/// destination. \n +/// 11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the +/// destination. +/// \returns A 256-bit vector of [4 x double] containing the copied values. +#define _mm256_permute2f128_pd(V1, V2, M) \ + ((__m256d)__builtin_ia32_vperm2f128_pd256((__v4df)(__m256d)(V1), \ + (__v4df)(__m256d)(V2), (int)(M))) + +/// Permutes 128-bit data values stored in two 256-bit vectors of +/// [8 x float], as specified by the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_permute2f128_ps(__m256 V1, __m256 V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPERM2F128 instruction. +/// +/// \param V1 +/// A 256-bit vector of [8 x float]. +/// \param V2 +/// A 256-bit vector of [8 x float]. +/// \param M +/// An immediate integer operand specifying how the values are to be +/// permuted. \n +/// Bits [1:0]: \n +/// 00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the +/// destination. \n +/// 01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the +/// destination. \n +/// 10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the +/// destination. \n +/// 11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the +/// destination. \n +/// Bits [5:4]: \n +/// 00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the +/// destination. \n +/// 01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the +/// destination. \n +/// 10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the +/// destination. \n +/// 11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the +/// destination. +/// \returns A 256-bit vector of [8 x float] containing the copied values. +#define _mm256_permute2f128_ps(V1, V2, M) \ + ((__m256)__builtin_ia32_vperm2f128_ps256((__v8sf)(__m256)(V1), \ + (__v8sf)(__m256)(V2), (int)(M))) + +/// Permutes 128-bit data values stored in two 256-bit integer vectors, +/// as specified by the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_permute2f128_si256(__m256i V1, __m256i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPERM2F128 instruction. +/// +/// \param V1 +/// A 256-bit integer vector. +/// \param V2 +/// A 256-bit integer vector. +/// \param M +/// An immediate integer operand specifying how the values are to be copied. +/// Bits [1:0]: \n +/// 00: Bits [127:0] of operand \a V1 are copied to bits [127:0] of the +/// destination. \n +/// 01: Bits [255:128] of operand \a V1 are copied to bits [127:0] of the +/// destination. \n +/// 10: Bits [127:0] of operand \a V2 are copied to bits [127:0] of the +/// destination. \n +/// 11: Bits [255:128] of operand \a V2 are copied to bits [127:0] of the +/// destination. \n +/// Bits [5:4]: \n +/// 00: Bits [127:0] of operand \a V1 are copied to bits [255:128] of the +/// destination. \n +/// 01: Bits [255:128] of operand \a V1 are copied to bits [255:128] of the +/// destination. \n +/// 10: Bits [127:0] of operand \a V2 are copied to bits [255:128] of the +/// destination. \n +/// 11: Bits [255:128] of operand \a V2 are copied to bits [255:128] of the +/// destination. +/// \returns A 256-bit integer vector containing the copied values. +#define _mm256_permute2f128_si256(V1, V2, M) \ + ((__m256i)__builtin_ia32_vperm2f128_si256((__v8si)(__m256i)(V1), \ + (__v8si)(__m256i)(V2), (int)(M))) + +/* Vector Blend */ +/// Merges 64-bit double-precision data values stored in either of the +/// two 256-bit vectors of [4 x double], as specified by the immediate +/// integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_blend_pd(__m256d V1, __m256d V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VBLENDPD instruction. +/// +/// \param V1 +/// A 256-bit vector of [4 x double]. +/// \param V2 +/// A 256-bit vector of [4 x double]. +/// \param M +/// An immediate integer operand, with mask bits [3:0] specifying how the +/// values are to be copied. The position of the mask bit corresponds to the +/// index of a copied value. When a mask bit is 0, the corresponding 64-bit +/// element in operand \a V1 is copied to the same position in the +/// destination. When a mask bit is 1, the corresponding 64-bit element in +/// operand \a V2 is copied to the same position in the destination. +/// \returns A 256-bit vector of [4 x double] containing the copied values. +#define _mm256_blend_pd(V1, V2, M) \ + ((__m256d)__builtin_ia32_blendpd256((__v4df)(__m256d)(V1), \ + (__v4df)(__m256d)(V2), (int)(M))) + +/// Merges 32-bit single-precision data values stored in either of the +/// two 256-bit vectors of [8 x float], as specified by the immediate +/// integer operand. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_blend_ps(__m256 V1, __m256 V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VBLENDPS instruction. +/// +/// \param V1 +/// A 256-bit vector of [8 x float]. +/// \param V2 +/// A 256-bit vector of [8 x float]. +/// \param M +/// An immediate integer operand, with mask bits [7:0] specifying how the +/// values are to be copied. The position of the mask bit corresponds to the +/// index of a copied value. When a mask bit is 0, the corresponding 32-bit +/// element in operand \a V1 is copied to the same position in the +/// destination. When a mask bit is 1, the corresponding 32-bit element in +/// operand \a V2 is copied to the same position in the destination. +/// \returns A 256-bit vector of [8 x float] containing the copied values. +#define _mm256_blend_ps(V1, V2, M) \ + ((__m256)__builtin_ia32_blendps256((__v8sf)(__m256)(V1), \ + (__v8sf)(__m256)(V2), (int)(M))) + +/// Merges 64-bit double-precision data values stored in either of the +/// two 256-bit vectors of [4 x double], as specified by the 256-bit vector +/// operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBLENDVPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \param __b +/// A 256-bit vector of [4 x double]. +/// \param __c +/// A 256-bit vector operand, with mask bits 255, 191, 127, and 63 specifying +/// how the values are to be copied. The position of the mask bit corresponds +/// to the most significant bit of a copied value. When a mask bit is 0, the +/// corresponding 64-bit element in operand \a __a is copied to the same +/// position in the destination. When a mask bit is 1, the corresponding +/// 64-bit element in operand \a __b is copied to the same position in the +/// destination. +/// \returns A 256-bit vector of [4 x double] containing the copied values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_blendv_pd(__m256d __a, __m256d __b, __m256d __c) +{ + return (__m256d)__builtin_ia32_blendvpd256( + (__v4df)__a, (__v4df)__b, (__v4df)__c); +} + +/// Merges 32-bit single-precision data values stored in either of the +/// two 256-bit vectors of [8 x float], as specified by the 256-bit vector +/// operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBLENDVPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \param __b +/// A 256-bit vector of [8 x float]. +/// \param __c +/// A 256-bit vector operand, with mask bits 255, 223, 191, 159, 127, 95, 63, +/// and 31 specifying how the values are to be copied. The position of the +/// mask bit corresponds to the most significant bit of a copied value. When +/// a mask bit is 0, the corresponding 32-bit element in operand \a __a is +/// copied to the same position in the destination. When a mask bit is 1, the +/// corresponding 32-bit element in operand \a __b is copied to the same +/// position in the destination. +/// \returns A 256-bit vector of [8 x float] containing the copied values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_blendv_ps(__m256 __a, __m256 __b, __m256 __c) +{ + return (__m256)__builtin_ia32_blendvps256( + (__v8sf)__a, (__v8sf)__b, (__v8sf)__c); +} + +/* Vector Dot Product */ +/// Computes two dot products in parallel, using the lower and upper +/// halves of two [8 x float] vectors as input to the two computations, and +/// returning the two dot products in the lower and upper halves of the +/// [8 x float] result. +/// +/// The immediate integer operand controls which input elements will +/// contribute to the dot product, and where the final results are returned. +/// In general, for each dot product, the four corresponding elements of the +/// input vectors are multiplied; the first two and second two products are +/// summed, then the two sums are added to form the final result. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_dp_ps(__m256 V1, __m256 V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VDPPS instruction. +/// +/// \param V1 +/// A vector of [8 x float] values, treated as two [4 x float] vectors. +/// \param V2 +/// A vector of [8 x float] values, treated as two [4 x float] vectors. +/// \param M +/// An immediate integer argument. Bits [7:4] determine which elements of +/// the input vectors are used, with bit [4] corresponding to the lowest +/// element and bit [7] corresponding to the highest element of each [4 x +/// float] subvector. If a bit is set, the corresponding elements from the +/// two input vectors are used as an input for dot product; otherwise that +/// input is treated as zero. Bits [3:0] determine which elements of the +/// result will receive a copy of the final dot product, with bit [0] +/// corresponding to the lowest element and bit [3] corresponding to the +/// highest element of each [4 x float] subvector. If a bit is set, the dot +/// product is returned in the corresponding element; otherwise that element +/// is set to zero. The bitmask is applied in the same way to each of the +/// two parallel dot product computations. +/// \returns A 256-bit vector of [8 x float] containing the two dot products. +#define _mm256_dp_ps(V1, V2, M) \ + ((__m256)__builtin_ia32_dpps256((__v8sf)(__m256)(V1), \ + (__v8sf)(__m256)(V2), (M))) + +/* Vector shuffle */ +/// Selects 8 float values from the 256-bit operands of [8 x float], as +/// specified by the immediate value operand. +/// +/// The four selected elements in each operand are copied to the destination +/// according to the bits specified in the immediate operand. The selected +/// elements from the first 256-bit operand are copied to bits [63:0] and +/// bits [191:128] of the destination, and the selected elements from the +/// second 256-bit operand are copied to bits [127:64] and bits [255:192] of +/// the destination. For example, if bits [7:0] of the immediate operand +/// contain a value of 0xFF, the 256-bit destination vector would contain the +/// following values: b[7], b[7], a[7], a[7], b[3], b[3], a[3], a[3]. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_shuffle_ps(__m256 a, __m256 b, const int mask); +/// \endcode +/// +/// This intrinsic corresponds to the VSHUFPS instruction. +/// +/// \param a +/// A 256-bit vector of [8 x float]. The four selected elements in this +/// operand are copied to bits [63:0] and bits [191:128] in the destination, +/// according to the bits specified in the immediate operand. +/// \param b +/// A 256-bit vector of [8 x float]. The four selected elements in this +/// operand are copied to bits [127:64] and bits [255:192] in the +/// destination, according to the bits specified in the immediate operand. +/// \param mask +/// An immediate value containing an 8-bit value specifying which elements to +/// copy from \a a and \a b \n. +/// Bits [3:0] specify the values copied from operand \a a. \n +/// Bits [7:4] specify the values copied from operand \a b. \n +/// The destinations within the 256-bit destination are assigned values as +/// follows, according to the bit value assignments described below: \n +/// Bits [1:0] are used to assign values to bits [31:0] and [159:128] in the +/// destination. \n +/// Bits [3:2] are used to assign values to bits [63:32] and [191:160] in the +/// destination. \n +/// Bits [5:4] are used to assign values to bits [95:64] and [223:192] in the +/// destination. \n +/// Bits [7:6] are used to assign values to bits [127:96] and [255:224] in +/// the destination. \n +/// Bit value assignments: \n +/// 00: Bits [31:0] and [159:128] are copied from the selected operand. \n +/// 01: Bits [63:32] and [191:160] are copied from the selected operand. \n +/// 10: Bits [95:64] and [223:192] are copied from the selected operand. \n +/// 11: Bits [127:96] and [255:224] are copied from the selected operand. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE macro. +/// _MM_SHUFFLE(b6, b4, b2, b0) can create an 8-bit mask of the form +/// [b6, b4, b2, b0]. +/// \returns A 256-bit vector of [8 x float] containing the shuffled values. +#define _mm256_shuffle_ps(a, b, mask) \ + ((__m256)__builtin_ia32_shufps256((__v8sf)(__m256)(a), \ + (__v8sf)(__m256)(b), (int)(mask))) + +/// Selects four double-precision values from the 256-bit operands of +/// [4 x double], as specified by the immediate value operand. +/// +/// The selected elements from the first 256-bit operand are copied to bits +/// [63:0] and bits [191:128] in the destination, and the selected elements +/// from the second 256-bit operand are copied to bits [127:64] and bits +/// [255:192] in the destination. For example, if bits [3:0] of the immediate +/// operand contain a value of 0xF, the 256-bit destination vector would +/// contain the following values: b[3], a[3], b[1], a[1]. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_shuffle_pd(__m256d a, __m256d b, const int mask); +/// \endcode +/// +/// This intrinsic corresponds to the VSHUFPD instruction. +/// +/// \param a +/// A 256-bit vector of [4 x double]. +/// \param b +/// A 256-bit vector of [4 x double]. +/// \param mask +/// An immediate value containing 8-bit values specifying which elements to +/// copy from \a a and \a b: \n +/// Bit [0]=0: Bits [63:0] are copied from \a a to bits [63:0] of the +/// destination. \n +/// Bit [0]=1: Bits [127:64] are copied from \a a to bits [63:0] of the +/// destination. \n +/// Bit [1]=0: Bits [63:0] are copied from \a b to bits [127:64] of the +/// destination. \n +/// Bit [1]=1: Bits [127:64] are copied from \a b to bits [127:64] of the +/// destination. \n +/// Bit [2]=0: Bits [191:128] are copied from \a a to bits [191:128] of the +/// destination. \n +/// Bit [2]=1: Bits [255:192] are copied from \a a to bits [191:128] of the +/// destination. \n +/// Bit [3]=0: Bits [191:128] are copied from \a b to bits [255:192] of the +/// destination. \n +/// Bit [3]=1: Bits [255:192] are copied from \a b to bits [255:192] of the +/// destination. +/// \returns A 256-bit vector of [4 x double] containing the shuffled values. +#define _mm256_shuffle_pd(a, b, mask) \ + ((__m256d)__builtin_ia32_shufpd256((__v4df)(__m256d)(a), \ + (__v4df)(__m256d)(b), (int)(mask))) + +/* Compare */ +#define _CMP_EQ_UQ 0x08 /* Equal (unordered, non-signaling) */ +#define _CMP_NGE_US 0x09 /* Not-greater-than-or-equal (unordered, signaling) */ +#define _CMP_NGT_US 0x0a /* Not-greater-than (unordered, signaling) */ +#define _CMP_FALSE_OQ 0x0b /* False (ordered, non-signaling) */ +#define _CMP_NEQ_OQ 0x0c /* Not-equal (ordered, non-signaling) */ +#define _CMP_GE_OS 0x0d /* Greater-than-or-equal (ordered, signaling) */ +#define _CMP_GT_OS 0x0e /* Greater-than (ordered, signaling) */ +#define _CMP_TRUE_UQ 0x0f /* True (unordered, non-signaling) */ +#define _CMP_EQ_OS 0x10 /* Equal (ordered, signaling) */ +#define _CMP_LT_OQ 0x11 /* Less-than (ordered, non-signaling) */ +#define _CMP_LE_OQ 0x12 /* Less-than-or-equal (ordered, non-signaling) */ +#define _CMP_UNORD_S 0x13 /* Unordered (signaling) */ +#define _CMP_NEQ_US 0x14 /* Not-equal (unordered, signaling) */ +#define _CMP_NLT_UQ 0x15 /* Not-less-than (unordered, non-signaling) */ +#define _CMP_NLE_UQ 0x16 /* Not-less-than-or-equal (unordered, non-signaling) */ +#define _CMP_ORD_S 0x17 /* Ordered (signaling) */ +#define _CMP_EQ_US 0x18 /* Equal (unordered, signaling) */ +#define _CMP_NGE_UQ 0x19 /* Not-greater-than-or-equal (unordered, non-signaling) */ +#define _CMP_NGT_UQ 0x1a /* Not-greater-than (unordered, non-signaling) */ +#define _CMP_FALSE_OS 0x1b /* False (ordered, signaling) */ +#define _CMP_NEQ_OS 0x1c /* Not-equal (ordered, signaling) */ +#define _CMP_GE_OQ 0x1d /* Greater-than-or-equal (ordered, non-signaling) */ +#define _CMP_GT_OQ 0x1e /* Greater-than (ordered, non-signaling) */ +#define _CMP_TRUE_US 0x1f /* True (unordered, signaling) */ + +/* Below intrinsic defined in emmintrin.h can be used for AVX */ +/// Compares each of the corresponding double-precision values of two +/// 128-bit vectors of [2 x double], using the operation specified by the +/// immediate integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_cmp_pd(__m128d a, __m128d b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the VCMPPD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double]. +/// \param b +/// A 128-bit vector of [2 x double]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// 0x08: Equal (unordered, non-signaling) \n +/// 0x09: Not-greater-than-or-equal (unordered, signaling) \n +/// 0x0A: Not-greater-than (unordered, signaling) \n +/// 0x0B: False (ordered, non-signaling) \n +/// 0x0C: Not-equal (ordered, non-signaling) \n +/// 0x0D: Greater-than-or-equal (ordered, signaling) \n +/// 0x0E: Greater-than (ordered, signaling) \n +/// 0x0F: True (unordered, non-signaling) \n +/// 0x10: Equal (ordered, signaling) \n +/// 0x11: Less-than (ordered, non-signaling) \n +/// 0x12: Less-than-or-equal (ordered, non-signaling) \n +/// 0x13: Unordered (signaling) \n +/// 0x14: Not-equal (unordered, signaling) \n +/// 0x15: Not-less-than (unordered, non-signaling) \n +/// 0x16: Not-less-than-or-equal (unordered, non-signaling) \n +/// 0x17: Ordered (signaling) \n +/// 0x18: Equal (unordered, signaling) \n +/// 0x19: Not-greater-than-or-equal (unordered, non-signaling) \n +/// 0x1A: Not-greater-than (unordered, non-signaling) \n +/// 0x1B: False (ordered, signaling) \n +/// 0x1C: Not-equal (ordered, signaling) \n +/// 0x1D: Greater-than-or-equal (ordered, non-signaling) \n +/// 0x1E: Greater-than (ordered, non-signaling) \n +/// 0x1F: True (unordered, signaling) +/// \returns A 128-bit vector of [2 x double] containing the comparison results. +/// \fn __m128d _mm_cmp_pd(__m128d a, __m128d b, const int c) + +/* Below intrinsic defined in xmmintrin.h can be used for AVX */ +/// Compares each of the corresponding values of two 128-bit vectors of +/// [4 x float], using the operation specified by the immediate integer +/// operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_cmp_ps(__m128 a, __m128 b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the VCMPPS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float]. +/// \param b +/// A 128-bit vector of [4 x float]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// 0x08: Equal (unordered, non-signaling) \n +/// 0x09: Not-greater-than-or-equal (unordered, signaling) \n +/// 0x0A: Not-greater-than (unordered, signaling) \n +/// 0x0B: False (ordered, non-signaling) \n +/// 0x0C: Not-equal (ordered, non-signaling) \n +/// 0x0D: Greater-than-or-equal (ordered, signaling) \n +/// 0x0E: Greater-than (ordered, signaling) \n +/// 0x0F: True (unordered, non-signaling) \n +/// 0x10: Equal (ordered, signaling) \n +/// 0x11: Less-than (ordered, non-signaling) \n +/// 0x12: Less-than-or-equal (ordered, non-signaling) \n +/// 0x13: Unordered (signaling) \n +/// 0x14: Not-equal (unordered, signaling) \n +/// 0x15: Not-less-than (unordered, non-signaling) \n +/// 0x16: Not-less-than-or-equal (unordered, non-signaling) \n +/// 0x17: Ordered (signaling) \n +/// 0x18: Equal (unordered, signaling) \n +/// 0x19: Not-greater-than-or-equal (unordered, non-signaling) \n +/// 0x1A: Not-greater-than (unordered, non-signaling) \n +/// 0x1B: False (ordered, signaling) \n +/// 0x1C: Not-equal (ordered, signaling) \n +/// 0x1D: Greater-than-or-equal (ordered, non-signaling) \n +/// 0x1E: Greater-than (ordered, non-signaling) \n +/// 0x1F: True (unordered, signaling) +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +/// \fn __m128 _mm_cmp_ps(__m128 a, __m128 b, const int c) + +/// Compares each of the corresponding double-precision values of two +/// 256-bit vectors of [4 x double], using the operation specified by the +/// immediate integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_cmp_pd(__m256d a, __m256d b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the VCMPPD instruction. +/// +/// \param a +/// A 256-bit vector of [4 x double]. +/// \param b +/// A 256-bit vector of [4 x double]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// 0x08: Equal (unordered, non-signaling) \n +/// 0x09: Not-greater-than-or-equal (unordered, signaling) \n +/// 0x0A: Not-greater-than (unordered, signaling) \n +/// 0x0B: False (ordered, non-signaling) \n +/// 0x0C: Not-equal (ordered, non-signaling) \n +/// 0x0D: Greater-than-or-equal (ordered, signaling) \n +/// 0x0E: Greater-than (ordered, signaling) \n +/// 0x0F: True (unordered, non-signaling) \n +/// 0x10: Equal (ordered, signaling) \n +/// 0x11: Less-than (ordered, non-signaling) \n +/// 0x12: Less-than-or-equal (ordered, non-signaling) \n +/// 0x13: Unordered (signaling) \n +/// 0x14: Not-equal (unordered, signaling) \n +/// 0x15: Not-less-than (unordered, non-signaling) \n +/// 0x16: Not-less-than-or-equal (unordered, non-signaling) \n +/// 0x17: Ordered (signaling) \n +/// 0x18: Equal (unordered, signaling) \n +/// 0x19: Not-greater-than-or-equal (unordered, non-signaling) \n +/// 0x1A: Not-greater-than (unordered, non-signaling) \n +/// 0x1B: False (ordered, signaling) \n +/// 0x1C: Not-equal (ordered, signaling) \n +/// 0x1D: Greater-than-or-equal (ordered, non-signaling) \n +/// 0x1E: Greater-than (ordered, non-signaling) \n +/// 0x1F: True (unordered, signaling) +/// \returns A 256-bit vector of [4 x double] containing the comparison results. +#define _mm256_cmp_pd(a, b, c) \ + ((__m256d)__builtin_ia32_cmppd256((__v4df)(__m256d)(a), \ + (__v4df)(__m256d)(b), (c))) + +/// Compares each of the corresponding values of two 256-bit vectors of +/// [8 x float], using the operation specified by the immediate integer +/// operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_cmp_ps(__m256 a, __m256 b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the VCMPPS instruction. +/// +/// \param a +/// A 256-bit vector of [8 x float]. +/// \param b +/// A 256-bit vector of [8 x float]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// 0x08: Equal (unordered, non-signaling) \n +/// 0x09: Not-greater-than-or-equal (unordered, signaling) \n +/// 0x0A: Not-greater-than (unordered, signaling) \n +/// 0x0B: False (ordered, non-signaling) \n +/// 0x0C: Not-equal (ordered, non-signaling) \n +/// 0x0D: Greater-than-or-equal (ordered, signaling) \n +/// 0x0E: Greater-than (ordered, signaling) \n +/// 0x0F: True (unordered, non-signaling) \n +/// 0x10: Equal (ordered, signaling) \n +/// 0x11: Less-than (ordered, non-signaling) \n +/// 0x12: Less-than-or-equal (ordered, non-signaling) \n +/// 0x13: Unordered (signaling) \n +/// 0x14: Not-equal (unordered, signaling) \n +/// 0x15: Not-less-than (unordered, non-signaling) \n +/// 0x16: Not-less-than-or-equal (unordered, non-signaling) \n +/// 0x17: Ordered (signaling) \n +/// 0x18: Equal (unordered, signaling) \n +/// 0x19: Not-greater-than-or-equal (unordered, non-signaling) \n +/// 0x1A: Not-greater-than (unordered, non-signaling) \n +/// 0x1B: False (ordered, signaling) \n +/// 0x1C: Not-equal (ordered, signaling) \n +/// 0x1D: Greater-than-or-equal (ordered, non-signaling) \n +/// 0x1E: Greater-than (ordered, non-signaling) \n +/// 0x1F: True (unordered, signaling) +/// \returns A 256-bit vector of [8 x float] containing the comparison results. +#define _mm256_cmp_ps(a, b, c) \ + ((__m256)__builtin_ia32_cmpps256((__v8sf)(__m256)(a), \ + (__v8sf)(__m256)(b), (c))) + +/* Below intrinsic defined in emmintrin.h can be used for AVX */ +/// Compares each of the corresponding scalar double-precision values of +/// two 128-bit vectors of [2 x double], using the operation specified by the +/// immediate integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_cmp_sd(__m128d a, __m128d b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the VCMPSD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double]. +/// \param b +/// A 128-bit vector of [2 x double]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// 0x08: Equal (unordered, non-signaling) \n +/// 0x09: Not-greater-than-or-equal (unordered, signaling) \n +/// 0x0A: Not-greater-than (unordered, signaling) \n +/// 0x0B: False (ordered, non-signaling) \n +/// 0x0C: Not-equal (ordered, non-signaling) \n +/// 0x0D: Greater-than-or-equal (ordered, signaling) \n +/// 0x0E: Greater-than (ordered, signaling) \n +/// 0x0F: True (unordered, non-signaling) \n +/// 0x10: Equal (ordered, signaling) \n +/// 0x11: Less-than (ordered, non-signaling) \n +/// 0x12: Less-than-or-equal (ordered, non-signaling) \n +/// 0x13: Unordered (signaling) \n +/// 0x14: Not-equal (unordered, signaling) \n +/// 0x15: Not-less-than (unordered, non-signaling) \n +/// 0x16: Not-less-than-or-equal (unordered, non-signaling) \n +/// 0x17: Ordered (signaling) \n +/// 0x18: Equal (unordered, signaling) \n +/// 0x19: Not-greater-than-or-equal (unordered, non-signaling) \n +/// 0x1A: Not-greater-than (unordered, non-signaling) \n +/// 0x1B: False (ordered, signaling) \n +/// 0x1C: Not-equal (ordered, signaling) \n +/// 0x1D: Greater-than-or-equal (ordered, non-signaling) \n +/// 0x1E: Greater-than (ordered, non-signaling) \n +/// 0x1F: True (unordered, signaling) +/// \returns A 128-bit vector of [2 x double] containing the comparison results. +/// \fn __m128d _mm_cmp_sd(__m128d a, __m128d b, const int c) + +/* Below intrinsic defined in xmmintrin.h can be used for AVX */ +/// Compares each of the corresponding scalar values of two 128-bit +/// vectors of [4 x float], using the operation specified by the immediate +/// integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_cmp_ss(__m128 a, __m128 b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the VCMPSS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float]. +/// \param b +/// A 128-bit vector of [4 x float]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// 0x08: Equal (unordered, non-signaling) \n +/// 0x09: Not-greater-than-or-equal (unordered, signaling) \n +/// 0x0A: Not-greater-than (unordered, signaling) \n +/// 0x0B: False (ordered, non-signaling) \n +/// 0x0C: Not-equal (ordered, non-signaling) \n +/// 0x0D: Greater-than-or-equal (ordered, signaling) \n +/// 0x0E: Greater-than (ordered, signaling) \n +/// 0x0F: True (unordered, non-signaling) \n +/// 0x10: Equal (ordered, signaling) \n +/// 0x11: Less-than (ordered, non-signaling) \n +/// 0x12: Less-than-or-equal (ordered, non-signaling) \n +/// 0x13: Unordered (signaling) \n +/// 0x14: Not-equal (unordered, signaling) \n +/// 0x15: Not-less-than (unordered, non-signaling) \n +/// 0x16: Not-less-than-or-equal (unordered, non-signaling) \n +/// 0x17: Ordered (signaling) \n +/// 0x18: Equal (unordered, signaling) \n +/// 0x19: Not-greater-than-or-equal (unordered, non-signaling) \n +/// 0x1A: Not-greater-than (unordered, non-signaling) \n +/// 0x1B: False (ordered, signaling) \n +/// 0x1C: Not-equal (ordered, signaling) \n +/// 0x1D: Greater-than-or-equal (ordered, non-signaling) \n +/// 0x1E: Greater-than (ordered, non-signaling) \n +/// 0x1F: True (unordered, signaling) +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +/// \fn __m128 _mm_cmp_ss(__m128 a, __m128 b, const int c) + +/// Takes a [8 x i32] vector and returns the vector element value +/// indexed by the immediate constant operand. +/// +/// \headerfile +/// +/// \code +/// int _mm256_extract_epi32(__m256i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A 256-bit vector of [8 x i32]. +/// \param N +/// An immediate integer operand with bits [2:0] determining which vector +/// element is extracted and returned. +/// \returns A 32-bit integer containing the extracted 32 bits of extended +/// packed data. +#define _mm256_extract_epi32(X, N) \ + ((int)__builtin_ia32_vec_ext_v8si((__v8si)(__m256i)(X), (int)(N))) + +/// Takes a [16 x i16] vector and returns the vector element value +/// indexed by the immediate constant operand. +/// +/// \headerfile +/// +/// \code +/// int _mm256_extract_epi16(__m256i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A 256-bit integer vector of [16 x i16]. +/// \param N +/// An immediate integer operand with bits [3:0] determining which vector +/// element is extracted and returned. +/// \returns A 32-bit integer containing the extracted 16 bits of zero extended +/// packed data. +#define _mm256_extract_epi16(X, N) \ + ((int)(unsigned short)__builtin_ia32_vec_ext_v16hi((__v16hi)(__m256i)(X), \ + (int)(N))) + +/// Takes a [32 x i8] vector and returns the vector element value +/// indexed by the immediate constant operand. +/// +/// \headerfile +/// +/// \code +/// int _mm256_extract_epi8(__m256i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A 256-bit integer vector of [32 x i8]. +/// \param N +/// An immediate integer operand with bits [4:0] determining which vector +/// element is extracted and returned. +/// \returns A 32-bit integer containing the extracted 8 bits of zero extended +/// packed data. +#define _mm256_extract_epi8(X, N) \ + ((int)(unsigned char)__builtin_ia32_vec_ext_v32qi((__v32qi)(__m256i)(X), \ + (int)(N))) + +#ifdef __x86_64__ +/// Takes a [4 x i64] vector and returns the vector element value +/// indexed by the immediate constant operand. +/// +/// \headerfile +/// +/// \code +/// long long _mm256_extract_epi64(__m256i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A 256-bit integer vector of [4 x i64]. +/// \param N +/// An immediate integer operand with bits [1:0] determining which vector +/// element is extracted and returned. +/// \returns A 64-bit integer containing the extracted 64 bits of extended +/// packed data. +#define _mm256_extract_epi64(X, N) \ + ((long long)__builtin_ia32_vec_ext_v4di((__v4di)(__m256i)(X), (int)(N))) +#endif + +/// Takes a [8 x i32] vector and replaces the vector element value +/// indexed by the immediate constant operand by a new value. Returns the +/// modified vector. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_insert_epi32(__m256i X, int I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A vector of [8 x i32] to be used by the insert operation. +/// \param I +/// An integer value. The replacement value for the insert operation. +/// \param N +/// An immediate integer specifying the index of the vector element to be +/// replaced. +/// \returns A copy of vector \a X, after replacing its element indexed by +/// \a N with \a I. +#define _mm256_insert_epi32(X, I, N) \ + ((__m256i)__builtin_ia32_vec_set_v8si((__v8si)(__m256i)(X), \ + (int)(I), (int)(N))) + + +/// Takes a [16 x i16] vector and replaces the vector element value +/// indexed by the immediate constant operand with a new value. Returns the +/// modified vector. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_insert_epi16(__m256i X, int I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A vector of [16 x i16] to be used by the insert operation. +/// \param I +/// An i16 integer value. The replacement value for the insert operation. +/// \param N +/// An immediate integer specifying the index of the vector element to be +/// replaced. +/// \returns A copy of vector \a X, after replacing its element indexed by +/// \a N with \a I. +#define _mm256_insert_epi16(X, I, N) \ + ((__m256i)__builtin_ia32_vec_set_v16hi((__v16hi)(__m256i)(X), \ + (int)(I), (int)(N))) + +/// Takes a [32 x i8] vector and replaces the vector element value +/// indexed by the immediate constant operand with a new value. Returns the +/// modified vector. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_insert_epi8(__m256i X, int I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A vector of [32 x i8] to be used by the insert operation. +/// \param I +/// An i8 integer value. The replacement value for the insert operation. +/// \param N +/// An immediate integer specifying the index of the vector element to be +/// replaced. +/// \returns A copy of vector \a X, after replacing its element indexed by +/// \a N with \a I. +#define _mm256_insert_epi8(X, I, N) \ + ((__m256i)__builtin_ia32_vec_set_v32qi((__v32qi)(__m256i)(X), \ + (int)(I), (int)(N))) + +#ifdef __x86_64__ +/// Takes a [4 x i64] vector and replaces the vector element value +/// indexed by the immediate constant operand with a new value. Returns the +/// modified vector. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_insert_epi64(__m256i X, int I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128+COMPOSITE +/// instruction. +/// +/// \param X +/// A vector of [4 x i64] to be used by the insert operation. +/// \param I +/// A 64-bit integer value. The replacement value for the insert operation. +/// \param N +/// An immediate integer specifying the index of the vector element to be +/// replaced. +/// \returns A copy of vector \a X, after replacing its element indexed by +/// \a N with \a I. +#define _mm256_insert_epi64(X, I, N) \ + ((__m256i)__builtin_ia32_vec_set_v4di((__v4di)(__m256i)(X), \ + (long long)(I), (int)(N))) +#endif + +/* Conversion */ +/// Converts a vector of [4 x i32] into a vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTDQ2PD instruction. +/// +/// \param __a +/// A 128-bit integer vector of [4 x i32]. +/// \returns A 256-bit vector of [4 x double] containing the converted values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_cvtepi32_pd(__m128i __a) +{ + return (__m256d)__builtin_convertvector((__v4si)__a, __v4df); +} + +/// Converts a vector of [8 x i32] into a vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTDQ2PS instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \returns A 256-bit vector of [8 x float] containing the converted values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_cvtepi32_ps(__m256i __a) +{ + return (__m256)__builtin_convertvector((__v8si)__a, __v8sf); +} + +/// Converts a 256-bit vector of [4 x double] into a 128-bit vector of +/// [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPD2PS instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \returns A 128-bit vector of [4 x float] containing the converted values. +static __inline __m128 __DEFAULT_FN_ATTRS +_mm256_cvtpd_ps(__m256d __a) +{ + return (__m128)__builtin_ia32_cvtpd2ps256((__v4df) __a); +} + +/// Converts a vector of [8 x float] into a vector of [8 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPS2DQ instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit integer vector containing the converted values. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_cvtps_epi32(__m256 __a) +{ + return (__m256i)__builtin_ia32_cvtps2dq256((__v8sf) __a); +} + +/// Converts a 128-bit vector of [4 x float] into a 256-bit vector of [4 +/// x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPS2PD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 256-bit vector of [4 x double] containing the converted values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_cvtps_pd(__m128 __a) +{ + return (__m256d)__builtin_convertvector((__v4sf)__a, __v4df); +} + +/// Converts a 256-bit vector of [4 x double] into four signed truncated +/// (rounded toward zero) 32-bit integers returned in a 128-bit vector of +/// [4 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTPD2DQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \returns A 128-bit integer vector containing the converted values. +static __inline __m128i __DEFAULT_FN_ATTRS +_mm256_cvttpd_epi32(__m256d __a) +{ + return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a); +} + +/// Converts a 256-bit vector of [4 x double] into a 128-bit vector of +/// [4 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPD2DQ instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \returns A 128-bit integer vector containing the converted values. +static __inline __m128i __DEFAULT_FN_ATTRS +_mm256_cvtpd_epi32(__m256d __a) +{ + return (__m128i)__builtin_ia32_cvtpd2dq256((__v4df) __a); +} + +/// Converts a vector of [8 x float] into eight signed truncated (rounded +/// toward zero) 32-bit integers returned in a vector of [8 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTPS2DQ instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 256-bit integer vector containing the converted values. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_cvttps_epi32(__m256 __a) +{ + return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a); +} + +/// Returns the first element of the input vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \returns A 64 bit double containing the first element of the input vector. +static __inline double __DEFAULT_FN_ATTRS +_mm256_cvtsd_f64(__m256d __a) +{ + return __a[0]; +} + +/// Returns the first element of the input vector of [8 x i32]. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x i32]. +/// \returns A 32 bit integer containing the first element of the input vector. +static __inline int __DEFAULT_FN_ATTRS +_mm256_cvtsi256_si32(__m256i __a) +{ + __v8si __b = (__v8si)__a; + return __b[0]; +} + +/// Returns the first element of the input vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \returns A 32 bit float containing the first element of the input vector. +static __inline float __DEFAULT_FN_ATTRS +_mm256_cvtss_f32(__m256 __a) +{ + return __a[0]; +} + +/* Vector replicate */ +/// Moves and duplicates odd-indexed values from a 256-bit vector of +/// [8 x float] to float values in a 256-bit vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSHDUP instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. \n +/// Bits [255:224] of \a __a are written to bits [255:224] and [223:192] of +/// the return value. \n +/// Bits [191:160] of \a __a are written to bits [191:160] and [159:128] of +/// the return value. \n +/// Bits [127:96] of \a __a are written to bits [127:96] and [95:64] of the +/// return value. \n +/// Bits [63:32] of \a __a are written to bits [63:32] and [31:0] of the +/// return value. +/// \returns A 256-bit vector of [8 x float] containing the moved and duplicated +/// values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_movehdup_ps(__m256 __a) +{ + return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 1, 1, 3, 3, 5, 5, 7, 7); +} + +/// Moves and duplicates even-indexed values from a 256-bit vector of +/// [8 x float] to float values in a 256-bit vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSLDUP instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. \n +/// Bits [223:192] of \a __a are written to bits [255:224] and [223:192] of +/// the return value. \n +/// Bits [159:128] of \a __a are written to bits [191:160] and [159:128] of +/// the return value. \n +/// Bits [95:64] of \a __a are written to bits [127:96] and [95:64] of the +/// return value. \n +/// Bits [31:0] of \a __a are written to bits [63:32] and [31:0] of the +/// return value. +/// \returns A 256-bit vector of [8 x float] containing the moved and duplicated +/// values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_moveldup_ps(__m256 __a) +{ + return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 0, 0, 2, 2, 4, 4, 6, 6); +} + +/// Moves and duplicates double-precision floating point values from a +/// 256-bit vector of [4 x double] to double-precision values in a 256-bit +/// vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. \n +/// Bits [63:0] of \a __a are written to bits [127:64] and [63:0] of the +/// return value. \n +/// Bits [191:128] of \a __a are written to bits [255:192] and [191:128] of +/// the return value. +/// \returns A 256-bit vector of [4 x double] containing the moved and +/// duplicated values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_movedup_pd(__m256d __a) +{ + return __builtin_shufflevector((__v4df)__a, (__v4df)__a, 0, 0, 2, 2); +} + +/* Unpack and Interleave */ +/// Unpacks the odd-indexed vector elements from two 256-bit vectors of +/// [4 x double] and interleaves them into a 256-bit vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKHPD instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [4 x double]. \n +/// Bits [127:64] are written to bits [63:0] of the return value. \n +/// Bits [255:192] are written to bits [191:128] of the return value. \n +/// \param __b +/// A 256-bit floating-point vector of [4 x double]. \n +/// Bits [127:64] are written to bits [127:64] of the return value. \n +/// Bits [255:192] are written to bits [255:192] of the return value. \n +/// \returns A 256-bit vector of [4 x double] containing the interleaved values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_unpackhi_pd(__m256d __a, __m256d __b) +{ + return __builtin_shufflevector((__v4df)__a, (__v4df)__b, 1, 5, 1+2, 5+2); +} + +/// Unpacks the even-indexed vector elements from two 256-bit vectors of +/// [4 x double] and interleaves them into a 256-bit vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [4 x double]. \n +/// Bits [63:0] are written to bits [63:0] of the return value. \n +/// Bits [191:128] are written to bits [191:128] of the return value. +/// \param __b +/// A 256-bit floating-point vector of [4 x double]. \n +/// Bits [63:0] are written to bits [127:64] of the return value. \n +/// Bits [191:128] are written to bits [255:192] of the return value. \n +/// \returns A 256-bit vector of [4 x double] containing the interleaved values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_unpacklo_pd(__m256d __a, __m256d __b) +{ + return __builtin_shufflevector((__v4df)__a, (__v4df)__b, 0, 4, 0+2, 4+2); +} + +/// Unpacks the 32-bit vector elements 2, 3, 6 and 7 from each of the +/// two 256-bit vectors of [8 x float] and interleaves them into a 256-bit +/// vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKHPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. \n +/// Bits [95:64] are written to bits [31:0] of the return value. \n +/// Bits [127:96] are written to bits [95:64] of the return value. \n +/// Bits [223:192] are written to bits [159:128] of the return value. \n +/// Bits [255:224] are written to bits [223:192] of the return value. +/// \param __b +/// A 256-bit vector of [8 x float]. \n +/// Bits [95:64] are written to bits [63:32] of the return value. \n +/// Bits [127:96] are written to bits [127:96] of the return value. \n +/// Bits [223:192] are written to bits [191:160] of the return value. \n +/// Bits [255:224] are written to bits [255:224] of the return value. +/// \returns A 256-bit vector of [8 x float] containing the interleaved values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_unpackhi_ps(__m256 __a, __m256 __b) +{ + return __builtin_shufflevector((__v8sf)__a, (__v8sf)__b, 2, 10, 2+1, 10+1, 6, 14, 6+1, 14+1); +} + +/// Unpacks the 32-bit vector elements 0, 1, 4 and 5 from each of the +/// two 256-bit vectors of [8 x float] and interleaves them into a 256-bit +/// vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. \n +/// Bits [31:0] are written to bits [31:0] of the return value. \n +/// Bits [63:32] are written to bits [95:64] of the return value. \n +/// Bits [159:128] are written to bits [159:128] of the return value. \n +/// Bits [191:160] are written to bits [223:192] of the return value. +/// \param __b +/// A 256-bit vector of [8 x float]. \n +/// Bits [31:0] are written to bits [63:32] of the return value. \n +/// Bits [63:32] are written to bits [127:96] of the return value. \n +/// Bits [159:128] are written to bits [191:160] of the return value. \n +/// Bits [191:160] are written to bits [255:224] of the return value. +/// \returns A 256-bit vector of [8 x float] containing the interleaved values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_unpacklo_ps(__m256 __a, __m256 __b) +{ + return __builtin_shufflevector((__v8sf)__a, (__v8sf)__b, 0, 8, 0+1, 8+1, 4, 12, 4+1, 12+1); +} + +/* Bit Test */ +/// Given two 128-bit floating-point vectors of [2 x double], perform an +/// element-by-element comparison of the double-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of double-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of double-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the ZF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns the ZF flag in the EFLAGS register. +static __inline int __DEFAULT_FN_ATTRS128 +_mm_testz_pd(__m128d __a, __m128d __b) +{ + return __builtin_ia32_vtestzpd((__v2df)__a, (__v2df)__b); +} + +/// Given two 128-bit floating-point vectors of [2 x double], perform an +/// element-by-element comparison of the double-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of double-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of double-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the CF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns the CF flag in the EFLAGS register. +static __inline int __DEFAULT_FN_ATTRS128 +_mm_testc_pd(__m128d __a, __m128d __b) +{ + return __builtin_ia32_vtestcpd((__v2df)__a, (__v2df)__b); +} + +/// Given two 128-bit floating-point vectors of [2 x double], perform an +/// element-by-element comparison of the double-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of double-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of double-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns 1 if both the ZF and CF flags are set to 0, +/// otherwise it returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0. +static __inline int __DEFAULT_FN_ATTRS128 +_mm_testnzc_pd(__m128d __a, __m128d __b) +{ + return __builtin_ia32_vtestnzcpd((__v2df)__a, (__v2df)__b); +} + +/// Given two 128-bit floating-point vectors of [4 x float], perform an +/// element-by-element comparison of the single-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of single-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of single-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the ZF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns the ZF flag. +static __inline int __DEFAULT_FN_ATTRS128 +_mm_testz_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_vtestzps((__v4sf)__a, (__v4sf)__b); +} + +/// Given two 128-bit floating-point vectors of [4 x float], perform an +/// element-by-element comparison of the single-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of single-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of single-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the CF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns the CF flag. +static __inline int __DEFAULT_FN_ATTRS128 +_mm_testc_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_vtestcps((__v4sf)__a, (__v4sf)__b); +} + +/// Given two 128-bit floating-point vectors of [4 x float], perform an +/// element-by-element comparison of the single-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of single-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of single-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns 1 if both the ZF and CF flags are set to 0, +/// otherwise it returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0. +static __inline int __DEFAULT_FN_ATTRS128 +_mm_testnzc_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_vtestnzcps((__v4sf)__a, (__v4sf)__b); +} + +/// Given two 256-bit floating-point vectors of [4 x double], perform an +/// element-by-element comparison of the double-precision elements in the +/// first source vector and the corresponding elements in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of double-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of double-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the ZF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \param __b +/// A 256-bit vector of [4 x double]. +/// \returns the ZF flag. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testz_pd(__m256d __a, __m256d __b) +{ + return __builtin_ia32_vtestzpd256((__v4df)__a, (__v4df)__b); +} + +/// Given two 256-bit floating-point vectors of [4 x double], perform an +/// element-by-element comparison of the double-precision elements in the +/// first source vector and the corresponding elements in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of double-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of double-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the CF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \param __b +/// A 256-bit vector of [4 x double]. +/// \returns the CF flag. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testc_pd(__m256d __a, __m256d __b) +{ + return __builtin_ia32_vtestcpd256((__v4df)__a, (__v4df)__b); +} + +/// Given two 256-bit floating-point vectors of [4 x double], perform an +/// element-by-element comparison of the double-precision elements in the +/// first source vector and the corresponding elements in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of double-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of double-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns 1 if both the ZF and CF flags are set to 0, +/// otherwise it returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double]. +/// \param __b +/// A 256-bit vector of [4 x double]. +/// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testnzc_pd(__m256d __a, __m256d __b) +{ + return __builtin_ia32_vtestnzcpd256((__v4df)__a, (__v4df)__b); +} + +/// Given two 256-bit floating-point vectors of [8 x float], perform an +/// element-by-element comparison of the single-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of single-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of single-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the ZF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \param __b +/// A 256-bit vector of [8 x float]. +/// \returns the ZF flag. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testz_ps(__m256 __a, __m256 __b) +{ + return __builtin_ia32_vtestzps256((__v8sf)__a, (__v8sf)__b); +} + +/// Given two 256-bit floating-point vectors of [8 x float], perform an +/// element-by-element comparison of the single-precision element in the +/// first source vector and the corresponding element in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of single-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of single-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the CF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \param __b +/// A 256-bit vector of [8 x float]. +/// \returns the CF flag. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testc_ps(__m256 __a, __m256 __b) +{ + return __builtin_ia32_vtestcps256((__v8sf)__a, (__v8sf)__b); +} + +/// Given two 256-bit floating-point vectors of [8 x float], perform an +/// element-by-element comparison of the single-precision elements in the +/// first source vector and the corresponding elements in the second source +/// vector. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of single-precision elements where the +/// sign-bits of both elements are 1, the ZF flag is set to 0. Otherwise the +/// ZF flag is set to 1. \n +/// If there is at least one pair of single-precision elements where the +/// sign-bit of the first element is 0 and the sign-bit of the second element +/// is 1, the CF flag is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns 1 if both the ZF and CF flags are set to 0, +/// otherwise it returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VTESTPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float]. +/// \param __b +/// A 256-bit vector of [8 x float]. +/// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testnzc_ps(__m256 __a, __m256 __b) +{ + return __builtin_ia32_vtestnzcps256((__v8sf)__a, (__v8sf)__b); +} + +/// Given two 256-bit integer vectors, perform a bit-by-bit comparison +/// of the two source vectors. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of bits where both bits are 1, the ZF flag +/// is set to 0. Otherwise the ZF flag is set to 1. \n +/// If there is at least one pair of bits where the bit from the first source +/// vector is 0 and the bit from the second source vector is 1, the CF flag +/// is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the ZF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPTEST instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns the ZF flag. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testz_si256(__m256i __a, __m256i __b) +{ + return __builtin_ia32_ptestz256((__v4di)__a, (__v4di)__b); +} + +/// Given two 256-bit integer vectors, perform a bit-by-bit comparison +/// of the two source vectors. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of bits where both bits are 1, the ZF flag +/// is set to 0. Otherwise the ZF flag is set to 1. \n +/// If there is at least one pair of bits where the bit from the first source +/// vector is 0 and the bit from the second source vector is 1, the CF flag +/// is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns the value of the CF flag. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPTEST instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns the CF flag. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testc_si256(__m256i __a, __m256i __b) +{ + return __builtin_ia32_ptestc256((__v4di)__a, (__v4di)__b); +} + +/// Given two 256-bit integer vectors, perform a bit-by-bit comparison +/// of the two source vectors. +/// +/// The EFLAGS register is updated as follows: \n +/// If there is at least one pair of bits where both bits are 1, the ZF flag +/// is set to 0. Otherwise the ZF flag is set to 1. \n +/// If there is at least one pair of bits where the bit from the first source +/// vector is 0 and the bit from the second source vector is 1, the CF flag +/// is set to 0. Otherwise the CF flag is set to 1. \n +/// This intrinsic returns 1 if both the ZF and CF flags are set to 0, +/// otherwise it returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPTEST instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \param __b +/// A 256-bit integer vector. +/// \returns 1 if both the ZF and CF flags are set to 0, otherwise returns 0. +static __inline int __DEFAULT_FN_ATTRS +_mm256_testnzc_si256(__m256i __a, __m256i __b) +{ + return __builtin_ia32_ptestnzc256((__v4di)__a, (__v4di)__b); +} + +/* Vector extract sign mask */ +/// Extracts the sign bits of double-precision floating point elements +/// in a 256-bit vector of [4 x double] and writes them to the lower order +/// bits of the return value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVMSKPD instruction. +/// +/// \param __a +/// A 256-bit vector of [4 x double] containing the double-precision +/// floating point values with sign bits to be extracted. +/// \returns The sign bits from the operand, written to bits [3:0]. +static __inline int __DEFAULT_FN_ATTRS +_mm256_movemask_pd(__m256d __a) +{ + return __builtin_ia32_movmskpd256((__v4df)__a); +} + +/// Extracts the sign bits of single-precision floating point elements +/// in a 256-bit vector of [8 x float] and writes them to the lower order +/// bits of the return value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVMSKPS instruction. +/// +/// \param __a +/// A 256-bit vector of [8 x float] containing the single-precision floating +/// point values with sign bits to be extracted. +/// \returns The sign bits from the operand, written to bits [7:0]. +static __inline int __DEFAULT_FN_ATTRS +_mm256_movemask_ps(__m256 __a) +{ + return __builtin_ia32_movmskps256((__v8sf)__a); +} + +/* Vector __zero */ +/// Zeroes the contents of all XMM or YMM registers. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VZEROALL instruction. +static __inline void __attribute__((__always_inline__, __nodebug__, __target__("avx"))) +_mm256_zeroall(void) +{ + __builtin_ia32_vzeroall(); +} + +/// Zeroes the upper 128 bits (bits 255:128) of all YMM registers. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VZEROUPPER instruction. +static __inline void __attribute__((__always_inline__, __nodebug__, __target__("avx"))) +_mm256_zeroupper(void) +{ + __builtin_ia32_vzeroupper(); +} + +/* Vector load with broadcast */ +/// Loads a scalar single-precision floating point value from the +/// specified address pointed to by \a __a and broadcasts it to the elements +/// of a [4 x float] vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBROADCASTSS instruction. +/// +/// \param __a +/// The single-precision floating point value to be broadcast. +/// \returns A 128-bit vector of [4 x float] whose 32-bit elements are set +/// equal to the broadcast value. +static __inline __m128 __DEFAULT_FN_ATTRS128 +_mm_broadcast_ss(float const *__a) +{ + struct __mm_broadcast_ss_struct { + float __f; + } __attribute__((__packed__, __may_alias__)); + float __f = ((const struct __mm_broadcast_ss_struct*)__a)->__f; + return __extension__ (__m128){ __f, __f, __f, __f }; +} + +/// Loads a scalar double-precision floating point value from the +/// specified address pointed to by \a __a and broadcasts it to the elements +/// of a [4 x double] vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBROADCASTSD instruction. +/// +/// \param __a +/// The double-precision floating point value to be broadcast. +/// \returns A 256-bit vector of [4 x double] whose 64-bit elements are set +/// equal to the broadcast value. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_broadcast_sd(double const *__a) +{ + struct __mm256_broadcast_sd_struct { + double __d; + } __attribute__((__packed__, __may_alias__)); + double __d = ((const struct __mm256_broadcast_sd_struct*)__a)->__d; + return __extension__ (__m256d)(__v4df){ __d, __d, __d, __d }; +} + +/// Loads a scalar single-precision floating point value from the +/// specified address pointed to by \a __a and broadcasts it to the elements +/// of a [8 x float] vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBROADCASTSS instruction. +/// +/// \param __a +/// The single-precision floating point value to be broadcast. +/// \returns A 256-bit vector of [8 x float] whose 32-bit elements are set +/// equal to the broadcast value. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_broadcast_ss(float const *__a) +{ + struct __mm256_broadcast_ss_struct { + float __f; + } __attribute__((__packed__, __may_alias__)); + float __f = ((const struct __mm256_broadcast_ss_struct*)__a)->__f; + return __extension__ (__m256)(__v8sf){ __f, __f, __f, __f, __f, __f, __f, __f }; +} + +/// Loads the data from a 128-bit vector of [2 x double] from the +/// specified address pointed to by \a __a and broadcasts it to 128-bit +/// elements in a 256-bit vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBROADCASTF128 instruction. +/// +/// \param __a +/// The 128-bit vector of [2 x double] to be broadcast. +/// \returns A 256-bit vector of [4 x double] whose 128-bit elements are set +/// equal to the broadcast value. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_broadcast_pd(__m128d const *__a) +{ + __m128d __b = _mm_loadu_pd((const double *)__a); + return (__m256d)__builtin_shufflevector((__v2df)__b, (__v2df)__b, + 0, 1, 0, 1); +} + +/// Loads the data from a 128-bit vector of [4 x float] from the +/// specified address pointed to by \a __a and broadcasts it to 128-bit +/// elements in a 256-bit vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBROADCASTF128 instruction. +/// +/// \param __a +/// The 128-bit vector of [4 x float] to be broadcast. +/// \returns A 256-bit vector of [8 x float] whose 128-bit elements are set +/// equal to the broadcast value. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_broadcast_ps(__m128 const *__a) +{ + __m128 __b = _mm_loadu_ps((const float *)__a); + return (__m256)__builtin_shufflevector((__v4sf)__b, (__v4sf)__b, + 0, 1, 2, 3, 0, 1, 2, 3); +} + +/* SIMD load ops */ +/// Loads 4 double-precision floating point values from a 32-byte aligned +/// memory location pointed to by \a __p into a vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPD instruction. +/// +/// \param __p +/// A 32-byte aligned pointer to a memory location containing +/// double-precision floating point values. +/// \returns A 256-bit vector of [4 x double] containing the moved values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_load_pd(double const *__p) +{ + return *(const __m256d *)__p; +} + +/// Loads 8 single-precision floating point values from a 32-byte aligned +/// memory location pointed to by \a __p into a vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS instruction. +/// +/// \param __p +/// A 32-byte aligned pointer to a memory location containing float values. +/// \returns A 256-bit vector of [8 x float] containing the moved values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_load_ps(float const *__p) +{ + return *(const __m256 *)__p; +} + +/// Loads 4 double-precision floating point values from an unaligned +/// memory location pointed to by \a __p into a vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPD instruction. +/// +/// \param __p +/// A pointer to a memory location containing double-precision floating +/// point values. +/// \returns A 256-bit vector of [4 x double] containing the moved values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_loadu_pd(double const *__p) +{ + struct __loadu_pd { + __m256d_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_pd*)__p)->__v; +} + +/// Loads 8 single-precision floating point values from an unaligned +/// memory location pointed to by \a __p into a vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPS instruction. +/// +/// \param __p +/// A pointer to a memory location containing single-precision floating +/// point values. +/// \returns A 256-bit vector of [8 x float] containing the moved values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_loadu_ps(float const *__p) +{ + struct __loadu_ps { + __m256_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_ps*)__p)->__v; +} + +/// Loads 256 bits of integer data from a 32-byte aligned memory +/// location pointed to by \a __p into elements of a 256-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDQA instruction. +/// +/// \param __p +/// A 32-byte aligned pointer to a 256-bit integer vector containing integer +/// values. +/// \returns A 256-bit integer vector containing the moved values. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_load_si256(__m256i const *__p) +{ + return *__p; +} + +/// Loads 256 bits of integer data from an unaligned memory location +/// pointed to by \a __p into a 256-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDQU instruction. +/// +/// \param __p +/// A pointer to a 256-bit integer vector containing integer values. +/// \returns A 256-bit integer vector containing the moved values. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_loadu_si256(__m256i_u const *__p) +{ + struct __loadu_si256 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_si256*)__p)->__v; +} + +/// Loads 256 bits of integer data from an unaligned memory location +/// pointed to by \a __p into a 256-bit integer vector. This intrinsic may +/// perform better than \c _mm256_loadu_si256 when the data crosses a cache +/// line boundary. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VLDDQU instruction. +/// +/// \param __p +/// A pointer to a 256-bit integer vector containing integer values. +/// \returns A 256-bit integer vector containing the moved values. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_lddqu_si256(__m256i_u const *__p) +{ + return (__m256i)__builtin_ia32_lddqu256((char const *)__p); +} + +/* SIMD store ops */ +/// Stores double-precision floating point values from a 256-bit vector +/// of [4 x double] to a 32-byte aligned memory location pointed to by +/// \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPD instruction. +/// +/// \param __p +/// A 32-byte aligned pointer to a memory location that will receive the +/// double-precision floaing point values. +/// \param __a +/// A 256-bit vector of [4 x double] containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_store_pd(double *__p, __m256d __a) +{ + *(__m256d *)__p = __a; +} + +/// Stores single-precision floating point values from a 256-bit vector +/// of [8 x float] to a 32-byte aligned memory location pointed to by \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS instruction. +/// +/// \param __p +/// A 32-byte aligned pointer to a memory location that will receive the +/// float values. +/// \param __a +/// A 256-bit vector of [8 x float] containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_store_ps(float *__p, __m256 __a) +{ + *(__m256 *)__p = __a; +} + +/// Stores double-precision floating point values from a 256-bit vector +/// of [4 x double] to an unaligned memory location pointed to by \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPD instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the double-precision +/// floating point values. +/// \param __a +/// A 256-bit vector of [4 x double] containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_storeu_pd(double *__p, __m256d __a) +{ + struct __storeu_pd { + __m256d_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_pd*)__p)->__v = __a; +} + +/// Stores single-precision floating point values from a 256-bit vector +/// of [8 x float] to an unaligned memory location pointed to by \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPS instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the float values. +/// \param __a +/// A 256-bit vector of [8 x float] containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_storeu_ps(float *__p, __m256 __a) +{ + struct __storeu_ps { + __m256_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_ps*)__p)->__v = __a; +} + +/// Stores integer values from a 256-bit integer vector to a 32-byte +/// aligned memory location pointed to by \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDQA instruction. +/// +/// \param __p +/// A 32-byte aligned pointer to a memory location that will receive the +/// integer values. +/// \param __a +/// A 256-bit integer vector containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_store_si256(__m256i *__p, __m256i __a) +{ + *__p = __a; +} + +/// Stores integer values from a 256-bit integer vector to an unaligned +/// memory location pointed to by \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDQU instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the integer values. +/// \param __a +/// A 256-bit integer vector containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_storeu_si256(__m256i_u *__p, __m256i __a) +{ + struct __storeu_si256 { + __m256i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_si256*)__p)->__v = __a; +} + +/* Conditional load ops */ +/// Conditionally loads double-precision floating point elements from a +/// memory location pointed to by \a __p into a 128-bit vector of +/// [2 x double], depending on the mask bits associated with each data +/// element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPD instruction. +/// +/// \param __p +/// A pointer to a memory location that contains the double-precision +/// floating point values. +/// \param __m +/// A 128-bit integer vector containing the mask. The most significant bit of +/// each data element represents the mask bits. If a mask bit is zero, the +/// corresponding value in the memory location is not loaded and the +/// corresponding field in the return value is set to zero. +/// \returns A 128-bit vector of [2 x double] containing the loaded values. +static __inline __m128d __DEFAULT_FN_ATTRS128 +_mm_maskload_pd(double const *__p, __m128i __m) +{ + return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2di)__m); +} + +/// Conditionally loads double-precision floating point elements from a +/// memory location pointed to by \a __p into a 256-bit vector of +/// [4 x double], depending on the mask bits associated with each data +/// element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPD instruction. +/// +/// \param __p +/// A pointer to a memory location that contains the double-precision +/// floating point values. +/// \param __m +/// A 256-bit integer vector of [4 x quadword] containing the mask. The most +/// significant bit of each quadword element represents the mask bits. If a +/// mask bit is zero, the corresponding value in the memory location is not +/// loaded and the corresponding field in the return value is set to zero. +/// \returns A 256-bit vector of [4 x double] containing the loaded values. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_maskload_pd(double const *__p, __m256i __m) +{ + return (__m256d)__builtin_ia32_maskloadpd256((const __v4df *)__p, + (__v4di)__m); +} + +/// Conditionally loads single-precision floating point elements from a +/// memory location pointed to by \a __p into a 128-bit vector of +/// [4 x float], depending on the mask bits associated with each data +/// element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPS instruction. +/// +/// \param __p +/// A pointer to a memory location that contains the single-precision +/// floating point values. +/// \param __m +/// A 128-bit integer vector containing the mask. The most significant bit of +/// each data element represents the mask bits. If a mask bit is zero, the +/// corresponding value in the memory location is not loaded and the +/// corresponding field in the return value is set to zero. +/// \returns A 128-bit vector of [4 x float] containing the loaded values. +static __inline __m128 __DEFAULT_FN_ATTRS128 +_mm_maskload_ps(float const *__p, __m128i __m) +{ + return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4si)__m); +} + +/// Conditionally loads single-precision floating point elements from a +/// memory location pointed to by \a __p into a 256-bit vector of +/// [8 x float], depending on the mask bits associated with each data +/// element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPS instruction. +/// +/// \param __p +/// A pointer to a memory location that contains the single-precision +/// floating point values. +/// \param __m +/// A 256-bit integer vector of [8 x dword] containing the mask. The most +/// significant bit of each dword element represents the mask bits. If a mask +/// bit is zero, the corresponding value in the memory location is not loaded +/// and the corresponding field in the return value is set to zero. +/// \returns A 256-bit vector of [8 x float] containing the loaded values. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_maskload_ps(float const *__p, __m256i __m) +{ + return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8si)__m); +} + +/* Conditional store ops */ +/// Moves single-precision floating point values from a 256-bit vector +/// of [8 x float] to a memory location pointed to by \a __p, according to +/// the specified mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPS instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the float values. +/// \param __m +/// A 256-bit integer vector of [8 x dword] containing the mask. The most +/// significant bit of each dword element in the mask vector represents the +/// mask bits. If a mask bit is zero, the corresponding value from vector +/// \a __a is not stored and the corresponding field in the memory location +/// pointed to by \a __p is not changed. +/// \param __a +/// A 256-bit vector of [8 x float] containing the values to be stored. +static __inline void __DEFAULT_FN_ATTRS +_mm256_maskstore_ps(float *__p, __m256i __m, __m256 __a) +{ + __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8si)__m, (__v8sf)__a); +} + +/// Moves double-precision values from a 128-bit vector of [2 x double] +/// to a memory location pointed to by \a __p, according to the specified +/// mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPD instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the float values. +/// \param __m +/// A 128-bit integer vector containing the mask. The most significant bit of +/// each field in the mask vector represents the mask bits. If a mask bit is +/// zero, the corresponding value from vector \a __a is not stored and the +/// corresponding field in the memory location pointed to by \a __p is not +/// changed. +/// \param __a +/// A 128-bit vector of [2 x double] containing the values to be stored. +static __inline void __DEFAULT_FN_ATTRS128 +_mm_maskstore_pd(double *__p, __m128i __m, __m128d __a) +{ + __builtin_ia32_maskstorepd((__v2df *)__p, (__v2di)__m, (__v2df)__a); +} + +/// Moves double-precision values from a 256-bit vector of [4 x double] +/// to a memory location pointed to by \a __p, according to the specified +/// mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPD instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the float values. +/// \param __m +/// A 256-bit integer vector of [4 x quadword] containing the mask. The most +/// significant bit of each quadword element in the mask vector represents +/// the mask bits. If a mask bit is zero, the corresponding value from vector +/// __a is not stored and the corresponding field in the memory location +/// pointed to by \a __p is not changed. +/// \param __a +/// A 256-bit vector of [4 x double] containing the values to be stored. +static __inline void __DEFAULT_FN_ATTRS +_mm256_maskstore_pd(double *__p, __m256i __m, __m256d __a) +{ + __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4di)__m, (__v4df)__a); +} + +/// Moves single-precision floating point values from a 128-bit vector +/// of [4 x float] to a memory location pointed to by \a __p, according to +/// the specified mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVPS instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the float values. +/// \param __m +/// A 128-bit integer vector containing the mask. The most significant bit of +/// each field in the mask vector represents the mask bits. If a mask bit is +/// zero, the corresponding value from vector __a is not stored and the +/// corresponding field in the memory location pointed to by \a __p is not +/// changed. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be stored. +static __inline void __DEFAULT_FN_ATTRS128 +_mm_maskstore_ps(float *__p, __m128i __m, __m128 __a) +{ + __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4si)__m, (__v4sf)__a); +} + +/* Cacheability support ops */ +/// Moves integer data from a 256-bit integer vector to a 32-byte +/// aligned memory location. To minimize caching, the data is flagged as +/// non-temporal (unlikely to be used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTDQ instruction. +/// +/// \param __a +/// A pointer to a 32-byte aligned memory location that will receive the +/// integer values. +/// \param __b +/// A 256-bit integer vector containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_stream_si256(void *__a, __m256i __b) +{ + typedef __v4di __v4di_aligned __attribute__((aligned(32))); + __builtin_nontemporal_store((__v4di_aligned)__b, (__v4di_aligned*)__a); +} + +/// Moves double-precision values from a 256-bit vector of [4 x double] +/// to a 32-byte aligned memory location. To minimize caching, the data is +/// flagged as non-temporal (unlikely to be used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTPD instruction. +/// +/// \param __a +/// A pointer to a 32-byte aligned memory location that will receive the +/// double-precision floating-point values. +/// \param __b +/// A 256-bit vector of [4 x double] containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_stream_pd(void *__a, __m256d __b) +{ + typedef __v4df __v4df_aligned __attribute__((aligned(32))); + __builtin_nontemporal_store((__v4df_aligned)__b, (__v4df_aligned*)__a); +} + +/// Moves single-precision floating point values from a 256-bit vector +/// of [8 x float] to a 32-byte aligned memory location. To minimize +/// caching, the data is flagged as non-temporal (unlikely to be used again +/// soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTPS instruction. +/// +/// \param __p +/// A pointer to a 32-byte aligned memory location that will receive the +/// single-precision floating point values. +/// \param __a +/// A 256-bit vector of [8 x float] containing the values to be moved. +static __inline void __DEFAULT_FN_ATTRS +_mm256_stream_ps(void *__p, __m256 __a) +{ + typedef __v8sf __v8sf_aligned __attribute__((aligned(32))); + __builtin_nontemporal_store((__v8sf_aligned)__a, (__v8sf_aligned*)__p); +} + +/* Create vectors */ +/// Create a 256-bit vector of [4 x double] with undefined values. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \returns A 256-bit vector of [4 x double] containing undefined values. +static __inline__ __m256d __DEFAULT_FN_ATTRS +_mm256_undefined_pd(void) +{ + return (__m256d)__builtin_ia32_undef256(); +} + +/// Create a 256-bit vector of [8 x float] with undefined values. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \returns A 256-bit vector of [8 x float] containing undefined values. +static __inline__ __m256 __DEFAULT_FN_ATTRS +_mm256_undefined_ps(void) +{ + return (__m256)__builtin_ia32_undef256(); +} + +/// Create a 256-bit integer vector with undefined values. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \returns A 256-bit integer vector containing undefined values. +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm256_undefined_si256(void) +{ + return (__m256i)__builtin_ia32_undef256(); +} + +/// Constructs a 256-bit floating-point vector of [4 x double] +/// initialized with the specified double-precision floating-point values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD+VINSERTF128 +/// instruction. +/// +/// \param __a +/// A double-precision floating-point value used to initialize bits [255:192] +/// of the result. +/// \param __b +/// A double-precision floating-point value used to initialize bits [191:128] +/// of the result. +/// \param __c +/// A double-precision floating-point value used to initialize bits [127:64] +/// of the result. +/// \param __d +/// A double-precision floating-point value used to initialize bits [63:0] +/// of the result. +/// \returns An initialized 256-bit floating-point vector of [4 x double]. +static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_set_pd(double __a, double __b, double __c, double __d) +{ + return __extension__ (__m256d){ __d, __c, __b, __a }; +} + +/// Constructs a 256-bit floating-point vector of [8 x float] initialized +/// with the specified single-precision floating-point values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __a +/// A single-precision floating-point value used to initialize bits [255:224] +/// of the result. +/// \param __b +/// A single-precision floating-point value used to initialize bits [223:192] +/// of the result. +/// \param __c +/// A single-precision floating-point value used to initialize bits [191:160] +/// of the result. +/// \param __d +/// A single-precision floating-point value used to initialize bits [159:128] +/// of the result. +/// \param __e +/// A single-precision floating-point value used to initialize bits [127:96] +/// of the result. +/// \param __f +/// A single-precision floating-point value used to initialize bits [95:64] +/// of the result. +/// \param __g +/// A single-precision floating-point value used to initialize bits [63:32] +/// of the result. +/// \param __h +/// A single-precision floating-point value used to initialize bits [31:0] +/// of the result. +/// \returns An initialized 256-bit floating-point vector of [8 x float]. +static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_set_ps(float __a, float __b, float __c, float __d, + float __e, float __f, float __g, float __h) +{ + return __extension__ (__m256){ __h, __g, __f, __e, __d, __c, __b, __a }; +} + +/// Constructs a 256-bit integer vector initialized with the specified +/// 32-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i0 +/// A 32-bit integral value used to initialize bits [255:224] of the result. +/// \param __i1 +/// A 32-bit integral value used to initialize bits [223:192] of the result. +/// \param __i2 +/// A 32-bit integral value used to initialize bits [191:160] of the result. +/// \param __i3 +/// A 32-bit integral value used to initialize bits [159:128] of the result. +/// \param __i4 +/// A 32-bit integral value used to initialize bits [127:96] of the result. +/// \param __i5 +/// A 32-bit integral value used to initialize bits [95:64] of the result. +/// \param __i6 +/// A 32-bit integral value used to initialize bits [63:32] of the result. +/// \param __i7 +/// A 32-bit integral value used to initialize bits [31:0] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set_epi32(int __i0, int __i1, int __i2, int __i3, + int __i4, int __i5, int __i6, int __i7) +{ + return __extension__ (__m256i)(__v8si){ __i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0 }; +} + +/// Constructs a 256-bit integer vector initialized with the specified +/// 16-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w15 +/// A 16-bit integral value used to initialize bits [255:240] of the result. +/// \param __w14 +/// A 16-bit integral value used to initialize bits [239:224] of the result. +/// \param __w13 +/// A 16-bit integral value used to initialize bits [223:208] of the result. +/// \param __w12 +/// A 16-bit integral value used to initialize bits [207:192] of the result. +/// \param __w11 +/// A 16-bit integral value used to initialize bits [191:176] of the result. +/// \param __w10 +/// A 16-bit integral value used to initialize bits [175:160] of the result. +/// \param __w09 +/// A 16-bit integral value used to initialize bits [159:144] of the result. +/// \param __w08 +/// A 16-bit integral value used to initialize bits [143:128] of the result. +/// \param __w07 +/// A 16-bit integral value used to initialize bits [127:112] of the result. +/// \param __w06 +/// A 16-bit integral value used to initialize bits [111:96] of the result. +/// \param __w05 +/// A 16-bit integral value used to initialize bits [95:80] of the result. +/// \param __w04 +/// A 16-bit integral value used to initialize bits [79:64] of the result. +/// \param __w03 +/// A 16-bit integral value used to initialize bits [63:48] of the result. +/// \param __w02 +/// A 16-bit integral value used to initialize bits [47:32] of the result. +/// \param __w01 +/// A 16-bit integral value used to initialize bits [31:16] of the result. +/// \param __w00 +/// A 16-bit integral value used to initialize bits [15:0] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set_epi16(short __w15, short __w14, short __w13, short __w12, + short __w11, short __w10, short __w09, short __w08, + short __w07, short __w06, short __w05, short __w04, + short __w03, short __w02, short __w01, short __w00) +{ + return __extension__ (__m256i)(__v16hi){ __w00, __w01, __w02, __w03, __w04, __w05, __w06, + __w07, __w08, __w09, __w10, __w11, __w12, __w13, __w14, __w15 }; +} + +/// Constructs a 256-bit integer vector initialized with the specified +/// 8-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b31 +/// An 8-bit integral value used to initialize bits [255:248] of the result. +/// \param __b30 +/// An 8-bit integral value used to initialize bits [247:240] of the result. +/// \param __b29 +/// An 8-bit integral value used to initialize bits [239:232] of the result. +/// \param __b28 +/// An 8-bit integral value used to initialize bits [231:224] of the result. +/// \param __b27 +/// An 8-bit integral value used to initialize bits [223:216] of the result. +/// \param __b26 +/// An 8-bit integral value used to initialize bits [215:208] of the result. +/// \param __b25 +/// An 8-bit integral value used to initialize bits [207:200] of the result. +/// \param __b24 +/// An 8-bit integral value used to initialize bits [199:192] of the result. +/// \param __b23 +/// An 8-bit integral value used to initialize bits [191:184] of the result. +/// \param __b22 +/// An 8-bit integral value used to initialize bits [183:176] of the result. +/// \param __b21 +/// An 8-bit integral value used to initialize bits [175:168] of the result. +/// \param __b20 +/// An 8-bit integral value used to initialize bits [167:160] of the result. +/// \param __b19 +/// An 8-bit integral value used to initialize bits [159:152] of the result. +/// \param __b18 +/// An 8-bit integral value used to initialize bits [151:144] of the result. +/// \param __b17 +/// An 8-bit integral value used to initialize bits [143:136] of the result. +/// \param __b16 +/// An 8-bit integral value used to initialize bits [135:128] of the result. +/// \param __b15 +/// An 8-bit integral value used to initialize bits [127:120] of the result. +/// \param __b14 +/// An 8-bit integral value used to initialize bits [119:112] of the result. +/// \param __b13 +/// An 8-bit integral value used to initialize bits [111:104] of the result. +/// \param __b12 +/// An 8-bit integral value used to initialize bits [103:96] of the result. +/// \param __b11 +/// An 8-bit integral value used to initialize bits [95:88] of the result. +/// \param __b10 +/// An 8-bit integral value used to initialize bits [87:80] of the result. +/// \param __b09 +/// An 8-bit integral value used to initialize bits [79:72] of the result. +/// \param __b08 +/// An 8-bit integral value used to initialize bits [71:64] of the result. +/// \param __b07 +/// An 8-bit integral value used to initialize bits [63:56] of the result. +/// \param __b06 +/// An 8-bit integral value used to initialize bits [55:48] of the result. +/// \param __b05 +/// An 8-bit integral value used to initialize bits [47:40] of the result. +/// \param __b04 +/// An 8-bit integral value used to initialize bits [39:32] of the result. +/// \param __b03 +/// An 8-bit integral value used to initialize bits [31:24] of the result. +/// \param __b02 +/// An 8-bit integral value used to initialize bits [23:16] of the result. +/// \param __b01 +/// An 8-bit integral value used to initialize bits [15:8] of the result. +/// \param __b00 +/// An 8-bit integral value used to initialize bits [7:0] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set_epi8(char __b31, char __b30, char __b29, char __b28, + char __b27, char __b26, char __b25, char __b24, + char __b23, char __b22, char __b21, char __b20, + char __b19, char __b18, char __b17, char __b16, + char __b15, char __b14, char __b13, char __b12, + char __b11, char __b10, char __b09, char __b08, + char __b07, char __b06, char __b05, char __b04, + char __b03, char __b02, char __b01, char __b00) +{ + return __extension__ (__m256i)(__v32qi){ + __b00, __b01, __b02, __b03, __b04, __b05, __b06, __b07, + __b08, __b09, __b10, __b11, __b12, __b13, __b14, __b15, + __b16, __b17, __b18, __b19, __b20, __b21, __b22, __b23, + __b24, __b25, __b26, __b27, __b28, __b29, __b30, __b31 + }; +} + +/// Constructs a 256-bit integer vector initialized with the specified +/// 64-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKLQDQ+VINSERTF128 +/// instruction. +/// +/// \param __a +/// A 64-bit integral value used to initialize bits [255:192] of the result. +/// \param __b +/// A 64-bit integral value used to initialize bits [191:128] of the result. +/// \param __c +/// A 64-bit integral value used to initialize bits [127:64] of the result. +/// \param __d +/// A 64-bit integral value used to initialize bits [63:0] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set_epi64x(long long __a, long long __b, long long __c, long long __d) +{ + return __extension__ (__m256i)(__v4di){ __d, __c, __b, __a }; +} + +/* Create vectors with elements in reverse order */ +/// Constructs a 256-bit floating-point vector of [4 x double], +/// initialized in reverse order with the specified double-precision +/// floating-point values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD+VINSERTF128 +/// instruction. +/// +/// \param __a +/// A double-precision floating-point value used to initialize bits [63:0] +/// of the result. +/// \param __b +/// A double-precision floating-point value used to initialize bits [127:64] +/// of the result. +/// \param __c +/// A double-precision floating-point value used to initialize bits [191:128] +/// of the result. +/// \param __d +/// A double-precision floating-point value used to initialize bits [255:192] +/// of the result. +/// \returns An initialized 256-bit floating-point vector of [4 x double]. +static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_setr_pd(double __a, double __b, double __c, double __d) +{ + return _mm256_set_pd(__d, __c, __b, __a); +} + +/// Constructs a 256-bit floating-point vector of [8 x float], +/// initialized in reverse order with the specified single-precision +/// float-point values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __a +/// A single-precision floating-point value used to initialize bits [31:0] +/// of the result. +/// \param __b +/// A single-precision floating-point value used to initialize bits [63:32] +/// of the result. +/// \param __c +/// A single-precision floating-point value used to initialize bits [95:64] +/// of the result. +/// \param __d +/// A single-precision floating-point value used to initialize bits [127:96] +/// of the result. +/// \param __e +/// A single-precision floating-point value used to initialize bits [159:128] +/// of the result. +/// \param __f +/// A single-precision floating-point value used to initialize bits [191:160] +/// of the result. +/// \param __g +/// A single-precision floating-point value used to initialize bits [223:192] +/// of the result. +/// \param __h +/// A single-precision floating-point value used to initialize bits [255:224] +/// of the result. +/// \returns An initialized 256-bit floating-point vector of [8 x float]. +static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_setr_ps(float __a, float __b, float __c, float __d, + float __e, float __f, float __g, float __h) +{ + return _mm256_set_ps(__h, __g, __f, __e, __d, __c, __b, __a); +} + +/// Constructs a 256-bit integer vector, initialized in reverse order +/// with the specified 32-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i0 +/// A 32-bit integral value used to initialize bits [31:0] of the result. +/// \param __i1 +/// A 32-bit integral value used to initialize bits [63:32] of the result. +/// \param __i2 +/// A 32-bit integral value used to initialize bits [95:64] of the result. +/// \param __i3 +/// A 32-bit integral value used to initialize bits [127:96] of the result. +/// \param __i4 +/// A 32-bit integral value used to initialize bits [159:128] of the result. +/// \param __i5 +/// A 32-bit integral value used to initialize bits [191:160] of the result. +/// \param __i6 +/// A 32-bit integral value used to initialize bits [223:192] of the result. +/// \param __i7 +/// A 32-bit integral value used to initialize bits [255:224] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_setr_epi32(int __i0, int __i1, int __i2, int __i3, + int __i4, int __i5, int __i6, int __i7) +{ + return _mm256_set_epi32(__i7, __i6, __i5, __i4, __i3, __i2, __i1, __i0); +} + +/// Constructs a 256-bit integer vector, initialized in reverse order +/// with the specified 16-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w15 +/// A 16-bit integral value used to initialize bits [15:0] of the result. +/// \param __w14 +/// A 16-bit integral value used to initialize bits [31:16] of the result. +/// \param __w13 +/// A 16-bit integral value used to initialize bits [47:32] of the result. +/// \param __w12 +/// A 16-bit integral value used to initialize bits [63:48] of the result. +/// \param __w11 +/// A 16-bit integral value used to initialize bits [79:64] of the result. +/// \param __w10 +/// A 16-bit integral value used to initialize bits [95:80] of the result. +/// \param __w09 +/// A 16-bit integral value used to initialize bits [111:96] of the result. +/// \param __w08 +/// A 16-bit integral value used to initialize bits [127:112] of the result. +/// \param __w07 +/// A 16-bit integral value used to initialize bits [143:128] of the result. +/// \param __w06 +/// A 16-bit integral value used to initialize bits [159:144] of the result. +/// \param __w05 +/// A 16-bit integral value used to initialize bits [175:160] of the result. +/// \param __w04 +/// A 16-bit integral value used to initialize bits [191:176] of the result. +/// \param __w03 +/// A 16-bit integral value used to initialize bits [207:192] of the result. +/// \param __w02 +/// A 16-bit integral value used to initialize bits [223:208] of the result. +/// \param __w01 +/// A 16-bit integral value used to initialize bits [239:224] of the result. +/// \param __w00 +/// A 16-bit integral value used to initialize bits [255:240] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_setr_epi16(short __w15, short __w14, short __w13, short __w12, + short __w11, short __w10, short __w09, short __w08, + short __w07, short __w06, short __w05, short __w04, + short __w03, short __w02, short __w01, short __w00) +{ + return _mm256_set_epi16(__w00, __w01, __w02, __w03, + __w04, __w05, __w06, __w07, + __w08, __w09, __w10, __w11, + __w12, __w13, __w14, __w15); +} + +/// Constructs a 256-bit integer vector, initialized in reverse order +/// with the specified 8-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b31 +/// An 8-bit integral value used to initialize bits [7:0] of the result. +/// \param __b30 +/// An 8-bit integral value used to initialize bits [15:8] of the result. +/// \param __b29 +/// An 8-bit integral value used to initialize bits [23:16] of the result. +/// \param __b28 +/// An 8-bit integral value used to initialize bits [31:24] of the result. +/// \param __b27 +/// An 8-bit integral value used to initialize bits [39:32] of the result. +/// \param __b26 +/// An 8-bit integral value used to initialize bits [47:40] of the result. +/// \param __b25 +/// An 8-bit integral value used to initialize bits [55:48] of the result. +/// \param __b24 +/// An 8-bit integral value used to initialize bits [63:56] of the result. +/// \param __b23 +/// An 8-bit integral value used to initialize bits [71:64] of the result. +/// \param __b22 +/// An 8-bit integral value used to initialize bits [79:72] of the result. +/// \param __b21 +/// An 8-bit integral value used to initialize bits [87:80] of the result. +/// \param __b20 +/// An 8-bit integral value used to initialize bits [95:88] of the result. +/// \param __b19 +/// An 8-bit integral value used to initialize bits [103:96] of the result. +/// \param __b18 +/// An 8-bit integral value used to initialize bits [111:104] of the result. +/// \param __b17 +/// An 8-bit integral value used to initialize bits [119:112] of the result. +/// \param __b16 +/// An 8-bit integral value used to initialize bits [127:120] of the result. +/// \param __b15 +/// An 8-bit integral value used to initialize bits [135:128] of the result. +/// \param __b14 +/// An 8-bit integral value used to initialize bits [143:136] of the result. +/// \param __b13 +/// An 8-bit integral value used to initialize bits [151:144] of the result. +/// \param __b12 +/// An 8-bit integral value used to initialize bits [159:152] of the result. +/// \param __b11 +/// An 8-bit integral value used to initialize bits [167:160] of the result. +/// \param __b10 +/// An 8-bit integral value used to initialize bits [175:168] of the result. +/// \param __b09 +/// An 8-bit integral value used to initialize bits [183:176] of the result. +/// \param __b08 +/// An 8-bit integral value used to initialize bits [191:184] of the result. +/// \param __b07 +/// An 8-bit integral value used to initialize bits [199:192] of the result. +/// \param __b06 +/// An 8-bit integral value used to initialize bits [207:200] of the result. +/// \param __b05 +/// An 8-bit integral value used to initialize bits [215:208] of the result. +/// \param __b04 +/// An 8-bit integral value used to initialize bits [223:216] of the result. +/// \param __b03 +/// An 8-bit integral value used to initialize bits [231:224] of the result. +/// \param __b02 +/// An 8-bit integral value used to initialize bits [239:232] of the result. +/// \param __b01 +/// An 8-bit integral value used to initialize bits [247:240] of the result. +/// \param __b00 +/// An 8-bit integral value used to initialize bits [255:248] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_setr_epi8(char __b31, char __b30, char __b29, char __b28, + char __b27, char __b26, char __b25, char __b24, + char __b23, char __b22, char __b21, char __b20, + char __b19, char __b18, char __b17, char __b16, + char __b15, char __b14, char __b13, char __b12, + char __b11, char __b10, char __b09, char __b08, + char __b07, char __b06, char __b05, char __b04, + char __b03, char __b02, char __b01, char __b00) +{ + return _mm256_set_epi8(__b00, __b01, __b02, __b03, __b04, __b05, __b06, __b07, + __b08, __b09, __b10, __b11, __b12, __b13, __b14, __b15, + __b16, __b17, __b18, __b19, __b20, __b21, __b22, __b23, + __b24, __b25, __b26, __b27, __b28, __b29, __b30, __b31); +} + +/// Constructs a 256-bit integer vector, initialized in reverse order +/// with the specified 64-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKLQDQ+VINSERTF128 +/// instruction. +/// +/// \param __a +/// A 64-bit integral value used to initialize bits [63:0] of the result. +/// \param __b +/// A 64-bit integral value used to initialize bits [127:64] of the result. +/// \param __c +/// A 64-bit integral value used to initialize bits [191:128] of the result. +/// \param __d +/// A 64-bit integral value used to initialize bits [255:192] of the result. +/// \returns An initialized 256-bit integer vector. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_setr_epi64x(long long __a, long long __b, long long __c, long long __d) +{ + return _mm256_set_epi64x(__d, __c, __b, __a); +} + +/* Create vectors with repeated elements */ +/// Constructs a 256-bit floating-point vector of [4 x double], with each +/// of the four double-precision floating-point vector elements set to the +/// specified double-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP+VINSERTF128 instruction. +/// +/// \param __w +/// A double-precision floating-point value used to initialize each vector +/// element of the result. +/// \returns An initialized 256-bit floating-point vector of [4 x double]. +static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_set1_pd(double __w) +{ + return _mm256_set_pd(__w, __w, __w, __w); +} + +/// Constructs a 256-bit floating-point vector of [8 x float], with each +/// of the eight single-precision floating-point vector elements set to the +/// specified single-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPS+VINSERTF128 +/// instruction. +/// +/// \param __w +/// A single-precision floating-point value used to initialize each vector +/// element of the result. +/// \returns An initialized 256-bit floating-point vector of [8 x float]. +static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_set1_ps(float __w) +{ + return _mm256_set_ps(__w, __w, __w, __w, __w, __w, __w, __w); +} + +/// Constructs a 256-bit integer vector of [8 x i32], with each of the +/// 32-bit integral vector elements set to the specified 32-bit integral +/// value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPS+VINSERTF128 +/// instruction. +/// +/// \param __i +/// A 32-bit integral value used to initialize each vector element of the +/// result. +/// \returns An initialized 256-bit integer vector of [8 x i32]. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set1_epi32(int __i) +{ + return _mm256_set_epi32(__i, __i, __i, __i, __i, __i, __i, __i); +} + +/// Constructs a 256-bit integer vector of [16 x i16], with each of the +/// 16-bit integral vector elements set to the specified 16-bit integral +/// value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSHUFB+VINSERTF128 instruction. +/// +/// \param __w +/// A 16-bit integral value used to initialize each vector element of the +/// result. +/// \returns An initialized 256-bit integer vector of [16 x i16]. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set1_epi16(short __w) +{ + return _mm256_set_epi16(__w, __w, __w, __w, __w, __w, __w, __w, + __w, __w, __w, __w, __w, __w, __w, __w); +} + +/// Constructs a 256-bit integer vector of [32 x i8], with each of the +/// 8-bit integral vector elements set to the specified 8-bit integral value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSHUFB+VINSERTF128 instruction. +/// +/// \param __b +/// An 8-bit integral value used to initialize each vector element of the +/// result. +/// \returns An initialized 256-bit integer vector of [32 x i8]. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set1_epi8(char __b) +{ + return _mm256_set_epi8(__b, __b, __b, __b, __b, __b, __b, __b, + __b, __b, __b, __b, __b, __b, __b, __b, + __b, __b, __b, __b, __b, __b, __b, __b, + __b, __b, __b, __b, __b, __b, __b, __b); +} + +/// Constructs a 256-bit integer vector of [4 x i64], with each of the +/// 64-bit integral vector elements set to the specified 64-bit integral +/// value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP+VINSERTF128 instruction. +/// +/// \param __q +/// A 64-bit integral value used to initialize each vector element of the +/// result. +/// \returns An initialized 256-bit integer vector of [4 x i64]. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set1_epi64x(long long __q) +{ + return _mm256_set_epi64x(__q, __q, __q, __q); +} + +/* Create __zeroed vectors */ +/// Constructs a 256-bit floating-point vector of [4 x double] with all +/// vector elements initialized to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS instruction. +/// +/// \returns A 256-bit vector of [4 x double] with all elements set to zero. +static __inline __m256d __DEFAULT_FN_ATTRS_CONSTEXPR _mm256_setzero_pd(void) { + return __extension__(__m256d){0.0, 0.0, 0.0, 0.0}; +} + +/// Constructs a 256-bit floating-point vector of [8 x float] with all +/// vector elements initialized to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS instruction. +/// +/// \returns A 256-bit vector of [8 x float] with all elements set to zero. +static __inline __m256 __DEFAULT_FN_ATTRS_CONSTEXPR _mm256_setzero_ps(void) { + return __extension__ (__m256){ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; +} + +/// Constructs a 256-bit integer vector initialized to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS instruction. +/// +/// \returns A 256-bit integer vector initialized to zero. +static __inline __m256i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm256_setzero_si256(void) { + return __extension__ (__m256i)(__v4di){ 0, 0, 0, 0 }; +} + +/* Cast between vector types */ +/// Casts a 256-bit floating-point vector of [4 x double] into a 256-bit +/// floating-point vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [4 x double]. +/// \returns A 256-bit floating-point vector of [8 x float] containing the same +/// bitwise pattern as the parameter. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_castpd_ps(__m256d __a) +{ + return (__m256)__a; +} + +/// Casts a 256-bit floating-point vector of [4 x double] into a 256-bit +/// integer vector. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [4 x double]. +/// \returns A 256-bit integer vector containing the same bitwise pattern as the +/// parameter. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_castpd_si256(__m256d __a) +{ + return (__m256i)__a; +} + +/// Casts a 256-bit floating-point vector of [8 x float] into a 256-bit +/// floating-point vector of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [8 x float]. +/// \returns A 256-bit floating-point vector of [4 x double] containing the same +/// bitwise pattern as the parameter. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_castps_pd(__m256 __a) +{ + return (__m256d)__a; +} + +/// Casts a 256-bit floating-point vector of [8 x float] into a 256-bit +/// integer vector. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [8 x float]. +/// \returns A 256-bit integer vector containing the same bitwise pattern as the +/// parameter. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_castps_si256(__m256 __a) +{ + return (__m256i)__a; +} + +/// Casts a 256-bit integer vector into a 256-bit floating-point vector +/// of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \returns A 256-bit floating-point vector of [8 x float] containing the same +/// bitwise pattern as the parameter. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_castsi256_ps(__m256i __a) +{ + return (__m256)__a; +} + +/// Casts a 256-bit integer vector into a 256-bit floating-point vector +/// of [4 x double]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \returns A 256-bit floating-point vector of [4 x double] containing the same +/// bitwise pattern as the parameter. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_castsi256_pd(__m256i __a) +{ + return (__m256d)__a; +} + +/// Returns the lower 128 bits of a 256-bit floating-point vector of +/// [4 x double] as a 128-bit floating-point vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [4 x double]. +/// \returns A 128-bit floating-point vector of [2 x double] containing the +/// lower 128 bits of the parameter. +static __inline __m128d __DEFAULT_FN_ATTRS +_mm256_castpd256_pd128(__m256d __a) +{ + return __builtin_shufflevector((__v4df)__a, (__v4df)__a, 0, 1); +} + +/// Returns the lower 128 bits of a 256-bit floating-point vector of +/// [8 x float] as a 128-bit floating-point vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit floating-point vector of [8 x float]. +/// \returns A 128-bit floating-point vector of [4 x float] containing the +/// lower 128 bits of the parameter. +static __inline __m128 __DEFAULT_FN_ATTRS +_mm256_castps256_ps128(__m256 __a) +{ + return __builtin_shufflevector((__v8sf)__a, (__v8sf)__a, 0, 1, 2, 3); +} + +/// Truncates a 256-bit integer vector into a 128-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 256-bit integer vector. +/// \returns A 128-bit integer vector containing the lower 128 bits of the +/// parameter. +static __inline __m128i __DEFAULT_FN_ATTRS +_mm256_castsi256_si128(__m256i __a) +{ + return __builtin_shufflevector((__v4di)__a, (__v4di)__a, 0, 1); +} + +/// Constructs a 256-bit floating-point vector of [4 x double] from a +/// 128-bit floating-point vector of [2 x double]. +/// +/// The lower 128 bits contain the value of the source vector. The contents +/// of the upper 128 bits are undefined. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 256-bit floating-point vector of [4 x double]. The lower 128 bits +/// contain the value of the parameter. The contents of the upper 128 bits +/// are undefined. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_castpd128_pd256(__m128d __a) +{ + return __builtin_shufflevector( + (__v2df)__a, (__v2df)__builtin_nondeterministic_value(__a), 0, 1, 2, 3); +} + +/// Constructs a 256-bit floating-point vector of [8 x float] from a +/// 128-bit floating-point vector of [4 x float]. +/// +/// The lower 128 bits contain the value of the source vector. The contents +/// of the upper 128 bits are undefined. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 256-bit floating-point vector of [8 x float]. The lower 128 bits +/// contain the value of the parameter. The contents of the upper 128 bits +/// are undefined. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_castps128_ps256(__m128 __a) +{ + return __builtin_shufflevector((__v4sf)__a, + (__v4sf)__builtin_nondeterministic_value(__a), + 0, 1, 2, 3, 4, 5, 6, 7); +} + +/// Constructs a 256-bit integer vector from a 128-bit integer vector. +/// +/// The lower 128 bits contain the value of the source vector. The contents +/// of the upper 128 bits are undefined. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \returns A 256-bit integer vector. The lower 128 bits contain the value of +/// the parameter. The contents of the upper 128 bits are undefined. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_castsi128_si256(__m128i __a) +{ + return __builtin_shufflevector( + (__v2di)__a, (__v2di)__builtin_nondeterministic_value(__a), 0, 1, 2, 3); +} + +/// Constructs a 256-bit floating-point vector of [4 x double] from a +/// 128-bit floating-point vector of [2 x double]. The lower 128 bits +/// contain the value of the source vector. The upper 128 bits are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 256-bit floating-point vector of [4 x double]. The lower 128 bits +/// contain the value of the parameter. The upper 128 bits are set to zero. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_zextpd128_pd256(__m128d __a) +{ + return __builtin_shufflevector((__v2df)__a, (__v2df)_mm_setzero_pd(), 0, 1, 2, 3); +} + +/// Constructs a 256-bit floating-point vector of [8 x float] from a +/// 128-bit floating-point vector of [4 x float]. The lower 128 bits contain +/// the value of the source vector. The upper 128 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 256-bit floating-point vector of [8 x float]. The lower 128 bits +/// contain the value of the parameter. The upper 128 bits are set to zero. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_zextps128_ps256(__m128 __a) +{ + return __builtin_shufflevector((__v4sf)__a, (__v4sf)_mm_setzero_ps(), 0, 1, 2, 3, 4, 5, 6, 7); +} + +/// Constructs a 256-bit integer vector from a 128-bit integer vector. +/// The lower 128 bits contain the value of the source vector. The upper +/// 128 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \returns A 256-bit integer vector. The lower 128 bits contain the value of +/// the parameter. The upper 128 bits are set to zero. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_zextsi128_si256(__m128i __a) +{ + return __builtin_shufflevector((__v2di)__a, (__v2di)_mm_setzero_si128(), 0, 1, 2, 3); +} + +/* + Vector insert. + We use macros rather than inlines because we only want to accept + invocations where the immediate M is a constant expression. +*/ +/// Constructs a new 256-bit vector of [8 x float] by first duplicating +/// a 256-bit vector of [8 x float] given in the first parameter, and then +/// replacing either the upper or the lower 128 bits with the contents of a +/// 128-bit vector of [4 x float] in the second parameter. +/// +/// The immediate integer parameter determines between the upper or the lower +/// 128 bits. +/// +/// \headerfile +/// +/// \code +/// __m256 _mm256_insertf128_ps(__m256 V1, __m128 V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param V1 +/// A 256-bit vector of [8 x float]. This vector is copied to the result +/// first, and then either the upper or the lower 128 bits of the result will +/// be replaced by the contents of \a V2. +/// \param V2 +/// A 128-bit vector of [4 x float]. The contents of this parameter are +/// written to either the upper or the lower 128 bits of the result depending +/// on the value of parameter \a M. +/// \param M +/// An immediate integer. The least significant bit determines how the values +/// from the two parameters are interleaved: \n +/// If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result, +/// and bits [255:128] of \a V1 are copied to bits [255:128] of the +/// result. \n +/// If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the +/// result, and bits [127:0] of \a V1 are copied to bits [127:0] of the +/// result. +/// \returns A 256-bit vector of [8 x float] containing the interleaved values. +#define _mm256_insertf128_ps(V1, V2, M) \ + ((__m256)__builtin_ia32_vinsertf128_ps256((__v8sf)(__m256)(V1), \ + (__v4sf)(__m128)(V2), (int)(M))) + +/// Constructs a new 256-bit vector of [4 x double] by first duplicating +/// a 256-bit vector of [4 x double] given in the first parameter, and then +/// replacing either the upper or the lower 128 bits with the contents of a +/// 128-bit vector of [2 x double] in the second parameter. +/// +/// The immediate integer parameter determines between the upper or the lower +/// 128 bits. +/// +/// \headerfile +/// +/// \code +/// __m256d _mm256_insertf128_pd(__m256d V1, __m128d V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param V1 +/// A 256-bit vector of [4 x double]. This vector is copied to the result +/// first, and then either the upper or the lower 128 bits of the result will +/// be replaced by the contents of \a V2. +/// \param V2 +/// A 128-bit vector of [2 x double]. The contents of this parameter are +/// written to either the upper or the lower 128 bits of the result depending +/// on the value of parameter \a M. +/// \param M +/// An immediate integer. The least significant bit determines how the values +/// from the two parameters are interleaved: \n +/// If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result, +/// and bits [255:128] of \a V1 are copied to bits [255:128] of the +/// result. \n +/// If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the +/// result, and bits [127:0] of \a V1 are copied to bits [127:0] of the +/// result. +/// \returns A 256-bit vector of [4 x double] containing the interleaved values. +#define _mm256_insertf128_pd(V1, V2, M) \ + ((__m256d)__builtin_ia32_vinsertf128_pd256((__v4df)(__m256d)(V1), \ + (__v2df)(__m128d)(V2), (int)(M))) + +/// Constructs a new 256-bit integer vector by first duplicating a +/// 256-bit integer vector given in the first parameter, and then replacing +/// either the upper or the lower 128 bits with the contents of a 128-bit +/// integer vector in the second parameter. +/// +/// The immediate integer parameter determines between the upper or the lower +/// 128 bits. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_insertf128_si256(__m256i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param V1 +/// A 256-bit integer vector. This vector is copied to the result first, and +/// then either the upper or the lower 128 bits of the result will be +/// replaced by the contents of \a V2. +/// \param V2 +/// A 128-bit integer vector. The contents of this parameter are written to +/// either the upper or the lower 128 bits of the result depending on the +/// value of parameter \a M. +/// \param M +/// An immediate integer. The least significant bit determines how the values +/// from the two parameters are interleaved: \n +/// If bit [0] of \a M is 0, \a V2 are copied to bits [127:0] of the result, +/// and bits [255:128] of \a V1 are copied to bits [255:128] of the +/// result. \n +/// If bit [0] of \a M is 1, \a V2 are copied to bits [255:128] of the +/// result, and bits [127:0] of \a V1 are copied to bits [127:0] of the +/// result. +/// \returns A 256-bit integer vector containing the interleaved values. +#define _mm256_insertf128_si256(V1, V2, M) \ + ((__m256i)__builtin_ia32_vinsertf128_si256((__v8si)(__m256i)(V1), \ + (__v4si)(__m128i)(V2), (int)(M))) + +/* + Vector extract. + We use macros rather than inlines because we only want to accept + invocations where the immediate M is a constant expression. +*/ +/// Extracts either the upper or the lower 128 bits from a 256-bit vector +/// of [8 x float], as determined by the immediate integer parameter, and +/// returns the extracted bits as a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm256_extractf128_ps(__m256 V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128 instruction. +/// +/// \param V +/// A 256-bit vector of [8 x float]. +/// \param M +/// An immediate integer. The least significant bit determines which bits are +/// extracted from the first parameter: \n +/// If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the +/// result. \n +/// If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result. +/// \returns A 128-bit vector of [4 x float] containing the extracted bits. +#define _mm256_extractf128_ps(V, M) \ + ((__m128)__builtin_ia32_vextractf128_ps256((__v8sf)(__m256)(V), (int)(M))) + +/// Extracts either the upper or the lower 128 bits from a 256-bit vector +/// of [4 x double], as determined by the immediate integer parameter, and +/// returns the extracted bits as a 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm256_extractf128_pd(__m256d V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128 instruction. +/// +/// \param V +/// A 256-bit vector of [4 x double]. +/// \param M +/// An immediate integer. The least significant bit determines which bits are +/// extracted from the first parameter: \n +/// If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the +/// result. \n +/// If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result. +/// \returns A 128-bit vector of [2 x double] containing the extracted bits. +#define _mm256_extractf128_pd(V, M) \ + ((__m128d)__builtin_ia32_vextractf128_pd256((__v4df)(__m256d)(V), (int)(M))) + +/// Extracts either the upper or the lower 128 bits from a 256-bit +/// integer vector, as determined by the immediate integer parameter, and +/// returns the extracted bits as a 128-bit integer vector. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm256_extractf128_si256(__m256i V, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTF128 instruction. +/// +/// \param V +/// A 256-bit integer vector. +/// \param M +/// An immediate integer. The least significant bit determines which bits are +/// extracted from the first parameter: \n +/// If bit [0] of \a M is 0, bits [127:0] of \a V are copied to the +/// result. \n +/// If bit [0] of \a M is 1, bits [255:128] of \a V are copied to the result. +/// \returns A 128-bit integer vector containing the extracted bits. +#define _mm256_extractf128_si256(V, M) \ + ((__m128i)__builtin_ia32_vextractf128_si256((__v8si)(__m256i)(V), (int)(M))) + +/// Constructs a 256-bit floating-point vector of [8 x float] by +/// concatenating two 128-bit floating-point vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param __hi +/// A 128-bit floating-point vector of [4 x float] to be copied to the upper +/// 128 bits of the result. +/// \param __lo +/// A 128-bit floating-point vector of [4 x float] to be copied to the lower +/// 128 bits of the result. +/// \returns A 256-bit floating-point vector of [8 x float] containing the +/// concatenated result. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_set_m128 (__m128 __hi, __m128 __lo) +{ + return (__m256) __builtin_shufflevector((__v4sf)__lo, (__v4sf)__hi, 0, 1, 2, 3, 4, 5, 6, 7); +} + +/// Constructs a 256-bit floating-point vector of [4 x double] by +/// concatenating two 128-bit floating-point vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param __hi +/// A 128-bit floating-point vector of [2 x double] to be copied to the upper +/// 128 bits of the result. +/// \param __lo +/// A 128-bit floating-point vector of [2 x double] to be copied to the lower +/// 128 bits of the result. +/// \returns A 256-bit floating-point vector of [4 x double] containing the +/// concatenated result. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_set_m128d (__m128d __hi, __m128d __lo) +{ + return (__m256d) __builtin_shufflevector((__v2df)__lo, (__v2df)__hi, 0, 1, 2, 3); +} + +/// Constructs a 256-bit integer vector by concatenating two 128-bit +/// integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param __hi +/// A 128-bit integer vector to be copied to the upper 128 bits of the +/// result. +/// \param __lo +/// A 128-bit integer vector to be copied to the lower 128 bits of the +/// result. +/// \returns A 256-bit integer vector containing the concatenated result. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_set_m128i (__m128i __hi, __m128i __lo) +{ + return (__m256i) __builtin_shufflevector((__v2di)__lo, (__v2di)__hi, 0, 1, 2, 3); +} + +/// Constructs a 256-bit floating-point vector of [8 x float] by +/// concatenating two 128-bit floating-point vectors of [4 x float]. This is +/// similar to _mm256_set_m128, but the order of the input parameters is +/// swapped. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param __lo +/// A 128-bit floating-point vector of [4 x float] to be copied to the lower +/// 128 bits of the result. +/// \param __hi +/// A 128-bit floating-point vector of [4 x float] to be copied to the upper +/// 128 bits of the result. +/// \returns A 256-bit floating-point vector of [8 x float] containing the +/// concatenated result. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_setr_m128 (__m128 __lo, __m128 __hi) +{ + return _mm256_set_m128(__hi, __lo); +} + +/// Constructs a 256-bit floating-point vector of [4 x double] by +/// concatenating two 128-bit floating-point vectors of [2 x double]. This is +/// similar to _mm256_set_m128d, but the order of the input parameters is +/// swapped. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param __lo +/// A 128-bit floating-point vector of [2 x double] to be copied to the lower +/// 128 bits of the result. +/// \param __hi +/// A 128-bit floating-point vector of [2 x double] to be copied to the upper +/// 128 bits of the result. +/// \returns A 256-bit floating-point vector of [4 x double] containing the +/// concatenated result. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_setr_m128d (__m128d __lo, __m128d __hi) +{ + return (__m256d)_mm256_set_m128d(__hi, __lo); +} + +/// Constructs a 256-bit integer vector by concatenating two 128-bit +/// integer vectors. This is similar to _mm256_set_m128i, but the order of +/// the input parameters is swapped. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VINSERTF128 instruction. +/// +/// \param __lo +/// A 128-bit integer vector to be copied to the lower 128 bits of the +/// result. +/// \param __hi +/// A 128-bit integer vector to be copied to the upper 128 bits of the +/// result. +/// \returns A 256-bit integer vector containing the concatenated result. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_setr_m128i (__m128i __lo, __m128i __hi) +{ + return (__m256i)_mm256_set_m128i(__hi, __lo); +} + +/* SIMD load ops (unaligned) */ +/// Loads two 128-bit floating-point vectors of [4 x float] from +/// unaligned memory locations and constructs a 256-bit floating-point vector +/// of [8 x float] by concatenating the two 128-bit vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to load instructions followed by the +/// VINSERTF128 instruction. +/// +/// \param __addr_hi +/// A pointer to a 128-bit memory location containing 4 consecutive +/// single-precision floating-point values. These values are to be copied to +/// bits[255:128] of the result. The address of the memory location does not +/// have to be aligned. +/// \param __addr_lo +/// A pointer to a 128-bit memory location containing 4 consecutive +/// single-precision floating-point values. These values are to be copied to +/// bits[127:0] of the result. The address of the memory location does not +/// have to be aligned. +/// \returns A 256-bit floating-point vector of [8 x float] containing the +/// concatenated result. +static __inline __m256 __DEFAULT_FN_ATTRS +_mm256_loadu2_m128(float const *__addr_hi, float const *__addr_lo) +{ + return _mm256_set_m128(_mm_loadu_ps(__addr_hi), _mm_loadu_ps(__addr_lo)); +} + +/// Loads two 128-bit floating-point vectors of [2 x double] from +/// unaligned memory locations and constructs a 256-bit floating-point vector +/// of [4 x double] by concatenating the two 128-bit vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to load instructions followed by the +/// VINSERTF128 instruction. +/// +/// \param __addr_hi +/// A pointer to a 128-bit memory location containing two consecutive +/// double-precision floating-point values. These values are to be copied to +/// bits[255:128] of the result. The address of the memory location does not +/// have to be aligned. +/// \param __addr_lo +/// A pointer to a 128-bit memory location containing two consecutive +/// double-precision floating-point values. These values are to be copied to +/// bits[127:0] of the result. The address of the memory location does not +/// have to be aligned. +/// \returns A 256-bit floating-point vector of [4 x double] containing the +/// concatenated result. +static __inline __m256d __DEFAULT_FN_ATTRS +_mm256_loadu2_m128d(double const *__addr_hi, double const *__addr_lo) +{ + return _mm256_set_m128d(_mm_loadu_pd(__addr_hi), _mm_loadu_pd(__addr_lo)); +} + +/// Loads two 128-bit integer vectors from unaligned memory locations and +/// constructs a 256-bit integer vector by concatenating the two 128-bit +/// vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to load instructions followed by the +/// VINSERTF128 instruction. +/// +/// \param __addr_hi +/// A pointer to a 128-bit memory location containing a 128-bit integer +/// vector. This vector is to be copied to bits[255:128] of the result. The +/// address of the memory location does not have to be aligned. +/// \param __addr_lo +/// A pointer to a 128-bit memory location containing a 128-bit integer +/// vector. This vector is to be copied to bits[127:0] of the result. The +/// address of the memory location does not have to be aligned. +/// \returns A 256-bit integer vector containing the concatenated result. +static __inline __m256i __DEFAULT_FN_ATTRS +_mm256_loadu2_m128i(__m128i_u const *__addr_hi, __m128i_u const *__addr_lo) +{ + return _mm256_set_m128i(_mm_loadu_si128(__addr_hi), _mm_loadu_si128(__addr_lo)); +} + +/* SIMD store ops (unaligned) */ +/// Stores the upper and lower 128 bits of a 256-bit floating-point +/// vector of [8 x float] into two different unaligned memory locations. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VEXTRACTF128 instruction and the +/// store instructions. +/// +/// \param __addr_hi +/// A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be +/// copied to this memory location. The address of this memory location does +/// not have to be aligned. +/// \param __addr_lo +/// A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be +/// copied to this memory location. The address of this memory location does +/// not have to be aligned. +/// \param __a +/// A 256-bit floating-point vector of [8 x float]. +static __inline void __DEFAULT_FN_ATTRS +_mm256_storeu2_m128(float *__addr_hi, float *__addr_lo, __m256 __a) +{ + __m128 __v128; + + __v128 = _mm256_castps256_ps128(__a); + _mm_storeu_ps(__addr_lo, __v128); + __v128 = _mm256_extractf128_ps(__a, 1); + _mm_storeu_ps(__addr_hi, __v128); +} + +/// Stores the upper and lower 128 bits of a 256-bit floating-point +/// vector of [4 x double] into two different unaligned memory locations. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VEXTRACTF128 instruction and the +/// store instructions. +/// +/// \param __addr_hi +/// A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be +/// copied to this memory location. The address of this memory location does +/// not have to be aligned. +/// \param __addr_lo +/// A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be +/// copied to this memory location. The address of this memory location does +/// not have to be aligned. +/// \param __a +/// A 256-bit floating-point vector of [4 x double]. +static __inline void __DEFAULT_FN_ATTRS +_mm256_storeu2_m128d(double *__addr_hi, double *__addr_lo, __m256d __a) +{ + __m128d __v128; + + __v128 = _mm256_castpd256_pd128(__a); + _mm_storeu_pd(__addr_lo, __v128); + __v128 = _mm256_extractf128_pd(__a, 1); + _mm_storeu_pd(__addr_hi, __v128); +} + +/// Stores the upper and lower 128 bits of a 256-bit integer vector into +/// two different unaligned memory locations. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VEXTRACTF128 instruction and the +/// store instructions. +/// +/// \param __addr_hi +/// A pointer to a 128-bit memory location. Bits[255:128] of \a __a are to be +/// copied to this memory location. The address of this memory location does +/// not have to be aligned. +/// \param __addr_lo +/// A pointer to a 128-bit memory location. Bits[127:0] of \a __a are to be +/// copied to this memory location. The address of this memory location does +/// not have to be aligned. +/// \param __a +/// A 256-bit integer vector. +static __inline void __DEFAULT_FN_ATTRS +_mm256_storeu2_m128i(__m128i_u *__addr_hi, __m128i_u *__addr_lo, __m256i __a) +{ + __m128i __v128; + + __v128 = _mm256_castsi256_si128(__a); + _mm_storeu_si128(__addr_lo, __v128); + __v128 = _mm256_extractf128_si256(__a, 1); + _mm_storeu_si128(__addr_hi, __v128); +} + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_CONSTEXPR +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS128_CONSTEXPR + +#endif /* __AVXINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxneconvertintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxneconvertintrin.h new file mode 100755 index 0000000..1bef1c8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxneconvertintrin.h @@ -0,0 +1,484 @@ +/*===-------------- avxneconvertintrin.h - AVXNECONVERT --------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifdef __SSE2__ + +#ifndef __AVXNECONVERTINTRIN_H +#define __AVXNECONVERTINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("avxneconvert"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("avxneconvert"), \ + __min_vector_width__(256))) + +/// Convert scalar BF16 (16-bit) floating-point element +/// stored at memory locations starting at location \a __A to a +/// single-precision (32-bit) floating-point, broadcast it to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_bcstnebf16_ps(const void *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VBCSTNEBF162PS instruction. +/// +/// \param __A +/// A pointer to a 16-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns +/// A 128-bit vector of [4 x float]. +/// +/// \code{.operation} +/// b := Convert_BF16_To_FP32(MEM[__A+15:__A]) +/// FOR j := 0 to 3 +/// m := j*32 +/// dst[m+31:m] := b +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_bcstnebf16_ps(const void *__A) { + return (__m128)__builtin_ia32_vbcstnebf162ps128((const __bf16 *)__A); +} + +/// Convert scalar BF16 (16-bit) floating-point element +/// stored at memory locations starting at location \a __A to a +/// single-precision (32-bit) floating-point, broadcast it to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_bcstnebf16_ps(const void *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VBCSTNEBF162PS instruction. +/// +/// \param __A +/// A pointer to a 16-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns +/// A 256-bit vector of [8 x float]. +/// +/// \code{.operation} +/// b := Convert_BF16_To_FP32(MEM[__A+15:__A]) +/// FOR j := 0 to 7 +/// m := j*32 +/// dst[m+31:m] := b +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_bcstnebf16_ps(const void *__A) { + return (__m256)__builtin_ia32_vbcstnebf162ps256((const __bf16 *)__A); +} + +/// Convert scalar half-precision (16-bit) floating-point element +/// stored at memory locations starting at location \a __A to a +/// single-precision (32-bit) floating-point, broadcast it to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_bcstnesh_ps(const void *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VBCSTNESH2PS instruction. +/// +/// \param __A +/// A pointer to a 16-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns +/// A 128-bit vector of [4 x float]. +/// +/// \code{.operation} +/// b := Convert_FP16_To_FP32(MEM[__A+15:__A]) +/// FOR j := 0 to 3 +/// m := j*32 +/// dst[m+31:m] := b +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_bcstnesh_ps(const void *__A) { + return (__m128)__builtin_ia32_vbcstnesh2ps128((const _Float16 *)__A); +} + +/// Convert scalar half-precision (16-bit) floating-point element +/// stored at memory locations starting at location \a __A to a +/// single-precision (32-bit) floating-point, broadcast it to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_bcstnesh_ps(const void *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VBCSTNESH2PS instruction. +/// +/// \param __A +/// A pointer to a 16-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns +/// A 256-bit vector of [8 x float]. +/// +/// \code{.operation} +/// b := Convert_FP16_To_FP32(MEM[__A+15:__A]) +/// FOR j := 0 to 7 +/// m := j*32 +/// dst[m+31:m] := b +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_bcstnesh_ps(const void *__A) { + return (__m256)__builtin_ia32_vbcstnesh2ps256((const _Float16 *)__A); +} + +/// Convert packed BF16 (16-bit) floating-point even-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_cvtneebf16_ps(const __m128bh *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEEBF162PS instruction. +/// +/// \param __A +/// A pointer to a 128-bit memory location containing 8 consecutive +/// BF16 (16-bit) floating-point values. +/// \returns +/// A 128-bit vector of [4 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// k := j*2 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_BF16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtneebf16_ps(const __m128bh *__A) { + return (__m128)__builtin_ia32_vcvtneebf162ps128((const __v8bf *)__A); +} + +/// Convert packed BF16 (16-bit) floating-point even-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_cvtneebf16_ps(const __m256bh *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEEBF162PS instruction. +/// +/// \param __A +/// A pointer to a 256-bit memory location containing 16 consecutive +/// BF16 (16-bit) floating-point values. +/// \returns +/// A 256-bit vector of [8 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// k := j*2 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_BF16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_cvtneebf16_ps(const __m256bh *__A) { + return (__m256)__builtin_ia32_vcvtneebf162ps256((const __v16bf *)__A); +} + +/// Convert packed half-precision (16-bit) floating-point even-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_cvtneeph_ps(const __m128h *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEEPH2PS instruction. +/// +/// \param __A +/// A pointer to a 128-bit memory location containing 8 consecutive +/// half-precision (16-bit) floating-point values. +/// \returns +/// A 128-bit vector of [4 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// k := j*2 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_FP16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtneeph_ps(const __m128h *__A) { + return (__m128)__builtin_ia32_vcvtneeph2ps128((const __v8hf *)__A); +} + +/// Convert packed half-precision (16-bit) floating-point even-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_cvtneeph_ps(const __m256h *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEEPH2PS instruction. +/// +/// \param __A +/// A pointer to a 256-bit memory location containing 16 consecutive +/// half-precision (16-bit) floating-point values. +/// \returns +/// A 256-bit vector of [8 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// k := j*2 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_FP16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_cvtneeph_ps(const __m256h *__A) { + return (__m256)__builtin_ia32_vcvtneeph2ps256((const __v16hf *)__A); +} + +/// Convert packed BF16 (16-bit) floating-point odd-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_cvtneobf16_ps(const __m128bh *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEOBF162PS instruction. +/// +/// \param __A +/// A pointer to a 128-bit memory location containing 8 consecutive +/// BF16 (16-bit) floating-point values. +/// \returns +/// A 128-bit vector of [4 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// k := j*2+1 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_BF16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtneobf16_ps(const __m128bh *__A) { + return (__m128)__builtin_ia32_vcvtneobf162ps128((const __v8bf *)__A); +} + +/// Convert packed BF16 (16-bit) floating-point odd-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_cvtneobf16_ps(const __m256bh *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEOBF162PS instruction. +/// +/// \param __A +/// A pointer to a 256-bit memory location containing 16 consecutive +/// BF16 (16-bit) floating-point values. +/// \returns +/// A 256-bit vector of [8 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// k := j*2+1 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_BF16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_cvtneobf16_ps(const __m256bh *__A) { + return (__m256)__builtin_ia32_vcvtneobf162ps256((const __v16bf *)__A); +} + +/// Convert packed half-precision (16-bit) floating-point odd-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_cvtneoph_ps(const __m128h *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEOPH2PS instruction. +/// +/// \param __A +/// A pointer to a 128-bit memory location containing 8 consecutive +/// half-precision (16-bit) floating-point values. +/// \returns +/// A 128-bit vector of [4 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// k := j*2+1 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_FP16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtneoph_ps(const __m128h *__A) { + return (__m128)__builtin_ia32_vcvtneoph2ps128((const __v8hf *)__A); +} + +/// Convert packed half-precision (16-bit) floating-point odd-indexed elements +/// stored at memory locations starting at location \a __A to packed +/// single-precision (32-bit) floating-point elements, and store the results in +/// \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_cvtneoph_ps(const __m256h *__A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEOPH2PS instruction. +/// +/// \param __A +/// A pointer to a 256-bit memory location containing 16 consecutive +/// half-precision (16-bit) floating-point values. +/// \returns +/// A 256-bit vector of [8 x float]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// k := j*2+1 +/// i := k*16 +/// m := j*32 +/// dst[m+31:m] := Convert_FP16_To_FP32(MEM[__A+i+15:__A+i]) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_cvtneoph_ps(const __m256h *__A) { + return (__m256)__builtin_ia32_vcvtneoph2ps256((const __v16hf *)__A); +} + +/// Convert packed single-precision (32-bit) floating-point elements in \a __A +/// to packed BF16 (16-bit) floating-point elements, and store the results in \a +/// dst. +/// +/// \headerfile +/// +/// \code +/// _mm_cvtneps_avx_pbh(__m128 __A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEPS2BF16 instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float]. +/// \returns +/// A 128-bit vector of [8 x bfloat]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// dst.word[j] := Convert_FP32_To_BF16(__A.fp32[j]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128bh __DEFAULT_FN_ATTRS128 +_mm_cvtneps_avx_pbh(__m128 __A) { + return (__m128bh)__builtin_ia32_vcvtneps2bf16128((__v4sf)__A); +} + +/// Convert packed single-precision (32-bit) floating-point elements in \a __A +/// to packed BF16 (16-bit) floating-point elements, and store the results in \a +/// dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_cvtneps_avx_pbh(__m256 __A); +/// \endcode +/// +/// This intrinsic corresponds to the \c VCVTNEPS2BF16 instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float]. +/// \returns +/// A 128-bit vector of [8 x bfloat]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// dst.word[j] := Convert_FP32_To_BF16(a.fp32[j]) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128bh __DEFAULT_FN_ATTRS256 +_mm256_cvtneps_avx_pbh(__m256 __A) { + return (__m128bh)__builtin_ia32_vcvtneps2bf16256((__v8sf)__A); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif // __AVXNECONVERTINTRIN_H +#endif // __SSE2__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniint16intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniint16intrin.h new file mode 100755 index 0000000..805d249 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniint16intrin.h @@ -0,0 +1,432 @@ +/*===----------- avxvnniint16intrin.h - AVXVNNIINT16 intrinsics-------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __AVXVNNIINT16INTRIN_H +#define __AVXVNNIINT16INTRIN_H + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_dpwsud_epi32(__m128i __W, __m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUD instruction. +/// +/// \param __W +/// A 128-bit vector of [4 x int]. +/// \param __A +/// A 128-bit vector of [8 x short]. +/// \param __B +/// A 128-bit vector of [8 x unsigned short]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpwsud_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpwsud128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_dpwsud_epi32(__m256i __W, __m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUD instruction. +/// +/// \param __W +/// A 256-bit vector of [8 x int]. +/// \param __A +/// A 256-bit vector of [16 x short]. +/// \param __B +/// A 256-bit vector of [16 x unsigned short]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpwsud_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpwsud256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_dpwsuds_epi32(__m128i __W, __m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUDS instruction. +/// +/// \param __W +/// A 128-bit vector of [4 x int]. +/// \param __A +/// A 128-bit vector of [8 x short]. +/// \param __B +/// A 128-bit vector of [8 x unsigned short]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpwsuds_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpwsuds128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_dpwsuds_epi32(__m256i __W, __m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUDS instruction. +/// +/// \param __W +/// A 256-bit vector of [8 x int]. +/// \param __A +/// A 256-bit vector of [16 x short]. +/// \param __B +/// A 256-bit vector of [16 x unsigned short]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpwsuds_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpwsuds256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_dpbusd_epi32(__m128i __W, __m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWUSD instruction. +/// +/// \param __W +/// A 128-bit vector of [4 x int]. +/// \param __A +/// A 128-bit vector of [8 x unsigned short]. +/// \param __B +/// A 128-bit vector of [8 x short]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpwusd_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpwusd128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_dpwusd_epi32(__m256i __W, __m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWUSD instruction. +/// +/// \param __W +/// A 256-bit vector of [8 x int]. +/// \param __A +/// A 256-bit vector of [16 x unsigned short]. +/// \param __B +/// A 256-bit vector of [16 x short]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpwusd_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpwusd256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_dpwusds_epi32(__m128i __W, __m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUDS instruction. +/// +/// \param __W +/// A 128-bit vector of [4 x int]. +/// \param __A +/// A 128-bit vector of [8 x unsigned short]. +/// \param __B +/// A 128-bit vector of [8 x short]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpwusds_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpwusds128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding signed 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_dpwsuds_epi32(__m256i __W, __m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUDS instruction. +/// +/// \param __W +/// A 256-bit vector of [8 x int]. +/// \param __A +/// A 256-bit vector of [16 x unsigned short]. +/// \param __B +/// A 256-bit vector of [16 x short]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpwusds_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpwusds256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_dpwuud_epi32(__m128i __W, __m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWUUD instruction. +/// +/// \param __W +/// A 128-bit vector of [4 x unsigned int]. +/// \param __A +/// A 128-bit vector of [8 x unsigned short]. +/// \param __B +/// A 128-bit vector of [8 x unsigned short]. +/// \returns +/// A 128-bit vector of [4 x unsigned int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpwuud_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpwuud128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_dpwuud_epi32(__m256i __W, __m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWUUD instruction. +/// +/// \param __W +/// A 256-bit vector of [8 x unsigned int]. +/// \param __A +/// A 256-bit vector of [16 x unsigned short]. +/// \param __B +/// A 256-bit vector of [16 x unsigned short]. +/// \returns +/// A 256-bit vector of [8 x unsigned int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpwuud_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpwuud256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_dpwsuds_epi32(__m128i __W, __m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUDS instruction. +/// +/// \param __W +/// A 128-bit vector of [4 x unsigned int]. +/// \param __A +/// A 128-bit vector of [8 x unsigned short]. +/// \param __B +/// A 128-bit vector of [8 x unsigned short]. +/// \returns +/// A 128-bit vector of [4 x unsigned int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := UNSIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpwuuds_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpwuuds128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 2 adjacent pairs of unsigned 16-bit integers in \a __A with +/// corresponding unsigned 16-bit integers in \a __B, producing 2 intermediate +/// signed 16-bit results. Sum these 2 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_dpwuuds_epi32(__m256i __W, __m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPWSUDS instruction. +/// +/// \param __W +/// A 256-bit vector of [8 x unsigned int]. +/// \param __A +/// A 256-bit vector of [16 x unsigned short]. +/// \param __B +/// A 256-bit vector of [16 x unsigned short]. +/// \returns +/// A 256-bit vector of [8 x unsigned int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := ZeroExtend32(__A.word[2*j]) * ZeroExtend32(__B.word[2*j]) +/// tmp2.dword := ZeroExtend32(__A.word[2*j+1]) * ZeroExtend32(__B.word[2*j+1]) +/// dst.dword[j] := UNSIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpwuuds_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpwuuds256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +#endif // __AVXVNNIINT16INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniint8intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniint8intrin.h new file mode 100755 index 0000000..c211620 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniint8intrin.h @@ -0,0 +1,430 @@ +/*===-------- avxvnniint8intrin.h - AVXVNNIINT8 intrinsics -----------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifndef __AVXVNNIINT8INTRIN_H +#define __AVXVNNIINT8INTRIN_H + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_dpbssd_epi32(__m128i __W, __m128i __A, __m128i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x char]. +/// \param __B +/// A 128-bit vector of [16 x char]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := SignExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]) +/// tmp2.word := SignExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]) +/// tmp3.word := SignExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]) +/// tmp4.word := SignExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpbssd_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpbssd128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_dpbssd_epi32(__m256i __W, __m256i __A, __m256i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x char]. +/// \param __B +/// A 256-bit vector of [32 x char]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := SignExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]) +/// tmp2.word := SignExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]) +/// tmp3.word := SignExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]) +/// tmp4.word := SignExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpbssd_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpbssd256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_dpbssds_epi32( __m128i __W, __m128i __A, __m128i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x char]. +/// \param __B +/// A 128-bit vector of [16 x char]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := SignExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]) +/// tmp2.word := SignExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]) +/// tmp3.word := SignExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]) +/// tmp4.word := SignExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpbssds_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpbssds128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_dpbssds_epi32(__m256i __W, __m256i __A, __m256i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x char]. +/// \param __B +/// A 256-bit vector of [32 x char]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := SignExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j]) +/// tmp2.word := SignExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1]) +/// tmp3.word := SignExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2]) +/// tmp4.word := SignExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpbssds_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpbssds256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_dpbsud_epi32(__m128i __W, __m128i __A, __m128i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x char]. +/// \param __B +/// A 128-bit vector of [16 x unsigned char]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := Signed(SignExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(SignExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(SignExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(SignExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3])) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpbsud_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpbsud128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_dpbsud_epi32(__m256i __W, __m256i __A, __m256i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x char]. +/// \param __B +/// A 256-bit vector of [32 x unsigned char]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := Signed(SignExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(SignExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(SignExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(SignExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3])) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpbsud_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpbsud256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_dpbsuds_epi32( __m128i __W, __m128i __A, __m128i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x char]. +/// \param __B +/// A 128-bit vector of [16 x unsigned char]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := Signed(SignExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(SignExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(SignExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(SignExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3])) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpbsuds_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpbsuds128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_dpbsuds_epi32(__m256i __W, __m256i __A, __m256i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x char]. +/// \param __B +/// A 256-bit vector of [32 x unsigned char]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := Signed(SignExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(SignExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(SignExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(SignExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3])) +/// dst.dword[j] := SIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpbsuds_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpbsuds256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_dpbuud_epi32(__m128i __W, __m128i __A, __m128i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x unsigned char]. +/// \param __B +/// A 128-bit vector of [16 x unsigned char]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := ZeroExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j]) +/// tmp2.word := ZeroExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1]) +/// tmp3.word := ZeroExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2]) +/// tmp4.word := ZeroExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpbuud_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpbuud128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W, and store the packed 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_dpbuud_epi32(__m256i __W, __m256i __A, __m256i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBSSD instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x unsigned char]. +/// \param __B +/// A 256-bit vector of [32 x unsigned char]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := ZeroExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j]) +/// tmp2.word := ZeroExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1]) +/// tmp3.word := ZeroExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2]) +/// tmp4.word := ZeroExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := __W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpbuud_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpbuud256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm_dpbuuds_epi32( __m128i __W, __m128i __A, __m128i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBUUDS instruction. +/// +/// \param __A +/// A 128-bit vector of [16 x unsigned char]. +/// \param __B +/// A 128-bit vector of [16 x unsigned char]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := ZeroExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j]) +/// tmp2.word := ZeroExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1]) +/// tmp3.word := ZeroExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2]) +/// tmp4.word := ZeroExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := UNSIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_dpbuuds_epi32(__W, __A, __B) \ + ((__m128i)__builtin_ia32_vpdpbuuds128((__v4si)(__W), (__v4si)(__A), \ + (__v4si)(__B))) + +/// corresponding unsigned 8-bit integers in \a __B, producing 4 intermediate +/// signed 16-bit results. Sum these 4 results with the corresponding +/// 32-bit integer in \a __W with signed saturation, and store the packed +/// 32-bit results in \a dst. +/// +/// \headerfile +/// +/// \code +/// _mm256_dpbuuds_epi32(__m256i __W, __m256i __A, __m256i __B); +/// \endcode +/// +/// This intrinsic corresponds to the \c VPDPBUUDS instruction. +/// +/// \param __A +/// A 256-bit vector of [32 x unsigned char]. +/// \param __B +/// A 256-bit vector of [32 x unsigned char]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := ZeroExtend16(__A.byte[4*j]) * ZeroExtend16(__B.byte[4*j]) +/// tmp2.word := ZeroExtend16(__A.byte[4*j+1]) * ZeroExtend16(__B.byte[4*j+1]) +/// tmp3.word := ZeroExtend16(__A.byte[4*j+2]) * ZeroExtend16(__B.byte[4*j+2]) +/// tmp4.word := ZeroExtend16(__A.byte[4*j+3]) * ZeroExtend16(__B.byte[4*j+3]) +/// dst.dword[j] := UNSIGNED_DWORD_SATURATE(__W.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// dst[MAX:256] := 0 +/// \endcode +#define _mm256_dpbuuds_epi32(__W, __A, __B) \ + ((__m256i)__builtin_ia32_vpdpbuuds256((__v8si)(__W), (__v8si)(__A), \ + (__v8si)(__B))) + +#endif // __AVXVNNIINT8INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniintrin.h new file mode 100755 index 0000000..b7de562 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/avxvnniintrin.h @@ -0,0 +1,225 @@ +/*===--------------- avxvnniintrin.h - VNNI intrinsics --------------------=== + * + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __AVXVNNIINTRIN_H +#define __AVXVNNIINTRIN_H + +/* Below intrinsics defined in avx512vlvnniintrin.h can be used for AVXVNNI */ +/// \fn __m256i _mm256_dpbusd_epi32(__m256i __S, __m256i __A, __m256i __B) +/// \fn __m256i _mm256_dpbusds_epi32(__m256i __S, __m256i __A, __m256i __B) +/// \fn __m256i _mm256_dpwssd_epi32(__m256i __S, __m256i __A, __m256i __B) +/// \fn __m256i _mm256_dpwssds_epi32(__m256i __S, __m256i __A, __m256i __B) +/// \fn __m128i _mm_dpbusd_epi32(__m128i __S, __m128i __A, __m128i __B) +/// \fn __m128i _mm_dpbusds_epi32(__m128i __S, __m128i __A, __m128i __B) +/// \fn __m128i _mm_dpwssd_epi32(__m128i __S, __m128i __A, __m128i __B) +/// \fn __m128i _mm_dpwssds_epi32(__m128i __S, __m128i __A, __m128i __B) + +/* Intrinsics with _avx_ prefix are for compatibility with msvc. */ +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("avxvnni"), __min_vector_width__(256))) +#define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("avxvnni"), __min_vector_width__(128))) + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a __S, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3])) +/// DST.dword[j] := __S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_dpbusd_avx_epi32(__m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_vpdpbusd256((__v8si)__S, (__v8si)__A, (__v8si)__B); +} + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a __S using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3])) +/// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_dpbusds_avx_epi32(__m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_vpdpbusds256((__v8si)__S, (__v8si)__A, (__v8si)__B); +} + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a __S, +/// and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// DST.dword[j] := __S.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_dpwssd_avx_epi32(__m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_vpdpwssd256((__v8si)__S, (__v8si)__A, (__v8si)__B); +} + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a __S +/// using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 7 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// DST[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_dpwssds_avx_epi32(__m256i __S, __m256i __A, __m256i __B) +{ + return (__m256i)__builtin_ia32_vpdpwssds256((__v8si)__S, (__v8si)__A, (__v8si)__B); +} + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a __S, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3])) +/// DST.dword[j] := __S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4 +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_dpbusd_avx_epi32(__m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpdpbusd128((__v4si)__S, (__v4si)__A, (__v4si)__B); +} + +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in \a __A with +/// corresponding signed 8-bit integers in \a __B, producing 4 intermediate signed +/// 16-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in \a __S using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPBUSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.word := Signed(ZeroExtend16(__A.byte[4*j]) * SignExtend16(__B.byte[4*j])) +/// tmp2.word := Signed(ZeroExtend16(__A.byte[4*j+1]) * SignExtend16(__B.byte[4*j+1])) +/// tmp3.word := Signed(ZeroExtend16(__A.byte[4*j+2]) * SignExtend16(__B.byte[4*j+2])) +/// tmp4.word := Signed(ZeroExtend16(__A.byte[4*j+3]) * SignExtend16(__B.byte[4*j+3])) +/// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2 + tmp3 + tmp4) +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_dpbusds_avx_epi32(__m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpdpbusds128((__v4si)__S, (__v4si)__A, (__v4si)__B); +} + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a __S, +/// and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSD instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// DST.dword[j] := __S.dword[j] + tmp1 + tmp2 +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_dpwssd_avx_epi32(__m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpdpwssd128((__v4si)__S, (__v4si)__A, (__v4si)__B); +} + +/// Multiply groups of 2 adjacent pairs of signed 16-bit integers in \a __A with +/// corresponding 16-bit integers in \a __B, producing 2 intermediate signed 32-bit +/// results. Sum these 2 results with the corresponding 32-bit integer in \a __S +/// using signed saturation, and store the packed 32-bit results in DST. +/// +/// This intrinsic corresponds to the VPDPWSSDS instructions. +/// +/// \code{.operation} +/// FOR j := 0 to 3 +/// tmp1.dword := SignExtend32(__A.word[2*j]) * SignExtend32(__B.word[2*j]) +/// tmp2.dword := SignExtend32(__A.word[2*j+1]) * SignExtend32(__B.word[2*j+1]) +/// DST.dword[j] := Saturate32(__S.dword[j] + tmp1 + tmp2) +/// ENDFOR +/// DST[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_dpwssds_avx_epi32(__m128i __S, __m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpdpwssds128((__v4si)__S, (__v4si)__A, (__v4si)__B); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif // __AVXVNNIINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/bmi2intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/bmi2intrin.h new file mode 100755 index 0000000..bdb61b1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/bmi2intrin.h @@ -0,0 +1,253 @@ +/*===---- bmi2intrin.h - BMI2 intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __BMI2INTRIN_H +#define __BMI2INTRIN_H + +/* Define the default attributes for the functions in this file. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("bmi2"))) constexpr +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("bmi2"))) +#endif + +/// Copies the unsigned 32-bit integer \a __X and zeroes the upper bits +/// starting at bit number \a __Y. +/// +/// \code{.operation} +/// i := __Y[7:0] +/// result := __X +/// IF i < 32 +/// result[31:i] := 0 +/// FI +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BZHI instruction. +/// +/// \param __X +/// The 32-bit source value to copy. +/// \param __Y +/// The lower 8 bits specify the bit number of the lowest bit to zero. +/// \returns The partially zeroed 32-bit value. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_bzhi_u32(unsigned int __X, unsigned int __Y) { + return __builtin_ia32_bzhi_si(__X, __Y); +} + +/// Deposit (scatter) low-order bits from the unsigned 32-bit integer \a __X +/// into the 32-bit result, according to the mask in the unsigned 32-bit +/// integer \a __Y. All other bits of the result are zero. +/// +/// \code{.operation} +/// i := 0 +/// result := 0 +/// FOR m := 0 TO 31 +/// IF __Y[m] == 1 +/// result[m] := __X[i] +/// i := i + 1 +/// ENDIF +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PDEP instruction. +/// +/// \param __X +/// The 32-bit source value to copy. +/// \param __Y +/// The 32-bit mask specifying where to deposit source bits. +/// \returns The 32-bit result. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_pdep_u32(unsigned int __X, unsigned int __Y) { + return __builtin_ia32_pdep_si(__X, __Y); +} + +/// Extract (gather) bits from the unsigned 32-bit integer \a __X into the +/// low-order bits of the 32-bit result, according to the mask in the +/// unsigned 32-bit integer \a __Y. All other bits of the result are zero. +/// +/// \code{.operation} +/// i := 0 +/// result := 0 +/// FOR m := 0 TO 31 +/// IF __Y[m] == 1 +/// result[i] := __X[m] +/// i := i + 1 +/// ENDIF +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PEXT instruction. +/// +/// \param __X +/// The 32-bit source value to copy. +/// \param __Y +/// The 32-bit mask specifying which source bits to extract. +/// \returns The 32-bit result. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_pext_u32(unsigned int __X, unsigned int __Y) { + return __builtin_ia32_pext_si(__X, __Y); +} + +/// Multiplies the unsigned 32-bit integers \a __X and \a __Y to form a +/// 64-bit product. Stores the upper 32 bits of the product in the +/// memory at \a __P and returns the lower 32 bits. +/// +/// \code{.operation} +/// Store32(__P, (__X * __Y)[63:32]) +/// result := (__X * __Y)[31:0] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MULX instruction. +/// +/// \param __X +/// An unsigned 32-bit multiplicand. +/// \param __Y +/// An unsigned 32-bit multiplicand. +/// \param __P +/// A pointer to memory for storing the upper half of the product. +/// \returns The lower half of the product. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mulx_u32(unsigned int __X, unsigned int __Y, unsigned int *__P) { + unsigned long long __res = (unsigned long long) __X * __Y; + *__P = (unsigned int)(__res >> 32); + return (unsigned int)__res; +} + +#ifdef __x86_64__ + +/// Copies the unsigned 64-bit integer \a __X and zeroes the upper bits +/// starting at bit number \a __Y. +/// +/// \code{.operation} +/// i := __Y[7:0] +/// result := __X +/// IF i < 64 +/// result[63:i] := 0 +/// FI +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BZHI instruction. +/// +/// \param __X +/// The 64-bit source value to copy. +/// \param __Y +/// The lower 8 bits specify the bit number of the lowest bit to zero. +/// \returns The partially zeroed 64-bit value. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_bzhi_u64(unsigned long long __X, unsigned long long __Y) { + return __builtin_ia32_bzhi_di(__X, __Y); +} + +/// Deposit (scatter) low-order bits from the unsigned 64-bit integer \a __X +/// into the 64-bit result, according to the mask in the unsigned 64-bit +/// integer \a __Y. All other bits of the result are zero. +/// +/// \code{.operation} +/// i := 0 +/// result := 0 +/// FOR m := 0 TO 63 +/// IF __Y[m] == 1 +/// result[m] := __X[i] +/// i := i + 1 +/// ENDIF +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PDEP instruction. +/// +/// \param __X +/// The 64-bit source value to copy. +/// \param __Y +/// The 64-bit mask specifying where to deposit source bits. +/// \returns The 64-bit result. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_pdep_u64(unsigned long long __X, unsigned long long __Y) { + return __builtin_ia32_pdep_di(__X, __Y); +} + +/// Extract (gather) bits from the unsigned 64-bit integer \a __X into the +/// low-order bits of the 64-bit result, according to the mask in the +/// unsigned 64-bit integer \a __Y. All other bits of the result are zero. +/// +/// \code{.operation} +/// i := 0 +/// result := 0 +/// FOR m := 0 TO 63 +/// IF __Y[m] == 1 +/// result[i] := __X[m] +/// i := i + 1 +/// ENDIF +/// ENDFOR +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PEXT instruction. +/// +/// \param __X +/// The 64-bit source value to copy. +/// \param __Y +/// The 64-bit mask specifying which source bits to extract. +/// \returns The 64-bit result. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_pext_u64(unsigned long long __X, unsigned long long __Y) { + return __builtin_ia32_pext_di(__X, __Y); +} + +/// Multiplies the unsigned 64-bit integers \a __X and \a __Y to form a +/// 128-bit product. Stores the upper 64 bits of the product to the +/// memory addressed by \a __P and returns the lower 64 bits. +/// +/// \code{.operation} +/// Store64(__P, (__X * __Y)[127:64]) +/// result := (__X * __Y)[63:0] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MULX instruction. +/// +/// \param __X +/// An unsigned 64-bit multiplicand. +/// \param __Y +/// An unsigned 64-bit multiplicand. +/// \param __P +/// A pointer to memory for storing the upper half of the product. +/// \returns The lower half of the product. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_mulx_u64 (unsigned long long __X, unsigned long long __Y, + unsigned long long *__P) { + unsigned __int128 __res = (unsigned __int128) __X * __Y; + *__P = (unsigned long long) (__res >> 64); + return (unsigned long long) __res; +} + +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __BMI2INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/bmiintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/bmiintrin.h new file mode 100755 index 0000000..8024da5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/bmiintrin.h @@ -0,0 +1,604 @@ +/*===---- bmiintrin.h - BMI intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __BMIINTRIN_H +#define __BMIINTRIN_H + +/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT + instruction behaves as BSF on non-BMI targets, there is code that expects + to use it as a potentially faster version of BSF. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __RELAXED_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__)) constexpr +#else +#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) +#endif + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 16-bit integer whose trailing zeros are to be counted. +/// \returns An unsigned 16-bit integer containing the number of trailing zero +/// bits in the operand. +/// \see _tzcnt_u16 +static __inline__ unsigned short __RELAXED_FN_ATTRS +__tzcnt_u16(unsigned short __X) { + return __builtin_ia32_tzcnt_u16(__X); +} + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// \code +/// unsigned short _tzcnt_u16(unsigned short __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 16-bit integer whose trailing zeros are to be counted. +/// \returns An unsigned 16-bit integer containing the number of trailing zero +/// bits in the operand. +/// \see __tzcnt_u16 +#define _tzcnt_u16 __tzcnt_u16 + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 32-bit integer whose trailing zeros are to be counted. +/// \returns An unsigned 32-bit integer containing the number of trailing zero +/// bits in the operand. +/// \see { _mm_tzcnt_32 _tzcnt_u32 } +static __inline__ unsigned int __RELAXED_FN_ATTRS +__tzcnt_u32(unsigned int __X) { + return __builtin_ia32_tzcnt_u32(__X); +} + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 32-bit integer whose trailing zeros are to be counted. +/// \returns A 32-bit integer containing the number of trailing zero bits in +/// the operand. +/// \see { __tzcnt_u32 _tzcnt_u32 } +static __inline__ int __RELAXED_FN_ATTRS +_mm_tzcnt_32(unsigned int __X) { + return (int)__builtin_ia32_tzcnt_u32(__X); +} + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// \code +/// unsigned int _tzcnt_u32(unsigned int __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 32-bit integer whose trailing zeros are to be counted. +/// \returns An unsigned 32-bit integer containing the number of trailing zero +/// bits in the operand. +/// \see { _mm_tzcnt_32 __tzcnt_u32 } +#define _tzcnt_u32 __tzcnt_u32 + +#ifdef __x86_64__ + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose trailing zeros are to be counted. +/// \returns An unsigned 64-bit integer containing the number of trailing zero +/// bits in the operand. +/// \see { _mm_tzcnt_64 _tzcnt_u64 } +static __inline__ unsigned long long __RELAXED_FN_ATTRS +__tzcnt_u64(unsigned long long __X) { + return __builtin_ia32_tzcnt_u64(__X); +} + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose trailing zeros are to be counted. +/// \returns An 64-bit integer containing the number of trailing zero bits in +/// the operand. +/// \see { __tzcnt_u64 _tzcnt_u64 } +static __inline__ long long __RELAXED_FN_ATTRS +_mm_tzcnt_64(unsigned long long __X) { + return (long long)__builtin_ia32_tzcnt_u64(__X); +} + +/// Counts the number of trailing zero bits in the operand. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _tzcnt_u64(unsigned long long __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c TZCNT instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose trailing zeros are to be counted. +/// \returns An unsigned 64-bit integer containing the number of trailing zero +/// bits in the operand. +/// \see { _mm_tzcnt_64 __tzcnt_u64 +#define _tzcnt_u64 __tzcnt_u64 + +#endif /* __x86_64__ */ + +#undef __RELAXED_FN_ATTRS + +/* Define the default attributes for the functions in this file. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("bmi"))) constexpr +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("bmi"))) +#endif + +/// Performs a bitwise AND of the second operand with the one's +/// complement of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ANDN instruction. +/// +/// \param __X +/// An unsigned integer containing one of the operands. +/// \param __Y +/// An unsigned integer containing one of the operands. +/// \returns An unsigned integer containing the bitwise AND of the second +/// operand with the one's complement of the first operand. +/// \see _andn_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__andn_u32(unsigned int __X, unsigned int __Y) { + return ~__X & __Y; +} + +/// Performs a bitwise AND of the second operand with the one's +/// complement of the first operand. +/// +/// \headerfile +/// +/// \code +/// unsigned int _andn_u32(unsigned int __X, unsigned int __Y); +/// \endcode +/// +/// This intrinsic corresponds to the \c ANDN instruction. +/// +/// \param __X +/// An unsigned integer containing one of the operands. +/// \param __Y +/// An unsigned integer containing one of the operands. +/// \returns An unsigned integer containing the bitwise AND of the second +/// operand with the one's complement of the first operand. +/// \see __andn_u32 +#define _andn_u32 __andn_u32 + +/* AMD-specified, double-leading-underscore version of BEXTR */ +/// Extracts the specified bits from the first operand and returns them +/// in the least significant bits of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BEXTR instruction. +/// +/// \param __X +/// An unsigned integer whose bits are to be extracted. +/// \param __Y +/// An unsigned integer used to specify which bits are extracted. Bits [7:0] +/// specify the index of the least significant bit. Bits [15:8] specify the +/// number of bits to be extracted. +/// \returns An unsigned integer whose least significant bits contain the +/// extracted bits. +/// \see _bextr_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__bextr_u32(unsigned int __X, unsigned int __Y) { + return __builtin_ia32_bextr_u32(__X, __Y); +} + +/* Intel-specified, single-leading-underscore version of BEXTR */ +/// Extracts the specified bits from the first operand and returns them +/// in the least significant bits of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BEXTR instruction. +/// +/// \param __X +/// An unsigned integer whose bits are to be extracted. +/// \param __Y +/// An unsigned integer used to specify the index of the least significant +/// bit for the bits to be extracted. Bits [7:0] specify the index. +/// \param __Z +/// An unsigned integer used to specify the number of bits to be extracted. +/// Bits [7:0] specify the number of bits. +/// \returns An unsigned integer whose least significant bits contain the +/// extracted bits. +/// \see __bextr_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_bextr_u32(unsigned int __X, unsigned int __Y, unsigned int __Z) { + return __builtin_ia32_bextr_u32(__X, ((__Y & 0xff) | ((__Z & 0xff) << 8))); +} + +/* Intel-specified, single-leading-underscore version of BEXTR2 */ +/// Extracts the specified bits from the first operand and returns them +/// in the least significant bits of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BEXTR instruction. +/// +/// \param __X +/// An unsigned integer whose bits are to be extracted. +/// \param __Y +/// An unsigned integer used to specify which bits are extracted. Bits [7:0] +/// specify the index of the least significant bit. Bits [15:8] specify the +/// number of bits to be extracted. +/// \returns An unsigned integer whose least significant bits contain the +/// extracted bits. +/// \see __bextr_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_bextr2_u32(unsigned int __X, unsigned int __Y) { + return __builtin_ia32_bextr_u32(__X, __Y); +} + +/// Clears all bits in the source except for the least significant bit +/// containing a value of 1 and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BLSI instruction. +/// +/// \param __X +/// An unsigned integer whose bits are to be cleared. +/// \returns An unsigned integer containing the result of clearing the bits from +/// the source operand. +/// \see _blsi_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blsi_u32(unsigned int __X) { + return __X & -__X; +} + +/// Clears all bits in the source except for the least significant bit +/// containing a value of 1 and returns the result. +/// +/// \headerfile +/// +/// \code +/// unsigned int _blsi_u32(unsigned int __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c BLSI instruction. +/// +/// \param __X +/// An unsigned integer whose bits are to be cleared. +/// \returns An unsigned integer containing the result of clearing the bits from +/// the source operand. +/// \see __blsi_u32 +#define _blsi_u32 __blsi_u32 + +/// Creates a mask whose bits are set to 1, using bit 0 up to and +/// including the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BLSMSK instruction. +/// +/// \param __X +/// An unsigned integer used to create the mask. +/// \returns An unsigned integer containing the newly created mask. +/// \see _blsmsk_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blsmsk_u32(unsigned int __X) { + return __X ^ (__X - 1); +} + +/// Creates a mask whose bits are set to 1, using bit 0 up to and +/// including the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// \code +/// unsigned int _blsmsk_u32(unsigned int __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c BLSMSK instruction. +/// +/// \param __X +/// An unsigned integer used to create the mask. +/// \returns An unsigned integer containing the newly created mask. +/// \see __blsmsk_u32 +#define _blsmsk_u32 __blsmsk_u32 + +/// Clears the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BLSR instruction. +/// +/// \param __X +/// An unsigned integer containing the operand to be cleared. +/// \returns An unsigned integer containing the result of clearing the source +/// operand. +/// \see _blsr_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blsr_u32(unsigned int __X) { + return __X & (__X - 1); +} + +/// Clears the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// \code +/// unsigned int _bls4_u32(unsigned int __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c BLSR instruction. +/// +/// \param __X +/// An unsigned integer containing the operand to be cleared. +/// \returns An unsigned integer containing the result of clearing the source +/// operand. +/// \see __blsr_u32 +#define _blsr_u32 __blsr_u32 + +#ifdef __x86_64__ + +/// Performs a bitwise AND of the second operand with the one's +/// complement of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ANDN instruction. +/// +/// \param __X +/// An unsigned 64-bit integer containing one of the operands. +/// \param __Y +/// An unsigned 64-bit integer containing one of the operands. +/// \returns An unsigned 64-bit integer containing the bitwise AND of the second +/// operand with the one's complement of the first operand. +/// \see _andn_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__andn_u64 (unsigned long long __X, unsigned long long __Y) { + return ~__X & __Y; +} + +/// Performs a bitwise AND of the second operand with the one's +/// complement of the first operand. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _andn_u64(unsigned long long __X, +/// unsigned long long __Y); +/// \endcode +/// +/// This intrinsic corresponds to the \c ANDN instruction. +/// +/// \param __X +/// An unsigned 64-bit integer containing one of the operands. +/// \param __Y +/// An unsigned 64-bit integer containing one of the operands. +/// \returns An unsigned 64-bit integer containing the bitwise AND of the second +/// operand with the one's complement of the first operand. +/// \see __andn_u64 +#define _andn_u64 __andn_u64 + +/* AMD-specified, double-leading-underscore version of BEXTR */ +/// Extracts the specified bits from the first operand and returns them +/// in the least significant bits of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BEXTR instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose bits are to be extracted. +/// \param __Y +/// An unsigned 64-bit integer used to specify which bits are extracted. Bits +/// [7:0] specify the index of the least significant bit. Bits [15:8] specify +/// the number of bits to be extracted. +/// \returns An unsigned 64-bit integer whose least significant bits contain the +/// extracted bits. +/// \see _bextr_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__bextr_u64(unsigned long long __X, unsigned long long __Y) { + return __builtin_ia32_bextr_u64(__X, __Y); +} + +/* Intel-specified, single-leading-underscore version of BEXTR */ +/// Extracts the specified bits from the first operand and returns them +/// in the least significant bits of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BEXTR instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose bits are to be extracted. +/// \param __Y +/// An unsigned integer used to specify the index of the least significant +/// bit for the bits to be extracted. Bits [7:0] specify the index. +/// \param __Z +/// An unsigned integer used to specify the number of bits to be extracted. +/// Bits [7:0] specify the number of bits. +/// \returns An unsigned 64-bit integer whose least significant bits contain the +/// extracted bits. +/// \see __bextr_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_bextr_u64(unsigned long long __X, unsigned int __Y, unsigned int __Z) { + return __builtin_ia32_bextr_u64(__X, ((__Y & 0xff) | ((__Z & 0xff) << 8))); +} + +/* Intel-specified, single-leading-underscore version of BEXTR2 */ +/// Extracts the specified bits from the first operand and returns them +/// in the least significant bits of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BEXTR instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose bits are to be extracted. +/// \param __Y +/// An unsigned 64-bit integer used to specify which bits are extracted. Bits +/// [7:0] specify the index of the least significant bit. Bits [15:8] specify +/// the number of bits to be extracted. +/// \returns An unsigned 64-bit integer whose least significant bits contain the +/// extracted bits. +/// \see __bextr_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_bextr2_u64(unsigned long long __X, unsigned long long __Y) { + return __builtin_ia32_bextr_u64(__X, __Y); +} + +/// Clears all bits in the source except for the least significant bit +/// containing a value of 1 and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BLSI instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose bits are to be cleared. +/// \returns An unsigned 64-bit integer containing the result of clearing the +/// bits from the source operand. +/// \see _blsi_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blsi_u64(unsigned long long __X) { + return __X & -__X; +} + +/// Clears all bits in the source except for the least significant bit +/// containing a value of 1 and returns the result. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _blsi_u64(unsigned long long __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c BLSI instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose bits are to be cleared. +/// \returns An unsigned 64-bit integer containing the result of clearing the +/// bits from the source operand. +/// \see __blsi_u64 +#define _blsi_u64 __blsi_u64 + +/// Creates a mask whose bits are set to 1, using bit 0 up to and +/// including the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BLSMSK instruction. +/// +/// \param __X +/// An unsigned 64-bit integer used to create the mask. +/// \returns An unsigned 64-bit integer containing the newly created mask. +/// \see _blsmsk_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blsmsk_u64(unsigned long long __X) { + return __X ^ (__X - 1); +} + +/// Creates a mask whose bits are set to 1, using bit 0 up to and +/// including the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _blsmsk_u64(unsigned long long __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c BLSMSK instruction. +/// +/// \param __X +/// An unsigned 64-bit integer used to create the mask. +/// \returns An unsigned 64-bit integer containing the newly created mask. +/// \see __blsmsk_u64 +#define _blsmsk_u64 __blsmsk_u64 + +/// Clears the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BLSR instruction. +/// +/// \param __X +/// An unsigned 64-bit integer containing the operand to be cleared. +/// \returns An unsigned 64-bit integer containing the result of clearing the +/// source operand. +/// \see _blsr_u64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blsr_u64(unsigned long long __X) { + return __X & (__X - 1); +} + +/// Clears the least significant bit that is set to 1 in the source +/// operand and returns the result. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _blsr_u64(unsigned long long __X); +/// \endcode +/// +/// This intrinsic corresponds to the \c BLSR instruction. +/// +/// \param __X +/// An unsigned 64-bit integer containing the operand to be cleared. +/// \returns An unsigned 64-bit integer containing the result of clearing the +/// source operand. +/// \see __blsr_u64 +#define _blsr_u64 __blsr_u64 + +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __BMIINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/builtins.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/builtins.h new file mode 100755 index 0000000..1e534e6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/builtins.h @@ -0,0 +1,19 @@ +/*===---- builtins.h - Standard header for extra builtins -----------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +/// Some legacy compilers have builtin definitions in a file named builtins.h. +/// This header file has been added to allow compatibility with code that was +/// written for those compilers. Code may have an include line for this file +/// and to avoid an error an empty file with this name is provided. +#ifndef __BUILTINS_H +#define __BUILTINS_H + +#if defined(__MVS__) && __has_include_next() +#include_next +#endif /* __MVS__ */ +#endif /* __BUILTINS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cet.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cet.h new file mode 100755 index 0000000..ffb19de --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cet.h @@ -0,0 +1,66 @@ +/*===------ cet.h -Control-flow Enforcement Technology feature ------------=== + * Add x86 feature with IBT and/or SHSTK bits to ELF program property if they + * are enabled. Otherwise, contents in this header file are unused. This file + * is mainly design for assembly source code which want to enable CET. + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __CET_H +#define __CET_H + +#ifdef __ASSEMBLER__ + +#ifndef __CET__ +# define _CET_ENDBR +#endif + +#ifdef __CET__ + +# ifdef __LP64__ +# if __CET__ & 0x1 +# define _CET_ENDBR endbr64 +# else +# define _CET_ENDBR +# endif +# else +# if __CET__ & 0x1 +# define _CET_ENDBR endbr32 +# else +# define _CET_ENDBR +# endif +# endif + + +# ifdef __LP64__ +# define __PROPERTY_ALIGN 3 +# else +# define __PROPERTY_ALIGN 2 +# endif + + .pushsection ".note.gnu.property", "a" + .p2align __PROPERTY_ALIGN + .long 1f - 0f /* name length. */ + .long 4f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0. */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align __PROPERTY_ALIGN + /* GNU_PROPERTY_X86_FEATURE_1_AND. */ + .long 0xc0000002 /* pr_type. */ + .long 3f - 2f /* pr_datasz. */ +2: + /* GNU_PROPERTY_X86_FEATURE_1_XXX. */ + .long __CET__ +3: + .p2align __PROPERTY_ALIGN +4: + .popsection +#endif +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cetintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cetintrin.h new file mode 100755 index 0000000..a68df5b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cetintrin.h @@ -0,0 +1,115 @@ +/*===---- cetintrin.h - CET intrinsic --------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __CETINTRIN_H +#define __CETINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("shstk"))) + +static __inline__ void __DEFAULT_FN_ATTRS _incsspd(int __a) { + __builtin_ia32_incsspd((unsigned int)__a); +} + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS _incsspq(unsigned long long __a) { + __builtin_ia32_incsspq(__a); +} +#endif /* __x86_64__ */ + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { + __builtin_ia32_incsspq(__a); +} +#else /* __x86_64__ */ +static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) { + __builtin_ia32_incsspd(__a); +} +#endif /* __x86_64__ */ + +static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd(unsigned int __a) { + return __builtin_ia32_rdsspd(__a); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd_i32(void) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wuninitialized" + unsigned int t; + return __builtin_ia32_rdsspd(t); +#pragma clang diagnostic pop +} + +#ifdef __x86_64__ +static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq(unsigned long long __a) { + return __builtin_ia32_rdsspq(__a); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq_i64(void) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wuninitialized" + unsigned long long t; + return __builtin_ia32_rdsspq(t); +#pragma clang diagnostic pop +} +#endif /* __x86_64__ */ + +#ifdef __x86_64__ +static __inline__ unsigned long long __DEFAULT_FN_ATTRS _get_ssp(void) { + return __builtin_ia32_rdsspq(0); +} +#else /* __x86_64__ */ +static __inline__ unsigned int __DEFAULT_FN_ATTRS _get_ssp(void) { + return __builtin_ia32_rdsspd(0); +} +#endif /* __x86_64__ */ + +static __inline__ void __DEFAULT_FN_ATTRS _saveprevssp(void) { + __builtin_ia32_saveprevssp(); +} + +static __inline__ void __DEFAULT_FN_ATTRS _rstorssp(void * __p) { + __builtin_ia32_rstorssp(__p); +} + +static __inline__ void __DEFAULT_FN_ATTRS _wrssd(unsigned int __a, void * __p) { + __builtin_ia32_wrssd(__a, __p); +} + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS _wrssq(unsigned long long __a, void * __p) { + __builtin_ia32_wrssq(__a, __p); +} +#endif /* __x86_64__ */ + +static __inline__ void __DEFAULT_FN_ATTRS _wrussd(unsigned int __a, void * __p) { + __builtin_ia32_wrussd(__a, __p); +} + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS _wrussq(unsigned long long __a, void * __p) { + __builtin_ia32_wrussq(__a, __p); +} +#endif /* __x86_64__ */ + +static __inline__ void __DEFAULT_FN_ATTRS _setssbsy(void) { + __builtin_ia32_setssbsy(); +} + +static __inline__ void __DEFAULT_FN_ATTRS _clrssbsy(void * __p) { + __builtin_ia32_clrssbsy(__p); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __CETINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cldemoteintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cldemoteintrin.h new file mode 100755 index 0000000..cfb951c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cldemoteintrin.h @@ -0,0 +1,36 @@ +/*===---- cldemoteintrin.h - CLDEMOTE intrinsic ----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __CLDEMOTEINTRIN_H +#define __CLDEMOTEINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("cldemote"))) + +/// Hint to hardware that the cache line that contains \p __P should be demoted +/// from the cache closest to the processor core to a level more distant from +/// the processor core. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CLDEMOTE instruction. +static __inline__ void __DEFAULT_FN_ATTRS +_cldemote(const void * __P) { + __builtin_ia32_cldemote(__P); +} + +#define _mm_cldemote(p) _cldemote(p) +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clflushoptintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clflushoptintrin.h new file mode 100755 index 0000000..ae0a024 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clflushoptintrin.h @@ -0,0 +1,36 @@ +/*===---- clflushoptintrin.h - CLFLUSHOPT intrinsic ------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __CLFLUSHOPTINTRIN_H +#define __CLFLUSHOPTINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("clflushopt"))) + +/// Invalidates all levels of the cache hierarchy and flushes modified data to +/// memory for the cache line specified by the address \a __m. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CLFLUSHOPT instruction. +/// +/// \param __m +/// An address within the cache line to flush and invalidate. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_clflushopt(void const * __m) { + __builtin_ia32_clflushopt(__m); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clwbintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clwbintrin.h new file mode 100755 index 0000000..3360d20 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clwbintrin.h @@ -0,0 +1,38 @@ +/*===---- clwbintrin.h - CLWB intrinsic ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __CLWBINTRIN_H +#define __CLWBINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("clwb"))) + +/// Writes back to memory the cache line (if modified) that contains the +/// linear address specified in \a __p from any level of the cache hierarchy in +/// the cache coherence domain +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CLWB instruction. +/// +/// \param __p +/// A pointer to the memory location used to identify the cache line to be +/// written back. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_clwb(void const *__p) { + __builtin_ia32_clwb(__p); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clzerointrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clzerointrin.h new file mode 100755 index 0000000..acccfe9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/clzerointrin.h @@ -0,0 +1,38 @@ +/*===----------------------- clzerointrin.h - CLZERO ----------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __CLZEROINTRIN_H +#define __CLZEROINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("clzero"))) + +/// Zeroes out the cache line for the address \a __line. This uses a +/// non-temporal store. Calling \c _mm_sfence() afterward might be needed +/// to enforce ordering. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CLZERO instruction. +/// +/// \param __line +/// An address within the cache line to zero out. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_clzero (void * __line) +{ + __builtin_ia32_clzero ((void *)__line); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __CLZEROINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cmpccxaddintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cmpccxaddintrin.h new file mode 100755 index 0000000..0076c40 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cmpccxaddintrin.h @@ -0,0 +1,70 @@ +/*===--------------- cmpccxaddintrin.h - CMPCCXADD intrinsics--------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __X86GPRINTRIN_H +#error \ + "Never use directly; include instead." +#endif // __X86GPRINTRIN_H + +#ifndef __CMPCCXADDINTRIN_H +#define __CMPCCXADDINTRIN_H +#ifdef __x86_64__ + +typedef enum { + _CMPCCX_O, /* Overflow. */ + _CMPCCX_NO, /* No overflow. */ + _CMPCCX_B, /* Below. */ + _CMPCCX_NB, /* Not below. */ + _CMPCCX_Z, /* Zero. */ + _CMPCCX_NZ, /* Not zero. */ + _CMPCCX_BE, /* Below or equal. */ + _CMPCCX_NBE, /* Neither below nor equal. */ + _CMPCCX_S, /* Sign. */ + _CMPCCX_NS, /* No sign. */ + _CMPCCX_P, /* Parity. */ + _CMPCCX_NP, /* No parity. */ + _CMPCCX_L, /* Less. */ + _CMPCCX_NL, /* Not less. */ + _CMPCCX_LE, /* Less or equal. */ + _CMPCCX_NLE, /* Neither less nor equal. */ +} _CMPCCX_ENUM; + +/// Compares the value from the memory __A with the value of __B. If the +/// specified condition __D is met, then add the third operand __C to the +/// __A and write it into __A, else the value of __A is unchanged. The return +/// value is the original value of __A. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CMPCCXADD instructions. +/// +/// \param __A +/// __A pointer specifying the memory address. +/// +/// \param __B +/// A integer operand. +/// +/// \param __C +/// A integer operand. +/// +/// \param __D +/// The specified condition. +/// +/// \returns a integer which is the original value of first operand. + +#define _cmpccxadd_epi32(__A, __B, __C, __D) \ + ((int)(__builtin_ia32_cmpccxadd32((void *)(__A), (int)(__B), (int)(__C), \ + (int)(__D)))) + +#define _cmpccxadd_epi64(__A, __B, __C, __D) \ + ((long long)(__builtin_ia32_cmpccxadd64((__A), (long long)(__B), \ + (long long)(__C), (int)(__D)))) + +#endif // __x86_64__ +#endif // __CMPCCXADDINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cpuid.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cpuid.h new file mode 100755 index 0000000..52addb7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cpuid.h @@ -0,0 +1,354 @@ +/*===---- cpuid.h - X86 cpu model detection --------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CPUID_H +#define __CPUID_H + +#if !defined(__x86_64__) && !defined(__i386__) +#error this header is for x86 only +#endif + +/* Responses identification request with %eax 0 */ +/* AMD: "AuthenticAMD" */ +#define signature_AMD_ebx 0x68747541 +#define signature_AMD_edx 0x69746e65 +#define signature_AMD_ecx 0x444d4163 +/* CENTAUR: "CentaurHauls" */ +#define signature_CENTAUR_ebx 0x746e6543 +#define signature_CENTAUR_edx 0x48727561 +#define signature_CENTAUR_ecx 0x736c7561 +/* CYRIX: "CyrixInstead" */ +#define signature_CYRIX_ebx 0x69727943 +#define signature_CYRIX_edx 0x736e4978 +#define signature_CYRIX_ecx 0x64616574 +/* HYGON: "HygonGenuine" */ +#define signature_HYGON_ebx 0x6f677948 +#define signature_HYGON_edx 0x6e65476e +#define signature_HYGON_ecx 0x656e6975 +/* INTEL: "GenuineIntel" */ +#define signature_INTEL_ebx 0x756e6547 +#define signature_INTEL_edx 0x49656e69 +#define signature_INTEL_ecx 0x6c65746e +/* TM1: "TransmetaCPU" */ +#define signature_TM1_ebx 0x6e617254 +#define signature_TM1_edx 0x74656d73 +#define signature_TM1_ecx 0x55504361 +/* TM2: "GenuineTMx86" */ +#define signature_TM2_ebx 0x756e6547 +#define signature_TM2_edx 0x54656e69 +#define signature_TM2_ecx 0x3638784d +/* NSC: "Geode by NSC" */ +#define signature_NSC_ebx 0x646f6547 +#define signature_NSC_edx 0x79622065 +#define signature_NSC_ecx 0x43534e20 +/* NEXGEN: "NexGenDriven" */ +#define signature_NEXGEN_ebx 0x4778654e +#define signature_NEXGEN_edx 0x72446e65 +#define signature_NEXGEN_ecx 0x6e657669 +/* RISE: "RiseRiseRise" */ +#define signature_RISE_ebx 0x65736952 +#define signature_RISE_edx 0x65736952 +#define signature_RISE_ecx 0x65736952 +/* SIS: "SiS SiS SiS " */ +#define signature_SIS_ebx 0x20536953 +#define signature_SIS_edx 0x20536953 +#define signature_SIS_ecx 0x20536953 +/* UMC: "UMC UMC UMC " */ +#define signature_UMC_ebx 0x20434d55 +#define signature_UMC_edx 0x20434d55 +#define signature_UMC_ecx 0x20434d55 +/* VIA: "VIA VIA VIA " */ +#define signature_VIA_ebx 0x20414956 +#define signature_VIA_edx 0x20414956 +#define signature_VIA_ecx 0x20414956 +/* VORTEX: "Vortex86 SoC" */ +#define signature_VORTEX_ebx 0x74726f56 +#define signature_VORTEX_edx 0x36387865 +#define signature_VORTEX_ecx 0x436f5320 + +/* Features in %ecx for leaf 1 */ +#define bit_SSE3 0x00000001 +#define bit_PCLMULQDQ 0x00000002 +#define bit_PCLMUL bit_PCLMULQDQ /* for gcc compat */ +#define bit_DTES64 0x00000004 +#define bit_MONITOR 0x00000008 +#define bit_DSCPL 0x00000010 +#define bit_VMX 0x00000020 +#define bit_SMX 0x00000040 +#define bit_EIST 0x00000080 +#define bit_TM2 0x00000100 +#define bit_SSSE3 0x00000200 +#define bit_CNXTID 0x00000400 +#define bit_FMA 0x00001000 +#define bit_CMPXCHG16B 0x00002000 +#define bit_xTPR 0x00004000 +#define bit_PDCM 0x00008000 +#define bit_PCID 0x00020000 +#define bit_DCA 0x00040000 +#define bit_SSE41 0x00080000 +#define bit_SSE4_1 bit_SSE41 /* for gcc compat */ +#define bit_SSE42 0x00100000 +#define bit_SSE4_2 bit_SSE42 /* for gcc compat */ +#define bit_x2APIC 0x00200000 +#define bit_MOVBE 0x00400000 +#define bit_POPCNT 0x00800000 +#define bit_TSCDeadline 0x01000000 +#define bit_AESNI 0x02000000 +#define bit_AES bit_AESNI /* for gcc compat */ +#define bit_XSAVE 0x04000000 +#define bit_OSXSAVE 0x08000000 +#define bit_AVX 0x10000000 +#define bit_F16C 0x20000000 +#define bit_RDRND 0x40000000 + +/* Features in %edx for leaf 1 */ +#define bit_FPU 0x00000001 +#define bit_VME 0x00000002 +#define bit_DE 0x00000004 +#define bit_PSE 0x00000008 +#define bit_TSC 0x00000010 +#define bit_MSR 0x00000020 +#define bit_PAE 0x00000040 +#define bit_MCE 0x00000080 +#define bit_CX8 0x00000100 +#define bit_CMPXCHG8B bit_CX8 /* for gcc compat */ +#define bit_APIC 0x00000200 +#define bit_SEP 0x00000800 +#define bit_MTRR 0x00001000 +#define bit_PGE 0x00002000 +#define bit_MCA 0x00004000 +#define bit_CMOV 0x00008000 +#define bit_PAT 0x00010000 +#define bit_PSE36 0x00020000 +#define bit_PSN 0x00040000 +#define bit_CLFSH 0x00080000 +#define bit_DS 0x00200000 +#define bit_ACPI 0x00400000 +#define bit_MMX 0x00800000 +#define bit_FXSR 0x01000000 +#define bit_FXSAVE bit_FXSR /* for gcc compat */ +#define bit_SSE 0x02000000 +#define bit_SSE2 0x04000000 +#define bit_SS 0x08000000 +#define bit_HTT 0x10000000 +#define bit_TM 0x20000000 +#define bit_PBE 0x80000000 + +/* Features in %ebx for leaf 7 sub-leaf 0 */ +#define bit_FSGSBASE 0x00000001 +#define bit_SGX 0x00000004 +#define bit_BMI 0x00000008 +#define bit_HLE 0x00000010 +#define bit_AVX2 0x00000020 +#define bit_SMEP 0x00000080 +#define bit_BMI2 0x00000100 +#define bit_ENH_MOVSB 0x00000200 +#define bit_INVPCID 0x00000400 +#define bit_RTM 0x00000800 +#define bit_MPX 0x00004000 +#define bit_AVX512F 0x00010000 +#define bit_AVX512DQ 0x00020000 +#define bit_RDSEED 0x00040000 +#define bit_ADX 0x00080000 +#define bit_AVX512IFMA 0x00200000 +#define bit_CLFLUSHOPT 0x00800000 +#define bit_CLWB 0x01000000 +#define bit_AVX512PF 0x04000000 +#define bit_AVX512ER 0x08000000 +#define bit_AVX512CD 0x10000000 +#define bit_SHA 0x20000000 +#define bit_AVX512BW 0x40000000 +#define bit_AVX512VL 0x80000000 + +/* Features in %ecx for leaf 7 sub-leaf 0 */ +#define bit_PREFTCHWT1 0x00000001 +#define bit_AVX512VBMI 0x00000002 +#define bit_PKU 0x00000004 +#define bit_OSPKE 0x00000010 +#define bit_WAITPKG 0x00000020 +#define bit_AVX512VBMI2 0x00000040 +#define bit_SHSTK 0x00000080 +#define bit_GFNI 0x00000100 +#define bit_VAES 0x00000200 +#define bit_VPCLMULQDQ 0x00000400 +#define bit_AVX512VNNI 0x00000800 +#define bit_AVX512BITALG 0x00001000 +#define bit_AVX512VPOPCNTDQ 0x00004000 +#define bit_RDPID 0x00400000 +#define bit_CLDEMOTE 0x02000000 +#define bit_MOVDIRI 0x08000000 +#define bit_MOVDIR64B 0x10000000 +#define bit_ENQCMD 0x20000000 + +/* Features in %edx for leaf 7 sub-leaf 0 */ +#define bit_AVX5124VNNIW 0x00000004 +#define bit_AVX5124FMAPS 0x00000008 +#define bit_UINTR 0x00000020 +#define bit_AVX512VP2INTERSECT 0x00000100 +#define bit_SERIALIZE 0x00004000 +#define bit_TSXLDTRK 0x00010000 +#define bit_PCONFIG 0x00040000 +#define bit_IBT 0x00100000 +#define bit_AMXBF16 0x00400000 +#define bit_AVX512FP16 0x00800000 +#define bit_AMXTILE 0x01000000 +#define bit_AMXINT8 0x02000000 + +/* Features in %eax for leaf 7 sub-leaf 1 */ +#define bit_SHA512 0x00000001 +#define bit_SM3 0x00000002 +#define bit_SM4 0x00000004 +#define bit_RAOINT 0x00000008 +#define bit_AVXVNNI 0x00000010 +#define bit_AVX512BF16 0x00000020 +#define bit_CMPCCXADD 0x00000080 +#define bit_AMXFP16 0x00200000 +#define bit_HRESET 0x00400000 +#define bit_AVXIFMA 0x00800000 + +/* Features in %edx for leaf 7 sub-leaf 1 */ +#define bit_AVXVNNIINT8 0x00000010 +#define bit_AVXNECONVERT 0x00000020 +#define bit_AMXCOMPLEX 0x00000100 +#define bit_AVXVNNIINT16 0x00000400 +#define bit_PREFETCHI 0x00004000 +#define bit_USERMSR 0x00008000 +#define bit_AVX10 0x00080000 +#define bit_APXF 0x00200000 + +/* Features in %eax for leaf 13 sub-leaf 1 */ +#define bit_XSAVEOPT 0x00000001 +#define bit_XSAVEC 0x00000002 +#define bit_XSAVES 0x00000008 + +/* Features in %eax for leaf 0x14 sub-leaf 0 */ +#define bit_PTWRITE 0x00000010 + +/* Features in %ecx for leaf 0x80000001 */ +#define bit_LAHF_LM 0x00000001 +#define bit_ABM 0x00000020 +#define bit_LZCNT bit_ABM /* for gcc compat */ +#define bit_SSE4a 0x00000040 +#define bit_PRFCHW 0x00000100 +#define bit_XOP 0x00000800 +#define bit_LWP 0x00008000 +#define bit_FMA4 0x00010000 +#define bit_TBM 0x00200000 +#define bit_MWAITX 0x20000000 + +/* Features in %edx for leaf 0x80000001 */ +#define bit_MMXEXT 0x00400000 +#define bit_LM 0x20000000 +#define bit_3DNOWP 0x40000000 +#define bit_3DNOW 0x80000000 + +/* Features in %ebx for leaf 0x80000008 */ +#define bit_CLZERO 0x00000001 +#define bit_RDPRU 0x00000010 +#define bit_WBNOINVD 0x00000200 + +/* Features in %ebx for leaf 0x24 */ +#define bit_AVX10_256 0x00020000 +#define bit_AVX10_512 0x00040000 + +#ifdef __i386__ +#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ + __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \ + : "0"(__leaf)) + +#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ + __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \ + : "0"(__leaf), "2"(__count)) +#else +/* x86-64 uses %rbx as the base register, so preserve it. */ +#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ + " cpuid\n" \ + " xchg{q|} {%%|}rbx,%q1" \ + : "=a"(__eax), "=r"(__ebx), "=c"(__ecx), "=d"(__edx) \ + : "0"(__leaf)) + +#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ + __asm(" xchg{q|} {%%|}rbx,%q1\n" \ + " cpuid\n" \ + " xchg{q|} {%%|}rbx,%q1" \ + : "=a"(__eax), "=r"(__ebx), "=c"(__ecx), "=d"(__edx) \ + : "0"(__leaf), "2"(__count)) +#endif + +static __inline unsigned int __get_cpuid_max (unsigned int __leaf, + unsigned int *__sig) +{ + unsigned int __eax, __ebx, __ecx, __edx; +#ifdef __i386__ + int __cpuid_supported; + + __asm(" pushf{l|d}\n" + " pop{l|} {%%|}eax\n" + " mov{l|} {%%eax,%%ecx|ecx,eax}\n" + " xor{l|} {$0x00200000,%%eax|eax,0x00200000}\n" + " push{l|} {%%|}eax\n" + " popf{l|d}\n" + " pushf{l|d}\n" + " pop{l|} {%%|}eax\n" + " mov{l|} {$0,%0|%0,0}\n" + " cmp{l|} {%%eax,%%ecx|ecx,eax}\n" + " je 1f\n" + " mov{l|} {$1,%0|%0,1}\n" + "1:" + : "=r"(__cpuid_supported) + : + : "eax", "ecx"); + if (!__cpuid_supported) + return 0; +#endif + + __cpuid(__leaf, __eax, __ebx, __ecx, __edx); + if (__sig) + *__sig = __ebx; + return __eax; +} + +static __inline int __get_cpuid (unsigned int __leaf, unsigned int *__eax, + unsigned int *__ebx, unsigned int *__ecx, + unsigned int *__edx) +{ + unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x80000000, 0); + + if (__max_leaf == 0 || __max_leaf < __leaf) + return 0; + + __cpuid(__leaf, *__eax, *__ebx, *__ecx, *__edx); + return 1; +} + +static __inline int __get_cpuid_count (unsigned int __leaf, + unsigned int __subleaf, + unsigned int *__eax, unsigned int *__ebx, + unsigned int *__ecx, unsigned int *__edx) +{ + unsigned int __max_leaf = __get_cpuid_max(__leaf & 0x80000000, 0); + + if (__max_leaf == 0 || __max_leaf < __leaf) + return 0; + + __cpuid_count(__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx); + return 1; +} + +// In some configurations, __cpuidex is defined as a builtin (primarily +// -fms-extensions) which will conflict with the __cpuidex definition below. +#if !(__has_builtin(__cpuidex)) +static __inline void __cpuidex(int __cpu_info[4], int __leaf, int __subleaf) { + __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2], + __cpu_info[3]); +} +#endif + +#endif /* __CPUID_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/crc32intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/crc32intrin.h new file mode 100755 index 0000000..a0bd99d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/crc32intrin.h @@ -0,0 +1,100 @@ +/*===---- crc32intrin.h - SSE4.2 Accumulate CRC32 intrinsics ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CRC32INTRIN_H +#define __CRC32INTRIN_H + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("crc32"))) + +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// unsigned char operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CRC32B instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 8-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mm_crc32_u8(unsigned int __C, unsigned char __D) +{ + return __builtin_ia32_crc32qi(__C, __D); +} + +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// unsigned short operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CRC32W instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 16-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mm_crc32_u16(unsigned int __C, unsigned short __D) +{ + return __builtin_ia32_crc32hi(__C, __D); +} + +/// Adds the first unsigned integer operand to the CRC-32C checksum of +/// the second unsigned integer operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CRC32L instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 32-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mm_crc32_u32(unsigned int __C, unsigned int __D) +{ + return __builtin_ia32_crc32si(__C, __D); +} + +#ifdef __x86_64__ +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// unsigned 64-bit integer operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CRC32Q instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 64-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_mm_crc32_u64(unsigned long long __C, unsigned long long __D) +{ + return __builtin_ia32_crc32di(__C, __D); +} +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __CRC32INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/algorithm b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/algorithm new file mode 100755 index 0000000..3f59f28 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/algorithm @@ -0,0 +1,116 @@ +/*===---- algorithm - CUDA wrapper for -------------------------=== + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_WRAPPERS_ALGORITHM +#define __CLANG_CUDA_WRAPPERS_ALGORITHM + +// This header defines __device__ overloads of std::min/max. +// +// Ideally we'd declare these functions only if we're <= C++11. In C++14, +// these functions are constexpr, and so are implicitly __host__ __device__. +// +// However, the compiler being in C++14 mode does not imply that the standard +// library supports C++14. There is no macro we can test to check that the +// stdlib has constexpr std::min/max. Thus we have to unconditionally define +// our device overloads. +// +// A host+device function cannot be overloaded, and a constexpr function +// implicitly become host device if there's no explicitly host or device +// overload preceding it. So the simple thing to do would be to declare our +// device min/max overloads, and then #include_next . This way our +// device overloads would come first, and so if we have a C++14 stdlib, its +// min/max won't become host+device and conflict with our device overloads. +// +// But that also doesn't work. libstdc++ is evil and declares std::min/max in +// an internal header that is included *before* . Thus by the time +// we're inside of this file, std::min/max may already have been declared, and +// thus we can't prevent them from becoming host+device if they're constexpr. +// +// Therefore we perpetrate the following hack: We mark our __device__ overloads +// with __attribute__((enable_if(true, ""))). This causes the signature of the +// function to change without changing anything else about it. (Except that +// overload resolution will prefer it over the __host__ __device__ version +// rather than considering them equally good). + +#include_next + +// We need to define these overloads in exactly the namespace our standard +// library uses (including the right inline namespace), otherwise they won't be +// picked up by other functions in the standard library (e.g. functions in +// ). Thus the ugliness below. +#ifdef _LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_BEGIN_NAMESPACE_STD +#else +namespace std { +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#endif +#endif + +#pragma push_macro("_CPP14_CONSTEXPR") +#if __cplusplus >= 201402L +#define _CPP14_CONSTEXPR constexpr +#else +#define _CPP14_CONSTEXPR +#endif + +template +__attribute__((enable_if(true, ""))) +inline _CPP14_CONSTEXPR __host__ __device__ const __T & +max(const __T &__a, const __T &__b, __Cmp __cmp) { + return __cmp(__a, __b) ? __b : __a; +} + +template +__attribute__((enable_if(true, ""))) +inline _CPP14_CONSTEXPR __host__ __device__ const __T & +max(const __T &__a, const __T &__b) { + return __a < __b ? __b : __a; +} + +template +__attribute__((enable_if(true, ""))) +inline _CPP14_CONSTEXPR __host__ __device__ const __T & +min(const __T &__a, const __T &__b, __Cmp __cmp) { + return __cmp(__b, __a) ? __b : __a; +} + +template +__attribute__((enable_if(true, ""))) +inline _CPP14_CONSTEXPR __host__ __device__ const __T & +min(const __T &__a, const __T &__b) { + return __b < __a ? __b : __a; +} + +#pragma pop_macro("_CPP14_CONSTEXPR") + +#ifdef _LIBCPP_END_NAMESPACE_STD +_LIBCPP_END_NAMESPACE_STD +#else +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +#endif +} // namespace std +#endif + +#endif // __CLANG_CUDA_WRAPPERS_ALGORITHM diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/basic_string.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/basic_string.h new file mode 100755 index 0000000..64f50d9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/basic_string.h @@ -0,0 +1,9 @@ +// CUDA headers define __noinline__ which interferes with libstdc++'s use of +// `__attribute((__noinline__))`. In order to avoid compilation error, +// temporarily unset __noinline__ when we include affected libstdc++ header. + +#pragma push_macro("__noinline__") +#undef __noinline__ +#include_next "bits/basic_string.h" + +#pragma pop_macro("__noinline__") diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/basic_string.tcc b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/basic_string.tcc new file mode 100755 index 0000000..90c7fe3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/basic_string.tcc @@ -0,0 +1,9 @@ +// CUDA headers define __noinline__ which interferes with libstdc++'s use of +// `__attribute((__noinline__))`. In order to avoid compilation error, +// temporarily unset __noinline__ when we include affected libstdc++ header. + +#pragma push_macro("__noinline__") +#undef __noinline__ +#include_next "bits/basic_string.tcc" + +#pragma pop_macro("__noinline__") diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/c++config.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/c++config.h new file mode 100755 index 0000000..2708325 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/c++config.h @@ -0,0 +1,61 @@ +// libstdc++ uses the non-constexpr function std::__glibcxx_assert_fail() +// to trigger compilation errors when the __glibcxx_assert(cond) macro +// is used in a constexpr context. +// Compilation fails when using code from the libstdc++ (such as std::array) on +// device code, since these assertions invoke a non-constexpr host function from +// device code. +// +// To work around this issue, we declare our own device version of the function + +#ifndef __CLANG_CUDA_WRAPPERS_BITS_CPP_CONFIG +#define __CLANG_CUDA_WRAPPERS_BITS_CPP_CONFIG + +#include_next + +#ifdef _LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_BEGIN_NAMESPACE_STD +#else +namespace std { +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#endif + +#pragma push_macro("CUDA_NOEXCEPT") +#if __cplusplus >= 201103L +#define CUDA_NOEXCEPT noexcept +#else +#define CUDA_NOEXCEPT +#endif + +__attribute__((device, noreturn)) inline void +__glibcxx_assert_fail(const char *file, int line, const char *function, + const char *condition) CUDA_NOEXCEPT { +#ifdef _GLIBCXX_VERBOSE_ASSERT + if (file && function && condition) + __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", file, line, + function, condition); + else if (function) + __builtin_printf("%s: Undefined behavior detected.\n", function); +#endif + __builtin_abort(); +} + +#endif +__attribute__((device, noreturn, __always_inline__, + __visibility__("default"))) inline void +__glibcxx_assert_fail() CUDA_NOEXCEPT { + __builtin_abort(); +} + +#pragma pop_macro("CUDA_NOEXCEPT") + +#ifdef _LIBCPP_END_NAMESPACE_STD +_LIBCPP_END_NAMESPACE_STD +#else +#ifdef _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +#endif +} // namespace std +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/shared_ptr_base.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/shared_ptr_base.h new file mode 100755 index 0000000..10028dd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/bits/shared_ptr_base.h @@ -0,0 +1,9 @@ +// CUDA headers define __noinline__ which interferes with libstdc++'s use of +// `__attribute((__noinline__))`. In order to avoid compilation error, +// temporarily unset __noinline__ when we include affected libstdc++ header. + +#pragma push_macro("__noinline__") +#undef __noinline__ +#include_next "bits/shared_ptr_base.h" + +#pragma pop_macro("__noinline__") diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/cmath b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/cmath new file mode 100755 index 0000000..8e9ee34 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/cmath @@ -0,0 +1,44 @@ +/*===---- cmath - CUDA wrapper for ---------------------------------=== + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_WRAPPERS_CMATH +#define __CLANG_CUDA_WRAPPERS_CMATH + +#if __has_include_next() +#include_next +#else +#error "Could not find standard C++ header 'cmath'. Add -v to your compilation command to check the include paths being searched. You may need to install the appropriate standard C++ library package corresponding to the search path." +#endif + +#if defined(_LIBCPP_STD_VER) + +// libc++ will need long double variants of these functions, but CUDA does not +// provide them. We'll provide their declarations, which should allow the +// headers to parse, but would not allow accidental use of them on a GPU. + +__attribute__((device)) long double logb(long double); +__attribute__((device)) long double scalbn(long double, int); + +#endif // _LIBCPP_STD_VER + +#endif // include guard diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/complex b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/complex new file mode 100755 index 0000000..e6805b6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/complex @@ -0,0 +1,90 @@ +/*===---- complex - CUDA wrapper for ------------------------------=== + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_WRAPPERS_COMPLEX +#define __CLANG_CUDA_WRAPPERS_COMPLEX + +// Wrapper around that forces its functions to be __host__ +// __device__. + +// First, include host-only headers we think are likely to be included by +// , so that the pragma below only applies to itself. +#if __cplusplus >= 201103L +#include +#endif +#include +#include +#include + +// Next, include our wrapper, to ensure that device overloads of +// std::min/max are available. +#include + +#pragma clang force_cuda_host_device begin + +// When compiling for device, ask libstdc++ to use its own implements of +// complex functions, rather than calling builtins (which resolve to library +// functions that don't exist when compiling CUDA device code). +// +// This is a little dicey, because it causes libstdc++ to define a different +// set of overloads on host and device. +// +// // Present only when compiling for host. +// __host__ __device__ void complex sin(const complex& x) { +// return __builtin_csinf(x); +// } +// +// // Present when compiling for host and for device. +// template +// void __host__ __device__ complex sin(const complex& x) { +// return complex(sin(x.real()) * cosh(x.imag()), +// cos(x.real()), sinh(x.imag())); +// } +// +// This is safe because when compiling for device, all function calls in +// __host__ code to sin() will still resolve to *something*, even if they don't +// resolve to the same function as they resolve to when compiling for host. We +// don't care that they don't resolve to the right function because we won't +// codegen this host code when compiling for device. + +#pragma push_macro("_GLIBCXX_USE_C99_COMPLEX") +#pragma push_macro("_GLIBCXX_USE_C99_COMPLEX_TR1") +#define _GLIBCXX_USE_C99_COMPLEX 0 +#define _GLIBCXX_USE_C99_COMPLEX_TR1 0 + +// Work around a compatibility issue with libstdc++ 11.1.0 +// https://bugs.llvm.org/show_bug.cgi?id=50383 +#pragma push_macro("__failed_assertion") +#if _GLIBCXX_RELEASE == 11 +#define __failed_assertion __cuda_failed_assertion +#endif + +#include_next + +#pragma pop_macro("__failed_assertion") +#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX_TR1") +#pragma pop_macro("_GLIBCXX_USE_C99_COMPLEX") + +#pragma clang force_cuda_host_device end + +#endif // include guard diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/new b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/new new file mode 100755 index 0000000..9d3e316 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/cuda_wrappers/new @@ -0,0 +1,108 @@ +/*===---- new - CUDA wrapper for -------------------------------------=== + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_CUDA_WRAPPERS_NEW +#define __CLANG_CUDA_WRAPPERS_NEW + +#include_next + +#if !defined(__device__) +// The header has been included too early from the standard C++ library +// and CUDA-specific macros are not available yet. +// Undo the include guard and try again later. +#undef __CLANG_CUDA_WRAPPERS_NEW +#else + +#pragma push_macro("CUDA_NOEXCEPT") +#if __cplusplus >= 201103L +#define CUDA_NOEXCEPT noexcept +#else +#define CUDA_NOEXCEPT +#endif + +// Device overrides for non-placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) { + size = 1; + } + return ::malloc(size); +} +__device__ inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) CUDA_NOEXCEPT { + return ::operator new(size); +} + +__device__ inline void *operator new[](__SIZE_TYPE__ size) { + return ::operator new(size); +} +__device__ inline void *operator new[](__SIZE_TYPE__ size, + const std::nothrow_t &) { + return ::operator new(size); +} + +__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT { + if (ptr) { + ::free(ptr); + } +} +__device__ inline void operator delete(void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +__device__ inline void operator delete(void *ptr, + __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +// Device overrides for placement new and delete. +#if !(_LIBCPP_STD_VER >= 26 || __cpp_lib_constexpr_new >= 202406L) +__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { + return __ptr; +} +__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { + return __ptr; +} +#endif +__device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {} +__device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {} + +#pragma pop_macro("CUDA_NOEXCEPT") + +#endif // __device__ +#endif // include guard diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/emmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/emmintrin.h new file mode 100755 index 0000000..78e8a42 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/emmintrin.h @@ -0,0 +1,4940 @@ +/*===---- emmintrin.h - SSE2 intrinsics ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __EMMINTRIN_H +#define __EMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +typedef double __m128d __attribute__((__vector_size__(16), __aligned__(16))); +typedef long long __m128i __attribute__((__vector_size__(16), __aligned__(16))); + +typedef double __m128d_u __attribute__((__vector_size__(16), __aligned__(1))); +typedef long long __m128i_u + __attribute__((__vector_size__(16), __aligned__(1))); + +/* Type defines. */ +typedef double __v2df __attribute__((__vector_size__(16))); +typedef long long __v2di __attribute__((__vector_size__(16))); +typedef short __v8hi __attribute__((__vector_size__(16))); +typedef char __v16qi __attribute__((__vector_size__(16))); + +/* Unsigned types */ +typedef unsigned long long __v2du __attribute__((__vector_size__(16))); +typedef unsigned short __v8hu __attribute__((__vector_size__(16))); +typedef unsigned char __v16qu __attribute__((__vector_size__(16))); + +/* We need an explicitly signed variant for char. Note that this shouldn't + * appear in the interface though. */ +typedef signed char __v16qs __attribute__((__vector_size__(16))); + +#ifdef __SSE2__ +/* Both _Float16 and __bf16 require SSE2 being enabled. */ +typedef _Float16 __v8hf __attribute__((__vector_size__(16), __aligned__(16))); +typedef _Float16 __m128h __attribute__((__vector_size__(16), __aligned__(16))); +typedef _Float16 __m128h_u __attribute__((__vector_size__(16), __aligned__(1))); + +typedef __bf16 __v8bf __attribute__((__vector_size__(16), __aligned__(16))); +typedef __bf16 __m128bh __attribute__((__vector_size__(16), __aligned__(16))); +#endif + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("sse2,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sse2"), \ + __min_vector_width__(128))) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#else +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS +#endif + +#define __trunc64(x) \ + (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0) +#define __anyext128(x) \ + (__m128i) __builtin_shufflevector((__v2si)(x), __extension__(__v2si){}, 0, \ + 1, -1, -1) + +/// Adds lower double-precision values in both operands and returns the +/// sum in the lower 64 bits of the result. The upper 64 bits of the result +/// are copied from the upper double-precision value of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDSD / ADDSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// sum of the lower 64 bits of both operands. The upper 64 bits are copied +/// from the upper 64 bits of the first source operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_add_sd(__m128d __a, + __m128d __b) { + __a[0] += __b[0]; + return __a; +} + +/// Adds two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDPD / ADDPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \returns A 128-bit vector of [2 x double] containing the sums of both +/// operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_add_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2df)__a + (__v2df)__b); +} + +/// Subtracts the lower double-precision value of the second operand +/// from the lower double-precision value of the first operand and returns +/// the difference in the lower 64 bits of the result. The upper 64 bits of +/// the result are copied from the upper double-precision value of the first +/// operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSUBSD / SUBSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the minuend. +/// \param __b +/// A 128-bit vector of [2 x double] containing the subtrahend. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// difference of the lower 64 bits of both operands. The upper 64 bits are +/// copied from the upper 64 bits of the first source operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_sub_sd(__m128d __a, + __m128d __b) { + __a[0] -= __b[0]; + return __a; +} + +/// Subtracts two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSUBPD / SUBPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the minuend. +/// \param __b +/// A 128-bit vector of [2 x double] containing the subtrahend. +/// \returns A 128-bit vector of [2 x double] containing the differences between +/// both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_sub_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2df)__a - (__v2df)__b); +} + +/// Multiplies lower double-precision values in both operands and returns +/// the product in the lower 64 bits of the result. The upper 64 bits of the +/// result are copied from the upper double-precision value of the first +/// operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMULSD / MULSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// product of the lower 64 bits of both operands. The upper 64 bits are +/// copied from the upper 64 bits of the first source operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_mul_sd(__m128d __a, + __m128d __b) { + __a[0] *= __b[0]; + return __a; +} + +/// Multiplies two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMULPD / MULPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the operands. +/// \returns A 128-bit vector of [2 x double] containing the products of both +/// operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_mul_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2df)__a * (__v2df)__b); +} + +/// Divides the lower double-precision value of the first operand by the +/// lower double-precision value of the second operand and returns the +/// quotient in the lower 64 bits of the result. The upper 64 bits of the +/// result are copied from the upper double-precision value of the first +/// operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDIVSD / DIVSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the dividend. +/// \param __b +/// A 128-bit vector of [2 x double] containing divisor. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// quotient of the lower 64 bits of both operands. The upper 64 bits are +/// copied from the upper 64 bits of the first source operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_div_sd(__m128d __a, + __m128d __b) { + __a[0] /= __b[0]; + return __a; +} + +/// Performs an element-by-element division of two 128-bit vectors of +/// [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDIVPD / DIVPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the dividend. +/// \param __b +/// A 128-bit vector of [2 x double] containing the divisor. +/// \returns A 128-bit vector of [2 x double] containing the quotients of both +/// operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_div_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2df)__a / (__v2df)__b); +} + +/// Calculates the square root of the lower double-precision value of +/// the second operand and returns it in the lower 64 bits of the result. +/// The upper 64 bits of the result are copied from the upper +/// double-precision value of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSQRTSD / SQRTSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the operands. The +/// upper 64 bits of this operand are copied to the upper 64 bits of the +/// result. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the operands. The +/// square root is calculated using the lower 64 bits of this operand. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// square root of the lower 64 bits of operand \a __b, and whose upper 64 +/// bits are copied from the upper 64 bits of operand \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_sqrt_sd(__m128d __a, + __m128d __b) { + __m128d __c = __builtin_ia32_sqrtsd((__v2df)__b); + return __extension__(__m128d){__c[0], __a[1]}; +} + +/// Calculates the square root of the each of two values stored in a +/// 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSQRTPD / SQRTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector of [2 x double] containing the square roots of the +/// values in the operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_sqrt_pd(__m128d __a) { + return __builtin_ia32_sqrtpd((__v2df)__a); +} + +/// Compares lower 64-bit double-precision values of both operands, and +/// returns the lesser of the pair of values in the lower 64-bits of the +/// result. The upper 64 bits of the result are copied from the upper +/// double-precision value of the first operand. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMINSD / MINSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the operands. The +/// lower 64 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the operands. The +/// lower 64 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// minimum value between both operands. The upper 64 bits are copied from +/// the upper 64 bits of the first source operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_min_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_minsd((__v2df)__a, (__v2df)__b); +} + +/// Performs element-by-element comparison of the two 128-bit vectors of +/// [2 x double] and returns a vector containing the lesser of each pair of +/// values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMINPD / MINPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the operands. +/// \returns A 128-bit vector of [2 x double] containing the minimum values +/// between both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_min_pd(__m128d __a, + __m128d __b) { + return __builtin_ia32_minpd((__v2df)__a, (__v2df)__b); +} + +/// Compares lower 64-bit double-precision values of both operands, and +/// returns the greater of the pair of values in the lower 64-bits of the +/// result. The upper 64 bits of the result are copied from the upper +/// double-precision value of the first operand. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMAXSD / MAXSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the operands. The +/// lower 64 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the operands. The +/// lower 64 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// maximum value between both operands. The upper 64 bits are copied from +/// the upper 64 bits of the first source operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_max_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_maxsd((__v2df)__a, (__v2df)__b); +} + +/// Performs element-by-element comparison of the two 128-bit vectors of +/// [2 x double] and returns a vector containing the greater of each pair +/// of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMAXPD / MAXPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the operands. +/// \returns A 128-bit vector of [2 x double] containing the maximum values +/// between both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_max_pd(__m128d __a, + __m128d __b) { + return __builtin_ia32_maxpd((__v2df)__a, (__v2df)__b); +} + +/// Performs a bitwise AND of two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPAND / PAND instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the +/// values between both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_and_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2du)__a & (__v2du)__b); +} + +/// Performs a bitwise AND of two 128-bit vectors of [2 x double], using +/// the one's complement of the values contained in the first source operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPANDN / PANDN instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the left source operand. The +/// one's complement of this value is used in the bitwise AND. +/// \param __b +/// A 128-bit vector of [2 x double] containing the right source operand. +/// \returns A 128-bit vector of [2 x double] containing the bitwise AND of the +/// values in the second operand and the one's complement of the first +/// operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_andnot_pd(__m128d __a, __m128d __b) { + return (__m128d)(~(__v2du)__a & (__v2du)__b); +} + +/// Performs a bitwise OR of two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPOR / POR instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \returns A 128-bit vector of [2 x double] containing the bitwise OR of the +/// values between both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_or_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2du)__a | (__v2du)__b); +} + +/// Performs a bitwise XOR of two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPXOR / PXOR instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// \returns A 128-bit vector of [2 x double] containing the bitwise XOR of the +/// values between both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_xor_pd(__m128d __a, + __m128d __b) { + return (__m128d)((__v2du)__a ^ (__v2du)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] for equality. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPEQPD / CMPEQPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpeq_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpeqpd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are less than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTPD / CMPLTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmplt_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpltpd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are less than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLEPD / CMPLEPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmple_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmplepd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTPD / CMPLTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpgt_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpltpd((__v2df)__b, (__v2df)__a); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are greater than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLEPD / CMPLEPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpge_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmplepd((__v2df)__b, (__v2df)__a); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are ordered with respect to those in the second operand. +/// +/// A pair of double-precision values are ordered with respect to each +/// other if neither value is a NaN. Each comparison returns 0x0 for false, +/// 0xFFFFFFFFFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPORDPD / CMPORDPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpord_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpordpd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are unordered with respect to those in the second operand. +/// +/// A pair of double-precision values are unordered with respect to each +/// other if one or both values are NaN. Each comparison returns 0x0 for +/// false, 0xFFFFFFFFFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPUNORDPD / CMPUNORDPD +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpunord_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpunordpd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are unequal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNEQPD / CMPNEQPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpneq_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpneqpd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are not less than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTPD / CMPNLTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnlt_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are not less than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLEPD / CMPNLEPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnle_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__a, (__v2df)__b); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are not greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTPD / CMPNLTPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpngt_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpnltpd((__v2df)__b, (__v2df)__a); +} + +/// Compares each of the corresponding double-precision values of the +/// 128-bit vectors of [2 x double] to determine if the values in the first +/// operand are not greater than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLEPD / CMPNLEPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \param __b +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector containing the comparison results. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnge_pd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpnlepd((__v2df)__b, (__v2df)__a); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] for equality. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPEQSD / CMPEQSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpeq_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpeqsd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is less than the corresponding value in +/// the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTSD / CMPLTSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmplt_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpltsd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is less than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLESD / CMPLESD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmple_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmplesd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is greater than the corresponding value +/// in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTSD / CMPLTSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpgt_sd(__m128d __a, + __m128d __b) { + __m128d __c = __builtin_ia32_cmpltsd((__v2df)__b, (__v2df)__a); + return __extension__(__m128d){__c[0], __a[1]}; +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is greater than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLESD / CMPLESD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpge_sd(__m128d __a, + __m128d __b) { + __m128d __c = __builtin_ia32_cmplesd((__v2df)__b, (__v2df)__a); + return __extension__(__m128d){__c[0], __a[1]}; +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is ordered with respect to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. A pair +/// of double-precision values are ordered with respect to each other if +/// neither value is a NaN. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPORDSD / CMPORDSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpord_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpordsd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is unordered with respect to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. A pair +/// of double-precision values are unordered with respect to each other if +/// one or both values are NaN. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPUNORDSD / CMPUNORDSD +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpunord_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpunordsd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is unequal to the corresponding value in +/// the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNEQSD / CMPNEQSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpneq_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpneqsd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is not less than the corresponding +/// value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTSD / CMPNLTSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnlt_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpnltsd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is not less than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLESD / CMPNLESD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnle_sd(__m128d __a, + __m128d __b) { + return (__m128d)__builtin_ia32_cmpnlesd((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is not greater than the corresponding +/// value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTSD / CMPNLTSD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpngt_sd(__m128d __a, + __m128d __b) { + __m128d __c = __builtin_ia32_cmpnltsd((__v2df)__b, (__v2df)__a); + return __extension__(__m128d){__c[0], __a[1]}; +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is not greater than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLESD / CMPNLESD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns A 128-bit vector. The lower 64 bits contains the comparison +/// results. The upper 64 bits are copied from the upper 64 bits of \a __a. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_cmpnge_sd(__m128d __a, + __m128d __b) { + __m128d __c = __builtin_ia32_cmpnlesd((__v2df)__b, (__v2df)__a); + return __extension__(__m128d){__c[0], __a[1]}; +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] for equality. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISD / COMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_comieq_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_comisdeq((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is less than the corresponding value in +/// the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISD / COMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_comilt_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_comisdlt((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is less than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISD / COMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_comile_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_comisdle((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is greater than the corresponding value +/// in the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISD / COMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_comigt_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_comisdgt((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is greater than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISD / COMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_comige_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_comisdge((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is unequal to the corresponding value in +/// the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISD / COMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_comineq_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_comisdneq((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] for equality. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISD / UCOMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomieq_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_ucomisdeq((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is less than the corresponding value in +/// the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISD / UCOMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomilt_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_ucomisdlt((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is less than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISD / UCOMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomile_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_ucomisdle((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is greater than the corresponding value +/// in the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISD / UCOMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomigt_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_ucomisdgt((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is greater than or equal to the +/// corresponding value in the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISD / UCOMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomige_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_ucomisdge((__v2df)__a, (__v2df)__b); +} + +/// Compares the lower double-precision floating-point values in each of +/// the two 128-bit floating-point vectors of [2 x double] to determine if +/// the value in the first parameter is unequal to the corresponding value in +/// the second parameter. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISD / UCOMISD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __b. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision value is +/// compared to the lower double-precision value of \a __a. +/// \returns An integer containing the comparison result. +static __inline__ int __DEFAULT_FN_ATTRS _mm_ucomineq_sd(__m128d __a, + __m128d __b) { + return __builtin_ia32_ucomisdneq((__v2df)__a, (__v2df)__b); +} + +/// Converts the two double-precision floating-point elements of a +/// 128-bit vector of [2 x double] into two single-precision floating-point +/// values, returned in the lower 64 bits of a 128-bit vector of [4 x float]. +/// The upper 64 bits of the result vector are set to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPD2PS / CVTPD2PS instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the +/// converted values. The upper 64 bits are set to zero. +static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtpd_ps(__m128d __a) { + return __builtin_ia32_cvtpd2ps((__v2df)__a); +} + +/// Converts the lower two single-precision floating-point elements of a +/// 128-bit vector of [4 x float] into two double-precision floating-point +/// values, returned in a 128-bit vector of [2 x double]. The upper two +/// elements of the input vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPS2PD / CVTPS2PD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower two single-precision +/// floating-point elements are converted to double-precision values. The +/// upper two elements are unused. +/// \returns A 128-bit vector of [2 x double] containing the converted values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtps_pd(__m128 __a) { + return (__m128d) __builtin_convertvector( + __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 1), __v2df); +} + +/// Converts the lower two integer elements of a 128-bit vector of +/// [4 x i32] into two double-precision floating-point values, returned in a +/// 128-bit vector of [2 x double]. +/// +/// The upper two elements of the input vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTDQ2PD / CVTDQ2PD instruction. +/// +/// \param __a +/// A 128-bit integer vector of [4 x i32]. The lower two integer elements are +/// converted to double-precision values. +/// +/// The upper two elements are unused. +/// \returns A 128-bit vector of [2 x double] containing the converted values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtepi32_pd(__m128i __a) { + return (__m128d) __builtin_convertvector( + __builtin_shufflevector((__v4si)__a, (__v4si)__a, 0, 1), __v2df); +} + +/// Converts the two double-precision floating-point elements of a +/// 128-bit vector of [2 x double] into two signed 32-bit integer values, +/// returned in the lower 64 bits of a 128-bit vector of [4 x i32]. The upper +/// 64 bits of the result vector are set to zero. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPD2DQ / CVTPD2DQ instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector of [4 x i32] whose lower 64 bits contain the +/// converted values. The upper 64 bits are set to zero. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtpd_epi32(__m128d __a) { + return __builtin_ia32_cvtpd2dq((__v2df)__a); +} + +/// Converts the low-order element of a 128-bit vector of [2 x double] +/// into a 32-bit signed integer value. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSD2SI / CVTSD2SI instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the +/// conversion. +/// \returns A 32-bit signed integer containing the converted value. +static __inline__ int __DEFAULT_FN_ATTRS _mm_cvtsd_si32(__m128d __a) { + return __builtin_ia32_cvtsd2si((__v2df)__a); +} + +/// Converts the lower double-precision floating-point element of a +/// 128-bit vector of [2 x double], in the second parameter, into a +/// single-precision floating-point value, returned in the lower 32 bits of a +/// 128-bit vector of [4 x float]. The upper 96 bits of the result vector are +/// copied from the upper 96 bits of the first parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSD2SS / CVTSD2SS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The upper 96 bits of this parameter are +/// copied to the upper 96 bits of the result. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower double-precision +/// floating-point element is used in the conversion. +/// \returns A 128-bit vector of [4 x float]. The lower 32 bits contain the +/// converted value from the second parameter. The upper 96 bits are copied +/// from the upper 96 bits of the first parameter. +static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtsd_ss(__m128 __a, + __m128d __b) { + return (__m128)__builtin_ia32_cvtsd2ss((__v4sf)__a, (__v2df)__b); +} + +/// Converts a 32-bit signed integer value, in the second parameter, into +/// a double-precision floating-point value, returned in the lower 64 bits of +/// a 128-bit vector of [2 x double]. The upper 64 bits of the result vector +/// are copied from the upper 64 bits of the first parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSI2SD / CVTSI2SD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The upper 64 bits of this parameter are +/// copied to the upper 64 bits of the result. +/// \param __b +/// A 32-bit signed integer containing the value to be converted. +/// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the +/// converted value from the second parameter. The upper 64 bits are copied +/// from the upper 64 bits of the first parameter. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtsi32_sd(__m128d __a, int __b) { + __a[0] = __b; + return __a; +} + +/// Converts the lower single-precision floating-point element of a +/// 128-bit vector of [4 x float], in the second parameter, into a +/// double-precision floating-point value, returned in the lower 64 bits of +/// a 128-bit vector of [2 x double]. The upper 64 bits of the result vector +/// are copied from the upper 64 bits of the first parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSS2SD / CVTSS2SD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The upper 64 bits of this parameter are +/// copied to the upper 64 bits of the result. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower single-precision +/// floating-point element is used in the conversion. +/// \returns A 128-bit vector of [2 x double]. The lower 64 bits contain the +/// converted value from the second parameter. The upper 64 bits are copied +/// from the upper 64 bits of the first parameter. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtss_sd(__m128d __a, __m128 __b) { + __a[0] = __b[0]; + return __a; +} + +/// Converts the two double-precision floating-point elements of a +/// 128-bit vector of [2 x double] into two signed truncated (rounded +/// toward zero) 32-bit integer values, returned in the lower 64 bits +/// of a 128-bit vector of [4 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTPD2DQ / CVTTPD2DQ +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector of [4 x i32] whose lower 64 bits contain the +/// converted values. The upper 64 bits are set to zero. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvttpd_epi32(__m128d __a) { + return (__m128i)__builtin_ia32_cvttpd2dq((__v2df)__a); +} + +/// Converts the low-order element of a [2 x double] vector into a 32-bit +/// signed truncated (rounded toward zero) integer value. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTSD2SI / CVTTSD2SI +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the +/// conversion. +/// \returns A 32-bit signed integer containing the converted value. +static __inline__ int __DEFAULT_FN_ATTRS _mm_cvttsd_si32(__m128d __a) { + return __builtin_ia32_cvttsd2si((__v2df)__a); +} + +/// Converts the two double-precision floating-point elements of a +/// 128-bit vector of [2 x double] into two signed 32-bit integer values, +/// returned in a 64-bit vector of [2 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPD2PI instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 64-bit vector of [2 x i32] containing the converted values. +static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_cvtpd_pi32(__m128d __a) { + return __trunc64(__builtin_ia32_cvtpd2dq((__v2df)__a)); +} + +/// Converts the two double-precision floating-point elements of a +/// 128-bit vector of [2 x double] into two signed truncated (rounded toward +/// zero) 32-bit integer values, returned in a 64-bit vector of [2 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTTPD2PI instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. +/// \returns A 64-bit vector of [2 x i32] containing the converted values. +static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_cvttpd_pi32(__m128d __a) { + return __trunc64(__builtin_ia32_cvttpd2dq((__v2df)__a)); +} + +/// Converts the two signed 32-bit integer elements of a 64-bit vector of +/// [2 x i32] into two double-precision floating-point values, returned in a +/// 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PD instruction. +/// +/// \param __a +/// A 64-bit vector of [2 x i32]. +/// \returns A 128-bit vector of [2 x double] containing the converted values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtpi32_pd(__m64 __a) { + return (__m128d) __builtin_convertvector((__v2si)__a, __v2df); +} + +/// Returns the low-order element of a 128-bit vector of [2 x double] as +/// a double-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower 64 bits are returned. +/// \returns A double-precision floating-point value copied from the lower 64 +/// bits of \a __a. +static __inline__ double __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtsd_f64(__m128d __a) { + return __a[0]; +} + +/// Loads a 128-bit floating-point vector of [2 x double] from an aligned +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPD / MOVAPD instruction. +/// +/// \param __dp +/// A pointer to a 128-bit memory location. The address of the memory +/// location has to be 16-byte aligned. +/// \returns A 128-bit vector of [2 x double] containing the loaded values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_load_pd(double const *__dp) { + return *(const __m128d *)__dp; +} + +/// Loads a double-precision floating-point value from a specified memory +/// location and duplicates it to both vector elements of a 128-bit vector of +/// [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP / MOVDDUP instruction. +/// +/// \param __dp +/// A pointer to a memory location containing a double-precision value. +/// \returns A 128-bit vector of [2 x double] containing the loaded and +/// duplicated values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_load1_pd(double const *__dp) { + struct __mm_load1_pd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + double __u = ((const struct __mm_load1_pd_struct *)__dp)->__u; + return __extension__(__m128d){__u, __u}; +} + +#define _mm_load_pd1(dp) _mm_load1_pd(dp) + +/// Loads two double-precision values, in reverse order, from an aligned +/// memory location into a 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPD / MOVAPD instruction + +/// needed shuffling instructions. In AVX mode, the shuffling may be combined +/// with the \c VMOVAPD, resulting in only a \c VPERMILPD instruction. +/// +/// \param __dp +/// A 16-byte aligned pointer to an array of double-precision values to be +/// loaded in reverse order. +/// \returns A 128-bit vector of [2 x double] containing the reversed loaded +/// values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_loadr_pd(double const *__dp) { + __m128d __u = *(const __m128d *)__dp; + return __builtin_shufflevector((__v2df)__u, (__v2df)__u, 1, 0); +} + +/// Loads a 128-bit floating-point vector of [2 x double] from an +/// unaligned memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPD / MOVUPD instruction. +/// +/// \param __dp +/// A pointer to a 128-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns A 128-bit vector of [2 x double] containing the loaded values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_loadu_pd(double const *__dp) { + struct __loadu_pd { + __m128d_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_pd *)__dp)->__v; +} + +/// Loads a 64-bit integer value to the low element of a 128-bit integer +/// vector and clears the upper element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction. +/// +/// \param __a +/// A pointer to a 64-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns A 128-bit vector of [2 x i64] containing the loaded value. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_loadu_si64(void const *__a) { + struct __loadu_si64 { + long long __v; + } __attribute__((__packed__, __may_alias__)); + long long __u = ((const struct __loadu_si64 *)__a)->__v; + return __extension__(__m128i)(__v2di){__u, 0LL}; +} + +/// Loads a 32-bit integer value to the low element of a 128-bit integer +/// vector and clears the upper element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVD / MOVD instruction. +/// +/// \param __a +/// A pointer to a 32-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns A 128-bit vector of [4 x i32] containing the loaded value. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_loadu_si32(void const *__a) { + struct __loadu_si32 { + int __v; + } __attribute__((__packed__, __may_alias__)); + int __u = ((const struct __loadu_si32 *)__a)->__v; + return __extension__(__m128i)(__v4si){__u, 0, 0, 0}; +} + +/// Loads a 16-bit integer value to the low element of a 128-bit integer +/// vector and clears the upper element. +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a specific instruction. +/// +/// \param __a +/// A pointer to a 16-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns A 128-bit vector of [8 x i16] containing the loaded value. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_loadu_si16(void const *__a) { + struct __loadu_si16 { + short __v; + } __attribute__((__packed__, __may_alias__)); + short __u = ((const struct __loadu_si16 *)__a)->__v; + return __extension__(__m128i)(__v8hi){__u, 0, 0, 0, 0, 0, 0, 0}; +} + +/// Loads a 64-bit double-precision value to the low element of a +/// 128-bit integer vector and clears the upper element. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSD / MOVSD instruction. +/// +/// \param __dp +/// A pointer to a memory location containing a double-precision value. +/// The address of the memory location does not have to be aligned. +/// \returns A 128-bit vector of [2 x double] containing the loaded value. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_load_sd(double const *__dp) { + struct __mm_load_sd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + double __u = ((const struct __mm_load_sd_struct *)__dp)->__u; + return __extension__(__m128d){__u, 0}; +} + +/// Loads a double-precision value into the high-order bits of a 128-bit +/// vector of [2 x double]. The low-order bits are copied from the low-order +/// bits of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVHPD / MOVHPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. \n +/// Bits [63:0] are written to bits [63:0] of the result. +/// \param __dp +/// A pointer to a 64-bit memory location containing a double-precision +/// floating-point value that is loaded. The loaded value is written to bits +/// [127:64] of the result. The address of the memory location does not have +/// to be aligned. +/// \returns A 128-bit vector of [2 x double] containing the moved values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_loadh_pd(__m128d __a, + double const *__dp) { + struct __mm_loadh_pd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + double __u = ((const struct __mm_loadh_pd_struct *)__dp)->__u; + return __extension__(__m128d){__a[0], __u}; +} + +/// Loads a double-precision value into the low-order bits of a 128-bit +/// vector of [2 x double]. The high-order bits are copied from the +/// high-order bits of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVLPD / MOVLPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. \n +/// Bits [127:64] are written to bits [127:64] of the result. +/// \param __dp +/// A pointer to a 64-bit memory location containing a double-precision +/// floating-point value that is loaded. The loaded value is written to bits +/// [63:0] of the result. The address of the memory location does not have to +/// be aligned. +/// \returns A 128-bit vector of [2 x double] containing the moved values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_loadl_pd(__m128d __a, + double const *__dp) { + struct __mm_loadl_pd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + double __u = ((const struct __mm_loadl_pd_struct *)__dp)->__u; + return __extension__(__m128d){__u, __a[1]}; +} + +/// Constructs a 128-bit floating-point vector of [2 x double] with +/// unspecified content. This could be used as an argument to another +/// intrinsic function where the argument is required but the value is not +/// actually used. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \returns A 128-bit floating-point vector of [2 x double] with unspecified +/// content. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_undefined_pd(void) { + return (__m128d)__builtin_ia32_undef128(); +} + +/// Constructs a 128-bit floating-point vector of [2 x double]. The lower +/// 64 bits of the vector are initialized with the specified double-precision +/// floating-point value. The upper 64 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction. +/// +/// \param __w +/// A double-precision floating-point value used to initialize the lower 64 +/// bits of the result. +/// \returns An initialized 128-bit floating-point vector of [2 x double]. The +/// lower 64 bits contain the value of the parameter. The upper 64 bits are +/// set to zero. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_sd(double __w) { + return __extension__(__m128d){__w, 0.0}; +} + +/// Constructs a 128-bit floating-point vector of [2 x double], with each +/// of the two double-precision floating-point vector elements set to the +/// specified double-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP / MOVLHPS instruction. +/// +/// \param __w +/// A double-precision floating-point value used to initialize each vector +/// element of the result. +/// \returns An initialized 128-bit floating-point vector of [2 x double]. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set1_pd(double __w) { + return __extension__(__m128d){__w, __w}; +} + +/// Constructs a 128-bit floating-point vector of [2 x double], with each +/// of the two double-precision floating-point vector elements set to the +/// specified double-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP / MOVLHPS instruction. +/// +/// \param __w +/// A double-precision floating-point value used to initialize each vector +/// element of the result. +/// \returns An initialized 128-bit floating-point vector of [2 x double]. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_pd1(double __w) { + return _mm_set1_pd(__w); +} + +/// Constructs a 128-bit floating-point vector of [2 x double] +/// initialized with the specified double-precision floating-point values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD / UNPCKLPD instruction. +/// +/// \param __w +/// A double-precision floating-point value used to initialize the upper 64 +/// bits of the result. +/// \param __x +/// A double-precision floating-point value used to initialize the lower 64 +/// bits of the result. +/// \returns An initialized 128-bit floating-point vector of [2 x double]. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_pd(double __w, + double __x) { + return __extension__(__m128d){__x, __w}; +} + +/// Constructs a 128-bit floating-point vector of [2 x double], +/// initialized in reverse order with the specified double-precision +/// floating-point values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD / UNPCKLPD instruction. +/// +/// \param __w +/// A double-precision floating-point value used to initialize the lower 64 +/// bits of the result. +/// \param __x +/// A double-precision floating-point value used to initialize the upper 64 +/// bits of the result. +/// \returns An initialized 128-bit floating-point vector of [2 x double]. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_setr_pd(double __w, + double __x) { + return __extension__(__m128d){__w, __x}; +} + +/// Constructs a 128-bit floating-point vector of [2 x double] +/// initialized to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS / XORPS instruction. +/// +/// \returns An initialized 128-bit floating-point vector of [2 x double] with +/// all elements set to zero. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR _mm_setzero_pd(void) { + return __extension__(__m128d){0.0, 0.0}; +} + +/// Constructs a 128-bit floating-point vector of [2 x double]. The lower +/// 64 bits are set to the lower 64 bits of the second parameter. The upper +/// 64 bits are set to the upper 64 bits of the first parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBLENDPD / BLENDPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The upper 64 bits are written to the +/// upper 64 bits of the result. +/// \param __b +/// A 128-bit vector of [2 x double]. The lower 64 bits are written to the +/// lower 64 bits of the result. +/// \returns A 128-bit vector of [2 x double] containing the moved values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_move_sd(__m128d __a, __m128d __b) { + __a[0] = __b[0]; + return __a; +} + +/// Stores the lower 64 bits of a 128-bit vector of [2 x double] to a +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSD / MOVSD instruction. +/// +/// \param __dp +/// A pointer to a 64-bit memory location. +/// \param __a +/// A 128-bit vector of [2 x double] containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_store_sd(double *__dp, + __m128d __a) { + struct __mm_store_sd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_store_sd_struct *)__dp)->__u = __a[0]; +} + +/// Moves packed double-precision values from a 128-bit vector of +/// [2 x double] to a memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPD / MOVAPS instruction. +/// +/// \param __dp +/// A pointer to an aligned memory location that can store two +/// double-precision values. +/// \param __a +/// A packed 128-bit vector of [2 x double] containing the values to be +/// moved. +static __inline__ void __DEFAULT_FN_ATTRS _mm_store_pd(double *__dp, + __m128d __a) { + *(__m128d *)__dp = __a; +} + +/// Moves the lower 64 bits of a 128-bit vector of [2 x double] twice to +/// the upper and lower 64 bits of a memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the +/// VMOVDDUP + VMOVAPD / MOVLHPS + MOVAPS instruction. +/// +/// \param __dp +/// A pointer to a memory location that can store two double-precision +/// values. +/// \param __a +/// A 128-bit vector of [2 x double] whose lower 64 bits are copied to each +/// of the values in \a __dp. +static __inline__ void __DEFAULT_FN_ATTRS _mm_store1_pd(double *__dp, + __m128d __a) { + __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0); + _mm_store_pd(__dp, __a); +} + +/// Moves the lower 64 bits of a 128-bit vector of [2 x double] twice to +/// the upper and lower 64 bits of a memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the +/// VMOVDDUP + VMOVAPD / MOVLHPS + MOVAPS instruction. +/// +/// \param __dp +/// A pointer to a memory location that can store two double-precision +/// values. +/// \param __a +/// A 128-bit vector of [2 x double] whose lower 64 bits are copied to each +/// of the values in \a __dp. +static __inline__ void __DEFAULT_FN_ATTRS _mm_store_pd1(double *__dp, + __m128d __a) { + _mm_store1_pd(__dp, __a); +} + +/// Stores a 128-bit vector of [2 x double] into an unaligned memory +/// location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPD / MOVUPD instruction. +/// +/// \param __dp +/// A pointer to a 128-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \param __a +/// A 128-bit vector of [2 x double] containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storeu_pd(double *__dp, + __m128d __a) { + struct __storeu_pd { + __m128d_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_pd *)__dp)->__v = __a; +} + +/// Stores two double-precision values, in reverse order, from a 128-bit +/// vector of [2 x double] to a 16-byte aligned memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to a shuffling instruction followed by a +/// VMOVAPD / MOVAPD instruction. +/// +/// \param __dp +/// A pointer to a 16-byte aligned memory location that can store two +/// double-precision values. +/// \param __a +/// A 128-bit vector of [2 x double] containing the values to be reversed and +/// stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storer_pd(double *__dp, + __m128d __a) { + __a = __builtin_shufflevector((__v2df)__a, (__v2df)__a, 1, 0); + *(__m128d *)__dp = __a; +} + +/// Stores the upper 64 bits of a 128-bit vector of [2 x double] to a +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVHPD / MOVHPD instruction. +/// +/// \param __dp +/// A pointer to a 64-bit memory location. +/// \param __a +/// A 128-bit vector of [2 x double] containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storeh_pd(double *__dp, + __m128d __a) { + struct __mm_storeh_pd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_storeh_pd_struct *)__dp)->__u = __a[1]; +} + +/// Stores the lower 64 bits of a 128-bit vector of [2 x double] to a +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVLPD / MOVLPD instruction. +/// +/// \param __dp +/// A pointer to a 64-bit memory location. +/// \param __a +/// A 128-bit vector of [2 x double] containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storel_pd(double *__dp, + __m128d __a) { + struct __mm_storeh_pd_struct { + double __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_storeh_pd_struct *)__dp)->__u = __a[0]; +} + +/// Adds the corresponding elements of two 128-bit vectors of [16 x i8], +/// saving the lower 8 bits of each sum in the corresponding element of a +/// 128-bit result vector of [16 x i8]. +/// +/// The integer elements of both parameters can be either signed or unsigned. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDB / PADDB instruction. +/// +/// \param __a +/// A 128-bit vector of [16 x i8]. +/// \param __b +/// A 128-bit vector of [16 x i8]. +/// \returns A 128-bit vector of [16 x i8] containing the sums of both +/// parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_add_epi8(__m128i __a, + __m128i __b) { + return (__m128i)((__v16qu)__a + (__v16qu)__b); +} + +/// Adds the corresponding elements of two 128-bit vectors of [8 x i16], +/// saving the lower 16 bits of each sum in the corresponding element of a +/// 128-bit result vector of [8 x i16]. +/// +/// The integer elements of both parameters can be either signed or unsigned. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDW / PADDW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16]. +/// \param __b +/// A 128-bit vector of [8 x i16]. +/// \returns A 128-bit vector of [8 x i16] containing the sums of both +/// parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_add_epi16(__m128i __a, + __m128i __b) { + return (__m128i)((__v8hu)__a + (__v8hu)__b); +} + +/// Adds the corresponding elements of two 128-bit vectors of [4 x i32], +/// saving the lower 32 bits of each sum in the corresponding element of a +/// 128-bit result vector of [4 x i32]. +/// +/// The integer elements of both parameters can be either signed or unsigned. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDD / PADDD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32]. +/// \param __b +/// A 128-bit vector of [4 x i32]. +/// \returns A 128-bit vector of [4 x i32] containing the sums of both +/// parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_add_epi32(__m128i __a, __m128i __b) { + return (__m128i)((__v4su)__a + (__v4su)__b); +} + +/// Adds two signed or unsigned 64-bit integer values, returning the +/// lower 64 bits of the sum. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDQ instruction. +/// +/// \param __a +/// A 64-bit integer. +/// \param __b +/// A 64-bit integer. +/// \returns A 64-bit integer containing the sum of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_add_si64(__m64 __a, __m64 __b) { + return (__m64)(((unsigned long long)__a) + ((unsigned long long)__b)); +} + +/// Adds the corresponding elements of two 128-bit vectors of [2 x i64], +/// saving the lower 64 bits of each sum in the corresponding element of a +/// 128-bit result vector of [2 x i64]. +/// +/// The integer elements of both parameters can be either signed or unsigned. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDQ / PADDQ instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x i64]. +/// \param __b +/// A 128-bit vector of [2 x i64]. +/// \returns A 128-bit vector of [2 x i64] containing the sums of both +/// parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_add_epi64(__m128i __a, __m128i __b) { + return (__m128i)((__v2du)__a + (__v2du)__b); +} + +/// Adds, with saturation, the corresponding elements of two 128-bit +/// signed [16 x i8] vectors, saving each sum in the corresponding element +/// of a 128-bit result vector of [16 x i8]. +/// +/// Positive sums greater than 0x7F are saturated to 0x7F. Negative sums +/// less than 0x80 are saturated to 0x80. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDSB / PADDSB instruction. +/// +/// \param __a +/// A 128-bit signed [16 x i8] vector. +/// \param __b +/// A 128-bit signed [16 x i8] vector. +/// \returns A 128-bit signed [16 x i8] vector containing the saturated sums of +/// both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_adds_epi8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_add_sat((__v16qs)__a, (__v16qs)__b); +} + +/// Adds, with saturation, the corresponding elements of two 128-bit +/// signed [8 x i16] vectors, saving each sum in the corresponding element +/// of a 128-bit result vector of [8 x i16]. +/// +/// Positive sums greater than 0x7FFF are saturated to 0x7FFF. Negative sums +/// less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDSW / PADDSW instruction. +/// +/// \param __a +/// A 128-bit signed [8 x i16] vector. +/// \param __b +/// A 128-bit signed [8 x i16] vector. +/// \returns A 128-bit signed [8 x i16] vector containing the saturated sums of +/// both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_adds_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_add_sat((__v8hi)__a, (__v8hi)__b); +} + +/// Adds, with saturation, the corresponding elements of two 128-bit +/// unsigned [16 x i8] vectors, saving each sum in the corresponding element +/// of a 128-bit result vector of [16 x i8]. +/// +/// Positive sums greater than 0xFF are saturated to 0xFF. Negative sums are +/// saturated to 0x00. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDUSB / PADDUSB instruction. +/// +/// \param __a +/// A 128-bit unsigned [16 x i8] vector. +/// \param __b +/// A 128-bit unsigned [16 x i8] vector. +/// \returns A 128-bit unsigned [16 x i8] vector containing the saturated sums +/// of both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_adds_epu8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_add_sat((__v16qu)__a, (__v16qu)__b); +} + +/// Adds, with saturation, the corresponding elements of two 128-bit +/// unsigned [8 x i16] vectors, saving each sum in the corresponding element +/// of a 128-bit result vector of [8 x i16]. +/// +/// Positive sums greater than 0xFFFF are saturated to 0xFFFF. Negative sums +/// are saturated to 0x0000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPADDUSB / PADDUSB instruction. +/// +/// \param __a +/// A 128-bit unsigned [8 x i16] vector. +/// \param __b +/// A 128-bit unsigned [8 x i16] vector. +/// \returns A 128-bit unsigned [8 x i16] vector containing the saturated sums +/// of both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_adds_epu16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_add_sat((__v8hu)__a, (__v8hu)__b); +} + +/// Computes the rounded averages of corresponding elements of two +/// 128-bit unsigned [16 x i8] vectors, saving each result in the +/// corresponding element of a 128-bit result vector of [16 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPAVGB / PAVGB instruction. +/// +/// \param __a +/// A 128-bit unsigned [16 x i8] vector. +/// \param __b +/// A 128-bit unsigned [16 x i8] vector. +/// \returns A 128-bit unsigned [16 x i8] vector containing the rounded +/// averages of both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_avg_epu8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_pavgb128((__v16qi)__a, (__v16qi)__b); +} + +/// Computes the rounded averages of corresponding elements of two +/// 128-bit unsigned [8 x i16] vectors, saving each result in the +/// corresponding element of a 128-bit result vector of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPAVGW / PAVGW instruction. +/// +/// \param __a +/// A 128-bit unsigned [8 x i16] vector. +/// \param __b +/// A 128-bit unsigned [8 x i16] vector. +/// \returns A 128-bit unsigned [8 x i16] vector containing the rounded +/// averages of both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_avg_epu16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_pavgw128((__v8hi)__a, (__v8hi)__b); +} + +/// Multiplies the corresponding elements of two 128-bit signed [8 x i16] +/// vectors, producing eight intermediate 32-bit signed integer products, and +/// adds the consecutive pairs of 32-bit products to form a 128-bit signed +/// [4 x i32] vector. +/// +/// For example, bits [15:0] of both parameters are multiplied producing a +/// 32-bit product, bits [31:16] of both parameters are multiplied producing +/// a 32-bit product, and the sum of those two products becomes bits [31:0] +/// of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMADDWD / PMADDWD instruction. +/// +/// \param __a +/// A 128-bit signed [8 x i16] vector. +/// \param __b +/// A 128-bit signed [8 x i16] vector. +/// \returns A 128-bit signed [4 x i32] vector containing the sums of products +/// of both parameters. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_madd_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_pmaddwd128((__v8hi)__a, (__v8hi)__b); +} + +/// Compares corresponding elements of two 128-bit signed [8 x i16] +/// vectors, saving the greater value from each comparison in the +/// corresponding element of a 128-bit result vector of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMAXSW / PMAXSW instruction. +/// +/// \param __a +/// A 128-bit signed [8 x i16] vector. +/// \param __b +/// A 128-bit signed [8 x i16] vector. +/// \returns A 128-bit signed [8 x i16] vector containing the greater value of +/// each comparison. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_max((__v8hi)__a, (__v8hi)__b); +} + +/// Compares corresponding elements of two 128-bit unsigned [16 x i8] +/// vectors, saving the greater value from each comparison in the +/// corresponding element of a 128-bit result vector of [16 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMAXUB / PMAXUB instruction. +/// +/// \param __a +/// A 128-bit unsigned [16 x i8] vector. +/// \param __b +/// A 128-bit unsigned [16 x i8] vector. +/// \returns A 128-bit unsigned [16 x i8] vector containing the greater value of +/// each comparison. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epu8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_max((__v16qu)__a, (__v16qu)__b); +} + +/// Compares corresponding elements of two 128-bit signed [8 x i16] +/// vectors, saving the smaller value from each comparison in the +/// corresponding element of a 128-bit result vector of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMINSW / PMINSW instruction. +/// +/// \param __a +/// A 128-bit signed [8 x i16] vector. +/// \param __b +/// A 128-bit signed [8 x i16] vector. +/// \returns A 128-bit signed [8 x i16] vector containing the smaller value of +/// each comparison. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_min_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_min((__v8hi)__a, (__v8hi)__b); +} + +/// Compares corresponding elements of two 128-bit unsigned [16 x i8] +/// vectors, saving the smaller value from each comparison in the +/// corresponding element of a 128-bit result vector of [16 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMINUB / PMINUB instruction. +/// +/// \param __a +/// A 128-bit unsigned [16 x i8] vector. +/// \param __b +/// A 128-bit unsigned [16 x i8] vector. +/// \returns A 128-bit unsigned [16 x i8] vector containing the smaller value of +/// each comparison. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_min_epu8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_min((__v16qu)__a, (__v16qu)__b); +} + +/// Multiplies the corresponding elements of two signed [8 x i16] +/// vectors, saving the upper 16 bits of each 32-bit product in the +/// corresponding element of a 128-bit signed [8 x i16] result vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMULHW / PMULHW instruction. +/// +/// \param __a +/// A 128-bit signed [8 x i16] vector. +/// \param __b +/// A 128-bit signed [8 x i16] vector. +/// \returns A 128-bit signed [8 x i16] vector containing the upper 16 bits of +/// each of the eight 32-bit products. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mulhi_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_pmulhw128((__v8hi)__a, (__v8hi)__b); +} + +/// Multiplies the corresponding elements of two unsigned [8 x i16] +/// vectors, saving the upper 16 bits of each 32-bit product in the +/// corresponding element of a 128-bit unsigned [8 x i16] result vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMULHUW / PMULHUW instruction. +/// +/// \param __a +/// A 128-bit unsigned [8 x i16] vector. +/// \param __b +/// A 128-bit unsigned [8 x i16] vector. +/// \returns A 128-bit unsigned [8 x i16] vector containing the upper 16 bits +/// of each of the eight 32-bit products. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mulhi_epu16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b); +} + +/// Multiplies the corresponding elements of two signed [8 x i16] +/// vectors, saving the lower 16 bits of each 32-bit product in the +/// corresponding element of a 128-bit signed [8 x i16] result vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMULLW / PMULLW instruction. +/// +/// \param __a +/// A 128-bit signed [8 x i16] vector. +/// \param __b +/// A 128-bit signed [8 x i16] vector. +/// \returns A 128-bit signed [8 x i16] vector containing the lower 16 bits of +/// each of the eight 32-bit products. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mullo_epi16(__m128i __a, + __m128i __b) { + return (__m128i)((__v8hu)__a * (__v8hu)__b); +} + +/// Multiplies 32-bit unsigned integer values contained in the lower bits +/// of the two 64-bit integer vectors and returns the 64-bit unsigned +/// product. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMULUDQ instruction. +/// +/// \param __a +/// A 64-bit integer containing one of the source operands. +/// \param __b +/// A 64-bit integer containing one of the source operands. +/// \returns A 64-bit integer vector containing the product of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_mul_su32(__m64 __a, __m64 __b) { + return __trunc64(__builtin_ia32_pmuludq128((__v4si)__anyext128(__a), + (__v4si)__anyext128(__b))); +} + +/// Multiplies 32-bit unsigned integer values contained in the lower +/// bits of the corresponding elements of two [2 x i64] vectors, and returns +/// the 64-bit products in the corresponding elements of a [2 x i64] vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMULUDQ / PMULUDQ instruction. +/// +/// \param __a +/// A [2 x i64] vector containing one of the source operands. +/// \param __b +/// A [2 x i64] vector containing one of the source operands. +/// \returns A [2 x i64] vector containing the product of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mul_epu32(__m128i __a, + __m128i __b) { + return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b); +} + +/// Computes the absolute differences of corresponding 8-bit integer +/// values in two 128-bit vectors. Sums the first 8 absolute differences, and +/// separately sums the second 8 absolute differences. Packs these two +/// unsigned 16-bit integer sums into the upper and lower elements of a +/// [2 x i64] vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSADBW / PSADBW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing one of the source operands. +/// \param __b +/// A 128-bit integer vector containing one of the source operands. +/// \returns A [2 x i64] vector containing the sums of the sets of absolute +/// differences between both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sad_epu8(__m128i __a, + __m128i __b) { + return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b); +} + +/// Subtracts the corresponding 8-bit integer values in the operands. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBB / PSUBB instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the differences of the values +/// in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sub_epi8(__m128i __a, + __m128i __b) { + return (__m128i)((__v16qu)__a - (__v16qu)__b); +} + +/// Subtracts the corresponding 16-bit integer values in the operands. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBW / PSUBW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the differences of the values +/// in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sub_epi16(__m128i __a, + __m128i __b) { + return (__m128i)((__v8hu)__a - (__v8hu)__b); +} + +/// Subtracts the corresponding 32-bit integer values in the operands. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBD / PSUBD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the differences of the values +/// in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_sub_epi32(__m128i __a, __m128i __b) { + return (__m128i)((__v4su)__a - (__v4su)__b); +} + +/// Subtracts signed or unsigned 64-bit integer values and writes the +/// difference to the corresponding bits in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBQ instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the minuend. +/// \param __b +/// A 64-bit integer vector containing the subtrahend. +/// \returns A 64-bit integer vector containing the difference of the values in +/// the operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS _mm_sub_si64(__m64 __a, __m64 __b) { + return (__m64)((unsigned long long)__a - (unsigned long long)__b); +} + +/// Subtracts the corresponding elements of two [2 x i64] vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBQ / PSUBQ instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the differences of the values +/// in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_sub_epi64(__m128i __a, __m128i __b) { + return (__m128i)((__v2du)__a - (__v2du)__b); +} + +/// Subtracts, with saturation, corresponding 8-bit signed integer values in +/// the input and returns the differences in the corresponding bytes in the +/// destination. +/// +/// Differences greater than 0x7F are saturated to 0x7F, and differences +/// less than 0x80 are saturated to 0x80. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBSB / PSUBSB instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the differences of the values +/// in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_subs_epi8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_sub_sat((__v16qs)__a, (__v16qs)__b); +} + +/// Subtracts, with saturation, corresponding 16-bit signed integer values in +/// the input and returns the differences in the corresponding bytes in the +/// destination. +/// +/// Differences greater than 0x7FFF are saturated to 0x7FFF, and values less +/// than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBSW / PSUBSW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the differences of the values +/// in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_subs_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_sub_sat((__v8hi)__a, (__v8hi)__b); +} + +/// Subtracts, with saturation, corresponding 8-bit unsigned integer values in +/// the input and returns the differences in the corresponding bytes in the +/// destination. +/// +/// Differences less than 0x00 are saturated to 0x00. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBUSB / PSUBUSB instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the unsigned integer +/// differences of the values in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_subs_epu8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_sub_sat((__v16qu)__a, (__v16qu)__b); +} + +/// Subtracts, with saturation, corresponding 16-bit unsigned integer values in +/// the input and returns the differences in the corresponding bytes in the +/// destination. +/// +/// Differences less than 0x0000 are saturated to 0x0000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSUBUSW / PSUBUSW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the minuends. +/// \param __b +/// A 128-bit integer vector containing the subtrahends. +/// \returns A 128-bit integer vector containing the unsigned integer +/// differences of the values in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_subs_epu16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_elementwise_sub_sat((__v8hu)__a, (__v8hu)__b); +} + +/// Performs a bitwise AND of two 128-bit integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPAND / PAND instruction. +/// +/// \param __a +/// A 128-bit integer vector containing one of the source operands. +/// \param __b +/// A 128-bit integer vector containing one of the source operands. +/// \returns A 128-bit integer vector containing the bitwise AND of the values +/// in both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_and_si128(__m128i __a, + __m128i __b) { + return (__m128i)((__v2du)__a & (__v2du)__b); +} + +/// Performs a bitwise AND of two 128-bit integer vectors, using the +/// one's complement of the values contained in the first source operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPANDN / PANDN instruction. +/// +/// \param __a +/// A 128-bit vector containing the left source operand. The one's complement +/// of this value is used in the bitwise AND. +/// \param __b +/// A 128-bit vector containing the right source operand. +/// \returns A 128-bit integer vector containing the bitwise AND of the one's +/// complement of the first operand and the values in the second operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_andnot_si128(__m128i __a, + __m128i __b) { + return (__m128i)(~(__v2du)__a & (__v2du)__b); +} +/// Performs a bitwise OR of two 128-bit integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPOR / POR instruction. +/// +/// \param __a +/// A 128-bit integer vector containing one of the source operands. +/// \param __b +/// A 128-bit integer vector containing one of the source operands. +/// \returns A 128-bit integer vector containing the bitwise OR of the values +/// in both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_or_si128(__m128i __a, + __m128i __b) { + return (__m128i)((__v2du)__a | (__v2du)__b); +} + +/// Performs a bitwise exclusive OR of two 128-bit integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPXOR / PXOR instruction. +/// +/// \param __a +/// A 128-bit integer vector containing one of the source operands. +/// \param __b +/// A 128-bit integer vector containing one of the source operands. +/// \returns A 128-bit integer vector containing the bitwise exclusive OR of the +/// values in both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_xor_si128(__m128i __a, + __m128i __b) { + return (__m128i)((__v2du)__a ^ (__v2du)__b); +} + +/// Left-shifts the 128-bit integer vector operand by the specified +/// number of bytes. Low-order bits are cleared. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_slli_si128(__m128i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPSLLDQ / PSLLDQ instruction. +/// +/// \param a +/// A 128-bit integer vector containing the source operand. +/// \param imm +/// An immediate value specifying the number of bytes to left-shift operand +/// \a a. +/// \returns A 128-bit integer vector containing the left-shifted value. +#define _mm_slli_si128(a, imm) \ + ((__m128i)__builtin_ia32_pslldqi128_byteshift((__v2di)(__m128i)(a), \ + (int)(imm))) + +#define _mm_bslli_si128(a, imm) \ + ((__m128i)__builtin_ia32_pslldqi128_byteshift((__v2di)(__m128i)(a), \ + (int)(imm))) + +/// Left-shifts each 16-bit value in the 128-bit integer vector operand +/// by the specified number of bits. Low-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSLLW / PSLLW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to left-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the left-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_slli_epi16(__m128i __a, + int __count) { + return (__m128i)__builtin_ia32_psllwi128((__v8hi)__a, __count); +} + +/// Left-shifts each 16-bit value in the 128-bit integer vector operand +/// by the specified number of bits. Low-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSLLW / PSLLW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to left-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the left-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sll_epi16(__m128i __a, + __m128i __count) { + return (__m128i)__builtin_ia32_psllw128((__v8hi)__a, (__v8hi)__count); +} + +/// Left-shifts each 32-bit value in the 128-bit integer vector operand +/// by the specified number of bits. Low-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSLLD / PSLLD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to left-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the left-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_slli_epi32(__m128i __a, + int __count) { + return (__m128i)__builtin_ia32_pslldi128((__v4si)__a, __count); +} + +/// Left-shifts each 32-bit value in the 128-bit integer vector operand +/// by the specified number of bits. Low-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSLLD / PSLLD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to left-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the left-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sll_epi32(__m128i __a, + __m128i __count) { + return (__m128i)__builtin_ia32_pslld128((__v4si)__a, (__v4si)__count); +} + +/// Left-shifts each 64-bit value in the 128-bit integer vector operand +/// by the specified number of bits. Low-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSLLQ / PSLLQ instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to left-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the left-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_slli_epi64(__m128i __a, + int __count) { + return __builtin_ia32_psllqi128((__v2di)__a, __count); +} + +/// Left-shifts each 64-bit value in the 128-bit integer vector operand +/// by the specified number of bits. Low-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSLLQ / PSLLQ instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to left-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the left-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sll_epi64(__m128i __a, + __m128i __count) { + return __builtin_ia32_psllq128((__v2di)__a, (__v2di)__count); +} + +/// Right-shifts each 16-bit value in the 128-bit integer vector operand +/// by the specified number of bits. High-order bits are filled with the sign +/// bit of the initial value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRAW / PSRAW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to right-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srai_epi16(__m128i __a, + int __count) { + return (__m128i)__builtin_ia32_psrawi128((__v8hi)__a, __count); +} + +/// Right-shifts each 16-bit value in the 128-bit integer vector operand +/// by the specified number of bits. High-order bits are filled with the sign +/// bit of the initial value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRAW / PSRAW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to right-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sra_epi16(__m128i __a, + __m128i __count) { + return (__m128i)__builtin_ia32_psraw128((__v8hi)__a, (__v8hi)__count); +} + +/// Right-shifts each 32-bit value in the 128-bit integer vector operand +/// by the specified number of bits. High-order bits are filled with the sign +/// bit of the initial value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRAD / PSRAD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to right-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srai_epi32(__m128i __a, + int __count) { + return (__m128i)__builtin_ia32_psradi128((__v4si)__a, __count); +} + +/// Right-shifts each 32-bit value in the 128-bit integer vector operand +/// by the specified number of bits. High-order bits are filled with the sign +/// bit of the initial value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRAD / PSRAD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to right-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_sra_epi32(__m128i __a, + __m128i __count) { + return (__m128i)__builtin_ia32_psrad128((__v4si)__a, (__v4si)__count); +} + +/// Right-shifts the 128-bit integer vector operand by the specified +/// number of bytes. High-order bits are cleared. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_srli_si128(__m128i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPSRLDQ / PSRLDQ instruction. +/// +/// \param a +/// A 128-bit integer vector containing the source operand. +/// \param imm +/// An immediate value specifying the number of bytes to right-shift operand +/// \a a. +/// \returns A 128-bit integer vector containing the right-shifted value. +#define _mm_srli_si128(a, imm) \ + ((__m128i)__builtin_ia32_psrldqi128_byteshift((__v2di)(__m128i)(a), \ + (int)(imm))) + +#define _mm_bsrli_si128(a, imm) \ + ((__m128i)__builtin_ia32_psrldqi128_byteshift((__v2di)(__m128i)(a), \ + (int)(imm))) + +/// Right-shifts each of 16-bit values in the 128-bit integer vector +/// operand by the specified number of bits. High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRLW / PSRLW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to right-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srli_epi16(__m128i __a, + int __count) { + return (__m128i)__builtin_ia32_psrlwi128((__v8hi)__a, __count); +} + +/// Right-shifts each of 16-bit values in the 128-bit integer vector +/// operand by the specified number of bits. High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRLW / PSRLW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to right-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi16(__m128i __a, + __m128i __count) { + return (__m128i)__builtin_ia32_psrlw128((__v8hi)__a, (__v8hi)__count); +} + +/// Right-shifts each of 32-bit values in the 128-bit integer vector +/// operand by the specified number of bits. High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRLD / PSRLD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to right-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srli_epi32(__m128i __a, + int __count) { + return (__m128i)__builtin_ia32_psrldi128((__v4si)__a, __count); +} + +/// Right-shifts each of 32-bit values in the 128-bit integer vector +/// operand by the specified number of bits. High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRLD / PSRLD instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to right-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi32(__m128i __a, + __m128i __count) { + return (__m128i)__builtin_ia32_psrld128((__v4si)__a, (__v4si)__count); +} + +/// Right-shifts each of 64-bit values in the 128-bit integer vector +/// operand by the specified number of bits. High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRLQ / PSRLQ instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// An integer value specifying the number of bits to right-shift each value +/// in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srli_epi64(__m128i __a, + int __count) { + return __builtin_ia32_psrlqi128((__v2di)__a, __count); +} + +/// Right-shifts each of 64-bit values in the 128-bit integer vector +/// operand by the specified number of bits. High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPSRLQ / PSRLQ instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the source operand. +/// \param __count +/// A 128-bit integer vector in which bits [63:0] specify the number of bits +/// to right-shift each value in operand \a __a. +/// \returns A 128-bit integer vector containing the right-shifted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_srl_epi64(__m128i __a, + __m128i __count) { + return __builtin_ia32_psrlq128((__v2di)__a, (__v2di)__count); +} + +/// Compares each of the corresponding 8-bit values of the 128-bit +/// integer vectors for equality. +/// +/// Each comparison returns 0x0 for false, 0xFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPEQB / PCMPEQB instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi8(__m128i __a, + __m128i __b) { + return (__m128i)((__v16qi)__a == (__v16qi)__b); +} + +/// Compares each of the corresponding 16-bit values of the 128-bit +/// integer vectors for equality. +/// +/// Each comparison returns 0x0 for false, 0xFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPEQW / PCMPEQW instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi16(__m128i __a, + __m128i __b) { + return (__m128i)((__v8hi)__a == (__v8hi)__b); +} + +/// Compares each of the corresponding 32-bit values of the 128-bit +/// integer vectors for equality. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPEQD / PCMPEQD instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi32(__m128i __a, + __m128i __b) { + return (__m128i)((__v4si)__a == (__v4si)__b); +} + +/// Compares each of the corresponding signed 8-bit values of the 128-bit +/// integer vectors to determine if the values in the first operand are +/// greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTB / PCMPGTB instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi8(__m128i __a, + __m128i __b) { + /* This function always performs a signed comparison, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m128i)((__v16qs)__a > (__v16qs)__b); +} + +/// Compares each of the corresponding signed 16-bit values of the +/// 128-bit integer vectors to determine if the values in the first operand +/// are greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTW / PCMPGTW instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi16(__m128i __a, + __m128i __b) { + return (__m128i)((__v8hi)__a > (__v8hi)__b); +} + +/// Compares each of the corresponding signed 32-bit values of the +/// 128-bit integer vectors to determine if the values in the first operand +/// are greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTD / PCMPGTD instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi32(__m128i __a, + __m128i __b) { + return (__m128i)((__v4si)__a > (__v4si)__b); +} + +/// Compares each of the corresponding signed 8-bit values of the 128-bit +/// integer vectors to determine if the values in the first operand are less +/// than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTB / PCMPGTB instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi8(__m128i __a, + __m128i __b) { + return _mm_cmpgt_epi8(__b, __a); +} + +/// Compares each of the corresponding signed 16-bit values of the +/// 128-bit integer vectors to determine if the values in the first operand +/// are less than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTW / PCMPGTW instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi16(__m128i __a, + __m128i __b) { + return _mm_cmpgt_epi16(__b, __a); +} + +/// Compares each of the corresponding signed 32-bit values of the +/// 128-bit integer vectors to determine if the values in the first operand +/// are less than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTD / PCMPGTD instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \param __b +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmplt_epi32(__m128i __a, + __m128i __b) { + return _mm_cmpgt_epi32(__b, __a); +} + +#ifdef __x86_64__ +/// Converts a 64-bit signed integer value from the second operand into a +/// double-precision value and returns it in the lower element of a [2 x +/// double] vector; the upper element of the returned vector is copied from +/// the upper element of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSI2SD / CVTSI2SD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The upper 64 bits of this operand are +/// copied to the upper 64 bits of the destination. +/// \param __b +/// A 64-bit signed integer operand containing the value to be converted. +/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the +/// converted value of the second operand. The upper 64 bits are copied from +/// the upper 64 bits of the first operand. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtsi64_sd(__m128d __a, long long __b) { + __a[0] = __b; + return __a; +} + +/// Converts the first (lower) element of a vector of [2 x double] into a +/// 64-bit signed integer value. +/// +/// If the converted value does not fit in a 64-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSD2SI / CVTSD2SI instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the +/// conversion. +/// \returns A 64-bit signed integer containing the converted value. +static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvtsd_si64(__m128d __a) { + return __builtin_ia32_cvtsd2si64((__v2df)__a); +} + +/// Converts the first (lower) element of a vector of [2 x double] into a +/// 64-bit signed truncated (rounded toward zero) integer value. +/// +/// If a converted value does not fit in a 64-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTSD2SI / CVTTSD2SI +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. The lower 64 bits are used in the +/// conversion. +/// \returns A 64-bit signed integer containing the converted value. +static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvttsd_si64(__m128d __a) { + return __builtin_ia32_cvttsd2si64((__v2df)__a); +} +#endif + +/// Converts a vector of [4 x i32] into a vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTDQ2PS / CVTDQ2PS instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \returns A 128-bit vector of [4 x float] containing the converted values. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtepi32_ps(__m128i __a) { + return (__m128) __builtin_convertvector((__v4si)__a, __v4sf); +} + +/// Converts a vector of [4 x float] into a vector of [4 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPS2DQ / CVTPS2DQ instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit integer vector of [4 x i32] containing the converted +/// values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtps_epi32(__m128 __a) { + return (__m128i)__builtin_ia32_cvtps2dq((__v4sf)__a); +} + +/// Converts a vector of [4 x float] into four signed truncated (rounded toward +/// zero) 32-bit integers, returned in a vector of [4 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTPS2DQ / CVTTPS2DQ +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x i32] containing the converted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvttps_epi32(__m128 __a) { + return (__m128i)__builtin_ia32_cvttps2dq((__v4sf)__a); +} + +/// Returns a vector of [4 x i32] where the lowest element is the input +/// operand and the remaining elements are zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVD / MOVD instruction. +/// +/// \param __a +/// A 32-bit signed integer operand. +/// \returns A 128-bit vector of [4 x i32]. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtsi32_si128(int __a) { + return __extension__(__m128i)(__v4si){__a, 0, 0, 0}; +} + +/// Returns a vector of [2 x i64] where the lower element is the input +/// operand and the upper element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction +/// in 64-bit mode. +/// +/// \param __a +/// A 64-bit signed integer operand containing the value to be converted. +/// \returns A 128-bit vector of [2 x i64] containing the converted value. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtsi64_si128(long long __a) { + return __extension__(__m128i)(__v2di){__a, 0}; +} + +/// Moves the least significant 32 bits of a vector of [4 x i32] to a +/// 32-bit signed integer value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVD / MOVD instruction. +/// +/// \param __a +/// A vector of [4 x i32]. The least significant 32 bits are moved to the +/// destination. +/// \returns A 32-bit signed integer containing the moved value. +static __inline__ int __DEFAULT_FN_ATTRS _mm_cvtsi128_si32(__m128i __a) { + __v4si __b = (__v4si)__a; + return __b[0]; +} + +/// Moves the least significant 64 bits of a vector of [2 x i64] to a +/// 64-bit signed integer value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction. +/// +/// \param __a +/// A vector of [2 x i64]. The least significant 64 bits are moved to the +/// destination. +/// \returns A 64-bit signed integer containing the moved value. +static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvtsi128_si64(__m128i __a) { + return __a[0]; +} + +/// Moves packed integer values from an aligned 128-bit memory location +/// to elements in a 128-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDQA / MOVDQA instruction. +/// +/// \param __p +/// An aligned pointer to a memory location containing integer values. +/// \returns A 128-bit integer vector containing the moved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_load_si128(__m128i const *__p) { + return *__p; +} + +/// Moves packed integer values from an unaligned 128-bit memory location +/// to elements in a 128-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDQU / MOVDQU instruction. +/// +/// \param __p +/// A pointer to a memory location containing integer values. +/// \returns A 128-bit integer vector containing the moved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_loadu_si128(__m128i_u const *__p) { + struct __loadu_si128 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_si128 *)__p)->__v; +} + +/// Returns a vector of [2 x i64] where the lower element is taken from +/// the lower element of the operand, and the upper element is zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction. +/// +/// \param __p +/// A 128-bit vector of [2 x i64]. Bits [63:0] are written to bits [63:0] of +/// the destination. +/// \returns A 128-bit vector of [2 x i64]. The lower order bits contain the +/// moved value. The higher order bits are cleared. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_loadl_epi64(__m128i_u const *__p) { + struct __mm_loadl_epi64_struct { + long long __u; + } __attribute__((__packed__, __may_alias__)); + return __extension__(__m128i){ + ((const struct __mm_loadl_epi64_struct *)__p)->__u, 0}; +} + +/// Generates a 128-bit vector of [4 x i32] with unspecified content. +/// This could be used as an argument to another intrinsic function where the +/// argument is required but the value is not actually used. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \returns A 128-bit vector of [4 x i32] with unspecified content. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_undefined_si128(void) { + return (__m128i)__builtin_ia32_undef128(); +} + +/// Initializes both 64-bit values in a 128-bit vector of [2 x i64] with +/// the specified 64-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __q1 +/// A 64-bit integer value used to initialize the upper 64 bits of the +/// destination vector of [2 x i64]. +/// \param __q0 +/// A 64-bit integer value used to initialize the lower 64 bits of the +/// destination vector of [2 x i64]. +/// \returns An initialized 128-bit vector of [2 x i64] containing the values +/// provided in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_epi64x(long long __q1, long long __q0) { + return __extension__(__m128i)(__v2di){__q0, __q1}; +} + +/// Initializes both 64-bit values in a 128-bit vector of [2 x i64] with +/// the specified 64-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __q1 +/// A 64-bit integer value used to initialize the upper 64 bits of the +/// destination vector of [2 x i64]. +/// \param __q0 +/// A 64-bit integer value used to initialize the lower 64 bits of the +/// destination vector of [2 x i64]. +/// \returns An initialized 128-bit vector of [2 x i64] containing the values +/// provided in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_epi64(__m64 __q1, __m64 __q0) { + return _mm_set_epi64x((long long)__q1[0], (long long)__q0[0]); +} + +/// Initializes the 32-bit values in a 128-bit vector of [4 x i32] with +/// the specified 32-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i3 +/// A 32-bit integer value used to initialize bits [127:96] of the +/// destination vector. +/// \param __i2 +/// A 32-bit integer value used to initialize bits [95:64] of the destination +/// vector. +/// \param __i1 +/// A 32-bit integer value used to initialize bits [63:32] of the destination +/// vector. +/// \param __i0 +/// A 32-bit integer value used to initialize bits [31:0] of the destination +/// vector. +/// \returns An initialized 128-bit vector of [4 x i32] containing the values +/// provided in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set_epi32(int __i3, + int __i2, + int __i1, + int __i0) { + return __extension__(__m128i)(__v4si){__i0, __i1, __i2, __i3}; +} + +/// Initializes the 16-bit values in a 128-bit vector of [8 x i16] with +/// the specified 16-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w7 +/// A 16-bit integer value used to initialize bits [127:112] of the +/// destination vector. +/// \param __w6 +/// A 16-bit integer value used to initialize bits [111:96] of the +/// destination vector. +/// \param __w5 +/// A 16-bit integer value used to initialize bits [95:80] of the destination +/// vector. +/// \param __w4 +/// A 16-bit integer value used to initialize bits [79:64] of the destination +/// vector. +/// \param __w3 +/// A 16-bit integer value used to initialize bits [63:48] of the destination +/// vector. +/// \param __w2 +/// A 16-bit integer value used to initialize bits [47:32] of the destination +/// vector. +/// \param __w1 +/// A 16-bit integer value used to initialize bits [31:16] of the destination +/// vector. +/// \param __w0 +/// A 16-bit integer value used to initialize bits [15:0] of the destination +/// vector. +/// \returns An initialized 128-bit vector of [8 x i16] containing the values +/// provided in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_epi16(short __w7, short __w6, short __w5, short __w4, short __w3, + short __w2, short __w1, short __w0) { + return __extension__(__m128i)(__v8hi){__w0, __w1, __w2, __w3, + __w4, __w5, __w6, __w7}; +} + +/// Initializes the 8-bit values in a 128-bit vector of [16 x i8] with +/// the specified 8-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b15 +/// Initializes bits [127:120] of the destination vector. +/// \param __b14 +/// Initializes bits [119:112] of the destination vector. +/// \param __b13 +/// Initializes bits [111:104] of the destination vector. +/// \param __b12 +/// Initializes bits [103:96] of the destination vector. +/// \param __b11 +/// Initializes bits [95:88] of the destination vector. +/// \param __b10 +/// Initializes bits [87:80] of the destination vector. +/// \param __b9 +/// Initializes bits [79:72] of the destination vector. +/// \param __b8 +/// Initializes bits [71:64] of the destination vector. +/// \param __b7 +/// Initializes bits [63:56] of the destination vector. +/// \param __b6 +/// Initializes bits [55:48] of the destination vector. +/// \param __b5 +/// Initializes bits [47:40] of the destination vector. +/// \param __b4 +/// Initializes bits [39:32] of the destination vector. +/// \param __b3 +/// Initializes bits [31:24] of the destination vector. +/// \param __b2 +/// Initializes bits [23:16] of the destination vector. +/// \param __b1 +/// Initializes bits [15:8] of the destination vector. +/// \param __b0 +/// Initializes bits [7:0] of the destination vector. +/// \returns An initialized 128-bit vector of [16 x i8] containing the values +/// provided in the operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_epi8(char __b15, char __b14, char __b13, char __b12, char __b11, + char __b10, char __b9, char __b8, char __b7, char __b6, char __b5, + char __b4, char __b3, char __b2, char __b1, char __b0) { + return __extension__(__m128i)(__v16qi){ + __b0, __b1, __b2, __b3, __b4, __b5, __b6, __b7, + __b8, __b9, __b10, __b11, __b12, __b13, __b14, __b15}; +} + +/// Initializes both values in a 128-bit integer vector with the +/// specified 64-bit integer value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __q +/// Integer value used to initialize the elements of the destination integer +/// vector. +/// \returns An initialized 128-bit integer vector of [2 x i64] with both +/// elements containing the value provided in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set1_epi64x(long long __q) { + return _mm_set_epi64x(__q, __q); +} + +/// Initializes both values in a 128-bit vector of [2 x i64] with the +/// specified 64-bit value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __q +/// A 64-bit value used to initialize the elements of the destination integer +/// vector. +/// \returns An initialized 128-bit vector of [2 x i64] with all elements +/// containing the value provided in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set1_epi64(__m64 __q) { + return _mm_set_epi64(__q, __q); +} + +/// Initializes all values in a 128-bit vector of [4 x i32] with the +/// specified 32-bit value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i +/// A 32-bit value used to initialize the elements of the destination integer +/// vector. +/// \returns An initialized 128-bit vector of [4 x i32] with all elements +/// containing the value provided in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set1_epi32(int __i) { + return _mm_set_epi32(__i, __i, __i, __i); +} + +/// Initializes all values in a 128-bit vector of [8 x i16] with the +/// specified 16-bit value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w +/// A 16-bit value used to initialize the elements of the destination integer +/// vector. +/// \returns An initialized 128-bit vector of [8 x i16] with all elements +/// containing the value provided in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set1_epi16(short __w) { + return _mm_set_epi16(__w, __w, __w, __w, __w, __w, __w, __w); +} + +/// Initializes all values in a 128-bit vector of [16 x i8] with the +/// specified 8-bit value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b +/// An 8-bit value used to initialize the elements of the destination integer +/// vector. +/// \returns An initialized 128-bit vector of [16 x i8] with all elements +/// containing the value provided in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_set1_epi8(char __b) { + return _mm_set_epi8(__b, __b, __b, __b, __b, __b, __b, __b, __b, __b, __b, + __b, __b, __b, __b, __b); +} + +/// Constructs a 128-bit integer vector, initialized in reverse order +/// with the specified 64-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a specific instruction. +/// +/// \param __q0 +/// A 64-bit integral value used to initialize the lower 64 bits of the +/// result. +/// \param __q1 +/// A 64-bit integral value used to initialize the upper 64 bits of the +/// result. +/// \returns An initialized 128-bit integer vector. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_setr_epi64(__m64 __q0, __m64 __q1) { + return _mm_set_epi64(__q1, __q0); +} + +/// Constructs a 128-bit integer vector, initialized in reverse order +/// with the specified 32-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i0 +/// A 32-bit integral value used to initialize bits [31:0] of the result. +/// \param __i1 +/// A 32-bit integral value used to initialize bits [63:32] of the result. +/// \param __i2 +/// A 32-bit integral value used to initialize bits [95:64] of the result. +/// \param __i3 +/// A 32-bit integral value used to initialize bits [127:96] of the result. +/// \returns An initialized 128-bit integer vector. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_setr_epi32(int __i0, int __i1, int __i2, int __i3) { + return _mm_set_epi32(__i3, __i2, __i1, __i0); +} + +/// Constructs a 128-bit integer vector, initialized in reverse order +/// with the specified 16-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w0 +/// A 16-bit integral value used to initialize bits [15:0] of the result. +/// \param __w1 +/// A 16-bit integral value used to initialize bits [31:16] of the result. +/// \param __w2 +/// A 16-bit integral value used to initialize bits [47:32] of the result. +/// \param __w3 +/// A 16-bit integral value used to initialize bits [63:48] of the result. +/// \param __w4 +/// A 16-bit integral value used to initialize bits [79:64] of the result. +/// \param __w5 +/// A 16-bit integral value used to initialize bits [95:80] of the result. +/// \param __w6 +/// A 16-bit integral value used to initialize bits [111:96] of the result. +/// \param __w7 +/// A 16-bit integral value used to initialize bits [127:112] of the result. +/// \returns An initialized 128-bit integer vector. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_setr_epi16(short __w0, short __w1, short __w2, short __w3, short __w4, + short __w5, short __w6, short __w7) { + return _mm_set_epi16(__w7, __w6, __w5, __w4, __w3, __w2, __w1, __w0); +} + +/// Constructs a 128-bit integer vector, initialized in reverse order +/// with the specified 8-bit integral values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b0 +/// An 8-bit integral value used to initialize bits [7:0] of the result. +/// \param __b1 +/// An 8-bit integral value used to initialize bits [15:8] of the result. +/// \param __b2 +/// An 8-bit integral value used to initialize bits [23:16] of the result. +/// \param __b3 +/// An 8-bit integral value used to initialize bits [31:24] of the result. +/// \param __b4 +/// An 8-bit integral value used to initialize bits [39:32] of the result. +/// \param __b5 +/// An 8-bit integral value used to initialize bits [47:40] of the result. +/// \param __b6 +/// An 8-bit integral value used to initialize bits [55:48] of the result. +/// \param __b7 +/// An 8-bit integral value used to initialize bits [63:56] of the result. +/// \param __b8 +/// An 8-bit integral value used to initialize bits [71:64] of the result. +/// \param __b9 +/// An 8-bit integral value used to initialize bits [79:72] of the result. +/// \param __b10 +/// An 8-bit integral value used to initialize bits [87:80] of the result. +/// \param __b11 +/// An 8-bit integral value used to initialize bits [95:88] of the result. +/// \param __b12 +/// An 8-bit integral value used to initialize bits [103:96] of the result. +/// \param __b13 +/// An 8-bit integral value used to initialize bits [111:104] of the result. +/// \param __b14 +/// An 8-bit integral value used to initialize bits [119:112] of the result. +/// \param __b15 +/// An 8-bit integral value used to initialize bits [127:120] of the result. +/// \returns An initialized 128-bit integer vector. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_setr_epi8(char __b0, char __b1, char __b2, char __b3, char __b4, char __b5, + char __b6, char __b7, char __b8, char __b9, char __b10, + char __b11, char __b12, char __b13, char __b14, char __b15) { + return _mm_set_epi8(__b15, __b14, __b13, __b12, __b11, __b10, __b9, __b8, + __b7, __b6, __b5, __b4, __b3, __b2, __b1, __b0); +} + +/// Creates a 128-bit integer vector initialized to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS / XORPS instruction. +/// +/// \returns An initialized 128-bit integer vector with all elements set to +/// zero. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR _mm_setzero_si128(void) { + return __extension__(__m128i)(__v2di){0LL, 0LL}; +} + +/// Stores a 128-bit integer vector to a memory location aligned on a +/// 128-bit boundary. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS / MOVAPS instruction. +/// +/// \param __p +/// A pointer to an aligned memory location that will receive the integer +/// values. +/// \param __b +/// A 128-bit integer vector containing the values to be moved. +static __inline__ void __DEFAULT_FN_ATTRS _mm_store_si128(__m128i *__p, + __m128i __b) { + *__p = __b; +} + +/// Stores a 128-bit integer vector to an unaligned memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPS / MOVUPS instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the integer values. +/// \param __b +/// A 128-bit integer vector containing the values to be moved. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storeu_si128(__m128i_u *__p, + __m128i __b) { + struct __storeu_si128 { + __m128i_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_si128 *)__p)->__v = __b; +} + +/// Stores a 64-bit integer value from the low element of a 128-bit integer +/// vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction. +/// +/// \param __p +/// A pointer to a 64-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \param __b +/// A 128-bit integer vector containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storeu_si64(void *__p, + __m128i __b) { + struct __storeu_si64 { + long long __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_si64 *)__p)->__v = ((__v2di)__b)[0]; +} + +/// Stores a 32-bit integer value from the low element of a 128-bit integer +/// vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVD / MOVD instruction. +/// +/// \param __p +/// A pointer to a 32-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \param __b +/// A 128-bit integer vector containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storeu_si32(void *__p, + __m128i __b) { + struct __storeu_si32 { + int __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_si32 *)__p)->__v = ((__v4si)__b)[0]; +} + +/// Stores a 16-bit integer value from the low element of a 128-bit integer +/// vector. +/// +/// \headerfile +/// +/// This intrinsic does not correspond to a specific instruction. +/// +/// \param __p +/// A pointer to a 16-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \param __b +/// A 128-bit integer vector containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storeu_si16(void *__p, + __m128i __b) { + struct __storeu_si16 { + short __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_si16 *)__p)->__v = ((__v8hi)__b)[0]; +} + +/// Moves bytes selected by the mask from the first operand to the +/// specified unaligned memory location. When a mask bit is 1, the +/// corresponding byte is written, otherwise it is not written. +/// +/// To minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). Exception and trap behavior for elements not selected +/// for storage to memory are implementation dependent. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMASKMOVDQU / MASKMOVDQU +/// instruction. +/// +/// \param __d +/// A 128-bit integer vector containing the values to be moved. +/// \param __n +/// A 128-bit integer vector containing the mask. The most significant bit of +/// each byte represents the mask bits. +/// \param __p +/// A pointer to an unaligned 128-bit memory location where the specified +/// values are moved. +static __inline__ void __DEFAULT_FN_ATTRS _mm_maskmoveu_si128(__m128i __d, + __m128i __n, + char *__p) { + __builtin_ia32_maskmovdqu((__v16qi)__d, (__v16qi)__n, __p); +} + +/// Stores the lower 64 bits of a 128-bit integer vector of [2 x i64] to +/// a memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVLPS / MOVLPS instruction. +/// +/// \param __p +/// A pointer to a 64-bit memory location that will receive the lower 64 bits +/// of the integer vector parameter. +/// \param __a +/// A 128-bit integer vector of [2 x i64]. The lower 64 bits contain the +/// value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_storel_epi64(__m128i_u *__p, + __m128i __a) { + struct __mm_storel_epi64_struct { + long long __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_storel_epi64_struct *)__p)->__u = __a[0]; +} + +/// Stores a 128-bit floating point vector of [2 x double] to a 128-bit +/// aligned memory location. +/// +/// To minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTPS / MOVNTPS instruction. +/// +/// \param __p +/// A pointer to the 128-bit aligned memory location used to store the value. +/// \param __a +/// A vector of [2 x double] containing the 64-bit values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_stream_pd(void *__p, + __m128d __a) { + __builtin_nontemporal_store((__v2df)__a, (__v2df *)__p); +} + +/// Stores a 128-bit integer vector to a 128-bit aligned memory location. +/// +/// To minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTPS / MOVNTPS instruction. +/// +/// \param __p +/// A pointer to the 128-bit aligned memory location used to store the value. +/// \param __a +/// A 128-bit integer vector containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS _mm_stream_si128(void *__p, + __m128i __a) { + __builtin_nontemporal_store((__v2di)__a, (__v2di *)__p); +} + +/// Stores a 32-bit integer value in the specified memory location. +/// +/// To minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVNTI instruction. +/// +/// \param __p +/// A pointer to the 32-bit memory location used to store the value. +/// \param __a +/// A 32-bit integer containing the value to be stored. +static __inline__ void + __attribute__((__always_inline__, __nodebug__, __target__("sse2"))) + _mm_stream_si32(void *__p, int __a) { + __builtin_ia32_movnti((int *)__p, __a); +} + +#ifdef __x86_64__ +/// Stores a 64-bit integer value in the specified memory location. +/// +/// To minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVNTIQ instruction. +/// +/// \param __p +/// A pointer to the 64-bit memory location used to store the value. +/// \param __a +/// A 64-bit integer containing the value to be stored. +static __inline__ void + __attribute__((__always_inline__, __nodebug__, __target__("sse2"))) + _mm_stream_si64(void *__p, long long __a) { + __builtin_ia32_movnti64((long long *)__p, __a); +} +#endif + +#if defined(__cplusplus) +extern "C" { +#endif + +/// The cache line containing \a __p is flushed and invalidated from all +/// caches in the coherency domain. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CLFLUSH instruction. +/// +/// \param __p +/// A pointer to the memory location used to identify the cache line to be +/// flushed. +void _mm_clflush(void const *__p); + +/// Forces strong memory ordering (serialization) between load +/// instructions preceding this instruction and load instructions following +/// this instruction, ensuring the system completes all previous loads before +/// executing subsequent loads. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LFENCE instruction. +/// +void _mm_lfence(void); + +/// Forces strong memory ordering (serialization) between load and store +/// instructions preceding this instruction and load and store instructions +/// following this instruction, ensuring that the system completes all +/// previous memory accesses before executing subsequent memory accesses. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MFENCE instruction. +/// +void _mm_mfence(void); + +#if defined(__cplusplus) +} // extern "C" +#endif + +/// Converts, with saturation, 16-bit signed integers from both 128-bit integer +/// vector operands into 8-bit signed integers, and packs the results into +/// the destination. +/// +/// Positive values greater than 0x7F are saturated to 0x7F. Negative values +/// less than 0x80 are saturated to 0x80. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPACKSSWB / PACKSSWB instruction. +/// +/// \param __a +/// A 128-bit integer vector of [8 x i16]. The converted [8 x i8] values are +/// written to the lower 64 bits of the result. +/// \param __b +/// A 128-bit integer vector of [8 x i16]. The converted [8 x i8] values are +/// written to the higher 64 bits of the result. +/// \returns A 128-bit vector of [16 x i8] containing the converted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_packs_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_packsswb128((__v8hi)__a, (__v8hi)__b); +} + +/// Converts, with saturation, 32-bit signed integers from both 128-bit integer +/// vector operands into 16-bit signed integers, and packs the results into +/// the destination. +/// +/// Positive values greater than 0x7FFF are saturated to 0x7FFF. Negative +/// values less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPACKSSDW / PACKSSDW instruction. +/// +/// \param __a +/// A 128-bit integer vector of [4 x i32]. The converted [4 x i16] values +/// are written to the lower 64 bits of the result. +/// \param __b +/// A 128-bit integer vector of [4 x i32]. The converted [4 x i16] values +/// are written to the higher 64 bits of the result. +/// \returns A 128-bit vector of [8 x i16] containing the converted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_packs_epi32(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_packssdw128((__v4si)__a, (__v4si)__b); +} + +/// Converts, with saturation, 16-bit signed integers from both 128-bit integer +/// vector operands into 8-bit unsigned integers, and packs the results into +/// the destination. +/// +/// Values greater than 0xFF are saturated to 0xFF. Values less than 0x00 +/// are saturated to 0x00. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPACKUSWB / PACKUSWB instruction. +/// +/// \param __a +/// A 128-bit integer vector of [8 x i16]. The converted [8 x i8] values are +/// written to the lower 64 bits of the result. +/// \param __b +/// A 128-bit integer vector of [8 x i16]. The converted [8 x i8] values are +/// written to the higher 64 bits of the result. +/// \returns A 128-bit vector of [16 x i8] containing the converted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_packus_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_ia32_packuswb128((__v8hi)__a, (__v8hi)__b); +} + +/// Extracts 16 bits from a 128-bit integer vector of [8 x i16], using +/// the immediate-value parameter as a selector. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_extract_epi16(__m128i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPEXTRW / PEXTRW instruction. +/// +/// \param a +/// A 128-bit integer vector. +/// \param imm +/// An immediate value. Bits [2:0] selects values from \a a to be assigned +/// to bits[15:0] of the result. \n +/// 000: assign values from bits [15:0] of \a a. \n +/// 001: assign values from bits [31:16] of \a a. \n +/// 010: assign values from bits [47:32] of \a a. \n +/// 011: assign values from bits [63:48] of \a a. \n +/// 100: assign values from bits [79:64] of \a a. \n +/// 101: assign values from bits [95:80] of \a a. \n +/// 110: assign values from bits [111:96] of \a a. \n +/// 111: assign values from bits [127:112] of \a a. +/// \returns An integer, whose lower 16 bits are selected from the 128-bit +/// integer vector parameter and the remaining bits are assigned zeros. +#define _mm_extract_epi16(a, imm) \ + ((int)(unsigned short)__builtin_ia32_vec_ext_v8hi((__v8hi)(__m128i)(a), \ + (int)(imm))) + +/// Constructs a 128-bit integer vector by first making a copy of the +/// 128-bit integer vector parameter, and then inserting the lower 16 bits +/// of an integer parameter into an offset specified by the immediate-value +/// parameter. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_insert_epi16(__m128i a, int b, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPINSRW / PINSRW instruction. +/// +/// \param a +/// A 128-bit integer vector of [8 x i16]. This vector is copied to the +/// result and then one of the eight elements in the result is replaced by +/// the lower 16 bits of \a b. +/// \param b +/// An integer. The lower 16 bits of this parameter are written to the +/// result beginning at an offset specified by \a imm. +/// \param imm +/// An immediate value specifying the bit offset in the result at which the +/// lower 16 bits of \a b are written. +/// \returns A 128-bit integer vector containing the constructed values. +#define _mm_insert_epi16(a, b, imm) \ + ((__m128i)__builtin_ia32_vec_set_v8hi((__v8hi)(__m128i)(a), (int)(b), \ + (int)(imm))) + +/// Copies the values of the most significant bits from each 8-bit +/// element in a 128-bit integer vector of [16 x i8] to create a 16-bit mask +/// value, zero-extends the value, and writes it to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVMSKB / PMOVMSKB instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the values with bits to be extracted. +/// \returns The most significant bits from each 8-bit element in \a __a, +/// written to bits [15:0]. The other bits are assigned zeros. +static __inline__ int __DEFAULT_FN_ATTRS _mm_movemask_epi8(__m128i __a) { + return __builtin_ia32_pmovmskb128((__v16qi)__a); +} + +/// Constructs a 128-bit integer vector by shuffling four 32-bit +/// elements of a 128-bit integer vector parameter, using the immediate-value +/// parameter as a specifier. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_shuffle_epi32(__m128i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPSHUFD / PSHUFD instruction. +/// +/// \param a +/// A 128-bit integer vector containing the values to be copied. +/// \param imm +/// An immediate value containing an 8-bit value specifying which elements to +/// copy from a. The destinations within the 128-bit destination are assigned +/// values as follows: \n +/// Bits [1:0] are used to assign values to bits [31:0] of the result. \n +/// Bits [3:2] are used to assign values to bits [63:32] of the result. \n +/// Bits [5:4] are used to assign values to bits [95:64] of the result. \n +/// Bits [7:6] are used to assign values to bits [127:96] of the result. \n +/// Bit value assignments: \n +/// 00: assign values from bits [31:0] of \a a. \n +/// 01: assign values from bits [63:32] of \a a. \n +/// 10: assign values from bits [95:64] of \a a. \n +/// 11: assign values from bits [127:96] of \a a. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE macro. +/// _MM_SHUFFLE(b6, b4, b2, b0) can create an 8-bit mask of the form +/// [b6, b4, b2, b0]. +/// \returns A 128-bit integer vector containing the shuffled values. +#define _mm_shuffle_epi32(a, imm) \ + ((__m128i)__builtin_ia32_pshufd((__v4si)(__m128i)(a), (int)(imm))) + +/// Constructs a 128-bit integer vector by shuffling four lower 16-bit +/// elements of a 128-bit integer vector of [8 x i16], using the immediate +/// value parameter as a specifier. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_shufflelo_epi16(__m128i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPSHUFLW / PSHUFLW instruction. +/// +/// \param a +/// A 128-bit integer vector of [8 x i16]. Bits [127:64] are copied to bits +/// [127:64] of the result. +/// \param imm +/// An 8-bit immediate value specifying which elements to copy from \a a. \n +/// Bits[1:0] are used to assign values to bits [15:0] of the result. \n +/// Bits[3:2] are used to assign values to bits [31:16] of the result. \n +/// Bits[5:4] are used to assign values to bits [47:32] of the result. \n +/// Bits[7:6] are used to assign values to bits [63:48] of the result. \n +/// Bit value assignments: \n +/// 00: assign values from bits [15:0] of \a a. \n +/// 01: assign values from bits [31:16] of \a a. \n +/// 10: assign values from bits [47:32] of \a a. \n +/// 11: assign values from bits [63:48] of \a a. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE macro. +/// _MM_SHUFFLE(b6, b4, b2, b0) can create an 8-bit mask of the form +/// [b6, b4, b2, b0]. +/// \returns A 128-bit integer vector containing the shuffled values. +#define _mm_shufflelo_epi16(a, imm) \ + ((__m128i)__builtin_ia32_pshuflw((__v8hi)(__m128i)(a), (int)(imm))) + +/// Constructs a 128-bit integer vector by shuffling four upper 16-bit +/// elements of a 128-bit integer vector of [8 x i16], using the immediate +/// value parameter as a specifier. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_shufflehi_epi16(__m128i a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VPSHUFHW / PSHUFHW instruction. +/// +/// \param a +/// A 128-bit integer vector of [8 x i16]. Bits [63:0] are copied to bits +/// [63:0] of the result. +/// \param imm +/// An 8-bit immediate value specifying which elements to copy from \a a. \n +/// Bits[1:0] are used to assign values to bits [79:64] of the result. \n +/// Bits[3:2] are used to assign values to bits [95:80] of the result. \n +/// Bits[5:4] are used to assign values to bits [111:96] of the result. \n +/// Bits[7:6] are used to assign values to bits [127:112] of the result. \n +/// Bit value assignments: \n +/// 00: assign values from bits [79:64] of \a a. \n +/// 01: assign values from bits [95:80] of \a a. \n +/// 10: assign values from bits [111:96] of \a a. \n +/// 11: assign values from bits [127:112] of \a a. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE macro. +/// _MM_SHUFFLE(b6, b4, b2, b0) can create an 8-bit mask of the form +/// [b6, b4, b2, b0]. +/// \returns A 128-bit integer vector containing the shuffled values. +#define _mm_shufflehi_epi16(a, imm) \ + ((__m128i)__builtin_ia32_pshufhw((__v8hi)(__m128i)(a), (int)(imm))) + +/// Unpacks the high-order (index 8-15) values from two 128-bit vectors +/// of [16 x i8] and interleaves them into a 128-bit vector of [16 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKHBW / PUNPCKHBW +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [16 x i8]. +/// Bits [71:64] are written to bits [7:0] of the result. \n +/// Bits [79:72] are written to bits [23:16] of the result. \n +/// Bits [87:80] are written to bits [39:32] of the result. \n +/// Bits [95:88] are written to bits [55:48] of the result. \n +/// Bits [103:96] are written to bits [71:64] of the result. \n +/// Bits [111:104] are written to bits [87:80] of the result. \n +/// Bits [119:112] are written to bits [103:96] of the result. \n +/// Bits [127:120] are written to bits [119:112] of the result. +/// \param __b +/// A 128-bit vector of [16 x i8]. \n +/// Bits [71:64] are written to bits [15:8] of the result. \n +/// Bits [79:72] are written to bits [31:24] of the result. \n +/// Bits [87:80] are written to bits [47:40] of the result. \n +/// Bits [95:88] are written to bits [63:56] of the result. \n +/// Bits [103:96] are written to bits [79:72] of the result. \n +/// Bits [111:104] are written to bits [95:88] of the result. \n +/// Bits [119:112] are written to bits [111:104] of the result. \n +/// Bits [127:120] are written to bits [127:120] of the result. +/// \returns A 128-bit vector of [16 x i8] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpackhi_epi8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector( + (__v16qi)__a, (__v16qi)__b, 8, 16 + 8, 9, 16 + 9, 10, 16 + 10, 11, + 16 + 11, 12, 16 + 12, 13, 16 + 13, 14, 16 + 14, 15, 16 + 15); +} + +/// Unpacks the high-order (index 4-7) values from two 128-bit vectors of +/// [8 x i16] and interleaves them into a 128-bit vector of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKHWD / PUNPCKHWD +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16]. +/// Bits [79:64] are written to bits [15:0] of the result. \n +/// Bits [95:80] are written to bits [47:32] of the result. \n +/// Bits [111:96] are written to bits [79:64] of the result. \n +/// Bits [127:112] are written to bits [111:96] of the result. +/// \param __b +/// A 128-bit vector of [8 x i16]. +/// Bits [79:64] are written to bits [31:16] of the result. \n +/// Bits [95:80] are written to bits [63:48] of the result. \n +/// Bits [111:96] are written to bits [95:80] of the result. \n +/// Bits [127:112] are written to bits [127:112] of the result. +/// \returns A 128-bit vector of [8 x i16] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpackhi_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 4, 8 + 4, 5, + 8 + 5, 6, 8 + 6, 7, 8 + 7); +} + +/// Unpacks the high-order (index 2,3) values from two 128-bit vectors of +/// [4 x i32] and interleaves them into a 128-bit vector of [4 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKHDQ / PUNPCKHDQ +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32]. \n +/// Bits [95:64] are written to bits [31:0] of the destination. \n +/// Bits [127:96] are written to bits [95:64] of the destination. +/// \param __b +/// A 128-bit vector of [4 x i32]. \n +/// Bits [95:64] are written to bits [64:32] of the destination. \n +/// Bits [127:96] are written to bits [127:96] of the destination. +/// \returns A 128-bit vector of [4 x i32] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpackhi_epi32(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 2, 4 + 2, 3, + 4 + 3); +} + +/// Unpacks the high-order 64-bit elements from two 128-bit vectors of +/// [2 x i64] and interleaves them into a 128-bit vector of [2 x i64]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKHQDQ / PUNPCKHQDQ +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x i64]. \n +/// Bits [127:64] are written to bits [63:0] of the destination. +/// \param __b +/// A 128-bit vector of [2 x i64]. \n +/// Bits [127:64] are written to bits [127:64] of the destination. +/// \returns A 128-bit vector of [2 x i64] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpackhi_epi64(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 1, 2 + 1); +} + +/// Unpacks the low-order (index 0-7) values from two 128-bit vectors of +/// [16 x i8] and interleaves them into a 128-bit vector of [16 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKLBW / PUNPCKLBW +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [16 x i8]. \n +/// Bits [7:0] are written to bits [7:0] of the result. \n +/// Bits [15:8] are written to bits [23:16] of the result. \n +/// Bits [23:16] are written to bits [39:32] of the result. \n +/// Bits [31:24] are written to bits [55:48] of the result. \n +/// Bits [39:32] are written to bits [71:64] of the result. \n +/// Bits [47:40] are written to bits [87:80] of the result. \n +/// Bits [55:48] are written to bits [103:96] of the result. \n +/// Bits [63:56] are written to bits [119:112] of the result. +/// \param __b +/// A 128-bit vector of [16 x i8]. +/// Bits [7:0] are written to bits [15:8] of the result. \n +/// Bits [15:8] are written to bits [31:24] of the result. \n +/// Bits [23:16] are written to bits [47:40] of the result. \n +/// Bits [31:24] are written to bits [63:56] of the result. \n +/// Bits [39:32] are written to bits [79:72] of the result. \n +/// Bits [47:40] are written to bits [95:88] of the result. \n +/// Bits [55:48] are written to bits [111:104] of the result. \n +/// Bits [63:56] are written to bits [127:120] of the result. +/// \returns A 128-bit vector of [16 x i8] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpacklo_epi8(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector( + (__v16qi)__a, (__v16qi)__b, 0, 16 + 0, 1, 16 + 1, 2, 16 + 2, 3, 16 + 3, 4, + 16 + 4, 5, 16 + 5, 6, 16 + 6, 7, 16 + 7); +} + +/// Unpacks the low-order (index 0-3) values from each of the two 128-bit +/// vectors of [8 x i16] and interleaves them into a 128-bit vector of +/// [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKLWD / PUNPCKLWD +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16]. +/// Bits [15:0] are written to bits [15:0] of the result. \n +/// Bits [31:16] are written to bits [47:32] of the result. \n +/// Bits [47:32] are written to bits [79:64] of the result. \n +/// Bits [63:48] are written to bits [111:96] of the result. +/// \param __b +/// A 128-bit vector of [8 x i16]. +/// Bits [15:0] are written to bits [31:16] of the result. \n +/// Bits [31:16] are written to bits [63:48] of the result. \n +/// Bits [47:32] are written to bits [95:80] of the result. \n +/// Bits [63:48] are written to bits [127:112] of the result. +/// \returns A 128-bit vector of [8 x i16] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpacklo_epi16(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector((__v8hi)__a, (__v8hi)__b, 0, 8 + 0, 1, + 8 + 1, 2, 8 + 2, 3, 8 + 3); +} + +/// Unpacks the low-order (index 0,1) values from two 128-bit vectors of +/// [4 x i32] and interleaves them into a 128-bit vector of [4 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKLDQ / PUNPCKLDQ +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32]. \n +/// Bits [31:0] are written to bits [31:0] of the destination. \n +/// Bits [63:32] are written to bits [95:64] of the destination. +/// \param __b +/// A 128-bit vector of [4 x i32]. \n +/// Bits [31:0] are written to bits [64:32] of the destination. \n +/// Bits [63:32] are written to bits [127:96] of the destination. +/// \returns A 128-bit vector of [4 x i32] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpacklo_epi32(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector((__v4si)__a, (__v4si)__b, 0, 4 + 0, 1, + 4 + 1); +} + +/// Unpacks the low-order 64-bit elements from two 128-bit vectors of +/// [2 x i64] and interleaves them into a 128-bit vector of [2 x i64]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPUNPCKLQDQ / PUNPCKLQDQ +/// instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x i64]. \n +/// Bits [63:0] are written to bits [63:0] of the destination. \n +/// \param __b +/// A 128-bit vector of [2 x i64]. \n +/// Bits [63:0] are written to bits [127:64] of the destination. \n +/// \returns A 128-bit vector of [2 x i64] containing the interleaved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_unpacklo_epi64(__m128i __a, + __m128i __b) { + return (__m128i)__builtin_shufflevector((__v2di)__a, (__v2di)__b, 0, 2 + 0); +} + +/// Returns the lower 64 bits of a 128-bit integer vector as a 64-bit +/// integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVDQ2Q instruction. +/// +/// \param __a +/// A 128-bit integer vector operand. The lower 64 bits are moved to the +/// destination. +/// \returns A 64-bit integer containing the lower 64 bits of the parameter. +static __inline__ __m64 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_movepi64_pi64(__m128i __a) { + return (__m64)__a[0]; +} + +/// Moves the 64-bit operand to a 128-bit integer vector, zeroing the +/// upper bits. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVD+VMOVQ instruction. +/// +/// \param __a +/// A 64-bit value. +/// \returns A 128-bit integer vector. The lower 64 bits contain the value from +/// the operand. The upper 64 bits are assigned zeros. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_movpi64_epi64(__m64 __a) { + return __builtin_shufflevector((__v1di)__a, _mm_setzero_si64(), 0, 1); +} + +/// Moves the lower 64 bits of a 128-bit integer vector to a 128-bit +/// integer vector, zeroing the upper bits. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVQ / MOVQ instruction. +/// +/// \param __a +/// A 128-bit integer vector operand. The lower 64 bits are moved to the +/// destination. +/// \returns A 128-bit integer vector. The lower 64 bits contain the value from +/// the operand. The upper 64 bits are assigned zeros. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_move_epi64(__m128i __a) { + return __builtin_shufflevector((__v2di)__a, _mm_setzero_si128(), 0, 2); +} + +/// Unpacks the high-order 64-bit elements from two 128-bit vectors of +/// [2 x double] and interleaves them into a 128-bit vector of [2 x +/// double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKHPD / UNPCKHPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. \n +/// Bits [127:64] are written to bits [63:0] of the destination. +/// \param __b +/// A 128-bit vector of [2 x double]. \n +/// Bits [127:64] are written to bits [127:64] of the destination. +/// \returns A 128-bit vector of [2 x double] containing the interleaved values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_unpackhi_pd(__m128d __a, __m128d __b) { + return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 1, 2 + 1); +} + +/// Unpacks the low-order 64-bit elements from two 128-bit vectors +/// of [2 x double] and interleaves them into a 128-bit vector of [2 x +/// double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD / UNPCKLPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. \n +/// Bits [63:0] are written to bits [63:0] of the destination. +/// \param __b +/// A 128-bit vector of [2 x double]. \n +/// Bits [63:0] are written to bits [127:64] of the destination. +/// \returns A 128-bit vector of [2 x double] containing the interleaved values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_unpacklo_pd(__m128d __a, __m128d __b) { + return __builtin_shufflevector((__v2df)__a, (__v2df)__b, 0, 2 + 0); +} + +/// Extracts the sign bits of the double-precision values in the 128-bit +/// vector of [2 x double], zero-extends the value, and writes it to the +/// low-order bits of the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVMSKPD / MOVMSKPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the values with sign bits to +/// be extracted. +/// \returns The sign bits from each of the double-precision elements in \a __a, +/// written to bits [1:0]. The remaining bits are assigned values of zero. +static __inline__ int __DEFAULT_FN_ATTRS _mm_movemask_pd(__m128d __a) { + return __builtin_ia32_movmskpd((__v2df)__a); +} + +/// Constructs a 128-bit floating-point vector of [2 x double] from two +/// 128-bit vector parameters of [2 x double], using the immediate-value +/// parameter as a specifier. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_shuffle_pd(__m128d a, __m128d b, const int i); +/// \endcode +/// +/// This intrinsic corresponds to the VSHUFPD / SHUFPD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double]. +/// \param b +/// A 128-bit vector of [2 x double]. +/// \param i +/// An 8-bit immediate value. The least significant two bits specify which +/// elements to copy from \a a and \a b: \n +/// Bit[0] = 0: lower element of \a a copied to lower element of result. \n +/// Bit[0] = 1: upper element of \a a copied to lower element of result. \n +/// Bit[1] = 0: lower element of \a b copied to upper element of result. \n +/// Bit[1] = 1: upper element of \a b copied to upper element of result. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE2 macro. +/// _MM_SHUFFLE2(b1, b0) can create a 2-bit mask of the form +/// [b1, b0]. +/// \returns A 128-bit vector of [2 x double] containing the shuffled values. +#define _mm_shuffle_pd(a, b, i) \ + ((__m128d)__builtin_ia32_shufpd((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \ + (int)(i))) + +/// Casts a 128-bit floating-point vector of [2 x double] into a 128-bit +/// floating-point vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [2 x double]. +/// \returns A 128-bit floating-point vector of [4 x float] containing the same +/// bitwise pattern as the parameter. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_castpd_ps(__m128d __a) { + return (__m128)__a; +} + +/// Casts a 128-bit floating-point vector of [2 x double] into a 128-bit +/// integer vector. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [2 x double]. +/// \returns A 128-bit integer vector containing the same bitwise pattern as the +/// parameter. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_castpd_si128(__m128d __a) { + return (__m128i)__a; +} + +/// Casts a 128-bit floating-point vector of [4 x float] into a 128-bit +/// floating-point vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. +/// \returns A 128-bit floating-point vector of [2 x double] containing the same +/// bitwise pattern as the parameter. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_castps_pd(__m128 __a) { + return (__m128d)__a; +} + +/// Casts a 128-bit floating-point vector of [4 x float] into a 128-bit +/// integer vector. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. +/// \returns A 128-bit integer vector containing the same bitwise pattern as the +/// parameter. +static __inline__ __m128i __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_castps_si128(__m128 __a) { + return (__m128i)__a; +} + +/// Casts a 128-bit integer vector into a 128-bit floating-point vector +/// of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \returns A 128-bit floating-point vector of [4 x float] containing the same +/// bitwise pattern as the parameter. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_castsi128_ps(__m128i __a) { + return (__m128)__a; +} + +/// Casts a 128-bit integer vector into a 128-bit floating-point vector +/// of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit integer vector. +/// \returns A 128-bit floating-point vector of [2 x double] containing the same +/// bitwise pattern as the parameter. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_castsi128_pd(__m128i __a) { + return (__m128d)__a; +} + +/// Compares each of the corresponding double-precision values of two +/// 128-bit vectors of [2 x double], using the operation specified by the +/// immediate integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_cmp_pd(__m128d a, __m128d b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the (V)CMPPD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double]. +/// \param b +/// A 128-bit vector of [2 x double]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// \returns A 128-bit vector of [2 x double] containing the comparison results. +#define _mm_cmp_pd(a, b, c) \ + ((__m128d)__builtin_ia32_cmppd((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \ + (c))) + +/// Compares each of the corresponding scalar double-precision values of +/// two 128-bit vectors of [2 x double], using the operation specified by the +/// immediate integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_cmp_sd(__m128d a, __m128d b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the (V)CMPSD instruction. +/// +/// \param a +/// A 128-bit vector of [2 x double]. +/// \param b +/// A 128-bit vector of [2 x double]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// \returns A 128-bit vector of [2 x double] containing the comparison results. +#define _mm_cmp_sd(a, b, c) \ + ((__m128d)__builtin_ia32_cmpsd((__v2df)(__m128d)(a), (__v2df)(__m128d)(b), \ + (c))) + +#if defined(__cplusplus) +extern "C" { +#endif + +/// Indicates that a spin loop is being executed for the purposes of +/// optimizing power consumption during the loop. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PAUSE instruction. +/// +void _mm_pause(void); + +#if defined(__cplusplus) +} // extern "C" +#endif + +#undef __anyext128 +#undef __trunc64 +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_CONSTEXPR + +#define _MM_SHUFFLE2(x, y) (((x) << 1) | (y)) + +#define _MM_DENORMALS_ZERO_ON (0x0040U) +#define _MM_DENORMALS_ZERO_OFF (0x0000U) + +#define _MM_DENORMALS_ZERO_MASK (0x0040U) + +#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK) +#define _MM_SET_DENORMALS_ZERO_MODE(x) \ + (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x))) + +#endif /* __EMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/enqcmdintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/enqcmdintrin.h new file mode 100755 index 0000000..30af67f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/enqcmdintrin.h @@ -0,0 +1,63 @@ +/*===------------------ enqcmdintrin.h - enqcmd intrinsics -----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __ENQCMDINTRIN_H +#define __ENQCMDINTRIN_H + +/* Define the default attributes for the functions in this file */ +#define _DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("enqcmd"))) + +/// Reads 64-byte command pointed by \a __src, formats 64-byte enqueue store +/// data, and performs 64-byte enqueue store to memory pointed by \a __dst. +/// This intrinsics may only be used in User mode. +/// +/// \headerfile +/// +/// This intrinsics corresponds to the ENQCMD instruction. +/// +/// \param __dst +/// Pointer to the destination of the enqueue store. +/// \param __src +/// Pointer to 64-byte command data. +/// \returns If the command data is successfully written to \a __dst then 0 is +/// returned. Otherwise 1 is returned. +static __inline__ int _DEFAULT_FN_ATTRS +_enqcmd (void *__dst, const void *__src) +{ + return __builtin_ia32_enqcmd(__dst, __src); +} + +/// Reads 64-byte command pointed by \a __src, formats 64-byte enqueue store +/// data, and performs 64-byte enqueue store to memory pointed by \a __dst +/// This intrinsic may only be used in Privileged mode. +/// +/// \headerfile +/// +/// This intrinsics corresponds to the ENQCMDS instruction. +/// +/// \param __dst +/// Pointer to the destination of the enqueue store. +/// \param __src +/// Pointer to 64-byte command data. +/// \returns If the command data is successfully written to \a __dst then 0 is +/// returned. Otherwise 1 is returned. +static __inline__ int _DEFAULT_FN_ATTRS +_enqcmds (void *__dst, const void *__src) +{ + return __builtin_ia32_enqcmds(__dst, __src); +} + +#undef _DEFAULT_FN_ATTRS + +#endif /* __ENQCMDINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/f16cintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/f16cintrin.h new file mode 100755 index 0000000..94a662c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/f16cintrin.h @@ -0,0 +1,162 @@ +/*===---- f16cintrin.h - F16C intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __F16CINTRIN_H +#define __F16CINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("f16c"), __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("f16c"), __min_vector_width__(256))) + +/* NOTE: Intel documents the 128-bit versions of these as being in emmintrin.h, + * but that's because icc can emulate these without f16c using a library call. + * Since we don't do that let's leave these in f16cintrin.h. + */ + +/// Converts a 16-bit half-precision float value into a 32-bit float +/// value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPH2PS instruction. +/// +/// \param __a +/// A 16-bit half-precision float value. +/// \returns The converted 32-bit float value. +static __inline float __DEFAULT_FN_ATTRS128 +_cvtsh_ss(unsigned short __a) +{ + __v8hi __v = {(short)__a, 0, 0, 0, 0, 0, 0, 0}; + __v4sf __r = __builtin_ia32_vcvtph2ps(__v); + return __r[0]; +} + +/// Converts a 32-bit single-precision float value to a 16-bit +/// half-precision float value. +/// +/// \headerfile +/// +/// \code +/// unsigned short _cvtss_sh(float a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VCVTPS2PH instruction. +/// +/// \param a +/// A 32-bit single-precision float value to be converted to a 16-bit +/// half-precision float value. +/// \param imm +/// An immediate value controlling rounding using bits [2:0]: \n +/// 000: Nearest \n +/// 001: Down \n +/// 010: Up \n +/// 011: Truncate \n +/// 1XX: Use MXCSR.RC for rounding +/// \returns The converted 16-bit half-precision float value. +#define _cvtss_sh(a, imm) __extension__ ({ \ + (unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \ + (imm)))[0]); }) + +/// Converts a 128-bit vector containing 32-bit float values into a +/// 128-bit vector containing 16-bit half-precision float values. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_cvtps_ph(__m128 a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VCVTPS2PH instruction. +/// +/// \param a +/// A 128-bit vector containing 32-bit float values. +/// \param imm +/// An immediate value controlling rounding using bits [2:0]: \n +/// 000: Nearest \n +/// 001: Down \n +/// 010: Up \n +/// 011: Truncate \n +/// 1XX: Use MXCSR.RC for rounding +/// \returns A 128-bit vector containing converted 16-bit half-precision float +/// values. The lower 64 bits are used to store the converted 16-bit +/// half-precision floating-point values. +#define _mm_cvtps_ph(a, imm) \ + ((__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm))) + +/// Converts a 128-bit vector containing 16-bit half-precision float +/// values into a 128-bit vector containing 32-bit float values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPH2PS instruction. +/// +/// \param __a +/// A 128-bit vector containing 16-bit half-precision float values. The lower +/// 64 bits are used in the conversion. +/// \returns A 128-bit vector of [4 x float] containing converted float values. +static __inline __m128 __DEFAULT_FN_ATTRS128 +_mm_cvtph_ps(__m128i __a) +{ + return (__m128)__builtin_ia32_vcvtph2ps((__v8hi)__a); +} + +/// Converts a 256-bit vector of [8 x float] into a 128-bit vector +/// containing 16-bit half-precision float values. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm256_cvtps_ph(__m256 a, const int imm); +/// \endcode +/// +/// This intrinsic corresponds to the VCVTPS2PH instruction. +/// +/// \param a +/// A 256-bit vector containing 32-bit single-precision float values to be +/// converted to 16-bit half-precision float values. +/// \param imm +/// An immediate value controlling rounding using bits [2:0]: \n +/// 000: Nearest \n +/// 001: Down \n +/// 010: Up \n +/// 011: Truncate \n +/// 1XX: Use MXCSR.RC for rounding +/// \returns A 128-bit vector containing the converted 16-bit half-precision +/// float values. +#define _mm256_cvtps_ph(a, imm) \ + ((__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm))) + +/// Converts a 128-bit vector containing 16-bit half-precision float +/// values into a 256-bit vector of [8 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTPH2PS instruction. +/// +/// \param __a +/// A 128-bit vector containing 16-bit half-precision float values to be +/// converted to 32-bit single-precision float values. +/// \returns A vector of [8 x float] containing the converted 32-bit +/// single-precision float values. +static __inline __m256 __DEFAULT_FN_ATTRS256 +_mm256_cvtph_ps(__m128i __a) +{ + return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __F16CINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/float.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/float.h new file mode 100755 index 0000000..84551af --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/float.h @@ -0,0 +1,187 @@ +/*===---- float.h - Characteristics of floating point types ----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_FLOAT_H +#define __CLANG_FLOAT_H + +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +/* If we're on MinGW, fall back to the system's float.h, which might have + * additional definitions provided for Windows. + * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx + * + * Also fall back on AIX to allow additional definitions and + * implementation-defined values. + */ +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(_AIX)) && \ + __STDC_HOSTED__ && __has_include_next() + +# include_next + +/* Undefine anything that we'll be redefining below. */ +# undef FLT_EVAL_METHOD +# undef FLT_ROUNDS +# undef FLT_RADIX +# undef FLT_MANT_DIG +# undef DBL_MANT_DIG +# undef LDBL_MANT_DIG +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# undef DECIMAL_DIG +# endif +# undef FLT_DIG +# undef DBL_DIG +# undef LDBL_DIG +# undef FLT_MIN_EXP +# undef DBL_MIN_EXP +# undef LDBL_MIN_EXP +# undef FLT_MIN_10_EXP +# undef DBL_MIN_10_EXP +# undef LDBL_MIN_10_EXP +# undef FLT_MAX_EXP +# undef DBL_MAX_EXP +# undef LDBL_MAX_EXP +# undef FLT_MAX_10_EXP +# undef DBL_MAX_10_EXP +# undef LDBL_MAX_10_EXP +# undef FLT_MAX +# undef DBL_MAX +# undef LDBL_MAX +# undef FLT_EPSILON +# undef DBL_EPSILON +# undef LDBL_EPSILON +# undef FLT_MIN +# undef DBL_MIN +# undef LDBL_MIN +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# undef FLT_TRUE_MIN +# undef DBL_TRUE_MIN +# undef LDBL_TRUE_MIN +# undef FLT_DECIMAL_DIG +# undef DBL_DECIMAL_DIG +# undef LDBL_DECIMAL_DIG +# undef FLT_HAS_SUBNORM +# undef DBL_HAS_SUBNORM +# undef LDBL_HAS_SUBNORM +# endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) +# undef FLT_NORM_MAX +# undef DBL_NORM_MAX +# undef LDBL_NORM_MAX +#endif +#endif + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) +# undef INFINITY +# undef NAN +#endif + +/* Characteristics of floating point types, C99 5.2.4.2.2 */ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif +#define FLT_ROUNDS (__builtin_flt_rounds()) +#define FLT_RADIX __FLT_RADIX__ + +#define FLT_MANT_DIG __FLT_MANT_DIG__ +#define DBL_MANT_DIG __DBL_MANT_DIG__ +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#define FLT_DIG __FLT_DIG__ +#define DBL_DIG __DBL_DIG__ +#define LDBL_DIG __LDBL_DIG__ + +#define FLT_MIN_EXP __FLT_MIN_EXP__ +#define DBL_MIN_EXP __DBL_MIN_EXP__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ + +#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ +#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ + +#define FLT_MAX_EXP __FLT_MAX_EXP__ +#define DBL_MAX_EXP __DBL_MAX_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ + +#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ +#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ + +#define FLT_MAX __FLT_MAX__ +#define DBL_MAX __DBL_MAX__ +#define LDBL_MAX __LDBL_MAX__ + +#define FLT_EPSILON __FLT_EPSILON__ +#define DBL_EPSILON __DBL_EPSILON__ +#define LDBL_EPSILON __LDBL_EPSILON__ + +#define FLT_MIN __FLT_MIN__ +#define DBL_MIN __DBL_MIN__ +#define LDBL_MIN __LDBL_MIN__ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# define FLT_TRUE_MIN __FLT_DENORM_MIN__ +# define DBL_TRUE_MIN __DBL_DENORM_MIN__ +# define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ +# define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ +# define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ +# define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ +# define FLT_HAS_SUBNORM __FLT_HAS_DENORM__ +# define DBL_HAS_SUBNORM __DBL_HAS_DENORM__ +# define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ +#endif + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) + /* C23 5.2.5.3.3p29-30 */ +# define INFINITY (__builtin_inff()) +# define NAN (__builtin_nanf("")) + /* C23 5.2.5.3.3p32 */ +# define FLT_NORM_MAX __FLT_NORM_MAX__ +# define DBL_NORM_MAX __DBL_NORM_MAX__ +# define LDBL_NORM_MAX __LDBL_NORM_MAX__ +#endif + +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ +# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ +# define FLT16_DIG __FLT16_DIG__ +# define FLT16_MIN_EXP __FLT16_MIN_EXP__ +# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ +# define FLT16_MAX_EXP __FLT16_MAX_EXP__ +# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ +# define FLT16_MAX __FLT16_MAX__ +# define FLT16_EPSILON __FLT16_EPSILON__ +# define FLT16_MIN __FLT16_MIN__ +# define FLT16_TRUE_MIN __FLT16_TRUE_MIN__ +#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ + +#endif /* __MVS__ */ +#endif /* __CLANG_FLOAT_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fma4intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fma4intrin.h new file mode 100755 index 0000000..694801b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fma4intrin.h @@ -0,0 +1,218 @@ +/*===---- fma4intrin.h - FMA4 intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __FMA4INTRIN_H +#define __FMA4INTRIN_H + +#include + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("fma4"), __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("fma4"), __min_vector_width__(256))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_macc_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_macc_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_macc_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss((__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_macc_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd((__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_msub_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_msub_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_msub_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_msub_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd((__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_nmacc_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps(-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_nmacc_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd(-(__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_nmacc_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss(-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_nmacc_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd(-(__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_nmsub_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps(-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_nmsub_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd(-(__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_nmsub_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss(-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_nmsub_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd(-(__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_maddsub_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_maddsub_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_msubadd_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_msubadd_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_macc_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_macc_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256((__v4df)__A, (__v4df)__B, (__v4df)__C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_msub_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_msub_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256((__v4df)__A, (__v4df)__B, -(__v4df)__C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_nmacc_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256(-(__v8sf)__A, (__v8sf)__B, (__v8sf)__C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_nmacc_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256(-(__v4df)__A, (__v4df)__B, (__v4df)__C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_nmsub_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256(-(__v8sf)__A, (__v8sf)__B, -(__v8sf)__C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_nmsub_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256(-(__v4df)__A, (__v4df)__B, -(__v4df)__C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_maddsub_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_maddsub_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, (__v4df)__C); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_msubadd_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_msubadd_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, -(__v4df)__C); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __FMA4INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fmaintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fmaintrin.h new file mode 100755 index 0000000..22d1a78 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fmaintrin.h @@ -0,0 +1,796 @@ +/*===---- fmaintrin.h - FMA intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __FMAINTRIN_H +#define __FMAINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("fma"), __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("fma"), __min_vector_width__(256))) + +/// Computes a multiply-add of 128-bit vectors of [4 x float]. +/// For each element, computes (__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADD213PS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier. +/// \param __C +/// A 128-bit vector of [4 x float] containing the addend. +/// \returns A 128-bit vector of [4 x float] containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fmadd_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +/// Computes a multiply-add of 128-bit vectors of [2 x double]. +/// For each element, computes (__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADD213PD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend. +/// \returns A 128-bit [2 x double] vector containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fmadd_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +/// Computes a scalar multiply-add of the single-precision values in the +/// low 32 bits of 128-bit vectors of [4 x float]. +/// +/// \code{.operation} +/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0] +/// result[127:32] = __A[127:32] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADD213SS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand in the low +/// 32 bits. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier in the low +/// 32 bits. +/// \param __C +/// A 128-bit vector of [4 x float] containing the addend in the low +/// 32 bits. +/// \returns A 128-bit vector of [4 x float] containing the result in the low +/// 32 bits and a copy of \a __A[127:32] in the upper 96 bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fmadd_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +/// Computes a scalar multiply-add of the double-precision values in the +/// low 64 bits of 128-bit vectors of [2 x double]. +/// +/// \code{.operation} +/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0] +/// result[127:64] = __A[127:64] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADD213SD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand in the low +/// 64 bits. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier in the low +/// 64 bits. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend in the low +/// 64 bits. +/// \returns A 128-bit vector of [2 x double] containing the result in the low +/// 64 bits and a copy of \a __A[127:64] in the upper 64 bits. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fmadd_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +/// Computes a multiply-subtract of 128-bit vectors of [4 x float]. +/// For each element, computes (__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUB213PS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier. +/// \param __C +/// A 128-bit vector of [4 x float] containing the subtrahend. +/// \returns A 128-bit vector of [4 x float] containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fmsub_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +/// Computes a multiply-subtract of 128-bit vectors of [2 x double]. +/// For each element, computes (__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUB213PD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend. +/// \returns A 128-bit vector of [2 x double] containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fmsub_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd((__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +/// Computes a scalar multiply-subtract of the single-precision values in +/// the low 32 bits of 128-bit vectors of [4 x float]. +/// +/// \code{.operation} +/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0] +/// result[127:32] = __A[127:32] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUB213SS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand in the low +/// 32 bits. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier in the low +/// 32 bits. +/// \param __C +/// A 128-bit vector of [4 x float] containing the subtrahend in the low +/// 32 bits. +/// \returns A 128-bit vector of [4 x float] containing the result in the low +/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fmsub_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +/// Computes a scalar multiply-subtract of the double-precision values in +/// the low 64 bits of 128-bit vectors of [2 x double]. +/// +/// \code{.operation} +/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0] +/// result[127:64] = __A[127:64] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUB213SD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand in the low +/// 64 bits. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier in the low +/// 64 bits. +/// \param __C +/// A 128-bit vector of [2 x double] containing the subtrahend in the low +/// 64 bits. +/// \returns A 128-bit vector of [2 x double] containing the result in the low +/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fmsub_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +/// Computes a negated multiply-add of 128-bit vectors of [4 x float]. +/// For each element, computes -(__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMADD213DPS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier. +/// \param __C +/// A 128-bit vector of [4 x float] containing the addend. +/// \returns A 128-bit [4 x float] vector containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fnmadd_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps(-(__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +/// Computes a negated multiply-add of 128-bit vectors of [2 x double]. +/// For each element, computes -(__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMADD213PD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend. +/// \returns A 128-bit vector of [2 x double] containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fnmadd_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd(-(__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +/// Computes a scalar negated multiply-add of the single-precision values in +/// the low 32 bits of 128-bit vectors of [4 x float]. +/// +/// \code{.operation} +/// result[31:0] = -(__A[31:0] * __B[31:0]) + __C[31:0] +/// result[127:32] = __A[127:32] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMADD213SS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand in the low +/// 32 bits. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier in the low +/// 32 bits. +/// \param __C +/// A 128-bit vector of [4 x float] containing the addend in the low +/// 32 bits. +/// \returns A 128-bit vector of [4 x float] containing the result in the low +/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fnmadd_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, -(__v4sf)__B, (__v4sf)__C); +} + +/// Computes a scalar negated multiply-add of the double-precision values +/// in the low 64 bits of 128-bit vectors of [2 x double]. +/// +/// \code{.operation} +/// result[63:0] = -(__A[63:0] * __B[63:0]) + __C[63:0] +/// result[127:64] = __A[127:64] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMADD213SD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand in the low +/// 64 bits. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier in the low +/// 64 bits. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend in the low +/// 64 bits. +/// \returns A 128-bit vector of [2 x double] containing the result in the low +/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fnmadd_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, -(__v2df)__B, (__v2df)__C); +} + +/// Computes a negated multiply-subtract of 128-bit vectors of [4 x float]. +/// For each element, computes -(__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMSUB213PS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier. +/// \param __C +/// A 128-bit vector of [4 x float] containing the subtrahend. +/// \returns A 128-bit vector of [4 x float] containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fnmsub_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddps(-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +/// Computes a negated multiply-subtract of 128-bit vectors of [2 x double]. +/// For each element, computes -(__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMSUB213PD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier. +/// \param __C +/// A 128-bit vector of [2 x double] containing the subtrahend. +/// \returns A 128-bit vector of [2 x double] containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fnmsub_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddpd(-(__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +/// Computes a scalar negated multiply-subtract of the single-precision +/// values in the low 32 bits of 128-bit vectors of [4 x float]. +/// +/// \code{.operation} +/// result[31:0] = -(__A[31:0] * __B[31:0]) - __C[31:0] +/// result[127:32] = __A[127:32] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMSUB213SS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand in the low +/// 32 bits. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier in the low +/// 32 bits. +/// \param __C +/// A 128-bit vector of [4 x float] containing the subtrahend in the low +/// 32 bits. +/// \returns A 128-bit vector of [4 x float] containing the result in the low +/// 32 bits, and a copy of \a __A[127:32] in the upper 96 bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fnmsub_ss(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddss3((__v4sf)__A, -(__v4sf)__B, -(__v4sf)__C); +} + +/// Computes a scalar negated multiply-subtract of the double-precision +/// values in the low 64 bits of 128-bit vectors of [2 x double]. +/// +/// \code{.operation} +/// result[63:0] = -(__A[63:0] * __B[63:0]) - __C[63:0] +/// result[127:64] = __A[127:64] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMSUB213SD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand in the low +/// 64 bits. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier in the low +/// 64 bits. +/// \param __C +/// A 128-bit vector of [2 x double] containing the subtrahend in the low +/// 64 bits. +/// \returns A 128-bit vector of [2 x double] containing the result in the low +/// 64 bits, and a copy of \a __A[127:64] in the upper 64 bits. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fnmsub_sd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsd3((__v2df)__A, -(__v2df)__B, -(__v2df)__C); +} + +/// Computes a multiply with alternating add/subtract of 128-bit vectors of +/// [4 x float]. +/// +/// \code{.operation} +/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0] +/// result[63:32] = (__A[63:32] * __B[63:32]) + __C[63:32] +/// result[95:64] = (__A[95:64] * __B[95:64]) - __C[95:64] +/// result[127:96] = (__A[127:96] * __B[127:96]) + __C[127:96] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADDSUB213PS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier. +/// \param __C +/// A 128-bit vector of [4 x float] containing the addend/subtrahend. +/// \returns A 128-bit vector of [4 x float] containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fmaddsub_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, (__v4sf)__C); +} + +/// Computes a multiply with alternating add/subtract of 128-bit vectors of +/// [2 x double]. +/// +/// \code{.operation} +/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0] +/// result[127:64] = (__A[127:64] * __B[127:64]) + __C[127:64] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend/subtrahend. +/// \returns A 128-bit vector of [2 x double] containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fmaddsub_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, (__v2df)__C); +} + +/// Computes a multiply with alternating add/subtract of 128-bit vectors of +/// [4 x float]. +/// +/// \code{.operation} +/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0] +/// result[63:32] = (__A[63:32] * __B[63:32]) - __C[63:32] +/// result[95:64] = (__A[95:64] * __B[95:64]) + __C[95:64] +/// result[127:96 = (__A[127:96] * __B[127:96]) - __C[127:96] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUBADD213PS instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x float] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [4 x float] containing the multiplier. +/// \param __C +/// A 128-bit vector of [4 x float] containing the addend/subtrahend. +/// \returns A 128-bit vector of [4 x float] containing the result. +static __inline__ __m128 __DEFAULT_FN_ATTRS128 +_mm_fmsubadd_ps(__m128 __A, __m128 __B, __m128 __C) +{ + return (__m128)__builtin_ia32_vfmaddsubps((__v4sf)__A, (__v4sf)__B, -(__v4sf)__C); +} + +/// Computes a multiply with alternating add/subtract of 128-bit vectors of +/// [2 x double]. +/// +/// \code{.operation} +/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0] +/// result[127:64] = (__A[127:64] * __B[127:64]) - __C[127:64] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction. +/// +/// \param __A +/// A 128-bit vector of [2 x double] containing the multiplicand. +/// \param __B +/// A 128-bit vector of [2 x double] containing the multiplier. +/// \param __C +/// A 128-bit vector of [2 x double] containing the addend/subtrahend. +/// \returns A 128-bit vector of [2 x double] containing the result. +static __inline__ __m128d __DEFAULT_FN_ATTRS128 +_mm_fmsubadd_pd(__m128d __A, __m128d __B, __m128d __C) +{ + return (__m128d)__builtin_ia32_vfmaddsubpd((__v2df)__A, (__v2df)__B, -(__v2df)__C); +} + +/// Computes a multiply-add of 256-bit vectors of [8 x float]. +/// For each element, computes (__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADD213PS instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [8 x float] containing the multiplier. +/// \param __C +/// A 256-bit vector of [8 x float] containing the addend. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_fmadd_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C); +} + +/// Computes a multiply-add of 256-bit vectors of [4 x double]. +/// For each element, computes (__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADD213PD instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x double] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [4 x double] containing the multiplier. +/// \param __C +/// A 256-bit vector of [4 x double] containing the addend. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_fmadd_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256((__v4df)__A, (__v4df)__B, (__v4df)__C); +} + +/// Computes a multiply-subtract of 256-bit vectors of [8 x float]. +/// For each element, computes (__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUB213PS instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [8 x float] containing the multiplier. +/// \param __C +/// A 256-bit vector of [8 x float] containing the subtrahend. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_fmsub_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C); +} + +/// Computes a multiply-subtract of 256-bit vectors of [4 x double]. +/// For each element, computes (__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUB213PD instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x double] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [4 x double] containing the multiplier. +/// \param __C +/// A 256-bit vector of [4 x double] containing the subtrahend. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_fmsub_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256((__v4df)__A, (__v4df)__B, -(__v4df)__C); +} + +/// Computes a negated multiply-add of 256-bit vectors of [8 x float]. +/// For each element, computes -(__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMADD213PS instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [8 x float] containing the multiplier. +/// \param __C +/// A 256-bit vector of [8 x float] containing the addend. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_fnmadd_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256(-(__v8sf)__A, (__v8sf)__B, (__v8sf)__C); +} + +/// Computes a negated multiply-add of 256-bit vectors of [4 x double]. +/// For each element, computes -(__A * __B) + __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMADD213PD instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x double] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [4 x double] containing the multiplier. +/// \param __C +/// A 256-bit vector of [4 x double] containing the addend. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_fnmadd_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256(-(__v4df)__A, (__v4df)__B, (__v4df)__C); +} + +/// Computes a negated multiply-subtract of 256-bit vectors of [8 x float]. +/// For each element, computes -(__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMSUB213PS instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [8 x float] containing the multiplier. +/// \param __C +/// A 256-bit vector of [8 x float] containing the subtrahend. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_fnmsub_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddps256(-(__v8sf)__A, (__v8sf)__B, -(__v8sf)__C); +} + +/// Computes a negated multiply-subtract of 256-bit vectors of [4 x double]. +/// For each element, computes -(__A * __B) - __C . +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFNMSUB213PD instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x double] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [4 x double] containing the multiplier. +/// \param __C +/// A 256-bit vector of [4 x double] containing the subtrahend. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_fnmsub_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddpd256(-(__v4df)__A, (__v4df)__B, -(__v4df)__C); +} + +/// Computes a multiply with alternating add/subtract of 256-bit vectors of +/// [8 x float]. +/// +/// \code{.operation} +/// result[31:0] = (__A[31:0] * __B[31:0]) - __C[31:0] +/// result[63:32] = (__A[63:32] * __B[63:32]) + __C[63:32] +/// result[95:64] = (__A[95:64] * __B[95:64]) - __C[95:64] +/// result[127:96] = (__A[127:96] * __B[127:96]) + __C[127:96] +/// result[159:128] = (__A[159:128] * __B[159:128]) - __C[159:128] +/// result[191:160] = (__A[191:160] * __B[191:160]) + __C[191:160] +/// result[223:192] = (__A[223:192] * __B[223:192]) - __C[223:192] +/// result[255:224] = (__A[255:224] * __B[255:224]) + __C[255:224] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADDSUB213PS instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [8 x float] containing the multiplier. +/// \param __C +/// A 256-bit vector of [8 x float] containing the addend/subtrahend. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_fmaddsub_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, (__v8sf)__C); +} + +/// Computes a multiply with alternating add/subtract of 256-bit vectors of +/// [4 x double]. +/// +/// \code{.operation} +/// result[63:0] = (__A[63:0] * __B[63:0]) - __C[63:0] +/// result[127:64] = (__A[127:64] * __B[127:64]) + __C[127:64] +/// result[191:128] = (__A[191:128] * __B[191:128]) - __C[191:128] +/// result[255:192] = (__A[255:192] * __B[255:192]) + __C[255:192] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMADDSUB213PD instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x double] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [4 x double] containing the multiplier. +/// \param __C +/// A 256-bit vector of [4 x double] containing the addend/subtrahend. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_fmaddsub_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, (__v4df)__C); +} + +/// Computes a vector multiply with alternating add/subtract of 256-bit +/// vectors of [8 x float]. +/// +/// \code{.operation} +/// result[31:0] = (__A[31:0] * __B[31:0]) + __C[31:0] +/// result[63:32] = (__A[63:32] * __B[63:32]) - __C[63:32] +/// result[95:64] = (__A[95:64] * __B[95:64]) + __C[95:64] +/// result[127:96] = (__A[127:96] * __B[127:96]) - __C[127:96] +/// result[159:128] = (__A[159:128] * __B[159:128]) + __C[159:128] +/// result[191:160] = (__A[191:160] * __B[191:160]) - __C[191:160] +/// result[223:192] = (__A[223:192] * __B[223:192]) + __C[223:192] +/// result[255:224] = (__A[255:224] * __B[255:224]) - __C[255:224] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUBADD213PS instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x float] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [8 x float] containing the multiplier. +/// \param __C +/// A 256-bit vector of [8 x float] containing the addend/subtrahend. +/// \returns A 256-bit vector of [8 x float] containing the result. +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_fmsubadd_ps(__m256 __A, __m256 __B, __m256 __C) +{ + return (__m256)__builtin_ia32_vfmaddsubps256((__v8sf)__A, (__v8sf)__B, -(__v8sf)__C); +} + +/// Computes a vector multiply with alternating add/subtract of 256-bit +/// vectors of [4 x double]. +/// +/// \code{.operation} +/// result[63:0] = (__A[63:0] * __B[63:0]) + __C[63:0] +/// result[127:64] = (__A[127:64] * __B[127:64]) - __C[127:64] +/// result[191:128] = (__A[191:128] * __B[191:128]) + __C[191:128] +/// result[255:192] = (__A[255:192] * __B[255:192]) - __C[255:192] +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VFMSUBADD213PD instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x double] containing the multiplicand. +/// \param __B +/// A 256-bit vector of [4 x double] containing the multiplier. +/// \param __C +/// A 256-bit vector of [4 x double] containing the addend/subtrahend. +/// \returns A 256-bit vector of [4 x double] containing the result. +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_fmsubadd_pd(__m256d __A, __m256d __B, __m256d __C) +{ + return (__m256d)__builtin_ia32_vfmaddsubpd256((__v4df)__A, (__v4df)__B, -(__v4df)__C); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __FMAINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fxsrintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fxsrintrin.h new file mode 100755 index 0000000..afee6aa --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/fxsrintrin.h @@ -0,0 +1,91 @@ +/*===---- fxsrintrin.h - FXSR intrinsic ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __FXSRINTRIN_H +#define __FXSRINTRIN_H + +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("fxsr"))) + +/// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte +/// memory region pointed to by the input parameter \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the FXSAVE instruction. +/// +/// \param __p +/// A pointer to a 512-byte memory region. The beginning of this memory +/// region should be aligned on a 16-byte boundary. +static __inline__ void __DEFAULT_FN_ATTRS +_fxsave(void *__p) +{ + __builtin_ia32_fxsave(__p); +} + +/// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte +/// memory region pointed to by the input parameter \a __p. The contents of +/// this memory region should have been written to by a previous \c _fxsave +/// or \c _fxsave64 intrinsic. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the FXRSTOR instruction. +/// +/// \param __p +/// A pointer to a 512-byte memory region. The beginning of this memory +/// region should be aligned on a 16-byte boundary. +static __inline__ void __DEFAULT_FN_ATTRS +_fxrstor(void *__p) +{ + __builtin_ia32_fxrstor(__p); +} + +#ifdef __x86_64__ +/// Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte +/// memory region pointed to by the input parameter \a __p. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the FXSAVE64 instruction. +/// +/// \param __p +/// A pointer to a 512-byte memory region. The beginning of this memory +/// region should be aligned on a 16-byte boundary. +static __inline__ void __DEFAULT_FN_ATTRS +_fxsave64(void *__p) +{ + __builtin_ia32_fxsave64(__p); +} + +/// Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte +/// memory region pointed to by the input parameter \a __p. The contents of +/// this memory region should have been written to by a previous \c _fxsave +/// or \c _fxsave64 intrinsic. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the FXRSTOR64 instruction. +/// +/// \param __p +/// A pointer to a 512-byte memory region. The beginning of this memory +/// region should be aligned on a 16-byte boundary. +static __inline__ void __DEFAULT_FN_ATTRS +_fxrstor64(void *__p) +{ + __builtin_ia32_fxrstor64(__p); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/gfniintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/gfniintrin.h new file mode 100755 index 0000000..9a5743d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/gfniintrin.h @@ -0,0 +1,233 @@ +/*===----------------- gfniintrin.h - GFNI intrinsics ----------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __GFNIINTRIN_H +#define __GFNIINTRIN_H + +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +/* Default attributes for simple form (no masking). */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("gfni,no-evex512"), __min_vector_width__(128))) + +/* Default attributes for YMM unmasked form. */ +#define __DEFAULT_FN_ATTRS_Y \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx,gfni,no-evex512"), \ + __min_vector_width__(256))) + +/* Default attributes for VLX masked forms. */ +#define __DEFAULT_FN_ATTRS_VL128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,avx512vl,gfni,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS_VL256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,avx512vl,gfni,no-evex512"), \ + __min_vector_width__(256))) +#else +/* Default attributes for simple form (no masking). */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("gfni"), \ + __min_vector_width__(128))) + +/* Default attributes for YMM unmasked form. */ +#define __DEFAULT_FN_ATTRS_Y \ + __attribute__((__always_inline__, __nodebug__, __target__("avx,gfni"), \ + __min_vector_width__(256))) + +/* Default attributes for VLX masked forms. */ +#define __DEFAULT_FN_ATTRS_VL128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,avx512vl,gfni"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS_VL256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,avx512vl,gfni"), \ + __min_vector_width__(256))) +#endif + +/* Default attributes for ZMM unmasked forms. */ +#define __DEFAULT_FN_ATTRS_Z \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512f,evex512,gfni"), \ + __min_vector_width__(512))) +/* Default attributes for ZMM masked forms. */ +#define __DEFAULT_FN_ATTRS_Z_MASK \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512bw,evex512,gfni"), \ + __min_vector_width__(512))) + +#define _mm_gf2p8affineinv_epi64_epi8(A, B, I) \ + ((__m128i)__builtin_ia32_vgf2p8affineinvqb_v16qi((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), \ + (char)(I))) + +#define _mm_gf2p8affine_epi64_epi8(A, B, I) \ + ((__m128i)__builtin_ia32_vgf2p8affineqb_v16qi((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), \ + (char)(I))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_gf2p8mul_epi8(__m128i __A, __m128i __B) +{ + return (__m128i) __builtin_ia32_vgf2p8mulb_v16qi((__v16qi) __A, + (__v16qi) __B); +} + +#ifdef __AVXINTRIN_H +#define _mm256_gf2p8affineinv_epi64_epi8(A, B, I) \ + ((__m256i)__builtin_ia32_vgf2p8affineinvqb_v32qi((__v32qi)(__m256i)(A), \ + (__v32qi)(__m256i)(B), \ + (char)(I))) + +#define _mm256_gf2p8affine_epi64_epi8(A, B, I) \ + ((__m256i)__builtin_ia32_vgf2p8affineqb_v32qi((__v32qi)(__m256i)(A), \ + (__v32qi)(__m256i)(B), \ + (char)(I))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS_Y +_mm256_gf2p8mul_epi8(__m256i __A, __m256i __B) +{ + return (__m256i) __builtin_ia32_vgf2p8mulb_v32qi((__v32qi) __A, + (__v32qi) __B); +} +#endif /* __AVXINTRIN_H */ + +#ifdef __AVX512BWINTRIN_H +#define _mm512_gf2p8affineinv_epi64_epi8(A, B, I) \ + ((__m512i)__builtin_ia32_vgf2p8affineinvqb_v64qi((__v64qi)(__m512i)(A), \ + (__v64qi)(__m512i)(B), \ + (char)(I))) + +#define _mm512_mask_gf2p8affineinv_epi64_epi8(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectb_512((__mmask64)(U), \ + (__v64qi)_mm512_gf2p8affineinv_epi64_epi8(A, B, I), \ + (__v64qi)(__m512i)(S))) + +#define _mm512_maskz_gf2p8affineinv_epi64_epi8(U, A, B, I) \ + _mm512_mask_gf2p8affineinv_epi64_epi8((__m512i)_mm512_setzero_si512(), \ + U, A, B, I) + +#define _mm512_gf2p8affine_epi64_epi8(A, B, I) \ + ((__m512i)__builtin_ia32_vgf2p8affineqb_v64qi((__v64qi)(__m512i)(A), \ + (__v64qi)(__m512i)(B), \ + (char)(I))) + +#define _mm512_mask_gf2p8affine_epi64_epi8(S, U, A, B, I) \ + ((__m512i)__builtin_ia32_selectb_512((__mmask64)(U), \ + (__v64qi)_mm512_gf2p8affine_epi64_epi8((A), (B), (I)), \ + (__v64qi)(__m512i)(S))) + +#define _mm512_maskz_gf2p8affine_epi64_epi8(U, A, B, I) \ + _mm512_mask_gf2p8affine_epi64_epi8((__m512i)_mm512_setzero_si512(), \ + U, A, B, I) + +static __inline__ __m512i __DEFAULT_FN_ATTRS_Z +_mm512_gf2p8mul_epi8(__m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_vgf2p8mulb_v64qi((__v64qi) __A, + (__v64qi) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_Z_MASK +_mm512_mask_gf2p8mul_epi8(__m512i __S, __mmask64 __U, __m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_selectb_512(__U, + (__v64qi) _mm512_gf2p8mul_epi8(__A, __B), + (__v64qi) __S); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_Z_MASK +_mm512_maskz_gf2p8mul_epi8(__mmask64 __U, __m512i __A, __m512i __B) +{ + return _mm512_mask_gf2p8mul_epi8((__m512i)_mm512_setzero_si512(), + __U, __A, __B); +} +#endif /* __AVX512BWINTRIN_H */ + +#ifdef __AVX512VLBWINTRIN_H +#define _mm_mask_gf2p8affineinv_epi64_epi8(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectb_128((__mmask16)(U), \ + (__v16qi)_mm_gf2p8affineinv_epi64_epi8(A, B, I), \ + (__v16qi)(__m128i)(S))) + +#define _mm_maskz_gf2p8affineinv_epi64_epi8(U, A, B, I) \ + _mm_mask_gf2p8affineinv_epi64_epi8((__m128i)_mm_setzero_si128(), \ + U, A, B, I) + +#define _mm256_mask_gf2p8affineinv_epi64_epi8(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectb_256((__mmask32)(U), \ + (__v32qi)_mm256_gf2p8affineinv_epi64_epi8(A, B, I), \ + (__v32qi)(__m256i)(S))) + +#define _mm256_maskz_gf2p8affineinv_epi64_epi8(U, A, B, I) \ + _mm256_mask_gf2p8affineinv_epi64_epi8((__m256i)_mm256_setzero_si256(), \ + U, A, B, I) + +#define _mm_mask_gf2p8affine_epi64_epi8(S, U, A, B, I) \ + ((__m128i)__builtin_ia32_selectb_128((__mmask16)(U), \ + (__v16qi)_mm_gf2p8affine_epi64_epi8(A, B, I), \ + (__v16qi)(__m128i)(S))) + +#define _mm_maskz_gf2p8affine_epi64_epi8(U, A, B, I) \ + _mm_mask_gf2p8affine_epi64_epi8((__m128i)_mm_setzero_si128(), U, A, B, I) + +#define _mm256_mask_gf2p8affine_epi64_epi8(S, U, A, B, I) \ + ((__m256i)__builtin_ia32_selectb_256((__mmask32)(U), \ + (__v32qi)_mm256_gf2p8affine_epi64_epi8(A, B, I), \ + (__v32qi)(__m256i)(S))) + +#define _mm256_maskz_gf2p8affine_epi64_epi8(U, A, B, I) \ + _mm256_mask_gf2p8affine_epi64_epi8((__m256i)_mm256_setzero_si256(), \ + U, A, B, I) + +static __inline__ __m128i __DEFAULT_FN_ATTRS_VL128 +_mm_mask_gf2p8mul_epi8(__m128i __S, __mmask16 __U, __m128i __A, __m128i __B) +{ + return (__m128i) __builtin_ia32_selectb_128(__U, + (__v16qi) _mm_gf2p8mul_epi8(__A, __B), + (__v16qi) __S); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS_VL128 +_mm_maskz_gf2p8mul_epi8(__mmask16 __U, __m128i __A, __m128i __B) +{ + return _mm_mask_gf2p8mul_epi8((__m128i)_mm_setzero_si128(), + __U, __A, __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS_VL256 +_mm256_mask_gf2p8mul_epi8(__m256i __S, __mmask32 __U, __m256i __A, __m256i __B) +{ + return (__m256i) __builtin_ia32_selectb_256(__U, + (__v32qi) _mm256_gf2p8mul_epi8(__A, __B), + (__v32qi) __S); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS_VL256 +_mm256_maskz_gf2p8mul_epi8(__mmask32 __U, __m256i __A, __m256i __B) +{ + return _mm256_mask_gf2p8mul_epi8((__m256i)_mm256_setzero_si256(), + __U, __A, __B); +} +#endif /* __AVX512VLBWINTRIN_H */ + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_Y +#undef __DEFAULT_FN_ATTRS_Z +#undef __DEFAULT_FN_ATTRS_VL128 +#undef __DEFAULT_FN_ATTRS_VL256 + +#endif /* __GFNIINTRIN_H */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/gpuintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/gpuintrin.h new file mode 100755 index 0000000..7afc824 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/gpuintrin.h @@ -0,0 +1,328 @@ +//===-- gpuintrin.h - Generic GPU intrinsic functions ---------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Provides wrappers around the clang builtins for accessing GPU hardware +// features. The interface is intended to be portable between architectures, but +// some targets may provide different implementations. This header can be +// included for all the common GPU programming languages, namely OpenMP, HIP, +// CUDA, and OpenCL. +// +//===----------------------------------------------------------------------===// + +#ifndef __GPUINTRIN_H +#define __GPUINTRIN_H + +#if !defined(_DEFAULT_FN_ATTRS) +#if defined(__HIP__) || defined(__CUDA__) +#define _DEFAULT_FN_ATTRS __attribute__((device)) +#else +#define _DEFAULT_FN_ATTRS +#endif +#endif + +#include + +#if !defined(__cplusplus) +_Pragma("push_macro(\"bool\")"); +#define bool _Bool +#endif + +_Pragma("omp begin declare target device_type(nohost)"); +_Pragma("omp begin declare variant match(device = {kind(gpu)})"); + +// Forward declare a few functions for the implementation header. + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u32_impl(uint64_t __lane_mask, uint32_t __x); + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u64_impl(uint64_t __lane_mask, uint64_t __x); + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u32_impl(uint64_t __lane_mask, uint32_t __x); + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u64_impl(uint64_t __lane_mask, uint64_t __x); + +_Pragma("omp end declare variant"); +_Pragma("omp end declare target"); + +#if defined(__NVPTX__) +#include +#elif defined(__AMDGPU__) +#include +#elif !defined(_OPENMP) +#error "This header is only meant to be used on GPU architectures." +#endif + +_Pragma("omp begin declare target device_type(nohost)"); +_Pragma("omp begin declare variant match(device = {kind(gpu)})"); + +#define __GPU_X_DIM 0 +#define __GPU_Y_DIM 1 +#define __GPU_Z_DIM 2 + +// Returns the number of blocks in the requested dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks(int __dim) { + switch (__dim) { + case 0: + return __gpu_num_blocks_x(); + case 1: + return __gpu_num_blocks_y(); + case 2: + return __gpu_num_blocks_z(); + default: + __builtin_unreachable(); + } +} + +// Returns the number of block id in the requested dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id(int __dim) { + switch (__dim) { + case 0: + return __gpu_block_id_x(); + case 1: + return __gpu_block_id_y(); + case 2: + return __gpu_block_id_z(); + default: + __builtin_unreachable(); + } +} + +// Returns the number of threads in the requested dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads(int __dim) { + switch (__dim) { + case 0: + return __gpu_num_threads_x(); + case 1: + return __gpu_num_threads_y(); + case 2: + return __gpu_num_threads_z(); + default: + __builtin_unreachable(); + } +} + +// Returns the thread id in the requested dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id(int __dim) { + switch (__dim) { + case 0: + return __gpu_thread_id_x(); + case 1: + return __gpu_thread_id_y(); + case 2: + return __gpu_thread_id_z(); + default: + __builtin_unreachable(); + } +} + +// Get the first active thread inside the lane. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_first_lane_id(uint64_t __lane_mask) { + return __builtin_ffsll(__lane_mask) - 1; +} + +// Conditional that is only true for a single thread in a lane. +_DEFAULT_FN_ATTRS static __inline__ bool +__gpu_is_first_in_lane(uint64_t __lane_mask) { + return __gpu_lane_id() == __gpu_first_lane_id(__lane_mask); +} + +// Copies the value from the first active thread to the rest. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_read_first_lane_u64(uint64_t __lane_mask, uint64_t __x) { + uint32_t __hi = (uint32_t)(__x >> 32ull); + uint32_t __lo = (uint32_t)(__x & 0xFFFFFFFFull); + return ((uint64_t)__gpu_read_first_lane_u32(__lane_mask, __hi) << 32ull) | + ((uint64_t)__gpu_read_first_lane_u32(__lane_mask, __lo) & + 0xFFFFFFFFull); +} + +// Gets the first floating point value from the active lanes. +_DEFAULT_FN_ATTRS static __inline__ float +__gpu_read_first_lane_f32(uint64_t __lane_mask, float __x) { + return __builtin_bit_cast( + float, __gpu_read_first_lane_u32(__lane_mask, + __builtin_bit_cast(uint32_t, __x))); +} + +// Gets the first floating point value from the active lanes. +_DEFAULT_FN_ATTRS static __inline__ double +__gpu_read_first_lane_f64(uint64_t __lane_mask, double __x) { + return __builtin_bit_cast( + double, __gpu_read_first_lane_u64(__lane_mask, + __builtin_bit_cast(uint64_t, __x))); +} + +// Shuffles the the lanes according to the given index. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_shuffle_idx_u64(uint64_t __lane_mask, uint32_t __idx, uint64_t __x, + uint32_t __width) { + uint32_t __hi = (uint32_t)(__x >> 32ull); + uint32_t __lo = (uint32_t)(__x & 0xFFFFFFFF); + uint32_t __mask = (uint32_t)__lane_mask; + return ((uint64_t)__gpu_shuffle_idx_u32(__mask, __idx, __hi, __width) + << 32ull) | + ((uint64_t)__gpu_shuffle_idx_u32(__mask, __idx, __lo, __width)); +} + +// Shuffles the the lanes according to the given index. +_DEFAULT_FN_ATTRS static __inline__ float +__gpu_shuffle_idx_f32(uint64_t __lane_mask, uint32_t __idx, float __x, + uint32_t __width) { + return __builtin_bit_cast( + float, __gpu_shuffle_idx_u32(__lane_mask, __idx, + __builtin_bit_cast(uint32_t, __x), __width)); +} + +// Shuffles the the lanes according to the given index. +_DEFAULT_FN_ATTRS static __inline__ double +__gpu_shuffle_idx_f64(uint64_t __lane_mask, uint32_t __idx, double __x, + uint32_t __width) { + return __builtin_bit_cast( + double, + __gpu_shuffle_idx_u64(__lane_mask, __idx, + __builtin_bit_cast(uint64_t, __x), __width)); +} + +// Gets the accumulator scan of the threads in the warp or wavefront. +#define __DO_LANE_SCAN(__type, __bitmask_type, __suffix) \ + _DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_lane_scan_##__suffix( \ + uint64_t __lane_mask, uint32_t __x) { \ + uint64_t __first = __lane_mask >> __builtin_ctzll(__lane_mask); \ + bool __divergent = __gpu_read_first_lane_##__suffix( \ + __lane_mask, __first & (__first + 1)); \ + if (__divergent) { \ + __type __accum = 0; \ + for (uint64_t __mask = __lane_mask; __mask; __mask &= __mask - 1) { \ + __type __index = __builtin_ctzll(__mask); \ + __type __tmp = __gpu_shuffle_idx_##__suffix(__lane_mask, __index, __x, \ + __gpu_num_lanes()); \ + __x = __gpu_lane_id() == __index ? __accum + __tmp : __x; \ + __accum += __tmp; \ + } \ + } else { \ + for (uint32_t __step = 1; __step < __gpu_num_lanes(); __step *= 2) { \ + uint32_t __index = __gpu_lane_id() - __step; \ + __bitmask_type bitmask = __gpu_lane_id() >= __step; \ + __x += __builtin_bit_cast( \ + __type, \ + -bitmask & __builtin_bit_cast(__bitmask_type, \ + __gpu_shuffle_idx_##__suffix( \ + __lane_mask, __index, __x, \ + __gpu_num_lanes()))); \ + } \ + } \ + return __x; \ + } +__DO_LANE_SCAN(uint32_t, uint32_t, u32); // uint32_t __gpu_lane_scan_u32(m, x) +__DO_LANE_SCAN(uint64_t, uint64_t, u64); // uint64_t __gpu_lane_scan_u64(m, x) +__DO_LANE_SCAN(float, uint32_t, f32); // float __gpu_lane_scan_f32(m, x) +__DO_LANE_SCAN(double, uint64_t, f64); // double __gpu_lane_scan_f64(m, x) +#undef __DO_LANE_SCAN + +// Gets the sum of all lanes inside the warp or wavefront. +#define __DO_LANE_SUM(__type, __suffix) \ + _DEFAULT_FN_ATTRS static __inline__ __type __gpu_lane_sum_##__suffix( \ + uint64_t __lane_mask, __type __x) { \ + uint64_t __first = __lane_mask >> __builtin_ctzll(__lane_mask); \ + bool __divergent = __gpu_read_first_lane_##__suffix( \ + __lane_mask, __first & (__first + 1)); \ + if (__divergent) { \ + return __gpu_shuffle_idx_##__suffix( \ + __lane_mask, 63 - __builtin_clzll(__lane_mask), \ + __gpu_lane_scan_##__suffix(__lane_mask, __x), __gpu_num_lanes()); \ + } else { \ + for (uint32_t __step = 1; __step < __gpu_num_lanes(); __step *= 2) { \ + uint32_t __index = __step + __gpu_lane_id(); \ + __x += __gpu_shuffle_idx_##__suffix(__lane_mask, __index, __x, \ + __gpu_num_lanes()); \ + } \ + return __gpu_read_first_lane_##__suffix(__lane_mask, __x); \ + } \ + } +__DO_LANE_SUM(uint32_t, u32); // uint32_t __gpu_lane_sum_u32(m, x) +__DO_LANE_SUM(uint64_t, u64); // uint64_t __gpu_lane_sum_u64(m, x) +__DO_LANE_SUM(float, f32); // float __gpu_lane_sum_f32(m, x) +__DO_LANE_SUM(double, f64); // double __gpu_lane_sum_f64(m, x) +#undef __DO_LANE_SUM + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u32_impl(uint64_t __lane_mask, uint32_t __x) { + uint64_t __match_mask = 0; + + bool __done = 0; + for (uint64_t __active_mask = __lane_mask; __active_mask; + __active_mask = __gpu_ballot(__lane_mask, !__done)) { + if (!__done) { + uint32_t __first = __gpu_read_first_lane_u32(__active_mask, __x); + if (__first == __x) { + __match_mask = __gpu_lane_mask(); + __done = 1; + } + } + } + __gpu_sync_lane(__lane_mask); + return __match_mask; +} + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u64_impl(uint64_t __lane_mask, uint64_t __x) { + uint64_t __match_mask = 0; + + bool __done = 0; + for (uint64_t __active_mask = __lane_mask; __active_mask; + __active_mask = __gpu_ballot(__lane_mask, !__done)) { + if (!__done) { + uint64_t __first = __gpu_read_first_lane_u64(__active_mask, __x); + if (__first == __x) { + __match_mask = __gpu_lane_mask(); + __done = 1; + } + } + } + __gpu_sync_lane(__lane_mask); + return __match_mask; +} + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u32_impl(uint64_t __lane_mask, uint32_t __x) { + uint32_t __first = __gpu_read_first_lane_u32(__lane_mask, __x); + uint64_t __ballot = __gpu_ballot(__lane_mask, __x == __first); + __gpu_sync_lane(__lane_mask); + return __ballot == __gpu_lane_mask() ? __gpu_lane_mask() : 0ull; +} + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u64_impl(uint64_t __lane_mask, uint64_t __x) { + uint64_t __first = __gpu_read_first_lane_u64(__lane_mask, __x); + uint64_t __ballot = __gpu_ballot(__lane_mask, __x == __first); + __gpu_sync_lane(__lane_mask); + return __ballot == __gpu_lane_mask() ? __gpu_lane_mask() : 0ull; +} + +_Pragma("omp end declare variant"); +_Pragma("omp end declare target"); + +#if !defined(__cplusplus) +_Pragma("pop_macro(\"bool\")"); +#endif + +#undef _DEFAULT_FN_ATTRS + +#endif // __GPUINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_circ_brev_intrinsics.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_circ_brev_intrinsics.h new file mode 100755 index 0000000..c53786d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_circ_brev_intrinsics.h @@ -0,0 +1,298 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _HEXAGON_CIRC_BREV_INTRINSICS_H_ +#define _HEXAGON_CIRC_BREV_INTRINSICS_H_ 1 + +#include +#include + +/* Circular Load */ +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_load_update_D(Word64 dst, Word64 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_load_update_D(dest,ptr,incr,bufsize,K) \ + { ptr = (int64_t *) HEXAGON_circ_ldd (ptr, &(dest), ((((K)+1)<<24)|((bufsize)<<3)), ((incr)*8)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_load_update_W(Word32 dst, Word32 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_load_update_W(dest,ptr,incr,bufsize,K) \ + { ptr = (int *) HEXAGON_circ_ldw (ptr, &(dest), (((K)<<24)|((bufsize)<<2)), ((incr)*4)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_load_update_H(Word16 dst, Word16 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_load_update_H(dest,ptr,incr,bufsize,K) \ + { ptr = (int16_t *) HEXAGON_circ_ldh (ptr, &(dest), ((((K)-1)<<24)|((bufsize)<<1)), ((incr)*2)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_load_update_UH( UWord16 dst, UWord16 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_load_update_UH(dest,ptr,incr,bufsize,K) \ + { ptr = (uint16_t *) HEXAGON_circ_lduh (ptr, &(dest), ((((K)-1)<<24)|((bufsize)<<1)), ((incr)*2)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_load_update_B(Word8 dst, Word8 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_load_update_B(dest,ptr,incr,bufsize,K) \ + { ptr = (int8_t *) HEXAGON_circ_ldb (ptr, &(dest), ((((K)-2)<<24)|(bufsize)), incr); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_load_update_UB(UWord8 dst, UWord8 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_load_update_UB(dest,ptr,incr,bufsize,K) \ + { ptr = (uint8_t *) HEXAGON_circ_ldub (ptr, &(dest), ((((K)-2)<<24)|(bufsize)), incr); } + +/* Circular Store */ +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_store_update_D(Word64 *src, Word64 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_store_update_D(src,ptr,incr,bufsize,K) \ + { ptr = (int64_t *) HEXAGON_circ_std (ptr, src, ((((K)+1)<<24)|((bufsize)<<3)), ((incr)*8)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_store_update_W(Word32 *src, Word32 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_store_update_W(src,ptr,incr,bufsize,K) \ + { ptr = (int *) HEXAGON_circ_stw (ptr, src, (((K)<<24)|((bufsize)<<2)), ((incr)*4)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_store_update_HL(Word16 *src, Word16 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_store_update_HL(src,ptr,incr,bufsize,K) \ + { ptr = (int16_t *) HEXAGON_circ_sth (ptr, src, ((((K)-1)<<24)|((bufsize)<<1)), ((incr)*2)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_store_update_HH(Word16 *src, Word16 *ptr, UWord32 incr, UWord32 bufsize, UWord32 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_store_update_HH(src,ptr,incr,bufsize,K) \ + { ptr = (int16_t *) HEXAGON_circ_sthhi (ptr, src, ((((K)-1)<<24)|((bufsize)<<1)), ((incr)*2)); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_circ_store_update_B(Word8 *src, Word8 *ptr, UWord32 I4, UWord32 bufsize, UWord64 K) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_circ_store_update_B(src,ptr,incr,bufsize,K) \ + { ptr = (int8_t *) HEXAGON_circ_stb (ptr, src, ((((K)-2)<<24)|(bufsize)), incr); } + + +/* Bit Reverse Load */ +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_load_update_D(Word64 dst, Word64 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_load_update_D(dest,ptr,log2bufsize) \ + { ptr = (int64_t *) HEXAGON_brev_ldd (ptr, &(dest), (1<<(16-((log2bufsize) + 3)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_load_update_W(Word32 dst, Word32 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_load_update_W(dest,ptr,log2bufsize) \ + { ptr = (int *) HEXAGON_brev_ldw (ptr, &(dest), (1<<(16-((log2bufsize) + 2)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_load_update_H(Word16 dst, Word16 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_load_update_H(dest,ptr,log2bufsize) \ + { ptr = (int16_t *) HEXAGON_brev_ldh (ptr, &(dest), (1<<(16-((log2bufsize) + 1)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_load_update_UH(UWord16 dst, UWord16 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_load_update_UH(dest,ptr,log2bufsize) \ + { ptr = (uint16_t *) HEXAGON_brev_lduh (ptr, &(dest), (1<<(16-((log2bufsize) + 1)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_load_update_B(Word8 dst, Word8 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_load_update_B(dest,ptr,log2bufsize) \ + { ptr = (int8_t *) HEXAGON_brev_ldb (ptr, &(dest), (1<<(16-((log2bufsize))))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_load_update_UB(UWord8 dst, UWord8 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_load_update_UB(dest,ptr,log2bufsize) \ + { ptr = (uint8_t *) HEXAGON_brev_ldub (ptr, &(dest), (1<<(16-((log2bufsize))))); } + +/* Bit Reverse Store */ + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_store_update_D(Word64 *src, Word64 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_store_update_D(src,ptr,log2bufsize) \ + { ptr = (int64_t *) HEXAGON_brev_std (ptr, src, (1<<(16-((log2bufsize) + 3)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_store_update_W(Word32 *src, Word32 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_store_update_W(src,ptr,log2bufsize) \ + { ptr = (int *) HEXAGON_brev_stw (ptr, src, (1<<(16-((log2bufsize) + 2)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_store_update_HL(Word16 *src, Word16 *ptr, Word32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_store_update_HL(src,ptr,log2bufsize) \ + { ptr = (int16_t *) HEXAGON_brev_sth (ptr, src, (1<<(16-((log2bufsize) + 1)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_store_update_HH(Word16 *src, Word16 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_store_update_HH(src,ptr,log2bufsize) \ + { ptr = (int16_t *) HEXAGON_brev_sthhi (ptr, src, (1<<(16-((log2bufsize) + 1)))); } + +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: void Q6_bitrev_store_update_B(Word8 *src, Word8 *ptr, UWord32 Iu4) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#define Q6_bitrev_store_update_B(src,ptr,log2bufsize) \ + { ptr = (int8_t *) HEXAGON_brev_stb (ptr, src, (1<<(16-((log2bufsize))))); } + + +#define HEXAGON_circ_ldd __builtin_circ_ldd +#define HEXAGON_circ_ldw __builtin_circ_ldw +#define HEXAGON_circ_ldh __builtin_circ_ldh +#define HEXAGON_circ_lduh __builtin_circ_lduh +#define HEXAGON_circ_ldb __builtin_circ_ldb +#define HEXAGON_circ_ldub __builtin_circ_ldub + + +#define HEXAGON_circ_std __builtin_circ_std +#define HEXAGON_circ_stw __builtin_circ_stw +#define HEXAGON_circ_sth __builtin_circ_sth +#define HEXAGON_circ_sthhi __builtin_circ_sthhi +#define HEXAGON_circ_stb __builtin_circ_stb + + +#define HEXAGON_brev_ldd __builtin_brev_ldd +#define HEXAGON_brev_ldw __builtin_brev_ldw +#define HEXAGON_brev_ldh __builtin_brev_ldh +#define HEXAGON_brev_lduh __builtin_brev_lduh +#define HEXAGON_brev_ldb __builtin_brev_ldb +#define HEXAGON_brev_ldub __builtin_brev_ldub + +#define HEXAGON_brev_std __builtin_brev_std +#define HEXAGON_brev_stw __builtin_brev_stw +#define HEXAGON_brev_sth __builtin_brev_sth +#define HEXAGON_brev_sthhi __builtin_brev_sthhi +#define HEXAGON_brev_stb __builtin_brev_stb + +#ifdef __HVX__ +/* ========================================================================== + Assembly Syntax: if (Qt) vmem(Rt+#0) = Vs + C Intrinsic Prototype: void Q6_vmaskedstoreq_QAV(HVX_VectorPred Qt, HVX_VectorAddress A, HVX_Vector Vs) + Instruction Type: COPROC_VMEM + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmaskedstoreq_QAV __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaskedstoreq) + +/* ========================================================================== + Assembly Syntax: if (!Qt) vmem(Rt+#0) = Vs + C Intrinsic Prototype: void Q6_vmaskedstorenq_QAV(HVX_VectorPred Qt, HVX_VectorAddress A, HVX_Vector Vs) + Instruction Type: COPROC_VMEM + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmaskedstorenq_QAV __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaskedstorenq) + +/* ========================================================================== + Assembly Syntax: if (Qt) vmem(Rt+#0):nt = Vs + C Intrinsic Prototype: void Q6_vmaskedstorentq_QAV(HVX_VectorPred Qt, HVX_VectorAddress A, HVX_Vector Vs) + Instruction Type: COPROC_VMEM + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmaskedstorentq_QAV __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaskedstorentq) + +/* ========================================================================== + Assembly Syntax: if (!Qt) vmem(Rt+#0):nt = Vs + C Intrinsic Prototype: void Q6_vmaskedstorentnq_QAV(HVX_VectorPred Qt, HVX_VectorAddress A, HVX_Vector Vs) + Instruction Type: COPROC_VMEM + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmaskedstorentnq_QAV __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaskedstorentnq) + +#endif + + +#endif /* #ifndef _HEXAGON_CIRC_BREV_INTRINSICS_H_ */ + +#ifdef __NOT_DEFINED__ +/*** comment block template ***/ +/* ========================================================================== + Assembly Syntax: Return=instruction() + C Intrinsic Prototype: ReturnType Intrinsic(ParamType Rs, ParamType Rt) + Instruction Type: InstructionType + Execution Slots: SLOT0123 + ========================================================================== */ +#endif /*** __NOT_DEFINED__ ***/ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_protos.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_protos.h new file mode 100755 index 0000000..2642f3c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_protos.h @@ -0,0 +1,8439 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// Automatically generated file, do not edit! +//===----------------------------------------------------------------------===// + + + +#ifndef __HEXAGON_PROTOS_H_ +#define __HEXAGON_PROTOS_H_ 1 + +/* ========================================================================== + Assembly Syntax: Rd32=abs(Rs32) + C Intrinsic Prototype: Word32 Q6_R_abs_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_abs_R __builtin_HEXAGON_A2_abs + +/* ========================================================================== + Assembly Syntax: Rdd32=abs(Rss32) + C Intrinsic Prototype: Word64 Q6_P_abs_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_abs_P __builtin_HEXAGON_A2_absp + +/* ========================================================================== + Assembly Syntax: Rd32=abs(Rs32):sat + C Intrinsic Prototype: Word32 Q6_R_abs_R_sat(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_abs_R_sat __builtin_HEXAGON_A2_abssat + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_add_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_add_RR __builtin_HEXAGON_A2_add + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.h,Rs32.h):<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RhRh_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RhRh_s16 __builtin_HEXAGON_A2_addh_h16_hh + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.h,Rs32.l):<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RhRl_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RhRl_s16 __builtin_HEXAGON_A2_addh_h16_hl + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.h):<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RlRh_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRh_s16 __builtin_HEXAGON_A2_addh_h16_lh + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.l):<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RlRl_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRl_s16 __builtin_HEXAGON_A2_addh_h16_ll + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.h,Rs32.h):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RhRh_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RhRh_sat_s16 __builtin_HEXAGON_A2_addh_h16_sat_hh + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.h,Rs32.l):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RhRl_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RhRl_sat_s16 __builtin_HEXAGON_A2_addh_h16_sat_hl + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.h):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RlRh_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRh_sat_s16 __builtin_HEXAGON_A2_addh_h16_sat_lh + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.l):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_add_RlRl_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRl_sat_s16 __builtin_HEXAGON_A2_addh_h16_sat_ll + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.h) + C Intrinsic Prototype: Word32 Q6_R_add_RlRh(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRh __builtin_HEXAGON_A2_addh_l16_hl + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.l) + C Intrinsic Prototype: Word32 Q6_R_add_RlRl(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRl __builtin_HEXAGON_A2_addh_l16_ll + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.h):sat + C Intrinsic Prototype: Word32 Q6_R_add_RlRh_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRh_sat __builtin_HEXAGON_A2_addh_l16_sat_hl + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rt32.l,Rs32.l):sat + C Intrinsic Prototype: Word32 Q6_R_add_RlRl_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_RlRl_sat __builtin_HEXAGON_A2_addh_l16_sat_ll + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rs32,#s16) + C Intrinsic Prototype: Word32 Q6_R_add_RI(Word32 Rs, Word32 Is16) + Instruction Type: ALU32_ADDI + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_add_RI __builtin_HEXAGON_A2_addi + +/* ========================================================================== + Assembly Syntax: Rdd32=add(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_add_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_add_PP __builtin_HEXAGON_A2_addp + +/* ========================================================================== + Assembly Syntax: Rdd32=add(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_add_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_add_PP_sat __builtin_HEXAGON_A2_addpsat + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rs32,Rt32):sat + C Intrinsic Prototype: Word32 Q6_R_add_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_add_RR_sat __builtin_HEXAGON_A2_addsat + +/* ========================================================================== + Assembly Syntax: Rdd32=add(Rs32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_add_RP(Word32 Rs, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_add_RP __builtin_HEXAGON_A2_addsp + +/* ========================================================================== + Assembly Syntax: Rd32=and(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_and_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_and_RR __builtin_HEXAGON_A2_and + +/* ========================================================================== + Assembly Syntax: Rd32=and(Rs32,#s10) + C Intrinsic Prototype: Word32 Q6_R_and_RI(Word32 Rs, Word32 Is10) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_and_RI __builtin_HEXAGON_A2_andir + +/* ========================================================================== + Assembly Syntax: Rdd32=and(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_and_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_and_PP __builtin_HEXAGON_A2_andp + +/* ========================================================================== + Assembly Syntax: Rd32=aslh(Rs32) + C Intrinsic Prototype: Word32 Q6_R_aslh_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_aslh_R __builtin_HEXAGON_A2_aslh + +/* ========================================================================== + Assembly Syntax: Rd32=asrh(Rs32) + C Intrinsic Prototype: Word32 Q6_R_asrh_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_asrh_R __builtin_HEXAGON_A2_asrh + +/* ========================================================================== + Assembly Syntax: Rd32=combine(Rt32.h,Rs32.h) + C Intrinsic Prototype: Word32 Q6_R_combine_RhRh(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_combine_RhRh __builtin_HEXAGON_A2_combine_hh + +/* ========================================================================== + Assembly Syntax: Rd32=combine(Rt32.h,Rs32.l) + C Intrinsic Prototype: Word32 Q6_R_combine_RhRl(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_combine_RhRl __builtin_HEXAGON_A2_combine_hl + +/* ========================================================================== + Assembly Syntax: Rd32=combine(Rt32.l,Rs32.h) + C Intrinsic Prototype: Word32 Q6_R_combine_RlRh(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_combine_RlRh __builtin_HEXAGON_A2_combine_lh + +/* ========================================================================== + Assembly Syntax: Rd32=combine(Rt32.l,Rs32.l) + C Intrinsic Prototype: Word32 Q6_R_combine_RlRl(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_combine_RlRl __builtin_HEXAGON_A2_combine_ll + +/* ========================================================================== + Assembly Syntax: Rdd32=combine(#s8,#S8) + C Intrinsic Prototype: Word64 Q6_P_combine_II(Word32 Is8, Word32 IS8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_combine_II __builtin_HEXAGON_A2_combineii + +/* ========================================================================== + Assembly Syntax: Rdd32=combine(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_combine_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_combine_RR __builtin_HEXAGON_A2_combinew + +/* ========================================================================== + Assembly Syntax: Rd32=max(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_max_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_max_RR __builtin_HEXAGON_A2_max + +/* ========================================================================== + Assembly Syntax: Rdd32=max(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_max_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_max_PP __builtin_HEXAGON_A2_maxp + +/* ========================================================================== + Assembly Syntax: Rd32=maxu(Rs32,Rt32) + C Intrinsic Prototype: UWord32 Q6_R_maxu_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_maxu_RR __builtin_HEXAGON_A2_maxu + +/* ========================================================================== + Assembly Syntax: Rdd32=maxu(Rss32,Rtt32) + C Intrinsic Prototype: UWord64 Q6_P_maxu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_maxu_PP __builtin_HEXAGON_A2_maxup + +/* ========================================================================== + Assembly Syntax: Rd32=min(Rt32,Rs32) + C Intrinsic Prototype: Word32 Q6_R_min_RR(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_min_RR __builtin_HEXAGON_A2_min + +/* ========================================================================== + Assembly Syntax: Rdd32=min(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_min_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_min_PP __builtin_HEXAGON_A2_minp + +/* ========================================================================== + Assembly Syntax: Rd32=minu(Rt32,Rs32) + C Intrinsic Prototype: UWord32 Q6_R_minu_RR(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_minu_RR __builtin_HEXAGON_A2_minu + +/* ========================================================================== + Assembly Syntax: Rdd32=minu(Rtt32,Rss32) + C Intrinsic Prototype: UWord64 Q6_P_minu_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_minu_PP __builtin_HEXAGON_A2_minup + +/* ========================================================================== + Assembly Syntax: Rd32=neg(Rs32) + C Intrinsic Prototype: Word32 Q6_R_neg_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_neg_R __builtin_HEXAGON_A2_neg + +/* ========================================================================== + Assembly Syntax: Rdd32=neg(Rss32) + C Intrinsic Prototype: Word64 Q6_P_neg_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_neg_P __builtin_HEXAGON_A2_negp + +/* ========================================================================== + Assembly Syntax: Rd32=neg(Rs32):sat + C Intrinsic Prototype: Word32 Q6_R_neg_R_sat(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_neg_R_sat __builtin_HEXAGON_A2_negsat + +/* ========================================================================== + Assembly Syntax: Rd32=not(Rs32) + C Intrinsic Prototype: Word32 Q6_R_not_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_not_R __builtin_HEXAGON_A2_not + +/* ========================================================================== + Assembly Syntax: Rdd32=not(Rss32) + C Intrinsic Prototype: Word64 Q6_P_not_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_not_P __builtin_HEXAGON_A2_notp + +/* ========================================================================== + Assembly Syntax: Rd32=or(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_or_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_or_RR __builtin_HEXAGON_A2_or + +/* ========================================================================== + Assembly Syntax: Rd32=or(Rs32,#s10) + C Intrinsic Prototype: Word32 Q6_R_or_RI(Word32 Rs, Word32 Is10) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_or_RI __builtin_HEXAGON_A2_orir + +/* ========================================================================== + Assembly Syntax: Rdd32=or(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_or_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_or_PP __builtin_HEXAGON_A2_orp + +/* ========================================================================== + Assembly Syntax: Rd32=round(Rss32):sat + C Intrinsic Prototype: Word32 Q6_R_round_P_sat(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_round_P_sat __builtin_HEXAGON_A2_roundsat + +/* ========================================================================== + Assembly Syntax: Rd32=sat(Rss32) + C Intrinsic Prototype: Word32 Q6_R_sat_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sat_P __builtin_HEXAGON_A2_sat + +/* ========================================================================== + Assembly Syntax: Rd32=satb(Rs32) + C Intrinsic Prototype: Word32 Q6_R_satb_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_satb_R __builtin_HEXAGON_A2_satb + +/* ========================================================================== + Assembly Syntax: Rd32=sath(Rs32) + C Intrinsic Prototype: Word32 Q6_R_sath_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sath_R __builtin_HEXAGON_A2_sath + +/* ========================================================================== + Assembly Syntax: Rd32=satub(Rs32) + C Intrinsic Prototype: Word32 Q6_R_satub_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_satub_R __builtin_HEXAGON_A2_satub + +/* ========================================================================== + Assembly Syntax: Rd32=satuh(Rs32) + C Intrinsic Prototype: Word32 Q6_R_satuh_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_satuh_R __builtin_HEXAGON_A2_satuh + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32,Rs32) + C Intrinsic Prototype: Word32 Q6_R_sub_RR(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_sub_RR __builtin_HEXAGON_A2_sub + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.h,Rs32.h):<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RhRh_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RhRh_s16 __builtin_HEXAGON_A2_subh_h16_hh + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.h,Rs32.l):<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RhRl_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RhRl_s16 __builtin_HEXAGON_A2_subh_h16_hl + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.h):<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RlRh_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRh_s16 __builtin_HEXAGON_A2_subh_h16_lh + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.l):<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RlRl_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRl_s16 __builtin_HEXAGON_A2_subh_h16_ll + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.h,Rs32.h):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RhRh_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RhRh_sat_s16 __builtin_HEXAGON_A2_subh_h16_sat_hh + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.h,Rs32.l):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RhRl_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RhRl_sat_s16 __builtin_HEXAGON_A2_subh_h16_sat_hl + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.h):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RlRh_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRh_sat_s16 __builtin_HEXAGON_A2_subh_h16_sat_lh + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.l):sat:<<16 + C Intrinsic Prototype: Word32 Q6_R_sub_RlRl_sat_s16(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRl_sat_s16 __builtin_HEXAGON_A2_subh_h16_sat_ll + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.h) + C Intrinsic Prototype: Word32 Q6_R_sub_RlRh(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRh __builtin_HEXAGON_A2_subh_l16_hl + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.l) + C Intrinsic Prototype: Word32 Q6_R_sub_RlRl(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRl __builtin_HEXAGON_A2_subh_l16_ll + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.h):sat + C Intrinsic Prototype: Word32 Q6_R_sub_RlRh_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRh_sat __builtin_HEXAGON_A2_subh_l16_sat_hl + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32.l,Rs32.l):sat + C Intrinsic Prototype: Word32 Q6_R_sub_RlRl_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_RlRl_sat __builtin_HEXAGON_A2_subh_l16_sat_ll + +/* ========================================================================== + Assembly Syntax: Rdd32=sub(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_sub_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_sub_PP __builtin_HEXAGON_A2_subp + +/* ========================================================================== + Assembly Syntax: Rd32=sub(#s10,Rs32) + C Intrinsic Prototype: Word32 Q6_R_sub_IR(Word32 Is10, Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_sub_IR __builtin_HEXAGON_A2_subri + +/* ========================================================================== + Assembly Syntax: Rd32=sub(Rt32,Rs32):sat + C Intrinsic Prototype: Word32 Q6_R_sub_RR_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_sub_RR_sat __builtin_HEXAGON_A2_subsat + +/* ========================================================================== + Assembly Syntax: Rd32=vaddh(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_vaddh_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vaddh_RR __builtin_HEXAGON_A2_svaddh + +/* ========================================================================== + Assembly Syntax: Rd32=vaddh(Rs32,Rt32):sat + C Intrinsic Prototype: Word32 Q6_R_vaddh_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vaddh_RR_sat __builtin_HEXAGON_A2_svaddhs + +/* ========================================================================== + Assembly Syntax: Rd32=vadduh(Rs32,Rt32):sat + C Intrinsic Prototype: Word32 Q6_R_vadduh_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vadduh_RR_sat __builtin_HEXAGON_A2_svadduhs + +/* ========================================================================== + Assembly Syntax: Rd32=vavgh(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_vavgh_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vavgh_RR __builtin_HEXAGON_A2_svavgh + +/* ========================================================================== + Assembly Syntax: Rd32=vavgh(Rs32,Rt32):rnd + C Intrinsic Prototype: Word32 Q6_R_vavgh_RR_rnd(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vavgh_RR_rnd __builtin_HEXAGON_A2_svavghs + +/* ========================================================================== + Assembly Syntax: Rd32=vnavgh(Rt32,Rs32) + C Intrinsic Prototype: Word32 Q6_R_vnavgh_RR(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vnavgh_RR __builtin_HEXAGON_A2_svnavgh + +/* ========================================================================== + Assembly Syntax: Rd32=vsubh(Rt32,Rs32) + C Intrinsic Prototype: Word32 Q6_R_vsubh_RR(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vsubh_RR __builtin_HEXAGON_A2_svsubh + +/* ========================================================================== + Assembly Syntax: Rd32=vsubh(Rt32,Rs32):sat + C Intrinsic Prototype: Word32 Q6_R_vsubh_RR_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vsubh_RR_sat __builtin_HEXAGON_A2_svsubhs + +/* ========================================================================== + Assembly Syntax: Rd32=vsubuh(Rt32,Rs32):sat + C Intrinsic Prototype: Word32 Q6_R_vsubuh_RR_sat(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vsubuh_RR_sat __builtin_HEXAGON_A2_svsubuhs + +/* ========================================================================== + Assembly Syntax: Rd32=swiz(Rs32) + C Intrinsic Prototype: Word32 Q6_R_swiz_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_swiz_R __builtin_HEXAGON_A2_swiz + +/* ========================================================================== + Assembly Syntax: Rd32=sxtb(Rs32) + C Intrinsic Prototype: Word32 Q6_R_sxtb_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_sxtb_R __builtin_HEXAGON_A2_sxtb + +/* ========================================================================== + Assembly Syntax: Rd32=sxth(Rs32) + C Intrinsic Prototype: Word32 Q6_R_sxth_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_sxth_R __builtin_HEXAGON_A2_sxth + +/* ========================================================================== + Assembly Syntax: Rdd32=sxtw(Rs32) + C Intrinsic Prototype: Word64 Q6_P_sxtw_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_sxtw_R __builtin_HEXAGON_A2_sxtw + +/* ========================================================================== + Assembly Syntax: Rd32=Rs32 + C Intrinsic Prototype: Word32 Q6_R_equals_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_equals_R __builtin_HEXAGON_A2_tfr + +/* ========================================================================== + Assembly Syntax: Rx32.h=#u16 + C Intrinsic Prototype: Word32 Q6_Rh_equals_I(Word32 Rx, Word32 Iu16) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Rh_equals_I __builtin_HEXAGON_A2_tfrih + +/* ========================================================================== + Assembly Syntax: Rx32.l=#u16 + C Intrinsic Prototype: Word32 Q6_Rl_equals_I(Word32 Rx, Word32 Iu16) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Rl_equals_I __builtin_HEXAGON_A2_tfril + +/* ========================================================================== + Assembly Syntax: Rdd32=Rss32 + C Intrinsic Prototype: Word64 Q6_P_equals_P(Word64 Rss) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_equals_P __builtin_HEXAGON_A2_tfrp + +/* ========================================================================== + Assembly Syntax: Rdd32=#s8 + C Intrinsic Prototype: Word64 Q6_P_equals_I(Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_equals_I __builtin_HEXAGON_A2_tfrpi + +/* ========================================================================== + Assembly Syntax: Rd32=#s16 + C Intrinsic Prototype: Word32 Q6_R_equals_I(Word32 Is16) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_equals_I __builtin_HEXAGON_A2_tfrsi + +/* ========================================================================== + Assembly Syntax: Rdd32=vabsh(Rss32) + C Intrinsic Prototype: Word64 Q6_P_vabsh_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsh_P __builtin_HEXAGON_A2_vabsh + +/* ========================================================================== + Assembly Syntax: Rdd32=vabsh(Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vabsh_P_sat(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsh_P_sat __builtin_HEXAGON_A2_vabshsat + +/* ========================================================================== + Assembly Syntax: Rdd32=vabsw(Rss32) + C Intrinsic Prototype: Word64 Q6_P_vabsw_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsw_P __builtin_HEXAGON_A2_vabsw + +/* ========================================================================== + Assembly Syntax: Rdd32=vabsw(Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vabsw_P_sat(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsw_P_sat __builtin_HEXAGON_A2_vabswsat + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddb(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vaddb_PP(Word64 Rss, Word64 Rtt) + Instruction Type: MAPPING + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_vaddb_PP __builtin_HEXAGON_A2_vaddb_map + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vaddh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaddh_PP __builtin_HEXAGON_A2_vaddh + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vaddh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaddh_PP_sat __builtin_HEXAGON_A2_vaddhs + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddub(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vaddub_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaddub_PP __builtin_HEXAGON_A2_vaddub + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddub(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vaddub_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaddub_PP_sat __builtin_HEXAGON_A2_vaddubs + +/* ========================================================================== + Assembly Syntax: Rdd32=vadduh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vadduh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vadduh_PP_sat __builtin_HEXAGON_A2_vadduhs + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vaddw_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaddw_PP __builtin_HEXAGON_A2_vaddw + +/* ========================================================================== + Assembly Syntax: Rdd32=vaddw(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vaddw_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaddw_PP_sat __builtin_HEXAGON_A2_vaddws + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vavgh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgh_PP __builtin_HEXAGON_A2_vavgh + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgh(Rss32,Rtt32):crnd + C Intrinsic Prototype: Word64 Q6_P_vavgh_PP_crnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgh_PP_crnd __builtin_HEXAGON_A2_vavghcr + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgh(Rss32,Rtt32):rnd + C Intrinsic Prototype: Word64 Q6_P_vavgh_PP_rnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgh_PP_rnd __builtin_HEXAGON_A2_vavghr + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgub(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vavgub_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgub_PP __builtin_HEXAGON_A2_vavgub + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgub(Rss32,Rtt32):rnd + C Intrinsic Prototype: Word64 Q6_P_vavgub_PP_rnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgub_PP_rnd __builtin_HEXAGON_A2_vavgubr + +/* ========================================================================== + Assembly Syntax: Rdd32=vavguh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vavguh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavguh_PP __builtin_HEXAGON_A2_vavguh + +/* ========================================================================== + Assembly Syntax: Rdd32=vavguh(Rss32,Rtt32):rnd + C Intrinsic Prototype: Word64 Q6_P_vavguh_PP_rnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavguh_PP_rnd __builtin_HEXAGON_A2_vavguhr + +/* ========================================================================== + Assembly Syntax: Rdd32=vavguw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vavguw_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavguw_PP __builtin_HEXAGON_A2_vavguw + +/* ========================================================================== + Assembly Syntax: Rdd32=vavguw(Rss32,Rtt32):rnd + C Intrinsic Prototype: Word64 Q6_P_vavguw_PP_rnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavguw_PP_rnd __builtin_HEXAGON_A2_vavguwr + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vavgw_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgw_PP __builtin_HEXAGON_A2_vavgw + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgw(Rss32,Rtt32):crnd + C Intrinsic Prototype: Word64 Q6_P_vavgw_PP_crnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgw_PP_crnd __builtin_HEXAGON_A2_vavgwcr + +/* ========================================================================== + Assembly Syntax: Rdd32=vavgw(Rss32,Rtt32):rnd + C Intrinsic Prototype: Word64 Q6_P_vavgw_PP_rnd(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vavgw_PP_rnd __builtin_HEXAGON_A2_vavgwr + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpb.eq(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmpb_eq_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpb_eq_PP __builtin_HEXAGON_A2_vcmpbeq + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpb.gtu(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmpb_gtu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpb_gtu_PP __builtin_HEXAGON_A2_vcmpbgtu + +/* ========================================================================== + Assembly Syntax: Pd4=vcmph.eq(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmph_eq_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmph_eq_PP __builtin_HEXAGON_A2_vcmpheq + +/* ========================================================================== + Assembly Syntax: Pd4=vcmph.gt(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmph_gt_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmph_gt_PP __builtin_HEXAGON_A2_vcmphgt + +/* ========================================================================== + Assembly Syntax: Pd4=vcmph.gtu(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmph_gtu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmph_gtu_PP __builtin_HEXAGON_A2_vcmphgtu + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpw.eq(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmpw_eq_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpw_eq_PP __builtin_HEXAGON_A2_vcmpweq + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpw.gt(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmpw_gt_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpw_gt_PP __builtin_HEXAGON_A2_vcmpwgt + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpw.gtu(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmpw_gtu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpw_gtu_PP __builtin_HEXAGON_A2_vcmpwgtu + +/* ========================================================================== + Assembly Syntax: Rdd32=vconj(Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vconj_P_sat(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vconj_P_sat __builtin_HEXAGON_A2_vconj + +/* ========================================================================== + Assembly Syntax: Rdd32=vmaxb(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vmaxb_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmaxb_PP __builtin_HEXAGON_A2_vmaxb + +/* ========================================================================== + Assembly Syntax: Rdd32=vmaxh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vmaxh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmaxh_PP __builtin_HEXAGON_A2_vmaxh + +/* ========================================================================== + Assembly Syntax: Rdd32=vmaxub(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vmaxub_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmaxub_PP __builtin_HEXAGON_A2_vmaxub + +/* ========================================================================== + Assembly Syntax: Rdd32=vmaxuh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vmaxuh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmaxuh_PP __builtin_HEXAGON_A2_vmaxuh + +/* ========================================================================== + Assembly Syntax: Rdd32=vmaxuw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vmaxuw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmaxuw_PP __builtin_HEXAGON_A2_vmaxuw + +/* ========================================================================== + Assembly Syntax: Rdd32=vmaxw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vmaxw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmaxw_PP __builtin_HEXAGON_A2_vmaxw + +/* ========================================================================== + Assembly Syntax: Rdd32=vminb(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vminb_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vminb_PP __builtin_HEXAGON_A2_vminb + +/* ========================================================================== + Assembly Syntax: Rdd32=vminh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vminh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vminh_PP __builtin_HEXAGON_A2_vminh + +/* ========================================================================== + Assembly Syntax: Rdd32=vminub(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vminub_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vminub_PP __builtin_HEXAGON_A2_vminub + +/* ========================================================================== + Assembly Syntax: Rdd32=vminuh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vminuh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vminuh_PP __builtin_HEXAGON_A2_vminuh + +/* ========================================================================== + Assembly Syntax: Rdd32=vminuw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vminuw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vminuw_PP __builtin_HEXAGON_A2_vminuw + +/* ========================================================================== + Assembly Syntax: Rdd32=vminw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vminw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vminw_PP __builtin_HEXAGON_A2_vminw + +/* ========================================================================== + Assembly Syntax: Rdd32=vnavgh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vnavgh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vnavgh_PP __builtin_HEXAGON_A2_vnavgh + +/* ========================================================================== + Assembly Syntax: Rdd32=vnavgh(Rtt32,Rss32):crnd:sat + C Intrinsic Prototype: Word64 Q6_P_vnavgh_PP_crnd_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vnavgh_PP_crnd_sat __builtin_HEXAGON_A2_vnavghcr + +/* ========================================================================== + Assembly Syntax: Rdd32=vnavgh(Rtt32,Rss32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vnavgh_PP_rnd_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vnavgh_PP_rnd_sat __builtin_HEXAGON_A2_vnavghr + +/* ========================================================================== + Assembly Syntax: Rdd32=vnavgw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vnavgw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vnavgw_PP __builtin_HEXAGON_A2_vnavgw + +/* ========================================================================== + Assembly Syntax: Rdd32=vnavgw(Rtt32,Rss32):crnd:sat + C Intrinsic Prototype: Word64 Q6_P_vnavgw_PP_crnd_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vnavgw_PP_crnd_sat __builtin_HEXAGON_A2_vnavgwcr + +/* ========================================================================== + Assembly Syntax: Rdd32=vnavgw(Rtt32,Rss32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vnavgw_PP_rnd_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vnavgw_PP_rnd_sat __builtin_HEXAGON_A2_vnavgwr + +/* ========================================================================== + Assembly Syntax: Rdd32=vraddub(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vraddub_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vraddub_PP __builtin_HEXAGON_A2_vraddub + +/* ========================================================================== + Assembly Syntax: Rxx32+=vraddub(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vraddubacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vraddubacc_PP __builtin_HEXAGON_A2_vraddub_acc + +/* ========================================================================== + Assembly Syntax: Rdd32=vrsadub(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrsadub_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrsadub_PP __builtin_HEXAGON_A2_vrsadub + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrsadub(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrsadubacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrsadubacc_PP __builtin_HEXAGON_A2_vrsadub_acc + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubb(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vsubb_PP(Word64 Rss, Word64 Rtt) + Instruction Type: MAPPING + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_vsubb_PP __builtin_HEXAGON_A2_vsubb_map + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsubh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubh_PP __builtin_HEXAGON_A2_vsubh + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubh(Rtt32,Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vsubh_PP_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubh_PP_sat __builtin_HEXAGON_A2_vsubhs + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubub(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsubub_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubub_PP __builtin_HEXAGON_A2_vsubub + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubub(Rtt32,Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vsubub_PP_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubub_PP_sat __builtin_HEXAGON_A2_vsububs + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubuh(Rtt32,Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vsubuh_PP_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubuh_PP_sat __builtin_HEXAGON_A2_vsubuhs + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsubw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubw_PP __builtin_HEXAGON_A2_vsubw + +/* ========================================================================== + Assembly Syntax: Rdd32=vsubw(Rtt32,Rss32):sat + C Intrinsic Prototype: Word64 Q6_P_vsubw_PP_sat(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsubw_PP_sat __builtin_HEXAGON_A2_vsubws + +/* ========================================================================== + Assembly Syntax: Rd32=xor(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_xor_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_xor_RR __builtin_HEXAGON_A2_xor + +/* ========================================================================== + Assembly Syntax: Rdd32=xor(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_xor_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_xor_PP __builtin_HEXAGON_A2_xorp + +/* ========================================================================== + Assembly Syntax: Rd32=zxtb(Rs32) + C Intrinsic Prototype: Word32 Q6_R_zxtb_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_zxtb_R __builtin_HEXAGON_A2_zxtb + +/* ========================================================================== + Assembly Syntax: Rd32=zxth(Rs32) + C Intrinsic Prototype: Word32 Q6_R_zxth_R(Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_zxth_R __builtin_HEXAGON_A2_zxth + +/* ========================================================================== + Assembly Syntax: Rd32=and(Rt32,~Rs32) + C Intrinsic Prototype: Word32 Q6_R_and_RnR(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_and_RnR __builtin_HEXAGON_A4_andn + +/* ========================================================================== + Assembly Syntax: Rdd32=and(Rtt32,~Rss32) + C Intrinsic Prototype: Word64 Q6_P_and_PnP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_and_PnP __builtin_HEXAGON_A4_andnp + +/* ========================================================================== + Assembly Syntax: Rdd32=bitsplit(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_bitsplit_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_bitsplit_RR __builtin_HEXAGON_A4_bitsplit + +/* ========================================================================== + Assembly Syntax: Rdd32=bitsplit(Rs32,#u5) + C Intrinsic Prototype: Word64 Q6_P_bitsplit_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_bitsplit_RI __builtin_HEXAGON_A4_bitspliti + +/* ========================================================================== + Assembly Syntax: Pd4=boundscheck(Rs32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_boundscheck_RP(Word32 Rs, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_boundscheck_RP __builtin_HEXAGON_A4_boundscheck + +/* ========================================================================== + Assembly Syntax: Pd4=cmpb.eq(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmpb_eq_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmpb_eq_RR __builtin_HEXAGON_A4_cmpbeq + +/* ========================================================================== + Assembly Syntax: Pd4=cmpb.eq(Rs32,#u8) + C Intrinsic Prototype: Byte Q6_p_cmpb_eq_RI(Word32 Rs, Word32 Iu8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmpb_eq_RI __builtin_HEXAGON_A4_cmpbeqi + +/* ========================================================================== + Assembly Syntax: Pd4=cmpb.gt(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmpb_gt_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmpb_gt_RR __builtin_HEXAGON_A4_cmpbgt + +/* ========================================================================== + Assembly Syntax: Pd4=cmpb.gt(Rs32,#s8) + C Intrinsic Prototype: Byte Q6_p_cmpb_gt_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmpb_gt_RI __builtin_HEXAGON_A4_cmpbgti + +/* ========================================================================== + Assembly Syntax: Pd4=cmpb.gtu(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmpb_gtu_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmpb_gtu_RR __builtin_HEXAGON_A4_cmpbgtu + +/* ========================================================================== + Assembly Syntax: Pd4=cmpb.gtu(Rs32,#u7) + C Intrinsic Prototype: Byte Q6_p_cmpb_gtu_RI(Word32 Rs, Word32 Iu7) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmpb_gtu_RI __builtin_HEXAGON_A4_cmpbgtui + +/* ========================================================================== + Assembly Syntax: Pd4=cmph.eq(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmph_eq_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmph_eq_RR __builtin_HEXAGON_A4_cmpheq + +/* ========================================================================== + Assembly Syntax: Pd4=cmph.eq(Rs32,#s8) + C Intrinsic Prototype: Byte Q6_p_cmph_eq_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmph_eq_RI __builtin_HEXAGON_A4_cmpheqi + +/* ========================================================================== + Assembly Syntax: Pd4=cmph.gt(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmph_gt_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmph_gt_RR __builtin_HEXAGON_A4_cmphgt + +/* ========================================================================== + Assembly Syntax: Pd4=cmph.gt(Rs32,#s8) + C Intrinsic Prototype: Byte Q6_p_cmph_gt_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmph_gt_RI __builtin_HEXAGON_A4_cmphgti + +/* ========================================================================== + Assembly Syntax: Pd4=cmph.gtu(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmph_gtu_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmph_gtu_RR __builtin_HEXAGON_A4_cmphgtu + +/* ========================================================================== + Assembly Syntax: Pd4=cmph.gtu(Rs32,#u7) + C Intrinsic Prototype: Byte Q6_p_cmph_gtu_RI(Word32 Rs, Word32 Iu7) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmph_gtu_RI __builtin_HEXAGON_A4_cmphgtui + +/* ========================================================================== + Assembly Syntax: Rdd32=combine(#s8,Rs32) + C Intrinsic Prototype: Word64 Q6_P_combine_IR(Word32 Is8, Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_combine_IR __builtin_HEXAGON_A4_combineir + +/* ========================================================================== + Assembly Syntax: Rdd32=combine(Rs32,#s8) + C Intrinsic Prototype: Word64 Q6_P_combine_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_combine_RI __builtin_HEXAGON_A4_combineri + +/* ========================================================================== + Assembly Syntax: Rd32=cround(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_cround_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cround_RI __builtin_HEXAGON_A4_cround_ri + +/* ========================================================================== + Assembly Syntax: Rd32=cround(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_cround_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cround_RR __builtin_HEXAGON_A4_cround_rr + +/* ========================================================================== + Assembly Syntax: Rd32=modwrap(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_modwrap_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_modwrap_RR __builtin_HEXAGON_A4_modwrapu + +/* ========================================================================== + Assembly Syntax: Rd32=or(Rt32,~Rs32) + C Intrinsic Prototype: Word32 Q6_R_or_RnR(Word32 Rt, Word32 Rs) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_or_RnR __builtin_HEXAGON_A4_orn + +/* ========================================================================== + Assembly Syntax: Rdd32=or(Rtt32,~Rss32) + C Intrinsic Prototype: Word64 Q6_P_or_PnP(Word64 Rtt, Word64 Rss) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_or_PnP __builtin_HEXAGON_A4_ornp + +/* ========================================================================== + Assembly Syntax: Rd32=cmp.eq(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_cmp_eq_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_cmp_eq_RR __builtin_HEXAGON_A4_rcmpeq + +/* ========================================================================== + Assembly Syntax: Rd32=cmp.eq(Rs32,#s8) + C Intrinsic Prototype: Word32 Q6_R_cmp_eq_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_cmp_eq_RI __builtin_HEXAGON_A4_rcmpeqi + +/* ========================================================================== + Assembly Syntax: Rd32=!cmp.eq(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_not_cmp_eq_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_not_cmp_eq_RR __builtin_HEXAGON_A4_rcmpneq + +/* ========================================================================== + Assembly Syntax: Rd32=!cmp.eq(Rs32,#s8) + C Intrinsic Prototype: Word32 Q6_R_not_cmp_eq_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_not_cmp_eq_RI __builtin_HEXAGON_A4_rcmpneqi + +/* ========================================================================== + Assembly Syntax: Rd32=round(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_round_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_round_RI __builtin_HEXAGON_A4_round_ri + +/* ========================================================================== + Assembly Syntax: Rd32=round(Rs32,#u5):sat + C Intrinsic Prototype: Word32 Q6_R_round_RI_sat(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_round_RI_sat __builtin_HEXAGON_A4_round_ri_sat + +/* ========================================================================== + Assembly Syntax: Rd32=round(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_round_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_round_RR __builtin_HEXAGON_A4_round_rr + +/* ========================================================================== + Assembly Syntax: Rd32=round(Rs32,Rt32):sat + C Intrinsic Prototype: Word32 Q6_R_round_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_round_RR_sat __builtin_HEXAGON_A4_round_rr_sat + +/* ========================================================================== + Assembly Syntax: Pd4=tlbmatch(Rss32,Rt32) + C Intrinsic Prototype: Byte Q6_p_tlbmatch_PR(Word64 Rss, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_tlbmatch_PR __builtin_HEXAGON_A4_tlbmatch + +/* ========================================================================== + Assembly Syntax: Pd4=any8(vcmpb.eq(Rss32,Rtt32)) + C Intrinsic Prototype: Byte Q6_p_any8_vcmpb_eq_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_any8_vcmpb_eq_PP __builtin_HEXAGON_A4_vcmpbeq_any + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpb.eq(Rss32,#u8) + C Intrinsic Prototype: Byte Q6_p_vcmpb_eq_PI(Word64 Rss, Word32 Iu8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpb_eq_PI __builtin_HEXAGON_A4_vcmpbeqi + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpb.gt(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_vcmpb_gt_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpb_gt_PP __builtin_HEXAGON_A4_vcmpbgt + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpb.gt(Rss32,#s8) + C Intrinsic Prototype: Byte Q6_p_vcmpb_gt_PI(Word64 Rss, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpb_gt_PI __builtin_HEXAGON_A4_vcmpbgti + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpb.gtu(Rss32,#u7) + C Intrinsic Prototype: Byte Q6_p_vcmpb_gtu_PI(Word64 Rss, Word32 Iu7) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpb_gtu_PI __builtin_HEXAGON_A4_vcmpbgtui + +/* ========================================================================== + Assembly Syntax: Pd4=vcmph.eq(Rss32,#s8) + C Intrinsic Prototype: Byte Q6_p_vcmph_eq_PI(Word64 Rss, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmph_eq_PI __builtin_HEXAGON_A4_vcmpheqi + +/* ========================================================================== + Assembly Syntax: Pd4=vcmph.gt(Rss32,#s8) + C Intrinsic Prototype: Byte Q6_p_vcmph_gt_PI(Word64 Rss, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmph_gt_PI __builtin_HEXAGON_A4_vcmphgti + +/* ========================================================================== + Assembly Syntax: Pd4=vcmph.gtu(Rss32,#u7) + C Intrinsic Prototype: Byte Q6_p_vcmph_gtu_PI(Word64 Rss, Word32 Iu7) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmph_gtu_PI __builtin_HEXAGON_A4_vcmphgtui + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpw.eq(Rss32,#s8) + C Intrinsic Prototype: Byte Q6_p_vcmpw_eq_PI(Word64 Rss, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpw_eq_PI __builtin_HEXAGON_A4_vcmpweqi + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpw.gt(Rss32,#s8) + C Intrinsic Prototype: Byte Q6_p_vcmpw_gt_PI(Word64 Rss, Word32 Is8) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpw_gt_PI __builtin_HEXAGON_A4_vcmpwgti + +/* ========================================================================== + Assembly Syntax: Pd4=vcmpw.gtu(Rss32,#u7) + C Intrinsic Prototype: Byte Q6_p_vcmpw_gtu_PI(Word64 Rss, Word32 Iu7) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_vcmpw_gtu_PI __builtin_HEXAGON_A4_vcmpwgtui + +/* ========================================================================== + Assembly Syntax: Rxx32=vrmaxh(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrmaxh_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmaxh_PR __builtin_HEXAGON_A4_vrmaxh + +/* ========================================================================== + Assembly Syntax: Rxx32=vrmaxuh(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrmaxuh_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmaxuh_PR __builtin_HEXAGON_A4_vrmaxuh + +/* ========================================================================== + Assembly Syntax: Rxx32=vrmaxuw(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrmaxuw_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmaxuw_PR __builtin_HEXAGON_A4_vrmaxuw + +/* ========================================================================== + Assembly Syntax: Rxx32=vrmaxw(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrmaxw_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmaxw_PR __builtin_HEXAGON_A4_vrmaxw + +/* ========================================================================== + Assembly Syntax: Rxx32=vrminh(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrminh_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrminh_PR __builtin_HEXAGON_A4_vrminh + +/* ========================================================================== + Assembly Syntax: Rxx32=vrminuh(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrminuh_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrminuh_PR __builtin_HEXAGON_A4_vrminuh + +/* ========================================================================== + Assembly Syntax: Rxx32=vrminuw(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrminuw_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrminuw_PR __builtin_HEXAGON_A4_vrminuw + +/* ========================================================================== + Assembly Syntax: Rxx32=vrminw(Rss32,Ru32) + C Intrinsic Prototype: Word64 Q6_P_vrminw_PR(Word64 Rxx, Word64 Rss, Word32 Ru) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrminw_PR __builtin_HEXAGON_A4_vrminw + +/* ========================================================================== + Assembly Syntax: Rd32=vaddhub(Rss32,Rtt32):sat + C Intrinsic Prototype: Word32 Q6_R_vaddhub_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vaddhub_PP_sat __builtin_HEXAGON_A5_vaddhubs + +/* ========================================================================== + Assembly Syntax: Pd4=all8(Ps4) + C Intrinsic Prototype: Byte Q6_p_all8_p(Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_all8_p __builtin_HEXAGON_C2_all8 + +/* ========================================================================== + Assembly Syntax: Pd4=and(Pt4,Ps4) + C Intrinsic Prototype: Byte Q6_p_and_pp(Byte Pt, Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_and_pp __builtin_HEXAGON_C2_and + +/* ========================================================================== + Assembly Syntax: Pd4=and(Pt4,!Ps4) + C Intrinsic Prototype: Byte Q6_p_and_pnp(Byte Pt, Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_and_pnp __builtin_HEXAGON_C2_andn + +/* ========================================================================== + Assembly Syntax: Pd4=any8(Ps4) + C Intrinsic Prototype: Byte Q6_p_any8_p(Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_any8_p __builtin_HEXAGON_C2_any8 + +/* ========================================================================== + Assembly Syntax: Pd4=bitsclr(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_bitsclr_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_bitsclr_RR __builtin_HEXAGON_C2_bitsclr + +/* ========================================================================== + Assembly Syntax: Pd4=bitsclr(Rs32,#u6) + C Intrinsic Prototype: Byte Q6_p_bitsclr_RI(Word32 Rs, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_bitsclr_RI __builtin_HEXAGON_C2_bitsclri + +/* ========================================================================== + Assembly Syntax: Pd4=bitsset(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_bitsset_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_bitsset_RR __builtin_HEXAGON_C2_bitsset + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.eq(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmp_eq_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_eq_RR __builtin_HEXAGON_C2_cmpeq + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.eq(Rs32,#s10) + C Intrinsic Prototype: Byte Q6_p_cmp_eq_RI(Word32 Rs, Word32 Is10) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_eq_RI __builtin_HEXAGON_C2_cmpeqi + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.eq(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_cmp_eq_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmp_eq_PP __builtin_HEXAGON_C2_cmpeqp + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.ge(Rs32,#s8) + C Intrinsic Prototype: Byte Q6_p_cmp_ge_RI(Word32 Rs, Word32 Is8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_ge_RI __builtin_HEXAGON_C2_cmpgei + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.geu(Rs32,#u8) + C Intrinsic Prototype: Byte Q6_p_cmp_geu_RI(Word32 Rs, Word32 Iu8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_geu_RI __builtin_HEXAGON_C2_cmpgeui + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.gt(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmp_gt_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_gt_RR __builtin_HEXAGON_C2_cmpgt + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.gt(Rs32,#s10) + C Intrinsic Prototype: Byte Q6_p_cmp_gt_RI(Word32 Rs, Word32 Is10) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_gt_RI __builtin_HEXAGON_C2_cmpgti + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.gt(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_cmp_gt_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmp_gt_PP __builtin_HEXAGON_C2_cmpgtp + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.gtu(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmp_gtu_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_gtu_RR __builtin_HEXAGON_C2_cmpgtu + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.gtu(Rs32,#u9) + C Intrinsic Prototype: Byte Q6_p_cmp_gtu_RI(Word32 Rs, Word32 Iu9) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_gtu_RI __builtin_HEXAGON_C2_cmpgtui + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.gtu(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_cmp_gtu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_cmp_gtu_PP __builtin_HEXAGON_C2_cmpgtup + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.lt(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmp_lt_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_lt_RR __builtin_HEXAGON_C2_cmplt + +/* ========================================================================== + Assembly Syntax: Pd4=cmp.ltu(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_cmp_ltu_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_cmp_ltu_RR __builtin_HEXAGON_C2_cmpltu + +/* ========================================================================== + Assembly Syntax: Rdd32=mask(Pt4) + C Intrinsic Prototype: Word64 Q6_P_mask_p(Byte Pt) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mask_p __builtin_HEXAGON_C2_mask + +/* ========================================================================== + Assembly Syntax: Rd32=mux(Pu4,Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mux_pRR(Byte Pu, Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_mux_pRR __builtin_HEXAGON_C2_mux + +/* ========================================================================== + Assembly Syntax: Rd32=mux(Pu4,#s8,#S8) + C Intrinsic Prototype: Word32 Q6_R_mux_pII(Byte Pu, Word32 Is8, Word32 IS8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_mux_pII __builtin_HEXAGON_C2_muxii + +/* ========================================================================== + Assembly Syntax: Rd32=mux(Pu4,Rs32,#s8) + C Intrinsic Prototype: Word32 Q6_R_mux_pRI(Byte Pu, Word32 Rs, Word32 Is8) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_mux_pRI __builtin_HEXAGON_C2_muxir + +/* ========================================================================== + Assembly Syntax: Rd32=mux(Pu4,#s8,Rs32) + C Intrinsic Prototype: Word32 Q6_R_mux_pIR(Byte Pu, Word32 Is8, Word32 Rs) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_mux_pIR __builtin_HEXAGON_C2_muxri + +/* ========================================================================== + Assembly Syntax: Pd4=not(Ps4) + C Intrinsic Prototype: Byte Q6_p_not_p(Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_p __builtin_HEXAGON_C2_not + +/* ========================================================================== + Assembly Syntax: Pd4=or(Pt4,Ps4) + C Intrinsic Prototype: Byte Q6_p_or_pp(Byte Pt, Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_or_pp __builtin_HEXAGON_C2_or + +/* ========================================================================== + Assembly Syntax: Pd4=or(Pt4,!Ps4) + C Intrinsic Prototype: Byte Q6_p_or_pnp(Byte Pt, Byte Ps) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_or_pnp __builtin_HEXAGON_C2_orn + +/* ========================================================================== + Assembly Syntax: Pd4=Ps4 + C Intrinsic Prototype: Byte Q6_p_equals_p(Byte Ps) + Instruction Type: MAPPING + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_equals_p __builtin_HEXAGON_C2_pxfer_map + +/* ========================================================================== + Assembly Syntax: Rd32=Ps4 + C Intrinsic Prototype: Word32 Q6_R_equals_p(Byte Ps) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_equals_p __builtin_HEXAGON_C2_tfrpr + +/* ========================================================================== + Assembly Syntax: Pd4=Rs32 + C Intrinsic Prototype: Byte Q6_p_equals_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_equals_R __builtin_HEXAGON_C2_tfrrp + +/* ========================================================================== + Assembly Syntax: Rd32=vitpack(Ps4,Pt4) + C Intrinsic Prototype: Word32 Q6_R_vitpack_pp(Byte Ps, Byte Pt) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vitpack_pp __builtin_HEXAGON_C2_vitpack + +/* ========================================================================== + Assembly Syntax: Rdd32=vmux(Pu4,Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vmux_pPP(Byte Pu, Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmux_pPP __builtin_HEXAGON_C2_vmux + +/* ========================================================================== + Assembly Syntax: Pd4=xor(Ps4,Pt4) + C Intrinsic Prototype: Byte Q6_p_xor_pp(Byte Ps, Byte Pt) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_xor_pp __builtin_HEXAGON_C2_xor + +/* ========================================================================== + Assembly Syntax: Pd4=and(Ps4,and(Pt4,Pu4)) + C Intrinsic Prototype: Byte Q6_p_and_and_ppp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_and_and_ppp __builtin_HEXAGON_C4_and_and + +/* ========================================================================== + Assembly Syntax: Pd4=and(Ps4,and(Pt4,!Pu4)) + C Intrinsic Prototype: Byte Q6_p_and_and_ppnp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_and_and_ppnp __builtin_HEXAGON_C4_and_andn + +/* ========================================================================== + Assembly Syntax: Pd4=and(Ps4,or(Pt4,Pu4)) + C Intrinsic Prototype: Byte Q6_p_and_or_ppp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_and_or_ppp __builtin_HEXAGON_C4_and_or + +/* ========================================================================== + Assembly Syntax: Pd4=and(Ps4,or(Pt4,!Pu4)) + C Intrinsic Prototype: Byte Q6_p_and_or_ppnp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_and_or_ppnp __builtin_HEXAGON_C4_and_orn + +/* ========================================================================== + Assembly Syntax: Pd4=!cmp.gt(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_not_cmp_gt_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_not_cmp_gt_RR __builtin_HEXAGON_C4_cmplte + +/* ========================================================================== + Assembly Syntax: Pd4=!cmp.gt(Rs32,#s10) + C Intrinsic Prototype: Byte Q6_p_not_cmp_gt_RI(Word32 Rs, Word32 Is10) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_not_cmp_gt_RI __builtin_HEXAGON_C4_cmpltei + +/* ========================================================================== + Assembly Syntax: Pd4=!cmp.gtu(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_not_cmp_gtu_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_not_cmp_gtu_RR __builtin_HEXAGON_C4_cmplteu + +/* ========================================================================== + Assembly Syntax: Pd4=!cmp.gtu(Rs32,#u9) + C Intrinsic Prototype: Byte Q6_p_not_cmp_gtu_RI(Word32 Rs, Word32 Iu9) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_not_cmp_gtu_RI __builtin_HEXAGON_C4_cmplteui + +/* ========================================================================== + Assembly Syntax: Pd4=!cmp.eq(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_not_cmp_eq_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_not_cmp_eq_RR __builtin_HEXAGON_C4_cmpneq + +/* ========================================================================== + Assembly Syntax: Pd4=!cmp.eq(Rs32,#s10) + C Intrinsic Prototype: Byte Q6_p_not_cmp_eq_RI(Word32 Rs, Word32 Is10) + Instruction Type: ALU32_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_p_not_cmp_eq_RI __builtin_HEXAGON_C4_cmpneqi + +/* ========================================================================== + Assembly Syntax: Pd4=fastcorner9(Ps4,Pt4) + C Intrinsic Prototype: Byte Q6_p_fastcorner9_pp(Byte Ps, Byte Pt) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_fastcorner9_pp __builtin_HEXAGON_C4_fastcorner9 + +/* ========================================================================== + Assembly Syntax: Pd4=!fastcorner9(Ps4,Pt4) + C Intrinsic Prototype: Byte Q6_p_not_fastcorner9_pp(Byte Ps, Byte Pt) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_fastcorner9_pp __builtin_HEXAGON_C4_fastcorner9_not + +/* ========================================================================== + Assembly Syntax: Pd4=!bitsclr(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_not_bitsclr_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_bitsclr_RR __builtin_HEXAGON_C4_nbitsclr + +/* ========================================================================== + Assembly Syntax: Pd4=!bitsclr(Rs32,#u6) + C Intrinsic Prototype: Byte Q6_p_not_bitsclr_RI(Word32 Rs, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_bitsclr_RI __builtin_HEXAGON_C4_nbitsclri + +/* ========================================================================== + Assembly Syntax: Pd4=!bitsset(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_not_bitsset_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_bitsset_RR __builtin_HEXAGON_C4_nbitsset + +/* ========================================================================== + Assembly Syntax: Pd4=or(Ps4,and(Pt4,Pu4)) + C Intrinsic Prototype: Byte Q6_p_or_and_ppp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_or_and_ppp __builtin_HEXAGON_C4_or_and + +/* ========================================================================== + Assembly Syntax: Pd4=or(Ps4,and(Pt4,!Pu4)) + C Intrinsic Prototype: Byte Q6_p_or_and_ppnp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_or_and_ppnp __builtin_HEXAGON_C4_or_andn + +/* ========================================================================== + Assembly Syntax: Pd4=or(Ps4,or(Pt4,Pu4)) + C Intrinsic Prototype: Byte Q6_p_or_or_ppp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_or_or_ppp __builtin_HEXAGON_C4_or_or + +/* ========================================================================== + Assembly Syntax: Pd4=or(Ps4,or(Pt4,!Pu4)) + C Intrinsic Prototype: Byte Q6_p_or_or_ppnp(Byte Ps, Byte Pt, Byte Pu) + Instruction Type: CR + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_or_or_ppnp __builtin_HEXAGON_C4_or_orn + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_d2df(Rss32) + C Intrinsic Prototype: Float64 Q6_P_convert_d2df_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_d2df_P __builtin_HEXAGON_F2_conv_d2df + +/* ========================================================================== + Assembly Syntax: Rd32=convert_d2sf(Rss32) + C Intrinsic Prototype: Float32 Q6_R_convert_d2sf_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_d2sf_P __builtin_HEXAGON_F2_conv_d2sf + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_df2d(Rss32) + C Intrinsic Prototype: Word64 Q6_P_convert_df2d_P(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_df2d_P __builtin_HEXAGON_F2_conv_df2d + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_df2d(Rss32):chop + C Intrinsic Prototype: Word64 Q6_P_convert_df2d_P_chop(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_df2d_P_chop __builtin_HEXAGON_F2_conv_df2d_chop + +/* ========================================================================== + Assembly Syntax: Rd32=convert_df2sf(Rss32) + C Intrinsic Prototype: Float32 Q6_R_convert_df2sf_P(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_df2sf_P __builtin_HEXAGON_F2_conv_df2sf + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_df2ud(Rss32) + C Intrinsic Prototype: Word64 Q6_P_convert_df2ud_P(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_df2ud_P __builtin_HEXAGON_F2_conv_df2ud + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_df2ud(Rss32):chop + C Intrinsic Prototype: Word64 Q6_P_convert_df2ud_P_chop(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_df2ud_P_chop __builtin_HEXAGON_F2_conv_df2ud_chop + +/* ========================================================================== + Assembly Syntax: Rd32=convert_df2uw(Rss32) + C Intrinsic Prototype: Word32 Q6_R_convert_df2uw_P(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_df2uw_P __builtin_HEXAGON_F2_conv_df2uw + +/* ========================================================================== + Assembly Syntax: Rd32=convert_df2uw(Rss32):chop + C Intrinsic Prototype: Word32 Q6_R_convert_df2uw_P_chop(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_df2uw_P_chop __builtin_HEXAGON_F2_conv_df2uw_chop + +/* ========================================================================== + Assembly Syntax: Rd32=convert_df2w(Rss32) + C Intrinsic Prototype: Word32 Q6_R_convert_df2w_P(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_df2w_P __builtin_HEXAGON_F2_conv_df2w + +/* ========================================================================== + Assembly Syntax: Rd32=convert_df2w(Rss32):chop + C Intrinsic Prototype: Word32 Q6_R_convert_df2w_P_chop(Float64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_df2w_P_chop __builtin_HEXAGON_F2_conv_df2w_chop + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_sf2d(Rs32) + C Intrinsic Prototype: Word64 Q6_P_convert_sf2d_R(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_sf2d_R __builtin_HEXAGON_F2_conv_sf2d + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_sf2d(Rs32):chop + C Intrinsic Prototype: Word64 Q6_P_convert_sf2d_R_chop(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_sf2d_R_chop __builtin_HEXAGON_F2_conv_sf2d_chop + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_sf2df(Rs32) + C Intrinsic Prototype: Float64 Q6_P_convert_sf2df_R(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_sf2df_R __builtin_HEXAGON_F2_conv_sf2df + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_sf2ud(Rs32) + C Intrinsic Prototype: Word64 Q6_P_convert_sf2ud_R(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_sf2ud_R __builtin_HEXAGON_F2_conv_sf2ud + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_sf2ud(Rs32):chop + C Intrinsic Prototype: Word64 Q6_P_convert_sf2ud_R_chop(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_sf2ud_R_chop __builtin_HEXAGON_F2_conv_sf2ud_chop + +/* ========================================================================== + Assembly Syntax: Rd32=convert_sf2uw(Rs32) + C Intrinsic Prototype: Word32 Q6_R_convert_sf2uw_R(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_sf2uw_R __builtin_HEXAGON_F2_conv_sf2uw + +/* ========================================================================== + Assembly Syntax: Rd32=convert_sf2uw(Rs32):chop + C Intrinsic Prototype: Word32 Q6_R_convert_sf2uw_R_chop(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_sf2uw_R_chop __builtin_HEXAGON_F2_conv_sf2uw_chop + +/* ========================================================================== + Assembly Syntax: Rd32=convert_sf2w(Rs32) + C Intrinsic Prototype: Word32 Q6_R_convert_sf2w_R(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_sf2w_R __builtin_HEXAGON_F2_conv_sf2w + +/* ========================================================================== + Assembly Syntax: Rd32=convert_sf2w(Rs32):chop + C Intrinsic Prototype: Word32 Q6_R_convert_sf2w_R_chop(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_sf2w_R_chop __builtin_HEXAGON_F2_conv_sf2w_chop + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_ud2df(Rss32) + C Intrinsic Prototype: Float64 Q6_P_convert_ud2df_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_ud2df_P __builtin_HEXAGON_F2_conv_ud2df + +/* ========================================================================== + Assembly Syntax: Rd32=convert_ud2sf(Rss32) + C Intrinsic Prototype: Float32 Q6_R_convert_ud2sf_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_ud2sf_P __builtin_HEXAGON_F2_conv_ud2sf + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_uw2df(Rs32) + C Intrinsic Prototype: Float64 Q6_P_convert_uw2df_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_uw2df_R __builtin_HEXAGON_F2_conv_uw2df + +/* ========================================================================== + Assembly Syntax: Rd32=convert_uw2sf(Rs32) + C Intrinsic Prototype: Float32 Q6_R_convert_uw2sf_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_uw2sf_R __builtin_HEXAGON_F2_conv_uw2sf + +/* ========================================================================== + Assembly Syntax: Rdd32=convert_w2df(Rs32) + C Intrinsic Prototype: Float64 Q6_P_convert_w2df_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_convert_w2df_R __builtin_HEXAGON_F2_conv_w2df + +/* ========================================================================== + Assembly Syntax: Rd32=convert_w2sf(Rs32) + C Intrinsic Prototype: Float32 Q6_R_convert_w2sf_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_convert_w2sf_R __builtin_HEXAGON_F2_conv_w2sf + +/* ========================================================================== + Assembly Syntax: Pd4=dfclass(Rss32,#u5) + C Intrinsic Prototype: Byte Q6_p_dfclass_PI(Float64 Rss, Word32 Iu5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_dfclass_PI __builtin_HEXAGON_F2_dfclass + +/* ========================================================================== + Assembly Syntax: Pd4=dfcmp.eq(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_dfcmp_eq_PP(Float64 Rss, Float64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_dfcmp_eq_PP __builtin_HEXAGON_F2_dfcmpeq + +/* ========================================================================== + Assembly Syntax: Pd4=dfcmp.ge(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_dfcmp_ge_PP(Float64 Rss, Float64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_dfcmp_ge_PP __builtin_HEXAGON_F2_dfcmpge + +/* ========================================================================== + Assembly Syntax: Pd4=dfcmp.gt(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_dfcmp_gt_PP(Float64 Rss, Float64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_dfcmp_gt_PP __builtin_HEXAGON_F2_dfcmpgt + +/* ========================================================================== + Assembly Syntax: Pd4=dfcmp.uo(Rss32,Rtt32) + C Intrinsic Prototype: Byte Q6_p_dfcmp_uo_PP(Float64 Rss, Float64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_dfcmp_uo_PP __builtin_HEXAGON_F2_dfcmpuo + +/* ========================================================================== + Assembly Syntax: Rdd32=dfmake(#u10):neg + C Intrinsic Prototype: Float64 Q6_P_dfmake_I_neg(Word32 Iu10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmake_I_neg __builtin_HEXAGON_F2_dfimm_n + +/* ========================================================================== + Assembly Syntax: Rdd32=dfmake(#u10):pos + C Intrinsic Prototype: Float64 Q6_P_dfmake_I_pos(Word32 Iu10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmake_I_pos __builtin_HEXAGON_F2_dfimm_p + +/* ========================================================================== + Assembly Syntax: Rd32=sfadd(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfadd_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfadd_RR __builtin_HEXAGON_F2_sfadd + +/* ========================================================================== + Assembly Syntax: Pd4=sfclass(Rs32,#u5) + C Intrinsic Prototype: Byte Q6_p_sfclass_RI(Float32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_sfclass_RI __builtin_HEXAGON_F2_sfclass + +/* ========================================================================== + Assembly Syntax: Pd4=sfcmp.eq(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_sfcmp_eq_RR(Float32 Rs, Float32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_sfcmp_eq_RR __builtin_HEXAGON_F2_sfcmpeq + +/* ========================================================================== + Assembly Syntax: Pd4=sfcmp.ge(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_sfcmp_ge_RR(Float32 Rs, Float32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_sfcmp_ge_RR __builtin_HEXAGON_F2_sfcmpge + +/* ========================================================================== + Assembly Syntax: Pd4=sfcmp.gt(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_sfcmp_gt_RR(Float32 Rs, Float32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_sfcmp_gt_RR __builtin_HEXAGON_F2_sfcmpgt + +/* ========================================================================== + Assembly Syntax: Pd4=sfcmp.uo(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_sfcmp_uo_RR(Float32 Rs, Float32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_sfcmp_uo_RR __builtin_HEXAGON_F2_sfcmpuo + +/* ========================================================================== + Assembly Syntax: Rd32=sffixupd(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sffixupd_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sffixupd_RR __builtin_HEXAGON_F2_sffixupd + +/* ========================================================================== + Assembly Syntax: Rd32=sffixupn(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sffixupn_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sffixupn_RR __builtin_HEXAGON_F2_sffixupn + +/* ========================================================================== + Assembly Syntax: Rd32=sffixupr(Rs32) + C Intrinsic Prototype: Float32 Q6_R_sffixupr_R(Float32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sffixupr_R __builtin_HEXAGON_F2_sffixupr + +/* ========================================================================== + Assembly Syntax: Rx32+=sfmpy(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfmpyacc_RR(Float32 Rx, Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmpyacc_RR __builtin_HEXAGON_F2_sffma + +/* ========================================================================== + Assembly Syntax: Rx32+=sfmpy(Rs32,Rt32):lib + C Intrinsic Prototype: Float32 Q6_R_sfmpyacc_RR_lib(Float32 Rx, Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmpyacc_RR_lib __builtin_HEXAGON_F2_sffma_lib + +/* ========================================================================== + Assembly Syntax: Rx32+=sfmpy(Rs32,Rt32,Pu4):scale + C Intrinsic Prototype: Float32 Q6_R_sfmpyacc_RRp_scale(Float32 Rx, Float32 Rs, Float32 Rt, Byte Pu) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmpyacc_RRp_scale __builtin_HEXAGON_F2_sffma_sc + +/* ========================================================================== + Assembly Syntax: Rx32-=sfmpy(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfmpynac_RR(Float32 Rx, Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmpynac_RR __builtin_HEXAGON_F2_sffms + +/* ========================================================================== + Assembly Syntax: Rx32-=sfmpy(Rs32,Rt32):lib + C Intrinsic Prototype: Float32 Q6_R_sfmpynac_RR_lib(Float32 Rx, Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmpynac_RR_lib __builtin_HEXAGON_F2_sffms_lib + +/* ========================================================================== + Assembly Syntax: Rd32=sfmake(#u10):neg + C Intrinsic Prototype: Float32 Q6_R_sfmake_I_neg(Word32 Iu10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmake_I_neg __builtin_HEXAGON_F2_sfimm_n + +/* ========================================================================== + Assembly Syntax: Rd32=sfmake(#u10):pos + C Intrinsic Prototype: Float32 Q6_R_sfmake_I_pos(Word32 Iu10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmake_I_pos __builtin_HEXAGON_F2_sfimm_p + +/* ========================================================================== + Assembly Syntax: Rd32=sfmax(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfmax_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmax_RR __builtin_HEXAGON_F2_sfmax + +/* ========================================================================== + Assembly Syntax: Rd32=sfmin(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfmin_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmin_RR __builtin_HEXAGON_F2_sfmin + +/* ========================================================================== + Assembly Syntax: Rd32=sfmpy(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfmpy_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfmpy_RR __builtin_HEXAGON_F2_sfmpy + +/* ========================================================================== + Assembly Syntax: Rd32=sfsub(Rs32,Rt32) + C Intrinsic Prototype: Float32 Q6_R_sfsub_RR(Float32 Rs, Float32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sfsub_RR __builtin_HEXAGON_F2_sfsub + +/* ========================================================================== + Assembly Syntax: Rd32=memb(Rx32++#s4:0:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memb_IM_circ(void** Rx, Word32 Is4_0, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memb_IM_circ __builtin_HEXAGON_L2_loadrb_pci + +/* ========================================================================== + Assembly Syntax: Rd32=memb(Rx32++I:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memb_M_circ(void** Rx, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memb_M_circ __builtin_HEXAGON_L2_loadrb_pcr + +/* ========================================================================== + Assembly Syntax: Rdd32=memd(Rx32++#s4:3:circ(Mu2)) + C Intrinsic Prototype: Word64 Q6_P_memd_IM_circ(void** Rx, Word32 Is4_3, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_P_memd_IM_circ __builtin_HEXAGON_L2_loadrd_pci + +/* ========================================================================== + Assembly Syntax: Rdd32=memd(Rx32++I:circ(Mu2)) + C Intrinsic Prototype: Word64 Q6_P_memd_M_circ(void** Rx, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_P_memd_M_circ __builtin_HEXAGON_L2_loadrd_pcr + +/* ========================================================================== + Assembly Syntax: Rd32=memh(Rx32++#s4:1:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memh_IM_circ(void** Rx, Word32 Is4_1, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memh_IM_circ __builtin_HEXAGON_L2_loadrh_pci + +/* ========================================================================== + Assembly Syntax: Rd32=memh(Rx32++I:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memh_M_circ(void** Rx, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memh_M_circ __builtin_HEXAGON_L2_loadrh_pcr + +/* ========================================================================== + Assembly Syntax: Rd32=memw(Rx32++#s4:2:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memw_IM_circ(void** Rx, Word32 Is4_2, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memw_IM_circ __builtin_HEXAGON_L2_loadri_pci + +/* ========================================================================== + Assembly Syntax: Rd32=memw(Rx32++I:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memw_M_circ(void** Rx, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memw_M_circ __builtin_HEXAGON_L2_loadri_pcr + +/* ========================================================================== + Assembly Syntax: Rd32=memub(Rx32++#s4:0:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memub_IM_circ(void** Rx, Word32 Is4_0, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memub_IM_circ __builtin_HEXAGON_L2_loadrub_pci + +/* ========================================================================== + Assembly Syntax: Rd32=memub(Rx32++I:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memub_M_circ(void** Rx, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memub_M_circ __builtin_HEXAGON_L2_loadrub_pcr + +/* ========================================================================== + Assembly Syntax: Rd32=memuh(Rx32++#s4:1:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memuh_IM_circ(void** Rx, Word32 Is4_1, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memuh_IM_circ __builtin_HEXAGON_L2_loadruh_pci + +/* ========================================================================== + Assembly Syntax: Rd32=memuh(Rx32++I:circ(Mu2)) + C Intrinsic Prototype: Word32 Q6_R_memuh_M_circ(void** Rx, Word32 Mu, void* BaseAddress) + Instruction Type: LD + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_R_memuh_M_circ __builtin_HEXAGON_L2_loadruh_pcr + +/* ========================================================================== + Assembly Syntax: Rx32+=add(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_addacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_addacc_RR __builtin_HEXAGON_M2_acci + +/* ========================================================================== + Assembly Syntax: Rx32+=add(Rs32,#s8) + C Intrinsic Prototype: Word32 Q6_R_addacc_RI(Word32 Rx, Word32 Rs, Word32 Is8) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_addacc_RI __builtin_HEXAGON_M2_accii + +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpyi(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyiacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyiacc_RR __builtin_HEXAGON_M2_cmaci_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpyr(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyracc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyracc_RR __builtin_HEXAGON_M2_cmacr_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpy(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_cmpyacc_RR_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyacc_RR_sat __builtin_HEXAGON_M2_cmacs_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpy(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_cmpyacc_RR_s1_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyacc_RR_s1_sat __builtin_HEXAGON_M2_cmacs_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpy(Rs32,Rt32*):sat + C Intrinsic Prototype: Word64 Q6_P_cmpyacc_RR_conj_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyacc_RR_conj_sat __builtin_HEXAGON_M2_cmacsc_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpy(Rs32,Rt32*):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_cmpyacc_RR_conj_s1_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyacc_RR_conj_s1_sat __builtin_HEXAGON_M2_cmacsc_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=cmpyi(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyi_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyi_RR __builtin_HEXAGON_M2_cmpyi_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=cmpyr(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyr_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpyr_RR __builtin_HEXAGON_M2_cmpyr_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=cmpy(Rs32,Rt32):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpy_RR_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpy_RR_rnd_sat __builtin_HEXAGON_M2_cmpyrs_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=cmpy(Rs32,Rt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpy_RR_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpy_RR_s1_rnd_sat __builtin_HEXAGON_M2_cmpyrs_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=cmpy(Rs32,Rt32*):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpy_RR_conj_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpy_RR_conj_rnd_sat __builtin_HEXAGON_M2_cmpyrsc_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=cmpy(Rs32,Rt32*):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpy_RR_conj_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpy_RR_conj_s1_rnd_sat __builtin_HEXAGON_M2_cmpyrsc_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=cmpy(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_cmpy_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpy_RR_sat __builtin_HEXAGON_M2_cmpys_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=cmpy(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_cmpy_RR_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpy_RR_s1_sat __builtin_HEXAGON_M2_cmpys_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=cmpy(Rs32,Rt32*):sat + C Intrinsic Prototype: Word64 Q6_P_cmpy_RR_conj_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpy_RR_conj_sat __builtin_HEXAGON_M2_cmpysc_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=cmpy(Rs32,Rt32*):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_cmpy_RR_conj_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpy_RR_conj_s1_sat __builtin_HEXAGON_M2_cmpysc_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=cmpy(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_cmpynac_RR_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpynac_RR_sat __builtin_HEXAGON_M2_cnacs_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=cmpy(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_cmpynac_RR_s1_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpynac_RR_s1_sat __builtin_HEXAGON_M2_cnacs_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=cmpy(Rs32,Rt32*):sat + C Intrinsic Prototype: Word64 Q6_P_cmpynac_RR_conj_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpynac_RR_conj_sat __builtin_HEXAGON_M2_cnacsc_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=cmpy(Rs32,Rt32*):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_cmpynac_RR_conj_s1_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cmpynac_RR_conj_s1_sat __builtin_HEXAGON_M2_cnacsc_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RR __builtin_HEXAGON_M2_dpmpyss_acc_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_mpynac_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RR __builtin_HEXAGON_M2_dpmpyss_nac_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32):rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RR_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RR_rnd __builtin_HEXAGON_M2_dpmpyss_rnd_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_mpy_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RR __builtin_HEXAGON_M2_dpmpyss_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RR __builtin_HEXAGON_M2_dpmpyuu_acc_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RR __builtin_HEXAGON_M2_dpmpyuu_nac_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32,Rt32) + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RR __builtin_HEXAGON_M2_dpmpyuu_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32.h):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RRh_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RRh_s1_rnd_sat __builtin_HEXAGON_M2_hmmpyh_rs1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RRh_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RRh_s1_sat __builtin_HEXAGON_M2_hmmpyh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32.l):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RRl_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RRl_s1_rnd_sat __builtin_HEXAGON_M2_hmmpyl_rs1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RRl_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RRl_s1_sat __builtin_HEXAGON_M2_hmmpyl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyi(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mpyiacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyiacc_RR __builtin_HEXAGON_M2_maci + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyi(Rs32,#u8) + C Intrinsic Prototype: Word32 Q6_R_mpyinac_RI(Word32 Rx, Word32 Rs, Word32 Iu8) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyinac_RI __builtin_HEXAGON_M2_macsin + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyi(Rs32,#u8) + C Intrinsic Prototype: Word32 Q6_R_mpyiacc_RI(Word32 Rx, Word32 Rs, Word32 Iu8) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyiacc_RI __builtin_HEXAGON_M2_macsip + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywoh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywohacc_PP_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywohacc_PP_rnd_sat __builtin_HEXAGON_M2_mmachs_rs0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywoh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywohacc_PP_s1_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywohacc_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmachs_rs1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywoh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpywohacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywohacc_PP_sat __builtin_HEXAGON_M2_mmachs_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywoh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywohacc_PP_s1_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywohacc_PP_s1_sat __builtin_HEXAGON_M2_mmachs_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywehacc_PP_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywehacc_PP_rnd_sat __builtin_HEXAGON_M2_mmacls_rs0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywehacc_PP_s1_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywehacc_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmacls_rs1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpywehacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywehacc_PP_sat __builtin_HEXAGON_M2_mmacls_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywehacc_PP_s1_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywehacc_PP_s1_sat __builtin_HEXAGON_M2_mmacls_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywouh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouhacc_PP_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouhacc_PP_rnd_sat __builtin_HEXAGON_M2_mmacuhs_rs0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywouh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouhacc_PP_s1_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouhacc_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmacuhs_rs1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywouh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouhacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouhacc_PP_sat __builtin_HEXAGON_M2_mmacuhs_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpywouh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouhacc_PP_s1_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouhacc_PP_s1_sat __builtin_HEXAGON_M2_mmacuhs_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweuh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuhacc_PP_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuhacc_PP_rnd_sat __builtin_HEXAGON_M2_mmaculs_rs0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweuh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuhacc_PP_s1_rnd_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuhacc_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmaculs_rs1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweuh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuhacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuhacc_PP_sat __builtin_HEXAGON_M2_mmaculs_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyweuh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuhacc_PP_s1_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuhacc_PP_s1_sat __builtin_HEXAGON_M2_mmaculs_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywoh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywoh_PP_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywoh_PP_rnd_sat __builtin_HEXAGON_M2_mmpyh_rs0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywoh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywoh_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywoh_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmpyh_rs1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywoh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpywoh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywoh_PP_sat __builtin_HEXAGON_M2_mmpyh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywoh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywoh_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywoh_PP_s1_sat __builtin_HEXAGON_M2_mmpyh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweh_PP_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweh_PP_rnd_sat __builtin_HEXAGON_M2_mmpyl_rs0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweh_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweh_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmpyl_rs1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweh_PP_sat __builtin_HEXAGON_M2_mmpyl_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweh_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweh_PP_s1_sat __builtin_HEXAGON_M2_mmpyl_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywouh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouh_PP_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouh_PP_rnd_sat __builtin_HEXAGON_M2_mmpyuh_rs0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywouh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouh_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouh_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmpyuh_rs1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywouh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouh_PP_sat __builtin_HEXAGON_M2_mmpyuh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpywouh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpywouh_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpywouh_PP_s1_sat __builtin_HEXAGON_M2_mmpyuh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweuh(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuh_PP_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuh_PP_rnd_sat __builtin_HEXAGON_M2_mmpyul_rs0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweuh(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuh_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuh_PP_s1_rnd_sat __builtin_HEXAGON_M2_mmpyul_rs1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweuh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuh_PP_sat __builtin_HEXAGON_M2_mmpyul_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyweuh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyweuh_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyweuh_PP_s1_sat __builtin_HEXAGON_M2_mmpyul_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRh __builtin_HEXAGON_M2_mpy_acc_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRh_s1 __builtin_HEXAGON_M2_mpy_acc_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRl __builtin_HEXAGON_M2_mpy_acc_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRl_s1 __builtin_HEXAGON_M2_mpy_acc_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRh __builtin_HEXAGON_M2_mpy_acc_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRh_s1 __builtin_HEXAGON_M2_mpy_acc_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRl __builtin_HEXAGON_M2_mpy_acc_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRl_s1 __builtin_HEXAGON_M2_mpy_acc_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.h):sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRh_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRh_sat __builtin_HEXAGON_M2_mpy_acc_sat_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRh_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRh_s1_sat __builtin_HEXAGON_M2_mpy_acc_sat_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.l):sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRl_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRl_sat __builtin_HEXAGON_M2_mpy_acc_sat_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.h,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RhRl_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RhRl_s1_sat __builtin_HEXAGON_M2_mpy_acc_sat_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.h):sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRh_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRh_sat __builtin_HEXAGON_M2_mpy_acc_sat_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRh_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRh_s1_sat __builtin_HEXAGON_M2_mpy_acc_sat_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.l):sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRl_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRl_sat __builtin_HEXAGON_M2_mpy_acc_sat_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32.l,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RlRl_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RlRl_s1_sat __builtin_HEXAGON_M2_mpy_acc_sat_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh __builtin_HEXAGON_M2_mpy_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_s1 __builtin_HEXAGON_M2_mpy_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl __builtin_HEXAGON_M2_mpy_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_s1 __builtin_HEXAGON_M2_mpy_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh __builtin_HEXAGON_M2_mpy_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_s1 __builtin_HEXAGON_M2_mpy_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl __builtin_HEXAGON_M2_mpy_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_s1 __builtin_HEXAGON_M2_mpy_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRh __builtin_HEXAGON_M2_mpy_nac_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRh_s1 __builtin_HEXAGON_M2_mpy_nac_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRl __builtin_HEXAGON_M2_mpy_nac_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRl_s1 __builtin_HEXAGON_M2_mpy_nac_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRh __builtin_HEXAGON_M2_mpy_nac_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRh_s1 __builtin_HEXAGON_M2_mpy_nac_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRl __builtin_HEXAGON_M2_mpy_nac_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRl_s1 __builtin_HEXAGON_M2_mpy_nac_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.h):sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRh_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRh_sat __builtin_HEXAGON_M2_mpy_nac_sat_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRh_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRh_s1_sat __builtin_HEXAGON_M2_mpy_nac_sat_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.l):sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRl_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRl_sat __builtin_HEXAGON_M2_mpy_nac_sat_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.h,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RhRl_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RhRl_s1_sat __builtin_HEXAGON_M2_mpy_nac_sat_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.h):sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRh_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRh_sat __builtin_HEXAGON_M2_mpy_nac_sat_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRh_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRh_s1_sat __builtin_HEXAGON_M2_mpy_nac_sat_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.l):sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRl_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRl_sat __builtin_HEXAGON_M2_mpy_nac_sat_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32.l,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RlRl_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RlRl_s1_sat __builtin_HEXAGON_M2_mpy_nac_sat_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_rnd __builtin_HEXAGON_M2_mpy_rnd_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):<<1:rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_s1_rnd __builtin_HEXAGON_M2_mpy_rnd_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_rnd __builtin_HEXAGON_M2_mpy_rnd_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):<<1:rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_s1_rnd __builtin_HEXAGON_M2_mpy_rnd_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_rnd __builtin_HEXAGON_M2_mpy_rnd_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):<<1:rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_s1_rnd __builtin_HEXAGON_M2_mpy_rnd_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_rnd __builtin_HEXAGON_M2_mpy_rnd_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):<<1:rnd + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_s1_rnd __builtin_HEXAGON_M2_mpy_rnd_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_sat __builtin_HEXAGON_M2_mpy_sat_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_s1_sat __builtin_HEXAGON_M2_mpy_sat_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_sat __builtin_HEXAGON_M2_mpy_sat_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_s1_sat __builtin_HEXAGON_M2_mpy_sat_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_sat __builtin_HEXAGON_M2_mpy_sat_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_s1_sat __builtin_HEXAGON_M2_mpy_sat_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_sat __builtin_HEXAGON_M2_mpy_sat_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_s1_sat __builtin_HEXAGON_M2_mpy_sat_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.h):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRh_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRh_s1_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.h,Rt32.l):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RhRl_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RhRl_s1_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.h):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRh_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRh_s1_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32.l,Rt32.l):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RlRl_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RlRl_s1_rnd_sat __builtin_HEXAGON_M2_mpy_sat_rnd_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mpy_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RR __builtin_HEXAGON_M2_mpy_up + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpy_RR_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RR_s1 __builtin_HEXAGON_M2_mpy_up_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpy(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpy_RR_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpy_RR_s1_sat __builtin_HEXAGON_M2_mpy_up_s1_sat + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RhRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RhRh __builtin_HEXAGON_M2_mpyd_acc_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RhRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RhRh_s1 __builtin_HEXAGON_M2_mpyd_acc_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RhRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RhRl __builtin_HEXAGON_M2_mpyd_acc_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RhRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RhRl_s1 __builtin_HEXAGON_M2_mpyd_acc_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RlRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RlRh __builtin_HEXAGON_M2_mpyd_acc_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RlRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RlRh_s1 __builtin_HEXAGON_M2_mpyd_acc_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RlRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RlRl __builtin_HEXAGON_M2_mpyd_acc_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpy(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyacc_RlRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyacc_RlRl_s1 __builtin_HEXAGON_M2_mpyd_acc_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRh __builtin_HEXAGON_M2_mpyd_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRh_s1 __builtin_HEXAGON_M2_mpyd_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRl __builtin_HEXAGON_M2_mpyd_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRl_s1 __builtin_HEXAGON_M2_mpyd_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRh __builtin_HEXAGON_M2_mpyd_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRh_s1 __builtin_HEXAGON_M2_mpyd_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRl __builtin_HEXAGON_M2_mpyd_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRl_s1 __builtin_HEXAGON_M2_mpyd_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpynac_RhRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RhRh __builtin_HEXAGON_M2_mpyd_nac_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpynac_RhRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RhRh_s1 __builtin_HEXAGON_M2_mpyd_nac_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpynac_RhRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RhRl __builtin_HEXAGON_M2_mpyd_nac_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpynac_RhRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RhRl_s1 __builtin_HEXAGON_M2_mpyd_nac_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpynac_RlRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RlRh __builtin_HEXAGON_M2_mpyd_nac_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpynac_RlRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RlRh_s1 __builtin_HEXAGON_M2_mpyd_nac_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpynac_RlRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RlRl __builtin_HEXAGON_M2_mpyd_nac_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpy(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpynac_RlRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpynac_RlRl_s1 __builtin_HEXAGON_M2_mpyd_nac_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.h):rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRh_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRh_rnd __builtin_HEXAGON_M2_mpyd_rnd_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.h):<<1:rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRh_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRh_s1_rnd __builtin_HEXAGON_M2_mpyd_rnd_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.l):rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRl_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRl_rnd __builtin_HEXAGON_M2_mpyd_rnd_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.h,Rt32.l):<<1:rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RhRl_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RhRl_s1_rnd __builtin_HEXAGON_M2_mpyd_rnd_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.h):rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRh_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRh_rnd __builtin_HEXAGON_M2_mpyd_rnd_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.h):<<1:rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRh_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRh_s1_rnd __builtin_HEXAGON_M2_mpyd_rnd_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.l):rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRl_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRl_rnd __builtin_HEXAGON_M2_mpyd_rnd_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpy(Rs32.l,Rt32.l):<<1:rnd + C Intrinsic Prototype: Word64 Q6_P_mpy_RlRl_s1_rnd(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpy_RlRl_s1_rnd __builtin_HEXAGON_M2_mpyd_rnd_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyi(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mpyi_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyi_RR __builtin_HEXAGON_M2_mpyi + +/* ========================================================================== + Assembly Syntax: Rd32=mpyi(Rs32,#m9) + C Intrinsic Prototype: Word32 Q6_R_mpyi_RI(Word32 Rs, Word32 Im9) + Instruction Type: M + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_mpyi_RI __builtin_HEXAGON_M2_mpysmi + +/* ========================================================================== + Assembly Syntax: Rd32=mpysu(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mpysu_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpysu_RR __builtin_HEXAGON_M2_mpysu_up + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RhRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RhRh __builtin_HEXAGON_M2_mpyu_acc_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RhRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RhRh_s1 __builtin_HEXAGON_M2_mpyu_acc_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RhRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RhRl __builtin_HEXAGON_M2_mpyu_acc_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RhRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RhRl_s1 __builtin_HEXAGON_M2_mpyu_acc_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RlRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RlRh __builtin_HEXAGON_M2_mpyu_acc_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RlRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RlRh_s1 __builtin_HEXAGON_M2_mpyu_acc_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RlRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RlRl __builtin_HEXAGON_M2_mpyu_acc_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rx32+=mpyu(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyuacc_RlRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyuacc_RlRl_s1 __builtin_HEXAGON_M2_mpyu_acc_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.h,Rt32.h) + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RhRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RhRh __builtin_HEXAGON_M2_mpyu_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RhRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RhRh_s1 __builtin_HEXAGON_M2_mpyu_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.h,Rt32.l) + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RhRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RhRl __builtin_HEXAGON_M2_mpyu_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RhRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RhRl_s1 __builtin_HEXAGON_M2_mpyu_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.l,Rt32.h) + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RlRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RlRh __builtin_HEXAGON_M2_mpyu_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RlRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RlRh_s1 __builtin_HEXAGON_M2_mpyu_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.l,Rt32.l) + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RlRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RlRl __builtin_HEXAGON_M2_mpyu_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RlRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RlRl_s1 __builtin_HEXAGON_M2_mpyu_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RhRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RhRh __builtin_HEXAGON_M2_mpyu_nac_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RhRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RhRh_s1 __builtin_HEXAGON_M2_mpyu_nac_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RhRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RhRl __builtin_HEXAGON_M2_mpyu_nac_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RhRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RhRl_s1 __builtin_HEXAGON_M2_mpyu_nac_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RlRh(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RlRh __builtin_HEXAGON_M2_mpyu_nac_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RlRh_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RlRh_s1 __builtin_HEXAGON_M2_mpyu_nac_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RlRl(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RlRl __builtin_HEXAGON_M2_mpyu_nac_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rx32-=mpyu(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word32 Q6_R_mpyunac_RlRl_s1(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyunac_RlRl_s1 __builtin_HEXAGON_M2_mpyu_nac_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyu(Rs32,Rt32) + C Intrinsic Prototype: UWord32 Q6_R_mpyu_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyu_RR __builtin_HEXAGON_M2_mpyu_up + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RhRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RhRh __builtin_HEXAGON_M2_mpyud_acc_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RhRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RhRh_s1 __builtin_HEXAGON_M2_mpyud_acc_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RhRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RhRl __builtin_HEXAGON_M2_mpyud_acc_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RhRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RhRl_s1 __builtin_HEXAGON_M2_mpyud_acc_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RlRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RlRh __builtin_HEXAGON_M2_mpyud_acc_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RlRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RlRh_s1 __builtin_HEXAGON_M2_mpyud_acc_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RlRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RlRl __builtin_HEXAGON_M2_mpyud_acc_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=mpyu(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyuacc_RlRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyuacc_RlRl_s1 __builtin_HEXAGON_M2_mpyud_acc_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.h,Rt32.h) + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RhRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RhRh __builtin_HEXAGON_M2_mpyud_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RhRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RhRh_s1 __builtin_HEXAGON_M2_mpyud_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.h,Rt32.l) + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RhRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RhRl __builtin_HEXAGON_M2_mpyud_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RhRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RhRl_s1 __builtin_HEXAGON_M2_mpyud_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.l,Rt32.h) + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RlRh(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RlRh __builtin_HEXAGON_M2_mpyud_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RlRh_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RlRh_s1 __builtin_HEXAGON_M2_mpyud_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.l,Rt32.l) + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RlRl(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RlRl __builtin_HEXAGON_M2_mpyud_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=mpyu(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: UWord64 Q6_P_mpyu_RlRl_s1(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyu_RlRl_s1 __builtin_HEXAGON_M2_mpyud_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.h,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RhRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RhRh __builtin_HEXAGON_M2_mpyud_nac_hh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.h,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RhRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RhRh_s1 __builtin_HEXAGON_M2_mpyud_nac_hh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.h,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RhRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RhRl __builtin_HEXAGON_M2_mpyud_nac_hl_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.h,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RhRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RhRl_s1 __builtin_HEXAGON_M2_mpyud_nac_hl_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.l,Rt32.h) + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RlRh(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RlRh __builtin_HEXAGON_M2_mpyud_nac_lh_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.l,Rt32.h):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RlRh_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RlRh_s1 __builtin_HEXAGON_M2_mpyud_nac_lh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.l,Rt32.l) + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RlRl(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RlRl __builtin_HEXAGON_M2_mpyud_nac_ll_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32-=mpyu(Rs32.l,Rt32.l):<<1 + C Intrinsic Prototype: Word64 Q6_P_mpyunac_RlRl_s1(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_mpyunac_RlRl_s1 __builtin_HEXAGON_M2_mpyud_nac_ll_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=mpyui(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mpyui_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_mpyui_RR __builtin_HEXAGON_M2_mpyui + +/* ========================================================================== + Assembly Syntax: Rx32-=add(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_addnac_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_addnac_RR __builtin_HEXAGON_M2_nacci + +/* ========================================================================== + Assembly Syntax: Rx32-=add(Rs32,#s8) + C Intrinsic Prototype: Word32 Q6_R_addnac_RI(Word32 Rx, Word32 Rs, Word32 Is8) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_addnac_RI __builtin_HEXAGON_M2_naccii + +/* ========================================================================== + Assembly Syntax: Rx32+=sub(Rt32,Rs32) + C Intrinsic Prototype: Word32 Q6_R_subacc_RR(Word32 Rx, Word32 Rt, Word32 Rs) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_subacc_RR __builtin_HEXAGON_M2_subacc + +/* ========================================================================== + Assembly Syntax: Rdd32=vabsdiffh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vabsdiffh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsdiffh_PP __builtin_HEXAGON_M2_vabsdiffh + +/* ========================================================================== + Assembly Syntax: Rdd32=vabsdiffw(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vabsdiffw_PP(Word64 Rtt, Word64 Rss) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsdiffw_PP __builtin_HEXAGON_M2_vabsdiffw + +/* ========================================================================== + Assembly Syntax: Rxx32+=vcmpyi(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vcmpyiacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcmpyiacc_PP_sat __builtin_HEXAGON_M2_vcmac_s0_sat_i + +/* ========================================================================== + Assembly Syntax: Rxx32+=vcmpyr(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vcmpyracc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcmpyracc_PP_sat __builtin_HEXAGON_M2_vcmac_s0_sat_r + +/* ========================================================================== + Assembly Syntax: Rdd32=vcmpyi(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vcmpyi_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcmpyi_PP_sat __builtin_HEXAGON_M2_vcmpy_s0_sat_i + +/* ========================================================================== + Assembly Syntax: Rdd32=vcmpyr(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vcmpyr_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcmpyr_PP_sat __builtin_HEXAGON_M2_vcmpy_s0_sat_r + +/* ========================================================================== + Assembly Syntax: Rdd32=vcmpyi(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vcmpyi_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcmpyi_PP_s1_sat __builtin_HEXAGON_M2_vcmpy_s1_sat_i + +/* ========================================================================== + Assembly Syntax: Rdd32=vcmpyr(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vcmpyr_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcmpyr_PP_s1_sat __builtin_HEXAGON_M2_vcmpy_s1_sat_r + +/* ========================================================================== + Assembly Syntax: Rxx32+=vdmpy(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vdmpyacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vdmpyacc_PP_sat __builtin_HEXAGON_M2_vdmacs_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vdmpy(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vdmpyacc_PP_s1_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vdmpyacc_PP_s1_sat __builtin_HEXAGON_M2_vdmacs_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=vdmpy(Rss32,Rtt32):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_vdmpy_PP_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vdmpy_PP_rnd_sat __builtin_HEXAGON_M2_vdmpyrs_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=vdmpy(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_vdmpy_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vdmpy_PP_s1_rnd_sat __builtin_HEXAGON_M2_vdmpyrs_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vdmpy(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vdmpy_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vdmpy_PP_sat __builtin_HEXAGON_M2_vdmpys_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vdmpy(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vdmpy_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vdmpy_PP_s1_sat __builtin_HEXAGON_M2_vdmpys_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyh(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vmpyhacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhacc_RR __builtin_HEXAGON_M2_vmac2 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyeh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vmpyehacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyehacc_PP __builtin_HEXAGON_M2_vmac2es + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyeh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyehacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyehacc_PP_sat __builtin_HEXAGON_M2_vmac2es_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyeh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyehacc_PP_s1_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyehacc_PP_s1_sat __builtin_HEXAGON_M2_vmac2es_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyh(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyhacc_RR_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhacc_RR_sat __builtin_HEXAGON_M2_vmac2s_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyh(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyhacc_RR_s1_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhacc_RR_s1_sat __builtin_HEXAGON_M2_vmac2s_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyhsu(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyhsuacc_RR_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhsuacc_RR_sat __builtin_HEXAGON_M2_vmac2su_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpyhsu(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyhsuacc_RR_s1_sat(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhsuacc_RR_s1_sat __builtin_HEXAGON_M2_vmac2su_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyeh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyeh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyeh_PP_sat __builtin_HEXAGON_M2_vmpy2es_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyeh(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyeh_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyeh_PP_s1_sat __builtin_HEXAGON_M2_vmpy2es_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyh(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyh_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyh_RR_sat __builtin_HEXAGON_M2_vmpy2s_s0 + +/* ========================================================================== + Assembly Syntax: Rd32=vmpyh(Rs32,Rt32):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_vmpyh_RR_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vmpyh_RR_rnd_sat __builtin_HEXAGON_M2_vmpy2s_s0pack + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyh(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyh_RR_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyh_RR_s1_sat __builtin_HEXAGON_M2_vmpy2s_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=vmpyh(Rs32,Rt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_vmpyh_RR_s1_rnd_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vmpyh_RR_s1_rnd_sat __builtin_HEXAGON_M2_vmpy2s_s1pack + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyhsu(Rs32,Rt32):sat + C Intrinsic Prototype: Word64 Q6_P_vmpyhsu_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhsu_RR_sat __builtin_HEXAGON_M2_vmpy2su_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpyhsu(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vmpyhsu_RR_s1_sat(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpyhsu_RR_s1_sat __builtin_HEXAGON_M2_vmpy2su_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=vraddh(Rss32,Rtt32) + C Intrinsic Prototype: Word32 Q6_R_vraddh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vraddh_PP __builtin_HEXAGON_M2_vraddh + +/* ========================================================================== + Assembly Syntax: Rd32=vradduh(Rss32,Rtt32) + C Intrinsic Prototype: Word32 Q6_R_vradduh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vradduh_PP __builtin_HEXAGON_M2_vradduh + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcmpyi(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyiacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyiacc_PP __builtin_HEXAGON_M2_vrcmaci_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcmpyi(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyiacc_PP_conj(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyiacc_PP_conj __builtin_HEXAGON_M2_vrcmaci_s0c + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcmpyr(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyracc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyracc_PP __builtin_HEXAGON_M2_vrcmacr_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcmpyr(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyracc_PP_conj(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyracc_PP_conj __builtin_HEXAGON_M2_vrcmacr_s0c + +/* ========================================================================== + Assembly Syntax: Rdd32=vrcmpyi(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyi_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyi_PP __builtin_HEXAGON_M2_vrcmpyi_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrcmpyi(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyi_PP_conj(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyi_PP_conj __builtin_HEXAGON_M2_vrcmpyi_s0c + +/* ========================================================================== + Assembly Syntax: Rdd32=vrcmpyr(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyr_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyr_PP __builtin_HEXAGON_M2_vrcmpyr_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrcmpyr(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_vrcmpyr_PP_conj(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcmpyr_PP_conj __builtin_HEXAGON_M2_vrcmpyr_s0c + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcmpys(Rss32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vrcmpysacc_PR_s1_sat(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_vrcmpysacc_PR_s1_sat __builtin_HEXAGON_M2_vrcmpys_acc_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrcmpys(Rss32,Rt32):<<1:sat + C Intrinsic Prototype: Word64 Q6_P_vrcmpys_PR_s1_sat(Word64 Rss, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_vrcmpys_PR_s1_sat __builtin_HEXAGON_M2_vrcmpys_s1 + +/* ========================================================================== + Assembly Syntax: Rd32=vrcmpys(Rss32,Rt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_vrcmpys_PR_s1_rnd_sat(Word64 Rss, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vrcmpys_PR_s1_rnd_sat __builtin_HEXAGON_M2_vrcmpys_s1rp + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpyh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpyhacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpyhacc_PP __builtin_HEXAGON_M2_vrmac_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpyh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpyh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpyh_PP __builtin_HEXAGON_M2_vrmpy_s0 + +/* ========================================================================== + Assembly Syntax: Rx32^=xor(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_xorxacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_xorxacc_RR __builtin_HEXAGON_M2_xor_xacc + +/* ========================================================================== + Assembly Syntax: Rx32&=and(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_andand_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andand_RR __builtin_HEXAGON_M4_and_and + +/* ========================================================================== + Assembly Syntax: Rx32&=and(Rs32,~Rt32) + C Intrinsic Prototype: Word32 Q6_R_andand_RnR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andand_RnR __builtin_HEXAGON_M4_and_andn + +/* ========================================================================== + Assembly Syntax: Rx32&=or(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_orand_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_orand_RR __builtin_HEXAGON_M4_and_or + +/* ========================================================================== + Assembly Syntax: Rx32&=xor(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_xorand_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_xorand_RR __builtin_HEXAGON_M4_and_xor + +/* ========================================================================== + Assembly Syntax: Rd32=cmpyiwh(Rss32,Rt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyiwh_PR_s1_rnd_sat(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpyiwh_PR_s1_rnd_sat __builtin_HEXAGON_M4_cmpyi_wh + +/* ========================================================================== + Assembly Syntax: Rd32=cmpyiwh(Rss32,Rt32*):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyiwh_PR_conj_s1_rnd_sat(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpyiwh_PR_conj_s1_rnd_sat __builtin_HEXAGON_M4_cmpyi_whc + +/* ========================================================================== + Assembly Syntax: Rd32=cmpyrwh(Rss32,Rt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyrwh_PR_s1_rnd_sat(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpyrwh_PR_s1_rnd_sat __builtin_HEXAGON_M4_cmpyr_wh + +/* ========================================================================== + Assembly Syntax: Rd32=cmpyrwh(Rss32,Rt32*):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyrwh_PR_conj_s1_rnd_sat(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cmpyrwh_PR_conj_s1_rnd_sat __builtin_HEXAGON_M4_cmpyr_whc + +/* ========================================================================== + Assembly Syntax: Rx32+=mpy(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpyacc_RR_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyacc_RR_s1_sat __builtin_HEXAGON_M4_mac_up_s1_sat + +/* ========================================================================== + Assembly Syntax: Rd32=add(#u6,mpyi(Rs32,#U6)) + C Intrinsic Prototype: Word32 Q6_R_add_mpyi_IRI(Word32 Iu6, Word32 Rs, Word32 IU6) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_mpyi_IRI __builtin_HEXAGON_M4_mpyri_addi + +/* ========================================================================== + Assembly Syntax: Rd32=add(Ru32,mpyi(Rs32,#u6)) + C Intrinsic Prototype: Word32 Q6_R_add_mpyi_RRI(Word32 Ru, Word32 Rs, Word32 Iu6) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_mpyi_RRI __builtin_HEXAGON_M4_mpyri_addr + +/* ========================================================================== + Assembly Syntax: Rd32=add(Ru32,mpyi(#u6:2,Rs32)) + C Intrinsic Prototype: Word32 Q6_R_add_mpyi_RIR(Word32 Ru, Word32 Iu6_2, Word32 Rs) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_mpyi_RIR __builtin_HEXAGON_M4_mpyri_addr_u2 + +/* ========================================================================== + Assembly Syntax: Rd32=add(#u6,mpyi(Rs32,Rt32)) + C Intrinsic Prototype: Word32 Q6_R_add_mpyi_IRR(Word32 Iu6, Word32 Rs, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_mpyi_IRR __builtin_HEXAGON_M4_mpyrr_addi + +/* ========================================================================== + Assembly Syntax: Ry32=add(Ru32,mpyi(Ry32,Rs32)) + C Intrinsic Prototype: Word32 Q6_R_add_mpyi_RRR(Word32 Ru, Word32 Ry, Word32 Rs) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_mpyi_RRR __builtin_HEXAGON_M4_mpyrr_addr + +/* ========================================================================== + Assembly Syntax: Rx32-=mpy(Rs32,Rt32):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_mpynac_RR_s1_sat(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpynac_RR_s1_sat __builtin_HEXAGON_M4_nac_up_s1_sat + +/* ========================================================================== + Assembly Syntax: Rx32|=and(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_andor_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andor_RR __builtin_HEXAGON_M4_or_and + +/* ========================================================================== + Assembly Syntax: Rx32|=and(Rs32,~Rt32) + C Intrinsic Prototype: Word32 Q6_R_andor_RnR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andor_RnR __builtin_HEXAGON_M4_or_andn + +/* ========================================================================== + Assembly Syntax: Rx32|=or(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_oror_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_oror_RR __builtin_HEXAGON_M4_or_or + +/* ========================================================================== + Assembly Syntax: Rx32|=xor(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_xoror_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_xoror_RR __builtin_HEXAGON_M4_or_xor + +/* ========================================================================== + Assembly Syntax: Rdd32=pmpyw(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_pmpyw_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_pmpyw_RR __builtin_HEXAGON_M4_pmpyw + +/* ========================================================================== + Assembly Syntax: Rxx32^=pmpyw(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_pmpywxacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_pmpywxacc_RR __builtin_HEXAGON_M4_pmpyw_acc + +/* ========================================================================== + Assembly Syntax: Rdd32=vpmpyh(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vpmpyh_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vpmpyh_RR __builtin_HEXAGON_M4_vpmpyh + +/* ========================================================================== + Assembly Syntax: Rxx32^=vpmpyh(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vpmpyhxacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vpmpyhxacc_RR __builtin_HEXAGON_M4_vpmpyh_acc + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpyweh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpywehacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpywehacc_PP __builtin_HEXAGON_M4_vrmpyeh_acc_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpyweh(Rss32,Rtt32):<<1 + C Intrinsic Prototype: Word64 Q6_P_vrmpywehacc_PP_s1(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpywehacc_PP_s1 __builtin_HEXAGON_M4_vrmpyeh_acc_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpyweh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpyweh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpyweh_PP __builtin_HEXAGON_M4_vrmpyeh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpyweh(Rss32,Rtt32):<<1 + C Intrinsic Prototype: Word64 Q6_P_vrmpyweh_PP_s1(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpyweh_PP_s1 __builtin_HEXAGON_M4_vrmpyeh_s1 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpywoh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpywohacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpywohacc_PP __builtin_HEXAGON_M4_vrmpyoh_acc_s0 + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpywoh(Rss32,Rtt32):<<1 + C Intrinsic Prototype: Word64 Q6_P_vrmpywohacc_PP_s1(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpywohacc_PP_s1 __builtin_HEXAGON_M4_vrmpyoh_acc_s1 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpywoh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpywoh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpywoh_PP __builtin_HEXAGON_M4_vrmpyoh_s0 + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpywoh(Rss32,Rtt32):<<1 + C Intrinsic Prototype: Word64 Q6_P_vrmpywoh_PP_s1(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpywoh_PP_s1 __builtin_HEXAGON_M4_vrmpyoh_s1 + +/* ========================================================================== + Assembly Syntax: Rx32^=and(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_andxacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andxacc_RR __builtin_HEXAGON_M4_xor_and + +/* ========================================================================== + Assembly Syntax: Rx32^=and(Rs32,~Rt32) + C Intrinsic Prototype: Word32 Q6_R_andxacc_RnR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andxacc_RnR __builtin_HEXAGON_M4_xor_andn + +/* ========================================================================== + Assembly Syntax: Rx32^=or(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_orxacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_orxacc_RR __builtin_HEXAGON_M4_xor_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=xor(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_xorxacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_xorxacc_PP __builtin_HEXAGON_M4_xor_xacc + +/* ========================================================================== + Assembly Syntax: Rxx32+=vdmpybsu(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vdmpybsuacc_PP_sat(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vdmpybsuacc_PP_sat __builtin_HEXAGON_M5_vdmacbsu + +/* ========================================================================== + Assembly Syntax: Rdd32=vdmpybsu(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vdmpybsu_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vdmpybsu_PP_sat __builtin_HEXAGON_M5_vdmpybsu + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpybsu(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vmpybsuacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpybsuacc_RR __builtin_HEXAGON_M5_vmacbsu + +/* ========================================================================== + Assembly Syntax: Rxx32+=vmpybu(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vmpybuacc_RR(Word64 Rxx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpybuacc_RR __builtin_HEXAGON_M5_vmacbuu + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpybsu(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vmpybsu_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpybsu_RR __builtin_HEXAGON_M5_vmpybsu + +/* ========================================================================== + Assembly Syntax: Rdd32=vmpybu(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vmpybu_RR(Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vmpybu_RR __builtin_HEXAGON_M5_vmpybuu + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpybsu(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpybsuacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpybsuacc_PP __builtin_HEXAGON_M5_vrmacbsu + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrmpybu(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpybuacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpybuacc_PP __builtin_HEXAGON_M5_vrmacbuu + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpybsu(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpybsu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpybsu_PP __builtin_HEXAGON_M5_vrmpybsu + +/* ========================================================================== + Assembly Syntax: Rdd32=vrmpybu(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vrmpybu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrmpybu_PP __builtin_HEXAGON_M5_vrmpybuu + +/* ========================================================================== + Assembly Syntax: Rd32=addasl(Rt32,Rs32,#u3) + C Intrinsic Prototype: Word32 Q6_R_addasl_RRI(Word32 Rt, Word32 Rs, Word32 Iu3) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_addasl_RRI __builtin_HEXAGON_S2_addasl_rrri + +/* ========================================================================== + Assembly Syntax: Rdd32=asl(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asl_PI(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asl_PI __builtin_HEXAGON_S2_asl_i_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=asl(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_aslacc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslacc_PI __builtin_HEXAGON_S2_asl_i_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=asl(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asland_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asland_PI __builtin_HEXAGON_S2_asl_i_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=asl(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_aslnac_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslnac_PI __builtin_HEXAGON_S2_asl_i_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=asl(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_aslor_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslor_PI __builtin_HEXAGON_S2_asl_i_p_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=asl(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_aslxacc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslxacc_PI __builtin_HEXAGON_S2_asl_i_p_xacc + +/* ========================================================================== + Assembly Syntax: Rd32=asl(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asl_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asl_RI __builtin_HEXAGON_S2_asl_i_r + +/* ========================================================================== + Assembly Syntax: Rx32+=asl(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_aslacc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslacc_RI __builtin_HEXAGON_S2_asl_i_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=asl(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asland_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asland_RI __builtin_HEXAGON_S2_asl_i_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=asl(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_aslnac_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslnac_RI __builtin_HEXAGON_S2_asl_i_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=asl(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_aslor_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslor_RI __builtin_HEXAGON_S2_asl_i_r_or + +/* ========================================================================== + Assembly Syntax: Rd32=asl(Rs32,#u5):sat + C Intrinsic Prototype: Word32 Q6_R_asl_RI_sat(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asl_RI_sat __builtin_HEXAGON_S2_asl_i_r_sat + +/* ========================================================================== + Assembly Syntax: Rx32^=asl(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_aslxacc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslxacc_RI __builtin_HEXAGON_S2_asl_i_r_xacc + +/* ========================================================================== + Assembly Syntax: Rdd32=vaslh(Rss32,#u4) + C Intrinsic Prototype: Word64 Q6_P_vaslh_PI(Word64 Rss, Word32 Iu4) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaslh_PI __builtin_HEXAGON_S2_asl_i_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vaslw(Rss32,#u5) + C Intrinsic Prototype: Word64 Q6_P_vaslw_PI(Word64 Rss, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaslw_PI __builtin_HEXAGON_S2_asl_i_vw + +/* ========================================================================== + Assembly Syntax: Rdd32=asl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asl_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asl_PR __builtin_HEXAGON_S2_asl_r_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=asl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_aslacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslacc_PR __builtin_HEXAGON_S2_asl_r_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=asl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asland_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asland_PR __builtin_HEXAGON_S2_asl_r_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=asl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_aslnac_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslnac_PR __builtin_HEXAGON_S2_asl_r_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=asl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_aslor_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslor_PR __builtin_HEXAGON_S2_asl_r_p_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=asl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_aslxacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_aslxacc_PR __builtin_HEXAGON_S2_asl_r_p_xor + +/* ========================================================================== + Assembly Syntax: Rd32=asl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asl_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asl_RR __builtin_HEXAGON_S2_asl_r_r + +/* ========================================================================== + Assembly Syntax: Rx32+=asl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_aslacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslacc_RR __builtin_HEXAGON_S2_asl_r_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=asl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asland_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asland_RR __builtin_HEXAGON_S2_asl_r_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=asl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_aslnac_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslnac_RR __builtin_HEXAGON_S2_asl_r_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=asl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_aslor_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_aslor_RR __builtin_HEXAGON_S2_asl_r_r_or + +/* ========================================================================== + Assembly Syntax: Rd32=asl(Rs32,Rt32):sat + C Intrinsic Prototype: Word32 Q6_R_asl_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asl_RR_sat __builtin_HEXAGON_S2_asl_r_r_sat + +/* ========================================================================== + Assembly Syntax: Rdd32=vaslh(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vaslh_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaslh_PR __builtin_HEXAGON_S2_asl_r_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vaslw(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vaslw_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vaslw_PR __builtin_HEXAGON_S2_asl_r_vw + +/* ========================================================================== + Assembly Syntax: Rdd32=asr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asr_PI(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asr_PI __builtin_HEXAGON_S2_asr_i_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=asr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asracc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asracc_PI __builtin_HEXAGON_S2_asr_i_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=asr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asrand_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asrand_PI __builtin_HEXAGON_S2_asr_i_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=asr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asrnac_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asrnac_PI __builtin_HEXAGON_S2_asr_i_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=asr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asror_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asror_PI __builtin_HEXAGON_S2_asr_i_p_or + +/* ========================================================================== + Assembly Syntax: Rdd32=asr(Rss32,#u6):rnd + C Intrinsic Prototype: Word64 Q6_P_asr_PI_rnd(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asr_PI_rnd __builtin_HEXAGON_S2_asr_i_p_rnd + +/* ========================================================================== + Assembly Syntax: Rdd32=asrrnd(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_asrrnd_PI(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_asrrnd_PI __builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rd32=asr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asr_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asr_RI __builtin_HEXAGON_S2_asr_i_r + +/* ========================================================================== + Assembly Syntax: Rx32+=asr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asracc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asracc_RI __builtin_HEXAGON_S2_asr_i_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=asr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asrand_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asrand_RI __builtin_HEXAGON_S2_asr_i_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=asr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asrnac_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asrnac_RI __builtin_HEXAGON_S2_asr_i_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=asr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asror_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asror_RI __builtin_HEXAGON_S2_asr_i_r_or + +/* ========================================================================== + Assembly Syntax: Rd32=asr(Rs32,#u5):rnd + C Intrinsic Prototype: Word32 Q6_R_asr_RI_rnd(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asr_RI_rnd __builtin_HEXAGON_S2_asr_i_r_rnd + +/* ========================================================================== + Assembly Syntax: Rd32=asrrnd(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_asrrnd_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_asrrnd_RI __builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rd32=vasrw(Rss32,#u5) + C Intrinsic Prototype: Word32 Q6_R_vasrw_PI(Word64 Rss, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vasrw_PI __builtin_HEXAGON_S2_asr_i_svw_trun + +/* ========================================================================== + Assembly Syntax: Rdd32=vasrh(Rss32,#u4) + C Intrinsic Prototype: Word64 Q6_P_vasrh_PI(Word64 Rss, Word32 Iu4) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vasrh_PI __builtin_HEXAGON_S2_asr_i_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vasrw(Rss32,#u5) + C Intrinsic Prototype: Word64 Q6_P_vasrw_PI(Word64 Rss, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vasrw_PI __builtin_HEXAGON_S2_asr_i_vw + +/* ========================================================================== + Assembly Syntax: Rdd32=asr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asr_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asr_PR __builtin_HEXAGON_S2_asr_r_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=asr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asracc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asracc_PR __builtin_HEXAGON_S2_asr_r_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=asr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asrand_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asrand_PR __builtin_HEXAGON_S2_asr_r_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=asr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asrnac_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asrnac_PR __builtin_HEXAGON_S2_asr_r_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=asr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asror_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asror_PR __builtin_HEXAGON_S2_asr_r_p_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=asr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_asrxacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_asrxacc_PR __builtin_HEXAGON_S2_asr_r_p_xor + +/* ========================================================================== + Assembly Syntax: Rd32=asr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asr_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asr_RR __builtin_HEXAGON_S2_asr_r_r + +/* ========================================================================== + Assembly Syntax: Rx32+=asr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asracc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asracc_RR __builtin_HEXAGON_S2_asr_r_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=asr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asrand_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asrand_RR __builtin_HEXAGON_S2_asr_r_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=asr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asrnac_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asrnac_RR __builtin_HEXAGON_S2_asr_r_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=asr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_asror_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asror_RR __builtin_HEXAGON_S2_asr_r_r_or + +/* ========================================================================== + Assembly Syntax: Rd32=asr(Rs32,Rt32):sat + C Intrinsic Prototype: Word32 Q6_R_asr_RR_sat(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_asr_RR_sat __builtin_HEXAGON_S2_asr_r_r_sat + +/* ========================================================================== + Assembly Syntax: Rd32=vasrw(Rss32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_vasrw_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vasrw_PR __builtin_HEXAGON_S2_asr_r_svw_trun + +/* ========================================================================== + Assembly Syntax: Rdd32=vasrh(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vasrh_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vasrh_PR __builtin_HEXAGON_S2_asr_r_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vasrw(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vasrw_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vasrw_PR __builtin_HEXAGON_S2_asr_r_vw + +/* ========================================================================== + Assembly Syntax: Rd32=brev(Rs32) + C Intrinsic Prototype: Word32 Q6_R_brev_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_brev_R __builtin_HEXAGON_S2_brev + +/* ========================================================================== + Assembly Syntax: Rdd32=brev(Rss32) + C Intrinsic Prototype: Word64 Q6_P_brev_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_brev_P __builtin_HEXAGON_S2_brevp + +/* ========================================================================== + Assembly Syntax: Rd32=cl0(Rs32) + C Intrinsic Prototype: Word32 Q6_R_cl0_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cl0_R __builtin_HEXAGON_S2_cl0 + +/* ========================================================================== + Assembly Syntax: Rd32=cl0(Rss32) + C Intrinsic Prototype: Word32 Q6_R_cl0_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cl0_P __builtin_HEXAGON_S2_cl0p + +/* ========================================================================== + Assembly Syntax: Rd32=cl1(Rs32) + C Intrinsic Prototype: Word32 Q6_R_cl1_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cl1_R __builtin_HEXAGON_S2_cl1 + +/* ========================================================================== + Assembly Syntax: Rd32=cl1(Rss32) + C Intrinsic Prototype: Word32 Q6_R_cl1_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_cl1_P __builtin_HEXAGON_S2_cl1p + +/* ========================================================================== + Assembly Syntax: Rd32=clb(Rs32) + C Intrinsic Prototype: Word32 Q6_R_clb_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_clb_R __builtin_HEXAGON_S2_clb + +/* ========================================================================== + Assembly Syntax: Rd32=normamt(Rs32) + C Intrinsic Prototype: Word32 Q6_R_normamt_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_normamt_R __builtin_HEXAGON_S2_clbnorm + +/* ========================================================================== + Assembly Syntax: Rd32=clb(Rss32) + C Intrinsic Prototype: Word32 Q6_R_clb_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_clb_P __builtin_HEXAGON_S2_clbp + +/* ========================================================================== + Assembly Syntax: Rd32=clrbit(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_clrbit_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_clrbit_RI __builtin_HEXAGON_S2_clrbit_i + +/* ========================================================================== + Assembly Syntax: Rd32=clrbit(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_clrbit_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_clrbit_RR __builtin_HEXAGON_S2_clrbit_r + +/* ========================================================================== + Assembly Syntax: Rd32=ct0(Rs32) + C Intrinsic Prototype: Word32 Q6_R_ct0_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_ct0_R __builtin_HEXAGON_S2_ct0 + +/* ========================================================================== + Assembly Syntax: Rd32=ct0(Rss32) + C Intrinsic Prototype: Word32 Q6_R_ct0_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_ct0_P __builtin_HEXAGON_S2_ct0p + +/* ========================================================================== + Assembly Syntax: Rd32=ct1(Rs32) + C Intrinsic Prototype: Word32 Q6_R_ct1_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_ct1_R __builtin_HEXAGON_S2_ct1 + +/* ========================================================================== + Assembly Syntax: Rd32=ct1(Rss32) + C Intrinsic Prototype: Word32 Q6_R_ct1_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_ct1_P __builtin_HEXAGON_S2_ct1p + +/* ========================================================================== + Assembly Syntax: Rdd32=deinterleave(Rss32) + C Intrinsic Prototype: Word64 Q6_P_deinterleave_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_deinterleave_P __builtin_HEXAGON_S2_deinterleave + +/* ========================================================================== + Assembly Syntax: Rd32=extractu(Rs32,#u5,#U5) + C Intrinsic Prototype: Word32 Q6_R_extractu_RII(Word32 Rs, Word32 Iu5, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_extractu_RII __builtin_HEXAGON_S2_extractu + +/* ========================================================================== + Assembly Syntax: Rd32=extractu(Rs32,Rtt32) + C Intrinsic Prototype: Word32 Q6_R_extractu_RP(Word32 Rs, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_extractu_RP __builtin_HEXAGON_S2_extractu_rp + +/* ========================================================================== + Assembly Syntax: Rdd32=extractu(Rss32,#u6,#U6) + C Intrinsic Prototype: Word64 Q6_P_extractu_PII(Word64 Rss, Word32 Iu6, Word32 IU6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_extractu_PII __builtin_HEXAGON_S2_extractup + +/* ========================================================================== + Assembly Syntax: Rdd32=extractu(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_extractu_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_extractu_PP __builtin_HEXAGON_S2_extractup_rp + +/* ========================================================================== + Assembly Syntax: Rx32=insert(Rs32,#u5,#U5) + C Intrinsic Prototype: Word32 Q6_R_insert_RII(Word32 Rx, Word32 Rs, Word32 Iu5, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_insert_RII __builtin_HEXAGON_S2_insert + +/* ========================================================================== + Assembly Syntax: Rx32=insert(Rs32,Rtt32) + C Intrinsic Prototype: Word32 Q6_R_insert_RP(Word32 Rx, Word32 Rs, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_insert_RP __builtin_HEXAGON_S2_insert_rp + +/* ========================================================================== + Assembly Syntax: Rxx32=insert(Rss32,#u6,#U6) + C Intrinsic Prototype: Word64 Q6_P_insert_PII(Word64 Rxx, Word64 Rss, Word32 Iu6, Word32 IU6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_insert_PII __builtin_HEXAGON_S2_insertp + +/* ========================================================================== + Assembly Syntax: Rxx32=insert(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_insert_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_insert_PP __builtin_HEXAGON_S2_insertp_rp + +/* ========================================================================== + Assembly Syntax: Rdd32=interleave(Rss32) + C Intrinsic Prototype: Word64 Q6_P_interleave_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_interleave_P __builtin_HEXAGON_S2_interleave + +/* ========================================================================== + Assembly Syntax: Rdd32=lfs(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_lfs_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lfs_PP __builtin_HEXAGON_S2_lfsp + +/* ========================================================================== + Assembly Syntax: Rdd32=lsl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsl_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsl_PR __builtin_HEXAGON_S2_lsl_r_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=lsl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lslacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lslacc_PR __builtin_HEXAGON_S2_lsl_r_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=lsl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsland_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsland_PR __builtin_HEXAGON_S2_lsl_r_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=lsl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lslnac_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lslnac_PR __builtin_HEXAGON_S2_lsl_r_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=lsl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lslor_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lslor_PR __builtin_HEXAGON_S2_lsl_r_p_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=lsl(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lslxacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lslxacc_PR __builtin_HEXAGON_S2_lsl_r_p_xor + +/* ========================================================================== + Assembly Syntax: Rd32=lsl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsl_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsl_RR __builtin_HEXAGON_S2_lsl_r_r + +/* ========================================================================== + Assembly Syntax: Rx32+=lsl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lslacc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lslacc_RR __builtin_HEXAGON_S2_lsl_r_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=lsl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsland_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsland_RR __builtin_HEXAGON_S2_lsl_r_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=lsl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lslnac_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lslnac_RR __builtin_HEXAGON_S2_lsl_r_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=lsl(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lslor_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lslor_RR __builtin_HEXAGON_S2_lsl_r_r_or + +/* ========================================================================== + Assembly Syntax: Rdd32=vlslh(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vlslh_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vlslh_PR __builtin_HEXAGON_S2_lsl_r_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vlslw(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vlslw_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vlslw_PR __builtin_HEXAGON_S2_lsl_r_vw + +/* ========================================================================== + Assembly Syntax: Rdd32=lsr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_lsr_PI(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsr_PI __builtin_HEXAGON_S2_lsr_i_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=lsr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_lsracc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsracc_PI __builtin_HEXAGON_S2_lsr_i_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=lsr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_lsrand_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsrand_PI __builtin_HEXAGON_S2_lsr_i_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=lsr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_lsrnac_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsrnac_PI __builtin_HEXAGON_S2_lsr_i_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=lsr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_lsror_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsror_PI __builtin_HEXAGON_S2_lsr_i_p_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=lsr(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_lsrxacc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsrxacc_PI __builtin_HEXAGON_S2_lsr_i_p_xacc + +/* ========================================================================== + Assembly Syntax: Rd32=lsr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_lsr_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsr_RI __builtin_HEXAGON_S2_lsr_i_r + +/* ========================================================================== + Assembly Syntax: Rx32+=lsr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_lsracc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsracc_RI __builtin_HEXAGON_S2_lsr_i_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=lsr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_lsrand_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsrand_RI __builtin_HEXAGON_S2_lsr_i_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=lsr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_lsrnac_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsrnac_RI __builtin_HEXAGON_S2_lsr_i_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=lsr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_lsror_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsror_RI __builtin_HEXAGON_S2_lsr_i_r_or + +/* ========================================================================== + Assembly Syntax: Rx32^=lsr(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_lsrxacc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsrxacc_RI __builtin_HEXAGON_S2_lsr_i_r_xacc + +/* ========================================================================== + Assembly Syntax: Rdd32=vlsrh(Rss32,#u4) + C Intrinsic Prototype: Word64 Q6_P_vlsrh_PI(Word64 Rss, Word32 Iu4) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vlsrh_PI __builtin_HEXAGON_S2_lsr_i_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vlsrw(Rss32,#u5) + C Intrinsic Prototype: Word64 Q6_P_vlsrw_PI(Word64 Rss, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vlsrw_PI __builtin_HEXAGON_S2_lsr_i_vw + +/* ========================================================================== + Assembly Syntax: Rdd32=lsr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsr_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsr_PR __builtin_HEXAGON_S2_lsr_r_p + +/* ========================================================================== + Assembly Syntax: Rxx32+=lsr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsracc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsracc_PR __builtin_HEXAGON_S2_lsr_r_p_acc + +/* ========================================================================== + Assembly Syntax: Rxx32&=lsr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsrand_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsrand_PR __builtin_HEXAGON_S2_lsr_r_p_and + +/* ========================================================================== + Assembly Syntax: Rxx32-=lsr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsrnac_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsrnac_PR __builtin_HEXAGON_S2_lsr_r_p_nac + +/* ========================================================================== + Assembly Syntax: Rxx32|=lsr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsror_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsror_PR __builtin_HEXAGON_S2_lsr_r_p_or + +/* ========================================================================== + Assembly Syntax: Rxx32^=lsr(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_lsrxacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_lsrxacc_PR __builtin_HEXAGON_S2_lsr_r_p_xor + +/* ========================================================================== + Assembly Syntax: Rd32=lsr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsr_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsr_RR __builtin_HEXAGON_S2_lsr_r_r + +/* ========================================================================== + Assembly Syntax: Rx32+=lsr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsracc_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsracc_RR __builtin_HEXAGON_S2_lsr_r_r_acc + +/* ========================================================================== + Assembly Syntax: Rx32&=lsr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsrand_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsrand_RR __builtin_HEXAGON_S2_lsr_r_r_and + +/* ========================================================================== + Assembly Syntax: Rx32-=lsr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsrnac_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsrnac_RR __builtin_HEXAGON_S2_lsr_r_r_nac + +/* ========================================================================== + Assembly Syntax: Rx32|=lsr(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsror_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsror_RR __builtin_HEXAGON_S2_lsr_r_r_or + +/* ========================================================================== + Assembly Syntax: Rdd32=vlsrh(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vlsrh_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vlsrh_PR __builtin_HEXAGON_S2_lsr_r_vh + +/* ========================================================================== + Assembly Syntax: Rdd32=vlsrw(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vlsrw_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vlsrw_PR __builtin_HEXAGON_S2_lsr_r_vw + +/* ========================================================================== + Assembly Syntax: Rdd32=packhl(Rs32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_packhl_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU32_3op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_packhl_RR __builtin_HEXAGON_S2_packhl + +/* ========================================================================== + Assembly Syntax: Rd32=parity(Rss32,Rtt32) + C Intrinsic Prototype: Word32 Q6_R_parity_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_parity_PP __builtin_HEXAGON_S2_parityp + +/* ========================================================================== + Assembly Syntax: Rd32=setbit(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_setbit_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_setbit_RI __builtin_HEXAGON_S2_setbit_i + +/* ========================================================================== + Assembly Syntax: Rd32=setbit(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_setbit_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_setbit_RR __builtin_HEXAGON_S2_setbit_r + +/* ========================================================================== + Assembly Syntax: Rdd32=shuffeb(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_shuffeb_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_shuffeb_PP __builtin_HEXAGON_S2_shuffeb + +/* ========================================================================== + Assembly Syntax: Rdd32=shuffeh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_shuffeh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_shuffeh_PP __builtin_HEXAGON_S2_shuffeh + +/* ========================================================================== + Assembly Syntax: Rdd32=shuffob(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_shuffob_PP(Word64 Rtt, Word64 Rss) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_shuffob_PP __builtin_HEXAGON_S2_shuffob + +/* ========================================================================== + Assembly Syntax: Rdd32=shuffoh(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_shuffoh_PP(Word64 Rtt, Word64 Rss) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_shuffoh_PP __builtin_HEXAGON_S2_shuffoh + +/* ========================================================================== + Assembly Syntax: memb(Rx32++#s4:0:circ(Mu2))=Rt32 + C Intrinsic Prototype: void Q6_memb_IMR_circ(void** Rx, Word32 Is4_0, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memb_IMR_circ __builtin_HEXAGON_S2_storerb_pci + +/* ========================================================================== + Assembly Syntax: memb(Rx32++I:circ(Mu2))=Rt32 + C Intrinsic Prototype: void Q6_memb_MR_circ(void** Rx, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memb_MR_circ __builtin_HEXAGON_S2_storerb_pcr + +/* ========================================================================== + Assembly Syntax: memd(Rx32++#s4:3:circ(Mu2))=Rtt32 + C Intrinsic Prototype: void Q6_memd_IMP_circ(void** Rx, Word32 Is4_3, Word32 Mu, Word64 Rtt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memd_IMP_circ __builtin_HEXAGON_S2_storerd_pci + +/* ========================================================================== + Assembly Syntax: memd(Rx32++I:circ(Mu2))=Rtt32 + C Intrinsic Prototype: void Q6_memd_MP_circ(void** Rx, Word32 Mu, Word64 Rtt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memd_MP_circ __builtin_HEXAGON_S2_storerd_pcr + +/* ========================================================================== + Assembly Syntax: memh(Rx32++#s4:1:circ(Mu2))=Rt32.h + C Intrinsic Prototype: void Q6_memh_IMRh_circ(void** Rx, Word32 Is4_1, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memh_IMRh_circ __builtin_HEXAGON_S2_storerf_pci + +/* ========================================================================== + Assembly Syntax: memh(Rx32++I:circ(Mu2))=Rt32.h + C Intrinsic Prototype: void Q6_memh_MRh_circ(void** Rx, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memh_MRh_circ __builtin_HEXAGON_S2_storerf_pcr + +/* ========================================================================== + Assembly Syntax: memh(Rx32++#s4:1:circ(Mu2))=Rt32 + C Intrinsic Prototype: void Q6_memh_IMR_circ(void** Rx, Word32 Is4_1, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memh_IMR_circ __builtin_HEXAGON_S2_storerh_pci + +/* ========================================================================== + Assembly Syntax: memh(Rx32++I:circ(Mu2))=Rt32 + C Intrinsic Prototype: void Q6_memh_MR_circ(void** Rx, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memh_MR_circ __builtin_HEXAGON_S2_storerh_pcr + +/* ========================================================================== + Assembly Syntax: memw(Rx32++#s4:2:circ(Mu2))=Rt32 + C Intrinsic Prototype: void Q6_memw_IMR_circ(void** Rx, Word32 Is4_2, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memw_IMR_circ __builtin_HEXAGON_S2_storeri_pci + +/* ========================================================================== + Assembly Syntax: memw(Rx32++I:circ(Mu2))=Rt32 + C Intrinsic Prototype: void Q6_memw_MR_circ(void** Rx, Word32 Mu, Word32 Rt, void* BaseAddress) + Instruction Type: ST + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_memw_MR_circ __builtin_HEXAGON_S2_storeri_pcr + +/* ========================================================================== + Assembly Syntax: Rd32=vsathb(Rs32) + C Intrinsic Prototype: Word32 Q6_R_vsathb_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsathb_R __builtin_HEXAGON_S2_svsathb + +/* ========================================================================== + Assembly Syntax: Rd32=vsathub(Rs32) + C Intrinsic Prototype: Word32 Q6_R_vsathub_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsathub_R __builtin_HEXAGON_S2_svsathub + +/* ========================================================================== + Assembly Syntax: Rx32=tableidxb(Rs32,#u4,#U5) + C Intrinsic Prototype: Word32 Q6_R_tableidxb_RII(Word32 Rx, Word32 Rs, Word32 Iu4, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_tableidxb_RII __builtin_HEXAGON_S2_tableidxb_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rx32=tableidxd(Rs32,#u4,#U5) + C Intrinsic Prototype: Word32 Q6_R_tableidxd_RII(Word32 Rx, Word32 Rs, Word32 Iu4, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_tableidxd_RII __builtin_HEXAGON_S2_tableidxd_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rx32=tableidxh(Rs32,#u4,#U5) + C Intrinsic Prototype: Word32 Q6_R_tableidxh_RII(Word32 Rx, Word32 Rs, Word32 Iu4, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_tableidxh_RII __builtin_HEXAGON_S2_tableidxh_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rx32=tableidxw(Rs32,#u4,#U5) + C Intrinsic Prototype: Word32 Q6_R_tableidxw_RII(Word32 Rx, Word32 Rs, Word32 Iu4, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_tableidxw_RII __builtin_HEXAGON_S2_tableidxw_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rd32=togglebit(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_togglebit_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_togglebit_RI __builtin_HEXAGON_S2_togglebit_i + +/* ========================================================================== + Assembly Syntax: Rd32=togglebit(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_togglebit_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_togglebit_RR __builtin_HEXAGON_S2_togglebit_r + +/* ========================================================================== + Assembly Syntax: Pd4=tstbit(Rs32,#u5) + C Intrinsic Prototype: Byte Q6_p_tstbit_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_tstbit_RI __builtin_HEXAGON_S2_tstbit_i + +/* ========================================================================== + Assembly Syntax: Pd4=tstbit(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_tstbit_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_tstbit_RR __builtin_HEXAGON_S2_tstbit_r + +/* ========================================================================== + Assembly Syntax: Rdd32=valignb(Rtt32,Rss32,#u3) + C Intrinsic Prototype: Word64 Q6_P_valignb_PPI(Word64 Rtt, Word64 Rss, Word32 Iu3) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_valignb_PPI __builtin_HEXAGON_S2_valignib + +/* ========================================================================== + Assembly Syntax: Rdd32=valignb(Rtt32,Rss32,Pu4) + C Intrinsic Prototype: Word64 Q6_P_valignb_PPp(Word64 Rtt, Word64 Rss, Byte Pu) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_valignb_PPp __builtin_HEXAGON_S2_valignrb + +/* ========================================================================== + Assembly Syntax: Rdd32=vcnegh(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vcnegh_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcnegh_PR __builtin_HEXAGON_S2_vcnegh + +/* ========================================================================== + Assembly Syntax: Rdd32=vcrotate(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vcrotate_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vcrotate_PR __builtin_HEXAGON_S2_vcrotate + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcnegh(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_vrcneghacc_PR(Word64 Rxx, Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcneghacc_PR __builtin_HEXAGON_S2_vrcnegh + +/* ========================================================================== + Assembly Syntax: Rd32=vrndwh(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vrndwh_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vrndwh_P __builtin_HEXAGON_S2_vrndpackwh + +/* ========================================================================== + Assembly Syntax: Rd32=vrndwh(Rss32):sat + C Intrinsic Prototype: Word32 Q6_R_vrndwh_P_sat(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vrndwh_P_sat __builtin_HEXAGON_S2_vrndpackwhs + +/* ========================================================================== + Assembly Syntax: Rd32=vsathb(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vsathb_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsathb_P __builtin_HEXAGON_S2_vsathb + +/* ========================================================================== + Assembly Syntax: Rdd32=vsathb(Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsathb_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsathb_P __builtin_HEXAGON_S2_vsathb_nopack + +/* ========================================================================== + Assembly Syntax: Rd32=vsathub(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vsathub_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsathub_P __builtin_HEXAGON_S2_vsathub + +/* ========================================================================== + Assembly Syntax: Rdd32=vsathub(Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsathub_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsathub_P __builtin_HEXAGON_S2_vsathub_nopack + +/* ========================================================================== + Assembly Syntax: Rd32=vsatwh(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vsatwh_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsatwh_P __builtin_HEXAGON_S2_vsatwh + +/* ========================================================================== + Assembly Syntax: Rdd32=vsatwh(Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsatwh_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsatwh_P __builtin_HEXAGON_S2_vsatwh_nopack + +/* ========================================================================== + Assembly Syntax: Rd32=vsatwuh(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vsatwuh_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsatwuh_P __builtin_HEXAGON_S2_vsatwuh + +/* ========================================================================== + Assembly Syntax: Rdd32=vsatwuh(Rss32) + C Intrinsic Prototype: Word64 Q6_P_vsatwuh_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsatwuh_P __builtin_HEXAGON_S2_vsatwuh_nopack + +/* ========================================================================== + Assembly Syntax: Rd32=vsplatb(Rs32) + C Intrinsic Prototype: Word32 Q6_R_vsplatb_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vsplatb_R __builtin_HEXAGON_S2_vsplatrb + +/* ========================================================================== + Assembly Syntax: Rdd32=vsplath(Rs32) + C Intrinsic Prototype: Word64 Q6_P_vsplath_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsplath_R __builtin_HEXAGON_S2_vsplatrh + +/* ========================================================================== + Assembly Syntax: Rdd32=vspliceb(Rss32,Rtt32,#u3) + C Intrinsic Prototype: Word64 Q6_P_vspliceb_PPI(Word64 Rss, Word64 Rtt, Word32 Iu3) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vspliceb_PPI __builtin_HEXAGON_S2_vspliceib + +/* ========================================================================== + Assembly Syntax: Rdd32=vspliceb(Rss32,Rtt32,Pu4) + C Intrinsic Prototype: Word64 Q6_P_vspliceb_PPp(Word64 Rss, Word64 Rtt, Byte Pu) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vspliceb_PPp __builtin_HEXAGON_S2_vsplicerb + +/* ========================================================================== + Assembly Syntax: Rdd32=vsxtbh(Rs32) + C Intrinsic Prototype: Word64 Q6_P_vsxtbh_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsxtbh_R __builtin_HEXAGON_S2_vsxtbh + +/* ========================================================================== + Assembly Syntax: Rdd32=vsxthw(Rs32) + C Intrinsic Prototype: Word64 Q6_P_vsxthw_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsxthw_R __builtin_HEXAGON_S2_vsxthw + +/* ========================================================================== + Assembly Syntax: Rd32=vtrunehb(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vtrunehb_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vtrunehb_P __builtin_HEXAGON_S2_vtrunehb + +/* ========================================================================== + Assembly Syntax: Rdd32=vtrunewh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vtrunewh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vtrunewh_PP __builtin_HEXAGON_S2_vtrunewh + +/* ========================================================================== + Assembly Syntax: Rd32=vtrunohb(Rss32) + C Intrinsic Prototype: Word32 Q6_R_vtrunohb_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vtrunohb_P __builtin_HEXAGON_S2_vtrunohb + +/* ========================================================================== + Assembly Syntax: Rdd32=vtrunowh(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vtrunowh_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vtrunowh_PP __builtin_HEXAGON_S2_vtrunowh + +/* ========================================================================== + Assembly Syntax: Rdd32=vzxtbh(Rs32) + C Intrinsic Prototype: Word64 Q6_P_vzxtbh_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vzxtbh_R __builtin_HEXAGON_S2_vzxtbh + +/* ========================================================================== + Assembly Syntax: Rdd32=vzxthw(Rs32) + C Intrinsic Prototype: Word64 Q6_P_vzxthw_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vzxthw_R __builtin_HEXAGON_S2_vzxthw + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rs32,add(Ru32,#s6)) + C Intrinsic Prototype: Word32 Q6_R_add_add_RRI(Word32 Rs, Word32 Ru, Word32 Is6) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_add_RRI __builtin_HEXAGON_S4_addaddi + +/* ========================================================================== + Assembly Syntax: Rx32=add(#u8,asl(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_add_asl_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_asl_IRI __builtin_HEXAGON_S4_addi_asl_ri + +/* ========================================================================== + Assembly Syntax: Rx32=add(#u8,lsr(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_add_lsr_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_lsr_IRI __builtin_HEXAGON_S4_addi_lsr_ri + +/* ========================================================================== + Assembly Syntax: Rx32=and(#u8,asl(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_and_asl_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_and_asl_IRI __builtin_HEXAGON_S4_andi_asl_ri + +/* ========================================================================== + Assembly Syntax: Rx32=and(#u8,lsr(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_and_lsr_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_and_lsr_IRI __builtin_HEXAGON_S4_andi_lsr_ri + +/* ========================================================================== + Assembly Syntax: Rd32=add(clb(Rs32),#s6) + C Intrinsic Prototype: Word32 Q6_R_add_clb_RI(Word32 Rs, Word32 Is6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_clb_RI __builtin_HEXAGON_S4_clbaddi + +/* ========================================================================== + Assembly Syntax: Rd32=add(clb(Rss32),#s6) + C Intrinsic Prototype: Word32 Q6_R_add_clb_PI(Word64 Rss, Word32 Is6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_clb_PI __builtin_HEXAGON_S4_clbpaddi + +/* ========================================================================== + Assembly Syntax: Rd32=normamt(Rss32) + C Intrinsic Prototype: Word32 Q6_R_normamt_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_normamt_P __builtin_HEXAGON_S4_clbpnorm + +/* ========================================================================== + Assembly Syntax: Rd32=extract(Rs32,#u5,#U5) + C Intrinsic Prototype: Word32 Q6_R_extract_RII(Word32 Rs, Word32 Iu5, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_extract_RII __builtin_HEXAGON_S4_extract + +/* ========================================================================== + Assembly Syntax: Rd32=extract(Rs32,Rtt32) + C Intrinsic Prototype: Word32 Q6_R_extract_RP(Word32 Rs, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_extract_RP __builtin_HEXAGON_S4_extract_rp + +/* ========================================================================== + Assembly Syntax: Rdd32=extract(Rss32,#u6,#U6) + C Intrinsic Prototype: Word64 Q6_P_extract_PII(Word64 Rss, Word32 Iu6, Word32 IU6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_extract_PII __builtin_HEXAGON_S4_extractp + +/* ========================================================================== + Assembly Syntax: Rdd32=extract(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_extract_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_extract_PP __builtin_HEXAGON_S4_extractp_rp + +/* ========================================================================== + Assembly Syntax: Rd32=lsl(#s6,Rt32) + C Intrinsic Prototype: Word32 Q6_R_lsl_IR(Word32 Is6, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_lsl_IR __builtin_HEXAGON_S4_lsli + +/* ========================================================================== + Assembly Syntax: Pd4=!tstbit(Rs32,#u5) + C Intrinsic Prototype: Byte Q6_p_not_tstbit_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_tstbit_RI __builtin_HEXAGON_S4_ntstbit_i + +/* ========================================================================== + Assembly Syntax: Pd4=!tstbit(Rs32,Rt32) + C Intrinsic Prototype: Byte Q6_p_not_tstbit_RR(Word32 Rs, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_tstbit_RR __builtin_HEXAGON_S4_ntstbit_r + +/* ========================================================================== + Assembly Syntax: Rx32|=and(Rs32,#s10) + C Intrinsic Prototype: Word32 Q6_R_andor_RI(Word32 Rx, Word32 Rs, Word32 Is10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_andor_RI __builtin_HEXAGON_S4_or_andi + +/* ========================================================================== + Assembly Syntax: Rx32=or(Ru32,and(Rx32,#s10)) + C Intrinsic Prototype: Word32 Q6_R_or_and_RRI(Word32 Ru, Word32 Rx, Word32 Is10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_or_and_RRI __builtin_HEXAGON_S4_or_andix + +/* ========================================================================== + Assembly Syntax: Rx32|=or(Rs32,#s10) + C Intrinsic Prototype: Word32 Q6_R_oror_RI(Word32 Rx, Word32 Rs, Word32 Is10) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_oror_RI __builtin_HEXAGON_S4_or_ori + +/* ========================================================================== + Assembly Syntax: Rx32=or(#u8,asl(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_or_asl_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_or_asl_IRI __builtin_HEXAGON_S4_ori_asl_ri + +/* ========================================================================== + Assembly Syntax: Rx32=or(#u8,lsr(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_or_lsr_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_or_lsr_IRI __builtin_HEXAGON_S4_ori_lsr_ri + +/* ========================================================================== + Assembly Syntax: Rd32=parity(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_parity_RR(Word32 Rs, Word32 Rt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_parity_RR __builtin_HEXAGON_S4_parity + +/* ========================================================================== + Assembly Syntax: Rd32=add(Rs32,sub(#s6,Ru32)) + C Intrinsic Prototype: Word32 Q6_R_add_sub_RIR(Word32 Rs, Word32 Is6, Word32 Ru) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_add_sub_RIR __builtin_HEXAGON_S4_subaddi + +/* ========================================================================== + Assembly Syntax: Rx32=sub(#u8,asl(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_sub_asl_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_asl_IRI __builtin_HEXAGON_S4_subi_asl_ri + +/* ========================================================================== + Assembly Syntax: Rx32=sub(#u8,lsr(Rx32,#U5)) + C Intrinsic Prototype: Word32 Q6_R_sub_lsr_IRI(Word32 Iu8, Word32 Rx, Word32 IU5) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_sub_lsr_IRI __builtin_HEXAGON_S4_subi_lsr_ri + +/* ========================================================================== + Assembly Syntax: Rdd32=vrcrotate(Rss32,Rt32,#u2) + C Intrinsic Prototype: Word64 Q6_P_vrcrotate_PRI(Word64 Rss, Word32 Rt, Word32 Iu2) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcrotate_PRI __builtin_HEXAGON_S4_vrcrotate + +/* ========================================================================== + Assembly Syntax: Rxx32+=vrcrotate(Rss32,Rt32,#u2) + C Intrinsic Prototype: Word64 Q6_P_vrcrotateacc_PRI(Word64 Rxx, Word64 Rss, Word32 Rt, Word32 Iu2) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vrcrotateacc_PRI __builtin_HEXAGON_S4_vrcrotate_acc + +/* ========================================================================== + Assembly Syntax: Rdd32=vxaddsubh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vxaddsubh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vxaddsubh_PP_sat __builtin_HEXAGON_S4_vxaddsubh + +/* ========================================================================== + Assembly Syntax: Rdd32=vxaddsubh(Rss32,Rtt32):rnd:>>1:sat + C Intrinsic Prototype: Word64 Q6_P_vxaddsubh_PP_rnd_rs1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vxaddsubh_PP_rnd_rs1_sat __builtin_HEXAGON_S4_vxaddsubhr + +/* ========================================================================== + Assembly Syntax: Rdd32=vxaddsubw(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vxaddsubw_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vxaddsubw_PP_sat __builtin_HEXAGON_S4_vxaddsubw + +/* ========================================================================== + Assembly Syntax: Rdd32=vxsubaddh(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vxsubaddh_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vxsubaddh_PP_sat __builtin_HEXAGON_S4_vxsubaddh + +/* ========================================================================== + Assembly Syntax: Rdd32=vxsubaddh(Rss32,Rtt32):rnd:>>1:sat + C Intrinsic Prototype: Word64 Q6_P_vxsubaddh_PP_rnd_rs1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vxsubaddh_PP_rnd_rs1_sat __builtin_HEXAGON_S4_vxsubaddhr + +/* ========================================================================== + Assembly Syntax: Rdd32=vxsubaddw(Rss32,Rtt32):sat + C Intrinsic Prototype: Word64 Q6_P_vxsubaddw_PP_sat(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vxsubaddw_PP_sat __builtin_HEXAGON_S4_vxsubaddw + +/* ========================================================================== + Assembly Syntax: Rd32=vasrhub(Rss32,#u4):rnd:sat + C Intrinsic Prototype: Word32 Q6_R_vasrhub_PI_rnd_sat(Word64 Rss, Word32 Iu4) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_R_vasrhub_PI_rnd_sat __builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax + +/* ========================================================================== + Assembly Syntax: Rd32=vasrhub(Rss32,#u4):sat + C Intrinsic Prototype: Word32 Q6_R_vasrhub_PI_sat(Word64 Rss, Word32 Iu4) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_vasrhub_PI_sat __builtin_HEXAGON_S5_asrhub_sat + +/* ========================================================================== + Assembly Syntax: Rd32=popcount(Rss32) + C Intrinsic Prototype: Word32 Q6_R_popcount_P(Word64 Rss) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_popcount_P __builtin_HEXAGON_S5_popcountp + +/* ========================================================================== + Assembly Syntax: Rdd32=vasrh(Rss32,#u4):rnd + C Intrinsic Prototype: Word64 Q6_P_vasrh_PI_rnd(Word64 Rss, Word32 Iu4) + Instruction Type: S_2op + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_P_vasrh_PI_rnd __builtin_HEXAGON_S5_vasrhrnd_goodsyntax + +/* ========================================================================== + Assembly Syntax: dccleana(Rs32) + C Intrinsic Prototype: void Q6_dccleana_A(Address Rs) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dccleana_A __builtin_HEXAGON_Y2_dccleana + +/* ========================================================================== + Assembly Syntax: dccleaninva(Rs32) + C Intrinsic Prototype: void Q6_dccleaninva_A(Address Rs) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dccleaninva_A __builtin_HEXAGON_Y2_dccleaninva + +/* ========================================================================== + Assembly Syntax: dcfetch(Rs32) + C Intrinsic Prototype: void Q6_dcfetch_A(Address Rs) + Instruction Type: MAPPING + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_dcfetch_A __builtin_HEXAGON_Y2_dcfetch + +/* ========================================================================== + Assembly Syntax: dcinva(Rs32) + C Intrinsic Prototype: void Q6_dcinva_A(Address Rs) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dcinva_A __builtin_HEXAGON_Y2_dcinva + +/* ========================================================================== + Assembly Syntax: dczeroa(Rs32) + C Intrinsic Prototype: void Q6_dczeroa_A(Address Rs) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dczeroa_A __builtin_HEXAGON_Y2_dczeroa + +/* ========================================================================== + Assembly Syntax: l2fetch(Rs32,Rt32) + C Intrinsic Prototype: void Q6_l2fetch_AR(Address Rs, Word32 Rt) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_l2fetch_AR __builtin_HEXAGON_Y4_l2fetch + +/* ========================================================================== + Assembly Syntax: l2fetch(Rs32,Rtt32) + C Intrinsic Prototype: void Q6_l2fetch_AP(Address Rs, Word64 Rtt) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_l2fetch_AP __builtin_HEXAGON_Y5_l2fetch + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rdd32=rol(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_rol_PI(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_rol_PI __builtin_HEXAGON_S6_rol_i_p +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rxx32+=rol(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_rolacc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_rolacc_PI __builtin_HEXAGON_S6_rol_i_p_acc +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rxx32&=rol(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_roland_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_roland_PI __builtin_HEXAGON_S6_rol_i_p_and +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rxx32-=rol(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_rolnac_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_rolnac_PI __builtin_HEXAGON_S6_rol_i_p_nac +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rxx32|=rol(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_rolor_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_rolor_PI __builtin_HEXAGON_S6_rol_i_p_or +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rxx32^=rol(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_rolxacc_PI(Word64 Rxx, Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_rolxacc_PI __builtin_HEXAGON_S6_rol_i_p_xacc +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rd32=rol(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_rol_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_rol_RI __builtin_HEXAGON_S6_rol_i_r +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rx32+=rol(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_rolacc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_rolacc_RI __builtin_HEXAGON_S6_rol_i_r_acc +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rx32&=rol(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_roland_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_roland_RI __builtin_HEXAGON_S6_rol_i_r_and +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rx32-=rol(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_rolnac_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_rolnac_RI __builtin_HEXAGON_S6_rol_i_r_nac +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rx32|=rol(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_rolor_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_rolor_RI __builtin_HEXAGON_S6_rol_i_r_or +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rx32^=rol(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_rolxacc_RI(Word32 Rx, Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_rolxacc_RI __builtin_HEXAGON_S6_rol_i_r_xacc +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HEXAGON_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Rdd32=vabsdiffb(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vabsdiffb_PP(Word64 Rtt, Word64 Rss) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsdiffb_PP __builtin_HEXAGON_M6_vabsdiffb +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HEXAGON_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Rdd32=vabsdiffub(Rtt32,Rss32) + C Intrinsic Prototype: Word64 Q6_P_vabsdiffub_PP(Word64 Rtt, Word64 Rss) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vabsdiffub_PP __builtin_HEXAGON_M6_vabsdiffub +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HEXAGON_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Rdd32=vsplatb(Rs32) + C Intrinsic Prototype: Word64 Q6_P_vsplatb_R(Word32 Rs) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vsplatb_R __builtin_HEXAGON_S6_vsplatrbp +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HEXAGON_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Rdd32=vtrunehb(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vtrunehb_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vtrunehb_PP __builtin_HEXAGON_S6_vtrunehb_ppp +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HEXAGON_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Rdd32=vtrunohb(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vtrunohb_PP(Word64 Rss, Word64 Rtt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vtrunohb_PP __builtin_HEXAGON_S6_vtrunohb_ppp +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HEXAGON_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Pd4=!any8(vcmpb.eq(Rss32,Rtt32)) + C Intrinsic Prototype: Byte Q6_p_not_any8_vcmpb_eq_PP(Word64 Rss, Word64 Rtt) + Instruction Type: ALU64 + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_p_not_any8_vcmpb_eq_PP __builtin_HEXAGON_A6_vcmpbeq_notany +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HEXAGON_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Rdd32=dfadd(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfadd_PP(Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfadd_PP __builtin_HEXAGON_F2_dfadd +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HEXAGON_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Rdd32=dfsub(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfsub_PP(Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfsub_PP __builtin_HEXAGON_F2_dfsub +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HEXAGON_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Rx32-=mpyi(Rs32,Rt32) + C Intrinsic Prototype: Word32 Q6_R_mpyinac_RR(Word32 Rx, Word32 Rs, Word32 Rt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mpyinac_RR __builtin_HEXAGON_M2_mnaci +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HEXAGON_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Rd32=mask(#u5,#U5) + C Intrinsic Prototype: Word32 Q6_R_mask_II(Word32 Iu5, Word32 IU5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_mask_II __builtin_HEXAGON_S2_mask +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=clip(Rs32,#u5) + C Intrinsic Prototype: Word32 Q6_R_clip_RI(Word32 Rs, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_R_clip_RI __builtin_HEXAGON_A7_clip +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=cround(Rss32,#u6) + C Intrinsic Prototype: Word64 Q6_P_cround_PI(Word64 Rss, Word32 Iu6) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cround_PI __builtin_HEXAGON_A7_croundd_ri +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=cround(Rss32,Rt32) + C Intrinsic Prototype: Word64 Q6_P_cround_PR(Word64 Rss, Word32 Rt) + Instruction Type: S_3op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_cround_PR __builtin_HEXAGON_A7_croundd_rr +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=vclip(Rss32,#u5) + C Intrinsic Prototype: Word64 Q6_P_vclip_PI(Word64 Rss, Word32 Iu5) + Instruction Type: S_2op + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_vclip_PI __builtin_HEXAGON_A7_vclip +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 +/* ========================================================================== + Assembly Syntax: Rdd32=dfmax(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfmax_PP(Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmax_PP __builtin_HEXAGON_F2_dfmax +#endif /* __HEXAGON_ARCH___ >= 67 */ + +#if __HEXAGON_ARCH__ >= 67 +/* ========================================================================== + Assembly Syntax: Rdd32=dfmin(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfmin_PP(Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmin_PP __builtin_HEXAGON_F2_dfmin +#endif /* __HEXAGON_ARCH___ >= 67 */ + +#if __HEXAGON_ARCH__ >= 67 +/* ========================================================================== + Assembly Syntax: Rdd32=dfmpyfix(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfmpyfix_PP(Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmpyfix_PP __builtin_HEXAGON_F2_dfmpyfix +#endif /* __HEXAGON_ARCH___ >= 67 */ + +#if __HEXAGON_ARCH__ >= 67 +/* ========================================================================== + Assembly Syntax: Rxx32+=dfmpyhh(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfmpyhhacc_PP(Float64 Rxx, Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmpyhhacc_PP __builtin_HEXAGON_F2_dfmpyhh +#endif /* __HEXAGON_ARCH___ >= 67 */ + +#if __HEXAGON_ARCH__ >= 67 +/* ========================================================================== + Assembly Syntax: Rxx32+=dfmpylh(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfmpylhacc_PP(Float64 Rxx, Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmpylhacc_PP __builtin_HEXAGON_F2_dfmpylh +#endif /* __HEXAGON_ARCH___ >= 67 */ + +#if __HEXAGON_ARCH__ >= 67 +/* ========================================================================== + Assembly Syntax: Rdd32=dfmpyll(Rss32,Rtt32) + C Intrinsic Prototype: Float64 Q6_P_dfmpyll_PP(Float64 Rss, Float64 Rtt) + Instruction Type: M + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_P_dfmpyll_PP __builtin_HEXAGON_F2_dfmpyll +#endif /* __HEXAGON_ARCH___ >= 67 */ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=cmpyiw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyiw_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyiw_PP __builtin_HEXAGON_M7_dcmpyiw +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpyiw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyiwacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyiwacc_PP __builtin_HEXAGON_M7_dcmpyiw_acc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=cmpyiw(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_cmpyiw_PP_conj(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyiw_PP_conj __builtin_HEXAGON_M7_dcmpyiwc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpyiw(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_cmpyiwacc_PP_conj(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyiwacc_PP_conj __builtin_HEXAGON_M7_dcmpyiwc_acc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=cmpyrw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyrw_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyrw_PP __builtin_HEXAGON_M7_dcmpyrw +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpyrw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_cmpyrwacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyrwacc_PP __builtin_HEXAGON_M7_dcmpyrw_acc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=cmpyrw(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_cmpyrw_PP_conj(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyrw_PP_conj __builtin_HEXAGON_M7_dcmpyrwc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rxx32+=cmpyrw(Rss32,Rtt32*) + C Intrinsic Prototype: Word64 Q6_P_cmpyrwacc_PP_conj(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_cmpyrwacc_PP_conj __builtin_HEXAGON_M7_dcmpyrwc_acc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rdd32=vdmpyw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vdmpyw_PP(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_vdmpyw_PP __builtin_HEXAGON_M7_vdmpy +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rxx32+=vdmpyw(Rss32,Rtt32) + C Intrinsic Prototype: Word64 Q6_P_vdmpywacc_PP(Word64 Rxx, Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_P_vdmpywacc_PP __builtin_HEXAGON_M7_vdmpy_acc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyiw(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyiw_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyiw_PP_s1_sat __builtin_HEXAGON_M7_wcmpyiw +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyiw(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyiw_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyiw_PP_s1_rnd_sat __builtin_HEXAGON_M7_wcmpyiw_rnd +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyiw(Rss32,Rtt32*):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyiw_PP_conj_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyiw_PP_conj_s1_sat __builtin_HEXAGON_M7_wcmpyiwc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyiw(Rss32,Rtt32*):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyiw_PP_conj_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyiw_PP_conj_s1_rnd_sat __builtin_HEXAGON_M7_wcmpyiwc_rnd +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyrw(Rss32,Rtt32):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyrw_PP_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyrw_PP_s1_sat __builtin_HEXAGON_M7_wcmpyrw +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyrw(Rss32,Rtt32):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyrw_PP_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyrw_PP_s1_rnd_sat __builtin_HEXAGON_M7_wcmpyrw_rnd +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyrw(Rss32,Rtt32*):<<1:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyrw_PP_conj_s1_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyrw_PP_conj_s1_sat __builtin_HEXAGON_M7_wcmpyrwc +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 67 && defined __HEXAGON_AUDIO__ +/* ========================================================================== + Assembly Syntax: Rd32=cmpyrw(Rss32,Rtt32*):<<1:rnd:sat + C Intrinsic Prototype: Word32 Q6_R_cmpyrw_PP_conj_s1_rnd_sat(Word64 Rss, Word64 Rtt) + Instruction Type: M + Execution Slots: SLOT3 + ========================================================================== */ + +#define Q6_R_cmpyrw_PP_conj_s1_rnd_sat __builtin_HEXAGON_M7_wcmpyrwc_rnd +#endif /* __HEXAGON_ARCH___ >= 67 && defined __HEXAGON_AUDIO__*/ + +#if __HEXAGON_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: dmlink(Rs32,Rt32) + C Intrinsic Prototype: void Q6_dmlink_AA(Address Rs, Address Rt) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dmlink_AA __builtin_HEXAGON_Y6_dmlink +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HEXAGON_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Rd32=dmpause + C Intrinsic Prototype: Word32 Q6_R_dmpause() + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_R_dmpause __builtin_HEXAGON_Y6_dmpause +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HEXAGON_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Rd32=dmpoll + C Intrinsic Prototype: Word32 Q6_R_dmpoll() + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_R_dmpoll __builtin_HEXAGON_Y6_dmpoll +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HEXAGON_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: dmresume(Rs32) + C Intrinsic Prototype: void Q6_dmresume_A(Address Rs) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dmresume_A __builtin_HEXAGON_Y6_dmresume +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HEXAGON_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: dmstart(Rs32) + C Intrinsic Prototype: void Q6_dmstart_A(Address Rs) + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_dmstart_A __builtin_HEXAGON_Y6_dmstart +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HEXAGON_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Rd32=dmwait + C Intrinsic Prototype: Word32 Q6_R_dmwait() + Instruction Type: ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_R_dmwait __builtin_HEXAGON_Y6_dmwait +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#include +#ifdef __HVX__ +#include +#endif /* __HVX__ */ +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_types.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_types.h new file mode 100755 index 0000000..8e73fad --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hexagon_types.h @@ -0,0 +1,2625 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef HEXAGON_TYPES_H +#define HEXAGON_TYPES_H + +#include + +/* Hexagon names */ +#define HEXAGON_Vect HEXAGON_Vect64 +#define HEXAGON_V_GET_D HEXAGON_V64_GET_D +#define HEXAGON_V_GET_UD HEXAGON_V64_GET_UD +#define HEXAGON_V_GET_W0 HEXAGON_V64_GET_W0 +#define HEXAGON_V_GET_W1 HEXAGON_V64_GET_W1 +#define HEXAGON_V_GET_UW0 HEXAGON_V64_GET_UW0 +#define HEXAGON_V_GET_UW1 HEXAGON_V64_GET_UW1 +#define HEXAGON_V_GET_H0 HEXAGON_V64_GET_H0 +#define HEXAGON_V_GET_H1 HEXAGON_V64_GET_H1 +#define HEXAGON_V_GET_H2 HEXAGON_V64_GET_H2 +#define HEXAGON_V_GET_H3 HEXAGON_V64_GET_H3 +#define HEXAGON_V_GET_UH0 HEXAGON_V64_GET_UH0 +#define HEXAGON_V_GET_UH1 HEXAGON_V64_GET_UH1 +#define HEXAGON_V_GET_UH2 HEXAGON_V64_GET_UH2 +#define HEXAGON_V_GET_UH3 HEXAGON_V64_GET_UH3 +#define HEXAGON_V_GET_B0 HEXAGON_V64_GET_B0 +#define HEXAGON_V_GET_B1 HEXAGON_V64_GET_B1 +#define HEXAGON_V_GET_B2 HEXAGON_V64_GET_B2 +#define HEXAGON_V_GET_B3 HEXAGON_V64_GET_B3 +#define HEXAGON_V_GET_B4 HEXAGON_V64_GET_B4 +#define HEXAGON_V_GET_B5 HEXAGON_V64_GET_B5 +#define HEXAGON_V_GET_B6 HEXAGON_V64_GET_B6 +#define HEXAGON_V_GET_B7 HEXAGON_V64_GET_B7 +#define HEXAGON_V_GET_UB0 HEXAGON_V64_GET_UB0 +#define HEXAGON_V_GET_UB1 HEXAGON_V64_GET_UB1 +#define HEXAGON_V_GET_UB2 HEXAGON_V64_GET_UB2 +#define HEXAGON_V_GET_UB3 HEXAGON_V64_GET_UB3 +#define HEXAGON_V_GET_UB4 HEXAGON_V64_GET_UB4 +#define HEXAGON_V_GET_UB5 HEXAGON_V64_GET_UB5 +#define HEXAGON_V_GET_UB6 HEXAGON_V64_GET_UB6 +#define HEXAGON_V_GET_UB7 HEXAGON_V64_GET_UB7 +#define HEXAGON_V_PUT_D HEXAGON_V64_PUT_D +#define HEXAGON_V_PUT_W0 HEXAGON_V64_PUT_W0 +#define HEXAGON_V_PUT_W1 HEXAGON_V64_PUT_W1 +#define HEXAGON_V_PUT_H0 HEXAGON_V64_PUT_H0 +#define HEXAGON_V_PUT_H1 HEXAGON_V64_PUT_H1 +#define HEXAGON_V_PUT_H2 HEXAGON_V64_PUT_H2 +#define HEXAGON_V_PUT_H3 HEXAGON_V64_PUT_H3 +#define HEXAGON_V_PUT_B0 HEXAGON_V64_PUT_B0 +#define HEXAGON_V_PUT_B1 HEXAGON_V64_PUT_B1 +#define HEXAGON_V_PUT_B2 HEXAGON_V64_PUT_B2 +#define HEXAGON_V_PUT_B3 HEXAGON_V64_PUT_B3 +#define HEXAGON_V_PUT_B4 HEXAGON_V64_PUT_B4 +#define HEXAGON_V_PUT_B5 HEXAGON_V64_PUT_B5 +#define HEXAGON_V_PUT_B6 HEXAGON_V64_PUT_B6 +#define HEXAGON_V_PUT_B7 HEXAGON_V64_PUT_B7 +#define HEXAGON_V_CREATE_D HEXAGON_V64_CREATE_D +#define HEXAGON_V_CREATE_W HEXAGON_V64_CREATE_W +#define HEXAGON_V_CREATE_H HEXAGON_V64_CREATE_H +#define HEXAGON_V_CREATE_B HEXAGON_V64_CREATE_B + +#ifdef __cplusplus +#define HEXAGON_VectC HEXAGON_Vect64C +#endif /* __cplusplus */ + +/* 64 Bit Vectors */ + +typedef long long __attribute__((__may_alias__)) HEXAGON_Vect64; + +/* Extract doubleword macros */ + +#define HEXAGON_V64_GET_D(v) (v) +#define HEXAGON_V64_GET_UD(v) ((unsigned long long)(v)) + +/* Extract word macros */ + +#define HEXAGON_V64_GET_W0(v) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.w[0]; \ + }) +#define HEXAGON_V64_GET_W1(v) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.w[1]; \ + }) +#define HEXAGON_V64_GET_UW0(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned int uw[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.uw[0]; \ + }) +#define HEXAGON_V64_GET_UW1(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned int uw[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.uw[1]; \ + }) + +/* Extract half word macros */ + +#define HEXAGON_V64_GET_H0(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[0]; \ + }) +#define HEXAGON_V64_GET_H1(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[1]; \ + }) +#define HEXAGON_V64_GET_H2(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[2]; \ + }) +#define HEXAGON_V64_GET_H3(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[3]; \ + }) +#define HEXAGON_V64_GET_UH0(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.uh[0]; \ + }) +#define HEXAGON_V64_GET_UH1(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.uh[1]; \ + }) +#define HEXAGON_V64_GET_UH2(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.uh[2]; \ + }) +#define HEXAGON_V64_GET_UH3(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.uh[3]; \ + }) + +/* Extract byte macros */ + +#define HEXAGON_V64_GET_B0(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[0]; \ + }) +#define HEXAGON_V64_GET_B1(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[1]; \ + }) +#define HEXAGON_V64_GET_B2(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[2]; \ + }) +#define HEXAGON_V64_GET_B3(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[3]; \ + }) +#define HEXAGON_V64_GET_B4(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[4]; \ + }) +#define HEXAGON_V64_GET_B5(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[5]; \ + }) +#define HEXAGON_V64_GET_B6(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[6]; \ + }) +#define HEXAGON_V64_GET_B7(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[7]; \ + }) +#define HEXAGON_V64_GET_UB0(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[0]; \ + }) +#define HEXAGON_V64_GET_UB1(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[1]; \ + }) +#define HEXAGON_V64_GET_UB2(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[2]; \ + }) +#define HEXAGON_V64_GET_UB3(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[3]; \ + }) +#define HEXAGON_V64_GET_UB4(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[4]; \ + }) +#define HEXAGON_V64_GET_UB5(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[5]; \ + }) +#define HEXAGON_V64_GET_UB6(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[6]; \ + }) +#define HEXAGON_V64_GET_UB7(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.ub[7]; \ + }) + +/* NOTE: All set macros return a HEXAGON_Vect64 type */ + +/* Set doubleword macro */ + +#define HEXAGON_V64_PUT_D(v, new) (new) + +/* Set word macros */ + +#ifdef __hexagon__ + +#define HEXAGON_V64_PUT_W0(v, new) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.w[0] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_W1(v, new) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.w[1] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V64_PUT_W0(v, new) \ + (((v) & 0xffffffff00000000LL) | ((HEXAGON_Vect64)((unsigned int)(new)))) +#define HEXAGON_V64_PUT_W1(v, new) \ + (((v) & 0x00000000ffffffffLL) | (((HEXAGON_Vect64)(new)) << 32LL)) + +#endif /* !__hexagon__ */ + +/* Set half word macros */ + +#ifdef __hexagon__ + +#define HEXAGON_V64_PUT_H0(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[0] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_H1(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[1] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_H2(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[2] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_H3(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.h[3] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V64_PUT_H0(v, new) \ + (((v) & 0xffffffffffff0000LL) | ((HEXAGON_Vect64)((unsigned short)(new)))) +#define HEXAGON_V64_PUT_H1(v, new) \ + (((v) & 0xffffffff0000ffffLL) | (((HEXAGON_Vect64)((unsigned short)(new))) << 16LL)) +#define HEXAGON_V64_PUT_H2(v, new) \ + (((v) & 0xffff0000ffffffffLL) | (((HEXAGON_Vect64)((unsigned short)(new))) << 32LL)) +#define HEXAGON_V64_PUT_H3(v, new) \ + (((v) & 0x0000ffffffffffffLL) | (((HEXAGON_Vect64)(new)) << 48LL)) + +#endif /* !__hexagon__ */ + +/* Set byte macros */ + +#ifdef __hexagon__ + +#define HEXAGON_V64_PUT_B0(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[0] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B1(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[1] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B2(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[2] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B3(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[3] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B4(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[4] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B5(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[5] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B6(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[6] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) +#define HEXAGON_V64_PUT_B7(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.d = (v); \ + _HEXAGON_V64_internal_union.b[7] = (new); \ + _HEXAGON_V64_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V64_PUT_B0(v, new) \ + (((v) & 0xffffffffffffff00LL) | ((HEXAGON_Vect64)((unsigned char)(new)))) +#define HEXAGON_V64_PUT_B1(v, new) \ + (((v) & 0xffffffffffff00ffLL) | (((HEXAGON_Vect64)((unsigned char)(new))) << 8LL)) +#define HEXAGON_V64_PUT_B2(v, new) \ + (((v) & 0xffffffffff00ffffLL) | (((HEXAGON_Vect64)((unsigned char)(new))) << 16LL)) +#define HEXAGON_V64_PUT_B3(v, new) \ + (((v) & 0xffffffff00ffffffLL) | (((HEXAGON_Vect64)((unsigned char)(new))) << 24LL)) +#define HEXAGON_V64_PUT_B4(v, new) \ + (((v) & 0xffffff00ffffffffLL) | (((HEXAGON_Vect64)((unsigned char)(new))) << 32LL)) +#define HEXAGON_V64_PUT_B5(v, new) \ + (((v) & 0xffff00ffffffffffLL) | (((HEXAGON_Vect64)((unsigned char)(new))) << 40LL)) +#define HEXAGON_V64_PUT_B6(v, new) \ + (((v) & 0xff00ffffffffffffLL) | (((HEXAGON_Vect64)((unsigned char)(new))) << 48LL)) +#define HEXAGON_V64_PUT_B7(v, new) \ + (((v) & 0x00ffffffffffffffLL) | (((HEXAGON_Vect64)(new)) << 56LL)) + +#endif /* !__hexagon__ */ + +/* NOTE: All create macros return a HEXAGON_Vect64 type */ + +/* Create from a doubleword */ + +#define HEXAGON_V64_CREATE_D(d) (d) + +/* Create from words */ + +#ifdef __hexagon__ + +#define HEXAGON_V64_CREATE_W(w1, w0) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.w[0] = (w0); \ + _HEXAGON_V64_internal_union.w[1] = (w1); \ + _HEXAGON_V64_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V64_CREATE_W(w1, w0) \ + ((((HEXAGON_Vect64)(w1)) << 32LL) | ((HEXAGON_Vect64)((w0) & 0xffffffff))) + +#endif /* !__hexagon__ */ + +/* Create from half words */ + +#ifdef __hexagon__ + +#define HEXAGON_V64_CREATE_H(h3, h2, h1, h0) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.h[0] = (h0); \ + _HEXAGON_V64_internal_union.h[1] = (h1); \ + _HEXAGON_V64_internal_union.h[2] = (h2); \ + _HEXAGON_V64_internal_union.h[3] = (h3); \ + _HEXAGON_V64_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V64_CREATE_H(h3, h2, h1, h0) \ + ((((HEXAGON_Vect64)(h3)) << 48LL) | (((HEXAGON_Vect64)((h2) & 0xffff)) << 32LL) | \ + (((HEXAGON_Vect64)((h1) & 0xffff)) << 16LL) | ((HEXAGON_Vect64)((h0) & 0xffff))) + +#endif /* !__hexagon__ */ + +/* Create from bytes */ + +#ifdef __hexagon__ + +#define HEXAGON_V64_CREATE_B(b7, b6, b5, b4, b3, b2, b1, b0) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _HEXAGON_V64_internal_union; \ + _HEXAGON_V64_internal_union.b[0] = (b0); \ + _HEXAGON_V64_internal_union.b[1] = (b1); \ + _HEXAGON_V64_internal_union.b[2] = (b2); \ + _HEXAGON_V64_internal_union.b[3] = (b3); \ + _HEXAGON_V64_internal_union.b[4] = (b4); \ + _HEXAGON_V64_internal_union.b[5] = (b5); \ + _HEXAGON_V64_internal_union.b[6] = (b6); \ + _HEXAGON_V64_internal_union.b[7] = (b7); \ + _HEXAGON_V64_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V64_CREATE_B(b7, b6, b5, b4, b3, b2, b1, b0) \ + ((((HEXAGON_Vect64)(b7)) << 56LL) | (((HEXAGON_Vect64)((b6) & 0xff)) << 48LL) | \ + (((HEXAGON_Vect64)((b5) & 0xff)) << 40LL) | (((HEXAGON_Vect64)((b4) & 0xff)) << 32LL) | \ + (((HEXAGON_Vect64)((b3) & 0xff)) << 24LL) | (((HEXAGON_Vect64)((b2) & 0xff)) << 16LL) | \ + (((HEXAGON_Vect64)((b1) & 0xff)) << 8LL) | ((HEXAGON_Vect64)((b0) & 0xff))) + +#endif /* !__hexagon__ */ + +#ifdef __cplusplus + +class HEXAGON_Vect64C { +public: + // Constructors + HEXAGON_Vect64C(long long d = 0) : data(d) {}; + HEXAGON_Vect64C(int w1, int w0) : data(HEXAGON_V64_CREATE_W(w1, w0)) {}; + HEXAGON_Vect64C(short h3, short h2, short h1, short h0) + : data(HEXAGON_V64_CREATE_H(h3, h2, h1, h0)) {}; + HEXAGON_Vect64C(signed char b7, signed char b6, signed char b5, signed char b4, + signed char b3, signed char b2, signed char b1, signed char b0) + : data(HEXAGON_V64_CREATE_B(b7, b6, b5, b4, b3, b2, b1, b0)) {}; + HEXAGON_Vect64C(const HEXAGON_Vect64C &v) : data(v.data) {}; + + HEXAGON_Vect64C &operator=(const HEXAGON_Vect64C &v) { + data = v.data; + return *this; + }; + + operator long long() { + return data; + }; + + // Extract doubleword methods + long long D(void) { + return HEXAGON_V64_GET_D(data); + }; + unsigned long long UD(void) { + return HEXAGON_V64_GET_UD(data); + }; + + // Extract word methods + int W0(void) { + return HEXAGON_V64_GET_W0(data); + }; + int W1(void) { + return HEXAGON_V64_GET_W1(data); + }; + unsigned int UW0(void) { + return HEXAGON_V64_GET_UW0(data); + }; + unsigned int UW1(void) { + return HEXAGON_V64_GET_UW1(data); + }; + + // Extract half word methods + short H0(void) { + return HEXAGON_V64_GET_H0(data); + }; + short H1(void) { + return HEXAGON_V64_GET_H1(data); + }; + short H2(void) { + return HEXAGON_V64_GET_H2(data); + }; + short H3(void) { + return HEXAGON_V64_GET_H3(data); + }; + unsigned short UH0(void) { + return HEXAGON_V64_GET_UH0(data); + }; + unsigned short UH1(void) { + return HEXAGON_V64_GET_UH1(data); + }; + unsigned short UH2(void) { + return HEXAGON_V64_GET_UH2(data); + }; + unsigned short UH3(void) { + return HEXAGON_V64_GET_UH3(data); + }; + + // Extract byte methods + signed char B0(void) { + return HEXAGON_V64_GET_B0(data); + }; + signed char B1(void) { + return HEXAGON_V64_GET_B1(data); + }; + signed char B2(void) { + return HEXAGON_V64_GET_B2(data); + }; + signed char B3(void) { + return HEXAGON_V64_GET_B3(data); + }; + signed char B4(void) { + return HEXAGON_V64_GET_B4(data); + }; + signed char B5(void) { + return HEXAGON_V64_GET_B5(data); + }; + signed char B6(void) { + return HEXAGON_V64_GET_B6(data); + }; + signed char B7(void) { + return HEXAGON_V64_GET_B7(data); + }; + unsigned char UB0(void) { + return HEXAGON_V64_GET_UB0(data); + }; + unsigned char UB1(void) { + return HEXAGON_V64_GET_UB1(data); + }; + unsigned char UB2(void) { + return HEXAGON_V64_GET_UB2(data); + }; + unsigned char UB3(void) { + return HEXAGON_V64_GET_UB3(data); + }; + unsigned char UB4(void) { + return HEXAGON_V64_GET_UB4(data); + }; + unsigned char UB5(void) { + return HEXAGON_V64_GET_UB5(data); + }; + unsigned char UB6(void) { + return HEXAGON_V64_GET_UB6(data); + }; + unsigned char UB7(void) { + return HEXAGON_V64_GET_UB7(data); + }; + + // NOTE: All set methods return a HEXAGON_Vect64C type + + // Set doubleword method + HEXAGON_Vect64C D(long long d) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_D(data, d)); + }; + + // Set word methods + HEXAGON_Vect64C W0(int w) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_W0(data, w)); + }; + HEXAGON_Vect64C W1(int w) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_W1(data, w)); + }; + + // Set half word methods + HEXAGON_Vect64C H0(short h) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_H0(data, h)); + }; + HEXAGON_Vect64C H1(short h) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_H1(data, h)); + }; + HEXAGON_Vect64C H2(short h) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_H2(data, h)); + }; + HEXAGON_Vect64C H3(short h) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_H3(data, h)); + }; + + // Set byte methods + HEXAGON_Vect64C B0(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B0(data, b)); + }; + HEXAGON_Vect64C B1(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B1(data, b)); + }; + HEXAGON_Vect64C B2(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B2(data, b)); + }; + HEXAGON_Vect64C B3(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B3(data, b)); + }; + HEXAGON_Vect64C B4(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B4(data, b)); + }; + HEXAGON_Vect64C B5(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B5(data, b)); + }; + HEXAGON_Vect64C B6(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B6(data, b)); + }; + HEXAGON_Vect64C B7(signed char b) { + return HEXAGON_Vect64C(HEXAGON_V64_PUT_B7(data, b)); + }; + +private: + long long data; +}; + +#endif /* __cplusplus */ + +/* 32 Bit Vectors */ + +typedef int HEXAGON_Vect32; + +/* Extract word macros */ + +#define HEXAGON_V32_GET_W(v) (v) +#define HEXAGON_V32_GET_UW(v) ((unsigned int)(v)) + +/* Extract half word macros */ + +#define HEXAGON_V32_GET_H0(v) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.h[0]; \ + }) +#define HEXAGON_V32_GET_H1(v) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.h[1]; \ + }) +#define HEXAGON_V32_GET_UH0(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned short uh[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.uh[0]; \ + }) +#define HEXAGON_V32_GET_UH1(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned short uh[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.uh[1]; \ + }) + +/* Extract byte macros */ + +#define HEXAGON_V32_GET_B0(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[0]; \ + }) +#define HEXAGON_V32_GET_B1(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[1]; \ + }) +#define HEXAGON_V32_GET_B2(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[2]; \ + }) +#define HEXAGON_V32_GET_B3(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[3]; \ + }) +#define HEXAGON_V32_GET_UB0(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.ub[0]; \ + }) +#define HEXAGON_V32_GET_UB1(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.ub[1]; \ + }) +#define HEXAGON_V32_GET_UB2(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.ub[2]; \ + }) +#define HEXAGON_V32_GET_UB3(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.ub[3]; \ + }) + +/* NOTE: All set macros return a HEXAGON_Vect32 type */ + +/* Set word macro */ + +#define HEXAGON_V32_PUT_W(v, new) (new) + +/* Set half word macros */ + +#ifdef __hexagon__ + +#define HEXAGON_V32_PUT_H0(v, new) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.h[0] = (new); \ + _HEXAGON_V32_internal_union.w; \ + }) +#define HEXAGON_V32_PUT_H1(v, new) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.h[1] = (new); \ + _HEXAGON_V32_internal_union.w; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V32_PUT_H0(v, new) \ + (((v) & 0xffff0000) | ((HEXAGON_Vect32)((unsigned short)(new)))) +#define HEXAGON_V32_PUT_H1(v, new) (((v) & 0x0000ffff) | (((HEXAGON_Vect32)(new)) << 16)) + +#endif /* !__hexagon__ */ + +/* Set byte macros */ + +#ifdef __hexagon__ + +#define HEXAGON_V32_PUT_B0(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[0] = (new); \ + _HEXAGON_V32_internal_union.w; \ + }) +#define HEXAGON_V32_PUT_B1(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[1] = (new); \ + _HEXAGON_V32_internal_union.w; \ + }) +#define HEXAGON_V32_PUT_B2(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[2] = (new); \ + _HEXAGON_V32_internal_union.w; \ + }) +#define HEXAGON_V32_PUT_B3(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.w = (v); \ + _HEXAGON_V32_internal_union.b[3] = (new); \ + _HEXAGON_V32_internal_union.w; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V32_PUT_B0(v, new) \ + (((v) & 0xffffff00) | ((HEXAGON_Vect32)((unsigned char)(new)))) +#define HEXAGON_V32_PUT_B1(v, new) \ + (((v) & 0xffff00ff) | (((HEXAGON_Vect32)((unsigned char)(new))) << 8)) +#define HEXAGON_V32_PUT_B2(v, new) \ + (((v) & 0xff00ffff) | (((HEXAGON_Vect32)((unsigned char)(new))) << 16)) +#define HEXAGON_V32_PUT_B3(v, new) (((v) & 0x00ffffff) | (((HEXAGON_Vect32)(new)) << 24)) + +#endif /* !__hexagon__ */ + +/* NOTE: All create macros return a HEXAGON_Vect32 type */ + +/* Create from a word */ + +#define HEXAGON_V32_CREATE_W(w) (w) + +/* Create from half words */ + +#ifdef __hexagon__ + +#define HEXAGON_V32_CREATE_H(h1, h0) \ + __extension__({ \ + union { \ + long long d; \ + short h[2]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.h[0] = (h0); \ + _HEXAGON_V32_internal_union.h[1] = (h1); \ + _HEXAGON_V32_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V32_CREATE_H(h1, h0) \ + ((((HEXAGON_Vect32)(h1)) << 16) | ((HEXAGON_Vect32)((h0) & 0xffff))) + +#endif /* !__hexagon__ */ + +/* Create from bytes */ +#ifdef __hexagon__ + +#define HEXAGON_V32_CREATE_B(b3, b2, b1, b0) \ + __extension__({ \ + union { \ + long long d; \ + char b[4]; \ + } _HEXAGON_V32_internal_union; \ + _HEXAGON_V32_internal_union.b[0] = (b0); \ + _HEXAGON_V32_internal_union.b[1] = (b1); \ + _HEXAGON_V32_internal_union.b[2] = (b2); \ + _HEXAGON_V32_internal_union.b[3] = (b3); \ + _HEXAGON_V32_internal_union.d; \ + }) + +#else /* !__hexagon__ */ + +#define HEXAGON_V32_CREATE_B(b3, b2, b1, b0) \ + ((((HEXAGON_Vect32)(b3)) << 24) | (((HEXAGON_Vect32)((b2) & 0xff)) << 16) | \ + (((HEXAGON_Vect32)((b1) & 0xff)) << 8) | ((HEXAGON_Vect32)((b0) & 0xff))) + +#endif /* !__hexagon__ */ + +#ifdef __cplusplus + +class HEXAGON_Vect32C { +public: + // Constructors + HEXAGON_Vect32C(int w = 0) : data(w) {}; + HEXAGON_Vect32C(short h1, short h0) : data(HEXAGON_V32_CREATE_H(h1, h0)) {}; + HEXAGON_Vect32C(signed char b3, signed char b2, signed char b1, signed char b0) + : data(HEXAGON_V32_CREATE_B(b3, b2, b1, b0)) {}; + HEXAGON_Vect32C(const HEXAGON_Vect32C &v) : data(v.data) {}; + + HEXAGON_Vect32C &operator=(const HEXAGON_Vect32C &v) { + data = v.data; + return *this; + }; + + operator int() { + return data; + }; + + // Extract word methods + int W(void) { + return HEXAGON_V32_GET_W(data); + }; + unsigned int UW(void) { + return HEXAGON_V32_GET_UW(data); + }; + + // Extract half word methods + short H0(void) { + return HEXAGON_V32_GET_H0(data); + }; + short H1(void) { + return HEXAGON_V32_GET_H1(data); + }; + unsigned short UH0(void) { + return HEXAGON_V32_GET_UH0(data); + }; + unsigned short UH1(void) { + return HEXAGON_V32_GET_UH1(data); + }; + + // Extract byte methods + signed char B0(void) { + return HEXAGON_V32_GET_B0(data); + }; + signed char B1(void) { + return HEXAGON_V32_GET_B1(data); + }; + signed char B2(void) { + return HEXAGON_V32_GET_B2(data); + }; + signed char B3(void) { + return HEXAGON_V32_GET_B3(data); + }; + unsigned char UB0(void) { + return HEXAGON_V32_GET_UB0(data); + }; + unsigned char UB1(void) { + return HEXAGON_V32_GET_UB1(data); + }; + unsigned char UB2(void) { + return HEXAGON_V32_GET_UB2(data); + }; + unsigned char UB3(void) { + return HEXAGON_V32_GET_UB3(data); + }; + + // NOTE: All set methods return a HEXAGON_Vect32C type + + // Set word method + HEXAGON_Vect32C W(int w) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_W(data, w)); + }; + + // Set half word methods + HEXAGON_Vect32C H0(short h) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_H0(data, h)); + }; + HEXAGON_Vect32C H1(short h) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_H1(data, h)); + }; + + // Set byte methods + HEXAGON_Vect32C B0(signed char b) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_B0(data, b)); + }; + HEXAGON_Vect32C B1(signed char b) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_B1(data, b)); + }; + HEXAGON_Vect32C B2(signed char b) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_B2(data, b)); + }; + HEXAGON_Vect32C B3(signed char b) { + return HEXAGON_Vect32C(HEXAGON_V32_PUT_B3(data, b)); + }; + +private: + int data; +}; + +#endif /* __cplusplus */ + +// V65 Vector types +#if __HVX_ARCH__ >= 65 +#if defined __HVX__ && (__HVX_LENGTH__ == 128) + typedef long HEXAGON_VecPred128 __attribute__((__vector_size__(128))) + __attribute__((aligned(128))); + + typedef long HEXAGON_Vect1024 __attribute__((__vector_size__(128))) + __attribute__((aligned(128))); + + typedef long HEXAGON_Vect2048 __attribute__((__vector_size__(256))) + __attribute__((aligned(256))); + + typedef long HEXAGON_UVect1024 __attribute__((__vector_size__(128))) + __attribute__((aligned(4))); + + typedef long HEXAGON_UVect2048 __attribute__((__vector_size__(256))) + __attribute__((aligned(4))); + + #define HVX_VectorPred HEXAGON_VecPred128 + #define HVX_Vector HEXAGON_Vect1024 + #define HVX_VectorPair HEXAGON_Vect2048 + #define HVX_UVector HEXAGON_UVect1024 + #define HVX_UVectorPair HEXAGON_UVect2048 +#else /* defined __HVX__ && (__HVX_LENGTH__ == 128) */ +#if defined __HVX__ && (__HVX_LENGTH__ == 64) + typedef long HEXAGON_VecPred64 __attribute__((__vector_size__(64))) + __attribute__((aligned(64))); + + typedef long HEXAGON_Vect512 __attribute__((__vector_size__(64))) + __attribute__((aligned(64))); + + typedef long HEXAGON_Vect1024 __attribute__((__vector_size__(128))) + __attribute__((aligned(128))); + + typedef long HEXAGON_UVect512 __attribute__((__vector_size__(64))) + __attribute__((aligned(4))); + + typedef long HEXAGON_UVect1024 __attribute__((__vector_size__(128))) + __attribute__((aligned(4))); + + #define HVX_VectorPred HEXAGON_VecPred64 + #define HVX_Vector HEXAGON_Vect512 + #define HVX_VectorPair HEXAGON_Vect1024 + #define HVX_UVector HEXAGON_UVect512 + #define HVX_UVectorPair HEXAGON_UVect1024 +#endif /* defined __HVX__ && (__HVX_LENGTH__ == 64) */ +#endif /* defined __HVX__ && (__HVX_LENGTH__ == 128) */ +#endif /* __HVX_ARCH__ >= 65 */ + +/* Predicates */ + +typedef int HEXAGON_Pred; + +/*** + *** backward compatibility aliases + ***/ + +/* Old names */ +#define Q6Vect Q6Vect64 +#define Q6V_GET_D Q6V64_GET_D +#define Q6V_GET_UD Q6V64_GET_UD +#define Q6V_GET_W0 Q6V64_GET_W0 +#define Q6V_GET_W1 Q6V64_GET_W1 +#define Q6V_GET_UW0 Q6V64_GET_UW0 +#define Q6V_GET_UW1 Q6V64_GET_UW1 +#define Q6V_GET_H0 Q6V64_GET_H0 +#define Q6V_GET_H1 Q6V64_GET_H1 +#define Q6V_GET_H2 Q6V64_GET_H2 +#define Q6V_GET_H3 Q6V64_GET_H3 +#define Q6V_GET_UH0 Q6V64_GET_UH0 +#define Q6V_GET_UH1 Q6V64_GET_UH1 +#define Q6V_GET_UH2 Q6V64_GET_UH2 +#define Q6V_GET_UH3 Q6V64_GET_UH3 +#define Q6V_GET_B0 Q6V64_GET_B0 +#define Q6V_GET_B1 Q6V64_GET_B1 +#define Q6V_GET_B2 Q6V64_GET_B2 +#define Q6V_GET_B3 Q6V64_GET_B3 +#define Q6V_GET_B4 Q6V64_GET_B4 +#define Q6V_GET_B5 Q6V64_GET_B5 +#define Q6V_GET_B6 Q6V64_GET_B6 +#define Q6V_GET_B7 Q6V64_GET_B7 +#define Q6V_GET_UB0 Q6V64_GET_UB0 +#define Q6V_GET_UB1 Q6V64_GET_UB1 +#define Q6V_GET_UB2 Q6V64_GET_UB2 +#define Q6V_GET_UB3 Q6V64_GET_UB3 +#define Q6V_GET_UB4 Q6V64_GET_UB4 +#define Q6V_GET_UB5 Q6V64_GET_UB5 +#define Q6V_GET_UB6 Q6V64_GET_UB6 +#define Q6V_GET_UB7 Q6V64_GET_UB7 +#define Q6V_PUT_D Q6V64_PUT_D +#define Q6V_PUT_W0 Q6V64_PUT_W0 +#define Q6V_PUT_W1 Q6V64_PUT_W1 +#define Q6V_PUT_H0 Q6V64_PUT_H0 +#define Q6V_PUT_H1 Q6V64_PUT_H1 +#define Q6V_PUT_H2 Q6V64_PUT_H2 +#define Q6V_PUT_H3 Q6V64_PUT_H3 +#define Q6V_PUT_B0 Q6V64_PUT_B0 +#define Q6V_PUT_B1 Q6V64_PUT_B1 +#define Q6V_PUT_B2 Q6V64_PUT_B2 +#define Q6V_PUT_B3 Q6V64_PUT_B3 +#define Q6V_PUT_B4 Q6V64_PUT_B4 +#define Q6V_PUT_B5 Q6V64_PUT_B5 +#define Q6V_PUT_B6 Q6V64_PUT_B6 +#define Q6V_PUT_B7 Q6V64_PUT_B7 +#define Q6V_CREATE_D Q6V64_CREATE_D +#define Q6V_CREATE_W Q6V64_CREATE_W +#define Q6V_CREATE_H Q6V64_CREATE_H +#define Q6V_CREATE_B Q6V64_CREATE_B + +#ifdef __cplusplus +#define Q6VectC Q6Vect64C +#endif /* __cplusplus */ + +/* 64 Bit Vectors */ + +typedef long long __attribute__((__may_alias__)) Q6Vect64; + +/* Extract doubleword macros */ + +#define Q6V64_GET_D(v) (v) +#define Q6V64_GET_UD(v) ((unsigned long long)(v)) + +/* Extract word macros */ + +#define Q6V64_GET_W0(v) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.w[0]; \ + }) +#define Q6V64_GET_W1(v) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.w[1]; \ + }) +#define Q6V64_GET_UW0(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned int uw[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.uw[0]; \ + }) +#define Q6V64_GET_UW1(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned int uw[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.uw[1]; \ + }) + +/* Extract half word macros */ + +#define Q6V64_GET_H0(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[0]; \ + }) +#define Q6V64_GET_H1(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[1]; \ + }) +#define Q6V64_GET_H2(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[2]; \ + }) +#define Q6V64_GET_H3(v) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[3]; \ + }) +#define Q6V64_GET_UH0(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.uh[0]; \ + }) +#define Q6V64_GET_UH1(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.uh[1]; \ + }) +#define Q6V64_GET_UH2(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.uh[2]; \ + }) +#define Q6V64_GET_UH3(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned short uh[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.uh[3]; \ + }) + +/* Extract byte macros */ + +#define Q6V64_GET_B0(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[0]; \ + }) +#define Q6V64_GET_B1(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[1]; \ + }) +#define Q6V64_GET_B2(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[2]; \ + }) +#define Q6V64_GET_B3(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[3]; \ + }) +#define Q6V64_GET_B4(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[4]; \ + }) +#define Q6V64_GET_B5(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[5]; \ + }) +#define Q6V64_GET_B6(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[6]; \ + }) +#define Q6V64_GET_B7(v) \ + __extension__({ \ + union { \ + long long d; \ + signed char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[7]; \ + }) +#define Q6V64_GET_UB0(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[0]; \ + }) +#define Q6V64_GET_UB1(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[1]; \ + }) +#define Q6V64_GET_UB2(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[2]; \ + }) +#define Q6V64_GET_UB3(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[3]; \ + }) +#define Q6V64_GET_UB4(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[4]; \ + }) +#define Q6V64_GET_UB5(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[5]; \ + }) +#define Q6V64_GET_UB6(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[6]; \ + }) +#define Q6V64_GET_UB7(v) \ + __extension__({ \ + union { \ + long long d; \ + unsigned char ub[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.ub[7]; \ + }) + +/* NOTE: All set macros return a Q6Vect64 type */ + +/* Set doubleword macro */ + +#define Q6V64_PUT_D(v, new) (new) + +/* Set word macros */ + +#ifdef __qdsp6__ + +#define Q6V64_PUT_W0(v, new) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.w[0] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_W1(v, new) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.w[1] = (new); \ + _Q6V64_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V64_PUT_W0(v, new) \ + (((v) & 0xffffffff00000000LL) | ((Q6Vect64)((unsigned int)(new)))) +#define Q6V64_PUT_W1(v, new) \ + (((v) & 0x00000000ffffffffLL) | (((Q6Vect64)(new)) << 32LL)) + +#endif /* !__qdsp6__ */ + +/* Set half word macros */ + +#ifdef __qdsp6__ + +#define Q6V64_PUT_H0(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[0] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_H1(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[1] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_H2(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[2] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_H3(v, new) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.h[3] = (new); \ + _Q6V64_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V64_PUT_H0(v, new) \ + (((v) & 0xffffffffffff0000LL) | ((Q6Vect64)((unsigned short)(new)))) +#define Q6V64_PUT_H1(v, new) \ + (((v) & 0xffffffff0000ffffLL) | (((Q6Vect64)((unsigned short)(new))) << 16LL)) +#define Q6V64_PUT_H2(v, new) \ + (((v) & 0xffff0000ffffffffLL) | (((Q6Vect64)((unsigned short)(new))) << 32LL)) +#define Q6V64_PUT_H3(v, new) \ + (((v) & 0x0000ffffffffffffLL) | (((Q6Vect64)(new)) << 48LL)) + +#endif /* !__qdsp6__ */ + +/* Set byte macros */ + +#ifdef __qdsp6__ + +#define Q6V64_PUT_B0(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[0] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B1(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[1] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B2(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[2] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B3(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[3] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B4(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[4] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B5(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[5] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B6(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[6] = (new); \ + _Q6V64_internal_union.d; \ + }) +#define Q6V64_PUT_B7(v, new) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.d = (v); \ + _Q6V64_internal_union.b[7] = (new); \ + _Q6V64_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V64_PUT_B0(v, new) \ + (((v) & 0xffffffffffffff00LL) | ((Q6Vect64)((unsigned char)(new)))) +#define Q6V64_PUT_B1(v, new) \ + (((v) & 0xffffffffffff00ffLL) | (((Q6Vect64)((unsigned char)(new))) << 8LL)) +#define Q6V64_PUT_B2(v, new) \ + (((v) & 0xffffffffff00ffffLL) | (((Q6Vect64)((unsigned char)(new))) << 16LL)) +#define Q6V64_PUT_B3(v, new) \ + (((v) & 0xffffffff00ffffffLL) | (((Q6Vect64)((unsigned char)(new))) << 24LL)) +#define Q6V64_PUT_B4(v, new) \ + (((v) & 0xffffff00ffffffffLL) | (((Q6Vect64)((unsigned char)(new))) << 32LL)) +#define Q6V64_PUT_B5(v, new) \ + (((v) & 0xffff00ffffffffffLL) | (((Q6Vect64)((unsigned char)(new))) << 40LL)) +#define Q6V64_PUT_B6(v, new) \ + (((v) & 0xff00ffffffffffffLL) | (((Q6Vect64)((unsigned char)(new))) << 48LL)) +#define Q6V64_PUT_B7(v, new) \ + (((v) & 0x00ffffffffffffffLL) | (((Q6Vect64)(new)) << 56LL)) + +#endif /* !__qdsp6__ */ + +/* NOTE: All create macros return a Q6Vect64 type */ + +/* Create from a doubleword */ + +#define Q6V64_CREATE_D(d) (d) + +/* Create from words */ + +#ifdef __qdsp6__ + +#define Q6V64_CREATE_W(w1, w0) \ + __extension__({ \ + union { \ + long long d; \ + int w[2]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.w[0] = (w0); \ + _Q6V64_internal_union.w[1] = (w1); \ + _Q6V64_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V64_CREATE_W(w1, w0) \ + ((((Q6Vect64)(w1)) << 32LL) | ((Q6Vect64)((w0) & 0xffffffff))) + +#endif /* !__qdsp6__ */ + +/* Create from half words */ + +#ifdef __qdsp6__ + +#define Q6V64_CREATE_H(h3, h2, h1, h0) \ + __extension__({ \ + union { \ + long long d; \ + short h[4]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.h[0] = (h0); \ + _Q6V64_internal_union.h[1] = (h1); \ + _Q6V64_internal_union.h[2] = (h2); \ + _Q6V64_internal_union.h[3] = (h3); \ + _Q6V64_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V64_CREATE_H(h3, h2, h1, h0) \ + ((((Q6Vect64)(h3)) << 48LL) | (((Q6Vect64)((h2) & 0xffff)) << 32LL) | \ + (((Q6Vect64)((h1) & 0xffff)) << 16LL) | ((Q6Vect64)((h0) & 0xffff))) + +#endif /* !__qdsp6__ */ + +/* Create from bytes */ + +#ifdef __qdsp6__ + +#define Q6V64_CREATE_B(b7, b6, b5, b4, b3, b2, b1, b0) \ + __extension__({ \ + union { \ + long long d; \ + char b[8]; \ + } _Q6V64_internal_union; \ + _Q6V64_internal_union.b[0] = (b0); \ + _Q6V64_internal_union.b[1] = (b1); \ + _Q6V64_internal_union.b[2] = (b2); \ + _Q6V64_internal_union.b[3] = (b3); \ + _Q6V64_internal_union.b[4] = (b4); \ + _Q6V64_internal_union.b[5] = (b5); \ + _Q6V64_internal_union.b[6] = (b6); \ + _Q6V64_internal_union.b[7] = (b7); \ + _Q6V64_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V64_CREATE_B(b7, b6, b5, b4, b3, b2, b1, b0) \ + ((((Q6Vect64)(b7)) << 56LL) | (((Q6Vect64)((b6) & 0xff)) << 48LL) | \ + (((Q6Vect64)((b5) & 0xff)) << 40LL) | (((Q6Vect64)((b4) & 0xff)) << 32LL) | \ + (((Q6Vect64)((b3) & 0xff)) << 24LL) | (((Q6Vect64)((b2) & 0xff)) << 16LL) | \ + (((Q6Vect64)((b1) & 0xff)) << 8LL) | ((Q6Vect64)((b0) & 0xff))) + +#endif /* !__qdsp6__ */ + +#ifdef __cplusplus + +class Q6Vect64C { +public: + // Constructors + Q6Vect64C(long long d = 0) : data(d) {}; + Q6Vect64C(int w1, int w0) : data(Q6V64_CREATE_W(w1, w0)) {}; + Q6Vect64C(short h3, short h2, short h1, short h0) + : data(Q6V64_CREATE_H(h3, h2, h1, h0)) {}; + Q6Vect64C(signed char b7, signed char b6, signed char b5, signed char b4, + signed char b3, signed char b2, signed char b1, signed char b0) + : data(Q6V64_CREATE_B(b7, b6, b5, b4, b3, b2, b1, b0)) {}; + Q6Vect64C(const Q6Vect64C &v) : data(v.data) {}; + + Q6Vect64C &operator=(const Q6Vect64C &v) { + data = v.data; + return *this; + }; + + operator long long() { + return data; + }; + + // Extract doubleword methods + long long D(void) { + return Q6V64_GET_D(data); + }; + unsigned long long UD(void) { + return Q6V64_GET_UD(data); + }; + + // Extract word methods + int W0(void) { + return Q6V64_GET_W0(data); + }; + int W1(void) { + return Q6V64_GET_W1(data); + }; + unsigned int UW0(void) { + return Q6V64_GET_UW0(data); + }; + unsigned int UW1(void) { + return Q6V64_GET_UW1(data); + }; + + // Extract half word methods + short H0(void) { + return Q6V64_GET_H0(data); + }; + short H1(void) { + return Q6V64_GET_H1(data); + }; + short H2(void) { + return Q6V64_GET_H2(data); + }; + short H3(void) { + return Q6V64_GET_H3(data); + }; + unsigned short UH0(void) { + return Q6V64_GET_UH0(data); + }; + unsigned short UH1(void) { + return Q6V64_GET_UH1(data); + }; + unsigned short UH2(void) { + return Q6V64_GET_UH2(data); + }; + unsigned short UH3(void) { + return Q6V64_GET_UH3(data); + }; + + // Extract byte methods + signed char B0(void) { + return Q6V64_GET_B0(data); + }; + signed char B1(void) { + return Q6V64_GET_B1(data); + }; + signed char B2(void) { + return Q6V64_GET_B2(data); + }; + signed char B3(void) { + return Q6V64_GET_B3(data); + }; + signed char B4(void) { + return Q6V64_GET_B4(data); + }; + signed char B5(void) { + return Q6V64_GET_B5(data); + }; + signed char B6(void) { + return Q6V64_GET_B6(data); + }; + signed char B7(void) { + return Q6V64_GET_B7(data); + }; + unsigned char UB0(void) { + return Q6V64_GET_UB0(data); + }; + unsigned char UB1(void) { + return Q6V64_GET_UB1(data); + }; + unsigned char UB2(void) { + return Q6V64_GET_UB2(data); + }; + unsigned char UB3(void) { + return Q6V64_GET_UB3(data); + }; + unsigned char UB4(void) { + return Q6V64_GET_UB4(data); + }; + unsigned char UB5(void) { + return Q6V64_GET_UB5(data); + }; + unsigned char UB6(void) { + return Q6V64_GET_UB6(data); + }; + unsigned char UB7(void) { + return Q6V64_GET_UB7(data); + }; + + // NOTE: All set methods return a Q6Vect64C type + + // Set doubleword method + Q6Vect64C D(long long d) { + return Q6Vect64C(Q6V64_PUT_D(data, d)); + }; + + // Set word methods + Q6Vect64C W0(int w) { + return Q6Vect64C(Q6V64_PUT_W0(data, w)); + }; + Q6Vect64C W1(int w) { + return Q6Vect64C(Q6V64_PUT_W1(data, w)); + }; + + // Set half word methods + Q6Vect64C H0(short h) { + return Q6Vect64C(Q6V64_PUT_H0(data, h)); + }; + Q6Vect64C H1(short h) { + return Q6Vect64C(Q6V64_PUT_H1(data, h)); + }; + Q6Vect64C H2(short h) { + return Q6Vect64C(Q6V64_PUT_H2(data, h)); + }; + Q6Vect64C H3(short h) { + return Q6Vect64C(Q6V64_PUT_H3(data, h)); + }; + + // Set byte methods + Q6Vect64C B0(signed char b) { + return Q6Vect64C(Q6V64_PUT_B0(data, b)); + }; + Q6Vect64C B1(signed char b) { + return Q6Vect64C(Q6V64_PUT_B1(data, b)); + }; + Q6Vect64C B2(signed char b) { + return Q6Vect64C(Q6V64_PUT_B2(data, b)); + }; + Q6Vect64C B3(signed char b) { + return Q6Vect64C(Q6V64_PUT_B3(data, b)); + }; + Q6Vect64C B4(signed char b) { + return Q6Vect64C(Q6V64_PUT_B4(data, b)); + }; + Q6Vect64C B5(signed char b) { + return Q6Vect64C(Q6V64_PUT_B5(data, b)); + }; + Q6Vect64C B6(signed char b) { + return Q6Vect64C(Q6V64_PUT_B6(data, b)); + }; + Q6Vect64C B7(signed char b) { + return Q6Vect64C(Q6V64_PUT_B7(data, b)); + }; + +private: + long long data; +}; + +#endif /* __cplusplus */ + +/* 32 Bit Vectors */ + +typedef int Q6Vect32; + +/* Extract word macros */ + +#define Q6V32_GET_W(v) (v) +#define Q6V32_GET_UW(v) ((unsigned int)(v)) + +/* Extract half word macros */ + +#define Q6V32_GET_H0(v) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.h[0]; \ + }) +#define Q6V32_GET_H1(v) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.h[1]; \ + }) +#define Q6V32_GET_UH0(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned short uh[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.uh[0]; \ + }) +#define Q6V32_GET_UH1(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned short uh[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.uh[1]; \ + }) + +/* Extract byte macros */ + +#define Q6V32_GET_B0(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[0]; \ + }) +#define Q6V32_GET_B1(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[1]; \ + }) +#define Q6V32_GET_B2(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[2]; \ + }) +#define Q6V32_GET_B3(v) \ + __extension__({ \ + union { \ + int w; \ + signed char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[3]; \ + }) +#define Q6V32_GET_UB0(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.ub[0]; \ + }) +#define Q6V32_GET_UB1(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.ub[1]; \ + }) +#define Q6V32_GET_UB2(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.ub[2]; \ + }) +#define Q6V32_GET_UB3(v) \ + __extension__({ \ + union { \ + int w; \ + unsigned char ub[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.ub[3]; \ + }) + +/* NOTE: All set macros return a Q6Vect32 type */ + +/* Set word macro */ + +#define Q6V32_PUT_W(v, new) (new) + +/* Set half word macros */ + +#ifdef __qdsp6__ + +#define Q6V32_PUT_H0(v, new) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.h[0] = (new); \ + _Q6V32_internal_union.w; \ + }) +#define Q6V32_PUT_H1(v, new) \ + __extension__({ \ + union { \ + int w; \ + short h[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.h[1] = (new); \ + _Q6V32_internal_union.w; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V32_PUT_H0(v, new) \ + (((v) & 0xffff0000) | ((Q6Vect32)((unsigned short)(new)))) +#define Q6V32_PUT_H1(v, new) (((v) & 0x0000ffff) | (((Q6Vect32)(new)) << 16)) + +#endif /* !__qdsp6__ */ + +/* Set byte macros */ + +#ifdef __qdsp6__ + +#define Q6V32_PUT_B0(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[0] = (new); \ + _Q6V32_internal_union.w; \ + }) +#define Q6V32_PUT_B1(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[1] = (new); \ + _Q6V32_internal_union.w; \ + }) +#define Q6V32_PUT_B2(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[2] = (new); \ + _Q6V32_internal_union.w; \ + }) +#define Q6V32_PUT_B3(v, new) \ + __extension__({ \ + union { \ + int w; \ + char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.w = (v); \ + _Q6V32_internal_union.b[3] = (new); \ + _Q6V32_internal_union.w; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V32_PUT_B0(v, new) \ + (((v) & 0xffffff00) | ((Q6Vect32)((unsigned char)(new)))) +#define Q6V32_PUT_B1(v, new) \ + (((v) & 0xffff00ff) | (((Q6Vect32)((unsigned char)(new))) << 8)) +#define Q6V32_PUT_B2(v, new) \ + (((v) & 0xff00ffff) | (((Q6Vect32)((unsigned char)(new))) << 16)) +#define Q6V32_PUT_B3(v, new) (((v) & 0x00ffffff) | (((Q6Vect32)(new)) << 24)) + +#endif /* !__qdsp6__ */ + +/* NOTE: All create macros return a Q6Vect32 type */ + +/* Create from a word */ + +#define Q6V32_CREATE_W(w) (w) + +/* Create from half words */ + +#ifdef __qdsp6__ + +#define Q6V32_CREATE_H(h1, h0) \ + __extension__({ \ + union { \ + long long d; \ + short h[2]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.h[0] = (h0); \ + _Q6V32_internal_union.h[1] = (h1); \ + _Q6V32_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V32_CREATE_H(h1, h0) \ + ((((Q6Vect32)(h1)) << 16) | ((Q6Vect32)((h0) & 0xffff))) + +#endif /* !__qdsp6__ */ + +/* Create from bytes */ +#ifdef __qdsp6__ + +#define Q6V32_CREATE_B(b3, b2, b1, b0) \ + __extension__({ \ + union { \ + long long d; \ + char b[4]; \ + } _Q6V32_internal_union; \ + _Q6V32_internal_union.b[0] = (b0); \ + _Q6V32_internal_union.b[1] = (b1); \ + _Q6V32_internal_union.b[2] = (b2); \ + _Q6V32_internal_union.b[3] = (b3); \ + _Q6V32_internal_union.d; \ + }) + +#else /* !__qdsp6__ */ + +#define Q6V32_CREATE_B(b3, b2, b1, b0) \ + ((((Q6Vect32)(b3)) << 24) | (((Q6Vect32)((b2) & 0xff)) << 16) | \ + (((Q6Vect32)((b1) & 0xff)) << 8) | ((Q6Vect32)((b0) & 0xff))) + +#endif /* !__qdsp6__ */ + +#ifdef __cplusplus + +class Q6Vect32C { +public: + // Constructors + Q6Vect32C(int w = 0) : data(w) {}; + Q6Vect32C(short h1, short h0) : data(Q6V32_CREATE_H(h1, h0)) {}; + Q6Vect32C(signed char b3, signed char b2, signed char b1, signed char b0) + : data(Q6V32_CREATE_B(b3, b2, b1, b0)) {}; + Q6Vect32C(const Q6Vect32C &v) : data(v.data) {}; + + Q6Vect32C &operator=(const Q6Vect32C &v) { + data = v.data; + return *this; + }; + + operator int() { + return data; + }; + + // Extract word methods + int W(void) { + return Q6V32_GET_W(data); + }; + unsigned int UW(void) { + return Q6V32_GET_UW(data); + }; + + // Extract half word methods + short H0(void) { + return Q6V32_GET_H0(data); + }; + short H1(void) { + return Q6V32_GET_H1(data); + }; + unsigned short UH0(void) { + return Q6V32_GET_UH0(data); + }; + unsigned short UH1(void) { + return Q6V32_GET_UH1(data); + }; + + // Extract byte methods + signed char B0(void) { + return Q6V32_GET_B0(data); + }; + signed char B1(void) { + return Q6V32_GET_B1(data); + }; + signed char B2(void) { + return Q6V32_GET_B2(data); + }; + signed char B3(void) { + return Q6V32_GET_B3(data); + }; + unsigned char UB0(void) { + return Q6V32_GET_UB0(data); + }; + unsigned char UB1(void) { + return Q6V32_GET_UB1(data); + }; + unsigned char UB2(void) { + return Q6V32_GET_UB2(data); + }; + unsigned char UB3(void) { + return Q6V32_GET_UB3(data); + }; + + // NOTE: All set methods return a Q6Vect32C type + + // Set word method + Q6Vect32C W(int w) { + return Q6Vect32C(Q6V32_PUT_W(data, w)); + }; + + // Set half word methods + Q6Vect32C H0(short h) { + return Q6Vect32C(Q6V32_PUT_H0(data, h)); + }; + Q6Vect32C H1(short h) { + return Q6Vect32C(Q6V32_PUT_H1(data, h)); + }; + + // Set byte methods + Q6Vect32C B0(signed char b) { + return Q6Vect32C(Q6V32_PUT_B0(data, b)); + }; + Q6Vect32C B1(signed char b) { + return Q6Vect32C(Q6V32_PUT_B1(data, b)); + }; + Q6Vect32C B2(signed char b) { + return Q6Vect32C(Q6V32_PUT_B2(data, b)); + }; + Q6Vect32C B3(signed char b) { + return Q6Vect32C(Q6V32_PUT_B3(data, b)); + }; + +private: + int data; +}; + +#endif /* __cplusplus */ + +// V65 Vector types +#if __HVX_ARCH__ >= 65 +#if defined __HVX__ && (__HVX_LENGTH__ == 128) +typedef long Q6VecPred128 __attribute__((__vector_size__(128))) + __attribute__((aligned(128))); + +typedef long Q6Vect1024 __attribute__((__vector_size__(128))) + __attribute__((aligned(128))); + +typedef long Q6Vect2048 __attribute__((__vector_size__(256))) + __attribute__((aligned(256))); + +#else /* defined __HVX__ && (__HVX_LENGTH__ == 128) */ +#if defined __HVX__ && (__HVX_LENGTH__ == 64) +typedef long Q6VecPred64 __attribute__((__vector_size__(64))) + __attribute__((aligned(64))); + +typedef long Q6Vect512 __attribute__((__vector_size__(64))) + __attribute__((aligned(64))); + +typedef long Q6Vect1024 __attribute__((__vector_size__(128))) + __attribute__((aligned(128))); + +#endif /* defined __HVX__ && (__HVX_LENGTH__ == 64) */ +#endif /* defined __HVX__ && (__HVX_LENGTH__ == 128) */ +#endif /* __HVX_ARCH__ >= 65 */ + +/* Predicates */ + +typedef int Q6Pred; + + +#ifdef __HVX__ + +// Extract HVX VectorPair macro. +#define HEXAGON_HVX_GET_W(v) (v) + +// Extract HVX Vector macros. +#define HEXAGON_HVX_GET_V0(v) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_Vector V[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.W = (v); \ + _HEXAGON_HVX_internal_union.V[0]; \ + }) +#define HEXAGON_HVX_GET_V1(v) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_Vector V[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.W = (v); \ + _HEXAGON_HVX_internal_union.V[1]; \ + }) +#define HEXAGON_HVX_GET_P(v) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_VectorPred P[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.W = (v); \ + _HEXAGON_HVX_internal_union.P[0]; \ + }) + +// Set HVX VectorPair macro. +#define HEXAGON_HVX_PUT_W(v, new) (new) + +// Set HVX Vector macros. +#define HEXAGON_HVX_PUT_V0(v, new) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_Vector V[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.W = (v); \ + _HEXAGON_HVX_internal_union.V[0] = (new); \ + _HEXAGON_HVX_internal_union.W; \ + }) + +#define HEXAGON_HVX_PUT_V1(v, new) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_Vector V[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.W = (v); \ + _HEXAGON_HVX_internal_union.V[1] = (new); \ + _HEXAGON_HVX_internal_union.W; \ + }) + +#define HEXAGON_HVX_PUT_P(v, new) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_VectorPred P[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.W = (v); \ + _HEXAGON_HVX_internal_union.P[0] = (new); \ + _HEXAGON_HVX_internal_union.W; \ + }) + + +#define HEXAGON_HVX_CREATE_W(v1, v0) \ + __extension__({ \ + union { \ + HVX_VectorPair W; \ + HVX_Vector V[2]; \ + } _HEXAGON_HVX_internal_union; \ + _HEXAGON_HVX_internal_union.V[0] = (v0); \ + _HEXAGON_HVX_internal_union.V[1] = (v1); \ + _HEXAGON_HVX_internal_union.W; \ + }) + +#ifdef __cplusplus + +class HVX_Vect { +public: + // Constructors. + // Default. + HVX_Vect() : data(Q6_W_vcombine_VV(Q6_V_vzero(), Q6_V_vzero())){}; + + // Custom constructors. + HVX_Vect(HVX_VectorPair W) : data(W){}; + HVX_Vect(HVX_Vector v1, HVX_Vector v0) : data(HEXAGON_HVX_CREATE_W(v1, v0)){}; + + // Copy constructor. + HVX_Vect(const HVX_Vect &W) = default; + + // Move constructor. + HVX_Vect(HVX_Vect &&W) = default; + + // Assignment operator. + HVX_Vect &operator=(const HVX_Vect &W) = default; + + operator HVX_VectorPair() { return data; }; + + // Extract VectorPair method. + HVX_VectorPair W(void) { return HEXAGON_HVX_GET_W(data); }; + + // Extract Vector methods. + HVX_Vector V0(void) { return HEXAGON_HVX_GET_V0(data); }; + HVX_Vector V1(void) { return HEXAGON_HVX_GET_V1(data); }; + HVX_VectorPred P(void) { return HEXAGON_HVX_GET_P(data); }; + + // NOTE: All set methods return a HVX_Vect type. + // Set HVX VectorPair method. + HVX_Vect W(HVX_VectorPair w) { return HVX_Vect(HEXAGON_HVX_PUT_W(data, w)); }; + + // Set HVX Vector methods. + HVX_Vect V0(HVX_Vector v) { return HVX_Vect(HEXAGON_HVX_PUT_V0(data, v)); }; + HVX_Vect V1(HVX_Vector v) { return HVX_Vect(HEXAGON_HVX_PUT_V1(data, v)); }; + HVX_Vect P(HVX_VectorPred p) { return HVX_Vect(HEXAGON_HVX_PUT_P(data, p)); }; + +private: + HVX_VectorPair data; +}; + +#endif /* __cplusplus */ +#endif /* __HVX__ */ + +#define HEXAGON_UDMA_DM0_STATUS_IDLE 0x00000000 +#define HEXAGON_UDMA_DM0_STATUS_RUN 0x00000001 +#define HEXAGON_UDMA_DM0_STATUS_ERROR 0x00000002 +#define HEXAGON_UDMA_DESC_DSTATE_INCOMPLETE 0 +#define HEXAGON_UDMA_DESC_DSTATE_COMPLETE 1 +#define HEXAGON_UDMA_DESC_ORDER_NOORDER 0 +#define HEXAGON_UDMA_DESC_ORDER_ORDER 1 +#define HEXAGON_UDMA_DESC_BYPASS_OFF 0 +#define HEXAGON_UDMA_DESC_BYPASS_ON 1 +#define HEXAGON_UDMA_DESC_COMP_NONE 0 +#define HEXAGON_UDMA_DESC_COMP_DLBC 1 +#define HEXAGON_UDMA_DESC_DESCTYPE_TYPE0 0 +#define HEXAGON_UDMA_DESC_DESCTYPE_TYPE1 1 + +typedef struct hexagon_udma_descriptor_type0_s +{ + void *next; + unsigned int length:24; + unsigned int desctype:2; + unsigned int dstcomp:1; + unsigned int srccomp:1; + unsigned int dstbypass:1; + unsigned int srcbypass:1; + unsigned int order:1; + unsigned int dstate:1; + void *src; + void *dst; +} hexagon_udma_descriptor_type0_t; + +typedef struct hexagon_udma_descriptor_type1_s +{ + void *next; + unsigned int length:24; + unsigned int desctype:2; + unsigned int dstcomp:1; + unsigned int srccomp:1; + unsigned int dstbypass:1; + unsigned int srcbypass:1; + unsigned int order:1; + unsigned int dstate:1; + void *src; + void *dst; + unsigned int allocation:28; + unsigned int padding:4; + unsigned int roiwidth:16; + unsigned int roiheight:16; + unsigned int srcstride:16; + unsigned int dststride:16; + unsigned int srcwidthoffset:16; + unsigned int dstwidthoffset:16; +} hexagon_udma_descriptor_type1_t; + +#endif /* !HEXAGON_TYPES_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hresetintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hresetintrin.h new file mode 100755 index 0000000..646f6c1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hresetintrin.h @@ -0,0 +1,49 @@ +/*===---------------- hresetintrin.h - HRESET intrinsics -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __X86GPRINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __HRESETINTRIN_H +#define __HRESETINTRIN_H + +#if __has_extension(gnu_asm) + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("hreset"))) + +/// Provides a hint to the processor to selectively reset the prediction +/// history of the current logical processor specified by a 32-bit integer +/// value \a __eax. +/// +/// This intrinsic corresponds to the HRESET instruction. +/// +/// \code{.operation} +/// IF __eax == 0 +/// // nop +/// ELSE +/// FOR i := 0 to 31 +/// IF __eax[i] +/// ResetPredictionFeature(i) +/// FI +/// ENDFOR +/// FI +/// \endcode +static __inline void __DEFAULT_FN_ATTRS +_hreset(int __eax) +{ + __asm__ ("hreset $0" :: "a"(__eax)); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __has_extension(gnu_asm) */ + +#endif /* __HRESETINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/htmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/htmintrin.h new file mode 100755 index 0000000..49c2b98 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/htmintrin.h @@ -0,0 +1,212 @@ +/*===---- htmintrin.h - Standard header for PowerPC HTM ---------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __HTMINTRIN_H +#define __HTMINTRIN_H + +#ifndef __HTM__ +#error "HTM instruction set not enabled" +#endif + +#ifdef __powerpc__ + +#include + +typedef uint64_t texasr_t; +typedef uint32_t texasru_t; +typedef uint32_t texasrl_t; +typedef uintptr_t tfiar_t; +typedef uintptr_t tfhar_t; + +#define _HTM_STATE(CR0) ((CR0 >> 1) & 0x3) +#define _HTM_NONTRANSACTIONAL 0x0 +#define _HTM_SUSPENDED 0x1 +#define _HTM_TRANSACTIONAL 0x2 + +#define _TEXASR_EXTRACT_BITS(TEXASR,BITNUM,SIZE) \ + (((TEXASR) >> (63-(BITNUM))) & ((1<<(SIZE))-1)) +#define _TEXASRU_EXTRACT_BITS(TEXASR,BITNUM,SIZE) \ + (((TEXASR) >> (31-(BITNUM))) & ((1<<(SIZE))-1)) + +#define _TEXASR_FAILURE_CODE(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 7, 8) +#define _TEXASRU_FAILURE_CODE(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 7, 8) + +#define _TEXASR_FAILURE_PERSISTENT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 7, 1) +#define _TEXASRU_FAILURE_PERSISTENT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 7, 1) + +#define _TEXASR_DISALLOWED(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 8, 1) +#define _TEXASRU_DISALLOWED(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 8, 1) + +#define _TEXASR_NESTING_OVERFLOW(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 9, 1) +#define _TEXASRU_NESTING_OVERFLOW(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 9, 1) + +#define _TEXASR_FOOTPRINT_OVERFLOW(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 10, 1) +#define _TEXASRU_FOOTPRINT_OVERFLOW(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 10, 1) + +#define _TEXASR_SELF_INDUCED_CONFLICT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 11, 1) +#define _TEXASRU_SELF_INDUCED_CONFLICT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 11, 1) + +#define _TEXASR_NON_TRANSACTIONAL_CONFLICT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 12, 1) +#define _TEXASRU_NON_TRANSACTIONAL_CONFLICT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 12, 1) + +#define _TEXASR_TRANSACTION_CONFLICT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 13, 1) +#define _TEXASRU_TRANSACTION_CONFLICT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 13, 1) + +#define _TEXASR_TRANSLATION_INVALIDATION_CONFLICT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 14, 1) +#define _TEXASRU_TRANSLATION_INVALIDATION_CONFLICT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 14, 1) + +#define _TEXASR_IMPLEMENTAION_SPECIFIC(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 15, 1) +#define _TEXASRU_IMPLEMENTAION_SPECIFIC(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 15, 1) + +#define _TEXASR_INSTRUCTION_FETCH_CONFLICT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 16, 1) +#define _TEXASRU_INSTRUCTION_FETCH_CONFLICT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 16, 1) + +#define _TEXASR_ABORT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 31, 1) +#define _TEXASRU_ABORT(TEXASRU) \ + _TEXASRU_EXTRACT_BITS(TEXASRU, 31, 1) + + +#define _TEXASR_SUSPENDED(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 32, 1) + +#define _TEXASR_PRIVILEGE(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 35, 2) + +#define _TEXASR_FAILURE_SUMMARY(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 36, 1) + +#define _TEXASR_TFIAR_EXACT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 37, 1) + +#define _TEXASR_ROT(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 38, 1) + +#define _TEXASR_TRANSACTION_LEVEL(TEXASR) \ + _TEXASR_EXTRACT_BITS(TEXASR, 63, 12) + +#endif /* __powerpc */ + +#ifdef __s390__ + +/* Condition codes generated by tbegin */ +#define _HTM_TBEGIN_STARTED 0 +#define _HTM_TBEGIN_INDETERMINATE 1 +#define _HTM_TBEGIN_TRANSIENT 2 +#define _HTM_TBEGIN_PERSISTENT 3 + +/* The abort codes below this threshold are reserved for machine use. */ +#define _HTM_FIRST_USER_ABORT_CODE 256 + +/* The transaction diagnostic block is it is defined in the Principles + of Operation chapter 5-91. */ + +struct __htm_tdb { + unsigned char format; /* 0 */ + unsigned char flags; + unsigned char reserved1[4]; + unsigned short nesting_depth; + unsigned long long abort_code; /* 8 */ + unsigned long long conflict_token; /* 16 */ + unsigned long long atia; /* 24 */ + unsigned char eaid; /* 32 */ + unsigned char dxc; + unsigned char reserved2[2]; + unsigned int program_int_id; + unsigned long long exception_id; /* 40 */ + unsigned long long bea; /* 48 */ + unsigned char reserved3[72]; /* 56 */ + unsigned long long gprs[16]; /* 128 */ +} __attribute__((__packed__, __aligned__ (8))); + + +/* Helper intrinsics to retry tbegin in case of transient failure. */ + +static __inline int __attribute__((__always_inline__, __nodebug__)) +__builtin_tbegin_retry_null (int __retry) +{ + int cc, i = 0; + + while ((cc = __builtin_tbegin(0)) == _HTM_TBEGIN_TRANSIENT + && i++ < __retry) + __builtin_tx_assist(i); + + return cc; +} + +static __inline int __attribute__((__always_inline__, __nodebug__)) +__builtin_tbegin_retry_tdb (void *__tdb, int __retry) +{ + int cc, i = 0; + + while ((cc = __builtin_tbegin(__tdb)) == _HTM_TBEGIN_TRANSIENT + && i++ < __retry) + __builtin_tx_assist(i); + + return cc; +} + +#define __builtin_tbegin_retry(tdb, retry) \ + (__builtin_constant_p(tdb == 0) && tdb == 0 ? \ + __builtin_tbegin_retry_null(retry) : \ + __builtin_tbegin_retry_tdb(tdb, retry)) + +static __inline int __attribute__((__always_inline__, __nodebug__)) +__builtin_tbegin_retry_nofloat_null (int __retry) +{ + int cc, i = 0; + + while ((cc = __builtin_tbegin_nofloat(0)) == _HTM_TBEGIN_TRANSIENT + && i++ < __retry) + __builtin_tx_assist(i); + + return cc; +} + +static __inline int __attribute__((__always_inline__, __nodebug__)) +__builtin_tbegin_retry_nofloat_tdb (void *__tdb, int __retry) +{ + int cc, i = 0; + + while ((cc = __builtin_tbegin_nofloat(__tdb)) == _HTM_TBEGIN_TRANSIENT + && i++ < __retry) + __builtin_tx_assist(i); + + return cc; +} + +#define __builtin_tbegin_retry_nofloat(tdb, retry) \ + (__builtin_constant_p(tdb == 0) && tdb == 0 ? \ + __builtin_tbegin_retry_nofloat_null(retry) : \ + __builtin_tbegin_retry_nofloat_tdb(tdb, retry)) + +#endif /* __s390__ */ + +#endif /* __HTMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/htmxlintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/htmxlintrin.h new file mode 100755 index 0000000..6ef6f4b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/htmxlintrin.h @@ -0,0 +1,345 @@ +/*===---- htmxlintrin.h - XL compiler HTM execution intrinsics-------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __HTMXLINTRIN_H +#define __HTMXLINTRIN_H + +#ifndef __HTM__ +#error "HTM instruction set not enabled" +#endif + +#include + +#ifdef __powerpc__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define _TEXASR_PTR(TM_BUF) ((texasr_t *)((char *)(TM_BUF) + 0)) +#define _TEXASRU_PTR(TM_BUF) ((texasru_t *)((char *)(TM_BUF) + 0)) +#define _TEXASRL_PTR(TM_BUF) ((texasrl_t *)((char *)(TM_BUF) + 4)) +#define _TFIAR_PTR(TM_BUF) ((tfiar_t *)((char *)(TM_BUF) + 8)) + +typedef char TM_buff_type[16]; + +/* This macro can be used to determine whether a transaction was successfully + started from the __TM_begin() and __TM_simple_begin() intrinsic functions + below. */ +#define _HTM_TBEGIN_STARTED 1 + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_simple_begin (void) +{ + if (__builtin_expect (__builtin_tbegin (0), 1)) + return _HTM_TBEGIN_STARTED; + return 0; +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_begin (void* const __TM_buff) +{ + *_TEXASRL_PTR (__TM_buff) = 0; + if (__builtin_expect (__builtin_tbegin (0), 1)) + return _HTM_TBEGIN_STARTED; +#ifdef __powerpc64__ + *_TEXASR_PTR (__TM_buff) = __builtin_get_texasr (); +#else + *_TEXASRU_PTR (__TM_buff) = __builtin_get_texasru (); + *_TEXASRL_PTR (__TM_buff) = __builtin_get_texasr (); +#endif + *_TFIAR_PTR (__TM_buff) = __builtin_get_tfiar (); + return 0; +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_end (void) +{ + if (__builtin_expect (__builtin_tend (0), 1)) + return 1; + return 0; +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_abort (void) +{ + __builtin_tabort (0); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_named_abort (unsigned char const __code) +{ + __builtin_tabort (__code); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_resume (void) +{ + __builtin_tresume (); +} + +extern __inline void +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_suspend (void) +{ + __builtin_tsuspend (); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_user_abort (void* const __TM_buff) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + return _TEXASRU_ABORT (texasru); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_named_user_abort (void* const __TM_buff, unsigned char *__code) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + + *__code = _TEXASRU_FAILURE_CODE (texasru); + return _TEXASRU_ABORT (texasru); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_illegal (void* const __TM_buff) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + return _TEXASRU_DISALLOWED (texasru); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_footprint_exceeded (void* const __TM_buff) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + return _TEXASRU_FOOTPRINT_OVERFLOW (texasru); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_nesting_depth (void* const __TM_buff) +{ + texasrl_t texasrl; + + if (_HTM_STATE (__builtin_ttest ()) == _HTM_NONTRANSACTIONAL) + { + texasrl = *_TEXASRL_PTR (__TM_buff); + if (!_TEXASR_FAILURE_SUMMARY (texasrl)) + texasrl = 0; + } + else + texasrl = (texasrl_t) __builtin_get_texasr (); + + return _TEXASR_TRANSACTION_LEVEL (texasrl); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_nested_too_deep(void* const __TM_buff) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + return _TEXASRU_NESTING_OVERFLOW (texasru); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_conflict(void* const __TM_buff) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + /* Return TEXASR bits 11 (Self-Induced Conflict) through + 14 (Translation Invalidation Conflict). */ + return (_TEXASRU_EXTRACT_BITS (texasru, 14, 4)) ? 1 : 0; +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_is_failure_persistent(void* const __TM_buff) +{ + texasru_t texasru = *_TEXASRU_PTR (__TM_buff); + return _TEXASRU_FAILURE_PERSISTENT (texasru); +} + +extern __inline long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_failure_address(void* const __TM_buff) +{ + return *_TFIAR_PTR (__TM_buff); +} + +extern __inline long long +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +__TM_failure_code(void* const __TM_buff) +{ + return *_TEXASR_PTR (__TM_buff); +} + +#ifdef __cplusplus +} +#endif + +#endif /* __powerpc__ */ + +#ifdef __s390__ + +#include + +/* These intrinsics are being made available for compatibility with + the IBM XL compiler. For documentation please see the "z/OS XL + C/C++ Programming Guide" publicly available on the web. */ + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_simple_begin () +{ + return __builtin_tbegin_nofloat (0); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_begin (void* const __tdb) +{ + return __builtin_tbegin_nofloat (__tdb); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_end () +{ + return __builtin_tend (); +} + +static __inline void __attribute__((__always_inline__)) +__TM_abort () +{ + return __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE); +} + +static __inline void __attribute__((__always_inline__, __nodebug__)) +__TM_named_abort (unsigned char const __code) +{ + return __builtin_tabort ((int)_HTM_FIRST_USER_ABORT_CODE + __code); +} + +static __inline void __attribute__((__always_inline__, __nodebug__)) +__TM_non_transactional_store (void* const __addr, long long const __value) +{ + __builtin_non_tx_store ((uint64_t*)__addr, (uint64_t)__value); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_nesting_depth (void* const __tdb_ptr) +{ + int depth = __builtin_tx_nesting_depth (); + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + if (depth != 0) + return depth; + + if (tdb->format != 1) + return 0; + return tdb->nesting_depth; +} + +/* Transaction failure diagnostics */ + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_user_abort (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + if (tdb->format != 1) + return 0; + + return !!(tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_named_user_abort (void* const __tdb_ptr, unsigned char* __code) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + if (tdb->format != 1) + return 0; + + if (tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE) + { + *__code = tdb->abort_code - _HTM_FIRST_USER_ABORT_CODE; + return 1; + } + return 0; +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_illegal (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + return (tdb->format == 1 + && (tdb->abort_code == 4 /* unfiltered program interruption */ + || tdb->abort_code == 11 /* restricted instruction */)); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_footprint_exceeded (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + return (tdb->format == 1 + && (tdb->abort_code == 7 /* fetch overflow */ + || tdb->abort_code == 8 /* store overflow */)); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_nested_too_deep (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + return tdb->format == 1 && tdb->abort_code == 13; /* depth exceeded */ +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_conflict (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + return (tdb->format == 1 + && (tdb->abort_code == 9 /* fetch conflict */ + || tdb->abort_code == 10 /* store conflict */)); +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_is_failure_persistent (long const __result) +{ + return __result == _HTM_TBEGIN_PERSISTENT; +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_failure_address (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + return tdb->atia; +} + +static __inline long __attribute__((__always_inline__, __nodebug__)) +__TM_failure_code (void* const __tdb_ptr) +{ + struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr; + + return tdb->abort_code; +} + +#endif /* __s390__ */ + +#endif /* __HTMXLINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hvx_hexagon_protos.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hvx_hexagon_protos.h new file mode 100755 index 0000000..fd120a5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/hvx_hexagon_protos.h @@ -0,0 +1,5610 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// Automatically generated file, do not edit! +//===----------------------------------------------------------------------===// + + +#ifndef _HVX_HEXAGON_PROTOS_H_ +#define _HVX_HEXAGON_PROTOS_H_ 1 + +#ifdef __HVX__ +#if __HVX_LENGTH__ == 128 +#define __BUILTIN_VECTOR_WRAP(a) a ## _128B +#else +#define __BUILTIN_VECTOR_WRAP(a) a +#endif + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Rd32=vextract(Vu32,Rs32) + C Intrinsic Prototype: Word32 Q6_R_vextract_VR(HVX_Vector Vu, Word32 Rs) + Instruction Type: LD + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_R_vextract_VR(Vu,Rs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_extractw)(Vu,Rs) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=hi(Vss32) + C Intrinsic Prototype: HVX_Vector Q6_V_hi_W(HVX_VectorPair Vss) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_hi_W(Vss) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_hi)(Vss) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=lo(Vss32) + C Intrinsic Prototype: HVX_Vector Q6_V_lo_W(HVX_VectorPair Vss) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_lo_W(Vss) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_lo)(Vss) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vsplat(Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vsplat_R(Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vsplat_R(Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_lvsplatw)(Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=and(Qs4,Qt4) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_and_QQ(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_and_QQ(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=and(Qs4,!Qt4) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_and_QQn(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_and_QQn(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_and_n)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=not(Qs4) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_not_Q(HVX_VectorPred Qs) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_not_Q(Qs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_not)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=or(Qs4,Qt4) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_or_QQ(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_or_QQ(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=or(Qs4,!Qt4) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_or_QQn(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_or_QQn(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_or_n)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vsetq(Rt32) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vsetq_R(Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vsetq_R(Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_scalar2)(Rt)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=xor(Qs4,Qt4) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_xor_QQ(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_xor_QQ(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) vmem(Rt32+#s4)=Vs32 + C Intrinsic Prototype: void Q6_vmem_QnRIV(HVX_VectorPred Qv, HVX_Vector* Rt, HVX_Vector Vs) + Instruction Type: CVI_VM_ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmem_QnRIV(Qv,Rt,Vs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vS32b_nqpred_ai)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Rt,Vs) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) vmem(Rt32+#s4):nt=Vs32 + C Intrinsic Prototype: void Q6_vmem_QnRIV_nt(HVX_VectorPred Qv, HVX_Vector* Rt, HVX_Vector Vs) + Instruction Type: CVI_VM_ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmem_QnRIV_nt(Qv,Rt,Vs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vS32b_nt_nqpred_ai)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Rt,Vs) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) vmem(Rt32+#s4):nt=Vs32 + C Intrinsic Prototype: void Q6_vmem_QRIV_nt(HVX_VectorPred Qv, HVX_Vector* Rt, HVX_Vector Vs) + Instruction Type: CVI_VM_ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmem_QRIV_nt(Qv,Rt,Vs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vS32b_nt_qpred_ai)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Rt,Vs) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) vmem(Rt32+#s4)=Vs32 + C Intrinsic Prototype: void Q6_vmem_QRIV(HVX_VectorPred Qv, HVX_Vector* Rt, HVX_Vector Vs) + Instruction Type: CVI_VM_ST + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vmem_QRIV(Qv,Rt,Vs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vS32b_qpred_ai)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Rt,Vs) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vabsdiff(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vabsdiff_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuh_vabsdiff_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsdiffh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vabsdiff(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vabsdiff_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vub_vabsdiff_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsdiffub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vabsdiff(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vabsdiff_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuh_vabsdiff_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsdiffuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vabsdiff(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vabsdiff_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vabsdiff_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsdiffw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vabs(Vu32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vabs_Vh(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vabs_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vabs(Vu32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vabs_Vh_sat(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vabs_Vh_sat(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsh_sat)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vabs(Vu32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vabs_Vw(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vabs_Vw(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsw)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vabs(Vu32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vabs_Vw_sat(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vabs_Vw_sat(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsw_sat)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vadd(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vadd_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vadd_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.b=vadd(Vuu32.b,Vvv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wb_vadd_WbWb(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wb_vadd_WbWb(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddb_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) Vx32.b+=Vu32.b + C Intrinsic Prototype: HVX_Vector Q6_Vb_condacc_QnVbVb(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_condacc_QnVbVb(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddbnq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) Vx32.b+=Vu32.b + C Intrinsic Prototype: HVX_Vector Q6_Vb_condacc_QVbVb(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_condacc_QVbVb(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddbq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vadd(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vadd_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vadd_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vadd(Vuu32.h,Vvv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vadd_WhWh(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vadd_WhWh(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddh_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) Vx32.h+=Vu32.h + C Intrinsic Prototype: HVX_Vector Q6_Vh_condacc_QnVhVh(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_condacc_QnVhVh(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddhnq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) Vx32.h+=Vu32.h + C Intrinsic Prototype: HVX_Vector Q6_Vh_condacc_QVhVh(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_condacc_QVhVh(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddhq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vadd(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vadd_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vadd_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddhsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vadd(Vuu32.h,Vvv32.h):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vadd_WhWh_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vadd_WhWh_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddhsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vadd(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vadd_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vadd_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddhw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vadd(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vadd_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vadd_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddubh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vadd(Vu32.ub,Vv32.ub):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vadd_VubVub_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vadd_VubVub_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddubsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.ub=vadd(Vuu32.ub,Vvv32.ub):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wub_vadd_WubWub_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wub_vadd_WubWub_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddubsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vadd(Vu32.uh,Vv32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vadd_VuhVuh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vadd_VuhVuh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadduhsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uh=vadd(Vuu32.uh,Vvv32.uh):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vadd_WuhWuh_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuh_vadd_WuhWuh_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadduhsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vadd(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vadd_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vadd_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadduhw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vadd(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vadd_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vadd_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vadd(Vuu32.w,Vvv32.w) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vadd_WwWw(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vadd_WwWw(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddw_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) Vx32.w+=Vu32.w + C Intrinsic Prototype: HVX_Vector Q6_Vw_condacc_QnVwVw(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_condacc_QnVwVw(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddwnq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) Vx32.w+=Vu32.w + C Intrinsic Prototype: HVX_Vector Q6_Vw_condacc_QVwVw(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_condacc_QVwVw(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddwq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vadd(Vu32.w,Vv32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vadd_VwVw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vadd_VwVw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddwsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vadd(Vuu32.w,Vvv32.w):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vadd_WwWw_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vadd_WwWw_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddwsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=valign(Vu32,Vv32,Rt8) + C Intrinsic Prototype: HVX_Vector Q6_V_valign_VVR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_valign_VVR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_valignb)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=valign(Vu32,Vv32,#u3) + C Intrinsic Prototype: HVX_Vector Q6_V_valign_VVI(HVX_Vector Vu, HVX_Vector Vv, Word32 Iu3) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_valign_VVI(Vu,Vv,Iu3) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_valignbi)(Vu,Vv,Iu3) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vand(Vu32,Vv32) + C Intrinsic Prototype: HVX_Vector Q6_V_vand_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vand_VV(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vand)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vand(Qu4,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vand_QR(HVX_VectorPred Qu, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vand_QR(Qu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qu),-1),Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32|=vand(Qu4,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vandor_VQR(HVX_Vector Vx, HVX_VectorPred Qu, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vandor_VQR(Vx,Qu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt_acc)(Vx,__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qu),-1),Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vand(Vu32,Rt32) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vand_VR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Q_vand_VR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)(Vu,Rt)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vand(Vu32,Rt32) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vandor_QVR(HVX_VectorPred Qx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Q_vandor_QVR(Qx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt_acc)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Rt)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasl(Vu32.h,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasl_VhR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasl_VhR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaslh)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasl(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasl_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasl_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaslhv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vasl(Vu32.w,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vasl_VwR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vasl_VwR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaslw)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vasl(Vu32.w,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vaslacc_VwVwR(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vaslacc_VwVwR(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaslw_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vasl(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vasl_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vasl_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaslwv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasr(Vu32.h,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasr_VhR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasr_VhR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrh)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vasr(Vu32.h,Vv32.h,Rt8):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vasr_VhVhR_rnd_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vasr_VhVhR_rnd_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrhbrndsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vasr(Vu32.h,Vv32.h,Rt8):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vasr_VhVhR_rnd_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vasr_VhVhR_rnd_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrhubrndsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vasr(Vu32.h,Vv32.h,Rt8):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vasr_VhVhR_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vasr_VhVhR_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrhubsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasr(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasr_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasr_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrhv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vasr(Vu32.w,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vasr_VwR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vasr_VwR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrw)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vasr(Vu32.w,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vasracc_VwVwR(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vasracc_VwVwR(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrw_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasr(Vu32.w,Vv32.w,Rt8) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasr_VwVwR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasr_VwVwR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrwh)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasr(Vu32.w,Vv32.w,Rt8):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasr_VwVwR_rnd_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasr_VwVwR_rnd_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrwhrndsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vasr(Vu32.w,Vv32.w,Rt8):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasr_VwVwR_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasr_VwVwR_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrwhsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vasr(Vu32.w,Vv32.w,Rt8):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vasr_VwVwR_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vasr_VwVwR_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrwuhsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vasr(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vasr_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vasr_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrwv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=Vu32 + C Intrinsic Prototype: HVX_Vector Q6_V_equals_V(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_equals_V(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vassign)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32=Vuu32 + C Intrinsic Prototype: HVX_VectorPair Q6_W_equals_W(HVX_VectorPair Vuu) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_W_equals_W(Vuu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vassignp)(Vuu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vavg(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vavg_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vavg_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vavg(Vu32.h,Vv32.h):rnd + C Intrinsic Prototype: HVX_Vector Q6_Vh_vavg_VhVh_rnd(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vavg_VhVh_rnd(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavghrnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vavg(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vavg_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vavg_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vavg(Vu32.ub,Vv32.ub):rnd + C Intrinsic Prototype: HVX_Vector Q6_Vub_vavg_VubVub_rnd(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vavg_VubVub_rnd(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgubrnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vavg(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vavg_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vavg_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavguh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vavg(Vu32.uh,Vv32.uh):rnd + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vavg_VuhVuh_rnd(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vavg_VuhVuh_rnd(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavguhrnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vavg(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vavg_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vavg_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vavg(Vu32.w,Vv32.w):rnd + C Intrinsic Prototype: HVX_Vector Q6_Vw_vavg_VwVw_rnd(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vavg_VwVw_rnd(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgwrnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vcl0(Vu32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vcl0_Vuh(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vcl0_Vuh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcl0h)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vcl0(Vu32.uw) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vcl0_Vuw(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vcl0_Vuw(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcl0w)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32=vcombine(Vu32,Vv32) + C Intrinsic Prototype: HVX_VectorPair Q6_W_vcombine_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_W_vcombine_VV(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcombine)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=#0 + C Intrinsic Prototype: HVX_Vector Q6_V_vzero() + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vzero() __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vd0)() +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vdeal(Vu32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vdeal_Vb(HVX_Vector Vu) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vdeal_Vb(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdealb)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vdeale(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vdeale_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vdeale_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdealb4w)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vdeal(Vu32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vdeal_Vh(HVX_Vector Vu) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vdeal_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdealh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32=vdeal(Vu32,Vv32,Rt8) + C Intrinsic Prototype: HVX_VectorPair Q6_W_vdeal_VVR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_W_vdeal_VVR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdealvdd)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vdelta(Vu32,Vv32) + C Intrinsic Prototype: HVX_Vector Q6_V_vdelta_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vdelta_VV(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdelta)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vdmpy(Vu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vdmpy_VubRb(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vdmpy_VubRb(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpybus)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.h+=vdmpy(Vu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vdmpyacc_VhVubRb(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vdmpyacc_VhVubRb(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpybus_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vdmpy(Vuu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vdmpy_WubRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vdmpy_WubRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpybus_dv)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vdmpy(Vuu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vdmpyacc_WhWubRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vdmpyacc_WhWubRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpybus_dv_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vdmpy(Vu32.h,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpy_VhRb(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpy_VhRb(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhb)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vdmpy(Vu32.h,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpyacc_VwVhRb(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpyacc_VwVhRb(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhb_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vdmpy(Vuu32.h,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vdmpy_WhRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vdmpy_WhRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhb_dv)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vdmpy(Vuu32.h,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vdmpyacc_WwWhRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vdmpyacc_WwWhRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhb_dv_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vdmpy(Vuu32.h,Rt32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpy_WhRh_sat(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpy_WhRh_sat(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhisat)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vdmpy(Vuu32.h,Rt32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpyacc_VwWhRh_sat(HVX_Vector Vx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpyacc_VwWhRh_sat(Vx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhisat_acc)(Vx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vdmpy(Vu32.h,Rt32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpy_VhRh_sat(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpy_VhRh_sat(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhsat)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vdmpy(Vu32.h,Rt32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpyacc_VwVhRh_sat(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpyacc_VwVhRh_sat(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhsat_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vdmpy(Vuu32.h,Rt32.uh,#1):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpy_WhRuh_sat(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpy_WhRuh_sat(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhsuisat)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vdmpy(Vuu32.h,Rt32.uh,#1):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpyacc_VwWhRuh_sat(HVX_Vector Vx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpyacc_VwWhRuh_sat(Vx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhsuisat_acc)(Vx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vdmpy(Vu32.h,Rt32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpy_VhRuh_sat(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpy_VhRuh_sat(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhsusat)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vdmpy(Vu32.h,Rt32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpyacc_VwVhRuh_sat(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpyacc_VwVhRuh_sat(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhsusat_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vdmpy(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpy_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpy_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhvsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vdmpy(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vdmpyacc_VwVhVh_sat(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vdmpyacc_VwVhVh_sat(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpyhvsat_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vdsad(Vuu32.uh,Rt32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vdsad_WuhRuh(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vdsad_WuhRuh(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdsaduh)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uw+=vdsad(Vuu32.uh,Rt32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vdsadacc_WuwWuhRuh(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vdsadacc_WuwWuhRuh(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdsaduh_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.eq(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eq_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eq_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqb)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.eq(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqand_QVbVb(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqand_QVbVb(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqb_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.eq(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqor_QVbVb(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqor_QVbVb(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqb_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.eq(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqxacc_QVbVb(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqxacc_QVbVb(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqb_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.eq(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eq_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eq_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqh)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.eq(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqand_QVhVh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqand_QVhVh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqh_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.eq(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqor_QVhVh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqor_QVhVh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqh_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.eq(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqxacc_QVhVh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqxacc_QVhVh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqh_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.eq(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eq_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eq_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqw)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.eq(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqand_QVwVw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqand_QVwVw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqw_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.eq(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqor_QVwVw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqor_QVwVw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqw_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.eq(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_eqxacc_QVwVw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_eqxacc_QVwVw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_veqw_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtb)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVbVb(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVbVb(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtb_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVbVb(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVbVb(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtb_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVbVb(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVbVb(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtb_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgth)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVhVh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVhVh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgth_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVhVh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVhVh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgth_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVhVh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVhVh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgth_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtub)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVubVub(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVubVub(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtub_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVubVub(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVubVub(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtub_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVubVub(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVubVub(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtub_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuh)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVuhVuh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVuhVuh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuh_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVuhVuh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVuhVuh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuh_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVuhVuh(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVuhVuh(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuh_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VuwVuw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VuwVuw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuw)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVuwVuw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVuwVuw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuw_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVuwVuw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVuwVuw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuw_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVuwVuw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVuwVuw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtuw_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtw)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVwVw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVwVw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtw_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVwVw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVwVw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtw_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVwVw(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVwVw(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtw_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w=vinsert(Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vinsert_VwR(HVX_Vector Vx, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vinsert_VwR(Vx,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vinsertwr)(Vx,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vlalign(Vu32,Vv32,Rt8) + C Intrinsic Prototype: HVX_Vector Q6_V_vlalign_VVR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vlalign_VVR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlalignb)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vlalign(Vu32,Vv32,#u3) + C Intrinsic Prototype: HVX_Vector Q6_V_vlalign_VVI(HVX_Vector Vu, HVX_Vector Vv, Word32 Iu3) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vlalign_VVI(Vu,Vv,Iu3) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlalignbi)(Vu,Vv,Iu3) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vlsr(Vu32.uh,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vlsr_VuhR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vlsr_VuhR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlsrh)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vlsr(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vlsr_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vlsr_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlsrhv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vlsr(Vu32.uw,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vlsr_VuwR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vlsr_VuwR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlsrw)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vlsr(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vlsr_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vlsr_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlsrwv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vlut32(Vu32.b,Vv32.b,Rt8) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vlut32_VbVbR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vlut32_VbVbR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvvb)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.b|=vlut32(Vu32.b,Vv32.b,Rt8) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vlut32or_VbVbVbR(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vlut32or_VbVbVbR(Vx,Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvvb_oracc)(Vx,Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vlut16(Vu32.b,Vv32.h,Rt8) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vlut16_VbVhR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vlut16_VbVhR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvwh)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h|=vlut16(Vu32.b,Vv32.h,Rt8) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vlut16or_WhVbVhR(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vlut16or_WhVbVhR(Vxx,Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvwh_oracc)(Vxx,Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmax(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmax_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vmax_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaxh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vmax(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vmax_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vmax_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaxub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vmax(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vmax_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vmax_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaxuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmax(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmax_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vmax_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaxw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmin(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmin_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vmin_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vminh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vmin(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vmin_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vmin_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vminub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vmin(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vmin_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vmin_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vminuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmin(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmin_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vmin_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vminw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpa(Vuu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpa_WubRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpa_WubRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpabus)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vmpa(Vuu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpaacc_WhWubRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpaacc_WhWubRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpabus_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpa(Vuu32.ub,Vvv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpa_WubWb(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpa_WubWb(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpabusv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpa(Vuu32.ub,Vvv32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpa_WubWub(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpa_WubWub(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpabuuv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vmpa(Vuu32.h,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpa_WhRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpa_WhRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpahb)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vmpa(Vuu32.h,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpaacc_WwWhRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpaacc_WwWhRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpahb_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpy(Vu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpy_VubRb(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpy_VubRb(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpybus)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vmpy(Vu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpyacc_WhVubRb(HVX_VectorPair Vxx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpyacc_WhVubRb(Vxx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpybus_acc)(Vxx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpy(Vu32.ub,Vv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpy_VubVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpy_VubVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpybusv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vmpy(Vu32.ub,Vv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpyacc_WhVubVb(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpyacc_WhVubVb(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpybusv_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpy(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpy_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpy_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpybv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vmpy(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpyacc_WhVbVb(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpyacc_WhVbVb(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpybv_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpye(Vu32.w,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpye_VwVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpye_VwVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyewuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vmpy(Vu32.h,Rt32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpy_VhRh(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpy_VhRh(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyh)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vmpy(Vu32.h,Rt32.h):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpyacc_WwVhRh_sat(HVX_VectorPair Vxx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpyacc_WwVhRh_sat(Vxx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhsat_acc)(Vxx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmpy(Vu32.h,Rt32.h):<<1:rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpy_VhRh_s1_rnd_sat(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpy_VhRh_s1_rnd_sat(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhsrs)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmpy(Vu32.h,Rt32.h):<<1:sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpy_VhRh_s1_sat(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpy_VhRh_s1_sat(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhss)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vmpy(Vu32.h,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpy_VhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpy_VhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhus)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vmpy(Vu32.h,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpyacc_WwVhVuh(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpyacc_WwVhVuh(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhus_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vmpy(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpy_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpy_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vmpy(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpyacc_WwVhVh(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpyacc_WwVhVh(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhv_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmpy(Vu32.h,Vv32.h):<<1:rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpy_VhVh_s1_rnd_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpy_VhVh_s1_rnd_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyhvsrs)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyieo(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyieo_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyieo_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyieoh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyie(Vu32.w,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyieacc_VwVwVh(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyieacc_VwVwVh(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiewh_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyie(Vu32.w,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyie_VwVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyie_VwVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiewuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyie(Vu32.w,Vv32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyieacc_VwVwVuh(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyieacc_VwVwVuh(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiewuh_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmpyi(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpyi_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpyi_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyih)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.h+=vmpyi(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpyiacc_VhVhVh(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpyiacc_VhVhVh(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyih_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vmpyi(Vu32.h,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpyi_VhRb(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpyi_VhRb(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyihb)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.h+=vmpyi(Vu32.h,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpyiacc_VhVhRb(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vmpyiacc_VhVhRb(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyihb_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyio(Vu32.w,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyio_VwVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyio_VwVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiowh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyi(Vu32.w,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyi_VwRb(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyi_VwRb(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiwb)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyi(Vu32.w,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyiacc_VwVwRb(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyiacc_VwVwRb(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiwb_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyi(Vu32.w,Rt32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyi_VwRh(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyi_VwRh(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiwh)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyi(Vu32.w,Rt32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyiacc_VwVwRh(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyiacc_VwVwRh(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiwh_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyo(Vu32.w,Vv32.h):<<1:sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyo_VwVh_s1_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyo_VwVh_s1_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyowh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyo(Vu32.w,Vv32.h):<<1:rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyo_VwVh_s1_rnd_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyo_VwVh_s1_rnd_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyowh_rnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyo(Vu32.w,Vv32.h):<<1:rnd:sat:shift + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyoacc_VwVwVh_s1_rnd_sat_shift(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyoacc_VwVwVh_s1_rnd_sat_shift(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyowh_rnd_sacc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyo(Vu32.w,Vv32.h):<<1:sat:shift + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyoacc_VwVwVh_s1_sat_shift(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyoacc_VwVwVh_s1_sat_shift(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyowh_sacc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uh=vmpy(Vu32.ub,Rt32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vmpy_VubRub(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuh_vmpy_VubRub(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyub)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uh+=vmpy(Vu32.ub,Rt32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vmpyacc_WuhVubRub(HVX_VectorPair Vxx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuh_vmpyacc_WuhVubRub(Vxx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyub_acc)(Vxx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uh=vmpy(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vmpy_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuh_vmpy_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyubv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uh+=vmpy(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vmpyacc_WuhVubVub(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuh_vmpyacc_WuhVubVub(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyubv_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vmpy(Vu32.uh,Rt32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vmpy_VuhRuh(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vmpy_VuhRuh(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuh)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uw+=vmpy(Vu32.uh,Rt32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vmpyacc_WuwVuhRuh(HVX_VectorPair Vxx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vmpyacc_WuwVuhRuh(Vxx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuh_acc)(Vxx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vmpy(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vmpy_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vmpy_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuhv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uw+=vmpy(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vmpyacc_WuwVuhVuh(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vmpyacc_WuwVuhVuh(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuhv_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vmux(Qt4,Vu32,Vv32) + C Intrinsic Prototype: HVX_Vector Q6_V_vmux_QVV(HVX_VectorPred Qt, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vmux_QVV(Qt,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmux)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1),Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vnavg(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vnavg_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vnavg_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnavgh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vnavg(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vnavg_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vnavg_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnavgub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vnavg(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vnavg_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vnavg_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnavgw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vnormamt(Vu32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vnormamt_Vh(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vnormamt_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnormamth)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vnormamt(Vu32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vnormamt_Vw(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vnormamt_Vw(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnormamtw)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vnot(Vu32) + C Intrinsic Prototype: HVX_Vector Q6_V_vnot_V(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vnot_V(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnot)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vor(Vu32,Vv32) + C Intrinsic Prototype: HVX_Vector Q6_V_vor_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vor_VV(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vor)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vpacke(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vpacke_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vpacke_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackeb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vpacke(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vpacke_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vpacke_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackeh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vpack(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vpack_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vpack_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackhb_sat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vpack(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vpack_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vpack_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackhub_sat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vpacko(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vpacko_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vpacko_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackob)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vpacko(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vpacko_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vpacko_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackoh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vpack(Vu32.w,Vv32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vpack_VwVw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vpack_VwVw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackwh_sat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vpack(Vu32.w,Vv32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vpack_VwVw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vpack_VwVw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpackwuh_sat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vpopcount(Vu32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vpopcount_Vh(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vpopcount_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vpopcounth)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vrdelta(Vu32,Vv32) + C Intrinsic Prototype: HVX_Vector Q6_V_vrdelta_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vrdelta_VV(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrdelta)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vrmpy(Vu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vrmpy_VubRb(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vrmpy_VubRb(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybus)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vrmpy(Vu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vrmpyacc_VwVubRb(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vrmpyacc_VwVubRb(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybus_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vrmpy(Vuu32.ub,Rt32.b,#u1) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vrmpy_WubRbI(HVX_VectorPair Vuu, Word32 Rt, Word32 Iu1) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vrmpy_WubRbI(Vuu,Rt,Iu1) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybusi)(Vuu,Rt,Iu1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vrmpy(Vuu32.ub,Rt32.b,#u1) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vrmpyacc_WwWubRbI(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt, Word32 Iu1) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vrmpyacc_WwWubRbI(Vxx,Vuu,Rt,Iu1) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybusi_acc)(Vxx,Vuu,Rt,Iu1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vrmpy(Vu32.ub,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vrmpy_VubVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vrmpy_VubVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybusv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vrmpy(Vu32.ub,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vrmpyacc_VwVubVb(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vrmpyacc_VwVubVb(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybusv_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vrmpy(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vrmpy_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vrmpy_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vrmpy(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vrmpyacc_VwVbVb(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vrmpyacc_VwVbVb(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpybv_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vrmpy(Vu32.ub,Rt32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vrmpy_VubRub(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vrmpy_VubRub(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpyub)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.uw+=vrmpy(Vu32.ub,Rt32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vrmpyacc_VuwVubRub(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vrmpyacc_VuwVubRub(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpyub_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vrmpy(Vuu32.ub,Rt32.ub,#u1) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vrmpy_WubRubI(HVX_VectorPair Vuu, Word32 Rt, Word32 Iu1) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vrmpy_WubRubI(Vuu,Rt,Iu1) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpyubi)(Vuu,Rt,Iu1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uw+=vrmpy(Vuu32.ub,Rt32.ub,#u1) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vrmpyacc_WuwWubRubI(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt, Word32 Iu1) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vrmpyacc_WuwWubRubI(Vxx,Vuu,Rt,Iu1) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpyubi_acc)(Vxx,Vuu,Rt,Iu1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vrmpy(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vrmpy_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vrmpy_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpyubv)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vx32.uw+=vrmpy(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vrmpyacc_VuwVubVub(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vrmpyacc_VuwVubVub(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrmpyubv_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vror(Vu32,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vror_VR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vror_VR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vror)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vround(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vround_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vround_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vroundhb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vround(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vround_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vround_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vroundhub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vround(Vu32.w,Vv32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vround_VwVw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vround_VwVw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vroundwh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vround(Vu32.w,Vv32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vround_VwVw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vround_VwVw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vroundwuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vrsad(Vuu32.ub,Rt32.ub,#u1) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vrsad_WubRubI(HVX_VectorPair Vuu, Word32 Rt, Word32 Iu1) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vrsad_WubRubI(Vuu,Rt,Iu1) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrsadubi)(Vuu,Rt,Iu1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.uw+=vrsad(Vuu32.ub,Rt32.ub,#u1) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vrsadacc_WuwWubRubI(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt, Word32 Iu1) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wuw_vrsadacc_WuwWubRubI(Vxx,Vuu,Rt,Iu1) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrsadubi_acc)(Vxx,Vuu,Rt,Iu1) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vsat(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vsat_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vsat_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsathub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vsat(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vsat_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vsat_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsatwh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vsxt(Vu32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vsxt_Vb(HVX_Vector Vu) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vsxt_Vb(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsb)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vsxt(Vu32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vsxt_Vh(HVX_Vector Vu) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vsxt_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vshuffe(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vshuffe_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vshuffe_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshufeh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vshuff(Vu32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vshuff_Vb(HVX_Vector Vu) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vshuff_Vb(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshuffb)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vshuffe(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vshuffe_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vshuffe_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshuffeb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vshuff(Vu32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vshuff_Vh(HVX_Vector Vu) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vshuff_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshuffh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vshuffo(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vshuffo_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vshuffo_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshuffob)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32=vshuff(Vu32,Vv32,Rt8) + C Intrinsic Prototype: HVX_VectorPair Q6_W_vshuff_VVR(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_W_vshuff_VVR(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshuffvdd)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.b=vshuffoe(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wb_vshuffoe_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wb_vshuffoe_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshufoeb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vshuffoe(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vshuffoe_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vshuffoe_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshufoeh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vshuffo(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vshuffo_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vshuffo_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vshufoh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.b=vsub(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vsub_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vsub_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.b=vsub(Vuu32.b,Vvv32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wb_vsub_WbWb(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wb_vsub_WbWb(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubb_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) Vx32.b-=Vu32.b + C Intrinsic Prototype: HVX_Vector Q6_Vb_condnac_QnVbVb(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_condnac_QnVbVb(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubbnq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) Vx32.b-=Vu32.b + C Intrinsic Prototype: HVX_Vector Q6_Vb_condnac_QVbVb(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_condnac_QVbVb(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubbq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vsub(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vsub_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vsub_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vsub(Vuu32.h,Vvv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vsub_WhWh(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vsub_WhWh(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubh_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) Vx32.h-=Vu32.h + C Intrinsic Prototype: HVX_Vector Q6_Vh_condnac_QnVhVh(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_condnac_QnVhVh(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubhnq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) Vx32.h-=Vu32.h + C Intrinsic Prototype: HVX_Vector Q6_Vh_condnac_QVhVh(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_condnac_QVhVh(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubhq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.h=vsub(Vu32.h,Vv32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vsub_VhVh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vsub_VhVh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubhsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vsub(Vuu32.h,Vvv32.h):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vsub_WhWh_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vsub_WhWh_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubhsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vsub(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vsub_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vsub_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubhw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vsub(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vsub_VubVub(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vsub_VubVub(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsububh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vsub(Vu32.ub,Vv32.ub):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vsub_VubVub_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vsub_VubVub_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsububsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.ub=vsub(Vuu32.ub,Vvv32.ub):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wub_vsub_WubWub_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wub_vsub_WubWub_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsububsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vsub(Vu32.uh,Vv32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vsub_VuhVuh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vsub_VuhVuh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubuhsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uh=vsub(Vuu32.uh,Vvv32.uh):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vsub_WuhWuh_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuh_vsub_WuhWuh_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubuhsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vsub(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vsub_VuhVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vsub_VuhVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubuhw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vsub(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vsub_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vsub_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vsub(Vuu32.w,Vvv32.w) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vsub_WwWw(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vsub_WwWw(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubw_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (!Qv4) Vx32.w-=Vu32.w + C Intrinsic Prototype: HVX_Vector Q6_Vw_condnac_QnVwVw(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_condnac_QnVwVw(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubwnq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: if (Qv4) Vx32.w-=Vu32.w + C Intrinsic Prototype: HVX_Vector Q6_Vw_condnac_QVwVw(HVX_VectorPred Qv, HVX_Vector Vx, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_condnac_QVwVw(Qv,Vx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubwq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32.w=vsub(Vu32.w,Vv32.w):sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vsub_VwVw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vsub_VwVw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubwsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vsub(Vuu32.w,Vvv32.w):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vsub_WwWw_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vsub_WwWw_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubwsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32=vswap(Qt4,Vu32,Vv32) + C Intrinsic Prototype: HVX_VectorPair Q6_W_vswap_QVV(HVX_VectorPred Qt, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_W_vswap_QVV(Qt,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vswap)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1),Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vtmpy(Vuu32.b,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vtmpy_WbRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vtmpy_WbRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vtmpyb)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vtmpy(Vuu32.b,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vtmpyacc_WhWbRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vtmpyacc_WhWbRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vtmpyb_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vtmpy(Vuu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vtmpy_WubRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vtmpy_WubRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vtmpybus)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vtmpy(Vuu32.ub,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vtmpyacc_WhWubRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vtmpyacc_WhWubRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vtmpybus_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vtmpy(Vuu32.h,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vtmpy_WhRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vtmpy_WhRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vtmpyhb)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vtmpy(Vuu32.h,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vtmpyacc_WwWhRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vtmpyacc_WwWhRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vtmpyhb_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vunpack(Vu32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vunpack_Vb(HVX_Vector Vu) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vunpack_Vb(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vunpackb)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vunpack(Vu32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vunpack_Vh(HVX_Vector Vu) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vunpack_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vunpackh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.h|=vunpacko(Vu32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vunpackoor_WhVb(HVX_VectorPair Vxx, HVX_Vector Vu) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vunpackoor_WhVb(Vxx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vunpackob)(Vxx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vxx32.w|=vunpacko(Vu32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vunpackoor_WwVh(HVX_VectorPair Vxx, HVX_Vector Vu) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vunpackoor_WwVh(Vxx,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vunpackoh)(Vxx,Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uh=vunpack(Vu32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vunpack_Vub(HVX_Vector Vu) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuh_vunpack_Vub(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vunpackub)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vunpack(Vu32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vunpack_Vuh(HVX_Vector Vu) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuw_vunpack_Vuh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vunpackuh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vd32=vxor(Vu32,Vv32) + C Intrinsic Prototype: HVX_Vector Q6_V_vxor_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vxor_VV(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vxor)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uh=vzxt(Vu32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuh_vzxt_Vub(HVX_Vector Vu) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuh_vzxt_Vub(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vzb)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 60 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vzxt(Vu32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vzxt_Vuh(HVX_Vector Vu) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuw_vzxt_Vuh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vzh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 60 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vsplat(Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vsplat_R(Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vb_vsplat_R(Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_lvsplatb)(Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.h=vsplat(Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vsplat_R(Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vsplat_R(Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_lvsplath)(Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Qd4=vsetq2(Rt32) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vsetq2_R(Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vsetq2_R(Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_pred_scalar2v2)(Rt)),-1) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Qd4.b=vshuffe(Qs4.h,Qt4.h) + C Intrinsic Prototype: HVX_VectorPred Q6_Qb_vshuffe_QhQh(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Qb_vshuffe_QhQh(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_shuffeqh)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Qd4.h=vshuffe(Qs4.w,Qt4.w) + C Intrinsic Prototype: HVX_VectorPred Q6_Qh_vshuffe_QwQw(HVX_VectorPred Qs, HVX_VectorPred Qt) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Qh_vshuffe_QwQw(Qs,Qt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_shuffeqw)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qt),-1))),-1) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vadd(Vu32.b,Vv32.b):sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vadd_VbVb_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vadd_VbVb_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddbsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.b=vadd(Vuu32.b,Vvv32.b):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wb_vadd_WbWb_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wb_vadd_WbWb_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddbsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.w=vadd(Vu32.w,Vv32.w,Qx4):carry + C Intrinsic Prototype: HVX_Vector Q6_Vw_vadd_VwVwQ_carry(HVX_Vector Vu, HVX_Vector Vv, HVX_VectorPred* Qx) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vadd_VwVwQ_carry(Vu,Vv,Qx) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddcarry)(Vu,Vv,Qx) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.h=vadd(vclb(Vu32.h),Vv32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vadd_vclb_VhVh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vadd_vclb_VhVh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddclbh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.w=vadd(vclb(Vu32.w),Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vadd_vclb_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vadd_vclb_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddclbw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vadd(Vu32.h,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vaddacc_WwVhVh(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vaddacc_WwVhVh(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddhw_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vadd(Vu32.ub,Vv32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vaddacc_WhVubVub(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vaddacc_WhVubVub(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddubh_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vadd(Vu32.ub,Vv32.b):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vadd_VubVb_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vadd_VubVb_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddububb_sat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vadd(Vu32.uh,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vaddacc_WwVuhVuh(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vaddacc_WwVuhVuh(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadduhw_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vadd(Vu32.uw,Vv32.uw):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vadd_VuwVuw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vadd_VuwVuw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadduwsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vadd(Vuu32.uw,Vvv32.uw):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vadd_WuwWuw_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuw_vadd_WuwWuw_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadduwsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32=vand(!Qu4,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vand_QnR(HVX_VectorPred Qu, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vand_QnR(Qu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandnqrt)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qu),-1),Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vx32|=vand(!Qu4,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vandor_VQnR(HVX_Vector Vx, HVX_VectorPred Qu, Word32 Rt) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vandor_VQnR(Vx,Qu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandnqrt_acc)(Vx,__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qu),-1),Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32=vand(!Qv4,Vu32) + C Intrinsic Prototype: HVX_Vector Q6_V_vand_QnV(HVX_VectorPred Qv, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vand_QnV(Qv,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvnqv)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vu) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32=vand(Qv4,Vu32) + C Intrinsic Prototype: HVX_Vector Q6_V_vand_QV(HVX_VectorPred Qv, HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vand_QV(Qv,Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvqv)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1),Vu) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vasr(Vu32.h,Vv32.h,Rt8):sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vasr_VhVhR_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vasr_VhVhR_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrhbsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vasr(Vu32.uw,Vv32.uw,Rt8):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vasr_VuwVuwR_rnd_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vasr_VuwVuwR_rnd_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasruwuhrndsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vasr(Vu32.w,Vv32.w,Rt8):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vasr_VwVwR_rnd_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vasr_VwVwR_rnd_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrwuhrndsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vlsr(Vu32.ub,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vlsr_VubR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vlsr_VubR(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlsrb)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vlut32(Vu32.b,Vv32.b,Rt8):nomatch + C Intrinsic Prototype: HVX_Vector Q6_Vb_vlut32_VbVbR_nomatch(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vlut32_VbVbR_nomatch(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvvb_nm)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vx32.b|=vlut32(Vu32.b,Vv32.b,#u3) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vlut32or_VbVbVbI(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv, Word32 Iu3) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vlut32or_VbVbVbI(Vx,Vu,Vv,Iu3) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvvb_oracci)(Vx,Vu,Vv,Iu3) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vlut32(Vu32.b,Vv32.b,#u3) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vlut32_VbVbI(HVX_Vector Vu, HVX_Vector Vv, Word32 Iu3) + Instruction Type: CVI_VP + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vlut32_VbVbI(Vu,Vv,Iu3) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvvbi)(Vu,Vv,Iu3) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vlut16(Vu32.b,Vv32.h,Rt8):nomatch + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vlut16_VbVhR_nomatch(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vlut16_VbVhR_nomatch(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvwh_nm)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vxx32.h|=vlut16(Vu32.b,Vv32.h,#u3) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vlut16or_WhVbVhI(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv, Word32 Iu3) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vlut16or_WhVbVhI(Vxx,Vu,Vv,Iu3) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvwh_oracci)(Vxx,Vu,Vv,Iu3) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vlut16(Vu32.b,Vv32.h,#u3) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vlut16_VbVhI(HVX_Vector Vu, HVX_Vector Vv, Word32 Iu3) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wh_vlut16_VbVhI(Vu,Vv,Iu3) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlutvwhi)(Vu,Vv,Iu3) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vmax(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vmax_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vmax_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmaxb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vmin(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vmin_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vmin_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vminb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.w=vmpa(Vuu32.uh,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpa_WuhRb(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpa_WuhRb(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpauhb)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vmpa(Vuu32.uh,Rt32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpaacc_WwWuhRb(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpaacc_WwWuhRb(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpauhb_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32=vmpye(Vu32.w,Vv32.uh) + C Intrinsic Prototype: HVX_VectorPair Q6_W_vmpye_VwVuh(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_W_vmpye_VwVuh(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyewuh_64)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.w=vmpyi(Vu32.w,Rt32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyi_VwRub(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyi_VwRub(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiwub)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vx32.w+=vmpyi(Vu32.w,Rt32.ub) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vmpyiacc_VwVwRub(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vmpyiacc_VwVwRub(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyiwub_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vxx32+=vmpyo(Vu32.w,Vv32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_W_vmpyoacc_WVwVh(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_W_vmpyoacc_WVwVh(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyowh_64_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vround(Vu32.uh,Vv32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vround_VuhVuh_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vround_VuhVuh_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrounduhub)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vround(Vu32.uw,Vv32.uw):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vround_VuwVuw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vround_VuwVuw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrounduwuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vsat(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vsat_VuwVuw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vsat_VuwVuw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsatuwuh)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.b=vsub(Vu32.b,Vv32.b):sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vsub_VbVb_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vsub_VbVb_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubbsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.b=vsub(Vuu32.b,Vvv32.b):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wb_vsub_WbWb_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wb_vsub_WbWb_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubbsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.w=vsub(Vu32.w,Vv32.w,Qx4):carry + C Intrinsic Prototype: HVX_Vector Q6_Vw_vsub_VwVwQ_carry(HVX_Vector Vu, HVX_Vector Vv, HVX_VectorPred* Qx) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vsub_VwVwQ_carry(Vu,Vv,Qx) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubcarry)(Vu,Vv,Qx) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vsub(Vu32.ub,Vv32.b):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vsub_VubVb_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vsub_VubVb_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubububb_sat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vsub(Vu32.uw,Vv32.uw):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vsub_VuwVuw_sat(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vsub_VuwVuw_sat(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubuwsat)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 62 +/* ========================================================================== + Assembly Syntax: Vdd32.uw=vsub(Vuu32.uw,Vvv32.uw):sat + C Intrinsic Prototype: HVX_VectorPair Q6_Wuw_vsub_WuwWuw_sat(HVX_VectorPair Vuu, HVX_VectorPair Vvv) + Instruction Type: CVI_VA_DV + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Wuw_vsub_WuwWuw_sat(Vuu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsubuwsat_dv)(Vuu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 62 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.b=vabs(Vu32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vabs_Vb(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vabs_Vb(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsb)(Vu) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.b=vabs(Vu32.b):sat + C Intrinsic Prototype: HVX_Vector Q6_Vb_vabs_Vb_sat(HVX_Vector Vu) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vabs_Vb_sat(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabsb_sat)(Vu) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vx32.h+=vasl(Vu32.h,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vaslacc_VhVhR(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vaslacc_VhVhR(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaslh_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vx32.h+=vasr(Vu32.h,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vasracc_VhVhR(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_vasracc_VhVhR(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrh_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vasr(Vu32.uh,Vv32.uh,Rt8):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vasr_VuhVuhR_rnd_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vasr_VuhVuhR_rnd_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasruhubrndsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vasr(Vu32.uh,Vv32.uh,Rt8):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vasr_VuhVuhR_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vasr_VuhVuhR_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasruhubsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vasr(Vu32.uw,Vv32.uw,Rt8):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vasr_VuwVuwR_sat(HVX_Vector Vu, HVX_Vector Vv, Word32 Rt) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vasr_VuwVuwR_sat(Vu,Vv,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasruwuhsat)(Vu,Vv,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.b=vavg(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vavg_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vavg_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.b=vavg(Vu32.b,Vv32.b):rnd + C Intrinsic Prototype: HVX_Vector Q6_Vb_vavg_VbVb_rnd(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vavg_VbVb_rnd(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavgbrnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vavg(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vavg_VuwVuw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vavg_VuwVuw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavguw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vavg(Vu32.uw,Vv32.uw):rnd + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vavg_VuwVuw_rnd(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vavg_VuwVuw_rnd(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vavguwrnd)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vdd32=#0 + C Intrinsic Prototype: HVX_VectorPair Q6_W_vzero() + Instruction Type: MAPPING + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_W_vzero() __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdd0)() +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vtmp.h=vgather(Rt32,Mu2,Vv32.h).h + C Intrinsic Prototype: void Q6_vgather_ARMVh(HVX_Vector* Rs, Word32 Rt, Word32 Mu, HVX_Vector Vv) + Instruction Type: CVI_GATHER + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_vgather_ARMVh(Rs,Rt,Mu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgathermh)(Rs,Rt,Mu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: if (Qs4) vtmp.h=vgather(Rt32,Mu2,Vv32.h).h + C Intrinsic Prototype: void Q6_vgather_AQRMVh(HVX_Vector* Rs, HVX_VectorPred Qs, Word32 Rt, Word32 Mu, HVX_Vector Vv) + Instruction Type: CVI_GATHER + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_vgather_AQRMVh(Rs,Qs,Rt,Mu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgathermhq)(Rs,__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),Rt,Mu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vtmp.h=vgather(Rt32,Mu2,Vvv32.w).h + C Intrinsic Prototype: void Q6_vgather_ARMWw(HVX_Vector* Rs, Word32 Rt, Word32 Mu, HVX_VectorPair Vvv) + Instruction Type: CVI_GATHER_DV + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_vgather_ARMWw(Rs,Rt,Mu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgathermhw)(Rs,Rt,Mu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: if (Qs4) vtmp.h=vgather(Rt32,Mu2,Vvv32.w).h + C Intrinsic Prototype: void Q6_vgather_AQRMWw(HVX_Vector* Rs, HVX_VectorPred Qs, Word32 Rt, Word32 Mu, HVX_VectorPair Vvv) + Instruction Type: CVI_GATHER_DV + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_vgather_AQRMWw(Rs,Qs,Rt,Mu,Vvv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgathermhwq)(Rs,__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),Rt,Mu,Vvv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vtmp.w=vgather(Rt32,Mu2,Vv32.w).w + C Intrinsic Prototype: void Q6_vgather_ARMVw(HVX_Vector* Rs, Word32 Rt, Word32 Mu, HVX_Vector Vv) + Instruction Type: CVI_GATHER + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_vgather_ARMVw(Rs,Rt,Mu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgathermw)(Rs,Rt,Mu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: if (Qs4) vtmp.w=vgather(Rt32,Mu2,Vv32.w).w + C Intrinsic Prototype: void Q6_vgather_AQRMVw(HVX_Vector* Rs, HVX_VectorPred Qs, Word32 Rt, Word32 Mu, HVX_Vector Vv) + Instruction Type: CVI_GATHER + Execution Slots: SLOT01 + ========================================================================== */ + +#define Q6_vgather_AQRMVw(Rs,Qs,Rt,Mu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgathermwq)(Rs,__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),Rt,Mu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.h=vlut4(Vu32.uh,Rtt32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vlut4_VuhPh(HVX_Vector Vu, Word64 Rtt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT2 + ========================================================================== */ + +#define Q6_Vh_vlut4_VuhPh(Vu,Rtt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vlut4)(Vu,Rtt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vdd32.h=vmpa(Vuu32.ub,Rt32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpa_WubRub(HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpa_WubRub(Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpabuu)(Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vxx32.h+=vmpa(Vuu32.ub,Rt32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Wh_vmpaacc_WhWubRub(HVX_VectorPair Vxx, HVX_VectorPair Vuu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wh_vmpaacc_WhWubRub(Vxx,Vuu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpabuu_acc)(Vxx,Vuu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vx32.h=vmpa(Vx32.h,Vu32.h,Rtt32.h):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpa_VhVhVhPh_sat(HVX_Vector Vx, HVX_Vector Vu, Word64 Rtt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT2 + ========================================================================== */ + +#define Q6_Vh_vmpa_VhVhVhPh_sat(Vx,Vu,Rtt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpahhsat)(Vx,Vu,Rtt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vx32.h=vmpa(Vx32.h,Vu32.uh,Rtt32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmpa_VhVhVuhPuh_sat(HVX_Vector Vx, HVX_Vector Vu, Word64 Rtt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT2 + ========================================================================== */ + +#define Q6_Vh_vmpa_VhVhVuhPuh_sat(Vx,Vu,Rtt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpauhuhsat)(Vx,Vu,Rtt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vx32.h=vmps(Vx32.h,Vu32.uh,Rtt32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vh_vmps_VhVhVuhPuh_sat(HVX_Vector Vx, HVX_Vector Vu, Word64 Rtt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT2 + ========================================================================== */ + +#define Q6_Vh_vmps_VhVhVuhPuh_sat(Vx,Vu,Rtt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpsuhuhsat)(Vx,Vu,Rtt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=vmpy(Vu32.h,Rt32.h) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vmpyacc_WwVhRh(HVX_VectorPair Vxx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_vmpyacc_WwVhRh(Vxx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyh_acc)(Vxx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vmpye(Vu32.uh,Rt32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vmpye_VuhRuh(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vmpye_VuhRuh(Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuhe)(Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vx32.uw+=vmpye(Vu32.uh,Rt32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vmpyeacc_VuwVuhRuh(HVX_Vector Vx, HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuw_vmpyeacc_VuwVuhRuh(Vx,Vu,Rt) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuhe_acc)(Vx,Vu,Rt) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.b=vnavg(Vu32.b,Vv32.b) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vnavg_VbVb(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_vnavg_VbVb(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vnavgb)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.b=prefixsum(Qv4) + C Intrinsic Prototype: HVX_Vector Q6_Vb_prefixsum_Q(HVX_VectorPred Qv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vb_prefixsum_Q(Qv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vprefixqb)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1)) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.h=prefixsum(Qv4) + C Intrinsic Prototype: HVX_Vector Q6_Vh_prefixsum_Q(HVX_VectorPred Qv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_prefixsum_Q(Qv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vprefixqh)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1)) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: Vd32.w=prefixsum(Qv4) + C Intrinsic Prototype: HVX_Vector Q6_Vw_prefixsum_Q(HVX_VectorPred Qv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_prefixsum_Q(Qv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vprefixqw)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qv),-1)) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vscatter(Rt32,Mu2,Vv32.h).h=Vw32 + C Intrinsic Prototype: void Q6_vscatter_RMVhV(Word32 Rt, Word32 Mu, HVX_Vector Vv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatter_RMVhV(Rt,Mu,Vv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermh)(Rt,Mu,Vv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vscatter(Rt32,Mu2,Vv32.h).h+=Vw32 + C Intrinsic Prototype: void Q6_vscatteracc_RMVhV(Word32 Rt, Word32 Mu, HVX_Vector Vv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatteracc_RMVhV(Rt,Mu,Vv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermh_add)(Rt,Mu,Vv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: if (Qs4) vscatter(Rt32,Mu2,Vv32.h).h=Vw32 + C Intrinsic Prototype: void Q6_vscatter_QRMVhV(HVX_VectorPred Qs, Word32 Rt, Word32 Mu, HVX_Vector Vv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatter_QRMVhV(Qs,Rt,Mu,Vv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermhq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),Rt,Mu,Vv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vscatter(Rt32,Mu2,Vvv32.w).h=Vw32 + C Intrinsic Prototype: void Q6_vscatter_RMWwV(Word32 Rt, Word32 Mu, HVX_VectorPair Vvv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER_DV + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatter_RMWwV(Rt,Mu,Vvv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermhw)(Rt,Mu,Vvv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vscatter(Rt32,Mu2,Vvv32.w).h+=Vw32 + C Intrinsic Prototype: void Q6_vscatteracc_RMWwV(Word32 Rt, Word32 Mu, HVX_VectorPair Vvv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER_DV + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatteracc_RMWwV(Rt,Mu,Vvv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermhw_add)(Rt,Mu,Vvv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: if (Qs4) vscatter(Rt32,Mu2,Vvv32.w).h=Vw32 + C Intrinsic Prototype: void Q6_vscatter_QRMWwV(HVX_VectorPred Qs, Word32 Rt, Word32 Mu, HVX_VectorPair Vvv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER_DV + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatter_QRMWwV(Qs,Rt,Mu,Vvv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermhwq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),Rt,Mu,Vvv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vscatter(Rt32,Mu2,Vv32.w).w=Vw32 + C Intrinsic Prototype: void Q6_vscatter_RMVwV(Word32 Rt, Word32 Mu, HVX_Vector Vv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatter_RMVwV(Rt,Mu,Vv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermw)(Rt,Mu,Vv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: vscatter(Rt32,Mu2,Vv32.w).w+=Vw32 + C Intrinsic Prototype: void Q6_vscatteracc_RMVwV(Word32 Rt, Word32 Mu, HVX_Vector Vv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatteracc_RMVwV(Rt,Mu,Vv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermw_add)(Rt,Mu,Vv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 65 +/* ========================================================================== + Assembly Syntax: if (Qs4) vscatter(Rt32,Mu2,Vv32.w).w=Vw32 + C Intrinsic Prototype: void Q6_vscatter_QRMVwV(HVX_VectorPred Qs, Word32 Rt, Word32 Mu, HVX_Vector Vv, HVX_Vector Vw) + Instruction Type: CVI_SCATTER + Execution Slots: SLOT0 + ========================================================================== */ + +#define Q6_vscatter_QRMVwV(Qs,Rt,Mu,Vv,Vw) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vscattermwq)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1),Rt,Mu,Vv,Vw) +#endif /* __HEXAGON_ARCH___ >= 65 */ + +#if __HVX_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Vd32.w=vadd(Vu32.w,Vv32.w,Qs4):carry:sat + C Intrinsic Prototype: HVX_Vector Q6_Vw_vadd_VwVwQ_carry_sat(HVX_Vector Vu, HVX_Vector Vv, HVX_VectorPred Qs) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vadd_VwVwQ_carry_sat(Vu,Vv,Qs) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vaddcarrysat)(Vu,Vv,__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qs),-1)) +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HVX_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Vxx32.w=vasrinto(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_vasrinto_WwVwVw(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VP_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Ww_vasrinto_WwVwVw(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasr_into)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HVX_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Vd32.uw=vrotr(Vu32.uw,Vv32.uw) + C Intrinsic Prototype: HVX_Vector Q6_Vuw_vrotr_VuwVuw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuw_vrotr_VuwVuw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vrotr)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HVX_ARCH__ >= 66 +/* ========================================================================== + Assembly Syntax: Vd32.w=vsatdw(Vu32.w,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vsatdw_VwVw(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_vsatdw_VwVw(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsatdw)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 66 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.w=v6mpy(Vuu32.ub,Vvv32.b,#u2):h + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_v6mpy_WubWbI_h(HVX_VectorPair Vuu, HVX_VectorPair Vvv, Word32 Iu2) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_v6mpy_WubWbI_h(Vuu,Vvv,Iu2) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_v6mpyhubs10)(Vuu,Vvv,Iu2) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=v6mpy(Vuu32.ub,Vvv32.b,#u2):h + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_v6mpyacc_WwWubWbI_h(HVX_VectorPair Vxx, HVX_VectorPair Vuu, HVX_VectorPair Vvv, Word32 Iu2) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_v6mpyacc_WwWubWbI_h(Vxx,Vuu,Vvv,Iu2) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_v6mpyhubs10_vxx)(Vxx,Vuu,Vvv,Iu2) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.w=v6mpy(Vuu32.ub,Vvv32.b,#u2):v + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_v6mpy_WubWbI_v(HVX_VectorPair Vuu, HVX_VectorPair Vvv, Word32 Iu2) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_v6mpy_WubWbI_v(Vuu,Vvv,Iu2) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_v6mpyvubs10)(Vuu,Vvv,Iu2) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vxx32.w+=v6mpy(Vuu32.ub,Vvv32.b,#u2):v + C Intrinsic Prototype: HVX_VectorPair Q6_Ww_v6mpyacc_WwWubWbI_v(HVX_VectorPair Vxx, HVX_VectorPair Vuu, HVX_VectorPair Vvv, Word32 Iu2) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Ww_v6mpyacc_WwWubWbI_v(Vxx,Vuu,Vvv,Iu2) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_v6mpyvubs10_vxx)(Vxx,Vuu,Vvv,Iu2) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vabs(Vu32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vabs_Vhf(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vabs_Vhf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabs_hf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vabs(Vu32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vabs_Vsf(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vabs_Vsf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabs_sf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vadd(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vadd_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf16_vadd_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vadd(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vadd_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vadd_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_hf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vadd(Vu32.qf16,Vv32.qf16) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vadd_Vqf16Vqf16(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf16_vadd_Vqf16Vqf16(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_qf16)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vadd(Vu32.qf16,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vadd_Vqf16Vhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf16_vadd_Vqf16Vhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_qf16_mix)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vadd(Vu32.qf32,Vv32.qf32) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vadd_Vqf32Vqf32(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf32_vadd_Vqf32Vqf32(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_qf32)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vadd(Vu32.qf32,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vadd_Vqf32Vsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf32_vadd_Vqf32Vsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_qf32_mix)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vadd(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vadd_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf32_vadd_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vadd(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vadd_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vadd_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_sf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vadd(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vadd_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vadd_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_sf_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.w=vfmv(Vu32.w) + C Intrinsic Prototype: HVX_Vector Q6_Vw_vfmv_Vw(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vw_vfmv_Vw(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vassign_fp)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=Vu32.qf16 + C Intrinsic Prototype: HVX_Vector Q6_Vhf_equals_Vqf16(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vhf_equals_Vqf16(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_hf_qf16)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=Vuu32.qf32 + C Intrinsic Prototype: HVX_Vector Q6_Vhf_equals_Wqf32(HVX_VectorPair Vuu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vhf_equals_Wqf32(Vuu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_hf_qf32)(Vuu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=Vu32.qf32 + C Intrinsic Prototype: HVX_Vector Q6_Vsf_equals_Vqf32(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vsf_equals_Vqf32(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_sf_qf32)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.b=vcvt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vcvt_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vb_vcvt_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_b_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.h=vcvt(Vu32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vh_vcvt_Vhf(HVX_Vector Vu) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vh_vcvt_Vhf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_h_hf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vcvt(Vu32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vcvt_Vb(HVX_Vector Vu) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vcvt_Vb(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_hf_b)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vcvt(Vu32.h) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vcvt_Vh(HVX_Vector Vu) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vcvt_Vh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_hf_h)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vcvt(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vcvt_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vcvt_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_hf_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vcvt(Vu32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vcvt_Vub(HVX_Vector Vu) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vcvt_Vub(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_hf_ub)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vcvt(Vu32.uh) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vcvt_Vuh(HVX_Vector Vu) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vcvt_Vuh(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_hf_uh)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vcvt(Vu32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vcvt_Vhf(HVX_Vector Vu) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vcvt_Vhf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_sf_hf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vcvt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vcvt_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vub_vcvt_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_ub_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vcvt(Vu32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vcvt_Vhf(HVX_Vector Vu) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuh_vcvt_Vhf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_uh_hf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vdmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vdmpy_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vdmpy_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpy_sf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vx32.sf+=vdmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vdmpyacc_VsfVhfVhf(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vdmpyacc_VsfVhfVhf(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vdmpy_sf_hf_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vfmax(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vfmax_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vfmax_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfmax_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vfmax(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vfmax_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vfmax_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfmax_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vfmin(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vfmin_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vfmin_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfmin_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vfmin(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vfmin_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vfmin_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfmin_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vfneg(Vu32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vfneg_Vhf(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vfneg_Vhf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfneg_hf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vfneg(Vu32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vfneg_Vsf(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vfneg_Vsf(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfneg_sf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgthf)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVhfVhf(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVhfVhf(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgthf_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVhfVhf(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVhfVhf(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgthf_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVhfVhf(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVhfVhf(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgthf_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtsf)(Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVsfVsf(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVsfVsf(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtsf_and)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVsfVsf(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVsfVsf(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtsf_or)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVsfVsf(HVX_VectorPred Qx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVsfVsf(Qx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt)((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtsf_xor)(__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx),-1),Vu,Vv)),-1) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vmax(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vmax_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vhf_vmax_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmax_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vmax(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vmax_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vsf_vmax_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmax_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vmin(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vmin_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vhf_vmin_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmin_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vmin(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vmin_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VA + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vsf_vmin_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmin_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vmpy_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vmpy_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_hf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vx32.hf+=vmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vmpyacc_VhfVhfVhf(HVX_Vector Vx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vmpyacc_VhfVhfVhf(Vx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_hf_hf_acc)(Vx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vmpy(Vu32.qf16,Vv32.qf16) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vmpy_Vqf16Vqf16(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf16_vmpy_Vqf16Vqf16(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf16)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vmpy_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf16_vmpy_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf16_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vmpy(Vu32.qf16,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vmpy_Vqf16Vhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf16_vmpy_Vqf16Vhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf16_mix_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vmpy(Vu32.qf32,Vv32.qf32) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vmpy_Vqf32Vqf32(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf32_vmpy_Vqf32Vqf32(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf32)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.qf32=vmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wqf32_vmpy_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wqf32_vmpy_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf32_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.qf32=vmpy(Vu32.qf16,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wqf32_vmpy_Vqf16Vhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wqf32_vmpy_Vqf16Vhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf32_mix_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.qf32=vmpy(Vu32.qf16,Vv32.qf16) + C Intrinsic Prototype: HVX_VectorPair Q6_Wqf32_vmpy_Vqf16Vqf16(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wqf32_vmpy_Vqf16Vqf16(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf32_qf16)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vmpy(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vmpy_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf32_vmpy_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_qf32_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vmpy_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vmpy_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_sf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vxx32.sf+=vmpy(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vmpyacc_WsfVhfVhf(HVX_VectorPair Vxx, HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vmpyacc_WsfVhfVhf(Vxx,Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_sf_hf_acc)(Vxx,Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vmpy(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vmpy_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vmpy_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_sf_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vsub(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vsub_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf16_vsub_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.hf=vsub(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vhf_vsub_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vhf_vsub_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_hf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vsub(Vu32.qf16,Vv32.qf16) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vsub_Vqf16Vqf16(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf16_vsub_Vqf16Vqf16(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_qf16)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vsub(Vu32.qf16,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vsub_Vqf16Vhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf16_vsub_Vqf16Vhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_qf16_mix)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vsub(Vu32.qf32,Vv32.qf32) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vsub_Vqf32Vqf32(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf32_vsub_Vqf32Vqf32(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_qf32)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vsub(Vu32.qf32,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vsub_Vqf32Vsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf32_vsub_Vqf32Vsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_qf32_mix)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vsub(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vsub_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vqf32_vsub_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vsub(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vsub_VhfVhf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vsub_VhfVhf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_sf_hf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 68 +/* ========================================================================== + Assembly Syntax: Vd32.sf=vsub(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vsf_vsub_VsfVsf(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vsf_vsub_VsfVsf(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_sf_sf)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 68 */ + +#if __HVX_ARCH__ >= 69 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vasr(Vuu32.uh,Vv32.ub):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vasr_WuhVub_rnd_sat(HVX_VectorPair Vuu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vasr_WuhVub_rnd_sat(Vuu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrvuhubrndsat)(Vuu,Vv) +#endif /* __HEXAGON_ARCH___ >= 69 */ + +#if __HVX_ARCH__ >= 69 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vasr(Vuu32.uh,Vv32.ub):sat + C Intrinsic Prototype: HVX_Vector Q6_Vub_vasr_WuhVub_sat(HVX_VectorPair Vuu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vub_vasr_WuhVub_sat(Vuu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrvuhubsat)(Vuu,Vv) +#endif /* __HEXAGON_ARCH___ >= 69 */ + +#if __HVX_ARCH__ >= 69 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vasr(Vuu32.w,Vv32.uh):rnd:sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vasr_WwVuh_rnd_sat(HVX_VectorPair Vuu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vasr_WwVuh_rnd_sat(Vuu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrvwuhrndsat)(Vuu,Vv) +#endif /* __HEXAGON_ARCH___ >= 69 */ + +#if __HVX_ARCH__ >= 69 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vasr(Vuu32.w,Vv32.uh):sat + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vasr_WwVuh_sat(HVX_VectorPair Vuu, HVX_Vector Vv) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vuh_vasr_WwVuh_sat(Vuu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vasrvwuhsat)(Vuu,Vv) +#endif /* __HEXAGON_ARCH___ >= 69 */ + +#if __HVX_ARCH__ >= 69 +/* ========================================================================== + Assembly Syntax: Vd32.uh=vmpy(Vu32.uh,Vv32.uh):>>16 + C Intrinsic Prototype: HVX_Vector Q6_Vuh_vmpy_VuhVuh_rs16(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vuh_vmpy_VuhVuh_rs16(Vu,Vv) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpyuhvs)(Vu,Vv) +#endif /* __HEXAGON_ARCH___ >= 69 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vadd(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vadd_VbfVbf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vadd_VbfVbf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_sf_bf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.h=Vu32.hf + C Intrinsic Prototype: HVX_Vector Q6_Vh_equals_Vhf(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vh_equals_Vhf(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_h_hf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.hf=Vu32.h + C Intrinsic Prototype: HVX_Vector Q6_Vhf_equals_Vh(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vhf_equals_Vh(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_hf_h)(Vu) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.sf=Vu32.w + C Intrinsic Prototype: HVX_Vector Q6_Vsf_equals_Vw(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vsf_equals_Vw(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_sf_w)(Vu) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.w=Vu32.sf + C Intrinsic Prototype: HVX_Vector Q6_Vw_equals_Vsf(HVX_Vector Vu) + Instruction Type: CVI_VS + Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Vw_equals_Vsf(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vconv_w_sf)(Vu) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.bf=vcvt(Vu32.sf,Vv32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vbf_vcvt_VsfVsf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vbf_vcvt_VsfVsf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_bf_sf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Qd4=vcmp.gt(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gt_VbfVbf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VA Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gt_VbfVbf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt) \ + ((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtbf)(Vu, Vv)), -1) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Qx4&=vcmp.gt(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtand_QVbfVbf(HVX_VectorPred + Qx, HVX_Vector Vu, HVX_Vector Vv) Instruction Type: CVI_VA Execution + Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtand_QVbfVbf(Qx, Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt) \ + ((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtbf_and)( \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx), -1), Vu, \ + Vv)), \ + -1) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Qx4|=vcmp.gt(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtor_QVbfVbf(HVX_VectorPred + Qx, HVX_Vector Vu, HVX_Vector Vv) Instruction Type: CVI_VA Execution + Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtor_QVbfVbf(Qx, Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt) \ + ((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtbf_or)( \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx), -1), Vu, \ + Vv)), \ + -1) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Qx4^=vcmp.gt(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPred Q6_Q_vcmp_gtxacc_QVbfVbf(HVX_VectorPred + Qx, HVX_Vector Vu, HVX_Vector Vv) Instruction Type: CVI_VA Execution + Slots: SLOT0123 + ========================================================================== */ + +#define Q6_Q_vcmp_gtxacc_QVbfVbf(Qx, Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandqrt) \ + ((__BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vgtbf_xor)( \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vandvrt)((Qx), -1), Vu, \ + Vv)), \ + -1) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.bf=vmax(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_Vector Q6_Vbf_vmax_VbfVbf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_LATE Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vbf_vmax_VbfVbf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmax_bf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vd32.bf=vmin(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_Vector Q6_Vbf_vmin_VbfVbf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_LATE Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vbf_vmin_VbfVbf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmin_bf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vmpy(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vmpy_VbfVbf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vmpy_VbfVbf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_sf_bf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vxx32.sf+=vmpy(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vmpyacc_WsfVbfVbf(HVX_VectorPair + Vxx, HVX_Vector Vu, HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution + Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vmpyacc_WsfVbfVbf(Vxx, Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_sf_bf_acc)(Vxx, Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 73 +/* ========================================================================== + Assembly Syntax: Vdd32.sf=vsub(Vu32.bf,Vv32.bf) + C Intrinsic Prototype: HVX_VectorPair Q6_Wsf_vsub_VbfVbf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Wsf_vsub_VbfVbf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_sf_bf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 73 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32=vgetqfext(Vu32.x,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vgetqfext_VR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vgetqfext_VR(Vu, Rt) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_get_qfext)(Vu, Rt) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vx32|=vgetqfext(Vu32.x,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vgetqfextor_VVR(HVX_Vector Vx, + HVX_Vector Vu, Word32 Rt) Instruction Type: CVI_VX Execution Slots: + SLOT23 + ========================================================================== */ + +#define Q6_V_vgetqfextor_VVR(Vx, Vu, Rt) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_get_qfext_oracc)(Vx, Vu, Rt) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.x=vsetqfext(Vu32,Rt32) + C Intrinsic Prototype: HVX_Vector Q6_V_vsetqfext_VR(HVX_Vector Vu, Word32 Rt) + Instruction Type: CVI_VX + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vsetqfext_VR(Vu, Rt) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_set_qfext)(Vu, Rt) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.f8=vabs(Vu32.f8) + C Intrinsic Prototype: HVX_Vector Q6_V_vabs_V(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vabs_V(Vu) __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vabs_f8)(Vu) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vadd(Vu32.f8,Vv32.f8) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vadd_VV(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vadd_VV(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vadd_hf_f8)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.b=vcvt2(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vb_vcvt2_VhfVhf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vb_vcvt2_VhfVhf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt2_b_hf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vcvt2(Vu32.b) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vcvt2_Vb(HVX_Vector Vu) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vcvt2_Vb(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt2_hf_b)(Vu) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vcvt2(Vu32.ub) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vcvt2_Vub(HVX_Vector Vu) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vcvt2_Vub(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt2_hf_ub)(Vu) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.ub=vcvt2(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vub_vcvt2_VhfVhf(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vub_vcvt2_VhfVhf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt2_ub_hf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.f8=vcvt(Vu32.hf,Vv32.hf) + C Intrinsic Prototype: HVX_Vector Q6_V_vcvt_VhfVhf(HVX_Vector Vu, HVX_Vector + Vv) Instruction Type: CVI_VX Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vcvt_VhfVhf(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_f8_hf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vcvt(Vu32.f8) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vcvt_V(HVX_Vector Vu) + Instruction Type: CVI_VX_DV + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vcvt_V(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vcvt_hf_f8)(Vu) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.f8=vfmax(Vu32.f8,Vv32.f8) + C Intrinsic Prototype: HVX_Vector Q6_V_vfmax_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vfmax_VV(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfmax_f8)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.f8=vfmin(Vu32.f8,Vv32.f8) + C Intrinsic Prototype: HVX_Vector Q6_V_vfmin_VV(HVX_Vector Vu, HVX_Vector Vv) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vfmin_VV(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfmin_f8)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.f8=vfneg(Vu32.f8) + C Intrinsic Prototype: HVX_Vector Q6_V_vfneg_V(HVX_Vector Vu) + Instruction Type: CVI_VX_LATE + Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_V_vfneg_V(Vu) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vfneg_f8)(Vu) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32=vmerge(Vu32.x,Vv32.w) + C Intrinsic Prototype: HVX_Vector Q6_V_vmerge_VVw(HVX_Vector Vu, HVX_Vector + Vv) Instruction Type: CVI_VS Execution Slots: SLOT0123 + ========================================================================== */ + +#define Q6_V_vmerge_VVw(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmerge_qf)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vmpy(Vu32.f8,Vv32.f8) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vmpy_VV(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vmpy_VV(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_hf_f8)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vxx32.hf+=vmpy(Vu32.f8,Vv32.f8) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vmpyacc_WhfVV(HVX_VectorPair + Vxx, HVX_Vector Vu, HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution + Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vmpyacc_WhfVV(Vxx, Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_hf_f8_acc)(Vxx, Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vmpy(Vu32.hf,Rt32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vmpy_VhfRhf(HVX_Vector Vu, Word32 + Rt) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf16_vmpy_VhfRhf(Vu, Rt) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_rt_hf)(Vu, Rt) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.qf16=vmpy(Vu32.qf16,Rt32.hf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf16_vmpy_Vqf16Rhf(HVX_Vector Vu, + Word32 Rt) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf16_vmpy_Vqf16Rhf(Vu, Rt) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_rt_qf16)(Vu, Rt) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vd32.qf32=vmpy(Vu32.sf,Rt32.sf) + C Intrinsic Prototype: HVX_Vector Q6_Vqf32_vmpy_VsfRsf(HVX_Vector Vu, Word32 + Rt) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Vqf32_vmpy_VsfRsf(Vu, Rt) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vmpy_rt_sf)(Vu, Rt) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#if __HVX_ARCH__ >= 79 +/* ========================================================================== + Assembly Syntax: Vdd32.hf=vsub(Vu32.f8,Vv32.f8) + C Intrinsic Prototype: HVX_VectorPair Q6_Whf_vsub_VV(HVX_Vector Vu, + HVX_Vector Vv) Instruction Type: CVI_VX_DV Execution Slots: SLOT23 + ========================================================================== */ + +#define Q6_Whf_vsub_VV(Vu, Vv) \ + __BUILTIN_VECTOR_WRAP(__builtin_HEXAGON_V6_vsub_hf_f8)(Vu, Vv) +#endif /* __HEXAGON_ARCH___ >= 79 */ + +#endif /* __HVX__ */ + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ia32intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ia32intrin.h new file mode 100755 index 0000000..8e65f23 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ia32intrin.h @@ -0,0 +1,863 @@ +/* ===-------- ia32intrin.h ---------------------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __IA32INTRIN_H +#define __IA32INTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) +#define __DEFAULT_FN_ATTRS_CRC32 __attribute__((__always_inline__, __nodebug__, __target__("crc32"))) + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CAST __attribute__((__always_inline__)) constexpr +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#else +#define __DEFAULT_FN_ATTRS_CAST __attribute__((__always_inline__)) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS +#endif + +/// Finds the first set bit starting from the least significant bit. The result +/// is undefined if the input is 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSF instruction or the +/// \c TZCNT instruction. +/// +/// \param __A +/// A 32-bit integer operand. +/// \returns A 32-bit integer containing the bit number. +/// \see _bit_scan_forward +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +__bsfd(int __A) { + return __builtin_ctz((unsigned int)__A); +} + +/// Finds the first set bit starting from the most significant bit. The result +/// is undefined if the input is 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSR instruction or the +/// \c LZCNT instruction and an \c XOR. +/// +/// \param __A +/// A 32-bit integer operand. +/// \returns A 32-bit integer containing the bit number. +/// \see _bit_scan_reverse +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +__bsrd(int __A) { + return 31 - __builtin_clz((unsigned int)__A); +} + +/// Swaps the bytes in the input, converting little endian to big endian or +/// vice versa. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSWAP instruction. +/// +/// \param __A +/// A 32-bit integer operand. +/// \returns A 32-bit integer containing the swapped bytes. +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +__bswapd(int __A) { + return (int)__builtin_bswap32((unsigned int)__A); +} + +/// Swaps the bytes in the input, converting little endian to big endian or +/// vice versa. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSWAP instruction. +/// +/// \param __A +/// A 32-bit integer operand. +/// \returns A 32-bit integer containing the swapped bytes. +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +_bswap(int __A) { + return (int)__builtin_bswap32((unsigned int)__A); +} + +/// Finds the first set bit starting from the least significant bit. The result +/// is undefined if the input is 0. +/// +/// \headerfile +/// +/// \code +/// int _bit_scan_forward(int A); +/// \endcode +/// +/// This intrinsic corresponds to the \c BSF instruction or the +/// \c TZCNT instruction. +/// +/// \param A +/// A 32-bit integer operand. +/// \returns A 32-bit integer containing the bit number. +/// \see __bsfd +#define _bit_scan_forward(A) __bsfd((A)) + +/// Finds the first set bit starting from the most significant bit. The result +/// is undefined if the input is 0. +/// +/// \headerfile +/// +/// \code +/// int _bit_scan_reverse(int A); +/// \endcode +/// +/// This intrinsic corresponds to the \c BSR instruction or the +/// \c LZCNT instruction and an \c XOR. +/// +/// \param A +/// A 32-bit integer operand. +/// \returns A 32-bit integer containing the bit number. +/// \see __bsrd +#define _bit_scan_reverse(A) __bsrd((A)) + +#ifdef __x86_64__ +/// Finds the first set bit starting from the least significant bit. The result +/// is undefined if the input is 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSF instruction or the +/// \c TZCNT instruction. +/// +/// \param __A +/// A 64-bit integer operand. +/// \returns A 32-bit integer containing the bit number. +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +__bsfq(long long __A) { + return (long long)__builtin_ctzll((unsigned long long)__A); +} + +/// Finds the first set bit starting from the most significant bit. The result +/// is undefined if input is 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSR instruction or the +/// \c LZCNT instruction and an \c XOR. +/// +/// \param __A +/// A 64-bit integer operand. +/// \returns A 32-bit integer containing the bit number. +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +__bsrq(long long __A) { + return 63 - __builtin_clzll((unsigned long long)__A); +} + +/// Swaps the bytes in the input, converting little endian to big endian or +/// vice versa. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c BSWAP instruction. +/// +/// \param __A +/// A 64-bit integer operand. +/// \returns A 64-bit integer containing the swapped bytes. +/// \see _bswap64 +static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR +__bswapq(long long __A) { + return (long long)__builtin_bswap64((unsigned long long)__A); +} + +/// Swaps the bytes in the input, converting little endian to big endian or +/// vice versa. +/// +/// \headerfile +/// +/// \code +/// long long _bswap64(long long A); +/// \endcode +/// +/// This intrinsic corresponds to the \c BSWAP instruction. +/// +/// \param A +/// A 64-bit integer operand. +/// \returns A 64-bit integer containing the swapped bytes. +/// \see __bswapq +#define _bswap64(A) __bswapq((A)) +#endif /* __x86_64__ */ + +/// Counts the number of bits in the source operand having a value of 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c POPCNT instruction or a +/// sequence of arithmetic and logic operations to calculate it. +/// +/// \param __A +/// An unsigned 32-bit integer operand. +/// \returns A 32-bit integer containing the number of bits with value 1 in the +/// source operand. +/// \see _popcnt32 +static __inline__ int __DEFAULT_FN_ATTRS_CONSTEXPR +__popcntd(unsigned int __A) +{ + return __builtin_popcount(__A); +} + +/// Counts the number of bits in the source operand having a value of 1. +/// +/// \headerfile +/// +/// \code +/// int _popcnt32(int A); +/// \endcode +/// +/// This intrinsic corresponds to the \c POPCNT instruction or a +/// sequence of arithmetic and logic operations to calculate it. +/// +/// \param A +/// An unsigned 32-bit integer operand. +/// \returns A 32-bit integer containing the number of bits with value 1 in the +/// source operand. +/// \see __popcntd +#define _popcnt32(A) __popcntd((A)) + +#ifdef __x86_64__ +/// Counts the number of bits in the source operand having a value of 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c POPCNT instruction or a +/// sequence of arithmetic and logic operations to calculate it. +/// +/// \param __A +/// An unsigned 64-bit integer operand. +/// \returns A 64-bit integer containing the number of bits with value 1 in the +/// source operand. +/// \see _popcnt64 +static __inline__ long long __DEFAULT_FN_ATTRS_CONSTEXPR +__popcntq(unsigned long long __A) +{ + return __builtin_popcountll(__A); +} + +/// Counts the number of bits in the source operand having a value of 1. +/// +/// \headerfile +/// +/// \code +/// long long _popcnt64(unsigned long long A); +/// \endcode +/// +/// This intrinsic corresponds to the \c POPCNT instruction or a +/// sequence of arithmetic and logic operations to calculate it. +/// +/// \param A +/// An unsigned 64-bit integer operand. +/// \returns A 64-bit integer containing the number of bits with value 1 in the +/// source operand. +/// \see __popcntq +#define _popcnt64(A) __popcntq((A)) +#endif /* __x86_64__ */ + +#ifdef __x86_64__ +/// Returns the program status-and-control \c RFLAGS register with the \c VM +/// and \c RF flags cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PUSHFQ + \c POP instruction sequence. +/// +/// \returns The 64-bit value of the RFLAGS register. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__readeflags(void) +{ + return __builtin_ia32_readeflags_u64(); +} + +/// Writes the specified value to the program status-and-control \c RFLAGS +/// register. Reserved bits are not affected. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PUSH + \c POPFQ instruction sequence. +/// +/// \param __f +/// The 64-bit value to write to \c RFLAGS. +static __inline__ void __DEFAULT_FN_ATTRS +__writeeflags(unsigned long long __f) +{ + __builtin_ia32_writeeflags_u64(__f); +} + +#else /* !__x86_64__ */ +/// Returns the program status-and-control \c EFLAGS register with the \c VM +/// and \c RF flags cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PUSHFD + \c POP instruction sequence. +/// +/// \returns The 32-bit value of the EFLAGS register. +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__readeflags(void) +{ + return __builtin_ia32_readeflags_u32(); +} + +/// Writes the specified value to the program status-and-control \c EFLAGS +/// register. Reserved bits are not affected. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PUSH + \c POPFD instruction sequence. +/// +/// \param __f +/// The 32-bit value to write to \c EFLAGS. +static __inline__ void __DEFAULT_FN_ATTRS +__writeeflags(unsigned int __f) +{ + __builtin_ia32_writeeflags_u32(__f); +} +#endif /* !__x86_64__ */ + +/// Casts a 32-bit float value to a 32-bit unsigned integer value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VMOVD / \c MOVD instruction in x86_64, +/// and corresponds to the \c VMOVL / \c MOVL instruction in ia32. +/// +/// \param __A +/// A 32-bit float value. +/// \returns A 32-bit unsigned integer containing the converted value. +static __inline__ unsigned int __DEFAULT_FN_ATTRS_CAST +_castf32_u32(float __A) { + return __builtin_bit_cast(unsigned int, __A); +} + +/// Casts a 64-bit float value to a 64-bit unsigned integer value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VMOVQ / \c MOVQ instruction in x86_64, +/// and corresponds to the \c VMOVL / \c MOVL instruction in ia32. +/// +/// \param __A +/// A 64-bit float value. +/// \returns A 64-bit unsigned integer containing the converted value. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CAST +_castf64_u64(double __A) { + return __builtin_bit_cast(unsigned long long, __A); +} + +/// Casts a 32-bit unsigned integer value to a 32-bit float value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VMOVQ / \c MOVQ instruction in x86_64, +/// and corresponds to the \c FLDS instruction in ia32. +/// +/// \param __A +/// A 32-bit unsigned integer value. +/// \returns A 32-bit float value containing the converted value. +static __inline__ float __DEFAULT_FN_ATTRS_CAST +_castu32_f32(unsigned int __A) { + return __builtin_bit_cast(float, __A); +} + +/// Casts a 64-bit unsigned integer value to a 64-bit float value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VMOVQ / \c MOVQ instruction in x86_64, +/// and corresponds to the \c FLDL instruction in ia32. +/// +/// \param __A +/// A 64-bit unsigned integer value. +/// \returns A 64-bit float value containing the converted value. +static __inline__ double __DEFAULT_FN_ATTRS_CAST +_castu64_f64(unsigned long long __A) { + return __builtin_bit_cast(double, __A); +} + +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// unsigned char operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CRC32B instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 8-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned int __DEFAULT_FN_ATTRS_CRC32 +__crc32b(unsigned int __C, unsigned char __D) +{ + return __builtin_ia32_crc32qi(__C, __D); +} + +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// unsigned short operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CRC32W instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 16-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned int __DEFAULT_FN_ATTRS_CRC32 +__crc32w(unsigned int __C, unsigned short __D) +{ + return __builtin_ia32_crc32hi(__C, __D); +} + +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// second unsigned integer operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CRC32D instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 32-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned int __DEFAULT_FN_ATTRS_CRC32 +__crc32d(unsigned int __C, unsigned int __D) +{ + return __builtin_ia32_crc32si(__C, __D); +} + +#ifdef __x86_64__ +/// Adds the unsigned integer operand to the CRC-32C checksum of the +/// unsigned 64-bit integer operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c CRC32Q instruction. +/// +/// \param __C +/// An unsigned integer operand to add to the CRC-32C checksum of operand +/// \a __D. +/// \param __D +/// An unsigned 64-bit integer operand used to compute the CRC-32C checksum. +/// \returns The result of adding operand \a __C to the CRC-32C checksum of +/// operand \a __D. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CRC32 +__crc32q(unsigned long long __C, unsigned long long __D) +{ + return __builtin_ia32_crc32di(__C, __D); +} +#endif /* __x86_64__ */ + +/// Reads the specified performance-monitoring counter. Refer to your +/// processor's documentation to determine which performance counters are +/// supported. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c RDPMC instruction. +/// +/// \param __A +/// The performance counter to read. +/// \returns The 64-bit value read from the performance counter. +/// \see _rdpmc +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__rdpmc(int __A) { + return __builtin_ia32_rdpmc(__A); +} + +/// Reads the processor's time-stamp counter and the \c IA32_TSC_AUX MSR +/// \c (0xc0000103). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c RDTSCP instruction. +/// +/// \param __A +/// The address of where to store the 32-bit \c IA32_TSC_AUX value. +/// \returns The 64-bit value of the time-stamp counter. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__rdtscp(unsigned int *__A) { + return __builtin_ia32_rdtscp(__A); +} + +/// Reads the processor's time-stamp counter. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _rdtsc(); +/// \endcode +/// +/// This intrinsic corresponds to the \c RDTSC instruction. +/// +/// \returns The 64-bit value of the time-stamp counter. +#define _rdtsc() __rdtsc() + +/// Reads the specified performance monitoring counter. Refer to your +/// processor's documentation to determine which performance counters are +/// supported. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _rdpmc(int A); +/// \endcode +/// +/// This intrinsic corresponds to the \c RDPMC instruction. +/// +/// \param A +/// The performance counter to read. +/// \returns The 64-bit value read from the performance counter. +/// \see __rdpmc +#define _rdpmc(A) __rdpmc(A) + +static __inline__ void __DEFAULT_FN_ATTRS +_wbinvd(void) { + __builtin_ia32_wbinvd(); +} + +/// Rotates an 8-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param __X +/// The unsigned 8-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +static __inline__ unsigned char __DEFAULT_FN_ATTRS_CONSTEXPR +__rolb(unsigned char __X, int __C) { + return __builtin_rotateleft8(__X, __C); +} + +/// Rotates an 8-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param __X +/// The unsigned 8-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +static __inline__ unsigned char __DEFAULT_FN_ATTRS_CONSTEXPR +__rorb(unsigned char __X, int __C) { + return __builtin_rotateright8(__X, __C); +} + +/// Rotates a 16-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param __X +/// The unsigned 16-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see _rotwl +static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR +__rolw(unsigned short __X, int __C) { + return __builtin_rotateleft16(__X, __C); +} + +/// Rotates a 16-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param __X +/// The unsigned 16-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see _rotwr +static __inline__ unsigned short __DEFAULT_FN_ATTRS_CONSTEXPR +__rorw(unsigned short __X, int __C) { + return __builtin_rotateright16(__X, __C); +} + +/// Rotates a 32-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param __X +/// The unsigned 32-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see _rotl +static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR +__rold(unsigned int __X, int __C) { + return __builtin_rotateleft32(__X, (unsigned int)__C); +} + +/// Rotates a 32-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param __X +/// The unsigned 32-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see _rotr +static __inline__ unsigned int __DEFAULT_FN_ATTRS_CONSTEXPR +__rord(unsigned int __X, int __C) { + return __builtin_rotateright32(__X, (unsigned int)__C); +} + +#ifdef __x86_64__ +/// Rotates a 64-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param __X +/// The unsigned 64-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CONSTEXPR +__rolq(unsigned long long __X, int __C) { + return __builtin_rotateleft64(__X, (unsigned long long)__C); +} + +/// Rotates a 64-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param __X +/// The unsigned 64-bit value to be rotated. +/// \param __C +/// The number of bits to rotate the value. +/// \returns The rotated value. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS_CONSTEXPR +__rorq(unsigned long long __X, int __C) { + return __builtin_rotateright64(__X, (unsigned long long)__C); +} +#endif /* __x86_64__ */ + +#ifndef _MSC_VER +/* These are already provided as builtins for MSVC. */ +/* Select the correct function based on the size of long. */ +#ifdef __LP64__ +/// Rotates a 64-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _lrotl(unsigned long long a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param a +/// The unsigned 64-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rolq +#define _lrotl(a,b) __rolq((a), (b)) + +/// Rotates a 64-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned long long _lrotr(unsigned long long a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param a +/// The unsigned 64-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rorq +#define _lrotr(a,b) __rorq((a), (b)) +#else // __LP64__ +/// Rotates a 32-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned int _lrotl(unsigned int a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param a +/// The unsigned 32-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rold +#define _lrotl(a,b) __rold((a), (b)) + +/// Rotates a 32-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned int _lrotr(unsigned int a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param a +/// The unsigned 32-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rord +#define _lrotr(a,b) __rord((a), (b)) +#endif // __LP64__ + +/// Rotates a 32-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned int _rotl(unsigned int a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param a +/// The unsigned 32-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rold +#define _rotl(a,b) __rold((a), (b)) + +/// Rotates a 32-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned int _rotr(unsigned int a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param a +/// The unsigned 32-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rord +#define _rotr(a,b) __rord((a), (b)) +#endif // _MSC_VER + +/* These are not builtins so need to be provided in all modes. */ +/// Rotates a 16-bit value to the left by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned short _rotwl(unsigned short a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROL instruction. +/// +/// \param a +/// The unsigned 16-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rolw +#define _rotwl(a,b) __rolw((a), (b)) + +/// Rotates a 16-bit value to the right by the specified number of bits. +/// This operation is undefined if the number of bits exceeds the size of +/// the value. +/// +/// \headerfile +/// +/// \code +/// unsigned short _rotwr(unsigned short a, int b); +/// \endcode +/// +/// This intrinsic corresponds to the \c ROR instruction. +/// +/// \param a +/// The unsigned 16-bit value to be rotated. +/// \param b +/// The number of bits to rotate the value. +/// \returns The rotated value. +/// \see __rorw +#define _rotwr(a,b) __rorw((a), (b)) + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_CAST +#undef __DEFAULT_FN_ATTRS_CRC32 +#undef __DEFAULT_FN_ATTRS_CONSTEXPR + +#endif /* __IA32INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/immintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/immintrin.h new file mode 100755 index 0000000..35f012c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/immintrin.h @@ -0,0 +1,607 @@ +/*===---- immintrin.h - Intel intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#define __IMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +/// Reads the value of the IA32_TSC_AUX MSR (0xc0000103). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDPID instruction. +/// +/// \returns The 32-bit contents of the MSR. +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("rdpid"))) +_rdpid_u32(void) { + return __builtin_ia32_rdpid(); +} + +/// Returns a 16-bit hardware-generated random value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDRAND instruction. +/// +/// \param __p +/// A pointer to a 16-bit memory location to place the random value. +/// \returns 1 if the value was successfully generated, 0 otherwise. +static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) +_rdrand16_step(unsigned short *__p) +{ + return (int)__builtin_ia32_rdrand16_step(__p); +} + +/// Returns a 32-bit hardware-generated random value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDRAND instruction. +/// +/// \param __p +/// A pointer to a 32-bit memory location to place the random value. +/// \returns 1 if the value was successfully generated, 0 otherwise. +static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) +_rdrand32_step(unsigned int *__p) +{ + return (int)__builtin_ia32_rdrand32_step(__p); +} + +/// Returns a 64-bit hardware-generated random value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDRAND instruction. +/// +/// \param __p +/// A pointer to a 64-bit memory location to place the random value. +/// \returns 1 if the value was successfully generated, 0 otherwise. +static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd"))) +_rdrand64_step(unsigned long long *__p) +{ +#ifdef __x86_64__ + return (int)__builtin_ia32_rdrand64_step(__p); +#else + // We need to emulate the functionality of 64-bit rdrand with 2 32-bit + // rdrand instructions. + unsigned int __lo, __hi; + unsigned int __res_lo = __builtin_ia32_rdrand32_step(&__lo); + unsigned int __res_hi = __builtin_ia32_rdrand32_step(&__hi); + if (__res_lo && __res_hi) { + *__p = ((unsigned long long)__hi << 32) | (unsigned long long)__lo; + return 1; + } else { + *__p = 0; + return 0; + } +#endif +} + +#ifdef __x86_64__ +/// Reads the FS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDFSBASE instruction. +/// +/// \returns The lower 32 bits of the FS base register. +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_readfsbase_u32(void) +{ + return __builtin_ia32_rdfsbase32(); +} + +/// Reads the FS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDFSBASE instruction. +/// +/// \returns The contents of the FS base register. +static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_readfsbase_u64(void) +{ + return __builtin_ia32_rdfsbase64(); +} + +/// Reads the GS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDGSBASE instruction. +/// +/// \returns The lower 32 bits of the GS base register. +static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_readgsbase_u32(void) +{ + return __builtin_ia32_rdgsbase32(); +} + +/// Reads the GS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDGSBASE instruction. +/// +/// \returns The contents of the GS base register. +static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_readgsbase_u64(void) +{ + return __builtin_ia32_rdgsbase64(); +} + +/// Modifies the FS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the WRFSBASE instruction. +/// +/// \param __V +/// Value to use for the lower 32 bits of the FS base register. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_writefsbase_u32(unsigned int __V) +{ + __builtin_ia32_wrfsbase32(__V); +} + +/// Modifies the FS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the WRFSBASE instruction. +/// +/// \param __V +/// Value to use for the FS base register. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_writefsbase_u64(unsigned long long __V) +{ + __builtin_ia32_wrfsbase64(__V); +} + +/// Modifies the GS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the WRGSBASE instruction. +/// +/// \param __V +/// Value to use for the lower 32 bits of the GS base register. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_writegsbase_u32(unsigned int __V) +{ + __builtin_ia32_wrgsbase32(__V); +} + +/// Modifies the GS base register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the WRFSBASE instruction. +/// +/// \param __V +/// Value to use for GS base register. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase"))) +_writegsbase_u64(unsigned long long __V) +{ + __builtin_ia32_wrgsbase64(__V); +} + +#endif + +/* The structs used below are to force the load/store to be unaligned. This + * is accomplished with the __packed__ attribute. The __may_alias__ prevents + * tbaa metadata from being generated based on the struct and the type of the + * field inside of it. + */ + +/// Load a 16-bit value from memory and swap its bytes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVBE instruction. +/// +/// \param __P +/// A pointer to the 16-bit value to load. +/// \returns The byte-swapped value. +static __inline__ short __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) +_loadbe_i16(void const * __P) { + struct __loadu_i16 { + unsigned short __v; + } __attribute__((__packed__, __may_alias__)); + return (short)__builtin_bswap16(((const struct __loadu_i16*)__P)->__v); +} + +/// Swap the bytes of a 16-bit value and store it to memory. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVBE instruction. +/// +/// \param __P +/// A pointer to the memory for storing the swapped value. +/// \param __D +/// The 16-bit value to be byte-swapped. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) +_storebe_i16(void * __P, short __D) { + struct __storeu_i16 { + unsigned short __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_i16*)__P)->__v = __builtin_bswap16((unsigned short)__D); +} + +/// Load a 32-bit value from memory and swap its bytes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVBE instruction. +/// +/// \param __P +/// A pointer to the 32-bit value to load. +/// \returns The byte-swapped value. +static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) +_loadbe_i32(void const * __P) { + struct __loadu_i32 { + unsigned int __v; + } __attribute__((__packed__, __may_alias__)); + return (int)__builtin_bswap32(((const struct __loadu_i32*)__P)->__v); +} + +/// Swap the bytes of a 32-bit value and store it to memory. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVBE instruction. +/// +/// \param __P +/// A pointer to the memory for storing the swapped value. +/// \param __D +/// The 32-bit value to be byte-swapped. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) +_storebe_i32(void * __P, int __D) { + struct __storeu_i32 { + unsigned int __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_i32*)__P)->__v = __builtin_bswap32((unsigned int)__D); +} + +#ifdef __x86_64__ +/// Load a 64-bit value from memory and swap its bytes. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVBE instruction. +/// +/// \param __P +/// A pointer to the 64-bit value to load. +/// \returns The byte-swapped value. +static __inline__ long long __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) +_loadbe_i64(void const * __P) { + struct __loadu_i64 { + unsigned long long __v; + } __attribute__((__packed__, __may_alias__)); + return (long long)__builtin_bswap64(((const struct __loadu_i64*)__P)->__v); +} + +/// Swap the bytes of a 64-bit value and store it to memory. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVBE instruction. +/// +/// \param __P +/// A pointer to the memory for storing the swapped value. +/// \param __D +/// The 64-bit value to be byte-swapped. +static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe"))) +_storebe_i64(void * __P, long long __D) { + struct __storeu_i64 { + unsigned long long __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_i64*)__P)->__v = __builtin_bswap64((unsigned long long)__D); +} +#endif + +#include +#include + +#include + +#include + +/* No feature check desired due to internal MSC_VER checks */ +#include + +#include + +#include + +#include + +#include + +/* Intrinsics inside adcintrin.h are available at all times. */ +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#if defined(_MSC_VER) && __has_extension(gnu_asm) +/* Define the default attributes for these intrinsics */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) +#ifdef __cplusplus +extern "C" { +#endif +/*----------------------------------------------------------------------------*\ +|* Interlocked Exchange HLE +\*----------------------------------------------------------------------------*/ +#if defined(__i386__) || defined(__x86_64__) +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchange_HLEAcquire(long volatile *_Target, long _Value) { + __asm__ __volatile__(".byte 0xf2 ; lock ; xchg {%0, %1|%1, %0}" + : "+r" (_Value), "+m" (*_Target) :: "memory"); + return _Value; +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchange_HLERelease(long volatile *_Target, long _Value) { + __asm__ __volatile__(".byte 0xf3 ; lock ; xchg {%0, %1|%1, %0}" + : "+r" (_Value), "+m" (*_Target) :: "memory"); + return _Value; +} +#endif +#if defined(__x86_64__) +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchange64_HLEAcquire(__int64 volatile *_Target, __int64 _Value) { + __asm__ __volatile__(".byte 0xf2 ; lock ; xchg {%0, %1|%1, %0}" + : "+r" (_Value), "+m" (*_Target) :: "memory"); + return _Value; +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchange64_HLERelease(__int64 volatile *_Target, __int64 _Value) { + __asm__ __volatile__(".byte 0xf3 ; lock ; xchg {%0, %1|%1, %0}" + : "+r" (_Value), "+m" (*_Target) :: "memory"); + return _Value; +} +#endif +/*----------------------------------------------------------------------------*\ +|* Interlocked Compare Exchange HLE +\*----------------------------------------------------------------------------*/ +#if defined(__i386__) || defined(__x86_64__) +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedCompareExchange_HLEAcquire(long volatile *_Destination, + long _Exchange, long _Comparand) { + __asm__ __volatile__(".byte 0xf2 ; lock ; cmpxchg {%2, %1|%1, %2}" + : "+a" (_Comparand), "+m" (*_Destination) + : "r" (_Exchange) : "memory"); + return _Comparand; +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedCompareExchange_HLERelease(long volatile *_Destination, + long _Exchange, long _Comparand) { + __asm__ __volatile__(".byte 0xf3 ; lock ; cmpxchg {%2, %1|%1, %2}" + : "+a" (_Comparand), "+m" (*_Destination) + : "r" (_Exchange) : "memory"); + return _Comparand; +} +#endif +#if defined(__x86_64__) +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedCompareExchange64_HLEAcquire(__int64 volatile *_Destination, + __int64 _Exchange, __int64 _Comparand) { + __asm__ __volatile__(".byte 0xf2 ; lock ; cmpxchg {%2, %1|%1, %2}" + : "+a" (_Comparand), "+m" (*_Destination) + : "r" (_Exchange) : "memory"); + return _Comparand; +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedCompareExchange64_HLERelease(__int64 volatile *_Destination, + __int64 _Exchange, __int64 _Comparand) { + __asm__ __volatile__(".byte 0xf3 ; lock ; cmpxchg {%2, %1|%1, %2}" + : "+a" (_Comparand), "+m" (*_Destination) + : "r" (_Exchange) : "memory"); + return _Comparand; +} +#endif +#ifdef __cplusplus +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif /* defined(_MSC_VER) && __has_extension(gnu_asm) */ + +#endif /* __IMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/intrin.h new file mode 100755 index 0000000..588c283 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/intrin.h @@ -0,0 +1,487 @@ +/* ===-------- intrin.h ---------------------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Only include this if we're compiling for the windows platform. */ +#ifndef _MSC_VER +#include_next +#else + +#ifndef __INTRIN_H +#define __INTRIN_H + +#include + +/* First include the standard intrinsics. */ +#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) +#include +#endif + +#if defined(__arm__) +#include +#endif + +#if defined(__aarch64__) || defined(__arm64ec__) +#include +#endif + +/* For the definition of jmp_buf. */ +#if __STDC_HOSTED__ +#include +#endif + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) + +#if __x86_64__ +#define __LPTRINT_TYPE__ __int64 +#else +#define __LPTRINT_TYPE__ long +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__MMX__) +/* And the random ones that aren't in those files. */ +__m64 _m_from_float(float); +float _m_to_float(__m64); +#endif + +/* Other assorted instruction intrinsics. */ +void __addfsbyte(unsigned long, unsigned char); +void __addfsdword(unsigned long, unsigned long); +void __addfsword(unsigned long, unsigned short); +void __code_seg(const char *); +void __cpuid(int[4], int); +void __cpuidex(int[4], int, int); +__int64 __emul(int, int); +unsigned __int64 __emulu(unsigned int, unsigned int); +unsigned int __getcallerseflags(void); +void __halt(void); +unsigned char __inbyte(unsigned short); +void __inbytestring(unsigned short, unsigned char *, unsigned long); +void __incfsbyte(unsigned long); +void __incfsdword(unsigned long); +void __incfsword(unsigned long); +unsigned long __indword(unsigned short); +void __indwordstring(unsigned short, unsigned long *, unsigned long); +void __int2c(void); +void __invlpg(void *); +unsigned short __inword(unsigned short); +void __inwordstring(unsigned short, unsigned short *, unsigned long); +void __lidt(void *); +unsigned __int64 __ll_lshift(unsigned __int64, int); +__int64 __ll_rshift(__int64, int); +void __movsb(unsigned char *, unsigned char const *, size_t); +void __movsd(unsigned long *, unsigned long const *, size_t); +void __movsw(unsigned short *, unsigned short const *, size_t); +void __nop(void); +void __nvreg_restore_fence(void); +void __nvreg_save_fence(void); +void __outbyte(unsigned short, unsigned char); +void __outbytestring(unsigned short, unsigned char *, unsigned long); +void __outdword(unsigned short, unsigned long); +void __outdwordstring(unsigned short, unsigned long *, unsigned long); +void __outword(unsigned short, unsigned short); +void __outwordstring(unsigned short, unsigned short *, unsigned long); +unsigned long __readcr0(void); +unsigned long __readcr2(void); +unsigned __LPTRINT_TYPE__ __readcr3(void); +unsigned __LPTRINT_TYPE__ __readcr4(void); +unsigned __int64 __readcr8(void); +unsigned int __readdr(unsigned int); +#ifdef __i386__ +unsigned char __readfsbyte(unsigned long); +unsigned short __readfsword(unsigned long); +unsigned long __readfsdword(unsigned long); +unsigned __int64 __readfsqword(unsigned long); +#endif +unsigned __int64 __readmsr(unsigned long); +unsigned __int64 __readpmc(unsigned long); +unsigned long __segmentlimit(unsigned long); +void __sidt(void *); +void __stosb(unsigned char *, unsigned char, size_t); +void __stosd(unsigned long *, unsigned long, size_t); +void __stosw(unsigned short *, unsigned short, size_t); +void __svm_clgi(void); +void __svm_invlpga(void *, int); +void __svm_skinit(int); +void __svm_stgi(void); +void __svm_vmload(size_t); +void __svm_vmrun(size_t); +void __svm_vmsave(size_t); +void __ud2(void); +unsigned __int64 __ull_rshift(unsigned __int64, int); +void __vmx_off(void); +void __vmx_vmptrst(unsigned __int64 *); +void __wbinvd(void); +void __writecr0(unsigned int); +void __writecr3(unsigned __INTPTR_TYPE__); +void __writecr4(unsigned __INTPTR_TYPE__); +void __writecr8(unsigned __int64); +void __writedr(unsigned int, unsigned int); +void __writefsbyte(unsigned long, unsigned char); +void __writefsdword(unsigned long, unsigned long); +void __writefsqword(unsigned long, unsigned __int64); +void __writefsword(unsigned long, unsigned short); +void __writemsr(unsigned long, unsigned __int64); +void *_AddressOfReturnAddress(void); +unsigned char _bittest(long const *, long); +unsigned char _bittestandcomplement(long *, long); +unsigned char _bittestandreset(long *, long); +unsigned char _bittestandset(long *, long); +void __cdecl _disable(void); +void __cdecl _enable(void); +long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value); +unsigned char _interlockedbittestandreset(long volatile *, long); +unsigned char _interlockedbittestandset(long volatile *, long); +void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *, + void *); +void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *, + void *); +long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long); +long _InterlockedExchangeAdd_HLERelease(long volatile *, long); +__int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64); +__int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64); +void _ReadBarrier(void); +unsigned int _rorx_u32(unsigned int, const unsigned int); +int _sarx_i32(int, unsigned int); +#if __STDC_HOSTED__ +int __cdecl _setjmp(jmp_buf); +#endif +unsigned int _shlx_u32(unsigned int, unsigned int); +unsigned int _shrx_u32(unsigned int, unsigned int); +void _Store_HLERelease(long volatile *, long); +void _Store64_HLERelease(__int64 volatile *, __int64); +void _StorePointer_HLERelease(void *volatile *, void *); +void _WriteBarrier(void); + +/* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */ +#if defined(__x86_64__) && !defined(__arm64ec__) +void __addgsbyte(unsigned long, unsigned char); +void __addgsdword(unsigned long, unsigned long); +void __addgsqword(unsigned long, unsigned __int64); +void __addgsword(unsigned long, unsigned short); +void __faststorefence(void); +void __incgsbyte(unsigned long); +void __incgsdword(unsigned long); +void __incgsqword(unsigned long); +void __incgsword(unsigned long); +void __movsq(unsigned long long *, unsigned long long const *, size_t); +unsigned char __readgsbyte(unsigned long); +unsigned long __readgsdword(unsigned long); +unsigned __int64 __readgsqword(unsigned long); +unsigned short __readgsword(unsigned long); +void __stosq(unsigned __int64 *, unsigned __int64, size_t); +unsigned char __vmx_on(unsigned __int64 *); +unsigned char __vmx_vmclear(unsigned __int64 *); +unsigned char __vmx_vmlaunch(void); +unsigned char __vmx_vmptrld(unsigned __int64 *); +unsigned char __vmx_vmread(size_t, size_t *); +unsigned char __vmx_vmresume(void); +unsigned char __vmx_vmwrite(size_t, size_t); +void __writegsbyte(unsigned long, unsigned char); +void __writegsdword(unsigned long, unsigned long); +void __writegsqword(unsigned long, unsigned __int64); +void __writegsword(unsigned long, unsigned short); +unsigned char _bittest64(__int64 const *, __int64); +unsigned char _bittestandcomplement64(__int64 *, __int64); +unsigned char _bittestandreset64(__int64 *, __int64); +unsigned char _bittestandset64(__int64 *, __int64); +long _InterlockedAnd_np(long volatile *_Value, long _Mask); +short _InterlockedAnd16_np(short volatile *_Value, short _Mask); +__int64 _InterlockedAnd64_np(__int64 volatile *_Value, __int64 _Mask); +char _InterlockedAnd8_np(char volatile *_Value, char _Mask); +unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64); +unsigned char _interlockedbittestandset64(__int64 volatile *, __int64); +long _InterlockedCompareExchange_np(long volatile *_Destination, long _Exchange, + long _Comparand); +unsigned char _InterlockedCompareExchange128_np(__int64 volatile *_Destination, + __int64 _ExchangeHigh, + __int64 _ExchangeLow, + __int64 *_ComparandResult); +short _InterlockedCompareExchange16_np(short volatile *_Destination, + short _Exchange, short _Comparand); +__int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination, + __int64 _Exchange, __int64 _Comparand); +void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination, + void *_Exchange, void *_Comparand); +long _InterlockedOr_np(long volatile *_Value, long _Mask); +short _InterlockedOr16_np(short volatile *_Value, short _Mask); +__int64 _InterlockedOr64_np(__int64 volatile *_Value, __int64 _Mask); +char _InterlockedOr8_np(char volatile *_Value, char _Mask); +long _InterlockedXor_np(long volatile *_Value, long _Mask); +short _InterlockedXor16_np(short volatile *_Value, short _Mask); +__int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask); +char _InterlockedXor8_np(char volatile *_Value, char _Mask); +unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int); +__int64 _sarx_i64(__int64, unsigned int); +unsigned __int64 _shlx_u64(unsigned __int64, unsigned int); +unsigned __int64 _shrx_u64(unsigned __int64, unsigned int); +__int64 __mulh(__int64, __int64); +unsigned __int64 __umulh(unsigned __int64, unsigned __int64); +__int64 _mul128(__int64, __int64, __int64 *); + +#endif /* __x86_64__ */ + +/*----------------------------------------------------------------------------*\ +|* movs, stos +\*----------------------------------------------------------------------------*/ + +#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) +static __inline__ void __DEFAULT_FN_ATTRS __movsb(unsigned char *__dst, + unsigned char const *__src, + size_t __n) { +#if defined(__x86_64__) + __asm__ __volatile__("rep movsb" + : "+D"(__dst), "+S"(__src), "+c"(__n) + : + : "memory"); +#else + __asm__ __volatile__("xchg {%%esi, %1|%1, esi}\n" + "rep movsb\n" + "xchg {%%esi, %1|%1, esi}" + : "+D"(__dst), "+r"(__src), "+c"(__n) + : + : "memory"); +#endif +} +static __inline__ void __DEFAULT_FN_ATTRS __movsd(unsigned long *__dst, + unsigned long const *__src, + size_t __n) { +#if defined(__x86_64__) + __asm__ __volatile__("rep movs{l|d}" + : "+D"(__dst), "+S"(__src), "+c"(__n) + : + : "memory"); +#else + __asm__ __volatile__("xchg {%%esi, %1|%1, esi}\n" + "rep movs{l|d}\n" + "xchg {%%esi, %1|%1, esi}" + : "+D"(__dst), "+r"(__src), "+c"(__n) + : + : "memory"); +#endif +} +static __inline__ void __DEFAULT_FN_ATTRS __movsw(unsigned short *__dst, + unsigned short const *__src, + size_t __n) { +#if defined(__x86_64__) + __asm__ __volatile__("rep movsw" + : "+D"(__dst), "+S"(__src), "+c"(__n) + : + : "memory"); +#else + __asm__ __volatile__("xchg {%%esi, %1|%1, esi}\n" + "rep movsw\n" + "xchg {%%esi, %1|%1, esi}" + : "+D"(__dst), "+r"(__src), "+c"(__n) + : + : "memory"); +#endif +} +static __inline__ void __DEFAULT_FN_ATTRS __stosd(unsigned long *__dst, + unsigned long __x, + size_t __n) { + __asm__ __volatile__("rep stos{l|d}" + : "+D"(__dst), "+c"(__n) + : "a"(__x) + : "memory"); +} +static __inline__ void __DEFAULT_FN_ATTRS __stosw(unsigned short *__dst, + unsigned short __x, + size_t __n) { + __asm__ __volatile__("rep stosw" + : "+D"(__dst), "+c"(__n) + : "a"(__x) + : "memory"); +} +#endif +#if defined(__x86_64__) && !defined(__arm64ec__) +static __inline__ void __DEFAULT_FN_ATTRS __movsq( + unsigned long long *__dst, unsigned long long const *__src, size_t __n) { + __asm__ __volatile__("rep movsq" + : "+D"(__dst), "+S"(__src), "+c"(__n) + : + : "memory"); +} +static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned __int64 *__dst, + unsigned __int64 __x, + size_t __n) { + __asm__ __volatile__("rep stosq" : "+D"(__dst), "+c"(__n) : "a"(__x) + : "memory"); +} +#endif + +/*----------------------------------------------------------------------------*\ +|* Misc +\*----------------------------------------------------------------------------*/ +#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) +static __inline__ void __DEFAULT_FN_ATTRS __halt(void) { + __asm__ volatile("hlt"); +} + +static __inline__ unsigned char __inbyte(unsigned short port) { + unsigned char ret; + __asm__ __volatile__("inb %w1, %b0" : "=a"(ret) : "Nd"(port)); + return ret; +} + +static __inline__ unsigned short __inword(unsigned short port) { + unsigned short ret; + __asm__ __volatile__("inw %w1, %w0" : "=a"(ret) : "Nd"(port)); + return ret; +} + +static __inline__ unsigned long __indword(unsigned short port) { + unsigned long ret; + __asm__ __volatile__("inl %w1, %k0" : "=a"(ret) : "Nd"(port)); + return ret; +} + +static __inline__ void __outbyte(unsigned short port, unsigned char data) { + __asm__ __volatile__("outb %b0, %w1" : : "a"(data), "Nd"(port)); +} + +static __inline__ void __outword(unsigned short port, unsigned short data) { + __asm__ __volatile__("outw %w0, %w1" : : "a"(data), "Nd"(port)); +} + +static __inline__ void __outdword(unsigned short port, unsigned long data) { + __asm__ __volatile__("outl %k0, %w1" : : "a"(data), "Nd"(port)); +} +#endif + +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) +static __inline__ void __DEFAULT_FN_ATTRS __nop(void) { + __asm__ volatile("nop"); +} +#endif + +/*----------------------------------------------------------------------------*\ +|* MS AArch64 specific +\*----------------------------------------------------------------------------*/ +#if defined(__aarch64__) || defined(__arm64ec__) +unsigned __int64 __getReg(int); +unsigned char _interlockedbittestandreset_acq(long volatile *, long); +unsigned char _interlockedbittestandreset_nf(long volatile *, long); +unsigned char _interlockedbittestandreset_rel(long volatile *, long); +unsigned char _interlockedbittestandreset64_acq(__int64 volatile *, __int64); +unsigned char _interlockedbittestandreset64_nf(__int64 volatile *, __int64); +unsigned char _interlockedbittestandreset64_rel(__int64 volatile *, __int64); +unsigned char _interlockedbittestandset_acq(long volatile *, long); +unsigned char _interlockedbittestandset_nf(long volatile *, long); +unsigned char _interlockedbittestandset_rel(long volatile *, long); +unsigned char _interlockedbittestandset64_acq(__int64 volatile *, __int64); +unsigned char _interlockedbittestandset64_nf(__int64 volatile *, __int64); +unsigned char _interlockedbittestandset64_rel(__int64 volatile *, __int64); +long _InterlockedAdd(long volatile *, long); +long _InterlockedAdd_acq(long volatile *, long); +long _InterlockedAdd_nf(long volatile *, long); +long _InterlockedAdd_rel(long volatile *, long); +__int64 _InterlockedAdd64(__int64 volatile *, __int64); +__int64 _InterlockedAdd64_acq(__int64 volatile *, __int64); +__int64 _InterlockedAdd64_nf(__int64 volatile *, __int64); +__int64 _InterlockedAdd64_rel(__int64 volatile *, __int64); +__int64 _ReadStatusReg(int); +void _WriteStatusReg(int, __int64); +unsigned int __sys(int, __int64); + +unsigned short __cdecl _byteswap_ushort(unsigned short val); +unsigned long __cdecl _byteswap_ulong (unsigned long val); +unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val); + +__int64 __mulh(__int64 __a, __int64 __b); +unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b); + +void __break(int); + +void __writex18byte(unsigned long offset, unsigned char data); +void __writex18word(unsigned long offset, unsigned short data); +void __writex18dword(unsigned long offset, unsigned long data); +void __writex18qword(unsigned long offset, unsigned __int64 data); + +unsigned char __readx18byte(unsigned long offset); +unsigned short __readx18word(unsigned long offset); +unsigned long __readx18dword(unsigned long offset); +unsigned __int64 __readx18qword(unsigned long offset); + +void __addx18byte(unsigned long offset, unsigned char data); +void __addx18word(unsigned long offset, unsigned short data); +void __addx18dword(unsigned long offset, unsigned long data); +void __addx18qword(unsigned long offset, unsigned __int64 data); + +void __incx18byte(unsigned long offset); +void __incx18word(unsigned long offset); +void __incx18dword(unsigned long offset); +void __incx18qword(unsigned long offset); + +double _CopyDoubleFromInt64(__int64); +float _CopyFloatFromInt32(__int32); +__int32 _CopyInt32FromFloat(float); +__int64 _CopyInt64FromDouble(double); + +unsigned int _CountLeadingOnes(unsigned long); +unsigned int _CountLeadingOnes64(unsigned __int64); +unsigned int _CountLeadingSigns(long); +unsigned int _CountLeadingSigns64(__int64); +unsigned int _CountOneBits(unsigned long); +unsigned int _CountOneBits64(unsigned __int64); + +unsigned int __hlt(unsigned int, ...); + +void __cdecl __prefetch(const void *); + +#endif + +/*----------------------------------------------------------------------------*\ +|* Privileged intrinsics +\*----------------------------------------------------------------------------*/ +#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) +static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS +__readmsr(unsigned long __register) { + // Loads the contents of a 64-bit model specific register (MSR) specified in + // the ECX register into registers EDX:EAX. The EDX register is loaded with + // the high-order 32 bits of the MSR and the EAX register is loaded with the + // low-order 32 bits. If less than 64 bits are implemented in the MSR being + // read, the values returned to EDX:EAX in unimplemented bit locations are + // undefined. + unsigned long __edx; + unsigned long __eax; + __asm__ ("rdmsr" : "=d"(__edx), "=a"(__eax) : "c"(__register)); + return (((unsigned __int64)__edx) << 32) | (unsigned __int64)__eax; +} + +static __inline__ unsigned __LPTRINT_TYPE__ __DEFAULT_FN_ATTRS __readcr3(void) { + unsigned __LPTRINT_TYPE__ __cr3_val; + __asm__ __volatile__( + "mov {%%cr3, %0|%0, cr3}" + : "=r"(__cr3_val) + : + : "memory"); + return __cr3_val; +} + +static __inline__ void __DEFAULT_FN_ATTRS +__writecr3(unsigned __INTPTR_TYPE__ __cr3_val) { + __asm__ ("mov {%0, %%cr3|cr3, %0}" : : "r"(__cr3_val) : "memory"); +} +#endif + +#ifdef __cplusplus +} +#endif + +#undef __LPTRINT_TYPE__ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __INTRIN_H */ +#endif /* _MSC_VER */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/intrin0.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/intrin0.h new file mode 100755 index 0000000..2bca9fc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/intrin0.h @@ -0,0 +1,256 @@ +/* ===-------- intrin.h ---------------------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Only include this if we're compiling for the windows platform. */ +#ifndef _MSC_VER +#include_next +#else + +#ifndef __INTRIN0_H +#define __INTRIN0_H + +#if defined(__x86_64__) && !defined(__arm64ec__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask); +unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask); +void _ReadWriteBarrier(void); + +#if defined(__aarch64__) || defined(__arm64ec__) +unsigned int _CountLeadingZeros(unsigned long); +unsigned int _CountLeadingZeros64(unsigned _int64); +unsigned char _InterlockedCompareExchange128_acq(__int64 volatile *_Destination, + __int64 _ExchangeHigh, + __int64 _ExchangeLow, + __int64 *_ComparandResult); +unsigned char _InterlockedCompareExchange128_nf(__int64 volatile *_Destination, + __int64 _ExchangeHigh, + __int64 _ExchangeLow, + __int64 *_ComparandResult); +unsigned char _InterlockedCompareExchange128_rel(__int64 volatile *_Destination, + __int64 _ExchangeHigh, + __int64 _ExchangeLow, + __int64 *_ComparandResult); +#endif + +#if defined(__x86_64__) && !defined(__arm64ec__) +unsigned __int64 _umul128(unsigned __int64, unsigned __int64, + unsigned __int64 *); +unsigned __int64 __shiftleft128(unsigned __int64 _LowPart, + unsigned __int64 _HighPart, + unsigned char _Shift); +unsigned __int64 __shiftright128(unsigned __int64 _LowPart, + unsigned __int64 _HighPart, + unsigned char _Shift); +#endif + +#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) +void _mm_pause(void); +#endif + +#if defined(__x86_64__) || defined(__aarch64__) +unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination, + __int64 _ExchangeHigh, + __int64 _ExchangeLow, + __int64 *_ComparandResult); +#endif + +#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) +unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask); +unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask); +#endif + +#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ + defined(__aarch64__) +__int64 _InterlockedDecrement64(__int64 volatile *_Addend); +__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); +__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); +__int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value); +__int64 _InterlockedIncrement64(__int64 volatile *_Addend); +__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask); +#endif + +#if defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__) +/*----------------------------------------------------------------------------*\ +|* Interlocked Exchange Add +\*----------------------------------------------------------------------------*/ +char _InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value); +char _InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value); +char _InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value); +short _InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value); +short _InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value); +short _InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value); +long _InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value); +long _InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value); +long _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value); +__int64 _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, + __int64 _Value); +__int64 _InterlockedExchangeAdd64_nf(__int64 volatile *_Addend, __int64 _Value); +__int64 _InterlockedExchangeAdd64_rel(__int64 volatile *_Addend, + __int64 _Value); + +/*----------------------------------------------------------------------------*\ +|* Interlocked Increment +\*----------------------------------------------------------------------------*/ +short _InterlockedIncrement16_acq(short volatile *_Value); +short _InterlockedIncrement16_nf(short volatile *_Value); +short _InterlockedIncrement16_rel(short volatile *_Value); +long _InterlockedIncrement_acq(long volatile *_Value); +long _InterlockedIncrement_nf(long volatile *_Value); +long _InterlockedIncrement_rel(long volatile *_Value); +__int64 _InterlockedIncrement64_acq(__int64 volatile *_Value); +__int64 _InterlockedIncrement64_nf(__int64 volatile *_Value); +__int64 _InterlockedIncrement64_rel(__int64 volatile *_Value); + +/*----------------------------------------------------------------------------*\ +|* Interlocked Decrement +\*----------------------------------------------------------------------------*/ +short _InterlockedDecrement16_acq(short volatile *_Value); +short _InterlockedDecrement16_nf(short volatile *_Value); +short _InterlockedDecrement16_rel(short volatile *_Value); +long _InterlockedDecrement_acq(long volatile *_Value); +long _InterlockedDecrement_nf(long volatile *_Value); +long _InterlockedDecrement_rel(long volatile *_Value); +__int64 _InterlockedDecrement64_acq(__int64 volatile *_Value); +__int64 _InterlockedDecrement64_nf(__int64 volatile *_Value); +__int64 _InterlockedDecrement64_rel(__int64 volatile *_Value); + +/*----------------------------------------------------------------------------*\ +|* Interlocked And +\*----------------------------------------------------------------------------*/ +char _InterlockedAnd8_acq(char volatile *_Value, char _Mask); +char _InterlockedAnd8_nf(char volatile *_Value, char _Mask); +char _InterlockedAnd8_rel(char volatile *_Value, char _Mask); +short _InterlockedAnd16_acq(short volatile *_Value, short _Mask); +short _InterlockedAnd16_nf(short volatile *_Value, short _Mask); +short _InterlockedAnd16_rel(short volatile *_Value, short _Mask); +long _InterlockedAnd_acq(long volatile *_Value, long _Mask); +long _InterlockedAnd_nf(long volatile *_Value, long _Mask); +long _InterlockedAnd_rel(long volatile *_Value, long _Mask); +__int64 _InterlockedAnd64_acq(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedAnd64_nf(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedAnd64_rel(__int64 volatile *_Value, __int64 _Mask); + +/*----------------------------------------------------------------------------*\ +|* Bit Counting and Testing +\*----------------------------------------------------------------------------*/ +unsigned char _interlockedbittestandset_acq(long volatile *_BitBase, + long _BitPos); +unsigned char _interlockedbittestandset_nf(long volatile *_BitBase, + long _BitPos); +unsigned char _interlockedbittestandset_rel(long volatile *_BitBase, + long _BitPos); +unsigned char _interlockedbittestandreset_acq(long volatile *_BitBase, + long _BitPos); +unsigned char _interlockedbittestandreset_nf(long volatile *_BitBase, + long _BitPos); +unsigned char _interlockedbittestandreset_rel(long volatile *_BitBase, + long _BitPos); + +/*----------------------------------------------------------------------------*\ +|* Interlocked Or +\*----------------------------------------------------------------------------*/ +char _InterlockedOr8_acq(char volatile *_Value, char _Mask); +char _InterlockedOr8_nf(char volatile *_Value, char _Mask); +char _InterlockedOr8_rel(char volatile *_Value, char _Mask); +short _InterlockedOr16_acq(short volatile *_Value, short _Mask); +short _InterlockedOr16_nf(short volatile *_Value, short _Mask); +short _InterlockedOr16_rel(short volatile *_Value, short _Mask); +long _InterlockedOr_acq(long volatile *_Value, long _Mask); +long _InterlockedOr_nf(long volatile *_Value, long _Mask); +long _InterlockedOr_rel(long volatile *_Value, long _Mask); +__int64 _InterlockedOr64_acq(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedOr64_nf(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedOr64_rel(__int64 volatile *_Value, __int64 _Mask); + +/*----------------------------------------------------------------------------*\ +|* Interlocked Xor +\*----------------------------------------------------------------------------*/ +char _InterlockedXor8_acq(char volatile *_Value, char _Mask); +char _InterlockedXor8_nf(char volatile *_Value, char _Mask); +char _InterlockedXor8_rel(char volatile *_Value, char _Mask); +short _InterlockedXor16_acq(short volatile *_Value, short _Mask); +short _InterlockedXor16_nf(short volatile *_Value, short _Mask); +short _InterlockedXor16_rel(short volatile *_Value, short _Mask); +long _InterlockedXor_acq(long volatile *_Value, long _Mask); +long _InterlockedXor_nf(long volatile *_Value, long _Mask); +long _InterlockedXor_rel(long volatile *_Value, long _Mask); +__int64 _InterlockedXor64_acq(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedXor64_nf(__int64 volatile *_Value, __int64 _Mask); +__int64 _InterlockedXor64_rel(__int64 volatile *_Value, __int64 _Mask); + +/*----------------------------------------------------------------------------*\ +|* Interlocked Exchange +\*----------------------------------------------------------------------------*/ +char _InterlockedExchange8_acq(char volatile *_Target, char _Value); +char _InterlockedExchange8_nf(char volatile *_Target, char _Value); +char _InterlockedExchange8_rel(char volatile *_Target, char _Value); +short _InterlockedExchange16_acq(short volatile *_Target, short _Value); +short _InterlockedExchange16_nf(short volatile *_Target, short _Value); +short _InterlockedExchange16_rel(short volatile *_Target, short _Value); +long _InterlockedExchange_acq(long volatile *_Target, long _Value); +long _InterlockedExchange_nf(long volatile *_Target, long _Value); +long _InterlockedExchange_rel(long volatile *_Target, long _Value); +__int64 _InterlockedExchange64_acq(__int64 volatile *_Target, __int64 _Value); +__int64 _InterlockedExchange64_nf(__int64 volatile *_Target, __int64 _Value); +__int64 _InterlockedExchange64_rel(__int64 volatile *_Target, __int64 _Value); +void *_InterlockedExchangePointer_acq(void *volatile *_Target, void *_Value); +void *_InterlockedExchangePointer_nf(void *volatile *_Target, void *_Value); +void *_InterlockedExchangePointer_rel(void *volatile *_Target, void *_Value); + +/*----------------------------------------------------------------------------*\ +|* Interlocked Compare Exchange +\*----------------------------------------------------------------------------*/ +char _InterlockedCompareExchange8_acq(char volatile *_Destination, + char _Exchange, char _Comparand); +char _InterlockedCompareExchange8_nf(char volatile *_Destination, + char _Exchange, char _Comparand); +char _InterlockedCompareExchange8_rel(char volatile *_Destination, + char _Exchange, char _Comparand); +short _InterlockedCompareExchange16_acq(short volatile *_Destination, + short _Exchange, short _Comparand); +short _InterlockedCompareExchange16_nf(short volatile *_Destination, + short _Exchange, short _Comparand); +short _InterlockedCompareExchange16_rel(short volatile *_Destination, + short _Exchange, short _Comparand); +long _InterlockedCompareExchange_acq(long volatile *_Destination, + long _Exchange, long _Comparand); +long _InterlockedCompareExchange_nf(long volatile *_Destination, long _Exchange, + long _Comparand); +long _InterlockedCompareExchange_rel(long volatile *_Destination, + long _Exchange, long _Comparand); +__int64 _InterlockedCompareExchange64_acq(__int64 volatile *_Destination, + __int64 _Exchange, + __int64 _Comparand); +__int64 _InterlockedCompareExchange64_nf(__int64 volatile *_Destination, + __int64 _Exchange, __int64 _Comparand); +__int64 _InterlockedCompareExchange64_rel(__int64 volatile *_Destination, + __int64 _Exchange, + __int64 _Comparand); +void *_InterlockedCompareExchangePointer_acq(void *volatile *_Destination, + void *_Exchange, void *_Comparand); +void *_InterlockedCompareExchangePointer_nf(void *volatile *_Destination, + void *_Exchange, void *_Comparand); +void *_InterlockedCompareExchangePointer_rel(void *volatile *_Destination, + void *_Exchange, void *_Comparand); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __INTRIN0_H */ +#endif /* _MSC_VER */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/inttypes.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/inttypes.h new file mode 100755 index 0000000..5150d22 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/inttypes.h @@ -0,0 +1,101 @@ +/*===---- inttypes.h - Standard header for integer printf macros ----------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_INTTYPES_H +// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. +#if !defined(_AIX) || !defined(_STD_TYPES_T) +#define __CLANG_INTTYPES_H +#endif +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +#if defined(_MSC_VER) && _MSC_VER < 1800 +#error MSVC does not have inttypes.h prior to Visual Studio 2013 +#endif + +#include_next + +#if defined(_MSC_VER) && _MSC_VER < 1900 +/* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x". + * This triggers format warnings, so fix it up here. */ +#undef PRId32 +#undef PRIdLEAST32 +#undef PRIdFAST32 +#undef PRIi32 +#undef PRIiLEAST32 +#undef PRIiFAST32 +#undef PRIo32 +#undef PRIoLEAST32 +#undef PRIoFAST32 +#undef PRIu32 +#undef PRIuLEAST32 +#undef PRIuFAST32 +#undef PRIx32 +#undef PRIxLEAST32 +#undef PRIxFAST32 +#undef PRIX32 +#undef PRIXLEAST32 +#undef PRIXFAST32 + +#undef SCNd32 +#undef SCNdLEAST32 +#undef SCNdFAST32 +#undef SCNi32 +#undef SCNiLEAST32 +#undef SCNiFAST32 +#undef SCNo32 +#undef SCNoLEAST32 +#undef SCNoFAST32 +#undef SCNu32 +#undef SCNuLEAST32 +#undef SCNuFAST32 +#undef SCNx32 +#undef SCNxLEAST32 +#undef SCNxFAST32 + +#define PRId32 "d" +#define PRIdLEAST32 "d" +#define PRIdFAST32 "d" +#define PRIi32 "i" +#define PRIiLEAST32 "i" +#define PRIiFAST32 "i" +#define PRIo32 "o" +#define PRIoLEAST32 "o" +#define PRIoFAST32 "o" +#define PRIu32 "u" +#define PRIuLEAST32 "u" +#define PRIuFAST32 "u" +#define PRIx32 "x" +#define PRIxLEAST32 "x" +#define PRIxFAST32 "x" +#define PRIX32 "X" +#define PRIXLEAST32 "X" +#define PRIXFAST32 "X" + +#define SCNd32 "d" +#define SCNdLEAST32 "d" +#define SCNdFAST32 "d" +#define SCNi32 "i" +#define SCNiLEAST32 "i" +#define SCNiFAST32 "i" +#define SCNo32 "o" +#define SCNoLEAST32 "o" +#define SCNoFAST32 "o" +#define SCNu32 "u" +#define SCNuLEAST32 "u" +#define SCNuFAST32 "u" +#define SCNx32 "x" +#define SCNxLEAST32 "x" +#define SCNxFAST32 "x" +#endif + +#endif /* __MVS__ */ +#endif /* __CLANG_INTTYPES_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/invpcidintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/invpcidintrin.h new file mode 100755 index 0000000..48dae0a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/invpcidintrin.h @@ -0,0 +1,23 @@ +/*===------------- invpcidintrin.h - INVPCID intrinsic ---------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __INVPCIDINTRIN_H +#define __INVPCIDINTRIN_H + +static __inline__ void + __attribute__((__always_inline__, __nodebug__, __target__("invpcid"))) +_invpcid(unsigned int __type, void *__descriptor) { + __builtin_ia32_invpcid(__type, __descriptor); +} + +#endif /* __INVPCIDINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/iso646.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/iso646.h new file mode 100755 index 0000000..b53fcd9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/iso646.h @@ -0,0 +1,31 @@ +/*===---- iso646.h - Standard header for alternate spellings of operators---=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __ISO646_H +#define __ISO646_H +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +#ifndef __cplusplus +#define and && +#define and_eq &= +#define bitand & +#define bitor | +#define compl ~ +#define not ! +#define not_eq != +#define or || +#define or_eq |= +#define xor ^ +#define xor_eq ^= +#endif + +#endif /* __MVS__ */ +#endif /* __ISO646_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/keylockerintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/keylockerintrin.h new file mode 100755 index 0000000..4e9e6be --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/keylockerintrin.h @@ -0,0 +1,518 @@ +/*===----------------- keylockerintrin.h - KL Intrinsics -------------------=== + * + * 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. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef _KEYLOCKERINTRIN_H +#define _KEYLOCKERINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("kl"),\ + __min_vector_width__(128))) + +/// Load internal wrapping key from __intkey, __enkey_lo and __enkey_hi. __ctl +/// will assigned to EAX, whch specifies the KeySource and whether backing up +/// the key is permitted. The 256-bit encryption key is loaded from the two +/// explicit operands (__enkey_lo and __enkey_hi). The 128-bit integrity key is +/// loaded from the implicit operand XMM0 which assigned by __intkey. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LOADIWKEY instructions. +/// +/// \code{.operation} +/// IF CPL > 0 // LOADKWKEY only allowed at ring 0 (supervisor mode) +/// GP (0) +/// FI +/// IF β€œLOADIWKEY exiting” VM execution control set +/// VMexit +/// FI +/// IF __ctl[4:1] > 1 // Reserved KeySource encoding used +/// GP (0) +/// FI +/// IF __ctl[31:5] != 0 // Reserved bit in __ctl is set +/// GP (0) +/// FI +/// IF __ctl[0] AND (CPUID.19H.ECX[0] == 0) // NoBackup is not supported on this part +/// GP (0) +/// FI +/// IF (__ctl[4:1] == 1) AND (CPUID.19H.ECX[1] == 0) // KeySource of 1 is not supported on this part +/// GP (0) +/// FI +/// IF (__ctl[4:1] == 0) // KeySource of 0. +/// IWKey.Encryption Key[127:0] := __enkey_hi[127:0]: +/// IWKey.Encryption Key[255:128] := __enkey_lo[127:0] +/// IWKey.IntegrityKey[127:0] := __intkey[127:0] +/// IWKey.NoBackup := __ctl[0] +/// IWKey.KeySource := __ctl[4:1] +/// ZF := 0 +/// ELSE // KeySource of 1. See RDSEED definition for details of randomness +/// IF HW_NRND_GEN.ready == 1 // Full-entropy random data from RDSEED was received +/// IWKey.Encryption Key[127:0] := __enkey_hi[127:0] XOR HW_NRND_GEN.data[127:0] +/// IWKey.Encryption Key[255:128] := __enkey_lo[127:0] XOR HW_NRND_GEN.data[255:128] +/// IWKey.Encryption Key[255:0] := __enkey_hi[127:0]:__enkey_lo[127:0] XOR HW_NRND_GEN.data[255:0] +/// IWKey.IntegrityKey[127:0] := __intkey[127:0] XOR HW_NRND_GEN.data[383:256] +/// IWKey.NoBackup := __ctl[0] +/// IWKey.KeySource := __ctl[4:1] +/// ZF := 0 +/// ELSE // Random data was not returned from RDSEED. IWKey was not loaded +/// ZF := 1 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS +_mm_loadiwkey (unsigned int __ctl, __m128i __intkey, + __m128i __enkey_lo, __m128i __enkey_hi) { + __builtin_ia32_loadiwkey (__intkey, __enkey_lo, __enkey_hi, __ctl); +} + +/// Wrap a 128-bit AES key from __key into a key handle and output in +/// ((__m128i*)__h) to ((__m128i*)__h) + 2 and a 32-bit value as return. +/// The explicit source operand __htype specifies handle restrictions. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the ENCODEKEY128 instructions. +/// +/// \code{.operation} +/// InputKey[127:0] := __key[127:0] +/// KeyMetadata[2:0] := __htype[2:0] +/// KeyMetadata[23:3] := 0 // Reserved for future usage +/// KeyMetadata[27:24] := 0 // KeyType is AES-128 (value of 0) +/// KeyMetadata[127:28] := 0 // Reserved for future usage +/// Handle[383:0] := WrapKey128(InputKey[127:0], KeyMetadata[127:0], +/// IWKey.Integrity Key[127:0], IWKey.Encryption Key[255:0]) +/// dst[0] := IWKey.NoBackup +/// dst[4:1] := IWKey.KeySource[3:0] +/// dst[31:5] := 0 +/// MEM[__h+127:__h] := Handle[127:0] // AAD +/// MEM[__h+255:__h+128] := Handle[255:128] // Integrity Tag +/// MEM[__h+383:__h+256] := Handle[383:256] // CipherText +/// OF := 0 +/// SF := 0 +/// ZF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mm_encodekey128_u32(unsigned int __htype, __m128i __key, void *__h) { + return __builtin_ia32_encodekey128_u32(__htype, (__v2di)__key, __h); +} + +/// Wrap a 256-bit AES key from __key_hi:__key_lo into a key handle, then +/// output handle in ((__m128i*)__h) to ((__m128i*)__h) + 3 and +/// a 32-bit value as return. +/// The explicit source operand __htype specifies handle restrictions. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the ENCODEKEY256 instructions. +/// +/// \code{.operation} +/// InputKey[127:0] := __key_lo[127:0] +/// InputKey[255:128] := __key_hi[255:128] +/// KeyMetadata[2:0] := __htype[2:0] +/// KeyMetadata[23:3] := 0 // Reserved for future usage +/// KeyMetadata[27:24] := 1 // KeyType is AES-256 (value of 1) +/// KeyMetadata[127:28] := 0 // Reserved for future usage +/// Handle[511:0] := WrapKey256(InputKey[255:0], KeyMetadata[127:0], +/// IWKey.Integrity Key[127:0], IWKey.Encryption Key[255:0]) +/// dst[0] := IWKey.NoBackup +/// dst[4:1] := IWKey.KeySource[3:0] +/// dst[31:5] := 0 +/// MEM[__h+127:__h] := Handle[127:0] // AAD +/// MEM[__h+255:__h+128] := Handle[255:128] // Tag +/// MEM[__h+383:__h+256] := Handle[383:256] // CipherText[127:0] +/// MEM[__h+511:__h+384] := Handle[511:384] // CipherText[255:128] +/// OF := 0 +/// SF := 0 +/// ZF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_mm_encodekey256_u32(unsigned int __htype, __m128i __key_lo, __m128i __key_hi, + void *__h) { + return __builtin_ia32_encodekey256_u32(__htype, (__v2di)__key_lo, + (__v2di)__key_hi, __h); +} + +/// The AESENC128KL performs 10 rounds of AES to encrypt the __idata using +/// the 128-bit key in the handle from the __h. It stores the result in the +/// __odata. And return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESENC128KL instructions. +/// +/// \code{.operation} +/// Handle[383:0] := MEM[__h+383:__h] // Load is not guaranteed to be atomic. +/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[383:256] || +/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128 ) +/// IF (IllegalHandle) +/// ZF := 1 +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey) +/// IF (Authentic == 0) +/// ZF := 1 +/// ELSE +/// MEM[__odata+127:__odata] := AES128Encrypt (__idata[127:0], UnwrappedKey) +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesenc128kl_u8(__m128i* __odata, __m128i __idata, const void *__h) { + return __builtin_ia32_aesenc128kl_u8((__v2di *)__odata, (__v2di)__idata, __h); +} + +/// The AESENC256KL performs 14 rounds of AES to encrypt the __idata using +/// the 256-bit key in the handle from the __h. It stores the result in the +/// __odata. And return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESENC256KL instructions. +/// +/// \code{.operation} +/// Handle[511:0] := MEM[__h+511:__h] // Load is not guaranteed to be atomic. +/// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[255:128] || +/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES256 ) +/// IF (IllegalHandle) +/// ZF := 1 +/// MEM[__odata+127:__odata] := 0 +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey) +/// IF (Authentic == 0) +/// ZF := 1 +/// MEM[__odata+127:__odata] := 0 +/// ELSE +/// MEM[__odata+127:__odata] := AES256Encrypt (__idata[127:0], UnwrappedKey) +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesenc256kl_u8(__m128i* __odata, __m128i __idata, const void *__h) { + return __builtin_ia32_aesenc256kl_u8((__v2di *)__odata, (__v2di)__idata, __h); +} + +/// The AESDEC128KL performs 10 rounds of AES to decrypt the __idata using +/// the 128-bit key in the handle from the __h. It stores the result in the +/// __odata. And return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESDEC128KL instructions. +/// +/// \code{.operation} +/// Handle[383:0] := MEM[__h+383:__h] // Load is not guaranteed to be atomic. +/// IllegalHandle := (HandleReservedBitSet (Handle[383:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[383:256] || +/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128) +/// IF (IllegalHandle) +/// ZF := 1 +/// MEM[__odata+127:__odata] := 0 +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey) +/// IF (Authentic == 0) +/// ZF := 1 +/// MEM[__odata+127:__odata] := 0 +/// ELSE +/// MEM[__odata+127:__odata] := AES128Decrypt (__idata[127:0], UnwrappedKey) +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesdec128kl_u8(__m128i* __odata, __m128i __idata, const void *__h) { + return __builtin_ia32_aesdec128kl_u8((__v2di *)__odata, (__v2di)__idata, __h); +} + +/// The AESDEC256KL performs 10 rounds of AES to decrypt the __idata using +/// the 256-bit key in the handle from the __h. It stores the result in the +/// __odata. And return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESDEC256KL instructions. +/// +/// \code{.operation} +/// Handle[511:0] := MEM[__h+511:__h] +/// IllegalHandle := (HandleReservedBitSet (Handle[511:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[383:256] || +/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES256) +/// IF (IllegalHandle) +/// ZF := 1 +/// MEM[__odata+127:__odata] := 0 +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey) +/// IF (Authentic == 0) +/// ZF := 1 +/// MEM[__odata+127:__odata] := 0 +/// ELSE +/// MEM[__odata+127:__odata] := AES256Decrypt (__idata[127:0], UnwrappedKey) +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesdec256kl_u8(__m128i* __odata, __m128i __idata, const void *__h) { + return __builtin_ia32_aesdec256kl_u8((__v2di *)__odata, (__v2di)__idata, __h); +} + +#undef __DEFAULT_FN_ATTRS + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("kl,widekl"),\ + __min_vector_width__(128))) + +/// Encrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle +/// at __h and store each resultant block back from __odata to __odata+7. And +/// return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESENCWIDE128KL instructions. +/// +/// \code{.operation} +/// Handle := MEM[__h+383:__h] +/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[255:128] || +/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128 ) +/// IF (IllegalHandle) +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey) +/// IF Authentic == 0 +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// FOR i := 0 to 7 +/// __odata[i] := AES128Encrypt (__idata[i], UnwrappedKey) +/// ENDFOR +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesencwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) { + return __builtin_ia32_aesencwide128kl_u8((__v2di *)__odata, + (const __v2di *)__idata, __h); +} + +/// Encrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle +/// at __h and store each resultant block back from __odata to __odata+7. And +/// return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESENCWIDE256KL instructions. +/// +/// \code{.operation} +/// Handle[511:0] := MEM[__h+511:__h] +/// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[255:128] || +/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES512 ) +/// IF (IllegalHandle) +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey) +/// IF Authentic == 0 +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// FOR i := 0 to 7 +/// __odata[i] := AES256Encrypt (__idata[i], UnwrappedKey) +/// ENDFOR +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesencwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) { + return __builtin_ia32_aesencwide256kl_u8((__v2di *)__odata, + (const __v2di *)__idata, __h); +} + +/// Decrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle +/// at __h and store each resultant block back from __odata to __odata+7. And +/// return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESDECWIDE128KL instructions. +/// +/// \code{.operation} +/// Handle[383:0] := MEM[__h+383:__h] +/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[255:128] || +/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES128 ) +/// IF (IllegalHandle) +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey) +/// IF Authentic == 0 +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// FOR i := 0 to 7 +/// __odata[i] := AES128Decrypt (__idata[i], UnwrappedKey) +/// ENDFOR +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesdecwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) { + return __builtin_ia32_aesdecwide128kl_u8((__v2di *)__odata, + (const __v2di *)__idata, __h); +} + +/// Decrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle +/// at __h and store each resultant block back from __odata to __odata+7. And +/// return the affected ZF flag status. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the AESDECWIDE256KL instructions. +/// +/// \code{.operation} +/// Handle[511:0] := MEM[__h+511:__h] +/// IllegalHandle = ( HandleReservedBitSet (Handle[511:0]) || +/// (Handle[127:0] AND (CPL > 0)) || +/// Handle[255:128] || +/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES512 ) +/// If (IllegalHandle) +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey) +/// IF Authentic == 0 +/// ZF := 1 +/// FOR i := 0 to 7 +/// __odata[i] := 0 +/// ENDFOR +/// ELSE +/// FOR i := 0 to 7 +/// __odata[i] := AES256Decrypt (__idata[i], UnwrappedKey) +/// ENDFOR +/// ZF := 0 +/// FI +/// FI +/// dst := ZF +/// OF := 0 +/// SF := 0 +/// AF := 0 +/// PF := 0 +/// CF := 0 +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_mm_aesdecwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) { + return __builtin_ia32_aesdecwide256kl_u8((__v2di *)__odata, + (const __v2di *)__idata, __h); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* _KEYLOCKERINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/larchintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/larchintrin.h new file mode 100755 index 0000000..a1247d1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/larchintrin.h @@ -0,0 +1,260 @@ +/*===------------ larchintrin.h - LoongArch intrinsics ---------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _LOONGARCH_BASE_INTRIN_H +#define _LOONGARCH_BASE_INTRIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rdtime { + unsigned int value; + unsigned int timeid; +} __rdtime_t; + +#if __loongarch_grlen == 64 +typedef struct drdtime { + unsigned long dvalue; + unsigned long dtimeid; +} __drdtime_t; + +extern __inline __drdtime_t + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __rdtime_d(void) { + __drdtime_t __drdtime; + __asm__ volatile( + "rdtime.d %[val], %[tid]\n\t" + : [val] "=&r"(__drdtime.dvalue), [tid] "=&r"(__drdtime.dtimeid)); + return __drdtime; +} +#endif + +extern __inline __rdtime_t + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __rdtimeh_w(void) { + __rdtime_t __rdtime; + __asm__ volatile("rdtimeh.w %[val], %[tid]\n\t" + : [val] "=&r"(__rdtime.value), [tid] "=&r"(__rdtime.timeid)); + return __rdtime; +} + +extern __inline __rdtime_t + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __rdtimel_w(void) { + __rdtime_t __rdtime; + __asm__ volatile("rdtimel.w %[val], %[tid]\n\t" + : [val] "=&r"(__rdtime.value), [tid] "=&r"(__rdtime.timeid)); + return __rdtime; +} + +#if __loongarch_grlen == 64 +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crc_w_b_w(char _1, int _2) { + return (int)__builtin_loongarch_crc_w_b_w((char)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crc_w_h_w(short _1, int _2) { + return (int)__builtin_loongarch_crc_w_h_w((short)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crc_w_w_w(int _1, int _2) { + return (int)__builtin_loongarch_crc_w_w_w((int)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crc_w_d_w(long int _1, int _2) { + return (int)__builtin_loongarch_crc_w_d_w((long int)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crcc_w_b_w(char _1, int _2) { + return (int)__builtin_loongarch_crcc_w_b_w((char)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crcc_w_h_w(short _1, int _2) { + return (int)__builtin_loongarch_crcc_w_h_w((short)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crcc_w_w_w(int _1, int _2) { + return (int)__builtin_loongarch_crcc_w_w_w((int)_1, (int)_2); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __crcc_w_d_w(long int _1, int _2) { + return (int)__builtin_loongarch_crcc_w_d_w((long int)_1, (int)_2); +} +#endif + +#define __break(/*ui15*/ _1) __builtin_loongarch_break((_1)) + +#if __loongarch_grlen == 32 +#define __cacop_w(/*uimm5*/ _1, /*unsigned int*/ _2, /*simm12*/ _3) \ + ((void)__builtin_loongarch_cacop_w((_1), (unsigned int)(_2), (_3))) +#endif + +#if __loongarch_grlen == 64 +#define __cacop_d(/*uimm5*/ _1, /*unsigned long int*/ _2, /*simm12*/ _3) \ + ((void)__builtin_loongarch_cacop_d((_1), (unsigned long int)(_2), (_3))) +#endif + +#define __dbar(/*ui15*/ _1) __builtin_loongarch_dbar((_1)) + +#define __ibar(/*ui15*/ _1) __builtin_loongarch_ibar((_1)) + +#define __movfcsr2gr(/*ui5*/ _1) __builtin_loongarch_movfcsr2gr((_1)); + +#define __movgr2fcsr(/*ui5*/ _1, _2) \ + __builtin_loongarch_movgr2fcsr((_1), (unsigned int)_2); + +#define __syscall(/*ui15*/ _1) __builtin_loongarch_syscall((_1)) + +#define __csrrd_w(/*ui14*/ _1) ((unsigned int)__builtin_loongarch_csrrd_w((_1))) + +#define __csrwr_w(/*unsigned int*/ _1, /*ui14*/ _2) \ + ((unsigned int)__builtin_loongarch_csrwr_w((unsigned int)(_1), (_2))) + +#define __csrxchg_w(/*unsigned int*/ _1, /*unsigned int*/ _2, /*ui14*/ _3) \ + ((unsigned int)__builtin_loongarch_csrxchg_w((unsigned int)(_1), \ + (unsigned int)(_2), (_3))) + +#if __loongarch_grlen == 64 +#define __csrrd_d(/*ui14*/ _1) \ + ((unsigned long int)__builtin_loongarch_csrrd_d((_1))) + +#define __csrwr_d(/*unsigned long int*/ _1, /*ui14*/ _2) \ + ((unsigned long int)__builtin_loongarch_csrwr_d((unsigned long int)(_1), \ + (_2))) + +#define __csrxchg_d(/*unsigned long int*/ _1, /*unsigned long int*/ _2, \ + /*ui14*/ _3) \ + ((unsigned long int)__builtin_loongarch_csrxchg_d( \ + (unsigned long int)(_1), (unsigned long int)(_2), (_3))) +#endif + +extern __inline unsigned char + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrrd_b(unsigned int _1) { + return (unsigned char)__builtin_loongarch_iocsrrd_b((unsigned int)_1); +} + +extern __inline unsigned short + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrrd_h(unsigned int _1) { + return (unsigned short)__builtin_loongarch_iocsrrd_h((unsigned int)_1); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrrd_w(unsigned int _1) { + return (unsigned int)__builtin_loongarch_iocsrrd_w((unsigned int)_1); +} + +#if __loongarch_grlen == 64 +extern __inline unsigned long int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrrd_d(unsigned int _1) { + return (unsigned long int)__builtin_loongarch_iocsrrd_d((unsigned int)_1); +} +#endif + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrwr_b(unsigned char _1, unsigned int _2) { + __builtin_loongarch_iocsrwr_b((unsigned char)_1, (unsigned int)_2); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrwr_h(unsigned short _1, unsigned int _2) { + __builtin_loongarch_iocsrwr_h((unsigned short)_1, (unsigned int)_2); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrwr_w(unsigned int _1, unsigned int _2) { + __builtin_loongarch_iocsrwr_w((unsigned int)_1, (unsigned int)_2); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __cpucfg(unsigned int _1) { + return (unsigned int)__builtin_loongarch_cpucfg((unsigned int)_1); +} + +#if __loongarch_grlen == 64 +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __iocsrwr_d(unsigned long int _1, unsigned int _2) { + __builtin_loongarch_iocsrwr_d((unsigned long int)_1, (unsigned int)_2); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __asrtgt_d(long int _1, long int _2) { + __builtin_loongarch_asrtgt_d((long int)_1, (long int)_2); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __asrtle_d(long int _1, long int _2) { + __builtin_loongarch_asrtle_d((long int)_1, (long int)_2); +} +#endif + +#if __loongarch_grlen == 64 +#define __lddir_d(/*long int*/ _1, /*ui5*/ _2) \ + ((long int)__builtin_loongarch_lddir_d((long int)(_1), (_2))) + +#define __ldpte_d(/*long int*/ _1, /*ui5*/ _2) \ + ((void)__builtin_loongarch_ldpte_d((long int)(_1), (_2))) +#endif + +#ifdef __loongarch_frecipe +extern __inline float + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __frecipe_s(float _1) { + return __builtin_loongarch_frecipe_s(_1); +} + +extern __inline double + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __frecipe_d(double _1) { + return __builtin_loongarch_frecipe_d(_1); +} + +extern __inline float + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __frsqrte_s(float _1) { + return __builtin_loongarch_frsqrte_s(_1); +} + +extern __inline double + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __frsqrte_d(double _1) { + return __builtin_loongarch_frsqrte_d(_1); +} +#endif + +#ifdef __cplusplus +} +#endif +#endif /* _LOONGARCH_BASE_INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lasxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lasxintrin.h new file mode 100755 index 0000000..85020d8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lasxintrin.h @@ -0,0 +1,3886 @@ +/*===------------ lasxintrin.h - LoongArch LASX intrinsics -----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _LOONGSON_ASXINTRIN_H +#define _LOONGSON_ASXINTRIN_H 1 + +#if defined(__loongarch_asx) + +typedef signed char v32i8 __attribute__((vector_size(32), aligned(32))); +typedef signed char v32i8_b __attribute__((vector_size(32), aligned(1))); +typedef unsigned char v32u8 __attribute__((vector_size(32), aligned(32))); +typedef unsigned char v32u8_b __attribute__((vector_size(32), aligned(1))); +typedef short v16i16 __attribute__((vector_size(32), aligned(32))); +typedef short v16i16_h __attribute__((vector_size(32), aligned(2))); +typedef unsigned short v16u16 __attribute__((vector_size(32), aligned(32))); +typedef unsigned short v16u16_h __attribute__((vector_size(32), aligned(2))); +typedef int v8i32 __attribute__((vector_size(32), aligned(32))); +typedef int v8i32_w __attribute__((vector_size(32), aligned(4))); +typedef unsigned int v8u32 __attribute__((vector_size(32), aligned(32))); +typedef unsigned int v8u32_w __attribute__((vector_size(32), aligned(4))); +typedef long long v4i64 __attribute__((vector_size(32), aligned(32))); +typedef long long v4i64_d __attribute__((vector_size(32), aligned(8))); +typedef unsigned long long v4u64 __attribute__((vector_size(32), aligned(32))); +typedef unsigned long long v4u64_d __attribute__((vector_size(32), aligned(8))); +typedef float v8f32 __attribute__((vector_size(32), aligned(32))); +typedef float v8f32_w __attribute__((vector_size(32), aligned(4))); +typedef double v4f64 __attribute__((vector_size(32), aligned(32))); +typedef double v4f64_d __attribute__((vector_size(32), aligned(8))); + +typedef double v4f64 __attribute__((vector_size(32), aligned(32))); +typedef double v4f64_d __attribute__((vector_size(32), aligned(8))); + +typedef float __m256 __attribute__((__vector_size__(32), __may_alias__)); +typedef long long __m256i __attribute__((__vector_size__(32), __may_alias__)); +typedef double __m256d __attribute__((__vector_size__(32), __may_alias__)); + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsll_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsll_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsll_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsll_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsll_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsll_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsll_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsll_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvslli_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvslli_b((v32i8)(_1), (_2))) + +#define __lasx_xvslli_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvslli_h((v16i16)(_1), (_2))) + +#define __lasx_xvslli_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslli_w((v8i32)(_1), (_2))) + +#define __lasx_xvslli_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvslli_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsra_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsra_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsra_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsra_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsra_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsra_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsra_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsra_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvsrai_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsrai_b((v32i8)(_1), (_2))) + +#define __lasx_xvsrai_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsrai_h((v16i16)(_1), (_2))) + +#define __lasx_xvsrai_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsrai_w((v8i32)(_1), (_2))) + +#define __lasx_xvsrai_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvsrai_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrar_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrar_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrar_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrar_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrar_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrar_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrar_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrar_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvsrari_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsrari_b((v32i8)(_1), (_2))) + +#define __lasx_xvsrari_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsrari_h((v16i16)(_1), (_2))) + +#define __lasx_xvsrari_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsrari_w((v8i32)(_1), (_2))) + +#define __lasx_xvsrari_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvsrari_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrl_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrl_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrl_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrl_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrl_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrl_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrl_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrl_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvsrli_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsrli_b((v32i8)(_1), (_2))) + +#define __lasx_xvsrli_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsrli_h((v16i16)(_1), (_2))) + +#define __lasx_xvsrli_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsrli_w((v8i32)(_1), (_2))) + +#define __lasx_xvsrli_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvsrli_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlr_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlr_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlr_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlr_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlr_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlr_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlr_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlr_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvsrlri_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsrlri_b((v32i8)(_1), (_2))) + +#define __lasx_xvsrlri_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsrlri_h((v16i16)(_1), (_2))) + +#define __lasx_xvsrlri_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsrlri_w((v8i32)(_1), (_2))) + +#define __lasx_xvsrlri_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvsrlri_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitclr_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitclr_b((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitclr_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitclr_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitclr_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitclr_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitclr_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitclr_d((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvbitclri_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvbitclri_b((v32u8)(_1), (_2))) + +#define __lasx_xvbitclri_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvbitclri_h((v16u16)(_1), (_2))) + +#define __lasx_xvbitclri_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvbitclri_w((v8u32)(_1), (_2))) + +#define __lasx_xvbitclri_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvbitclri_d((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitset_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitset_b((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitset_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitset_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitset_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitset_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitset_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitset_d((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvbitseti_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvbitseti_b((v32u8)(_1), (_2))) + +#define __lasx_xvbitseti_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvbitseti_h((v16u16)(_1), (_2))) + +#define __lasx_xvbitseti_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvbitseti_w((v8u32)(_1), (_2))) + +#define __lasx_xvbitseti_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvbitseti_d((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitrev_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitrev_b((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitrev_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitrev_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitrev_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitrev_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitrev_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvbitrev_d((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvbitrevi_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvbitrevi_b((v32u8)(_1), (_2))) + +#define __lasx_xvbitrevi_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvbitrevi_h((v16u16)(_1), (_2))) + +#define __lasx_xvbitrevi_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvbitrevi_w((v8u32)(_1), (_2))) + +#define __lasx_xvbitrevi_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvbitrevi_d((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadd_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadd_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadd_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadd_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadd_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadd_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadd_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadd_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvaddi_bu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvaddi_bu((v32i8)(_1), (_2))) + +#define __lasx_xvaddi_hu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvaddi_hu((v16i16)(_1), (_2))) + +#define __lasx_xvaddi_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvaddi_wu((v8i32)(_1), (_2))) + +#define __lasx_xvaddi_du(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvaddi_du((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsub_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsub_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsub_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsub_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsub_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsub_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsub_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsub_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvsubi_bu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsubi_bu((v32i8)(_1), (_2))) + +#define __lasx_xvsubi_hu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsubi_hu((v16i16)(_1), (_2))) + +#define __lasx_xvsubi_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsubi_wu((v8i32)(_1), (_2))) + +#define __lasx_xvsubi_du(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsubi_du((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvmaxi_b(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_b((v32i8)(_1), (_2))) + +#define __lasx_xvmaxi_h(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_h((v16i16)(_1), (_2))) + +#define __lasx_xvmaxi_w(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_w((v8i32)(_1), (_2))) + +#define __lasx_xvmaxi_d(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmax_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmax_du((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvmaxi_bu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_bu((v32u8)(_1), (_2))) + +#define __lasx_xvmaxi_hu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_hu((v16u16)(_1), (_2))) + +#define __lasx_xvmaxi_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_wu((v8u32)(_1), (_2))) + +#define __lasx_xvmaxi_du(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmaxi_du((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvmini_b(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_b((v32i8)(_1), (_2))) + +#define __lasx_xvmini_h(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_h((v16i16)(_1), (_2))) + +#define __lasx_xvmini_w(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_w((v8i32)(_1), (_2))) + +#define __lasx_xvmini_d(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmin_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmin_du((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvmini_bu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_bu((v32u8)(_1), (_2))) + +#define __lasx_xvmini_hu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_hu((v16u16)(_1), (_2))) + +#define __lasx_xvmini_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_wu((v8u32)(_1), (_2))) + +#define __lasx_xvmini_du(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvmini_du((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvseq_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvseq_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvseq_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvseq_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvseq_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvseq_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvseq_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvseq_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvseqi_b(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvseqi_b((v32i8)(_1), (_2))) + +#define __lasx_xvseqi_h(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvseqi_h((v16i16)(_1), (_2))) + +#define __lasx_xvseqi_w(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvseqi_w((v8i32)(_1), (_2))) + +#define __lasx_xvseqi_d(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvseqi_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvslti_b(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_b((v32i8)(_1), (_2))) + +#define __lasx_xvslti_h(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_h((v16i16)(_1), (_2))) + +#define __lasx_xvslti_w(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_w((v8i32)(_1), (_2))) + +#define __lasx_xvslti_d(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvslt_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvslt_du((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvslti_bu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_bu((v32u8)(_1), (_2))) + +#define __lasx_xvslti_hu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_hu((v16u16)(_1), (_2))) + +#define __lasx_xvslti_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_wu((v8u32)(_1), (_2))) + +#define __lasx_xvslti_du(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslti_du((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_d((v4i64)_1, (v4i64)_2); +} + +#define __lasx_xvslei_b(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_b((v32i8)(_1), (_2))) + +#define __lasx_xvslei_h(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_h((v16i16)(_1), (_2))) + +#define __lasx_xvslei_w(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_w((v8i32)(_1), (_2))) + +#define __lasx_xvslei_d(/*__m256i*/ _1, /*si5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsle_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsle_du((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvslei_bu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_bu((v32u8)(_1), (_2))) + +#define __lasx_xvslei_hu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_hu((v16u16)(_1), (_2))) + +#define __lasx_xvslei_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_wu((v8u32)(_1), (_2))) + +#define __lasx_xvslei_du(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvslei_du((v4u64)(_1), (_2))) + +#define __lasx_xvsat_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_b((v32i8)(_1), (_2))) + +#define __lasx_xvsat_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_h((v16i16)(_1), (_2))) + +#define __lasx_xvsat_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_w((v8i32)(_1), (_2))) + +#define __lasx_xvsat_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_d((v4i64)(_1), (_2))) + +#define __lasx_xvsat_bu(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_bu((v32u8)(_1), (_2))) + +#define __lasx_xvsat_hu(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_hu((v16u16)(_1), (_2))) + +#define __lasx_xvsat_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_wu((v8u32)(_1), (_2))) + +#define __lasx_xvsat_du(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvsat_du((v4u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadda_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadda_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadda_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadda_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadda_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadda_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadda_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadda_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsadd_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsadd_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavg_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavg_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvavgr_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvavgr_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssub_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssub_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvabsd_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvabsd_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmul_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmul_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmul_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmul_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmul_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmul_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmul_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmul_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmadd_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmadd_b((v32i8)_1, (v32i8)_2, (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmadd_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmadd_h((v16i16)_1, (v16i16)_2, (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmadd_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmadd_w((v8i32)_1, (v8i32)_2, (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmadd_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmadd_d((v4i64)_1, (v4i64)_2, (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmsub_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmsub_b((v32i8)_1, (v32i8)_2, (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmsub_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmsub_h((v16i16)_1, (v16i16)_2, (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmsub_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmsub_w((v8i32)_1, (v8i32)_2, (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmsub_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmsub_d((v4i64)_1, (v4i64)_2, (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvdiv_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvdiv_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_hu_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_hu_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_wu_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_wu_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_du_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_du_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_hu_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_hu_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_wu_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_wu_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_du_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_du_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmod_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmod_du((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvrepl128vei_b(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvrepl128vei_b((v32i8)(_1), (_2))) + +#define __lasx_xvrepl128vei_h(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvrepl128vei_h((v16i16)(_1), (_2))) + +#define __lasx_xvrepl128vei_w(/*__m256i*/ _1, /*ui2*/ _2) \ + ((__m256i)__builtin_lasx_xvrepl128vei_w((v8i32)(_1), (_2))) + +#define __lasx_xvrepl128vei_d(/*__m256i*/ _1, /*ui1*/ _2) \ + ((__m256i)__builtin_lasx_xvrepl128vei_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickev_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickev_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickev_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickev_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickev_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickev_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickev_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickev_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickod_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickod_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickod_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickod_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickod_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickod_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpickod_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpickod_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvh_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvh_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvh_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvh_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvh_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvh_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvh_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvh_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvl_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvl_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvl_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvl_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvl_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvl_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvilvl_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvilvl_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackev_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackev_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackev_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackev_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackev_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackev_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackev_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackev_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackod_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackod_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackod_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackod_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackod_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackod_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpackod_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvpackod_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvshuf_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvshuf_b((v32i8)_1, (v32i8)_2, (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvshuf_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvshuf_h((v16i16)_1, (v16i16)_2, (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvshuf_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvshuf_w((v8i32)_1, (v8i32)_2, (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvshuf_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvshuf_d((v4i64)_1, (v4i64)_2, (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvand_v(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvand_v((v32u8)_1, (v32u8)_2); +} + +#define __lasx_xvandi_b(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvandi_b((v32u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvor_v(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvor_v((v32u8)_1, (v32u8)_2); +} + +#define __lasx_xvori_b(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvori_b((v32u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvnor_v(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvnor_v((v32u8)_1, (v32u8)_2); +} + +#define __lasx_xvnori_b(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvnori_b((v32u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvxor_v(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvxor_v((v32u8)_1, (v32u8)_2); +} + +#define __lasx_xvxori_b(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvxori_b((v32u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvbitsel_v(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvbitsel_v((v32u8)_1, (v32u8)_2, (v32u8)_3); +} + +#define __lasx_xvbitseli_b(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvbitseli_b((v32u8)(_1), (v32u8)(_2), (_3))) + +#define __lasx_xvshuf4i_b(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvshuf4i_b((v32i8)(_1), (_2))) + +#define __lasx_xvshuf4i_h(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvshuf4i_h((v16i16)(_1), (_2))) + +#define __lasx_xvshuf4i_w(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvshuf4i_w((v8i32)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplgr2vr_b(int _1) { + return (__m256i)__builtin_lasx_xvreplgr2vr_b((int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplgr2vr_h(int _1) { + return (__m256i)__builtin_lasx_xvreplgr2vr_h((int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplgr2vr_w(int _1) { + return (__m256i)__builtin_lasx_xvreplgr2vr_w((int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplgr2vr_d(long int _1) { + return (__m256i)__builtin_lasx_xvreplgr2vr_d((long int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpcnt_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvpcnt_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpcnt_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvpcnt_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpcnt_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvpcnt_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvpcnt_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvpcnt_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclo_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvclo_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclo_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvclo_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclo_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvclo_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclo_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvclo_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclz_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvclz_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclz_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvclz_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclz_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvclz_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvclz_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvclz_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfadd_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfadd_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfadd_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfadd_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfsub_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfsub_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfsub_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfsub_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmul_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfmul_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmul_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfmul_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfdiv_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfdiv_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfdiv_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfdiv_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcvt_h_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcvt_h_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfcvt_s_d(__m256d _1, __m256d _2) { + return (__m256)__builtin_lasx_xvfcvt_s_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmin_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfmin_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmin_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfmin_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmina_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfmina_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmina_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfmina_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmax_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfmax_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmax_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfmax_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmaxa_s(__m256 _1, __m256 _2) { + return (__m256)__builtin_lasx_xvfmaxa_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmaxa_d(__m256d _1, __m256d _2) { + return (__m256d)__builtin_lasx_xvfmaxa_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfclass_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvfclass_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfclass_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvfclass_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfsqrt_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfsqrt_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfsqrt_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfsqrt_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrecip_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrecip_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrecip_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrecip_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrint_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrint_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrint_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrint_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrsqrt_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrsqrt_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrsqrt_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrsqrt_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvflogb_s(__m256 _1) { + return (__m256)__builtin_lasx_xvflogb_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvflogb_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvflogb_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfcvth_s_h(__m256i _1) { + return (__m256)__builtin_lasx_xvfcvth_s_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfcvth_d_s(__m256 _1) { + return (__m256d)__builtin_lasx_xvfcvth_d_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfcvtl_s_h(__m256i _1) { + return (__m256)__builtin_lasx_xvfcvtl_s_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfcvtl_d_s(__m256 _1) { + return (__m256d)__builtin_lasx_xvfcvtl_d_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftint_w_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftint_w_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftint_l_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftint_l_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftint_wu_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftint_wu_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftint_lu_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftint_lu_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrz_w_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrz_w_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrz_l_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftintrz_l_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrz_wu_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrz_wu_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrz_lu_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftintrz_lu_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvffint_s_w(__m256i _1) { + return (__m256)__builtin_lasx_xvffint_s_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvffint_d_l(__m256i _1) { + return (__m256d)__builtin_lasx_xvffint_d_l((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvffint_s_wu(__m256i _1) { + return (__m256)__builtin_lasx_xvffint_s_wu((v8u32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvffint_d_lu(__m256i _1) { + return (__m256d)__builtin_lasx_xvffint_d_lu((v4u64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve_b(__m256i _1, int _2) { + return (__m256i)__builtin_lasx_xvreplve_b((v32i8)_1, (int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve_h(__m256i _1, int _2) { + return (__m256i)__builtin_lasx_xvreplve_h((v16i16)_1, (int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve_w(__m256i _1, int _2) { + return (__m256i)__builtin_lasx_xvreplve_w((v8i32)_1, (int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve_d(__m256i _1, int _2) { + return (__m256i)__builtin_lasx_xvreplve_d((v4i64)_1, (int)_2); +} + +#define __lasx_xvpermi_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvpermi_w((v8i32)(_1), (v8i32)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvandn_v(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvandn_v((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvneg_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvneg_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvneg_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvneg_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvneg_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvneg_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvneg_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvneg_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmuh_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmuh_du((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvsllwil_h_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsllwil_h_b((v32i8)(_1), (_2))) + +#define __lasx_xvsllwil_w_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsllwil_w_h((v16i16)(_1), (_2))) + +#define __lasx_xvsllwil_d_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsllwil_d_w((v8i32)(_1), (_2))) + +#define __lasx_xvsllwil_hu_bu(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvsllwil_hu_bu((v32u8)(_1), (_2))) + +#define __lasx_xvsllwil_wu_hu(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvsllwil_wu_hu((v16u16)(_1), (_2))) + +#define __lasx_xvsllwil_du_wu(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvsllwil_du_wu((v8u32)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsran_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsran_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsran_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsran_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsran_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsran_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssran_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssran_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssran_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssran_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssran_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssran_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssran_bu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssran_bu_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssran_hu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssran_hu_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssran_wu_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssran_wu_d((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrarn_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrarn_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrarn_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrarn_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrarn_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrarn_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrarn_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrarn_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrarn_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrarn_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrarn_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrarn_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrarn_bu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrarn_bu_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrarn_hu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrarn_hu_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrarn_wu_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrarn_wu_d((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrln_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrln_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrln_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrln_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrln_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrln_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrln_bu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrln_bu_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrln_hu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrln_hu_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrln_wu_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrln_wu_d((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlrn_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlrn_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlrn_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlrn_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsrlrn_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsrlrn_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrlrn_bu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrlrn_bu_h((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrlrn_hu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrlrn_hu_w((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrlrn_wu_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrlrn_wu_d((v4u64)_1, (v4u64)_2); +} + +#define __lasx_xvfrstpi_b(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvfrstpi_b((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvfrstpi_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvfrstpi_h((v16i16)(_1), (v16i16)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfrstp_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvfrstp_b((v32i8)_1, (v32i8)_2, (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfrstp_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvfrstp_h((v16i16)_1, (v16i16)_2, (v16i16)_3); +} + +#define __lasx_xvshuf4i_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvshuf4i_d((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvbsrl_v(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvbsrl_v((v32i8)(_1), (_2))) + +#define __lasx_xvbsll_v(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvbsll_v((v32i8)(_1), (_2))) + +#define __lasx_xvextrins_b(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvextrins_b((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvextrins_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvextrins_h((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvextrins_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvextrins_w((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvextrins_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvextrins_d((v4i64)(_1), (v4i64)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmskltz_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvmskltz_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmskltz_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvmskltz_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmskltz_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvmskltz_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmskltz_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvmskltz_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsigncov_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsigncov_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsigncov_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsigncov_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsigncov_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsigncov_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsigncov_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsigncov_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmadd_s(__m256 _1, __m256 _2, __m256 _3) { + return (__m256)__builtin_lasx_xvfmadd_s((v8f32)_1, (v8f32)_2, (v8f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmadd_d(__m256d _1, __m256d _2, __m256d _3) { + return (__m256d)__builtin_lasx_xvfmadd_d((v4f64)_1, (v4f64)_2, (v4f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfmsub_s(__m256 _1, __m256 _2, __m256 _3) { + return (__m256)__builtin_lasx_xvfmsub_s((v8f32)_1, (v8f32)_2, (v8f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfmsub_d(__m256d _1, __m256d _2, __m256d _3) { + return (__m256d)__builtin_lasx_xvfmsub_d((v4f64)_1, (v4f64)_2, (v4f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfnmadd_s(__m256 _1, __m256 _2, __m256 _3) { + return (__m256)__builtin_lasx_xvfnmadd_s((v8f32)_1, (v8f32)_2, (v8f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfnmadd_d(__m256d _1, __m256d _2, __m256d _3) { + return (__m256d)__builtin_lasx_xvfnmadd_d((v4f64)_1, (v4f64)_2, (v4f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfnmsub_s(__m256 _1, __m256 _2, __m256 _3) { + return (__m256)__builtin_lasx_xvfnmsub_s((v8f32)_1, (v8f32)_2, (v8f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfnmsub_d(__m256d _1, __m256d _2, __m256d _3) { + return (__m256d)__builtin_lasx_xvfnmsub_d((v4f64)_1, (v4f64)_2, (v4f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrne_w_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrne_w_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrne_l_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftintrne_l_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrp_w_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrp_w_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrp_l_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftintrp_l_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrm_w_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrm_w_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrm_l_d(__m256d _1) { + return (__m256i)__builtin_lasx_xvftintrm_l_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftint_w_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvftint_w_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvffint_s_l(__m256i _1, __m256i _2) { + return (__m256)__builtin_lasx_xvffint_s_l((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrz_w_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvftintrz_w_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrp_w_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvftintrp_w_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrm_w_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvftintrm_w_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrne_w_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvftintrne_w_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftinth_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftinth_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintl_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintl_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvffinth_d_w(__m256i _1) { + return (__m256d)__builtin_lasx_xvffinth_d_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvffintl_d_w(__m256i _1) { + return (__m256d)__builtin_lasx_xvffintl_d_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrzh_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrzh_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrzl_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrzl_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrph_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrph_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrpl_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrpl_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrmh_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrmh_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrml_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrml_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrneh_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrneh_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvftintrnel_l_s(__m256 _1) { + return (__m256i)__builtin_lasx_xvftintrnel_l_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrintrne_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrintrne_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrintrne_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrintrne_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrintrz_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrintrz_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrintrz_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrintrz_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrintrp_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrintrp_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrintrp_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrintrp_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrintrm_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrintrm_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrintrm_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrintrm_d((v4f64)_1); +} + +#define __lasx_xvld(/*void **/ _1, /*si12*/ _2) \ + ((__m256i)__builtin_lasx_xvld((void const *)(_1), (_2))) + +#define __lasx_xvst(/*__m256i*/ _1, /*void **/ _2, /*si12*/ _3) \ + ((void)__builtin_lasx_xvst((v32i8)(_1), (void *)(_2), (_3))) + +#define __lasx_xvstelm_b(/*__m256i*/ _1, /*void **/ _2, /*si8*/ _3, \ + /*idx*/ _4) \ + ((void)__builtin_lasx_xvstelm_b((v32i8)(_1), (void *)(_2), (_3), (_4))) + +#define __lasx_xvstelm_h(/*__m256i*/ _1, /*void **/ _2, /*si8*/ _3, \ + /*idx*/ _4) \ + ((void)__builtin_lasx_xvstelm_h((v16i16)(_1), (void *)(_2), (_3), (_4))) + +#define __lasx_xvstelm_w(/*__m256i*/ _1, /*void **/ _2, /*si8*/ _3, \ + /*idx*/ _4) \ + ((void)__builtin_lasx_xvstelm_w((v8i32)(_1), (void *)(_2), (_3), (_4))) + +#define __lasx_xvstelm_d(/*__m256i*/ _1, /*void **/ _2, /*si8*/ _3, \ + /*idx*/ _4) \ + ((void)__builtin_lasx_xvstelm_d((v4i64)(_1), (void *)(_2), (_3), (_4))) + +#define __lasx_xvinsve0_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui3*/ _3) \ + ((__m256i)__builtin_lasx_xvinsve0_w((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvinsve0_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui2*/ _3) \ + ((__m256i)__builtin_lasx_xvinsve0_d((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvpickve_w(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvpickve_w((v8i32)(_1), (_2))) + +#define __lasx_xvpickve_d(/*__m256i*/ _1, /*ui2*/ _2) \ + ((__m256i)__builtin_lasx_xvpickve_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrlrn_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrlrn_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrlrn_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrlrn_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrlrn_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrlrn_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrln_b_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrln_b_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrln_h_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrln_h_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvssrln_w_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvssrln_w_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvorn_v(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvorn_v((v32u8)_1, (v32u8)_2); +} + +#define __lasx_xvldi(/*i13*/ _1) ((__m256i)__builtin_lasx_xvldi((_1))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvldx(void const *_1, long int _2) { + return (__m256i)__builtin_lasx_xvldx((void const *)_1, (long int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) void + __lasx_xvstx(__m256i _1, void *_2, long int _3) { + return (void)__builtin_lasx_xvstx((v32i8)_1, (void *)_2, (long int)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvextl_qu_du(__m256i _1) { + return (__m256i)__builtin_lasx_xvextl_qu_du((v4u64)_1); +} + +#define __lasx_xvinsgr2vr_w(/*__m256i*/ _1, /*int*/ _2, /*ui3*/ _3) \ + ((__m256i)__builtin_lasx_xvinsgr2vr_w((v8i32)(_1), (int)(_2), (_3))) + +#define __lasx_xvinsgr2vr_d(/*__m256i*/ _1, /*long int*/ _2, /*ui2*/ _3) \ + ((__m256i)__builtin_lasx_xvinsgr2vr_d((v4i64)(_1), (long int)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve0_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvreplve0_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve0_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvreplve0_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve0_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvreplve0_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve0_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvreplve0_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvreplve0_q(__m256i _1) { + return (__m256i)__builtin_lasx_xvreplve0_q((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_h_b(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_h_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_w_h(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_w_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_d_w(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_d_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_w_b(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_w_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_d_h(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_d_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_d_b(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_d_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_hu_bu(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_hu_bu((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_wu_hu(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_wu_hu((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_du_wu(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_du_wu((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_wu_bu(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_wu_bu((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_du_hu(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_du_hu((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_vext2xv_du_bu(__m256i _1) { + return (__m256i)__builtin_lasx_vext2xv_du_bu((v32i8)_1); +} + +#define __lasx_xvpermi_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui8*/ _3) \ + ((__m256i)__builtin_lasx_xvpermi_q((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvpermi_d(/*__m256i*/ _1, /*ui8*/ _2) \ + ((__m256i)__builtin_lasx_xvpermi_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvperm_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvperm_w((v8i32)_1, (v8i32)_2); +} + +#define __lasx_xvldrepl_b(/*void **/ _1, /*si12*/ _2) \ + ((__m256i)__builtin_lasx_xvldrepl_b((void const *)(_1), (_2))) + +#define __lasx_xvldrepl_h(/*void **/ _1, /*si11*/ _2) \ + ((__m256i)__builtin_lasx_xvldrepl_h((void const *)(_1), (_2))) + +#define __lasx_xvldrepl_w(/*void **/ _1, /*si10*/ _2) \ + ((__m256i)__builtin_lasx_xvldrepl_w((void const *)(_1), (_2))) + +#define __lasx_xvldrepl_d(/*void **/ _1, /*si9*/ _2) \ + ((__m256i)__builtin_lasx_xvldrepl_d((void const *)(_1), (_2))) + +#define __lasx_xvpickve2gr_w(/*__m256i*/ _1, /*ui3*/ _2) \ + ((int)__builtin_lasx_xvpickve2gr_w((v8i32)(_1), (_2))) + +#define __lasx_xvpickve2gr_wu(/*__m256i*/ _1, /*ui3*/ _2) \ + ((unsigned int)__builtin_lasx_xvpickve2gr_wu((v8i32)(_1), (_2))) + +#define __lasx_xvpickve2gr_d(/*__m256i*/ _1, /*ui2*/ _2) \ + ((long int)__builtin_lasx_xvpickve2gr_d((v4i64)(_1), (_2))) + +#define __lasx_xvpickve2gr_du(/*__m256i*/ _1, /*ui2*/ _2) \ + ((unsigned long int)__builtin_lasx_xvpickve2gr_du((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_q_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_q_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_d_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_d_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_w_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_w_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_h_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_h_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_q_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_q_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_d_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_d_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_w_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_w_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwev_h_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwev_h_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_q_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_q_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_d_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_d_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_w_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_w_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_h_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_h_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_q_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_q_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_d_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_d_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_w_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_w_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_h_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_h_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_q_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_q_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_d_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_d_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_w_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_w_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsubwod_h_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsubwod_h_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_d_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_d_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_w_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_w_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_h_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_h_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_q_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_q_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_d_wu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_d_wu((v8u32)_1, (v8u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_w_hu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_w_hu((v16u16)_1, (v16u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_h_bu(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_h_bu((v32u8)_1, (v32u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_d_wu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_d_wu_w((v8u32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_w_hu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_w_hu_h((v16u16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_h_bu_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_h_bu_b((v32u8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_d_wu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_d_wu_w((v8u32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_w_hu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_w_hu_h((v16u16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_h_bu_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_h_bu_b((v32u8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_d_wu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_d_wu_w((v8u32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_w_hu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_w_hu_h((v16u16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_h_bu_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_h_bu_b((v32u8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_d_wu_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_d_wu_w((v8u32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_w_hu_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_w_hu_h((v16u16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_h_bu_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_h_bu_b((v32u8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhaddw_qu_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhaddw_qu_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_q_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_q_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvhsubw_qu_du(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvhsubw_qu_du((v4u64)_1, (v4u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_q_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_q_d((v4i64)_1, (v4i64)_2, (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_d_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_d_w((v4i64)_1, (v8i32)_2, (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_w_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_w_h((v8i32)_1, (v16i16)_2, + (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_h_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_h_b((v16i16)_1, (v32i8)_2, + (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_q_du(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_q_du((v4u64)_1, (v4u64)_2, + (v4u64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_d_wu(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_d_wu((v4u64)_1, (v8u32)_2, + (v8u32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_w_hu(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_w_hu((v8u32)_1, (v16u16)_2, + (v16u16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_h_bu(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_h_bu((v16u16)_1, (v32u8)_2, + (v32u8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_q_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_q_d((v4i64)_1, (v4i64)_2, (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_d_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_d_w((v4i64)_1, (v8i32)_2, (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_w_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_w_h((v8i32)_1, (v16i16)_2, + (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_h_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_h_b((v16i16)_1, (v32i8)_2, + (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_q_du(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_q_du((v4u64)_1, (v4u64)_2, + (v4u64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_d_wu(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_d_wu((v4u64)_1, (v8u32)_2, + (v8u32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_w_hu(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_w_hu((v8u32)_1, (v16u16)_2, + (v16u16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_h_bu(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_h_bu((v16u16)_1, (v32u8)_2, + (v32u8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_q_du_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_q_du_d((v4i64)_1, (v4u64)_2, + (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_d_wu_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_d_wu_w((v4i64)_1, (v8u32)_2, + (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_w_hu_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_w_hu_h((v8i32)_1, (v16u16)_2, + (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwev_h_bu_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwev_h_bu_b((v16i16)_1, (v32u8)_2, + (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_q_du_d(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_q_du_d((v4i64)_1, (v4u64)_2, + (v4i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_d_wu_w(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_d_wu_w((v4i64)_1, (v8u32)_2, + (v8i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_w_hu_h(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_w_hu_h((v8i32)_1, (v16u16)_2, + (v16i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmaddwod_h_bu_b(__m256i _1, __m256i _2, __m256i _3) { + return (__m256i)__builtin_lasx_xvmaddwod_h_bu_b((v16i16)_1, (v32u8)_2, + (v32i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvrotr_b(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvrotr_b((v32i8)_1, (v32i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvrotr_h(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvrotr_h((v16i16)_1, (v16i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvrotr_w(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvrotr_w((v8i32)_1, (v8i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvrotr_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvrotr_d((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvadd_q(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvadd_q((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvsub_q(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvsub_q((v4i64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwev_q_du_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwev_q_du_d((v4u64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvaddwod_q_du_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvaddwod_q_du_d((v4u64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwev_q_du_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwev_q_du_d((v4u64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmulwod_q_du_d(__m256i _1, __m256i _2) { + return (__m256i)__builtin_lasx_xvmulwod_q_du_d((v4u64)_1, (v4i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmskgez_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvmskgez_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvmsknz_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvmsknz_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_h_b(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_h_b((v32i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_w_h(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_w_h((v16i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_d_w(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_d_w((v8i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_q_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_q_d((v4i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_hu_bu(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_hu_bu((v32u8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_wu_hu(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_wu_hu((v16u16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_du_wu(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_du_wu((v8u32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvexth_qu_du(__m256i _1) { + return (__m256i)__builtin_lasx_xvexth_qu_du((v4u64)_1); +} + +#define __lasx_xvrotri_b(/*__m256i*/ _1, /*ui3*/ _2) \ + ((__m256i)__builtin_lasx_xvrotri_b((v32i8)(_1), (_2))) + +#define __lasx_xvrotri_h(/*__m256i*/ _1, /*ui4*/ _2) \ + ((__m256i)__builtin_lasx_xvrotri_h((v16i16)(_1), (_2))) + +#define __lasx_xvrotri_w(/*__m256i*/ _1, /*ui5*/ _2) \ + ((__m256i)__builtin_lasx_xvrotri_w((v8i32)(_1), (_2))) + +#define __lasx_xvrotri_d(/*__m256i*/ _1, /*ui6*/ _2) \ + ((__m256i)__builtin_lasx_xvrotri_d((v4i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvextl_q_d(__m256i _1) { + return (__m256i)__builtin_lasx_xvextl_q_d((v4i64)_1); +} + +#define __lasx_xvsrlni_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlni_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvsrlni_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlni_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvsrlni_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlni_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvsrlni_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlni_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvsrlrni_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlrni_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvsrlrni_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlrni_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvsrlrni_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlrni_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvsrlrni_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvsrlrni_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrlni_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrlni_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrlni_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrlni_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrlni_bu_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_bu_h((v32u8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrlni_hu_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_hu_w((v16u16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrlni_wu_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_wu_d((v8u32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrlni_du_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlni_du_q((v4u64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrlrni_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrlrni_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrlrni_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrlrni_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrlrni_bu_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_bu_h((v32u8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrlrni_hu_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_hu_w((v16u16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrlrni_wu_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_wu_d((v8u32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrlrni_du_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrlrni_du_q((v4u64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvsrani_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvsrani_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvsrani_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvsrani_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvsrani_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvsrani_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvsrani_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvsrani_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvsrarni_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvsrarni_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvsrarni_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvsrarni_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvsrarni_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvsrarni_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvsrarni_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvsrarni_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrani_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrani_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrani_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrani_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrani_bu_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_bu_h((v32u8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrani_hu_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_hu_w((v16u16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrani_wu_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_wu_d((v8u32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrani_du_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrani_du_q((v4u64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrarni_b_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_b_h((v32i8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrarni_h_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_h_w((v16i16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrarni_w_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_w_d((v8i32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrarni_d_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_d_q((v4i64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xvssrarni_bu_h(/*__m256i*/ _1, /*__m256i*/ _2, /*ui4*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_bu_h((v32u8)(_1), (v32i8)(_2), (_3))) + +#define __lasx_xvssrarni_hu_w(/*__m256i*/ _1, /*__m256i*/ _2, /*ui5*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_hu_w((v16u16)(_1), (v16i16)(_2), (_3))) + +#define __lasx_xvssrarni_wu_d(/*__m256i*/ _1, /*__m256i*/ _2, /*ui6*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_wu_d((v8u32)(_1), (v8i32)(_2), (_3))) + +#define __lasx_xvssrarni_du_q(/*__m256i*/ _1, /*__m256i*/ _2, /*ui7*/ _3) \ + ((__m256i)__builtin_lasx_xvssrarni_du_q((v4u64)(_1), (v4i64)(_2), (_3))) + +#define __lasx_xbnz_b(/*__m256i*/ _1) ((int)__builtin_lasx_xbnz_b((v32u8)(_1))) + +#define __lasx_xbnz_d(/*__m256i*/ _1) ((int)__builtin_lasx_xbnz_d((v4u64)(_1))) + +#define __lasx_xbnz_h(/*__m256i*/ _1) ((int)__builtin_lasx_xbnz_h((v16u16)(_1))) + +#define __lasx_xbnz_v(/*__m256i*/ _1) ((int)__builtin_lasx_xbnz_v((v32u8)(_1))) + +#define __lasx_xbnz_w(/*__m256i*/ _1) ((int)__builtin_lasx_xbnz_w((v8u32)(_1))) + +#define __lasx_xbz_b(/*__m256i*/ _1) ((int)__builtin_lasx_xbz_b((v32u8)(_1))) + +#define __lasx_xbz_d(/*__m256i*/ _1) ((int)__builtin_lasx_xbz_d((v4u64)(_1))) + +#define __lasx_xbz_h(/*__m256i*/ _1) ((int)__builtin_lasx_xbz_h((v16u16)(_1))) + +#define __lasx_xbz_v(/*__m256i*/ _1) ((int)__builtin_lasx_xbz_v((v32u8)(_1))) + +#define __lasx_xbz_w(/*__m256i*/ _1) ((int)__builtin_lasx_xbz_w((v8u32)(_1))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_caf_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_caf_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_caf_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_caf_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_ceq_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_ceq_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_ceq_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_ceq_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cle_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cle_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cle_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cle_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_clt_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_clt_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_clt_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_clt_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cne_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cne_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cne_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cne_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cor_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cor_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cor_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cor_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cueq_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cueq_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cueq_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cueq_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cule_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cule_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cule_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cule_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cult_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cult_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cult_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cult_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cun_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cun_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cune_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_cune_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cune_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cune_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_cun_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_cun_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_saf_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_saf_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_saf_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_saf_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_seq_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_seq_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_seq_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_seq_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sle_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sle_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sle_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sle_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_slt_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_slt_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_slt_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_slt_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sne_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sne_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sne_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sne_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sor_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sor_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sor_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sor_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sueq_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sueq_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sueq_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sueq_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sule_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sule_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sule_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sule_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sult_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sult_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sult_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sult_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sun_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sun_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sune_d(__m256d _1, __m256d _2) { + return (__m256i)__builtin_lasx_xvfcmp_sune_d((v4f64)_1, (v4f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sune_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sune_s((v8f32)_1, (v8f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256i + __lasx_xvfcmp_sun_s(__m256 _1, __m256 _2) { + return (__m256i)__builtin_lasx_xvfcmp_sun_s((v8f32)_1, (v8f32)_2); +} + +#if defined(__loongarch_frecipe) +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrecipe_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrecipe_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrecipe_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrecipe_d((v4f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256 + __lasx_xvfrsqrte_s(__m256 _1) { + return (__m256)__builtin_lasx_xvfrsqrte_s((v8f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m256d + __lasx_xvfrsqrte_d(__m256d _1) { + return (__m256d)__builtin_lasx_xvfrsqrte_d((v4f64)_1); +} +#endif + +#define __lasx_xvpickve_d_f(/*__m256d*/ _1, /*ui2*/ _2) \ + ((__m256d)__builtin_lasx_xvpickve_d_f((v4f64)(_1), (_2))) + +#define __lasx_xvpickve_w_f(/*__m256*/ _1, /*ui3*/ _2) \ + ((__m256)__builtin_lasx_xvpickve_w_f((v8f32)(_1), (_2))) + +#define __lasx_xvrepli_b(/*si10*/ _1) ((__m256i)__builtin_lasx_xvrepli_b((_1))) + +#define __lasx_xvrepli_d(/*si10*/ _1) ((__m256i)__builtin_lasx_xvrepli_d((_1))) + +#define __lasx_xvrepli_h(/*si10*/ _1) ((__m256i)__builtin_lasx_xvrepli_h((_1))) + +#define __lasx_xvrepli_w(/*si10*/ _1) ((__m256i)__builtin_lasx_xvrepli_w((_1))) + +#endif /* defined(__loongarch_asx). */ +#endif /* _LOONGSON_ASXINTRIN_H. */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/limits.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/limits.h new file mode 100755 index 0000000..d08227f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/limits.h @@ -0,0 +1,133 @@ +/*===---- limits.h - Standard header for integer sizes --------------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_LIMITS_H +#define __CLANG_LIMITS_H + +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +/* The system's limits.h may, in turn, try to #include_next GCC's limits.h. + Avert this #include_next madness. */ +#if defined __GNUC__ && !defined _GCC_LIMITS_H_ +#define _GCC_LIMITS_H_ +#endif + +/* System headers include a number of constants from POSIX in . + Include it if we're hosted. */ +#if __STDC_HOSTED__ && __has_include_next() +#include_next +#endif + +/* Many system headers try to "help us out" by defining these. No really, we + know how big each datatype is. */ +#undef SCHAR_MIN +#undef SCHAR_MAX +#undef UCHAR_MAX +#undef SHRT_MIN +#undef SHRT_MAX +#undef USHRT_MAX +#undef INT_MIN +#undef INT_MAX +#undef UINT_MAX +#undef LONG_MIN +#undef LONG_MAX +#undef ULONG_MAX + +#undef CHAR_BIT +#undef CHAR_MIN +#undef CHAR_MAX + +/* C90/99 5.2.4.2.1 */ +#define SCHAR_MAX __SCHAR_MAX__ +#define SHRT_MAX __SHRT_MAX__ +#define INT_MAX __INT_MAX__ +#define LONG_MAX __LONG_MAX__ + +#define SCHAR_MIN (-__SCHAR_MAX__-1) +#define SHRT_MIN (-__SHRT_MAX__ -1) +#define INT_MIN (-__INT_MAX__ -1) +#define LONG_MIN (-__LONG_MAX__ -1L) + +#define UCHAR_MAX (__SCHAR_MAX__*2 +1) +#if __SHRT_WIDTH__ < __INT_WIDTH__ +#define USHRT_MAX (__SHRT_MAX__ * 2 + 1) +#else +#define USHRT_MAX (__SHRT_MAX__ * 2U + 1U) +#endif +#define UINT_MAX (__INT_MAX__ *2U +1U) +#define ULONG_MAX (__LONG_MAX__ *2UL+1UL) + +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 1 +#endif + +#define CHAR_BIT __CHAR_BIT__ + +/* C23 5.2.4.2.1 */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define BOOL_WIDTH __BOOL_WIDTH__ +#define CHAR_WIDTH CHAR_BIT +#define SCHAR_WIDTH CHAR_BIT +#define UCHAR_WIDTH CHAR_BIT +#define USHRT_WIDTH __SHRT_WIDTH__ +#define SHRT_WIDTH __SHRT_WIDTH__ +#define UINT_WIDTH __INT_WIDTH__ +#define INT_WIDTH __INT_WIDTH__ +#define ULONG_WIDTH __LONG_WIDTH__ +#define LONG_WIDTH __LONG_WIDTH__ +#define ULLONG_WIDTH __LLONG_WIDTH__ +#define LLONG_WIDTH __LLONG_WIDTH__ + +#define BITINT_MAXWIDTH __BITINT_MAXWIDTH__ +#endif + +#ifdef __CHAR_UNSIGNED__ /* -funsigned-char */ +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#else +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX __SCHAR_MAX__ +#endif + +/* C99 5.2.4.2.1: Added long long. + C++11 18.3.3.2: same contents as the Standard C Library header . + */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) + +#undef LLONG_MIN +#undef LLONG_MAX +#undef ULLONG_MAX + +#define LLONG_MAX __LONG_LONG_MAX__ +#define LLONG_MIN (-__LONG_LONG_MAX__-1LL) +#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL) +#endif + +/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's + bionic also defines them. It's too bad that we don't have something like + #pragma poison that could be used to deprecate a macro - the code should just + use LLONG_MAX and friends. + */ +#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) \ + : !defined(__STRICT_ANSI__)) || \ + defined(__BIONIC__) + +#undef LONG_LONG_MIN +#undef LONG_LONG_MAX +#undef ULONG_LONG_MAX + +#define LONG_LONG_MAX __LONG_LONG_MAX__ +#define LONG_LONG_MIN (-__LONG_LONG_MAX__-1LL) +#define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL) +#endif + +#endif /* __MVS__ */ +#endif /* __CLANG_LIMITS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/assert.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/assert.h new file mode 100755 index 0000000..610ed96 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/assert.h @@ -0,0 +1,34 @@ +//===-- Wrapper for C standard assert.h declarations on the GPU -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__ + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +#include_next + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +#pragma omp begin declare target + +#include + +#pragma omp end declare target + +#undef __LIBC_ATTRS + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/ctype.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/ctype.h new file mode 100755 index 0000000..960cf43 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/ctype.h @@ -0,0 +1,140 @@ +//===-- Wrapper for C standard ctype.h declarations on the GPU ------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__ + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +// The GNU headers like to define 'toupper' and 'tolower' redundantly. This is +// necessary to prevent it from doing that and remapping our implementation. +#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(__GLIBC__) +#pragma push_macro("__USE_EXTERN_INLINES") +#undef __USE_EXTERN_INLINES +#endif + +#include_next + +#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(__GLIBC__) +#pragma pop_macro("__USE_EXTERN_INLINES") +#endif + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +// The GNU headers like to provide these as macros, we need to undefine them so +// they do not conflict with the following definitions for the GPU. + +#pragma push_macro("isalnum") +#pragma push_macro("isalpha") +#pragma push_macro("isascii") +#pragma push_macro("isblank") +#pragma push_macro("iscntrl") +#pragma push_macro("isdigit") +#pragma push_macro("isgraph") +#pragma push_macro("islower") +#pragma push_macro("isprint") +#pragma push_macro("ispunct") +#pragma push_macro("isspace") +#pragma push_macro("isupper") +#pragma push_macro("isxdigit") +#pragma push_macro("toascii") +#pragma push_macro("tolower") +#pragma push_macro("toupper") +#pragma push_macro("isalnum_l") +#pragma push_macro("isalpha_l") +#pragma push_macro("isascii_l") +#pragma push_macro("isblank_l") +#pragma push_macro("iscntrl_l") +#pragma push_macro("isdigit_l") +#pragma push_macro("isgraph_l") +#pragma push_macro("islower_l") +#pragma push_macro("isprint_l") +#pragma push_macro("ispunct_l") +#pragma push_macro("isspace_l") +#pragma push_macro("isupper_l") +#pragma push_macro("isxdigit_l") + +#undef isalnum +#undef isalpha +#undef isascii +#undef iscntrl +#undef isdigit +#undef islower +#undef isgraph +#undef isprint +#undef ispunct +#undef isspace +#undef isupper +#undef isblank +#undef isxdigit +#undef toascii +#undef tolower +#undef toupper +#undef isalnum_l +#undef isalpha_l +#undef iscntrl_l +#undef isdigit_l +#undef islower_l +#undef isgraph_l +#undef isprint_l +#undef ispunct_l +#undef isspace_l +#undef isupper_l +#undef isblank_l +#undef isxdigit_l + +#pragma omp begin declare target + +#include + +#pragma omp end declare target + +// Restore the original macros when compiling on the host. +#if !defined(__NVPTX__) && !defined(__AMDGPU__) +#pragma pop_macro("isalnum") +#pragma pop_macro("isalpha") +#pragma pop_macro("isascii") +#pragma pop_macro("isblank") +#pragma pop_macro("iscntrl") +#pragma pop_macro("isdigit") +#pragma pop_macro("isgraph") +#pragma pop_macro("islower") +#pragma pop_macro("isprint") +#pragma pop_macro("ispunct") +#pragma pop_macro("isspace") +#pragma pop_macro("isupper") +#pragma pop_macro("isxdigit") +#pragma pop_macro("toascii") +#pragma pop_macro("tolower") +#pragma pop_macro("toupper") +#pragma pop_macro("isalnum_l") +#pragma pop_macro("isalpha_l") +#pragma pop_macro("isascii_l") +#pragma pop_macro("isblank_l") +#pragma pop_macro("iscntrl_l") +#pragma pop_macro("isdigit_l") +#pragma pop_macro("isgraph_l") +#pragma pop_macro("islower_l") +#pragma pop_macro("isprint_l") +#pragma pop_macro("ispunct_l") +#pragma pop_macro("isspace_l") +#pragma pop_macro("isupper_l") +#pragma pop_macro("isxdigit_l") +#endif + +#undef __LIBC_ATTRS + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_CTYPE_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/inttypes.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/inttypes.h new file mode 100755 index 0000000..415f1e4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/inttypes.h @@ -0,0 +1,34 @@ +//===-- Wrapper for C standard inttypes.h declarations on the GPU ---------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__ + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +#include_next + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +#pragma omp begin declare target + +#include + +#pragma omp end declare target + +#undef __LIBC_ATTRS + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_INTTYPES_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/stdio.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/stdio.h new file mode 100755 index 0000000..950f91b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/stdio.h @@ -0,0 +1,80 @@ +//===-- Wrapper for C standard stdio.h declarations on the GPU ------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +#include_next + +// In some old versions of glibc, other standard headers sometimes define +// special macros (e.g., __need_FILE) before including stdio.h to cause stdio.h +// to produce special definitions. Future includes of stdio.h when those +// special macros are undefined are expected to produce the normal definitions +// from stdio.h. +// +// We do not apply our include guard (__CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__) +// unconditionally to the above include_next. Otherwise, after an occurrence of +// the first glibc stdio.h use case described above, the include_next would be +// skipped for remaining includes of stdio.h, leaving required symbols +// undefined. +// +// We make the following assumptions to handle all use cases: +// +// 1. If the above include_next produces special glibc definitions, then (a) it +// does not produce the normal definitions that we must intercept below, (b) +// the current file was included from a glibc header that already defined +// __GLIBC__ (usually by including glibc's ), and (c) the above +// include_next does not define _STDIO_H. In that case, we skip the rest of +// the current file and don't guard against future includes. +// 2. If the above include_next produces the normal stdio.h definitions, then +// either (a) __GLIBC__ is not defined because C headers are from some other +// libc implementation or (b) the above include_next defines _STDIO_H to +// prevent the above include_next from having any effect in the future. +#if !defined(__GLIBC__) || defined(_STDIO_H) + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__ + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +// Some headers provide these as macros. Temporarily undefine them so they do +// not conflict with any definitions for the GPU. + +#pragma push_macro("stdout") +#pragma push_macro("stdin") +#pragma push_macro("stderr") + +#undef stdout +#undef stderr +#undef stdin + +#pragma omp begin declare target + +#include + +#pragma omp end declare target + +#undef __LIBC_ATTRS + +// Restore the original macros when compiling on the host. +#if !defined(__NVPTX__) && !defined(__AMDGPU__) +#pragma pop_macro("stdout") +#pragma pop_macro("stderr") +#pragma pop_macro("stdin") +#endif + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__ + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/stdlib.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/stdlib.h new file mode 100755 index 0000000..1da22ab --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/stdlib.h @@ -0,0 +1,53 @@ +//===-- Wrapper for C standard stdlib.h declarations on the GPU -----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__ + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +#include_next + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +#pragma omp begin declare target + +// The LLVM C library uses these named types so we forward declare them. +typedef void (*__atexithandler_t)(void); +typedef int (*__search_compare_t)(const void *, const void *); +typedef int (*__qsortcompare_t)(const void *, const void *); +typedef int (*__qsortrcompare_t)(const void *, const void *, void *); + +// Enforce ABI compatibility with the structs used by the LLVM C library. +_Static_assert(__builtin_offsetof(div_t, quot) == 0, "ABI mismatch!"); +_Static_assert(__builtin_offsetof(ldiv_t, quot) == 0, "ABI mismatch!"); +_Static_assert(__builtin_offsetof(lldiv_t, quot) == 0, "ABI mismatch!"); + +#if defined(__GLIBC__) && __cplusplus >= 201703L +#define at_quick_exit atexit +#endif + +#include + +#if defined(__GLIBC__) && __cplusplus >= 201703L +#undef at_quick_exit +#endif + +#pragma omp end declare target + +#undef __LIBC_ATTRS + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_STDLIB_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/string.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/string.h new file mode 100755 index 0000000..0ea49cb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/string.h @@ -0,0 +1,96 @@ +//===-- Wrapper for C standard string.h declarations on the GPU -----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__ + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +#include_next + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +#pragma omp begin declare target + +// The GNU headers provide C++ standard compliant headers when in C++ mode and +// the LLVM libc does not. We need to manually provide the definitions using the +// same prototypes. +#if defined(__cplusplus) && defined(__GLIBC__) && \ + defined(__CORRECT_ISO_CPP_STRING_H_PROTO) + +#ifndef __LIBC_ATTRS +#define __LIBC_ATTRS +#endif + +extern "C" { +void *memccpy(void *__restrict, const void *__restrict, int, + size_t) __LIBC_ATTRS; +int memcmp(const void *, const void *, size_t) __LIBC_ATTRS; +void *memcpy(void *__restrict, const void *__restrict, size_t) __LIBC_ATTRS; +void *memmem(const void *, size_t, const void *, size_t) __LIBC_ATTRS; +void *memmove(void *, const void *, size_t) __LIBC_ATTRS; +void *mempcpy(void *__restrict, const void *__restrict, size_t) __LIBC_ATTRS; +void *memset(void *, int, size_t) __LIBC_ATTRS; +char *stpcpy(char *__restrict, const char *__restrict) __LIBC_ATTRS; +char *stpncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; +char *strcat(char *__restrict, const char *__restrict) __LIBC_ATTRS; +int strcmp(const char *, const char *) __LIBC_ATTRS; +int strcoll(const char *, const char *) __LIBC_ATTRS; +char *strcpy(char *__restrict, const char *__restrict) __LIBC_ATTRS; +size_t strcspn(const char *, const char *) __LIBC_ATTRS; +char *strdup(const char *) __LIBC_ATTRS; +size_t strlen(const char *) __LIBC_ATTRS; +char *strncat(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; +int strncmp(const char *, const char *, size_t) __LIBC_ATTRS; +char *strncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; +char *strndup(const char *, size_t) __LIBC_ATTRS; +size_t strnlen(const char *, size_t) __LIBC_ATTRS; +size_t strspn(const char *, const char *) __LIBC_ATTRS; +char *strtok(char *__restrict, const char *__restrict) __LIBC_ATTRS; +char *strtok_r(char *__restrict, const char *__restrict, + char **__restrict) __LIBC_ATTRS; +size_t strxfrm(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; +} + +extern "C++" { +char *strstr(char *, const char *) noexcept __LIBC_ATTRS; +const char *strstr(const char *, const char *) noexcept __LIBC_ATTRS; +char *strpbrk(char *, const char *) noexcept __LIBC_ATTRS; +const char *strpbrk(const char *, const char *) noexcept __LIBC_ATTRS; +char *strrchr(char *, int) noexcept __LIBC_ATTRS; +const char *strrchr(const char *, int) noexcept __LIBC_ATTRS; +char *strchr(char *, int) noexcept __LIBC_ATTRS; +const char *strchr(const char *, int) noexcept __LIBC_ATTRS; +char *strchrnul(char *, int) noexcept __LIBC_ATTRS; +const char *strchrnul(const char *, int) noexcept __LIBC_ATTRS; +char *strcasestr(char *, const char *) noexcept __LIBC_ATTRS; +const char *strcasestr(const char *, const char *) noexcept __LIBC_ATTRS; +void *memrchr(void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; +const void *memrchr(const void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; +void *memchr(void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; +const void *memchr(const void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; +} + +#else +#include + +#endif + +#pragma omp end declare target + +#undef __LIBC_ATTRS + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/time.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/time.h new file mode 100755 index 0000000..9d1340c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_libc_wrappers/time.h @@ -0,0 +1,34 @@ +//===-- Wrapper for C standard time.h declarations on the GPU -------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__ +#define __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__ + +#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__) +#error "This file is for GPU offloading compilation only" +#endif + +#include_next + +#if __has_include() + +#if defined(__HIP__) || defined(__CUDA__) +#define __LIBC_ATTRS __attribute__((device)) +#endif + +#pragma omp begin declare target + +_Static_assert(sizeof(clock_t) == sizeof(long), "ABI mismatch!"); + +#include + +#pragma omp end declare target + +#endif + +#endif // __CLANG_LLVM_LIBC_WRAPPERS_TIME_H__ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload.h new file mode 100755 index 0000000..2898898 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload.h @@ -0,0 +1,31 @@ +/*===------ LLVM/Offload helpers for kernel languages (CUDA/HIP) -*- c++ -*-=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#include + +#define __host__ __attribute__((host)) +#define __device__ __attribute__((device)) +#define __global__ __attribute__((global)) +#define __shared__ __attribute__((shared)) +#define __constant__ __attribute__((constant)) +#define __managed__ __attribute__((managed)) + +extern "C" { + +typedef struct dim3 { + dim3() {} + dim3(unsigned x) : x(x) {} + unsigned x = 0, y = 0, z = 0; +} dim3; + +// TODO: For some reason the CUDA device compilation requires this declaration +// to be present on the device while it is only used on the host. +unsigned __llvmPushCallConfiguration(dim3 gridDim, dim3 blockDim, + size_t sharedMem = 0, void *stream = 0); +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload_device.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload_device.h new file mode 100755 index 0000000..1a813b3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload_device.h @@ -0,0 +1,10 @@ +/*===------ LLVM/Offload helpers for kernel languages (CUDA/HIP) -*- c++ -*-=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#include "__llvm_offload.h" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload_host.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload_host.h new file mode 100755 index 0000000..160289d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/llvm_offload_wrappers/__llvm_offload_host.h @@ -0,0 +1,15 @@ +/*===------ LLVM/Offload helpers for kernel languages (CUDA/HIP) -*- c++ -*-=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#include "__llvm_offload.h" + +extern "C" { +unsigned llvmLaunchKernel(const void *func, dim3 gridDim, dim3 blockDim, + void **args, size_t sharedMem = 0, void *stream = 0); +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lsxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lsxintrin.h new file mode 100755 index 0000000..a9b1922 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lsxintrin.h @@ -0,0 +1,3752 @@ +/*===------------- lsxintrin.h - LoongArch LSX intrinsics ------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _LOONGSON_SXINTRIN_H +#define _LOONGSON_SXINTRIN_H 1 + +#if defined(__loongarch_sx) +typedef signed char v16i8 __attribute__((vector_size(16), aligned(16))); +typedef signed char v16i8_b __attribute__((vector_size(16), aligned(1))); +typedef unsigned char v16u8 __attribute__((vector_size(16), aligned(16))); +typedef unsigned char v16u8_b __attribute__((vector_size(16), aligned(1))); +typedef short v8i16 __attribute__((vector_size(16), aligned(16))); +typedef short v8i16_h __attribute__((vector_size(16), aligned(2))); +typedef unsigned short v8u16 __attribute__((vector_size(16), aligned(16))); +typedef unsigned short v8u16_h __attribute__((vector_size(16), aligned(2))); +typedef int v4i32 __attribute__((vector_size(16), aligned(16))); +typedef int v4i32_w __attribute__((vector_size(16), aligned(4))); +typedef unsigned int v4u32 __attribute__((vector_size(16), aligned(16))); +typedef unsigned int v4u32_w __attribute__((vector_size(16), aligned(4))); +typedef long long v2i64 __attribute__((vector_size(16), aligned(16))); +typedef long long v2i64_d __attribute__((vector_size(16), aligned(8))); +typedef unsigned long long v2u64 __attribute__((vector_size(16), aligned(16))); +typedef unsigned long long v2u64_d __attribute__((vector_size(16), aligned(8))); +typedef float v4f32 __attribute__((vector_size(16), aligned(16))); +typedef float v4f32_w __attribute__((vector_size(16), aligned(4))); +typedef double v2f64 __attribute__((vector_size(16), aligned(16))); +typedef double v2f64_d __attribute__((vector_size(16), aligned(8))); + +typedef long long __m128i __attribute__((__vector_size__(16), __may_alias__)); +typedef float __m128 __attribute__((__vector_size__(16), __may_alias__)); +typedef double __m128d __attribute__((__vector_size__(16), __may_alias__)); + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsll_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsll_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsll_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsll_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsll_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsll_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsll_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsll_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vslli_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vslli_b((v16i8)(_1), (_2))) + +#define __lsx_vslli_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vslli_h((v8i16)(_1), (_2))) + +#define __lsx_vslli_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslli_w((v4i32)(_1), (_2))) + +#define __lsx_vslli_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vslli_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsra_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsra_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsra_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsra_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsra_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsra_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsra_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsra_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vsrai_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsrai_b((v16i8)(_1), (_2))) + +#define __lsx_vsrai_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsrai_h((v8i16)(_1), (_2))) + +#define __lsx_vsrai_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsrai_w((v4i32)(_1), (_2))) + +#define __lsx_vsrai_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vsrai_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrar_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrar_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrar_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrar_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrar_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrar_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrar_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrar_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vsrari_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsrari_b((v16i8)(_1), (_2))) + +#define __lsx_vsrari_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsrari_h((v8i16)(_1), (_2))) + +#define __lsx_vsrari_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsrari_w((v4i32)(_1), (_2))) + +#define __lsx_vsrari_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vsrari_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrl_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrl_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrl_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrl_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrl_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrl_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrl_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrl_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vsrli_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsrli_b((v16i8)(_1), (_2))) + +#define __lsx_vsrli_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsrli_h((v8i16)(_1), (_2))) + +#define __lsx_vsrli_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsrli_w((v4i32)(_1), (_2))) + +#define __lsx_vsrli_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vsrli_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlr_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlr_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlr_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlr_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlr_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlr_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlr_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlr_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vsrlri_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsrlri_b((v16i8)(_1), (_2))) + +#define __lsx_vsrlri_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsrlri_h((v8i16)(_1), (_2))) + +#define __lsx_vsrlri_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsrlri_w((v4i32)(_1), (_2))) + +#define __lsx_vsrlri_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vsrlri_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitclr_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitclr_b((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitclr_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitclr_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitclr_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitclr_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitclr_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitclr_d((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vbitclri_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vbitclri_b((v16u8)(_1), (_2))) + +#define __lsx_vbitclri_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vbitclri_h((v8u16)(_1), (_2))) + +#define __lsx_vbitclri_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vbitclri_w((v4u32)(_1), (_2))) + +#define __lsx_vbitclri_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vbitclri_d((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitset_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitset_b((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitset_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitset_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitset_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitset_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitset_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitset_d((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vbitseti_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vbitseti_b((v16u8)(_1), (_2))) + +#define __lsx_vbitseti_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vbitseti_h((v8u16)(_1), (_2))) + +#define __lsx_vbitseti_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vbitseti_w((v4u32)(_1), (_2))) + +#define __lsx_vbitseti_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vbitseti_d((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitrev_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitrev_b((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitrev_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitrev_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitrev_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitrev_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitrev_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vbitrev_d((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vbitrevi_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vbitrevi_b((v16u8)(_1), (_2))) + +#define __lsx_vbitrevi_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vbitrevi_h((v8u16)(_1), (_2))) + +#define __lsx_vbitrevi_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vbitrevi_w((v4u32)(_1), (_2))) + +#define __lsx_vbitrevi_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vbitrevi_d((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadd_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadd_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadd_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadd_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadd_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadd_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadd_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadd_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vaddi_bu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vaddi_bu((v16i8)(_1), (_2))) + +#define __lsx_vaddi_hu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vaddi_hu((v8i16)(_1), (_2))) + +#define __lsx_vaddi_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vaddi_wu((v4i32)(_1), (_2))) + +#define __lsx_vaddi_du(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vaddi_du((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsub_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsub_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsub_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsub_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsub_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsub_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsub_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsub_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vsubi_bu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsubi_bu((v16i8)(_1), (_2))) + +#define __lsx_vsubi_hu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsubi_hu((v8i16)(_1), (_2))) + +#define __lsx_vsubi_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsubi_wu((v4i32)(_1), (_2))) + +#define __lsx_vsubi_du(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsubi_du((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vmaxi_b(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_b((v16i8)(_1), (_2))) + +#define __lsx_vmaxi_h(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_h((v8i16)(_1), (_2))) + +#define __lsx_vmaxi_w(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_w((v4i32)(_1), (_2))) + +#define __lsx_vmaxi_d(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmax_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmax_du((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vmaxi_bu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_bu((v16u8)(_1), (_2))) + +#define __lsx_vmaxi_hu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_hu((v8u16)(_1), (_2))) + +#define __lsx_vmaxi_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_wu((v4u32)(_1), (_2))) + +#define __lsx_vmaxi_du(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmaxi_du((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vmini_b(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_b((v16i8)(_1), (_2))) + +#define __lsx_vmini_h(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_h((v8i16)(_1), (_2))) + +#define __lsx_vmini_w(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_w((v4i32)(_1), (_2))) + +#define __lsx_vmini_d(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmin_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmin_du((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vmini_bu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_bu((v16u8)(_1), (_2))) + +#define __lsx_vmini_hu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_hu((v8u16)(_1), (_2))) + +#define __lsx_vmini_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_wu((v4u32)(_1), (_2))) + +#define __lsx_vmini_du(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vmini_du((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vseq_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vseq_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vseq_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vseq_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vseq_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vseq_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vseq_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vseq_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vseqi_b(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vseqi_b((v16i8)(_1), (_2))) + +#define __lsx_vseqi_h(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vseqi_h((v8i16)(_1), (_2))) + +#define __lsx_vseqi_w(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vseqi_w((v4i32)(_1), (_2))) + +#define __lsx_vseqi_d(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vseqi_d((v2i64)(_1), (_2))) + +#define __lsx_vslti_b(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_b((v16i8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vslti_h(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_h((v8i16)(_1), (_2))) + +#define __lsx_vslti_w(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_w((v4i32)(_1), (_2))) + +#define __lsx_vslti_d(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vslt_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vslt_du((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vslti_bu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_bu((v16u8)(_1), (_2))) + +#define __lsx_vslti_hu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_hu((v8u16)(_1), (_2))) + +#define __lsx_vslti_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_wu((v4u32)(_1), (_2))) + +#define __lsx_vslti_du(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslti_du((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_d((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vslei_b(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_b((v16i8)(_1), (_2))) + +#define __lsx_vslei_h(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_h((v8i16)(_1), (_2))) + +#define __lsx_vslei_w(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_w((v4i32)(_1), (_2))) + +#define __lsx_vslei_d(/*__m128i*/ _1, /*si5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsle_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsle_du((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vslei_bu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_bu((v16u8)(_1), (_2))) + +#define __lsx_vslei_hu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_hu((v8u16)(_1), (_2))) + +#define __lsx_vslei_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_wu((v4u32)(_1), (_2))) + +#define __lsx_vslei_du(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vslei_du((v2u64)(_1), (_2))) + +#define __lsx_vsat_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsat_b((v16i8)(_1), (_2))) + +#define __lsx_vsat_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsat_h((v8i16)(_1), (_2))) + +#define __lsx_vsat_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsat_w((v4i32)(_1), (_2))) + +#define __lsx_vsat_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vsat_d((v2i64)(_1), (_2))) + +#define __lsx_vsat_bu(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsat_bu((v16u8)(_1), (_2))) + +#define __lsx_vsat_hu(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsat_hu((v8u16)(_1), (_2))) + +#define __lsx_vsat_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsat_wu((v4u32)(_1), (_2))) + +#define __lsx_vsat_du(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vsat_du((v2u64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadda_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadda_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadda_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadda_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadda_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadda_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadda_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadda_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsadd_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsadd_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavg_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavg_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vavgr_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vavgr_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssub_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssub_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vabsd_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vabsd_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmul_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmul_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmul_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmul_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmul_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmul_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmul_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmul_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmadd_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmadd_b((v16i8)_1, (v16i8)_2, (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmadd_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmadd_h((v8i16)_1, (v8i16)_2, (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmadd_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmadd_w((v4i32)_1, (v4i32)_2, (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmadd_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmadd_d((v2i64)_1, (v2i64)_2, (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmsub_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmsub_b((v16i8)_1, (v16i8)_2, (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmsub_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmsub_h((v8i16)_1, (v8i16)_2, (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmsub_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmsub_w((v4i32)_1, (v4i32)_2, (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmsub_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmsub_d((v2i64)_1, (v2i64)_2, (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vdiv_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vdiv_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_hu_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_hu_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_wu_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_wu_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_du_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_du_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_hu_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_hu_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_wu_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_wu_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_du_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_du_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmod_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmod_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplve_b(__m128i _1, int _2) { + return (__m128i)__builtin_lsx_vreplve_b((v16i8)_1, (int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplve_h(__m128i _1, int _2) { + return (__m128i)__builtin_lsx_vreplve_h((v8i16)_1, (int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplve_w(__m128i _1, int _2) { + return (__m128i)__builtin_lsx_vreplve_w((v4i32)_1, (int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplve_d(__m128i _1, int _2) { + return (__m128i)__builtin_lsx_vreplve_d((v2i64)_1, (int)_2); +} + +#define __lsx_vreplvei_b(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vreplvei_b((v16i8)(_1), (_2))) + +#define __lsx_vreplvei_h(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vreplvei_h((v8i16)(_1), (_2))) + +#define __lsx_vreplvei_w(/*__m128i*/ _1, /*ui2*/ _2) \ + ((__m128i)__builtin_lsx_vreplvei_w((v4i32)(_1), (_2))) + +#define __lsx_vreplvei_d(/*__m128i*/ _1, /*ui1*/ _2) \ + ((__m128i)__builtin_lsx_vreplvei_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickev_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickev_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickev_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickev_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickev_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickev_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickev_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickev_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickod_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickod_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickod_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickod_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickod_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickod_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpickod_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpickod_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvh_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvh_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvh_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvh_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvh_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvh_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvh_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvh_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvl_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvl_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvl_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvl_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvl_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvl_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vilvl_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vilvl_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackev_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackev_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackev_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackev_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackev_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackev_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackev_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackev_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackod_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackod_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackod_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackod_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackod_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackod_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpackod_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vpackod_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vshuf_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vshuf_h((v8i16)_1, (v8i16)_2, (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vshuf_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vshuf_w((v4i32)_1, (v4i32)_2, (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vshuf_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vshuf_d((v2i64)_1, (v2i64)_2, (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vand_v(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vand_v((v16u8)_1, (v16u8)_2); +} + +#define __lsx_vandi_b(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vandi_b((v16u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vor_v(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vor_v((v16u8)_1, (v16u8)_2); +} + +#define __lsx_vori_b(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vori_b((v16u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vnor_v(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vnor_v((v16u8)_1, (v16u8)_2); +} + +#define __lsx_vnori_b(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vnori_b((v16u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vxor_v(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vxor_v((v16u8)_1, (v16u8)_2); +} + +#define __lsx_vxori_b(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vxori_b((v16u8)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vbitsel_v(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vbitsel_v((v16u8)_1, (v16u8)_2, (v16u8)_3); +} + +#define __lsx_vbitseli_b(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vbitseli_b((v16u8)(_1), (v16u8)(_2), (_3))) + +#define __lsx_vshuf4i_b(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vshuf4i_b((v16i8)(_1), (_2))) + +#define __lsx_vshuf4i_h(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vshuf4i_h((v8i16)(_1), (_2))) + +#define __lsx_vshuf4i_w(/*__m128i*/ _1, /*ui8*/ _2) \ + ((__m128i)__builtin_lsx_vshuf4i_w((v4i32)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplgr2vr_b(int _1) { + return (__m128i)__builtin_lsx_vreplgr2vr_b((int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplgr2vr_h(int _1) { + return (__m128i)__builtin_lsx_vreplgr2vr_h((int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplgr2vr_w(int _1) { + return (__m128i)__builtin_lsx_vreplgr2vr_w((int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vreplgr2vr_d(long int _1) { + return (__m128i)__builtin_lsx_vreplgr2vr_d((long int)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpcnt_b(__m128i _1) { + return (__m128i)__builtin_lsx_vpcnt_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpcnt_h(__m128i _1) { + return (__m128i)__builtin_lsx_vpcnt_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpcnt_w(__m128i _1) { + return (__m128i)__builtin_lsx_vpcnt_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vpcnt_d(__m128i _1) { + return (__m128i)__builtin_lsx_vpcnt_d((v2i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclo_b(__m128i _1) { + return (__m128i)__builtin_lsx_vclo_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclo_h(__m128i _1) { + return (__m128i)__builtin_lsx_vclo_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclo_w(__m128i _1) { + return (__m128i)__builtin_lsx_vclo_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclo_d(__m128i _1) { + return (__m128i)__builtin_lsx_vclo_d((v2i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclz_b(__m128i _1) { + return (__m128i)__builtin_lsx_vclz_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclz_h(__m128i _1) { + return (__m128i)__builtin_lsx_vclz_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclz_w(__m128i _1) { + return (__m128i)__builtin_lsx_vclz_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vclz_d(__m128i _1) { + return (__m128i)__builtin_lsx_vclz_d((v2i64)_1); +} + +#define __lsx_vpickve2gr_b(/*__m128i*/ _1, /*ui4*/ _2) \ + ((int)__builtin_lsx_vpickve2gr_b((v16i8)(_1), (_2))) + +#define __lsx_vpickve2gr_h(/*__m128i*/ _1, /*ui3*/ _2) \ + ((int)__builtin_lsx_vpickve2gr_h((v8i16)(_1), (_2))) + +#define __lsx_vpickve2gr_w(/*__m128i*/ _1, /*ui2*/ _2) \ + ((int)__builtin_lsx_vpickve2gr_w((v4i32)(_1), (_2))) + +#define __lsx_vpickve2gr_d(/*__m128i*/ _1, /*ui1*/ _2) \ + ((long int)__builtin_lsx_vpickve2gr_d((v2i64)(_1), (_2))) + +#define __lsx_vpickve2gr_bu(/*__m128i*/ _1, /*ui4*/ _2) \ + ((unsigned int)__builtin_lsx_vpickve2gr_bu((v16i8)(_1), (_2))) + +#define __lsx_vpickve2gr_hu(/*__m128i*/ _1, /*ui3*/ _2) \ + ((unsigned int)__builtin_lsx_vpickve2gr_hu((v8i16)(_1), (_2))) + +#define __lsx_vpickve2gr_wu(/*__m128i*/ _1, /*ui2*/ _2) \ + ((unsigned int)__builtin_lsx_vpickve2gr_wu((v4i32)(_1), (_2))) + +#define __lsx_vpickve2gr_du(/*__m128i*/ _1, /*ui1*/ _2) \ + ((unsigned long int)__builtin_lsx_vpickve2gr_du((v2i64)(_1), (_2))) + +#define __lsx_vinsgr2vr_b(/*__m128i*/ _1, /*int*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vinsgr2vr_b((v16i8)(_1), (int)(_2), (_3))) + +#define __lsx_vinsgr2vr_h(/*__m128i*/ _1, /*int*/ _2, /*ui3*/ _3) \ + ((__m128i)__builtin_lsx_vinsgr2vr_h((v8i16)(_1), (int)(_2), (_3))) + +#define __lsx_vinsgr2vr_w(/*__m128i*/ _1, /*int*/ _2, /*ui2*/ _3) \ + ((__m128i)__builtin_lsx_vinsgr2vr_w((v4i32)(_1), (int)(_2), (_3))) + +#define __lsx_vinsgr2vr_d(/*__m128i*/ _1, /*long int*/ _2, /*ui1*/ _3) \ + ((__m128i)__builtin_lsx_vinsgr2vr_d((v2i64)(_1), (long int)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfadd_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfadd_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfadd_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfadd_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfsub_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfsub_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfsub_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfsub_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmul_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfmul_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmul_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfmul_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfdiv_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfdiv_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfdiv_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfdiv_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcvt_h_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcvt_h_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfcvt_s_d(__m128d _1, __m128d _2) { + return (__m128)__builtin_lsx_vfcvt_s_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmin_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfmin_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmin_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfmin_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmina_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfmina_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmina_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfmina_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmax_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfmax_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmax_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfmax_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmaxa_s(__m128 _1, __m128 _2) { + return (__m128)__builtin_lsx_vfmaxa_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmaxa_d(__m128d _1, __m128d _2) { + return (__m128d)__builtin_lsx_vfmaxa_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfclass_s(__m128 _1) { + return (__m128i)__builtin_lsx_vfclass_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfclass_d(__m128d _1) { + return (__m128i)__builtin_lsx_vfclass_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfsqrt_s(__m128 _1) { + return (__m128)__builtin_lsx_vfsqrt_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfsqrt_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfsqrt_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrecip_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrecip_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrecip_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrecip_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrint_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrint_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrint_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrint_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrsqrt_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrsqrt_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrsqrt_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrsqrt_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vflogb_s(__m128 _1) { + return (__m128)__builtin_lsx_vflogb_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vflogb_d(__m128d _1) { + return (__m128d)__builtin_lsx_vflogb_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfcvth_s_h(__m128i _1) { + return (__m128)__builtin_lsx_vfcvth_s_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfcvth_d_s(__m128 _1) { + return (__m128d)__builtin_lsx_vfcvth_d_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfcvtl_s_h(__m128i _1) { + return (__m128)__builtin_lsx_vfcvtl_s_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfcvtl_d_s(__m128 _1) { + return (__m128d)__builtin_lsx_vfcvtl_d_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftint_w_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftint_w_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftint_l_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftint_l_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftint_wu_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftint_wu_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftint_lu_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftint_lu_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrz_w_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrz_w_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrz_l_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftintrz_l_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrz_wu_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrz_wu_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrz_lu_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftintrz_lu_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vffint_s_w(__m128i _1) { + return (__m128)__builtin_lsx_vffint_s_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vffint_d_l(__m128i _1) { + return (__m128d)__builtin_lsx_vffint_d_l((v2i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vffint_s_wu(__m128i _1) { + return (__m128)__builtin_lsx_vffint_s_wu((v4u32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vffint_d_lu(__m128i _1) { + return (__m128d)__builtin_lsx_vffint_d_lu((v2u64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vandn_v(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vandn_v((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vneg_b(__m128i _1) { + return (__m128i)__builtin_lsx_vneg_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vneg_h(__m128i _1) { + return (__m128i)__builtin_lsx_vneg_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vneg_w(__m128i _1) { + return (__m128i)__builtin_lsx_vneg_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vneg_d(__m128i _1) { + return (__m128i)__builtin_lsx_vneg_d((v2i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmuh_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmuh_du((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vsllwil_h_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsllwil_h_b((v16i8)(_1), (_2))) + +#define __lsx_vsllwil_w_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsllwil_w_h((v8i16)(_1), (_2))) + +#define __lsx_vsllwil_d_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsllwil_d_w((v4i32)(_1), (_2))) + +#define __lsx_vsllwil_hu_bu(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vsllwil_hu_bu((v16u8)(_1), (_2))) + +#define __lsx_vsllwil_wu_hu(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vsllwil_wu_hu((v8u16)(_1), (_2))) + +#define __lsx_vsllwil_du_wu(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vsllwil_du_wu((v4u32)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsran_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsran_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsran_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsran_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsran_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsran_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssran_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssran_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssran_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssran_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssran_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssran_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssran_bu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssran_bu_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssran_hu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssran_hu_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssran_wu_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssran_wu_d((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrarn_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrarn_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrarn_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrarn_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrarn_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrarn_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrarn_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrarn_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrarn_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrarn_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrarn_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrarn_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrarn_bu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrarn_bu_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrarn_hu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrarn_hu_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrarn_wu_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrarn_wu_d((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrln_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrln_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrln_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrln_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrln_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrln_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrln_bu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrln_bu_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrln_hu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrln_hu_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrln_wu_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrln_wu_d((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlrn_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlrn_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlrn_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlrn_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsrlrn_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsrlrn_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrlrn_bu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrlrn_bu_h((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrlrn_hu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrlrn_hu_w((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrlrn_wu_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrlrn_wu_d((v2u64)_1, (v2u64)_2); +} + +#define __lsx_vfrstpi_b(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vfrstpi_b((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vfrstpi_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vfrstpi_h((v8i16)(_1), (v8i16)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfrstp_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vfrstp_b((v16i8)_1, (v16i8)_2, (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfrstp_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vfrstp_h((v8i16)_1, (v8i16)_2, (v8i16)_3); +} + +#define __lsx_vshuf4i_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vshuf4i_d((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vbsrl_v(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vbsrl_v((v16i8)(_1), (_2))) + +#define __lsx_vbsll_v(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vbsll_v((v16i8)(_1), (_2))) + +#define __lsx_vextrins_b(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vextrins_b((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vextrins_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vextrins_h((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vextrins_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vextrins_w((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vextrins_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vextrins_d((v2i64)(_1), (v2i64)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmskltz_b(__m128i _1) { + return (__m128i)__builtin_lsx_vmskltz_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmskltz_h(__m128i _1) { + return (__m128i)__builtin_lsx_vmskltz_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmskltz_w(__m128i _1) { + return (__m128i)__builtin_lsx_vmskltz_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmskltz_d(__m128i _1) { + return (__m128i)__builtin_lsx_vmskltz_d((v2i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsigncov_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsigncov_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsigncov_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsigncov_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsigncov_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsigncov_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsigncov_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsigncov_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmadd_s(__m128 _1, __m128 _2, __m128 _3) { + return (__m128)__builtin_lsx_vfmadd_s((v4f32)_1, (v4f32)_2, (v4f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmadd_d(__m128d _1, __m128d _2, __m128d _3) { + return (__m128d)__builtin_lsx_vfmadd_d((v2f64)_1, (v2f64)_2, (v2f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfmsub_s(__m128 _1, __m128 _2, __m128 _3) { + return (__m128)__builtin_lsx_vfmsub_s((v4f32)_1, (v4f32)_2, (v4f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfmsub_d(__m128d _1, __m128d _2, __m128d _3) { + return (__m128d)__builtin_lsx_vfmsub_d((v2f64)_1, (v2f64)_2, (v2f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfnmadd_s(__m128 _1, __m128 _2, __m128 _3) { + return (__m128)__builtin_lsx_vfnmadd_s((v4f32)_1, (v4f32)_2, (v4f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfnmadd_d(__m128d _1, __m128d _2, __m128d _3) { + return (__m128d)__builtin_lsx_vfnmadd_d((v2f64)_1, (v2f64)_2, (v2f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfnmsub_s(__m128 _1, __m128 _2, __m128 _3) { + return (__m128)__builtin_lsx_vfnmsub_s((v4f32)_1, (v4f32)_2, (v4f32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfnmsub_d(__m128d _1, __m128d _2, __m128d _3) { + return (__m128d)__builtin_lsx_vfnmsub_d((v2f64)_1, (v2f64)_2, (v2f64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrne_w_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrne_w_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrne_l_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftintrne_l_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrp_w_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrp_w_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrp_l_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftintrp_l_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrm_w_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrm_w_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrm_l_d(__m128d _1) { + return (__m128i)__builtin_lsx_vftintrm_l_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftint_w_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vftint_w_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vffint_s_l(__m128i _1, __m128i _2) { + return (__m128)__builtin_lsx_vffint_s_l((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrz_w_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vftintrz_w_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrp_w_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vftintrp_w_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrm_w_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vftintrm_w_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrne_w_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vftintrne_w_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintl_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintl_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftinth_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftinth_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vffinth_d_w(__m128i _1) { + return (__m128d)__builtin_lsx_vffinth_d_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vffintl_d_w(__m128i _1) { + return (__m128d)__builtin_lsx_vffintl_d_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrzl_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrzl_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrzh_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrzh_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrpl_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrpl_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrph_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrph_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrml_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrml_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrmh_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrmh_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrnel_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrnel_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vftintrneh_l_s(__m128 _1) { + return (__m128i)__builtin_lsx_vftintrneh_l_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrintrne_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrintrne_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrintrne_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrintrne_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrintrz_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrintrz_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrintrz_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrintrz_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrintrp_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrintrp_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrintrp_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrintrp_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrintrm_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrintrm_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrintrm_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrintrm_d((v2f64)_1); +} + +#define __lsx_vstelm_b(/*__m128i*/ _1, /*void **/ _2, /*si8*/ _3, /*idx*/ _4) \ + ((void)__builtin_lsx_vstelm_b((v16i8)(_1), (void *)(_2), (_3), (_4))) + +#define __lsx_vstelm_h(/*__m128i*/ _1, /*void **/ _2, /*si8*/ _3, /*idx*/ _4) \ + ((void)__builtin_lsx_vstelm_h((v8i16)(_1), (void *)(_2), (_3), (_4))) + +#define __lsx_vstelm_w(/*__m128i*/ _1, /*void **/ _2, /*si8*/ _3, /*idx*/ _4) \ + ((void)__builtin_lsx_vstelm_w((v4i32)(_1), (void *)(_2), (_3), (_4))) + +#define __lsx_vstelm_d(/*__m128i*/ _1, /*void **/ _2, /*si8*/ _3, /*idx*/ _4) \ + ((void)__builtin_lsx_vstelm_d((v2i64)(_1), (void *)(_2), (_3), (_4))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_d_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_d_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_w_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_w_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_h_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_h_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_d_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_d_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_w_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_w_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_h_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_h_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_d_wu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_d_wu_w((v4u32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_w_hu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_w_hu_h((v8u16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_h_bu_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_h_bu_b((v16u8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_d_wu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_d_wu_w((v4u32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_w_hu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_w_hu_h((v8u16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_h_bu_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_h_bu_b((v16u8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_d_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_d_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_w_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_w_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_h_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_h_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_d_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_d_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_w_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_w_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_h_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_h_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_q_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_q_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_q_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_q_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwev_q_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwev_q_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsubwod_q_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsubwod_q_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwev_q_du_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwev_q_du_d((v2u64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vaddwod_q_du_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vaddwod_q_du_d((v2u64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_d_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_d_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_w_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_w_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_h_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_h_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_d_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_d_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_w_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_w_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_h_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_h_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_d_wu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_d_wu((v4u32)_1, (v4u32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_w_hu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_w_hu((v8u16)_1, (v8u16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_h_bu(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_h_bu((v16u8)_1, (v16u8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_d_wu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_d_wu_w((v4u32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_w_hu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_w_hu_h((v8u16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_h_bu_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_h_bu_b((v16u8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_d_wu_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_d_wu_w((v4u32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_w_hu_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_w_hu_h((v8u16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_h_bu_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_h_bu_b((v16u8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_q_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_q_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_q_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_q_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwev_q_du_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwev_q_du_d((v2u64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmulwod_q_du_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vmulwod_q_du_d((v2u64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhaddw_qu_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhaddw_qu_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_q_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_q_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vhsubw_qu_du(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vhsubw_qu_du((v2u64)_1, (v2u64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_d_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_d_w((v2i64)_1, (v4i32)_2, (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_w_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_w_h((v4i32)_1, (v8i16)_2, (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_h_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_h_b((v8i16)_1, (v16i8)_2, (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_d_wu(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_d_wu((v2u64)_1, (v4u32)_2, (v4u32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_w_hu(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_w_hu((v4u32)_1, (v8u16)_2, (v8u16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_h_bu(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_h_bu((v8u16)_1, (v16u8)_2, (v16u8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_d_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_d_w((v2i64)_1, (v4i32)_2, (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_w_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_w_h((v4i32)_1, (v8i16)_2, (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_h_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_h_b((v8i16)_1, (v16i8)_2, (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_d_wu(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_d_wu((v2u64)_1, (v4u32)_2, (v4u32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_w_hu(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_w_hu((v4u32)_1, (v8u16)_2, (v8u16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_h_bu(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_h_bu((v8u16)_1, (v16u8)_2, (v16u8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_d_wu_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_d_wu_w((v2i64)_1, (v4u32)_2, + (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_w_hu_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_w_hu_h((v4i32)_1, (v8u16)_2, + (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_h_bu_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_h_bu_b((v8i16)_1, (v16u8)_2, + (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_d_wu_w(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_d_wu_w((v2i64)_1, (v4u32)_2, + (v4i32)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_w_hu_h(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_w_hu_h((v4i32)_1, (v8u16)_2, + (v8i16)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_h_bu_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_h_bu_b((v8i16)_1, (v16u8)_2, + (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_q_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_q_d((v2i64)_1, (v2i64)_2, (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_q_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_q_d((v2i64)_1, (v2i64)_2, (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_q_du(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_q_du((v2u64)_1, (v2u64)_2, (v2u64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_q_du(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_q_du((v2u64)_1, (v2u64)_2, (v2u64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwev_q_du_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwev_q_du_d((v2i64)_1, (v2u64)_2, + (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmaddwod_q_du_d(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vmaddwod_q_du_d((v2i64)_1, (v2u64)_2, + (v2i64)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vrotr_b(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vrotr_b((v16i8)_1, (v16i8)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vrotr_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vrotr_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vrotr_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vrotr_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vrotr_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vrotr_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vadd_q(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vadd_q((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vsub_q(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vsub_q((v2i64)_1, (v2i64)_2); +} + +#define __lsx_vldrepl_b(/*void **/ _1, /*si12*/ _2) \ + ((__m128i)__builtin_lsx_vldrepl_b((void const *)(_1), (_2))) + +#define __lsx_vldrepl_h(/*void **/ _1, /*si11*/ _2) \ + ((__m128i)__builtin_lsx_vldrepl_h((void const *)(_1), (_2))) + +#define __lsx_vldrepl_w(/*void **/ _1, /*si10*/ _2) \ + ((__m128i)__builtin_lsx_vldrepl_w((void const *)(_1), (_2))) + +#define __lsx_vldrepl_d(/*void **/ _1, /*si9*/ _2) \ + ((__m128i)__builtin_lsx_vldrepl_d((void const *)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmskgez_b(__m128i _1) { + return (__m128i)__builtin_lsx_vmskgez_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vmsknz_b(__m128i _1) { + return (__m128i)__builtin_lsx_vmsknz_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_h_b(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_h_b((v16i8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_w_h(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_w_h((v8i16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_d_w(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_d_w((v4i32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_q_d(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_q_d((v2i64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_hu_bu(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_hu_bu((v16u8)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_wu_hu(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_wu_hu((v8u16)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_du_wu(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_du_wu((v4u32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vexth_qu_du(__m128i _1) { + return (__m128i)__builtin_lsx_vexth_qu_du((v2u64)_1); +} + +#define __lsx_vrotri_b(/*__m128i*/ _1, /*ui3*/ _2) \ + ((__m128i)__builtin_lsx_vrotri_b((v16i8)(_1), (_2))) + +#define __lsx_vrotri_h(/*__m128i*/ _1, /*ui4*/ _2) \ + ((__m128i)__builtin_lsx_vrotri_h((v8i16)(_1), (_2))) + +#define __lsx_vrotri_w(/*__m128i*/ _1, /*ui5*/ _2) \ + ((__m128i)__builtin_lsx_vrotri_w((v4i32)(_1), (_2))) + +#define __lsx_vrotri_d(/*__m128i*/ _1, /*ui6*/ _2) \ + ((__m128i)__builtin_lsx_vrotri_d((v2i64)(_1), (_2))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vextl_q_d(__m128i _1) { + return (__m128i)__builtin_lsx_vextl_q_d((v2i64)_1); +} + +#define __lsx_vsrlni_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vsrlni_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vsrlni_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vsrlni_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vsrlni_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vsrlni_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vsrlni_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vsrlni_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vsrlrni_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vsrlrni_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vsrlrni_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vsrlrni_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vsrlrni_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vsrlrni_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vsrlrni_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vsrlrni_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrlni_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrlni_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrlni_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrlni_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrlni_bu_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_bu_h((v16u8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrlni_hu_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_hu_w((v8u16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrlni_wu_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_wu_d((v4u32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrlni_du_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrlni_du_q((v2u64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrlrni_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrlrni_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrlrni_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrlrni_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrlrni_bu_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_bu_h((v16u8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrlrni_hu_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_hu_w((v8u16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrlrni_wu_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_wu_d((v4u32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrlrni_du_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrlrni_du_q((v2u64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vsrani_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vsrani_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vsrani_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vsrani_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vsrani_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vsrani_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vsrani_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vsrani_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vsrarni_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vsrarni_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vsrarni_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vsrarni_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vsrarni_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vsrarni_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vsrarni_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vsrarni_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrani_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrani_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrani_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrani_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrani_bu_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_bu_h((v16u8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrani_hu_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_hu_w((v8u16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrani_wu_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_wu_d((v4u32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrani_du_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrani_du_q((v2u64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrarni_b_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_b_h((v16i8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrarni_h_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_h_w((v8i16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrarni_w_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_w_d((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrarni_d_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_d_q((v2i64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vssrarni_bu_h(/*__m128i*/ _1, /*__m128i*/ _2, /*ui4*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_bu_h((v16u8)(_1), (v16i8)(_2), (_3))) + +#define __lsx_vssrarni_hu_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui5*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_hu_w((v8u16)(_1), (v8i16)(_2), (_3))) + +#define __lsx_vssrarni_wu_d(/*__m128i*/ _1, /*__m128i*/ _2, /*ui6*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_wu_d((v4u32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vssrarni_du_q(/*__m128i*/ _1, /*__m128i*/ _2, /*ui7*/ _3) \ + ((__m128i)__builtin_lsx_vssrarni_du_q((v2u64)(_1), (v2i64)(_2), (_3))) + +#define __lsx_vpermi_w(/*__m128i*/ _1, /*__m128i*/ _2, /*ui8*/ _3) \ + ((__m128i)__builtin_lsx_vpermi_w((v4i32)(_1), (v4i32)(_2), (_3))) + +#define __lsx_vld(/*void **/ _1, /*si12*/ _2) \ + ((__m128i)__builtin_lsx_vld((void const *)(_1), (_2))) + +#define __lsx_vst(/*__m128i*/ _1, /*void **/ _2, /*si12*/ _3) \ + ((void)__builtin_lsx_vst((v16i8)(_1), (void *)(_2), (_3))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrlrn_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrlrn_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrlrn_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrlrn_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrlrn_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrlrn_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrln_b_h(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrln_b_h((v8i16)_1, (v8i16)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrln_h_w(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrln_h_w((v4i32)_1, (v4i32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vssrln_w_d(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vssrln_w_d((v2i64)_1, (v2i64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vorn_v(__m128i _1, __m128i _2) { + return (__m128i)__builtin_lsx_vorn_v((v16u8)_1, (v16u8)_2); +} + +#define __lsx_vldi(/*i13*/ _1) ((__m128i)__builtin_lsx_vldi((_1))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vshuf_b(__m128i _1, __m128i _2, __m128i _3) { + return (__m128i)__builtin_lsx_vshuf_b((v16i8)_1, (v16i8)_2, (v16i8)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vldx(void const *_1, long int _2) { + return (__m128i)__builtin_lsx_vldx((void const *)_1, (long int)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) void + __lsx_vstx(__m128i _1, void *_2, long int _3) { + return (void)__builtin_lsx_vstx((v16i8)_1, (void *)_2, (long int)_3); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vextl_qu_du(__m128i _1) { + return (__m128i)__builtin_lsx_vextl_qu_du((v2u64)_1); +} + +#define __lsx_bnz_b(/*__m128i*/ _1) ((int)__builtin_lsx_bnz_b((v16u8)(_1))) + +#define __lsx_bnz_d(/*__m128i*/ _1) ((int)__builtin_lsx_bnz_d((v2u64)(_1))) + +#define __lsx_bnz_h(/*__m128i*/ _1) ((int)__builtin_lsx_bnz_h((v8u16)(_1))) + +#define __lsx_bnz_v(/*__m128i*/ _1) ((int)__builtin_lsx_bnz_v((v16u8)(_1))) + +#define __lsx_bnz_w(/*__m128i*/ _1) ((int)__builtin_lsx_bnz_w((v4u32)(_1))) + +#define __lsx_bz_b(/*__m128i*/ _1) ((int)__builtin_lsx_bz_b((v16u8)(_1))) + +#define __lsx_bz_d(/*__m128i*/ _1) ((int)__builtin_lsx_bz_d((v2u64)(_1))) + +#define __lsx_bz_h(/*__m128i*/ _1) ((int)__builtin_lsx_bz_h((v8u16)(_1))) + +#define __lsx_bz_v(/*__m128i*/ _1) ((int)__builtin_lsx_bz_v((v16u8)(_1))) + +#define __lsx_bz_w(/*__m128i*/ _1) ((int)__builtin_lsx_bz_w((v4u32)(_1))) + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_caf_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_caf_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_caf_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_caf_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_ceq_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_ceq_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_ceq_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_ceq_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cle_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cle_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cle_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cle_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_clt_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_clt_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_clt_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_clt_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cne_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cne_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cne_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cne_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cor_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cor_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cor_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cor_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cueq_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cueq_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cueq_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cueq_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cule_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cule_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cule_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cule_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cult_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cult_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cult_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cult_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cun_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cun_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cune_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_cune_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cune_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cune_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_cun_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_cun_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_saf_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_saf_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_saf_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_saf_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_seq_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_seq_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_seq_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_seq_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sle_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sle_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sle_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sle_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_slt_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_slt_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_slt_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_slt_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sne_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sne_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sne_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sne_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sor_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sor_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sor_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sor_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sueq_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sueq_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sueq_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sueq_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sule_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sule_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sule_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sule_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sult_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sult_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sult_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sult_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sun_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sun_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sune_d(__m128d _1, __m128d _2) { + return (__m128i)__builtin_lsx_vfcmp_sune_d((v2f64)_1, (v2f64)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sune_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sune_s((v4f32)_1, (v4f32)_2); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128i + __lsx_vfcmp_sun_s(__m128 _1, __m128 _2) { + return (__m128i)__builtin_lsx_vfcmp_sun_s((v4f32)_1, (v4f32)_2); +} + +#if defined(__loongarch_frecipe) +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrecipe_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrecipe_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrecipe_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrecipe_d((v2f64)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128 + __lsx_vfrsqrte_s(__m128 _1) { + return (__m128)__builtin_lsx_vfrsqrte_s((v4f32)_1); +} + +extern __inline + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) __m128d + __lsx_vfrsqrte_d(__m128d _1) { + return (__m128d)__builtin_lsx_vfrsqrte_d((v2f64)_1); +} +#endif + +#define __lsx_vrepli_b(/*si10*/ _1) ((__m128i)__builtin_lsx_vrepli_b((_1))) + +#define __lsx_vrepli_d(/*si10*/ _1) ((__m128i)__builtin_lsx_vrepli_d((_1))) + +#define __lsx_vrepli_h(/*si10*/ _1) ((__m128i)__builtin_lsx_vrepli_h((_1))) + +#define __lsx_vrepli_w(/*si10*/ _1) ((__m128i)__builtin_lsx_vrepli_w((_1))) + +#endif /* defined(__loongarch_sx) */ +#endif /* _LOONGSON_SXINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lwpintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lwpintrin.h new file mode 100755 index 0000000..d8ab0db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lwpintrin.h @@ -0,0 +1,136 @@ +/*===---- lwpintrin.h - LWP intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __LWPINTRIN_H +#define __LWPINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("lwp"))) + +/// Parses the LWPCB at the specified address and enables +/// profiling if valid. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LLWPCB instruction. +/// +/// \param __addr +/// Address to the new Lightweight Profiling Control Block (LWPCB). If the +/// LWPCB is valid, writes the address into the LWP_CBADDR MSR and enables +/// Lightweight Profiling. +static __inline__ void __DEFAULT_FN_ATTRS +__llwpcb (void *__addr) +{ + __builtin_ia32_llwpcb(__addr); +} + +/// Flushes the LWP state to memory and returns the address of the LWPCB. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the SLWPCB instruction. +/// +/// \return +/// Address to the current Lightweight Profiling Control Block (LWPCB). +/// If LWP is not currently enabled, returns NULL. +static __inline__ void* __DEFAULT_FN_ATTRS +__slwpcb (void) +{ + return __builtin_ia32_slwpcb(); +} + +/// Inserts programmed event record into the LWP event ring buffer +/// and advances the ring buffer pointer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LWPINS instruction. +/// +/// \param DATA2 +/// A 32-bit value is zero-extended and inserted into the 64-bit Data2 field. +/// \param DATA1 +/// A 32-bit value is inserted into the 32-bit Data1 field. +/// \param FLAGS +/// A 32-bit immediate value is inserted into the 32-bit Flags field. +/// \returns If the ring buffer is full and LWP is running in Synchronized Mode, +/// the event record overwrites the last record in the buffer, the MissedEvents +/// counter in the LWPCB is incremented, the head pointer is not advanced, and +/// 1 is returned. Otherwise 0 is returned. +#define __lwpins32(DATA2, DATA1, FLAGS) \ + (__builtin_ia32_lwpins32((unsigned int) (DATA2), (unsigned int) (DATA1), \ + (unsigned int) (FLAGS))) + +/// Decrements the LWP programmed value sample event counter. If the result is +/// negative, inserts an event record into the LWP event ring buffer in memory +/// and advances the ring buffer pointer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LWPVAL instruction. +/// +/// \param DATA2 +/// A 32-bit value is zero-extended and inserted into the 64-bit Data2 field. +/// \param DATA1 +/// A 32-bit value is inserted into the 32-bit Data1 field. +/// \param FLAGS +/// A 32-bit immediate value is inserted into the 32-bit Flags field. +#define __lwpval32(DATA2, DATA1, FLAGS) \ + (__builtin_ia32_lwpval32((unsigned int) (DATA2), (unsigned int) (DATA1), \ + (unsigned int) (FLAGS))) + +#ifdef __x86_64__ + +/// Inserts programmed event record into the LWP event ring buffer +/// and advances the ring buffer pointer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LWPINS instruction. +/// +/// \param DATA2 +/// A 64-bit value is inserted into the 64-bit Data2 field. +/// \param DATA1 +/// A 32-bit value is inserted into the 32-bit Data1 field. +/// \param FLAGS +/// A 32-bit immediate value is inserted into the 32-bit Flags field. +/// \returns If the ring buffer is full and LWP is running in Synchronized Mode, +/// the event record overwrites the last record in the buffer, the MissedEvents +/// counter in the LWPCB is incremented, the head pointer is not advanced, and +/// 1 is returned. Otherwise 0 is returned. +#define __lwpins64(DATA2, DATA1, FLAGS) \ + (__builtin_ia32_lwpins64((unsigned long long) (DATA2), (unsigned int) (DATA1), \ + (unsigned int) (FLAGS))) + +/// Decrements the LWP programmed value sample event counter. If the result is +/// negative, inserts an event record into the LWP event ring buffer in memory +/// and advances the ring buffer pointer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LWPVAL instruction. +/// +/// \param DATA2 +/// A 64-bit value is and inserted into the 64-bit Data2 field. +/// \param DATA1 +/// A 32-bit value is inserted into the 32-bit Data1 field. +/// \param FLAGS +/// A 32-bit immediate value is inserted into the 32-bit Flags field. +#define __lwpval64(DATA2, DATA1, FLAGS) \ + (__builtin_ia32_lwpval64((unsigned long long) (DATA2), (unsigned int) (DATA1), \ + (unsigned int) (FLAGS))) + +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif /* __LWPINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lzcntintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lzcntintrin.h new file mode 100755 index 0000000..123a42a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/lzcntintrin.h @@ -0,0 +1,109 @@ +/*===---- lzcntintrin.h - LZCNT intrinsics ---------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __LZCNTINTRIN_H +#define __LZCNTINTRIN_H + +/* Define the default attributes for the functions in this file. + Allow using the lzcnt intrinsics even for non-LZCNT targets. Since the LZCNT + intrinsics are mapped to llvm.ctlz.*, false, which can be lowered to BSR on + non-LZCNT targets with zero-value input handled correctly. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__)) constexpr +#else +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) +#endif + +#ifndef _MSC_VER +/// Counts the number of leading zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c LZCNT instruction. +/// +/// \param __X +/// An unsigned 16-bit integer whose leading zeros are to be counted. +/// \returns An unsigned 16-bit integer containing the number of leading zero +/// bits in the operand. +#define __lzcnt16(X) __builtin_ia32_lzcnt_u16((unsigned short)(X)) +#endif // _MSC_VER + +/// Counts the number of leading zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c LZCNT instruction. +/// +/// \param __X +/// An unsigned 32-bit integer whose leading zeros are to be counted. +/// \returns An unsigned 32-bit integer containing the number of leading zero +/// bits in the operand. +/// \see _lzcnt_u32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__lzcnt32(unsigned int __X) { + return __builtin_ia32_lzcnt_u32(__X); +} + +/// Counts the number of leading zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c LZCNT instruction. +/// +/// \param __X +/// An unsigned 32-bit integer whose leading zeros are to be counted. +/// \returns An unsigned 32-bit integer containing the number of leading zero +/// bits in the operand. +/// \see __lzcnt32 +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_lzcnt_u32(unsigned int __X) { + return __builtin_ia32_lzcnt_u32(__X); +} + +#ifdef __x86_64__ +#ifndef _MSC_VER +/// Counts the number of leading zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c LZCNT instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose leading zeros are to be counted. +/// \returns An unsigned 64-bit integer containing the number of leading zero +/// bits in the operand. +/// \see _lzcnt_u64 +#define __lzcnt64(X) __builtin_ia32_lzcnt_u64((unsigned long long)(X)) +#endif // _MSC_VER + +/// Counts the number of leading zero bits in the operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c LZCNT instruction. +/// +/// \param __X +/// An unsigned 64-bit integer whose leading zeros are to be counted. +/// \returns An unsigned 64-bit integer containing the number of leading zero +/// bits in the operand. +/// \see __lzcnt64 +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +_lzcnt_u64(unsigned long long __X) { + return __builtin_ia32_lzcnt_u64(__X); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif /* __LZCNTINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mm3dnow.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mm3dnow.h new file mode 100755 index 0000000..afffba3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mm3dnow.h @@ -0,0 +1,22 @@ +/*===---- mm3dnow.h - 3DNow! intrinsics ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +// 3dNow intrinsics are no longer supported. + +#ifndef _MM3DNOW_H_INCLUDED +#define _MM3DNOW_H_INCLUDED + +#ifndef _CLANG_DISABLE_CRT_DEPRECATION_WARNINGS +#warning "The header is deprecated, and 3dNow! intrinsics are unsupported. For other intrinsics, include , instead." +#endif + +#include +#include + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mm_malloc.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mm_malloc.h new file mode 100755 index 0000000..d32fe59 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mm_malloc.h @@ -0,0 +1,67 @@ +/*===---- mm_malloc.h - Allocating and Freeing Aligned Memory Blocks -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __MM_MALLOC_H +#define __MM_MALLOC_H + +#include + +#ifdef _WIN32 +#include +#else +#ifndef __cplusplus +extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size); +#else +// Some systems (e.g. those with GNU libc) declare posix_memalign with an +// exception specifier. Via an "egregious workaround" in +// Sema::CheckEquivalentExceptionSpec, Clang accepts the following as a valid +// redeclaration of glibc's declaration. +extern "C" int posix_memalign(void **__memptr, size_t __alignment, size_t __size); +#endif +#endif + +#if !(defined(_WIN32) && defined(_mm_malloc)) +static __inline__ void *__attribute__((__always_inline__, __nodebug__, + __malloc__, __alloc_size__(1), + __alloc_align__(2))) +_mm_malloc(size_t __size, size_t __align) { + if (__align == 1) { + return malloc(__size); + } + + if (!(__align & (__align - 1)) && __align < sizeof(void *)) + __align = sizeof(void *); + + void *__mallocedMemory; +#if defined(__MINGW32__) + __mallocedMemory = __mingw_aligned_malloc(__size, __align); +#elif defined(_WIN32) + __mallocedMemory = _aligned_malloc(__size, __align); +#else + if (posix_memalign(&__mallocedMemory, __align, __size)) + return 0; +#endif + + return __mallocedMemory; +} + +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_mm_free(void *__p) +{ +#if defined(__MINGW32__) + __mingw_aligned_free(__p); +#elif defined(_WIN32) + _aligned_free(__p); +#else + free(__p); +#endif +} +#endif + +#endif /* __MM_MALLOC_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mmintrin.h new file mode 100755 index 0000000..dc0fa5c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mmintrin.h @@ -0,0 +1,1610 @@ +/*===---- mmintrin.h - MMX intrinsics --------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __MMINTRIN_H +#define __MMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +typedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8))); + +typedef long long __v1di __attribute__((__vector_size__(8))); +typedef int __v2si __attribute__((__vector_size__(8))); +typedef short __v4hi __attribute__((__vector_size__(8))); +typedef char __v8qi __attribute__((__vector_size__(8))); + +/* Unsigned types */ +typedef unsigned long long __v1du __attribute__ ((__vector_size__ (8))); +typedef unsigned int __v2su __attribute__ ((__vector_size__ (8))); +typedef unsigned short __v4hu __attribute__((__vector_size__(8))); +typedef unsigned char __v8qu __attribute__((__vector_size__(8))); + +/* We need an explicitly signed variant for char. Note that this shouldn't + * appear in the interface though. */ +typedef signed char __v8qs __attribute__((__vector_size__(8))); + +/* SSE/SSE2 types */ +typedef long long __m128i __attribute__((__vector_size__(16), __aligned__(16))); +typedef long long __v2di __attribute__ ((__vector_size__ (16))); +typedef int __v4si __attribute__((__vector_size__(16))); +typedef short __v8hi __attribute__((__vector_size__(16))); +typedef char __v16qi __attribute__((__vector_size__(16))); + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS_SSE2 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("sse2,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS_SSE2 \ + __attribute__((__always_inline__, __nodebug__, __target__("sse2"), \ + __min_vector_width__(128))) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR __DEFAULT_FN_ATTRS_SSE2 constexpr +#else +#define __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR __DEFAULT_FN_ATTRS_SSE2 +#endif + +#define __trunc64(x) \ + (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0) +#define __anyext128(x) \ + (__m128i) __builtin_shufflevector((__v2si)(x), __extension__(__v2si){}, 0, \ + 1, -1, -1) + +/// Clears the MMX state by setting the state of the x87 stack registers +/// to empty. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the EMMS instruction. +/// +static __inline__ void __attribute__((__always_inline__, __nodebug__, + __target__("mmx,no-evex512"))) +_mm_empty(void) { + __builtin_ia32_emms(); +} + +/// Constructs a 64-bit integer vector, setting the lower 32 bits to the +/// value of the 32-bit integer parameter and setting the upper 32 bits to 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVD instruction. +/// +/// \param __i +/// A 32-bit integer value. +/// \returns A 64-bit integer vector. The lower 32 bits contain the value of the +/// parameter. The upper 32 bits are set to 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtsi32_si64(int __i) +{ + return __extension__ (__m64)(__v2si){__i, 0}; +} + +/// Returns the lower 32 bits of a 64-bit integer vector as a 32-bit +/// signed integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVD instruction. +/// +/// \param __m +/// A 64-bit integer vector. +/// \returns A 32-bit signed integer value containing the lower 32 bits of the +/// parameter. +static __inline__ int __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtsi64_si32(__m64 __m) +{ + return ((__v2si)__m)[0]; +} + +/// Casts a 64-bit signed integer value into a 64-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVQ instruction. +/// +/// \param __i +/// A 64-bit signed integer. +/// \returns A 64-bit integer vector containing the same bitwise pattern as the +/// parameter. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtsi64_m64(long long __i) +{ + return (__m64)__i; +} + +/// Casts a 64-bit integer vector into a 64-bit signed integer value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVQ instruction. +/// +/// \param __m +/// A 64-bit integer vector. +/// \returns A 64-bit signed integer containing the same bitwise pattern as the +/// parameter. +static __inline__ long long __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtm64_si64(__m64 __m) +{ + return (long long)__m; +} + +/// Converts, with saturation, 16-bit signed integers from both 64-bit integer +/// vector parameters of [4 x i16] into 8-bit signed integer values, and +/// constructs a 64-bit integer vector of [8 x i8] as the result. +/// +/// Positive values greater than 0x7F are saturated to 0x7F. Negative values +/// less than 0x80 are saturated to 0x80. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PACKSSWB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. The converted [4 x i8] values are +/// written to the lower 32 bits of the result. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. The converted [4 x i8] values are +/// written to the upper 32 bits of the result. +/// \returns A 64-bit integer vector of [8 x i8] containing the converted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_packs_pi16(__m64 __m1, __m64 __m2) +{ + return __trunc64(__builtin_ia32_packsswb128( + (__v8hi)__builtin_shufflevector(__m1, __m2, 0, 1), (__v8hi){})); +} + +/// Converts, with saturation, 32-bit signed integers from both 64-bit integer +/// vector parameters of [2 x i32] into 16-bit signed integer values, and +/// constructs a 64-bit integer vector of [4 x i16] as the result. +/// +/// Positive values greater than 0x7FFF are saturated to 0x7FFF. Negative +/// values less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PACKSSDW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32]. The converted [2 x i16] values are +/// written to the lower 32 bits of the result. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32]. The converted [2 x i16] values are +/// written to the upper 32 bits of the result. +/// \returns A 64-bit integer vector of [4 x i16] containing the converted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_packs_pi32(__m64 __m1, __m64 __m2) +{ + return __trunc64(__builtin_ia32_packssdw128( + (__v4si)__builtin_shufflevector(__m1, __m2, 0, 1), (__v4si){})); +} + +/// Converts, with saturation, 16-bit signed integers from both 64-bit integer +/// vector parameters of [4 x i16] into 8-bit unsigned integer values, and +/// constructs a 64-bit integer vector of [8 x i8] as the result. +/// +/// Values greater than 0xFF are saturated to 0xFF. Values less than 0 are +/// saturated to 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PACKUSWB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. The converted [4 x i8] values are +/// written to the lower 32 bits of the result. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. The converted [4 x i8] values are +/// written to the upper 32 bits of the result. +/// \returns A 64-bit integer vector of [8 x i8] containing the converted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_packs_pu16(__m64 __m1, __m64 __m2) +{ + return __trunc64(__builtin_ia32_packuswb128( + (__v8hi)__builtin_shufflevector(__m1, __m2, 0, 1), (__v8hi){})); +} + +/// Unpacks the upper 32 bits from two 64-bit integer vectors of [8 x i8] +/// and interleaves them into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PUNPCKHBW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. \n +/// Bits [39:32] are written to bits [7:0] of the result. \n +/// Bits [47:40] are written to bits [23:16] of the result. \n +/// Bits [55:48] are written to bits [39:32] of the result. \n +/// Bits [63:56] are written to bits [55:48] of the result. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// Bits [39:32] are written to bits [15:8] of the result. \n +/// Bits [47:40] are written to bits [31:24] of the result. \n +/// Bits [55:48] are written to bits [47:40] of the result. \n +/// Bits [63:56] are written to bits [63:56] of the result. +/// \returns A 64-bit integer vector of [8 x i8] containing the interleaved +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_unpackhi_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_shufflevector((__v8qi)__m1, (__v8qi)__m2, + 4, 12, 5, 13, 6, 14, 7, 15); +} + +/// Unpacks the upper 32 bits from two 64-bit integer vectors of +/// [4 x i16] and interleaves them into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PUNPCKHWD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// Bits [47:32] are written to bits [15:0] of the result. \n +/// Bits [63:48] are written to bits [47:32] of the result. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// Bits [47:32] are written to bits [31:16] of the result. \n +/// Bits [63:48] are written to bits [63:48] of the result. +/// \returns A 64-bit integer vector of [4 x i16] containing the interleaved +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_unpackhi_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_shufflevector((__v4hi)__m1, (__v4hi)__m2, + 2, 6, 3, 7); +} + +/// Unpacks the upper 32 bits from two 64-bit integer vectors of +/// [2 x i32] and interleaves them into a 64-bit integer vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PUNPCKHDQ instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32]. The upper 32 bits are written to +/// the lower 32 bits of the result. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32]. The upper 32 bits are written to +/// the upper 32 bits of the result. +/// \returns A 64-bit integer vector of [2 x i32] containing the interleaved +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_unpackhi_pi32(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_shufflevector((__v2si)__m1, (__v2si)__m2, 1, 3); +} + +/// Unpacks the lower 32 bits from two 64-bit integer vectors of [8 x i8] +/// and interleaves them into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PUNPCKLBW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. +/// Bits [7:0] are written to bits [7:0] of the result. \n +/// Bits [15:8] are written to bits [23:16] of the result. \n +/// Bits [23:16] are written to bits [39:32] of the result. \n +/// Bits [31:24] are written to bits [55:48] of the result. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// Bits [7:0] are written to bits [15:8] of the result. \n +/// Bits [15:8] are written to bits [31:24] of the result. \n +/// Bits [23:16] are written to bits [47:40] of the result. \n +/// Bits [31:24] are written to bits [63:56] of the result. +/// \returns A 64-bit integer vector of [8 x i8] containing the interleaved +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_unpacklo_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_shufflevector((__v8qi)__m1, (__v8qi)__m2, + 0, 8, 1, 9, 2, 10, 3, 11); +} + +/// Unpacks the lower 32 bits from two 64-bit integer vectors of +/// [4 x i16] and interleaves them into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PUNPCKLWD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// Bits [15:0] are written to bits [15:0] of the result. \n +/// Bits [31:16] are written to bits [47:32] of the result. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// Bits [15:0] are written to bits [31:16] of the result. \n +/// Bits [31:16] are written to bits [63:48] of the result. +/// \returns A 64-bit integer vector of [4 x i16] containing the interleaved +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_unpacklo_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_shufflevector((__v4hi)__m1, (__v4hi)__m2, + 0, 4, 1, 5); +} + +/// Unpacks the lower 32 bits from two 64-bit integer vectors of +/// [2 x i32] and interleaves them into a 64-bit integer vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PUNPCKLDQ instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32]. The lower 32 bits are written to +/// the lower 32 bits of the result. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32]. The lower 32 bits are written to +/// the upper 32 bits of the result. +/// \returns A 64-bit integer vector of [2 x i32] containing the interleaved +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_unpacklo_pi32(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_shufflevector((__v2si)__m1, (__v2si)__m2, 0, 2); +} + +/// Adds each 8-bit integer element of the first 64-bit integer vector +/// of [8 x i8] to the corresponding 8-bit integer element of the second +/// 64-bit integer vector of [8 x i8]. The lower 8 bits of the results are +/// packed into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// \returns A 64-bit integer vector of [8 x i8] containing the sums of both +/// parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_add_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v8qu)__m1) + ((__v8qu)__m2)); +} + +/// Adds each 16-bit integer element of the first 64-bit integer vector +/// of [4 x i16] to the corresponding 16-bit integer element of the second +/// 64-bit integer vector of [4 x i16]. The lower 16 bits of the results are +/// packed into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the sums of both +/// parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_add_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v4hu)__m1) + ((__v4hu)__m2)); +} + +/// Adds each 32-bit integer element of the first 64-bit integer vector +/// of [2 x i32] to the corresponding 32-bit integer element of the second +/// 64-bit integer vector of [2 x i32]. The lower 32 bits of the results are +/// packed into a 64-bit integer vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32]. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32]. +/// \returns A 64-bit integer vector of [2 x i32] containing the sums of both +/// parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_add_pi32(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v2su)__m1) + ((__v2su)__m2)); +} + +/// Adds, with saturation, each 8-bit signed integer element of the first +/// 64-bit integer vector of [8 x i8] to the corresponding 8-bit signed +/// integer element of the second 64-bit integer vector of [8 x i8]. +/// +/// Positive sums greater than 0x7F are saturated to 0x7F. Negative sums +/// less than 0x80 are saturated to 0x80. The results are packed into a +/// 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDSB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// \returns A 64-bit integer vector of [8 x i8] containing the saturated sums +/// of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_adds_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_add_sat((__v8qs)__m1, (__v8qs)__m2); +} + +/// Adds, with saturation, each 16-bit signed integer element of the first +/// 64-bit integer vector of [4 x i16] to the corresponding 16-bit signed +/// integer element of the second 64-bit integer vector of [4 x i16]. +/// +/// Positive sums greater than 0x7FFF are saturated to 0x7FFF. Negative sums +/// less than 0x8000 are saturated to 0x8000. The results are packed into a +/// 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDSW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the saturated sums +/// of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_adds_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_add_sat((__v4hi)__m1, (__v4hi)__m2); +} + +/// Adds, with saturation, each 8-bit unsigned integer element of the first +/// 64-bit integer vector of [8 x i8] to the corresponding 8-bit unsigned +/// integer element of the second 64-bit integer vector of [8 x i8]. +/// +/// Sums greater than 0xFF are saturated to 0xFF. The results are packed +/// into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDUSB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// \returns A 64-bit integer vector of [8 x i8] containing the saturated +/// unsigned sums of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_adds_pu8(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_add_sat((__v8qu)__m1, (__v8qu)__m2); +} + +/// Adds, with saturation, each 16-bit unsigned integer element of the first +/// 64-bit integer vector of [4 x i16] to the corresponding 16-bit unsigned +/// integer element of the second 64-bit integer vector of [4 x i16]. +/// +/// Sums greater than 0xFFFF are saturated to 0xFFFF. The results are packed +/// into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PADDUSW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the saturated +/// unsigned sums of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_adds_pu16(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_add_sat((__v4hu)__m1, (__v4hu)__m2); +} + +/// Subtracts each 8-bit integer element of the second 64-bit integer +/// vector of [8 x i8] from the corresponding 8-bit integer element of the +/// first 64-bit integer vector of [8 x i8]. The lower 8 bits of the results +/// are packed into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8] containing the subtrahends. +/// \returns A 64-bit integer vector of [8 x i8] containing the differences of +/// both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sub_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v8qu)__m1) - ((__v8qu)__m2)); +} + +/// Subtracts each 16-bit integer element of the second 64-bit integer +/// vector of [4 x i16] from the corresponding 16-bit integer element of the +/// first 64-bit integer vector of [4 x i16]. The lower 16 bits of the +/// results are packed into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16] containing the subtrahends. +/// \returns A 64-bit integer vector of [4 x i16] containing the differences of +/// both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sub_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v4hu)__m1) - ((__v4hu)__m2)); +} + +/// Subtracts each 32-bit integer element of the second 64-bit integer +/// vector of [2 x i32] from the corresponding 32-bit integer element of the +/// first 64-bit integer vector of [2 x i32]. The lower 32 bits of the +/// results are packed into a 64-bit integer vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32] containing the subtrahends. +/// \returns A 64-bit integer vector of [2 x i32] containing the differences of +/// both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sub_pi32(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v2su)__m1) - ((__v2su)__m2)); +} + +/// Subtracts, with saturation, each 8-bit signed integer element of the second +/// 64-bit integer vector of [8 x i8] from the corresponding 8-bit signed +/// integer element of the first 64-bit integer vector of [8 x i8]. +/// +/// Positive results greater than 0x7F are saturated to 0x7F. Negative +/// results less than 0x80 are saturated to 0x80. The results are packed +/// into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBSB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8] containing the subtrahends. +/// \returns A 64-bit integer vector of [8 x i8] containing the saturated +/// differences of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_subs_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_sub_sat((__v8qs)__m1, (__v8qs)__m2); +} + +/// Subtracts, with saturation, each 16-bit signed integer element of the +/// second 64-bit integer vector of [4 x i16] from the corresponding 16-bit +/// signed integer element of the first 64-bit integer vector of [4 x i16]. +/// +/// Positive results greater than 0x7FFF are saturated to 0x7FFF. Negative +/// results less than 0x8000 are saturated to 0x8000. The results are packed +/// into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBSW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16] containing the subtrahends. +/// \returns A 64-bit integer vector of [4 x i16] containing the saturated +/// differences of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_subs_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_sub_sat((__v4hi)__m1, (__v4hi)__m2); +} + +/// Subtracts each 8-bit unsigned integer element of the second 64-bit +/// integer vector of [8 x i8] from the corresponding 8-bit unsigned integer +/// element of the first 64-bit integer vector of [8 x i8]. +/// +/// If an element of the first vector is less than the corresponding element +/// of the second vector, the result is saturated to 0. The results are +/// packed into a 64-bit integer vector of [8 x i8]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBUSB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8] containing the subtrahends. +/// \returns A 64-bit integer vector of [8 x i8] containing the saturated +/// differences of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_subs_pu8(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_sub_sat((__v8qu)__m1, (__v8qu)__m2); +} + +/// Subtracts each 16-bit unsigned integer element of the second 64-bit +/// integer vector of [4 x i16] from the corresponding 16-bit unsigned +/// integer element of the first 64-bit integer vector of [4 x i16]. +/// +/// If an element of the first vector is less than the corresponding element +/// of the second vector, the result is saturated to 0. The results are +/// packed into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSUBUSW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16] containing the minuends. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16] containing the subtrahends. +/// \returns A 64-bit integer vector of [4 x i16] containing the saturated +/// differences of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_subs_pu16(__m64 __m1, __m64 __m2) +{ + return (__m64)__builtin_elementwise_sub_sat((__v4hu)__m1, (__v4hu)__m2); +} + +/// Multiplies each 16-bit signed integer element of the first 64-bit +/// integer vector of [4 x i16] by the corresponding 16-bit signed integer +/// element of the second 64-bit integer vector of [4 x i16] and get four +/// 32-bit products. Adds adjacent pairs of products to get two 32-bit sums. +/// The lower 32 bits of these two sums are packed into a 64-bit integer +/// vector of [2 x i32]. +/// +/// For example, bits [15:0] of both parameters are multiplied, bits [31:16] +/// of both parameters are multiplied, and the sum of both results is written +/// to bits [31:0] of the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMADDWD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [2 x i32] containing the sums of +/// products of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_madd_pi16(__m64 __m1, __m64 __m2) +{ + return __trunc64(__builtin_ia32_pmaddwd128((__v8hi)__anyext128(__m1), + (__v8hi)__anyext128(__m2))); +} + +/// Multiplies each 16-bit signed integer element of the first 64-bit +/// integer vector of [4 x i16] by the corresponding 16-bit signed integer +/// element of the second 64-bit integer vector of [4 x i16]. Packs the upper +/// 16 bits of the 32-bit products into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMULHW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the upper 16 bits +/// of the products of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_mulhi_pi16(__m64 __m1, __m64 __m2) +{ + return __trunc64(__builtin_ia32_pmulhw128((__v8hi)__anyext128(__m1), + (__v8hi)__anyext128(__m2))); +} + +/// Multiplies each 16-bit signed integer element of the first 64-bit +/// integer vector of [4 x i16] by the corresponding 16-bit signed integer +/// element of the second 64-bit integer vector of [4 x i16]. Packs the lower +/// 16 bits of the 32-bit products into a 64-bit integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMULLW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the lower 16 bits +/// of the products of both parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_mullo_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v4hu)__m1) * ((__v4hu)__m2)); +} + +/// Left-shifts each 16-bit signed integer element of the first +/// parameter, which is a 64-bit integer vector of [4 x i16], by the number +/// of bits specified by the second parameter, which is a 64-bit integer. The +/// lower 16 bits of the results are packed into a 64-bit integer vector of +/// [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSLLW instruction. +/// +/// \param __m +/// A 64-bit integer vector of [4 x i16]. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector of [4 x i16] containing the left-shifted +/// values. If \a __count is greater or equal to 16, the result is set to all +/// 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sll_pi16(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psllw128((__v8hi)__anyext128(__m), + (__v8hi)__anyext128(__count))); +} + +/// Left-shifts each 16-bit signed integer element of a 64-bit integer +/// vector of [4 x i16] by the number of bits specified by a 32-bit integer. +/// The lower 16 bits of the results are packed into a 64-bit integer vector +/// of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSLLW instruction. +/// +/// \param __m +/// A 64-bit integer vector of [4 x i16]. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector of [4 x i16] containing the left-shifted +/// values. If \a __count is greater or equal to 16, the result is set to all +/// 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_slli_pi16(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psllwi128((__v8hi)__anyext128(__m), + __count)); +} + +/// Left-shifts each 32-bit signed integer element of the first +/// parameter, which is a 64-bit integer vector of [2 x i32], by the number +/// of bits specified by the second parameter, which is a 64-bit integer. The +/// lower 32 bits of the results are packed into a 64-bit integer vector of +/// [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSLLD instruction. +/// +/// \param __m +/// A 64-bit integer vector of [2 x i32]. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector of [2 x i32] containing the left-shifted +/// values. If \a __count is greater or equal to 32, the result is set to all +/// 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sll_pi32(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_pslld128((__v4si)__anyext128(__m), + (__v4si)__anyext128(__count))); +} + +/// Left-shifts each 32-bit signed integer element of a 64-bit integer +/// vector of [2 x i32] by the number of bits specified by a 32-bit integer. +/// The lower 32 bits of the results are packed into a 64-bit integer vector +/// of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSLLD instruction. +/// +/// \param __m +/// A 64-bit integer vector of [2 x i32]. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector of [2 x i32] containing the left-shifted +/// values. If \a __count is greater or equal to 32, the result is set to all +/// 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_slli_pi32(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_pslldi128((__v4si)__anyext128(__m), + __count)); +} + +/// Left-shifts the first 64-bit integer parameter by the number of bits +/// specified by the second 64-bit integer parameter. The lower 64 bits of +/// result are returned. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSLLQ instruction. +/// +/// \param __m +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector containing the left-shifted value. If +/// \a __count is greater or equal to 64, the result is set to 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sll_si64(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psllq128((__v2di)__anyext128(__m), + (__v2di)__anyext128(__count))); +} + +/// Left-shifts the first parameter, which is a 64-bit integer, by the +/// number of bits specified by the second parameter, which is a 32-bit +/// integer. The lower 64 bits of result are returned. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSLLQ instruction. +/// +/// \param __m +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector containing the left-shifted value. If +/// \a __count is greater or equal to 64, the result is set to 0. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_slli_si64(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psllqi128((__v2di)__anyext128(__m), + __count)); +} + +/// Right-shifts each 16-bit integer element of the first parameter, +/// which is a 64-bit integer vector of [4 x i16], by the number of bits +/// specified by the second parameter, which is a 64-bit integer. +/// +/// High-order bits are filled with the sign bit of the initial value of each +/// 16-bit element. The 16-bit results are packed into a 64-bit integer +/// vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRAW instruction. +/// +/// \param __m +/// A 64-bit integer vector of [4 x i16]. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector of [4 x i16] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sra_pi16(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psraw128((__v8hi)__anyext128(__m), + (__v8hi)__anyext128(__count))); +} + +/// Right-shifts each 16-bit integer element of a 64-bit integer vector +/// of [4 x i16] by the number of bits specified by a 32-bit integer. +/// +/// High-order bits are filled with the sign bit of the initial value of each +/// 16-bit element. The 16-bit results are packed into a 64-bit integer +/// vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRAW instruction. +/// +/// \param __m +/// A 64-bit integer vector of [4 x i16]. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector of [4 x i16] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srai_pi16(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psrawi128((__v8hi)__anyext128(__m), + __count)); +} + +/// Right-shifts each 32-bit integer element of the first parameter, +/// which is a 64-bit integer vector of [2 x i32], by the number of bits +/// specified by the second parameter, which is a 64-bit integer. +/// +/// High-order bits are filled with the sign bit of the initial value of each +/// 32-bit element. The 32-bit results are packed into a 64-bit integer +/// vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRAD instruction. +/// +/// \param __m +/// A 64-bit integer vector of [2 x i32]. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector of [2 x i32] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sra_pi32(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psrad128((__v4si)__anyext128(__m), + (__v4si)__anyext128(__count))); +} + +/// Right-shifts each 32-bit integer element of a 64-bit integer vector +/// of [2 x i32] by the number of bits specified by a 32-bit integer. +/// +/// High-order bits are filled with the sign bit of the initial value of each +/// 32-bit element. The 32-bit results are packed into a 64-bit integer +/// vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRAD instruction. +/// +/// \param __m +/// A 64-bit integer vector of [2 x i32]. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector of [2 x i32] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srai_pi32(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psradi128((__v4si)__anyext128(__m), + __count)); +} + +/// Right-shifts each 16-bit integer element of the first parameter, +/// which is a 64-bit integer vector of [4 x i16], by the number of bits +/// specified by the second parameter, which is a 64-bit integer. +/// +/// High-order bits are cleared. The 16-bit results are packed into a 64-bit +/// integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRLW instruction. +/// +/// \param __m +/// A 64-bit integer vector of [4 x i16]. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector of [4 x i16] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srl_pi16(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psrlw128((__v8hi)__anyext128(__m), + (__v8hi)__anyext128(__count))); +} + +/// Right-shifts each 16-bit integer element of a 64-bit integer vector +/// of [4 x i16] by the number of bits specified by a 32-bit integer. +/// +/// High-order bits are cleared. The 16-bit results are packed into a 64-bit +/// integer vector of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRLW instruction. +/// +/// \param __m +/// A 64-bit integer vector of [4 x i16]. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector of [4 x i16] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srli_pi16(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psrlwi128((__v8hi)__anyext128(__m), + __count)); +} + +/// Right-shifts each 32-bit integer element of the first parameter, +/// which is a 64-bit integer vector of [2 x i32], by the number of bits +/// specified by the second parameter, which is a 64-bit integer. +/// +/// High-order bits are cleared. The 32-bit results are packed into a 64-bit +/// integer vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRLD instruction. +/// +/// \param __m +/// A 64-bit integer vector of [2 x i32]. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector of [2 x i32] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srl_pi32(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psrld128((__v4si)__anyext128(__m), + (__v4si)__anyext128(__count))); +} + +/// Right-shifts each 32-bit integer element of a 64-bit integer vector +/// of [2 x i32] by the number of bits specified by a 32-bit integer. +/// +/// High-order bits are cleared. The 32-bit results are packed into a 64-bit +/// integer vector of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRLD instruction. +/// +/// \param __m +/// A 64-bit integer vector of [2 x i32]. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector of [2 x i32] containing the right-shifted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srli_pi32(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psrldi128((__v4si)__anyext128(__m), + __count)); +} + +/// Right-shifts the first 64-bit integer parameter by the number of bits +/// specified by the second 64-bit integer parameter. +/// +/// High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRLQ instruction. +/// +/// \param __m +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \param __count +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \returns A 64-bit integer vector containing the right-shifted value. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srl_si64(__m64 __m, __m64 __count) +{ + return __trunc64(__builtin_ia32_psrlq128((__v2di)__anyext128(__m), + (__v2di)__anyext128(__count))); +} + +/// Right-shifts the first parameter, which is a 64-bit integer, by the +/// number of bits specified by the second parameter, which is a 32-bit +/// integer. +/// +/// High-order bits are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSRLQ instruction. +/// +/// \param __m +/// A 64-bit integer vector interpreted as a single 64-bit integer. +/// \param __count +/// A 32-bit integer value. +/// \returns A 64-bit integer vector containing the right-shifted value. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_srli_si64(__m64 __m, int __count) +{ + return __trunc64(__builtin_ia32_psrlqi128((__v2di)__anyext128(__m), + __count)); +} + +/// Performs a bitwise AND of two 64-bit integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PAND instruction. +/// +/// \param __m1 +/// A 64-bit integer vector. +/// \param __m2 +/// A 64-bit integer vector. +/// \returns A 64-bit integer vector containing the bitwise AND of both +/// parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_and_si64(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v1du)__m1) & ((__v1du)__m2)); +} + +/// Performs a bitwise NOT of the first 64-bit integer vector, and then +/// performs a bitwise AND of the intermediate result and the second 64-bit +/// integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PANDN instruction. +/// +/// \param __m1 +/// A 64-bit integer vector. The one's complement of this parameter is used +/// in the bitwise AND. +/// \param __m2 +/// A 64-bit integer vector. +/// \returns A 64-bit integer vector containing the bitwise AND of the second +/// parameter and the one's complement of the first parameter. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_andnot_si64(__m64 __m1, __m64 __m2) +{ + return (__m64)(~((__v1du)__m1) & ((__v1du)__m2)); +} + +/// Performs a bitwise OR of two 64-bit integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the POR instruction. +/// +/// \param __m1 +/// A 64-bit integer vector. +/// \param __m2 +/// A 64-bit integer vector. +/// \returns A 64-bit integer vector containing the bitwise OR of both +/// parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_or_si64(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v1du)__m1) | ((__v1du)__m2)); +} + +/// Performs a bitwise exclusive OR of two 64-bit integer vectors. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PXOR instruction. +/// +/// \param __m1 +/// A 64-bit integer vector. +/// \param __m2 +/// A 64-bit integer vector. +/// \returns A 64-bit integer vector containing the bitwise exclusive OR of both +/// parameters. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_xor_si64(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v1du)__m1) ^ ((__v1du)__m2)); +} + +/// Compares the 8-bit integer elements of two 64-bit integer vectors of +/// [8 x i8] to determine if the element of the first vector is equal to the +/// corresponding element of the second vector. +/// +/// Each comparison returns 0 for false, 0xFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PCMPEQB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// \returns A 64-bit integer vector of [8 x i8] containing the comparison +/// results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cmpeq_pi8(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v8qi)__m1) == ((__v8qi)__m2)); +} + +/// Compares the 16-bit integer elements of two 64-bit integer vectors of +/// [4 x i16] to determine if the element of the first vector is equal to the +/// corresponding element of the second vector. +/// +/// Each comparison returns 0 for false, 0xFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PCMPEQW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the comparison +/// results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cmpeq_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v4hi)__m1) == ((__v4hi)__m2)); +} + +/// Compares the 32-bit integer elements of two 64-bit integer vectors of +/// [2 x i32] to determine if the element of the first vector is equal to the +/// corresponding element of the second vector. +/// +/// Each comparison returns 0 for false, 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PCMPEQD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32]. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32]. +/// \returns A 64-bit integer vector of [2 x i32] containing the comparison +/// results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cmpeq_pi32(__m64 __m1, __m64 __m2) +{ + return (__m64)(((__v2si)__m1) == ((__v2si)__m2)); +} + +/// Compares the 8-bit integer elements of two 64-bit integer vectors of +/// [8 x i8] to determine if the element of the first vector is greater than +/// the corresponding element of the second vector. +/// +/// Each comparison returns 0 for false, 0xFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PCMPGTB instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [8 x i8]. +/// \param __m2 +/// A 64-bit integer vector of [8 x i8]. +/// \returns A 64-bit integer vector of [8 x i8] containing the comparison +/// results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cmpgt_pi8(__m64 __m1, __m64 __m2) +{ + /* This function always performs a signed comparison, but __v8qi is a char + which may be signed or unsigned, so use __v8qs. */ + return (__m64)((__v8qs)__m1 > (__v8qs)__m2); +} + +/// Compares the 16-bit integer elements of two 64-bit integer vectors of +/// [4 x i16] to determine if the element of the first vector is greater than +/// the corresponding element of the second vector. +/// +/// Each comparison returns 0 for false, 0xFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PCMPGTW instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [4 x i16]. +/// \param __m2 +/// A 64-bit integer vector of [4 x i16]. +/// \returns A 64-bit integer vector of [4 x i16] containing the comparison +/// results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cmpgt_pi16(__m64 __m1, __m64 __m2) +{ + return (__m64)((__v4hi)__m1 > (__v4hi)__m2); +} + +/// Compares the 32-bit integer elements of two 64-bit integer vectors of +/// [2 x i32] to determine if the element of the first vector is greater than +/// the corresponding element of the second vector. +/// +/// Each comparison returns 0 for false, 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PCMPGTD instruction. +/// +/// \param __m1 +/// A 64-bit integer vector of [2 x i32]. +/// \param __m2 +/// A 64-bit integer vector of [2 x i32]. +/// \returns A 64-bit integer vector of [2 x i32] containing the comparison +/// results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cmpgt_pi32(__m64 __m1, __m64 __m2) +{ + return (__m64)((__v2si)__m1 > (__v2si)__m2); +} + +/// Constructs a 64-bit integer vector initialized to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PXOR instruction. +/// +/// \returns An initialized 64-bit integer vector with all elements set to zero. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_setzero_si64(void) { + return __extension__(__m64){0LL}; +} + +/// Constructs a 64-bit integer vector initialized with the specified +/// 32-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i1 +/// A 32-bit integer value used to initialize the upper 32 bits of the +/// result. +/// \param __i0 +/// A 32-bit integer value used to initialize the lower 32 bits of the +/// result. +/// \returns An initialized 64-bit integer vector. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_set_pi32(int __i1, int __i0) { + return __extension__(__m64)(__v2si){__i0, __i1}; +} + +/// Constructs a 64-bit integer vector initialized with the specified +/// 16-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __s3 +/// A 16-bit integer value used to initialize bits [63:48] of the result. +/// \param __s2 +/// A 16-bit integer value used to initialize bits [47:32] of the result. +/// \param __s1 +/// A 16-bit integer value used to initialize bits [31:16] of the result. +/// \param __s0 +/// A 16-bit integer value used to initialize bits [15:0] of the result. +/// \returns An initialized 64-bit integer vector. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_set_pi16(short __s3, short __s2, short __s1, short __s0) { + return __extension__(__m64)(__v4hi){__s0, __s1, __s2, __s3}; +} + +/// Constructs a 64-bit integer vector initialized with the specified +/// 8-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b7 +/// An 8-bit integer value used to initialize bits [63:56] of the result. +/// \param __b6 +/// An 8-bit integer value used to initialize bits [55:48] of the result. +/// \param __b5 +/// An 8-bit integer value used to initialize bits [47:40] of the result. +/// \param __b4 +/// An 8-bit integer value used to initialize bits [39:32] of the result. +/// \param __b3 +/// An 8-bit integer value used to initialize bits [31:24] of the result. +/// \param __b2 +/// An 8-bit integer value used to initialize bits [23:16] of the result. +/// \param __b1 +/// An 8-bit integer value used to initialize bits [15:8] of the result. +/// \param __b0 +/// An 8-bit integer value used to initialize bits [7:0] of the result. +/// \returns An initialized 64-bit integer vector. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_set_pi8(char __b7, char __b6, char __b5, char __b4, char __b3, char __b2, + char __b1, char __b0) { + return __extension__(__m64)(__v8qi){__b0, __b1, __b2, __b3, + __b4, __b5, __b6, __b7}; +} + +/// Constructs a 64-bit integer vector of [2 x i32], with each of the +/// 32-bit integer vector elements set to the specified 32-bit integer +/// value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i +/// A 32-bit integer value used to initialize each vector element of the +/// result. +/// \returns An initialized 64-bit integer vector of [2 x i32]. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_set1_pi32(int __i) { + return _mm_set_pi32(__i, __i); +} + +/// Constructs a 64-bit integer vector of [4 x i16], with each of the +/// 16-bit integer vector elements set to the specified 16-bit integer +/// value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w +/// A 16-bit integer value used to initialize each vector element of the +/// result. +/// \returns An initialized 64-bit integer vector of [4 x i16]. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_set1_pi16(short __w) { + return _mm_set_pi16(__w, __w, __w, __w); +} + +/// Constructs a 64-bit integer vector of [8 x i8], with each of the +/// 8-bit integer vector elements set to the specified 8-bit integer value. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b +/// An 8-bit integer value used to initialize each vector element of the +/// result. +/// \returns An initialized 64-bit integer vector of [8 x i8]. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_set1_pi8(char __b) { + return _mm_set_pi8(__b, __b, __b, __b, __b, __b, __b, __b); +} + +/// Constructs a 64-bit integer vector, initialized in reverse order with +/// the specified 32-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __i0 +/// A 32-bit integer value used to initialize the lower 32 bits of the +/// result. +/// \param __i1 +/// A 32-bit integer value used to initialize the upper 32 bits of the +/// result. +/// \returns An initialized 64-bit integer vector. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_setr_pi32(int __i0, int __i1) { + return _mm_set_pi32(__i1, __i0); +} + +/// Constructs a 64-bit integer vector, initialized in reverse order with +/// the specified 16-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __w0 +/// A 16-bit integer value used to initialize bits [15:0] of the result. +/// \param __w1 +/// A 16-bit integer value used to initialize bits [31:16] of the result. +/// \param __w2 +/// A 16-bit integer value used to initialize bits [47:32] of the result. +/// \param __w3 +/// A 16-bit integer value used to initialize bits [63:48] of the result. +/// \returns An initialized 64-bit integer vector. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_setr_pi16(short __w0, short __w1, short __w2, short __w3) { + return _mm_set_pi16(__w3, __w2, __w1, __w0); +} + +/// Constructs a 64-bit integer vector, initialized in reverse order with +/// the specified 8-bit integer values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __b0 +/// An 8-bit integer value used to initialize bits [7:0] of the result. +/// \param __b1 +/// An 8-bit integer value used to initialize bits [15:8] of the result. +/// \param __b2 +/// An 8-bit integer value used to initialize bits [23:16] of the result. +/// \param __b3 +/// An 8-bit integer value used to initialize bits [31:24] of the result. +/// \param __b4 +/// An 8-bit integer value used to initialize bits [39:32] of the result. +/// \param __b5 +/// An 8-bit integer value used to initialize bits [47:40] of the result. +/// \param __b6 +/// An 8-bit integer value used to initialize bits [55:48] of the result. +/// \param __b7 +/// An 8-bit integer value used to initialize bits [63:56] of the result. +/// \returns An initialized 64-bit integer vector. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR +_mm_setr_pi8(char __b0, char __b1, char __b2, char __b3, char __b4, char __b5, + char __b6, char __b7) { + return _mm_set_pi8(__b7, __b6, __b5, __b4, __b3, __b2, __b1, __b0); +} + +#undef __anyext128 +#undef __trunc64 +#undef __DEFAULT_FN_ATTRS_SSE2 + +/* Aliases for compatibility. */ +#define _m_empty _mm_empty +#define _m_from_int _mm_cvtsi32_si64 +#define _m_from_int64 _mm_cvtsi64_m64 +#define _m_to_int _mm_cvtsi64_si32 +#define _m_to_int64 _mm_cvtm64_si64 +#define _m_packsswb _mm_packs_pi16 +#define _m_packssdw _mm_packs_pi32 +#define _m_packuswb _mm_packs_pu16 +#define _m_punpckhbw _mm_unpackhi_pi8 +#define _m_punpckhwd _mm_unpackhi_pi16 +#define _m_punpckhdq _mm_unpackhi_pi32 +#define _m_punpcklbw _mm_unpacklo_pi8 +#define _m_punpcklwd _mm_unpacklo_pi16 +#define _m_punpckldq _mm_unpacklo_pi32 +#define _m_paddb _mm_add_pi8 +#define _m_paddw _mm_add_pi16 +#define _m_paddd _mm_add_pi32 +#define _m_paddsb _mm_adds_pi8 +#define _m_paddsw _mm_adds_pi16 +#define _m_paddusb _mm_adds_pu8 +#define _m_paddusw _mm_adds_pu16 +#define _m_psubb _mm_sub_pi8 +#define _m_psubw _mm_sub_pi16 +#define _m_psubd _mm_sub_pi32 +#define _m_psubsb _mm_subs_pi8 +#define _m_psubsw _mm_subs_pi16 +#define _m_psubusb _mm_subs_pu8 +#define _m_psubusw _mm_subs_pu16 +#define _m_pmaddwd _mm_madd_pi16 +#define _m_pmulhw _mm_mulhi_pi16 +#define _m_pmullw _mm_mullo_pi16 +#define _m_psllw _mm_sll_pi16 +#define _m_psllwi _mm_slli_pi16 +#define _m_pslld _mm_sll_pi32 +#define _m_pslldi _mm_slli_pi32 +#define _m_psllq _mm_sll_si64 +#define _m_psllqi _mm_slli_si64 +#define _m_psraw _mm_sra_pi16 +#define _m_psrawi _mm_srai_pi16 +#define _m_psrad _mm_sra_pi32 +#define _m_psradi _mm_srai_pi32 +#define _m_psrlw _mm_srl_pi16 +#define _m_psrlwi _mm_srli_pi16 +#define _m_psrld _mm_srl_pi32 +#define _m_psrldi _mm_srli_pi32 +#define _m_psrlq _mm_srl_si64 +#define _m_psrlqi _mm_srli_si64 +#define _m_pand _mm_and_si64 +#define _m_pandn _mm_andnot_si64 +#define _m_por _mm_or_si64 +#define _m_pxor _mm_xor_si64 +#define _m_pcmpeqb _mm_cmpeq_pi8 +#define _m_pcmpeqw _mm_cmpeq_pi16 +#define _m_pcmpeqd _mm_cmpeq_pi32 +#define _m_pcmpgtb _mm_cmpgt_pi8 +#define _m_pcmpgtw _mm_cmpgt_pi16 +#define _m_pcmpgtd _mm_cmpgt_pi32 + +#endif /* __MMINTRIN_H */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/module.modulemap b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/module.modulemap new file mode 100755 index 0000000..a728286 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/module.modulemap @@ -0,0 +1,341 @@ +/*===---- module.modulemap - intrinsics module map -------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +module _Builtin_intrinsics [system] [extern_c] { + explicit module altivec { + requires altivec + header "altivec.h" + } + + explicit module arm { + requires arm + + explicit module acle { + header "arm_acle.h" + export * + } + + explicit module neon { + requires neon + header "arm_neon.h" + header "arm_fp16.h" + export * + } + + explicit module sve { + requires sve + header "arm_sve.h" + export * + } + } + + explicit module arm64 { + requires arm64 + requires windows + + header "arm64intr.h" + export * + } + + explicit module intel { + requires x86 + export * + + header "immintrin.h" + textual header "f16cintrin.h" + textual header "avxintrin.h" + textual header "avx2intrin.h" + textual header "avx512fintrin.h" + textual header "fmaintrin.h" + + header "x86intrin.h" + textual header "bmiintrin.h" + textual header "bmi2intrin.h" + textual header "lzcntintrin.h" + textual header "xopintrin.h" + textual header "fma4intrin.h" + textual header "mwaitxintrin.h" + textual header "clzerointrin.h" + textual header "wbnoinvdintrin.h" + textual header "cldemoteintrin.h" + textual header "waitpkgintrin.h" + textual header "movdirintrin.h" + textual header "pconfigintrin.h" + textual header "sgxintrin.h" + textual header "ptwriteintrin.h" + textual header "invpcidintrin.h" + + textual header "__wmmintrin_aes.h" + textual header "__wmmintrin_pclmul.h" + + textual header "mm3dnow.h" + + explicit module mm_malloc { + requires !freestanding + header "mm_malloc.h" + export * // note: for dependency + } + + explicit module cpuid { + requires gnuinlineasm + header "cpuid.h" + } + + explicit module mmx { + header "mmintrin.h" + } + + explicit module sse { + export mm_malloc + export mmx + export sse2 // note: for hackish dependency + header "xmmintrin.h" + } + + explicit module sse2 { + export sse + header "emmintrin.h" + } + + explicit module sse3 { + export sse2 + header "pmmintrin.h" + } + + explicit module ssse3 { + export sse3 + header "tmmintrin.h" + } + + explicit module sse4_1 { + export ssse3 + header "smmintrin.h" + } + + explicit module sse4_2 { + export sse4_1 + header "nmmintrin.h" + } + + explicit module sse4a { + export sse3 + header "ammintrin.h" + } + + explicit module popcnt { + header "popcntintrin.h" + } + + explicit module aes_pclmul { + header "wmmintrin.h" + export aes + export pclmul + } + } + + explicit module systemz { + requires systemz + export * + + header "s390intrin.h" + + explicit module htm { + requires htm + header "htmintrin.h" + header "htmxlintrin.h" + } + + explicit module zvector { + requires zvector, vx + header "vecintrin.h" + } + } +} + +// Start -fbuiltin-headers-in-system-modules affected modules + +// The following modules all ignore their headers when +// -fbuiltin-headers-in-system-modules is passed, and many of +// those headers join system modules when present. + +// e.g. if -fbuiltin-headers-in-system-modules is passed, then +// float.h will not be in the _Builtin_float module (that module +// will be empty). If there is a system module that declares +// `header "float.h"`, then the builtin float.h will join +// that module. The system float.h (if present) will be treated +// as a textual header in the sytem module. +module _Builtin_float [system] { + header "float.h" + export * +} + +module _Builtin_inttypes [system] { + header "inttypes.h" + export * +} + +module _Builtin_iso646 [system] { + header "iso646.h" + export * +} + +module _Builtin_limits [system] { + header "limits.h" + export * +} + +module _Builtin_stdalign [system] { + header "stdalign.h" + export * +} + +module _Builtin_stdarg [system] { + textual header "stdarg.h" + + explicit module __gnuc_va_list { + header "__stdarg___gnuc_va_list.h" + export * + } + + explicit module __va_copy { + header "__stdarg___va_copy.h" + export * + } + + explicit module header_macro { + header "__stdarg_header_macro.h" + export * + } + + explicit module va_arg { + header "__stdarg_va_arg.h" + export * + } + + explicit module va_copy { + header "__stdarg_va_copy.h" + export * + } + + explicit module va_list { + header "__stdarg_va_list.h" + export * + } +} + +module _Builtin_stdatomic [system] { + header "stdatomic.h" + export * +} + +module _Builtin_stdbool [system] { + header "stdbool.h" + export * +} + +module _Builtin_stdcountof [system] { + header "stdcountof.h" + export * +} + +module _Builtin_stddef [system] { + textual header "stddef.h" + + explicit module header_macro { + header "__stddef_header_macro.h" + export * + } + // __stddef_max_align_t.h is always in this module, even if + // -fbuiltin-headers-in-system-modules is passed. + explicit module max_align_t { + header "__stddef_max_align_t.h" + export * + } + + explicit module null { + header "__stddef_null.h" + export * + } + + explicit module nullptr_t { + header "__stddef_nullptr_t.h" + export * + } + + explicit module offsetof { + header "__stddef_offsetof.h" + export * + } + + explicit module ptrdiff_t { + header "__stddef_ptrdiff_t.h" + export * + } + + explicit module rsize_t { + header "__stddef_rsize_t.h" + export * + } + + explicit module size_t { + header "__stddef_size_t.h" + export * + } + + explicit module unreachable { + header "__stddef_unreachable.h" + export * + } + + explicit module wchar_t { + header "__stddef_wchar_t.h" + export * + } +} + +// wint_t is provided by and not . It's here +// for compatibility, but must be explicitly requested. Therefore +// __stddef_wint_t.h is not part of _Builtin_stddef. It is always in +// this module even if -fbuiltin-headers-in-system-modules is passed. +module _Builtin_stddef_wint_t [system] { + header "__stddef_wint_t.h" + export * +} + +module _Builtin_stdint [system] { + header "stdint.h" + export * +} + +module _Builtin_stdnoreturn [system] { + header "stdnoreturn.h" + export * +} + +module _Builtin_tgmath [system] { + header "tgmath.h" + export * +} + +module _Builtin_unwind [system] { + header "unwind.h" + export * +} +// End -fbuiltin-headers-in-system-modules affected modules + +module opencl_c { + requires opencl + header "opencl-c.h" + header "opencl-c-base.h" +} + +module ptrauth { + header "ptrauth.h" + export * +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movdirintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movdirintrin.h new file mode 100755 index 0000000..30c4d02 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movdirintrin.h @@ -0,0 +1,49 @@ +/*===------------------------- movdirintrin.h ------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef _MOVDIRINTRIN_H +#define _MOVDIRINTRIN_H + +/* Move doubleword as direct store */ +static __inline__ void +__attribute__((__always_inline__, __nodebug__, __target__("movdiri"))) +_directstoreu_u32 (void *__dst, unsigned int __value) +{ + __builtin_ia32_directstore_u32((unsigned int *)__dst, (unsigned int)__value); +} + +#ifdef __x86_64__ + +/* Move quadword as direct store */ +static __inline__ void +__attribute__((__always_inline__, __nodebug__, __target__("movdiri"))) +_directstoreu_u64 (void *__dst, unsigned long __value) +{ + __builtin_ia32_directstore_u64((unsigned long *)__dst, __value); +} + +#endif /* __x86_64__ */ + +/* + * movdir64b - Move 64 bytes as direct store. + * The destination must be 64 byte aligned, and the store is atomic. + * The source address has no alignment requirement, and the load from + * the source address is not atomic. + */ +static __inline__ void +__attribute__((__always_inline__, __nodebug__, __target__("movdir64b"))) +_movdir64b (void *__dst __attribute__((align_value(64))), const void *__src) +{ + __builtin_ia32_movdir64b(__dst, __src); +} + +#endif /* _MOVDIRINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrs_avx10_2_512intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrs_avx10_2_512intrin.h new file mode 100755 index 0000000..5cd907a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrs_avx10_2_512intrin.h @@ -0,0 +1,98 @@ +/*===----- movrs_avx10_2_512intrin.h - AVX10.2-512-MOVRS intrinsics --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifndef __MOVRS_AVX10_2_512INTRIN_H +#define __MOVRS_AVX10_2_512INTRIN_H +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("movrs, avx10.2-512"), __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadrs_epi8(void const *__A) { + return (__m512i)__builtin_ia32_vmovrsb512((const __v64qi *)(__A)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadrs_epi8(__m512i __W, __mmask64 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectb_512( + (__mmask64)__U, (__v64qi)_mm512_loadrs_epi8(__A), (__v64qi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadrs_epi8(__mmask64 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectb_512((__mmask64)__U, + (__v64qi)_mm512_loadrs_epi8(__A), + (__v64qi)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadrs_epi32(void const *__A) { + return (__m512i)__builtin_ia32_vmovrsd512((const __v16si *)(__A)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadrs_epi32(__m512i __W, __mmask16 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectd_512( + (__mmask16)__U, (__v16si)_mm512_loadrs_epi32(__A), (__v16si)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadrs_epi32(__mmask16 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectd_512((__mmask16)__U, + (__v16si)_mm512_loadrs_epi32(__A), + (__v16si)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadrs_epi64(void const *__A) { + return (__m512i)__builtin_ia32_vmovrsq512((const __v8di *)(__A)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadrs_epi64(__m512i __W, __mmask8 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectq_512( + (__mmask8)__U, (__v8di)_mm512_loadrs_epi64(__A), (__v8di)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadrs_epi64(__mmask8 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectq_512((__mmask8)__U, + (__v8di)_mm512_loadrs_epi64(__A), + (__v8di)_mm512_setzero_si512()); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_loadrs_epi16(void const *__A) { + return (__m512i)__builtin_ia32_vmovrsw512((const __v32hi *)(__A)); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_mask_loadrs_epi16(__m512i __W, __mmask32 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectw_512( + (__mmask32)__U, (__v32hi)_mm512_loadrs_epi16(__A), (__v32hi)__W); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_maskz_loadrs_epi16(__mmask32 __U, void const *__A) { + return (__m512i)__builtin_ia32_selectw_512((__mmask32)__U, + (__v32hi)_mm512_loadrs_epi16(__A), + (__v32hi)_mm512_setzero_si512()); +} + +#undef __DEFAULT_FN_ATTRS512 + +#endif /* __x86_64__ */ +#endif /* __MOVRS_AVX10_2_512INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrs_avx10_2intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrs_avx10_2intrin.h new file mode 100755 index 0000000..27b625b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrs_avx10_2intrin.h @@ -0,0 +1,174 @@ +/*===--------- movrs_avx10_2intrin.h - AVX10.2-MOVRS intrinsics ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error \ + "Never use directly; include instead." +#endif + +#ifndef __MOVRS_AVX10_2INTRIN_H +#define __MOVRS_AVX10_2INTRIN_H +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("movrs,avx10.2-256"), __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("movrs,avx10.2-256"), __min_vector_width__(256))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_loadrs_epi8(void const *__A) { + return (__m128i)__builtin_ia32_vmovrsb128((const __v16qi *)(__A)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadrs_epi8(__m128i __W, __mmask16 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectb_128( + (__mmask16)__U, (__v16qi)_mm_loadrs_epi8(__A), (__v16qi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadrs_epi8(__mmask16 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectb_128((__mmask16)__U, + (__v16qi)_mm_loadrs_epi8(__A), + (__v16qi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadrs_epi8(void const *__A) { + return (__m256i)__builtin_ia32_vmovrsb256((const __v32qi *)(__A)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadrs_epi8(__m256i __W, __mmask32 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectb_256( + (__mmask32)__U, (__v32qi)_mm256_loadrs_epi8(__A), (__v32qi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadrs_epi8(__mmask32 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectb_256((__mmask32)__U, + (__v32qi)_mm256_loadrs_epi8(__A), + (__v32qi)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_loadrs_epi32(void const *__A) { + return (__m128i)__builtin_ia32_vmovrsd128((const __v4si *)(__A)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadrs_epi32(__m128i __W, __mmask8 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectd_128( + (__mmask8)__U, (__v4si)_mm_loadrs_epi32(__A), (__v4si)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadrs_epi32(__mmask8 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectd_128((__mmask8)__U, + (__v4si)_mm_loadrs_epi32(__A), + (__v4si)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadrs_epi32(void const *__A) { + return (__m256i)__builtin_ia32_vmovrsd256((const __v8si *)(__A)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadrs_epi32(__m256i __W, __mmask8 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectd_256( + (__mmask8)__U, (__v8si)_mm256_loadrs_epi32(__A), (__v8si)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadrs_epi32(__mmask8 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectd_256((__mmask8)__U, + (__v8si)_mm256_loadrs_epi32(__A), + (__v8si)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_loadrs_epi64(void const *__A) { + return (__m128i)__builtin_ia32_vmovrsq128((const __v2di *)(__A)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadrs_epi64(__m128i __W, __mmask8 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectq_128( + (__mmask8)__U, (__v2di)_mm_loadrs_epi64(__A), (__v2di)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadrs_epi64(__mmask8 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectq_128((__mmask8)__U, + (__v2di)_mm_loadrs_epi64(__A), + (__v2di)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadrs_epi64(void const *__A) { + return (__m256i)__builtin_ia32_vmovrsq256((const __v4di *)(__A)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadrs_epi64(__m256i __W, __mmask8 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectq_256( + (__mmask8)__U, (__v4di)_mm256_loadrs_epi64(__A), (__v4di)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadrs_epi64(__mmask8 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectq_256((__mmask8)__U, + (__v4di)_mm256_loadrs_epi64(__A), + (__v4di)_mm256_setzero_si256()); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_loadrs_epi16(void const *__A) { + return (__m128i)__builtin_ia32_vmovrsw128((const __v8hi *)(__A)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_mask_loadrs_epi16(__m128i __W, __mmask8 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectw_128( + (__mmask8)__U, (__v8hi)_mm_loadrs_epi16(__A), (__v8hi)__W); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS128 +_mm_maskz_loadrs_epi16(__mmask8 __U, void const *__A) { + return (__m128i)__builtin_ia32_selectw_128((__mmask8)__U, + (__v8hi)_mm_loadrs_epi16(__A), + (__v8hi)_mm_setzero_si128()); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_loadrs_epi16(void const *__A) { + return (__m256i)__builtin_ia32_vmovrsw256((const __v16hi *)(__A)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_mask_loadrs_epi16(__m256i __W, __mmask16 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectw_256( + (__mmask16)__U, (__v16hi)_mm256_loadrs_epi16(__A), (__v16hi)__W); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_maskz_loadrs_epi16(__mmask16 __U, void const *__A) { + return (__m256i)__builtin_ia32_selectw_256((__mmask16)__U, + (__v16hi)_mm256_loadrs_epi16(__A), + (__v16hi)_mm256_setzero_si256()); +} + +#undef __DEFAULT_FN_ATTRS128 +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __x86_64__ */ +#endif /* __MOVRS_AVX10_2INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrsintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrsintrin.h new file mode 100755 index 0000000..9451048 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/movrsintrin.h @@ -0,0 +1,59 @@ +/*===---------------- movrsintrin.h - MOVRS intrinsics ----------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===----------------------------------------------------------------------===*/ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __MOVRSINTRIN_H +#define __MOVRSINTRIN_H + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("movrs"))) + +#ifdef __x86_64__ +static __inline__ char __DEFAULT_FN_ATTRS _movrs_i8(const void *__A) { + return (char)__builtin_ia32_movrsqi((const void *)__A); +} + +static __inline__ short __DEFAULT_FN_ATTRS _movrs_i16(const void *__A) { + return (short)__builtin_ia32_movrshi((const void *)__A); +} + +static __inline__ int __DEFAULT_FN_ATTRS _movrs_i32(const void *__A) { + return (int)__builtin_ia32_movrssi((const void *)__A); +} + +static __inline__ long long __DEFAULT_FN_ATTRS _movrs_i64(const void *__A) { + return (long long)__builtin_ia32_movrsdi((const void *)__A); +} +#endif // __x86_64__ + +// Loads a memory sequence containing the specified memory address into +/// the L3 data cache. Data will be shared (read/written) to by requesting +/// core and other cores. +/// +/// Note that the effect of this intrinsic is dependent on the processor +/// implementation. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PREFETCHRS instruction. +/// +/// \param __P +/// A pointer specifying the memory address to be prefetched. +static __inline__ void __DEFAULT_FN_ATTRS +_m_prefetchrs(volatile const void *__P) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" + __builtin_ia32_prefetchrs((const void *)__P); +#pragma clang diagnostic pop +} + +#undef __DEFAULT_FN_ATTRS +#endif // __MOVRSINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/msa.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/msa.h new file mode 100755 index 0000000..0ca4900 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/msa.h @@ -0,0 +1,573 @@ +/*===---- msa.h - MIPS MSA intrinsics --------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _MSA_H +#define _MSA_H 1 + +#if defined(__mips_msa) +typedef signed char v16i8 __attribute__((vector_size(16), aligned(16))); +typedef signed char v16i8_b __attribute__((vector_size(16), aligned(1))); +typedef unsigned char v16u8 __attribute__((vector_size(16), aligned(16))); +typedef unsigned char v16u8_b __attribute__((vector_size(16), aligned(1))); +typedef short v8i16 __attribute__((vector_size(16), aligned(16))); +typedef short v8i16_h __attribute__((vector_size(16), aligned(2))); +typedef unsigned short v8u16 __attribute__((vector_size(16), aligned(16))); +typedef unsigned short v8u16_h __attribute__((vector_size(16), aligned(2))); +typedef int v4i32 __attribute__((vector_size(16), aligned(16))); +typedef int v4i32_w __attribute__((vector_size(16), aligned(4))); +typedef unsigned int v4u32 __attribute__((vector_size(16), aligned(16))); +typedef unsigned int v4u32_w __attribute__((vector_size(16), aligned(4))); +typedef long long v2i64 __attribute__((vector_size(16), aligned(16))); +typedef long long v2i64_d __attribute__((vector_size(16), aligned(8))); +typedef unsigned long long v2u64 __attribute__((vector_size(16), aligned(16))); +typedef unsigned long long v2u64_d __attribute__((vector_size(16), aligned(8))); +typedef float v4f32 __attribute__((vector_size(16), aligned(16))); +typedef float v4f32_w __attribute__((vector_size(16), aligned(4))); +typedef double v2f64 __attribute__ ((vector_size(16), aligned(16))); +typedef double v2f64_d __attribute__ ((vector_size(16), aligned(8))); + +#define __msa_sll_b __builtin_msa_sll_b +#define __msa_sll_h __builtin_msa_sll_h +#define __msa_sll_w __builtin_msa_sll_w +#define __msa_sll_d __builtin_msa_sll_d +#define __msa_slli_b __builtin_msa_slli_b +#define __msa_slli_h __builtin_msa_slli_h +#define __msa_slli_w __builtin_msa_slli_w +#define __msa_slli_d __builtin_msa_slli_d +#define __msa_sra_b __builtin_msa_sra_b +#define __msa_sra_h __builtin_msa_sra_h +#define __msa_sra_w __builtin_msa_sra_w +#define __msa_sra_d __builtin_msa_sra_d +#define __msa_srai_b __builtin_msa_srai_b +#define __msa_srai_h __builtin_msa_srai_h +#define __msa_srai_w __builtin_msa_srai_w +#define __msa_srai_d __builtin_msa_srai_d +#define __msa_srar_b __builtin_msa_srar_b +#define __msa_srar_h __builtin_msa_srar_h +#define __msa_srar_w __builtin_msa_srar_w +#define __msa_srar_d __builtin_msa_srar_d +#define __msa_srari_b __builtin_msa_srari_b +#define __msa_srari_h __builtin_msa_srari_h +#define __msa_srari_w __builtin_msa_srari_w +#define __msa_srari_d __builtin_msa_srari_d +#define __msa_srl_b __builtin_msa_srl_b +#define __msa_srl_h __builtin_msa_srl_h +#define __msa_srl_w __builtin_msa_srl_w +#define __msa_srl_d __builtin_msa_srl_d +#define __msa_srli_b __builtin_msa_srli_b +#define __msa_srli_h __builtin_msa_srli_h +#define __msa_srli_w __builtin_msa_srli_w +#define __msa_srli_d __builtin_msa_srli_d +#define __msa_srlr_b __builtin_msa_srlr_b +#define __msa_srlr_h __builtin_msa_srlr_h +#define __msa_srlr_w __builtin_msa_srlr_w +#define __msa_srlr_d __builtin_msa_srlr_d +#define __msa_srlri_b __builtin_msa_srlri_b +#define __msa_srlri_h __builtin_msa_srlri_h +#define __msa_srlri_w __builtin_msa_srlri_w +#define __msa_srlri_d __builtin_msa_srlri_d +#define __msa_bclr_b __builtin_msa_bclr_b +#define __msa_bclr_h __builtin_msa_bclr_h +#define __msa_bclr_w __builtin_msa_bclr_w +#define __msa_bclr_d __builtin_msa_bclr_d +#define __msa_bclri_b __builtin_msa_bclri_b +#define __msa_bclri_h __builtin_msa_bclri_h +#define __msa_bclri_w __builtin_msa_bclri_w +#define __msa_bclri_d __builtin_msa_bclri_d +#define __msa_bset_b __builtin_msa_bset_b +#define __msa_bset_h __builtin_msa_bset_h +#define __msa_bset_w __builtin_msa_bset_w +#define __msa_bset_d __builtin_msa_bset_d +#define __msa_bseti_b __builtin_msa_bseti_b +#define __msa_bseti_h __builtin_msa_bseti_h +#define __msa_bseti_w __builtin_msa_bseti_w +#define __msa_bseti_d __builtin_msa_bseti_d +#define __msa_bneg_b __builtin_msa_bneg_b +#define __msa_bneg_h __builtin_msa_bneg_h +#define __msa_bneg_w __builtin_msa_bneg_w +#define __msa_bneg_d __builtin_msa_bneg_d +#define __msa_bnegi_b __builtin_msa_bnegi_b +#define __msa_bnegi_h __builtin_msa_bnegi_h +#define __msa_bnegi_w __builtin_msa_bnegi_w +#define __msa_bnegi_d __builtin_msa_bnegi_d +#define __msa_binsl_b __builtin_msa_binsl_b +#define __msa_binsl_h __builtin_msa_binsl_h +#define __msa_binsl_w __builtin_msa_binsl_w +#define __msa_binsl_d __builtin_msa_binsl_d +#define __msa_binsli_b __builtin_msa_binsli_b +#define __msa_binsli_h __builtin_msa_binsli_h +#define __msa_binsli_w __builtin_msa_binsli_w +#define __msa_binsli_d __builtin_msa_binsli_d +#define __msa_binsr_b __builtin_msa_binsr_b +#define __msa_binsr_h __builtin_msa_binsr_h +#define __msa_binsr_w __builtin_msa_binsr_w +#define __msa_binsr_d __builtin_msa_binsr_d +#define __msa_binsri_b __builtin_msa_binsri_b +#define __msa_binsri_h __builtin_msa_binsri_h +#define __msa_binsri_w __builtin_msa_binsri_w +#define __msa_binsri_d __builtin_msa_binsri_d +#define __msa_addv_b __builtin_msa_addv_b +#define __msa_addv_h __builtin_msa_addv_h +#define __msa_addv_w __builtin_msa_addv_w +#define __msa_addv_d __builtin_msa_addv_d +#define __msa_addvi_b __builtin_msa_addvi_b +#define __msa_addvi_h __builtin_msa_addvi_h +#define __msa_addvi_w __builtin_msa_addvi_w +#define __msa_addvi_d __builtin_msa_addvi_d +#define __msa_subv_b __builtin_msa_subv_b +#define __msa_subv_h __builtin_msa_subv_h +#define __msa_subv_w __builtin_msa_subv_w +#define __msa_subv_d __builtin_msa_subv_d +#define __msa_subvi_b __builtin_msa_subvi_b +#define __msa_subvi_h __builtin_msa_subvi_h +#define __msa_subvi_w __builtin_msa_subvi_w +#define __msa_subvi_d __builtin_msa_subvi_d +#define __msa_max_s_b __builtin_msa_max_s_b +#define __msa_max_s_h __builtin_msa_max_s_h +#define __msa_max_s_w __builtin_msa_max_s_w +#define __msa_max_s_d __builtin_msa_max_s_d +#define __msa_maxi_s_b __builtin_msa_maxi_s_b +#define __msa_maxi_s_h __builtin_msa_maxi_s_h +#define __msa_maxi_s_w __builtin_msa_maxi_s_w +#define __msa_maxi_s_d __builtin_msa_maxi_s_d +#define __msa_max_u_b __builtin_msa_max_u_b +#define __msa_max_u_h __builtin_msa_max_u_h +#define __msa_max_u_w __builtin_msa_max_u_w +#define __msa_max_u_d __builtin_msa_max_u_d +#define __msa_maxi_u_b __builtin_msa_maxi_u_b +#define __msa_maxi_u_h __builtin_msa_maxi_u_h +#define __msa_maxi_u_w __builtin_msa_maxi_u_w +#define __msa_maxi_u_d __builtin_msa_maxi_u_d +#define __msa_min_s_b __builtin_msa_min_s_b +#define __msa_min_s_h __builtin_msa_min_s_h +#define __msa_min_s_w __builtin_msa_min_s_w +#define __msa_min_s_d __builtin_msa_min_s_d +#define __msa_mini_s_b __builtin_msa_mini_s_b +#define __msa_mini_s_h __builtin_msa_mini_s_h +#define __msa_mini_s_w __builtin_msa_mini_s_w +#define __msa_mini_s_d __builtin_msa_mini_s_d +#define __msa_min_u_b __builtin_msa_min_u_b +#define __msa_min_u_h __builtin_msa_min_u_h +#define __msa_min_u_w __builtin_msa_min_u_w +#define __msa_min_u_d __builtin_msa_min_u_d +#define __msa_mini_u_b __builtin_msa_mini_u_b +#define __msa_mini_u_h __builtin_msa_mini_u_h +#define __msa_mini_u_w __builtin_msa_mini_u_w +#define __msa_mini_u_d __builtin_msa_mini_u_d +#define __msa_max_a_b __builtin_msa_max_a_b +#define __msa_max_a_h __builtin_msa_max_a_h +#define __msa_max_a_w __builtin_msa_max_a_w +#define __msa_max_a_d __builtin_msa_max_a_d +#define __msa_min_a_b __builtin_msa_min_a_b +#define __msa_min_a_h __builtin_msa_min_a_h +#define __msa_min_a_w __builtin_msa_min_a_w +#define __msa_min_a_d __builtin_msa_min_a_d +#define __msa_ceq_b __builtin_msa_ceq_b +#define __msa_ceq_h __builtin_msa_ceq_h +#define __msa_ceq_w __builtin_msa_ceq_w +#define __msa_ceq_d __builtin_msa_ceq_d +#define __msa_ceqi_b __builtin_msa_ceqi_b +#define __msa_ceqi_h __builtin_msa_ceqi_h +#define __msa_ceqi_w __builtin_msa_ceqi_w +#define __msa_ceqi_d __builtin_msa_ceqi_d +#define __msa_clt_s_b __builtin_msa_clt_s_b +#define __msa_clt_s_h __builtin_msa_clt_s_h +#define __msa_clt_s_w __builtin_msa_clt_s_w +#define __msa_clt_s_d __builtin_msa_clt_s_d +#define __msa_clti_s_b __builtin_msa_clti_s_b +#define __msa_clti_s_h __builtin_msa_clti_s_h +#define __msa_clti_s_w __builtin_msa_clti_s_w +#define __msa_clti_s_d __builtin_msa_clti_s_d +#define __msa_clt_u_b __builtin_msa_clt_u_b +#define __msa_clt_u_h __builtin_msa_clt_u_h +#define __msa_clt_u_w __builtin_msa_clt_u_w +#define __msa_clt_u_d __builtin_msa_clt_u_d +#define __msa_clti_u_b __builtin_msa_clti_u_b +#define __msa_clti_u_h __builtin_msa_clti_u_h +#define __msa_clti_u_w __builtin_msa_clti_u_w +#define __msa_clti_u_d __builtin_msa_clti_u_d +#define __msa_cle_s_b __builtin_msa_cle_s_b +#define __msa_cle_s_h __builtin_msa_cle_s_h +#define __msa_cle_s_w __builtin_msa_cle_s_w +#define __msa_cle_s_d __builtin_msa_cle_s_d +#define __msa_clei_s_b __builtin_msa_clei_s_b +#define __msa_clei_s_h __builtin_msa_clei_s_h +#define __msa_clei_s_w __builtin_msa_clei_s_w +#define __msa_clei_s_d __builtin_msa_clei_s_d +#define __msa_cle_u_b __builtin_msa_cle_u_b +#define __msa_cle_u_h __builtin_msa_cle_u_h +#define __msa_cle_u_w __builtin_msa_cle_u_w +#define __msa_cle_u_d __builtin_msa_cle_u_d +#define __msa_clei_u_b __builtin_msa_clei_u_b +#define __msa_clei_u_h __builtin_msa_clei_u_h +#define __msa_clei_u_w __builtin_msa_clei_u_w +#define __msa_clei_u_d __builtin_msa_clei_u_d +#define __msa_ld_b __builtin_msa_ld_b +#define __msa_ld_h __builtin_msa_ld_h +#define __msa_ld_w __builtin_msa_ld_w +#define __msa_ld_d __builtin_msa_ld_d +#define __msa_ldr_d __builtin_msa_ldr_d +#define __msa_ldr_w __builtin_msa_ldrq_w +#define __msa_st_b __builtin_msa_st_b +#define __msa_st_h __builtin_msa_st_h +#define __msa_st_w __builtin_msa_st_w +#define __msa_st_d __builtin_msa_st_d +#define __msa_str_d __builtin_msa_str_d +#define __msa_str_w __builtin_msa_strq_w +#define __msa_sat_s_b __builtin_msa_sat_s_b +#define __msa_sat_s_h __builtin_msa_sat_s_h +#define __msa_sat_s_w __builtin_msa_sat_s_w +#define __msa_sat_s_d __builtin_msa_sat_s_d +#define __msa_sat_u_b __builtin_msa_sat_u_b +#define __msa_sat_u_h __builtin_msa_sat_u_h +#define __msa_sat_u_w __builtin_msa_sat_u_w +#define __msa_sat_u_d __builtin_msa_sat_u_d +#define __msa_add_a_b __builtin_msa_add_a_b +#define __msa_add_a_h __builtin_msa_add_a_h +#define __msa_add_a_w __builtin_msa_add_a_w +#define __msa_add_a_d __builtin_msa_add_a_d +#define __msa_adds_a_b __builtin_msa_adds_a_b +#define __msa_adds_a_h __builtin_msa_adds_a_h +#define __msa_adds_a_w __builtin_msa_adds_a_w +#define __msa_adds_a_d __builtin_msa_adds_a_d +#define __msa_adds_s_b __builtin_msa_adds_s_b +#define __msa_adds_s_h __builtin_msa_adds_s_h +#define __msa_adds_s_w __builtin_msa_adds_s_w +#define __msa_adds_s_d __builtin_msa_adds_s_d +#define __msa_adds_u_b __builtin_msa_adds_u_b +#define __msa_adds_u_h __builtin_msa_adds_u_h +#define __msa_adds_u_w __builtin_msa_adds_u_w +#define __msa_adds_u_d __builtin_msa_adds_u_d +#define __msa_ave_s_b __builtin_msa_ave_s_b +#define __msa_ave_s_h __builtin_msa_ave_s_h +#define __msa_ave_s_w __builtin_msa_ave_s_w +#define __msa_ave_s_d __builtin_msa_ave_s_d +#define __msa_ave_u_b __builtin_msa_ave_u_b +#define __msa_ave_u_h __builtin_msa_ave_u_h +#define __msa_ave_u_w __builtin_msa_ave_u_w +#define __msa_ave_u_d __builtin_msa_ave_u_d +#define __msa_aver_s_b __builtin_msa_aver_s_b +#define __msa_aver_s_h __builtin_msa_aver_s_h +#define __msa_aver_s_w __builtin_msa_aver_s_w +#define __msa_aver_s_d __builtin_msa_aver_s_d +#define __msa_aver_u_b __builtin_msa_aver_u_b +#define __msa_aver_u_h __builtin_msa_aver_u_h +#define __msa_aver_u_w __builtin_msa_aver_u_w +#define __msa_aver_u_d __builtin_msa_aver_u_d +#define __msa_subs_s_b __builtin_msa_subs_s_b +#define __msa_subs_s_h __builtin_msa_subs_s_h +#define __msa_subs_s_w __builtin_msa_subs_s_w +#define __msa_subs_s_d __builtin_msa_subs_s_d +#define __msa_subs_u_b __builtin_msa_subs_u_b +#define __msa_subs_u_h __builtin_msa_subs_u_h +#define __msa_subs_u_w __builtin_msa_subs_u_w +#define __msa_subs_u_d __builtin_msa_subs_u_d +#define __msa_subsuu_s_b __builtin_msa_subsuu_s_b +#define __msa_subsuu_s_h __builtin_msa_subsuu_s_h +#define __msa_subsuu_s_w __builtin_msa_subsuu_s_w +#define __msa_subsuu_s_d __builtin_msa_subsuu_s_d +#define __msa_subsus_u_b __builtin_msa_subsus_u_b +#define __msa_subsus_u_h __builtin_msa_subsus_u_h +#define __msa_subsus_u_w __builtin_msa_subsus_u_w +#define __msa_subsus_u_d __builtin_msa_subsus_u_d +#define __msa_asub_s_b __builtin_msa_asub_s_b +#define __msa_asub_s_h __builtin_msa_asub_s_h +#define __msa_asub_s_w __builtin_msa_asub_s_w +#define __msa_asub_s_d __builtin_msa_asub_s_d +#define __msa_asub_u_b __builtin_msa_asub_u_b +#define __msa_asub_u_h __builtin_msa_asub_u_h +#define __msa_asub_u_w __builtin_msa_asub_u_w +#define __msa_asub_u_d __builtin_msa_asub_u_d +#define __msa_mulv_b __builtin_msa_mulv_b +#define __msa_mulv_h __builtin_msa_mulv_h +#define __msa_mulv_w __builtin_msa_mulv_w +#define __msa_mulv_d __builtin_msa_mulv_d +#define __msa_maddv_b __builtin_msa_maddv_b +#define __msa_maddv_h __builtin_msa_maddv_h +#define __msa_maddv_w __builtin_msa_maddv_w +#define __msa_maddv_d __builtin_msa_maddv_d +#define __msa_msubv_b __builtin_msa_msubv_b +#define __msa_msubv_h __builtin_msa_msubv_h +#define __msa_msubv_w __builtin_msa_msubv_w +#define __msa_msubv_d __builtin_msa_msubv_d +#define __msa_div_s_b __builtin_msa_div_s_b +#define __msa_div_s_h __builtin_msa_div_s_h +#define __msa_div_s_w __builtin_msa_div_s_w +#define __msa_div_s_d __builtin_msa_div_s_d +#define __msa_div_u_b __builtin_msa_div_u_b +#define __msa_div_u_h __builtin_msa_div_u_h +#define __msa_div_u_w __builtin_msa_div_u_w +#define __msa_div_u_d __builtin_msa_div_u_d +#define __msa_hadd_s_h __builtin_msa_hadd_s_h +#define __msa_hadd_s_w __builtin_msa_hadd_s_w +#define __msa_hadd_s_d __builtin_msa_hadd_s_d +#define __msa_hadd_u_h __builtin_msa_hadd_u_h +#define __msa_hadd_u_w __builtin_msa_hadd_u_w +#define __msa_hadd_u_d __builtin_msa_hadd_u_d +#define __msa_hsub_s_h __builtin_msa_hsub_s_h +#define __msa_hsub_s_w __builtin_msa_hsub_s_w +#define __msa_hsub_s_d __builtin_msa_hsub_s_d +#define __msa_hsub_u_h __builtin_msa_hsub_u_h +#define __msa_hsub_u_w __builtin_msa_hsub_u_w +#define __msa_hsub_u_d __builtin_msa_hsub_u_d +#define __msa_mod_s_b __builtin_msa_mod_s_b +#define __msa_mod_s_h __builtin_msa_mod_s_h +#define __msa_mod_s_w __builtin_msa_mod_s_w +#define __msa_mod_s_d __builtin_msa_mod_s_d +#define __msa_mod_u_b __builtin_msa_mod_u_b +#define __msa_mod_u_h __builtin_msa_mod_u_h +#define __msa_mod_u_w __builtin_msa_mod_u_w +#define __msa_mod_u_d __builtin_msa_mod_u_d +#define __msa_dotp_s_h __builtin_msa_dotp_s_h +#define __msa_dotp_s_w __builtin_msa_dotp_s_w +#define __msa_dotp_s_d __builtin_msa_dotp_s_d +#define __msa_dotp_u_h __builtin_msa_dotp_u_h +#define __msa_dotp_u_w __builtin_msa_dotp_u_w +#define __msa_dotp_u_d __builtin_msa_dotp_u_d +#define __msa_dpadd_s_h __builtin_msa_dpadd_s_h +#define __msa_dpadd_s_w __builtin_msa_dpadd_s_w +#define __msa_dpadd_s_d __builtin_msa_dpadd_s_d +#define __msa_dpadd_u_h __builtin_msa_dpadd_u_h +#define __msa_dpadd_u_w __builtin_msa_dpadd_u_w +#define __msa_dpadd_u_d __builtin_msa_dpadd_u_d +#define __msa_dpsub_s_h __builtin_msa_dpsub_s_h +#define __msa_dpsub_s_w __builtin_msa_dpsub_s_w +#define __msa_dpsub_s_d __builtin_msa_dpsub_s_d +#define __msa_dpsub_u_h __builtin_msa_dpsub_u_h +#define __msa_dpsub_u_w __builtin_msa_dpsub_u_w +#define __msa_dpsub_u_d __builtin_msa_dpsub_u_d +#define __msa_sld_b __builtin_msa_sld_b +#define __msa_sld_h __builtin_msa_sld_h +#define __msa_sld_w __builtin_msa_sld_w +#define __msa_sld_d __builtin_msa_sld_d +#define __msa_sldi_b __builtin_msa_sldi_b +#define __msa_sldi_h __builtin_msa_sldi_h +#define __msa_sldi_w __builtin_msa_sldi_w +#define __msa_sldi_d __builtin_msa_sldi_d +#define __msa_splat_b __builtin_msa_splat_b +#define __msa_splat_h __builtin_msa_splat_h +#define __msa_splat_w __builtin_msa_splat_w +#define __msa_splat_d __builtin_msa_splat_d +#define __msa_splati_b __builtin_msa_splati_b +#define __msa_splati_h __builtin_msa_splati_h +#define __msa_splati_w __builtin_msa_splati_w +#define __msa_splati_d __builtin_msa_splati_d +#define __msa_pckev_b __builtin_msa_pckev_b +#define __msa_pckev_h __builtin_msa_pckev_h +#define __msa_pckev_w __builtin_msa_pckev_w +#define __msa_pckev_d __builtin_msa_pckev_d +#define __msa_pckod_b __builtin_msa_pckod_b +#define __msa_pckod_h __builtin_msa_pckod_h +#define __msa_pckod_w __builtin_msa_pckod_w +#define __msa_pckod_d __builtin_msa_pckod_d +#define __msa_ilvl_b __builtin_msa_ilvl_b +#define __msa_ilvl_h __builtin_msa_ilvl_h +#define __msa_ilvl_w __builtin_msa_ilvl_w +#define __msa_ilvl_d __builtin_msa_ilvl_d +#define __msa_ilvr_b __builtin_msa_ilvr_b +#define __msa_ilvr_h __builtin_msa_ilvr_h +#define __msa_ilvr_w __builtin_msa_ilvr_w +#define __msa_ilvr_d __builtin_msa_ilvr_d +#define __msa_ilvev_b __builtin_msa_ilvev_b +#define __msa_ilvev_h __builtin_msa_ilvev_h +#define __msa_ilvev_w __builtin_msa_ilvev_w +#define __msa_ilvev_d __builtin_msa_ilvev_d +#define __msa_ilvod_b __builtin_msa_ilvod_b +#define __msa_ilvod_h __builtin_msa_ilvod_h +#define __msa_ilvod_w __builtin_msa_ilvod_w +#define __msa_ilvod_d __builtin_msa_ilvod_d +#define __msa_vshf_b __builtin_msa_vshf_b +#define __msa_vshf_h __builtin_msa_vshf_h +#define __msa_vshf_w __builtin_msa_vshf_w +#define __msa_vshf_d __builtin_msa_vshf_d +#define __msa_and_v __builtin_msa_and_v +#define __msa_andi_b __builtin_msa_andi_b +#define __msa_or_v __builtin_msa_or_v +#define __msa_ori_b __builtin_msa_ori_b +#define __msa_nor_v __builtin_msa_nor_v +#define __msa_nori_b __builtin_msa_nori_b +#define __msa_xor_v __builtin_msa_xor_v +#define __msa_xori_b __builtin_msa_xori_b +#define __msa_bmnz_v __builtin_msa_bmnz_v +#define __msa_bmnzi_b __builtin_msa_bmnzi_b +#define __msa_bmz_v __builtin_msa_bmz_v +#define __msa_bmzi_b __builtin_msa_bmzi_b +#define __msa_bsel_v __builtin_msa_bsel_v +#define __msa_bseli_b __builtin_msa_bseli_b +#define __msa_shf_b __builtin_msa_shf_b +#define __msa_shf_h __builtin_msa_shf_h +#define __msa_shf_w __builtin_msa_shf_w +#define __msa_test_bnz_v __builtin_msa_bnz_v +#define __msa_test_bz_v __builtin_msa_bz_v +#define __msa_fill_b __builtin_msa_fill_b +#define __msa_fill_h __builtin_msa_fill_h +#define __msa_fill_w __builtin_msa_fill_w +#define __msa_fill_d __builtin_msa_fill_d +#define __msa_pcnt_b __builtin_msa_pcnt_b +#define __msa_pcnt_h __builtin_msa_pcnt_h +#define __msa_pcnt_w __builtin_msa_pcnt_w +#define __msa_pcnt_d __builtin_msa_pcnt_d +#define __msa_nloc_b __builtin_msa_nloc_b +#define __msa_nloc_h __builtin_msa_nloc_h +#define __msa_nloc_w __builtin_msa_nloc_w +#define __msa_nloc_d __builtin_msa_nloc_d +#define __msa_nlzc_b __builtin_msa_nlzc_b +#define __msa_nlzc_h __builtin_msa_nlzc_h +#define __msa_nlzc_w __builtin_msa_nlzc_w +#define __msa_nlzc_d __builtin_msa_nlzc_d +#define __msa_copy_s_b __builtin_msa_copy_s_b +#define __msa_copy_s_h __builtin_msa_copy_s_h +#define __msa_copy_s_w __builtin_msa_copy_s_w +#define __msa_copy_s_d __builtin_msa_copy_s_d +#define __msa_copy_u_b __builtin_msa_copy_u_b +#define __msa_copy_u_h __builtin_msa_copy_u_h +#define __msa_copy_u_w __builtin_msa_copy_u_w +#define __msa_copy_u_d __builtin_msa_copy_u_d +#define __msa_insert_b __builtin_msa_insert_b +#define __msa_insert_h __builtin_msa_insert_h +#define __msa_insert_w __builtin_msa_insert_w +#define __msa_insert_d __builtin_msa_insert_d +#define __msa_insve_b __builtin_msa_insve_b +#define __msa_insve_h __builtin_msa_insve_h +#define __msa_insve_w __builtin_msa_insve_w +#define __msa_insve_d __builtin_msa_insve_d +#define __msa_test_bnz_b __builtin_msa_bnz_b +#define __msa_test_bnz_h __builtin_msa_bnz_h +#define __msa_test_bnz_w __builtin_msa_bnz_w +#define __msa_test_bnz_d __builtin_msa_bnz_d +#define __msa_test_bz_b __builtin_msa_bz_b +#define __msa_test_bz_h __builtin_msa_bz_h +#define __msa_test_bz_w __builtin_msa_bz_w +#define __msa_test_bz_d __builtin_msa_bz_d +#define __msa_ldi_b __builtin_msa_ldi_b +#define __msa_ldi_h __builtin_msa_ldi_h +#define __msa_ldi_w __builtin_msa_ldi_w +#define __msa_ldi_d __builtin_msa_ldi_d +#define __msa_fcaf_w __builtin_msa_fcaf_w +#define __msa_fcaf_d __builtin_msa_fcaf_d +#define __msa_fcor_w __builtin_msa_fcor_w +#define __msa_fcor_d __builtin_msa_fcor_d +#define __msa_fcun_w __builtin_msa_fcun_w +#define __msa_fcun_d __builtin_msa_fcun_d +#define __msa_fcune_w __builtin_msa_fcune_w +#define __msa_fcune_d __builtin_msa_fcune_d +#define __msa_fcueq_w __builtin_msa_fcueq_w +#define __msa_fcueq_d __builtin_msa_fcueq_d +#define __msa_fceq_w __builtin_msa_fceq_w +#define __msa_fceq_d __builtin_msa_fceq_d +#define __msa_fcne_w __builtin_msa_fcne_w +#define __msa_fcne_d __builtin_msa_fcne_d +#define __msa_fclt_w __builtin_msa_fclt_w +#define __msa_fclt_d __builtin_msa_fclt_d +#define __msa_fcult_w __builtin_msa_fcult_w +#define __msa_fcult_d __builtin_msa_fcult_d +#define __msa_fcle_w __builtin_msa_fcle_w +#define __msa_fcle_d __builtin_msa_fcle_d +#define __msa_fcule_w __builtin_msa_fcule_w +#define __msa_fcule_d __builtin_msa_fcule_d +#define __msa_fsaf_w __builtin_msa_fsaf_w +#define __msa_fsaf_d __builtin_msa_fsaf_d +#define __msa_fsor_w __builtin_msa_fsor_w +#define __msa_fsor_d __builtin_msa_fsor_d +#define __msa_fsun_w __builtin_msa_fsun_w +#define __msa_fsun_d __builtin_msa_fsun_d +#define __msa_fsune_w __builtin_msa_fsune_w +#define __msa_fsune_d __builtin_msa_fsune_d +#define __msa_fsueq_w __builtin_msa_fsueq_w +#define __msa_fsueq_d __builtin_msa_fsueq_d +#define __msa_fseq_w __builtin_msa_fseq_w +#define __msa_fseq_d __builtin_msa_fseq_d +#define __msa_fsne_w __builtin_msa_fsne_w +#define __msa_fsne_d __builtin_msa_fsne_d +#define __msa_fslt_w __builtin_msa_fslt_w +#define __msa_fslt_d __builtin_msa_fslt_d +#define __msa_fsult_w __builtin_msa_fsult_w +#define __msa_fsult_d __builtin_msa_fsult_d +#define __msa_fsle_w __builtin_msa_fsle_w +#define __msa_fsle_d __builtin_msa_fsle_d +#define __msa_fsule_w __builtin_msa_fsule_w +#define __msa_fsule_d __builtin_msa_fsule_d +#define __msa_fadd_w __builtin_msa_fadd_w +#define __msa_fadd_d __builtin_msa_fadd_d +#define __msa_fsub_w __builtin_msa_fsub_w +#define __msa_fsub_d __builtin_msa_fsub_d +#define __msa_fmul_w __builtin_msa_fmul_w +#define __msa_fmul_d __builtin_msa_fmul_d +#define __msa_fdiv_w __builtin_msa_fdiv_w +#define __msa_fdiv_d __builtin_msa_fdiv_d +#define __msa_fmadd_w __builtin_msa_fmadd_w +#define __msa_fmadd_d __builtin_msa_fmadd_d +#define __msa_fmsub_w __builtin_msa_fmsub_w +#define __msa_fmsub_d __builtin_msa_fmsub_d +#define __msa_fexp2_w __builtin_msa_fexp2_w +#define __msa_fexp2_d __builtin_msa_fexp2_d +#define __msa_fexdo_h __builtin_msa_fexdo_h +#define __msa_fexdo_w __builtin_msa_fexdo_w +#define __msa_ftq_h __builtin_msa_ftq_h +#define __msa_ftq_w __builtin_msa_ftq_w +#define __msa_fmin_w __builtin_msa_fmin_w +#define __msa_fmin_d __builtin_msa_fmin_d +#define __msa_fmin_a_w __builtin_msa_fmin_a_w +#define __msa_fmin_a_d __builtin_msa_fmin_a_d +#define __msa_fmax_w __builtin_msa_fmax_w +#define __msa_fmax_d __builtin_msa_fmax_d +#define __msa_fmax_a_w __builtin_msa_fmax_a_w +#define __msa_fmax_a_d __builtin_msa_fmax_a_d +#define __msa_mul_q_h __builtin_msa_mul_q_h +#define __msa_mul_q_w __builtin_msa_mul_q_w +#define __msa_mulr_q_h __builtin_msa_mulr_q_h +#define __msa_mulr_q_w __builtin_msa_mulr_q_w +#define __msa_madd_q_h __builtin_msa_madd_q_h +#define __msa_madd_q_w __builtin_msa_madd_q_w +#define __msa_maddr_q_h __builtin_msa_maddr_q_h +#define __msa_maddr_q_w __builtin_msa_maddr_q_w +#define __msa_msub_q_h __builtin_msa_msub_q_h +#define __msa_msub_q_w __builtin_msa_msub_q_w +#define __msa_msubr_q_h __builtin_msa_msubr_q_h +#define __msa_msubr_q_w __builtin_msa_msubr_q_w +#define __msa_fclass_w __builtin_msa_fclass_w +#define __msa_fclass_d __builtin_msa_fclass_d +#define __msa_fsqrt_w __builtin_msa_fsqrt_w +#define __msa_fsqrt_d __builtin_msa_fsqrt_d +#define __msa_frcp_w __builtin_msa_frcp_w +#define __msa_frcp_d __builtin_msa_frcp_d +#define __msa_frint_w __builtin_msa_frint_w +#define __msa_frint_d __builtin_msa_frint_d +#define __msa_frsqrt_w __builtin_msa_frsqrt_w +#define __msa_frsqrt_d __builtin_msa_frsqrt_d +#define __msa_flog2_w __builtin_msa_flog2_w +#define __msa_flog2_d __builtin_msa_flog2_d +#define __msa_fexupl_w __builtin_msa_fexupl_w +#define __msa_fexupl_d __builtin_msa_fexupl_d +#define __msa_fexupr_w __builtin_msa_fexupr_w +#define __msa_fexupr_d __builtin_msa_fexupr_d +#define __msa_ffql_w __builtin_msa_ffql_w +#define __msa_ffql_d __builtin_msa_ffql_d +#define __msa_ffqr_w __builtin_msa_ffqr_w +#define __msa_ffqr_d __builtin_msa_ffqr_d +#define __msa_ftint_s_w __builtin_msa_ftint_s_w +#define __msa_ftint_s_d __builtin_msa_ftint_s_d +#define __msa_ftint_u_w __builtin_msa_ftint_u_w +#define __msa_ftint_u_d __builtin_msa_ftint_u_d +#define __msa_ftrunc_s_w __builtin_msa_ftrunc_s_w +#define __msa_ftrunc_s_d __builtin_msa_ftrunc_s_d +#define __msa_ftrunc_u_w __builtin_msa_ftrunc_u_w +#define __msa_ftrunc_u_d __builtin_msa_ftrunc_u_d +#define __msa_ffint_s_w __builtin_msa_ffint_s_w +#define __msa_ffint_s_d __builtin_msa_ffint_s_d +#define __msa_ffint_u_w __builtin_msa_ffint_u_w +#define __msa_ffint_u_d __builtin_msa_ffint_u_d +#define __msa_cfcmsa __builtin_msa_cfcmsa +#define __msa_move_v __builtin_msa_move_v +#define __msa_cast_to_vector_float __builtin_msa_cast_to_vector_float +#define __msa_cast_to_vector_double __builtin_msa_cast_to_vector_double +#define __msa_cast_to_scalar_float __builtin_msa_cast_to_scalar_float +#define __msa_cast_to_scalar_double __builtin_msa_cast_to_scalar_double +#endif /* defined(__mips_msa) */ +#endif /* _MSA_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mwaitxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mwaitxintrin.h new file mode 100755 index 0000000..65f4271 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/mwaitxintrin.h @@ -0,0 +1,62 @@ +/*===---- mwaitxintrin.h - MONITORX/MWAITX intrinsics ----------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __MWAITXINTRIN_H +#define __MWAITXINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("mwaitx"))) + +/// Establishes a linear address memory range to be monitored and puts +/// the processor in the monitor event pending state. Data stored in the +/// monitored address range causes the processor to exit the pending state. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MONITORX instruction. +/// +/// \param __p +/// The memory range to be monitored. The size of the range is determined by +/// CPUID function 0000_0005h. +/// \param __extensions +/// Optional extensions for the monitoring state. +/// \param __hints +/// Optional hints for the monitoring state. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_monitorx(void * __p, unsigned __extensions, unsigned __hints) +{ + __builtin_ia32_monitorx(__p, __extensions, __hints); +} + +/// Used with the \c MONITORX instruction to wait while the processor is in +/// the monitor event pending state. Data stored in the monitored address +/// range, or an interrupt, causes the processor to exit the pending state. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MWAITX instruction. +/// +/// \param __extensions +/// Optional extensions for the monitoring state, which can vary by +/// processor. +/// \param __hints +/// Optional hints for the monitoring state, which can vary by processor. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_mwaitx(unsigned __extensions, unsigned __hints, unsigned __clock) +{ + __builtin_ia32_mwaitx(__extensions, __hints, __clock); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __MWAITXINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/nmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/nmmintrin.h new file mode 100755 index 0000000..59fc7ec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/nmmintrin.h @@ -0,0 +1,20 @@ +/*===---- nmmintrin.h - SSE4 intrinsics ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __NMMINTRIN_H +#define __NMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +/* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h, + just include it now then. */ +#include +#endif /* __NMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/nvptxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/nvptxintrin.h new file mode 100755 index 0000000..fb811d0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/nvptxintrin.h @@ -0,0 +1,219 @@ +//===-- nvptxintrin.h - NVPTX intrinsic functions -------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __NVPTXINTRIN_H +#define __NVPTXINTRIN_H + +#ifndef __NVPTX__ +#error "This file is intended for NVPTX targets or offloading to NVPTX" +#endif + +#ifndef __GPUINTRIN_H +#error "Never use directly; include instead" +#endif + +#ifndef __CUDA_ARCH__ +#define __CUDA_ARCH__ 0 +#endif + +_Pragma("omp begin declare target device_type(nohost)"); +_Pragma("omp begin declare variant match(device = {arch(nvptx64)})"); + +// Type aliases to the address spaces used by the NVPTX backend. +#define __gpu_private __attribute__((address_space(5))) +#define __gpu_constant __attribute__((address_space(4))) +#define __gpu_local __attribute__((address_space(3))) +#define __gpu_global __attribute__((address_space(1))) +#define __gpu_generic __attribute__((address_space(0))) + +// Attribute to declare a function as a kernel. +#define __gpu_kernel __attribute__((nvptx_kernel, visibility("protected"))) + +// Returns the number of CUDA blocks in the 'x' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks_x(void) { + return __nvvm_read_ptx_sreg_nctaid_x(); +} + +// Returns the number of CUDA blocks in the 'y' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks_y(void) { + return __nvvm_read_ptx_sreg_nctaid_y(); +} + +// Returns the number of CUDA blocks in the 'z' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_blocks_z(void) { + return __nvvm_read_ptx_sreg_nctaid_z(); +} + +// Returns the 'x' dimension of the current CUDA block's id. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id_x(void) { + return __nvvm_read_ptx_sreg_ctaid_x(); +} + +// Returns the 'y' dimension of the current CUDA block's id. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id_y(void) { + return __nvvm_read_ptx_sreg_ctaid_y(); +} + +// Returns the 'z' dimension of the current CUDA block's id. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_block_id_z(void) { + return __nvvm_read_ptx_sreg_ctaid_z(); +} + +// Returns the number of CUDA threads in the 'x' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads_x(void) { + return __nvvm_read_ptx_sreg_ntid_x(); +} + +// Returns the number of CUDA threads in the 'y' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads_y(void) { + return __nvvm_read_ptx_sreg_ntid_y(); +} + +// Returns the number of CUDA threads in the 'z' dimension. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_threads_z(void) { + return __nvvm_read_ptx_sreg_ntid_z(); +} + +// Returns the 'x' dimension id of the thread in the current CUDA block. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id_x(void) { + return __nvvm_read_ptx_sreg_tid_x(); +} + +// Returns the 'y' dimension id of the thread in the current CUDA block. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id_y(void) { + return __nvvm_read_ptx_sreg_tid_y(); +} + +// Returns the 'z' dimension id of the thread in the current CUDA block. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_thread_id_z(void) { + return __nvvm_read_ptx_sreg_tid_z(); +} + +// Returns the size of a CUDA warp, always 32 on NVIDIA hardware. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_num_lanes(void) { + return __nvvm_read_ptx_sreg_warpsize(); +} + +// Returns the id of the thread inside of a CUDA warp executing together. +_DEFAULT_FN_ATTRS static __inline__ uint32_t __gpu_lane_id(void) { + return __nvvm_read_ptx_sreg_laneid(); +} + +// Returns the bit-mask of active threads in the current warp. +_DEFAULT_FN_ATTRS static __inline__ uint64_t __gpu_lane_mask(void) { + return __nvvm_activemask(); +} + +// Copies the value from the first active thread in the warp to the rest. +_DEFAULT_FN_ATTRS static __inline__ uint32_t +__gpu_read_first_lane_u32(uint64_t __lane_mask, uint32_t __x) { + uint32_t __mask = (uint32_t)__lane_mask; + uint32_t __id = __builtin_ffs(__mask) - 1; + return __nvvm_shfl_sync_idx_i32(__mask, __x, __id, __gpu_num_lanes() - 1); +} + +// Returns a bitmask of threads in the current lane for which \p x is true. +_DEFAULT_FN_ATTRS static __inline__ uint64_t __gpu_ballot(uint64_t __lane_mask, + bool __x) { + uint32_t __mask = (uint32_t)__lane_mask; + return __nvvm_vote_ballot_sync(__mask, __x); +} + +// Waits for all the threads in the block to converge and issues a fence. +_DEFAULT_FN_ATTRS static __inline__ void __gpu_sync_threads(void) { + __syncthreads(); +} + +// Waits for all threads in the warp to reconverge for independent scheduling. +_DEFAULT_FN_ATTRS static __inline__ void __gpu_sync_lane(uint64_t __lane_mask) { + __nvvm_bar_warp_sync((uint32_t)__lane_mask); +} + +// Shuffles the the lanes inside the warp according to the given index. +_DEFAULT_FN_ATTRS static __inline__ uint32_t +__gpu_shuffle_idx_u32(uint64_t __lane_mask, uint32_t __idx, uint32_t __x, + uint32_t __width) { + // Mask out inactive lanes to match AMDGPU behavior. + uint32_t __mask = (uint32_t)__lane_mask; + bool __bitmask = (1ull << __idx) & __lane_mask; + return -__bitmask & + __nvvm_shfl_sync_idx_i32(__mask, __x, __idx, + ((__gpu_num_lanes() - __width) << 8u) | 0x1f); +} + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u32(uint64_t __lane_mask, uint32_t __x) { + // Newer targets can use the dedicated CUDA support. +#if __CUDA_ARCH__ >= 700 + return __nvvm_match_any_sync_i32(__lane_mask, __x); +#else + return __gpu_match_any_u32_impl(__lane_mask, __x); +#endif +} + +// Returns a bitmask marking all lanes that have the same value of __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_any_u64(uint64_t __lane_mask, uint64_t __x) { + // Newer targets can use the dedicated CUDA support. +#if __CUDA_ARCH__ >= 700 + return __nvvm_match_any_sync_i64(__lane_mask, __x); +#else + return __gpu_match_any_u64_impl(__lane_mask, __x); +#endif +} + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u32(uint64_t __lane_mask, uint32_t __x) { + // Newer targets can use the dedicated CUDA support. +#if __CUDA_ARCH__ >= 700 + int predicate; + return __nvvm_match_all_sync_i32p(__lane_mask, __x, &predicate); +#else + return __gpu_match_all_u32_impl(__lane_mask, __x); +#endif +} + +// Returns the current lane mask if every lane contains __x. +_DEFAULT_FN_ATTRS static __inline__ uint64_t +__gpu_match_all_u64(uint64_t __lane_mask, uint64_t __x) { + // Newer targets can use the dedicated CUDA support. +#if __CUDA_ARCH__ >= 700 + int predicate; + return __nvvm_match_all_sync_i64p(__lane_mask, __x, &predicate); +#else + return __gpu_match_all_u64_impl(__lane_mask, __x); +#endif +} + +// Returns true if the flat pointer points to CUDA 'shared' memory. +_DEFAULT_FN_ATTRS static __inline__ bool __gpu_is_ptr_local(void *ptr) { + return __nvvm_isspacep_shared(ptr); +} + +// Returns true if the flat pointer points to CUDA 'local' memory. +_DEFAULT_FN_ATTRS static __inline__ bool __gpu_is_ptr_private(void *ptr) { + return __nvvm_isspacep_local(ptr); +} + +// Terminates execution of the calling thread. +_DEFAULT_FN_ATTRS [[noreturn]] static __inline__ void __gpu_exit(void) { + __nvvm_exit(); +} + +// Suspend the thread briefly to assist the scheduler during busy loops. +_DEFAULT_FN_ATTRS static __inline__ void __gpu_thread_suspend(void) { + if (__nvvm_reflect("__CUDA_ARCH") >= 700) + asm("nanosleep.u32 64;" ::: "memory"); +} + +_Pragma("omp end declare variant"); +_Pragma("omp end declare target"); + +#endif // __NVPTXINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/opencl-c-base.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/opencl-c-base.h new file mode 100755 index 0000000..6206a34 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/opencl-c-base.h @@ -0,0 +1,851 @@ +//===----- opencl-c-base.h - OpenCL C language base definitions -----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _OPENCL_BASE_H_ +#define _OPENCL_BASE_H_ + +// Define extension macros + +#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) +// For SPIR and SPIR-V all extensions are supported. +#if defined(__SPIR__) || defined(__SPIRV__) +#define cl_khr_subgroup_extended_types 1 +#define cl_khr_subgroup_non_uniform_vote 1 +#define cl_khr_subgroup_ballot 1 +#define cl_khr_subgroup_non_uniform_arithmetic 1 +#define cl_khr_subgroup_shuffle 1 +#define cl_khr_subgroup_shuffle_relative 1 +#define cl_khr_subgroup_clustered_reduce 1 +#define cl_khr_subgroup_rotate 1 +#define cl_khr_extended_bit_ops 1 +#define cl_khr_integer_dot_product 1 +#define __opencl_c_integer_dot_product_input_4x8bit 1 +#define __opencl_c_integer_dot_product_input_4x8bit_packed 1 +#define cl_ext_float_atomics 1 +#ifdef cl_khr_fp16 +#define __opencl_c_ext_fp16_global_atomic_load_store 1 +#define __opencl_c_ext_fp16_local_atomic_load_store 1 +#define __opencl_c_ext_fp16_global_atomic_add 1 +#define __opencl_c_ext_fp16_local_atomic_add 1 +#define __opencl_c_ext_fp16_global_atomic_min_max 1 +#define __opencl_c_ext_fp16_local_atomic_min_max 1 +#endif +#ifdef cl_khr_fp64 +#define __opencl_c_ext_fp64_global_atomic_add 1 +#define __opencl_c_ext_fp64_local_atomic_add 1 +#define __opencl_c_ext_fp64_global_atomic_min_max 1 +#define __opencl_c_ext_fp64_local_atomic_min_max 1 +#endif +#define __opencl_c_ext_fp32_global_atomic_add 1 +#define __opencl_c_ext_fp32_local_atomic_add 1 +#define __opencl_c_ext_fp32_global_atomic_min_max 1 +#define __opencl_c_ext_fp32_local_atomic_min_max 1 +#define __opencl_c_ext_image_raw10_raw12 1 +#define __opencl_c_ext_image_unorm_int_2_101010 1 +#define __opencl_c_ext_image_unsigned_10x6_12x4_14x2 1 +#define cl_khr_kernel_clock 1 +#define __opencl_c_kernel_clock_scope_device 1 +#define __opencl_c_kernel_clock_scope_work_group 1 +#define __opencl_c_kernel_clock_scope_sub_group 1 + +#endif // defined(__SPIR__) || defined(__SPIRV__) +#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) + +// Define feature macros for OpenCL C 2.0 +#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) +#define __opencl_c_pipes 1 +#define __opencl_c_generic_address_space 1 +#define __opencl_c_work_group_collective_functions 1 +#define __opencl_c_atomic_order_acq_rel 1 +#define __opencl_c_atomic_order_seq_cst 1 +#define __opencl_c_atomic_scope_device 1 +#define __opencl_c_atomic_scope_all_devices 1 +#define __opencl_c_device_enqueue 1 +#define __opencl_c_read_write_images 1 +#define __opencl_c_program_scope_global_variables 1 +#define __opencl_c_images 1 +#endif + +// Define header-only feature macros for OpenCL C 3.0. +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) +// For the SPIR and SPIR-V target all features are supported. +#if defined(__SPIR__) || defined(__SPIRV__) +#define __opencl_c_work_group_collective_functions 1 +#define __opencl_c_atomic_order_seq_cst 1 +#define __opencl_c_atomic_scope_device 1 +#define __opencl_c_atomic_scope_all_devices 1 +#define __opencl_c_read_write_images 1 +#endif // defined(__SPIR__) + +// Undefine any feature macros that have been explicitly disabled using +// an __undef_ macro. +#ifdef __undef___opencl_c_work_group_collective_functions +#undef __opencl_c_work_group_collective_functions +#endif +#ifdef __undef___opencl_c_atomic_order_seq_cst +#undef __opencl_c_atomic_order_seq_cst +#endif +#ifdef __undef___opencl_c_atomic_scope_device +#undef __opencl_c_atomic_scope_device +#endif +#ifdef __undef___opencl_c_atomic_scope_all_devices +#undef __opencl_c_atomic_scope_all_devices +#endif +#ifdef __undef___opencl_c_read_write_images +#undef __opencl_c_read_write_images +#endif + +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) + +#if !defined(__opencl_c_generic_address_space) +// Internal feature macro to provide named (global, local, private) address +// space overloads for builtin functions that take a pointer argument. +#define __opencl_c_named_address_space_builtins 1 +#endif // !defined(__opencl_c_generic_address_space) + +#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups) +// Internal feature macro to provide subgroup builtins. +#define __opencl_subgroup_builtins 1 +#endif + +// built-in scalar data types: + +/** + * An unsigned 8-bit integer. + */ +typedef unsigned char uchar; + +/** + * An unsigned 16-bit integer. + */ +typedef unsigned short ushort; + +/** + * An unsigned 32-bit integer. + */ +typedef unsigned int uint; + +/** + * An unsigned 64-bit integer. + */ +typedef unsigned long ulong; + +/** + * The unsigned integer type of the result of the sizeof operator. This + * is a 32-bit unsigned integer if CL_DEVICE_ADDRESS_BITS + * defined in table 4.3 is 32-bits and is a 64-bit unsigned integer if + * CL_DEVICE_ADDRESS_BITS is 64-bits. + */ +typedef __SIZE_TYPE__ size_t; + +/** + * A signed integer type that is the result of subtracting two pointers. + * This is a 32-bit signed integer if CL_DEVICE_ADDRESS_BITS + * defined in table 4.3 is 32-bits and is a 64-bit signed integer if + * CL_DEVICE_ADDRESS_BITS is 64-bits. + */ +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +/** + * A signed integer type with the property that any valid pointer to + * void can be converted to this type, then converted back to pointer + * to void, and the result will compare equal to the original pointer. + */ +typedef __INTPTR_TYPE__ intptr_t; + +/** + * An unsigned integer type with the property that any valid pointer to + * void can be converted to this type, then converted back to pointer + * to void, and the result will compare equal to the original pointer. + */ +typedef __UINTPTR_TYPE__ uintptr_t; + +// built-in vector data types: +typedef char char2 __attribute__((ext_vector_type(2))); +typedef char char3 __attribute__((ext_vector_type(3))); +typedef char char4 __attribute__((ext_vector_type(4))); +typedef char char8 __attribute__((ext_vector_type(8))); +typedef char char16 __attribute__((ext_vector_type(16))); +typedef uchar uchar2 __attribute__((ext_vector_type(2))); +typedef uchar uchar3 __attribute__((ext_vector_type(3))); +typedef uchar uchar4 __attribute__((ext_vector_type(4))); +typedef uchar uchar8 __attribute__((ext_vector_type(8))); +typedef uchar uchar16 __attribute__((ext_vector_type(16))); +typedef short short2 __attribute__((ext_vector_type(2))); +typedef short short3 __attribute__((ext_vector_type(3))); +typedef short short4 __attribute__((ext_vector_type(4))); +typedef short short8 __attribute__((ext_vector_type(8))); +typedef short short16 __attribute__((ext_vector_type(16))); +typedef ushort ushort2 __attribute__((ext_vector_type(2))); +typedef ushort ushort3 __attribute__((ext_vector_type(3))); +typedef ushort ushort4 __attribute__((ext_vector_type(4))); +typedef ushort ushort8 __attribute__((ext_vector_type(8))); +typedef ushort ushort16 __attribute__((ext_vector_type(16))); +typedef int int2 __attribute__((ext_vector_type(2))); +typedef int int3 __attribute__((ext_vector_type(3))); +typedef int int4 __attribute__((ext_vector_type(4))); +typedef int int8 __attribute__((ext_vector_type(8))); +typedef int int16 __attribute__((ext_vector_type(16))); +typedef uint uint2 __attribute__((ext_vector_type(2))); +typedef uint uint3 __attribute__((ext_vector_type(3))); +typedef uint uint4 __attribute__((ext_vector_type(4))); +typedef uint uint8 __attribute__((ext_vector_type(8))); +typedef uint uint16 __attribute__((ext_vector_type(16))); +typedef long long2 __attribute__((ext_vector_type(2))); +typedef long long3 __attribute__((ext_vector_type(3))); +typedef long long4 __attribute__((ext_vector_type(4))); +typedef long long8 __attribute__((ext_vector_type(8))); +typedef long long16 __attribute__((ext_vector_type(16))); +typedef ulong ulong2 __attribute__((ext_vector_type(2))); +typedef ulong ulong3 __attribute__((ext_vector_type(3))); +typedef ulong ulong4 __attribute__((ext_vector_type(4))); +typedef ulong ulong8 __attribute__((ext_vector_type(8))); +typedef ulong ulong16 __attribute__((ext_vector_type(16))); +typedef float float2 __attribute__((ext_vector_type(2))); +typedef float float3 __attribute__((ext_vector_type(3))); +typedef float float4 __attribute__((ext_vector_type(4))); +typedef float float8 __attribute__((ext_vector_type(8))); +typedef float float16 __attribute__((ext_vector_type(16))); +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +typedef half half2 __attribute__((ext_vector_type(2))); +typedef half half3 __attribute__((ext_vector_type(3))); +typedef half half4 __attribute__((ext_vector_type(4))); +typedef half half8 __attribute__((ext_vector_type(8))); +typedef half half16 __attribute__((ext_vector_type(16))); +#endif +#ifdef cl_khr_fp64 +#if __OPENCL_C_VERSION__ < CL_VERSION_1_2 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +#endif +typedef double double2 __attribute__((ext_vector_type(2))); +typedef double double3 __attribute__((ext_vector_type(3))); +typedef double double4 __attribute__((ext_vector_type(4))); +typedef double double8 __attribute__((ext_vector_type(8))); +typedef double double16 __attribute__((ext_vector_type(16))); +#endif + +// An internal alias for half, for use by OpenCLBuiltins.td. +#define __half half + +#if defined(__OPENCL_CPP_VERSION__) +#define NULL nullptr +#elif defined(__OPENCL_C_VERSION__) +#define NULL ((void*)0) +#endif + +/** + * Value of maximum non-infinite single-precision floating-point + * number. + */ +#define MAXFLOAT 0x1.fffffep127f + +/** + * A positive float constant expression. HUGE_VALF evaluates + * to +infinity. Used as an error value returned by the built-in + * math functions. + */ +#define HUGE_VALF (__builtin_huge_valf()) + +/** + * A positive double constant expression. HUGE_VAL evaluates + * to +infinity. Used as an error value returned by the built-in + * math functions. + */ +#define HUGE_VAL (__builtin_huge_val()) + +/** + * A constant expression of type float representing positive or + * unsigned infinity. + */ +#define INFINITY (__builtin_inff()) + +/** + * A constant expression of type float representing a quiet NaN. + */ +#define NAN as_float(INT_MAX) + +#define FP_ILOGB0 INT_MIN +#define FP_ILOGBNAN INT_MAX + +#define FLT_DIG 6 +#define FLT_MANT_DIG 24 +#define FLT_MAX_10_EXP +38 +#define FLT_MAX_EXP +128 +#define FLT_MIN_10_EXP -37 +#define FLT_MIN_EXP -125 +#define FLT_RADIX 2 +#define FLT_MAX 0x1.fffffep127f +#define FLT_MIN 0x1.0p-126f +#define FLT_EPSILON 0x1.0p-23f + +#define M_E_F 2.71828182845904523536028747135266250f +#define M_LOG2E_F 1.44269504088896340735992468100189214f +#define M_LOG10E_F 0.434294481903251827651128918916605082f +#define M_LN2_F 0.693147180559945309417232121458176568f +#define M_LN10_F 2.30258509299404568401799145468436421f +#define M_PI_F 3.14159265358979323846264338327950288f +#define M_PI_2_F 1.57079632679489661923132169163975144f +#define M_PI_4_F 0.785398163397448309615660845819875721f +#define M_1_PI_F 0.318309886183790671537767526745028724f +#define M_2_PI_F 0.636619772367581343075535053490057448f +#define M_2_SQRTPI_F 1.12837916709551257389615890312154517f +#define M_SQRT2_F 1.41421356237309504880168872420969808f +#define M_SQRT1_2_F 0.707106781186547524400844362104849039f + +#define DBL_DIG 15 +#define DBL_MANT_DIG 53 +#define DBL_MAX_10_EXP +308 +#define DBL_MAX_EXP +1024 +#define DBL_MIN_10_EXP -307 +#define DBL_MIN_EXP -1021 +#define DBL_RADIX 2 +#define DBL_MAX 0x1.fffffffffffffp1023 +#define DBL_MIN 0x1.0p-1022 +#define DBL_EPSILON 0x1.0p-52 + +#define M_E 0x1.5bf0a8b145769p+1 +#define M_LOG2E 0x1.71547652b82fep+0 +#define M_LOG10E 0x1.bcb7b1526e50ep-2 +#define M_LN2 0x1.62e42fefa39efp-1 +#define M_LN10 0x1.26bb1bbb55516p+1 +#define M_PI 0x1.921fb54442d18p+1 +#define M_PI_2 0x1.921fb54442d18p+0 +#define M_PI_4 0x1.921fb54442d18p-1 +#define M_1_PI 0x1.45f306dc9c883p-2 +#define M_2_PI 0x1.45f306dc9c883p-1 +#define M_2_SQRTPI 0x1.20dd750429b6dp+0 +#define M_SQRT2 0x1.6a09e667f3bcdp+0 +#define M_SQRT1_2 0x1.6a09e667f3bcdp-1 + +#ifdef cl_khr_fp16 + +#define HALF_DIG 3 +#define HALF_MANT_DIG 11 +#define HALF_MAX_10_EXP +4 +#define HALF_MAX_EXP +16 +#define HALF_MIN_10_EXP -4 +#define HALF_MIN_EXP -13 +#define HALF_RADIX 2 +#define HALF_MAX ((0x1.ffcp15h)) +#define HALF_MIN ((0x1.0p-14h)) +#define HALF_EPSILON ((0x1.0p-10h)) + +#define M_E_H 2.71828182845904523536028747135266250h +#define M_LOG2E_H 1.44269504088896340735992468100189214h +#define M_LOG10E_H 0.434294481903251827651128918916605082h +#define M_LN2_H 0.693147180559945309417232121458176568h +#define M_LN10_H 2.30258509299404568401799145468436421h +#define M_PI_H 3.14159265358979323846264338327950288h +#define M_PI_2_H 1.57079632679489661923132169163975144h +#define M_PI_4_H 0.785398163397448309615660845819875721h +#define M_1_PI_H 0.318309886183790671537767526745028724h +#define M_2_PI_H 0.636619772367581343075535053490057448h +#define M_2_SQRTPI_H 1.12837916709551257389615890312154517h +#define M_SQRT2_H 1.41421356237309504880168872420969808h +#define M_SQRT1_2_H 0.707106781186547524400844362104849039h + +#endif //cl_khr_fp16 + +#define CHAR_BIT 8 +#define SCHAR_MAX 127 +#define SCHAR_MIN (-128) +#define UCHAR_MAX 255 +#define CHAR_MAX SCHAR_MAX +#define CHAR_MIN SCHAR_MIN +#define USHRT_MAX 65535 +#define SHRT_MAX 32767 +#define SHRT_MIN (-32768) +#define UINT_MAX 0xffffffff +#define INT_MAX 2147483647 +#define INT_MIN (-2147483647-1) +#define ULONG_MAX 0xffffffffffffffffUL +#define LONG_MAX 0x7fffffffffffffffL +#define LONG_MIN (-0x7fffffffffffffffL-1) + +// OpenCL v1.1 s6.11.8, v1.2 s6.12.8, v2.0 s6.13.8 - Synchronization Functions + +// Flag type and values for barrier, mem_fence, read_mem_fence, write_mem_fence +typedef uint cl_mem_fence_flags; + +/** + * Queue a memory fence to ensure correct + * ordering of memory operations to local memory + */ +#define CLK_LOCAL_MEM_FENCE 0x01 + +/** + * Queue a memory fence to ensure correct + * ordering of memory operations to global memory + */ +#define CLK_GLOBAL_MEM_FENCE 0x02 + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +typedef enum memory_scope { + memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM, + memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP, + memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE, +#if defined(__opencl_c_atomic_scope_all_devices) + memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES, +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + memory_scope_all_devices = memory_scope_all_svm_devices, +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif // defined(__opencl_c_atomic_scope_all_devices) +/** + * Subgroups have different requirements on forward progress, so just test + * all the relevant macros. + * CL 3.0 sub-groups "they are not guaranteed to make independent forward progress" + * KHR subgroups "Subgroups within a workgroup are independent, make forward progress with respect to each other" + */ +#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups) + memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP +#endif +} memory_scope; + +/** + * Queue a memory fence to ensure correct ordering of memory + * operations between work-items of a work-group to + * image memory. + */ +#define CLK_IMAGE_MEM_FENCE 0x04 + +#ifndef ATOMIC_VAR_INIT +#define ATOMIC_VAR_INIT(x) (x) +#endif //ATOMIC_VAR_INIT +#define ATOMIC_FLAG_INIT 0 + +// enum values aligned with what clang uses in EmitAtomicExpr() +typedef enum memory_order +{ + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, +#if defined(__opencl_c_atomic_order_seq_cst) + memory_order_seq_cst = __ATOMIC_SEQ_CST +#endif +} memory_order; + +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions + +// These values need to match the runtime equivalent +// +// Addressing Mode. +// +#define CLK_ADDRESS_NONE 0 +#define CLK_ADDRESS_CLAMP_TO_EDGE 2 +#define CLK_ADDRESS_CLAMP 4 +#define CLK_ADDRESS_REPEAT 6 +#define CLK_ADDRESS_MIRRORED_REPEAT 8 + +// +// Coordination Normalization +// +#define CLK_NORMALIZED_COORDS_FALSE 0 +#define CLK_NORMALIZED_COORDS_TRUE 1 + +// +// Filtering Mode. +// +#define CLK_FILTER_NEAREST 0x10 +#define CLK_FILTER_LINEAR 0x20 + +#ifdef cl_khr_gl_msaa_sharing +#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable +#endif //cl_khr_gl_msaa_sharing + +// +// Channel Datatype. +// +#define CLK_SNORM_INT8 0x10D0 +#define CLK_SNORM_INT16 0x10D1 +#define CLK_UNORM_INT8 0x10D2 +#define CLK_UNORM_INT16 0x10D3 +#define CLK_UNORM_SHORT_565 0x10D4 +#define CLK_UNORM_SHORT_555 0x10D5 +#define CLK_UNORM_INT_101010 0x10D6 +#define CLK_SIGNED_INT8 0x10D7 +#define CLK_SIGNED_INT16 0x10D8 +#define CLK_SIGNED_INT32 0x10D9 +#define CLK_UNSIGNED_INT8 0x10DA +#define CLK_UNSIGNED_INT16 0x10DB +#define CLK_UNSIGNED_INT32 0x10DC +#define CLK_HALF_FLOAT 0x10DD +#define CLK_FLOAT 0x10DE +#define CLK_UNORM_INT24 0x10DF +#if __OPENCL_C_VERSION__ >= CL_VERSION_3_0 +#define CLK_UNORM_INT_101010_2 0x10E0 +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0 +#ifdef __opencl_c_ext_image_raw10_raw12 +#define CLK_UNSIGNED_INT_RAW10_EXT 0x10E3 +#define CLK_UNSIGNED_INT_RAW12_EXT 0x10E4 +#endif // __opencl_c_ext_image_raw10_raw12 +#ifdef __opencl_c_ext_image_unorm_int_2_101010 +#define CLK_UNORM_INT_2_101010_EXT 0x10E5 +#endif // __opencl_c_ext_image_unorm_int_2_101010 +#ifdef __opencl_c_ext_image_unsigned_10x6_12x4_14x2 +#define CLK_UNSIGNED_INT10X6_EXT 0x10E6 +#define CLK_UNSIGNED_INT12X4_EXT 0x10E7 +#define CLK_UNSIGNED_INT14X2_EXT 0x10E8 +#define CLK_UNORM_10X6_EXT 0x10E1 +#define CLK_UNORM_12X4_EXT 0x10E9 +#define CLK_UNORM_14X2_EXT 0x10EA +#endif // __opencl_c_ext_image_unsigned_10x6_12x4_14x2 + +// Channel order, numbering must be aligned with cl_channel_order in cl.h +// +#define CLK_R 0x10B0 +#define CLK_A 0x10B1 +#define CLK_RG 0x10B2 +#define CLK_RA 0x10B3 +#define CLK_RGB 0x10B4 +#define CLK_RGBA 0x10B5 +#define CLK_BGRA 0x10B6 +#define CLK_ARGB 0x10B7 +#define CLK_INTENSITY 0x10B8 +#define CLK_LUMINANCE 0x10B9 +#define CLK_Rx 0x10BA +#define CLK_RGx 0x10BB +#define CLK_RGBx 0x10BC +#define CLK_DEPTH 0x10BD +#define CLK_DEPTH_STENCIL 0x10BE +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 +#define CLK_sRGB 0x10BF +#define CLK_sRGBx 0x10C0 +#define CLK_sRGBA 0x10C1 +#define CLK_sBGRA 0x10C2 +#define CLK_ABGR 0x10C3 +#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 + +// OpenCL v2.0 s6.13.16 - Pipe Functions +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +#define CLK_NULL_RESERVE_ID (__builtin_astype(((void*)(__SIZE_MAX__)), reserve_id_t)) + +// OpenCL v2.0 s6.13.17 - Enqueue Kernels +#define CL_COMPLETE 0x0 +#define CL_RUNNING 0x1 +#define CL_SUBMITTED 0x2 +#define CL_QUEUED 0x3 + +#define CLK_SUCCESS 0 +#define CLK_ENQUEUE_FAILURE -101 +#define CLK_INVALID_QUEUE -102 +#define CLK_INVALID_NDRANGE -160 +#define CLK_INVALID_EVENT_WAIT_LIST -57 +#define CLK_DEVICE_QUEUE_FULL -161 +#define CLK_INVALID_ARG_SIZE -51 +#define CLK_EVENT_ALLOCATION_FAILURE -100 +#define CLK_OUT_OF_RESOURCES -5 + +#define CLK_NULL_QUEUE 0 +#define CLK_NULL_EVENT (__builtin_astype(((__SIZE_MAX__)), clk_event_t)) + +// execution model related definitions +#define CLK_ENQUEUE_FLAGS_NO_WAIT 0x0 +#define CLK_ENQUEUE_FLAGS_WAIT_KERNEL 0x1 +#define CLK_ENQUEUE_FLAGS_WAIT_WORK_GROUP 0x2 + +typedef int kernel_enqueue_flags_t; +typedef int clk_profiling_info; + +// Profiling info name (see capture_event_profiling_info) +#define CLK_PROFILING_COMMAND_EXEC_TIME 0x1 + +#define MAX_WORK_DIM 3 + +#ifdef __opencl_c_device_enqueue +typedef struct { + unsigned int workDimension; + size_t globalWorkOffset[MAX_WORK_DIM]; + size_t globalWorkSize[MAX_WORK_DIM]; + size_t localWorkSize[MAX_WORK_DIM]; +} ndrange_t; +#endif // __opencl_c_device_enqueue + +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +/** + * OpenCL v1.1/1.2/2.0 s6.2.4.2 - as_type operators + * Reinterprets a data type as another data type of the same size + */ +#define as_char(x) __builtin_astype((x), char) +#define as_char2(x) __builtin_astype((x), char2) +#define as_char3(x) __builtin_astype((x), char3) +#define as_char4(x) __builtin_astype((x), char4) +#define as_char8(x) __builtin_astype((x), char8) +#define as_char16(x) __builtin_astype((x), char16) + +#define as_uchar(x) __builtin_astype((x), uchar) +#define as_uchar2(x) __builtin_astype((x), uchar2) +#define as_uchar3(x) __builtin_astype((x), uchar3) +#define as_uchar4(x) __builtin_astype((x), uchar4) +#define as_uchar8(x) __builtin_astype((x), uchar8) +#define as_uchar16(x) __builtin_astype((x), uchar16) + +#define as_short(x) __builtin_astype((x), short) +#define as_short2(x) __builtin_astype((x), short2) +#define as_short3(x) __builtin_astype((x), short3) +#define as_short4(x) __builtin_astype((x), short4) +#define as_short8(x) __builtin_astype((x), short8) +#define as_short16(x) __builtin_astype((x), short16) + +#define as_ushort(x) __builtin_astype((x), ushort) +#define as_ushort2(x) __builtin_astype((x), ushort2) +#define as_ushort3(x) __builtin_astype((x), ushort3) +#define as_ushort4(x) __builtin_astype((x), ushort4) +#define as_ushort8(x) __builtin_astype((x), ushort8) +#define as_ushort16(x) __builtin_astype((x), ushort16) + +#define as_int(x) __builtin_astype((x), int) +#define as_int2(x) __builtin_astype((x), int2) +#define as_int3(x) __builtin_astype((x), int3) +#define as_int4(x) __builtin_astype((x), int4) +#define as_int8(x) __builtin_astype((x), int8) +#define as_int16(x) __builtin_astype((x), int16) + +#define as_uint(x) __builtin_astype((x), uint) +#define as_uint2(x) __builtin_astype((x), uint2) +#define as_uint3(x) __builtin_astype((x), uint3) +#define as_uint4(x) __builtin_astype((x), uint4) +#define as_uint8(x) __builtin_astype((x), uint8) +#define as_uint16(x) __builtin_astype((x), uint16) + +#define as_long(x) __builtin_astype((x), long) +#define as_long2(x) __builtin_astype((x), long2) +#define as_long3(x) __builtin_astype((x), long3) +#define as_long4(x) __builtin_astype((x), long4) +#define as_long8(x) __builtin_astype((x), long8) +#define as_long16(x) __builtin_astype((x), long16) + +#define as_ulong(x) __builtin_astype((x), ulong) +#define as_ulong2(x) __builtin_astype((x), ulong2) +#define as_ulong3(x) __builtin_astype((x), ulong3) +#define as_ulong4(x) __builtin_astype((x), ulong4) +#define as_ulong8(x) __builtin_astype((x), ulong8) +#define as_ulong16(x) __builtin_astype((x), ulong16) + +#define as_float(x) __builtin_astype((x), float) +#define as_float2(x) __builtin_astype((x), float2) +#define as_float3(x) __builtin_astype((x), float3) +#define as_float4(x) __builtin_astype((x), float4) +#define as_float8(x) __builtin_astype((x), float8) +#define as_float16(x) __builtin_astype((x), float16) + +#ifdef cl_khr_fp64 +#define as_double(x) __builtin_astype((x), double) +#define as_double2(x) __builtin_astype((x), double2) +#define as_double3(x) __builtin_astype((x), double3) +#define as_double4(x) __builtin_astype((x), double4) +#define as_double8(x) __builtin_astype((x), double8) +#define as_double16(x) __builtin_astype((x), double16) +#endif // cl_khr_fp64 + +#ifdef cl_khr_fp16 +#define as_half(x) __builtin_astype((x), half) +#define as_half2(x) __builtin_astype((x), half2) +#define as_half3(x) __builtin_astype((x), half3) +#define as_half4(x) __builtin_astype((x), half4) +#define as_half8(x) __builtin_astype((x), half8) +#define as_half16(x) __builtin_astype((x), half16) +#endif // cl_khr_fp16 + +#define as_size_t(x) __builtin_astype((x), size_t) +#define as_ptrdiff_t(x) __builtin_astype((x), ptrdiff_t) +#define as_intptr_t(x) __builtin_astype((x), intptr_t) +#define as_uintptr_t(x) __builtin_astype((x), uintptr_t) + +// C++ for OpenCL - __remove_address_space +#if defined(__OPENCL_CPP_VERSION__) +template struct __remove_address_space { using type = _Tp; }; +#if defined(__opencl_c_generic_address_space) +template struct __remove_address_space<__generic _Tp> { + using type = _Tp; +}; +#endif +template struct __remove_address_space<__global _Tp> { + using type = _Tp; +}; +template struct __remove_address_space<__private _Tp> { + using type = _Tp; +}; +template struct __remove_address_space<__local _Tp> { + using type = _Tp; +}; +template struct __remove_address_space<__constant _Tp> { + using type = _Tp; +}; +#endif + +// OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers + +#define __kernel_exec(X, typen) __kernel \ + __attribute__((work_group_size_hint(X, 1, 1))) \ + __attribute__((vec_type_hint(typen))) + +#define kernel_exec(X, typen) __kernel \ + __attribute__((work_group_size_hint(X, 1, 1))) \ + __attribute__((vec_type_hint(typen))) + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf + +#ifdef __OPENCL_CPP_VERSION__ +#define CLINKAGE extern "C" +#else +#define CLINKAGE +#endif + +CLINKAGE int printf(__constant const char *st, ...) + __attribute__((format(printf, 1, 2))); + +#undef CLINKAGE +#endif + +#ifdef cl_intel_device_side_avc_motion_estimation + +#define CLK_AVC_ME_MAJOR_16x16_INTEL 0x0 +#define CLK_AVC_ME_MAJOR_16x8_INTEL 0x1 +#define CLK_AVC_ME_MAJOR_8x16_INTEL 0x2 +#define CLK_AVC_ME_MAJOR_8x8_INTEL 0x3 + +#define CLK_AVC_ME_MINOR_8x8_INTEL 0x0 +#define CLK_AVC_ME_MINOR_8x4_INTEL 0x1 +#define CLK_AVC_ME_MINOR_4x8_INTEL 0x2 +#define CLK_AVC_ME_MINOR_4x4_INTEL 0x3 + +#define CLK_AVC_ME_MAJOR_FORWARD_INTEL 0x0 +#define CLK_AVC_ME_MAJOR_BACKWARD_INTEL 0x1 +#define CLK_AVC_ME_MAJOR_BIDIRECTIONAL_INTEL 0x2 + +#define CLK_AVC_ME_PARTITION_MASK_ALL_INTEL 0x0 +#define CLK_AVC_ME_PARTITION_MASK_16x16_INTEL 0x7E +#define CLK_AVC_ME_PARTITION_MASK_16x8_INTEL 0x7D +#define CLK_AVC_ME_PARTITION_MASK_8x16_INTEL 0x7B +#define CLK_AVC_ME_PARTITION_MASK_8x8_INTEL 0x77 +#define CLK_AVC_ME_PARTITION_MASK_8x4_INTEL 0x6F +#define CLK_AVC_ME_PARTITION_MASK_4x8_INTEL 0x5F +#define CLK_AVC_ME_PARTITION_MASK_4x4_INTEL 0x3F + +#define CLK_AVC_ME_SLICE_TYPE_PRED_INTEL 0x0 +#define CLK_AVC_ME_SLICE_TYPE_BPRED_INTEL 0x1 +#define CLK_AVC_ME_SLICE_TYPE_INTRA_INTEL 0x2 + +#define CLK_AVC_ME_SEARCH_WINDOW_EXHAUSTIVE_INTEL 0x0 +#define CLK_AVC_ME_SEARCH_WINDOW_SMALL_INTEL 0x1 +#define CLK_AVC_ME_SEARCH_WINDOW_TINY_INTEL 0x2 +#define CLK_AVC_ME_SEARCH_WINDOW_EXTRA_TINY_INTEL 0x3 +#define CLK_AVC_ME_SEARCH_WINDOW_DIAMOND_INTEL 0x4 +#define CLK_AVC_ME_SEARCH_WINDOW_LARGE_DIAMOND_INTEL 0x5 +#define CLK_AVC_ME_SEARCH_WINDOW_RESERVED0_INTEL 0x6 +#define CLK_AVC_ME_SEARCH_WINDOW_RESERVED1_INTEL 0x7 +#define CLK_AVC_ME_SEARCH_WINDOW_CUSTOM_INTEL 0x8 + +#define CLK_AVC_ME_SAD_ADJUST_MODE_NONE_INTEL 0x0 +#define CLK_AVC_ME_SAD_ADJUST_MODE_HAAR_INTEL 0x2 + +#define CLK_AVC_ME_SUBPIXEL_MODE_INTEGER_INTEL 0x0 +#define CLK_AVC_ME_SUBPIXEL_MODE_HPEL_INTEL 0x1 +#define CLK_AVC_ME_SUBPIXEL_MODE_QPEL_INTEL 0x3 + +#define CLK_AVC_ME_COST_PRECISION_QPEL_INTEL 0x0 +#define CLK_AVC_ME_COST_PRECISION_HPEL_INTEL 0x1 +#define CLK_AVC_ME_COST_PRECISION_PEL_INTEL 0x2 +#define CLK_AVC_ME_COST_PRECISION_DPEL_INTEL 0x3 + +#define CLK_AVC_ME_BIDIR_WEIGHT_QUARTER_INTEL 0x10 +#define CLK_AVC_ME_BIDIR_WEIGHT_THIRD_INTEL 0x15 +#define CLK_AVC_ME_BIDIR_WEIGHT_HALF_INTEL 0x20 +#define CLK_AVC_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL 0x2B +#define CLK_AVC_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL 0x30 + +#define CLK_AVC_ME_BORDER_REACHED_LEFT_INTEL 0x0 +#define CLK_AVC_ME_BORDER_REACHED_RIGHT_INTEL 0x2 +#define CLK_AVC_ME_BORDER_REACHED_TOP_INTEL 0x4 +#define CLK_AVC_ME_BORDER_REACHED_BOTTOM_INTEL 0x8 + +#define CLK_AVC_ME_INTRA_16x16_INTEL 0x0 +#define CLK_AVC_ME_INTRA_8x8_INTEL 0x1 +#define CLK_AVC_ME_INTRA_4x4_INTEL 0x2 + +#define CLK_AVC_ME_SKIP_BLOCK_PARTITION_16x16_INTEL 0x0 +#define CLK_AVC_ME_SKIP_BLOCK_PARTITION_8x8_INTEL 0x4000 + +#define CLK_AVC_ME_SKIP_BLOCK_16x16_FORWARD_ENABLE_INTEL (0x1 << 24) +#define CLK_AVC_ME_SKIP_BLOCK_16x16_BACKWARD_ENABLE_INTEL (0x2 << 24) +#define CLK_AVC_ME_SKIP_BLOCK_16x16_DUAL_ENABLE_INTEL (0x3 << 24) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_FORWARD_ENABLE_INTEL (0x55 << 24) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_BACKWARD_ENABLE_INTEL (0xAA << 24) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_DUAL_ENABLE_INTEL (0xFF << 24) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_0_FORWARD_ENABLE_INTEL (0x1 << 24) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_0_BACKWARD_ENABLE_INTEL (0x2 << 24) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_1_FORWARD_ENABLE_INTEL (0x1 << 26) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_1_BACKWARD_ENABLE_INTEL (0x2 << 26) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_2_FORWARD_ENABLE_INTEL (0x1 << 28) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_2_BACKWARD_ENABLE_INTEL (0x2 << 28) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_3_FORWARD_ENABLE_INTEL (0x1 << 30) +#define CLK_AVC_ME_SKIP_BLOCK_8x8_3_BACKWARD_ENABLE_INTEL (0x2 << 30) + +#define CLK_AVC_ME_BLOCK_BASED_SKIP_4x4_INTEL 0x00 +#define CLK_AVC_ME_BLOCK_BASED_SKIP_8x8_INTEL 0x80 + +#define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_ALL_INTEL 0x0 +#define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_16x16_INTEL 0x6 +#define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_8x8_INTEL 0x5 +#define CLK_AVC_ME_INTRA_LUMA_PARTITION_MASK_4x4_INTEL 0x3 + +#define CLK_AVC_ME_INTRA_NEIGHBOR_LEFT_MASK_ENABLE_INTEL 0x60 +#define CLK_AVC_ME_INTRA_NEIGHBOR_UPPER_MASK_ENABLE_INTEL 0x10 +#define CLK_AVC_ME_INTRA_NEIGHBOR_UPPER_RIGHT_MASK_ENABLE_INTEL 0x8 +#define CLK_AVC_ME_INTRA_NEIGHBOR_UPPER_LEFT_MASK_ENABLE_INTEL 0x4 + +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL 0x0 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_DC_INTEL 0x2 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL 0x3 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL 0x4 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL 0x4 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL 0x5 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL 0x6 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL 0x7 +#define CLK_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL 0x8 +#define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_DC_INTEL 0x0 +#define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 +#define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL 0x2 +#define CLK_AVC_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL 0x3 + +#define CLK_AVC_ME_FRAME_FORWARD_INTEL 0x1 +#define CLK_AVC_ME_FRAME_BACKWARD_INTEL 0x2 +#define CLK_AVC_ME_FRAME_DUAL_INTEL 0x3 + +#define CLK_AVC_ME_INTERLACED_SCAN_TOP_FIELD_INTEL 0x0 +#define CLK_AVC_ME_INTERLACED_SCAN_BOTTOM_FIELD_INTEL 0x1 + +#define CLK_AVC_ME_INITIALIZE_INTEL 0x0 + +#define CLK_AVC_IME_PAYLOAD_INITIALIZE_INTEL 0x0 +#define CLK_AVC_REF_PAYLOAD_INITIALIZE_INTEL 0x0 +#define CLK_AVC_SIC_PAYLOAD_INITIALIZE_INTEL 0x0 + +#define CLK_AVC_IME_RESULT_INITIALIZE_INTEL 0x0 +#define CLK_AVC_REF_RESULT_INITIALIZE_INTEL 0x0 +#define CLK_AVC_SIC_RESULT_INITIALIZE_INTEL 0x0 + +#define CLK_AVC_IME_RESULT_SINGLE_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0 +#define CLK_AVC_IME_RESULT_SINGLE_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0 +#define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMOUT_INITIALIZE_INTEL 0x0 +#define CLK_AVC_IME_RESULT_DUAL_REFERENCE_STREAMIN_INITIALIZE_INTEL 0x0 + +#endif // cl_intel_device_side_avc_motion_estimation + +// Disable any extensions we may have enabled previously. +#pragma OPENCL EXTENSION all : disable + +#endif //_OPENCL_BASE_H_ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/opencl-c.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/opencl-c.h new file mode 100755 index 0000000..e1e0fde --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/opencl-c.h @@ -0,0 +1,18630 @@ +//===--- opencl-c.h - OpenCL C language builtin function header -----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _OPENCL_H_ +#define _OPENCL_H_ + +#include "opencl-c-base.h" + +#if defined(__opencl_c_images) +#ifndef cl_khr_depth_images +#define cl_khr_depth_images +#endif //cl_khr_depth_images +#endif //defined(__opencl_c_images) + +#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 +#ifdef cl_khr_3d_image_writes +#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable +#endif //cl_khr_3d_image_writes +#endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0 + +#if (defined(__OPENCL_CPP_VERSION__) || \ + (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)) && \ + (defined(__SPIR__) || defined(__SPIRV__)) +#pragma OPENCL EXTENSION cl_intel_planar_yuv : begin +#pragma OPENCL EXTENSION cl_intel_planar_yuv : end +#endif // (defined(__OPENCL_CPP_VERSION__) || + // (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)) && + // (defined(__SPIR__) || defined(__SPIRV__)) + +#define __ovld __attribute__((overloadable)) +#define __conv __attribute__((convergent)) + +// Optimizations +#define __purefn __attribute__((pure)) +#define __cnfn __attribute__((const)) + + +// OpenCL v1.1/1.2/2.0 s6.2.3 - Explicit conversions + +char __ovld __cnfn convert_char_rte(char); +char __ovld __cnfn convert_char_sat_rte(char); +char __ovld __cnfn convert_char_rtz(char); +char __ovld __cnfn convert_char_sat_rtz(char); +char __ovld __cnfn convert_char_rtp(char); +char __ovld __cnfn convert_char_sat_rtp(char); +char __ovld __cnfn convert_char_rtn(char); +char __ovld __cnfn convert_char_sat_rtn(char); +char __ovld __cnfn convert_char(char); +char __ovld __cnfn convert_char_sat(char); +char __ovld __cnfn convert_char_rte(uchar); +char __ovld __cnfn convert_char_sat_rte(uchar); +char __ovld __cnfn convert_char_rtz(uchar); +char __ovld __cnfn convert_char_sat_rtz(uchar); +char __ovld __cnfn convert_char_rtp(uchar); +char __ovld __cnfn convert_char_sat_rtp(uchar); +char __ovld __cnfn convert_char_rtn(uchar); +char __ovld __cnfn convert_char_sat_rtn(uchar); +char __ovld __cnfn convert_char(uchar); +char __ovld __cnfn convert_char_sat(uchar); +char __ovld __cnfn convert_char_rte(short); +char __ovld __cnfn convert_char_sat_rte(short); +char __ovld __cnfn convert_char_rtz(short); +char __ovld __cnfn convert_char_sat_rtz(short); +char __ovld __cnfn convert_char_rtp(short); +char __ovld __cnfn convert_char_sat_rtp(short); +char __ovld __cnfn convert_char_rtn(short); +char __ovld __cnfn convert_char_sat_rtn(short); +char __ovld __cnfn convert_char(short); +char __ovld __cnfn convert_char_sat(short); +char __ovld __cnfn convert_char_rte(ushort); +char __ovld __cnfn convert_char_sat_rte(ushort); +char __ovld __cnfn convert_char_rtz(ushort); +char __ovld __cnfn convert_char_sat_rtz(ushort); +char __ovld __cnfn convert_char_rtp(ushort); +char __ovld __cnfn convert_char_sat_rtp(ushort); +char __ovld __cnfn convert_char_rtn(ushort); +char __ovld __cnfn convert_char_sat_rtn(ushort); +char __ovld __cnfn convert_char(ushort); +char __ovld __cnfn convert_char_sat(ushort); +char __ovld __cnfn convert_char_rte(int); +char __ovld __cnfn convert_char_sat_rte(int); +char __ovld __cnfn convert_char_rtz(int); +char __ovld __cnfn convert_char_sat_rtz(int); +char __ovld __cnfn convert_char_rtp(int); +char __ovld __cnfn convert_char_sat_rtp(int); +char __ovld __cnfn convert_char_rtn(int); +char __ovld __cnfn convert_char_sat_rtn(int); +char __ovld __cnfn convert_char(int); +char __ovld __cnfn convert_char_sat(int); +char __ovld __cnfn convert_char_rte(uint); +char __ovld __cnfn convert_char_sat_rte(uint); +char __ovld __cnfn convert_char_rtz(uint); +char __ovld __cnfn convert_char_sat_rtz(uint); +char __ovld __cnfn convert_char_rtp(uint); +char __ovld __cnfn convert_char_sat_rtp(uint); +char __ovld __cnfn convert_char_rtn(uint); +char __ovld __cnfn convert_char_sat_rtn(uint); +char __ovld __cnfn convert_char(uint); +char __ovld __cnfn convert_char_sat(uint); +char __ovld __cnfn convert_char_rte(long); +char __ovld __cnfn convert_char_sat_rte(long); +char __ovld __cnfn convert_char_rtz(long); +char __ovld __cnfn convert_char_sat_rtz(long); +char __ovld __cnfn convert_char_rtp(long); +char __ovld __cnfn convert_char_sat_rtp(long); +char __ovld __cnfn convert_char_rtn(long); +char __ovld __cnfn convert_char_sat_rtn(long); +char __ovld __cnfn convert_char(long); +char __ovld __cnfn convert_char_sat(long); +char __ovld __cnfn convert_char_rte(ulong); +char __ovld __cnfn convert_char_sat_rte(ulong); +char __ovld __cnfn convert_char_rtz(ulong); +char __ovld __cnfn convert_char_sat_rtz(ulong); +char __ovld __cnfn convert_char_rtp(ulong); +char __ovld __cnfn convert_char_sat_rtp(ulong); +char __ovld __cnfn convert_char_rtn(ulong); +char __ovld __cnfn convert_char_sat_rtn(ulong); +char __ovld __cnfn convert_char(ulong); +char __ovld __cnfn convert_char_sat(ulong); +char __ovld __cnfn convert_char_rte(float); +char __ovld __cnfn convert_char_sat_rte(float); +char __ovld __cnfn convert_char_rtz(float); +char __ovld __cnfn convert_char_sat_rtz(float); +char __ovld __cnfn convert_char_rtp(float); +char __ovld __cnfn convert_char_sat_rtp(float); +char __ovld __cnfn convert_char_rtn(float); +char __ovld __cnfn convert_char_sat_rtn(float); +char __ovld __cnfn convert_char(float); +char __ovld __cnfn convert_char_sat(float); +uchar __ovld __cnfn convert_uchar_rte(char); +uchar __ovld __cnfn convert_uchar_sat_rte(char); +uchar __ovld __cnfn convert_uchar_rtz(char); +uchar __ovld __cnfn convert_uchar_sat_rtz(char); +uchar __ovld __cnfn convert_uchar_rtp(char); +uchar __ovld __cnfn convert_uchar_sat_rtp(char); +uchar __ovld __cnfn convert_uchar_rtn(char); +uchar __ovld __cnfn convert_uchar_sat_rtn(char); +uchar __ovld __cnfn convert_uchar(char); +uchar __ovld __cnfn convert_uchar_sat(char); +uchar __ovld __cnfn convert_uchar_rte(uchar); +uchar __ovld __cnfn convert_uchar_sat_rte(uchar); +uchar __ovld __cnfn convert_uchar_rtz(uchar); +uchar __ovld __cnfn convert_uchar_sat_rtz(uchar); +uchar __ovld __cnfn convert_uchar_rtp(uchar); +uchar __ovld __cnfn convert_uchar_sat_rtp(uchar); +uchar __ovld __cnfn convert_uchar_rtn(uchar); +uchar __ovld __cnfn convert_uchar_sat_rtn(uchar); +uchar __ovld __cnfn convert_uchar(uchar); +uchar __ovld __cnfn convert_uchar_sat(uchar); +uchar __ovld __cnfn convert_uchar_rte(short); +uchar __ovld __cnfn convert_uchar_sat_rte(short); +uchar __ovld __cnfn convert_uchar_rtz(short); +uchar __ovld __cnfn convert_uchar_sat_rtz(short); +uchar __ovld __cnfn convert_uchar_rtp(short); +uchar __ovld __cnfn convert_uchar_sat_rtp(short); +uchar __ovld __cnfn convert_uchar_rtn(short); +uchar __ovld __cnfn convert_uchar_sat_rtn(short); +uchar __ovld __cnfn convert_uchar(short); +uchar __ovld __cnfn convert_uchar_sat(short); +uchar __ovld __cnfn convert_uchar_rte(ushort); +uchar __ovld __cnfn convert_uchar_sat_rte(ushort); +uchar __ovld __cnfn convert_uchar_rtz(ushort); +uchar __ovld __cnfn convert_uchar_sat_rtz(ushort); +uchar __ovld __cnfn convert_uchar_rtp(ushort); +uchar __ovld __cnfn convert_uchar_sat_rtp(ushort); +uchar __ovld __cnfn convert_uchar_rtn(ushort); +uchar __ovld __cnfn convert_uchar_sat_rtn(ushort); +uchar __ovld __cnfn convert_uchar(ushort); +uchar __ovld __cnfn convert_uchar_sat(ushort); +uchar __ovld __cnfn convert_uchar_rte(int); +uchar __ovld __cnfn convert_uchar_sat_rte(int); +uchar __ovld __cnfn convert_uchar_rtz(int); +uchar __ovld __cnfn convert_uchar_sat_rtz(int); +uchar __ovld __cnfn convert_uchar_rtp(int); +uchar __ovld __cnfn convert_uchar_sat_rtp(int); +uchar __ovld __cnfn convert_uchar_rtn(int); +uchar __ovld __cnfn convert_uchar_sat_rtn(int); +uchar __ovld __cnfn convert_uchar(int); +uchar __ovld __cnfn convert_uchar_sat(int); +uchar __ovld __cnfn convert_uchar_rte(uint); +uchar __ovld __cnfn convert_uchar_sat_rte(uint); +uchar __ovld __cnfn convert_uchar_rtz(uint); +uchar __ovld __cnfn convert_uchar_sat_rtz(uint); +uchar __ovld __cnfn convert_uchar_rtp(uint); +uchar __ovld __cnfn convert_uchar_sat_rtp(uint); +uchar __ovld __cnfn convert_uchar_rtn(uint); +uchar __ovld __cnfn convert_uchar_sat_rtn(uint); +uchar __ovld __cnfn convert_uchar(uint); +uchar __ovld __cnfn convert_uchar_sat(uint); +uchar __ovld __cnfn convert_uchar_rte(long); +uchar __ovld __cnfn convert_uchar_sat_rte(long); +uchar __ovld __cnfn convert_uchar_rtz(long); +uchar __ovld __cnfn convert_uchar_sat_rtz(long); +uchar __ovld __cnfn convert_uchar_rtp(long); +uchar __ovld __cnfn convert_uchar_sat_rtp(long); +uchar __ovld __cnfn convert_uchar_rtn(long); +uchar __ovld __cnfn convert_uchar_sat_rtn(long); +uchar __ovld __cnfn convert_uchar(long); +uchar __ovld __cnfn convert_uchar_sat(long); +uchar __ovld __cnfn convert_uchar_rte(ulong); +uchar __ovld __cnfn convert_uchar_sat_rte(ulong); +uchar __ovld __cnfn convert_uchar_rtz(ulong); +uchar __ovld __cnfn convert_uchar_sat_rtz(ulong); +uchar __ovld __cnfn convert_uchar_rtp(ulong); +uchar __ovld __cnfn convert_uchar_sat_rtp(ulong); +uchar __ovld __cnfn convert_uchar_rtn(ulong); +uchar __ovld __cnfn convert_uchar_sat_rtn(ulong); +uchar __ovld __cnfn convert_uchar(ulong); +uchar __ovld __cnfn convert_uchar_sat(ulong); +uchar __ovld __cnfn convert_uchar_rte(float); +uchar __ovld __cnfn convert_uchar_sat_rte(float); +uchar __ovld __cnfn convert_uchar_rtz(float); +uchar __ovld __cnfn convert_uchar_sat_rtz(float); +uchar __ovld __cnfn convert_uchar_rtp(float); +uchar __ovld __cnfn convert_uchar_sat_rtp(float); +uchar __ovld __cnfn convert_uchar_rtn(float); +uchar __ovld __cnfn convert_uchar_sat_rtn(float); +uchar __ovld __cnfn convert_uchar(float); +uchar __ovld __cnfn convert_uchar_sat(float); + +short __ovld __cnfn convert_short_rte(char); +short __ovld __cnfn convert_short_sat_rte(char); +short __ovld __cnfn convert_short_rtz(char); +short __ovld __cnfn convert_short_sat_rtz(char); +short __ovld __cnfn convert_short_rtp(char); +short __ovld __cnfn convert_short_sat_rtp(char); +short __ovld __cnfn convert_short_rtn(char); +short __ovld __cnfn convert_short_sat_rtn(char); +short __ovld __cnfn convert_short(char); +short __ovld __cnfn convert_short_sat(char); +short __ovld __cnfn convert_short_rte(uchar); +short __ovld __cnfn convert_short_sat_rte(uchar); +short __ovld __cnfn convert_short_rtz(uchar); +short __ovld __cnfn convert_short_sat_rtz(uchar); +short __ovld __cnfn convert_short_rtp(uchar); +short __ovld __cnfn convert_short_sat_rtp(uchar); +short __ovld __cnfn convert_short_rtn(uchar); +short __ovld __cnfn convert_short_sat_rtn(uchar); +short __ovld __cnfn convert_short(uchar); +short __ovld __cnfn convert_short_sat(uchar); +short __ovld __cnfn convert_short_rte(short); +short __ovld __cnfn convert_short_sat_rte(short); +short __ovld __cnfn convert_short_rtz(short); +short __ovld __cnfn convert_short_sat_rtz(short); +short __ovld __cnfn convert_short_rtp(short); +short __ovld __cnfn convert_short_sat_rtp(short); +short __ovld __cnfn convert_short_rtn(short); +short __ovld __cnfn convert_short_sat_rtn(short); +short __ovld __cnfn convert_short(short); +short __ovld __cnfn convert_short_sat(short); +short __ovld __cnfn convert_short_rte(ushort); +short __ovld __cnfn convert_short_sat_rte(ushort); +short __ovld __cnfn convert_short_rtz(ushort); +short __ovld __cnfn convert_short_sat_rtz(ushort); +short __ovld __cnfn convert_short_rtp(ushort); +short __ovld __cnfn convert_short_sat_rtp(ushort); +short __ovld __cnfn convert_short_rtn(ushort); +short __ovld __cnfn convert_short_sat_rtn(ushort); +short __ovld __cnfn convert_short(ushort); +short __ovld __cnfn convert_short_sat(ushort); +short __ovld __cnfn convert_short_rte(int); +short __ovld __cnfn convert_short_sat_rte(int); +short __ovld __cnfn convert_short_rtz(int); +short __ovld __cnfn convert_short_sat_rtz(int); +short __ovld __cnfn convert_short_rtp(int); +short __ovld __cnfn convert_short_sat_rtp(int); +short __ovld __cnfn convert_short_rtn(int); +short __ovld __cnfn convert_short_sat_rtn(int); +short __ovld __cnfn convert_short(int); +short __ovld __cnfn convert_short_sat(int); +short __ovld __cnfn convert_short_rte(uint); +short __ovld __cnfn convert_short_sat_rte(uint); +short __ovld __cnfn convert_short_rtz(uint); +short __ovld __cnfn convert_short_sat_rtz(uint); +short __ovld __cnfn convert_short_rtp(uint); +short __ovld __cnfn convert_short_sat_rtp(uint); +short __ovld __cnfn convert_short_rtn(uint); +short __ovld __cnfn convert_short_sat_rtn(uint); +short __ovld __cnfn convert_short(uint); +short __ovld __cnfn convert_short_sat(uint); +short __ovld __cnfn convert_short_rte(long); +short __ovld __cnfn convert_short_sat_rte(long); +short __ovld __cnfn convert_short_rtz(long); +short __ovld __cnfn convert_short_sat_rtz(long); +short __ovld __cnfn convert_short_rtp(long); +short __ovld __cnfn convert_short_sat_rtp(long); +short __ovld __cnfn convert_short_rtn(long); +short __ovld __cnfn convert_short_sat_rtn(long); +short __ovld __cnfn convert_short(long); +short __ovld __cnfn convert_short_sat(long); +short __ovld __cnfn convert_short_rte(ulong); +short __ovld __cnfn convert_short_sat_rte(ulong); +short __ovld __cnfn convert_short_rtz(ulong); +short __ovld __cnfn convert_short_sat_rtz(ulong); +short __ovld __cnfn convert_short_rtp(ulong); +short __ovld __cnfn convert_short_sat_rtp(ulong); +short __ovld __cnfn convert_short_rtn(ulong); +short __ovld __cnfn convert_short_sat_rtn(ulong); +short __ovld __cnfn convert_short(ulong); +short __ovld __cnfn convert_short_sat(ulong); +short __ovld __cnfn convert_short_rte(float); +short __ovld __cnfn convert_short_sat_rte(float); +short __ovld __cnfn convert_short_rtz(float); +short __ovld __cnfn convert_short_sat_rtz(float); +short __ovld __cnfn convert_short_rtp(float); +short __ovld __cnfn convert_short_sat_rtp(float); +short __ovld __cnfn convert_short_rtn(float); +short __ovld __cnfn convert_short_sat_rtn(float); +short __ovld __cnfn convert_short(float); +short __ovld __cnfn convert_short_sat(float); +ushort __ovld __cnfn convert_ushort_rte(char); +ushort __ovld __cnfn convert_ushort_sat_rte(char); +ushort __ovld __cnfn convert_ushort_rtz(char); +ushort __ovld __cnfn convert_ushort_sat_rtz(char); +ushort __ovld __cnfn convert_ushort_rtp(char); +ushort __ovld __cnfn convert_ushort_sat_rtp(char); +ushort __ovld __cnfn convert_ushort_rtn(char); +ushort __ovld __cnfn convert_ushort_sat_rtn(char); +ushort __ovld __cnfn convert_ushort(char); +ushort __ovld __cnfn convert_ushort_sat(char); +ushort __ovld __cnfn convert_ushort_rte(uchar); +ushort __ovld __cnfn convert_ushort_sat_rte(uchar); +ushort __ovld __cnfn convert_ushort_rtz(uchar); +ushort __ovld __cnfn convert_ushort_sat_rtz(uchar); +ushort __ovld __cnfn convert_ushort_rtp(uchar); +ushort __ovld __cnfn convert_ushort_sat_rtp(uchar); +ushort __ovld __cnfn convert_ushort_rtn(uchar); +ushort __ovld __cnfn convert_ushort_sat_rtn(uchar); +ushort __ovld __cnfn convert_ushort(uchar); +ushort __ovld __cnfn convert_ushort_sat(uchar); +ushort __ovld __cnfn convert_ushort_rte(short); +ushort __ovld __cnfn convert_ushort_sat_rte(short); +ushort __ovld __cnfn convert_ushort_rtz(short); +ushort __ovld __cnfn convert_ushort_sat_rtz(short); +ushort __ovld __cnfn convert_ushort_rtp(short); +ushort __ovld __cnfn convert_ushort_sat_rtp(short); +ushort __ovld __cnfn convert_ushort_rtn(short); +ushort __ovld __cnfn convert_ushort_sat_rtn(short); +ushort __ovld __cnfn convert_ushort(short); +ushort __ovld __cnfn convert_ushort_sat(short); +ushort __ovld __cnfn convert_ushort_rte(ushort); +ushort __ovld __cnfn convert_ushort_sat_rte(ushort); +ushort __ovld __cnfn convert_ushort_rtz(ushort); +ushort __ovld __cnfn convert_ushort_sat_rtz(ushort); +ushort __ovld __cnfn convert_ushort_rtp(ushort); +ushort __ovld __cnfn convert_ushort_sat_rtp(ushort); +ushort __ovld __cnfn convert_ushort_rtn(ushort); +ushort __ovld __cnfn convert_ushort_sat_rtn(ushort); +ushort __ovld __cnfn convert_ushort(ushort); +ushort __ovld __cnfn convert_ushort_sat(ushort); +ushort __ovld __cnfn convert_ushort_rte(int); +ushort __ovld __cnfn convert_ushort_sat_rte(int); +ushort __ovld __cnfn convert_ushort_rtz(int); +ushort __ovld __cnfn convert_ushort_sat_rtz(int); +ushort __ovld __cnfn convert_ushort_rtp(int); +ushort __ovld __cnfn convert_ushort_sat_rtp(int); +ushort __ovld __cnfn convert_ushort_rtn(int); +ushort __ovld __cnfn convert_ushort_sat_rtn(int); +ushort __ovld __cnfn convert_ushort(int); +ushort __ovld __cnfn convert_ushort_sat(int); +ushort __ovld __cnfn convert_ushort_rte(uint); +ushort __ovld __cnfn convert_ushort_sat_rte(uint); +ushort __ovld __cnfn convert_ushort_rtz(uint); +ushort __ovld __cnfn convert_ushort_sat_rtz(uint); +ushort __ovld __cnfn convert_ushort_rtp(uint); +ushort __ovld __cnfn convert_ushort_sat_rtp(uint); +ushort __ovld __cnfn convert_ushort_rtn(uint); +ushort __ovld __cnfn convert_ushort_sat_rtn(uint); +ushort __ovld __cnfn convert_ushort(uint); +ushort __ovld __cnfn convert_ushort_sat(uint); +ushort __ovld __cnfn convert_ushort_rte(long); +ushort __ovld __cnfn convert_ushort_sat_rte(long); +ushort __ovld __cnfn convert_ushort_rtz(long); +ushort __ovld __cnfn convert_ushort_sat_rtz(long); +ushort __ovld __cnfn convert_ushort_rtp(long); +ushort __ovld __cnfn convert_ushort_sat_rtp(long); +ushort __ovld __cnfn convert_ushort_rtn(long); +ushort __ovld __cnfn convert_ushort_sat_rtn(long); +ushort __ovld __cnfn convert_ushort(long); +ushort __ovld __cnfn convert_ushort_sat(long); +ushort __ovld __cnfn convert_ushort_rte(ulong); +ushort __ovld __cnfn convert_ushort_sat_rte(ulong); +ushort __ovld __cnfn convert_ushort_rtz(ulong); +ushort __ovld __cnfn convert_ushort_sat_rtz(ulong); +ushort __ovld __cnfn convert_ushort_rtp(ulong); +ushort __ovld __cnfn convert_ushort_sat_rtp(ulong); +ushort __ovld __cnfn convert_ushort_rtn(ulong); +ushort __ovld __cnfn convert_ushort_sat_rtn(ulong); +ushort __ovld __cnfn convert_ushort(ulong); +ushort __ovld __cnfn convert_ushort_sat(ulong); +ushort __ovld __cnfn convert_ushort_rte(float); +ushort __ovld __cnfn convert_ushort_sat_rte(float); +ushort __ovld __cnfn convert_ushort_rtz(float); +ushort __ovld __cnfn convert_ushort_sat_rtz(float); +ushort __ovld __cnfn convert_ushort_rtp(float); +ushort __ovld __cnfn convert_ushort_sat_rtp(float); +ushort __ovld __cnfn convert_ushort_rtn(float); +ushort __ovld __cnfn convert_ushort_sat_rtn(float); +ushort __ovld __cnfn convert_ushort(float); +ushort __ovld __cnfn convert_ushort_sat(float); +int __ovld __cnfn convert_int_rte(char); +int __ovld __cnfn convert_int_sat_rte(char); +int __ovld __cnfn convert_int_rtz(char); +int __ovld __cnfn convert_int_sat_rtz(char); +int __ovld __cnfn convert_int_rtp(char); +int __ovld __cnfn convert_int_sat_rtp(char); +int __ovld __cnfn convert_int_rtn(char); +int __ovld __cnfn convert_int_sat_rtn(char); +int __ovld __cnfn convert_int(char); +int __ovld __cnfn convert_int_sat(char); +int __ovld __cnfn convert_int_rte(uchar); +int __ovld __cnfn convert_int_sat_rte(uchar); +int __ovld __cnfn convert_int_rtz(uchar); +int __ovld __cnfn convert_int_sat_rtz(uchar); +int __ovld __cnfn convert_int_rtp(uchar); +int __ovld __cnfn convert_int_sat_rtp(uchar); +int __ovld __cnfn convert_int_rtn(uchar); +int __ovld __cnfn convert_int_sat_rtn(uchar); +int __ovld __cnfn convert_int(uchar); +int __ovld __cnfn convert_int_sat(uchar); +int __ovld __cnfn convert_int_rte(short); +int __ovld __cnfn convert_int_sat_rte(short); +int __ovld __cnfn convert_int_rtz(short); +int __ovld __cnfn convert_int_sat_rtz(short); +int __ovld __cnfn convert_int_rtp(short); +int __ovld __cnfn convert_int_sat_rtp(short); +int __ovld __cnfn convert_int_rtn(short); +int __ovld __cnfn convert_int_sat_rtn(short); +int __ovld __cnfn convert_int(short); +int __ovld __cnfn convert_int_sat(short); +int __ovld __cnfn convert_int_rte(ushort); +int __ovld __cnfn convert_int_sat_rte(ushort); +int __ovld __cnfn convert_int_rtz(ushort); +int __ovld __cnfn convert_int_sat_rtz(ushort); +int __ovld __cnfn convert_int_rtp(ushort); +int __ovld __cnfn convert_int_sat_rtp(ushort); +int __ovld __cnfn convert_int_rtn(ushort); +int __ovld __cnfn convert_int_sat_rtn(ushort); +int __ovld __cnfn convert_int(ushort); +int __ovld __cnfn convert_int_sat(ushort); +int __ovld __cnfn convert_int_rte(int); +int __ovld __cnfn convert_int_sat_rte(int); +int __ovld __cnfn convert_int_rtz(int); +int __ovld __cnfn convert_int_sat_rtz(int); +int __ovld __cnfn convert_int_rtp(int); +int __ovld __cnfn convert_int_sat_rtp(int); +int __ovld __cnfn convert_int_rtn(int); +int __ovld __cnfn convert_int_sat_rtn(int); +int __ovld __cnfn convert_int(int); +int __ovld __cnfn convert_int_sat(int); +int __ovld __cnfn convert_int_rte(uint); +int __ovld __cnfn convert_int_sat_rte(uint); +int __ovld __cnfn convert_int_rtz(uint); +int __ovld __cnfn convert_int_sat_rtz(uint); +int __ovld __cnfn convert_int_rtp(uint); +int __ovld __cnfn convert_int_sat_rtp(uint); +int __ovld __cnfn convert_int_rtn(uint); +int __ovld __cnfn convert_int_sat_rtn(uint); +int __ovld __cnfn convert_int(uint); +int __ovld __cnfn convert_int_sat(uint); +int __ovld __cnfn convert_int_rte(long); +int __ovld __cnfn convert_int_sat_rte(long); +int __ovld __cnfn convert_int_rtz(long); +int __ovld __cnfn convert_int_sat_rtz(long); +int __ovld __cnfn convert_int_rtp(long); +int __ovld __cnfn convert_int_sat_rtp(long); +int __ovld __cnfn convert_int_rtn(long); +int __ovld __cnfn convert_int_sat_rtn(long); +int __ovld __cnfn convert_int(long); +int __ovld __cnfn convert_int_sat(long); +int __ovld __cnfn convert_int_rte(ulong); +int __ovld __cnfn convert_int_sat_rte(ulong); +int __ovld __cnfn convert_int_rtz(ulong); +int __ovld __cnfn convert_int_sat_rtz(ulong); +int __ovld __cnfn convert_int_rtp(ulong); +int __ovld __cnfn convert_int_sat_rtp(ulong); +int __ovld __cnfn convert_int_rtn(ulong); +int __ovld __cnfn convert_int_sat_rtn(ulong); +int __ovld __cnfn convert_int(ulong); +int __ovld __cnfn convert_int_sat(ulong); +int __ovld __cnfn convert_int_rte(float); +int __ovld __cnfn convert_int_sat_rte(float); +int __ovld __cnfn convert_int_rtz(float); +int __ovld __cnfn convert_int_sat_rtz(float); +int __ovld __cnfn convert_int_rtp(float); +int __ovld __cnfn convert_int_sat_rtp(float); +int __ovld __cnfn convert_int_rtn(float); +int __ovld __cnfn convert_int_sat_rtn(float); +int __ovld __cnfn convert_int(float); +int __ovld __cnfn convert_int_sat(float); +uint __ovld __cnfn convert_uint_rte(char); +uint __ovld __cnfn convert_uint_sat_rte(char); +uint __ovld __cnfn convert_uint_rtz(char); +uint __ovld __cnfn convert_uint_sat_rtz(char); +uint __ovld __cnfn convert_uint_rtp(char); +uint __ovld __cnfn convert_uint_sat_rtp(char); +uint __ovld __cnfn convert_uint_rtn(char); +uint __ovld __cnfn convert_uint_sat_rtn(char); +uint __ovld __cnfn convert_uint(char); +uint __ovld __cnfn convert_uint_sat(char); +uint __ovld __cnfn convert_uint_rte(uchar); +uint __ovld __cnfn convert_uint_sat_rte(uchar); +uint __ovld __cnfn convert_uint_rtz(uchar); +uint __ovld __cnfn convert_uint_sat_rtz(uchar); +uint __ovld __cnfn convert_uint_rtp(uchar); +uint __ovld __cnfn convert_uint_sat_rtp(uchar); +uint __ovld __cnfn convert_uint_rtn(uchar); +uint __ovld __cnfn convert_uint_sat_rtn(uchar); +uint __ovld __cnfn convert_uint(uchar); +uint __ovld __cnfn convert_uint_sat(uchar); +uint __ovld __cnfn convert_uint_rte(short); +uint __ovld __cnfn convert_uint_sat_rte(short); +uint __ovld __cnfn convert_uint_rtz(short); +uint __ovld __cnfn convert_uint_sat_rtz(short); +uint __ovld __cnfn convert_uint_rtp(short); +uint __ovld __cnfn convert_uint_sat_rtp(short); +uint __ovld __cnfn convert_uint_rtn(short); +uint __ovld __cnfn convert_uint_sat_rtn(short); +uint __ovld __cnfn convert_uint(short); +uint __ovld __cnfn convert_uint_sat(short); +uint __ovld __cnfn convert_uint_rte(ushort); +uint __ovld __cnfn convert_uint_sat_rte(ushort); +uint __ovld __cnfn convert_uint_rtz(ushort); +uint __ovld __cnfn convert_uint_sat_rtz(ushort); +uint __ovld __cnfn convert_uint_rtp(ushort); +uint __ovld __cnfn convert_uint_sat_rtp(ushort); +uint __ovld __cnfn convert_uint_rtn(ushort); +uint __ovld __cnfn convert_uint_sat_rtn(ushort); +uint __ovld __cnfn convert_uint(ushort); +uint __ovld __cnfn convert_uint_sat(ushort); +uint __ovld __cnfn convert_uint_rte(int); +uint __ovld __cnfn convert_uint_sat_rte(int); +uint __ovld __cnfn convert_uint_rtz(int); +uint __ovld __cnfn convert_uint_sat_rtz(int); +uint __ovld __cnfn convert_uint_rtp(int); +uint __ovld __cnfn convert_uint_sat_rtp(int); +uint __ovld __cnfn convert_uint_rtn(int); +uint __ovld __cnfn convert_uint_sat_rtn(int); +uint __ovld __cnfn convert_uint(int); +uint __ovld __cnfn convert_uint_sat(int); +uint __ovld __cnfn convert_uint_rte(uint); +uint __ovld __cnfn convert_uint_sat_rte(uint); +uint __ovld __cnfn convert_uint_rtz(uint); +uint __ovld __cnfn convert_uint_sat_rtz(uint); +uint __ovld __cnfn convert_uint_rtp(uint); +uint __ovld __cnfn convert_uint_sat_rtp(uint); +uint __ovld __cnfn convert_uint_rtn(uint); +uint __ovld __cnfn convert_uint_sat_rtn(uint); +uint __ovld __cnfn convert_uint(uint); +uint __ovld __cnfn convert_uint_sat(uint); +uint __ovld __cnfn convert_uint_rte(long); +uint __ovld __cnfn convert_uint_sat_rte(long); +uint __ovld __cnfn convert_uint_rtz(long); +uint __ovld __cnfn convert_uint_sat_rtz(long); +uint __ovld __cnfn convert_uint_rtp(long); +uint __ovld __cnfn convert_uint_sat_rtp(long); +uint __ovld __cnfn convert_uint_rtn(long); +uint __ovld __cnfn convert_uint_sat_rtn(long); +uint __ovld __cnfn convert_uint(long); +uint __ovld __cnfn convert_uint_sat(long); +uint __ovld __cnfn convert_uint_rte(ulong); +uint __ovld __cnfn convert_uint_sat_rte(ulong); +uint __ovld __cnfn convert_uint_rtz(ulong); +uint __ovld __cnfn convert_uint_sat_rtz(ulong); +uint __ovld __cnfn convert_uint_rtp(ulong); +uint __ovld __cnfn convert_uint_sat_rtp(ulong); +uint __ovld __cnfn convert_uint_rtn(ulong); +uint __ovld __cnfn convert_uint_sat_rtn(ulong); +uint __ovld __cnfn convert_uint(ulong); +uint __ovld __cnfn convert_uint_sat(ulong); +uint __ovld __cnfn convert_uint_rte(float); +uint __ovld __cnfn convert_uint_sat_rte(float); +uint __ovld __cnfn convert_uint_rtz(float); +uint __ovld __cnfn convert_uint_sat_rtz(float); +uint __ovld __cnfn convert_uint_rtp(float); +uint __ovld __cnfn convert_uint_sat_rtp(float); +uint __ovld __cnfn convert_uint_rtn(float); +uint __ovld __cnfn convert_uint_sat_rtn(float); +uint __ovld __cnfn convert_uint(float); +uint __ovld __cnfn convert_uint_sat(float); +long __ovld __cnfn convert_long_rte(char); +long __ovld __cnfn convert_long_sat_rte(char); +long __ovld __cnfn convert_long_rtz(char); +long __ovld __cnfn convert_long_sat_rtz(char); +long __ovld __cnfn convert_long_rtp(char); +long __ovld __cnfn convert_long_sat_rtp(char); +long __ovld __cnfn convert_long_rtn(char); +long __ovld __cnfn convert_long_sat_rtn(char); +long __ovld __cnfn convert_long(char); +long __ovld __cnfn convert_long_sat(char); +long __ovld __cnfn convert_long_rte(uchar); +long __ovld __cnfn convert_long_sat_rte(uchar); +long __ovld __cnfn convert_long_rtz(uchar); +long __ovld __cnfn convert_long_sat_rtz(uchar); +long __ovld __cnfn convert_long_rtp(uchar); +long __ovld __cnfn convert_long_sat_rtp(uchar); +long __ovld __cnfn convert_long_rtn(uchar); +long __ovld __cnfn convert_long_sat_rtn(uchar); +long __ovld __cnfn convert_long(uchar); +long __ovld __cnfn convert_long_sat(uchar); +long __ovld __cnfn convert_long_rte(short); +long __ovld __cnfn convert_long_sat_rte(short); +long __ovld __cnfn convert_long_rtz(short); +long __ovld __cnfn convert_long_sat_rtz(short); +long __ovld __cnfn convert_long_rtp(short); +long __ovld __cnfn convert_long_sat_rtp(short); +long __ovld __cnfn convert_long_rtn(short); +long __ovld __cnfn convert_long_sat_rtn(short); +long __ovld __cnfn convert_long(short); +long __ovld __cnfn convert_long_sat(short); +long __ovld __cnfn convert_long_rte(ushort); +long __ovld __cnfn convert_long_sat_rte(ushort); +long __ovld __cnfn convert_long_rtz(ushort); +long __ovld __cnfn convert_long_sat_rtz(ushort); +long __ovld __cnfn convert_long_rtp(ushort); +long __ovld __cnfn convert_long_sat_rtp(ushort); +long __ovld __cnfn convert_long_rtn(ushort); +long __ovld __cnfn convert_long_sat_rtn(ushort); +long __ovld __cnfn convert_long(ushort); +long __ovld __cnfn convert_long_sat(ushort); +long __ovld __cnfn convert_long_rte(int); +long __ovld __cnfn convert_long_sat_rte(int); +long __ovld __cnfn convert_long_rtz(int); +long __ovld __cnfn convert_long_sat_rtz(int); +long __ovld __cnfn convert_long_rtp(int); +long __ovld __cnfn convert_long_sat_rtp(int); +long __ovld __cnfn convert_long_rtn(int); +long __ovld __cnfn convert_long_sat_rtn(int); +long __ovld __cnfn convert_long(int); +long __ovld __cnfn convert_long_sat(int); +long __ovld __cnfn convert_long_rte(uint); +long __ovld __cnfn convert_long_sat_rte(uint); +long __ovld __cnfn convert_long_rtz(uint); +long __ovld __cnfn convert_long_sat_rtz(uint); +long __ovld __cnfn convert_long_rtp(uint); +long __ovld __cnfn convert_long_sat_rtp(uint); +long __ovld __cnfn convert_long_rtn(uint); +long __ovld __cnfn convert_long_sat_rtn(uint); +long __ovld __cnfn convert_long(uint); +long __ovld __cnfn convert_long_sat(uint); +long __ovld __cnfn convert_long_rte(long); +long __ovld __cnfn convert_long_sat_rte(long); +long __ovld __cnfn convert_long_rtz(long); +long __ovld __cnfn convert_long_sat_rtz(long); +long __ovld __cnfn convert_long_rtp(long); +long __ovld __cnfn convert_long_sat_rtp(long); +long __ovld __cnfn convert_long_rtn(long); +long __ovld __cnfn convert_long_sat_rtn(long); +long __ovld __cnfn convert_long(long); +long __ovld __cnfn convert_long_sat(long); +long __ovld __cnfn convert_long_rte(ulong); +long __ovld __cnfn convert_long_sat_rte(ulong); +long __ovld __cnfn convert_long_rtz(ulong); +long __ovld __cnfn convert_long_sat_rtz(ulong); +long __ovld __cnfn convert_long_rtp(ulong); +long __ovld __cnfn convert_long_sat_rtp(ulong); +long __ovld __cnfn convert_long_rtn(ulong); +long __ovld __cnfn convert_long_sat_rtn(ulong); +long __ovld __cnfn convert_long(ulong); +long __ovld __cnfn convert_long_sat(ulong); +long __ovld __cnfn convert_long_rte(float); +long __ovld __cnfn convert_long_sat_rte(float); +long __ovld __cnfn convert_long_rtz(float); +long __ovld __cnfn convert_long_sat_rtz(float); +long __ovld __cnfn convert_long_rtp(float); +long __ovld __cnfn convert_long_sat_rtp(float); +long __ovld __cnfn convert_long_rtn(float); +long __ovld __cnfn convert_long_sat_rtn(float); +long __ovld __cnfn convert_long(float); +long __ovld __cnfn convert_long_sat(float); +ulong __ovld __cnfn convert_ulong_rte(char); +ulong __ovld __cnfn convert_ulong_sat_rte(char); +ulong __ovld __cnfn convert_ulong_rtz(char); +ulong __ovld __cnfn convert_ulong_sat_rtz(char); +ulong __ovld __cnfn convert_ulong_rtp(char); +ulong __ovld __cnfn convert_ulong_sat_rtp(char); +ulong __ovld __cnfn convert_ulong_rtn(char); +ulong __ovld __cnfn convert_ulong_sat_rtn(char); +ulong __ovld __cnfn convert_ulong(char); +ulong __ovld __cnfn convert_ulong_sat(char); +ulong __ovld __cnfn convert_ulong_rte(uchar); +ulong __ovld __cnfn convert_ulong_sat_rte(uchar); +ulong __ovld __cnfn convert_ulong_rtz(uchar); +ulong __ovld __cnfn convert_ulong_sat_rtz(uchar); +ulong __ovld __cnfn convert_ulong_rtp(uchar); +ulong __ovld __cnfn convert_ulong_sat_rtp(uchar); +ulong __ovld __cnfn convert_ulong_rtn(uchar); +ulong __ovld __cnfn convert_ulong_sat_rtn(uchar); +ulong __ovld __cnfn convert_ulong(uchar); +ulong __ovld __cnfn convert_ulong_sat(uchar); +ulong __ovld __cnfn convert_ulong_rte(short); +ulong __ovld __cnfn convert_ulong_sat_rte(short); +ulong __ovld __cnfn convert_ulong_rtz(short); +ulong __ovld __cnfn convert_ulong_sat_rtz(short); +ulong __ovld __cnfn convert_ulong_rtp(short); +ulong __ovld __cnfn convert_ulong_sat_rtp(short); +ulong __ovld __cnfn convert_ulong_rtn(short); +ulong __ovld __cnfn convert_ulong_sat_rtn(short); +ulong __ovld __cnfn convert_ulong(short); +ulong __ovld __cnfn convert_ulong_sat(short); +ulong __ovld __cnfn convert_ulong_rte(ushort); +ulong __ovld __cnfn convert_ulong_sat_rte(ushort); +ulong __ovld __cnfn convert_ulong_rtz(ushort); +ulong __ovld __cnfn convert_ulong_sat_rtz(ushort); +ulong __ovld __cnfn convert_ulong_rtp(ushort); +ulong __ovld __cnfn convert_ulong_sat_rtp(ushort); +ulong __ovld __cnfn convert_ulong_rtn(ushort); +ulong __ovld __cnfn convert_ulong_sat_rtn(ushort); +ulong __ovld __cnfn convert_ulong(ushort); +ulong __ovld __cnfn convert_ulong_sat(ushort); +ulong __ovld __cnfn convert_ulong_rte(int); +ulong __ovld __cnfn convert_ulong_sat_rte(int); +ulong __ovld __cnfn convert_ulong_rtz(int); +ulong __ovld __cnfn convert_ulong_sat_rtz(int); +ulong __ovld __cnfn convert_ulong_rtp(int); +ulong __ovld __cnfn convert_ulong_sat_rtp(int); +ulong __ovld __cnfn convert_ulong_rtn(int); +ulong __ovld __cnfn convert_ulong_sat_rtn(int); +ulong __ovld __cnfn convert_ulong(int); +ulong __ovld __cnfn convert_ulong_sat(int); +ulong __ovld __cnfn convert_ulong_rte(uint); +ulong __ovld __cnfn convert_ulong_sat_rte(uint); +ulong __ovld __cnfn convert_ulong_rtz(uint); +ulong __ovld __cnfn convert_ulong_sat_rtz(uint); +ulong __ovld __cnfn convert_ulong_rtp(uint); +ulong __ovld __cnfn convert_ulong_sat_rtp(uint); +ulong __ovld __cnfn convert_ulong_rtn(uint); +ulong __ovld __cnfn convert_ulong_sat_rtn(uint); +ulong __ovld __cnfn convert_ulong(uint); +ulong __ovld __cnfn convert_ulong_sat(uint); +ulong __ovld __cnfn convert_ulong_rte(long); +ulong __ovld __cnfn convert_ulong_sat_rte(long); +ulong __ovld __cnfn convert_ulong_rtz(long); +ulong __ovld __cnfn convert_ulong_sat_rtz(long); +ulong __ovld __cnfn convert_ulong_rtp(long); +ulong __ovld __cnfn convert_ulong_sat_rtp(long); +ulong __ovld __cnfn convert_ulong_rtn(long); +ulong __ovld __cnfn convert_ulong_sat_rtn(long); +ulong __ovld __cnfn convert_ulong(long); +ulong __ovld __cnfn convert_ulong_sat(long); +ulong __ovld __cnfn convert_ulong_rte(ulong); +ulong __ovld __cnfn convert_ulong_sat_rte(ulong); +ulong __ovld __cnfn convert_ulong_rtz(ulong); +ulong __ovld __cnfn convert_ulong_sat_rtz(ulong); +ulong __ovld __cnfn convert_ulong_rtp(ulong); +ulong __ovld __cnfn convert_ulong_sat_rtp(ulong); +ulong __ovld __cnfn convert_ulong_rtn(ulong); +ulong __ovld __cnfn convert_ulong_sat_rtn(ulong); +ulong __ovld __cnfn convert_ulong(ulong); +ulong __ovld __cnfn convert_ulong_sat(ulong); +ulong __ovld __cnfn convert_ulong_rte(float); +ulong __ovld __cnfn convert_ulong_sat_rte(float); +ulong __ovld __cnfn convert_ulong_rtz(float); +ulong __ovld __cnfn convert_ulong_sat_rtz(float); +ulong __ovld __cnfn convert_ulong_rtp(float); +ulong __ovld __cnfn convert_ulong_sat_rtp(float); +ulong __ovld __cnfn convert_ulong_rtn(float); +ulong __ovld __cnfn convert_ulong_sat_rtn(float); +ulong __ovld __cnfn convert_ulong(float); +ulong __ovld __cnfn convert_ulong_sat(float); +float __ovld __cnfn convert_float_rte(char); +float __ovld __cnfn convert_float_rtz(char); +float __ovld __cnfn convert_float_rtp(char); +float __ovld __cnfn convert_float_rtn(char); +float __ovld __cnfn convert_float(char); +float __ovld __cnfn convert_float_rte(uchar); +float __ovld __cnfn convert_float_rtz(uchar); +float __ovld __cnfn convert_float_rtp(uchar); +float __ovld __cnfn convert_float_rtn(uchar); +float __ovld __cnfn convert_float(uchar); +float __ovld __cnfn convert_float_rte(short); +float __ovld __cnfn convert_float_rtz(short); +float __ovld __cnfn convert_float_rtp(short); +float __ovld __cnfn convert_float_rtn(short); +float __ovld __cnfn convert_float(short); +float __ovld __cnfn convert_float_rte(ushort); +float __ovld __cnfn convert_float_rtz(ushort); +float __ovld __cnfn convert_float_rtp(ushort); +float __ovld __cnfn convert_float_rtn(ushort); +float __ovld __cnfn convert_float(ushort); +float __ovld __cnfn convert_float_rte(int); +float __ovld __cnfn convert_float_rtz(int); +float __ovld __cnfn convert_float_rtp(int); +float __ovld __cnfn convert_float_rtn(int); +float __ovld __cnfn convert_float(int); +float __ovld __cnfn convert_float_rte(uint); +float __ovld __cnfn convert_float_rtz(uint); +float __ovld __cnfn convert_float_rtp(uint); +float __ovld __cnfn convert_float_rtn(uint); +float __ovld __cnfn convert_float(uint); +float __ovld __cnfn convert_float_rte(long); +float __ovld __cnfn convert_float_rtz(long); +float __ovld __cnfn convert_float_rtp(long); +float __ovld __cnfn convert_float_rtn(long); +float __ovld __cnfn convert_float(long); +float __ovld __cnfn convert_float_rte(ulong); +float __ovld __cnfn convert_float_rtz(ulong); +float __ovld __cnfn convert_float_rtp(ulong); +float __ovld __cnfn convert_float_rtn(ulong); +float __ovld __cnfn convert_float(ulong); +float __ovld __cnfn convert_float_rte(float); +float __ovld __cnfn convert_float_rtz(float); +float __ovld __cnfn convert_float_rtp(float); +float __ovld __cnfn convert_float_rtn(float); +float __ovld __cnfn convert_float(float); +char2 __ovld __cnfn convert_char2_rte(char2); +char2 __ovld __cnfn convert_char2_sat_rte(char2); +char2 __ovld __cnfn convert_char2_rtz(char2); +char2 __ovld __cnfn convert_char2_sat_rtz(char2); +char2 __ovld __cnfn convert_char2_rtp(char2); +char2 __ovld __cnfn convert_char2_sat_rtp(char2); +char2 __ovld __cnfn convert_char2_rtn(char2); +char2 __ovld __cnfn convert_char2_sat_rtn(char2); +char2 __ovld __cnfn convert_char2(char2); +char2 __ovld __cnfn convert_char2_sat(char2); +char2 __ovld __cnfn convert_char2_rte(uchar2); +char2 __ovld __cnfn convert_char2_sat_rte(uchar2); +char2 __ovld __cnfn convert_char2_rtz(uchar2); +char2 __ovld __cnfn convert_char2_sat_rtz(uchar2); +char2 __ovld __cnfn convert_char2_rtp(uchar2); +char2 __ovld __cnfn convert_char2_sat_rtp(uchar2); +char2 __ovld __cnfn convert_char2_rtn(uchar2); +char2 __ovld __cnfn convert_char2_sat_rtn(uchar2); +char2 __ovld __cnfn convert_char2(uchar2); +char2 __ovld __cnfn convert_char2_sat(uchar2); +char2 __ovld __cnfn convert_char2_rte(short2); +char2 __ovld __cnfn convert_char2_sat_rte(short2); +char2 __ovld __cnfn convert_char2_rtz(short2); +char2 __ovld __cnfn convert_char2_sat_rtz(short2); +char2 __ovld __cnfn convert_char2_rtp(short2); +char2 __ovld __cnfn convert_char2_sat_rtp(short2); +char2 __ovld __cnfn convert_char2_rtn(short2); +char2 __ovld __cnfn convert_char2_sat_rtn(short2); +char2 __ovld __cnfn convert_char2(short2); +char2 __ovld __cnfn convert_char2_sat(short2); +char2 __ovld __cnfn convert_char2_rte(ushort2); +char2 __ovld __cnfn convert_char2_sat_rte(ushort2); +char2 __ovld __cnfn convert_char2_rtz(ushort2); +char2 __ovld __cnfn convert_char2_sat_rtz(ushort2); +char2 __ovld __cnfn convert_char2_rtp(ushort2); +char2 __ovld __cnfn convert_char2_sat_rtp(ushort2); +char2 __ovld __cnfn convert_char2_rtn(ushort2); +char2 __ovld __cnfn convert_char2_sat_rtn(ushort2); +char2 __ovld __cnfn convert_char2(ushort2); +char2 __ovld __cnfn convert_char2_sat(ushort2); +char2 __ovld __cnfn convert_char2_rte(int2); +char2 __ovld __cnfn convert_char2_sat_rte(int2); +char2 __ovld __cnfn convert_char2_rtz(int2); +char2 __ovld __cnfn convert_char2_sat_rtz(int2); +char2 __ovld __cnfn convert_char2_rtp(int2); +char2 __ovld __cnfn convert_char2_sat_rtp(int2); +char2 __ovld __cnfn convert_char2_rtn(int2); +char2 __ovld __cnfn convert_char2_sat_rtn(int2); +char2 __ovld __cnfn convert_char2(int2); +char2 __ovld __cnfn convert_char2_sat(int2); +char2 __ovld __cnfn convert_char2_rte(uint2); +char2 __ovld __cnfn convert_char2_sat_rte(uint2); +char2 __ovld __cnfn convert_char2_rtz(uint2); +char2 __ovld __cnfn convert_char2_sat_rtz(uint2); +char2 __ovld __cnfn convert_char2_rtp(uint2); +char2 __ovld __cnfn convert_char2_sat_rtp(uint2); +char2 __ovld __cnfn convert_char2_rtn(uint2); +char2 __ovld __cnfn convert_char2_sat_rtn(uint2); +char2 __ovld __cnfn convert_char2(uint2); +char2 __ovld __cnfn convert_char2_sat(uint2); +char2 __ovld __cnfn convert_char2_rte(long2); +char2 __ovld __cnfn convert_char2_sat_rte(long2); +char2 __ovld __cnfn convert_char2_rtz(long2); +char2 __ovld __cnfn convert_char2_sat_rtz(long2); +char2 __ovld __cnfn convert_char2_rtp(long2); +char2 __ovld __cnfn convert_char2_sat_rtp(long2); +char2 __ovld __cnfn convert_char2_rtn(long2); +char2 __ovld __cnfn convert_char2_sat_rtn(long2); +char2 __ovld __cnfn convert_char2(long2); +char2 __ovld __cnfn convert_char2_sat(long2); +char2 __ovld __cnfn convert_char2_rte(ulong2); +char2 __ovld __cnfn convert_char2_sat_rte(ulong2); +char2 __ovld __cnfn convert_char2_rtz(ulong2); +char2 __ovld __cnfn convert_char2_sat_rtz(ulong2); +char2 __ovld __cnfn convert_char2_rtp(ulong2); +char2 __ovld __cnfn convert_char2_sat_rtp(ulong2); +char2 __ovld __cnfn convert_char2_rtn(ulong2); +char2 __ovld __cnfn convert_char2_sat_rtn(ulong2); +char2 __ovld __cnfn convert_char2(ulong2); +char2 __ovld __cnfn convert_char2_sat(ulong2); +char2 __ovld __cnfn convert_char2_rte(float2); +char2 __ovld __cnfn convert_char2_sat_rte(float2); +char2 __ovld __cnfn convert_char2_rtz(float2); +char2 __ovld __cnfn convert_char2_sat_rtz(float2); +char2 __ovld __cnfn convert_char2_rtp(float2); +char2 __ovld __cnfn convert_char2_sat_rtp(float2); +char2 __ovld __cnfn convert_char2_rtn(float2); +char2 __ovld __cnfn convert_char2_sat_rtn(float2); +char2 __ovld __cnfn convert_char2(float2); +char2 __ovld __cnfn convert_char2_sat(float2); +uchar2 __ovld __cnfn convert_uchar2_rte(char2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(char2); +uchar2 __ovld __cnfn convert_uchar2_rtz(char2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(char2); +uchar2 __ovld __cnfn convert_uchar2_rtp(char2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(char2); +uchar2 __ovld __cnfn convert_uchar2_rtn(char2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(char2); +uchar2 __ovld __cnfn convert_uchar2(char2); +uchar2 __ovld __cnfn convert_uchar2_sat(char2); +uchar2 __ovld __cnfn convert_uchar2_rte(uchar2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(uchar2); +uchar2 __ovld __cnfn convert_uchar2_rtz(uchar2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(uchar2); +uchar2 __ovld __cnfn convert_uchar2_rtp(uchar2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(uchar2); +uchar2 __ovld __cnfn convert_uchar2_rtn(uchar2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(uchar2); +uchar2 __ovld __cnfn convert_uchar2(uchar2); +uchar2 __ovld __cnfn convert_uchar2_sat(uchar2); +uchar2 __ovld __cnfn convert_uchar2_rte(short2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(short2); +uchar2 __ovld __cnfn convert_uchar2_rtz(short2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(short2); +uchar2 __ovld __cnfn convert_uchar2_rtp(short2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(short2); +uchar2 __ovld __cnfn convert_uchar2_rtn(short2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(short2); +uchar2 __ovld __cnfn convert_uchar2(short2); +uchar2 __ovld __cnfn convert_uchar2_sat(short2); +uchar2 __ovld __cnfn convert_uchar2_rte(ushort2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(ushort2); +uchar2 __ovld __cnfn convert_uchar2_rtz(ushort2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(ushort2); +uchar2 __ovld __cnfn convert_uchar2_rtp(ushort2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(ushort2); +uchar2 __ovld __cnfn convert_uchar2_rtn(ushort2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(ushort2); +uchar2 __ovld __cnfn convert_uchar2(ushort2); +uchar2 __ovld __cnfn convert_uchar2_sat(ushort2); +uchar2 __ovld __cnfn convert_uchar2_rte(int2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(int2); +uchar2 __ovld __cnfn convert_uchar2_rtz(int2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(int2); +uchar2 __ovld __cnfn convert_uchar2_rtp(int2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(int2); +uchar2 __ovld __cnfn convert_uchar2_rtn(int2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(int2); +uchar2 __ovld __cnfn convert_uchar2(int2); +uchar2 __ovld __cnfn convert_uchar2_sat(int2); +uchar2 __ovld __cnfn convert_uchar2_rte(uint2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(uint2); +uchar2 __ovld __cnfn convert_uchar2_rtz(uint2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(uint2); +uchar2 __ovld __cnfn convert_uchar2_rtp(uint2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(uint2); +uchar2 __ovld __cnfn convert_uchar2_rtn(uint2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(uint2); +uchar2 __ovld __cnfn convert_uchar2(uint2); +uchar2 __ovld __cnfn convert_uchar2_sat(uint2); +uchar2 __ovld __cnfn convert_uchar2_rte(long2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(long2); +uchar2 __ovld __cnfn convert_uchar2_rtz(long2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(long2); +uchar2 __ovld __cnfn convert_uchar2_rtp(long2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(long2); +uchar2 __ovld __cnfn convert_uchar2_rtn(long2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(long2); +uchar2 __ovld __cnfn convert_uchar2(long2); +uchar2 __ovld __cnfn convert_uchar2_sat(long2); +uchar2 __ovld __cnfn convert_uchar2_rte(ulong2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(ulong2); +uchar2 __ovld __cnfn convert_uchar2_rtz(ulong2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(ulong2); +uchar2 __ovld __cnfn convert_uchar2_rtp(ulong2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(ulong2); +uchar2 __ovld __cnfn convert_uchar2_rtn(ulong2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(ulong2); +uchar2 __ovld __cnfn convert_uchar2(ulong2); +uchar2 __ovld __cnfn convert_uchar2_sat(ulong2); +uchar2 __ovld __cnfn convert_uchar2_rte(float2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(float2); +uchar2 __ovld __cnfn convert_uchar2_rtz(float2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(float2); +uchar2 __ovld __cnfn convert_uchar2_rtp(float2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(float2); +uchar2 __ovld __cnfn convert_uchar2_rtn(float2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(float2); +uchar2 __ovld __cnfn convert_uchar2(float2); +uchar2 __ovld __cnfn convert_uchar2_sat(float2); +short2 __ovld __cnfn convert_short2_rte(char2); +short2 __ovld __cnfn convert_short2_sat_rte(char2); +short2 __ovld __cnfn convert_short2_rtz(char2); +short2 __ovld __cnfn convert_short2_sat_rtz(char2); +short2 __ovld __cnfn convert_short2_rtp(char2); +short2 __ovld __cnfn convert_short2_sat_rtp(char2); +short2 __ovld __cnfn convert_short2_rtn(char2); +short2 __ovld __cnfn convert_short2_sat_rtn(char2); +short2 __ovld __cnfn convert_short2(char2); +short2 __ovld __cnfn convert_short2_sat(char2); +short2 __ovld __cnfn convert_short2_rte(uchar2); +short2 __ovld __cnfn convert_short2_sat_rte(uchar2); +short2 __ovld __cnfn convert_short2_rtz(uchar2); +short2 __ovld __cnfn convert_short2_sat_rtz(uchar2); +short2 __ovld __cnfn convert_short2_rtp(uchar2); +short2 __ovld __cnfn convert_short2_sat_rtp(uchar2); +short2 __ovld __cnfn convert_short2_rtn(uchar2); +short2 __ovld __cnfn convert_short2_sat_rtn(uchar2); +short2 __ovld __cnfn convert_short2(uchar2); +short2 __ovld __cnfn convert_short2_sat(uchar2); +short2 __ovld __cnfn convert_short2_rte(short2); +short2 __ovld __cnfn convert_short2_sat_rte(short2); +short2 __ovld __cnfn convert_short2_rtz(short2); +short2 __ovld __cnfn convert_short2_sat_rtz(short2); +short2 __ovld __cnfn convert_short2_rtp(short2); +short2 __ovld __cnfn convert_short2_sat_rtp(short2); +short2 __ovld __cnfn convert_short2_rtn(short2); +short2 __ovld __cnfn convert_short2_sat_rtn(short2); +short2 __ovld __cnfn convert_short2(short2); +short2 __ovld __cnfn convert_short2_sat(short2); +short2 __ovld __cnfn convert_short2_rte(ushort2); +short2 __ovld __cnfn convert_short2_sat_rte(ushort2); +short2 __ovld __cnfn convert_short2_rtz(ushort2); +short2 __ovld __cnfn convert_short2_sat_rtz(ushort2); +short2 __ovld __cnfn convert_short2_rtp(ushort2); +short2 __ovld __cnfn convert_short2_sat_rtp(ushort2); +short2 __ovld __cnfn convert_short2_rtn(ushort2); +short2 __ovld __cnfn convert_short2_sat_rtn(ushort2); +short2 __ovld __cnfn convert_short2(ushort2); +short2 __ovld __cnfn convert_short2_sat(ushort2); +short2 __ovld __cnfn convert_short2_rte(int2); +short2 __ovld __cnfn convert_short2_sat_rte(int2); +short2 __ovld __cnfn convert_short2_rtz(int2); +short2 __ovld __cnfn convert_short2_sat_rtz(int2); +short2 __ovld __cnfn convert_short2_rtp(int2); +short2 __ovld __cnfn convert_short2_sat_rtp(int2); +short2 __ovld __cnfn convert_short2_rtn(int2); +short2 __ovld __cnfn convert_short2_sat_rtn(int2); +short2 __ovld __cnfn convert_short2(int2); +short2 __ovld __cnfn convert_short2_sat(int2); +short2 __ovld __cnfn convert_short2_rte(uint2); +short2 __ovld __cnfn convert_short2_sat_rte(uint2); +short2 __ovld __cnfn convert_short2_rtz(uint2); +short2 __ovld __cnfn convert_short2_sat_rtz(uint2); +short2 __ovld __cnfn convert_short2_rtp(uint2); +short2 __ovld __cnfn convert_short2_sat_rtp(uint2); +short2 __ovld __cnfn convert_short2_rtn(uint2); +short2 __ovld __cnfn convert_short2_sat_rtn(uint2); +short2 __ovld __cnfn convert_short2(uint2); +short2 __ovld __cnfn convert_short2_sat(uint2); +short2 __ovld __cnfn convert_short2_rte(long2); +short2 __ovld __cnfn convert_short2_sat_rte(long2); +short2 __ovld __cnfn convert_short2_rtz(long2); +short2 __ovld __cnfn convert_short2_sat_rtz(long2); +short2 __ovld __cnfn convert_short2_rtp(long2); +short2 __ovld __cnfn convert_short2_sat_rtp(long2); +short2 __ovld __cnfn convert_short2_rtn(long2); +short2 __ovld __cnfn convert_short2_sat_rtn(long2); +short2 __ovld __cnfn convert_short2(long2); +short2 __ovld __cnfn convert_short2_sat(long2); +short2 __ovld __cnfn convert_short2_rte(ulong2); +short2 __ovld __cnfn convert_short2_sat_rte(ulong2); +short2 __ovld __cnfn convert_short2_rtz(ulong2); +short2 __ovld __cnfn convert_short2_sat_rtz(ulong2); +short2 __ovld __cnfn convert_short2_rtp(ulong2); +short2 __ovld __cnfn convert_short2_sat_rtp(ulong2); +short2 __ovld __cnfn convert_short2_rtn(ulong2); +short2 __ovld __cnfn convert_short2_sat_rtn(ulong2); +short2 __ovld __cnfn convert_short2(ulong2); +short2 __ovld __cnfn convert_short2_sat(ulong2); +short2 __ovld __cnfn convert_short2_rte(float2); +short2 __ovld __cnfn convert_short2_sat_rte(float2); +short2 __ovld __cnfn convert_short2_rtz(float2); +short2 __ovld __cnfn convert_short2_sat_rtz(float2); +short2 __ovld __cnfn convert_short2_rtp(float2); +short2 __ovld __cnfn convert_short2_sat_rtp(float2); +short2 __ovld __cnfn convert_short2_rtn(float2); +short2 __ovld __cnfn convert_short2_sat_rtn(float2); +short2 __ovld __cnfn convert_short2(float2); +short2 __ovld __cnfn convert_short2_sat(float2); +ushort2 __ovld __cnfn convert_ushort2_rte(char2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(char2); +ushort2 __ovld __cnfn convert_ushort2_rtz(char2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(char2); +ushort2 __ovld __cnfn convert_ushort2_rtp(char2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(char2); +ushort2 __ovld __cnfn convert_ushort2_rtn(char2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(char2); +ushort2 __ovld __cnfn convert_ushort2(char2); +ushort2 __ovld __cnfn convert_ushort2_sat(char2); +ushort2 __ovld __cnfn convert_ushort2_rte(uchar2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(uchar2); +ushort2 __ovld __cnfn convert_ushort2_rtz(uchar2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(uchar2); +ushort2 __ovld __cnfn convert_ushort2_rtp(uchar2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(uchar2); +ushort2 __ovld __cnfn convert_ushort2_rtn(uchar2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(uchar2); +ushort2 __ovld __cnfn convert_ushort2(uchar2); +ushort2 __ovld __cnfn convert_ushort2_sat(uchar2); +ushort2 __ovld __cnfn convert_ushort2_rte(short2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(short2); +ushort2 __ovld __cnfn convert_ushort2_rtz(short2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(short2); +ushort2 __ovld __cnfn convert_ushort2_rtp(short2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(short2); +ushort2 __ovld __cnfn convert_ushort2_rtn(short2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(short2); +ushort2 __ovld __cnfn convert_ushort2(short2); +ushort2 __ovld __cnfn convert_ushort2_sat(short2); +ushort2 __ovld __cnfn convert_ushort2_rte(ushort2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(ushort2); +ushort2 __ovld __cnfn convert_ushort2_rtz(ushort2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(ushort2); +ushort2 __ovld __cnfn convert_ushort2_rtp(ushort2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(ushort2); +ushort2 __ovld __cnfn convert_ushort2_rtn(ushort2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(ushort2); +ushort2 __ovld __cnfn convert_ushort2(ushort2); +ushort2 __ovld __cnfn convert_ushort2_sat(ushort2); +ushort2 __ovld __cnfn convert_ushort2_rte(int2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(int2); +ushort2 __ovld __cnfn convert_ushort2_rtz(int2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(int2); +ushort2 __ovld __cnfn convert_ushort2_rtp(int2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(int2); +ushort2 __ovld __cnfn convert_ushort2_rtn(int2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(int2); +ushort2 __ovld __cnfn convert_ushort2(int2); +ushort2 __ovld __cnfn convert_ushort2_sat(int2); +ushort2 __ovld __cnfn convert_ushort2_rte(uint2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(uint2); +ushort2 __ovld __cnfn convert_ushort2_rtz(uint2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(uint2); +ushort2 __ovld __cnfn convert_ushort2_rtp(uint2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(uint2); +ushort2 __ovld __cnfn convert_ushort2_rtn(uint2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(uint2); +ushort2 __ovld __cnfn convert_ushort2(uint2); +ushort2 __ovld __cnfn convert_ushort2_sat(uint2); +ushort2 __ovld __cnfn convert_ushort2_rte(long2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(long2); +ushort2 __ovld __cnfn convert_ushort2_rtz(long2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(long2); +ushort2 __ovld __cnfn convert_ushort2_rtp(long2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(long2); +ushort2 __ovld __cnfn convert_ushort2_rtn(long2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(long2); +ushort2 __ovld __cnfn convert_ushort2(long2); +ushort2 __ovld __cnfn convert_ushort2_sat(long2); +ushort2 __ovld __cnfn convert_ushort2_rte(ulong2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(ulong2); +ushort2 __ovld __cnfn convert_ushort2_rtz(ulong2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(ulong2); +ushort2 __ovld __cnfn convert_ushort2_rtp(ulong2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(ulong2); +ushort2 __ovld __cnfn convert_ushort2_rtn(ulong2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(ulong2); +ushort2 __ovld __cnfn convert_ushort2(ulong2); +ushort2 __ovld __cnfn convert_ushort2_sat(ulong2); +ushort2 __ovld __cnfn convert_ushort2_rte(float2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(float2); +ushort2 __ovld __cnfn convert_ushort2_rtz(float2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(float2); +ushort2 __ovld __cnfn convert_ushort2_rtp(float2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(float2); +ushort2 __ovld __cnfn convert_ushort2_rtn(float2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(float2); +ushort2 __ovld __cnfn convert_ushort2(float2); +ushort2 __ovld __cnfn convert_ushort2_sat(float2); +int2 __ovld __cnfn convert_int2_rte(char2); +int2 __ovld __cnfn convert_int2_sat_rte(char2); +int2 __ovld __cnfn convert_int2_rtz(char2); +int2 __ovld __cnfn convert_int2_sat_rtz(char2); +int2 __ovld __cnfn convert_int2_rtp(char2); +int2 __ovld __cnfn convert_int2_sat_rtp(char2); +int2 __ovld __cnfn convert_int2_rtn(char2); +int2 __ovld __cnfn convert_int2_sat_rtn(char2); +int2 __ovld __cnfn convert_int2(char2); +int2 __ovld __cnfn convert_int2_sat(char2); +int2 __ovld __cnfn convert_int2_rte(uchar2); +int2 __ovld __cnfn convert_int2_sat_rte(uchar2); +int2 __ovld __cnfn convert_int2_rtz(uchar2); +int2 __ovld __cnfn convert_int2_sat_rtz(uchar2); +int2 __ovld __cnfn convert_int2_rtp(uchar2); +int2 __ovld __cnfn convert_int2_sat_rtp(uchar2); +int2 __ovld __cnfn convert_int2_rtn(uchar2); +int2 __ovld __cnfn convert_int2_sat_rtn(uchar2); +int2 __ovld __cnfn convert_int2(uchar2); +int2 __ovld __cnfn convert_int2_sat(uchar2); +int2 __ovld __cnfn convert_int2_rte(short2); +int2 __ovld __cnfn convert_int2_sat_rte(short2); +int2 __ovld __cnfn convert_int2_rtz(short2); +int2 __ovld __cnfn convert_int2_sat_rtz(short2); +int2 __ovld __cnfn convert_int2_rtp(short2); +int2 __ovld __cnfn convert_int2_sat_rtp(short2); +int2 __ovld __cnfn convert_int2_rtn(short2); +int2 __ovld __cnfn convert_int2_sat_rtn(short2); +int2 __ovld __cnfn convert_int2(short2); +int2 __ovld __cnfn convert_int2_sat(short2); +int2 __ovld __cnfn convert_int2_rte(ushort2); +int2 __ovld __cnfn convert_int2_sat_rte(ushort2); +int2 __ovld __cnfn convert_int2_rtz(ushort2); +int2 __ovld __cnfn convert_int2_sat_rtz(ushort2); +int2 __ovld __cnfn convert_int2_rtp(ushort2); +int2 __ovld __cnfn convert_int2_sat_rtp(ushort2); +int2 __ovld __cnfn convert_int2_rtn(ushort2); +int2 __ovld __cnfn convert_int2_sat_rtn(ushort2); +int2 __ovld __cnfn convert_int2(ushort2); +int2 __ovld __cnfn convert_int2_sat(ushort2); +int2 __ovld __cnfn convert_int2_rte(int2); +int2 __ovld __cnfn convert_int2_sat_rte(int2); +int2 __ovld __cnfn convert_int2_rtz(int2); +int2 __ovld __cnfn convert_int2_sat_rtz(int2); +int2 __ovld __cnfn convert_int2_rtp(int2); +int2 __ovld __cnfn convert_int2_sat_rtp(int2); +int2 __ovld __cnfn convert_int2_rtn(int2); +int2 __ovld __cnfn convert_int2_sat_rtn(int2); +int2 __ovld __cnfn convert_int2(int2); +int2 __ovld __cnfn convert_int2_sat(int2); +int2 __ovld __cnfn convert_int2_rte(uint2); +int2 __ovld __cnfn convert_int2_sat_rte(uint2); +int2 __ovld __cnfn convert_int2_rtz(uint2); +int2 __ovld __cnfn convert_int2_sat_rtz(uint2); +int2 __ovld __cnfn convert_int2_rtp(uint2); +int2 __ovld __cnfn convert_int2_sat_rtp(uint2); +int2 __ovld __cnfn convert_int2_rtn(uint2); +int2 __ovld __cnfn convert_int2_sat_rtn(uint2); +int2 __ovld __cnfn convert_int2(uint2); +int2 __ovld __cnfn convert_int2_sat(uint2); +int2 __ovld __cnfn convert_int2_rte(long2); +int2 __ovld __cnfn convert_int2_sat_rte(long2); +int2 __ovld __cnfn convert_int2_rtz(long2); +int2 __ovld __cnfn convert_int2_sat_rtz(long2); +int2 __ovld __cnfn convert_int2_rtp(long2); +int2 __ovld __cnfn convert_int2_sat_rtp(long2); +int2 __ovld __cnfn convert_int2_rtn(long2); +int2 __ovld __cnfn convert_int2_sat_rtn(long2); +int2 __ovld __cnfn convert_int2(long2); +int2 __ovld __cnfn convert_int2_sat(long2); +int2 __ovld __cnfn convert_int2_rte(ulong2); +int2 __ovld __cnfn convert_int2_sat_rte(ulong2); +int2 __ovld __cnfn convert_int2_rtz(ulong2); +int2 __ovld __cnfn convert_int2_sat_rtz(ulong2); +int2 __ovld __cnfn convert_int2_rtp(ulong2); +int2 __ovld __cnfn convert_int2_sat_rtp(ulong2); +int2 __ovld __cnfn convert_int2_rtn(ulong2); +int2 __ovld __cnfn convert_int2_sat_rtn(ulong2); +int2 __ovld __cnfn convert_int2(ulong2); +int2 __ovld __cnfn convert_int2_sat(ulong2); +int2 __ovld __cnfn convert_int2_rte(float2); +int2 __ovld __cnfn convert_int2_sat_rte(float2); +int2 __ovld __cnfn convert_int2_rtz(float2); +int2 __ovld __cnfn convert_int2_sat_rtz(float2); +int2 __ovld __cnfn convert_int2_rtp(float2); +int2 __ovld __cnfn convert_int2_sat_rtp(float2); +int2 __ovld __cnfn convert_int2_rtn(float2); +int2 __ovld __cnfn convert_int2_sat_rtn(float2); +int2 __ovld __cnfn convert_int2(float2); +int2 __ovld __cnfn convert_int2_sat(float2); +uint2 __ovld __cnfn convert_uint2_rte(char2); +uint2 __ovld __cnfn convert_uint2_sat_rte(char2); +uint2 __ovld __cnfn convert_uint2_rtz(char2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(char2); +uint2 __ovld __cnfn convert_uint2_rtp(char2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(char2); +uint2 __ovld __cnfn convert_uint2_rtn(char2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(char2); +uint2 __ovld __cnfn convert_uint2(char2); +uint2 __ovld __cnfn convert_uint2_sat(char2); +uint2 __ovld __cnfn convert_uint2_rte(uchar2); +uint2 __ovld __cnfn convert_uint2_sat_rte(uchar2); +uint2 __ovld __cnfn convert_uint2_rtz(uchar2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(uchar2); +uint2 __ovld __cnfn convert_uint2_rtp(uchar2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(uchar2); +uint2 __ovld __cnfn convert_uint2_rtn(uchar2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(uchar2); +uint2 __ovld __cnfn convert_uint2(uchar2); +uint2 __ovld __cnfn convert_uint2_sat(uchar2); +uint2 __ovld __cnfn convert_uint2_rte(short2); +uint2 __ovld __cnfn convert_uint2_sat_rte(short2); +uint2 __ovld __cnfn convert_uint2_rtz(short2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(short2); +uint2 __ovld __cnfn convert_uint2_rtp(short2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(short2); +uint2 __ovld __cnfn convert_uint2_rtn(short2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(short2); +uint2 __ovld __cnfn convert_uint2(short2); +uint2 __ovld __cnfn convert_uint2_sat(short2); +uint2 __ovld __cnfn convert_uint2_rte(ushort2); +uint2 __ovld __cnfn convert_uint2_sat_rte(ushort2); +uint2 __ovld __cnfn convert_uint2_rtz(ushort2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(ushort2); +uint2 __ovld __cnfn convert_uint2_rtp(ushort2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(ushort2); +uint2 __ovld __cnfn convert_uint2_rtn(ushort2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(ushort2); +uint2 __ovld __cnfn convert_uint2(ushort2); +uint2 __ovld __cnfn convert_uint2_sat(ushort2); +uint2 __ovld __cnfn convert_uint2_rte(int2); +uint2 __ovld __cnfn convert_uint2_sat_rte(int2); +uint2 __ovld __cnfn convert_uint2_rtz(int2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(int2); +uint2 __ovld __cnfn convert_uint2_rtp(int2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(int2); +uint2 __ovld __cnfn convert_uint2_rtn(int2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(int2); +uint2 __ovld __cnfn convert_uint2(int2); +uint2 __ovld __cnfn convert_uint2_sat(int2); +uint2 __ovld __cnfn convert_uint2_rte(uint2); +uint2 __ovld __cnfn convert_uint2_sat_rte(uint2); +uint2 __ovld __cnfn convert_uint2_rtz(uint2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(uint2); +uint2 __ovld __cnfn convert_uint2_rtp(uint2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(uint2); +uint2 __ovld __cnfn convert_uint2_rtn(uint2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(uint2); +uint2 __ovld __cnfn convert_uint2(uint2); +uint2 __ovld __cnfn convert_uint2_sat(uint2); +uint2 __ovld __cnfn convert_uint2_rte(long2); +uint2 __ovld __cnfn convert_uint2_sat_rte(long2); +uint2 __ovld __cnfn convert_uint2_rtz(long2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(long2); +uint2 __ovld __cnfn convert_uint2_rtp(long2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(long2); +uint2 __ovld __cnfn convert_uint2_rtn(long2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(long2); +uint2 __ovld __cnfn convert_uint2(long2); +uint2 __ovld __cnfn convert_uint2_sat(long2); +uint2 __ovld __cnfn convert_uint2_rte(ulong2); +uint2 __ovld __cnfn convert_uint2_sat_rte(ulong2); +uint2 __ovld __cnfn convert_uint2_rtz(ulong2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(ulong2); +uint2 __ovld __cnfn convert_uint2_rtp(ulong2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(ulong2); +uint2 __ovld __cnfn convert_uint2_rtn(ulong2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(ulong2); +uint2 __ovld __cnfn convert_uint2(ulong2); +uint2 __ovld __cnfn convert_uint2_sat(ulong2); +uint2 __ovld __cnfn convert_uint2_rte(float2); +uint2 __ovld __cnfn convert_uint2_sat_rte(float2); +uint2 __ovld __cnfn convert_uint2_rtz(float2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(float2); +uint2 __ovld __cnfn convert_uint2_rtp(float2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(float2); +uint2 __ovld __cnfn convert_uint2_rtn(float2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(float2); +uint2 __ovld __cnfn convert_uint2(float2); +uint2 __ovld __cnfn convert_uint2_sat(float2); +long2 __ovld __cnfn convert_long2_rte(char2); +long2 __ovld __cnfn convert_long2_sat_rte(char2); +long2 __ovld __cnfn convert_long2_rtz(char2); +long2 __ovld __cnfn convert_long2_sat_rtz(char2); +long2 __ovld __cnfn convert_long2_rtp(char2); +long2 __ovld __cnfn convert_long2_sat_rtp(char2); +long2 __ovld __cnfn convert_long2_rtn(char2); +long2 __ovld __cnfn convert_long2_sat_rtn(char2); +long2 __ovld __cnfn convert_long2(char2); +long2 __ovld __cnfn convert_long2_sat(char2); +long2 __ovld __cnfn convert_long2_rte(uchar2); +long2 __ovld __cnfn convert_long2_sat_rte(uchar2); +long2 __ovld __cnfn convert_long2_rtz(uchar2); +long2 __ovld __cnfn convert_long2_sat_rtz(uchar2); +long2 __ovld __cnfn convert_long2_rtp(uchar2); +long2 __ovld __cnfn convert_long2_sat_rtp(uchar2); +long2 __ovld __cnfn convert_long2_rtn(uchar2); +long2 __ovld __cnfn convert_long2_sat_rtn(uchar2); +long2 __ovld __cnfn convert_long2(uchar2); +long2 __ovld __cnfn convert_long2_sat(uchar2); +long2 __ovld __cnfn convert_long2_rte(short2); +long2 __ovld __cnfn convert_long2_sat_rte(short2); +long2 __ovld __cnfn convert_long2_rtz(short2); +long2 __ovld __cnfn convert_long2_sat_rtz(short2); +long2 __ovld __cnfn convert_long2_rtp(short2); +long2 __ovld __cnfn convert_long2_sat_rtp(short2); +long2 __ovld __cnfn convert_long2_rtn(short2); +long2 __ovld __cnfn convert_long2_sat_rtn(short2); +long2 __ovld __cnfn convert_long2(short2); +long2 __ovld __cnfn convert_long2_sat(short2); +long2 __ovld __cnfn convert_long2_rte(ushort2); +long2 __ovld __cnfn convert_long2_sat_rte(ushort2); +long2 __ovld __cnfn convert_long2_rtz(ushort2); +long2 __ovld __cnfn convert_long2_sat_rtz(ushort2); +long2 __ovld __cnfn convert_long2_rtp(ushort2); +long2 __ovld __cnfn convert_long2_sat_rtp(ushort2); +long2 __ovld __cnfn convert_long2_rtn(ushort2); +long2 __ovld __cnfn convert_long2_sat_rtn(ushort2); +long2 __ovld __cnfn convert_long2(ushort2); +long2 __ovld __cnfn convert_long2_sat(ushort2); +long2 __ovld __cnfn convert_long2_rte(int2); +long2 __ovld __cnfn convert_long2_sat_rte(int2); +long2 __ovld __cnfn convert_long2_rtz(int2); +long2 __ovld __cnfn convert_long2_sat_rtz(int2); +long2 __ovld __cnfn convert_long2_rtp(int2); +long2 __ovld __cnfn convert_long2_sat_rtp(int2); +long2 __ovld __cnfn convert_long2_rtn(int2); +long2 __ovld __cnfn convert_long2_sat_rtn(int2); +long2 __ovld __cnfn convert_long2(int2); +long2 __ovld __cnfn convert_long2_sat(int2); +long2 __ovld __cnfn convert_long2_rte(uint2); +long2 __ovld __cnfn convert_long2_sat_rte(uint2); +long2 __ovld __cnfn convert_long2_rtz(uint2); +long2 __ovld __cnfn convert_long2_sat_rtz(uint2); +long2 __ovld __cnfn convert_long2_rtp(uint2); +long2 __ovld __cnfn convert_long2_sat_rtp(uint2); +long2 __ovld __cnfn convert_long2_rtn(uint2); +long2 __ovld __cnfn convert_long2_sat_rtn(uint2); +long2 __ovld __cnfn convert_long2(uint2); +long2 __ovld __cnfn convert_long2_sat(uint2); +long2 __ovld __cnfn convert_long2_rte(long2); +long2 __ovld __cnfn convert_long2_sat_rte(long2); +long2 __ovld __cnfn convert_long2_rtz(long2); +long2 __ovld __cnfn convert_long2_sat_rtz(long2); +long2 __ovld __cnfn convert_long2_rtp(long2); +long2 __ovld __cnfn convert_long2_sat_rtp(long2); +long2 __ovld __cnfn convert_long2_rtn(long2); +long2 __ovld __cnfn convert_long2_sat_rtn(long2); +long2 __ovld __cnfn convert_long2(long2); +long2 __ovld __cnfn convert_long2_sat(long2); +long2 __ovld __cnfn convert_long2_rte(ulong2); +long2 __ovld __cnfn convert_long2_sat_rte(ulong2); +long2 __ovld __cnfn convert_long2_rtz(ulong2); +long2 __ovld __cnfn convert_long2_sat_rtz(ulong2); +long2 __ovld __cnfn convert_long2_rtp(ulong2); +long2 __ovld __cnfn convert_long2_sat_rtp(ulong2); +long2 __ovld __cnfn convert_long2_rtn(ulong2); +long2 __ovld __cnfn convert_long2_sat_rtn(ulong2); +long2 __ovld __cnfn convert_long2(ulong2); +long2 __ovld __cnfn convert_long2_sat(ulong2); +long2 __ovld __cnfn convert_long2_rte(float2); +long2 __ovld __cnfn convert_long2_sat_rte(float2); +long2 __ovld __cnfn convert_long2_rtz(float2); +long2 __ovld __cnfn convert_long2_sat_rtz(float2); +long2 __ovld __cnfn convert_long2_rtp(float2); +long2 __ovld __cnfn convert_long2_sat_rtp(float2); +long2 __ovld __cnfn convert_long2_rtn(float2); +long2 __ovld __cnfn convert_long2_sat_rtn(float2); +long2 __ovld __cnfn convert_long2(float2); +long2 __ovld __cnfn convert_long2_sat(float2); +ulong2 __ovld __cnfn convert_ulong2_rte(char2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(char2); +ulong2 __ovld __cnfn convert_ulong2_rtz(char2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(char2); +ulong2 __ovld __cnfn convert_ulong2_rtp(char2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(char2); +ulong2 __ovld __cnfn convert_ulong2_rtn(char2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(char2); +ulong2 __ovld __cnfn convert_ulong2(char2); +ulong2 __ovld __cnfn convert_ulong2_sat(char2); +ulong2 __ovld __cnfn convert_ulong2_rte(uchar2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(uchar2); +ulong2 __ovld __cnfn convert_ulong2_rtz(uchar2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(uchar2); +ulong2 __ovld __cnfn convert_ulong2_rtp(uchar2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(uchar2); +ulong2 __ovld __cnfn convert_ulong2_rtn(uchar2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(uchar2); +ulong2 __ovld __cnfn convert_ulong2(uchar2); +ulong2 __ovld __cnfn convert_ulong2_sat(uchar2); +ulong2 __ovld __cnfn convert_ulong2_rte(short2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(short2); +ulong2 __ovld __cnfn convert_ulong2_rtz(short2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(short2); +ulong2 __ovld __cnfn convert_ulong2_rtp(short2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(short2); +ulong2 __ovld __cnfn convert_ulong2_rtn(short2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(short2); +ulong2 __ovld __cnfn convert_ulong2(short2); +ulong2 __ovld __cnfn convert_ulong2_sat(short2); +ulong2 __ovld __cnfn convert_ulong2_rte(ushort2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(ushort2); +ulong2 __ovld __cnfn convert_ulong2_rtz(ushort2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(ushort2); +ulong2 __ovld __cnfn convert_ulong2_rtp(ushort2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(ushort2); +ulong2 __ovld __cnfn convert_ulong2_rtn(ushort2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(ushort2); +ulong2 __ovld __cnfn convert_ulong2(ushort2); +ulong2 __ovld __cnfn convert_ulong2_sat(ushort2); +ulong2 __ovld __cnfn convert_ulong2_rte(int2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(int2); +ulong2 __ovld __cnfn convert_ulong2_rtz(int2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(int2); +ulong2 __ovld __cnfn convert_ulong2_rtp(int2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(int2); +ulong2 __ovld __cnfn convert_ulong2_rtn(int2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(int2); +ulong2 __ovld __cnfn convert_ulong2(int2); +ulong2 __ovld __cnfn convert_ulong2_sat(int2); +ulong2 __ovld __cnfn convert_ulong2_rte(uint2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(uint2); +ulong2 __ovld __cnfn convert_ulong2_rtz(uint2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(uint2); +ulong2 __ovld __cnfn convert_ulong2_rtp(uint2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(uint2); +ulong2 __ovld __cnfn convert_ulong2_rtn(uint2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(uint2); +ulong2 __ovld __cnfn convert_ulong2(uint2); +ulong2 __ovld __cnfn convert_ulong2_sat(uint2); +ulong2 __ovld __cnfn convert_ulong2_rte(long2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(long2); +ulong2 __ovld __cnfn convert_ulong2_rtz(long2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(long2); +ulong2 __ovld __cnfn convert_ulong2_rtp(long2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(long2); +ulong2 __ovld __cnfn convert_ulong2_rtn(long2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(long2); +ulong2 __ovld __cnfn convert_ulong2(long2); +ulong2 __ovld __cnfn convert_ulong2_sat(long2); +ulong2 __ovld __cnfn convert_ulong2_rte(ulong2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(ulong2); +ulong2 __ovld __cnfn convert_ulong2_rtz(ulong2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(ulong2); +ulong2 __ovld __cnfn convert_ulong2_rtp(ulong2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(ulong2); +ulong2 __ovld __cnfn convert_ulong2_rtn(ulong2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(ulong2); +ulong2 __ovld __cnfn convert_ulong2(ulong2); +ulong2 __ovld __cnfn convert_ulong2_sat(ulong2); +ulong2 __ovld __cnfn convert_ulong2_rte(float2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(float2); +ulong2 __ovld __cnfn convert_ulong2_rtz(float2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(float2); +ulong2 __ovld __cnfn convert_ulong2_rtp(float2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(float2); +ulong2 __ovld __cnfn convert_ulong2_rtn(float2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(float2); +ulong2 __ovld __cnfn convert_ulong2(float2); +ulong2 __ovld __cnfn convert_ulong2_sat(float2); +float2 __ovld __cnfn convert_float2_rte(char2); +float2 __ovld __cnfn convert_float2_rtz(char2); +float2 __ovld __cnfn convert_float2_rtp(char2); +float2 __ovld __cnfn convert_float2_rtn(char2); +float2 __ovld __cnfn convert_float2(char2); +float2 __ovld __cnfn convert_float2_rte(uchar2); +float2 __ovld __cnfn convert_float2_rtz(uchar2); +float2 __ovld __cnfn convert_float2_rtp(uchar2); +float2 __ovld __cnfn convert_float2_rtn(uchar2); +float2 __ovld __cnfn convert_float2(uchar2); +float2 __ovld __cnfn convert_float2_rte(short2); +float2 __ovld __cnfn convert_float2_rtz(short2); +float2 __ovld __cnfn convert_float2_rtp(short2); +float2 __ovld __cnfn convert_float2_rtn(short2); +float2 __ovld __cnfn convert_float2(short2); +float2 __ovld __cnfn convert_float2_rte(ushort2); +float2 __ovld __cnfn convert_float2_rtz(ushort2); +float2 __ovld __cnfn convert_float2_rtp(ushort2); +float2 __ovld __cnfn convert_float2_rtn(ushort2); +float2 __ovld __cnfn convert_float2(ushort2); +float2 __ovld __cnfn convert_float2_rte(int2); +float2 __ovld __cnfn convert_float2_rtz(int2); +float2 __ovld __cnfn convert_float2_rtp(int2); +float2 __ovld __cnfn convert_float2_rtn(int2); +float2 __ovld __cnfn convert_float2(int2); +float2 __ovld __cnfn convert_float2_rte(uint2); +float2 __ovld __cnfn convert_float2_rtz(uint2); +float2 __ovld __cnfn convert_float2_rtp(uint2); +float2 __ovld __cnfn convert_float2_rtn(uint2); +float2 __ovld __cnfn convert_float2(uint2); +float2 __ovld __cnfn convert_float2_rte(long2); +float2 __ovld __cnfn convert_float2_rtz(long2); +float2 __ovld __cnfn convert_float2_rtp(long2); +float2 __ovld __cnfn convert_float2_rtn(long2); +float2 __ovld __cnfn convert_float2(long2); +float2 __ovld __cnfn convert_float2_rte(ulong2); +float2 __ovld __cnfn convert_float2_rtz(ulong2); +float2 __ovld __cnfn convert_float2_rtp(ulong2); +float2 __ovld __cnfn convert_float2_rtn(ulong2); +float2 __ovld __cnfn convert_float2(ulong2); +float2 __ovld __cnfn convert_float2_rte(float2); +float2 __ovld __cnfn convert_float2_rtz(float2); +float2 __ovld __cnfn convert_float2_rtp(float2); +float2 __ovld __cnfn convert_float2_rtn(float2); +float2 __ovld __cnfn convert_float2(float2); +char3 __ovld __cnfn convert_char3_rte(char3); +char3 __ovld __cnfn convert_char3_sat_rte(char3); +char3 __ovld __cnfn convert_char3_rtz(char3); +char3 __ovld __cnfn convert_char3_sat_rtz(char3); +char3 __ovld __cnfn convert_char3_rtp(char3); +char3 __ovld __cnfn convert_char3_sat_rtp(char3); +char3 __ovld __cnfn convert_char3_rtn(char3); +char3 __ovld __cnfn convert_char3_sat_rtn(char3); +char3 __ovld __cnfn convert_char3(char3); +char3 __ovld __cnfn convert_char3_sat(char3); +char3 __ovld __cnfn convert_char3_rte(uchar3); +char3 __ovld __cnfn convert_char3_sat_rte(uchar3); +char3 __ovld __cnfn convert_char3_rtz(uchar3); +char3 __ovld __cnfn convert_char3_sat_rtz(uchar3); +char3 __ovld __cnfn convert_char3_rtp(uchar3); +char3 __ovld __cnfn convert_char3_sat_rtp(uchar3); +char3 __ovld __cnfn convert_char3_rtn(uchar3); +char3 __ovld __cnfn convert_char3_sat_rtn(uchar3); +char3 __ovld __cnfn convert_char3(uchar3); +char3 __ovld __cnfn convert_char3_sat(uchar3); +char3 __ovld __cnfn convert_char3_rte(short3); +char3 __ovld __cnfn convert_char3_sat_rte(short3); +char3 __ovld __cnfn convert_char3_rtz(short3); +char3 __ovld __cnfn convert_char3_sat_rtz(short3); +char3 __ovld __cnfn convert_char3_rtp(short3); +char3 __ovld __cnfn convert_char3_sat_rtp(short3); +char3 __ovld __cnfn convert_char3_rtn(short3); +char3 __ovld __cnfn convert_char3_sat_rtn(short3); +char3 __ovld __cnfn convert_char3(short3); +char3 __ovld __cnfn convert_char3_sat(short3); +char3 __ovld __cnfn convert_char3_rte(ushort3); +char3 __ovld __cnfn convert_char3_sat_rte(ushort3); +char3 __ovld __cnfn convert_char3_rtz(ushort3); +char3 __ovld __cnfn convert_char3_sat_rtz(ushort3); +char3 __ovld __cnfn convert_char3_rtp(ushort3); +char3 __ovld __cnfn convert_char3_sat_rtp(ushort3); +char3 __ovld __cnfn convert_char3_rtn(ushort3); +char3 __ovld __cnfn convert_char3_sat_rtn(ushort3); +char3 __ovld __cnfn convert_char3(ushort3); +char3 __ovld __cnfn convert_char3_sat(ushort3); +char3 __ovld __cnfn convert_char3_rte(int3); +char3 __ovld __cnfn convert_char3_sat_rte(int3); +char3 __ovld __cnfn convert_char3_rtz(int3); +char3 __ovld __cnfn convert_char3_sat_rtz(int3); +char3 __ovld __cnfn convert_char3_rtp(int3); +char3 __ovld __cnfn convert_char3_sat_rtp(int3); +char3 __ovld __cnfn convert_char3_rtn(int3); +char3 __ovld __cnfn convert_char3_sat_rtn(int3); +char3 __ovld __cnfn convert_char3(int3); +char3 __ovld __cnfn convert_char3_sat(int3); +char3 __ovld __cnfn convert_char3_rte(uint3); +char3 __ovld __cnfn convert_char3_sat_rte(uint3); +char3 __ovld __cnfn convert_char3_rtz(uint3); +char3 __ovld __cnfn convert_char3_sat_rtz(uint3); +char3 __ovld __cnfn convert_char3_rtp(uint3); +char3 __ovld __cnfn convert_char3_sat_rtp(uint3); +char3 __ovld __cnfn convert_char3_rtn(uint3); +char3 __ovld __cnfn convert_char3_sat_rtn(uint3); +char3 __ovld __cnfn convert_char3(uint3); +char3 __ovld __cnfn convert_char3_sat(uint3); +char3 __ovld __cnfn convert_char3_rte(long3); +char3 __ovld __cnfn convert_char3_sat_rte(long3); +char3 __ovld __cnfn convert_char3_rtz(long3); +char3 __ovld __cnfn convert_char3_sat_rtz(long3); +char3 __ovld __cnfn convert_char3_rtp(long3); +char3 __ovld __cnfn convert_char3_sat_rtp(long3); +char3 __ovld __cnfn convert_char3_rtn(long3); +char3 __ovld __cnfn convert_char3_sat_rtn(long3); +char3 __ovld __cnfn convert_char3(long3); +char3 __ovld __cnfn convert_char3_sat(long3); +char3 __ovld __cnfn convert_char3_rte(ulong3); +char3 __ovld __cnfn convert_char3_sat_rte(ulong3); +char3 __ovld __cnfn convert_char3_rtz(ulong3); +char3 __ovld __cnfn convert_char3_sat_rtz(ulong3); +char3 __ovld __cnfn convert_char3_rtp(ulong3); +char3 __ovld __cnfn convert_char3_sat_rtp(ulong3); +char3 __ovld __cnfn convert_char3_rtn(ulong3); +char3 __ovld __cnfn convert_char3_sat_rtn(ulong3); +char3 __ovld __cnfn convert_char3(ulong3); +char3 __ovld __cnfn convert_char3_sat(ulong3); +char3 __ovld __cnfn convert_char3_rte(float3); +char3 __ovld __cnfn convert_char3_sat_rte(float3); +char3 __ovld __cnfn convert_char3_rtz(float3); +char3 __ovld __cnfn convert_char3_sat_rtz(float3); +char3 __ovld __cnfn convert_char3_rtp(float3); +char3 __ovld __cnfn convert_char3_sat_rtp(float3); +char3 __ovld __cnfn convert_char3_rtn(float3); +char3 __ovld __cnfn convert_char3_sat_rtn(float3); +char3 __ovld __cnfn convert_char3(float3); +char3 __ovld __cnfn convert_char3_sat(float3); +uchar3 __ovld __cnfn convert_uchar3_rte(char3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(char3); +uchar3 __ovld __cnfn convert_uchar3_rtz(char3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(char3); +uchar3 __ovld __cnfn convert_uchar3_rtp(char3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(char3); +uchar3 __ovld __cnfn convert_uchar3_rtn(char3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(char3); +uchar3 __ovld __cnfn convert_uchar3(char3); +uchar3 __ovld __cnfn convert_uchar3_sat(char3); +uchar3 __ovld __cnfn convert_uchar3_rte(uchar3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(uchar3); +uchar3 __ovld __cnfn convert_uchar3_rtz(uchar3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(uchar3); +uchar3 __ovld __cnfn convert_uchar3_rtp(uchar3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(uchar3); +uchar3 __ovld __cnfn convert_uchar3_rtn(uchar3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(uchar3); +uchar3 __ovld __cnfn convert_uchar3(uchar3); +uchar3 __ovld __cnfn convert_uchar3_sat(uchar3); +uchar3 __ovld __cnfn convert_uchar3_rte(short3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(short3); +uchar3 __ovld __cnfn convert_uchar3_rtz(short3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(short3); +uchar3 __ovld __cnfn convert_uchar3_rtp(short3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(short3); +uchar3 __ovld __cnfn convert_uchar3_rtn(short3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(short3); +uchar3 __ovld __cnfn convert_uchar3(short3); +uchar3 __ovld __cnfn convert_uchar3_sat(short3); +uchar3 __ovld __cnfn convert_uchar3_rte(ushort3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(ushort3); +uchar3 __ovld __cnfn convert_uchar3_rtz(ushort3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(ushort3); +uchar3 __ovld __cnfn convert_uchar3_rtp(ushort3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(ushort3); +uchar3 __ovld __cnfn convert_uchar3_rtn(ushort3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(ushort3); +uchar3 __ovld __cnfn convert_uchar3(ushort3); +uchar3 __ovld __cnfn convert_uchar3_sat(ushort3); +uchar3 __ovld __cnfn convert_uchar3_rte(int3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(int3); +uchar3 __ovld __cnfn convert_uchar3_rtz(int3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(int3); +uchar3 __ovld __cnfn convert_uchar3_rtp(int3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(int3); +uchar3 __ovld __cnfn convert_uchar3_rtn(int3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(int3); +uchar3 __ovld __cnfn convert_uchar3(int3); +uchar3 __ovld __cnfn convert_uchar3_sat(int3); +uchar3 __ovld __cnfn convert_uchar3_rte(uint3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(uint3); +uchar3 __ovld __cnfn convert_uchar3_rtz(uint3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(uint3); +uchar3 __ovld __cnfn convert_uchar3_rtp(uint3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(uint3); +uchar3 __ovld __cnfn convert_uchar3_rtn(uint3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(uint3); +uchar3 __ovld __cnfn convert_uchar3(uint3); +uchar3 __ovld __cnfn convert_uchar3_sat(uint3); +uchar3 __ovld __cnfn convert_uchar3_rte(long3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(long3); +uchar3 __ovld __cnfn convert_uchar3_rtz(long3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(long3); +uchar3 __ovld __cnfn convert_uchar3_rtp(long3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(long3); +uchar3 __ovld __cnfn convert_uchar3_rtn(long3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(long3); +uchar3 __ovld __cnfn convert_uchar3(long3); +uchar3 __ovld __cnfn convert_uchar3_sat(long3); +uchar3 __ovld __cnfn convert_uchar3_rte(ulong3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(ulong3); +uchar3 __ovld __cnfn convert_uchar3_rtz(ulong3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(ulong3); +uchar3 __ovld __cnfn convert_uchar3_rtp(ulong3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(ulong3); +uchar3 __ovld __cnfn convert_uchar3_rtn(ulong3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(ulong3); +uchar3 __ovld __cnfn convert_uchar3(ulong3); +uchar3 __ovld __cnfn convert_uchar3_sat(ulong3); +uchar3 __ovld __cnfn convert_uchar3_rte(float3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(float3); +uchar3 __ovld __cnfn convert_uchar3_rtz(float3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(float3); +uchar3 __ovld __cnfn convert_uchar3_rtp(float3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(float3); +uchar3 __ovld __cnfn convert_uchar3_rtn(float3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(float3); +uchar3 __ovld __cnfn convert_uchar3(float3); +uchar3 __ovld __cnfn convert_uchar3_sat(float3); +short3 __ovld __cnfn convert_short3_rte(char3); +short3 __ovld __cnfn convert_short3_sat_rte(char3); +short3 __ovld __cnfn convert_short3_rtz(char3); +short3 __ovld __cnfn convert_short3_sat_rtz(char3); +short3 __ovld __cnfn convert_short3_rtp(char3); +short3 __ovld __cnfn convert_short3_sat_rtp(char3); +short3 __ovld __cnfn convert_short3_rtn(char3); +short3 __ovld __cnfn convert_short3_sat_rtn(char3); +short3 __ovld __cnfn convert_short3(char3); +short3 __ovld __cnfn convert_short3_sat(char3); +short3 __ovld __cnfn convert_short3_rte(uchar3); +short3 __ovld __cnfn convert_short3_sat_rte(uchar3); +short3 __ovld __cnfn convert_short3_rtz(uchar3); +short3 __ovld __cnfn convert_short3_sat_rtz(uchar3); +short3 __ovld __cnfn convert_short3_rtp(uchar3); +short3 __ovld __cnfn convert_short3_sat_rtp(uchar3); +short3 __ovld __cnfn convert_short3_rtn(uchar3); +short3 __ovld __cnfn convert_short3_sat_rtn(uchar3); +short3 __ovld __cnfn convert_short3(uchar3); +short3 __ovld __cnfn convert_short3_sat(uchar3); +short3 __ovld __cnfn convert_short3_rte(short3); +short3 __ovld __cnfn convert_short3_sat_rte(short3); +short3 __ovld __cnfn convert_short3_rtz(short3); +short3 __ovld __cnfn convert_short3_sat_rtz(short3); +short3 __ovld __cnfn convert_short3_rtp(short3); +short3 __ovld __cnfn convert_short3_sat_rtp(short3); +short3 __ovld __cnfn convert_short3_rtn(short3); +short3 __ovld __cnfn convert_short3_sat_rtn(short3); +short3 __ovld __cnfn convert_short3(short3); +short3 __ovld __cnfn convert_short3_sat(short3); +short3 __ovld __cnfn convert_short3_rte(ushort3); +short3 __ovld __cnfn convert_short3_sat_rte(ushort3); +short3 __ovld __cnfn convert_short3_rtz(ushort3); +short3 __ovld __cnfn convert_short3_sat_rtz(ushort3); +short3 __ovld __cnfn convert_short3_rtp(ushort3); +short3 __ovld __cnfn convert_short3_sat_rtp(ushort3); +short3 __ovld __cnfn convert_short3_rtn(ushort3); +short3 __ovld __cnfn convert_short3_sat_rtn(ushort3); +short3 __ovld __cnfn convert_short3(ushort3); +short3 __ovld __cnfn convert_short3_sat(ushort3); +short3 __ovld __cnfn convert_short3_rte(int3); +short3 __ovld __cnfn convert_short3_sat_rte(int3); +short3 __ovld __cnfn convert_short3_rtz(int3); +short3 __ovld __cnfn convert_short3_sat_rtz(int3); +short3 __ovld __cnfn convert_short3_rtp(int3); +short3 __ovld __cnfn convert_short3_sat_rtp(int3); +short3 __ovld __cnfn convert_short3_rtn(int3); +short3 __ovld __cnfn convert_short3_sat_rtn(int3); +short3 __ovld __cnfn convert_short3(int3); +short3 __ovld __cnfn convert_short3_sat(int3); +short3 __ovld __cnfn convert_short3_rte(uint3); +short3 __ovld __cnfn convert_short3_sat_rte(uint3); +short3 __ovld __cnfn convert_short3_rtz(uint3); +short3 __ovld __cnfn convert_short3_sat_rtz(uint3); +short3 __ovld __cnfn convert_short3_rtp(uint3); +short3 __ovld __cnfn convert_short3_sat_rtp(uint3); +short3 __ovld __cnfn convert_short3_rtn(uint3); +short3 __ovld __cnfn convert_short3_sat_rtn(uint3); +short3 __ovld __cnfn convert_short3(uint3); +short3 __ovld __cnfn convert_short3_sat(uint3); +short3 __ovld __cnfn convert_short3_rte(long3); +short3 __ovld __cnfn convert_short3_sat_rte(long3); +short3 __ovld __cnfn convert_short3_rtz(long3); +short3 __ovld __cnfn convert_short3_sat_rtz(long3); +short3 __ovld __cnfn convert_short3_rtp(long3); +short3 __ovld __cnfn convert_short3_sat_rtp(long3); +short3 __ovld __cnfn convert_short3_rtn(long3); +short3 __ovld __cnfn convert_short3_sat_rtn(long3); +short3 __ovld __cnfn convert_short3(long3); +short3 __ovld __cnfn convert_short3_sat(long3); +short3 __ovld __cnfn convert_short3_rte(ulong3); +short3 __ovld __cnfn convert_short3_sat_rte(ulong3); +short3 __ovld __cnfn convert_short3_rtz(ulong3); +short3 __ovld __cnfn convert_short3_sat_rtz(ulong3); +short3 __ovld __cnfn convert_short3_rtp(ulong3); +short3 __ovld __cnfn convert_short3_sat_rtp(ulong3); +short3 __ovld __cnfn convert_short3_rtn(ulong3); +short3 __ovld __cnfn convert_short3_sat_rtn(ulong3); +short3 __ovld __cnfn convert_short3(ulong3); +short3 __ovld __cnfn convert_short3_sat(ulong3); +short3 __ovld __cnfn convert_short3_rte(float3); +short3 __ovld __cnfn convert_short3_sat_rte(float3); +short3 __ovld __cnfn convert_short3_rtz(float3); +short3 __ovld __cnfn convert_short3_sat_rtz(float3); +short3 __ovld __cnfn convert_short3_rtp(float3); +short3 __ovld __cnfn convert_short3_sat_rtp(float3); +short3 __ovld __cnfn convert_short3_rtn(float3); +short3 __ovld __cnfn convert_short3_sat_rtn(float3); +short3 __ovld __cnfn convert_short3(float3); +short3 __ovld __cnfn convert_short3_sat(float3); +ushort3 __ovld __cnfn convert_ushort3_rte(char3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(char3); +ushort3 __ovld __cnfn convert_ushort3_rtz(char3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(char3); +ushort3 __ovld __cnfn convert_ushort3_rtp(char3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(char3); +ushort3 __ovld __cnfn convert_ushort3_rtn(char3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(char3); +ushort3 __ovld __cnfn convert_ushort3(char3); +ushort3 __ovld __cnfn convert_ushort3_sat(char3); +ushort3 __ovld __cnfn convert_ushort3_rte(uchar3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(uchar3); +ushort3 __ovld __cnfn convert_ushort3_rtz(uchar3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(uchar3); +ushort3 __ovld __cnfn convert_ushort3_rtp(uchar3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(uchar3); +ushort3 __ovld __cnfn convert_ushort3_rtn(uchar3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(uchar3); +ushort3 __ovld __cnfn convert_ushort3(uchar3); +ushort3 __ovld __cnfn convert_ushort3_sat(uchar3); +ushort3 __ovld __cnfn convert_ushort3_rte(short3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(short3); +ushort3 __ovld __cnfn convert_ushort3_rtz(short3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(short3); +ushort3 __ovld __cnfn convert_ushort3_rtp(short3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(short3); +ushort3 __ovld __cnfn convert_ushort3_rtn(short3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(short3); +ushort3 __ovld __cnfn convert_ushort3(short3); +ushort3 __ovld __cnfn convert_ushort3_sat(short3); +ushort3 __ovld __cnfn convert_ushort3_rte(ushort3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(ushort3); +ushort3 __ovld __cnfn convert_ushort3_rtz(ushort3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(ushort3); +ushort3 __ovld __cnfn convert_ushort3_rtp(ushort3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(ushort3); +ushort3 __ovld __cnfn convert_ushort3_rtn(ushort3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(ushort3); +ushort3 __ovld __cnfn convert_ushort3(ushort3); +ushort3 __ovld __cnfn convert_ushort3_sat(ushort3); +ushort3 __ovld __cnfn convert_ushort3_rte(int3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(int3); +ushort3 __ovld __cnfn convert_ushort3_rtz(int3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(int3); +ushort3 __ovld __cnfn convert_ushort3_rtp(int3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(int3); +ushort3 __ovld __cnfn convert_ushort3_rtn(int3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(int3); +ushort3 __ovld __cnfn convert_ushort3(int3); +ushort3 __ovld __cnfn convert_ushort3_sat(int3); +ushort3 __ovld __cnfn convert_ushort3_rte(uint3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(uint3); +ushort3 __ovld __cnfn convert_ushort3_rtz(uint3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(uint3); +ushort3 __ovld __cnfn convert_ushort3_rtp(uint3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(uint3); +ushort3 __ovld __cnfn convert_ushort3_rtn(uint3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(uint3); +ushort3 __ovld __cnfn convert_ushort3(uint3); +ushort3 __ovld __cnfn convert_ushort3_sat(uint3); +ushort3 __ovld __cnfn convert_ushort3_rte(long3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(long3); +ushort3 __ovld __cnfn convert_ushort3_rtz(long3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(long3); +ushort3 __ovld __cnfn convert_ushort3_rtp(long3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(long3); +ushort3 __ovld __cnfn convert_ushort3_rtn(long3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(long3); +ushort3 __ovld __cnfn convert_ushort3(long3); +ushort3 __ovld __cnfn convert_ushort3_sat(long3); +ushort3 __ovld __cnfn convert_ushort3_rte(ulong3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(ulong3); +ushort3 __ovld __cnfn convert_ushort3_rtz(ulong3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(ulong3); +ushort3 __ovld __cnfn convert_ushort3_rtp(ulong3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(ulong3); +ushort3 __ovld __cnfn convert_ushort3_rtn(ulong3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(ulong3); +ushort3 __ovld __cnfn convert_ushort3(ulong3); +ushort3 __ovld __cnfn convert_ushort3_sat(ulong3); +ushort3 __ovld __cnfn convert_ushort3_rte(float3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(float3); +ushort3 __ovld __cnfn convert_ushort3_rtz(float3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(float3); +ushort3 __ovld __cnfn convert_ushort3_rtp(float3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(float3); +ushort3 __ovld __cnfn convert_ushort3_rtn(float3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(float3); +ushort3 __ovld __cnfn convert_ushort3(float3); +ushort3 __ovld __cnfn convert_ushort3_sat(float3); +int3 __ovld __cnfn convert_int3_rte(char3); +int3 __ovld __cnfn convert_int3_sat_rte(char3); +int3 __ovld __cnfn convert_int3_rtz(char3); +int3 __ovld __cnfn convert_int3_sat_rtz(char3); +int3 __ovld __cnfn convert_int3_rtp(char3); +int3 __ovld __cnfn convert_int3_sat_rtp(char3); +int3 __ovld __cnfn convert_int3_rtn(char3); +int3 __ovld __cnfn convert_int3_sat_rtn(char3); +int3 __ovld __cnfn convert_int3(char3); +int3 __ovld __cnfn convert_int3_sat(char3); +int3 __ovld __cnfn convert_int3_rte(uchar3); +int3 __ovld __cnfn convert_int3_sat_rte(uchar3); +int3 __ovld __cnfn convert_int3_rtz(uchar3); +int3 __ovld __cnfn convert_int3_sat_rtz(uchar3); +int3 __ovld __cnfn convert_int3_rtp(uchar3); +int3 __ovld __cnfn convert_int3_sat_rtp(uchar3); +int3 __ovld __cnfn convert_int3_rtn(uchar3); +int3 __ovld __cnfn convert_int3_sat_rtn(uchar3); +int3 __ovld __cnfn convert_int3(uchar3); +int3 __ovld __cnfn convert_int3_sat(uchar3); +int3 __ovld __cnfn convert_int3_rte(short3); +int3 __ovld __cnfn convert_int3_sat_rte(short3); +int3 __ovld __cnfn convert_int3_rtz(short3); +int3 __ovld __cnfn convert_int3_sat_rtz(short3); +int3 __ovld __cnfn convert_int3_rtp(short3); +int3 __ovld __cnfn convert_int3_sat_rtp(short3); +int3 __ovld __cnfn convert_int3_rtn(short3); +int3 __ovld __cnfn convert_int3_sat_rtn(short3); +int3 __ovld __cnfn convert_int3(short3); +int3 __ovld __cnfn convert_int3_sat(short3); +int3 __ovld __cnfn convert_int3_rte(ushort3); +int3 __ovld __cnfn convert_int3_sat_rte(ushort3); +int3 __ovld __cnfn convert_int3_rtz(ushort3); +int3 __ovld __cnfn convert_int3_sat_rtz(ushort3); +int3 __ovld __cnfn convert_int3_rtp(ushort3); +int3 __ovld __cnfn convert_int3_sat_rtp(ushort3); +int3 __ovld __cnfn convert_int3_rtn(ushort3); +int3 __ovld __cnfn convert_int3_sat_rtn(ushort3); +int3 __ovld __cnfn convert_int3(ushort3); +int3 __ovld __cnfn convert_int3_sat(ushort3); +int3 __ovld __cnfn convert_int3_rte(int3); +int3 __ovld __cnfn convert_int3_sat_rte(int3); +int3 __ovld __cnfn convert_int3_rtz(int3); +int3 __ovld __cnfn convert_int3_sat_rtz(int3); +int3 __ovld __cnfn convert_int3_rtp(int3); +int3 __ovld __cnfn convert_int3_sat_rtp(int3); +int3 __ovld __cnfn convert_int3_rtn(int3); +int3 __ovld __cnfn convert_int3_sat_rtn(int3); +int3 __ovld __cnfn convert_int3(int3); +int3 __ovld __cnfn convert_int3_sat(int3); +int3 __ovld __cnfn convert_int3_rte(uint3); +int3 __ovld __cnfn convert_int3_sat_rte(uint3); +int3 __ovld __cnfn convert_int3_rtz(uint3); +int3 __ovld __cnfn convert_int3_sat_rtz(uint3); +int3 __ovld __cnfn convert_int3_rtp(uint3); +int3 __ovld __cnfn convert_int3_sat_rtp(uint3); +int3 __ovld __cnfn convert_int3_rtn(uint3); +int3 __ovld __cnfn convert_int3_sat_rtn(uint3); +int3 __ovld __cnfn convert_int3(uint3); +int3 __ovld __cnfn convert_int3_sat(uint3); +int3 __ovld __cnfn convert_int3_rte(long3); +int3 __ovld __cnfn convert_int3_sat_rte(long3); +int3 __ovld __cnfn convert_int3_rtz(long3); +int3 __ovld __cnfn convert_int3_sat_rtz(long3); +int3 __ovld __cnfn convert_int3_rtp(long3); +int3 __ovld __cnfn convert_int3_sat_rtp(long3); +int3 __ovld __cnfn convert_int3_rtn(long3); +int3 __ovld __cnfn convert_int3_sat_rtn(long3); +int3 __ovld __cnfn convert_int3(long3); +int3 __ovld __cnfn convert_int3_sat(long3); +int3 __ovld __cnfn convert_int3_rte(ulong3); +int3 __ovld __cnfn convert_int3_sat_rte(ulong3); +int3 __ovld __cnfn convert_int3_rtz(ulong3); +int3 __ovld __cnfn convert_int3_sat_rtz(ulong3); +int3 __ovld __cnfn convert_int3_rtp(ulong3); +int3 __ovld __cnfn convert_int3_sat_rtp(ulong3); +int3 __ovld __cnfn convert_int3_rtn(ulong3); +int3 __ovld __cnfn convert_int3_sat_rtn(ulong3); +int3 __ovld __cnfn convert_int3(ulong3); +int3 __ovld __cnfn convert_int3_sat(ulong3); +int3 __ovld __cnfn convert_int3_rte(float3); +int3 __ovld __cnfn convert_int3_sat_rte(float3); +int3 __ovld __cnfn convert_int3_rtz(float3); +int3 __ovld __cnfn convert_int3_sat_rtz(float3); +int3 __ovld __cnfn convert_int3_rtp(float3); +int3 __ovld __cnfn convert_int3_sat_rtp(float3); +int3 __ovld __cnfn convert_int3_rtn(float3); +int3 __ovld __cnfn convert_int3_sat_rtn(float3); +int3 __ovld __cnfn convert_int3(float3); +int3 __ovld __cnfn convert_int3_sat(float3); +uint3 __ovld __cnfn convert_uint3_rte(char3); +uint3 __ovld __cnfn convert_uint3_sat_rte(char3); +uint3 __ovld __cnfn convert_uint3_rtz(char3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(char3); +uint3 __ovld __cnfn convert_uint3_rtp(char3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(char3); +uint3 __ovld __cnfn convert_uint3_rtn(char3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(char3); +uint3 __ovld __cnfn convert_uint3(char3); +uint3 __ovld __cnfn convert_uint3_sat(char3); +uint3 __ovld __cnfn convert_uint3_rte(uchar3); +uint3 __ovld __cnfn convert_uint3_sat_rte(uchar3); +uint3 __ovld __cnfn convert_uint3_rtz(uchar3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(uchar3); +uint3 __ovld __cnfn convert_uint3_rtp(uchar3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(uchar3); +uint3 __ovld __cnfn convert_uint3_rtn(uchar3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(uchar3); +uint3 __ovld __cnfn convert_uint3(uchar3); +uint3 __ovld __cnfn convert_uint3_sat(uchar3); +uint3 __ovld __cnfn convert_uint3_rte(short3); +uint3 __ovld __cnfn convert_uint3_sat_rte(short3); +uint3 __ovld __cnfn convert_uint3_rtz(short3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(short3); +uint3 __ovld __cnfn convert_uint3_rtp(short3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(short3); +uint3 __ovld __cnfn convert_uint3_rtn(short3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(short3); +uint3 __ovld __cnfn convert_uint3(short3); +uint3 __ovld __cnfn convert_uint3_sat(short3); +uint3 __ovld __cnfn convert_uint3_rte(ushort3); +uint3 __ovld __cnfn convert_uint3_sat_rte(ushort3); +uint3 __ovld __cnfn convert_uint3_rtz(ushort3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(ushort3); +uint3 __ovld __cnfn convert_uint3_rtp(ushort3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(ushort3); +uint3 __ovld __cnfn convert_uint3_rtn(ushort3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(ushort3); +uint3 __ovld __cnfn convert_uint3(ushort3); +uint3 __ovld __cnfn convert_uint3_sat(ushort3); +uint3 __ovld __cnfn convert_uint3_rte(int3); +uint3 __ovld __cnfn convert_uint3_sat_rte(int3); +uint3 __ovld __cnfn convert_uint3_rtz(int3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(int3); +uint3 __ovld __cnfn convert_uint3_rtp(int3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(int3); +uint3 __ovld __cnfn convert_uint3_rtn(int3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(int3); +uint3 __ovld __cnfn convert_uint3(int3); +uint3 __ovld __cnfn convert_uint3_sat(int3); +uint3 __ovld __cnfn convert_uint3_rte(uint3); +uint3 __ovld __cnfn convert_uint3_sat_rte(uint3); +uint3 __ovld __cnfn convert_uint3_rtz(uint3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(uint3); +uint3 __ovld __cnfn convert_uint3_rtp(uint3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(uint3); +uint3 __ovld __cnfn convert_uint3_rtn(uint3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(uint3); +uint3 __ovld __cnfn convert_uint3(uint3); +uint3 __ovld __cnfn convert_uint3_sat(uint3); +uint3 __ovld __cnfn convert_uint3_rte(long3); +uint3 __ovld __cnfn convert_uint3_sat_rte(long3); +uint3 __ovld __cnfn convert_uint3_rtz(long3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(long3); +uint3 __ovld __cnfn convert_uint3_rtp(long3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(long3); +uint3 __ovld __cnfn convert_uint3_rtn(long3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(long3); +uint3 __ovld __cnfn convert_uint3(long3); +uint3 __ovld __cnfn convert_uint3_sat(long3); +uint3 __ovld __cnfn convert_uint3_rte(ulong3); +uint3 __ovld __cnfn convert_uint3_sat_rte(ulong3); +uint3 __ovld __cnfn convert_uint3_rtz(ulong3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(ulong3); +uint3 __ovld __cnfn convert_uint3_rtp(ulong3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(ulong3); +uint3 __ovld __cnfn convert_uint3_rtn(ulong3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(ulong3); +uint3 __ovld __cnfn convert_uint3(ulong3); +uint3 __ovld __cnfn convert_uint3_sat(ulong3); +uint3 __ovld __cnfn convert_uint3_rte(float3); +uint3 __ovld __cnfn convert_uint3_sat_rte(float3); +uint3 __ovld __cnfn convert_uint3_rtz(float3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(float3); +uint3 __ovld __cnfn convert_uint3_rtp(float3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(float3); +uint3 __ovld __cnfn convert_uint3_rtn(float3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(float3); +uint3 __ovld __cnfn convert_uint3(float3); +uint3 __ovld __cnfn convert_uint3_sat(float3); +long3 __ovld __cnfn convert_long3_rte(char3); +long3 __ovld __cnfn convert_long3_sat_rte(char3); +long3 __ovld __cnfn convert_long3_rtz(char3); +long3 __ovld __cnfn convert_long3_sat_rtz(char3); +long3 __ovld __cnfn convert_long3_rtp(char3); +long3 __ovld __cnfn convert_long3_sat_rtp(char3); +long3 __ovld __cnfn convert_long3_rtn(char3); +long3 __ovld __cnfn convert_long3_sat_rtn(char3); +long3 __ovld __cnfn convert_long3(char3); +long3 __ovld __cnfn convert_long3_sat(char3); +long3 __ovld __cnfn convert_long3_rte(uchar3); +long3 __ovld __cnfn convert_long3_sat_rte(uchar3); +long3 __ovld __cnfn convert_long3_rtz(uchar3); +long3 __ovld __cnfn convert_long3_sat_rtz(uchar3); +long3 __ovld __cnfn convert_long3_rtp(uchar3); +long3 __ovld __cnfn convert_long3_sat_rtp(uchar3); +long3 __ovld __cnfn convert_long3_rtn(uchar3); +long3 __ovld __cnfn convert_long3_sat_rtn(uchar3); +long3 __ovld __cnfn convert_long3(uchar3); +long3 __ovld __cnfn convert_long3_sat(uchar3); +long3 __ovld __cnfn convert_long3_rte(short3); +long3 __ovld __cnfn convert_long3_sat_rte(short3); +long3 __ovld __cnfn convert_long3_rtz(short3); +long3 __ovld __cnfn convert_long3_sat_rtz(short3); +long3 __ovld __cnfn convert_long3_rtp(short3); +long3 __ovld __cnfn convert_long3_sat_rtp(short3); +long3 __ovld __cnfn convert_long3_rtn(short3); +long3 __ovld __cnfn convert_long3_sat_rtn(short3); +long3 __ovld __cnfn convert_long3(short3); +long3 __ovld __cnfn convert_long3_sat(short3); +long3 __ovld __cnfn convert_long3_rte(ushort3); +long3 __ovld __cnfn convert_long3_sat_rte(ushort3); +long3 __ovld __cnfn convert_long3_rtz(ushort3); +long3 __ovld __cnfn convert_long3_sat_rtz(ushort3); +long3 __ovld __cnfn convert_long3_rtp(ushort3); +long3 __ovld __cnfn convert_long3_sat_rtp(ushort3); +long3 __ovld __cnfn convert_long3_rtn(ushort3); +long3 __ovld __cnfn convert_long3_sat_rtn(ushort3); +long3 __ovld __cnfn convert_long3(ushort3); +long3 __ovld __cnfn convert_long3_sat(ushort3); +long3 __ovld __cnfn convert_long3_rte(int3); +long3 __ovld __cnfn convert_long3_sat_rte(int3); +long3 __ovld __cnfn convert_long3_rtz(int3); +long3 __ovld __cnfn convert_long3_sat_rtz(int3); +long3 __ovld __cnfn convert_long3_rtp(int3); +long3 __ovld __cnfn convert_long3_sat_rtp(int3); +long3 __ovld __cnfn convert_long3_rtn(int3); +long3 __ovld __cnfn convert_long3_sat_rtn(int3); +long3 __ovld __cnfn convert_long3(int3); +long3 __ovld __cnfn convert_long3_sat(int3); +long3 __ovld __cnfn convert_long3_rte(uint3); +long3 __ovld __cnfn convert_long3_sat_rte(uint3); +long3 __ovld __cnfn convert_long3_rtz(uint3); +long3 __ovld __cnfn convert_long3_sat_rtz(uint3); +long3 __ovld __cnfn convert_long3_rtp(uint3); +long3 __ovld __cnfn convert_long3_sat_rtp(uint3); +long3 __ovld __cnfn convert_long3_rtn(uint3); +long3 __ovld __cnfn convert_long3_sat_rtn(uint3); +long3 __ovld __cnfn convert_long3(uint3); +long3 __ovld __cnfn convert_long3_sat(uint3); +long3 __ovld __cnfn convert_long3_rte(long3); +long3 __ovld __cnfn convert_long3_sat_rte(long3); +long3 __ovld __cnfn convert_long3_rtz(long3); +long3 __ovld __cnfn convert_long3_sat_rtz(long3); +long3 __ovld __cnfn convert_long3_rtp(long3); +long3 __ovld __cnfn convert_long3_sat_rtp(long3); +long3 __ovld __cnfn convert_long3_rtn(long3); +long3 __ovld __cnfn convert_long3_sat_rtn(long3); +long3 __ovld __cnfn convert_long3(long3); +long3 __ovld __cnfn convert_long3_sat(long3); +long3 __ovld __cnfn convert_long3_rte(ulong3); +long3 __ovld __cnfn convert_long3_sat_rte(ulong3); +long3 __ovld __cnfn convert_long3_rtz(ulong3); +long3 __ovld __cnfn convert_long3_sat_rtz(ulong3); +long3 __ovld __cnfn convert_long3_rtp(ulong3); +long3 __ovld __cnfn convert_long3_sat_rtp(ulong3); +long3 __ovld __cnfn convert_long3_rtn(ulong3); +long3 __ovld __cnfn convert_long3_sat_rtn(ulong3); +long3 __ovld __cnfn convert_long3(ulong3); +long3 __ovld __cnfn convert_long3_sat(ulong3); +long3 __ovld __cnfn convert_long3_rte(float3); +long3 __ovld __cnfn convert_long3_sat_rte(float3); +long3 __ovld __cnfn convert_long3_rtz(float3); +long3 __ovld __cnfn convert_long3_sat_rtz(float3); +long3 __ovld __cnfn convert_long3_rtp(float3); +long3 __ovld __cnfn convert_long3_sat_rtp(float3); +long3 __ovld __cnfn convert_long3_rtn(float3); +long3 __ovld __cnfn convert_long3_sat_rtn(float3); +long3 __ovld __cnfn convert_long3(float3); +long3 __ovld __cnfn convert_long3_sat(float3); +ulong3 __ovld __cnfn convert_ulong3_rte(char3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(char3); +ulong3 __ovld __cnfn convert_ulong3_rtz(char3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(char3); +ulong3 __ovld __cnfn convert_ulong3_rtp(char3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(char3); +ulong3 __ovld __cnfn convert_ulong3_rtn(char3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(char3); +ulong3 __ovld __cnfn convert_ulong3(char3); +ulong3 __ovld __cnfn convert_ulong3_sat(char3); +ulong3 __ovld __cnfn convert_ulong3_rte(uchar3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(uchar3); +ulong3 __ovld __cnfn convert_ulong3_rtz(uchar3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(uchar3); +ulong3 __ovld __cnfn convert_ulong3_rtp(uchar3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(uchar3); +ulong3 __ovld __cnfn convert_ulong3_rtn(uchar3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(uchar3); +ulong3 __ovld __cnfn convert_ulong3(uchar3); +ulong3 __ovld __cnfn convert_ulong3_sat(uchar3); +ulong3 __ovld __cnfn convert_ulong3_rte(short3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(short3); +ulong3 __ovld __cnfn convert_ulong3_rtz(short3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(short3); +ulong3 __ovld __cnfn convert_ulong3_rtp(short3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(short3); +ulong3 __ovld __cnfn convert_ulong3_rtn(short3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(short3); +ulong3 __ovld __cnfn convert_ulong3(short3); +ulong3 __ovld __cnfn convert_ulong3_sat(short3); +ulong3 __ovld __cnfn convert_ulong3_rte(ushort3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(ushort3); +ulong3 __ovld __cnfn convert_ulong3_rtz(ushort3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(ushort3); +ulong3 __ovld __cnfn convert_ulong3_rtp(ushort3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(ushort3); +ulong3 __ovld __cnfn convert_ulong3_rtn(ushort3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(ushort3); +ulong3 __ovld __cnfn convert_ulong3(ushort3); +ulong3 __ovld __cnfn convert_ulong3_sat(ushort3); +ulong3 __ovld __cnfn convert_ulong3_rte(int3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(int3); +ulong3 __ovld __cnfn convert_ulong3_rtz(int3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(int3); +ulong3 __ovld __cnfn convert_ulong3_rtp(int3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(int3); +ulong3 __ovld __cnfn convert_ulong3_rtn(int3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(int3); +ulong3 __ovld __cnfn convert_ulong3(int3); +ulong3 __ovld __cnfn convert_ulong3_sat(int3); +ulong3 __ovld __cnfn convert_ulong3_rte(uint3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(uint3); +ulong3 __ovld __cnfn convert_ulong3_rtz(uint3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(uint3); +ulong3 __ovld __cnfn convert_ulong3_rtp(uint3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(uint3); +ulong3 __ovld __cnfn convert_ulong3_rtn(uint3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(uint3); +ulong3 __ovld __cnfn convert_ulong3(uint3); +ulong3 __ovld __cnfn convert_ulong3_sat(uint3); +ulong3 __ovld __cnfn convert_ulong3_rte(long3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(long3); +ulong3 __ovld __cnfn convert_ulong3_rtz(long3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(long3); +ulong3 __ovld __cnfn convert_ulong3_rtp(long3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(long3); +ulong3 __ovld __cnfn convert_ulong3_rtn(long3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(long3); +ulong3 __ovld __cnfn convert_ulong3(long3); +ulong3 __ovld __cnfn convert_ulong3_sat(long3); +ulong3 __ovld __cnfn convert_ulong3_rte(ulong3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(ulong3); +ulong3 __ovld __cnfn convert_ulong3_rtz(ulong3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(ulong3); +ulong3 __ovld __cnfn convert_ulong3_rtp(ulong3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(ulong3); +ulong3 __ovld __cnfn convert_ulong3_rtn(ulong3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(ulong3); +ulong3 __ovld __cnfn convert_ulong3(ulong3); +ulong3 __ovld __cnfn convert_ulong3_sat(ulong3); +ulong3 __ovld __cnfn convert_ulong3_rte(float3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(float3); +ulong3 __ovld __cnfn convert_ulong3_rtz(float3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(float3); +ulong3 __ovld __cnfn convert_ulong3_rtp(float3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(float3); +ulong3 __ovld __cnfn convert_ulong3_rtn(float3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(float3); +ulong3 __ovld __cnfn convert_ulong3(float3); +ulong3 __ovld __cnfn convert_ulong3_sat(float3); +float3 __ovld __cnfn convert_float3_rte(char3); +float3 __ovld __cnfn convert_float3_rtz(char3); +float3 __ovld __cnfn convert_float3_rtp(char3); +float3 __ovld __cnfn convert_float3_rtn(char3); +float3 __ovld __cnfn convert_float3(char3); +float3 __ovld __cnfn convert_float3_rte(uchar3); +float3 __ovld __cnfn convert_float3_rtz(uchar3); +float3 __ovld __cnfn convert_float3_rtp(uchar3); +float3 __ovld __cnfn convert_float3_rtn(uchar3); +float3 __ovld __cnfn convert_float3(uchar3); +float3 __ovld __cnfn convert_float3_rte(short3); +float3 __ovld __cnfn convert_float3_rtz(short3); +float3 __ovld __cnfn convert_float3_rtp(short3); +float3 __ovld __cnfn convert_float3_rtn(short3); +float3 __ovld __cnfn convert_float3(short3); +float3 __ovld __cnfn convert_float3_rte(ushort3); +float3 __ovld __cnfn convert_float3_rtz(ushort3); +float3 __ovld __cnfn convert_float3_rtp(ushort3); +float3 __ovld __cnfn convert_float3_rtn(ushort3); +float3 __ovld __cnfn convert_float3(ushort3); +float3 __ovld __cnfn convert_float3_rte(int3); +float3 __ovld __cnfn convert_float3_rtz(int3); +float3 __ovld __cnfn convert_float3_rtp(int3); +float3 __ovld __cnfn convert_float3_rtn(int3); +float3 __ovld __cnfn convert_float3(int3); +float3 __ovld __cnfn convert_float3_rte(uint3); +float3 __ovld __cnfn convert_float3_rtz(uint3); +float3 __ovld __cnfn convert_float3_rtp(uint3); +float3 __ovld __cnfn convert_float3_rtn(uint3); +float3 __ovld __cnfn convert_float3(uint3); +float3 __ovld __cnfn convert_float3_rte(long3); +float3 __ovld __cnfn convert_float3_rtz(long3); +float3 __ovld __cnfn convert_float3_rtp(long3); +float3 __ovld __cnfn convert_float3_rtn(long3); +float3 __ovld __cnfn convert_float3(long3); +float3 __ovld __cnfn convert_float3_rte(ulong3); +float3 __ovld __cnfn convert_float3_rtz(ulong3); +float3 __ovld __cnfn convert_float3_rtp(ulong3); +float3 __ovld __cnfn convert_float3_rtn(ulong3); +float3 __ovld __cnfn convert_float3(ulong3); +float3 __ovld __cnfn convert_float3_rte(float3); +float3 __ovld __cnfn convert_float3_rtz(float3); +float3 __ovld __cnfn convert_float3_rtp(float3); +float3 __ovld __cnfn convert_float3_rtn(float3); +float3 __ovld __cnfn convert_float3(float3); +char4 __ovld __cnfn convert_char4_rte(char4); +char4 __ovld __cnfn convert_char4_sat_rte(char4); +char4 __ovld __cnfn convert_char4_rtz(char4); +char4 __ovld __cnfn convert_char4_sat_rtz(char4); +char4 __ovld __cnfn convert_char4_rtp(char4); +char4 __ovld __cnfn convert_char4_sat_rtp(char4); +char4 __ovld __cnfn convert_char4_rtn(char4); +char4 __ovld __cnfn convert_char4_sat_rtn(char4); +char4 __ovld __cnfn convert_char4(char4); +char4 __ovld __cnfn convert_char4_sat(char4); +char4 __ovld __cnfn convert_char4_rte(uchar4); +char4 __ovld __cnfn convert_char4_sat_rte(uchar4); +char4 __ovld __cnfn convert_char4_rtz(uchar4); +char4 __ovld __cnfn convert_char4_sat_rtz(uchar4); +char4 __ovld __cnfn convert_char4_rtp(uchar4); +char4 __ovld __cnfn convert_char4_sat_rtp(uchar4); +char4 __ovld __cnfn convert_char4_rtn(uchar4); +char4 __ovld __cnfn convert_char4_sat_rtn(uchar4); +char4 __ovld __cnfn convert_char4(uchar4); +char4 __ovld __cnfn convert_char4_sat(uchar4); +char4 __ovld __cnfn convert_char4_rte(short4); +char4 __ovld __cnfn convert_char4_sat_rte(short4); +char4 __ovld __cnfn convert_char4_rtz(short4); +char4 __ovld __cnfn convert_char4_sat_rtz(short4); +char4 __ovld __cnfn convert_char4_rtp(short4); +char4 __ovld __cnfn convert_char4_sat_rtp(short4); +char4 __ovld __cnfn convert_char4_rtn(short4); +char4 __ovld __cnfn convert_char4_sat_rtn(short4); +char4 __ovld __cnfn convert_char4(short4); +char4 __ovld __cnfn convert_char4_sat(short4); +char4 __ovld __cnfn convert_char4_rte(ushort4); +char4 __ovld __cnfn convert_char4_sat_rte(ushort4); +char4 __ovld __cnfn convert_char4_rtz(ushort4); +char4 __ovld __cnfn convert_char4_sat_rtz(ushort4); +char4 __ovld __cnfn convert_char4_rtp(ushort4); +char4 __ovld __cnfn convert_char4_sat_rtp(ushort4); +char4 __ovld __cnfn convert_char4_rtn(ushort4); +char4 __ovld __cnfn convert_char4_sat_rtn(ushort4); +char4 __ovld __cnfn convert_char4(ushort4); +char4 __ovld __cnfn convert_char4_sat(ushort4); +char4 __ovld __cnfn convert_char4_rte(int4); +char4 __ovld __cnfn convert_char4_sat_rte(int4); +char4 __ovld __cnfn convert_char4_rtz(int4); +char4 __ovld __cnfn convert_char4_sat_rtz(int4); +char4 __ovld __cnfn convert_char4_rtp(int4); +char4 __ovld __cnfn convert_char4_sat_rtp(int4); +char4 __ovld __cnfn convert_char4_rtn(int4); +char4 __ovld __cnfn convert_char4_sat_rtn(int4); +char4 __ovld __cnfn convert_char4(int4); +char4 __ovld __cnfn convert_char4_sat(int4); +char4 __ovld __cnfn convert_char4_rte(uint4); +char4 __ovld __cnfn convert_char4_sat_rte(uint4); +char4 __ovld __cnfn convert_char4_rtz(uint4); +char4 __ovld __cnfn convert_char4_sat_rtz(uint4); +char4 __ovld __cnfn convert_char4_rtp(uint4); +char4 __ovld __cnfn convert_char4_sat_rtp(uint4); +char4 __ovld __cnfn convert_char4_rtn(uint4); +char4 __ovld __cnfn convert_char4_sat_rtn(uint4); +char4 __ovld __cnfn convert_char4(uint4); +char4 __ovld __cnfn convert_char4_sat(uint4); +char4 __ovld __cnfn convert_char4_rte(long4); +char4 __ovld __cnfn convert_char4_sat_rte(long4); +char4 __ovld __cnfn convert_char4_rtz(long4); +char4 __ovld __cnfn convert_char4_sat_rtz(long4); +char4 __ovld __cnfn convert_char4_rtp(long4); +char4 __ovld __cnfn convert_char4_sat_rtp(long4); +char4 __ovld __cnfn convert_char4_rtn(long4); +char4 __ovld __cnfn convert_char4_sat_rtn(long4); +char4 __ovld __cnfn convert_char4(long4); +char4 __ovld __cnfn convert_char4_sat(long4); +char4 __ovld __cnfn convert_char4_rte(ulong4); +char4 __ovld __cnfn convert_char4_sat_rte(ulong4); +char4 __ovld __cnfn convert_char4_rtz(ulong4); +char4 __ovld __cnfn convert_char4_sat_rtz(ulong4); +char4 __ovld __cnfn convert_char4_rtp(ulong4); +char4 __ovld __cnfn convert_char4_sat_rtp(ulong4); +char4 __ovld __cnfn convert_char4_rtn(ulong4); +char4 __ovld __cnfn convert_char4_sat_rtn(ulong4); +char4 __ovld __cnfn convert_char4(ulong4); +char4 __ovld __cnfn convert_char4_sat(ulong4); +char4 __ovld __cnfn convert_char4_rte(float4); +char4 __ovld __cnfn convert_char4_sat_rte(float4); +char4 __ovld __cnfn convert_char4_rtz(float4); +char4 __ovld __cnfn convert_char4_sat_rtz(float4); +char4 __ovld __cnfn convert_char4_rtp(float4); +char4 __ovld __cnfn convert_char4_sat_rtp(float4); +char4 __ovld __cnfn convert_char4_rtn(float4); +char4 __ovld __cnfn convert_char4_sat_rtn(float4); +char4 __ovld __cnfn convert_char4(float4); +char4 __ovld __cnfn convert_char4_sat(float4); +uchar4 __ovld __cnfn convert_uchar4_rte(char4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(char4); +uchar4 __ovld __cnfn convert_uchar4_rtz(char4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(char4); +uchar4 __ovld __cnfn convert_uchar4_rtp(char4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(char4); +uchar4 __ovld __cnfn convert_uchar4_rtn(char4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(char4); +uchar4 __ovld __cnfn convert_uchar4(char4); +uchar4 __ovld __cnfn convert_uchar4_sat(char4); +uchar4 __ovld __cnfn convert_uchar4_rte(uchar4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(uchar4); +uchar4 __ovld __cnfn convert_uchar4_rtz(uchar4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(uchar4); +uchar4 __ovld __cnfn convert_uchar4_rtp(uchar4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(uchar4); +uchar4 __ovld __cnfn convert_uchar4_rtn(uchar4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(uchar4); +uchar4 __ovld __cnfn convert_uchar4(uchar4); +uchar4 __ovld __cnfn convert_uchar4_sat(uchar4); +uchar4 __ovld __cnfn convert_uchar4_rte(short4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(short4); +uchar4 __ovld __cnfn convert_uchar4_rtz(short4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(short4); +uchar4 __ovld __cnfn convert_uchar4_rtp(short4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(short4); +uchar4 __ovld __cnfn convert_uchar4_rtn(short4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(short4); +uchar4 __ovld __cnfn convert_uchar4(short4); +uchar4 __ovld __cnfn convert_uchar4_sat(short4); +uchar4 __ovld __cnfn convert_uchar4_rte(ushort4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(ushort4); +uchar4 __ovld __cnfn convert_uchar4_rtz(ushort4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(ushort4); +uchar4 __ovld __cnfn convert_uchar4_rtp(ushort4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(ushort4); +uchar4 __ovld __cnfn convert_uchar4_rtn(ushort4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(ushort4); +uchar4 __ovld __cnfn convert_uchar4(ushort4); +uchar4 __ovld __cnfn convert_uchar4_sat(ushort4); +uchar4 __ovld __cnfn convert_uchar4_rte(int4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(int4); +uchar4 __ovld __cnfn convert_uchar4_rtz(int4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(int4); +uchar4 __ovld __cnfn convert_uchar4_rtp(int4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(int4); +uchar4 __ovld __cnfn convert_uchar4_rtn(int4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(int4); +uchar4 __ovld __cnfn convert_uchar4(int4); +uchar4 __ovld __cnfn convert_uchar4_sat(int4); +uchar4 __ovld __cnfn convert_uchar4_rte(uint4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(uint4); +uchar4 __ovld __cnfn convert_uchar4_rtz(uint4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(uint4); +uchar4 __ovld __cnfn convert_uchar4_rtp(uint4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(uint4); +uchar4 __ovld __cnfn convert_uchar4_rtn(uint4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(uint4); +uchar4 __ovld __cnfn convert_uchar4(uint4); +uchar4 __ovld __cnfn convert_uchar4_sat(uint4); +uchar4 __ovld __cnfn convert_uchar4_rte(long4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(long4); +uchar4 __ovld __cnfn convert_uchar4_rtz(long4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(long4); +uchar4 __ovld __cnfn convert_uchar4_rtp(long4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(long4); +uchar4 __ovld __cnfn convert_uchar4_rtn(long4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(long4); +uchar4 __ovld __cnfn convert_uchar4(long4); +uchar4 __ovld __cnfn convert_uchar4_sat(long4); +uchar4 __ovld __cnfn convert_uchar4_rte(ulong4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(ulong4); +uchar4 __ovld __cnfn convert_uchar4_rtz(ulong4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(ulong4); +uchar4 __ovld __cnfn convert_uchar4_rtp(ulong4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(ulong4); +uchar4 __ovld __cnfn convert_uchar4_rtn(ulong4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(ulong4); +uchar4 __ovld __cnfn convert_uchar4(ulong4); +uchar4 __ovld __cnfn convert_uchar4_sat(ulong4); +uchar4 __ovld __cnfn convert_uchar4_rte(float4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(float4); +uchar4 __ovld __cnfn convert_uchar4_rtz(float4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(float4); +uchar4 __ovld __cnfn convert_uchar4_rtp(float4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(float4); +uchar4 __ovld __cnfn convert_uchar4_rtn(float4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(float4); +uchar4 __ovld __cnfn convert_uchar4(float4); +uchar4 __ovld __cnfn convert_uchar4_sat(float4); +short4 __ovld __cnfn convert_short4_rte(char4); +short4 __ovld __cnfn convert_short4_sat_rte(char4); +short4 __ovld __cnfn convert_short4_rtz(char4); +short4 __ovld __cnfn convert_short4_sat_rtz(char4); +short4 __ovld __cnfn convert_short4_rtp(char4); +short4 __ovld __cnfn convert_short4_sat_rtp(char4); +short4 __ovld __cnfn convert_short4_rtn(char4); +short4 __ovld __cnfn convert_short4_sat_rtn(char4); +short4 __ovld __cnfn convert_short4(char4); +short4 __ovld __cnfn convert_short4_sat(char4); +short4 __ovld __cnfn convert_short4_rte(uchar4); +short4 __ovld __cnfn convert_short4_sat_rte(uchar4); +short4 __ovld __cnfn convert_short4_rtz(uchar4); +short4 __ovld __cnfn convert_short4_sat_rtz(uchar4); +short4 __ovld __cnfn convert_short4_rtp(uchar4); +short4 __ovld __cnfn convert_short4_sat_rtp(uchar4); +short4 __ovld __cnfn convert_short4_rtn(uchar4); +short4 __ovld __cnfn convert_short4_sat_rtn(uchar4); +short4 __ovld __cnfn convert_short4(uchar4); +short4 __ovld __cnfn convert_short4_sat(uchar4); +short4 __ovld __cnfn convert_short4_rte(short4); +short4 __ovld __cnfn convert_short4_sat_rte(short4); +short4 __ovld __cnfn convert_short4_rtz(short4); +short4 __ovld __cnfn convert_short4_sat_rtz(short4); +short4 __ovld __cnfn convert_short4_rtp(short4); +short4 __ovld __cnfn convert_short4_sat_rtp(short4); +short4 __ovld __cnfn convert_short4_rtn(short4); +short4 __ovld __cnfn convert_short4_sat_rtn(short4); +short4 __ovld __cnfn convert_short4(short4); +short4 __ovld __cnfn convert_short4_sat(short4); +short4 __ovld __cnfn convert_short4_rte(ushort4); +short4 __ovld __cnfn convert_short4_sat_rte(ushort4); +short4 __ovld __cnfn convert_short4_rtz(ushort4); +short4 __ovld __cnfn convert_short4_sat_rtz(ushort4); +short4 __ovld __cnfn convert_short4_rtp(ushort4); +short4 __ovld __cnfn convert_short4_sat_rtp(ushort4); +short4 __ovld __cnfn convert_short4_rtn(ushort4); +short4 __ovld __cnfn convert_short4_sat_rtn(ushort4); +short4 __ovld __cnfn convert_short4(ushort4); +short4 __ovld __cnfn convert_short4_sat(ushort4); +short4 __ovld __cnfn convert_short4_rte(int4); +short4 __ovld __cnfn convert_short4_sat_rte(int4); +short4 __ovld __cnfn convert_short4_rtz(int4); +short4 __ovld __cnfn convert_short4_sat_rtz(int4); +short4 __ovld __cnfn convert_short4_rtp(int4); +short4 __ovld __cnfn convert_short4_sat_rtp(int4); +short4 __ovld __cnfn convert_short4_rtn(int4); +short4 __ovld __cnfn convert_short4_sat_rtn(int4); +short4 __ovld __cnfn convert_short4(int4); +short4 __ovld __cnfn convert_short4_sat(int4); +short4 __ovld __cnfn convert_short4_rte(uint4); +short4 __ovld __cnfn convert_short4_sat_rte(uint4); +short4 __ovld __cnfn convert_short4_rtz(uint4); +short4 __ovld __cnfn convert_short4_sat_rtz(uint4); +short4 __ovld __cnfn convert_short4_rtp(uint4); +short4 __ovld __cnfn convert_short4_sat_rtp(uint4); +short4 __ovld __cnfn convert_short4_rtn(uint4); +short4 __ovld __cnfn convert_short4_sat_rtn(uint4); +short4 __ovld __cnfn convert_short4(uint4); +short4 __ovld __cnfn convert_short4_sat(uint4); +short4 __ovld __cnfn convert_short4_rte(long4); +short4 __ovld __cnfn convert_short4_sat_rte(long4); +short4 __ovld __cnfn convert_short4_rtz(long4); +short4 __ovld __cnfn convert_short4_sat_rtz(long4); +short4 __ovld __cnfn convert_short4_rtp(long4); +short4 __ovld __cnfn convert_short4_sat_rtp(long4); +short4 __ovld __cnfn convert_short4_rtn(long4); +short4 __ovld __cnfn convert_short4_sat_rtn(long4); +short4 __ovld __cnfn convert_short4(long4); +short4 __ovld __cnfn convert_short4_sat(long4); +short4 __ovld __cnfn convert_short4_rte(ulong4); +short4 __ovld __cnfn convert_short4_sat_rte(ulong4); +short4 __ovld __cnfn convert_short4_rtz(ulong4); +short4 __ovld __cnfn convert_short4_sat_rtz(ulong4); +short4 __ovld __cnfn convert_short4_rtp(ulong4); +short4 __ovld __cnfn convert_short4_sat_rtp(ulong4); +short4 __ovld __cnfn convert_short4_rtn(ulong4); +short4 __ovld __cnfn convert_short4_sat_rtn(ulong4); +short4 __ovld __cnfn convert_short4(ulong4); +short4 __ovld __cnfn convert_short4_sat(ulong4); +short4 __ovld __cnfn convert_short4_rte(float4); +short4 __ovld __cnfn convert_short4_sat_rte(float4); +short4 __ovld __cnfn convert_short4_rtz(float4); +short4 __ovld __cnfn convert_short4_sat_rtz(float4); +short4 __ovld __cnfn convert_short4_rtp(float4); +short4 __ovld __cnfn convert_short4_sat_rtp(float4); +short4 __ovld __cnfn convert_short4_rtn(float4); +short4 __ovld __cnfn convert_short4_sat_rtn(float4); +short4 __ovld __cnfn convert_short4(float4); +short4 __ovld __cnfn convert_short4_sat(float4); +ushort4 __ovld __cnfn convert_ushort4_rte(char4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(char4); +ushort4 __ovld __cnfn convert_ushort4_rtz(char4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(char4); +ushort4 __ovld __cnfn convert_ushort4_rtp(char4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(char4); +ushort4 __ovld __cnfn convert_ushort4_rtn(char4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(char4); +ushort4 __ovld __cnfn convert_ushort4(char4); +ushort4 __ovld __cnfn convert_ushort4_sat(char4); +ushort4 __ovld __cnfn convert_ushort4_rte(uchar4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(uchar4); +ushort4 __ovld __cnfn convert_ushort4_rtz(uchar4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(uchar4); +ushort4 __ovld __cnfn convert_ushort4_rtp(uchar4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(uchar4); +ushort4 __ovld __cnfn convert_ushort4_rtn(uchar4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(uchar4); +ushort4 __ovld __cnfn convert_ushort4(uchar4); +ushort4 __ovld __cnfn convert_ushort4_sat(uchar4); +ushort4 __ovld __cnfn convert_ushort4_rte(short4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(short4); +ushort4 __ovld __cnfn convert_ushort4_rtz(short4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(short4); +ushort4 __ovld __cnfn convert_ushort4_rtp(short4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(short4); +ushort4 __ovld __cnfn convert_ushort4_rtn(short4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(short4); +ushort4 __ovld __cnfn convert_ushort4(short4); +ushort4 __ovld __cnfn convert_ushort4_sat(short4); +ushort4 __ovld __cnfn convert_ushort4_rte(ushort4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(ushort4); +ushort4 __ovld __cnfn convert_ushort4_rtz(ushort4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(ushort4); +ushort4 __ovld __cnfn convert_ushort4_rtp(ushort4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(ushort4); +ushort4 __ovld __cnfn convert_ushort4_rtn(ushort4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(ushort4); +ushort4 __ovld __cnfn convert_ushort4(ushort4); +ushort4 __ovld __cnfn convert_ushort4_sat(ushort4); +ushort4 __ovld __cnfn convert_ushort4_rte(int4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(int4); +ushort4 __ovld __cnfn convert_ushort4_rtz(int4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(int4); +ushort4 __ovld __cnfn convert_ushort4_rtp(int4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(int4); +ushort4 __ovld __cnfn convert_ushort4_rtn(int4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(int4); +ushort4 __ovld __cnfn convert_ushort4(int4); +ushort4 __ovld __cnfn convert_ushort4_sat(int4); +ushort4 __ovld __cnfn convert_ushort4_rte(uint4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(uint4); +ushort4 __ovld __cnfn convert_ushort4_rtz(uint4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(uint4); +ushort4 __ovld __cnfn convert_ushort4_rtp(uint4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(uint4); +ushort4 __ovld __cnfn convert_ushort4_rtn(uint4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(uint4); +ushort4 __ovld __cnfn convert_ushort4(uint4); +ushort4 __ovld __cnfn convert_ushort4_sat(uint4); +ushort4 __ovld __cnfn convert_ushort4_rte(long4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(long4); +ushort4 __ovld __cnfn convert_ushort4_rtz(long4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(long4); +ushort4 __ovld __cnfn convert_ushort4_rtp(long4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(long4); +ushort4 __ovld __cnfn convert_ushort4_rtn(long4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(long4); +ushort4 __ovld __cnfn convert_ushort4(long4); +ushort4 __ovld __cnfn convert_ushort4_sat(long4); +ushort4 __ovld __cnfn convert_ushort4_rte(ulong4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(ulong4); +ushort4 __ovld __cnfn convert_ushort4_rtz(ulong4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(ulong4); +ushort4 __ovld __cnfn convert_ushort4_rtp(ulong4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(ulong4); +ushort4 __ovld __cnfn convert_ushort4_rtn(ulong4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(ulong4); +ushort4 __ovld __cnfn convert_ushort4(ulong4); +ushort4 __ovld __cnfn convert_ushort4_sat(ulong4); +ushort4 __ovld __cnfn convert_ushort4_rte(float4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(float4); +ushort4 __ovld __cnfn convert_ushort4_rtz(float4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(float4); +ushort4 __ovld __cnfn convert_ushort4_rtp(float4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(float4); +ushort4 __ovld __cnfn convert_ushort4_rtn(float4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(float4); +ushort4 __ovld __cnfn convert_ushort4(float4); +ushort4 __ovld __cnfn convert_ushort4_sat(float4); +int4 __ovld __cnfn convert_int4_rte(char4); +int4 __ovld __cnfn convert_int4_sat_rte(char4); +int4 __ovld __cnfn convert_int4_rtz(char4); +int4 __ovld __cnfn convert_int4_sat_rtz(char4); +int4 __ovld __cnfn convert_int4_rtp(char4); +int4 __ovld __cnfn convert_int4_sat_rtp(char4); +int4 __ovld __cnfn convert_int4_rtn(char4); +int4 __ovld __cnfn convert_int4_sat_rtn(char4); +int4 __ovld __cnfn convert_int4(char4); +int4 __ovld __cnfn convert_int4_sat(char4); +int4 __ovld __cnfn convert_int4_rte(uchar4); +int4 __ovld __cnfn convert_int4_sat_rte(uchar4); +int4 __ovld __cnfn convert_int4_rtz(uchar4); +int4 __ovld __cnfn convert_int4_sat_rtz(uchar4); +int4 __ovld __cnfn convert_int4_rtp(uchar4); +int4 __ovld __cnfn convert_int4_sat_rtp(uchar4); +int4 __ovld __cnfn convert_int4_rtn(uchar4); +int4 __ovld __cnfn convert_int4_sat_rtn(uchar4); +int4 __ovld __cnfn convert_int4(uchar4); +int4 __ovld __cnfn convert_int4_sat(uchar4); +int4 __ovld __cnfn convert_int4_rte(short4); +int4 __ovld __cnfn convert_int4_sat_rte(short4); +int4 __ovld __cnfn convert_int4_rtz(short4); +int4 __ovld __cnfn convert_int4_sat_rtz(short4); +int4 __ovld __cnfn convert_int4_rtp(short4); +int4 __ovld __cnfn convert_int4_sat_rtp(short4); +int4 __ovld __cnfn convert_int4_rtn(short4); +int4 __ovld __cnfn convert_int4_sat_rtn(short4); +int4 __ovld __cnfn convert_int4(short4); +int4 __ovld __cnfn convert_int4_sat(short4); +int4 __ovld __cnfn convert_int4_rte(ushort4); +int4 __ovld __cnfn convert_int4_sat_rte(ushort4); +int4 __ovld __cnfn convert_int4_rtz(ushort4); +int4 __ovld __cnfn convert_int4_sat_rtz(ushort4); +int4 __ovld __cnfn convert_int4_rtp(ushort4); +int4 __ovld __cnfn convert_int4_sat_rtp(ushort4); +int4 __ovld __cnfn convert_int4_rtn(ushort4); +int4 __ovld __cnfn convert_int4_sat_rtn(ushort4); +int4 __ovld __cnfn convert_int4(ushort4); +int4 __ovld __cnfn convert_int4_sat(ushort4); +int4 __ovld __cnfn convert_int4_rte(int4); +int4 __ovld __cnfn convert_int4_sat_rte(int4); +int4 __ovld __cnfn convert_int4_rtz(int4); +int4 __ovld __cnfn convert_int4_sat_rtz(int4); +int4 __ovld __cnfn convert_int4_rtp(int4); +int4 __ovld __cnfn convert_int4_sat_rtp(int4); +int4 __ovld __cnfn convert_int4_rtn(int4); +int4 __ovld __cnfn convert_int4_sat_rtn(int4); +int4 __ovld __cnfn convert_int4(int4); +int4 __ovld __cnfn convert_int4_sat(int4); +int4 __ovld __cnfn convert_int4_rte(uint4); +int4 __ovld __cnfn convert_int4_sat_rte(uint4); +int4 __ovld __cnfn convert_int4_rtz(uint4); +int4 __ovld __cnfn convert_int4_sat_rtz(uint4); +int4 __ovld __cnfn convert_int4_rtp(uint4); +int4 __ovld __cnfn convert_int4_sat_rtp(uint4); +int4 __ovld __cnfn convert_int4_rtn(uint4); +int4 __ovld __cnfn convert_int4_sat_rtn(uint4); +int4 __ovld __cnfn convert_int4(uint4); +int4 __ovld __cnfn convert_int4_sat(uint4); +int4 __ovld __cnfn convert_int4_rte(long4); +int4 __ovld __cnfn convert_int4_sat_rte(long4); +int4 __ovld __cnfn convert_int4_rtz(long4); +int4 __ovld __cnfn convert_int4_sat_rtz(long4); +int4 __ovld __cnfn convert_int4_rtp(long4); +int4 __ovld __cnfn convert_int4_sat_rtp(long4); +int4 __ovld __cnfn convert_int4_rtn(long4); +int4 __ovld __cnfn convert_int4_sat_rtn(long4); +int4 __ovld __cnfn convert_int4(long4); +int4 __ovld __cnfn convert_int4_sat(long4); +int4 __ovld __cnfn convert_int4_rte(ulong4); +int4 __ovld __cnfn convert_int4_sat_rte(ulong4); +int4 __ovld __cnfn convert_int4_rtz(ulong4); +int4 __ovld __cnfn convert_int4_sat_rtz(ulong4); +int4 __ovld __cnfn convert_int4_rtp(ulong4); +int4 __ovld __cnfn convert_int4_sat_rtp(ulong4); +int4 __ovld __cnfn convert_int4_rtn(ulong4); +int4 __ovld __cnfn convert_int4_sat_rtn(ulong4); +int4 __ovld __cnfn convert_int4(ulong4); +int4 __ovld __cnfn convert_int4_sat(ulong4); +int4 __ovld __cnfn convert_int4_rte(float4); +int4 __ovld __cnfn convert_int4_sat_rte(float4); +int4 __ovld __cnfn convert_int4_rtz(float4); +int4 __ovld __cnfn convert_int4_sat_rtz(float4); +int4 __ovld __cnfn convert_int4_rtp(float4); +int4 __ovld __cnfn convert_int4_sat_rtp(float4); +int4 __ovld __cnfn convert_int4_rtn(float4); +int4 __ovld __cnfn convert_int4_sat_rtn(float4); +int4 __ovld __cnfn convert_int4(float4); +int4 __ovld __cnfn convert_int4_sat(float4); +uint4 __ovld __cnfn convert_uint4_rte(char4); +uint4 __ovld __cnfn convert_uint4_sat_rte(char4); +uint4 __ovld __cnfn convert_uint4_rtz(char4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(char4); +uint4 __ovld __cnfn convert_uint4_rtp(char4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(char4); +uint4 __ovld __cnfn convert_uint4_rtn(char4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(char4); +uint4 __ovld __cnfn convert_uint4(char4); +uint4 __ovld __cnfn convert_uint4_sat(char4); +uint4 __ovld __cnfn convert_uint4_rte(uchar4); +uint4 __ovld __cnfn convert_uint4_sat_rte(uchar4); +uint4 __ovld __cnfn convert_uint4_rtz(uchar4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(uchar4); +uint4 __ovld __cnfn convert_uint4_rtp(uchar4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(uchar4); +uint4 __ovld __cnfn convert_uint4_rtn(uchar4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(uchar4); +uint4 __ovld __cnfn convert_uint4(uchar4); +uint4 __ovld __cnfn convert_uint4_sat(uchar4); +uint4 __ovld __cnfn convert_uint4_rte(short4); +uint4 __ovld __cnfn convert_uint4_sat_rte(short4); +uint4 __ovld __cnfn convert_uint4_rtz(short4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(short4); +uint4 __ovld __cnfn convert_uint4_rtp(short4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(short4); +uint4 __ovld __cnfn convert_uint4_rtn(short4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(short4); +uint4 __ovld __cnfn convert_uint4(short4); +uint4 __ovld __cnfn convert_uint4_sat(short4); +uint4 __ovld __cnfn convert_uint4_rte(ushort4); +uint4 __ovld __cnfn convert_uint4_sat_rte(ushort4); +uint4 __ovld __cnfn convert_uint4_rtz(ushort4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(ushort4); +uint4 __ovld __cnfn convert_uint4_rtp(ushort4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(ushort4); +uint4 __ovld __cnfn convert_uint4_rtn(ushort4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(ushort4); +uint4 __ovld __cnfn convert_uint4(ushort4); +uint4 __ovld __cnfn convert_uint4_sat(ushort4); +uint4 __ovld __cnfn convert_uint4_rte(int4); +uint4 __ovld __cnfn convert_uint4_sat_rte(int4); +uint4 __ovld __cnfn convert_uint4_rtz(int4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(int4); +uint4 __ovld __cnfn convert_uint4_rtp(int4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(int4); +uint4 __ovld __cnfn convert_uint4_rtn(int4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(int4); +uint4 __ovld __cnfn convert_uint4(int4); +uint4 __ovld __cnfn convert_uint4_sat(int4); +uint4 __ovld __cnfn convert_uint4_rte(uint4); +uint4 __ovld __cnfn convert_uint4_sat_rte(uint4); +uint4 __ovld __cnfn convert_uint4_rtz(uint4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(uint4); +uint4 __ovld __cnfn convert_uint4_rtp(uint4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(uint4); +uint4 __ovld __cnfn convert_uint4_rtn(uint4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(uint4); +uint4 __ovld __cnfn convert_uint4(uint4); +uint4 __ovld __cnfn convert_uint4_sat(uint4); +uint4 __ovld __cnfn convert_uint4_rte(long4); +uint4 __ovld __cnfn convert_uint4_sat_rte(long4); +uint4 __ovld __cnfn convert_uint4_rtz(long4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(long4); +uint4 __ovld __cnfn convert_uint4_rtp(long4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(long4); +uint4 __ovld __cnfn convert_uint4_rtn(long4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(long4); +uint4 __ovld __cnfn convert_uint4(long4); +uint4 __ovld __cnfn convert_uint4_sat(long4); +uint4 __ovld __cnfn convert_uint4_rte(ulong4); +uint4 __ovld __cnfn convert_uint4_sat_rte(ulong4); +uint4 __ovld __cnfn convert_uint4_rtz(ulong4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(ulong4); +uint4 __ovld __cnfn convert_uint4_rtp(ulong4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(ulong4); +uint4 __ovld __cnfn convert_uint4_rtn(ulong4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(ulong4); +uint4 __ovld __cnfn convert_uint4(ulong4); +uint4 __ovld __cnfn convert_uint4_sat(ulong4); +uint4 __ovld __cnfn convert_uint4_rte(float4); +uint4 __ovld __cnfn convert_uint4_sat_rte(float4); +uint4 __ovld __cnfn convert_uint4_rtz(float4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(float4); +uint4 __ovld __cnfn convert_uint4_rtp(float4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(float4); +uint4 __ovld __cnfn convert_uint4_rtn(float4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(float4); +uint4 __ovld __cnfn convert_uint4(float4); +uint4 __ovld __cnfn convert_uint4_sat(float4); +long4 __ovld __cnfn convert_long4_rte(char4); +long4 __ovld __cnfn convert_long4_sat_rte(char4); +long4 __ovld __cnfn convert_long4_rtz(char4); +long4 __ovld __cnfn convert_long4_sat_rtz(char4); +long4 __ovld __cnfn convert_long4_rtp(char4); +long4 __ovld __cnfn convert_long4_sat_rtp(char4); +long4 __ovld __cnfn convert_long4_rtn(char4); +long4 __ovld __cnfn convert_long4_sat_rtn(char4); +long4 __ovld __cnfn convert_long4(char4); +long4 __ovld __cnfn convert_long4_sat(char4); +long4 __ovld __cnfn convert_long4_rte(uchar4); +long4 __ovld __cnfn convert_long4_sat_rte(uchar4); +long4 __ovld __cnfn convert_long4_rtz(uchar4); +long4 __ovld __cnfn convert_long4_sat_rtz(uchar4); +long4 __ovld __cnfn convert_long4_rtp(uchar4); +long4 __ovld __cnfn convert_long4_sat_rtp(uchar4); +long4 __ovld __cnfn convert_long4_rtn(uchar4); +long4 __ovld __cnfn convert_long4_sat_rtn(uchar4); +long4 __ovld __cnfn convert_long4(uchar4); +long4 __ovld __cnfn convert_long4_sat(uchar4); +long4 __ovld __cnfn convert_long4_rte(short4); +long4 __ovld __cnfn convert_long4_sat_rte(short4); +long4 __ovld __cnfn convert_long4_rtz(short4); +long4 __ovld __cnfn convert_long4_sat_rtz(short4); +long4 __ovld __cnfn convert_long4_rtp(short4); +long4 __ovld __cnfn convert_long4_sat_rtp(short4); +long4 __ovld __cnfn convert_long4_rtn(short4); +long4 __ovld __cnfn convert_long4_sat_rtn(short4); +long4 __ovld __cnfn convert_long4(short4); +long4 __ovld __cnfn convert_long4_sat(short4); +long4 __ovld __cnfn convert_long4_rte(ushort4); +long4 __ovld __cnfn convert_long4_sat_rte(ushort4); +long4 __ovld __cnfn convert_long4_rtz(ushort4); +long4 __ovld __cnfn convert_long4_sat_rtz(ushort4); +long4 __ovld __cnfn convert_long4_rtp(ushort4); +long4 __ovld __cnfn convert_long4_sat_rtp(ushort4); +long4 __ovld __cnfn convert_long4_rtn(ushort4); +long4 __ovld __cnfn convert_long4_sat_rtn(ushort4); +long4 __ovld __cnfn convert_long4(ushort4); +long4 __ovld __cnfn convert_long4_sat(ushort4); +long4 __ovld __cnfn convert_long4_rte(int4); +long4 __ovld __cnfn convert_long4_sat_rte(int4); +long4 __ovld __cnfn convert_long4_rtz(int4); +long4 __ovld __cnfn convert_long4_sat_rtz(int4); +long4 __ovld __cnfn convert_long4_rtp(int4); +long4 __ovld __cnfn convert_long4_sat_rtp(int4); +long4 __ovld __cnfn convert_long4_rtn(int4); +long4 __ovld __cnfn convert_long4_sat_rtn(int4); +long4 __ovld __cnfn convert_long4(int4); +long4 __ovld __cnfn convert_long4_sat(int4); +long4 __ovld __cnfn convert_long4_rte(uint4); +long4 __ovld __cnfn convert_long4_sat_rte(uint4); +long4 __ovld __cnfn convert_long4_rtz(uint4); +long4 __ovld __cnfn convert_long4_sat_rtz(uint4); +long4 __ovld __cnfn convert_long4_rtp(uint4); +long4 __ovld __cnfn convert_long4_sat_rtp(uint4); +long4 __ovld __cnfn convert_long4_rtn(uint4); +long4 __ovld __cnfn convert_long4_sat_rtn(uint4); +long4 __ovld __cnfn convert_long4(uint4); +long4 __ovld __cnfn convert_long4_sat(uint4); +long4 __ovld __cnfn convert_long4_rte(long4); +long4 __ovld __cnfn convert_long4_sat_rte(long4); +long4 __ovld __cnfn convert_long4_rtz(long4); +long4 __ovld __cnfn convert_long4_sat_rtz(long4); +long4 __ovld __cnfn convert_long4_rtp(long4); +long4 __ovld __cnfn convert_long4_sat_rtp(long4); +long4 __ovld __cnfn convert_long4_rtn(long4); +long4 __ovld __cnfn convert_long4_sat_rtn(long4); +long4 __ovld __cnfn convert_long4(long4); +long4 __ovld __cnfn convert_long4_sat(long4); +long4 __ovld __cnfn convert_long4_rte(ulong4); +long4 __ovld __cnfn convert_long4_sat_rte(ulong4); +long4 __ovld __cnfn convert_long4_rtz(ulong4); +long4 __ovld __cnfn convert_long4_sat_rtz(ulong4); +long4 __ovld __cnfn convert_long4_rtp(ulong4); +long4 __ovld __cnfn convert_long4_sat_rtp(ulong4); +long4 __ovld __cnfn convert_long4_rtn(ulong4); +long4 __ovld __cnfn convert_long4_sat_rtn(ulong4); +long4 __ovld __cnfn convert_long4(ulong4); +long4 __ovld __cnfn convert_long4_sat(ulong4); +long4 __ovld __cnfn convert_long4_rte(float4); +long4 __ovld __cnfn convert_long4_sat_rte(float4); +long4 __ovld __cnfn convert_long4_rtz(float4); +long4 __ovld __cnfn convert_long4_sat_rtz(float4); +long4 __ovld __cnfn convert_long4_rtp(float4); +long4 __ovld __cnfn convert_long4_sat_rtp(float4); +long4 __ovld __cnfn convert_long4_rtn(float4); +long4 __ovld __cnfn convert_long4_sat_rtn(float4); +long4 __ovld __cnfn convert_long4(float4); +long4 __ovld __cnfn convert_long4_sat(float4); +ulong4 __ovld __cnfn convert_ulong4_rte(char4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(char4); +ulong4 __ovld __cnfn convert_ulong4_rtz(char4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(char4); +ulong4 __ovld __cnfn convert_ulong4_rtp(char4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(char4); +ulong4 __ovld __cnfn convert_ulong4_rtn(char4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(char4); +ulong4 __ovld __cnfn convert_ulong4(char4); +ulong4 __ovld __cnfn convert_ulong4_sat(char4); +ulong4 __ovld __cnfn convert_ulong4_rte(uchar4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(uchar4); +ulong4 __ovld __cnfn convert_ulong4_rtz(uchar4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(uchar4); +ulong4 __ovld __cnfn convert_ulong4_rtp(uchar4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(uchar4); +ulong4 __ovld __cnfn convert_ulong4_rtn(uchar4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(uchar4); +ulong4 __ovld __cnfn convert_ulong4(uchar4); +ulong4 __ovld __cnfn convert_ulong4_sat(uchar4); +ulong4 __ovld __cnfn convert_ulong4_rte(short4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(short4); +ulong4 __ovld __cnfn convert_ulong4_rtz(short4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(short4); +ulong4 __ovld __cnfn convert_ulong4_rtp(short4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(short4); +ulong4 __ovld __cnfn convert_ulong4_rtn(short4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(short4); +ulong4 __ovld __cnfn convert_ulong4(short4); +ulong4 __ovld __cnfn convert_ulong4_sat(short4); +ulong4 __ovld __cnfn convert_ulong4_rte(ushort4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(ushort4); +ulong4 __ovld __cnfn convert_ulong4_rtz(ushort4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(ushort4); +ulong4 __ovld __cnfn convert_ulong4_rtp(ushort4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(ushort4); +ulong4 __ovld __cnfn convert_ulong4_rtn(ushort4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(ushort4); +ulong4 __ovld __cnfn convert_ulong4(ushort4); +ulong4 __ovld __cnfn convert_ulong4_sat(ushort4); +ulong4 __ovld __cnfn convert_ulong4_rte(int4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(int4); +ulong4 __ovld __cnfn convert_ulong4_rtz(int4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(int4); +ulong4 __ovld __cnfn convert_ulong4_rtp(int4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(int4); +ulong4 __ovld __cnfn convert_ulong4_rtn(int4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(int4); +ulong4 __ovld __cnfn convert_ulong4(int4); +ulong4 __ovld __cnfn convert_ulong4_sat(int4); +ulong4 __ovld __cnfn convert_ulong4_rte(uint4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(uint4); +ulong4 __ovld __cnfn convert_ulong4_rtz(uint4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(uint4); +ulong4 __ovld __cnfn convert_ulong4_rtp(uint4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(uint4); +ulong4 __ovld __cnfn convert_ulong4_rtn(uint4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(uint4); +ulong4 __ovld __cnfn convert_ulong4(uint4); +ulong4 __ovld __cnfn convert_ulong4_sat(uint4); +ulong4 __ovld __cnfn convert_ulong4_rte(long4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(long4); +ulong4 __ovld __cnfn convert_ulong4_rtz(long4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(long4); +ulong4 __ovld __cnfn convert_ulong4_rtp(long4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(long4); +ulong4 __ovld __cnfn convert_ulong4_rtn(long4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(long4); +ulong4 __ovld __cnfn convert_ulong4(long4); +ulong4 __ovld __cnfn convert_ulong4_sat(long4); +ulong4 __ovld __cnfn convert_ulong4_rte(ulong4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(ulong4); +ulong4 __ovld __cnfn convert_ulong4_rtz(ulong4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(ulong4); +ulong4 __ovld __cnfn convert_ulong4_rtp(ulong4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(ulong4); +ulong4 __ovld __cnfn convert_ulong4_rtn(ulong4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(ulong4); +ulong4 __ovld __cnfn convert_ulong4(ulong4); +ulong4 __ovld __cnfn convert_ulong4_sat(ulong4); +ulong4 __ovld __cnfn convert_ulong4_rte(float4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(float4); +ulong4 __ovld __cnfn convert_ulong4_rtz(float4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(float4); +ulong4 __ovld __cnfn convert_ulong4_rtp(float4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(float4); +ulong4 __ovld __cnfn convert_ulong4_rtn(float4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(float4); +ulong4 __ovld __cnfn convert_ulong4(float4); +ulong4 __ovld __cnfn convert_ulong4_sat(float4); +float4 __ovld __cnfn convert_float4_rte(char4); +float4 __ovld __cnfn convert_float4_rtz(char4); +float4 __ovld __cnfn convert_float4_rtp(char4); +float4 __ovld __cnfn convert_float4_rtn(char4); +float4 __ovld __cnfn convert_float4(char4); +float4 __ovld __cnfn convert_float4_rte(uchar4); +float4 __ovld __cnfn convert_float4_rtz(uchar4); +float4 __ovld __cnfn convert_float4_rtp(uchar4); +float4 __ovld __cnfn convert_float4_rtn(uchar4); +float4 __ovld __cnfn convert_float4(uchar4); +float4 __ovld __cnfn convert_float4_rte(short4); +float4 __ovld __cnfn convert_float4_rtz(short4); +float4 __ovld __cnfn convert_float4_rtp(short4); +float4 __ovld __cnfn convert_float4_rtn(short4); +float4 __ovld __cnfn convert_float4(short4); +float4 __ovld __cnfn convert_float4_rte(ushort4); +float4 __ovld __cnfn convert_float4_rtz(ushort4); +float4 __ovld __cnfn convert_float4_rtp(ushort4); +float4 __ovld __cnfn convert_float4_rtn(ushort4); +float4 __ovld __cnfn convert_float4(ushort4); +float4 __ovld __cnfn convert_float4_rte(int4); +float4 __ovld __cnfn convert_float4_rtz(int4); +float4 __ovld __cnfn convert_float4_rtp(int4); +float4 __ovld __cnfn convert_float4_rtn(int4); +float4 __ovld __cnfn convert_float4(int4); +float4 __ovld __cnfn convert_float4_rte(uint4); +float4 __ovld __cnfn convert_float4_rtz(uint4); +float4 __ovld __cnfn convert_float4_rtp(uint4); +float4 __ovld __cnfn convert_float4_rtn(uint4); +float4 __ovld __cnfn convert_float4(uint4); +float4 __ovld __cnfn convert_float4_rte(long4); +float4 __ovld __cnfn convert_float4_rtz(long4); +float4 __ovld __cnfn convert_float4_rtp(long4); +float4 __ovld __cnfn convert_float4_rtn(long4); +float4 __ovld __cnfn convert_float4(long4); +float4 __ovld __cnfn convert_float4_rte(ulong4); +float4 __ovld __cnfn convert_float4_rtz(ulong4); +float4 __ovld __cnfn convert_float4_rtp(ulong4); +float4 __ovld __cnfn convert_float4_rtn(ulong4); +float4 __ovld __cnfn convert_float4(ulong4); +float4 __ovld __cnfn convert_float4_rte(float4); +float4 __ovld __cnfn convert_float4_rtz(float4); +float4 __ovld __cnfn convert_float4_rtp(float4); +float4 __ovld __cnfn convert_float4_rtn(float4); +float4 __ovld __cnfn convert_float4(float4); +char8 __ovld __cnfn convert_char8_rte(char8); +char8 __ovld __cnfn convert_char8_sat_rte(char8); +char8 __ovld __cnfn convert_char8_rtz(char8); +char8 __ovld __cnfn convert_char8_sat_rtz(char8); +char8 __ovld __cnfn convert_char8_rtp(char8); +char8 __ovld __cnfn convert_char8_sat_rtp(char8); +char8 __ovld __cnfn convert_char8_rtn(char8); +char8 __ovld __cnfn convert_char8_sat_rtn(char8); +char8 __ovld __cnfn convert_char8(char8); +char8 __ovld __cnfn convert_char8_sat(char8); +char8 __ovld __cnfn convert_char8_rte(uchar8); +char8 __ovld __cnfn convert_char8_sat_rte(uchar8); +char8 __ovld __cnfn convert_char8_rtz(uchar8); +char8 __ovld __cnfn convert_char8_sat_rtz(uchar8); +char8 __ovld __cnfn convert_char8_rtp(uchar8); +char8 __ovld __cnfn convert_char8_sat_rtp(uchar8); +char8 __ovld __cnfn convert_char8_rtn(uchar8); +char8 __ovld __cnfn convert_char8_sat_rtn(uchar8); +char8 __ovld __cnfn convert_char8(uchar8); +char8 __ovld __cnfn convert_char8_sat(uchar8); +char8 __ovld __cnfn convert_char8_rte(short8); +char8 __ovld __cnfn convert_char8_sat_rte(short8); +char8 __ovld __cnfn convert_char8_rtz(short8); +char8 __ovld __cnfn convert_char8_sat_rtz(short8); +char8 __ovld __cnfn convert_char8_rtp(short8); +char8 __ovld __cnfn convert_char8_sat_rtp(short8); +char8 __ovld __cnfn convert_char8_rtn(short8); +char8 __ovld __cnfn convert_char8_sat_rtn(short8); +char8 __ovld __cnfn convert_char8(short8); +char8 __ovld __cnfn convert_char8_sat(short8); +char8 __ovld __cnfn convert_char8_rte(ushort8); +char8 __ovld __cnfn convert_char8_sat_rte(ushort8); +char8 __ovld __cnfn convert_char8_rtz(ushort8); +char8 __ovld __cnfn convert_char8_sat_rtz(ushort8); +char8 __ovld __cnfn convert_char8_rtp(ushort8); +char8 __ovld __cnfn convert_char8_sat_rtp(ushort8); +char8 __ovld __cnfn convert_char8_rtn(ushort8); +char8 __ovld __cnfn convert_char8_sat_rtn(ushort8); +char8 __ovld __cnfn convert_char8(ushort8); +char8 __ovld __cnfn convert_char8_sat(ushort8); +char8 __ovld __cnfn convert_char8_rte(int8); +char8 __ovld __cnfn convert_char8_sat_rte(int8); +char8 __ovld __cnfn convert_char8_rtz(int8); +char8 __ovld __cnfn convert_char8_sat_rtz(int8); +char8 __ovld __cnfn convert_char8_rtp(int8); +char8 __ovld __cnfn convert_char8_sat_rtp(int8); +char8 __ovld __cnfn convert_char8_rtn(int8); +char8 __ovld __cnfn convert_char8_sat_rtn(int8); +char8 __ovld __cnfn convert_char8(int8); +char8 __ovld __cnfn convert_char8_sat(int8); +char8 __ovld __cnfn convert_char8_rte(uint8); +char8 __ovld __cnfn convert_char8_sat_rte(uint8); +char8 __ovld __cnfn convert_char8_rtz(uint8); +char8 __ovld __cnfn convert_char8_sat_rtz(uint8); +char8 __ovld __cnfn convert_char8_rtp(uint8); +char8 __ovld __cnfn convert_char8_sat_rtp(uint8); +char8 __ovld __cnfn convert_char8_rtn(uint8); +char8 __ovld __cnfn convert_char8_sat_rtn(uint8); +char8 __ovld __cnfn convert_char8(uint8); +char8 __ovld __cnfn convert_char8_sat(uint8); +char8 __ovld __cnfn convert_char8_rte(long8); +char8 __ovld __cnfn convert_char8_sat_rte(long8); +char8 __ovld __cnfn convert_char8_rtz(long8); +char8 __ovld __cnfn convert_char8_sat_rtz(long8); +char8 __ovld __cnfn convert_char8_rtp(long8); +char8 __ovld __cnfn convert_char8_sat_rtp(long8); +char8 __ovld __cnfn convert_char8_rtn(long8); +char8 __ovld __cnfn convert_char8_sat_rtn(long8); +char8 __ovld __cnfn convert_char8(long8); +char8 __ovld __cnfn convert_char8_sat(long8); +char8 __ovld __cnfn convert_char8_rte(ulong8); +char8 __ovld __cnfn convert_char8_sat_rte(ulong8); +char8 __ovld __cnfn convert_char8_rtz(ulong8); +char8 __ovld __cnfn convert_char8_sat_rtz(ulong8); +char8 __ovld __cnfn convert_char8_rtp(ulong8); +char8 __ovld __cnfn convert_char8_sat_rtp(ulong8); +char8 __ovld __cnfn convert_char8_rtn(ulong8); +char8 __ovld __cnfn convert_char8_sat_rtn(ulong8); +char8 __ovld __cnfn convert_char8(ulong8); +char8 __ovld __cnfn convert_char8_sat(ulong8); +char8 __ovld __cnfn convert_char8_rte(float8); +char8 __ovld __cnfn convert_char8_sat_rte(float8); +char8 __ovld __cnfn convert_char8_rtz(float8); +char8 __ovld __cnfn convert_char8_sat_rtz(float8); +char8 __ovld __cnfn convert_char8_rtp(float8); +char8 __ovld __cnfn convert_char8_sat_rtp(float8); +char8 __ovld __cnfn convert_char8_rtn(float8); +char8 __ovld __cnfn convert_char8_sat_rtn(float8); +char8 __ovld __cnfn convert_char8(float8); +char8 __ovld __cnfn convert_char8_sat(float8); +uchar8 __ovld __cnfn convert_uchar8_rte(char8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(char8); +uchar8 __ovld __cnfn convert_uchar8_rtz(char8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(char8); +uchar8 __ovld __cnfn convert_uchar8_rtp(char8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(char8); +uchar8 __ovld __cnfn convert_uchar8_rtn(char8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(char8); +uchar8 __ovld __cnfn convert_uchar8(char8); +uchar8 __ovld __cnfn convert_uchar8_sat(char8); +uchar8 __ovld __cnfn convert_uchar8_rte(uchar8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(uchar8); +uchar8 __ovld __cnfn convert_uchar8_rtz(uchar8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(uchar8); +uchar8 __ovld __cnfn convert_uchar8_rtp(uchar8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(uchar8); +uchar8 __ovld __cnfn convert_uchar8_rtn(uchar8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(uchar8); +uchar8 __ovld __cnfn convert_uchar8(uchar8); +uchar8 __ovld __cnfn convert_uchar8_sat(uchar8); +uchar8 __ovld __cnfn convert_uchar8_rte(short8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(short8); +uchar8 __ovld __cnfn convert_uchar8_rtz(short8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(short8); +uchar8 __ovld __cnfn convert_uchar8_rtp(short8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(short8); +uchar8 __ovld __cnfn convert_uchar8_rtn(short8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(short8); +uchar8 __ovld __cnfn convert_uchar8(short8); +uchar8 __ovld __cnfn convert_uchar8_sat(short8); +uchar8 __ovld __cnfn convert_uchar8_rte(ushort8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(ushort8); +uchar8 __ovld __cnfn convert_uchar8_rtz(ushort8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(ushort8); +uchar8 __ovld __cnfn convert_uchar8_rtp(ushort8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(ushort8); +uchar8 __ovld __cnfn convert_uchar8_rtn(ushort8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(ushort8); +uchar8 __ovld __cnfn convert_uchar8(ushort8); +uchar8 __ovld __cnfn convert_uchar8_sat(ushort8); +uchar8 __ovld __cnfn convert_uchar8_rte(int8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(int8); +uchar8 __ovld __cnfn convert_uchar8_rtz(int8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(int8); +uchar8 __ovld __cnfn convert_uchar8_rtp(int8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(int8); +uchar8 __ovld __cnfn convert_uchar8_rtn(int8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(int8); +uchar8 __ovld __cnfn convert_uchar8(int8); +uchar8 __ovld __cnfn convert_uchar8_sat(int8); +uchar8 __ovld __cnfn convert_uchar8_rte(uint8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(uint8); +uchar8 __ovld __cnfn convert_uchar8_rtz(uint8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(uint8); +uchar8 __ovld __cnfn convert_uchar8_rtp(uint8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(uint8); +uchar8 __ovld __cnfn convert_uchar8_rtn(uint8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(uint8); +uchar8 __ovld __cnfn convert_uchar8(uint8); +uchar8 __ovld __cnfn convert_uchar8_sat(uint8); +uchar8 __ovld __cnfn convert_uchar8_rte(long8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(long8); +uchar8 __ovld __cnfn convert_uchar8_rtz(long8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(long8); +uchar8 __ovld __cnfn convert_uchar8_rtp(long8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(long8); +uchar8 __ovld __cnfn convert_uchar8_rtn(long8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(long8); +uchar8 __ovld __cnfn convert_uchar8(long8); +uchar8 __ovld __cnfn convert_uchar8_sat(long8); +uchar8 __ovld __cnfn convert_uchar8_rte(ulong8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(ulong8); +uchar8 __ovld __cnfn convert_uchar8_rtz(ulong8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(ulong8); +uchar8 __ovld __cnfn convert_uchar8_rtp(ulong8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(ulong8); +uchar8 __ovld __cnfn convert_uchar8_rtn(ulong8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(ulong8); +uchar8 __ovld __cnfn convert_uchar8(ulong8); +uchar8 __ovld __cnfn convert_uchar8_sat(ulong8); +uchar8 __ovld __cnfn convert_uchar8_rte(float8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(float8); +uchar8 __ovld __cnfn convert_uchar8_rtz(float8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(float8); +uchar8 __ovld __cnfn convert_uchar8_rtp(float8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(float8); +uchar8 __ovld __cnfn convert_uchar8_rtn(float8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(float8); +uchar8 __ovld __cnfn convert_uchar8(float8); +uchar8 __ovld __cnfn convert_uchar8_sat(float8); +short8 __ovld __cnfn convert_short8_rte(char8); +short8 __ovld __cnfn convert_short8_sat_rte(char8); +short8 __ovld __cnfn convert_short8_rtz(char8); +short8 __ovld __cnfn convert_short8_sat_rtz(char8); +short8 __ovld __cnfn convert_short8_rtp(char8); +short8 __ovld __cnfn convert_short8_sat_rtp(char8); +short8 __ovld __cnfn convert_short8_rtn(char8); +short8 __ovld __cnfn convert_short8_sat_rtn(char8); +short8 __ovld __cnfn convert_short8(char8); +short8 __ovld __cnfn convert_short8_sat(char8); +short8 __ovld __cnfn convert_short8_rte(uchar8); +short8 __ovld __cnfn convert_short8_sat_rte(uchar8); +short8 __ovld __cnfn convert_short8_rtz(uchar8); +short8 __ovld __cnfn convert_short8_sat_rtz(uchar8); +short8 __ovld __cnfn convert_short8_rtp(uchar8); +short8 __ovld __cnfn convert_short8_sat_rtp(uchar8); +short8 __ovld __cnfn convert_short8_rtn(uchar8); +short8 __ovld __cnfn convert_short8_sat_rtn(uchar8); +short8 __ovld __cnfn convert_short8(uchar8); +short8 __ovld __cnfn convert_short8_sat(uchar8); +short8 __ovld __cnfn convert_short8_rte(short8); +short8 __ovld __cnfn convert_short8_sat_rte(short8); +short8 __ovld __cnfn convert_short8_rtz(short8); +short8 __ovld __cnfn convert_short8_sat_rtz(short8); +short8 __ovld __cnfn convert_short8_rtp(short8); +short8 __ovld __cnfn convert_short8_sat_rtp(short8); +short8 __ovld __cnfn convert_short8_rtn(short8); +short8 __ovld __cnfn convert_short8_sat_rtn(short8); +short8 __ovld __cnfn convert_short8(short8); +short8 __ovld __cnfn convert_short8_sat(short8); +short8 __ovld __cnfn convert_short8_rte(ushort8); +short8 __ovld __cnfn convert_short8_sat_rte(ushort8); +short8 __ovld __cnfn convert_short8_rtz(ushort8); +short8 __ovld __cnfn convert_short8_sat_rtz(ushort8); +short8 __ovld __cnfn convert_short8_rtp(ushort8); +short8 __ovld __cnfn convert_short8_sat_rtp(ushort8); +short8 __ovld __cnfn convert_short8_rtn(ushort8); +short8 __ovld __cnfn convert_short8_sat_rtn(ushort8); +short8 __ovld __cnfn convert_short8(ushort8); +short8 __ovld __cnfn convert_short8_sat(ushort8); +short8 __ovld __cnfn convert_short8_rte(int8); +short8 __ovld __cnfn convert_short8_sat_rte(int8); +short8 __ovld __cnfn convert_short8_rtz(int8); +short8 __ovld __cnfn convert_short8_sat_rtz(int8); +short8 __ovld __cnfn convert_short8_rtp(int8); +short8 __ovld __cnfn convert_short8_sat_rtp(int8); +short8 __ovld __cnfn convert_short8_rtn(int8); +short8 __ovld __cnfn convert_short8_sat_rtn(int8); +short8 __ovld __cnfn convert_short8(int8); +short8 __ovld __cnfn convert_short8_sat(int8); +short8 __ovld __cnfn convert_short8_rte(uint8); +short8 __ovld __cnfn convert_short8_sat_rte(uint8); +short8 __ovld __cnfn convert_short8_rtz(uint8); +short8 __ovld __cnfn convert_short8_sat_rtz(uint8); +short8 __ovld __cnfn convert_short8_rtp(uint8); +short8 __ovld __cnfn convert_short8_sat_rtp(uint8); +short8 __ovld __cnfn convert_short8_rtn(uint8); +short8 __ovld __cnfn convert_short8_sat_rtn(uint8); +short8 __ovld __cnfn convert_short8(uint8); +short8 __ovld __cnfn convert_short8_sat(uint8); +short8 __ovld __cnfn convert_short8_rte(long8); +short8 __ovld __cnfn convert_short8_sat_rte(long8); +short8 __ovld __cnfn convert_short8_rtz(long8); +short8 __ovld __cnfn convert_short8_sat_rtz(long8); +short8 __ovld __cnfn convert_short8_rtp(long8); +short8 __ovld __cnfn convert_short8_sat_rtp(long8); +short8 __ovld __cnfn convert_short8_rtn(long8); +short8 __ovld __cnfn convert_short8_sat_rtn(long8); +short8 __ovld __cnfn convert_short8(long8); +short8 __ovld __cnfn convert_short8_sat(long8); +short8 __ovld __cnfn convert_short8_rte(ulong8); +short8 __ovld __cnfn convert_short8_sat_rte(ulong8); +short8 __ovld __cnfn convert_short8_rtz(ulong8); +short8 __ovld __cnfn convert_short8_sat_rtz(ulong8); +short8 __ovld __cnfn convert_short8_rtp(ulong8); +short8 __ovld __cnfn convert_short8_sat_rtp(ulong8); +short8 __ovld __cnfn convert_short8_rtn(ulong8); +short8 __ovld __cnfn convert_short8_sat_rtn(ulong8); +short8 __ovld __cnfn convert_short8(ulong8); +short8 __ovld __cnfn convert_short8_sat(ulong8); +short8 __ovld __cnfn convert_short8_rte(float8); +short8 __ovld __cnfn convert_short8_sat_rte(float8); +short8 __ovld __cnfn convert_short8_rtz(float8); +short8 __ovld __cnfn convert_short8_sat_rtz(float8); +short8 __ovld __cnfn convert_short8_rtp(float8); +short8 __ovld __cnfn convert_short8_sat_rtp(float8); +short8 __ovld __cnfn convert_short8_rtn(float8); +short8 __ovld __cnfn convert_short8_sat_rtn(float8); +short8 __ovld __cnfn convert_short8(float8); +short8 __ovld __cnfn convert_short8_sat(float8); +ushort8 __ovld __cnfn convert_ushort8_rte(char8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(char8); +ushort8 __ovld __cnfn convert_ushort8_rtz(char8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(char8); +ushort8 __ovld __cnfn convert_ushort8_rtp(char8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(char8); +ushort8 __ovld __cnfn convert_ushort8_rtn(char8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(char8); +ushort8 __ovld __cnfn convert_ushort8(char8); +ushort8 __ovld __cnfn convert_ushort8_sat(char8); +ushort8 __ovld __cnfn convert_ushort8_rte(uchar8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(uchar8); +ushort8 __ovld __cnfn convert_ushort8_rtz(uchar8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(uchar8); +ushort8 __ovld __cnfn convert_ushort8_rtp(uchar8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(uchar8); +ushort8 __ovld __cnfn convert_ushort8_rtn(uchar8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(uchar8); +ushort8 __ovld __cnfn convert_ushort8(uchar8); +ushort8 __ovld __cnfn convert_ushort8_sat(uchar8); +ushort8 __ovld __cnfn convert_ushort8_rte(short8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(short8); +ushort8 __ovld __cnfn convert_ushort8_rtz(short8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(short8); +ushort8 __ovld __cnfn convert_ushort8_rtp(short8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(short8); +ushort8 __ovld __cnfn convert_ushort8_rtn(short8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(short8); +ushort8 __ovld __cnfn convert_ushort8(short8); +ushort8 __ovld __cnfn convert_ushort8_sat(short8); +ushort8 __ovld __cnfn convert_ushort8_rte(ushort8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(ushort8); +ushort8 __ovld __cnfn convert_ushort8_rtz(ushort8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(ushort8); +ushort8 __ovld __cnfn convert_ushort8_rtp(ushort8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(ushort8); +ushort8 __ovld __cnfn convert_ushort8_rtn(ushort8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(ushort8); +ushort8 __ovld __cnfn convert_ushort8(ushort8); +ushort8 __ovld __cnfn convert_ushort8_sat(ushort8); +ushort8 __ovld __cnfn convert_ushort8_rte(int8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(int8); +ushort8 __ovld __cnfn convert_ushort8_rtz(int8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(int8); +ushort8 __ovld __cnfn convert_ushort8_rtp(int8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(int8); +ushort8 __ovld __cnfn convert_ushort8_rtn(int8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(int8); +ushort8 __ovld __cnfn convert_ushort8(int8); +ushort8 __ovld __cnfn convert_ushort8_sat(int8); +ushort8 __ovld __cnfn convert_ushort8_rte(uint8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(uint8); +ushort8 __ovld __cnfn convert_ushort8_rtz(uint8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(uint8); +ushort8 __ovld __cnfn convert_ushort8_rtp(uint8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(uint8); +ushort8 __ovld __cnfn convert_ushort8_rtn(uint8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(uint8); +ushort8 __ovld __cnfn convert_ushort8(uint8); +ushort8 __ovld __cnfn convert_ushort8_sat(uint8); +ushort8 __ovld __cnfn convert_ushort8_rte(long8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(long8); +ushort8 __ovld __cnfn convert_ushort8_rtz(long8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(long8); +ushort8 __ovld __cnfn convert_ushort8_rtp(long8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(long8); +ushort8 __ovld __cnfn convert_ushort8_rtn(long8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(long8); +ushort8 __ovld __cnfn convert_ushort8(long8); +ushort8 __ovld __cnfn convert_ushort8_sat(long8); +ushort8 __ovld __cnfn convert_ushort8_rte(ulong8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(ulong8); +ushort8 __ovld __cnfn convert_ushort8_rtz(ulong8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(ulong8); +ushort8 __ovld __cnfn convert_ushort8_rtp(ulong8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(ulong8); +ushort8 __ovld __cnfn convert_ushort8_rtn(ulong8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(ulong8); +ushort8 __ovld __cnfn convert_ushort8(ulong8); +ushort8 __ovld __cnfn convert_ushort8_sat(ulong8); +ushort8 __ovld __cnfn convert_ushort8_rte(float8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(float8); +ushort8 __ovld __cnfn convert_ushort8_rtz(float8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(float8); +ushort8 __ovld __cnfn convert_ushort8_rtp(float8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(float8); +ushort8 __ovld __cnfn convert_ushort8_rtn(float8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(float8); +ushort8 __ovld __cnfn convert_ushort8(float8); +ushort8 __ovld __cnfn convert_ushort8_sat(float8); +int8 __ovld __cnfn convert_int8_rte(char8); +int8 __ovld __cnfn convert_int8_sat_rte(char8); +int8 __ovld __cnfn convert_int8_rtz(char8); +int8 __ovld __cnfn convert_int8_sat_rtz(char8); +int8 __ovld __cnfn convert_int8_rtp(char8); +int8 __ovld __cnfn convert_int8_sat_rtp(char8); +int8 __ovld __cnfn convert_int8_rtn(char8); +int8 __ovld __cnfn convert_int8_sat_rtn(char8); +int8 __ovld __cnfn convert_int8(char8); +int8 __ovld __cnfn convert_int8_sat(char8); +int8 __ovld __cnfn convert_int8_rte(uchar8); +int8 __ovld __cnfn convert_int8_sat_rte(uchar8); +int8 __ovld __cnfn convert_int8_rtz(uchar8); +int8 __ovld __cnfn convert_int8_sat_rtz(uchar8); +int8 __ovld __cnfn convert_int8_rtp(uchar8); +int8 __ovld __cnfn convert_int8_sat_rtp(uchar8); +int8 __ovld __cnfn convert_int8_rtn(uchar8); +int8 __ovld __cnfn convert_int8_sat_rtn(uchar8); +int8 __ovld __cnfn convert_int8(uchar8); +int8 __ovld __cnfn convert_int8_sat(uchar8); +int8 __ovld __cnfn convert_int8_rte(short8); +int8 __ovld __cnfn convert_int8_sat_rte(short8); +int8 __ovld __cnfn convert_int8_rtz(short8); +int8 __ovld __cnfn convert_int8_sat_rtz(short8); +int8 __ovld __cnfn convert_int8_rtp(short8); +int8 __ovld __cnfn convert_int8_sat_rtp(short8); +int8 __ovld __cnfn convert_int8_rtn(short8); +int8 __ovld __cnfn convert_int8_sat_rtn(short8); +int8 __ovld __cnfn convert_int8(short8); +int8 __ovld __cnfn convert_int8_sat(short8); +int8 __ovld __cnfn convert_int8_rte(ushort8); +int8 __ovld __cnfn convert_int8_sat_rte(ushort8); +int8 __ovld __cnfn convert_int8_rtz(ushort8); +int8 __ovld __cnfn convert_int8_sat_rtz(ushort8); +int8 __ovld __cnfn convert_int8_rtp(ushort8); +int8 __ovld __cnfn convert_int8_sat_rtp(ushort8); +int8 __ovld __cnfn convert_int8_rtn(ushort8); +int8 __ovld __cnfn convert_int8_sat_rtn(ushort8); +int8 __ovld __cnfn convert_int8(ushort8); +int8 __ovld __cnfn convert_int8_sat(ushort8); +int8 __ovld __cnfn convert_int8_rte(int8); +int8 __ovld __cnfn convert_int8_sat_rte(int8); +int8 __ovld __cnfn convert_int8_rtz(int8); +int8 __ovld __cnfn convert_int8_sat_rtz(int8); +int8 __ovld __cnfn convert_int8_rtp(int8); +int8 __ovld __cnfn convert_int8_sat_rtp(int8); +int8 __ovld __cnfn convert_int8_rtn(int8); +int8 __ovld __cnfn convert_int8_sat_rtn(int8); +int8 __ovld __cnfn convert_int8(int8); +int8 __ovld __cnfn convert_int8_sat(int8); +int8 __ovld __cnfn convert_int8_rte(uint8); +int8 __ovld __cnfn convert_int8_sat_rte(uint8); +int8 __ovld __cnfn convert_int8_rtz(uint8); +int8 __ovld __cnfn convert_int8_sat_rtz(uint8); +int8 __ovld __cnfn convert_int8_rtp(uint8); +int8 __ovld __cnfn convert_int8_sat_rtp(uint8); +int8 __ovld __cnfn convert_int8_rtn(uint8); +int8 __ovld __cnfn convert_int8_sat_rtn(uint8); +int8 __ovld __cnfn convert_int8(uint8); +int8 __ovld __cnfn convert_int8_sat(uint8); +int8 __ovld __cnfn convert_int8_rte(long8); +int8 __ovld __cnfn convert_int8_sat_rte(long8); +int8 __ovld __cnfn convert_int8_rtz(long8); +int8 __ovld __cnfn convert_int8_sat_rtz(long8); +int8 __ovld __cnfn convert_int8_rtp(long8); +int8 __ovld __cnfn convert_int8_sat_rtp(long8); +int8 __ovld __cnfn convert_int8_rtn(long8); +int8 __ovld __cnfn convert_int8_sat_rtn(long8); +int8 __ovld __cnfn convert_int8(long8); +int8 __ovld __cnfn convert_int8_sat(long8); +int8 __ovld __cnfn convert_int8_rte(ulong8); +int8 __ovld __cnfn convert_int8_sat_rte(ulong8); +int8 __ovld __cnfn convert_int8_rtz(ulong8); +int8 __ovld __cnfn convert_int8_sat_rtz(ulong8); +int8 __ovld __cnfn convert_int8_rtp(ulong8); +int8 __ovld __cnfn convert_int8_sat_rtp(ulong8); +int8 __ovld __cnfn convert_int8_rtn(ulong8); +int8 __ovld __cnfn convert_int8_sat_rtn(ulong8); +int8 __ovld __cnfn convert_int8(ulong8); +int8 __ovld __cnfn convert_int8_sat(ulong8); +int8 __ovld __cnfn convert_int8_rte(float8); +int8 __ovld __cnfn convert_int8_sat_rte(float8); +int8 __ovld __cnfn convert_int8_rtz(float8); +int8 __ovld __cnfn convert_int8_sat_rtz(float8); +int8 __ovld __cnfn convert_int8_rtp(float8); +int8 __ovld __cnfn convert_int8_sat_rtp(float8); +int8 __ovld __cnfn convert_int8_rtn(float8); +int8 __ovld __cnfn convert_int8_sat_rtn(float8); +int8 __ovld __cnfn convert_int8(float8); +int8 __ovld __cnfn convert_int8_sat(float8); +uint8 __ovld __cnfn convert_uint8_rte(char8); +uint8 __ovld __cnfn convert_uint8_sat_rte(char8); +uint8 __ovld __cnfn convert_uint8_rtz(char8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(char8); +uint8 __ovld __cnfn convert_uint8_rtp(char8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(char8); +uint8 __ovld __cnfn convert_uint8_rtn(char8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(char8); +uint8 __ovld __cnfn convert_uint8(char8); +uint8 __ovld __cnfn convert_uint8_sat(char8); +uint8 __ovld __cnfn convert_uint8_rte(uchar8); +uint8 __ovld __cnfn convert_uint8_sat_rte(uchar8); +uint8 __ovld __cnfn convert_uint8_rtz(uchar8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(uchar8); +uint8 __ovld __cnfn convert_uint8_rtp(uchar8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(uchar8); +uint8 __ovld __cnfn convert_uint8_rtn(uchar8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(uchar8); +uint8 __ovld __cnfn convert_uint8(uchar8); +uint8 __ovld __cnfn convert_uint8_sat(uchar8); +uint8 __ovld __cnfn convert_uint8_rte(short8); +uint8 __ovld __cnfn convert_uint8_sat_rte(short8); +uint8 __ovld __cnfn convert_uint8_rtz(short8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(short8); +uint8 __ovld __cnfn convert_uint8_rtp(short8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(short8); +uint8 __ovld __cnfn convert_uint8_rtn(short8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(short8); +uint8 __ovld __cnfn convert_uint8(short8); +uint8 __ovld __cnfn convert_uint8_sat(short8); +uint8 __ovld __cnfn convert_uint8_rte(ushort8); +uint8 __ovld __cnfn convert_uint8_sat_rte(ushort8); +uint8 __ovld __cnfn convert_uint8_rtz(ushort8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(ushort8); +uint8 __ovld __cnfn convert_uint8_rtp(ushort8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(ushort8); +uint8 __ovld __cnfn convert_uint8_rtn(ushort8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(ushort8); +uint8 __ovld __cnfn convert_uint8(ushort8); +uint8 __ovld __cnfn convert_uint8_sat(ushort8); +uint8 __ovld __cnfn convert_uint8_rte(int8); +uint8 __ovld __cnfn convert_uint8_sat_rte(int8); +uint8 __ovld __cnfn convert_uint8_rtz(int8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(int8); +uint8 __ovld __cnfn convert_uint8_rtp(int8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(int8); +uint8 __ovld __cnfn convert_uint8_rtn(int8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(int8); +uint8 __ovld __cnfn convert_uint8(int8); +uint8 __ovld __cnfn convert_uint8_sat(int8); +uint8 __ovld __cnfn convert_uint8_rte(uint8); +uint8 __ovld __cnfn convert_uint8_sat_rte(uint8); +uint8 __ovld __cnfn convert_uint8_rtz(uint8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(uint8); +uint8 __ovld __cnfn convert_uint8_rtp(uint8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(uint8); +uint8 __ovld __cnfn convert_uint8_rtn(uint8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(uint8); +uint8 __ovld __cnfn convert_uint8(uint8); +uint8 __ovld __cnfn convert_uint8_sat(uint8); +uint8 __ovld __cnfn convert_uint8_rte(long8); +uint8 __ovld __cnfn convert_uint8_sat_rte(long8); +uint8 __ovld __cnfn convert_uint8_rtz(long8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(long8); +uint8 __ovld __cnfn convert_uint8_rtp(long8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(long8); +uint8 __ovld __cnfn convert_uint8_rtn(long8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(long8); +uint8 __ovld __cnfn convert_uint8(long8); +uint8 __ovld __cnfn convert_uint8_sat(long8); +uint8 __ovld __cnfn convert_uint8_rte(ulong8); +uint8 __ovld __cnfn convert_uint8_sat_rte(ulong8); +uint8 __ovld __cnfn convert_uint8_rtz(ulong8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(ulong8); +uint8 __ovld __cnfn convert_uint8_rtp(ulong8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(ulong8); +uint8 __ovld __cnfn convert_uint8_rtn(ulong8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(ulong8); +uint8 __ovld __cnfn convert_uint8(ulong8); +uint8 __ovld __cnfn convert_uint8_sat(ulong8); +uint8 __ovld __cnfn convert_uint8_rte(float8); +uint8 __ovld __cnfn convert_uint8_sat_rte(float8); +uint8 __ovld __cnfn convert_uint8_rtz(float8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(float8); +uint8 __ovld __cnfn convert_uint8_rtp(float8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(float8); +uint8 __ovld __cnfn convert_uint8_rtn(float8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(float8); +uint8 __ovld __cnfn convert_uint8(float8); +uint8 __ovld __cnfn convert_uint8_sat(float8); +long8 __ovld __cnfn convert_long8_rte(char8); +long8 __ovld __cnfn convert_long8_sat_rte(char8); +long8 __ovld __cnfn convert_long8_rtz(char8); +long8 __ovld __cnfn convert_long8_sat_rtz(char8); +long8 __ovld __cnfn convert_long8_rtp(char8); +long8 __ovld __cnfn convert_long8_sat_rtp(char8); +long8 __ovld __cnfn convert_long8_rtn(char8); +long8 __ovld __cnfn convert_long8_sat_rtn(char8); +long8 __ovld __cnfn convert_long8(char8); +long8 __ovld __cnfn convert_long8_sat(char8); +long8 __ovld __cnfn convert_long8_rte(uchar8); +long8 __ovld __cnfn convert_long8_sat_rte(uchar8); +long8 __ovld __cnfn convert_long8_rtz(uchar8); +long8 __ovld __cnfn convert_long8_sat_rtz(uchar8); +long8 __ovld __cnfn convert_long8_rtp(uchar8); +long8 __ovld __cnfn convert_long8_sat_rtp(uchar8); +long8 __ovld __cnfn convert_long8_rtn(uchar8); +long8 __ovld __cnfn convert_long8_sat_rtn(uchar8); +long8 __ovld __cnfn convert_long8(uchar8); +long8 __ovld __cnfn convert_long8_sat(uchar8); +long8 __ovld __cnfn convert_long8_rte(short8); +long8 __ovld __cnfn convert_long8_sat_rte(short8); +long8 __ovld __cnfn convert_long8_rtz(short8); +long8 __ovld __cnfn convert_long8_sat_rtz(short8); +long8 __ovld __cnfn convert_long8_rtp(short8); +long8 __ovld __cnfn convert_long8_sat_rtp(short8); +long8 __ovld __cnfn convert_long8_rtn(short8); +long8 __ovld __cnfn convert_long8_sat_rtn(short8); +long8 __ovld __cnfn convert_long8(short8); +long8 __ovld __cnfn convert_long8_sat(short8); +long8 __ovld __cnfn convert_long8_rte(ushort8); +long8 __ovld __cnfn convert_long8_sat_rte(ushort8); +long8 __ovld __cnfn convert_long8_rtz(ushort8); +long8 __ovld __cnfn convert_long8_sat_rtz(ushort8); +long8 __ovld __cnfn convert_long8_rtp(ushort8); +long8 __ovld __cnfn convert_long8_sat_rtp(ushort8); +long8 __ovld __cnfn convert_long8_rtn(ushort8); +long8 __ovld __cnfn convert_long8_sat_rtn(ushort8); +long8 __ovld __cnfn convert_long8(ushort8); +long8 __ovld __cnfn convert_long8_sat(ushort8); +long8 __ovld __cnfn convert_long8_rte(int8); +long8 __ovld __cnfn convert_long8_sat_rte(int8); +long8 __ovld __cnfn convert_long8_rtz(int8); +long8 __ovld __cnfn convert_long8_sat_rtz(int8); +long8 __ovld __cnfn convert_long8_rtp(int8); +long8 __ovld __cnfn convert_long8_sat_rtp(int8); +long8 __ovld __cnfn convert_long8_rtn(int8); +long8 __ovld __cnfn convert_long8_sat_rtn(int8); +long8 __ovld __cnfn convert_long8(int8); +long8 __ovld __cnfn convert_long8_sat(int8); +long8 __ovld __cnfn convert_long8_rte(uint8); +long8 __ovld __cnfn convert_long8_sat_rte(uint8); +long8 __ovld __cnfn convert_long8_rtz(uint8); +long8 __ovld __cnfn convert_long8_sat_rtz(uint8); +long8 __ovld __cnfn convert_long8_rtp(uint8); +long8 __ovld __cnfn convert_long8_sat_rtp(uint8); +long8 __ovld __cnfn convert_long8_rtn(uint8); +long8 __ovld __cnfn convert_long8_sat_rtn(uint8); +long8 __ovld __cnfn convert_long8(uint8); +long8 __ovld __cnfn convert_long8_sat(uint8); +long8 __ovld __cnfn convert_long8_rte(long8); +long8 __ovld __cnfn convert_long8_sat_rte(long8); +long8 __ovld __cnfn convert_long8_rtz(long8); +long8 __ovld __cnfn convert_long8_sat_rtz(long8); +long8 __ovld __cnfn convert_long8_rtp(long8); +long8 __ovld __cnfn convert_long8_sat_rtp(long8); +long8 __ovld __cnfn convert_long8_rtn(long8); +long8 __ovld __cnfn convert_long8_sat_rtn(long8); +long8 __ovld __cnfn convert_long8(long8); +long8 __ovld __cnfn convert_long8_sat(long8); +long8 __ovld __cnfn convert_long8_rte(ulong8); +long8 __ovld __cnfn convert_long8_sat_rte(ulong8); +long8 __ovld __cnfn convert_long8_rtz(ulong8); +long8 __ovld __cnfn convert_long8_sat_rtz(ulong8); +long8 __ovld __cnfn convert_long8_rtp(ulong8); +long8 __ovld __cnfn convert_long8_sat_rtp(ulong8); +long8 __ovld __cnfn convert_long8_rtn(ulong8); +long8 __ovld __cnfn convert_long8_sat_rtn(ulong8); +long8 __ovld __cnfn convert_long8(ulong8); +long8 __ovld __cnfn convert_long8_sat(ulong8); +long8 __ovld __cnfn convert_long8_rte(float8); +long8 __ovld __cnfn convert_long8_sat_rte(float8); +long8 __ovld __cnfn convert_long8_rtz(float8); +long8 __ovld __cnfn convert_long8_sat_rtz(float8); +long8 __ovld __cnfn convert_long8_rtp(float8); +long8 __ovld __cnfn convert_long8_sat_rtp(float8); +long8 __ovld __cnfn convert_long8_rtn(float8); +long8 __ovld __cnfn convert_long8_sat_rtn(float8); +long8 __ovld __cnfn convert_long8(float8); +long8 __ovld __cnfn convert_long8_sat(float8); +ulong8 __ovld __cnfn convert_ulong8_rte(char8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(char8); +ulong8 __ovld __cnfn convert_ulong8_rtz(char8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(char8); +ulong8 __ovld __cnfn convert_ulong8_rtp(char8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(char8); +ulong8 __ovld __cnfn convert_ulong8_rtn(char8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(char8); +ulong8 __ovld __cnfn convert_ulong8(char8); +ulong8 __ovld __cnfn convert_ulong8_sat(char8); +ulong8 __ovld __cnfn convert_ulong8_rte(uchar8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(uchar8); +ulong8 __ovld __cnfn convert_ulong8_rtz(uchar8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(uchar8); +ulong8 __ovld __cnfn convert_ulong8_rtp(uchar8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(uchar8); +ulong8 __ovld __cnfn convert_ulong8_rtn(uchar8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(uchar8); +ulong8 __ovld __cnfn convert_ulong8(uchar8); +ulong8 __ovld __cnfn convert_ulong8_sat(uchar8); +ulong8 __ovld __cnfn convert_ulong8_rte(short8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(short8); +ulong8 __ovld __cnfn convert_ulong8_rtz(short8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(short8); +ulong8 __ovld __cnfn convert_ulong8_rtp(short8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(short8); +ulong8 __ovld __cnfn convert_ulong8_rtn(short8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(short8); +ulong8 __ovld __cnfn convert_ulong8(short8); +ulong8 __ovld __cnfn convert_ulong8_sat(short8); +ulong8 __ovld __cnfn convert_ulong8_rte(ushort8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(ushort8); +ulong8 __ovld __cnfn convert_ulong8_rtz(ushort8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(ushort8); +ulong8 __ovld __cnfn convert_ulong8_rtp(ushort8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(ushort8); +ulong8 __ovld __cnfn convert_ulong8_rtn(ushort8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(ushort8); +ulong8 __ovld __cnfn convert_ulong8(ushort8); +ulong8 __ovld __cnfn convert_ulong8_sat(ushort8); +ulong8 __ovld __cnfn convert_ulong8_rte(int8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(int8); +ulong8 __ovld __cnfn convert_ulong8_rtz(int8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(int8); +ulong8 __ovld __cnfn convert_ulong8_rtp(int8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(int8); +ulong8 __ovld __cnfn convert_ulong8_rtn(int8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(int8); +ulong8 __ovld __cnfn convert_ulong8(int8); +ulong8 __ovld __cnfn convert_ulong8_sat(int8); +ulong8 __ovld __cnfn convert_ulong8_rte(uint8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(uint8); +ulong8 __ovld __cnfn convert_ulong8_rtz(uint8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(uint8); +ulong8 __ovld __cnfn convert_ulong8_rtp(uint8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(uint8); +ulong8 __ovld __cnfn convert_ulong8_rtn(uint8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(uint8); +ulong8 __ovld __cnfn convert_ulong8(uint8); +ulong8 __ovld __cnfn convert_ulong8_sat(uint8); +ulong8 __ovld __cnfn convert_ulong8_rte(long8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(long8); +ulong8 __ovld __cnfn convert_ulong8_rtz(long8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(long8); +ulong8 __ovld __cnfn convert_ulong8_rtp(long8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(long8); +ulong8 __ovld __cnfn convert_ulong8_rtn(long8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(long8); +ulong8 __ovld __cnfn convert_ulong8(long8); +ulong8 __ovld __cnfn convert_ulong8_sat(long8); +ulong8 __ovld __cnfn convert_ulong8_rte(ulong8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(ulong8); +ulong8 __ovld __cnfn convert_ulong8_rtz(ulong8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(ulong8); +ulong8 __ovld __cnfn convert_ulong8_rtp(ulong8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(ulong8); +ulong8 __ovld __cnfn convert_ulong8_rtn(ulong8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(ulong8); +ulong8 __ovld __cnfn convert_ulong8(ulong8); +ulong8 __ovld __cnfn convert_ulong8_sat(ulong8); +ulong8 __ovld __cnfn convert_ulong8_rte(float8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(float8); +ulong8 __ovld __cnfn convert_ulong8_rtz(float8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(float8); +ulong8 __ovld __cnfn convert_ulong8_rtp(float8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(float8); +ulong8 __ovld __cnfn convert_ulong8_rtn(float8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(float8); +ulong8 __ovld __cnfn convert_ulong8(float8); +ulong8 __ovld __cnfn convert_ulong8_sat(float8); +float8 __ovld __cnfn convert_float8_rte(char8); +float8 __ovld __cnfn convert_float8_rtz(char8); +float8 __ovld __cnfn convert_float8_rtp(char8); +float8 __ovld __cnfn convert_float8_rtn(char8); +float8 __ovld __cnfn convert_float8(char8); +float8 __ovld __cnfn convert_float8_rte(uchar8); +float8 __ovld __cnfn convert_float8_rtz(uchar8); +float8 __ovld __cnfn convert_float8_rtp(uchar8); +float8 __ovld __cnfn convert_float8_rtn(uchar8); +float8 __ovld __cnfn convert_float8(uchar8); +float8 __ovld __cnfn convert_float8_rte(short8); +float8 __ovld __cnfn convert_float8_rtz(short8); +float8 __ovld __cnfn convert_float8_rtp(short8); +float8 __ovld __cnfn convert_float8_rtn(short8); +float8 __ovld __cnfn convert_float8(short8); +float8 __ovld __cnfn convert_float8_rte(ushort8); +float8 __ovld __cnfn convert_float8_rtz(ushort8); +float8 __ovld __cnfn convert_float8_rtp(ushort8); +float8 __ovld __cnfn convert_float8_rtn(ushort8); +float8 __ovld __cnfn convert_float8(ushort8); +float8 __ovld __cnfn convert_float8_rte(int8); +float8 __ovld __cnfn convert_float8_rtz(int8); +float8 __ovld __cnfn convert_float8_rtp(int8); +float8 __ovld __cnfn convert_float8_rtn(int8); +float8 __ovld __cnfn convert_float8(int8); +float8 __ovld __cnfn convert_float8_rte(uint8); +float8 __ovld __cnfn convert_float8_rtz(uint8); +float8 __ovld __cnfn convert_float8_rtp(uint8); +float8 __ovld __cnfn convert_float8_rtn(uint8); +float8 __ovld __cnfn convert_float8(uint8); +float8 __ovld __cnfn convert_float8_rte(long8); +float8 __ovld __cnfn convert_float8_rtz(long8); +float8 __ovld __cnfn convert_float8_rtp(long8); +float8 __ovld __cnfn convert_float8_rtn(long8); +float8 __ovld __cnfn convert_float8(long8); +float8 __ovld __cnfn convert_float8_rte(ulong8); +float8 __ovld __cnfn convert_float8_rtz(ulong8); +float8 __ovld __cnfn convert_float8_rtp(ulong8); +float8 __ovld __cnfn convert_float8_rtn(ulong8); +float8 __ovld __cnfn convert_float8(ulong8); +float8 __ovld __cnfn convert_float8_rte(float8); +float8 __ovld __cnfn convert_float8_rtz(float8); +float8 __ovld __cnfn convert_float8_rtp(float8); +float8 __ovld __cnfn convert_float8_rtn(float8); +float8 __ovld __cnfn convert_float8(float8); +char16 __ovld __cnfn convert_char16_rte(char16); +char16 __ovld __cnfn convert_char16_sat_rte(char16); +char16 __ovld __cnfn convert_char16_rtz(char16); +char16 __ovld __cnfn convert_char16_sat_rtz(char16); +char16 __ovld __cnfn convert_char16_rtp(char16); +char16 __ovld __cnfn convert_char16_sat_rtp(char16); +char16 __ovld __cnfn convert_char16_rtn(char16); +char16 __ovld __cnfn convert_char16_sat_rtn(char16); +char16 __ovld __cnfn convert_char16(char16); +char16 __ovld __cnfn convert_char16_sat(char16); +char16 __ovld __cnfn convert_char16_rte(uchar16); +char16 __ovld __cnfn convert_char16_sat_rte(uchar16); +char16 __ovld __cnfn convert_char16_rtz(uchar16); +char16 __ovld __cnfn convert_char16_sat_rtz(uchar16); +char16 __ovld __cnfn convert_char16_rtp(uchar16); +char16 __ovld __cnfn convert_char16_sat_rtp(uchar16); +char16 __ovld __cnfn convert_char16_rtn(uchar16); +char16 __ovld __cnfn convert_char16_sat_rtn(uchar16); +char16 __ovld __cnfn convert_char16(uchar16); +char16 __ovld __cnfn convert_char16_sat(uchar16); +char16 __ovld __cnfn convert_char16_rte(short16); +char16 __ovld __cnfn convert_char16_sat_rte(short16); +char16 __ovld __cnfn convert_char16_rtz(short16); +char16 __ovld __cnfn convert_char16_sat_rtz(short16); +char16 __ovld __cnfn convert_char16_rtp(short16); +char16 __ovld __cnfn convert_char16_sat_rtp(short16); +char16 __ovld __cnfn convert_char16_rtn(short16); +char16 __ovld __cnfn convert_char16_sat_rtn(short16); +char16 __ovld __cnfn convert_char16(short16); +char16 __ovld __cnfn convert_char16_sat(short16); +char16 __ovld __cnfn convert_char16_rte(ushort16); +char16 __ovld __cnfn convert_char16_sat_rte(ushort16); +char16 __ovld __cnfn convert_char16_rtz(ushort16); +char16 __ovld __cnfn convert_char16_sat_rtz(ushort16); +char16 __ovld __cnfn convert_char16_rtp(ushort16); +char16 __ovld __cnfn convert_char16_sat_rtp(ushort16); +char16 __ovld __cnfn convert_char16_rtn(ushort16); +char16 __ovld __cnfn convert_char16_sat_rtn(ushort16); +char16 __ovld __cnfn convert_char16(ushort16); +char16 __ovld __cnfn convert_char16_sat(ushort16); +char16 __ovld __cnfn convert_char16_rte(int16); +char16 __ovld __cnfn convert_char16_sat_rte(int16); +char16 __ovld __cnfn convert_char16_rtz(int16); +char16 __ovld __cnfn convert_char16_sat_rtz(int16); +char16 __ovld __cnfn convert_char16_rtp(int16); +char16 __ovld __cnfn convert_char16_sat_rtp(int16); +char16 __ovld __cnfn convert_char16_rtn(int16); +char16 __ovld __cnfn convert_char16_sat_rtn(int16); +char16 __ovld __cnfn convert_char16(int16); +char16 __ovld __cnfn convert_char16_sat(int16); +char16 __ovld __cnfn convert_char16_rte(uint16); +char16 __ovld __cnfn convert_char16_sat_rte(uint16); +char16 __ovld __cnfn convert_char16_rtz(uint16); +char16 __ovld __cnfn convert_char16_sat_rtz(uint16); +char16 __ovld __cnfn convert_char16_rtp(uint16); +char16 __ovld __cnfn convert_char16_sat_rtp(uint16); +char16 __ovld __cnfn convert_char16_rtn(uint16); +char16 __ovld __cnfn convert_char16_sat_rtn(uint16); +char16 __ovld __cnfn convert_char16(uint16); +char16 __ovld __cnfn convert_char16_sat(uint16); +char16 __ovld __cnfn convert_char16_rte(long16); +char16 __ovld __cnfn convert_char16_sat_rte(long16); +char16 __ovld __cnfn convert_char16_rtz(long16); +char16 __ovld __cnfn convert_char16_sat_rtz(long16); +char16 __ovld __cnfn convert_char16_rtp(long16); +char16 __ovld __cnfn convert_char16_sat_rtp(long16); +char16 __ovld __cnfn convert_char16_rtn(long16); +char16 __ovld __cnfn convert_char16_sat_rtn(long16); +char16 __ovld __cnfn convert_char16(long16); +char16 __ovld __cnfn convert_char16_sat(long16); +char16 __ovld __cnfn convert_char16_rte(ulong16); +char16 __ovld __cnfn convert_char16_sat_rte(ulong16); +char16 __ovld __cnfn convert_char16_rtz(ulong16); +char16 __ovld __cnfn convert_char16_sat_rtz(ulong16); +char16 __ovld __cnfn convert_char16_rtp(ulong16); +char16 __ovld __cnfn convert_char16_sat_rtp(ulong16); +char16 __ovld __cnfn convert_char16_rtn(ulong16); +char16 __ovld __cnfn convert_char16_sat_rtn(ulong16); +char16 __ovld __cnfn convert_char16(ulong16); +char16 __ovld __cnfn convert_char16_sat(ulong16); +char16 __ovld __cnfn convert_char16_rte(float16); +char16 __ovld __cnfn convert_char16_sat_rte(float16); +char16 __ovld __cnfn convert_char16_rtz(float16); +char16 __ovld __cnfn convert_char16_sat_rtz(float16); +char16 __ovld __cnfn convert_char16_rtp(float16); +char16 __ovld __cnfn convert_char16_sat_rtp(float16); +char16 __ovld __cnfn convert_char16_rtn(float16); +char16 __ovld __cnfn convert_char16_sat_rtn(float16); +char16 __ovld __cnfn convert_char16(float16); +char16 __ovld __cnfn convert_char16_sat(float16); +uchar16 __ovld __cnfn convert_uchar16_rte(char16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(char16); +uchar16 __ovld __cnfn convert_uchar16_rtz(char16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(char16); +uchar16 __ovld __cnfn convert_uchar16_rtp(char16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(char16); +uchar16 __ovld __cnfn convert_uchar16_rtn(char16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(char16); +uchar16 __ovld __cnfn convert_uchar16(char16); +uchar16 __ovld __cnfn convert_uchar16_sat(char16); +uchar16 __ovld __cnfn convert_uchar16_rte(uchar16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(uchar16); +uchar16 __ovld __cnfn convert_uchar16_rtz(uchar16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(uchar16); +uchar16 __ovld __cnfn convert_uchar16_rtp(uchar16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(uchar16); +uchar16 __ovld __cnfn convert_uchar16_rtn(uchar16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(uchar16); +uchar16 __ovld __cnfn convert_uchar16(uchar16); +uchar16 __ovld __cnfn convert_uchar16_sat(uchar16); +uchar16 __ovld __cnfn convert_uchar16_rte(short16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(short16); +uchar16 __ovld __cnfn convert_uchar16_rtz(short16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(short16); +uchar16 __ovld __cnfn convert_uchar16_rtp(short16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(short16); +uchar16 __ovld __cnfn convert_uchar16_rtn(short16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(short16); +uchar16 __ovld __cnfn convert_uchar16(short16); +uchar16 __ovld __cnfn convert_uchar16_sat(short16); +uchar16 __ovld __cnfn convert_uchar16_rte(ushort16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(ushort16); +uchar16 __ovld __cnfn convert_uchar16_rtz(ushort16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(ushort16); +uchar16 __ovld __cnfn convert_uchar16_rtp(ushort16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(ushort16); +uchar16 __ovld __cnfn convert_uchar16_rtn(ushort16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(ushort16); +uchar16 __ovld __cnfn convert_uchar16(ushort16); +uchar16 __ovld __cnfn convert_uchar16_sat(ushort16); +uchar16 __ovld __cnfn convert_uchar16_rte(int16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(int16); +uchar16 __ovld __cnfn convert_uchar16_rtz(int16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(int16); +uchar16 __ovld __cnfn convert_uchar16_rtp(int16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(int16); +uchar16 __ovld __cnfn convert_uchar16_rtn(int16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(int16); +uchar16 __ovld __cnfn convert_uchar16(int16); +uchar16 __ovld __cnfn convert_uchar16_sat(int16); +uchar16 __ovld __cnfn convert_uchar16_rte(uint16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(uint16); +uchar16 __ovld __cnfn convert_uchar16_rtz(uint16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(uint16); +uchar16 __ovld __cnfn convert_uchar16_rtp(uint16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(uint16); +uchar16 __ovld __cnfn convert_uchar16_rtn(uint16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(uint16); +uchar16 __ovld __cnfn convert_uchar16(uint16); +uchar16 __ovld __cnfn convert_uchar16_sat(uint16); +uchar16 __ovld __cnfn convert_uchar16_rte(long16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(long16); +uchar16 __ovld __cnfn convert_uchar16_rtz(long16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(long16); +uchar16 __ovld __cnfn convert_uchar16_rtp(long16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(long16); +uchar16 __ovld __cnfn convert_uchar16_rtn(long16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(long16); +uchar16 __ovld __cnfn convert_uchar16(long16); +uchar16 __ovld __cnfn convert_uchar16_sat(long16); +uchar16 __ovld __cnfn convert_uchar16_rte(ulong16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(ulong16); +uchar16 __ovld __cnfn convert_uchar16_rtz(ulong16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(ulong16); +uchar16 __ovld __cnfn convert_uchar16_rtp(ulong16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(ulong16); +uchar16 __ovld __cnfn convert_uchar16_rtn(ulong16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(ulong16); +uchar16 __ovld __cnfn convert_uchar16(ulong16); +uchar16 __ovld __cnfn convert_uchar16_sat(ulong16); +uchar16 __ovld __cnfn convert_uchar16_rte(float16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(float16); +uchar16 __ovld __cnfn convert_uchar16_rtz(float16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(float16); +uchar16 __ovld __cnfn convert_uchar16_rtp(float16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(float16); +uchar16 __ovld __cnfn convert_uchar16_rtn(float16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(float16); +uchar16 __ovld __cnfn convert_uchar16(float16); +uchar16 __ovld __cnfn convert_uchar16_sat(float16); +short16 __ovld __cnfn convert_short16_rte(char16); +short16 __ovld __cnfn convert_short16_sat_rte(char16); +short16 __ovld __cnfn convert_short16_rtz(char16); +short16 __ovld __cnfn convert_short16_sat_rtz(char16); +short16 __ovld __cnfn convert_short16_rtp(char16); +short16 __ovld __cnfn convert_short16_sat_rtp(char16); +short16 __ovld __cnfn convert_short16_rtn(char16); +short16 __ovld __cnfn convert_short16_sat_rtn(char16); +short16 __ovld __cnfn convert_short16(char16); +short16 __ovld __cnfn convert_short16_sat(char16); +short16 __ovld __cnfn convert_short16_rte(uchar16); +short16 __ovld __cnfn convert_short16_sat_rte(uchar16); +short16 __ovld __cnfn convert_short16_rtz(uchar16); +short16 __ovld __cnfn convert_short16_sat_rtz(uchar16); +short16 __ovld __cnfn convert_short16_rtp(uchar16); +short16 __ovld __cnfn convert_short16_sat_rtp(uchar16); +short16 __ovld __cnfn convert_short16_rtn(uchar16); +short16 __ovld __cnfn convert_short16_sat_rtn(uchar16); +short16 __ovld __cnfn convert_short16(uchar16); +short16 __ovld __cnfn convert_short16_sat(uchar16); +short16 __ovld __cnfn convert_short16_rte(short16); +short16 __ovld __cnfn convert_short16_sat_rte(short16); +short16 __ovld __cnfn convert_short16_rtz(short16); +short16 __ovld __cnfn convert_short16_sat_rtz(short16); +short16 __ovld __cnfn convert_short16_rtp(short16); +short16 __ovld __cnfn convert_short16_sat_rtp(short16); +short16 __ovld __cnfn convert_short16_rtn(short16); +short16 __ovld __cnfn convert_short16_sat_rtn(short16); +short16 __ovld __cnfn convert_short16(short16); +short16 __ovld __cnfn convert_short16_sat(short16); +short16 __ovld __cnfn convert_short16_rte(ushort16); +short16 __ovld __cnfn convert_short16_sat_rte(ushort16); +short16 __ovld __cnfn convert_short16_rtz(ushort16); +short16 __ovld __cnfn convert_short16_sat_rtz(ushort16); +short16 __ovld __cnfn convert_short16_rtp(ushort16); +short16 __ovld __cnfn convert_short16_sat_rtp(ushort16); +short16 __ovld __cnfn convert_short16_rtn(ushort16); +short16 __ovld __cnfn convert_short16_sat_rtn(ushort16); +short16 __ovld __cnfn convert_short16(ushort16); +short16 __ovld __cnfn convert_short16_sat(ushort16); +short16 __ovld __cnfn convert_short16_rte(int16); +short16 __ovld __cnfn convert_short16_sat_rte(int16); +short16 __ovld __cnfn convert_short16_rtz(int16); +short16 __ovld __cnfn convert_short16_sat_rtz(int16); +short16 __ovld __cnfn convert_short16_rtp(int16); +short16 __ovld __cnfn convert_short16_sat_rtp(int16); +short16 __ovld __cnfn convert_short16_rtn(int16); +short16 __ovld __cnfn convert_short16_sat_rtn(int16); +short16 __ovld __cnfn convert_short16(int16); +short16 __ovld __cnfn convert_short16_sat(int16); +short16 __ovld __cnfn convert_short16_rte(uint16); +short16 __ovld __cnfn convert_short16_sat_rte(uint16); +short16 __ovld __cnfn convert_short16_rtz(uint16); +short16 __ovld __cnfn convert_short16_sat_rtz(uint16); +short16 __ovld __cnfn convert_short16_rtp(uint16); +short16 __ovld __cnfn convert_short16_sat_rtp(uint16); +short16 __ovld __cnfn convert_short16_rtn(uint16); +short16 __ovld __cnfn convert_short16_sat_rtn(uint16); +short16 __ovld __cnfn convert_short16(uint16); +short16 __ovld __cnfn convert_short16_sat(uint16); +short16 __ovld __cnfn convert_short16_rte(long16); +short16 __ovld __cnfn convert_short16_sat_rte(long16); +short16 __ovld __cnfn convert_short16_rtz(long16); +short16 __ovld __cnfn convert_short16_sat_rtz(long16); +short16 __ovld __cnfn convert_short16_rtp(long16); +short16 __ovld __cnfn convert_short16_sat_rtp(long16); +short16 __ovld __cnfn convert_short16_rtn(long16); +short16 __ovld __cnfn convert_short16_sat_rtn(long16); +short16 __ovld __cnfn convert_short16(long16); +short16 __ovld __cnfn convert_short16_sat(long16); +short16 __ovld __cnfn convert_short16_rte(ulong16); +short16 __ovld __cnfn convert_short16_sat_rte(ulong16); +short16 __ovld __cnfn convert_short16_rtz(ulong16); +short16 __ovld __cnfn convert_short16_sat_rtz(ulong16); +short16 __ovld __cnfn convert_short16_rtp(ulong16); +short16 __ovld __cnfn convert_short16_sat_rtp(ulong16); +short16 __ovld __cnfn convert_short16_rtn(ulong16); +short16 __ovld __cnfn convert_short16_sat_rtn(ulong16); +short16 __ovld __cnfn convert_short16(ulong16); +short16 __ovld __cnfn convert_short16_sat(ulong16); +short16 __ovld __cnfn convert_short16_rte(float16); +short16 __ovld __cnfn convert_short16_sat_rte(float16); +short16 __ovld __cnfn convert_short16_rtz(float16); +short16 __ovld __cnfn convert_short16_sat_rtz(float16); +short16 __ovld __cnfn convert_short16_rtp(float16); +short16 __ovld __cnfn convert_short16_sat_rtp(float16); +short16 __ovld __cnfn convert_short16_rtn(float16); +short16 __ovld __cnfn convert_short16_sat_rtn(float16); +short16 __ovld __cnfn convert_short16(float16); +short16 __ovld __cnfn convert_short16_sat(float16); +ushort16 __ovld __cnfn convert_ushort16_rte(char16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(char16); +ushort16 __ovld __cnfn convert_ushort16_rtz(char16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(char16); +ushort16 __ovld __cnfn convert_ushort16_rtp(char16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(char16); +ushort16 __ovld __cnfn convert_ushort16_rtn(char16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(char16); +ushort16 __ovld __cnfn convert_ushort16(char16); +ushort16 __ovld __cnfn convert_ushort16_sat(char16); +ushort16 __ovld __cnfn convert_ushort16_rte(uchar16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(uchar16); +ushort16 __ovld __cnfn convert_ushort16_rtz(uchar16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(uchar16); +ushort16 __ovld __cnfn convert_ushort16_rtp(uchar16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(uchar16); +ushort16 __ovld __cnfn convert_ushort16_rtn(uchar16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(uchar16); +ushort16 __ovld __cnfn convert_ushort16(uchar16); +ushort16 __ovld __cnfn convert_ushort16_sat(uchar16); +ushort16 __ovld __cnfn convert_ushort16_rte(short16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(short16); +ushort16 __ovld __cnfn convert_ushort16_rtz(short16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(short16); +ushort16 __ovld __cnfn convert_ushort16_rtp(short16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(short16); +ushort16 __ovld __cnfn convert_ushort16_rtn(short16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(short16); +ushort16 __ovld __cnfn convert_ushort16(short16); +ushort16 __ovld __cnfn convert_ushort16_sat(short16); +ushort16 __ovld __cnfn convert_ushort16_rte(ushort16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(ushort16); +ushort16 __ovld __cnfn convert_ushort16_rtz(ushort16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(ushort16); +ushort16 __ovld __cnfn convert_ushort16_rtp(ushort16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(ushort16); +ushort16 __ovld __cnfn convert_ushort16_rtn(ushort16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(ushort16); +ushort16 __ovld __cnfn convert_ushort16(ushort16); +ushort16 __ovld __cnfn convert_ushort16_sat(ushort16); +ushort16 __ovld __cnfn convert_ushort16_rte(int16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(int16); +ushort16 __ovld __cnfn convert_ushort16_rtz(int16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(int16); +ushort16 __ovld __cnfn convert_ushort16_rtp(int16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(int16); +ushort16 __ovld __cnfn convert_ushort16_rtn(int16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(int16); +ushort16 __ovld __cnfn convert_ushort16(int16); +ushort16 __ovld __cnfn convert_ushort16_sat(int16); +ushort16 __ovld __cnfn convert_ushort16_rte(uint16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(uint16); +ushort16 __ovld __cnfn convert_ushort16_rtz(uint16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(uint16); +ushort16 __ovld __cnfn convert_ushort16_rtp(uint16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(uint16); +ushort16 __ovld __cnfn convert_ushort16_rtn(uint16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(uint16); +ushort16 __ovld __cnfn convert_ushort16(uint16); +ushort16 __ovld __cnfn convert_ushort16_sat(uint16); +ushort16 __ovld __cnfn convert_ushort16_rte(long16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(long16); +ushort16 __ovld __cnfn convert_ushort16_rtz(long16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(long16); +ushort16 __ovld __cnfn convert_ushort16_rtp(long16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(long16); +ushort16 __ovld __cnfn convert_ushort16_rtn(long16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(long16); +ushort16 __ovld __cnfn convert_ushort16(long16); +ushort16 __ovld __cnfn convert_ushort16_sat(long16); +ushort16 __ovld __cnfn convert_ushort16_rte(ulong16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(ulong16); +ushort16 __ovld __cnfn convert_ushort16_rtz(ulong16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(ulong16); +ushort16 __ovld __cnfn convert_ushort16_rtp(ulong16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(ulong16); +ushort16 __ovld __cnfn convert_ushort16_rtn(ulong16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(ulong16); +ushort16 __ovld __cnfn convert_ushort16(ulong16); +ushort16 __ovld __cnfn convert_ushort16_sat(ulong16); +ushort16 __ovld __cnfn convert_ushort16_rte(float16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(float16); +ushort16 __ovld __cnfn convert_ushort16_rtz(float16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(float16); +ushort16 __ovld __cnfn convert_ushort16_rtp(float16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(float16); +ushort16 __ovld __cnfn convert_ushort16_rtn(float16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(float16); +ushort16 __ovld __cnfn convert_ushort16(float16); +ushort16 __ovld __cnfn convert_ushort16_sat(float16); +int16 __ovld __cnfn convert_int16_rte(char16); +int16 __ovld __cnfn convert_int16_sat_rte(char16); +int16 __ovld __cnfn convert_int16_rtz(char16); +int16 __ovld __cnfn convert_int16_sat_rtz(char16); +int16 __ovld __cnfn convert_int16_rtp(char16); +int16 __ovld __cnfn convert_int16_sat_rtp(char16); +int16 __ovld __cnfn convert_int16_rtn(char16); +int16 __ovld __cnfn convert_int16_sat_rtn(char16); +int16 __ovld __cnfn convert_int16(char16); +int16 __ovld __cnfn convert_int16_sat(char16); +int16 __ovld __cnfn convert_int16_rte(uchar16); +int16 __ovld __cnfn convert_int16_sat_rte(uchar16); +int16 __ovld __cnfn convert_int16_rtz(uchar16); +int16 __ovld __cnfn convert_int16_sat_rtz(uchar16); +int16 __ovld __cnfn convert_int16_rtp(uchar16); +int16 __ovld __cnfn convert_int16_sat_rtp(uchar16); +int16 __ovld __cnfn convert_int16_rtn(uchar16); +int16 __ovld __cnfn convert_int16_sat_rtn(uchar16); +int16 __ovld __cnfn convert_int16(uchar16); +int16 __ovld __cnfn convert_int16_sat(uchar16); +int16 __ovld __cnfn convert_int16_rte(short16); +int16 __ovld __cnfn convert_int16_sat_rte(short16); +int16 __ovld __cnfn convert_int16_rtz(short16); +int16 __ovld __cnfn convert_int16_sat_rtz(short16); +int16 __ovld __cnfn convert_int16_rtp(short16); +int16 __ovld __cnfn convert_int16_sat_rtp(short16); +int16 __ovld __cnfn convert_int16_rtn(short16); +int16 __ovld __cnfn convert_int16_sat_rtn(short16); +int16 __ovld __cnfn convert_int16(short16); +int16 __ovld __cnfn convert_int16_sat(short16); +int16 __ovld __cnfn convert_int16_rte(ushort16); +int16 __ovld __cnfn convert_int16_sat_rte(ushort16); +int16 __ovld __cnfn convert_int16_rtz(ushort16); +int16 __ovld __cnfn convert_int16_sat_rtz(ushort16); +int16 __ovld __cnfn convert_int16_rtp(ushort16); +int16 __ovld __cnfn convert_int16_sat_rtp(ushort16); +int16 __ovld __cnfn convert_int16_rtn(ushort16); +int16 __ovld __cnfn convert_int16_sat_rtn(ushort16); +int16 __ovld __cnfn convert_int16(ushort16); +int16 __ovld __cnfn convert_int16_sat(ushort16); +int16 __ovld __cnfn convert_int16_rte(int16); +int16 __ovld __cnfn convert_int16_sat_rte(int16); +int16 __ovld __cnfn convert_int16_rtz(int16); +int16 __ovld __cnfn convert_int16_sat_rtz(int16); +int16 __ovld __cnfn convert_int16_rtp(int16); +int16 __ovld __cnfn convert_int16_sat_rtp(int16); +int16 __ovld __cnfn convert_int16_rtn(int16); +int16 __ovld __cnfn convert_int16_sat_rtn(int16); +int16 __ovld __cnfn convert_int16(int16); +int16 __ovld __cnfn convert_int16_sat(int16); +int16 __ovld __cnfn convert_int16_rte(uint16); +int16 __ovld __cnfn convert_int16_sat_rte(uint16); +int16 __ovld __cnfn convert_int16_rtz(uint16); +int16 __ovld __cnfn convert_int16_sat_rtz(uint16); +int16 __ovld __cnfn convert_int16_rtp(uint16); +int16 __ovld __cnfn convert_int16_sat_rtp(uint16); +int16 __ovld __cnfn convert_int16_rtn(uint16); +int16 __ovld __cnfn convert_int16_sat_rtn(uint16); +int16 __ovld __cnfn convert_int16(uint16); +int16 __ovld __cnfn convert_int16_sat(uint16); +int16 __ovld __cnfn convert_int16_rte(long16); +int16 __ovld __cnfn convert_int16_sat_rte(long16); +int16 __ovld __cnfn convert_int16_rtz(long16); +int16 __ovld __cnfn convert_int16_sat_rtz(long16); +int16 __ovld __cnfn convert_int16_rtp(long16); +int16 __ovld __cnfn convert_int16_sat_rtp(long16); +int16 __ovld __cnfn convert_int16_rtn(long16); +int16 __ovld __cnfn convert_int16_sat_rtn(long16); +int16 __ovld __cnfn convert_int16(long16); +int16 __ovld __cnfn convert_int16_sat(long16); +int16 __ovld __cnfn convert_int16_rte(ulong16); +int16 __ovld __cnfn convert_int16_sat_rte(ulong16); +int16 __ovld __cnfn convert_int16_rtz(ulong16); +int16 __ovld __cnfn convert_int16_sat_rtz(ulong16); +int16 __ovld __cnfn convert_int16_rtp(ulong16); +int16 __ovld __cnfn convert_int16_sat_rtp(ulong16); +int16 __ovld __cnfn convert_int16_rtn(ulong16); +int16 __ovld __cnfn convert_int16_sat_rtn(ulong16); +int16 __ovld __cnfn convert_int16(ulong16); +int16 __ovld __cnfn convert_int16_sat(ulong16); +int16 __ovld __cnfn convert_int16_rte(float16); +int16 __ovld __cnfn convert_int16_sat_rte(float16); +int16 __ovld __cnfn convert_int16_rtz(float16); +int16 __ovld __cnfn convert_int16_sat_rtz(float16); +int16 __ovld __cnfn convert_int16_rtp(float16); +int16 __ovld __cnfn convert_int16_sat_rtp(float16); +int16 __ovld __cnfn convert_int16_rtn(float16); +int16 __ovld __cnfn convert_int16_sat_rtn(float16); +int16 __ovld __cnfn convert_int16(float16); +int16 __ovld __cnfn convert_int16_sat(float16); +uint16 __ovld __cnfn convert_uint16_rte(char16); +uint16 __ovld __cnfn convert_uint16_sat_rte(char16); +uint16 __ovld __cnfn convert_uint16_rtz(char16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(char16); +uint16 __ovld __cnfn convert_uint16_rtp(char16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(char16); +uint16 __ovld __cnfn convert_uint16_rtn(char16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(char16); +uint16 __ovld __cnfn convert_uint16(char16); +uint16 __ovld __cnfn convert_uint16_sat(char16); +uint16 __ovld __cnfn convert_uint16_rte(uchar16); +uint16 __ovld __cnfn convert_uint16_sat_rte(uchar16); +uint16 __ovld __cnfn convert_uint16_rtz(uchar16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(uchar16); +uint16 __ovld __cnfn convert_uint16_rtp(uchar16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(uchar16); +uint16 __ovld __cnfn convert_uint16_rtn(uchar16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(uchar16); +uint16 __ovld __cnfn convert_uint16(uchar16); +uint16 __ovld __cnfn convert_uint16_sat(uchar16); +uint16 __ovld __cnfn convert_uint16_rte(short16); +uint16 __ovld __cnfn convert_uint16_sat_rte(short16); +uint16 __ovld __cnfn convert_uint16_rtz(short16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(short16); +uint16 __ovld __cnfn convert_uint16_rtp(short16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(short16); +uint16 __ovld __cnfn convert_uint16_rtn(short16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(short16); +uint16 __ovld __cnfn convert_uint16(short16); +uint16 __ovld __cnfn convert_uint16_sat(short16); +uint16 __ovld __cnfn convert_uint16_rte(ushort16); +uint16 __ovld __cnfn convert_uint16_sat_rte(ushort16); +uint16 __ovld __cnfn convert_uint16_rtz(ushort16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(ushort16); +uint16 __ovld __cnfn convert_uint16_rtp(ushort16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(ushort16); +uint16 __ovld __cnfn convert_uint16_rtn(ushort16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(ushort16); +uint16 __ovld __cnfn convert_uint16(ushort16); +uint16 __ovld __cnfn convert_uint16_sat(ushort16); +uint16 __ovld __cnfn convert_uint16_rte(int16); +uint16 __ovld __cnfn convert_uint16_sat_rte(int16); +uint16 __ovld __cnfn convert_uint16_rtz(int16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(int16); +uint16 __ovld __cnfn convert_uint16_rtp(int16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(int16); +uint16 __ovld __cnfn convert_uint16_rtn(int16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(int16); +uint16 __ovld __cnfn convert_uint16(int16); +uint16 __ovld __cnfn convert_uint16_sat(int16); +uint16 __ovld __cnfn convert_uint16_rte(uint16); +uint16 __ovld __cnfn convert_uint16_sat_rte(uint16); +uint16 __ovld __cnfn convert_uint16_rtz(uint16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(uint16); +uint16 __ovld __cnfn convert_uint16_rtp(uint16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(uint16); +uint16 __ovld __cnfn convert_uint16_rtn(uint16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(uint16); +uint16 __ovld __cnfn convert_uint16(uint16); +uint16 __ovld __cnfn convert_uint16_sat(uint16); +uint16 __ovld __cnfn convert_uint16_rte(long16); +uint16 __ovld __cnfn convert_uint16_sat_rte(long16); +uint16 __ovld __cnfn convert_uint16_rtz(long16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(long16); +uint16 __ovld __cnfn convert_uint16_rtp(long16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(long16); +uint16 __ovld __cnfn convert_uint16_rtn(long16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(long16); +uint16 __ovld __cnfn convert_uint16(long16); +uint16 __ovld __cnfn convert_uint16_sat(long16); +uint16 __ovld __cnfn convert_uint16_rte(ulong16); +uint16 __ovld __cnfn convert_uint16_sat_rte(ulong16); +uint16 __ovld __cnfn convert_uint16_rtz(ulong16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(ulong16); +uint16 __ovld __cnfn convert_uint16_rtp(ulong16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(ulong16); +uint16 __ovld __cnfn convert_uint16_rtn(ulong16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(ulong16); +uint16 __ovld __cnfn convert_uint16(ulong16); +uint16 __ovld __cnfn convert_uint16_sat(ulong16); +uint16 __ovld __cnfn convert_uint16_rte(float16); +uint16 __ovld __cnfn convert_uint16_sat_rte(float16); +uint16 __ovld __cnfn convert_uint16_rtz(float16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(float16); +uint16 __ovld __cnfn convert_uint16_rtp(float16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(float16); +uint16 __ovld __cnfn convert_uint16_rtn(float16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(float16); +uint16 __ovld __cnfn convert_uint16(float16); +uint16 __ovld __cnfn convert_uint16_sat(float16); +long16 __ovld __cnfn convert_long16_rte(char16); +long16 __ovld __cnfn convert_long16_sat_rte(char16); +long16 __ovld __cnfn convert_long16_rtz(char16); +long16 __ovld __cnfn convert_long16_sat_rtz(char16); +long16 __ovld __cnfn convert_long16_rtp(char16); +long16 __ovld __cnfn convert_long16_sat_rtp(char16); +long16 __ovld __cnfn convert_long16_rtn(char16); +long16 __ovld __cnfn convert_long16_sat_rtn(char16); +long16 __ovld __cnfn convert_long16(char16); +long16 __ovld __cnfn convert_long16_sat(char16); +long16 __ovld __cnfn convert_long16_rte(uchar16); +long16 __ovld __cnfn convert_long16_sat_rte(uchar16); +long16 __ovld __cnfn convert_long16_rtz(uchar16); +long16 __ovld __cnfn convert_long16_sat_rtz(uchar16); +long16 __ovld __cnfn convert_long16_rtp(uchar16); +long16 __ovld __cnfn convert_long16_sat_rtp(uchar16); +long16 __ovld __cnfn convert_long16_rtn(uchar16); +long16 __ovld __cnfn convert_long16_sat_rtn(uchar16); +long16 __ovld __cnfn convert_long16(uchar16); +long16 __ovld __cnfn convert_long16_sat(uchar16); +long16 __ovld __cnfn convert_long16_rte(short16); +long16 __ovld __cnfn convert_long16_sat_rte(short16); +long16 __ovld __cnfn convert_long16_rtz(short16); +long16 __ovld __cnfn convert_long16_sat_rtz(short16); +long16 __ovld __cnfn convert_long16_rtp(short16); +long16 __ovld __cnfn convert_long16_sat_rtp(short16); +long16 __ovld __cnfn convert_long16_rtn(short16); +long16 __ovld __cnfn convert_long16_sat_rtn(short16); +long16 __ovld __cnfn convert_long16(short16); +long16 __ovld __cnfn convert_long16_sat(short16); +long16 __ovld __cnfn convert_long16_rte(ushort16); +long16 __ovld __cnfn convert_long16_sat_rte(ushort16); +long16 __ovld __cnfn convert_long16_rtz(ushort16); +long16 __ovld __cnfn convert_long16_sat_rtz(ushort16); +long16 __ovld __cnfn convert_long16_rtp(ushort16); +long16 __ovld __cnfn convert_long16_sat_rtp(ushort16); +long16 __ovld __cnfn convert_long16_rtn(ushort16); +long16 __ovld __cnfn convert_long16_sat_rtn(ushort16); +long16 __ovld __cnfn convert_long16(ushort16); +long16 __ovld __cnfn convert_long16_sat(ushort16); +long16 __ovld __cnfn convert_long16_rte(int16); +long16 __ovld __cnfn convert_long16_sat_rte(int16); +long16 __ovld __cnfn convert_long16_rtz(int16); +long16 __ovld __cnfn convert_long16_sat_rtz(int16); +long16 __ovld __cnfn convert_long16_rtp(int16); +long16 __ovld __cnfn convert_long16_sat_rtp(int16); +long16 __ovld __cnfn convert_long16_rtn(int16); +long16 __ovld __cnfn convert_long16_sat_rtn(int16); +long16 __ovld __cnfn convert_long16(int16); +long16 __ovld __cnfn convert_long16_sat(int16); +long16 __ovld __cnfn convert_long16_rte(uint16); +long16 __ovld __cnfn convert_long16_sat_rte(uint16); +long16 __ovld __cnfn convert_long16_rtz(uint16); +long16 __ovld __cnfn convert_long16_sat_rtz(uint16); +long16 __ovld __cnfn convert_long16_rtp(uint16); +long16 __ovld __cnfn convert_long16_sat_rtp(uint16); +long16 __ovld __cnfn convert_long16_rtn(uint16); +long16 __ovld __cnfn convert_long16_sat_rtn(uint16); +long16 __ovld __cnfn convert_long16(uint16); +long16 __ovld __cnfn convert_long16_sat(uint16); +long16 __ovld __cnfn convert_long16_rte(long16); +long16 __ovld __cnfn convert_long16_sat_rte(long16); +long16 __ovld __cnfn convert_long16_rtz(long16); +long16 __ovld __cnfn convert_long16_sat_rtz(long16); +long16 __ovld __cnfn convert_long16_rtp(long16); +long16 __ovld __cnfn convert_long16_sat_rtp(long16); +long16 __ovld __cnfn convert_long16_rtn(long16); +long16 __ovld __cnfn convert_long16_sat_rtn(long16); +long16 __ovld __cnfn convert_long16(long16); +long16 __ovld __cnfn convert_long16_sat(long16); +long16 __ovld __cnfn convert_long16_rte(ulong16); +long16 __ovld __cnfn convert_long16_sat_rte(ulong16); +long16 __ovld __cnfn convert_long16_rtz(ulong16); +long16 __ovld __cnfn convert_long16_sat_rtz(ulong16); +long16 __ovld __cnfn convert_long16_rtp(ulong16); +long16 __ovld __cnfn convert_long16_sat_rtp(ulong16); +long16 __ovld __cnfn convert_long16_rtn(ulong16); +long16 __ovld __cnfn convert_long16_sat_rtn(ulong16); +long16 __ovld __cnfn convert_long16(ulong16); +long16 __ovld __cnfn convert_long16_sat(ulong16); +long16 __ovld __cnfn convert_long16_rte(float16); +long16 __ovld __cnfn convert_long16_sat_rte(float16); +long16 __ovld __cnfn convert_long16_rtz(float16); +long16 __ovld __cnfn convert_long16_sat_rtz(float16); +long16 __ovld __cnfn convert_long16_rtp(float16); +long16 __ovld __cnfn convert_long16_sat_rtp(float16); +long16 __ovld __cnfn convert_long16_rtn(float16); +long16 __ovld __cnfn convert_long16_sat_rtn(float16); +long16 __ovld __cnfn convert_long16(float16); +long16 __ovld __cnfn convert_long16_sat(float16); +ulong16 __ovld __cnfn convert_ulong16_rte(char16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(char16); +ulong16 __ovld __cnfn convert_ulong16_rtz(char16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(char16); +ulong16 __ovld __cnfn convert_ulong16_rtp(char16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(char16); +ulong16 __ovld __cnfn convert_ulong16_rtn(char16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(char16); +ulong16 __ovld __cnfn convert_ulong16(char16); +ulong16 __ovld __cnfn convert_ulong16_sat(char16); +ulong16 __ovld __cnfn convert_ulong16_rte(uchar16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(uchar16); +ulong16 __ovld __cnfn convert_ulong16_rtz(uchar16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(uchar16); +ulong16 __ovld __cnfn convert_ulong16_rtp(uchar16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(uchar16); +ulong16 __ovld __cnfn convert_ulong16_rtn(uchar16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(uchar16); +ulong16 __ovld __cnfn convert_ulong16(uchar16); +ulong16 __ovld __cnfn convert_ulong16_sat(uchar16); +ulong16 __ovld __cnfn convert_ulong16_rte(short16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(short16); +ulong16 __ovld __cnfn convert_ulong16_rtz(short16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(short16); +ulong16 __ovld __cnfn convert_ulong16_rtp(short16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(short16); +ulong16 __ovld __cnfn convert_ulong16_rtn(short16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(short16); +ulong16 __ovld __cnfn convert_ulong16(short16); +ulong16 __ovld __cnfn convert_ulong16_sat(short16); +ulong16 __ovld __cnfn convert_ulong16_rte(ushort16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(ushort16); +ulong16 __ovld __cnfn convert_ulong16_rtz(ushort16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(ushort16); +ulong16 __ovld __cnfn convert_ulong16_rtp(ushort16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(ushort16); +ulong16 __ovld __cnfn convert_ulong16_rtn(ushort16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(ushort16); +ulong16 __ovld __cnfn convert_ulong16(ushort16); +ulong16 __ovld __cnfn convert_ulong16_sat(ushort16); +ulong16 __ovld __cnfn convert_ulong16_rte(int16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(int16); +ulong16 __ovld __cnfn convert_ulong16_rtz(int16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(int16); +ulong16 __ovld __cnfn convert_ulong16_rtp(int16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(int16); +ulong16 __ovld __cnfn convert_ulong16_rtn(int16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(int16); +ulong16 __ovld __cnfn convert_ulong16(int16); +ulong16 __ovld __cnfn convert_ulong16_sat(int16); +ulong16 __ovld __cnfn convert_ulong16_rte(uint16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(uint16); +ulong16 __ovld __cnfn convert_ulong16_rtz(uint16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(uint16); +ulong16 __ovld __cnfn convert_ulong16_rtp(uint16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(uint16); +ulong16 __ovld __cnfn convert_ulong16_rtn(uint16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(uint16); +ulong16 __ovld __cnfn convert_ulong16(uint16); +ulong16 __ovld __cnfn convert_ulong16_sat(uint16); +ulong16 __ovld __cnfn convert_ulong16_rte(long16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(long16); +ulong16 __ovld __cnfn convert_ulong16_rtz(long16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(long16); +ulong16 __ovld __cnfn convert_ulong16_rtp(long16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(long16); +ulong16 __ovld __cnfn convert_ulong16_rtn(long16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(long16); +ulong16 __ovld __cnfn convert_ulong16(long16); +ulong16 __ovld __cnfn convert_ulong16_sat(long16); +ulong16 __ovld __cnfn convert_ulong16_rte(ulong16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(ulong16); +ulong16 __ovld __cnfn convert_ulong16_rtz(ulong16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(ulong16); +ulong16 __ovld __cnfn convert_ulong16_rtp(ulong16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(ulong16); +ulong16 __ovld __cnfn convert_ulong16_rtn(ulong16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(ulong16); +ulong16 __ovld __cnfn convert_ulong16(ulong16); +ulong16 __ovld __cnfn convert_ulong16_sat(ulong16); +ulong16 __ovld __cnfn convert_ulong16_rte(float16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(float16); +ulong16 __ovld __cnfn convert_ulong16_rtz(float16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(float16); +ulong16 __ovld __cnfn convert_ulong16_rtp(float16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(float16); +ulong16 __ovld __cnfn convert_ulong16_rtn(float16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(float16); +ulong16 __ovld __cnfn convert_ulong16(float16); +ulong16 __ovld __cnfn convert_ulong16_sat(float16); +float16 __ovld __cnfn convert_float16_rte(char16); +float16 __ovld __cnfn convert_float16_rtz(char16); +float16 __ovld __cnfn convert_float16_rtp(char16); +float16 __ovld __cnfn convert_float16_rtn(char16); +float16 __ovld __cnfn convert_float16(char16); +float16 __ovld __cnfn convert_float16_rte(uchar16); +float16 __ovld __cnfn convert_float16_rtz(uchar16); +float16 __ovld __cnfn convert_float16_rtp(uchar16); +float16 __ovld __cnfn convert_float16_rtn(uchar16); +float16 __ovld __cnfn convert_float16(uchar16); +float16 __ovld __cnfn convert_float16_rte(short16); +float16 __ovld __cnfn convert_float16_rtz(short16); +float16 __ovld __cnfn convert_float16_rtp(short16); +float16 __ovld __cnfn convert_float16_rtn(short16); +float16 __ovld __cnfn convert_float16(short16); +float16 __ovld __cnfn convert_float16_rte(ushort16); +float16 __ovld __cnfn convert_float16_rtz(ushort16); +float16 __ovld __cnfn convert_float16_rtp(ushort16); +float16 __ovld __cnfn convert_float16_rtn(ushort16); +float16 __ovld __cnfn convert_float16(ushort16); +float16 __ovld __cnfn convert_float16_rte(int16); +float16 __ovld __cnfn convert_float16_rtz(int16); +float16 __ovld __cnfn convert_float16_rtp(int16); +float16 __ovld __cnfn convert_float16_rtn(int16); +float16 __ovld __cnfn convert_float16(int16); +float16 __ovld __cnfn convert_float16_rte(uint16); +float16 __ovld __cnfn convert_float16_rtz(uint16); +float16 __ovld __cnfn convert_float16_rtp(uint16); +float16 __ovld __cnfn convert_float16_rtn(uint16); +float16 __ovld __cnfn convert_float16(uint16); +float16 __ovld __cnfn convert_float16_rte(long16); +float16 __ovld __cnfn convert_float16_rtz(long16); +float16 __ovld __cnfn convert_float16_rtp(long16); +float16 __ovld __cnfn convert_float16_rtn(long16); +float16 __ovld __cnfn convert_float16(long16); +float16 __ovld __cnfn convert_float16_rte(ulong16); +float16 __ovld __cnfn convert_float16_rtz(ulong16); +float16 __ovld __cnfn convert_float16_rtp(ulong16); +float16 __ovld __cnfn convert_float16_rtn(ulong16); +float16 __ovld __cnfn convert_float16(ulong16); +float16 __ovld __cnfn convert_float16_rte(float16); +float16 __ovld __cnfn convert_float16_rtz(float16); +float16 __ovld __cnfn convert_float16_rtp(float16); +float16 __ovld __cnfn convert_float16_rtn(float16); +float16 __ovld __cnfn convert_float16(float16); + +// Conversions with double data type parameters or return value. + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +char __ovld __cnfn convert_char(double); +char __ovld __cnfn convert_char_rte(double); +char __ovld __cnfn convert_char_rtn(double); +char __ovld __cnfn convert_char_rtp(double); +char __ovld __cnfn convert_char_rtz(double); +char __ovld __cnfn convert_char_sat(double); +char __ovld __cnfn convert_char_sat_rte(double); +char __ovld __cnfn convert_char_sat_rtn(double); +char __ovld __cnfn convert_char_sat_rtp(double); +char __ovld __cnfn convert_char_sat_rtz(double); +char2 __ovld __cnfn convert_char2(double2); +char2 __ovld __cnfn convert_char2_rte(double2); +char2 __ovld __cnfn convert_char2_rtn(double2); +char2 __ovld __cnfn convert_char2_rtp(double2); +char2 __ovld __cnfn convert_char2_rtz(double2); +char2 __ovld __cnfn convert_char2_sat(double2); +char2 __ovld __cnfn convert_char2_sat_rte(double2); +char2 __ovld __cnfn convert_char2_sat_rtn(double2); +char2 __ovld __cnfn convert_char2_sat_rtp(double2); +char2 __ovld __cnfn convert_char2_sat_rtz(double2); +char3 __ovld __cnfn convert_char3(double3); +char3 __ovld __cnfn convert_char3_rte(double3); +char3 __ovld __cnfn convert_char3_rtn(double3); +char3 __ovld __cnfn convert_char3_rtp(double3); +char3 __ovld __cnfn convert_char3_rtz(double3); +char3 __ovld __cnfn convert_char3_sat(double3); +char3 __ovld __cnfn convert_char3_sat_rte(double3); +char3 __ovld __cnfn convert_char3_sat_rtn(double3); +char3 __ovld __cnfn convert_char3_sat_rtp(double3); +char3 __ovld __cnfn convert_char3_sat_rtz(double3); +char4 __ovld __cnfn convert_char4(double4); +char4 __ovld __cnfn convert_char4_rte(double4); +char4 __ovld __cnfn convert_char4_rtn(double4); +char4 __ovld __cnfn convert_char4_rtp(double4); +char4 __ovld __cnfn convert_char4_rtz(double4); +char4 __ovld __cnfn convert_char4_sat(double4); +char4 __ovld __cnfn convert_char4_sat_rte(double4); +char4 __ovld __cnfn convert_char4_sat_rtn(double4); +char4 __ovld __cnfn convert_char4_sat_rtp(double4); +char4 __ovld __cnfn convert_char4_sat_rtz(double4); +char8 __ovld __cnfn convert_char8(double8); +char8 __ovld __cnfn convert_char8_rte(double8); +char8 __ovld __cnfn convert_char8_rtn(double8); +char8 __ovld __cnfn convert_char8_rtp(double8); +char8 __ovld __cnfn convert_char8_rtz(double8); +char8 __ovld __cnfn convert_char8_sat(double8); +char8 __ovld __cnfn convert_char8_sat_rte(double8); +char8 __ovld __cnfn convert_char8_sat_rtn(double8); +char8 __ovld __cnfn convert_char8_sat_rtp(double8); +char8 __ovld __cnfn convert_char8_sat_rtz(double8); +char16 __ovld __cnfn convert_char16(double16); +char16 __ovld __cnfn convert_char16_rte(double16); +char16 __ovld __cnfn convert_char16_rtn(double16); +char16 __ovld __cnfn convert_char16_rtp(double16); +char16 __ovld __cnfn convert_char16_rtz(double16); +char16 __ovld __cnfn convert_char16_sat(double16); +char16 __ovld __cnfn convert_char16_sat_rte(double16); +char16 __ovld __cnfn convert_char16_sat_rtn(double16); +char16 __ovld __cnfn convert_char16_sat_rtp(double16); +char16 __ovld __cnfn convert_char16_sat_rtz(double16); + +uchar __ovld __cnfn convert_uchar(double); +uchar __ovld __cnfn convert_uchar_rte(double); +uchar __ovld __cnfn convert_uchar_rtn(double); +uchar __ovld __cnfn convert_uchar_rtp(double); +uchar __ovld __cnfn convert_uchar_rtz(double); +uchar __ovld __cnfn convert_uchar_sat(double); +uchar __ovld __cnfn convert_uchar_sat_rte(double); +uchar __ovld __cnfn convert_uchar_sat_rtn(double); +uchar __ovld __cnfn convert_uchar_sat_rtp(double); +uchar __ovld __cnfn convert_uchar_sat_rtz(double); +uchar2 __ovld __cnfn convert_uchar2(double2); +uchar2 __ovld __cnfn convert_uchar2_rte(double2); +uchar2 __ovld __cnfn convert_uchar2_rtn(double2); +uchar2 __ovld __cnfn convert_uchar2_rtp(double2); +uchar2 __ovld __cnfn convert_uchar2_rtz(double2); +uchar2 __ovld __cnfn convert_uchar2_sat(double2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(double2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(double2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(double2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(double2); +uchar3 __ovld __cnfn convert_uchar3(double3); +uchar3 __ovld __cnfn convert_uchar3_rte(double3); +uchar3 __ovld __cnfn convert_uchar3_rtn(double3); +uchar3 __ovld __cnfn convert_uchar3_rtp(double3); +uchar3 __ovld __cnfn convert_uchar3_rtz(double3); +uchar3 __ovld __cnfn convert_uchar3_sat(double3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(double3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(double3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(double3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(double3); +uchar4 __ovld __cnfn convert_uchar4(double4); +uchar4 __ovld __cnfn convert_uchar4_rte(double4); +uchar4 __ovld __cnfn convert_uchar4_rtn(double4); +uchar4 __ovld __cnfn convert_uchar4_rtp(double4); +uchar4 __ovld __cnfn convert_uchar4_rtz(double4); +uchar4 __ovld __cnfn convert_uchar4_sat(double4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(double4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(double4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(double4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(double4); +uchar8 __ovld __cnfn convert_uchar8(double8); +uchar8 __ovld __cnfn convert_uchar8_rte(double8); +uchar8 __ovld __cnfn convert_uchar8_rtn(double8); +uchar8 __ovld __cnfn convert_uchar8_rtp(double8); +uchar8 __ovld __cnfn convert_uchar8_rtz(double8); +uchar8 __ovld __cnfn convert_uchar8_sat(double8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(double8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(double8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(double8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(double8); +uchar16 __ovld __cnfn convert_uchar16(double16); +uchar16 __ovld __cnfn convert_uchar16_rte(double16); +uchar16 __ovld __cnfn convert_uchar16_rtn(double16); +uchar16 __ovld __cnfn convert_uchar16_rtp(double16); +uchar16 __ovld __cnfn convert_uchar16_rtz(double16); +uchar16 __ovld __cnfn convert_uchar16_sat(double16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(double16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(double16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(double16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(double16); + +short __ovld __cnfn convert_short(double); +short __ovld __cnfn convert_short_rte(double); +short __ovld __cnfn convert_short_rtn(double); +short __ovld __cnfn convert_short_rtp(double); +short __ovld __cnfn convert_short_rtz(double); +short __ovld __cnfn convert_short_sat(double); +short __ovld __cnfn convert_short_sat_rte(double); +short __ovld __cnfn convert_short_sat_rtn(double); +short __ovld __cnfn convert_short_sat_rtp(double); +short __ovld __cnfn convert_short_sat_rtz(double); +short2 __ovld __cnfn convert_short2(double2); +short2 __ovld __cnfn convert_short2_rte(double2); +short2 __ovld __cnfn convert_short2_rtn(double2); +short2 __ovld __cnfn convert_short2_rtp(double2); +short2 __ovld __cnfn convert_short2_rtz(double2); +short2 __ovld __cnfn convert_short2_sat(double2); +short2 __ovld __cnfn convert_short2_sat_rte(double2); +short2 __ovld __cnfn convert_short2_sat_rtn(double2); +short2 __ovld __cnfn convert_short2_sat_rtp(double2); +short2 __ovld __cnfn convert_short2_sat_rtz(double2); +short3 __ovld __cnfn convert_short3(double3); +short3 __ovld __cnfn convert_short3_rte(double3); +short3 __ovld __cnfn convert_short3_rtn(double3); +short3 __ovld __cnfn convert_short3_rtp(double3); +short3 __ovld __cnfn convert_short3_rtz(double3); +short3 __ovld __cnfn convert_short3_sat(double3); +short3 __ovld __cnfn convert_short3_sat_rte(double3); +short3 __ovld __cnfn convert_short3_sat_rtn(double3); +short3 __ovld __cnfn convert_short3_sat_rtp(double3); +short3 __ovld __cnfn convert_short3_sat_rtz(double3); +short4 __ovld __cnfn convert_short4(double4); +short4 __ovld __cnfn convert_short4_rte(double4); +short4 __ovld __cnfn convert_short4_rtn(double4); +short4 __ovld __cnfn convert_short4_rtp(double4); +short4 __ovld __cnfn convert_short4_rtz(double4); +short4 __ovld __cnfn convert_short4_sat(double4); +short4 __ovld __cnfn convert_short4_sat_rte(double4); +short4 __ovld __cnfn convert_short4_sat_rtn(double4); +short4 __ovld __cnfn convert_short4_sat_rtp(double4); +short4 __ovld __cnfn convert_short4_sat_rtz(double4); +short8 __ovld __cnfn convert_short8(double8); +short8 __ovld __cnfn convert_short8_rte(double8); +short8 __ovld __cnfn convert_short8_rtn(double8); +short8 __ovld __cnfn convert_short8_rtp(double8); +short8 __ovld __cnfn convert_short8_rtz(double8); +short8 __ovld __cnfn convert_short8_sat(double8); +short8 __ovld __cnfn convert_short8_sat_rte(double8); +short8 __ovld __cnfn convert_short8_sat_rtn(double8); +short8 __ovld __cnfn convert_short8_sat_rtp(double8); +short8 __ovld __cnfn convert_short8_sat_rtz(double8); +short16 __ovld __cnfn convert_short16(double16); +short16 __ovld __cnfn convert_short16_rte(double16); +short16 __ovld __cnfn convert_short16_rtn(double16); +short16 __ovld __cnfn convert_short16_rtp(double16); +short16 __ovld __cnfn convert_short16_rtz(double16); +short16 __ovld __cnfn convert_short16_sat(double16); +short16 __ovld __cnfn convert_short16_sat_rte(double16); +short16 __ovld __cnfn convert_short16_sat_rtn(double16); +short16 __ovld __cnfn convert_short16_sat_rtp(double16); +short16 __ovld __cnfn convert_short16_sat_rtz(double16); + +ushort __ovld __cnfn convert_ushort(double); +ushort __ovld __cnfn convert_ushort_rte(double); +ushort __ovld __cnfn convert_ushort_rtn(double); +ushort __ovld __cnfn convert_ushort_rtp(double); +ushort __ovld __cnfn convert_ushort_rtz(double); +ushort __ovld __cnfn convert_ushort_sat(double); +ushort __ovld __cnfn convert_ushort_sat_rte(double); +ushort __ovld __cnfn convert_ushort_sat_rtn(double); +ushort __ovld __cnfn convert_ushort_sat_rtp(double); +ushort __ovld __cnfn convert_ushort_sat_rtz(double); +ushort2 __ovld __cnfn convert_ushort2(double2); +ushort2 __ovld __cnfn convert_ushort2_rte(double2); +ushort2 __ovld __cnfn convert_ushort2_rtn(double2); +ushort2 __ovld __cnfn convert_ushort2_rtp(double2); +ushort2 __ovld __cnfn convert_ushort2_rtz(double2); +ushort2 __ovld __cnfn convert_ushort2_sat(double2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(double2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(double2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(double2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(double2); +ushort3 __ovld __cnfn convert_ushort3(double3); +ushort3 __ovld __cnfn convert_ushort3_rte(double3); +ushort3 __ovld __cnfn convert_ushort3_rtn(double3); +ushort3 __ovld __cnfn convert_ushort3_rtp(double3); +ushort3 __ovld __cnfn convert_ushort3_rtz(double3); +ushort3 __ovld __cnfn convert_ushort3_sat(double3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(double3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(double3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(double3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(double3); +ushort4 __ovld __cnfn convert_ushort4(double4); +ushort4 __ovld __cnfn convert_ushort4_rte(double4); +ushort4 __ovld __cnfn convert_ushort4_rtn(double4); +ushort4 __ovld __cnfn convert_ushort4_rtp(double4); +ushort4 __ovld __cnfn convert_ushort4_rtz(double4); +ushort4 __ovld __cnfn convert_ushort4_sat(double4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(double4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(double4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(double4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(double4); +ushort8 __ovld __cnfn convert_ushort8(double8); +ushort8 __ovld __cnfn convert_ushort8_rte(double8); +ushort8 __ovld __cnfn convert_ushort8_rtn(double8); +ushort8 __ovld __cnfn convert_ushort8_rtp(double8); +ushort8 __ovld __cnfn convert_ushort8_rtz(double8); +ushort8 __ovld __cnfn convert_ushort8_sat(double8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(double8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(double8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(double8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(double8); +ushort16 __ovld __cnfn convert_ushort16(double16); +ushort16 __ovld __cnfn convert_ushort16_rte(double16); +ushort16 __ovld __cnfn convert_ushort16_rtn(double16); +ushort16 __ovld __cnfn convert_ushort16_rtp(double16); +ushort16 __ovld __cnfn convert_ushort16_rtz(double16); +ushort16 __ovld __cnfn convert_ushort16_sat(double16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(double16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(double16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(double16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(double16); + +int __ovld __cnfn convert_int(double); +int __ovld __cnfn convert_int_rte(double); +int __ovld __cnfn convert_int_rtn(double); +int __ovld __cnfn convert_int_rtp(double); +int __ovld __cnfn convert_int_rtz(double); +int __ovld __cnfn convert_int_sat(double); +int __ovld __cnfn convert_int_sat_rte(double); +int __ovld __cnfn convert_int_sat_rtn(double); +int __ovld __cnfn convert_int_sat_rtp(double); +int __ovld __cnfn convert_int_sat_rtz(double); +int2 __ovld __cnfn convert_int2(double2); +int2 __ovld __cnfn convert_int2_rte(double2); +int2 __ovld __cnfn convert_int2_rtn(double2); +int2 __ovld __cnfn convert_int2_rtp(double2); +int2 __ovld __cnfn convert_int2_rtz(double2); +int2 __ovld __cnfn convert_int2_sat(double2); +int2 __ovld __cnfn convert_int2_sat_rte(double2); +int2 __ovld __cnfn convert_int2_sat_rtn(double2); +int2 __ovld __cnfn convert_int2_sat_rtp(double2); +int2 __ovld __cnfn convert_int2_sat_rtz(double2); +int3 __ovld __cnfn convert_int3(double3); +int3 __ovld __cnfn convert_int3_rte(double3); +int3 __ovld __cnfn convert_int3_rtn(double3); +int3 __ovld __cnfn convert_int3_rtp(double3); +int3 __ovld __cnfn convert_int3_rtz(double3); +int3 __ovld __cnfn convert_int3_sat(double3); +int3 __ovld __cnfn convert_int3_sat_rte(double3); +int3 __ovld __cnfn convert_int3_sat_rtn(double3); +int3 __ovld __cnfn convert_int3_sat_rtp(double3); +int3 __ovld __cnfn convert_int3_sat_rtz(double3); +int4 __ovld __cnfn convert_int4(double4); +int4 __ovld __cnfn convert_int4_rte(double4); +int4 __ovld __cnfn convert_int4_rtn(double4); +int4 __ovld __cnfn convert_int4_rtp(double4); +int4 __ovld __cnfn convert_int4_rtz(double4); +int4 __ovld __cnfn convert_int4_sat(double4); +int4 __ovld __cnfn convert_int4_sat_rte(double4); +int4 __ovld __cnfn convert_int4_sat_rtn(double4); +int4 __ovld __cnfn convert_int4_sat_rtp(double4); +int4 __ovld __cnfn convert_int4_sat_rtz(double4); +int8 __ovld __cnfn convert_int8(double8); +int8 __ovld __cnfn convert_int8_rte(double8); +int8 __ovld __cnfn convert_int8_rtn(double8); +int8 __ovld __cnfn convert_int8_rtp(double8); +int8 __ovld __cnfn convert_int8_rtz(double8); +int8 __ovld __cnfn convert_int8_sat(double8); +int8 __ovld __cnfn convert_int8_sat_rte(double8); +int8 __ovld __cnfn convert_int8_sat_rtn(double8); +int8 __ovld __cnfn convert_int8_sat_rtp(double8); +int8 __ovld __cnfn convert_int8_sat_rtz(double8); +int16 __ovld __cnfn convert_int16(double16); +int16 __ovld __cnfn convert_int16_rte(double16); +int16 __ovld __cnfn convert_int16_rtn(double16); +int16 __ovld __cnfn convert_int16_rtp(double16); +int16 __ovld __cnfn convert_int16_rtz(double16); +int16 __ovld __cnfn convert_int16_sat(double16); +int16 __ovld __cnfn convert_int16_sat_rte(double16); +int16 __ovld __cnfn convert_int16_sat_rtn(double16); +int16 __ovld __cnfn convert_int16_sat_rtp(double16); +int16 __ovld __cnfn convert_int16_sat_rtz(double16); + +uint __ovld __cnfn convert_uint(double); +uint __ovld __cnfn convert_uint_rte(double); +uint __ovld __cnfn convert_uint_rtn(double); +uint __ovld __cnfn convert_uint_rtp(double); +uint __ovld __cnfn convert_uint_rtz(double); +uint __ovld __cnfn convert_uint_sat(double); +uint __ovld __cnfn convert_uint_sat_rte(double); +uint __ovld __cnfn convert_uint_sat_rtn(double); +uint __ovld __cnfn convert_uint_sat_rtp(double); +uint __ovld __cnfn convert_uint_sat_rtz(double); +uint2 __ovld __cnfn convert_uint2(double2); +uint2 __ovld __cnfn convert_uint2_rte(double2); +uint2 __ovld __cnfn convert_uint2_rtn(double2); +uint2 __ovld __cnfn convert_uint2_rtp(double2); +uint2 __ovld __cnfn convert_uint2_rtz(double2); +uint2 __ovld __cnfn convert_uint2_sat(double2); +uint2 __ovld __cnfn convert_uint2_sat_rte(double2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(double2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(double2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(double2); +uint3 __ovld __cnfn convert_uint3(double3); +uint3 __ovld __cnfn convert_uint3_rte(double3); +uint3 __ovld __cnfn convert_uint3_rtn(double3); +uint3 __ovld __cnfn convert_uint3_rtp(double3); +uint3 __ovld __cnfn convert_uint3_rtz(double3); +uint3 __ovld __cnfn convert_uint3_sat(double3); +uint3 __ovld __cnfn convert_uint3_sat_rte(double3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(double3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(double3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(double3); +uint4 __ovld __cnfn convert_uint4(double4); +uint4 __ovld __cnfn convert_uint4_rte(double4); +uint4 __ovld __cnfn convert_uint4_rtn(double4); +uint4 __ovld __cnfn convert_uint4_rtp(double4); +uint4 __ovld __cnfn convert_uint4_rtz(double4); +uint4 __ovld __cnfn convert_uint4_sat(double4); +uint4 __ovld __cnfn convert_uint4_sat_rte(double4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(double4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(double4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(double4); +uint8 __ovld __cnfn convert_uint8(double8); +uint8 __ovld __cnfn convert_uint8_rte(double8); +uint8 __ovld __cnfn convert_uint8_rtn(double8); +uint8 __ovld __cnfn convert_uint8_rtp(double8); +uint8 __ovld __cnfn convert_uint8_rtz(double8); +uint8 __ovld __cnfn convert_uint8_sat(double8); +uint8 __ovld __cnfn convert_uint8_sat_rte(double8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(double8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(double8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(double8); +uint16 __ovld __cnfn convert_uint16(double16); +uint16 __ovld __cnfn convert_uint16_rte(double16); +uint16 __ovld __cnfn convert_uint16_rtn(double16); +uint16 __ovld __cnfn convert_uint16_rtp(double16); +uint16 __ovld __cnfn convert_uint16_rtz(double16); +uint16 __ovld __cnfn convert_uint16_sat(double16); +uint16 __ovld __cnfn convert_uint16_sat_rte(double16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(double16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(double16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(double16); + +long __ovld __cnfn convert_long(double); +long __ovld __cnfn convert_long_rte(double); +long __ovld __cnfn convert_long_rtn(double); +long __ovld __cnfn convert_long_rtp(double); +long __ovld __cnfn convert_long_rtz(double); +long __ovld __cnfn convert_long_sat(double); +long __ovld __cnfn convert_long_sat_rte(double); +long __ovld __cnfn convert_long_sat_rtn(double); +long __ovld __cnfn convert_long_sat_rtp(double); +long __ovld __cnfn convert_long_sat_rtz(double); +long2 __ovld __cnfn convert_long2(double2); +long2 __ovld __cnfn convert_long2_rte(double2); +long2 __ovld __cnfn convert_long2_rtn(double2); +long2 __ovld __cnfn convert_long2_rtp(double2); +long2 __ovld __cnfn convert_long2_rtz(double2); +long2 __ovld __cnfn convert_long2_sat(double2); +long2 __ovld __cnfn convert_long2_sat_rte(double2); +long2 __ovld __cnfn convert_long2_sat_rtn(double2); +long2 __ovld __cnfn convert_long2_sat_rtp(double2); +long2 __ovld __cnfn convert_long2_sat_rtz(double2); +long3 __ovld __cnfn convert_long3(double3); +long3 __ovld __cnfn convert_long3_rte(double3); +long3 __ovld __cnfn convert_long3_rtn(double3); +long3 __ovld __cnfn convert_long3_rtp(double3); +long3 __ovld __cnfn convert_long3_rtz(double3); +long3 __ovld __cnfn convert_long3_sat(double3); +long3 __ovld __cnfn convert_long3_sat_rte(double3); +long3 __ovld __cnfn convert_long3_sat_rtn(double3); +long3 __ovld __cnfn convert_long3_sat_rtp(double3); +long3 __ovld __cnfn convert_long3_sat_rtz(double3); +long4 __ovld __cnfn convert_long4(double4); +long4 __ovld __cnfn convert_long4_rte(double4); +long4 __ovld __cnfn convert_long4_rtn(double4); +long4 __ovld __cnfn convert_long4_rtp(double4); +long4 __ovld __cnfn convert_long4_rtz(double4); +long4 __ovld __cnfn convert_long4_sat(double4); +long4 __ovld __cnfn convert_long4_sat_rte(double4); +long4 __ovld __cnfn convert_long4_sat_rtn(double4); +long4 __ovld __cnfn convert_long4_sat_rtp(double4); +long4 __ovld __cnfn convert_long4_sat_rtz(double4); +long8 __ovld __cnfn convert_long8(double8); +long8 __ovld __cnfn convert_long8_rte(double8); +long8 __ovld __cnfn convert_long8_rtn(double8); +long8 __ovld __cnfn convert_long8_rtp(double8); +long8 __ovld __cnfn convert_long8_rtz(double8); +long8 __ovld __cnfn convert_long8_sat(double8); +long8 __ovld __cnfn convert_long8_sat_rte(double8); +long8 __ovld __cnfn convert_long8_sat_rtn(double8); +long8 __ovld __cnfn convert_long8_sat_rtp(double8); +long8 __ovld __cnfn convert_long8_sat_rtz(double8); +long16 __ovld __cnfn convert_long16(double16); +long16 __ovld __cnfn convert_long16_rte(double16); +long16 __ovld __cnfn convert_long16_rtn(double16); +long16 __ovld __cnfn convert_long16_rtp(double16); +long16 __ovld __cnfn convert_long16_rtz(double16); +long16 __ovld __cnfn convert_long16_sat(double16); +long16 __ovld __cnfn convert_long16_sat_rte(double16); +long16 __ovld __cnfn convert_long16_sat_rtn(double16); +long16 __ovld __cnfn convert_long16_sat_rtp(double16); +long16 __ovld __cnfn convert_long16_sat_rtz(double16); + +ulong __ovld __cnfn convert_ulong(double); +ulong __ovld __cnfn convert_ulong_rte(double); +ulong __ovld __cnfn convert_ulong_rtn(double); +ulong __ovld __cnfn convert_ulong_rtp(double); +ulong __ovld __cnfn convert_ulong_rtz(double); +ulong __ovld __cnfn convert_ulong_sat(double); +ulong __ovld __cnfn convert_ulong_sat_rte(double); +ulong __ovld __cnfn convert_ulong_sat_rtn(double); +ulong __ovld __cnfn convert_ulong_sat_rtp(double); +ulong __ovld __cnfn convert_ulong_sat_rtz(double); +ulong2 __ovld __cnfn convert_ulong2(double2); +ulong2 __ovld __cnfn convert_ulong2_rte(double2); +ulong2 __ovld __cnfn convert_ulong2_rtn(double2); +ulong2 __ovld __cnfn convert_ulong2_rtp(double2); +ulong2 __ovld __cnfn convert_ulong2_rtz(double2); +ulong2 __ovld __cnfn convert_ulong2_sat(double2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(double2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(double2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(double2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(double2); +ulong3 __ovld __cnfn convert_ulong3(double3); +ulong3 __ovld __cnfn convert_ulong3_rte(double3); +ulong3 __ovld __cnfn convert_ulong3_rtn(double3); +ulong3 __ovld __cnfn convert_ulong3_rtp(double3); +ulong3 __ovld __cnfn convert_ulong3_rtz(double3); +ulong3 __ovld __cnfn convert_ulong3_sat(double3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(double3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(double3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(double3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(double3); +ulong4 __ovld __cnfn convert_ulong4(double4); +ulong4 __ovld __cnfn convert_ulong4_rte(double4); +ulong4 __ovld __cnfn convert_ulong4_rtn(double4); +ulong4 __ovld __cnfn convert_ulong4_rtp(double4); +ulong4 __ovld __cnfn convert_ulong4_rtz(double4); +ulong4 __ovld __cnfn convert_ulong4_sat(double4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(double4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(double4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(double4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(double4); +ulong8 __ovld __cnfn convert_ulong8(double8); +ulong8 __ovld __cnfn convert_ulong8_rte(double8); +ulong8 __ovld __cnfn convert_ulong8_rtn(double8); +ulong8 __ovld __cnfn convert_ulong8_rtp(double8); +ulong8 __ovld __cnfn convert_ulong8_rtz(double8); +ulong8 __ovld __cnfn convert_ulong8_sat(double8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(double8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(double8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(double8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(double8); +ulong16 __ovld __cnfn convert_ulong16(double16); +ulong16 __ovld __cnfn convert_ulong16_rte(double16); +ulong16 __ovld __cnfn convert_ulong16_rtn(double16); +ulong16 __ovld __cnfn convert_ulong16_rtp(double16); +ulong16 __ovld __cnfn convert_ulong16_rtz(double16); +ulong16 __ovld __cnfn convert_ulong16_sat(double16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(double16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(double16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(double16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(double16); + +float __ovld __cnfn convert_float(double); +float __ovld __cnfn convert_float_rte(double); +float __ovld __cnfn convert_float_rtn(double); +float __ovld __cnfn convert_float_rtp(double); +float __ovld __cnfn convert_float_rtz(double); +float2 __ovld __cnfn convert_float2(double2); +float2 __ovld __cnfn convert_float2_rte(double2); +float2 __ovld __cnfn convert_float2_rtn(double2); +float2 __ovld __cnfn convert_float2_rtp(double2); +float2 __ovld __cnfn convert_float2_rtz(double2); +float3 __ovld __cnfn convert_float3(double3); +float3 __ovld __cnfn convert_float3_rte(double3); +float3 __ovld __cnfn convert_float3_rtn(double3); +float3 __ovld __cnfn convert_float3_rtp(double3); +float3 __ovld __cnfn convert_float3_rtz(double3); +float4 __ovld __cnfn convert_float4(double4); +float4 __ovld __cnfn convert_float4_rte(double4); +float4 __ovld __cnfn convert_float4_rtn(double4); +float4 __ovld __cnfn convert_float4_rtp(double4); +float4 __ovld __cnfn convert_float4_rtz(double4); +float8 __ovld __cnfn convert_float8(double8); +float8 __ovld __cnfn convert_float8_rte(double8); +float8 __ovld __cnfn convert_float8_rtn(double8); +float8 __ovld __cnfn convert_float8_rtp(double8); +float8 __ovld __cnfn convert_float8_rtz(double8); +float16 __ovld __cnfn convert_float16(double16); +float16 __ovld __cnfn convert_float16_rte(double16); +float16 __ovld __cnfn convert_float16_rtn(double16); +float16 __ovld __cnfn convert_float16_rtp(double16); +float16 __ovld __cnfn convert_float16_rtz(double16); + +double __ovld __cnfn convert_double(char); +double __ovld __cnfn convert_double(double); +double __ovld __cnfn convert_double(float); +double __ovld __cnfn convert_double(int); +double __ovld __cnfn convert_double(long); +double __ovld __cnfn convert_double(short); +double __ovld __cnfn convert_double(uchar); +double __ovld __cnfn convert_double(uint); +double __ovld __cnfn convert_double(ulong); +double __ovld __cnfn convert_double(ushort); +double __ovld __cnfn convert_double_rte(char); +double __ovld __cnfn convert_double_rte(double); +double __ovld __cnfn convert_double_rte(float); +double __ovld __cnfn convert_double_rte(int); +double __ovld __cnfn convert_double_rte(long); +double __ovld __cnfn convert_double_rte(short); +double __ovld __cnfn convert_double_rte(uchar); +double __ovld __cnfn convert_double_rte(uint); +double __ovld __cnfn convert_double_rte(ulong); +double __ovld __cnfn convert_double_rte(ushort); +double __ovld __cnfn convert_double_rtn(char); +double __ovld __cnfn convert_double_rtn(double); +double __ovld __cnfn convert_double_rtn(float); +double __ovld __cnfn convert_double_rtn(int); +double __ovld __cnfn convert_double_rtn(long); +double __ovld __cnfn convert_double_rtn(short); +double __ovld __cnfn convert_double_rtn(uchar); +double __ovld __cnfn convert_double_rtn(uint); +double __ovld __cnfn convert_double_rtn(ulong); +double __ovld __cnfn convert_double_rtn(ushort); +double __ovld __cnfn convert_double_rtp(char); +double __ovld __cnfn convert_double_rtp(double); +double __ovld __cnfn convert_double_rtp(float); +double __ovld __cnfn convert_double_rtp(int); +double __ovld __cnfn convert_double_rtp(long); +double __ovld __cnfn convert_double_rtp(short); +double __ovld __cnfn convert_double_rtp(uchar); +double __ovld __cnfn convert_double_rtp(uint); +double __ovld __cnfn convert_double_rtp(ulong); +double __ovld __cnfn convert_double_rtp(ushort); +double __ovld __cnfn convert_double_rtz(char); +double __ovld __cnfn convert_double_rtz(double); +double __ovld __cnfn convert_double_rtz(float); +double __ovld __cnfn convert_double_rtz(int); +double __ovld __cnfn convert_double_rtz(long); +double __ovld __cnfn convert_double_rtz(short); +double __ovld __cnfn convert_double_rtz(uchar); +double __ovld __cnfn convert_double_rtz(uint); +double __ovld __cnfn convert_double_rtz(ulong); +double __ovld __cnfn convert_double_rtz(ushort); +double2 __ovld __cnfn convert_double2(char2); +double2 __ovld __cnfn convert_double2(double2); +double2 __ovld __cnfn convert_double2(float2); +double2 __ovld __cnfn convert_double2(int2); +double2 __ovld __cnfn convert_double2(long2); +double2 __ovld __cnfn convert_double2(short2); +double2 __ovld __cnfn convert_double2(uchar2); +double2 __ovld __cnfn convert_double2(uint2); +double2 __ovld __cnfn convert_double2(ulong2); +double2 __ovld __cnfn convert_double2(ushort2); +double2 __ovld __cnfn convert_double2_rte(char2); +double2 __ovld __cnfn convert_double2_rte(double2); +double2 __ovld __cnfn convert_double2_rte(float2); +double2 __ovld __cnfn convert_double2_rte(int2); +double2 __ovld __cnfn convert_double2_rte(long2); +double2 __ovld __cnfn convert_double2_rte(short2); +double2 __ovld __cnfn convert_double2_rte(uchar2); +double2 __ovld __cnfn convert_double2_rte(uint2); +double2 __ovld __cnfn convert_double2_rte(ulong2); +double2 __ovld __cnfn convert_double2_rte(ushort2); +double2 __ovld __cnfn convert_double2_rtn(char2); +double2 __ovld __cnfn convert_double2_rtn(double2); +double2 __ovld __cnfn convert_double2_rtn(float2); +double2 __ovld __cnfn convert_double2_rtn(int2); +double2 __ovld __cnfn convert_double2_rtn(long2); +double2 __ovld __cnfn convert_double2_rtn(short2); +double2 __ovld __cnfn convert_double2_rtn(uchar2); +double2 __ovld __cnfn convert_double2_rtn(uint2); +double2 __ovld __cnfn convert_double2_rtn(ulong2); +double2 __ovld __cnfn convert_double2_rtn(ushort2); +double2 __ovld __cnfn convert_double2_rtp(char2); +double2 __ovld __cnfn convert_double2_rtp(double2); +double2 __ovld __cnfn convert_double2_rtp(float2); +double2 __ovld __cnfn convert_double2_rtp(int2); +double2 __ovld __cnfn convert_double2_rtp(long2); +double2 __ovld __cnfn convert_double2_rtp(short2); +double2 __ovld __cnfn convert_double2_rtp(uchar2); +double2 __ovld __cnfn convert_double2_rtp(uint2); +double2 __ovld __cnfn convert_double2_rtp(ulong2); +double2 __ovld __cnfn convert_double2_rtp(ushort2); +double2 __ovld __cnfn convert_double2_rtz(char2); +double2 __ovld __cnfn convert_double2_rtz(double2); +double2 __ovld __cnfn convert_double2_rtz(float2); +double2 __ovld __cnfn convert_double2_rtz(int2); +double2 __ovld __cnfn convert_double2_rtz(long2); +double2 __ovld __cnfn convert_double2_rtz(short2); +double2 __ovld __cnfn convert_double2_rtz(uchar2); +double2 __ovld __cnfn convert_double2_rtz(uint2); +double2 __ovld __cnfn convert_double2_rtz(ulong2); +double2 __ovld __cnfn convert_double2_rtz(ushort2); +double3 __ovld __cnfn convert_double3(char3); +double3 __ovld __cnfn convert_double3(double3); +double3 __ovld __cnfn convert_double3(float3); +double3 __ovld __cnfn convert_double3(int3); +double3 __ovld __cnfn convert_double3(long3); +double3 __ovld __cnfn convert_double3(short3); +double3 __ovld __cnfn convert_double3(uchar3); +double3 __ovld __cnfn convert_double3(uint3); +double3 __ovld __cnfn convert_double3(ulong3); +double3 __ovld __cnfn convert_double3(ushort3); +double3 __ovld __cnfn convert_double3_rte(char3); +double3 __ovld __cnfn convert_double3_rte(double3); +double3 __ovld __cnfn convert_double3_rte(float3); +double3 __ovld __cnfn convert_double3_rte(int3); +double3 __ovld __cnfn convert_double3_rte(long3); +double3 __ovld __cnfn convert_double3_rte(short3); +double3 __ovld __cnfn convert_double3_rte(uchar3); +double3 __ovld __cnfn convert_double3_rte(uint3); +double3 __ovld __cnfn convert_double3_rte(ulong3); +double3 __ovld __cnfn convert_double3_rte(ushort3); +double3 __ovld __cnfn convert_double3_rtn(char3); +double3 __ovld __cnfn convert_double3_rtn(double3); +double3 __ovld __cnfn convert_double3_rtn(float3); +double3 __ovld __cnfn convert_double3_rtn(int3); +double3 __ovld __cnfn convert_double3_rtn(long3); +double3 __ovld __cnfn convert_double3_rtn(short3); +double3 __ovld __cnfn convert_double3_rtn(uchar3); +double3 __ovld __cnfn convert_double3_rtn(uint3); +double3 __ovld __cnfn convert_double3_rtn(ulong3); +double3 __ovld __cnfn convert_double3_rtn(ushort3); +double3 __ovld __cnfn convert_double3_rtp(char3); +double3 __ovld __cnfn convert_double3_rtp(double3); +double3 __ovld __cnfn convert_double3_rtp(float3); +double3 __ovld __cnfn convert_double3_rtp(int3); +double3 __ovld __cnfn convert_double3_rtp(long3); +double3 __ovld __cnfn convert_double3_rtp(short3); +double3 __ovld __cnfn convert_double3_rtp(uchar3); +double3 __ovld __cnfn convert_double3_rtp(uint3); +double3 __ovld __cnfn convert_double3_rtp(ulong3); +double3 __ovld __cnfn convert_double3_rtp(ushort3); +double3 __ovld __cnfn convert_double3_rtz(char3); +double3 __ovld __cnfn convert_double3_rtz(double3); +double3 __ovld __cnfn convert_double3_rtz(float3); +double3 __ovld __cnfn convert_double3_rtz(int3); +double3 __ovld __cnfn convert_double3_rtz(long3); +double3 __ovld __cnfn convert_double3_rtz(short3); +double3 __ovld __cnfn convert_double3_rtz(uchar3); +double3 __ovld __cnfn convert_double3_rtz(uint3); +double3 __ovld __cnfn convert_double3_rtz(ulong3); +double3 __ovld __cnfn convert_double3_rtz(ushort3); +double4 __ovld __cnfn convert_double4(char4); +double4 __ovld __cnfn convert_double4(double4); +double4 __ovld __cnfn convert_double4(float4); +double4 __ovld __cnfn convert_double4(int4); +double4 __ovld __cnfn convert_double4(long4); +double4 __ovld __cnfn convert_double4(short4); +double4 __ovld __cnfn convert_double4(uchar4); +double4 __ovld __cnfn convert_double4(uint4); +double4 __ovld __cnfn convert_double4(ulong4); +double4 __ovld __cnfn convert_double4(ushort4); +double4 __ovld __cnfn convert_double4_rte(char4); +double4 __ovld __cnfn convert_double4_rte(double4); +double4 __ovld __cnfn convert_double4_rte(float4); +double4 __ovld __cnfn convert_double4_rte(int4); +double4 __ovld __cnfn convert_double4_rte(long4); +double4 __ovld __cnfn convert_double4_rte(short4); +double4 __ovld __cnfn convert_double4_rte(uchar4); +double4 __ovld __cnfn convert_double4_rte(uint4); +double4 __ovld __cnfn convert_double4_rte(ulong4); +double4 __ovld __cnfn convert_double4_rte(ushort4); +double4 __ovld __cnfn convert_double4_rtn(char4); +double4 __ovld __cnfn convert_double4_rtn(double4); +double4 __ovld __cnfn convert_double4_rtn(float4); +double4 __ovld __cnfn convert_double4_rtn(int4); +double4 __ovld __cnfn convert_double4_rtn(long4); +double4 __ovld __cnfn convert_double4_rtn(short4); +double4 __ovld __cnfn convert_double4_rtn(uchar4); +double4 __ovld __cnfn convert_double4_rtn(uint4); +double4 __ovld __cnfn convert_double4_rtn(ulong4); +double4 __ovld __cnfn convert_double4_rtn(ushort4); +double4 __ovld __cnfn convert_double4_rtp(char4); +double4 __ovld __cnfn convert_double4_rtp(double4); +double4 __ovld __cnfn convert_double4_rtp(float4); +double4 __ovld __cnfn convert_double4_rtp(int4); +double4 __ovld __cnfn convert_double4_rtp(long4); +double4 __ovld __cnfn convert_double4_rtp(short4); +double4 __ovld __cnfn convert_double4_rtp(uchar4); +double4 __ovld __cnfn convert_double4_rtp(uint4); +double4 __ovld __cnfn convert_double4_rtp(ulong4); +double4 __ovld __cnfn convert_double4_rtp(ushort4); +double4 __ovld __cnfn convert_double4_rtz(char4); +double4 __ovld __cnfn convert_double4_rtz(double4); +double4 __ovld __cnfn convert_double4_rtz(float4); +double4 __ovld __cnfn convert_double4_rtz(int4); +double4 __ovld __cnfn convert_double4_rtz(long4); +double4 __ovld __cnfn convert_double4_rtz(short4); +double4 __ovld __cnfn convert_double4_rtz(uchar4); +double4 __ovld __cnfn convert_double4_rtz(uint4); +double4 __ovld __cnfn convert_double4_rtz(ulong4); +double4 __ovld __cnfn convert_double4_rtz(ushort4); +double8 __ovld __cnfn convert_double8(char8); +double8 __ovld __cnfn convert_double8(double8); +double8 __ovld __cnfn convert_double8(float8); +double8 __ovld __cnfn convert_double8(int8); +double8 __ovld __cnfn convert_double8(long8); +double8 __ovld __cnfn convert_double8(short8); +double8 __ovld __cnfn convert_double8(uchar8); +double8 __ovld __cnfn convert_double8(uint8); +double8 __ovld __cnfn convert_double8(ulong8); +double8 __ovld __cnfn convert_double8(ushort8); +double8 __ovld __cnfn convert_double8_rte(char8); +double8 __ovld __cnfn convert_double8_rte(double8); +double8 __ovld __cnfn convert_double8_rte(float8); +double8 __ovld __cnfn convert_double8_rte(int8); +double8 __ovld __cnfn convert_double8_rte(long8); +double8 __ovld __cnfn convert_double8_rte(short8); +double8 __ovld __cnfn convert_double8_rte(uchar8); +double8 __ovld __cnfn convert_double8_rte(uint8); +double8 __ovld __cnfn convert_double8_rte(ulong8); +double8 __ovld __cnfn convert_double8_rte(ushort8); +double8 __ovld __cnfn convert_double8_rtn(char8); +double8 __ovld __cnfn convert_double8_rtn(double8); +double8 __ovld __cnfn convert_double8_rtn(float8); +double8 __ovld __cnfn convert_double8_rtn(int8); +double8 __ovld __cnfn convert_double8_rtn(long8); +double8 __ovld __cnfn convert_double8_rtn(short8); +double8 __ovld __cnfn convert_double8_rtn(uchar8); +double8 __ovld __cnfn convert_double8_rtn(uint8); +double8 __ovld __cnfn convert_double8_rtn(ulong8); +double8 __ovld __cnfn convert_double8_rtn(ushort8); +double8 __ovld __cnfn convert_double8_rtp(char8); +double8 __ovld __cnfn convert_double8_rtp(double8); +double8 __ovld __cnfn convert_double8_rtp(float8); +double8 __ovld __cnfn convert_double8_rtp(int8); +double8 __ovld __cnfn convert_double8_rtp(long8); +double8 __ovld __cnfn convert_double8_rtp(short8); +double8 __ovld __cnfn convert_double8_rtp(uchar8); +double8 __ovld __cnfn convert_double8_rtp(uint8); +double8 __ovld __cnfn convert_double8_rtp(ulong8); +double8 __ovld __cnfn convert_double8_rtp(ushort8); +double8 __ovld __cnfn convert_double8_rtz(char8); +double8 __ovld __cnfn convert_double8_rtz(double8); +double8 __ovld __cnfn convert_double8_rtz(float8); +double8 __ovld __cnfn convert_double8_rtz(int8); +double8 __ovld __cnfn convert_double8_rtz(long8); +double8 __ovld __cnfn convert_double8_rtz(short8); +double8 __ovld __cnfn convert_double8_rtz(uchar8); +double8 __ovld __cnfn convert_double8_rtz(uint8); +double8 __ovld __cnfn convert_double8_rtz(ulong8); +double8 __ovld __cnfn convert_double8_rtz(ushort8); +double16 __ovld __cnfn convert_double16(char16); +double16 __ovld __cnfn convert_double16(double16); +double16 __ovld __cnfn convert_double16(float16); +double16 __ovld __cnfn convert_double16(int16); +double16 __ovld __cnfn convert_double16(long16); +double16 __ovld __cnfn convert_double16(short16); +double16 __ovld __cnfn convert_double16(uchar16); +double16 __ovld __cnfn convert_double16(uint16); +double16 __ovld __cnfn convert_double16(ulong16); +double16 __ovld __cnfn convert_double16(ushort16); +double16 __ovld __cnfn convert_double16_rte(char16); +double16 __ovld __cnfn convert_double16_rte(double16); +double16 __ovld __cnfn convert_double16_rte(float16); +double16 __ovld __cnfn convert_double16_rte(int16); +double16 __ovld __cnfn convert_double16_rte(long16); +double16 __ovld __cnfn convert_double16_rte(short16); +double16 __ovld __cnfn convert_double16_rte(uchar16); +double16 __ovld __cnfn convert_double16_rte(uint16); +double16 __ovld __cnfn convert_double16_rte(ulong16); +double16 __ovld __cnfn convert_double16_rte(ushort16); +double16 __ovld __cnfn convert_double16_rtn(char16); +double16 __ovld __cnfn convert_double16_rtn(double16); +double16 __ovld __cnfn convert_double16_rtn(float16); +double16 __ovld __cnfn convert_double16_rtn(int16); +double16 __ovld __cnfn convert_double16_rtn(long16); +double16 __ovld __cnfn convert_double16_rtn(short16); +double16 __ovld __cnfn convert_double16_rtn(uchar16); +double16 __ovld __cnfn convert_double16_rtn(uint16); +double16 __ovld __cnfn convert_double16_rtn(ulong16); +double16 __ovld __cnfn convert_double16_rtn(ushort16); +double16 __ovld __cnfn convert_double16_rtp(char16); +double16 __ovld __cnfn convert_double16_rtp(double16); +double16 __ovld __cnfn convert_double16_rtp(float16); +double16 __ovld __cnfn convert_double16_rtp(int16); +double16 __ovld __cnfn convert_double16_rtp(long16); +double16 __ovld __cnfn convert_double16_rtp(short16); +double16 __ovld __cnfn convert_double16_rtp(uchar16); +double16 __ovld __cnfn convert_double16_rtp(uint16); +double16 __ovld __cnfn convert_double16_rtp(ulong16); +double16 __ovld __cnfn convert_double16_rtp(ushort16); +double16 __ovld __cnfn convert_double16_rtz(char16); +double16 __ovld __cnfn convert_double16_rtz(double16); +double16 __ovld __cnfn convert_double16_rtz(float16); +double16 __ovld __cnfn convert_double16_rtz(int16); +double16 __ovld __cnfn convert_double16_rtz(long16); +double16 __ovld __cnfn convert_double16_rtz(short16); +double16 __ovld __cnfn convert_double16_rtz(uchar16); +double16 __ovld __cnfn convert_double16_rtz(uint16); +double16 __ovld __cnfn convert_double16_rtz(ulong16); +double16 __ovld __cnfn convert_double16_rtz(ushort16); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +// Convert half types to non-double types. +uchar __ovld __cnfn convert_uchar(half); +uchar __ovld __cnfn convert_uchar_rte(half); +uchar __ovld __cnfn convert_uchar_rtp(half); +uchar __ovld __cnfn convert_uchar_rtn(half); +uchar __ovld __cnfn convert_uchar_rtz(half); +uchar __ovld __cnfn convert_uchar_sat(half); +uchar __ovld __cnfn convert_uchar_sat_rte(half); +uchar __ovld __cnfn convert_uchar_sat_rtp(half); +uchar __ovld __cnfn convert_uchar_sat_rtn(half); +uchar __ovld __cnfn convert_uchar_sat_rtz(half); +uchar2 __ovld __cnfn convert_uchar2(half2); +uchar2 __ovld __cnfn convert_uchar2_rte(half2); +uchar2 __ovld __cnfn convert_uchar2_rtp(half2); +uchar2 __ovld __cnfn convert_uchar2_rtn(half2); +uchar2 __ovld __cnfn convert_uchar2_rtz(half2); +uchar2 __ovld __cnfn convert_uchar2_sat(half2); +uchar2 __ovld __cnfn convert_uchar2_sat_rte(half2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtp(half2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtn(half2); +uchar2 __ovld __cnfn convert_uchar2_sat_rtz(half2); +uchar3 __ovld __cnfn convert_uchar3(half3); +uchar3 __ovld __cnfn convert_uchar3_rte(half3); +uchar3 __ovld __cnfn convert_uchar3_rtp(half3); +uchar3 __ovld __cnfn convert_uchar3_rtn(half3); +uchar3 __ovld __cnfn convert_uchar3_rtz(half3); +uchar3 __ovld __cnfn convert_uchar3_sat(half3); +uchar3 __ovld __cnfn convert_uchar3_sat_rte(half3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtp(half3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtn(half3); +uchar3 __ovld __cnfn convert_uchar3_sat_rtz(half3); +uchar4 __ovld __cnfn convert_uchar4(half4); +uchar4 __ovld __cnfn convert_uchar4_rte(half4); +uchar4 __ovld __cnfn convert_uchar4_rtp(half4); +uchar4 __ovld __cnfn convert_uchar4_rtn(half4); +uchar4 __ovld __cnfn convert_uchar4_rtz(half4); +uchar4 __ovld __cnfn convert_uchar4_sat(half4); +uchar4 __ovld __cnfn convert_uchar4_sat_rte(half4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtp(half4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtn(half4); +uchar4 __ovld __cnfn convert_uchar4_sat_rtz(half4); +uchar8 __ovld __cnfn convert_uchar8(half8); +uchar8 __ovld __cnfn convert_uchar8_rte(half8); +uchar8 __ovld __cnfn convert_uchar8_rtp(half8); +uchar8 __ovld __cnfn convert_uchar8_rtn(half8); +uchar8 __ovld __cnfn convert_uchar8_rtz(half8); +uchar8 __ovld __cnfn convert_uchar8_sat(half8); +uchar8 __ovld __cnfn convert_uchar8_sat_rte(half8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtp(half8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtn(half8); +uchar8 __ovld __cnfn convert_uchar8_sat_rtz(half8); +uchar16 __ovld __cnfn convert_uchar16(half16); +uchar16 __ovld __cnfn convert_uchar16_rte(half16); +uchar16 __ovld __cnfn convert_uchar16_rtp(half16); +uchar16 __ovld __cnfn convert_uchar16_rtn(half16); +uchar16 __ovld __cnfn convert_uchar16_rtz(half16); +uchar16 __ovld __cnfn convert_uchar16_sat(half16); +uchar16 __ovld __cnfn convert_uchar16_sat_rte(half16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtp(half16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtn(half16); +uchar16 __ovld __cnfn convert_uchar16_sat_rtz(half16); +ushort __ovld __cnfn convert_ushort(half); +ushort __ovld __cnfn convert_ushort_rte(half); +ushort __ovld __cnfn convert_ushort_rtp(half); +ushort __ovld __cnfn convert_ushort_rtn(half); +ushort __ovld __cnfn convert_ushort_rtz(half); +ushort __ovld __cnfn convert_ushort_sat(half); +ushort __ovld __cnfn convert_ushort_sat_rte(half); +ushort __ovld __cnfn convert_ushort_sat_rtp(half); +ushort __ovld __cnfn convert_ushort_sat_rtn(half); +ushort __ovld __cnfn convert_ushort_sat_rtz(half); +ushort2 __ovld __cnfn convert_ushort2(half2); +ushort2 __ovld __cnfn convert_ushort2_rte(half2); +ushort2 __ovld __cnfn convert_ushort2_rtp(half2); +ushort2 __ovld __cnfn convert_ushort2_rtn(half2); +ushort2 __ovld __cnfn convert_ushort2_rtz(half2); +ushort2 __ovld __cnfn convert_ushort2_sat(half2); +ushort2 __ovld __cnfn convert_ushort2_sat_rte(half2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtp(half2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtn(half2); +ushort2 __ovld __cnfn convert_ushort2_sat_rtz(half2); +ushort3 __ovld __cnfn convert_ushort3(half3); +ushort3 __ovld __cnfn convert_ushort3_rte(half3); +ushort3 __ovld __cnfn convert_ushort3_rtp(half3); +ushort3 __ovld __cnfn convert_ushort3_rtn(half3); +ushort3 __ovld __cnfn convert_ushort3_rtz(half3); +ushort3 __ovld __cnfn convert_ushort3_sat(half3); +ushort3 __ovld __cnfn convert_ushort3_sat_rte(half3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtp(half3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtn(half3); +ushort3 __ovld __cnfn convert_ushort3_sat_rtz(half3); +ushort4 __ovld __cnfn convert_ushort4(half4); +ushort4 __ovld __cnfn convert_ushort4_rte(half4); +ushort4 __ovld __cnfn convert_ushort4_rtp(half4); +ushort4 __ovld __cnfn convert_ushort4_rtn(half4); +ushort4 __ovld __cnfn convert_ushort4_rtz(half4); +ushort4 __ovld __cnfn convert_ushort4_sat(half4); +ushort4 __ovld __cnfn convert_ushort4_sat_rte(half4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtp(half4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtn(half4); +ushort4 __ovld __cnfn convert_ushort4_sat_rtz(half4); +ushort8 __ovld __cnfn convert_ushort8(half8); +ushort8 __ovld __cnfn convert_ushort8_rte(half8); +ushort8 __ovld __cnfn convert_ushort8_rtp(half8); +ushort8 __ovld __cnfn convert_ushort8_rtn(half8); +ushort8 __ovld __cnfn convert_ushort8_rtz(half8); +ushort8 __ovld __cnfn convert_ushort8_sat(half8); +ushort8 __ovld __cnfn convert_ushort8_sat_rte(half8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtp(half8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtn(half8); +ushort8 __ovld __cnfn convert_ushort8_sat_rtz(half8); +ushort16 __ovld __cnfn convert_ushort16(half16); +ushort16 __ovld __cnfn convert_ushort16_rte(half16); +ushort16 __ovld __cnfn convert_ushort16_rtp(half16); +ushort16 __ovld __cnfn convert_ushort16_rtn(half16); +ushort16 __ovld __cnfn convert_ushort16_rtz(half16); +ushort16 __ovld __cnfn convert_ushort16_sat(half16); +ushort16 __ovld __cnfn convert_ushort16_sat_rte(half16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtp(half16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtn(half16); +ushort16 __ovld __cnfn convert_ushort16_sat_rtz(half16); +uint __ovld __cnfn convert_uint(half); +uint __ovld __cnfn convert_uint_rte(half); +uint __ovld __cnfn convert_uint_rtp(half); +uint __ovld __cnfn convert_uint_rtn(half); +uint __ovld __cnfn convert_uint_rtz(half); +uint __ovld __cnfn convert_uint_sat(half); +uint __ovld __cnfn convert_uint_sat_rte(half); +uint __ovld __cnfn convert_uint_sat_rtp(half); +uint __ovld __cnfn convert_uint_sat_rtn(half); +uint __ovld __cnfn convert_uint_sat_rtz(half); +uint2 __ovld __cnfn convert_uint2(half2); +uint2 __ovld __cnfn convert_uint2_rte(half2); +uint2 __ovld __cnfn convert_uint2_rtp(half2); +uint2 __ovld __cnfn convert_uint2_rtn(half2); +uint2 __ovld __cnfn convert_uint2_rtz(half2); +uint2 __ovld __cnfn convert_uint2_sat(half2); +uint2 __ovld __cnfn convert_uint2_sat_rte(half2); +uint2 __ovld __cnfn convert_uint2_sat_rtp(half2); +uint2 __ovld __cnfn convert_uint2_sat_rtn(half2); +uint2 __ovld __cnfn convert_uint2_sat_rtz(half2); +uint3 __ovld __cnfn convert_uint3(half3); +uint3 __ovld __cnfn convert_uint3_rte(half3); +uint3 __ovld __cnfn convert_uint3_rtp(half3); +uint3 __ovld __cnfn convert_uint3_rtn(half3); +uint3 __ovld __cnfn convert_uint3_rtz(half3); +uint3 __ovld __cnfn convert_uint3_sat(half3); +uint3 __ovld __cnfn convert_uint3_sat_rte(half3); +uint3 __ovld __cnfn convert_uint3_sat_rtp(half3); +uint3 __ovld __cnfn convert_uint3_sat_rtn(half3); +uint3 __ovld __cnfn convert_uint3_sat_rtz(half3); +uint4 __ovld __cnfn convert_uint4(half4); +uint4 __ovld __cnfn convert_uint4_rte(half4); +uint4 __ovld __cnfn convert_uint4_rtp(half4); +uint4 __ovld __cnfn convert_uint4_rtn(half4); +uint4 __ovld __cnfn convert_uint4_rtz(half4); +uint4 __ovld __cnfn convert_uint4_sat(half4); +uint4 __ovld __cnfn convert_uint4_sat_rte(half4); +uint4 __ovld __cnfn convert_uint4_sat_rtp(half4); +uint4 __ovld __cnfn convert_uint4_sat_rtn(half4); +uint4 __ovld __cnfn convert_uint4_sat_rtz(half4); +uint8 __ovld __cnfn convert_uint8(half8); +uint8 __ovld __cnfn convert_uint8_rte(half8); +uint8 __ovld __cnfn convert_uint8_rtp(half8); +uint8 __ovld __cnfn convert_uint8_rtn(half8); +uint8 __ovld __cnfn convert_uint8_rtz(half8); +uint8 __ovld __cnfn convert_uint8_sat(half8); +uint8 __ovld __cnfn convert_uint8_sat_rte(half8); +uint8 __ovld __cnfn convert_uint8_sat_rtp(half8); +uint8 __ovld __cnfn convert_uint8_sat_rtn(half8); +uint8 __ovld __cnfn convert_uint8_sat_rtz(half8); +uint16 __ovld __cnfn convert_uint16(half16); +uint16 __ovld __cnfn convert_uint16_rte(half16); +uint16 __ovld __cnfn convert_uint16_rtp(half16); +uint16 __ovld __cnfn convert_uint16_rtn(half16); +uint16 __ovld __cnfn convert_uint16_rtz(half16); +uint16 __ovld __cnfn convert_uint16_sat(half16); +uint16 __ovld __cnfn convert_uint16_sat_rte(half16); +uint16 __ovld __cnfn convert_uint16_sat_rtp(half16); +uint16 __ovld __cnfn convert_uint16_sat_rtn(half16); +uint16 __ovld __cnfn convert_uint16_sat_rtz(half16); +ulong __ovld __cnfn convert_ulong(half); +ulong __ovld __cnfn convert_ulong_rte(half); +ulong __ovld __cnfn convert_ulong_rtp(half); +ulong __ovld __cnfn convert_ulong_rtn(half); +ulong __ovld __cnfn convert_ulong_rtz(half); +ulong __ovld __cnfn convert_ulong_sat(half); +ulong __ovld __cnfn convert_ulong_sat_rte(half); +ulong __ovld __cnfn convert_ulong_sat_rtp(half); +ulong __ovld __cnfn convert_ulong_sat_rtn(half); +ulong __ovld __cnfn convert_ulong_sat_rtz(half); +ulong2 __ovld __cnfn convert_ulong2(half2); +ulong2 __ovld __cnfn convert_ulong2_rte(half2); +ulong2 __ovld __cnfn convert_ulong2_rtp(half2); +ulong2 __ovld __cnfn convert_ulong2_rtn(half2); +ulong2 __ovld __cnfn convert_ulong2_rtz(half2); +ulong2 __ovld __cnfn convert_ulong2_sat(half2); +ulong2 __ovld __cnfn convert_ulong2_sat_rte(half2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtp(half2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtn(half2); +ulong2 __ovld __cnfn convert_ulong2_sat_rtz(half2); +ulong3 __ovld __cnfn convert_ulong3(half3); +ulong3 __ovld __cnfn convert_ulong3_rte(half3); +ulong3 __ovld __cnfn convert_ulong3_rtp(half3); +ulong3 __ovld __cnfn convert_ulong3_rtn(half3); +ulong3 __ovld __cnfn convert_ulong3_rtz(half3); +ulong3 __ovld __cnfn convert_ulong3_sat(half3); +ulong3 __ovld __cnfn convert_ulong3_sat_rte(half3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtp(half3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtn(half3); +ulong3 __ovld __cnfn convert_ulong3_sat_rtz(half3); +ulong4 __ovld __cnfn convert_ulong4(half4); +ulong4 __ovld __cnfn convert_ulong4_rte(half4); +ulong4 __ovld __cnfn convert_ulong4_rtp(half4); +ulong4 __ovld __cnfn convert_ulong4_rtn(half4); +ulong4 __ovld __cnfn convert_ulong4_rtz(half4); +ulong4 __ovld __cnfn convert_ulong4_sat(half4); +ulong4 __ovld __cnfn convert_ulong4_sat_rte(half4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtp(half4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtn(half4); +ulong4 __ovld __cnfn convert_ulong4_sat_rtz(half4); +ulong8 __ovld __cnfn convert_ulong8(half8); +ulong8 __ovld __cnfn convert_ulong8_rte(half8); +ulong8 __ovld __cnfn convert_ulong8_rtp(half8); +ulong8 __ovld __cnfn convert_ulong8_rtn(half8); +ulong8 __ovld __cnfn convert_ulong8_rtz(half8); +ulong8 __ovld __cnfn convert_ulong8_sat(half8); +ulong8 __ovld __cnfn convert_ulong8_sat_rte(half8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtp(half8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtn(half8); +ulong8 __ovld __cnfn convert_ulong8_sat_rtz(half8); +ulong16 __ovld __cnfn convert_ulong16(half16); +ulong16 __ovld __cnfn convert_ulong16_rte(half16); +ulong16 __ovld __cnfn convert_ulong16_rtp(half16); +ulong16 __ovld __cnfn convert_ulong16_rtn(half16); +ulong16 __ovld __cnfn convert_ulong16_rtz(half16); +ulong16 __ovld __cnfn convert_ulong16_sat(half16); +ulong16 __ovld __cnfn convert_ulong16_sat_rte(half16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtp(half16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtn(half16); +ulong16 __ovld __cnfn convert_ulong16_sat_rtz(half16); +char __ovld __cnfn convert_char(half); +char __ovld __cnfn convert_char_rte(half); +char __ovld __cnfn convert_char_rtp(half); +char __ovld __cnfn convert_char_rtn(half); +char __ovld __cnfn convert_char_rtz(half); +char __ovld __cnfn convert_char_sat(half); +char __ovld __cnfn convert_char_sat_rte(half); +char __ovld __cnfn convert_char_sat_rtp(half); +char __ovld __cnfn convert_char_sat_rtn(half); +char __ovld __cnfn convert_char_sat_rtz(half); +char2 __ovld __cnfn convert_char2(half2); +char2 __ovld __cnfn convert_char2_rte(half2); +char2 __ovld __cnfn convert_char2_rtp(half2); +char2 __ovld __cnfn convert_char2_rtn(half2); +char2 __ovld __cnfn convert_char2_rtz(half2); +char2 __ovld __cnfn convert_char2_sat(half2); +char2 __ovld __cnfn convert_char2_sat_rte(half2); +char2 __ovld __cnfn convert_char2_sat_rtp(half2); +char2 __ovld __cnfn convert_char2_sat_rtn(half2); +char2 __ovld __cnfn convert_char2_sat_rtz(half2); +char3 __ovld __cnfn convert_char3(half3); +char3 __ovld __cnfn convert_char3_rte(half3); +char3 __ovld __cnfn convert_char3_rtp(half3); +char3 __ovld __cnfn convert_char3_rtn(half3); +char3 __ovld __cnfn convert_char3_rtz(half3); +char3 __ovld __cnfn convert_char3_sat(half3); +char3 __ovld __cnfn convert_char3_sat_rte(half3); +char3 __ovld __cnfn convert_char3_sat_rtp(half3); +char3 __ovld __cnfn convert_char3_sat_rtn(half3); +char3 __ovld __cnfn convert_char3_sat_rtz(half3); +char4 __ovld __cnfn convert_char4(half4); +char4 __ovld __cnfn convert_char4_rte(half4); +char4 __ovld __cnfn convert_char4_rtp(half4); +char4 __ovld __cnfn convert_char4_rtn(half4); +char4 __ovld __cnfn convert_char4_rtz(half4); +char4 __ovld __cnfn convert_char4_sat(half4); +char4 __ovld __cnfn convert_char4_sat_rte(half4); +char4 __ovld __cnfn convert_char4_sat_rtp(half4); +char4 __ovld __cnfn convert_char4_sat_rtn(half4); +char4 __ovld __cnfn convert_char4_sat_rtz(half4); +char8 __ovld __cnfn convert_char8(half8); +char8 __ovld __cnfn convert_char8_rte(half8); +char8 __ovld __cnfn convert_char8_rtp(half8); +char8 __ovld __cnfn convert_char8_rtn(half8); +char8 __ovld __cnfn convert_char8_rtz(half8); +char8 __ovld __cnfn convert_char8_sat(half8); +char8 __ovld __cnfn convert_char8_sat_rte(half8); +char8 __ovld __cnfn convert_char8_sat_rtp(half8); +char8 __ovld __cnfn convert_char8_sat_rtn(half8); +char8 __ovld __cnfn convert_char8_sat_rtz(half8); +char16 __ovld __cnfn convert_char16(half16); +char16 __ovld __cnfn convert_char16_rte(half16); +char16 __ovld __cnfn convert_char16_rtp(half16); +char16 __ovld __cnfn convert_char16_rtn(half16); +char16 __ovld __cnfn convert_char16_rtz(half16); +char16 __ovld __cnfn convert_char16_sat(half16); +char16 __ovld __cnfn convert_char16_sat_rte(half16); +char16 __ovld __cnfn convert_char16_sat_rtp(half16); +char16 __ovld __cnfn convert_char16_sat_rtn(half16); +char16 __ovld __cnfn convert_char16_sat_rtz(half16); +short __ovld __cnfn convert_short(half); +short __ovld __cnfn convert_short_rte(half); +short __ovld __cnfn convert_short_rtp(half); +short __ovld __cnfn convert_short_rtn(half); +short __ovld __cnfn convert_short_rtz(half); +short __ovld __cnfn convert_short_sat(half); +short __ovld __cnfn convert_short_sat_rte(half); +short __ovld __cnfn convert_short_sat_rtp(half); +short __ovld __cnfn convert_short_sat_rtn(half); +short __ovld __cnfn convert_short_sat_rtz(half); +short2 __ovld __cnfn convert_short2(half2); +short2 __ovld __cnfn convert_short2_rte(half2); +short2 __ovld __cnfn convert_short2_rtp(half2); +short2 __ovld __cnfn convert_short2_rtn(half2); +short2 __ovld __cnfn convert_short2_rtz(half2); +short2 __ovld __cnfn convert_short2_sat(half2); +short2 __ovld __cnfn convert_short2_sat_rte(half2); +short2 __ovld __cnfn convert_short2_sat_rtp(half2); +short2 __ovld __cnfn convert_short2_sat_rtn(half2); +short2 __ovld __cnfn convert_short2_sat_rtz(half2); +short3 __ovld __cnfn convert_short3(half3); +short3 __ovld __cnfn convert_short3_rte(half3); +short3 __ovld __cnfn convert_short3_rtp(half3); +short3 __ovld __cnfn convert_short3_rtn(half3); +short3 __ovld __cnfn convert_short3_rtz(half3); +short3 __ovld __cnfn convert_short3_sat(half3); +short3 __ovld __cnfn convert_short3_sat_rte(half3); +short3 __ovld __cnfn convert_short3_sat_rtp(half3); +short3 __ovld __cnfn convert_short3_sat_rtn(half3); +short3 __ovld __cnfn convert_short3_sat_rtz(half3); +short4 __ovld __cnfn convert_short4(half4); +short4 __ovld __cnfn convert_short4_rte(half4); +short4 __ovld __cnfn convert_short4_rtp(half4); +short4 __ovld __cnfn convert_short4_rtn(half4); +short4 __ovld __cnfn convert_short4_rtz(half4); +short4 __ovld __cnfn convert_short4_sat(half4); +short4 __ovld __cnfn convert_short4_sat_rte(half4); +short4 __ovld __cnfn convert_short4_sat_rtp(half4); +short4 __ovld __cnfn convert_short4_sat_rtn(half4); +short4 __ovld __cnfn convert_short4_sat_rtz(half4); +short8 __ovld __cnfn convert_short8(half8); +short8 __ovld __cnfn convert_short8_rte(half8); +short8 __ovld __cnfn convert_short8_rtp(half8); +short8 __ovld __cnfn convert_short8_rtn(half8); +short8 __ovld __cnfn convert_short8_rtz(half8); +short8 __ovld __cnfn convert_short8_sat(half8); +short8 __ovld __cnfn convert_short8_sat_rte(half8); +short8 __ovld __cnfn convert_short8_sat_rtp(half8); +short8 __ovld __cnfn convert_short8_sat_rtn(half8); +short8 __ovld __cnfn convert_short8_sat_rtz(half8); +short16 __ovld __cnfn convert_short16(half16); +short16 __ovld __cnfn convert_short16_rte(half16); +short16 __ovld __cnfn convert_short16_rtp(half16); +short16 __ovld __cnfn convert_short16_rtn(half16); +short16 __ovld __cnfn convert_short16_rtz(half16); +short16 __ovld __cnfn convert_short16_sat(half16); +short16 __ovld __cnfn convert_short16_sat_rte(half16); +short16 __ovld __cnfn convert_short16_sat_rtp(half16); +short16 __ovld __cnfn convert_short16_sat_rtn(half16); +short16 __ovld __cnfn convert_short16_sat_rtz(half16); +int __ovld __cnfn convert_int(half); +int __ovld __cnfn convert_int_rte(half); +int __ovld __cnfn convert_int_rtp(half); +int __ovld __cnfn convert_int_rtn(half); +int __ovld __cnfn convert_int_rtz(half); +int __ovld __cnfn convert_int_sat(half); +int __ovld __cnfn convert_int_sat_rte(half); +int __ovld __cnfn convert_int_sat_rtp(half); +int __ovld __cnfn convert_int_sat_rtn(half); +int __ovld __cnfn convert_int_sat_rtz(half); +int2 __ovld __cnfn convert_int2(half2); +int2 __ovld __cnfn convert_int2_rte(half2); +int2 __ovld __cnfn convert_int2_rtp(half2); +int2 __ovld __cnfn convert_int2_rtn(half2); +int2 __ovld __cnfn convert_int2_rtz(half2); +int2 __ovld __cnfn convert_int2_sat(half2); +int2 __ovld __cnfn convert_int2_sat_rte(half2); +int2 __ovld __cnfn convert_int2_sat_rtp(half2); +int2 __ovld __cnfn convert_int2_sat_rtn(half2); +int2 __ovld __cnfn convert_int2_sat_rtz(half2); +int3 __ovld __cnfn convert_int3(half3); +int3 __ovld __cnfn convert_int3_rte(half3); +int3 __ovld __cnfn convert_int3_rtp(half3); +int3 __ovld __cnfn convert_int3_rtn(half3); +int3 __ovld __cnfn convert_int3_rtz(half3); +int3 __ovld __cnfn convert_int3_sat(half3); +int3 __ovld __cnfn convert_int3_sat_rte(half3); +int3 __ovld __cnfn convert_int3_sat_rtp(half3); +int3 __ovld __cnfn convert_int3_sat_rtn(half3); +int3 __ovld __cnfn convert_int3_sat_rtz(half3); +int4 __ovld __cnfn convert_int4(half4); +int4 __ovld __cnfn convert_int4_rte(half4); +int4 __ovld __cnfn convert_int4_rtp(half4); +int4 __ovld __cnfn convert_int4_rtn(half4); +int4 __ovld __cnfn convert_int4_rtz(half4); +int4 __ovld __cnfn convert_int4_sat(half4); +int4 __ovld __cnfn convert_int4_sat_rte(half4); +int4 __ovld __cnfn convert_int4_sat_rtp(half4); +int4 __ovld __cnfn convert_int4_sat_rtn(half4); +int4 __ovld __cnfn convert_int4_sat_rtz(half4); +int8 __ovld __cnfn convert_int8(half8); +int8 __ovld __cnfn convert_int8_rte(half8); +int8 __ovld __cnfn convert_int8_rtp(half8); +int8 __ovld __cnfn convert_int8_rtn(half8); +int8 __ovld __cnfn convert_int8_rtz(half8); +int8 __ovld __cnfn convert_int8_sat(half8); +int8 __ovld __cnfn convert_int8_sat_rte(half8); +int8 __ovld __cnfn convert_int8_sat_rtp(half8); +int8 __ovld __cnfn convert_int8_sat_rtn(half8); +int8 __ovld __cnfn convert_int8_sat_rtz(half8); +int16 __ovld __cnfn convert_int16(half16); +int16 __ovld __cnfn convert_int16_rte(half16); +int16 __ovld __cnfn convert_int16_rtp(half16); +int16 __ovld __cnfn convert_int16_rtn(half16); +int16 __ovld __cnfn convert_int16_rtz(half16); +int16 __ovld __cnfn convert_int16_sat(half16); +int16 __ovld __cnfn convert_int16_sat_rte(half16); +int16 __ovld __cnfn convert_int16_sat_rtp(half16); +int16 __ovld __cnfn convert_int16_sat_rtn(half16); +int16 __ovld __cnfn convert_int16_sat_rtz(half16); +long __ovld __cnfn convert_long(half); +long __ovld __cnfn convert_long_rte(half); +long __ovld __cnfn convert_long_rtp(half); +long __ovld __cnfn convert_long_rtn(half); +long __ovld __cnfn convert_long_rtz(half); +long __ovld __cnfn convert_long_sat(half); +long __ovld __cnfn convert_long_sat_rte(half); +long __ovld __cnfn convert_long_sat_rtp(half); +long __ovld __cnfn convert_long_sat_rtn(half); +long __ovld __cnfn convert_long_sat_rtz(half); +long2 __ovld __cnfn convert_long2(half2); +long2 __ovld __cnfn convert_long2_rte(half2); +long2 __ovld __cnfn convert_long2_rtp(half2); +long2 __ovld __cnfn convert_long2_rtn(half2); +long2 __ovld __cnfn convert_long2_rtz(half2); +long2 __ovld __cnfn convert_long2_sat(half2); +long2 __ovld __cnfn convert_long2_sat_rte(half2); +long2 __ovld __cnfn convert_long2_sat_rtp(half2); +long2 __ovld __cnfn convert_long2_sat_rtn(half2); +long2 __ovld __cnfn convert_long2_sat_rtz(half2); +long3 __ovld __cnfn convert_long3(half3); +long3 __ovld __cnfn convert_long3_rte(half3); +long3 __ovld __cnfn convert_long3_rtp(half3); +long3 __ovld __cnfn convert_long3_rtn(half3); +long3 __ovld __cnfn convert_long3_rtz(half3); +long3 __ovld __cnfn convert_long3_sat(half3); +long3 __ovld __cnfn convert_long3_sat_rte(half3); +long3 __ovld __cnfn convert_long3_sat_rtp(half3); +long3 __ovld __cnfn convert_long3_sat_rtn(half3); +long3 __ovld __cnfn convert_long3_sat_rtz(half3); +long4 __ovld __cnfn convert_long4(half4); +long4 __ovld __cnfn convert_long4_rte(half4); +long4 __ovld __cnfn convert_long4_rtp(half4); +long4 __ovld __cnfn convert_long4_rtn(half4); +long4 __ovld __cnfn convert_long4_rtz(half4); +long4 __ovld __cnfn convert_long4_sat(half4); +long4 __ovld __cnfn convert_long4_sat_rte(half4); +long4 __ovld __cnfn convert_long4_sat_rtp(half4); +long4 __ovld __cnfn convert_long4_sat_rtn(half4); +long4 __ovld __cnfn convert_long4_sat_rtz(half4); +long8 __ovld __cnfn convert_long8(half8); +long8 __ovld __cnfn convert_long8_rte(half8); +long8 __ovld __cnfn convert_long8_rtp(half8); +long8 __ovld __cnfn convert_long8_rtn(half8); +long8 __ovld __cnfn convert_long8_rtz(half8); +long8 __ovld __cnfn convert_long8_sat(half8); +long8 __ovld __cnfn convert_long8_sat_rte(half8); +long8 __ovld __cnfn convert_long8_sat_rtp(half8); +long8 __ovld __cnfn convert_long8_sat_rtn(half8); +long8 __ovld __cnfn convert_long8_sat_rtz(half8); +long16 __ovld __cnfn convert_long16(half16); +long16 __ovld __cnfn convert_long16_rte(half16); +long16 __ovld __cnfn convert_long16_rtp(half16); +long16 __ovld __cnfn convert_long16_rtn(half16); +long16 __ovld __cnfn convert_long16_rtz(half16); +long16 __ovld __cnfn convert_long16_sat(half16); +long16 __ovld __cnfn convert_long16_sat_rte(half16); +long16 __ovld __cnfn convert_long16_sat_rtp(half16); +long16 __ovld __cnfn convert_long16_sat_rtn(half16); +long16 __ovld __cnfn convert_long16_sat_rtz(half16); +float __ovld __cnfn convert_float(half); +float __ovld __cnfn convert_float_rte(half); +float __ovld __cnfn convert_float_rtp(half); +float __ovld __cnfn convert_float_rtn(half); +float __ovld __cnfn convert_float_rtz(half); +float2 __ovld __cnfn convert_float2(half2); +float2 __ovld __cnfn convert_float2_rte(half2); +float2 __ovld __cnfn convert_float2_rtp(half2); +float2 __ovld __cnfn convert_float2_rtn(half2); +float2 __ovld __cnfn convert_float2_rtz(half2); +float3 __ovld __cnfn convert_float3(half3); +float3 __ovld __cnfn convert_float3_rte(half3); +float3 __ovld __cnfn convert_float3_rtp(half3); +float3 __ovld __cnfn convert_float3_rtn(half3); +float3 __ovld __cnfn convert_float3_rtz(half3); +float4 __ovld __cnfn convert_float4(half4); +float4 __ovld __cnfn convert_float4_rte(half4); +float4 __ovld __cnfn convert_float4_rtp(half4); +float4 __ovld __cnfn convert_float4_rtn(half4); +float4 __ovld __cnfn convert_float4_rtz(half4); +float8 __ovld __cnfn convert_float8(half8); +float8 __ovld __cnfn convert_float8_rte(half8); +float8 __ovld __cnfn convert_float8_rtp(half8); +float8 __ovld __cnfn convert_float8_rtn(half8); +float8 __ovld __cnfn convert_float8_rtz(half8); +float16 __ovld __cnfn convert_float16(half16); +float16 __ovld __cnfn convert_float16_rte(half16); +float16 __ovld __cnfn convert_float16_rtp(half16); +float16 __ovld __cnfn convert_float16_rtn(half16); +float16 __ovld __cnfn convert_float16_rtz(half16); + +// Convert non-double types to half types. +half __ovld __cnfn convert_half(uchar); +half __ovld __cnfn convert_half(ushort); +half __ovld __cnfn convert_half(uint); +half __ovld __cnfn convert_half(ulong); +half __ovld __cnfn convert_half(char); +half __ovld __cnfn convert_half(short); +half __ovld __cnfn convert_half(int); +half __ovld __cnfn convert_half(long); +half __ovld __cnfn convert_half(float); +half __ovld __cnfn convert_half(half); +half __ovld __cnfn convert_half_rte(uchar); +half __ovld __cnfn convert_half_rte(ushort); +half __ovld __cnfn convert_half_rte(uint); +half __ovld __cnfn convert_half_rte(ulong); +half __ovld __cnfn convert_half_rte(char); +half __ovld __cnfn convert_half_rte(short); +half __ovld __cnfn convert_half_rte(int); +half __ovld __cnfn convert_half_rte(long); +half __ovld __cnfn convert_half_rte(float); +half __ovld __cnfn convert_half_rte(half); +half __ovld __cnfn convert_half_rtp(uchar); +half __ovld __cnfn convert_half_rtp(ushort); +half __ovld __cnfn convert_half_rtp(uint); +half __ovld __cnfn convert_half_rtp(ulong); +half __ovld __cnfn convert_half_rtp(char); +half __ovld __cnfn convert_half_rtp(short); +half __ovld __cnfn convert_half_rtp(int); +half __ovld __cnfn convert_half_rtp(long); +half __ovld __cnfn convert_half_rtp(float); +half __ovld __cnfn convert_half_rtp(half); +half __ovld __cnfn convert_half_rtn(uchar); +half __ovld __cnfn convert_half_rtn(ushort); +half __ovld __cnfn convert_half_rtn(uint); +half __ovld __cnfn convert_half_rtn(ulong); +half __ovld __cnfn convert_half_rtn(char); +half __ovld __cnfn convert_half_rtn(short); +half __ovld __cnfn convert_half_rtn(int); +half __ovld __cnfn convert_half_rtn(long); +half __ovld __cnfn convert_half_rtn(float); +half __ovld __cnfn convert_half_rtn(half); +half __ovld __cnfn convert_half_rtz(uchar); +half __ovld __cnfn convert_half_rtz(ushort); +half __ovld __cnfn convert_half_rtz(uint); +half __ovld __cnfn convert_half_rtz(ulong); +half __ovld __cnfn convert_half_rtz(char); +half __ovld __cnfn convert_half_rtz(short); +half __ovld __cnfn convert_half_rtz(int); +half __ovld __cnfn convert_half_rtz(long); +half __ovld __cnfn convert_half_rtz(float); +half __ovld __cnfn convert_half_rtz(half); +half2 __ovld __cnfn convert_half2(char2); +half2 __ovld __cnfn convert_half2(uchar2); +half2 __ovld __cnfn convert_half2(short2); +half2 __ovld __cnfn convert_half2(ushort2); +half2 __ovld __cnfn convert_half2(int2); +half2 __ovld __cnfn convert_half2(uint2); +half2 __ovld __cnfn convert_half2(long2); +half2 __ovld __cnfn convert_half2(ulong2); +half2 __ovld __cnfn convert_half2(float2); +half2 __ovld __cnfn convert_half2(half2); +half2 __ovld __cnfn convert_half2_rte(char2); +half2 __ovld __cnfn convert_half2_rte(uchar2); +half2 __ovld __cnfn convert_half2_rte(short2); +half2 __ovld __cnfn convert_half2_rte(ushort2); +half2 __ovld __cnfn convert_half2_rte(int2); +half2 __ovld __cnfn convert_half2_rte(uint2); +half2 __ovld __cnfn convert_half2_rte(long2); +half2 __ovld __cnfn convert_half2_rte(ulong2); +half2 __ovld __cnfn convert_half2_rte(float2); +half2 __ovld __cnfn convert_half2_rte(half2); +half2 __ovld __cnfn convert_half2_rtp(char2); +half2 __ovld __cnfn convert_half2_rtp(uchar2); +half2 __ovld __cnfn convert_half2_rtp(short2); +half2 __ovld __cnfn convert_half2_rtp(ushort2); +half2 __ovld __cnfn convert_half2_rtp(int2); +half2 __ovld __cnfn convert_half2_rtp(uint2); +half2 __ovld __cnfn convert_half2_rtp(long2); +half2 __ovld __cnfn convert_half2_rtp(ulong2); +half2 __ovld __cnfn convert_half2_rtp(float2); +half2 __ovld __cnfn convert_half2_rtp(half2); +half2 __ovld __cnfn convert_half2_rtn(char2); +half2 __ovld __cnfn convert_half2_rtn(uchar2); +half2 __ovld __cnfn convert_half2_rtn(short2); +half2 __ovld __cnfn convert_half2_rtn(ushort2); +half2 __ovld __cnfn convert_half2_rtn(int2); +half2 __ovld __cnfn convert_half2_rtn(uint2); +half2 __ovld __cnfn convert_half2_rtn(long2); +half2 __ovld __cnfn convert_half2_rtn(ulong2); +half2 __ovld __cnfn convert_half2_rtn(float2); +half2 __ovld __cnfn convert_half2_rtn(half2); +half2 __ovld __cnfn convert_half2_rtz(char2); +half2 __ovld __cnfn convert_half2_rtz(uchar2); +half2 __ovld __cnfn convert_half2_rtz(short2); +half2 __ovld __cnfn convert_half2_rtz(ushort2); +half2 __ovld __cnfn convert_half2_rtz(int2); +half2 __ovld __cnfn convert_half2_rtz(uint2); +half2 __ovld __cnfn convert_half2_rtz(long2); +half2 __ovld __cnfn convert_half2_rtz(ulong2); +half2 __ovld __cnfn convert_half2_rtz(float2); +half2 __ovld __cnfn convert_half2_rtz(half2); +half3 __ovld __cnfn convert_half3(char3); +half3 __ovld __cnfn convert_half3(uchar3); +half3 __ovld __cnfn convert_half3(short3); +half3 __ovld __cnfn convert_half3(ushort3); +half3 __ovld __cnfn convert_half3(int3); +half3 __ovld __cnfn convert_half3(uint3); +half3 __ovld __cnfn convert_half3(long3); +half3 __ovld __cnfn convert_half3(ulong3); +half3 __ovld __cnfn convert_half3(float3); +half3 __ovld __cnfn convert_half3(half3); +half3 __ovld __cnfn convert_half3_rte(char3); +half3 __ovld __cnfn convert_half3_rte(uchar3); +half3 __ovld __cnfn convert_half3_rte(short3); +half3 __ovld __cnfn convert_half3_rte(ushort3); +half3 __ovld __cnfn convert_half3_rte(int3); +half3 __ovld __cnfn convert_half3_rte(uint3); +half3 __ovld __cnfn convert_half3_rte(long3); +half3 __ovld __cnfn convert_half3_rte(ulong3); +half3 __ovld __cnfn convert_half3_rte(float3); +half3 __ovld __cnfn convert_half3_rte(half3); +half3 __ovld __cnfn convert_half3_rtp(char3); +half3 __ovld __cnfn convert_half3_rtp(uchar3); +half3 __ovld __cnfn convert_half3_rtp(short3); +half3 __ovld __cnfn convert_half3_rtp(ushort3); +half3 __ovld __cnfn convert_half3_rtp(int3); +half3 __ovld __cnfn convert_half3_rtp(uint3); +half3 __ovld __cnfn convert_half3_rtp(long3); +half3 __ovld __cnfn convert_half3_rtp(ulong3); +half3 __ovld __cnfn convert_half3_rtp(float3); +half3 __ovld __cnfn convert_half3_rtp(half3); +half3 __ovld __cnfn convert_half3_rtn(char3); +half3 __ovld __cnfn convert_half3_rtn(uchar3); +half3 __ovld __cnfn convert_half3_rtn(short3); +half3 __ovld __cnfn convert_half3_rtn(ushort3); +half3 __ovld __cnfn convert_half3_rtn(int3); +half3 __ovld __cnfn convert_half3_rtn(uint3); +half3 __ovld __cnfn convert_half3_rtn(long3); +half3 __ovld __cnfn convert_half3_rtn(ulong3); +half3 __ovld __cnfn convert_half3_rtn(float3); +half3 __ovld __cnfn convert_half3_rtn(half3); +half3 __ovld __cnfn convert_half3_rtz(char3); +half3 __ovld __cnfn convert_half3_rtz(uchar3); +half3 __ovld __cnfn convert_half3_rtz(short3); +half3 __ovld __cnfn convert_half3_rtz(ushort3); +half3 __ovld __cnfn convert_half3_rtz(int3); +half3 __ovld __cnfn convert_half3_rtz(uint3); +half3 __ovld __cnfn convert_half3_rtz(long3); +half3 __ovld __cnfn convert_half3_rtz(ulong3); +half3 __ovld __cnfn convert_half3_rtz(float3); +half3 __ovld __cnfn convert_half3_rtz(half3); +half4 __ovld __cnfn convert_half4(char4); +half4 __ovld __cnfn convert_half4(uchar4); +half4 __ovld __cnfn convert_half4(short4); +half4 __ovld __cnfn convert_half4(ushort4); +half4 __ovld __cnfn convert_half4(int4); +half4 __ovld __cnfn convert_half4(uint4); +half4 __ovld __cnfn convert_half4(long4); +half4 __ovld __cnfn convert_half4(ulong4); +half4 __ovld __cnfn convert_half4(float4); +half4 __ovld __cnfn convert_half4(half4); +half4 __ovld __cnfn convert_half4_rte(char4); +half4 __ovld __cnfn convert_half4_rte(uchar4); +half4 __ovld __cnfn convert_half4_rte(short4); +half4 __ovld __cnfn convert_half4_rte(ushort4); +half4 __ovld __cnfn convert_half4_rte(int4); +half4 __ovld __cnfn convert_half4_rte(uint4); +half4 __ovld __cnfn convert_half4_rte(long4); +half4 __ovld __cnfn convert_half4_rte(ulong4); +half4 __ovld __cnfn convert_half4_rte(float4); +half4 __ovld __cnfn convert_half4_rte(half4); +half4 __ovld __cnfn convert_half4_rtp(char4); +half4 __ovld __cnfn convert_half4_rtp(uchar4); +half4 __ovld __cnfn convert_half4_rtp(short4); +half4 __ovld __cnfn convert_half4_rtp(ushort4); +half4 __ovld __cnfn convert_half4_rtp(int4); +half4 __ovld __cnfn convert_half4_rtp(uint4); +half4 __ovld __cnfn convert_half4_rtp(long4); +half4 __ovld __cnfn convert_half4_rtp(ulong4); +half4 __ovld __cnfn convert_half4_rtp(float4); +half4 __ovld __cnfn convert_half4_rtp(half4); +half4 __ovld __cnfn convert_half4_rtn(char4); +half4 __ovld __cnfn convert_half4_rtn(uchar4); +half4 __ovld __cnfn convert_half4_rtn(short4); +half4 __ovld __cnfn convert_half4_rtn(ushort4); +half4 __ovld __cnfn convert_half4_rtn(int4); +half4 __ovld __cnfn convert_half4_rtn(uint4); +half4 __ovld __cnfn convert_half4_rtn(long4); +half4 __ovld __cnfn convert_half4_rtn(ulong4); +half4 __ovld __cnfn convert_half4_rtn(float4); +half4 __ovld __cnfn convert_half4_rtn(half4); +half4 __ovld __cnfn convert_half4_rtz(char4); +half4 __ovld __cnfn convert_half4_rtz(uchar4); +half4 __ovld __cnfn convert_half4_rtz(short4); +half4 __ovld __cnfn convert_half4_rtz(ushort4); +half4 __ovld __cnfn convert_half4_rtz(int4); +half4 __ovld __cnfn convert_half4_rtz(uint4); +half4 __ovld __cnfn convert_half4_rtz(long4); +half4 __ovld __cnfn convert_half4_rtz(ulong4); +half4 __ovld __cnfn convert_half4_rtz(float4); +half4 __ovld __cnfn convert_half4_rtz(half4); +half8 __ovld __cnfn convert_half8(char8); +half8 __ovld __cnfn convert_half8(uchar8); +half8 __ovld __cnfn convert_half8(short8); +half8 __ovld __cnfn convert_half8(ushort8); +half8 __ovld __cnfn convert_half8(int8); +half8 __ovld __cnfn convert_half8(uint8); +half8 __ovld __cnfn convert_half8(long8); +half8 __ovld __cnfn convert_half8(ulong8); +half8 __ovld __cnfn convert_half8(float8); +half8 __ovld __cnfn convert_half8(half8); +half8 __ovld __cnfn convert_half8_rte(char8); +half8 __ovld __cnfn convert_half8_rte(uchar8); +half8 __ovld __cnfn convert_half8_rte(short8); +half8 __ovld __cnfn convert_half8_rte(ushort8); +half8 __ovld __cnfn convert_half8_rte(int8); +half8 __ovld __cnfn convert_half8_rte(uint8); +half8 __ovld __cnfn convert_half8_rte(long8); +half8 __ovld __cnfn convert_half8_rte(ulong8); +half8 __ovld __cnfn convert_half8_rte(float8); +half8 __ovld __cnfn convert_half8_rte(half8); +half8 __ovld __cnfn convert_half8_rtp(char8); +half8 __ovld __cnfn convert_half8_rtp(uchar8); +half8 __ovld __cnfn convert_half8_rtp(short8); +half8 __ovld __cnfn convert_half8_rtp(ushort8); +half8 __ovld __cnfn convert_half8_rtp(int8); +half8 __ovld __cnfn convert_half8_rtp(uint8); +half8 __ovld __cnfn convert_half8_rtp(long8); +half8 __ovld __cnfn convert_half8_rtp(ulong8); +half8 __ovld __cnfn convert_half8_rtp(float8); +half8 __ovld __cnfn convert_half8_rtp(half8); +half8 __ovld __cnfn convert_half8_rtn(char8); +half8 __ovld __cnfn convert_half8_rtn(uchar8); +half8 __ovld __cnfn convert_half8_rtn(short8); +half8 __ovld __cnfn convert_half8_rtn(ushort8); +half8 __ovld __cnfn convert_half8_rtn(int8); +half8 __ovld __cnfn convert_half8_rtn(uint8); +half8 __ovld __cnfn convert_half8_rtn(long8); +half8 __ovld __cnfn convert_half8_rtn(ulong8); +half8 __ovld __cnfn convert_half8_rtn(float8); +half8 __ovld __cnfn convert_half8_rtn(half8); +half8 __ovld __cnfn convert_half8_rtz(char8); +half8 __ovld __cnfn convert_half8_rtz(uchar8); +half8 __ovld __cnfn convert_half8_rtz(short8); +half8 __ovld __cnfn convert_half8_rtz(ushort8); +half8 __ovld __cnfn convert_half8_rtz(int8); +half8 __ovld __cnfn convert_half8_rtz(uint8); +half8 __ovld __cnfn convert_half8_rtz(long8); +half8 __ovld __cnfn convert_half8_rtz(ulong8); +half8 __ovld __cnfn convert_half8_rtz(float8); +half8 __ovld __cnfn convert_half8_rtz(half8); +half16 __ovld __cnfn convert_half16(char16); +half16 __ovld __cnfn convert_half16(uchar16); +half16 __ovld __cnfn convert_half16(short16); +half16 __ovld __cnfn convert_half16(ushort16); +half16 __ovld __cnfn convert_half16(int16); +half16 __ovld __cnfn convert_half16(uint16); +half16 __ovld __cnfn convert_half16(long16); +half16 __ovld __cnfn convert_half16(ulong16); +half16 __ovld __cnfn convert_half16(float16); +half16 __ovld __cnfn convert_half16(half16); +half16 __ovld __cnfn convert_half16_rte(char16); +half16 __ovld __cnfn convert_half16_rte(uchar16); +half16 __ovld __cnfn convert_half16_rte(short16); +half16 __ovld __cnfn convert_half16_rte(ushort16); +half16 __ovld __cnfn convert_half16_rte(int16); +half16 __ovld __cnfn convert_half16_rte(uint16); +half16 __ovld __cnfn convert_half16_rte(long16); +half16 __ovld __cnfn convert_half16_rte(ulong16); +half16 __ovld __cnfn convert_half16_rte(float16); +half16 __ovld __cnfn convert_half16_rte(half16); +half16 __ovld __cnfn convert_half16_rtp(char16); +half16 __ovld __cnfn convert_half16_rtp(uchar16); +half16 __ovld __cnfn convert_half16_rtp(short16); +half16 __ovld __cnfn convert_half16_rtp(ushort16); +half16 __ovld __cnfn convert_half16_rtp(int16); +half16 __ovld __cnfn convert_half16_rtp(uint16); +half16 __ovld __cnfn convert_half16_rtp(long16); +half16 __ovld __cnfn convert_half16_rtp(ulong16); +half16 __ovld __cnfn convert_half16_rtp(float16); +half16 __ovld __cnfn convert_half16_rtp(half16); +half16 __ovld __cnfn convert_half16_rtn(char16); +half16 __ovld __cnfn convert_half16_rtn(uchar16); +half16 __ovld __cnfn convert_half16_rtn(short16); +half16 __ovld __cnfn convert_half16_rtn(ushort16); +half16 __ovld __cnfn convert_half16_rtn(int16); +half16 __ovld __cnfn convert_half16_rtn(uint16); +half16 __ovld __cnfn convert_half16_rtn(long16); +half16 __ovld __cnfn convert_half16_rtn(ulong16); +half16 __ovld __cnfn convert_half16_rtn(float16); +half16 __ovld __cnfn convert_half16_rtn(half16); +half16 __ovld __cnfn convert_half16_rtz(char16); +half16 __ovld __cnfn convert_half16_rtz(uchar16); +half16 __ovld __cnfn convert_half16_rtz(short16); +half16 __ovld __cnfn convert_half16_rtz(ushort16); +half16 __ovld __cnfn convert_half16_rtz(int16); +half16 __ovld __cnfn convert_half16_rtz(uint16); +half16 __ovld __cnfn convert_half16_rtz(long16); +half16 __ovld __cnfn convert_half16_rtz(ulong16); +half16 __ovld __cnfn convert_half16_rtz(float16); +half16 __ovld __cnfn convert_half16_rtz(half16); + +// Convert half types to double types. +#ifdef cl_khr_fp64 +double __ovld __cnfn convert_double(half); +double __ovld __cnfn convert_double_rte(half); +double __ovld __cnfn convert_double_rtp(half); +double __ovld __cnfn convert_double_rtn(half); +double __ovld __cnfn convert_double_rtz(half); +double2 __ovld __cnfn convert_double2(half2); +double2 __ovld __cnfn convert_double2_rte(half2); +double2 __ovld __cnfn convert_double2_rtp(half2); +double2 __ovld __cnfn convert_double2_rtn(half2); +double2 __ovld __cnfn convert_double2_rtz(half2); +double3 __ovld __cnfn convert_double3(half3); +double3 __ovld __cnfn convert_double3_rte(half3); +double3 __ovld __cnfn convert_double3_rtp(half3); +double3 __ovld __cnfn convert_double3_rtn(half3); +double3 __ovld __cnfn convert_double3_rtz(half3); +double4 __ovld __cnfn convert_double4(half4); +double4 __ovld __cnfn convert_double4_rte(half4); +double4 __ovld __cnfn convert_double4_rtp(half4); +double4 __ovld __cnfn convert_double4_rtn(half4); +double4 __ovld __cnfn convert_double4_rtz(half4); +double8 __ovld __cnfn convert_double8(half8); +double8 __ovld __cnfn convert_double8_rte(half8); +double8 __ovld __cnfn convert_double8_rtp(half8); +double8 __ovld __cnfn convert_double8_rtn(half8); +double8 __ovld __cnfn convert_double8_rtz(half8); +double16 __ovld __cnfn convert_double16(half16); +double16 __ovld __cnfn convert_double16_rte(half16); +double16 __ovld __cnfn convert_double16_rtp(half16); +double16 __ovld __cnfn convert_double16_rtn(half16); +double16 __ovld __cnfn convert_double16_rtz(half16); + +// Convert double types to half types. +half __ovld __cnfn convert_half(double); +half __ovld __cnfn convert_half_rte(double); +half __ovld __cnfn convert_half_rtp(double); +half __ovld __cnfn convert_half_rtn(double); +half __ovld __cnfn convert_half_rtz(double); +half2 __ovld __cnfn convert_half2(double2); +half2 __ovld __cnfn convert_half2_rte(double2); +half2 __ovld __cnfn convert_half2_rtp(double2); +half2 __ovld __cnfn convert_half2_rtn(double2); +half2 __ovld __cnfn convert_half2_rtz(double2); +half3 __ovld __cnfn convert_half3(double3); +half3 __ovld __cnfn convert_half3_rte(double3); +half3 __ovld __cnfn convert_half3_rtp(double3); +half3 __ovld __cnfn convert_half3_rtn(double3); +half3 __ovld __cnfn convert_half3_rtz(double3); +half4 __ovld __cnfn convert_half4(double4); +half4 __ovld __cnfn convert_half4_rte(double4); +half4 __ovld __cnfn convert_half4_rtp(double4); +half4 __ovld __cnfn convert_half4_rtn(double4); +half4 __ovld __cnfn convert_half4_rtz(double4); +half8 __ovld __cnfn convert_half8(double8); +half8 __ovld __cnfn convert_half8_rte(double8); +half8 __ovld __cnfn convert_half8_rtp(double8); +half8 __ovld __cnfn convert_half8_rtn(double8); +half8 __ovld __cnfn convert_half8_rtz(double8); +half16 __ovld __cnfn convert_half16(double16); +half16 __ovld __cnfn convert_half16_rte(double16); +half16 __ovld __cnfn convert_half16_rtp(double16); +half16 __ovld __cnfn convert_half16_rtn(double16); +half16 __ovld __cnfn convert_half16_rtz(double16); +#endif //cl_khr_fp64 + +#endif // cl_khr_fp16 + +// OpenCL v1.1 s6.11.1, v1.2 s6.12.1, v2.0 s6.13.1 - Work-item Functions + +/** + * Returns the number of dimensions in use. This is the + * value given to the work_dim argument specified in + * clEnqueueNDRangeKernel. + * For clEnqueueTask, this returns 1. + */ +uint __ovld __cnfn get_work_dim(void); + +/** + * Returns the number of global work-items specified for + * dimension identified by dimindx. This value is given by + * the global_work_size argument to + * clEnqueueNDRangeKernel. Valid values of dimindx + * are 0 to get_work_dim() - 1. For other values of + * dimindx, get_global_size() returns 1. + * For clEnqueueTask, this always returns 1. + */ +size_t __ovld __cnfn get_global_size(uint); + +/** + * Returns the unique global work-item ID value for + * dimension identified by dimindx. The global work-item + * ID specifies the work-item ID based on the number of + * global work-items specified to execute the kernel. Valid + * values of dimindx are 0 to get_work_dim() - 1. For + * other values of dimindx, get_global_id() returns 0. + * For clEnqueueTask, this returns 0. + */ +size_t __ovld __cnfn get_global_id(uint); + +/** + * Returns the number of local work-items specified in + * dimension identified by dimindx. This value is given by + * the local_work_size argument to + * clEnqueueNDRangeKernel if local_work_size is not + * NULL; otherwise the OpenCL implementation chooses + * an appropriate local_work_size value which is returned + * by this function. Valid values of dimindx are 0 to + * get_work_dim() - 1. For other values of dimindx, + * get_local_size() returns 1. + * For clEnqueueTask, this always returns 1. + */ +size_t __ovld __cnfn get_local_size(uint); + +/** + * Returns the unique local work-item ID i.e. a work-item + * within a specific work-group for dimension identified by + * dimindx. Valid values of dimindx are 0 to + * get_work_dim() - 1. For other values of dimindx, + * get_local_id() returns 0. + * For clEnqueueTask, this returns 0. + */ +size_t __ovld __cnfn get_local_id(uint); + +/** + * Returns the number of work-groups that will execute a + * kernel for dimension identified by dimindx. + * Valid values of dimindx are 0 to get_work_dim() - 1. + * For other values of dimindx, get_num_groups() returns 1. + * For clEnqueueTask, this always returns 1. + */ +size_t __ovld __cnfn get_num_groups(uint); + +/** + * get_group_id returns the work-group ID which is a + * number from 0 .. get_num_groups(dimindx) - 1. + * Valid values of dimindx are 0 to get_work_dim() - 1. + * For other values, get_group_id() returns 0. + * For clEnqueueTask, this returns 0. + */ +size_t __ovld __cnfn get_group_id(uint); + +/** + * get_global_offset returns the offset values specified in + * global_work_offset argument to + * clEnqueueNDRangeKernel. + * Valid values of dimindx are 0 to get_work_dim() - 1. + * For other values, get_global_offset() returns 0. + * For clEnqueueTask, this returns 0. + */ +size_t __ovld __cnfn get_global_offset(uint); + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +size_t __ovld get_enqueued_local_size(uint); +size_t __ovld get_global_linear_id(void); +size_t __ovld get_local_linear_id(void); +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// OpenCL v1.1 s6.11.2, v1.2 s6.12.2, v2.0 s6.13.2 - Math functions + +/** + * Arc cosine function. + */ +float __ovld __cnfn acos(float); +float2 __ovld __cnfn acos(float2); +float3 __ovld __cnfn acos(float3); +float4 __ovld __cnfn acos(float4); +float8 __ovld __cnfn acos(float8); +float16 __ovld __cnfn acos(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn acos(double); +double2 __ovld __cnfn acos(double2); +double3 __ovld __cnfn acos(double3); +double4 __ovld __cnfn acos(double4); +double8 __ovld __cnfn acos(double8); +double16 __ovld __cnfn acos(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn acos(half); +half2 __ovld __cnfn acos(half2); +half3 __ovld __cnfn acos(half3); +half4 __ovld __cnfn acos(half4); +half8 __ovld __cnfn acos(half8); +half16 __ovld __cnfn acos(half16); +#endif //cl_khr_fp16 + +/** + * Inverse hyperbolic cosine. + */ +float __ovld __cnfn acosh(float); +float2 __ovld __cnfn acosh(float2); +float3 __ovld __cnfn acosh(float3); +float4 __ovld __cnfn acosh(float4); +float8 __ovld __cnfn acosh(float8); +float16 __ovld __cnfn acosh(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn acosh(double); +double2 __ovld __cnfn acosh(double2); +double3 __ovld __cnfn acosh(double3); +double4 __ovld __cnfn acosh(double4); +double8 __ovld __cnfn acosh(double8); +double16 __ovld __cnfn acosh(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn acosh(half); +half2 __ovld __cnfn acosh(half2); +half3 __ovld __cnfn acosh(half3); +half4 __ovld __cnfn acosh(half4); +half8 __ovld __cnfn acosh(half8); +half16 __ovld __cnfn acosh(half16); +#endif //cl_khr_fp16 + +/** + * Compute acos (x) / PI. + */ +float __ovld __cnfn acospi(float); +float2 __ovld __cnfn acospi(float2); +float3 __ovld __cnfn acospi(float3); +float4 __ovld __cnfn acospi(float4); +float8 __ovld __cnfn acospi(float8); +float16 __ovld __cnfn acospi(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn acospi(double); +double2 __ovld __cnfn acospi(double2); +double3 __ovld __cnfn acospi(double3); +double4 __ovld __cnfn acospi(double4); +double8 __ovld __cnfn acospi(double8); +double16 __ovld __cnfn acospi(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn acospi(half); +half2 __ovld __cnfn acospi(half2); +half3 __ovld __cnfn acospi(half3); +half4 __ovld __cnfn acospi(half4); +half8 __ovld __cnfn acospi(half8); +half16 __ovld __cnfn acospi(half16); +#endif //cl_khr_fp16 + +/** + * Arc sine function. + */ +float __ovld __cnfn asin(float); +float2 __ovld __cnfn asin(float2); +float3 __ovld __cnfn asin(float3); +float4 __ovld __cnfn asin(float4); +float8 __ovld __cnfn asin(float8); +float16 __ovld __cnfn asin(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn asin(double); +double2 __ovld __cnfn asin(double2); +double3 __ovld __cnfn asin(double3); +double4 __ovld __cnfn asin(double4); +double8 __ovld __cnfn asin(double8); +double16 __ovld __cnfn asin(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn asin(half); +half2 __ovld __cnfn asin(half2); +half3 __ovld __cnfn asin(half3); +half4 __ovld __cnfn asin(half4); +half8 __ovld __cnfn asin(half8); +half16 __ovld __cnfn asin(half16); +#endif //cl_khr_fp16 + +/** + * Inverse hyperbolic sine. + */ +float __ovld __cnfn asinh(float); +float2 __ovld __cnfn asinh(float2); +float3 __ovld __cnfn asinh(float3); +float4 __ovld __cnfn asinh(float4); +float8 __ovld __cnfn asinh(float8); +float16 __ovld __cnfn asinh(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn asinh(double); +double2 __ovld __cnfn asinh(double2); +double3 __ovld __cnfn asinh(double3); +double4 __ovld __cnfn asinh(double4); +double8 __ovld __cnfn asinh(double8); +double16 __ovld __cnfn asinh(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn asinh(half); +half2 __ovld __cnfn asinh(half2); +half3 __ovld __cnfn asinh(half3); +half4 __ovld __cnfn asinh(half4); +half8 __ovld __cnfn asinh(half8); +half16 __ovld __cnfn asinh(half16); +#endif //cl_khr_fp16 + +/** + * Compute asin (x) / PI. + */ +float __ovld __cnfn asinpi(float); +float2 __ovld __cnfn asinpi(float2); +float3 __ovld __cnfn asinpi(float3); +float4 __ovld __cnfn asinpi(float4); +float8 __ovld __cnfn asinpi(float8); +float16 __ovld __cnfn asinpi(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn asinpi(double); +double2 __ovld __cnfn asinpi(double2); +double3 __ovld __cnfn asinpi(double3); +double4 __ovld __cnfn asinpi(double4); +double8 __ovld __cnfn asinpi(double8); +double16 __ovld __cnfn asinpi(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn asinpi(half); +half2 __ovld __cnfn asinpi(half2); +half3 __ovld __cnfn asinpi(half3); +half4 __ovld __cnfn asinpi(half4); +half8 __ovld __cnfn asinpi(half8); +half16 __ovld __cnfn asinpi(half16); +#endif //cl_khr_fp16 + +/** + * Arc tangent function. + */ +float __ovld __cnfn atan(float); +float2 __ovld __cnfn atan(float2); +float3 __ovld __cnfn atan(float3); +float4 __ovld __cnfn atan(float4); +float8 __ovld __cnfn atan(float8); +float16 __ovld __cnfn atan(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn atan(double); +double2 __ovld __cnfn atan(double2); +double3 __ovld __cnfn atan(double3); +double4 __ovld __cnfn atan(double4); +double8 __ovld __cnfn atan(double8); +double16 __ovld __cnfn atan(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn atan(half); +half2 __ovld __cnfn atan(half2); +half3 __ovld __cnfn atan(half3); +half4 __ovld __cnfn atan(half4); +half8 __ovld __cnfn atan(half8); +half16 __ovld __cnfn atan(half16); +#endif //cl_khr_fp16 + +/** + * Arc tangent of y / x. + */ +float __ovld __cnfn atan2(float, float); +float2 __ovld __cnfn atan2(float2, float2); +float3 __ovld __cnfn atan2(float3, float3); +float4 __ovld __cnfn atan2(float4, float4); +float8 __ovld __cnfn atan2(float8, float8); +float16 __ovld __cnfn atan2(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn atan2(double, double); +double2 __ovld __cnfn atan2(double2, double2); +double3 __ovld __cnfn atan2(double3, double3); +double4 __ovld __cnfn atan2(double4, double4); +double8 __ovld __cnfn atan2(double8, double8); +double16 __ovld __cnfn atan2(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn atan2(half, half); +half2 __ovld __cnfn atan2(half2, half2); +half3 __ovld __cnfn atan2(half3, half3); +half4 __ovld __cnfn atan2(half4, half4); +half8 __ovld __cnfn atan2(half8, half8); +half16 __ovld __cnfn atan2(half16, half16); +#endif //cl_khr_fp16 + +/** + * Hyperbolic arc tangent. + */ +float __ovld __cnfn atanh(float); +float2 __ovld __cnfn atanh(float2); +float3 __ovld __cnfn atanh(float3); +float4 __ovld __cnfn atanh(float4); +float8 __ovld __cnfn atanh(float8); +float16 __ovld __cnfn atanh(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn atanh(double); +double2 __ovld __cnfn atanh(double2); +double3 __ovld __cnfn atanh(double3); +double4 __ovld __cnfn atanh(double4); +double8 __ovld __cnfn atanh(double8); +double16 __ovld __cnfn atanh(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn atanh(half); +half2 __ovld __cnfn atanh(half2); +half3 __ovld __cnfn atanh(half3); +half4 __ovld __cnfn atanh(half4); +half8 __ovld __cnfn atanh(half8); +half16 __ovld __cnfn atanh(half16); +#endif //cl_khr_fp16 + +/** + * Compute atan (x) / PI. + */ +float __ovld __cnfn atanpi(float); +float2 __ovld __cnfn atanpi(float2); +float3 __ovld __cnfn atanpi(float3); +float4 __ovld __cnfn atanpi(float4); +float8 __ovld __cnfn atanpi(float8); +float16 __ovld __cnfn atanpi(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn atanpi(double); +double2 __ovld __cnfn atanpi(double2); +double3 __ovld __cnfn atanpi(double3); +double4 __ovld __cnfn atanpi(double4); +double8 __ovld __cnfn atanpi(double8); +double16 __ovld __cnfn atanpi(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn atanpi(half); +half2 __ovld __cnfn atanpi(half2); +half3 __ovld __cnfn atanpi(half3); +half4 __ovld __cnfn atanpi(half4); +half8 __ovld __cnfn atanpi(half8); +half16 __ovld __cnfn atanpi(half16); +#endif //cl_khr_fp16 + +/** + * Compute atan2 (y, x) / PI. + */ +float __ovld __cnfn atan2pi(float, float); +float2 __ovld __cnfn atan2pi(float2, float2); +float3 __ovld __cnfn atan2pi(float3, float3); +float4 __ovld __cnfn atan2pi(float4, float4); +float8 __ovld __cnfn atan2pi(float8, float8); +float16 __ovld __cnfn atan2pi(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn atan2pi(double, double); +double2 __ovld __cnfn atan2pi(double2, double2); +double3 __ovld __cnfn atan2pi(double3, double3); +double4 __ovld __cnfn atan2pi(double4, double4); +double8 __ovld __cnfn atan2pi(double8, double8); +double16 __ovld __cnfn atan2pi(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn atan2pi(half, half); +half2 __ovld __cnfn atan2pi(half2, half2); +half3 __ovld __cnfn atan2pi(half3, half3); +half4 __ovld __cnfn atan2pi(half4, half4); +half8 __ovld __cnfn atan2pi(half8, half8); +half16 __ovld __cnfn atan2pi(half16, half16); +#endif //cl_khr_fp16 + +/** + * Compute cube-root. + */ +float __ovld __cnfn cbrt(float); +float2 __ovld __cnfn cbrt(float2); +float3 __ovld __cnfn cbrt(float3); +float4 __ovld __cnfn cbrt(float4); +float8 __ovld __cnfn cbrt(float8); +float16 __ovld __cnfn cbrt(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn cbrt(double); +double2 __ovld __cnfn cbrt(double2); +double3 __ovld __cnfn cbrt(double3); +double4 __ovld __cnfn cbrt(double4); +double8 __ovld __cnfn cbrt(double8); +double16 __ovld __cnfn cbrt(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn cbrt(half); +half2 __ovld __cnfn cbrt(half2); +half3 __ovld __cnfn cbrt(half3); +half4 __ovld __cnfn cbrt(half4); +half8 __ovld __cnfn cbrt(half8); +half16 __ovld __cnfn cbrt(half16); +#endif //cl_khr_fp16 + +/** + * Round to integral value using the round to positive + * infinity rounding mode. + */ +float __ovld __cnfn ceil(float); +float2 __ovld __cnfn ceil(float2); +float3 __ovld __cnfn ceil(float3); +float4 __ovld __cnfn ceil(float4); +float8 __ovld __cnfn ceil(float8); +float16 __ovld __cnfn ceil(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn ceil(double); +double2 __ovld __cnfn ceil(double2); +double3 __ovld __cnfn ceil(double3); +double4 __ovld __cnfn ceil(double4); +double8 __ovld __cnfn ceil(double8); +double16 __ovld __cnfn ceil(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn ceil(half); +half2 __ovld __cnfn ceil(half2); +half3 __ovld __cnfn ceil(half3); +half4 __ovld __cnfn ceil(half4); +half8 __ovld __cnfn ceil(half8); +half16 __ovld __cnfn ceil(half16); +#endif //cl_khr_fp16 + +/** + * Returns x with its sign changed to match the sign of y. + */ +float __ovld __cnfn copysign(float, float); +float2 __ovld __cnfn copysign(float2, float2); +float3 __ovld __cnfn copysign(float3, float3); +float4 __ovld __cnfn copysign(float4, float4); +float8 __ovld __cnfn copysign(float8, float8); +float16 __ovld __cnfn copysign(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn copysign(double, double); +double2 __ovld __cnfn copysign(double2, double2); +double3 __ovld __cnfn copysign(double3, double3); +double4 __ovld __cnfn copysign(double4, double4); +double8 __ovld __cnfn copysign(double8, double8); +double16 __ovld __cnfn copysign(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn copysign(half, half); +half2 __ovld __cnfn copysign(half2, half2); +half3 __ovld __cnfn copysign(half3, half3); +half4 __ovld __cnfn copysign(half4, half4); +half8 __ovld __cnfn copysign(half8, half8); +half16 __ovld __cnfn copysign(half16, half16); +#endif //cl_khr_fp16 + +/** + * Compute cosine. + */ +float __ovld __cnfn cos(float); +float2 __ovld __cnfn cos(float2); +float3 __ovld __cnfn cos(float3); +float4 __ovld __cnfn cos(float4); +float8 __ovld __cnfn cos(float8); +float16 __ovld __cnfn cos(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn cos(double); +double2 __ovld __cnfn cos(double2); +double3 __ovld __cnfn cos(double3); +double4 __ovld __cnfn cos(double4); +double8 __ovld __cnfn cos(double8); +double16 __ovld __cnfn cos(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn cos(half); +half2 __ovld __cnfn cos(half2); +half3 __ovld __cnfn cos(half3); +half4 __ovld __cnfn cos(half4); +half8 __ovld __cnfn cos(half8); +half16 __ovld __cnfn cos(half16); +#endif //cl_khr_fp16 + +/** + * Compute hyperbolic cosine. + */ +float __ovld __cnfn cosh(float); +float2 __ovld __cnfn cosh(float2); +float3 __ovld __cnfn cosh(float3); +float4 __ovld __cnfn cosh(float4); +float8 __ovld __cnfn cosh(float8); +float16 __ovld __cnfn cosh(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn cosh(double); +double2 __ovld __cnfn cosh(double2); +double3 __ovld __cnfn cosh(double3); +double4 __ovld __cnfn cosh(double4); +double8 __ovld __cnfn cosh(double8); +double16 __ovld __cnfn cosh(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn cosh(half); +half2 __ovld __cnfn cosh(half2); +half3 __ovld __cnfn cosh(half3); +half4 __ovld __cnfn cosh(half4); +half8 __ovld __cnfn cosh(half8); +half16 __ovld __cnfn cosh(half16); +#endif //cl_khr_fp16 + +/** + * Compute cos (PI * x). + */ +float __ovld __cnfn cospi(float); +float2 __ovld __cnfn cospi(float2); +float3 __ovld __cnfn cospi(float3); +float4 __ovld __cnfn cospi(float4); +float8 __ovld __cnfn cospi(float8); +float16 __ovld __cnfn cospi(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn cospi(double); +double2 __ovld __cnfn cospi(double2); +double3 __ovld __cnfn cospi(double3); +double4 __ovld __cnfn cospi(double4); +double8 __ovld __cnfn cospi(double8); +double16 __ovld __cnfn cospi(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn cospi(half); +half2 __ovld __cnfn cospi(half2); +half3 __ovld __cnfn cospi(half3); +half4 __ovld __cnfn cospi(half4); +half8 __ovld __cnfn cospi(half8); +half16 __ovld __cnfn cospi(half16); +#endif //cl_khr_fp16 + +/** + * Complementary error function. + */ +float __ovld __cnfn erfc(float); +float2 __ovld __cnfn erfc(float2); +float3 __ovld __cnfn erfc(float3); +float4 __ovld __cnfn erfc(float4); +float8 __ovld __cnfn erfc(float8); +float16 __ovld __cnfn erfc(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn erfc(double); +double2 __ovld __cnfn erfc(double2); +double3 __ovld __cnfn erfc(double3); +double4 __ovld __cnfn erfc(double4); +double8 __ovld __cnfn erfc(double8); +double16 __ovld __cnfn erfc(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn erfc(half); +half2 __ovld __cnfn erfc(half2); +half3 __ovld __cnfn erfc(half3); +half4 __ovld __cnfn erfc(half4); +half8 __ovld __cnfn erfc(half8); +half16 __ovld __cnfn erfc(half16); +#endif //cl_khr_fp16 + +/** + * Error function encountered in integrating the + * normal distribution. + */ +float __ovld __cnfn erf(float); +float2 __ovld __cnfn erf(float2); +float3 __ovld __cnfn erf(float3); +float4 __ovld __cnfn erf(float4); +float8 __ovld __cnfn erf(float8); +float16 __ovld __cnfn erf(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn erf(double); +double2 __ovld __cnfn erf(double2); +double3 __ovld __cnfn erf(double3); +double4 __ovld __cnfn erf(double4); +double8 __ovld __cnfn erf(double8); +double16 __ovld __cnfn erf(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn erf(half); +half2 __ovld __cnfn erf(half2); +half3 __ovld __cnfn erf(half3); +half4 __ovld __cnfn erf(half4); +half8 __ovld __cnfn erf(half8); +half16 __ovld __cnfn erf(half16); +#endif //cl_khr_fp16 + +/** + * Compute the base e exponential function of x. + */ +float __ovld __cnfn exp(float); +float2 __ovld __cnfn exp(float2); +float3 __ovld __cnfn exp(float3); +float4 __ovld __cnfn exp(float4); +float8 __ovld __cnfn exp(float8); +float16 __ovld __cnfn exp(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn exp(double); +double2 __ovld __cnfn exp(double2); +double3 __ovld __cnfn exp(double3); +double4 __ovld __cnfn exp(double4); +double8 __ovld __cnfn exp(double8); +double16 __ovld __cnfn exp(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn exp(half); +half2 __ovld __cnfn exp(half2); +half3 __ovld __cnfn exp(half3); +half4 __ovld __cnfn exp(half4); +half8 __ovld __cnfn exp(half8); +half16 __ovld __cnfn exp(half16); +#endif //cl_khr_fp16 + +/** + * Exponential base 2 function. + */ +float __ovld __cnfn exp2(float); +float2 __ovld __cnfn exp2(float2); +float3 __ovld __cnfn exp2(float3); +float4 __ovld __cnfn exp2(float4); +float8 __ovld __cnfn exp2(float8); +float16 __ovld __cnfn exp2(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn exp2(double); +double2 __ovld __cnfn exp2(double2); +double3 __ovld __cnfn exp2(double3); +double4 __ovld __cnfn exp2(double4); +double8 __ovld __cnfn exp2(double8); +double16 __ovld __cnfn exp2(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn exp2(half); +half2 __ovld __cnfn exp2(half2); +half3 __ovld __cnfn exp2(half3); +half4 __ovld __cnfn exp2(half4); +half8 __ovld __cnfn exp2(half8); +half16 __ovld __cnfn exp2(half16); +#endif //cl_khr_fp16 + +/** + * Exponential base 10 function. + */ +float __ovld __cnfn exp10(float); +float2 __ovld __cnfn exp10(float2); +float3 __ovld __cnfn exp10(float3); +float4 __ovld __cnfn exp10(float4); +float8 __ovld __cnfn exp10(float8); +float16 __ovld __cnfn exp10(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn exp10(double); +double2 __ovld __cnfn exp10(double2); +double3 __ovld __cnfn exp10(double3); +double4 __ovld __cnfn exp10(double4); +double8 __ovld __cnfn exp10(double8); +double16 __ovld __cnfn exp10(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn exp10(half); +half2 __ovld __cnfn exp10(half2); +half3 __ovld __cnfn exp10(half3); +half4 __ovld __cnfn exp10(half4); +half8 __ovld __cnfn exp10(half8); +half16 __ovld __cnfn exp10(half16); +#endif //cl_khr_fp16 + +/** + * Compute e^x- 1.0. + */ +float __ovld __cnfn expm1(float); +float2 __ovld __cnfn expm1(float2); +float3 __ovld __cnfn expm1(float3); +float4 __ovld __cnfn expm1(float4); +float8 __ovld __cnfn expm1(float8); +float16 __ovld __cnfn expm1(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn expm1(double); +double2 __ovld __cnfn expm1(double2); +double3 __ovld __cnfn expm1(double3); +double4 __ovld __cnfn expm1(double4); +double8 __ovld __cnfn expm1(double8); +double16 __ovld __cnfn expm1(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn expm1(half); +half2 __ovld __cnfn expm1(half2); +half3 __ovld __cnfn expm1(half3); +half4 __ovld __cnfn expm1(half4); +half8 __ovld __cnfn expm1(half8); +half16 __ovld __cnfn expm1(half16); +#endif //cl_khr_fp16 + +/** + * Compute absolute value of a floating-point number. + */ +float __ovld __cnfn fabs(float); +float2 __ovld __cnfn fabs(float2); +float3 __ovld __cnfn fabs(float3); +float4 __ovld __cnfn fabs(float4); +float8 __ovld __cnfn fabs(float8); +float16 __ovld __cnfn fabs(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn fabs(double); +double2 __ovld __cnfn fabs(double2); +double3 __ovld __cnfn fabs(double3); +double4 __ovld __cnfn fabs(double4); +double8 __ovld __cnfn fabs(double8); +double16 __ovld __cnfn fabs(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn fabs(half); +half2 __ovld __cnfn fabs(half2); +half3 __ovld __cnfn fabs(half3); +half4 __ovld __cnfn fabs(half4); +half8 __ovld __cnfn fabs(half8); +half16 __ovld __cnfn fabs(half16); +#endif //cl_khr_fp16 + +/** + * x - y if x > y, +0 if x is less than or equal to y. + */ +float __ovld __cnfn fdim(float, float); +float2 __ovld __cnfn fdim(float2, float2); +float3 __ovld __cnfn fdim(float3, float3); +float4 __ovld __cnfn fdim(float4, float4); +float8 __ovld __cnfn fdim(float8, float8); +float16 __ovld __cnfn fdim(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn fdim(double, double); +double2 __ovld __cnfn fdim(double2, double2); +double3 __ovld __cnfn fdim(double3, double3); +double4 __ovld __cnfn fdim(double4, double4); +double8 __ovld __cnfn fdim(double8, double8); +double16 __ovld __cnfn fdim(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn fdim(half, half); +half2 __ovld __cnfn fdim(half2, half2); +half3 __ovld __cnfn fdim(half3, half3); +half4 __ovld __cnfn fdim(half4, half4); +half8 __ovld __cnfn fdim(half8, half8); +half16 __ovld __cnfn fdim(half16, half16); +#endif //cl_khr_fp16 + +/** + * Round to integral value using the round to -ve + * infinity rounding mode. + */ +float __ovld __cnfn floor(float); +float2 __ovld __cnfn floor(float2); +float3 __ovld __cnfn floor(float3); +float4 __ovld __cnfn floor(float4); +float8 __ovld __cnfn floor(float8); +float16 __ovld __cnfn floor(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn floor(double); +double2 __ovld __cnfn floor(double2); +double3 __ovld __cnfn floor(double3); +double4 __ovld __cnfn floor(double4); +double8 __ovld __cnfn floor(double8); +double16 __ovld __cnfn floor(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn floor(half); +half2 __ovld __cnfn floor(half2); +half3 __ovld __cnfn floor(half3); +half4 __ovld __cnfn floor(half4); +half8 __ovld __cnfn floor(half8); +half16 __ovld __cnfn floor(half16); +#endif //cl_khr_fp16 + +/** + * Returns the correctly rounded floating-point + * representation of the sum of c with the infinitely + * precise product of a and b. Rounding of + * intermediate products shall not occur. Edge case + * behavior is per the IEEE 754-2008 standard. + */ +float __ovld __cnfn fma(float, float, float); +float2 __ovld __cnfn fma(float2, float2, float2); +float3 __ovld __cnfn fma(float3, float3, float3); +float4 __ovld __cnfn fma(float4, float4, float4); +float8 __ovld __cnfn fma(float8, float8, float8); +float16 __ovld __cnfn fma(float16, float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn fma(double, double, double); +double2 __ovld __cnfn fma(double2, double2, double2); +double3 __ovld __cnfn fma(double3, double3, double3); +double4 __ovld __cnfn fma(double4, double4, double4); +double8 __ovld __cnfn fma(double8, double8, double8); +double16 __ovld __cnfn fma(double16, double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn fma(half, half, half); +half2 __ovld __cnfn fma(half2, half2, half2); +half3 __ovld __cnfn fma(half3, half3, half3); +half4 __ovld __cnfn fma(half4, half4, half4); +half8 __ovld __cnfn fma(half8, half8, half8); +half16 __ovld __cnfn fma(half16, half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns y if x < y, otherwise it returns x. If one + * argument is a NaN, fmax() returns the other + * argument. If both arguments are NaNs, fmax() + * returns a NaN. + */ +float __ovld __cnfn fmax(float, float); +float2 __ovld __cnfn fmax(float2, float2); +float3 __ovld __cnfn fmax(float3, float3); +float4 __ovld __cnfn fmax(float4, float4); +float8 __ovld __cnfn fmax(float8, float8); +float16 __ovld __cnfn fmax(float16, float16); +float2 __ovld __cnfn fmax(float2, float); +float3 __ovld __cnfn fmax(float3, float); +float4 __ovld __cnfn fmax(float4, float); +float8 __ovld __cnfn fmax(float8, float); +float16 __ovld __cnfn fmax(float16, float); +#ifdef cl_khr_fp64 +double __ovld __cnfn fmax(double, double); +double2 __ovld __cnfn fmax(double2, double2); +double3 __ovld __cnfn fmax(double3, double3); +double4 __ovld __cnfn fmax(double4, double4); +double8 __ovld __cnfn fmax(double8, double8); +double16 __ovld __cnfn fmax(double16, double16); +double2 __ovld __cnfn fmax(double2, double); +double3 __ovld __cnfn fmax(double3, double); +double4 __ovld __cnfn fmax(double4, double); +double8 __ovld __cnfn fmax(double8, double); +double16 __ovld __cnfn fmax(double16, double); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn fmax(half, half); +half2 __ovld __cnfn fmax(half2, half2); +half3 __ovld __cnfn fmax(half3, half3); +half4 __ovld __cnfn fmax(half4, half4); +half8 __ovld __cnfn fmax(half8, half8); +half16 __ovld __cnfn fmax(half16, half16); +half2 __ovld __cnfn fmax(half2, half); +half3 __ovld __cnfn fmax(half3, half); +half4 __ovld __cnfn fmax(half4, half); +half8 __ovld __cnfn fmax(half8, half); +half16 __ovld __cnfn fmax(half16, half); +#endif //cl_khr_fp16 + +/** + * Returns y if y < x, otherwise it returns x. If one + * argument is a NaN, fmin() returns the other + * argument. If both arguments are NaNs, fmin() + * returns a NaN. + */ +float __ovld __cnfn fmin(float, float); +float2 __ovld __cnfn fmin(float2, float2); +float3 __ovld __cnfn fmin(float3, float3); +float4 __ovld __cnfn fmin(float4, float4); +float8 __ovld __cnfn fmin(float8, float8); +float16 __ovld __cnfn fmin(float16, float16); +float2 __ovld __cnfn fmin(float2, float); +float3 __ovld __cnfn fmin(float3, float); +float4 __ovld __cnfn fmin(float4, float); +float8 __ovld __cnfn fmin(float8, float); +float16 __ovld __cnfn fmin(float16, float); +#ifdef cl_khr_fp64 +double __ovld __cnfn fmin(double, double); +double2 __ovld __cnfn fmin(double2, double2); +double3 __ovld __cnfn fmin(double3, double3); +double4 __ovld __cnfn fmin(double4, double4); +double8 __ovld __cnfn fmin(double8, double8); +double16 __ovld __cnfn fmin(double16, double16); +double2 __ovld __cnfn fmin(double2, double); +double3 __ovld __cnfn fmin(double3, double); +double4 __ovld __cnfn fmin(double4, double); +double8 __ovld __cnfn fmin(double8, double); +double16 __ovld __cnfn fmin(double16, double); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn fmin(half, half); +half2 __ovld __cnfn fmin(half2, half2); +half3 __ovld __cnfn fmin(half3, half3); +half4 __ovld __cnfn fmin(half4, half4); +half8 __ovld __cnfn fmin(half8, half8); +half16 __ovld __cnfn fmin(half16, half16); +half2 __ovld __cnfn fmin(half2, half); +half3 __ovld __cnfn fmin(half3, half); +half4 __ovld __cnfn fmin(half4, half); +half8 __ovld __cnfn fmin(half8, half); +half16 __ovld __cnfn fmin(half16, half); +#endif //cl_khr_fp16 + +/** + * Modulus. Returns x - y * trunc (x/y). + */ +float __ovld __cnfn fmod(float, float); +float2 __ovld __cnfn fmod(float2, float2); +float3 __ovld __cnfn fmod(float3, float3); +float4 __ovld __cnfn fmod(float4, float4); +float8 __ovld __cnfn fmod(float8, float8); +float16 __ovld __cnfn fmod(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn fmod(double, double); +double2 __ovld __cnfn fmod(double2, double2); +double3 __ovld __cnfn fmod(double3, double3); +double4 __ovld __cnfn fmod(double4, double4); +double8 __ovld __cnfn fmod(double8, double8); +double16 __ovld __cnfn fmod(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn fmod(half, half); +half2 __ovld __cnfn fmod(half2, half2); +half3 __ovld __cnfn fmod(half3, half3); +half4 __ovld __cnfn fmod(half4, half4); +half8 __ovld __cnfn fmod(half8, half8); +half16 __ovld __cnfn fmod(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns fmin(x - floor (x), 0x1.fffffep-1f ). + * floor(x) is returned in iptr. + */ +#if defined(__opencl_c_generic_address_space) +float __ovld fract(float, float *); +float2 __ovld fract(float2, float2 *); +float3 __ovld fract(float3, float3 *); +float4 __ovld fract(float4, float4 *); +float8 __ovld fract(float8, float8 *); +float16 __ovld fract(float16, float16 *); +#ifdef cl_khr_fp64 +double __ovld fract(double, double *); +double2 __ovld fract(double2, double2 *); +double3 __ovld fract(double3, double3 *); +double4 __ovld fract(double4, double4 *); +double8 __ovld fract(double8, double8 *); +double16 __ovld fract(double16, double16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld fract(half, half *); +half2 __ovld fract(half2, half2 *); +half3 __ovld fract(half3, half3 *); +half4 __ovld fract(half4, half4 *); +half8 __ovld fract(half8, half8 *); +half16 __ovld fract(half16, half16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld fract(float, __global float *); +float2 __ovld fract(float2, __global float2 *); +float3 __ovld fract(float3, __global float3 *); +float4 __ovld fract(float4, __global float4 *); +float8 __ovld fract(float8, __global float8 *); +float16 __ovld fract(float16, __global float16 *); +float __ovld fract(float, __local float *); +float2 __ovld fract(float2, __local float2 *); +float3 __ovld fract(float3, __local float3 *); +float4 __ovld fract(float4, __local float4 *); +float8 __ovld fract(float8, __local float8 *); +float16 __ovld fract(float16, __local float16 *); +float __ovld fract(float, __private float *); +float2 __ovld fract(float2, __private float2 *); +float3 __ovld fract(float3, __private float3 *); +float4 __ovld fract(float4, __private float4 *); +float8 __ovld fract(float8, __private float8 *); +float16 __ovld fract(float16, __private float16 *); +#ifdef cl_khr_fp64 +double __ovld fract(double, __global double *); +double2 __ovld fract(double2, __global double2 *); +double3 __ovld fract(double3, __global double3 *); +double4 __ovld fract(double4, __global double4 *); +double8 __ovld fract(double8, __global double8 *); +double16 __ovld fract(double16, __global double16 *); +double __ovld fract(double, __local double *); +double2 __ovld fract(double2, __local double2 *); +double3 __ovld fract(double3, __local double3 *); +double4 __ovld fract(double4, __local double4 *); +double8 __ovld fract(double8, __local double8 *); +double16 __ovld fract(double16, __local double16 *); +double __ovld fract(double, __private double *); +double2 __ovld fract(double2, __private double2 *); +double3 __ovld fract(double3, __private double3 *); +double4 __ovld fract(double4, __private double4 *); +double8 __ovld fract(double8, __private double8 *); +double16 __ovld fract(double16, __private double16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld fract(half, __global half *); +half2 __ovld fract(half2, __global half2 *); +half3 __ovld fract(half3, __global half3 *); +half4 __ovld fract(half4, __global half4 *); +half8 __ovld fract(half8, __global half8 *); +half16 __ovld fract(half16, __global half16 *); +half __ovld fract(half, __local half *); +half2 __ovld fract(half2, __local half2 *); +half3 __ovld fract(half3, __local half3 *); +half4 __ovld fract(half4, __local half4 *); +half8 __ovld fract(half8, __local half8 *); +half16 __ovld fract(half16, __local half16 *); +half __ovld fract(half, __private half *); +half2 __ovld fract(half2, __private half2 *); +half3 __ovld fract(half3, __private half3 *); +half4 __ovld fract(half4, __private half4 *); +half8 __ovld fract(half8, __private half8 *); +half16 __ovld fract(half16, __private half16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Extract mantissa and exponent from x. For each + * component the mantissa returned is a float with + * magnitude in the interval [1/2, 1) or 0. Each + * component of x equals mantissa returned * 2^exp. + */ +#if defined(__opencl_c_generic_address_space) +float __ovld frexp(float, int *); +float2 __ovld frexp(float2, int2 *); +float3 __ovld frexp(float3, int3 *); +float4 __ovld frexp(float4, int4 *); +float8 __ovld frexp(float8, int8 *); +float16 __ovld frexp(float16, int16 *); +#ifdef cl_khr_fp64 +double __ovld frexp(double, int *); +double2 __ovld frexp(double2, int2 *); +double3 __ovld frexp(double3, int3 *); +double4 __ovld frexp(double4, int4 *); +double8 __ovld frexp(double8, int8 *); +double16 __ovld frexp(double16, int16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld frexp(half, int *); +half2 __ovld frexp(half2, int2 *); +half3 __ovld frexp(half3, int3 *); +half4 __ovld frexp(half4, int4 *); +half8 __ovld frexp(half8, int8 *); +half16 __ovld frexp(half16, int16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld frexp(float, __global int *); +float2 __ovld frexp(float2, __global int2 *); +float3 __ovld frexp(float3, __global int3 *); +float4 __ovld frexp(float4, __global int4 *); +float8 __ovld frexp(float8, __global int8 *); +float16 __ovld frexp(float16, __global int16 *); +float __ovld frexp(float, __local int *); +float2 __ovld frexp(float2, __local int2 *); +float3 __ovld frexp(float3, __local int3 *); +float4 __ovld frexp(float4, __local int4 *); +float8 __ovld frexp(float8, __local int8 *); +float16 __ovld frexp(float16, __local int16 *); +float __ovld frexp(float, __private int *); +float2 __ovld frexp(float2, __private int2 *); +float3 __ovld frexp(float3, __private int3 *); +float4 __ovld frexp(float4, __private int4 *); +float8 __ovld frexp(float8, __private int8 *); +float16 __ovld frexp(float16, __private int16 *); +#ifdef cl_khr_fp64 +double __ovld frexp(double, __global int *); +double2 __ovld frexp(double2, __global int2 *); +double3 __ovld frexp(double3, __global int3 *); +double4 __ovld frexp(double4, __global int4 *); +double8 __ovld frexp(double8, __global int8 *); +double16 __ovld frexp(double16, __global int16 *); +double __ovld frexp(double, __local int *); +double2 __ovld frexp(double2, __local int2 *); +double3 __ovld frexp(double3, __local int3 *); +double4 __ovld frexp(double4, __local int4 *); +double8 __ovld frexp(double8, __local int8 *); +double16 __ovld frexp(double16, __local int16 *); +double __ovld frexp(double, __private int *); +double2 __ovld frexp(double2, __private int2 *); +double3 __ovld frexp(double3, __private int3 *); +double4 __ovld frexp(double4, __private int4 *); +double8 __ovld frexp(double8, __private int8 *); +double16 __ovld frexp(double16, __private int16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld frexp(half, __global int *); +half2 __ovld frexp(half2, __global int2 *); +half3 __ovld frexp(half3, __global int3 *); +half4 __ovld frexp(half4, __global int4 *); +half8 __ovld frexp(half8, __global int8 *); +half16 __ovld frexp(half16, __global int16 *); +half __ovld frexp(half, __local int *); +half2 __ovld frexp(half2, __local int2 *); +half3 __ovld frexp(half3, __local int3 *); +half4 __ovld frexp(half4, __local int4 *); +half8 __ovld frexp(half8, __local int8 *); +half16 __ovld frexp(half16, __local int16 *); +half __ovld frexp(half, __private int *); +half2 __ovld frexp(half2, __private int2 *); +half3 __ovld frexp(half3, __private int3 *); +half4 __ovld frexp(half4, __private int4 *); +half8 __ovld frexp(half8, __private int8 *); +half16 __ovld frexp(half16, __private int16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Compute the value of the square root of x^2 + y^2 + * without undue overflow or underflow. + */ +float __ovld __cnfn hypot(float, float); +float2 __ovld __cnfn hypot(float2, float2); +float3 __ovld __cnfn hypot(float3, float3); +float4 __ovld __cnfn hypot(float4, float4); +float8 __ovld __cnfn hypot(float8, float8); +float16 __ovld __cnfn hypot(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn hypot(double, double); +double2 __ovld __cnfn hypot(double2, double2); +double3 __ovld __cnfn hypot(double3, double3); +double4 __ovld __cnfn hypot(double4, double4); +double8 __ovld __cnfn hypot(double8, double8); +double16 __ovld __cnfn hypot(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn hypot(half, half); +half2 __ovld __cnfn hypot(half2, half2); +half3 __ovld __cnfn hypot(half3, half3); +half4 __ovld __cnfn hypot(half4, half4); +half8 __ovld __cnfn hypot(half8, half8); +half16 __ovld __cnfn hypot(half16, half16); +#endif //cl_khr_fp16 + +/** + * Return the exponent as an integer value. + */ +int __ovld __cnfn ilogb(float); +int2 __ovld __cnfn ilogb(float2); +int3 __ovld __cnfn ilogb(float3); +int4 __ovld __cnfn ilogb(float4); +int8 __ovld __cnfn ilogb(float8); +int16 __ovld __cnfn ilogb(float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn ilogb(double); +int2 __ovld __cnfn ilogb(double2); +int3 __ovld __cnfn ilogb(double3); +int4 __ovld __cnfn ilogb(double4); +int8 __ovld __cnfn ilogb(double8); +int16 __ovld __cnfn ilogb(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn ilogb(half); +int2 __ovld __cnfn ilogb(half2); +int3 __ovld __cnfn ilogb(half3); +int4 __ovld __cnfn ilogb(half4); +int8 __ovld __cnfn ilogb(half8); +int16 __ovld __cnfn ilogb(half16); +#endif //cl_khr_fp16 + +/** + * Multiply x by 2 to the power n. + */ +float __ovld __cnfn ldexp(float, int); +float2 __ovld __cnfn ldexp(float2, int2); +float3 __ovld __cnfn ldexp(float3, int3); +float4 __ovld __cnfn ldexp(float4, int4); +float8 __ovld __cnfn ldexp(float8, int8); +float16 __ovld __cnfn ldexp(float16, int16); +float2 __ovld __cnfn ldexp(float2, int); +float3 __ovld __cnfn ldexp(float3, int); +float4 __ovld __cnfn ldexp(float4, int); +float8 __ovld __cnfn ldexp(float8, int); +float16 __ovld __cnfn ldexp(float16, int); +#ifdef cl_khr_fp64 +double __ovld __cnfn ldexp(double, int); +double2 __ovld __cnfn ldexp(double2, int2); +double3 __ovld __cnfn ldexp(double3, int3); +double4 __ovld __cnfn ldexp(double4, int4); +double8 __ovld __cnfn ldexp(double8, int8); +double16 __ovld __cnfn ldexp(double16, int16); +double2 __ovld __cnfn ldexp(double2, int); +double3 __ovld __cnfn ldexp(double3, int); +double4 __ovld __cnfn ldexp(double4, int); +double8 __ovld __cnfn ldexp(double8, int); +double16 __ovld __cnfn ldexp(double16, int); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn ldexp(half, int); +half2 __ovld __cnfn ldexp(half2, int2); +half3 __ovld __cnfn ldexp(half3, int3); +half4 __ovld __cnfn ldexp(half4, int4); +half8 __ovld __cnfn ldexp(half8, int8); +half16 __ovld __cnfn ldexp(half16, int16); +half2 __ovld __cnfn ldexp(half2, int); +half3 __ovld __cnfn ldexp(half3, int); +half4 __ovld __cnfn ldexp(half4, int); +half8 __ovld __cnfn ldexp(half8, int); +half16 __ovld __cnfn ldexp(half16, int); +#endif //cl_khr_fp16 + +/** + * Log gamma function. Returns the natural + * logarithm of the absolute value of the gamma + * function. The sign of the gamma function is + * returned in the signp argument of lgamma_r. + */ +float __ovld __cnfn lgamma(float); +float2 __ovld __cnfn lgamma(float2); +float3 __ovld __cnfn lgamma(float3); +float4 __ovld __cnfn lgamma(float4); +float8 __ovld __cnfn lgamma(float8); +float16 __ovld __cnfn lgamma(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn lgamma(double); +double2 __ovld __cnfn lgamma(double2); +double3 __ovld __cnfn lgamma(double3); +double4 __ovld __cnfn lgamma(double4); +double8 __ovld __cnfn lgamma(double8); +double16 __ovld __cnfn lgamma(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn lgamma(half); +half2 __ovld __cnfn lgamma(half2); +half3 __ovld __cnfn lgamma(half3); +half4 __ovld __cnfn lgamma(half4); +half8 __ovld __cnfn lgamma(half8); +half16 __ovld __cnfn lgamma(half16); +#endif //cl_khr_fp16 + +#if defined(__opencl_c_generic_address_space) +float __ovld lgamma_r(float, int *); +float2 __ovld lgamma_r(float2, int2 *); +float3 __ovld lgamma_r(float3, int3 *); +float4 __ovld lgamma_r(float4, int4 *); +float8 __ovld lgamma_r(float8, int8 *); +float16 __ovld lgamma_r(float16, int16 *); +#ifdef cl_khr_fp64 +double __ovld lgamma_r(double, int *); +double2 __ovld lgamma_r(double2, int2 *); +double3 __ovld lgamma_r(double3, int3 *); +double4 __ovld lgamma_r(double4, int4 *); +double8 __ovld lgamma_r(double8, int8 *); +double16 __ovld lgamma_r(double16, int16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld lgamma_r(half, int *); +half2 __ovld lgamma_r(half2, int2 *); +half3 __ovld lgamma_r(half3, int3 *); +half4 __ovld lgamma_r(half4, int4 *); +half8 __ovld lgamma_r(half8, int8 *); +half16 __ovld lgamma_r(half16, int16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld lgamma_r(float, __global int *); +float2 __ovld lgamma_r(float2, __global int2 *); +float3 __ovld lgamma_r(float3, __global int3 *); +float4 __ovld lgamma_r(float4, __global int4 *); +float8 __ovld lgamma_r(float8, __global int8 *); +float16 __ovld lgamma_r(float16, __global int16 *); +float __ovld lgamma_r(float, __local int *); +float2 __ovld lgamma_r(float2, __local int2 *); +float3 __ovld lgamma_r(float3, __local int3 *); +float4 __ovld lgamma_r(float4, __local int4 *); +float8 __ovld lgamma_r(float8, __local int8 *); +float16 __ovld lgamma_r(float16, __local int16 *); +float __ovld lgamma_r(float, __private int *); +float2 __ovld lgamma_r(float2, __private int2 *); +float3 __ovld lgamma_r(float3, __private int3 *); +float4 __ovld lgamma_r(float4, __private int4 *); +float8 __ovld lgamma_r(float8, __private int8 *); +float16 __ovld lgamma_r(float16, __private int16 *); +#ifdef cl_khr_fp64 +double __ovld lgamma_r(double, __global int *); +double2 __ovld lgamma_r(double2, __global int2 *); +double3 __ovld lgamma_r(double3, __global int3 *); +double4 __ovld lgamma_r(double4, __global int4 *); +double8 __ovld lgamma_r(double8, __global int8 *); +double16 __ovld lgamma_r(double16, __global int16 *); +double __ovld lgamma_r(double, __local int *); +double2 __ovld lgamma_r(double2, __local int2 *); +double3 __ovld lgamma_r(double3, __local int3 *); +double4 __ovld lgamma_r(double4, __local int4 *); +double8 __ovld lgamma_r(double8, __local int8 *); +double16 __ovld lgamma_r(double16, __local int16 *); +double __ovld lgamma_r(double, __private int *); +double2 __ovld lgamma_r(double2, __private int2 *); +double3 __ovld lgamma_r(double3, __private int3 *); +double4 __ovld lgamma_r(double4, __private int4 *); +double8 __ovld lgamma_r(double8, __private int8 *); +double16 __ovld lgamma_r(double16, __private int16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld lgamma_r(half, __global int *); +half2 __ovld lgamma_r(half2, __global int2 *); +half3 __ovld lgamma_r(half3, __global int3 *); +half4 __ovld lgamma_r(half4, __global int4 *); +half8 __ovld lgamma_r(half8, __global int8 *); +half16 __ovld lgamma_r(half16, __global int16 *); +half __ovld lgamma_r(half, __local int *); +half2 __ovld lgamma_r(half2, __local int2 *); +half3 __ovld lgamma_r(half3, __local int3 *); +half4 __ovld lgamma_r(half4, __local int4 *); +half8 __ovld lgamma_r(half8, __local int8 *); +half16 __ovld lgamma_r(half16, __local int16 *); +half __ovld lgamma_r(half, __private int *); +half2 __ovld lgamma_r(half2, __private int2 *); +half3 __ovld lgamma_r(half3, __private int3 *); +half4 __ovld lgamma_r(half4, __private int4 *); +half8 __ovld lgamma_r(half8, __private int8 *); +half16 __ovld lgamma_r(half16, __private int16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Compute natural logarithm. + */ +float __ovld __cnfn log(float); +float2 __ovld __cnfn log(float2); +float3 __ovld __cnfn log(float3); +float4 __ovld __cnfn log(float4); +float8 __ovld __cnfn log(float8); +float16 __ovld __cnfn log(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn log(double); +double2 __ovld __cnfn log(double2); +double3 __ovld __cnfn log(double3); +double4 __ovld __cnfn log(double4); +double8 __ovld __cnfn log(double8); +double16 __ovld __cnfn log(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn log(half); +half2 __ovld __cnfn log(half2); +half3 __ovld __cnfn log(half3); +half4 __ovld __cnfn log(half4); +half8 __ovld __cnfn log(half8); +half16 __ovld __cnfn log(half16); +#endif //cl_khr_fp16 + +/** + * Compute a base 2 logarithm. + */ +float __ovld __cnfn log2(float); +float2 __ovld __cnfn log2(float2); +float3 __ovld __cnfn log2(float3); +float4 __ovld __cnfn log2(float4); +float8 __ovld __cnfn log2(float8); +float16 __ovld __cnfn log2(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn log2(double); +double2 __ovld __cnfn log2(double2); +double3 __ovld __cnfn log2(double3); +double4 __ovld __cnfn log2(double4); +double8 __ovld __cnfn log2(double8); +double16 __ovld __cnfn log2(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn log2(half); +half2 __ovld __cnfn log2(half2); +half3 __ovld __cnfn log2(half3); +half4 __ovld __cnfn log2(half4); +half8 __ovld __cnfn log2(half8); +half16 __ovld __cnfn log2(half16); +#endif //cl_khr_fp16 + +/** + * Compute a base 10 logarithm. + */ +float __ovld __cnfn log10(float); +float2 __ovld __cnfn log10(float2); +float3 __ovld __cnfn log10(float3); +float4 __ovld __cnfn log10(float4); +float8 __ovld __cnfn log10(float8); +float16 __ovld __cnfn log10(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn log10(double); +double2 __ovld __cnfn log10(double2); +double3 __ovld __cnfn log10(double3); +double4 __ovld __cnfn log10(double4); +double8 __ovld __cnfn log10(double8); +double16 __ovld __cnfn log10(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn log10(half); +half2 __ovld __cnfn log10(half2); +half3 __ovld __cnfn log10(half3); +half4 __ovld __cnfn log10(half4); +half8 __ovld __cnfn log10(half8); +half16 __ovld __cnfn log10(half16); +#endif //cl_khr_fp16 + +/** + * Compute a base e logarithm of (1.0 + x). + */ +float __ovld __cnfn log1p(float); +float2 __ovld __cnfn log1p(float2); +float3 __ovld __cnfn log1p(float3); +float4 __ovld __cnfn log1p(float4); +float8 __ovld __cnfn log1p(float8); +float16 __ovld __cnfn log1p(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn log1p(double); +double2 __ovld __cnfn log1p(double2); +double3 __ovld __cnfn log1p(double3); +double4 __ovld __cnfn log1p(double4); +double8 __ovld __cnfn log1p(double8); +double16 __ovld __cnfn log1p(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn log1p(half); +half2 __ovld __cnfn log1p(half2); +half3 __ovld __cnfn log1p(half3); +half4 __ovld __cnfn log1p(half4); +half8 __ovld __cnfn log1p(half8); +half16 __ovld __cnfn log1p(half16); +#endif //cl_khr_fp16 + +/** + * Compute the exponent of x, which is the integral + * part of logr | x |. + */ +float __ovld __cnfn logb(float); +float2 __ovld __cnfn logb(float2); +float3 __ovld __cnfn logb(float3); +float4 __ovld __cnfn logb(float4); +float8 __ovld __cnfn logb(float8); +float16 __ovld __cnfn logb(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn logb(double); +double2 __ovld __cnfn logb(double2); +double3 __ovld __cnfn logb(double3); +double4 __ovld __cnfn logb(double4); +double8 __ovld __cnfn logb(double8); +double16 __ovld __cnfn logb(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn logb(half); +half2 __ovld __cnfn logb(half2); +half3 __ovld __cnfn logb(half3); +half4 __ovld __cnfn logb(half4); +half8 __ovld __cnfn logb(half8); +half16 __ovld __cnfn logb(half16); +#endif //cl_khr_fp16 + +/** + * mad approximates a * b + c. Whether or how the + * product of a * b is rounded and how supernormal or + * subnormal intermediate products are handled is not + * defined. mad is intended to be used where speed is + * preferred over accuracy. + */ +float __ovld __cnfn mad(float, float, float); +float2 __ovld __cnfn mad(float2, float2, float2); +float3 __ovld __cnfn mad(float3, float3, float3); +float4 __ovld __cnfn mad(float4, float4, float4); +float8 __ovld __cnfn mad(float8, float8, float8); +float16 __ovld __cnfn mad(float16, float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn mad(double, double, double); +double2 __ovld __cnfn mad(double2, double2, double2); +double3 __ovld __cnfn mad(double3, double3, double3); +double4 __ovld __cnfn mad(double4, double4, double4); +double8 __ovld __cnfn mad(double8, double8, double8); +double16 __ovld __cnfn mad(double16, double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn mad(half, half, half); +half2 __ovld __cnfn mad(half2, half2, half2); +half3 __ovld __cnfn mad(half3, half3, half3); +half4 __ovld __cnfn mad(half4, half4, half4); +half8 __ovld __cnfn mad(half8, half8, half8); +half16 __ovld __cnfn mad(half16, half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns x if | x | > | y |, y if | y | > | x |, otherwise + * fmax(x, y). + */ +float __ovld __cnfn maxmag(float, float); +float2 __ovld __cnfn maxmag(float2, float2); +float3 __ovld __cnfn maxmag(float3, float3); +float4 __ovld __cnfn maxmag(float4, float4); +float8 __ovld __cnfn maxmag(float8, float8); +float16 __ovld __cnfn maxmag(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn maxmag(double, double); +double2 __ovld __cnfn maxmag(double2, double2); +double3 __ovld __cnfn maxmag(double3, double3); +double4 __ovld __cnfn maxmag(double4, double4); +double8 __ovld __cnfn maxmag(double8, double8); +double16 __ovld __cnfn maxmag(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn maxmag(half, half); +half2 __ovld __cnfn maxmag(half2, half2); +half3 __ovld __cnfn maxmag(half3, half3); +half4 __ovld __cnfn maxmag(half4, half4); +half8 __ovld __cnfn maxmag(half8, half8); +half16 __ovld __cnfn maxmag(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns x if | x | < | y |, y if | y | < | x |, otherwise + * fmin(x, y). + */ +float __ovld __cnfn minmag(float, float); +float2 __ovld __cnfn minmag(float2, float2); +float3 __ovld __cnfn minmag(float3, float3); +float4 __ovld __cnfn minmag(float4, float4); +float8 __ovld __cnfn minmag(float8, float8); +float16 __ovld __cnfn minmag(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn minmag(double, double); +double2 __ovld __cnfn minmag(double2, double2); +double3 __ovld __cnfn minmag(double3, double3); +double4 __ovld __cnfn minmag(double4, double4); +double8 __ovld __cnfn minmag(double8, double8); +double16 __ovld __cnfn minmag(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn minmag(half, half); +half2 __ovld __cnfn minmag(half2, half2); +half3 __ovld __cnfn minmag(half3, half3); +half4 __ovld __cnfn minmag(half4, half4); +half8 __ovld __cnfn minmag(half8, half8); +half16 __ovld __cnfn minmag(half16, half16); +#endif //cl_khr_fp16 + +/** + * Decompose a floating-point number. The modf + * function breaks the argument x into integral and + * fractional parts, each of which has the same sign as + * the argument. It stores the integral part in the object + * pointed to by iptr. + */ +#if defined(__opencl_c_generic_address_space) +float __ovld modf(float, float *); +float2 __ovld modf(float2, float2 *); +float3 __ovld modf(float3, float3 *); +float4 __ovld modf(float4, float4 *); +float8 __ovld modf(float8, float8 *); +float16 __ovld modf(float16, float16 *); +#ifdef cl_khr_fp64 +double __ovld modf(double, double *); +double2 __ovld modf(double2, double2 *); +double3 __ovld modf(double3, double3 *); +double4 __ovld modf(double4, double4 *); +double8 __ovld modf(double8, double8 *); +double16 __ovld modf(double16, double16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld modf(half, half *); +half2 __ovld modf(half2, half2 *); +half3 __ovld modf(half3, half3 *); +half4 __ovld modf(half4, half4 *); +half8 __ovld modf(half8, half8 *); +half16 __ovld modf(half16, half16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld modf(float, __global float *); +float2 __ovld modf(float2, __global float2 *); +float3 __ovld modf(float3, __global float3 *); +float4 __ovld modf(float4, __global float4 *); +float8 __ovld modf(float8, __global float8 *); +float16 __ovld modf(float16, __global float16 *); +float __ovld modf(float, __local float *); +float2 __ovld modf(float2, __local float2 *); +float3 __ovld modf(float3, __local float3 *); +float4 __ovld modf(float4, __local float4 *); +float8 __ovld modf(float8, __local float8 *); +float16 __ovld modf(float16, __local float16 *); +float __ovld modf(float, __private float *); +float2 __ovld modf(float2, __private float2 *); +float3 __ovld modf(float3, __private float3 *); +float4 __ovld modf(float4, __private float4 *); +float8 __ovld modf(float8, __private float8 *); +float16 __ovld modf(float16, __private float16 *); +#ifdef cl_khr_fp64 +double __ovld modf(double, __global double *); +double2 __ovld modf(double2, __global double2 *); +double3 __ovld modf(double3, __global double3 *); +double4 __ovld modf(double4, __global double4 *); +double8 __ovld modf(double8, __global double8 *); +double16 __ovld modf(double16, __global double16 *); +double __ovld modf(double, __local double *); +double2 __ovld modf(double2, __local double2 *); +double3 __ovld modf(double3, __local double3 *); +double4 __ovld modf(double4, __local double4 *); +double8 __ovld modf(double8, __local double8 *); +double16 __ovld modf(double16, __local double16 *); +double __ovld modf(double, __private double *); +double2 __ovld modf(double2, __private double2 *); +double3 __ovld modf(double3, __private double3 *); +double4 __ovld modf(double4, __private double4 *); +double8 __ovld modf(double8, __private double8 *); +double16 __ovld modf(double16, __private double16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld modf(half, __global half *); +half2 __ovld modf(half2, __global half2 *); +half3 __ovld modf(half3, __global half3 *); +half4 __ovld modf(half4, __global half4 *); +half8 __ovld modf(half8, __global half8 *); +half16 __ovld modf(half16, __global half16 *); +half __ovld modf(half, __local half *); +half2 __ovld modf(half2, __local half2 *); +half3 __ovld modf(half3, __local half3 *); +half4 __ovld modf(half4, __local half4 *); +half8 __ovld modf(half8, __local half8 *); +half16 __ovld modf(half16, __local half16 *); +half __ovld modf(half, __private half *); +half2 __ovld modf(half2, __private half2 *); +half3 __ovld modf(half3, __private half3 *); +half4 __ovld modf(half4, __private half4 *); +half8 __ovld modf(half8, __private half8 *); +half16 __ovld modf(half16, __private half16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Returns a quiet NaN. The nancode may be placed + * in the significand of the resulting NaN. + */ +float __ovld __cnfn nan(uint); +float2 __ovld __cnfn nan(uint2); +float3 __ovld __cnfn nan(uint3); +float4 __ovld __cnfn nan(uint4); +float8 __ovld __cnfn nan(uint8); +float16 __ovld __cnfn nan(uint16); +#ifdef cl_khr_fp64 +double __ovld __cnfn nan(ulong); +double2 __ovld __cnfn nan(ulong2); +double3 __ovld __cnfn nan(ulong3); +double4 __ovld __cnfn nan(ulong4); +double8 __ovld __cnfn nan(ulong8); +double16 __ovld __cnfn nan(ulong16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn nan(ushort); +half2 __ovld __cnfn nan(ushort2); +half3 __ovld __cnfn nan(ushort3); +half4 __ovld __cnfn nan(ushort4); +half8 __ovld __cnfn nan(ushort8); +half16 __ovld __cnfn nan(ushort16); +#endif //cl_khr_fp16 + +/** + * Computes the next representable single-precision + * floating-point value following x in the direction of + * y. Thus, if y is less than x, nextafter() returns the + * largest representable floating-point number less + * than x. + */ +float __ovld __cnfn nextafter(float, float); +float2 __ovld __cnfn nextafter(float2, float2); +float3 __ovld __cnfn nextafter(float3, float3); +float4 __ovld __cnfn nextafter(float4, float4); +float8 __ovld __cnfn nextafter(float8, float8); +float16 __ovld __cnfn nextafter(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn nextafter(double, double); +double2 __ovld __cnfn nextafter(double2, double2); +double3 __ovld __cnfn nextafter(double3, double3); +double4 __ovld __cnfn nextafter(double4, double4); +double8 __ovld __cnfn nextafter(double8, double8); +double16 __ovld __cnfn nextafter(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn nextafter(half, half); +half2 __ovld __cnfn nextafter(half2, half2); +half3 __ovld __cnfn nextafter(half3, half3); +half4 __ovld __cnfn nextafter(half4, half4); +half8 __ovld __cnfn nextafter(half8, half8); +half16 __ovld __cnfn nextafter(half16, half16); +#endif //cl_khr_fp16 + +/** + * Compute x to the power y. + */ +float __ovld __cnfn pow(float, float); +float2 __ovld __cnfn pow(float2, float2); +float3 __ovld __cnfn pow(float3, float3); +float4 __ovld __cnfn pow(float4, float4); +float8 __ovld __cnfn pow(float8, float8); +float16 __ovld __cnfn pow(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn pow(double, double); +double2 __ovld __cnfn pow(double2, double2); +double3 __ovld __cnfn pow(double3, double3); +double4 __ovld __cnfn pow(double4, double4); +double8 __ovld __cnfn pow(double8, double8); +double16 __ovld __cnfn pow(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn pow(half, half); +half2 __ovld __cnfn pow(half2, half2); +half3 __ovld __cnfn pow(half3, half3); +half4 __ovld __cnfn pow(half4, half4); +half8 __ovld __cnfn pow(half8, half8); +half16 __ovld __cnfn pow(half16, half16); +#endif //cl_khr_fp16 + +/** + * Compute x to the power y, where y is an integer. + */ +float __ovld __cnfn pown(float, int); +float2 __ovld __cnfn pown(float2, int2); +float3 __ovld __cnfn pown(float3, int3); +float4 __ovld __cnfn pown(float4, int4); +float8 __ovld __cnfn pown(float8, int8); +float16 __ovld __cnfn pown(float16, int16); +#ifdef cl_khr_fp64 +double __ovld __cnfn pown(double, int); +double2 __ovld __cnfn pown(double2, int2); +double3 __ovld __cnfn pown(double3, int3); +double4 __ovld __cnfn pown(double4, int4); +double8 __ovld __cnfn pown(double8, int8); +double16 __ovld __cnfn pown(double16, int16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn pown(half, int); +half2 __ovld __cnfn pown(half2, int2); +half3 __ovld __cnfn pown(half3, int3); +half4 __ovld __cnfn pown(half4, int4); +half8 __ovld __cnfn pown(half8, int8); +half16 __ovld __cnfn pown(half16, int16); +#endif //cl_khr_fp16 + +/** + * Compute x to the power y, where x is >= 0. + */ +float __ovld __cnfn powr(float, float); +float2 __ovld __cnfn powr(float2, float2); +float3 __ovld __cnfn powr(float3, float3); +float4 __ovld __cnfn powr(float4, float4); +float8 __ovld __cnfn powr(float8, float8); +float16 __ovld __cnfn powr(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn powr(double, double); +double2 __ovld __cnfn powr(double2, double2); +double3 __ovld __cnfn powr(double3, double3); +double4 __ovld __cnfn powr(double4, double4); +double8 __ovld __cnfn powr(double8, double8); +double16 __ovld __cnfn powr(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn powr(half, half); +half2 __ovld __cnfn powr(half2, half2); +half3 __ovld __cnfn powr(half3, half3); +half4 __ovld __cnfn powr(half4, half4); +half8 __ovld __cnfn powr(half8, half8); +half16 __ovld __cnfn powr(half16, half16); +#endif //cl_khr_fp16 + +/** + * Compute the value r such that r = x - n*y, where n + * is the integer nearest the exact value of x/y. If there + * are two integers closest to x/y, n shall be the even + * one. If r is zero, it is given the same sign as x. + */ +float __ovld __cnfn remainder(float, float); +float2 __ovld __cnfn remainder(float2, float2); +float3 __ovld __cnfn remainder(float3, float3); +float4 __ovld __cnfn remainder(float4, float4); +float8 __ovld __cnfn remainder(float8, float8); +float16 __ovld __cnfn remainder(float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn remainder(double, double); +double2 __ovld __cnfn remainder(double2, double2); +double3 __ovld __cnfn remainder(double3, double3); +double4 __ovld __cnfn remainder(double4, double4); +double8 __ovld __cnfn remainder(double8, double8); +double16 __ovld __cnfn remainder(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn remainder(half, half); +half2 __ovld __cnfn remainder(half2, half2); +half3 __ovld __cnfn remainder(half3, half3); +half4 __ovld __cnfn remainder(half4, half4); +half8 __ovld __cnfn remainder(half8, half8); +half16 __ovld __cnfn remainder(half16, half16); +#endif //cl_khr_fp16 + +/** + * The remquo function computes the value r such + * that r = x - n*y, where n is the integer nearest the + * exact value of x/y. If there are two integers closest + * to x/y, n shall be the even one. If r is zero, it is + * given the same sign as x. This is the same value + * that is returned by the remainder function. + * remquo also calculates the lower seven bits of the + * integral quotient x/y, and gives that value the same + * sign as x/y. It stores this signed value in the object + * pointed to by quo. + */ +#if defined(__opencl_c_generic_address_space) +float __ovld remquo(float, float, int *); +float2 __ovld remquo(float2, float2, int2 *); +float3 __ovld remquo(float3, float3, int3 *); +float4 __ovld remquo(float4, float4, int4 *); +float8 __ovld remquo(float8, float8, int8 *); +float16 __ovld remquo(float16, float16, int16 *); +#ifdef cl_khr_fp64 +double __ovld remquo(double, double, int *); +double2 __ovld remquo(double2, double2, int2 *); +double3 __ovld remquo(double3, double3, int3 *); +double4 __ovld remquo(double4, double4, int4 *); +double8 __ovld remquo(double8, double8, int8 *); +double16 __ovld remquo(double16, double16, int16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld remquo(half, half, int *); +half2 __ovld remquo(half2, half2, int2 *); +half3 __ovld remquo(half3, half3, int3 *); +half4 __ovld remquo(half4, half4, int4 *); +half8 __ovld remquo(half8, half8, int8 *); +half16 __ovld remquo(half16, half16, int16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld remquo(float, float, __global int *); +float2 __ovld remquo(float2, float2, __global int2 *); +float3 __ovld remquo(float3, float3, __global int3 *); +float4 __ovld remquo(float4, float4, __global int4 *); +float8 __ovld remquo(float8, float8, __global int8 *); +float16 __ovld remquo(float16, float16, __global int16 *); +float __ovld remquo(float, float, __local int *); +float2 __ovld remquo(float2, float2, __local int2 *); +float3 __ovld remquo(float3, float3, __local int3 *); +float4 __ovld remquo(float4, float4, __local int4 *); +float8 __ovld remquo(float8, float8, __local int8 *); +float16 __ovld remquo(float16, float16, __local int16 *); +float __ovld remquo(float, float, __private int *); +float2 __ovld remquo(float2, float2, __private int2 *); +float3 __ovld remquo(float3, float3, __private int3 *); +float4 __ovld remquo(float4, float4, __private int4 *); +float8 __ovld remquo(float8, float8, __private int8 *); +float16 __ovld remquo(float16, float16, __private int16 *); +#ifdef cl_khr_fp64 +double __ovld remquo(double, double, __global int *); +double2 __ovld remquo(double2, double2, __global int2 *); +double3 __ovld remquo(double3, double3, __global int3 *); +double4 __ovld remquo(double4, double4, __global int4 *); +double8 __ovld remquo(double8, double8, __global int8 *); +double16 __ovld remquo(double16, double16, __global int16 *); +double __ovld remquo(double, double, __local int *); +double2 __ovld remquo(double2, double2, __local int2 *); +double3 __ovld remquo(double3, double3, __local int3 *); +double4 __ovld remquo(double4, double4, __local int4 *); +double8 __ovld remquo(double8, double8, __local int8 *); +double16 __ovld remquo(double16, double16, __local int16 *); +double __ovld remquo(double, double, __private int *); +double2 __ovld remquo(double2, double2, __private int2 *); +double3 __ovld remquo(double3, double3, __private int3 *); +double4 __ovld remquo(double4, double4, __private int4 *); +double8 __ovld remquo(double8, double8, __private int8 *); +double16 __ovld remquo(double16, double16, __private int16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld remquo(half, half, __global int *); +half2 __ovld remquo(half2, half2, __global int2 *); +half3 __ovld remquo(half3, half3, __global int3 *); +half4 __ovld remquo(half4, half4, __global int4 *); +half8 __ovld remquo(half8, half8, __global int8 *); +half16 __ovld remquo(half16, half16, __global int16 *); +half __ovld remquo(half, half, __local int *); +half2 __ovld remquo(half2, half2, __local int2 *); +half3 __ovld remquo(half3, half3, __local int3 *); +half4 __ovld remquo(half4, half4, __local int4 *); +half8 __ovld remquo(half8, half8, __local int8 *); +half16 __ovld remquo(half16, half16, __local int16 *); +half __ovld remquo(half, half, __private int *); +half2 __ovld remquo(half2, half2, __private int2 *); +half3 __ovld remquo(half3, half3, __private int3 *); +half4 __ovld remquo(half4, half4, __private int4 *); +half8 __ovld remquo(half8, half8, __private int8 *); +half16 __ovld remquo(half16, half16, __private int16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) +/** + * Round to integral value (using round to nearest + * even rounding mode) in floating-point format. + * Refer to section 7.1 for description of rounding + * modes. + */ +float __ovld __cnfn rint(float); +float2 __ovld __cnfn rint(float2); +float3 __ovld __cnfn rint(float3); +float4 __ovld __cnfn rint(float4); +float8 __ovld __cnfn rint(float8); +float16 __ovld __cnfn rint(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn rint(double); +double2 __ovld __cnfn rint(double2); +double3 __ovld __cnfn rint(double3); +double4 __ovld __cnfn rint(double4); +double8 __ovld __cnfn rint(double8); +double16 __ovld __cnfn rint(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn rint(half); +half2 __ovld __cnfn rint(half2); +half3 __ovld __cnfn rint(half3); +half4 __ovld __cnfn rint(half4); +half8 __ovld __cnfn rint(half8); +half16 __ovld __cnfn rint(half16); +#endif //cl_khr_fp16 + +/** + * Compute x to the power 1/y. + */ +float __ovld __cnfn rootn(float, int); +float2 __ovld __cnfn rootn(float2, int2); +float3 __ovld __cnfn rootn(float3, int3); +float4 __ovld __cnfn rootn(float4, int4); +float8 __ovld __cnfn rootn(float8, int8); +float16 __ovld __cnfn rootn(float16, int16); +#ifdef cl_khr_fp64 +double __ovld __cnfn rootn(double, int); +double2 __ovld __cnfn rootn(double2, int2); +double3 __ovld __cnfn rootn(double3, int3); +double4 __ovld __cnfn rootn(double4, int4); +double8 __ovld __cnfn rootn(double8, int8); +double16 __ovld __cnfn rootn(double16, int16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn rootn(half, int); +half2 __ovld __cnfn rootn(half2, int2); +half3 __ovld __cnfn rootn(half3, int3); +half4 __ovld __cnfn rootn(half4, int4); +half8 __ovld __cnfn rootn(half8, int8); +half16 __ovld __cnfn rootn(half16, int16); +#endif //cl_khr_fp16 + +/** + * Return the integral value nearest to x rounding + * halfway cases away from zero, regardless of the + * current rounding direction. + */ +float __ovld __cnfn round(float); +float2 __ovld __cnfn round(float2); +float3 __ovld __cnfn round(float3); +float4 __ovld __cnfn round(float4); +float8 __ovld __cnfn round(float8); +float16 __ovld __cnfn round(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn round(double); +double2 __ovld __cnfn round(double2); +double3 __ovld __cnfn round(double3); +double4 __ovld __cnfn round(double4); +double8 __ovld __cnfn round(double8); +double16 __ovld __cnfn round(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn round(half); +half2 __ovld __cnfn round(half2); +half3 __ovld __cnfn round(half3); +half4 __ovld __cnfn round(half4); +half8 __ovld __cnfn round(half8); +half16 __ovld __cnfn round(half16); +#endif //cl_khr_fp16 + +/** + * Compute inverse square root. + */ +float __ovld __cnfn rsqrt(float); +float2 __ovld __cnfn rsqrt(float2); +float3 __ovld __cnfn rsqrt(float3); +float4 __ovld __cnfn rsqrt(float4); +float8 __ovld __cnfn rsqrt(float8); +float16 __ovld __cnfn rsqrt(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn rsqrt(double); +double2 __ovld __cnfn rsqrt(double2); +double3 __ovld __cnfn rsqrt(double3); +double4 __ovld __cnfn rsqrt(double4); +double8 __ovld __cnfn rsqrt(double8); +double16 __ovld __cnfn rsqrt(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn rsqrt(half); +half2 __ovld __cnfn rsqrt(half2); +half3 __ovld __cnfn rsqrt(half3); +half4 __ovld __cnfn rsqrt(half4); +half8 __ovld __cnfn rsqrt(half8); +half16 __ovld __cnfn rsqrt(half16); +#endif //cl_khr_fp16 + +/** + * Compute sine. + */ +float __ovld __cnfn sin(float); +float2 __ovld __cnfn sin(float2); +float3 __ovld __cnfn sin(float3); +float4 __ovld __cnfn sin(float4); +float8 __ovld __cnfn sin(float8); +float16 __ovld __cnfn sin(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn sin(double); +double2 __ovld __cnfn sin(double2); +double3 __ovld __cnfn sin(double3); +double4 __ovld __cnfn sin(double4); +double8 __ovld __cnfn sin(double8); +double16 __ovld __cnfn sin(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn sin(half); +half2 __ovld __cnfn sin(half2); +half3 __ovld __cnfn sin(half3); +half4 __ovld __cnfn sin(half4); +half8 __ovld __cnfn sin(half8); +half16 __ovld __cnfn sin(half16); +#endif //cl_khr_fp16 + +/** + * Compute sine and cosine of x. The computed sine + * is the return value and computed cosine is returned + * in cosval. + */ +#if defined(__opencl_c_generic_address_space) +float __ovld sincos(float, float *); +float2 __ovld sincos(float2, float2 *); +float3 __ovld sincos(float3, float3 *); +float4 __ovld sincos(float4, float4 *); +float8 __ovld sincos(float8, float8 *); +float16 __ovld sincos(float16, float16 *); +#ifdef cl_khr_fp64 +double __ovld sincos(double, double *); +double2 __ovld sincos(double2, double2 *); +double3 __ovld sincos(double3, double3 *); +double4 __ovld sincos(double4, double4 *); +double8 __ovld sincos(double8, double8 *); +double16 __ovld sincos(double16, double16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld sincos(half, half *); +half2 __ovld sincos(half2, half2 *); +half3 __ovld sincos(half3, half3 *); +half4 __ovld sincos(half4, half4 *); +half8 __ovld sincos(half8, half8 *); +half16 __ovld sincos(half16, half16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld sincos(float, __global float *); +float2 __ovld sincos(float2, __global float2 *); +float3 __ovld sincos(float3, __global float3 *); +float4 __ovld sincos(float4, __global float4 *); +float8 __ovld sincos(float8, __global float8 *); +float16 __ovld sincos(float16, __global float16 *); +float __ovld sincos(float, __local float *); +float2 __ovld sincos(float2, __local float2 *); +float3 __ovld sincos(float3, __local float3 *); +float4 __ovld sincos(float4, __local float4 *); +float8 __ovld sincos(float8, __local float8 *); +float16 __ovld sincos(float16, __local float16 *); +float __ovld sincos(float, __private float *); +float2 __ovld sincos(float2, __private float2 *); +float3 __ovld sincos(float3, __private float3 *); +float4 __ovld sincos(float4, __private float4 *); +float8 __ovld sincos(float8, __private float8 *); +float16 __ovld sincos(float16, __private float16 *); +#ifdef cl_khr_fp64 +double __ovld sincos(double, __global double *); +double2 __ovld sincos(double2, __global double2 *); +double3 __ovld sincos(double3, __global double3 *); +double4 __ovld sincos(double4, __global double4 *); +double8 __ovld sincos(double8, __global double8 *); +double16 __ovld sincos(double16, __global double16 *); +double __ovld sincos(double, __local double *); +double2 __ovld sincos(double2, __local double2 *); +double3 __ovld sincos(double3, __local double3 *); +double4 __ovld sincos(double4, __local double4 *); +double8 __ovld sincos(double8, __local double8 *); +double16 __ovld sincos(double16, __local double16 *); +double __ovld sincos(double, __private double *); +double2 __ovld sincos(double2, __private double2 *); +double3 __ovld sincos(double3, __private double3 *); +double4 __ovld sincos(double4, __private double4 *); +double8 __ovld sincos(double8, __private double8 *); +double16 __ovld sincos(double16, __private double16 *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld sincos(half, __global half *); +half2 __ovld sincos(half2, __global half2 *); +half3 __ovld sincos(half3, __global half3 *); +half4 __ovld sincos(half4, __global half4 *); +half8 __ovld sincos(half8, __global half8 *); +half16 __ovld sincos(half16, __global half16 *); +half __ovld sincos(half, __local half *); +half2 __ovld sincos(half2, __local half2 *); +half3 __ovld sincos(half3, __local half3 *); +half4 __ovld sincos(half4, __local half4 *); +half8 __ovld sincos(half8, __local half8 *); +half16 __ovld sincos(half16, __local half16 *); +half __ovld sincos(half, __private half *); +half2 __ovld sincos(half2, __private half2 *); +half3 __ovld sincos(half3, __private half3 *); +half4 __ovld sincos(half4, __private half4 *); +half8 __ovld sincos(half8, __private half8 *); +half16 __ovld sincos(half16, __private half16 *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Compute hyperbolic sine. + */ +float __ovld __cnfn sinh(float); +float2 __ovld __cnfn sinh(float2); +float3 __ovld __cnfn sinh(float3); +float4 __ovld __cnfn sinh(float4); +float8 __ovld __cnfn sinh(float8); +float16 __ovld __cnfn sinh(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn sinh(double); +double2 __ovld __cnfn sinh(double2); +double3 __ovld __cnfn sinh(double3); +double4 __ovld __cnfn sinh(double4); +double8 __ovld __cnfn sinh(double8); +double16 __ovld __cnfn sinh(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn sinh(half); +half2 __ovld __cnfn sinh(half2); +half3 __ovld __cnfn sinh(half3); +half4 __ovld __cnfn sinh(half4); +half8 __ovld __cnfn sinh(half8); +half16 __ovld __cnfn sinh(half16); +#endif //cl_khr_fp16 + +/** + * Compute sin (PI * x). + */ +float __ovld __cnfn sinpi(float); +float2 __ovld __cnfn sinpi(float2); +float3 __ovld __cnfn sinpi(float3); +float4 __ovld __cnfn sinpi(float4); +float8 __ovld __cnfn sinpi(float8); +float16 __ovld __cnfn sinpi(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn sinpi(double); +double2 __ovld __cnfn sinpi(double2); +double3 __ovld __cnfn sinpi(double3); +double4 __ovld __cnfn sinpi(double4); +double8 __ovld __cnfn sinpi(double8); +double16 __ovld __cnfn sinpi(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn sinpi(half); +half2 __ovld __cnfn sinpi(half2); +half3 __ovld __cnfn sinpi(half3); +half4 __ovld __cnfn sinpi(half4); +half8 __ovld __cnfn sinpi(half8); +half16 __ovld __cnfn sinpi(half16); +#endif //cl_khr_fp16 + +/** + * Compute square root. + */ +float __ovld __cnfn sqrt(float); +float2 __ovld __cnfn sqrt(float2); +float3 __ovld __cnfn sqrt(float3); +float4 __ovld __cnfn sqrt(float4); +float8 __ovld __cnfn sqrt(float8); +float16 __ovld __cnfn sqrt(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn sqrt(double); +double2 __ovld __cnfn sqrt(double2); +double3 __ovld __cnfn sqrt(double3); +double4 __ovld __cnfn sqrt(double4); +double8 __ovld __cnfn sqrt(double8); +double16 __ovld __cnfn sqrt(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn sqrt(half); +half2 __ovld __cnfn sqrt(half2); +half3 __ovld __cnfn sqrt(half3); +half4 __ovld __cnfn sqrt(half4); +half8 __ovld __cnfn sqrt(half8); +half16 __ovld __cnfn sqrt(half16); +#endif //cl_khr_fp16 + +/** + * Compute tangent. + */ +float __ovld __cnfn tan(float); +float2 __ovld __cnfn tan(float2); +float3 __ovld __cnfn tan(float3); +float4 __ovld __cnfn tan(float4); +float8 __ovld __cnfn tan(float8); +float16 __ovld __cnfn tan(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn tan(double); +double2 __ovld __cnfn tan(double2); +double3 __ovld __cnfn tan(double3); +double4 __ovld __cnfn tan(double4); +double8 __ovld __cnfn tan(double8); +double16 __ovld __cnfn tan(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn tan(half); +half2 __ovld __cnfn tan(half2); +half3 __ovld __cnfn tan(half3); +half4 __ovld __cnfn tan(half4); +half8 __ovld __cnfn tan(half8); +half16 __ovld __cnfn tan(half16); +#endif //cl_khr_fp16 + +/** + * Compute hyperbolic tangent. + */ +float __ovld __cnfn tanh(float); +float2 __ovld __cnfn tanh(float2); +float3 __ovld __cnfn tanh(float3); +float4 __ovld __cnfn tanh(float4); +float8 __ovld __cnfn tanh(float8); +float16 __ovld __cnfn tanh(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn tanh(double); +double2 __ovld __cnfn tanh(double2); +double3 __ovld __cnfn tanh(double3); +double4 __ovld __cnfn tanh(double4); +double8 __ovld __cnfn tanh(double8); +double16 __ovld __cnfn tanh(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn tanh(half); +half2 __ovld __cnfn tanh(half2); +half3 __ovld __cnfn tanh(half3); +half4 __ovld __cnfn tanh(half4); +half8 __ovld __cnfn tanh(half8); +half16 __ovld __cnfn tanh(half16); +#endif //cl_khr_fp16 + +/** + * Compute tan (PI * x). + */ +float __ovld __cnfn tanpi(float); +float2 __ovld __cnfn tanpi(float2); +float3 __ovld __cnfn tanpi(float3); +float4 __ovld __cnfn tanpi(float4); +float8 __ovld __cnfn tanpi(float8); +float16 __ovld __cnfn tanpi(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn tanpi(double); +double2 __ovld __cnfn tanpi(double2); +double3 __ovld __cnfn tanpi(double3); +double4 __ovld __cnfn tanpi(double4); +double8 __ovld __cnfn tanpi(double8); +double16 __ovld __cnfn tanpi(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn tanpi(half); +half2 __ovld __cnfn tanpi(half2); +half3 __ovld __cnfn tanpi(half3); +half4 __ovld __cnfn tanpi(half4); +half8 __ovld __cnfn tanpi(half8); +half16 __ovld __cnfn tanpi(half16); +#endif //cl_khr_fp16 + +/** + * Compute the gamma function. + */ +float __ovld __cnfn tgamma(float); +float2 __ovld __cnfn tgamma(float2); +float3 __ovld __cnfn tgamma(float3); +float4 __ovld __cnfn tgamma(float4); +float8 __ovld __cnfn tgamma(float8); +float16 __ovld __cnfn tgamma(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn tgamma(double); +double2 __ovld __cnfn tgamma(double2); +double3 __ovld __cnfn tgamma(double3); +double4 __ovld __cnfn tgamma(double4); +double8 __ovld __cnfn tgamma(double8); +double16 __ovld __cnfn tgamma(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn tgamma(half); +half2 __ovld __cnfn tgamma(half2); +half3 __ovld __cnfn tgamma(half3); +half4 __ovld __cnfn tgamma(half4); +half8 __ovld __cnfn tgamma(half8); +half16 __ovld __cnfn tgamma(half16); +#endif //cl_khr_fp16 + +/** + * Round to integral value using the round to zero + * rounding mode. + */ +float __ovld __cnfn trunc(float); +float2 __ovld __cnfn trunc(float2); +float3 __ovld __cnfn trunc(float3); +float4 __ovld __cnfn trunc(float4); +float8 __ovld __cnfn trunc(float8); +float16 __ovld __cnfn trunc(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn trunc(double); +double2 __ovld __cnfn trunc(double2); +double3 __ovld __cnfn trunc(double3); +double4 __ovld __cnfn trunc(double4); +double8 __ovld __cnfn trunc(double8); +double16 __ovld __cnfn trunc(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn trunc(half); +half2 __ovld __cnfn trunc(half2); +half3 __ovld __cnfn trunc(half3); +half4 __ovld __cnfn trunc(half4); +half8 __ovld __cnfn trunc(half8); +half16 __ovld __cnfn trunc(half16); +#endif //cl_khr_fp16 + +/** + * Compute cosine. x must be in the range -2^16 ... +2^16. + */ +float __ovld __cnfn half_cos(float); +float2 __ovld __cnfn half_cos(float2); +float3 __ovld __cnfn half_cos(float3); +float4 __ovld __cnfn half_cos(float4); +float8 __ovld __cnfn half_cos(float8); +float16 __ovld __cnfn half_cos(float16); + +/** + * Compute x / y. + */ +float __ovld __cnfn half_divide(float, float); +float2 __ovld __cnfn half_divide(float2, float2); +float3 __ovld __cnfn half_divide(float3, float3); +float4 __ovld __cnfn half_divide(float4, float4); +float8 __ovld __cnfn half_divide(float8, float8); +float16 __ovld __cnfn half_divide(float16, float16); + +/** + * Compute the base- e exponential of x. + */ +float __ovld __cnfn half_exp(float); +float2 __ovld __cnfn half_exp(float2); +float3 __ovld __cnfn half_exp(float3); +float4 __ovld __cnfn half_exp(float4); +float8 __ovld __cnfn half_exp(float8); +float16 __ovld __cnfn half_exp(float16); + +/** + * Compute the base- 2 exponential of x. + */ +float __ovld __cnfn half_exp2(float); +float2 __ovld __cnfn half_exp2(float2); +float3 __ovld __cnfn half_exp2(float3); +float4 __ovld __cnfn half_exp2(float4); +float8 __ovld __cnfn half_exp2(float8); +float16 __ovld __cnfn half_exp2(float16); + +/** + * Compute the base- 10 exponential of x. + */ +float __ovld __cnfn half_exp10(float); +float2 __ovld __cnfn half_exp10(float2); +float3 __ovld __cnfn half_exp10(float3); +float4 __ovld __cnfn half_exp10(float4); +float8 __ovld __cnfn half_exp10(float8); +float16 __ovld __cnfn half_exp10(float16); + +/** + * Compute natural logarithm. + */ +float __ovld __cnfn half_log(float); +float2 __ovld __cnfn half_log(float2); +float3 __ovld __cnfn half_log(float3); +float4 __ovld __cnfn half_log(float4); +float8 __ovld __cnfn half_log(float8); +float16 __ovld __cnfn half_log(float16); + +/** + * Compute a base 2 logarithm. + */ +float __ovld __cnfn half_log2(float); +float2 __ovld __cnfn half_log2(float2); +float3 __ovld __cnfn half_log2(float3); +float4 __ovld __cnfn half_log2(float4); +float8 __ovld __cnfn half_log2(float8); +float16 __ovld __cnfn half_log2(float16); + +/** + * Compute a base 10 logarithm. + */ +float __ovld __cnfn half_log10(float); +float2 __ovld __cnfn half_log10(float2); +float3 __ovld __cnfn half_log10(float3); +float4 __ovld __cnfn half_log10(float4); +float8 __ovld __cnfn half_log10(float8); +float16 __ovld __cnfn half_log10(float16); + +/** + * Compute x to the power y, where x is >= 0. + */ +float __ovld __cnfn half_powr(float, float); +float2 __ovld __cnfn half_powr(float2, float2); +float3 __ovld __cnfn half_powr(float3, float3); +float4 __ovld __cnfn half_powr(float4, float4); +float8 __ovld __cnfn half_powr(float8, float8); +float16 __ovld __cnfn half_powr(float16, float16); + +/** + * Compute reciprocal. + */ +float __ovld __cnfn half_recip(float); +float2 __ovld __cnfn half_recip(float2); +float3 __ovld __cnfn half_recip(float3); +float4 __ovld __cnfn half_recip(float4); +float8 __ovld __cnfn half_recip(float8); +float16 __ovld __cnfn half_recip(float16); + +/** + * Compute inverse square root. + */ +float __ovld __cnfn half_rsqrt(float); +float2 __ovld __cnfn half_rsqrt(float2); +float3 __ovld __cnfn half_rsqrt(float3); +float4 __ovld __cnfn half_rsqrt(float4); +float8 __ovld __cnfn half_rsqrt(float8); +float16 __ovld __cnfn half_rsqrt(float16); + +/** + * Compute sine. x must be in the range -2^16 ... +2^16. + */ +float __ovld __cnfn half_sin(float); +float2 __ovld __cnfn half_sin(float2); +float3 __ovld __cnfn half_sin(float3); +float4 __ovld __cnfn half_sin(float4); +float8 __ovld __cnfn half_sin(float8); +float16 __ovld __cnfn half_sin(float16); + +/** + * Compute square root. + */ +float __ovld __cnfn half_sqrt(float); +float2 __ovld __cnfn half_sqrt(float2); +float3 __ovld __cnfn half_sqrt(float3); +float4 __ovld __cnfn half_sqrt(float4); +float8 __ovld __cnfn half_sqrt(float8); +float16 __ovld __cnfn half_sqrt(float16); + +/** + * Compute tangent. x must be in the range -216 ... +216. + */ +float __ovld __cnfn half_tan(float); +float2 __ovld __cnfn half_tan(float2); +float3 __ovld __cnfn half_tan(float3); +float4 __ovld __cnfn half_tan(float4); +float8 __ovld __cnfn half_tan(float8); +float16 __ovld __cnfn half_tan(float16); + +/** + * Compute cosine over an implementation-defined range. + * The maximum error is implementation-defined. + */ +float __ovld __cnfn native_cos(float); +float2 __ovld __cnfn native_cos(float2); +float3 __ovld __cnfn native_cos(float3); +float4 __ovld __cnfn native_cos(float4); +float8 __ovld __cnfn native_cos(float8); +float16 __ovld __cnfn native_cos(float16); + +/** + * Compute x / y over an implementation-defined range. + * The maximum error is implementation-defined. + */ +float __ovld __cnfn native_divide(float, float); +float2 __ovld __cnfn native_divide(float2, float2); +float3 __ovld __cnfn native_divide(float3, float3); +float4 __ovld __cnfn native_divide(float4, float4); +float8 __ovld __cnfn native_divide(float8, float8); +float16 __ovld __cnfn native_divide(float16, float16); + +/** + * Compute the base- e exponential of x over an + * implementation-defined range. The maximum error is + * implementation-defined. + */ +float __ovld __cnfn native_exp(float); +float2 __ovld __cnfn native_exp(float2); +float3 __ovld __cnfn native_exp(float3); +float4 __ovld __cnfn native_exp(float4); +float8 __ovld __cnfn native_exp(float8); +float16 __ovld __cnfn native_exp(float16); + +/** + * Compute the base- 2 exponential of x over an + * implementation-defined range. The maximum error is + * implementation-defined. + */ +float __ovld __cnfn native_exp2(float); +float2 __ovld __cnfn native_exp2(float2); +float3 __ovld __cnfn native_exp2(float3); +float4 __ovld __cnfn native_exp2(float4); +float8 __ovld __cnfn native_exp2(float8); +float16 __ovld __cnfn native_exp2(float16); + +/** + * Compute the base- 10 exponential of x over an + * implementation-defined range. The maximum error is + * implementation-defined. + */ +float __ovld __cnfn native_exp10(float); +float2 __ovld __cnfn native_exp10(float2); +float3 __ovld __cnfn native_exp10(float3); +float4 __ovld __cnfn native_exp10(float4); +float8 __ovld __cnfn native_exp10(float8); +float16 __ovld __cnfn native_exp10(float16); + +/** + * Compute natural logarithm over an implementationdefined + * range. The maximum error is implementation + * defined. + */ +float __ovld __cnfn native_log(float); +float2 __ovld __cnfn native_log(float2); +float3 __ovld __cnfn native_log(float3); +float4 __ovld __cnfn native_log(float4); +float8 __ovld __cnfn native_log(float8); +float16 __ovld __cnfn native_log(float16); + +/** + * Compute a base 2 logarithm over an implementationdefined + * range. The maximum error is implementationdefined. + */ +float __ovld __cnfn native_log2(float); +float2 __ovld __cnfn native_log2(float2); +float3 __ovld __cnfn native_log2(float3); +float4 __ovld __cnfn native_log2(float4); +float8 __ovld __cnfn native_log2(float8); +float16 __ovld __cnfn native_log2(float16); + +/** + * Compute a base 10 logarithm over an implementationdefined + * range. The maximum error is implementationdefined. + */ +float __ovld __cnfn native_log10(float); +float2 __ovld __cnfn native_log10(float2); +float3 __ovld __cnfn native_log10(float3); +float4 __ovld __cnfn native_log10(float4); +float8 __ovld __cnfn native_log10(float8); +float16 __ovld __cnfn native_log10(float16); + +/** + * Compute x to the power y, where x is >= 0. The range of + * x and y are implementation-defined. The maximum error + * is implementation-defined. + */ +float __ovld __cnfn native_powr(float, float); +float2 __ovld __cnfn native_powr(float2, float2); +float3 __ovld __cnfn native_powr(float3, float3); +float4 __ovld __cnfn native_powr(float4, float4); +float8 __ovld __cnfn native_powr(float8, float8); +float16 __ovld __cnfn native_powr(float16, float16); + +/** + * Compute reciprocal over an implementation-defined + * range. The maximum error is implementation-defined. + */ +float __ovld __cnfn native_recip(float); +float2 __ovld __cnfn native_recip(float2); +float3 __ovld __cnfn native_recip(float3); +float4 __ovld __cnfn native_recip(float4); +float8 __ovld __cnfn native_recip(float8); +float16 __ovld __cnfn native_recip(float16); + +/** + * Compute inverse square root over an implementationdefined + * range. The maximum error is implementationdefined. + */ +float __ovld __cnfn native_rsqrt(float); +float2 __ovld __cnfn native_rsqrt(float2); +float3 __ovld __cnfn native_rsqrt(float3); +float4 __ovld __cnfn native_rsqrt(float4); +float8 __ovld __cnfn native_rsqrt(float8); +float16 __ovld __cnfn native_rsqrt(float16); + +/** + * Compute sine over an implementation-defined range. + * The maximum error is implementation-defined. + */ +float __ovld __cnfn native_sin(float); +float2 __ovld __cnfn native_sin(float2); +float3 __ovld __cnfn native_sin(float3); +float4 __ovld __cnfn native_sin(float4); +float8 __ovld __cnfn native_sin(float8); +float16 __ovld __cnfn native_sin(float16); + +/** + * Compute square root over an implementation-defined + * range. The maximum error is implementation-defined. + */ +float __ovld __cnfn native_sqrt(float); +float2 __ovld __cnfn native_sqrt(float2); +float3 __ovld __cnfn native_sqrt(float3); +float4 __ovld __cnfn native_sqrt(float4); +float8 __ovld __cnfn native_sqrt(float8); +float16 __ovld __cnfn native_sqrt(float16); + +/** + * Compute tangent over an implementation-defined range. + * The maximum error is implementation-defined. + */ +float __ovld __cnfn native_tan(float); +float2 __ovld __cnfn native_tan(float2); +float3 __ovld __cnfn native_tan(float3); +float4 __ovld __cnfn native_tan(float4); +float8 __ovld __cnfn native_tan(float8); +float16 __ovld __cnfn native_tan(float16); + +// OpenCL v1.1 s6.11.3, v1.2 s6.12.3, v2.0 s6.13.3 - Integer Functions + +/** + * Returns | x |. + */ +uchar __ovld __cnfn abs(char); +uchar __ovld __cnfn abs(uchar); +uchar2 __ovld __cnfn abs(char2); +uchar2 __ovld __cnfn abs(uchar2); +uchar3 __ovld __cnfn abs(char3); +uchar3 __ovld __cnfn abs(uchar3); +uchar4 __ovld __cnfn abs(char4); +uchar4 __ovld __cnfn abs(uchar4); +uchar8 __ovld __cnfn abs(char8); +uchar8 __ovld __cnfn abs(uchar8); +uchar16 __ovld __cnfn abs(char16); +uchar16 __ovld __cnfn abs(uchar16); +ushort __ovld __cnfn abs(short); +ushort __ovld __cnfn abs(ushort); +ushort2 __ovld __cnfn abs(short2); +ushort2 __ovld __cnfn abs(ushort2); +ushort3 __ovld __cnfn abs(short3); +ushort3 __ovld __cnfn abs(ushort3); +ushort4 __ovld __cnfn abs(short4); +ushort4 __ovld __cnfn abs(ushort4); +ushort8 __ovld __cnfn abs(short8); +ushort8 __ovld __cnfn abs(ushort8); +ushort16 __ovld __cnfn abs(short16); +ushort16 __ovld __cnfn abs(ushort16); +uint __ovld __cnfn abs(int); +uint __ovld __cnfn abs(uint); +uint2 __ovld __cnfn abs(int2); +uint2 __ovld __cnfn abs(uint2); +uint3 __ovld __cnfn abs(int3); +uint3 __ovld __cnfn abs(uint3); +uint4 __ovld __cnfn abs(int4); +uint4 __ovld __cnfn abs(uint4); +uint8 __ovld __cnfn abs(int8); +uint8 __ovld __cnfn abs(uint8); +uint16 __ovld __cnfn abs(int16); +uint16 __ovld __cnfn abs(uint16); +ulong __ovld __cnfn abs(long); +ulong __ovld __cnfn abs(ulong); +ulong2 __ovld __cnfn abs(long2); +ulong2 __ovld __cnfn abs(ulong2); +ulong3 __ovld __cnfn abs(long3); +ulong3 __ovld __cnfn abs(ulong3); +ulong4 __ovld __cnfn abs(long4); +ulong4 __ovld __cnfn abs(ulong4); +ulong8 __ovld __cnfn abs(long8); +ulong8 __ovld __cnfn abs(ulong8); +ulong16 __ovld __cnfn abs(long16); +ulong16 __ovld __cnfn abs(ulong16); + +/** + * Returns | x - y | without modulo overflow. + */ +uchar __ovld __cnfn abs_diff(char, char); +uchar __ovld __cnfn abs_diff(uchar, uchar); +uchar2 __ovld __cnfn abs_diff(char2, char2); +uchar2 __ovld __cnfn abs_diff(uchar2, uchar2); +uchar3 __ovld __cnfn abs_diff(char3, char3); +uchar3 __ovld __cnfn abs_diff(uchar3, uchar3); +uchar4 __ovld __cnfn abs_diff(char4, char4); +uchar4 __ovld __cnfn abs_diff(uchar4, uchar4); +uchar8 __ovld __cnfn abs_diff(char8, char8); +uchar8 __ovld __cnfn abs_diff(uchar8, uchar8); +uchar16 __ovld __cnfn abs_diff(char16, char16); +uchar16 __ovld __cnfn abs_diff(uchar16, uchar16); +ushort __ovld __cnfn abs_diff(short, short); +ushort __ovld __cnfn abs_diff(ushort, ushort); +ushort2 __ovld __cnfn abs_diff(short2, short2); +ushort2 __ovld __cnfn abs_diff(ushort2, ushort2); +ushort3 __ovld __cnfn abs_diff(short3, short3); +ushort3 __ovld __cnfn abs_diff(ushort3, ushort3); +ushort4 __ovld __cnfn abs_diff(short4, short4); +ushort4 __ovld __cnfn abs_diff(ushort4, ushort4); +ushort8 __ovld __cnfn abs_diff(short8, short8); +ushort8 __ovld __cnfn abs_diff(ushort8, ushort8); +ushort16 __ovld __cnfn abs_diff(short16, short16); +ushort16 __ovld __cnfn abs_diff(ushort16, ushort16); +uint __ovld __cnfn abs_diff(int, int); +uint __ovld __cnfn abs_diff(uint, uint); +uint2 __ovld __cnfn abs_diff(int2, int2); +uint2 __ovld __cnfn abs_diff(uint2, uint2); +uint3 __ovld __cnfn abs_diff(int3, int3); +uint3 __ovld __cnfn abs_diff(uint3, uint3); +uint4 __ovld __cnfn abs_diff(int4, int4); +uint4 __ovld __cnfn abs_diff(uint4, uint4); +uint8 __ovld __cnfn abs_diff(int8, int8); +uint8 __ovld __cnfn abs_diff(uint8, uint8); +uint16 __ovld __cnfn abs_diff(int16, int16); +uint16 __ovld __cnfn abs_diff(uint16, uint16); +ulong __ovld __cnfn abs_diff(long, long); +ulong __ovld __cnfn abs_diff(ulong, ulong); +ulong2 __ovld __cnfn abs_diff(long2, long2); +ulong2 __ovld __cnfn abs_diff(ulong2, ulong2); +ulong3 __ovld __cnfn abs_diff(long3, long3); +ulong3 __ovld __cnfn abs_diff(ulong3, ulong3); +ulong4 __ovld __cnfn abs_diff(long4, long4); +ulong4 __ovld __cnfn abs_diff(ulong4, ulong4); +ulong8 __ovld __cnfn abs_diff(long8, long8); +ulong8 __ovld __cnfn abs_diff(ulong8, ulong8); +ulong16 __ovld __cnfn abs_diff(long16, long16); +ulong16 __ovld __cnfn abs_diff(ulong16, ulong16); + +/** + * Returns x + y and saturates the result. + */ +char __ovld __cnfn add_sat(char, char); +uchar __ovld __cnfn add_sat(uchar, uchar); +char2 __ovld __cnfn add_sat(char2, char2); +uchar2 __ovld __cnfn add_sat(uchar2, uchar2); +char3 __ovld __cnfn add_sat(char3, char3); +uchar3 __ovld __cnfn add_sat(uchar3, uchar3); +char4 __ovld __cnfn add_sat(char4, char4); +uchar4 __ovld __cnfn add_sat(uchar4, uchar4); +char8 __ovld __cnfn add_sat(char8, char8); +uchar8 __ovld __cnfn add_sat(uchar8, uchar8); +char16 __ovld __cnfn add_sat(char16, char16); +uchar16 __ovld __cnfn add_sat(uchar16, uchar16); +short __ovld __cnfn add_sat(short, short); +ushort __ovld __cnfn add_sat(ushort, ushort); +short2 __ovld __cnfn add_sat(short2, short2); +ushort2 __ovld __cnfn add_sat(ushort2, ushort2); +short3 __ovld __cnfn add_sat(short3, short3); +ushort3 __ovld __cnfn add_sat(ushort3, ushort3); +short4 __ovld __cnfn add_sat(short4, short4); +ushort4 __ovld __cnfn add_sat(ushort4, ushort4); +short8 __ovld __cnfn add_sat(short8, short8); +ushort8 __ovld __cnfn add_sat(ushort8, ushort8); +short16 __ovld __cnfn add_sat(short16, short16); +ushort16 __ovld __cnfn add_sat(ushort16, ushort16); +int __ovld __cnfn add_sat(int, int); +uint __ovld __cnfn add_sat(uint, uint); +int2 __ovld __cnfn add_sat(int2, int2); +uint2 __ovld __cnfn add_sat(uint2, uint2); +int3 __ovld __cnfn add_sat(int3, int3); +uint3 __ovld __cnfn add_sat(uint3, uint3); +int4 __ovld __cnfn add_sat(int4, int4); +uint4 __ovld __cnfn add_sat(uint4, uint4); +int8 __ovld __cnfn add_sat(int8, int8); +uint8 __ovld __cnfn add_sat(uint8, uint8); +int16 __ovld __cnfn add_sat(int16, int16); +uint16 __ovld __cnfn add_sat(uint16, uint16); +long __ovld __cnfn add_sat(long, long); +ulong __ovld __cnfn add_sat(ulong, ulong); +long2 __ovld __cnfn add_sat(long2, long2); +ulong2 __ovld __cnfn add_sat(ulong2, ulong2); +long3 __ovld __cnfn add_sat(long3, long3); +ulong3 __ovld __cnfn add_sat(ulong3, ulong3); +long4 __ovld __cnfn add_sat(long4, long4); +ulong4 __ovld __cnfn add_sat(ulong4, ulong4); +long8 __ovld __cnfn add_sat(long8, long8); +ulong8 __ovld __cnfn add_sat(ulong8, ulong8); +long16 __ovld __cnfn add_sat(long16, long16); +ulong16 __ovld __cnfn add_sat(ulong16, ulong16); + +/** + * Returns (x + y) >> 1. The intermediate sum does + * not modulo overflow. + */ +char __ovld __cnfn hadd(char, char); +uchar __ovld __cnfn hadd(uchar, uchar); +char2 __ovld __cnfn hadd(char2, char2); +uchar2 __ovld __cnfn hadd(uchar2, uchar2); +char3 __ovld __cnfn hadd(char3, char3); +uchar3 __ovld __cnfn hadd(uchar3, uchar3); +char4 __ovld __cnfn hadd(char4, char4); +uchar4 __ovld __cnfn hadd(uchar4, uchar4); +char8 __ovld __cnfn hadd(char8, char8); +uchar8 __ovld __cnfn hadd(uchar8, uchar8); +char16 __ovld __cnfn hadd(char16, char16); +uchar16 __ovld __cnfn hadd(uchar16, uchar16); +short __ovld __cnfn hadd(short, short); +ushort __ovld __cnfn hadd(ushort, ushort); +short2 __ovld __cnfn hadd(short2, short2); +ushort2 __ovld __cnfn hadd(ushort2, ushort2); +short3 __ovld __cnfn hadd(short3, short3); +ushort3 __ovld __cnfn hadd(ushort3, ushort3); +short4 __ovld __cnfn hadd(short4, short4); +ushort4 __ovld __cnfn hadd(ushort4, ushort4); +short8 __ovld __cnfn hadd(short8, short8); +ushort8 __ovld __cnfn hadd(ushort8, ushort8); +short16 __ovld __cnfn hadd(short16, short16); +ushort16 __ovld __cnfn hadd(ushort16, ushort16); +int __ovld __cnfn hadd(int, int); +uint __ovld __cnfn hadd(uint, uint); +int2 __ovld __cnfn hadd(int2, int2); +uint2 __ovld __cnfn hadd(uint2, uint2); +int3 __ovld __cnfn hadd(int3, int3); +uint3 __ovld __cnfn hadd(uint3, uint3); +int4 __ovld __cnfn hadd(int4, int4); +uint4 __ovld __cnfn hadd(uint4, uint4); +int8 __ovld __cnfn hadd(int8, int8); +uint8 __ovld __cnfn hadd(uint8, uint8); +int16 __ovld __cnfn hadd(int16, int16); +uint16 __ovld __cnfn hadd(uint16, uint16); +long __ovld __cnfn hadd(long, long); +ulong __ovld __cnfn hadd(ulong, ulong); +long2 __ovld __cnfn hadd(long2, long2); +ulong2 __ovld __cnfn hadd(ulong2, ulong2); +long3 __ovld __cnfn hadd(long3, long3); +ulong3 __ovld __cnfn hadd(ulong3, ulong3); +long4 __ovld __cnfn hadd(long4, long4); +ulong4 __ovld __cnfn hadd(ulong4, ulong4); +long8 __ovld __cnfn hadd(long8, long8); +ulong8 __ovld __cnfn hadd(ulong8, ulong8); +long16 __ovld __cnfn hadd(long16, long16); +ulong16 __ovld __cnfn hadd(ulong16, ulong16); + +/** + * Returns (x + y + 1) >> 1. The intermediate sum + * does not modulo overflow. + */ +char __ovld __cnfn rhadd(char, char); +uchar __ovld __cnfn rhadd(uchar, uchar); +char2 __ovld __cnfn rhadd(char2, char2); +uchar2 __ovld __cnfn rhadd(uchar2, uchar2); +char3 __ovld __cnfn rhadd(char3, char3); +uchar3 __ovld __cnfn rhadd(uchar3, uchar3); +char4 __ovld __cnfn rhadd(char4, char4); +uchar4 __ovld __cnfn rhadd(uchar4, uchar4); +char8 __ovld __cnfn rhadd(char8, char8); +uchar8 __ovld __cnfn rhadd(uchar8, uchar8); +char16 __ovld __cnfn rhadd(char16, char16); +uchar16 __ovld __cnfn rhadd(uchar16, uchar16); +short __ovld __cnfn rhadd(short, short); +ushort __ovld __cnfn rhadd(ushort, ushort); +short2 __ovld __cnfn rhadd(short2, short2); +ushort2 __ovld __cnfn rhadd(ushort2, ushort2); +short3 __ovld __cnfn rhadd(short3, short3); +ushort3 __ovld __cnfn rhadd(ushort3, ushort3); +short4 __ovld __cnfn rhadd(short4, short4); +ushort4 __ovld __cnfn rhadd(ushort4, ushort4); +short8 __ovld __cnfn rhadd(short8, short8); +ushort8 __ovld __cnfn rhadd(ushort8, ushort8); +short16 __ovld __cnfn rhadd(short16, short16); +ushort16 __ovld __cnfn rhadd(ushort16, ushort16); +int __ovld __cnfn rhadd(int, int); +uint __ovld __cnfn rhadd(uint, uint); +int2 __ovld __cnfn rhadd(int2, int2); +uint2 __ovld __cnfn rhadd(uint2, uint2); +int3 __ovld __cnfn rhadd(int3, int3); +uint3 __ovld __cnfn rhadd(uint3, uint3); +int4 __ovld __cnfn rhadd(int4, int4); +uint4 __ovld __cnfn rhadd(uint4, uint4); +int8 __ovld __cnfn rhadd(int8, int8); +uint8 __ovld __cnfn rhadd(uint8, uint8); +int16 __ovld __cnfn rhadd(int16, int16); +uint16 __ovld __cnfn rhadd(uint16, uint16); +long __ovld __cnfn rhadd(long, long); +ulong __ovld __cnfn rhadd(ulong, ulong); +long2 __ovld __cnfn rhadd(long2, long2); +ulong2 __ovld __cnfn rhadd(ulong2, ulong2); +long3 __ovld __cnfn rhadd(long3, long3); +ulong3 __ovld __cnfn rhadd(ulong3, ulong3); +long4 __ovld __cnfn rhadd(long4, long4); +ulong4 __ovld __cnfn rhadd(ulong4, ulong4); +long8 __ovld __cnfn rhadd(long8, long8); +ulong8 __ovld __cnfn rhadd(ulong8, ulong8); +long16 __ovld __cnfn rhadd(long16, long16); +ulong16 __ovld __cnfn rhadd(ulong16, ulong16); + +/** + * Returns min(max(x, minval), maxval). + * Results are undefined if minval > maxval. + */ +char __ovld __cnfn clamp(char, char, char); +uchar __ovld __cnfn clamp(uchar, uchar, uchar); +char2 __ovld __cnfn clamp(char2, char2, char2); +uchar2 __ovld __cnfn clamp(uchar2, uchar2, uchar2); +char3 __ovld __cnfn clamp(char3, char3, char3); +uchar3 __ovld __cnfn clamp(uchar3, uchar3, uchar3); +char4 __ovld __cnfn clamp(char4, char4, char4); +uchar4 __ovld __cnfn clamp(uchar4, uchar4, uchar4); +char8 __ovld __cnfn clamp(char8, char8, char8); +uchar8 __ovld __cnfn clamp(uchar8, uchar8, uchar8); +char16 __ovld __cnfn clamp(char16, char16, char16); +uchar16 __ovld __cnfn clamp(uchar16, uchar16, uchar16); +short __ovld __cnfn clamp(short, short, short); +ushort __ovld __cnfn clamp(ushort, ushort, ushort); +short2 __ovld __cnfn clamp(short2, short2, short2); +ushort2 __ovld __cnfn clamp(ushort2, ushort2, ushort2); +short3 __ovld __cnfn clamp(short3, short3, short3); +ushort3 __ovld __cnfn clamp(ushort3, ushort3, ushort3); +short4 __ovld __cnfn clamp(short4, short4, short4); +ushort4 __ovld __cnfn clamp(ushort4, ushort4, ushort4); +short8 __ovld __cnfn clamp(short8, short8, short8); +ushort8 __ovld __cnfn clamp(ushort8, ushort8, ushort8); +short16 __ovld __cnfn clamp(short16, short16, short16); +ushort16 __ovld __cnfn clamp(ushort16, ushort16, ushort16); +int __ovld __cnfn clamp(int, int, int); +uint __ovld __cnfn clamp(uint, uint, uint); +int2 __ovld __cnfn clamp(int2, int2, int2); +uint2 __ovld __cnfn clamp(uint2, uint2, uint2); +int3 __ovld __cnfn clamp(int3, int3, int3); +uint3 __ovld __cnfn clamp(uint3, uint3, uint3); +int4 __ovld __cnfn clamp(int4, int4, int4); +uint4 __ovld __cnfn clamp(uint4, uint4, uint4); +int8 __ovld __cnfn clamp(int8, int8, int8); +uint8 __ovld __cnfn clamp(uint8, uint8, uint8); +int16 __ovld __cnfn clamp(int16, int16, int16); +uint16 __ovld __cnfn clamp(uint16, uint16, uint16); +long __ovld __cnfn clamp(long, long, long); +ulong __ovld __cnfn clamp(ulong, ulong, ulong); +long2 __ovld __cnfn clamp(long2, long2, long2); +ulong2 __ovld __cnfn clamp(ulong2, ulong2, ulong2); +long3 __ovld __cnfn clamp(long3, long3, long3); +ulong3 __ovld __cnfn clamp(ulong3, ulong3, ulong3); +long4 __ovld __cnfn clamp(long4, long4, long4); +ulong4 __ovld __cnfn clamp(ulong4, ulong4, ulong4); +long8 __ovld __cnfn clamp(long8, long8, long8); +ulong8 __ovld __cnfn clamp(ulong8, ulong8, ulong8); +long16 __ovld __cnfn clamp(long16, long16, long16); +ulong16 __ovld __cnfn clamp(ulong16, ulong16, ulong16); +char2 __ovld __cnfn clamp(char2, char, char); +uchar2 __ovld __cnfn clamp(uchar2, uchar, uchar); +char3 __ovld __cnfn clamp(char3, char, char); +uchar3 __ovld __cnfn clamp(uchar3, uchar, uchar); +char4 __ovld __cnfn clamp(char4, char, char); +uchar4 __ovld __cnfn clamp(uchar4, uchar, uchar); +char8 __ovld __cnfn clamp(char8, char, char); +uchar8 __ovld __cnfn clamp(uchar8, uchar, uchar); +char16 __ovld __cnfn clamp(char16, char, char); +uchar16 __ovld __cnfn clamp(uchar16, uchar, uchar); +short2 __ovld __cnfn clamp(short2, short, short); +ushort2 __ovld __cnfn clamp(ushort2, ushort, ushort); +short3 __ovld __cnfn clamp(short3, short, short); +ushort3 __ovld __cnfn clamp(ushort3, ushort, ushort); +short4 __ovld __cnfn clamp(short4, short, short); +ushort4 __ovld __cnfn clamp(ushort4, ushort, ushort); +short8 __ovld __cnfn clamp(short8, short, short); +ushort8 __ovld __cnfn clamp(ushort8, ushort, ushort); +short16 __ovld __cnfn clamp(short16, short, short); +ushort16 __ovld __cnfn clamp(ushort16, ushort, ushort); +int2 __ovld __cnfn clamp(int2, int, int); +uint2 __ovld __cnfn clamp(uint2, uint, uint); +int3 __ovld __cnfn clamp(int3, int, int); +uint3 __ovld __cnfn clamp(uint3, uint, uint); +int4 __ovld __cnfn clamp(int4, int, int); +uint4 __ovld __cnfn clamp(uint4, uint, uint); +int8 __ovld __cnfn clamp(int8, int, int); +uint8 __ovld __cnfn clamp(uint8, uint, uint); +int16 __ovld __cnfn clamp(int16, int, int); +uint16 __ovld __cnfn clamp(uint16, uint, uint); +long2 __ovld __cnfn clamp(long2, long, long); +ulong2 __ovld __cnfn clamp(ulong2, ulong, ulong); +long3 __ovld __cnfn clamp(long3, long, long); +ulong3 __ovld __cnfn clamp(ulong3, ulong, ulong); +long4 __ovld __cnfn clamp(long4, long, long); +ulong4 __ovld __cnfn clamp(ulong4, ulong, ulong); +long8 __ovld __cnfn clamp(long8, long, long); +ulong8 __ovld __cnfn clamp(ulong8, ulong, ulong); +long16 __ovld __cnfn clamp(long16, long, long); +ulong16 __ovld __cnfn clamp(ulong16, ulong, ulong); + +/** + * Returns the number of leading 0-bits in x, starting + * at the most significant bit position. + */ +char __ovld __cnfn clz(char); +uchar __ovld __cnfn clz(uchar); +char2 __ovld __cnfn clz(char2); +uchar2 __ovld __cnfn clz(uchar2); +char3 __ovld __cnfn clz(char3); +uchar3 __ovld __cnfn clz(uchar3); +char4 __ovld __cnfn clz(char4); +uchar4 __ovld __cnfn clz(uchar4); +char8 __ovld __cnfn clz(char8); +uchar8 __ovld __cnfn clz(uchar8); +char16 __ovld __cnfn clz(char16); +uchar16 __ovld __cnfn clz(uchar16); +short __ovld __cnfn clz(short); +ushort __ovld __cnfn clz(ushort); +short2 __ovld __cnfn clz(short2); +ushort2 __ovld __cnfn clz(ushort2); +short3 __ovld __cnfn clz(short3); +ushort3 __ovld __cnfn clz(ushort3); +short4 __ovld __cnfn clz(short4); +ushort4 __ovld __cnfn clz(ushort4); +short8 __ovld __cnfn clz(short8); +ushort8 __ovld __cnfn clz(ushort8); +short16 __ovld __cnfn clz(short16); +ushort16 __ovld __cnfn clz(ushort16); +int __ovld __cnfn clz(int); +uint __ovld __cnfn clz(uint); +int2 __ovld __cnfn clz(int2); +uint2 __ovld __cnfn clz(uint2); +int3 __ovld __cnfn clz(int3); +uint3 __ovld __cnfn clz(uint3); +int4 __ovld __cnfn clz(int4); +uint4 __ovld __cnfn clz(uint4); +int8 __ovld __cnfn clz(int8); +uint8 __ovld __cnfn clz(uint8); +int16 __ovld __cnfn clz(int16); +uint16 __ovld __cnfn clz(uint16); +long __ovld __cnfn clz(long); +ulong __ovld __cnfn clz(ulong); +long2 __ovld __cnfn clz(long2); +ulong2 __ovld __cnfn clz(ulong2); +long3 __ovld __cnfn clz(long3); +ulong3 __ovld __cnfn clz(ulong3); +long4 __ovld __cnfn clz(long4); +ulong4 __ovld __cnfn clz(ulong4); +long8 __ovld __cnfn clz(long8); +ulong8 __ovld __cnfn clz(ulong8); +long16 __ovld __cnfn clz(long16); +ulong16 __ovld __cnfn clz(ulong16); + +/** + * Returns the count of trailing 0-bits in x. If x is 0, + * returns the size in bits of the type of x or + * component type of x, if x is a vector. + */ +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +char __ovld __cnfn ctz(char); +uchar __ovld __cnfn ctz(uchar); +char2 __ovld __cnfn ctz(char2); +uchar2 __ovld __cnfn ctz(uchar2); +char3 __ovld __cnfn ctz(char3); +uchar3 __ovld __cnfn ctz(uchar3); +char4 __ovld __cnfn ctz(char4); +uchar4 __ovld __cnfn ctz(uchar4); +char8 __ovld __cnfn ctz(char8); +uchar8 __ovld __cnfn ctz(uchar8); +char16 __ovld __cnfn ctz(char16); +uchar16 __ovld __cnfn ctz(uchar16); +short __ovld __cnfn ctz(short); +ushort __ovld __cnfn ctz(ushort); +short2 __ovld __cnfn ctz(short2); +ushort2 __ovld __cnfn ctz(ushort2); +short3 __ovld __cnfn ctz(short3); +ushort3 __ovld __cnfn ctz(ushort3); +short4 __ovld __cnfn ctz(short4); +ushort4 __ovld __cnfn ctz(ushort4); +short8 __ovld __cnfn ctz(short8); +ushort8 __ovld __cnfn ctz(ushort8); +short16 __ovld __cnfn ctz(short16); +ushort16 __ovld __cnfn ctz(ushort16); +int __ovld __cnfn ctz(int); +uint __ovld __cnfn ctz(uint); +int2 __ovld __cnfn ctz(int2); +uint2 __ovld __cnfn ctz(uint2); +int3 __ovld __cnfn ctz(int3); +uint3 __ovld __cnfn ctz(uint3); +int4 __ovld __cnfn ctz(int4); +uint4 __ovld __cnfn ctz(uint4); +int8 __ovld __cnfn ctz(int8); +uint8 __ovld __cnfn ctz(uint8); +int16 __ovld __cnfn ctz(int16); +uint16 __ovld __cnfn ctz(uint16); +long __ovld __cnfn ctz(long); +ulong __ovld __cnfn ctz(ulong); +long2 __ovld __cnfn ctz(long2); +ulong2 __ovld __cnfn ctz(ulong2); +long3 __ovld __cnfn ctz(long3); +ulong3 __ovld __cnfn ctz(ulong3); +long4 __ovld __cnfn ctz(long4); +ulong4 __ovld __cnfn ctz(ulong4); +long8 __ovld __cnfn ctz(long8); +ulong8 __ovld __cnfn ctz(ulong8); +long16 __ovld __cnfn ctz(long16); +ulong16 __ovld __cnfn ctz(ulong16); +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +/** + * Returns mul_hi(a, b) + c. + */ +char __ovld __cnfn mad_hi(char, char, char); +uchar __ovld __cnfn mad_hi(uchar, uchar, uchar); +char2 __ovld __cnfn mad_hi(char2, char2, char2); +uchar2 __ovld __cnfn mad_hi(uchar2, uchar2, uchar2); +char3 __ovld __cnfn mad_hi(char3, char3, char3); +uchar3 __ovld __cnfn mad_hi(uchar3, uchar3, uchar3); +char4 __ovld __cnfn mad_hi(char4, char4, char4); +uchar4 __ovld __cnfn mad_hi(uchar4, uchar4, uchar4); +char8 __ovld __cnfn mad_hi(char8, char8, char8); +uchar8 __ovld __cnfn mad_hi(uchar8, uchar8, uchar8); +char16 __ovld __cnfn mad_hi(char16, char16, char16); +uchar16 __ovld __cnfn mad_hi(uchar16, uchar16, uchar16); +short __ovld __cnfn mad_hi(short, short, short); +ushort __ovld __cnfn mad_hi(ushort, ushort, ushort); +short2 __ovld __cnfn mad_hi(short2, short2, short2); +ushort2 __ovld __cnfn mad_hi(ushort2, ushort2, ushort2); +short3 __ovld __cnfn mad_hi(short3, short3, short3); +ushort3 __ovld __cnfn mad_hi(ushort3, ushort3, ushort3); +short4 __ovld __cnfn mad_hi(short4, short4, short4); +ushort4 __ovld __cnfn mad_hi(ushort4, ushort4, ushort4); +short8 __ovld __cnfn mad_hi(short8, short8, short8); +ushort8 __ovld __cnfn mad_hi(ushort8, ushort8, ushort8); +short16 __ovld __cnfn mad_hi(short16, short16, short16); +ushort16 __ovld __cnfn mad_hi(ushort16, ushort16, ushort16); +int __ovld __cnfn mad_hi(int, int, int); +uint __ovld __cnfn mad_hi(uint, uint, uint); +int2 __ovld __cnfn mad_hi(int2, int2, int2); +uint2 __ovld __cnfn mad_hi(uint2, uint2, uint2); +int3 __ovld __cnfn mad_hi(int3, int3, int3); +uint3 __ovld __cnfn mad_hi(uint3, uint3, uint3); +int4 __ovld __cnfn mad_hi(int4, int4, int4); +uint4 __ovld __cnfn mad_hi(uint4, uint4, uint4); +int8 __ovld __cnfn mad_hi(int8, int8, int8); +uint8 __ovld __cnfn mad_hi(uint8, uint8, uint8); +int16 __ovld __cnfn mad_hi(int16, int16, int16); +uint16 __ovld __cnfn mad_hi(uint16, uint16, uint16); +long __ovld __cnfn mad_hi(long, long, long); +ulong __ovld __cnfn mad_hi(ulong, ulong, ulong); +long2 __ovld __cnfn mad_hi(long2, long2, long2); +ulong2 __ovld __cnfn mad_hi(ulong2, ulong2, ulong2); +long3 __ovld __cnfn mad_hi(long3, long3, long3); +ulong3 __ovld __cnfn mad_hi(ulong3, ulong3, ulong3); +long4 __ovld __cnfn mad_hi(long4, long4, long4); +ulong4 __ovld __cnfn mad_hi(ulong4, ulong4, ulong4); +long8 __ovld __cnfn mad_hi(long8, long8, long8); +ulong8 __ovld __cnfn mad_hi(ulong8, ulong8, ulong8); +long16 __ovld __cnfn mad_hi(long16, long16, long16); +ulong16 __ovld __cnfn mad_hi(ulong16, ulong16, ulong16); + +/** + * Returns a * b + c and saturates the result. + */ +char __ovld __cnfn mad_sat(char, char, char); +uchar __ovld __cnfn mad_sat(uchar, uchar, uchar); +char2 __ovld __cnfn mad_sat(char2, char2, char2); +uchar2 __ovld __cnfn mad_sat(uchar2, uchar2, uchar2); +char3 __ovld __cnfn mad_sat(char3, char3, char3); +uchar3 __ovld __cnfn mad_sat(uchar3, uchar3, uchar3); +char4 __ovld __cnfn mad_sat(char4, char4, char4); +uchar4 __ovld __cnfn mad_sat(uchar4, uchar4, uchar4); +char8 __ovld __cnfn mad_sat(char8, char8, char8); +uchar8 __ovld __cnfn mad_sat(uchar8, uchar8, uchar8); +char16 __ovld __cnfn mad_sat(char16, char16, char16); +uchar16 __ovld __cnfn mad_sat(uchar16, uchar16, uchar16); +short __ovld __cnfn mad_sat(short, short, short); +ushort __ovld __cnfn mad_sat(ushort, ushort, ushort); +short2 __ovld __cnfn mad_sat(short2, short2, short2); +ushort2 __ovld __cnfn mad_sat(ushort2, ushort2, ushort2); +short3 __ovld __cnfn mad_sat(short3, short3, short3); +ushort3 __ovld __cnfn mad_sat(ushort3, ushort3, ushort3); +short4 __ovld __cnfn mad_sat(short4, short4, short4); +ushort4 __ovld __cnfn mad_sat(ushort4, ushort4, ushort4); +short8 __ovld __cnfn mad_sat(short8, short8, short8); +ushort8 __ovld __cnfn mad_sat(ushort8, ushort8, ushort8); +short16 __ovld __cnfn mad_sat(short16, short16, short16); +ushort16 __ovld __cnfn mad_sat(ushort16, ushort16, ushort16); +int __ovld __cnfn mad_sat(int, int, int); +uint __ovld __cnfn mad_sat(uint, uint, uint); +int2 __ovld __cnfn mad_sat(int2, int2, int2); +uint2 __ovld __cnfn mad_sat(uint2, uint2, uint2); +int3 __ovld __cnfn mad_sat(int3, int3, int3); +uint3 __ovld __cnfn mad_sat(uint3, uint3, uint3); +int4 __ovld __cnfn mad_sat(int4, int4, int4); +uint4 __ovld __cnfn mad_sat(uint4, uint4, uint4); +int8 __ovld __cnfn mad_sat(int8, int8, int8); +uint8 __ovld __cnfn mad_sat(uint8, uint8, uint8); +int16 __ovld __cnfn mad_sat(int16, int16, int16); +uint16 __ovld __cnfn mad_sat(uint16, uint16, uint16); +long __ovld __cnfn mad_sat(long, long, long); +ulong __ovld __cnfn mad_sat(ulong, ulong, ulong); +long2 __ovld __cnfn mad_sat(long2, long2, long2); +ulong2 __ovld __cnfn mad_sat(ulong2, ulong2, ulong2); +long3 __ovld __cnfn mad_sat(long3, long3, long3); +ulong3 __ovld __cnfn mad_sat(ulong3, ulong3, ulong3); +long4 __ovld __cnfn mad_sat(long4, long4, long4); +ulong4 __ovld __cnfn mad_sat(ulong4, ulong4, ulong4); +long8 __ovld __cnfn mad_sat(long8, long8, long8); +ulong8 __ovld __cnfn mad_sat(ulong8, ulong8, ulong8); +long16 __ovld __cnfn mad_sat(long16, long16, long16); +ulong16 __ovld __cnfn mad_sat(ulong16, ulong16, ulong16); + +/** + * Returns y if x < y, otherwise it returns x. + */ +char __ovld __cnfn max(char, char); +uchar __ovld __cnfn max(uchar, uchar); +char2 __ovld __cnfn max(char2, char2); +uchar2 __ovld __cnfn max(uchar2, uchar2); +char3 __ovld __cnfn max(char3, char3); +uchar3 __ovld __cnfn max(uchar3, uchar3); +char4 __ovld __cnfn max(char4, char4); +uchar4 __ovld __cnfn max(uchar4, uchar4); +char8 __ovld __cnfn max(char8, char8); +uchar8 __ovld __cnfn max(uchar8, uchar8); +char16 __ovld __cnfn max(char16, char16); +uchar16 __ovld __cnfn max(uchar16, uchar16); +short __ovld __cnfn max(short, short); +ushort __ovld __cnfn max(ushort, ushort); +short2 __ovld __cnfn max(short2, short2); +ushort2 __ovld __cnfn max(ushort2, ushort2); +short3 __ovld __cnfn max(short3, short3); +ushort3 __ovld __cnfn max(ushort3, ushort3); +short4 __ovld __cnfn max(short4, short4); +ushort4 __ovld __cnfn max(ushort4, ushort4); +short8 __ovld __cnfn max(short8, short8); +ushort8 __ovld __cnfn max(ushort8, ushort8); +short16 __ovld __cnfn max(short16, short16); +ushort16 __ovld __cnfn max(ushort16, ushort16); +int __ovld __cnfn max(int, int); +uint __ovld __cnfn max(uint, uint); +int2 __ovld __cnfn max(int2, int2); +uint2 __ovld __cnfn max(uint2, uint2); +int3 __ovld __cnfn max(int3, int3); +uint3 __ovld __cnfn max(uint3, uint3); +int4 __ovld __cnfn max(int4, int4); +uint4 __ovld __cnfn max(uint4, uint4); +int8 __ovld __cnfn max(int8, int8); +uint8 __ovld __cnfn max(uint8, uint8); +int16 __ovld __cnfn max(int16, int16); +uint16 __ovld __cnfn max(uint16, uint16); +long __ovld __cnfn max(long, long); +ulong __ovld __cnfn max(ulong, ulong); +long2 __ovld __cnfn max(long2, long2); +ulong2 __ovld __cnfn max(ulong2, ulong2); +long3 __ovld __cnfn max(long3, long3); +ulong3 __ovld __cnfn max(ulong3, ulong3); +long4 __ovld __cnfn max(long4, long4); +ulong4 __ovld __cnfn max(ulong4, ulong4); +long8 __ovld __cnfn max(long8, long8); +ulong8 __ovld __cnfn max(ulong8, ulong8); +long16 __ovld __cnfn max(long16, long16); +ulong16 __ovld __cnfn max(ulong16, ulong16); +char2 __ovld __cnfn max(char2, char); +uchar2 __ovld __cnfn max(uchar2, uchar); +char3 __ovld __cnfn max(char3, char); +uchar3 __ovld __cnfn max(uchar3, uchar); +char4 __ovld __cnfn max(char4, char); +uchar4 __ovld __cnfn max(uchar4, uchar); +char8 __ovld __cnfn max(char8, char); +uchar8 __ovld __cnfn max(uchar8, uchar); +char16 __ovld __cnfn max(char16, char); +uchar16 __ovld __cnfn max(uchar16, uchar); +short2 __ovld __cnfn max(short2, short); +ushort2 __ovld __cnfn max(ushort2, ushort); +short3 __ovld __cnfn max(short3, short); +ushort3 __ovld __cnfn max(ushort3, ushort); +short4 __ovld __cnfn max(short4, short); +ushort4 __ovld __cnfn max(ushort4, ushort); +short8 __ovld __cnfn max(short8, short); +ushort8 __ovld __cnfn max(ushort8, ushort); +short16 __ovld __cnfn max(short16, short); +ushort16 __ovld __cnfn max(ushort16, ushort); +int2 __ovld __cnfn max(int2, int); +uint2 __ovld __cnfn max(uint2, uint); +int3 __ovld __cnfn max(int3, int); +uint3 __ovld __cnfn max(uint3, uint); +int4 __ovld __cnfn max(int4, int); +uint4 __ovld __cnfn max(uint4, uint); +int8 __ovld __cnfn max(int8, int); +uint8 __ovld __cnfn max(uint8, uint); +int16 __ovld __cnfn max(int16, int); +uint16 __ovld __cnfn max(uint16, uint); +long2 __ovld __cnfn max(long2, long); +ulong2 __ovld __cnfn max(ulong2, ulong); +long3 __ovld __cnfn max(long3, long); +ulong3 __ovld __cnfn max(ulong3, ulong); +long4 __ovld __cnfn max(long4, long); +ulong4 __ovld __cnfn max(ulong4, ulong); +long8 __ovld __cnfn max(long8, long); +ulong8 __ovld __cnfn max(ulong8, ulong); +long16 __ovld __cnfn max(long16, long); +ulong16 __ovld __cnfn max(ulong16, ulong); + +/** + * Returns y if y < x, otherwise it returns x. + */ +char __ovld __cnfn min(char, char); +uchar __ovld __cnfn min(uchar, uchar); +char2 __ovld __cnfn min(char2, char2); +uchar2 __ovld __cnfn min(uchar2, uchar2); +char3 __ovld __cnfn min(char3, char3); +uchar3 __ovld __cnfn min(uchar3, uchar3); +char4 __ovld __cnfn min(char4, char4); +uchar4 __ovld __cnfn min(uchar4, uchar4); +char8 __ovld __cnfn min(char8, char8); +uchar8 __ovld __cnfn min(uchar8, uchar8); +char16 __ovld __cnfn min(char16, char16); +uchar16 __ovld __cnfn min(uchar16, uchar16); +short __ovld __cnfn min(short, short); +ushort __ovld __cnfn min(ushort, ushort); +short2 __ovld __cnfn min(short2, short2); +ushort2 __ovld __cnfn min(ushort2, ushort2); +short3 __ovld __cnfn min(short3, short3); +ushort3 __ovld __cnfn min(ushort3, ushort3); +short4 __ovld __cnfn min(short4, short4); +ushort4 __ovld __cnfn min(ushort4, ushort4); +short8 __ovld __cnfn min(short8, short8); +ushort8 __ovld __cnfn min(ushort8, ushort8); +short16 __ovld __cnfn min(short16, short16); +ushort16 __ovld __cnfn min(ushort16, ushort16); +int __ovld __cnfn min(int, int); +uint __ovld __cnfn min(uint, uint); +int2 __ovld __cnfn min(int2, int2); +uint2 __ovld __cnfn min(uint2, uint2); +int3 __ovld __cnfn min(int3, int3); +uint3 __ovld __cnfn min(uint3, uint3); +int4 __ovld __cnfn min(int4, int4); +uint4 __ovld __cnfn min(uint4, uint4); +int8 __ovld __cnfn min(int8, int8); +uint8 __ovld __cnfn min(uint8, uint8); +int16 __ovld __cnfn min(int16, int16); +uint16 __ovld __cnfn min(uint16, uint16); +long __ovld __cnfn min(long, long); +ulong __ovld __cnfn min(ulong, ulong); +long2 __ovld __cnfn min(long2, long2); +ulong2 __ovld __cnfn min(ulong2, ulong2); +long3 __ovld __cnfn min(long3, long3); +ulong3 __ovld __cnfn min(ulong3, ulong3); +long4 __ovld __cnfn min(long4, long4); +ulong4 __ovld __cnfn min(ulong4, ulong4); +long8 __ovld __cnfn min(long8, long8); +ulong8 __ovld __cnfn min(ulong8, ulong8); +long16 __ovld __cnfn min(long16, long16); +ulong16 __ovld __cnfn min(ulong16, ulong16); +char2 __ovld __cnfn min(char2, char); +uchar2 __ovld __cnfn min(uchar2, uchar); +char3 __ovld __cnfn min(char3, char); +uchar3 __ovld __cnfn min(uchar3, uchar); +char4 __ovld __cnfn min(char4, char); +uchar4 __ovld __cnfn min(uchar4, uchar); +char8 __ovld __cnfn min(char8, char); +uchar8 __ovld __cnfn min(uchar8, uchar); +char16 __ovld __cnfn min(char16, char); +uchar16 __ovld __cnfn min(uchar16, uchar); +short2 __ovld __cnfn min(short2, short); +ushort2 __ovld __cnfn min(ushort2, ushort); +short3 __ovld __cnfn min(short3, short); +ushort3 __ovld __cnfn min(ushort3, ushort); +short4 __ovld __cnfn min(short4, short); +ushort4 __ovld __cnfn min(ushort4, ushort); +short8 __ovld __cnfn min(short8, short); +ushort8 __ovld __cnfn min(ushort8, ushort); +short16 __ovld __cnfn min(short16, short); +ushort16 __ovld __cnfn min(ushort16, ushort); +int2 __ovld __cnfn min(int2, int); +uint2 __ovld __cnfn min(uint2, uint); +int3 __ovld __cnfn min(int3, int); +uint3 __ovld __cnfn min(uint3, uint); +int4 __ovld __cnfn min(int4, int); +uint4 __ovld __cnfn min(uint4, uint); +int8 __ovld __cnfn min(int8, int); +uint8 __ovld __cnfn min(uint8, uint); +int16 __ovld __cnfn min(int16, int); +uint16 __ovld __cnfn min(uint16, uint); +long2 __ovld __cnfn min(long2, long); +ulong2 __ovld __cnfn min(ulong2, ulong); +long3 __ovld __cnfn min(long3, long); +ulong3 __ovld __cnfn min(ulong3, ulong); +long4 __ovld __cnfn min(long4, long); +ulong4 __ovld __cnfn min(ulong4, ulong); +long8 __ovld __cnfn min(long8, long); +ulong8 __ovld __cnfn min(ulong8, ulong); +long16 __ovld __cnfn min(long16, long); +ulong16 __ovld __cnfn min(ulong16, ulong); + +/** + * Computes x * y and returns the high half of the + * product of x and y. + */ +char __ovld __cnfn mul_hi(char, char); +uchar __ovld __cnfn mul_hi(uchar, uchar); +char2 __ovld __cnfn mul_hi(char2, char2); +uchar2 __ovld __cnfn mul_hi(uchar2, uchar2); +char3 __ovld __cnfn mul_hi(char3, char3); +uchar3 __ovld __cnfn mul_hi(uchar3, uchar3); +char4 __ovld __cnfn mul_hi(char4, char4); +uchar4 __ovld __cnfn mul_hi(uchar4, uchar4); +char8 __ovld __cnfn mul_hi(char8, char8); +uchar8 __ovld __cnfn mul_hi(uchar8, uchar8); +char16 __ovld __cnfn mul_hi(char16, char16); +uchar16 __ovld __cnfn mul_hi(uchar16, uchar16); +short __ovld __cnfn mul_hi(short, short); +ushort __ovld __cnfn mul_hi(ushort, ushort); +short2 __ovld __cnfn mul_hi(short2, short2); +ushort2 __ovld __cnfn mul_hi(ushort2, ushort2); +short3 __ovld __cnfn mul_hi(short3, short3); +ushort3 __ovld __cnfn mul_hi(ushort3, ushort3); +short4 __ovld __cnfn mul_hi(short4, short4); +ushort4 __ovld __cnfn mul_hi(ushort4, ushort4); +short8 __ovld __cnfn mul_hi(short8, short8); +ushort8 __ovld __cnfn mul_hi(ushort8, ushort8); +short16 __ovld __cnfn mul_hi(short16, short16); +ushort16 __ovld __cnfn mul_hi(ushort16, ushort16); +int __ovld __cnfn mul_hi(int, int); +uint __ovld __cnfn mul_hi(uint, uint); +int2 __ovld __cnfn mul_hi(int2, int2); +uint2 __ovld __cnfn mul_hi(uint2, uint2); +int3 __ovld __cnfn mul_hi(int3, int3); +uint3 __ovld __cnfn mul_hi(uint3, uint3); +int4 __ovld __cnfn mul_hi(int4, int4); +uint4 __ovld __cnfn mul_hi(uint4, uint4); +int8 __ovld __cnfn mul_hi(int8, int8); +uint8 __ovld __cnfn mul_hi(uint8, uint8); +int16 __ovld __cnfn mul_hi(int16, int16); +uint16 __ovld __cnfn mul_hi(uint16, uint16); +long __ovld __cnfn mul_hi(long, long); +ulong __ovld __cnfn mul_hi(ulong, ulong); +long2 __ovld __cnfn mul_hi(long2, long2); +ulong2 __ovld __cnfn mul_hi(ulong2, ulong2); +long3 __ovld __cnfn mul_hi(long3, long3); +ulong3 __ovld __cnfn mul_hi(ulong3, ulong3); +long4 __ovld __cnfn mul_hi(long4, long4); +ulong4 __ovld __cnfn mul_hi(ulong4, ulong4); +long8 __ovld __cnfn mul_hi(long8, long8); +ulong8 __ovld __cnfn mul_hi(ulong8, ulong8); +long16 __ovld __cnfn mul_hi(long16, long16); +ulong16 __ovld __cnfn mul_hi(ulong16, ulong16); + +/** + * For each element in v, the bits are shifted left by + * the number of bits given by the corresponding + * element in i (subject to usual shift modulo rules + * described in section 6.3). Bits shifted off the left + * side of the element are shifted back in from the + * right. + */ +char __ovld __cnfn rotate(char, char); +uchar __ovld __cnfn rotate(uchar, uchar); +char2 __ovld __cnfn rotate(char2, char2); +uchar2 __ovld __cnfn rotate(uchar2, uchar2); +char3 __ovld __cnfn rotate(char3, char3); +uchar3 __ovld __cnfn rotate(uchar3, uchar3); +char4 __ovld __cnfn rotate(char4, char4); +uchar4 __ovld __cnfn rotate(uchar4, uchar4); +char8 __ovld __cnfn rotate(char8, char8); +uchar8 __ovld __cnfn rotate(uchar8, uchar8); +char16 __ovld __cnfn rotate(char16, char16); +uchar16 __ovld __cnfn rotate(uchar16, uchar16); +short __ovld __cnfn rotate(short, short); +ushort __ovld __cnfn rotate(ushort, ushort); +short2 __ovld __cnfn rotate(short2, short2); +ushort2 __ovld __cnfn rotate(ushort2, ushort2); +short3 __ovld __cnfn rotate(short3, short3); +ushort3 __ovld __cnfn rotate(ushort3, ushort3); +short4 __ovld __cnfn rotate(short4, short4); +ushort4 __ovld __cnfn rotate(ushort4, ushort4); +short8 __ovld __cnfn rotate(short8, short8); +ushort8 __ovld __cnfn rotate(ushort8, ushort8); +short16 __ovld __cnfn rotate(short16, short16); +ushort16 __ovld __cnfn rotate(ushort16, ushort16); +int __ovld __cnfn rotate(int, int); +uint __ovld __cnfn rotate(uint, uint); +int2 __ovld __cnfn rotate(int2, int2); +uint2 __ovld __cnfn rotate(uint2, uint2); +int3 __ovld __cnfn rotate(int3, int3); +uint3 __ovld __cnfn rotate(uint3, uint3); +int4 __ovld __cnfn rotate(int4, int4); +uint4 __ovld __cnfn rotate(uint4, uint4); +int8 __ovld __cnfn rotate(int8, int8); +uint8 __ovld __cnfn rotate(uint8, uint8); +int16 __ovld __cnfn rotate(int16, int16); +uint16 __ovld __cnfn rotate(uint16, uint16); +long __ovld __cnfn rotate(long, long); +ulong __ovld __cnfn rotate(ulong, ulong); +long2 __ovld __cnfn rotate(long2, long2); +ulong2 __ovld __cnfn rotate(ulong2, ulong2); +long3 __ovld __cnfn rotate(long3, long3); +ulong3 __ovld __cnfn rotate(ulong3, ulong3); +long4 __ovld __cnfn rotate(long4, long4); +ulong4 __ovld __cnfn rotate(ulong4, ulong4); +long8 __ovld __cnfn rotate(long8, long8); +ulong8 __ovld __cnfn rotate(ulong8, ulong8); +long16 __ovld __cnfn rotate(long16, long16); +ulong16 __ovld __cnfn rotate(ulong16, ulong16); + +/** + * Returns x - y and saturates the result. + */ +char __ovld __cnfn sub_sat(char, char); +uchar __ovld __cnfn sub_sat(uchar, uchar); +char2 __ovld __cnfn sub_sat(char2, char2); +uchar2 __ovld __cnfn sub_sat(uchar2, uchar2); +char3 __ovld __cnfn sub_sat(char3, char3); +uchar3 __ovld __cnfn sub_sat(uchar3, uchar3); +char4 __ovld __cnfn sub_sat(char4, char4); +uchar4 __ovld __cnfn sub_sat(uchar4, uchar4); +char8 __ovld __cnfn sub_sat(char8, char8); +uchar8 __ovld __cnfn sub_sat(uchar8, uchar8); +char16 __ovld __cnfn sub_sat(char16, char16); +uchar16 __ovld __cnfn sub_sat(uchar16, uchar16); +short __ovld __cnfn sub_sat(short, short); +ushort __ovld __cnfn sub_sat(ushort, ushort); +short2 __ovld __cnfn sub_sat(short2, short2); +ushort2 __ovld __cnfn sub_sat(ushort2, ushort2); +short3 __ovld __cnfn sub_sat(short3, short3); +ushort3 __ovld __cnfn sub_sat(ushort3, ushort3); +short4 __ovld __cnfn sub_sat(short4, short4); +ushort4 __ovld __cnfn sub_sat(ushort4, ushort4); +short8 __ovld __cnfn sub_sat(short8, short8); +ushort8 __ovld __cnfn sub_sat(ushort8, ushort8); +short16 __ovld __cnfn sub_sat(short16, short16); +ushort16 __ovld __cnfn sub_sat(ushort16, ushort16); +int __ovld __cnfn sub_sat(int, int); +uint __ovld __cnfn sub_sat(uint, uint); +int2 __ovld __cnfn sub_sat(int2, int2); +uint2 __ovld __cnfn sub_sat(uint2, uint2); +int3 __ovld __cnfn sub_sat(int3, int3); +uint3 __ovld __cnfn sub_sat(uint3, uint3); +int4 __ovld __cnfn sub_sat(int4, int4); +uint4 __ovld __cnfn sub_sat(uint4, uint4); +int8 __ovld __cnfn sub_sat(int8, int8); +uint8 __ovld __cnfn sub_sat(uint8, uint8); +int16 __ovld __cnfn sub_sat(int16, int16); +uint16 __ovld __cnfn sub_sat(uint16, uint16); +long __ovld __cnfn sub_sat(long, long); +ulong __ovld __cnfn sub_sat(ulong, ulong); +long2 __ovld __cnfn sub_sat(long2, long2); +ulong2 __ovld __cnfn sub_sat(ulong2, ulong2); +long3 __ovld __cnfn sub_sat(long3, long3); +ulong3 __ovld __cnfn sub_sat(ulong3, ulong3); +long4 __ovld __cnfn sub_sat(long4, long4); +ulong4 __ovld __cnfn sub_sat(ulong4, ulong4); +long8 __ovld __cnfn sub_sat(long8, long8); +ulong8 __ovld __cnfn sub_sat(ulong8, ulong8); +long16 __ovld __cnfn sub_sat(long16, long16); +ulong16 __ovld __cnfn sub_sat(ulong16, ulong16); + +/** + * result[i] = ((short)hi[i] << 8) | lo[i] + * result[i] = ((ushort)hi[i] << 8) | lo[i] + */ +short __ovld __cnfn upsample(char, uchar); +ushort __ovld __cnfn upsample(uchar, uchar); +short2 __ovld __cnfn upsample(char2, uchar2); +short3 __ovld __cnfn upsample(char3, uchar3); +short4 __ovld __cnfn upsample(char4, uchar4); +short8 __ovld __cnfn upsample(char8, uchar8); +short16 __ovld __cnfn upsample(char16, uchar16); +ushort2 __ovld __cnfn upsample(uchar2, uchar2); +ushort3 __ovld __cnfn upsample(uchar3, uchar3); +ushort4 __ovld __cnfn upsample(uchar4, uchar4); +ushort8 __ovld __cnfn upsample(uchar8, uchar8); +ushort16 __ovld __cnfn upsample(uchar16, uchar16); + +/** + * result[i] = ((int)hi[i] << 16) | lo[i] + * result[i] = ((uint)hi[i] << 16) | lo[i] + */ +int __ovld __cnfn upsample(short, ushort); +uint __ovld __cnfn upsample(ushort, ushort); +int2 __ovld __cnfn upsample(short2, ushort2); +int3 __ovld __cnfn upsample(short3, ushort3); +int4 __ovld __cnfn upsample(short4, ushort4); +int8 __ovld __cnfn upsample(short8, ushort8); +int16 __ovld __cnfn upsample(short16, ushort16); +uint2 __ovld __cnfn upsample(ushort2, ushort2); +uint3 __ovld __cnfn upsample(ushort3, ushort3); +uint4 __ovld __cnfn upsample(ushort4, ushort4); +uint8 __ovld __cnfn upsample(ushort8, ushort8); +uint16 __ovld __cnfn upsample(ushort16, ushort16); +/** + * result[i] = ((long)hi[i] << 32) | lo[i] + * result[i] = ((ulong)hi[i] << 32) | lo[i] + */ +long __ovld __cnfn upsample(int, uint); +ulong __ovld __cnfn upsample(uint, uint); +long2 __ovld __cnfn upsample(int2, uint2); +long3 __ovld __cnfn upsample(int3, uint3); +long4 __ovld __cnfn upsample(int4, uint4); +long8 __ovld __cnfn upsample(int8, uint8); +long16 __ovld __cnfn upsample(int16, uint16); +ulong2 __ovld __cnfn upsample(uint2, uint2); +ulong3 __ovld __cnfn upsample(uint3, uint3); +ulong4 __ovld __cnfn upsample(uint4, uint4); +ulong8 __ovld __cnfn upsample(uint8, uint8); +ulong16 __ovld __cnfn upsample(uint16, uint16); + +/* + * popcount(x): returns the number of set bit in x + */ +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +char __ovld __cnfn popcount(char); +uchar __ovld __cnfn popcount(uchar); +char2 __ovld __cnfn popcount(char2); +uchar2 __ovld __cnfn popcount(uchar2); +char3 __ovld __cnfn popcount(char3); +uchar3 __ovld __cnfn popcount(uchar3); +char4 __ovld __cnfn popcount(char4); +uchar4 __ovld __cnfn popcount(uchar4); +char8 __ovld __cnfn popcount(char8); +uchar8 __ovld __cnfn popcount(uchar8); +char16 __ovld __cnfn popcount(char16); +uchar16 __ovld __cnfn popcount(uchar16); +short __ovld __cnfn popcount(short); +ushort __ovld __cnfn popcount(ushort); +short2 __ovld __cnfn popcount(short2); +ushort2 __ovld __cnfn popcount(ushort2); +short3 __ovld __cnfn popcount(short3); +ushort3 __ovld __cnfn popcount(ushort3); +short4 __ovld __cnfn popcount(short4); +ushort4 __ovld __cnfn popcount(ushort4); +short8 __ovld __cnfn popcount(short8); +ushort8 __ovld __cnfn popcount(ushort8); +short16 __ovld __cnfn popcount(short16); +ushort16 __ovld __cnfn popcount(ushort16); +int __ovld __cnfn popcount(int); +uint __ovld __cnfn popcount(uint); +int2 __ovld __cnfn popcount(int2); +uint2 __ovld __cnfn popcount(uint2); +int3 __ovld __cnfn popcount(int3); +uint3 __ovld __cnfn popcount(uint3); +int4 __ovld __cnfn popcount(int4); +uint4 __ovld __cnfn popcount(uint4); +int8 __ovld __cnfn popcount(int8); +uint8 __ovld __cnfn popcount(uint8); +int16 __ovld __cnfn popcount(int16); +uint16 __ovld __cnfn popcount(uint16); +long __ovld __cnfn popcount(long); +ulong __ovld __cnfn popcount(ulong); +long2 __ovld __cnfn popcount(long2); +ulong2 __ovld __cnfn popcount(ulong2); +long3 __ovld __cnfn popcount(long3); +ulong3 __ovld __cnfn popcount(ulong3); +long4 __ovld __cnfn popcount(long4); +ulong4 __ovld __cnfn popcount(ulong4); +long8 __ovld __cnfn popcount(long8); +ulong8 __ovld __cnfn popcount(ulong8); +long16 __ovld __cnfn popcount(long16); +ulong16 __ovld __cnfn popcount(ulong16); +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) + +/** + * Multiply two 24-bit integer values x and y and add + * the 32-bit integer result to the 32-bit integer z. + * Refer to definition of mul24 to see how the 24-bit + * integer multiplication is performed. + */ +int __ovld __cnfn mad24(int, int, int); +uint __ovld __cnfn mad24(uint, uint, uint); +int2 __ovld __cnfn mad24(int2, int2, int2); +uint2 __ovld __cnfn mad24(uint2, uint2, uint2); +int3 __ovld __cnfn mad24(int3, int3, int3); +uint3 __ovld __cnfn mad24(uint3, uint3, uint3); +int4 __ovld __cnfn mad24(int4, int4, int4); +uint4 __ovld __cnfn mad24(uint4, uint4, uint4); +int8 __ovld __cnfn mad24(int8, int8, int8); +uint8 __ovld __cnfn mad24(uint8, uint8, uint8); +int16 __ovld __cnfn mad24(int16, int16, int16); +uint16 __ovld __cnfn mad24(uint16, uint16, uint16); + +/** + * Multiply two 24-bit integer values x and y. x and y + * are 32-bit integers but only the low 24-bits are used + * to perform the multiplication. mul24 should only + * be used when values in x and y are in the range [- + * 2^23, 2^23-1] if x and y are signed integers and in the + * range [0, 2^24-1] if x and y are unsigned integers. If + * x and y are not in this range, the multiplication + * result is implementation-defined. + */ +int __ovld __cnfn mul24(int, int); +uint __ovld __cnfn mul24(uint, uint); +int2 __ovld __cnfn mul24(int2, int2); +uint2 __ovld __cnfn mul24(uint2, uint2); +int3 __ovld __cnfn mul24(int3, int3); +uint3 __ovld __cnfn mul24(uint3, uint3); +int4 __ovld __cnfn mul24(int4, int4); +uint4 __ovld __cnfn mul24(uint4, uint4); +int8 __ovld __cnfn mul24(int8, int8); +uint8 __ovld __cnfn mul24(uint8, uint8); +int16 __ovld __cnfn mul24(int16, int16); +uint16 __ovld __cnfn mul24(uint16, uint16); + +// OpenCL v1.1 s6.11.4, v1.2 s6.12.4, v2.0 s6.13.4 - Common Functions + +/** + * Returns fmin(fmax(x, minval), maxval). + * Results are undefined if minval > maxval. + */ +float __ovld __cnfn clamp(float, float, float); +float2 __ovld __cnfn clamp(float2, float2, float2); +float3 __ovld __cnfn clamp(float3, float3, float3); +float4 __ovld __cnfn clamp(float4, float4, float4); +float8 __ovld __cnfn clamp(float8, float8, float8); +float16 __ovld __cnfn clamp(float16, float16, float16); +float2 __ovld __cnfn clamp(float2, float, float); +float3 __ovld __cnfn clamp(float3, float, float); +float4 __ovld __cnfn clamp(float4, float, float); +float8 __ovld __cnfn clamp(float8, float, float); +float16 __ovld __cnfn clamp(float16, float, float); +#ifdef cl_khr_fp64 +double __ovld __cnfn clamp(double, double, double); +double2 __ovld __cnfn clamp(double2, double2, double2); +double3 __ovld __cnfn clamp(double3, double3, double3); +double4 __ovld __cnfn clamp(double4, double4, double4); +double8 __ovld __cnfn clamp(double8, double8, double8); +double16 __ovld __cnfn clamp(double16, double16, double16); +double2 __ovld __cnfn clamp(double2, double, double); +double3 __ovld __cnfn clamp(double3, double, double); +double4 __ovld __cnfn clamp(double4, double, double); +double8 __ovld __cnfn clamp(double8, double, double); +double16 __ovld __cnfn clamp(double16, double, double); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn clamp(half, half, half); +half2 __ovld __cnfn clamp(half2, half2, half2); +half3 __ovld __cnfn clamp(half3, half3, half3); +half4 __ovld __cnfn clamp(half4, half4, half4); +half8 __ovld __cnfn clamp(half8, half8, half8); +half16 __ovld __cnfn clamp(half16, half16, half16); +half2 __ovld __cnfn clamp(half2, half, half); +half3 __ovld __cnfn clamp(half3, half, half); +half4 __ovld __cnfn clamp(half4, half, half); +half8 __ovld __cnfn clamp(half8, half, half); +half16 __ovld __cnfn clamp(half16, half, half); +#endif //cl_khr_fp16 + +/** + * Converts radians to degrees, i.e. (180 / PI) * + * radians. + */ +float __ovld __cnfn degrees(float); +float2 __ovld __cnfn degrees(float2); +float3 __ovld __cnfn degrees(float3); +float4 __ovld __cnfn degrees(float4); +float8 __ovld __cnfn degrees(float8); +float16 __ovld __cnfn degrees(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn degrees(double); +double2 __ovld __cnfn degrees(double2); +double3 __ovld __cnfn degrees(double3); +double4 __ovld __cnfn degrees(double4); +double8 __ovld __cnfn degrees(double8); +double16 __ovld __cnfn degrees(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn degrees(half); +half2 __ovld __cnfn degrees(half2); +half3 __ovld __cnfn degrees(half3); +half4 __ovld __cnfn degrees(half4); +half8 __ovld __cnfn degrees(half8); +half16 __ovld __cnfn degrees(half16); +#endif //cl_khr_fp16 + +/** + * Returns y if x < y, otherwise it returns x. If x and y + * are infinite or NaN, the return values are undefined. + */ +float __ovld __cnfn max(float, float); +float2 __ovld __cnfn max(float2, float2); +float3 __ovld __cnfn max(float3, float3); +float4 __ovld __cnfn max(float4, float4); +float8 __ovld __cnfn max(float8, float8); +float16 __ovld __cnfn max(float16, float16); +float2 __ovld __cnfn max(float2, float); +float3 __ovld __cnfn max(float3, float); +float4 __ovld __cnfn max(float4, float); +float8 __ovld __cnfn max(float8, float); +float16 __ovld __cnfn max(float16, float); +#ifdef cl_khr_fp64 +double __ovld __cnfn max(double, double); +double2 __ovld __cnfn max(double2, double2); +double3 __ovld __cnfn max(double3, double3); +double4 __ovld __cnfn max(double4, double4); +double8 __ovld __cnfn max(double8, double8); +double16 __ovld __cnfn max(double16, double16); +double2 __ovld __cnfn max(double2, double); +double3 __ovld __cnfn max(double3, double); +double4 __ovld __cnfn max(double4, double); +double8 __ovld __cnfn max(double8, double); +double16 __ovld __cnfn max(double16, double); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn max(half, half); +half2 __ovld __cnfn max(half2, half2); +half3 __ovld __cnfn max(half3, half3); +half4 __ovld __cnfn max(half4, half4); +half8 __ovld __cnfn max(half8, half8); +half16 __ovld __cnfn max(half16, half16); +half2 __ovld __cnfn max(half2, half); +half3 __ovld __cnfn max(half3, half); +half4 __ovld __cnfn max(half4, half); +half8 __ovld __cnfn max(half8, half); +half16 __ovld __cnfn max(half16, half); +#endif //cl_khr_fp16 + +/** + * Returns y if y < x, otherwise it returns x. If x and y + * are infinite or NaN, the return values are undefined. + */ +float __ovld __cnfn min(float, float); +float2 __ovld __cnfn min(float2, float2); +float3 __ovld __cnfn min(float3, float3); +float4 __ovld __cnfn min(float4, float4); +float8 __ovld __cnfn min(float8, float8); +float16 __ovld __cnfn min(float16, float16); +float2 __ovld __cnfn min(float2, float); +float3 __ovld __cnfn min(float3, float); +float4 __ovld __cnfn min(float4, float); +float8 __ovld __cnfn min(float8, float); +float16 __ovld __cnfn min(float16, float); +#ifdef cl_khr_fp64 +double __ovld __cnfn min(double, double); +double2 __ovld __cnfn min(double2, double2); +double3 __ovld __cnfn min(double3, double3); +double4 __ovld __cnfn min(double4, double4); +double8 __ovld __cnfn min(double8, double8); +double16 __ovld __cnfn min(double16, double16); +double2 __ovld __cnfn min(double2, double); +double3 __ovld __cnfn min(double3, double); +double4 __ovld __cnfn min(double4, double); +double8 __ovld __cnfn min(double8, double); +double16 __ovld __cnfn min(double16, double); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn min(half, half); +half2 __ovld __cnfn min(half2, half2); +half3 __ovld __cnfn min(half3, half3); +half4 __ovld __cnfn min(half4, half4); +half8 __ovld __cnfn min(half8, half8); +half16 __ovld __cnfn min(half16, half16); +half2 __ovld __cnfn min(half2, half); +half3 __ovld __cnfn min(half3, half); +half4 __ovld __cnfn min(half4, half); +half8 __ovld __cnfn min(half8, half); +half16 __ovld __cnfn min(half16, half); +#endif //cl_khr_fp16 + +/** + * Returns the linear blend of x & y implemented as: + * x + (y - x) * a + * a must be a value in the range 0.0 ... 1.0. If a is not + * in the range 0.0 ... 1.0, the return values are + * undefined. + */ +float __ovld __cnfn mix(float, float, float); +float2 __ovld __cnfn mix(float2, float2, float2); +float3 __ovld __cnfn mix(float3, float3, float3); +float4 __ovld __cnfn mix(float4, float4, float4); +float8 __ovld __cnfn mix(float8, float8, float8); +float16 __ovld __cnfn mix(float16, float16, float16); +float2 __ovld __cnfn mix(float2, float2, float); +float3 __ovld __cnfn mix(float3, float3, float); +float4 __ovld __cnfn mix(float4, float4, float); +float8 __ovld __cnfn mix(float8, float8, float); +float16 __ovld __cnfn mix(float16, float16, float); +#ifdef cl_khr_fp64 +double __ovld __cnfn mix(double, double, double); +double2 __ovld __cnfn mix(double2, double2, double2); +double3 __ovld __cnfn mix(double3, double3, double3); +double4 __ovld __cnfn mix(double4, double4, double4); +double8 __ovld __cnfn mix(double8, double8, double8); +double16 __ovld __cnfn mix(double16, double16, double16); +double2 __ovld __cnfn mix(double2, double2, double); +double3 __ovld __cnfn mix(double3, double3, double); +double4 __ovld __cnfn mix(double4, double4, double); +double8 __ovld __cnfn mix(double8, double8, double); +double16 __ovld __cnfn mix(double16, double16, double); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn mix(half, half, half); +half2 __ovld __cnfn mix(half2, half2, half2); +half3 __ovld __cnfn mix(half3, half3, half3); +half4 __ovld __cnfn mix(half4, half4, half4); +half8 __ovld __cnfn mix(half8, half8, half8); +half16 __ovld __cnfn mix(half16, half16, half16); +half2 __ovld __cnfn mix(half2, half2, half); +half3 __ovld __cnfn mix(half3, half3, half); +half4 __ovld __cnfn mix(half4, half4, half); +half8 __ovld __cnfn mix(half8, half8, half); +half16 __ovld __cnfn mix(half16, half16, half); +#endif //cl_khr_fp16 + +/** + * Converts degrees to radians, i.e. (PI / 180) * + * degrees. + */ +float __ovld __cnfn radians(float); +float2 __ovld __cnfn radians(float2); +float3 __ovld __cnfn radians(float3); +float4 __ovld __cnfn radians(float4); +float8 __ovld __cnfn radians(float8); +float16 __ovld __cnfn radians(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn radians(double); +double2 __ovld __cnfn radians(double2); +double3 __ovld __cnfn radians(double3); +double4 __ovld __cnfn radians(double4); +double8 __ovld __cnfn radians(double8); +double16 __ovld __cnfn radians(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn radians(half); +half2 __ovld __cnfn radians(half2); +half3 __ovld __cnfn radians(half3); +half4 __ovld __cnfn radians(half4); +half8 __ovld __cnfn radians(half8); +half16 __ovld __cnfn radians(half16); +#endif //cl_khr_fp16 + +/** + * Returns 0.0 if x < edge, otherwise it returns 1.0. + */ +float __ovld __cnfn step(float, float); +float2 __ovld __cnfn step(float2, float2); +float3 __ovld __cnfn step(float3, float3); +float4 __ovld __cnfn step(float4, float4); +float8 __ovld __cnfn step(float8, float8); +float16 __ovld __cnfn step(float16, float16); +float2 __ovld __cnfn step(float, float2); +float3 __ovld __cnfn step(float, float3); +float4 __ovld __cnfn step(float, float4); +float8 __ovld __cnfn step(float, float8); +float16 __ovld __cnfn step(float, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn step(double, double); +double2 __ovld __cnfn step(double2, double2); +double3 __ovld __cnfn step(double3, double3); +double4 __ovld __cnfn step(double4, double4); +double8 __ovld __cnfn step(double8, double8); +double16 __ovld __cnfn step(double16, double16); +double2 __ovld __cnfn step(double, double2); +double3 __ovld __cnfn step(double, double3); +double4 __ovld __cnfn step(double, double4); +double8 __ovld __cnfn step(double, double8); +double16 __ovld __cnfn step(double, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn step(half, half); +half2 __ovld __cnfn step(half2, half2); +half3 __ovld __cnfn step(half3, half3); +half4 __ovld __cnfn step(half4, half4); +half8 __ovld __cnfn step(half8, half8); +half16 __ovld __cnfn step(half16, half16); +half2 __ovld __cnfn step(half, half2); +half3 __ovld __cnfn step(half, half3); +half4 __ovld __cnfn step(half, half4); +half8 __ovld __cnfn step(half, half8); +half16 __ovld __cnfn step(half, half16); +#endif //cl_khr_fp16 + +/** + * Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and + * performs smooth Hermite interpolation between 0 + * and 1when edge0 < x < edge1. This is useful in + * cases where you would want a threshold function + * with a smooth transition. + * This is equivalent to: + * gentype t; + * t = clamp ((x - edge0) / (edge1 - edge0), 0, 1); + * return t * t * (3 - 2 * t); + * Results are undefined if edge0 >= edge1 or if x, + * edge0 or edge1 is a NaN. + */ +float __ovld __cnfn smoothstep(float, float, float); +float2 __ovld __cnfn smoothstep(float2, float2, float2); +float3 __ovld __cnfn smoothstep(float3, float3, float3); +float4 __ovld __cnfn smoothstep(float4, float4, float4); +float8 __ovld __cnfn smoothstep(float8, float8, float8); +float16 __ovld __cnfn smoothstep(float16, float16, float16); +float2 __ovld __cnfn smoothstep(float, float, float2); +float3 __ovld __cnfn smoothstep(float, float, float3); +float4 __ovld __cnfn smoothstep(float, float, float4); +float8 __ovld __cnfn smoothstep(float, float, float8); +float16 __ovld __cnfn smoothstep(float, float, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn smoothstep(double, double, double); +double2 __ovld __cnfn smoothstep(double2, double2, double2); +double3 __ovld __cnfn smoothstep(double3, double3, double3); +double4 __ovld __cnfn smoothstep(double4, double4, double4); +double8 __ovld __cnfn smoothstep(double8, double8, double8); +double16 __ovld __cnfn smoothstep(double16, double16, double16); +double2 __ovld __cnfn smoothstep(double, double, double2); +double3 __ovld __cnfn smoothstep(double, double, double3); +double4 __ovld __cnfn smoothstep(double, double, double4); +double8 __ovld __cnfn smoothstep(double, double, double8); +double16 __ovld __cnfn smoothstep(double, double, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn smoothstep(half, half, half); +half2 __ovld __cnfn smoothstep(half2, half2, half2); +half3 __ovld __cnfn smoothstep(half3, half3, half3); +half4 __ovld __cnfn smoothstep(half4, half4, half4); +half8 __ovld __cnfn smoothstep(half8, half8, half8); +half16 __ovld __cnfn smoothstep(half16, half16, half16); +half2 __ovld __cnfn smoothstep(half, half, half2); +half3 __ovld __cnfn smoothstep(half, half, half3); +half4 __ovld __cnfn smoothstep(half, half, half4); +half8 __ovld __cnfn smoothstep(half, half, half8); +half16 __ovld __cnfn smoothstep(half, half, half16); +#endif //cl_khr_fp16 + +/** + * Returns 1.0 if x > 0, -0.0 if x = -0.0, +0.0 if x = + * +0.0, or -1.0 if x < 0. Returns 0.0 if x is a NaN. + */ +float __ovld __cnfn sign(float); +float2 __ovld __cnfn sign(float2); +float3 __ovld __cnfn sign(float3); +float4 __ovld __cnfn sign(float4); +float8 __ovld __cnfn sign(float8); +float16 __ovld __cnfn sign(float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn sign(double); +double2 __ovld __cnfn sign(double2); +double3 __ovld __cnfn sign(double3); +double4 __ovld __cnfn sign(double4); +double8 __ovld __cnfn sign(double8); +double16 __ovld __cnfn sign(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn sign(half); +half2 __ovld __cnfn sign(half2); +half3 __ovld __cnfn sign(half3); +half4 __ovld __cnfn sign(half4); +half8 __ovld __cnfn sign(half8); +half16 __ovld __cnfn sign(half16); +#endif //cl_khr_fp16 + +// OpenCL v1.1 s6.11.5, v1.2 s6.12.5, v2.0 s6.13.5 - Geometric Functions + +/** + * Returns the cross product of p0.xyz and p1.xyz. The + * w component of float4 result returned will be 0.0. + */ +float4 __ovld __cnfn cross(float4, float4); +float3 __ovld __cnfn cross(float3, float3); +#ifdef cl_khr_fp64 +double4 __ovld __cnfn cross(double4, double4); +double3 __ovld __cnfn cross(double3, double3); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half4 __ovld __cnfn cross(half4, half4); +half3 __ovld __cnfn cross(half3, half3); +#endif //cl_khr_fp16 + +/** + * Compute dot product. + */ +float __ovld __cnfn dot(float, float); +float __ovld __cnfn dot(float2, float2); +float __ovld __cnfn dot(float3, float3); +float __ovld __cnfn dot(float4, float4); +#ifdef cl_khr_fp64 +double __ovld __cnfn dot(double, double); +double __ovld __cnfn dot(double2, double2); +double __ovld __cnfn dot(double3, double3); +double __ovld __cnfn dot(double4, double4); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn dot(half, half); +half __ovld __cnfn dot(half2, half2); +half __ovld __cnfn dot(half3, half3); +half __ovld __cnfn dot(half4, half4); +#endif //cl_khr_fp16 + +/** + * Returns the distance between p0 and p1. This is + * calculated as length(p0 - p1). + */ +float __ovld __cnfn distance(float, float); +float __ovld __cnfn distance(float2, float2); +float __ovld __cnfn distance(float3, float3); +float __ovld __cnfn distance(float4, float4); +#ifdef cl_khr_fp64 +double __ovld __cnfn distance(double, double); +double __ovld __cnfn distance(double2, double2); +double __ovld __cnfn distance(double3, double3); +double __ovld __cnfn distance(double4, double4); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn distance(half, half); +half __ovld __cnfn distance(half2, half2); +half __ovld __cnfn distance(half3, half3); +half __ovld __cnfn distance(half4, half4); +#endif //cl_khr_fp16 + +/** + * Return the length of vector p, i.e., + * sqrt(p.x2 + p.y 2 + ...) + */ +float __ovld __cnfn length(float); +float __ovld __cnfn length(float2); +float __ovld __cnfn length(float3); +float __ovld __cnfn length(float4); +#ifdef cl_khr_fp64 +double __ovld __cnfn length(double); +double __ovld __cnfn length(double2); +double __ovld __cnfn length(double3); +double __ovld __cnfn length(double4); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn length(half); +half __ovld __cnfn length(half2); +half __ovld __cnfn length(half3); +half __ovld __cnfn length(half4); +#endif //cl_khr_fp16 + +/** + * Returns a vector in the same direction as p but with a + * length of 1. + */ +float __ovld __cnfn normalize(float); +float2 __ovld __cnfn normalize(float2); +float3 __ovld __cnfn normalize(float3); +float4 __ovld __cnfn normalize(float4); +#ifdef cl_khr_fp64 +double __ovld __cnfn normalize(double); +double2 __ovld __cnfn normalize(double2); +double3 __ovld __cnfn normalize(double3); +double4 __ovld __cnfn normalize(double4); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn normalize(half); +half2 __ovld __cnfn normalize(half2); +half3 __ovld __cnfn normalize(half3); +half4 __ovld __cnfn normalize(half4); +#endif //cl_khr_fp16 + +/** + * Returns fast_length(p0 - p1). + */ +float __ovld __cnfn fast_distance(float, float); +float __ovld __cnfn fast_distance(float2, float2); +float __ovld __cnfn fast_distance(float3, float3); +float __ovld __cnfn fast_distance(float4, float4); + +/** + * Returns the length of vector p computed as: + * half_sqrt(p.x2 + p.y2 + ...) + */ +float __ovld __cnfn fast_length(float); +float __ovld __cnfn fast_length(float2); +float __ovld __cnfn fast_length(float3); +float __ovld __cnfn fast_length(float4); + +/** + * Returns a vector in the same direction as p but with a + * length of 1. fast_normalize is computed as: + * p * half_rsqrt (p.x^2 + p.y^2 + ... ) + * The result shall be within 8192 ulps error from the + * infinitely precise result of + * if (all(p == 0.0f)) + * result = p; + * else + * result = p / sqrt (p.x^2 + p.y^2 + ...); + * with the following exceptions: + * 1) If the sum of squares is greater than FLT_MAX + * then the value of the floating-point values in the + * result vector are undefined. + * 2) If the sum of squares is less than FLT_MIN then + * the implementation may return back p. + * 3) If the device is in "denorms are flushed to zero" + * mode, individual operand elements with magnitude + * less than sqrt(FLT_MIN) may be flushed to zero + * before proceeding with the calculation. + */ +float __ovld __cnfn fast_normalize(float); +float2 __ovld __cnfn fast_normalize(float2); +float3 __ovld __cnfn fast_normalize(float3); +float4 __ovld __cnfn fast_normalize(float4); + +// OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions + +/** + * intn isequal (floatn x, floatn y) + * Returns the component-wise compare of x == y. + */ +int __ovld __cnfn isequal(float, float); +int2 __ovld __cnfn isequal(float2, float2); +int3 __ovld __cnfn isequal(float3, float3); +int4 __ovld __cnfn isequal(float4, float4); +int8 __ovld __cnfn isequal(float8, float8); +int16 __ovld __cnfn isequal(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isequal(double, double); +long2 __ovld __cnfn isequal(double2, double2); +long3 __ovld __cnfn isequal(double3, double3); +long4 __ovld __cnfn isequal(double4, double4); +long8 __ovld __cnfn isequal(double8, double8); +long16 __ovld __cnfn isequal(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isequal(half, half); +short2 __ovld __cnfn isequal(half2, half2); +short3 __ovld __cnfn isequal(half3, half3); +short4 __ovld __cnfn isequal(half4, half4); +short8 __ovld __cnfn isequal(half8, half8); +short16 __ovld __cnfn isequal(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns the component-wise compare of x != y. + */ +int __ovld __cnfn isnotequal(float, float); +int2 __ovld __cnfn isnotequal(float2, float2); +int3 __ovld __cnfn isnotequal(float3, float3); +int4 __ovld __cnfn isnotequal(float4, float4); +int8 __ovld __cnfn isnotequal(float8, float8); +int16 __ovld __cnfn isnotequal(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isnotequal(double, double); +long2 __ovld __cnfn isnotequal(double2, double2); +long3 __ovld __cnfn isnotequal(double3, double3); +long4 __ovld __cnfn isnotequal(double4, double4); +long8 __ovld __cnfn isnotequal(double8, double8); +long16 __ovld __cnfn isnotequal(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isnotequal(half, half); +short2 __ovld __cnfn isnotequal(half2, half2); +short3 __ovld __cnfn isnotequal(half3, half3); +short4 __ovld __cnfn isnotequal(half4, half4); +short8 __ovld __cnfn isnotequal(half8, half8); +short16 __ovld __cnfn isnotequal(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns the component-wise compare of x > y. + */ +int __ovld __cnfn isgreater(float, float); +int2 __ovld __cnfn isgreater(float2, float2); +int3 __ovld __cnfn isgreater(float3, float3); +int4 __ovld __cnfn isgreater(float4, float4); +int8 __ovld __cnfn isgreater(float8, float8); +int16 __ovld __cnfn isgreater(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isgreater(double, double); +long2 __ovld __cnfn isgreater(double2, double2); +long3 __ovld __cnfn isgreater(double3, double3); +long4 __ovld __cnfn isgreater(double4, double4); +long8 __ovld __cnfn isgreater(double8, double8); +long16 __ovld __cnfn isgreater(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isgreater(half, half); +short2 __ovld __cnfn isgreater(half2, half2); +short3 __ovld __cnfn isgreater(half3, half3); +short4 __ovld __cnfn isgreater(half4, half4); +short8 __ovld __cnfn isgreater(half8, half8); +short16 __ovld __cnfn isgreater(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns the component-wise compare of x >= y. + */ +int __ovld __cnfn isgreaterequal(float, float); +int2 __ovld __cnfn isgreaterequal(float2, float2); +int3 __ovld __cnfn isgreaterequal(float3, float3); +int4 __ovld __cnfn isgreaterequal(float4, float4); +int8 __ovld __cnfn isgreaterequal(float8, float8); +int16 __ovld __cnfn isgreaterequal(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isgreaterequal(double, double); +long2 __ovld __cnfn isgreaterequal(double2, double2); +long3 __ovld __cnfn isgreaterequal(double3, double3); +long4 __ovld __cnfn isgreaterequal(double4, double4); +long8 __ovld __cnfn isgreaterequal(double8, double8); +long16 __ovld __cnfn isgreaterequal(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isgreaterequal(half, half); +short2 __ovld __cnfn isgreaterequal(half2, half2); +short3 __ovld __cnfn isgreaterequal(half3, half3); +short4 __ovld __cnfn isgreaterequal(half4, half4); +short8 __ovld __cnfn isgreaterequal(half8, half8); +short16 __ovld __cnfn isgreaterequal(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns the component-wise compare of x < y. + */ +int __ovld __cnfn isless(float, float); +int2 __ovld __cnfn isless(float2, float2); +int3 __ovld __cnfn isless(float3, float3); +int4 __ovld __cnfn isless(float4, float4); +int8 __ovld __cnfn isless(float8, float8); +int16 __ovld __cnfn isless(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isless(double, double); +long2 __ovld __cnfn isless(double2, double2); +long3 __ovld __cnfn isless(double3, double3); +long4 __ovld __cnfn isless(double4, double4); +long8 __ovld __cnfn isless(double8, double8); +long16 __ovld __cnfn isless(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isless(half, half); +short2 __ovld __cnfn isless(half2, half2); +short3 __ovld __cnfn isless(half3, half3); +short4 __ovld __cnfn isless(half4, half4); +short8 __ovld __cnfn isless(half8, half8); +short16 __ovld __cnfn isless(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns the component-wise compare of x <= y. + */ +int __ovld __cnfn islessequal(float, float); +int2 __ovld __cnfn islessequal(float2, float2); +int3 __ovld __cnfn islessequal(float3, float3); +int4 __ovld __cnfn islessequal(float4, float4); +int8 __ovld __cnfn islessequal(float8, float8); +int16 __ovld __cnfn islessequal(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn islessequal(double, double); +long2 __ovld __cnfn islessequal(double2, double2); +long3 __ovld __cnfn islessequal(double3, double3); +long4 __ovld __cnfn islessequal(double4, double4); +long8 __ovld __cnfn islessequal(double8, double8); +long16 __ovld __cnfn islessequal(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn islessequal(half, half); +short2 __ovld __cnfn islessequal(half2, half2); +short3 __ovld __cnfn islessequal(half3, half3); +short4 __ovld __cnfn islessequal(half4, half4); +short8 __ovld __cnfn islessequal(half8, half8); +short16 __ovld __cnfn islessequal(half16, half16); +#endif //cl_khr_fp16 + +/** + * Returns the component-wise compare of + * (x < y) || (x > y) . + */ +int __ovld __cnfn islessgreater(float, float); +int2 __ovld __cnfn islessgreater(float2, float2); +int3 __ovld __cnfn islessgreater(float3, float3); +int4 __ovld __cnfn islessgreater(float4, float4); +int8 __ovld __cnfn islessgreater(float8, float8); +int16 __ovld __cnfn islessgreater(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn islessgreater(double, double); +long2 __ovld __cnfn islessgreater(double2, double2); +long3 __ovld __cnfn islessgreater(double3, double3); +long4 __ovld __cnfn islessgreater(double4, double4); +long8 __ovld __cnfn islessgreater(double8, double8); +long16 __ovld __cnfn islessgreater(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn islessgreater(half, half); +short2 __ovld __cnfn islessgreater(half2, half2); +short3 __ovld __cnfn islessgreater(half3, half3); +short4 __ovld __cnfn islessgreater(half4, half4); +short8 __ovld __cnfn islessgreater(half8, half8); +short16 __ovld __cnfn islessgreater(half16, half16); +#endif //cl_khr_fp16 + +/** + * Test for finite value. + */ +int __ovld __cnfn isfinite(float); +int2 __ovld __cnfn isfinite(float2); +int3 __ovld __cnfn isfinite(float3); +int4 __ovld __cnfn isfinite(float4); +int8 __ovld __cnfn isfinite(float8); +int16 __ovld __cnfn isfinite(float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isfinite(double); +long2 __ovld __cnfn isfinite(double2); +long3 __ovld __cnfn isfinite(double3); +long4 __ovld __cnfn isfinite(double4); +long8 __ovld __cnfn isfinite(double8); +long16 __ovld __cnfn isfinite(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isfinite(half); +short2 __ovld __cnfn isfinite(half2); +short3 __ovld __cnfn isfinite(half3); +short4 __ovld __cnfn isfinite(half4); +short8 __ovld __cnfn isfinite(half8); +short16 __ovld __cnfn isfinite(half16); +#endif //cl_khr_fp16 + +/** + * Test for infinity value (+ve or -ve) . + */ +int __ovld __cnfn isinf(float); +int2 __ovld __cnfn isinf(float2); +int3 __ovld __cnfn isinf(float3); +int4 __ovld __cnfn isinf(float4); +int8 __ovld __cnfn isinf(float8); +int16 __ovld __cnfn isinf(float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isinf(double); +long2 __ovld __cnfn isinf(double2); +long3 __ovld __cnfn isinf(double3); +long4 __ovld __cnfn isinf(double4); +long8 __ovld __cnfn isinf(double8); +long16 __ovld __cnfn isinf(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isinf(half); +short2 __ovld __cnfn isinf(half2); +short3 __ovld __cnfn isinf(half3); +short4 __ovld __cnfn isinf(half4); +short8 __ovld __cnfn isinf(half8); +short16 __ovld __cnfn isinf(half16); +#endif //cl_khr_fp16 + +/** + * Test for a NaN. + */ +int __ovld __cnfn isnan(float); +int2 __ovld __cnfn isnan(float2); +int3 __ovld __cnfn isnan(float3); +int4 __ovld __cnfn isnan(float4); +int8 __ovld __cnfn isnan(float8); +int16 __ovld __cnfn isnan(float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isnan(double); +long2 __ovld __cnfn isnan(double2); +long3 __ovld __cnfn isnan(double3); +long4 __ovld __cnfn isnan(double4); +long8 __ovld __cnfn isnan(double8); +long16 __ovld __cnfn isnan(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isnan(half); +short2 __ovld __cnfn isnan(half2); +short3 __ovld __cnfn isnan(half3); +short4 __ovld __cnfn isnan(half4); +short8 __ovld __cnfn isnan(half8); +short16 __ovld __cnfn isnan(half16); +#endif //cl_khr_fp16 + +/** + * Test for a normal value. + */ +int __ovld __cnfn isnormal(float); +int2 __ovld __cnfn isnormal(float2); +int3 __ovld __cnfn isnormal(float3); +int4 __ovld __cnfn isnormal(float4); +int8 __ovld __cnfn isnormal(float8); +int16 __ovld __cnfn isnormal(float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isnormal(double); +long2 __ovld __cnfn isnormal(double2); +long3 __ovld __cnfn isnormal(double3); +long4 __ovld __cnfn isnormal(double4); +long8 __ovld __cnfn isnormal(double8); +long16 __ovld __cnfn isnormal(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isnormal(half); +short2 __ovld __cnfn isnormal(half2); +short3 __ovld __cnfn isnormal(half3); +short4 __ovld __cnfn isnormal(half4); +short8 __ovld __cnfn isnormal(half8); +short16 __ovld __cnfn isnormal(half16); +#endif //cl_khr_fp16 + +/** + * Test if arguments are ordered. isordered() takes + * arguments x and y, and returns the result + * isequal(x, x) && isequal(y, y). + */ +int __ovld __cnfn isordered(float, float); +int2 __ovld __cnfn isordered(float2, float2); +int3 __ovld __cnfn isordered(float3, float3); +int4 __ovld __cnfn isordered(float4, float4); +int8 __ovld __cnfn isordered(float8, float8); +int16 __ovld __cnfn isordered(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isordered(double, double); +long2 __ovld __cnfn isordered(double2, double2); +long3 __ovld __cnfn isordered(double3, double3); +long4 __ovld __cnfn isordered(double4, double4); +long8 __ovld __cnfn isordered(double8, double8); +long16 __ovld __cnfn isordered(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isordered(half, half); +short2 __ovld __cnfn isordered(half2, half2); +short3 __ovld __cnfn isordered(half3, half3); +short4 __ovld __cnfn isordered(half4, half4); +short8 __ovld __cnfn isordered(half8, half8); +short16 __ovld __cnfn isordered(half16, half16); +#endif //cl_khr_fp16 + +/** + * Test if arguments are unordered. isunordered() + * takes arguments x and y, returning non-zero if x or y + * is NaN, and zero otherwise. + */ +int __ovld __cnfn isunordered(float, float); +int2 __ovld __cnfn isunordered(float2, float2); +int3 __ovld __cnfn isunordered(float3, float3); +int4 __ovld __cnfn isunordered(float4, float4); +int8 __ovld __cnfn isunordered(float8, float8); +int16 __ovld __cnfn isunordered(float16, float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn isunordered(double, double); +long2 __ovld __cnfn isunordered(double2, double2); +long3 __ovld __cnfn isunordered(double3, double3); +long4 __ovld __cnfn isunordered(double4, double4); +long8 __ovld __cnfn isunordered(double8, double8); +long16 __ovld __cnfn isunordered(double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn isunordered(half, half); +short2 __ovld __cnfn isunordered(half2, half2); +short3 __ovld __cnfn isunordered(half3, half3); +short4 __ovld __cnfn isunordered(half4, half4); +short8 __ovld __cnfn isunordered(half8, half8); +short16 __ovld __cnfn isunordered(half16, half16); +#endif //cl_khr_fp16 + +/** + * Test for sign bit. The scalar version of the function + * returns a 1 if the sign bit in the float is set else returns + * 0. The vector version of the function returns the + * following for each component in floatn: a -1 if the + * sign bit in the float is set else returns 0. + */ +int __ovld __cnfn signbit(float); +int2 __ovld __cnfn signbit(float2); +int3 __ovld __cnfn signbit(float3); +int4 __ovld __cnfn signbit(float4); +int8 __ovld __cnfn signbit(float8); +int16 __ovld __cnfn signbit(float16); +#ifdef cl_khr_fp64 +int __ovld __cnfn signbit(double); +long2 __ovld __cnfn signbit(double2); +long3 __ovld __cnfn signbit(double3); +long4 __ovld __cnfn signbit(double4); +long8 __ovld __cnfn signbit(double8); +long16 __ovld __cnfn signbit(double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +int __ovld __cnfn signbit(half); +short2 __ovld __cnfn signbit(half2); +short3 __ovld __cnfn signbit(half3); +short4 __ovld __cnfn signbit(half4); +short8 __ovld __cnfn signbit(half8); +short16 __ovld __cnfn signbit(half16); +#endif //cl_khr_fp16 + +/** + * Returns 1 if the most significant bit in any component + * of x is set; otherwise returns 0. + */ +int __ovld __cnfn any(char); +int __ovld __cnfn any(char2); +int __ovld __cnfn any(char3); +int __ovld __cnfn any(char4); +int __ovld __cnfn any(char8); +int __ovld __cnfn any(char16); +int __ovld __cnfn any(short); +int __ovld __cnfn any(short2); +int __ovld __cnfn any(short3); +int __ovld __cnfn any(short4); +int __ovld __cnfn any(short8); +int __ovld __cnfn any(short16); +int __ovld __cnfn any(int); +int __ovld __cnfn any(int2); +int __ovld __cnfn any(int3); +int __ovld __cnfn any(int4); +int __ovld __cnfn any(int8); +int __ovld __cnfn any(int16); +int __ovld __cnfn any(long); +int __ovld __cnfn any(long2); +int __ovld __cnfn any(long3); +int __ovld __cnfn any(long4); +int __ovld __cnfn any(long8); +int __ovld __cnfn any(long16); + +/** + * Returns 1 if the most significant bit in all components + * of x is set; otherwise returns 0. + */ +int __ovld __cnfn all(char); +int __ovld __cnfn all(char2); +int __ovld __cnfn all(char3); +int __ovld __cnfn all(char4); +int __ovld __cnfn all(char8); +int __ovld __cnfn all(char16); +int __ovld __cnfn all(short); +int __ovld __cnfn all(short2); +int __ovld __cnfn all(short3); +int __ovld __cnfn all(short4); +int __ovld __cnfn all(short8); +int __ovld __cnfn all(short16); +int __ovld __cnfn all(int); +int __ovld __cnfn all(int2); +int __ovld __cnfn all(int3); +int __ovld __cnfn all(int4); +int __ovld __cnfn all(int8); +int __ovld __cnfn all(int16); +int __ovld __cnfn all(long); +int __ovld __cnfn all(long2); +int __ovld __cnfn all(long3); +int __ovld __cnfn all(long4); +int __ovld __cnfn all(long8); +int __ovld __cnfn all(long16); + +/** + * Each bit of the result is the corresponding bit of a if + * the corresponding bit of c is 0. Otherwise it is the + * corresponding bit of b. + */ +char __ovld __cnfn bitselect(char, char, char); +uchar __ovld __cnfn bitselect(uchar, uchar, uchar); +char2 __ovld __cnfn bitselect(char2, char2, char2); +uchar2 __ovld __cnfn bitselect(uchar2, uchar2, uchar2); +char3 __ovld __cnfn bitselect(char3, char3, char3); +uchar3 __ovld __cnfn bitselect(uchar3, uchar3, uchar3); +char4 __ovld __cnfn bitselect(char4, char4, char4); +uchar4 __ovld __cnfn bitselect(uchar4, uchar4, uchar4); +char8 __ovld __cnfn bitselect(char8, char8, char8); +uchar8 __ovld __cnfn bitselect(uchar8, uchar8, uchar8); +char16 __ovld __cnfn bitselect(char16, char16, char16); +uchar16 __ovld __cnfn bitselect(uchar16, uchar16, uchar16); +short __ovld __cnfn bitselect(short, short, short); +ushort __ovld __cnfn bitselect(ushort, ushort, ushort); +short2 __ovld __cnfn bitselect(short2, short2, short2); +ushort2 __ovld __cnfn bitselect(ushort2, ushort2, ushort2); +short3 __ovld __cnfn bitselect(short3, short3, short3); +ushort3 __ovld __cnfn bitselect(ushort3, ushort3, ushort3); +short4 __ovld __cnfn bitselect(short4, short4, short4); +ushort4 __ovld __cnfn bitselect(ushort4, ushort4, ushort4); +short8 __ovld __cnfn bitselect(short8, short8, short8); +ushort8 __ovld __cnfn bitselect(ushort8, ushort8, ushort8); +short16 __ovld __cnfn bitselect(short16, short16, short16); +ushort16 __ovld __cnfn bitselect(ushort16, ushort16, ushort16); +int __ovld __cnfn bitselect(int, int, int); +uint __ovld __cnfn bitselect(uint, uint, uint); +int2 __ovld __cnfn bitselect(int2, int2, int2); +uint2 __ovld __cnfn bitselect(uint2, uint2, uint2); +int3 __ovld __cnfn bitselect(int3, int3, int3); +uint3 __ovld __cnfn bitselect(uint3, uint3, uint3); +int4 __ovld __cnfn bitselect(int4, int4, int4); +uint4 __ovld __cnfn bitselect(uint4, uint4, uint4); +int8 __ovld __cnfn bitselect(int8, int8, int8); +uint8 __ovld __cnfn bitselect(uint8, uint8, uint8); +int16 __ovld __cnfn bitselect(int16, int16, int16); +uint16 __ovld __cnfn bitselect(uint16, uint16, uint16); +long __ovld __cnfn bitselect(long, long, long); +ulong __ovld __cnfn bitselect(ulong, ulong, ulong); +long2 __ovld __cnfn bitselect(long2, long2, long2); +ulong2 __ovld __cnfn bitselect(ulong2, ulong2, ulong2); +long3 __ovld __cnfn bitselect(long3, long3, long3); +ulong3 __ovld __cnfn bitselect(ulong3, ulong3, ulong3); +long4 __ovld __cnfn bitselect(long4, long4, long4); +ulong4 __ovld __cnfn bitselect(ulong4, ulong4, ulong4); +long8 __ovld __cnfn bitselect(long8, long8, long8); +ulong8 __ovld __cnfn bitselect(ulong8, ulong8, ulong8); +long16 __ovld __cnfn bitselect(long16, long16, long16); +ulong16 __ovld __cnfn bitselect(ulong16, ulong16, ulong16); +float __ovld __cnfn bitselect(float, float, float); +float2 __ovld __cnfn bitselect(float2, float2, float2); +float3 __ovld __cnfn bitselect(float3, float3, float3); +float4 __ovld __cnfn bitselect(float4, float4, float4); +float8 __ovld __cnfn bitselect(float8, float8, float8); +float16 __ovld __cnfn bitselect(float16, float16, float16); +#ifdef cl_khr_fp64 +double __ovld __cnfn bitselect(double, double, double); +double2 __ovld __cnfn bitselect(double2, double2, double2); +double3 __ovld __cnfn bitselect(double3, double3, double3); +double4 __ovld __cnfn bitselect(double4, double4, double4); +double8 __ovld __cnfn bitselect(double8, double8, double8); +double16 __ovld __cnfn bitselect(double16, double16, double16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn bitselect(half, half, half); +half2 __ovld __cnfn bitselect(half2, half2, half2); +half3 __ovld __cnfn bitselect(half3, half3, half3); +half4 __ovld __cnfn bitselect(half4, half4, half4); +half8 __ovld __cnfn bitselect(half8, half8, half8); +half16 __ovld __cnfn bitselect(half16, half16, half16); +#endif //cl_khr_fp16 + +/** + * For each component of a vector type, + * result[i] = if MSB of c[i] is set ? b[i] : a[i]. + * For a scalar type, result = c ? b : a. + * b and a must have the same type. + * c must have the same number of elements and bits as a. + */ +char __ovld __cnfn select(char, char, char); +uchar __ovld __cnfn select(uchar, uchar, char); +char2 __ovld __cnfn select(char2, char2, char2); +uchar2 __ovld __cnfn select(uchar2, uchar2, char2); +char3 __ovld __cnfn select(char3, char3, char3); +uchar3 __ovld __cnfn select(uchar3, uchar3, char3); +char4 __ovld __cnfn select(char4, char4, char4); +uchar4 __ovld __cnfn select(uchar4, uchar4, char4); +char8 __ovld __cnfn select(char8, char8, char8); +uchar8 __ovld __cnfn select(uchar8, uchar8, char8); +char16 __ovld __cnfn select(char16, char16, char16); +uchar16 __ovld __cnfn select(uchar16, uchar16, char16); + +short __ovld __cnfn select(short, short, short); +ushort __ovld __cnfn select(ushort, ushort, short); +short2 __ovld __cnfn select(short2, short2, short2); +ushort2 __ovld __cnfn select(ushort2, ushort2, short2); +short3 __ovld __cnfn select(short3, short3, short3); +ushort3 __ovld __cnfn select(ushort3, ushort3, short3); +short4 __ovld __cnfn select(short4, short4, short4); +ushort4 __ovld __cnfn select(ushort4, ushort4, short4); +short8 __ovld __cnfn select(short8, short8, short8); +ushort8 __ovld __cnfn select(ushort8, ushort8, short8); +short16 __ovld __cnfn select(short16, short16, short16); +ushort16 __ovld __cnfn select(ushort16, ushort16, short16); + +int __ovld __cnfn select(int, int, int); +uint __ovld __cnfn select(uint, uint, int); +int2 __ovld __cnfn select(int2, int2, int2); +uint2 __ovld __cnfn select(uint2, uint2, int2); +int3 __ovld __cnfn select(int3, int3, int3); +uint3 __ovld __cnfn select(uint3, uint3, int3); +int4 __ovld __cnfn select(int4, int4, int4); +uint4 __ovld __cnfn select(uint4, uint4, int4); +int8 __ovld __cnfn select(int8, int8, int8); +uint8 __ovld __cnfn select(uint8, uint8, int8); +int16 __ovld __cnfn select(int16, int16, int16); +uint16 __ovld __cnfn select(uint16, uint16, int16); +float __ovld __cnfn select(float, float, int); +float2 __ovld __cnfn select(float2, float2, int2); +float3 __ovld __cnfn select(float3, float3, int3); +float4 __ovld __cnfn select(float4, float4, int4); +float8 __ovld __cnfn select(float8, float8, int8); +float16 __ovld __cnfn select(float16, float16, int16); + +long __ovld __cnfn select(long, long, long); +ulong __ovld __cnfn select(ulong, ulong, long); +long2 __ovld __cnfn select(long2, long2, long2); +ulong2 __ovld __cnfn select(ulong2, ulong2, long2); +long3 __ovld __cnfn select(long3, long3, long3); +ulong3 __ovld __cnfn select(ulong3, ulong3, long3); +long4 __ovld __cnfn select(long4, long4, long4); +ulong4 __ovld __cnfn select(ulong4, ulong4, long4); +long8 __ovld __cnfn select(long8, long8, long8); +ulong8 __ovld __cnfn select(ulong8, ulong8, long8); +long16 __ovld __cnfn select(long16, long16, long16); +ulong16 __ovld __cnfn select(ulong16, ulong16, long16); + +char __ovld __cnfn select(char, char, uchar); +uchar __ovld __cnfn select(uchar, uchar, uchar); +char2 __ovld __cnfn select(char2, char2, uchar2); +uchar2 __ovld __cnfn select(uchar2, uchar2, uchar2); +char3 __ovld __cnfn select(char3, char3, uchar3); +uchar3 __ovld __cnfn select(uchar3, uchar3, uchar3); +char4 __ovld __cnfn select(char4, char4, uchar4); +uchar4 __ovld __cnfn select(uchar4, uchar4, uchar4); +char8 __ovld __cnfn select(char8, char8, uchar8); +uchar8 __ovld __cnfn select(uchar8, uchar8, uchar8); +char16 __ovld __cnfn select(char16, char16, uchar16); +uchar16 __ovld __cnfn select(uchar16, uchar16, uchar16); + +short __ovld __cnfn select(short, short, ushort); +ushort __ovld __cnfn select(ushort, ushort, ushort); +short2 __ovld __cnfn select(short2, short2, ushort2); +ushort2 __ovld __cnfn select(ushort2, ushort2, ushort2); +short3 __ovld __cnfn select(short3, short3, ushort3); +ushort3 __ovld __cnfn select(ushort3, ushort3, ushort3); +short4 __ovld __cnfn select(short4, short4, ushort4); +ushort4 __ovld __cnfn select(ushort4, ushort4, ushort4); +short8 __ovld __cnfn select(short8, short8, ushort8); +ushort8 __ovld __cnfn select(ushort8, ushort8, ushort8); +short16 __ovld __cnfn select(short16, short16, ushort16); +ushort16 __ovld __cnfn select(ushort16, ushort16, ushort16); + +int __ovld __cnfn select(int, int, uint); +uint __ovld __cnfn select(uint, uint, uint); +int2 __ovld __cnfn select(int2, int2, uint2); +uint2 __ovld __cnfn select(uint2, uint2, uint2); +int3 __ovld __cnfn select(int3, int3, uint3); +uint3 __ovld __cnfn select(uint3, uint3, uint3); +int4 __ovld __cnfn select(int4, int4, uint4); +uint4 __ovld __cnfn select(uint4, uint4, uint4); +int8 __ovld __cnfn select(int8, int8, uint8); +uint8 __ovld __cnfn select(uint8, uint8, uint8); +int16 __ovld __cnfn select(int16, int16, uint16); +uint16 __ovld __cnfn select(uint16, uint16, uint16); +float __ovld __cnfn select(float, float, uint); +float2 __ovld __cnfn select(float2, float2, uint2); +float3 __ovld __cnfn select(float3, float3, uint3); +float4 __ovld __cnfn select(float4, float4, uint4); +float8 __ovld __cnfn select(float8, float8, uint8); +float16 __ovld __cnfn select(float16, float16, uint16); + +long __ovld __cnfn select(long, long, ulong); +ulong __ovld __cnfn select(ulong, ulong, ulong); +long2 __ovld __cnfn select(long2, long2, ulong2); +ulong2 __ovld __cnfn select(ulong2, ulong2, ulong2); +long3 __ovld __cnfn select(long3, long3, ulong3); +ulong3 __ovld __cnfn select(ulong3, ulong3, ulong3); +long4 __ovld __cnfn select(long4, long4, ulong4); +ulong4 __ovld __cnfn select(ulong4, ulong4, ulong4); +long8 __ovld __cnfn select(long8, long8, ulong8); +ulong8 __ovld __cnfn select(ulong8, ulong8, ulong8); +long16 __ovld __cnfn select(long16, long16, ulong16); +ulong16 __ovld __cnfn select(ulong16, ulong16, ulong16); + +#ifdef cl_khr_fp64 +double __ovld __cnfn select(double, double, long); +double2 __ovld __cnfn select(double2, double2, long2); +double3 __ovld __cnfn select(double3, double3, long3); +double4 __ovld __cnfn select(double4, double4, long4); +double8 __ovld __cnfn select(double8, double8, long8); +double16 __ovld __cnfn select(double16, double16, long16); +double __ovld __cnfn select(double, double, ulong); +double2 __ovld __cnfn select(double2, double2, ulong2); +double3 __ovld __cnfn select(double3, double3, ulong3); +double4 __ovld __cnfn select(double4, double4, ulong4); +double8 __ovld __cnfn select(double8, double8, ulong8); +double16 __ovld __cnfn select(double16, double16, ulong16); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +half __ovld __cnfn select(half, half, short); +half2 __ovld __cnfn select(half2, half2, short2); +half3 __ovld __cnfn select(half3, half3, short3); +half4 __ovld __cnfn select(half4, half4, short4); +half8 __ovld __cnfn select(half8, half8, short8); +half16 __ovld __cnfn select(half16, half16, short16); +half __ovld __cnfn select(half, half, ushort); +half2 __ovld __cnfn select(half2, half2, ushort2); +half3 __ovld __cnfn select(half3, half3, ushort3); +half4 __ovld __cnfn select(half4, half4, ushort4); +half8 __ovld __cnfn select(half8, half8, ushort8); +half16 __ovld __cnfn select(half16, half16, ushort16); +#endif //cl_khr_fp16 + +// OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions +// OpenCL extensions v1.1 s9.6.6, v1.2 s9.5.6, v2.0 s9.4.6 - Vector Data Load and Store Functions for Half Type +/** + * Use generic type gentype to indicate the built-in data types + * char, uchar, short, ushort, int, uint, long, ulong, float, + * double or half. + * + * vloadn return sizeof (gentypen) bytes of data read from address (p + (offset * n)). + * + * vstoren write sizeof (gentypen) bytes given by data to address (p + (offset * n)). + * + * The address computed as (p + (offset * n)) must be + * 8-bit aligned if gentype is char, uchar; + * 16-bit aligned if gentype is short, ushort, half; + * 32-bit aligned if gentype is int, uint, float; + * 64-bit aligned if gentype is long, ulong, double. + */ + +char2 __ovld __purefn vload2(size_t, const __constant char *); +uchar2 __ovld __purefn vload2(size_t, const __constant uchar *); +short2 __ovld __purefn vload2(size_t, const __constant short *); +ushort2 __ovld __purefn vload2(size_t, const __constant ushort *); +int2 __ovld __purefn vload2(size_t, const __constant int *); +uint2 __ovld __purefn vload2(size_t, const __constant uint *); +long2 __ovld __purefn vload2(size_t, const __constant long *); +ulong2 __ovld __purefn vload2(size_t, const __constant ulong *); +float2 __ovld __purefn vload2(size_t, const __constant float *); +char3 __ovld __purefn vload3(size_t, const __constant char *); +uchar3 __ovld __purefn vload3(size_t, const __constant uchar *); +short3 __ovld __purefn vload3(size_t, const __constant short *); +ushort3 __ovld __purefn vload3(size_t, const __constant ushort *); +int3 __ovld __purefn vload3(size_t, const __constant int *); +uint3 __ovld __purefn vload3(size_t, const __constant uint *); +long3 __ovld __purefn vload3(size_t, const __constant long *); +ulong3 __ovld __purefn vload3(size_t, const __constant ulong *); +float3 __ovld __purefn vload3(size_t, const __constant float *); +char4 __ovld __purefn vload4(size_t, const __constant char *); +uchar4 __ovld __purefn vload4(size_t, const __constant uchar *); +short4 __ovld __purefn vload4(size_t, const __constant short *); +ushort4 __ovld __purefn vload4(size_t, const __constant ushort *); +int4 __ovld __purefn vload4(size_t, const __constant int *); +uint4 __ovld __purefn vload4(size_t, const __constant uint *); +long4 __ovld __purefn vload4(size_t, const __constant long *); +ulong4 __ovld __purefn vload4(size_t, const __constant ulong *); +float4 __ovld __purefn vload4(size_t, const __constant float *); +char8 __ovld __purefn vload8(size_t, const __constant char *); +uchar8 __ovld __purefn vload8(size_t, const __constant uchar *); +short8 __ovld __purefn vload8(size_t, const __constant short *); +ushort8 __ovld __purefn vload8(size_t, const __constant ushort *); +int8 __ovld __purefn vload8(size_t, const __constant int *); +uint8 __ovld __purefn vload8(size_t, const __constant uint *); +long8 __ovld __purefn vload8(size_t, const __constant long *); +ulong8 __ovld __purefn vload8(size_t, const __constant ulong *); +float8 __ovld __purefn vload8(size_t, const __constant float *); +char16 __ovld __purefn vload16(size_t, const __constant char *); +uchar16 __ovld __purefn vload16(size_t, const __constant uchar *); +short16 __ovld __purefn vload16(size_t, const __constant short *); +ushort16 __ovld __purefn vload16(size_t, const __constant ushort *); +int16 __ovld __purefn vload16(size_t, const __constant int *); +uint16 __ovld __purefn vload16(size_t, const __constant uint *); +long16 __ovld __purefn vload16(size_t, const __constant long *); +ulong16 __ovld __purefn vload16(size_t, const __constant ulong *); +float16 __ovld __purefn vload16(size_t, const __constant float *); +#ifdef cl_khr_fp64 +double2 __ovld __purefn vload2(size_t, const __constant double *); +double3 __ovld __purefn vload3(size_t, const __constant double *); +double4 __ovld __purefn vload4(size_t, const __constant double *); +double8 __ovld __purefn vload8(size_t, const __constant double *); +double16 __ovld __purefn vload16(size_t, const __constant double *); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +half2 __ovld __purefn vload2(size_t, const __constant half *); +half3 __ovld __purefn vload3(size_t, const __constant half *); +half4 __ovld __purefn vload4(size_t, const __constant half *); +half8 __ovld __purefn vload8(size_t, const __constant half *); +half16 __ovld __purefn vload16(size_t, const __constant half *); +#endif //cl_khr_fp16 + +#if defined(__opencl_c_generic_address_space) +char2 __ovld __purefn vload2(size_t, const char *); +uchar2 __ovld __purefn vload2(size_t, const uchar *); +short2 __ovld __purefn vload2(size_t, const short *); +ushort2 __ovld __purefn vload2(size_t, const ushort *); +int2 __ovld __purefn vload2(size_t, const int *); +uint2 __ovld __purefn vload2(size_t, const uint *); +long2 __ovld __purefn vload2(size_t, const long *); +ulong2 __ovld __purefn vload2(size_t, const ulong *); +float2 __ovld __purefn vload2(size_t, const float *); +char3 __ovld __purefn vload3(size_t, const char *); +uchar3 __ovld __purefn vload3(size_t, const uchar *); +short3 __ovld __purefn vload3(size_t, const short *); +ushort3 __ovld __purefn vload3(size_t, const ushort *); +int3 __ovld __purefn vload3(size_t, const int *); +uint3 __ovld __purefn vload3(size_t, const uint *); +long3 __ovld __purefn vload3(size_t, const long *); +ulong3 __ovld __purefn vload3(size_t, const ulong *); +float3 __ovld __purefn vload3(size_t, const float *); +char4 __ovld __purefn vload4(size_t, const char *); +uchar4 __ovld __purefn vload4(size_t, const uchar *); +short4 __ovld __purefn vload4(size_t, const short *); +ushort4 __ovld __purefn vload4(size_t, const ushort *); +int4 __ovld __purefn vload4(size_t, const int *); +uint4 __ovld __purefn vload4(size_t, const uint *); +long4 __ovld __purefn vload4(size_t, const long *); +ulong4 __ovld __purefn vload4(size_t, const ulong *); +float4 __ovld __purefn vload4(size_t, const float *); +char8 __ovld __purefn vload8(size_t, const char *); +uchar8 __ovld __purefn vload8(size_t, const uchar *); +short8 __ovld __purefn vload8(size_t, const short *); +ushort8 __ovld __purefn vload8(size_t, const ushort *); +int8 __ovld __purefn vload8(size_t, const int *); +uint8 __ovld __purefn vload8(size_t, const uint *); +long8 __ovld __purefn vload8(size_t, const long *); +ulong8 __ovld __purefn vload8(size_t, const ulong *); +float8 __ovld __purefn vload8(size_t, const float *); +char16 __ovld __purefn vload16(size_t, const char *); +uchar16 __ovld __purefn vload16(size_t, const uchar *); +short16 __ovld __purefn vload16(size_t, const short *); +ushort16 __ovld __purefn vload16(size_t, const ushort *); +int16 __ovld __purefn vload16(size_t, const int *); +uint16 __ovld __purefn vload16(size_t, const uint *); +long16 __ovld __purefn vload16(size_t, const long *); +ulong16 __ovld __purefn vload16(size_t, const ulong *); +float16 __ovld __purefn vload16(size_t, const float *); + +#ifdef cl_khr_fp64 +double2 __ovld __purefn vload2(size_t, const double *); +double3 __ovld __purefn vload3(size_t, const double *); +double4 __ovld __purefn vload4(size_t, const double *); +double8 __ovld __purefn vload8(size_t, const double *); +double16 __ovld __purefn vload16(size_t, const double *); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +half2 __ovld __purefn vload2(size_t, const half *); +half3 __ovld __purefn vload3(size_t, const half *); +half4 __ovld __purefn vload4(size_t, const half *); +half8 __ovld __purefn vload8(size_t, const half *); +half16 __ovld __purefn vload16(size_t, const half *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +char2 __ovld __purefn vload2(size_t, const __global char *); +uchar2 __ovld __purefn vload2(size_t, const __global uchar *); +short2 __ovld __purefn vload2(size_t, const __global short *); +ushort2 __ovld __purefn vload2(size_t, const __global ushort *); +int2 __ovld __purefn vload2(size_t, const __global int *); +uint2 __ovld __purefn vload2(size_t, const __global uint *); +long2 __ovld __purefn vload2(size_t, const __global long *); +ulong2 __ovld __purefn vload2(size_t, const __global ulong *); +float2 __ovld __purefn vload2(size_t, const __global float *); +char3 __ovld __purefn vload3(size_t, const __global char *); +uchar3 __ovld __purefn vload3(size_t, const __global uchar *); +short3 __ovld __purefn vload3(size_t, const __global short *); +ushort3 __ovld __purefn vload3(size_t, const __global ushort *); +int3 __ovld __purefn vload3(size_t, const __global int *); +uint3 __ovld __purefn vload3(size_t, const __global uint *); +long3 __ovld __purefn vload3(size_t, const __global long *); +ulong3 __ovld __purefn vload3(size_t, const __global ulong *); +float3 __ovld __purefn vload3(size_t, const __global float *); +char4 __ovld __purefn vload4(size_t, const __global char *); +uchar4 __ovld __purefn vload4(size_t, const __global uchar *); +short4 __ovld __purefn vload4(size_t, const __global short *); +ushort4 __ovld __purefn vload4(size_t, const __global ushort *); +int4 __ovld __purefn vload4(size_t, const __global int *); +uint4 __ovld __purefn vload4(size_t, const __global uint *); +long4 __ovld __purefn vload4(size_t, const __global long *); +ulong4 __ovld __purefn vload4(size_t, const __global ulong *); +float4 __ovld __purefn vload4(size_t, const __global float *); +char8 __ovld __purefn vload8(size_t, const __global char *); +uchar8 __ovld __purefn vload8(size_t, const __global uchar *); +short8 __ovld __purefn vload8(size_t, const __global short *); +ushort8 __ovld __purefn vload8(size_t, const __global ushort *); +int8 __ovld __purefn vload8(size_t, const __global int *); +uint8 __ovld __purefn vload8(size_t, const __global uint *); +long8 __ovld __purefn vload8(size_t, const __global long *); +ulong8 __ovld __purefn vload8(size_t, const __global ulong *); +float8 __ovld __purefn vload8(size_t, const __global float *); +char16 __ovld __purefn vload16(size_t, const __global char *); +uchar16 __ovld __purefn vload16(size_t, const __global uchar *); +short16 __ovld __purefn vload16(size_t, const __global short *); +ushort16 __ovld __purefn vload16(size_t, const __global ushort *); +int16 __ovld __purefn vload16(size_t, const __global int *); +uint16 __ovld __purefn vload16(size_t, const __global uint *); +long16 __ovld __purefn vload16(size_t, const __global long *); +ulong16 __ovld __purefn vload16(size_t, const __global ulong *); +float16 __ovld __purefn vload16(size_t, const __global float *); +char2 __ovld __purefn vload2(size_t, const __local char *); +uchar2 __ovld __purefn vload2(size_t, const __local uchar *); +short2 __ovld __purefn vload2(size_t, const __local short *); +ushort2 __ovld __purefn vload2(size_t, const __local ushort *); +int2 __ovld __purefn vload2(size_t, const __local int *); +uint2 __ovld __purefn vload2(size_t, const __local uint *); +long2 __ovld __purefn vload2(size_t, const __local long *); +ulong2 __ovld __purefn vload2(size_t, const __local ulong *); +float2 __ovld __purefn vload2(size_t, const __local float *); +char3 __ovld __purefn vload3(size_t, const __local char *); +uchar3 __ovld __purefn vload3(size_t, const __local uchar *); +short3 __ovld __purefn vload3(size_t, const __local short *); +ushort3 __ovld __purefn vload3(size_t, const __local ushort *); +int3 __ovld __purefn vload3(size_t, const __local int *); +uint3 __ovld __purefn vload3(size_t, const __local uint *); +long3 __ovld __purefn vload3(size_t, const __local long *); +ulong3 __ovld __purefn vload3(size_t, const __local ulong *); +float3 __ovld __purefn vload3(size_t, const __local float *); +char4 __ovld __purefn vload4(size_t, const __local char *); +uchar4 __ovld __purefn vload4(size_t, const __local uchar *); +short4 __ovld __purefn vload4(size_t, const __local short *); +ushort4 __ovld __purefn vload4(size_t, const __local ushort *); +int4 __ovld __purefn vload4(size_t, const __local int *); +uint4 __ovld __purefn vload4(size_t, const __local uint *); +long4 __ovld __purefn vload4(size_t, const __local long *); +ulong4 __ovld __purefn vload4(size_t, const __local ulong *); +float4 __ovld __purefn vload4(size_t, const __local float *); +char8 __ovld __purefn vload8(size_t, const __local char *); +uchar8 __ovld __purefn vload8(size_t, const __local uchar *); +short8 __ovld __purefn vload8(size_t, const __local short *); +ushort8 __ovld __purefn vload8(size_t, const __local ushort *); +int8 __ovld __purefn vload8(size_t, const __local int *); +uint8 __ovld __purefn vload8(size_t, const __local uint *); +long8 __ovld __purefn vload8(size_t, const __local long *); +ulong8 __ovld __purefn vload8(size_t, const __local ulong *); +float8 __ovld __purefn vload8(size_t, const __local float *); +char16 __ovld __purefn vload16(size_t, const __local char *); +uchar16 __ovld __purefn vload16(size_t, const __local uchar *); +short16 __ovld __purefn vload16(size_t, const __local short *); +ushort16 __ovld __purefn vload16(size_t, const __local ushort *); +int16 __ovld __purefn vload16(size_t, const __local int *); +uint16 __ovld __purefn vload16(size_t, const __local uint *); +long16 __ovld __purefn vload16(size_t, const __local long *); +ulong16 __ovld __purefn vload16(size_t, const __local ulong *); +float16 __ovld __purefn vload16(size_t, const __local float *); +char2 __ovld __purefn vload2(size_t, const __private char *); +uchar2 __ovld __purefn vload2(size_t, const __private uchar *); +short2 __ovld __purefn vload2(size_t, const __private short *); +ushort2 __ovld __purefn vload2(size_t, const __private ushort *); +int2 __ovld __purefn vload2(size_t, const __private int *); +uint2 __ovld __purefn vload2(size_t, const __private uint *); +long2 __ovld __purefn vload2(size_t, const __private long *); +ulong2 __ovld __purefn vload2(size_t, const __private ulong *); +float2 __ovld __purefn vload2(size_t, const __private float *); +char3 __ovld __purefn vload3(size_t, const __private char *); +uchar3 __ovld __purefn vload3(size_t, const __private uchar *); +short3 __ovld __purefn vload3(size_t, const __private short *); +ushort3 __ovld __purefn vload3(size_t, const __private ushort *); +int3 __ovld __purefn vload3(size_t, const __private int *); +uint3 __ovld __purefn vload3(size_t, const __private uint *); +long3 __ovld __purefn vload3(size_t, const __private long *); +ulong3 __ovld __purefn vload3(size_t, const __private ulong *); +float3 __ovld __purefn vload3(size_t, const __private float *); +char4 __ovld __purefn vload4(size_t, const __private char *); +uchar4 __ovld __purefn vload4(size_t, const __private uchar *); +short4 __ovld __purefn vload4(size_t, const __private short *); +ushort4 __ovld __purefn vload4(size_t, const __private ushort *); +int4 __ovld __purefn vload4(size_t, const __private int *); +uint4 __ovld __purefn vload4(size_t, const __private uint *); +long4 __ovld __purefn vload4(size_t, const __private long *); +ulong4 __ovld __purefn vload4(size_t, const __private ulong *); +float4 __ovld __purefn vload4(size_t, const __private float *); +char8 __ovld __purefn vload8(size_t, const __private char *); +uchar8 __ovld __purefn vload8(size_t, const __private uchar *); +short8 __ovld __purefn vload8(size_t, const __private short *); +ushort8 __ovld __purefn vload8(size_t, const __private ushort *); +int8 __ovld __purefn vload8(size_t, const __private int *); +uint8 __ovld __purefn vload8(size_t, const __private uint *); +long8 __ovld __purefn vload8(size_t, const __private long *); +ulong8 __ovld __purefn vload8(size_t, const __private ulong *); +float8 __ovld __purefn vload8(size_t, const __private float *); +char16 __ovld __purefn vload16(size_t, const __private char *); +uchar16 __ovld __purefn vload16(size_t, const __private uchar *); +short16 __ovld __purefn vload16(size_t, const __private short *); +ushort16 __ovld __purefn vload16(size_t, const __private ushort *); +int16 __ovld __purefn vload16(size_t, const __private int *); +uint16 __ovld __purefn vload16(size_t, const __private uint *); +long16 __ovld __purefn vload16(size_t, const __private long *); +ulong16 __ovld __purefn vload16(size_t, const __private ulong *); +float16 __ovld __purefn vload16(size_t, const __private float *); + +#ifdef cl_khr_fp64 +double2 __ovld __purefn vload2(size_t, const __global double *); +double3 __ovld __purefn vload3(size_t, const __global double *); +double4 __ovld __purefn vload4(size_t, const __global double *); +double8 __ovld __purefn vload8(size_t, const __global double *); +double16 __ovld __purefn vload16(size_t, const __global double *); +double2 __ovld __purefn vload2(size_t, const __local double *); +double3 __ovld __purefn vload3(size_t, const __local double *); +double4 __ovld __purefn vload4(size_t, const __local double *); +double8 __ovld __purefn vload8(size_t, const __local double *); +double16 __ovld __purefn vload16(size_t, const __local double *); +double2 __ovld __purefn vload2(size_t, const __private double *); +double3 __ovld __purefn vload3(size_t, const __private double *); +double4 __ovld __purefn vload4(size_t, const __private double *); +double8 __ovld __purefn vload8(size_t, const __private double *); +double16 __ovld __purefn vload16(size_t, const __private double *); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +half2 __ovld __purefn vload2(size_t, const __global half *); +half3 __ovld __purefn vload3(size_t, const __global half *); +half4 __ovld __purefn vload4(size_t, const __global half *); +half8 __ovld __purefn vload8(size_t, const __global half *); +half16 __ovld __purefn vload16(size_t, const __global half *); +half2 __ovld __purefn vload2(size_t, const __local half *); +half3 __ovld __purefn vload3(size_t, const __local half *); +half4 __ovld __purefn vload4(size_t, const __local half *); +half8 __ovld __purefn vload8(size_t, const __local half *); +half16 __ovld __purefn vload16(size_t, const __local half *); +half2 __ovld __purefn vload2(size_t, const __private half *); +half3 __ovld __purefn vload3(size_t, const __private half *); +half4 __ovld __purefn vload4(size_t, const __private half *); +half8 __ovld __purefn vload8(size_t, const __private half *); +half16 __ovld __purefn vload16(size_t, const __private half *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +#if defined(__opencl_c_generic_address_space) +void __ovld vstore2(char2, size_t, char *); +void __ovld vstore2(uchar2, size_t, uchar *); +void __ovld vstore2(short2, size_t, short *); +void __ovld vstore2(ushort2, size_t, ushort *); +void __ovld vstore2(int2, size_t, int *); +void __ovld vstore2(uint2, size_t, uint *); +void __ovld vstore2(long2, size_t, long *); +void __ovld vstore2(ulong2, size_t, ulong *); +void __ovld vstore2(float2, size_t, float *); +void __ovld vstore3(char3, size_t, char *); +void __ovld vstore3(uchar3, size_t, uchar *); +void __ovld vstore3(short3, size_t, short *); +void __ovld vstore3(ushort3, size_t, ushort *); +void __ovld vstore3(int3, size_t, int *); +void __ovld vstore3(uint3, size_t, uint *); +void __ovld vstore3(long3, size_t, long *); +void __ovld vstore3(ulong3, size_t, ulong *); +void __ovld vstore3(float3, size_t, float *); +void __ovld vstore4(char4, size_t, char *); +void __ovld vstore4(uchar4, size_t, uchar *); +void __ovld vstore4(short4, size_t, short *); +void __ovld vstore4(ushort4, size_t, ushort *); +void __ovld vstore4(int4, size_t, int *); +void __ovld vstore4(uint4, size_t, uint *); +void __ovld vstore4(long4, size_t, long *); +void __ovld vstore4(ulong4, size_t, ulong *); +void __ovld vstore4(float4, size_t, float *); +void __ovld vstore8(char8, size_t, char *); +void __ovld vstore8(uchar8, size_t, uchar *); +void __ovld vstore8(short8, size_t, short *); +void __ovld vstore8(ushort8, size_t, ushort *); +void __ovld vstore8(int8, size_t, int *); +void __ovld vstore8(uint8, size_t, uint *); +void __ovld vstore8(long8, size_t, long *); +void __ovld vstore8(ulong8, size_t, ulong *); +void __ovld vstore8(float8, size_t, float *); +void __ovld vstore16(char16, size_t, char *); +void __ovld vstore16(uchar16, size_t, uchar *); +void __ovld vstore16(short16, size_t, short *); +void __ovld vstore16(ushort16, size_t, ushort *); +void __ovld vstore16(int16, size_t, int *); +void __ovld vstore16(uint16, size_t, uint *); +void __ovld vstore16(long16, size_t, long *); +void __ovld vstore16(ulong16, size_t, ulong *); +void __ovld vstore16(float16, size_t, float *); +#ifdef cl_khr_fp64 +void __ovld vstore2(double2, size_t, double *); +void __ovld vstore3(double3, size_t, double *); +void __ovld vstore4(double4, size_t, double *); +void __ovld vstore8(double8, size_t, double *); +void __ovld vstore16(double16, size_t, double *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +void __ovld vstore2(half2, size_t, half *); +void __ovld vstore3(half3, size_t, half *); +void __ovld vstore4(half4, size_t, half *); +void __ovld vstore8(half8, size_t, half *); +void __ovld vstore16(half16, size_t, half *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +void __ovld vstore2(char2, size_t, __global char *); +void __ovld vstore2(uchar2, size_t, __global uchar *); +void __ovld vstore2(short2, size_t, __global short *); +void __ovld vstore2(ushort2, size_t, __global ushort *); +void __ovld vstore2(int2, size_t, __global int *); +void __ovld vstore2(uint2, size_t, __global uint *); +void __ovld vstore2(long2, size_t, __global long *); +void __ovld vstore2(ulong2, size_t, __global ulong *); +void __ovld vstore2(float2, size_t, __global float *); +void __ovld vstore3(char3, size_t, __global char *); +void __ovld vstore3(uchar3, size_t, __global uchar *); +void __ovld vstore3(short3, size_t, __global short *); +void __ovld vstore3(ushort3, size_t, __global ushort *); +void __ovld vstore3(int3, size_t, __global int *); +void __ovld vstore3(uint3, size_t, __global uint *); +void __ovld vstore3(long3, size_t, __global long *); +void __ovld vstore3(ulong3, size_t, __global ulong *); +void __ovld vstore3(float3, size_t, __global float *); +void __ovld vstore4(char4, size_t, __global char *); +void __ovld vstore4(uchar4, size_t, __global uchar *); +void __ovld vstore4(short4, size_t, __global short *); +void __ovld vstore4(ushort4, size_t, __global ushort *); +void __ovld vstore4(int4, size_t, __global int *); +void __ovld vstore4(uint4, size_t, __global uint *); +void __ovld vstore4(long4, size_t, __global long *); +void __ovld vstore4(ulong4, size_t, __global ulong *); +void __ovld vstore4(float4, size_t, __global float *); +void __ovld vstore8(char8, size_t, __global char *); +void __ovld vstore8(uchar8, size_t, __global uchar *); +void __ovld vstore8(short8, size_t, __global short *); +void __ovld vstore8(ushort8, size_t, __global ushort *); +void __ovld vstore8(int8, size_t, __global int *); +void __ovld vstore8(uint8, size_t, __global uint *); +void __ovld vstore8(long8, size_t, __global long *); +void __ovld vstore8(ulong8, size_t, __global ulong *); +void __ovld vstore8(float8, size_t, __global float *); +void __ovld vstore16(char16, size_t, __global char *); +void __ovld vstore16(uchar16, size_t, __global uchar *); +void __ovld vstore16(short16, size_t, __global short *); +void __ovld vstore16(ushort16, size_t, __global ushort *); +void __ovld vstore16(int16, size_t, __global int *); +void __ovld vstore16(uint16, size_t, __global uint *); +void __ovld vstore16(long16, size_t, __global long *); +void __ovld vstore16(ulong16, size_t, __global ulong *); +void __ovld vstore16(float16, size_t, __global float *); +void __ovld vstore2(char2, size_t, __local char *); +void __ovld vstore2(uchar2, size_t, __local uchar *); +void __ovld vstore2(short2, size_t, __local short *); +void __ovld vstore2(ushort2, size_t, __local ushort *); +void __ovld vstore2(int2, size_t, __local int *); +void __ovld vstore2(uint2, size_t, __local uint *); +void __ovld vstore2(long2, size_t, __local long *); +void __ovld vstore2(ulong2, size_t, __local ulong *); +void __ovld vstore2(float2, size_t, __local float *); +void __ovld vstore3(char3, size_t, __local char *); +void __ovld vstore3(uchar3, size_t, __local uchar *); +void __ovld vstore3(short3, size_t, __local short *); +void __ovld vstore3(ushort3, size_t, __local ushort *); +void __ovld vstore3(int3, size_t, __local int *); +void __ovld vstore3(uint3, size_t, __local uint *); +void __ovld vstore3(long3, size_t, __local long *); +void __ovld vstore3(ulong3, size_t, __local ulong *); +void __ovld vstore3(float3, size_t, __local float *); +void __ovld vstore4(char4, size_t, __local char *); +void __ovld vstore4(uchar4, size_t, __local uchar *); +void __ovld vstore4(short4, size_t, __local short *); +void __ovld vstore4(ushort4, size_t, __local ushort *); +void __ovld vstore4(int4, size_t, __local int *); +void __ovld vstore4(uint4, size_t, __local uint *); +void __ovld vstore4(long4, size_t, __local long *); +void __ovld vstore4(ulong4, size_t, __local ulong *); +void __ovld vstore4(float4, size_t, __local float *); +void __ovld vstore8(char8, size_t, __local char *); +void __ovld vstore8(uchar8, size_t, __local uchar *); +void __ovld vstore8(short8, size_t, __local short *); +void __ovld vstore8(ushort8, size_t, __local ushort *); +void __ovld vstore8(int8, size_t, __local int *); +void __ovld vstore8(uint8, size_t, __local uint *); +void __ovld vstore8(long8, size_t, __local long *); +void __ovld vstore8(ulong8, size_t, __local ulong *); +void __ovld vstore8(float8, size_t, __local float *); +void __ovld vstore16(char16, size_t, __local char *); +void __ovld vstore16(uchar16, size_t, __local uchar *); +void __ovld vstore16(short16, size_t, __local short *); +void __ovld vstore16(ushort16, size_t, __local ushort *); +void __ovld vstore16(int16, size_t, __local int *); +void __ovld vstore16(uint16, size_t, __local uint *); +void __ovld vstore16(long16, size_t, __local long *); +void __ovld vstore16(ulong16, size_t, __local ulong *); +void __ovld vstore16(float16, size_t, __local float *); +void __ovld vstore2(char2, size_t, __private char *); +void __ovld vstore2(uchar2, size_t, __private uchar *); +void __ovld vstore2(short2, size_t, __private short *); +void __ovld vstore2(ushort2, size_t, __private ushort *); +void __ovld vstore2(int2, size_t, __private int *); +void __ovld vstore2(uint2, size_t, __private uint *); +void __ovld vstore2(long2, size_t, __private long *); +void __ovld vstore2(ulong2, size_t, __private ulong *); +void __ovld vstore2(float2, size_t, __private float *); +void __ovld vstore3(char3, size_t, __private char *); +void __ovld vstore3(uchar3, size_t, __private uchar *); +void __ovld vstore3(short3, size_t, __private short *); +void __ovld vstore3(ushort3, size_t, __private ushort *); +void __ovld vstore3(int3, size_t, __private int *); +void __ovld vstore3(uint3, size_t, __private uint *); +void __ovld vstore3(long3, size_t, __private long *); +void __ovld vstore3(ulong3, size_t, __private ulong *); +void __ovld vstore3(float3, size_t, __private float *); +void __ovld vstore4(char4, size_t, __private char *); +void __ovld vstore4(uchar4, size_t, __private uchar *); +void __ovld vstore4(short4, size_t, __private short *); +void __ovld vstore4(ushort4, size_t, __private ushort *); +void __ovld vstore4(int4, size_t, __private int *); +void __ovld vstore4(uint4, size_t, __private uint *); +void __ovld vstore4(long4, size_t, __private long *); +void __ovld vstore4(ulong4, size_t, __private ulong *); +void __ovld vstore4(float4, size_t, __private float *); +void __ovld vstore8(char8, size_t, __private char *); +void __ovld vstore8(uchar8, size_t, __private uchar *); +void __ovld vstore8(short8, size_t, __private short *); +void __ovld vstore8(ushort8, size_t, __private ushort *); +void __ovld vstore8(int8, size_t, __private int *); +void __ovld vstore8(uint8, size_t, __private uint *); +void __ovld vstore8(long8, size_t, __private long *); +void __ovld vstore8(ulong8, size_t, __private ulong *); +void __ovld vstore8(float8, size_t, __private float *); +void __ovld vstore16(char16, size_t, __private char *); +void __ovld vstore16(uchar16, size_t, __private uchar *); +void __ovld vstore16(short16, size_t, __private short *); +void __ovld vstore16(ushort16, size_t, __private ushort *); +void __ovld vstore16(int16, size_t, __private int *); +void __ovld vstore16(uint16, size_t, __private uint *); +void __ovld vstore16(long16, size_t, __private long *); +void __ovld vstore16(ulong16, size_t, __private ulong *); +void __ovld vstore16(float16, size_t, __private float *); +#ifdef cl_khr_fp64 +void __ovld vstore2(double2, size_t, __global double *); +void __ovld vstore3(double3, size_t, __global double *); +void __ovld vstore4(double4, size_t, __global double *); +void __ovld vstore8(double8, size_t, __global double *); +void __ovld vstore16(double16, size_t, __global double *); +void __ovld vstore2(double2, size_t, __local double *); +void __ovld vstore3(double3, size_t, __local double *); +void __ovld vstore4(double4, size_t, __local double *); +void __ovld vstore8(double8, size_t, __local double *); +void __ovld vstore16(double16, size_t, __local double *); +void __ovld vstore2(double2, size_t, __private double *); +void __ovld vstore3(double3, size_t, __private double *); +void __ovld vstore4(double4, size_t, __private double *); +void __ovld vstore8(double8, size_t, __private double *); +void __ovld vstore16(double16, size_t, __private double *); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +void __ovld vstore2(half2, size_t, __global half *); +void __ovld vstore3(half3, size_t, __global half *); +void __ovld vstore4(half4, size_t, __global half *); +void __ovld vstore8(half8, size_t, __global half *); +void __ovld vstore16(half16, size_t, __global half *); +void __ovld vstore2(half2, size_t, __local half *); +void __ovld vstore3(half3, size_t, __local half *); +void __ovld vstore4(half4, size_t, __local half *); +void __ovld vstore8(half8, size_t, __local half *); +void __ovld vstore16(half16, size_t, __local half *); +void __ovld vstore2(half2, size_t, __private half *); +void __ovld vstore3(half3, size_t, __private half *); +void __ovld vstore4(half4, size_t, __private half *); +void __ovld vstore8(half8, size_t, __private half *); +void __ovld vstore16(half16, size_t, __private half *); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Read sizeof (half) bytes of data from address + * (p + offset). The data read is interpreted as a + * half value. The half value is converted to a + * float value and the float value is returned. + * The read address computed as (p + offset) + * must be 16-bit aligned. + */ +float __ovld __purefn vload_half(size_t, const __constant half *); +#if defined(__opencl_c_generic_address_space) +float __ovld __purefn vload_half(size_t, const half *); +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float __ovld __purefn vload_half(size_t, const __global half *); +float __ovld __purefn vload_half(size_t, const __local half *); +float __ovld __purefn vload_half(size_t, const __private half *); +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * Read sizeof (halfn) bytes of data from address + * (p + (offset * n)). The data read is interpreted + * as a halfn value. The halfn value read is + * converted to a floatn value and the floatn + * value is returned. The read address computed + * as (p + (offset * n)) must be 16-bit aligned. + */ +float2 __ovld __purefn vload_half2(size_t, const __constant half *); +float3 __ovld __purefn vload_half3(size_t, const __constant half *); +float4 __ovld __purefn vload_half4(size_t, const __constant half *); +float8 __ovld __purefn vload_half8(size_t, const __constant half *); +float16 __ovld __purefn vload_half16(size_t, const __constant half *); +#if defined(__opencl_c_generic_address_space) +float2 __ovld __purefn vload_half2(size_t, const half *); +float3 __ovld __purefn vload_half3(size_t, const half *); +float4 __ovld __purefn vload_half4(size_t, const half *); +float8 __ovld __purefn vload_half8(size_t, const half *); +float16 __ovld __purefn vload_half16(size_t, const half *); +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float2 __ovld __purefn vload_half2(size_t, const __global half *); +float3 __ovld __purefn vload_half3(size_t, const __global half *); +float4 __ovld __purefn vload_half4(size_t, const __global half *); +float8 __ovld __purefn vload_half8(size_t, const __global half *); +float16 __ovld __purefn vload_half16(size_t, const __global half *); +float2 __ovld __purefn vload_half2(size_t, const __local half *); +float3 __ovld __purefn vload_half3(size_t, const __local half *); +float4 __ovld __purefn vload_half4(size_t, const __local half *); +float8 __ovld __purefn vload_half8(size_t, const __local half *); +float16 __ovld __purefn vload_half16(size_t, const __local half *); +float2 __ovld __purefn vload_half2(size_t, const __private half *); +float3 __ovld __purefn vload_half3(size_t, const __private half *); +float4 __ovld __purefn vload_half4(size_t, const __private half *); +float8 __ovld __purefn vload_half8(size_t, const __private half *); +float16 __ovld __purefn vload_half16(size_t, const __private half *); +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * The float value given by data is first + * converted to a half value using the appropriate + * rounding mode. The half value is then written + * to address computed as (p + offset). The + * address computed as (p + offset) must be 16- + * bit aligned. + * vstore_half use the current rounding mode. + * The default current rounding mode is round to + * nearest even. + */ +#if defined(__opencl_c_generic_address_space) +void __ovld vstore_half(float, size_t, half *); +void __ovld vstore_half_rte(float, size_t, half *); +void __ovld vstore_half_rtz(float, size_t, half *); +void __ovld vstore_half_rtp(float, size_t, half *); +void __ovld vstore_half_rtn(float, size_t, half *); +#ifdef cl_khr_fp64 +void __ovld vstore_half(double, size_t, half *); +void __ovld vstore_half_rte(double, size_t, half *); +void __ovld vstore_half_rtz(double, size_t, half *); +void __ovld vstore_half_rtp(double, size_t, half *); +void __ovld vstore_half_rtn(double, size_t, half *); +#endif //cl_khr_fp64 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +void __ovld vstore_half(float, size_t, __global half *); +void __ovld vstore_half_rte(float, size_t, __global half *); +void __ovld vstore_half_rtz(float, size_t, __global half *); +void __ovld vstore_half_rtp(float, size_t, __global half *); +void __ovld vstore_half_rtn(float, size_t, __global half *); +void __ovld vstore_half(float, size_t, __local half *); +void __ovld vstore_half_rte(float, size_t, __local half *); +void __ovld vstore_half_rtz(float, size_t, __local half *); +void __ovld vstore_half_rtp(float, size_t, __local half *); +void __ovld vstore_half_rtn(float, size_t, __local half *); +void __ovld vstore_half(float, size_t, __private half *); +void __ovld vstore_half_rte(float, size_t, __private half *); +void __ovld vstore_half_rtz(float, size_t, __private half *); +void __ovld vstore_half_rtp(float, size_t, __private half *); +void __ovld vstore_half_rtn(float, size_t, __private half *); +#ifdef cl_khr_fp64 +void __ovld vstore_half(double, size_t, __global half *); +void __ovld vstore_half_rte(double, size_t, __global half *); +void __ovld vstore_half_rtz(double, size_t, __global half *); +void __ovld vstore_half_rtp(double, size_t, __global half *); +void __ovld vstore_half_rtn(double, size_t, __global half *); +void __ovld vstore_half(double, size_t, __local half *); +void __ovld vstore_half_rte(double, size_t, __local half *); +void __ovld vstore_half_rtz(double, size_t, __local half *); +void __ovld vstore_half_rtp(double, size_t, __local half *); +void __ovld vstore_half_rtn(double, size_t, __local half *); +void __ovld vstore_half(double, size_t, __private half *); +void __ovld vstore_half_rte(double, size_t, __private half *); +void __ovld vstore_half_rtz(double, size_t, __private half *); +void __ovld vstore_half_rtp(double, size_t, __private half *); +void __ovld vstore_half_rtn(double, size_t, __private half *); +#endif //cl_khr_fp64 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * The floatn value given by data is converted to + * a halfn value using the appropriate rounding + * mode. The halfn value is then written to + * address computed as (p + (offset * n)). The + * address computed as (p + (offset * n)) must be + * 16-bit aligned. + * vstore_halfn uses the current rounding mode. + * The default current rounding mode is round to + * nearest even. + */ +#if defined(__opencl_c_generic_address_space) +void __ovld vstore_half2(float2, size_t, half *); +void __ovld vstore_half3(float3, size_t, half *); +void __ovld vstore_half4(float4, size_t, half *); +void __ovld vstore_half8(float8, size_t, half *); +void __ovld vstore_half16(float16, size_t, half *); +void __ovld vstore_half2_rte(float2, size_t, half *); +void __ovld vstore_half3_rte(float3, size_t, half *); +void __ovld vstore_half4_rte(float4, size_t, half *); +void __ovld vstore_half8_rte(float8, size_t, half *); +void __ovld vstore_half16_rte(float16, size_t, half *); +void __ovld vstore_half2_rtz(float2, size_t, half *); +void __ovld vstore_half3_rtz(float3, size_t, half *); +void __ovld vstore_half4_rtz(float4, size_t, half *); +void __ovld vstore_half8_rtz(float8, size_t, half *); +void __ovld vstore_half16_rtz(float16, size_t, half *); +void __ovld vstore_half2_rtp(float2, size_t, half *); +void __ovld vstore_half3_rtp(float3, size_t, half *); +void __ovld vstore_half4_rtp(float4, size_t, half *); +void __ovld vstore_half8_rtp(float8, size_t, half *); +void __ovld vstore_half16_rtp(float16, size_t, half *); +void __ovld vstore_half2_rtn(float2, size_t, half *); +void __ovld vstore_half3_rtn(float3, size_t, half *); +void __ovld vstore_half4_rtn(float4, size_t, half *); +void __ovld vstore_half8_rtn(float8, size_t, half *); +void __ovld vstore_half16_rtn(float16, size_t, half *); +#ifdef cl_khr_fp64 +void __ovld vstore_half2(double2, size_t, half *); +void __ovld vstore_half3(double3, size_t, half *); +void __ovld vstore_half4(double4, size_t, half *); +void __ovld vstore_half8(double8, size_t, half *); +void __ovld vstore_half16(double16, size_t, half *); +void __ovld vstore_half2_rte(double2, size_t, half *); +void __ovld vstore_half3_rte(double3, size_t, half *); +void __ovld vstore_half4_rte(double4, size_t, half *); +void __ovld vstore_half8_rte(double8, size_t, half *); +void __ovld vstore_half16_rte(double16, size_t, half *); +void __ovld vstore_half2_rtz(double2, size_t, half *); +void __ovld vstore_half3_rtz(double3, size_t, half *); +void __ovld vstore_half4_rtz(double4, size_t, half *); +void __ovld vstore_half8_rtz(double8, size_t, half *); +void __ovld vstore_half16_rtz(double16, size_t, half *); +void __ovld vstore_half2_rtp(double2, size_t, half *); +void __ovld vstore_half3_rtp(double3, size_t, half *); +void __ovld vstore_half4_rtp(double4, size_t, half *); +void __ovld vstore_half8_rtp(double8, size_t, half *); +void __ovld vstore_half16_rtp(double16, size_t, half *); +void __ovld vstore_half2_rtn(double2, size_t, half *); +void __ovld vstore_half3_rtn(double3, size_t, half *); +void __ovld vstore_half4_rtn(double4, size_t, half *); +void __ovld vstore_half8_rtn(double8, size_t, half *); +void __ovld vstore_half16_rtn(double16, size_t, half *); +#endif //cl_khr_fp64 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +void __ovld vstore_half2(float2, size_t, __global half *); +void __ovld vstore_half3(float3, size_t, __global half *); +void __ovld vstore_half4(float4, size_t, __global half *); +void __ovld vstore_half8(float8, size_t, __global half *); +void __ovld vstore_half16(float16, size_t, __global half *); +void __ovld vstore_half2_rte(float2, size_t, __global half *); +void __ovld vstore_half3_rte(float3, size_t, __global half *); +void __ovld vstore_half4_rte(float4, size_t, __global half *); +void __ovld vstore_half8_rte(float8, size_t, __global half *); +void __ovld vstore_half16_rte(float16, size_t, __global half *); +void __ovld vstore_half2_rtz(float2, size_t, __global half *); +void __ovld vstore_half3_rtz(float3, size_t, __global half *); +void __ovld vstore_half4_rtz(float4, size_t, __global half *); +void __ovld vstore_half8_rtz(float8, size_t, __global half *); +void __ovld vstore_half16_rtz(float16, size_t, __global half *); +void __ovld vstore_half2_rtp(float2, size_t, __global half *); +void __ovld vstore_half3_rtp(float3, size_t, __global half *); +void __ovld vstore_half4_rtp(float4, size_t, __global half *); +void __ovld vstore_half8_rtp(float8, size_t, __global half *); +void __ovld vstore_half16_rtp(float16, size_t, __global half *); +void __ovld vstore_half2_rtn(float2, size_t, __global half *); +void __ovld vstore_half3_rtn(float3, size_t, __global half *); +void __ovld vstore_half4_rtn(float4, size_t, __global half *); +void __ovld vstore_half8_rtn(float8, size_t, __global half *); +void __ovld vstore_half16_rtn(float16, size_t, __global half *); +void __ovld vstore_half2(float2, size_t, __local half *); +void __ovld vstore_half3(float3, size_t, __local half *); +void __ovld vstore_half4(float4, size_t, __local half *); +void __ovld vstore_half8(float8, size_t, __local half *); +void __ovld vstore_half16(float16, size_t, __local half *); +void __ovld vstore_half2_rte(float2, size_t, __local half *); +void __ovld vstore_half3_rte(float3, size_t, __local half *); +void __ovld vstore_half4_rte(float4, size_t, __local half *); +void __ovld vstore_half8_rte(float8, size_t, __local half *); +void __ovld vstore_half16_rte(float16, size_t, __local half *); +void __ovld vstore_half2_rtz(float2, size_t, __local half *); +void __ovld vstore_half3_rtz(float3, size_t, __local half *); +void __ovld vstore_half4_rtz(float4, size_t, __local half *); +void __ovld vstore_half8_rtz(float8, size_t, __local half *); +void __ovld vstore_half16_rtz(float16, size_t, __local half *); +void __ovld vstore_half2_rtp(float2, size_t, __local half *); +void __ovld vstore_half3_rtp(float3, size_t, __local half *); +void __ovld vstore_half4_rtp(float4, size_t, __local half *); +void __ovld vstore_half8_rtp(float8, size_t, __local half *); +void __ovld vstore_half16_rtp(float16, size_t, __local half *); +void __ovld vstore_half2_rtn(float2, size_t, __local half *); +void __ovld vstore_half3_rtn(float3, size_t, __local half *); +void __ovld vstore_half4_rtn(float4, size_t, __local half *); +void __ovld vstore_half8_rtn(float8, size_t, __local half *); +void __ovld vstore_half16_rtn(float16, size_t, __local half *); +void __ovld vstore_half2(float2, size_t, __private half *); +void __ovld vstore_half3(float3, size_t, __private half *); +void __ovld vstore_half4(float4, size_t, __private half *); +void __ovld vstore_half8(float8, size_t, __private half *); +void __ovld vstore_half16(float16, size_t, __private half *); +void __ovld vstore_half2_rte(float2, size_t, __private half *); +void __ovld vstore_half3_rte(float3, size_t, __private half *); +void __ovld vstore_half4_rte(float4, size_t, __private half *); +void __ovld vstore_half8_rte(float8, size_t, __private half *); +void __ovld vstore_half16_rte(float16, size_t, __private half *); +void __ovld vstore_half2_rtz(float2, size_t, __private half *); +void __ovld vstore_half3_rtz(float3, size_t, __private half *); +void __ovld vstore_half4_rtz(float4, size_t, __private half *); +void __ovld vstore_half8_rtz(float8, size_t, __private half *); +void __ovld vstore_half16_rtz(float16, size_t, __private half *); +void __ovld vstore_half2_rtp(float2, size_t, __private half *); +void __ovld vstore_half3_rtp(float3, size_t, __private half *); +void __ovld vstore_half4_rtp(float4, size_t, __private half *); +void __ovld vstore_half8_rtp(float8, size_t, __private half *); +void __ovld vstore_half16_rtp(float16, size_t, __private half *); +void __ovld vstore_half2_rtn(float2, size_t, __private half *); +void __ovld vstore_half3_rtn(float3, size_t, __private half *); +void __ovld vstore_half4_rtn(float4, size_t, __private half *); +void __ovld vstore_half8_rtn(float8, size_t, __private half *); +void __ovld vstore_half16_rtn(float16, size_t, __private half *); +#ifdef cl_khr_fp64 +void __ovld vstore_half2(double2, size_t, __global half *); +void __ovld vstore_half3(double3, size_t, __global half *); +void __ovld vstore_half4(double4, size_t, __global half *); +void __ovld vstore_half8(double8, size_t, __global half *); +void __ovld vstore_half16(double16, size_t, __global half *); +void __ovld vstore_half2_rte(double2, size_t, __global half *); +void __ovld vstore_half3_rte(double3, size_t, __global half *); +void __ovld vstore_half4_rte(double4, size_t, __global half *); +void __ovld vstore_half8_rte(double8, size_t, __global half *); +void __ovld vstore_half16_rte(double16, size_t, __global half *); +void __ovld vstore_half2_rtz(double2, size_t, __global half *); +void __ovld vstore_half3_rtz(double3, size_t, __global half *); +void __ovld vstore_half4_rtz(double4, size_t, __global half *); +void __ovld vstore_half8_rtz(double8, size_t, __global half *); +void __ovld vstore_half16_rtz(double16, size_t, __global half *); +void __ovld vstore_half2_rtp(double2, size_t, __global half *); +void __ovld vstore_half3_rtp(double3, size_t, __global half *); +void __ovld vstore_half4_rtp(double4, size_t, __global half *); +void __ovld vstore_half8_rtp(double8, size_t, __global half *); +void __ovld vstore_half16_rtp(double16, size_t, __global half *); +void __ovld vstore_half2_rtn(double2, size_t, __global half *); +void __ovld vstore_half3_rtn(double3, size_t, __global half *); +void __ovld vstore_half4_rtn(double4, size_t, __global half *); +void __ovld vstore_half8_rtn(double8, size_t, __global half *); +void __ovld vstore_half16_rtn(double16, size_t, __global half *); +void __ovld vstore_half2(double2, size_t, __local half *); +void __ovld vstore_half3(double3, size_t, __local half *); +void __ovld vstore_half4(double4, size_t, __local half *); +void __ovld vstore_half8(double8, size_t, __local half *); +void __ovld vstore_half16(double16, size_t, __local half *); +void __ovld vstore_half2_rte(double2, size_t, __local half *); +void __ovld vstore_half3_rte(double3, size_t, __local half *); +void __ovld vstore_half4_rte(double4, size_t, __local half *); +void __ovld vstore_half8_rte(double8, size_t, __local half *); +void __ovld vstore_half16_rte(double16, size_t, __local half *); +void __ovld vstore_half2_rtz(double2, size_t, __local half *); +void __ovld vstore_half3_rtz(double3, size_t, __local half *); +void __ovld vstore_half4_rtz(double4, size_t, __local half *); +void __ovld vstore_half8_rtz(double8, size_t, __local half *); +void __ovld vstore_half16_rtz(double16, size_t, __local half *); +void __ovld vstore_half2_rtp(double2, size_t, __local half *); +void __ovld vstore_half3_rtp(double3, size_t, __local half *); +void __ovld vstore_half4_rtp(double4, size_t, __local half *); +void __ovld vstore_half8_rtp(double8, size_t, __local half *); +void __ovld vstore_half16_rtp(double16, size_t, __local half *); +void __ovld vstore_half2_rtn(double2, size_t, __local half *); +void __ovld vstore_half3_rtn(double3, size_t, __local half *); +void __ovld vstore_half4_rtn(double4, size_t, __local half *); +void __ovld vstore_half8_rtn(double8, size_t, __local half *); +void __ovld vstore_half16_rtn(double16, size_t, __local half *); +void __ovld vstore_half2(double2, size_t, __private half *); +void __ovld vstore_half3(double3, size_t, __private half *); +void __ovld vstore_half4(double4, size_t, __private half *); +void __ovld vstore_half8(double8, size_t, __private half *); +void __ovld vstore_half16(double16, size_t, __private half *); +void __ovld vstore_half2_rte(double2, size_t, __private half *); +void __ovld vstore_half3_rte(double3, size_t, __private half *); +void __ovld vstore_half4_rte(double4, size_t, __private half *); +void __ovld vstore_half8_rte(double8, size_t, __private half *); +void __ovld vstore_half16_rte(double16, size_t, __private half *); +void __ovld vstore_half2_rtz(double2, size_t, __private half *); +void __ovld vstore_half3_rtz(double3, size_t, __private half *); +void __ovld vstore_half4_rtz(double4, size_t, __private half *); +void __ovld vstore_half8_rtz(double8, size_t, __private half *); +void __ovld vstore_half16_rtz(double16, size_t, __private half *); +void __ovld vstore_half2_rtp(double2, size_t, __private half *); +void __ovld vstore_half3_rtp(double3, size_t, __private half *); +void __ovld vstore_half4_rtp(double4, size_t, __private half *); +void __ovld vstore_half8_rtp(double8, size_t, __private half *); +void __ovld vstore_half16_rtp(double16, size_t, __private half *); +void __ovld vstore_half2_rtn(double2, size_t, __private half *); +void __ovld vstore_half3_rtn(double3, size_t, __private half *); +void __ovld vstore_half4_rtn(double4, size_t, __private half *); +void __ovld vstore_half8_rtn(double8, size_t, __private half *); +void __ovld vstore_half16_rtn(double16, size_t, __private half *); +#endif //cl_khr_fp64 +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * For n = 1, 2, 4, 8 and 16 read sizeof (halfn) + * bytes of data from address (p + (offset * n)). + * The data read is interpreted as a halfn value. + * The halfn value read is converted to a floatn + * value and the floatn value is returned. + * The address computed as (p + (offset * n)) + * must be aligned to sizeof (halfn) bytes. + * For n = 3, vloada_half3 reads a half3 from + * address (p + (offset * 4)) and returns a float3. + * The address computed as (p + (offset * 4)) + * must be aligned to sizeof (half) * 4 bytes. + */ +float2 __ovld __purefn vloada_half2(size_t, const __constant half *); +float3 __ovld __purefn vloada_half3(size_t, const __constant half *); +float4 __ovld __purefn vloada_half4(size_t, const __constant half *); +float8 __ovld __purefn vloada_half8(size_t, const __constant half *); +float16 __ovld __purefn vloada_half16(size_t, const __constant half *); +#if defined(__opencl_c_generic_address_space) +float2 __ovld __purefn vloada_half2(size_t, const half *); +float3 __ovld __purefn vloada_half3(size_t, const half *); +float4 __ovld __purefn vloada_half4(size_t, const half *); +float8 __ovld __purefn vloada_half8(size_t, const half *); +float16 __ovld __purefn vloada_half16(size_t, const half *); +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +float2 __ovld __purefn vloada_half2(size_t, const __global half *); +float3 __ovld __purefn vloada_half3(size_t, const __global half *); +float4 __ovld __purefn vloada_half4(size_t, const __global half *); +float8 __ovld __purefn vloada_half8(size_t, const __global half *); +float16 __ovld __purefn vloada_half16(size_t, const __global half *); +float2 __ovld __purefn vloada_half2(size_t, const __local half *); +float3 __ovld __purefn vloada_half3(size_t, const __local half *); +float4 __ovld __purefn vloada_half4(size_t, const __local half *); +float8 __ovld __purefn vloada_half8(size_t, const __local half *); +float16 __ovld __purefn vloada_half16(size_t, const __local half *); +float2 __ovld __purefn vloada_half2(size_t, const __private half *); +float3 __ovld __purefn vloada_half3(size_t, const __private half *); +float4 __ovld __purefn vloada_half4(size_t, const __private half *); +float8 __ovld __purefn vloada_half8(size_t, const __private half *); +float16 __ovld __purefn vloada_half16(size_t, const __private half *); +#endif //defined(__opencl_c_named_address_space_builtins) + +/** + * The floatn value given by data is converted to + * a halfn value using the appropriate rounding + * mode. + * For n = 1, 2, 4, 8 and 16, the halfn value is + * written to the address computed as (p + (offset + * * n)). The address computed as (p + (offset * + * n)) must be aligned to sizeof (halfn) bytes. + * For n = 3, the half3 value is written to the + * address computed as (p + (offset * 4)). The + * address computed as (p + (offset * 4)) must be + * aligned to sizeof (half) * 4 bytes. + * vstorea_halfn uses the current rounding + * mode. The default current rounding mode is + * round to nearest even. + */ +#if defined(__opencl_c_generic_address_space) +void __ovld vstorea_half2(float2, size_t, half *); +void __ovld vstorea_half3(float3, size_t, half *); +void __ovld vstorea_half4(float4, size_t, half *); +void __ovld vstorea_half8(float8, size_t, half *); +void __ovld vstorea_half16(float16, size_t, half *); + +void __ovld vstorea_half2_rte(float2, size_t, half *); +void __ovld vstorea_half3_rte(float3, size_t, half *); +void __ovld vstorea_half4_rte(float4, size_t, half *); +void __ovld vstorea_half8_rte(float8, size_t, half *); +void __ovld vstorea_half16_rte(float16, size_t, half *); + +void __ovld vstorea_half2_rtz(float2, size_t, half *); +void __ovld vstorea_half3_rtz(float3, size_t, half *); +void __ovld vstorea_half4_rtz(float4, size_t, half *); +void __ovld vstorea_half8_rtz(float8, size_t, half *); +void __ovld vstorea_half16_rtz(float16, size_t, half *); + +void __ovld vstorea_half2_rtp(float2, size_t, half *); +void __ovld vstorea_half3_rtp(float3, size_t, half *); +void __ovld vstorea_half4_rtp(float4, size_t, half *); +void __ovld vstorea_half8_rtp(float8, size_t, half *); +void __ovld vstorea_half16_rtp(float16, size_t, half *); + +void __ovld vstorea_half2_rtn(float2, size_t, half *); +void __ovld vstorea_half3_rtn(float3, size_t, half *); +void __ovld vstorea_half4_rtn(float4, size_t, half *); +void __ovld vstorea_half8_rtn(float8, size_t, half *); +void __ovld vstorea_half16_rtn(float16, size_t, half *); + +#ifdef cl_khr_fp64 +void __ovld vstorea_half2(double2, size_t, half *); +void __ovld vstorea_half3(double3, size_t, half *); +void __ovld vstorea_half4(double4, size_t, half *); +void __ovld vstorea_half8(double8, size_t, half *); +void __ovld vstorea_half16(double16, size_t, half *); + +void __ovld vstorea_half2_rte(double2, size_t, half *); +void __ovld vstorea_half3_rte(double3, size_t, half *); +void __ovld vstorea_half4_rte(double4, size_t, half *); +void __ovld vstorea_half8_rte(double8, size_t, half *); +void __ovld vstorea_half16_rte(double16, size_t, half *); + +void __ovld vstorea_half2_rtz(double2, size_t, half *); +void __ovld vstorea_half3_rtz(double3, size_t, half *); +void __ovld vstorea_half4_rtz(double4, size_t, half *); +void __ovld vstorea_half8_rtz(double8, size_t, half *); +void __ovld vstorea_half16_rtz(double16, size_t, half *); + +void __ovld vstorea_half2_rtp(double2, size_t, half *); +void __ovld vstorea_half3_rtp(double3, size_t, half *); +void __ovld vstorea_half4_rtp(double4, size_t, half *); +void __ovld vstorea_half8_rtp(double8, size_t, half *); +void __ovld vstorea_half16_rtp(double16, size_t, half *); + +void __ovld vstorea_half2_rtn(double2, size_t, half *); +void __ovld vstorea_half3_rtn(double3, size_t, half *); +void __ovld vstorea_half4_rtn(double4, size_t, half *); +void __ovld vstorea_half8_rtn(double8, size_t, half *); +void __ovld vstorea_half16_rtn(double16, size_t, half *); +#endif //cl_khr_fp64 +#endif //defined(__opencl_c_generic_address_space) + +#if defined(__opencl_c_named_address_space_builtins) +void __ovld vstorea_half2(float2, size_t, __global half *); +void __ovld vstorea_half3(float3, size_t, __global half *); +void __ovld vstorea_half4(float4, size_t, __global half *); +void __ovld vstorea_half8(float8, size_t, __global half *); +void __ovld vstorea_half16(float16, size_t, __global half *); + +void __ovld vstorea_half2_rte(float2, size_t, __global half *); +void __ovld vstorea_half3_rte(float3, size_t, __global half *); +void __ovld vstorea_half4_rte(float4, size_t, __global half *); +void __ovld vstorea_half8_rte(float8, size_t, __global half *); +void __ovld vstorea_half16_rte(float16, size_t, __global half *); + +void __ovld vstorea_half2_rtz(float2, size_t, __global half *); +void __ovld vstorea_half3_rtz(float3, size_t, __global half *); +void __ovld vstorea_half4_rtz(float4, size_t, __global half *); +void __ovld vstorea_half8_rtz(float8, size_t, __global half *); +void __ovld vstorea_half16_rtz(float16, size_t, __global half *); + +void __ovld vstorea_half2_rtp(float2, size_t, __global half *); +void __ovld vstorea_half3_rtp(float3, size_t, __global half *); +void __ovld vstorea_half4_rtp(float4, size_t, __global half *); +void __ovld vstorea_half8_rtp(float8, size_t, __global half *); +void __ovld vstorea_half16_rtp(float16, size_t, __global half *); + +void __ovld vstorea_half2_rtn(float2, size_t, __global half *); +void __ovld vstorea_half3_rtn(float3, size_t, __global half *); +void __ovld vstorea_half4_rtn(float4, size_t, __global half *); +void __ovld vstorea_half8_rtn(float8, size_t, __global half *); +void __ovld vstorea_half16_rtn(float16, size_t, __global half *); + +void __ovld vstorea_half2(float2, size_t, __local half *); +void __ovld vstorea_half3(float3, size_t, __local half *); +void __ovld vstorea_half4(float4, size_t, __local half *); +void __ovld vstorea_half8(float8, size_t, __local half *); +void __ovld vstorea_half16(float16, size_t, __local half *); + +void __ovld vstorea_half2_rte(float2, size_t, __local half *); +void __ovld vstorea_half3_rte(float3, size_t, __local half *); +void __ovld vstorea_half4_rte(float4, size_t, __local half *); +void __ovld vstorea_half8_rte(float8, size_t, __local half *); +void __ovld vstorea_half16_rte(float16, size_t, __local half *); + +void __ovld vstorea_half2_rtz(float2, size_t, __local half *); +void __ovld vstorea_half3_rtz(float3, size_t, __local half *); +void __ovld vstorea_half4_rtz(float4, size_t, __local half *); +void __ovld vstorea_half8_rtz(float8, size_t, __local half *); +void __ovld vstorea_half16_rtz(float16, size_t, __local half *); + +void __ovld vstorea_half2_rtp(float2, size_t, __local half *); +void __ovld vstorea_half3_rtp(float3, size_t, __local half *); +void __ovld vstorea_half4_rtp(float4, size_t, __local half *); +void __ovld vstorea_half8_rtp(float8, size_t, __local half *); +void __ovld vstorea_half16_rtp(float16, size_t, __local half *); + +void __ovld vstorea_half2_rtn(float2, size_t, __local half *); +void __ovld vstorea_half3_rtn(float3, size_t, __local half *); +void __ovld vstorea_half4_rtn(float4, size_t, __local half *); +void __ovld vstorea_half8_rtn(float8, size_t, __local half *); +void __ovld vstorea_half16_rtn(float16, size_t, __local half *); + +void __ovld vstorea_half2(float2, size_t, __private half *); +void __ovld vstorea_half3(float3, size_t, __private half *); +void __ovld vstorea_half4(float4, size_t, __private half *); +void __ovld vstorea_half8(float8, size_t, __private half *); +void __ovld vstorea_half16(float16, size_t, __private half *); + +void __ovld vstorea_half2_rte(float2, size_t, __private half *); +void __ovld vstorea_half3_rte(float3, size_t, __private half *); +void __ovld vstorea_half4_rte(float4, size_t, __private half *); +void __ovld vstorea_half8_rte(float8, size_t, __private half *); +void __ovld vstorea_half16_rte(float16, size_t, __private half *); + +void __ovld vstorea_half2_rtz(float2, size_t, __private half *); +void __ovld vstorea_half3_rtz(float3, size_t, __private half *); +void __ovld vstorea_half4_rtz(float4, size_t, __private half *); +void __ovld vstorea_half8_rtz(float8, size_t, __private half *); +void __ovld vstorea_half16_rtz(float16, size_t, __private half *); + +void __ovld vstorea_half2_rtp(float2, size_t, __private half *); +void __ovld vstorea_half3_rtp(float3, size_t, __private half *); +void __ovld vstorea_half4_rtp(float4, size_t, __private half *); +void __ovld vstorea_half8_rtp(float8, size_t, __private half *); +void __ovld vstorea_half16_rtp(float16, size_t, __private half *); + +void __ovld vstorea_half2_rtn(float2, size_t, __private half *); +void __ovld vstorea_half3_rtn(float3, size_t, __private half *); +void __ovld vstorea_half4_rtn(float4, size_t, __private half *); +void __ovld vstorea_half8_rtn(float8, size_t, __private half *); +void __ovld vstorea_half16_rtn(float16, size_t, __private half *); + +#ifdef cl_khr_fp64 +void __ovld vstorea_half2(double2, size_t, __global half *); +void __ovld vstorea_half3(double3, size_t, __global half *); +void __ovld vstorea_half4(double4, size_t, __global half *); +void __ovld vstorea_half8(double8, size_t, __global half *); +void __ovld vstorea_half16(double16, size_t, __global half *); + +void __ovld vstorea_half2_rte(double2, size_t, __global half *); +void __ovld vstorea_half3_rte(double3, size_t, __global half *); +void __ovld vstorea_half4_rte(double4, size_t, __global half *); +void __ovld vstorea_half8_rte(double8, size_t, __global half *); +void __ovld vstorea_half16_rte(double16, size_t, __global half *); + +void __ovld vstorea_half2_rtz(double2, size_t, __global half *); +void __ovld vstorea_half3_rtz(double3, size_t, __global half *); +void __ovld vstorea_half4_rtz(double4, size_t, __global half *); +void __ovld vstorea_half8_rtz(double8, size_t, __global half *); +void __ovld vstorea_half16_rtz(double16, size_t, __global half *); + +void __ovld vstorea_half2_rtp(double2, size_t, __global half *); +void __ovld vstorea_half3_rtp(double3, size_t, __global half *); +void __ovld vstorea_half4_rtp(double4, size_t, __global half *); +void __ovld vstorea_half8_rtp(double8, size_t, __global half *); +void __ovld vstorea_half16_rtp(double16, size_t, __global half *); + +void __ovld vstorea_half2_rtn(double2, size_t, __global half *); +void __ovld vstorea_half3_rtn(double3, size_t, __global half *); +void __ovld vstorea_half4_rtn(double4, size_t, __global half *); +void __ovld vstorea_half8_rtn(double8, size_t, __global half *); +void __ovld vstorea_half16_rtn(double16, size_t, __global half *); + +void __ovld vstorea_half2(double2, size_t, __local half *); +void __ovld vstorea_half3(double3, size_t, __local half *); +void __ovld vstorea_half4(double4, size_t, __local half *); +void __ovld vstorea_half8(double8, size_t, __local half *); +void __ovld vstorea_half16(double16, size_t, __local half *); + +void __ovld vstorea_half2_rte(double2, size_t, __local half *); +void __ovld vstorea_half3_rte(double3, size_t, __local half *); +void __ovld vstorea_half4_rte(double4, size_t, __local half *); +void __ovld vstorea_half8_rte(double8, size_t, __local half *); +void __ovld vstorea_half16_rte(double16, size_t, __local half *); + +void __ovld vstorea_half2_rtz(double2, size_t, __local half *); +void __ovld vstorea_half3_rtz(double3, size_t, __local half *); +void __ovld vstorea_half4_rtz(double4, size_t, __local half *); +void __ovld vstorea_half8_rtz(double8, size_t, __local half *); +void __ovld vstorea_half16_rtz(double16, size_t, __local half *); + +void __ovld vstorea_half2_rtp(double2, size_t, __local half *); +void __ovld vstorea_half3_rtp(double3, size_t, __local half *); +void __ovld vstorea_half4_rtp(double4, size_t, __local half *); +void __ovld vstorea_half8_rtp(double8, size_t, __local half *); +void __ovld vstorea_half16_rtp(double16, size_t, __local half *); + +void __ovld vstorea_half2_rtn(double2, size_t, __local half *); +void __ovld vstorea_half3_rtn(double3, size_t, __local half *); +void __ovld vstorea_half4_rtn(double4, size_t, __local half *); +void __ovld vstorea_half8_rtn(double8, size_t, __local half *); +void __ovld vstorea_half16_rtn(double16, size_t, __local half *); + +void __ovld vstorea_half2(double2, size_t, __private half *); +void __ovld vstorea_half3(double3, size_t, __private half *); +void __ovld vstorea_half4(double4, size_t, __private half *); +void __ovld vstorea_half8(double8, size_t, __private half *); +void __ovld vstorea_half16(double16, size_t, __private half *); + +void __ovld vstorea_half2_rte(double2, size_t, __private half *); +void __ovld vstorea_half3_rte(double3, size_t, __private half *); +void __ovld vstorea_half4_rte(double4, size_t, __private half *); +void __ovld vstorea_half8_rte(double8, size_t, __private half *); +void __ovld vstorea_half16_rte(double16, size_t, __private half *); + +void __ovld vstorea_half2_rtz(double2, size_t, __private half *); +void __ovld vstorea_half3_rtz(double3, size_t, __private half *); +void __ovld vstorea_half4_rtz(double4, size_t, __private half *); +void __ovld vstorea_half8_rtz(double8, size_t, __private half *); +void __ovld vstorea_half16_rtz(double16, size_t, __private half *); + +void __ovld vstorea_half2_rtp(double2, size_t, __private half *); +void __ovld vstorea_half3_rtp(double3, size_t, __private half *); +void __ovld vstorea_half4_rtp(double4, size_t, __private half *); +void __ovld vstorea_half8_rtp(double8, size_t, __private half *); +void __ovld vstorea_half16_rtp(double16, size_t, __private half *); + +void __ovld vstorea_half2_rtn(double2, size_t, __private half *); +void __ovld vstorea_half3_rtn(double3, size_t, __private half *); +void __ovld vstorea_half4_rtn(double4, size_t, __private half *); +void __ovld vstorea_half8_rtn(double8, size_t, __private half *); +void __ovld vstorea_half16_rtn(double16, size_t, __private half *); +#endif //cl_khr_fp64 +#endif //defined(__opencl_c_named_address_space_builtins) + +// OpenCL v1.1 s6.11.8, v1.2 s6.12.8, v2.0 s6.13.8 - Synchronization Functions + +/** + * All work-items in a work-group executing the kernel + * on a processor must execute this function before any + * are allowed to continue execution beyond the barrier. + * This function must be encountered by all work-items in + * a work-group executing the kernel. + * If barrier is inside a conditional statement, then all + * work-items must enter the conditional if any work-item + * enters the conditional statement and executes the + * barrier. + * If barrer is inside a loop, all work-items must execute + * the barrier for each iteration of the loop before any are + * allowed to continue execution beyond the barrier. + * The barrier function also queues a memory fence + * (reads and writes) to ensure correct ordering of + * memory operations to local or global memory. + * The flags argument specifies the memory address space + * and can be set to a combination of the following literal + * values. + * CLK_LOCAL_MEM_FENCE - The barrier function + * will either flush any variables stored in local memory + * or queue a memory fence to ensure correct ordering of + * memory operations to local memory. + * CLK_GLOBAL_MEM_FENCE - The barrier function + * will queue a memory fence to ensure correct ordering + * of memory operations to global memory. This can be + * useful when work-items, for example, write to buffer or + * image objects and then want to read the updated data. + */ + +void __ovld __conv barrier(cl_mem_fence_flags); + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +void __ovld __conv work_group_barrier(cl_mem_fence_flags, memory_scope); +void __ovld __conv work_group_barrier(cl_mem_fence_flags); +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// OpenCL v1.1 s6.11.9, v1.2 s6.12.9 - Explicit Memory Fence Functions + +/** + * Orders loads and stores of a work-item + * executing a kernel. This means that loads + * and stores preceding the mem_fence will + * be committed to memory before any loads + * and stores following the mem_fence. + * The flags argument specifies the memory + * address space and can be set to a + * combination of the following literal + * values: + * CLK_LOCAL_MEM_FENCE + * CLK_GLOBAL_MEM_FENCE. + */ +void __ovld mem_fence(cl_mem_fence_flags); + +/** + * Read memory barrier that orders only + * loads. + * The flags argument specifies the memory + * address space and can be set to a + * combination of the following literal + * values: + * CLK_LOCAL_MEM_FENCE + * CLK_GLOBAL_MEM_FENCE. + */ +void __ovld read_mem_fence(cl_mem_fence_flags); + +/** + * Write memory barrier that orders only + * stores. + * The flags argument specifies the memory + * address space and can be set to a + * combination of the following literal + * values: + * CLK_LOCAL_MEM_FENCE + * CLK_GLOBAL_MEM_FENCE. + */ +void __ovld write_mem_fence(cl_mem_fence_flags); + +// OpenCL v2.0 s6.13.9 - Address Space Qualifier Functions + +#if defined(__opencl_c_generic_address_space) +cl_mem_fence_flags __ovld get_fence(const void *ptr); +cl_mem_fence_flags __ovld get_fence(void *ptr); + +/** + * Builtin functions to_global, to_local, and to_private need to be declared as Clang builtin functions + * and checked in Sema since they should be declared as + * addr gentype* to_addr (gentype*); + * where gentype is builtin type or user defined type. + */ + +#endif //defined(__opencl_c_generic_address_space) + +// OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10 - Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch + +/** + * event_t async_work_group_copy ( + * __global gentype *dst, + * const __local gentype *src, + * size_t num_elements, + * event_t event) + * Perform an async copy of num_elements + * gentype elements from src to dst. The async + * copy is performed by all work-items in a workgroup + * and this built-in function must therefore + * be encountered by all work-items in a workgroup + * executing the kernel with the same + * argument values; otherwise the results are + * undefined. + * Returns an event object that can be used by + * wait_group_events to wait for the async copy + * to finish. The event argument can also be used + * to associate the async_work_group_copy with + * a previous async copy allowing an event to be + * shared by multiple async copies; otherwise event + * should be zero. + * If event argument is non-zero, the event object + * supplied in event argument will be returned. + * This function does not perform any implicit + * synchronization of source data such as using a + * barrier before performing the copy. + */ +event_t __ovld async_work_group_copy(__local char *, const __global char *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uchar *, const __global uchar *, size_t, event_t); +event_t __ovld async_work_group_copy(__local short *, const __global short *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ushort *, const __global ushort *, size_t, event_t); +event_t __ovld async_work_group_copy(__local int *, const __global int *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uint *, const __global uint *, size_t, event_t); +event_t __ovld async_work_group_copy(__local long *, const __global long *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ulong *, const __global ulong *, size_t, event_t); +event_t __ovld async_work_group_copy(__local float *, const __global float *, size_t, event_t); +event_t __ovld async_work_group_copy(__local char2 *, const __global char2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uchar2 *, const __global uchar2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local short2 *, const __global short2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ushort2 *, const __global ushort2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local int2 *, const __global int2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uint2 *, const __global uint2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local long2 *, const __global long2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ulong2 *, const __global ulong2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local float2 *, const __global float2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local char3 *, const __global char3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uchar3 *, const __global uchar3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local short3 *, const __global short3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ushort3 *, const __global ushort3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local int3 *, const __global int3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uint3 *, const __global uint3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local long3 *, const __global long3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ulong3 *, const __global ulong3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local float3 *, const __global float3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local char4 *, const __global char4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uchar4 *, const __global uchar4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local short4 *, const __global short4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ushort4 *, const __global ushort4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local int4 *, const __global int4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uint4 *, const __global uint4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local long4 *, const __global long4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ulong4 *, const __global ulong4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local float4 *, const __global float4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local char8 *, const __global char8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uchar8 *, const __global uchar8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local short8 *, const __global short8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ushort8 *, const __global ushort8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local int8 *, const __global int8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uint8 *, const __global uint8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local long8 *, const __global long8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ulong8 *, const __global ulong8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local float8 *, const __global float8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local char16 *, const __global char16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uchar16 *, const __global uchar16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local short16 *, const __global short16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ushort16 *, const __global ushort16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local int16 *, const __global int16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local uint16 *, const __global uint16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local long16 *, const __global long16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local ulong16 *, const __global ulong16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local float16 *, const __global float16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global char *, const __local char *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uchar *, const __local uchar *, size_t, event_t); +event_t __ovld async_work_group_copy(__global short *, const __local short *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ushort *, const __local ushort *, size_t, event_t); +event_t __ovld async_work_group_copy(__global int *, const __local int *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uint *, const __local uint *, size_t, event_t); +event_t __ovld async_work_group_copy(__global long *, const __local long *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ulong *, const __local ulong *, size_t, event_t); +event_t __ovld async_work_group_copy(__global float *, const __local float *, size_t, event_t); +event_t __ovld async_work_group_copy(__global char2 *, const __local char2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uchar2 *, const __local uchar2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global short2 *, const __local short2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ushort2 *, const __local ushort2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global int2 *, const __local int2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uint2 *, const __local uint2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global long2 *, const __local long2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ulong2 *, const __local ulong2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global float2 *, const __local float2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global char3 *, const __local char3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uchar3 *, const __local uchar3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global short3 *, const __local short3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ushort3 *, const __local ushort3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global int3 *, const __local int3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uint3 *, const __local uint3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global long3 *, const __local long3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ulong3 *, const __local ulong3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global float3 *, const __local float3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global char4 *, const __local char4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uchar4 *, const __local uchar4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global short4 *, const __local short4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ushort4 *, const __local ushort4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global int4 *, const __local int4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uint4 *, const __local uint4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global long4 *, const __local long4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ulong4 *, const __local ulong4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global float4 *, const __local float4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global char8 *, const __local char8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uchar8 *, const __local uchar8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global short8 *, const __local short8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ushort8 *, const __local ushort8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global int8 *, const __local int8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uint8 *, const __local uint8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global long8 *, const __local long8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ulong8 *, const __local ulong8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global float8 *, const __local float8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global char16 *, const __local char16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uchar16 *, const __local uchar16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global short16 *, const __local short16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ushort16 *, const __local ushort16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global int16 *, const __local int16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global uint16 *, const __local uint16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global long16 *, const __local long16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global ulong16 *, const __local ulong16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global float16 *, const __local float16 *, size_t, event_t); +#ifdef cl_khr_fp64 +event_t __ovld async_work_group_copy(__local double *, const __global double *, size_t, event_t); +event_t __ovld async_work_group_copy(__local double2 *, const __global double2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local double3 *, const __global double3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local double4 *, const __global double4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local double8 *, const __global double8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local double16 *, const __global double16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global double *, const __local double *, size_t, event_t); +event_t __ovld async_work_group_copy(__global double2 *, const __local double2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global double3 *, const __local double3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global double4 *, const __local double4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global double8 *, const __local double8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global double16 *, const __local double16 *, size_t, event_t); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +event_t __ovld async_work_group_copy(__local half *, const __global half *, size_t, event_t); +event_t __ovld async_work_group_copy(__local half2 *, const __global half2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local half3 *, const __global half3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local half4 *, const __global half4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local half8 *, const __global half8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__local half16 *, const __global half16 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global half *, const __local half *, size_t, event_t); +event_t __ovld async_work_group_copy(__global half2 *, const __local half2 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global half3 *, const __local half3 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global half4 *, const __local half4 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global half8 *, const __local half8 *, size_t, event_t); +event_t __ovld async_work_group_copy(__global half16 *, const __local half16 *, size_t, event_t); +#endif //cl_khr_fp16 + +/** + * Perform an async gather of num_elements + * gentype elements from src to dst. The + * src_stride is the stride in elements for each + * gentype element read from src. The dst_stride + * is the stride in elements for each gentype + * element written to dst. The async gather is + * performed by all work-items in a work-group. + * This built-in function must therefore be + * encountered by all work-items in a work-group + * executing the kernel with the same argument + * values; otherwise the results are undefined. + * Returns an event object that can be used by + * wait_group_events to wait for the async copy + * to finish. The event argument can also be used + * to associate the + * async_work_group_strided_copy with a + * previous async copy allowing an event to be + * shared by multiple async copies; otherwise event + * should be zero. + * If event argument is non-zero, the event object + * supplied in event argument will be returned. + * This function does not perform any implicit + * synchronization of source data such as using a + * barrier before performing the copy. + */ +event_t __ovld async_work_group_strided_copy(__local char *, const __global char *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uchar *, const __global uchar *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local short *, const __global short *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ushort *, const __global ushort *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local int *, const __global int *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uint *, const __global uint *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local long *, const __global long *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ulong *, const __global ulong *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local float *, const __global float *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local char2 *, const __global char2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uchar2 *, const __global uchar2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local short2 *, const __global short2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ushort2 *, const __global ushort2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local int2 *, const __global int2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uint2 *, const __global uint2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local long2 *, const __global long2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ulong2 *, const __global ulong2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local float2 *, const __global float2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local char3 *, const __global char3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uchar3 *, const __global uchar3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local short3 *, const __global short3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ushort3 *, const __global ushort3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local int3 *, const __global int3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uint3 *, const __global uint3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local long3 *, const __global long3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ulong3 *, const __global ulong3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local float3 *, const __global float3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local char4 *, const __global char4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uchar4 *, const __global uchar4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local short4 *, const __global short4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ushort4 *, const __global ushort4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local int4 *, const __global int4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uint4 *, const __global uint4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local long4 *, const __global long4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ulong4 *, const __global ulong4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local float4 *, const __global float4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local char8 *, const __global char8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uchar8 *, const __global uchar8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local short8 *, const __global short8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ushort8 *, const __global ushort8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local int8 *, const __global int8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uint8 *, const __global uint8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local long8 *, const __global long8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ulong8 *, const __global ulong8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local float8 *, const __global float8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local char16 *, const __global char16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uchar16 *, const __global uchar16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local short16 *, const __global short16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ushort16 *, const __global ushort16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local int16 *, const __global int16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local uint16 *, const __global uint16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local long16 *, const __global long16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local ulong16 *, const __global ulong16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local float16 *, const __global float16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global char *, const __local char *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uchar *, const __local uchar *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global short *, const __local short *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ushort *, const __local ushort *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global int *, const __local int *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uint *, const __local uint *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global long *, const __local long *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ulong *, const __local ulong *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global float *, const __local float *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global char2 *, const __local char2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uchar2 *, const __local uchar2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global short2 *, const __local short2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ushort2 *, const __local ushort2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global int2 *, const __local int2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uint2 *, const __local uint2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global long2 *, const __local long2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ulong2 *, const __local ulong2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global float2 *, const __local float2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global char3 *, const __local char3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uchar3 *, const __local uchar3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global short3 *, const __local short3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ushort3 *, const __local ushort3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global int3 *, const __local int3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uint3 *, const __local uint3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global long3 *, const __local long3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ulong3 *, const __local ulong3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global float3 *, const __local float3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global char4 *, const __local char4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uchar4 *, const __local uchar4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global short4 *, const __local short4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ushort4 *, const __local ushort4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global int4 *, const __local int4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uint4 *, const __local uint4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global long4 *, const __local long4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ulong4 *, const __local ulong4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global float4 *, const __local float4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global char8 *, const __local char8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uchar8 *, const __local uchar8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global short8 *, const __local short8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ushort8 *, const __local ushort8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global int8 *, const __local int8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uint8 *, const __local uint8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global long8 *, const __local long8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ulong8 *, const __local ulong8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global float8 *, const __local float8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global char16 *, const __local char16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uchar16 *, const __local uchar16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global short16 *, const __local short16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ushort16 *, const __local ushort16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global int16 *, const __local int16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global uint16 *, const __local uint16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global long16 *, const __local long16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global ulong16 *, const __local ulong16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global float16 *, const __local float16 *, size_t, size_t, event_t); +#ifdef cl_khr_fp64 +event_t __ovld async_work_group_strided_copy(__local double *, const __global double *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local double2 *, const __global double2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local double3 *, const __global double3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local double4 *, const __global double4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local double8 *, const __global double8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local double16 *, const __global double16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global double *, const __local double *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global double2 *, const __local double2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global double3 *, const __local double3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global double4 *, const __local double4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global double8 *, const __local double8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global double16 *, const __local double16 *, size_t, size_t, event_t); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +event_t __ovld async_work_group_strided_copy(__local half *, const __global half *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local half2 *, const __global half2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local half3 *, const __global half3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local half4 *, const __global half4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local half8 *, const __global half8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__local half16 *, const __global half16 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global half *, const __local half *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global half2 *, const __local half2 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global half3 *, const __local half3 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global half4 *, const __local half4 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global half8 *, const __local half8 *, size_t, size_t, event_t); +event_t __ovld async_work_group_strided_copy(__global half16 *, const __local half16 *, size_t, size_t, event_t); +#endif //cl_khr_fp16 + +/** + * Wait for events that identify the + * async_work_group_copy operations to + * complete. The event objects specified in + * event_list will be released after the wait is + * performed. + * This function must be encountered by all workitems + * in a work-group executing the kernel with + * the same num_events and event objects specified + * in event_list; otherwise the results are undefined. + */ +void __ovld wait_group_events(int, event_t *); + +/** + * Prefetch num_elements * sizeof(gentype) + * bytes into the global cache. The prefetch + * instruction is applied to a work-item in a workgroup + * and does not affect the functional + * behavior of the kernel. + */ +void __ovld prefetch(const __global char *, size_t); +void __ovld prefetch(const __global uchar *, size_t); +void __ovld prefetch(const __global short *, size_t); +void __ovld prefetch(const __global ushort *, size_t); +void __ovld prefetch(const __global int *, size_t); +void __ovld prefetch(const __global uint *, size_t); +void __ovld prefetch(const __global long *, size_t); +void __ovld prefetch(const __global ulong *, size_t); +void __ovld prefetch(const __global float *, size_t); +void __ovld prefetch(const __global char2 *, size_t); +void __ovld prefetch(const __global uchar2 *, size_t); +void __ovld prefetch(const __global short2 *, size_t); +void __ovld prefetch(const __global ushort2 *, size_t); +void __ovld prefetch(const __global int2 *, size_t); +void __ovld prefetch(const __global uint2 *, size_t); +void __ovld prefetch(const __global long2 *, size_t); +void __ovld prefetch(const __global ulong2 *, size_t); +void __ovld prefetch(const __global float2 *, size_t); +void __ovld prefetch(const __global char3 *, size_t); +void __ovld prefetch(const __global uchar3 *, size_t); +void __ovld prefetch(const __global short3 *, size_t); +void __ovld prefetch(const __global ushort3 *, size_t); +void __ovld prefetch(const __global int3 *, size_t); +void __ovld prefetch(const __global uint3 *, size_t); +void __ovld prefetch(const __global long3 *, size_t); +void __ovld prefetch(const __global ulong3 *, size_t); +void __ovld prefetch(const __global float3 *, size_t); +void __ovld prefetch(const __global char4 *, size_t); +void __ovld prefetch(const __global uchar4 *, size_t); +void __ovld prefetch(const __global short4 *, size_t); +void __ovld prefetch(const __global ushort4 *, size_t); +void __ovld prefetch(const __global int4 *, size_t); +void __ovld prefetch(const __global uint4 *, size_t); +void __ovld prefetch(const __global long4 *, size_t); +void __ovld prefetch(const __global ulong4 *, size_t); +void __ovld prefetch(const __global float4 *, size_t); +void __ovld prefetch(const __global char8 *, size_t); +void __ovld prefetch(const __global uchar8 *, size_t); +void __ovld prefetch(const __global short8 *, size_t); +void __ovld prefetch(const __global ushort8 *, size_t); +void __ovld prefetch(const __global int8 *, size_t); +void __ovld prefetch(const __global uint8 *, size_t); +void __ovld prefetch(const __global long8 *, size_t); +void __ovld prefetch(const __global ulong8 *, size_t); +void __ovld prefetch(const __global float8 *, size_t); +void __ovld prefetch(const __global char16 *, size_t); +void __ovld prefetch(const __global uchar16 *, size_t); +void __ovld prefetch(const __global short16 *, size_t); +void __ovld prefetch(const __global ushort16 *, size_t); +void __ovld prefetch(const __global int16 *, size_t); +void __ovld prefetch(const __global uint16 *, size_t); +void __ovld prefetch(const __global long16 *, size_t); +void __ovld prefetch(const __global ulong16 *, size_t); +void __ovld prefetch(const __global float16 *, size_t); +#ifdef cl_khr_fp64 +void __ovld prefetch(const __global double *, size_t); +void __ovld prefetch(const __global double2 *, size_t); +void __ovld prefetch(const __global double3 *, size_t); +void __ovld prefetch(const __global double4 *, size_t); +void __ovld prefetch(const __global double8 *, size_t); +void __ovld prefetch(const __global double16 *, size_t); +#endif //cl_khr_fp64 +#ifdef cl_khr_fp16 +void __ovld prefetch(const __global half *, size_t); +void __ovld prefetch(const __global half2 *, size_t); +void __ovld prefetch(const __global half3 *, size_t); +void __ovld prefetch(const __global half4 *, size_t); +void __ovld prefetch(const __global half8 *, size_t); +void __ovld prefetch(const __global half16 *, size_t); +#endif // cl_khr_fp16 + +// OpenCL v1.1 s6.11.1, v1.2 s6.12.11 - Atomic Functions + +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable +#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable +#endif +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old + val) and store result at location + * pointed by p. The function returns old. + */ +int __ovld atomic_add(volatile __global int *, int); +uint __ovld atomic_add(volatile __global uint *, uint); +int __ovld atomic_add(volatile __local int *, int); +uint __ovld atomic_add(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_add(volatile int *, int); +uint __ovld atomic_add(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_base_atomics) +int __ovld atom_add(volatile __global int *, int); +uint __ovld atom_add(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_base_atomics) +int __ovld atom_add(volatile __local int *, int); +uint __ovld atom_add(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_base_atomics) +long __ovld atom_add(volatile __global long *, long); +ulong __ovld atom_add(volatile __global ulong *, ulong); +long __ovld atom_add(volatile __local long *, long); +ulong __ovld atom_add(volatile __local ulong *, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) stored at location pointed by p. + * Compute (old - val) and store result at location pointed by p. The function + * returns old. + */ +int __ovld atomic_sub(volatile __global int *, int); +uint __ovld atomic_sub(volatile __global uint *, uint); +int __ovld atomic_sub(volatile __local int *, int); +uint __ovld atomic_sub(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_sub(volatile int *, int); +uint __ovld atomic_sub(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_base_atomics) +int __ovld atom_sub(volatile __global int *, int); +uint __ovld atom_sub(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_base_atomics) +int __ovld atom_sub(volatile __local int *, int); +uint __ovld atom_sub(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_base_atomics) +long __ovld atom_sub(volatile __global long *, long); +ulong __ovld atom_sub(volatile __global ulong *, ulong); +long __ovld atom_sub(volatile __local long *, long); +ulong __ovld atom_sub(volatile __local ulong *, ulong); +#endif + +/** + * Swaps the old value stored at location p + * with new value given by val. Returns old + * value. + */ +int __ovld atomic_xchg(volatile __global int *, int); +uint __ovld atomic_xchg(volatile __global uint *, uint); +int __ovld atomic_xchg(volatile __local int *, int); +uint __ovld atomic_xchg(volatile __local uint *, uint); +float __ovld atomic_xchg(volatile __global float *, float); +float __ovld atomic_xchg(volatile __local float *, float); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_xchg(volatile int *, int); +uint __ovld atomic_xchg(volatile uint *, uint); +float __ovld atomic_xchg(volatile float *, float); +#endif + +#if defined(cl_khr_global_int32_base_atomics) +int __ovld atom_xchg(volatile __global int *, int); +uint __ovld atom_xchg(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_base_atomics) +int __ovld atom_xchg(volatile __local int *, int); +uint __ovld atom_xchg(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_base_atomics) +long __ovld atom_xchg(volatile __global long *, long); +long __ovld atom_xchg(volatile __local long *, long); +ulong __ovld atom_xchg(volatile __global ulong *, ulong); +ulong __ovld atom_xchg(volatile __local ulong *, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old + 1) and store result at location + * pointed by p. The function returns old. + */ +int __ovld atomic_inc(volatile __global int *); +uint __ovld atomic_inc(volatile __global uint *); +int __ovld atomic_inc(volatile __local int *); +uint __ovld atomic_inc(volatile __local uint *); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_inc(volatile int *); +uint __ovld atomic_inc(volatile uint *); +#endif + +#if defined(cl_khr_global_int32_base_atomics) +int __ovld atom_inc(volatile __global int *); +uint __ovld atom_inc(volatile __global uint *); +#endif +#if defined(cl_khr_local_int32_base_atomics) +int __ovld atom_inc(volatile __local int *); +uint __ovld atom_inc(volatile __local uint *); +#endif + +#if defined(cl_khr_int64_base_atomics) +long __ovld atom_inc(volatile __global long *); +ulong __ovld atom_inc(volatile __global ulong *); +long __ovld atom_inc(volatile __local long *); +ulong __ovld atom_inc(volatile __local ulong *); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old - 1) and store result at location + * pointed by p. The function returns old. + */ +int __ovld atomic_dec(volatile __global int *); +uint __ovld atomic_dec(volatile __global uint *); +int __ovld atomic_dec(volatile __local int *); +uint __ovld atomic_dec(volatile __local uint *); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_dec(volatile int *); +uint __ovld atomic_dec(volatile uint *); +#endif + +#if defined(cl_khr_global_int32_base_atomics) +int __ovld atom_dec(volatile __global int *); +uint __ovld atom_dec(volatile __global uint *); +#endif +#if defined(cl_khr_local_int32_base_atomics) +int __ovld atom_dec(volatile __local int *); +uint __ovld atom_dec(volatile __local uint *); +#endif + +#if defined(cl_khr_int64_base_atomics) +long __ovld atom_dec(volatile __global long *); +ulong __ovld atom_dec(volatile __global ulong *); +long __ovld atom_dec(volatile __local long *); +ulong __ovld atom_dec(volatile __local ulong *); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old == cmp) ? val : old and store result at + * location pointed by p. The function + * returns old. + */ +int __ovld atomic_cmpxchg(volatile __global int *, int, int); +uint __ovld atomic_cmpxchg(volatile __global uint *, uint, uint); +int __ovld atomic_cmpxchg(volatile __local int *, int, int); +uint __ovld atomic_cmpxchg(volatile __local uint *, uint, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_cmpxchg(volatile int *, int, int); +uint __ovld atomic_cmpxchg(volatile uint *, uint, uint); +#endif + +#if defined(cl_khr_global_int32_base_atomics) +int __ovld atom_cmpxchg(volatile __global int *, int, int); +uint __ovld atom_cmpxchg(volatile __global uint *, uint, uint); +#endif +#if defined(cl_khr_local_int32_base_atomics) +int __ovld atom_cmpxchg(volatile __local int *, int, int); +uint __ovld atom_cmpxchg(volatile __local uint *, uint, uint); +#endif + +#if defined(cl_khr_int64_base_atomics) +long __ovld atom_cmpxchg(volatile __global long *, long, long); +ulong __ovld atom_cmpxchg(volatile __global ulong *, ulong, ulong); +long __ovld atom_cmpxchg(volatile __local long *, long, long); +ulong __ovld atom_cmpxchg(volatile __local ulong *, ulong, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * min(old, val) and store minimum value at + * location pointed by p. The function + * returns old. + */ +int __ovld atomic_min(volatile __global int *, int); +uint __ovld atomic_min(volatile __global uint *, uint); +int __ovld atomic_min(volatile __local int *, int); +uint __ovld atomic_min(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_min(volatile int *, int); +uint __ovld atomic_min(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_extended_atomics) +int __ovld atom_min(volatile __global int *, int); +uint __ovld atom_min(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_extended_atomics) +int __ovld atom_min(volatile __local int *, int); +uint __ovld atom_min(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_extended_atomics) +long __ovld atom_min(volatile __global long *, long); +ulong __ovld atom_min(volatile __global ulong *, ulong); +long __ovld atom_min(volatile __local long *, long); +ulong __ovld atom_min(volatile __local ulong *, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * max(old, val) and store maximum value at + * location pointed by p. The function + * returns old. + */ +int __ovld atomic_max(volatile __global int *, int); +uint __ovld atomic_max(volatile __global uint *, uint); +int __ovld atomic_max(volatile __local int *, int); +uint __ovld atomic_max(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_max(volatile int *, int); +uint __ovld atomic_max(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_extended_atomics) +int __ovld atom_max(volatile __global int *, int); +uint __ovld atom_max(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_extended_atomics) +int __ovld atom_max(volatile __local int *, int); +uint __ovld atom_max(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_extended_atomics) +long __ovld atom_max(volatile __global long *, long); +ulong __ovld atom_max(volatile __global ulong *, ulong); +long __ovld atom_max(volatile __local long *, long); +ulong __ovld atom_max(volatile __local ulong *, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old & val) and store result at location + * pointed by p. The function returns old. + */ +int __ovld atomic_and(volatile __global int *, int); +uint __ovld atomic_and(volatile __global uint *, uint); +int __ovld atomic_and(volatile __local int *, int); +uint __ovld atomic_and(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_and(volatile int *, int); +uint __ovld atomic_and(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_extended_atomics) +int __ovld atom_and(volatile __global int *, int); +uint __ovld atom_and(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_extended_atomics) +int __ovld atom_and(volatile __local int *, int); +uint __ovld atom_and(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_extended_atomics) +long __ovld atom_and(volatile __global long *, long); +ulong __ovld atom_and(volatile __global ulong *, ulong); +long __ovld atom_and(volatile __local long *, long); +ulong __ovld atom_and(volatile __local ulong *, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old | val) and store result at location + * pointed by p. The function returns old. + */ +int __ovld atomic_or(volatile __global int *, int); +uint __ovld atomic_or(volatile __global uint *, uint); +int __ovld atomic_or(volatile __local int *, int); +uint __ovld atomic_or(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_or(volatile int *, int); +uint __ovld atomic_or(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_extended_atomics) +int __ovld atom_or(volatile __global int *, int); +uint __ovld atom_or(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_extended_atomics) +int __ovld atom_or(volatile __local int *, int); +uint __ovld atom_or(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_extended_atomics) +long __ovld atom_or(volatile __global long *, long); +ulong __ovld atom_or(volatile __global ulong *, ulong); +long __ovld atom_or(volatile __local long *, long); +ulong __ovld atom_or(volatile __local ulong *, ulong); +#endif + +/** + * Read the 32-bit value (referred to as old) + * stored at location pointed by p. Compute + * (old ^ val) and store result at location + * pointed by p. The function returns old. + */ +int __ovld atomic_xor(volatile __global int *, int); +uint __ovld atomic_xor(volatile __global uint *, uint); +int __ovld atomic_xor(volatile __local int *, int); +uint __ovld atomic_xor(volatile __local uint *, uint); +#ifdef __OPENCL_CPP_VERSION__ +int __ovld atomic_xor(volatile int *, int); +uint __ovld atomic_xor(volatile uint *, uint); +#endif + +#if defined(cl_khr_global_int32_extended_atomics) +int __ovld atom_xor(volatile __global int *, int); +uint __ovld atom_xor(volatile __global uint *, uint); +#endif +#if defined(cl_khr_local_int32_extended_atomics) +int __ovld atom_xor(volatile __local int *, int); +uint __ovld atom_xor(volatile __local uint *, uint); +#endif + +#if defined(cl_khr_int64_extended_atomics) +long __ovld atom_xor(volatile __global long *, long); +ulong __ovld atom_xor(volatile __global ulong *, ulong); +long __ovld atom_xor(volatile __local long *, long); +ulong __ovld atom_xor(volatile __local ulong *, ulong); +#endif + +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable +#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable +#endif + +// OpenCL v2.0 s6.13.11 - Atomics Functions + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// double atomics support requires extensions cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable +#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable +#endif + +// atomic_init() +#if defined(__opencl_c_generic_address_space) +void __ovld atomic_init(volatile atomic_int *, int); +void __ovld atomic_init(volatile atomic_uint *, uint); +void __ovld atomic_init(volatile atomic_float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +void __ovld atomic_init(volatile atomic_long *, long); +void __ovld atomic_init(volatile atomic_ulong *, ulong); +#ifdef cl_khr_fp64 +void __ovld atomic_init(volatile atomic_double *, double); +#endif //cl_khr_fp64 +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +void __ovld atomic_init(volatile __global atomic_int *, int); +void __ovld atomic_init(volatile __local atomic_int *, int); +void __ovld atomic_init(volatile __global atomic_uint *, uint); +void __ovld atomic_init(volatile __local atomic_uint *, uint); +void __ovld atomic_init(volatile __global atomic_float *, float); +void __ovld atomic_init(volatile __local atomic_float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +void __ovld atomic_init(volatile __global atomic_long *, long); +void __ovld atomic_init(volatile __local atomic_long *, long); +void __ovld atomic_init(volatile __global atomic_ulong *, ulong); +void __ovld atomic_init(volatile __local atomic_ulong *, ulong); +#ifdef cl_khr_fp64 +void __ovld atomic_init(volatile __global atomic_double *, double); +void __ovld atomic_init(volatile __local atomic_double *, double); +#endif //cl_khr_fp64 +#endif +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + +// atomic_work_item_fence() +void __ovld atomic_work_item_fence(cl_mem_fence_flags, memory_order, memory_scope); + +// atomic_fetch() +// OpenCL v2.0 s6.13.11.7.5: +// add/sub: atomic type argument can be uintptr_t/intptr_t, value type argument can be ptrdiff_t. + +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_fetch_add(volatile atomic_int *, int); +uint __ovld atomic_fetch_add(volatile atomic_uint *, uint); +int __ovld atomic_fetch_sub(volatile atomic_int *, int); +uint __ovld atomic_fetch_sub(volatile atomic_uint *, uint); +int __ovld atomic_fetch_or(volatile atomic_int *, int); +uint __ovld atomic_fetch_or(volatile atomic_uint *, uint); +int __ovld atomic_fetch_xor(volatile atomic_int *, int); +uint __ovld atomic_fetch_xor(volatile atomic_uint *, uint); +int __ovld atomic_fetch_and(volatile atomic_int *, int); +uint __ovld atomic_fetch_and(volatile atomic_uint *, uint); +int __ovld atomic_fetch_min(volatile atomic_int *, int); +uint __ovld atomic_fetch_min(volatile atomic_uint *, uint); +int __ovld atomic_fetch_max(volatile atomic_int *, int); +uint __ovld atomic_fetch_max(volatile atomic_uint *, uint); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +long __ovld atomic_fetch_add(volatile atomic_long *, long); +ulong __ovld atomic_fetch_add(volatile atomic_ulong *, ulong); +long __ovld atomic_fetch_sub(volatile atomic_long *, long); +ulong __ovld atomic_fetch_sub(volatile atomic_ulong *, ulong); +long __ovld atomic_fetch_or(volatile atomic_long *, long); +ulong __ovld atomic_fetch_or(volatile atomic_ulong *, ulong); +long __ovld atomic_fetch_xor(volatile atomic_long *, long); +ulong __ovld atomic_fetch_xor(volatile atomic_ulong *, ulong); +long __ovld atomic_fetch_and(volatile atomic_long *, long); +ulong __ovld atomic_fetch_and(volatile atomic_ulong *, ulong); +long __ovld atomic_fetch_min(volatile atomic_long *, long); +ulong __ovld atomic_fetch_min(volatile atomic_ulong *, ulong); +long __ovld atomic_fetch_max(volatile atomic_long *, long); +ulong __ovld atomic_fetch_max(volatile atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *, ptrdiff_t); +uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *, ptrdiff_t); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_fetch_add(volatile __global atomic_int *, int); +int __ovld atomic_fetch_add(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_add(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_add(volatile __local atomic_uint *, uint); +int __ovld atomic_fetch_sub(volatile __global atomic_int *, int); +int __ovld atomic_fetch_sub(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_sub(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_sub(volatile __local atomic_uint *, uint); +int __ovld atomic_fetch_or(volatile __global atomic_int *, int); +int __ovld atomic_fetch_or(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_or(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_or(volatile __local atomic_uint *, uint); +int __ovld atomic_fetch_xor(volatile __global atomic_int *, int); +int __ovld atomic_fetch_xor(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_xor(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_xor(volatile __local atomic_uint *, uint); +int __ovld atomic_fetch_and(volatile __global atomic_int *, int); +int __ovld atomic_fetch_and(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_and(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_and(volatile __local atomic_uint *, uint); +int __ovld atomic_fetch_min(volatile __global atomic_int *, int); +int __ovld atomic_fetch_min(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_min(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_min(volatile __local atomic_uint *, uint); +int __ovld atomic_fetch_max(volatile __global atomic_int *, int); +int __ovld atomic_fetch_max(volatile __local atomic_int *, int); +uint __ovld atomic_fetch_max(volatile __global atomic_uint *, uint); +uint __ovld atomic_fetch_max(volatile __local atomic_uint *, uint); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +long __ovld atomic_fetch_add(volatile __global atomic_long *, long); +long __ovld atomic_fetch_add(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_add(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_add(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_add(volatile __global atomic_uintptr_t *, ptrdiff_t); +uintptr_t __ovld atomic_fetch_add(volatile __local atomic_uintptr_t *, ptrdiff_t); +long __ovld atomic_fetch_sub(volatile __global atomic_long *, long); +long __ovld atomic_fetch_sub(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_sub(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_sub(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_sub(volatile __global atomic_uintptr_t *, ptrdiff_t); +uintptr_t __ovld atomic_fetch_sub(volatile __local atomic_uintptr_t *, ptrdiff_t); +long __ovld atomic_fetch_or(volatile __global atomic_long *, long); +long __ovld atomic_fetch_or(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_or(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_or(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_or(volatile __global atomic_uintptr_t *, intptr_t); +uintptr_t __ovld atomic_fetch_or(volatile __local atomic_uintptr_t *, intptr_t); +intptr_t __ovld atomic_fetch_or(volatile __global atomic_intptr_t *, uintptr_t); +intptr_t __ovld atomic_fetch_or(volatile __local atomic_intptr_t *, uintptr_t); +long __ovld atomic_fetch_xor(volatile __global atomic_long *, long); +long __ovld atomic_fetch_xor(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_xor(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_xor(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_xor(volatile __global atomic_uintptr_t *, intptr_t); +uintptr_t __ovld atomic_fetch_xor(volatile __local atomic_uintptr_t *, intptr_t); +intptr_t __ovld atomic_fetch_xor(volatile __global atomic_intptr_t *, uintptr_t); +intptr_t __ovld atomic_fetch_xor(volatile __local atomic_intptr_t *, uintptr_t); +long __ovld atomic_fetch_and(volatile __global atomic_long *, long); +long __ovld atomic_fetch_and(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_and(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_and(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_and(volatile __global atomic_uintptr_t *, intptr_t); +uintptr_t __ovld atomic_fetch_and(volatile __local atomic_uintptr_t *, intptr_t); +intptr_t __ovld atomic_fetch_and(volatile __global atomic_intptr_t *, uintptr_t); +intptr_t __ovld atomic_fetch_and(volatile __local atomic_intptr_t *, uintptr_t); +long __ovld atomic_fetch_min(volatile __global atomic_long *, long); +long __ovld atomic_fetch_min(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_min(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_min(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_min(volatile __global atomic_uintptr_t *, intptr_t); +uintptr_t __ovld atomic_fetch_min(volatile __local atomic_uintptr_t *, intptr_t); +intptr_t __ovld atomic_fetch_min(volatile __global atomic_intptr_t *, uintptr_t); +intptr_t __ovld atomic_fetch_min(volatile __local atomic_intptr_t *, uintptr_t); +long __ovld atomic_fetch_max(volatile __global atomic_long *, long); +long __ovld atomic_fetch_max(volatile __local atomic_long *, long); +ulong __ovld atomic_fetch_max(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_fetch_max(volatile __local atomic_ulong *, ulong); +uintptr_t __ovld atomic_fetch_max(volatile __global atomic_uintptr_t *, uintptr_t); +uintptr_t __ovld atomic_fetch_max(volatile __local atomic_uintptr_t *, uintptr_t); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_fetch_add_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_sub_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_or_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_xor_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_and_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_min_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_max_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *, uint, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +long __ovld atomic_fetch_add_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *, ulong, memory_order); +long __ovld atomic_fetch_sub_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *, ulong, memory_order); +long __ovld atomic_fetch_or_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *, ulong, memory_order); +long __ovld atomic_fetch_xor_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *, ulong, memory_order); +long __ovld atomic_fetch_and_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *, ulong, memory_order); +long __ovld atomic_fetch_min_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *, ulong, memory_order); +long __ovld atomic_fetch_max_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *, ptrdiff_t, memory_order); +uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *, ptrdiff_t, memory_order); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_add_explicit(volatile __local atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_sub_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_sub_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_sub_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_sub_explicit(volatile __local atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_or_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_or_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_or_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_or_explicit(volatile __local atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_xor_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_xor_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_xor_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_xor_explicit(volatile __local atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_and_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_and_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_and_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_and_explicit(volatile __local atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_min_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_min_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_min_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_min_explicit(volatile __local atomic_uint *, uint, memory_order); +int __ovld atomic_fetch_max_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_fetch_max_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_fetch_max_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_fetch_max_explicit(volatile __local atomic_uint *, uint, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +long __ovld atomic_fetch_add_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_add_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_add_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_add_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *, ptrdiff_t, memory_order); +uintptr_t __ovld atomic_fetch_add_explicit(volatile __local atomic_uintptr_t *, ptrdiff_t, memory_order); +long __ovld atomic_fetch_sub_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_sub_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_sub_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_sub_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_sub_explicit(volatile __global atomic_uintptr_t *, ptrdiff_t, memory_order); +uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *, ptrdiff_t, memory_order); +long __ovld atomic_fetch_or_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_or_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_or_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_or_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_or_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order); +uintptr_t __ovld atomic_fetch_or_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order); +intptr_t __ovld atomic_fetch_or_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order); +intptr_t __ovld atomic_fetch_or_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order); +long __ovld atomic_fetch_xor_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_xor_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_xor_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_xor_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_xor_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order); +uintptr_t __ovld atomic_fetch_xor_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order); +intptr_t __ovld atomic_fetch_xor_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order); +intptr_t __ovld atomic_fetch_xor_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order); +long __ovld atomic_fetch_and_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_and_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_and_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_and_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_and_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order); +uintptr_t __ovld atomic_fetch_and_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order); +intptr_t __ovld atomic_fetch_and_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order); +intptr_t __ovld atomic_fetch_and_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order); +long __ovld atomic_fetch_min_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_min_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_min_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_min_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_min_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order); +uintptr_t __ovld atomic_fetch_min_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order); +intptr_t __ovld atomic_fetch_min_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order); +intptr_t __ovld atomic_fetch_min_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order); +long __ovld atomic_fetch_max_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_fetch_max_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_fetch_max_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_fetch_max_explicit(volatile __local atomic_ulong *, ulong, memory_order); +uintptr_t __ovld atomic_fetch_max_explicit(volatile __global atomic_uintptr_t *, uintptr_t, memory_order); +uintptr_t __ovld atomic_fetch_max_explicit(volatile __local atomic_uintptr_t *, uintptr_t, memory_order); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_fetch_add_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_sub_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_or_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_xor_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_and_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_min_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_max_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +long __ovld atomic_fetch_add_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_add_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_sub_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_sub_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_or_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_or_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_xor_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_xor_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_and_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_and_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_min_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_min_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_max_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_max_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_add_explicit(volatile atomic_uintptr_t *, ptrdiff_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *, ptrdiff_t, memory_order, memory_scope); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_fetch_add_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_add_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_add_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_add_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_sub_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_sub_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_sub_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_sub_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_or_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_or_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_or_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_or_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_xor_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_xor_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_xor_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_xor_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_and_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_and_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_and_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_and_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_min_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_min_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_min_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_min_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +int __ovld atomic_fetch_max_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_fetch_max_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_fetch_max_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_fetch_max_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +long __ovld atomic_fetch_add_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_add_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_add_explicit(volatile __global atomic_uintptr_t *, ptrdiff_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_add_explicit(volatile __local atomic_uintptr_t *, ptrdiff_t, memory_order, memory_scope); +ulong __ovld atomic_fetch_add_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_add_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +long __ovld atomic_fetch_sub_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_sub_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_sub_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_sub_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_sub_explicit(volatile __global atomic_uintptr_t *, ptrdiff_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t *, ptrdiff_t, memory_order, memory_scope); +long __ovld atomic_fetch_or_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_or_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_or_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_or_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_or_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_or_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_or_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_or_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +long __ovld atomic_fetch_xor_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_xor_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_xor_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_xor_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_xor_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_xor_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_xor_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_xor_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +long __ovld atomic_fetch_and_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_and_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_and_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_and_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_and_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_and_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_and_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_and_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +long __ovld atomic_fetch_min_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_min_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_min_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_min_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_min_explicit(volatile __global atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_min_explicit(volatile __local atomic_uintptr_t *, intptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_min_explicit(volatile __global atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +intptr_t __ovld atomic_fetch_min_explicit(volatile __local atomic_intptr_t *, uintptr_t, memory_order, memory_scope); +long __ovld atomic_fetch_max_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_fetch_max_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_fetch_max_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_fetch_max_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_max_explicit(volatile __global atomic_uintptr_t *, uintptr_t, memory_order, memory_scope); +uintptr_t __ovld atomic_fetch_max_explicit(volatile __local atomic_uintptr_t *, uintptr_t, memory_order, memory_scope); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + +// The functionality added by cl_ext_float_atomics extension +#if defined(cl_ext_float_atomics) + +#if defined(__opencl_c_ext_fp16_global_atomic_load_store) +void __ovld atomic_store(volatile __global atomic_half *, half); +void __ovld atomic_store_explicit(volatile __global atomic_half *, + half, memory_order); +void __ovld atomic_store_explicit(volatile __global atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_load(volatile __global atomic_half *); +half __ovld atomic_load_explicit(volatile __global atomic_half *, + memory_order); +half __ovld atomic_load_explicit(volatile __global atomic_half *, + memory_order, memory_scope); +half __ovld atomic_exchange(volatile __global atomic_half *, half); +half __ovld atomic_exchange_explicit(volatile __global atomic_half *, + half, memory_order); +half __ovld atomic_exchange_explicit(volatile __global atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_global_atomic_load_store) + +#if defined(__opencl_c_ext_fp16_local_atomic_load_store) +void __ovld atomic_store(volatile __local atomic_half *, half); +void __ovld atomic_store_explicit(volatile __local atomic_half *, + half, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_load(volatile __local atomic_half *); +half __ovld atomic_load_explicit(volatile __local atomic_half *, + memory_order); +half __ovld atomic_load_explicit(volatile __local atomic_half *, + memory_order, memory_scope); +half __ovld atomic_exchange(volatile __local atomic_half *, half); +half __ovld atomic_exchange_explicit(volatile __local atomic_half *, + half, memory_order); +half __ovld atomic_exchange_explicit(volatile __local atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_local_atomic_load_store) + +#if defined(__opencl_c_ext_fp16_global_atomic_load_store) && \ + defined(__opencl_c_ext_fp16_local_atomic_load_store) +void __ovld atomic_store(volatile atomic_half *, half); +void __ovld atomic_store_explicit(volatile atomic_half *, half, + memory_order); +void __ovld atomic_store_explicit(volatile atomic_half *, half, + memory_order, memory_scope); +half __ovld atomic_load(volatile atomic_half *); +half __ovld atomic_load_explicit(volatile atomic_half *, + memory_order); +half __ovld atomic_load_explicit(volatile atomic_half *, + memory_order, memory_scope); +half __ovld atomic_exchange(volatile atomic_half *, half); +half __ovld atomic_exchange_explicit(volatile atomic_half *, half, + memory_order); +half __ovld atomic_exchange_explicit(volatile atomic_half *, half, + memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_global_atomic_load_store) && + // defined(__opencl_c_ext_fp16_local_atomic_load_store) + +#if defined(__opencl_c_ext_fp16_global_atomic_min_max) +half __ovld atomic_fetch_min(volatile __global atomic_half *, half); +half __ovld atomic_fetch_max(volatile __global atomic_half *, half); +half __ovld atomic_fetch_min_explicit(volatile __global atomic_half *, + half, memory_order); +half __ovld atomic_fetch_max_explicit(volatile __global atomic_half *, + half, memory_order); +half __ovld atomic_fetch_min_explicit(volatile __global atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_fetch_max_explicit(volatile __global atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_global_atomic_min_max) + +#if defined(__opencl_c_ext_fp16_local_atomic_min_max) +half __ovld atomic_fetch_min(volatile __local atomic_half *, half); +half __ovld atomic_fetch_max(volatile __local atomic_half *, half); +half __ovld atomic_fetch_min_explicit(volatile __local atomic_half *, + half, memory_order); +half __ovld atomic_fetch_max_explicit(volatile __local atomic_half *, + half, memory_order); +half __ovld atomic_fetch_min_explicit(volatile __local atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_fetch_max_explicit(volatile __local atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_local_atomic_min_max) + +#if defined(__opencl_c_ext_fp16_global_atomic_min_max) && \ + defined(__opencl_c_ext_fp16_local_atomic_min_max) +half __ovld atomic_fetch_min(volatile atomic_half *, half); +half __ovld atomic_fetch_max(volatile atomic_half *, half); +half __ovld atomic_fetch_min_explicit(volatile atomic_half *, + half, memory_order); +half __ovld atomic_fetch_max_explicit(volatile atomic_half *, + half, memory_order); +half __ovld atomic_fetch_min_explicit(volatile atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_fetch_max_explicit(volatile atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_global_atomic_min_max) && \ + defined(__opencl_c_ext_fp16_local_atomic_min_max) + +#if defined(__opencl_c_ext_fp32_global_atomic_min_max) +float __ovld atomic_fetch_min(volatile __global atomic_float *, float); +float __ovld atomic_fetch_max(volatile __global atomic_float *, float); +float __ovld atomic_fetch_min_explicit(volatile __global atomic_float *, + float, memory_order); +float __ovld atomic_fetch_max_explicit(volatile __global atomic_float *, + float, memory_order); +float __ovld atomic_fetch_min_explicit(volatile __global atomic_float *, + float, memory_order, memory_scope); +float __ovld atomic_fetch_max_explicit(volatile __global atomic_float *, + float, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) + +#if defined(__opencl_c_ext_fp32_local_atomic_min_max) +float __ovld atomic_fetch_min(volatile __local atomic_float *, float); +float __ovld atomic_fetch_max(volatile __local atomic_float *, float); +float __ovld atomic_fetch_min_explicit(volatile __local atomic_float *, + float, memory_order); +float __ovld atomic_fetch_max_explicit(volatile __local atomic_float *, + float, memory_order); +float __ovld atomic_fetch_min_explicit(volatile __local atomic_float *, + float, memory_order, memory_scope); +float __ovld atomic_fetch_max_explicit(volatile __local atomic_float *, + float, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp32_local_atomic_min_max) + +#if defined(__opencl_c_ext_fp32_global_atomic_min_max) && \ + defined(__opencl_c_ext_fp32_local_atomic_min_max) +float __ovld atomic_fetch_min(volatile atomic_float *, float); +float __ovld atomic_fetch_max(volatile atomic_float *, float); +float __ovld atomic_fetch_min_explicit(volatile atomic_float *, + float, memory_order); +float __ovld atomic_fetch_max_explicit(volatile atomic_float *, + float, memory_order); +float __ovld atomic_fetch_min_explicit(volatile atomic_float *, + float, memory_order, memory_scope); +float __ovld atomic_fetch_max_explicit(volatile atomic_float *, + float, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) && \ + defined(__opencl_c_ext_fp32_local_atomic_min_max) + +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#if defined(__opencl_c_ext_fp64_global_atomic_min_max) +double __ovld atomic_fetch_min(volatile __global atomic_double *, double); +double __ovld atomic_fetch_max(volatile __global atomic_double *, double); +double __ovld atomic_fetch_min_explicit(volatile __global atomic_double *, + double, memory_order); +double __ovld atomic_fetch_max_explicit(volatile __global atomic_double *, + double, memory_order); +double __ovld atomic_fetch_min_explicit(volatile __global atomic_double *, + double, memory_order, memory_scope); +double __ovld atomic_fetch_max_explicit(volatile __global atomic_double *, + double, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) + +#if defined(__opencl_c_ext_fp64_local_atomic_min_max) +double __ovld atomic_fetch_min(volatile __local atomic_double *, double); +double __ovld atomic_fetch_max(volatile __local atomic_double *, double); +double __ovld atomic_fetch_min_explicit(volatile __local atomic_double *, + double, memory_order); +double __ovld atomic_fetch_max_explicit(volatile __local atomic_double *, + double, memory_order); +double __ovld atomic_fetch_min_explicit(volatile __local atomic_double *, + double, memory_order, memory_scope); +double __ovld atomic_fetch_max_explicit(volatile __local atomic_double *, + double, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp64_local_atomic_min_max) + +#if defined(__opencl_c_ext_fp64_global_atomic_min_max) && \ + defined(__opencl_c_ext_fp64_local_atomic_min_max) +double __ovld atomic_fetch_min(volatile atomic_double *, double); +double __ovld atomic_fetch_max(volatile atomic_double *, double); +double __ovld atomic_fetch_min_explicit(volatile atomic_double *, + double, memory_order); +double __ovld atomic_fetch_max_explicit(volatile atomic_double *, + double, memory_order); +double __ovld atomic_fetch_min_explicit(volatile atomic_double *, + double, memory_order, memory_scope); +double __ovld atomic_fetch_max_explicit(volatile atomic_double *, + double, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) && \ + defined(__opencl_c_ext_fp64_local_atomic_min_max) +#endif // defined(cl_khr_int64_base_atomics) && \ + defined(cl_khr_int64_extended_atomics) + +#if defined(__opencl_c_ext_fp16_global_atomic_add) +half __ovld atomic_fetch_add(volatile __global atomic_half *, half); +half __ovld atomic_fetch_sub(volatile __global atomic_half *, half); +half __ovld atomic_fetch_add_explicit(volatile __global atomic_half *, + half, memory_order); +half __ovld atomic_fetch_sub_explicit(volatile __global atomic_half *, + half, memory_order); +half __ovld atomic_fetch_add_explicit(volatile __global atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_fetch_sub_explicit(volatile __global atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_global_atomic_add) + +#if defined(__opencl_c_ext_fp16_local_atomic_add) +half __ovld atomic_fetch_add(volatile __local atomic_half *, half); +half __ovld atomic_fetch_sub(volatile __local atomic_half *, half); +half __ovld atomic_fetch_add_explicit(volatile __local atomic_half *, + half, memory_order); +half __ovld atomic_fetch_sub_explicit(volatile __local atomic_half *, + half, memory_order); +half __ovld atomic_fetch_add_explicit(volatile __local atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_fetch_sub_explicit(volatile __local atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_local_atomic_add) + +#if defined(__opencl_c_ext_fp16_global_atomic_add) && \ + defined(__opencl_c_ext_fp16_local_atomic_add) +half __ovld atomic_fetch_add(volatile atomic_half *, half); +half __ovld atomic_fetch_sub(volatile atomic_half *, half); +half __ovld atomic_fetch_add_explicit(volatile atomic_half *, + half, memory_order); +half __ovld atomic_fetch_sub_explicit(volatile atomic_half *, + half, memory_order); +half __ovld atomic_fetch_add_explicit(volatile atomic_half *, + half, memory_order, memory_scope); +half __ovld atomic_fetch_sub_explicit(volatile atomic_half *, + half, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp16_global_atomic_add) && \ + defined(__opencl_c_ext_fp16_local_atomic_add) + +#if defined(__opencl_c_ext_fp32_global_atomic_add) +float __ovld atomic_fetch_add(volatile __global atomic_float *, float); +float __ovld atomic_fetch_sub(volatile __global atomic_float *, float); +float __ovld atomic_fetch_add_explicit(volatile __global atomic_float *, + float, memory_order); +float __ovld atomic_fetch_sub_explicit(volatile __global atomic_float *, + float, memory_order); +float __ovld atomic_fetch_add_explicit(volatile __global atomic_float *, + float, memory_order, memory_scope); +float __ovld atomic_fetch_sub_explicit(volatile __global atomic_float *, + float, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp32_global_atomic_add) + +#if defined(__opencl_c_ext_fp32_local_atomic_add) +float __ovld atomic_fetch_add(volatile __local atomic_float *, float); +float __ovld atomic_fetch_sub(volatile __local atomic_float *, float); +float __ovld atomic_fetch_add_explicit(volatile __local atomic_float *, + float, memory_order); +float __ovld atomic_fetch_sub_explicit(volatile __local atomic_float *, + float, memory_order); +float __ovld atomic_fetch_add_explicit(volatile __local atomic_float *, + float, memory_order, memory_scope); +float __ovld atomic_fetch_sub_explicit(volatile __local atomic_float *, + float, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp32_local_atomic_add) + +#if defined(__opencl_c_ext_fp32_global_atomic_add) && \ + defined(__opencl_c_ext_fp32_local_atomic_add) +float __ovld atomic_fetch_add(volatile atomic_float *, float); +float __ovld atomic_fetch_sub(volatile atomic_float *, float); +float __ovld atomic_fetch_add_explicit(volatile atomic_float *, + float, memory_order); +float __ovld atomic_fetch_sub_explicit(volatile atomic_float *, + float, memory_order); +float __ovld atomic_fetch_add_explicit(volatile atomic_float *, + float, memory_order, memory_scope); +float __ovld atomic_fetch_sub_explicit(volatile atomic_float *, + float, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp32_global_atomic_add) && \ + defined(__opencl_c_ext_fp32_local_atomic_add) + +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#if defined(__opencl_c_ext_fp64_global_atomic_add) +double __ovld atomic_fetch_add(volatile __global atomic_double *, double); +double __ovld atomic_fetch_sub(volatile __global atomic_double *, double); +double __ovld atomic_fetch_add_explicit(volatile __global atomic_double *, + double, memory_order); +double __ovld atomic_fetch_sub_explicit(volatile __global atomic_double *, + double, memory_order); +double __ovld atomic_fetch_add_explicit(volatile __global atomic_double *, + double, memory_order, memory_scope); +double __ovld atomic_fetch_sub_explicit(volatile __global atomic_double *, + double, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp64_global_atomic_add) + +#if defined(__opencl_c_ext_fp64_local_atomic_add) +double __ovld atomic_fetch_add(volatile __local atomic_double *, double); +double __ovld atomic_fetch_sub(volatile __local atomic_double *, double); +double __ovld atomic_fetch_add_explicit(volatile __local atomic_double *, + double, memory_order); +double __ovld atomic_fetch_sub_explicit(volatile __local atomic_double *, + double, memory_order); +double __ovld atomic_fetch_add_explicit(volatile __local atomic_double *, + double, memory_order, memory_scope); +double __ovld atomic_fetch_sub_explicit(volatile __local atomic_double *, + double, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp64_local_atomic_add) + +#if defined(__opencl_c_ext_fp64_global_atomic_add) && \ + defined(__opencl_c_ext_fp64_local_atomic_add) +double __ovld atomic_fetch_add(volatile atomic_double *, double); +double __ovld atomic_fetch_sub(volatile atomic_double *, double); +double __ovld atomic_fetch_add_explicit(volatile atomic_double *, + double, memory_order); +double __ovld atomic_fetch_sub_explicit(volatile atomic_double *, + double, memory_order); +double __ovld atomic_fetch_add_explicit(volatile atomic_double *, + double, memory_order, memory_scope); +double __ovld atomic_fetch_sub_explicit(volatile atomic_double *, + double, memory_order, memory_scope); +#endif // defined(__opencl_c_ext_fp64_global_atomic_add) && \ + defined(__opencl_c_ext_fp64_local_atomic_add) +#endif // defined(cl_khr_int64_base_atomics) && \ + defined(cl_khr_int64_extended_atomics) + +#endif // cl_ext_float_atomics + +// atomic_store() + +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +void __ovld atomic_store(volatile atomic_int *, int); +void __ovld atomic_store(volatile atomic_uint *, uint); +void __ovld atomic_store(volatile atomic_float *, float); + +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +void __ovld atomic_store(volatile atomic_double *, double); +#endif //cl_khr_fp64 +void __ovld atomic_store(volatile atomic_long *, long); +void __ovld atomic_store(volatile atomic_ulong *, ulong); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +void __ovld atomic_store(volatile __global atomic_int *, int); +void __ovld atomic_store(volatile __local atomic_int *, int); +void __ovld atomic_store(volatile __global atomic_uint *, uint); +void __ovld atomic_store(volatile __local atomic_uint *, uint); +void __ovld atomic_store(volatile __global atomic_float *, float); +void __ovld atomic_store(volatile __local atomic_float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +void __ovld atomic_store(volatile __global atomic_double *, double); +void __ovld atomic_store(volatile __local atomic_double *, double); +#endif //cl_khr_fp64 +void __ovld atomic_store(volatile __global atomic_long *, long); +void __ovld atomic_store(volatile __local atomic_long *, long); +void __ovld atomic_store(volatile __global atomic_ulong *, ulong); +void __ovld atomic_store(volatile __local atomic_ulong *, ulong); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +void __ovld atomic_store_explicit(volatile atomic_int *, int, memory_order); +void __ovld atomic_store_explicit(volatile atomic_uint *, uint, memory_order); +void __ovld atomic_store_explicit(volatile atomic_float *, float, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +void __ovld atomic_store_explicit(volatile atomic_double *, double, memory_order); +#endif //cl_khr_fp64 +void __ovld atomic_store_explicit(volatile atomic_long *, long, memory_order); +void __ovld atomic_store_explicit(volatile atomic_ulong *, ulong, memory_order); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +void __ovld atomic_store_explicit(volatile __global atomic_int *, int, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_int *, int, memory_order); +void __ovld atomic_store_explicit(volatile __global atomic_uint *, uint, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_uint *, uint, memory_order); +void __ovld atomic_store_explicit(volatile __global atomic_float *, float, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_float *, float, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +void __ovld atomic_store_explicit(volatile __global atomic_double *, double, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_double *, double, memory_order); +#endif +void __ovld atomic_store_explicit(volatile __global atomic_long *, long, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_long *, long, memory_order); +void __ovld atomic_store_explicit(volatile __global atomic_ulong *, ulong, memory_order); +void __ovld atomic_store_explicit(volatile __local atomic_ulong *, ulong, memory_order); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_generic_address_space) +void __ovld atomic_store_explicit(volatile atomic_int *, int, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile atomic_float *, float, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +void __ovld atomic_store_explicit(volatile atomic_double *, double, memory_order, memory_scope); +#endif //cl_khr_fp64 +void __ovld atomic_store_explicit(volatile atomic_long *, long, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +void __ovld atomic_store_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __global atomic_float *, float, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __local atomic_float *, float, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +void __ovld atomic_store_explicit(volatile __global atomic_double *, double, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __local atomic_double *, double, memory_order, memory_scope); +#endif //cl_khr_fp64 +void __ovld atomic_store_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +void __ovld atomic_store_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + +// atomic_load() +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_load(volatile atomic_int *); +uint __ovld atomic_load(volatile atomic_uint *); +float __ovld atomic_load(volatile atomic_float *); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_load(volatile atomic_double *); +#endif //cl_khr_fp64 +long __ovld atomic_load(volatile atomic_long *); +ulong __ovld atomic_load(volatile atomic_ulong *); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_load(volatile __global atomic_int *); +int __ovld atomic_load(volatile __local atomic_int *); +uint __ovld atomic_load(volatile __global atomic_uint *); +uint __ovld atomic_load(volatile __local atomic_uint *); +float __ovld atomic_load(volatile __global atomic_float *); +float __ovld atomic_load(volatile __local atomic_float *); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_load(volatile __global atomic_double *); +double __ovld atomic_load(volatile __local atomic_double *); +#endif //cl_khr_fp64 +long __ovld atomic_load(volatile __global atomic_long *); +long __ovld atomic_load(volatile __local atomic_long *); +ulong __ovld atomic_load(volatile __global atomic_ulong *); +ulong __ovld atomic_load(volatile __local atomic_ulong *); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_load_explicit(volatile atomic_int *, memory_order); +uint __ovld atomic_load_explicit(volatile atomic_uint *, memory_order); +float __ovld atomic_load_explicit(volatile atomic_float *, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_load_explicit(volatile atomic_double *, memory_order); +#endif //cl_khr_fp64 +long __ovld atomic_load_explicit(volatile atomic_long *, memory_order); +ulong __ovld atomic_load_explicit(volatile atomic_ulong *, memory_order); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_load_explicit(volatile __global atomic_int *, memory_order); +int __ovld atomic_load_explicit(volatile __local atomic_int *, memory_order); +uint __ovld atomic_load_explicit(volatile __global atomic_uint *, memory_order); +uint __ovld atomic_load_explicit(volatile __local atomic_uint *, memory_order); +float __ovld atomic_load_explicit(volatile __global atomic_float *, memory_order); +float __ovld atomic_load_explicit(volatile __local atomic_float *, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_load_explicit(volatile __global atomic_double *, memory_order); +double __ovld atomic_load_explicit(volatile __local atomic_double *, memory_order); +#endif //cl_khr_fp64 +long __ovld atomic_load_explicit(volatile __global atomic_long *, memory_order); +long __ovld atomic_load_explicit(volatile __local atomic_long *, memory_order); +ulong __ovld atomic_load_explicit(volatile __global atomic_ulong *, memory_order); +ulong __ovld atomic_load_explicit(volatile __local atomic_ulong *, memory_order); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_load_explicit(volatile atomic_int *, memory_order, memory_scope); +uint __ovld atomic_load_explicit(volatile atomic_uint *, memory_order, memory_scope); +float __ovld atomic_load_explicit(volatile atomic_float *, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_load_explicit(volatile atomic_double *, memory_order, memory_scope); +#endif //cl_khr_fp64 +long __ovld atomic_load_explicit(volatile atomic_long *, memory_order, memory_scope); +ulong __ovld atomic_load_explicit(volatile atomic_ulong *, memory_order, memory_scope); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_load_explicit(volatile __global atomic_int *, memory_order, memory_scope); +int __ovld atomic_load_explicit(volatile __local atomic_int *, memory_order, memory_scope); +uint __ovld atomic_load_explicit(volatile __global atomic_uint *, memory_order, memory_scope); +uint __ovld atomic_load_explicit(volatile __local atomic_uint *, memory_order, memory_scope); +float __ovld atomic_load_explicit(volatile __global atomic_float *, memory_order, memory_scope); +float __ovld atomic_load_explicit(volatile __local atomic_float *, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_load_explicit(volatile __global atomic_double *, memory_order, memory_scope); +double __ovld atomic_load_explicit(volatile __local atomic_double *, memory_order, memory_scope); +#endif +long __ovld atomic_load_explicit(volatile __global atomic_long *, memory_order, memory_scope); +long __ovld atomic_load_explicit(volatile __local atomic_long *, memory_order, memory_scope); +ulong __ovld atomic_load_explicit(volatile __global atomic_ulong *, memory_order, memory_scope); +ulong __ovld atomic_load_explicit(volatile __local atomic_ulong *, memory_order, memory_scope); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + +// atomic_exchange() + +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_exchange(volatile atomic_int *, int); +uint __ovld atomic_exchange(volatile atomic_uint *, uint); +float __ovld atomic_exchange(volatile atomic_float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_exchange(volatile atomic_double *, double); +#endif //cl_khr_fp64 +long __ovld atomic_exchange(volatile atomic_long *, long); +ulong __ovld atomic_exchange(volatile atomic_ulong *, ulong); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_exchange(volatile __global atomic_int *, int); +int __ovld atomic_exchange(volatile __local atomic_int *, int); +uint __ovld atomic_exchange(volatile __global atomic_uint *, uint); +uint __ovld atomic_exchange(volatile __local atomic_uint *, uint); +float __ovld atomic_exchange(volatile __global atomic_float *, float); +float __ovld atomic_exchange(volatile __local atomic_float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_exchange(volatile __global atomic_double *, double); +double __ovld atomic_exchange(volatile __local atomic_double *, double); +#endif //cl_khr_fp64 +long __ovld atomic_exchange(volatile __global atomic_long *, long); +long __ovld atomic_exchange(volatile __local atomic_long *, long); +ulong __ovld atomic_exchange(volatile __global atomic_ulong *, ulong); +ulong __ovld atomic_exchange(volatile __local atomic_ulong *, ulong); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_exchange_explicit(volatile atomic_int *, int, memory_order); +uint __ovld atomic_exchange_explicit(volatile atomic_uint *, uint, memory_order); +float __ovld atomic_exchange_explicit(volatile atomic_float *, float, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_exchange_explicit(volatile atomic_double *, double, memory_order); +#endif //cl_khr_fp64 +long __ovld atomic_exchange_explicit(volatile atomic_long *, long, memory_order); +ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *, ulong, memory_order); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_exchange_explicit(volatile __global atomic_int *, int, memory_order); +int __ovld atomic_exchange_explicit(volatile __local atomic_int *, int, memory_order); +uint __ovld atomic_exchange_explicit(volatile __global atomic_uint *, uint, memory_order); +uint __ovld atomic_exchange_explicit(volatile __local atomic_uint *, uint, memory_order); +float __ovld atomic_exchange_explicit(volatile __global atomic_float *, float, memory_order); +float __ovld atomic_exchange_explicit(volatile __local atomic_float *, float, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_exchange_explicit(volatile __global atomic_double *, double, memory_order); +double __ovld atomic_exchange_explicit(volatile __local atomic_double *, double, memory_order); +#endif //cl_khr_fp64 +long __ovld atomic_exchange_explicit(volatile __global atomic_long *, long, memory_order); +long __ovld atomic_exchange_explicit(volatile __local atomic_long *, long, memory_order); +ulong __ovld atomic_exchange_explicit(volatile __global atomic_ulong *, ulong, memory_order); +ulong __ovld atomic_exchange_explicit(volatile __local atomic_ulong *, ulong, memory_order); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)wi +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_generic_address_space) +int __ovld atomic_exchange_explicit(volatile atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_exchange_explicit(volatile atomic_uint *, uint, memory_order, memory_scope); +float __ovld atomic_exchange_explicit(volatile atomic_float *, float, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_exchange_explicit(volatile atomic_double *, double, memory_order, memory_scope); +#endif //cl_khr_fp64 +long __ovld atomic_exchange_explicit(volatile atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_exchange_explicit(volatile atomic_ulong *, ulong, memory_order, memory_scope); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +int __ovld atomic_exchange_explicit(volatile __global atomic_int *, int, memory_order, memory_scope); +int __ovld atomic_exchange_explicit(volatile __local atomic_int *, int, memory_order, memory_scope); +uint __ovld atomic_exchange_explicit(volatile __global atomic_uint *, uint, memory_order, memory_scope); +uint __ovld atomic_exchange_explicit(volatile __local atomic_uint *, uint, memory_order, memory_scope); +float __ovld atomic_exchange_explicit(volatile __global atomic_float *, float, memory_order, memory_scope); +float __ovld atomic_exchange_explicit(volatile __local atomic_float *, float, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +double __ovld atomic_exchange_explicit(volatile __global atomic_double *, double, memory_order, memory_scope); +double __ovld atomic_exchange_explicit(volatile __local atomic_double *, double, memory_order, memory_scope); +#endif //cl_khr_fp64 +long __ovld atomic_exchange_explicit(volatile __global atomic_long *, long, memory_order, memory_scope); +long __ovld atomic_exchange_explicit(volatile __local atomic_long *, long, memory_order, memory_scope); +ulong __ovld atomic_exchange_explicit(volatile __global atomic_ulong *, ulong, memory_order, memory_scope); +ulong __ovld atomic_exchange_explicit(volatile __local atomic_ulong *, ulong, memory_order, memory_scope); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + +// atomic_compare_exchange_strong() and atomic_compare_exchange_weak() +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +bool __ovld atomic_compare_exchange_strong(volatile atomic_int *, int *, int); +bool __ovld atomic_compare_exchange_strong(volatile atomic_uint *, uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile atomic_int *, int *, int); +bool __ovld atomic_compare_exchange_weak(volatile atomic_uint *, uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile atomic_float *, float *, float); +bool __ovld atomic_compare_exchange_weak(volatile atomic_float *, float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong(volatile atomic_double *, double *, double); +bool __ovld atomic_compare_exchange_weak(volatile atomic_double *, double *, double); +#endif //cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong(volatile atomic_long *, long *, long); +bool __ovld atomic_compare_exchange_weak(volatile atomic_long *, long *, long); +bool __ovld atomic_compare_exchange_strong(volatile atomic_ulong *, ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile atomic_ulong *, ulong *, ulong); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_int *, __global int *, int); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_int *, __local int *, int); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_int *, __private int *, int); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_int *, __global int *, int); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_int *, __local int *, int); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_int *, __private int *, int); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_uint *, __global uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_uint *, __local uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_uint *, __private uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_uint *, __global uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_uint *, __local uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_uint *, __private uint *, uint); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_float *, __global float *, float); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_float *, __local float *, float); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_float *, __private float *, float); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_float *, __global float *, float); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_float *, __local float *, float); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_float *, __private float *, float); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_int *, __global int *, int); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_int *, __local int *, int); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_int *, __private int *, int); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_int *, __global int *, int); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_int *, __local int *, int); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_int *, __private int *, int); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_uint *, __global uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_uint *, __local uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_uint *, __private uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_uint *, __global uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_uint *, __local uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_uint *, __private uint *, uint); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_float *, __global float *, float); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_float *, __local float *, float); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_float *, __private float *, float); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_float *, __global float *, float); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_float *, __local float *, float); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_float *, __private float *, float); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_double *, __global double *, double); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_double *, __local double *, double); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_double *, __private double *, double); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_double *, __global double *, double); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_double *, __local double *, double); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_double *, __private double *, double); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_double *, __global double *, double); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_double *, __local double *, double); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_double *, __private double *, double); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_double *, __global double *, double); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_double *, __local double *, double); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_double *, __private double *, double); +#endif //cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_long *, __global long *, long); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_long *, __local long *, long); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_long *, __private long *, long); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_long *, __global long *, long); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_long *, __local long *, long); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_long *, __private long *, long); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_ulong *, __global ulong *, ulong); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_ulong *, __local ulong *, ulong); +bool __ovld atomic_compare_exchange_strong(volatile __global atomic_ulong *, __private ulong *, ulong); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_ulong *, __global ulong *, ulong); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_ulong *, __local ulong *, ulong); +bool __ovld atomic_compare_exchange_strong(volatile __local atomic_ulong *, __private ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_long *, __global long *, long); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_long *, __local long *, long); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_long *, __private long *, long); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_long *, __global long *, long); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_long *, __local long *, long); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_long *, __private long *, long); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_ulong *, __global ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_ulong *, __local ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile __global atomic_ulong *, __private ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_ulong *, __global ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_ulong *, __local ulong *, ulong); +bool __ovld atomic_compare_exchange_weak(volatile __local atomic_ulong *, __private ulong *, ulong); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *, int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *, uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *, int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *, uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *, float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *, float *, float, memory_order, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *, double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *, double *, double, memory_order, memory_order); +#endif //cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *, long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *, long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *, ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *, ulong *, ulong, memory_order, memory_order); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_int *, __global int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_int *, __local int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_int *, __private int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_int *, __global int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_int *, __local int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_int *, __private int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_uint *, __global uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_uint *, __local uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_uint *, __private uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_uint *, __global uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_uint *, __local uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_uint *, __private uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_float *, __global float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_float *, __local float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_float *, __private float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_float *, __global float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_float *, __local float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_float *, __private float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_int *, __global int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_int *, __local int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_int *, __private int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_int *, __global int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_int *, __local int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_int *, __private int *, int, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_uint *, __global uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_uint *, __local uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_uint *, __private uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_uint *, __global uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_uint *, __local uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_uint *, __private uint *, uint, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_float *, __global float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_float *, __local float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_float *, __private float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_float *, __global float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_float *, __local float *, float, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_float *, __private float *, float, memory_order, memory_order); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_double *, __global double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_double *, __local double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_double *, __private double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_double *, __global double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_double *, __local double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_double *, __private double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_double *, __global double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_double *, __local double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_double *, __private double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_double *, __global double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_double *, __local double *, double, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_double *, __private double *, double, memory_order, memory_order); +#endif //cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_long *, __global long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_long *, __local long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_long *, __private long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_long *, __global long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_long *, __local long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_long *, __private long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_ulong *, __global ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_ulong *, __local ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_ulong *, __private ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_ulong *, __global ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_ulong *, __local ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_ulong *, __private ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_long *, __global long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_long *, __local long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_long *, __private long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_long *, __global long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_long *, __local long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_long *, __private long *, long, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_ulong *, __global ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_ulong *, __local ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_ulong *, __private ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong *, __global ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong *, __local ulong *, ulong, memory_order, memory_order); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong *, __private ulong *, ulong, memory_order, memory_order); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif //defined(__opencl_c_atomic_scope_device) + +#if defined(__opencl_c_generic_address_space) +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_int *, int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_uint *, uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_int *, int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_uint *, uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_float *, float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_float *, float *, float, memory_order, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_double *, double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_double *, double *, double, memory_order, memory_order, memory_scope); +#endif //cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_long *, long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_long *, long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile atomic_ulong *, ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile atomic_ulong *, ulong *, ulong, memory_order, memory_order, memory_scope); +#endif +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_int *, __global int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_int *, __local int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_int *, __private int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_int *, __global int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_int *, __local int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_int *, __private int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_uint *, __global uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_uint *, __local uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_uint *, __private uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_uint *, __global uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_uint *, __local uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_uint *, __private uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_float *, __global float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_float *, __local float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_float *, __private float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_float *, __global float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_float *, __local float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_float *, __private float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_int *, __global int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_int *, __local int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_int *, __private int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_int *, __global int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_int *, __local int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_int *, __private int *, int, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_uint *, __global uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_uint *, __local uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_uint *, __private uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_uint *, __global uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_uint *, __local uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_uint *, __private uint *, uint, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_float *, __global float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_float *, __local float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_float *, __private float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_float *, __global float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_float *, __local float *, float, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_float *, __private float *, float, memory_order, memory_order, memory_scope); +#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#ifdef cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_double *, __global double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_double *, __local double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_double *, __private double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_double *, __global double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_double *, __local double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_double *, __private double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_double *, __global double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_double *, __local double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_double *, __private double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_double *, __global double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_double *, __local double *, double, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_double *, __private double *, double, memory_order, memory_order, memory_scope); +#endif //cl_khr_fp64 +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_long *, __global long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_long *, __local long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_long *, __private long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_long *, __global long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_long *, __local long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_long *, __private long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_ulong *, __global ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_ulong *, __local ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __global atomic_ulong *, __private ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_ulong *, __global ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_ulong *, __local ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_strong_explicit(volatile __local atomic_ulong *, __private ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_long *, __global long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_long *, __local long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_long *, __private long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_long *, __global long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_long *, __local long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_long *, __private long *, long, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_ulong *, __global ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_ulong *, __local ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __global atomic_ulong *, __private ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong *, __global ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong *, __local ulong *, ulong, memory_order, memory_order, memory_scope); +bool __ovld atomic_compare_exchange_weak_explicit(volatile __local atomic_ulong *, __private ulong *, ulong, memory_order, memory_order, memory_scope); +#endif //defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics) +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) + +// atomic_flag_test_and_set() and atomic_flag_clear() +#if defined(__opencl_c_atomic_order_seq_cst) && defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +bool __ovld atomic_flag_test_and_set(volatile atomic_flag *); +void __ovld atomic_flag_clear(volatile atomic_flag *); +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +bool __ovld atomic_flag_test_and_set(volatile __global atomic_flag *); +bool __ovld atomic_flag_test_and_set(volatile __local atomic_flag *); +void __ovld atomic_flag_clear(volatile __global atomic_flag *); +void __ovld atomic_flag_clear(volatile __local atomic_flag *); +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_atomic_scope_device) +#if defined(__opencl_c_generic_address_space) +bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order); +void __ovld atomic_flag_clear_explicit(volatile atomic_flag *, memory_order); +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +bool __ovld atomic_flag_test_and_set_explicit(volatile __global atomic_flag *, memory_order); +bool __ovld atomic_flag_test_and_set_explicit(volatile __local atomic_flag *, memory_order); +void __ovld atomic_flag_clear_explicit(volatile __global atomic_flag *, memory_order); +void __ovld atomic_flag_clear_explicit(volatile __local atomic_flag *, memory_order); +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif + +#if defined(__opencl_c_generic_address_space) +bool __ovld atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order, memory_scope); +void __ovld atomic_flag_clear_explicit(volatile atomic_flag *, memory_order, memory_scope); +#endif //defined(__opencl_c_generic_address_space) +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +bool __ovld atomic_flag_test_and_set_explicit(volatile __global atomic_flag *, memory_order, memory_scope); +bool __ovld atomic_flag_test_and_set_explicit(volatile __local atomic_flag *, memory_order, memory_scope); +void __ovld atomic_flag_clear_explicit(volatile __global atomic_flag *, memory_order, memory_scope); +void __ovld atomic_flag_clear_explicit(volatile __local atomic_flag *, memory_order, memory_scope); +#endif // (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 || __OPENCL_CPP_VERSION__ >= 202100) +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector Functions + +/** + * The shuffle and shuffle2 built-in functions construct + * a permutation of elements from one or two input + * vectors respectively that are of the same type, + * returning a vector with the same element type as the + * input and length that is the same as the shuffle mask. + * The size of each element in the mask must match the + * size of each element in the result. For shuffle, only + * the ilogb(2m-1) least significant bits of each mask + * element are considered. For shuffle2, only the + * ilogb(2m-1)+1 least significant bits of each mask + * element are considered. Other bits in the mask shall + * be ignored. + * The elements of the input vectors are numbered from + * left to right across one or both of the vectors. For this + * purpose, the number of elements in a vector is given + * by vec_step(gentypem). The shuffle mask operand + * specifies, for each element of the result vector, which + * element of the one or two input vectors the result + * element gets. + * Examples: + * uint4 mask = (uint4)(3, 2, + * 1, 0); + * float4 a; + * float4 r = shuffle(a, mask); + * // r.s0123 = a.wzyx + * uint8 mask = (uint8)(0, 1, 2, 3, + * 4, 5, 6, 7); + * float4 a, b; + * float8 r = shuffle2(a, b, mask); + * // r.s0123 = a.xyzw + * // r.s4567 = b.xyzw + * uint4 mask; + * float8 a; + * float4 b; + * b = shuffle(a, mask); + * Examples that are not valid are: + * uint8 mask; + * short16 a; + * short8 b; + * b = shuffle(a, mask); <- not valid + */ +char2 __ovld __cnfn shuffle(char2, uchar2); +char2 __ovld __cnfn shuffle(char4, uchar2); +char2 __ovld __cnfn shuffle(char8, uchar2); +char2 __ovld __cnfn shuffle(char16, uchar2); + +uchar2 __ovld __cnfn shuffle(uchar2, uchar2); +uchar2 __ovld __cnfn shuffle(uchar4, uchar2); +uchar2 __ovld __cnfn shuffle(uchar8, uchar2); +uchar2 __ovld __cnfn shuffle(uchar16, uchar2); + +short2 __ovld __cnfn shuffle(short2, ushort2); +short2 __ovld __cnfn shuffle(short4, ushort2); +short2 __ovld __cnfn shuffle(short8, ushort2); +short2 __ovld __cnfn shuffle(short16, ushort2); + +ushort2 __ovld __cnfn shuffle(ushort2, ushort2); +ushort2 __ovld __cnfn shuffle(ushort4, ushort2); +ushort2 __ovld __cnfn shuffle(ushort8, ushort2); +ushort2 __ovld __cnfn shuffle(ushort16, ushort2); + +int2 __ovld __cnfn shuffle(int2, uint2); +int2 __ovld __cnfn shuffle(int4, uint2); +int2 __ovld __cnfn shuffle(int8, uint2); +int2 __ovld __cnfn shuffle(int16, uint2); + +uint2 __ovld __cnfn shuffle(uint2, uint2); +uint2 __ovld __cnfn shuffle(uint4, uint2); +uint2 __ovld __cnfn shuffle(uint8, uint2); +uint2 __ovld __cnfn shuffle(uint16, uint2); + +long2 __ovld __cnfn shuffle(long2, ulong2); +long2 __ovld __cnfn shuffle(long4, ulong2); +long2 __ovld __cnfn shuffle(long8, ulong2); +long2 __ovld __cnfn shuffle(long16, ulong2); + +ulong2 __ovld __cnfn shuffle(ulong2, ulong2); +ulong2 __ovld __cnfn shuffle(ulong4, ulong2); +ulong2 __ovld __cnfn shuffle(ulong8, ulong2); +ulong2 __ovld __cnfn shuffle(ulong16, ulong2); + +float2 __ovld __cnfn shuffle(float2, uint2); +float2 __ovld __cnfn shuffle(float4, uint2); +float2 __ovld __cnfn shuffle(float8, uint2); +float2 __ovld __cnfn shuffle(float16, uint2); + +char4 __ovld __cnfn shuffle(char2, uchar4); +char4 __ovld __cnfn shuffle(char4, uchar4); +char4 __ovld __cnfn shuffle(char8, uchar4); +char4 __ovld __cnfn shuffle(char16, uchar4); + +uchar4 __ovld __cnfn shuffle(uchar2, uchar4); +uchar4 __ovld __cnfn shuffle(uchar4, uchar4); +uchar4 __ovld __cnfn shuffle(uchar8, uchar4); +uchar4 __ovld __cnfn shuffle(uchar16, uchar4); + +short4 __ovld __cnfn shuffle(short2, ushort4); +short4 __ovld __cnfn shuffle(short4, ushort4); +short4 __ovld __cnfn shuffle(short8, ushort4); +short4 __ovld __cnfn shuffle(short16, ushort4); + +ushort4 __ovld __cnfn shuffle(ushort2, ushort4); +ushort4 __ovld __cnfn shuffle(ushort4, ushort4); +ushort4 __ovld __cnfn shuffle(ushort8, ushort4); +ushort4 __ovld __cnfn shuffle(ushort16, ushort4); + +int4 __ovld __cnfn shuffle(int2, uint4); +int4 __ovld __cnfn shuffle(int4, uint4); +int4 __ovld __cnfn shuffle(int8, uint4); +int4 __ovld __cnfn shuffle(int16, uint4); + +uint4 __ovld __cnfn shuffle(uint2, uint4); +uint4 __ovld __cnfn shuffle(uint4, uint4); +uint4 __ovld __cnfn shuffle(uint8, uint4); +uint4 __ovld __cnfn shuffle(uint16, uint4); + +long4 __ovld __cnfn shuffle(long2, ulong4); +long4 __ovld __cnfn shuffle(long4, ulong4); +long4 __ovld __cnfn shuffle(long8, ulong4); +long4 __ovld __cnfn shuffle(long16, ulong4); + +ulong4 __ovld __cnfn shuffle(ulong2, ulong4); +ulong4 __ovld __cnfn shuffle(ulong4, ulong4); +ulong4 __ovld __cnfn shuffle(ulong8, ulong4); +ulong4 __ovld __cnfn shuffle(ulong16, ulong4); + +float4 __ovld __cnfn shuffle(float2, uint4); +float4 __ovld __cnfn shuffle(float4, uint4); +float4 __ovld __cnfn shuffle(float8, uint4); +float4 __ovld __cnfn shuffle(float16, uint4); + +char8 __ovld __cnfn shuffle(char2, uchar8); +char8 __ovld __cnfn shuffle(char4, uchar8); +char8 __ovld __cnfn shuffle(char8, uchar8); +char8 __ovld __cnfn shuffle(char16, uchar8); + +uchar8 __ovld __cnfn shuffle(uchar2, uchar8); +uchar8 __ovld __cnfn shuffle(uchar4, uchar8); +uchar8 __ovld __cnfn shuffle(uchar8, uchar8); +uchar8 __ovld __cnfn shuffle(uchar16, uchar8); + +short8 __ovld __cnfn shuffle(short2, ushort8); +short8 __ovld __cnfn shuffle(short4, ushort8); +short8 __ovld __cnfn shuffle(short8, ushort8); +short8 __ovld __cnfn shuffle(short16, ushort8); + +ushort8 __ovld __cnfn shuffle(ushort2, ushort8); +ushort8 __ovld __cnfn shuffle(ushort4, ushort8); +ushort8 __ovld __cnfn shuffle(ushort8, ushort8); +ushort8 __ovld __cnfn shuffle(ushort16, ushort8); + +int8 __ovld __cnfn shuffle(int2, uint8); +int8 __ovld __cnfn shuffle(int4, uint8); +int8 __ovld __cnfn shuffle(int8, uint8); +int8 __ovld __cnfn shuffle(int16, uint8); + +uint8 __ovld __cnfn shuffle(uint2, uint8); +uint8 __ovld __cnfn shuffle(uint4, uint8); +uint8 __ovld __cnfn shuffle(uint8, uint8); +uint8 __ovld __cnfn shuffle(uint16, uint8); + +long8 __ovld __cnfn shuffle(long2, ulong8); +long8 __ovld __cnfn shuffle(long4, ulong8); +long8 __ovld __cnfn shuffle(long8, ulong8); +long8 __ovld __cnfn shuffle(long16, ulong8); + +ulong8 __ovld __cnfn shuffle(ulong2, ulong8); +ulong8 __ovld __cnfn shuffle(ulong4, ulong8); +ulong8 __ovld __cnfn shuffle(ulong8, ulong8); +ulong8 __ovld __cnfn shuffle(ulong16, ulong8); + +float8 __ovld __cnfn shuffle(float2, uint8); +float8 __ovld __cnfn shuffle(float4, uint8); +float8 __ovld __cnfn shuffle(float8, uint8); +float8 __ovld __cnfn shuffle(float16, uint8); + +char16 __ovld __cnfn shuffle(char2, uchar16); +char16 __ovld __cnfn shuffle(char4, uchar16); +char16 __ovld __cnfn shuffle(char8, uchar16); +char16 __ovld __cnfn shuffle(char16, uchar16); + +uchar16 __ovld __cnfn shuffle(uchar2, uchar16); +uchar16 __ovld __cnfn shuffle(uchar4, uchar16); +uchar16 __ovld __cnfn shuffle(uchar8, uchar16); +uchar16 __ovld __cnfn shuffle(uchar16, uchar16); + +short16 __ovld __cnfn shuffle(short2, ushort16); +short16 __ovld __cnfn shuffle(short4, ushort16); +short16 __ovld __cnfn shuffle(short8, ushort16); +short16 __ovld __cnfn shuffle(short16, ushort16); + +ushort16 __ovld __cnfn shuffle(ushort2, ushort16); +ushort16 __ovld __cnfn shuffle(ushort4, ushort16); +ushort16 __ovld __cnfn shuffle(ushort8, ushort16); +ushort16 __ovld __cnfn shuffle(ushort16, ushort16); + +int16 __ovld __cnfn shuffle(int2, uint16); +int16 __ovld __cnfn shuffle(int4, uint16); +int16 __ovld __cnfn shuffle(int8, uint16); +int16 __ovld __cnfn shuffle(int16, uint16); + +uint16 __ovld __cnfn shuffle(uint2, uint16); +uint16 __ovld __cnfn shuffle(uint4, uint16); +uint16 __ovld __cnfn shuffle(uint8, uint16); +uint16 __ovld __cnfn shuffle(uint16, uint16); + +long16 __ovld __cnfn shuffle(long2, ulong16); +long16 __ovld __cnfn shuffle(long4, ulong16); +long16 __ovld __cnfn shuffle(long8, ulong16); +long16 __ovld __cnfn shuffle(long16, ulong16); + +ulong16 __ovld __cnfn shuffle(ulong2, ulong16); +ulong16 __ovld __cnfn shuffle(ulong4, ulong16); +ulong16 __ovld __cnfn shuffle(ulong8, ulong16); +ulong16 __ovld __cnfn shuffle(ulong16, ulong16); + +float16 __ovld __cnfn shuffle(float2, uint16); +float16 __ovld __cnfn shuffle(float4, uint16); +float16 __ovld __cnfn shuffle(float8, uint16); +float16 __ovld __cnfn shuffle(float16, uint16); + +#ifdef cl_khr_fp64 +double2 __ovld __cnfn shuffle(double2, ulong2); +double2 __ovld __cnfn shuffle(double4, ulong2); +double2 __ovld __cnfn shuffle(double8, ulong2); +double2 __ovld __cnfn shuffle(double16, ulong2); + +double4 __ovld __cnfn shuffle(double2, ulong4); +double4 __ovld __cnfn shuffle(double4, ulong4); +double4 __ovld __cnfn shuffle(double8, ulong4); +double4 __ovld __cnfn shuffle(double16, ulong4); + +double8 __ovld __cnfn shuffle(double2, ulong8); +double8 __ovld __cnfn shuffle(double4, ulong8); +double8 __ovld __cnfn shuffle(double8, ulong8); +double8 __ovld __cnfn shuffle(double16, ulong8); + +double16 __ovld __cnfn shuffle(double2, ulong16); +double16 __ovld __cnfn shuffle(double4, ulong16); +double16 __ovld __cnfn shuffle(double8, ulong16); +double16 __ovld __cnfn shuffle(double16, ulong16); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +half2 __ovld __cnfn shuffle(half2, ushort2); +half2 __ovld __cnfn shuffle(half4, ushort2); +half2 __ovld __cnfn shuffle(half8, ushort2); +half2 __ovld __cnfn shuffle(half16, ushort2); + +half4 __ovld __cnfn shuffle(half2, ushort4); +half4 __ovld __cnfn shuffle(half4, ushort4); +half4 __ovld __cnfn shuffle(half8, ushort4); +half4 __ovld __cnfn shuffle(half16, ushort4); + +half8 __ovld __cnfn shuffle(half2, ushort8); +half8 __ovld __cnfn shuffle(half4, ushort8); +half8 __ovld __cnfn shuffle(half8, ushort8); +half8 __ovld __cnfn shuffle(half16, ushort8); + +half16 __ovld __cnfn shuffle(half2, ushort16); +half16 __ovld __cnfn shuffle(half4, ushort16); +half16 __ovld __cnfn shuffle(half8, ushort16); +half16 __ovld __cnfn shuffle(half16, ushort16); +#endif //cl_khr_fp16 + +char2 __ovld __cnfn shuffle2(char2, char2, uchar2); +char2 __ovld __cnfn shuffle2(char4, char4, uchar2); +char2 __ovld __cnfn shuffle2(char8, char8, uchar2); +char2 __ovld __cnfn shuffle2(char16, char16, uchar2); + +uchar2 __ovld __cnfn shuffle2(uchar2, uchar2, uchar2); +uchar2 __ovld __cnfn shuffle2(uchar4, uchar4, uchar2); +uchar2 __ovld __cnfn shuffle2(uchar8, uchar8, uchar2); +uchar2 __ovld __cnfn shuffle2(uchar16, uchar16, uchar2); + +short2 __ovld __cnfn shuffle2(short2, short2, ushort2); +short2 __ovld __cnfn shuffle2(short4, short4, ushort2); +short2 __ovld __cnfn shuffle2(short8, short8, ushort2); +short2 __ovld __cnfn shuffle2(short16, short16, ushort2); + +ushort2 __ovld __cnfn shuffle2(ushort2, ushort2, ushort2); +ushort2 __ovld __cnfn shuffle2(ushort4, ushort4, ushort2); +ushort2 __ovld __cnfn shuffle2(ushort8, ushort8, ushort2); +ushort2 __ovld __cnfn shuffle2(ushort16, ushort16, ushort2); + +int2 __ovld __cnfn shuffle2(int2, int2, uint2); +int2 __ovld __cnfn shuffle2(int4, int4, uint2); +int2 __ovld __cnfn shuffle2(int8, int8, uint2); +int2 __ovld __cnfn shuffle2(int16, int16, uint2); + +uint2 __ovld __cnfn shuffle2(uint2, uint2, uint2); +uint2 __ovld __cnfn shuffle2(uint4, uint4, uint2); +uint2 __ovld __cnfn shuffle2(uint8, uint8, uint2); +uint2 __ovld __cnfn shuffle2(uint16, uint16, uint2); + +long2 __ovld __cnfn shuffle2(long2, long2, ulong2); +long2 __ovld __cnfn shuffle2(long4, long4, ulong2); +long2 __ovld __cnfn shuffle2(long8, long8, ulong2); +long2 __ovld __cnfn shuffle2(long16, long16, ulong2); + +ulong2 __ovld __cnfn shuffle2(ulong2, ulong2, ulong2); +ulong2 __ovld __cnfn shuffle2(ulong4, ulong4, ulong2); +ulong2 __ovld __cnfn shuffle2(ulong8, ulong8, ulong2); +ulong2 __ovld __cnfn shuffle2(ulong16, ulong16, ulong2); + +float2 __ovld __cnfn shuffle2(float2, float2, uint2); +float2 __ovld __cnfn shuffle2(float4, float4, uint2); +float2 __ovld __cnfn shuffle2(float8, float8, uint2); +float2 __ovld __cnfn shuffle2(float16, float16, uint2); + +char4 __ovld __cnfn shuffle2(char2, char2, uchar4); +char4 __ovld __cnfn shuffle2(char4, char4, uchar4); +char4 __ovld __cnfn shuffle2(char8, char8, uchar4); +char4 __ovld __cnfn shuffle2(char16, char16, uchar4); + +uchar4 __ovld __cnfn shuffle2(uchar2, uchar2, uchar4); +uchar4 __ovld __cnfn shuffle2(uchar4, uchar4, uchar4); +uchar4 __ovld __cnfn shuffle2(uchar8, uchar8, uchar4); +uchar4 __ovld __cnfn shuffle2(uchar16, uchar16, uchar4); + +short4 __ovld __cnfn shuffle2(short2, short2, ushort4); +short4 __ovld __cnfn shuffle2(short4, short4, ushort4); +short4 __ovld __cnfn shuffle2(short8, short8, ushort4); +short4 __ovld __cnfn shuffle2(short16, short16, ushort4); + +ushort4 __ovld __cnfn shuffle2(ushort2, ushort2, ushort4); +ushort4 __ovld __cnfn shuffle2(ushort4, ushort4, ushort4); +ushort4 __ovld __cnfn shuffle2(ushort8, ushort8, ushort4); +ushort4 __ovld __cnfn shuffle2(ushort16, ushort16, ushort4); + +int4 __ovld __cnfn shuffle2(int2, int2, uint4); +int4 __ovld __cnfn shuffle2(int4, int4, uint4); +int4 __ovld __cnfn shuffle2(int8, int8, uint4); +int4 __ovld __cnfn shuffle2(int16, int16, uint4); + +uint4 __ovld __cnfn shuffle2(uint2, uint2, uint4); +uint4 __ovld __cnfn shuffle2(uint4, uint4, uint4); +uint4 __ovld __cnfn shuffle2(uint8, uint8, uint4); +uint4 __ovld __cnfn shuffle2(uint16, uint16, uint4); + +long4 __ovld __cnfn shuffle2(long2, long2, ulong4); +long4 __ovld __cnfn shuffle2(long4, long4, ulong4); +long4 __ovld __cnfn shuffle2(long8, long8, ulong4); +long4 __ovld __cnfn shuffle2(long16, long16, ulong4); + +ulong4 __ovld __cnfn shuffle2(ulong2, ulong2, ulong4); +ulong4 __ovld __cnfn shuffle2(ulong4, ulong4, ulong4); +ulong4 __ovld __cnfn shuffle2(ulong8, ulong8, ulong4); +ulong4 __ovld __cnfn shuffle2(ulong16, ulong16, ulong4); + +float4 __ovld __cnfn shuffle2(float2, float2, uint4); +float4 __ovld __cnfn shuffle2(float4, float4, uint4); +float4 __ovld __cnfn shuffle2(float8, float8, uint4); +float4 __ovld __cnfn shuffle2(float16, float16, uint4); + +char8 __ovld __cnfn shuffle2(char2, char2, uchar8); +char8 __ovld __cnfn shuffle2(char4, char4, uchar8); +char8 __ovld __cnfn shuffle2(char8, char8, uchar8); +char8 __ovld __cnfn shuffle2(char16, char16, uchar8); + +uchar8 __ovld __cnfn shuffle2(uchar2, uchar2, uchar8); +uchar8 __ovld __cnfn shuffle2(uchar4, uchar4, uchar8); +uchar8 __ovld __cnfn shuffle2(uchar8, uchar8, uchar8); +uchar8 __ovld __cnfn shuffle2(uchar16, uchar16, uchar8); + +short8 __ovld __cnfn shuffle2(short2, short2, ushort8); +short8 __ovld __cnfn shuffle2(short4, short4, ushort8); +short8 __ovld __cnfn shuffle2(short8, short8, ushort8); +short8 __ovld __cnfn shuffle2(short16, short16, ushort8); + +ushort8 __ovld __cnfn shuffle2(ushort2, ushort2, ushort8); +ushort8 __ovld __cnfn shuffle2(ushort4, ushort4, ushort8); +ushort8 __ovld __cnfn shuffle2(ushort8, ushort8, ushort8); +ushort8 __ovld __cnfn shuffle2(ushort16, ushort16, ushort8); + +int8 __ovld __cnfn shuffle2(int2, int2, uint8); +int8 __ovld __cnfn shuffle2(int4, int4, uint8); +int8 __ovld __cnfn shuffle2(int8, int8, uint8); +int8 __ovld __cnfn shuffle2(int16, int16, uint8); + +uint8 __ovld __cnfn shuffle2(uint2, uint2, uint8); +uint8 __ovld __cnfn shuffle2(uint4, uint4, uint8); +uint8 __ovld __cnfn shuffle2(uint8, uint8, uint8); +uint8 __ovld __cnfn shuffle2(uint16, uint16, uint8); + +long8 __ovld __cnfn shuffle2(long2, long2, ulong8); +long8 __ovld __cnfn shuffle2(long4, long4, ulong8); +long8 __ovld __cnfn shuffle2(long8, long8, ulong8); +long8 __ovld __cnfn shuffle2(long16, long16, ulong8); + +ulong8 __ovld __cnfn shuffle2(ulong2, ulong2, ulong8); +ulong8 __ovld __cnfn shuffle2(ulong4, ulong4, ulong8); +ulong8 __ovld __cnfn shuffle2(ulong8, ulong8, ulong8); +ulong8 __ovld __cnfn shuffle2(ulong16, ulong16, ulong8); + +float8 __ovld __cnfn shuffle2(float2, float2, uint8); +float8 __ovld __cnfn shuffle2(float4, float4, uint8); +float8 __ovld __cnfn shuffle2(float8, float8, uint8); +float8 __ovld __cnfn shuffle2(float16, float16, uint8); + +char16 __ovld __cnfn shuffle2(char2, char2, uchar16); +char16 __ovld __cnfn shuffle2(char4, char4, uchar16); +char16 __ovld __cnfn shuffle2(char8, char8, uchar16); +char16 __ovld __cnfn shuffle2(char16, char16, uchar16); + +uchar16 __ovld __cnfn shuffle2(uchar2, uchar2, uchar16); +uchar16 __ovld __cnfn shuffle2(uchar4, uchar4, uchar16); +uchar16 __ovld __cnfn shuffle2(uchar8, uchar8, uchar16); +uchar16 __ovld __cnfn shuffle2(uchar16, uchar16, uchar16); + +short16 __ovld __cnfn shuffle2(short2, short2, ushort16); +short16 __ovld __cnfn shuffle2(short4, short4, ushort16); +short16 __ovld __cnfn shuffle2(short8, short8, ushort16); +short16 __ovld __cnfn shuffle2(short16, short16, ushort16); + +ushort16 __ovld __cnfn shuffle2(ushort2, ushort2, ushort16); +ushort16 __ovld __cnfn shuffle2(ushort4, ushort4, ushort16); +ushort16 __ovld __cnfn shuffle2(ushort8, ushort8, ushort16); +ushort16 __ovld __cnfn shuffle2(ushort16, ushort16, ushort16); + +int16 __ovld __cnfn shuffle2(int2, int2, uint16); +int16 __ovld __cnfn shuffle2(int4, int4, uint16); +int16 __ovld __cnfn shuffle2(int8, int8, uint16); +int16 __ovld __cnfn shuffle2(int16, int16, uint16); + +uint16 __ovld __cnfn shuffle2(uint2, uint2, uint16); +uint16 __ovld __cnfn shuffle2(uint4, uint4, uint16); +uint16 __ovld __cnfn shuffle2(uint8, uint8, uint16); +uint16 __ovld __cnfn shuffle2(uint16, uint16, uint16); + +long16 __ovld __cnfn shuffle2(long2, long2, ulong16); +long16 __ovld __cnfn shuffle2(long4, long4, ulong16); +long16 __ovld __cnfn shuffle2(long8, long8, ulong16); +long16 __ovld __cnfn shuffle2(long16, long16, ulong16); + +ulong16 __ovld __cnfn shuffle2(ulong2, ulong2, ulong16); +ulong16 __ovld __cnfn shuffle2(ulong4, ulong4, ulong16); +ulong16 __ovld __cnfn shuffle2(ulong8, ulong8, ulong16); +ulong16 __ovld __cnfn shuffle2(ulong16, ulong16, ulong16); + +float16 __ovld __cnfn shuffle2(float2, float2, uint16); +float16 __ovld __cnfn shuffle2(float4, float4, uint16); +float16 __ovld __cnfn shuffle2(float8, float8, uint16); +float16 __ovld __cnfn shuffle2(float16, float16, uint16); + +#ifdef cl_khr_fp64 +double2 __ovld __cnfn shuffle2(double2, double2, ulong2); +double2 __ovld __cnfn shuffle2(double4, double4, ulong2); +double2 __ovld __cnfn shuffle2(double8, double8, ulong2); +double2 __ovld __cnfn shuffle2(double16, double16, ulong2); + +double4 __ovld __cnfn shuffle2(double2, double2, ulong4); +double4 __ovld __cnfn shuffle2(double4, double4, ulong4); +double4 __ovld __cnfn shuffle2(double8, double8, ulong4); +double4 __ovld __cnfn shuffle2(double16, double16, ulong4); + +double8 __ovld __cnfn shuffle2(double2, double2, ulong8); +double8 __ovld __cnfn shuffle2(double4, double4, ulong8); +double8 __ovld __cnfn shuffle2(double8, double8, ulong8); +double8 __ovld __cnfn shuffle2(double16, double16, ulong8); + +double16 __ovld __cnfn shuffle2(double2, double2, ulong16); +double16 __ovld __cnfn shuffle2(double4, double4, ulong16); +double16 __ovld __cnfn shuffle2(double8, double8, ulong16); +double16 __ovld __cnfn shuffle2(double16, double16, ulong16); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +half2 __ovld __cnfn shuffle2(half2, half2, ushort2); +half2 __ovld __cnfn shuffle2(half4, half4, ushort2); +half2 __ovld __cnfn shuffle2(half8, half8, ushort2); +half2 __ovld __cnfn shuffle2(half16, half16, ushort2); + +half4 __ovld __cnfn shuffle2(half2, half2, ushort4); +half4 __ovld __cnfn shuffle2(half4, half4, ushort4); +half4 __ovld __cnfn shuffle2(half8, half8, ushort4); +half4 __ovld __cnfn shuffle2(half16, half16, ushort4); + +half8 __ovld __cnfn shuffle2(half2, half2, ushort8); +half8 __ovld __cnfn shuffle2(half4, half4, ushort8); +half8 __ovld __cnfn shuffle2(half8, half8, ushort8); +half8 __ovld __cnfn shuffle2(half16, half16, ushort8); + +half16 __ovld __cnfn shuffle2(half2, half2, ushort16); +half16 __ovld __cnfn shuffle2(half4, half4, ushort16); +half16 __ovld __cnfn shuffle2(half8, half8, ushort16); +half16 __ovld __cnfn shuffle2(half16, half16, ushort16); +#endif //cl_khr_fp16 + +// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions + +#ifdef cl_khr_gl_msaa_sharing +#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable +#endif //cl_khr_gl_msaa_sharing + +#if (defined(__opencl_c_images) || defined(__IMAGE_SUPPORT__)) +/** + * Use the coordinate (coord.xy) to do an element lookup in + * the 2D image object specified by image. + * + * Use the coordinate (coord.x, coord.y, coord.z) to do + * an element lookup in the 3D image object specified + * by image. coord.w is ignored. + * + * Use the coordinate (coord.z) to index into the + * 2D image array object specified by image_array + * and (coord.x, coord.y) to do an element lookup in + * the 2D image object specified by image. + * + * Use the coordinate (x) to do an element lookup in + * the 1D image object specified by image. + * + * Use the coordinate (coord.y) to index into the + * 1D image array object specified by image_array + * and (coord.x) to do an element lookup in + * the 1D image object specified by image. + * + * Use the coordinate (cood.xy) and sample to do an + * element lookup in the 2D multi-sample image specified + * by image. + * + * Use coord.xy and sample to do an element + * lookup in the 2D multi-sample image layer + * identified by index coord.z in the 2D multi-sample + * image array specified by image. + * + * For mipmap images, use the mip-level specified by + * the Level-of-Detail (lod) or use gradients for LOD + * computation. + * + * read_imagef returns floating-point values in the + * range [0.0 ... 1.0] for image objects created with + * image_channel_data_type set to one of the predefined + * packed formats or CL_UNORM_INT8, or + * CL_UNORM_INT16. + * + * read_imagef returns floating-point values in the + * range [-1.0 ... 1.0] for image objects created with + * image_channel_data_type set to CL_SNORM_INT8, + * or CL_SNORM_INT16. + * + * read_imagef returns floating-point values for image + * objects created with image_channel_data_type set to + * CL_HALF_FLOAT or CL_FLOAT. + * + * read_imagei and read_imageui return + * unnormalized signed integer and unsigned integer + * values respectively. Each channel will be stored in a + * 32-bit integer. + * + * read_imagei can only be used with image objects + * created with image_channel_data_type set to one of + * the following values: + * CL_SIGNED_INT8, + * CL_SIGNED_INT16 and + * CL_SIGNED_INT32. + * If the image_channel_data_type is not one of the + * above values, the values returned by read_imagei + * are undefined. + * + * read_imageui can only be used with image objects + * created with image_channel_data_type set to one of + * the following values: + * CL_UNSIGNED_INT8, + * CL_UNSIGNED_INT16 and + * CL_UNSIGNED_INT32. + * If the image_channel_data_type is not one of the + * above values, the values returned by read_imageui + * are undefined. + * + * The read_image{i|ui} calls support a nearest filter + * only. The filter_mode specified in sampler + * must be set to CLK_FILTER_NEAREST; otherwise + * the values returned are undefined. + + * The read_image{f|i|ui} calls that take + * integer coordinates must use a sampler with + * normalized coordinates set to + * CLK_NORMALIZED_COORDS_FALSE and + * addressing mode set to + * CLK_ADDRESS_CLAMP_TO_EDGE, + * CLK_ADDRESS_CLAMP or CLK_ADDRESS_NONE; + * otherwise the values returned are undefined. + * + * Values returned by read_imagef for image objects + * with image_channel_data_type values not specified + * in the description above are undefined. + */ + +float4 __ovld __purefn read_imagef(read_only image2d_t, sampler_t, int2); +float4 __ovld __purefn read_imagef(read_only image2d_t, sampler_t, float2); + +int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, int2); +int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2); +uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, int2); +uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2); + +float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, int4); +float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4); + +int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, int4); +int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4); +uint4 __ovld __purefn read_imageui(read_only image3d_t, sampler_t, int4); +uint4 __ovld __purefn read_imageui(read_only image3d_t, sampler_t, float4); + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, int4); +float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, float4); + +int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, int4); +int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4); +uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, int4); +uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, float4); +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) + +float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, int); +float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, float); + +int4 __ovld __purefn read_imagei(read_only image1d_t, sampler_t, int); +int4 __ovld __purefn read_imagei(read_only image1d_t, sampler_t, float); +uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, int); +uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, float); + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, int2); +float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, float2); + +int4 __ovld __purefn read_imagei(read_only image1d_array_t, sampler_t, int2); +int4 __ovld __purefn read_imagei(read_only image1d_array_t, sampler_t, float2); +uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, int2); +uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, float2); +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, float2); +float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, int2); + +float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, float4); +float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, int4); +#endif //cl_khr_depth_images + +#if defined(cl_khr_gl_msaa_sharing) +float4 __ovld __purefn read_imagef(read_only image2d_msaa_t, int2, int); +int4 __ovld __purefn read_imagei(read_only image2d_msaa_t, int2, int); +uint4 __ovld __purefn read_imageui(read_only image2d_msaa_t, int2, int); + +float __ovld __purefn read_imagef(read_only image2d_msaa_depth_t, int2, int); + +float4 __ovld __purefn read_imagef(read_only image2d_array_msaa_t, int4, int); +int4 __ovld __purefn read_imagei(read_only image2d_array_msaa_t, int4, int); +uint4 __ovld __purefn read_imageui(read_only image2d_array_msaa_t, int4, int); + +float __ovld __purefn read_imagef(read_only image2d_array_msaa_depth_t, int4, int); +#endif //cl_khr_gl_msaa_sharing + +// OpenCL Extension v2.0 s9.18 - Mipmaps +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +#ifdef cl_khr_mipmap_image + +float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, float, float); +int4 __ovld __purefn read_imagei(read_only image1d_t, sampler_t, float, float); +uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, float, float); + +float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, float2, float); +int4 __ovld __purefn read_imagei(read_only image1d_array_t, sampler_t, float2, float); +uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, float2, float); + +float4 __ovld __purefn read_imagef(read_only image2d_t, sampler_t, float2, float); +int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2, float); +uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2, float); + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, float2, float); +#endif // cl_khr_depth_images + +float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, float4, float); +int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4, float); +uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, float4, float); + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, float4, float); +#endif // cl_khr_depth_images + +float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4, float); +int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4, float); +uint4 __ovld __purefn read_imageui(read_only image3d_t, sampler_t, float4, float); + +float4 __ovld __purefn read_imagef(read_only image1d_t, sampler_t, float, float, float); +int4 __ovld __purefn read_imagei(read_only image1d_t, sampler_t, float, float, float); +uint4 __ovld __purefn read_imageui(read_only image1d_t, sampler_t, float, float, float); + +float4 __ovld __purefn read_imagef(read_only image1d_array_t, sampler_t, float2, float, float); +int4 __ovld __purefn read_imagei(read_only image1d_array_t, sampler_t, float2, float, float); +uint4 __ovld __purefn read_imageui(read_only image1d_array_t, sampler_t, float2, float, float); + +float4 __ovld __purefn read_imagef(read_only image2d_t, sampler_t, float2, float2, float2); +int4 __ovld __purefn read_imagei(read_only image2d_t, sampler_t, float2, float2, float2); +uint4 __ovld __purefn read_imageui(read_only image2d_t, sampler_t, float2, float2, float2); + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_only image2d_depth_t, sampler_t, float2, float2, float2); +#endif // cl_khr_depth_images + +float4 __ovld __purefn read_imagef(read_only image2d_array_t, sampler_t, float4, float2, float2); +int4 __ovld __purefn read_imagei(read_only image2d_array_t, sampler_t, float4, float2, float2); +uint4 __ovld __purefn read_imageui(read_only image2d_array_t, sampler_t, float4, float2, float2); + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_only image2d_array_depth_t, sampler_t, float4, float2, float2); +#endif // cl_khr_depth_images + +float4 __ovld __purefn read_imagef(read_only image3d_t, sampler_t, float4, float4, float4); +int4 __ovld __purefn read_imagei(read_only image3d_t, sampler_t, float4, float4, float4); +uint4 __ovld __purefn read_imageui(read_only image3d_t, sampler_t, float4, float4, float4); + +#endif //cl_khr_mipmap_image +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) + +/** +* Sampler-less Image Access +*/ + +float4 __ovld __purefn read_imagef(read_only image1d_t, int); +int4 __ovld __purefn read_imagei(read_only image1d_t, int); +uint4 __ovld __purefn read_imageui(read_only image1d_t, int); + +float4 __ovld __purefn read_imagef(read_only image1d_buffer_t, int); +int4 __ovld __purefn read_imagei(read_only image1d_buffer_t, int); +uint4 __ovld __purefn read_imageui(read_only image1d_buffer_t, int); + +float4 __ovld __purefn read_imagef(read_only image1d_array_t, int2); +int4 __ovld __purefn read_imagei(read_only image1d_array_t, int2); +uint4 __ovld __purefn read_imageui(read_only image1d_array_t, int2); + +float4 __ovld __purefn read_imagef(read_only image2d_t, int2); +int4 __ovld __purefn read_imagei(read_only image2d_t, int2); +uint4 __ovld __purefn read_imageui(read_only image2d_t, int2); + +float4 __ovld __purefn read_imagef(read_only image2d_array_t, int4); +int4 __ovld __purefn read_imagei(read_only image2d_array_t, int4); +uint4 __ovld __purefn read_imageui(read_only image2d_array_t, int4); + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_only image2d_depth_t, int2); +float __ovld __purefn read_imagef(read_only image2d_array_depth_t, int4); +#endif //cl_khr_depth_images + +float4 __ovld __purefn read_imagef(read_only image3d_t, int4); +int4 __ovld __purefn read_imagei(read_only image3d_t, int4); +uint4 __ovld __purefn read_imageui(read_only image3d_t, int4); + +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) + +// Image read functions returning half4 type +#ifdef cl_khr_fp16 +half4 __ovld __purefn read_imageh(read_only image1d_t, sampler_t, int); +half4 __ovld __purefn read_imageh(read_only image1d_t, sampler_t, float); +half4 __ovld __purefn read_imageh(read_only image2d_t, sampler_t, int2); +half4 __ovld __purefn read_imageh(read_only image2d_t, sampler_t, float2); +half4 __ovld __purefn read_imageh(read_only image3d_t, sampler_t, int4); +half4 __ovld __purefn read_imageh(read_only image3d_t, sampler_t, float4); +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +half4 __ovld __purefn read_imageh(read_only image1d_array_t, sampler_t, int2); +half4 __ovld __purefn read_imageh(read_only image1d_array_t, sampler_t, float2); +half4 __ovld __purefn read_imageh(read_only image2d_array_t, sampler_t, int4); +half4 __ovld __purefn read_imageh(read_only image2d_array_t, sampler_t, float4); +/** + * Sampler-less Image Access + */ +half4 __ovld __purefn read_imageh(read_only image1d_t, int); +half4 __ovld __purefn read_imageh(read_only image2d_t, int2); +half4 __ovld __purefn read_imageh(read_only image3d_t, int4); +half4 __ovld __purefn read_imageh(read_only image1d_array_t, int2); +half4 __ovld __purefn read_imageh(read_only image2d_array_t, int4); +half4 __ovld __purefn read_imageh(read_only image1d_buffer_t, int); +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) +#endif //cl_khr_fp16 + +// Image read functions for read_write images +#if defined(__opencl_c_read_write_images) +float4 __ovld __purefn read_imagef(read_write image1d_t, int); +int4 __ovld __purefn read_imagei(read_write image1d_t, int); +uint4 __ovld __purefn read_imageui(read_write image1d_t, int); + +float4 __ovld __purefn read_imagef(read_write image1d_buffer_t, int); +int4 __ovld __purefn read_imagei(read_write image1d_buffer_t, int); +uint4 __ovld __purefn read_imageui(read_write image1d_buffer_t, int); + +float4 __ovld __purefn read_imagef(read_write image1d_array_t, int2); +int4 __ovld __purefn read_imagei(read_write image1d_array_t, int2); +uint4 __ovld __purefn read_imageui(read_write image1d_array_t, int2); + +float4 __ovld __purefn read_imagef(read_write image2d_t, int2); +int4 __ovld __purefn read_imagei(read_write image2d_t, int2); +uint4 __ovld __purefn read_imageui(read_write image2d_t, int2); + +float4 __ovld __purefn read_imagef(read_write image2d_array_t, int4); +int4 __ovld __purefn read_imagei(read_write image2d_array_t, int4); +uint4 __ovld __purefn read_imageui(read_write image2d_array_t, int4); + +#ifdef cl_khr_3d_image_writes +float4 __ovld __purefn read_imagef(read_write image3d_t, int4); +int4 __ovld __purefn read_imagei(read_write image3d_t, int4); +uint4 __ovld __purefn read_imageui(read_write image3d_t, int4); +#endif // cl_khr_3d_image_writes + +#ifdef cl_khr_depth_images +float __ovld __purefn read_imagef(read_write image2d_depth_t, int2); +float __ovld __purefn read_imagef(read_write image2d_array_depth_t, int4); +#endif //cl_khr_depth_images + +#if cl_khr_gl_msaa_sharing +float4 __ovld __purefn read_imagef(read_write image2d_msaa_t, int2, int); +int4 __ovld __purefn read_imagei(read_write image2d_msaa_t, int2, int); +uint4 __ovld __purefn read_imageui(read_write image2d_msaa_t, int2, int); + +float4 __ovld __purefn read_imagef(read_write image2d_array_msaa_t, int4, int); +int4 __ovld __purefn read_imagei(read_write image2d_array_msaa_t, int4, int); +uint4 __ovld __purefn read_imageui(read_write image2d_array_msaa_t, int4, int); + +float __ovld __purefn read_imagef(read_write image2d_msaa_depth_t, int2, int); +float __ovld __purefn read_imagef(read_write image2d_array_msaa_depth_t, int4, int); +#endif //cl_khr_gl_msaa_sharing + +#ifdef cl_khr_mipmap_image +float4 __ovld __purefn read_imagef(read_write image1d_t, sampler_t, float, float); +int4 __ovld __purefn read_imagei(read_write image1d_t, sampler_t, float, float); +uint4 __ovld __purefn read_imageui(read_write image1d_t, sampler_t, float, float); + +float4 __ovld __purefn read_imagef(read_write image1d_array_t, sampler_t, float2, float); +int4 __ovld __purefn read_imagei(read_write image1d_array_t, sampler_t, float2, float); +uint4 __ovld __purefn read_imageui(read_write image1d_array_t, sampler_t, float2, float); + +float4 __ovld __purefn read_imagef(read_write image2d_t, sampler_t, float2, float); +int4 __ovld __purefn read_imagei(read_write image2d_t, sampler_t, float2, float); +uint4 __ovld __purefn read_imageui(read_write image2d_t, sampler_t, float2, float); + +float __ovld __purefn read_imagef(read_write image2d_depth_t, sampler_t, float2, float); + +float4 __ovld __purefn read_imagef(read_write image2d_array_t, sampler_t, float4, float); +int4 __ovld __purefn read_imagei(read_write image2d_array_t, sampler_t, float4, float); +uint4 __ovld __purefn read_imageui(read_write image2d_array_t, sampler_t, float4, float); + +float __ovld __purefn read_imagef(read_write image2d_array_depth_t, sampler_t, float4, float); + +#ifdef cl_khr_3d_image_writes +float4 __ovld __purefn read_imagef(read_write image3d_t, sampler_t, float4, float); +int4 __ovld __purefn read_imagei(read_write image3d_t, sampler_t, float4, float); +uint4 __ovld __purefn read_imageui(read_write image3d_t, sampler_t, float4, float); +#endif // cl_khr_3d_image_writes + +float4 __ovld __purefn read_imagef(read_write image1d_t, sampler_t, float, float, float); +int4 __ovld __purefn read_imagei(read_write image1d_t, sampler_t, float, float, float); +uint4 __ovld __purefn read_imageui(read_write image1d_t, sampler_t, float, float, float); + +float4 __ovld __purefn read_imagef(read_write image1d_array_t, sampler_t, float2, float, float); +int4 __ovld __purefn read_imagei(read_write image1d_array_t, sampler_t, float2, float, float); +uint4 __ovld __purefn read_imageui(read_write image1d_array_t, sampler_t, float2, float, float); + +float4 __ovld __purefn read_imagef(read_write image2d_t, sampler_t, float2, float2, float2); +int4 __ovld __purefn read_imagei(read_write image2d_t, sampler_t, float2, float2, float2); +uint4 __ovld __purefn read_imageui(read_write image2d_t, sampler_t, float2, float2, float2); + +float __ovld __purefn read_imagef(read_write image2d_depth_t, sampler_t, float2, float2, float2); + +float4 __ovld __purefn read_imagef(read_write image2d_array_t, sampler_t, float4, float2, float2); +int4 __ovld __purefn read_imagei(read_write image2d_array_t, sampler_t, float4, float2, float2); +uint4 __ovld __purefn read_imageui(read_write image2d_array_t, sampler_t, float4, float2, float2); + +float __ovld __purefn read_imagef(read_write image2d_array_depth_t, sampler_t, float4, float2, float2); + +#ifdef cl_khr_3d_image_writes +float4 __ovld __purefn read_imagef(read_write image3d_t, sampler_t, float4, float4, float4); +int4 __ovld __purefn read_imagei(read_write image3d_t, sampler_t, float4, float4, float4); +uint4 __ovld __purefn read_imageui(read_write image3d_t, sampler_t, float4, float4, float4); +#endif // cl_khr_3d_image_writes + +#endif //cl_khr_mipmap_image + +// Image read functions returning half4 type +#ifdef cl_khr_fp16 +half4 __ovld __purefn read_imageh(read_write image1d_t, int); +half4 __ovld __purefn read_imageh(read_write image2d_t, int2); +#ifdef cl_khr_3d_image_writes +half4 __ovld __purefn read_imageh(read_write image3d_t, int4); +#endif // cl_khr_3d_image_writes +half4 __ovld __purefn read_imageh(read_write image1d_array_t, int2); +half4 __ovld __purefn read_imageh(read_write image2d_array_t, int4); +half4 __ovld __purefn read_imageh(read_write image1d_buffer_t, int); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_read_write_images) + +/** + * Write color value to location specified by coordinate + * (coord.x, coord.y) in the 2D image object specified by image. + * (coord.x, coord.y) are considered to be unnormalized coordinates + * and must be in the range 0 ... image width - 1, and 0 + * ... image height - 1. + + * Write color value to location specified by coordinate + * (coord.x, coord.y) in the 2D image object specified by index + * (coord.z) of the 2D image array object image_array. + * (coord.x, coord.y) are considered to be unnormalized + * coordinates and must be in the range 0 ... image width + * - 1. + * + * Write color value to location specified by coordinate + * (coord) in the 1D image (buffer) object specified by image. + * coord is considered to be unnormalized coordinates + * and must be in the range 0 ... image width - 1. + * + * Write color value to location specified by coordinate + * (coord.x) in the 1D image object specified by index + * (coord.y) of the 1D image array object image_array. + * x is considered to be unnormalized coordinates + * and must be in the range 0 ... image width - 1. + * + * Write color value to location specified by coordinate + * (coord.x, coord.y, coord.z) in the 3D image object specified by image. + * coord.x & coord.y are considered to be unnormalized coordinates + * and must be in the range 0 ... image width - 1, and 0 + * ... image height - 1. + * + * For mipmap images, use mip-level specified by lod. + * + * Appropriate data format conversion to the specified + * image format is done before writing the color value. + * + * write_imagef can only be used with image objects + * created with image_channel_data_type set to one of + * the pre-defined packed formats or set to + * CL_SNORM_INT8, CL_UNORM_INT8, + * CL_SNORM_INT16, CL_UNORM_INT16, + * CL_HALF_FLOAT or CL_FLOAT. Appropriate data + * format conversion will be done to convert channel + * data from a floating-point value to actual data format + * in which the channels are stored. + * + * write_imagei can only be used with image objects + * created with image_channel_data_type set to one of + * the following values: + * CL_SIGNED_INT8, + * CL_SIGNED_INT16 and + * CL_SIGNED_INT32. + * + * write_imageui can only be used with image objects + * created with image_channel_data_type set to one of + * the following values: + * CL_UNSIGNED_INT8, + * CL_UNSIGNED_INT16 and + * CL_UNSIGNED_INT32. + * + * The behavior of write_imagef, write_imagei and + * write_imageui for image objects created with + * image_channel_data_type values not specified in + * the description above or with (x, y) coordinate + * values that are not in the range (0 ... image width -1, + * 0 ... image height - 1), respectively, is undefined. + */ +void __ovld write_imagef(write_only image2d_t, int2, float4); +void __ovld write_imagei(write_only image2d_t, int2, int4); +void __ovld write_imageui(write_only image2d_t, int2, uint4); + +void __ovld write_imagef(write_only image2d_array_t, int4, float4); +void __ovld write_imagei(write_only image2d_array_t, int4, int4); +void __ovld write_imageui(write_only image2d_array_t, int4, uint4); + +void __ovld write_imagef(write_only image1d_t, int, float4); +void __ovld write_imagei(write_only image1d_t, int, int4); +void __ovld write_imageui(write_only image1d_t, int, uint4); + +void __ovld write_imagef(write_only image1d_buffer_t, int, float4); +void __ovld write_imagei(write_only image1d_buffer_t, int, int4); +void __ovld write_imageui(write_only image1d_buffer_t, int, uint4); + +void __ovld write_imagef(write_only image1d_array_t, int2, float4); +void __ovld write_imagei(write_only image1d_array_t, int2, int4); +void __ovld write_imageui(write_only image1d_array_t, int2, uint4); + +#ifdef cl_khr_3d_image_writes +void __ovld write_imagef(write_only image3d_t, int4, float4); +void __ovld write_imagei(write_only image3d_t, int4, int4); +void __ovld write_imageui(write_only image3d_t, int4, uint4); +#endif + +#ifdef cl_khr_depth_images +void __ovld write_imagef(write_only image2d_depth_t, int2, float); +void __ovld write_imagef(write_only image2d_array_depth_t, int4, float); +#endif //cl_khr_depth_images + +// OpenCL Extension v2.0 s9.18 - Mipmaps +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +#if defined(cl_khr_mipmap_image_writes) +void __ovld write_imagef(write_only image1d_t, int, int, float4); +void __ovld write_imagei(write_only image1d_t, int, int, int4); +void __ovld write_imageui(write_only image1d_t, int, int, uint4); + +void __ovld write_imagef(write_only image1d_array_t, int2, int, float4); +void __ovld write_imagei(write_only image1d_array_t, int2, int, int4); +void __ovld write_imageui(write_only image1d_array_t, int2, int, uint4); + +void __ovld write_imagef(write_only image2d_t, int2, int, float4); +void __ovld write_imagei(write_only image2d_t, int2, int, int4); +void __ovld write_imageui(write_only image2d_t, int2, int, uint4); + +void __ovld write_imagef(write_only image2d_array_t, int4, int, float4); +void __ovld write_imagei(write_only image2d_array_t, int4, int, int4); +void __ovld write_imageui(write_only image2d_array_t, int4, int, uint4); + +void __ovld write_imagef(write_only image2d_depth_t, int2, int, float); +void __ovld write_imagef(write_only image2d_array_depth_t, int4, int, float); + +#ifdef cl_khr_3d_image_writes +void __ovld write_imagef(write_only image3d_t, int4, int, float4); +void __ovld write_imagei(write_only image3d_t, int4, int, int4); +void __ovld write_imageui(write_only image3d_t, int4, int, uint4); +#endif //cl_khr_3d_image_writes + +#endif //defined(cl_khr_mipmap_image_writes) +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// Image write functions for half4 type +#ifdef cl_khr_fp16 +void __ovld write_imageh(write_only image1d_t, int, half4); +void __ovld write_imageh(write_only image2d_t, int2, half4); +#ifdef cl_khr_3d_image_writes +void __ovld write_imageh(write_only image3d_t, int4, half4); +#endif +void __ovld write_imageh(write_only image1d_array_t, int2, half4); +void __ovld write_imageh(write_only image2d_array_t, int4, half4); +void __ovld write_imageh(write_only image1d_buffer_t, int, half4); +#endif //cl_khr_fp16 + +// Image write functions for read_write images +#if defined(__opencl_c_read_write_images) +void __ovld write_imagef(read_write image2d_t, int2, float4); +void __ovld write_imagei(read_write image2d_t, int2, int4); +void __ovld write_imageui(read_write image2d_t, int2, uint4); + +void __ovld write_imagef(read_write image2d_array_t, int4, float4); +void __ovld write_imagei(read_write image2d_array_t, int4, int4); +void __ovld write_imageui(read_write image2d_array_t, int4, uint4); + +void __ovld write_imagef(read_write image1d_t, int, float4); +void __ovld write_imagei(read_write image1d_t, int, int4); +void __ovld write_imageui(read_write image1d_t, int, uint4); + +void __ovld write_imagef(read_write image1d_buffer_t, int, float4); +void __ovld write_imagei(read_write image1d_buffer_t, int, int4); +void __ovld write_imageui(read_write image1d_buffer_t, int, uint4); + +void __ovld write_imagef(read_write image1d_array_t, int2, float4); +void __ovld write_imagei(read_write image1d_array_t, int2, int4); +void __ovld write_imageui(read_write image1d_array_t, int2, uint4); + +#ifdef cl_khr_3d_image_writes +void __ovld write_imagef(read_write image3d_t, int4, float4); +void __ovld write_imagei(read_write image3d_t, int4, int4); +void __ovld write_imageui(read_write image3d_t, int4, uint4); +#endif + +#ifdef cl_khr_depth_images +void __ovld write_imagef(read_write image2d_depth_t, int2, float); +void __ovld write_imagef(read_write image2d_array_depth_t, int4, float); +#endif //cl_khr_depth_images + +#if defined(cl_khr_mipmap_image_writes) +void __ovld write_imagef(read_write image1d_t, int, int, float4); +void __ovld write_imagei(read_write image1d_t, int, int, int4); +void __ovld write_imageui(read_write image1d_t, int, int, uint4); + +void __ovld write_imagef(read_write image1d_array_t, int2, int, float4); +void __ovld write_imagei(read_write image1d_array_t, int2, int, int4); +void __ovld write_imageui(read_write image1d_array_t, int2, int, uint4); + +void __ovld write_imagef(read_write image2d_t, int2, int, float4); +void __ovld write_imagei(read_write image2d_t, int2, int, int4); +void __ovld write_imageui(read_write image2d_t, int2, int, uint4); + +void __ovld write_imagef(read_write image2d_array_t, int4, int, float4); +void __ovld write_imagei(read_write image2d_array_t, int4, int, int4); +void __ovld write_imageui(read_write image2d_array_t, int4, int, uint4); + +void __ovld write_imagef(read_write image2d_depth_t, int2, int, float); +void __ovld write_imagef(read_write image2d_array_depth_t, int4, int, float); + +#ifdef cl_khr_3d_image_writes +void __ovld write_imagef(read_write image3d_t, int4, int, float4); +void __ovld write_imagei(read_write image3d_t, int4, int, int4); +void __ovld write_imageui(read_write image3d_t, int4, int, uint4); +#endif //cl_khr_3d_image_writes + +#endif //cl_khr_mipmap_image_writes + +// Image write functions for half4 type +#ifdef cl_khr_fp16 +void __ovld write_imageh(read_write image1d_t, int, half4); +void __ovld write_imageh(read_write image2d_t, int2, half4); +#ifdef cl_khr_3d_image_writes +void __ovld write_imageh(read_write image3d_t, int4, half4); +#endif +void __ovld write_imageh(read_write image1d_array_t, int2, half4); +void __ovld write_imageh(read_write image2d_array_t, int4, half4); +void __ovld write_imageh(read_write image1d_buffer_t, int, half4); +#endif //cl_khr_fp16 +#endif //defined(__opencl_c_read_write_images) + +// Note: In OpenCL v1.0/1.1/1.2, image argument of image query builtin functions does not have +// access qualifier, which by default assume read_only access qualifier. Image query builtin +// functions with write_only image argument should also be declared. + +/** + * Return the image width in pixels. + * + */ +int __ovld __cnfn get_image_width(read_only image1d_t); +int __ovld __cnfn get_image_width(read_only image1d_buffer_t); +int __ovld __cnfn get_image_width(read_only image2d_t); +int __ovld __cnfn get_image_width(read_only image3d_t); +int __ovld __cnfn get_image_width(read_only image1d_array_t); +int __ovld __cnfn get_image_width(read_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_width(read_only image2d_depth_t); +int __ovld __cnfn get_image_width(read_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_width(read_only image2d_msaa_t); +int __ovld __cnfn get_image_width(read_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_width(read_only image2d_array_msaa_t); +int __ovld __cnfn get_image_width(read_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +int __ovld __cnfn get_image_width(write_only image1d_t); +int __ovld __cnfn get_image_width(write_only image1d_buffer_t); +int __ovld __cnfn get_image_width(write_only image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_width(write_only image3d_t); +#endif +int __ovld __cnfn get_image_width(write_only image1d_array_t); +int __ovld __cnfn get_image_width(write_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_width(write_only image2d_depth_t); +int __ovld __cnfn get_image_width(write_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_width(write_only image2d_msaa_t); +int __ovld __cnfn get_image_width(write_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_width(write_only image2d_array_msaa_t); +int __ovld __cnfn get_image_width(write_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +#if defined(__opencl_c_read_write_images) +int __ovld __cnfn get_image_width(read_write image1d_t); +int __ovld __cnfn get_image_width(read_write image1d_buffer_t); +int __ovld __cnfn get_image_width(read_write image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_width(read_write image3d_t); +#endif // cl_khr_3d_image_writes +int __ovld __cnfn get_image_width(read_write image1d_array_t); +int __ovld __cnfn get_image_width(read_write image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_width(read_write image2d_depth_t); +int __ovld __cnfn get_image_width(read_write image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_width(read_write image2d_msaa_t); +int __ovld __cnfn get_image_width(read_write image2d_msaa_depth_t); +int __ovld __cnfn get_image_width(read_write image2d_array_msaa_t); +int __ovld __cnfn get_image_width(read_write image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing +#endif //defined(__opencl_c_read_write_images) + +/** + * Return the image height in pixels. + */ +int __ovld __cnfn get_image_height(read_only image2d_t); +int __ovld __cnfn get_image_height(read_only image3d_t); +int __ovld __cnfn get_image_height(read_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_height(read_only image2d_depth_t); +int __ovld __cnfn get_image_height(read_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_height(read_only image2d_msaa_t); +int __ovld __cnfn get_image_height(read_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_height(read_only image2d_array_msaa_t); +int __ovld __cnfn get_image_height(read_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +int __ovld __cnfn get_image_height(write_only image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_height(write_only image3d_t); +#endif +int __ovld __cnfn get_image_height(write_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_height(write_only image2d_depth_t); +int __ovld __cnfn get_image_height(write_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_height(write_only image2d_msaa_t); +int __ovld __cnfn get_image_height(write_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_height(write_only image2d_array_msaa_t); +int __ovld __cnfn get_image_height(write_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +#if defined(__opencl_c_read_write_images) +int __ovld __cnfn get_image_height(read_write image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_height(read_write image3d_t); +#endif // cl_khr_3d_image_writes +int __ovld __cnfn get_image_height(read_write image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_height(read_write image2d_depth_t); +int __ovld __cnfn get_image_height(read_write image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_height(read_write image2d_msaa_t); +int __ovld __cnfn get_image_height(read_write image2d_msaa_depth_t); +int __ovld __cnfn get_image_height(read_write image2d_array_msaa_t); +int __ovld __cnfn get_image_height(read_write image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing +#endif //defined(__opencl_c_read_write_images) + +/** + * Return the image depth in pixels. + */ +int __ovld __cnfn get_image_depth(read_only image3d_t); + +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_depth(write_only image3d_t); + +#if defined(__opencl_c_read_write_images) +int __ovld __cnfn get_image_depth(read_write image3d_t); +#endif //defined(__opencl_c_read_write_images) +#endif // cl_khr_3d_image_writes + +// OpenCL Extension v2.0 s9.18 - Mipmaps +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +#ifdef cl_khr_mipmap_image +/** + * Return the image miplevels. + */ + +int __ovld get_image_num_mip_levels(read_only image1d_t); +int __ovld get_image_num_mip_levels(read_only image2d_t); +int __ovld get_image_num_mip_levels(read_only image3d_t); + +int __ovld get_image_num_mip_levels(write_only image1d_t); +int __ovld get_image_num_mip_levels(write_only image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld get_image_num_mip_levels(write_only image3d_t); +#endif + +#if defined(__opencl_c_read_write_images) +int __ovld get_image_num_mip_levels(read_write image1d_t); +int __ovld get_image_num_mip_levels(read_write image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld get_image_num_mip_levels(read_write image3d_t); +#endif // cl_khr_3d_image_writes +#endif //defined(__opencl_c_read_write_images) + +int __ovld get_image_num_mip_levels(read_only image1d_array_t); +int __ovld get_image_num_mip_levels(read_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld get_image_num_mip_levels(read_only image2d_array_depth_t); +int __ovld get_image_num_mip_levels(read_only image2d_depth_t); +#endif // cl_khr_depth_images + +int __ovld get_image_num_mip_levels(write_only image1d_array_t); +int __ovld get_image_num_mip_levels(write_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t); +int __ovld get_image_num_mip_levels(write_only image2d_depth_t); +#endif // cl_khr_depth_images + +#if defined(__opencl_c_read_write_images) +int __ovld get_image_num_mip_levels(read_write image1d_array_t); +int __ovld get_image_num_mip_levels(read_write image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld get_image_num_mip_levels(read_write image2d_array_depth_t); +int __ovld get_image_num_mip_levels(read_write image2d_depth_t); +#endif // cl_khr_depth_images +#endif //defined(__opencl_c_read_write_images) + +#endif //cl_khr_mipmap_image +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +/** + * Return the channel data type. Valid values are: + * CLK_SNORM_INT8 + * CLK_SNORM_INT16 + * CLK_UNORM_INT8 + * CLK_UNORM_INT16 + * CLK_UNORM_SHORT_565 + * CLK_UNORM_SHORT_555 + * CLK_UNORM_SHORT_101010 + * CLK_SIGNED_INT8 + * CLK_SIGNED_INT16 + * CLK_SIGNED_INT32 + * CLK_UNSIGNED_INT8 + * CLK_UNSIGNED_INT16 + * CLK_UNSIGNED_INT32 + * CLK_HALF_FLOAT + * CLK_FLOAT + */ + +int __ovld __cnfn get_image_channel_data_type(read_only image1d_t); +int __ovld __cnfn get_image_channel_data_type(read_only image1d_buffer_t); +int __ovld __cnfn get_image_channel_data_type(read_only image2d_t); +int __ovld __cnfn get_image_channel_data_type(read_only image3d_t); +int __ovld __cnfn get_image_channel_data_type(read_only image1d_array_t); +int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_channel_data_type(read_only image2d_depth_t); +int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_channel_data_type(read_only image2d_msaa_t); +int __ovld __cnfn get_image_channel_data_type(read_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_msaa_t); +int __ovld __cnfn get_image_channel_data_type(read_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +int __ovld __cnfn get_image_channel_data_type(write_only image1d_t); +int __ovld __cnfn get_image_channel_data_type(write_only image1d_buffer_t); +int __ovld __cnfn get_image_channel_data_type(write_only image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_channel_data_type(write_only image3d_t); +#endif +int __ovld __cnfn get_image_channel_data_type(write_only image1d_array_t); +int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_channel_data_type(write_only image2d_depth_t); +int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_channel_data_type(write_only image2d_msaa_t); +int __ovld __cnfn get_image_channel_data_type(write_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_msaa_t); +int __ovld __cnfn get_image_channel_data_type(write_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +#if defined(__opencl_c_read_write_images) +int __ovld __cnfn get_image_channel_data_type(read_write image1d_t); +int __ovld __cnfn get_image_channel_data_type(read_write image1d_buffer_t); +int __ovld __cnfn get_image_channel_data_type(read_write image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_channel_data_type(read_write image3d_t); +#endif // cl_khr_3d_image_writes +int __ovld __cnfn get_image_channel_data_type(read_write image1d_array_t); +int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_channel_data_type(read_write image2d_depth_t); +int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_channel_data_type(read_write image2d_msaa_t); +int __ovld __cnfn get_image_channel_data_type(read_write image2d_msaa_depth_t); +int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_msaa_t); +int __ovld __cnfn get_image_channel_data_type(read_write image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing +#endif //defined(__opencl_c_read_write_images) + +/** + * Return the image channel order. Valid values are: + * CLK_A + * CLK_R + * CLK_Rx + * CLK_RG + * CLK_RGx + * CLK_RA + * CLK_RGB + * CLK_RGBx + * CLK_RGBA + * CLK_ARGB + * CLK_BGRA + * CLK_INTENSITY + * CLK_LUMINANCE + */ + +int __ovld __cnfn get_image_channel_order(read_only image1d_t); +int __ovld __cnfn get_image_channel_order(read_only image1d_buffer_t); +int __ovld __cnfn get_image_channel_order(read_only image2d_t); +int __ovld __cnfn get_image_channel_order(read_only image3d_t); +int __ovld __cnfn get_image_channel_order(read_only image1d_array_t); +int __ovld __cnfn get_image_channel_order(read_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_channel_order(read_only image2d_depth_t); +int __ovld __cnfn get_image_channel_order(read_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_channel_order(read_only image2d_msaa_t); +int __ovld __cnfn get_image_channel_order(read_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_channel_order(read_only image2d_array_msaa_t); +int __ovld __cnfn get_image_channel_order(read_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +int __ovld __cnfn get_image_channel_order(write_only image1d_t); +int __ovld __cnfn get_image_channel_order(write_only image1d_buffer_t); +int __ovld __cnfn get_image_channel_order(write_only image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_channel_order(write_only image3d_t); +#endif +int __ovld __cnfn get_image_channel_order(write_only image1d_array_t); +int __ovld __cnfn get_image_channel_order(write_only image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_channel_order(write_only image2d_depth_t); +int __ovld __cnfn get_image_channel_order(write_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_channel_order(write_only image2d_msaa_t); +int __ovld __cnfn get_image_channel_order(write_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_channel_order(write_only image2d_array_msaa_t); +int __ovld __cnfn get_image_channel_order(write_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +#if defined(__opencl_c_read_write_images) +int __ovld __cnfn get_image_channel_order(read_write image1d_t); +int __ovld __cnfn get_image_channel_order(read_write image1d_buffer_t); +int __ovld __cnfn get_image_channel_order(read_write image2d_t); +#ifdef cl_khr_3d_image_writes +int __ovld __cnfn get_image_channel_order(read_write image3d_t); +#endif // cl_khr_3d_image_writes +int __ovld __cnfn get_image_channel_order(read_write image1d_array_t); +int __ovld __cnfn get_image_channel_order(read_write image2d_array_t); +#ifdef cl_khr_depth_images +int __ovld __cnfn get_image_channel_order(read_write image2d_depth_t); +int __ovld __cnfn get_image_channel_order(read_write image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_channel_order(read_write image2d_msaa_t); +int __ovld __cnfn get_image_channel_order(read_write image2d_msaa_depth_t); +int __ovld __cnfn get_image_channel_order(read_write image2d_array_msaa_t); +int __ovld __cnfn get_image_channel_order(read_write image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing +#endif //defined(__opencl_c_read_write_images) + +/** + * Return the 2D image width and height as an int2 + * type. The width is returned in the x component, and + * the height in the y component. + */ +int2 __ovld __cnfn get_image_dim(read_only image2d_t); +int2 __ovld __cnfn get_image_dim(read_only image2d_array_t); +#ifdef cl_khr_depth_images +int2 __ovld __cnfn get_image_dim(read_only image2d_array_depth_t); +int2 __ovld __cnfn get_image_dim(read_only image2d_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int2 __ovld __cnfn get_image_dim(read_only image2d_msaa_t); +int2 __ovld __cnfn get_image_dim(read_only image2d_msaa_depth_t); +int2 __ovld __cnfn get_image_dim(read_only image2d_array_msaa_t); +int2 __ovld __cnfn get_image_dim(read_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +int2 __ovld __cnfn get_image_dim(write_only image2d_t); +int2 __ovld __cnfn get_image_dim(write_only image2d_array_t); +#ifdef cl_khr_depth_images +int2 __ovld __cnfn get_image_dim(write_only image2d_array_depth_t); +int2 __ovld __cnfn get_image_dim(write_only image2d_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int2 __ovld __cnfn get_image_dim(write_only image2d_msaa_t); +int2 __ovld __cnfn get_image_dim(write_only image2d_msaa_depth_t); +int2 __ovld __cnfn get_image_dim(write_only image2d_array_msaa_t); +int2 __ovld __cnfn get_image_dim(write_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +#if defined(__opencl_c_read_write_images) +int2 __ovld __cnfn get_image_dim(read_write image2d_t); +int2 __ovld __cnfn get_image_dim(read_write image2d_array_t); +#ifdef cl_khr_depth_images +int2 __ovld __cnfn get_image_dim(read_write image2d_array_depth_t); +int2 __ovld __cnfn get_image_dim(read_write image2d_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +int2 __ovld __cnfn get_image_dim(read_write image2d_msaa_t); +int2 __ovld __cnfn get_image_dim(read_write image2d_msaa_depth_t); +int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_t); +int2 __ovld __cnfn get_image_dim(read_write image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing +#endif //defined(__opencl_c_read_write_images) + +/** + * Return the 3D image width, height, and depth as an + * int4 type. The width is returned in the x + * component, height in the y component, depth in the z + * component and the w component is 0. + */ +int4 __ovld __cnfn get_image_dim(read_only image3d_t); +#ifdef cl_khr_3d_image_writes +int4 __ovld __cnfn get_image_dim(write_only image3d_t); +#if defined(__opencl_c_read_write_images) +int4 __ovld __cnfn get_image_dim(read_write image3d_t); +#endif //defined(__opencl_c_read_write_images) +#endif // cl_khr_3d_image_writes + +/** + * Return the image array size. + */ + +size_t __ovld __cnfn get_image_array_size(read_only image1d_array_t); +size_t __ovld __cnfn get_image_array_size(read_only image2d_array_t); +#ifdef cl_khr_depth_images +size_t __ovld __cnfn get_image_array_size(read_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +size_t __ovld __cnfn get_image_array_size(read_only image2d_array_msaa_t); +size_t __ovld __cnfn get_image_array_size(read_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +size_t __ovld __cnfn get_image_array_size(write_only image1d_array_t); +size_t __ovld __cnfn get_image_array_size(write_only image2d_array_t); +#ifdef cl_khr_depth_images +size_t __ovld __cnfn get_image_array_size(write_only image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +size_t __ovld __cnfn get_image_array_size(write_only image2d_array_msaa_t); +size_t __ovld __cnfn get_image_array_size(write_only image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing + +#if defined(__opencl_c_read_write_images) +size_t __ovld __cnfn get_image_array_size(read_write image1d_array_t); +size_t __ovld __cnfn get_image_array_size(read_write image2d_array_t); +#ifdef cl_khr_depth_images +size_t __ovld __cnfn get_image_array_size(read_write image2d_array_depth_t); +#endif //cl_khr_depth_images +#if defined(cl_khr_gl_msaa_sharing) +size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_t); +size_t __ovld __cnfn get_image_array_size(read_write image2d_array_msaa_depth_t); +#endif //cl_khr_gl_msaa_sharing +#endif //defined(__opencl_c_read_write_images) + +/** +* Return the number of samples associated with image +*/ +#if defined(cl_khr_gl_msaa_sharing) +int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_t); +int __ovld __cnfn get_image_num_samples(read_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_t); +int __ovld __cnfn get_image_num_samples(read_only image2d_array_msaa_depth_t); + +int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_t); +int __ovld __cnfn get_image_num_samples(write_only image2d_msaa_depth_t); +int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_t); +int __ovld __cnfn get_image_num_samples(write_only image2d_array_msaa_depth_t); + +#if defined(__opencl_c_read_write_images) +int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_t); +int __ovld __cnfn get_image_num_samples(read_write image2d_msaa_depth_t); +int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_t); +int __ovld __cnfn get_image_num_samples(read_write image2d_array_msaa_depth_t); +#endif //defined(__opencl_c_read_write_images) +#endif + +#endif // (defined(__opencl_c_images) || defined(__IMAGE_SUPPORT__)) + +// OpenCL v2.0 s6.13.15 - Work-group Functions + +#if defined(__opencl_c_work_group_collective_functions) +int __ovld __conv work_group_all(int predicate); +int __ovld __conv work_group_any(int predicate); + +#ifdef cl_khr_fp16 +half __ovld __conv work_group_broadcast(half, size_t local_id); +half __ovld __conv work_group_broadcast(half, size_t, size_t); +half __ovld __conv work_group_broadcast(half, size_t, size_t, size_t); +#endif +int __ovld __conv work_group_broadcast(int, size_t local_id); +int __ovld __conv work_group_broadcast(int, size_t, size_t); +int __ovld __conv work_group_broadcast(int, size_t, size_t, size_t); +uint __ovld __conv work_group_broadcast(uint, size_t local_id); +uint __ovld __conv work_group_broadcast(uint, size_t, size_t); +uint __ovld __conv work_group_broadcast(uint, size_t, size_t, size_t); +long __ovld __conv work_group_broadcast(long, size_t local_id); +long __ovld __conv work_group_broadcast(long, size_t, size_t); +long __ovld __conv work_group_broadcast(long, size_t, size_t, size_t); +ulong __ovld __conv work_group_broadcast(ulong, size_t local_id); +ulong __ovld __conv work_group_broadcast(ulong, size_t, size_t); +ulong __ovld __conv work_group_broadcast(ulong, size_t, size_t, size_t); +float __ovld __conv work_group_broadcast(float, size_t local_id); +float __ovld __conv work_group_broadcast(float, size_t, size_t); +float __ovld __conv work_group_broadcast(float, size_t, size_t, size_t); +#ifdef cl_khr_fp64 +double __ovld __conv work_group_broadcast(double, size_t local_id); +double __ovld __conv work_group_broadcast(double, size_t, size_t); +double __ovld __conv work_group_broadcast(double, size_t, size_t, size_t); +#endif //cl_khr_fp64 + +#ifdef cl_khr_fp16 +half __ovld __conv work_group_reduce_add(half); +half __ovld __conv work_group_reduce_min(half); +half __ovld __conv work_group_reduce_max(half); +half __ovld __conv work_group_scan_exclusive_add(half); +half __ovld __conv work_group_scan_exclusive_min(half); +half __ovld __conv work_group_scan_exclusive_max(half); +half __ovld __conv work_group_scan_inclusive_add(half); +half __ovld __conv work_group_scan_inclusive_min(half); +half __ovld __conv work_group_scan_inclusive_max(half); +#endif +int __ovld __conv work_group_reduce_add(int); +int __ovld __conv work_group_reduce_min(int); +int __ovld __conv work_group_reduce_max(int); +int __ovld __conv work_group_scan_exclusive_add(int); +int __ovld __conv work_group_scan_exclusive_min(int); +int __ovld __conv work_group_scan_exclusive_max(int); +int __ovld __conv work_group_scan_inclusive_add(int); +int __ovld __conv work_group_scan_inclusive_min(int); +int __ovld __conv work_group_scan_inclusive_max(int); +uint __ovld __conv work_group_reduce_add(uint); +uint __ovld __conv work_group_reduce_min(uint); +uint __ovld __conv work_group_reduce_max(uint); +uint __ovld __conv work_group_scan_exclusive_add(uint); +uint __ovld __conv work_group_scan_exclusive_min(uint); +uint __ovld __conv work_group_scan_exclusive_max(uint); +uint __ovld __conv work_group_scan_inclusive_add(uint); +uint __ovld __conv work_group_scan_inclusive_min(uint); +uint __ovld __conv work_group_scan_inclusive_max(uint); +long __ovld __conv work_group_reduce_add(long); +long __ovld __conv work_group_reduce_min(long); +long __ovld __conv work_group_reduce_max(long); +long __ovld __conv work_group_scan_exclusive_add(long); +long __ovld __conv work_group_scan_exclusive_min(long); +long __ovld __conv work_group_scan_exclusive_max(long); +long __ovld __conv work_group_scan_inclusive_add(long); +long __ovld __conv work_group_scan_inclusive_min(long); +long __ovld __conv work_group_scan_inclusive_max(long); +ulong __ovld __conv work_group_reduce_add(ulong); +ulong __ovld __conv work_group_reduce_min(ulong); +ulong __ovld __conv work_group_reduce_max(ulong); +ulong __ovld __conv work_group_scan_exclusive_add(ulong); +ulong __ovld __conv work_group_scan_exclusive_min(ulong); +ulong __ovld __conv work_group_scan_exclusive_max(ulong); +ulong __ovld __conv work_group_scan_inclusive_add(ulong); +ulong __ovld __conv work_group_scan_inclusive_min(ulong); +ulong __ovld __conv work_group_scan_inclusive_max(ulong); +float __ovld __conv work_group_reduce_add(float); +float __ovld __conv work_group_reduce_min(float); +float __ovld __conv work_group_reduce_max(float); +float __ovld __conv work_group_scan_exclusive_add(float); +float __ovld __conv work_group_scan_exclusive_min(float); +float __ovld __conv work_group_scan_exclusive_max(float); +float __ovld __conv work_group_scan_inclusive_add(float); +float __ovld __conv work_group_scan_inclusive_min(float); +float __ovld __conv work_group_scan_inclusive_max(float); +#ifdef cl_khr_fp64 +double __ovld __conv work_group_reduce_add(double); +double __ovld __conv work_group_reduce_min(double); +double __ovld __conv work_group_reduce_max(double); +double __ovld __conv work_group_scan_exclusive_add(double); +double __ovld __conv work_group_scan_exclusive_min(double); +double __ovld __conv work_group_scan_exclusive_max(double); +double __ovld __conv work_group_scan_inclusive_add(double); +double __ovld __conv work_group_scan_inclusive_min(double); +double __ovld __conv work_group_scan_inclusive_max(double); +#endif //cl_khr_fp64 + +#endif //defined(__opencl_c_work_group_collective_functions) + +// OpenCL v2.0 s6.13.16 - Pipe Functions +#if defined(__opencl_c_pipes) +bool __ovld is_valid_reserve_id(reserve_id_t reserve_id); +#endif //defined(__opencl_c_pipes) + + +// OpenCL v2.0 s6.13.17 - Enqueue Kernels +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +#ifdef __opencl_c_device_enqueue +ndrange_t __ovld ndrange_1D(size_t); +ndrange_t __ovld ndrange_1D(size_t, size_t); +ndrange_t __ovld ndrange_1D(size_t, size_t, size_t); + +ndrange_t __ovld ndrange_2D(const size_t[2]); +ndrange_t __ovld ndrange_2D(const size_t[2], const size_t[2]); +ndrange_t __ovld ndrange_2D(const size_t[2], const size_t[2], const size_t[2]); + +ndrange_t __ovld ndrange_3D(const size_t[3]); +ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3]); +ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3], const size_t[3]); + +int __ovld enqueue_marker(queue_t, uint, const clk_event_t*, clk_event_t*); + +void __ovld retain_event(clk_event_t); + +void __ovld release_event(clk_event_t); + +clk_event_t __ovld create_user_event(void); + +void __ovld set_user_event_status(clk_event_t e, int state); + +bool __ovld is_valid_event (clk_event_t event); + +void __ovld capture_event_profiling_info(clk_event_t, clk_profiling_info, __global void*); + +queue_t __ovld get_default_queue(void); +#endif //__opencl_c_device_enqueue +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +// OpenCL Extension v2.0 s9.17 - Sub-groups + +#if defined(__opencl_subgroup_builtins) +// Shared Sub Group Functions +uint __ovld get_sub_group_size(void); +uint __ovld get_max_sub_group_size(void); +uint __ovld get_num_sub_groups(void); +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +uint __ovld get_enqueued_num_sub_groups(void); +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +uint __ovld get_sub_group_id(void); +uint __ovld get_sub_group_local_id(void); + +void __ovld __conv sub_group_barrier(cl_mem_fence_flags); +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) +void __ovld __conv sub_group_barrier(cl_mem_fence_flags, memory_scope); +#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) + +int __ovld __conv sub_group_all(int predicate); +int __ovld __conv sub_group_any(int predicate); + +int __ovld __conv sub_group_broadcast(int , uint sub_group_local_id); +uint __ovld __conv sub_group_broadcast(uint , uint sub_group_local_id); +long __ovld __conv sub_group_broadcast(long , uint sub_group_local_id); +ulong __ovld __conv sub_group_broadcast(ulong, uint sub_group_local_id); +float __ovld __conv sub_group_broadcast(float, uint sub_group_local_id); + +int __ovld __conv sub_group_reduce_add(int ); +uint __ovld __conv sub_group_reduce_add(uint ); +long __ovld __conv sub_group_reduce_add(long ); +ulong __ovld __conv sub_group_reduce_add(ulong); +float __ovld __conv sub_group_reduce_add(float); +int __ovld __conv sub_group_reduce_min(int ); +uint __ovld __conv sub_group_reduce_min(uint ); +long __ovld __conv sub_group_reduce_min(long ); +ulong __ovld __conv sub_group_reduce_min(ulong); +float __ovld __conv sub_group_reduce_min(float); +int __ovld __conv sub_group_reduce_max(int ); +uint __ovld __conv sub_group_reduce_max(uint ); +long __ovld __conv sub_group_reduce_max(long ); +ulong __ovld __conv sub_group_reduce_max(ulong); +float __ovld __conv sub_group_reduce_max(float); + +int __ovld __conv sub_group_scan_exclusive_add(int ); +uint __ovld __conv sub_group_scan_exclusive_add(uint ); +long __ovld __conv sub_group_scan_exclusive_add(long ); +ulong __ovld __conv sub_group_scan_exclusive_add(ulong); +float __ovld __conv sub_group_scan_exclusive_add(float); +int __ovld __conv sub_group_scan_exclusive_min(int ); +uint __ovld __conv sub_group_scan_exclusive_min(uint ); +long __ovld __conv sub_group_scan_exclusive_min(long ); +ulong __ovld __conv sub_group_scan_exclusive_min(ulong); +float __ovld __conv sub_group_scan_exclusive_min(float); +int __ovld __conv sub_group_scan_exclusive_max(int ); +uint __ovld __conv sub_group_scan_exclusive_max(uint ); +long __ovld __conv sub_group_scan_exclusive_max(long ); +ulong __ovld __conv sub_group_scan_exclusive_max(ulong); +float __ovld __conv sub_group_scan_exclusive_max(float); + +int __ovld __conv sub_group_scan_inclusive_add(int ); +uint __ovld __conv sub_group_scan_inclusive_add(uint ); +long __ovld __conv sub_group_scan_inclusive_add(long ); +ulong __ovld __conv sub_group_scan_inclusive_add(ulong); +float __ovld __conv sub_group_scan_inclusive_add(float); +int __ovld __conv sub_group_scan_inclusive_min(int ); +uint __ovld __conv sub_group_scan_inclusive_min(uint ); +long __ovld __conv sub_group_scan_inclusive_min(long ); +ulong __ovld __conv sub_group_scan_inclusive_min(ulong); +float __ovld __conv sub_group_scan_inclusive_min(float); +int __ovld __conv sub_group_scan_inclusive_max(int ); +uint __ovld __conv sub_group_scan_inclusive_max(uint ); +long __ovld __conv sub_group_scan_inclusive_max(long ); +ulong __ovld __conv sub_group_scan_inclusive_max(ulong); +float __ovld __conv sub_group_scan_inclusive_max(float); + +#ifdef cl_khr_fp16 +half __ovld __conv sub_group_broadcast(half, uint sub_group_local_id); +half __ovld __conv sub_group_reduce_add(half); +half __ovld __conv sub_group_reduce_min(half); +half __ovld __conv sub_group_reduce_max(half); +half __ovld __conv sub_group_scan_exclusive_add(half); +half __ovld __conv sub_group_scan_exclusive_min(half); +half __ovld __conv sub_group_scan_exclusive_max(half); +half __ovld __conv sub_group_scan_inclusive_add(half); +half __ovld __conv sub_group_scan_inclusive_min(half); +half __ovld __conv sub_group_scan_inclusive_max(half); +#endif //cl_khr_fp16 + +#ifdef cl_khr_fp64 +double __ovld __conv sub_group_broadcast(double, uint sub_group_local_id); +double __ovld __conv sub_group_reduce_add(double); +double __ovld __conv sub_group_reduce_min(double); +double __ovld __conv sub_group_reduce_max(double); +double __ovld __conv sub_group_scan_exclusive_add(double); +double __ovld __conv sub_group_scan_exclusive_min(double); +double __ovld __conv sub_group_scan_exclusive_max(double); +double __ovld __conv sub_group_scan_inclusive_add(double); +double __ovld __conv sub_group_scan_inclusive_min(double); +double __ovld __conv sub_group_scan_inclusive_max(double); +#endif //cl_khr_fp64 + +#endif // __opencl_subgroup_builtins + +#if defined(cl_khr_subgroup_extended_types) +char __ovld __conv sub_group_broadcast( char value, uint index ); +char2 __ovld __conv sub_group_broadcast( char2 value, uint index ); +char3 __ovld __conv sub_group_broadcast( char3 value, uint index ); +char4 __ovld __conv sub_group_broadcast( char4 value, uint index ); +char8 __ovld __conv sub_group_broadcast( char8 value, uint index ); +char16 __ovld __conv sub_group_broadcast( char16 value, uint index ); + +uchar __ovld __conv sub_group_broadcast( uchar value, uint index ); +uchar2 __ovld __conv sub_group_broadcast( uchar2 value, uint index ); +uchar3 __ovld __conv sub_group_broadcast( uchar3 value, uint index ); +uchar4 __ovld __conv sub_group_broadcast( uchar4 value, uint index ); +uchar8 __ovld __conv sub_group_broadcast( uchar8 value, uint index ); +uchar16 __ovld __conv sub_group_broadcast( uchar16 value, uint index ); + +short __ovld __conv sub_group_broadcast( short value, uint index ); +short2 __ovld __conv sub_group_broadcast( short2 value, uint index ); +short3 __ovld __conv sub_group_broadcast( short3 value, uint index ); +short4 __ovld __conv sub_group_broadcast( short4 value, uint index ); +short8 __ovld __conv sub_group_broadcast( short8 value, uint index ); +short16 __ovld __conv sub_group_broadcast( short16 value, uint index ); + +ushort __ovld __conv sub_group_broadcast( ushort value, uint index ); +ushort2 __ovld __conv sub_group_broadcast( ushort2 value, uint index ); +ushort3 __ovld __conv sub_group_broadcast( ushort3 value, uint index ); +ushort4 __ovld __conv sub_group_broadcast( ushort4 value, uint index ); +ushort8 __ovld __conv sub_group_broadcast( ushort8 value, uint index ); +ushort16 __ovld __conv sub_group_broadcast( ushort16 value, uint index ); + +// scalar int broadcast is part of cl_khr_subgroups +int2 __ovld __conv sub_group_broadcast( int2 value, uint index ); +int3 __ovld __conv sub_group_broadcast( int3 value, uint index ); +int4 __ovld __conv sub_group_broadcast( int4 value, uint index ); +int8 __ovld __conv sub_group_broadcast( int8 value, uint index ); +int16 __ovld __conv sub_group_broadcast( int16 value, uint index ); + +// scalar uint broadcast is part of cl_khr_subgroups +uint2 __ovld __conv sub_group_broadcast( uint2 value, uint index ); +uint3 __ovld __conv sub_group_broadcast( uint3 value, uint index ); +uint4 __ovld __conv sub_group_broadcast( uint4 value, uint index ); +uint8 __ovld __conv sub_group_broadcast( uint8 value, uint index ); +uint16 __ovld __conv sub_group_broadcast( uint16 value, uint index ); + +// scalar long broadcast is part of cl_khr_subgroups +long2 __ovld __conv sub_group_broadcast( long2 value, uint index ); +long3 __ovld __conv sub_group_broadcast( long3 value, uint index ); +long4 __ovld __conv sub_group_broadcast( long4 value, uint index ); +long8 __ovld __conv sub_group_broadcast( long8 value, uint index ); +long16 __ovld __conv sub_group_broadcast( long16 value, uint index ); + +// scalar ulong broadcast is part of cl_khr_subgroups +ulong2 __ovld __conv sub_group_broadcast( ulong2 value, uint index ); +ulong3 __ovld __conv sub_group_broadcast( ulong3 value, uint index ); +ulong4 __ovld __conv sub_group_broadcast( ulong4 value, uint index ); +ulong8 __ovld __conv sub_group_broadcast( ulong8 value, uint index ); +ulong16 __ovld __conv sub_group_broadcast( ulong16 value, uint index ); + +// scalar float broadcast is part of cl_khr_subgroups +float2 __ovld __conv sub_group_broadcast( float2 value, uint index ); +float3 __ovld __conv sub_group_broadcast( float3 value, uint index ); +float4 __ovld __conv sub_group_broadcast( float4 value, uint index ); +float8 __ovld __conv sub_group_broadcast( float8 value, uint index ); +float16 __ovld __conv sub_group_broadcast( float16 value, uint index ); + +char __ovld __conv sub_group_reduce_add( char value ); +uchar __ovld __conv sub_group_reduce_add( uchar value ); +short __ovld __conv sub_group_reduce_add( short value ); +ushort __ovld __conv sub_group_reduce_add( ushort value ); + +char __ovld __conv sub_group_reduce_min( char value ); +uchar __ovld __conv sub_group_reduce_min( uchar value ); +short __ovld __conv sub_group_reduce_min( short value ); +ushort __ovld __conv sub_group_reduce_min( ushort value ); + +char __ovld __conv sub_group_reduce_max( char value ); +uchar __ovld __conv sub_group_reduce_max( uchar value ); +short __ovld __conv sub_group_reduce_max( short value ); +ushort __ovld __conv sub_group_reduce_max( ushort value ); + +char __ovld __conv sub_group_scan_inclusive_add( char value ); +uchar __ovld __conv sub_group_scan_inclusive_add( uchar value ); +short __ovld __conv sub_group_scan_inclusive_add( short value ); +ushort __ovld __conv sub_group_scan_inclusive_add( ushort value ); + +char __ovld __conv sub_group_scan_inclusive_min( char value ); +uchar __ovld __conv sub_group_scan_inclusive_min( uchar value ); +short __ovld __conv sub_group_scan_inclusive_min( short value ); +ushort __ovld __conv sub_group_scan_inclusive_min( ushort value ); + +char __ovld __conv sub_group_scan_inclusive_max( char value ); +uchar __ovld __conv sub_group_scan_inclusive_max( uchar value ); +short __ovld __conv sub_group_scan_inclusive_max( short value ); +ushort __ovld __conv sub_group_scan_inclusive_max( ushort value ); + +char __ovld __conv sub_group_scan_exclusive_add( char value ); +uchar __ovld __conv sub_group_scan_exclusive_add( uchar value ); +short __ovld __conv sub_group_scan_exclusive_add( short value ); +ushort __ovld __conv sub_group_scan_exclusive_add( ushort value ); + +char __ovld __conv sub_group_scan_exclusive_min( char value ); +uchar __ovld __conv sub_group_scan_exclusive_min( uchar value ); +short __ovld __conv sub_group_scan_exclusive_min( short value ); +ushort __ovld __conv sub_group_scan_exclusive_min( ushort value ); + +char __ovld __conv sub_group_scan_exclusive_max( char value ); +uchar __ovld __conv sub_group_scan_exclusive_max( uchar value ); +short __ovld __conv sub_group_scan_exclusive_max( short value ); +ushort __ovld __conv sub_group_scan_exclusive_max( ushort value ); + +#if defined(cl_khr_fp16) +// scalar half broadcast is part of cl_khr_subgroups +half2 __ovld __conv sub_group_broadcast( half2 value, uint index ); +half3 __ovld __conv sub_group_broadcast( half3 value, uint index ); +half4 __ovld __conv sub_group_broadcast( half4 value, uint index ); +half8 __ovld __conv sub_group_broadcast( half8 value, uint index ); +half16 __ovld __conv sub_group_broadcast( half16 value, uint index ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +// scalar double broadcast is part of cl_khr_subgroups +double2 __ovld __conv sub_group_broadcast( double2 value, uint index ); +double3 __ovld __conv sub_group_broadcast( double3 value, uint index ); +double4 __ovld __conv sub_group_broadcast( double4 value, uint index ); +double8 __ovld __conv sub_group_broadcast( double8 value, uint index ); +double16 __ovld __conv sub_group_broadcast( double16 value, uint index ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_extended_types + +#if defined(cl_khr_subgroup_non_uniform_vote) +int __ovld sub_group_elect(void); +int __ovld sub_group_non_uniform_all( int predicate ); +int __ovld sub_group_non_uniform_any( int predicate ); + +int __ovld sub_group_non_uniform_all_equal( char value ); +int __ovld sub_group_non_uniform_all_equal( uchar value ); +int __ovld sub_group_non_uniform_all_equal( short value ); +int __ovld sub_group_non_uniform_all_equal( ushort value ); +int __ovld sub_group_non_uniform_all_equal( int value ); +int __ovld sub_group_non_uniform_all_equal( uint value ); +int __ovld sub_group_non_uniform_all_equal( long value ); +int __ovld sub_group_non_uniform_all_equal( ulong value ); +int __ovld sub_group_non_uniform_all_equal( float value ); + +#if defined(cl_khr_fp16) +int __ovld sub_group_non_uniform_all_equal( half value ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +int __ovld sub_group_non_uniform_all_equal( double value ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_non_uniform_vote + +#if defined(cl_khr_subgroup_ballot) +char __ovld sub_group_non_uniform_broadcast( char value, uint index ); +char2 __ovld sub_group_non_uniform_broadcast( char2 value, uint index ); +char3 __ovld sub_group_non_uniform_broadcast( char3 value, uint index ); +char4 __ovld sub_group_non_uniform_broadcast( char4 value, uint index ); +char8 __ovld sub_group_non_uniform_broadcast( char8 value, uint index ); +char16 __ovld sub_group_non_uniform_broadcast( char16 value, uint index ); + +uchar __ovld sub_group_non_uniform_broadcast( uchar value, uint index ); +uchar2 __ovld sub_group_non_uniform_broadcast( uchar2 value, uint index ); +uchar3 __ovld sub_group_non_uniform_broadcast( uchar3 value, uint index ); +uchar4 __ovld sub_group_non_uniform_broadcast( uchar4 value, uint index ); +uchar8 __ovld sub_group_non_uniform_broadcast( uchar8 value, uint index ); +uchar16 __ovld sub_group_non_uniform_broadcast( uchar16 value, uint index ); + +short __ovld sub_group_non_uniform_broadcast( short value, uint index ); +short2 __ovld sub_group_non_uniform_broadcast( short2 value, uint index ); +short3 __ovld sub_group_non_uniform_broadcast( short3 value, uint index ); +short4 __ovld sub_group_non_uniform_broadcast( short4 value, uint index ); +short8 __ovld sub_group_non_uniform_broadcast( short8 value, uint index ); +short16 __ovld sub_group_non_uniform_broadcast( short16 value, uint index ); + +ushort __ovld sub_group_non_uniform_broadcast( ushort value, uint index ); +ushort2 __ovld sub_group_non_uniform_broadcast( ushort2 value, uint index ); +ushort3 __ovld sub_group_non_uniform_broadcast( ushort3 value, uint index ); +ushort4 __ovld sub_group_non_uniform_broadcast( ushort4 value, uint index ); +ushort8 __ovld sub_group_non_uniform_broadcast( ushort8 value, uint index ); +ushort16 __ovld sub_group_non_uniform_broadcast( ushort16 value, uint index ); + +int __ovld sub_group_non_uniform_broadcast( int value, uint index ); +int2 __ovld sub_group_non_uniform_broadcast( int2 value, uint index ); +int3 __ovld sub_group_non_uniform_broadcast( int3 value, uint index ); +int4 __ovld sub_group_non_uniform_broadcast( int4 value, uint index ); +int8 __ovld sub_group_non_uniform_broadcast( int8 value, uint index ); +int16 __ovld sub_group_non_uniform_broadcast( int16 value, uint index ); + +uint __ovld sub_group_non_uniform_broadcast( uint value, uint index ); +uint2 __ovld sub_group_non_uniform_broadcast( uint2 value, uint index ); +uint3 __ovld sub_group_non_uniform_broadcast( uint3 value, uint index ); +uint4 __ovld sub_group_non_uniform_broadcast( uint4 value, uint index ); +uint8 __ovld sub_group_non_uniform_broadcast( uint8 value, uint index ); +uint16 __ovld sub_group_non_uniform_broadcast( uint16 value, uint index ); + +long __ovld sub_group_non_uniform_broadcast( long value, uint index ); +long2 __ovld sub_group_non_uniform_broadcast( long2 value, uint index ); +long3 __ovld sub_group_non_uniform_broadcast( long3 value, uint index ); +long4 __ovld sub_group_non_uniform_broadcast( long4 value, uint index ); +long8 __ovld sub_group_non_uniform_broadcast( long8 value, uint index ); +long16 __ovld sub_group_non_uniform_broadcast( long16 value, uint index ); + +ulong __ovld sub_group_non_uniform_broadcast( ulong value, uint index ); +ulong2 __ovld sub_group_non_uniform_broadcast( ulong2 value, uint index ); +ulong3 __ovld sub_group_non_uniform_broadcast( ulong3 value, uint index ); +ulong4 __ovld sub_group_non_uniform_broadcast( ulong4 value, uint index ); +ulong8 __ovld sub_group_non_uniform_broadcast( ulong8 value, uint index ); +ulong16 __ovld sub_group_non_uniform_broadcast( ulong16 value, uint index ); + +float __ovld sub_group_non_uniform_broadcast( float value, uint index ); +float2 __ovld sub_group_non_uniform_broadcast( float2 value, uint index ); +float3 __ovld sub_group_non_uniform_broadcast( float3 value, uint index ); +float4 __ovld sub_group_non_uniform_broadcast( float4 value, uint index ); +float8 __ovld sub_group_non_uniform_broadcast( float8 value, uint index ); +float16 __ovld sub_group_non_uniform_broadcast( float16 value, uint index ); + +char __ovld sub_group_broadcast_first( char value ); +uchar __ovld sub_group_broadcast_first( uchar value ); +short __ovld sub_group_broadcast_first( short value ); +ushort __ovld sub_group_broadcast_first( ushort value ); +int __ovld sub_group_broadcast_first( int value ); +uint __ovld sub_group_broadcast_first( uint value ); +long __ovld sub_group_broadcast_first( long value ); +ulong __ovld sub_group_broadcast_first( ulong value ); +float __ovld sub_group_broadcast_first( float value ); + +uint4 __ovld sub_group_ballot( int predicate ); +int __ovld __cnfn sub_group_inverse_ballot( uint4 value ); +int __ovld __cnfn sub_group_ballot_bit_extract( uint4 value, uint index ); +uint __ovld __cnfn sub_group_ballot_bit_count( uint4 value ); + +uint __ovld sub_group_ballot_inclusive_scan( uint4 value ); +uint __ovld sub_group_ballot_exclusive_scan( uint4 value ); +uint __ovld sub_group_ballot_find_lsb( uint4 value ); +uint __ovld sub_group_ballot_find_msb( uint4 value ); + +uint4 __ovld __cnfn get_sub_group_eq_mask(void); +uint4 __ovld __cnfn get_sub_group_ge_mask(void); +uint4 __ovld __cnfn get_sub_group_gt_mask(void); +uint4 __ovld __cnfn get_sub_group_le_mask(void); +uint4 __ovld __cnfn get_sub_group_lt_mask(void); + +#if defined(cl_khr_fp16) +half __ovld sub_group_non_uniform_broadcast( half value, uint index ); +half2 __ovld sub_group_non_uniform_broadcast( half2 value, uint index ); +half3 __ovld sub_group_non_uniform_broadcast( half3 value, uint index ); +half4 __ovld sub_group_non_uniform_broadcast( half4 value, uint index ); +half8 __ovld sub_group_non_uniform_broadcast( half8 value, uint index ); +half16 __ovld sub_group_non_uniform_broadcast( half16 value, uint index ); + +half __ovld sub_group_broadcast_first( half value ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +double __ovld sub_group_non_uniform_broadcast( double value, uint index ); +double2 __ovld sub_group_non_uniform_broadcast( double2 value, uint index ); +double3 __ovld sub_group_non_uniform_broadcast( double3 value, uint index ); +double4 __ovld sub_group_non_uniform_broadcast( double4 value, uint index ); +double8 __ovld sub_group_non_uniform_broadcast( double8 value, uint index ); +double16 __ovld sub_group_non_uniform_broadcast( double16 value, uint index ); + +double __ovld sub_group_broadcast_first( double value ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_ballot + +#if defined(cl_khr_subgroup_non_uniform_arithmetic) +char __ovld sub_group_non_uniform_reduce_add( char value ); +uchar __ovld sub_group_non_uniform_reduce_add( uchar value ); +short __ovld sub_group_non_uniform_reduce_add( short value ); +ushort __ovld sub_group_non_uniform_reduce_add( ushort value ); +int __ovld sub_group_non_uniform_reduce_add( int value ); +uint __ovld sub_group_non_uniform_reduce_add( uint value ); +long __ovld sub_group_non_uniform_reduce_add( long value ); +ulong __ovld sub_group_non_uniform_reduce_add( ulong value ); +float __ovld sub_group_non_uniform_reduce_add( float value ); + +char __ovld sub_group_non_uniform_reduce_mul( char value ); +uchar __ovld sub_group_non_uniform_reduce_mul( uchar value ); +short __ovld sub_group_non_uniform_reduce_mul( short value ); +ushort __ovld sub_group_non_uniform_reduce_mul( ushort value ); +int __ovld sub_group_non_uniform_reduce_mul( int value ); +uint __ovld sub_group_non_uniform_reduce_mul( uint value ); +long __ovld sub_group_non_uniform_reduce_mul( long value ); +ulong __ovld sub_group_non_uniform_reduce_mul( ulong value ); +float __ovld sub_group_non_uniform_reduce_mul( float value ); + +char __ovld sub_group_non_uniform_reduce_min( char value ); +uchar __ovld sub_group_non_uniform_reduce_min( uchar value ); +short __ovld sub_group_non_uniform_reduce_min( short value ); +ushort __ovld sub_group_non_uniform_reduce_min( ushort value ); +int __ovld sub_group_non_uniform_reduce_min( int value ); +uint __ovld sub_group_non_uniform_reduce_min( uint value ); +long __ovld sub_group_non_uniform_reduce_min( long value ); +ulong __ovld sub_group_non_uniform_reduce_min( ulong value ); +float __ovld sub_group_non_uniform_reduce_min( float value ); + +char __ovld sub_group_non_uniform_reduce_max( char value ); +uchar __ovld sub_group_non_uniform_reduce_max( uchar value ); +short __ovld sub_group_non_uniform_reduce_max( short value ); +ushort __ovld sub_group_non_uniform_reduce_max( ushort value ); +int __ovld sub_group_non_uniform_reduce_max( int value ); +uint __ovld sub_group_non_uniform_reduce_max( uint value ); +long __ovld sub_group_non_uniform_reduce_max( long value ); +ulong __ovld sub_group_non_uniform_reduce_max( ulong value ); +float __ovld sub_group_non_uniform_reduce_max( float value ); + +char __ovld sub_group_non_uniform_scan_inclusive_add( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_add( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_add( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_add( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_add( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_add( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_add( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_add( ulong value ); +float __ovld sub_group_non_uniform_scan_inclusive_add( float value ); + +char __ovld sub_group_non_uniform_scan_inclusive_mul( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_mul( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_mul( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_mul( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_mul( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_mul( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_mul( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_mul( ulong value ); +float __ovld sub_group_non_uniform_scan_inclusive_mul( float value ); + +char __ovld sub_group_non_uniform_scan_inclusive_min( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_min( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_min( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_min( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_min( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_min( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_min( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_min( ulong value ); +float __ovld sub_group_non_uniform_scan_inclusive_min( float value ); + +char __ovld sub_group_non_uniform_scan_inclusive_max( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_max( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_max( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_max( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_max( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_max( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_max( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_max( ulong value ); +float __ovld sub_group_non_uniform_scan_inclusive_max( float value ); + +char __ovld sub_group_non_uniform_scan_exclusive_add( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_add( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_add( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_add( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_add( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_add( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_add( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_add( ulong value ); +float __ovld sub_group_non_uniform_scan_exclusive_add( float value ); + +char __ovld sub_group_non_uniform_scan_exclusive_mul( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_mul( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_mul( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_mul( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_mul( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_mul( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_mul( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_mul( ulong value ); +float __ovld sub_group_non_uniform_scan_exclusive_mul( float value ); + +char __ovld sub_group_non_uniform_scan_exclusive_min( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_min( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_min( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_min( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_min( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_min( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_min( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_min( ulong value ); +float __ovld sub_group_non_uniform_scan_exclusive_min( float value ); + +char __ovld sub_group_non_uniform_scan_exclusive_max( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_max( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_max( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_max( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_max( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_max( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_max( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_max( ulong value ); +float __ovld sub_group_non_uniform_scan_exclusive_max( float value ); + +char __ovld sub_group_non_uniform_reduce_and( char value ); +uchar __ovld sub_group_non_uniform_reduce_and( uchar value ); +short __ovld sub_group_non_uniform_reduce_and( short value ); +ushort __ovld sub_group_non_uniform_reduce_and( ushort value ); +int __ovld sub_group_non_uniform_reduce_and( int value ); +uint __ovld sub_group_non_uniform_reduce_and( uint value ); +long __ovld sub_group_non_uniform_reduce_and( long value ); +ulong __ovld sub_group_non_uniform_reduce_and( ulong value ); + +char __ovld sub_group_non_uniform_reduce_or( char value ); +uchar __ovld sub_group_non_uniform_reduce_or( uchar value ); +short __ovld sub_group_non_uniform_reduce_or( short value ); +ushort __ovld sub_group_non_uniform_reduce_or( ushort value ); +int __ovld sub_group_non_uniform_reduce_or( int value ); +uint __ovld sub_group_non_uniform_reduce_or( uint value ); +long __ovld sub_group_non_uniform_reduce_or( long value ); +ulong __ovld sub_group_non_uniform_reduce_or( ulong value ); + +char __ovld sub_group_non_uniform_reduce_xor( char value ); +uchar __ovld sub_group_non_uniform_reduce_xor( uchar value ); +short __ovld sub_group_non_uniform_reduce_xor( short value ); +ushort __ovld sub_group_non_uniform_reduce_xor( ushort value ); +int __ovld sub_group_non_uniform_reduce_xor( int value ); +uint __ovld sub_group_non_uniform_reduce_xor( uint value ); +long __ovld sub_group_non_uniform_reduce_xor( long value ); +ulong __ovld sub_group_non_uniform_reduce_xor( ulong value ); + +char __ovld sub_group_non_uniform_scan_inclusive_and( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_and( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_and( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_and( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_and( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_and( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_and( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_and( ulong value ); + +char __ovld sub_group_non_uniform_scan_inclusive_or( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_or( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_or( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_or( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_or( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_or( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_or( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_or( ulong value ); + +char __ovld sub_group_non_uniform_scan_inclusive_xor( char value ); +uchar __ovld sub_group_non_uniform_scan_inclusive_xor( uchar value ); +short __ovld sub_group_non_uniform_scan_inclusive_xor( short value ); +ushort __ovld sub_group_non_uniform_scan_inclusive_xor( ushort value ); +int __ovld sub_group_non_uniform_scan_inclusive_xor( int value ); +uint __ovld sub_group_non_uniform_scan_inclusive_xor( uint value ); +long __ovld sub_group_non_uniform_scan_inclusive_xor( long value ); +ulong __ovld sub_group_non_uniform_scan_inclusive_xor( ulong value ); + +char __ovld sub_group_non_uniform_scan_exclusive_and( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_and( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_and( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_and( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_and( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_and( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_and( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_and( ulong value ); + +char __ovld sub_group_non_uniform_scan_exclusive_or( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_or( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_or( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_or( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_or( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_or( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_or( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_or( ulong value ); + +char __ovld sub_group_non_uniform_scan_exclusive_xor( char value ); +uchar __ovld sub_group_non_uniform_scan_exclusive_xor( uchar value ); +short __ovld sub_group_non_uniform_scan_exclusive_xor( short value ); +ushort __ovld sub_group_non_uniform_scan_exclusive_xor( ushort value ); +int __ovld sub_group_non_uniform_scan_exclusive_xor( int value ); +uint __ovld sub_group_non_uniform_scan_exclusive_xor( uint value ); +long __ovld sub_group_non_uniform_scan_exclusive_xor( long value ); +ulong __ovld sub_group_non_uniform_scan_exclusive_xor( ulong value ); + +int __ovld sub_group_non_uniform_reduce_logical_and( int predicate ); +int __ovld sub_group_non_uniform_reduce_logical_or( int predicate ); +int __ovld sub_group_non_uniform_reduce_logical_xor( int predicate ); + +int __ovld sub_group_non_uniform_scan_inclusive_logical_and( int predicate ); +int __ovld sub_group_non_uniform_scan_inclusive_logical_or( int predicate ); +int __ovld sub_group_non_uniform_scan_inclusive_logical_xor( int predicate ); + +int __ovld sub_group_non_uniform_scan_exclusive_logical_and( int predicate ); +int __ovld sub_group_non_uniform_scan_exclusive_logical_or( int predicate ); +int __ovld sub_group_non_uniform_scan_exclusive_logical_xor( int predicate ); + +#if defined(cl_khr_fp16) +half __ovld sub_group_non_uniform_reduce_add( half value ); +half __ovld sub_group_non_uniform_reduce_mul( half value ); +half __ovld sub_group_non_uniform_reduce_min( half value ); +half __ovld sub_group_non_uniform_reduce_max( half value ); +half __ovld sub_group_non_uniform_scan_inclusive_add( half value ); +half __ovld sub_group_non_uniform_scan_inclusive_mul( half value ); +half __ovld sub_group_non_uniform_scan_inclusive_min( half value ); +half __ovld sub_group_non_uniform_scan_inclusive_max( half value ); +half __ovld sub_group_non_uniform_scan_exclusive_add( half value ); +half __ovld sub_group_non_uniform_scan_exclusive_mul( half value ); +half __ovld sub_group_non_uniform_scan_exclusive_min( half value ); +half __ovld sub_group_non_uniform_scan_exclusive_max( half value ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +double __ovld sub_group_non_uniform_reduce_add( double value ); +double __ovld sub_group_non_uniform_reduce_mul( double value ); +double __ovld sub_group_non_uniform_reduce_min( double value ); +double __ovld sub_group_non_uniform_reduce_max( double value ); +double __ovld sub_group_non_uniform_scan_inclusive_add( double value ); +double __ovld sub_group_non_uniform_scan_inclusive_mul( double value ); +double __ovld sub_group_non_uniform_scan_inclusive_min( double value ); +double __ovld sub_group_non_uniform_scan_inclusive_max( double value ); +double __ovld sub_group_non_uniform_scan_exclusive_add( double value ); +double __ovld sub_group_non_uniform_scan_exclusive_mul( double value ); +double __ovld sub_group_non_uniform_scan_exclusive_min( double value ); +double __ovld sub_group_non_uniform_scan_exclusive_max( double value ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_non_uniform_arithmetic + +#if defined(cl_khr_subgroup_shuffle) +char __ovld sub_group_shuffle( char value, uint index ); +uchar __ovld sub_group_shuffle( uchar value, uint index ); +short __ovld sub_group_shuffle( short value, uint index ); +ushort __ovld sub_group_shuffle( ushort value, uint index ); +int __ovld sub_group_shuffle( int value, uint index ); +uint __ovld sub_group_shuffle( uint value, uint index ); +long __ovld sub_group_shuffle( long value, uint index ); +ulong __ovld sub_group_shuffle( ulong value, uint index ); +float __ovld sub_group_shuffle( float value, uint index ); + +char __ovld sub_group_shuffle_xor( char value, uint mask ); +uchar __ovld sub_group_shuffle_xor( uchar value, uint mask ); +short __ovld sub_group_shuffle_xor( short value, uint mask ); +ushort __ovld sub_group_shuffle_xor( ushort value, uint mask ); +int __ovld sub_group_shuffle_xor( int value, uint mask ); +uint __ovld sub_group_shuffle_xor( uint value, uint mask ); +long __ovld sub_group_shuffle_xor( long value, uint mask ); +ulong __ovld sub_group_shuffle_xor( ulong value, uint mask ); +float __ovld sub_group_shuffle_xor( float value, uint mask ); + +#if defined(cl_khr_fp16) +half __ovld sub_group_shuffle( half value, uint index ); +half __ovld sub_group_shuffle_xor( half value, uint mask ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +double __ovld sub_group_shuffle( double value, uint index ); +double __ovld sub_group_shuffle_xor( double value, uint mask ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_shuffle + +#if defined(cl_khr_subgroup_shuffle_relative) +char __ovld sub_group_shuffle_up( char value, uint delta ); +uchar __ovld sub_group_shuffle_up( uchar value, uint delta ); +short __ovld sub_group_shuffle_up( short value, uint delta ); +ushort __ovld sub_group_shuffle_up( ushort value, uint delta ); +int __ovld sub_group_shuffle_up( int value, uint delta ); +uint __ovld sub_group_shuffle_up( uint value, uint delta ); +long __ovld sub_group_shuffle_up( long value, uint delta ); +ulong __ovld sub_group_shuffle_up( ulong value, uint delta ); +float __ovld sub_group_shuffle_up( float value, uint delta ); + +char __ovld sub_group_shuffle_down( char value, uint delta ); +uchar __ovld sub_group_shuffle_down( uchar value, uint delta ); +short __ovld sub_group_shuffle_down( short value, uint delta ); +ushort __ovld sub_group_shuffle_down( ushort value, uint delta ); +int __ovld sub_group_shuffle_down( int value, uint delta ); +uint __ovld sub_group_shuffle_down( uint value, uint delta ); +long __ovld sub_group_shuffle_down( long value, uint delta ); +ulong __ovld sub_group_shuffle_down( ulong value, uint delta ); +float __ovld sub_group_shuffle_down( float value, uint delta ); + +#if defined(cl_khr_fp16) +half __ovld sub_group_shuffle_up( half value, uint delta ); +half __ovld sub_group_shuffle_down( half value, uint delta ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +double __ovld sub_group_shuffle_up( double value, uint delta ); +double __ovld sub_group_shuffle_down( double value, uint delta ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_shuffle_relative + +#if defined(cl_khr_subgroup_clustered_reduce) +char __ovld sub_group_clustered_reduce_add( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_add( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_add( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_add( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_add( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_add( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_add( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_add( ulong value, uint clustersize ); +float __ovld sub_group_clustered_reduce_add( float value, uint clustersize ); + +char __ovld sub_group_clustered_reduce_mul( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_mul( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_mul( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_mul( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_mul( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_mul( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_mul( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_mul( ulong value, uint clustersize ); +float __ovld sub_group_clustered_reduce_mul( float value, uint clustersize ); + +char __ovld sub_group_clustered_reduce_min( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_min( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_min( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_min( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_min( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_min( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_min( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_min( ulong value, uint clustersize ); +float __ovld sub_group_clustered_reduce_min( float value, uint clustersize ); + +char __ovld sub_group_clustered_reduce_max( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_max( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_max( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_max( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_max( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_max( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_max( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_max( ulong value, uint clustersize ); +float __ovld sub_group_clustered_reduce_max( float value, uint clustersize ); + +char __ovld sub_group_clustered_reduce_and( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_and( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_and( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_and( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_and( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_and( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_and( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_and( ulong value, uint clustersize ); + +char __ovld sub_group_clustered_reduce_or( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_or( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_or( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_or( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_or( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_or( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_or( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_or( ulong value, uint clustersize ); + +char __ovld sub_group_clustered_reduce_xor( char value, uint clustersize ); +uchar __ovld sub_group_clustered_reduce_xor( uchar value, uint clustersize ); +short __ovld sub_group_clustered_reduce_xor( short value, uint clustersize ); +ushort __ovld sub_group_clustered_reduce_xor( ushort value, uint clustersize ); +int __ovld sub_group_clustered_reduce_xor( int value, uint clustersize ); +uint __ovld sub_group_clustered_reduce_xor( uint value, uint clustersize ); +long __ovld sub_group_clustered_reduce_xor( long value, uint clustersize ); +ulong __ovld sub_group_clustered_reduce_xor( ulong value, uint clustersize ); + +int __ovld sub_group_clustered_reduce_logical_and( int predicate, uint clustersize ); +int __ovld sub_group_clustered_reduce_logical_or( int predicate, uint clustersize ); +int __ovld sub_group_clustered_reduce_logical_xor( int predicate, uint clustersize ); + +#if defined(cl_khr_fp16) +half __ovld sub_group_clustered_reduce_add( half value, uint clustersize ); +half __ovld sub_group_clustered_reduce_mul( half value, uint clustersize ); +half __ovld sub_group_clustered_reduce_min( half value, uint clustersize ); +half __ovld sub_group_clustered_reduce_max( half value, uint clustersize ); +#endif // cl_khr_fp16 + +#if defined(cl_khr_fp64) +double __ovld sub_group_clustered_reduce_add( double value, uint clustersize ); +double __ovld sub_group_clustered_reduce_mul( double value, uint clustersize ); +double __ovld sub_group_clustered_reduce_min( double value, uint clustersize ); +double __ovld sub_group_clustered_reduce_max( double value, uint clustersize ); +#endif // cl_khr_fp64 + +#endif // cl_khr_subgroup_clustered_reduce + +#if defined(cl_khr_extended_bit_ops) +char __ovld __cnfn bitfield_insert(char, char, uint, uint); +uchar __ovld __cnfn bitfield_insert(uchar, uchar, uint, uint); +short __ovld __cnfn bitfield_insert(short, short, uint, uint); +ushort __ovld __cnfn bitfield_insert(ushort, ushort, uint, uint); +int __ovld __cnfn bitfield_insert(int, int, uint, uint); +uint __ovld __cnfn bitfield_insert(uint, uint, uint, uint); +long __ovld __cnfn bitfield_insert(long, long, uint, uint); +ulong __ovld __cnfn bitfield_insert(ulong, ulong, uint, uint); +char2 __ovld __cnfn bitfield_insert(char2, char2, uint, uint); +uchar2 __ovld __cnfn bitfield_insert(uchar2, uchar2, uint, uint); +short2 __ovld __cnfn bitfield_insert(short2, short2, uint, uint); +ushort2 __ovld __cnfn bitfield_insert(ushort2, ushort2, uint, uint); +int2 __ovld __cnfn bitfield_insert(int2, int2, uint, uint); +uint2 __ovld __cnfn bitfield_insert(uint2, uint2, uint, uint); +long2 __ovld __cnfn bitfield_insert(long2, long2, uint, uint); +ulong2 __ovld __cnfn bitfield_insert(ulong2, ulong2, uint, uint); +char3 __ovld __cnfn bitfield_insert(char3, char3, uint, uint); +uchar3 __ovld __cnfn bitfield_insert(uchar3, uchar3, uint, uint); +short3 __ovld __cnfn bitfield_insert(short3, short3, uint, uint); +ushort3 __ovld __cnfn bitfield_insert(ushort3, ushort3, uint, uint); +int3 __ovld __cnfn bitfield_insert(int3, int3, uint, uint); +uint3 __ovld __cnfn bitfield_insert(uint3, uint3, uint, uint); +long3 __ovld __cnfn bitfield_insert(long3, long3, uint, uint); +ulong3 __ovld __cnfn bitfield_insert(ulong3, ulong3, uint, uint); +char4 __ovld __cnfn bitfield_insert(char4, char4, uint, uint); +uchar4 __ovld __cnfn bitfield_insert(uchar4, uchar4, uint, uint); +short4 __ovld __cnfn bitfield_insert(short4, short4, uint, uint); +ushort4 __ovld __cnfn bitfield_insert(ushort4, ushort4, uint, uint); +int4 __ovld __cnfn bitfield_insert(int4, int4, uint, uint); +uint4 __ovld __cnfn bitfield_insert(uint4, uint4, uint, uint); +long4 __ovld __cnfn bitfield_insert(long4, long4, uint, uint); +ulong4 __ovld __cnfn bitfield_insert(ulong4, ulong4, uint, uint); +char8 __ovld __cnfn bitfield_insert(char8, char8, uint, uint); +uchar8 __ovld __cnfn bitfield_insert(uchar8, uchar8, uint, uint); +short8 __ovld __cnfn bitfield_insert(short8, short8, uint, uint); +ushort8 __ovld __cnfn bitfield_insert(ushort8, ushort8, uint, uint); +int8 __ovld __cnfn bitfield_insert(int8, int8, uint, uint); +uint8 __ovld __cnfn bitfield_insert(uint8, uint8, uint, uint); +long8 __ovld __cnfn bitfield_insert(long8, long8, uint, uint); +ulong8 __ovld __cnfn bitfield_insert(ulong8, ulong8, uint, uint); +char16 __ovld __cnfn bitfield_insert(char16, char16, uint, uint); +uchar16 __ovld __cnfn bitfield_insert(uchar16, uchar16, uint, uint); +short16 __ovld __cnfn bitfield_insert(short16, short16, uint, uint); +ushort16 __ovld __cnfn bitfield_insert(ushort16, ushort16, uint, uint); +int16 __ovld __cnfn bitfield_insert(int16, int16, uint, uint); +uint16 __ovld __cnfn bitfield_insert(uint16, uint16, uint, uint); +long16 __ovld __cnfn bitfield_insert(long16, long16, uint, uint); +ulong16 __ovld __cnfn bitfield_insert(ulong16, ulong16, uint, uint); + +char __ovld __cnfn bitfield_extract_signed(char, uint, uint); +short __ovld __cnfn bitfield_extract_signed(short, uint, uint); +int __ovld __cnfn bitfield_extract_signed(int, uint, uint); +long __ovld __cnfn bitfield_extract_signed(long, uint, uint); +char2 __ovld __cnfn bitfield_extract_signed(char2, uint, uint); +short2 __ovld __cnfn bitfield_extract_signed(short2, uint, uint); +int2 __ovld __cnfn bitfield_extract_signed(int2, uint, uint); +long2 __ovld __cnfn bitfield_extract_signed(long2, uint, uint); +char3 __ovld __cnfn bitfield_extract_signed(char3, uint, uint); +short3 __ovld __cnfn bitfield_extract_signed(short3, uint, uint); +int3 __ovld __cnfn bitfield_extract_signed(int3, uint, uint); +long3 __ovld __cnfn bitfield_extract_signed(long3, uint, uint); +char4 __ovld __cnfn bitfield_extract_signed(char4, uint, uint); +short4 __ovld __cnfn bitfield_extract_signed(short4, uint, uint); +int4 __ovld __cnfn bitfield_extract_signed(int4, uint, uint); +long4 __ovld __cnfn bitfield_extract_signed(long4, uint, uint); +char8 __ovld __cnfn bitfield_extract_signed(char8, uint, uint); +short8 __ovld __cnfn bitfield_extract_signed(short8, uint, uint); +int8 __ovld __cnfn bitfield_extract_signed(int8, uint, uint); +long8 __ovld __cnfn bitfield_extract_signed(long8, uint, uint); +char16 __ovld __cnfn bitfield_extract_signed(char16, uint, uint); +short16 __ovld __cnfn bitfield_extract_signed(short16, uint, uint); +int16 __ovld __cnfn bitfield_extract_signed(int16, uint, uint); +long16 __ovld __cnfn bitfield_extract_signed(long16, uint, uint); + +char __ovld __cnfn bitfield_extract_signed(uchar, uint, uint); +short __ovld __cnfn bitfield_extract_signed(ushort, uint, uint); +int __ovld __cnfn bitfield_extract_signed(uint, uint, uint); +long __ovld __cnfn bitfield_extract_signed(ulong, uint, uint); +char2 __ovld __cnfn bitfield_extract_signed(uchar2, uint, uint); +short2 __ovld __cnfn bitfield_extract_signed(ushort2, uint, uint); +int2 __ovld __cnfn bitfield_extract_signed(uint2, uint, uint); +long2 __ovld __cnfn bitfield_extract_signed(ulong2, uint, uint); +char3 __ovld __cnfn bitfield_extract_signed(uchar3, uint, uint); +short3 __ovld __cnfn bitfield_extract_signed(ushort3, uint, uint); +int3 __ovld __cnfn bitfield_extract_signed(uint3, uint, uint); +long3 __ovld __cnfn bitfield_extract_signed(ulong3, uint, uint); +char4 __ovld __cnfn bitfield_extract_signed(uchar4, uint, uint); +short4 __ovld __cnfn bitfield_extract_signed(ushort4, uint, uint); +int4 __ovld __cnfn bitfield_extract_signed(uint4, uint, uint); +long4 __ovld __cnfn bitfield_extract_signed(ulong4, uint, uint); +char8 __ovld __cnfn bitfield_extract_signed(uchar8, uint, uint); +short8 __ovld __cnfn bitfield_extract_signed(ushort8, uint, uint); +int8 __ovld __cnfn bitfield_extract_signed(uint8, uint, uint); +long8 __ovld __cnfn bitfield_extract_signed(ulong8, uint, uint); +char16 __ovld __cnfn bitfield_extract_signed(uchar16, uint, uint); +short16 __ovld __cnfn bitfield_extract_signed(ushort16, uint, uint); +int16 __ovld __cnfn bitfield_extract_signed(uint16, uint, uint); +long16 __ovld __cnfn bitfield_extract_signed(ulong16, uint, uint); + +uchar __ovld __cnfn bitfield_extract_unsigned(char, uint, uint); +ushort __ovld __cnfn bitfield_extract_unsigned(short, uint, uint); +uint __ovld __cnfn bitfield_extract_unsigned(int, uint, uint); +ulong __ovld __cnfn bitfield_extract_unsigned(long, uint, uint); +uchar2 __ovld __cnfn bitfield_extract_unsigned(char2, uint, uint); +ushort2 __ovld __cnfn bitfield_extract_unsigned(short2, uint, uint); +uint2 __ovld __cnfn bitfield_extract_unsigned(int2, uint, uint); +ulong2 __ovld __cnfn bitfield_extract_unsigned(long2, uint, uint); +uchar3 __ovld __cnfn bitfield_extract_unsigned(char3, uint, uint); +ushort3 __ovld __cnfn bitfield_extract_unsigned(short3, uint, uint); +uint3 __ovld __cnfn bitfield_extract_unsigned(int3, uint, uint); +ulong3 __ovld __cnfn bitfield_extract_unsigned(long3, uint, uint); +uchar4 __ovld __cnfn bitfield_extract_unsigned(char4, uint, uint); +ushort4 __ovld __cnfn bitfield_extract_unsigned(short4, uint, uint); +uint4 __ovld __cnfn bitfield_extract_unsigned(int4, uint, uint); +ulong4 __ovld __cnfn bitfield_extract_unsigned(long4, uint, uint); +uchar8 __ovld __cnfn bitfield_extract_unsigned(char8, uint, uint); +ushort8 __ovld __cnfn bitfield_extract_unsigned(short8, uint, uint); +uint8 __ovld __cnfn bitfield_extract_unsigned(int8, uint, uint); +ulong8 __ovld __cnfn bitfield_extract_unsigned(long8, uint, uint); +uchar16 __ovld __cnfn bitfield_extract_unsigned(char16, uint, uint); +ushort16 __ovld __cnfn bitfield_extract_unsigned(short16, uint, uint); +uint16 __ovld __cnfn bitfield_extract_unsigned(int16, uint, uint); +ulong16 __ovld __cnfn bitfield_extract_unsigned(long16, uint, uint); + +uchar __ovld __cnfn bitfield_extract_unsigned(uchar, uint, uint); +ushort __ovld __cnfn bitfield_extract_unsigned(ushort, uint, uint); +uint __ovld __cnfn bitfield_extract_unsigned(uint, uint, uint); +ulong __ovld __cnfn bitfield_extract_unsigned(ulong, uint, uint); +uchar2 __ovld __cnfn bitfield_extract_unsigned(uchar2, uint, uint); +ushort2 __ovld __cnfn bitfield_extract_unsigned(ushort2, uint, uint); +uint2 __ovld __cnfn bitfield_extract_unsigned(uint2, uint, uint); +ulong2 __ovld __cnfn bitfield_extract_unsigned(ulong2, uint, uint); +uchar3 __ovld __cnfn bitfield_extract_unsigned(uchar3, uint, uint); +ushort3 __ovld __cnfn bitfield_extract_unsigned(ushort3, uint, uint); +uint3 __ovld __cnfn bitfield_extract_unsigned(uint3, uint, uint); +ulong3 __ovld __cnfn bitfield_extract_unsigned(ulong3, uint, uint); +uchar4 __ovld __cnfn bitfield_extract_unsigned(uchar4, uint, uint); +ushort4 __ovld __cnfn bitfield_extract_unsigned(ushort4, uint, uint); +uint4 __ovld __cnfn bitfield_extract_unsigned(uint4, uint, uint); +ulong4 __ovld __cnfn bitfield_extract_unsigned(ulong4, uint, uint); +uchar8 __ovld __cnfn bitfield_extract_unsigned(uchar8, uint, uint); +ushort8 __ovld __cnfn bitfield_extract_unsigned(ushort8, uint, uint); +uint8 __ovld __cnfn bitfield_extract_unsigned(uint8, uint, uint); +ulong8 __ovld __cnfn bitfield_extract_unsigned(ulong8, uint, uint); +uchar16 __ovld __cnfn bitfield_extract_unsigned(uchar16, uint, uint); +ushort16 __ovld __cnfn bitfield_extract_unsigned(ushort16, uint, uint); +uint16 __ovld __cnfn bitfield_extract_unsigned(uint16, uint, uint); +ulong16 __ovld __cnfn bitfield_extract_unsigned(ulong16, uint, uint); + +char __ovld __cnfn bit_reverse(char); +uchar __ovld __cnfn bit_reverse(uchar); +short __ovld __cnfn bit_reverse(short); +ushort __ovld __cnfn bit_reverse(ushort); +int __ovld __cnfn bit_reverse(int); +uint __ovld __cnfn bit_reverse(uint); +long __ovld __cnfn bit_reverse(long); +ulong __ovld __cnfn bit_reverse(ulong); +char2 __ovld __cnfn bit_reverse(char2); +uchar2 __ovld __cnfn bit_reverse(uchar2); +short2 __ovld __cnfn bit_reverse(short2); +ushort2 __ovld __cnfn bit_reverse(ushort2); +int2 __ovld __cnfn bit_reverse(int2); +uint2 __ovld __cnfn bit_reverse(uint2); +long2 __ovld __cnfn bit_reverse(long2); +ulong2 __ovld __cnfn bit_reverse(ulong2); +char3 __ovld __cnfn bit_reverse(char3); +uchar3 __ovld __cnfn bit_reverse(uchar3); +short3 __ovld __cnfn bit_reverse(short3); +ushort3 __ovld __cnfn bit_reverse(ushort3); +int3 __ovld __cnfn bit_reverse(int3); +uint3 __ovld __cnfn bit_reverse(uint3); +long3 __ovld __cnfn bit_reverse(long3); +ulong3 __ovld __cnfn bit_reverse(ulong3); +char4 __ovld __cnfn bit_reverse(char4); +uchar4 __ovld __cnfn bit_reverse(uchar4); +short4 __ovld __cnfn bit_reverse(short4); +ushort4 __ovld __cnfn bit_reverse(ushort4); +int4 __ovld __cnfn bit_reverse(int4); +uint4 __ovld __cnfn bit_reverse(uint4); +long4 __ovld __cnfn bit_reverse(long4); +ulong4 __ovld __cnfn bit_reverse(ulong4); +char8 __ovld __cnfn bit_reverse(char8); +uchar8 __ovld __cnfn bit_reverse(uchar8); +short8 __ovld __cnfn bit_reverse(short8); +ushort8 __ovld __cnfn bit_reverse(ushort8); +int8 __ovld __cnfn bit_reverse(int8); +uint8 __ovld __cnfn bit_reverse(uint8); +long8 __ovld __cnfn bit_reverse(long8); +ulong8 __ovld __cnfn bit_reverse(ulong8); +char16 __ovld __cnfn bit_reverse(char16); +uchar16 __ovld __cnfn bit_reverse(uchar16); +short16 __ovld __cnfn bit_reverse(short16); +ushort16 __ovld __cnfn bit_reverse(ushort16); +int16 __ovld __cnfn bit_reverse(int16); +uint16 __ovld __cnfn bit_reverse(uint16); +long16 __ovld __cnfn bit_reverse(long16); +ulong16 __ovld __cnfn bit_reverse(ulong16); +#endif // cl_khr_extended_bit_ops + +#if defined(__opencl_c_integer_dot_product_input_4x8bit) +uint __ovld __cnfn dot(uchar4, uchar4); +int __ovld __cnfn dot(char4, char4); +int __ovld __cnfn dot(uchar4, char4); +int __ovld __cnfn dot(char4, uchar4); + +uint __ovld __cnfn dot_acc_sat(uchar4, uchar4, uint); +int __ovld __cnfn dot_acc_sat(char4, char4, int); +int __ovld __cnfn dot_acc_sat(uchar4, char4, int); +int __ovld __cnfn dot_acc_sat(char4, uchar4, int); +#endif // __opencl_c_integer_dot_product_input_4x8bit + +#if defined(__opencl_c_integer_dot_product_input_4x8bit_packed) +uint __ovld __cnfn dot_4x8packed_uu_uint(uint, uint); +int __ovld __cnfn dot_4x8packed_ss_int(uint, uint); +int __ovld __cnfn dot_4x8packed_us_int(uint, uint); +int __ovld __cnfn dot_4x8packed_su_int(uint, uint); + +uint __ovld __cnfn dot_acc_sat_4x8packed_uu_uint(uint, uint, uint); +int __ovld __cnfn dot_acc_sat_4x8packed_ss_int(uint, uint, int); +int __ovld __cnfn dot_acc_sat_4x8packed_us_int(uint, uint, int); +int __ovld __cnfn dot_acc_sat_4x8packed_su_int(uint, uint, int); +#endif // __opencl_c_integer_dot_product_input_4x8bit_packed + +#if defined(cl_khr_subgroup_rotate) +char __ovld __conv sub_group_rotate(char, int); +uchar __ovld __conv sub_group_rotate(uchar, int); +short __ovld __conv sub_group_rotate(short, int); +ushort __ovld __conv sub_group_rotate(ushort, int); +int __ovld __conv sub_group_rotate(int, int); +uint __ovld __conv sub_group_rotate(uint, int); +long __ovld __conv sub_group_rotate(long, int); +ulong __ovld __conv sub_group_rotate(ulong, int); +float __ovld __conv sub_group_rotate(float, int); +#if defined(cl_khr_fp64) +double __ovld __conv sub_group_rotate(double, int); +#endif // cl_khr_fp64 +#if defined(cl_khr_fp16) +half __ovld __conv sub_group_rotate(half, int); +#endif // cl_khr_fp16 + +char __ovld __conv sub_group_clustered_rotate(char, int, uint); +uchar __ovld __conv sub_group_clustered_rotate(uchar, int, uint); +short __ovld __conv sub_group_clustered_rotate(short, int, uint); +ushort __ovld __conv sub_group_clustered_rotate(ushort, int, uint); +int __ovld __conv sub_group_clustered_rotate(int, int, uint); +uint __ovld __conv sub_group_clustered_rotate(uint, int, uint); +long __ovld __conv sub_group_clustered_rotate(long, int, uint); +ulong __ovld __conv sub_group_clustered_rotate(ulong, int, uint); +float __ovld __conv sub_group_clustered_rotate(float, int, uint); +#if defined(cl_khr_fp64) +double __ovld __conv sub_group_clustered_rotate(double, int, uint); +#endif // cl_khr_fp64 +#if defined(cl_khr_fp16) +half __ovld __conv sub_group_clustered_rotate(half, int, uint); +#endif // cl_khr_fp16 +#endif // cl_khr_subgroup_rotate + +#if defined(cl_khr_kernel_clock) +#if defined(__opencl_c_kernel_clock_scope_device) +ulong __ovld clock_read_device(); +uint2 __ovld clock_read_hilo_device(); +#endif // __opencl_c_kernel_clock_scope_device +#if defined(__opencl_c_kernel_clock_scope_work_group) +ulong __ovld clock_read_work_group(); +uint2 __ovld clock_read_hilo_work_group(); +#endif // __opencl_c_kernel_clock_scope_work_group +#if defined(__opencl_c_kernel_clock_scope_sub_group) +ulong __ovld clock_read_sub_group(); +uint2 __ovld clock_read_hilo_sub_group(); +#endif // __opencl_c_kernel_clock_scope_sub_group +#endif // cl_khr_kernel_clock + +#if defined(cl_intel_subgroups) +// Intel-Specific Sub Group Functions +float __ovld __conv intel_sub_group_shuffle( float , uint ); +float2 __ovld __conv intel_sub_group_shuffle( float2, uint ); +float3 __ovld __conv intel_sub_group_shuffle( float3, uint ); +float4 __ovld __conv intel_sub_group_shuffle( float4, uint ); +float8 __ovld __conv intel_sub_group_shuffle( float8, uint ); +float16 __ovld __conv intel_sub_group_shuffle( float16, uint ); + +int __ovld __conv intel_sub_group_shuffle( int , uint ); +int2 __ovld __conv intel_sub_group_shuffle( int2, uint ); +int3 __ovld __conv intel_sub_group_shuffle( int3, uint ); +int4 __ovld __conv intel_sub_group_shuffle( int4, uint ); +int8 __ovld __conv intel_sub_group_shuffle( int8, uint ); +int16 __ovld __conv intel_sub_group_shuffle( int16, uint ); + +uint __ovld __conv intel_sub_group_shuffle( uint , uint ); +uint2 __ovld __conv intel_sub_group_shuffle( uint2, uint ); +uint3 __ovld __conv intel_sub_group_shuffle( uint3, uint ); +uint4 __ovld __conv intel_sub_group_shuffle( uint4, uint ); +uint8 __ovld __conv intel_sub_group_shuffle( uint8, uint ); +uint16 __ovld __conv intel_sub_group_shuffle( uint16, uint ); + +long __ovld __conv intel_sub_group_shuffle( long, uint ); +ulong __ovld __conv intel_sub_group_shuffle( ulong, uint ); + +float __ovld __conv intel_sub_group_shuffle_down( float cur, float next, uint ); +float2 __ovld __conv intel_sub_group_shuffle_down( float2 cur, float2 next, uint ); +float3 __ovld __conv intel_sub_group_shuffle_down( float3 cur, float3 next, uint ); +float4 __ovld __conv intel_sub_group_shuffle_down( float4 cur, float4 next, uint ); +float8 __ovld __conv intel_sub_group_shuffle_down( float8 cur, float8 next, uint ); +float16 __ovld __conv intel_sub_group_shuffle_down( float16 cur, float16 next, uint ); + +int __ovld __conv intel_sub_group_shuffle_down( int cur, int next, uint ); +int2 __ovld __conv intel_sub_group_shuffle_down( int2 cur, int2 next, uint ); +int3 __ovld __conv intel_sub_group_shuffle_down( int3 cur, int3 next, uint ); +int4 __ovld __conv intel_sub_group_shuffle_down( int4 cur, int4 next, uint ); +int8 __ovld __conv intel_sub_group_shuffle_down( int8 cur, int8 next, uint ); +int16 __ovld __conv intel_sub_group_shuffle_down( int16 cur, int16 next, uint ); + +uint __ovld __conv intel_sub_group_shuffle_down( uint cur, uint next, uint ); +uint2 __ovld __conv intel_sub_group_shuffle_down( uint2 cur, uint2 next, uint ); +uint3 __ovld __conv intel_sub_group_shuffle_down( uint3 cur, uint3 next, uint ); +uint4 __ovld __conv intel_sub_group_shuffle_down( uint4 cur, uint4 next, uint ); +uint8 __ovld __conv intel_sub_group_shuffle_down( uint8 cur, uint8 next, uint ); +uint16 __ovld __conv intel_sub_group_shuffle_down( uint16 cur, uint16 next, uint ); + +long __ovld __conv intel_sub_group_shuffle_down( long prev, long cur, uint ); +ulong __ovld __conv intel_sub_group_shuffle_down( ulong prev, ulong cur, uint ); + +float __ovld __conv intel_sub_group_shuffle_up( float prev, float cur, uint ); +float2 __ovld __conv intel_sub_group_shuffle_up( float2 prev, float2 cur, uint ); +float3 __ovld __conv intel_sub_group_shuffle_up( float3 prev, float3 cur, uint ); +float4 __ovld __conv intel_sub_group_shuffle_up( float4 prev, float4 cur, uint ); +float8 __ovld __conv intel_sub_group_shuffle_up( float8 prev, float8 cur, uint ); +float16 __ovld __conv intel_sub_group_shuffle_up( float16 prev, float16 cur, uint ); + +int __ovld __conv intel_sub_group_shuffle_up( int prev, int cur, uint ); +int2 __ovld __conv intel_sub_group_shuffle_up( int2 prev, int2 cur, uint ); +int3 __ovld __conv intel_sub_group_shuffle_up( int3 prev, int3 cur, uint ); +int4 __ovld __conv intel_sub_group_shuffle_up( int4 prev, int4 cur, uint ); +int8 __ovld __conv intel_sub_group_shuffle_up( int8 prev, int8 cur, uint ); +int16 __ovld __conv intel_sub_group_shuffle_up( int16 prev, int16 cur, uint ); + +uint __ovld __conv intel_sub_group_shuffle_up( uint prev, uint cur, uint ); +uint2 __ovld __conv intel_sub_group_shuffle_up( uint2 prev, uint2 cur, uint ); +uint3 __ovld __conv intel_sub_group_shuffle_up( uint3 prev, uint3 cur, uint ); +uint4 __ovld __conv intel_sub_group_shuffle_up( uint4 prev, uint4 cur, uint ); +uint8 __ovld __conv intel_sub_group_shuffle_up( uint8 prev, uint8 cur, uint ); +uint16 __ovld __conv intel_sub_group_shuffle_up( uint16 prev, uint16 cur, uint ); + +long __ovld __conv intel_sub_group_shuffle_up( long prev, long cur, uint ); +ulong __ovld __conv intel_sub_group_shuffle_up( ulong prev, ulong cur, uint ); + +float __ovld __conv intel_sub_group_shuffle_xor( float , uint ); +float2 __ovld __conv intel_sub_group_shuffle_xor( float2, uint ); +float3 __ovld __conv intel_sub_group_shuffle_xor( float3, uint ); +float4 __ovld __conv intel_sub_group_shuffle_xor( float4, uint ); +float8 __ovld __conv intel_sub_group_shuffle_xor( float8, uint ); +float16 __ovld __conv intel_sub_group_shuffle_xor( float16, uint ); + +int __ovld __conv intel_sub_group_shuffle_xor( int , uint ); +int2 __ovld __conv intel_sub_group_shuffle_xor( int2, uint ); +int3 __ovld __conv intel_sub_group_shuffle_xor( int3, uint ); +int4 __ovld __conv intel_sub_group_shuffle_xor( int4, uint ); +int8 __ovld __conv intel_sub_group_shuffle_xor( int8, uint ); +int16 __ovld __conv intel_sub_group_shuffle_xor( int16, uint ); + +uint __ovld __conv intel_sub_group_shuffle_xor( uint , uint ); +uint2 __ovld __conv intel_sub_group_shuffle_xor( uint2, uint ); +uint3 __ovld __conv intel_sub_group_shuffle_xor( uint3, uint ); +uint4 __ovld __conv intel_sub_group_shuffle_xor( uint4, uint ); +uint8 __ovld __conv intel_sub_group_shuffle_xor( uint8, uint ); +uint16 __ovld __conv intel_sub_group_shuffle_xor( uint16, uint ); + +long __ovld __conv intel_sub_group_shuffle_xor( long, uint ); +ulong __ovld __conv intel_sub_group_shuffle_xor( ulong, uint ); + +#if defined(__opencl_c_images) +uint __ovld __conv intel_sub_group_block_read(read_only image2d_t, int2); +uint2 __ovld __conv intel_sub_group_block_read2(read_only image2d_t, int2); +uint4 __ovld __conv intel_sub_group_block_read4(read_only image2d_t, int2); +uint8 __ovld __conv intel_sub_group_block_read8(read_only image2d_t, int2); +#endif + +#if defined(__opencl_c_read_write_images) +uint __ovld __conv intel_sub_group_block_read(read_write image2d_t, int2); +uint2 __ovld __conv intel_sub_group_block_read2(read_write image2d_t, int2); +uint4 __ovld __conv intel_sub_group_block_read4(read_write image2d_t, int2); +uint8 __ovld __conv intel_sub_group_block_read8(read_write image2d_t, int2); +#endif // defined(__opencl_c_read_write_images) + +uint __ovld __conv intel_sub_group_block_read( const __global uint* p ); +uint2 __ovld __conv intel_sub_group_block_read2( const __global uint* p ); +uint4 __ovld __conv intel_sub_group_block_read4( const __global uint* p ); +uint8 __ovld __conv intel_sub_group_block_read8( const __global uint* p ); + +#if defined(__opencl_c_images) +void __ovld __conv intel_sub_group_block_write(write_only image2d_t, int2, uint); +void __ovld __conv intel_sub_group_block_write2(write_only image2d_t, int2, uint2); +void __ovld __conv intel_sub_group_block_write4(write_only image2d_t, int2, uint4); +void __ovld __conv intel_sub_group_block_write8(write_only image2d_t, int2, uint8); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +void __ovld __conv intel_sub_group_block_write(read_write image2d_t, int2, uint); +void __ovld __conv intel_sub_group_block_write2(read_write image2d_t, int2, uint2); +void __ovld __conv intel_sub_group_block_write4(read_write image2d_t, int2, uint4); +void __ovld __conv intel_sub_group_block_write8(read_write image2d_t, int2, uint8); +#endif // defined(__opencl_c_read_write_images) + +void __ovld __conv intel_sub_group_block_write( __global uint* p, uint data ); +void __ovld __conv intel_sub_group_block_write2( __global uint* p, uint2 data ); +void __ovld __conv intel_sub_group_block_write4( __global uint* p, uint4 data ); +void __ovld __conv intel_sub_group_block_write8( __global uint* p, uint8 data ); + +#ifdef cl_khr_fp16 +half __ovld __conv intel_sub_group_shuffle( half, uint ); +half __ovld __conv intel_sub_group_shuffle_down( half prev, half cur, uint ); +half __ovld __conv intel_sub_group_shuffle_up( half prev, half cur, uint ); +half __ovld __conv intel_sub_group_shuffle_xor( half, uint ); +#endif + +#if defined(cl_khr_fp64) +double __ovld __conv intel_sub_group_shuffle( double, uint ); +double __ovld __conv intel_sub_group_shuffle_down( double prev, double cur, uint ); +double __ovld __conv intel_sub_group_shuffle_up( double prev, double cur, uint ); +double __ovld __conv intel_sub_group_shuffle_xor( double, uint ); +#endif + +#if defined(cl_intel_subgroups_char) || defined(cl_intel_subgroups_short) || \ + defined(cl_intel_subgroups_long) + +#if defined(__opencl_c_images) +uint __ovld __conv intel_sub_group_block_read_ui(read_only image2d_t, int2); +uint2 __ovld __conv intel_sub_group_block_read_ui2(read_only image2d_t, int2); +uint4 __ovld __conv intel_sub_group_block_read_ui4(read_only image2d_t, int2); +uint8 __ovld __conv intel_sub_group_block_read_ui8(read_only image2d_t, int2); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +uint __ovld __conv intel_sub_group_block_read_ui(read_write image2d_t, int2); +uint2 __ovld __conv intel_sub_group_block_read_ui2(read_write image2d_t, int2); +uint4 __ovld __conv intel_sub_group_block_read_ui4(read_write image2d_t, int2); +uint8 __ovld __conv intel_sub_group_block_read_ui8(read_write image2d_t, int2); +#endif // defined(__opencl_c_read_write_images) + +uint __ovld __conv intel_sub_group_block_read_ui( const __global uint* p ); +uint2 __ovld __conv intel_sub_group_block_read_ui2( const __global uint* p ); +uint4 __ovld __conv intel_sub_group_block_read_ui4( const __global uint* p ); +uint8 __ovld __conv intel_sub_group_block_read_ui8( const __global uint* p ); + +#if defined(__opencl_c_images) +void __ovld __conv intel_sub_group_block_write_ui(read_only image2d_t, int2, uint); +void __ovld __conv intel_sub_group_block_write_ui2(read_only image2d_t, int2, uint2); +void __ovld __conv intel_sub_group_block_write_ui4(read_only image2d_t, int2, uint4); +void __ovld __conv intel_sub_group_block_write_ui8(read_only image2d_t, int2, uint8); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +void __ovld __conv intel_sub_group_block_write_ui(read_write image2d_t, int2, uint); +void __ovld __conv intel_sub_group_block_write_ui2(read_write image2d_t, int2, uint2); +void __ovld __conv intel_sub_group_block_write_ui4(read_write image2d_t, int2, uint4); +void __ovld __conv intel_sub_group_block_write_ui8(read_write image2d_t, int2, uint8); +#endif // defined(__opencl_c_read_write_images) + +void __ovld __conv intel_sub_group_block_write_ui( __global uint* p, uint data ); +void __ovld __conv intel_sub_group_block_write_ui2( __global uint* p, uint2 data ); +void __ovld __conv intel_sub_group_block_write_ui4( __global uint* p, uint4 data ); +void __ovld __conv intel_sub_group_block_write_ui8( __global uint* p, uint8 data ); + +#endif // defined(cl_intel_subgroups_char) || defined(cl_intel_subgroups_short) || + // defined(cl_intel_subgroups_long) +#endif // cl_intel_subgroups + +#if defined(cl_intel_subgroups_short) +short __ovld __conv intel_sub_group_broadcast( short , uint sub_group_local_id ); +short2 __ovld __conv intel_sub_group_broadcast( short2, uint sub_group_local_id ); +short3 __ovld __conv intel_sub_group_broadcast( short3, uint sub_group_local_id ); +short4 __ovld __conv intel_sub_group_broadcast( short4, uint sub_group_local_id ); +short8 __ovld __conv intel_sub_group_broadcast( short8, uint sub_group_local_id ); + +ushort __ovld __conv intel_sub_group_broadcast( ushort , uint sub_group_local_id ); +ushort2 __ovld __conv intel_sub_group_broadcast( ushort2, uint sub_group_local_id ); +ushort3 __ovld __conv intel_sub_group_broadcast( ushort3, uint sub_group_local_id ); +ushort4 __ovld __conv intel_sub_group_broadcast( ushort4, uint sub_group_local_id ); +ushort8 __ovld __conv intel_sub_group_broadcast( ushort8, uint sub_group_local_id ); + +short __ovld __conv intel_sub_group_shuffle( short , uint ); +short2 __ovld __conv intel_sub_group_shuffle( short2 , uint ); +short3 __ovld __conv intel_sub_group_shuffle( short3 , uint ); +short4 __ovld __conv intel_sub_group_shuffle( short4 , uint ); +short8 __ovld __conv intel_sub_group_shuffle( short8 , uint ); +short16 __ovld __conv intel_sub_group_shuffle( short16, uint); + +ushort __ovld __conv intel_sub_group_shuffle( ushort , uint ); +ushort2 __ovld __conv intel_sub_group_shuffle( ushort2 , uint ); +ushort3 __ovld __conv intel_sub_group_shuffle( ushort3 , uint ); +ushort4 __ovld __conv intel_sub_group_shuffle( ushort4 , uint ); +ushort8 __ovld __conv intel_sub_group_shuffle( ushort8 , uint ); +ushort16 __ovld __conv intel_sub_group_shuffle( ushort16, uint ); + +short __ovld __conv intel_sub_group_shuffle_down( short cur, short next, uint ); +short2 __ovld __conv intel_sub_group_shuffle_down( short2 cur, short2 next, uint ); +short3 __ovld __conv intel_sub_group_shuffle_down( short3 cur, short3 next, uint ); +short4 __ovld __conv intel_sub_group_shuffle_down( short4 cur, short4 next, uint ); +short8 __ovld __conv intel_sub_group_shuffle_down( short8 cur, short8 next, uint ); +short16 __ovld __conv intel_sub_group_shuffle_down( short16 cur, short16 next, uint ); + +ushort __ovld __conv intel_sub_group_shuffle_down( ushort cur, ushort next, uint ); +ushort2 __ovld __conv intel_sub_group_shuffle_down( ushort2 cur, ushort2 next, uint ); +ushort3 __ovld __conv intel_sub_group_shuffle_down( ushort3 cur, ushort3 next, uint ); +ushort4 __ovld __conv intel_sub_group_shuffle_down( ushort4 cur, ushort4 next, uint ); +ushort8 __ovld __conv intel_sub_group_shuffle_down( ushort8 cur, ushort8 next, uint ); +ushort16 __ovld __conv intel_sub_group_shuffle_down( ushort16 cur, ushort16 next, uint ); + +short __ovld __conv intel_sub_group_shuffle_up( short cur, short next, uint ); +short2 __ovld __conv intel_sub_group_shuffle_up( short2 cur, short2 next, uint ); +short3 __ovld __conv intel_sub_group_shuffle_up( short3 cur, short3 next, uint ); +short4 __ovld __conv intel_sub_group_shuffle_up( short4 cur, short4 next, uint ); +short8 __ovld __conv intel_sub_group_shuffle_up( short8 cur, short8 next, uint ); +short16 __ovld __conv intel_sub_group_shuffle_up( short16 cur, short16 next, uint ); + +ushort __ovld __conv intel_sub_group_shuffle_up( ushort cur, ushort next, uint ); +ushort2 __ovld __conv intel_sub_group_shuffle_up( ushort2 cur, ushort2 next, uint ); +ushort3 __ovld __conv intel_sub_group_shuffle_up( ushort3 cur, ushort3 next, uint ); +ushort4 __ovld __conv intel_sub_group_shuffle_up( ushort4 cur, ushort4 next, uint ); +ushort8 __ovld __conv intel_sub_group_shuffle_up( ushort8 cur, ushort8 next, uint ); +ushort16 __ovld __conv intel_sub_group_shuffle_up( ushort16 cur, ushort16 next, uint ); + +short __ovld __conv intel_sub_group_shuffle_xor( short , uint ); +short2 __ovld __conv intel_sub_group_shuffle_xor( short2 , uint ); +short3 __ovld __conv intel_sub_group_shuffle_xor( short3 , uint ); +short4 __ovld __conv intel_sub_group_shuffle_xor( short4 , uint ); +short8 __ovld __conv intel_sub_group_shuffle_xor( short8 , uint ); +short16 __ovld __conv intel_sub_group_shuffle_xor( short16, uint ); + +ushort __ovld __conv intel_sub_group_shuffle_xor( ushort , uint ); +ushort2 __ovld __conv intel_sub_group_shuffle_xor( ushort2 , uint ); +ushort3 __ovld __conv intel_sub_group_shuffle_xor( ushort3 , uint ); +ushort4 __ovld __conv intel_sub_group_shuffle_xor( ushort4 , uint ); +ushort8 __ovld __conv intel_sub_group_shuffle_xor( ushort8 , uint ); +ushort16 __ovld __conv intel_sub_group_shuffle_xor( ushort16, uint ); + +short __ovld __conv intel_sub_group_reduce_add( short x ); +ushort __ovld __conv intel_sub_group_reduce_add( ushort x ); +short __ovld __conv intel_sub_group_reduce_min( short x ); +ushort __ovld __conv intel_sub_group_reduce_min( ushort x ); +short __ovld __conv intel_sub_group_reduce_max( short x ); +ushort __ovld __conv intel_sub_group_reduce_max( ushort x ); + +short __ovld __conv intel_sub_group_scan_exclusive_add( short x ); +ushort __ovld __conv intel_sub_group_scan_exclusive_add( ushort x ); +short __ovld __conv intel_sub_group_scan_exclusive_min( short x ); +ushort __ovld __conv intel_sub_group_scan_exclusive_min( ushort x ); +short __ovld __conv intel_sub_group_scan_exclusive_max( short x ); +ushort __ovld __conv intel_sub_group_scan_exclusive_max( ushort x ); + +short __ovld __conv intel_sub_group_scan_inclusive_add( short x ); +ushort __ovld __conv intel_sub_group_scan_inclusive_add( ushort x ); +short __ovld __conv intel_sub_group_scan_inclusive_min( short x ); +ushort __ovld __conv intel_sub_group_scan_inclusive_min( ushort x ); +short __ovld __conv intel_sub_group_scan_inclusive_max( short x ); +ushort __ovld __conv intel_sub_group_scan_inclusive_max( ushort x ); + +#if defined(__opencl_c_images) +ushort __ovld __conv intel_sub_group_block_read_us(read_only image2d_t, int2); +ushort2 __ovld __conv intel_sub_group_block_read_us2(read_only image2d_t, int2); +ushort4 __ovld __conv intel_sub_group_block_read_us4(read_only image2d_t, int2); +ushort8 __ovld __conv intel_sub_group_block_read_us8(read_only image2d_t, int2); +ushort16 __ovld __conv intel_sub_group_block_read_us16(read_only image2d_t, int2); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +ushort __ovld __conv intel_sub_group_block_read_us(read_write image2d_t, int2); +ushort2 __ovld __conv intel_sub_group_block_read_us2(read_write image2d_t, int2); +ushort4 __ovld __conv intel_sub_group_block_read_us4(read_write image2d_t, int2); +ushort8 __ovld __conv intel_sub_group_block_read_us8(read_write image2d_t, int2); +ushort16 __ovld __conv intel_sub_group_block_read_us16(read_write image2d_t, int2); +#endif // defined(__opencl_c_read_write_images) + +ushort __ovld __conv intel_sub_group_block_read_us( const __global ushort* p ); +ushort2 __ovld __conv intel_sub_group_block_read_us2( const __global ushort* p ); +ushort4 __ovld __conv intel_sub_group_block_read_us4( const __global ushort* p ); +ushort8 __ovld __conv intel_sub_group_block_read_us8( const __global ushort* p ); +ushort16 __ovld __conv intel_sub_group_block_read_us16(const __global ushort* p); + +#if defined(__opencl_c_images) +void __ovld __conv intel_sub_group_block_write_us(write_only image2d_t, int2, ushort); +void __ovld __conv intel_sub_group_block_write_us2(write_only image2d_t, int2, ushort2); +void __ovld __conv intel_sub_group_block_write_us4(write_only image2d_t, int2, ushort4); +void __ovld __conv intel_sub_group_block_write_us8(write_only image2d_t, int2, ushort8); +void __ovld __conv intel_sub_group_block_write_us16(write_only image2d_t, int2, ushort16); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +void __ovld __conv intel_sub_group_block_write_us(read_write image2d_t, int2, ushort); +void __ovld __conv intel_sub_group_block_write_us2(read_write image2d_t, int2, ushort2); +void __ovld __conv intel_sub_group_block_write_us4(read_write image2d_t, int2, ushort4); +void __ovld __conv intel_sub_group_block_write_us8(read_write image2d_t, int2, ushort8); +void __ovld __conv intel_sub_group_block_write_us16(read_write image2d_t, int2, ushort16); +#endif // defined(__opencl_c_read_write_images) + +void __ovld __conv intel_sub_group_block_write_us( __global ushort* p, ushort data ); +void __ovld __conv intel_sub_group_block_write_us2( __global ushort* p, ushort2 data ); +void __ovld __conv intel_sub_group_block_write_us4( __global ushort* p, ushort4 data ); +void __ovld __conv intel_sub_group_block_write_us8( __global ushort* p, ushort8 data ); +void __ovld __conv intel_sub_group_block_write_us16( __global ushort* p, ushort16 data ); +#endif // cl_intel_subgroups_short + +#if defined(cl_intel_subgroups_char) +char __ovld __conv intel_sub_group_broadcast( char , uint sub_group_local_id ); +char2 __ovld __conv intel_sub_group_broadcast( char2, uint sub_group_local_id ); +char3 __ovld __conv intel_sub_group_broadcast( char3, uint sub_group_local_id ); +char4 __ovld __conv intel_sub_group_broadcast( char4, uint sub_group_local_id ); +char8 __ovld __conv intel_sub_group_broadcast( char8, uint sub_group_local_id ); + +uchar __ovld __conv intel_sub_group_broadcast( uchar , uint sub_group_local_id ); +uchar2 __ovld __conv intel_sub_group_broadcast( uchar2, uint sub_group_local_id ); +uchar3 __ovld __conv intel_sub_group_broadcast( uchar3, uint sub_group_local_id ); +uchar4 __ovld __conv intel_sub_group_broadcast( uchar4, uint sub_group_local_id ); +uchar8 __ovld __conv intel_sub_group_broadcast( uchar8, uint sub_group_local_id ); + +char __ovld __conv intel_sub_group_shuffle( char , uint ); +char2 __ovld __conv intel_sub_group_shuffle( char2 , uint ); +char3 __ovld __conv intel_sub_group_shuffle( char3 , uint ); +char4 __ovld __conv intel_sub_group_shuffle( char4 , uint ); +char8 __ovld __conv intel_sub_group_shuffle( char8 , uint ); +char16 __ovld __conv intel_sub_group_shuffle( char16, uint); + +uchar __ovld __conv intel_sub_group_shuffle( uchar , uint ); +uchar2 __ovld __conv intel_sub_group_shuffle( uchar2 , uint ); +uchar3 __ovld __conv intel_sub_group_shuffle( uchar3 , uint ); +uchar4 __ovld __conv intel_sub_group_shuffle( uchar4 , uint ); +uchar8 __ovld __conv intel_sub_group_shuffle( uchar8 , uint ); +uchar16 __ovld __conv intel_sub_group_shuffle( uchar16, uint ); + +char __ovld __conv intel_sub_group_shuffle_down( char cur, char next, uint ); +char2 __ovld __conv intel_sub_group_shuffle_down( char2 cur, char2 next, uint ); +char3 __ovld __conv intel_sub_group_shuffle_down( char3 cur, char3 next, uint ); +char4 __ovld __conv intel_sub_group_shuffle_down( char4 cur, char4 next, uint ); +char8 __ovld __conv intel_sub_group_shuffle_down( char8 cur, char8 next, uint ); +char16 __ovld __conv intel_sub_group_shuffle_down( char16 cur, char16 next, uint ); + +uchar __ovld __conv intel_sub_group_shuffle_down( uchar cur, uchar next, uint ); +uchar2 __ovld __conv intel_sub_group_shuffle_down( uchar2 cur, uchar2 next, uint ); +uchar3 __ovld __conv intel_sub_group_shuffle_down( uchar3 cur, uchar3 next, uint ); +uchar4 __ovld __conv intel_sub_group_shuffle_down( uchar4 cur, uchar4 next, uint ); +uchar8 __ovld __conv intel_sub_group_shuffle_down( uchar8 cur, uchar8 next, uint ); +uchar16 __ovld __conv intel_sub_group_shuffle_down( uchar16 cur, uchar16 next, uint ); + +char __ovld __conv intel_sub_group_shuffle_up( char cur, char next, uint ); +char2 __ovld __conv intel_sub_group_shuffle_up( char2 cur, char2 next, uint ); +char3 __ovld __conv intel_sub_group_shuffle_up( char3 cur, char3 next, uint ); +char4 __ovld __conv intel_sub_group_shuffle_up( char4 cur, char4 next, uint ); +char8 __ovld __conv intel_sub_group_shuffle_up( char8 cur, char8 next, uint ); +char16 __ovld __conv intel_sub_group_shuffle_up( char16 cur, char16 next, uint ); + +uchar __ovld __conv intel_sub_group_shuffle_up( uchar cur, uchar next, uint ); +uchar2 __ovld __conv intel_sub_group_shuffle_up( uchar2 cur, uchar2 next, uint ); +uchar3 __ovld __conv intel_sub_group_shuffle_up( uchar3 cur, uchar3 next, uint ); +uchar4 __ovld __conv intel_sub_group_shuffle_up( uchar4 cur, uchar4 next, uint ); +uchar8 __ovld __conv intel_sub_group_shuffle_up( uchar8 cur, uchar8 next, uint ); +uchar16 __ovld __conv intel_sub_group_shuffle_up( uchar16 cur, uchar16 next, uint ); + +char __ovld __conv intel_sub_group_shuffle_xor( char , uint ); +char2 __ovld __conv intel_sub_group_shuffle_xor( char2 , uint ); +char3 __ovld __conv intel_sub_group_shuffle_xor( char3 , uint ); +char4 __ovld __conv intel_sub_group_shuffle_xor( char4 , uint ); +char8 __ovld __conv intel_sub_group_shuffle_xor( char8 , uint ); +char16 __ovld __conv intel_sub_group_shuffle_xor( char16, uint ); + +uchar __ovld __conv intel_sub_group_shuffle_xor( uchar , uint ); +uchar2 __ovld __conv intel_sub_group_shuffle_xor( uchar2 , uint ); +uchar3 __ovld __conv intel_sub_group_shuffle_xor( uchar3 , uint ); +uchar4 __ovld __conv intel_sub_group_shuffle_xor( uchar4 , uint ); +uchar8 __ovld __conv intel_sub_group_shuffle_xor( uchar8 , uint ); +uchar16 __ovld __conv intel_sub_group_shuffle_xor( uchar16, uint ); + +char __ovld __conv intel_sub_group_reduce_add( char x ); +uchar __ovld __conv intel_sub_group_reduce_add( uchar x ); +char __ovld __conv intel_sub_group_reduce_min( char x ); +uchar __ovld __conv intel_sub_group_reduce_min( uchar x ); +char __ovld __conv intel_sub_group_reduce_max( char x ); +uchar __ovld __conv intel_sub_group_reduce_max( uchar x ); + +char __ovld __conv intel_sub_group_scan_exclusive_add( char x ); +uchar __ovld __conv intel_sub_group_scan_exclusive_add( uchar x ); +char __ovld __conv intel_sub_group_scan_exclusive_min( char x ); +uchar __ovld __conv intel_sub_group_scan_exclusive_min( uchar x ); +char __ovld __conv intel_sub_group_scan_exclusive_max( char x ); +uchar __ovld __conv intel_sub_group_scan_exclusive_max( uchar x ); + +char __ovld __conv intel_sub_group_scan_inclusive_add( char x ); +uchar __ovld __conv intel_sub_group_scan_inclusive_add( uchar x ); +char __ovld __conv intel_sub_group_scan_inclusive_min( char x ); +uchar __ovld __conv intel_sub_group_scan_inclusive_min( uchar x ); +char __ovld __conv intel_sub_group_scan_inclusive_max( char x ); +uchar __ovld __conv intel_sub_group_scan_inclusive_max( uchar x ); + +#if defined(__opencl_c_images) +uchar __ovld __conv intel_sub_group_block_read_uc(read_only image2d_t, int2); +uchar2 __ovld __conv intel_sub_group_block_read_uc2(read_only image2d_t, int2); +uchar4 __ovld __conv intel_sub_group_block_read_uc4(read_only image2d_t, int2); +uchar8 __ovld __conv intel_sub_group_block_read_uc8(read_only image2d_t, int2); +uchar16 __ovld __conv intel_sub_group_block_read_uc16(read_only image2d_t, int2); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +uchar __ovld __conv intel_sub_group_block_read_uc(read_write image2d_t, int2); +uchar2 __ovld __conv intel_sub_group_block_read_uc2(read_write image2d_t, int2); +uchar4 __ovld __conv intel_sub_group_block_read_uc4(read_write image2d_t, int2); +uchar8 __ovld __conv intel_sub_group_block_read_uc8(read_write image2d_t, int2); +uchar16 __ovld __conv intel_sub_group_block_read_uc16(read_write image2d_t, int2); +#endif // defined(__opencl_c_read_write_images) + +uchar __ovld __conv intel_sub_group_block_read_uc( const __global uchar* p ); +uchar2 __ovld __conv intel_sub_group_block_read_uc2( const __global uchar* p ); +uchar4 __ovld __conv intel_sub_group_block_read_uc4( const __global uchar* p ); +uchar8 __ovld __conv intel_sub_group_block_read_uc8( const __global uchar* p ); +uchar16 __ovld __conv intel_sub_group_block_read_uc16( const __global uchar* p ); + +#if defined(__opencl_c_images) +void __ovld __conv intel_sub_group_block_write_uc(write_only image2d_t, int2, uchar); +void __ovld __conv intel_sub_group_block_write_uc2(write_only image2d_t, int2, uchar2); +void __ovld __conv intel_sub_group_block_write_uc4(write_only image2d_t, int2, uchar4); +void __ovld __conv intel_sub_group_block_write_uc8(write_only image2d_t, int2, uchar8); +void __ovld __conv intel_sub_group_block_write_uc16(write_only image2d_t, int2, uchar16); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +void __ovld __conv intel_sub_group_block_write_uc(read_write image2d_t, int2, uchar); +void __ovld __conv intel_sub_group_block_write_uc2(read_write image2d_t, int2, uchar2); +void __ovld __conv intel_sub_group_block_write_uc4(read_write image2d_t, int2, uchar4); +void __ovld __conv intel_sub_group_block_write_uc8(read_write image2d_t, int2, uchar8); +void __ovld __conv intel_sub_group_block_write_uc16(read_write image2d_t, int2, uchar16); +#endif // defined(__opencl_c_read_write_images) + +void __ovld __conv intel_sub_group_block_write_uc( __global uchar* p, uchar data ); +void __ovld __conv intel_sub_group_block_write_uc2( __global uchar* p, uchar2 data ); +void __ovld __conv intel_sub_group_block_write_uc4( __global uchar* p, uchar4 data ); +void __ovld __conv intel_sub_group_block_write_uc8( __global uchar* p, uchar8 data ); +void __ovld __conv intel_sub_group_block_write_uc16( __global uchar* p, uchar16 data ); +#endif // cl_intel_subgroups_char + +#if defined(cl_intel_subgroups_long) +#if defined(__opencl_c_images) +ulong __ovld __conv intel_sub_group_block_read_ul(read_only image2d_t, int2); +ulong2 __ovld __conv intel_sub_group_block_read_ul2(read_only image2d_t, int2); +ulong4 __ovld __conv intel_sub_group_block_read_ul4(read_only image2d_t, int2); +ulong8 __ovld __conv intel_sub_group_block_read_ul8(read_only image2d_t, int2); +ulong16 __ovld __conv intel_sub_group_block_read_ul16(read_only image2d_t, int2); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +ulong __ovld __conv intel_sub_group_block_read_ul(read_write image2d_t, int2); +ulong2 __ovld __conv intel_sub_group_block_read_ul2(read_write image2d_t, int2); +ulong4 __ovld __conv intel_sub_group_block_read_ul4(read_write image2d_t, int2); +ulong8 __ovld __conv intel_sub_group_block_read_ul8(read_write image2d_t, int2); +ulong16 __ovld __conv intel_sub_group_block_read_ul16(read_write image2d_t, int2); +#endif // defined(__opencl_c_read_write_images) + +ulong __ovld __conv intel_sub_group_block_read_ul( const __global ulong* p ); +ulong2 __ovld __conv intel_sub_group_block_read_ul2( const __global ulong* p ); +ulong4 __ovld __conv intel_sub_group_block_read_ul4( const __global ulong* p ); +ulong8 __ovld __conv intel_sub_group_block_read_ul8( const __global ulong* p ); + +#if defined(__opencl_c_images) +void __ovld __conv intel_sub_group_block_write_ul(write_only image2d_t, int2, ulong); +void __ovld __conv intel_sub_group_block_write_ul2(write_only image2d_t, int2, ulong2); +void __ovld __conv intel_sub_group_block_write_ul4(write_only image2d_t, int2, ulong4); +void __ovld __conv intel_sub_group_block_write_ul8(write_only image2d_t, int2, ulong8); +void __ovld __conv intel_sub_group_block_write_ul16(write_only image2d_t, int2, ulong16); +#endif // defined(__opencl_c_images) + +#if defined(__opencl_c_read_write_images) +void __ovld __conv intel_sub_group_block_write_ul(read_write image2d_t, int2, ulong); +void __ovld __conv intel_sub_group_block_write_ul2(read_write image2d_t, int2, ulong2); +void __ovld __conv intel_sub_group_block_write_ul4(read_write image2d_t, int2, ulong4); +void __ovld __conv intel_sub_group_block_write_ul8(read_write image2d_t, int2, ulong8); +void __ovld __conv intel_sub_group_block_write_ul16(read_write image2d_t, int2, ulong16); +#endif // defined(__opencl_c_read_write_images) + +void __ovld __conv intel_sub_group_block_write_ul( __global ulong* p, ulong data ); +void __ovld __conv intel_sub_group_block_write_ul2( __global ulong* p, ulong2 data ); +void __ovld __conv intel_sub_group_block_write_ul4( __global ulong* p, ulong4 data ); +void __ovld __conv intel_sub_group_block_write_ul8( __global ulong* p, ulong8 data); +#endif // cl_intel_subgroups_long + +#if defined(cl_intel_subgroup_local_block_io) +uint __ovld __conv intel_sub_group_block_read( const __local uint* p ); +uint2 __ovld __conv intel_sub_group_block_read2( const __local uint* p ); +uint4 __ovld __conv intel_sub_group_block_read4( const __local uint* p ); +uint8 __ovld __conv intel_sub_group_block_read8( const __local uint* p ); + +void __ovld __conv intel_sub_group_block_write( __local uint* p, uint data ); +void __ovld __conv intel_sub_group_block_write2( __local uint* p, uint2 data ); +void __ovld __conv intel_sub_group_block_write4( __local uint* p, uint4 data ); +void __ovld __conv intel_sub_group_block_write8( __local uint* p, uint8 data ); + +#if defined(cl_intel_subgroups_char) || defined(cl_intel_subgroups_short) || \ + defined(cl_intel_subgroups_long) +uint __ovld __conv intel_sub_group_block_read_ui( const __local uint* p ); +uint2 __ovld __conv intel_sub_group_block_read_ui2( const __local uint* p ); +uint4 __ovld __conv intel_sub_group_block_read_ui4( const __local uint* p ); +uint8 __ovld __conv intel_sub_group_block_read_ui8( const __local uint* p ); + +void __ovld __conv intel_sub_group_block_write_ui( __local uint* p, uint data ); +void __ovld __conv intel_sub_group_block_write_ui2( __local uint* p, uint2 data ); +void __ovld __conv intel_sub_group_block_write_ui4( __local uint* p, uint4 data ); +void __ovld __conv intel_sub_group_block_write_ui8( __local uint* p, uint8 data ); +#endif // defined(cl_intel_subgroups_char) || defined(cl_intel_subgroups_short) || + // defined(cl_intel_subgroups_long) + +#if defined(cl_intel_subgroups_char) +uchar __ovld __conv intel_sub_group_block_read_uc( const __local uchar* p ); +uchar2 __ovld __conv intel_sub_group_block_read_uc2( const __local uchar* p ); +uchar4 __ovld __conv intel_sub_group_block_read_uc4( const __local uchar* p ); +uchar8 __ovld __conv intel_sub_group_block_read_uc8( const __local uchar* p ); +uchar16 __ovld __conv intel_sub_group_block_read_uc16( const __local uchar* p ); + +void __ovld __conv intel_sub_group_block_write_uc( __local uchar* p, uchar data ); +void __ovld __conv intel_sub_group_block_write_uc2( __local uchar* p, uchar2 data ); +void __ovld __conv intel_sub_group_block_write_uc4( __local uchar* p, uchar4 data ); +void __ovld __conv intel_sub_group_block_write_uc8( __local uchar* p, uchar8 data ); +void __ovld __conv intel_sub_group_block_write_uc16( __local uchar* p, uchar16 data ); +#endif // defined(cl_intel_subgroups_char) + +#if defined(cl_intel_subgroups_short) +ushort __ovld __conv intel_sub_group_block_read_us( const __local ushort* p ); +ushort2 __ovld __conv intel_sub_group_block_read_us2( const __local ushort* p ); +ushort4 __ovld __conv intel_sub_group_block_read_us4( const __local ushort* p ); +ushort8 __ovld __conv intel_sub_group_block_read_us8( const __local ushort* p ); +ushort16 __ovld __conv intel_sub_group_block_read_us16( const __local ushort* p ); + +void __ovld __conv intel_sub_group_block_write_us( __local ushort* p, ushort data ); +void __ovld __conv intel_sub_group_block_write_us2( __local ushort* p, ushort2 data ); +void __ovld __conv intel_sub_group_block_write_us4( __local ushort* p, ushort4 data ); +void __ovld __conv intel_sub_group_block_write_us8( __local ushort* p, ushort8 data ); +void __ovld __conv intel_sub_group_block_write_us16( __local ushort* p, ushort16 data ); +#endif // defined(cl_intel_subgroups_short) + +#if defined(cl_intel_subgroups_long) +ulong __ovld __conv intel_sub_group_block_read_ul( const __local ulong* p ); +ulong2 __ovld __conv intel_sub_group_block_read_ul2( const __local ulong* p ); +ulong4 __ovld __conv intel_sub_group_block_read_ul4( const __local ulong* p ); +ulong8 __ovld __conv intel_sub_group_block_read_ul8( const __local ulong* p ); + +void __ovld __conv intel_sub_group_block_write_ul( __local ulong* p, ulong data ); +void __ovld __conv intel_sub_group_block_write_ul2( __local ulong* p, ulong2 data ); +void __ovld __conv intel_sub_group_block_write_ul4( __local ulong* p, ulong4 data ); +void __ovld __conv intel_sub_group_block_write_ul8( __local ulong* p, ulong8 data ); +#endif // defined(cl_intel_subgroups_long) +#endif // cl_intel_subgroup_local_block_io + +#ifdef cl_intel_device_side_avc_motion_estimation +#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin + +// MCE built-in functions +uchar __ovld +intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty( + uchar slice_type, uchar qp); +ulong __ovld intel_sub_group_avc_mce_get_default_inter_shape_penalty( + uchar slice_type, uchar qp); +uchar __ovld intel_sub_group_avc_mce_get_default_inter_direction_penalty( + uchar slice_type, uchar qp); +uint __ovld intel_sub_group_avc_mce_get_default_intra_luma_shape_penalty( + uchar slice_type, uchar qp); +uint2 __ovld +intel_sub_group_avc_mce_get_default_inter_motion_vector_cost_table( + uchar slice_type, uchar qp); +uchar __ovld intel_sub_group_avc_mce_get_default_intra_luma_mode_penalty( + uchar slice_type, uchar qp); + +uint2 __ovld intel_sub_group_avc_mce_get_default_high_penalty_cost_table(); +uint2 __ovld intel_sub_group_avc_mce_get_default_medium_penalty_cost_table(); +uint2 __ovld intel_sub_group_avc_mce_get_default_low_penalty_cost_table(); +uint __ovld intel_sub_group_avc_mce_get_default_non_dc_luma_intra_penalty(); +uchar __ovld +intel_sub_group_avc_mce_get_default_intra_chroma_mode_base_penalty(); + +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_inter_base_multi_reference_penalty( + uchar reference_base_penalty, intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_inter_shape_penalty( + ulong packed_shape_penalty, intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_inter_direction_penalty( + uchar direction_cost, intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_motion_vector_cost_function( + ulong packed_cost_center_delta, uint2 packed_cost_table, + uchar cost_precision, intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_ac_only_haar( + intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_source_interlaced_field_polarity( + uchar src_field_polarity, intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_single_reference_interlaced_field_polarity( + uchar ref_field_polarity, intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_mce_set_dual_reference_interlaced_field_polarities( + uchar fwd_ref_field_polarity, uchar bwd_ref_field_polarity, + intel_sub_group_avc_mce_payload_t payload); + +ulong __ovld intel_sub_group_avc_mce_get_motion_vectors( + intel_sub_group_avc_mce_result_t result); +ushort __ovld intel_sub_group_avc_mce_get_inter_distortions( + intel_sub_group_avc_mce_result_t result); +ushort __ovld intel_sub_group_avc_mce_get_best_inter_distortion( + intel_sub_group_avc_mce_result_t result); +uchar __ovld intel_sub_group_avc_mce_get_inter_major_shape( + intel_sub_group_avc_mce_result_t result); +uchar __ovld intel_sub_group_avc_mce_get_inter_minor_shapes( + intel_sub_group_avc_mce_result_t result); +uchar __ovld intel_sub_group_avc_mce_get_inter_directions( + intel_sub_group_avc_mce_result_t result); +uchar __ovld intel_sub_group_avc_mce_get_inter_motion_vector_count( + intel_sub_group_avc_mce_result_t result); +uint __ovld intel_sub_group_avc_mce_get_inter_reference_ids( + intel_sub_group_avc_mce_result_t result); +uchar __ovld +intel_sub_group_avc_mce_get_inter_reference_interlaced_field_polarities( + uint packed_reference_ids, uint packed_reference_parameter_field_polarities, + intel_sub_group_avc_mce_result_t result); + +// IME built-in functions +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_initialize( + ushort2 src_coord, uchar partition_mask, uchar sad_adjustment); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_single_reference( + short2 ref_offset, uchar search_window_config, + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_dual_reference( + short2 fwd_ref_offset, short2 bwd_ref_offset, uchar search_window_config, + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_max_motion_vector_count( + uchar max_motion_vector_count, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_unidirectional_mix_disable( + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_early_search_termination_threshold( + uchar threshold, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_weighted_sad( + uint packed_sad_weights, intel_sub_group_avc_ime_payload_t payload); + +__attribute__((deprecated("If you use the latest Intel driver, please use " + "intel_sub_group_avc_ime_ref_window_size instead", + "intel_sub_group_avc_ime_ref_window_size"))) +ushort2 __ovld +intel_sub_group_ime_ref_window_size(uchar search_window_config, char dual_ref); +ushort2 __ovld intel_sub_group_avc_ime_ref_window_size( + uchar search_window_config, char dual_ref); +short2 __ovld intel_sub_group_avc_ime_adjust_ref_offset( + short2 ref_offset, ushort2 src_coord, ushort2 ref_window_size, + ushort2 image_size); + +#if defined(__opencl_c_images) +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_ime_evaluate_with_single_reference( + read_only image2d_t src_image, read_only image2d_t ref_image, + sampler_t vme_media_sampler, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_ime_evaluate_with_dual_reference( + read_only image2d_t src_image, read_only image2d_t fwd_ref_image, + read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_result_single_reference_streamout_t __ovld +intel_sub_group_avc_ime_evaluate_with_single_reference_streamout( + read_only image2d_t src_image, read_only image2d_t ref_image, + sampler_t vme_media_sampler, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_result_dual_reference_streamout_t __ovld +intel_sub_group_avc_ime_evaluate_with_dual_reference_streamout( + read_only image2d_t src_image, read_only image2d_t fwd_ref_image, + read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_ime_evaluate_with_single_reference_streamin( + read_only image2d_t src_image, read_only image2d_t ref_image, + sampler_t vme_media_sampler, intel_sub_group_avc_ime_payload_t payload, + intel_sub_group_avc_ime_single_reference_streamin_t streamin_components); +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_ime_evaluate_with_dual_reference_streamin( + read_only image2d_t src_image, read_only image2d_t fwd_ref_image, + read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, + intel_sub_group_avc_ime_payload_t payload, + intel_sub_group_avc_ime_dual_reference_streamin_t streamin_components); +intel_sub_group_avc_ime_result_single_reference_streamout_t __ovld +intel_sub_group_avc_ime_evaluate_with_single_reference_streaminout( + read_only image2d_t src_image, read_only image2d_t ref_image, + sampler_t vme_media_sampler, intel_sub_group_avc_ime_payload_t payload, + intel_sub_group_avc_ime_single_reference_streamin_t streamin_components); +intel_sub_group_avc_ime_result_dual_reference_streamout_t __ovld +intel_sub_group_avc_ime_evaluate_with_dual_reference_streaminout( + read_only image2d_t src_image, read_only image2d_t fwd_ref_image, + read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, + intel_sub_group_avc_ime_payload_t payload, + intel_sub_group_avc_ime_dual_reference_streamin_t streamin_components); +#endif + +intel_sub_group_avc_ime_single_reference_streamin_t __ovld +intel_sub_group_avc_ime_get_single_reference_streamin( + intel_sub_group_avc_ime_result_single_reference_streamout_t result); +intel_sub_group_avc_ime_dual_reference_streamin_t __ovld +intel_sub_group_avc_ime_get_dual_reference_streamin( + intel_sub_group_avc_ime_result_dual_reference_streamout_t result); +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_ime_strip_single_reference_streamout( + intel_sub_group_avc_ime_result_single_reference_streamout_t result); +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_ime_strip_dual_reference_streamout( + intel_sub_group_avc_ime_result_dual_reference_streamout_t result); + +uint __ovld intel_sub_group_avc_ime_get_streamout_major_shape_motion_vectors( + intel_sub_group_avc_ime_result_single_reference_streamout_t result, + uchar major_shape); +ushort __ovld intel_sub_group_avc_ime_get_streamout_major_shape_distortions( + intel_sub_group_avc_ime_result_single_reference_streamout_t result, + uchar major_shape); +uchar __ovld intel_sub_group_avc_ime_get_streamout_major_shape_reference_ids( + intel_sub_group_avc_ime_result_single_reference_streamout_t result, + uchar major_shape); +uint __ovld intel_sub_group_avc_ime_get_streamout_major_shape_motion_vectors( + intel_sub_group_avc_ime_result_dual_reference_streamout_t result, + uchar major_shape, uchar direction); +ushort __ovld intel_sub_group_avc_ime_get_streamout_major_shape_distortions( + intel_sub_group_avc_ime_result_dual_reference_streamout_t result, + uchar major_shape, uchar direction); +uchar __ovld intel_sub_group_avc_ime_get_streamout_major_shape_reference_ids( + intel_sub_group_avc_ime_result_dual_reference_streamout_t result, + uchar major_shape, uchar direction); + +uchar __ovld intel_sub_group_avc_ime_get_border_reached( + uchar image_select, intel_sub_group_avc_ime_result_t result); +uchar __ovld intel_sub_group_avc_ime_get_truncated_search_indication( + intel_sub_group_avc_ime_result_t result); +uchar __ovld +intel_sub_group_avc_ime_get_unidirectional_early_search_termination( + intel_sub_group_avc_ime_result_t result); +uint __ovld intel_sub_group_avc_ime_get_weighting_pattern_minimum_motion_vector( + intel_sub_group_avc_ime_result_t result); +ushort __ovld intel_sub_group_avc_ime_get_weighting_pattern_minimum_distortion( + intel_sub_group_avc_ime_result_t result); + +// REF built-in functions +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_fme_initialize( + ushort2 src_coord, ulong motion_vectors, uchar major_shapes, + uchar minor_shapes, uchar directions, uchar pixel_resolution, + uchar sad_adjustment); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_bme_initialize( + ushort2 src_coord, ulong motion_vectors, uchar major_shapes, + uchar minor_shapes, uchar directions, uchar pixel_resolution, + uchar bidirectional_weight, uchar sad_adjustment); + +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_bidirectional_mix_disable( + intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_bilinear_filter_enable( + intel_sub_group_avc_ref_payload_t payload); + +#if defined(__opencl_c_images) +intel_sub_group_avc_ref_result_t __ovld +intel_sub_group_avc_ref_evaluate_with_single_reference( + read_only image2d_t src_image, read_only image2d_t ref_image, + sampler_t vme_media_sampler, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_ref_result_t __ovld +intel_sub_group_avc_ref_evaluate_with_dual_reference( + read_only image2d_t src_image, read_only image2d_t fwd_ref_image, + read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, + intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_ref_result_t __ovld +intel_sub_group_avc_ref_evaluate_with_multi_reference( + read_only image2d_t src_image, uint packed_reference_ids, + sampler_t vme_media_sampler, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_ref_result_t __ovld +intel_sub_group_avc_ref_evaluate_with_multi_reference( + read_only image2d_t src_image, uint packed_reference_ids, + uchar packed_reference_field_polarities, sampler_t vme_media_sampler, + intel_sub_group_avc_ref_payload_t payload); +#endif //defined(__opencl_c_images) + +// SIC built-in functions +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_initialize( + ushort2 src_coord); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_configure_skc( + uint skip_block_partition_type, uint skip_motion_vector_mask, + ulong motion_vectors, uchar bidirectional_weight, uchar skip_sad_adjustment, + intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld intel_sub_group_avc_sic_configure_ipe( + uchar luma_intra_partition_mask, uchar intra_neighbour_availability, + uchar left_edge_luma_pixels, uchar upper_left_corner_luma_pixel, + uchar upper_edge_luma_pixels, uchar upper_right_edge_luma_pixels, + uchar intra_sad_adjustment, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld intel_sub_group_avc_sic_configure_ipe( + uchar luma_intra_partition_mask, uchar intra_neighbour_availability, + uchar left_edge_luma_pixels, uchar upper_left_corner_luma_pixel, + uchar upper_edge_luma_pixels, uchar upper_right_edge_luma_pixels, + ushort left_edge_chroma_pixels, ushort upper_left_corner_chroma_pixel, + ushort upper_edge_chroma_pixels, uchar intra_sad_adjustment, + intel_sub_group_avc_sic_payload_t payload); +uint __ovld +intel_sub_group_avc_sic_get_motion_vector_mask( + uint skip_block_partition_type, uchar direction); + +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_intra_luma_shape_penalty( + uint packed_shape_cost, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_intra_luma_mode_cost_function( + uchar luma_mode_penalty, uint luma_packed_neighbor_modes, + uint luma_packed_non_dc_penalty, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_intra_chroma_mode_cost_function( + uchar chroma_mode_penalty, intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_skc_bilinear_filter_enable( + intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_skc_forward_transform_enable( + ulong packed_sad_coefficients, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_block_based_raw_skip_sad( + uchar block_based_skip_type, + intel_sub_group_avc_sic_payload_t payload); + +#if defined(__opencl_c_images) +intel_sub_group_avc_sic_result_t __ovld +intel_sub_group_avc_sic_evaluate_ipe( + read_only image2d_t src_image, sampler_t vme_media_sampler, + intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_result_t __ovld +intel_sub_group_avc_sic_evaluate_with_single_reference( + read_only image2d_t src_image, read_only image2d_t ref_image, + sampler_t vme_media_sampler, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_result_t __ovld +intel_sub_group_avc_sic_evaluate_with_dual_reference( + read_only image2d_t src_image, read_only image2d_t fwd_ref_image, + read_only image2d_t bwd_ref_image, sampler_t vme_media_sampler, + intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_result_t __ovld +intel_sub_group_avc_sic_evaluate_with_multi_reference( + read_only image2d_t src_image, uint packed_reference_ids, + sampler_t vme_media_sampler, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_result_t __ovld +intel_sub_group_avc_sic_evaluate_with_multi_reference( + read_only image2d_t src_image, uint packed_reference_ids, + uchar packed_reference_field_polarities, sampler_t vme_media_sampler, + intel_sub_group_avc_sic_payload_t payload); +#endif //defined(__opencl_c_images) + +uchar __ovld intel_sub_group_avc_sic_get_ipe_luma_shape( + intel_sub_group_avc_sic_result_t result); +ushort __ovld intel_sub_group_avc_sic_get_best_ipe_luma_distortion( + intel_sub_group_avc_sic_result_t result); +ushort __ovld intel_sub_group_avc_sic_get_best_ipe_chroma_distortion( + intel_sub_group_avc_sic_result_t result); +ulong __ovld intel_sub_group_avc_sic_get_packed_ipe_luma_modes( + intel_sub_group_avc_sic_result_t result); +uchar __ovld intel_sub_group_avc_sic_get_ipe_chroma_mode( + intel_sub_group_avc_sic_result_t result); +uint __ovld intel_sub_group_avc_sic_get_packed_skc_luma_count_threshold( + intel_sub_group_avc_sic_result_t result); +ulong __ovld intel_sub_group_avc_sic_get_packed_skc_luma_sum_threshold( + intel_sub_group_avc_sic_result_t result); +ushort __ovld intel_sub_group_avc_sic_get_inter_raw_sads( + intel_sub_group_avc_sic_result_t result); + +// Wrappers +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_inter_base_multi_reference_penalty( + uchar reference_base_penalty, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_inter_base_multi_reference_penalty( + uchar reference_base_penalty, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_inter_base_multi_reference_penalty( + uchar reference_base_penalty, intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_inter_shape_penalty( + ulong packed_shape_cost, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_inter_shape_penalty( + ulong packed_shape_cost, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_inter_shape_penalty( + ulong packed_shape_cost, intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_inter_direction_penalty( + uchar direction_cost, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_inter_direction_penalty( + uchar direction_cost, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_inter_direction_penalty( + uchar direction_cost, intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_motion_vector_cost_function( + ulong packed_cost_center_delta, uint2 packed_cost_table, + uchar cost_precision, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_motion_vector_cost_function( + ulong packed_cost_center_delta, uint2 packed_cost_table, + uchar cost_precision, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_motion_vector_cost_function( + ulong packed_cost_center_delta, uint2 packed_cost_table, + uchar cost_precision, intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_source_interlaced_field_polarity( + uchar src_field_polarity, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_source_interlaced_field_polarity( + uchar src_field_polarity, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_source_interlaced_field_polarity( + uchar src_field_polarity, intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_single_reference_interlaced_field_polarity( + uchar ref_field_polarity, intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_single_reference_interlaced_field_polarity( + uchar ref_field_polarity, intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_single_reference_interlaced_field_polarity( + uchar ref_field_polarity, intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_dual_reference_interlaced_field_polarities( + uchar fwd_ref_field_polarity, uchar bwd_ref_field_polarity, + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_dual_reference_interlaced_field_polarities( + uchar fwd_ref_field_polarity, uchar bwd_ref_field_polarity, + intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_dual_reference_interlaced_field_polarities( + uchar fwd_ref_field_polarity, uchar bwd_ref_field_polarity, + intel_sub_group_avc_sic_payload_t payload); + +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_ime_set_ac_only_haar( + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_ref_set_ac_only_haar( + intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_sic_set_ac_only_haar( + intel_sub_group_avc_sic_payload_t payload); + +ulong __ovld intel_sub_group_avc_ime_get_motion_vectors( + intel_sub_group_avc_ime_result_t result); +ulong __ovld intel_sub_group_avc_ref_get_motion_vectors( + intel_sub_group_avc_ref_result_t result); + +ushort __ovld intel_sub_group_avc_ime_get_inter_distortions( + intel_sub_group_avc_ime_result_t result); +ushort __ovld intel_sub_group_avc_ref_get_inter_distortions( + intel_sub_group_avc_ref_result_t result); +ushort __ovld intel_sub_group_avc_sic_get_inter_distortions( + intel_sub_group_avc_sic_result_t result); + +ushort __ovld intel_sub_group_avc_ime_get_best_inter_distortion( + intel_sub_group_avc_ime_result_t result); +ushort __ovld intel_sub_group_avc_ref_get_best_inter_distortion( + intel_sub_group_avc_ref_result_t result); + +uchar __ovld intel_sub_group_avc_ime_get_inter_major_shape( + intel_sub_group_avc_ime_result_t result); +uchar __ovld intel_sub_group_avc_ref_get_inter_major_shape( + intel_sub_group_avc_ref_result_t result); +uchar __ovld intel_sub_group_avc_ime_get_inter_minor_shapes( + intel_sub_group_avc_ime_result_t result); +uchar __ovld intel_sub_group_avc_ref_get_inter_minor_shapes( + intel_sub_group_avc_ref_result_t result); + +uchar __ovld intel_sub_group_avc_ime_get_inter_directions( + intel_sub_group_avc_ime_result_t result); +uchar __ovld intel_sub_group_avc_ref_get_inter_directions( + intel_sub_group_avc_ref_result_t result); + +uchar __ovld intel_sub_group_avc_ime_get_inter_motion_vector_count( + intel_sub_group_avc_ime_result_t result); +uchar __ovld intel_sub_group_avc_ref_get_inter_motion_vector_count( + intel_sub_group_avc_ref_result_t result); + +uint __ovld intel_sub_group_avc_ime_get_inter_reference_ids( + intel_sub_group_avc_ime_result_t result); +uint __ovld intel_sub_group_avc_ref_get_inter_reference_ids( + intel_sub_group_avc_ref_result_t result); + +uchar __ovld +intel_sub_group_avc_ime_get_inter_reference_interlaced_field_polarities( + uint packed_reference_ids, uint packed_reference_parameter_field_polarities, + intel_sub_group_avc_ime_result_t result); +uchar __ovld +intel_sub_group_avc_ref_get_inter_reference_interlaced_field_polarities( + uint packed_reference_ids, uint packed_reference_parameter_field_polarities, + intel_sub_group_avc_ref_result_t result); + +// Type conversion functions +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_ime_convert_to_mce_payload( + intel_sub_group_avc_ime_payload_t payload); +intel_sub_group_avc_ime_payload_t __ovld +intel_sub_group_avc_mce_convert_to_ime_payload( + intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_ref_convert_to_mce_payload( + intel_sub_group_avc_ref_payload_t payload); +intel_sub_group_avc_ref_payload_t __ovld +intel_sub_group_avc_mce_convert_to_ref_payload( + intel_sub_group_avc_mce_payload_t payload); +intel_sub_group_avc_mce_payload_t __ovld +intel_sub_group_avc_sic_convert_to_mce_payload( + intel_sub_group_avc_sic_payload_t payload); +intel_sub_group_avc_sic_payload_t __ovld +intel_sub_group_avc_mce_convert_to_sic_payload( + intel_sub_group_avc_mce_payload_t payload); + +intel_sub_group_avc_mce_result_t __ovld +intel_sub_group_avc_ime_convert_to_mce_result( + intel_sub_group_avc_ime_result_t result); +intel_sub_group_avc_ime_result_t __ovld +intel_sub_group_avc_mce_convert_to_ime_result( + intel_sub_group_avc_mce_result_t result); +intel_sub_group_avc_mce_result_t __ovld +intel_sub_group_avc_ref_convert_to_mce_result( + intel_sub_group_avc_ref_result_t result); +intel_sub_group_avc_ref_result_t __ovld +intel_sub_group_avc_mce_convert_to_ref_result( + intel_sub_group_avc_mce_result_t result); +intel_sub_group_avc_mce_result_t __ovld +intel_sub_group_avc_sic_convert_to_mce_result( + intel_sub_group_avc_sic_result_t result); +intel_sub_group_avc_sic_result_t __ovld +intel_sub_group_avc_mce_convert_to_sic_result( + intel_sub_group_avc_mce_result_t result); +#pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end +#endif // cl_intel_device_side_avc_motion_estimation + +#ifdef cl_amd_media_ops +uint __ovld amd_bitalign(uint, uint, uint); +uint2 __ovld amd_bitalign(uint2, uint2, uint2); +uint3 __ovld amd_bitalign(uint3, uint3, uint3); +uint4 __ovld amd_bitalign(uint4, uint4, uint4); +uint8 __ovld amd_bitalign(uint8, uint8, uint8); +uint16 __ovld amd_bitalign(uint16, uint16, uint16); + +uint __ovld amd_bytealign(uint, uint, uint); +uint2 __ovld amd_bytealign(uint2, uint2, uint2); +uint3 __ovld amd_bytealign(uint3, uint3, uint3); +uint4 __ovld amd_bytealign(uint4, uint4, uint4); +uint8 __ovld amd_bytealign(uint8, uint8, uint8); +uint16 __ovld amd_bytealign(uint16, uint16, uint16); + +uint __ovld amd_lerp(uint, uint, uint); +uint2 __ovld amd_lerp(uint2, uint2, uint2); +uint3 __ovld amd_lerp(uint3, uint3, uint3); +uint4 __ovld amd_lerp(uint4, uint4, uint4); +uint8 __ovld amd_lerp(uint8, uint8, uint8); +uint16 __ovld amd_lerp(uint16, uint16, uint16); + +uint __ovld amd_pack(float4 v); + +uint __ovld amd_sad4(uint4, uint4, uint); + +uint __ovld amd_sadhi(uint, uint, uint); +uint2 __ovld amd_sadhi(uint2, uint2, uint2); +uint3 __ovld amd_sadhi(uint3, uint3, uint3); +uint4 __ovld amd_sadhi(uint4, uint4, uint4); +uint8 __ovld amd_sadhi(uint8, uint8, uint8); +uint16 __ovld amd_sadhi(uint16, uint16, uint16); + +uint __ovld amd_sad(uint, uint, uint); +uint2 __ovld amd_sad(uint2, uint2, uint2); +uint3 __ovld amd_sad(uint3, uint3, uint3); +uint4 __ovld amd_sad(uint4, uint4, uint4); +uint8 __ovld amd_sad(uint8, uint8, uint8); +uint16 __ovld amd_sad(uint16, uint16, uint16); + +float __ovld amd_unpack0(uint); +float2 __ovld amd_unpack0(uint2); +float3 __ovld amd_unpack0(uint3); +float4 __ovld amd_unpack0(uint4); +float8 __ovld amd_unpack0(uint8); +float16 __ovld amd_unpack0(uint16); + +float __ovld amd_unpack1(uint); +float2 __ovld amd_unpack1(uint2); +float3 __ovld amd_unpack1(uint3); +float4 __ovld amd_unpack1(uint4); +float8 __ovld amd_unpack1(uint8); +float16 __ovld amd_unpack1(uint16); + +float __ovld amd_unpack2(uint); +float2 __ovld amd_unpack2(uint2); +float3 __ovld amd_unpack2(uint3); +float4 __ovld amd_unpack2(uint4); +float8 __ovld amd_unpack2(uint8); +float16 __ovld amd_unpack2(uint16); + +float __ovld amd_unpack3(uint); +float2 __ovld amd_unpack3(uint2); +float3 __ovld amd_unpack3(uint3); +float4 __ovld amd_unpack3(uint4); +float8 __ovld amd_unpack3(uint8); +float16 __ovld amd_unpack3(uint16); +#endif // cl_amd_media_ops + +#ifdef cl_amd_media_ops2 +int __ovld amd_bfe(int src0, uint src1, uint src2); +int2 __ovld amd_bfe(int2 src0, uint2 src1, uint2 src2); +int3 __ovld amd_bfe(int3 src0, uint3 src1, uint3 src2); +int4 __ovld amd_bfe(int4 src0, uint4 src1, uint4 src2); +int8 __ovld amd_bfe(int8 src0, uint8 src1, uint8 src2); +int16 __ovld amd_bfe(int16 src0, uint16 src1, uint16 src2); + +uint __ovld amd_bfe(uint src0, uint src1, uint src2); +uint2 __ovld amd_bfe(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_bfe(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_bfe(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_bfe(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_bfe(uint16 src0, uint16 src1, uint16 src2); + +uint __ovld amd_bfm(uint src0, uint src1); +uint2 __ovld amd_bfm(uint2 src0, uint2 src1); +uint3 __ovld amd_bfm(uint3 src0, uint3 src1); +uint4 __ovld amd_bfm(uint4 src0, uint4 src1); +uint8 __ovld amd_bfm(uint8 src0, uint8 src1); +uint16 __ovld amd_bfm(uint16 src0, uint16 src1); + +float __ovld amd_max3(float src0, float src1, float src2); +float2 __ovld amd_max3(float2 src0, float2 src1, float2 src2); +float3 __ovld amd_max3(float3 src0, float3 src1, float3 src2); +float4 __ovld amd_max3(float4 src0, float4 src1, float4 src2); +float8 __ovld amd_max3(float8 src0, float8 src1, float8 src2); +float16 __ovld amd_max3(float16 src0, float16 src1, float16 src2); + +int __ovld amd_max3(int src0, int src1, int src2); +int2 __ovld amd_max3(int2 src0, int2 src1, int2 src2); +int3 __ovld amd_max3(int3 src0, int3 src1, int3 src2); +int4 __ovld amd_max3(int4 src0, int4 src1, int4 src2); +int8 __ovld amd_max3(int8 src0, int8 src1, int8 src2); +int16 __ovld amd_max3(int16 src0, int16 src1, int16 src2); + +uint __ovld amd_max3(uint src0, uint src1, uint src2); +uint2 __ovld amd_max3(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_max3(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_max3(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_max3(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_max3(uint16 src0, uint16 src1, uint16 src2); + +float __ovld amd_median3(float src0, float src1, float src2); +float2 __ovld amd_median3(float2 src0, float2 src1, float2 src2); +float3 __ovld amd_median3(float3 src0, float3 src1, float3 src2); +float4 __ovld amd_median3(float4 src0, float4 src1, float4 src2); +float8 __ovld amd_median3(float8 src0, float8 src1, float8 src2); +float16 __ovld amd_median3(float16 src0, float16 src1, float16 src2); + +int __ovld amd_median3(int src0, int src1, int src2); +int2 __ovld amd_median3(int2 src0, int2 src1, int2 src2); +int3 __ovld amd_median3(int3 src0, int3 src1, int3 src2); +int4 __ovld amd_median3(int4 src0, int4 src1, int4 src2); +int8 __ovld amd_median3(int8 src0, int8 src1, int8 src2); +int16 __ovld amd_median3(int16 src0, int16 src1, int16 src2); + +uint __ovld amd_median3(uint src0, uint src1, uint src2); +uint2 __ovld amd_median3(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_median3(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_median3(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_median3(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_median3(uint16 src0, uint16 src1, uint16 src2); + +float __ovld amd_min3(float src0, float src1, float src); +float2 __ovld amd_min3(float2 src0, float2 src1, float2 src); +float3 __ovld amd_min3(float3 src0, float3 src1, float3 src); +float4 __ovld amd_min3(float4 src0, float4 src1, float4 src); +float8 __ovld amd_min3(float8 src0, float8 src1, float8 src); +float16 __ovld amd_min3(float16 src0, float16 src1, float16 src); + +int __ovld amd_min3(int src0, int src1, int src2); +int2 __ovld amd_min3(int2 src0, int2 src1, int2 src2); +int3 __ovld amd_min3(int3 src0, int3 src1, int3 src2); +int4 __ovld amd_min3(int4 src0, int4 src1, int4 src2); +int8 __ovld amd_min3(int8 src0, int8 src1, int8 src2); +int16 __ovld amd_min3(int16 src0, int16 src1, int16 src2); + +uint __ovld amd_min3(uint src0, uint src1, uint src2); +uint2 __ovld amd_min3(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_min3(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_min3(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_min3(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_min3(uint16 src0, uint16 src1, uint16 src2); + +ulong __ovld amd_mqsad(ulong src0, uint src1, ulong src2); +ulong2 __ovld amd_mqsad(ulong2 src0, uint2 src1, ulong2 src2); +ulong3 __ovld amd_mqsad(ulong3 src0, uint3 src1, ulong3 src2); +ulong4 __ovld amd_mqsad(ulong4 src0, uint4 src1, ulong4 src2); +ulong8 __ovld amd_mqsad(ulong8 src0, uint8 src1, ulong8 src2); +ulong16 __ovld amd_mqsad(ulong16 src0, uint16 src1, ulong16 src2); + +ulong __ovld amd_qsad(ulong src0, uint src1, ulong src2); +ulong2 __ovld amd_qsad(ulong2 src0, uint2 src1, ulong2 src2); +ulong3 __ovld amd_qsad(ulong3 src0, uint3 src1, ulong3 src2); +ulong4 __ovld amd_qsad(ulong4 src0, uint4 src1, ulong4 src2); +ulong8 __ovld amd_qsad(ulong8 src0, uint8 src1, ulong8 src2); +ulong16 __ovld amd_qsad(ulong16 src0, uint16 src1, ulong16 src2); + +uint __ovld amd_msad(uint src0, uint src1, uint src2); +uint2 __ovld amd_msad(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_msad(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_msad(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_msad(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_msad(uint16 src0, uint16 src1, uint16 src2); + +uint __ovld amd_sadd(uint src0, uint src1, uint src2); +uint2 __ovld amd_sadd(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_sadd(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_sadd(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_sadd(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_sadd(uint16 src0, uint16 src1, uint16 src2); + +uint __ovld amd_sadw(uint src0, uint src1, uint src2); +uint2 __ovld amd_sadw(uint2 src0, uint2 src1, uint2 src2); +uint3 __ovld amd_sadw(uint3 src0, uint3 src1, uint3 src2); +uint4 __ovld amd_sadw(uint4 src0, uint4 src1, uint4 src2); +uint8 __ovld amd_sadw(uint8 src0, uint8 src1, uint8 src2); +uint16 __ovld amd_sadw(uint16 src0, uint16 src1, uint16 src2); +#endif // cl_amd_media_ops2 + +#if defined(cl_arm_integer_dot_product_int8) +uint __ovld arm_dot(uchar4, uchar4); +int __ovld arm_dot(char4, char4); +#endif // defined(cl_arm_integer_dot_product_int8) + +#if defined(cl_arm_integer_dot_product_accumulate_int8) +uint __ovld arm_dot_acc(uchar4, uchar4, uint); +int __ovld arm_dot_acc(char4, char4, int); +#endif // defined(cl_arm_integer_dot_product_accumulate_int8) + +#if defined(cl_arm_integer_dot_product_accumulate_int16) +uint __ovld arm_dot_acc(ushort2, ushort2, uint); +int __ovld arm_dot_acc(short2, short2, int); +#endif // defined(cl_arm_integer_dot_product_accumulate_int16) + +#if defined(cl_arm_integer_dot_product_accumulate_saturate_int8) +uint __ovld arm_dot_acc_sat(uchar4, uchar4, uint); +int __ovld arm_dot_acc_sat(char4, char4, int); +#endif // defined(cl_arm_integer_dot_product_accumulate_saturate_int8) + +// Disable any extensions we may have enabled previously. +#pragma OPENCL EXTENSION all : disable + +#undef __opencl_c_named_address_space_builtins + +#undef __cnfn +#undef __ovld +#endif //_OPENCL_H_ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/__clang_openmp_device_functions.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/__clang_openmp_device_functions.h new file mode 100755 index 0000000..3e354c6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/__clang_openmp_device_functions.h @@ -0,0 +1,104 @@ +/*===- __clang_openmp_device_functions.h - OpenMP device function declares -=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_OPENMP_DEVICE_FUNCTIONS_H__ +#define __CLANG_OPENMP_DEVICE_FUNCTIONS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __NVPTX__ +#pragma omp begin declare variant match( \ + device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)}) + +#pragma push_macro("__CUDA__") +#define __CUDA__ +#define __OPENMP_NVPTX__ + +/// Include declarations for libdevice functions. +#include <__clang_cuda_libdevice_declares.h> + +/// Provide definitions for these functions. +#include <__clang_cuda_device_functions.h> + +#undef __OPENMP_NVPTX__ +#pragma pop_macro("__CUDA__") + +#pragma omp end declare variant +#endif + +#ifdef __AMDGCN__ +#pragma omp begin declare variant match(device = {arch(amdgcn)}) + +// Import types which will be used by __clang_hip_libdevice_declares.h +#ifndef __cplusplus +#include +#endif + +#define __OPENMP_AMDGCN__ +#pragma push_macro("__device__") +#define __device__ + +/// Include declarations for libdevice functions. +#include <__clang_hip_libdevice_declares.h> + +#pragma pop_macro("__device__") +#undef __OPENMP_AMDGCN__ + +#pragma omp end declare variant +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the +// need to `include ` in C++ mode. +#ifdef __cplusplus + +// We require malloc/free. +#include + +#pragma push_macro("OPENMP_NOEXCEPT") +#if __cplusplus >= 201103L +#define OPENMP_NOEXCEPT noexcept +#else +#define OPENMP_NOEXCEPT +#endif + +// Device overrides for non-placement new and delete. +inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) + size = 1; + return ::malloc(size); +} + +inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); } + +inline void operator delete(void *ptr)OPENMP_NOEXCEPT { ::free(ptr); } + +inline void operator delete[](void *ptr) OPENMP_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT { + ::operator delete(ptr); +} +inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +#pragma pop_macro("OPENMP_NOEXCEPT") +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/cmath b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/cmath new file mode 100755 index 0000000..e1b7151 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/cmath @@ -0,0 +1,132 @@ +/*===-- __clang_openmp_device_functions.h - OpenMP math declares -*- c++ -*-=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_OPENMP_CMATH_H__ +#define __CLANG_OPENMP_CMATH_H__ + +#ifndef _OPENMP +#error "This file is for OpenMP compilation only." +#endif + +#include_next + +// Make sure we include our math.h overlay, it probably happend already but we +// need to be sure. +#include + +// We (might) need cstdlib because __clang_cuda_cmath.h below declares `abs` +// which might live in cstdlib. +#include + +// We need limits because __clang_cuda_cmath.h below uses `std::numeric_limit`. +#include + +#pragma omp begin declare variant match( \ + device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any, allow_templates)}) + +#define __CUDA__ +#define __OPENMP_NVPTX__ +#include <__clang_cuda_cmath.h> +#undef __OPENMP_NVPTX__ +#undef __CUDA__ + +// Overloads not provided by the CUDA wrappers but by the CUDA system headers. +// Since we do not include the latter we define them ourselves. +#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) + +__DEVICE__ float acosh(float __x) { return ::acoshf(__x); } +__DEVICE__ float asinh(float __x) { return ::asinhf(__x); } +__DEVICE__ float atanh(float __x) { return ::atanhf(__x); } +__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); } +__DEVICE__ float erf(float __x) { return ::erff(__x); } +__DEVICE__ float erfc(float __x) { return ::erfcf(__x); } +__DEVICE__ float exp2(float __x) { return ::exp2f(__x); } +__DEVICE__ float expm1(float __x) { return ::expm1f(__x); } +__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); } +__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); } +__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); } +__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); } +__DEVICE__ long long int llrint(float __x) { return ::llrintf(__x); } +__DEVICE__ long long int llround(float __x) { return ::llroundf(__x); } +__DEVICE__ float log1p(float __x) { return ::log1pf(__x); } +__DEVICE__ float log2(float __x) { return ::log2f(__x); } +__DEVICE__ float logb(float __x) { return ::logbf(__x); } +__DEVICE__ long int lrint(float __x) { return ::lrintf(__x); } +__DEVICE__ long int lround(float __x) { return ::lroundf(__x); } +__DEVICE__ float nextafter(float __x, float __y) { + return ::nextafterf(__x, __y); +} +__DEVICE__ float remainder(float __x, float __y) { + return ::remainderf(__x, __y); +} +__DEVICE__ float scalbln(float __x, long int __y) { + return ::scalblnf(__x, __y); +} +__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); } +__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); } + +#undef __DEVICE__ + +#pragma omp end declare variant + +#ifdef __AMDGCN__ +#pragma omp begin declare variant match(device = {arch(amdgcn)}) + +#pragma push_macro("__constant__") +#define __constant__ __attribute__((constant)) +#define __OPENMP_AMDGCN__ + +#include <__clang_hip_cmath.h> + +#pragma pop_macro("__constant__") +#undef __OPENMP_AMDGCN__ + +// Define overloads otherwise which are absent +#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) + +__DEVICE__ float acos(float __x) { return ::acosf(__x); } +__DEVICE__ float acosh(float __x) { return ::acoshf(__x); } +__DEVICE__ float asin(float __x) { return ::asinf(__x); } +__DEVICE__ float asinh(float __x) { return ::asinhf(__x); } +__DEVICE__ float atan(float __x) { return ::atanf(__x); } +__DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); } +__DEVICE__ float atanh(float __x) { return ::atanhf(__x); } +__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); } +__DEVICE__ float cosh(float __x) { return ::coshf(__x); } +__DEVICE__ float erf(float __x) { return ::erff(__x); } +__DEVICE__ float erfc(float __x) { return ::erfcf(__x); } +__DEVICE__ float exp2(float __x) { return ::exp2f(__x); } +__DEVICE__ float expm1(float __x) { return ::expm1f(__x); } +__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); } +__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); } +__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); } +__DEVICE__ float ldexp(float __arg, int __exp) { + return ::ldexpf(__arg, __exp); +} +__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); } +__DEVICE__ float log1p(float __x) { return ::log1pf(__x); } +__DEVICE__ float logb(float __x) { return ::logbf(__x); } +__DEVICE__ float nextafter(float __x, float __y) { + return ::nextafterf(__x, __y); +} +__DEVICE__ float remainder(float __x, float __y) { + return ::remainderf(__x, __y); +} +__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); } +__DEVICE__ float sinh(float __x) { return ::sinhf(__x); } +__DEVICE__ float tan(float __x) { return ::tanf(__x); } +__DEVICE__ float tanh(float __x) { return ::tanhf(__x); } +__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); } + +#undef __DEVICE__ + +#pragma omp end declare variant +#endif // __AMDGCN__ + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex new file mode 100755 index 0000000..1ceecc1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex @@ -0,0 +1,55 @@ +/*===-- complex --- OpenMP complex wrapper for target regions --------- c++ -=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_OPENMP_COMPLEX__ +#define __CLANG_OPENMP_COMPLEX__ + +#ifndef _OPENMP +#error "This file is for OpenMP compilation only." +#endif + +// We require std::math functions in the complex builtins below. +#include + +#ifdef __NVPTX__ +#define __OPENMP_NVPTX__ +#include <__clang_cuda_complex_builtins.h> +#undef __OPENMP_NVPTX__ +#endif // __NVPTX__ + +#ifdef __AMDGCN__ +#define __OPENMP_AMDGCN__ +#include <__clang_cuda_complex_builtins.h> +#undef __OPENMP_AMDGCN__ +#endif // __AMDGCN__ + +#endif + +// Grab the host header too. +#include_next + +// If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set +// after including above. Since the complex header we use is a +// simplified version of the libc++, we don't need it in this case. If we +// compile against libstdc++, or any other standard library, we will overload +// the (hopefully template) functions in the header with the ones we +// got from libc++ which decomposes math functions, like `std::sin`, into +// arithmetic and calls to non-complex functions, all of which we can then +// handle. +#ifndef _LIBCPP_STD_VER + +#pragma omp begin declare variant match( \ + device = {arch(amdgcn, nvptx, nvptx64)}, \ + implementation = {extension(match_any, allow_templates)}) + +#include + +#pragma omp end declare variant + +#endif // _LIBCPP_STD_VER diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex.h new file mode 100755 index 0000000..7e7c086 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex.h @@ -0,0 +1,35 @@ +/*===-- complex --- OpenMP complex wrapper for target regions --------- c++ -=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_OPENMP_COMPLEX_H__ +#define __CLANG_OPENMP_COMPLEX_H__ + +#ifndef _OPENMP +#error "This file is for OpenMP compilation only." +#endif + +// We require math functions in the complex builtins below. +#include + +#ifdef __NVPTX__ +#define __OPENMP_NVPTX__ +#include <__clang_cuda_complex_builtins.h> +#undef __OPENMP_NVPTX__ +#endif + +#ifdef __AMDGCN__ +#define __OPENMP_AMDGCN__ +#include <__clang_cuda_complex_builtins.h> +#undef __OPENMP_AMDGCN__ +#endif + +#endif + +// Grab the host header too. +#include_next diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex_cmath.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex_cmath.h new file mode 100755 index 0000000..cee36bd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/complex_cmath.h @@ -0,0 +1,393 @@ +//===------------------------- __complex_cmath.h --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// std::complex header copied from the libcxx source and simplified for use in +// OpenMP target offload regions. +// +//===----------------------------------------------------------------------===// + +#ifndef _OPENMP +#error "This file is for OpenMP compilation only." +#endif + +#ifndef __cplusplus +#error "This file is for C++ compilation only." +#endif + +#ifndef _LIBCPP_COMPLEX +#define _LIBCPP_COMPLEX + +#include +#include + +#define __DEVICE__ static constexpr __attribute__((nothrow)) + +namespace std { + +// abs + +template __DEVICE__ _Tp abs(const std::complex<_Tp> &__c) { + return hypot(__c.real(), __c.imag()); +} + +// arg + +template __DEVICE__ _Tp arg(const std::complex<_Tp> &__c) { + return atan2(__c.imag(), __c.real()); +} + +template +typename enable_if::value || is_same<_Tp, double>::value, + double>::type +arg(_Tp __re) { + return atan2(0., __re); +} + +template +typename enable_if::value, float>::type arg(_Tp __re) { + return atan2f(0.F, __re); +} + +// norm + +template __DEVICE__ _Tp norm(const std::complex<_Tp> &__c) { + if (std::isinf(__c.real())) + return abs(__c.real()); + if (std::isinf(__c.imag())) + return abs(__c.imag()); + return __c.real() * __c.real() + __c.imag() * __c.imag(); +} + +// conj +#ifdef _GLIBCXX20_CONSTEXPR +#define CXX20_CONSTEXPR_DEVICE __DEVICE__ +#else +#define CXX20_CONSTEXPR_DEVICE +#endif +template +CXX20_CONSTEXPR_DEVICE std::complex<_Tp> conj(const std::complex<_Tp> &__c) { + return std::complex<_Tp>(__c.real(), -__c.imag()); +} + +// proj + +template std::complex<_Tp> proj(const std::complex<_Tp> &__c) { + std::complex<_Tp> __r = __c; + if (std::isinf(__c.real()) || std::isinf(__c.imag())) + __r = std::complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag())); + return __r; +} + +// polar + +template +complex<_Tp> polar(const _Tp &__rho, const _Tp &__theta = _Tp()) { + if (std::isnan(__rho) || signbit(__rho)) + return std::complex<_Tp>(_Tp(NAN), _Tp(NAN)); + if (std::isnan(__theta)) { + if (std::isinf(__rho)) + return std::complex<_Tp>(__rho, __theta); + return std::complex<_Tp>(__theta, __theta); + } + if (std::isinf(__theta)) { + if (std::isinf(__rho)) + return std::complex<_Tp>(__rho, _Tp(NAN)); + return std::complex<_Tp>(_Tp(NAN), _Tp(NAN)); + } + _Tp __x = __rho * cos(__theta); + if (std::isnan(__x)) + __x = 0; + _Tp __y = __rho * sin(__theta); + if (std::isnan(__y)) + __y = 0; + return std::complex<_Tp>(__x, __y); +} + +// log + +template std::complex<_Tp> log(const std::complex<_Tp> &__x) { + return std::complex<_Tp>(log(abs(__x)), arg(__x)); +} + +// log10 + +template std::complex<_Tp> log10(const std::complex<_Tp> &__x) { + return log(__x) / log(_Tp(10)); +} + +// sqrt + +template +__DEVICE__ std::complex<_Tp> sqrt(const std::complex<_Tp> &__x) { + if (std::isinf(__x.imag())) + return std::complex<_Tp>(_Tp(INFINITY), __x.imag()); + if (std::isinf(__x.real())) { + if (__x.real() > _Tp(0)) + return std::complex<_Tp>(__x.real(), std::isnan(__x.imag()) + ? __x.imag() + : copysign(_Tp(0), __x.imag())); + return std::complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), + copysign(__x.real(), __x.imag())); + } + return polar(sqrt(abs(__x)), arg(__x) / _Tp(2)); +} + +// exp + +template +__DEVICE__ std::complex<_Tp> exp(const std::complex<_Tp> &__x) { + _Tp __i = __x.imag(); + if (std::isinf(__x.real())) { + if (__x.real() < _Tp(0)) { + if (!std::isfinite(__i)) + __i = _Tp(1); + } else if (__i == 0 || !std::isfinite(__i)) { + if (std::isinf(__i)) + __i = _Tp(NAN); + return std::complex<_Tp>(__x.real(), __i); + } + } else if (std::isnan(__x.real()) && __x.imag() == 0) + return __x; + _Tp __e = exp(__x.real()); + return std::complex<_Tp>(__e * cos(__i), __e * sin(__i)); +} + +// pow + +template +std::complex<_Tp> pow(const std::complex<_Tp> &__x, + const std::complex<_Tp> &__y) { + return exp(__y * log(__x)); +} + +// __sqr, computes pow(x, 2) + +template std::complex<_Tp> __sqr(const std::complex<_Tp> &__x) { + return std::complex<_Tp>((__x.real() - __x.imag()) * + (__x.real() + __x.imag()), + _Tp(2) * __x.real() * __x.imag()); +} + +// asinh + +template +__DEVICE__ std::complex<_Tp> asinh(const std::complex<_Tp> &__x) { + const _Tp __pi(atan2(+0., -0.)); + if (std::isinf(__x.real())) { + if (std::isnan(__x.imag())) + return __x; + if (std::isinf(__x.imag())) + return std::complex<_Tp>(__x.real(), + copysign(__pi * _Tp(0.25), __x.imag())); + return std::complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag())); + } + if (std::isnan(__x.real())) { + if (std::isinf(__x.imag())) + return std::complex<_Tp>(__x.imag(), __x.real()); + if (__x.imag() == 0) + return __x; + return std::complex<_Tp>(__x.real(), __x.real()); + } + if (std::isinf(__x.imag())) + return std::complex<_Tp>(copysign(__x.imag(), __x.real()), + copysign(__pi / _Tp(2), __x.imag())); + std::complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1))); + return std::complex<_Tp>(copysign(__z.real(), __x.real()), + copysign(__z.imag(), __x.imag())); +} + +// acosh + +template +__DEVICE__ std::complex<_Tp> acosh(const std::complex<_Tp> &__x) { + const _Tp __pi(atan2(+0., -0.)); + if (std::isinf(__x.real())) { + if (std::isnan(__x.imag())) + return std::complex<_Tp>(abs(__x.real()), __x.imag()); + if (std::isinf(__x.imag())) { + if (__x.real() > 0) + return std::complex<_Tp>(__x.real(), + copysign(__pi * _Tp(0.25), __x.imag())); + else + return std::complex<_Tp>(-__x.real(), + copysign(__pi * _Tp(0.75), __x.imag())); + } + if (__x.real() < 0) + return std::complex<_Tp>(-__x.real(), copysign(__pi, __x.imag())); + return std::complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag())); + } + if (std::isnan(__x.real())) { + if (std::isinf(__x.imag())) + return std::complex<_Tp>(abs(__x.imag()), __x.real()); + return std::complex<_Tp>(__x.real(), __x.real()); + } + if (std::isinf(__x.imag())) + return std::complex<_Tp>(abs(__x.imag()), + copysign(__pi / _Tp(2), __x.imag())); + std::complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1))); + return std::complex<_Tp>(copysign(__z.real(), _Tp(0)), + copysign(__z.imag(), __x.imag())); +} + +// atanh + +template +__DEVICE__ std::complex<_Tp> atanh(const std::complex<_Tp> &__x) { + const _Tp __pi(atan2(+0., -0.)); + if (std::isinf(__x.imag())) { + return std::complex<_Tp>(copysign(_Tp(0), __x.real()), + copysign(__pi / _Tp(2), __x.imag())); + } + if (std::isnan(__x.imag())) { + if (std::isinf(__x.real()) || __x.real() == 0) + return std::complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag()); + return std::complex<_Tp>(__x.imag(), __x.imag()); + } + if (std::isnan(__x.real())) { + return std::complex<_Tp>(__x.real(), __x.real()); + } + if (std::isinf(__x.real())) { + return std::complex<_Tp>(copysign(_Tp(0), __x.real()), + copysign(__pi / _Tp(2), __x.imag())); + } + if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) { + return std::complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), + copysign(_Tp(0), __x.imag())); + } + std::complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2); + return std::complex<_Tp>(copysign(__z.real(), __x.real()), + copysign(__z.imag(), __x.imag())); +} + +// sinh + +template +__DEVICE__ std::complex<_Tp> sinh(const std::complex<_Tp> &__x) { + if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) + return std::complex<_Tp>(__x.real(), _Tp(NAN)); + if (__x.real() == 0 && !std::isfinite(__x.imag())) + return std::complex<_Tp>(__x.real(), _Tp(NAN)); + if (__x.imag() == 0 && !std::isfinite(__x.real())) + return __x; + return std::complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), + cosh(__x.real()) * sin(__x.imag())); +} + +// cosh + +template +__DEVICE__ std::complex<_Tp> cosh(const std::complex<_Tp> &__x) { + if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) + return std::complex<_Tp>(abs(__x.real()), _Tp(NAN)); + if (__x.real() == 0 && !std::isfinite(__x.imag())) + return std::complex<_Tp>(_Tp(NAN), __x.real()); + if (__x.real() == 0 && __x.imag() == 0) + return std::complex<_Tp>(_Tp(1), __x.imag()); + if (__x.imag() == 0 && !std::isfinite(__x.real())) + return std::complex<_Tp>(abs(__x.real()), __x.imag()); + return std::complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), + sinh(__x.real()) * sin(__x.imag())); +} + +// tanh + +template +__DEVICE__ std::complex<_Tp> tanh(const std::complex<_Tp> &__x) { + if (std::isinf(__x.real())) { + if (!std::isfinite(__x.imag())) + return std::complex<_Tp>(_Tp(1), _Tp(0)); + return std::complex<_Tp>(_Tp(1), + copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); + } + if (std::isnan(__x.real()) && __x.imag() == 0) + return __x; + _Tp __2r(_Tp(2) * __x.real()); + _Tp __2i(_Tp(2) * __x.imag()); + _Tp __d(cosh(__2r) + cos(__2i)); + _Tp __2rsh(sinh(__2r)); + if (std::isinf(__2rsh) && std::isinf(__d)) + return std::complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), + __2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); + return std::complex<_Tp>(__2rsh / __d, sin(__2i) / __d); +} + +// asin + +template +__DEVICE__ std::complex<_Tp> asin(const std::complex<_Tp> &__x) { + std::complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real())); + return std::complex<_Tp>(__z.imag(), -__z.real()); +} + +// acos + +template +__DEVICE__ std::complex<_Tp> acos(const std::complex<_Tp> &__x) { + const _Tp __pi(atan2(+0., -0.)); + if (std::isinf(__x.real())) { + if (std::isnan(__x.imag())) + return std::complex<_Tp>(__x.imag(), __x.real()); + if (std::isinf(__x.imag())) { + if (__x.real() < _Tp(0)) + return std::complex<_Tp>(_Tp(0.75) * __pi, -__x.imag()); + return std::complex<_Tp>(_Tp(0.25) * __pi, -__x.imag()); + } + if (__x.real() < _Tp(0)) + return std::complex<_Tp>(__pi, + signbit(__x.imag()) ? -__x.real() : __x.real()); + return std::complex<_Tp>(_Tp(0), + signbit(__x.imag()) ? __x.real() : -__x.real()); + } + if (std::isnan(__x.real())) { + if (std::isinf(__x.imag())) + return std::complex<_Tp>(__x.real(), -__x.imag()); + return std::complex<_Tp>(__x.real(), __x.real()); + } + if (std::isinf(__x.imag())) + return std::complex<_Tp>(__pi / _Tp(2), -__x.imag()); + if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag()))) + return std::complex<_Tp>(__pi / _Tp(2), -__x.imag()); + std::complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1))); + if (signbit(__x.imag())) + return std::complex<_Tp>(abs(__z.imag()), abs(__z.real())); + return std::complex<_Tp>(abs(__z.imag()), -abs(__z.real())); +} + +// atan + +template +__DEVICE__ std::complex<_Tp> atan(const std::complex<_Tp> &__x) { + std::complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real())); + return std::complex<_Tp>(__z.imag(), -__z.real()); +} + +// sin + +template +__DEVICE__ std::complex<_Tp> sin(const std::complex<_Tp> &__x) { + std::complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real())); + return std::complex<_Tp>(__z.imag(), -__z.real()); +} + +// cos + +template std::complex<_Tp> cos(const std::complex<_Tp> &__x) { + return cosh(complex<_Tp>(-__x.imag(), __x.real())); +} + +// tan + +template +__DEVICE__ std::complex<_Tp> tan(const std::complex<_Tp> &__x) { + std::complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real())); + return std::complex<_Tp>(__z.imag(), -__z.real()); +} + +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/math.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/math.h new file mode 100755 index 0000000..1e3c07c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/math.h @@ -0,0 +1,61 @@ +/*===---- openmp_wrapper/math.h -------- OpenMP math.h intercept ------ c++ -=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +// If we are in C++ mode and include (not ) first, we still need +// to make sure is read first. The problem otherwise is that we haven't +// seen the declarations of the math.h functions when the system math.h includes +// our cmath overlay. However, our cmath overlay, or better the underlying +// overlay, e.g. CUDA, uses the math.h functions. Since we haven't declared them +// yet we get errors. CUDA avoids this by eagerly declaring all math functions +// (in the __device__ space) but we cannot do this. Instead we break the +// dependence by forcing cmath to go first. While our cmath will in turn include +// this file, the cmath guards will prevent recursion. +#ifdef __cplusplus +#include +#endif + +#ifndef __CLANG_OPENMP_MATH_H__ +#define __CLANG_OPENMP_MATH_H__ + +#ifndef _OPENMP +#error "This file is for OpenMP compilation only." +#endif + +#include_next + +// We need limits.h for __clang_cuda_math.h below and because it should not hurt +// we include it eagerly here. +#include + +// We need stdlib.h because (for now) __clang_cuda_math.h below declares `abs` +// which should live in stdlib.h. +#include + +#pragma omp begin declare variant match( \ + device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)}) + +#define __CUDA__ +#define __OPENMP_NVPTX__ +#include <__clang_cuda_math.h> +#undef __OPENMP_NVPTX__ +#undef __CUDA__ + +#pragma omp end declare variant + +#ifdef __AMDGCN__ +#pragma omp begin declare variant match(device = {arch(amdgcn)}) + +#define __OPENMP_AMDGCN__ +#include <__clang_hip_math.h> +#undef __OPENMP_AMDGCN__ + +#pragma omp end declare variant +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/new b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/new new file mode 100755 index 0000000..8bad3f1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/openmp_wrappers/new @@ -0,0 +1,48 @@ +//===--------- new - OPENMP wrapper for ------------------------------=== +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===-----------------------------------------------------------------------=== + +#ifndef __CLANG_OPENMP_WRAPPERS_NEW +#define __CLANG_OPENMP_WRAPPERS_NEW + +// We need the system for the std::nothrow_t. The new/delete operators +// which do not use nothrow_t are provided without the header. +#include_next + +#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(_OPENMP) + +#include + +#pragma push_macro("OPENMP_NOEXCEPT") +#if __cplusplus >= 201103L +#define OPENMP_NOEXCEPT noexcept +#else +#define OPENMP_NOEXCEPT +#endif + +inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) OPENMP_NOEXCEPT { + return ::operator new(size); +} + +inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) { + return ::operator new(size); +} + +inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT { + ::operator delete(ptr); +} + +inline void operator delete[](void *ptr, + const std::nothrow_t &) OPENMP_NOEXCEPT { + ::operator delete(ptr); +} + +#pragma pop_macro("OPENMP_NOEXCEPT") +#endif + +#endif // include guard diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pconfigintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pconfigintrin.h new file mode 100755 index 0000000..d2014b0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pconfigintrin.h @@ -0,0 +1,40 @@ +/*===---- pconfigintrin.h - X86 platform configuration ---------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PCONFIGINTRIN_H +#define __PCONFIGINTRIN_H + +#define __PCONFIG_KEY_PROGRAM 0x00000001 + +#if __has_extension(gnu_asm) + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("pconfig"))) + +static __inline unsigned int __DEFAULT_FN_ATTRS +_pconfig_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) +{ + unsigned int __result; + __asm__ ("pconfig" + : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) + : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) + : "cc"); + return __result; +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __has_extension(gnu_asm) */ + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pkuintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pkuintrin.h new file mode 100755 index 0000000..c62080b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pkuintrin.h @@ -0,0 +1,34 @@ +/*===---- pkuintrin.h - PKU intrinsics -------------------------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PKUINTRIN_H +#define __PKUINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("pku"))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_rdpkru_u32(void) +{ + return __builtin_ia32_rdpkru(); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_wrpkru(unsigned int __val) +{ + __builtin_ia32_wrpkru(__val); +} + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pmmintrin.h new file mode 100755 index 0000000..cd605df --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/pmmintrin.h @@ -0,0 +1,314 @@ +/*===---- pmmintrin.h - SSE3 intrinsics ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __PMMINTRIN_H +#define __PMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("sse3,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sse3"), \ + __min_vector_width__(128))) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#else +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS +#endif + +/// Loads data from an unaligned memory location to elements in a 128-bit +/// vector. +/// +/// If the address of the data is not 16-byte aligned, the instruction may +/// read two adjacent aligned blocks of memory to retrieve the requested +/// data. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VLDDQU instruction. +/// +/// \param __p +/// A pointer to a 128-bit integer vector containing integer values. +/// \returns A 128-bit vector containing the moved values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_lddqu_si128(__m128i_u const *__p) +{ + return (__m128i)__builtin_ia32_lddqu((char const *)__p); +} + +/// Adds the even-indexed values and subtracts the odd-indexed values of +/// two 128-bit vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDSUBPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing the left source operand. +/// \param __b +/// A 128-bit vector of [4 x float] containing the right source operand. +/// \returns A 128-bit vector of [4 x float] containing the alternating sums and +/// differences of both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_addsub_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_addsubps((__v4sf)__a, (__v4sf)__b); +} + +/// Horizontally adds the adjacent pairs of values contained in two +/// 128-bit vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHADDPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 128-bit vector of [4 x float] containing the horizontal sums of +/// both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_hadd_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_haddps((__v4sf)__a, (__v4sf)__b); +} + +/// Horizontally subtracts the adjacent pairs of values contained in two +/// 128-bit vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHSUBPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The horizontal differences between the values are stored in the lower +/// bits of the destination. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The horizontal differences between the values are stored in the upper +/// bits of the destination. +/// \returns A 128-bit vector of [4 x float] containing the horizontal +/// differences of both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_hsub_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_hsubps((__v4sf)__a, (__v4sf)__b); +} + +/// Moves and duplicates odd-indexed values from a 128-bit vector +/// of [4 x float] to float values stored in a 128-bit vector of +/// [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSHDUP instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. \n +/// Bits [127:96] of the source are written to bits [127:96] and [95:64] of +/// the destination. \n +/// Bits [63:32] of the source are written to bits [63:32] and [31:0] of the +/// destination. +/// \returns A 128-bit vector of [4 x float] containing the moved and duplicated +/// values. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_movehdup_ps(__m128 __a) +{ + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 1, 1, 3, 3); +} + +/// Duplicates even-indexed values from a 128-bit vector of +/// [4 x float] to float values stored in a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSLDUP instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float] \n +/// Bits [95:64] of the source are written to bits [127:96] and [95:64] of +/// the destination. \n +/// Bits [31:0] of the source are written to bits [63:32] and [31:0] of the +/// destination. +/// \returns A 128-bit vector of [4 x float] containing the moved and duplicated +/// values. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_moveldup_ps(__m128 __a) +{ + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 2, 2); +} + +/// Adds the even-indexed values and subtracts the odd-indexed values of +/// two 128-bit vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDSUBPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing the left source operand. +/// \param __b +/// A 128-bit vector of [2 x double] containing the right source operand. +/// \returns A 128-bit vector of [2 x double] containing the alternating sums +/// and differences of both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS +_mm_addsub_pd(__m128d __a, __m128d __b) +{ + return __builtin_ia32_addsubpd((__v2df)__a, (__v2df)__b); +} + +/// Horizontally adds the pairs of values contained in two 128-bit +/// vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHADDPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// The horizontal sum of the values is stored in the lower bits of the +/// destination. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// The horizontal sum of the values is stored in the upper bits of the +/// destination. +/// \returns A 128-bit vector of [2 x double] containing the horizontal sums of +/// both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS +_mm_hadd_pd(__m128d __a, __m128d __b) +{ + return __builtin_ia32_haddpd((__v2df)__a, (__v2df)__b); +} + +/// Horizontally subtracts the pairs of values contained in two 128-bit +/// vectors of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VHSUBPD instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// The horizontal difference of the values is stored in the lower bits of +/// the destination. +/// \param __b +/// A 128-bit vector of [2 x double] containing one of the source operands. +/// The horizontal difference of the values is stored in the upper bits of +/// the destination. +/// \returns A 128-bit vector of [2 x double] containing the horizontal +/// differences of both operands. +static __inline__ __m128d __DEFAULT_FN_ATTRS +_mm_hsub_pd(__m128d __a, __m128d __b) +{ + return __builtin_ia32_hsubpd((__v2df)__a, (__v2df)__b); +} + +/// Moves and duplicates one double-precision value to double-precision +/// values stored in a 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_loaddup_pd(double const *dp); +/// \endcode +/// +/// This intrinsic corresponds to the VMOVDDUP instruction. +/// +/// \param dp +/// A pointer to a double-precision value to be moved and duplicated. +/// \returns A 128-bit vector of [2 x double] containing the moved and +/// duplicated values. +#define _mm_loaddup_pd(dp) _mm_load1_pd(dp) + +/// Moves and duplicates the double-precision value in the lower bits of +/// a 128-bit vector of [2 x double] to double-precision values stored in a +/// 128-bit vector of [2 x double]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVDDUP instruction. +/// +/// \param __a +/// A 128-bit vector of [2 x double]. Bits [63:0] are written to bits +/// [127:64] and [63:0] of the destination. +/// \returns A 128-bit vector of [2 x double] containing the moved and +/// duplicated values. +static __inline__ __m128d __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_movedup_pd(__m128d __a) +{ + return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0); +} + +/// Establishes a linear address memory range to be monitored and puts +/// the processor in the monitor event pending state. Data stored in the +/// monitored address range causes the processor to exit the pending state. +/// +/// The \c MONITOR instruction can be used in kernel mode, and in other modes +/// if MSR C001_0015h[MonMwaitUserEn] is set. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MONITOR instruction. +/// +/// \param __p +/// The memory range to be monitored. The size of the range is determined by +/// CPUID function 0000_0005h. +/// \param __extensions +/// Optional extensions for the monitoring state. +/// \param __hints +/// Optional hints for the monitoring state. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_monitor(void const *__p, unsigned __extensions, unsigned __hints) +{ + __builtin_ia32_monitor(__p, __extensions, __hints); +} + +/// Used with the \c MONITOR instruction to wait while the processor is in +/// the monitor event pending state. Data stored in the monitored address +/// range, or an interrupt, causes the processor to exit the pending state. +/// +/// The \c MWAIT instruction can be used in kernel mode, and in other modes if +/// MSR C001_0015h[MonMwaitUserEn] is set. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c MWAIT instruction. +/// +/// \param __extensions +/// Optional extensions for the monitoring state, which can vary by +/// processor. +/// \param __hints +/// Optional hints for the monitoring state, which can vary by processor. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_mwait(unsigned __extensions, unsigned __hints) +{ + __builtin_ia32_mwait(__extensions, __hints); +} + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_CONSTEXPR + +#endif /* __PMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/popcntintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/popcntintrin.h new file mode 100755 index 0000000..b276b4d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/popcntintrin.h @@ -0,0 +1,59 @@ +/*===---- popcntintrin.h - POPCNT intrinsics -------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __POPCNTINTRIN_H +#define __POPCNTINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("popcnt"))) constexpr +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("popcnt"))) +#endif + +/// Counts the number of bits in the source operand having a value of 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the POPCNT instruction. +/// +/// \param __A +/// An unsigned 32-bit integer operand. +/// \returns A 32-bit integer containing the number of bits with value 1 in the +/// source operand. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_popcnt_u32(unsigned int __A) +{ + return __builtin_popcount(__A); +} + +#ifdef __x86_64__ +/// Counts the number of bits in the source operand having a value of 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the POPCNT instruction. +/// +/// \param __A +/// An unsigned 64-bit integer operand. +/// \returns A 64-bit integer containing the number of bits with value 1 in the +/// source operand. +static __inline__ long long __DEFAULT_FN_ATTRS +_mm_popcnt_u64(unsigned long long __A) +{ + return __builtin_popcountll(__A); +} +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __POPCNTINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/bmi2intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/bmi2intrin.h new file mode 100755 index 0000000..0dc0d14 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/bmi2intrin.h @@ -0,0 +1,134 @@ +/*===---- bmiintrin.h - Implementation of BMI2 intrinsics on PowerPC -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined X86GPRINTRIN_H_ +#error "Never use directly; include instead." +#endif + +#ifndef BMI2INTRIN_H_ +#define BMI2INTRIN_H_ + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _bzhi_u32(unsigned int __X, unsigned int __Y) { + return ((__X << (32 - __Y)) >> (32 - __Y)); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mulx_u32(unsigned int __X, unsigned int __Y, unsigned int *__P) { + unsigned long long __res = (unsigned long long)__X * __Y; + *__P = (unsigned int)(__res >> 32); + return (unsigned int)__res; +} + +#ifdef __PPC64__ +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _bzhi_u64(unsigned long long __X, unsigned long long __Y) { + return ((__X << (64 - __Y)) >> (64 - __Y)); +} + +/* __int128 requires base 64-bit. */ +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mulx_u64(unsigned long long __X, unsigned long long __Y, + unsigned long long *__P) { + unsigned __int128 __res = (unsigned __int128)__X * __Y; + *__P = (unsigned long long)(__res >> 64); + return (unsigned long long)__res; +} + +#ifdef _ARCH_PWR7 +/* popcount and bpermd require power7 minimum. */ +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _pdep_u64(unsigned long long __X, unsigned long long __M) { + unsigned long __result = 0x0UL; + const unsigned long __mask = 0x8000000000000000UL; + unsigned long __m = __M; + unsigned long __c, __t; + unsigned long __p; + + /* The pop-count of the mask gives the number of the bits from + source to process. This is also needed to shift bits from the + source into the correct position for the result. */ + __p = 64 - __builtin_popcountl(__M); + + /* The loop is for the number of '1' bits in the mask and clearing + each mask bit as it is processed. */ + while (__m != 0) { + __c = __builtin_clzl(__m); + __t = __X << (__p - __c); + __m ^= (__mask >> __c); + __result |= (__t & (__mask >> __c)); + __p++; + } + return __result; +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _pext_u64(unsigned long long __X, unsigned long long __M) { + unsigned long __p = 0x4040404040404040UL; // initial bit permute control + const unsigned long __mask = 0x8000000000000000UL; + unsigned long __m = __M; + unsigned long __c; + unsigned long __result; + + /* if the mask is constant and selects 8 bits or less we can use + the Power8 Bit permute instruction. */ + if (__builtin_constant_p(__M) && (__builtin_popcountl(__M) <= 8)) { + /* Also if the pext mask is constant, then the popcount is + constant, we can evaluate the following loop at compile + time and use a constant bit permute vector. */ + long __i; + for (__i = 0; __i < __builtin_popcountl(__M); __i++) { + __c = __builtin_clzl(__m); + __p = (__p << 8) | __c; + __m ^= (__mask >> __c); + } + __result = __builtin_bpermd(__p, __X); + } else { + __p = 64 - __builtin_popcountl(__M); + __result = 0; + /* We could a use a for loop here, but that combined with + -funroll-loops can expand to a lot of code. The while + loop avoids unrolling and the compiler commons the xor + from clearing the mask bit with the (m != 0) test. The + result is a more compact loop setup and body. */ + while (__m != 0) { + unsigned long __t; + __c = __builtin_clzl(__m); + __t = (__X & (__mask >> __c)) >> (__p - __c); + __m ^= (__mask >> __c); + __result |= (__t); + __p++; + } + } + return __result; +} + +/* these 32-bit implementations depend on 64-bit pdep/pext + which depend on _ARCH_PWR7. */ +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _pdep_u32(unsigned int __X, unsigned int __Y) { + return _pdep_u64(__X, __Y); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _pext_u32(unsigned int __X, unsigned int __Y) { + return _pext_u64(__X, __Y); +} +#endif /* _ARCH_PWR7 */ +#endif /* __PPC64__ */ + +#endif /* BMI2INTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/bmiintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/bmiintrin.h new file mode 100755 index 0000000..7d33159 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/bmiintrin.h @@ -0,0 +1,165 @@ +/*===---- bmiintrin.h - Implementation of BMI intrinsics on PowerPC --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined X86GPRINTRIN_H_ +#error "Never use directly; include instead." +#endif + +#ifndef BMIINTRIN_H_ +#define BMIINTRIN_H_ + +extern __inline unsigned short + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __tzcnt_u16(unsigned short __X) { + return __builtin_ctz(__X); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __andn_u32(unsigned int __X, unsigned int __Y) { + return (~__X & __Y); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _bextr_u32(unsigned int __X, unsigned int __P, unsigned int __L) { + return ((__X << (32 - (__L + __P))) >> (32 - __L)); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __bextr_u32(unsigned int __X, unsigned int __Y) { + unsigned int __P, __L; + __P = __Y & 0xFF; + __L = (__Y >> 8) & 0xFF; + return (_bextr_u32(__X, __P, __L)); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __blsi_u32(unsigned int __X) { + return (__X & -__X); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _blsi_u32(unsigned int __X) { + return __blsi_u32(__X); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __blsmsk_u32(unsigned int __X) { + return (__X ^ (__X - 1)); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _blsmsk_u32(unsigned int __X) { + return __blsmsk_u32(__X); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __blsr_u32(unsigned int __X) { + return (__X & (__X - 1)); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _blsr_u32(unsigned int __X) { + return __blsr_u32(__X); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __tzcnt_u32(unsigned int __X) { + return __builtin_ctz(__X); +} + +extern __inline unsigned int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _tzcnt_u32(unsigned int __X) { + return __builtin_ctz(__X); +} + +/* use the 64-bit shift, rotate, and count leading zeros instructions + for long long. */ +#ifdef __PPC64__ +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __andn_u64(unsigned long long __X, unsigned long long __Y) { + return (~__X & __Y); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _bextr_u64(unsigned long long __X, unsigned int __P, unsigned int __L) { + return ((__X << (64 - (__L + __P))) >> (64 - __L)); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __bextr_u64(unsigned long long __X, unsigned long long __Y) { + unsigned int __P, __L; + __P = __Y & 0xFF; + __L = (__Y & 0xFF00) >> 8; + return (_bextr_u64(__X, __P, __L)); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __blsi_u64(unsigned long long __X) { + return __X & -__X; +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _blsi_u64(unsigned long long __X) { + return __blsi_u64(__X); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __blsmsk_u64(unsigned long long __X) { + return (__X ^ (__X - 1)); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _blsmsk_u64(unsigned long long __X) { + return __blsmsk_u64(__X); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __blsr_u64(unsigned long long __X) { + return (__X & (__X - 1)); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _blsr_u64(unsigned long long __X) { + return __blsr_u64(__X); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + __tzcnt_u64(unsigned long long __X) { + return __builtin_ctzll(__X); +} + +extern __inline unsigned long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _tzcnt_u64(unsigned long long __X) { + return __builtin_ctzll(__X); +} +#endif /* __PPC64__ */ + +#endif /* BMIINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/emmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/emmintrin.h new file mode 100755 index 0000000..fc18ab9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/emmintrin.h @@ -0,0 +1,2269 @@ +/*===---- emmintrin.h - Implementation of SSE2 intrinsics on PowerPC -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Implemented from the specification included in the Intel C++ Compiler + User Guide and Reference, version 9.0. */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header file is to help porting code using Intel intrinsics + explicitly from x86_64 to powerpc64/powerpc64le. + + Since X86 SSE2 intrinsics mainly handles __m128i and __m128d type, + PowerPC VMX/VSX ISA is a good match for vector float SIMD operations. + However scalar float operations in vector (XMM) registers require + the POWER8 VSX ISA (2.07) level. There are differences for data + format and placement of float scalars in the vector register, which + require extra steps to match SSE2 scalar float semantics on POWER. + + It should be noted that there's much difference between X86_64's + MXSCR and PowerISA's FPSCR/VSCR registers. It's recommended to use + portable instead of access MXSCR directly. + + Most SSE2 scalar float intrinsic operations can be performed more + efficiently as C language float scalar operations or optimized to + use vector SIMD operations. We recommend this for new applications. +*/ +#error \ + "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this error." +#endif + +#ifndef EMMINTRIN_H_ +#define EMMINTRIN_H_ + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +#include + +/* We need definitions from the SSE header files. */ +#include + +/* SSE2 */ +typedef __vector double __v2df; +typedef __vector float __v4f; +typedef __vector long long __v2di; +typedef __vector unsigned long long __v2du; +typedef __vector int __v4si; +typedef __vector unsigned int __v4su; +typedef __vector short __v8hi; +typedef __vector unsigned short __v8hu; +typedef __vector signed char __v16qi; +typedef __vector unsigned char __v16qu; + +/* The Intel API is flexible enough that we must allow aliasing with other + vector types, and their scalar components. */ +typedef long long __m128i __attribute__((__vector_size__(16), __may_alias__)); +typedef double __m128d __attribute__((__vector_size__(16), __may_alias__)); + +/* Unaligned version of the same types. */ +typedef long long __m128i_u + __attribute__((__vector_size__(16), __may_alias__, __aligned__(1))); +typedef double __m128d_u + __attribute__((__vector_size__(16), __may_alias__, __aligned__(1))); + +/* Define two value permute mask. */ +#define _MM_SHUFFLE2(x, y) (((x) << 1) | (y)) + +/* Create a vector with element 0 as F and the rest zero. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_sd(double __F) { + return __extension__(__m128d){__F, 0.0}; +} + +/* Create a vector with both elements equal to F. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_pd(double __F) { + return __extension__(__m128d){__F, __F}; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_pd1(double __F) { + return _mm_set1_pd(__F); +} + +/* Create a vector with the lower value X and upper value W. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_pd(double __W, double __X) { + return __extension__(__m128d){__X, __W}; +} + +/* Create a vector with the lower value W and upper value X. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_pd(double __W, double __X) { + return __extension__(__m128d){__W, __X}; +} + +/* Create an undefined vector. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_undefined_pd(void) { + __m128d __Y = __Y; + return __Y; +} + +/* Create a vector of zeros. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setzero_pd(void) { + return (__m128d)vec_splats(0); +} + +/* Sets the low DPFP value of A from the low value of B. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_move_sd(__m128d __A, __m128d __B) { + __v2df __result = (__v2df)__A; + __result[0] = ((__v2df)__B)[0]; + return (__m128d)__result; +} + +/* Load two DPFP values from P. The address must be 16-byte aligned. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_pd(double const *__P) { + return ((__m128d)vec_ld(0, (__v16qu *)__P)); +} + +/* Load two DPFP values from P. The address need not be 16-byte aligned. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadu_pd(double const *__P) { + return (vec_vsx_ld(0, __P)); +} + +/* Create a vector with all two elements equal to *P. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load1_pd(double const *__P) { + return (vec_splats(*__P)); +} + +/* Create a vector with element 0 as *P and the rest zero. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_sd(double const *__P) { + return _mm_set_sd(*__P); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_pd1(double const *__P) { + return _mm_load1_pd(__P); +} + +/* Load two DPFP values in reverse order. The address must be aligned. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadr_pd(double const *__P) { + __v2df __tmp = _mm_load_pd(__P); + return (__m128d)vec_xxpermdi(__tmp, __tmp, 2); +} + +/* Store two DPFP values. The address must be 16-byte aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_pd(double *__P, __m128d __A) { + vec_st((__v16qu)__A, 0, (__v16qu *)__P); +} + +/* Store two DPFP values. The address need not be 16-byte aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storeu_pd(double *__P, __m128d __A) { + *(__m128d_u *)__P = __A; +} + +/* Stores the lower DPFP value. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_sd(double *__P, __m128d __A) { + *__P = ((__v2df)__A)[0]; +} + +extern __inline double + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsd_f64(__m128d __A) { + return ((__v2df)__A)[0]; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storel_pd(double *__P, __m128d __A) { + _mm_store_sd(__P, __A); +} + +/* Stores the upper DPFP value. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storeh_pd(double *__P, __m128d __A) { + *__P = ((__v2df)__A)[1]; +} +/* Store the lower DPFP value across two words. + The address must be 16-byte aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store1_pd(double *__P, __m128d __A) { + _mm_store_pd(__P, vec_splat(__A, 0)); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_pd1(double *__P, __m128d __A) { + _mm_store1_pd(__P, __A); +} + +/* Store two DPFP values in reverse order. The address must be aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storer_pd(double *__P, __m128d __A) { + _mm_store_pd(__P, vec_xxpermdi(__A, __A, 2)); +} + +/* Intel intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi128_si64(__m128i __A) { + return ((__v2di)__A)[0]; +} + +/* Microsoft intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi128_si64x(__m128i __A) { + return ((__v2di)__A)[0]; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_pd(__m128d __A, __m128d __B) { + return (__m128d)((__v2df)__A + (__v2df)__B); +} + +/* Add the lower double-precision (64-bit) floating-point element in + a and b, store the result in the lower element of dst, and copy + the upper element from a to the upper element of dst. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_sd(__m128d __A, __m128d __B) { + __A[0] = __A[0] + __B[0]; + return (__A); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_pd(__m128d __A, __m128d __B) { + return (__m128d)((__v2df)__A - (__v2df)__B); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_sd(__m128d __A, __m128d __B) { + __A[0] = __A[0] - __B[0]; + return (__A); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_pd(__m128d __A, __m128d __B) { + return (__m128d)((__v2df)__A * (__v2df)__B); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_sd(__m128d __A, __m128d __B) { + __A[0] = __A[0] * __B[0]; + return (__A); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_div_pd(__m128d __A, __m128d __B) { + return (__m128d)((__v2df)__A / (__v2df)__B); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_div_sd(__m128d __A, __m128d __B) { + __A[0] = __A[0] / __B[0]; + return (__A); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sqrt_pd(__m128d __A) { + return (vec_sqrt(__A)); +} + +/* Return pair {sqrt (B[0]), A[1]}. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sqrt_sd(__m128d __A, __m128d __B) { + __v2df __c; + __c = vec_sqrt((__v2df)_mm_set1_pd(__B[0])); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_pd(__m128d __A, __m128d __B) { + return (vec_min(__A, __B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = vec_min(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_pd(__m128d __A, __m128d __B) { + return (vec_max(__A, __B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = vec_max(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmpeq((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmplt((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmple_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmple((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmpgt((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpge_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmpge((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpneq_pd(__m128d __A, __m128d __B) { + __v2df __temp = (__v2df)vec_cmpeq((__v2df)__A, (__v2df)__B); + return ((__m128d)vec_nor(__temp, __temp)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnlt_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmpge((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnle_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmpgt((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpngt_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmple((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnge_pd(__m128d __A, __m128d __B) { + return ((__m128d)vec_cmplt((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpord_pd(__m128d __A, __m128d __B) { + __v2du __c, __d; + /* Compare against self will return false (0's) if NAN. */ + __c = (__v2du)vec_cmpeq(__A, __A); + __d = (__v2du)vec_cmpeq(__B, __B); + /* A != NAN and B != NAN. */ + return ((__m128d)vec_and(__c, __d)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpunord_pd(__m128d __A, __m128d __B) { +#if _ARCH_PWR8 + __v2du __c, __d; + /* Compare against self will return false (0's) if NAN. */ + __c = (__v2du)vec_cmpeq((__v2df)__A, (__v2df)__A); + __d = (__v2du)vec_cmpeq((__v2df)__B, (__v2df)__B); + /* A == NAN OR B == NAN converts too: + NOT(A != NAN) OR NOT(B != NAN). */ + __c = vec_nor(__c, __c); + return ((__m128d)vec_orc(__c, __d)); +#else + __v2du __c, __d; + /* Compare against self will return false (0's) if NAN. */ + __c = (__v2du)vec_cmpeq((__v2df)__A, (__v2df)__A); + __d = (__v2du)vec_cmpeq((__v2df)__B, (__v2df)__B); + /* Convert the true ('1's) is NAN. */ + __c = vec_nor(__c, __c); + __d = vec_nor(__d, __d); + return ((__m128d)vec_or(__c, __d)); +#endif +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + /* PowerISA VSX does not allow partial (for just lower double) + results. So to insure we don't generate spurious exceptions + (from the upper double values) we splat the lower double + before we do the operation. */ + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = (__v2df)vec_cmpeq(__a, __b); + /* Then we merge the lower double result with the original upper + double from __A. */ + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = (__v2df)vec_cmplt(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmple_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = (__v2df)vec_cmple(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = (__v2df)vec_cmpgt(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpge_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = (__v2df)vec_cmpge(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpneq_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + __c = (__v2df)vec_cmpeq(__a, __b); + __c = vec_nor(__c, __c); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnlt_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + /* Not less than is just greater than or equal. */ + __c = (__v2df)vec_cmpge(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnle_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + /* Not less than or equal is just greater than. */ + __c = (__v2df)vec_cmpge(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpngt_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + /* Not greater than is just less than or equal. */ + __c = (__v2df)vec_cmple(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnge_sd(__m128d __A, __m128d __B) { + __v2df __a, __b, __c; + __a = vec_splats(__A[0]); + __b = vec_splats(__B[0]); + /* Not greater than or equal is just less than. */ + __c = (__v2df)vec_cmplt(__a, __b); + return (__m128d)_mm_setr_pd(__c[0], __A[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpord_sd(__m128d __A, __m128d __B) { + __v2df __r; + __r = (__v2df)_mm_cmpord_pd(vec_splats(__A[0]), vec_splats(__B[0])); + return (__m128d)_mm_setr_pd(__r[0], ((__v2df)__A)[1]); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpunord_sd(__m128d __A, __m128d __B) { + __v2df __r; + __r = _mm_cmpunord_pd(vec_splats(__A[0]), vec_splats(__B[0])); + return (__m128d)_mm_setr_pd(__r[0], __A[1]); +} + +/* FIXME + The __mm_comi??_sd and __mm_ucomi??_sd implementations below are + exactly the same because GCC for PowerPC only generates unordered + compares (scalar and vector). + Technically __mm_comieq_sp et all should be using the ordered + compare and signal for QNaNs. The __mm_ucomieq_sd et all should + be OK. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comieq_sd(__m128d __A, __m128d __B) { + return (__A[0] == __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comilt_sd(__m128d __A, __m128d __B) { + return (__A[0] < __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comile_sd(__m128d __A, __m128d __B) { + return (__A[0] <= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comigt_sd(__m128d __A, __m128d __B) { + return (__A[0] > __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comige_sd(__m128d __A, __m128d __B) { + return (__A[0] >= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comineq_sd(__m128d __A, __m128d __B) { + return (__A[0] != __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomieq_sd(__m128d __A, __m128d __B) { + return (__A[0] == __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomilt_sd(__m128d __A, __m128d __B) { + return (__A[0] < __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomile_sd(__m128d __A, __m128d __B) { + return (__A[0] <= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomigt_sd(__m128d __A, __m128d __B) { + return (__A[0] > __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomige_sd(__m128d __A, __m128d __B) { + return (__A[0] >= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomineq_sd(__m128d __A, __m128d __B) { + return (__A[0] != __B[0]); +} + +/* Create a vector of Qi, where i is the element number. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_epi64x(long long __q1, long long __q0) { + return __extension__(__m128i)(__v2di){__q0, __q1}; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_epi64(__m64 __q1, __m64 __q0) { + return _mm_set_epi64x((long long)__q1, (long long)__q0); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_epi32(int __q3, int __q2, int __q1, int __q0) { + return __extension__(__m128i)(__v4si){__q0, __q1, __q2, __q3}; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_epi16(short __q7, short __q6, short __q5, short __q4, short __q3, + short __q2, short __q1, short __q0) { + return __extension__(__m128i)(__v8hi){__q0, __q1, __q2, __q3, + __q4, __q5, __q6, __q7}; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_epi8(char __q15, char __q14, char __q13, char __q12, char __q11, + char __q10, char __q09, char __q08, char __q07, char __q06, + char __q05, char __q04, char __q03, char __q02, char __q01, + char __q00) { + return __extension__(__m128i)(__v16qi){ + __q00, __q01, __q02, __q03, __q04, __q05, __q06, __q07, + __q08, __q09, __q10, __q11, __q12, __q13, __q14, __q15}; +} + +/* Set all of the elements of the vector to A. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_epi64x(long long __A) { + return _mm_set_epi64x(__A, __A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_epi64(__m64 __A) { + return _mm_set_epi64(__A, __A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_epi32(int __A) { + return _mm_set_epi32(__A, __A, __A, __A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_epi16(short __A) { + return _mm_set_epi16(__A, __A, __A, __A, __A, __A, __A, __A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_epi8(char __A) { + return _mm_set_epi8(__A, __A, __A, __A, __A, __A, __A, __A, __A, __A, __A, + __A, __A, __A, __A, __A); +} + +/* Create a vector of Qi, where i is the element number. + The parameter order is reversed from the _mm_set_epi* functions. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_epi64(__m64 __q0, __m64 __q1) { + return _mm_set_epi64(__q1, __q0); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_epi32(int __q0, int __q1, int __q2, int __q3) { + return _mm_set_epi32(__q3, __q2, __q1, __q0); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_epi16(short __q0, short __q1, short __q2, short __q3, short __q4, + short __q5, short __q6, short __q7) { + return _mm_set_epi16(__q7, __q6, __q5, __q4, __q3, __q2, __q1, __q0); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_epi8(char __q00, char __q01, char __q02, char __q03, char __q04, + char __q05, char __q06, char __q07, char __q08, char __q09, + char __q10, char __q11, char __q12, char __q13, char __q14, + char __q15) { + return _mm_set_epi8(__q15, __q14, __q13, __q12, __q11, __q10, __q09, __q08, + __q07, __q06, __q05, __q04, __q03, __q02, __q01, __q00); +} + +/* Create a vector with element 0 as *P and the rest zero. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_si128(__m128i const *__P) { + return *__P; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadu_si128(__m128i_u const *__P) { + return (__m128i)(vec_vsx_ld(0, (signed int const *)__P)); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadl_epi64(__m128i_u const *__P) { + return _mm_set_epi64((__m64)0LL, *(__m64 *)__P); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_si128(__m128i *__P, __m128i __B) { + vec_st((__v16qu)__B, 0, (__v16qu *)__P); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storeu_si128(__m128i_u *__P, __m128i __B) { + *__P = __B; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storel_epi64(__m128i_u *__P, __m128i __B) { + *(long long *)__P = ((__v2di)__B)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movepi64_pi64(__m128i_u __B) { + return (__m64)((__v2di)__B)[0]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movpi64_epi64(__m64 __A) { + return _mm_set_epi64((__m64)0LL, __A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_move_epi64(__m128i __A) { + return _mm_set_epi64((__m64)0LL, (__m64)__A[0]); +} + +/* Create an undefined vector. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_undefined_si128(void) { + __m128i __Y = __Y; + return __Y; +} + +/* Create a vector of zeros. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setzero_si128(void) { + return __extension__(__m128i)(__v4si){0, 0, 0, 0}; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi32_pd(__m128i __A) { + __v2di __val; + /* For LE need to generate Vector Unpack Low Signed Word. + Which is generated from unpackh. */ + __val = (__v2di)vec_unpackh((__v4si)__A); + + return (__m128d)vec_ctf(__val, 0); +} +#endif + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi32_ps(__m128i __A) { + return ((__m128)vec_ctf((__v4si)__A, 0)); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpd_epi32(__m128d __A) { + __v2df __rounded = vec_rint(__A); + __v4si __result, __temp; + const __v4si __vzero = {0, 0, 0, 0}; + + /* VSX Vector truncate Double-Precision to integer and Convert to + Signed Integer Word format with Saturate. */ + __asm__("xvcvdpsxws %x0,%x1" : "=wa"(__temp) : "wa"(__rounded) :); + +#ifdef _ARCH_PWR8 +#ifdef __LITTLE_ENDIAN__ + __temp = vec_mergeo(__temp, __temp); +#else + __temp = vec_mergee(__temp, __temp); +#endif + __result = (__v4si)vec_vpkudum((__vector long long)__temp, + (__vector long long)__vzero); +#else + { + const __v16qu __pkperm = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, + 0x14, 0x15, 0x16, 0x17, 0x1c, 0x1d, 0x1e, 0x1f}; + __result = (__v4si)vec_perm((__v16qu)__temp, (__v16qu)__vzero, __pkperm); + } +#endif + return (__m128i)__result; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpd_pi32(__m128d __A) { + __m128i __result = _mm_cvtpd_epi32(__A); + + return (__m64)__result[0]; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpd_ps(__m128d __A) { + __v4sf __result; + __v4si __temp; + const __v4si __vzero = {0, 0, 0, 0}; + + __asm__("xvcvdpsp %x0,%x1" : "=wa"(__temp) : "wa"(__A) :); + +#ifdef _ARCH_PWR8 +#ifdef __LITTLE_ENDIAN__ + __temp = vec_mergeo(__temp, __temp); +#else + __temp = vec_mergee(__temp, __temp); +#endif + __result = (__v4sf)vec_vpkudum((__vector long long)__temp, + (__vector long long)__vzero); +#else + { + const __v16qu __pkperm = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, + 0x14, 0x15, 0x16, 0x17, 0x1c, 0x1d, 0x1e, 0x1f}; + __result = (__v4sf)vec_perm((__v16qu)__temp, (__v16qu)__vzero, __pkperm); + } +#endif + return ((__m128)__result); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttpd_epi32(__m128d __A) { + __v4si __result; + __v4si __temp; + const __v4si __vzero = {0, 0, 0, 0}; + + /* VSX Vector truncate Double-Precision to integer and Convert to + Signed Integer Word format with Saturate. */ + __asm__("xvcvdpsxws %x0,%x1" : "=wa"(__temp) : "wa"(__A) :); + +#ifdef _ARCH_PWR8 +#ifdef __LITTLE_ENDIAN__ + __temp = vec_mergeo(__temp, __temp); +#else + __temp = vec_mergee(__temp, __temp); +#endif + __result = (__v4si)vec_vpkudum((__vector long long)__temp, + (__vector long long)__vzero); +#else + { + const __v16qu __pkperm = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0a, 0x0b, + 0x14, 0x15, 0x16, 0x17, 0x1c, 0x1d, 0x1e, 0x1f}; + __result = (__v4si)vec_perm((__v16qu)__temp, (__v16qu)__vzero, __pkperm); + } +#endif + + return ((__m128i)__result); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttpd_pi32(__m128d __A) { + __m128i __result = _mm_cvttpd_epi32(__A); + + return (__m64)__result[0]; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi128_si32(__m128i __A) { + return ((__v4si)__A)[0]; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpi32_pd(__m64 __A) { + __v4si __temp; + __v2di __tmp2; + __v4f __result; + + __temp = (__v4si)vec_splats(__A); + __tmp2 = (__v2di)vec_unpackl(__temp); + __result = vec_ctf((__vector signed long long)__tmp2, 0); + return (__m128d)__result; +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtps_epi32(__m128 __A) { + __v4sf __rounded; + __v4si __result; + + __rounded = vec_rint((__v4sf)__A); + __result = vec_cts(__rounded, 0); + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttps_epi32(__m128 __A) { + __v4si __result; + + __result = vec_cts((__v4sf)__A, 0); + return (__m128i)__result; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtps_pd(__m128 __A) { + /* Check if vec_doubleh is defined by . If so use that. */ +#ifdef vec_doubleh + return (__m128d)vec_doubleh((__v4sf)__A); +#else + /* Otherwise the compiler is not current and so need to generate the + equivalent code. */ + __v4sf __a = (__v4sf)__A; + __v4sf __temp; + __v2df __result; +#ifdef __LITTLE_ENDIAN__ + /* The input float values are in elements {[0], [1]} but the convert + instruction needs them in elements {[1], [3]}, So we use two + shift left double vector word immediates to get the elements + lined up. */ + __temp = __builtin_vsx_xxsldwi(__a, __a, 3); + __temp = __builtin_vsx_xxsldwi(__a, __temp, 2); +#else + /* The input float values are in elements {[0], [1]} but the convert + instruction needs them in elements {[0], [2]}, So we use two + shift left double vector word immediates to get the elements + lined up. */ + __temp = vec_vmrghw(__a, __a); +#endif + __asm__(" xvcvspdp %x0,%x1" : "=wa"(__result) : "wa"(__temp) :); + return (__m128d)__result; +#endif +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsd_si32(__m128d __A) { + __v2df __rounded = vec_rint((__v2df)__A); + int __result = ((__v2df)__rounded)[0]; + + return __result; +} +/* Intel intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsd_si64(__m128d __A) { + __v2df __rounded = vec_rint((__v2df)__A); + long long __result = ((__v2df)__rounded)[0]; + + return __result; +} + +/* Microsoft intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsd_si64x(__m128d __A) { + return _mm_cvtsd_si64((__v2df)__A); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttsd_si32(__m128d __A) { + int __result = ((__v2df)__A)[0]; + + return __result; +} + +/* Intel intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttsd_si64(__m128d __A) { + long long __result = ((__v2df)__A)[0]; + + return __result; +} + +/* Microsoft intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttsd_si64x(__m128d __A) { + return _mm_cvttsd_si64(__A); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsd_ss(__m128 __A, __m128d __B) { + __v4sf __result = (__v4sf)__A; + +#ifdef __LITTLE_ENDIAN__ + __v4sf __temp_s; + /* Copy double element[0] to element [1] for conversion. */ + __v2df __temp_b = vec_splat((__v2df)__B, 0); + + /* Pre-rotate __A left 3 (logically right 1) elements. */ + __result = __builtin_vsx_xxsldwi(__result, __result, 3); + /* Convert double to single float scalar in a vector. */ + __asm__("xscvdpsp %x0,%x1" : "=wa"(__temp_s) : "wa"(__temp_b) :); + /* Shift the resulting scalar into vector element [0]. */ + __result = __builtin_vsx_xxsldwi(__result, __temp_s, 1); +#else + __result[0] = ((__v2df)__B)[0]; +#endif + return (__m128)__result; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi32_sd(__m128d __A, int __B) { + __v2df __result = (__v2df)__A; + double __db = __B; + __result[0] = __db; + return (__m128d)__result; +} + +/* Intel intrinsic. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64_sd(__m128d __A, long long __B) { + __v2df __result = (__v2df)__A; + double __db = __B; + __result[0] = __db; + return (__m128d)__result; +} + +/* Microsoft intrinsic. */ +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64x_sd(__m128d __A, long long __B) { + return _mm_cvtsi64_sd(__A, __B); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtss_sd(__m128d __A, __m128 __B) { +#ifdef __LITTLE_ENDIAN__ + /* Use splat to move element [0] into position for the convert. */ + __v4sf __temp = vec_splat((__v4sf)__B, 0); + __v2df __res; + /* Convert single float scalar to double in a vector. */ + __asm__("xscvspdp %x0,%x1" : "=wa"(__res) : "wa"(__temp) :); + return (__m128d)vec_mergel(__res, (__v2df)__A); +#else + __v2df __res = (__v2df)__A; + __res[0] = ((__v4sf)__B)[0]; + return (__m128d)__res; +#endif +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shuffle_pd(__m128d __A, __m128d __B, const int __mask) { + __vector double __result; + const int __litmsk = __mask & 0x3; + + if (__litmsk == 0) + __result = vec_mergeh(__A, __B); +#if __GNUC__ < 6 + else if (__litmsk == 1) + __result = vec_xxpermdi(__B, __A, 2); + else if (__litmsk == 2) + __result = vec_xxpermdi(__B, __A, 1); +#else + else if (__litmsk == 1) + __result = vec_xxpermdi(__A, __B, 2); + else if (__litmsk == 2) + __result = vec_xxpermdi(__A, __B, 1); +#endif + else + __result = vec_mergel(__A, __B); + + return __result; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_pd(__m128d __A, __m128d __B) { + return (__m128d)vec_mergel((__v2df)__A, (__v2df)__B); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_pd(__m128d __A, __m128d __B) { + return (__m128d)vec_mergeh((__v2df)__A, (__v2df)__B); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadh_pd(__m128d __A, double const *__B) { + __v2df __result = (__v2df)__A; + __result[1] = *__B; + return (__m128d)__result; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadl_pd(__m128d __A, double const *__B) { + __v2df __result = (__v2df)__A; + __result[0] = *__B; + return (__m128d)__result; +} + +#ifdef _ARCH_PWR8 +/* Intrinsic functions that require PowerISA 2.07 minimum. */ + +/* Creates a 2-bit mask from the most significant bits of the DPFP values. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movemask_pd(__m128d __A) { +#ifdef _ARCH_PWR10 + return vec_extractm((__v2du)__A); +#else + __vector unsigned long long __result; + static const __vector unsigned int __perm_mask = { +#ifdef __LITTLE_ENDIAN__ + 0x80800040, 0x80808080, 0x80808080, 0x80808080 +#else + 0x80808080, 0x80808080, 0x80808080, 0x80804000 +#endif + }; + + __result = ((__vector unsigned long long)vec_vbpermq( + (__vector unsigned char)__A, (__vector unsigned char)__perm_mask)); + +#ifdef __LITTLE_ENDIAN__ + return __result[1]; +#else + return __result[0]; +#endif +#endif /* !_ARCH_PWR10 */ +} +#endif /* _ARCH_PWR8 */ + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packs_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_packs((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packs_epi32(__m128i __A, __m128i __B) { + return (__m128i)vec_packs((__v4si)__A, (__v4si)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packus_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_packsu((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_mergel((__v16qu)__A, (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_mergel((__v8hu)__A, (__v8hu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_epi32(__m128i __A, __m128i __B) { + return (__m128i)vec_mergel((__v4su)__A, (__v4su)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_epi64(__m128i __A, __m128i __B) { + return (__m128i)vec_mergel((__vector long long)__A, (__vector long long)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_mergeh((__v16qu)__A, (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_mergeh((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_epi32(__m128i __A, __m128i __B) { + return (__m128i)vec_mergeh((__v4si)__A, (__v4si)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_epi64(__m128i __A, __m128i __B) { + return (__m128i)vec_mergeh((__vector long long)__A, (__vector long long)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_epi8(__m128i __A, __m128i __B) { + return (__m128i)((__v16qu)__A + (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_epi16(__m128i __A, __m128i __B) { + return (__m128i)((__v8hu)__A + (__v8hu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_epi32(__m128i __A, __m128i __B) { + return (__m128i)((__v4su)__A + (__v4su)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_epi64(__m128i __A, __m128i __B) { + return (__m128i)((__v2du)__A + (__v2du)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_adds((__v16qi)__A, (__v16qi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_adds((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_epu8(__m128i __A, __m128i __B) { + return (__m128i)vec_adds((__v16qu)__A, (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_epu16(__m128i __A, __m128i __B) { + return (__m128i)vec_adds((__v8hu)__A, (__v8hu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_epi8(__m128i __A, __m128i __B) { + return (__m128i)((__v16qu)__A - (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_epi16(__m128i __A, __m128i __B) { + return (__m128i)((__v8hu)__A - (__v8hu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_epi32(__m128i __A, __m128i __B) { + return (__m128i)((__v4su)__A - (__v4su)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_epi64(__m128i __A, __m128i __B) { + return (__m128i)((__v2du)__A - (__v2du)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_subs((__v16qi)__A, (__v16qi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_subs((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_epu8(__m128i __A, __m128i __B) { + return (__m128i)vec_subs((__v16qu)__A, (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_epu16(__m128i __A, __m128i __B) { + return (__m128i)vec_subs((__v8hu)__A, (__v8hu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_madd_epi16(__m128i __A, __m128i __B) { + __vector signed int __zero = {0, 0, 0, 0}; + + return (__m128i)vec_vmsumshm((__v8hi)__A, (__v8hi)__B, __zero); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mulhi_epi16(__m128i __A, __m128i __B) { + __vector signed int __w0, __w1; + + __vector unsigned char __xform1 = { +#ifdef __LITTLE_ENDIAN__ + 0x02, 0x03, 0x12, 0x13, 0x06, 0x07, 0x16, 0x17, 0x0A, + 0x0B, 0x1A, 0x1B, 0x0E, 0x0F, 0x1E, 0x1F +#else + 0x00, 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15, 0x08, + 0x09, 0x18, 0x19, 0x0C, 0x0D, 0x1C, 0x1D +#endif + }; + + __w0 = vec_vmulesh((__v8hi)__A, (__v8hi)__B); + __w1 = vec_vmulosh((__v8hi)__A, (__v8hi)__B); + return (__m128i)vec_perm(__w0, __w1, __xform1); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mullo_epi16(__m128i __A, __m128i __B) { + return (__m128i)((__v8hi)__A * (__v8hi)__B); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_su32(__m64 __A, __m64 __B) { + unsigned int __a = __A; + unsigned int __b = __B; + + return ((__m64)__a * (__m64)__b); +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_epu32(__m128i __A, __m128i __B) { +#if __GNUC__ < 8 + __v2du __result; + +#ifdef __LITTLE_ENDIAN__ + /* VMX Vector Multiply Odd Unsigned Word. */ + __asm__("vmulouw %0,%1,%2" : "=v"(__result) : "v"(__A), "v"(__B) :); +#else + /* VMX Vector Multiply Even Unsigned Word. */ + __asm__("vmuleuw %0,%1,%2" : "=v"(__result) : "v"(__A), "v"(__B) :); +#endif + return (__m128i)__result; +#else + return (__m128i)vec_mule((__v4su)__A, (__v4su)__B); +#endif +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_epi16(__m128i __A, int __B) { + __v8hu __lshift; + __v8hi __result = {0, 0, 0, 0, 0, 0, 0, 0}; + + if (__B >= 0 && __B < 16) { + if (__builtin_constant_p(__B)) + __lshift = (__v8hu)vec_splat_s16(__B); + else + __lshift = vec_splats((unsigned short)__B); + + __result = vec_sl((__v8hi)__A, __lshift); + } + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_epi32(__m128i __A, int __B) { + __v4su __lshift; + __v4si __result = {0, 0, 0, 0}; + + if (__B >= 0 && __B < 32) { + if (__builtin_constant_p(__B) && __B < 16) + __lshift = (__v4su)vec_splat_s32(__B); + else + __lshift = vec_splats((unsigned int)__B); + + __result = vec_sl((__v4si)__A, __lshift); + } + + return (__m128i)__result; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_epi64(__m128i __A, int __B) { + __v2du __lshift; + __v2di __result = {0, 0}; + + if (__B >= 0 && __B < 64) { + if (__builtin_constant_p(__B) && __B < 16) + __lshift = (__v2du)vec_splat_s32(__B); + else + __lshift = (__v2du)vec_splats((unsigned int)__B); + + __result = vec_sl((__v2di)__A, __lshift); + } + + return (__m128i)__result; +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srai_epi16(__m128i __A, int __B) { + __v8hu __rshift = {15, 15, 15, 15, 15, 15, 15, 15}; + __v8hi __result; + + if (__B < 16) { + if (__builtin_constant_p(__B)) + __rshift = (__v8hu)vec_splat_s16(__B); + else + __rshift = vec_splats((unsigned short)__B); + } + __result = vec_sra((__v8hi)__A, __rshift); + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srai_epi32(__m128i __A, int __B) { + __v4su __rshift = {31, 31, 31, 31}; + __v4si __result; + + if (__B < 32) { + if (__builtin_constant_p(__B)) { + if (__B < 16) + __rshift = (__v4su)vec_splat_s32(__B); + else + __rshift = (__v4su)vec_splats((unsigned int)__B); + } else + __rshift = vec_splats((unsigned int)__B); + } + __result = vec_sra((__v4si)__A, __rshift); + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_bslli_si128(__m128i __A, const int __N) { + __v16qu __result; + const __v16qu __zeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + if (__N < 16) + __result = vec_sld((__v16qu)__A, __zeros, __N); + else + __result = __zeros; + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_bsrli_si128(__m128i __A, const int __N) { + __v16qu __result; + const __v16qu __zeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + if (__N < 16) +#ifdef __LITTLE_ENDIAN__ + if (__builtin_constant_p(__N)) + /* Would like to use Vector Shift Left Double by Octet + Immediate here to use the immediate form and avoid + load of __N * 8 value into a separate VR. */ + __result = vec_sld(__zeros, (__v16qu)__A, (16 - __N)); + else +#endif + { + __v16qu __shift = vec_splats((unsigned char)(__N * 8)); +#ifdef __LITTLE_ENDIAN__ + __result = vec_sro((__v16qu)__A, __shift); +#else + __result = vec_slo((__v16qu)__A, __shift); +#endif + } + else + __result = __zeros; + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srli_si128(__m128i __A, const int __N) { + return _mm_bsrli_si128(__A, __N); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_si128(__m128i __A, const int _imm5) { + __v16qu __result; + const __v16qu __zeros = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + if (_imm5 < 16) +#ifdef __LITTLE_ENDIAN__ + __result = vec_sld((__v16qu)__A, __zeros, _imm5); +#else + __result = vec_sld(__zeros, (__v16qu)__A, (16 - _imm5)); +#endif + else + __result = __zeros; + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + + _mm_srli_epi16(__m128i __A, int __B) { + __v8hu __rshift; + __v8hi __result = {0, 0, 0, 0, 0, 0, 0, 0}; + + if (__B < 16) { + if (__builtin_constant_p(__B)) + __rshift = (__v8hu)vec_splat_s16(__B); + else + __rshift = vec_splats((unsigned short)__B); + + __result = vec_sr((__v8hi)__A, __rshift); + } + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srli_epi32(__m128i __A, int __B) { + __v4su __rshift; + __v4si __result = {0, 0, 0, 0}; + + if (__B < 32) { + if (__builtin_constant_p(__B)) { + if (__B < 16) + __rshift = (__v4su)vec_splat_s32(__B); + else + __rshift = (__v4su)vec_splats((unsigned int)__B); + } else + __rshift = vec_splats((unsigned int)__B); + + __result = vec_sr((__v4si)__A, __rshift); + } + + return (__m128i)__result; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srli_epi64(__m128i __A, int __B) { + __v2du __rshift; + __v2di __result = {0, 0}; + + if (__B < 64) { + if (__builtin_constant_p(__B)) { + if (__B < 16) + __rshift = (__v2du)vec_splat_s32(__B); + else + __rshift = (__v2du)vec_splats((unsigned long long)__B); + } else + __rshift = (__v2du)vec_splats((unsigned int)__B); + + __result = vec_sr((__v2di)__A, __rshift); + } + + return (__m128i)__result; +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sll_epi16(__m128i __A, __m128i __B) { + __v8hu __lshift; + __vector __bool short __shmask; + const __v8hu __shmax = {15, 15, 15, 15, 15, 15, 15, 15}; + __v8hu __result; + +#ifdef __LITTLE_ENDIAN__ + __lshift = vec_splat((__v8hu)__B, 0); +#else + __lshift = vec_splat((__v8hu)__B, 3); +#endif + __shmask = vec_cmple(__lshift, __shmax); + __result = vec_sl((__v8hu)__A, __lshift); + __result = vec_sel((__v8hu)__shmask, __result, __shmask); + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sll_epi32(__m128i __A, __m128i __B) { + __v4su __lshift; + __vector __bool int __shmask; + const __v4su __shmax = {32, 32, 32, 32}; + __v4su __result; +#ifdef __LITTLE_ENDIAN__ + __lshift = vec_splat((__v4su)__B, 0); +#else + __lshift = vec_splat((__v4su)__B, 1); +#endif + __shmask = vec_cmplt(__lshift, __shmax); + __result = vec_sl((__v4su)__A, __lshift); + __result = vec_sel((__v4su)__shmask, __result, __shmask); + + return (__m128i)__result; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sll_epi64(__m128i __A, __m128i __B) { + __v2du __lshift; + __vector __bool long long __shmask; + const __v2du __shmax = {64, 64}; + __v2du __result; + + __lshift = vec_splat((__v2du)__B, 0); + __shmask = vec_cmplt(__lshift, __shmax); + __result = vec_sl((__v2du)__A, __lshift); + __result = vec_sel((__v2du)__shmask, __result, __shmask); + + return (__m128i)__result; +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sra_epi16(__m128i __A, __m128i __B) { + const __v8hu __rshmax = {15, 15, 15, 15, 15, 15, 15, 15}; + __v8hu __rshift; + __v8hi __result; + +#ifdef __LITTLE_ENDIAN__ + __rshift = vec_splat((__v8hu)__B, 0); +#else + __rshift = vec_splat((__v8hu)__B, 3); +#endif + __rshift = vec_min(__rshift, __rshmax); + __result = vec_sra((__v8hi)__A, __rshift); + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sra_epi32(__m128i __A, __m128i __B) { + const __v4su __rshmax = {31, 31, 31, 31}; + __v4su __rshift; + __v4si __result; + +#ifdef __LITTLE_ENDIAN__ + __rshift = vec_splat((__v4su)__B, 0); +#else + __rshift = vec_splat((__v4su)__B, 1); +#endif + __rshift = vec_min(__rshift, __rshmax); + __result = vec_sra((__v4si)__A, __rshift); + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srl_epi16(__m128i __A, __m128i __B) { + __v8hu __rshift; + __vector __bool short __shmask; + const __v8hu __shmax = {15, 15, 15, 15, 15, 15, 15, 15}; + __v8hu __result; + +#ifdef __LITTLE_ENDIAN__ + __rshift = vec_splat((__v8hu)__B, 0); +#else + __rshift = vec_splat((__v8hu)__B, 3); +#endif + __shmask = vec_cmple(__rshift, __shmax); + __result = vec_sr((__v8hu)__A, __rshift); + __result = vec_sel((__v8hu)__shmask, __result, __shmask); + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srl_epi32(__m128i __A, __m128i __B) { + __v4su __rshift; + __vector __bool int __shmask; + const __v4su __shmax = {32, 32, 32, 32}; + __v4su __result; + +#ifdef __LITTLE_ENDIAN__ + __rshift = vec_splat((__v4su)__B, 0); +#else + __rshift = vec_splat((__v4su)__B, 1); +#endif + __shmask = vec_cmplt(__rshift, __shmax); + __result = vec_sr((__v4su)__A, __rshift); + __result = vec_sel((__v4su)__shmask, __result, __shmask); + + return (__m128i)__result; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srl_epi64(__m128i __A, __m128i __B) { + __v2du __rshift; + __vector __bool long long __shmask; + const __v2du __shmax = {64, 64}; + __v2du __result; + + __rshift = vec_splat((__v2du)__B, 0); + __shmask = vec_cmplt(__rshift, __shmax); + __result = vec_sr((__v2du)__A, __rshift); + __result = vec_sel((__v2du)__shmask, __result, __shmask); + + return (__m128i)__result; +} +#endif + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_and_pd(__m128d __A, __m128d __B) { + return (vec_and((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_andnot_pd(__m128d __A, __m128d __B) { + return (vec_andc((__v2df)__B, (__v2df)__A)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_or_pd(__m128d __A, __m128d __B) { + return (vec_or((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_xor_pd(__m128d __A, __m128d __B) { + return (vec_xor((__v2df)__A, (__v2df)__B)); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_and_si128(__m128i __A, __m128i __B) { + return (__m128i)vec_and((__v2di)__A, (__v2di)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_andnot_si128(__m128i __A, __m128i __B) { + return (__m128i)vec_andc((__v2di)__B, (__v2di)__A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_or_si128(__m128i __A, __m128i __B) { + return (__m128i)vec_or((__v2di)__A, (__v2di)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_xor_si128(__m128i __A, __m128i __B) { + return (__m128i)vec_xor((__v2di)__A, (__v2di)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_cmpeq((__v16qi)__A, (__v16qi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_cmpeq((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_epi32(__m128i __A, __m128i __B) { + return (__m128i)vec_cmpeq((__v4si)__A, (__v4si)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_cmplt((__v16qi)__A, (__v16qi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_cmplt((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_epi32(__m128i __A, __m128i __B) { + return (__m128i)vec_cmplt((__v4si)__A, (__v4si)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_epi8(__m128i __A, __m128i __B) { + return (__m128i)vec_cmpgt((__v16qi)__A, (__v16qi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_cmpgt((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_epi32(__m128i __A, __m128i __B) { + return (__m128i)vec_cmpgt((__v4si)__A, (__v4si)__B); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_extract_epi16(__m128i const __A, int const __N) { + return (unsigned short)((__v8hi)__A)[__N & 7]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_insert_epi16(__m128i const __A, int const __D, int const __N) { + __v8hi __result = (__v8hi)__A; + + __result[(__N & 7)] = __D; + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_max((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_epu8(__m128i __A, __m128i __B) { + return (__m128i)vec_max((__v16qu)__A, (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_epi16(__m128i __A, __m128i __B) { + return (__m128i)vec_min((__v8hi)__A, (__v8hi)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_epu8(__m128i __A, __m128i __B) { + return (__m128i)vec_min((__v16qu)__A, (__v16qu)__B); +} + +#ifdef _ARCH_PWR8 +/* Intrinsic functions that require PowerISA 2.07 minimum. */ + +/* Return a mask created from the most significant bit of each 8-bit + element in A. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movemask_epi8(__m128i __A) { +#ifdef _ARCH_PWR10 + return vec_extractm((__v16qu)__A); +#else + __vector unsigned long long __result; + static const __vector unsigned char __perm_mask = { + 0x78, 0x70, 0x68, 0x60, 0x58, 0x50, 0x48, 0x40, + 0x38, 0x30, 0x28, 0x20, 0x18, 0x10, 0x08, 0x00}; + + __result = ((__vector unsigned long long)vec_vbpermq( + (__vector unsigned char)__A, (__vector unsigned char)__perm_mask)); + +#ifdef __LITTLE_ENDIAN__ + return __result[1]; +#else + return __result[0]; +#endif +#endif /* !_ARCH_PWR10 */ +} +#endif /* _ARCH_PWR8 */ + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mulhi_epu16(__m128i __A, __m128i __B) { + __v4su __w0, __w1; + __v16qu __xform1 = { +#ifdef __LITTLE_ENDIAN__ + 0x02, 0x03, 0x12, 0x13, 0x06, 0x07, 0x16, 0x17, 0x0A, + 0x0B, 0x1A, 0x1B, 0x0E, 0x0F, 0x1E, 0x1F +#else + 0x00, 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15, 0x08, + 0x09, 0x18, 0x19, 0x0C, 0x0D, 0x1C, 0x1D +#endif + }; + + __w0 = vec_vmuleuh((__v8hu)__A, (__v8hu)__B); + __w1 = vec_vmulouh((__v8hu)__A, (__v8hu)__B); + return (__m128i)vec_perm(__w0, __w1, __xform1); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shufflehi_epi16(__m128i __A, const int __mask) { + unsigned long __element_selector_98 = __mask & 0x03; + unsigned long __element_selector_BA = (__mask >> 2) & 0x03; + unsigned long __element_selector_DC = (__mask >> 4) & 0x03; + unsigned long __element_selector_FE = (__mask >> 6) & 0x03; + static const unsigned short __permute_selectors[4] = { +#ifdef __LITTLE_ENDIAN__ + 0x0908, 0x0B0A, 0x0D0C, 0x0F0E +#else + 0x0809, 0x0A0B, 0x0C0D, 0x0E0F +#endif + }; + __v2du __pmask = +#ifdef __LITTLE_ENDIAN__ + {0x1716151413121110UL, 0UL}; +#else + {0x1011121314151617UL, 0UL}; +#endif + __m64_union __t; + __v2du __a, __r; + + __t.as_short[0] = __permute_selectors[__element_selector_98]; + __t.as_short[1] = __permute_selectors[__element_selector_BA]; + __t.as_short[2] = __permute_selectors[__element_selector_DC]; + __t.as_short[3] = __permute_selectors[__element_selector_FE]; + __pmask[1] = __t.as_m64; + __a = (__v2du)__A; + __r = vec_perm(__a, __a, (__vector unsigned char)__pmask); + return (__m128i)__r; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shufflelo_epi16(__m128i __A, const int __mask) { + unsigned long __element_selector_10 = __mask & 0x03; + unsigned long __element_selector_32 = (__mask >> 2) & 0x03; + unsigned long __element_selector_54 = (__mask >> 4) & 0x03; + unsigned long __element_selector_76 = (__mask >> 6) & 0x03; + static const unsigned short __permute_selectors[4] = { +#ifdef __LITTLE_ENDIAN__ + 0x0100, 0x0302, 0x0504, 0x0706 +#else + 0x0001, 0x0203, 0x0405, 0x0607 +#endif + }; + __v2du __pmask = +#ifdef __LITTLE_ENDIAN__ + {0UL, 0x1f1e1d1c1b1a1918UL}; +#else + {0UL, 0x18191a1b1c1d1e1fUL}; +#endif + __m64_union __t; + __v2du __a, __r; + __t.as_short[0] = __permute_selectors[__element_selector_10]; + __t.as_short[1] = __permute_selectors[__element_selector_32]; + __t.as_short[2] = __permute_selectors[__element_selector_54]; + __t.as_short[3] = __permute_selectors[__element_selector_76]; + __pmask[0] = __t.as_m64; + __a = (__v2du)__A; + __r = vec_perm(__a, __a, (__vector unsigned char)__pmask); + return (__m128i)__r; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shuffle_epi32(__m128i __A, const int __mask) { + unsigned long __element_selector_10 = __mask & 0x03; + unsigned long __element_selector_32 = (__mask >> 2) & 0x03; + unsigned long __element_selector_54 = (__mask >> 4) & 0x03; + unsigned long __element_selector_76 = (__mask >> 6) & 0x03; + static const unsigned int __permute_selectors[4] = { +#ifdef __LITTLE_ENDIAN__ + 0x03020100, 0x07060504, 0x0B0A0908, 0x0F0E0D0C +#else + 0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F +#endif + }; + __v4su __t; + + __t[0] = __permute_selectors[__element_selector_10]; + __t[1] = __permute_selectors[__element_selector_32]; + __t[2] = __permute_selectors[__element_selector_54] + 0x10101010; + __t[3] = __permute_selectors[__element_selector_76] + 0x10101010; + return (__m128i)vec_perm((__v4si)__A, (__v4si)__A, + (__vector unsigned char)__t); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_maskmoveu_si128(__m128i __A, __m128i __B, char *__C) { + __v2du __hibit = {0x7f7f7f7f7f7f7f7fUL, 0x7f7f7f7f7f7f7f7fUL}; + __v16qu __mask, __tmp; + __m128i_u *__p = (__m128i_u *)__C; + + __tmp = (__v16qu)_mm_loadu_si128(__p); + __mask = (__v16qu)vec_cmpgt((__v16qu)__B, (__v16qu)__hibit); + __tmp = vec_sel(__tmp, (__v16qu)__A, __mask); + _mm_storeu_si128(__p, (__m128i)__tmp); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_avg_epu8(__m128i __A, __m128i __B) { + return (__m128i)vec_avg((__v16qu)__A, (__v16qu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_avg_epu16(__m128i __A, __m128i __B) { + return (__m128i)vec_avg((__v8hu)__A, (__v8hu)__B); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sad_epu8(__m128i __A, __m128i __B) { + __v16qu __a, __b; + __v16qu __vabsdiff; + __v4si __vsum; + const __v4su __zero = {0, 0, 0, 0}; + __v4si __result; + + __a = (__v16qu)__A; + __b = (__v16qu)__B; +#ifndef _ARCH_PWR9 + __v16qu __vmin = vec_min(__a, __b); + __v16qu __vmax = vec_max(__a, __b); + __vabsdiff = vec_sub(__vmax, __vmin); +#else + __vabsdiff = vec_absd(__a, __b); +#endif + /* Sum four groups of bytes into integers. */ + __vsum = (__vector signed int)vec_sum4s(__vabsdiff, __zero); +#ifdef __LITTLE_ENDIAN__ + /* Sum across four integers with two integer results. */ + __asm__("vsum2sws %0,%1,%2" : "=v"(__result) : "v"(__vsum), "v"(__zero)); + /* Note: vec_sum2s could be used here, but on little-endian, vector + shifts are added that are not needed for this use-case. + A vector shift to correctly position the 32-bit integer results + (currently at [0] and [2]) to [1] and [3] would then need to be + swapped back again since the desired results are two 64-bit + integers ([1]|[0] and [3]|[2]). Thus, no shift is performed. */ +#else + /* Sum across four integers with two integer results. */ + __result = vec_sum2s(__vsum, (__vector signed int)__zero); + /* Rotate the sums into the correct position. */ + __result = vec_sld(__result, __result, 6); +#endif + return (__m128i)__result; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_stream_si32(int *__A, int __B) { + /* Use the data cache block touch for store transient. */ + __asm__("dcbtstt 0,%0" : : "b"(__A) : "memory"); + *__A = __B; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_stream_si64(long long int *__A, long long int __B) { + /* Use the data cache block touch for store transient. */ + __asm__(" dcbtstt 0,%0" : : "b"(__A) : "memory"); + *__A = __B; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_stream_si128(__m128i *__A, __m128i __B) { + /* Use the data cache block touch for store transient. */ + __asm__("dcbtstt 0,%0" : : "b"(__A) : "memory"); + *__A = __B; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_stream_pd(double *__A, __m128d __B) { + /* Use the data cache block touch for store transient. */ + __asm__("dcbtstt 0,%0" : : "b"(__A) : "memory"); + *(__m128d *)__A = __B; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_clflush(void const *__A) { + /* Use the data cache block flush. */ + __asm__("dcbf 0,%0" : : "b"(__A) : "memory"); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_lfence(void) { + /* Use light weight sync for load to load ordering. */ + __atomic_thread_fence(__ATOMIC_RELEASE); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mfence(void) { + /* Use heavy weight sync for any to any ordering. */ + __atomic_thread_fence(__ATOMIC_SEQ_CST); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi32_si128(int __A) { + return _mm_set_epi32(0, 0, 0, __A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64_si128(long long __A) { + return __extension__(__m128i)(__v2di){__A, 0LL}; +} + +/* Microsoft intrinsic. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64x_si128(long long __A) { + return __extension__(__m128i)(__v2di){__A, 0LL}; +} + +/* Casts between various SP, DP, INT vector types. Note that these do no + conversion of values, they just change the type. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_castpd_ps(__m128d __A) { + return (__m128)__A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_castpd_si128(__m128d __A) { + return (__m128i)__A; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_castps_pd(__m128 __A) { + return (__m128d)__A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_castps_si128(__m128 __A) { + return (__m128i)__A; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_castsi128_ps(__m128i __A) { + return (__m128)__A; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_castsi128_pd(__m128i __A) { + return (__m128d)__A; +} + +#else +#include_next +#endif /* defined(__powerpc64__) && \ + * (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */ + +#endif /* EMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/immintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/immintrin.h new file mode 100755 index 0000000..c1ada98 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/immintrin.h @@ -0,0 +1,27 @@ +/*===---- immintrin.h - Implementation of Intel intrinsics on PowerPC ------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef IMMINTRIN_H_ +#define IMMINTRIN_H_ + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#endif /* IMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/mm_malloc.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/mm_malloc.h new file mode 100755 index 0000000..7c1e625 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/mm_malloc.h @@ -0,0 +1,45 @@ +/*===---- mm_malloc.h - Implementation of _mm_malloc and _mm_free ----------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _MM_MALLOC_H_INCLUDED +#define _MM_MALLOC_H_INCLUDED + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +#include + +/* We can't depend on since the prototype of posix_memalign + may not be visible. */ +#ifndef __cplusplus +extern int posix_memalign(void **, size_t, size_t); +#else +extern "C" int posix_memalign(void **, size_t, size_t); +#endif + +static __inline void *_mm_malloc(size_t __size, size_t __alignment) { + /* PowerPC64 ELF V2 ABI requires quadword alignment. */ + size_t __vec_align = sizeof(__vector float); + void *__ptr; + + if (__alignment < __vec_align) + __alignment = __vec_align; + if (posix_memalign(&__ptr, __alignment, __size) == 0) + return __ptr; + else + return NULL; +} + +static __inline void _mm_free(void *__ptr) { free(__ptr); } + +#else +#include_next +#endif + +#endif /* _MM_MALLOC_H_INCLUDED */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/mmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/mmintrin.h new file mode 100755 index 0000000..0be3af2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/mmintrin.h @@ -0,0 +1,1453 @@ +/*===---- mmintrin.h - Implementation of MMX intrinsics on PowerPC ---------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Implemented from the specification included in the Intel C++ Compiler + User Guide and Reference, version 9.0. */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header file is to help porting code using Intel intrinsics + explicitly from x86_64 to powerpc64/powerpc64le. + + Since PowerPC target doesn't support native 64-bit vector type, we + typedef __m64 to 64-bit unsigned long long in MMX intrinsics, which + works well for _si64 and some _pi32 operations. + + For _pi16 and _pi8 operations, it's better to transfer __m64 into + 128-bit PowerPC vector first. Power8 introduced direct register + move instructions which helps for more efficient implementation. + + It's user's responsibility to determine if the results of such port + are acceptable or further changes are needed. Please note that much + code using Intel intrinsics CAN BE REWRITTEN in more portable and + efficient standard C or GNU C extensions with 64-bit scalar + operations, or 128-bit SSE/Altivec operations, which are more + recommended. */ +#error \ + "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this error." +#endif + +#ifndef _MMINTRIN_H_INCLUDED +#define _MMINTRIN_H_INCLUDED + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +#include +/* The Intel API is flexible enough that we must allow aliasing with other + vector types, and their scalar components. */ +typedef __attribute__((__aligned__(8))) unsigned long long __m64; + +typedef __attribute__((__aligned__(8))) union { + __m64 as_m64; + char as_char[8]; + signed char as_signed_char[8]; + short as_short[4]; + int as_int[2]; + long long as_long_long; + float as_float[2]; + double as_double; +} __m64_union; + +/* Empty the multimedia state. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_empty(void) { + /* nothing to do on PowerPC. */ +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_empty(void) { + /* nothing to do on PowerPC. */ +} + +/* Convert I to a __m64 object. The integer is zero-extended to 64-bits. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi32_si64(int __i) { + return (__m64)(unsigned int)__i; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_from_int(int __i) { + return _mm_cvtsi32_si64(__i); +} + +/* Convert the lower 32 bits of the __m64 object into an integer. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64_si32(__m64 __i) { + return ((int)__i); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_to_int(__m64 __i) { + return _mm_cvtsi64_si32(__i); +} + +/* Convert I to a __m64 object. */ + +/* Intel intrinsic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_from_int64(long long __i) { + return (__m64)__i; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64_m64(long long __i) { + return (__m64)__i; +} + +/* Microsoft intrinsic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64x_si64(long long __i) { + return (__m64)__i; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_pi64x(long long __i) { + return (__m64)__i; +} + +/* Convert the __m64 object to a 64bit integer. */ + +/* Intel intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_to_int64(__m64 __i) { + return (long long)__i; +} + +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtm64_si64(__m64 __i) { + return (long long)__i; +} + +/* Microsoft intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64_si64x(__m64 __i) { + return (long long)__i; +} + +#ifdef _ARCH_PWR8 +/* Pack the four 16-bit values from M1 into the lower four 8-bit values of + the result, and the four 16-bit values from M2 into the upper four 8-bit + values of the result, all with signed saturation. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packs_pi16(__m64 __m1, __m64 __m2) { + __vector signed short __vm1; + __vector signed char __vresult; + + __vm1 = (__vector signed short)(__vector unsigned long long) +#ifdef __LITTLE_ENDIAN__ + {__m1, __m2}; +#else + {__m2, __m1}; +#endif + __vresult = vec_packs(__vm1, __vm1); + return (__m64)((__vector long long)__vresult)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_packsswb(__m64 __m1, __m64 __m2) { + return _mm_packs_pi16(__m1, __m2); +} + +/* Pack the two 32-bit values from M1 in to the lower two 16-bit values of + the result, and the two 32-bit values from M2 into the upper two 16-bit + values of the result, all with signed saturation. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packs_pi32(__m64 __m1, __m64 __m2) { + __vector signed int __vm1; + __vector signed short __vresult; + + __vm1 = (__vector signed int)(__vector unsigned long long) +#ifdef __LITTLE_ENDIAN__ + {__m1, __m2}; +#else + {__m2, __m1}; +#endif + __vresult = vec_packs(__vm1, __vm1); + return (__m64)((__vector long long)__vresult)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_packssdw(__m64 __m1, __m64 __m2) { + return _mm_packs_pi32(__m1, __m2); +} + +/* Pack the four 16-bit values from M1 into the lower four 8-bit values of + the result, and the four 16-bit values from M2 into the upper four 8-bit + values of the result, all with unsigned saturation. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packs_pu16(__m64 __m1, __m64 __m2) { + __vector unsigned char __r; + __vector signed short __vm1 = (__vector signed short)(__vector long long) +#ifdef __LITTLE_ENDIAN__ + {__m1, __m2}; +#else + {__m2, __m1}; +#endif + const __vector signed short __zero = {0}; + __vector __bool short __select = vec_cmplt(__vm1, __zero); + __r = + vec_packs((__vector unsigned short)__vm1, (__vector unsigned short)__vm1); + __vector __bool char __packsel = vec_pack(__select, __select); + __r = vec_sel(__r, (const __vector unsigned char)__zero, __packsel); + return (__m64)((__vector long long)__r)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_packuswb(__m64 __m1, __m64 __m2) { + return _mm_packs_pu16(__m1, __m2); +} +#endif /* end ARCH_PWR8 */ + +/* Interleave the four 8-bit values from the high half of M1 with the four + 8-bit values from the high half of M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_pi8(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector unsigned char __a, __b, __c; + + __a = (__vector unsigned char)vec_splats(__m1); + __b = (__vector unsigned char)vec_splats(__m2); + __c = vec_mergel(__a, __b); + return (__m64)((__vector long long)__c)[1]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_char[0] = __mu1.as_char[4]; + __res.as_char[1] = __mu2.as_char[4]; + __res.as_char[2] = __mu1.as_char[5]; + __res.as_char[3] = __mu2.as_char[5]; + __res.as_char[4] = __mu1.as_char[6]; + __res.as_char[5] = __mu2.as_char[6]; + __res.as_char[6] = __mu1.as_char[7]; + __res.as_char[7] = __mu2.as_char[7]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_punpckhbw(__m64 __m1, __m64 __m2) { + return _mm_unpackhi_pi8(__m1, __m2); +} + +/* Interleave the two 16-bit values from the high half of M1 with the two + 16-bit values from the high half of M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_pi16(__m64 __m1, __m64 __m2) { + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_short[0] = __mu1.as_short[2]; + __res.as_short[1] = __mu2.as_short[2]; + __res.as_short[2] = __mu1.as_short[3]; + __res.as_short[3] = __mu2.as_short[3]; + + return (__m64)__res.as_m64; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_punpckhwd(__m64 __m1, __m64 __m2) { + return _mm_unpackhi_pi16(__m1, __m2); +} +/* Interleave the 32-bit value from the high half of M1 with the 32-bit + value from the high half of M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_pi32(__m64 __m1, __m64 __m2) { + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_int[0] = __mu1.as_int[1]; + __res.as_int[1] = __mu2.as_int[1]; + + return (__m64)__res.as_m64; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_punpckhdq(__m64 __m1, __m64 __m2) { + return _mm_unpackhi_pi32(__m1, __m2); +} +/* Interleave the four 8-bit values from the low half of M1 with the four + 8-bit values from the low half of M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_pi8(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector unsigned char __a, __b, __c; + + __a = (__vector unsigned char)vec_splats(__m1); + __b = (__vector unsigned char)vec_splats(__m2); + __c = vec_mergel(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_char[0] = __mu1.as_char[0]; + __res.as_char[1] = __mu2.as_char[0]; + __res.as_char[2] = __mu1.as_char[1]; + __res.as_char[3] = __mu2.as_char[1]; + __res.as_char[4] = __mu1.as_char[2]; + __res.as_char[5] = __mu2.as_char[2]; + __res.as_char[6] = __mu1.as_char[3]; + __res.as_char[7] = __mu2.as_char[3]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_punpcklbw(__m64 __m1, __m64 __m2) { + return _mm_unpacklo_pi8(__m1, __m2); +} +/* Interleave the two 16-bit values from the low half of M1 with the two + 16-bit values from the low half of M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_pi16(__m64 __m1, __m64 __m2) { + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_short[0] = __mu1.as_short[0]; + __res.as_short[1] = __mu2.as_short[0]; + __res.as_short[2] = __mu1.as_short[1]; + __res.as_short[3] = __mu2.as_short[1]; + + return (__m64)__res.as_m64; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_punpcklwd(__m64 __m1, __m64 __m2) { + return _mm_unpacklo_pi16(__m1, __m2); +} + +/* Interleave the 32-bit value from the low half of M1 with the 32-bit + value from the low half of M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_pi32(__m64 __m1, __m64 __m2) { + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_int[0] = __mu1.as_int[0]; + __res.as_int[1] = __mu2.as_int[0]; + + return (__m64)__res.as_m64; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_punpckldq(__m64 __m1, __m64 __m2) { + return _mm_unpacklo_pi32(__m1, __m2); +} + +/* Add the 8-bit values in M1 to the 8-bit values in M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_pi8(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed char __a, __b, __c; + + __a = (__vector signed char)vec_splats(__m1); + __b = (__vector signed char)vec_splats(__m2); + __c = vec_add(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_char[0] = __mu1.as_char[0] + __mu2.as_char[0]; + __res.as_char[1] = __mu1.as_char[1] + __mu2.as_char[1]; + __res.as_char[2] = __mu1.as_char[2] + __mu2.as_char[2]; + __res.as_char[3] = __mu1.as_char[3] + __mu2.as_char[3]; + __res.as_char[4] = __mu1.as_char[4] + __mu2.as_char[4]; + __res.as_char[5] = __mu1.as_char[5] + __mu2.as_char[5]; + __res.as_char[6] = __mu1.as_char[6] + __mu2.as_char[6]; + __res.as_char[7] = __mu1.as_char[7] + __mu2.as_char[7]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddb(__m64 __m1, __m64 __m2) { + return _mm_add_pi8(__m1, __m2); +} + +/* Add the 16-bit values in M1 to the 16-bit values in M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_pi16(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = vec_add(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_short[0] = __mu1.as_short[0] + __mu2.as_short[0]; + __res.as_short[1] = __mu1.as_short[1] + __mu2.as_short[1]; + __res.as_short[2] = __mu1.as_short[2] + __mu2.as_short[2]; + __res.as_short[3] = __mu1.as_short[3] + __mu2.as_short[3]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddw(__m64 __m1, __m64 __m2) { + return _mm_add_pi16(__m1, __m2); +} + +/* Add the 32-bit values in M1 to the 32-bit values in M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_pi32(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR9 + __vector signed int __a, __b, __c; + + __a = (__vector signed int)vec_splats(__m1); + __b = (__vector signed int)vec_splats(__m2); + __c = vec_add(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_int[0] = __mu1.as_int[0] + __mu2.as_int[0]; + __res.as_int[1] = __mu1.as_int[1] + __mu2.as_int[1]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddd(__m64 __m1, __m64 __m2) { + return _mm_add_pi32(__m1, __m2); +} + +/* Subtract the 8-bit values in M2 from the 8-bit values in M1. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_pi8(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed char __a, __b, __c; + + __a = (__vector signed char)vec_splats(__m1); + __b = (__vector signed char)vec_splats(__m2); + __c = vec_sub(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_char[0] = __mu1.as_char[0] - __mu2.as_char[0]; + __res.as_char[1] = __mu1.as_char[1] - __mu2.as_char[1]; + __res.as_char[2] = __mu1.as_char[2] - __mu2.as_char[2]; + __res.as_char[3] = __mu1.as_char[3] - __mu2.as_char[3]; + __res.as_char[4] = __mu1.as_char[4] - __mu2.as_char[4]; + __res.as_char[5] = __mu1.as_char[5] - __mu2.as_char[5]; + __res.as_char[6] = __mu1.as_char[6] - __mu2.as_char[6]; + __res.as_char[7] = __mu1.as_char[7] - __mu2.as_char[7]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubb(__m64 __m1, __m64 __m2) { + return _mm_sub_pi8(__m1, __m2); +} + +/* Subtract the 16-bit values in M2 from the 16-bit values in M1. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_pi16(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = vec_sub(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_short[0] = __mu1.as_short[0] - __mu2.as_short[0]; + __res.as_short[1] = __mu1.as_short[1] - __mu2.as_short[1]; + __res.as_short[2] = __mu1.as_short[2] - __mu2.as_short[2]; + __res.as_short[3] = __mu1.as_short[3] - __mu2.as_short[3]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubw(__m64 __m1, __m64 __m2) { + return _mm_sub_pi16(__m1, __m2); +} + +/* Subtract the 32-bit values in M2 from the 32-bit values in M1. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_pi32(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR9 + __vector signed int __a, __b, __c; + + __a = (__vector signed int)vec_splats(__m1); + __b = (__vector signed int)vec_splats(__m2); + __c = vec_sub(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_int[0] = __mu1.as_int[0] - __mu2.as_int[0]; + __res.as_int[1] = __mu1.as_int[1] - __mu2.as_int[1]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubd(__m64 __m1, __m64 __m2) { + return _mm_sub_pi32(__m1, __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_si64(__m64 __m1, __m64 __m2) { + return (__m1 + __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_si64(__m64 __m1, __m64 __m2) { + return (__m1 - __m2); +} + +/* Shift the 64-bit value in M left by COUNT. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sll_si64(__m64 __m, __m64 __count) { + return (__m << __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psllq(__m64 __m, __m64 __count) { + return _mm_sll_si64(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_si64(__m64 __m, const int __count) { + return (__m << __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psllqi(__m64 __m, const int __count) { + return _mm_slli_si64(__m, __count); +} + +/* Shift the 64-bit value in M left by COUNT; shift in zeros. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srl_si64(__m64 __m, __m64 __count) { + return (__m >> __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrlq(__m64 __m, __m64 __count) { + return _mm_srl_si64(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srli_si64(__m64 __m, const int __count) { + return (__m >> __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrlqi(__m64 __m, const int __count) { + return _mm_srli_si64(__m, __count); +} + +/* Bit-wise AND the 64-bit values in M1 and M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_and_si64(__m64 __m1, __m64 __m2) { + return (__m1 & __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pand(__m64 __m1, __m64 __m2) { + return _mm_and_si64(__m1, __m2); +} + +/* Bit-wise complement the 64-bit value in M1 and bit-wise AND it with the + 64-bit value in M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_andnot_si64(__m64 __m1, __m64 __m2) { + return (~__m1 & __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pandn(__m64 __m1, __m64 __m2) { + return _mm_andnot_si64(__m1, __m2); +} + +/* Bit-wise inclusive OR the 64-bit values in M1 and M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_or_si64(__m64 __m1, __m64 __m2) { + return (__m1 | __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_por(__m64 __m1, __m64 __m2) { + return _mm_or_si64(__m1, __m2); +} + +/* Bit-wise exclusive OR the 64-bit values in M1 and M2. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_xor_si64(__m64 __m1, __m64 __m2) { + return (__m1 ^ __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pxor(__m64 __m1, __m64 __m2) { + return _mm_xor_si64(__m1, __m2); +} + +/* Creates a 64-bit zero. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setzero_si64(void) { + return (__m64)0; +} + +/* Compare eight 8-bit values. The result of the comparison is 0xFF if the + test is true and zero if false. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_pi8(__m64 __m1, __m64 __m2) { +#if defined(_ARCH_PWR6) && defined(__powerpc64__) + __m64 __res; + __asm__("cmpb %0,%1,%2;\n" : "=r"(__res) : "r"(__m1), "r"(__m2) :); + return (__res); +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_char[0] = (__mu1.as_char[0] == __mu2.as_char[0]) ? -1 : 0; + __res.as_char[1] = (__mu1.as_char[1] == __mu2.as_char[1]) ? -1 : 0; + __res.as_char[2] = (__mu1.as_char[2] == __mu2.as_char[2]) ? -1 : 0; + __res.as_char[3] = (__mu1.as_char[3] == __mu2.as_char[3]) ? -1 : 0; + __res.as_char[4] = (__mu1.as_char[4] == __mu2.as_char[4]) ? -1 : 0; + __res.as_char[5] = (__mu1.as_char[5] == __mu2.as_char[5]) ? -1 : 0; + __res.as_char[6] = (__mu1.as_char[6] == __mu2.as_char[6]) ? -1 : 0; + __res.as_char[7] = (__mu1.as_char[7] == __mu2.as_char[7]) ? -1 : 0; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pcmpeqb(__m64 __m1, __m64 __m2) { + return _mm_cmpeq_pi8(__m1, __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_pi8(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed char __a, __b, __c; + + __a = (__vector signed char)vec_splats(__m1); + __b = (__vector signed char)vec_splats(__m2); + __c = (__vector signed char)vec_cmpgt(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_char[0] = (__mu1.as_char[0] > __mu2.as_char[0]) ? -1 : 0; + __res.as_char[1] = (__mu1.as_char[1] > __mu2.as_char[1]) ? -1 : 0; + __res.as_char[2] = (__mu1.as_char[2] > __mu2.as_char[2]) ? -1 : 0; + __res.as_char[3] = (__mu1.as_char[3] > __mu2.as_char[3]) ? -1 : 0; + __res.as_char[4] = (__mu1.as_char[4] > __mu2.as_char[4]) ? -1 : 0; + __res.as_char[5] = (__mu1.as_char[5] > __mu2.as_char[5]) ? -1 : 0; + __res.as_char[6] = (__mu1.as_char[6] > __mu2.as_char[6]) ? -1 : 0; + __res.as_char[7] = (__mu1.as_char[7] > __mu2.as_char[7]) ? -1 : 0; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pcmpgtb(__m64 __m1, __m64 __m2) { + return _mm_cmpgt_pi8(__m1, __m2); +} + +/* Compare four 16-bit values. The result of the comparison is 0xFFFF if + the test is true and zero if false. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_pi16(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = (__vector signed short)vec_cmpeq(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_short[0] = (__mu1.as_short[0] == __mu2.as_short[0]) ? -1 : 0; + __res.as_short[1] = (__mu1.as_short[1] == __mu2.as_short[1]) ? -1 : 0; + __res.as_short[2] = (__mu1.as_short[2] == __mu2.as_short[2]) ? -1 : 0; + __res.as_short[3] = (__mu1.as_short[3] == __mu2.as_short[3]) ? -1 : 0; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pcmpeqw(__m64 __m1, __m64 __m2) { + return _mm_cmpeq_pi16(__m1, __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_pi16(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR8 + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = (__vector signed short)vec_cmpgt(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_short[0] = (__mu1.as_short[0] > __mu2.as_short[0]) ? -1 : 0; + __res.as_short[1] = (__mu1.as_short[1] > __mu2.as_short[1]) ? -1 : 0; + __res.as_short[2] = (__mu1.as_short[2] > __mu2.as_short[2]) ? -1 : 0; + __res.as_short[3] = (__mu1.as_short[3] > __mu2.as_short[3]) ? -1 : 0; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pcmpgtw(__m64 __m1, __m64 __m2) { + return _mm_cmpgt_pi16(__m1, __m2); +} + +/* Compare two 32-bit values. The result of the comparison is 0xFFFFFFFF if + the test is true and zero if false. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_pi32(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR9 + __vector signed int __a, __b, __c; + + __a = (__vector signed int)vec_splats(__m1); + __b = (__vector signed int)vec_splats(__m2); + __c = (__vector signed int)vec_cmpeq(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_int[0] = (__mu1.as_int[0] == __mu2.as_int[0]) ? -1 : 0; + __res.as_int[1] = (__mu1.as_int[1] == __mu2.as_int[1]) ? -1 : 0; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pcmpeqd(__m64 __m1, __m64 __m2) { + return _mm_cmpeq_pi32(__m1, __m2); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_pi32(__m64 __m1, __m64 __m2) { +#if _ARCH_PWR9 + __vector signed int __a, __b, __c; + + __a = (__vector signed int)vec_splats(__m1); + __b = (__vector signed int)vec_splats(__m2); + __c = (__vector signed int)vec_cmpgt(__a, __b); + return (__m64)((__vector long long)__c)[0]; +#else + __m64_union __mu1, __mu2, __res; + + __mu1.as_m64 = __m1; + __mu2.as_m64 = __m2; + + __res.as_int[0] = (__mu1.as_int[0] > __mu2.as_int[0]) ? -1 : 0; + __res.as_int[1] = (__mu1.as_int[1] > __mu2.as_int[1]) ? -1 : 0; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pcmpgtd(__m64 __m1, __m64 __m2) { + return _mm_cmpgt_pi32(__m1, __m2); +} + +#if _ARCH_PWR8 +/* Add the 8-bit values in M1 to the 8-bit values in M2 using signed + saturated arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_pi8(__m64 __m1, __m64 __m2) { + __vector signed char __a, __b, __c; + + __a = (__vector signed char)vec_splats(__m1); + __b = (__vector signed char)vec_splats(__m2); + __c = vec_adds(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddsb(__m64 __m1, __m64 __m2) { + return _mm_adds_pi8(__m1, __m2); +} +/* Add the 16-bit values in M1 to the 16-bit values in M2 using signed + saturated arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_pi16(__m64 __m1, __m64 __m2) { + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = vec_adds(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddsw(__m64 __m1, __m64 __m2) { + return _mm_adds_pi16(__m1, __m2); +} +/* Add the 8-bit values in M1 to the 8-bit values in M2 using unsigned + saturated arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_pu8(__m64 __m1, __m64 __m2) { + __vector unsigned char __a, __b, __c; + + __a = (__vector unsigned char)vec_splats(__m1); + __b = (__vector unsigned char)vec_splats(__m2); + __c = vec_adds(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddusb(__m64 __m1, __m64 __m2) { + return _mm_adds_pu8(__m1, __m2); +} + +/* Add the 16-bit values in M1 to the 16-bit values in M2 using unsigned + saturated arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_adds_pu16(__m64 __m1, __m64 __m2) { + __vector unsigned short __a, __b, __c; + + __a = (__vector unsigned short)vec_splats(__m1); + __b = (__vector unsigned short)vec_splats(__m2); + __c = vec_adds(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_paddusw(__m64 __m1, __m64 __m2) { + return _mm_adds_pu16(__m1, __m2); +} + +/* Subtract the 8-bit values in M2 from the 8-bit values in M1 using signed + saturating arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_pi8(__m64 __m1, __m64 __m2) { + __vector signed char __a, __b, __c; + + __a = (__vector signed char)vec_splats(__m1); + __b = (__vector signed char)vec_splats(__m2); + __c = vec_subs(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubsb(__m64 __m1, __m64 __m2) { + return _mm_subs_pi8(__m1, __m2); +} + +/* Subtract the 16-bit values in M2 from the 16-bit values in M1 using + signed saturating arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_pi16(__m64 __m1, __m64 __m2) { + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = vec_subs(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubsw(__m64 __m1, __m64 __m2) { + return _mm_subs_pi16(__m1, __m2); +} + +/* Subtract the 8-bit values in M2 from the 8-bit values in M1 using + unsigned saturating arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_pu8(__m64 __m1, __m64 __m2) { + __vector unsigned char __a, __b, __c; + + __a = (__vector unsigned char)vec_splats(__m1); + __b = (__vector unsigned char)vec_splats(__m2); + __c = vec_subs(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubusb(__m64 __m1, __m64 __m2) { + return _mm_subs_pu8(__m1, __m2); +} + +/* Subtract the 16-bit values in M2 from the 16-bit values in M1 using + unsigned saturating arithmetic. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_subs_pu16(__m64 __m1, __m64 __m2) { + __vector unsigned short __a, __b, __c; + + __a = (__vector unsigned short)vec_splats(__m1); + __b = (__vector unsigned short)vec_splats(__m2); + __c = vec_subs(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psubusw(__m64 __m1, __m64 __m2) { + return _mm_subs_pu16(__m1, __m2); +} + +/* Multiply four 16-bit values in M1 by four 16-bit values in M2 producing + four 32-bit intermediate results, which are then summed by pairs to + produce two 32-bit results. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_madd_pi16(__m64 __m1, __m64 __m2) { + __vector signed short __a, __b; + __vector signed int __c; + __vector signed int __zero = {0, 0, 0, 0}; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = vec_vmsumshm(__a, __b, __zero); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmaddwd(__m64 __m1, __m64 __m2) { + return _mm_madd_pi16(__m1, __m2); +} +/* Multiply four signed 16-bit values in M1 by four signed 16-bit values in + M2 and produce the high 16 bits of the 32-bit results. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mulhi_pi16(__m64 __m1, __m64 __m2) { + __vector signed short __a, __b; + __vector signed short __c; + __vector signed int __w0, __w1; + __vector unsigned char __xform1 = { +#ifdef __LITTLE_ENDIAN__ + 0x02, 0x03, 0x12, 0x13, 0x06, 0x07, 0x16, 0x17, 0x0A, + 0x0B, 0x1A, 0x1B, 0x0E, 0x0F, 0x1E, 0x1F +#else + 0x00, 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15, 0x00, + 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15 +#endif + }; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + + __w0 = vec_vmulesh(__a, __b); + __w1 = vec_vmulosh(__a, __b); + __c = (__vector signed short)vec_perm(__w0, __w1, __xform1); + + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmulhw(__m64 __m1, __m64 __m2) { + return _mm_mulhi_pi16(__m1, __m2); +} + +/* Multiply four 16-bit values in M1 by four 16-bit values in M2 and produce + the low 16 bits of the results. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mullo_pi16(__m64 __m1, __m64 __m2) { + __vector signed short __a, __b, __c; + + __a = (__vector signed short)vec_splats(__m1); + __b = (__vector signed short)vec_splats(__m2); + __c = __a * __b; + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmullw(__m64 __m1, __m64 __m2) { + return _mm_mullo_pi16(__m1, __m2); +} + +/* Shift four 16-bit values in M left by COUNT. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sll_pi16(__m64 __m, __m64 __count) { + __vector signed short __r; + __vector unsigned short __c; + + if (__count <= 15) { + __r = (__vector signed short)vec_splats(__m); + __c = (__vector unsigned short)vec_splats((unsigned short)__count); + __r = vec_sl(__r, (__vector unsigned short)__c); + return (__m64)((__vector long long)__r)[0]; + } else + return (0); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psllw(__m64 __m, __m64 __count) { + return _mm_sll_pi16(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_pi16(__m64 __m, int __count) { + /* Promote int to long then invoke mm_sll_pi16. */ + return _mm_sll_pi16(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psllwi(__m64 __m, int __count) { + return _mm_slli_pi16(__m, __count); +} + +/* Shift two 32-bit values in M left by COUNT. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sll_pi32(__m64 __m, __m64 __count) { + __m64_union __res; + + __res.as_m64 = __m; + + __res.as_int[0] = __res.as_int[0] << __count; + __res.as_int[1] = __res.as_int[1] << __count; + return (__res.as_m64); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pslld(__m64 __m, __m64 __count) { + return _mm_sll_pi32(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_slli_pi32(__m64 __m, int __count) { + /* Promote int to long then invoke mm_sll_pi32. */ + return _mm_sll_pi32(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pslldi(__m64 __m, int __count) { + return _mm_slli_pi32(__m, __count); +} + +/* Shift four 16-bit values in M right by COUNT; shift in the sign bit. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sra_pi16(__m64 __m, __m64 __count) { + __vector signed short __r; + __vector unsigned short __c; + + if (__count <= 15) { + __r = (__vector signed short)vec_splats(__m); + __c = (__vector unsigned short)vec_splats((unsigned short)__count); + __r = vec_sra(__r, (__vector unsigned short)__c); + return (__m64)((__vector long long)__r)[0]; + } else + return (0); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psraw(__m64 __m, __m64 __count) { + return _mm_sra_pi16(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srai_pi16(__m64 __m, int __count) { + /* Promote int to long then invoke mm_sra_pi32. */ + return _mm_sra_pi16(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrawi(__m64 __m, int __count) { + return _mm_srai_pi16(__m, __count); +} + +/* Shift two 32-bit values in M right by COUNT; shift in the sign bit. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sra_pi32(__m64 __m, __m64 __count) { + __m64_union __res; + + __res.as_m64 = __m; + + __res.as_int[0] = __res.as_int[0] >> __count; + __res.as_int[1] = __res.as_int[1] >> __count; + return (__res.as_m64); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrad(__m64 __m, __m64 __count) { + return _mm_sra_pi32(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srai_pi32(__m64 __m, int __count) { + /* Promote int to long then invoke mm_sra_pi32. */ + return _mm_sra_pi32(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psradi(__m64 __m, int __count) { + return _mm_srai_pi32(__m, __count); +} + +/* Shift four 16-bit values in M right by COUNT; shift in zeros. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srl_pi16(__m64 __m, __m64 __count) { + __vector unsigned short __r; + __vector unsigned short __c; + + if (__count <= 15) { + __r = (__vector unsigned short)vec_splats(__m); + __c = (__vector unsigned short)vec_splats((unsigned short)__count); + __r = vec_sr(__r, (__vector unsigned short)__c); + return (__m64)((__vector long long)__r)[0]; + } else + return (0); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrlw(__m64 __m, __m64 __count) { + return _mm_srl_pi16(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srli_pi16(__m64 __m, int __count) { + /* Promote int to long then invoke mm_sra_pi32. */ + return _mm_srl_pi16(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrlwi(__m64 __m, int __count) { + return _mm_srli_pi16(__m, __count); +} + +/* Shift two 32-bit values in M right by COUNT; shift in zeros. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srl_pi32(__m64 __m, __m64 __count) { + __m64_union __res; + + __res.as_m64 = __m; + + __res.as_int[0] = (unsigned int)__res.as_int[0] >> __count; + __res.as_int[1] = (unsigned int)__res.as_int[1] >> __count; + return (__res.as_m64); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrld(__m64 __m, __m64 __count) { + return _mm_srl_pi32(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_srli_pi32(__m64 __m, int __count) { + /* Promote int to long then invoke mm_srl_pi32. */ + return _mm_srl_pi32(__m, __count); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psrldi(__m64 __m, int __count) { + return _mm_srli_pi32(__m, __count); +} +#endif /* _ARCH_PWR8 */ + +/* Creates a vector of two 32-bit values; I0 is least significant. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_pi32(int __i1, int __i0) { + __m64_union __res; + + __res.as_int[0] = __i0; + __res.as_int[1] = __i1; + return (__res.as_m64); +} + +/* Creates a vector of four 16-bit values; W0 is least significant. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_pi16(short __w3, short __w2, short __w1, short __w0) { + __m64_union __res; + + __res.as_short[0] = __w0; + __res.as_short[1] = __w1; + __res.as_short[2] = __w2; + __res.as_short[3] = __w3; + return (__res.as_m64); +} + +/* Creates a vector of eight 8-bit values; B0 is least significant. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_pi8(char __b7, char __b6, char __b5, char __b4, char __b3, + char __b2, char __b1, char __b0) { + __m64_union __res; + + __res.as_char[0] = __b0; + __res.as_char[1] = __b1; + __res.as_char[2] = __b2; + __res.as_char[3] = __b3; + __res.as_char[4] = __b4; + __res.as_char[5] = __b5; + __res.as_char[6] = __b6; + __res.as_char[7] = __b7; + return (__res.as_m64); +} + +/* Similar, but with the arguments in reverse order. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_pi32(int __i0, int __i1) { + __m64_union __res; + + __res.as_int[0] = __i0; + __res.as_int[1] = __i1; + return (__res.as_m64); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_pi16(short __w0, short __w1, short __w2, short __w3) { + return _mm_set_pi16(__w3, __w2, __w1, __w0); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_pi8(char __b0, char __b1, char __b2, char __b3, char __b4, + char __b5, char __b6, char __b7) { + return _mm_set_pi8(__b7, __b6, __b5, __b4, __b3, __b2, __b1, __b0); +} + +/* Creates a vector of two 32-bit values, both elements containing I. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_pi32(int __i) { + __m64_union __res; + + __res.as_int[0] = __i; + __res.as_int[1] = __i; + return (__res.as_m64); +} + +/* Creates a vector of four 16-bit values, all elements containing W. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_pi16(short __w) { +#if _ARCH_PWR9 + __vector signed short w; + + w = (__vector signed short)vec_splats(__w); + return (__m64)((__vector long long)w)[0]; +#else + __m64_union __res; + + __res.as_short[0] = __w; + __res.as_short[1] = __w; + __res.as_short[2] = __w; + __res.as_short[3] = __w; + return (__res.as_m64); +#endif +} + +/* Creates a vector of eight 8-bit values, all elements containing B. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_pi8(signed char __b) { +#if _ARCH_PWR8 + __vector signed char __res; + + __res = (__vector signed char)vec_splats(__b); + return (__m64)((__vector long long)__res)[0]; +#else + __m64_union __res; + + __res.as_char[0] = __b; + __res.as_char[1] = __b; + __res.as_char[2] = __b; + __res.as_char[3] = __b; + __res.as_char[4] = __b; + __res.as_char[5] = __b; + __res.as_char[6] = __b; + __res.as_char[7] = __b; + return (__res.as_m64); +#endif +} + +#else +#include_next +#endif /* defined(__powerpc64__) && \ + * (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */ + +#endif /* _MMINTRIN_H_INCLUDED */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/nmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/nmmintrin.h new file mode 100755 index 0000000..789bba6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/nmmintrin.h @@ -0,0 +1,26 @@ +/*===---- nmmintrin.h - Implementation of SSE4 intrinsics on PowerPC -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header is distributed to simplify porting x86_64 code that + makes explicit use of Intel intrinsics to powerpc64le. + It is the user's responsibility to determine if the results are + acceptable and make additional changes as necessary. + Note that much code that uses Intel intrinsics can be rewritten in + standard C or GNU C extensions, which are more portable and better + optimized across multiple targets. */ +#endif + +#ifndef NMMINTRIN_H_ +#define NMMINTRIN_H_ + +/* We just include SSE4.1 header file. */ +#include + +#endif /* NMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/pmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/pmmintrin.h new file mode 100755 index 0000000..db12819 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/pmmintrin.h @@ -0,0 +1,145 @@ +/*===---- pmmintrin.h - Implementation of SSE3 intrinsics on PowerPC -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Implemented from the specification included in the Intel C++ Compiler + User Guide and Reference, version 9.0. */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header is distributed to simplify porting x86_64 code that + makes explicit use of Intel intrinsics to powerpc64le. + It is the user's responsibility to determine if the results are + acceptable and make additional changes as necessary. + Note that much code that uses Intel intrinsics can be rewritten in + standard C or GNU C extensions, which are more portable and better + optimized across multiple targets. + + In the specific case of X86 SSE3 intrinsics, the PowerPC VMX/VSX ISA + is a good match for most SIMD operations. However the Horizontal + add/sub requires the data pairs be permuted into a separate + registers with vertical even/odd alignment for the operation. + And the addsub operation requires the sign of only the even numbered + elements be flipped (xored with -0.0). + For larger blocks of code using these intrinsic implementations, + the compiler be should be able to schedule instructions to avoid + additional latency. + + In the specific case of the monitor and mwait instructions there are + no direct equivalent in the PowerISA at this time. So those + intrinsics are not implemented. */ +#error \ + "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this warning." +#endif + +#ifndef PMMINTRIN_H_ +#define PMMINTRIN_H_ + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +/* We need definitions from the SSE2 and SSE header files*/ +#include + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_addsub_ps(__m128 __X, __m128 __Y) { + const __v4sf __even_n0 = {-0.0, 0.0, -0.0, 0.0}; + __v4sf __even_neg_Y = vec_xor(__Y, __even_n0); + return (__m128)vec_add(__X, __even_neg_Y); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_addsub_pd(__m128d __X, __m128d __Y) { + const __v2df __even_n0 = {-0.0, 0.0}; + __v2df __even_neg_Y = vec_xor(__Y, __even_n0); + return (__m128d)vec_add(__X, __even_neg_Y); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadd_ps(__m128 __X, __m128 __Y) { + __vector unsigned char __xform2 = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, + 0x0A, 0x0B, 0x10, 0x11, 0x12, 0x13, + 0x18, 0x19, 0x1A, 0x1B}; + __vector unsigned char __xform1 = {0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, + 0x0E, 0x0F, 0x14, 0x15, 0x16, 0x17, + 0x1C, 0x1D, 0x1E, 0x1F}; + return (__m128)vec_add(vec_perm((__v4sf)__X, (__v4sf)__Y, __xform2), + vec_perm((__v4sf)__X, (__v4sf)__Y, __xform1)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsub_ps(__m128 __X, __m128 __Y) { + __vector unsigned char __xform2 = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, + 0x0A, 0x0B, 0x10, 0x11, 0x12, 0x13, + 0x18, 0x19, 0x1A, 0x1B}; + __vector unsigned char __xform1 = {0x04, 0x05, 0x06, 0x07, 0x0C, 0x0D, + 0x0E, 0x0F, 0x14, 0x15, 0x16, 0x17, + 0x1C, 0x1D, 0x1E, 0x1F}; + return (__m128)vec_sub(vec_perm((__v4sf)__X, (__v4sf)__Y, __xform2), + vec_perm((__v4sf)__X, (__v4sf)__Y, __xform1)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadd_pd(__m128d __X, __m128d __Y) { + return (__m128d)vec_add(vec_mergeh((__v2df)__X, (__v2df)__Y), + vec_mergel((__v2df)__X, (__v2df)__Y)); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsub_pd(__m128d __X, __m128d __Y) { + return (__m128d)vec_sub(vec_mergeh((__v2df)__X, (__v2df)__Y), + vec_mergel((__v2df)__X, (__v2df)__Y)); +} + +#ifdef _ARCH_PWR8 +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movehdup_ps(__m128 __X) { + return (__m128)vec_mergeo((__v4su)__X, (__v4su)__X); +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_moveldup_ps(__m128 __X) { + return (__m128)vec_mergee((__v4su)__X, (__v4su)__X); +} +#endif + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loaddup_pd(double const *__P) { + return (__m128d)vec_splats(*__P); +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movedup_pd(__m128d __X) { + return _mm_shuffle_pd(__X, __X, _MM_SHUFFLE2(0, 0)); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_lddqu_si128(__m128i const *__P) { + return (__m128i)(vec_vsx_ld(0, (signed int const *)__P)); +} + +/* POWER8 / POWER9 have no equivalent for _mm_monitor nor _mm_wait. */ + +#else +#include_next +#endif /* defined(__powerpc64__) && \ + * (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */ + +#endif /* PMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/smmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/smmintrin.h new file mode 100755 index 0000000..19cdecb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/smmintrin.h @@ -0,0 +1,683 @@ +/*===---- smmintrin.h - Implementation of SSE4 intrinsics on PowerPC -------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Implemented from the specification included in the Intel C++ Compiler + User Guide and Reference, version 9.0. + + NOTE: This is NOT a complete implementation of the SSE4 intrinsics! */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header is distributed to simplify porting x86_64 code that + makes explicit use of Intel intrinsics to powerpc64/powerpc64le. + + It is the user's responsibility to determine if the results are + acceptable and make additional changes as necessary. + + Note that much code that uses Intel intrinsics can be rewritten in + standard C or GNU C extensions, which are more portable and better + optimized across multiple targets. */ +#error \ + "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this error." +#endif + +#ifndef SMMINTRIN_H_ +#define SMMINTRIN_H_ + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +#include +#include + +/* Rounding mode macros. */ +#define _MM_FROUND_TO_NEAREST_INT 0x00 +#define _MM_FROUND_TO_ZERO 0x01 +#define _MM_FROUND_TO_POS_INF 0x02 +#define _MM_FROUND_TO_NEG_INF 0x03 +#define _MM_FROUND_CUR_DIRECTION 0x04 + +#define _MM_FROUND_NINT (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_RAISE_EXC) +#define _MM_FROUND_FLOOR (_MM_FROUND_TO_NEG_INF | _MM_FROUND_RAISE_EXC) +#define _MM_FROUND_CEIL (_MM_FROUND_TO_POS_INF | _MM_FROUND_RAISE_EXC) +#define _MM_FROUND_TRUNC (_MM_FROUND_TO_ZERO | _MM_FROUND_RAISE_EXC) +#define _MM_FROUND_RINT (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_RAISE_EXC) +#define _MM_FROUND_NEARBYINT (_MM_FROUND_CUR_DIRECTION | _MM_FROUND_NO_EXC) + +#define _MM_FROUND_RAISE_EXC 0x00 +#define _MM_FROUND_NO_EXC 0x08 + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_round_pd(__m128d __A, int __rounding) { + __v2df __r; + union { + double __fr; + long long __fpscr; + } __enables_save, __fpscr_save; + + if (__rounding & _MM_FROUND_NO_EXC) { + /* Save enabled exceptions, disable all exceptions, + and preserve the rounding mode. */ +#ifdef _ARCH_PWR9 + __asm__("mffsce %0" : "=f"(__fpscr_save.__fr)); + __enables_save.__fpscr = __fpscr_save.__fpscr & 0xf8; +#else + __fpscr_save.__fr = __builtin_ppc_mffs(); + __enables_save.__fpscr = __fpscr_save.__fpscr & 0xf8; + __fpscr_save.__fpscr &= ~0xf8; + __builtin_ppc_mtfsf(0b00000011, __fpscr_save.__fr); +#endif + /* Insert an artificial "read/write" reference to the variable + read below, to ensure the compiler does not schedule + a read/use of the variable before the FPSCR is modified, above. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : "+wa"(__A)); + } + + switch (__rounding) { + case _MM_FROUND_TO_NEAREST_INT: +#ifdef _ARCH_PWR9 + __fpscr_save.__fr = __builtin_ppc_mffsl(); +#else + __fpscr_save.__fr = __builtin_ppc_mffs(); + __fpscr_save.__fpscr &= 0x70007f0ffL; +#endif + __attribute__((fallthrough)); + case _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC: + __builtin_ppc_set_fpscr_rn(0b00); + /* Insert an artificial "read/write" reference to the variable + read below, to ensure the compiler does not schedule + a read/use of the variable before the FPSCR is modified, above. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : "+wa"(__A)); + + __r = vec_rint((__v2df)__A); + + /* Insert an artificial "read" reference to the variable written + above, to ensure the compiler does not schedule the computation + of the value after the manipulation of the FPSCR, below. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : : "wa"(__r)); + __builtin_ppc_set_fpscr_rn(__fpscr_save.__fpscr); + break; + case _MM_FROUND_TO_NEG_INF: + case _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC: + __r = vec_floor((__v2df)__A); + break; + case _MM_FROUND_TO_POS_INF: + case _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC: + __r = vec_ceil((__v2df)__A); + break; + case _MM_FROUND_TO_ZERO: + case _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC: + __r = vec_trunc((__v2df)__A); + break; + case _MM_FROUND_CUR_DIRECTION: + __r = vec_rint((__v2df)__A); + break; + } + if (__rounding & _MM_FROUND_NO_EXC) { + /* Insert an artificial "read" reference to the variable written + above, to ensure the compiler does not schedule the computation + of the value after the manipulation of the FPSCR, below. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : : "wa"(__r)); + /* Restore enabled exceptions. */ +#ifdef _ARCH_PWR9 + __fpscr_save.__fr = __builtin_ppc_mffsl(); +#else + __fpscr_save.__fr = __builtin_ppc_mffs(); + __fpscr_save.__fpscr &= 0x70007f0ffL; +#endif + __fpscr_save.__fpscr |= __enables_save.__fpscr; + __builtin_ppc_mtfsf(0b00000011, __fpscr_save.__fr); + } + return (__m128d)__r; +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_round_sd(__m128d __A, __m128d __B, int __rounding) { + __B = _mm_round_pd(__B, __rounding); + __v2df __r = {((__v2df)__B)[0], ((__v2df)__A)[1]}; + return (__m128d)__r; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_round_ps(__m128 __A, int __rounding) { + __v4sf __r; + union { + double __fr; + long long __fpscr; + } __enables_save, __fpscr_save; + + if (__rounding & _MM_FROUND_NO_EXC) { + /* Save enabled exceptions, disable all exceptions, + and preserve the rounding mode. */ +#ifdef _ARCH_PWR9 + __asm__("mffsce %0" : "=f"(__fpscr_save.__fr)); + __enables_save.__fpscr = __fpscr_save.__fpscr & 0xf8; +#else + __fpscr_save.__fr = __builtin_ppc_mffs(); + __enables_save.__fpscr = __fpscr_save.__fpscr & 0xf8; + __fpscr_save.__fpscr &= ~0xf8; + __builtin_ppc_mtfsf(0b00000011, __fpscr_save.__fr); +#endif + /* Insert an artificial "read/write" reference to the variable + read below, to ensure the compiler does not schedule + a read/use of the variable before the FPSCR is modified, above. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : "+wa"(__A)); + } + + switch (__rounding) { + case _MM_FROUND_TO_NEAREST_INT: +#ifdef _ARCH_PWR9 + __fpscr_save.__fr = __builtin_ppc_mffsl(); +#else + __fpscr_save.__fr = __builtin_ppc_mffs(); + __fpscr_save.__fpscr &= 0x70007f0ffL; +#endif + __attribute__((fallthrough)); + case _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC: + __builtin_ppc_set_fpscr_rn(0b00); + /* Insert an artificial "read/write" reference to the variable + read below, to ensure the compiler does not schedule + a read/use of the variable before the FPSCR is modified, above. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : "+wa"(__A)); + + __r = vec_rint((__v4sf)__A); + + /* Insert an artificial "read" reference to the variable written + above, to ensure the compiler does not schedule the computation + of the value after the manipulation of the FPSCR, below. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : : "wa"(__r)); + __builtin_ppc_set_fpscr_rn(__fpscr_save.__fpscr); + break; + case _MM_FROUND_TO_NEG_INF: + case _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC: + __r = vec_floor((__v4sf)__A); + break; + case _MM_FROUND_TO_POS_INF: + case _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC: + __r = vec_ceil((__v4sf)__A); + break; + case _MM_FROUND_TO_ZERO: + case _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC: + __r = vec_trunc((__v4sf)__A); + break; + case _MM_FROUND_CUR_DIRECTION: + __r = vec_rint((__v4sf)__A); + break; + } + if (__rounding & _MM_FROUND_NO_EXC) { + /* Insert an artificial "read" reference to the variable written + above, to ensure the compiler does not schedule the computation + of the value after the manipulation of the FPSCR, below. + This can be removed if and when GCC PR102783 is fixed. + */ + __asm__("" : : "wa"(__r)); + /* Restore enabled exceptions. */ +#ifdef _ARCH_PWR9 + __fpscr_save.__fr = __builtin_ppc_mffsl(); +#else + __fpscr_save.__fr = __builtin_ppc_mffs(); + __fpscr_save.__fpscr &= 0x70007f0ffL; +#endif + __fpscr_save.__fpscr |= __enables_save.__fpscr; + __builtin_ppc_mtfsf(0b00000011, __fpscr_save.__fr); + } + return (__m128)__r; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_round_ss(__m128 __A, __m128 __B, int __rounding) { + __B = _mm_round_ps(__B, __rounding); + __v4sf __r = (__v4sf)__A; + __r[0] = ((__v4sf)__B)[0]; + return (__m128)__r; +} + +#define _mm_ceil_pd(V) _mm_round_pd((V), _MM_FROUND_CEIL) +#define _mm_ceil_sd(D, V) _mm_round_sd((D), (V), _MM_FROUND_CEIL) + +#define _mm_floor_pd(V) _mm_round_pd((V), _MM_FROUND_FLOOR) +#define _mm_floor_sd(D, V) _mm_round_sd((D), (V), _MM_FROUND_FLOOR) + +#define _mm_ceil_ps(V) _mm_round_ps((V), _MM_FROUND_CEIL) +#define _mm_ceil_ss(D, V) _mm_round_ss((D), (V), _MM_FROUND_CEIL) + +#define _mm_floor_ps(V) _mm_round_ps((V), _MM_FROUND_FLOOR) +#define _mm_floor_ss(D, V) _mm_round_ss((D), (V), _MM_FROUND_FLOOR) + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_insert_epi8(__m128i const __A, int const __D, int const __N) { + __v16qi __result = (__v16qi)__A; + + __result[__N & 0xf] = __D; + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_insert_epi32(__m128i const __A, int const __D, int const __N) { + __v4si __result = (__v4si)__A; + + __result[__N & 3] = __D; + + return (__m128i)__result; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_insert_epi64(__m128i const __A, long long const __D, int const __N) { + __v2di __result = (__v2di)__A; + + __result[__N & 1] = __D; + + return (__m128i)__result; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_extract_epi8(__m128i __X, const int __N) { + return (unsigned char)((__v16qi)__X)[__N & 15]; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_extract_epi32(__m128i __X, const int __N) { + return ((__v4si)__X)[__N & 3]; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_extract_epi64(__m128i __X, const int __N) { + return ((__v2di)__X)[__N & 1]; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_extract_ps(__m128 __X, const int __N) { + return ((__v4si)__X)[__N & 3]; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_blend_epi16(__m128i __A, __m128i __B, const int __imm8) { + __v16qu __charmask = vec_splats((unsigned char)__imm8); + __charmask = vec_gb(__charmask); + __v8hu __shortmask = (__v8hu)vec_unpackh((__v16qi)__charmask); +#ifdef __BIG_ENDIAN__ + __shortmask = vec_reve(__shortmask); +#endif + return (__m128i)vec_sel((__v8hu)__A, (__v8hu)__B, __shortmask); +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_blendv_epi8(__m128i __A, __m128i __B, __m128i __mask) { +#ifdef _ARCH_PWR10 + return (__m128i)vec_blendv((__v16qi)__A, (__v16qi)__B, (__v16qu)__mask); +#else + const __v16qu __seven = vec_splats((unsigned char)0x07); + __v16qu __lmask = vec_sra((__v16qu)__mask, __seven); + return (__m128i)vec_sel((__v16qi)__A, (__v16qi)__B, __lmask); +#endif +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_blend_ps(__m128 __A, __m128 __B, const int __imm8) { + __v16qu __pcv[] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {16, 17, 18, 19, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, 12, 13, 14, 15}, + {16, 17, 18, 19, 20, 21, 22, 23, 8, 9, 10, 11, 12, 13, 14, 15}, + {0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 12, 13, 14, 15}, + {16, 17, 18, 19, 4, 5, 6, 7, 24, 25, 26, 27, 12, 13, 14, 15}, + {0, 1, 2, 3, 20, 21, 22, 23, 24, 25, 26, 27, 12, 13, 14, 15}, + {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 12, 13, 14, 15}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 29, 30, 31}, + {16, 17, 18, 19, 4, 5, 6, 7, 8, 9, 10, 11, 28, 29, 30, 31}, + {0, 1, 2, 3, 20, 21, 22, 23, 8, 9, 10, 11, 28, 29, 30, 31}, + {16, 17, 18, 19, 20, 21, 22, 23, 8, 9, 10, 11, 28, 29, 30, 31}, + {0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31}, + {16, 17, 18, 19, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31}, + {0, 1, 2, 3, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, + {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, + }; + __v16qu __r = vec_perm((__v16qu)__A, (__v16qu)__B, __pcv[__imm8]); + return (__m128)__r; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_blendv_ps(__m128 __A, __m128 __B, __m128 __mask) { +#ifdef _ARCH_PWR10 + return (__m128)vec_blendv((__v4sf)__A, (__v4sf)__B, (__v4su)__mask); +#else + const __v4si __zero = {0}; + const __vector __bool int __boolmask = vec_cmplt((__v4si)__mask, __zero); + return (__m128)vec_sel((__v4su)__A, (__v4su)__B, (__v4su)__boolmask); +#endif +} + +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_blend_pd(__m128d __A, __m128d __B, const int __imm8) { + __v16qu __pcv[] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {16, 17, 18, 19, 20, 21, 22, 23, 8, 9, 10, 11, 12, 13, 14, 15}, + {0, 1, 2, 3, 4, 5, 6, 7, 24, 25, 26, 27, 28, 29, 30, 31}, + {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}}; + __v16qu __r = vec_perm((__v16qu)__A, (__v16qu)__B, __pcv[__imm8]); + return (__m128d)__r; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128d + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_blendv_pd(__m128d __A, __m128d __B, __m128d __mask) { +#ifdef _ARCH_PWR10 + return (__m128d)vec_blendv((__v2df)__A, (__v2df)__B, (__v2du)__mask); +#else + const __v2di __zero = {0}; + const __vector __bool long long __boolmask = + vec_cmplt((__v2di)__mask, __zero); + return (__m128d)vec_sel((__v2du)__A, (__v2du)__B, (__v2du)__boolmask); +#endif +} +#endif + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_testz_si128(__m128i __A, __m128i __B) { + /* Note: This implementation does NOT set "zero" or "carry" flags. */ + const __v16qu __zero = {0}; + return vec_all_eq(vec_and((__v16qu)__A, (__v16qu)__B), __zero); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_testc_si128(__m128i __A, __m128i __B) { + /* Note: This implementation does NOT set "zero" or "carry" flags. */ + const __v16qu __zero = {0}; + const __v16qu __notA = vec_nor((__v16qu)__A, (__v16qu)__A); + return vec_all_eq(vec_and((__v16qu)__notA, (__v16qu)__B), __zero); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_testnzc_si128(__m128i __A, __m128i __B) { + /* Note: This implementation does NOT set "zero" or "carry" flags. */ + return _mm_testz_si128(__A, __B) == 0 && _mm_testc_si128(__A, __B) == 0; +} + +#define _mm_test_all_zeros(M, V) _mm_testz_si128((M), (V)) + +#define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_cmpeq_epi32((V), (V))) + +#define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V)) + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_epi64(__m128i __X, __m128i __Y) { + return (__m128i)vec_cmpeq((__v2di)__X, (__v2di)__Y); +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_epi8(__m128i __X, __m128i __Y) { + return (__m128i)vec_min((__v16qi)__X, (__v16qi)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_epu16(__m128i __X, __m128i __Y) { + return (__m128i)vec_min((__v8hu)__X, (__v8hu)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_epi32(__m128i __X, __m128i __Y) { + return (__m128i)vec_min((__v4si)__X, (__v4si)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_epu32(__m128i __X, __m128i __Y) { + return (__m128i)vec_min((__v4su)__X, (__v4su)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_epi8(__m128i __X, __m128i __Y) { + return (__m128i)vec_max((__v16qi)__X, (__v16qi)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_epu16(__m128i __X, __m128i __Y) { + return (__m128i)vec_max((__v8hu)__X, (__v8hu)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_epi32(__m128i __X, __m128i __Y) { + return (__m128i)vec_max((__v4si)__X, (__v4si)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_epu32(__m128i __X, __m128i __Y) { + return (__m128i)vec_max((__v4su)__X, (__v4su)__Y); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mullo_epi32(__m128i __X, __m128i __Y) { + return (__m128i)vec_mul((__v4su)__X, (__v4su)__Y); +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_epi32(__m128i __X, __m128i __Y) { + return (__m128i)vec_mule((__v4si)__X, (__v4si)__Y); +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi8_epi16(__m128i __A) { + return (__m128i)vec_unpackh((__v16qi)__A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi8_epi32(__m128i __A) { + __A = (__m128i)vec_unpackh((__v16qi)__A); + return (__m128i)vec_unpackh((__v8hi)__A); +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi8_epi64(__m128i __A) { + __A = (__m128i)vec_unpackh((__v16qi)__A); + __A = (__m128i)vec_unpackh((__v8hi)__A); + return (__m128i)vec_unpackh((__v4si)__A); +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi16_epi32(__m128i __A) { + return (__m128i)vec_unpackh((__v8hi)__A); +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi16_epi64(__m128i __A) { + __A = (__m128i)vec_unpackh((__v8hi)__A); + return (__m128i)vec_unpackh((__v4si)__A); +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepi32_epi64(__m128i __A) { + return (__m128i)vec_unpackh((__v4si)__A); +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepu8_epi16(__m128i __A) { + const __v16qu __zero = {0}; +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_mergeh((__v16qu)__A, __zero); +#else /* __BIG_ENDIAN__. */ + __A = (__m128i)vec_mergeh(__zero, (__v16qu)__A); +#endif /* __BIG_ENDIAN__. */ + return __A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepu8_epi32(__m128i __A) { + const __v16qu __zero = {0}; +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_mergeh((__v16qu)__A, __zero); + __A = (__m128i)vec_mergeh((__v8hu)__A, (__v8hu)__zero); +#else /* __BIG_ENDIAN__. */ + __A = (__m128i)vec_mergeh(__zero, (__v16qu)__A); + __A = (__m128i)vec_mergeh((__v8hu)__zero, (__v8hu)__A); +#endif /* __BIG_ENDIAN__. */ + return __A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepu8_epi64(__m128i __A) { + const __v16qu __zero = {0}; +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_mergeh((__v16qu)__A, __zero); + __A = (__m128i)vec_mergeh((__v8hu)__A, (__v8hu)__zero); + __A = (__m128i)vec_mergeh((__v4su)__A, (__v4su)__zero); +#else /* __BIG_ENDIAN__. */ + __A = (__m128i)vec_mergeh(__zero, (__v16qu)__A); + __A = (__m128i)vec_mergeh((__v8hu)__zero, (__v8hu)__A); + __A = (__m128i)vec_mergeh((__v4su)__zero, (__v4su)__A); +#endif /* __BIG_ENDIAN__. */ + return __A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepu16_epi32(__m128i __A) { + const __v8hu __zero = {0}; +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_mergeh((__v8hu)__A, __zero); +#else /* __BIG_ENDIAN__. */ + __A = (__m128i)vec_mergeh(__zero, (__v8hu)__A); +#endif /* __BIG_ENDIAN__. */ + return __A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepu16_epi64(__m128i __A) { + const __v8hu __zero = {0}; +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_mergeh((__v8hu)__A, __zero); + __A = (__m128i)vec_mergeh((__v4su)__A, (__v4su)__zero); +#else /* __BIG_ENDIAN__. */ + __A = (__m128i)vec_mergeh(__zero, (__v8hu)__A); + __A = (__m128i)vec_mergeh((__v4su)__zero, (__v4su)__A); +#endif /* __BIG_ENDIAN__. */ + return __A; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtepu32_epi64(__m128i __A) { + const __v4su __zero = {0}; +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_mergeh((__v4su)__A, __zero); +#else /* __BIG_ENDIAN__. */ + __A = (__m128i)vec_mergeh(__zero, (__v4su)__A); +#endif /* __BIG_ENDIAN__. */ + return __A; +} + +/* Return horizontal packed word minimum and its index in bits [15:0] + and bits [18:16] respectively. */ +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_minpos_epu16(__m128i __A) { + union __u { + __m128i __m; + __v8hu __uh; + }; + union __u __u = {.__m = __A}, __r = {.__m = {0}}; + unsigned short __ridx = 0; + unsigned short __rmin = __u.__uh[__ridx]; + unsigned long __i; + for (__i = 1; __i < 8; __i++) { + if (__u.__uh[__i] < __rmin) { + __rmin = __u.__uh[__i]; + __ridx = __i; + } + } + __r.__uh[0] = __rmin; + __r.__uh[1] = __ridx; + return __r.__m; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_packus_epi32(__m128i __X, __m128i __Y) { + return (__m128i)vec_packsu((__v4si)__X, (__v4si)__Y); +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_epi64(__m128i __X, __m128i __Y) { + return (__m128i)vec_cmpgt((__v2di)__X, (__v2di)__Y); +} +#endif + +#else +#include_next +#endif /* defined(__powerpc64__) && \ + * (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */ + +#endif /* SMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/tmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/tmmintrin.h new file mode 100755 index 0000000..92f0867 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/tmmintrin.h @@ -0,0 +1,453 @@ +/*===---- tmmintrin.h - Implementation of SSSE3 intrinsics on PowerPC ------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Implemented from the specification included in the Intel C++ Compiler + User Guide and Reference, version 9.0. */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header is distributed to simplify porting x86_64 code that + makes explicit use of Intel intrinsics to powerpc64le. + + It is the user's responsibility to determine if the results are + acceptable and make additional changes as necessary. + + Note that much code that uses Intel intrinsics can be rewritten in + standard C or GNU C extensions, which are more portable and better + optimized across multiple targets. */ +#endif + +#ifndef TMMINTRIN_H_ +#define TMMINTRIN_H_ + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +#include + +/* We need definitions from the SSE header files. */ +#include + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_abs_epi16(__m128i __A) { + return (__m128i)vec_abs((__v8hi)__A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_abs_epi32(__m128i __A) { + return (__m128i)vec_abs((__v4si)__A); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_abs_epi8(__m128i __A) { + return (__m128i)vec_abs((__v16qi)__A); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_abs_pi16(__m64 __A) { + __v8hi __B = (__v8hi)(__v2du){__A, __A}; + return (__m64)((__v2du)vec_abs(__B))[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_abs_pi32(__m64 __A) { + __v4si __B = (__v4si)(__v2du){__A, __A}; + return (__m64)((__v2du)vec_abs(__B))[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_abs_pi8(__m64 __A) { + __v16qi __B = (__v16qi)(__v2du){__A, __A}; + return (__m64)((__v2du)vec_abs(__B))[0]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_alignr_epi8(__m128i __A, __m128i __B, const unsigned int __count) { + if (__builtin_constant_p(__count) && __count < 16) { +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_reve((__v16qu)__A); + __B = (__m128i)vec_reve((__v16qu)__B); +#endif + __A = (__m128i)vec_sld((__v16qu)__B, (__v16qu)__A, __count); +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_reve((__v16qu)__A); +#endif + return __A; + } + + if (__count == 0) + return __B; + + if (__count >= 16) { + if (__count >= 32) { + const __v16qu __zero = {0}; + return (__m128i)__zero; + } else { + const __v16qu __shift = vec_splats((unsigned char)((__count - 16) * 8)); +#ifdef __LITTLE_ENDIAN__ + return (__m128i)vec_sro((__v16qu)__A, __shift); +#else + return (__m128i)vec_slo((__v16qu)__A, __shift); +#endif + } + } else { + const __v16qu __shiftA = vec_splats((unsigned char)((16 - __count) * 8)); + const __v16qu __shiftB = vec_splats((unsigned char)(__count * 8)); +#ifdef __LITTLE_ENDIAN__ + __A = (__m128i)vec_slo((__v16qu)__A, __shiftA); + __B = (__m128i)vec_sro((__v16qu)__B, __shiftB); +#else + __A = (__m128i)vec_sro((__v16qu)__A, __shiftA); + __B = (__m128i)vec_slo((__v16qu)__B, __shiftB); +#endif + return (__m128i)vec_or((__v16qu)__A, (__v16qu)__B); + } +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_alignr_pi8(__m64 __A, __m64 __B, unsigned int __count) { + if (__count < 16) { + __v2du __C = {__B, __A}; +#ifdef __LITTLE_ENDIAN__ + const __v4su __shift = {__count << 3, 0, 0, 0}; + __C = (__v2du)vec_sro((__v16qu)__C, (__v16qu)__shift); +#else + const __v4su __shift = {0, 0, 0, __count << 3}; + __C = (__v2du)vec_slo((__v16qu)__C, (__v16qu)__shift); +#endif + return (__m64)__C[0]; + } else { + const __m64 __zero = {0}; + return __zero; + } +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadd_epi16(__m128i __A, __m128i __B) { + const __v16qu __P = {0, 1, 4, 5, 8, 9, 12, 13, + 16, 17, 20, 21, 24, 25, 28, 29}; + const __v16qu __Q = {2, 3, 6, 7, 10, 11, 14, 15, + 18, 19, 22, 23, 26, 27, 30, 31}; + __v8hi __C = vec_perm((__v8hi)__A, (__v8hi)__B, __P); + __v8hi __D = vec_perm((__v8hi)__A, (__v8hi)__B, __Q); + return (__m128i)vec_add(__C, __D); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadd_epi32(__m128i __A, __m128i __B) { + const __v16qu __P = {0, 1, 2, 3, 8, 9, 10, 11, + 16, 17, 18, 19, 24, 25, 26, 27}; + const __v16qu __Q = {4, 5, 6, 7, 12, 13, 14, 15, + 20, 21, 22, 23, 28, 29, 30, 31}; + __v4si __C = vec_perm((__v4si)__A, (__v4si)__B, __P); + __v4si __D = vec_perm((__v4si)__A, (__v4si)__B, __Q); + return (__m128i)vec_add(__C, __D); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadd_pi16(__m64 __A, __m64 __B) { + __v8hi __C = (__v8hi)(__v2du){__A, __B}; + const __v16qu __P = {0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13}; + const __v16qu __Q = {2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15}; + __v8hi __D = vec_perm(__C, __C, __Q); + __C = vec_perm(__C, __C, __P); + __C = vec_add(__C, __D); + return (__m64)((__v2du)__C)[1]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadd_pi32(__m64 __A, __m64 __B) { + __v4si __C = (__v4si)(__v2du){__A, __B}; + const __v16qu __P = {0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 8, 9, 10, 11}; + const __v16qu __Q = {4, 5, 6, 7, 12, 13, 14, 15, 4, 5, 6, 7, 12, 13, 14, 15}; + __v4si __D = vec_perm(__C, __C, __Q); + __C = vec_perm(__C, __C, __P); + __C = vec_add(__C, __D); + return (__m64)((__v2du)__C)[1]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadds_epi16(__m128i __A, __m128i __B) { + __v4si __C = {0}, __D = {0}; + __C = vec_sum4s((__v8hi)__A, __C); + __D = vec_sum4s((__v8hi)__B, __D); + __C = (__v4si)vec_packs(__C, __D); + return (__m128i)__C; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hadds_pi16(__m64 __A, __m64 __B) { + const __v4si __zero = {0}; + __v8hi __C = (__v8hi)(__v2du){__A, __B}; + __v4si __D = vec_sum4s(__C, __zero); + __C = vec_packs(__D, __D); + return (__m64)((__v2du)__C)[1]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsub_epi16(__m128i __A, __m128i __B) { + const __v16qu __P = {0, 1, 4, 5, 8, 9, 12, 13, + 16, 17, 20, 21, 24, 25, 28, 29}; + const __v16qu __Q = {2, 3, 6, 7, 10, 11, 14, 15, + 18, 19, 22, 23, 26, 27, 30, 31}; + __v8hi __C = vec_perm((__v8hi)__A, (__v8hi)__B, __P); + __v8hi __D = vec_perm((__v8hi)__A, (__v8hi)__B, __Q); + return (__m128i)vec_sub(__C, __D); +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsub_epi32(__m128i __A, __m128i __B) { + const __v16qu __P = {0, 1, 2, 3, 8, 9, 10, 11, + 16, 17, 18, 19, 24, 25, 26, 27}; + const __v16qu __Q = {4, 5, 6, 7, 12, 13, 14, 15, + 20, 21, 22, 23, 28, 29, 30, 31}; + __v4si __C = vec_perm((__v4si)__A, (__v4si)__B, __P); + __v4si __D = vec_perm((__v4si)__A, (__v4si)__B, __Q); + return (__m128i)vec_sub(__C, __D); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsub_pi16(__m64 __A, __m64 __B) { + const __v16qu __P = {0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13}; + const __v16qu __Q = {2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15}; + __v8hi __C = (__v8hi)(__v2du){__A, __B}; + __v8hi __D = vec_perm(__C, __C, __Q); + __C = vec_perm(__C, __C, __P); + __C = vec_sub(__C, __D); + return (__m64)((__v2du)__C)[1]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsub_pi32(__m64 __A, __m64 __B) { + const __v16qu __P = {0, 1, 2, 3, 8, 9, 10, 11, 0, 1, 2, 3, 8, 9, 10, 11}; + const __v16qu __Q = {4, 5, 6, 7, 12, 13, 14, 15, 4, 5, 6, 7, 12, 13, 14, 15}; + __v4si __C = (__v4si)(__v2du){__A, __B}; + __v4si __D = vec_perm(__C, __C, __Q); + __C = vec_perm(__C, __C, __P); + __C = vec_sub(__C, __D); + return (__m64)((__v2du)__C)[1]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsubs_epi16(__m128i __A, __m128i __B) { + const __v16qu __P = {0, 1, 4, 5, 8, 9, 12, 13, + 16, 17, 20, 21, 24, 25, 28, 29}; + const __v16qu __Q = {2, 3, 6, 7, 10, 11, 14, 15, + 18, 19, 22, 23, 26, 27, 30, 31}; + __v8hi __C = vec_perm((__v8hi)__A, (__v8hi)__B, __P); + __v8hi __D = vec_perm((__v8hi)__A, (__v8hi)__B, __Q); + return (__m128i)vec_subs(__C, __D); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_hsubs_pi16(__m64 __A, __m64 __B) { + const __v16qu __P = {0, 1, 4, 5, 8, 9, 12, 13, 0, 1, 4, 5, 8, 9, 12, 13}; + const __v16qu __Q = {2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15}; + __v8hi __C = (__v8hi)(__v2du){__A, __B}; + __v8hi __D = vec_perm(__C, __C, __P); + __v8hi __E = vec_perm(__C, __C, __Q); + __C = vec_subs(__D, __E); + return (__m64)((__v2du)__C)[1]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shuffle_epi8(__m128i __A, __m128i __B) { + const __v16qi __zero = {0}; + __vector __bool char __select = vec_cmplt((__v16qi)__B, __zero); + __v16qi __C = vec_perm((__v16qi)__A, (__v16qi)__A, (__v16qu)__B); + return (__m128i)vec_sel(__C, __zero, __select); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shuffle_pi8(__m64 __A, __m64 __B) { + const __v16qi __zero = {0}; + __v16qi __C = (__v16qi)(__v2du){__A, __A}; + __v16qi __D = (__v16qi)(__v2du){__B, __B}; + __vector __bool char __select = vec_cmplt((__v16qi)__D, __zero); + __C = vec_perm((__v16qi)__C, (__v16qi)__C, (__v16qu)__D); + __C = vec_sel(__C, __zero, __select); + return (__m64)((__v2du)(__C))[0]; +} + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sign_epi8(__m128i __A, __m128i __B) { + const __v16qi __zero = {0}; + __v16qi __selectneg = (__v16qi)vec_cmplt((__v16qi)__B, __zero); + __v16qi __selectpos = + (__v16qi)vec_neg((__v16qi)vec_cmpgt((__v16qi)__B, __zero)); + __v16qi __conv = vec_add(__selectneg, __selectpos); + return (__m128i)vec_mul((__v16qi)__A, (__v16qi)__conv); +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sign_epi16(__m128i __A, __m128i __B) { + const __v8hi __zero = {0}; + __v8hi __selectneg = (__v8hi)vec_cmplt((__v8hi)__B, __zero); + __v8hi __selectpos = (__v8hi)vec_neg((__v8hi)vec_cmpgt((__v8hi)__B, __zero)); + __v8hi __conv = vec_add(__selectneg, __selectpos); + return (__m128i)vec_mul((__v8hi)__A, (__v8hi)__conv); +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sign_epi32(__m128i __A, __m128i __B) { + const __v4si __zero = {0}; + __v4si __selectneg = (__v4si)vec_cmplt((__v4si)__B, __zero); + __v4si __selectpos = (__v4si)vec_neg((__v4si)vec_cmpgt((__v4si)__B, __zero)); + __v4si __conv = vec_add(__selectneg, __selectpos); + return (__m128i)vec_mul((__v4si)__A, (__v4si)__conv); +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sign_pi8(__m64 __A, __m64 __B) { + const __v16qi __zero = {0}; + __v16qi __C = (__v16qi)(__v2du){__A, __A}; + __v16qi __D = (__v16qi)(__v2du){__B, __B}; + __C = (__v16qi)_mm_sign_epi8((__m128i)__C, (__m128i)__D); + return (__m64)((__v2du)(__C))[0]; +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sign_pi16(__m64 __A, __m64 __B) { + const __v8hi __zero = {0}; + __v8hi __C = (__v8hi)(__v2du){__A, __A}; + __v8hi __D = (__v8hi)(__v2du){__B, __B}; + __C = (__v8hi)_mm_sign_epi16((__m128i)__C, (__m128i)__D); + return (__m64)((__v2du)(__C))[0]; +} +#endif + +#ifdef _ARCH_PWR8 +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sign_pi32(__m64 __A, __m64 __B) { + const __v4si __zero = {0}; + __v4si __C = (__v4si)(__v2du){__A, __A}; + __v4si __D = (__v4si)(__v2du){__B, __B}; + __C = (__v4si)_mm_sign_epi32((__m128i)__C, (__m128i)__D); + return (__m64)((__v2du)(__C))[0]; +} +#endif + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_maddubs_epi16(__m128i __A, __m128i __B) { + __v8hi __unsigned = vec_splats((signed short)0x00ff); + __v8hi __C = vec_and(vec_unpackh((__v16qi)__A), __unsigned); + __v8hi __D = vec_and(vec_unpackl((__v16qi)__A), __unsigned); + __v8hi __E = vec_unpackh((__v16qi)__B); + __v8hi __F = vec_unpackl((__v16qi)__B); + __C = vec_mul(__C, __E); + __D = vec_mul(__D, __F); + const __v16qu __odds = {0, 1, 4, 5, 8, 9, 12, 13, + 16, 17, 20, 21, 24, 25, 28, 29}; + const __v16qu __evens = {2, 3, 6, 7, 10, 11, 14, 15, + 18, 19, 22, 23, 26, 27, 30, 31}; + __E = vec_perm(__C, __D, __odds); + __F = vec_perm(__C, __D, __evens); + return (__m128i)vec_adds(__E, __F); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_maddubs_pi16(__m64 __A, __m64 __B) { + __v8hi __C = (__v8hi)(__v2du){__A, __A}; + __C = vec_unpackl((__v16qi)__C); + const __v8hi __unsigned = vec_splats((signed short)0x00ff); + __C = vec_and(__C, __unsigned); + __v8hi __D = (__v8hi)(__v2du){__B, __B}; + __D = vec_unpackl((__v16qi)__D); + __D = vec_mul(__C, __D); + const __v16qu __odds = {0, 1, 4, 5, 8, 9, 12, 13, + 16, 17, 20, 21, 24, 25, 28, 29}; + const __v16qu __evens = {2, 3, 6, 7, 10, 11, 14, 15, + 18, 19, 22, 23, 26, 27, 30, 31}; + __C = vec_perm(__D, __D, __odds); + __D = vec_perm(__D, __D, __evens); + __C = vec_adds(__C, __D); + return (__m64)((__v2du)(__C))[0]; +} + +extern __inline __m128i + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mulhrs_epi16(__m128i __A, __m128i __B) { + __v4si __C = vec_unpackh((__v8hi)__A); + __v4si __D = vec_unpackh((__v8hi)__B); + __C = vec_mul(__C, __D); + __D = vec_unpackl((__v8hi)__A); + __v4si __E = vec_unpackl((__v8hi)__B); + __D = vec_mul(__D, __E); + const __v4su __shift = vec_splats((unsigned int)14); + __C = vec_sr(__C, __shift); + __D = vec_sr(__D, __shift); + const __v4si __ones = vec_splats((signed int)1); + __C = vec_add(__C, __ones); + __C = vec_sr(__C, (__v4su)__ones); + __D = vec_add(__D, __ones); + __D = vec_sr(__D, (__v4su)__ones); + return (__m128i)vec_pack(__C, __D); +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mulhrs_pi16(__m64 __A, __m64 __B) { + __v4si __C = (__v4si)(__v2du){__A, __A}; + __C = vec_unpackh((__v8hi)__C); + __v4si __D = (__v4si)(__v2du){__B, __B}; + __D = vec_unpackh((__v8hi)__D); + __C = vec_mul(__C, __D); + const __v4su __shift = vec_splats((unsigned int)14); + __C = vec_sr(__C, __shift); + const __v4si __ones = vec_splats((signed int)1); + __C = vec_add(__C, __ones); + __C = vec_sr(__C, (__v4su)__ones); + __v8hi __E = vec_pack(__C, __D); + return (__m64)((__v2du)(__E))[0]; +} + +#else +#include_next +#endif /* defined(__powerpc64__) && \ + * (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */ + +#endif /* TMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/x86gprintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/x86gprintrin.h new file mode 100755 index 0000000..cbfac26 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/x86gprintrin.h @@ -0,0 +1,17 @@ +/*===--- x86gprintrin.h - Implementation of X86 GPR intrinsics on PowerPC --=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef X86GPRINTRIN_H_ +#define X86GPRINTRIN_H_ + +#include + +#include + +#endif /* X86GPRINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/x86intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/x86intrin.h new file mode 100755 index 0000000..f5c2012 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/x86intrin.h @@ -0,0 +1,28 @@ +/*===---- x86intrin.h - Implementation of X86 intrinsics on PowerPC --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header is distributed to simplify porting x86_64 code that + makes explicit use of Intel intrinsics to powerpc64le. + It is the user's responsibility to determine if the results are + acceptable and make additional changes as necessary. + Note that much code that uses Intel intrinsics can be rewritten in + standard C or GNU C extensions, which are more portable and better + optimized across multiple targets. */ +#error "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this error." +#endif + +#ifndef X86INTRIN_H_ +#define X86INTRIN_H_ + +#ifdef __ALTIVEC__ +#include +#endif /* __ALTIVEC__ */ + +#endif /* X86INTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/xmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/xmmintrin.h new file mode 100755 index 0000000..9dd21b6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ppc_wrappers/xmmintrin.h @@ -0,0 +1,1827 @@ +/*===---- xmmintrin.h - Implementation of SSE intrinsics on PowerPC --------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Implemented from the specification included in the Intel C++ Compiler + User Guide and Reference, version 9.0. */ + +#ifndef NO_WARN_X86_INTRINSICS +/* This header file is to help porting code using Intel intrinsics + explicitly from x86_64 to powerpc64/powerpc64le. + + Since X86 SSE intrinsics mainly handles __m128 type, PowerPC + VMX/VSX ISA is a good match for vector float SIMD operations. + However scalar float operations in vector (XMM) registers require + the POWER8 VSX ISA (2.07) level. There are differences for data + format and placement of float scalars in the vector register, which + require extra steps to match SSE scalar float semantics on POWER. + + It should be noted that there's much difference between X86_64's + MXSCR and PowerISA's FPSCR/VSCR registers. It's recommended to use + portable instead of access MXSCR directly. + + Most SSE scalar float intrinsic operations can be performed more + efficiently as C language float scalar operations or optimized to + use vector SIMD operations. We recommend this for new applications. */ +#error \ + "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this error." +#endif + +#ifndef XMMINTRIN_H_ +#define XMMINTRIN_H_ + +#if defined(__powerpc64__) && \ + (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) + +/* Define four value permute mask */ +#define _MM_SHUFFLE(w, x, y, z) (((w) << 6) | ((x) << 4) | ((y) << 2) | (z)) + +#include + +/* Avoid collisions between altivec.h and strict adherence to C++ and + C11 standards. This should eventually be done inside altivec.h itself, + but only after testing a full distro build. */ +#if defined(__STRICT_ANSI__) && \ + (defined(__cplusplus) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)) +#undef vector +#undef pixel +#undef bool +#endif + +/* We need type definitions from the MMX header file. */ +#include + +/* Get _mm_malloc () and _mm_free (). */ +#if __STDC_HOSTED__ +#include +#endif + +/* The Intel API is flexible enough that we must allow aliasing with other + vector types, and their scalar components. */ +typedef vector float __m128 __attribute__((__may_alias__)); + +/* Unaligned version of the same type. */ +typedef vector float __m128_u __attribute__((__may_alias__, __aligned__(1))); + +/* Internal data types for implementing the intrinsics. */ +typedef vector float __v4sf; + +/* Create an undefined vector. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_undefined_ps(void) { + __m128 __Y = __Y; + return __Y; +} + +/* Create a vector of zeros. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setzero_ps(void) { + return __extension__(__m128){0.0f, 0.0f, 0.0f, 0.0f}; +} + +/* Load four SPFP values from P. The address must be 16-byte aligned. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_ps(float const *__P) { + return ((__m128)vec_ld(0, (__v4sf *)__P)); +} + +/* Load four SPFP values from P. The address need not be 16-byte aligned. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadu_ps(float const *__P) { + return (vec_vsx_ld(0, __P)); +} + +/* Load four SPFP values in reverse order. The address must be aligned. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadr_ps(float const *__P) { + __v4sf __tmp; + __m128 __result; + static const __vector unsigned char __permute_vector = { + 0x1C, 0x1D, 0x1E, 0x1F, 0x18, 0x19, 0x1A, 0x1B, + 0x14, 0x15, 0x16, 0x17, 0x10, 0x11, 0x12, 0x13}; + + __tmp = vec_ld(0, (__v4sf *)__P); + __result = (__m128)vec_perm(__tmp, __tmp, __permute_vector); + return __result; +} + +/* Create a vector with all four elements equal to F. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set1_ps(float __F) { + return __extension__(__m128)(__v4sf){__F, __F, __F, __F}; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_ps1(float __F) { + return _mm_set1_ps(__F); +} + +/* Create the vector [Z Y X W]. */ +extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__, + __artificial__)) +_mm_set_ps(const float __Z, const float __Y, const float __X, const float __W) { + return __extension__(__m128)(__v4sf){__W, __X, __Y, __Z}; +} + +/* Create the vector [W X Y Z]. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_setr_ps(float __Z, float __Y, float __X, float __W) { + return __extension__(__m128)(__v4sf){__Z, __Y, __X, __W}; +} + +/* Store four SPFP values. The address must be 16-byte aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_ps(float *__P, __m128 __A) { + vec_st((__v4sf)__A, 0, (__v4sf *)__P); +} + +/* Store four SPFP values. The address need not be 16-byte aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storeu_ps(float *__P, __m128 __A) { + *(__m128_u *)__P = __A; +} + +/* Store four SPFP values in reverse order. The address must be aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storer_ps(float *__P, __m128 __A) { + __v4sf __tmp; + static const __vector unsigned char __permute_vector = { + 0x1C, 0x1D, 0x1E, 0x1F, 0x18, 0x19, 0x1A, 0x1B, + 0x14, 0x15, 0x16, 0x17, 0x10, 0x11, 0x12, 0x13}; + + __tmp = (__m128)vec_perm(__A, __A, __permute_vector); + + _mm_store_ps(__P, __tmp); +} + +/* Store the lower SPFP value across four words. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store1_ps(float *__P, __m128 __A) { + __v4sf __va = vec_splat((__v4sf)__A, 0); + _mm_store_ps(__P, __va); +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_ps1(float *__P, __m128 __A) { + _mm_store1_ps(__P, __A); +} + +/* Create a vector with element 0 as F and the rest zero. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_set_ss(float __F) { + return __extension__(__m128)(__v4sf){__F, 0.0f, 0.0f, 0.0f}; +} + +/* Sets the low SPFP value of A from the low value of B. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_move_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + + return (vec_sel((__v4sf)__A, (__v4sf)__B, __mask)); +} + +/* Create a vector with element 0 as *P and the rest zero. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_ss(float const *__P) { + return _mm_set_ss(*__P); +} + +/* Stores the lower SPFP value. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_store_ss(float *__P, __m128 __A) { + *__P = ((__v4sf)__A)[0]; +} + +/* Perform the respective operation on the lower SPFP (single-precision + floating-point) values of A and B; the upper three SPFP values are + passed through from A. */ + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_ss(__m128 __A, __m128 __B) { +#ifdef _ARCH_PWR7 + __m128 __a, __b, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + results. So to insure we don't generate spurious exceptions + (from the upper double values) we splat the lower double + before we to the operation. */ + __a = vec_splat(__A, 0); + __b = vec_splat(__B, 0); + __c = __a + __b; + /* Then we merge the lower float result with the original upper + float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +#else + __A[0] = __A[0] + __B[0]; + return (__A); +#endif +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_ss(__m128 __A, __m128 __B) { +#ifdef _ARCH_PWR7 + __m128 __a, __b, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + results. So to insure we don't generate spurious exceptions + (from the upper double values) we splat the lower double + before we to the operation. */ + __a = vec_splat(__A, 0); + __b = vec_splat(__B, 0); + __c = __a - __b; + /* Then we merge the lower float result with the original upper + float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +#else + __A[0] = __A[0] - __B[0]; + return (__A); +#endif +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_ss(__m128 __A, __m128 __B) { +#ifdef _ARCH_PWR7 + __m128 __a, __b, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + results. So to insure we don't generate spurious exceptions + (from the upper double values) we splat the lower double + before we to the operation. */ + __a = vec_splat(__A, 0); + __b = vec_splat(__B, 0); + __c = __a * __b; + /* Then we merge the lower float result with the original upper + float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +#else + __A[0] = __A[0] * __B[0]; + return (__A); +#endif +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_div_ss(__m128 __A, __m128 __B) { +#ifdef _ARCH_PWR7 + __m128 __a, __b, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + results. So to insure we don't generate spurious exceptions + (from the upper double values) we splat the lower double + before we to the operation. */ + __a = vec_splat(__A, 0); + __b = vec_splat(__B, 0); + __c = __a / __b; + /* Then we merge the lower float result with the original upper + float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +#else + __A[0] = __A[0] / __B[0]; + return (__A); +#endif +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sqrt_ss(__m128 __A) { + __m128 __a, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + * results. So to insure we don't generate spurious exceptions + * (from the upper double values) we splat the lower double + * before we to the operation. */ + __a = vec_splat(__A, 0); + __c = vec_sqrt(__a); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +} + +/* Perform the respective operation on the four SPFP values in A and B. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_add_ps(__m128 __A, __m128 __B) { + return (__m128)((__v4sf)__A + (__v4sf)__B); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sub_ps(__m128 __A, __m128 __B) { + return (__m128)((__v4sf)__A - (__v4sf)__B); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mul_ps(__m128 __A, __m128 __B) { + return (__m128)((__v4sf)__A * (__v4sf)__B); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_div_ps(__m128 __A, __m128 __B) { + return (__m128)((__v4sf)__A / (__v4sf)__B); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sqrt_ps(__m128 __A) { + return (vec_sqrt((__v4sf)__A)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_rcp_ps(__m128 __A) { + return (vec_re((__v4sf)__A)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_rsqrt_ps(__m128 __A) { + return (vec_rsqrte(__A)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_rcp_ss(__m128 __A) { + __m128 __a, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + * results. So to insure we don't generate spurious exceptions + * (from the upper double values) we splat the lower double + * before we to the operation. */ + __a = vec_splat(__A, 0); + __c = _mm_rcp_ps(__a); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_rsqrt_ss(__m128 __A) { + __m128 __a, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower double) + * results. So to insure we don't generate spurious exceptions + * (from the upper double values) we splat the lower double + * before we to the operation. */ + __a = vec_splat(__A, 0); + __c = vec_rsqrte(__a); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return (vec_sel(__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_ss(__m128 __A, __m128 __B) { + __v4sf __a, __b, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower float) + * results. So to insure we don't generate spurious exceptions + * (from the upper float values) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = vec_min(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return (vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_ss(__m128 __A, __m128 __B) { + __v4sf __a, __b, __c; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + /* PowerISA VSX does not allow partial (for just lower float) + * results. So to insure we don't generate spurious exceptions + * (from the upper float values) we splat the lower float + * before we to the operation. */ + __a = vec_splat(__A, 0); + __b = vec_splat(__B, 0); + __c = vec_max(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return (vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_ps(__m128 __A, __m128 __B) { + __vector __bool int __m = vec_cmpgt((__v4sf)__B, (__v4sf)__A); + return vec_sel(__B, __A, __m); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_ps(__m128 __A, __m128 __B) { + __vector __bool int __m = vec_cmpgt((__v4sf)__A, (__v4sf)__B); + return vec_sel(__B, __A, __m); +} + +/* Perform logical bit-wise operations on 128-bit values. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_and_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_and((__v4sf)__A, (__v4sf)__B)); + // return __builtin_ia32_andps (__A, __B); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_andnot_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_andc((__v4sf)__B, (__v4sf)__A)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_or_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_or((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_xor_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_xor((__v4sf)__A, (__v4sf)__B)); +} + +/* Perform a comparison on the four SPFP values of A and B. For each + element, if the comparison is true, place a mask of all ones in the + result, otherwise a mask of zeros. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmpeq((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmplt((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmple_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmple((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmpgt((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpge_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmpge((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpneq_ps(__m128 __A, __m128 __B) { + __v4sf __temp = (__v4sf)vec_cmpeq((__v4sf)__A, (__v4sf)__B); + return ((__m128)vec_nor(__temp, __temp)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnlt_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmpge((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnle_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmpgt((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpngt_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmple((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnge_ps(__m128 __A, __m128 __B) { + return ((__m128)vec_cmplt((__v4sf)__A, (__v4sf)__B)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpord_ps(__m128 __A, __m128 __B) { + __vector unsigned int __a, __b; + __vector unsigned int __c, __d; + static const __vector unsigned int __float_exp_mask = { + 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000}; + + __a = (__vector unsigned int)vec_abs((__v4sf)__A); + __b = (__vector unsigned int)vec_abs((__v4sf)__B); + __c = (__vector unsigned int)vec_cmpgt(__float_exp_mask, __a); + __d = (__vector unsigned int)vec_cmpgt(__float_exp_mask, __b); + return ((__m128)vec_and(__c, __d)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpunord_ps(__m128 __A, __m128 __B) { + __vector unsigned int __a, __b; + __vector unsigned int __c, __d; + static const __vector unsigned int __float_exp_mask = { + 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000}; + + __a = (__vector unsigned int)vec_abs((__v4sf)__A); + __b = (__vector unsigned int)vec_abs((__v4sf)__B); + __c = (__vector unsigned int)vec_cmpgt(__a, __float_exp_mask); + __d = (__vector unsigned int)vec_cmpgt(__b, __float_exp_mask); + return ((__m128)vec_or(__c, __d)); +} + +/* Perform a comparison on the lower SPFP values of A and B. If the + comparison is true, place a mask of all ones in the result, otherwise a + mask of zeros. The upper three SPFP values are passed through from A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmpeq(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmplt_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmplt(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmple_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmple(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpgt_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmpgt(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpge_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmpge(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpneq_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmpeq(__a, __b); + __c = vec_nor(__c, __c); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnlt_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmpge(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnle_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmpgt(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpngt_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we to the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmple(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpnge_ss(__m128 __A, __m128 __B) { + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + __v4sf __a, __b, __c; + /* PowerISA VMX does not allow partial (for just element 0) + * results. So to insure we don't generate spurious exceptions + * (from the upper elements) we splat the lower float + * before we do the operation. */ + __a = vec_splat((__v4sf)__A, 0); + __b = vec_splat((__v4sf)__B, 0); + __c = (__v4sf)vec_cmplt(__a, __b); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, __c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpord_ss(__m128 __A, __m128 __B) { + __vector unsigned int __a, __b; + __vector unsigned int __c, __d; + static const __vector unsigned int __float_exp_mask = { + 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000}; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + + __a = (__vector unsigned int)vec_abs((__v4sf)__A); + __b = (__vector unsigned int)vec_abs((__v4sf)__B); + __c = (__vector unsigned int)vec_cmpgt(__float_exp_mask, __a); + __d = (__vector unsigned int)vec_cmpgt(__float_exp_mask, __b); + __c = vec_and(__c, __d); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, (__v4sf)__c, __mask)); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpunord_ss(__m128 __A, __m128 __B) { + __vector unsigned int __a, __b; + __vector unsigned int __c, __d; + static const __vector unsigned int __float_exp_mask = { + 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000}; + static const __vector unsigned int __mask = {0xffffffff, 0, 0, 0}; + + __a = (__vector unsigned int)vec_abs((__v4sf)__A); + __b = (__vector unsigned int)vec_abs((__v4sf)__B); + __c = (__vector unsigned int)vec_cmpgt(__a, __float_exp_mask); + __d = (__vector unsigned int)vec_cmpgt(__b, __float_exp_mask); + __c = vec_or(__c, __d); + /* Then we merge the lower float result with the original upper + * float elements from __A. */ + return ((__m128)vec_sel((__v4sf)__A, (__v4sf)__c, __mask)); +} + +/* Compare the lower SPFP values of A and B and return 1 if true + and 0 if false. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comieq_ss(__m128 __A, __m128 __B) { + return (__A[0] == __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comilt_ss(__m128 __A, __m128 __B) { + return (__A[0] < __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comile_ss(__m128 __A, __m128 __B) { + return (__A[0] <= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comigt_ss(__m128 __A, __m128 __B) { + return (__A[0] > __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comige_ss(__m128 __A, __m128 __B) { + return (__A[0] >= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_comineq_ss(__m128 __A, __m128 __B) { + return (__A[0] != __B[0]); +} + +/* FIXME + * The __mm_ucomi??_ss implementations below are exactly the same as + * __mm_comi??_ss because GCC for PowerPC only generates unordered + * compares (scalar and vector). + * Technically __mm_comieq_ss et al should be using the ordered + * compare and signal for QNaNs. + * The __mm_ucomieq_sd et all should be OK, as is. + */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomieq_ss(__m128 __A, __m128 __B) { + return (__A[0] == __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomilt_ss(__m128 __A, __m128 __B) { + return (__A[0] < __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomile_ss(__m128 __A, __m128 __B) { + return (__A[0] <= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomigt_ss(__m128 __A, __m128 __B) { + return (__A[0] > __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomige_ss(__m128 __A, __m128 __B) { + return (__A[0] >= __B[0]); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_ucomineq_ss(__m128 __A, __m128 __B) { + return (__A[0] != __B[0]); +} + +extern __inline float + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtss_f32(__m128 __A) { + return ((__v4sf)__A)[0]; +} + +/* Convert the lower SPFP value to a 32-bit integer according to the current + rounding mode. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtss_si32(__m128 __A) { + int __res; +#ifdef _ARCH_PWR8 + double __dtmp; + __asm__( +#ifdef __LITTLE_ENDIAN__ + "xxsldwi %x0,%x0,%x0,3;\n" +#endif + "xscvspdp %x2,%x0;\n" + "fctiw %2,%2;\n" + "mfvsrd %1,%x2;\n" + : "+wa"(__A), "=r"(__res), "=f"(__dtmp) + :); +#else + __res = __builtin_rint(__A[0]); +#endif + return __res; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvt_ss2si(__m128 __A) { + return _mm_cvtss_si32(__A); +} + +/* Convert the lower SPFP value to a 32-bit integer according to the + current rounding mode. */ + +/* Intel intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtss_si64(__m128 __A) { + long long __res; +#if defined(_ARCH_PWR8) && defined(__powerpc64__) + double __dtmp; + __asm__( +#ifdef __LITTLE_ENDIAN__ + "xxsldwi %x0,%x0,%x0,3;\n" +#endif + "xscvspdp %x2,%x0;\n" + "fctid %2,%2;\n" + "mfvsrd %1,%x2;\n" + : "+wa"(__A), "=r"(__res), "=f"(__dtmp) + :); +#else + __res = __builtin_llrint(__A[0]); +#endif + return __res; +} + +/* Microsoft intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtss_si64x(__m128 __A) { + return _mm_cvtss_si64((__v4sf)__A); +} + +/* Constants for use with _mm_prefetch. */ +enum _mm_hint { + /* _MM_HINT_ET is _MM_HINT_T with set 3rd bit. */ + _MM_HINT_ET0 = 7, + _MM_HINT_ET1 = 6, + _MM_HINT_T0 = 3, + _MM_HINT_T1 = 2, + _MM_HINT_T2 = 1, + _MM_HINT_NTA = 0 +}; + +/* Loads one cache line from address P to a location "closer" to the + processor. The selector I specifies the type of prefetch operation. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_prefetch(const void *__P, enum _mm_hint __I) { + /* Current PowerPC will ignores the hint parameters. */ + __builtin_prefetch(__P); +} + +/* Convert the two lower SPFP values to 32-bit integers according to the + current rounding mode. Return the integers in packed form. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtps_pi32(__m128 __A) { + /* Splat two lower SPFP values to both halves. */ + __v4sf __temp, __rounded; + __vector unsigned long long __result; + + /* Splat two lower SPFP values to both halves. */ + __temp = (__v4sf)vec_splat((__vector long long)__A, 0); + __rounded = vec_rint(__temp); + __result = (__vector unsigned long long)vec_cts(__rounded, 0); + + return (__m64)((__vector long long)__result)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvt_ps2pi(__m128 __A) { + return _mm_cvtps_pi32(__A); +} + +/* Truncate the lower SPFP value to a 32-bit integer. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttss_si32(__m128 __A) { + /* Extract the lower float element. */ + float __temp = __A[0]; + /* truncate to 32-bit integer and return. */ + return __temp; +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtt_ss2si(__m128 __A) { + return _mm_cvttss_si32(__A); +} + +/* Intel intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttss_si64(__m128 __A) { + /* Extract the lower float element. */ + float __temp = __A[0]; + /* truncate to 32-bit integer and return. */ + return __temp; +} + +/* Microsoft intrinsic. */ +extern __inline long long + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttss_si64x(__m128 __A) { + /* Extract the lower float element. */ + float __temp = __A[0]; + /* truncate to 32-bit integer and return. */ + return __temp; +} + +/* Truncate the two lower SPFP values to 32-bit integers. Return the + integers in packed form. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvttps_pi32(__m128 __A) { + __v4sf __temp; + __vector unsigned long long __result; + + /* Splat two lower SPFP values to both halves. */ + __temp = (__v4sf)vec_splat((__vector long long)__A, 0); + __result = (__vector unsigned long long)vec_cts(__temp, 0); + + return (__m64)((__vector long long)__result)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtt_ps2pi(__m128 __A) { + return _mm_cvttps_pi32(__A); +} + +/* Convert B to a SPFP value and insert it as element zero in A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi32_ss(__m128 __A, int __B) { + float __temp = __B; + __A[0] = __temp; + + return __A; +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvt_si2ss(__m128 __A, int __B) { + return _mm_cvtsi32_ss(__A, __B); +} + +/* Convert B to a SPFP value and insert it as element zero in A. */ +/* Intel intrinsic. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64_ss(__m128 __A, long long __B) { + float __temp = __B; + __A[0] = __temp; + + return __A; +} + +/* Microsoft intrinsic. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtsi64x_ss(__m128 __A, long long __B) { + return _mm_cvtsi64_ss(__A, __B); +} + +/* Convert the two 32-bit values in B to SPFP form and insert them + as the two lower elements in A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpi32_ps(__m128 __A, __m64 __B) { + __vector signed int __vm1; + __vector float __vf1; + + __vm1 = (__vector signed int)(__vector unsigned long long){__B, __B}; + __vf1 = (__vector float)vec_ctf(__vm1, 0); + + return ((__m128)(__vector unsigned long long){ + ((__vector unsigned long long)__vf1)[0], + ((__vector unsigned long long)__A)[1]}); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvt_pi2ps(__m128 __A, __m64 __B) { + return _mm_cvtpi32_ps(__A, __B); +} + +/* Convert the four signed 16-bit values in A to SPFP form. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpi16_ps(__m64 __A) { + __vector signed short __vs8; + __vector signed int __vi4; + __vector float __vf1; + + __vs8 = (__vector signed short)(__vector unsigned long long){__A, __A}; + __vi4 = vec_vupklsh(__vs8); + __vf1 = (__vector float)vec_ctf(__vi4, 0); + + return (__m128)__vf1; +} + +/* Convert the four unsigned 16-bit values in A to SPFP form. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpu16_ps(__m64 __A) { + const __vector unsigned short __zero = {0, 0, 0, 0, 0, 0, 0, 0}; + __vector unsigned short __vs8; + __vector unsigned int __vi4; + __vector float __vf1; + + __vs8 = (__vector unsigned short)(__vector unsigned long long){__A, __A}; + __vi4 = (__vector unsigned int)vec_mergel +#ifdef __LITTLE_ENDIAN__ + (__vs8, __zero); +#else + (__zero, __vs8); +#endif + __vf1 = (__vector float)vec_ctf(__vi4, 0); + + return (__m128)__vf1; +} + +/* Convert the low four signed 8-bit values in A to SPFP form. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpi8_ps(__m64 __A) { + __vector signed char __vc16; + __vector signed short __vs8; + __vector signed int __vi4; + __vector float __vf1; + + __vc16 = (__vector signed char)(__vector unsigned long long){__A, __A}; + __vs8 = vec_vupkhsb(__vc16); + __vi4 = vec_vupkhsh(__vs8); + __vf1 = (__vector float)vec_ctf(__vi4, 0); + + return (__m128)__vf1; +} + +/* Convert the low four unsigned 8-bit values in A to SPFP form. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + + _mm_cvtpu8_ps(__m64 __A) { + const __vector unsigned char __zero = {0, 0, 0, 0, 0, 0, 0, 0}; + __vector unsigned char __vc16; + __vector unsigned short __vs8; + __vector unsigned int __vi4; + __vector float __vf1; + + __vc16 = (__vector unsigned char)(__vector unsigned long long){__A, __A}; +#ifdef __LITTLE_ENDIAN__ + __vs8 = (__vector unsigned short)vec_mergel(__vc16, __zero); + __vi4 = + (__vector unsigned int)vec_mergeh(__vs8, (__vector unsigned short)__zero); +#else + __vs8 = (__vector unsigned short)vec_mergel(__zero, __vc16); + __vi4 = + (__vector unsigned int)vec_mergeh((__vector unsigned short)__zero, __vs8); +#endif + __vf1 = (__vector float)vec_ctf(__vi4, 0); + + return (__m128)__vf1; +} + +/* Convert the four signed 32-bit values in A and B to SPFP form. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtpi32x2_ps(__m64 __A, __m64 __B) { + __vector signed int __vi4; + __vector float __vf4; + + __vi4 = (__vector signed int)(__vector unsigned long long){__A, __B}; + __vf4 = (__vector float)vec_ctf(__vi4, 0); + return (__m128)__vf4; +} + +/* Convert the four SPFP values in A to four signed 16-bit integers. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtps_pi16(__m128 __A) { + __v4sf __rounded; + __vector signed int __temp; + __vector unsigned long long __result; + + __rounded = vec_rint(__A); + __temp = vec_cts(__rounded, 0); + __result = (__vector unsigned long long)vec_pack(__temp, __temp); + + return (__m64)((__vector long long)__result)[0]; +} + +/* Convert the four SPFP values in A to four signed 8-bit integers. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cvtps_pi8(__m128 __A) { + __v4sf __rounded; + __vector signed int __tmp_i; + static const __vector signed int __zero = {0, 0, 0, 0}; + __vector signed short __tmp_s; + __vector signed char __res_v; + + __rounded = vec_rint(__A); + __tmp_i = vec_cts(__rounded, 0); + __tmp_s = vec_pack(__tmp_i, __zero); + __res_v = vec_pack(__tmp_s, __tmp_s); + return (__m64)((__vector long long)__res_v)[0]; +} + +/* Selects four specific SPFP values from A and B based on MASK. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + + _mm_shuffle_ps(__m128 __A, __m128 __B, int const __mask) { + unsigned long __element_selector_10 = __mask & 0x03; + unsigned long __element_selector_32 = (__mask >> 2) & 0x03; + unsigned long __element_selector_54 = (__mask >> 4) & 0x03; + unsigned long __element_selector_76 = (__mask >> 6) & 0x03; + static const unsigned int __permute_selectors[4] = { +#ifdef __LITTLE_ENDIAN__ + 0x03020100, 0x07060504, 0x0B0A0908, 0x0F0E0D0C +#else + 0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F +#endif + }; + __vector unsigned int __t; + + __t[0] = __permute_selectors[__element_selector_10]; + __t[1] = __permute_selectors[__element_selector_32]; + __t[2] = __permute_selectors[__element_selector_54] + 0x10101010; + __t[3] = __permute_selectors[__element_selector_76] + 0x10101010; + return vec_perm((__v4sf)__A, (__v4sf)__B, (__vector unsigned char)__t); +} + +/* Selects and interleaves the upper two SPFP values from A and B. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpackhi_ps(__m128 __A, __m128 __B) { + return (__m128)vec_vmrglw((__v4sf)__A, (__v4sf)__B); +} + +/* Selects and interleaves the lower two SPFP values from A and B. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_unpacklo_ps(__m128 __A, __m128 __B) { + return (__m128)vec_vmrghw((__v4sf)__A, (__v4sf)__B); +} + +/* Sets the upper two SPFP values with 64-bits of data loaded from P; + the lower two values are passed through from A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadh_pi(__m128 __A, __m64 const *__P) { + __vector unsigned long long __a = (__vector unsigned long long)__A; + __vector unsigned long long __p = vec_splats(*__P); + __a[1] = __p[1]; + + return (__m128)__a; +} + +/* Stores the upper two SPFP values of A into P. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storeh_pi(__m64 *__P, __m128 __A) { + __vector unsigned long long __a = (__vector unsigned long long)__A; + + *__P = __a[1]; +} + +/* Moves the upper two values of B into the lower two values of A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movehl_ps(__m128 __A, __m128 __B) { + return (__m128)vec_mergel((__vector unsigned long long)__B, + (__vector unsigned long long)__A); +} + +/* Moves the lower two values of B into the upper two values of A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movelh_ps(__m128 __A, __m128 __B) { + return (__m128)vec_mergeh((__vector unsigned long long)__A, + (__vector unsigned long long)__B); +} + +/* Sets the lower two SPFP values with 64-bits of data loaded from P; + the upper two values are passed through from A. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadl_pi(__m128 __A, __m64 const *__P) { + __vector unsigned long long __a = (__vector unsigned long long)__A; + __vector unsigned long long __p = vec_splats(*__P); + __a[0] = __p[0]; + + return (__m128)__a; +} + +/* Stores the lower two SPFP values of A into P. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_storel_pi(__m64 *__P, __m128 __A) { + __vector unsigned long long __a = (__vector unsigned long long)__A; + + *__P = __a[0]; +} + +#ifdef _ARCH_PWR8 +/* Intrinsic functions that require PowerISA 2.07 minimum. */ + +/* Creates a 4-bit mask from the most significant bits of the SPFP values. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movemask_ps(__m128 __A) { +#ifdef _ARCH_PWR10 + return vec_extractm((__vector unsigned int)__A); +#else + __vector unsigned long long __result; + static const __vector unsigned int __perm_mask = { +#ifdef __LITTLE_ENDIAN__ + 0x00204060, 0x80808080, 0x80808080, 0x80808080 +#else + 0x80808080, 0x80808080, 0x80808080, 0x00204060 +#endif + }; + + __result = ((__vector unsigned long long)vec_vbpermq( + (__vector unsigned char)__A, (__vector unsigned char)__perm_mask)); + +#ifdef __LITTLE_ENDIAN__ + return __result[1]; +#else + return __result[0]; +#endif +#endif /* !_ARCH_PWR10 */ +} +#endif /* _ARCH_PWR8 */ + +/* Create a vector with all four elements equal to *P. */ +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load1_ps(float const *__P) { + return _mm_set1_ps(*__P); +} + +extern __inline __m128 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_load_ps1(float const *__P) { + return _mm_load1_ps(__P); +} + +/* Extracts one of the four words of A. The selector N must be immediate. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_extract_pi16(__m64 const __A, int const __N) { + unsigned int __shiftr = __N & 3; +#ifdef __BIG_ENDIAN__ + __shiftr = 3 - __shiftr; +#endif + + return ((__A >> (__shiftr * 16)) & 0xffff); +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pextrw(__m64 const __A, int const __N) { + return _mm_extract_pi16(__A, __N); +} + +/* Inserts word D into one of four words of A. The selector N must be + immediate. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_insert_pi16(__m64 const __A, int const __D, int const __N) { + const int __shiftl = (__N & 3) * 16; + const __m64 __shiftD = (const __m64)__D << __shiftl; + const __m64 __mask = 0xffffUL << __shiftl; + __m64 __result = (__A & (~__mask)) | (__shiftD & __mask); + + return __result; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pinsrw(__m64 const __A, int const __D, int const __N) { + return _mm_insert_pi16(__A, __D, __N); +} + +/* Compute the element-wise maximum of signed 16-bit values. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + + _mm_max_pi16(__m64 __A, __m64 __B) { +#if _ARCH_PWR8 + __vector signed short __a, __b, __r; + __vector __bool short __c; + + __a = (__vector signed short)vec_splats(__A); + __b = (__vector signed short)vec_splats(__B); + __c = (__vector __bool short)vec_cmpgt(__a, __b); + __r = vec_sel(__b, __a, __c); + return (__m64)((__vector long long)__r)[0]; +#else + __m64_union __m1, __m2, __res; + + __m1.as_m64 = __A; + __m2.as_m64 = __B; + + __res.as_short[0] = (__m1.as_short[0] > __m2.as_short[0]) ? __m1.as_short[0] + : __m2.as_short[0]; + __res.as_short[1] = (__m1.as_short[1] > __m2.as_short[1]) ? __m1.as_short[1] + : __m2.as_short[1]; + __res.as_short[2] = (__m1.as_short[2] > __m2.as_short[2]) ? __m1.as_short[2] + : __m2.as_short[2]; + __res.as_short[3] = (__m1.as_short[3] > __m2.as_short[3]) ? __m1.as_short[3] + : __m2.as_short[3]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmaxsw(__m64 __A, __m64 __B) { + return _mm_max_pi16(__A, __B); +} + +/* Compute the element-wise maximum of unsigned 8-bit values. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_max_pu8(__m64 __A, __m64 __B) { +#if _ARCH_PWR8 + __vector unsigned char __a, __b, __r; + __vector __bool char __c; + + __a = (__vector unsigned char)vec_splats(__A); + __b = (__vector unsigned char)vec_splats(__B); + __c = (__vector __bool char)vec_cmpgt(__a, __b); + __r = vec_sel(__b, __a, __c); + return (__m64)((__vector long long)__r)[0]; +#else + __m64_union __m1, __m2, __res; + long __i; + + __m1.as_m64 = __A; + __m2.as_m64 = __B; + + for (__i = 0; __i < 8; __i++) + __res.as_char[__i] = + ((unsigned char)__m1.as_char[__i] > (unsigned char)__m2.as_char[__i]) + ? __m1.as_char[__i] + : __m2.as_char[__i]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmaxub(__m64 __A, __m64 __B) { + return _mm_max_pu8(__A, __B); +} + +/* Compute the element-wise minimum of signed 16-bit values. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_pi16(__m64 __A, __m64 __B) { +#if _ARCH_PWR8 + __vector signed short __a, __b, __r; + __vector __bool short __c; + + __a = (__vector signed short)vec_splats(__A); + __b = (__vector signed short)vec_splats(__B); + __c = (__vector __bool short)vec_cmplt(__a, __b); + __r = vec_sel(__b, __a, __c); + return (__m64)((__vector long long)__r)[0]; +#else + __m64_union __m1, __m2, __res; + + __m1.as_m64 = __A; + __m2.as_m64 = __B; + + __res.as_short[0] = (__m1.as_short[0] < __m2.as_short[0]) ? __m1.as_short[0] + : __m2.as_short[0]; + __res.as_short[1] = (__m1.as_short[1] < __m2.as_short[1]) ? __m1.as_short[1] + : __m2.as_short[1]; + __res.as_short[2] = (__m1.as_short[2] < __m2.as_short[2]) ? __m1.as_short[2] + : __m2.as_short[2]; + __res.as_short[3] = (__m1.as_short[3] < __m2.as_short[3]) ? __m1.as_short[3] + : __m2.as_short[3]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pminsw(__m64 __A, __m64 __B) { + return _mm_min_pi16(__A, __B); +} + +/* Compute the element-wise minimum of unsigned 8-bit values. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_min_pu8(__m64 __A, __m64 __B) { +#if _ARCH_PWR8 + __vector unsigned char __a, __b, __r; + __vector __bool char __c; + + __a = (__vector unsigned char)vec_splats(__A); + __b = (__vector unsigned char)vec_splats(__B); + __c = (__vector __bool char)vec_cmplt(__a, __b); + __r = vec_sel(__b, __a, __c); + return (__m64)((__vector long long)__r)[0]; +#else + __m64_union __m1, __m2, __res; + long __i; + + __m1.as_m64 = __A; + __m2.as_m64 = __B; + + for (__i = 0; __i < 8; __i++) + __res.as_char[__i] = + ((unsigned char)__m1.as_char[__i] < (unsigned char)__m2.as_char[__i]) + ? __m1.as_char[__i] + : __m2.as_char[__i]; + + return (__m64)__res.as_m64; +#endif +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pminub(__m64 __A, __m64 __B) { + return _mm_min_pu8(__A, __B); +} + +/* Create an 8-bit mask of the signs of 8-bit values. */ +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movemask_pi8(__m64 __A) { +#ifdef __powerpc64__ + unsigned long long __p = +#ifdef __LITTLE_ENDIAN__ + 0x0008101820283038UL; // permute control for sign bits +#else + 0x3830282018100800UL; // permute control for sign bits +#endif + return __builtin_bpermd(__p, __A); +#else +#ifdef __LITTLE_ENDIAN__ + unsigned int __mask = 0x20283038UL; + unsigned int __r1 = __builtin_bpermd(__mask, __A) & 0xf; + unsigned int __r2 = __builtin_bpermd(__mask, __A >> 32) & 0xf; +#else + unsigned int __mask = 0x38302820UL; + unsigned int __r1 = __builtin_bpermd(__mask, __A >> 32) & 0xf; + unsigned int __r2 = __builtin_bpermd(__mask, __A) & 0xf; +#endif + return (__r2 << 4) | __r1; +#endif +} + +extern __inline int + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmovmskb(__m64 __A) { + return _mm_movemask_pi8(__A); +} + +/* Multiply four unsigned 16-bit values in A by four unsigned 16-bit values + in B and produce the high 16 bits of the 32-bit results. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_mulhi_pu16(__m64 __A, __m64 __B) { + __vector unsigned short __a, __b; + __vector unsigned short __c; + __vector unsigned int __w0, __w1; + __vector unsigned char __xform1 = { +#ifdef __LITTLE_ENDIAN__ + 0x02, 0x03, 0x12, 0x13, 0x06, 0x07, 0x16, 0x17, 0x0A, + 0x0B, 0x1A, 0x1B, 0x0E, 0x0F, 0x1E, 0x1F +#else + 0x00, 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15, 0x00, + 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15 +#endif + }; + + __a = (__vector unsigned short)vec_splats(__A); + __b = (__vector unsigned short)vec_splats(__B); + + __w0 = vec_vmuleuh(__a, __b); + __w1 = vec_vmulouh(__a, __b); + __c = (__vector unsigned short)vec_perm(__w0, __w1, __xform1); + + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pmulhuw(__m64 __A, __m64 __B) { + return _mm_mulhi_pu16(__A, __B); +} + +/* Return a combination of the four 16-bit values in A. The selector + must be an immediate. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_shuffle_pi16(__m64 __A, int const __N) { + unsigned long __element_selector_10 = __N & 0x03; + unsigned long __element_selector_32 = (__N >> 2) & 0x03; + unsigned long __element_selector_54 = (__N >> 4) & 0x03; + unsigned long __element_selector_76 = (__N >> 6) & 0x03; + static const unsigned short __permute_selectors[4] = { +#ifdef __LITTLE_ENDIAN__ + 0x0908, 0x0B0A, 0x0D0C, 0x0F0E +#else + 0x0607, 0x0405, 0x0203, 0x0001 +#endif + }; + __m64_union __t; + __vector unsigned long long __a, __p, __r; + +#ifdef __LITTLE_ENDIAN__ + __t.as_short[0] = __permute_selectors[__element_selector_10]; + __t.as_short[1] = __permute_selectors[__element_selector_32]; + __t.as_short[2] = __permute_selectors[__element_selector_54]; + __t.as_short[3] = __permute_selectors[__element_selector_76]; +#else + __t.as_short[3] = __permute_selectors[__element_selector_10]; + __t.as_short[2] = __permute_selectors[__element_selector_32]; + __t.as_short[1] = __permute_selectors[__element_selector_54]; + __t.as_short[0] = __permute_selectors[__element_selector_76]; +#endif + __p = vec_splats(__t.as_m64); + __a = vec_splats(__A); + __r = vec_perm(__a, __a, (__vector unsigned char)__p); + return (__m64)((__vector long long)__r)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pshufw(__m64 __A, int const __N) { + return _mm_shuffle_pi16(__A, __N); +} + +/* Conditionally store byte elements of A into P. The high bit of each + byte in the selector N determines whether the corresponding byte from + A is stored. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_maskmove_si64(__m64 __A, __m64 __N, char *__P) { + __m64 __hibit = 0x8080808080808080UL; + __m64 __mask, __tmp; + __m64 *__p = (__m64 *)__P; + + __tmp = *__p; + __mask = _mm_cmpeq_pi8((__N & __hibit), __hibit); + __tmp = (__tmp & (~__mask)) | (__A & __mask); + *__p = __tmp; +} + +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_maskmovq(__m64 __A, __m64 __N, char *__P) { + _mm_maskmove_si64(__A, __N, __P); +} + +/* Compute the rounded averages of the unsigned 8-bit values in A and B. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_avg_pu8(__m64 __A, __m64 __B) { + __vector unsigned char __a, __b, __c; + + __a = (__vector unsigned char)vec_splats(__A); + __b = (__vector unsigned char)vec_splats(__B); + __c = vec_avg(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pavgb(__m64 __A, __m64 __B) { + return _mm_avg_pu8(__A, __B); +} + +/* Compute the rounded averages of the unsigned 16-bit values in A and B. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_avg_pu16(__m64 __A, __m64 __B) { + __vector unsigned short __a, __b, __c; + + __a = (__vector unsigned short)vec_splats(__A); + __b = (__vector unsigned short)vec_splats(__B); + __c = vec_avg(__a, __b); + return (__m64)((__vector long long)__c)[0]; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_pavgw(__m64 __A, __m64 __B) { + return _mm_avg_pu16(__A, __B); +} + +/* Compute the sum of the absolute differences of the unsigned 8-bit + values in A and B. Return the value in the lower 16-bit word; the + upper words are cleared. */ +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sad_pu8(__m64 __A, __m64 __B) { + __vector unsigned char __a, __b; + __vector unsigned char __vmin, __vmax, __vabsdiff; + __vector signed int __vsum; + const __vector unsigned int __zero = {0, 0, 0, 0}; + __m64_union __result = {0}; + + __a = (__vector unsigned char)(__vector unsigned long long){0UL, __A}; + __b = (__vector unsigned char)(__vector unsigned long long){0UL, __B}; + __vmin = vec_min(__a, __b); + __vmax = vec_max(__a, __b); + __vabsdiff = vec_sub(__vmax, __vmin); + /* Sum four groups of bytes into integers. */ + __vsum = (__vector signed int)vec_sum4s(__vabsdiff, __zero); + /* Sum across four integers with integer result. */ + __vsum = vec_sums(__vsum, (__vector signed int)__zero); + /* The sum is in the right most 32-bits of the vector result. + Transfer to a GPR and truncate to 16 bits. */ + __result.as_short[0] = __vsum[3]; + return __result.as_m64; +} + +extern __inline __m64 + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _m_psadbw(__m64 __A, __m64 __B) { + return _mm_sad_pu8(__A, __B); +} + +/* Stores the data in A to the address P without polluting the caches. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_stream_pi(__m64 *__P, __m64 __A) { + /* Use the data cache block touch for store transient. */ + __asm__(" dcbtstt 0,%0" : : "b"(__P) : "memory"); + *__P = __A; +} + +/* Likewise. The address must be 16-byte aligned. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_stream_ps(float *__P, __m128 __A) { + /* Use the data cache block touch for store transient. */ + __asm__(" dcbtstt 0,%0" : : "b"(__P) : "memory"); + _mm_store_ps(__P, __A); +} + +/* Guarantees that every preceding store is globally visible before + any subsequent store. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_sfence(void) { + /* Generate a light weight sync. */ + __atomic_thread_fence(__ATOMIC_RELEASE); +} + +/* The execution of the next instruction is delayed by an implementation + specific amount of time. The instruction does not modify the + architectural state. This is after the pop_options pragma because + it does not require SSE support in the processor--the encoding is a + nop on processors that do not support it. */ +extern __inline void + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_pause(void) { + /* There is no exact match with this construct, but the following is + close to the desired effect. */ +#if _ARCH_PWR8 + /* On power8 and later processors we can depend on Program Priority + (PRI) and associated "very low" PPI setting. Since we don't know + what PPI this thread is running at we: 1) save the current PRI + from the PPR SPR into a local GRP, 2) set the PRI to "very low* + via the special or 31,31,31 encoding. 3) issue an "isync" to + insure the PRI change takes effect before we execute any more + instructions. + Now we can execute a lwsync (release barrier) while we execute + this thread at "very low" PRI. Finally we restore the original + PRI and continue execution. */ + unsigned long __PPR; + + __asm__ volatile(" mfppr %0;" + " or 31,31,31;" + " isync;" + " lwsync;" + " isync;" + " mtppr %0;" + : "=r"(__PPR) + : + : "memory"); +#else + /* For older processor where we may not even have Program Priority + controls we can only depend on Heavy Weight Sync. */ + __atomic_thread_fence(__ATOMIC_SEQ_CST); +#endif +} + +/* Transpose the 4x4 matrix composed of row[0-3]. */ +#define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \ + do { \ + __v4sf __r0 = (row0), __r1 = (row1), __r2 = (row2), __r3 = (row3); \ + __v4sf __t0 = vec_vmrghw(__r0, __r1); \ + __v4sf __t1 = vec_vmrghw(__r2, __r3); \ + __v4sf __t2 = vec_vmrglw(__r0, __r1); \ + __v4sf __t3 = vec_vmrglw(__r2, __r3); \ + (row0) = (__v4sf)vec_mergeh((__vector long long)__t0, \ + (__vector long long)__t1); \ + (row1) = (__v4sf)vec_mergel((__vector long long)__t0, \ + (__vector long long)__t1); \ + (row2) = (__v4sf)vec_mergeh((__vector long long)__t2, \ + (__vector long long)__t3); \ + (row3) = (__v4sf)vec_mergel((__vector long long)__t2, \ + (__vector long long)__t3); \ + } while (0) + +/* For backward source compatibility. */ +//# include + +#else +#include_next +#endif /* defined(__powerpc64__) && \ + * (defined(__linux__) || defined(__FreeBSD__) || defined(_AIX)) */ + +#endif /* XMMINTRIN_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/prfchiintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/prfchiintrin.h new file mode 100755 index 0000000..36600b2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/prfchiintrin.h @@ -0,0 +1,61 @@ +/*===---- prfchiintrin.h - PREFETCHI intrinsic -----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __PRFCHIINTRIN_H +#define __PRFCHIINTRIN_H + +#ifdef __x86_64__ + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("prefetchi"))) + +/// Loads an instruction sequence containing the specified memory address into +/// all level cache. +/// +/// Note that the effect of this intrinsic is dependent on the processor +/// implementation. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PREFETCHIT0 instruction. +/// +/// \param __P +/// A pointer specifying the memory address to be prefetched. +static __inline__ void __DEFAULT_FN_ATTRS +_m_prefetchit0(volatile const void *__P) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" + __builtin_ia32_prefetchi((const void *)__P, 3 /* _MM_HINT_T0 */); +#pragma clang diagnostic pop +} + +/// Loads an instruction sequence containing the specified memory address into +/// all but the first-level cache. +/// +/// Note that the effect of this intrinsic is dependent on the processor +/// implementation. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PREFETCHIT1 instruction. +/// +/// \param __P +/// A pointer specifying the memory address to be prefetched. +static __inline__ void __DEFAULT_FN_ATTRS +_m_prefetchit1(volatile const void *__P) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" + __builtin_ia32_prefetchi((const void *)__P, 2 /* _MM_HINT_T1 */); +#pragma clang diagnostic pop +} +#endif /* __x86_64__ */ +#undef __DEFAULT_FN_ATTRS + +#endif /* __PRFCHWINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/prfchwintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/prfchwintrin.h new file mode 100755 index 0000000..8ec55d7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/prfchwintrin.h @@ -0,0 +1,57 @@ +/*===---- prfchwintrin.h - PREFETCHW intrinsic -----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined(__X86INTRIN_H) && !defined(_MM3DNOW_H_INCLUDED) +#error "Never use directly; include instead." +#endif + +#ifndef __PRFCHWINTRIN_H +#define __PRFCHWINTRIN_H + +#if defined(__cplusplus) +extern "C" { +#endif + +/// Loads a memory sequence containing the specified memory address into +/// all data cache levels. +/// +/// The cache-coherency state is set to exclusive. Data can be read from +/// and written to the cache line without additional delay. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PREFETCHT0 instruction. +/// +/// \param __P +/// A pointer specifying the memory address to be prefetched. +void _m_prefetch(void *__P); + +/// Loads a memory sequence containing the specified memory address into +/// the L1 data cache and sets the cache-coherency state to modified. +/// +/// This provides a hint to the processor that the cache line will be +/// modified. It is intended for use when the cache line will be written to +/// shortly after the prefetch is performed. +/// +/// Note that the effect of this intrinsic is dependent on the processor +/// implementation. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PREFETCHW instruction. +/// +/// \param __P +/// A pointer specifying the memory address to be prefetched. +void _m_prefetchw(volatile const void *__P); + +#if defined(__cplusplus) +} // extern "C" +#endif + +#endif /* __PRFCHWINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ptrauth.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ptrauth.h new file mode 100755 index 0000000..f902ca1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ptrauth.h @@ -0,0 +1,393 @@ +/*===---- ptrauth.h - Pointer authentication -------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __PTRAUTH_H +#define __PTRAUTH_H + +typedef enum { + ptrauth_key_asia = 0, + ptrauth_key_asib = 1, + ptrauth_key_asda = 2, + ptrauth_key_asdb = 3, + + /* A process-independent key which can be used to sign code pointers. */ + ptrauth_key_process_independent_code = ptrauth_key_asia, + + /* A process-specific key which can be used to sign code pointers. */ + ptrauth_key_process_dependent_code = ptrauth_key_asib, + + /* A process-independent key which can be used to sign data pointers. */ + ptrauth_key_process_independent_data = ptrauth_key_asda, + + /* A process-specific key which can be used to sign data pointers. */ + ptrauth_key_process_dependent_data = ptrauth_key_asdb, + + /* The key used to sign return addresses on the stack. + The extra data is based on the storage address of the return address. + On AArch64, that is always the storage address of the return address + 8 + (or, in other words, the value of the stack pointer on function entry) */ + ptrauth_key_return_address = ptrauth_key_process_dependent_code, + + /* The key used to sign C function pointers. + The extra data is always 0. */ + ptrauth_key_function_pointer = ptrauth_key_process_independent_code, + + /* The key used to sign C++ v-table pointers. + The extra data is always 0. */ + ptrauth_key_cxx_vtable_pointer = ptrauth_key_process_independent_data, + + /* The key used to sign metadata pointers to Objective-C method-lists. */ + ptrauth_key_method_list_pointer = ptrauth_key_asda, + + /* The key used to sign Objective-C isa and super pointers. */ + ptrauth_key_objc_isa_pointer = ptrauth_key_process_independent_data, + ptrauth_key_objc_super_pointer = ptrauth_key_process_independent_data, + + /* The key used to sign selector pointers */ + ptrauth_key_objc_sel_pointer = ptrauth_key_process_dependent_data, + + /* The key used to sign Objective-C class_ro_t pointers. */ + ptrauth_key_objc_class_ro_pointer = ptrauth_key_process_independent_data, + + /* The key used to sign pointers in ELF .init_array/.fini_array. */ + ptrauth_key_init_fini_pointer = ptrauth_key_process_independent_code, + + /* Other pointers signed under the ABI use private ABI rules. */ + +} ptrauth_key; + +/* An integer type of the appropriate size for a discriminator argument. */ +typedef __UINTPTR_TYPE__ ptrauth_extra_data_t; + +/* An integer type of the appropriate size for a generic signature. */ +typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t; + +/* A signed pointer value embeds the original pointer together with + a signature that attests to the validity of that pointer. Because + this signature must use only "spare" bits of the pointer, a + signature's validity is probabilistic in practice: it is unlikely + but still plausible that an invalidly-derived signature will + somehow equal the correct signature and therefore successfully + authenticate. Nonetheless, this scheme provides a strong degree + of protection against certain kinds of attacks. */ + +/* Authenticating a pointer that was not signed with the given key + and extra-data value will (likely) fail by trapping. */ + +/* The null function pointer is always the all-zero bit pattern. + Signing an all-zero bit pattern will embed a (likely) non-zero + signature in the result, and so the result will not seem to be + a null function pointer. Authenticating this value will yield + a null function pointer back. However, authenticating an + all-zero bit pattern will probably fail, because the + authentication will expect a (likely) non-zero signature to + embedded in the value. + + Because of this, if a pointer may validly be null, you should + check for null before attempting to authenticate it with one + of these intrinsics. This is not necessary when using the + __ptrauth qualifier; the compiler will perform this check + automatically. */ + +#if __has_feature(ptrauth_intrinsics) || defined(__PTRAUTH__) + +/* Strip the signature from a value without authenticating it. + + If the value is a function pointer, the result will not be a + legal function pointer because of the missing signature, and + attempting to call it will result in an authentication failure. + + The value must be an expression of pointer type. + The key must be a constant expression of type ptrauth_key. + The result will have the same type as the original value. */ +#define ptrauth_strip(__value, __key) __builtin_ptrauth_strip(__value, __key) + +/* Blend a constant discriminator into the given pointer-like value + to form a new discriminator. Not all bits of the inputs are + guaranteed to contribute to the result. + + On arm64e, the integer must fall within the range of a uint16_t; + other bits may be ignored. + + For the purposes of ptrauth_sign_constant, the result of calling + this function is considered a constant expression if the arguments + are constant. Some restrictions may be imposed on the pointer. + + The first argument must be an expression of pointer type. + The second argument must be an expression of integer type. + The result will have type uintptr_t. */ +#define ptrauth_blend_discriminator(__pointer, __integer) \ + __builtin_ptrauth_blend_discriminator(__pointer, __integer) + +/* Return a signed pointer for a constant address in a manner which guarantees + a non-attackable sequence. + + The value must be a constant expression of pointer type which evaluates to + a non-null pointer. + The key must be a constant expression of type ptrauth_key. + The extra data must be a constant expression of pointer or integer type; + if an integer, it will be coerced to ptrauth_extra_data_t. + The result will have the same type as the original value. + + This can be used in constant expressions. */ +#define ptrauth_sign_constant(__value, __key, __data) \ + __builtin_ptrauth_sign_constant(__value, __key, __data) + +/* Add a signature to the given pointer value using a specific key, + using the given extra data as a salt to the signing process. + + This operation does not authenticate the original value and is + therefore potentially insecure if an attacker could possibly + control that value. + + The value must be an expression of pointer type. + The key must be a constant expression of type ptrauth_key. + The extra data must be an expression of pointer or integer type; + if an integer, it will be coerced to ptrauth_extra_data_t. + The result will have the same type as the original value. */ +#define ptrauth_sign_unauthenticated(__value, __key, __data) \ + __builtin_ptrauth_sign_unauthenticated(__value, __key, __data) + +/* Authenticate a pointer using one scheme and resign it using another. + + If the result is subsequently authenticated using the new scheme, that + authentication is guaranteed to fail if and only if the initial + authentication failed. + + The value must be an expression of pointer type. + The key must be a constant expression of type ptrauth_key. + The extra data must be an expression of pointer or integer type; + if an integer, it will be coerced to ptrauth_extra_data_t. + The result will have the same type as the original value. + + This operation is guaranteed to not leave the intermediate value + available for attack before it is re-signed. + + Do not pass a null pointer to this function. A null pointer + will not successfully authenticate. + + This operation traps if the authentication fails. */ +#define ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, \ + __new_data) \ + __builtin_ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, \ + __new_data) + +/* Authenticate a pointer using one scheme and resign it as a C + function pointer. + + If the result is subsequently authenticated using the new scheme, that + authentication is guaranteed to fail if and only if the initial + authentication failed. + + The value must be an expression of function pointer type. + The key must be a constant expression of type ptrauth_key. + The extra data must be an expression of pointer or integer type; + if an integer, it will be coerced to ptrauth_extra_data_t. + The result will have the same type as the original value. + + This operation is guaranteed to not leave the intermediate value + available for attack before it is re-signed. Additionally, if this + expression is used syntactically as the function expression in a + call, only a single authentication will be performed. */ +#define ptrauth_auth_function(__value, __old_key, __old_data) \ + ptrauth_auth_and_resign(__value, __old_key, __old_data, \ + ptrauth_key_function_pointer, 0) + +/* Authenticate a data pointer. + + The value must be an expression of non-function pointer type. + The key must be a constant expression of type ptrauth_key. + The extra data must be an expression of pointer or integer type; + if an integer, it will be coerced to ptrauth_extra_data_t. + The result will have the same type as the original value. + + This operation traps if the authentication fails. */ +#define ptrauth_auth_data(__value, __old_key, __old_data) \ + __builtin_ptrauth_auth(__value, __old_key, __old_data) + +/* Compute a constant discriminator from the given string. + + The argument must be a string literal of char character type. The result + has type ptrauth_extra_data_t. + + The result value is never zero and always within range for both the + __ptrauth qualifier and ptrauth_blend_discriminator. + + This can be used in constant expressions. +*/ +#define ptrauth_string_discriminator(__string) \ + __builtin_ptrauth_string_discriminator(__string) + +/* Compute a constant discriminator from the given type. + + The result can be used as the second argument to + ptrauth_blend_discriminator or the third argument to the + __ptrauth qualifier. It has type size_t. + + If the type is a C++ member function pointer type, the result is + the discriminator used to signed member function pointers of that + type. If the type is a function, function pointer, or function + reference type, the result is the discriminator used to sign + functions of that type. It is ill-formed to use this macro with any + other type. + + A call to this function is an integer constant expression. */ +#define ptrauth_type_discriminator(__type) \ + __builtin_ptrauth_type_discriminator(__type) + +/* Compute a signature for the given pair of pointer-sized values. + The order of the arguments is significant. + + Like a pointer signature, the resulting signature depends on + private key data and therefore should not be reliably reproducible + by attackers. That means that this can be used to validate the + integrity of arbitrary data by storing a signature for that data + alongside it, then checking that the signature is still valid later. + Data which exceeds two pointers in size can be signed by either + computing a tree of generic signatures or just signing an ordinary + cryptographic hash of the data. + + The result has type ptrauth_generic_signature_t. However, it may + not have as many bits of entropy as that type's width would suggest; + some implementations are known to compute a compressed signature as + if the arguments were a pointer and a discriminator. + + The arguments must be either pointers or integers; if integers, they + will be coerce to uintptr_t. */ +#define ptrauth_sign_generic_data(__value, __data) \ + __builtin_ptrauth_sign_generic_data(__value, __data) + +/* C++ vtable pointer signing class attribute */ +#define ptrauth_cxx_vtable_pointer(key, address_discrimination, \ + extra_discrimination...) \ + [[clang::ptrauth_vtable_pointer(key, address_discrimination, \ + extra_discrimination)]] + +/* The value is ptrauth_string_discriminator("init_fini") */ +#define __ptrauth_init_fini_discriminator 0xd9d4 + +/* Objective-C pointer auth ABI qualifiers */ +#define __ptrauth_objc_method_list_imp \ + __ptrauth(ptrauth_key_function_pointer, 1, 0) + +#if __has_feature(ptrauth_objc_method_list_pointer) +#define __ptrauth_objc_method_list_pointer \ + __ptrauth(ptrauth_key_method_list_pointer, 1, 0xC310) +#else +#define __ptrauth_objc_method_list_pointer +#endif + +#define __ptrauth_isa_discriminator 0x6AE1 +#define __ptrauth_super_discriminator 0xB5AB +#define __ptrauth_objc_isa_pointer \ + __ptrauth(ptrauth_key_objc_isa_pointer, 1, __ptrauth_isa_discriminator) +#if __has_feature(ptrauth_restricted_intptr_qualifier) +#define __ptrauth_objc_isa_uintptr \ + __ptrauth_restricted_intptr(ptrauth_key_objc_isa_pointer, 1, \ + __ptrauth_isa_discriminator) +#else +#define __ptrauth_objc_isa_uintptr \ + __ptrauth(ptrauth_key_objc_isa_pointer, 1, __ptrauth_isa_discriminator) +#endif + +#define __ptrauth_objc_super_pointer \ + __ptrauth(ptrauth_key_objc_super_pointer, 1, __ptrauth_super_discriminator) + +#define __ptrauth_objc_sel_discriminator 0x57c2 +#if __has_feature(ptrauth_objc_interface_sel) +#define __ptrauth_objc_sel \ + __ptrauth(ptrauth_key_objc_sel_pointer, 1, __ptrauth_objc_sel_discriminator) +#else +#define __ptrauth_objc_sel +#endif + +#define __ptrauth_objc_class_ro_discriminator 0x61f8 +#define __ptrauth_objc_class_ro \ + __ptrauth(ptrauth_key_objc_class_ro_pointer, 1, \ + __ptrauth_objc_class_ro_discriminator) + +#else + +#define ptrauth_strip(__value, __key) \ + ({ \ + (void)__key; \ + __value; \ + }) + +#define ptrauth_blend_discriminator(__pointer, __integer) \ + ({ \ + (void)__pointer; \ + (void)__integer; \ + ((ptrauth_extra_data_t)0); \ + }) + +#define ptrauth_sign_constant(__value, __key, __data) \ + ({ \ + (void)__key; \ + (void)__data; \ + __value; \ + }) + +#define ptrauth_sign_unauthenticated(__value, __key, __data) \ + ({ \ + (void)__key; \ + (void)__data; \ + __value; \ + }) + +#define ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, \ + __new_data) \ + ({ \ + (void)__old_key; \ + (void)__old_data; \ + (void)__new_key; \ + (void)__new_data; \ + __value; \ + }) + +#define ptrauth_auth_function(__value, __old_key, __old_data) \ + ({ \ + (void)__old_key; \ + (void)__old_data; \ + __value; \ + }) + +#define ptrauth_auth_data(__value, __old_key, __old_data) \ + ({ \ + (void)__old_key; \ + (void)__old_data; \ + __value; \ + }) + +#define ptrauth_string_discriminator(__string) \ + ({ \ + (void)__string; \ + ((ptrauth_extra_data_t)0); \ + }) + +#define ptrauth_type_discriminator(__type) ((ptrauth_extra_data_t)0) + +#define ptrauth_sign_generic_data(__value, __data) \ + ({ \ + (void)__value; \ + (void)__data; \ + ((ptrauth_generic_signature_t)0); \ + }) + + +#define ptrauth_cxx_vtable_pointer(key, address_discrimination, \ + extra_discrimination...) + +#define __ptrauth_objc_isa_pointer +#define __ptrauth_objc_isa_uintptr +#define __ptrauth_objc_super_pointer + +#endif /* __has_feature(ptrauth_intrinsics) || defined(__PTRAUTH__) */ + +#endif /* __PTRAUTH_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ptwriteintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ptwriteintrin.h new file mode 100755 index 0000000..0a04f7c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/ptwriteintrin.h @@ -0,0 +1,37 @@ +/*===------------ ptwriteintrin.h - PTWRITE intrinsic --------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PTWRITEINTRIN_H +#define __PTWRITEINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("ptwrite"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_ptwrite32(unsigned int __value) { + __builtin_ia32_ptwrite32(__value); +} + +#ifdef __x86_64__ + +static __inline__ void __DEFAULT_FN_ATTRS +_ptwrite64(unsigned long long __value) { + __builtin_ia32_ptwrite64(__value); +} + +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __PTWRITEINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/raointintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/raointintrin.h new file mode 100755 index 0000000..d3290eb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/raointintrin.h @@ -0,0 +1,203 @@ +/*===----------------------- raointintrin.h - RAOINT ------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86GPRINTRIN_H +#error "Never use directly; include instead." +#endif // __X86GPRINTRIN_H + +#ifndef __RAOINTINTRIN_H +#define __RAOINTINTRIN_H + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("raoint"))) + +/// Atomically add a 32-bit value at memory operand \a __A and a 32-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AADD instruction. +/// +/// \param __A +/// A pointer to a 32-bit memory location. +/// \param __B +/// A 32-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+31:__A] := MEM[__A+31:__A] + __B[31:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _aadd_i32(int *__A, int __B) { + __builtin_ia32_aadd32((int *)__A, __B); +} + +/// Atomically and a 32-bit value at memory operand \a __A and a 32-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AAND instruction. +/// +/// \param __A +/// A pointer to a 32-bit memory location. +/// \param __B +/// A 32-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+31:__A] := MEM[__A+31:__A] AND __B[31:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _aand_i32(int *__A, int __B) { + __builtin_ia32_aand32((int *)__A, __B); +} + +/// Atomically or a 32-bit value at memory operand \a __A and a 32-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AOR instruction. +/// +/// \param __A +/// A pointer to a 32-bit memory location. +/// \param __B +/// A 32-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+31:__A] := MEM[__A+31:__A] OR __B[31:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _aor_i32(int *__A, int __B) { + __builtin_ia32_aor32((int *)__A, __B); +} + +/// Atomically xor a 32-bit value at memory operand \a __A and a 32-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AXOR instruction. +/// +/// \param __A +/// A pointer to a 32-bit memory location. +/// \param __B +/// A 32-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+31:__A] := MEM[__A+31:__A] XOR __B[31:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _axor_i32(int *__A, int __B) { + __builtin_ia32_axor32((int *)__A, __B); +} + +#ifdef __x86_64__ +/// Atomically add a 64-bit value at memory operand \a __A and a 64-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AADD instruction. +/// +/// \param __A +/// A pointer to a 64-bit memory location. +/// \param __B +/// A 64-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+63:__A] := MEM[__A+63:__A] + __B[63:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _aadd_i64(long long *__A, + long long __B) { + __builtin_ia32_aadd64((long long *)__A, __B); +} + +/// Atomically and a 64-bit value at memory operand \a __A and a 64-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AAND instruction. +/// +/// \param __A +/// A pointer to a 64-bit memory location. +/// \param __B +/// A 64-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+63:__A] := MEM[__A+63:__A] AND __B[63:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _aand_i64(long long *__A, + long long __B) { + __builtin_ia32_aand64((long long *)__A, __B); +} + +/// Atomically or a 64-bit value at memory operand \a __A and a 64-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AOR instruction. +/// +/// \param __A +/// A pointer to a 64-bit memory location. +/// \param __B +/// A 64-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+63:__A] := MEM[__A+63:__A] OR __B[63:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _aor_i64(long long *__A, + long long __B) { + __builtin_ia32_aor64((long long *)__A, __B); +} + +/// Atomically xor a 64-bit value at memory operand \a __A and a 64-bit \a __B, +/// and store the result to the same memory location. +/// +/// This intrinsic should be used for contention or weak ordering. It may +/// result in bad performance for hot data used by single thread only. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c AXOR instruction. +/// +/// \param __A +/// A pointer to a 64-bit memory location. +/// \param __B +/// A 64-bit integer value. +/// +/// \code{.operation} +/// MEM[__A+63:__A] := MEM[__A+63:__A] XOR __B[63:0] +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS _axor_i64(long long *__A, + long long __B) { + __builtin_ia32_axor64((long long *)__A, __B); +} +#endif // __x86_64__ + +#undef __DEFAULT_FN_ATTRS +#endif // __RAOINTINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rdpruintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rdpruintrin.h new file mode 100755 index 0000000..89732bb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rdpruintrin.h @@ -0,0 +1,57 @@ +/*===---- rdpruintrin.h - RDPRU intrinsics ---------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __RDPRUINTRIN_H +#define __RDPRUINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("rdpru"))) + + +/// Reads the content of a processor register. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the RDPRU instruction. +/// +/// \param reg_id +/// A processor register identifier. +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__rdpru (int reg_id) +{ + return __builtin_ia32_rdpru(reg_id); +} + +#define __RDPRU_MPERF 0 +#define __RDPRU_APERF 1 + +/// Reads the content of processor register MPERF. +/// +/// \headerfile +/// +/// This intrinsic generates instruction RDPRU to read the value of +/// register MPERF. +#define __mperf() __builtin_ia32_rdpru(__RDPRU_MPERF) + +/// Reads the content of processor register APERF. +/// +/// \headerfile +/// +/// This intrinsic generates instruction RDPRU to read the value of +/// register APERF. +#define __aperf() __builtin_ia32_rdpru(__RDPRU_APERF) + +#undef __DEFAULT_FN_ATTRS + +#endif /* __RDPRUINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rdseedintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rdseedintrin.h new file mode 100755 index 0000000..8a4fe09 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rdseedintrin.h @@ -0,0 +1,105 @@ +/*===---- rdseedintrin.h - RDSEED intrinsics -------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __RDSEEDINTRIN_H +#define __RDSEEDINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("rdseed"))) + +/// Stores a hardware-generated 16-bit random value in the memory at \a __p. +/// +/// The random number generator complies with NIST SP800-90B and SP800-90C. +/// +/// \code{.operation} +/// IF HW_NRND_GEN.ready == 1 +/// Store16(__p, HW_NRND_GEN.data) +/// result := 1 +/// ELSE +/// Store16(__p, 0) +/// result := 0 +/// END +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c RDSEED instruction. +/// +/// \param __p +/// Pointer to memory for storing the 16-bit random number. +/// \returns 1 if a random number was generated, 0 if not. +static __inline__ int __DEFAULT_FN_ATTRS +_rdseed16_step(unsigned short *__p) +{ + return (int) __builtin_ia32_rdseed16_step(__p); +} + +/// Stores a hardware-generated 32-bit random value in the memory at \a __p. +/// +/// The random number generator complies with NIST SP800-90B and SP800-90C. +/// +/// \code{.operation} +/// IF HW_NRND_GEN.ready == 1 +/// Store32(__p, HW_NRND_GEN.data) +/// result := 1 +/// ELSE +/// Store32(__p, 0) +/// result := 0 +/// END +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c RDSEED instruction. +/// +/// \param __p +/// Pointer to memory for storing the 32-bit random number. +/// \returns 1 if a random number was generated, 0 if not. +static __inline__ int __DEFAULT_FN_ATTRS +_rdseed32_step(unsigned int *__p) +{ + return (int) __builtin_ia32_rdseed32_step(__p); +} + +#ifdef __x86_64__ +/// Stores a hardware-generated 64-bit random value in the memory at \a __p. +/// +/// The random number generator complies with NIST SP800-90B and SP800-90C. +/// +/// \code{.operation} +/// IF HW_NRND_GEN.ready == 1 +/// Store64(__p, HW_NRND_GEN.data) +/// result := 1 +/// ELSE +/// Store64(__p, 0) +/// result := 0 +/// END +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c RDSEED instruction. +/// +/// \param __p +/// Pointer to memory for storing the 64-bit random number. +/// \returns 1 if a random number was generated, 0 if not. +static __inline__ int __DEFAULT_FN_ATTRS +_rdseed64_step(unsigned long long *__p) +{ + return (int) __builtin_ia32_rdseed64_step(__p); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif /* __RDSEEDINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_bitmanip.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_bitmanip.h new file mode 100755 index 0000000..2bc7ee0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_bitmanip.h @@ -0,0 +1,195 @@ +/*===---- riscv_bitmanip.h - RISC-V Zb* intrinsics --------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __RISCV_BITMANIP_H +#define __RISCV_BITMANIP_H + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(__riscv_zbb) +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_orc_b_32(uint32_t __x) { + return __builtin_riscv_orc_b_32(__x); +} + +static __inline__ unsigned __attribute__((__always_inline__, __nodebug__)) +__riscv_clz_32(uint32_t __x) { + return __builtin_riscv_clz_32(__x); +} + +static __inline__ unsigned __attribute__((__always_inline__, __nodebug__)) +__riscv_ctz_32(uint32_t __x) { + return __builtin_riscv_ctz_32(__x); +} + +static __inline__ unsigned __attribute__((__always_inline__, __nodebug__)) +__riscv_cpop_32(uint32_t __x) { + return __builtin_popcount(__x); +} + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_orc_b_64(uint64_t __x) { + return __builtin_riscv_orc_b_64(__x); +} + +static __inline__ unsigned __attribute__((__always_inline__, __nodebug__)) +__riscv_clz_64(uint64_t __x) { + return __builtin_riscv_clz_64(__x); +} + +static __inline__ unsigned __attribute__((__always_inline__, __nodebug__)) +__riscv_ctz_64(uint64_t __x) { + return __builtin_riscv_ctz_64(__x); +} + +static __inline__ unsigned __attribute__((__always_inline__, __nodebug__)) +__riscv_cpop_64(uint64_t __x) { + return __builtin_popcountll(__x); +} +#endif +#endif // defined(__riscv_zbb) + +#if defined(__riscv_zbb) || defined(__riscv_zbkb) +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_rev8_32(uint32_t __x) { + return __builtin_bswap32(__x); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_rol_32(uint32_t __x, uint32_t __y) { + return __builtin_rotateleft32(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_ror_32(uint32_t __x, uint32_t __y) { + return __builtin_rotateright32(__x, __y); +} + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_rev8_64(uint64_t __x) { + return __builtin_bswap64(__x); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_rol_64(uint64_t __x, uint32_t __y) { + return __builtin_rotateleft64(__x, __y); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_ror_64(uint64_t __x, uint32_t __y) { + return __builtin_rotateright64(__x, __y); +} +#endif +#endif // defined(__riscv_zbb) || defined(__riscv_zbkb) + +#if defined(__riscv_zbkb) +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_brev8_32(uint32_t __x) { + return __builtin_riscv_brev8_32(__x); +} + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_brev8_64(uint64_t __x) { + return __builtin_riscv_brev8_64(__x); +} +#endif + +#if __riscv_xlen == 32 +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_unzip_32(uint32_t __x) { + return __builtin_riscv_unzip_32(__x); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_zip_32(uint32_t __x) { + return __builtin_riscv_zip_32(__x); +} +#endif +#endif // defined(__riscv_zbkb) + +#if defined(__riscv_zbc) +#if __riscv_xlen == 32 +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_clmulr_32(uint32_t __x, uint32_t __y) { + return __builtin_riscv_clmulr_32(__x, __y); +} +#endif + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_clmulr_64(uint64_t __x, uint64_t __y) { + return __builtin_riscv_clmulr_64(__x, __y); +} +#endif +#endif // defined(__riscv_zbc) + +#if defined(__riscv_zbkc) || defined(__riscv_zbc) +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_clmul_32(uint32_t __x, uint32_t __y) { + return __builtin_riscv_clmul_32(__x, __y); +} + +#if __riscv_xlen == 32 +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_clmulh_32(uint32_t __x, uint32_t __y) { + return __builtin_riscv_clmulh_32(__x, __y); +} +#endif + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_clmul_64(uint64_t __x, uint64_t __y) { + return __builtin_riscv_clmul_64(__x, __y); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_clmulh_64(uint64_t __x, uint64_t __y) { + return __builtin_riscv_clmulh_64(__x, __y); +} +#endif +#endif // defined(__riscv_zbkc) || defined(__riscv_zbc) + +#if defined(__riscv_zbkx) +#if __riscv_xlen == 32 +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_xperm4_32(uint32_t __x, uint32_t __y) { + return __builtin_riscv_xperm4_32(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_xperm8_32(uint32_t __x, uint32_t __y) { + return __builtin_riscv_xperm8_32(__x, __y); +} +#endif + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_xperm4_64(uint64_t __x, uint64_t __y) { + return __builtin_riscv_xperm4_64(__x, __y); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_xperm8_64(uint64_t __x, uint64_t __y) { + return __builtin_riscv_xperm8_64(__x, __y); +} +#endif +#endif // defined(__riscv_zbkx) + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_corev_alu.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_corev_alu.h new file mode 100755 index 0000000..84f4d08 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_corev_alu.h @@ -0,0 +1,128 @@ +/*===---- riscv_corev_alu.h - CORE-V ALU intrinsics ------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __RISCV_COREV_ALU_H +#define __RISCV_COREV_ALU_H + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(__riscv_xcvalu) + +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_abs(long a) { + return __builtin_abs(a); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_sle(long a, long b) { + return __builtin_riscv_cv_alu_sle(a, b); +} + +static __inline__ long __DEFAULT_FN_ATTRS +__riscv_cv_alu_sleu(unsigned long a, unsigned long b) { + return __builtin_riscv_cv_alu_sleu(a, b); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_min(long a, long b) { + return __builtin_elementwise_min(a, b); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_minu(unsigned long a, unsigned long b) { + return __builtin_elementwise_min(a, b); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_max(long a, long b) { + return __builtin_elementwise_max(a, b); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_maxu(unsigned long a, unsigned long b) { + return __builtin_elementwise_max(a, b); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_exths(int16_t a) { + return __builtin_riscv_cv_alu_exths(a); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_exthz(uint16_t a) { + return __builtin_riscv_cv_alu_exthz(a); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_extbs(int8_t a) { + return __builtin_riscv_cv_alu_extbs(a); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_extbz(uint8_t a) { + return __builtin_riscv_cv_alu_extbz(a); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_clip(long a, + unsigned long b) { + return __builtin_riscv_cv_alu_clip(a, b); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_clipu(unsigned long a, unsigned long b) { + return __builtin_riscv_cv_alu_clipu(a, b); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addN(long a, long b, + uint8_t shft) { + return __builtin_riscv_cv_alu_addN(a, b, shft); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_adduN(unsigned long a, unsigned long b, uint8_t shft) { + return __builtin_riscv_cv_alu_adduN(a, b, shft); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addRN(long a, long b, + uint8_t shft) { + return __builtin_riscv_cv_alu_addRN(a, b, shft); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_adduRN(unsigned long a, unsigned long b, uint8_t shft) { + return __builtin_riscv_cv_alu_adduRN(a, b, shft); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subN(long a, long b, + uint8_t shft) { + return __builtin_riscv_cv_alu_subN(a, b, shft); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_subuN(unsigned long a, unsigned long b, uint8_t shft) { + return __builtin_riscv_cv_alu_subuN(a, b, shft); +} + +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subRN(long a, long b, + uint8_t shft) { + return __builtin_riscv_cv_alu_subRN(a, b, shft); +} + +static __inline__ unsigned long __DEFAULT_FN_ATTRS +__riscv_cv_alu_subuRN(unsigned long a, unsigned long b, uint8_t shft) { + return __builtin_riscv_cv_alu_subuRN(a, b, shft); +} + +#endif // defined(__riscv_xcvalu) + +#if defined(__cplusplus) +} +#endif + +#endif // define __RISCV_COREV_ALU_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_crypto.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_crypto.h new file mode 100755 index 0000000..7cd2a70 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_crypto.h @@ -0,0 +1,170 @@ +/*===---- riscv_crypto.h - RISC-V Zk* intrinsics ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __RISCV_CRYPTO_H +#define __RISCV_CRYPTO_H + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#if defined(__riscv_zknd) +#if __riscv_xlen == 32 +#define __riscv_aes32dsi(x, y, bs) __builtin_riscv_aes32dsi(x, y, bs) +#define __riscv_aes32dsmi(x, y, bs) __builtin_riscv_aes32dsmi(x, y, bs) +#endif + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_aes64ds(uint64_t __x, uint64_t __y) { + return __builtin_riscv_aes64ds(__x, __y); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_aes64dsm(uint64_t __x, uint64_t __y) { + return __builtin_riscv_aes64dsm(__x, __y); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_aes64im(uint64_t __x) { + return __builtin_riscv_aes64im(__x); +} +#endif +#endif // defined(__riscv_zknd) + +#if defined(__riscv_zkne) +#if __riscv_xlen == 32 +#define __riscv_aes32esi(x, y, bs) __builtin_riscv_aes32esi(x, y, bs) +#define __riscv_aes32esmi(x, y, bs) __builtin_riscv_aes32esmi(x, y, bs) +#endif + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_aes64es(uint64_t __x, uint64_t __y) { + return __builtin_riscv_aes64es(__x, __y); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_aes64esm(uint64_t __x, uint64_t __y) { + return __builtin_riscv_aes64esm(__x, __y); +} +#endif +#endif // defined(__riscv_zkne) + +#if defined(__riscv_zknd) || defined(__riscv_zkne) +#if __riscv_xlen == 64 +#define __riscv_aes64ks1i(x, rnum) __builtin_riscv_aes64ks1i(x, rnum) + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_aes64ks2(uint64_t __x, uint64_t __y) { + return __builtin_riscv_aes64ks2(__x, __y); +} +#endif +#endif // defined(__riscv_zknd) || defined(__riscv_zkne) + +#if defined(__riscv_zknh) +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha256sig0(uint32_t __x) { + return __builtin_riscv_sha256sig0(__x); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha256sig1(uint32_t __x) { + return __builtin_riscv_sha256sig1(__x); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha256sum0(uint32_t __x) { + return __builtin_riscv_sha256sum0(__x); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha256sum1(uint32_t __x) { + return __builtin_riscv_sha256sum1(__x); +} + +#if __riscv_xlen == 32 +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sig0h(uint32_t __x, uint32_t __y) { + return __builtin_riscv_sha512sig0h(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sig0l(uint32_t __x, uint32_t __y) { + return __builtin_riscv_sha512sig0l(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sig1h(uint32_t __x, uint32_t __y) { + return __builtin_riscv_sha512sig1h(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sig1l(uint32_t __x, uint32_t __y) { + return __builtin_riscv_sha512sig1l(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sum0r(uint32_t __x, uint32_t __y) { + return __builtin_riscv_sha512sum0r(__x, __y); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sum1r(uint32_t __x, uint32_t __y) { + return __builtin_riscv_sha512sum1r(__x, __y); +} +#endif + +#if __riscv_xlen == 64 +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sig0(uint64_t __x) { + return __builtin_riscv_sha512sig0(__x); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sig1(uint64_t __x) { + return __builtin_riscv_sha512sig1(__x); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sum0(uint64_t __x) { + return __builtin_riscv_sha512sum0(__x); +} + +static __inline__ uint64_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sha512sum1(uint64_t __x) { + return __builtin_riscv_sha512sum1(__x); +} +#endif +#endif // defined(__riscv_zknh) + +#if defined(__riscv_zksh) +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sm3p0(uint32_t __x) { + return __builtin_riscv_sm3p0(__x); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__riscv_sm3p1(uint32_t __x) { + return __builtin_riscv_sm3p1(__x); +} +#endif // defined(__riscv_zksh) + +#if defined(__riscv_zksed) +#define __riscv_sm4ed(x, y, bs) __builtin_riscv_sm4ed(x, y, bs); +#define __riscv_sm4ks(x, y, bs) __builtin_riscv_sm4ks(x, y, bs); +#endif // defined(__riscv_zksed) + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_ntlh.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_ntlh.h new file mode 100755 index 0000000..c92e580 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/riscv_ntlh.h @@ -0,0 +1,26 @@ +/*===---- riscv_ntlh.h - RISC-V NTLH intrinsics ----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __RISCV_NTLH_H +#define __RISCV_NTLH_H + +#ifndef __riscv_zihintntl +#error "NTLH intrinsics require the NTLH extension." +#endif + +enum { + __RISCV_NTLH_INNERMOST_PRIVATE = 2, + __RISCV_NTLH_ALL_PRIVATE, + __RISCV_NTLH_INNERMOST_SHARED, + __RISCV_NTLH_ALL +}; + +#define __riscv_ntl_load __builtin_riscv_ntl_load +#define __riscv_ntl_store __builtin_riscv_ntl_store +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rtmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rtmintrin.h new file mode 100755 index 0000000..a3ec81e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/rtmintrin.h @@ -0,0 +1,45 @@ +/*===---- rtmintrin.h - RTM intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __RTMINTRIN_H +#define __RTMINTRIN_H + +#define _XBEGIN_STARTED (~0u) +#define _XABORT_EXPLICIT (1 << 0) +#define _XABORT_RETRY (1 << 1) +#define _XABORT_CONFLICT (1 << 2) +#define _XABORT_CAPACITY (1 << 3) +#define _XABORT_DEBUG (1 << 4) +#define _XABORT_NESTED (1 << 5) +#define _XABORT_CODE(x) (((x) >> 24) & 0xFF) + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("rtm"))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +_xbegin(void) +{ + return (unsigned int)__builtin_ia32_xbegin(); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_xend(void) +{ + __builtin_ia32_xend(); +} + +#define _xabort(imm) __builtin_ia32_xabort((imm)) + +#undef __DEFAULT_FN_ATTRS + +#endif /* __RTMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/s390intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/s390intrin.h new file mode 100755 index 0000000..73a915c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/s390intrin.h @@ -0,0 +1,25 @@ +/*===---- s390intrin.h - SystemZ intrinsics --------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __S390INTRIN_H +#define __S390INTRIN_H + +#ifndef __s390__ +#error " is for s390 only" +#endif + +#ifdef __HTM__ +#include +#endif + +#ifdef __VEC__ +#include +#endif + +#endif /* __S390INTRIN_H*/ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/serializeintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/serializeintrin.h new file mode 100755 index 0000000..b774e5a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/serializeintrin.h @@ -0,0 +1,30 @@ +/*===--------------- serializeintrin.h - serialize intrinsics --------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __SERIALIZEINTRIN_H +#define __SERIALIZEINTRIN_H + +/// Serialize instruction fetch and execution. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the SERIALIZE instruction. +/// +static __inline__ void +__attribute__((__always_inline__, __nodebug__, __target__("serialize"))) +_serialize (void) +{ + __builtin_ia32_serialize (); +} + +#endif /* __SERIALIZEINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sgxintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sgxintrin.h new file mode 100755 index 0000000..303a21f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sgxintrin.h @@ -0,0 +1,60 @@ +/*===---- sgxintrin.h - X86 SGX intrinsics configuration -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __SGXINTRIN_H +#define __SGXINTRIN_H + +#if __has_extension(gnu_asm) + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sgx"))) + +static __inline unsigned int __DEFAULT_FN_ATTRS +_enclu_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) +{ + unsigned int __result; + __asm__ ("enclu" + : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) + : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) + : "cc"); + return __result; +} + +static __inline unsigned int __DEFAULT_FN_ATTRS +_encls_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) +{ + unsigned int __result; + __asm__ ("encls" + : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) + : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) + : "cc"); + return __result; +} + +static __inline unsigned int __DEFAULT_FN_ATTRS +_enclv_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) +{ + unsigned int __result; + __asm__ ("enclv" + : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) + : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) + : "cc"); + return __result; +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __has_extension(gnu_asm) */ + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sha512intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sha512intrin.h new file mode 100755 index 0000000..065ef5d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sha512intrin.h @@ -0,0 +1,200 @@ +/*===--------------- sha512intrin.h - SHA512 intrinsics -----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __SHA512INTRIN_H +#define __SHA512INTRIN_H + +#define __DEFAULT_FN_ATTRS256 \ + __attribute__((__always_inline__, __nodebug__, __target__("sha512"), \ + __min_vector_width__(256))) + +/// This intrinisc is one of the two SHA512 message scheduling instructions. +/// The intrinsic performs an intermediate calculation for the next four +/// SHA512 message qwords. The calculated results are stored in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_sha512msg1_epi64(__m256i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSHA512MSG1 instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x long long]. +/// \param __B +/// A 128-bit vector of [2 x long long]. +/// \returns +/// A 256-bit vector of [4 x long long]. +/// +/// \code{.operation} +/// DEFINE ROR64(qword, n) { +/// count := n % 64 +/// dest := (qword >> count) | (qword << (64 - count)) +/// RETURN dest +/// } +/// DEFINE SHR64(qword, n) { +/// RETURN qword >> n +/// } +/// DEFINE s0(qword): +/// RETURN ROR64(qword,1) ^ ROR64(qword, 8) ^ SHR64(qword, 7) +/// } +/// W[4] := __B.qword[0] +/// W[3] := __A.qword[3] +/// W[2] := __A.qword[2] +/// W[1] := __A.qword[1] +/// W[0] := __A.qword[0] +/// dst.qword[3] := W[3] + s0(W[4]) +/// dst.qword[2] := W[2] + s0(W[3]) +/// dst.qword[1] := W[1] + s0(W[2]) +/// dst.qword[0] := W[0] + s0(W[1]) +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sha512msg1_epi64(__m256i __A, __m128i __B) { + return (__m256i)__builtin_ia32_vsha512msg1((__v4du)__A, (__v2du)__B); +} + +/// This intrinisc is one of the two SHA512 message scheduling instructions. +/// The intrinsic performs the final calculation for the next four SHA512 +/// message qwords. The calculated results are stored in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_sha512msg2_epi64(__m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSHA512MSG2 instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x long long]. +/// \param __B +/// A 256-bit vector of [4 x long long]. +/// \returns +/// A 256-bit vector of [4 x long long]. +/// +/// \code{.operation} +/// DEFINE ROR64(qword, n) { +/// count := n % 64 +/// dest := (qword >> count) | (qword << (64 - count)) +/// RETURN dest +/// } +/// DEFINE SHR64(qword, n) { +/// RETURN qword >> n +/// } +/// DEFINE s1(qword) { +/// RETURN ROR64(qword,19) ^ ROR64(qword, 61) ^ SHR64(qword, 6) +/// } +/// W[14] := __B.qword[2] +/// W[15] := __B.qword[3] +/// W[16] := __A.qword[0] + s1(W[14]) +/// W[17] := __A.qword[1] + s1(W[15]) +/// W[18] := __A.qword[2] + s1(W[16]) +/// W[19] := __A.qword[3] + s1(W[17]) +/// dst.qword[3] := W[19] +/// dst.qword[2] := W[18] +/// dst.qword[1] := W[17] +/// dst.qword[0] := W[16] +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sha512msg2_epi64(__m256i __A, __m256i __B) { + return (__m256i)__builtin_ia32_vsha512msg2((__v4du)__A, (__v4du)__B); +} + +/// This intrinisc performs two rounds of SHA512 operation using initial SHA512 +/// state (C,D,G,H) from \a __A, an initial SHA512 state (A,B,E,F) from +/// \a __A, and a pre-computed sum of the next two round message qwords and +/// the corresponding round constants from \a __C (only the two lower qwords +/// of the third operand). The updated SHA512 state (A,B,E,F) is written to +/// \a __A, and \a __A can be used as the updated state (C,D,G,H) in later +/// rounds. +/// +/// \headerfile +/// +/// \code +/// __m256i _mm256_sha512rnds2_epi64(__m256i __A, __m256i __B, __m128i __C) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSHA512RNDS2 instruction. +/// +/// \param __A +/// A 256-bit vector of [4 x long long]. +/// \param __B +/// A 256-bit vector of [4 x long long]. +/// \param __C +/// A 128-bit vector of [2 x long long]. +/// \returns +/// A 256-bit vector of [4 x long long]. +/// +/// \code{.operation} +/// DEFINE ROR64(qword, n) { +/// count := n % 64 +/// dest := (qword >> count) | (qword << (64 - count)) +/// RETURN dest +/// } +/// DEFINE SHR64(qword, n) { +/// RETURN qword >> n +/// } +/// DEFINE cap_sigma0(qword) { +/// RETURN ROR64(qword,28) ^ ROR64(qword, 34) ^ ROR64(qword, 39) +/// } +/// DEFINE cap_sigma1(qword) { +/// RETURN ROR64(qword,14) ^ ROR64(qword, 18) ^ ROR64(qword, 41) +/// } +/// DEFINE MAJ(a,b,c) { +/// RETURN (a & b) ^ (a & c) ^ (b & c) +/// } +/// DEFINE CH(e,f,g) { +/// RETURN (e & f) ^ (g & ~e) +/// } +/// A[0] := __B.qword[3] +/// B[0] := __B.qword[2] +/// C[0] := __C.qword[3] +/// D[0] := __C.qword[2] +/// E[0] := __B.qword[1] +/// F[0] := __B.qword[0] +/// G[0] := __C.qword[1] +/// H[0] := __C.qword[0] +/// WK[0]:= __A.qword[0] +/// WK[1]:= __A.qword[1] +/// FOR i := 0 to 1: +/// A[i+1] := CH(E[i], F[i], G[i]) + +/// cap_sigma1(E[i]) + WK[i] + H[i] + +/// MAJ(A[i], B[i], C[i]) + +/// cap_sigma0(A[i]) +/// B[i+1] := A[i] +/// C[i+1] := B[i] +/// D[i+1] := C[i] +/// E[i+1] := CH(E[i], F[i], G[i]) + +/// cap_sigma1(E[i]) + WK[i] + H[i] + D[i] +/// F[i+1] := E[i] +/// G[i+1] := F[i] +/// H[i+1] := G[i] +/// ENDFOR +/// dst.qword[3] := A[2] +/// dst.qword[2] := B[2] +/// dst.qword[1] := E[2] +/// dst.qword[0] := F[2] +/// dst[MAX:256] := 0 +/// \endcode +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_sha512rnds2_epi64(__m256i __A, __m256i __B, __m128i __C) { + return (__m256i)__builtin_ia32_vsha512rnds2((__v4du)__A, (__v4du)__B, + (__v2du)__C); +} + +#undef __DEFAULT_FN_ATTRS256 + +#endif // __SHA512INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/shaintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/shaintrin.h new file mode 100755 index 0000000..e21d3bd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/shaintrin.h @@ -0,0 +1,190 @@ +/*===---- shaintrin.h - SHA intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __SHAINTRIN_H +#define __SHAINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sha"), __min_vector_width__(128))) + +/// Performs four iterations of the inner loop of the SHA-1 message digest +/// algorithm using the starting SHA-1 state (A, B, C, D) from the 128-bit +/// vector of [4 x i32] in \a V1 and the next four 32-bit elements of the +/// message from the 128-bit vector of [4 x i32] in \a V2. Note that the +/// SHA-1 state variable E must have already been added to \a V2 +/// (\c _mm_sha1nexte_epu32() can perform this step). Returns the updated +/// SHA-1 state (A, B, C, D) as a 128-bit vector of [4 x i32]. +/// +/// The SHA-1 algorithm has an inner loop of 80 iterations, twenty each +/// with a different combining function and rounding constant. This +/// intrinsic performs four iterations using a combining function and +/// rounding constant selected by \a M[1:0]. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_sha1rnds4_epu32(__m128i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the \c SHA1RNDS4 instruction. +/// +/// \param V1 +/// A 128-bit vector of [4 x i32] containing the initial SHA-1 state. +/// \param V2 +/// A 128-bit vector of [4 x i32] containing the next four elements of +/// the message, plus SHA-1 state variable E. +/// \param M +/// An immediate value where bits [1:0] select among four possible +/// combining functions and rounding constants (not specified here). +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 state. +#define _mm_sha1rnds4_epu32(V1, V2, M) \ + ((__m128i)__builtin_ia32_sha1rnds4((__v4si)(__m128i)(V1), \ + (__v4si)(__m128i)(V2), (M))) + +/// Calculates the SHA-1 state variable E from the SHA-1 state variables in +/// the 128-bit vector of [4 x i32] in \a __X, adds that to the next set of +/// four message elements in the 128-bit vector of [4 x i32] in \a __Y, and +/// returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1NEXTE instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] containing the current SHA-1 state. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing the next four elements of the +/// message. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 +/// values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha1nexte_epu32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_sha1nexte((__v4si)__X, (__v4si)__Y); +} + +/// Performs an intermediate calculation for deriving the next four SHA-1 +/// message elements using previous message elements from the 128-bit +/// vectors of [4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1MSG1 instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] containing previous message elements. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing previous message elements. +/// \returns A 128-bit vector of [4 x i32] containing the derived SHA-1 +/// elements. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha1msg1_epu32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_sha1msg1((__v4si)__X, (__v4si)__Y); +} + +/// Performs the final calculation for deriving the next four SHA-1 message +/// elements using previous message elements from the 128-bit vectors of +/// [4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA1MSG2 instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] containing an intermediate result. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing previous message values. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 +/// values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha1msg2_epu32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_sha1msg2((__v4si)__X, (__v4si)__Y); +} + +/// Performs two rounds of SHA-256 operation using the following inputs: a +/// starting SHA-256 state (C, D, G, H) from the 128-bit vector of +/// [4 x i32] in \a __X; a starting SHA-256 state (A, B, E, F) from the +/// 128-bit vector of [4 x i32] in \a __Y; and a pre-computed sum of the +/// next two message elements (unsigned 32-bit integers) and corresponding +/// rounding constants from the 128-bit vector of [4 x i32] in \a __Z. +/// Returns the updated SHA-256 state (A, B, E, F) as a 128-bit vector of +/// [4 x i32]. +/// +/// The SHA-256 algorithm has a core loop of 64 iterations. This intrinsic +/// performs two of those iterations. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA256RNDS2 instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] containing part of the initial SHA-256 +/// state. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing part of the initial SHA-256 +/// state. +/// \param __Z +/// A 128-bit vector of [4 x i32] containing additional input to the +/// SHA-256 operation. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-1 state. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha256rnds2_epu32(__m128i __X, __m128i __Y, __m128i __Z) +{ + return (__m128i)__builtin_ia32_sha256rnds2((__v4si)__X, (__v4si)__Y, (__v4si)__Z); +} + +/// Performs an intermediate calculation for deriving the next four SHA-256 +/// message elements using previous message elements from the 128-bit +/// vectors of [4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA256MSG1 instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] containing previous message elements. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing previous message elements. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-256 +/// values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha256msg1_epu32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_sha256msg1((__v4si)__X, (__v4si)__Y); +} + +/// Performs the final calculation for deriving the next four SHA-256 message +/// elements using previous message elements from the 128-bit vectors of +/// [4 x i32] in \a __X and \a __Y, and returns the result. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c SHA256MSG2 instruction. +/// +/// \param __X +/// A 128-bit vector of [4 x i32] containing an intermediate result. +/// \param __Y +/// A 128-bit vector of [4 x i32] containing previous message values. +/// \returns A 128-bit vector of [4 x i32] containing the updated SHA-256 +/// values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha256msg2_epu32(__m128i __X, __m128i __Y) +{ + return (__m128i)__builtin_ia32_sha256msg2((__v4si)__X, (__v4si)__Y); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __SHAINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sifive_vector.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sifive_vector.h new file mode 100755 index 0000000..4e67ad6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sifive_vector.h @@ -0,0 +1,118 @@ +//===----- sifive_vector.h - SiFive Vector definitions --------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _SIFIVE_VECTOR_H_ +#define _SIFIVE_VECTOR_H_ + +#include "riscv_vector.h" + +#pragma clang riscv intrinsic sifive_vector + +#define __riscv_sf_vc_x_se_u8mf4(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 6, vl) +#define __riscv_sf_vc_x_se_u8mf2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 7, vl) +#define __riscv_sf_vc_x_se_u8m1(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 0, vl) +#define __riscv_sf_vc_x_se_u8m2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 1, vl) +#define __riscv_sf_vc_x_se_u8m4(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 2, vl) +#define __riscv_sf_vc_x_se_u8m8(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 3, vl) + +#define __riscv_sf_vc_x_se_u16mf2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint16_t)rs1, 16, 7, vl) +#define __riscv_sf_vc_x_se_u16m1(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint16_t)rs1, 16, 0, vl) +#define __riscv_sf_vc_x_se_u16m2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint16_t)rs1, 16, 1, vl) +#define __riscv_sf_vc_x_se_u16m4(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint16_t)rs1, 16, 2, vl) +#define __riscv_sf_vc_x_se_u16m8(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint16_t)rs1, 16, 3, vl) + +#define __riscv_sf_vc_x_se_u32m1(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint32_t)rs1, 32, 0, vl) +#define __riscv_sf_vc_x_se_u32m2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint32_t)rs1, 32, 1, vl) +#define __riscv_sf_vc_x_se_u32m4(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint32_t)rs1, 32, 2, vl) +#define __riscv_sf_vc_x_se_u32m8(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint32_t)rs1, 32, 3, vl) + +#define __riscv_sf_vc_i_se_u8mf4(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 7, vl) +#define __riscv_sf_vc_i_se_u8mf2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 6, vl) +#define __riscv_sf_vc_i_se_u8m1(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 0, vl) +#define __riscv_sf_vc_i_se_u8m2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 1, vl) +#define __riscv_sf_vc_i_se_u8m4(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 2, vl) +#define __riscv_sf_vc_i_se_u8m8(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 3, vl) + +#define __riscv_sf_vc_i_se_u16mf2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 16, 7, vl) +#define __riscv_sf_vc_i_se_u16m1(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 16, 0, vl) +#define __riscv_sf_vc_i_se_u16m2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 16, 1, vl) +#define __riscv_sf_vc_i_se_u16m4(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 16, 2, vl) +#define __riscv_sf_vc_i_se_u16m8(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 16, 3, vl) + +#define __riscv_sf_vc_i_se_u32m1(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 32, 0, vl) +#define __riscv_sf_vc_i_se_u32m2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 32, 1, vl) +#define __riscv_sf_vc_i_se_u32m4(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 32, 2, vl) +#define __riscv_sf_vc_i_se_u32m8(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 32, 3, vl) + +#if __riscv_v_elen >= 64 +#define __riscv_sf_vc_x_se_u8mf8(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint8_t)rs1, 8, 5, vl) +#define __riscv_sf_vc_x_se_u16mf4(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint16_t)rs1, 16, 6, vl) +#define __riscv_sf_vc_x_se_u32mf2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint32_t)rs1, 32, 7, vl) + +#define __riscv_sf_vc_i_se_u8mf8(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 8, 5, vl) +#define __riscv_sf_vc_i_se_u16mf4(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 16, 6, vl) +#define __riscv_sf_vc_i_se_u32mf2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 32, 7, vl) + +#define __riscv_sf_vc_i_se_u64m1(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 64, 0, vl) +#define __riscv_sf_vc_i_se_u64m2(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 64, 1, vl) +#define __riscv_sf_vc_i_se_u64m4(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 64, 2, vl) +#define __riscv_sf_vc_i_se_u64m8(p27_26, p24_20, p11_7, simm5, vl) \ + __riscv_sf_vc_i_se(p27_26, p24_20, p11_7, simm5, 64, 3, vl) + +#if __riscv_xlen >= 64 +#define __riscv_sf_vc_x_se_u64m1(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint64_t)rs1, 64, 0, vl) +#define __riscv_sf_vc_x_se_u64m2(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint64_t)rs1, 64, 1, vl) +#define __riscv_sf_vc_x_se_u64m4(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint64_t)rs1, 64, 2, vl) +#define __riscv_sf_vc_x_se_u64m8(p27_26, p24_20, p11_7, rs1, vl) \ + __riscv_sf_vc_x_se(p27_26, p24_20, p11_7, (uint64_t)rs1, 64, 3, vl) +#endif +#endif + +#endif //_SIFIVE_VECTOR_H_ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm3intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm3intrin.h new file mode 100755 index 0000000..8a3d8bc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm3intrin.h @@ -0,0 +1,238 @@ +/*===-------------------- sm3intrin.h - SM3 intrinsics ---------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __SM3INTRIN_H +#define __SM3INTRIN_H + +#define __DEFAULT_FN_ATTRS128 \ + __attribute__((__always_inline__, __nodebug__, __target__("sm3"), \ + __min_vector_width__(128))) + +/// This intrinisc is one of the two SM3 message scheduling intrinsics. The +/// intrinsic performs an initial calculation for the next four SM3 message +/// words. The calculated results are stored in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_sm3msg1_epi32(__m128i __A, __m128i __B, __m128i __C) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSM3MSG1 instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x int]. +/// \param __B +/// A 128-bit vector of [4 x int]. +/// \param __C +/// A 128-bit vector of [4 x int]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32 - count)) +/// RETURN dest +/// } +/// DEFINE P1(x) { +/// RETURN x ^ ROL32(x, 15) ^ ROL32(x, 23) +/// } +/// W[0] := __C.dword[0] +/// W[1] := __C.dword[1] +/// W[2] := __C.dword[2] +/// W[3] := __C.dword[3] +/// W[7] := __A.dword[0] +/// W[8] := __A.dword[1] +/// W[9] := __A.dword[2] +/// W[10] := __A.dword[3] +/// W[13] := __B.dword[0] +/// W[14] := __B.dword[1] +/// W[15] := __B.dword[2] +/// TMP0 := W[7] ^ W[0] ^ ROL32(W[13], 15) +/// TMP1 := W[8] ^ W[1] ^ ROL32(W[14], 15) +/// TMP2 := W[9] ^ W[2] ^ ROL32(W[15], 15) +/// TMP3 := W[10] ^ W[3] +/// dst.dword[0] := P1(TMP0) +/// dst.dword[1] := P1(TMP1) +/// dst.dword[2] := P1(TMP2) +/// dst.dword[3] := P1(TMP3) +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_sm3msg1_epi32(__m128i __A, + __m128i __B, + __m128i __C) { + return (__m128i)__builtin_ia32_vsm3msg1((__v4su)__A, (__v4su)__B, + (__v4su)__C); +} + +/// This intrinisc is one of the two SM3 message scheduling intrinsics. The +/// intrinsic performs the final calculation for the next four SM3 message +/// words. The calculated results are stored in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_sm3msg2_epi32(__m128i __A, __m128i __B, __m128i __C) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSM3MSG2 instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x int]. +/// \param __B +/// A 128-bit vector of [4 x int]. +/// \param __C +/// A 128-bit vector of [4 x int]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32-count)) +/// RETURN dest +/// } +/// WTMP[0] := __A.dword[0] +/// WTMP[1] := __A.dword[1] +/// WTMP[2] := __A.dword[2] +/// WTMP[3] := __A.dword[3] +/// W[3] := __B.dword[0] +/// W[4] := __B.dword[1] +/// W[5] := __B.dword[2] +/// W[6] := __B.dword[3] +/// W[10] := __C.dword[0] +/// W[11] := __C.dword[1] +/// W[12] := __C.dword[2] +/// W[13] := __C.dword[3] +/// W[16] := ROL32(W[3], 7) ^ W[10] ^ WTMP[0] +/// W[17] := ROL32(W[4], 7) ^ W[11] ^ WTMP[1] +/// W[18] := ROL32(W[5], 7) ^ W[12] ^ WTMP[2] +/// W[19] := ROL32(W[6], 7) ^ W[13] ^ WTMP[3] +/// W[19] := W[19] ^ ROL32(W[16], 6) ^ ROL32(W[16], 15) ^ ROL32(W[16], 30) +/// dst.dword[0] := W[16] +/// dst.dword[1] := W[17] +/// dst.dword[2] := W[18] +/// dst.dword[3] := W[19] +/// dst[MAX:128] := 0 +/// \endcode +static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_sm3msg2_epi32(__m128i __A, + __m128i __B, + __m128i __C) { + return (__m128i)__builtin_ia32_vsm3msg2((__v4su)__A, (__v4su)__B, + (__v4su)__C); +} + +/// This intrinsic performs two rounds of SM3 operation using initial SM3 state +/// (C, D, G, H) from \a __A, an initial SM3 states (A, B, E, F) +/// from \a __B and a pre-computed words from the \a __C. \a __A with +/// initial SM3 state of (C, D, G, H) assumes input of non-rotated left +/// variables from previous state. The updated SM3 state (A, B, E, F) is +/// written to \a __A. The \a imm8 should contain the even round number +/// for the first of the two rounds computed by this instruction. The +/// computation masks the \a imm8 value by AND’ing it with 0x3E so that only +/// even round numbers from 0 through 62 are used for this operation. The +/// calculated results are stored in \a dst. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_sm3rnds2_epi32(__m128i __A, __m128i __B, __m128i __C, const int +/// imm8) \endcode +/// +/// This intrinsic corresponds to the \c VSM3RNDS2 instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x int]. +/// \param __B +/// A 128-bit vector of [4 x int]. +/// \param __C +/// A 128-bit vector of [4 x int]. +/// \param imm8 +/// A 8-bit constant integer. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32-count)) +/// RETURN dest +/// } +/// DEFINE P0(dword) { +/// RETURN dword ^ ROL32(dword, 9) ^ ROL32(dword, 17) +/// } +/// DEFINE FF(x,y,z, round){ +/// IF round < 16 +/// RETURN (x ^ y ^ z) +/// ELSE +/// RETURN (x & y) | (x & z) | (y & z) +/// FI +/// } +/// DEFINE GG(x, y, z, round){ +/// IF round < 16 +/// RETURN (x ^ y ^ z) +/// ELSE +/// RETURN (x & y) | (~x & z) +/// FI +/// } +/// A[0] := __B.dword[3] +/// B[0] := __B.dword[2] +/// C[0] := __A.dword[3] +/// D[0] := __A.dword[2] +/// E[0] := __B.dword[1] +/// F[0] := __B.dword[0] +/// G[0] := __A.dword[1] +/// H[0] := __A.dword[0] +/// W[0] := __C.dword[0] +/// W[1] := __C.dword[1] +/// W[4] := __C.dword[2] +/// W[5] := __C.dword[3] +/// C[0] := ROL32(C[0], 9) +/// D[0] := ROL32(D[0], 9) +/// G[0] := ROL32(G[0], 19) +/// H[0] := ROL32(H[0], 19) +/// ROUND := __D & 0x3E +/// IF ROUND < 16 +/// CONST := 0x79CC4519 +/// ELSE +/// CONST := 0x7A879D8A +/// FI +/// CONST := ROL32(CONST,ROUND) +/// FOR i:= 0 to 1 +/// S1 := ROL32((ROL32(A[i], 12) + E[i] + CONST), 7) +/// S2 := S1 ^ ROL32(A[i], 12) +/// T1 := FF(A[i], B[i], C[i], ROUND) + D[i] + S2 + (W[i] ^ W[i+4]) +/// T2 := GG(E[i], F[i], G[i], ROUND) + H[i] + S1 + W[i] +/// D[i+1] := C[i] +/// C[i+1] := ROL32(B[i],9) +/// B[i+1] := A[i] +/// A[i+1] := T1 +/// H[i+1] := G[i] +/// G[i+1] := ROL32(F[i], 19) +/// F[i+1] := E[i] +/// E[i+1] := P0(T2) +/// CONST := ROL32(CONST, 1) +/// ENDFOR +/// dst.dword[3] := A[2] +/// dst.dword[2] := B[2] +/// dst.dword[1] := E[2] +/// dst.dword[0] := F[2] +/// dst[MAX:128] := 0 +/// \endcode +#define _mm_sm3rnds2_epi32(A, B, C, D) \ + (__m128i) __builtin_ia32_vsm3rnds2((__v4su)A, (__v4su)B, (__v4su)C, (int)D) + +#undef __DEFAULT_FN_ATTRS128 + +#endif // __SM3INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm4evexintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm4evexintrin.h new file mode 100755 index 0000000..f6ae003 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm4evexintrin.h @@ -0,0 +1,32 @@ +/*===--------------- sm4evexintrin.h - SM4 EVEX intrinsics -----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __SM4EVEXINTRIN_H +#define __SM4EVEXINTRIN_H + +#define __DEFAULT_FN_ATTRS512 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("sm4,avx10.2-512"), __min_vector_width__(512))) + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sm4key4_epi32(__m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_vsm4key4512((__v16su)__A, (__v16su)__B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS512 +_mm512_sm4rnds4_epi32(__m512i __A, __m512i __B) { + return (__m512i)__builtin_ia32_vsm4rnds4512((__v16su)__A, (__v16su)__B); +} + +#undef __DEFAULT_FN_ATTRS512 + +#endif // __SM4EVEXINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm4intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm4intrin.h new file mode 100755 index 0000000..47aeec4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/sm4intrin.h @@ -0,0 +1,269 @@ +/*===--------------- sm4intrin.h - SM4 intrinsics -----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif // __IMMINTRIN_H + +#ifndef __SM4INTRIN_H +#define __SM4INTRIN_H + +/// This intrinsic performs four rounds of SM4 key expansion. The intrinsic +/// operates on independent 128-bit lanes. The calculated results are +/// stored in \a dst. +/// \headerfile +/// +/// \code +/// __m128i _mm_sm4key4_epi32(__m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSM4KEY4 instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x int]. +/// \param __B +/// A 128-bit vector of [4 x int]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32-count)) +/// RETURN dest +/// } +/// DEFINE SBOX_BYTE(dword, i) { +/// RETURN sbox[dword.byte[i]] +/// } +/// DEFINE lower_t(dword) { +/// tmp.byte[0] := SBOX_BYTE(dword, 0) +/// tmp.byte[1] := SBOX_BYTE(dword, 1) +/// tmp.byte[2] := SBOX_BYTE(dword, 2) +/// tmp.byte[3] := SBOX_BYTE(dword, 3) +/// RETURN tmp +/// } +/// DEFINE L_KEY(dword) { +/// RETURN dword ^ ROL32(dword, 13) ^ ROL32(dword, 23) +/// } +/// DEFINE T_KEY(dword) { +/// RETURN L_KEY(lower_t(dword)) +/// } +/// DEFINE F_KEY(X0, X1, X2, X3, round_key) { +/// RETURN X0 ^ T_KEY(X1 ^ X2 ^ X3 ^ round_key) +/// } +/// FOR i:= 0 to 0 +/// P[0] := __B.xmm[i].dword[0] +/// P[1] := __B.xmm[i].dword[1] +/// P[2] := __B.xmm[i].dword[2] +/// P[3] := __B.xmm[i].dword[3] +/// C[0] := F_KEY(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0]) +/// C[1] := F_KEY(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1]) +/// C[2] := F_KEY(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2]) +/// C[3] := F_KEY(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3]) +/// DEST.xmm[i].dword[0] := C[0] +/// DEST.xmm[i].dword[1] := C[1] +/// DEST.xmm[i].dword[2] := C[2] +/// DEST.xmm[i].dword[3] := C[3] +/// ENDFOR +/// DEST[MAX:128] := 0 +/// \endcode +#define _mm_sm4key4_epi32(A, B) \ + (__m128i) __builtin_ia32_vsm4key4128((__v4su)A, (__v4su)B) + +/// This intrinsic performs four rounds of SM4 key expansion. The intrinsic +/// operates on independent 128-bit lanes. The calculated results are +/// stored in \a dst. +/// \headerfile +/// +/// \code +/// __m256i _mm256_sm4key4_epi32(__m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSM4KEY4 instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x int]. +/// \param __B +/// A 256-bit vector of [8 x int]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32-count)) +/// RETURN dest +/// } +/// DEFINE SBOX_BYTE(dword, i) { +/// RETURN sbox[dword.byte[i]] +/// } +/// DEFINE lower_t(dword) { +/// tmp.byte[0] := SBOX_BYTE(dword, 0) +/// tmp.byte[1] := SBOX_BYTE(dword, 1) +/// tmp.byte[2] := SBOX_BYTE(dword, 2) +/// tmp.byte[3] := SBOX_BYTE(dword, 3) +/// RETURN tmp +/// } +/// DEFINE L_KEY(dword) { +/// RETURN dword ^ ROL32(dword, 13) ^ ROL32(dword, 23) +/// } +/// DEFINE T_KEY(dword) { +/// RETURN L_KEY(lower_t(dword)) +/// } +/// DEFINE F_KEY(X0, X1, X2, X3, round_key) { +/// RETURN X0 ^ T_KEY(X1 ^ X2 ^ X3 ^ round_key) +/// } +/// FOR i:= 0 to 1 +/// P[0] := __B.xmm[i].dword[0] +/// P[1] := __B.xmm[i].dword[1] +/// P[2] := __B.xmm[i].dword[2] +/// P[3] := __B.xmm[i].dword[3] +/// C[0] := F_KEY(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0]) +/// C[1] := F_KEY(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1]) +/// C[2] := F_KEY(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2]) +/// C[3] := F_KEY(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3]) +/// DEST.xmm[i].dword[0] := C[0] +/// DEST.xmm[i].dword[1] := C[1] +/// DEST.xmm[i].dword[2] := C[2] +/// DEST.xmm[i].dword[3] := C[3] +/// ENDFOR +/// DEST[MAX:256] := 0 +/// \endcode +#define _mm256_sm4key4_epi32(A, B) \ + (__m256i) __builtin_ia32_vsm4key4256((__v8su)A, (__v8su)B) + +/// This intrinisc performs four rounds of SM4 encryption. The intrinisc +/// operates on independent 128-bit lanes. The calculated results are +/// stored in \a dst. +/// \headerfile +/// +/// \code +/// __m128i _mm_sm4rnds4_epi32(__m128i __A, __m128i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSM4RNDS4 instruction. +/// +/// \param __A +/// A 128-bit vector of [4 x int]. +/// \param __B +/// A 128-bit vector of [4 x int]. +/// \returns +/// A 128-bit vector of [4 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32-count)) +/// RETURN dest +/// } +/// DEFINE lower_t(dword) { +/// tmp.byte[0] := SBOX_BYTE(dword, 0) +/// tmp.byte[1] := SBOX_BYTE(dword, 1) +/// tmp.byte[2] := SBOX_BYTE(dword, 2) +/// tmp.byte[3] := SBOX_BYTE(dword, 3) +/// RETURN tmp +/// } +/// DEFINE L_RND(dword) { +/// tmp := dword +/// tmp := tmp ^ ROL32(dword, 2) +/// tmp := tmp ^ ROL32(dword, 10) +/// tmp := tmp ^ ROL32(dword, 18) +/// tmp := tmp ^ ROL32(dword, 24) +/// RETURN tmp +/// } +/// DEFINE T_RND(dword) { +/// RETURN L_RND(lower_t(dword)) +/// } +/// DEFINE F_RND(X0, X1, X2, X3, round_key) { +/// RETURN X0 ^ T_RND(X1 ^ X2 ^ X3 ^ round_key) +/// } +/// FOR i:= 0 to 0 +/// P[0] := __B.xmm[i].dword[0] +/// P[1] := __B.xmm[i].dword[1] +/// P[2] := __B.xmm[i].dword[2] +/// P[3] := __B.xmm[i].dword[3] +/// C[0] := F_RND(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0]) +/// C[1] := F_RND(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1]) +/// C[2] := F_RND(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2]) +/// C[3] := F_RND(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3]) +/// DEST.xmm[i].dword[0] := C[0] +/// DEST.xmm[i].dword[1] := C[1] +/// DEST.xmm[i].dword[2] := C[2] +/// DEST.xmm[i].dword[3] := C[3] +/// ENDFOR +/// DEST[MAX:128] := 0 +/// \endcode +#define _mm_sm4rnds4_epi32(A, B) \ + (__m128i) __builtin_ia32_vsm4rnds4128((__v4su)A, (__v4su)B) + +/// This intrinisc performs four rounds of SM4 encryption. The intrinisc +/// operates on independent 128-bit lanes. The calculated results are +/// stored in \a dst. +/// \headerfile +/// +/// \code +/// __m256i _mm256_sm4rnds4_epi32(__m256i __A, __m256i __B) +/// \endcode +/// +/// This intrinsic corresponds to the \c VSM4RNDS4 instruction. +/// +/// \param __A +/// A 256-bit vector of [8 x int]. +/// \param __B +/// A 256-bit vector of [8 x int]. +/// \returns +/// A 256-bit vector of [8 x int]. +/// +/// \code{.operation} +/// DEFINE ROL32(dword, n) { +/// count := n % 32 +/// dest := (dword << count) | (dword >> (32-count)) +/// RETURN dest +/// } +/// DEFINE lower_t(dword) { +/// tmp.byte[0] := SBOX_BYTE(dword, 0) +/// tmp.byte[1] := SBOX_BYTE(dword, 1) +/// tmp.byte[2] := SBOX_BYTE(dword, 2) +/// tmp.byte[3] := SBOX_BYTE(dword, 3) +/// RETURN tmp +/// } +/// DEFINE L_RND(dword) { +/// tmp := dword +/// tmp := tmp ^ ROL32(dword, 2) +/// tmp := tmp ^ ROL32(dword, 10) +/// tmp := tmp ^ ROL32(dword, 18) +/// tmp := tmp ^ ROL32(dword, 24) +/// RETURN tmp +/// } +/// DEFINE T_RND(dword) { +/// RETURN L_RND(lower_t(dword)) +/// } +/// DEFINE F_RND(X0, X1, X2, X3, round_key) { +/// RETURN X0 ^ T_RND(X1 ^ X2 ^ X3 ^ round_key) +/// } +/// FOR i:= 0 to 0 +/// P[0] := __B.xmm[i].dword[0] +/// P[1] := __B.xmm[i].dword[1] +/// P[2] := __B.xmm[i].dword[2] +/// P[3] := __B.xmm[i].dword[3] +/// C[0] := F_RND(P[0], P[1], P[2], P[3], __A.xmm[i].dword[0]) +/// C[1] := F_RND(P[1], P[2], P[3], C[0], __A.xmm[i].dword[1]) +/// C[2] := F_RND(P[2], P[3], C[0], C[1], __A.xmm[i].dword[2]) +/// C[3] := F_RND(P[3], C[0], C[1], C[2], __A.xmm[i].dword[3]) +/// DEST.xmm[i].dword[0] := C[0] +/// DEST.xmm[i].dword[1] := C[1] +/// DEST.xmm[i].dword[2] := C[2] +/// DEST.xmm[i].dword[3] := C[3] +/// ENDFOR +/// DEST[MAX:256] := 0 +/// \endcode +#define _mm256_sm4rnds4_epi32(A, B) \ + (__m256i) __builtin_ia32_vsm4rnds4256((__v8su)A, (__v8su)B) + +#endif // __SM4INTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/smmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/smmintrin.h new file mode 100755 index 0000000..bc6fe4c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/smmintrin.h @@ -0,0 +1,2334 @@ +/*===---- smmintrin.h - SSE4 intrinsics ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __SMMINTRIN_H +#define __SMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("sse4.1,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sse4.1"), \ + __min_vector_width__(128))) +#endif + +/* SSE4 Rounding macros. */ +#define _MM_FROUND_TO_NEAREST_INT 0x00 +#define _MM_FROUND_TO_NEG_INF 0x01 +#define _MM_FROUND_TO_POS_INF 0x02 +#define _MM_FROUND_TO_ZERO 0x03 +#define _MM_FROUND_CUR_DIRECTION 0x04 + +#define _MM_FROUND_RAISE_EXC 0x00 +#define _MM_FROUND_NO_EXC 0x08 + +#define _MM_FROUND_NINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEAREST_INT) +#define _MM_FROUND_FLOOR (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_NEG_INF) +#define _MM_FROUND_CEIL (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_POS_INF) +#define _MM_FROUND_TRUNC (_MM_FROUND_RAISE_EXC | _MM_FROUND_TO_ZERO) +#define _MM_FROUND_RINT (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION) +#define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION) + +/// Rounds up each element of the 128-bit vector of [4 x float] to an +/// integer and returns the rounded values in a 128-bit vector of +/// [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_ceil_ps(__m128 X); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPS / ROUNDPS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float] values to be rounded up. +/// \returns A 128-bit vector of [4 x float] containing the rounded values. +#define _mm_ceil_ps(X) _mm_round_ps((X), _MM_FROUND_CEIL) + +/// Rounds up each element of the 128-bit vector of [2 x double] to an +/// integer and returns the rounded values in a 128-bit vector of +/// [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_ceil_pd(__m128d X); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPD / ROUNDPD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double] values to be rounded up. +/// \returns A 128-bit vector of [2 x double] containing the rounded values. +#define _mm_ceil_pd(X) _mm_round_pd((X), _MM_FROUND_CEIL) + +/// Copies three upper elements of the first 128-bit vector operand to +/// the corresponding three upper elements of the 128-bit result vector of +/// [4 x float]. Rounds up the lowest element of the second 128-bit vector +/// operand to an integer and copies it to the lowest element of the 128-bit +/// result vector of [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_ceil_ss(__m128 X, __m128 Y); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDSS / ROUNDSS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are +/// copied to the corresponding bits of the result. +/// \param Y +/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is +/// rounded up to the nearest integer and copied to the corresponding bits +/// of the result. +/// \returns A 128-bit vector of [4 x float] containing the copied and rounded +/// values. +#define _mm_ceil_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_CEIL) + +/// Copies the upper element of the first 128-bit vector operand to the +/// corresponding upper element of the 128-bit result vector of [2 x double]. +/// Rounds up the lower element of the second 128-bit vector operand to an +/// integer and copies it to the lower element of the 128-bit result vector +/// of [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_ceil_sd(__m128d X, __m128d Y); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDSD / ROUNDSD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is +/// copied to the corresponding bits of the result. +/// \param Y +/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is +/// rounded up to the nearest integer and copied to the corresponding bits +/// of the result. +/// \returns A 128-bit vector of [2 x double] containing the copied and rounded +/// values. +#define _mm_ceil_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_CEIL) + +/// Rounds down each element of the 128-bit vector of [4 x float] to an +/// an integer and returns the rounded values in a 128-bit vector of +/// [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_floor_ps(__m128 X); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPS / ROUNDPS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float] values to be rounded down. +/// \returns A 128-bit vector of [4 x float] containing the rounded values. +#define _mm_floor_ps(X) _mm_round_ps((X), _MM_FROUND_FLOOR) + +/// Rounds down each element of the 128-bit vector of [2 x double] to an +/// integer and returns the rounded values in a 128-bit vector of +/// [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_floor_pd(__m128d X); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPD / ROUNDPD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double]. +/// \returns A 128-bit vector of [2 x double] containing the rounded values. +#define _mm_floor_pd(X) _mm_round_pd((X), _MM_FROUND_FLOOR) + +/// Copies three upper elements of the first 128-bit vector operand to +/// the corresponding three upper elements of the 128-bit result vector of +/// [4 x float]. Rounds down the lowest element of the second 128-bit vector +/// operand to an integer and copies it to the lowest element of the 128-bit +/// result vector of [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_floor_ss(__m128 X, __m128 Y); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDSS / ROUNDSS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are +/// copied to the corresponding bits of the result. +/// \param Y +/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is +/// rounded down to the nearest integer and copied to the corresponding bits +/// of the result. +/// \returns A 128-bit vector of [4 x float] containing the copied and rounded +/// values. +#define _mm_floor_ss(X, Y) _mm_round_ss((X), (Y), _MM_FROUND_FLOOR) + +/// Copies the upper element of the first 128-bit vector operand to the +/// corresponding upper element of the 128-bit result vector of [2 x double]. +/// Rounds down the lower element of the second 128-bit vector operand to an +/// integer and copies it to the lower element of the 128-bit result vector +/// of [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_floor_sd(__m128d X, __m128d Y); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDSD / ROUNDSD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is +/// copied to the corresponding bits of the result. +/// \param Y +/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is +/// rounded down to the nearest integer and copied to the corresponding bits +/// of the result. +/// \returns A 128-bit vector of [2 x double] containing the copied and rounded +/// values. +#define _mm_floor_sd(X, Y) _mm_round_sd((X), (Y), _MM_FROUND_FLOOR) + +/// Rounds each element of the 128-bit vector of [4 x float] to an +/// integer value according to the rounding control specified by the second +/// argument and returns the rounded values in a 128-bit vector of +/// [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_round_ps(__m128 X, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPS / ROUNDPS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float]. +/// \param M +/// An integer value that specifies the rounding operation. \n +/// Bits [7:4] are reserved. \n +/// Bit [3] is a precision exception value: \n +/// 0: A normal PE exception is used \n +/// 1: The PE field is not updated \n +/// Bit [2] is the rounding control source: \n +/// 0: Use bits [1:0] of \a M \n +/// 1: Use the current MXCSR setting \n +/// Bits [1:0] contain the rounding control definition: \n +/// 00: Nearest \n +/// 01: Downward (toward negative infinity) \n +/// 10: Upward (toward positive infinity) \n +/// 11: Truncated +/// \returns A 128-bit vector of [4 x float] containing the rounded values. +#define _mm_round_ps(X, M) \ + ((__m128)__builtin_ia32_roundps((__v4sf)(__m128)(X), (M))) + +/// Copies three upper elements of the first 128-bit vector operand to +/// the corresponding three upper elements of the 128-bit result vector of +/// [4 x float]. Rounds the lowest element of the second 128-bit vector +/// operand to an integer value according to the rounding control specified +/// by the third argument and copies it to the lowest element of the 128-bit +/// result vector of [4 x float]. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_round_ss(__m128 X, __m128 Y, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDSS / ROUNDSS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float]. The values stored in bits [127:32] are +/// copied to the corresponding bits of the result. +/// \param Y +/// A 128-bit vector of [4 x float]. The value stored in bits [31:0] is +/// rounded to the nearest integer using the specified rounding control and +/// copied to the corresponding bits of the result. +/// \param M +/// An integer value that specifies the rounding operation. \n +/// Bits [7:4] are reserved. \n +/// Bit [3] is a precision exception value: \n +/// 0: A normal PE exception is used \n +/// 1: The PE field is not updated \n +/// Bit [2] is the rounding control source: \n +/// 0: Use bits [1:0] of \a M \n +/// 1: Use the current MXCSR setting \n +/// Bits [1:0] contain the rounding control definition: \n +/// 00: Nearest \n +/// 01: Downward (toward negative infinity) \n +/// 10: Upward (toward positive infinity) \n +/// 11: Truncated +/// \returns A 128-bit vector of [4 x float] containing the copied and rounded +/// values. +#define _mm_round_ss(X, Y, M) \ + ((__m128)__builtin_ia32_roundss((__v4sf)(__m128)(X), (__v4sf)(__m128)(Y), \ + (M))) + +/// Rounds each element of the 128-bit vector of [2 x double] to an +/// integer value according to the rounding control specified by the second +/// argument and returns the rounded values in a 128-bit vector of +/// [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_round_pd(__m128d X, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDPD / ROUNDPD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double]. +/// \param M +/// An integer value that specifies the rounding operation. \n +/// Bits [7:4] are reserved. \n +/// Bit [3] is a precision exception value: \n +/// 0: A normal PE exception is used \n +/// 1: The PE field is not updated \n +/// Bit [2] is the rounding control source: \n +/// 0: Use bits [1:0] of \a M \n +/// 1: Use the current MXCSR setting \n +/// Bits [1:0] contain the rounding control definition: \n +/// 00: Nearest \n +/// 01: Downward (toward negative infinity) \n +/// 10: Upward (toward positive infinity) \n +/// 11: Truncated +/// \returns A 128-bit vector of [2 x double] containing the rounded values. +#define _mm_round_pd(X, M) \ + ((__m128d)__builtin_ia32_roundpd((__v2df)(__m128d)(X), (M))) + +/// Copies the upper element of the first 128-bit vector operand to the +/// corresponding upper element of the 128-bit result vector of [2 x double]. +/// Rounds the lower element of the second 128-bit vector operand to an +/// integer value according to the rounding control specified by the third +/// argument and copies it to the lower element of the 128-bit result vector +/// of [2 x double]. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_round_sd(__m128d X, __m128d Y, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VROUNDSD / ROUNDSD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double]. The value stored in bits [127:64] is +/// copied to the corresponding bits of the result. +/// \param Y +/// A 128-bit vector of [2 x double]. The value stored in bits [63:0] is +/// rounded to the nearest integer using the specified rounding control and +/// copied to the corresponding bits of the result. +/// \param M +/// An integer value that specifies the rounding operation. \n +/// Bits [7:4] are reserved. \n +/// Bit [3] is a precision exception value: \n +/// 0: A normal PE exception is used \n +/// 1: The PE field is not updated \n +/// Bit [2] is the rounding control source: \n +/// 0: Use bits [1:0] of \a M \n +/// 1: Use the current MXCSR setting \n +/// Bits [1:0] contain the rounding control definition: \n +/// 00: Nearest \n +/// 01: Downward (toward negative infinity) \n +/// 10: Upward (toward positive infinity) \n +/// 11: Truncated +/// \returns A 128-bit vector of [2 x double] containing the copied and rounded +/// values. +#define _mm_round_sd(X, Y, M) \ + ((__m128d)__builtin_ia32_roundsd((__v2df)(__m128d)(X), (__v2df)(__m128d)(Y), \ + (M))) + +/* SSE4 Packed Blending Intrinsics. */ +/// Returns a 128-bit vector of [2 x double] where the values are +/// selected from either the first or second operand as specified by the +/// third operand, the control mask. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_blend_pd(__m128d V1, __m128d V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VBLENDPD / BLENDPD instruction. +/// +/// \param V1 +/// A 128-bit vector of [2 x double]. +/// \param V2 +/// A 128-bit vector of [2 x double]. +/// \param M +/// An immediate integer operand, with mask bits [1:0] specifying how the +/// values are to be copied. The position of the mask bit corresponds to the +/// index of a copied value. When a mask bit is 0, the corresponding 64-bit +/// element in operand \a V1 is copied to the same position in the result. +/// When a mask bit is 1, the corresponding 64-bit element in operand \a V2 +/// is copied to the same position in the result. +/// \returns A 128-bit vector of [2 x double] containing the copied values. +#define _mm_blend_pd(V1, V2, M) \ + ((__m128d)__builtin_ia32_blendpd((__v2df)(__m128d)(V1), \ + (__v2df)(__m128d)(V2), (int)(M))) + +/// Returns a 128-bit vector of [4 x float] where the values are selected +/// from either the first or second operand as specified by the third +/// operand, the control mask. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_blend_ps(__m128 V1, __m128 V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VBLENDPS / BLENDPS instruction. +/// +/// \param V1 +/// A 128-bit vector of [4 x float]. +/// \param V2 +/// A 128-bit vector of [4 x float]. +/// \param M +/// An immediate integer operand, with mask bits [3:0] specifying how the +/// values are to be copied. The position of the mask bit corresponds to the +/// index of a copied value. When a mask bit is 0, the corresponding 32-bit +/// element in operand \a V1 is copied to the same position in the result. +/// When a mask bit is 1, the corresponding 32-bit element in operand \a V2 +/// is copied to the same position in the result. +/// \returns A 128-bit vector of [4 x float] containing the copied values. +#define _mm_blend_ps(V1, V2, M) \ + ((__m128)__builtin_ia32_blendps((__v4sf)(__m128)(V1), (__v4sf)(__m128)(V2), \ + (int)(M))) + +/// Returns a 128-bit vector of [2 x double] where the values are +/// selected from either the first or second operand as specified by the +/// third operand, the control mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBLENDVPD / BLENDVPD instruction. +/// +/// \param __V1 +/// A 128-bit vector of [2 x double]. +/// \param __V2 +/// A 128-bit vector of [2 x double]. +/// \param __M +/// A 128-bit vector operand, with mask bits 127 and 63 specifying how the +/// values are to be copied. The position of the mask bit corresponds to the +/// most significant bit of a copied value. When a mask bit is 0, the +/// corresponding 64-bit element in operand \a __V1 is copied to the same +/// position in the result. When a mask bit is 1, the corresponding 64-bit +/// element in operand \a __V2 is copied to the same position in the result. +/// \returns A 128-bit vector of [2 x double] containing the copied values. +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_blendv_pd(__m128d __V1, + __m128d __V2, + __m128d __M) { + return (__m128d)__builtin_ia32_blendvpd((__v2df)__V1, (__v2df)__V2, + (__v2df)__M); +} + +/// Returns a 128-bit vector of [4 x float] where the values are +/// selected from either the first or second operand as specified by the +/// third operand, the control mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBLENDVPS / BLENDVPS instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x float]. +/// \param __V2 +/// A 128-bit vector of [4 x float]. +/// \param __M +/// A 128-bit vector operand, with mask bits 127, 95, 63, and 31 specifying +/// how the values are to be copied. The position of the mask bit corresponds +/// to the most significant bit of a copied value. When a mask bit is 0, the +/// corresponding 32-bit element in operand \a __V1 is copied to the same +/// position in the result. When a mask bit is 1, the corresponding 32-bit +/// element in operand \a __V2 is copied to the same position in the result. +/// \returns A 128-bit vector of [4 x float] containing the copied values. +static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_blendv_ps(__m128 __V1, + __m128 __V2, + __m128 __M) { + return (__m128)__builtin_ia32_blendvps((__v4sf)__V1, (__v4sf)__V2, + (__v4sf)__M); +} + +/// Returns a 128-bit vector of [16 x i8] where the values are selected +/// from either of the first or second operand as specified by the third +/// operand, the control mask. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPBLENDVB / PBLENDVB instruction. +/// +/// \param __V1 +/// A 128-bit vector of [16 x i8]. +/// \param __V2 +/// A 128-bit vector of [16 x i8]. +/// \param __M +/// A 128-bit vector operand, with mask bits 127, 119, 111...7 specifying +/// how the values are to be copied. The position of the mask bit corresponds +/// to the most significant bit of a copied value. When a mask bit is 0, the +/// corresponding 8-bit element in operand \a __V1 is copied to the same +/// position in the result. When a mask bit is 1, the corresponding 8-bit +/// element in operand \a __V2 is copied to the same position in the result. +/// \returns A 128-bit vector of [16 x i8] containing the copied values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_blendv_epi8(__m128i __V1, + __m128i __V2, + __m128i __M) { + return (__m128i)__builtin_ia32_pblendvb128((__v16qi)__V1, (__v16qi)__V2, + (__v16qi)__M); +} + +/// Returns a 128-bit vector of [8 x i16] where the values are selected +/// from either of the first or second operand as specified by the third +/// operand, the control mask. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_blend_epi16(__m128i V1, __m128i V2, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPBLENDW / PBLENDW instruction. +/// +/// \param V1 +/// A 128-bit vector of [8 x i16]. +/// \param V2 +/// A 128-bit vector of [8 x i16]. +/// \param M +/// An immediate integer operand, with mask bits [7:0] specifying how the +/// values are to be copied. The position of the mask bit corresponds to the +/// index of a copied value. When a mask bit is 0, the corresponding 16-bit +/// element in operand \a V1 is copied to the same position in the result. +/// When a mask bit is 1, the corresponding 16-bit element in operand \a V2 +/// is copied to the same position in the result. +/// \returns A 128-bit vector of [8 x i16] containing the copied values. +#define _mm_blend_epi16(V1, V2, M) \ + ((__m128i)__builtin_ia32_pblendw128((__v8hi)(__m128i)(V1), \ + (__v8hi)(__m128i)(V2), (int)(M))) + +/* SSE4 Dword Multiply Instructions. */ +/// Multiples corresponding elements of two 128-bit vectors of [4 x i32] +/// and returns the lower 32 bits of the each product in a 128-bit vector of +/// [4 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMULLD / PMULLD instruction. +/// +/// \param __V1 +/// A 128-bit integer vector. +/// \param __V2 +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the products of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mullo_epi32(__m128i __V1, + __m128i __V2) { + return (__m128i)((__v4su)__V1 * (__v4su)__V2); +} + +/// Multiplies corresponding even-indexed elements of two 128-bit +/// vectors of [4 x i32] and returns a 128-bit vector of [2 x i64] +/// containing the products. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMULDQ / PMULDQ instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x i32]. +/// \param __V2 +/// A 128-bit vector of [4 x i32]. +/// \returns A 128-bit vector of [2 x i64] containing the products of both +/// operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_mul_epi32(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_ia32_pmuldq128((__v4si)__V1, (__v4si)__V2); +} + +/* SSE4 Floating Point Dot Product Instructions. */ +/// Computes the dot product of the two 128-bit vectors of [4 x float] +/// and returns it in the elements of the 128-bit result vector of +/// [4 x float]. +/// +/// The immediate integer operand controls which input elements +/// will contribute to the dot product, and where the final results are +/// returned. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_dp_ps(__m128 X, __m128 Y, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VDPPS / DPPS instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float]. +/// \param Y +/// A 128-bit vector of [4 x float]. +/// \param M +/// An immediate integer operand. Mask bits [7:4] determine which elements +/// of the input vectors are used, with bit [4] corresponding to the lowest +/// element and bit [7] corresponding to the highest element of each [4 x +/// float] vector. If a bit is set, the corresponding elements from the two +/// input vectors are used as an input for dot product; otherwise that input +/// is treated as zero. Bits [3:0] determine which elements of the result +/// will receive a copy of the final dot product, with bit [0] corresponding +/// to the lowest element and bit [3] corresponding to the highest element of +/// each [4 x float] subvector. If a bit is set, the dot product is returned +/// in the corresponding element; otherwise that element is set to zero. +/// \returns A 128-bit vector of [4 x float] containing the dot product. +#define _mm_dp_ps(X, Y, M) \ + ((__m128)__builtin_ia32_dpps((__v4sf)(__m128)(X), (__v4sf)(__m128)(Y), (M))) + +/// Computes the dot product of the two 128-bit vectors of [2 x double] +/// and returns it in the elements of the 128-bit result vector of +/// [2 x double]. +/// +/// The immediate integer operand controls which input +/// elements will contribute to the dot product, and where the final results +/// are returned. +/// +/// \headerfile +/// +/// \code +/// __m128d _mm_dp_pd(__m128d X, __m128d Y, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VDPPD / DPPD instruction. +/// +/// \param X +/// A 128-bit vector of [2 x double]. +/// \param Y +/// A 128-bit vector of [2 x double]. +/// \param M +/// An immediate integer operand. Mask bits [5:4] determine which elements +/// of the input vectors are used, with bit [4] corresponding to the lowest +/// element and bit [5] corresponding to the highest element of each of [2 x +/// double] vector. If a bit is set, the corresponding elements from the two +/// input vectors are used as an input for dot product; otherwise that input +/// is treated as zero. Bits [1:0] determine which elements of the result +/// will receive a copy of the final dot product, with bit [0] corresponding +/// to the lowest element and bit [1] corresponding to the highest element of +/// each [2 x double] vector. If a bit is set, the dot product is returned in +/// the corresponding element; otherwise that element is set to zero. +#define _mm_dp_pd(X, Y, M) \ + ((__m128d)__builtin_ia32_dppd((__v2df)(__m128d)(X), (__v2df)(__m128d)(Y), \ + (M))) + +/* SSE4 Streaming Load Hint Instruction. */ +/// Loads integer values from a 128-bit aligned memory location to a +/// 128-bit integer vector. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTDQA / MOVNTDQA instruction. +/// +/// \param __V +/// A pointer to a 128-bit aligned memory location that contains the integer +/// values. +/// \returns A 128-bit integer vector containing the data stored at the +/// specified memory location. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_stream_load_si128(const void *__V) { + return (__m128i)__builtin_nontemporal_load((const __v2di *)__V); +} + +/* SSE4 Packed Integer Min/Max Instructions. */ +/// Compares the corresponding elements of two 128-bit vectors of +/// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the lesser +/// of the two values. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMINSB / PMINSB instruction. +/// +/// \param __V1 +/// A 128-bit vector of [16 x i8]. +/// \param __V2 +/// A 128-bit vector of [16 x i8] +/// \returns A 128-bit vector of [16 x i8] containing the lesser values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_min_epi8(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_min((__v16qs)__V1, (__v16qs)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [16 x i8] and returns a 128-bit vector of [16 x i8] containing the +/// greater value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMAXSB / PMAXSB instruction. +/// +/// \param __V1 +/// A 128-bit vector of [16 x i8]. +/// \param __V2 +/// A 128-bit vector of [16 x i8]. +/// \returns A 128-bit vector of [16 x i8] containing the greater values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epi8(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_max((__v16qs)__V1, (__v16qs)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the lesser +/// value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMINUW / PMINUW instruction. +/// +/// \param __V1 +/// A 128-bit vector of [8 x u16]. +/// \param __V2 +/// A 128-bit vector of [8 x u16]. +/// \returns A 128-bit vector of [8 x u16] containing the lesser values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_min_epu16(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_min((__v8hu)__V1, (__v8hu)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [8 x u16] and returns a 128-bit vector of [8 x u16] containing the +/// greater value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMAXUW / PMAXUW instruction. +/// +/// \param __V1 +/// A 128-bit vector of [8 x u16]. +/// \param __V2 +/// A 128-bit vector of [8 x u16]. +/// \returns A 128-bit vector of [8 x u16] containing the greater values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epu16(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_max((__v8hu)__V1, (__v8hu)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the lesser +/// value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMINSD / PMINSD instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x i32]. +/// \param __V2 +/// A 128-bit vector of [4 x i32]. +/// \returns A 128-bit vector of [4 x i32] containing the lesser values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_min_epi32(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_min((__v4si)__V1, (__v4si)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [4 x i32] and returns a 128-bit vector of [4 x i32] containing the +/// greater value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMAXSD / PMAXSD instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x i32]. +/// \param __V2 +/// A 128-bit vector of [4 x i32]. +/// \returns A 128-bit vector of [4 x i32] containing the greater values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epi32(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_max((__v4si)__V1, (__v4si)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the lesser +/// value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMINUD / PMINUD instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x u32]. +/// \param __V2 +/// A 128-bit vector of [4 x u32]. +/// \returns A 128-bit vector of [4 x u32] containing the lesser values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_min_epu32(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_min((__v4su)__V1, (__v4su)__V2); +} + +/// Compares the corresponding elements of two 128-bit vectors of +/// [4 x u32] and returns a 128-bit vector of [4 x u32] containing the +/// greater value of the two. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMAXUD / PMAXUD instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x u32]. +/// \param __V2 +/// A 128-bit vector of [4 x u32]. +/// \returns A 128-bit vector of [4 x u32] containing the greater values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_max_epu32(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_elementwise_max((__v4su)__V1, (__v4su)__V2); +} + +/* SSE4 Insertion and Extraction from XMM Register Instructions. */ +/// Takes the first argument \a X and inserts an element from the second +/// argument \a Y as selected by the third argument \a N. That result then +/// has elements zeroed out also as selected by the third argument \a N. The +/// resulting 128-bit vector of [4 x float] is then returned. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_insert_ps(__m128 X, __m128 Y, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VINSERTPS instruction. +/// +/// \param X +/// A 128-bit vector source operand of [4 x float]. With the exception of +/// those bits in the result copied from parameter \a Y and zeroed by bits +/// [3:0] of \a N, all bits from this parameter are copied to the result. +/// \param Y +/// A 128-bit vector source operand of [4 x float]. One single-precision +/// floating-point element from this source, as determined by the immediate +/// parameter, is copied to the result. +/// \param N +/// Specifies which bits from operand \a Y will be copied, which bits in the +/// result they will be copied to, and which bits in the result will be +/// cleared. The following assignments are made: \n +/// Bits [7:6] specify the bits to copy from operand \a Y: \n +/// 00: Selects bits [31:0] from operand \a Y. \n +/// 01: Selects bits [63:32] from operand \a Y. \n +/// 10: Selects bits [95:64] from operand \a Y. \n +/// 11: Selects bits [127:96] from operand \a Y. \n +/// Bits [5:4] specify the bits in the result to which the selected bits +/// from operand \a Y are copied: \n +/// 00: Copies the selected bits from \a Y to result bits [31:0]. \n +/// 01: Copies the selected bits from \a Y to result bits [63:32]. \n +/// 10: Copies the selected bits from \a Y to result bits [95:64]. \n +/// 11: Copies the selected bits from \a Y to result bits [127:96]. \n +/// Bits[3:0]: If any of these bits are set, the corresponding result +/// element is cleared. +/// \returns A 128-bit vector of [4 x float] containing the copied +/// single-precision floating point elements from the operands. +#define _mm_insert_ps(X, Y, N) __builtin_ia32_insertps128((X), (Y), (N)) + +/// Extracts a 32-bit integer from a 128-bit vector of [4 x float] and +/// returns it, using the immediate value parameter \a N as a selector. +/// +/// \headerfile +/// +/// \code +/// int _mm_extract_ps(__m128 X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VEXTRACTPS / EXTRACTPS +/// instruction. +/// +/// \param X +/// A 128-bit vector of [4 x float]. +/// \param N +/// An immediate value. Bits [1:0] determines which bits from the argument +/// \a X are extracted and returned: \n +/// 00: Bits [31:0] of parameter \a X are returned. \n +/// 01: Bits [63:32] of parameter \a X are returned. \n +/// 10: Bits [95:64] of parameter \a X are returned. \n +/// 11: Bits [127:96] of parameter \a X are returned. +/// \returns A 32-bit integer containing the extracted 32 bits of float data. +#define _mm_extract_ps(X, N) \ + __builtin_bit_cast( \ + int, __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N))) + +/* Miscellaneous insert and extract macros. */ +/* Extract a single-precision float from X at index N into D. */ +#define _MM_EXTRACT_FLOAT(D, X, N) \ + do { \ + (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); \ + } while (0) + +/* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create + an index suitable for _mm_insert_ps. */ +#define _MM_MK_INSERTPS_NDX(X, Y, Z) (((X) << 6) | ((Y) << 4) | (Z)) + +/* Extract a float from X at index N into the first index of the return. */ +#define _MM_PICK_OUT_PS(X, N) \ + _mm_insert_ps(_mm_setzero_ps(), (X), _MM_MK_INSERTPS_NDX((N), 0, 0x0e)) + +/* Insert int into packed integer array at index. */ +/// Constructs a 128-bit vector of [16 x i8] by first making a copy of +/// the 128-bit integer vector parameter, and then inserting the lower 8 bits +/// of an integer parameter \a I into an offset specified by the immediate +/// value parameter \a N. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_insert_epi8(__m128i X, int I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VPINSRB / PINSRB instruction. +/// +/// \param X +/// A 128-bit integer vector of [16 x i8]. This vector is copied to the +/// result and then one of the sixteen elements in the result vector is +/// replaced by the lower 8 bits of \a I. +/// \param I +/// An integer. The lower 8 bits of this operand are written to the result +/// beginning at the offset specified by \a N. +/// \param N +/// An immediate value. Bits [3:0] specify the bit offset in the result at +/// which the lower 8 bits of \a I are written. \n +/// 0000: Bits [7:0] of the result are used for insertion. \n +/// 0001: Bits [15:8] of the result are used for insertion. \n +/// 0010: Bits [23:16] of the result are used for insertion. \n +/// 0011: Bits [31:24] of the result are used for insertion. \n +/// 0100: Bits [39:32] of the result are used for insertion. \n +/// 0101: Bits [47:40] of the result are used for insertion. \n +/// 0110: Bits [55:48] of the result are used for insertion. \n +/// 0111: Bits [63:56] of the result are used for insertion. \n +/// 1000: Bits [71:64] of the result are used for insertion. \n +/// 1001: Bits [79:72] of the result are used for insertion. \n +/// 1010: Bits [87:80] of the result are used for insertion. \n +/// 1011: Bits [95:88] of the result are used for insertion. \n +/// 1100: Bits [103:96] of the result are used for insertion. \n +/// 1101: Bits [111:104] of the result are used for insertion. \n +/// 1110: Bits [119:112] of the result are used for insertion. \n +/// 1111: Bits [127:120] of the result are used for insertion. +/// \returns A 128-bit integer vector containing the constructed values. +#define _mm_insert_epi8(X, I, N) \ + ((__m128i)__builtin_ia32_vec_set_v16qi((__v16qi)(__m128i)(X), (int)(I), \ + (int)(N))) + +/// Constructs a 128-bit vector of [4 x i32] by first making a copy of +/// the 128-bit integer vector parameter, and then inserting the 32-bit +/// integer parameter \a I at the offset specified by the immediate value +/// parameter \a N. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_insert_epi32(__m128i X, int I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VPINSRD / PINSRD instruction. +/// +/// \param X +/// A 128-bit integer vector of [4 x i32]. This vector is copied to the +/// result and then one of the four elements in the result vector is +/// replaced by \a I. +/// \param I +/// A 32-bit integer that is written to the result beginning at the offset +/// specified by \a N. +/// \param N +/// An immediate value. Bits [1:0] specify the bit offset in the result at +/// which the integer \a I is written. \n +/// 00: Bits [31:0] of the result are used for insertion. \n +/// 01: Bits [63:32] of the result are used for insertion. \n +/// 10: Bits [95:64] of the result are used for insertion. \n +/// 11: Bits [127:96] of the result are used for insertion. +/// \returns A 128-bit integer vector containing the constructed values. +#define _mm_insert_epi32(X, I, N) \ + ((__m128i)__builtin_ia32_vec_set_v4si((__v4si)(__m128i)(X), (int)(I), \ + (int)(N))) + +#ifdef __x86_64__ +/// Constructs a 128-bit vector of [2 x i64] by first making a copy of +/// the 128-bit integer vector parameter, and then inserting the 64-bit +/// integer parameter \a I, using the immediate value parameter \a N as an +/// insertion location selector. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_insert_epi64(__m128i X, long long I, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VPINSRQ / PINSRQ instruction. +/// +/// \param X +/// A 128-bit integer vector of [2 x i64]. This vector is copied to the +/// result and then one of the two elements in the result vector is replaced +/// by \a I. +/// \param I +/// A 64-bit integer that is written to the result beginning at the offset +/// specified by \a N. +/// \param N +/// An immediate value. Bit [0] specifies the bit offset in the result at +/// which the integer \a I is written. \n +/// 0: Bits [63:0] of the result are used for insertion. \n +/// 1: Bits [127:64] of the result are used for insertion. \n +/// \returns A 128-bit integer vector containing the constructed values. +#define _mm_insert_epi64(X, I, N) \ + ((__m128i)__builtin_ia32_vec_set_v2di((__v2di)(__m128i)(X), (long long)(I), \ + (int)(N))) +#endif /* __x86_64__ */ + +/* Extract int from packed integer array at index. This returns the element + * as a zero extended value, so it is unsigned. + */ +/// Extracts an 8-bit element from the 128-bit integer vector of +/// [16 x i8], using the immediate value parameter \a N as a selector. +/// +/// \headerfile +/// +/// \code +/// int _mm_extract_epi8(__m128i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VPEXTRB / PEXTRB instruction. +/// +/// \param X +/// A 128-bit integer vector. +/// \param N +/// An immediate value. Bits [3:0] specify which 8-bit vector element from +/// the argument \a X to extract and copy to the result. \n +/// 0000: Bits [7:0] of parameter \a X are extracted. \n +/// 0001: Bits [15:8] of the parameter \a X are extracted. \n +/// 0010: Bits [23:16] of the parameter \a X are extracted. \n +/// 0011: Bits [31:24] of the parameter \a X are extracted. \n +/// 0100: Bits [39:32] of the parameter \a X are extracted. \n +/// 0101: Bits [47:40] of the parameter \a X are extracted. \n +/// 0110: Bits [55:48] of the parameter \a X are extracted. \n +/// 0111: Bits [63:56] of the parameter \a X are extracted. \n +/// 1000: Bits [71:64] of the parameter \a X are extracted. \n +/// 1001: Bits [79:72] of the parameter \a X are extracted. \n +/// 1010: Bits [87:80] of the parameter \a X are extracted. \n +/// 1011: Bits [95:88] of the parameter \a X are extracted. \n +/// 1100: Bits [103:96] of the parameter \a X are extracted. \n +/// 1101: Bits [111:104] of the parameter \a X are extracted. \n +/// 1110: Bits [119:112] of the parameter \a X are extracted. \n +/// 1111: Bits [127:120] of the parameter \a X are extracted. +/// \returns An unsigned integer, whose lower 8 bits are selected from the +/// 128-bit integer vector parameter and the remaining bits are assigned +/// zeros. +#define _mm_extract_epi8(X, N) \ + ((int)(unsigned char)__builtin_ia32_vec_ext_v16qi((__v16qi)(__m128i)(X), \ + (int)(N))) + +/// Extracts a 32-bit element from the 128-bit integer vector of +/// [4 x i32], using the immediate value parameter \a N as a selector. +/// +/// \headerfile +/// +/// \code +/// int _mm_extract_epi32(__m128i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VPEXTRD / PEXTRD instruction. +/// +/// \param X +/// A 128-bit integer vector. +/// \param N +/// An immediate value. Bits [1:0] specify which 32-bit vector element from +/// the argument \a X to extract and copy to the result. \n +/// 00: Bits [31:0] of the parameter \a X are extracted. \n +/// 01: Bits [63:32] of the parameter \a X are extracted. \n +/// 10: Bits [95:64] of the parameter \a X are extracted. \n +/// 11: Bits [127:96] of the parameter \a X are exracted. +/// \returns An integer, whose lower 32 bits are selected from the 128-bit +/// integer vector parameter and the remaining bits are assigned zeros. +#define _mm_extract_epi32(X, N) \ + ((int)__builtin_ia32_vec_ext_v4si((__v4si)(__m128i)(X), (int)(N))) + +/// Extracts a 64-bit element from the 128-bit integer vector of +/// [2 x i64], using the immediate value parameter \a N as a selector. +/// +/// \headerfile +/// +/// \code +/// long long _mm_extract_epi64(__m128i X, const int N); +/// \endcode +/// +/// This intrinsic corresponds to the VPEXTRQ / PEXTRQ instruction +/// in 64-bit mode. +/// +/// \param X +/// A 128-bit integer vector. +/// \param N +/// An immediate value. Bit [0] specifies which 64-bit vector element from +/// the argument \a X to return. \n +/// 0: Bits [63:0] are returned. \n +/// 1: Bits [127:64] are returned. \n +/// \returns A 64-bit integer. +#define _mm_extract_epi64(X, N) \ + ((long long)__builtin_ia32_vec_ext_v2di((__v2di)(__m128i)(X), (int)(N))) + +/* SSE4 128-bit Packed Integer Comparisons. */ +/// Tests whether the specified bits in a 128-bit integer vector are all +/// zeros. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPTEST / PTEST instruction. +/// +/// \param __M +/// A 128-bit integer vector containing the bits to be tested. +/// \param __V +/// A 128-bit integer vector selecting which bits to test in operand \a __M. +/// \returns TRUE if the specified bits are all zeros; FALSE otherwise. +static __inline__ int __DEFAULT_FN_ATTRS _mm_testz_si128(__m128i __M, + __m128i __V) { + return __builtin_ia32_ptestz128((__v2di)__M, (__v2di)__V); +} + +/// Tests whether the specified bits in a 128-bit integer vector are all +/// ones. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPTEST / PTEST instruction. +/// +/// \param __M +/// A 128-bit integer vector containing the bits to be tested. +/// \param __V +/// A 128-bit integer vector selecting which bits to test in operand \a __M. +/// \returns TRUE if the specified bits are all ones; FALSE otherwise. +static __inline__ int __DEFAULT_FN_ATTRS _mm_testc_si128(__m128i __M, + __m128i __V) { + return __builtin_ia32_ptestc128((__v2di)__M, (__v2di)__V); +} + +/// Tests whether the specified bits in a 128-bit integer vector are +/// neither all zeros nor all ones. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPTEST / PTEST instruction. +/// +/// \param __M +/// A 128-bit integer vector containing the bits to be tested. +/// \param __V +/// A 128-bit integer vector selecting which bits to test in operand \a __M. +/// \returns TRUE if the specified bits are neither all zeros nor all ones; +/// FALSE otherwise. +static __inline__ int __DEFAULT_FN_ATTRS _mm_testnzc_si128(__m128i __M, + __m128i __V) { + return __builtin_ia32_ptestnzc128((__v2di)__M, (__v2di)__V); +} + +/// Tests whether the specified bits in a 128-bit integer vector are all +/// ones. +/// +/// \headerfile +/// +/// \code +/// int _mm_test_all_ones(__m128i V); +/// \endcode +/// +/// This intrinsic corresponds to the VPTEST / PTEST instruction. +/// +/// \param V +/// A 128-bit integer vector containing the bits to be tested. +/// \returns TRUE if the bits specified in the operand are all set to 1; FALSE +/// otherwise. +#define _mm_test_all_ones(V) _mm_testc_si128((V), _mm_set1_epi32(-1)) + +/// Tests whether the specified bits in a 128-bit integer vector are +/// neither all zeros nor all ones. +/// +/// \headerfile +/// +/// \code +/// int _mm_test_mix_ones_zeros(__m128i M, __m128i V); +/// \endcode +/// +/// This intrinsic corresponds to the VPTEST / PTEST instruction. +/// +/// \param M +/// A 128-bit integer vector containing the bits to be tested. +/// \param V +/// A 128-bit integer vector selecting which bits to test in operand \a M. +/// \returns TRUE if the specified bits are neither all zeros nor all ones; +/// FALSE otherwise. +#define _mm_test_mix_ones_zeros(M, V) _mm_testnzc_si128((M), (V)) + +/// Tests whether the specified bits in a 128-bit integer vector are all +/// zeros. +/// +/// \headerfile +/// +/// \code +/// int _mm_test_all_zeros(__m128i M, __m128i V); +/// \endcode +/// +/// This intrinsic corresponds to the VPTEST / PTEST instruction. +/// +/// \param M +/// A 128-bit integer vector containing the bits to be tested. +/// \param V +/// A 128-bit integer vector selecting which bits to test in operand \a M. +/// \returns TRUE if the specified bits are all zeros; FALSE otherwise. +#define _mm_test_all_zeros(M, V) _mm_testz_si128((M), (V)) + +/* SSE4 64-bit Packed Integer Comparisons. */ +/// Compares each of the corresponding 64-bit values of the 128-bit +/// integer vectors for equality. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPEQQ / PCMPEQQ instruction. +/// +/// \param __V1 +/// A 128-bit integer vector. +/// \param __V2 +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpeq_epi64(__m128i __V1, + __m128i __V2) { + return (__m128i)((__v2di)__V1 == (__v2di)__V2); +} + +/* SSE4 Packed Integer Sign-Extension. */ +/// Sign-extends each of the lower eight 8-bit integer elements of a +/// 128-bit vector of [16 x i8] to 16-bit values and returns them in a +/// 128-bit vector of [8 x i16]. The upper eight elements of the input vector +/// are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVSXBW / PMOVSXBW instruction. +/// +/// \param __V +/// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are +/// sign-extended to 16-bit values. +/// \returns A 128-bit vector of [8 x i16] containing the sign-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi8_epi16(__m128i __V) { + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3, 4, 5, 6, + 7), + __v8hi); +} + +/// Sign-extends each of the lower four 8-bit integer elements of a +/// 128-bit vector of [16 x i8] to 32-bit values and returns them in a +/// 128-bit vector of [4 x i32]. The upper twelve elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVSXBD / PMOVSXBD instruction. +/// +/// \param __V +/// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are +/// sign-extended to 32-bit values. +/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi8_epi32(__m128i __V) { + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1, 2, 3), __v4si); +} + +/// Sign-extends each of the lower two 8-bit integer elements of a +/// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in +/// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVSXBQ / PMOVSXBQ instruction. +/// +/// \param __V +/// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are +/// sign-extended to 64-bit values. +/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi8_epi64(__m128i __V) { + /* This function always performs a signed extension, but __v16qi is a char + which may be signed or unsigned, so use __v16qs. */ + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v16qs)__V, (__v16qs)__V, 0, 1), __v2di); +} + +/// Sign-extends each of the lower four 16-bit integer elements of a +/// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in +/// a 128-bit vector of [4 x i32]. The upper four elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVSXWD / PMOVSXWD instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are +/// sign-extended to 32-bit values. +/// \returns A 128-bit vector of [4 x i32] containing the sign-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi16_epi32(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1, 2, 3), __v4si); +} + +/// Sign-extends each of the lower two 16-bit integer elements of a +/// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in +/// a 128-bit vector of [2 x i64]. The upper six elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVSXWQ / PMOVSXWQ instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are +/// sign-extended to 64-bit values. +/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi16_epi64(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v8hi)__V, (__v8hi)__V, 0, 1), __v2di); +} + +/// Sign-extends each of the lower two 32-bit integer elements of a +/// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in +/// a 128-bit vector of [2 x i64]. The upper two elements of the input vector +/// are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVSXDQ / PMOVSXDQ instruction. +/// +/// \param __V +/// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are +/// sign-extended to 64-bit values. +/// \returns A 128-bit vector of [2 x i64] containing the sign-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepi32_epi64(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v4si)__V, (__v4si)__V, 0, 1), __v2di); +} + +/* SSE4 Packed Integer Zero-Extension. */ +/// Zero-extends each of the lower eight 8-bit integer elements of a +/// 128-bit vector of [16 x i8] to 16-bit values and returns them in a +/// 128-bit vector of [8 x i16]. The upper eight elements of the input vector +/// are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVZXBW / PMOVZXBW instruction. +/// +/// \param __V +/// A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are +/// zero-extended to 16-bit values. +/// \returns A 128-bit vector of [8 x i16] containing the zero-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepu8_epi16(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3, 4, 5, 6, + 7), + __v8hi); +} + +/// Zero-extends each of the lower four 8-bit integer elements of a +/// 128-bit vector of [16 x i8] to 32-bit values and returns them in a +/// 128-bit vector of [4 x i32]. The upper twelve elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVZXBD / PMOVZXBD instruction. +/// +/// \param __V +/// A 128-bit vector of [16 x i8]. The lower four 8-bit elements are +/// zero-extended to 32-bit values. +/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepu8_epi32(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1, 2, 3), __v4si); +} + +/// Zero-extends each of the lower two 8-bit integer elements of a +/// 128-bit integer vector of [16 x i8] to 64-bit values and returns them in +/// a 128-bit vector of [2 x i64]. The upper fourteen elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVZXBQ / PMOVZXBQ instruction. +/// +/// \param __V +/// A 128-bit vector of [16 x i8]. The lower two 8-bit elements are +/// zero-extended to 64-bit values. +/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepu8_epi64(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v16qu)__V, (__v16qu)__V, 0, 1), __v2di); +} + +/// Zero-extends each of the lower four 16-bit integer elements of a +/// 128-bit integer vector of [8 x i16] to 32-bit values and returns them in +/// a 128-bit vector of [4 x i32]. The upper four elements of the input +/// vector are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVZXWD / PMOVZXWD instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16]. The lower four 16-bit elements are +/// zero-extended to 32-bit values. +/// \returns A 128-bit vector of [4 x i32] containing the zero-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepu16_epi32(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1, 2, 3), __v4si); +} + +/// Zero-extends each of the lower two 16-bit integer elements of a +/// 128-bit integer vector of [8 x i16] to 64-bit values and returns them in +/// a 128-bit vector of [2 x i64]. The upper six elements of the input vector +/// are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVZXWQ / PMOVZXWQ instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x i16]. The lower two 16-bit elements are +/// zero-extended to 64-bit values. +/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepu16_epi64(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v8hu)__V, (__v8hu)__V, 0, 1), __v2di); +} + +/// Zero-extends each of the lower two 32-bit integer elements of a +/// 128-bit integer vector of [4 x i32] to 64-bit values and returns them in +/// a 128-bit vector of [2 x i64]. The upper two elements of the input vector +/// are unused. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPMOVZXDQ / PMOVZXDQ instruction. +/// +/// \param __V +/// A 128-bit vector of [4 x i32]. The lower two 32-bit elements are +/// zero-extended to 64-bit values. +/// \returns A 128-bit vector of [2 x i64] containing the zero-extended values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvtepu32_epi64(__m128i __V) { + return (__m128i) __builtin_convertvector( + __builtin_shufflevector((__v4su)__V, (__v4su)__V, 0, 1), __v2di); +} + +/* SSE4 Pack with Unsigned Saturation. */ +/// Converts, with saturation, 32-bit signed integers from both 128-bit integer +/// vector operands into 16-bit unsigned integers, and returns the packed +/// result. +/// +/// Values greater than 0xFFFF are saturated to 0xFFFF. Values less than +/// 0x0000 are saturated to 0x0000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPACKUSDW / PACKUSDW instruction. +/// +/// \param __V1 +/// A 128-bit vector of [4 x i32]. The converted [4 x i16] values are +/// written to the lower 64 bits of the result. +/// \param __V2 +/// A 128-bit vector of [4 x i32]. The converted [4 x i16] values are +/// written to the higher 64 bits of the result. +/// \returns A 128-bit vector of [8 x i16] containing the converted values. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_packus_epi32(__m128i __V1, + __m128i __V2) { + return (__m128i)__builtin_ia32_packusdw128((__v4si)__V1, (__v4si)__V2); +} + +/* SSE4 Multiple Packed Sums of Absolute Difference. */ +/// Subtracts 8-bit unsigned integer values and computes the absolute +/// values of the differences to the corresponding bits in the destination. +/// Then sums of the absolute differences are returned according to the bit +/// fields in the immediate operand. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VMPSADBW / MPSADBW instruction. +/// +/// \param X +/// A 128-bit vector of [16 x i8]. +/// \param Y +/// A 128-bit vector of [16 x i8]. +/// \param M +/// An 8-bit immediate operand specifying how the absolute differences are to +/// be calculated, according to the following algorithm: +/// \code +/// // M2 represents bit 2 of the immediate operand +/// // M10 represents bits [1:0] of the immediate operand +/// i = M2 * 4; +/// j = M10 * 4; +/// for (k = 0; k < 8; k = k + 1) { +/// d0 = abs(X[i + k + 0] - Y[j + 0]); +/// d1 = abs(X[i + k + 1] - Y[j + 1]); +/// d2 = abs(X[i + k + 2] - Y[j + 2]); +/// d3 = abs(X[i + k + 3] - Y[j + 3]); +/// r[k] = d0 + d1 + d2 + d3; +/// } +/// \endcode +/// \returns A 128-bit integer vector containing the sums of the sets of +/// absolute differences between both operands. +#define _mm_mpsadbw_epu8(X, Y, M) \ + ((__m128i)__builtin_ia32_mpsadbw128((__v16qi)(__m128i)(X), \ + (__v16qi)(__m128i)(Y), (M))) + +/// Finds the minimum unsigned 16-bit element in the input 128-bit +/// vector of [8 x u16] and returns it and along with its index. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPHMINPOSUW / PHMINPOSUW +/// instruction. +/// +/// \param __V +/// A 128-bit vector of [8 x u16]. +/// \returns A 128-bit value where bits [15:0] contain the minimum value found +/// in parameter \a __V, bits [18:16] contain the index of the minimum value +/// and the remaining bits are set to 0. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_minpos_epu16(__m128i __V) { + return (__m128i)__builtin_ia32_phminposuw128((__v8hi)__V); +} + +/* Handle the sse4.2 definitions here. */ + +/* These definitions are normally in nmmintrin.h, but gcc puts them in here + so we'll do the same. */ + +#undef __DEFAULT_FN_ATTRS +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sse4.2"))) + +/* These specify the type of data that we're comparing. */ +#define _SIDD_UBYTE_OPS 0x00 +#define _SIDD_UWORD_OPS 0x01 +#define _SIDD_SBYTE_OPS 0x02 +#define _SIDD_SWORD_OPS 0x03 + +/* These specify the type of comparison operation. */ +#define _SIDD_CMP_EQUAL_ANY 0x00 +#define _SIDD_CMP_RANGES 0x04 +#define _SIDD_CMP_EQUAL_EACH 0x08 +#define _SIDD_CMP_EQUAL_ORDERED 0x0c + +/* These macros specify the polarity of the operation. */ +#define _SIDD_POSITIVE_POLARITY 0x00 +#define _SIDD_NEGATIVE_POLARITY 0x10 +#define _SIDD_MASKED_POSITIVE_POLARITY 0x20 +#define _SIDD_MASKED_NEGATIVE_POLARITY 0x30 + +/* These macros are used in _mm_cmpXstri() to specify the return. */ +#define _SIDD_LEAST_SIGNIFICANT 0x00 +#define _SIDD_MOST_SIGNIFICANT 0x40 + +/* These macros are used in _mm_cmpXstri() to specify the return. */ +#define _SIDD_BIT_MASK 0x00 +#define _SIDD_UNIT_MASK 0x40 + +/* SSE4.2 Packed Comparison Intrinsics. */ +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns a 128-bit integer vector representing the result +/// mask of the comparison. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_cmpistrm(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRM / PCMPISTRM +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words, the type of comparison to perform, and the format of the return +/// value. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// Bit [6]: Determines whether the result is zero-extended or expanded to 16 +/// bytes. \n +/// 0: The result is zero-extended to 16 bytes. \n +/// 1: The result is expanded to 16 bytes (this expansion is performed by +/// repeating each bit 8 or 16 times). +/// \returns Returns a 128-bit integer vector representing the result mask of +/// the comparison. +#define _mm_cmpistrm(A, B, M) \ + ((__m128i)__builtin_ia32_pcmpistrm128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns an integer representing the result index of the +/// comparison. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpistri(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRI / PCMPISTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words, the type of comparison to perform, and the format of the return +/// value. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// Bit [6]: Determines whether the index of the lowest set bit or the +/// highest set bit is returned. \n +/// 0: The index of the least significant set bit. \n +/// 1: The index of the most significant set bit. \n +/// \returns Returns an integer representing the result index of the comparison. +#define _mm_cmpistri(A, B, M) \ + ((int)__builtin_ia32_pcmpistri128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns a 128-bit integer vector representing the result +/// mask of the comparison. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_cmpestrm(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRM / PCMPESTRM +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words, the type of comparison to perform, and the format of the return +/// value. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// Bit [6]: Determines whether the result is zero-extended or expanded to 16 +/// bytes. \n +/// 0: The result is zero-extended to 16 bytes. \n +/// 1: The result is expanded to 16 bytes (this expansion is performed by +/// repeating each bit 8 or 16 times). \n +/// \returns Returns a 128-bit integer vector representing the result mask of +/// the comparison. +#define _mm_cmpestrm(A, LA, B, LB, M) \ + ((__m128i)__builtin_ia32_pcmpestrm128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns an integer representing the result index of the +/// comparison. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpestri(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRI / PCMPESTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words, the type of comparison to perform, and the format of the return +/// value. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// Bit [6]: Determines whether the index of the lowest set bit or the +/// highest set bit is returned. \n +/// 0: The index of the least significant set bit. \n +/// 1: The index of the most significant set bit. \n +/// \returns Returns an integer representing the result index of the comparison. +#define _mm_cmpestri(A, LA, B, LB, M) \ + ((int)__builtin_ia32_pcmpestri128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/* SSE4.2 Packed Comparison Intrinsics and EFlag Reading. */ +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the bit mask is zero and the length of the +/// string in \a B is the maximum, otherwise, returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpistra(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRI / PCMPISTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// \returns Returns 1 if the bit mask is zero and the length of the string in +/// \a B is the maximum; otherwise, returns 0. +#define _mm_cmpistra(A, B, M) \ + ((int)__builtin_ia32_pcmpistria128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the bit mask is non-zero, otherwise, returns +/// 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpistrc(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRI / PCMPISTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. +/// \returns Returns 1 if the bit mask is non-zero, otherwise, returns 0. +#define _mm_cmpistrc(A, B, M) \ + ((int)__builtin_ia32_pcmpistric128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns bit 0 of the resulting bit mask. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpistro(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRI / PCMPISTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// \returns Returns bit 0 of the resulting bit mask. +#define _mm_cmpistro(A, B, M) \ + ((int)__builtin_ia32_pcmpistrio128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the length of the string in \a A is less than +/// the maximum, otherwise, returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpistrs(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRI / PCMPISTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// \returns Returns 1 if the length of the string in \a A is less than the +/// maximum, otherwise, returns 0. +#define _mm_cmpistrs(A, B, M) \ + ((int)__builtin_ia32_pcmpistris128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with implicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the length of the string in \a B is less than +/// the maximum, otherwise, returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpistrz(__m128i A, __m128i B, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPISTRI / PCMPISTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. +/// \returns Returns 1 if the length of the string in \a B is less than the +/// maximum, otherwise, returns 0. +#define _mm_cmpistrz(A, B, M) \ + ((int)__builtin_ia32_pcmpistriz128((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the bit mask is zero and the length of the +/// string in \a B is the maximum, otherwise, returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpestra(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRI / PCMPESTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. +/// \returns Returns 1 if the bit mask is zero and the length of the string in +/// \a B is the maximum, otherwise, returns 0. +#define _mm_cmpestra(A, LA, B, LB, M) \ + ((int)__builtin_ia32_pcmpestria128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the resulting mask is non-zero, otherwise, +/// returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpestrc(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRI / PCMPESTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// \returns Returns 1 if the resulting mask is non-zero, otherwise, returns 0. +#define _mm_cmpestrc(A, LA, B, LB, M) \ + ((int)__builtin_ia32_pcmpestric128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns bit 0 of the resulting bit mask. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpestro(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRI / PCMPESTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. +/// \returns Returns bit 0 of the resulting bit mask. +#define _mm_cmpestro(A, LA, B, LB, M) \ + ((int)__builtin_ia32_pcmpestrio128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the length of the string in \a A is less than +/// the maximum, otherwise, returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpestrs(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRI / PCMPESTRI +/// instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement in the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. \n +/// \returns Returns 1 if the length of the string in \a A is less than the +/// maximum, otherwise, returns 0. +#define _mm_cmpestrs(A, LA, B, LB, M) \ + ((int)__builtin_ia32_pcmpestris128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/// Uses the immediate operand \a M to perform a comparison of string +/// data with explicitly defined lengths that is contained in source operands +/// \a A and \a B. Returns 1 if the length of the string in \a B is less than +/// the maximum, otherwise, returns 0. +/// +/// \headerfile +/// +/// \code +/// int _mm_cmpestrz(__m128i A, int LA, __m128i B, int LB, const int M); +/// \endcode +/// +/// This intrinsic corresponds to the VPCMPESTRI instruction. +/// +/// \param A +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LA +/// An integer that specifies the length of the string in \a A. +/// \param B +/// A 128-bit integer vector containing one of the source operands to be +/// compared. +/// \param LB +/// An integer that specifies the length of the string in \a B. +/// \param M +/// An 8-bit immediate operand specifying whether the characters are bytes or +/// words and the type of comparison to perform. \n +/// Bits [1:0]: Determine source data format. \n +/// 00: 16 unsigned bytes \n +/// 01: 8 unsigned words \n +/// 10: 16 signed bytes \n +/// 11: 8 signed words \n +/// Bits [3:2]: Determine comparison type and aggregation method. \n +/// 00: Subset: Each character in \a B is compared for equality with all +/// the characters in \a A. \n +/// 01: Ranges: Each character in \a B is compared to \a A. The comparison +/// basis is greater than or equal for even-indexed elements in \a A, +/// and less than or equal for odd-indexed elements in \a A. \n +/// 10: Match: Compare each pair of corresponding characters in \a A and +/// \a B for equality. \n +/// 11: Substring: Search \a B for substring matches of \a A. \n +/// Bits [5:4]: Determine whether to perform a one's complement on the bit +/// mask of the comparison results. \n +/// 00: No effect. \n +/// 01: Negate the bit mask. \n +/// 10: No effect. \n +/// 11: Negate the bit mask only for bits with an index less than or equal +/// to the size of \a A or \a B. +/// \returns Returns 1 if the length of the string in \a B is less than the +/// maximum, otherwise, returns 0. +#define _mm_cmpestrz(A, LA, B, LB, M) \ + ((int)__builtin_ia32_pcmpestriz128((__v16qi)(__m128i)(A), (int)(LA), \ + (__v16qi)(__m128i)(B), (int)(LB), \ + (int)(M))) + +/* SSE4.2 Compare Packed Data -- Greater Than. */ +/// Compares each of the corresponding 64-bit values of the 128-bit +/// integer vectors to determine if the values in the first operand are +/// greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPCMPGTQ / PCMPGTQ instruction. +/// +/// \param __V1 +/// A 128-bit integer vector. +/// \param __V2 +/// A 128-bit integer vector. +/// \returns A 128-bit integer vector containing the comparison results. +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cmpgt_epi64(__m128i __V1, + __m128i __V2) { + return (__m128i)((__v2di)__V1 > (__v2di)__V2); +} + +#undef __DEFAULT_FN_ATTRS + +#include + +#include + +#endif /* __SMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdalign.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdalign.h new file mode 100755 index 0000000..158508e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdalign.h @@ -0,0 +1,24 @@ +/*===---- stdalign.h - Standard header for alignment ------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDALIGN_H +#define __STDALIGN_H + +#if defined(__cplusplus) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L) +#ifndef __cplusplus +#define alignas _Alignas +#define alignof _Alignof +#endif + +#define __alignas_is_defined 1 +#define __alignof_is_defined 1 +#endif /* __STDC_VERSION__ */ + +#endif /* __STDALIGN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdarg.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdarg.h new file mode 100755 index 0000000..6203d7a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdarg.h @@ -0,0 +1,75 @@ +/*===---- stdarg.h - Variable argument handling ----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * This header is designed to be included multiple times. If any of the __need_ + * macros are defined, then only that subset of interfaces are provided. This + * can be useful for POSIX headers that need to not expose all of stdarg.h, but + * need to use some of its interfaces. Otherwise this header provides all of + * the expected interfaces. + * + * When clang modules are enabled, this header is a textual header to support + * the multiple include behavior. As such, it doesn't directly declare anything + * so that it doesn't add duplicate declarations to all of its includers' + * modules. + */ +#if defined(__MVS__) && __has_include_next() +#undef __need___va_list +#undef __need_va_list +#undef __need_va_arg +#undef __need___va_copy +#undef __need_va_copy +#include <__stdarg_header_macro.h> +#include_next + +#else +#if !defined(__need___va_list) && !defined(__need_va_list) && \ + !defined(__need_va_arg) && !defined(__need___va_copy) && \ + !defined(__need_va_copy) +#define __need___va_list +#define __need_va_list +#define __need_va_arg +#define __need___va_copy +/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode + * or -ansi is not specified, since it was not part of C90. + */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) || \ + !defined(__STRICT_ANSI__) +#define __need_va_copy +#endif +#include <__stdarg_header_macro.h> +#endif + +#ifdef __need___va_list +#include <__stdarg___gnuc_va_list.h> +#undef __need___va_list +#endif /* defined(__need___va_list) */ + +#ifdef __need_va_list +#include <__stdarg_va_list.h> +#undef __need_va_list +#endif /* defined(__need_va_list) */ + +#ifdef __need_va_arg +#include <__stdarg_va_arg.h> +#undef __need_va_arg +#endif /* defined(__need_va_arg) */ + +#ifdef __need___va_copy +#include <__stdarg___va_copy.h> +#undef __need___va_copy +#endif /* defined(__need___va_copy) */ + +#ifdef __need_va_copy +#include <__stdarg_va_copy.h> +#undef __need_va_copy +#endif /* defined(__need_va_copy) */ + +#endif /* __MVS__ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdatomic.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdatomic.h new file mode 100755 index 0000000..1991351 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdatomic.h @@ -0,0 +1,204 @@ +/*===---- stdatomic.h - Standard header for atomic types and operations -----=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_STDATOMIC_H +#define __CLANG_STDATOMIC_H + +/* If we're hosted, fall back to the system's stdatomic.h. FreeBSD, for + * example, already has a Clang-compatible stdatomic.h header. + * + * Exclude the MSVC path as well as the MSVC header as of the 14.31.30818 + * explicitly disallows `stdatomic.h` in the C mode via an `#error`. Fallback + * to the clang resource header until that is fully supported. The + * `stdatomic.h` header requires C++23 or newer. + */ +#if __STDC_HOSTED__ && \ + __has_include_next() && \ + (!defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 202002L)) +# include_next +#else + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* 7.17.1 Introduction */ + +#define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE +#endif +#define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __CLANG_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __CLANG_ATOMIC_INT_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE + +/* 7.17.2 Initialization */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L) || \ + defined(__cplusplus) +/* ATOMIC_VAR_INIT was removed in C23, but still remains in C++23. */ +#define ATOMIC_VAR_INIT(value) (value) +#endif + +#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L && \ + __STDC_VERSION__ < 202311L) || \ + (defined(__cplusplus) && __cplusplus >= 202002L)) && \ + !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS) +/* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */ +#pragma clang deprecated(ATOMIC_VAR_INIT) +#endif +#define atomic_init __c11_atomic_init + +/* 7.17.3 Order and consistency */ + +typedef enum memory_order { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +#define kill_dependency(y) (y) + +/* 7.17.4 Fences */ + +/* These should be provided by the libc implementation. */ +void atomic_thread_fence(memory_order); +void atomic_signal_fence(memory_order); + +#define atomic_thread_fence(order) __c11_atomic_thread_fence(order) +#define atomic_signal_fence(order) __c11_atomic_signal_fence(order) + +/* 7.17.5 Lock-free property */ + +#define atomic_is_lock_free(obj) __c11_atomic_is_lock_free(sizeof(*(obj))) + +/* 7.17.6 Atomic integer types */ + +#ifdef __cplusplus +typedef _Atomic(bool) atomic_bool; +#else +typedef _Atomic(_Bool) atomic_bool; +#endif +typedef _Atomic(char) atomic_char; +typedef _Atomic(signed char) atomic_schar; +typedef _Atomic(unsigned char) atomic_uchar; +typedef _Atomic(short) atomic_short; +typedef _Atomic(unsigned short) atomic_ushort; +typedef _Atomic(int) atomic_int; +typedef _Atomic(unsigned int) atomic_uint; +typedef _Atomic(long) atomic_long; +typedef _Atomic(unsigned long) atomic_ulong; +typedef _Atomic(long long) atomic_llong; +typedef _Atomic(unsigned long long) atomic_ullong; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +typedef _Atomic(unsigned char) atomic_char8_t; +#endif +typedef _Atomic(uint_least16_t) atomic_char16_t; +typedef _Atomic(uint_least32_t) atomic_char32_t; +typedef _Atomic(wchar_t) atomic_wchar_t; +typedef _Atomic(int_least8_t) atomic_int_least8_t; +typedef _Atomic(uint_least8_t) atomic_uint_least8_t; +typedef _Atomic(int_least16_t) atomic_int_least16_t; +typedef _Atomic(uint_least16_t) atomic_uint_least16_t; +typedef _Atomic(int_least32_t) atomic_int_least32_t; +typedef _Atomic(uint_least32_t) atomic_uint_least32_t; +typedef _Atomic(int_least64_t) atomic_int_least64_t; +typedef _Atomic(uint_least64_t) atomic_uint_least64_t; +typedef _Atomic(int_fast8_t) atomic_int_fast8_t; +typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; +typedef _Atomic(int_fast16_t) atomic_int_fast16_t; +typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; +typedef _Atomic(int_fast32_t) atomic_int_fast32_t; +typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; +typedef _Atomic(int_fast64_t) atomic_int_fast64_t; +typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; +typedef _Atomic(intptr_t) atomic_intptr_t; +typedef _Atomic(uintptr_t) atomic_uintptr_t; +typedef _Atomic(size_t) atomic_size_t; +typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; +typedef _Atomic(intmax_t) atomic_intmax_t; +typedef _Atomic(uintmax_t) atomic_uintmax_t; + +/* 7.17.7 Operations on atomic types */ + +#define atomic_store(object, desired) __c11_atomic_store(object, desired, __ATOMIC_SEQ_CST) +#define atomic_store_explicit __c11_atomic_store + +#define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST) +#define atomic_load_explicit __c11_atomic_load + +#define atomic_exchange(object, desired) __c11_atomic_exchange(object, desired, __ATOMIC_SEQ_CST) +#define atomic_exchange_explicit __c11_atomic_exchange + +#define atomic_compare_exchange_strong(object, expected, desired) __c11_atomic_compare_exchange_strong(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) +#define atomic_compare_exchange_strong_explicit __c11_atomic_compare_exchange_strong + +#define atomic_compare_exchange_weak(object, expected, desired) __c11_atomic_compare_exchange_weak(object, expected, desired, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) +#define atomic_compare_exchange_weak_explicit __c11_atomic_compare_exchange_weak + +#define atomic_fetch_add(object, operand) __c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST) +#define atomic_fetch_add_explicit __c11_atomic_fetch_add + +#define atomic_fetch_sub(object, operand) __c11_atomic_fetch_sub(object, operand, __ATOMIC_SEQ_CST) +#define atomic_fetch_sub_explicit __c11_atomic_fetch_sub + +#define atomic_fetch_or(object, operand) __c11_atomic_fetch_or(object, operand, __ATOMIC_SEQ_CST) +#define atomic_fetch_or_explicit __c11_atomic_fetch_or + +#define atomic_fetch_xor(object, operand) __c11_atomic_fetch_xor(object, operand, __ATOMIC_SEQ_CST) +#define atomic_fetch_xor_explicit __c11_atomic_fetch_xor + +#define atomic_fetch_and(object, operand) __c11_atomic_fetch_and(object, operand, __ATOMIC_SEQ_CST) +#define atomic_fetch_and_explicit __c11_atomic_fetch_and + +/* 7.17.8 Atomic flag type and operations */ + +typedef struct atomic_flag { atomic_bool _Value; } atomic_flag; + +#ifdef __cplusplus +#define ATOMIC_FLAG_INIT {false} +#else +#define ATOMIC_FLAG_INIT { 0 } +#endif + +/* These should be provided by the libc implementation. */ +#ifdef __cplusplus +bool atomic_flag_test_and_set(volatile atomic_flag *); +bool atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order); +#else +_Bool atomic_flag_test_and_set(volatile atomic_flag *); +_Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order); +#endif +void atomic_flag_clear(volatile atomic_flag *); +void atomic_flag_clear_explicit(volatile atomic_flag *, memory_order); + +#define atomic_flag_test_and_set(object) __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST) +#define atomic_flag_test_and_set_explicit(object, order) __c11_atomic_exchange(&(object)->_Value, 1, order) + +#define atomic_flag_clear(object) __c11_atomic_store(&(object)->_Value, 0, __ATOMIC_SEQ_CST) +#define atomic_flag_clear_explicit(object, order) __c11_atomic_store(&(object)->_Value, 0, order) + +#ifdef __cplusplus +} +#endif + +#endif /* __STDC_HOSTED__ */ +#endif /* __CLANG_STDATOMIC_H */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdbool.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdbool.h new file mode 100755 index 0000000..dfaad2b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdbool.h @@ -0,0 +1,39 @@ +/*===---- stdbool.h - Standard header for booleans -------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDBOOL_H +#define __STDBOOL_H + +#define __bool_true_false_are_defined 1 + +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L +/* FIXME: We should be issuing a deprecation warning here, but cannot yet due + * to system headers which include this header file unconditionally. + */ +#elif !defined(__cplusplus) +#define bool _Bool +#define true 1 +#define false 0 +#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) +/* Define _Bool as a GNU extension. */ +#define _Bool bool +#if defined(__cplusplus) && __cplusplus < 201103L +/* For C++98, define bool, false, true as a GNU extension. */ +#define bool bool +#define false false +#define true true +#endif +#endif + +#endif /* __MVS__ */ +#endif /* __STDBOOL_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdckdint.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdckdint.h new file mode 100755 index 0000000..20bc34f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdckdint.h @@ -0,0 +1,42 @@ +/*===---- stdckdint.h - Standard header for checking integer----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDCKDINT_H +#define __STDCKDINT_H + +/* If we're hosted, fall back to the system's stdckdint.h. FreeBSD, for + * example, already has a Clang-compatible stdckdint.h header. + * + * The `stdckdint.h` header requires C 23 or newer. + */ +#if __STDC_HOSTED__ && __has_include_next() +#include_next +#else + +/* C23 7.20.1 Defines several macros for performing checked integer arithmetic*/ + +#define __STDC_VERSION_STDCKDINT_H__ 202311L + +// Both A and B shall be any integer type other than "plain" char, bool, a bit- +// precise integer type, or an enumerated type, and they need not be the same. + +// R shall be a modifiable lvalue of any integer type other than "plain" char, +// bool, a bit-precise integer type, or an enumerated type. It shouldn't be +// short type, either. Otherwise, it may be unable to hold two the result of +// operating two 'int's. + +// A diagnostic message will be produced if A or B are not suitable integer +// types, or if R is not a modifiable lvalue of a suitable integer type or R +// is short type. +#define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R)) +#define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R)) +#define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R)) + +#endif /* __STDC_HOSTED__ */ +#endif /* __STDCKDINT_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdcountof.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdcountof.h new file mode 100755 index 0000000..5714e6d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdcountof.h @@ -0,0 +1,15 @@ +/*===---- stdcountof.h - Standard header for countof -----------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDCOUNTOF_H +#define __STDCOUNTOF_H + +#define countof _Countof + +#endif /* __STDCOUNTOF_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stddef.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stddef.h new file mode 100755 index 0000000..99b275a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stddef.h @@ -0,0 +1,139 @@ +/*===---- stddef.h - Basic type definitions --------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* + * This header is designed to be included multiple times. If any of the __need_ + * macros are defined, then only that subset of interfaces are provided. This + * can be useful for POSIX headers that need to not expose all of stddef.h, but + * need to use some of its interfaces. Otherwise this header provides all of + * the expected interfaces. + * + * When clang modules are enabled, this header is a textual header to support + * the multiple include behavior. As such, it doesn't directly declare anything + * so that it doesn't add duplicate declarations to all of its includers' + * modules. + */ +#if defined(__MVS__) && __has_include_next() +#undef __need_ptrdiff_t +#undef __need_size_t +#undef __need_rsize_t +#undef __need_wchar_t +#undef __need_NULL +#undef __need_nullptr_t +#undef __need_unreachable +#undef __need_max_align_t +#undef __need_offsetof +#undef __need_wint_t +#include <__stddef_header_macro.h> +#include_next + +#else + +#if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \ + !defined(__need_rsize_t) && !defined(__need_wchar_t) && \ + !defined(__need_NULL) && !defined(__need_nullptr_t) && \ + !defined(__need_unreachable) && !defined(__need_max_align_t) && \ + !defined(__need_offsetof) && !defined(__need_wint_t) +#define __need_ptrdiff_t +#define __need_size_t +/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is + * enabled. */ +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 +#define __need_rsize_t +#endif +#define __need_wchar_t +#if !defined(__STDDEF_H) || __has_feature(modules) +/* + * __stddef_null.h is special when building without modules: if __need_NULL is + * set, then it will unconditionally redefine NULL. To avoid stepping on client + * definitions of NULL, __need_NULL should only be set the first time this + * header is included, that is when __STDDEF_H is not defined. However, when + * building with modules, this header is a textual header and needs to + * unconditionally include __stdef_null.h to support multiple submodules + * exporting _Builtin_stddef.null. Take module SM with submodules A and B, whose + * headers both include stddef.h When SM.A builds, __STDDEF_H will be defined. + * When SM.B builds, the definition from SM.A will leak when building without + * local submodule visibility. stddef.h wouldn't include __stddef_null.h, and + * SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't + * export NULL as expected. When building with modules, always include + * __stddef_null.h so that everything works as expected. + */ +#define __need_NULL +#endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + defined(__cplusplus) +#define __need_nullptr_t +#endif +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define __need_unreachable +#endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) +#define __need_max_align_t +#endif +#define __need_offsetof +/* wint_t is provided by and not . It's here + * for compatibility, but must be explicitly requested. Therefore + * __need_wint_t is intentionally not defined here. */ +#include <__stddef_header_macro.h> +#endif + +#if defined(__need_ptrdiff_t) +#include <__stddef_ptrdiff_t.h> +#undef __need_ptrdiff_t +#endif /* defined(__need_ptrdiff_t) */ + +#if defined(__need_size_t) +#include <__stddef_size_t.h> +#undef __need_size_t +#endif /*defined(__need_size_t) */ + +#if defined(__need_rsize_t) +#include <__stddef_rsize_t.h> +#undef __need_rsize_t +#endif /* defined(__need_rsize_t) */ + +#if defined(__need_wchar_t) +#include <__stddef_wchar_t.h> +#undef __need_wchar_t +#endif /* defined(__need_wchar_t) */ + +#if defined(__need_NULL) +#include <__stddef_null.h> +#undef __need_NULL +#endif /* defined(__need_NULL) */ + +#if defined(__need_nullptr_t) +#include <__stddef_nullptr_t.h> +#undef __need_nullptr_t +#endif /* defined(__need_nullptr_t) */ + +#if defined(__need_unreachable) +#include <__stddef_unreachable.h> +#undef __need_unreachable +#endif /* defined(__need_unreachable) */ + +#if defined(__need_max_align_t) +#include <__stddef_max_align_t.h> +#undef __need_max_align_t +#endif /* defined(__need_max_align_t) */ + +#if defined(__need_offsetof) +#include <__stddef_offsetof.h> +#undef __need_offsetof +#endif /* defined(__need_offsetof) */ + +/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use +__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ +#if defined(__need_wint_t) +#include <__stddef_wint_t.h> +#undef __need_wint_t +#endif /* __need_wint_t */ + +#endif /* __MVS__ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdint.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdint.h new file mode 100755 index 0000000..96c2cca --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdint.h @@ -0,0 +1,844 @@ +/*===---- stdint.h - Standard header for sized integer types --------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_STDINT_H +// AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T +// is defined until an inclusion of it without _STD_TYPES_T occurs, in which +// case the header guard macro is defined. +#if !defined(_AIX) || !defined(_STD_TYPES_T) || !defined(__STDC_HOSTED__) +#define __CLANG_STDINT_H +#endif + +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +/* If we're hosted, fall back to the system's stdint.h, which might have + * additional definitions. + */ +#if __STDC_HOSTED__ && __has_include_next() + +// C99 7.18.3 Limits of other integer types +// +// Footnote 219, 220: C++ implementations should define these macros only when +// __STDC_LIMIT_MACROS is defined before is included. +// +// Footnote 222: C++ implementations should define these macros only when +// __STDC_CONSTANT_MACROS is defined before is included. +// +// C++11 [cstdint.syn]p2: +// +// The macros defined by are provided unconditionally. In particular, +// the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in +// footnotes 219, 220, and 222 in the C standard) play no role in C++. +// +// C11 removed the problematic footnotes. +// +// Work around this inconsistency by always defining those macros in C++ mode, +// so that a C library implementation which follows the C99 standard can be +// used in C++. +# ifdef __cplusplus +# if !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG +# endif +# if !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG +# endif +# endif + +# include_next + +# ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG +# undef __STDC_LIMIT_MACROS +# undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG +# endif +# ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG +# undef __STDC_CONSTANT_MACROS +# undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG +# endif + +#else + +/* C99 7.18.1.1 Exact-width integer types. + * C99 7.18.1.2 Minimum-width integer types. + * C99 7.18.1.3 Fastest minimum-width integer types. + * + * The standard requires that exact-width type be defined for 8-, 16-, 32-, and + * 64-bit types if they are implemented. Other exact width types are optional. + * This implementation defines an exact-width types for every integer width + * that is represented in the standard integer types. + * + * The standard also requires minimum-width types be defined for 8-, 16-, 32-, + * and 64-bit widths regardless of whether there are corresponding exact-width + * types. + * + * To accommodate targets that are missing types that are exactly 8, 16, 32, or + * 64 bits wide, this implementation takes an approach of cascading + * redefinitions, redefining __int_leastN_t to successively smaller exact-width + * types. It is therefore important that the types are defined in order of + * descending widths. + * + * We currently assume that the minimum-width types and the fastest + * minimum-width types are the same. This is allowed by the standard, but is + * suboptimal. + * + * In violation of the standard, some targets do not implement a type that is + * wide enough to represent all of the required widths (8-, 16-, 32-, 64-bit). + * To accommodate these targets, a required minimum-width type is only + * defined if there exists an exact-width type of equal or greater width. + */ + +#ifdef __INT64_TYPE__ +# ifndef __int8_t_defined /* glibc sys/types.h also defines int64_t*/ +typedef __INT64_TYPE__ int64_t; +# endif /* __int8_t_defined */ +typedef __UINT64_TYPE__ uint64_t; +# undef __int_least64_t +# define __int_least64_t int64_t +# undef __uint_least64_t +# define __uint_least64_t uint64_t +# undef __int_least32_t +# define __int_least32_t int64_t +# undef __uint_least32_t +# define __uint_least32_t uint64_t +# undef __int_least16_t +# define __int_least16_t int64_t +# undef __uint_least16_t +# define __uint_least16_t uint64_t +# undef __int_least8_t +# define __int_least8_t int64_t +# undef __uint_least8_t +# define __uint_least8_t uint64_t +#endif /* __INT64_TYPE__ */ + +#ifdef __int_least64_t +typedef __int_least64_t int_least64_t; +typedef __uint_least64_t uint_least64_t; +typedef __int_least64_t int_fast64_t; +typedef __uint_least64_t uint_fast64_t; +#endif /* __int_least64_t */ + +#ifdef __INT56_TYPE__ +typedef __INT56_TYPE__ int56_t; +typedef __UINT56_TYPE__ uint56_t; +typedef int56_t int_least56_t; +typedef uint56_t uint_least56_t; +typedef int56_t int_fast56_t; +typedef uint56_t uint_fast56_t; +# undef __int_least32_t +# define __int_least32_t int56_t +# undef __uint_least32_t +# define __uint_least32_t uint56_t +# undef __int_least16_t +# define __int_least16_t int56_t +# undef __uint_least16_t +# define __uint_least16_t uint56_t +# undef __int_least8_t +# define __int_least8_t int56_t +# undef __uint_least8_t +# define __uint_least8_t uint56_t +#endif /* __INT56_TYPE__ */ + + +#ifdef __INT48_TYPE__ +typedef __INT48_TYPE__ int48_t; +typedef __UINT48_TYPE__ uint48_t; +typedef int48_t int_least48_t; +typedef uint48_t uint_least48_t; +typedef int48_t int_fast48_t; +typedef uint48_t uint_fast48_t; +# undef __int_least32_t +# define __int_least32_t int48_t +# undef __uint_least32_t +# define __uint_least32_t uint48_t +# undef __int_least16_t +# define __int_least16_t int48_t +# undef __uint_least16_t +# define __uint_least16_t uint48_t +# undef __int_least8_t +# define __int_least8_t int48_t +# undef __uint_least8_t +# define __uint_least8_t uint48_t +#endif /* __INT48_TYPE__ */ + + +#ifdef __INT40_TYPE__ +typedef __INT40_TYPE__ int40_t; +typedef __UINT40_TYPE__ uint40_t; +typedef int40_t int_least40_t; +typedef uint40_t uint_least40_t; +typedef int40_t int_fast40_t; +typedef uint40_t uint_fast40_t; +# undef __int_least32_t +# define __int_least32_t int40_t +# undef __uint_least32_t +# define __uint_least32_t uint40_t +# undef __int_least16_t +# define __int_least16_t int40_t +# undef __uint_least16_t +# define __uint_least16_t uint40_t +# undef __int_least8_t +# define __int_least8_t int40_t +# undef __uint_least8_t +# define __uint_least8_t uint40_t +#endif /* __INT40_TYPE__ */ + + +#ifdef __INT32_TYPE__ + +# ifndef __int8_t_defined /* glibc sys/types.h also defines int32_t*/ +typedef __INT32_TYPE__ int32_t; +# endif /* __int8_t_defined */ + +# ifndef __uint32_t_defined /* more glibc compatibility */ +# define __uint32_t_defined +typedef __UINT32_TYPE__ uint32_t; +# endif /* __uint32_t_defined */ + +# undef __int_least32_t +# define __int_least32_t int32_t +# undef __uint_least32_t +# define __uint_least32_t uint32_t +# undef __int_least16_t +# define __int_least16_t int32_t +# undef __uint_least16_t +# define __uint_least16_t uint32_t +# undef __int_least8_t +# define __int_least8_t int32_t +# undef __uint_least8_t +# define __uint_least8_t uint32_t +#endif /* __INT32_TYPE__ */ + +#ifdef __int_least32_t +typedef __int_least32_t int_least32_t; +typedef __uint_least32_t uint_least32_t; +typedef __int_least32_t int_fast32_t; +typedef __uint_least32_t uint_fast32_t; +#endif /* __int_least32_t */ + +#ifdef __INT24_TYPE__ +typedef __INT24_TYPE__ int24_t; +typedef __UINT24_TYPE__ uint24_t; +typedef int24_t int_least24_t; +typedef uint24_t uint_least24_t; +typedef int24_t int_fast24_t; +typedef uint24_t uint_fast24_t; +# undef __int_least16_t +# define __int_least16_t int24_t +# undef __uint_least16_t +# define __uint_least16_t uint24_t +# undef __int_least8_t +# define __int_least8_t int24_t +# undef __uint_least8_t +# define __uint_least8_t uint24_t +#endif /* __INT24_TYPE__ */ + +#ifdef __INT16_TYPE__ +#ifndef __int8_t_defined /* glibc sys/types.h also defines int16_t*/ +typedef __INT16_TYPE__ int16_t; +#endif /* __int8_t_defined */ +typedef __UINT16_TYPE__ uint16_t; +# undef __int_least16_t +# define __int_least16_t int16_t +# undef __uint_least16_t +# define __uint_least16_t uint16_t +# undef __int_least8_t +# define __int_least8_t int16_t +# undef __uint_least8_t +# define __uint_least8_t uint16_t +#endif /* __INT16_TYPE__ */ + +#ifdef __int_least16_t +typedef __int_least16_t int_least16_t; +typedef __uint_least16_t uint_least16_t; +typedef __int_least16_t int_fast16_t; +typedef __uint_least16_t uint_fast16_t; +#endif /* __int_least16_t */ + + +#ifdef __INT8_TYPE__ +#ifndef __int8_t_defined /* glibc sys/types.h also defines int8_t*/ +typedef __INT8_TYPE__ int8_t; +#endif /* __int8_t_defined */ +typedef __UINT8_TYPE__ uint8_t; +# undef __int_least8_t +# define __int_least8_t int8_t +# undef __uint_least8_t +# define __uint_least8_t uint8_t +#endif /* __INT8_TYPE__ */ + +#ifdef __int_least8_t +typedef __int_least8_t int_least8_t; +typedef __uint_least8_t uint_least8_t; +typedef __int_least8_t int_fast8_t; +typedef __uint_least8_t uint_fast8_t; +#endif /* __int_least8_t */ + +/* prevent glibc sys/types.h from defining conflicting types */ +#ifndef __int8_t_defined +# define __int8_t_defined +#endif /* __int8_t_defined */ + +/* C99 7.18.1.4 Integer types capable of holding object pointers. + */ +#define __stdint_join3(a,b,c) a ## b ## c + +#ifndef _INTPTR_T +#ifndef __intptr_t_defined +typedef __INTPTR_TYPE__ intptr_t; +#define __intptr_t_defined +#define _INTPTR_T +#endif +#endif + +#ifndef _UINTPTR_T +typedef __UINTPTR_TYPE__ uintptr_t; +#define _UINTPTR_T +#endif + +/* C99 7.18.1.5 Greatest-width integer types. + */ +typedef __INTMAX_TYPE__ intmax_t; +typedef __UINTMAX_TYPE__ uintmax_t; + +/* C99 7.18.4 Macros for minimum-width integer constants. + * + * The standard requires that integer constant macros be defined for all the + * minimum-width types defined above. As 8-, 16-, 32-, and 64-bit minimum-width + * types are required, the corresponding integer constant macros are defined + * here. This implementation also defines minimum-width types for every other + * integer width that the target implements, so corresponding macros are + * defined below, too. + * + * Note that C++ should not check __STDC_CONSTANT_MACROS here, contrary to the + * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + */ + +#ifdef __int_least64_t +#define INT64_C(v) __INT64_C(v) +#define UINT64_C(v) __UINT64_C(v) +#endif /* __int_least64_t */ + + +#ifdef __INT56_TYPE__ +#define INT56_C(v) __INT56_C(v) +#define UINT56_C(v) __UINT56_C(v) +#endif /* __INT56_TYPE__ */ + + +#ifdef __INT48_TYPE__ +#define INT48_C(v) __INT48_C(v) +#define UINT48_C(v) __UINT48_C(v) +#endif /* __INT48_TYPE__ */ + + +#ifdef __INT40_TYPE__ +#define INT40_C(v) __INT40_C(v) +#define UINT40_C(v) __UINT40_C(v) +#endif /* __INT40_TYPE__ */ + + +#ifdef __int_least32_t +#define INT32_C(v) __INT32_C(v) +#define UINT32_C(v) __UINT32_C(v) +#endif /* __int_least32_t */ + + +#ifdef __INT24_TYPE__ +#define INT24_C(v) __INT24_C(v) +#define UINT24_C(v) __UINT24_C(v) +#endif /* __INT24_TYPE__ */ + + +#ifdef __int_least16_t +#define INT16_C(v) __INT16_C(v) +#define UINT16_C(v) __UINT16_C(v) +#endif /* __int_least16_t */ + + +#ifdef __int_least8_t +#define INT8_C(v) __INT8_C(v) +#define UINT8_C(v) __UINT8_C(v) +#endif /* __int_least8_t */ + + +/* C99 7.18.2.1 Limits of exact-width integer types. + * C99 7.18.2.2 Limits of minimum-width integer types. + * C99 7.18.2.3 Limits of fastest minimum-width integer types. + * + * The presence of limit macros are completely optional in C99. This + * implementation defines limits for all of the types (exact- and + * minimum-width) that it defines above, using the limits of the minimum-width + * type for any types that do not have exact-width representations. + * + * As in the type definitions, this section takes an approach of + * successive-shrinking to determine which limits to use for the standard (8, + * 16, 32, 64) bit widths when they don't have exact representations. It is + * therefore important that the definitions be kept in order of decending + * widths. + * + * Note that C++ should not check __STDC_LIMIT_MACROS here, contrary to the + * claims of the C standard (see C++ 18.3.1p2, [cstdint.syn]). + */ + +#ifdef __INT64_TYPE__ +# define INT64_MAX INT64_C( 9223372036854775807) +# define INT64_MIN (-INT64_C( 9223372036854775807)-1) +# define UINT64_MAX UINT64_C(18446744073709551615) + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT64_WIDTH 64 +# define INT64_WIDTH UINT64_WIDTH + +# define __UINT_LEAST64_WIDTH UINT64_WIDTH +# undef __UINT_LEAST32_WIDTH +# define __UINT_LEAST32_WIDTH UINT64_WIDTH +# undef __UINT_LEAST16_WIDTH +# define __UINT_LEAST16_WIDTH UINT64_WIDTH +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT64_MAX +#endif /* __STDC_VERSION__ */ + +# define __INT_LEAST64_MIN INT64_MIN +# define __INT_LEAST64_MAX INT64_MAX +# define __UINT_LEAST64_MAX UINT64_MAX +# undef __INT_LEAST32_MIN +# define __INT_LEAST32_MIN INT64_MIN +# undef __INT_LEAST32_MAX +# define __INT_LEAST32_MAX INT64_MAX +# undef __UINT_LEAST32_MAX +# define __UINT_LEAST32_MAX UINT64_MAX +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT64_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT64_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT64_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT64_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT64_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT64_MAX +#endif /* __INT64_TYPE__ */ + +#ifdef __INT_LEAST64_MIN +# define INT_LEAST64_MIN __INT_LEAST64_MIN +# define INT_LEAST64_MAX __INT_LEAST64_MAX +# define UINT_LEAST64_MAX __UINT_LEAST64_MAX +# define INT_FAST64_MIN __INT_LEAST64_MIN +# define INT_FAST64_MAX __INT_LEAST64_MAX +# define UINT_FAST64_MAX __UINT_LEAST64_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT_LEAST64_WIDTH __UINT_LEAST64_WIDTH +# define INT_LEAST64_WIDTH UINT_LEAST64_WIDTH +# define UINT_FAST64_WIDTH __UINT_LEAST64_WIDTH +# define INT_FAST64_WIDTH UINT_FAST64_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST64_MIN */ + + +#ifdef __INT56_TYPE__ +# define INT56_MAX INT56_C(36028797018963967) +# define INT56_MIN (-INT56_C(36028797018963967)-1) +# define UINT56_MAX UINT56_C(72057594037927935) +# define INT_LEAST56_MIN INT56_MIN +# define INT_LEAST56_MAX INT56_MAX +# define UINT_LEAST56_MAX UINT56_MAX +# define INT_FAST56_MIN INT56_MIN +# define INT_FAST56_MAX INT56_MAX +# define UINT_FAST56_MAX UINT56_MAX + +# undef __INT_LEAST32_MIN +# define __INT_LEAST32_MIN INT56_MIN +# undef __INT_LEAST32_MAX +# define __INT_LEAST32_MAX INT56_MAX +# undef __UINT_LEAST32_MAX +# define __UINT_LEAST32_MAX UINT56_MAX +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT56_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT56_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT56_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT56_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT56_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT56_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT56_WIDTH 56 +# define INT56_WIDTH UINT56_WIDTH +# define UINT_LEAST56_WIDTH UINT56_WIDTH +# define INT_LEAST56_WIDTH UINT_LEAST56_WIDTH +# define UINT_FAST56_WIDTH UINT56_WIDTH +# define INT_FAST56_WIDTH UINT_FAST56_WIDTH +# undef __UINT_LEAST32_WIDTH +# define __UINT_LEAST32_WIDTH UINT56_WIDTH +# undef __UINT_LEAST16_WIDTH +# define __UINT_LEAST16_WIDTH UINT56_WIDTH +# undef __UINT_LEAST8_WIDTH +# define __UINT_LEAST8_WIDTH UINT56_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT56_TYPE__ */ + + +#ifdef __INT48_TYPE__ +# define INT48_MAX INT48_C(140737488355327) +# define INT48_MIN (-INT48_C(140737488355327)-1) +# define UINT48_MAX UINT48_C(281474976710655) +# define INT_LEAST48_MIN INT48_MIN +# define INT_LEAST48_MAX INT48_MAX +# define UINT_LEAST48_MAX UINT48_MAX +# define INT_FAST48_MIN INT48_MIN +# define INT_FAST48_MAX INT48_MAX +# define UINT_FAST48_MAX UINT48_MAX + +# undef __INT_LEAST32_MIN +# define __INT_LEAST32_MIN INT48_MIN +# undef __INT_LEAST32_MAX +# define __INT_LEAST32_MAX INT48_MAX +# undef __UINT_LEAST32_MAX +# define __UINT_LEAST32_MAX UINT48_MAX +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT48_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT48_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT48_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT48_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT48_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT48_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define UINT48_WIDTH 48 +#define INT48_WIDTH UINT48_WIDTH +#define UINT_LEAST48_WIDTH UINT48_WIDTH +#define INT_LEAST48_WIDTH UINT_LEAST48_WIDTH +#define UINT_FAST48_WIDTH UINT48_WIDTH +#define INT_FAST48_WIDTH UINT_FAST48_WIDTH +#undef __UINT_LEAST32_WIDTH +#define __UINT_LEAST32_WIDTH UINT48_WIDTH +# undef __UINT_LEAST16_WIDTH +#define __UINT_LEAST16_WIDTH UINT48_WIDTH +# undef __UINT_LEAST8_WIDTH +#define __UINT_LEAST8_WIDTH UINT48_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT48_TYPE__ */ + + +#ifdef __INT40_TYPE__ +# define INT40_MAX INT40_C(549755813887) +# define INT40_MIN (-INT40_C(549755813887)-1) +# define UINT40_MAX UINT40_C(1099511627775) +# define INT_LEAST40_MIN INT40_MIN +# define INT_LEAST40_MAX INT40_MAX +# define UINT_LEAST40_MAX UINT40_MAX +# define INT_FAST40_MIN INT40_MIN +# define INT_FAST40_MAX INT40_MAX +# define UINT_FAST40_MAX UINT40_MAX + +# undef __INT_LEAST32_MIN +# define __INT_LEAST32_MIN INT40_MIN +# undef __INT_LEAST32_MAX +# define __INT_LEAST32_MAX INT40_MAX +# undef __UINT_LEAST32_MAX +# define __UINT_LEAST32_MAX UINT40_MAX +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT40_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT40_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT40_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT40_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT40_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT40_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT40_WIDTH 40 +# define INT40_WIDTH UINT40_WIDTH +# define UINT_LEAST40_WIDTH UINT40_WIDTH +# define INT_LEAST40_WIDTH UINT_LEAST40_WIDTH +# define UINT_FAST40_WIDTH UINT40_WIDTH +# define INT_FAST40_WIDTH UINT_FAST40_WIDTH +# undef __UINT_LEAST32_WIDTH +# define __UINT_LEAST32_WIDTH UINT40_WIDTH +# undef __UINT_LEAST16_WIDTH +# define __UINT_LEAST16_WIDTH UINT40_WIDTH +# undef __UINT_LEAST8_WIDTH +# define __UINT_LEAST8_WIDTH UINT40_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT40_TYPE__ */ + + +#ifdef __INT32_TYPE__ +# define INT32_MAX INT32_C(2147483647) +# define INT32_MIN (-INT32_C(2147483647)-1) +# define UINT32_MAX UINT32_C(4294967295) + +# undef __INT_LEAST32_MIN +# define __INT_LEAST32_MIN INT32_MIN +# undef __INT_LEAST32_MAX +# define __INT_LEAST32_MAX INT32_MAX +# undef __UINT_LEAST32_MAX +# define __UINT_LEAST32_MAX UINT32_MAX +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT32_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT32_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT32_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT32_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT32_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT32_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT32_WIDTH 32 +# define INT32_WIDTH UINT32_WIDTH +# undef __UINT_LEAST32_WIDTH +# define __UINT_LEAST32_WIDTH UINT32_WIDTH +# undef __UINT_LEAST16_WIDTH +# define __UINT_LEAST16_WIDTH UINT32_WIDTH +# undef __UINT_LEAST8_WIDTH +# define __UINT_LEAST8_WIDTH UINT32_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT32_TYPE__ */ + +#ifdef __INT_LEAST32_MIN +# define INT_LEAST32_MIN __INT_LEAST32_MIN +# define INT_LEAST32_MAX __INT_LEAST32_MAX +# define UINT_LEAST32_MAX __UINT_LEAST32_MAX +# define INT_FAST32_MIN __INT_LEAST32_MIN +# define INT_FAST32_MAX __INT_LEAST32_MAX +# define UINT_FAST32_MAX __UINT_LEAST32_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT_LEAST32_WIDTH __UINT_LEAST32_WIDTH +# define INT_LEAST32_WIDTH UINT_LEAST32_WIDTH +# define UINT_FAST32_WIDTH __UINT_LEAST32_WIDTH +# define INT_FAST32_WIDTH UINT_FAST32_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST32_MIN */ + + +#ifdef __INT24_TYPE__ +# define INT24_MAX INT24_C(8388607) +# define INT24_MIN (-INT24_C(8388607)-1) +# define UINT24_MAX UINT24_C(16777215) +# define INT_LEAST24_MIN INT24_MIN +# define INT_LEAST24_MAX INT24_MAX +# define UINT_LEAST24_MAX UINT24_MAX +# define INT_FAST24_MIN INT24_MIN +# define INT_FAST24_MAX INT24_MAX +# define UINT_FAST24_MAX UINT24_MAX + +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT24_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT24_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT24_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT24_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT24_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT24_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT24_WIDTH 24 +# define INT24_WIDTH UINT24_WIDTH +# define UINT_LEAST24_WIDTH UINT24_WIDTH +# define INT_LEAST24_WIDTH UINT_LEAST24_WIDTH +# define UINT_FAST24_WIDTH UINT24_WIDTH +# define INT_FAST24_WIDTH UINT_FAST24_WIDTH +# undef __UINT_LEAST16_WIDTH +# define __UINT_LEAST16_WIDTH UINT24_WIDTH +# undef __UINT_LEAST8_WIDTH +# define __UINT_LEAST8_WIDTH UINT24_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT24_TYPE__ */ + + +#ifdef __INT16_TYPE__ +#define INT16_MAX INT16_C(32767) +#define INT16_MIN (-INT16_C(32767)-1) +#define UINT16_MAX UINT16_C(65535) + +# undef __INT_LEAST16_MIN +# define __INT_LEAST16_MIN INT16_MIN +# undef __INT_LEAST16_MAX +# define __INT_LEAST16_MAX INT16_MAX +# undef __UINT_LEAST16_MAX +# define __UINT_LEAST16_MAX UINT16_MAX +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT16_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT16_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT16_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT16_WIDTH 16 +# define INT16_WIDTH UINT16_WIDTH +# undef __UINT_LEAST16_WIDTH +# define __UINT_LEAST16_WIDTH UINT16_WIDTH +# undef __UINT_LEAST8_WIDTH +# define __UINT_LEAST8_WIDTH UINT16_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT16_TYPE__ */ + +#ifdef __INT_LEAST16_MIN +# define INT_LEAST16_MIN __INT_LEAST16_MIN +# define INT_LEAST16_MAX __INT_LEAST16_MAX +# define UINT_LEAST16_MAX __UINT_LEAST16_MAX +# define INT_FAST16_MIN __INT_LEAST16_MIN +# define INT_FAST16_MAX __INT_LEAST16_MAX +# define UINT_FAST16_MAX __UINT_LEAST16_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT_LEAST16_WIDTH __UINT_LEAST16_WIDTH +# define INT_LEAST16_WIDTH UINT_LEAST16_WIDTH +# define UINT_FAST16_WIDTH __UINT_LEAST16_WIDTH +# define INT_FAST16_WIDTH UINT_FAST16_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST16_MIN */ + + +#ifdef __INT8_TYPE__ +# define INT8_MAX INT8_C(127) +# define INT8_MIN (-INT8_C(127)-1) +# define UINT8_MAX UINT8_C(255) + +# undef __INT_LEAST8_MIN +# define __INT_LEAST8_MIN INT8_MIN +# undef __INT_LEAST8_MAX +# define __INT_LEAST8_MAX INT8_MAX +# undef __UINT_LEAST8_MAX +# define __UINT_LEAST8_MAX UINT8_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT8_WIDTH 8 +# define INT8_WIDTH UINT8_WIDTH +# undef __UINT_LEAST8_WIDTH +# define __UINT_LEAST8_WIDTH UINT8_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT8_TYPE__ */ + +#ifdef __INT_LEAST8_MIN +# define INT_LEAST8_MIN __INT_LEAST8_MIN +# define INT_LEAST8_MAX __INT_LEAST8_MAX +# define UINT_LEAST8_MAX __UINT_LEAST8_MAX +# define INT_FAST8_MIN __INT_LEAST8_MIN +# define INT_FAST8_MAX __INT_LEAST8_MAX +# define UINT_FAST8_MAX __UINT_LEAST8_MAX + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +# define UINT_LEAST8_WIDTH __UINT_LEAST8_WIDTH +# define INT_LEAST8_WIDTH UINT_LEAST8_WIDTH +# define UINT_FAST8_WIDTH __UINT_LEAST8_WIDTH +# define INT_FAST8_WIDTH UINT_FAST8_WIDTH +#endif /* __STDC_VERSION__ */ +#endif /* __INT_LEAST8_MIN */ + +/* Some utility macros */ +#define __INTN_MIN(n) __stdint_join3( INT, n, _MIN) +#define __INTN_MAX(n) __stdint_join3( INT, n, _MAX) +#define __UINTN_MAX(n) __stdint_join3(UINT, n, _MAX) +#define __INTN_C(n, v) __stdint_join3( INT, n, _C(v)) +#define __UINTN_C(n, v) __stdint_join3(UINT, n, _C(v)) + +/* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ +/* C99 7.18.3 Limits of other integer types. */ + +#define INTPTR_MIN (-__INTPTR_MAX__-1) +#define INTPTR_MAX __INTPTR_MAX__ +#define UINTPTR_MAX __UINTPTR_MAX__ +#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1) +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#define SIZE_MAX __SIZE_MAX__ + +/* C23 7.22.2.4 Width of integer types capable of holding object pointers. */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +/* NB: The C standard requires that these be the same value, but the compiler + exposes separate internal width macros. */ +#define INTPTR_WIDTH __INTPTR_WIDTH__ +#define UINTPTR_WIDTH __UINTPTR_WIDTH__ +#endif + +/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ + * is enabled. */ +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 +#define RSIZE_MAX (SIZE_MAX >> 1) +#endif + +/* C99 7.18.2.5 Limits of greatest-width integer types. */ +#define INTMAX_MIN (-__INTMAX_MAX__-1) +#define INTMAX_MAX __INTMAX_MAX__ +#define UINTMAX_MAX __UINTMAX_MAX__ + +/* C23 7.22.2.5 Width of greatest-width integer types. */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +/* NB: The C standard requires that these be the same value, but the compiler + exposes separate internal width macros. */ +#define INTMAX_WIDTH __INTMAX_WIDTH__ +#define UINTMAX_WIDTH __UINTMAX_WIDTH__ +#endif + +/* C99 7.18.3 Limits of other integer types. */ +#define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__) +#define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__) +#ifdef __WINT_UNSIGNED__ +# define WINT_MIN __UINTN_C(__WINT_WIDTH__, 0) +# define WINT_MAX __UINTN_MAX(__WINT_WIDTH__) +#else +# define WINT_MIN __INTN_MIN(__WINT_WIDTH__) +# define WINT_MAX __INTN_MAX(__WINT_WIDTH__) +#endif + +#ifndef WCHAR_MAX +# define WCHAR_MAX __WCHAR_MAX__ +#endif +#ifndef WCHAR_MIN +# if __WCHAR_MAX__ == __INTN_MAX(__WCHAR_WIDTH__) +# define WCHAR_MIN __INTN_MIN(__WCHAR_WIDTH__) +# else +# define WCHAR_MIN __UINTN_C(__WCHAR_WIDTH__, 0) +# endif +#endif + +/* 7.18.4.2 Macros for greatest-width integer constants. */ +#define INTMAX_C(v) __INTMAX_C(v) +#define UINTMAX_C(v) __UINTMAX_C(v) + +/* C23 7.22.3.x Width of other integer types. */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__ +#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__ +#define SIZE_WIDTH __SIZE_WIDTH__ +#define WCHAR_WIDTH __WCHAR_WIDTH__ +#define WINT_WIDTH __WINT_WIDTH__ +#endif + +#endif /* __STDC_HOSTED__ */ +#endif /* __MVS__ */ +#endif /* __CLANG_STDINT_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdnoreturn.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdnoreturn.h new file mode 100755 index 0000000..6a9b209 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/stdnoreturn.h @@ -0,0 +1,35 @@ +/*===---- stdnoreturn.h - Standard header for noreturn macro ---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDNORETURN_H +#define __STDNORETURN_H + +#if defined(__MVS__) && __has_include_next() +#include_next +#else + +#define noreturn _Noreturn +#define __noreturn_is_defined 1 + +#endif /* __MVS__ */ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L) && \ + !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS) +/* The noreturn macro is deprecated in C23. We do not mark it as such because + including the header file in C23 is also deprecated and we do not want to + issue a confusing diagnostic for code which includes + followed by code that writes [[noreturn]]. The issue with such code is not + with the attribute, or the use of 'noreturn', but the inclusion of the + header. */ +/* FIXME: We should be issuing a deprecation warning here, but cannot yet due + * to system headers which include this header file unconditionally. + */ +#endif + +#endif /* __STDNORETURN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tbmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tbmintrin.h new file mode 100755 index 0000000..cf92d5a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tbmintrin.h @@ -0,0 +1,128 @@ +/*===---- tbmintrin.h - TBM intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __TBMINTRIN_H +#define __TBMINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("tbm"))) constexpr +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("tbm"))) +#endif + +#define __bextri_u32(a, b) \ + ((unsigned int)__builtin_ia32_bextri_u32((unsigned int)(a), \ + (unsigned int)(b))) + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blcfill_u32(unsigned int __a) { + return __a & (__a + 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blci_u32(unsigned int __a) { + return __a | ~(__a + 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blcic_u32(unsigned int __a) { + return ~__a & (__a + 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blcmsk_u32(unsigned int __a) { + return __a ^ (__a + 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blcs_u32(unsigned int __a) { + return __a | (__a + 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blsfill_u32(unsigned int __a) { + return __a | (__a - 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__blsic_u32(unsigned int __a) { + return ~__a | (__a - 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__t1mskc_u32(unsigned int __a) { + return ~__a | (__a + 1); +} + +static __inline__ unsigned int __DEFAULT_FN_ATTRS +__tzmsk_u32(unsigned int __a) { + return ~__a & (__a - 1); +} + +#ifdef __x86_64__ +#define __bextri_u64(a, b) \ + ((unsigned long long)__builtin_ia32_bextri_u64((unsigned long long)(a), \ + (unsigned long long)(b))) + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blcfill_u64(unsigned long long __a) { + return __a & (__a + 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blci_u64(unsigned long long __a) { + return __a | ~(__a + 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blcic_u64(unsigned long long __a) { + return ~__a & (__a + 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blcmsk_u64(unsigned long long __a) { + return __a ^ (__a + 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blcs_u64(unsigned long long __a) { + return __a | (__a + 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blsfill_u64(unsigned long long __a) { + return __a | (__a - 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__blsic_u64(unsigned long long __a) { + return ~__a | (__a - 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__t1mskc_u64(unsigned long long __a) { + return ~__a | (__a + 1); +} + +static __inline__ unsigned long long __DEFAULT_FN_ATTRS +__tzmsk_u64(unsigned long long __a) { + return ~__a & (__a - 1); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif /* __TBMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tgmath.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tgmath.h new file mode 100755 index 0000000..7acf18b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tgmath.h @@ -0,0 +1,1368 @@ +/*===---- tgmath.h - Standard header for type generic math ----------------===*\ + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * +\*===----------------------------------------------------------------------===*/ + +#ifndef __CLANG_TGMATH_H +#define __CLANG_TGMATH_H + +/* C99 7.22 Type-generic math . */ +#include + +/* + * Allow additional definitions and implementation-defined values on Apple + * platforms. This is done after #include to avoid depcycle conflicts + * between libcxx and darwin in C++ modules builds. + */ +#if defined(__APPLE__) && __STDC_HOSTED__ && __has_include_next() +# include_next +#else + +/* C++ handles type genericity with overloading in math.h. */ +#ifndef __cplusplus +#include + +#define _TG_ATTRSp __attribute__((__overloadable__)) +#define _TG_ATTRS __attribute__((__overloadable__, __always_inline__)) + +// promotion + +typedef void _Argument_type_is_not_arithmetic; +static _Argument_type_is_not_arithmetic __tg_promote(...) + __attribute__((__unavailable__,__overloadable__)); +static double _TG_ATTRSp __tg_promote(int); +static double _TG_ATTRSp __tg_promote(unsigned int); +static double _TG_ATTRSp __tg_promote(long); +static double _TG_ATTRSp __tg_promote(unsigned long); +static double _TG_ATTRSp __tg_promote(long long); +static double _TG_ATTRSp __tg_promote(unsigned long long); +static float _TG_ATTRSp __tg_promote(float); +static double _TG_ATTRSp __tg_promote(double); +static long double _TG_ATTRSp __tg_promote(long double); +static float _Complex _TG_ATTRSp __tg_promote(float _Complex); +static double _Complex _TG_ATTRSp __tg_promote(double _Complex); +static long double _Complex _TG_ATTRSp __tg_promote(long double _Complex); + +#define __tg_promote1(__x) (__typeof__(__tg_promote(__x))) +#define __tg_promote2(__x, __y) (__typeof__(__tg_promote(__x) + \ + __tg_promote(__y))) +#define __tg_promote3(__x, __y, __z) (__typeof__(__tg_promote(__x) + \ + __tg_promote(__y) + \ + __tg_promote(__z))) + +// acos + +static float + _TG_ATTRS + __tg_acos(float __x) {return acosf(__x);} + +static double + _TG_ATTRS + __tg_acos(double __x) {return acos(__x);} + +static long double + _TG_ATTRS + __tg_acos(long double __x) {return acosl(__x);} + +static float _Complex + _TG_ATTRS + __tg_acos(float _Complex __x) {return cacosf(__x);} + +static double _Complex + _TG_ATTRS + __tg_acos(double _Complex __x) {return cacos(__x);} + +static long double _Complex + _TG_ATTRS + __tg_acos(long double _Complex __x) {return cacosl(__x);} + +#undef acos +#define acos(__x) __tg_acos(__tg_promote1((__x))(__x)) + +// asin + +static float + _TG_ATTRS + __tg_asin(float __x) {return asinf(__x);} + +static double + _TG_ATTRS + __tg_asin(double __x) {return asin(__x);} + +static long double + _TG_ATTRS + __tg_asin(long double __x) {return asinl(__x);} + +static float _Complex + _TG_ATTRS + __tg_asin(float _Complex __x) {return casinf(__x);} + +static double _Complex + _TG_ATTRS + __tg_asin(double _Complex __x) {return casin(__x);} + +static long double _Complex + _TG_ATTRS + __tg_asin(long double _Complex __x) {return casinl(__x);} + +#undef asin +#define asin(__x) __tg_asin(__tg_promote1((__x))(__x)) + +// atan + +static float + _TG_ATTRS + __tg_atan(float __x) {return atanf(__x);} + +static double + _TG_ATTRS + __tg_atan(double __x) {return atan(__x);} + +static long double + _TG_ATTRS + __tg_atan(long double __x) {return atanl(__x);} + +static float _Complex + _TG_ATTRS + __tg_atan(float _Complex __x) {return catanf(__x);} + +static double _Complex + _TG_ATTRS + __tg_atan(double _Complex __x) {return catan(__x);} + +static long double _Complex + _TG_ATTRS + __tg_atan(long double _Complex __x) {return catanl(__x);} + +#undef atan +#define atan(__x) __tg_atan(__tg_promote1((__x))(__x)) + +// acosh + +static float + _TG_ATTRS + __tg_acosh(float __x) {return acoshf(__x);} + +static double + _TG_ATTRS + __tg_acosh(double __x) {return acosh(__x);} + +static long double + _TG_ATTRS + __tg_acosh(long double __x) {return acoshl(__x);} + +static float _Complex + _TG_ATTRS + __tg_acosh(float _Complex __x) {return cacoshf(__x);} + +static double _Complex + _TG_ATTRS + __tg_acosh(double _Complex __x) {return cacosh(__x);} + +static long double _Complex + _TG_ATTRS + __tg_acosh(long double _Complex __x) {return cacoshl(__x);} + +#undef acosh +#define acosh(__x) __tg_acosh(__tg_promote1((__x))(__x)) + +// asinh + +static float + _TG_ATTRS + __tg_asinh(float __x) {return asinhf(__x);} + +static double + _TG_ATTRS + __tg_asinh(double __x) {return asinh(__x);} + +static long double + _TG_ATTRS + __tg_asinh(long double __x) {return asinhl(__x);} + +static float _Complex + _TG_ATTRS + __tg_asinh(float _Complex __x) {return casinhf(__x);} + +static double _Complex + _TG_ATTRS + __tg_asinh(double _Complex __x) {return casinh(__x);} + +static long double _Complex + _TG_ATTRS + __tg_asinh(long double _Complex __x) {return casinhl(__x);} + +#undef asinh +#define asinh(__x) __tg_asinh(__tg_promote1((__x))(__x)) + +// atanh + +static float + _TG_ATTRS + __tg_atanh(float __x) {return atanhf(__x);} + +static double + _TG_ATTRS + __tg_atanh(double __x) {return atanh(__x);} + +static long double + _TG_ATTRS + __tg_atanh(long double __x) {return atanhl(__x);} + +static float _Complex + _TG_ATTRS + __tg_atanh(float _Complex __x) {return catanhf(__x);} + +static double _Complex + _TG_ATTRS + __tg_atanh(double _Complex __x) {return catanh(__x);} + +static long double _Complex + _TG_ATTRS + __tg_atanh(long double _Complex __x) {return catanhl(__x);} + +#undef atanh +#define atanh(__x) __tg_atanh(__tg_promote1((__x))(__x)) + +// cos + +static float + _TG_ATTRS + __tg_cos(float __x) {return cosf(__x);} + +static double + _TG_ATTRS + __tg_cos(double __x) {return cos(__x);} + +static long double + _TG_ATTRS + __tg_cos(long double __x) {return cosl(__x);} + +static float _Complex + _TG_ATTRS + __tg_cos(float _Complex __x) {return ccosf(__x);} + +static double _Complex + _TG_ATTRS + __tg_cos(double _Complex __x) {return ccos(__x);} + +static long double _Complex + _TG_ATTRS + __tg_cos(long double _Complex __x) {return ccosl(__x);} + +#undef cos +#define cos(__x) __tg_cos(__tg_promote1((__x))(__x)) + +// sin + +static float + _TG_ATTRS + __tg_sin(float __x) {return sinf(__x);} + +static double + _TG_ATTRS + __tg_sin(double __x) {return sin(__x);} + +static long double + _TG_ATTRS + __tg_sin(long double __x) {return sinl(__x);} + +static float _Complex + _TG_ATTRS + __tg_sin(float _Complex __x) {return csinf(__x);} + +static double _Complex + _TG_ATTRS + __tg_sin(double _Complex __x) {return csin(__x);} + +static long double _Complex + _TG_ATTRS + __tg_sin(long double _Complex __x) {return csinl(__x);} + +#undef sin +#define sin(__x) __tg_sin(__tg_promote1((__x))(__x)) + +// tan + +static float + _TG_ATTRS + __tg_tan(float __x) {return tanf(__x);} + +static double + _TG_ATTRS + __tg_tan(double __x) {return tan(__x);} + +static long double + _TG_ATTRS + __tg_tan(long double __x) {return tanl(__x);} + +static float _Complex + _TG_ATTRS + __tg_tan(float _Complex __x) {return ctanf(__x);} + +static double _Complex + _TG_ATTRS + __tg_tan(double _Complex __x) {return ctan(__x);} + +static long double _Complex + _TG_ATTRS + __tg_tan(long double _Complex __x) {return ctanl(__x);} + +#undef tan +#define tan(__x) __tg_tan(__tg_promote1((__x))(__x)) + +// cosh + +static float + _TG_ATTRS + __tg_cosh(float __x) {return coshf(__x);} + +static double + _TG_ATTRS + __tg_cosh(double __x) {return cosh(__x);} + +static long double + _TG_ATTRS + __tg_cosh(long double __x) {return coshl(__x);} + +static float _Complex + _TG_ATTRS + __tg_cosh(float _Complex __x) {return ccoshf(__x);} + +static double _Complex + _TG_ATTRS + __tg_cosh(double _Complex __x) {return ccosh(__x);} + +static long double _Complex + _TG_ATTRS + __tg_cosh(long double _Complex __x) {return ccoshl(__x);} + +#undef cosh +#define cosh(__x) __tg_cosh(__tg_promote1((__x))(__x)) + +// sinh + +static float + _TG_ATTRS + __tg_sinh(float __x) {return sinhf(__x);} + +static double + _TG_ATTRS + __tg_sinh(double __x) {return sinh(__x);} + +static long double + _TG_ATTRS + __tg_sinh(long double __x) {return sinhl(__x);} + +static float _Complex + _TG_ATTRS + __tg_sinh(float _Complex __x) {return csinhf(__x);} + +static double _Complex + _TG_ATTRS + __tg_sinh(double _Complex __x) {return csinh(__x);} + +static long double _Complex + _TG_ATTRS + __tg_sinh(long double _Complex __x) {return csinhl(__x);} + +#undef sinh +#define sinh(__x) __tg_sinh(__tg_promote1((__x))(__x)) + +// tanh + +static float + _TG_ATTRS + __tg_tanh(float __x) {return tanhf(__x);} + +static double + _TG_ATTRS + __tg_tanh(double __x) {return tanh(__x);} + +static long double + _TG_ATTRS + __tg_tanh(long double __x) {return tanhl(__x);} + +static float _Complex + _TG_ATTRS + __tg_tanh(float _Complex __x) {return ctanhf(__x);} + +static double _Complex + _TG_ATTRS + __tg_tanh(double _Complex __x) {return ctanh(__x);} + +static long double _Complex + _TG_ATTRS + __tg_tanh(long double _Complex __x) {return ctanhl(__x);} + +#undef tanh +#define tanh(__x) __tg_tanh(__tg_promote1((__x))(__x)) + +// exp + +static float + _TG_ATTRS + __tg_exp(float __x) {return expf(__x);} + +static double + _TG_ATTRS + __tg_exp(double __x) {return exp(__x);} + +static long double + _TG_ATTRS + __tg_exp(long double __x) {return expl(__x);} + +static float _Complex + _TG_ATTRS + __tg_exp(float _Complex __x) {return cexpf(__x);} + +static double _Complex + _TG_ATTRS + __tg_exp(double _Complex __x) {return cexp(__x);} + +static long double _Complex + _TG_ATTRS + __tg_exp(long double _Complex __x) {return cexpl(__x);} + +#undef exp +#define exp(__x) __tg_exp(__tg_promote1((__x))(__x)) + +// log + +static float + _TG_ATTRS + __tg_log(float __x) {return logf(__x);} + +static double + _TG_ATTRS + __tg_log(double __x) {return log(__x);} + +static long double + _TG_ATTRS + __tg_log(long double __x) {return logl(__x);} + +static float _Complex + _TG_ATTRS + __tg_log(float _Complex __x) {return clogf(__x);} + +static double _Complex + _TG_ATTRS + __tg_log(double _Complex __x) {return clog(__x);} + +static long double _Complex + _TG_ATTRS + __tg_log(long double _Complex __x) {return clogl(__x);} + +#undef log +#define log(__x) __tg_log(__tg_promote1((__x))(__x)) + +// pow + +static float + _TG_ATTRS + __tg_pow(float __x, float __y) {return powf(__x, __y);} + +static double + _TG_ATTRS + __tg_pow(double __x, double __y) {return pow(__x, __y);} + +static long double + _TG_ATTRS + __tg_pow(long double __x, long double __y) {return powl(__x, __y);} + +static float _Complex + _TG_ATTRS + __tg_pow(float _Complex __x, float _Complex __y) {return cpowf(__x, __y);} + +static double _Complex + _TG_ATTRS + __tg_pow(double _Complex __x, double _Complex __y) {return cpow(__x, __y);} + +static long double _Complex + _TG_ATTRS + __tg_pow(long double _Complex __x, long double _Complex __y) + {return cpowl(__x, __y);} + +#undef pow +#define pow(__x, __y) __tg_pow(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// sqrt + +static float + _TG_ATTRS + __tg_sqrt(float __x) {return sqrtf(__x);} + +static double + _TG_ATTRS + __tg_sqrt(double __x) {return sqrt(__x);} + +static long double + _TG_ATTRS + __tg_sqrt(long double __x) {return sqrtl(__x);} + +static float _Complex + _TG_ATTRS + __tg_sqrt(float _Complex __x) {return csqrtf(__x);} + +static double _Complex + _TG_ATTRS + __tg_sqrt(double _Complex __x) {return csqrt(__x);} + +static long double _Complex + _TG_ATTRS + __tg_sqrt(long double _Complex __x) {return csqrtl(__x);} + +#undef sqrt +#define sqrt(__x) __tg_sqrt(__tg_promote1((__x))(__x)) + +// fabs + +static float + _TG_ATTRS + __tg_fabs(float __x) {return fabsf(__x);} + +static double + _TG_ATTRS + __tg_fabs(double __x) {return fabs(__x);} + +static long double + _TG_ATTRS + __tg_fabs(long double __x) {return fabsl(__x);} + +static float + _TG_ATTRS + __tg_fabs(float _Complex __x) {return cabsf(__x);} + +static double + _TG_ATTRS + __tg_fabs(double _Complex __x) {return cabs(__x);} + +static long double + _TG_ATTRS + __tg_fabs(long double _Complex __x) {return cabsl(__x);} + +#undef fabs +#define fabs(__x) __tg_fabs(__tg_promote1((__x))(__x)) + +// atan2 + +static float + _TG_ATTRS + __tg_atan2(float __x, float __y) {return atan2f(__x, __y);} + +static double + _TG_ATTRS + __tg_atan2(double __x, double __y) {return atan2(__x, __y);} + +static long double + _TG_ATTRS + __tg_atan2(long double __x, long double __y) {return atan2l(__x, __y);} + +#undef atan2 +#define atan2(__x, __y) __tg_atan2(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// cbrt + +static float + _TG_ATTRS + __tg_cbrt(float __x) {return cbrtf(__x);} + +static double + _TG_ATTRS + __tg_cbrt(double __x) {return cbrt(__x);} + +static long double + _TG_ATTRS + __tg_cbrt(long double __x) {return cbrtl(__x);} + +#undef cbrt +#define cbrt(__x) __tg_cbrt(__tg_promote1((__x))(__x)) + +// ceil + +static float + _TG_ATTRS + __tg_ceil(float __x) {return ceilf(__x);} + +static double + _TG_ATTRS + __tg_ceil(double __x) {return ceil(__x);} + +static long double + _TG_ATTRS + __tg_ceil(long double __x) {return ceill(__x);} + +#undef ceil +#define ceil(__x) __tg_ceil(__tg_promote1((__x))(__x)) + +// copysign + +static float + _TG_ATTRS + __tg_copysign(float __x, float __y) {return copysignf(__x, __y);} + +static double + _TG_ATTRS + __tg_copysign(double __x, double __y) {return copysign(__x, __y);} + +static long double + _TG_ATTRS + __tg_copysign(long double __x, long double __y) {return copysignl(__x, __y);} + +#undef copysign +#define copysign(__x, __y) __tg_copysign(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// erf + +static float + _TG_ATTRS + __tg_erf(float __x) {return erff(__x);} + +static double + _TG_ATTRS + __tg_erf(double __x) {return erf(__x);} + +static long double + _TG_ATTRS + __tg_erf(long double __x) {return erfl(__x);} + +#undef erf +#define erf(__x) __tg_erf(__tg_promote1((__x))(__x)) + +// erfc + +static float + _TG_ATTRS + __tg_erfc(float __x) {return erfcf(__x);} + +static double + _TG_ATTRS + __tg_erfc(double __x) {return erfc(__x);} + +static long double + _TG_ATTRS + __tg_erfc(long double __x) {return erfcl(__x);} + +#undef erfc +#define erfc(__x) __tg_erfc(__tg_promote1((__x))(__x)) + +// exp2 + +static float + _TG_ATTRS + __tg_exp2(float __x) {return exp2f(__x);} + +static double + _TG_ATTRS + __tg_exp2(double __x) {return exp2(__x);} + +static long double + _TG_ATTRS + __tg_exp2(long double __x) {return exp2l(__x);} + +#undef exp2 +#define exp2(__x) __tg_exp2(__tg_promote1((__x))(__x)) + +// expm1 + +static float + _TG_ATTRS + __tg_expm1(float __x) {return expm1f(__x);} + +static double + _TG_ATTRS + __tg_expm1(double __x) {return expm1(__x);} + +static long double + _TG_ATTRS + __tg_expm1(long double __x) {return expm1l(__x);} + +#undef expm1 +#define expm1(__x) __tg_expm1(__tg_promote1((__x))(__x)) + +// fdim + +static float + _TG_ATTRS + __tg_fdim(float __x, float __y) {return fdimf(__x, __y);} + +static double + _TG_ATTRS + __tg_fdim(double __x, double __y) {return fdim(__x, __y);} + +static long double + _TG_ATTRS + __tg_fdim(long double __x, long double __y) {return fdiml(__x, __y);} + +#undef fdim +#define fdim(__x, __y) __tg_fdim(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// floor + +static float + _TG_ATTRS + __tg_floor(float __x) {return floorf(__x);} + +static double + _TG_ATTRS + __tg_floor(double __x) {return floor(__x);} + +static long double + _TG_ATTRS + __tg_floor(long double __x) {return floorl(__x);} + +#undef floor +#define floor(__x) __tg_floor(__tg_promote1((__x))(__x)) + +// fma + +static float + _TG_ATTRS + __tg_fma(float __x, float __y, float __z) + {return fmaf(__x, __y, __z);} + +static double + _TG_ATTRS + __tg_fma(double __x, double __y, double __z) + {return fma(__x, __y, __z);} + +static long double + _TG_ATTRS + __tg_fma(long double __x,long double __y, long double __z) + {return fmal(__x, __y, __z);} + +#undef fma +#define fma(__x, __y, __z) \ + __tg_fma(__tg_promote3((__x), (__y), (__z))(__x), \ + __tg_promote3((__x), (__y), (__z))(__y), \ + __tg_promote3((__x), (__y), (__z))(__z)) + +// fmax + +static float + _TG_ATTRS + __tg_fmax(float __x, float __y) {return fmaxf(__x, __y);} + +static double + _TG_ATTRS + __tg_fmax(double __x, double __y) {return fmax(__x, __y);} + +static long double + _TG_ATTRS + __tg_fmax(long double __x, long double __y) {return fmaxl(__x, __y);} + +#undef fmax +#define fmax(__x, __y) __tg_fmax(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// fmin + +static float + _TG_ATTRS + __tg_fmin(float __x, float __y) {return fminf(__x, __y);} + +static double + _TG_ATTRS + __tg_fmin(double __x, double __y) {return fmin(__x, __y);} + +static long double + _TG_ATTRS + __tg_fmin(long double __x, long double __y) {return fminl(__x, __y);} + +#undef fmin +#define fmin(__x, __y) __tg_fmin(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// fmod + +static float + _TG_ATTRS + __tg_fmod(float __x, float __y) {return fmodf(__x, __y);} + +static double + _TG_ATTRS + __tg_fmod(double __x, double __y) {return fmod(__x, __y);} + +static long double + _TG_ATTRS + __tg_fmod(long double __x, long double __y) {return fmodl(__x, __y);} + +#undef fmod +#define fmod(__x, __y) __tg_fmod(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// frexp + +static float + _TG_ATTRS + __tg_frexp(float __x, int* __y) {return frexpf(__x, __y);} + +static double + _TG_ATTRS + __tg_frexp(double __x, int* __y) {return frexp(__x, __y);} + +static long double + _TG_ATTRS + __tg_frexp(long double __x, int* __y) {return frexpl(__x, __y);} + +#undef frexp +#define frexp(__x, __y) __tg_frexp(__tg_promote1((__x))(__x), __y) + +// hypot + +static float + _TG_ATTRS + __tg_hypot(float __x, float __y) {return hypotf(__x, __y);} + +static double + _TG_ATTRS + __tg_hypot(double __x, double __y) {return hypot(__x, __y);} + +static long double + _TG_ATTRS + __tg_hypot(long double __x, long double __y) {return hypotl(__x, __y);} + +#undef hypot +#define hypot(__x, __y) __tg_hypot(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// ilogb + +static int + _TG_ATTRS + __tg_ilogb(float __x) {return ilogbf(__x);} + +static int + _TG_ATTRS + __tg_ilogb(double __x) {return ilogb(__x);} + +static int + _TG_ATTRS + __tg_ilogb(long double __x) {return ilogbl(__x);} + +#undef ilogb +#define ilogb(__x) __tg_ilogb(__tg_promote1((__x))(__x)) + +// ldexp + +static float + _TG_ATTRS + __tg_ldexp(float __x, int __y) {return ldexpf(__x, __y);} + +static double + _TG_ATTRS + __tg_ldexp(double __x, int __y) {return ldexp(__x, __y);} + +static long double + _TG_ATTRS + __tg_ldexp(long double __x, int __y) {return ldexpl(__x, __y);} + +#undef ldexp +#define ldexp(__x, __y) __tg_ldexp(__tg_promote1((__x))(__x), __y) + +// lgamma + +static float + _TG_ATTRS + __tg_lgamma(float __x) {return lgammaf(__x);} + +static double + _TG_ATTRS + __tg_lgamma(double __x) {return lgamma(__x);} + +static long double + _TG_ATTRS + __tg_lgamma(long double __x) {return lgammal(__x);} + +#undef lgamma +#define lgamma(__x) __tg_lgamma(__tg_promote1((__x))(__x)) + +// llrint + +static long long + _TG_ATTRS + __tg_llrint(float __x) {return llrintf(__x);} + +static long long + _TG_ATTRS + __tg_llrint(double __x) {return llrint(__x);} + +static long long + _TG_ATTRS + __tg_llrint(long double __x) {return llrintl(__x);} + +#undef llrint +#define llrint(__x) __tg_llrint(__tg_promote1((__x))(__x)) + +// llround + +static long long + _TG_ATTRS + __tg_llround(float __x) {return llroundf(__x);} + +static long long + _TG_ATTRS + __tg_llround(double __x) {return llround(__x);} + +static long long + _TG_ATTRS + __tg_llround(long double __x) {return llroundl(__x);} + +#undef llround +#define llround(__x) __tg_llround(__tg_promote1((__x))(__x)) + +// log10 + +static float + _TG_ATTRS + __tg_log10(float __x) {return log10f(__x);} + +static double + _TG_ATTRS + __tg_log10(double __x) {return log10(__x);} + +static long double + _TG_ATTRS + __tg_log10(long double __x) {return log10l(__x);} + +#undef log10 +#define log10(__x) __tg_log10(__tg_promote1((__x))(__x)) + +// log1p + +static float + _TG_ATTRS + __tg_log1p(float __x) {return log1pf(__x);} + +static double + _TG_ATTRS + __tg_log1p(double __x) {return log1p(__x);} + +static long double + _TG_ATTRS + __tg_log1p(long double __x) {return log1pl(__x);} + +#undef log1p +#define log1p(__x) __tg_log1p(__tg_promote1((__x))(__x)) + +// log2 + +static float + _TG_ATTRS + __tg_log2(float __x) {return log2f(__x);} + +static double + _TG_ATTRS + __tg_log2(double __x) {return log2(__x);} + +static long double + _TG_ATTRS + __tg_log2(long double __x) {return log2l(__x);} + +#undef log2 +#define log2(__x) __tg_log2(__tg_promote1((__x))(__x)) + +// logb + +static float + _TG_ATTRS + __tg_logb(float __x) {return logbf(__x);} + +static double + _TG_ATTRS + __tg_logb(double __x) {return logb(__x);} + +static long double + _TG_ATTRS + __tg_logb(long double __x) {return logbl(__x);} + +#undef logb +#define logb(__x) __tg_logb(__tg_promote1((__x))(__x)) + +// lrint + +static long + _TG_ATTRS + __tg_lrint(float __x) {return lrintf(__x);} + +static long + _TG_ATTRS + __tg_lrint(double __x) {return lrint(__x);} + +static long + _TG_ATTRS + __tg_lrint(long double __x) {return lrintl(__x);} + +#undef lrint +#define lrint(__x) __tg_lrint(__tg_promote1((__x))(__x)) + +// lround + +static long + _TG_ATTRS + __tg_lround(float __x) {return lroundf(__x);} + +static long + _TG_ATTRS + __tg_lround(double __x) {return lround(__x);} + +static long + _TG_ATTRS + __tg_lround(long double __x) {return lroundl(__x);} + +#undef lround +#define lround(__x) __tg_lround(__tg_promote1((__x))(__x)) + +// nearbyint + +static float + _TG_ATTRS + __tg_nearbyint(float __x) {return nearbyintf(__x);} + +static double + _TG_ATTRS + __tg_nearbyint(double __x) {return nearbyint(__x);} + +static long double + _TG_ATTRS + __tg_nearbyint(long double __x) {return nearbyintl(__x);} + +#undef nearbyint +#define nearbyint(__x) __tg_nearbyint(__tg_promote1((__x))(__x)) + +// nextafter + +static float + _TG_ATTRS + __tg_nextafter(float __x, float __y) {return nextafterf(__x, __y);} + +static double + _TG_ATTRS + __tg_nextafter(double __x, double __y) {return nextafter(__x, __y);} + +static long double + _TG_ATTRS + __tg_nextafter(long double __x, long double __y) {return nextafterl(__x, __y);} + +#undef nextafter +#define nextafter(__x, __y) __tg_nextafter(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// nexttoward + +static float + _TG_ATTRS + __tg_nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);} + +static double + _TG_ATTRS + __tg_nexttoward(double __x, long double __y) {return nexttoward(__x, __y);} + +static long double + _TG_ATTRS + __tg_nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);} + +#undef nexttoward +#define nexttoward(__x, __y) __tg_nexttoward(__tg_promote1((__x))(__x), (__y)) + +// remainder + +static float + _TG_ATTRS + __tg_remainder(float __x, float __y) {return remainderf(__x, __y);} + +static double + _TG_ATTRS + __tg_remainder(double __x, double __y) {return remainder(__x, __y);} + +static long double + _TG_ATTRS + __tg_remainder(long double __x, long double __y) {return remainderl(__x, __y);} + +#undef remainder +#define remainder(__x, __y) __tg_remainder(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y)) + +// remquo + +static float + _TG_ATTRS + __tg_remquo(float __x, float __y, int* __z) + {return remquof(__x, __y, __z);} + +static double + _TG_ATTRS + __tg_remquo(double __x, double __y, int* __z) + {return remquo(__x, __y, __z);} + +static long double + _TG_ATTRS + __tg_remquo(long double __x,long double __y, int* __z) + {return remquol(__x, __y, __z);} + +#undef remquo +#define remquo(__x, __y, __z) \ + __tg_remquo(__tg_promote2((__x), (__y))(__x), \ + __tg_promote2((__x), (__y))(__y), \ + (__z)) + +// rint + +static float + _TG_ATTRS + __tg_rint(float __x) {return rintf(__x);} + +static double + _TG_ATTRS + __tg_rint(double __x) {return rint(__x);} + +static long double + _TG_ATTRS + __tg_rint(long double __x) {return rintl(__x);} + +#undef rint +#define rint(__x) __tg_rint(__tg_promote1((__x))(__x)) + +// round + +static float + _TG_ATTRS + __tg_round(float __x) {return roundf(__x);} + +static double + _TG_ATTRS + __tg_round(double __x) {return round(__x);} + +static long double + _TG_ATTRS + __tg_round(long double __x) {return roundl(__x);} + +#undef round +#define round(__x) __tg_round(__tg_promote1((__x))(__x)) + +// scalbn + +static float + _TG_ATTRS + __tg_scalbn(float __x, int __y) {return scalbnf(__x, __y);} + +static double + _TG_ATTRS + __tg_scalbn(double __x, int __y) {return scalbn(__x, __y);} + +static long double + _TG_ATTRS + __tg_scalbn(long double __x, int __y) {return scalbnl(__x, __y);} + +#undef scalbn +#define scalbn(__x, __y) __tg_scalbn(__tg_promote1((__x))(__x), __y) + +// scalbln + +static float + _TG_ATTRS + __tg_scalbln(float __x, long __y) {return scalblnf(__x, __y);} + +static double + _TG_ATTRS + __tg_scalbln(double __x, long __y) {return scalbln(__x, __y);} + +static long double + _TG_ATTRS + __tg_scalbln(long double __x, long __y) {return scalblnl(__x, __y);} + +#undef scalbln +#define scalbln(__x, __y) __tg_scalbln(__tg_promote1((__x))(__x), __y) + +// tgamma + +static float + _TG_ATTRS + __tg_tgamma(float __x) {return tgammaf(__x);} + +static double + _TG_ATTRS + __tg_tgamma(double __x) {return tgamma(__x);} + +static long double + _TG_ATTRS + __tg_tgamma(long double __x) {return tgammal(__x);} + +#undef tgamma +#define tgamma(__x) __tg_tgamma(__tg_promote1((__x))(__x)) + +// trunc + +static float + _TG_ATTRS + __tg_trunc(float __x) {return truncf(__x);} + +static double + _TG_ATTRS + __tg_trunc(double __x) {return trunc(__x);} + +static long double + _TG_ATTRS + __tg_trunc(long double __x) {return truncl(__x);} + +#undef trunc +#define trunc(__x) __tg_trunc(__tg_promote1((__x))(__x)) + +// carg + +static float + _TG_ATTRS + __tg_carg(float __x) {return atan2f(0.F, __x);} + +static double + _TG_ATTRS + __tg_carg(double __x) {return atan2(0., __x);} + +static long double + _TG_ATTRS + __tg_carg(long double __x) {return atan2l(0.L, __x);} + +static float + _TG_ATTRS + __tg_carg(float _Complex __x) {return cargf(__x);} + +static double + _TG_ATTRS + __tg_carg(double _Complex __x) {return carg(__x);} + +static long double + _TG_ATTRS + __tg_carg(long double _Complex __x) {return cargl(__x);} + +#undef carg +#define carg(__x) __tg_carg(__tg_promote1((__x))(__x)) + +// cimag + +static float + _TG_ATTRS + __tg_cimag(float __x) {return 0;} + +static double + _TG_ATTRS + __tg_cimag(double __x) {return 0;} + +static long double + _TG_ATTRS + __tg_cimag(long double __x) {return 0;} + +static float + _TG_ATTRS + __tg_cimag(float _Complex __x) {return cimagf(__x);} + +static double + _TG_ATTRS + __tg_cimag(double _Complex __x) {return cimag(__x);} + +static long double + _TG_ATTRS + __tg_cimag(long double _Complex __x) {return cimagl(__x);} + +#undef cimag +#define cimag(__x) __tg_cimag(__tg_promote1((__x))(__x)) + +// conj + +static float _Complex + _TG_ATTRS + __tg_conj(float __x) {return __x;} + +static double _Complex + _TG_ATTRS + __tg_conj(double __x) {return __x;} + +static long double _Complex + _TG_ATTRS + __tg_conj(long double __x) {return __x;} + +static float _Complex + _TG_ATTRS + __tg_conj(float _Complex __x) {return conjf(__x);} + +static double _Complex + _TG_ATTRS + __tg_conj(double _Complex __x) {return conj(__x);} + +static long double _Complex + _TG_ATTRS + __tg_conj(long double _Complex __x) {return conjl(__x);} + +#undef conj +#define conj(__x) __tg_conj(__tg_promote1((__x))(__x)) + +// cproj + +static float _Complex + _TG_ATTRS + __tg_cproj(float __x) {return cprojf(__x);} + +static double _Complex + _TG_ATTRS + __tg_cproj(double __x) {return cproj(__x);} + +static long double _Complex + _TG_ATTRS + __tg_cproj(long double __x) {return cprojl(__x);} + +static float _Complex + _TG_ATTRS + __tg_cproj(float _Complex __x) {return cprojf(__x);} + +static double _Complex + _TG_ATTRS + __tg_cproj(double _Complex __x) {return cproj(__x);} + +static long double _Complex + _TG_ATTRS + __tg_cproj(long double _Complex __x) {return cprojl(__x);} + +#undef cproj +#define cproj(__x) __tg_cproj(__tg_promote1((__x))(__x)) + +// creal + +static float + _TG_ATTRS + __tg_creal(float __x) {return __x;} + +static double + _TG_ATTRS + __tg_creal(double __x) {return __x;} + +static long double + _TG_ATTRS + __tg_creal(long double __x) {return __x;} + +static float + _TG_ATTRS + __tg_creal(float _Complex __x) {return crealf(__x);} + +static double + _TG_ATTRS + __tg_creal(double _Complex __x) {return creal(__x);} + +static long double + _TG_ATTRS + __tg_creal(long double _Complex __x) {return creall(__x);} + +#undef creal +#define creal(__x) __tg_creal(__tg_promote1((__x))(__x)) + +#undef _TG_ATTRSp +#undef _TG_ATTRS + +#endif /* __cplusplus */ +#endif /* __has_include_next */ +#endif /* __CLANG_TGMATH_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tmmintrin.h new file mode 100755 index 0000000..371cc82 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tmmintrin.h @@ -0,0 +1,810 @@ +/*===---- tmmintrin.h - SSSE3 intrinsics -----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __TMMINTRIN_H +#define __TMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("ssse3,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("ssse3"), \ + __min_vector_width__(128))) +#endif + +#define __trunc64(x) \ + (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0) +#define __anyext128(x) \ + (__m128i) __builtin_shufflevector((__v2si)(x), __extension__(__v2si){}, 0, \ + 1, -1, -1) + +/// Computes the absolute value of each of the packed 8-bit signed +/// integers in the source operand and stores the 8-bit unsigned integer +/// results in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PABSB instruction. +/// +/// \param __a +/// A 64-bit vector of [8 x i8]. +/// \returns A 64-bit integer vector containing the absolute values of the +/// elements in the operand. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_abs_pi8(__m64 __a) +{ + return (__m64)__builtin_elementwise_abs((__v8qs)__a); +} + +/// Computes the absolute value of each of the packed 8-bit signed +/// integers in the source operand and stores the 8-bit unsigned integer +/// results in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPABSB instruction. +/// +/// \param __a +/// A 128-bit vector of [16 x i8]. +/// \returns A 128-bit integer vector containing the absolute values of the +/// elements in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_abs_epi8(__m128i __a) +{ + return (__m128i)__builtin_elementwise_abs((__v16qs)__a); +} + +/// Computes the absolute value of each of the packed 16-bit signed +/// integers in the source operand and stores the 16-bit unsigned integer +/// results in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PABSW instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16]. +/// \returns A 64-bit integer vector containing the absolute values of the +/// elements in the operand. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_abs_pi16(__m64 __a) +{ + return (__m64)__builtin_elementwise_abs((__v4hi)__a); +} + +/// Computes the absolute value of each of the packed 16-bit signed +/// integers in the source operand and stores the 16-bit unsigned integer +/// results in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPABSW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16]. +/// \returns A 128-bit integer vector containing the absolute values of the +/// elements in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_abs_epi16(__m128i __a) +{ + return (__m128i)__builtin_elementwise_abs((__v8hi)__a); +} + +/// Computes the absolute value of each of the packed 32-bit signed +/// integers in the source operand and stores the 32-bit unsigned integer +/// results in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PABSD instruction. +/// +/// \param __a +/// A 64-bit vector of [2 x i32]. +/// \returns A 64-bit integer vector containing the absolute values of the +/// elements in the operand. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_abs_pi32(__m64 __a) +{ + return (__m64)__builtin_elementwise_abs((__v2si)__a); +} + +/// Computes the absolute value of each of the packed 32-bit signed +/// integers in the source operand and stores the 32-bit unsigned integer +/// results in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPABSD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32]. +/// \returns A 128-bit integer vector containing the absolute values of the +/// elements in the operand. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_abs_epi32(__m128i __a) +{ + return (__m128i)__builtin_elementwise_abs((__v4si)__a); +} + +/// Concatenates the two 128-bit integer vector operands, and +/// right-shifts the result by the number of bytes specified in the immediate +/// operand. +/// +/// \headerfile +/// +/// \code +/// __m128i _mm_alignr_epi8(__m128i a, __m128i b, const int n); +/// \endcode +/// +/// This intrinsic corresponds to the \c PALIGNR instruction. +/// +/// \param a +/// A 128-bit vector of [16 x i8] containing one of the source operands. +/// \param b +/// A 128-bit vector of [16 x i8] containing one of the source operands. +/// \param n +/// An immediate operand specifying how many bytes to right-shift the result. +/// \returns A 128-bit integer vector containing the concatenated right-shifted +/// value. +#define _mm_alignr_epi8(a, b, n) \ + ((__m128i)__builtin_ia32_palignr128((__v16qi)(__m128i)(a), \ + (__v16qi)(__m128i)(b), (n))) + +/// Concatenates the two 64-bit integer vector operands, and right-shifts +/// the result by the number of bytes specified in the immediate operand. +/// +/// \headerfile +/// +/// \code +/// __m64 _mm_alignr_pi8(__m64 a, __m64 b, const int n); +/// \endcode +/// +/// This intrinsic corresponds to the \c PALIGNR instruction. +/// +/// \param a +/// A 64-bit vector of [8 x i8] containing one of the source operands. +/// \param b +/// A 64-bit vector of [8 x i8] containing one of the source operands. +/// \param n +/// An immediate operand specifying how many bytes to right-shift the result. +/// \returns A 64-bit integer vector containing the concatenated right-shifted +/// value. +#define _mm_alignr_pi8(a, b, n) \ + ((__m64)__builtin_shufflevector( \ + __builtin_ia32_psrldqi128_byteshift( \ + __builtin_shufflevector((__v1di)(a), (__v1di)(b), 1, 0), \ + (n)), __extension__ (__v2di){}, 0)) + +/// Horizontally adds the adjacent pairs of values contained in 2 packed +/// 128-bit vectors of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHADDW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 128-bit vector of [8 x i16] containing the horizontal sums of +/// both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hadd_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_phaddw128((__v8hi)__a, (__v8hi)__b); +} + +/// Horizontally adds the adjacent pairs of values contained in 2 packed +/// 128-bit vectors of [4 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHADDD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32] containing one of the source operands. The +/// horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 128-bit vector of [4 x i32] containing one of the source operands. The +/// horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 128-bit vector of [4 x i32] containing the horizontal sums of +/// both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hadd_epi32(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_phaddd128((__v4si)__a, (__v4si)__b); +} + +/// Horizontally adds the adjacent pairs of values contained in 2 packed +/// 64-bit vectors of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PHADDW instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 64-bit vector of [4 x i16] containing the horizontal sums of both +/// operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_hadd_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_phaddw128( + (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){})); +} + +/// Horizontally adds the adjacent pairs of values contained in 2 packed +/// 64-bit vectors of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PHADDD instruction. +/// +/// \param __a +/// A 64-bit vector of [2 x i32] containing one of the source operands. The +/// horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 64-bit vector of [2 x i32] containing one of the source operands. The +/// horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 64-bit vector of [2 x i32] containing the horizontal sums of both +/// operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_hadd_pi32(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_phaddd128( + (__v4si)__builtin_shufflevector(__a, __b, 0, 1), (__v4si){})); +} + +/// Horizontally adds, with saturation, the adjacent pairs of values contained +/// in two packed 128-bit vectors of [8 x i16]. +/// +/// Positive sums greater than 0x7FFF are saturated to 0x7FFF. Negative sums +/// less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHADDSW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated +/// sums of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hadds_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_phaddsw128((__v8hi)__a, (__v8hi)__b); +} + +/// Horizontally adds, with saturation, the adjacent pairs of values contained +/// in two packed 64-bit vectors of [4 x i16]. +/// +/// Positive sums greater than 0x7FFF are saturated to 0x7FFF. Negative sums +/// less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PHADDSW instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the lower bits of the +/// destination. +/// \param __b +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal sums of the values are stored in the upper bits of the +/// destination. +/// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated +/// sums of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_hadds_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_phaddsw128( + (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){})); +} + +/// Horizontally subtracts the adjacent pairs of values contained in 2 +/// packed 128-bit vectors of [8 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHSUBW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the lower bits of +/// the destination. +/// \param __b +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the upper bits of +/// the destination. +/// \returns A 128-bit vector of [8 x i16] containing the horizontal differences +/// of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hsub_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_phsubw128((__v8hi)__a, (__v8hi)__b); +} + +/// Horizontally subtracts the adjacent pairs of values contained in 2 +/// packed 128-bit vectors of [4 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHSUBD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x i32] containing one of the source operands. The +/// horizontal differences between the values are stored in the lower bits of +/// the destination. +/// \param __b +/// A 128-bit vector of [4 x i32] containing one of the source operands. The +/// horizontal differences between the values are stored in the upper bits of +/// the destination. +/// \returns A 128-bit vector of [4 x i32] containing the horizontal differences +/// of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hsub_epi32(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_phsubd128((__v4si)__a, (__v4si)__b); +} + +/// Horizontally subtracts the adjacent pairs of values contained in 2 +/// packed 64-bit vectors of [4 x i16]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PHSUBW instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the lower bits of +/// the destination. +/// \param __b +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the upper bits of +/// the destination. +/// \returns A 64-bit vector of [4 x i16] containing the horizontal differences +/// of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_hsub_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_phsubw128( + (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){})); +} + +/// Horizontally subtracts the adjacent pairs of values contained in 2 +/// packed 64-bit vectors of [2 x i32]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PHSUBD instruction. +/// +/// \param __a +/// A 64-bit vector of [2 x i32] containing one of the source operands. The +/// horizontal differences between the values are stored in the lower bits of +/// the destination. +/// \param __b +/// A 64-bit vector of [2 x i32] containing one of the source operands. The +/// horizontal differences between the values are stored in the upper bits of +/// the destination. +/// \returns A 64-bit vector of [2 x i32] containing the horizontal differences +/// of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_hsub_pi32(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_phsubd128( + (__v4si)__builtin_shufflevector(__a, __b, 0, 1), (__v4si){})); +} + +/// Horizontally subtracts, with saturation, the adjacent pairs of values +/// contained in two packed 128-bit vectors of [8 x i16]. +/// +/// Positive differences greater than 0x7FFF are saturated to 0x7FFF. +/// Negative differences less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPHSUBSW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the lower bits of +/// the destination. +/// \param __b +/// A 128-bit vector of [8 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the upper bits of +/// the destination. +/// \returns A 128-bit vector of [8 x i16] containing the horizontal saturated +/// differences of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hsubs_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_phsubsw128((__v8hi)__a, (__v8hi)__b); +} + +/// Horizontally subtracts, with saturation, the adjacent pairs of values +/// contained in two packed 64-bit vectors of [4 x i16]. +/// +/// Positive differences greater than 0x7FFF are saturated to 0x7FFF. +/// Negative differences less than 0x8000 are saturated to 0x8000. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PHSUBSW instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the lower bits of +/// the destination. +/// \param __b +/// A 64-bit vector of [4 x i16] containing one of the source operands. The +/// horizontal differences between the values are stored in the upper bits of +/// the destination. +/// \returns A 64-bit vector of [4 x i16] containing the horizontal saturated +/// differences of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_hsubs_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_phsubsw128( + (__v8hi)__builtin_shufflevector(__a, __b, 0, 1), (__v8hi){})); +} + +/// Multiplies corresponding pairs of packed 8-bit unsigned integer +/// values contained in the first source operand and packed 8-bit signed +/// integer values contained in the second source operand, adds pairs of +/// contiguous products with signed saturation, and writes the 16-bit sums to +/// the corresponding bits in the destination. +/// +/// For example, bits [7:0] of both operands are multiplied, bits [15:8] of +/// both operands are multiplied, and the sum of both results is written to +/// bits [15:0] of the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMADDUBSW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the first source operand. +/// \param __b +/// A 128-bit integer vector containing the second source operand. +/// \returns A 128-bit integer vector containing the sums of products of both +/// operands: \n +/// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n +/// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n +/// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n +/// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7) \n +/// \a R4 := (\a __a8 * \a __b8) + (\a __a9 * \a __b9) \n +/// \a R5 := (\a __a10 * \a __b10) + (\a __a11 * \a __b11) \n +/// \a R6 := (\a __a12 * \a __b12) + (\a __a13 * \a __b13) \n +/// \a R7 := (\a __a14 * \a __b14) + (\a __a15 * \a __b15) +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maddubs_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_pmaddubsw128((__v16qi)__a, (__v16qi)__b); +} + +/// Multiplies corresponding pairs of packed 8-bit unsigned integer +/// values contained in the first source operand and packed 8-bit signed +/// integer values contained in the second source operand, adds pairs of +/// contiguous products with signed saturation, and writes the 16-bit sums to +/// the corresponding bits in the destination. +/// +/// For example, bits [7:0] of both operands are multiplied, bits [15:8] of +/// both operands are multiplied, and the sum of both results is written to +/// bits [15:0] of the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PMADDUBSW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the first source operand. +/// \param __b +/// A 64-bit integer vector containing the second source operand. +/// \returns A 64-bit integer vector containing the sums of products of both +/// operands: \n +/// \a R0 := (\a __a0 * \a __b0) + (\a __a1 * \a __b1) \n +/// \a R1 := (\a __a2 * \a __b2) + (\a __a3 * \a __b3) \n +/// \a R2 := (\a __a4 * \a __b4) + (\a __a5 * \a __b5) \n +/// \a R3 := (\a __a6 * \a __b6) + (\a __a7 * \a __b7) +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_maddubs_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_pmaddubsw128((__v16qi)__anyext128(__a), + (__v16qi)__anyext128(__b))); +} + +/// Multiplies packed 16-bit signed integer values, truncates the 32-bit +/// products to the 18 most significant bits by right-shifting, rounds the +/// truncated value by adding 1, and writes bits [16:1] to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPMULHRSW instruction. +/// +/// \param __a +/// A 128-bit vector of [8 x i16] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [8 x i16] containing one of the source operands. +/// \returns A 128-bit vector of [8 x i16] containing the rounded and scaled +/// products of both operands. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_mulhrs_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_pmulhrsw128((__v8hi)__a, (__v8hi)__b); +} + +/// Multiplies packed 16-bit signed integer values, truncates the 32-bit +/// products to the 18 most significant bits by right-shifting, rounds the +/// truncated value by adding 1, and writes bits [16:1] to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PMULHRSW instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16] containing one of the source operands. +/// \param __b +/// A 64-bit vector of [4 x i16] containing one of the source operands. +/// \returns A 64-bit vector of [4 x i16] containing the rounded and scaled +/// products of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_mulhrs_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_pmulhrsw128((__v8hi)__anyext128(__a), + (__v8hi)__anyext128(__b))); +} + +/// Copies the 8-bit integers from a 128-bit integer vector to the +/// destination or clears 8-bit values in the destination, as specified by +/// the second source operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSHUFB instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the values to be copied. +/// \param __b +/// A 128-bit integer vector containing control bytes corresponding to +/// positions in the destination: +/// Bit 7: \n +/// 1: Clear the corresponding byte in the destination. \n +/// 0: Copy the selected source byte to the corresponding byte in the +/// destination. \n +/// Bits [6:4] Reserved. \n +/// Bits [3:0] select the source byte to be copied. +/// \returns A 128-bit integer vector containing the copied or cleared values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_shuffle_epi8(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_pshufb128((__v16qi)__a, (__v16qi)__b); +} + +/// Copies the 8-bit integers from a 64-bit integer vector to the +/// destination or clears 8-bit values in the destination, as specified by +/// the second source operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PSHUFB instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the values to be copied. +/// \param __b +/// A 64-bit integer vector containing control bytes corresponding to +/// positions in the destination: +/// Bit 7: \n +/// 1: Clear the corresponding byte in the destination. \n +/// 0: Copy the selected source byte to the corresponding byte in the +/// destination. \n +/// Bits [2:0] select the source byte to be copied. +/// \returns A 64-bit integer vector containing the copied or cleared values. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_shuffle_pi8(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_pshufb128( + (__v16qi)__builtin_shufflevector( + (__v2si)(__a), __extension__ (__v2si){}, 0, 1, 0, 1), + (__v16qi)__anyext128(__b))); +} + +/// For each 8-bit integer in the first source operand, perform one of +/// the following actions as specified by the second source operand. +/// +/// If the byte in the second source is negative, calculate the two's +/// complement of the corresponding byte in the first source, and write that +/// value to the destination. If the byte in the second source is positive, +/// copy the corresponding byte from the first source to the destination. If +/// the byte in the second source is zero, clear the corresponding byte in +/// the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSIGNB instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the values to be copied. +/// \param __b +/// A 128-bit integer vector containing control bytes corresponding to +/// positions in the destination. +/// \returns A 128-bit integer vector containing the resultant values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sign_epi8(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_psignb128((__v16qi)__a, (__v16qi)__b); +} + +/// For each 16-bit integer in the first source operand, perform one of +/// the following actions as specified by the second source operand. +/// +/// If the word in the second source is negative, calculate the two's +/// complement of the corresponding word in the first source, and write that +/// value to the destination. If the word in the second source is positive, +/// copy the corresponding word from the first source to the destination. If +/// the word in the second source is zero, clear the corresponding word in +/// the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSIGNW instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the values to be copied. +/// \param __b +/// A 128-bit integer vector containing control words corresponding to +/// positions in the destination. +/// \returns A 128-bit integer vector containing the resultant values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sign_epi16(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_psignw128((__v8hi)__a, (__v8hi)__b); +} + +/// For each 32-bit integer in the first source operand, perform one of +/// the following actions as specified by the second source operand. +/// +/// If the doubleword in the second source is negative, calculate the two's +/// complement of the corresponding word in the first source, and write that +/// value to the destination. If the doubleword in the second source is +/// positive, copy the corresponding word from the first source to the +/// destination. If the doubleword in the second source is zero, clear the +/// corresponding word in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c VPSIGND instruction. +/// +/// \param __a +/// A 128-bit integer vector containing the values to be copied. +/// \param __b +/// A 128-bit integer vector containing control doublewords corresponding to +/// positions in the destination. +/// \returns A 128-bit integer vector containing the resultant values. +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sign_epi32(__m128i __a, __m128i __b) +{ + return (__m128i)__builtin_ia32_psignd128((__v4si)__a, (__v4si)__b); +} + +/// For each 8-bit integer in the first source operand, perform one of +/// the following actions as specified by the second source operand. +/// +/// If the byte in the second source is negative, calculate the two's +/// complement of the corresponding byte in the first source, and write that +/// value to the destination. If the byte in the second source is positive, +/// copy the corresponding byte from the first source to the destination. If +/// the byte in the second source is zero, clear the corresponding byte in +/// the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PSIGNB instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the values to be copied. +/// \param __b +/// A 64-bit integer vector containing control bytes corresponding to +/// positions in the destination. +/// \returns A 64-bit integer vector containing the resultant values. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_sign_pi8(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_psignb128((__v16qi)__anyext128(__a), + (__v16qi)__anyext128(__b))); +} + +/// For each 16-bit integer in the first source operand, perform one of +/// the following actions as specified by the second source operand. +/// +/// If the word in the second source is negative, calculate the two's +/// complement of the corresponding word in the first source, and write that +/// value to the destination. If the word in the second source is positive, +/// copy the corresponding word from the first source to the destination. If +/// the word in the second source is zero, clear the corresponding word in +/// the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PSIGNW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the values to be copied. +/// \param __b +/// A 64-bit integer vector containing control words corresponding to +/// positions in the destination. +/// \returns A 64-bit integer vector containing the resultant values. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_sign_pi16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_psignw128((__v8hi)__anyext128(__a), + (__v8hi)__anyext128(__b))); +} + +/// For each 32-bit integer in the first source operand, perform one of +/// the following actions as specified by the second source operand. +/// +/// If the doubleword in the second source is negative, calculate the two's +/// complement of the corresponding doubleword in the first source, and +/// write that value to the destination. If the doubleword in the second +/// source is positive, copy the corresponding doubleword from the first +/// source to the destination. If the doubleword in the second source is +/// zero, clear the corresponding doubleword in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c PSIGND instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the values to be copied. +/// \param __b +/// A 64-bit integer vector containing two control doublewords corresponding +/// to positions in the destination. +/// \returns A 64-bit integer vector containing the resultant values. +static __inline__ __m64 __DEFAULT_FN_ATTRS +_mm_sign_pi32(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_psignd128((__v4si)__anyext128(__a), + (__v4si)__anyext128(__b))); +} + +#undef __anyext128 +#undef __trunc64 +#undef __DEFAULT_FN_ATTRS + +#endif /* __TMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tsxldtrkintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tsxldtrkintrin.h new file mode 100755 index 0000000..491823e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/tsxldtrkintrin.h @@ -0,0 +1,56 @@ +/*===------------- tsxldtrkintrin.h - tsxldtrk intrinsics ------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __TSXLDTRKINTRIN_H +#define __TSXLDTRKINTRIN_H + +/* Define the default attributes for the functions in this file */ +#define _DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("tsxldtrk"))) + +/// Marks the start of an TSX (RTM) suspend load address tracking region. If +/// this intrinsic is used inside a transactional region, subsequent loads +/// are not added to the read set of the transaction. If it's used inside a +/// suspend load address tracking region it will cause transaction abort. +/// If it's used outside of a transactional region it behaves like a NOP. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c XSUSLDTRK instruction. +/// +static __inline__ void _DEFAULT_FN_ATTRS +_xsusldtrk (void) +{ + __builtin_ia32_xsusldtrk(); +} + +/// Marks the end of an TSX (RTM) suspend load address tracking region. If this +/// intrinsic is used inside a suspend load address tracking region it will +/// end the suspend region and all following load addresses will be added to +/// the transaction read set. If it's used inside an active transaction but +/// not in a suspend region it will cause transaction abort. If it's used +/// outside of a transactional region it behaves like a NOP. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c XRESLDTRK instruction. +/// +static __inline__ void _DEFAULT_FN_ATTRS +_xresldtrk (void) +{ + __builtin_ia32_xresldtrk(); +} + +#undef _DEFAULT_FN_ATTRS + +#endif /* __TSXLDTRKINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/uintrintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/uintrintrin.h new file mode 100755 index 0000000..135dc81 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/uintrintrin.h @@ -0,0 +1,157 @@ +/*===------------------ uintrintrin.h - UINTR intrinsics -------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86GPRINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __UINTRINTRIN_H +#define __UINTRINTRIN_H + +/* Define the default attributes for the functions in this file */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("uintr"))) + +#ifdef __x86_64__ + +struct __uintr_frame +{ + unsigned long long rip; + unsigned long long rflags; + unsigned long long rsp; +}; + +/// Clears the user interrupt flag (UIF). Its effect takes place immediately: a +/// user interrupt cannot be delivered on the instruction boundary following +/// CLUI. Can be executed only if CR4.UINT = 1, the logical processor is in +/// 64-bit mode, and software is not executing inside an enclave; otherwise, +/// each causes an invalid-opcode exception. Causes a transactional abort if +/// executed inside a transactional region; the abort loads EAX as it would +/// had it been due to an execution of CLI. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CLUI instruction. +/// +/// \code{.operation} +/// UIF := 0 +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS +_clui (void) +{ + __builtin_ia32_clui(); +} + +/// Sets the user interrupt flag (UIF). Its effect takes place immediately; a +/// user interrupt may be delivered on the instruction boundary following +/// STUI. Can be executed only if CR4.UINT = 1, the logical processor is in +/// 64-bit mode, and software is not executing inside an enclave; otherwise, +/// each causes an invalid-opcode exception. Causes a transactional abort if +/// executed inside a transactional region; the abort loads EAX as it would +/// had it been due to an execution of STI. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the STUI instruction. +/// +/// \code{.operation} +/// UIF := 1 +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS +_stui (void) +{ + __builtin_ia32_stui(); +} + +/// Get the current value of the user interrupt flag (UIF). Can be executed +/// regardless of CPL and inside a transactional region. Can be executed only +/// if CR4.UINT = 1, the logical processor is in 64-bit mode, and software is +/// not executing inside an enclave; otherwise, it causes an invalid-opcode +/// exception. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TESTUI instruction. +/// +/// \returns The current value of the user interrupt flag (UIF). +/// +/// \code{.operation} +/// CF := UIF +/// ZF := 0 +/// AF := 0 +/// OF := 0 +/// PF := 0 +/// SF := 0 +/// dst := CF +/// \endcode +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_testui (void) +{ + return __builtin_ia32_testui(); +} + +/// Send interprocessor user interrupt. Can be executed only if +/// CR4.UINT = IA32_UINT_TT[0] = 1, the logical processor is in 64-bit mode, +/// and software is not executing inside an enclave; otherwise, it causes an +/// invalid-opcode exception. May be executed at any privilege level, all of +/// its memory accesses are performed with supervisor privilege. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the SENDUIPI instruction +/// +/// \param __a +/// Index of user-interrupt target table entry in user-interrupt target +/// table. +/// +/// \code{.operation} +/// IF __a > UITTSZ +/// GP (0) +/// FI +/// tempUITTE := MEM[UITTADDR + (a<<4)] +/// // tempUITTE must be valid, and can't have any reserved bit set +/// IF (tempUITTE.V == 0 OR tempUITTE[7:1] != 0) +/// GP (0) +/// FI +/// tempUPID := MEM[tempUITTE.UPIDADDR] // under lock +/// // tempUPID can't have any reserved bit set +/// IF (tempUPID[15:2] != 0 OR tempUPID[31:24] != 0) +/// GP (0) // release lock +/// FI +/// tempUPID.PIR[tempUITTE.UV] := 1; +/// IF (tempUPID.SN == 0 AND tempUPID.ON == 0) +/// tempUPID.ON := 1 +/// sendNotify := 1 +/// ELSE +/// sendNotify := 0 +/// FI +/// MEM[tempUITTE.UPIDADDR] := tempUPID // release lock +/// IF sendNotify == 1 +/// IF IA32_APIC_BASE[10] == 1 // local APIC is in x2APIC mode +/// // send ordinary IPI with vector tempUPID.NV to 32-bit physical APIC +/// // ID tempUPID.NDST +/// SendOrdinaryIPI(tempUPID.NV, tempUPID.NDST) +/// ELSE +/// // send ordinary IPI with vector tempUPID.NV to 8-bit physical APIC +/// // ID tempUPID.NDST[15:8] +/// SendOrdinaryIPI(tempUPID.NV, tempUPID.NDST[15:8]) +/// FI +/// FI +/// \endcode +static __inline__ void __DEFAULT_FN_ATTRS +_senduipi (unsigned long long __a) +{ + __builtin_ia32_senduipi(__a); +} + +#endif /* __x86_64__ */ + +#undef __DEFAULT_FN_ATTRS + +#endif /* __UINTRINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/unwind.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/unwind.h new file mode 100755 index 0000000..33e1792 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/unwind.h @@ -0,0 +1,332 @@ +/*===---- unwind.h - Stack unwinding ----------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/ + +#ifndef __CLANG_UNWIND_H +#define __CLANG_UNWIND_H + +#if defined(__APPLE__) && __has_include_next() +/* Darwin (from 11.x on) provide an unwind.h. If that's available, + * use it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE, + * so define that around the include.*/ +# ifndef _GNU_SOURCE +# define _SHOULD_UNDEFINE_GNU_SOURCE +# define _GNU_SOURCE +# endif +// libunwind's unwind.h reflects the current visibility. However, Mozilla +// builds with -fvisibility=hidden and relies on gcc's unwind.h to reset the +// visibility to default and export its contents. gcc also allows users to +// override its override by #defining HIDE_EXPORTS (but note, this only obeys +// the user's -fvisibility setting; it doesn't hide any exports on its own). We +// imitate gcc's header here: +# ifdef HIDE_EXPORTS +# include_next +# else +# pragma GCC visibility push(default) +# include_next +# pragma GCC visibility pop +# endif +# ifdef _SHOULD_UNDEFINE_GNU_SOURCE +# undef _GNU_SOURCE +# undef _SHOULD_UNDEFINE_GNU_SOURCE +# endif +#else + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* It is a bit strange for a header to play with the visibility of the + symbols it declares, but this matches gcc's behavior and some programs + depend on it */ +#ifndef HIDE_EXPORTS +#pragma GCC visibility push(default) +#endif + +typedef uintptr_t _Unwind_Word __attribute__((__mode__(__unwind_word__))); +typedef intptr_t _Unwind_Sword __attribute__((__mode__(__unwind_word__))); +typedef uintptr_t _Unwind_Ptr; +typedef uintptr_t _Unwind_Internal_Ptr; +typedef uint64_t _Unwind_Exception_Class; + +typedef intptr_t _sleb128_t; +typedef uintptr_t _uleb128_t; + +struct _Unwind_Context; +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || \ + defined(__ARM_DWARF_EH__) || defined(__SEH__)) +struct _Unwind_Control_Block; +typedef struct _Unwind_Control_Block _Unwind_Control_Block; +#define _Unwind_Exception _Unwind_Control_Block /* Alias */ +#else +struct _Unwind_Exception; +typedef struct _Unwind_Exception _Unwind_Exception; +#endif +typedef enum { + _URC_NO_REASON = 0, +#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ + !defined(__ARM_DWARF_EH__) && !defined(__SEH__) + _URC_OK = 0, /* used by ARM EHABI */ +#endif + _URC_FOREIGN_EXCEPTION_CAUGHT = 1, + + _URC_FATAL_PHASE2_ERROR = 2, + _URC_FATAL_PHASE1_ERROR = 3, + _URC_NORMAL_STOP = 4, + + _URC_END_OF_STACK = 5, + _URC_HANDLER_FOUND = 6, + _URC_INSTALL_CONTEXT = 7, + _URC_CONTINUE_UNWIND = 8, +#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ + !defined(__ARM_DWARF_EH__) && !defined(__SEH__) + _URC_FAILURE = 9 /* used by ARM EHABI */ +#endif +} _Unwind_Reason_Code; + +typedef enum { + _UA_SEARCH_PHASE = 1, + _UA_CLEANUP_PHASE = 2, + + _UA_HANDLER_FRAME = 4, + _UA_FORCE_UNWIND = 8, + _UA_END_OF_STACK = 16 /* gcc extension to C++ ABI */ +} _Unwind_Action; + +typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, + _Unwind_Exception *); + +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || \ + defined(__ARM_DWARF_EH__) || defined(__SEH__)) +typedef struct _Unwind_Control_Block _Unwind_Control_Block; +typedef uint32_t _Unwind_EHT_Header; + +struct _Unwind_Control_Block { + uint64_t exception_class; + void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *); + /* unwinder cache (private fields for the unwinder's use) */ + struct { + uint32_t reserved1; /* forced unwind stop function, 0 if not forced */ + uint32_t reserved2; /* personality routine */ + uint32_t reserved3; /* callsite */ + uint32_t reserved4; /* forced unwind stop argument */ + uint32_t reserved5; + } unwinder_cache; + /* propagation barrier cache (valid after phase 1) */ + struct { + uint32_t sp; + uint32_t bitpattern[5]; + } barrier_cache; + /* cleanup cache (preserved over cleanup) */ + struct { + uint32_t bitpattern[4]; + } cleanup_cache; + /* personality cache (for personality's benefit) */ + struct { + uint32_t fnstart; /* function start address */ + _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */ + uint32_t additional; /* additional data */ + uint32_t reserved1; + } pr_cache; + long long int : 0; /* force alignment of next item to 8-byte boundary */ +} __attribute__((__aligned__(8))); +#else +struct _Unwind_Exception { + _Unwind_Exception_Class exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; +#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__) + _Unwind_Word private_[6]; +#else + _Unwind_Word private_1; + _Unwind_Word private_2; +#endif + /* The Itanium ABI requires that _Unwind_Exception objects are "double-word + * aligned". GCC has interpreted this to mean "use the maximum useful + * alignment for the target"; so do we. */ +} __attribute__((__aligned__)); +#endif + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action, + _Unwind_Exception_Class, + _Unwind_Exception *, + struct _Unwind_Context *, + void *); + +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(int, _Unwind_Action, + _Unwind_Exception_Class, + _Unwind_Exception *, + struct _Unwind_Context *); +typedef _Unwind_Personality_Fn __personality_routine; + +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *, + void *); + +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || \ + defined(__ARM_DWARF_EH__) || defined(__SEH__)) +typedef enum { + _UVRSC_CORE = 0, /* integer register */ + _UVRSC_VFP = 1, /* vfp */ + _UVRSC_WMMXD = 3, /* Intel WMMX data register */ + _UVRSC_WMMXC = 4, /* Intel WMMX control register */ + _UVRSC_PSEUDO = 5 /* Special purpose pseudo register */ +} _Unwind_VRS_RegClass; + +typedef enum { + _UVRSD_UINT32 = 0, + _UVRSD_VFPX = 1, + _UVRSD_UINT64 = 3, + _UVRSD_FLOAT = 4, + _UVRSD_DOUBLE = 5 +} _Unwind_VRS_DataRepresentation; + +typedef enum { + _UVRSR_OK = 0, + _UVRSR_NOT_IMPLEMENTED = 1, + _UVRSR_FAILED = 2 +} _Unwind_VRS_Result; + +typedef uint32_t _Unwind_State; +#define _US_VIRTUAL_UNWIND_FRAME ((_Unwind_State)0) +#define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1) +#define _US_UNWIND_FRAME_RESUME ((_Unwind_State)2) +#define _US_ACTION_MASK ((_Unwind_State)3) +#define _US_FORCE_UNWIND ((_Unwind_State)8) + +_Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context, + _Unwind_VRS_RegClass __regclass, + uint32_t __regno, + _Unwind_VRS_DataRepresentation __representation, + void *__valuep); + +_Unwind_VRS_Result _Unwind_VRS_Set(struct _Unwind_Context *__context, + _Unwind_VRS_RegClass __regclass, + uint32_t __regno, + _Unwind_VRS_DataRepresentation __representation, + void *__valuep); + +static __inline__ +_Unwind_Word _Unwind_GetGR(struct _Unwind_Context *__context, int __index) { + _Unwind_Word __value; + _Unwind_VRS_Get(__context, _UVRSC_CORE, __index, _UVRSD_UINT32, &__value); + return __value; +} + +static __inline__ +void _Unwind_SetGR(struct _Unwind_Context *__context, int __index, + _Unwind_Word __value) { + _Unwind_VRS_Set(__context, _UVRSC_CORE, __index, _UVRSD_UINT32, &__value); +} + +static __inline__ +_Unwind_Word _Unwind_GetIP(struct _Unwind_Context *__context) { + _Unwind_Word __ip = _Unwind_GetGR(__context, 15); + return __ip & ~(_Unwind_Word)(0x1); /* Remove thumb mode bit. */ +} + +static __inline__ +void _Unwind_SetIP(struct _Unwind_Context *__context, _Unwind_Word __value) { + _Unwind_Word __thumb_mode_bit = _Unwind_GetGR(__context, 15) & 0x1; + _Unwind_SetGR(__context, 15, __value | __thumb_mode_bit); +} +#else +_Unwind_Word _Unwind_GetGR(struct _Unwind_Context *, int); +void _Unwind_SetGR(struct _Unwind_Context *, int, _Unwind_Word); + +_Unwind_Word _Unwind_GetIP(struct _Unwind_Context *); +void _Unwind_SetIP(struct _Unwind_Context *, _Unwind_Word); +#endif + + +_Unwind_Word _Unwind_GetIPInfo(struct _Unwind_Context *, int *); + +_Unwind_Word _Unwind_GetCFA(struct _Unwind_Context *); + +_Unwind_Word _Unwind_GetBSP(struct _Unwind_Context *); + +void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context *); + +_Unwind_Ptr _Unwind_GetRegionStart(struct _Unwind_Context *); + +/* DWARF EH functions; currently not available on Darwin/ARM */ +#if !defined(__APPLE__) || !defined(__arm__) +_Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *); +_Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception *, _Unwind_Stop_Fn, + void *); +void _Unwind_DeleteException(_Unwind_Exception *); +void _Unwind_Resume(_Unwind_Exception *); +_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *); + +#endif + +_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *); + +/* setjmp(3)/longjmp(3) stuff */ +typedef struct SjLj_Function_Context *_Unwind_FunctionContext_t; + +void _Unwind_SjLj_Register(_Unwind_FunctionContext_t); +void _Unwind_SjLj_Unregister(_Unwind_FunctionContext_t); +_Unwind_Reason_Code _Unwind_SjLj_RaiseException(_Unwind_Exception *); +_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(_Unwind_Exception *, + _Unwind_Stop_Fn, void *); +void _Unwind_SjLj_Resume(_Unwind_Exception *); +_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(_Unwind_Exception *); + +void *_Unwind_FindEnclosingFunction(void *); + +#ifdef __APPLE__ + +_Unwind_Ptr _Unwind_GetDataRelBase(struct _Unwind_Context *) + __attribute__((__unavailable__)); +_Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *) + __attribute__((__unavailable__)); + +/* Darwin-specific functions */ +void __register_frame(const void *); +void __deregister_frame(const void *); + +struct dwarf_eh_bases { + uintptr_t tbase; + uintptr_t dbase; + uintptr_t func; +}; +void *_Unwind_Find_FDE(const void *, struct dwarf_eh_bases *); + +void __register_frame_info_bases(const void *, void *, void *, void *) + __attribute__((__unavailable__)); +void __register_frame_info(const void *, void *) __attribute__((__unavailable__)); +void __register_frame_info_table_bases(const void *, void*, void *, void *) + __attribute__((__unavailable__)); +void __register_frame_info_table(const void *, void *) + __attribute__((__unavailable__)); +void __register_frame_table(const void *) __attribute__((__unavailable__)); +void __deregister_frame_info(const void *) __attribute__((__unavailable__)); +void __deregister_frame_info_bases(const void *)__attribute__((__unavailable__)); + +#else + +_Unwind_Ptr _Unwind_GetDataRelBase(struct _Unwind_Context *); +_Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *); + +#endif + + +#ifndef HIDE_EXPORTS +#pragma GCC visibility pop +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* __CLANG_UNWIND_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/usermsrintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/usermsrintrin.h new file mode 100755 index 0000000..6138837 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/usermsrintrin.h @@ -0,0 +1,51 @@ +/*===--------------- usermsrintrin.h - USERMSR intrinsics -----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __X86GPRINTRIN_H +#error "Never use directly; include instead." +#endif // __X86GPRINTRIN_H + +#ifndef __USERMSRINTRIN_H +#define __USERMSRINTRIN_H +#ifdef __x86_64__ + +/// Reads the contents of a 64-bit MSR specified in \a __A into \a dst. +/// +/// This intrinsic corresponds to the URDMSR instruction. +/// \param __A +/// An unsigned long long. +/// +/// \code{.operation} +/// DEST := MSR[__A] +/// \endcode +static __inline__ unsigned long long + __attribute__((__always_inline__, __nodebug__, __target__("usermsr"))) + _urdmsr(unsigned long long __A) { + return __builtin_ia32_urdmsr(__A); +} + +/// Writes the contents of \a __B into the 64-bit MSR specified in \a __A. +/// +/// This intrinsic corresponds to the UWRMSR instruction. +/// +/// \param __A +/// An unsigned long long. +/// \param __B +/// An unsigned long long. +/// +/// \code{.operation} +/// MSR[__A] := __B +/// \endcode +static __inline__ void + __attribute__((__always_inline__, __nodebug__, __target__("usermsr"))) + _uwrmsr(unsigned long long __A, unsigned long long __B) { + return __builtin_ia32_uwrmsr(__A, __B); +} + +#endif // __x86_64__ +#endif // __USERMSRINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vadefs.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vadefs.h new file mode 100755 index 0000000..b617568 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vadefs.h @@ -0,0 +1,51 @@ +/* ===-------- vadefs.h ---------------------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +/* Only include this if we are aiming for MSVC compatibility. */ +#ifndef _MSC_VER +#include_next +#else + +#ifndef __clang_vadefs_h +#define __clang_vadefs_h + +#include_next + +/* Override macros from vadefs.h with definitions that work with Clang. */ +#ifdef _crt_va_start +#undef _crt_va_start +#define _crt_va_start(ap, param) __builtin_va_start(ap, param) +#endif +#ifdef _crt_va_end +#undef _crt_va_end +#define _crt_va_end(ap) __builtin_va_end(ap) +#endif +#ifdef _crt_va_arg +#undef _crt_va_arg +#define _crt_va_arg(ap, type) __builtin_va_arg(ap, type) +#endif + +/* VS 2015 switched to double underscore names, which is an improvement, but now + * we have to intercept those names too. + */ +#ifdef __crt_va_start +#undef __crt_va_start +#define __crt_va_start(ap, param) __builtin_va_start(ap, param) +#endif +#ifdef __crt_va_end +#undef __crt_va_end +#define __crt_va_end(ap) __builtin_va_end(ap) +#endif +#ifdef __crt_va_arg +#undef __crt_va_arg +#define __crt_va_arg(ap, type) __builtin_va_arg(ap, type) +#endif + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vaesintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vaesintrin.h new file mode 100755 index 0000000..d7c162f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vaesintrin.h @@ -0,0 +1,87 @@ +/*===------------------ vaesintrin.h - VAES intrinsics ---------------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __VAESINTRIN_H +#define __VAESINTRIN_H + +/* Default attributes for YMM forms. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("vaes"), __min_vector_width__(256))) + +/* Default attributes for ZMM forms. */ +#define __DEFAULT_FN_ATTRS_F \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("avx512f,evex512,vaes"), \ + __min_vector_width__(512))) + +static __inline__ __m256i __DEFAULT_FN_ATTRS + _mm256_aesenc_epi128(__m256i __A, __m256i __B) +{ + return (__m256i) __builtin_ia32_aesenc256((__v4di) __A, + (__v4di) __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS + _mm256_aesdec_epi128(__m256i __A, __m256i __B) +{ + return (__m256i) __builtin_ia32_aesdec256((__v4di) __A, + (__v4di) __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS + _mm256_aesenclast_epi128(__m256i __A, __m256i __B) +{ + return (__m256i) __builtin_ia32_aesenclast256((__v4di) __A, + (__v4di) __B); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS + _mm256_aesdeclast_epi128(__m256i __A, __m256i __B) +{ + return (__m256i) __builtin_ia32_aesdeclast256((__v4di) __A, + (__v4di) __B); +} + +#ifdef __AVX512FINTRIN_H +static __inline__ __m512i __DEFAULT_FN_ATTRS_F + _mm512_aesenc_epi128(__m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_aesenc512((__v8di) __A, + (__v8di) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_F + _mm512_aesdec_epi128(__m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_aesdec512((__v8di) __A, + (__v8di) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_F + _mm512_aesenclast_epi128(__m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_aesenclast512((__v8di) __A, + (__v8di) __B); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS_F + _mm512_aesdeclast_epi128(__m512i __A, __m512i __B) +{ + return (__m512i) __builtin_ia32_aesdeclast512((__v8di) __A, + (__v8di) __B); +} +#endif // __AVX512FINTRIN_H + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_F + +#endif // __VAESINTRIN_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/varargs.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/varargs.h new file mode 100755 index 0000000..d33ddc5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/varargs.h @@ -0,0 +1,16 @@ +/*===---- varargs.h - Variable argument handling -------------------------------------=== +* +* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +* See https://llvm.org/LICENSE.txt for license information. +* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +* +*===-----------------------------------------------------------------------=== +*/ +#ifndef __VARARGS_H +#define __VARARGS_H +#if defined(__MVS__) && __has_include_next() +#include_next +#else +#error "Please use instead of " +#endif /* __MVS__ */ +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vecintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vecintrin.h new file mode 100755 index 0000000..338ea51 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vecintrin.h @@ -0,0 +1,12868 @@ +/*===---- vecintrin.h - Vector intrinsics ----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _VECINTRIN_H +#define _VECINTRIN_H + +#if defined(__s390x__) && defined(__VEC__) + +#define __ATTRS_ai __attribute__((__always_inline__)) +#define __ATTRS_o __attribute__((__overloadable__)) +#define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__)) + +#define __constant(PARM) \ + __attribute__((__enable_if__ ((PARM) == (PARM), \ + "argument must be a constant integer"))) +#define __constant_range(PARM, LOW, HIGH) \ + __attribute__((__enable_if__ ((PARM) >= (LOW) && (PARM) <= (HIGH), \ + "argument must be a constant integer from " #LOW " to " #HIGH))) +#define __constant_pow2_range(PARM, LOW, HIGH) \ + __attribute__((__enable_if__ ((PARM) >= (LOW) && (PARM) <= (HIGH) && \ + ((PARM) & ((PARM) - 1)) == 0, \ + "argument must be a constant power of 2 from " #LOW " to " #HIGH))) + +/*-- __lcbb -----------------------------------------------------------------*/ + +extern __ATTRS_o unsigned int +__lcbb(const void *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +#define __lcbb(X, Y) ((__typeof__((__lcbb)((X), (Y)))) \ + __builtin_s390_lcbb((X), __builtin_constant_p((Y))? \ + ((Y) == 64 ? 0 : \ + (Y) == 128 ? 1 : \ + (Y) == 256 ? 2 : \ + (Y) == 512 ? 3 : \ + (Y) == 1024 ? 4 : \ + (Y) == 2048 ? 5 : \ + (Y) == 4096 ? 6 : 0) : 0)) + +/*-- vec_extract ------------------------------------------------------------*/ + +static inline __ATTRS_o_ai signed char +vec_extract(__vector signed char __vec, int __index) { + return __vec[__index & 15]; +} + +static inline __ATTRS_o_ai unsigned char +vec_extract(__vector __bool char __vec, int __index) { + return __vec[__index & 15]; +} + +static inline __ATTRS_o_ai unsigned char +vec_extract(__vector unsigned char __vec, int __index) { + return __vec[__index & 15]; +} + +static inline __ATTRS_o_ai signed short +vec_extract(__vector signed short __vec, int __index) { + return __vec[__index & 7]; +} + +static inline __ATTRS_o_ai unsigned short +vec_extract(__vector __bool short __vec, int __index) { + return __vec[__index & 7]; +} + +static inline __ATTRS_o_ai unsigned short +vec_extract(__vector unsigned short __vec, int __index) { + return __vec[__index & 7]; +} + +static inline __ATTRS_o_ai signed int +vec_extract(__vector signed int __vec, int __index) { + return __vec[__index & 3]; +} + +static inline __ATTRS_o_ai unsigned int +vec_extract(__vector __bool int __vec, int __index) { + return __vec[__index & 3]; +} + +static inline __ATTRS_o_ai unsigned int +vec_extract(__vector unsigned int __vec, int __index) { + return __vec[__index & 3]; +} + +static inline __ATTRS_o_ai signed long long +vec_extract(__vector signed long long __vec, int __index) { + return __vec[__index & 1]; +} + +static inline __ATTRS_o_ai unsigned long long +vec_extract(__vector __bool long long __vec, int __index) { + return __vec[__index & 1]; +} + +static inline __ATTRS_o_ai unsigned long long +vec_extract(__vector unsigned long long __vec, int __index) { + return __vec[__index & 1]; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai float +vec_extract(__vector float __vec, int __index) { + return __vec[__index & 3]; +} +#endif + +static inline __ATTRS_o_ai double +vec_extract(__vector double __vec, int __index) { + return __vec[__index & 1]; +} + +/*-- vec_insert -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_insert(signed char __scalar, __vector signed char __vec, int __index) { + __vec[__index & 15] = __scalar; + return __vec; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_insert(unsigned char __scalar, __vector __bool char __vec, int __index) { + __vector unsigned char __newvec = (__vector unsigned char)__vec; + __newvec[__index & 15] = (unsigned char)__scalar; + return __newvec; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_insert(unsigned char __scalar, __vector unsigned char __vec, int __index) { + __vec[__index & 15] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed short +vec_insert(signed short __scalar, __vector signed short __vec, int __index) { + __vec[__index & 7] = __scalar; + return __vec; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_insert(unsigned short __scalar, __vector __bool short __vec, + int __index) { + __vector unsigned short __newvec = (__vector unsigned short)__vec; + __newvec[__index & 7] = (unsigned short)__scalar; + return __newvec; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_insert(unsigned short __scalar, __vector unsigned short __vec, + int __index) { + __vec[__index & 7] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed int +vec_insert(signed int __scalar, __vector signed int __vec, int __index) { + __vec[__index & 3] = __scalar; + return __vec; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_insert(unsigned int __scalar, __vector __bool int __vec, int __index) { + __vector unsigned int __newvec = (__vector unsigned int)__vec; + __newvec[__index & 3] = __scalar; + return __newvec; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_insert(unsigned int __scalar, __vector unsigned int __vec, int __index) { + __vec[__index & 3] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_insert(signed long long __scalar, __vector signed long long __vec, + int __index) { + __vec[__index & 1] = __scalar; + return __vec; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_insert(unsigned long long __scalar, __vector __bool long long __vec, + int __index) { + __vector unsigned long long __newvec = (__vector unsigned long long)__vec; + __newvec[__index & 1] = __scalar; + return __newvec; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_insert(unsigned long long __scalar, __vector unsigned long long __vec, + int __index) { + __vec[__index & 1] = __scalar; + return __vec; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_insert(float __scalar, __vector float __vec, int __index) { + __vec[__index & 1] = __scalar; + return __vec; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_insert(double __scalar, __vector double __vec, int __index) { + __vec[__index & 1] = __scalar; + return __vec; +} + +/*-- vec_promote ------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_promote(signed char __scalar, int __index) { + const __vector signed char __zero = (__vector signed char)0; + __vector signed char __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); + __vec[__index & 15] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_promote(unsigned char __scalar, int __index) { + const __vector unsigned char __zero = (__vector unsigned char)0; + __vector unsigned char __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); + __vec[__index & 15] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed short +vec_promote(signed short __scalar, int __index) { + const __vector signed short __zero = (__vector signed short)0; + __vector signed short __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1, -1, -1, -1, -1); + __vec[__index & 7] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_promote(unsigned short __scalar, int __index) { + const __vector unsigned short __zero = (__vector unsigned short)0; + __vector unsigned short __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1, -1, -1, -1, -1); + __vec[__index & 7] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed int +vec_promote(signed int __scalar, int __index) { + const __vector signed int __zero = (__vector signed int)0; + __vector signed int __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1); + __vec[__index & 3] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_promote(unsigned int __scalar, int __index) { + const __vector unsigned int __zero = (__vector unsigned int)0; + __vector unsigned int __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1); + __vec[__index & 3] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_promote(signed long long __scalar, int __index) { + const __vector signed long long __zero = (__vector signed long long)0; + __vector signed long long __vec = __builtin_shufflevector(__zero, __zero, + -1, -1); + __vec[__index & 1] = __scalar; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_promote(unsigned long long __scalar, int __index) { + const __vector unsigned long long __zero = (__vector unsigned long long)0; + __vector unsigned long long __vec = __builtin_shufflevector(__zero, __zero, + -1, -1); + __vec[__index & 1] = __scalar; + return __vec; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_promote(float __scalar, int __index) { + const __vector float __zero = (__vector float)0.0f; + __vector float __vec = __builtin_shufflevector(__zero, __zero, + -1, -1, -1, -1); + __vec[__index & 3] = __scalar; + return __vec; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_promote(double __scalar, int __index) { + const __vector double __zero = (__vector double)0.0; + __vector double __vec = __builtin_shufflevector(__zero, __zero, -1, -1); + __vec[__index & 1] = __scalar; + return __vec; +} + +/*-- vec_insert_and_zero ----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_insert_and_zero(const signed char *__ptr) { + __vector signed char __vec = (__vector signed char)0; + __vec[7] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_insert_and_zero(const unsigned char *__ptr) { + __vector unsigned char __vec = (__vector unsigned char)0; + __vec[7] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed short +vec_insert_and_zero(const signed short *__ptr) { + __vector signed short __vec = (__vector signed short)0; + __vec[3] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_insert_and_zero(const unsigned short *__ptr) { + __vector unsigned short __vec = (__vector unsigned short)0; + __vec[3] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed int +vec_insert_and_zero(const signed int *__ptr) { + __vector signed int __vec = (__vector signed int)0; + __vec[1] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_insert_and_zero(const unsigned int *__ptr) { + __vector unsigned int __vec = (__vector unsigned int)0; + __vec[1] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_insert_and_zero(const signed long long *__ptr) { + __vector signed long long __vec = (__vector signed long long)0; + __vec[0] = *__ptr; + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_insert_and_zero(const unsigned long long *__ptr) { + __vector unsigned long long __vec = (__vector unsigned long long)0; + __vec[0] = *__ptr; + return __vec; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_insert_and_zero(const float *__ptr) { + __vector float __vec = (__vector float)0.0f; + __vec[1] = *__ptr; + return __vec; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_insert_and_zero(const double *__ptr) { + __vector double __vec = (__vector double)0.0; + __vec[0] = *__ptr; + return __vec; +} + +/*-- vec_perm ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_perm(__vector signed char __a, __vector signed char __b, + __vector unsigned char __c) { + return (__vector signed char)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_perm(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector unsigned char)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_perm(__vector __bool char __a, __vector __bool char __b, + __vector unsigned char __c) { + return (__vector __bool char)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector signed short +vec_perm(__vector signed short __a, __vector signed short __b, + __vector unsigned char __c) { + return (__vector signed short)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_perm(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned char __c) { + return (__vector unsigned short)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_perm(__vector __bool short __a, __vector __bool short __b, + __vector unsigned char __c) { + return (__vector __bool short)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector signed int +vec_perm(__vector signed int __a, __vector signed int __b, + __vector unsigned char __c) { + return (__vector signed int)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_perm(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned char __c) { + return (__vector unsigned int)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_perm(__vector __bool int __a, __vector __bool int __b, + __vector unsigned char __c) { + return (__vector __bool int)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_perm(__vector signed long long __a, __vector signed long long __b, + __vector unsigned char __c) { + return (__vector signed long long)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_perm(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned char __c) { + return (__vector unsigned long long)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_perm(__vector __bool long long __a, __vector __bool long long __b, + __vector unsigned char __c) { + return (__vector __bool long long)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_perm(__vector signed __int128 __a, __vector signed __int128 __b, + __vector unsigned char __c) { + return (__vector signed __int128)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_perm(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned char __c) { + return (__vector unsigned __int128)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_perm(__vector __bool __int128 __a, __vector __bool __int128 __b, + __vector unsigned char __c) { + return (__vector __bool __int128)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_perm(__vector float __a, __vector float __b, + __vector unsigned char __c) { + return (__vector float)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_perm(__vector double __a, __vector double __b, + __vector unsigned char __c) { + return (__vector double)__builtin_s390_vperm( + (__vector unsigned char)__a, (__vector unsigned char)__b, __c); +} + +/*-- vec_permi --------------------------------------------------------------*/ + +// This prototype is deprecated. +extern __ATTRS_o __vector signed long long +vec_permi(__vector signed long long __a, __vector signed long long __b, + int __c) + __constant_range(__c, 0, 3); + +// This prototype is deprecated. +extern __ATTRS_o __vector unsigned long long +vec_permi(__vector unsigned long long __a, __vector unsigned long long __b, + int __c) + __constant_range(__c, 0, 3); + +// This prototype is deprecated. +extern __ATTRS_o __vector __bool long long +vec_permi(__vector __bool long long __a, __vector __bool long long __b, + int __c) + __constant_range(__c, 0, 3); + +// This prototype is deprecated. +extern __ATTRS_o __vector double +vec_permi(__vector double __a, __vector double __b, int __c) + __constant_range(__c, 0, 3); + +#define vec_permi(X, Y, Z) ((__typeof__((vec_permi)((X), (Y), (Z)))) \ + __builtin_s390_vpdi((__vector unsigned long long)(X), \ + (__vector unsigned long long)(Y), \ + (((Z) & 2) << 1) | ((Z) & 1))) + +/*-- vec_bperm --------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_ai __vector unsigned long long +vec_bperm(__vector unsigned __int128 __a, __vector unsigned char __b) { + return __builtin_s390_vbperm((__vector unsigned char)__a, __b); +} +#endif + +/*-- vec_bperm_u128 ---------------------------------------------------------*/ + +#if __ARCH__ >= 12 +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned long long +vec_bperm_u128(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vbperm(__a, __b); +} +#endif + +/*-- vec_revb ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_revb(__vector signed short __vec) { + return (__vector signed short) + __builtin_s390_vlbrh((__vector unsigned short)__vec); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_revb(__vector unsigned short __vec) { + return __builtin_s390_vlbrh(__vec); +} + +static inline __ATTRS_o_ai __vector signed int +vec_revb(__vector signed int __vec) { + return (__vector signed int) + __builtin_s390_vlbrf((__vector unsigned int)__vec); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_revb(__vector unsigned int __vec) { + return __builtin_s390_vlbrf(__vec); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_revb(__vector signed long long __vec) { + return (__vector signed long long) + __builtin_s390_vlbrg((__vector unsigned long long)__vec); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_revb(__vector unsigned long long __vec) { + return __builtin_s390_vlbrg(__vec); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_revb(__vector signed __int128 __vec) { + return (__vector signed __int128) + __builtin_s390_vlbrq((unsigned __int128)__vec); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_revb(__vector unsigned __int128 __vec) { + return (__vector unsigned __int128) + __builtin_s390_vlbrq((unsigned __int128)__vec); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_revb(__vector float __vec) { + return (__vector float) + __builtin_s390_vlbrf((__vector unsigned int)__vec); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_revb(__vector double __vec) { + return (__vector double) + __builtin_s390_vlbrg((__vector unsigned long long)__vec); +} + +/*-- vec_reve ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_reve(__vector signed char __vec) { + return (__vector signed char) { __vec[15], __vec[14], __vec[13], __vec[12], + __vec[11], __vec[10], __vec[9], __vec[8], + __vec[7], __vec[6], __vec[5], __vec[4], + __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_reve(__vector unsigned char __vec) { + return (__vector unsigned char) { __vec[15], __vec[14], __vec[13], __vec[12], + __vec[11], __vec[10], __vec[9], __vec[8], + __vec[7], __vec[6], __vec[5], __vec[4], + __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector __bool char +vec_reve(__vector __bool char __vec) { + return (__vector __bool char) { __vec[15], __vec[14], __vec[13], __vec[12], + __vec[11], __vec[10], __vec[9], __vec[8], + __vec[7], __vec[6], __vec[5], __vec[4], + __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector signed short +vec_reve(__vector signed short __vec) { + return (__vector signed short) { __vec[7], __vec[6], __vec[5], __vec[4], + __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_reve(__vector unsigned short __vec) { + return (__vector unsigned short) { __vec[7], __vec[6], __vec[5], __vec[4], + __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_reve(__vector __bool short __vec) { + return (__vector __bool short) { __vec[7], __vec[6], __vec[5], __vec[4], + __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector signed int +vec_reve(__vector signed int __vec) { + return (__vector signed int) { __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_reve(__vector unsigned int __vec) { + return (__vector unsigned int) { __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_reve(__vector __bool int __vec) { + return (__vector __bool int) { __vec[3], __vec[2], __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_reve(__vector signed long long __vec) { + return (__vector signed long long) { __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_reve(__vector unsigned long long __vec) { + return (__vector unsigned long long) { __vec[1], __vec[0] }; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_reve(__vector __bool long long __vec) { + return (__vector __bool long long) { __vec[1], __vec[0] }; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_reve(__vector float __vec) { + return (__vector float) { __vec[3], __vec[2], __vec[1], __vec[0] }; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_reve(__vector double __vec) { + return (__vector double) { __vec[1], __vec[0] }; +} + +/*-- vec_sel ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_sel(__vector signed char __a, __vector signed char __b, + __vector unsigned char __c) { + return (((__vector signed char)__c & __b) | + (~(__vector signed char)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed char +vec_sel(__vector signed char __a, __vector signed char __b, + __vector __bool char __c) { + return (((__vector signed char)__c & __b) | + (~(__vector signed char)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_sel(__vector __bool char __a, __vector __bool char __b, + __vector unsigned char __c) { + return (((__vector __bool char)__c & __b) | + (~(__vector __bool char)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_sel(__vector __bool char __a, __vector __bool char __b, + __vector __bool char __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_sel(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_sel(__vector unsigned char __a, __vector unsigned char __b, + __vector __bool char __c) { + return (((__vector unsigned char)__c & __b) | + (~(__vector unsigned char)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed short +vec_sel(__vector signed short __a, __vector signed short __b, + __vector unsigned short __c) { + return (((__vector signed short)__c & __b) | + (~(__vector signed short)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed short +vec_sel(__vector signed short __a, __vector signed short __b, + __vector __bool short __c) { + return (((__vector signed short)__c & __b) | + (~(__vector signed short)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_sel(__vector __bool short __a, __vector __bool short __b, + __vector unsigned short __c) { + return (((__vector __bool short)__c & __b) | + (~(__vector __bool short)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_sel(__vector __bool short __a, __vector __bool short __b, + __vector __bool short __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_sel(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_sel(__vector unsigned short __a, __vector unsigned short __b, + __vector __bool short __c) { + return (((__vector unsigned short)__c & __b) | + (~(__vector unsigned short)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed int +vec_sel(__vector signed int __a, __vector signed int __b, + __vector unsigned int __c) { + return (((__vector signed int)__c & __b) | + (~(__vector signed int)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed int +vec_sel(__vector signed int __a, __vector signed int __b, + __vector __bool int __c) { + return (((__vector signed int)__c & __b) | + (~(__vector signed int)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_sel(__vector __bool int __a, __vector __bool int __b, + __vector unsigned int __c) { + return (((__vector __bool int)__c & __b) | + (~(__vector __bool int)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_sel(__vector __bool int __a, __vector __bool int __b, + __vector __bool int __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_sel(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_sel(__vector unsigned int __a, __vector unsigned int __b, + __vector __bool int __c) { + return (((__vector unsigned int)__c & __b) | + (~(__vector unsigned int)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_sel(__vector signed long long __a, __vector signed long long __b, + __vector unsigned long long __c) { + return (((__vector signed long long)__c & __b) | + (~(__vector signed long long)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_sel(__vector signed long long __a, __vector signed long long __b, + __vector __bool long long __c) { + return (((__vector signed long long)__c & __b) | + (~(__vector signed long long)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_sel(__vector __bool long long __a, __vector __bool long long __b, + __vector unsigned long long __c) { + return (((__vector __bool long long)__c & __b) | + (~(__vector __bool long long)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_sel(__vector __bool long long __a, __vector __bool long long __b, + __vector __bool long long __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_sel(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned long long __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_sel(__vector unsigned long long __a, __vector unsigned long long __b, + __vector __bool long long __c) { + return (((__vector unsigned long long)__c & __b) | + (~(__vector unsigned long long)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_sel(__vector signed __int128 __a, __vector signed __int128 __b, + __vector unsigned __int128 __c) { + return (((__vector signed __int128)__c & __b) | + (~(__vector signed __int128)__c & __a)); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_sel(__vector signed __int128 __a, __vector signed __int128 __b, + __vector __bool __int128 __c) { + return (((__vector signed __int128)__c & __b) | + (~(__vector signed __int128)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_sel(__vector __bool __int128 __a, __vector __bool __int128 __b, + __vector unsigned __int128 __c) { + return (((__vector __bool __int128)__c & __b) | + (~(__vector __bool __int128)__c & __a)); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_sel(__vector __bool __int128 __a, __vector __bool __int128 __b, + __vector __bool __int128 __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_sel(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return (__c & __b) | (~__c & __a); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_sel(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector __bool __int128 __c) { + return (((__vector unsigned __int128)__c & __b) | + (~(__vector unsigned __int128)__c & __a)); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_sel(__vector float __a, __vector float __b, __vector unsigned int __c) { + return (__vector float)((__c & (__vector unsigned int)__b) | + (~__c & (__vector unsigned int)__a)); +} + +static inline __ATTRS_o_ai __vector float +vec_sel(__vector float __a, __vector float __b, __vector __bool int __c) { + __vector unsigned int __ac = (__vector unsigned int)__a; + __vector unsigned int __bc = (__vector unsigned int)__b; + __vector unsigned int __cc = (__vector unsigned int)__c; + return (__vector float)((__cc & __bc) | (~__cc & __ac)); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_sel(__vector double __a, __vector double __b, + __vector unsigned long long __c) { + return (__vector double)((__c & (__vector unsigned long long)__b) | + (~__c & (__vector unsigned long long)__a)); +} + +static inline __ATTRS_o_ai __vector double +vec_sel(__vector double __a, __vector double __b, + __vector __bool long long __c) { + __vector unsigned long long __ac = (__vector unsigned long long)__a; + __vector unsigned long long __bc = (__vector unsigned long long)__b; + __vector unsigned long long __cc = (__vector unsigned long long)__c; + return (__vector double)((__cc & __bc) | (~__cc & __ac)); +} + +/*-- vec_gather_element -----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed int +vec_gather_element(__vector signed int __vec, + __vector unsigned int __offset, + const signed int *__ptr, int __index) + __constant_range(__index, 0, 3) { + __vec[__index] = *(const signed int *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_gather_element(__vector __bool int __vec, + __vector unsigned int __offset, + const unsigned int *__ptr, int __index) + __constant_range(__index, 0, 3) { + __vec[__index] = *(const unsigned int *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_gather_element(__vector unsigned int __vec, + __vector unsigned int __offset, + const unsigned int *__ptr, int __index) + __constant_range(__index, 0, 3) { + __vec[__index] = *(const unsigned int *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_gather_element(__vector signed long long __vec, + __vector unsigned long long __offset, + const signed long long *__ptr, int __index) + __constant_range(__index, 0, 1) { + __vec[__index] = *(const signed long long *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_gather_element(__vector __bool long long __vec, + __vector unsigned long long __offset, + const unsigned long long *__ptr, int __index) + __constant_range(__index, 0, 1) { + __vec[__index] = *(const unsigned long long *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_gather_element(__vector unsigned long long __vec, + __vector unsigned long long __offset, + const unsigned long long *__ptr, int __index) + __constant_range(__index, 0, 1) { + __vec[__index] = *(const unsigned long long *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_gather_element(__vector float __vec, + __vector unsigned int __offset, + const float *__ptr, int __index) + __constant_range(__index, 0, 3) { + __vec[__index] = *(const float *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_gather_element(__vector double __vec, + __vector unsigned long long __offset, + const double *__ptr, int __index) + __constant_range(__index, 0, 1) { + __vec[__index] = *(const double *)( + (const char *)__ptr + __offset[__index]); + return __vec; +} + +/*-- vec_scatter_element ----------------------------------------------------*/ + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector signed int __vec, + __vector unsigned int __offset, + signed int *__ptr, int __index) + __constant_range(__index, 0, 3) { + *(signed int *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector __bool int __vec, + __vector unsigned int __offset, + unsigned int *__ptr, int __index) + __constant_range(__index, 0, 3) { + *(unsigned int *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector unsigned int __vec, + __vector unsigned int __offset, + unsigned int *__ptr, int __index) + __constant_range(__index, 0, 3) { + *(unsigned int *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector signed long long __vec, + __vector unsigned long long __offset, + signed long long *__ptr, int __index) + __constant_range(__index, 0, 1) { + *(signed long long *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector __bool long long __vec, + __vector unsigned long long __offset, + unsigned long long *__ptr, int __index) + __constant_range(__index, 0, 1) { + *(unsigned long long *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector unsigned long long __vec, + __vector unsigned long long __offset, + unsigned long long *__ptr, int __index) + __constant_range(__index, 0, 1) { + *(unsigned long long *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai void +vec_scatter_element(__vector float __vec, + __vector unsigned int __offset, + float *__ptr, int __index) + __constant_range(__index, 0, 3) { + *(float *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} +#endif + +static inline __ATTRS_o_ai void +vec_scatter_element(__vector double __vec, + __vector unsigned long long __offset, + double *__ptr, int __index) + __constant_range(__index, 0, 1) { + *(double *)((char *)__ptr + __offset[__index]) = + __vec[__index]; +} + +/*-- vec_xl -----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_xl(long __offset, const signed char *__ptr) { + __vector signed char V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed char)); + return V; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_xl(long __offset, const unsigned char *__ptr) { + __vector unsigned char V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned char)); + return V; +} + +static inline __ATTRS_o_ai __vector signed short +vec_xl(long __offset, const signed short *__ptr) { + __vector signed short V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed short)); + return V; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_xl(long __offset, const unsigned short *__ptr) { + __vector unsigned short V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned short)); + return V; +} + +static inline __ATTRS_o_ai __vector signed int +vec_xl(long __offset, const signed int *__ptr) { + __vector signed int V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed int)); + return V; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_xl(long __offset, const unsigned int *__ptr) { + __vector unsigned int V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned int)); + return V; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_xl(long __offset, const signed long long *__ptr) { + __vector signed long long V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed long long)); + return V; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_xl(long __offset, const unsigned long long *__ptr) { + __vector unsigned long long V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned long long)); + return V; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_xl(long __offset, const signed __int128 *__ptr) { + __vector signed __int128 V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed __int128)); + return V; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_xl(long __offset, const unsigned __int128 *__ptr) { + __vector unsigned __int128 V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned __int128)); + return V; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_xl(long __offset, const float *__ptr) { + __vector float V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector float)); + return V; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_xl(long __offset, const double *__ptr) { + __vector double V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector double)); + return V; +} + +/*-- vec_xld2 ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_xld2(long __offset, const signed char *__ptr) { + __vector signed char V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed char)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_xld2(long __offset, const unsigned char *__ptr) { + __vector unsigned char V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned char)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_xld2(long __offset, const signed short *__ptr) { + __vector signed short V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed short)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_xld2(long __offset, const unsigned short *__ptr) { + __vector unsigned short V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned short)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_xld2(long __offset, const signed int *__ptr) { + __vector signed int V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed int)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_xld2(long __offset, const unsigned int *__ptr) { + __vector unsigned int V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned int)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_xld2(long __offset, const signed long long *__ptr) { + __vector signed long long V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed long long)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_xld2(long __offset, const unsigned long long *__ptr) { + __vector unsigned long long V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned long long)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_xld2(long __offset, const double *__ptr) { + __vector double V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector double)); + return V; +} + +/*-- vec_xlw4 ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_xlw4(long __offset, const signed char *__ptr) { + __vector signed char V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed char)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_xlw4(long __offset, const unsigned char *__ptr) { + __vector unsigned char V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned char)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_xlw4(long __offset, const signed short *__ptr) { + __vector signed short V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed short)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_xlw4(long __offset, const unsigned short *__ptr) { + __vector unsigned short V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned short)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_xlw4(long __offset, const signed int *__ptr) { + __vector signed int V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector signed int)); + return V; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_xlw4(long __offset, const unsigned int *__ptr) { + __vector unsigned int V; + __builtin_memcpy(&V, ((const char *)__ptr + __offset), + sizeof(__vector unsigned int)); + return V; +} + +/*-- vec_xst ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai void +vec_xst(__vector signed char __vec, long __offset, signed char *__ptr) { + __vector signed char V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed char)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector unsigned char __vec, long __offset, unsigned char *__ptr) { + __vector unsigned char V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned char)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector signed short __vec, long __offset, signed short *__ptr) { + __vector signed short V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed short)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector unsigned short __vec, long __offset, unsigned short *__ptr) { + __vector unsigned short V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned short)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector signed int __vec, long __offset, signed int *__ptr) { + __vector signed int V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, sizeof(__vector signed int)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector unsigned int __vec, long __offset, unsigned int *__ptr) { + __vector unsigned int V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned int)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector signed long long __vec, long __offset, + signed long long *__ptr) { + __vector signed long long V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed long long)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector unsigned long long __vec, long __offset, + unsigned long long *__ptr) { + __vector unsigned long long V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned long long)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector signed __int128 __vec, long __offset, + signed __int128 *__ptr) { + __vector signed __int128 V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed __int128)); +} + +static inline __ATTRS_o_ai void +vec_xst(__vector unsigned __int128 __vec, long __offset, + unsigned __int128 *__ptr) { + __vector unsigned __int128 V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned __int128)); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai void +vec_xst(__vector float __vec, long __offset, float *__ptr) { + __vector float V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, sizeof(__vector float)); +} +#endif + +static inline __ATTRS_o_ai void +vec_xst(__vector double __vec, long __offset, double *__ptr) { + __vector double V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, sizeof(__vector double)); +} + +/*-- vec_xstd2 --------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector signed char __vec, long __offset, signed char *__ptr) { + __vector signed char V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed char)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector unsigned char __vec, long __offset, unsigned char *__ptr) { + __vector unsigned char V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned char)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector signed short __vec, long __offset, signed short *__ptr) { + __vector signed short V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed short)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector unsigned short __vec, long __offset, unsigned short *__ptr) { + __vector unsigned short V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned short)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector signed int __vec, long __offset, signed int *__ptr) { + __vector signed int V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, sizeof(__vector signed int)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector unsigned int __vec, long __offset, unsigned int *__ptr) { + __vector unsigned int V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned int)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector signed long long __vec, long __offset, + signed long long *__ptr) { + __vector signed long long V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed long long)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector unsigned long long __vec, long __offset, + unsigned long long *__ptr) { + __vector unsigned long long V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned long long)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstd2(__vector double __vec, long __offset, double *__ptr) { + __vector double V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, sizeof(__vector double)); +} + +/*-- vec_xstw4 --------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstw4(__vector signed char __vec, long __offset, signed char *__ptr) { + __vector signed char V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed char)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstw4(__vector unsigned char __vec, long __offset, unsigned char *__ptr) { + __vector unsigned char V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned char)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstw4(__vector signed short __vec, long __offset, signed short *__ptr) { + __vector signed short V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector signed short)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstw4(__vector unsigned short __vec, long __offset, unsigned short *__ptr) { + __vector unsigned short V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned short)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstw4(__vector signed int __vec, long __offset, signed int *__ptr) { + __vector signed int V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, sizeof(__vector signed int)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_xstw4(__vector unsigned int __vec, long __offset, unsigned int *__ptr) { + __vector unsigned int V = __vec; + __builtin_memcpy(((char *)__ptr + __offset), &V, + sizeof(__vector unsigned int)); +} + +/*-- vec_load_bndry ---------------------------------------------------------*/ + +extern __ATTRS_o __vector signed char +vec_load_bndry(const signed char *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector unsigned char +vec_load_bndry(const unsigned char *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector signed short +vec_load_bndry(const signed short *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector unsigned short +vec_load_bndry(const unsigned short *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector signed int +vec_load_bndry(const signed int *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector unsigned int +vec_load_bndry(const unsigned int *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector signed long long +vec_load_bndry(const signed long long *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector unsigned long long +vec_load_bndry(const unsigned long long *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector signed __int128 +vec_load_bndry(const signed __int128 *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +extern __ATTRS_o __vector unsigned __int128 +vec_load_bndry(const unsigned __int128 *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +#if __ARCH__ >= 12 +extern __ATTRS_o __vector float +vec_load_bndry(const float *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); +#endif + +extern __ATTRS_o __vector double +vec_load_bndry(const double *__ptr, unsigned short __len) + __constant_pow2_range(__len, 64, 4096); + +#define vec_load_bndry(X, Y) ((__typeof__((vec_load_bndry)((X), (Y)))) \ + __builtin_s390_vlbb((X), ((Y) == 64 ? 0 : \ + (Y) == 128 ? 1 : \ + (Y) == 256 ? 2 : \ + (Y) == 512 ? 3 : \ + (Y) == 1024 ? 4 : \ + (Y) == 2048 ? 5 : \ + (Y) == 4096 ? 6 : -1))) + +/*-- vec_load_len -----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_load_len(const signed char *__ptr, unsigned int __len) { + return (__vector signed char)__builtin_s390_vll(__len, __ptr); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_load_len(const unsigned char *__ptr, unsigned int __len) { + return (__vector unsigned char)__builtin_s390_vll(__len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_load_len(const signed short *__ptr, unsigned int __len) { + return (__vector signed short)__builtin_s390_vll(__len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_load_len(const unsigned short *__ptr, unsigned int __len) { + return (__vector unsigned short)__builtin_s390_vll(__len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_load_len(const signed int *__ptr, unsigned int __len) { + return (__vector signed int)__builtin_s390_vll(__len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_load_len(const unsigned int *__ptr, unsigned int __len) { + return (__vector unsigned int)__builtin_s390_vll(__len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_load_len(const signed long long *__ptr, unsigned int __len) { + return (__vector signed long long)__builtin_s390_vll(__len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_load_len(const unsigned long long *__ptr, unsigned int __len) { + return (__vector unsigned long long)__builtin_s390_vll(__len, __ptr); +} + +#if __ARCH__ >= 12 +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_load_len(const float *__ptr, unsigned int __len) { + return (__vector float)__builtin_s390_vll(__len, __ptr); +} +#endif + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_load_len(const double *__ptr, unsigned int __len) { + return (__vector double)__builtin_s390_vll(__len, __ptr); +} + +/*-- vec_load_len_r ---------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector signed char +vec_load_len_r(const signed char *__ptr, unsigned int __len) { + return (__vector signed char)__builtin_s390_vlrlr(__len, __ptr); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_load_len_r(const unsigned char *__ptr, unsigned int __len) { + return (__vector unsigned char)__builtin_s390_vlrlr(__len, __ptr); +} +#endif + +/*-- vec_store_len ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai void +vec_store_len(__vector signed char __vec, signed char *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +static inline __ATTRS_o_ai void +vec_store_len(__vector unsigned char __vec, unsigned char *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector signed short __vec, signed short *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector unsigned short __vec, unsigned short *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector signed int __vec, signed int *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector unsigned int __vec, unsigned int *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector signed long long __vec, signed long long *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector unsigned long long __vec, unsigned long long *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +#if __ARCH__ >= 12 +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector float __vec, float *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} +#endif + +// This prototype is deprecated. +static inline __ATTRS_o_ai void +vec_store_len(__vector double __vec, double *__ptr, + unsigned int __len) { + __builtin_s390_vstl((__vector signed char)__vec, __len, __ptr); +} + +/*-- vec_store_len_r --------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai void +vec_store_len_r(__vector signed char __vec, signed char *__ptr, + unsigned int __len) { + __builtin_s390_vstrlr(__vec, __len, __ptr); +} + +static inline __ATTRS_o_ai void +vec_store_len_r(__vector unsigned char __vec, unsigned char *__ptr, + unsigned int __len) { + __builtin_s390_vstrlr((__vector signed char)__vec, __len, __ptr); +} +#endif + +/*-- vec_load_pair ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed long long +vec_load_pair(signed long long __a, signed long long __b) { + return (__vector signed long long)(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_load_pair(unsigned long long __a, unsigned long long __b) { + return (__vector unsigned long long)(__a, __b); +} + +/*-- vec_genmask ------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_genmask(unsigned short __mask) + __constant(__mask) { + return (__vector unsigned char)( + __mask & 0x8000 ? 0xff : 0, + __mask & 0x4000 ? 0xff : 0, + __mask & 0x2000 ? 0xff : 0, + __mask & 0x1000 ? 0xff : 0, + __mask & 0x0800 ? 0xff : 0, + __mask & 0x0400 ? 0xff : 0, + __mask & 0x0200 ? 0xff : 0, + __mask & 0x0100 ? 0xff : 0, + __mask & 0x0080 ? 0xff : 0, + __mask & 0x0040 ? 0xff : 0, + __mask & 0x0020 ? 0xff : 0, + __mask & 0x0010 ? 0xff : 0, + __mask & 0x0008 ? 0xff : 0, + __mask & 0x0004 ? 0xff : 0, + __mask & 0x0002 ? 0xff : 0, + __mask & 0x0001 ? 0xff : 0); +} + +/*-- vec_genmasks_* ---------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_genmasks_8(unsigned char __first, unsigned char __last) + __constant(__first) __constant(__last) { + unsigned char __bit1 = __first & 7; + unsigned char __bit2 = __last & 7; + unsigned char __mask1 = (unsigned char)(1U << (7 - __bit1) << 1) - 1; + unsigned char __mask2 = (unsigned char)(1U << (7 - __bit2)) - 1; + unsigned char __value = (__bit1 <= __bit2 ? + __mask1 & ~__mask2 : + __mask1 | ~__mask2); + return (__vector unsigned char)__value; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_genmasks_16(unsigned char __first, unsigned char __last) + __constant(__first) __constant(__last) { + unsigned char __bit1 = __first & 15; + unsigned char __bit2 = __last & 15; + unsigned short __mask1 = (unsigned short)(1U << (15 - __bit1) << 1) - 1; + unsigned short __mask2 = (unsigned short)(1U << (15 - __bit2)) - 1; + unsigned short __value = (__bit1 <= __bit2 ? + __mask1 & ~__mask2 : + __mask1 | ~__mask2); + return (__vector unsigned short)__value; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_genmasks_32(unsigned char __first, unsigned char __last) + __constant(__first) __constant(__last) { + unsigned char __bit1 = __first & 31; + unsigned char __bit2 = __last & 31; + unsigned int __mask1 = (1U << (31 - __bit1) << 1) - 1; + unsigned int __mask2 = (1U << (31 - __bit2)) - 1; + unsigned int __value = (__bit1 <= __bit2 ? + __mask1 & ~__mask2 : + __mask1 | ~__mask2); + return (__vector unsigned int)__value; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_genmasks_64(unsigned char __first, unsigned char __last) + __constant(__first) __constant(__last) { + unsigned char __bit1 = __first & 63; + unsigned char __bit2 = __last & 63; + unsigned long long __mask1 = (1ULL << (63 - __bit1) << 1) - 1; + unsigned long long __mask2 = (1ULL << (63 - __bit2)) - 1; + unsigned long long __value = (__bit1 <= __bit2 ? + __mask1 & ~__mask2 : + __mask1 | ~__mask2); + return (__vector unsigned long long)__value; +} + +/*-- vec_gen_element_masks_* ------------------------------------------------*/ + +#if __ARCH__ >= 15 +static inline __ATTRS_ai __vector unsigned char +vec_gen_element_masks_8(__vector unsigned short __mask) { + return __builtin_s390_vgemb(__mask); +} + +static inline __ATTRS_ai __vector unsigned short +vec_gen_element_masks_16(__vector unsigned char __mask) { + return __builtin_s390_vgemh(__mask); +} + +static inline __ATTRS_ai __vector unsigned int +vec_gen_element_masks_32(__vector unsigned char __mask) { + return __builtin_s390_vgemf(__mask); +} + +static inline __ATTRS_ai __vector unsigned long long +vec_gen_element_masks_64(__vector unsigned char __mask) { + return __builtin_s390_vgemg(__mask); +} + +static inline __ATTRS_ai __vector unsigned __int128 +vec_gen_element_masks_128(__vector unsigned char __mask) { + return (__vector unsigned __int128)__builtin_s390_vgemq(__mask); +} +#endif + +/*-- vec_splat --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_splat(__vector signed char __vec, int __index) + __constant_range(__index, 0, 15) { + return (__vector signed char)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector __bool char +vec_splat(__vector __bool char __vec, int __index) + __constant_range(__index, 0, 15) { + return (__vector __bool char)(__vector unsigned char)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_splat(__vector unsigned char __vec, int __index) + __constant_range(__index, 0, 15) { + return (__vector unsigned char)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector signed short +vec_splat(__vector signed short __vec, int __index) + __constant_range(__index, 0, 7) { + return (__vector signed short)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_splat(__vector __bool short __vec, int __index) + __constant_range(__index, 0, 7) { + return (__vector __bool short)(__vector unsigned short)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_splat(__vector unsigned short __vec, int __index) + __constant_range(__index, 0, 7) { + return (__vector unsigned short)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector signed int +vec_splat(__vector signed int __vec, int __index) + __constant_range(__index, 0, 3) { + return (__vector signed int)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_splat(__vector __bool int __vec, int __index) + __constant_range(__index, 0, 3) { + return (__vector __bool int)(__vector unsigned int)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_splat(__vector unsigned int __vec, int __index) + __constant_range(__index, 0, 3) { + return (__vector unsigned int)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_splat(__vector signed long long __vec, int __index) + __constant_range(__index, 0, 1) { + return (__vector signed long long)__vec[__index]; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_splat(__vector __bool long long __vec, int __index) + __constant_range(__index, 0, 1) { + return ((__vector __bool long long) + (__vector unsigned long long)__vec[__index]); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_splat(__vector unsigned long long __vec, int __index) + __constant_range(__index, 0, 1) { + return (__vector unsigned long long)__vec[__index]; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_splat(__vector float __vec, int __index) + __constant_range(__index, 0, 3) { + return (__vector float)__vec[__index]; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_splat(__vector double __vec, int __index) + __constant_range(__index, 0, 1) { + return (__vector double)__vec[__index]; +} + +/*-- vec_splat_s* -----------------------------------------------------------*/ + +static inline __ATTRS_ai __vector signed char +vec_splat_s8(signed char __scalar) + __constant(__scalar) { + return (__vector signed char)__scalar; +} + +static inline __ATTRS_ai __vector signed short +vec_splat_s16(signed short __scalar) + __constant(__scalar) { + return (__vector signed short)__scalar; +} + +static inline __ATTRS_ai __vector signed int +vec_splat_s32(signed short __scalar) + __constant(__scalar) { + return (__vector signed int)(signed int)__scalar; +} + +static inline __ATTRS_ai __vector signed long long +vec_splat_s64(signed short __scalar) + __constant(__scalar) { + return (__vector signed long long)(signed long)__scalar; +} + +/*-- vec_splat_u* -----------------------------------------------------------*/ + +static inline __ATTRS_ai __vector unsigned char +vec_splat_u8(unsigned char __scalar) + __constant(__scalar) { + return (__vector unsigned char)__scalar; +} + +static inline __ATTRS_ai __vector unsigned short +vec_splat_u16(unsigned short __scalar) + __constant(__scalar) { + return (__vector unsigned short)__scalar; +} + +static inline __ATTRS_ai __vector unsigned int +vec_splat_u32(signed short __scalar) + __constant(__scalar) { + return (__vector unsigned int)(signed int)__scalar; +} + +static inline __ATTRS_ai __vector unsigned long long +vec_splat_u64(signed short __scalar) + __constant(__scalar) { + return (__vector unsigned long long)(signed long long)__scalar; +} + +/*-- vec_splats -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_splats(signed char __scalar) { + return (__vector signed char)__scalar; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_splats(unsigned char __scalar) { + return (__vector unsigned char)__scalar; +} + +static inline __ATTRS_o_ai __vector signed short +vec_splats(signed short __scalar) { + return (__vector signed short)__scalar; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_splats(unsigned short __scalar) { + return (__vector unsigned short)__scalar; +} + +static inline __ATTRS_o_ai __vector signed int +vec_splats(signed int __scalar) { + return (__vector signed int)__scalar; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_splats(unsigned int __scalar) { + return (__vector unsigned int)__scalar; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_splats(signed long long __scalar) { + return (__vector signed long long)__scalar; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_splats(unsigned long long __scalar) { + return (__vector unsigned long long)__scalar; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_splats(signed __int128 __scalar) { + return (__vector signed __int128)__scalar; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_splats(unsigned __int128 __scalar) { + return (__vector unsigned __int128)__scalar; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_splats(float __scalar) { + return (__vector float)__scalar; +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_splats(double __scalar) { + return (__vector double)__scalar; +} + +/*-- vec_extend_s64 ---------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed long long +vec_extend_s64(__vector signed char __a) { + return (__vector signed long long)(__a[7], __a[15]); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_extend_s64(__vector signed short __a) { + return (__vector signed long long)(__a[3], __a[7]); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_extend_s64(__vector signed int __a) { + return (__vector signed long long)(__a[1], __a[3]); +} + +/*-- vec_mergeh -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_mergeh(__vector signed char __a, __vector signed char __b) { + return (__vector signed char)( + __a[0], __b[0], __a[1], __b[1], __a[2], __b[2], __a[3], __b[3], + __a[4], __b[4], __a[5], __b[5], __a[6], __b[6], __a[7], __b[7]); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_mergeh(__vector __bool char __a, __vector __bool char __b) { + return (__vector __bool char)( + __a[0], __b[0], __a[1], __b[1], __a[2], __b[2], __a[3], __b[3], + __a[4], __b[4], __a[5], __b[5], __a[6], __b[6], __a[7], __b[7]); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_mergeh(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector unsigned char)( + __a[0], __b[0], __a[1], __b[1], __a[2], __b[2], __a[3], __b[3], + __a[4], __b[4], __a[5], __b[5], __a[6], __b[6], __a[7], __b[7]); +} + +static inline __ATTRS_o_ai __vector signed short +vec_mergeh(__vector signed short __a, __vector signed short __b) { + return (__vector signed short)( + __a[0], __b[0], __a[1], __b[1], __a[2], __b[2], __a[3], __b[3]); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_mergeh(__vector __bool short __a, __vector __bool short __b) { + return (__vector __bool short)( + __a[0], __b[0], __a[1], __b[1], __a[2], __b[2], __a[3], __b[3]); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mergeh(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)( + __a[0], __b[0], __a[1], __b[1], __a[2], __b[2], __a[3], __b[3]); +} + +static inline __ATTRS_o_ai __vector signed int +vec_mergeh(__vector signed int __a, __vector signed int __b) { + return (__vector signed int)(__a[0], __b[0], __a[1], __b[1]); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_mergeh(__vector __bool int __a, __vector __bool int __b) { + return (__vector __bool int)(__a[0], __b[0], __a[1], __b[1]); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mergeh(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)(__a[0], __b[0], __a[1], __b[1]); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_mergeh(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed long long)(__a[0], __b[0]); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_mergeh(__vector __bool long long __a, __vector __bool long long __b) { + return (__vector __bool long long)(__a[0], __b[0]); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mergeh(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned long long)(__a[0], __b[0]); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_mergeh(__vector float __a, __vector float __b) { + return (__vector float)(__a[0], __b[0], __a[1], __b[1]); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_mergeh(__vector double __a, __vector double __b) { + return (__vector double)(__a[0], __b[0]); +} + +/*-- vec_mergel -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_mergel(__vector signed char __a, __vector signed char __b) { + return (__vector signed char)( + __a[8], __b[8], __a[9], __b[9], __a[10], __b[10], __a[11], __b[11], + __a[12], __b[12], __a[13], __b[13], __a[14], __b[14], __a[15], __b[15]); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_mergel(__vector __bool char __a, __vector __bool char __b) { + return (__vector __bool char)( + __a[8], __b[8], __a[9], __b[9], __a[10], __b[10], __a[11], __b[11], + __a[12], __b[12], __a[13], __b[13], __a[14], __b[14], __a[15], __b[15]); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_mergel(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector unsigned char)( + __a[8], __b[8], __a[9], __b[9], __a[10], __b[10], __a[11], __b[11], + __a[12], __b[12], __a[13], __b[13], __a[14], __b[14], __a[15], __b[15]); +} + +static inline __ATTRS_o_ai __vector signed short +vec_mergel(__vector signed short __a, __vector signed short __b) { + return (__vector signed short)( + __a[4], __b[4], __a[5], __b[5], __a[6], __b[6], __a[7], __b[7]); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_mergel(__vector __bool short __a, __vector __bool short __b) { + return (__vector __bool short)( + __a[4], __b[4], __a[5], __b[5], __a[6], __b[6], __a[7], __b[7]); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mergel(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)( + __a[4], __b[4], __a[5], __b[5], __a[6], __b[6], __a[7], __b[7]); +} + +static inline __ATTRS_o_ai __vector signed int +vec_mergel(__vector signed int __a, __vector signed int __b) { + return (__vector signed int)(__a[2], __b[2], __a[3], __b[3]); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_mergel(__vector __bool int __a, __vector __bool int __b) { + return (__vector __bool int)(__a[2], __b[2], __a[3], __b[3]); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mergel(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)(__a[2], __b[2], __a[3], __b[3]); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_mergel(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed long long)(__a[1], __b[1]); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_mergel(__vector __bool long long __a, __vector __bool long long __b) { + return (__vector __bool long long)(__a[1], __b[1]); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mergel(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned long long)(__a[1], __b[1]); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_mergel(__vector float __a, __vector float __b) { + return (__vector float)(__a[2], __b[2], __a[3], __b[3]); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_mergel(__vector double __a, __vector double __b) { + return (__vector double)(__a[1], __b[1]); +} + +/*-- vec_pack ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_pack(__vector signed short __a, __vector signed short __b) { + __vector signed char __ac = (__vector signed char)__a; + __vector signed char __bc = (__vector signed char)__b; + return (__vector signed char)( + __ac[1], __ac[3], __ac[5], __ac[7], __ac[9], __ac[11], __ac[13], __ac[15], + __bc[1], __bc[3], __bc[5], __bc[7], __bc[9], __bc[11], __bc[13], __bc[15]); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_pack(__vector __bool short __a, __vector __bool short __b) { + __vector __bool char __ac = (__vector __bool char)__a; + __vector __bool char __bc = (__vector __bool char)__b; + return (__vector __bool char)( + __ac[1], __ac[3], __ac[5], __ac[7], __ac[9], __ac[11], __ac[13], __ac[15], + __bc[1], __bc[3], __bc[5], __bc[7], __bc[9], __bc[11], __bc[13], __bc[15]); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_pack(__vector unsigned short __a, __vector unsigned short __b) { + __vector unsigned char __ac = (__vector unsigned char)__a; + __vector unsigned char __bc = (__vector unsigned char)__b; + return (__vector unsigned char)( + __ac[1], __ac[3], __ac[5], __ac[7], __ac[9], __ac[11], __ac[13], __ac[15], + __bc[1], __bc[3], __bc[5], __bc[7], __bc[9], __bc[11], __bc[13], __bc[15]); +} + +static inline __ATTRS_o_ai __vector signed short +vec_pack(__vector signed int __a, __vector signed int __b) { + __vector signed short __ac = (__vector signed short)__a; + __vector signed short __bc = (__vector signed short)__b; + return (__vector signed short)( + __ac[1], __ac[3], __ac[5], __ac[7], + __bc[1], __bc[3], __bc[5], __bc[7]); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_pack(__vector __bool int __a, __vector __bool int __b) { + __vector __bool short __ac = (__vector __bool short)__a; + __vector __bool short __bc = (__vector __bool short)__b; + return (__vector __bool short)( + __ac[1], __ac[3], __ac[5], __ac[7], + __bc[1], __bc[3], __bc[5], __bc[7]); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_pack(__vector unsigned int __a, __vector unsigned int __b) { + __vector unsigned short __ac = (__vector unsigned short)__a; + __vector unsigned short __bc = (__vector unsigned short)__b; + return (__vector unsigned short)( + __ac[1], __ac[3], __ac[5], __ac[7], + __bc[1], __bc[3], __bc[5], __bc[7]); +} + +static inline __ATTRS_o_ai __vector signed int +vec_pack(__vector signed long long __a, __vector signed long long __b) { + __vector signed int __ac = (__vector signed int)__a; + __vector signed int __bc = (__vector signed int)__b; + return (__vector signed int)(__ac[1], __ac[3], __bc[1], __bc[3]); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_pack(__vector __bool long long __a, __vector __bool long long __b) { + __vector __bool int __ac = (__vector __bool int)__a; + __vector __bool int __bc = (__vector __bool int)__b; + return (__vector __bool int)(__ac[1], __ac[3], __bc[1], __bc[3]); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_pack(__vector unsigned long long __a, __vector unsigned long long __b) { + __vector unsigned int __ac = (__vector unsigned int)__a; + __vector unsigned int __bc = (__vector unsigned int)__b; + return (__vector unsigned int)(__ac[1], __ac[3], __bc[1], __bc[3]); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_pack(__vector signed __int128 __a, __vector signed __int128 __b) { + __vector signed long long __ac = (__vector signed long long)__a; + __vector signed long long __bc = (__vector signed long long)__b; + return (__vector signed long long)(__ac[1], __bc[1]); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_pack(__vector __bool __int128 __a, __vector __bool __int128 __b) { + __vector __bool long long __ac = (__vector __bool long long)__a; + __vector __bool long long __bc = (__vector __bool long long)__b; + return (__vector __bool long long)(__ac[1], __bc[1]); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_pack(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + __vector unsigned long long __ac = (__vector unsigned long long)__a; + __vector unsigned long long __bc = (__vector unsigned long long)__b; + return (__vector unsigned long long)(__ac[1], __bc[1]); +} + +/*-- vec_packs --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_packs(__vector signed short __a, __vector signed short __b) { + return __builtin_s390_vpksh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_packs(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vpklsh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_packs(__vector signed int __a, __vector signed int __b) { + return __builtin_s390_vpksf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_packs(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vpklsf(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_packs(__vector signed long long __a, __vector signed long long __b) { + return __builtin_s390_vpksg(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_packs(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_vpklsg(__a, __b); +} + +/*-- vec_packs_cc -----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_packs_cc(__vector signed short __a, __vector signed short __b, int *__cc) { + return __builtin_s390_vpkshs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_packs_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return __builtin_s390_vpklshs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_packs_cc(__vector signed int __a, __vector signed int __b, int *__cc) { + return __builtin_s390_vpksfs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_packs_cc(__vector unsigned int __a, __vector unsigned int __b, int *__cc) { + return __builtin_s390_vpklsfs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_packs_cc(__vector signed long long __a, __vector signed long long __b, + int *__cc) { + return __builtin_s390_vpksgs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_packs_cc(__vector unsigned long long __a, __vector unsigned long long __b, + int *__cc) { + return __builtin_s390_vpklsgs(__a, __b, __cc); +} + +/*-- vec_packsu -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_packsu(__vector signed short __a, __vector signed short __b) { + const __vector signed short __zero = (__vector signed short)0; + return __builtin_s390_vpklsh( + (__vector unsigned short)(__a >= __zero) & (__vector unsigned short)__a, + (__vector unsigned short)(__b >= __zero) & (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_packsu(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vpklsh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_packsu(__vector signed int __a, __vector signed int __b) { + const __vector signed int __zero = (__vector signed int)0; + return __builtin_s390_vpklsf( + (__vector unsigned int)(__a >= __zero) & (__vector unsigned int)__a, + (__vector unsigned int)(__b >= __zero) & (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_packsu(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vpklsf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_packsu(__vector signed long long __a, __vector signed long long __b) { + const __vector signed long long __zero = (__vector signed long long)0; + return __builtin_s390_vpklsg( + (__vector unsigned long long)(__a >= __zero) & + (__vector unsigned long long)__a, + (__vector unsigned long long)(__b >= __zero) & + (__vector unsigned long long)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_packsu(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_vpklsg(__a, __b); +} + +/*-- vec_packsu_cc ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_packsu_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return __builtin_s390_vpklshs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_packsu_cc(__vector unsigned int __a, __vector unsigned int __b, int *__cc) { + return __builtin_s390_vpklsfs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_packsu_cc(__vector unsigned long long __a, __vector unsigned long long __b, + int *__cc) { + return __builtin_s390_vpklsgs(__a, __b, __cc); +} + +/*-- vec_unpackh ------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_unpackh(__vector signed char __a) { + return __builtin_s390_vuphb(__a); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_unpackh(__vector __bool char __a) { + return ((__vector __bool short) + __builtin_s390_vuphb((__vector signed char)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_unpackh(__vector unsigned char __a) { + return __builtin_s390_vuplhb(__a); +} + +static inline __ATTRS_o_ai __vector signed int +vec_unpackh(__vector signed short __a) { + return __builtin_s390_vuphh(__a); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_unpackh(__vector __bool short __a) { + return (__vector __bool int)__builtin_s390_vuphh((__vector signed short)__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_unpackh(__vector unsigned short __a) { + return __builtin_s390_vuplhh(__a); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_unpackh(__vector signed int __a) { + return __builtin_s390_vuphf(__a); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_unpackh(__vector __bool int __a) { + return ((__vector __bool long long) + __builtin_s390_vuphf((__vector signed int)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_unpackh(__vector unsigned int __a) { + return __builtin_s390_vuplhf(__a); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_unpackh(__vector signed long long __a) { + return (__vector signed __int128)__builtin_s390_vuphg(__a); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_unpackh(__vector __bool long long __a) { + return ((__vector __bool __int128) + __builtin_s390_vuphg((__vector signed long long)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_unpackh(__vector unsigned long long __a) { + return (__vector unsigned __int128)__builtin_s390_vuplhg(__a); +} +#endif + +/*-- vec_unpackl ------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_unpackl(__vector signed char __a) { + return __builtin_s390_vuplb(__a); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_unpackl(__vector __bool char __a) { + return ((__vector __bool short) + __builtin_s390_vuplb((__vector signed char)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_unpackl(__vector unsigned char __a) { + return __builtin_s390_vupllb(__a); +} + +static inline __ATTRS_o_ai __vector signed int +vec_unpackl(__vector signed short __a) { + return __builtin_s390_vuplhw(__a); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_unpackl(__vector __bool short __a) { + return ((__vector __bool int) + __builtin_s390_vuplhw((__vector signed short)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_unpackl(__vector unsigned short __a) { + return __builtin_s390_vupllh(__a); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_unpackl(__vector signed int __a) { + return __builtin_s390_vuplf(__a); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_unpackl(__vector __bool int __a) { + return ((__vector __bool long long) + __builtin_s390_vuplf((__vector signed int)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_unpackl(__vector unsigned int __a) { + return __builtin_s390_vupllf(__a); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_unpackl(__vector signed long long __a) { + return (__vector signed __int128)__builtin_s390_vuplg(__a); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_unpackl(__vector __bool long long __a) { + return ((__vector __bool __int128) + __builtin_s390_vuplg((__vector signed long long)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_unpackl(__vector unsigned long long __a) { + return (__vector unsigned __int128)__builtin_s390_vupllg(__a); +} +#endif + +/*-- vec_cmpeq --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpeq(__vector __bool char __a, __vector __bool char __b) { + return (__vector __bool char)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpeq(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpeq(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpeq(__vector __bool short __a, __vector __bool short __b) { + return (__vector __bool short)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpeq(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpeq(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpeq(__vector __bool int __a, __vector __bool int __b) { + return (__vector __bool int)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpeq(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpeq(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpeq(__vector __bool long long __a, __vector __bool long long __b) { + return (__vector __bool long long)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpeq(__vector signed long long __a, __vector signed long long __b) { + return (__vector __bool long long)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpeq(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector __bool long long)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpeq(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return (__vector __bool __int128)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpeq(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector __bool __int128)(__a == __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpeq(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector __bool __int128)(__a == __b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool int +vec_cmpeq(__vector float __a, __vector float __b) { + return (__vector __bool int)(__a == __b); +} +#endif + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpeq(__vector double __a, __vector double __b) { + return (__vector __bool long long)(__a == __b); +} + +/*-- vec_cmpge --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpge(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpge(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpge(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpge(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpge(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpge(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpge(__vector signed long long __a, __vector signed long long __b) { + return (__vector __bool long long)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpge(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector __bool long long)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpge(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector __bool __int128)(__a >= __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpge(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector __bool __int128)(__a >= __b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool int +vec_cmpge(__vector float __a, __vector float __b) { + return (__vector __bool int)(__a >= __b); +} +#endif + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpge(__vector double __a, __vector double __b) { + return (__vector __bool long long)(__a >= __b); +} + +/*-- vec_cmpgt --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpgt(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpgt(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpgt(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpgt(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpgt(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpgt(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpgt(__vector signed long long __a, __vector signed long long __b) { + return (__vector __bool long long)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpgt(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector __bool long long)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpgt(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector __bool __int128)(__a > __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmpgt(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector __bool __int128)(__a > __b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool int +vec_cmpgt(__vector float __a, __vector float __b) { + return (__vector __bool int)(__a > __b); +} +#endif + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmpgt(__vector double __a, __vector double __b) { + return (__vector __bool long long)(__a > __b); +} + +/*-- vec_cmple --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmple(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cmple(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmple(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmple(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmple(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmple(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmple(__vector signed long long __a, __vector signed long long __b) { + return (__vector __bool long long)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmple(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector __bool long long)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmple(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector __bool __int128)(__a <= __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmple(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector __bool __int128)(__a <= __b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool int +vec_cmple(__vector float __a, __vector float __b) { + return (__vector __bool int)(__a <= __b); +} +#endif + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmple(__vector double __a, __vector double __b) { + return (__vector __bool long long)(__a <= __b); +} + +/*-- vec_cmplt --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmplt(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cmplt(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmplt(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmplt(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmplt(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmplt(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmplt(__vector signed long long __a, __vector signed long long __b) { + return (__vector __bool long long)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmplt(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector __bool long long)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmplt(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector __bool __int128)(__a < __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_cmplt(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector __bool __int128)(__a < __b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool int +vec_cmplt(__vector float __a, __vector float __b) { + return (__vector __bool int)(__a < __b); +} +#endif + +static inline __ATTRS_o_ai __vector __bool long long +vec_cmplt(__vector double __a, __vector double __b) { + return (__vector __bool long long)(__a < __b); +} + +/*-- vec_all_eq -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs(__a, (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs(__a, (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs(__a, (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_all_eq(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_eq(__vector __bool __int128 __a, __vector __bool __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 0; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_eq(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfcesbs(__a, __b, &__cc); + return __cc == 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_eq(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfcedbs(__a, __b, &__cc); + return __cc == 0; +} + +/*-- vec_all_ne -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs(__a, (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs(__a, (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs(__a, (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_all_ne(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ne(__vector __bool __int128 __a, __vector __bool __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 3; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_ne(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfcesbs(__a, __b, &__cc); + return __cc == 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_ne(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfcedbs(__a, __b, &__cc); + return __cc == 3; +} + +/*-- vec_all_ge -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, (__vector signed char)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, (__vector unsigned char)__a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, + (__vector unsigned char)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, (__vector signed short)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, (__vector unsigned short)__a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, + (__vector unsigned short)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, (__vector signed int)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, (__vector unsigned int)__a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, + (__vector unsigned int)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, (__vector signed long long)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, __a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, (__vector unsigned long long)__a, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_ge(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, + (__vector unsigned long long)__a, &__cc); + return __cc == 3; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_all_ge(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__b, (signed __int128)__a, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_ge(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__b, (unsigned __int128)__a, &__cc); + return __cc == 3; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_ge(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__a, __b, &__cc); + return __cc == 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_ge(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__a, __b, &__cc); + return __cc == 0; +} + +/*-- vec_all_gt -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs(__a, (__vector signed char)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs(__a, (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs(__a, (__vector signed short)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs(__a, (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs(__a, (__vector signed int)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs(__a, (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs(__a, (__vector signed long long)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__a, __b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, __b, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_gt(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 0; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_all_gt(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__a, (signed __int128)__b, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_gt(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 0; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_gt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__a, __b, &__cc); + return __cc == 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_gt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__a, __b, &__cc); + return __cc == 0; +} + +/*-- vec_all_le -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_all_le(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs(__a, (__vector signed char)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs(__a, (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs(__a, (__vector signed short)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs(__a, (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs(__a, (__vector signed int)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs(__a, (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs(__a, (__vector signed long long)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__a, __b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, __b, &__cc); + return __cc == 3; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_le(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc == 3; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_all_le(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__a, (signed __int128)__b, &__cc); + return __cc == 3; +} + +static inline __ATTRS_o_ai int +vec_all_le(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc == 3; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_le(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__b, __a, &__cc); + return __cc == 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_le(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__b, __a, &__cc); + return __cc == 0; +} + +/*-- vec_all_lt -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, (__vector signed char)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, (__vector unsigned char)__a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, + (__vector unsigned char)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, (__vector signed short)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, (__vector unsigned short)__a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, + (__vector unsigned short)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, (__vector signed int)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, (__vector unsigned int)__a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, + (__vector unsigned int)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, (__vector signed long long)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, __a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, (__vector unsigned long long)__a, &__cc); + return __cc == 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_all_lt(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, + (__vector unsigned long long)__a, &__cc); + return __cc == 0; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_all_lt(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__b, (signed __int128)__a, &__cc); + return __cc == 0; +} + +static inline __ATTRS_o_ai int +vec_all_lt(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__b, (unsigned __int128)__a, &__cc); + return __cc == 0; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_lt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__b, __a, &__cc); + return __cc == 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_lt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__b, __a, &__cc); + return __cc == 0; +} + +/*-- vec_all_nge ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_nge(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__a, __b, &__cc); + return __cc == 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_nge(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__a, __b, &__cc); + return __cc == 3; +} + +/*-- vec_all_ngt ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_ngt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__a, __b, &__cc); + return __cc == 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_ngt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__a, __b, &__cc); + return __cc == 3; +} + +/*-- vec_all_nle ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_nle(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__b, __a, &__cc); + return __cc == 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_nle(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__b, __a, &__cc); + return __cc == 3; +} + +/*-- vec_all_nlt ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_nlt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__b, __a, &__cc); + return __cc == 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_nlt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__b, __a, &__cc); + return __cc == 3; +} + +/*-- vec_all_nan ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_nan(__vector float __a) { + int __cc; + __builtin_s390_vftcisb(__a, 15, &__cc); + return __cc == 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_nan(__vector double __a) { + int __cc; + __builtin_s390_vftcidb(__a, 15, &__cc); + return __cc == 0; +} + +/*-- vec_all_numeric --------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_all_numeric(__vector float __a) { + int __cc; + __builtin_s390_vftcisb(__a, 15, &__cc); + return __cc == 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_all_numeric(__vector double __a) { + int __cc; + __builtin_s390_vftcidb(__a, 15, &__cc); + return __cc == 3; +} + +/*-- vec_any_eq -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs(__a, (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs(__a, (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs(__a, (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_any_eq(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_eq(__vector __bool __int128 __a, __vector __bool __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc <= 1; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_eq(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfcesbs(__a, __b, &__cc); + return __cc <= 1; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_eq(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfcedbs(__a, __b, &__cc); + return __cc <= 1; +} + +/*-- vec_any_ne -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs(__a, (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vceqbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs(__a, (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vceqhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs(__a, (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vceqfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vceqgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_any_ne(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ne(__vector __bool __int128 __a, __vector __bool __int128 __b) { + int __cc; + __builtin_s390_vceqqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc != 0; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_ne(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfcesbs(__a, __b, &__cc); + return __cc != 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_ne(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfcedbs(__a, __b, &__cc); + return __cc != 0; +} + +/*-- vec_any_ge -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, (__vector signed char)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, (__vector unsigned char)__a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, + (__vector unsigned char)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, (__vector signed short)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, (__vector unsigned short)__a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, + (__vector unsigned short)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, (__vector signed int)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, (__vector unsigned int)__a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, + (__vector unsigned int)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, (__vector signed long long)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, __a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, (__vector unsigned long long)__a, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_ge(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, + (__vector unsigned long long)__a, &__cc); + return __cc != 0; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_any_ge(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__b, (signed __int128)__a, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_ge(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__b, (unsigned __int128)__a, &__cc); + return __cc != 0; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_ge(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__a, __b, &__cc); + return __cc <= 1; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_ge(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__a, __b, &__cc); + return __cc <= 1; +} + +/*-- vec_any_gt -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs(__a, (__vector signed char)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs(__a, (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs(__a, (__vector signed short)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs(__a, (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs(__a, (__vector signed int)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs(__a, (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs(__a, (__vector signed long long)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__a, __b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, __b, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_gt(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc <= 1; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_any_gt(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__a, (signed __int128)__b, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_gt(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc <= 1; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_gt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__a, __b, &__cc); + return __cc <= 1; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_gt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__a, __b, &__cc); + return __cc <= 1; +} + +/*-- vec_any_le -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_any_le(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs(__a, (__vector signed char)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs(__a, (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__a, + (__vector unsigned char)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs(__a, (__vector signed short)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs(__a, (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__a, + (__vector unsigned short)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs(__a, (__vector signed int)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs(__a, (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__a, + (__vector unsigned int)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs(__a, (__vector signed long long)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__a, __b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs(__a, (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, __b, &__cc); + return __cc != 0; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_le(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__a, + (__vector unsigned long long)__b, &__cc); + return __cc != 0; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_any_le(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__a, (signed __int128)__b, &__cc); + return __cc != 0; +} + +static inline __ATTRS_o_ai int +vec_any_le(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__a, (unsigned __int128)__b, &__cc); + return __cc != 0; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_le(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__b, __a, &__cc); + return __cc <= 1; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_le(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__b, __a, &__cc); + return __cc <= 1; +} + +/*-- vec_any_lt -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchbs((__vector signed char)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool char __a, __vector signed char __b) { + int __cc; + __builtin_s390_vchbs(__b, (__vector signed char)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool char __a, __vector unsigned char __b) { + int __cc; + __builtin_s390_vchlbs(__b, (__vector unsigned char)__a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool char __a, __vector __bool char __b) { + int __cc; + __builtin_s390_vchlbs((__vector unsigned char)__b, + (__vector unsigned char)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchhs((__vector signed short)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool short __a, __vector signed short __b) { + int __cc; + __builtin_s390_vchhs(__b, (__vector signed short)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool short __a, __vector unsigned short __b) { + int __cc; + __builtin_s390_vchlhs(__b, (__vector unsigned short)__a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool short __a, __vector __bool short __b) { + int __cc; + __builtin_s390_vchlhs((__vector unsigned short)__b, + (__vector unsigned short)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchfs((__vector signed int)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool int __a, __vector signed int __b) { + int __cc; + __builtin_s390_vchfs(__b, (__vector signed int)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool int __a, __vector unsigned int __b) { + int __cc; + __builtin_s390_vchlfs(__b, (__vector unsigned int)__a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool int __a, __vector __bool int __b) { + int __cc; + __builtin_s390_vchlfs((__vector unsigned int)__b, + (__vector unsigned int)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchgs((__vector signed long long)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool long long __a, __vector signed long long __b) { + int __cc; + __builtin_s390_vchgs(__b, (__vector signed long long)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, __a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool long long __a, __vector unsigned long long __b) { + int __cc; + __builtin_s390_vchlgs(__b, (__vector unsigned long long)__a, &__cc); + return __cc <= 1; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai int +vec_any_lt(__vector __bool long long __a, __vector __bool long long __b) { + int __cc; + __builtin_s390_vchlgs((__vector unsigned long long)__b, + (__vector unsigned long long)__a, &__cc); + return __cc <= 1; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai int +vec_any_lt(__vector signed __int128 __a, __vector signed __int128 __b) { + int __cc; + __builtin_s390_vchqs((signed __int128)__b, (signed __int128)__a, &__cc); + return __cc <= 1; +} + +static inline __ATTRS_o_ai int +vec_any_lt(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + int __cc; + __builtin_s390_vchlqs((unsigned __int128)__b, (unsigned __int128)__a, &__cc); + return __cc <= 1; +} +#endif + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_lt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__b, __a, &__cc); + return __cc <= 1; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_lt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__b, __a, &__cc); + return __cc <= 1; +} + +/*-- vec_any_nge ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_nge(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__a, __b, &__cc); + return __cc != 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_nge(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__a, __b, &__cc); + return __cc != 0; +} + +/*-- vec_any_ngt ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_ngt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__a, __b, &__cc); + return __cc != 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_ngt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__a, __b, &__cc); + return __cc != 0; +} + +/*-- vec_any_nle ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_nle(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchesbs(__b, __a, &__cc); + return __cc != 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_nle(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchedbs(__b, __a, &__cc); + return __cc != 0; +} + +/*-- vec_any_nlt ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_nlt(__vector float __a, __vector float __b) { + int __cc; + __builtin_s390_vfchsbs(__b, __a, &__cc); + return __cc != 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_nlt(__vector double __a, __vector double __b) { + int __cc; + __builtin_s390_vfchdbs(__b, __a, &__cc); + return __cc != 0; +} + +/*-- vec_any_nan ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_nan(__vector float __a) { + int __cc; + __builtin_s390_vftcisb(__a, 15, &__cc); + return __cc != 3; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_nan(__vector double __a) { + int __cc; + __builtin_s390_vftcidb(__a, 15, &__cc); + return __cc != 3; +} + +/*-- vec_any_numeric --------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_any_numeric(__vector float __a) { + int __cc; + __builtin_s390_vftcisb(__a, 15, &__cc); + return __cc != 0; +} +#endif + +static inline __ATTRS_o_ai int +vec_any_numeric(__vector double __a) { + int __cc; + __builtin_s390_vftcidb(__a, 15, &__cc); + return __cc != 0; +} + +/*-- vec_blend --------------------------------------------------------------*/ + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed char +vec_blend(__vector signed char __a, __vector signed char __b, + __vector signed char __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed char)0)); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_blend(__vector __bool char __a, __vector __bool char __b, + __vector signed char __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed char)0)); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_blend(__vector unsigned char __a, __vector unsigned char __b, + __vector signed char __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed char)0)); +} + +static inline __ATTRS_o_ai __vector signed short +vec_blend(__vector signed short __a, __vector signed short __b, + __vector signed short __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed short)0)); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_blend(__vector __bool short __a, __vector __bool short __b, + __vector signed short __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed short)0)); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_blend(__vector unsigned short __a, __vector unsigned short __b, + __vector signed short __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed short)0)); +} + +static inline __ATTRS_o_ai __vector signed int +vec_blend(__vector signed int __a, __vector signed int __b, + __vector signed int __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed int)0)); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_blend(__vector __bool int __a, __vector __bool int __b, + __vector signed int __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed int)0)); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_blend(__vector unsigned int __a, __vector unsigned int __b, + __vector signed int __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed int)0)); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_blend(__vector signed long long __a, __vector signed long long __b, + __vector signed long long __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed long long)0)); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_blend(__vector __bool long long __a, __vector __bool long long __b, + __vector signed long long __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed long long)0)); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_blend(__vector unsigned long long __a, __vector unsigned long long __b, + __vector signed long long __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed long long)0)); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_blend(__vector signed __int128 __a, __vector signed __int128 __b, + __vector signed __int128 __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed __int128)0)); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_blend(__vector __bool __int128 __a, __vector __bool __int128 __b, + __vector signed __int128 __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed __int128)0)); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_blend(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector signed __int128 __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed __int128)0)); +} + +static inline __ATTRS_o_ai __vector float +vec_blend(__vector float __a, __vector float __b, + __vector signed int __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed int)0)); +} + +static inline __ATTRS_o_ai __vector double +vec_blend(__vector double __a, __vector double __b, + __vector signed long long __c) { + return vec_sel(__a, __b, vec_cmplt(__c, (__vector signed long long)0)); +} +#endif + +/*-- vec_and ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_and(__vector __bool char __a, __vector __bool char __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector signed char +vec_and(__vector signed char __a, __vector signed char __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_and(__vector unsigned char __a, __vector unsigned char __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_and(__vector __bool short __a, __vector __bool short __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector signed short +vec_and(__vector signed short __a, __vector signed short __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_and(__vector unsigned short __a, __vector unsigned short __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_and(__vector __bool int __a, __vector __bool int __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector signed int +vec_and(__vector signed int __a, __vector signed int __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_and(__vector unsigned int __a, __vector unsigned int __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_and(__vector __bool long long __a, __vector __bool long long __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_and(__vector signed long long __a, __vector signed long long __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_and(__vector unsigned long long __a, __vector unsigned long long __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_and(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_and(__vector signed __int128 __a, __vector signed __int128 __b) { + return __a & __b; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_and(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return __a & __b; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_and(__vector float __a, __vector float __b) { + return (__vector float)((__vector unsigned int)__a & + (__vector unsigned int)__b); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_and(__vector double __a, __vector double __b) { + return (__vector double)((__vector unsigned long long)__a & + (__vector unsigned long long)__b); +} + +/*-- vec_or ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_or(__vector __bool char __a, __vector __bool char __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector signed char +vec_or(__vector signed char __a, __vector signed char __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_or(__vector unsigned char __a, __vector unsigned char __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_or(__vector __bool short __a, __vector __bool short __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector signed short +vec_or(__vector signed short __a, __vector signed short __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_or(__vector unsigned short __a, __vector unsigned short __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_or(__vector __bool int __a, __vector __bool int __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector signed int +vec_or(__vector signed int __a, __vector signed int __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_or(__vector unsigned int __a, __vector unsigned int __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_or(__vector __bool long long __a, __vector __bool long long __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_or(__vector signed long long __a, __vector signed long long __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_or(__vector unsigned long long __a, __vector unsigned long long __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_or(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_or(__vector signed __int128 __a, __vector signed __int128 __b) { + return __a | __b; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_or(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return __a | __b; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_or(__vector float __a, __vector float __b) { + return (__vector float)((__vector unsigned int)__a | + (__vector unsigned int)__b); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_or(__vector double __a, __vector double __b) { + return (__vector double)((__vector unsigned long long)__a | + (__vector unsigned long long)__b); +} + +/*-- vec_xor ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_xor(__vector __bool char __a, __vector __bool char __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector signed char +vec_xor(__vector signed char __a, __vector signed char __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_xor(__vector unsigned char __a, __vector unsigned char __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_xor(__vector __bool short __a, __vector __bool short __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector signed short +vec_xor(__vector signed short __a, __vector signed short __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_xor(__vector unsigned short __a, __vector unsigned short __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_xor(__vector __bool int __a, __vector __bool int __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector signed int +vec_xor(__vector signed int __a, __vector signed int __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_xor(__vector unsigned int __a, __vector unsigned int __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_xor(__vector __bool long long __a, __vector __bool long long __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_xor(__vector signed long long __a, __vector signed long long __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_xor(__vector unsigned long long __a, __vector unsigned long long __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_xor(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_xor(__vector signed __int128 __a, __vector signed __int128 __b) { + return __a ^ __b; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_xor(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return __a ^ __b; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_xor(__vector float __a, __vector float __b) { + return (__vector float)((__vector unsigned int)__a ^ + (__vector unsigned int)__b); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_xor(__vector double __a, __vector double __b) { + return (__vector double)((__vector unsigned long long)__a ^ + (__vector unsigned long long)__b); +} + +/*-- vec_andc ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_andc(__vector __bool char __a, __vector __bool char __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector signed char +vec_andc(__vector signed char __a, __vector signed char __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_andc(__vector __bool char __a, __vector signed char __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_andc(__vector signed char __a, __vector __bool char __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_andc(__vector unsigned char __a, __vector unsigned char __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_andc(__vector __bool char __a, __vector unsigned char __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_andc(__vector unsigned char __a, __vector __bool char __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_andc(__vector __bool short __a, __vector __bool short __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector signed short +vec_andc(__vector signed short __a, __vector signed short __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_andc(__vector __bool short __a, __vector signed short __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_andc(__vector signed short __a, __vector __bool short __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_andc(__vector unsigned short __a, __vector unsigned short __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_andc(__vector __bool short __a, __vector unsigned short __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_andc(__vector unsigned short __a, __vector __bool short __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_andc(__vector __bool int __a, __vector __bool int __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector signed int +vec_andc(__vector signed int __a, __vector signed int __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_andc(__vector __bool int __a, __vector signed int __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_andc(__vector signed int __a, __vector __bool int __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_andc(__vector unsigned int __a, __vector unsigned int __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_andc(__vector __bool int __a, __vector unsigned int __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_andc(__vector unsigned int __a, __vector __bool int __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_andc(__vector __bool long long __a, __vector __bool long long __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_andc(__vector signed long long __a, __vector signed long long __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_andc(__vector __bool long long __a, __vector signed long long __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_andc(__vector signed long long __a, __vector __bool long long __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_andc(__vector unsigned long long __a, __vector unsigned long long __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_andc(__vector __bool long long __a, __vector unsigned long long __b) { + return __a & ~__b; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_andc(__vector unsigned long long __a, __vector __bool long long __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_andc(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_andc(__vector signed __int128 __a, __vector signed __int128 __b) { + return __a & ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_andc(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return __a & ~__b; +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_andc(__vector float __a, __vector float __b) { + return (__vector float)((__vector unsigned int)__a & + ~(__vector unsigned int)__b); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_andc(__vector double __a, __vector double __b) { + return (__vector double)((__vector unsigned long long)__a & + ~(__vector unsigned long long)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_andc(__vector __bool long long __a, __vector double __b) { + return (__vector double)((__vector unsigned long long)__a & + ~(__vector unsigned long long)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_andc(__vector double __a, __vector __bool long long __b) { + return (__vector double)((__vector unsigned long long)__a & + ~(__vector unsigned long long)__b); +} + +/*-- vec_nor ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_nor(__vector __bool char __a, __vector __bool char __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector signed char +vec_nor(__vector signed char __a, __vector signed char __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_nor(__vector __bool char __a, __vector signed char __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_nor(__vector signed char __a, __vector __bool char __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_nor(__vector unsigned char __a, __vector unsigned char __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_nor(__vector __bool char __a, __vector unsigned char __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_nor(__vector unsigned char __a, __vector __bool char __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_nor(__vector __bool short __a, __vector __bool short __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_nor(__vector signed short __a, __vector signed short __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_nor(__vector __bool short __a, __vector signed short __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_nor(__vector signed short __a, __vector __bool short __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_nor(__vector unsigned short __a, __vector unsigned short __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_nor(__vector __bool short __a, __vector unsigned short __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_nor(__vector unsigned short __a, __vector __bool short __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_nor(__vector __bool int __a, __vector __bool int __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_nor(__vector signed int __a, __vector signed int __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_nor(__vector __bool int __a, __vector signed int __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_nor(__vector signed int __a, __vector __bool int __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_nor(__vector unsigned int __a, __vector unsigned int __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_nor(__vector __bool int __a, __vector unsigned int __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_nor(__vector unsigned int __a, __vector __bool int __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_nor(__vector __bool long long __a, __vector __bool long long __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_nor(__vector signed long long __a, __vector signed long long __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_nor(__vector __bool long long __a, __vector signed long long __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_nor(__vector signed long long __a, __vector __bool long long __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_nor(__vector unsigned long long __a, __vector unsigned long long __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_nor(__vector __bool long long __a, __vector unsigned long long __b) { + return ~(__a | __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_nor(__vector unsigned long long __a, __vector __bool long long __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_nor(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_nor(__vector signed __int128 __a, __vector signed __int128 __b) { + return ~(__a | __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_nor(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return ~(__a | __b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_nor(__vector float __a, __vector float __b) { + return (__vector float)~((__vector unsigned int)__a | + (__vector unsigned int)__b); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_nor(__vector double __a, __vector double __b) { + return (__vector double)~((__vector unsigned long long)__a | + (__vector unsigned long long)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_nor(__vector __bool long long __a, __vector double __b) { + return (__vector double)~((__vector unsigned long long)__a | + (__vector unsigned long long)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_nor(__vector double __a, __vector __bool long long __b) { + return (__vector double)~((__vector unsigned long long)__a | + (__vector unsigned long long)__b); +} + +/*-- vec_orc ----------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool char +vec_orc(__vector __bool char __a, __vector __bool char __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector signed char +vec_orc(__vector signed char __a, __vector signed char __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_orc(__vector unsigned char __a, __vector unsigned char __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector __bool short +vec_orc(__vector __bool short __a, __vector __bool short __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector signed short +vec_orc(__vector signed short __a, __vector signed short __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_orc(__vector unsigned short __a, __vector unsigned short __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector __bool int +vec_orc(__vector __bool int __a, __vector __bool int __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector signed int +vec_orc(__vector signed int __a, __vector signed int __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_orc(__vector unsigned int __a, __vector unsigned int __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_orc(__vector __bool long long __a, __vector __bool long long __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_orc(__vector signed long long __a, __vector signed long long __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_orc(__vector unsigned long long __a, __vector unsigned long long __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_orc(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_orc(__vector signed __int128 __a, __vector signed __int128 __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_orc(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return __a | ~__b; +} + +static inline __ATTRS_o_ai __vector float +vec_orc(__vector float __a, __vector float __b) { + return (__vector float)((__vector unsigned int)__a | + ~(__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector double +vec_orc(__vector double __a, __vector double __b) { + return (__vector double)((__vector unsigned long long)__a | + ~(__vector unsigned long long)__b); +} +#endif + +/*-- vec_nand ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool char +vec_nand(__vector __bool char __a, __vector __bool char __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector signed char +vec_nand(__vector signed char __a, __vector signed char __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_nand(__vector unsigned char __a, __vector unsigned char __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_nand(__vector __bool short __a, __vector __bool short __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_nand(__vector signed short __a, __vector signed short __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_nand(__vector unsigned short __a, __vector unsigned short __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_nand(__vector __bool int __a, __vector __bool int __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_nand(__vector signed int __a, __vector signed int __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_nand(__vector unsigned int __a, __vector unsigned int __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_nand(__vector __bool long long __a, __vector __bool long long __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_nand(__vector signed long long __a, __vector signed long long __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_nand(__vector unsigned long long __a, __vector unsigned long long __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_nand(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_nand(__vector signed __int128 __a, __vector signed __int128 __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_nand(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return ~(__a & __b); +} + +static inline __ATTRS_o_ai __vector float +vec_nand(__vector float __a, __vector float __b) { + return (__vector float)~((__vector unsigned int)__a & + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector double +vec_nand(__vector double __a, __vector double __b) { + return (__vector double)~((__vector unsigned long long)__a & + (__vector unsigned long long)__b); +} +#endif + +/*-- vec_eqv ----------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector __bool char +vec_eqv(__vector __bool char __a, __vector __bool char __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector signed char +vec_eqv(__vector signed char __a, __vector signed char __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_eqv(__vector unsigned char __a, __vector unsigned char __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_eqv(__vector __bool short __a, __vector __bool short __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_eqv(__vector signed short __a, __vector signed short __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_eqv(__vector unsigned short __a, __vector unsigned short __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_eqv(__vector __bool int __a, __vector __bool int __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_eqv(__vector signed int __a, __vector signed int __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_eqv(__vector unsigned int __a, __vector unsigned int __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector __bool long long +vec_eqv(__vector __bool long long __a, __vector __bool long long __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_eqv(__vector signed long long __a, __vector signed long long __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_eqv(__vector unsigned long long __a, __vector unsigned long long __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector __bool __int128 +vec_eqv(__vector __bool __int128 __a, __vector __bool __int128 __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_eqv(__vector signed __int128 __a, __vector signed __int128 __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_eqv(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return ~(__a ^ __b); +} + +static inline __ATTRS_o_ai __vector float +vec_eqv(__vector float __a, __vector float __b) { + return (__vector float)~((__vector unsigned int)__a ^ + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector double +vec_eqv(__vector double __a, __vector double __b) { + return (__vector double)~((__vector unsigned long long)__a ^ + (__vector unsigned long long)__b); +} +#endif + +/*-- vec_evaluate -----------------------------------------------------------*/ + +#if __ARCH__ >= 15 +extern __ATTRS_o __vector signed char +vec_evaluate(__vector signed char __a, __vector signed char __b, + __vector signed char __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector unsigned char +vec_evaluate(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector __bool char +vec_evaluate(__vector __bool char __a, __vector __bool char __b, + __vector __bool char __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector signed short +vec_evaluate(__vector signed short __a, __vector signed short __b, + __vector signed short __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector unsigned short +vec_evaluate(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector __bool short +vec_evaluate(__vector __bool short __a, __vector __bool short __b, + __vector __bool short __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector signed int +vec_evaluate(__vector signed int __a, __vector signed int __b, + __vector signed int __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector unsigned int +vec_evaluate(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector __bool int +vec_evaluate(__vector __bool int __a, __vector __bool int __b, + __vector __bool int __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector signed long long +vec_evaluate(__vector signed long long __a, __vector signed long long __b, + __vector signed long long __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector unsigned long long +vec_evaluate(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned long long __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector __bool long long +vec_evaluate(__vector __bool long long __a, __vector __bool long long __b, + __vector __bool long long __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector signed __int128 +vec_evaluate(__vector signed __int128 __a, __vector signed __int128 __b, + __vector signed __int128 __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector unsigned __int128 +vec_evaluate(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c, unsigned char __d) + __constant(__d); + +extern __ATTRS_o __vector __bool __int128 +vec_evaluate(__vector __bool __int128 __a, __vector __bool __int128 __b, + __vector __bool __int128 __c, unsigned char __d) + __constant(__d); + +#define vec_evaluate(A, B, C, D) \ + ((__typeof__((vec_evaluate)((A), (B), (C), (D)))) \ + __builtin_s390_veval((__vector unsigned char)(A), \ + (__vector unsigned char)(B), \ + (__vector unsigned char)(C), (D))) +#endif + +/*-- vec_cntlz --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cntlz(__vector signed char __a) { + return __builtin_s390_vclzb((__vector unsigned char)__a); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cntlz(__vector unsigned char __a) { + return __builtin_s390_vclzb(__a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cntlz(__vector signed short __a) { + return __builtin_s390_vclzh((__vector unsigned short)__a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cntlz(__vector unsigned short __a) { + return __builtin_s390_vclzh(__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cntlz(__vector signed int __a) { + return __builtin_s390_vclzf((__vector unsigned int)__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cntlz(__vector unsigned int __a) { + return __builtin_s390_vclzf(__a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_cntlz(__vector signed long long __a) { + return __builtin_s390_vclzg((__vector unsigned long long)__a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_cntlz(__vector unsigned long long __a) { + return __builtin_s390_vclzg(__a); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_cntlz(__vector signed __int128 __a) { + return (__vector unsigned __int128) + __builtin_s390_vclzq((unsigned __int128)__a); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_cntlz(__vector unsigned __int128 __a) { + return (__vector unsigned __int128) + __builtin_s390_vclzq((unsigned __int128)__a); +} +#endif + +/*-- vec_cnttz --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cnttz(__vector signed char __a) { + return __builtin_s390_vctzb((__vector unsigned char)__a); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cnttz(__vector unsigned char __a) { + return __builtin_s390_vctzb(__a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cnttz(__vector signed short __a) { + return __builtin_s390_vctzh((__vector unsigned short)__a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cnttz(__vector unsigned short __a) { + return __builtin_s390_vctzh(__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cnttz(__vector signed int __a) { + return __builtin_s390_vctzf((__vector unsigned int)__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cnttz(__vector unsigned int __a) { + return __builtin_s390_vctzf(__a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_cnttz(__vector signed long long __a) { + return __builtin_s390_vctzg((__vector unsigned long long)__a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_cnttz(__vector unsigned long long __a) { + return __builtin_s390_vctzg(__a); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_cnttz(__vector signed __int128 __a) { + return (__vector unsigned __int128) + __builtin_s390_vctzq((unsigned __int128)__a); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_cnttz(__vector unsigned __int128 __a) { + return (__vector unsigned __int128) + __builtin_s390_vctzq((unsigned __int128)__a); +} +#endif + +/*-- vec_popcnt -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_popcnt(__vector signed char __a) { + return __builtin_elementwise_popcount((__vector unsigned char)__a); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_popcnt(__vector unsigned char __a) { + return __builtin_elementwise_popcount(__a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_popcnt(__vector signed short __a) { + return __builtin_elementwise_popcount((__vector unsigned short)__a); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_popcnt(__vector unsigned short __a) { + return __builtin_elementwise_popcount(__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_popcnt(__vector signed int __a) { + return __builtin_elementwise_popcount((__vector unsigned int)__a); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_popcnt(__vector unsigned int __a) { + return __builtin_elementwise_popcount(__a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_popcnt(__vector signed long long __a) { + return __builtin_elementwise_popcount((__vector unsigned long long)__a); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_popcnt(__vector unsigned long long __a) { + return __builtin_elementwise_popcount(__a); +} + +/*-- vec_rl -----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_rl(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_verllvb( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_rl(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_verllvb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_rl(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_verllvh( + (__vector unsigned short)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_rl(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_verllvh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_rl(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_verllvf( + (__vector unsigned int)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_rl(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_verllvf(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_rl(__vector signed long long __a, __vector unsigned long long __b) { + return (__vector signed long long)__builtin_s390_verllvg( + (__vector unsigned long long)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_rl(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_verllvg(__a, __b); +} + +/*-- vec_rli ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_rli(__vector signed char __a, unsigned long __b) { + return (__vector signed char)__builtin_s390_verllb( + (__vector unsigned char)__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_rli(__vector unsigned char __a, unsigned long __b) { + return __builtin_s390_verllb(__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_rli(__vector signed short __a, unsigned long __b) { + return (__vector signed short)__builtin_s390_verllh( + (__vector unsigned short)__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_rli(__vector unsigned short __a, unsigned long __b) { + return __builtin_s390_verllh(__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_rli(__vector signed int __a, unsigned long __b) { + return (__vector signed int)__builtin_s390_verllf( + (__vector unsigned int)__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_rli(__vector unsigned int __a, unsigned long __b) { + return __builtin_s390_verllf(__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_rli(__vector signed long long __a, unsigned long __b) { + return (__vector signed long long)__builtin_s390_verllg( + (__vector unsigned long long)__a, (unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_rli(__vector unsigned long long __a, unsigned long __b) { + return __builtin_s390_verllg(__a, (unsigned char)__b); +} + +/*-- vec_rl_mask ------------------------------------------------------------*/ + +extern __ATTRS_o __vector signed char +vec_rl_mask(__vector signed char __a, __vector unsigned char __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector unsigned char +vec_rl_mask(__vector unsigned char __a, __vector unsigned char __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector signed short +vec_rl_mask(__vector signed short __a, __vector unsigned short __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector unsigned short +vec_rl_mask(__vector unsigned short __a, __vector unsigned short __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector signed int +vec_rl_mask(__vector signed int __a, __vector unsigned int __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector unsigned int +vec_rl_mask(__vector unsigned int __a, __vector unsigned int __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector signed long long +vec_rl_mask(__vector signed long long __a, __vector unsigned long long __b, + unsigned char __c) __constant(__c); + +extern __ATTRS_o __vector unsigned long long +vec_rl_mask(__vector unsigned long long __a, __vector unsigned long long __b, + unsigned char __c) __constant(__c); + +#define vec_rl_mask(X, Y, Z) ((__typeof__((vec_rl_mask)((X), (Y), (Z)))) \ + __extension__ ({ \ + __vector unsigned char __res; \ + __vector unsigned char __x = (__vector unsigned char)(X); \ + __vector unsigned char __y = (__vector unsigned char)(Y); \ + switch (sizeof ((X)[0])) { \ + case 1: __res = (__vector unsigned char) __builtin_s390_verimb( \ + (__vector unsigned char)__x, (__vector unsigned char)__x, \ + (__vector unsigned char)__y, (Z)); break; \ + case 2: __res = (__vector unsigned char) __builtin_s390_verimh( \ + (__vector unsigned short)__x, (__vector unsigned short)__x, \ + (__vector unsigned short)__y, (Z)); break; \ + case 4: __res = (__vector unsigned char) __builtin_s390_verimf( \ + (__vector unsigned int)__x, (__vector unsigned int)__x, \ + (__vector unsigned int)__y, (Z)); break; \ + default: __res = (__vector unsigned char) __builtin_s390_verimg( \ + (__vector unsigned long long)__x, (__vector unsigned long long)__x, \ + (__vector unsigned long long)__y, (Z)); break; \ + } __res; })) + +/*-- vec_sll ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_sll(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_sll(__vector signed char __a, __vector unsigned short __b) { + return (__vector signed char)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_sll(__vector signed char __a, __vector unsigned int __b) { + return (__vector signed char)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_sll(__vector __bool char __a, __vector unsigned char __b) { + return (__vector __bool char)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_sll(__vector __bool char __a, __vector unsigned short __b) { + return (__vector __bool char)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_sll(__vector __bool char __a, __vector unsigned int __b) { + return (__vector __bool char)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_sll(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vsl(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_sll(__vector unsigned char __a, __vector unsigned short __b) { + return __builtin_s390_vsl(__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_sll(__vector unsigned char __a, __vector unsigned int __b) { + return __builtin_s390_vsl(__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_sll(__vector signed short __a, __vector unsigned char __b) { + return (__vector signed short)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_sll(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_sll(__vector signed short __a, __vector unsigned int __b) { + return (__vector signed short)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_sll(__vector __bool short __a, __vector unsigned char __b) { + return (__vector __bool short)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_sll(__vector __bool short __a, __vector unsigned short __b) { + return (__vector __bool short)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_sll(__vector __bool short __a, __vector unsigned int __b) { + return (__vector __bool short)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_sll(__vector unsigned short __a, __vector unsigned char __b) { + return (__vector unsigned short)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_sll(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_sll(__vector unsigned short __a, __vector unsigned int __b) { + return (__vector unsigned short)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_sll(__vector signed int __a, __vector unsigned char __b) { + return (__vector signed int)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_sll(__vector signed int __a, __vector unsigned short __b) { + return (__vector signed int)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_sll(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_sll(__vector __bool int __a, __vector unsigned char __b) { + return (__vector __bool int)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_sll(__vector __bool int __a, __vector unsigned short __b) { + return (__vector __bool int)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_sll(__vector __bool int __a, __vector unsigned int __b) { + return (__vector __bool int)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_sll(__vector unsigned int __a, __vector unsigned char __b) { + return (__vector unsigned int)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_sll(__vector unsigned int __a, __vector unsigned short __b) { + return (__vector unsigned int)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_sll(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_sll(__vector signed long long __a, __vector unsigned char __b) { + return (__vector signed long long)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_sll(__vector signed long long __a, __vector unsigned short __b) { + return (__vector signed long long)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_sll(__vector signed long long __a, __vector unsigned int __b) { + return (__vector signed long long)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_sll(__vector __bool long long __a, __vector unsigned char __b) { + return (__vector __bool long long)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_sll(__vector __bool long long __a, __vector unsigned short __b) { + return (__vector __bool long long)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_sll(__vector __bool long long __a, __vector unsigned int __b) { + return (__vector __bool long long)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_sll(__vector unsigned long long __a, __vector unsigned char __b) { + return (__vector unsigned long long)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_sll(__vector unsigned long long __a, __vector unsigned short __b) { + return (__vector unsigned long long)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_sll(__vector unsigned long long __a, __vector unsigned int __b) { + return (__vector unsigned long long)__builtin_s390_vsl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_sll(__vector signed __int128 __a, __vector unsigned char __b) { + return (__vector signed __int128)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_sll(__vector unsigned __int128 __a, __vector unsigned char __b) { + return (__vector unsigned __int128)__builtin_s390_vsl( + (__vector unsigned char)__a, __b); +} + +/*-- vec_slb ----------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_slb(__vector signed char __a, __vector signed char __b) { + return (__vector signed char)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed char +vec_slb(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_slb(__vector unsigned char __a, __vector signed char __b) { + return __builtin_s390_vslb(__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_slb(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vslb(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_slb(__vector signed short __a, __vector signed short __b) { + return (__vector signed short)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_slb(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_slb(__vector signed short __a, __vector unsigned char __b) { + return (__vector signed short)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_slb(__vector unsigned short __a, __vector signed short __b) { + return (__vector unsigned short)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_slb(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_slb(__vector unsigned short __a, __vector unsigned char __b) { + return (__vector unsigned short)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_slb(__vector signed int __a, __vector signed int __b) { + return (__vector signed int)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_slb(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_slb(__vector signed int __a, __vector unsigned char __b) { + return (__vector signed int)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_slb(__vector unsigned int __a, __vector signed int __b) { + return (__vector unsigned int)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_slb(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_slb(__vector unsigned int __a, __vector unsigned char __b) { + return (__vector unsigned int)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_slb(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed long long)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_slb(__vector signed long long __a, __vector unsigned long long __b) { + return (__vector signed long long)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_slb(__vector signed long long __a, __vector unsigned char __b) { + return (__vector signed long long)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_slb(__vector unsigned long long __a, __vector signed long long __b) { + return (__vector unsigned long long)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_slb(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned long long)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_slb(__vector unsigned long long __a, __vector unsigned char __b) { + return (__vector unsigned long long)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_slb(__vector signed __int128 __a, __vector unsigned char __b) { + return (__vector signed __int128)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_slb(__vector unsigned __int128 __a, __vector unsigned char __b) { + return (__vector unsigned __int128)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +#if __ARCH__ >= 12 +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_slb(__vector float __a, __vector signed int __b) { + return (__vector float)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_slb(__vector float __a, __vector unsigned int __b) { + return (__vector float)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector float +vec_slb(__vector float __a, __vector unsigned char __b) { + return (__vector float)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} +#endif + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_slb(__vector double __a, __vector signed long long __b) { + return (__vector double)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_slb(__vector double __a, __vector unsigned long long __b) { + return (__vector double)__builtin_s390_vslb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector double +vec_slb(__vector double __a, __vector unsigned char __b) { + return (__vector double)__builtin_s390_vslb( + (__vector unsigned char)__a, __b); +} + +/*-- vec_sld ----------------------------------------------------------------*/ + +extern __ATTRS_o __vector signed char +vec_sld(__vector signed char __a, __vector signed char __b, int __c) + __constant_range(__c, 0, 15); + +// This prototype is deprecated. +extern __ATTRS_o __vector __bool char +vec_sld(__vector __bool char __a, __vector __bool char __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector unsigned char +vec_sld(__vector unsigned char __a, __vector unsigned char __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector signed short +vec_sld(__vector signed short __a, __vector signed short __b, int __c) + __constant_range(__c, 0, 15); + +// This prototype is deprecated. +extern __ATTRS_o __vector __bool short +vec_sld(__vector __bool short __a, __vector __bool short __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector unsigned short +vec_sld(__vector unsigned short __a, __vector unsigned short __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector signed int +vec_sld(__vector signed int __a, __vector signed int __b, int __c) + __constant_range(__c, 0, 15); + +// This prototype is deprecated. +extern __ATTRS_o __vector __bool int +vec_sld(__vector __bool int __a, __vector __bool int __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector unsigned int +vec_sld(__vector unsigned int __a, __vector unsigned int __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector signed long long +vec_sld(__vector signed long long __a, __vector signed long long __b, int __c) + __constant_range(__c, 0, 15); + +// This prototype is deprecated. +extern __ATTRS_o __vector __bool long long +vec_sld(__vector __bool long long __a, __vector __bool long long __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector unsigned long long +vec_sld(__vector unsigned long long __a, __vector unsigned long long __b, + int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector signed __int128 +vec_sld(__vector signed __int128 __a, __vector signed __int128 __b, int __c) + __constant_range(__c, 0, 15); + +extern __ATTRS_o __vector unsigned __int128 +vec_sld(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + int __c) + __constant_range(__c, 0, 15); + +#if __ARCH__ >= 12 +extern __ATTRS_o __vector float +vec_sld(__vector float __a, __vector float __b, int __c) + __constant_range(__c, 0, 15); +#endif + +extern __ATTRS_o __vector double +vec_sld(__vector double __a, __vector double __b, int __c) + __constant_range(__c, 0, 15); + +#define vec_sld(X, Y, Z) ((__typeof__((vec_sld)((X), (Y), (Z)))) \ + __builtin_s390_vsldb((__vector unsigned char)(X), \ + (__vector unsigned char)(Y), (Z))) + +/*-- vec_sldw ---------------------------------------------------------------*/ + +extern __ATTRS_o __vector signed char +vec_sldw(__vector signed char __a, __vector signed char __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector unsigned char +vec_sldw(__vector unsigned char __a, __vector unsigned char __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector signed short +vec_sldw(__vector signed short __a, __vector signed short __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector unsigned short +vec_sldw(__vector unsigned short __a, __vector unsigned short __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector signed int +vec_sldw(__vector signed int __a, __vector signed int __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector unsigned int +vec_sldw(__vector unsigned int __a, __vector unsigned int __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector signed long long +vec_sldw(__vector signed long long __a, __vector signed long long __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector unsigned long long +vec_sldw(__vector unsigned long long __a, __vector unsigned long long __b, + int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector signed __int128 +vec_sldw(__vector signed __int128 __a, __vector signed __int128 __b, int __c) + __constant_range(__c, 0, 3); + +extern __ATTRS_o __vector unsigned __int128 +vec_sldw(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + int __c) + __constant_range(__c, 0, 3); + +// This prototype is deprecated. +extern __ATTRS_o __vector double +vec_sldw(__vector double __a, __vector double __b, int __c) + __constant_range(__c, 0, 3); + +#define vec_sldw(X, Y, Z) ((__typeof__((vec_sldw)((X), (Y), (Z)))) \ + __builtin_s390_vsldb((__vector unsigned char)(X), \ + (__vector unsigned char)(Y), (Z) * 4)) + +/*-- vec_sldb ---------------------------------------------------------------*/ + +#if __ARCH__ >= 13 + +extern __ATTRS_o __vector signed char +vec_sldb(__vector signed char __a, __vector signed char __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned char +vec_sldb(__vector unsigned char __a, __vector unsigned char __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed short +vec_sldb(__vector signed short __a, __vector signed short __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned short +vec_sldb(__vector unsigned short __a, __vector unsigned short __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed int +vec_sldb(__vector signed int __a, __vector signed int __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned int +vec_sldb(__vector unsigned int __a, __vector unsigned int __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed long long +vec_sldb(__vector signed long long __a, __vector signed long long __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned long long +vec_sldb(__vector unsigned long long __a, __vector unsigned long long __b, + int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed __int128 +vec_sldb(__vector signed __int128 __a, __vector signed __int128 __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned __int128 +vec_sldb(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector float +vec_sldb(__vector float __a, __vector float __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector double +vec_sldb(__vector double __a, __vector double __b, int __c) + __constant_range(__c, 0, 7); + +#define vec_sldb(X, Y, Z) ((__typeof__((vec_sldb)((X), (Y), (Z)))) \ + __builtin_s390_vsld((__vector unsigned char)(X), \ + (__vector unsigned char)(Y), (Z))) + +#endif + +/*-- vec_sral ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_sral(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_sral(__vector signed char __a, __vector unsigned short __b) { + return (__vector signed char)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_sral(__vector signed char __a, __vector unsigned int __b) { + return (__vector signed char)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_sral(__vector __bool char __a, __vector unsigned char __b) { + return (__vector __bool char)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_sral(__vector __bool char __a, __vector unsigned short __b) { + return (__vector __bool char)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_sral(__vector __bool char __a, __vector unsigned int __b) { + return (__vector __bool char)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_sral(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vsra(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_sral(__vector unsigned char __a, __vector unsigned short __b) { + return __builtin_s390_vsra(__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_sral(__vector unsigned char __a, __vector unsigned int __b) { + return __builtin_s390_vsra(__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_sral(__vector signed short __a, __vector unsigned char __b) { + return (__vector signed short)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_sral(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_sral(__vector signed short __a, __vector unsigned int __b) { + return (__vector signed short)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_sral(__vector __bool short __a, __vector unsigned char __b) { + return (__vector __bool short)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_sral(__vector __bool short __a, __vector unsigned short __b) { + return (__vector __bool short)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_sral(__vector __bool short __a, __vector unsigned int __b) { + return (__vector __bool short)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_sral(__vector unsigned short __a, __vector unsigned char __b) { + return (__vector unsigned short)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_sral(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_sral(__vector unsigned short __a, __vector unsigned int __b) { + return (__vector unsigned short)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_sral(__vector signed int __a, __vector unsigned char __b) { + return (__vector signed int)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_sral(__vector signed int __a, __vector unsigned short __b) { + return (__vector signed int)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_sral(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_sral(__vector __bool int __a, __vector unsigned char __b) { + return (__vector __bool int)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_sral(__vector __bool int __a, __vector unsigned short __b) { + return (__vector __bool int)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_sral(__vector __bool int __a, __vector unsigned int __b) { + return (__vector __bool int)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_sral(__vector unsigned int __a, __vector unsigned char __b) { + return (__vector unsigned int)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_sral(__vector unsigned int __a, __vector unsigned short __b) { + return (__vector unsigned int)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_sral(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_sral(__vector signed long long __a, __vector unsigned char __b) { + return (__vector signed long long)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_sral(__vector signed long long __a, __vector unsigned short __b) { + return (__vector signed long long)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_sral(__vector signed long long __a, __vector unsigned int __b) { + return (__vector signed long long)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_sral(__vector __bool long long __a, __vector unsigned char __b) { + return (__vector __bool long long)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_sral(__vector __bool long long __a, __vector unsigned short __b) { + return (__vector __bool long long)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_sral(__vector __bool long long __a, __vector unsigned int __b) { + return (__vector __bool long long)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_sral(__vector unsigned long long __a, __vector unsigned char __b) { + return (__vector unsigned long long)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_sral(__vector unsigned long long __a, __vector unsigned short __b) { + return (__vector unsigned long long)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_sral(__vector unsigned long long __a, __vector unsigned int __b) { + return (__vector unsigned long long)__builtin_s390_vsra( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_sral(__vector signed __int128 __a, __vector unsigned char __b) { + return (__vector signed __int128)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_sral(__vector unsigned __int128 __a, __vector unsigned char __b) { + return (__vector unsigned __int128)__builtin_s390_vsra( + (__vector unsigned char)__a, __b); +} + +/*-- vec_srab ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_srab(__vector signed char __a, __vector signed char __b) { + return (__vector signed char)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed char +vec_srab(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_srab(__vector unsigned char __a, __vector signed char __b) { + return __builtin_s390_vsrab(__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_srab(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vsrab(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_srab(__vector signed short __a, __vector signed short __b) { + return (__vector signed short)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_srab(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_srab(__vector signed short __a, __vector unsigned char __b) { + return (__vector signed short)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_srab(__vector unsigned short __a, __vector signed short __b) { + return (__vector unsigned short)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_srab(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_srab(__vector unsigned short __a, __vector unsigned char __b) { + return (__vector unsigned short)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_srab(__vector signed int __a, __vector signed int __b) { + return (__vector signed int)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_srab(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_srab(__vector signed int __a, __vector unsigned char __b) { + return (__vector signed int)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_srab(__vector unsigned int __a, __vector signed int __b) { + return (__vector unsigned int)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_srab(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_srab(__vector unsigned int __a, __vector unsigned char __b) { + return (__vector unsigned int)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_srab(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed long long)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_srab(__vector signed long long __a, __vector unsigned long long __b) { + return (__vector signed long long)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_srab(__vector signed long long __a, __vector unsigned char __b) { + return (__vector signed long long)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_srab(__vector unsigned long long __a, __vector signed long long __b) { + return (__vector unsigned long long)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_srab(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned long long)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_srab(__vector unsigned long long __a, __vector unsigned char __b) { + return (__vector unsigned long long)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_srab(__vector signed __int128 __a, __vector unsigned char __b) { + return (__vector signed __int128)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_srab(__vector unsigned __int128 __a, __vector unsigned char __b) { + return (__vector unsigned __int128)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +#if __ARCH__ >= 12 +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_srab(__vector float __a, __vector signed int __b) { + return (__vector float)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_srab(__vector float __a, __vector unsigned int __b) { + return (__vector float)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector float +vec_srab(__vector float __a, __vector unsigned char __b) { + return (__vector float)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} +#endif + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_srab(__vector double __a, __vector signed long long __b) { + return (__vector double)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_srab(__vector double __a, __vector unsigned long long __b) { + return (__vector double)__builtin_s390_vsrab( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector double +vec_srab(__vector double __a, __vector unsigned char __b) { + return (__vector double)__builtin_s390_vsrab( + (__vector unsigned char)__a, __b); +} + +/*-- vec_srl ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_srl(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_srl(__vector signed char __a, __vector unsigned short __b) { + return (__vector signed char)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_srl(__vector signed char __a, __vector unsigned int __b) { + return (__vector signed char)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_srl(__vector __bool char __a, __vector unsigned char __b) { + return (__vector __bool char)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_srl(__vector __bool char __a, __vector unsigned short __b) { + return (__vector __bool char)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool char +vec_srl(__vector __bool char __a, __vector unsigned int __b) { + return (__vector __bool char)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_srl(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vsrl(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_srl(__vector unsigned char __a, __vector unsigned short __b) { + return __builtin_s390_vsrl(__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_srl(__vector unsigned char __a, __vector unsigned int __b) { + return __builtin_s390_vsrl(__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_srl(__vector signed short __a, __vector unsigned char __b) { + return (__vector signed short)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_srl(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_srl(__vector signed short __a, __vector unsigned int __b) { + return (__vector signed short)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_srl(__vector __bool short __a, __vector unsigned char __b) { + return (__vector __bool short)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_srl(__vector __bool short __a, __vector unsigned short __b) { + return (__vector __bool short)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool short +vec_srl(__vector __bool short __a, __vector unsigned int __b) { + return (__vector __bool short)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_srl(__vector unsigned short __a, __vector unsigned char __b) { + return (__vector unsigned short)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_srl(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_srl(__vector unsigned short __a, __vector unsigned int __b) { + return (__vector unsigned short)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_srl(__vector signed int __a, __vector unsigned char __b) { + return (__vector signed int)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_srl(__vector signed int __a, __vector unsigned short __b) { + return (__vector signed int)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_srl(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_srl(__vector __bool int __a, __vector unsigned char __b) { + return (__vector __bool int)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_srl(__vector __bool int __a, __vector unsigned short __b) { + return (__vector __bool int)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool int +vec_srl(__vector __bool int __a, __vector unsigned int __b) { + return (__vector __bool int)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_srl(__vector unsigned int __a, __vector unsigned char __b) { + return (__vector unsigned int)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_srl(__vector unsigned int __a, __vector unsigned short __b) { + return (__vector unsigned int)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_srl(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_srl(__vector signed long long __a, __vector unsigned char __b) { + return (__vector signed long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_srl(__vector signed long long __a, __vector unsigned short __b) { + return (__vector signed long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_srl(__vector signed long long __a, __vector unsigned int __b) { + return (__vector signed long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_srl(__vector __bool long long __a, __vector unsigned char __b) { + return (__vector __bool long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_srl(__vector __bool long long __a, __vector unsigned short __b) { + return (__vector __bool long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector __bool long long +vec_srl(__vector __bool long long __a, __vector unsigned int __b) { + return (__vector __bool long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_srl(__vector unsigned long long __a, __vector unsigned char __b) { + return (__vector unsigned long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_srl(__vector unsigned long long __a, __vector unsigned short __b) { + return (__vector unsigned long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_srl(__vector unsigned long long __a, __vector unsigned int __b) { + return (__vector unsigned long long)__builtin_s390_vsrl( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_srl(__vector signed __int128 __a, __vector unsigned char __b) { + return (__vector signed __int128)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_srl(__vector unsigned __int128 __a, __vector unsigned char __b) { + return (__vector unsigned __int128)__builtin_s390_vsrl( + (__vector unsigned char)__a, __b); +} + +/*-- vec_srb ----------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_srb(__vector signed char __a, __vector signed char __b) { + return (__vector signed char)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed char +vec_srb(__vector signed char __a, __vector unsigned char __b) { + return (__vector signed char)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_srb(__vector unsigned char __a, __vector signed char __b) { + return __builtin_s390_vsrlb(__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_srb(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vsrlb(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_srb(__vector signed short __a, __vector signed short __b) { + return (__vector signed short)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_srb(__vector signed short __a, __vector unsigned short __b) { + return (__vector signed short)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_srb(__vector signed short __a, __vector unsigned char __b) { + return (__vector signed short)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_srb(__vector unsigned short __a, __vector signed short __b) { + return (__vector unsigned short)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_srb(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector unsigned short)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_srb(__vector unsigned short __a, __vector unsigned char __b) { + return (__vector unsigned short)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_srb(__vector signed int __a, __vector signed int __b) { + return (__vector signed int)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_srb(__vector signed int __a, __vector unsigned int __b) { + return (__vector signed int)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_srb(__vector signed int __a, __vector unsigned char __b) { + return (__vector signed int)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_srb(__vector unsigned int __a, __vector signed int __b) { + return (__vector unsigned int)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_srb(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned int)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_srb(__vector unsigned int __a, __vector unsigned char __b) { + return (__vector unsigned int)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_srb(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed long long)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_srb(__vector signed long long __a, __vector unsigned long long __b) { + return (__vector signed long long)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_srb(__vector signed long long __a, __vector unsigned char __b) { + return (__vector signed long long)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_srb(__vector unsigned long long __a, __vector signed long long __b) { + return (__vector unsigned long long)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_srb(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned long long)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_srb(__vector unsigned long long __a, __vector unsigned char __b) { + return (__vector unsigned long long)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_srb(__vector signed __int128 __a, __vector unsigned char __b) { + return (__vector signed __int128)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_srb(__vector unsigned __int128 __a, __vector unsigned char __b) { + return (__vector unsigned __int128)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +#if __ARCH__ >= 12 +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_srb(__vector float __a, __vector signed int __b) { + return (__vector float)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector float +vec_srb(__vector float __a, __vector unsigned int __b) { + return (__vector float)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector float +vec_srb(__vector float __a, __vector unsigned char __b) { + return (__vector float)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} +#endif + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_srb(__vector double __a, __vector signed long long __b) { + return (__vector double)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_srb(__vector double __a, __vector unsigned long long __b) { + return (__vector double)__builtin_s390_vsrlb( + (__vector unsigned char)__a, (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector double +vec_srb(__vector double __a, __vector unsigned char __b) { + return (__vector double)__builtin_s390_vsrlb( + (__vector unsigned char)__a, __b); +} + +/*-- vec_srdb ---------------------------------------------------------------*/ + +#if __ARCH__ >= 13 + +extern __ATTRS_o __vector signed char +vec_srdb(__vector signed char __a, __vector signed char __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned char +vec_srdb(__vector unsigned char __a, __vector unsigned char __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed short +vec_srdb(__vector signed short __a, __vector signed short __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned short +vec_srdb(__vector unsigned short __a, __vector unsigned short __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed int +vec_srdb(__vector signed int __a, __vector signed int __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned int +vec_srdb(__vector unsigned int __a, __vector unsigned int __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed long long +vec_srdb(__vector signed long long __a, __vector signed long long __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned long long +vec_srdb(__vector unsigned long long __a, __vector unsigned long long __b, + int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector signed __int128 +vec_srdb(__vector signed __int128 __a, __vector signed __int128 __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector unsigned __int128 +vec_srdb(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector float +vec_srdb(__vector float __a, __vector float __b, int __c) + __constant_range(__c, 0, 7); + +extern __ATTRS_o __vector double +vec_srdb(__vector double __a, __vector double __b, int __c) + __constant_range(__c, 0, 7); + +#define vec_srdb(X, Y, Z) ((__typeof__((vec_srdb)((X), (Y), (Z)))) \ + __builtin_s390_vsrd((__vector unsigned char)(X), \ + (__vector unsigned char)(Y), (Z))) + +#endif + +/*-- vec_abs ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_abs(__vector signed char __a) { + return vec_sel(__a, -__a, vec_cmplt(__a, (__vector signed char)0)); +} + +static inline __ATTRS_o_ai __vector signed short +vec_abs(__vector signed short __a) { + return vec_sel(__a, -__a, vec_cmplt(__a, (__vector signed short)0)); +} + +static inline __ATTRS_o_ai __vector signed int +vec_abs(__vector signed int __a) { + return vec_sel(__a, -__a, vec_cmplt(__a, (__vector signed int)0)); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_abs(__vector signed long long __a) { + return vec_sel(__a, -__a, vec_cmplt(__a, (__vector signed long long)0)); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_abs(__vector signed __int128 __a) { + return vec_sel(__a, -__a, vec_cmplt(__a, (__vector signed __int128)0)); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_abs(__vector float __a) { + return __builtin_s390_vflpsb(__a); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_abs(__vector double __a) { + return __builtin_s390_vflpdb(__a); +} + +/*-- vec_nabs ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_nabs(__vector float __a) { + return __builtin_s390_vflnsb(__a); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_nabs(__vector double __a) { + return __builtin_s390_vflndb(__a); +} + +/*-- vec_max ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_max(__vector signed char __a, __vector signed char __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_max(__vector signed char __a, __vector __bool char __b) { + __vector signed char __bc = (__vector signed char)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_max(__vector __bool char __a, __vector signed char __b) { + __vector signed char __ac = (__vector signed char)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_max(__vector unsigned char __a, __vector unsigned char __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_max(__vector unsigned char __a, __vector __bool char __b) { + __vector unsigned char __bc = (__vector unsigned char)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_max(__vector __bool char __a, __vector unsigned char __b) { + __vector unsigned char __ac = (__vector unsigned char)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed short +vec_max(__vector signed short __a, __vector signed short __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_max(__vector signed short __a, __vector __bool short __b) { + __vector signed short __bc = (__vector signed short)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_max(__vector __bool short __a, __vector signed short __b) { + __vector signed short __ac = (__vector signed short)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_max(__vector unsigned short __a, __vector unsigned short __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_max(__vector unsigned short __a, __vector __bool short __b) { + __vector unsigned short __bc = (__vector unsigned short)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_max(__vector __bool short __a, __vector unsigned short __b) { + __vector unsigned short __ac = (__vector unsigned short)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed int +vec_max(__vector signed int __a, __vector signed int __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_max(__vector signed int __a, __vector __bool int __b) { + __vector signed int __bc = (__vector signed int)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_max(__vector __bool int __a, __vector signed int __b) { + __vector signed int __ac = (__vector signed int)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_max(__vector unsigned int __a, __vector unsigned int __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_max(__vector unsigned int __a, __vector __bool int __b) { + __vector unsigned int __bc = (__vector unsigned int)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_max(__vector __bool int __a, __vector unsigned int __b) { + __vector unsigned int __ac = (__vector unsigned int)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_max(__vector signed long long __a, __vector signed long long __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_max(__vector signed long long __a, __vector __bool long long __b) { + __vector signed long long __bc = (__vector signed long long)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_max(__vector __bool long long __a, __vector signed long long __b) { + __vector signed long long __ac = (__vector signed long long)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_max(__vector unsigned long long __a, __vector unsigned long long __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_max(__vector unsigned long long __a, __vector __bool long long __b) { + __vector unsigned long long __bc = (__vector unsigned long long)__b; + return vec_sel(__bc, __a, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_max(__vector __bool long long __a, __vector unsigned long long __b) { + __vector unsigned long long __ac = (__vector unsigned long long)__a; + return vec_sel(__b, __ac, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_max(__vector signed __int128 __a, __vector signed __int128 __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_max(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_max(__vector float __a, __vector float __b) { + return __builtin_s390_vfmaxsb(__a, __b, 0); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_max(__vector double __a, __vector double __b) { +#if __ARCH__ >= 12 + return __builtin_s390_vfmaxdb(__a, __b, 0); +#else + return vec_sel(__b, __a, vec_cmpgt(__a, __b)); +#endif +} + +/*-- vec_min ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_min(__vector signed char __a, __vector signed char __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_min(__vector signed char __a, __vector __bool char __b) { + __vector signed char __bc = (__vector signed char)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed char +vec_min(__vector __bool char __a, __vector signed char __b) { + __vector signed char __ac = (__vector signed char)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_min(__vector unsigned char __a, __vector unsigned char __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_min(__vector unsigned char __a, __vector __bool char __b) { + __vector unsigned char __bc = (__vector unsigned char)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_min(__vector __bool char __a, __vector unsigned char __b) { + __vector unsigned char __ac = (__vector unsigned char)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed short +vec_min(__vector signed short __a, __vector signed short __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_min(__vector signed short __a, __vector __bool short __b) { + __vector signed short __bc = (__vector signed short)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed short +vec_min(__vector __bool short __a, __vector signed short __b) { + __vector signed short __ac = (__vector signed short)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_min(__vector unsigned short __a, __vector unsigned short __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_min(__vector unsigned short __a, __vector __bool short __b) { + __vector unsigned short __bc = (__vector unsigned short)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned short +vec_min(__vector __bool short __a, __vector unsigned short __b) { + __vector unsigned short __ac = (__vector unsigned short)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed int +vec_min(__vector signed int __a, __vector signed int __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_min(__vector signed int __a, __vector __bool int __b) { + __vector signed int __bc = (__vector signed int)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed int +vec_min(__vector __bool int __a, __vector signed int __b) { + __vector signed int __ac = (__vector signed int)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_min(__vector unsigned int __a, __vector unsigned int __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_min(__vector unsigned int __a, __vector __bool int __b) { + __vector unsigned int __bc = (__vector unsigned int)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned int +vec_min(__vector __bool int __a, __vector unsigned int __b) { + __vector unsigned int __ac = (__vector unsigned int)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_min(__vector signed long long __a, __vector signed long long __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_min(__vector signed long long __a, __vector __bool long long __b) { + __vector signed long long __bc = (__vector signed long long)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_min(__vector __bool long long __a, __vector signed long long __b) { + __vector signed long long __ac = (__vector signed long long)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_min(__vector unsigned long long __a, __vector unsigned long long __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_min(__vector unsigned long long __a, __vector __bool long long __b) { + __vector unsigned long long __bc = (__vector unsigned long long)__b; + return vec_sel(__a, __bc, vec_cmpgt(__a, __bc)); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_min(__vector __bool long long __a, __vector unsigned long long __b) { + __vector unsigned long long __ac = (__vector unsigned long long)__a; + return vec_sel(__ac, __b, vec_cmpgt(__ac, __b)); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_min(__vector signed __int128 __a, __vector signed __int128 __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_min(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_min(__vector float __a, __vector float __b) { + return __builtin_s390_vfminsb(__a, __b, 0); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_min(__vector double __a, __vector double __b) { +#if __ARCH__ >= 12 + return __builtin_s390_vfmindb(__a, __b, 0); +#else + return vec_sel(__a, __b, vec_cmpgt(__a, __b)); +#endif +} + +/*-- vec_add_u128 -----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_add_u128(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector unsigned char)(__vector unsigned __int128) + ((__int128)__a + (__int128)__b); +} + +/*-- vec_addc ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_addc(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vaccb(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_addc(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vacch(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_addc(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vaccf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_addc(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_vaccg(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_addc(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector unsigned __int128) + __builtin_s390_vaccq((unsigned __int128)__a, (unsigned __int128)__b); +} + +/*-- vec_addc_u128 ----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_addc_u128(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vaccq((unsigned __int128)__a, (unsigned __int128)__b); +} + +/*-- vec_adde ---------------------------------------------------------------*/ + +static inline __ATTRS_ai __vector unsigned __int128 +vec_adde(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vacq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_adde_u128 ----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_adde_u128(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vacq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_addec --------------------------------------------------------------*/ + +static inline __ATTRS_ai __vector unsigned __int128 +vec_addec(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vacccq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_addec_u128 ---------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_addec_u128(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vacccq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_avg ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_avg(__vector signed char __a, __vector signed char __b) { + return __builtin_s390_vavgb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_avg(__vector signed short __a, __vector signed short __b) { + return __builtin_s390_vavgh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_avg(__vector signed int __a, __vector signed int __b) { + return __builtin_s390_vavgf(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_avg(__vector signed long long __a, __vector signed long long __b) { + return __builtin_s390_vavgg(__a, __b); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_avg(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector signed __int128) + __builtin_s390_vavgq((signed __int128)__a, (signed __int128)__b); +} +#endif + +static inline __ATTRS_o_ai __vector unsigned char +vec_avg(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vavglb(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_avg(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vavglh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_avg(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vavglf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_avg(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_vavglg(__a, __b); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_avg(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector unsigned __int128) + __builtin_s390_vavglq((unsigned __int128)__a, (unsigned __int128)__b); +} +#endif + +/*-- vec_checksum -----------------------------------------------------------*/ + +static inline __ATTRS_ai __vector unsigned int +vec_checksum(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vcksm(__a, __b); +} + +/*-- vec_gfmsum -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned short +vec_gfmsum(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vgfmb(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_gfmsum(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vgfmh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_gfmsum(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vgfmf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_gfmsum(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned __int128)__builtin_s390_vgfmg(__a, __b); +} + +/*-- vec_gfmsum_128 ---------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_gfmsum_128(__vector unsigned long long __a, + __vector unsigned long long __b) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vgfmg(__a, __b); +} + +/*-- vec_gfmsum_accum -------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned short +vec_gfmsum_accum(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned short __c) { + return __builtin_s390_vgfmab(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_gfmsum_accum(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned int __c) { + return __builtin_s390_vgfmah(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_gfmsum_accum(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned long long __c) { + return __builtin_s390_vgfmaf(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_gfmsum_accum(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vgfmag(__a, __b, (unsigned __int128)__c); +} + +/*-- vec_gfmsum_accum_128 ---------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_gfmsum_accum_128(__vector unsigned long long __a, + __vector unsigned long long __b, + __vector unsigned char __c) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vgfmag(__a, __b, (unsigned __int128)__c); +} + +/*-- vec_mladd --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_mladd(__vector signed char __a, __vector signed char __b, + __vector signed char __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed char +vec_mladd(__vector unsigned char __a, __vector signed char __b, + __vector signed char __c) { + return (__vector signed char)__a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed char +vec_mladd(__vector signed char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __a * (__vector signed char)__b + (__vector signed char)__c; +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_mladd(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed short +vec_mladd(__vector signed short __a, __vector signed short __b, + __vector signed short __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed short +vec_mladd(__vector unsigned short __a, __vector signed short __b, + __vector signed short __c) { + return (__vector signed short)__a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed short +vec_mladd(__vector signed short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __a * (__vector signed short)__b + (__vector signed short)__c; +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mladd(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed int +vec_mladd(__vector signed int __a, __vector signed int __b, + __vector signed int __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed int +vec_mladd(__vector unsigned int __a, __vector signed int __b, + __vector signed int __c) { + return (__vector signed int)__a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed int +vec_mladd(__vector signed int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __a * (__vector signed int)__b + (__vector signed int)__c; +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mladd(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __a * __b + __c; +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed long long +vec_mladd(__vector signed long long __a, __vector signed long long __b, + __vector signed long long __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_mladd(__vector unsigned long long __a, __vector signed long long __b, + __vector signed long long __c) { + return (__vector signed long long)__a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed long long +vec_mladd(__vector signed long long __a, __vector unsigned long long __b, + __vector unsigned long long __c) { + return __a * (__vector signed long long)__b + (__vector signed long long)__c; +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mladd(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned long long __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_mladd(__vector signed __int128 __a, __vector signed __int128 __b, + __vector signed __int128 __c) { + return __a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_mladd(__vector unsigned __int128 __a, __vector signed __int128 __b, + __vector signed __int128 __c) { + return (__vector signed __int128)__a * __b + __c; +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_mladd(__vector signed __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return __a * (__vector signed __int128)__b + (__vector signed __int128)__c; +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_mladd(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return __a * __b + __c; +} +#endif + +/*-- vec_mhadd --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_mhadd(__vector signed char __a, __vector signed char __b, + __vector signed char __c) { + return __builtin_s390_vmahb(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_mhadd(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __builtin_s390_vmalhb(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed short +vec_mhadd(__vector signed short __a, __vector signed short __b, + __vector signed short __c) { + return __builtin_s390_vmahh(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mhadd(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __builtin_s390_vmalhh(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed int +vec_mhadd(__vector signed int __a, __vector signed int __b, + __vector signed int __c) { + return __builtin_s390_vmahf(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mhadd(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __builtin_s390_vmalhf(__a, __b, __c); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed long long +vec_mhadd(__vector signed long long __a, __vector signed long long __b, + __vector signed long long __c) { + return __builtin_s390_vmahg(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mhadd(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned long long __c) { + return __builtin_s390_vmalhg(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_mhadd(__vector signed __int128 __a, __vector signed __int128 __b, + __vector signed __int128 __c) { + return (__vector signed __int128) + __builtin_s390_vmahq((signed __int128)__a, (signed __int128)__b, (signed __int128)__c); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_mhadd(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vmalhq((unsigned __int128)__a, (unsigned __int128)__b, (unsigned __int128)__c); +} +#endif + +/*-- vec_meadd --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_meadd(__vector signed char __a, __vector signed char __b, + __vector signed short __c) { + return __builtin_s390_vmaeb(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_meadd(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned short __c) { + return __builtin_s390_vmaleb(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed int +vec_meadd(__vector signed short __a, __vector signed short __b, + __vector signed int __c) { + return __builtin_s390_vmaeh(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_meadd(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned int __c) { + return __builtin_s390_vmaleh(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_meadd(__vector signed int __a, __vector signed int __b, + __vector signed long long __c) { + return __builtin_s390_vmaef(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_meadd(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned long long __c) { + return __builtin_s390_vmalef(__a, __b, __c); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_meadd(__vector signed long long __a, __vector signed long long __b, + __vector signed __int128 __c) { + return (__vector signed __int128) + __builtin_s390_vmaeg(__a, __b, (signed __int128)__c); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_meadd(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vmaleg(__a, __b, (unsigned __int128)__c); +} +#endif + +/*-- vec_moadd --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_moadd(__vector signed char __a, __vector signed char __b, + __vector signed short __c) { + return __builtin_s390_vmaob(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_moadd(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned short __c) { + return __builtin_s390_vmalob(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed int +vec_moadd(__vector signed short __a, __vector signed short __b, + __vector signed int __c) { + return __builtin_s390_vmaoh(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_moadd(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned int __c) { + return __builtin_s390_vmaloh(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_moadd(__vector signed int __a, __vector signed int __b, + __vector signed long long __c) { + return __builtin_s390_vmaof(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_moadd(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned long long __c) { + return __builtin_s390_vmalof(__a, __b, __c); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_moadd(__vector signed long long __a, __vector signed long long __b, + __vector signed __int128 __c) { + return (__vector signed __int128) + __builtin_s390_vmaog(__a, __b, (signed __int128)__c); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_moadd(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vmalog(__a, __b, (unsigned __int128)__c); +} +#endif + +/*-- vec_mulh ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_mulh(__vector signed char __a, __vector signed char __b) { + return __builtin_s390_vmhb(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_mulh(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vmlhb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_mulh(__vector signed short __a, __vector signed short __b) { + return __builtin_s390_vmhh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mulh(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vmlhh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_mulh(__vector signed int __a, __vector signed int __b) { + return __builtin_s390_vmhf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mulh(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vmlhf(__a, __b); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed long long +vec_mulh(__vector signed long long __a, __vector signed long long __b) { + return __builtin_s390_vmhg(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mulh(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_vmlhg(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed __int128 +vec_mulh(__vector signed __int128 __a, __vector signed __int128 __b) { + return (__vector signed __int128) + __builtin_s390_vmhq((signed __int128)__a, (signed __int128)__b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_mulh(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector unsigned __int128) + __builtin_s390_vmlhq((unsigned __int128)__a, (unsigned __int128)__b); +} +#endif + +/*-- vec_mule ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_mule(__vector signed char __a, __vector signed char __b) { + return __builtin_s390_vmeb(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mule(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vmleb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_mule(__vector signed short __a, __vector signed short __b) { + return __builtin_s390_vmeh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mule(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vmleh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_mule(__vector signed int __a, __vector signed int __b) { + return __builtin_s390_vmef(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mule(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vmlef(__a, __b); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_mule(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed __int128)__builtin_s390_vmeg(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_mule(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned __int128)__builtin_s390_vmleg(__a, __b); +} +#endif + +/*-- vec_mulo ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed short +vec_mulo(__vector signed char __a, __vector signed char __b) { + return __builtin_s390_vmob(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_mulo(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vmlob(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_mulo(__vector signed short __a, __vector signed short __b) { + return __builtin_s390_vmoh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_mulo(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vmloh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed long long +vec_mulo(__vector signed int __a, __vector signed int __b) { + return __builtin_s390_vmof(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_mulo(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vmlof(__a, __b); +} + +#if __ARCH__ >= 15 +static inline __ATTRS_o_ai __vector signed __int128 +vec_mulo(__vector signed long long __a, __vector signed long long __b) { + return (__vector signed __int128)__builtin_s390_vmog(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_mulo(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned __int128)__builtin_s390_vmlog(__a, __b); +} +#endif + +/*-- vec_msum ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +extern __ATTRS_o __vector unsigned __int128 +vec_msum(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned __int128 __c, int __d) + __constant_range(__d, 0, 15); + +#define vec_msum(X, Y, Z, W) \ + ((__typeof__((vec_msum)((X), (Y), (Z), (W)))) \ + __builtin_s390_vmslg((X), (Y), (unsigned __int128)(Z), (W))) +#endif + +/*-- vec_msum_u128 ----------------------------------------------------------*/ + +#if __ARCH__ >= 12 +// This prototype is deprecated. +extern __ATTRS_o __vector unsigned char +vec_msum_u128(__vector unsigned long long __a, __vector unsigned long long __b, + __vector unsigned char __c, int __d) + __constant_range(__d, 0, 15); + +#define vec_msum_u128(X, Y, Z, W) \ + ((__typeof__((vec_msum_u128)((X), (Y), (Z), (W)))) \ + (__vector unsigned __int128) \ + __builtin_s390_vmslg((X), (Y), (unsigned __int128)(Z), (W))) +#endif + +/*-- vec_sub_u128 -----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_sub_u128(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector unsigned char)(__vector unsigned __int128) + ((__int128)__a - (__int128)__b); +} + +/*-- vec_subc ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_subc(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vscbib(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_subc(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vscbih(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_subc(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vscbif(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_subc(__vector unsigned long long __a, __vector unsigned long long __b) { + return __builtin_s390_vscbig(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_subc(__vector unsigned __int128 __a, __vector unsigned __int128 __b) { + return (__vector unsigned __int128) + __builtin_s390_vscbiq((unsigned __int128)__a, (unsigned __int128)__b); +} + +/*-- vec_subc_u128 ----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_subc_u128(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vscbiq((unsigned __int128)__a, (unsigned __int128)__b); +} + +/*-- vec_sube ---------------------------------------------------------------*/ + +static inline __ATTRS_ai __vector unsigned __int128 +vec_sube(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vsbiq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_sube_u128 ----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_sube_u128(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vsbiq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_subec --------------------------------------------------------------*/ + +static inline __ATTRS_ai __vector unsigned __int128 +vec_subec(__vector unsigned __int128 __a, __vector unsigned __int128 __b, + __vector unsigned __int128 __c) { + return (__vector unsigned __int128) + __builtin_s390_vsbcbiq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_subec_u128 ---------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector unsigned char +vec_subec_u128(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vsbcbiq((unsigned __int128)__a, (unsigned __int128)__b, + (unsigned __int128)__c); +} + +/*-- vec_sum2 ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned long long +vec_sum2(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vsumgh(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned long long +vec_sum2(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vsumgf(__a, __b); +} + +/*-- vec_sum ----------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_sum(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned __int128)__builtin_s390_vsumqf(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned __int128 +vec_sum(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned __int128)__builtin_s390_vsumqg(__a, __b); +} + +/*-- vec_sum_u128 -----------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_sum_u128(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vsumqf(__a, __b); +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned char +vec_sum_u128(__vector unsigned long long __a, __vector unsigned long long __b) { + return (__vector unsigned char)(__vector unsigned __int128) + __builtin_s390_vsumqg(__a, __b); +} + +/*-- vec_sum4 ---------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned int +vec_sum4(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vsumb(__a, __b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_sum4(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vsumh(__a, __b); +} + +/*-- vec_test_mask ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai int +vec_test_mask(__vector signed char __a, __vector unsigned char __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vtm(__a, __b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector signed short __a, __vector unsigned short __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector signed int __a, __vector unsigned int __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector signed long long __a, __vector unsigned long long __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector unsigned long long __a, + __vector unsigned long long __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector signed __int128 __a, __vector unsigned __int128 __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai int +vec_test_mask(__vector unsigned __int128 __a, + __vector unsigned __int128 __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai int +vec_test_mask(__vector float __a, __vector unsigned int __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} +#endif + +static inline __ATTRS_o_ai int +vec_test_mask(__vector double __a, __vector unsigned long long __b) { + return __builtin_s390_vtm((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +/*-- vec_madd ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_madd(__vector float __a, __vector float __b, __vector float __c) { + return __builtin_s390_vfmasb(__a, __b, __c); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_madd(__vector double __a, __vector double __b, __vector double __c) { + return __builtin_s390_vfmadb(__a, __b, __c); +} + +/*-- vec_msub ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_msub(__vector float __a, __vector float __b, __vector float __c) { + return __builtin_s390_vfmssb(__a, __b, __c); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_msub(__vector double __a, __vector double __b, __vector double __c) { + return __builtin_s390_vfmsdb(__a, __b, __c); +} + +/*-- vec_nmadd ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_nmadd(__vector float __a, __vector float __b, __vector float __c) { + return __builtin_s390_vfnmasb(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector double +vec_nmadd(__vector double __a, __vector double __b, __vector double __c) { + return __builtin_s390_vfnmadb(__a, __b, __c); +} +#endif + +/*-- vec_nmsub ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_nmsub(__vector float __a, __vector float __b, __vector float __c) { + return __builtin_s390_vfnmssb(__a, __b, __c); +} + +static inline __ATTRS_o_ai __vector double +vec_nmsub(__vector double __a, __vector double __b, __vector double __c) { + return __builtin_s390_vfnmsdb(__a, __b, __c); +} +#endif + +/*-- vec_sqrt ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_sqrt(__vector float __a) { + return __builtin_s390_vfsqsb(__a); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_sqrt(__vector double __a) { + return __builtin_s390_vfsqdb(__a); +} + +/*-- vec_ld2f ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai __vector double +vec_ld2f(const float *__ptr) { + typedef float __v2f32 __attribute__((__vector_size__(8))); + return __builtin_convertvector(*(const __v2f32 *)__ptr, __vector double); +} + +/*-- vec_st2f ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_ai void +vec_st2f(__vector double __a, float *__ptr) { + typedef float __v2f32 __attribute__((__vector_size__(8))); + *(__v2f32 *)__ptr = __builtin_convertvector(__a, __v2f32); +} + +/*-- vec_ctd ----------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_ctd(__vector signed long long __a, int __b) + __constant_range(__b, 0, 31) { + __vector double __conv = __builtin_convertvector(__a, __vector double); + __conv *= ((__vector double)(__vector unsigned long long) + ((0x3ffULL - __b) << 52)); + return __conv; +} + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector double +vec_ctd(__vector unsigned long long __a, int __b) + __constant_range(__b, 0, 31) { + __vector double __conv = __builtin_convertvector(__a, __vector double); + __conv *= ((__vector double)(__vector unsigned long long) + ((0x3ffULL - __b) << 52)); + return __conv; +} + +/*-- vec_ctsl ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector signed long long +vec_ctsl(__vector double __a, int __b) + __constant_range(__b, 0, 31) { + __a *= ((__vector double)(__vector unsigned long long) + ((0x3ffULL + __b) << 52)); + return __builtin_convertvector(__a, __vector signed long long); +} + +/*-- vec_ctul ---------------------------------------------------------------*/ + +// This prototype is deprecated. +static inline __ATTRS_o_ai __vector unsigned long long +vec_ctul(__vector double __a, int __b) + __constant_range(__b, 0, 31) { + __a *= ((__vector double)(__vector unsigned long long) + ((0x3ffULL + __b) << 52)); + return __builtin_convertvector(__a, __vector unsigned long long); +} + +/*-- vec_doublee ------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_ai __vector double +vec_doublee(__vector float __a) { + typedef float __v2f32 __attribute__((__vector_size__(8))); + __v2f32 __pack = __builtin_shufflevector(__a, __a, 0, 2); + return __builtin_convertvector(__pack, __vector double); +} +#endif + +/*-- vec_floate -------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_ai __vector float +vec_floate(__vector double __a) { + typedef float __v2f32 __attribute__((__vector_size__(8))); + __v2f32 __pack = __builtin_convertvector(__a, __v2f32); + return __builtin_shufflevector(__pack, __pack, 0, -1, 1, -1); +} +#endif + +/*-- vec_double -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector double +vec_double(__vector signed long long __a) { + return __builtin_convertvector(__a, __vector double); +} + +static inline __ATTRS_o_ai __vector double +vec_double(__vector unsigned long long __a) { + return __builtin_convertvector(__a, __vector double); +} + +/*-- vec_float --------------------------------------------------------------*/ + +#if __ARCH__ >= 13 + +static inline __ATTRS_o_ai __vector float +vec_float(__vector signed int __a) { + return __builtin_convertvector(__a, __vector float); +} + +static inline __ATTRS_o_ai __vector float +vec_float(__vector unsigned int __a) { + return __builtin_convertvector(__a, __vector float); +} + +#endif + +/*-- vec_signed -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed long long +vec_signed(__vector double __a) { + return __builtin_convertvector(__a, __vector signed long long); +} + +#if __ARCH__ >= 13 +static inline __ATTRS_o_ai __vector signed int +vec_signed(__vector float __a) { + return __builtin_convertvector(__a, __vector signed int); +} +#endif + +/*-- vec_unsigned -----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned long long +vec_unsigned(__vector double __a) { + return __builtin_convertvector(__a, __vector unsigned long long); +} + +#if __ARCH__ >= 13 +static inline __ATTRS_o_ai __vector unsigned int +vec_unsigned(__vector float __a) { + return __builtin_convertvector(__a, __vector unsigned int); +} +#endif + +/*-- vec_roundp -------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_roundp(__vector float __a) { + return __builtin_s390_vfisb(__a, 4, 6); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_roundp(__vector double __a) { + return __builtin_s390_vfidb(__a, 4, 6); +} + +/*-- vec_ceil ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_ceil(__vector float __a) { + // On this platform, vec_ceil never triggers the IEEE-inexact exception. + return __builtin_s390_vfisb(__a, 4, 6); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_ceil(__vector double __a) { + // On this platform, vec_ceil never triggers the IEEE-inexact exception. + return __builtin_s390_vfidb(__a, 4, 6); +} + +/*-- vec_roundm -------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_roundm(__vector float __a) { + return __builtin_s390_vfisb(__a, 4, 7); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_roundm(__vector double __a) { + return __builtin_s390_vfidb(__a, 4, 7); +} + +/*-- vec_floor --------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_floor(__vector float __a) { + // On this platform, vec_floor never triggers the IEEE-inexact exception. + return __builtin_s390_vfisb(__a, 4, 7); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_floor(__vector double __a) { + // On this platform, vec_floor never triggers the IEEE-inexact exception. + return __builtin_s390_vfidb(__a, 4, 7); +} + +/*-- vec_roundz -------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_roundz(__vector float __a) { + return __builtin_s390_vfisb(__a, 4, 5); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_roundz(__vector double __a) { + return __builtin_s390_vfidb(__a, 4, 5); +} + +/*-- vec_trunc --------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_trunc(__vector float __a) { + // On this platform, vec_trunc never triggers the IEEE-inexact exception. + return __builtin_s390_vfisb(__a, 4, 5); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_trunc(__vector double __a) { + // On this platform, vec_trunc never triggers the IEEE-inexact exception. + return __builtin_s390_vfidb(__a, 4, 5); +} + +/*-- vec_roundc -------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_roundc(__vector float __a) { + return __builtin_s390_vfisb(__a, 4, 0); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_roundc(__vector double __a) { + return __builtin_s390_vfidb(__a, 4, 0); +} + +/*-- vec_rint ---------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_rint(__vector float __a) { + // vec_rint may trigger the IEEE-inexact exception. + return __builtin_s390_vfisb(__a, 0, 0); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_rint(__vector double __a) { + // vec_rint may trigger the IEEE-inexact exception. + return __builtin_s390_vfidb(__a, 0, 0); +} + +/*-- vec_round --------------------------------------------------------------*/ + +#if __ARCH__ >= 12 +static inline __ATTRS_o_ai __vector float +vec_round(__vector float __a) { + return __builtin_s390_vfisb(__a, 4, 4); +} +#endif + +static inline __ATTRS_o_ai __vector double +vec_round(__vector double __a) { + return __builtin_s390_vfidb(__a, 4, 4); +} + +/*-- vec_fp_test_data_class -------------------------------------------------*/ + +#if __ARCH__ >= 12 +extern __ATTRS_o __vector __bool int +vec_fp_test_data_class(__vector float __a, int __b, int *__c) + __constant_range(__b, 0, 4095); + +extern __ATTRS_o __vector __bool long long +vec_fp_test_data_class(__vector double __a, int __b, int *__c) + __constant_range(__b, 0, 4095); + +#define vec_fp_test_data_class(X, Y, Z) \ + ((__typeof__((vec_fp_test_data_class)((X), (Y), (Z)))) \ + __extension__ ({ \ + __vector unsigned char __res; \ + __vector unsigned char __x = (__vector unsigned char)(X); \ + int *__z = (Z); \ + switch (sizeof ((X)[0])) { \ + case 4: __res = (__vector unsigned char) \ + __builtin_s390_vftcisb((__vector float)__x, (Y), __z); \ + break; \ + default: __res = (__vector unsigned char) \ + __builtin_s390_vftcidb((__vector double)__x, (Y), __z); \ + break; \ + } __res; })) +#else +#define vec_fp_test_data_class(X, Y, Z) \ + ((__vector __bool long long)__builtin_s390_vftcidb((X), (Y), (Z))) +#endif + +#define __VEC_CLASS_FP_ZERO_P (1 << 11) +#define __VEC_CLASS_FP_ZERO_N (1 << 10) +#define __VEC_CLASS_FP_ZERO (__VEC_CLASS_FP_ZERO_P | __VEC_CLASS_FP_ZERO_N) +#define __VEC_CLASS_FP_NORMAL_P (1 << 9) +#define __VEC_CLASS_FP_NORMAL_N (1 << 8) +#define __VEC_CLASS_FP_NORMAL (__VEC_CLASS_FP_NORMAL_P | \ + __VEC_CLASS_FP_NORMAL_N) +#define __VEC_CLASS_FP_SUBNORMAL_P (1 << 7) +#define __VEC_CLASS_FP_SUBNORMAL_N (1 << 6) +#define __VEC_CLASS_FP_SUBNORMAL (__VEC_CLASS_FP_SUBNORMAL_P | \ + __VEC_CLASS_FP_SUBNORMAL_N) +#define __VEC_CLASS_FP_INFINITY_P (1 << 5) +#define __VEC_CLASS_FP_INFINITY_N (1 << 4) +#define __VEC_CLASS_FP_INFINITY (__VEC_CLASS_FP_INFINITY_P | \ + __VEC_CLASS_FP_INFINITY_N) +#define __VEC_CLASS_FP_QNAN_P (1 << 3) +#define __VEC_CLASS_FP_QNAN_N (1 << 2) +#define __VEC_CLASS_FP_QNAN (__VEC_CLASS_FP_QNAN_P | __VEC_CLASS_FP_QNAN_N) +#define __VEC_CLASS_FP_SNAN_P (1 << 1) +#define __VEC_CLASS_FP_SNAN_N (1 << 0) +#define __VEC_CLASS_FP_SNAN (__VEC_CLASS_FP_SNAN_P | __VEC_CLASS_FP_SNAN_N) +#define __VEC_CLASS_FP_NAN (__VEC_CLASS_FP_QNAN | __VEC_CLASS_FP_SNAN) +#define __VEC_CLASS_FP_NOT_NORMAL (__VEC_CLASS_FP_NAN | \ + __VEC_CLASS_FP_SUBNORMAL | \ + __VEC_CLASS_FP_ZERO | \ + __VEC_CLASS_FP_INFINITY) + +/*-- vec_extend_to_fp32_hi --------------------------------------------------*/ + +#if __ARCH__ >= 14 +#define vec_extend_to_fp32_hi(X, W) \ + ((__vector float)__builtin_s390_vclfnhs((X), (W))); +#endif + +/*-- vec_extend_to_fp32_hi --------------------------------------------------*/ + +#if __ARCH__ >= 14 +#define vec_extend_to_fp32_lo(X, W) \ + ((__vector float)__builtin_s390_vclfnls((X), (W))); +#endif + +/*-- vec_round_from_fp32 ----------------------------------------------------*/ + +#if __ARCH__ >= 14 +#define vec_round_from_fp32(X, Y, W) \ + ((__vector unsigned short)__builtin_s390_vcrnfs((X), (Y), (W))); +#endif + +/*-- vec_convert_to_fp16 ----------------------------------------------------*/ + +#if __ARCH__ >= 14 +#define vec_convert_to_fp16(X, W) \ + ((__vector unsigned short)__builtin_s390_vcfn((X), (W))); +#endif + +/*-- vec_convert_from_fp16 --------------------------------------------------*/ + +#if __ARCH__ >= 14 +#define vec_convert_from_fp16(X, W) \ + ((__vector unsigned short)__builtin_s390_vcnf((X), (W))); +#endif + +/*-- vec_cp_until_zero ------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cp_until_zero(__vector signed char __a) { + return ((__vector signed char) + __builtin_s390_vistrb((__vector unsigned char)__a)); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cp_until_zero(__vector __bool char __a) { + return ((__vector __bool char) + __builtin_s390_vistrb((__vector unsigned char)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cp_until_zero(__vector unsigned char __a) { + return __builtin_s390_vistrb(__a); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cp_until_zero(__vector signed short __a) { + return ((__vector signed short) + __builtin_s390_vistrh((__vector unsigned short)__a)); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cp_until_zero(__vector __bool short __a) { + return ((__vector __bool short) + __builtin_s390_vistrh((__vector unsigned short)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cp_until_zero(__vector unsigned short __a) { + return __builtin_s390_vistrh(__a); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cp_until_zero(__vector signed int __a) { + return ((__vector signed int) + __builtin_s390_vistrf((__vector unsigned int)__a)); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cp_until_zero(__vector __bool int __a) { + return ((__vector __bool int) + __builtin_s390_vistrf((__vector unsigned int)__a)); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cp_until_zero(__vector unsigned int __a) { + return __builtin_s390_vistrf(__a); +} + +/*-- vec_cp_until_zero_cc ---------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cp_until_zero_cc(__vector signed char __a, int *__cc) { + return (__vector signed char) + __builtin_s390_vistrbs((__vector unsigned char)__a, __cc); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_cp_until_zero_cc(__vector __bool char __a, int *__cc) { + return (__vector __bool char) + __builtin_s390_vistrbs((__vector unsigned char)__a, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cp_until_zero_cc(__vector unsigned char __a, int *__cc) { + return __builtin_s390_vistrbs(__a, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cp_until_zero_cc(__vector signed short __a, int *__cc) { + return (__vector signed short) + __builtin_s390_vistrhs((__vector unsigned short)__a, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cp_until_zero_cc(__vector __bool short __a, int *__cc) { + return (__vector __bool short) + __builtin_s390_vistrhs((__vector unsigned short)__a, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cp_until_zero_cc(__vector unsigned short __a, int *__cc) { + return __builtin_s390_vistrhs(__a, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cp_until_zero_cc(__vector signed int __a, int *__cc) { + return (__vector signed int) + __builtin_s390_vistrfs((__vector unsigned int)__a, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cp_until_zero_cc(__vector __bool int __a, int *__cc) { + return (__vector __bool int) + __builtin_s390_vistrfs((__vector unsigned int)__a, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cp_until_zero_cc(__vector unsigned int __a, int *__cc) { + return __builtin_s390_vistrfs(__a, __cc); +} + +/*-- vec_cmpeq_idx ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpeq_idx(__vector signed char __a, __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfeeb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_idx(__vector __bool char __a, __vector __bool char __b) { + return __builtin_s390_vfeeb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_idx(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vfeeb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpeq_idx(__vector signed short __a, __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfeeh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_idx(__vector __bool short __a, __vector __bool short __b) { + return __builtin_s390_vfeeh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_idx(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vfeeh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpeq_idx(__vector signed int __a, __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfeef((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_idx(__vector __bool int __a, __vector __bool int __b) { + return __builtin_s390_vfeef((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_idx(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vfeef(__a, __b); +} + +/*-- vec_cmpeq_idx_cc -------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpeq_idx_cc(__vector signed char __a, __vector signed char __b, int *__cc) { + return (__vector signed char) + __builtin_s390_vfeebs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_idx_cc(__vector __bool char __a, __vector __bool char __b, int *__cc) { + return __builtin_s390_vfeebs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + int *__cc) { + return __builtin_s390_vfeebs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpeq_idx_cc(__vector signed short __a, __vector signed short __b, + int *__cc) { + return (__vector signed short) + __builtin_s390_vfeehs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_idx_cc(__vector __bool short __a, __vector __bool short __b, int *__cc) { + return __builtin_s390_vfeehs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return __builtin_s390_vfeehs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpeq_idx_cc(__vector signed int __a, __vector signed int __b, int *__cc) { + return (__vector signed int) + __builtin_s390_vfeefs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_idx_cc(__vector __bool int __a, __vector __bool int __b, int *__cc) { + return __builtin_s390_vfeefs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + int *__cc) { + return __builtin_s390_vfeefs(__a, __b, __cc); +} + +/*-- vec_cmpeq_or_0_idx -----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpeq_or_0_idx(__vector signed char __a, __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfeezb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_or_0_idx(__vector __bool char __a, __vector __bool char __b) { + return __builtin_s390_vfeezb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_or_0_idx(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vfeezb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpeq_or_0_idx(__vector signed short __a, __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfeezh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_or_0_idx(__vector __bool short __a, __vector __bool short __b) { + return __builtin_s390_vfeezh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_or_0_idx(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vfeezh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpeq_or_0_idx(__vector signed int __a, __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfeezf((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_or_0_idx(__vector __bool int __a, __vector __bool int __b) { + return __builtin_s390_vfeezf((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_or_0_idx(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vfeezf(__a, __b); +} + +/*-- vec_cmpeq_or_0_idx_cc --------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpeq_or_0_idx_cc(__vector signed char __a, __vector signed char __b, + int *__cc) { + return (__vector signed char) + __builtin_s390_vfeezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_or_0_idx_cc(__vector __bool char __a, __vector __bool char __b, + int *__cc) { + return __builtin_s390_vfeezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpeq_or_0_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + int *__cc) { + return __builtin_s390_vfeezbs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpeq_or_0_idx_cc(__vector signed short __a, __vector signed short __b, + int *__cc) { + return (__vector signed short) + __builtin_s390_vfeezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_or_0_idx_cc(__vector __bool short __a, __vector __bool short __b, + int *__cc) { + return __builtin_s390_vfeezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpeq_or_0_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return __builtin_s390_vfeezhs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpeq_or_0_idx_cc(__vector signed int __a, __vector signed int __b, + int *__cc) { + return (__vector signed int) + __builtin_s390_vfeezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_or_0_idx_cc(__vector __bool int __a, __vector __bool int __b, + int *__cc) { + return __builtin_s390_vfeezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpeq_or_0_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + int *__cc) { + return __builtin_s390_vfeezfs(__a, __b, __cc); +} + +/*-- vec_cmpne_idx ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpne_idx(__vector signed char __a, __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfeneb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_idx(__vector __bool char __a, __vector __bool char __b) { + return __builtin_s390_vfeneb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_idx(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vfeneb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpne_idx(__vector signed short __a, __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfeneh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_idx(__vector __bool short __a, __vector __bool short __b) { + return __builtin_s390_vfeneh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_idx(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vfeneh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpne_idx(__vector signed int __a, __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfenef((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_idx(__vector __bool int __a, __vector __bool int __b) { + return __builtin_s390_vfenef((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_idx(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vfenef(__a, __b); +} + +/*-- vec_cmpne_idx_cc -------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpne_idx_cc(__vector signed char __a, __vector signed char __b, int *__cc) { + return (__vector signed char) + __builtin_s390_vfenebs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_idx_cc(__vector __bool char __a, __vector __bool char __b, int *__cc) { + return __builtin_s390_vfenebs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + int *__cc) { + return __builtin_s390_vfenebs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpne_idx_cc(__vector signed short __a, __vector signed short __b, + int *__cc) { + return (__vector signed short) + __builtin_s390_vfenehs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_idx_cc(__vector __bool short __a, __vector __bool short __b, + int *__cc) { + return __builtin_s390_vfenehs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return __builtin_s390_vfenehs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpne_idx_cc(__vector signed int __a, __vector signed int __b, int *__cc) { + return (__vector signed int) + __builtin_s390_vfenefs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_idx_cc(__vector __bool int __a, __vector __bool int __b, int *__cc) { + return __builtin_s390_vfenefs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + int *__cc) { + return __builtin_s390_vfenefs(__a, __b, __cc); +} + +/*-- vec_cmpne_or_0_idx -----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpne_or_0_idx(__vector signed char __a, __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfenezb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_or_0_idx(__vector __bool char __a, __vector __bool char __b) { + return __builtin_s390_vfenezb((__vector unsigned char)__a, + (__vector unsigned char)__b); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_or_0_idx(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vfenezb(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpne_or_0_idx(__vector signed short __a, __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfenezh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_or_0_idx(__vector __bool short __a, __vector __bool short __b) { + return __builtin_s390_vfenezh((__vector unsigned short)__a, + (__vector unsigned short)__b); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_or_0_idx(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vfenezh(__a, __b); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpne_or_0_idx(__vector signed int __a, __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfenezf((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_or_0_idx(__vector __bool int __a, __vector __bool int __b) { + return __builtin_s390_vfenezf((__vector unsigned int)__a, + (__vector unsigned int)__b); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_or_0_idx(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vfenezf(__a, __b); +} + +/*-- vec_cmpne_or_0_idx_cc --------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_cmpne_or_0_idx_cc(__vector signed char __a, __vector signed char __b, + int *__cc) { + return (__vector signed char) + __builtin_s390_vfenezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_or_0_idx_cc(__vector __bool char __a, __vector __bool char __b, + int *__cc) { + return __builtin_s390_vfenezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpne_or_0_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + int *__cc) { + return __builtin_s390_vfenezbs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_cmpne_or_0_idx_cc(__vector signed short __a, __vector signed short __b, + int *__cc) { + return (__vector signed short) + __builtin_s390_vfenezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_or_0_idx_cc(__vector __bool short __a, __vector __bool short __b, + int *__cc) { + return __builtin_s390_vfenezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpne_or_0_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return __builtin_s390_vfenezhs(__a, __b, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_cmpne_or_0_idx_cc(__vector signed int __a, __vector signed int __b, + int *__cc) { + return (__vector signed int) + __builtin_s390_vfenezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_or_0_idx_cc(__vector __bool int __a, __vector __bool int __b, + int *__cc) { + return __builtin_s390_vfenezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpne_or_0_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + int *__cc) { + return __builtin_s390_vfenezfs(__a, __b, __cc); +} + +/*-- vec_cmprg --------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmprg(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector __bool char)__builtin_s390_vstrcb(__a, __b, __c, 4); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmprg(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return (__vector __bool short)__builtin_s390_vstrch(__a, __b, __c, 4); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmprg(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return (__vector __bool int)__builtin_s390_vstrcf(__a, __b, __c, 4); +} + +/*-- vec_cmprg_cc -----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmprg_cc(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return (__vector __bool char)__builtin_s390_vstrcbs(__a, __b, __c, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmprg_cc(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c, int *__cc) { + return (__vector __bool short)__builtin_s390_vstrchs(__a, __b, __c, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmprg_cc(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c, int *__cc) { + return (__vector __bool int)__builtin_s390_vstrcfs(__a, __b, __c, 4, __cc); +} + +/*-- vec_cmprg_idx ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmprg_idx(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __builtin_s390_vstrcb(__a, __b, __c, 0); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmprg_idx(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __builtin_s390_vstrch(__a, __b, __c, 0); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmprg_idx(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __builtin_s390_vstrcf(__a, __b, __c, 0); +} + +/*-- vec_cmprg_idx_cc -------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmprg_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrcbs(__a, __b, __c, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmprg_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c, int *__cc) { + return __builtin_s390_vstrchs(__a, __b, __c, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmprg_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c, int *__cc) { + return __builtin_s390_vstrcfs(__a, __b, __c, 0, __cc); +} + +/*-- vec_cmprg_or_0_idx -----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmprg_or_0_idx(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __builtin_s390_vstrczb(__a, __b, __c, 0); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmprg_or_0_idx(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __builtin_s390_vstrczh(__a, __b, __c, 0); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmprg_or_0_idx(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __builtin_s390_vstrczf(__a, __b, __c, 0); +} + +/*-- vec_cmprg_or_0_idx_cc --------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmprg_or_0_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrczbs(__a, __b, __c, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmprg_or_0_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c, int *__cc) { + return __builtin_s390_vstrczhs(__a, __b, __c, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmprg_or_0_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c, int *__cc) { + return __builtin_s390_vstrczfs(__a, __b, __c, 0, __cc); +} + +/*-- vec_cmpnrg -------------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpnrg(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return (__vector __bool char)__builtin_s390_vstrcb(__a, __b, __c, 12); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpnrg(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return (__vector __bool short)__builtin_s390_vstrch(__a, __b, __c, 12); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpnrg(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return (__vector __bool int)__builtin_s390_vstrcf(__a, __b, __c, 12); +} + +/*-- vec_cmpnrg_cc ----------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_cmpnrg_cc(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return (__vector __bool char) + __builtin_s390_vstrcbs(__a, __b, __c, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_cmpnrg_cc(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c, int *__cc) { + return (__vector __bool short) + __builtin_s390_vstrchs(__a, __b, __c, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_cmpnrg_cc(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c, int *__cc) { + return (__vector __bool int) + __builtin_s390_vstrcfs(__a, __b, __c, 12, __cc); +} + +/*-- vec_cmpnrg_idx ---------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpnrg_idx(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __builtin_s390_vstrcb(__a, __b, __c, 8); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpnrg_idx(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __builtin_s390_vstrch(__a, __b, __c, 8); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpnrg_idx(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __builtin_s390_vstrcf(__a, __b, __c, 8); +} + +/*-- vec_cmpnrg_idx_cc ------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpnrg_idx_cc(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrcbs(__a, __b, __c, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpnrg_idx_cc(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c, int *__cc) { + return __builtin_s390_vstrchs(__a, __b, __c, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpnrg_idx_cc(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c, int *__cc) { + return __builtin_s390_vstrcfs(__a, __b, __c, 8, __cc); +} + +/*-- vec_cmpnrg_or_0_idx ----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpnrg_or_0_idx(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c) { + return __builtin_s390_vstrczb(__a, __b, __c, 8); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpnrg_or_0_idx(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned short __c) { + return __builtin_s390_vstrczh(__a, __b, __c, 8); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpnrg_or_0_idx(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned int __c) { + return __builtin_s390_vstrczf(__a, __b, __c, 8); +} + +/*-- vec_cmpnrg_or_0_idx_cc -------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector unsigned char +vec_cmpnrg_or_0_idx_cc(__vector unsigned char __a, + __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrczbs(__a, __b, __c, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_cmpnrg_or_0_idx_cc(__vector unsigned short __a, + __vector unsigned short __b, + __vector unsigned short __c, int *__cc) { + return __builtin_s390_vstrczhs(__a, __b, __c, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_cmpnrg_or_0_idx_cc(__vector unsigned int __a, + __vector unsigned int __b, + __vector unsigned int __c, int *__cc) { + return __builtin_s390_vstrczfs(__a, __b, __c, 8, __cc); +} + +/*-- vec_find_any_eq --------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_eq(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char) + __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 4); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_eq(__vector __bool char __a, __vector __bool char __b) { + return (__vector __bool char) + __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 4); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_eq(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)__builtin_s390_vfaeb(__a, __b, 4); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_eq(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short) + __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 4); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_eq(__vector __bool short __a, __vector __bool short __b) { + return (__vector __bool short) + __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 4); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_eq(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)__builtin_s390_vfaeh(__a, __b, 4); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_eq(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int) + __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 4); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_eq(__vector __bool int __a, __vector __bool int __b) { + return (__vector __bool int) + __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 4); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_eq(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)__builtin_s390_vfaef(__a, __b, 4); +} + +/*-- vec_find_any_eq_cc -----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_eq_cc(__vector signed char __a, __vector signed char __b, + int *__cc) { + return (__vector __bool char) + __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_eq_cc(__vector __bool char __a, __vector __bool char __b, + int *__cc) { + return (__vector __bool char) + __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_eq_cc(__vector unsigned char __a, __vector unsigned char __b, + int *__cc) { + return (__vector __bool char)__builtin_s390_vfaebs(__a, __b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_eq_cc(__vector signed short __a, __vector signed short __b, + int *__cc) { + return (__vector __bool short) + __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_eq_cc(__vector __bool short __a, __vector __bool short __b, + int *__cc) { + return (__vector __bool short) + __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_eq_cc(__vector unsigned short __a, __vector unsigned short __b, + int *__cc) { + return (__vector __bool short)__builtin_s390_vfaehs(__a, __b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_eq_cc(__vector signed int __a, __vector signed int __b, + int *__cc) { + return (__vector __bool int) + __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_eq_cc(__vector __bool int __a, __vector __bool int __b, + int *__cc) { + return (__vector __bool int) + __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 4, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_eq_cc(__vector unsigned int __a, __vector unsigned int __b, + int *__cc) { + return (__vector __bool int)__builtin_s390_vfaefs(__a, __b, 4, __cc); +} + +/*-- vec_find_any_eq_idx ----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_eq_idx(__vector signed char __a, __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_idx(__vector __bool char __a, __vector __bool char __b) { + return __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_idx(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vfaeb(__a, __b, 0); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_eq_idx(__vector signed short __a, __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_idx(__vector __bool short __a, __vector __bool short __b) { + return __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_idx(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vfaeh(__a, __b, 0); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_eq_idx(__vector signed int __a, __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_idx(__vector __bool int __a, __vector __bool int __b) { + return __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_idx(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vfaef(__a, __b, 0); +} + +/*-- vec_find_any_eq_idx_cc -------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_eq_idx_cc(__vector signed char __a, + __vector signed char __b, int *__cc) { + return (__vector signed char) + __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_idx_cc(__vector __bool char __a, + __vector __bool char __b, int *__cc) { + return __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_idx_cc(__vector unsigned char __a, + __vector unsigned char __b, int *__cc) { + return __builtin_s390_vfaebs(__a, __b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_eq_idx_cc(__vector signed short __a, + __vector signed short __b, int *__cc) { + return (__vector signed short) + __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_idx_cc(__vector __bool short __a, + __vector __bool short __b, int *__cc) { + return __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_idx_cc(__vector unsigned short __a, + __vector unsigned short __b, int *__cc) { + return __builtin_s390_vfaehs(__a, __b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_eq_idx_cc(__vector signed int __a, + __vector signed int __b, int *__cc) { + return (__vector signed int) + __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_idx_cc(__vector __bool int __a, + __vector __bool int __b, int *__cc) { + return __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_idx_cc(__vector unsigned int __a, + __vector unsigned int __b, int *__cc) { + return __builtin_s390_vfaefs(__a, __b, 0, __cc); +} + +/*-- vec_find_any_eq_or_0_idx -----------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_eq_or_0_idx(__vector signed char __a, + __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfaezb((__vector unsigned char)__a, + (__vector unsigned char)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_or_0_idx(__vector __bool char __a, + __vector __bool char __b) { + return __builtin_s390_vfaezb((__vector unsigned char)__a, + (__vector unsigned char)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_or_0_idx(__vector unsigned char __a, + __vector unsigned char __b) { + return __builtin_s390_vfaezb(__a, __b, 0); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_eq_or_0_idx(__vector signed short __a, + __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfaezh((__vector unsigned short)__a, + (__vector unsigned short)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_or_0_idx(__vector __bool short __a, + __vector __bool short __b) { + return __builtin_s390_vfaezh((__vector unsigned short)__a, + (__vector unsigned short)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_or_0_idx(__vector unsigned short __a, + __vector unsigned short __b) { + return __builtin_s390_vfaezh(__a, __b, 0); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_eq_or_0_idx(__vector signed int __a, + __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfaezf((__vector unsigned int)__a, + (__vector unsigned int)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_or_0_idx(__vector __bool int __a, + __vector __bool int __b) { + return __builtin_s390_vfaezf((__vector unsigned int)__a, + (__vector unsigned int)__b, 0); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_or_0_idx(__vector unsigned int __a, + __vector unsigned int __b) { + return __builtin_s390_vfaezf(__a, __b, 0); +} + +/*-- vec_find_any_eq_or_0_idx_cc --------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_eq_or_0_idx_cc(__vector signed char __a, + __vector signed char __b, int *__cc) { + return (__vector signed char) + __builtin_s390_vfaezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_or_0_idx_cc(__vector __bool char __a, + __vector __bool char __b, int *__cc) { + return __builtin_s390_vfaezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_eq_or_0_idx_cc(__vector unsigned char __a, + __vector unsigned char __b, int *__cc) { + return __builtin_s390_vfaezbs(__a, __b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_eq_or_0_idx_cc(__vector signed short __a, + __vector signed short __b, int *__cc) { + return (__vector signed short) + __builtin_s390_vfaezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_or_0_idx_cc(__vector __bool short __a, + __vector __bool short __b, int *__cc) { + return __builtin_s390_vfaezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_eq_or_0_idx_cc(__vector unsigned short __a, + __vector unsigned short __b, int *__cc) { + return __builtin_s390_vfaezhs(__a, __b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_eq_or_0_idx_cc(__vector signed int __a, + __vector signed int __b, int *__cc) { + return (__vector signed int) + __builtin_s390_vfaezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_or_0_idx_cc(__vector __bool int __a, + __vector __bool int __b, int *__cc) { + return __builtin_s390_vfaezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, 0, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_eq_or_0_idx_cc(__vector unsigned int __a, + __vector unsigned int __b, int *__cc) { + return __builtin_s390_vfaezfs(__a, __b, 0, __cc); +} + +/*-- vec_find_any_ne --------------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_ne(__vector signed char __a, __vector signed char __b) { + return (__vector __bool char) + __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 12); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_ne(__vector __bool char __a, __vector __bool char __b) { + return (__vector __bool char) + __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 12); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_ne(__vector unsigned char __a, __vector unsigned char __b) { + return (__vector __bool char)__builtin_s390_vfaeb(__a, __b, 12); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_ne(__vector signed short __a, __vector signed short __b) { + return (__vector __bool short) + __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 12); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_ne(__vector __bool short __a, __vector __bool short __b) { + return (__vector __bool short) + __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 12); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_ne(__vector unsigned short __a, __vector unsigned short __b) { + return (__vector __bool short)__builtin_s390_vfaeh(__a, __b, 12); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_ne(__vector signed int __a, __vector signed int __b) { + return (__vector __bool int) + __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 12); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_ne(__vector __bool int __a, __vector __bool int __b) { + return (__vector __bool int) + __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 12); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_ne(__vector unsigned int __a, __vector unsigned int __b) { + return (__vector __bool int)__builtin_s390_vfaef(__a, __b, 12); +} + +/*-- vec_find_any_ne_cc -----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_ne_cc(__vector signed char __a, + __vector signed char __b, int *__cc) { + return (__vector __bool char) + __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_ne_cc(__vector __bool char __a, + __vector __bool char __b, int *__cc) { + return (__vector __bool char) + __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool char +vec_find_any_ne_cc(__vector unsigned char __a, + __vector unsigned char __b, int *__cc) { + return (__vector __bool char)__builtin_s390_vfaebs(__a, __b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_ne_cc(__vector signed short __a, + __vector signed short __b, int *__cc) { + return (__vector __bool short) + __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_ne_cc(__vector __bool short __a, + __vector __bool short __b, int *__cc) { + return (__vector __bool short) + __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool short +vec_find_any_ne_cc(__vector unsigned short __a, + __vector unsigned short __b, int *__cc) { + return (__vector __bool short)__builtin_s390_vfaehs(__a, __b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_ne_cc(__vector signed int __a, + __vector signed int __b, int *__cc) { + return (__vector __bool int) + __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_ne_cc(__vector __bool int __a, + __vector __bool int __b, int *__cc) { + return (__vector __bool int) + __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 12, __cc); +} + +static inline __ATTRS_o_ai __vector __bool int +vec_find_any_ne_cc(__vector unsigned int __a, + __vector unsigned int __b, int *__cc) { + return (__vector __bool int)__builtin_s390_vfaefs(__a, __b, 12, __cc); +} + +/*-- vec_find_any_ne_idx ----------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_ne_idx(__vector signed char __a, __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_idx(__vector __bool char __a, __vector __bool char __b) { + return __builtin_s390_vfaeb((__vector unsigned char)__a, + (__vector unsigned char)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_idx(__vector unsigned char __a, __vector unsigned char __b) { + return __builtin_s390_vfaeb(__a, __b, 8); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_ne_idx(__vector signed short __a, __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_idx(__vector __bool short __a, __vector __bool short __b) { + return __builtin_s390_vfaeh((__vector unsigned short)__a, + (__vector unsigned short)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_idx(__vector unsigned short __a, __vector unsigned short __b) { + return __builtin_s390_vfaeh(__a, __b, 8); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_ne_idx(__vector signed int __a, __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_idx(__vector __bool int __a, __vector __bool int __b) { + return __builtin_s390_vfaef((__vector unsigned int)__a, + (__vector unsigned int)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_idx(__vector unsigned int __a, __vector unsigned int __b) { + return __builtin_s390_vfaef(__a, __b, 8); +} + +/*-- vec_find_any_ne_idx_cc -------------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_ne_idx_cc(__vector signed char __a, + __vector signed char __b, int *__cc) { + return (__vector signed char) + __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_idx_cc(__vector __bool char __a, + __vector __bool char __b, int *__cc) { + return __builtin_s390_vfaebs((__vector unsigned char)__a, + (__vector unsigned char)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_idx_cc(__vector unsigned char __a, + __vector unsigned char __b, + int *__cc) { + return __builtin_s390_vfaebs(__a, __b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_ne_idx_cc(__vector signed short __a, + __vector signed short __b, int *__cc) { + return (__vector signed short) + __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_idx_cc(__vector __bool short __a, + __vector __bool short __b, int *__cc) { + return __builtin_s390_vfaehs((__vector unsigned short)__a, + (__vector unsigned short)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_idx_cc(__vector unsigned short __a, + __vector unsigned short __b, int *__cc) { + return __builtin_s390_vfaehs(__a, __b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_ne_idx_cc(__vector signed int __a, + __vector signed int __b, int *__cc) { + return (__vector signed int) + __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_idx_cc(__vector __bool int __a, + __vector __bool int __b, int *__cc) { + return __builtin_s390_vfaefs((__vector unsigned int)__a, + (__vector unsigned int)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_idx_cc(__vector unsigned int __a, + __vector unsigned int __b, int *__cc) { + return __builtin_s390_vfaefs(__a, __b, 8, __cc); +} + +/*-- vec_find_any_ne_or_0_idx -----------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_ne_or_0_idx(__vector signed char __a, + __vector signed char __b) { + return (__vector signed char) + __builtin_s390_vfaezb((__vector unsigned char)__a, + (__vector unsigned char)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_or_0_idx(__vector __bool char __a, + __vector __bool char __b) { + return __builtin_s390_vfaezb((__vector unsigned char)__a, + (__vector unsigned char)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_or_0_idx(__vector unsigned char __a, + __vector unsigned char __b) { + return __builtin_s390_vfaezb(__a, __b, 8); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_ne_or_0_idx(__vector signed short __a, + __vector signed short __b) { + return (__vector signed short) + __builtin_s390_vfaezh((__vector unsigned short)__a, + (__vector unsigned short)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_or_0_idx(__vector __bool short __a, + __vector __bool short __b) { + return __builtin_s390_vfaezh((__vector unsigned short)__a, + (__vector unsigned short)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_or_0_idx(__vector unsigned short __a, + __vector unsigned short __b) { + return __builtin_s390_vfaezh(__a, __b, 8); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_ne_or_0_idx(__vector signed int __a, + __vector signed int __b) { + return (__vector signed int) + __builtin_s390_vfaezf((__vector unsigned int)__a, + (__vector unsigned int)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_or_0_idx(__vector __bool int __a, + __vector __bool int __b) { + return __builtin_s390_vfaezf((__vector unsigned int)__a, + (__vector unsigned int)__b, 8); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_or_0_idx(__vector unsigned int __a, + __vector unsigned int __b) { + return __builtin_s390_vfaezf(__a, __b, 8); +} + +/*-- vec_find_any_ne_or_0_idx_cc --------------------------------------------*/ + +static inline __ATTRS_o_ai __vector signed char +vec_find_any_ne_or_0_idx_cc(__vector signed char __a, + __vector signed char __b, int *__cc) { + return (__vector signed char) + __builtin_s390_vfaezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_or_0_idx_cc(__vector __bool char __a, + __vector __bool char __b, int *__cc) { + return __builtin_s390_vfaezbs((__vector unsigned char)__a, + (__vector unsigned char)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_find_any_ne_or_0_idx_cc(__vector unsigned char __a, + __vector unsigned char __b, int *__cc) { + return __builtin_s390_vfaezbs(__a, __b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector signed short +vec_find_any_ne_or_0_idx_cc(__vector signed short __a, + __vector signed short __b, int *__cc) { + return (__vector signed short) + __builtin_s390_vfaezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_or_0_idx_cc(__vector __bool short __a, + __vector __bool short __b, int *__cc) { + return __builtin_s390_vfaezhs((__vector unsigned short)__a, + (__vector unsigned short)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned short +vec_find_any_ne_or_0_idx_cc(__vector unsigned short __a, + __vector unsigned short __b, int *__cc) { + return __builtin_s390_vfaezhs(__a, __b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector signed int +vec_find_any_ne_or_0_idx_cc(__vector signed int __a, + __vector signed int __b, int *__cc) { + return (__vector signed int) + __builtin_s390_vfaezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_or_0_idx_cc(__vector __bool int __a, + __vector __bool int __b, int *__cc) { + return __builtin_s390_vfaezfs((__vector unsigned int)__a, + (__vector unsigned int)__b, 8, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned int +vec_find_any_ne_or_0_idx_cc(__vector unsigned int __a, + __vector unsigned int __b, int *__cc) { + return __builtin_s390_vfaezfs(__a, __b, 8, __cc); +} + +/*-- vec_search_string_cc ---------------------------------------------------*/ + +#if __ARCH__ >= 13 + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector signed char __a, __vector signed char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsb((__vector unsigned char)__a, + (__vector unsigned char)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector __bool char __a, __vector __bool char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsb((__vector unsigned char)__a, + (__vector unsigned char)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector unsigned char __a, __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsb(__a, __b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector signed short __a, __vector signed short __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsh((__vector unsigned short)__a, + (__vector unsigned short)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector __bool short __a, __vector __bool short __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsh((__vector unsigned short)__a, + (__vector unsigned short)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector unsigned short __a, __vector unsigned short __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsh(__a, __b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector signed int __a, __vector signed int __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsf((__vector unsigned int)__a, + (__vector unsigned int)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector __bool int __a, __vector __bool int __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsf((__vector unsigned int)__a, + (__vector unsigned int)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_cc(__vector unsigned int __a, __vector unsigned int __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrsf(__a, __b, __c, __cc); +} + +#endif + +/*-- vec_search_string_until_zero_cc ----------------------------------------*/ + +#if __ARCH__ >= 13 + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector signed char __a, + __vector signed char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszb((__vector unsigned char)__a, + (__vector unsigned char)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector __bool char __a, + __vector __bool char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszb((__vector unsigned char)__a, + (__vector unsigned char)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector unsigned char __a, + __vector unsigned char __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszb(__a, __b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector signed short __a, + __vector signed short __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszh((__vector unsigned short)__a, + (__vector unsigned short)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector __bool short __a, + __vector __bool short __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszh((__vector unsigned short)__a, + (__vector unsigned short)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector unsigned short __a, + __vector unsigned short __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszh(__a, __b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector signed int __a, + __vector signed int __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszf((__vector unsigned int)__a, + (__vector unsigned int)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector __bool int __a, + __vector __bool int __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszf((__vector unsigned int)__a, + (__vector unsigned int)__b, __c, __cc); +} + +static inline __ATTRS_o_ai __vector unsigned char +vec_search_string_until_zero_cc(__vector unsigned int __a, + __vector unsigned int __b, + __vector unsigned char __c, int *__cc) { + return __builtin_s390_vstrszf(__a, __b, __c, __cc); +} + +#endif + +#undef __constant_pow2_range +#undef __constant_range +#undef __constant +#undef __ATTRS_o +#undef __ATTRS_o_ai +#undef __ATTRS_ai + +#else + +#error "Use -fzvector to enable vector extensions" + +#endif + +#endif /* _VECINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin.h new file mode 100755 index 0000000..3f2bc00 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin.h @@ -0,0 +1,71 @@ +/*===---- velintrin.h - VEL intrinsics for VE ------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __VEL_INTRIN_H__ +#define __VEL_INTRIN_H__ + +// Vector registers +typedef double __vr __attribute__((__vector_size__(2048))); + +// Vector mask registers +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +// For C99 +typedef _Bool __vm __attribute__((ext_vector_type(256))); +typedef _Bool __vm256 __attribute__((ext_vector_type(256))); +typedef _Bool __vm512 __attribute__((ext_vector_type(512))); +#else +#ifdef __cplusplus +// For C++ +typedef bool __vm __attribute__((ext_vector_type(256))); +typedef bool __vm256 __attribute__((ext_vector_type(256))); +typedef bool __vm512 __attribute__((ext_vector_type(512))); +#else +#error need C++ or C99 to use vector intrinsics for VE +#endif +#endif + +enum VShuffleCodes { + VE_VSHUFFLE_YUYU = 0, + VE_VSHUFFLE_YUYL = 1, + VE_VSHUFFLE_YUZU = 2, + VE_VSHUFFLE_YUZL = 3, + VE_VSHUFFLE_YLYU = 4, + VE_VSHUFFLE_YLYL = 5, + VE_VSHUFFLE_YLZU = 6, + VE_VSHUFFLE_YLZL = 7, + VE_VSHUFFLE_ZUYU = 8, + VE_VSHUFFLE_ZUYL = 9, + VE_VSHUFFLE_ZUZU = 10, + VE_VSHUFFLE_ZUZL = 11, + VE_VSHUFFLE_ZLYU = 12, + VE_VSHUFFLE_ZLYL = 13, + VE_VSHUFFLE_ZLZU = 14, + VE_VSHUFFLE_ZLZL = 15, +}; + +// Use generated intrinsic name definitions +#include + +// Use helper functions +#include + +// pack + +#define _vel_pack_f32p __builtin_ve_vl_pack_f32p +#define _vel_pack_f32a __builtin_ve_vl_pack_f32a + +static inline unsigned long int _vel_pack_i32(unsigned int a, unsigned int b) { + return (((unsigned long int)a) << 32) | b; +} + +#define _vel_extract_vm512u(vm) __builtin_ve_vl_extract_vm512u(vm) +#define _vel_extract_vm512l(vm) __builtin_ve_vl_extract_vm512l(vm) +#define _vel_insert_vm512u(vm512, vm) __builtin_ve_vl_insert_vm512u(vm512, vm) +#define _vel_insert_vm512l(vm512, vm) __builtin_ve_vl_insert_vm512l(vm512, vm) + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin_approx.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin_approx.h new file mode 100755 index 0000000..89d270f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin_approx.h @@ -0,0 +1,120 @@ +/*===---- velintrin_approx.h - VEL intrinsics helper for VE ----------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __VEL_INTRIN_APPROX_H__ +#define __VEL_INTRIN_APPROX_H__ + +static inline __vr _vel_approx_vfdivs_vvvl(__vr v0, __vr v1, int l) { + float s0; + __vr v2, v3, v4, v5; + v5 = _vel_vrcps_vvl(v1, l); + s0 = 1.0; + v4 = _vel_vfnmsbs_vsvvl(s0, v1, v5, l); + v3 = _vel_vfmads_vvvvl(v5, v5, v4, l); + v2 = _vel_vfmuls_vvvl(v0, v3, l); + v4 = _vel_vfnmsbs_vvvvl(v0, v2, v1, l); + v2 = _vel_vfmads_vvvvl(v2, v5, v4, l); + v0 = _vel_vfnmsbs_vvvvl(v0, v2, v1, l); + v0 = _vel_vfmads_vvvvl(v2, v3, v0, l); + return v0; +} + +static inline __vr _vel_approx_pvfdiv_vvvl(__vr v0, __vr v1, int l) { + float s0; + __vr v2, v3, v4, v5; + v5 = _vel_pvrcp_vvl(v1, l); + s0 = 1.0; + v4 = _vel_pvfnmsb_vsvvl(s0, v1, v5, l); + v3 = _vel_pvfmad_vvvvl(v5, v5, v4, l); + v2 = _vel_pvfmul_vvvl(v0, v3, l); + v4 = _vel_pvfnmsb_vvvvl(v0, v2, v1, l); + v2 = _vel_pvfmad_vvvvl(v2, v5, v4, l); + v0 = _vel_pvfnmsb_vvvvl(v0, v2, v1, l); + v0 = _vel_pvfmad_vvvvl(v2, v3, v0, l); + return v0; +} + +static inline __vr _vel_approx_vfdivs_vsvl(float s0, __vr v0, int l) { + float s1; + __vr v1, v2, v3, v4; + v4 = _vel_vrcps_vvl(v0, l); + s1 = 1.0; + v2 = _vel_vfnmsbs_vsvvl(s1, v0, v4, l); + v2 = _vel_vfmads_vvvvl(v4, v4, v2, l); + v1 = _vel_vfmuls_vsvl(s0, v2, l); + v3 = _vel_vfnmsbs_vsvvl(s0, v1, v0, l); + v1 = _vel_vfmads_vvvvl(v1, v4, v3, l); + v3 = _vel_vfnmsbs_vsvvl(s0, v1, v0, l); + v0 = _vel_vfmads_vvvvl(v1, v2, v3, l); + return v0; +} + +static inline __vr _vel_approx_vfdivs_vvsl(__vr v0, float s0, int l) { + float s1; + __vr v1, v2; + s1 = 1.0f / s0; + v1 = _vel_vfmuls_vsvl(s1, v0, l); + v2 = _vel_vfnmsbs_vvsvl(v0, s0, v1, l); + v0 = _vel_vfmads_vvsvl(v1, s1, v2, l); + return v0; +} + +static inline __vr _vel_approx_vfdivd_vsvl(double s0, __vr v0, int l) { + __vr v1, v2, v3; + v2 = _vel_vrcpd_vvl(v0, l); + double s1 = 1.0; + v3 = _vel_vfnmsbd_vsvvl(s1, v0, v2, l); + v2 = _vel_vfmadd_vvvvl(v2, v2, v3, l); + v1 = _vel_vfnmsbd_vsvvl(s1, v0, v2, l); + v1 = _vel_vfmadd_vvvvl(v2, v2, v1, l); + v1 = _vel_vaddul_vsvl(1, v1, l); + v3 = _vel_vfnmsbd_vsvvl(s1, v0, v1, l); + v3 = _vel_vfmadd_vvvvl(v1, v1, v3, l); + v1 = _vel_vfmuld_vsvl(s0, v3, l); + v0 = _vel_vfnmsbd_vsvvl(s0, v1, v0, l); + v0 = _vel_vfmadd_vvvvl(v1, v3, v0, l); + return v0; +} + +static inline __vr _vel_approx_vfsqrtd_vvl(__vr v0, int l) { + double s0, s1; + __vr v1, v2, v3; + v2 = _vel_vrsqrtdnex_vvl(v0, l); + v1 = _vel_vfmuld_vvvl(v0, v2, l); + s0 = 1.0; + s1 = 0.5; + v3 = _vel_vfnmsbd_vsvvl(s0, v1, v2, l); + v3 = _vel_vfmuld_vsvl(s1, v3, l); + v2 = _vel_vfmadd_vvvvl(v2, v2, v3, l); + v1 = _vel_vfmuld_vvvl(v0, v2, l); + v3 = _vel_vfnmsbd_vsvvl(s0, v1, v2, l); + v3 = _vel_vfmuld_vsvl(s1, v3, l); + v0 = _vel_vfmadd_vvvvl(v1, v1, v3, l); + return v0; +} + +static inline __vr _vel_approx_vfsqrts_vvl(__vr v0, int l) { + float s0, s1; + __vr v1, v2, v3; + v0 = _vel_vcvtds_vvl(v0, l); + v2 = _vel_vrsqrtdnex_vvl(v0, l); + v1 = _vel_vfmuld_vvvl(v0, v2, l); + s0 = 1.0; + s1 = 0.5; + v3 = _vel_vfnmsbd_vsvvl(s0, v1, v2, l); + v3 = _vel_vfmuld_vsvl(s1, v3, l); + v2 = _vel_vfmadd_vvvvl(v2, v2, v3, l); + v1 = _vel_vfmuld_vvvl(v0, v2, l); + v3 = _vel_vfnmsbd_vsvvl(s0, v1, v2, l); + v3 = _vel_vfmuld_vsvl(s1, v3, l); + v0 = _vel_vfmadd_vvvvl(v1, v1, v3, l); + v0 = _vel_vcvtsd_vvl(v0, l); + return v0; +} + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin_gen.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin_gen.h new file mode 100755 index 0000000..845c0da --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/velintrin_gen.h @@ -0,0 +1,1257 @@ +#define _vel_vld_vssl __builtin_ve_vl_vld_vssl +#define _vel_vld_vssvl __builtin_ve_vl_vld_vssvl +#define _vel_vldnc_vssl __builtin_ve_vl_vldnc_vssl +#define _vel_vldnc_vssvl __builtin_ve_vl_vldnc_vssvl +#define _vel_vldu_vssl __builtin_ve_vl_vldu_vssl +#define _vel_vldu_vssvl __builtin_ve_vl_vldu_vssvl +#define _vel_vldunc_vssl __builtin_ve_vl_vldunc_vssl +#define _vel_vldunc_vssvl __builtin_ve_vl_vldunc_vssvl +#define _vel_vldlsx_vssl __builtin_ve_vl_vldlsx_vssl +#define _vel_vldlsx_vssvl __builtin_ve_vl_vldlsx_vssvl +#define _vel_vldlsxnc_vssl __builtin_ve_vl_vldlsxnc_vssl +#define _vel_vldlsxnc_vssvl __builtin_ve_vl_vldlsxnc_vssvl +#define _vel_vldlzx_vssl __builtin_ve_vl_vldlzx_vssl +#define _vel_vldlzx_vssvl __builtin_ve_vl_vldlzx_vssvl +#define _vel_vldlzxnc_vssl __builtin_ve_vl_vldlzxnc_vssl +#define _vel_vldlzxnc_vssvl __builtin_ve_vl_vldlzxnc_vssvl +#define _vel_vld2d_vssl __builtin_ve_vl_vld2d_vssl +#define _vel_vld2d_vssvl __builtin_ve_vl_vld2d_vssvl +#define _vel_vld2dnc_vssl __builtin_ve_vl_vld2dnc_vssl +#define _vel_vld2dnc_vssvl __builtin_ve_vl_vld2dnc_vssvl +#define _vel_vldu2d_vssl __builtin_ve_vl_vldu2d_vssl +#define _vel_vldu2d_vssvl __builtin_ve_vl_vldu2d_vssvl +#define _vel_vldu2dnc_vssl __builtin_ve_vl_vldu2dnc_vssl +#define _vel_vldu2dnc_vssvl __builtin_ve_vl_vldu2dnc_vssvl +#define _vel_vldl2dsx_vssl __builtin_ve_vl_vldl2dsx_vssl +#define _vel_vldl2dsx_vssvl __builtin_ve_vl_vldl2dsx_vssvl +#define _vel_vldl2dsxnc_vssl __builtin_ve_vl_vldl2dsxnc_vssl +#define _vel_vldl2dsxnc_vssvl __builtin_ve_vl_vldl2dsxnc_vssvl +#define _vel_vldl2dzx_vssl __builtin_ve_vl_vldl2dzx_vssl +#define _vel_vldl2dzx_vssvl __builtin_ve_vl_vldl2dzx_vssvl +#define _vel_vldl2dzxnc_vssl __builtin_ve_vl_vldl2dzxnc_vssl +#define _vel_vldl2dzxnc_vssvl __builtin_ve_vl_vldl2dzxnc_vssvl +#define _vel_vst_vssl __builtin_ve_vl_vst_vssl +#define _vel_vst_vssml __builtin_ve_vl_vst_vssml +#define _vel_vstnc_vssl __builtin_ve_vl_vstnc_vssl +#define _vel_vstnc_vssml __builtin_ve_vl_vstnc_vssml +#define _vel_vstot_vssl __builtin_ve_vl_vstot_vssl +#define _vel_vstot_vssml __builtin_ve_vl_vstot_vssml +#define _vel_vstncot_vssl __builtin_ve_vl_vstncot_vssl +#define _vel_vstncot_vssml __builtin_ve_vl_vstncot_vssml +#define _vel_vstu_vssl __builtin_ve_vl_vstu_vssl +#define _vel_vstu_vssml __builtin_ve_vl_vstu_vssml +#define _vel_vstunc_vssl __builtin_ve_vl_vstunc_vssl +#define _vel_vstunc_vssml __builtin_ve_vl_vstunc_vssml +#define _vel_vstuot_vssl __builtin_ve_vl_vstuot_vssl +#define _vel_vstuot_vssml __builtin_ve_vl_vstuot_vssml +#define _vel_vstuncot_vssl __builtin_ve_vl_vstuncot_vssl +#define _vel_vstuncot_vssml __builtin_ve_vl_vstuncot_vssml +#define _vel_vstl_vssl __builtin_ve_vl_vstl_vssl +#define _vel_vstl_vssml __builtin_ve_vl_vstl_vssml +#define _vel_vstlnc_vssl __builtin_ve_vl_vstlnc_vssl +#define _vel_vstlnc_vssml __builtin_ve_vl_vstlnc_vssml +#define _vel_vstlot_vssl __builtin_ve_vl_vstlot_vssl +#define _vel_vstlot_vssml __builtin_ve_vl_vstlot_vssml +#define _vel_vstlncot_vssl __builtin_ve_vl_vstlncot_vssl +#define _vel_vstlncot_vssml __builtin_ve_vl_vstlncot_vssml +#define _vel_vst2d_vssl __builtin_ve_vl_vst2d_vssl +#define _vel_vst2d_vssml __builtin_ve_vl_vst2d_vssml +#define _vel_vst2dnc_vssl __builtin_ve_vl_vst2dnc_vssl +#define _vel_vst2dnc_vssml __builtin_ve_vl_vst2dnc_vssml +#define _vel_vst2dot_vssl __builtin_ve_vl_vst2dot_vssl +#define _vel_vst2dot_vssml __builtin_ve_vl_vst2dot_vssml +#define _vel_vst2dncot_vssl __builtin_ve_vl_vst2dncot_vssl +#define _vel_vst2dncot_vssml __builtin_ve_vl_vst2dncot_vssml +#define _vel_vstu2d_vssl __builtin_ve_vl_vstu2d_vssl +#define _vel_vstu2d_vssml __builtin_ve_vl_vstu2d_vssml +#define _vel_vstu2dnc_vssl __builtin_ve_vl_vstu2dnc_vssl +#define _vel_vstu2dnc_vssml __builtin_ve_vl_vstu2dnc_vssml +#define _vel_vstu2dot_vssl __builtin_ve_vl_vstu2dot_vssl +#define _vel_vstu2dot_vssml __builtin_ve_vl_vstu2dot_vssml +#define _vel_vstu2dncot_vssl __builtin_ve_vl_vstu2dncot_vssl +#define _vel_vstu2dncot_vssml __builtin_ve_vl_vstu2dncot_vssml +#define _vel_vstl2d_vssl __builtin_ve_vl_vstl2d_vssl +#define _vel_vstl2d_vssml __builtin_ve_vl_vstl2d_vssml +#define _vel_vstl2dnc_vssl __builtin_ve_vl_vstl2dnc_vssl +#define _vel_vstl2dnc_vssml __builtin_ve_vl_vstl2dnc_vssml +#define _vel_vstl2dot_vssl __builtin_ve_vl_vstl2dot_vssl +#define _vel_vstl2dot_vssml __builtin_ve_vl_vstl2dot_vssml +#define _vel_vstl2dncot_vssl __builtin_ve_vl_vstl2dncot_vssl +#define _vel_vstl2dncot_vssml __builtin_ve_vl_vstl2dncot_vssml +#define _vel_pfchv_ssl __builtin_ve_vl_pfchv_ssl +#define _vel_pfchvnc_ssl __builtin_ve_vl_pfchvnc_ssl +#define _vel_lsv_vvss __builtin_ve_vl_lsv_vvss +#define _vel_lvsl_svs __builtin_ve_vl_lvsl_svs +#define _vel_lvsd_svs __builtin_ve_vl_lvsd_svs +#define _vel_lvss_svs __builtin_ve_vl_lvss_svs +#define _vel_lvm_mmss __builtin_ve_vl_lvm_mmss +#define _vel_lvm_MMss __builtin_ve_vl_lvm_MMss +#define _vel_svm_sms __builtin_ve_vl_svm_sms +#define _vel_svm_sMs __builtin_ve_vl_svm_sMs +#define _vel_vbrdd_vsl __builtin_ve_vl_vbrdd_vsl +#define _vel_vbrdd_vsvl __builtin_ve_vl_vbrdd_vsvl +#define _vel_vbrdd_vsmvl __builtin_ve_vl_vbrdd_vsmvl +#define _vel_vbrdl_vsl __builtin_ve_vl_vbrdl_vsl +#define _vel_vbrdl_vsvl __builtin_ve_vl_vbrdl_vsvl +#define _vel_vbrdl_vsmvl __builtin_ve_vl_vbrdl_vsmvl +#define _vel_vbrds_vsl __builtin_ve_vl_vbrds_vsl +#define _vel_vbrds_vsvl __builtin_ve_vl_vbrds_vsvl +#define _vel_vbrds_vsmvl __builtin_ve_vl_vbrds_vsmvl +#define _vel_vbrdw_vsl __builtin_ve_vl_vbrdw_vsl +#define _vel_vbrdw_vsvl __builtin_ve_vl_vbrdw_vsvl +#define _vel_vbrdw_vsmvl __builtin_ve_vl_vbrdw_vsmvl +#define _vel_pvbrd_vsl __builtin_ve_vl_pvbrd_vsl +#define _vel_pvbrd_vsvl __builtin_ve_vl_pvbrd_vsvl +#define _vel_pvbrd_vsMvl __builtin_ve_vl_pvbrd_vsMvl +#define _vel_vmv_vsvl __builtin_ve_vl_vmv_vsvl +#define _vel_vmv_vsvvl __builtin_ve_vl_vmv_vsvvl +#define _vel_vmv_vsvmvl __builtin_ve_vl_vmv_vsvmvl +#define _vel_vaddul_vvvl __builtin_ve_vl_vaddul_vvvl +#define _vel_vaddul_vvvvl __builtin_ve_vl_vaddul_vvvvl +#define _vel_vaddul_vsvl __builtin_ve_vl_vaddul_vsvl +#define _vel_vaddul_vsvvl __builtin_ve_vl_vaddul_vsvvl +#define _vel_vaddul_vvvmvl __builtin_ve_vl_vaddul_vvvmvl +#define _vel_vaddul_vsvmvl __builtin_ve_vl_vaddul_vsvmvl +#define _vel_vadduw_vvvl __builtin_ve_vl_vadduw_vvvl +#define _vel_vadduw_vvvvl __builtin_ve_vl_vadduw_vvvvl +#define _vel_vadduw_vsvl __builtin_ve_vl_vadduw_vsvl +#define _vel_vadduw_vsvvl __builtin_ve_vl_vadduw_vsvvl +#define _vel_vadduw_vvvmvl __builtin_ve_vl_vadduw_vvvmvl +#define _vel_vadduw_vsvmvl __builtin_ve_vl_vadduw_vsvmvl +#define _vel_pvaddu_vvvl __builtin_ve_vl_pvaddu_vvvl +#define _vel_pvaddu_vvvvl __builtin_ve_vl_pvaddu_vvvvl +#define _vel_pvaddu_vsvl __builtin_ve_vl_pvaddu_vsvl +#define _vel_pvaddu_vsvvl __builtin_ve_vl_pvaddu_vsvvl +#define _vel_pvaddu_vvvMvl __builtin_ve_vl_pvaddu_vvvMvl +#define _vel_pvaddu_vsvMvl __builtin_ve_vl_pvaddu_vsvMvl +#define _vel_vaddswsx_vvvl __builtin_ve_vl_vaddswsx_vvvl +#define _vel_vaddswsx_vvvvl __builtin_ve_vl_vaddswsx_vvvvl +#define _vel_vaddswsx_vsvl __builtin_ve_vl_vaddswsx_vsvl +#define _vel_vaddswsx_vsvvl __builtin_ve_vl_vaddswsx_vsvvl +#define _vel_vaddswsx_vvvmvl __builtin_ve_vl_vaddswsx_vvvmvl +#define _vel_vaddswsx_vsvmvl __builtin_ve_vl_vaddswsx_vsvmvl +#define _vel_vaddswzx_vvvl __builtin_ve_vl_vaddswzx_vvvl +#define _vel_vaddswzx_vvvvl __builtin_ve_vl_vaddswzx_vvvvl +#define _vel_vaddswzx_vsvl __builtin_ve_vl_vaddswzx_vsvl +#define _vel_vaddswzx_vsvvl __builtin_ve_vl_vaddswzx_vsvvl +#define _vel_vaddswzx_vvvmvl __builtin_ve_vl_vaddswzx_vvvmvl +#define _vel_vaddswzx_vsvmvl __builtin_ve_vl_vaddswzx_vsvmvl +#define _vel_pvadds_vvvl __builtin_ve_vl_pvadds_vvvl +#define _vel_pvadds_vvvvl __builtin_ve_vl_pvadds_vvvvl +#define _vel_pvadds_vsvl __builtin_ve_vl_pvadds_vsvl +#define _vel_pvadds_vsvvl __builtin_ve_vl_pvadds_vsvvl +#define _vel_pvadds_vvvMvl __builtin_ve_vl_pvadds_vvvMvl +#define _vel_pvadds_vsvMvl __builtin_ve_vl_pvadds_vsvMvl +#define _vel_vaddsl_vvvl __builtin_ve_vl_vaddsl_vvvl +#define _vel_vaddsl_vvvvl __builtin_ve_vl_vaddsl_vvvvl +#define _vel_vaddsl_vsvl __builtin_ve_vl_vaddsl_vsvl +#define _vel_vaddsl_vsvvl __builtin_ve_vl_vaddsl_vsvvl +#define _vel_vaddsl_vvvmvl __builtin_ve_vl_vaddsl_vvvmvl +#define _vel_vaddsl_vsvmvl __builtin_ve_vl_vaddsl_vsvmvl +#define _vel_vsubul_vvvl __builtin_ve_vl_vsubul_vvvl +#define _vel_vsubul_vvvvl __builtin_ve_vl_vsubul_vvvvl +#define _vel_vsubul_vsvl __builtin_ve_vl_vsubul_vsvl +#define _vel_vsubul_vsvvl __builtin_ve_vl_vsubul_vsvvl +#define _vel_vsubul_vvvmvl __builtin_ve_vl_vsubul_vvvmvl +#define _vel_vsubul_vsvmvl __builtin_ve_vl_vsubul_vsvmvl +#define _vel_vsubuw_vvvl __builtin_ve_vl_vsubuw_vvvl +#define _vel_vsubuw_vvvvl __builtin_ve_vl_vsubuw_vvvvl +#define _vel_vsubuw_vsvl __builtin_ve_vl_vsubuw_vsvl +#define _vel_vsubuw_vsvvl __builtin_ve_vl_vsubuw_vsvvl +#define _vel_vsubuw_vvvmvl __builtin_ve_vl_vsubuw_vvvmvl +#define _vel_vsubuw_vsvmvl __builtin_ve_vl_vsubuw_vsvmvl +#define _vel_pvsubu_vvvl __builtin_ve_vl_pvsubu_vvvl +#define _vel_pvsubu_vvvvl __builtin_ve_vl_pvsubu_vvvvl +#define _vel_pvsubu_vsvl __builtin_ve_vl_pvsubu_vsvl +#define _vel_pvsubu_vsvvl __builtin_ve_vl_pvsubu_vsvvl +#define _vel_pvsubu_vvvMvl __builtin_ve_vl_pvsubu_vvvMvl +#define _vel_pvsubu_vsvMvl __builtin_ve_vl_pvsubu_vsvMvl +#define _vel_vsubswsx_vvvl __builtin_ve_vl_vsubswsx_vvvl +#define _vel_vsubswsx_vvvvl __builtin_ve_vl_vsubswsx_vvvvl +#define _vel_vsubswsx_vsvl __builtin_ve_vl_vsubswsx_vsvl +#define _vel_vsubswsx_vsvvl __builtin_ve_vl_vsubswsx_vsvvl +#define _vel_vsubswsx_vvvmvl __builtin_ve_vl_vsubswsx_vvvmvl +#define _vel_vsubswsx_vsvmvl __builtin_ve_vl_vsubswsx_vsvmvl +#define _vel_vsubswzx_vvvl __builtin_ve_vl_vsubswzx_vvvl +#define _vel_vsubswzx_vvvvl __builtin_ve_vl_vsubswzx_vvvvl +#define _vel_vsubswzx_vsvl __builtin_ve_vl_vsubswzx_vsvl +#define _vel_vsubswzx_vsvvl __builtin_ve_vl_vsubswzx_vsvvl +#define _vel_vsubswzx_vvvmvl __builtin_ve_vl_vsubswzx_vvvmvl +#define _vel_vsubswzx_vsvmvl __builtin_ve_vl_vsubswzx_vsvmvl +#define _vel_pvsubs_vvvl __builtin_ve_vl_pvsubs_vvvl +#define _vel_pvsubs_vvvvl __builtin_ve_vl_pvsubs_vvvvl +#define _vel_pvsubs_vsvl __builtin_ve_vl_pvsubs_vsvl +#define _vel_pvsubs_vsvvl __builtin_ve_vl_pvsubs_vsvvl +#define _vel_pvsubs_vvvMvl __builtin_ve_vl_pvsubs_vvvMvl +#define _vel_pvsubs_vsvMvl __builtin_ve_vl_pvsubs_vsvMvl +#define _vel_vsubsl_vvvl __builtin_ve_vl_vsubsl_vvvl +#define _vel_vsubsl_vvvvl __builtin_ve_vl_vsubsl_vvvvl +#define _vel_vsubsl_vsvl __builtin_ve_vl_vsubsl_vsvl +#define _vel_vsubsl_vsvvl __builtin_ve_vl_vsubsl_vsvvl +#define _vel_vsubsl_vvvmvl __builtin_ve_vl_vsubsl_vvvmvl +#define _vel_vsubsl_vsvmvl __builtin_ve_vl_vsubsl_vsvmvl +#define _vel_vmulul_vvvl __builtin_ve_vl_vmulul_vvvl +#define _vel_vmulul_vvvvl __builtin_ve_vl_vmulul_vvvvl +#define _vel_vmulul_vsvl __builtin_ve_vl_vmulul_vsvl +#define _vel_vmulul_vsvvl __builtin_ve_vl_vmulul_vsvvl +#define _vel_vmulul_vvvmvl __builtin_ve_vl_vmulul_vvvmvl +#define _vel_vmulul_vsvmvl __builtin_ve_vl_vmulul_vsvmvl +#define _vel_vmuluw_vvvl __builtin_ve_vl_vmuluw_vvvl +#define _vel_vmuluw_vvvvl __builtin_ve_vl_vmuluw_vvvvl +#define _vel_vmuluw_vsvl __builtin_ve_vl_vmuluw_vsvl +#define _vel_vmuluw_vsvvl __builtin_ve_vl_vmuluw_vsvvl +#define _vel_vmuluw_vvvmvl __builtin_ve_vl_vmuluw_vvvmvl +#define _vel_vmuluw_vsvmvl __builtin_ve_vl_vmuluw_vsvmvl +#define _vel_vmulswsx_vvvl __builtin_ve_vl_vmulswsx_vvvl +#define _vel_vmulswsx_vvvvl __builtin_ve_vl_vmulswsx_vvvvl +#define _vel_vmulswsx_vsvl __builtin_ve_vl_vmulswsx_vsvl +#define _vel_vmulswsx_vsvvl __builtin_ve_vl_vmulswsx_vsvvl +#define _vel_vmulswsx_vvvmvl __builtin_ve_vl_vmulswsx_vvvmvl +#define _vel_vmulswsx_vsvmvl __builtin_ve_vl_vmulswsx_vsvmvl +#define _vel_vmulswzx_vvvl __builtin_ve_vl_vmulswzx_vvvl +#define _vel_vmulswzx_vvvvl __builtin_ve_vl_vmulswzx_vvvvl +#define _vel_vmulswzx_vsvl __builtin_ve_vl_vmulswzx_vsvl +#define _vel_vmulswzx_vsvvl __builtin_ve_vl_vmulswzx_vsvvl +#define _vel_vmulswzx_vvvmvl __builtin_ve_vl_vmulswzx_vvvmvl +#define _vel_vmulswzx_vsvmvl __builtin_ve_vl_vmulswzx_vsvmvl +#define _vel_vmulsl_vvvl __builtin_ve_vl_vmulsl_vvvl +#define _vel_vmulsl_vvvvl __builtin_ve_vl_vmulsl_vvvvl +#define _vel_vmulsl_vsvl __builtin_ve_vl_vmulsl_vsvl +#define _vel_vmulsl_vsvvl __builtin_ve_vl_vmulsl_vsvvl +#define _vel_vmulsl_vvvmvl __builtin_ve_vl_vmulsl_vvvmvl +#define _vel_vmulsl_vsvmvl __builtin_ve_vl_vmulsl_vsvmvl +#define _vel_vmulslw_vvvl __builtin_ve_vl_vmulslw_vvvl +#define _vel_vmulslw_vvvvl __builtin_ve_vl_vmulslw_vvvvl +#define _vel_vmulslw_vsvl __builtin_ve_vl_vmulslw_vsvl +#define _vel_vmulslw_vsvvl __builtin_ve_vl_vmulslw_vsvvl +#define _vel_vdivul_vvvl __builtin_ve_vl_vdivul_vvvl +#define _vel_vdivul_vvvvl __builtin_ve_vl_vdivul_vvvvl +#define _vel_vdivul_vsvl __builtin_ve_vl_vdivul_vsvl +#define _vel_vdivul_vsvvl __builtin_ve_vl_vdivul_vsvvl +#define _vel_vdivul_vvvmvl __builtin_ve_vl_vdivul_vvvmvl +#define _vel_vdivul_vsvmvl __builtin_ve_vl_vdivul_vsvmvl +#define _vel_vdivuw_vvvl __builtin_ve_vl_vdivuw_vvvl +#define _vel_vdivuw_vvvvl __builtin_ve_vl_vdivuw_vvvvl +#define _vel_vdivuw_vsvl __builtin_ve_vl_vdivuw_vsvl +#define _vel_vdivuw_vsvvl __builtin_ve_vl_vdivuw_vsvvl +#define _vel_vdivuw_vvvmvl __builtin_ve_vl_vdivuw_vvvmvl +#define _vel_vdivuw_vsvmvl __builtin_ve_vl_vdivuw_vsvmvl +#define _vel_vdivul_vvsl __builtin_ve_vl_vdivul_vvsl +#define _vel_vdivul_vvsvl __builtin_ve_vl_vdivul_vvsvl +#define _vel_vdivul_vvsmvl __builtin_ve_vl_vdivul_vvsmvl +#define _vel_vdivuw_vvsl __builtin_ve_vl_vdivuw_vvsl +#define _vel_vdivuw_vvsvl __builtin_ve_vl_vdivuw_vvsvl +#define _vel_vdivuw_vvsmvl __builtin_ve_vl_vdivuw_vvsmvl +#define _vel_vdivswsx_vvvl __builtin_ve_vl_vdivswsx_vvvl +#define _vel_vdivswsx_vvvvl __builtin_ve_vl_vdivswsx_vvvvl +#define _vel_vdivswsx_vsvl __builtin_ve_vl_vdivswsx_vsvl +#define _vel_vdivswsx_vsvvl __builtin_ve_vl_vdivswsx_vsvvl +#define _vel_vdivswsx_vvvmvl __builtin_ve_vl_vdivswsx_vvvmvl +#define _vel_vdivswsx_vsvmvl __builtin_ve_vl_vdivswsx_vsvmvl +#define _vel_vdivswzx_vvvl __builtin_ve_vl_vdivswzx_vvvl +#define _vel_vdivswzx_vvvvl __builtin_ve_vl_vdivswzx_vvvvl +#define _vel_vdivswzx_vsvl __builtin_ve_vl_vdivswzx_vsvl +#define _vel_vdivswzx_vsvvl __builtin_ve_vl_vdivswzx_vsvvl +#define _vel_vdivswzx_vvvmvl __builtin_ve_vl_vdivswzx_vvvmvl +#define _vel_vdivswzx_vsvmvl __builtin_ve_vl_vdivswzx_vsvmvl +#define _vel_vdivswsx_vvsl __builtin_ve_vl_vdivswsx_vvsl +#define _vel_vdivswsx_vvsvl __builtin_ve_vl_vdivswsx_vvsvl +#define _vel_vdivswsx_vvsmvl __builtin_ve_vl_vdivswsx_vvsmvl +#define _vel_vdivswzx_vvsl __builtin_ve_vl_vdivswzx_vvsl +#define _vel_vdivswzx_vvsvl __builtin_ve_vl_vdivswzx_vvsvl +#define _vel_vdivswzx_vvsmvl __builtin_ve_vl_vdivswzx_vvsmvl +#define _vel_vdivsl_vvvl __builtin_ve_vl_vdivsl_vvvl +#define _vel_vdivsl_vvvvl __builtin_ve_vl_vdivsl_vvvvl +#define _vel_vdivsl_vsvl __builtin_ve_vl_vdivsl_vsvl +#define _vel_vdivsl_vsvvl __builtin_ve_vl_vdivsl_vsvvl +#define _vel_vdivsl_vvvmvl __builtin_ve_vl_vdivsl_vvvmvl +#define _vel_vdivsl_vsvmvl __builtin_ve_vl_vdivsl_vsvmvl +#define _vel_vdivsl_vvsl __builtin_ve_vl_vdivsl_vvsl +#define _vel_vdivsl_vvsvl __builtin_ve_vl_vdivsl_vvsvl +#define _vel_vdivsl_vvsmvl __builtin_ve_vl_vdivsl_vvsmvl +#define _vel_vcmpul_vvvl __builtin_ve_vl_vcmpul_vvvl +#define _vel_vcmpul_vvvvl __builtin_ve_vl_vcmpul_vvvvl +#define _vel_vcmpul_vsvl __builtin_ve_vl_vcmpul_vsvl +#define _vel_vcmpul_vsvvl __builtin_ve_vl_vcmpul_vsvvl +#define _vel_vcmpul_vvvmvl __builtin_ve_vl_vcmpul_vvvmvl +#define _vel_vcmpul_vsvmvl __builtin_ve_vl_vcmpul_vsvmvl +#define _vel_vcmpuw_vvvl __builtin_ve_vl_vcmpuw_vvvl +#define _vel_vcmpuw_vvvvl __builtin_ve_vl_vcmpuw_vvvvl +#define _vel_vcmpuw_vsvl __builtin_ve_vl_vcmpuw_vsvl +#define _vel_vcmpuw_vsvvl __builtin_ve_vl_vcmpuw_vsvvl +#define _vel_vcmpuw_vvvmvl __builtin_ve_vl_vcmpuw_vvvmvl +#define _vel_vcmpuw_vsvmvl __builtin_ve_vl_vcmpuw_vsvmvl +#define _vel_pvcmpu_vvvl __builtin_ve_vl_pvcmpu_vvvl +#define _vel_pvcmpu_vvvvl __builtin_ve_vl_pvcmpu_vvvvl +#define _vel_pvcmpu_vsvl __builtin_ve_vl_pvcmpu_vsvl +#define _vel_pvcmpu_vsvvl __builtin_ve_vl_pvcmpu_vsvvl +#define _vel_pvcmpu_vvvMvl __builtin_ve_vl_pvcmpu_vvvMvl +#define _vel_pvcmpu_vsvMvl __builtin_ve_vl_pvcmpu_vsvMvl +#define _vel_vcmpswsx_vvvl __builtin_ve_vl_vcmpswsx_vvvl +#define _vel_vcmpswsx_vvvvl __builtin_ve_vl_vcmpswsx_vvvvl +#define _vel_vcmpswsx_vsvl __builtin_ve_vl_vcmpswsx_vsvl +#define _vel_vcmpswsx_vsvvl __builtin_ve_vl_vcmpswsx_vsvvl +#define _vel_vcmpswsx_vvvmvl __builtin_ve_vl_vcmpswsx_vvvmvl +#define _vel_vcmpswsx_vsvmvl __builtin_ve_vl_vcmpswsx_vsvmvl +#define _vel_vcmpswzx_vvvl __builtin_ve_vl_vcmpswzx_vvvl +#define _vel_vcmpswzx_vvvvl __builtin_ve_vl_vcmpswzx_vvvvl +#define _vel_vcmpswzx_vsvl __builtin_ve_vl_vcmpswzx_vsvl +#define _vel_vcmpswzx_vsvvl __builtin_ve_vl_vcmpswzx_vsvvl +#define _vel_vcmpswzx_vvvmvl __builtin_ve_vl_vcmpswzx_vvvmvl +#define _vel_vcmpswzx_vsvmvl __builtin_ve_vl_vcmpswzx_vsvmvl +#define _vel_pvcmps_vvvl __builtin_ve_vl_pvcmps_vvvl +#define _vel_pvcmps_vvvvl __builtin_ve_vl_pvcmps_vvvvl +#define _vel_pvcmps_vsvl __builtin_ve_vl_pvcmps_vsvl +#define _vel_pvcmps_vsvvl __builtin_ve_vl_pvcmps_vsvvl +#define _vel_pvcmps_vvvMvl __builtin_ve_vl_pvcmps_vvvMvl +#define _vel_pvcmps_vsvMvl __builtin_ve_vl_pvcmps_vsvMvl +#define _vel_vcmpsl_vvvl __builtin_ve_vl_vcmpsl_vvvl +#define _vel_vcmpsl_vvvvl __builtin_ve_vl_vcmpsl_vvvvl +#define _vel_vcmpsl_vsvl __builtin_ve_vl_vcmpsl_vsvl +#define _vel_vcmpsl_vsvvl __builtin_ve_vl_vcmpsl_vsvvl +#define _vel_vcmpsl_vvvmvl __builtin_ve_vl_vcmpsl_vvvmvl +#define _vel_vcmpsl_vsvmvl __builtin_ve_vl_vcmpsl_vsvmvl +#define _vel_vmaxswsx_vvvl __builtin_ve_vl_vmaxswsx_vvvl +#define _vel_vmaxswsx_vvvvl __builtin_ve_vl_vmaxswsx_vvvvl +#define _vel_vmaxswsx_vsvl __builtin_ve_vl_vmaxswsx_vsvl +#define _vel_vmaxswsx_vsvvl __builtin_ve_vl_vmaxswsx_vsvvl +#define _vel_vmaxswsx_vvvmvl __builtin_ve_vl_vmaxswsx_vvvmvl +#define _vel_vmaxswsx_vsvmvl __builtin_ve_vl_vmaxswsx_vsvmvl +#define _vel_vmaxswzx_vvvl __builtin_ve_vl_vmaxswzx_vvvl +#define _vel_vmaxswzx_vvvvl __builtin_ve_vl_vmaxswzx_vvvvl +#define _vel_vmaxswzx_vsvl __builtin_ve_vl_vmaxswzx_vsvl +#define _vel_vmaxswzx_vsvvl __builtin_ve_vl_vmaxswzx_vsvvl +#define _vel_vmaxswzx_vvvmvl __builtin_ve_vl_vmaxswzx_vvvmvl +#define _vel_vmaxswzx_vsvmvl __builtin_ve_vl_vmaxswzx_vsvmvl +#define _vel_pvmaxs_vvvl __builtin_ve_vl_pvmaxs_vvvl +#define _vel_pvmaxs_vvvvl __builtin_ve_vl_pvmaxs_vvvvl +#define _vel_pvmaxs_vsvl __builtin_ve_vl_pvmaxs_vsvl +#define _vel_pvmaxs_vsvvl __builtin_ve_vl_pvmaxs_vsvvl +#define _vel_pvmaxs_vvvMvl __builtin_ve_vl_pvmaxs_vvvMvl +#define _vel_pvmaxs_vsvMvl __builtin_ve_vl_pvmaxs_vsvMvl +#define _vel_vminswsx_vvvl __builtin_ve_vl_vminswsx_vvvl +#define _vel_vminswsx_vvvvl __builtin_ve_vl_vminswsx_vvvvl +#define _vel_vminswsx_vsvl __builtin_ve_vl_vminswsx_vsvl +#define _vel_vminswsx_vsvvl __builtin_ve_vl_vminswsx_vsvvl +#define _vel_vminswsx_vvvmvl __builtin_ve_vl_vminswsx_vvvmvl +#define _vel_vminswsx_vsvmvl __builtin_ve_vl_vminswsx_vsvmvl +#define _vel_vminswzx_vvvl __builtin_ve_vl_vminswzx_vvvl +#define _vel_vminswzx_vvvvl __builtin_ve_vl_vminswzx_vvvvl +#define _vel_vminswzx_vsvl __builtin_ve_vl_vminswzx_vsvl +#define _vel_vminswzx_vsvvl __builtin_ve_vl_vminswzx_vsvvl +#define _vel_vminswzx_vvvmvl __builtin_ve_vl_vminswzx_vvvmvl +#define _vel_vminswzx_vsvmvl __builtin_ve_vl_vminswzx_vsvmvl +#define _vel_pvmins_vvvl __builtin_ve_vl_pvmins_vvvl +#define _vel_pvmins_vvvvl __builtin_ve_vl_pvmins_vvvvl +#define _vel_pvmins_vsvl __builtin_ve_vl_pvmins_vsvl +#define _vel_pvmins_vsvvl __builtin_ve_vl_pvmins_vsvvl +#define _vel_pvmins_vvvMvl __builtin_ve_vl_pvmins_vvvMvl +#define _vel_pvmins_vsvMvl __builtin_ve_vl_pvmins_vsvMvl +#define _vel_vmaxsl_vvvl __builtin_ve_vl_vmaxsl_vvvl +#define _vel_vmaxsl_vvvvl __builtin_ve_vl_vmaxsl_vvvvl +#define _vel_vmaxsl_vsvl __builtin_ve_vl_vmaxsl_vsvl +#define _vel_vmaxsl_vsvvl __builtin_ve_vl_vmaxsl_vsvvl +#define _vel_vmaxsl_vvvmvl __builtin_ve_vl_vmaxsl_vvvmvl +#define _vel_vmaxsl_vsvmvl __builtin_ve_vl_vmaxsl_vsvmvl +#define _vel_vminsl_vvvl __builtin_ve_vl_vminsl_vvvl +#define _vel_vminsl_vvvvl __builtin_ve_vl_vminsl_vvvvl +#define _vel_vminsl_vsvl __builtin_ve_vl_vminsl_vsvl +#define _vel_vminsl_vsvvl __builtin_ve_vl_vminsl_vsvvl +#define _vel_vminsl_vvvmvl __builtin_ve_vl_vminsl_vvvmvl +#define _vel_vminsl_vsvmvl __builtin_ve_vl_vminsl_vsvmvl +#define _vel_vand_vvvl __builtin_ve_vl_vand_vvvl +#define _vel_vand_vvvvl __builtin_ve_vl_vand_vvvvl +#define _vel_vand_vsvl __builtin_ve_vl_vand_vsvl +#define _vel_vand_vsvvl __builtin_ve_vl_vand_vsvvl +#define _vel_vand_vvvmvl __builtin_ve_vl_vand_vvvmvl +#define _vel_vand_vsvmvl __builtin_ve_vl_vand_vsvmvl +#define _vel_pvand_vvvl __builtin_ve_vl_pvand_vvvl +#define _vel_pvand_vvvvl __builtin_ve_vl_pvand_vvvvl +#define _vel_pvand_vsvl __builtin_ve_vl_pvand_vsvl +#define _vel_pvand_vsvvl __builtin_ve_vl_pvand_vsvvl +#define _vel_pvand_vvvMvl __builtin_ve_vl_pvand_vvvMvl +#define _vel_pvand_vsvMvl __builtin_ve_vl_pvand_vsvMvl +#define _vel_vor_vvvl __builtin_ve_vl_vor_vvvl +#define _vel_vor_vvvvl __builtin_ve_vl_vor_vvvvl +#define _vel_vor_vsvl __builtin_ve_vl_vor_vsvl +#define _vel_vor_vsvvl __builtin_ve_vl_vor_vsvvl +#define _vel_vor_vvvmvl __builtin_ve_vl_vor_vvvmvl +#define _vel_vor_vsvmvl __builtin_ve_vl_vor_vsvmvl +#define _vel_pvor_vvvl __builtin_ve_vl_pvor_vvvl +#define _vel_pvor_vvvvl __builtin_ve_vl_pvor_vvvvl +#define _vel_pvor_vsvl __builtin_ve_vl_pvor_vsvl +#define _vel_pvor_vsvvl __builtin_ve_vl_pvor_vsvvl +#define _vel_pvor_vvvMvl __builtin_ve_vl_pvor_vvvMvl +#define _vel_pvor_vsvMvl __builtin_ve_vl_pvor_vsvMvl +#define _vel_vxor_vvvl __builtin_ve_vl_vxor_vvvl +#define _vel_vxor_vvvvl __builtin_ve_vl_vxor_vvvvl +#define _vel_vxor_vsvl __builtin_ve_vl_vxor_vsvl +#define _vel_vxor_vsvvl __builtin_ve_vl_vxor_vsvvl +#define _vel_vxor_vvvmvl __builtin_ve_vl_vxor_vvvmvl +#define _vel_vxor_vsvmvl __builtin_ve_vl_vxor_vsvmvl +#define _vel_pvxor_vvvl __builtin_ve_vl_pvxor_vvvl +#define _vel_pvxor_vvvvl __builtin_ve_vl_pvxor_vvvvl +#define _vel_pvxor_vsvl __builtin_ve_vl_pvxor_vsvl +#define _vel_pvxor_vsvvl __builtin_ve_vl_pvxor_vsvvl +#define _vel_pvxor_vvvMvl __builtin_ve_vl_pvxor_vvvMvl +#define _vel_pvxor_vsvMvl __builtin_ve_vl_pvxor_vsvMvl +#define _vel_veqv_vvvl __builtin_ve_vl_veqv_vvvl +#define _vel_veqv_vvvvl __builtin_ve_vl_veqv_vvvvl +#define _vel_veqv_vsvl __builtin_ve_vl_veqv_vsvl +#define _vel_veqv_vsvvl __builtin_ve_vl_veqv_vsvvl +#define _vel_veqv_vvvmvl __builtin_ve_vl_veqv_vvvmvl +#define _vel_veqv_vsvmvl __builtin_ve_vl_veqv_vsvmvl +#define _vel_pveqv_vvvl __builtin_ve_vl_pveqv_vvvl +#define _vel_pveqv_vvvvl __builtin_ve_vl_pveqv_vvvvl +#define _vel_pveqv_vsvl __builtin_ve_vl_pveqv_vsvl +#define _vel_pveqv_vsvvl __builtin_ve_vl_pveqv_vsvvl +#define _vel_pveqv_vvvMvl __builtin_ve_vl_pveqv_vvvMvl +#define _vel_pveqv_vsvMvl __builtin_ve_vl_pveqv_vsvMvl +#define _vel_vldz_vvl __builtin_ve_vl_vldz_vvl +#define _vel_vldz_vvvl __builtin_ve_vl_vldz_vvvl +#define _vel_vldz_vvmvl __builtin_ve_vl_vldz_vvmvl +#define _vel_pvldzlo_vvl __builtin_ve_vl_pvldzlo_vvl +#define _vel_pvldzlo_vvvl __builtin_ve_vl_pvldzlo_vvvl +#define _vel_pvldzlo_vvmvl __builtin_ve_vl_pvldzlo_vvmvl +#define _vel_pvldzup_vvl __builtin_ve_vl_pvldzup_vvl +#define _vel_pvldzup_vvvl __builtin_ve_vl_pvldzup_vvvl +#define _vel_pvldzup_vvmvl __builtin_ve_vl_pvldzup_vvmvl +#define _vel_pvldz_vvl __builtin_ve_vl_pvldz_vvl +#define _vel_pvldz_vvvl __builtin_ve_vl_pvldz_vvvl +#define _vel_pvldz_vvMvl __builtin_ve_vl_pvldz_vvMvl +#define _vel_vpcnt_vvl __builtin_ve_vl_vpcnt_vvl +#define _vel_vpcnt_vvvl __builtin_ve_vl_vpcnt_vvvl +#define _vel_vpcnt_vvmvl __builtin_ve_vl_vpcnt_vvmvl +#define _vel_pvpcntlo_vvl __builtin_ve_vl_pvpcntlo_vvl +#define _vel_pvpcntlo_vvvl __builtin_ve_vl_pvpcntlo_vvvl +#define _vel_pvpcntlo_vvmvl __builtin_ve_vl_pvpcntlo_vvmvl +#define _vel_pvpcntup_vvl __builtin_ve_vl_pvpcntup_vvl +#define _vel_pvpcntup_vvvl __builtin_ve_vl_pvpcntup_vvvl +#define _vel_pvpcntup_vvmvl __builtin_ve_vl_pvpcntup_vvmvl +#define _vel_pvpcnt_vvl __builtin_ve_vl_pvpcnt_vvl +#define _vel_pvpcnt_vvvl __builtin_ve_vl_pvpcnt_vvvl +#define _vel_pvpcnt_vvMvl __builtin_ve_vl_pvpcnt_vvMvl +#define _vel_vbrv_vvl __builtin_ve_vl_vbrv_vvl +#define _vel_vbrv_vvvl __builtin_ve_vl_vbrv_vvvl +#define _vel_vbrv_vvmvl __builtin_ve_vl_vbrv_vvmvl +#define _vel_pvbrvlo_vvl __builtin_ve_vl_pvbrvlo_vvl +#define _vel_pvbrvlo_vvvl __builtin_ve_vl_pvbrvlo_vvvl +#define _vel_pvbrvlo_vvmvl __builtin_ve_vl_pvbrvlo_vvmvl +#define _vel_pvbrvup_vvl __builtin_ve_vl_pvbrvup_vvl +#define _vel_pvbrvup_vvvl __builtin_ve_vl_pvbrvup_vvvl +#define _vel_pvbrvup_vvmvl __builtin_ve_vl_pvbrvup_vvmvl +#define _vel_pvbrv_vvl __builtin_ve_vl_pvbrv_vvl +#define _vel_pvbrv_vvvl __builtin_ve_vl_pvbrv_vvvl +#define _vel_pvbrv_vvMvl __builtin_ve_vl_pvbrv_vvMvl +#define _vel_vseq_vl __builtin_ve_vl_vseq_vl +#define _vel_vseq_vvl __builtin_ve_vl_vseq_vvl +#define _vel_pvseqlo_vl __builtin_ve_vl_pvseqlo_vl +#define _vel_pvseqlo_vvl __builtin_ve_vl_pvseqlo_vvl +#define _vel_pvsequp_vl __builtin_ve_vl_pvsequp_vl +#define _vel_pvsequp_vvl __builtin_ve_vl_pvsequp_vvl +#define _vel_pvseq_vl __builtin_ve_vl_pvseq_vl +#define _vel_pvseq_vvl __builtin_ve_vl_pvseq_vvl +#define _vel_vsll_vvvl __builtin_ve_vl_vsll_vvvl +#define _vel_vsll_vvvvl __builtin_ve_vl_vsll_vvvvl +#define _vel_vsll_vvsl __builtin_ve_vl_vsll_vvsl +#define _vel_vsll_vvsvl __builtin_ve_vl_vsll_vvsvl +#define _vel_vsll_vvvmvl __builtin_ve_vl_vsll_vvvmvl +#define _vel_vsll_vvsmvl __builtin_ve_vl_vsll_vvsmvl +#define _vel_pvsll_vvvl __builtin_ve_vl_pvsll_vvvl +#define _vel_pvsll_vvvvl __builtin_ve_vl_pvsll_vvvvl +#define _vel_pvsll_vvsl __builtin_ve_vl_pvsll_vvsl +#define _vel_pvsll_vvsvl __builtin_ve_vl_pvsll_vvsvl +#define _vel_pvsll_vvvMvl __builtin_ve_vl_pvsll_vvvMvl +#define _vel_pvsll_vvsMvl __builtin_ve_vl_pvsll_vvsMvl +#define _vel_vsrl_vvvl __builtin_ve_vl_vsrl_vvvl +#define _vel_vsrl_vvvvl __builtin_ve_vl_vsrl_vvvvl +#define _vel_vsrl_vvsl __builtin_ve_vl_vsrl_vvsl +#define _vel_vsrl_vvsvl __builtin_ve_vl_vsrl_vvsvl +#define _vel_vsrl_vvvmvl __builtin_ve_vl_vsrl_vvvmvl +#define _vel_vsrl_vvsmvl __builtin_ve_vl_vsrl_vvsmvl +#define _vel_pvsrl_vvvl __builtin_ve_vl_pvsrl_vvvl +#define _vel_pvsrl_vvvvl __builtin_ve_vl_pvsrl_vvvvl +#define _vel_pvsrl_vvsl __builtin_ve_vl_pvsrl_vvsl +#define _vel_pvsrl_vvsvl __builtin_ve_vl_pvsrl_vvsvl +#define _vel_pvsrl_vvvMvl __builtin_ve_vl_pvsrl_vvvMvl +#define _vel_pvsrl_vvsMvl __builtin_ve_vl_pvsrl_vvsMvl +#define _vel_vslawsx_vvvl __builtin_ve_vl_vslawsx_vvvl +#define _vel_vslawsx_vvvvl __builtin_ve_vl_vslawsx_vvvvl +#define _vel_vslawsx_vvsl __builtin_ve_vl_vslawsx_vvsl +#define _vel_vslawsx_vvsvl __builtin_ve_vl_vslawsx_vvsvl +#define _vel_vslawsx_vvvmvl __builtin_ve_vl_vslawsx_vvvmvl +#define _vel_vslawsx_vvsmvl __builtin_ve_vl_vslawsx_vvsmvl +#define _vel_vslawzx_vvvl __builtin_ve_vl_vslawzx_vvvl +#define _vel_vslawzx_vvvvl __builtin_ve_vl_vslawzx_vvvvl +#define _vel_vslawzx_vvsl __builtin_ve_vl_vslawzx_vvsl +#define _vel_vslawzx_vvsvl __builtin_ve_vl_vslawzx_vvsvl +#define _vel_vslawzx_vvvmvl __builtin_ve_vl_vslawzx_vvvmvl +#define _vel_vslawzx_vvsmvl __builtin_ve_vl_vslawzx_vvsmvl +#define _vel_pvsla_vvvl __builtin_ve_vl_pvsla_vvvl +#define _vel_pvsla_vvvvl __builtin_ve_vl_pvsla_vvvvl +#define _vel_pvsla_vvsl __builtin_ve_vl_pvsla_vvsl +#define _vel_pvsla_vvsvl __builtin_ve_vl_pvsla_vvsvl +#define _vel_pvsla_vvvMvl __builtin_ve_vl_pvsla_vvvMvl +#define _vel_pvsla_vvsMvl __builtin_ve_vl_pvsla_vvsMvl +#define _vel_vslal_vvvl __builtin_ve_vl_vslal_vvvl +#define _vel_vslal_vvvvl __builtin_ve_vl_vslal_vvvvl +#define _vel_vslal_vvsl __builtin_ve_vl_vslal_vvsl +#define _vel_vslal_vvsvl __builtin_ve_vl_vslal_vvsvl +#define _vel_vslal_vvvmvl __builtin_ve_vl_vslal_vvvmvl +#define _vel_vslal_vvsmvl __builtin_ve_vl_vslal_vvsmvl +#define _vel_vsrawsx_vvvl __builtin_ve_vl_vsrawsx_vvvl +#define _vel_vsrawsx_vvvvl __builtin_ve_vl_vsrawsx_vvvvl +#define _vel_vsrawsx_vvsl __builtin_ve_vl_vsrawsx_vvsl +#define _vel_vsrawsx_vvsvl __builtin_ve_vl_vsrawsx_vvsvl +#define _vel_vsrawsx_vvvmvl __builtin_ve_vl_vsrawsx_vvvmvl +#define _vel_vsrawsx_vvsmvl __builtin_ve_vl_vsrawsx_vvsmvl +#define _vel_vsrawzx_vvvl __builtin_ve_vl_vsrawzx_vvvl +#define _vel_vsrawzx_vvvvl __builtin_ve_vl_vsrawzx_vvvvl +#define _vel_vsrawzx_vvsl __builtin_ve_vl_vsrawzx_vvsl +#define _vel_vsrawzx_vvsvl __builtin_ve_vl_vsrawzx_vvsvl +#define _vel_vsrawzx_vvvmvl __builtin_ve_vl_vsrawzx_vvvmvl +#define _vel_vsrawzx_vvsmvl __builtin_ve_vl_vsrawzx_vvsmvl +#define _vel_pvsra_vvvl __builtin_ve_vl_pvsra_vvvl +#define _vel_pvsra_vvvvl __builtin_ve_vl_pvsra_vvvvl +#define _vel_pvsra_vvsl __builtin_ve_vl_pvsra_vvsl +#define _vel_pvsra_vvsvl __builtin_ve_vl_pvsra_vvsvl +#define _vel_pvsra_vvvMvl __builtin_ve_vl_pvsra_vvvMvl +#define _vel_pvsra_vvsMvl __builtin_ve_vl_pvsra_vvsMvl +#define _vel_vsral_vvvl __builtin_ve_vl_vsral_vvvl +#define _vel_vsral_vvvvl __builtin_ve_vl_vsral_vvvvl +#define _vel_vsral_vvsl __builtin_ve_vl_vsral_vvsl +#define _vel_vsral_vvsvl __builtin_ve_vl_vsral_vvsvl +#define _vel_vsral_vvvmvl __builtin_ve_vl_vsral_vvvmvl +#define _vel_vsral_vvsmvl __builtin_ve_vl_vsral_vvsmvl +#define _vel_vsfa_vvssl __builtin_ve_vl_vsfa_vvssl +#define _vel_vsfa_vvssvl __builtin_ve_vl_vsfa_vvssvl +#define _vel_vsfa_vvssmvl __builtin_ve_vl_vsfa_vvssmvl +#define _vel_vfaddd_vvvl __builtin_ve_vl_vfaddd_vvvl +#define _vel_vfaddd_vvvvl __builtin_ve_vl_vfaddd_vvvvl +#define _vel_vfaddd_vsvl __builtin_ve_vl_vfaddd_vsvl +#define _vel_vfaddd_vsvvl __builtin_ve_vl_vfaddd_vsvvl +#define _vel_vfaddd_vvvmvl __builtin_ve_vl_vfaddd_vvvmvl +#define _vel_vfaddd_vsvmvl __builtin_ve_vl_vfaddd_vsvmvl +#define _vel_vfadds_vvvl __builtin_ve_vl_vfadds_vvvl +#define _vel_vfadds_vvvvl __builtin_ve_vl_vfadds_vvvvl +#define _vel_vfadds_vsvl __builtin_ve_vl_vfadds_vsvl +#define _vel_vfadds_vsvvl __builtin_ve_vl_vfadds_vsvvl +#define _vel_vfadds_vvvmvl __builtin_ve_vl_vfadds_vvvmvl +#define _vel_vfadds_vsvmvl __builtin_ve_vl_vfadds_vsvmvl +#define _vel_pvfadd_vvvl __builtin_ve_vl_pvfadd_vvvl +#define _vel_pvfadd_vvvvl __builtin_ve_vl_pvfadd_vvvvl +#define _vel_pvfadd_vsvl __builtin_ve_vl_pvfadd_vsvl +#define _vel_pvfadd_vsvvl __builtin_ve_vl_pvfadd_vsvvl +#define _vel_pvfadd_vvvMvl __builtin_ve_vl_pvfadd_vvvMvl +#define _vel_pvfadd_vsvMvl __builtin_ve_vl_pvfadd_vsvMvl +#define _vel_vfsubd_vvvl __builtin_ve_vl_vfsubd_vvvl +#define _vel_vfsubd_vvvvl __builtin_ve_vl_vfsubd_vvvvl +#define _vel_vfsubd_vsvl __builtin_ve_vl_vfsubd_vsvl +#define _vel_vfsubd_vsvvl __builtin_ve_vl_vfsubd_vsvvl +#define _vel_vfsubd_vvvmvl __builtin_ve_vl_vfsubd_vvvmvl +#define _vel_vfsubd_vsvmvl __builtin_ve_vl_vfsubd_vsvmvl +#define _vel_vfsubs_vvvl __builtin_ve_vl_vfsubs_vvvl +#define _vel_vfsubs_vvvvl __builtin_ve_vl_vfsubs_vvvvl +#define _vel_vfsubs_vsvl __builtin_ve_vl_vfsubs_vsvl +#define _vel_vfsubs_vsvvl __builtin_ve_vl_vfsubs_vsvvl +#define _vel_vfsubs_vvvmvl __builtin_ve_vl_vfsubs_vvvmvl +#define _vel_vfsubs_vsvmvl __builtin_ve_vl_vfsubs_vsvmvl +#define _vel_pvfsub_vvvl __builtin_ve_vl_pvfsub_vvvl +#define _vel_pvfsub_vvvvl __builtin_ve_vl_pvfsub_vvvvl +#define _vel_pvfsub_vsvl __builtin_ve_vl_pvfsub_vsvl +#define _vel_pvfsub_vsvvl __builtin_ve_vl_pvfsub_vsvvl +#define _vel_pvfsub_vvvMvl __builtin_ve_vl_pvfsub_vvvMvl +#define _vel_pvfsub_vsvMvl __builtin_ve_vl_pvfsub_vsvMvl +#define _vel_vfmuld_vvvl __builtin_ve_vl_vfmuld_vvvl +#define _vel_vfmuld_vvvvl __builtin_ve_vl_vfmuld_vvvvl +#define _vel_vfmuld_vsvl __builtin_ve_vl_vfmuld_vsvl +#define _vel_vfmuld_vsvvl __builtin_ve_vl_vfmuld_vsvvl +#define _vel_vfmuld_vvvmvl __builtin_ve_vl_vfmuld_vvvmvl +#define _vel_vfmuld_vsvmvl __builtin_ve_vl_vfmuld_vsvmvl +#define _vel_vfmuls_vvvl __builtin_ve_vl_vfmuls_vvvl +#define _vel_vfmuls_vvvvl __builtin_ve_vl_vfmuls_vvvvl +#define _vel_vfmuls_vsvl __builtin_ve_vl_vfmuls_vsvl +#define _vel_vfmuls_vsvvl __builtin_ve_vl_vfmuls_vsvvl +#define _vel_vfmuls_vvvmvl __builtin_ve_vl_vfmuls_vvvmvl +#define _vel_vfmuls_vsvmvl __builtin_ve_vl_vfmuls_vsvmvl +#define _vel_pvfmul_vvvl __builtin_ve_vl_pvfmul_vvvl +#define _vel_pvfmul_vvvvl __builtin_ve_vl_pvfmul_vvvvl +#define _vel_pvfmul_vsvl __builtin_ve_vl_pvfmul_vsvl +#define _vel_pvfmul_vsvvl __builtin_ve_vl_pvfmul_vsvvl +#define _vel_pvfmul_vvvMvl __builtin_ve_vl_pvfmul_vvvMvl +#define _vel_pvfmul_vsvMvl __builtin_ve_vl_pvfmul_vsvMvl +#define _vel_vfdivd_vvvl __builtin_ve_vl_vfdivd_vvvl +#define _vel_vfdivd_vvvvl __builtin_ve_vl_vfdivd_vvvvl +#define _vel_vfdivd_vsvl __builtin_ve_vl_vfdivd_vsvl +#define _vel_vfdivd_vsvvl __builtin_ve_vl_vfdivd_vsvvl +#define _vel_vfdivd_vvvmvl __builtin_ve_vl_vfdivd_vvvmvl +#define _vel_vfdivd_vsvmvl __builtin_ve_vl_vfdivd_vsvmvl +#define _vel_vfdivs_vvvl __builtin_ve_vl_vfdivs_vvvl +#define _vel_vfdivs_vvvvl __builtin_ve_vl_vfdivs_vvvvl +#define _vel_vfdivs_vsvl __builtin_ve_vl_vfdivs_vsvl +#define _vel_vfdivs_vsvvl __builtin_ve_vl_vfdivs_vsvvl +#define _vel_vfdivs_vvvmvl __builtin_ve_vl_vfdivs_vvvmvl +#define _vel_vfdivs_vsvmvl __builtin_ve_vl_vfdivs_vsvmvl +#define _vel_vfsqrtd_vvl __builtin_ve_vl_vfsqrtd_vvl +#define _vel_vfsqrtd_vvvl __builtin_ve_vl_vfsqrtd_vvvl +#define _vel_vfsqrts_vvl __builtin_ve_vl_vfsqrts_vvl +#define _vel_vfsqrts_vvvl __builtin_ve_vl_vfsqrts_vvvl +#define _vel_vfcmpd_vvvl __builtin_ve_vl_vfcmpd_vvvl +#define _vel_vfcmpd_vvvvl __builtin_ve_vl_vfcmpd_vvvvl +#define _vel_vfcmpd_vsvl __builtin_ve_vl_vfcmpd_vsvl +#define _vel_vfcmpd_vsvvl __builtin_ve_vl_vfcmpd_vsvvl +#define _vel_vfcmpd_vvvmvl __builtin_ve_vl_vfcmpd_vvvmvl +#define _vel_vfcmpd_vsvmvl __builtin_ve_vl_vfcmpd_vsvmvl +#define _vel_vfcmps_vvvl __builtin_ve_vl_vfcmps_vvvl +#define _vel_vfcmps_vvvvl __builtin_ve_vl_vfcmps_vvvvl +#define _vel_vfcmps_vsvl __builtin_ve_vl_vfcmps_vsvl +#define _vel_vfcmps_vsvvl __builtin_ve_vl_vfcmps_vsvvl +#define _vel_vfcmps_vvvmvl __builtin_ve_vl_vfcmps_vvvmvl +#define _vel_vfcmps_vsvmvl __builtin_ve_vl_vfcmps_vsvmvl +#define _vel_pvfcmp_vvvl __builtin_ve_vl_pvfcmp_vvvl +#define _vel_pvfcmp_vvvvl __builtin_ve_vl_pvfcmp_vvvvl +#define _vel_pvfcmp_vsvl __builtin_ve_vl_pvfcmp_vsvl +#define _vel_pvfcmp_vsvvl __builtin_ve_vl_pvfcmp_vsvvl +#define _vel_pvfcmp_vvvMvl __builtin_ve_vl_pvfcmp_vvvMvl +#define _vel_pvfcmp_vsvMvl __builtin_ve_vl_pvfcmp_vsvMvl +#define _vel_vfmaxd_vvvl __builtin_ve_vl_vfmaxd_vvvl +#define _vel_vfmaxd_vvvvl __builtin_ve_vl_vfmaxd_vvvvl +#define _vel_vfmaxd_vsvl __builtin_ve_vl_vfmaxd_vsvl +#define _vel_vfmaxd_vsvvl __builtin_ve_vl_vfmaxd_vsvvl +#define _vel_vfmaxd_vvvmvl __builtin_ve_vl_vfmaxd_vvvmvl +#define _vel_vfmaxd_vsvmvl __builtin_ve_vl_vfmaxd_vsvmvl +#define _vel_vfmaxs_vvvl __builtin_ve_vl_vfmaxs_vvvl +#define _vel_vfmaxs_vvvvl __builtin_ve_vl_vfmaxs_vvvvl +#define _vel_vfmaxs_vsvl __builtin_ve_vl_vfmaxs_vsvl +#define _vel_vfmaxs_vsvvl __builtin_ve_vl_vfmaxs_vsvvl +#define _vel_vfmaxs_vvvmvl __builtin_ve_vl_vfmaxs_vvvmvl +#define _vel_vfmaxs_vsvmvl __builtin_ve_vl_vfmaxs_vsvmvl +#define _vel_pvfmax_vvvl __builtin_ve_vl_pvfmax_vvvl +#define _vel_pvfmax_vvvvl __builtin_ve_vl_pvfmax_vvvvl +#define _vel_pvfmax_vsvl __builtin_ve_vl_pvfmax_vsvl +#define _vel_pvfmax_vsvvl __builtin_ve_vl_pvfmax_vsvvl +#define _vel_pvfmax_vvvMvl __builtin_ve_vl_pvfmax_vvvMvl +#define _vel_pvfmax_vsvMvl __builtin_ve_vl_pvfmax_vsvMvl +#define _vel_vfmind_vvvl __builtin_ve_vl_vfmind_vvvl +#define _vel_vfmind_vvvvl __builtin_ve_vl_vfmind_vvvvl +#define _vel_vfmind_vsvl __builtin_ve_vl_vfmind_vsvl +#define _vel_vfmind_vsvvl __builtin_ve_vl_vfmind_vsvvl +#define _vel_vfmind_vvvmvl __builtin_ve_vl_vfmind_vvvmvl +#define _vel_vfmind_vsvmvl __builtin_ve_vl_vfmind_vsvmvl +#define _vel_vfmins_vvvl __builtin_ve_vl_vfmins_vvvl +#define _vel_vfmins_vvvvl __builtin_ve_vl_vfmins_vvvvl +#define _vel_vfmins_vsvl __builtin_ve_vl_vfmins_vsvl +#define _vel_vfmins_vsvvl __builtin_ve_vl_vfmins_vsvvl +#define _vel_vfmins_vvvmvl __builtin_ve_vl_vfmins_vvvmvl +#define _vel_vfmins_vsvmvl __builtin_ve_vl_vfmins_vsvmvl +#define _vel_pvfmin_vvvl __builtin_ve_vl_pvfmin_vvvl +#define _vel_pvfmin_vvvvl __builtin_ve_vl_pvfmin_vvvvl +#define _vel_pvfmin_vsvl __builtin_ve_vl_pvfmin_vsvl +#define _vel_pvfmin_vsvvl __builtin_ve_vl_pvfmin_vsvvl +#define _vel_pvfmin_vvvMvl __builtin_ve_vl_pvfmin_vvvMvl +#define _vel_pvfmin_vsvMvl __builtin_ve_vl_pvfmin_vsvMvl +#define _vel_vfmadd_vvvvl __builtin_ve_vl_vfmadd_vvvvl +#define _vel_vfmadd_vvvvvl __builtin_ve_vl_vfmadd_vvvvvl +#define _vel_vfmadd_vsvvl __builtin_ve_vl_vfmadd_vsvvl +#define _vel_vfmadd_vsvvvl __builtin_ve_vl_vfmadd_vsvvvl +#define _vel_vfmadd_vvsvl __builtin_ve_vl_vfmadd_vvsvl +#define _vel_vfmadd_vvsvvl __builtin_ve_vl_vfmadd_vvsvvl +#define _vel_vfmadd_vvvvmvl __builtin_ve_vl_vfmadd_vvvvmvl +#define _vel_vfmadd_vsvvmvl __builtin_ve_vl_vfmadd_vsvvmvl +#define _vel_vfmadd_vvsvmvl __builtin_ve_vl_vfmadd_vvsvmvl +#define _vel_vfmads_vvvvl __builtin_ve_vl_vfmads_vvvvl +#define _vel_vfmads_vvvvvl __builtin_ve_vl_vfmads_vvvvvl +#define _vel_vfmads_vsvvl __builtin_ve_vl_vfmads_vsvvl +#define _vel_vfmads_vsvvvl __builtin_ve_vl_vfmads_vsvvvl +#define _vel_vfmads_vvsvl __builtin_ve_vl_vfmads_vvsvl +#define _vel_vfmads_vvsvvl __builtin_ve_vl_vfmads_vvsvvl +#define _vel_vfmads_vvvvmvl __builtin_ve_vl_vfmads_vvvvmvl +#define _vel_vfmads_vsvvmvl __builtin_ve_vl_vfmads_vsvvmvl +#define _vel_vfmads_vvsvmvl __builtin_ve_vl_vfmads_vvsvmvl +#define _vel_pvfmad_vvvvl __builtin_ve_vl_pvfmad_vvvvl +#define _vel_pvfmad_vvvvvl __builtin_ve_vl_pvfmad_vvvvvl +#define _vel_pvfmad_vsvvl __builtin_ve_vl_pvfmad_vsvvl +#define _vel_pvfmad_vsvvvl __builtin_ve_vl_pvfmad_vsvvvl +#define _vel_pvfmad_vvsvl __builtin_ve_vl_pvfmad_vvsvl +#define _vel_pvfmad_vvsvvl __builtin_ve_vl_pvfmad_vvsvvl +#define _vel_pvfmad_vvvvMvl __builtin_ve_vl_pvfmad_vvvvMvl +#define _vel_pvfmad_vsvvMvl __builtin_ve_vl_pvfmad_vsvvMvl +#define _vel_pvfmad_vvsvMvl __builtin_ve_vl_pvfmad_vvsvMvl +#define _vel_vfmsbd_vvvvl __builtin_ve_vl_vfmsbd_vvvvl +#define _vel_vfmsbd_vvvvvl __builtin_ve_vl_vfmsbd_vvvvvl +#define _vel_vfmsbd_vsvvl __builtin_ve_vl_vfmsbd_vsvvl +#define _vel_vfmsbd_vsvvvl __builtin_ve_vl_vfmsbd_vsvvvl +#define _vel_vfmsbd_vvsvl __builtin_ve_vl_vfmsbd_vvsvl +#define _vel_vfmsbd_vvsvvl __builtin_ve_vl_vfmsbd_vvsvvl +#define _vel_vfmsbd_vvvvmvl __builtin_ve_vl_vfmsbd_vvvvmvl +#define _vel_vfmsbd_vsvvmvl __builtin_ve_vl_vfmsbd_vsvvmvl +#define _vel_vfmsbd_vvsvmvl __builtin_ve_vl_vfmsbd_vvsvmvl +#define _vel_vfmsbs_vvvvl __builtin_ve_vl_vfmsbs_vvvvl +#define _vel_vfmsbs_vvvvvl __builtin_ve_vl_vfmsbs_vvvvvl +#define _vel_vfmsbs_vsvvl __builtin_ve_vl_vfmsbs_vsvvl +#define _vel_vfmsbs_vsvvvl __builtin_ve_vl_vfmsbs_vsvvvl +#define _vel_vfmsbs_vvsvl __builtin_ve_vl_vfmsbs_vvsvl +#define _vel_vfmsbs_vvsvvl __builtin_ve_vl_vfmsbs_vvsvvl +#define _vel_vfmsbs_vvvvmvl __builtin_ve_vl_vfmsbs_vvvvmvl +#define _vel_vfmsbs_vsvvmvl __builtin_ve_vl_vfmsbs_vsvvmvl +#define _vel_vfmsbs_vvsvmvl __builtin_ve_vl_vfmsbs_vvsvmvl +#define _vel_pvfmsb_vvvvl __builtin_ve_vl_pvfmsb_vvvvl +#define _vel_pvfmsb_vvvvvl __builtin_ve_vl_pvfmsb_vvvvvl +#define _vel_pvfmsb_vsvvl __builtin_ve_vl_pvfmsb_vsvvl +#define _vel_pvfmsb_vsvvvl __builtin_ve_vl_pvfmsb_vsvvvl +#define _vel_pvfmsb_vvsvl __builtin_ve_vl_pvfmsb_vvsvl +#define _vel_pvfmsb_vvsvvl __builtin_ve_vl_pvfmsb_vvsvvl +#define _vel_pvfmsb_vvvvMvl __builtin_ve_vl_pvfmsb_vvvvMvl +#define _vel_pvfmsb_vsvvMvl __builtin_ve_vl_pvfmsb_vsvvMvl +#define _vel_pvfmsb_vvsvMvl __builtin_ve_vl_pvfmsb_vvsvMvl +#define _vel_vfnmadd_vvvvl __builtin_ve_vl_vfnmadd_vvvvl +#define _vel_vfnmadd_vvvvvl __builtin_ve_vl_vfnmadd_vvvvvl +#define _vel_vfnmadd_vsvvl __builtin_ve_vl_vfnmadd_vsvvl +#define _vel_vfnmadd_vsvvvl __builtin_ve_vl_vfnmadd_vsvvvl +#define _vel_vfnmadd_vvsvl __builtin_ve_vl_vfnmadd_vvsvl +#define _vel_vfnmadd_vvsvvl __builtin_ve_vl_vfnmadd_vvsvvl +#define _vel_vfnmadd_vvvvmvl __builtin_ve_vl_vfnmadd_vvvvmvl +#define _vel_vfnmadd_vsvvmvl __builtin_ve_vl_vfnmadd_vsvvmvl +#define _vel_vfnmadd_vvsvmvl __builtin_ve_vl_vfnmadd_vvsvmvl +#define _vel_vfnmads_vvvvl __builtin_ve_vl_vfnmads_vvvvl +#define _vel_vfnmads_vvvvvl __builtin_ve_vl_vfnmads_vvvvvl +#define _vel_vfnmads_vsvvl __builtin_ve_vl_vfnmads_vsvvl +#define _vel_vfnmads_vsvvvl __builtin_ve_vl_vfnmads_vsvvvl +#define _vel_vfnmads_vvsvl __builtin_ve_vl_vfnmads_vvsvl +#define _vel_vfnmads_vvsvvl __builtin_ve_vl_vfnmads_vvsvvl +#define _vel_vfnmads_vvvvmvl __builtin_ve_vl_vfnmads_vvvvmvl +#define _vel_vfnmads_vsvvmvl __builtin_ve_vl_vfnmads_vsvvmvl +#define _vel_vfnmads_vvsvmvl __builtin_ve_vl_vfnmads_vvsvmvl +#define _vel_pvfnmad_vvvvl __builtin_ve_vl_pvfnmad_vvvvl +#define _vel_pvfnmad_vvvvvl __builtin_ve_vl_pvfnmad_vvvvvl +#define _vel_pvfnmad_vsvvl __builtin_ve_vl_pvfnmad_vsvvl +#define _vel_pvfnmad_vsvvvl __builtin_ve_vl_pvfnmad_vsvvvl +#define _vel_pvfnmad_vvsvl __builtin_ve_vl_pvfnmad_vvsvl +#define _vel_pvfnmad_vvsvvl __builtin_ve_vl_pvfnmad_vvsvvl +#define _vel_pvfnmad_vvvvMvl __builtin_ve_vl_pvfnmad_vvvvMvl +#define _vel_pvfnmad_vsvvMvl __builtin_ve_vl_pvfnmad_vsvvMvl +#define _vel_pvfnmad_vvsvMvl __builtin_ve_vl_pvfnmad_vvsvMvl +#define _vel_vfnmsbd_vvvvl __builtin_ve_vl_vfnmsbd_vvvvl +#define _vel_vfnmsbd_vvvvvl __builtin_ve_vl_vfnmsbd_vvvvvl +#define _vel_vfnmsbd_vsvvl __builtin_ve_vl_vfnmsbd_vsvvl +#define _vel_vfnmsbd_vsvvvl __builtin_ve_vl_vfnmsbd_vsvvvl +#define _vel_vfnmsbd_vvsvl __builtin_ve_vl_vfnmsbd_vvsvl +#define _vel_vfnmsbd_vvsvvl __builtin_ve_vl_vfnmsbd_vvsvvl +#define _vel_vfnmsbd_vvvvmvl __builtin_ve_vl_vfnmsbd_vvvvmvl +#define _vel_vfnmsbd_vsvvmvl __builtin_ve_vl_vfnmsbd_vsvvmvl +#define _vel_vfnmsbd_vvsvmvl __builtin_ve_vl_vfnmsbd_vvsvmvl +#define _vel_vfnmsbs_vvvvl __builtin_ve_vl_vfnmsbs_vvvvl +#define _vel_vfnmsbs_vvvvvl __builtin_ve_vl_vfnmsbs_vvvvvl +#define _vel_vfnmsbs_vsvvl __builtin_ve_vl_vfnmsbs_vsvvl +#define _vel_vfnmsbs_vsvvvl __builtin_ve_vl_vfnmsbs_vsvvvl +#define _vel_vfnmsbs_vvsvl __builtin_ve_vl_vfnmsbs_vvsvl +#define _vel_vfnmsbs_vvsvvl __builtin_ve_vl_vfnmsbs_vvsvvl +#define _vel_vfnmsbs_vvvvmvl __builtin_ve_vl_vfnmsbs_vvvvmvl +#define _vel_vfnmsbs_vsvvmvl __builtin_ve_vl_vfnmsbs_vsvvmvl +#define _vel_vfnmsbs_vvsvmvl __builtin_ve_vl_vfnmsbs_vvsvmvl +#define _vel_pvfnmsb_vvvvl __builtin_ve_vl_pvfnmsb_vvvvl +#define _vel_pvfnmsb_vvvvvl __builtin_ve_vl_pvfnmsb_vvvvvl +#define _vel_pvfnmsb_vsvvl __builtin_ve_vl_pvfnmsb_vsvvl +#define _vel_pvfnmsb_vsvvvl __builtin_ve_vl_pvfnmsb_vsvvvl +#define _vel_pvfnmsb_vvsvl __builtin_ve_vl_pvfnmsb_vvsvl +#define _vel_pvfnmsb_vvsvvl __builtin_ve_vl_pvfnmsb_vvsvvl +#define _vel_pvfnmsb_vvvvMvl __builtin_ve_vl_pvfnmsb_vvvvMvl +#define _vel_pvfnmsb_vsvvMvl __builtin_ve_vl_pvfnmsb_vsvvMvl +#define _vel_pvfnmsb_vvsvMvl __builtin_ve_vl_pvfnmsb_vvsvMvl +#define _vel_vrcpd_vvl __builtin_ve_vl_vrcpd_vvl +#define _vel_vrcpd_vvvl __builtin_ve_vl_vrcpd_vvvl +#define _vel_vrcps_vvl __builtin_ve_vl_vrcps_vvl +#define _vel_vrcps_vvvl __builtin_ve_vl_vrcps_vvvl +#define _vel_pvrcp_vvl __builtin_ve_vl_pvrcp_vvl +#define _vel_pvrcp_vvvl __builtin_ve_vl_pvrcp_vvvl +#define _vel_vrsqrtd_vvl __builtin_ve_vl_vrsqrtd_vvl +#define _vel_vrsqrtd_vvvl __builtin_ve_vl_vrsqrtd_vvvl +#define _vel_vrsqrts_vvl __builtin_ve_vl_vrsqrts_vvl +#define _vel_vrsqrts_vvvl __builtin_ve_vl_vrsqrts_vvvl +#define _vel_pvrsqrt_vvl __builtin_ve_vl_pvrsqrt_vvl +#define _vel_pvrsqrt_vvvl __builtin_ve_vl_pvrsqrt_vvvl +#define _vel_vrsqrtdnex_vvl __builtin_ve_vl_vrsqrtdnex_vvl +#define _vel_vrsqrtdnex_vvvl __builtin_ve_vl_vrsqrtdnex_vvvl +#define _vel_vrsqrtsnex_vvl __builtin_ve_vl_vrsqrtsnex_vvl +#define _vel_vrsqrtsnex_vvvl __builtin_ve_vl_vrsqrtsnex_vvvl +#define _vel_pvrsqrtnex_vvl __builtin_ve_vl_pvrsqrtnex_vvl +#define _vel_pvrsqrtnex_vvvl __builtin_ve_vl_pvrsqrtnex_vvvl +#define _vel_vcvtwdsx_vvl __builtin_ve_vl_vcvtwdsx_vvl +#define _vel_vcvtwdsx_vvvl __builtin_ve_vl_vcvtwdsx_vvvl +#define _vel_vcvtwdsx_vvmvl __builtin_ve_vl_vcvtwdsx_vvmvl +#define _vel_vcvtwdsxrz_vvl __builtin_ve_vl_vcvtwdsxrz_vvl +#define _vel_vcvtwdsxrz_vvvl __builtin_ve_vl_vcvtwdsxrz_vvvl +#define _vel_vcvtwdsxrz_vvmvl __builtin_ve_vl_vcvtwdsxrz_vvmvl +#define _vel_vcvtwdzx_vvl __builtin_ve_vl_vcvtwdzx_vvl +#define _vel_vcvtwdzx_vvvl __builtin_ve_vl_vcvtwdzx_vvvl +#define _vel_vcvtwdzx_vvmvl __builtin_ve_vl_vcvtwdzx_vvmvl +#define _vel_vcvtwdzxrz_vvl __builtin_ve_vl_vcvtwdzxrz_vvl +#define _vel_vcvtwdzxrz_vvvl __builtin_ve_vl_vcvtwdzxrz_vvvl +#define _vel_vcvtwdzxrz_vvmvl __builtin_ve_vl_vcvtwdzxrz_vvmvl +#define _vel_vcvtwssx_vvl __builtin_ve_vl_vcvtwssx_vvl +#define _vel_vcvtwssx_vvvl __builtin_ve_vl_vcvtwssx_vvvl +#define _vel_vcvtwssx_vvmvl __builtin_ve_vl_vcvtwssx_vvmvl +#define _vel_vcvtwssxrz_vvl __builtin_ve_vl_vcvtwssxrz_vvl +#define _vel_vcvtwssxrz_vvvl __builtin_ve_vl_vcvtwssxrz_vvvl +#define _vel_vcvtwssxrz_vvmvl __builtin_ve_vl_vcvtwssxrz_vvmvl +#define _vel_vcvtwszx_vvl __builtin_ve_vl_vcvtwszx_vvl +#define _vel_vcvtwszx_vvvl __builtin_ve_vl_vcvtwszx_vvvl +#define _vel_vcvtwszx_vvmvl __builtin_ve_vl_vcvtwszx_vvmvl +#define _vel_vcvtwszxrz_vvl __builtin_ve_vl_vcvtwszxrz_vvl +#define _vel_vcvtwszxrz_vvvl __builtin_ve_vl_vcvtwszxrz_vvvl +#define _vel_vcvtwszxrz_vvmvl __builtin_ve_vl_vcvtwszxrz_vvmvl +#define _vel_pvcvtws_vvl __builtin_ve_vl_pvcvtws_vvl +#define _vel_pvcvtws_vvvl __builtin_ve_vl_pvcvtws_vvvl +#define _vel_pvcvtws_vvMvl __builtin_ve_vl_pvcvtws_vvMvl +#define _vel_pvcvtwsrz_vvl __builtin_ve_vl_pvcvtwsrz_vvl +#define _vel_pvcvtwsrz_vvvl __builtin_ve_vl_pvcvtwsrz_vvvl +#define _vel_pvcvtwsrz_vvMvl __builtin_ve_vl_pvcvtwsrz_vvMvl +#define _vel_vcvtld_vvl __builtin_ve_vl_vcvtld_vvl +#define _vel_vcvtld_vvvl __builtin_ve_vl_vcvtld_vvvl +#define _vel_vcvtld_vvmvl __builtin_ve_vl_vcvtld_vvmvl +#define _vel_vcvtldrz_vvl __builtin_ve_vl_vcvtldrz_vvl +#define _vel_vcvtldrz_vvvl __builtin_ve_vl_vcvtldrz_vvvl +#define _vel_vcvtldrz_vvmvl __builtin_ve_vl_vcvtldrz_vvmvl +#define _vel_vcvtdw_vvl __builtin_ve_vl_vcvtdw_vvl +#define _vel_vcvtdw_vvvl __builtin_ve_vl_vcvtdw_vvvl +#define _vel_vcvtsw_vvl __builtin_ve_vl_vcvtsw_vvl +#define _vel_vcvtsw_vvvl __builtin_ve_vl_vcvtsw_vvvl +#define _vel_pvcvtsw_vvl __builtin_ve_vl_pvcvtsw_vvl +#define _vel_pvcvtsw_vvvl __builtin_ve_vl_pvcvtsw_vvvl +#define _vel_vcvtdl_vvl __builtin_ve_vl_vcvtdl_vvl +#define _vel_vcvtdl_vvvl __builtin_ve_vl_vcvtdl_vvvl +#define _vel_vcvtds_vvl __builtin_ve_vl_vcvtds_vvl +#define _vel_vcvtds_vvvl __builtin_ve_vl_vcvtds_vvvl +#define _vel_vcvtsd_vvl __builtin_ve_vl_vcvtsd_vvl +#define _vel_vcvtsd_vvvl __builtin_ve_vl_vcvtsd_vvvl +#define _vel_vmrg_vvvml __builtin_ve_vl_vmrg_vvvml +#define _vel_vmrg_vvvmvl __builtin_ve_vl_vmrg_vvvmvl +#define _vel_vmrg_vsvml __builtin_ve_vl_vmrg_vsvml +#define _vel_vmrg_vsvmvl __builtin_ve_vl_vmrg_vsvmvl +#define _vel_vmrgw_vvvMl __builtin_ve_vl_vmrgw_vvvMl +#define _vel_vmrgw_vvvMvl __builtin_ve_vl_vmrgw_vvvMvl +#define _vel_vmrgw_vsvMl __builtin_ve_vl_vmrgw_vsvMl +#define _vel_vmrgw_vsvMvl __builtin_ve_vl_vmrgw_vsvMvl +#define _vel_vshf_vvvsl __builtin_ve_vl_vshf_vvvsl +#define _vel_vshf_vvvsvl __builtin_ve_vl_vshf_vvvsvl +#define _vel_vcp_vvmvl __builtin_ve_vl_vcp_vvmvl +#define _vel_vex_vvmvl __builtin_ve_vl_vex_vvmvl +#define _vel_vfmklat_ml __builtin_ve_vl_vfmklat_ml +#define _vel_vfmklaf_ml __builtin_ve_vl_vfmklaf_ml +#define _vel_pvfmkat_Ml __builtin_ve_vl_pvfmkat_Ml +#define _vel_pvfmkaf_Ml __builtin_ve_vl_pvfmkaf_Ml +#define _vel_vfmklgt_mvl __builtin_ve_vl_vfmklgt_mvl +#define _vel_vfmklgt_mvml __builtin_ve_vl_vfmklgt_mvml +#define _vel_vfmkllt_mvl __builtin_ve_vl_vfmkllt_mvl +#define _vel_vfmkllt_mvml __builtin_ve_vl_vfmkllt_mvml +#define _vel_vfmklne_mvl __builtin_ve_vl_vfmklne_mvl +#define _vel_vfmklne_mvml __builtin_ve_vl_vfmklne_mvml +#define _vel_vfmkleq_mvl __builtin_ve_vl_vfmkleq_mvl +#define _vel_vfmkleq_mvml __builtin_ve_vl_vfmkleq_mvml +#define _vel_vfmklge_mvl __builtin_ve_vl_vfmklge_mvl +#define _vel_vfmklge_mvml __builtin_ve_vl_vfmklge_mvml +#define _vel_vfmklle_mvl __builtin_ve_vl_vfmklle_mvl +#define _vel_vfmklle_mvml __builtin_ve_vl_vfmklle_mvml +#define _vel_vfmklnum_mvl __builtin_ve_vl_vfmklnum_mvl +#define _vel_vfmklnum_mvml __builtin_ve_vl_vfmklnum_mvml +#define _vel_vfmklnan_mvl __builtin_ve_vl_vfmklnan_mvl +#define _vel_vfmklnan_mvml __builtin_ve_vl_vfmklnan_mvml +#define _vel_vfmklgtnan_mvl __builtin_ve_vl_vfmklgtnan_mvl +#define _vel_vfmklgtnan_mvml __builtin_ve_vl_vfmklgtnan_mvml +#define _vel_vfmklltnan_mvl __builtin_ve_vl_vfmklltnan_mvl +#define _vel_vfmklltnan_mvml __builtin_ve_vl_vfmklltnan_mvml +#define _vel_vfmklnenan_mvl __builtin_ve_vl_vfmklnenan_mvl +#define _vel_vfmklnenan_mvml __builtin_ve_vl_vfmklnenan_mvml +#define _vel_vfmkleqnan_mvl __builtin_ve_vl_vfmkleqnan_mvl +#define _vel_vfmkleqnan_mvml __builtin_ve_vl_vfmkleqnan_mvml +#define _vel_vfmklgenan_mvl __builtin_ve_vl_vfmklgenan_mvl +#define _vel_vfmklgenan_mvml __builtin_ve_vl_vfmklgenan_mvml +#define _vel_vfmkllenan_mvl __builtin_ve_vl_vfmkllenan_mvl +#define _vel_vfmkllenan_mvml __builtin_ve_vl_vfmkllenan_mvml +#define _vel_vfmkwgt_mvl __builtin_ve_vl_vfmkwgt_mvl +#define _vel_vfmkwgt_mvml __builtin_ve_vl_vfmkwgt_mvml +#define _vel_vfmkwlt_mvl __builtin_ve_vl_vfmkwlt_mvl +#define _vel_vfmkwlt_mvml __builtin_ve_vl_vfmkwlt_mvml +#define _vel_vfmkwne_mvl __builtin_ve_vl_vfmkwne_mvl +#define _vel_vfmkwne_mvml __builtin_ve_vl_vfmkwne_mvml +#define _vel_vfmkweq_mvl __builtin_ve_vl_vfmkweq_mvl +#define _vel_vfmkweq_mvml __builtin_ve_vl_vfmkweq_mvml +#define _vel_vfmkwge_mvl __builtin_ve_vl_vfmkwge_mvl +#define _vel_vfmkwge_mvml __builtin_ve_vl_vfmkwge_mvml +#define _vel_vfmkwle_mvl __builtin_ve_vl_vfmkwle_mvl +#define _vel_vfmkwle_mvml __builtin_ve_vl_vfmkwle_mvml +#define _vel_vfmkwnum_mvl __builtin_ve_vl_vfmkwnum_mvl +#define _vel_vfmkwnum_mvml __builtin_ve_vl_vfmkwnum_mvml +#define _vel_vfmkwnan_mvl __builtin_ve_vl_vfmkwnan_mvl +#define _vel_vfmkwnan_mvml __builtin_ve_vl_vfmkwnan_mvml +#define _vel_vfmkwgtnan_mvl __builtin_ve_vl_vfmkwgtnan_mvl +#define _vel_vfmkwgtnan_mvml __builtin_ve_vl_vfmkwgtnan_mvml +#define _vel_vfmkwltnan_mvl __builtin_ve_vl_vfmkwltnan_mvl +#define _vel_vfmkwltnan_mvml __builtin_ve_vl_vfmkwltnan_mvml +#define _vel_vfmkwnenan_mvl __builtin_ve_vl_vfmkwnenan_mvl +#define _vel_vfmkwnenan_mvml __builtin_ve_vl_vfmkwnenan_mvml +#define _vel_vfmkweqnan_mvl __builtin_ve_vl_vfmkweqnan_mvl +#define _vel_vfmkweqnan_mvml __builtin_ve_vl_vfmkweqnan_mvml +#define _vel_vfmkwgenan_mvl __builtin_ve_vl_vfmkwgenan_mvl +#define _vel_vfmkwgenan_mvml __builtin_ve_vl_vfmkwgenan_mvml +#define _vel_vfmkwlenan_mvl __builtin_ve_vl_vfmkwlenan_mvl +#define _vel_vfmkwlenan_mvml __builtin_ve_vl_vfmkwlenan_mvml +#define _vel_pvfmkwlogt_mvl __builtin_ve_vl_pvfmkwlogt_mvl +#define _vel_pvfmkwupgt_mvl __builtin_ve_vl_pvfmkwupgt_mvl +#define _vel_pvfmkwlogt_mvml __builtin_ve_vl_pvfmkwlogt_mvml +#define _vel_pvfmkwupgt_mvml __builtin_ve_vl_pvfmkwupgt_mvml +#define _vel_pvfmkwlolt_mvl __builtin_ve_vl_pvfmkwlolt_mvl +#define _vel_pvfmkwuplt_mvl __builtin_ve_vl_pvfmkwuplt_mvl +#define _vel_pvfmkwlolt_mvml __builtin_ve_vl_pvfmkwlolt_mvml +#define _vel_pvfmkwuplt_mvml __builtin_ve_vl_pvfmkwuplt_mvml +#define _vel_pvfmkwlone_mvl __builtin_ve_vl_pvfmkwlone_mvl +#define _vel_pvfmkwupne_mvl __builtin_ve_vl_pvfmkwupne_mvl +#define _vel_pvfmkwlone_mvml __builtin_ve_vl_pvfmkwlone_mvml +#define _vel_pvfmkwupne_mvml __builtin_ve_vl_pvfmkwupne_mvml +#define _vel_pvfmkwloeq_mvl __builtin_ve_vl_pvfmkwloeq_mvl +#define _vel_pvfmkwupeq_mvl __builtin_ve_vl_pvfmkwupeq_mvl +#define _vel_pvfmkwloeq_mvml __builtin_ve_vl_pvfmkwloeq_mvml +#define _vel_pvfmkwupeq_mvml __builtin_ve_vl_pvfmkwupeq_mvml +#define _vel_pvfmkwloge_mvl __builtin_ve_vl_pvfmkwloge_mvl +#define _vel_pvfmkwupge_mvl __builtin_ve_vl_pvfmkwupge_mvl +#define _vel_pvfmkwloge_mvml __builtin_ve_vl_pvfmkwloge_mvml +#define _vel_pvfmkwupge_mvml __builtin_ve_vl_pvfmkwupge_mvml +#define _vel_pvfmkwlole_mvl __builtin_ve_vl_pvfmkwlole_mvl +#define _vel_pvfmkwuple_mvl __builtin_ve_vl_pvfmkwuple_mvl +#define _vel_pvfmkwlole_mvml __builtin_ve_vl_pvfmkwlole_mvml +#define _vel_pvfmkwuple_mvml __builtin_ve_vl_pvfmkwuple_mvml +#define _vel_pvfmkwlonum_mvl __builtin_ve_vl_pvfmkwlonum_mvl +#define _vel_pvfmkwupnum_mvl __builtin_ve_vl_pvfmkwupnum_mvl +#define _vel_pvfmkwlonum_mvml __builtin_ve_vl_pvfmkwlonum_mvml +#define _vel_pvfmkwupnum_mvml __builtin_ve_vl_pvfmkwupnum_mvml +#define _vel_pvfmkwlonan_mvl __builtin_ve_vl_pvfmkwlonan_mvl +#define _vel_pvfmkwupnan_mvl __builtin_ve_vl_pvfmkwupnan_mvl +#define _vel_pvfmkwlonan_mvml __builtin_ve_vl_pvfmkwlonan_mvml +#define _vel_pvfmkwupnan_mvml __builtin_ve_vl_pvfmkwupnan_mvml +#define _vel_pvfmkwlogtnan_mvl __builtin_ve_vl_pvfmkwlogtnan_mvl +#define _vel_pvfmkwupgtnan_mvl __builtin_ve_vl_pvfmkwupgtnan_mvl +#define _vel_pvfmkwlogtnan_mvml __builtin_ve_vl_pvfmkwlogtnan_mvml +#define _vel_pvfmkwupgtnan_mvml __builtin_ve_vl_pvfmkwupgtnan_mvml +#define _vel_pvfmkwloltnan_mvl __builtin_ve_vl_pvfmkwloltnan_mvl +#define _vel_pvfmkwupltnan_mvl __builtin_ve_vl_pvfmkwupltnan_mvl +#define _vel_pvfmkwloltnan_mvml __builtin_ve_vl_pvfmkwloltnan_mvml +#define _vel_pvfmkwupltnan_mvml __builtin_ve_vl_pvfmkwupltnan_mvml +#define _vel_pvfmkwlonenan_mvl __builtin_ve_vl_pvfmkwlonenan_mvl +#define _vel_pvfmkwupnenan_mvl __builtin_ve_vl_pvfmkwupnenan_mvl +#define _vel_pvfmkwlonenan_mvml __builtin_ve_vl_pvfmkwlonenan_mvml +#define _vel_pvfmkwupnenan_mvml __builtin_ve_vl_pvfmkwupnenan_mvml +#define _vel_pvfmkwloeqnan_mvl __builtin_ve_vl_pvfmkwloeqnan_mvl +#define _vel_pvfmkwupeqnan_mvl __builtin_ve_vl_pvfmkwupeqnan_mvl +#define _vel_pvfmkwloeqnan_mvml __builtin_ve_vl_pvfmkwloeqnan_mvml +#define _vel_pvfmkwupeqnan_mvml __builtin_ve_vl_pvfmkwupeqnan_mvml +#define _vel_pvfmkwlogenan_mvl __builtin_ve_vl_pvfmkwlogenan_mvl +#define _vel_pvfmkwupgenan_mvl __builtin_ve_vl_pvfmkwupgenan_mvl +#define _vel_pvfmkwlogenan_mvml __builtin_ve_vl_pvfmkwlogenan_mvml +#define _vel_pvfmkwupgenan_mvml __builtin_ve_vl_pvfmkwupgenan_mvml +#define _vel_pvfmkwlolenan_mvl __builtin_ve_vl_pvfmkwlolenan_mvl +#define _vel_pvfmkwuplenan_mvl __builtin_ve_vl_pvfmkwuplenan_mvl +#define _vel_pvfmkwlolenan_mvml __builtin_ve_vl_pvfmkwlolenan_mvml +#define _vel_pvfmkwuplenan_mvml __builtin_ve_vl_pvfmkwuplenan_mvml +#define _vel_pvfmkwgt_Mvl __builtin_ve_vl_pvfmkwgt_Mvl +#define _vel_pvfmkwgt_MvMl __builtin_ve_vl_pvfmkwgt_MvMl +#define _vel_pvfmkwlt_Mvl __builtin_ve_vl_pvfmkwlt_Mvl +#define _vel_pvfmkwlt_MvMl __builtin_ve_vl_pvfmkwlt_MvMl +#define _vel_pvfmkwne_Mvl __builtin_ve_vl_pvfmkwne_Mvl +#define _vel_pvfmkwne_MvMl __builtin_ve_vl_pvfmkwne_MvMl +#define _vel_pvfmkweq_Mvl __builtin_ve_vl_pvfmkweq_Mvl +#define _vel_pvfmkweq_MvMl __builtin_ve_vl_pvfmkweq_MvMl +#define _vel_pvfmkwge_Mvl __builtin_ve_vl_pvfmkwge_Mvl +#define _vel_pvfmkwge_MvMl __builtin_ve_vl_pvfmkwge_MvMl +#define _vel_pvfmkwle_Mvl __builtin_ve_vl_pvfmkwle_Mvl +#define _vel_pvfmkwle_MvMl __builtin_ve_vl_pvfmkwle_MvMl +#define _vel_pvfmkwnum_Mvl __builtin_ve_vl_pvfmkwnum_Mvl +#define _vel_pvfmkwnum_MvMl __builtin_ve_vl_pvfmkwnum_MvMl +#define _vel_pvfmkwnan_Mvl __builtin_ve_vl_pvfmkwnan_Mvl +#define _vel_pvfmkwnan_MvMl __builtin_ve_vl_pvfmkwnan_MvMl +#define _vel_pvfmkwgtnan_Mvl __builtin_ve_vl_pvfmkwgtnan_Mvl +#define _vel_pvfmkwgtnan_MvMl __builtin_ve_vl_pvfmkwgtnan_MvMl +#define _vel_pvfmkwltnan_Mvl __builtin_ve_vl_pvfmkwltnan_Mvl +#define _vel_pvfmkwltnan_MvMl __builtin_ve_vl_pvfmkwltnan_MvMl +#define _vel_pvfmkwnenan_Mvl __builtin_ve_vl_pvfmkwnenan_Mvl +#define _vel_pvfmkwnenan_MvMl __builtin_ve_vl_pvfmkwnenan_MvMl +#define _vel_pvfmkweqnan_Mvl __builtin_ve_vl_pvfmkweqnan_Mvl +#define _vel_pvfmkweqnan_MvMl __builtin_ve_vl_pvfmkweqnan_MvMl +#define _vel_pvfmkwgenan_Mvl __builtin_ve_vl_pvfmkwgenan_Mvl +#define _vel_pvfmkwgenan_MvMl __builtin_ve_vl_pvfmkwgenan_MvMl +#define _vel_pvfmkwlenan_Mvl __builtin_ve_vl_pvfmkwlenan_Mvl +#define _vel_pvfmkwlenan_MvMl __builtin_ve_vl_pvfmkwlenan_MvMl +#define _vel_vfmkdgt_mvl __builtin_ve_vl_vfmkdgt_mvl +#define _vel_vfmkdgt_mvml __builtin_ve_vl_vfmkdgt_mvml +#define _vel_vfmkdlt_mvl __builtin_ve_vl_vfmkdlt_mvl +#define _vel_vfmkdlt_mvml __builtin_ve_vl_vfmkdlt_mvml +#define _vel_vfmkdne_mvl __builtin_ve_vl_vfmkdne_mvl +#define _vel_vfmkdne_mvml __builtin_ve_vl_vfmkdne_mvml +#define _vel_vfmkdeq_mvl __builtin_ve_vl_vfmkdeq_mvl +#define _vel_vfmkdeq_mvml __builtin_ve_vl_vfmkdeq_mvml +#define _vel_vfmkdge_mvl __builtin_ve_vl_vfmkdge_mvl +#define _vel_vfmkdge_mvml __builtin_ve_vl_vfmkdge_mvml +#define _vel_vfmkdle_mvl __builtin_ve_vl_vfmkdle_mvl +#define _vel_vfmkdle_mvml __builtin_ve_vl_vfmkdle_mvml +#define _vel_vfmkdnum_mvl __builtin_ve_vl_vfmkdnum_mvl +#define _vel_vfmkdnum_mvml __builtin_ve_vl_vfmkdnum_mvml +#define _vel_vfmkdnan_mvl __builtin_ve_vl_vfmkdnan_mvl +#define _vel_vfmkdnan_mvml __builtin_ve_vl_vfmkdnan_mvml +#define _vel_vfmkdgtnan_mvl __builtin_ve_vl_vfmkdgtnan_mvl +#define _vel_vfmkdgtnan_mvml __builtin_ve_vl_vfmkdgtnan_mvml +#define _vel_vfmkdltnan_mvl __builtin_ve_vl_vfmkdltnan_mvl +#define _vel_vfmkdltnan_mvml __builtin_ve_vl_vfmkdltnan_mvml +#define _vel_vfmkdnenan_mvl __builtin_ve_vl_vfmkdnenan_mvl +#define _vel_vfmkdnenan_mvml __builtin_ve_vl_vfmkdnenan_mvml +#define _vel_vfmkdeqnan_mvl __builtin_ve_vl_vfmkdeqnan_mvl +#define _vel_vfmkdeqnan_mvml __builtin_ve_vl_vfmkdeqnan_mvml +#define _vel_vfmkdgenan_mvl __builtin_ve_vl_vfmkdgenan_mvl +#define _vel_vfmkdgenan_mvml __builtin_ve_vl_vfmkdgenan_mvml +#define _vel_vfmkdlenan_mvl __builtin_ve_vl_vfmkdlenan_mvl +#define _vel_vfmkdlenan_mvml __builtin_ve_vl_vfmkdlenan_mvml +#define _vel_vfmksgt_mvl __builtin_ve_vl_vfmksgt_mvl +#define _vel_vfmksgt_mvml __builtin_ve_vl_vfmksgt_mvml +#define _vel_vfmkslt_mvl __builtin_ve_vl_vfmkslt_mvl +#define _vel_vfmkslt_mvml __builtin_ve_vl_vfmkslt_mvml +#define _vel_vfmksne_mvl __builtin_ve_vl_vfmksne_mvl +#define _vel_vfmksne_mvml __builtin_ve_vl_vfmksne_mvml +#define _vel_vfmkseq_mvl __builtin_ve_vl_vfmkseq_mvl +#define _vel_vfmkseq_mvml __builtin_ve_vl_vfmkseq_mvml +#define _vel_vfmksge_mvl __builtin_ve_vl_vfmksge_mvl +#define _vel_vfmksge_mvml __builtin_ve_vl_vfmksge_mvml +#define _vel_vfmksle_mvl __builtin_ve_vl_vfmksle_mvl +#define _vel_vfmksle_mvml __builtin_ve_vl_vfmksle_mvml +#define _vel_vfmksnum_mvl __builtin_ve_vl_vfmksnum_mvl +#define _vel_vfmksnum_mvml __builtin_ve_vl_vfmksnum_mvml +#define _vel_vfmksnan_mvl __builtin_ve_vl_vfmksnan_mvl +#define _vel_vfmksnan_mvml __builtin_ve_vl_vfmksnan_mvml +#define _vel_vfmksgtnan_mvl __builtin_ve_vl_vfmksgtnan_mvl +#define _vel_vfmksgtnan_mvml __builtin_ve_vl_vfmksgtnan_mvml +#define _vel_vfmksltnan_mvl __builtin_ve_vl_vfmksltnan_mvl +#define _vel_vfmksltnan_mvml __builtin_ve_vl_vfmksltnan_mvml +#define _vel_vfmksnenan_mvl __builtin_ve_vl_vfmksnenan_mvl +#define _vel_vfmksnenan_mvml __builtin_ve_vl_vfmksnenan_mvml +#define _vel_vfmkseqnan_mvl __builtin_ve_vl_vfmkseqnan_mvl +#define _vel_vfmkseqnan_mvml __builtin_ve_vl_vfmkseqnan_mvml +#define _vel_vfmksgenan_mvl __builtin_ve_vl_vfmksgenan_mvl +#define _vel_vfmksgenan_mvml __builtin_ve_vl_vfmksgenan_mvml +#define _vel_vfmkslenan_mvl __builtin_ve_vl_vfmkslenan_mvl +#define _vel_vfmkslenan_mvml __builtin_ve_vl_vfmkslenan_mvml +#define _vel_pvfmkslogt_mvl __builtin_ve_vl_pvfmkslogt_mvl +#define _vel_pvfmksupgt_mvl __builtin_ve_vl_pvfmksupgt_mvl +#define _vel_pvfmkslogt_mvml __builtin_ve_vl_pvfmkslogt_mvml +#define _vel_pvfmksupgt_mvml __builtin_ve_vl_pvfmksupgt_mvml +#define _vel_pvfmkslolt_mvl __builtin_ve_vl_pvfmkslolt_mvl +#define _vel_pvfmksuplt_mvl __builtin_ve_vl_pvfmksuplt_mvl +#define _vel_pvfmkslolt_mvml __builtin_ve_vl_pvfmkslolt_mvml +#define _vel_pvfmksuplt_mvml __builtin_ve_vl_pvfmksuplt_mvml +#define _vel_pvfmkslone_mvl __builtin_ve_vl_pvfmkslone_mvl +#define _vel_pvfmksupne_mvl __builtin_ve_vl_pvfmksupne_mvl +#define _vel_pvfmkslone_mvml __builtin_ve_vl_pvfmkslone_mvml +#define _vel_pvfmksupne_mvml __builtin_ve_vl_pvfmksupne_mvml +#define _vel_pvfmksloeq_mvl __builtin_ve_vl_pvfmksloeq_mvl +#define _vel_pvfmksupeq_mvl __builtin_ve_vl_pvfmksupeq_mvl +#define _vel_pvfmksloeq_mvml __builtin_ve_vl_pvfmksloeq_mvml +#define _vel_pvfmksupeq_mvml __builtin_ve_vl_pvfmksupeq_mvml +#define _vel_pvfmksloge_mvl __builtin_ve_vl_pvfmksloge_mvl +#define _vel_pvfmksupge_mvl __builtin_ve_vl_pvfmksupge_mvl +#define _vel_pvfmksloge_mvml __builtin_ve_vl_pvfmksloge_mvml +#define _vel_pvfmksupge_mvml __builtin_ve_vl_pvfmksupge_mvml +#define _vel_pvfmkslole_mvl __builtin_ve_vl_pvfmkslole_mvl +#define _vel_pvfmksuple_mvl __builtin_ve_vl_pvfmksuple_mvl +#define _vel_pvfmkslole_mvml __builtin_ve_vl_pvfmkslole_mvml +#define _vel_pvfmksuple_mvml __builtin_ve_vl_pvfmksuple_mvml +#define _vel_pvfmkslonum_mvl __builtin_ve_vl_pvfmkslonum_mvl +#define _vel_pvfmksupnum_mvl __builtin_ve_vl_pvfmksupnum_mvl +#define _vel_pvfmkslonum_mvml __builtin_ve_vl_pvfmkslonum_mvml +#define _vel_pvfmksupnum_mvml __builtin_ve_vl_pvfmksupnum_mvml +#define _vel_pvfmkslonan_mvl __builtin_ve_vl_pvfmkslonan_mvl +#define _vel_pvfmksupnan_mvl __builtin_ve_vl_pvfmksupnan_mvl +#define _vel_pvfmkslonan_mvml __builtin_ve_vl_pvfmkslonan_mvml +#define _vel_pvfmksupnan_mvml __builtin_ve_vl_pvfmksupnan_mvml +#define _vel_pvfmkslogtnan_mvl __builtin_ve_vl_pvfmkslogtnan_mvl +#define _vel_pvfmksupgtnan_mvl __builtin_ve_vl_pvfmksupgtnan_mvl +#define _vel_pvfmkslogtnan_mvml __builtin_ve_vl_pvfmkslogtnan_mvml +#define _vel_pvfmksupgtnan_mvml __builtin_ve_vl_pvfmksupgtnan_mvml +#define _vel_pvfmksloltnan_mvl __builtin_ve_vl_pvfmksloltnan_mvl +#define _vel_pvfmksupltnan_mvl __builtin_ve_vl_pvfmksupltnan_mvl +#define _vel_pvfmksloltnan_mvml __builtin_ve_vl_pvfmksloltnan_mvml +#define _vel_pvfmksupltnan_mvml __builtin_ve_vl_pvfmksupltnan_mvml +#define _vel_pvfmkslonenan_mvl __builtin_ve_vl_pvfmkslonenan_mvl +#define _vel_pvfmksupnenan_mvl __builtin_ve_vl_pvfmksupnenan_mvl +#define _vel_pvfmkslonenan_mvml __builtin_ve_vl_pvfmkslonenan_mvml +#define _vel_pvfmksupnenan_mvml __builtin_ve_vl_pvfmksupnenan_mvml +#define _vel_pvfmksloeqnan_mvl __builtin_ve_vl_pvfmksloeqnan_mvl +#define _vel_pvfmksupeqnan_mvl __builtin_ve_vl_pvfmksupeqnan_mvl +#define _vel_pvfmksloeqnan_mvml __builtin_ve_vl_pvfmksloeqnan_mvml +#define _vel_pvfmksupeqnan_mvml __builtin_ve_vl_pvfmksupeqnan_mvml +#define _vel_pvfmkslogenan_mvl __builtin_ve_vl_pvfmkslogenan_mvl +#define _vel_pvfmksupgenan_mvl __builtin_ve_vl_pvfmksupgenan_mvl +#define _vel_pvfmkslogenan_mvml __builtin_ve_vl_pvfmkslogenan_mvml +#define _vel_pvfmksupgenan_mvml __builtin_ve_vl_pvfmksupgenan_mvml +#define _vel_pvfmkslolenan_mvl __builtin_ve_vl_pvfmkslolenan_mvl +#define _vel_pvfmksuplenan_mvl __builtin_ve_vl_pvfmksuplenan_mvl +#define _vel_pvfmkslolenan_mvml __builtin_ve_vl_pvfmkslolenan_mvml +#define _vel_pvfmksuplenan_mvml __builtin_ve_vl_pvfmksuplenan_mvml +#define _vel_pvfmksgt_Mvl __builtin_ve_vl_pvfmksgt_Mvl +#define _vel_pvfmksgt_MvMl __builtin_ve_vl_pvfmksgt_MvMl +#define _vel_pvfmkslt_Mvl __builtin_ve_vl_pvfmkslt_Mvl +#define _vel_pvfmkslt_MvMl __builtin_ve_vl_pvfmkslt_MvMl +#define _vel_pvfmksne_Mvl __builtin_ve_vl_pvfmksne_Mvl +#define _vel_pvfmksne_MvMl __builtin_ve_vl_pvfmksne_MvMl +#define _vel_pvfmkseq_Mvl __builtin_ve_vl_pvfmkseq_Mvl +#define _vel_pvfmkseq_MvMl __builtin_ve_vl_pvfmkseq_MvMl +#define _vel_pvfmksge_Mvl __builtin_ve_vl_pvfmksge_Mvl +#define _vel_pvfmksge_MvMl __builtin_ve_vl_pvfmksge_MvMl +#define _vel_pvfmksle_Mvl __builtin_ve_vl_pvfmksle_Mvl +#define _vel_pvfmksle_MvMl __builtin_ve_vl_pvfmksle_MvMl +#define _vel_pvfmksnum_Mvl __builtin_ve_vl_pvfmksnum_Mvl +#define _vel_pvfmksnum_MvMl __builtin_ve_vl_pvfmksnum_MvMl +#define _vel_pvfmksnan_Mvl __builtin_ve_vl_pvfmksnan_Mvl +#define _vel_pvfmksnan_MvMl __builtin_ve_vl_pvfmksnan_MvMl +#define _vel_pvfmksgtnan_Mvl __builtin_ve_vl_pvfmksgtnan_Mvl +#define _vel_pvfmksgtnan_MvMl __builtin_ve_vl_pvfmksgtnan_MvMl +#define _vel_pvfmksltnan_Mvl __builtin_ve_vl_pvfmksltnan_Mvl +#define _vel_pvfmksltnan_MvMl __builtin_ve_vl_pvfmksltnan_MvMl +#define _vel_pvfmksnenan_Mvl __builtin_ve_vl_pvfmksnenan_Mvl +#define _vel_pvfmksnenan_MvMl __builtin_ve_vl_pvfmksnenan_MvMl +#define _vel_pvfmkseqnan_Mvl __builtin_ve_vl_pvfmkseqnan_Mvl +#define _vel_pvfmkseqnan_MvMl __builtin_ve_vl_pvfmkseqnan_MvMl +#define _vel_pvfmksgenan_Mvl __builtin_ve_vl_pvfmksgenan_Mvl +#define _vel_pvfmksgenan_MvMl __builtin_ve_vl_pvfmksgenan_MvMl +#define _vel_pvfmkslenan_Mvl __builtin_ve_vl_pvfmkslenan_Mvl +#define _vel_pvfmkslenan_MvMl __builtin_ve_vl_pvfmkslenan_MvMl +#define _vel_vsumwsx_vvl __builtin_ve_vl_vsumwsx_vvl +#define _vel_vsumwsx_vvml __builtin_ve_vl_vsumwsx_vvml +#define _vel_vsumwzx_vvl __builtin_ve_vl_vsumwzx_vvl +#define _vel_vsumwzx_vvml __builtin_ve_vl_vsumwzx_vvml +#define _vel_vsuml_vvl __builtin_ve_vl_vsuml_vvl +#define _vel_vsuml_vvml __builtin_ve_vl_vsuml_vvml +#define _vel_vfsumd_vvl __builtin_ve_vl_vfsumd_vvl +#define _vel_vfsumd_vvml __builtin_ve_vl_vfsumd_vvml +#define _vel_vfsums_vvl __builtin_ve_vl_vfsums_vvl +#define _vel_vfsums_vvml __builtin_ve_vl_vfsums_vvml +#define _vel_vrmaxswfstsx_vvl __builtin_ve_vl_vrmaxswfstsx_vvl +#define _vel_vrmaxswfstsx_vvvl __builtin_ve_vl_vrmaxswfstsx_vvvl +#define _vel_vrmaxswlstsx_vvl __builtin_ve_vl_vrmaxswlstsx_vvl +#define _vel_vrmaxswlstsx_vvvl __builtin_ve_vl_vrmaxswlstsx_vvvl +#define _vel_vrmaxswfstzx_vvl __builtin_ve_vl_vrmaxswfstzx_vvl +#define _vel_vrmaxswfstzx_vvvl __builtin_ve_vl_vrmaxswfstzx_vvvl +#define _vel_vrmaxswlstzx_vvl __builtin_ve_vl_vrmaxswlstzx_vvl +#define _vel_vrmaxswlstzx_vvvl __builtin_ve_vl_vrmaxswlstzx_vvvl +#define _vel_vrminswfstsx_vvl __builtin_ve_vl_vrminswfstsx_vvl +#define _vel_vrminswfstsx_vvvl __builtin_ve_vl_vrminswfstsx_vvvl +#define _vel_vrminswlstsx_vvl __builtin_ve_vl_vrminswlstsx_vvl +#define _vel_vrminswlstsx_vvvl __builtin_ve_vl_vrminswlstsx_vvvl +#define _vel_vrminswfstzx_vvl __builtin_ve_vl_vrminswfstzx_vvl +#define _vel_vrminswfstzx_vvvl __builtin_ve_vl_vrminswfstzx_vvvl +#define _vel_vrminswlstzx_vvl __builtin_ve_vl_vrminswlstzx_vvl +#define _vel_vrminswlstzx_vvvl __builtin_ve_vl_vrminswlstzx_vvvl +#define _vel_vrmaxslfst_vvl __builtin_ve_vl_vrmaxslfst_vvl +#define _vel_vrmaxslfst_vvvl __builtin_ve_vl_vrmaxslfst_vvvl +#define _vel_vrmaxsllst_vvl __builtin_ve_vl_vrmaxsllst_vvl +#define _vel_vrmaxsllst_vvvl __builtin_ve_vl_vrmaxsllst_vvvl +#define _vel_vrminslfst_vvl __builtin_ve_vl_vrminslfst_vvl +#define _vel_vrminslfst_vvvl __builtin_ve_vl_vrminslfst_vvvl +#define _vel_vrminsllst_vvl __builtin_ve_vl_vrminsllst_vvl +#define _vel_vrminsllst_vvvl __builtin_ve_vl_vrminsllst_vvvl +#define _vel_vfrmaxdfst_vvl __builtin_ve_vl_vfrmaxdfst_vvl +#define _vel_vfrmaxdfst_vvvl __builtin_ve_vl_vfrmaxdfst_vvvl +#define _vel_vfrmaxdlst_vvl __builtin_ve_vl_vfrmaxdlst_vvl +#define _vel_vfrmaxdlst_vvvl __builtin_ve_vl_vfrmaxdlst_vvvl +#define _vel_vfrmaxsfst_vvl __builtin_ve_vl_vfrmaxsfst_vvl +#define _vel_vfrmaxsfst_vvvl __builtin_ve_vl_vfrmaxsfst_vvvl +#define _vel_vfrmaxslst_vvl __builtin_ve_vl_vfrmaxslst_vvl +#define _vel_vfrmaxslst_vvvl __builtin_ve_vl_vfrmaxslst_vvvl +#define _vel_vfrmindfst_vvl __builtin_ve_vl_vfrmindfst_vvl +#define _vel_vfrmindfst_vvvl __builtin_ve_vl_vfrmindfst_vvvl +#define _vel_vfrmindlst_vvl __builtin_ve_vl_vfrmindlst_vvl +#define _vel_vfrmindlst_vvvl __builtin_ve_vl_vfrmindlst_vvvl +#define _vel_vfrminsfst_vvl __builtin_ve_vl_vfrminsfst_vvl +#define _vel_vfrminsfst_vvvl __builtin_ve_vl_vfrminsfst_vvvl +#define _vel_vfrminslst_vvl __builtin_ve_vl_vfrminslst_vvl +#define _vel_vfrminslst_vvvl __builtin_ve_vl_vfrminslst_vvvl +#define _vel_vrand_vvl __builtin_ve_vl_vrand_vvl +#define _vel_vrand_vvml __builtin_ve_vl_vrand_vvml +#define _vel_vror_vvl __builtin_ve_vl_vror_vvl +#define _vel_vror_vvml __builtin_ve_vl_vror_vvml +#define _vel_vrxor_vvl __builtin_ve_vl_vrxor_vvl +#define _vel_vrxor_vvml __builtin_ve_vl_vrxor_vvml +#define _vel_vgt_vvssl __builtin_ve_vl_vgt_vvssl +#define _vel_vgt_vvssvl __builtin_ve_vl_vgt_vvssvl +#define _vel_vgt_vvssml __builtin_ve_vl_vgt_vvssml +#define _vel_vgt_vvssmvl __builtin_ve_vl_vgt_vvssmvl +#define _vel_vgtnc_vvssl __builtin_ve_vl_vgtnc_vvssl +#define _vel_vgtnc_vvssvl __builtin_ve_vl_vgtnc_vvssvl +#define _vel_vgtnc_vvssml __builtin_ve_vl_vgtnc_vvssml +#define _vel_vgtnc_vvssmvl __builtin_ve_vl_vgtnc_vvssmvl +#define _vel_vgtu_vvssl __builtin_ve_vl_vgtu_vvssl +#define _vel_vgtu_vvssvl __builtin_ve_vl_vgtu_vvssvl +#define _vel_vgtu_vvssml __builtin_ve_vl_vgtu_vvssml +#define _vel_vgtu_vvssmvl __builtin_ve_vl_vgtu_vvssmvl +#define _vel_vgtunc_vvssl __builtin_ve_vl_vgtunc_vvssl +#define _vel_vgtunc_vvssvl __builtin_ve_vl_vgtunc_vvssvl +#define _vel_vgtunc_vvssml __builtin_ve_vl_vgtunc_vvssml +#define _vel_vgtunc_vvssmvl __builtin_ve_vl_vgtunc_vvssmvl +#define _vel_vgtlsx_vvssl __builtin_ve_vl_vgtlsx_vvssl +#define _vel_vgtlsx_vvssvl __builtin_ve_vl_vgtlsx_vvssvl +#define _vel_vgtlsx_vvssml __builtin_ve_vl_vgtlsx_vvssml +#define _vel_vgtlsx_vvssmvl __builtin_ve_vl_vgtlsx_vvssmvl +#define _vel_vgtlsxnc_vvssl __builtin_ve_vl_vgtlsxnc_vvssl +#define _vel_vgtlsxnc_vvssvl __builtin_ve_vl_vgtlsxnc_vvssvl +#define _vel_vgtlsxnc_vvssml __builtin_ve_vl_vgtlsxnc_vvssml +#define _vel_vgtlsxnc_vvssmvl __builtin_ve_vl_vgtlsxnc_vvssmvl +#define _vel_vgtlzx_vvssl __builtin_ve_vl_vgtlzx_vvssl +#define _vel_vgtlzx_vvssvl __builtin_ve_vl_vgtlzx_vvssvl +#define _vel_vgtlzx_vvssml __builtin_ve_vl_vgtlzx_vvssml +#define _vel_vgtlzx_vvssmvl __builtin_ve_vl_vgtlzx_vvssmvl +#define _vel_vgtlzxnc_vvssl __builtin_ve_vl_vgtlzxnc_vvssl +#define _vel_vgtlzxnc_vvssvl __builtin_ve_vl_vgtlzxnc_vvssvl +#define _vel_vgtlzxnc_vvssml __builtin_ve_vl_vgtlzxnc_vvssml +#define _vel_vgtlzxnc_vvssmvl __builtin_ve_vl_vgtlzxnc_vvssmvl +#define _vel_vsc_vvssl __builtin_ve_vl_vsc_vvssl +#define _vel_vsc_vvssml __builtin_ve_vl_vsc_vvssml +#define _vel_vscnc_vvssl __builtin_ve_vl_vscnc_vvssl +#define _vel_vscnc_vvssml __builtin_ve_vl_vscnc_vvssml +#define _vel_vscot_vvssl __builtin_ve_vl_vscot_vvssl +#define _vel_vscot_vvssml __builtin_ve_vl_vscot_vvssml +#define _vel_vscncot_vvssl __builtin_ve_vl_vscncot_vvssl +#define _vel_vscncot_vvssml __builtin_ve_vl_vscncot_vvssml +#define _vel_vscu_vvssl __builtin_ve_vl_vscu_vvssl +#define _vel_vscu_vvssml __builtin_ve_vl_vscu_vvssml +#define _vel_vscunc_vvssl __builtin_ve_vl_vscunc_vvssl +#define _vel_vscunc_vvssml __builtin_ve_vl_vscunc_vvssml +#define _vel_vscuot_vvssl __builtin_ve_vl_vscuot_vvssl +#define _vel_vscuot_vvssml __builtin_ve_vl_vscuot_vvssml +#define _vel_vscuncot_vvssl __builtin_ve_vl_vscuncot_vvssl +#define _vel_vscuncot_vvssml __builtin_ve_vl_vscuncot_vvssml +#define _vel_vscl_vvssl __builtin_ve_vl_vscl_vvssl +#define _vel_vscl_vvssml __builtin_ve_vl_vscl_vvssml +#define _vel_vsclnc_vvssl __builtin_ve_vl_vsclnc_vvssl +#define _vel_vsclnc_vvssml __builtin_ve_vl_vsclnc_vvssml +#define _vel_vsclot_vvssl __builtin_ve_vl_vsclot_vvssl +#define _vel_vsclot_vvssml __builtin_ve_vl_vsclot_vvssml +#define _vel_vsclncot_vvssl __builtin_ve_vl_vsclncot_vvssl +#define _vel_vsclncot_vvssml __builtin_ve_vl_vsclncot_vvssml +#define _vel_andm_mmm __builtin_ve_vl_andm_mmm +#define _vel_andm_MMM __builtin_ve_vl_andm_MMM +#define _vel_orm_mmm __builtin_ve_vl_orm_mmm +#define _vel_orm_MMM __builtin_ve_vl_orm_MMM +#define _vel_xorm_mmm __builtin_ve_vl_xorm_mmm +#define _vel_xorm_MMM __builtin_ve_vl_xorm_MMM +#define _vel_eqvm_mmm __builtin_ve_vl_eqvm_mmm +#define _vel_eqvm_MMM __builtin_ve_vl_eqvm_MMM +#define _vel_nndm_mmm __builtin_ve_vl_nndm_mmm +#define _vel_nndm_MMM __builtin_ve_vl_nndm_MMM +#define _vel_negm_mm __builtin_ve_vl_negm_mm +#define _vel_negm_MM __builtin_ve_vl_negm_MM +#define _vel_pcvm_sml __builtin_ve_vl_pcvm_sml +#define _vel_lzvm_sml __builtin_ve_vl_lzvm_sml +#define _vel_tovm_sml __builtin_ve_vl_tovm_sml +#define _vel_lcr_sss __builtin_ve_vl_lcr_sss +#define _vel_scr_sss __builtin_ve_vl_scr_sss +#define _vel_tscr_ssss __builtin_ve_vl_tscr_ssss +#define _vel_fidcr_sss __builtin_ve_vl_fidcr_sss +#define _vel_fencei __builtin_ve_vl_fencei +#define _vel_fencem_s __builtin_ve_vl_fencem_s +#define _vel_fencec_s __builtin_ve_vl_fencec_s +#define _vel_svob __builtin_ve_vl_svob diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vpclmulqdqintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vpclmulqdqintrin.h new file mode 100755 index 0000000..485692e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/vpclmulqdqintrin.h @@ -0,0 +1,30 @@ +/*===------------ vpclmulqdqintrin.h - VPCLMULQDQ intrinsics ---------------=== + * + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __VPCLMULQDQINTRIN_H +#define __VPCLMULQDQINTRIN_H + +#define _mm256_clmulepi64_epi128(A, B, I) \ + ((__m256i)__builtin_ia32_pclmulqdq256((__v4di)(__m256i)(A), \ + (__v4di)(__m256i)(B), \ + (char)(I))) + +#ifdef __AVX512FINTRIN_H +#define _mm512_clmulepi64_epi128(A, B, I) \ + ((__m512i)__builtin_ia32_pclmulqdq512((__v8di)(__m512i)(A), \ + (__v8di)(__m512i)(B), \ + (char)(I))) +#endif // __AVX512FINTRIN_H + +#endif /* __VPCLMULQDQINTRIN_H */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/waitpkgintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/waitpkgintrin.h new file mode 100755 index 0000000..7ecada4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/waitpkgintrin.h @@ -0,0 +1,42 @@ +/*===----------------------- waitpkgintrin.h - WAITPKG --------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __WAITPKGINTRIN_H +#define __WAITPKGINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("waitpkg"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_umonitor (void * __address) +{ + __builtin_ia32_umonitor (__address); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_umwait (unsigned int __control, unsigned long long __counter) +{ + return __builtin_ia32_umwait (__control, + (unsigned int)(__counter >> 32), (unsigned int)__counter); +} + +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_tpause (unsigned int __control, unsigned long long __counter) +{ + return __builtin_ia32_tpause (__control, + (unsigned int)(__counter >> 32), (unsigned int)__counter); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* __WAITPKGINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wasm_simd128.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wasm_simd128.h new file mode 100755 index 0000000..08e39bf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wasm_simd128.h @@ -0,0 +1,2143 @@ +/*===---- wasm_simd128.h - WebAssembly portable SIMD intrinsics ------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __WASM_SIMD128_H +#define __WASM_SIMD128_H + +#include +#include + +// User-facing type +typedef int32_t v128_t __attribute__((__vector_size__(16), __aligned__(16))); + +// Internal types determined by clang builtin definitions +typedef int32_t __v128_u __attribute__((__vector_size__(16), __aligned__(1))); +typedef signed char __i8x16 + __attribute__((__vector_size__(16), __aligned__(16))); +typedef unsigned char __u8x16 + __attribute__((__vector_size__(16), __aligned__(16))); +typedef short __i16x8 __attribute__((__vector_size__(16), __aligned__(16))); +typedef unsigned short __u16x8 + __attribute__((__vector_size__(16), __aligned__(16))); +typedef int __i32x4 __attribute__((__vector_size__(16), __aligned__(16))); +typedef unsigned int __u32x4 + __attribute__((__vector_size__(16), __aligned__(16))); +typedef long long __i64x2 __attribute__((__vector_size__(16), __aligned__(16))); +typedef unsigned long long __u64x2 + __attribute__((__vector_size__(16), __aligned__(16))); +typedef float __f32x4 __attribute__((__vector_size__(16), __aligned__(16))); +typedef double __f64x2 __attribute__((__vector_size__(16), __aligned__(16))); +typedef __fp16 __f16x8 __attribute__((__vector_size__(16), __aligned__(16))); + +typedef signed char __i8x8 __attribute__((__vector_size__(8), __aligned__(8))); +typedef unsigned char __u8x8 + __attribute__((__vector_size__(8), __aligned__(8))); +typedef short __i16x4 __attribute__((__vector_size__(8), __aligned__(8))); +typedef unsigned short __u16x4 + __attribute__((__vector_size__(8), __aligned__(8))); +typedef int __i32x2 __attribute__((__vector_size__(8), __aligned__(8))); +typedef unsigned int __u32x2 + __attribute__((__vector_size__(8), __aligned__(8))); +typedef float __f32x2 __attribute__((__vector_size__(8), __aligned__(8))); + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("simd128"), \ + __min_vector_width__(128))) + +#define __REQUIRE_CONSTANT(c) \ + __attribute__((__diagnose_if__(!__builtin_constant_p(c), \ + #c " must be constant", "error"))) + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load(const void *__mem) { + // UB-free unaligned access copied from xmmintrin.h + struct __wasm_v128_load_struct { + __v128_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __wasm_v128_load_struct *)__mem)->__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_v128_load8_splat(const void *__mem) { + struct __wasm_v128_load8_splat_struct { + uint8_t __v; + } __attribute__((__packed__, __may_alias__)); + uint8_t __v = ((const struct __wasm_v128_load8_splat_struct *)__mem)->__v; + return (v128_t)(__u8x16){__v, __v, __v, __v, __v, __v, __v, __v, + __v, __v, __v, __v, __v, __v, __v, __v}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_v128_load16_splat(const void *__mem) { + struct __wasm_v128_load16_splat_struct { + uint16_t __v; + } __attribute__((__packed__, __may_alias__)); + uint16_t __v = ((const struct __wasm_v128_load16_splat_struct *)__mem)->__v; + return (v128_t)(__u16x8){__v, __v, __v, __v, __v, __v, __v, __v}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_v128_load32_splat(const void *__mem) { + struct __wasm_v128_load32_splat_struct { + uint32_t __v; + } __attribute__((__packed__, __may_alias__)); + uint32_t __v = ((const struct __wasm_v128_load32_splat_struct *)__mem)->__v; + return (v128_t)(__u32x4){__v, __v, __v, __v}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_v128_load64_splat(const void *__mem) { + struct __wasm_v128_load64_splat_struct { + uint64_t __v; + } __attribute__((__packed__, __may_alias__)); + uint64_t __v = ((const struct __wasm_v128_load64_splat_struct *)__mem)->__v; + return (v128_t)(__u64x2){__v, __v}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_load8x8(const void *__mem) { + struct __wasm_i16x8_load8x8_struct { + __i8x8 __v; + } __attribute__((__packed__, __may_alias__)); + __i8x8 __v = ((const struct __wasm_i16x8_load8x8_struct *)__mem)->__v; + return (v128_t) __builtin_convertvector(__v, __i16x8); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_load8x8(const void *__mem) { + struct __wasm_u16x8_load8x8_struct { + __u8x8 __v; + } __attribute__((__packed__, __may_alias__)); + __u8x8 __v = ((const struct __wasm_u16x8_load8x8_struct *)__mem)->__v; + return (v128_t) __builtin_convertvector(__v, __u16x8); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_load16x4(const void *__mem) { + struct __wasm_i32x4_load16x4_struct { + __i16x4 __v; + } __attribute__((__packed__, __may_alias__)); + __i16x4 __v = ((const struct __wasm_i32x4_load16x4_struct *)__mem)->__v; + return (v128_t) __builtin_convertvector(__v, __i32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_load16x4(const void *__mem) { + struct __wasm_u32x4_load16x4_struct { + __u16x4 __v; + } __attribute__((__packed__, __may_alias__)); + __u16x4 __v = ((const struct __wasm_u32x4_load16x4_struct *)__mem)->__v; + return (v128_t) __builtin_convertvector(__v, __u32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i64x2_load32x2(const void *__mem) { + struct __wasm_i64x2_load32x2_struct { + __i32x2 __v; + } __attribute__((__packed__, __may_alias__)); + __i32x2 __v = ((const struct __wasm_i64x2_load32x2_struct *)__mem)->__v; + return (v128_t) __builtin_convertvector(__v, __i64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u64x2_load32x2(const void *__mem) { + struct __wasm_u64x2_load32x2_struct { + __u32x2 __v; + } __attribute__((__packed__, __may_alias__)); + __u32x2 __v = ((const struct __wasm_u64x2_load32x2_struct *)__mem)->__v; + return (v128_t) __builtin_convertvector(__v, __u64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_v128_load32_zero(const void *__mem) { + struct __wasm_v128_load32_zero_struct { + int32_t __v; + } __attribute__((__packed__, __may_alias__)); + int32_t __v = ((const struct __wasm_v128_load32_zero_struct *)__mem)->__v; + return (v128_t)(__i32x4){__v, 0, 0, 0}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_v128_load64_zero(const void *__mem) { + struct __wasm_v128_load64_zero_struct { + int64_t __v; + } __attribute__((__packed__, __may_alias__)); + int64_t __v = ((const struct __wasm_v128_load64_zero_struct *)__mem)->__v; + return (v128_t)(__i64x2){__v, 0}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load8_lane( + const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_load8_lane_struct { + int8_t __v; + } __attribute__((__packed__, __may_alias__)); + int8_t __v = ((const struct __wasm_v128_load8_lane_struct *)__mem)->__v; + __i8x16 __ret = (__i8x16)__vec; + __ret[__i] = __v; + return (v128_t)__ret; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load16_lane( + const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_load16_lane_struct { + int16_t __v; + } __attribute__((__packed__, __may_alias__)); + int16_t __v = ((const struct __wasm_v128_load16_lane_struct *)__mem)->__v; + __i16x8 __ret = (__i16x8)__vec; + __ret[__i] = __v; + return (v128_t)__ret; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load32_lane( + const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_load32_lane_struct { + int32_t __v; + } __attribute__((__packed__, __may_alias__)); + int32_t __v = ((const struct __wasm_v128_load32_lane_struct *)__mem)->__v; + __i32x4 __ret = (__i32x4)__vec; + __ret[__i] = __v; + return (v128_t)__ret; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load64_lane( + const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_load64_lane_struct { + int64_t __v; + } __attribute__((__packed__, __may_alias__)); + int64_t __v = ((const struct __wasm_v128_load64_lane_struct *)__mem)->__v; + __i64x2 __ret = (__i64x2)__vec; + __ret[__i] = __v; + return (v128_t)__ret; +} + +static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store(void *__mem, + v128_t __a) { + // UB-free unaligned access copied from xmmintrin.h + struct __wasm_v128_store_struct { + __v128_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __wasm_v128_store_struct *)__mem)->__v = __a; +} + +static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store8_lane(void *__mem, + v128_t __vec, + int __i) + __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_store8_lane_struct { + int8_t __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __wasm_v128_store8_lane_struct *)__mem)->__v = ((__i8x16)__vec)[__i]; +} + +static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store16_lane(void *__mem, + v128_t __vec, + int __i) + __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_store16_lane_struct { + int16_t __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __wasm_v128_store16_lane_struct *)__mem)->__v = + ((__i16x8)__vec)[__i]; +} + +static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store32_lane(void *__mem, + v128_t __vec, + int __i) + __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_store32_lane_struct { + int32_t __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __wasm_v128_store32_lane_struct *)__mem)->__v = + ((__i32x4)__vec)[__i]; +} + +static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store64_lane(void *__mem, + v128_t __vec, + int __i) + __REQUIRE_CONSTANT(__i) { + struct __wasm_v128_store64_lane_struct { + int64_t __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __wasm_v128_store64_lane_struct *)__mem)->__v = + ((__i64x2)__vec)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i8x16_make(int8_t __c0, int8_t __c1, int8_t __c2, int8_t __c3, int8_t __c4, + int8_t __c5, int8_t __c6, int8_t __c7, int8_t __c8, int8_t __c9, + int8_t __c10, int8_t __c11, int8_t __c12, int8_t __c13, + int8_t __c14, int8_t __c15) { + return (v128_t)(__i8x16){__c0, __c1, __c2, __c3, __c4, __c5, + __c6, __c7, __c8, __c9, __c10, __c11, + __c12, __c13, __c14, __c15}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u8x16_make(uint8_t __c0, uint8_t __c1, uint8_t __c2, uint8_t __c3, + uint8_t __c4, uint8_t __c5, uint8_t __c6, uint8_t __c7, + uint8_t __c8, uint8_t __c9, uint8_t __c10, uint8_t __c11, + uint8_t __c12, uint8_t __c13, uint8_t __c14, uint8_t __c15) { + return (v128_t)(__u8x16){__c0, __c1, __c2, __c3, __c4, __c5, + __c6, __c7, __c8, __c9, __c10, __c11, + __c12, __c13, __c14, __c15}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_make(int16_t __c0, int16_t __c1, int16_t __c2, int16_t __c3, + int16_t __c4, int16_t __c5, int16_t __c6, int16_t __c7) { + return (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_make(uint16_t __c0, uint16_t __c1, uint16_t __c2, uint16_t __c3, + uint16_t __c4, uint16_t __c5, uint16_t __c6, uint16_t __c7) { + return (v128_t)(__u16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_make(int32_t __c0, + int32_t __c1, + int32_t __c2, + int32_t __c3) { + return (v128_t)(__i32x4){__c0, __c1, __c2, __c3}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_make(uint32_t __c0, + uint32_t __c1, + uint32_t __c2, + uint32_t __c3) { + return (v128_t)(__u32x4){__c0, __c1, __c2, __c3}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_make(int64_t __c0, + int64_t __c1) { + return (v128_t)(__i64x2){__c0, __c1}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_make(uint64_t __c0, + uint64_t __c1) { + return (v128_t)(__u64x2){__c0, __c1}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_make(float __c0, + float __c1, + float __c2, + float __c3) { + return (v128_t)(__f32x4){__c0, __c1, __c2, __c3}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double __c0, + double __c1) { + return (v128_t)(__f64x2){__c0, __c1}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i8x16_const(int8_t __c0, int8_t __c1, int8_t __c2, int8_t __c3, + int8_t __c4, int8_t __c5, int8_t __c6, int8_t __c7, + int8_t __c8, int8_t __c9, int8_t __c10, int8_t __c11, + int8_t __c12, int8_t __c13, int8_t __c14, int8_t __c15) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) + __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) + __REQUIRE_CONSTANT(__c7) __REQUIRE_CONSTANT(__c8) + __REQUIRE_CONSTANT(__c9) __REQUIRE_CONSTANT(__c10) + __REQUIRE_CONSTANT(__c11) __REQUIRE_CONSTANT(__c12) + __REQUIRE_CONSTANT(__c13) __REQUIRE_CONSTANT(__c14) + __REQUIRE_CONSTANT(__c15) { + return (v128_t)(__i8x16){__c0, __c1, __c2, __c3, __c4, __c5, + __c6, __c7, __c8, __c9, __c10, __c11, + __c12, __c13, __c14, __c15}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u8x16_const(uint8_t __c0, uint8_t __c1, uint8_t __c2, uint8_t __c3, + uint8_t __c4, uint8_t __c5, uint8_t __c6, uint8_t __c7, + uint8_t __c8, uint8_t __c9, uint8_t __c10, uint8_t __c11, + uint8_t __c12, uint8_t __c13, uint8_t __c14, uint8_t __c15) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) + __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) + __REQUIRE_CONSTANT(__c7) __REQUIRE_CONSTANT(__c8) + __REQUIRE_CONSTANT(__c9) __REQUIRE_CONSTANT(__c10) + __REQUIRE_CONSTANT(__c11) __REQUIRE_CONSTANT(__c12) + __REQUIRE_CONSTANT(__c13) __REQUIRE_CONSTANT(__c14) + __REQUIRE_CONSTANT(__c15) { + return (v128_t)(__u8x16){__c0, __c1, __c2, __c3, __c4, __c5, + __c6, __c7, __c8, __c9, __c10, __c11, + __c12, __c13, __c14, __c15}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_const(int16_t __c0, int16_t __c1, int16_t __c2, int16_t __c3, + int16_t __c4, int16_t __c5, int16_t __c6, int16_t __c7) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) + __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) + __REQUIRE_CONSTANT(__c7) { + return (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_const(uint16_t __c0, uint16_t __c1, uint16_t __c2, uint16_t __c3, + uint16_t __c4, uint16_t __c5, uint16_t __c6, uint16_t __c7) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) + __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) + __REQUIRE_CONSTANT(__c7) { + return (v128_t)(__u16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_const(int32_t __c0, int32_t __c1, int32_t __c2, int32_t __c3) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) { + return (v128_t)(__i32x4){__c0, __c1, __c2, __c3}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_const(uint32_t __c0, uint32_t __c1, uint32_t __c2, uint32_t __c3) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) { + return (v128_t)(__u32x4){__c0, __c1, __c2, __c3}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_const(int64_t __c0, + int64_t __c1) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) { + return (v128_t)(__i64x2){__c0, __c1}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_const(uint64_t __c0, + uint64_t __c1) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) { + return (v128_t)(__u64x2){__c0, __c1}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f32x4_const(float __c0, float __c1, float __c2, float __c3) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) + __REQUIRE_CONSTANT(__c3) { + return (v128_t)(__f32x4){__c0, __c1, __c2, __c3}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_const(double __c0, + double __c1) + __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) { + return (v128_t)(__f64x2){__c0, __c1}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_const_splat(int8_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__i8x16){__c, __c, __c, __c, __c, __c, __c, __c, + __c, __c, __c, __c, __c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_const_splat(uint8_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__u8x16){__c, __c, __c, __c, __c, __c, __c, __c, + __c, __c, __c, __c, __c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_const_splat(int16_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__i16x8){__c, __c, __c, __c, __c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_const_splat(uint16_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__u16x8){__c, __c, __c, __c, __c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_const_splat(int32_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__i32x4){__c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_const_splat(uint32_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__u32x4){__c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_const_splat(int64_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__i64x2){__c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_const_splat(uint64_t __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__u64x2){__c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_const_splat(float __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__f32x4){__c, __c, __c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_const_splat(double __c) + __REQUIRE_CONSTANT(__c) { + return (v128_t)(__f64x2){__c, __c}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_splat(int8_t __a) { + return (v128_t)(__i8x16){__a, __a, __a, __a, __a, __a, __a, __a, + __a, __a, __a, __a, __a, __a, __a, __a}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_splat(uint8_t __a) { + return (v128_t)(__u8x16){__a, __a, __a, __a, __a, __a, __a, __a, + __a, __a, __a, __a, __a, __a, __a, __a}; +} + +static __inline__ int8_t __DEFAULT_FN_ATTRS wasm_i8x16_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__i8x16)__a)[__i]; +} + +static __inline__ uint8_t __DEFAULT_FN_ATTRS wasm_u8x16_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__u8x16)__a)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_replace_lane(v128_t __a, + int __i, + int8_t __b) + __REQUIRE_CONSTANT(__i) { + __i8x16 __v = (__i8x16)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_replace_lane(v128_t __a, + int __i, + uint8_t __b) + __REQUIRE_CONSTANT(__i) { + __u8x16 __v = (__u8x16)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_splat(int16_t __a) { + return (v128_t)(__i16x8){__a, __a, __a, __a, __a, __a, __a, __a}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_splat(uint16_t __a) { + return (v128_t)(__u16x8){__a, __a, __a, __a, __a, __a, __a, __a}; +} + +static __inline__ int16_t __DEFAULT_FN_ATTRS wasm_i16x8_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__i16x8)__a)[__i]; +} + +static __inline__ uint16_t __DEFAULT_FN_ATTRS +wasm_u16x8_extract_lane(v128_t __a, int __i) __REQUIRE_CONSTANT(__i) { + return ((__u16x8)__a)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_replace_lane(v128_t __a, + int __i, + int16_t __b) + __REQUIRE_CONSTANT(__i) { + __i16x8 __v = (__i16x8)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_replace_lane( + v128_t __a, int __i, uint16_t __b) __REQUIRE_CONSTANT(__i) { + __u16x8 __v = (__u16x8)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_splat(int32_t __a) { + return (v128_t)(__i32x4){__a, __a, __a, __a}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_splat(uint32_t __a) { + return (v128_t)(__u32x4){__a, __a, __a, __a}; +} + +static __inline__ int32_t __DEFAULT_FN_ATTRS wasm_i32x4_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__i32x4)__a)[__i]; +} + +static __inline__ uint32_t __DEFAULT_FN_ATTRS +wasm_u32x4_extract_lane(v128_t __a, int __i) __REQUIRE_CONSTANT(__i) { + return ((__u32x4)__a)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_replace_lane(v128_t __a, + int __i, + int32_t __b) + __REQUIRE_CONSTANT(__i) { + __i32x4 __v = (__i32x4)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_replace_lane( + v128_t __a, int __i, uint32_t __b) __REQUIRE_CONSTANT(__i) { + __u32x4 __v = (__u32x4)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_splat(int64_t __a) { + return (v128_t)(__i64x2){__a, __a}; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_splat(uint64_t __a) { + return (v128_t)(__u64x2){__a, __a}; +} + +static __inline__ int64_t __DEFAULT_FN_ATTRS wasm_i64x2_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__i64x2)__a)[__i]; +} + +static __inline__ uint64_t __DEFAULT_FN_ATTRS +wasm_u64x2_extract_lane(v128_t __a, int __i) __REQUIRE_CONSTANT(__i) { + return ((__u64x2)__a)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_replace_lane(v128_t __a, + int __i, + int64_t __b) + __REQUIRE_CONSTANT(__i) { + __i64x2 __v = (__i64x2)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_replace_lane( + v128_t __a, int __i, uint64_t __b) __REQUIRE_CONSTANT(__i) { + __u64x2 __v = (__u64x2)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_splat(float __a) { + return (v128_t)(__f32x4){__a, __a, __a, __a}; +} + +static __inline__ float __DEFAULT_FN_ATTRS wasm_f32x4_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__f32x4)__a)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_replace_lane(v128_t __a, + int __i, + float __b) + __REQUIRE_CONSTANT(__i) { + __f32x4 __v = (__f32x4)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_splat(double __a) { + return (v128_t)(__f64x2){__a, __a}; +} + +static __inline__ double __DEFAULT_FN_ATTRS wasm_f64x2_extract_lane(v128_t __a, + int __i) + __REQUIRE_CONSTANT(__i) { + return ((__f64x2)__a)[__i]; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_replace_lane(v128_t __a, + int __i, + double __b) + __REQUIRE_CONSTANT(__i) { + __f64x2 __v = (__f64x2)__a; + __v[__i] = __b; + return (v128_t)__v; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_eq(v128_t __a, + v128_t __b) { + return (v128_t)((__i8x16)__a == (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_ne(v128_t __a, + v128_t __b) { + return (v128_t)((__i8x16)__a != (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__i8x16)__a < (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__u8x16)__a < (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__i8x16)__a > (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__u8x16)__a > (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_le(v128_t __a, + v128_t __b) { + return (v128_t)((__i8x16)__a <= (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_le(v128_t __a, + v128_t __b) { + return (v128_t)((__u8x16)__a <= (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__i8x16)__a >= (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__u8x16)__a >= (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_eq(v128_t __a, + v128_t __b) { + return (v128_t)((__i16x8)__a == (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_ne(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a != (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__i16x8)__a < (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a < (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__i16x8)__a > (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a > (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_le(v128_t __a, + v128_t __b) { + return (v128_t)((__i16x8)__a <= (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_le(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a <= (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__i16x8)__a >= (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a >= (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_eq(v128_t __a, + v128_t __b) { + return (v128_t)((__i32x4)__a == (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_ne(v128_t __a, + v128_t __b) { + return (v128_t)((__i32x4)__a != (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__i32x4)__a < (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a < (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__i32x4)__a > (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a > (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_le(v128_t __a, + v128_t __b) { + return (v128_t)((__i32x4)__a <= (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_le(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a <= (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__i32x4)__a >= (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a >= (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_eq(v128_t __a, + v128_t __b) { + return (v128_t)((__i64x2)__a == (__i64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_ne(v128_t __a, + v128_t __b) { + return (v128_t)((__i64x2)__a != (__i64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__i64x2)__a < (__i64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__i64x2)__a > (__i64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_le(v128_t __a, + v128_t __b) { + return (v128_t)((__i64x2)__a <= (__i64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__i64x2)__a >= (__i64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_eq(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a == (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ne(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a != (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a < (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a > (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_le(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a <= (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a >= (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_eq(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a == (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ne(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a != (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_lt(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a < (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_gt(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a > (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_le(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a <= (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ge(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a >= (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_not(v128_t __a) { + return ~__a; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_and(v128_t __a, + v128_t __b) { + return __a & __b; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_or(v128_t __a, + v128_t __b) { + return __a | __b; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_xor(v128_t __a, + v128_t __b) { + return __a ^ __b; +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_andnot(v128_t __a, + v128_t __b) { + return __a & ~__b; +} + +static __inline__ bool __DEFAULT_FN_ATTRS wasm_v128_any_true(v128_t __a) { + return __builtin_wasm_any_true_v128((__i8x16)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_bitselect(v128_t __a, + v128_t __b, + v128_t __mask) { + return (v128_t)__builtin_wasm_bitselect((__i32x4)__a, (__i32x4)__b, + (__i32x4)__mask); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_i8x16((__i8x16)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_neg(v128_t __a) { + return (v128_t)(-(__u8x16)__a); +} + +static __inline__ bool __DEFAULT_FN_ATTRS wasm_i8x16_all_true(v128_t __a) { + return __builtin_wasm_all_true_i8x16((__i8x16)__a); +} + +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i8x16_bitmask(v128_t __a) { + return __builtin_wasm_bitmask_i8x16((__i8x16)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_popcnt(v128_t __a) { + return (v128_t)__builtin_elementwise_popcount((__i8x16)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shl(v128_t __a, + uint32_t __b) { + return (v128_t)((__i8x16)__a << (__b & 0x7)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__i8x16)__a >> (__b & 0x7)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__u8x16)__a >> (__b & 0x7)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_add(v128_t __a, + v128_t __b) { + return (v128_t)((__u8x16)__a + (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_add_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_add_sat((__i8x16)__a, (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_add_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_add_sat((__u8x16)__a, (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__u8x16)__a - (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_sub_sat((__i8x16)__a, (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_sub_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_sub_sat((__u8x16)__a, (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_min((__i8x16)__a, (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_min((__u8x16)__a, (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_max((__i8x16)__a, (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_max((__u8x16)__a, (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_avgr_u_i8x16((__u8x16)__a, (__u8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_i16x8((__i16x8)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_neg(v128_t __a) { + return (v128_t)(-(__u16x8)__a); +} + +static __inline__ bool __DEFAULT_FN_ATTRS wasm_i16x8_all_true(v128_t __a) { + return __builtin_wasm_all_true_i16x8((__i16x8)__a); +} + +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i16x8_bitmask(v128_t __a) { + return __builtin_wasm_bitmask_i16x8((__i16x8)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shl(v128_t __a, + uint32_t __b) { + return (v128_t)((__i16x8)__a << (__b & 0xF)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__i16x8)__a >> (__b & 0xF)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__u16x8)__a >> (__b & 0xF)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_add(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a + (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_add_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_add_sat((__i16x8)__a, (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_add_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_add_sat((__u16x8)__a, (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__i16x8)__a - (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_sub_sat((__i16x8)__a, (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_sub_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_sub_sat((__u16x8)__a, (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_mul(v128_t __a, + v128_t __b) { + return (v128_t)((__u16x8)__a * (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_min((__i16x8)__a, (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_min((__u16x8)__a, (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_max((__i16x8)__a, (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_max((__u16x8)__a, (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_avgr(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_avgr_u_i16x8((__u16x8)__a, (__u16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_i32x4((__i32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_neg(v128_t __a) { + return (v128_t)(-(__u32x4)__a); +} + +static __inline__ bool __DEFAULT_FN_ATTRS wasm_i32x4_all_true(v128_t __a) { + return __builtin_wasm_all_true_i32x4((__i32x4)__a); +} + +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i32x4_bitmask(v128_t __a) { + return __builtin_wasm_bitmask_i32x4((__i32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shl(v128_t __a, + uint32_t __b) { + return (v128_t)((__i32x4)__a << (__b & 0x1F)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__i32x4)__a >> (__b & 0x1F)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__u32x4)__a >> (__b & 0x1F)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_add(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a + (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a - (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_mul(v128_t __a, + v128_t __b) { + return (v128_t)((__u32x4)__a * (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_min((__i32x4)__a, (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_min((__u32x4)__a, (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_max((__i32x4)__a, (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_elementwise_max((__u32x4)__a, (__u32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_dot_i16x8(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_dot_s_i32x4_i16x8((__i16x8)__a, (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_i64x2((__i64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_neg(v128_t __a) { + return (v128_t)(-(__u64x2)__a); +} + +static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_all_true(v128_t __a) { + return __builtin_wasm_all_true_i64x2((__i64x2)__a); +} + +static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i64x2_bitmask(v128_t __a) { + return __builtin_wasm_bitmask_i64x2((__i64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shl(v128_t __a, + uint32_t __b) { + return (v128_t)((__i64x2)__a << ((int64_t)__b & 0x3F)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__i64x2)__a >> ((int64_t)__b & 0x3F)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_shr(v128_t __a, + uint32_t __b) { + return (v128_t)((__u64x2)__a >> ((int64_t)__b & 0x3F)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_add(v128_t __a, + v128_t __b) { + return (v128_t)((__u64x2)__a + (__u64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__u64x2)__a - (__u64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a, + v128_t __b) { + return (v128_t)((__u64x2)__a * (__u64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_neg(v128_t __a) { + return (v128_t)(-(__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sqrt(v128_t __a) { + return (v128_t)__builtin_wasm_sqrt_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ceil(v128_t __a) { + return (v128_t)__builtin_wasm_ceil_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_floor(v128_t __a) { + return (v128_t)__builtin_wasm_floor_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_trunc(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_nearest(v128_t __a) { + return (v128_t)__builtin_wasm_nearest_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_add(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a + (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a - (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_mul(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a * (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_div(v128_t __a, + v128_t __b) { + return (v128_t)((__f32x4)__a / (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_min_f32x4((__f32x4)__a, (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_max_f32x4((__f32x4)__a, (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmin(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_pmin_f32x4((__f32x4)__a, (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmax(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_pmax_f32x4((__f32x4)__a, (__f32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_neg(v128_t __a) { + return (v128_t)(-(__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sqrt(v128_t __a) { + return (v128_t)__builtin_wasm_sqrt_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ceil(v128_t __a) { + return (v128_t)__builtin_wasm_ceil_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_floor(v128_t __a) { + return (v128_t)__builtin_wasm_floor_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_trunc(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_nearest(v128_t __a) { + return (v128_t)__builtin_wasm_nearest_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_add(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a + (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a - (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_mul(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a * (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_div(v128_t __a, + v128_t __b) { + return (v128_t)((__f64x2)__a / (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_min_f64x2((__f64x2)__a, (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_max_f64x2((__f64x2)__a, (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmin(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_pmin_f64x2((__f64x2)__a, (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmax(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_pmax_f64x2((__f64x2)__a, (__f64x2)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_trunc_sat_f32x4(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_saturate_s_i32x4_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_trunc_sat_f32x4(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_saturate_u_i32x4_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f32x4_convert_i32x4(v128_t __a) { + return (v128_t) __builtin_convertvector((__i32x4)__a, __f32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f32x4_convert_u32x4(v128_t __a) { + return (v128_t) __builtin_convertvector((__u32x4)__a, __f32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f64x2_convert_low_i32x4(v128_t __a) { + return (v128_t) __builtin_convertvector((__i32x2){__a[0], __a[1]}, __f64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f64x2_convert_low_u32x4(v128_t __a) { + return (v128_t) __builtin_convertvector((__u32x2){__a[0], __a[1]}, __f64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_trunc_sat_f64x2_zero(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_sat_s_zero_f64x2_i32x4((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_trunc_sat_f64x2_zero(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_sat_u_zero_f64x2_i32x4((__f64x2)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f32x4_demote_f64x2_zero(v128_t __a) { + return (v128_t) __builtin_convertvector( + __builtin_shufflevector((__f64x2)__a, (__f64x2){0, 0}, 0, 1, 2, 3), + __f32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_f64x2_promote_low_f32x4(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__f32x2){((__f32x4)__a)[0], ((__f32x4)__a)[1]}, __f64x2); +} + +#define wasm_i8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ + __c7, __c8, __c9, __c10, __c11, __c12, __c13, \ + __c14, __c15) \ + ((v128_t)__builtin_wasm_shuffle_i8x16( \ + (__i8x16)(__a), (__i8x16)(__b), __c0, __c1, __c2, __c3, __c4, __c5, \ + __c6, __c7, __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15)) + +#define wasm_i16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ + __c7) \ + ((v128_t)__builtin_wasm_shuffle_i8x16( \ + (__i8x16)(__a), (__i8x16)(__b), (__c0)*2, (__c0)*2 + 1, (__c1)*2, \ + (__c1)*2 + 1, (__c2)*2, (__c2)*2 + 1, (__c3)*2, (__c3)*2 + 1, (__c4)*2, \ + (__c4)*2 + 1, (__c5)*2, (__c5)*2 + 1, (__c6)*2, (__c6)*2 + 1, (__c7)*2, \ + (__c7)*2 + 1)) + +#define wasm_i32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) \ + ((v128_t)__builtin_wasm_shuffle_i8x16( \ + (__i8x16)(__a), (__i8x16)(__b), (__c0)*4, (__c0)*4 + 1, (__c0)*4 + 2, \ + (__c0)*4 + 3, (__c1)*4, (__c1)*4 + 1, (__c1)*4 + 2, (__c1)*4 + 3, \ + (__c2)*4, (__c2)*4 + 1, (__c2)*4 + 2, (__c2)*4 + 3, (__c3)*4, \ + (__c3)*4 + 1, (__c3)*4 + 2, (__c3)*4 + 3)) + +#define wasm_i64x2_shuffle(__a, __b, __c0, __c1) \ + ((v128_t)__builtin_wasm_shuffle_i8x16( \ + (__i8x16)(__a), (__i8x16)(__b), (__c0)*8, (__c0)*8 + 1, (__c0)*8 + 2, \ + (__c0)*8 + 3, (__c0)*8 + 4, (__c0)*8 + 5, (__c0)*8 + 6, (__c0)*8 + 7, \ + (__c1)*8, (__c1)*8 + 1, (__c1)*8 + 2, (__c1)*8 + 3, (__c1)*8 + 4, \ + (__c1)*8 + 5, (__c1)*8 + 6, (__c1)*8 + 7)) + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_swizzle(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_swizzle_i8x16((__i8x16)__a, (__i8x16)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i8x16_narrow_i16x8(v128_t __a, v128_t __b) { + return (v128_t)__builtin_wasm_narrow_s_i8x16_i16x8((__i16x8)__a, + (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) { + return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a, + (__i16x8)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_narrow_i32x4(v128_t __a, v128_t __b) { + return (v128_t)__builtin_wasm_narrow_s_i16x8_i32x4((__i32x4)__a, + (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) { + return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a, + (__i32x4)__b); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_extend_low_i8x16(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__i8x8){((__i8x16)__a)[0], ((__i8x16)__a)[1], ((__i8x16)__a)[2], + ((__i8x16)__a)[3], ((__i8x16)__a)[4], ((__i8x16)__a)[5], + ((__i8x16)__a)[6], ((__i8x16)__a)[7]}, + __i16x8); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_extend_high_i8x16(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__i8x8){((__i8x16)__a)[8], ((__i8x16)__a)[9], ((__i8x16)__a)[10], + ((__i8x16)__a)[11], ((__i8x16)__a)[12], ((__i8x16)__a)[13], + ((__i8x16)__a)[14], ((__i8x16)__a)[15]}, + __i16x8); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_extend_low_u8x16(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__u8x8){((__u8x16)__a)[0], ((__u8x16)__a)[1], ((__u8x16)__a)[2], + ((__u8x16)__a)[3], ((__u8x16)__a)[4], ((__u8x16)__a)[5], + ((__u8x16)__a)[6], ((__u8x16)__a)[7]}, + __u16x8); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_extend_high_u8x16(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__u8x8){((__u8x16)__a)[8], ((__u8x16)__a)[9], ((__u8x16)__a)[10], + ((__u8x16)__a)[11], ((__u8x16)__a)[12], ((__u8x16)__a)[13], + ((__u8x16)__a)[14], ((__u8x16)__a)[15]}, + __u16x8); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_extend_low_i16x8(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__i16x4){((__i16x8)__a)[0], ((__i16x8)__a)[1], ((__i16x8)__a)[2], + ((__i16x8)__a)[3]}, + __i32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_extend_high_i16x8(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__i16x4){((__i16x8)__a)[4], ((__i16x8)__a)[5], ((__i16x8)__a)[6], + ((__i16x8)__a)[7]}, + __i32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_extend_low_u16x8(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__u16x4){((__u16x8)__a)[0], ((__u16x8)__a)[1], ((__u16x8)__a)[2], + ((__u16x8)__a)[3]}, + __u32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_extend_high_u16x8(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__u16x4){((__u16x8)__a)[4], ((__u16x8)__a)[5], ((__u16x8)__a)[6], + ((__u16x8)__a)[7]}, + __u32x4); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i64x2_extend_low_i32x4(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__i32x2){((__i32x4)__a)[0], ((__i32x4)__a)[1]}, __i64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i64x2_extend_high_i32x4(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__i32x2){((__i32x4)__a)[2], ((__i32x4)__a)[3]}, __i64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u64x2_extend_low_u32x4(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__u32x2){((__u32x4)__a)[0], ((__u32x4)__a)[1]}, __u64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u64x2_extend_high_u32x4(v128_t __a) { + return (v128_t) __builtin_convertvector( + (__u32x2){((__u32x4)__a)[2], ((__u32x4)__a)[3]}, __u64x2); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_extadd_pairwise_i8x16(v128_t __a) { + return (v128_t)__builtin_wasm_extadd_pairwise_i8x16_s_i16x8((__i8x16)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_extadd_pairwise_u8x16(v128_t __a) { + return (v128_t)__builtin_wasm_extadd_pairwise_i8x16_u_i16x8((__u8x16)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_extadd_pairwise_i16x8(v128_t __a) { + return (v128_t)__builtin_wasm_extadd_pairwise_i16x8_s_i32x4((__i16x8)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_extadd_pairwise_u16x8(v128_t __a) { + return (v128_t)__builtin_wasm_extadd_pairwise_i16x8_u_i32x4((__u16x8)__a); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_extmul_low_i8x16(v128_t __a, v128_t __b) { + return (v128_t)((__i16x8)wasm_i16x8_extend_low_i8x16(__a) * + (__i16x8)wasm_i16x8_extend_low_i8x16(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i16x8_extmul_high_i8x16(v128_t __a, v128_t __b) { + return (v128_t)((__i16x8)wasm_i16x8_extend_high_i8x16(__a) * + (__i16x8)wasm_i16x8_extend_high_i8x16(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_extmul_low_u8x16(v128_t __a, v128_t __b) { + return (v128_t)((__u16x8)wasm_u16x8_extend_low_u8x16(__a) * + (__u16x8)wasm_u16x8_extend_low_u8x16(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u16x8_extmul_high_u8x16(v128_t __a, v128_t __b) { + return (v128_t)((__u16x8)wasm_u16x8_extend_high_u8x16(__a) * + (__u16x8)wasm_u16x8_extend_high_u8x16(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_extmul_low_i16x8(v128_t __a, v128_t __b) { + return (v128_t)((__i32x4)wasm_i32x4_extend_low_i16x8(__a) * + (__i32x4)wasm_i32x4_extend_low_i16x8(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i32x4_extmul_high_i16x8(v128_t __a, v128_t __b) { + return (v128_t)((__i32x4)wasm_i32x4_extend_high_i16x8(__a) * + (__i32x4)wasm_i32x4_extend_high_i16x8(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_extmul_low_u16x8(v128_t __a, v128_t __b) { + return (v128_t)((__u32x4)wasm_u32x4_extend_low_u16x8(__a) * + (__u32x4)wasm_u32x4_extend_low_u16x8(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u32x4_extmul_high_u16x8(v128_t __a, v128_t __b) { + return (v128_t)((__u32x4)wasm_u32x4_extend_high_u16x8(__a) * + (__u32x4)wasm_u32x4_extend_high_u16x8(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i64x2_extmul_low_i32x4(v128_t __a, v128_t __b) { + return (v128_t)((__i64x2)wasm_i64x2_extend_low_i32x4(__a) * + (__i64x2)wasm_i64x2_extend_low_i32x4(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_i64x2_extmul_high_i32x4(v128_t __a, v128_t __b) { + return (v128_t)((__i64x2)wasm_i64x2_extend_high_i32x4(__a) * + (__i64x2)wasm_i64x2_extend_high_i32x4(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u64x2_extmul_low_u32x4(v128_t __a, v128_t __b) { + return (v128_t)((__u64x2)wasm_u64x2_extend_low_u32x4(__a) * + (__u64x2)wasm_u64x2_extend_low_u32x4(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS +wasm_u64x2_extmul_high_u32x4(v128_t __a, v128_t __b) { + return (v128_t)((__u64x2)wasm_u64x2_extend_high_u32x4(__a) * + (__u64x2)wasm_u64x2_extend_high_u32x4(__b)); +} + +static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_q15mulr_sat(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_q15mulr_sat_s_i16x8((__i16x8)__a, (__i16x8)__b); +} + +// Old intrinsic names supported to ease transitioning to the standard names. Do +// not use these; they will be removed in the near future. + +#define __DEPRECATED_FN_ATTRS(__replacement) \ + __DEFAULT_FN_ATTRS __attribute__( \ + (deprecated("use " __replacement " instead", __replacement))) + +#define __WASM_STR(X) #X + +#ifdef __DEPRECATED +#define __DEPRECATED_WASM_MACRO(__name, __replacement) \ + _Pragma(__WASM_STR(GCC warning( \ + "'" __name "' is deprecated: use '" __replacement "' instead"))) +#else +#define __DEPRECATED_WASM_MACRO(__name, __replacement) +#endif + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load8_splat") +wasm_v8x16_load_splat(const void *__mem) { + return wasm_v128_load8_splat(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load16_splat") +wasm_v16x8_load_splat(const void *__mem) { + return wasm_v128_load16_splat(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load32_splat") +wasm_v32x4_load_splat(const void *__mem) { + return wasm_v128_load32_splat(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load64_splat") +wasm_v64x2_load_splat(const void *__mem) { + return wasm_v128_load64_splat(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_load8x8") +wasm_i16x8_load_8x8(const void *__mem) { + return wasm_i16x8_load8x8(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_load8x8") +wasm_u16x8_load_8x8(const void *__mem) { + return wasm_u16x8_load8x8(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_load16x4") +wasm_i32x4_load_16x4(const void *__mem) { + return wasm_i32x4_load16x4(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_load16x4") +wasm_u32x4_load_16x4(const void *__mem) { + return wasm_u32x4_load16x4(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i64x2_load32x2") +wasm_i64x2_load_32x2(const void *__mem) { + return wasm_i64x2_load32x2(__mem); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u64x2_load32x2") +wasm_u64x2_load_32x2(const void *__mem) { + return wasm_u64x2_load32x2(__mem); +} + +#define wasm_v8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ + __c7, __c8, __c9, __c10, __c11, __c12, __c13, \ + __c14, __c15) \ + __DEPRECATED_WASM_MACRO("wasm_v8x16_shuffle", "wasm_i8x16_shuffle") \ + wasm_i8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7, \ + __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15) + +#define wasm_v16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ + __c7) \ + __DEPRECATED_WASM_MACRO("wasm_v16x8_shuffle", "wasm_i16x8_shuffle") \ + wasm_i16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7) + +#define wasm_v32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) \ + __DEPRECATED_WASM_MACRO("wasm_v32x4_shuffle", "wasm_i32x4_shuffle") \ + wasm_i32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) + +#define wasm_v64x2_shuffle(__a, __b, __c0, __c1) \ + __DEPRECATED_WASM_MACRO("wasm_v64x2_shuffle", "wasm_i64x2_shuffle") \ + wasm_i64x2_shuffle(__a, __b, __c0, __c1) + +// Relaxed SIMD intrinsics + +#define __RELAXED_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("relaxed-simd"), \ + __min_vector_width__(128))) + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_f32x4_relaxed_madd(v128_t __a, v128_t __b, v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_madd_f32x4((__f32x4)__a, (__f32x4)__b, + (__f32x4)__c); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_f32x4_relaxed_nmadd(v128_t __a, v128_t __b, v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_nmadd_f32x4((__f32x4)__a, (__f32x4)__b, + (__f32x4)__c); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_f64x2_relaxed_madd(v128_t __a, v128_t __b, v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_madd_f64x2((__f64x2)__a, (__f64x2)__b, + (__f64x2)__c); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_f64x2_relaxed_nmadd(v128_t __a, v128_t __b, v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_nmadd_f64x2((__f64x2)__a, (__f64x2)__b, + (__f64x2)__c); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i8x16_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { + return (v128_t)__builtin_wasm_relaxed_laneselect_i8x16( + (__i8x16)__a, (__i8x16)__b, (__i8x16)__m); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i16x8_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { + return (v128_t)__builtin_wasm_relaxed_laneselect_i16x8( + (__i16x8)__a, (__i16x8)__b, (__i16x8)__m); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i32x4_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { + return (v128_t)__builtin_wasm_relaxed_laneselect_i32x4( + (__i32x4)__a, (__i32x4)__b, (__i32x4)__m); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i64x2_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { + return (v128_t)__builtin_wasm_relaxed_laneselect_i64x2( + (__i64x2)__a, (__i64x2)__b, (__i64x2)__m); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i8x16_relaxed_swizzle(v128_t __a, v128_t __s) { + return (v128_t)__builtin_wasm_relaxed_swizzle_i8x16((__i8x16)__a, + (__i8x16)__s); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f32x4_relaxed_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_relaxed_min_f32x4((__f32x4)__a, (__f32x4)__b); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f32x4_relaxed_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_relaxed_max_f32x4((__f32x4)__a, (__f32x4)__b); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f64x2_relaxed_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_relaxed_min_f64x2((__f64x2)__a, (__f64x2)__b); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f64x2_relaxed_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_relaxed_max_f64x2((__f64x2)__a, (__f64x2)__b); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i32x4_relaxed_trunc_f32x4(v128_t __a) { + return (v128_t)__builtin_wasm_relaxed_trunc_s_i32x4_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_u32x4_relaxed_trunc_f32x4(v128_t __a) { + return (v128_t)__builtin_wasm_relaxed_trunc_u_i32x4_f32x4((__f32x4)__a); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i32x4_relaxed_trunc_f64x2_zero(v128_t __a) { + return (v128_t)__builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_u32x4_relaxed_trunc_f64x2_zero(v128_t __a) { + return (v128_t)__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2((__f64x2)__a); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i16x8_relaxed_q15mulr(v128_t __a, v128_t __b) { + return (v128_t)__builtin_wasm_relaxed_q15mulr_s_i16x8((__i16x8)__a, + (__i16x8)__b); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i16x8_relaxed_dot_i8x16_i7x16(v128_t __a, v128_t __b) { + return (v128_t)__builtin_wasm_relaxed_dot_i8x16_i7x16_s_i16x8((__i8x16)__a, + (__i8x16)__b); +} + +static __inline__ v128_t __RELAXED_FN_ATTRS +wasm_i32x4_relaxed_dot_i8x16_i7x16_add(v128_t __a, v128_t __b, v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_dot_i8x16_i7x16_add_s_i32x4( + (__i8x16)__a, (__i8x16)__b, (__i32x4)__c); +} + +// FP16 intrinsics +#define __FP16_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("fp16"), \ + __min_vector_width__(128))) + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_splat(float __a) { + return (v128_t)__builtin_wasm_splat_f16x8(__a); +} + +#ifdef __wasm_fp16__ +// TODO Replace the following macros with regular C functions and use normal +// target-independent vector code like the other replace/extract instructions. + +#define wasm_f16x8_extract_lane(__a, __i) \ + (__builtin_wasm_extract_lane_f16x8((__f16x8)(__a), __i)) + +#define wasm_f16x8_replace_lane(__a, __i, __b) \ + ((v128_t)__builtin_wasm_replace_lane_f16x8((__f16x8)(__a), __i, __b)) + +#endif + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_abs(v128_t __a) { + return (v128_t)__builtin_wasm_abs_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_neg(v128_t __a) { + return (v128_t)(-(__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_sqrt(v128_t __a) { + return (v128_t)__builtin_wasm_sqrt_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_ceil(v128_t __a) { + return (v128_t)__builtin_wasm_ceil_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_floor(v128_t __a) { + return (v128_t)__builtin_wasm_floor_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_trunc(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_nearest(v128_t __a) { + return (v128_t)__builtin_wasm_nearest_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_eq(v128_t __a, v128_t __b) { + return (v128_t)((__f16x8)__a == (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_ne(v128_t __a, v128_t __b) { + return (v128_t)((__f16x8)__a != (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_lt(v128_t __a, v128_t __b) { + return (v128_t)((__f16x8)__a < (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_gt(v128_t __a, v128_t __b) { + return (v128_t)((__f16x8)__a > (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_le(v128_t __a, v128_t __b) { + return (v128_t)((__f16x8)__a <= (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_ge(v128_t __a, v128_t __b) { + return (v128_t)((__f16x8)__a >= (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_add(v128_t __a, + v128_t __b) { + return (v128_t)((__f16x8)__a + (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_sub(v128_t __a, + v128_t __b) { + return (v128_t)((__f16x8)__a - (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_mul(v128_t __a, + v128_t __b) { + return (v128_t)((__f16x8)__a * (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_div(v128_t __a, + v128_t __b) { + return (v128_t)((__f16x8)__a / (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_min(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_min_f16x8((__f16x8)__a, (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_max(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_max_f16x8((__f16x8)__a, (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_pmin(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_pmin_f16x8((__f16x8)__a, (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_pmax(v128_t __a, + v128_t __b) { + return (v128_t)__builtin_wasm_pmax_f16x8((__f16x8)__a, (__f16x8)__b); +} + +static __inline__ v128_t __FP16_FN_ATTRS +wasm_i16x8_trunc_sat_f16x8(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_saturate_s_i16x8_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS +wasm_u16x8_trunc_sat_f16x8(v128_t __a) { + return (v128_t)__builtin_wasm_trunc_saturate_u_i16x8_f16x8((__f16x8)__a); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_convert_i16x8(v128_t __a) { + return (v128_t) __builtin_convertvector((__i16x8)__a, __f16x8); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_convert_u16x8(v128_t __a) { + return (v128_t) __builtin_convertvector((__u16x8)__a, __f16x8); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_relaxed_madd(v128_t __a, + v128_t __b, + v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_madd_f16x8((__f16x8)__a, (__f16x8)__b, + (__f16x8)__c); +} + +static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_relaxed_nmadd(v128_t __a, + v128_t __b, + v128_t __c) { + return (v128_t)__builtin_wasm_relaxed_nmadd_f16x8((__f16x8)__a, (__f16x8)__b, + (__f16x8)__c); +} + +// Deprecated intrinsics + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_swizzle") +wasm_v8x16_swizzle(v128_t __a, v128_t __b) { + return wasm_i8x16_swizzle(__a, __b); +} + +static __inline__ bool __DEPRECATED_FN_ATTRS("wasm_v128_any_true") +wasm_i8x16_any_true(v128_t __a) { + return wasm_v128_any_true(__a); +} + +static __inline__ bool __DEPRECATED_FN_ATTRS("wasm_v128_any_true") +wasm_i16x8_any_true(v128_t __a) { + return wasm_v128_any_true(__a); +} + +static __inline__ bool __DEPRECATED_FN_ATTRS("wasm_v128_any_true") +wasm_i32x4_any_true(v128_t __a) { + return wasm_v128_any_true(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_add_sat") +wasm_i8x16_add_saturate(v128_t __a, v128_t __b) { + return wasm_i8x16_add_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u8x16_add_sat") +wasm_u8x16_add_saturate(v128_t __a, v128_t __b) { + return wasm_u8x16_add_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_sub_sat") +wasm_i8x16_sub_saturate(v128_t __a, v128_t __b) { + return wasm_i8x16_sub_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u8x16_sub_sat") +wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) { + return wasm_u8x16_sub_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_add_sat") +wasm_i16x8_add_saturate(v128_t __a, v128_t __b) { + return wasm_i16x8_add_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_add_sat") +wasm_u16x8_add_saturate(v128_t __a, v128_t __b) { + return wasm_u16x8_add_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_sub_sat") +wasm_i16x8_sub_saturate(v128_t __a, v128_t __b) { + return wasm_i16x8_sub_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_sub_sat") +wasm_u16x8_sub_saturate(v128_t __a, v128_t __b) { + return wasm_u16x8_sub_sat(__a, __b); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_extend_low_i8x16") +wasm_i16x8_widen_low_i8x16(v128_t __a) { + return wasm_i16x8_extend_low_i8x16(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_extend_high_i8x16") +wasm_i16x8_widen_high_i8x16(v128_t __a) { + return wasm_i16x8_extend_high_i8x16(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_extend_low_u8x16") +wasm_i16x8_widen_low_u8x16(v128_t __a) { + return wasm_u16x8_extend_low_u8x16(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_extend_high_u8x16") +wasm_i16x8_widen_high_u8x16(v128_t __a) { + return wasm_u16x8_extend_high_u8x16(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_extend_low_i16x8") +wasm_i32x4_widen_low_i16x8(v128_t __a) { + return wasm_i32x4_extend_low_i16x8(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_extend_high_i16x8") +wasm_i32x4_widen_high_i16x8(v128_t __a) { + return wasm_i32x4_extend_high_i16x8(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_extend_low_u16x8") +wasm_i32x4_widen_low_u16x8(v128_t __a) { + return wasm_u32x4_extend_low_u16x8(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_extend_high_u16x8") +wasm_i32x4_widen_high_u16x8(v128_t __a) { + return wasm_u32x4_extend_high_u16x8(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_trunc_sat_f32x4") +wasm_i32x4_trunc_saturate_f32x4(v128_t __a) { + return wasm_i32x4_trunc_sat_f32x4(__a); +} + +static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_trunc_sat_f32x4") +wasm_u32x4_trunc_saturate_f32x4(v128_t __a) { + return wasm_u32x4_trunc_sat_f32x4(__a); +} + +// Undefine helper macros +#undef __DEFAULT_FN_ATTRS +#undef __DEPRECATED_FN_ATTRS + +#endif // __WASM_SIMD128_H diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wbnoinvdintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wbnoinvdintrin.h new file mode 100755 index 0000000..cac0347 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wbnoinvdintrin.h @@ -0,0 +1,24 @@ +/*===-------------- wbnoinvdintrin.h - wbnoinvd intrinsic-------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __WBNOINVDINTRIN_H +#define __WBNOINVDINTRIN_H + +static __inline__ void + __attribute__((__always_inline__, __nodebug__, __target__("wbnoinvd"))) +_wbnoinvd (void) +{ + __builtin_ia32_wbnoinvd (); +} + +#endif /* __WBNOINVDINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wmmintrin.h new file mode 100755 index 0000000..49148db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/wmmintrin.h @@ -0,0 +1,23 @@ +/*===---- wmmintrin.h - AES intrinsics ------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __WMMINTRIN_H +#define __WMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +#include <__wmmintrin_aes.h> + +#include <__wmmintrin_pclmul.h> + +#endif /* __WMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/x86gprintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/x86gprintrin.h new file mode 100755 index 0000000..8d513ce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/x86gprintrin.h @@ -0,0 +1,49 @@ +/*===--------------- x86gprintrin.h - X86 GPR intrinsics ------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86GPRINTRIN_H +#define __X86GPRINTRIN_H + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#if defined(__i386__) +#define __SAVE_GPRBX "mov {%%ebx, %%eax |eax, ebx};" +#define __RESTORE_GPRBX "mov {%%eax, %%ebx |ebx, eax};" +#define __TMPGPR "eax" +#else +// When in 64-bit target, the 32-bit operands generate a 32-bit result, +// zero-extended to a 64-bit result in the destination general-purpose, +// It means "mov x %ebx" will clobber the higher 32 bits of rbx, so we +// should preserve the 64-bit register rbx. +#define __SAVE_GPRBX "mov {%%rbx, %%rax |rax, rbx};" +#define __RESTORE_GPRBX "mov {%%rax, %%rbx |rbx, rax};" +#define __TMPGPR "rax" +#endif + +#define __SSC_MARK(__Tag) \ + __asm__ __volatile__( __SAVE_GPRBX \ + "mov {%0, %%ebx|ebx, %0}; " \ + ".byte 0x64, 0x67, 0x90; " \ + __RESTORE_GPRBX \ + ::"i"(__Tag) \ + : __TMPGPR ); + +#endif /* __X86GPRINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/x86intrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/x86intrin.h new file mode 100755 index 0000000..aaa8436 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/x86intrin.h @@ -0,0 +1,35 @@ +/*===---- x86intrin.h - X86 intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#define __X86INTRIN_H + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#include + +#endif /* __X86INTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xmmintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xmmintrin.h new file mode 100755 index 0000000..6a64369 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xmmintrin.h @@ -0,0 +1,3201 @@ +/*===---- xmmintrin.h - SSE intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __XMMINTRIN_H +#define __XMMINTRIN_H + +#if !defined(__i386__) && !defined(__x86_64__) +#error "This header is only meant to be used on x86 and x64 architecture" +#endif + +#include + +typedef int __v4si __attribute__((__vector_size__(16))); +typedef float __v4sf __attribute__((__vector_size__(16))); +typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16))); + +typedef float __m128_u __attribute__((__vector_size__(16), __aligned__(1))); + +/* Unsigned types */ +typedef unsigned int __v4su __attribute__((__vector_size__(16))); + +/* This header should only be included in a hosted environment as it depends on + * a standard library to provide allocation routines. */ +#if __STDC_HOSTED__ +#include +#endif + +/* Define the default attributes for the functions in this file. */ +#if defined(__EVEX512__) && !defined(__AVX10_1_512__) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sse,no-evex512"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS_SSE2 \ + __attribute__((__always_inline__, __nodebug__, \ + __target__("sse2,no-evex512"), __min_vector_width__(128))) +#else +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("sse"), \ + __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS_SSE2 \ + __attribute__((__always_inline__, __nodebug__, __target__("sse2"), \ + __min_vector_width__(128))) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L) +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS constexpr +#define __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR __DEFAULT_FN_ATTRS_SSE2 constexpr +#else +#define __DEFAULT_FN_ATTRS_CONSTEXPR __DEFAULT_FN_ATTRS +#define __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR __DEFAULT_FN_ATTRS_SSE2 +#endif + +#define __trunc64(x) \ + (__m64) __builtin_shufflevector((__v2di)(x), __extension__(__v2di){}, 0) +#define __zext128(x) \ + (__m128i) __builtin_shufflevector((__v2si)(x), __extension__(__v2si){}, 0, \ + 1, 2, 3) +#define __anyext128(x) \ + (__m128i) __builtin_shufflevector((__v2si)(x), __extension__(__v2si){}, 0, \ + 1, -1, -1) +#define __zeroupper64(x) \ + (__m128i) __builtin_shufflevector((__v4si)(x), __extension__(__v4si){}, 0, \ + 1, 4, 5) + +/// Adds the 32-bit float values in the low-order bits of the operands. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDSS / ADDSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The lower 32 bits of this operand are used in the calculation. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The lower 32 bits of this operand are used in the calculation. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the sum +/// of the lower 32 bits of both operands. The upper 96 bits are copied from +/// the upper 96 bits of the first source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_add_ss(__m128 __a, __m128 __b) { + __a[0] += __b[0]; + return __a; +} + +/// Adds two 128-bit vectors of [4 x float], and returns the results of +/// the addition. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VADDPS / ADDPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \returns A 128-bit vector of [4 x float] containing the sums of both +/// operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_add_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4sf)__a + (__v4sf)__b); +} + +/// Subtracts the 32-bit float value in the low-order bits of the second +/// operand from the corresponding value in the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSUBSS / SUBSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing the minuend. The lower 32 bits +/// of this operand are used in the calculation. +/// \param __b +/// A 128-bit vector of [4 x float] containing the subtrahend. The lower 32 +/// bits of this operand are used in the calculation. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the +/// difference of the lower 32 bits of both operands. The upper 96 bits are +/// copied from the upper 96 bits of the first source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_sub_ss(__m128 __a, __m128 __b) { + __a[0] -= __b[0]; + return __a; +} + +/// Subtracts each of the values of the second operand from the first +/// operand, both of which are 128-bit vectors of [4 x float] and returns +/// the results of the subtraction. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSUBPS / SUBPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing the minuend. +/// \param __b +/// A 128-bit vector of [4 x float] containing the subtrahend. +/// \returns A 128-bit vector of [4 x float] containing the differences between +/// both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_sub_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4sf)__a - (__v4sf)__b); +} + +/// Multiplies two 32-bit float values in the low-order bits of the +/// operands. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMULSS / MULSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The lower 32 bits of this operand are used in the calculation. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// The lower 32 bits of this operand are used in the calculation. +/// \returns A 128-bit vector of [4 x float] containing the product of the lower +/// 32 bits of both operands. The upper 96 bits are copied from the upper 96 +/// bits of the first source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_mul_ss(__m128 __a, __m128 __b) { + __a[0] *= __b[0]; + return __a; +} + +/// Multiplies two 128-bit vectors of [4 x float] and returns the +/// results of the multiplication. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMULPS / MULPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \returns A 128-bit vector of [4 x float] containing the products of both +/// operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_mul_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4sf)__a * (__v4sf)__b); +} + +/// Divides the value in the low-order 32 bits of the first operand by +/// the corresponding value in the second operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDIVSS / DIVSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing the dividend. The lower 32 +/// bits of this operand are used in the calculation. +/// \param __b +/// A 128-bit vector of [4 x float] containing the divisor. The lower 32 bits +/// of this operand are used in the calculation. +/// \returns A 128-bit vector of [4 x float] containing the quotients of the +/// lower 32 bits of both operands. The upper 96 bits are copied from the +/// upper 96 bits of the first source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_div_ss(__m128 __a, __m128 __b) { + __a[0] /= __b[0]; + return __a; +} + +/// Divides two 128-bit vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VDIVPS / DIVPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing the dividend. +/// \param __b +/// A 128-bit vector of [4 x float] containing the divisor. +/// \returns A 128-bit vector of [4 x float] containing the quotients of both +/// operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_div_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4sf)__a / (__v4sf)__b); +} + +/// Calculates the square root of the value stored in the low-order bits +/// of a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSQRTSS / SQRTSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the calculation. +/// \returns A 128-bit vector of [4 x float] containing the square root of the +/// value in the low-order bits of the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_sqrt_ss(__m128 __a) +{ + return (__m128)__builtin_ia32_sqrtss((__v4sf)__a); +} + +/// Calculates the square roots of the values stored in a 128-bit vector +/// of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSQRTPS / SQRTPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the square roots of the +/// values in the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_sqrt_ps(__m128 __a) +{ + return __builtin_ia32_sqrtps((__v4sf)__a); +} + +/// Calculates the approximate reciprocal of the value stored in the +/// low-order bits of a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VRCPSS / RCPSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the calculation. +/// \returns A 128-bit vector of [4 x float] containing the approximate +/// reciprocal of the value in the low-order bits of the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_rcp_ss(__m128 __a) +{ + return (__m128)__builtin_ia32_rcpss((__v4sf)__a); +} + +/// Calculates the approximate reciprocals of the values stored in a +/// 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VRCPPS / RCPPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the approximate +/// reciprocals of the values in the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_rcp_ps(__m128 __a) +{ + return (__m128)__builtin_ia32_rcpps((__v4sf)__a); +} + +/// Calculates the approximate reciprocal of the square root of the value +/// stored in the low-order bits of a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VRSQRTSS / RSQRTSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the calculation. +/// \returns A 128-bit vector of [4 x float] containing the approximate +/// reciprocal of the square root of the value in the low-order bits of the +/// operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_rsqrt_ss(__m128 __a) +{ + return __builtin_ia32_rsqrtss((__v4sf)__a); +} + +/// Calculates the approximate reciprocals of the square roots of the +/// values stored in a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VRSQRTPS / RSQRTPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the approximate +/// reciprocals of the square roots of the values in the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_rsqrt_ps(__m128 __a) +{ + return __builtin_ia32_rsqrtps((__v4sf)__a); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands and returns the lesser value in the low-order bits of the +/// vector of [4 x float]. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMINSS / MINSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the +/// minimum value between both operands. The upper 96 bits are copied from +/// the upper 96 bits of the first source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_min_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_minss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 128-bit vectors of [4 x float] and returns the lesser +/// of each pair of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMINPS / MINPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. +/// \returns A 128-bit vector of [4 x float] containing the minimum values +/// between both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_min_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_minps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands and returns the greater value in the low-order bits of a 128-bit +/// vector of [4 x float]. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMAXSS / MAXSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the +/// maximum value between both operands. The upper 96 bits are copied from +/// the upper 96 bits of the first source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_max_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_maxss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 128-bit vectors of [4 x float] and returns the greater +/// of each pair of values. +/// +/// If either value in a comparison is NaN, returns the value from \a __b. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMAXPS / MAXPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. +/// \returns A 128-bit vector of [4 x float] containing the maximum values +/// between both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_max_ps(__m128 __a, __m128 __b) +{ + return __builtin_ia32_maxps((__v4sf)__a, (__v4sf)__b); +} + +/// Performs a bitwise AND of two 128-bit vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VANDPS / ANDPS instructions. +/// +/// \param __a +/// A 128-bit vector containing one of the source operands. +/// \param __b +/// A 128-bit vector containing one of the source operands. +/// \returns A 128-bit vector of [4 x float] containing the bitwise AND of the +/// values between both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_and_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4su)__a & (__v4su)__b); +} + +/// Performs a bitwise AND of two 128-bit vectors of [4 x float], using +/// the one's complement of the values contained in the first source +/// operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VANDNPS / ANDNPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing the first source operand. The +/// one's complement of this value is used in the bitwise AND. +/// \param __b +/// A 128-bit vector of [4 x float] containing the second source operand. +/// \returns A 128-bit vector of [4 x float] containing the bitwise AND of the +/// one's complement of the first operand and the values in the second +/// operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_andnot_ps(__m128 __a, __m128 __b) { + return (__m128)(~(__v4su)__a & (__v4su)__b); +} + +/// Performs a bitwise OR of two 128-bit vectors of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VORPS / ORPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \returns A 128-bit vector of [4 x float] containing the bitwise OR of the +/// values between both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_or_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4su)__a | (__v4su)__b); +} + +/// Performs a bitwise exclusive OR of two 128-bit vectors of +/// [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS / XORPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the source operands. +/// \returns A 128-bit vector of [4 x float] containing the bitwise exclusive OR +/// of the values between both operands. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_xor_ps(__m128 __a, __m128 __b) { + return (__m128)((__v4su)__a ^ (__v4su)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands for equality. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector [4 x float]. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPEQSS / CMPEQSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpeq_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpeqss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] for equality. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPEQPS / CMPEQPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpeq_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpeqps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is less than the +/// corresponding value in the second operand. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTSS / CMPLTSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmplt_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpltss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are less than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTPS / CMPLTPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmplt_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpltps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is less than or +/// equal to the corresponding value in the second operand. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true, in +/// the low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLESS / CMPLESS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmple_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpless((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are less than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLEPS / CMPLEPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmple_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpleps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is greater than +/// the corresponding value in the second operand. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTSS / CMPLTSS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpgt_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_shufflevector((__v4sf)__a, + (__v4sf)__builtin_ia32_cmpltss((__v4sf)__b, (__v4sf)__a), + 4, 1, 2, 3); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLTPS / CMPLTPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpgt_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpltps((__v4sf)__b, (__v4sf)__a); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is greater than +/// or equal to the corresponding value in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLESS / CMPLESS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpge_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_shufflevector((__v4sf)__a, + (__v4sf)__builtin_ia32_cmpless((__v4sf)__b, (__v4sf)__a), + 4, 1, 2, 3); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are greater than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFFFFFFFFFF for true. +/// If either value in a comparison is NaN, returns false. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPLEPS / CMPLEPS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpge_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpleps((__v4sf)__b, (__v4sf)__a); +} + +/// Compares two 32-bit float values in the low-order bits of both operands +/// for inequality. +/// +/// The comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNEQSS / CMPNEQSS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpneq_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpneqss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] for inequality. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNEQPS / CMPNEQPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpneq_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpneqps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is not less than +/// the corresponding value in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTSS / CMPNLTSS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpnlt_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpnltss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are not less than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTPS / CMPNLTPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpnlt_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpnltps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is not less than +/// or equal to the corresponding value in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLESS / CMPNLESS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpnle_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpnless((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are not less than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLEPS / CMPNLEPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpnle_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpnleps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is not greater +/// than the corresponding value in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTSS / CMPNLTSS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpngt_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_shufflevector((__v4sf)__a, + (__v4sf)__builtin_ia32_cmpnltss((__v4sf)__b, (__v4sf)__a), + 4, 1, 2, 3); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are not greater than those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLTPS / CMPNLTPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpngt_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpnltps((__v4sf)__b, (__v4sf)__a); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is not greater +/// than or equal to the corresponding value in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true, in the +/// low-order bits of a vector of [4 x float]. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLESS / CMPNLESS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpnge_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_shufflevector((__v4sf)__a, + (__v4sf)__builtin_ia32_cmpnless((__v4sf)__b, (__v4sf)__a), + 4, 1, 2, 3); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are not greater than or equal to those in the second operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, returns true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPNLEPS / CMPNLEPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpnge_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpnleps((__v4sf)__b, (__v4sf)__a); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is ordered with +/// respect to the corresponding value in the second operand. +/// +/// A pair of floating-point values are ordered with respect to each +/// other if neither value is a NaN. Each comparison returns 0x0 for false, +/// 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPORDSS / CMPORDSS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpord_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpordss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are ordered with respect to those in the second operand. +/// +/// A pair of floating-point values are ordered with respect to each +/// other if neither value is a NaN. Each comparison returns 0x0 for false, +/// 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPORDPS / CMPORDPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpord_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpordps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the value in the first operand is unordered +/// with respect to the corresponding value in the second operand. +/// +/// A pair of double-precision values are unordered with respect to each +/// other if one or both values are NaN. Each comparison returns 0x0 for +/// false, 0xFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPUNORDSS / CMPUNORDSS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float] containing one of the operands. The lower +/// 32 bits of this operand are used in the comparison. +/// \returns A 128-bit vector of [4 x float] containing the comparison results +/// in the low-order bits. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpunord_ss(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpunordss((__v4sf)__a, (__v4sf)__b); +} + +/// Compares each of the corresponding 32-bit float values of the +/// 128-bit vectors of [4 x float] to determine if the values in the first +/// operand are unordered with respect to those in the second operand. +/// +/// A pair of double-precision values are unordered with respect to each +/// other if one or both values are NaN. Each comparison returns 0x0 for +/// false, 0xFFFFFFFFFFFFFFFF for true. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCMPUNORDPS / CMPUNORDPS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_cmpunord_ps(__m128 __a, __m128 __b) +{ + return (__m128)__builtin_ia32_cmpunordps((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands for equality. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISS / COMISS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_comieq_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_comieq((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the first operand is less than the second +/// operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISS / COMISS +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_comilt_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_comilt((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the first operand is less than or equal to the +/// second operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISS / COMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_comile_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_comile((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the first operand is greater than the second +/// operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISS / COMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_comigt_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_comigt((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the first operand is greater than or equal to +/// the second operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISS / COMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_comige_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_comige((__v4sf)__a, (__v4sf)__b); +} + +/// Compares two 32-bit float values in the low-order bits of both +/// operands to determine if the first operand is not equal to the second +/// operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 1. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCOMISS / COMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_comineq_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_comineq((__v4sf)__a, (__v4sf)__b); +} + +/// Performs an unordered comparison of two 32-bit float values using +/// the low-order bits of both operands to determine equality. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISS / UCOMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_ucomieq_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_ucomieq((__v4sf)__a, (__v4sf)__b); +} + +/// Performs an unordered comparison of two 32-bit float values using +/// the low-order bits of both operands to determine if the first operand is +/// less than the second operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISS / UCOMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_ucomilt_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_ucomilt((__v4sf)__a, (__v4sf)__b); +} + +/// Performs an unordered comparison of two 32-bit float values using +/// the low-order bits of both operands to determine if the first operand is +/// less than or equal to the second operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISS / UCOMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_ucomile_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_ucomile((__v4sf)__a, (__v4sf)__b); +} + +/// Performs an unordered comparison of two 32-bit float values using +/// the low-order bits of both operands to determine if the first operand is +/// greater than the second operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISS / UCOMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_ucomigt_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_ucomigt((__v4sf)__a, (__v4sf)__b); +} + +/// Performs an unordered comparison of two 32-bit float values using +/// the low-order bits of both operands to determine if the first operand is +/// greater than or equal to the second operand. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISS / UCOMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_ucomige_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_ucomige((__v4sf)__a, (__v4sf)__b); +} + +/// Performs an unordered comparison of two 32-bit float values using +/// the low-order bits of both operands to determine inequality. +/// +/// The comparison returns 0 for false, 1 for true. If either value in a +/// comparison is NaN, returns 0. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUCOMISS / UCOMISS instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \param __b +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the comparison. +/// \returns An integer containing the comparison results. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_ucomineq_ss(__m128 __a, __m128 __b) +{ + return __builtin_ia32_ucomineq((__v4sf)__a, (__v4sf)__b); +} + +/// Converts a float value contained in the lower 32 bits of a vector of +/// [4 x float] into a 32-bit integer. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSS2SI / CVTSS2SI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the conversion. +/// \returns A 32-bit integer containing the converted value. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_cvtss_si32(__m128 __a) +{ + return __builtin_ia32_cvtss2si((__v4sf)__a); +} + +/// Converts a float value contained in the lower 32 bits of a vector of +/// [4 x float] into a 32-bit integer. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSS2SI / CVTSS2SI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the conversion. +/// \returns A 32-bit integer containing the converted value. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_cvt_ss2si(__m128 __a) +{ + return _mm_cvtss_si32(__a); +} + +#ifdef __x86_64__ + +/// Converts a float value contained in the lower 32 bits of a vector of +/// [4 x float] into a 64-bit integer. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSS2SI / CVTSS2SI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the conversion. +/// \returns A 64-bit integer containing the converted value. +static __inline__ long long __DEFAULT_FN_ATTRS +_mm_cvtss_si64(__m128 __a) +{ + return __builtin_ia32_cvtss2si64((__v4sf)__a); +} + +#endif + +/// Converts two low-order float values in a 128-bit vector of +/// [4 x float] into a 64-bit vector of [2 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPS2PI instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 64-bit integer vector containing the converted values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtps_pi32(__m128 __a) +{ + return __trunc64(__builtin_ia32_cvtps2dq((__v4sf)__zeroupper64(__a))); +} + +/// Converts two low-order float values in a 128-bit vector of +/// [4 x float] into a 64-bit vector of [2 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPS2PI instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 64-bit integer vector containing the converted values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvt_ps2pi(__m128 __a) +{ + return _mm_cvtps_pi32(__a); +} + +/// Converts the lower (first) element of a vector of [4 x float] into a signed +/// truncated (rounded toward zero) 32-bit integer. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTSS2SI / CVTTSS2SI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the conversion. +/// \returns A 32-bit integer containing the converted value. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_cvttss_si32(__m128 __a) +{ + return __builtin_ia32_cvttss2si((__v4sf)__a); +} + +/// Converts the lower (first) element of a vector of [4 x float] into a signed +/// truncated (rounded toward zero) 32-bit integer. +/// +/// If the converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTSS2SI / CVTTSS2SI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the conversion. +/// \returns A 32-bit integer containing the converted value. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_cvtt_ss2si(__m128 __a) +{ + return _mm_cvttss_si32(__a); +} + +#ifdef __x86_64__ +/// Converts the lower (first) element of a vector of [4 x float] into a signed +/// truncated (rounded toward zero) 64-bit integer. +/// +/// If the converted value does not fit in a 64-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTTSS2SI / CVTTSS2SI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the conversion. +/// \returns A 64-bit integer containing the converted value. +static __inline__ long long __DEFAULT_FN_ATTRS +_mm_cvttss_si64(__m128 __a) +{ + return __builtin_ia32_cvttss2si64((__v4sf)__a); +} +#endif + +/// Converts the lower (first) two elements of a 128-bit vector of [4 x float] +/// into two signed truncated (rounded toward zero) 32-bit integers, +/// returned in a 64-bit vector of [2 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTTPS2PI / VTTPS2PI +/// instructions. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 64-bit integer vector containing the converted values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvttps_pi32(__m128 __a) +{ + return __trunc64(__builtin_ia32_cvttps2dq((__v4sf)__zeroupper64(__a))); +} + +/// Converts the lower (first) two elements of a 128-bit vector of [4 x float] +/// into two signed truncated (rounded toward zero) 64-bit integers, +/// returned in a 64-bit vector of [2 x i32]. +/// +/// If a converted value does not fit in a 32-bit integer, raises a +/// floating-point invalid exception. If the exception is masked, returns +/// the most negative integer. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTTPS2PI instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \returns A 64-bit integer vector containing the converted values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtt_ps2pi(__m128 __a) +{ + return _mm_cvttps_pi32(__a); +} + +/// Converts a 32-bit signed integer value into a floating point value +/// and writes it to the lower 32 bits of the destination. The remaining +/// higher order elements of the destination vector are copied from the +/// corresponding elements in the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSI2SS / CVTSI2SS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 32-bit signed integer operand containing the value to be converted. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the +/// converted value of the second operand. The upper 96 bits are copied from +/// the upper 96 bits of the first operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvtsi32_ss(__m128 __a, + int __b) { + __a[0] = __b; + return __a; +} + +/// Converts a 32-bit signed integer value into a floating point value +/// and writes it to the lower 32 bits of the destination. The remaining +/// higher order elements of the destination are copied from the +/// corresponding elements in the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSI2SS / CVTSI2SS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 32-bit signed integer operand containing the value to be converted. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the +/// converted value of the second operand. The upper 96 bits are copied from +/// the upper 96 bits of the first operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvt_si2ss(__m128 __a, + int __b) { + return _mm_cvtsi32_ss(__a, __b); +} + +#ifdef __x86_64__ + +/// Converts a 64-bit signed integer value into a floating point value +/// and writes it to the lower 32 bits of the destination. The remaining +/// higher order elements of the destination are copied from the +/// corresponding elements in the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VCVTSI2SS / CVTSI2SS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 64-bit signed integer operand containing the value to be converted. +/// \returns A 128-bit vector of [4 x float] whose lower 32 bits contain the +/// converted value of the second operand. The upper 96 bits are copied from +/// the upper 96 bits of the first operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtsi64_ss(__m128 __a, long long __b) { + __a[0] = __b; + return __a; +} + +#endif + +/// Converts two elements of a 64-bit vector of [2 x i32] into two +/// floating point values and writes them to the lower 64-bits of the +/// destination. The remaining higher order elements of the destination are +/// copied from the corresponding elements in the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 64-bit vector of [2 x i32]. The elements in this vector are converted +/// and written to the corresponding low-order elements in the destination. +/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the +/// converted value of the second operand. The upper 64 bits are copied from +/// the upper 64 bits of the first operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtpi32_ps(__m128 __a, __m64 __b) +{ + return (__m128)__builtin_shufflevector( + (__v4sf)__a, + __builtin_convertvector((__v4si)__zext128(__b), __v4sf), + 4, 5, 2, 3); +} + +/// Converts two elements of a 64-bit vector of [2 x i32] into two +/// floating point values and writes them to the lower 64-bits of the +/// destination. The remaining higher order elements of the destination are +/// copied from the corresponding elements in the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. +/// \param __b +/// A 64-bit vector of [2 x i32]. The elements in this vector are converted +/// and written to the corresponding low-order elements in the destination. +/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the +/// converted value from the second operand. The upper 64 bits are copied +/// from the upper 64 bits of the first operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvt_pi2ps(__m128 __a, __m64 __b) +{ + return _mm_cvtpi32_ps(__a, __b); +} + +/// Extracts a float value contained in the lower 32 bits of a vector of +/// [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. The lower 32 bits of this operand are +/// used in the extraction. +/// \returns A 32-bit float containing the extracted value. +static __inline__ float __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_cvtss_f32(__m128 __a) { + return __a[0]; +} + +/// Loads two packed float values from the address \a __p into the +/// high-order bits of a 128-bit vector of [4 x float]. The low-order bits +/// are copied from the low-order bits of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVHPD / MOVHPD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. Bits [63:0] are written to bits [63:0] +/// of the destination. +/// \param __p +/// A pointer to two packed float values. Bits [63:0] are written to bits +/// [127:64] of the destination. +/// \returns A 128-bit vector of [4 x float] containing the moved values. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_loadh_pi(__m128 __a, const __m64 *__p) +{ + typedef float __mm_loadh_pi_v2f32 __attribute__((__vector_size__(8))); + struct __mm_loadh_pi_struct { + __mm_loadh_pi_v2f32 __u; + } __attribute__((__packed__, __may_alias__)); + __mm_loadh_pi_v2f32 __b = ((const struct __mm_loadh_pi_struct*)__p)->__u; + __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1); + return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5); +} + +/// Loads two packed float values from the address \a __p into the +/// low-order bits of a 128-bit vector of [4 x float]. The high-order bits +/// are copied from the high-order bits of the first operand. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVLPD / MOVLPD instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. Bits [127:64] are written to bits +/// [127:64] of the destination. +/// \param __p +/// A pointer to two packed float values. Bits [63:0] are written to bits +/// [63:0] of the destination. +/// \returns A 128-bit vector of [4 x float] containing the moved values. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_loadl_pi(__m128 __a, const __m64 *__p) +{ + typedef float __mm_loadl_pi_v2f32 __attribute__((__vector_size__(8))); + struct __mm_loadl_pi_struct { + __mm_loadl_pi_v2f32 __u; + } __attribute__((__packed__, __may_alias__)); + __mm_loadl_pi_v2f32 __b = ((const struct __mm_loadl_pi_struct*)__p)->__u; + __m128 __bb = __builtin_shufflevector(__b, __b, 0, 1, 0, 1); + return __builtin_shufflevector(__a, __bb, 4, 5, 2, 3); +} + +/// Constructs a 128-bit floating-point vector of [4 x float]. The lower +/// 32 bits of the vector are initialized with the single-precision +/// floating-point value loaded from a specified memory location. The upper +/// 96 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSS / MOVSS instruction. +/// +/// \param __p +/// A pointer to a 32-bit memory location containing a single-precision +/// floating-point value. +/// \returns An initialized 128-bit floating-point vector of [4 x float]. The +/// lower 32 bits contain the value loaded from the memory location. The +/// upper 96 bits are set to zero. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_load_ss(const float *__p) +{ + struct __mm_load_ss_struct { + float __u; + } __attribute__((__packed__, __may_alias__)); + float __u = ((const struct __mm_load_ss_struct*)__p)->__u; + return __extension__ (__m128){ __u, 0, 0, 0 }; +} + +/// Loads a 32-bit float value and duplicates it to all four vector +/// elements of a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBROADCASTSS / MOVSS + shuffling +/// instruction. +/// +/// \param __p +/// A pointer to a float value to be loaded and duplicated. +/// \returns A 128-bit vector of [4 x float] containing the loaded and +/// duplicated values. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_load1_ps(const float *__p) +{ + struct __mm_load1_ps_struct { + float __u; + } __attribute__((__packed__, __may_alias__)); + float __u = ((const struct __mm_load1_ps_struct*)__p)->__u; + return __extension__ (__m128){ __u, __u, __u, __u }; +} + +#define _mm_load_ps1(p) _mm_load1_ps(p) + +/// Loads a 128-bit floating-point vector of [4 x float] from an aligned +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS / MOVAPS instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. The address of the memory +/// location has to be 128-bit aligned. +/// \returns A 128-bit vector of [4 x float] containing the loaded values. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_load_ps(const float *__p) +{ + return *(const __m128*)__p; +} + +/// Loads a 128-bit floating-point vector of [4 x float] from an +/// unaligned memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPS / MOVUPS instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \returns A 128-bit vector of [4 x float] containing the loaded values. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_loadu_ps(const float *__p) +{ + struct __loadu_ps { + __m128_u __v; + } __attribute__((__packed__, __may_alias__)); + return ((const struct __loadu_ps*)__p)->__v; +} + +/// Loads four packed float values, in reverse order, from an aligned +/// memory location to 32-bit elements in a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS / MOVAPS + shuffling +/// instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. The address of the memory +/// location has to be 128-bit aligned. +/// \returns A 128-bit vector of [4 x float] containing the moved values, loaded +/// in reverse order. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_loadr_ps(const float *__p) +{ + __m128 __a = _mm_load_ps(__p); + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 3, 2, 1, 0); +} + +/// Create a 128-bit vector of [4 x float] with undefined values. +/// +/// \headerfile +/// +/// This intrinsic has no corresponding instruction. +/// +/// \returns A 128-bit vector of [4 x float] containing undefined values. +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_undefined_ps(void) +{ + return (__m128)__builtin_ia32_undef128(); +} + +/// Constructs a 128-bit floating-point vector of [4 x float]. The lower +/// 32 bits of the vector are initialized with the specified single-precision +/// floating-point value. The upper 96 bits are set to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSS / MOVSS instruction. +/// +/// \param __w +/// A single-precision floating-point value used to initialize the lower 32 +/// bits of the result. +/// \returns An initialized 128-bit floating-point vector of [4 x float]. The +/// lower 32 bits contain the value provided in the source operand. The +/// upper 96 bits are set to zero. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_ss(float __w) { + return __extension__ (__m128){ __w, 0.0f, 0.0f, 0.0f }; +} + +/// Constructs a 128-bit floating-point vector of [4 x float], with each +/// of the four single-precision floating-point vector elements set to the +/// specified single-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPS / PERMILPS instruction. +/// +/// \param __w +/// A single-precision floating-point value used to initialize each vector +/// element of the result. +/// \returns An initialized 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set1_ps(float __w) { + return __extension__ (__m128){ __w, __w, __w, __w }; +} + +/* Microsoft specific. */ +/// Constructs a 128-bit floating-point vector of [4 x float], with each +/// of the four single-precision floating-point vector elements set to the +/// specified single-precision floating-point value. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPERMILPS / PERMILPS instruction. +/// +/// \param __w +/// A single-precision floating-point value used to initialize each vector +/// element of the result. +/// \returns An initialized 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_ps1(float __w) { + return _mm_set1_ps(__w); +} + +/// Constructs a 128-bit floating-point vector of [4 x float] +/// initialized with the specified single-precision floating-point values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __z +/// A single-precision floating-point value used to initialize bits [127:96] +/// of the result. +/// \param __y +/// A single-precision floating-point value used to initialize bits [95:64] +/// of the result. +/// \param __x +/// A single-precision floating-point value used to initialize bits [63:32] +/// of the result. +/// \param __w +/// A single-precision floating-point value used to initialize bits [31:0] +/// of the result. +/// \returns An initialized 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_set_ps(float __z, float __y, float __x, float __w) { + return __extension__ (__m128){ __w, __x, __y, __z }; +} + +/// Constructs a 128-bit floating-point vector of [4 x float], +/// initialized in reverse order with the specified 32-bit single-precision +/// float-point values. +/// +/// \headerfile +/// +/// This intrinsic is a utility function and does not correspond to a specific +/// instruction. +/// +/// \param __z +/// A single-precision floating-point value used to initialize bits [31:0] +/// of the result. +/// \param __y +/// A single-precision floating-point value used to initialize bits [63:32] +/// of the result. +/// \param __x +/// A single-precision floating-point value used to initialize bits [95:64] +/// of the result. +/// \param __w +/// A single-precision floating-point value used to initialize bits [127:96] +/// of the result. +/// \returns An initialized 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_setr_ps(float __z, float __y, float __x, float __w) { + return __extension__ (__m128){ __z, __y, __x, __w }; +} + +/// Constructs a 128-bit floating-point vector of [4 x float] initialized +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VXORPS / XORPS instruction. +/// +/// \returns An initialized 128-bit floating-point vector of [4 x float] with +/// all elements set to zero. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_setzero_ps(void) { + return __extension__ (__m128){ 0.0f, 0.0f, 0.0f, 0.0f }; +} + +/// Stores the upper 64 bits of a 128-bit vector of [4 x float] to a +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VPEXTRQ / PEXTRQ instruction. +/// +/// \param __p +/// A pointer to a 64-bit memory location. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_storeh_pi(__m64 *__p, __m128 __a) +{ + typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8))); + struct __mm_storeh_pi_struct { + __mm_storeh_pi_v2f32 __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, __a, 2, 3); +} + +/// Stores the lower 64 bits of a 128-bit vector of [4 x float] to a +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVLPS / MOVLPS instruction. +/// +/// \param __p +/// A pointer to a memory location that will receive the float values. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_storel_pi(__m64 *__p, __m128 __a) +{ + typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8))); + struct __mm_storeh_pi_struct { + __mm_storeh_pi_v2f32 __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, __a, 0, 1); +} + +/// Stores the lower 32 bits of a 128-bit vector of [4 x float] to a +/// memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVSS / MOVSS instruction. +/// +/// \param __p +/// A pointer to a 32-bit memory location. +/// \param __a +/// A 128-bit vector of [4 x float] containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_store_ss(float *__p, __m128 __a) +{ + struct __mm_store_ss_struct { + float __u; + } __attribute__((__packed__, __may_alias__)); + ((struct __mm_store_ss_struct*)__p)->__u = __a[0]; +} + +/// Stores a 128-bit vector of [4 x float] to an unaligned memory +/// location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVUPS / MOVUPS instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. The address of the memory +/// location does not have to be aligned. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_storeu_ps(float *__p, __m128 __a) +{ + struct __storeu_ps { + __m128_u __v; + } __attribute__((__packed__, __may_alias__)); + ((struct __storeu_ps*)__p)->__v = __a; +} + +/// Stores a 128-bit vector of [4 x float] into an aligned memory +/// location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS / MOVAPS instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. The address of the memory +/// location has to be 16-byte aligned. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_store_ps(float *__p, __m128 __a) +{ + *(__m128*)__p = __a; +} + +/// Stores the lower 32 bits of a 128-bit vector of [4 x float] into +/// four contiguous elements in an aligned memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to VMOVAPS / MOVAPS + shuffling +/// instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. +/// \param __a +/// A 128-bit vector of [4 x float] whose lower 32 bits are stored to each +/// of the four contiguous elements pointed by \a __p. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_store1_ps(float *__p, __m128 __a) +{ + __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 0, 0, 0, 0); + _mm_store_ps(__p, __a); +} + +/// Stores the lower 32 bits of a 128-bit vector of [4 x float] into +/// four contiguous elements in an aligned memory location. +/// +/// \headerfile +/// +/// This intrinsic corresponds to VMOVAPS / MOVAPS + shuffling +/// instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. +/// \param __a +/// A 128-bit vector of [4 x float] whose lower 32 bits are stored to each +/// of the four contiguous elements pointed by \a __p. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_store_ps1(float *__p, __m128 __a) +{ + _mm_store1_ps(__p, __a); +} + +/// Stores float values from a 128-bit vector of [4 x float] to an +/// aligned memory location in reverse order. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVAPS / MOVAPS + shuffling +/// instruction. +/// +/// \param __p +/// A pointer to a 128-bit memory location. The address of the memory +/// location has to be 128-bit aligned. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_storer_ps(float *__p, __m128 __a) +{ + __a = __builtin_shufflevector((__v4sf)__a, (__v4sf)__a, 3, 2, 1, 0); + _mm_store_ps(__p, __a); +} + +#define _MM_HINT_ET0 7 +#define _MM_HINT_ET1 6 +#define _MM_HINT_T0 3 +#define _MM_HINT_T1 2 +#define _MM_HINT_T2 1 +#define _MM_HINT_NTA 0 + +#ifndef _MSC_VER +// If _MSC_VER is defined, we use the builtin variant of _mm_prefetch. +// Otherwise, we provide this macro, which includes a cast, allowing the user +// to pass a pointer of any time. The _mm_prefetch accepts char to match MSVC. + +/// Loads one cache line of data from the specified address to a location +/// closer to the processor. +/// +/// \headerfile +/// +/// \code +/// void _mm_prefetch(const void *a, const int sel); +/// \endcode +/// +/// This intrinsic corresponds to the PREFETCHNTA instruction. +/// +/// \param a +/// A pointer to a memory location containing a cache line of data. +/// \param sel +/// A predefined integer constant specifying the type of prefetch +/// operation: \n +/// _MM_HINT_NTA: Move data using the non-temporal access (NTA) hint. The +/// PREFETCHNTA instruction will be generated. \n +/// _MM_HINT_T0: Move data using the T0 hint. The PREFETCHT0 instruction will +/// be generated. \n +/// _MM_HINT_T1: Move data using the T1 hint. The PREFETCHT1 instruction will +/// be generated. \n +/// _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will +/// be generated. +#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \ + ((sel) >> 2) & 1, (sel) & 0x3)) +#endif + +/// Stores a 64-bit integer in the specified aligned memory location. To +/// minimize caching, the data is flagged as non-temporal (unlikely to be +/// used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MOVNTQ instruction. +/// +/// \param __p +/// A pointer to an aligned memory location used to store the register value. +/// \param __a +/// A 64-bit integer containing the value to be stored. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_stream_pi(void *__p, __m64 __a) +{ + __builtin_nontemporal_store(__a, (__m64 *)__p); +} + +/// Moves packed float values from a 128-bit vector of [4 x float] to a +/// 128-bit aligned memory location. To minimize caching, the data is flagged +/// as non-temporal (unlikely to be used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVNTPS / MOVNTPS instruction. +/// +/// \param __p +/// A pointer to a 128-bit aligned memory location that will receive the +/// single-precision floating-point values. +/// \param __a +/// A 128-bit vector of [4 x float] containing the values to be moved. +static __inline__ void __DEFAULT_FN_ATTRS +_mm_stream_ps(void *__p, __m128 __a) +{ + __builtin_nontemporal_store((__v4sf)__a, (__v4sf*)__p); +} + +#if defined(__cplusplus) +extern "C" { +#endif + +/// Forces strong memory ordering (serialization) between store +/// instructions preceding this instruction and store instructions following +/// this instruction, ensuring the system completes all previous stores +/// before executing subsequent stores. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the SFENCE instruction. +/// +void _mm_sfence(void); + +#if defined(__cplusplus) +} // extern "C" +#endif + +/// Extracts 16-bit element from a 64-bit vector of [4 x i16] and +/// returns it, as specified by the immediate integer operand. +/// +/// \headerfile +/// +/// \code +/// int _mm_extract_pi16(__m64 a, int n); +/// \endcode +/// +/// This intrinsic corresponds to the VPEXTRW / PEXTRW instruction. +/// +/// \param a +/// A 64-bit vector of [4 x i16]. +/// \param n +/// An immediate integer operand that determines which bits are extracted: \n +/// 0: Bits [15:0] are copied to the destination. \n +/// 1: Bits [31:16] are copied to the destination. \n +/// 2: Bits [47:32] are copied to the destination. \n +/// 3: Bits [63:48] are copied to the destination. +/// \returns A 16-bit integer containing the extracted 16 bits of packed data. +#define _mm_extract_pi16(a, n) \ + ((int)(unsigned short)__builtin_ia32_vec_ext_v4hi((__v4hi)a, (int)n)) + +/// Copies data from the 64-bit vector of [4 x i16] to the destination, +/// and inserts the lower 16-bits of an integer operand at the 16-bit offset +/// specified by the immediate operand \a n. +/// +/// \headerfile +/// +/// \code +/// __m64 _mm_insert_pi16(__m64 a, int d, int n); +/// \endcode +/// +/// This intrinsic corresponds to the PINSRW instruction. +/// +/// \param a +/// A 64-bit vector of [4 x i16]. +/// \param d +/// An integer. The lower 16-bit value from this operand is written to the +/// destination at the offset specified by operand \a n. +/// \param n +/// An immediate integer operant that determines which the bits to be used +/// in the destination. \n +/// 0: Bits [15:0] are copied to the destination. \n +/// 1: Bits [31:16] are copied to the destination. \n +/// 2: Bits [47:32] are copied to the destination. \n +/// 3: Bits [63:48] are copied to the destination. \n +/// The remaining bits in the destination are copied from the corresponding +/// bits in operand \a a. +/// \returns A 64-bit integer vector containing the copied packed data from the +/// operands. +#define _mm_insert_pi16(a, d, n) \ + ((__m64)__builtin_ia32_vec_set_v4hi((__v4hi)a, (int)d, (int)n)) + +/// Compares each of the corresponding packed 16-bit integer values of +/// the 64-bit integer vectors, and writes the greater value to the +/// corresponding bits in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMAXSW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the comparison results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_max_pi16(__m64 __a, __m64 __b) +{ + return (__m64)__builtin_elementwise_max((__v4hi)__a, (__v4hi)__b); +} + +/// Compares each of the corresponding packed 8-bit unsigned integer +/// values of the 64-bit integer vectors, and writes the greater value to the +/// corresponding bits in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMAXUB instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the comparison results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_max_pu8(__m64 __a, __m64 __b) +{ + return (__m64)__builtin_elementwise_max((__v8qu)__a, (__v8qu)__b); +} + +/// Compares each of the corresponding packed 16-bit integer values of +/// the 64-bit integer vectors, and writes the lesser value to the +/// corresponding bits in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMINSW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the comparison results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_min_pi16(__m64 __a, __m64 __b) +{ + return (__m64)__builtin_elementwise_min((__v4hi)__a, (__v4hi)__b); +} + +/// Compares each of the corresponding packed 8-bit unsigned integer +/// values of the 64-bit integer vectors, and writes the lesser value to the +/// corresponding bits in the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMINUB instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the comparison results. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_min_pu8(__m64 __a, __m64 __b) +{ + return (__m64)__builtin_elementwise_min((__v8qu)__a, (__v8qu)__b); +} + +/// Takes the most significant bit from each 8-bit element in a 64-bit +/// integer vector to create an 8-bit mask value. Zero-extends the value to +/// 32-bit integer and writes it to the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMOVMSKB instruction. +/// +/// \param __a +/// A 64-bit integer vector containing the values with bits to be extracted. +/// \returns The most significant bit from each 8-bit element in \a __a, +/// written to bits [7:0]. +static __inline__ int __DEFAULT_FN_ATTRS_SSE2 +_mm_movemask_pi8(__m64 __a) +{ + return __builtin_ia32_pmovmskb128((__v16qi)__zext128(__a)); +} + +/// Multiplies packed 16-bit unsigned integer values and writes the +/// high-order 16 bits of each 32-bit product to the corresponding bits in +/// the destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PMULHUW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the products of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_mulhi_pu16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_pmulhuw128((__v8hi)__anyext128(__a), + (__v8hi)__anyext128(__b))); +} + +/// Shuffles the 4 16-bit integers from a 64-bit integer vector to the +/// destination, as specified by the immediate value operand. +/// +/// \headerfile +/// +/// \code +/// __m64 _mm_shuffle_pi16(__m64 a, const int n); +/// \endcode +/// +/// This intrinsic corresponds to the PSHUFW instruction. +/// +/// \param a +/// A 64-bit integer vector containing the values to be shuffled. +/// \param n +/// An immediate value containing an 8-bit value specifying which elements to +/// copy from \a a. The destinations within the 64-bit destination are +/// assigned values as follows: \n +/// Bits [1:0] are used to assign values to bits [15:0] in the +/// destination. \n +/// Bits [3:2] are used to assign values to bits [31:16] in the +/// destination. \n +/// Bits [5:4] are used to assign values to bits [47:32] in the +/// destination. \n +/// Bits [7:6] are used to assign values to bits [63:48] in the +/// destination. \n +/// Bit value assignments: \n +/// 00: assigned from bits [15:0] of \a a. \n +/// 01: assigned from bits [31:16] of \a a. \n +/// 10: assigned from bits [47:32] of \a a. \n +/// 11: assigned from bits [63:48] of \a a. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE macro. +/// _MM_SHUFFLE(b6, b4, b2, b0) can create an 8-bit mask of the form +/// [b6, b4, b2, b0]. +/// \returns A 64-bit integer vector containing the shuffled values. +#define _mm_shuffle_pi16(a, n) \ + ((__m64)__builtin_shufflevector((__v4hi)(__m64)(a), __extension__(__v4hi){}, \ + (n) & 0x3, ((n) >> 2) & 0x3, \ + ((n) >> 4) & 0x3, ((n) >> 6) & 0x3)) + +/// Conditionally copies the values from each 8-bit element in the first +/// 64-bit integer vector operand to the specified memory location, as +/// specified by the most significant bit in the corresponding element in the +/// second 64-bit integer vector operand. +/// +/// To minimize caching, the data is flagged as non-temporal +/// (unlikely to be used again soon). +/// +/// \headerfile +/// +/// This intrinsic corresponds to the MASKMOVQ instruction. +/// +/// \param __d +/// A 64-bit integer vector containing the values with elements to be copied. +/// \param __n +/// A 64-bit integer vector operand. The most significant bit from each 8-bit +/// element determines whether the corresponding element in operand \a __d +/// is copied. If the most significant bit of a given element is 1, the +/// corresponding element in operand \a __d is copied. +/// \param __p +/// A pointer to a 64-bit memory location that will receive the conditionally +/// copied integer values. The address of the memory location does not have +/// to be aligned. +static __inline__ void __DEFAULT_FN_ATTRS_SSE2 +_mm_maskmove_si64(__m64 __d, __m64 __n, char *__p) +{ + // This is complex, because we need to support the case where __p is pointing + // within the last 15 to 8 bytes of a page. In that case, using a 128-bit + // write might cause a trap where a 64-bit maskmovq would not. (Memory + // locations not selected by the mask bits might still cause traps.) + __m128i __d128 = __anyext128(__d); + __m128i __n128 = __zext128(__n); + if (((__SIZE_TYPE__)__p & 0xfff) >= 4096-15 && + ((__SIZE_TYPE__)__p & 0xfff) <= 4096-8) { + // If there's a risk of spurious trap due to a 128-bit write, back up the + // pointer by 8 bytes and shift values in registers to match. + __p -= 8; + __d128 = __builtin_ia32_pslldqi128_byteshift((__v2di)__d128, 8); + __n128 = __builtin_ia32_pslldqi128_byteshift((__v2di)__n128, 8); + } + + __builtin_ia32_maskmovdqu((__v16qi)__d128, (__v16qi)__n128, __p); +} + +/// Computes the rounded averages of the packed unsigned 8-bit integer +/// values and writes the averages to the corresponding bits in the +/// destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PAVGB instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the averages of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_avg_pu8(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_pavgb128((__v16qi)__anyext128(__a), + (__v16qi)__anyext128(__b))); +} + +/// Computes the rounded averages of the packed unsigned 16-bit integer +/// values and writes the averages to the corresponding bits in the +/// destination. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PAVGW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector containing the averages of both operands. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_avg_pu16(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_pavgw128((__v8hi)__anyext128(__a), + (__v8hi)__anyext128(__b))); +} + +/// Subtracts the corresponding 8-bit unsigned integer values of the two +/// 64-bit vector operands and computes the absolute value for each of the +/// difference. Then sum of the 8 absolute differences is written to the +/// bits [15:0] of the destination; the remaining bits [63:16] are cleared. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the PSADBW instruction. +/// +/// \param __a +/// A 64-bit integer vector containing one of the source operands. +/// \param __b +/// A 64-bit integer vector containing one of the source operands. +/// \returns A 64-bit integer vector whose lower 16 bits contain the sums of the +/// sets of absolute differences between both operands. The upper bits are +/// cleared. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_sad_pu8(__m64 __a, __m64 __b) +{ + return __trunc64(__builtin_ia32_psadbw128((__v16qi)__zext128(__a), + (__v16qi)__zext128(__b))); +} + +#if defined(__cplusplus) +extern "C" { +#endif + +/// Returns the contents of the MXCSR register as a 32-bit unsigned +/// integer value. +/// +/// There are several groups of macros associated with this +/// intrinsic, including: +///
    +///
  • +/// For checking exception states: _MM_EXCEPT_INVALID, _MM_EXCEPT_DIV_ZERO, +/// _MM_EXCEPT_DENORM, _MM_EXCEPT_OVERFLOW, _MM_EXCEPT_UNDERFLOW, +/// _MM_EXCEPT_INEXACT. There is a convenience wrapper +/// _MM_GET_EXCEPTION_STATE(). +///
  • +///
  • +/// For checking exception masks: _MM_MASK_UNDERFLOW, _MM_MASK_OVERFLOW, +/// _MM_MASK_INVALID, _MM_MASK_DENORM, _MM_MASK_DIV_ZERO, _MM_MASK_INEXACT. +/// There is a convenience wrapper _MM_GET_EXCEPTION_MASK(). +///
  • +///
  • +/// For checking rounding modes: _MM_ROUND_NEAREST, _MM_ROUND_DOWN, +/// _MM_ROUND_UP, _MM_ROUND_TOWARD_ZERO. There is a convenience wrapper +/// _MM_GET_ROUNDING_MODE(). +///
  • +///
  • +/// For checking flush-to-zero mode: _MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_OFF. +/// There is a convenience wrapper _MM_GET_FLUSH_ZERO_MODE(). +///
  • +///
  • +/// For checking denormals-are-zero mode: _MM_DENORMALS_ZERO_ON, +/// _MM_DENORMALS_ZERO_OFF. There is a convenience wrapper +/// _MM_GET_DENORMALS_ZERO_MODE(). +///
  • +///
+/// +/// For example, the following expression checks if an overflow exception has +/// occurred: +/// \code +/// ( _mm_getcsr() & _MM_EXCEPT_OVERFLOW ) +/// \endcode +/// +/// The following expression gets the current rounding mode: +/// \code +/// _MM_GET_ROUNDING_MODE() +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VSTMXCSR / STMXCSR instruction. +/// +/// \returns A 32-bit unsigned integer containing the contents of the MXCSR +/// register. +unsigned int _mm_getcsr(void); + +/// Sets the MXCSR register with the 32-bit unsigned integer value. +/// +/// There are several groups of macros associated with this intrinsic, +/// including: +///
    +///
  • +/// For setting exception states: _MM_EXCEPT_INVALID, _MM_EXCEPT_DIV_ZERO, +/// _MM_EXCEPT_DENORM, _MM_EXCEPT_OVERFLOW, _MM_EXCEPT_UNDERFLOW, +/// _MM_EXCEPT_INEXACT. There is a convenience wrapper +/// _MM_SET_EXCEPTION_STATE(x) where x is one of these macros. +///
  • +///
  • +/// For setting exception masks: _MM_MASK_UNDERFLOW, _MM_MASK_OVERFLOW, +/// _MM_MASK_INVALID, _MM_MASK_DENORM, _MM_MASK_DIV_ZERO, _MM_MASK_INEXACT. +/// There is a convenience wrapper _MM_SET_EXCEPTION_MASK(x) where x is one +/// of these macros. +///
  • +///
  • +/// For setting rounding modes: _MM_ROUND_NEAREST, _MM_ROUND_DOWN, +/// _MM_ROUND_UP, _MM_ROUND_TOWARD_ZERO. There is a convenience wrapper +/// _MM_SET_ROUNDING_MODE(x) where x is one of these macros. +///
  • +///
  • +/// For setting flush-to-zero mode: _MM_FLUSH_ZERO_ON, _MM_FLUSH_ZERO_OFF. +/// There is a convenience wrapper _MM_SET_FLUSH_ZERO_MODE(x) where x is +/// one of these macros. +///
  • +///
  • +/// For setting denormals-are-zero mode: _MM_DENORMALS_ZERO_ON, +/// _MM_DENORMALS_ZERO_OFF. There is a convenience wrapper +/// _MM_SET_DENORMALS_ZERO_MODE(x) where x is one of these macros. +///
  • +///
+/// +/// For example, the following expression causes subsequent floating-point +/// operations to round up: +/// _mm_setcsr(_mm_getcsr() | _MM_ROUND_UP) +/// +/// The following example sets the DAZ and FTZ flags: +/// \code +/// void setFlags() { +/// _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); +/// _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); +/// } +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VLDMXCSR / LDMXCSR instruction. +/// +/// \param __i +/// A 32-bit unsigned integer value to be written to the MXCSR register. +void _mm_setcsr(unsigned int __i); + +#if defined(__cplusplus) +} // extern "C" +#endif + +/// Selects 4 float values from the 128-bit operands of [4 x float], as +/// specified by the immediate value operand. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_shuffle_ps(__m128 a, __m128 b, const int mask); +/// \endcode +/// +/// This intrinsic corresponds to the VSHUFPS / SHUFPS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float]. +/// \param b +/// A 128-bit vector of [4 x float]. +/// \param mask +/// An immediate value containing an 8-bit value specifying which elements to +/// copy from \a a and \a b. \n +/// Bits [3:0] specify the values copied from operand \a a. \n +/// Bits [7:4] specify the values copied from operand \a b. \n +/// The destinations within the 128-bit destination are assigned values as +/// follows: \n +/// Bits [1:0] are used to assign values to bits [31:0] in the +/// destination. \n +/// Bits [3:2] are used to assign values to bits [63:32] in the +/// destination. \n +/// Bits [5:4] are used to assign values to bits [95:64] in the +/// destination. \n +/// Bits [7:6] are used to assign values to bits [127:96] in the +/// destination. \n +/// Bit value assignments: \n +/// 00: Bits [31:0] copied from the specified operand. \n +/// 01: Bits [63:32] copied from the specified operand. \n +/// 10: Bits [95:64] copied from the specified operand. \n +/// 11: Bits [127:96] copied from the specified operand. \n +/// Note: To generate a mask, you can use the \c _MM_SHUFFLE macro. +/// _MM_SHUFFLE(b6, b4, b2, b0) can create an 8-bit mask of the form +/// [b6, b4, b2, b0]. +/// \returns A 128-bit vector of [4 x float] containing the shuffled values. +#define _mm_shuffle_ps(a, b, mask) \ + ((__m128)__builtin_ia32_shufps((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), \ + (int)(mask))) + +/// Unpacks the high-order (index 2,3) values from two 128-bit vectors of +/// [4 x float] and interleaves them into a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKHPS / UNPCKHPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. \n +/// Bits [95:64] are written to bits [31:0] of the destination. \n +/// Bits [127:96] are written to bits [95:64] of the destination. +/// \param __b +/// A 128-bit vector of [4 x float]. +/// Bits [95:64] are written to bits [63:32] of the destination. \n +/// Bits [127:96] are written to bits [127:96] of the destination. +/// \returns A 128-bit vector of [4 x float] containing the interleaved values. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_unpackhi_ps(__m128 __a, __m128 __b) { + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 2, 6, 3, 7); +} + +/// Unpacks the low-order (index 0,1) values from two 128-bit vectors of +/// [4 x float] and interleaves them into a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPS / UNPCKLPS instruction. +/// +/// \param __a +/// A 128-bit vector of [4 x float]. \n +/// Bits [31:0] are written to bits [31:0] of the destination. \n +/// Bits [63:32] are written to bits [95:64] of the destination. +/// \param __b +/// A 128-bit vector of [4 x float]. \n +/// Bits [31:0] are written to bits [63:32] of the destination. \n +/// Bits [63:32] are written to bits [127:96] of the destination. +/// \returns A 128-bit vector of [4 x float] containing the interleaved values. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_unpacklo_ps(__m128 __a, __m128 __b) { + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 0, 4, 1, 5); +} + +/// Constructs a 128-bit floating-point vector of [4 x float]. The lower +/// 32 bits are set to the lower 32 bits of the second parameter. The upper +/// 96 bits are set to the upper 96 bits of the first parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VBLENDPS / BLENDPS / MOVSS +/// instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. The upper 96 bits are +/// written to the upper 96 bits of the result. +/// \param __b +/// A 128-bit floating-point vector of [4 x float]. The lower 32 bits are +/// written to the lower 32 bits of the result. +/// \returns A 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_move_ss(__m128 __a, __m128 __b) { + __a[0] = __b[0]; + return __a; +} + +/// Constructs a 128-bit floating-point vector of [4 x float]. The lower +/// 64 bits are set to the upper 64 bits of the second parameter. The upper +/// 64 bits are set to the upper 64 bits of the first parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKHPD / UNPCKHPD instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. The upper 64 bits are +/// written to the upper 64 bits of the result. +/// \param __b +/// A 128-bit floating-point vector of [4 x float]. The upper 64 bits are +/// written to the lower 64 bits of the result. +/// \returns A 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_movehl_ps(__m128 __a, __m128 __b) { + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 6, 7, 2, 3); +} + +/// Constructs a 128-bit floating-point vector of [4 x float]. The lower +/// 64 bits are set to the lower 64 bits of the first parameter. The upper +/// 64 bits are set to the lower 64 bits of the second parameter. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VUNPCKLPD / UNPCKLPD instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. The lower 64 bits are +/// written to the lower 64 bits of the result. +/// \param __b +/// A 128-bit floating-point vector of [4 x float]. The lower 64 bits are +/// written to the upper 64 bits of the result. +/// \returns A 128-bit floating-point vector of [4 x float]. +static __inline__ __m128 __DEFAULT_FN_ATTRS_CONSTEXPR +_mm_movelh_ps(__m128 __a, __m128 __b) { + return __builtin_shufflevector((__v4sf)__a, (__v4sf)__b, 0, 1, 4, 5); +} + +/// Converts a 64-bit vector of [4 x i16] into a 128-bit vector of [4 x +/// float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS + COMPOSITE instruction. +/// +/// \param __a +/// A 64-bit vector of [4 x i16]. The elements of the destination are copied +/// from the corresponding elements in this operand. +/// \returns A 128-bit vector of [4 x float] containing the copied and converted +/// values from the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtpi16_ps(__m64 __a) +{ + return __builtin_convertvector((__v4hi)__a, __v4sf); +} + +/// Converts a 64-bit vector of 16-bit unsigned integer values into a +/// 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS + COMPOSITE instruction. +/// +/// \param __a +/// A 64-bit vector of 16-bit unsigned integer values. The elements of the +/// destination are copied from the corresponding elements in this operand. +/// \returns A 128-bit vector of [4 x float] containing the copied and converted +/// values from the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtpu16_ps(__m64 __a) +{ + return __builtin_convertvector((__v4hu)__a, __v4sf); +} + +/// Converts the lower four 8-bit values from a 64-bit vector of [8 x i8] +/// into a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS + COMPOSITE instruction. +/// +/// \param __a +/// A 64-bit vector of [8 x i8]. The elements of the destination are copied +/// from the corresponding lower 4 elements in this operand. +/// \returns A 128-bit vector of [4 x float] containing the copied and converted +/// values from the operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtpi8_ps(__m64 __a) +{ + return __builtin_convertvector( + __builtin_shufflevector((__v8qs)__a, __extension__ (__v8qs){}, + 0, 1, 2, 3), __v4sf); +} + +/// Converts the lower four unsigned 8-bit integer values from a 64-bit +/// vector of [8 x u8] into a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS + COMPOSITE instruction. +/// +/// \param __a +/// A 64-bit vector of unsigned 8-bit integer values. The elements of the +/// destination are copied from the corresponding lower 4 elements in this +/// operand. +/// \returns A 128-bit vector of [4 x float] containing the copied and converted +/// values from the source operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtpu8_ps(__m64 __a) +{ + return __builtin_convertvector( + __builtin_shufflevector((__v8qu)__a, __extension__ (__v8qu){}, + 0, 1, 2, 3), __v4sf); +} + +/// Converts the two 32-bit signed integer values from each 64-bit vector +/// operand of [2 x i32] into a 128-bit vector of [4 x float]. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPI2PS + COMPOSITE instruction. +/// +/// \param __a +/// A 64-bit vector of [2 x i32]. The lower elements of the destination are +/// copied from the elements in this operand. +/// \param __b +/// A 64-bit vector of [2 x i32]. The upper elements of the destination are +/// copied from the elements in this operand. +/// \returns A 128-bit vector of [4 x float] whose lower 64 bits contain the +/// copied and converted values from the first operand. The upper 64 bits +/// contain the copied and converted values from the second operand. +static __inline__ __m128 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtpi32x2_ps(__m64 __a, __m64 __b) +{ + return __builtin_convertvector( + __builtin_shufflevector((__v2si)__a, (__v2si)__b, + 0, 1, 2, 3), __v4sf); +} + +/// Converts each single-precision floating-point element of a 128-bit +/// floating-point vector of [4 x float] into a 16-bit signed integer, and +/// packs the results into a 64-bit integer vector of [4 x i16]. +/// +/// If the floating-point element is NaN or infinity, or if the +/// floating-point element is greater than 0x7FFFFFFF or less than -0x8000, +/// it is converted to 0x8000. Otherwise if the floating-point element is +/// greater than 0x7FFF, it is converted to 0x7FFF. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPS2PI + COMPOSITE instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. +/// \returns A 64-bit integer vector of [4 x i16] containing the converted +/// values. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtps_pi16(__m128 __a) +{ + return __trunc64(__builtin_ia32_packssdw128( + (__v4si)__builtin_ia32_cvtps2dq((__v4sf)__a), (__v4si)_mm_setzero_ps())); +} + +/// Converts each single-precision floating-point element of a 128-bit +/// floating-point vector of [4 x float] into an 8-bit signed integer, and +/// packs the results into the lower 32 bits of a 64-bit integer vector of +/// [8 x i8]. The upper 32 bits of the vector are set to 0. +/// +/// If the floating-point element is NaN or infinity, or if the +/// floating-point element is greater than 0x7FFFFFFF or less than -0x80, it +/// is converted to 0x80. Otherwise if the floating-point element is greater +/// than 0x7F, it is converted to 0x7F. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the CVTPS2PI + COMPOSITE instruction. +/// +/// \param __a +/// 128-bit floating-point vector of [4 x float]. +/// \returns A 64-bit integer vector of [8 x i8]. The lower 32 bits contain the +/// converted values and the uppper 32 bits are set to zero. +static __inline__ __m64 __DEFAULT_FN_ATTRS_SSE2 +_mm_cvtps_pi8(__m128 __a) +{ + __m64 __b, __c; + + __b = _mm_cvtps_pi16(__a); + __c = _mm_setzero_si64(); + + return _mm_packs_pi16(__b, __c); +} + +/// Extracts the sign bits from each single-precision floating-point +/// element of a 128-bit floating-point vector of [4 x float] and returns the +/// sign bits in bits [0:3] of the result. Bits [31:4] of the result are set +/// to zero. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the VMOVMSKPS / MOVMSKPS instruction. +/// +/// \param __a +/// A 128-bit floating-point vector of [4 x float]. +/// \returns A 32-bit integer value. Bits [3:0] contain the sign bits from each +/// single-precision floating-point element of the parameter. Bits [31:4] are +/// set to zero. +static __inline__ int __DEFAULT_FN_ATTRS +_mm_movemask_ps(__m128 __a) +{ + return __builtin_ia32_movmskps((__v4sf)__a); +} + +/* Compare */ +#define _CMP_EQ_OQ 0x00 /* Equal (ordered, non-signaling) */ +#define _CMP_LT_OS 0x01 /* Less-than (ordered, signaling) */ +#define _CMP_LE_OS 0x02 /* Less-than-or-equal (ordered, signaling) */ +#define _CMP_UNORD_Q 0x03 /* Unordered (non-signaling) */ +#define _CMP_NEQ_UQ 0x04 /* Not-equal (unordered, non-signaling) */ +#define _CMP_NLT_US 0x05 /* Not-less-than (unordered, signaling) */ +#define _CMP_NLE_US 0x06 /* Not-less-than-or-equal (unordered, signaling) */ +#define _CMP_ORD_Q 0x07 /* Ordered (non-signaling) */ + +/// Compares each of the corresponding values of two 128-bit vectors of +/// [4 x float], using the operation specified by the immediate integer +/// operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_cmp_ps(__m128 a, __m128 b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the (V)CMPPS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float]. +/// \param b +/// A 128-bit vector of [4 x float]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +#define _mm_cmp_ps(a, b, c) \ + ((__m128)__builtin_ia32_cmpps((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), (c))) + +/// Compares each of the corresponding scalar values of two 128-bit +/// vectors of [4 x float], using the operation specified by the immediate +/// integer operand. +/// +/// Each comparison returns 0x0 for false, 0xFFFFFFFF for true. +/// If either value in a comparison is NaN, comparisons that are ordered +/// return false, and comparisons that are unordered return true. +/// +/// \headerfile +/// +/// \code +/// __m128 _mm_cmp_ss(__m128 a, __m128 b, const int c); +/// \endcode +/// +/// This intrinsic corresponds to the (V)CMPSS instruction. +/// +/// \param a +/// A 128-bit vector of [4 x float]. +/// \param b +/// A 128-bit vector of [4 x float]. +/// \param c +/// An immediate integer operand, with bits [4:0] specifying which comparison +/// operation to use: \n +/// 0x00: Equal (ordered, non-signaling) \n +/// 0x01: Less-than (ordered, signaling) \n +/// 0x02: Less-than-or-equal (ordered, signaling) \n +/// 0x03: Unordered (non-signaling) \n +/// 0x04: Not-equal (unordered, non-signaling) \n +/// 0x05: Not-less-than (unordered, signaling) \n +/// 0x06: Not-less-than-or-equal (unordered, signaling) \n +/// 0x07: Ordered (non-signaling) \n +/// \returns A 128-bit vector of [4 x float] containing the comparison results. +#define _mm_cmp_ss(a, b, c) \ + ((__m128)__builtin_ia32_cmpss((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), (c))) + +#define _MM_ALIGN16 __attribute__((aligned(16))) + +#define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) + +#define _MM_EXCEPT_INVALID (0x0001U) +#define _MM_EXCEPT_DENORM (0x0002U) +#define _MM_EXCEPT_DIV_ZERO (0x0004U) +#define _MM_EXCEPT_OVERFLOW (0x0008U) +#define _MM_EXCEPT_UNDERFLOW (0x0010U) +#define _MM_EXCEPT_INEXACT (0x0020U) +#define _MM_EXCEPT_MASK (0x003fU) + +#define _MM_MASK_INVALID (0x0080U) +#define _MM_MASK_DENORM (0x0100U) +#define _MM_MASK_DIV_ZERO (0x0200U) +#define _MM_MASK_OVERFLOW (0x0400U) +#define _MM_MASK_UNDERFLOW (0x0800U) +#define _MM_MASK_INEXACT (0x1000U) +#define _MM_MASK_MASK (0x1f80U) + +#define _MM_ROUND_NEAREST (0x0000U) +#define _MM_ROUND_DOWN (0x2000U) +#define _MM_ROUND_UP (0x4000U) +#define _MM_ROUND_TOWARD_ZERO (0x6000U) +#define _MM_ROUND_MASK (0x6000U) + +#define _MM_FLUSH_ZERO_MASK (0x8000U) +#define _MM_FLUSH_ZERO_ON (0x8000U) +#define _MM_FLUSH_ZERO_OFF (0x0000U) + +#define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK) +#define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK) +#define _MM_GET_FLUSH_ZERO_MODE() (_mm_getcsr() & _MM_FLUSH_ZERO_MASK) +#define _MM_GET_ROUNDING_MODE() (_mm_getcsr() & _MM_ROUND_MASK) + +#define _MM_SET_EXCEPTION_MASK(x) (_mm_setcsr((_mm_getcsr() & ~_MM_MASK_MASK) | (x))) +#define _MM_SET_EXCEPTION_STATE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_EXCEPT_MASK) | (x))) +#define _MM_SET_FLUSH_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_FLUSH_ZERO_MASK) | (x))) +#define _MM_SET_ROUNDING_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_ROUND_MASK) | (x))) + +#define _MM_TRANSPOSE4_PS(row0, row1, row2, row3) \ +do { \ + __m128 tmp3, tmp2, tmp1, tmp0; \ + tmp0 = _mm_unpacklo_ps((row0), (row1)); \ + tmp2 = _mm_unpacklo_ps((row2), (row3)); \ + tmp1 = _mm_unpackhi_ps((row0), (row1)); \ + tmp3 = _mm_unpackhi_ps((row2), (row3)); \ + (row0) = _mm_movelh_ps(tmp0, tmp2); \ + (row1) = _mm_movehl_ps(tmp2, tmp0); \ + (row2) = _mm_movelh_ps(tmp1, tmp3); \ + (row3) = _mm_movehl_ps(tmp3, tmp1); \ +} while (0) + +/* Aliases for compatibility. */ +#define _m_pextrw _mm_extract_pi16 +#define _m_pinsrw _mm_insert_pi16 +#define _m_pmaxsw _mm_max_pi16 +#define _m_pmaxub _mm_max_pu8 +#define _m_pminsw _mm_min_pi16 +#define _m_pminub _mm_min_pu8 +#define _m_pmovmskb _mm_movemask_pi8 +#define _m_pmulhuw _mm_mulhi_pu16 +#define _m_pshufw _mm_shuffle_pi16 +#define _m_maskmovq _mm_maskmove_si64 +#define _m_pavgb _mm_avg_pu8 +#define _m_pavgw _mm_avg_pu16 +#define _m_psadbw _mm_sad_pu8 +#define _m_ _mm_ + +#undef __trunc64 +#undef __zext128 +#undef __anyext128 +#undef __zeroupper64 +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS_CONSTEXPR +#undef __DEFAULT_FN_ATTRS_SSE2 +#undef __DEFAULT_FN_ATTRS_SSE2_CONSTEXPR + +/* Ugly hack for backwards-compatibility (compatible with gcc) */ +#if defined(__SSE2__) && !__building_module(_Builtin_intrinsics) +#include +#endif + +#endif /* __XMMINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xopintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xopintrin.h new file mode 100755 index 0000000..976cdf4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xopintrin.h @@ -0,0 +1,770 @@ +/*===---- xopintrin.h - XOP intrinsics -------------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __XOPINTRIN_H +#define __XOPINTRIN_H + +#include + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xop"), __min_vector_width__(128))) +#define __DEFAULT_FN_ATTRS256 __attribute__((__always_inline__, __nodebug__, __target__("xop"), __min_vector_width__(256))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacssww((__v8hi)__A, (__v8hi)__B, (__v8hi)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_macc_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacsww((__v8hi)__A, (__v8hi)__B, (__v8hi)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maccsd_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacsswd((__v8hi)__A, (__v8hi)__B, (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maccd_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacswd((__v8hi)__A, (__v8hi)__B, (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maccs_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacssdd((__v4si)__A, (__v4si)__B, (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_macc_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacsdd((__v4si)__A, (__v4si)__B, (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maccslo_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacssdql((__v4si)__A, (__v4si)__B, (__v2di)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_macclo_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacsdql((__v4si)__A, (__v4si)__B, (__v2di)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maccshi_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacssdqh((__v4si)__A, (__v4si)__B, (__v2di)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_macchi_epi32(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmacsdqh((__v4si)__A, (__v4si)__B, (__v2di)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maddsd_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmadcsswd((__v8hi)__A, (__v8hi)__B, (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_maddd_epi16(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpmadcswd((__v8hi)__A, (__v8hi)__B, (__v4si)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddw_epi8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddbw((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddd_epi8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddbd((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddq_epi8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddbq((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddd_epi16(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddwd((__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddq_epi16(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddwq((__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddq_epi32(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphadddq((__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddw_epu8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddubw((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddd_epu8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddubd((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddq_epu8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddubq((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddd_epu16(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphadduwd((__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddq_epu16(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphadduwq((__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_haddq_epu32(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphaddudq((__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hsubw_epi8(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphsubbw((__v16qi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hsubd_epi16(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphsubwd((__v8hi)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_hsubq_epi32(__m128i __A) +{ + return (__m128i)__builtin_ia32_vphsubdq((__v4si)__A); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_cmov_si128(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)(((__v2du)__A & (__v2du)__C) | ((__v2du)__B & ~(__v2du)__C)); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS256 +_mm256_cmov_si256(__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i)(((__v4du)__A & (__v4du)__C) | ((__v4du)__B & ~(__v4du)__C)); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_perm_epi8(__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i)__builtin_ia32_vpperm((__v16qi)__A, (__v16qi)__B, (__v16qi)__C); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_rot_epi8(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vprotb((__v16qi)__A, (__v16qi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_rot_epi16(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vprotw((__v8hi)__A, (__v8hi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_rot_epi32(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vprotd((__v4si)__A, (__v4si)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_rot_epi64(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vprotq((__v2di)__A, (__v2di)__B); +} + +#define _mm_roti_epi8(A, N) \ + ((__m128i)__builtin_ia32_vprotbi((__v16qi)(__m128i)(A), (N))) + +#define _mm_roti_epi16(A, N) \ + ((__m128i)__builtin_ia32_vprotwi((__v8hi)(__m128i)(A), (N))) + +#define _mm_roti_epi32(A, N) \ + ((__m128i)__builtin_ia32_vprotdi((__v4si)(__m128i)(A), (N))) + +#define _mm_roti_epi64(A, N) \ + ((__m128i)__builtin_ia32_vprotqi((__v2di)(__m128i)(A), (N))) + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_shl_epi8(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshlb((__v16qi)__A, (__v16qi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_shl_epi16(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshlw((__v8hi)__A, (__v8hi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_shl_epi32(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshld((__v4si)__A, (__v4si)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_shl_epi64(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshlq((__v2di)__A, (__v2di)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha_epi8(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshab((__v16qi)__A, (__v16qi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha_epi16(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshaw((__v8hi)__A, (__v8hi)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha_epi32(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshad((__v4si)__A, (__v4si)__B); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_sha_epi64(__m128i __A, __m128i __B) +{ + return (__m128i)__builtin_ia32_vpshaq((__v2di)__A, (__v2di)__B); +} + +#define _mm_com_epu8(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomub((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (N))) + +#define _mm_com_epu16(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomuw((__v8hi)(__m128i)(A), \ + (__v8hi)(__m128i)(B), (N))) + +#define _mm_com_epu32(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomud((__v4si)(__m128i)(A), \ + (__v4si)(__m128i)(B), (N))) + +#define _mm_com_epu64(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomuq((__v2di)(__m128i)(A), \ + (__v2di)(__m128i)(B), (N))) + +#define _mm_com_epi8(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomb((__v16qi)(__m128i)(A), \ + (__v16qi)(__m128i)(B), (N))) + +#define _mm_com_epi16(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomw((__v8hi)(__m128i)(A), \ + (__v8hi)(__m128i)(B), (N))) + +#define _mm_com_epi32(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomd((__v4si)(__m128i)(A), \ + (__v4si)(__m128i)(B), (N))) + +#define _mm_com_epi64(A, B, N) \ + ((__m128i)__builtin_ia32_vpcomq((__v2di)(__m128i)(A), \ + (__v2di)(__m128i)(B), (N))) + +#define _MM_PCOMCTRL_LT 0 +#define _MM_PCOMCTRL_LE 1 +#define _MM_PCOMCTRL_GT 2 +#define _MM_PCOMCTRL_GE 3 +#define _MM_PCOMCTRL_EQ 4 +#define _MM_PCOMCTRL_NEQ 5 +#define _MM_PCOMCTRL_FALSE 6 +#define _MM_PCOMCTRL_TRUE 7 + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epu8(__m128i __A, __m128i __B) +{ + return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epu16(__m128i __A, __m128i __B) +{ + return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epu32(__m128i __A, __m128i __B) +{ + return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epu64(__m128i __A, __m128i __B) +{ + return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epi8(__m128i __A, __m128i __B) +{ + return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epi16(__m128i __A, __m128i __B) +{ + return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epi32(__m128i __A, __m128i __B) +{ + return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_TRUE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comlt_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comle_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comgt_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GT); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comge_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comeq_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_EQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comneq_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_NEQ); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comfalse_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_FALSE); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_comtrue_epi64(__m128i __A, __m128i __B) +{ + return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_TRUE); +} + +#define _mm_permute2_pd(X, Y, C, I) \ + ((__m128d)__builtin_ia32_vpermil2pd((__v2df)(__m128d)(X), \ + (__v2df)(__m128d)(Y), \ + (__v2di)(__m128i)(C), (I))) + +#define _mm256_permute2_pd(X, Y, C, I) \ + ((__m256d)__builtin_ia32_vpermil2pd256((__v4df)(__m256d)(X), \ + (__v4df)(__m256d)(Y), \ + (__v4di)(__m256i)(C), (I))) + +#define _mm_permute2_ps(X, Y, C, I) \ + ((__m128)__builtin_ia32_vpermil2ps((__v4sf)(__m128)(X), (__v4sf)(__m128)(Y), \ + (__v4si)(__m128i)(C), (I))) + +#define _mm256_permute2_ps(X, Y, C, I) \ + ((__m256)__builtin_ia32_vpermil2ps256((__v8sf)(__m256)(X), \ + (__v8sf)(__m256)(Y), \ + (__v8si)(__m256i)(C), (I))) + +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_frcz_ss(__m128 __A) +{ + return (__m128)__builtin_ia32_vfrczss((__v4sf)__A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS +_mm_frcz_sd(__m128d __A) +{ + return (__m128d)__builtin_ia32_vfrczsd((__v2df)__A); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_frcz_ps(__m128 __A) +{ + return (__m128)__builtin_ia32_vfrczps((__v4sf)__A); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS +_mm_frcz_pd(__m128d __A) +{ + return (__m128d)__builtin_ia32_vfrczpd((__v2df)__A); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS256 +_mm256_frcz_ps(__m256 __A) +{ + return (__m256)__builtin_ia32_vfrczps256((__v8sf)__A); +} + +static __inline__ __m256d __DEFAULT_FN_ATTRS256 +_mm256_frcz_pd(__m256d __A) +{ + return (__m256d)__builtin_ia32_vfrczpd256((__v4df)__A); +} + +#undef __DEFAULT_FN_ATTRS +#undef __DEFAULT_FN_ATTRS256 + +#endif /* __XOPINTRIN_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsavecintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsavecintrin.h new file mode 100755 index 0000000..1f2d001 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsavecintrin.h @@ -0,0 +1,84 @@ +/*===---- xsavecintrin.h - XSAVEC intrinsic --------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __XSAVECINTRIN_H +#define __XSAVECINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsavec"))) + +/// Performs a full or partial save of processor state to the memory at +/// \a __p. The exact state saved depends on the 64-bit mask \a __m and +/// processor control register \c XCR0. +/// +/// \code{.operation} +/// mask[62:0] := __m[62:0] AND XCR0[62:0] +/// FOR i := 0 TO 62 +/// IF mask[i] == 1 +/// CASE (i) OF +/// 0: save X87 FPU state +/// 1: save SSE state +/// DEFAULT: __p.Ext_Save_Area[i] := ProcessorState[i] +/// FI +/// ENDFOR +/// __p.Header.XSTATE_BV[62:0] := INIT_FUNCTION(mask[62:0]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c XSAVEC instruction. +/// +/// \param __p +/// Pointer to the save area; must be 64-byte aligned. +/// \param __m +/// A 64-bit mask indicating what state should be saved. +static __inline__ void __DEFAULT_FN_ATTRS +_xsavec(void *__p, unsigned long long __m) { + __builtin_ia32_xsavec(__p, __m); +} + +#ifdef __x86_64__ +/// Performs a full or partial save of processor state to the memory at +/// \a __p. The exact state saved depends on the 64-bit mask \a __m and +/// processor control register \c XCR0. +/// +/// \code{.operation} +/// mask[62:0] := __m[62:0] AND XCR0[62:0] +/// FOR i := 0 TO 62 +/// IF mask[i] == 1 +/// CASE (i) OF +/// 0: save X87 FPU state +/// 1: save SSE state +/// DEFAULT: __p.Ext_Save_Area[i] := ProcessorState[i] +/// FI +/// ENDFOR +/// __p.Header.XSTATE_BV[62:0] := INIT_FUNCTION(mask[62:0]) +/// \endcode +/// +/// \headerfile +/// +/// This intrinsic corresponds to the \c XSAVEC64 instruction. +/// +/// \param __p +/// Pointer to the save area; must be 64-byte aligned. +/// \param __m +/// A 64-bit mask indicating what state should be saved. +static __inline__ void __DEFAULT_FN_ATTRS +_xsavec64(void *__p, unsigned long long __m) { + __builtin_ia32_xsavec64(__p, __m); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsaveintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsaveintrin.h new file mode 100755 index 0000000..9429db6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsaveintrin.h @@ -0,0 +1,63 @@ +/*===---- xsaveintrin.h - XSAVE intrinsic ----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __XSAVEINTRIN_H +#define __XSAVEINTRIN_H + +#ifdef _MSC_VER +#define _XCR_XFEATURE_ENABLED_MASK 0 +#endif + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsave"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_xsave(void *__p, unsigned long long __m) { + __builtin_ia32_xsave(__p, __m); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_xrstor(void *__p, unsigned long long __m) { + __builtin_ia32_xrstor(__p, __m); +} + +#ifndef _MSC_VER +#define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A)) +#define _xsetbv(A, B) __builtin_ia32_xsetbv((unsigned int)(A), (unsigned long long)(B)) +#else +#ifdef __cplusplus +extern "C" { +#endif +unsigned __int64 __cdecl _xgetbv(unsigned int); +void __cdecl _xsetbv(unsigned int, unsigned __int64); +#ifdef __cplusplus +} +#endif +#endif /* _MSC_VER */ + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS +_xsave64(void *__p, unsigned long long __m) { + __builtin_ia32_xsave64(__p, __m); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_xrstor64(void *__p, unsigned long long __m) { + __builtin_ia32_xrstor64(__p, __m); +} + +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsaveoptintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsaveoptintrin.h new file mode 100755 index 0000000..89a4c44 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsaveoptintrin.h @@ -0,0 +1,34 @@ +/*===---- xsaveoptintrin.h - XSAVEOPT intrinsic ----------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __XSAVEOPTINTRIN_H +#define __XSAVEOPTINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsaveopt"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_xsaveopt(void *__p, unsigned long long __m) { + __builtin_ia32_xsaveopt(__p, __m); +} + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS +_xsaveopt64(void *__p, unsigned long long __m) { + __builtin_ia32_xsaveopt64(__p, __m); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsavesintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsavesintrin.h new file mode 100755 index 0000000..3f99219 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xsavesintrin.h @@ -0,0 +1,44 @@ +/*===---- xsavesintrin.h - XSAVES intrinsic --------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __XSAVESINTRIN_H +#define __XSAVESINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("xsaves"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_xsaves(void *__p, unsigned long long __m) { + __builtin_ia32_xsaves(__p, __m); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_xrstors(void *__p, unsigned long long __m) { + __builtin_ia32_xrstors(__p, __m); +} + +#ifdef __x86_64__ +static __inline__ void __DEFAULT_FN_ATTRS +_xrstors64(void *__p, unsigned long long __m) { + __builtin_ia32_xrstors64(__p, __m); +} + +static __inline__ void __DEFAULT_FN_ATTRS +_xsaves64(void *__p, unsigned long long __m) { + __builtin_ia32_xsaves64(__p, __m); +} +#endif + +#undef __DEFAULT_FN_ATTRS + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xtestintrin.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xtestintrin.h new file mode 100755 index 0000000..7d19e37 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/xtestintrin.h @@ -0,0 +1,27 @@ +/*===---- xtestintrin.h - XTEST intrinsic ----------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __XTESTINTRIN_H +#define __XTESTINTRIN_H + +/* xtest returns non-zero if the instruction is executed within an RTM or active + * HLE region. */ +/* FIXME: This can be an either or for RTM/HLE. Deal with this when HLE is + * supported. */ +static __inline__ int + __attribute__((__always_inline__, __nodebug__, __target__("rtm"))) + _xtest(void) { + return __builtin_ia32_xtest(); +} + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/yvals_core.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/yvals_core.h new file mode 100755 index 0000000..5ee194a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/yvals_core.h @@ -0,0 +1,25 @@ +//===----- yvals_core.h - Internal MSVC STL core header -------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Only include this if we are aiming for MSVC compatibility. +#ifndef _MSC_VER +#include_next +#else + +#ifndef __clang_yvals_core_h +#define __clang_yvals_core_h + +#include_next + +#ifdef _STL_INTRIN_HEADER +#undef _STL_INTRIN_HEADER +#define _STL_INTRIN_HEADER +#endif + +#endif +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/zos_wrappers/builtins.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/zos_wrappers/builtins.h new file mode 100755 index 0000000..1f0d0e2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/clang/21/include/zos_wrappers/builtins.h @@ -0,0 +1,18 @@ +/*===---- builtins.h - z/Architecture Builtin Functions --------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __ZOS_WRAPPERS_BUILTINS_H +#define __ZOS_WRAPPERS_BUILTINS_H +#if defined(__MVS__) +#include_next +#if defined(__VEC__) +#include +#endif +#endif /* defined(__MVS__) */ +#endif /* __ZOS_WRAPPERS_BUILTINS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM-21.so b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM-21.so new file mode 100755 index 0000000..8282f37 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM-21.so @@ -0,0 +1 @@ +libLLVM.so.21.1 \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM.so b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM.so new file mode 100755 index 0000000..8282f37 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM.so @@ -0,0 +1 @@ +libLLVM.so.21.1 \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM.so.21.1 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM.so.21.1 new file mode 100755 index 0000000..f2964ce Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLLVM.so.21.1 differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLTO.so b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLTO.so new file mode 100755 index 0000000..af3b1df --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLTO.so @@ -0,0 +1 @@ +libLTO.so.21.1 \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLTO.so.21.1 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLTO.so.21.1 new file mode 100755 index 0000000..6507f35 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libLTO.so.21.1 differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libRemarks.so b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libRemarks.so new file mode 100755 index 0000000..754e0e9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libRemarks.so @@ -0,0 +1 @@ +libRemarks.so.21.1 \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libRemarks.so.21.1 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libRemarks.so.21.1 new file mode 100755 index 0000000..4616402 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libRemarks.so.21.1 differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang-cpp.so.21.1 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang-cpp.so.21.1 new file mode 100755 index 0000000..d290aa2 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang-cpp.so.21.1 differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang.so b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang.so new file mode 100755 index 0000000..993c462 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang.so @@ -0,0 +1 @@ +libclang.so.21.1 \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang.so.21.1.6 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang.so.21.1.6 new file mode 100755 index 0000000..6f0359e Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libclang.so.21.1.6 differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/__init__.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/__init__.py new file mode 100755 index 0000000..b3a8e6c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/__init__.py @@ -0,0 +1,272 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module compiles the intercept library. """ + +import sys +import os +import os.path +import re +import tempfile +import shutil +import contextlib +import logging + +__all__ = ["build_libear"] + + +def build_libear(compiler, dst_dir): + """Returns the full path to the 'libear' library.""" + + try: + src_dir = os.path.dirname(os.path.realpath(__file__)) + toolset = make_toolset(src_dir) + toolset.set_compiler(compiler) + toolset.set_language_standard("c99") + toolset.add_definitions(["-D_GNU_SOURCE"]) + + configure = do_configure(toolset) + configure.check_function_exists("execve", "HAVE_EXECVE") + configure.check_function_exists("execv", "HAVE_EXECV") + configure.check_function_exists("execvpe", "HAVE_EXECVPE") + configure.check_function_exists("execvp", "HAVE_EXECVP") + configure.check_function_exists("execvP", "HAVE_EXECVP2") + configure.check_function_exists("exect", "HAVE_EXECT") + configure.check_function_exists("execl", "HAVE_EXECL") + configure.check_function_exists("execlp", "HAVE_EXECLP") + configure.check_function_exists("execle", "HAVE_EXECLE") + configure.check_function_exists("posix_spawn", "HAVE_POSIX_SPAWN") + configure.check_function_exists("posix_spawnp", "HAVE_POSIX_SPAWNP") + configure.check_symbol_exists( + "_NSGetEnviron", "crt_externs.h", "HAVE_NSGETENVIRON" + ) + configure.write_by_template( + os.path.join(src_dir, "config.h.in"), os.path.join(dst_dir, "config.h") + ) + + target = create_shared_library("ear", toolset) + target.add_include(dst_dir) + target.add_sources("ear.c") + target.link_against(toolset.dl_libraries()) + target.link_against(["pthread"]) + target.build_release(dst_dir) + + return os.path.join(dst_dir, target.name) + + except Exception: + logging.info("Could not build interception library.", exc_info=True) + return None + + +def execute(cmd, *args, **kwargs): + """Make subprocess execution silent.""" + + import subprocess + + kwargs.update({"stdout": subprocess.PIPE, "stderr": subprocess.STDOUT}) + return subprocess.check_call(cmd, *args, **kwargs) + + +@contextlib.contextmanager +def TemporaryDirectory(**kwargs): + name = tempfile.mkdtemp(**kwargs) + try: + yield name + finally: + shutil.rmtree(name) + + +class Toolset(object): + """Abstract class to represent different toolset.""" + + def __init__(self, src_dir): + self.src_dir = src_dir + self.compiler = None + self.c_flags = [] + + def set_compiler(self, compiler): + """part of public interface""" + self.compiler = compiler + + def set_language_standard(self, standard): + """part of public interface""" + self.c_flags.append("-std=" + standard) + + def add_definitions(self, defines): + """part of public interface""" + self.c_flags.extend(defines) + + def dl_libraries(self): + raise NotImplementedError() + + def shared_library_name(self, name): + raise NotImplementedError() + + def shared_library_c_flags(self, release): + extra = ["-DNDEBUG", "-O3"] if release else [] + return extra + ["-fPIC"] + self.c_flags + + def shared_library_ld_flags(self, release, name): + raise NotImplementedError() + + +class DarwinToolset(Toolset): + def __init__(self, src_dir): + Toolset.__init__(self, src_dir) + + def dl_libraries(self): + return [] + + def shared_library_name(self, name): + return "lib" + name + ".dylib" + + def shared_library_ld_flags(self, release, name): + extra = ["-dead_strip"] if release else [] + return extra + ["-dynamiclib", "-install_name", "@rpath/" + name] + + +class UnixToolset(Toolset): + def __init__(self, src_dir): + Toolset.__init__(self, src_dir) + + def dl_libraries(self): + return [] + + def shared_library_name(self, name): + return "lib" + name + ".so" + + def shared_library_ld_flags(self, release, name): + extra = [] if release else [] + return extra + ["-shared", "-Wl,-soname," + name] + + +class LinuxToolset(UnixToolset): + def __init__(self, src_dir): + UnixToolset.__init__(self, src_dir) + + def dl_libraries(self): + return ["dl"] + + +def make_toolset(src_dir): + platform = sys.platform + if platform in {"win32", "cygwin"}: + raise RuntimeError("not implemented on this platform") + elif platform == "darwin": + return DarwinToolset(src_dir) + elif platform in {"linux", "linux2"}: + return LinuxToolset(src_dir) + else: + return UnixToolset(src_dir) + + +class Configure(object): + def __init__(self, toolset): + self.ctx = toolset + self.results = {"APPLE": sys.platform == "darwin"} + + def _try_to_compile_and_link(self, source): + try: + with TemporaryDirectory() as work_dir: + src_file = "check.c" + with open(os.path.join(work_dir, src_file), "w") as handle: + handle.write(source) + + execute([self.ctx.compiler, src_file] + self.ctx.c_flags, cwd=work_dir) + return True + except Exception: + return False + + def check_function_exists(self, function, name): + template = "int FUNCTION(); int main() { return FUNCTION(); }" + source = template.replace("FUNCTION", function) + + logging.debug("Checking function %s", function) + found = self._try_to_compile_and_link(source) + logging.debug( + "Checking function %s -- %s", function, "found" if found else "not found" + ) + self.results.update({name: found}) + + def check_symbol_exists(self, symbol, include, name): + template = """#include + int main() { return ((int*)(&SYMBOL))[0]; }""" + source = template.replace("INCLUDE", include).replace("SYMBOL", symbol) + + logging.debug("Checking symbol %s", symbol) + found = self._try_to_compile_and_link(source) + logging.debug( + "Checking symbol %s -- %s", symbol, "found" if found else "not found" + ) + self.results.update({name: found}) + + def write_by_template(self, template, output): + def transform(line, definitions): + + pattern = re.compile(r"^#cmakedefine\s+(\S+)") + m = pattern.match(line) + if m: + key = m.group(1) + if key not in definitions or not definitions[key]: + return "/* #undef {0} */{1}".format(key, os.linesep) + else: + return "#define {0}{1}".format(key, os.linesep) + return line + + with open(template, "r") as src_handle: + logging.debug("Writing config to %s", output) + with open(output, "w") as dst_handle: + for line in src_handle: + dst_handle.write(transform(line, self.results)) + + +def do_configure(toolset): + return Configure(toolset) + + +class SharedLibrary(object): + def __init__(self, name, toolset): + self.name = toolset.shared_library_name(name) + self.ctx = toolset + self.inc = [] + self.src = [] + self.lib = [] + + def add_include(self, directory): + self.inc.extend(["-I", directory]) + + def add_sources(self, source): + self.src.append(source) + + def link_against(self, libraries): + self.lib.extend(["-l" + lib for lib in libraries]) + + def build_release(self, directory): + for src in self.src: + logging.debug("Compiling %s", src) + execute( + [ + self.ctx.compiler, + "-c", + os.path.join(self.ctx.src_dir, src), + "-o", + src + ".o", + ] + + self.inc + + self.ctx.shared_library_c_flags(True), + cwd=directory, + ) + logging.debug("Linking %s", self.name) + execute( + [self.ctx.compiler] + + [src + ".o" for src in self.src] + + ["-o", self.name] + + self.lib + + self.ctx.shared_library_ld_flags(True, self.name), + cwd=directory, + ) + + +def create_shared_library(name, toolset): + return SharedLibrary(name, toolset) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/config.h.in b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/config.h.in new file mode 100755 index 0000000..6ca1b95 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/config.h.in @@ -0,0 +1,22 @@ +/* -*- coding: utf-8 -*- +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +*/ + +#pragma once + +#cmakedefine HAVE_EXECVE +#cmakedefine HAVE_EXECV +#cmakedefine HAVE_EXECVPE +#cmakedefine HAVE_EXECVP +#cmakedefine HAVE_EXECVP2 +#cmakedefine HAVE_EXECT +#cmakedefine HAVE_EXECL +#cmakedefine HAVE_EXECLP +#cmakedefine HAVE_EXECLE +#cmakedefine HAVE_POSIX_SPAWN +#cmakedefine HAVE_POSIX_SPAWNP +#cmakedefine HAVE_NSGETENVIRON + +#cmakedefine APPLE diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/ear.c b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/ear.c new file mode 100755 index 0000000..3232511 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libear/ear.c @@ -0,0 +1,605 @@ +/* -*- coding: utf-8 -*- +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +*/ + +/** + * This file implements a shared library. This library can be pre-loaded by + * the dynamic linker of the Operating System (OS). It implements a few function + * related to process creation. By pre-load this library the executed process + * uses these functions instead of those from the standard library. + * + * The idea here is to inject a logic before call the real methods. The logic is + * to dump the call into a file. To call the real method this library is doing + * the job of the dynamic linker. + * + * The only input for the log writing is about the destination directory. + * This is passed as environment variable. + */ + +// NOLINTNEXTLINE +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined HAVE_POSIX_SPAWN || defined HAVE_POSIX_SPAWNP +#include +#endif + +#if defined HAVE_NSGETENVIRON +#include +#else +extern char **environ; +#endif + +#define ENV_OUTPUT "INTERCEPT_BUILD_TARGET_DIR" +#ifdef APPLE +#define ENV_FLAT "DYLD_FORCE_FLAT_NAMESPACE" +#define ENV_PRELOAD "DYLD_INSERT_LIBRARIES" +#define ENV_SIZE 3 +#else +#define ENV_PRELOAD "LD_PRELOAD" +#define ENV_SIZE 2 +#endif + +#define DLSYM(TYPE_, VAR_, SYMBOL_) \ + union { \ + void *from; \ + TYPE_ to; \ + } cast; \ + if (0 == (cast.from = dlsym(RTLD_NEXT, SYMBOL_))) { \ + perror("bear: dlsym"); \ + exit(EXIT_FAILURE); \ + } \ + TYPE_ const VAR_ = cast.to; + +typedef char const *bear_env_t[ENV_SIZE]; + +static int bear_capture_env_t(bear_env_t *env); +static int bear_reset_env_t(bear_env_t *env); +static void bear_release_env_t(bear_env_t *env); +static char const **bear_update_environment(char *const envp[], + bear_env_t *env); +static char const **bear_update_environ(char const **in, char const *key, + char const *value); +static char **bear_get_environment(); +static void bear_report_call(char const *fun, char const *const argv[]); +static char const **bear_strings_build(char const *arg, va_list *ap); +static char const **bear_strings_copy(char const **const in); +static char const **bear_strings_append(char const **in, char const *e); +static size_t bear_strings_length(char const *const *in); +static void bear_strings_release(char const **); + +static bear_env_t env_names = {ENV_OUTPUT, ENV_PRELOAD +#ifdef ENV_FLAT + , + ENV_FLAT +#endif +}; + +static bear_env_t initial_env = {0, 0 +#ifdef ENV_FLAT + , + 0 +#endif +}; + +static int initialized = 0; +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +static void on_load(void) __attribute__((constructor)); +static void on_unload(void) __attribute__((destructor)); + +#ifdef HAVE_EXECVE +static int call_execve(const char *path, char *const argv[], + char *const envp[]); +#endif +#ifdef HAVE_EXECVP +static int call_execvp(const char *file, char *const argv[]); +#endif +#ifdef HAVE_EXECVPE +static int call_execvpe(const char *file, char *const argv[], + char *const envp[]); +#endif +#ifdef HAVE_EXECVP2 +static int call_execvP(const char *file, const char *search_path, + char *const argv[]); +#endif +#ifdef HAVE_EXECT +static int call_exect(const char *path, char *const argv[], char *const envp[]); +#endif +#ifdef HAVE_POSIX_SPAWN +static int call_posix_spawn(pid_t *restrict pid, const char *restrict path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], + char *const envp[restrict]); +#endif +#ifdef HAVE_POSIX_SPAWNP +static int call_posix_spawnp(pid_t *restrict pid, const char *restrict file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], + char *const envp[restrict]); +#endif + +/* Initialization method to Captures the relevant environment variables. + */ + +static void on_load(void) { + pthread_mutex_lock(&mutex); + if (!initialized) + initialized = bear_capture_env_t(&initial_env); + pthread_mutex_unlock(&mutex); +} + +static void on_unload(void) { + pthread_mutex_lock(&mutex); + bear_release_env_t(&initial_env); + initialized = 0; + pthread_mutex_unlock(&mutex); +} + +/* These are the methods we are try to hijack. + */ + +#ifdef HAVE_EXECVE +int execve(const char *path, char *const argv[], char *const envp[]) { + bear_report_call(__func__, (char const *const *)argv); + return call_execve(path, argv, envp); +} +#endif + +#ifdef HAVE_EXECV +#ifndef HAVE_EXECVE +#error can not implement execv without execve +#endif +int execv(const char *path, char *const argv[]) { + bear_report_call(__func__, (char const *const *)argv); + char *const *envp = bear_get_environment(); + return call_execve(path, argv, envp); +} +#endif + +#ifdef HAVE_EXECVPE +int execvpe(const char *file, char *const argv[], char *const envp[]) { + bear_report_call(__func__, (char const *const *)argv); + return call_execvpe(file, argv, envp); +} +#endif + +#ifdef HAVE_EXECVP +int execvp(const char *file, char *const argv[]) { + bear_report_call(__func__, (char const *const *)argv); + return call_execvp(file, argv); +} +#endif + +#ifdef HAVE_EXECVP2 +int execvP(const char *file, const char *search_path, char *const argv[]) { + bear_report_call(__func__, (char const *const *)argv); + return call_execvP(file, search_path, argv); +} +#endif + +#ifdef HAVE_EXECT +int exect(const char *path, char *const argv[], char *const envp[]) { + bear_report_call(__func__, (char const *const *)argv); + return call_exect(path, argv, envp); +} +#endif + +#ifdef HAVE_EXECL +#ifndef HAVE_EXECVE +#error can not implement execl without execve +#endif +int execl(const char *path, const char *arg, ...) { + va_list args; + va_start(args, arg); + char const **argv = bear_strings_build(arg, &args); + va_end(args); + + bear_report_call(__func__, (char const *const *)argv); + char *const *envp = bear_get_environment(); + int const result = call_execve(path, (char *const *)argv, envp); + + bear_strings_release(argv); + return result; +} +#endif + +#ifdef HAVE_EXECLP +#ifndef HAVE_EXECVP +#error can not implement execlp without execvp +#endif +int execlp(const char *file, const char *arg, ...) { + va_list args; + va_start(args, arg); + char const **argv = bear_strings_build(arg, &args); + va_end(args); + + bear_report_call(__func__, (char const *const *)argv); + int const result = call_execvp(file, (char *const *)argv); + + bear_strings_release(argv); + return result; +} +#endif + +#ifdef HAVE_EXECLE +#ifndef HAVE_EXECVE +#error can not implement execle without execve +#endif +// int execle(const char *path, const char *arg, ..., char * const envp[]); +int execle(const char *path, const char *arg, ...) { + va_list args; + va_start(args, arg); + char const **argv = bear_strings_build(arg, &args); + char const **envp = va_arg(args, char const **); + va_end(args); + + bear_report_call(__func__, (char const *const *)argv); + int const result = + call_execve(path, (char *const *)argv, (char *const *)envp); + + bear_strings_release(argv); + return result; +} +#endif + +#ifdef HAVE_POSIX_SPAWN +int posix_spawn(pid_t *restrict pid, const char *restrict path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], char *const envp[restrict]) { + bear_report_call(__func__, (char const *const *)argv); + return call_posix_spawn(pid, path, file_actions, attrp, argv, envp); +} +#endif + +#ifdef HAVE_POSIX_SPAWNP +int posix_spawnp(pid_t *restrict pid, const char *restrict file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], char *const envp[restrict]) { + bear_report_call(__func__, (char const *const *)argv); + return call_posix_spawnp(pid, file, file_actions, attrp, argv, envp); +} +#endif + +/* These are the methods which forward the call to the standard implementation. + */ + +#ifdef HAVE_EXECVE +static int call_execve(const char *path, char *const argv[], + char *const envp[]) { + typedef int (*func)(const char *, char *const *, char *const *); + + DLSYM(func, fp, "execve"); + + char const **const menvp = bear_update_environment(envp, &initial_env); + int const result = (*fp)(path, argv, (char *const *)menvp); + bear_strings_release(menvp); + return result; +} +#endif + +#ifdef HAVE_EXECVPE +static int call_execvpe(const char *file, char *const argv[], + char *const envp[]) { + typedef int (*func)(const char *, char *const *, char *const *); + + DLSYM(func, fp, "execvpe"); + + char const **const menvp = bear_update_environment(envp, &initial_env); + int const result = (*fp)(file, argv, (char *const *)menvp); + bear_strings_release(menvp); + return result; +} +#endif + +#ifdef HAVE_EXECVP +static int call_execvp(const char *file, char *const argv[]) { + typedef int (*func)(const char *file, char *const argv[]); + + DLSYM(func, fp, "execvp"); + + bear_env_t current_env; + bear_capture_env_t(¤t_env); + bear_reset_env_t(&initial_env); + int const result = (*fp)(file, argv); + bear_reset_env_t(¤t_env); + bear_release_env_t(¤t_env); + + return result; +} +#endif + +#ifdef HAVE_EXECVP2 +static int call_execvP(const char *file, const char *search_path, + char *const argv[]) { + typedef int (*func)(const char *, const char *, char *const *); + + DLSYM(func, fp, "execvP"); + + bear_env_t current_env; + bear_capture_env_t(¤t_env); + bear_reset_env_t(&initial_env); + int const result = (*fp)(file, search_path, argv); + bear_reset_env_t(¤t_env); + bear_release_env_t(¤t_env); + + return result; +} +#endif + +#ifdef HAVE_EXECT +static int call_exect(const char *path, char *const argv[], + char *const envp[]) { + typedef int (*func)(const char *, char *const *, char *const *); + + DLSYM(func, fp, "exect"); + + char const **const menvp = bear_update_environment(envp, &initial_env); + int const result = (*fp)(path, argv, (char *const *)menvp); + bear_strings_release(menvp); + return result; +} +#endif + +#ifdef HAVE_POSIX_SPAWN +static int call_posix_spawn(pid_t *restrict pid, const char *restrict path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], + char *const envp[restrict]) { + typedef int (*func)(pid_t *restrict, const char *restrict, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t *restrict, char *const *restrict, + char *const *restrict); + + DLSYM(func, fp, "posix_spawn"); + + char const **const menvp = bear_update_environment(envp, &initial_env); + int const result = + (*fp)(pid, path, file_actions, attrp, argv, (char *const *restrict)menvp); + bear_strings_release(menvp); + return result; +} +#endif + +#ifdef HAVE_POSIX_SPAWNP +static int call_posix_spawnp(pid_t *restrict pid, const char *restrict file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *restrict attrp, + char *const argv[restrict], + char *const envp[restrict]) { + typedef int (*func)(pid_t *restrict, const char *restrict, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t *restrict, char *const *restrict, + char *const *restrict); + + DLSYM(func, fp, "posix_spawnp"); + + char const **const menvp = bear_update_environment(envp, &initial_env); + int const result = + (*fp)(pid, file, file_actions, attrp, argv, (char *const *restrict)menvp); + bear_strings_release(menvp); + return result; +} +#endif + +/* this method is to write log about the process creation. */ + +static void bear_report_call(char const *fun, char const *const argv[]) { + static int const GS = 0x1d; + static int const RS = 0x1e; + static int const US = 0x1f; + + if (!initialized) + return; + + pthread_mutex_lock(&mutex); + const char *cwd = getcwd(NULL, 0); + if (0 == cwd) { + perror("bear: getcwd"); + pthread_mutex_unlock(&mutex); + exit(EXIT_FAILURE); + } + char const *const out_dir = initial_env[0]; + size_t const path_max_length = strlen(out_dir) + 32; + char filename[path_max_length]; + if (-1 == + snprintf(filename, path_max_length, "%s/%d.cmd", out_dir, getpid())) { + perror("bear: snprintf"); + pthread_mutex_unlock(&mutex); + exit(EXIT_FAILURE); + } + FILE *fd = fopen(filename, "a+"); + if (0 == fd) { + perror("bear: fopen"); + pthread_mutex_unlock(&mutex); + exit(EXIT_FAILURE); + } + fprintf(fd, "%d%c", getpid(), RS); + fprintf(fd, "%d%c", getppid(), RS); + fprintf(fd, "%s%c", fun, RS); + fprintf(fd, "%s%c", cwd, RS); + size_t const argc = bear_strings_length(argv); + for (size_t it = 0; it < argc; ++it) { + fprintf(fd, "%s%c", argv[it], US); + } + fprintf(fd, "%c", GS); + if (fclose(fd)) { + perror("bear: fclose"); + pthread_mutex_unlock(&mutex); + exit(EXIT_FAILURE); + } + free((void *)cwd); + pthread_mutex_unlock(&mutex); +} + +/* update environment assure that children processes will copy the desired + * behaviour */ + +static int bear_capture_env_t(bear_env_t *env) { + int status = 1; + for (size_t it = 0; it < ENV_SIZE; ++it) { + char const *const env_value = getenv(env_names[it]); + char const *const env_copy = (env_value) ? strdup(env_value) : env_value; + (*env)[it] = env_copy; + status &= (env_copy) ? 1 : 0; + } + return status; +} + +static int bear_reset_env_t(bear_env_t *env) { + int status = 1; + for (size_t it = 0; it < ENV_SIZE; ++it) { + if ((*env)[it]) { + setenv(env_names[it], (*env)[it], 1); + } else { + unsetenv(env_names[it]); + } + } + return status; +} + +static void bear_release_env_t(bear_env_t *env) { + for (size_t it = 0; it < ENV_SIZE; ++it) { + free((void *)(*env)[it]); + (*env)[it] = 0; + } +} + +static char const **bear_update_environment(char *const envp[], + bear_env_t *env) { + char const **result = bear_strings_copy((char const **)envp); + for (size_t it = 0; it < ENV_SIZE && (*env)[it]; ++it) + result = bear_update_environ(result, env_names[it], (*env)[it]); + return result; +} + +static char const **bear_update_environ(char const *envs[], char const *key, + char const *const value) { + // find the key if it's there + size_t const key_length = strlen(key); + char const **it = envs; + for (; (it) && (*it); ++it) { + if ((0 == strncmp(*it, key, key_length)) && (strlen(*it) > key_length) && + ('=' == (*it)[key_length])) + break; + } + // allocate a environment entry + size_t const value_length = strlen(value); + size_t const env_length = key_length + value_length + 2; + char *env = malloc(env_length); + if (0 == env) { + perror("bear: malloc [in env_update]"); + exit(EXIT_FAILURE); + } + if (-1 == snprintf(env, env_length, "%s=%s", key, value)) { + perror("bear: snprintf"); + exit(EXIT_FAILURE); + } + // replace or append the environment entry + if (it && *it) { + free((void *)*it); + *it = env; + return envs; + } + return bear_strings_append(envs, env); +} + +static char **bear_get_environment() { +#if defined HAVE_NSGETENVIRON + return *_NSGetEnviron(); +#else + return environ; +#endif +} + +/* util methods to deal with string arrays. environment and process arguments + * are both represented as string arrays. */ + +static char const **bear_strings_build(char const *const arg, va_list *args) { + char const **result = 0; + size_t size = 0; + for (char const *it = arg; it; it = va_arg(*args, char const *)) { + result = realloc(result, (size + 1) * sizeof(char const *)); + if (0 == result) { + perror("bear: realloc"); + exit(EXIT_FAILURE); + } + char const *copy = strdup(it); + if (0 == copy) { + perror("bear: strdup"); + exit(EXIT_FAILURE); + } + result[size++] = copy; + } + result = realloc(result, (size + 1) * sizeof(char const *)); + if (0 == result) { + perror("bear: realloc"); + exit(EXIT_FAILURE); + } + result[size++] = 0; + + return result; +} + +static char const **bear_strings_copy(char const **const in) { + size_t const size = bear_strings_length(in); + + char const **const result = malloc((size + 1) * sizeof(char const *)); + if (0 == result) { + perror("bear: malloc"); + exit(EXIT_FAILURE); + } + + char const **out_it = result; + for (char const *const *in_it = in; (in_it) && (*in_it); ++in_it, ++out_it) { + *out_it = strdup(*in_it); + if (0 == *out_it) { + perror("bear: strdup"); + exit(EXIT_FAILURE); + } + } + *out_it = 0; + return result; +} + +static char const **bear_strings_append(char const **const in, + char const *const e) { + size_t size = bear_strings_length(in); + char const **result = realloc(in, (size + 2) * sizeof(char const *)); + if (0 == result) { + perror("bear: realloc"); + exit(EXIT_FAILURE); + } + result[size++] = e; + result[size++] = 0; + return result; +} + +static size_t bear_strings_length(char const *const *const in) { + size_t result = 0; + for (char const *const *it = in; (it) && (*it); ++it) + ++result; + return result; +} + +static void bear_strings_release(char const **in) { + for (char const *const *it = in; (it) && (*it); ++it) { + free((void *)*it); + } + free((void *)in); +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/__init__.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/__init__.py new file mode 100755 index 0000000..ba16008 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/__init__.py @@ -0,0 +1,215 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module is a collection of methods commonly used in this project. """ +import collections +import functools +import json +import logging +import os +import os.path +import re +import shlex +import subprocess +import sys + +ENVIRONMENT_KEY = "INTERCEPT_BUILD" + +Execution = collections.namedtuple("Execution", ["pid", "cwd", "cmd"]) + +CtuConfig = collections.namedtuple( + "CtuConfig", ["collect", "analyze", "dir", "extdef_map_cmd"] +) + + +def duplicate_check(method): + """Predicate to detect duplicated entries. + + Unique hash method can be use to detect duplicates. Entries are + represented as dictionaries, which has no default hash method. + This implementation uses a set datatype to store the unique hash values. + + This method returns a method which can detect the duplicate values.""" + + def predicate(entry): + entry_hash = predicate.unique(entry) + if entry_hash not in predicate.state: + predicate.state.add(entry_hash) + return False + return True + + predicate.unique = method + predicate.state = set() + return predicate + + +def run_build(command, *args, **kwargs): + """Run and report build command execution + + :param command: array of tokens + :return: exit code of the process + """ + environment = kwargs.get("env", os.environ) + logging.debug("run build %s, in environment: %s", command, environment) + exit_code = subprocess.call(command, *args, **kwargs) + logging.debug("build finished with exit code: %d", exit_code) + return exit_code + + +def run_command(command, cwd=None): + """Run a given command and report the execution. + + :param command: array of tokens + :param cwd: the working directory where the command will be executed + :return: output of the command + """ + + def decode_when_needed(result): + """check_output returns bytes or string depend on python version""" + return result.decode("utf-8") if isinstance(result, bytes) else result + + try: + directory = os.path.abspath(cwd) if cwd else os.getcwd() + logging.debug("exec command %s in %s", command, directory) + output = subprocess.check_output( + command, cwd=directory, stderr=subprocess.STDOUT + ) + return decode_when_needed(output).splitlines() + except subprocess.CalledProcessError as ex: + ex.output = decode_when_needed(ex.output).splitlines() + raise ex + + +def reconfigure_logging(verbose_level): + """Reconfigure logging level and format based on the verbose flag. + + :param verbose_level: number of `-v` flags received by the command + :return: no return value + """ + # Exit when nothing to do. + if verbose_level == 0: + return + + root = logging.getLogger() + # Tune logging level. + level = logging.WARNING - min(logging.WARNING, (10 * verbose_level)) + root.setLevel(level) + # Be verbose with messages. + if verbose_level <= 3: + fmt_string = "%(name)s: %(levelname)s: %(message)s" + else: + fmt_string = "%(name)s: %(levelname)s: %(funcName)s: %(message)s" + handler = logging.StreamHandler(sys.stdout) + handler.setFormatter(logging.Formatter(fmt=fmt_string)) + root.handlers = [handler] + + +def command_entry_point(function): + """Decorator for command entry methods. + + The decorator initialize/shutdown logging and guard on programming + errors (catch exceptions). + + The decorated method can have arbitrary parameters, the return value will + be the exit code of the process.""" + + @functools.wraps(function) + def wrapper(*args, **kwargs): + """Do housekeeping tasks and execute the wrapped method.""" + + try: + logging.basicConfig( + format="%(name)s: %(message)s", level=logging.WARNING, stream=sys.stdout + ) + # This hack to get the executable name as %(name). + logging.getLogger().name = os.path.basename(sys.argv[0]) + return function(*args, **kwargs) + except KeyboardInterrupt: + logging.warning("Keyboard interrupt") + return 130 # Signal received exit code for bash. + except Exception: + logging.exception("Internal error.") + if logging.getLogger().isEnabledFor(logging.DEBUG): + logging.error( + "Please report this bug and attach the output " "to the bug report" + ) + else: + logging.error( + "Please run this command again and turn on " + "verbose mode (add '-vvvv' as argument)." + ) + return 64 # Some non used exit code for internal errors. + finally: + logging.shutdown() + + return wrapper + + +def compiler_wrapper(function): + """Implements compiler wrapper base functionality. + + A compiler wrapper executes the real compiler, then implement some + functionality, then returns with the real compiler exit code. + + :param function: the extra functionality what the wrapper want to + do on top of the compiler call. If it throws exception, it will be + caught and logged. + :return: the exit code of the real compiler. + + The :param function: will receive the following arguments: + + :param result: the exit code of the compilation. + :param execution: the command executed by the wrapper.""" + + def is_cxx_compiler(): + """Find out was it a C++ compiler call. Compiler wrapper names + contain the compiler type. C++ compiler wrappers ends with `c++`, + but might have `.exe` extension on windows.""" + + wrapper_command = os.path.basename(sys.argv[0]) + return re.match(r"(.+)c\+\+(.*)", wrapper_command) + + def run_compiler(executable): + """Execute compilation with the real compiler.""" + + command = executable + sys.argv[1:] + logging.debug("compilation: %s", command) + result = subprocess.call(command) + logging.debug("compilation exit code: %d", result) + return result + + # Get relevant parameters from environment. + parameters = json.loads(os.environ[ENVIRONMENT_KEY]) + reconfigure_logging(parameters["verbose"]) + # Execute the requested compilation. Do crash if anything goes wrong. + cxx = is_cxx_compiler() + compiler = parameters["cxx"] if cxx else parameters["cc"] + result = run_compiler(compiler) + # Call the wrapped method and ignore it's return value. + try: + call = Execution( + pid=os.getpid(), + cwd=os.getcwd(), + cmd=["c++" if cxx else "cc"] + sys.argv[1:], + ) + function(result, call) + except: + logging.exception("Compiler wrapper failed complete.") + finally: + # Always return the real compiler exit code. + return result + + +def wrapper_environment(args): + """Set up environment for interpose compiler wrapper.""" + + return { + ENVIRONMENT_KEY: json.dumps( + { + "verbose": args.verbose, + "cc": shlex.split(args.cc), + "cxx": shlex.split(args.cxx), + } + ) + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/analyze.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/analyze.py new file mode 100755 index 0000000..72aac8f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/analyze.py @@ -0,0 +1,886 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module implements the 'scan-build' command API. + +To run the static analyzer against a build is done in multiple steps: + + -- Intercept: capture the compilation command during the build, + -- Analyze: run the analyzer against the captured commands, + -- Report: create a cover report from the analyzer outputs. """ + +import re +import os +import os.path +import json +import logging +import multiprocessing +import tempfile +import functools +import subprocess +import contextlib +import datetime +import shutil +import glob +from collections import defaultdict + +from libscanbuild import ( + command_entry_point, + compiler_wrapper, + wrapper_environment, + run_build, + run_command, + CtuConfig, +) +from libscanbuild.arguments import ( + parse_args_for_scan_build, + parse_args_for_analyze_build, +) +from libscanbuild.intercept import capture +from libscanbuild.report import document +from libscanbuild.compilation import split_command, classify_source, compiler_language +from libscanbuild.clang import ( + get_version, + get_arguments, + get_triple_arch, + ClangErrorException, +) +from libscanbuild.shell import decode + +__all__ = ["scan_build", "analyze_build", "analyze_compiler_wrapper"] + +scanbuild_dir = os.path.dirname(os.path.realpath(__import__("sys").argv[0])) + +COMPILER_WRAPPER_CC = os.path.join(scanbuild_dir, "..", "libexec", "analyze-cc") +COMPILER_WRAPPER_CXX = os.path.join(scanbuild_dir, "..", "libexec", "analyze-c++") + +CTU_EXTDEF_MAP_FILENAME = "externalDefMap.txt" +CTU_TEMP_DEFMAP_FOLDER = "tmpExternalDefMaps" + + +@command_entry_point +def scan_build(): + """Entry point for scan-build command.""" + + args = parse_args_for_scan_build() + # will re-assign the report directory as new output + with report_directory( + args.output, args.keep_empty, args.output_format + ) as args.output: + # Run against a build command. there are cases, when analyzer run + # is not required. But we need to set up everything for the + # wrappers, because 'configure' needs to capture the CC/CXX values + # for the Makefile. + if args.intercept_first: + # Run build command with intercept module. + exit_code = capture(args) + # Run the analyzer against the captured commands. + if need_analyzer(args.build): + govern_analyzer_runs(args) + else: + # Run build command and analyzer with compiler wrappers. + environment = setup_environment(args) + exit_code = run_build(args.build, env=environment) + # Cover report generation and bug counting. + number_of_bugs = document(args) + # Set exit status as it was requested. + return number_of_bugs if args.status_bugs else exit_code + + +@command_entry_point +def analyze_build(): + """Entry point for analyze-build command.""" + + args = parse_args_for_analyze_build() + # will re-assign the report directory as new output + with report_directory( + args.output, args.keep_empty, args.output_format + ) as args.output: + # Run the analyzer against a compilation db. + govern_analyzer_runs(args) + # Cover report generation and bug counting. + number_of_bugs = document(args) + # Set exit status as it was requested. + return number_of_bugs if args.status_bugs else 0 + + +def need_analyzer(args): + """Check the intent of the build command. + + When static analyzer run against project configure step, it should be + silent and no need to run the analyzer or generate report. + + To run `scan-build` against the configure step might be necessary, + when compiler wrappers are used. That's the moment when build setup + check the compiler and capture the location for the build process.""" + + return len(args) and not re.search(r"configure|autogen", args[0]) + + +def prefix_with(constant, pieces): + """From a sequence create another sequence where every second element + is from the original sequence and the odd elements are the prefix. + + eg.: prefix_with(0, [1,2,3]) creates [0, 1, 0, 2, 0, 3]""" + + return [elem for piece in pieces for elem in [constant, piece]] + + +def get_ctu_config_from_args(args): + """CTU configuration is created from the chosen phases and dir.""" + + return ( + CtuConfig( + collect=args.ctu_phases.collect, + analyze=args.ctu_phases.analyze, + dir=args.ctu_dir, + extdef_map_cmd=args.extdef_map_cmd, + ) + if hasattr(args, "ctu_phases") and hasattr(args.ctu_phases, "dir") + else CtuConfig(collect=False, analyze=False, dir="", extdef_map_cmd="") + ) + + +def get_ctu_config_from_json(ctu_conf_json): + """CTU configuration is created from the chosen phases and dir.""" + + ctu_config = json.loads(ctu_conf_json) + # Recover namedtuple from json when coming from analyze-cc or analyze-c++ + return CtuConfig( + collect=ctu_config[0], + analyze=ctu_config[1], + dir=ctu_config[2], + extdef_map_cmd=ctu_config[3], + ) + + +def create_global_ctu_extdef_map(extdef_map_lines): + """Takes iterator of individual external definition maps and creates a + global map keeping only unique names. We leave conflicting names out of + CTU. + + :param extdef_map_lines: Contains the id of a definition (mangled name) and + the originating source (the corresponding AST file) name. + :type extdef_map_lines: Iterator of str. + :returns: Mangled name - AST file pairs. + :rtype: List of (str, str) tuples. + """ + + mangled_to_asts = defaultdict(set) + + for line in extdef_map_lines: + mangled_name, ast_file = line.strip().split(" ", 1) + mangled_to_asts[mangled_name].add(ast_file) + + mangled_ast_pairs = [] + + for mangled_name, ast_files in mangled_to_asts.items(): + if len(ast_files) == 1: + mangled_ast_pairs.append((mangled_name, next(iter(ast_files)))) + + return mangled_ast_pairs + + +def merge_ctu_extdef_maps(ctudir): + """Merge individual external definition maps into a global one. + + As the collect phase runs parallel on multiple threads, all compilation + units are separately mapped into a temporary file in CTU_TEMP_DEFMAP_FOLDER. + These definition maps contain the mangled names and the source + (AST generated from the source) which had their definition. + These files should be merged at the end into a global map file: + CTU_EXTDEF_MAP_FILENAME.""" + + def generate_extdef_map_lines(extdefmap_dir): + """Iterate over all lines of input files in a determined order.""" + + files = glob.glob(os.path.join(extdefmap_dir, "*")) + files.sort() + for filename in files: + with open(filename, "r") as in_file: + for line in in_file: + yield line + + def write_global_map(arch, mangled_ast_pairs): + """Write (mangled name, ast file) pairs into final file.""" + + extern_defs_map_file = os.path.join(ctudir, arch, CTU_EXTDEF_MAP_FILENAME) + with open(extern_defs_map_file, "w") as out_file: + for mangled_name, ast_file in mangled_ast_pairs: + out_file.write("%s %s\n" % (mangled_name, ast_file)) + + triple_arches = glob.glob(os.path.join(ctudir, "*")) + for triple_path in triple_arches: + if os.path.isdir(triple_path): + triple_arch = os.path.basename(triple_path) + extdefmap_dir = os.path.join(ctudir, triple_arch, CTU_TEMP_DEFMAP_FOLDER) + + extdef_map_lines = generate_extdef_map_lines(extdefmap_dir) + mangled_ast_pairs = create_global_ctu_extdef_map(extdef_map_lines) + write_global_map(triple_arch, mangled_ast_pairs) + + # Remove all temporary files + shutil.rmtree(extdefmap_dir, ignore_errors=True) + + +def run_analyzer_parallel(args): + """Runs the analyzer against the given compilation database.""" + + def exclude(filename, directory): + """Return true when any excluded directory prefix the filename.""" + if not os.path.isabs(filename): + # filename is either absolute or relative to directory. Need to turn + # it to absolute since 'args.excludes' are absolute paths. + filename = os.path.normpath(os.path.join(directory, filename)) + return any( + re.match(r"^" + exclude_directory, filename) + for exclude_directory in args.excludes + ) + + consts = { + "clang": args.clang, + "output_dir": args.output, + "output_format": args.output_format, + "output_failures": args.output_failures, + "direct_args": analyzer_params(args), + "force_debug": args.force_debug, + "ctu": get_ctu_config_from_args(args), + } + + logging.debug("run analyzer against compilation database") + with open(args.cdb, "r") as handle: + generator = ( + dict(cmd, **consts) + for cmd in json.load(handle) + if not exclude(cmd["file"], cmd["directory"]) + ) + # when verbose output requested execute sequentially + pool = multiprocessing.Pool(1 if args.verbose > 2 else None) + for current in pool.imap_unordered(run, generator): + if current is not None: + # display error message from the static analyzer + for line in current["error_output"]: + logging.info(line.rstrip()) + pool.close() + pool.join() + + +def govern_analyzer_runs(args): + """Governs multiple runs in CTU mode or runs once in normal mode.""" + + ctu_config = get_ctu_config_from_args(args) + # If we do a CTU collect (1st phase) we remove all previous collection + # data first. + if ctu_config.collect: + shutil.rmtree(ctu_config.dir, ignore_errors=True) + + # If the user asked for a collect (1st) and analyze (2nd) phase, we do an + # all-in-one run where we deliberately remove collection data before and + # also after the run. If the user asks only for a single phase data is + # left so multiple analyze runs can use the same data gathered by a single + # collection run. + if ctu_config.collect and ctu_config.analyze: + # CTU strings are coming from args.ctu_dir and extdef_map_cmd, + # so we can leave it empty + args.ctu_phases = CtuConfig( + collect=True, analyze=False, dir="", extdef_map_cmd="" + ) + run_analyzer_parallel(args) + merge_ctu_extdef_maps(ctu_config.dir) + args.ctu_phases = CtuConfig( + collect=False, analyze=True, dir="", extdef_map_cmd="" + ) + run_analyzer_parallel(args) + shutil.rmtree(ctu_config.dir, ignore_errors=True) + else: + # Single runs (collect or analyze) are launched from here. + run_analyzer_parallel(args) + if ctu_config.collect: + merge_ctu_extdef_maps(ctu_config.dir) + + +def setup_environment(args): + """Set up environment for build command to interpose compiler wrapper.""" + + environment = dict(os.environ) + environment.update(wrapper_environment(args)) + environment.update( + { + "CC": COMPILER_WRAPPER_CC, + "CXX": COMPILER_WRAPPER_CXX, + "ANALYZE_BUILD_CLANG": args.clang if need_analyzer(args.build) else "", + "ANALYZE_BUILD_REPORT_DIR": args.output, + "ANALYZE_BUILD_REPORT_FORMAT": args.output_format, + "ANALYZE_BUILD_REPORT_FAILURES": "yes" if args.output_failures else "", + "ANALYZE_BUILD_PARAMETERS": " ".join(analyzer_params(args)), + "ANALYZE_BUILD_FORCE_DEBUG": "yes" if args.force_debug else "", + "ANALYZE_BUILD_CTU": json.dumps(get_ctu_config_from_args(args)), + } + ) + return environment + + +@command_entry_point +def analyze_compiler_wrapper(): + """Entry point for `analyze-cc` and `analyze-c++` compiler wrappers.""" + + return compiler_wrapper(analyze_compiler_wrapper_impl) + + +def analyze_compiler_wrapper_impl(result, execution): + """Implements analyzer compiler wrapper functionality.""" + + # don't run analyzer when compilation fails. or when it's not requested. + if result or not os.getenv("ANALYZE_BUILD_CLANG"): + return + + # check is it a compilation? + compilation = split_command(execution.cmd) + if compilation is None: + return + # collect the needed parameters from environment, crash when missing + parameters = { + "clang": os.getenv("ANALYZE_BUILD_CLANG"), + "output_dir": os.getenv("ANALYZE_BUILD_REPORT_DIR"), + "output_format": os.getenv("ANALYZE_BUILD_REPORT_FORMAT"), + "output_failures": os.getenv("ANALYZE_BUILD_REPORT_FAILURES"), + "direct_args": os.getenv("ANALYZE_BUILD_PARAMETERS", "").split(" "), + "force_debug": os.getenv("ANALYZE_BUILD_FORCE_DEBUG"), + "directory": execution.cwd, + "command": [execution.cmd[0], "-c"] + compilation.flags, + "ctu": get_ctu_config_from_json(os.getenv("ANALYZE_BUILD_CTU")), + } + # call static analyzer against the compilation + for source in compilation.files: + parameters.update({"file": source}) + logging.debug("analyzer parameters %s", parameters) + current = run(parameters) + # display error message from the static analyzer + if current is not None: + for line in current["error_output"]: + logging.info(line.rstrip()) + + +@contextlib.contextmanager +def report_directory(hint, keep, output_format): + """Responsible for the report directory. + + hint -- could specify the parent directory of the output directory. + keep -- a boolean value to keep or delete the empty report directory.""" + + stamp_format = "scan-build-%Y-%m-%d-%H-%M-%S-%f-" + stamp = datetime.datetime.now().strftime(stamp_format) + parent_dir = os.path.abspath(hint) + if not os.path.exists(parent_dir): + os.makedirs(parent_dir) + name = tempfile.mkdtemp(prefix=stamp, dir=parent_dir) + + logging.info("Report directory created: %s", name) + + try: + yield name + finally: + args = (name,) + if os.listdir(name): + if output_format not in ["sarif", "sarif-html"]: # FIXME: + # 'scan-view' currently does not support sarif format. + msg = "Run 'scan-view %s' to examine bug reports." + elif output_format == "sarif-html": + msg = ( + "Run 'scan-view %s' to examine bug reports or see " + "merged sarif results at %s/results-merged.sarif." + ) + args = (name, name) + else: + msg = "View merged sarif results at %s/results-merged.sarif." + keep = True + else: + if keep: + msg = "Report directory '%s' contains no report, but kept." + else: + msg = "Removing directory '%s' because it contains no report." + logging.warning(msg, *args) + + if not keep: + os.rmdir(name) + + +def analyzer_params(args): + """A group of command line arguments can mapped to command + line arguments of the analyzer. This method generates those.""" + + result = [] + + if args.constraints_model: + result.append("-analyzer-constraints={0}".format(args.constraints_model)) + if args.internal_stats: + result.append("-analyzer-stats") + if args.analyze_headers: + result.append("-analyzer-opt-analyze-headers") + if args.stats: + result.append("-analyzer-checker=debug.Stats") + if args.maxloop: + result.extend(["-analyzer-max-loop", str(args.maxloop)]) + if args.output_format: + result.append("-analyzer-output={0}".format(args.output_format)) + if args.analyzer_config: + result.extend(["-analyzer-config", args.analyzer_config]) + if args.verbose >= 4: + result.append("-analyzer-display-progress") + if args.plugins: + result.extend(prefix_with("-load", args.plugins)) + if args.enable_checker: + checkers = ",".join(args.enable_checker) + result.extend(["-analyzer-checker", checkers]) + if args.disable_checker: + checkers = ",".join(args.disable_checker) + result.extend(["-analyzer-disable-checker", checkers]) + + return prefix_with("-Xclang", result) + + +def require(required): + """Decorator for checking the required values in state. + + It checks the required attributes in the passed state and stop when + any of those is missing.""" + + def decorator(function): + @functools.wraps(function) + def wrapper(*args, **kwargs): + for key in required: + if key not in args[0]: + raise KeyError( + "{0} not passed to {1}".format(key, function.__name__) + ) + + return function(*args, **kwargs) + + return wrapper + + return decorator + + +@require( + [ + "command", # entry from compilation database + "directory", # entry from compilation database + "file", # entry from compilation database + "clang", # clang executable name (and path) + "direct_args", # arguments from command line + "force_debug", # kill non debug macros + "output_dir", # where generated report files shall go + "output_format", # it's 'plist', 'html', 'plist-html', 'plist-multi-file', 'sarif', or 'sarif-html' + "output_failures", # generate crash reports or not + "ctu", + ] +) # ctu control options +def run(opts): + """Entry point to run (or not) static analyzer against a single entry + of the compilation database. + + This complex task is decomposed into smaller methods which are calling + each other in chain. If the analysis is not possible the given method + just return and break the chain. + + The passed parameter is a python dictionary. Each method first check + that the needed parameters received. (This is done by the 'require' + decorator. It's like an 'assert' to check the contract between the + caller and the called method.)""" + + try: + command = opts.pop("command") + command = command if isinstance(command, list) else decode(command) + logging.debug("Run analyzer against '%s'", command) + opts.update(classify_parameters(command)) + + return arch_check(opts) + except Exception: + logging.error("Problem occurred during analysis.", exc_info=1) + return None + + +@require( + [ + "clang", + "directory", + "flags", + "file", + "output_dir", + "language", + "error_output", + "exit_code", + ] +) +def report_failure(opts): + """Create report when analyzer failed. + + The major report is the preprocessor output. The output filename generated + randomly. The compiler output also captured into '.stderr.txt' file. + And some more execution context also saved into '.info.txt' file.""" + + def extension(): + """Generate preprocessor file extension.""" + + mapping = {"objective-c++": ".mii", "objective-c": ".mi", "c++": ".ii"} + return mapping.get(opts["language"], ".i") + + def destination(): + """Creates failures directory if not exits yet.""" + + failures_dir = os.path.join(opts["output_dir"], "failures") + if not os.path.isdir(failures_dir): + os.makedirs(failures_dir) + return failures_dir + + # Classify error type: when Clang terminated by a signal it's a 'Crash'. + # (python subprocess Popen.returncode is negative when child terminated + # by signal.) Everything else is 'Other Error'. + error = "crash" if opts["exit_code"] < 0 else "other_error" + # Create preprocessor output file name. (This is blindly following the + # Perl implementation.) + (handle, name) = tempfile.mkstemp( + suffix=extension(), prefix="clang_" + error + "_", dir=destination() + ) + os.close(handle) + # Execute Clang again, but run the syntax check only. + cwd = opts["directory"] + cmd = ( + [opts["clang"], "-fsyntax-only", "-E"] + + opts["flags"] + + [opts["file"], "-o", name] + ) + try: + cmd = get_arguments(cmd, cwd) + run_command(cmd, cwd=cwd) + except subprocess.CalledProcessError: + pass + except ClangErrorException: + pass + # write general information about the crash + with open(name + ".info.txt", "w") as handle: + handle.write(opts["file"] + os.linesep) + handle.write(error.title().replace("_", " ") + os.linesep) + handle.write(" ".join(cmd) + os.linesep) + handle.write(" ".join(os.uname()) + os.linesep) + handle.write(get_version(opts["clang"])) + handle.close() + # write the captured output too + with open(name + ".stderr.txt", "w") as handle: + handle.writelines(opts["error_output"]) + handle.close() + + +@require( + [ + "clang", + "directory", + "flags", + "direct_args", + "file", + "output_dir", + "output_format", + ] +) +def run_analyzer(opts, continuation=report_failure): + """It assembles the analysis command line and executes it. Capture the + output of the analysis and returns with it. If failure reports are + requested, it calls the continuation to generate it.""" + + def target(): + """Creates output file name for reports.""" + if opts["output_format"] in {"plist", "plist-html", "plist-multi-file"}: + (handle, name) = tempfile.mkstemp( + prefix="report-", suffix=".plist", dir=opts["output_dir"] + ) + os.close(handle) + return name + elif opts["output_format"] in {"sarif", "sarif-html"}: + (handle, name) = tempfile.mkstemp( + prefix="result-", suffix=".sarif", dir=opts["output_dir"] + ) + os.close(handle) + return name + return opts["output_dir"] + + try: + cwd = opts["directory"] + cmd = get_arguments( + [opts["clang"], "--analyze"] + + opts["direct_args"] + + opts["flags"] + + [opts["file"], "-o", target()], + cwd, + ) + output = run_command(cmd, cwd=cwd) + return {"error_output": output, "exit_code": 0} + except subprocess.CalledProcessError as ex: + result = {"error_output": ex.output, "exit_code": ex.returncode} + if opts.get("output_failures", False): + opts.update(result) + continuation(opts) + return result + except ClangErrorException as ex: + result = {"error_output": ex.error, "exit_code": 0} + if opts.get("output_failures", False): + opts.update(result) + continuation(opts) + return result + + +def extdef_map_list_src_to_ast(extdef_src_list): + """Turns textual external definition map list with source files into an + external definition map list with ast files.""" + + extdef_ast_list = [] + for extdef_src_txt in extdef_src_list: + mangled_name, path = extdef_src_txt.split(" ", 1) + # Normalize path on windows as well + path = os.path.splitdrive(path)[1] + # Make relative path out of absolute + path = path[1:] if path[0] == os.sep else path + ast_path = os.path.join("ast", path + ".ast") + extdef_ast_list.append(mangled_name + " " + ast_path) + return extdef_ast_list + + +@require(["clang", "directory", "flags", "direct_args", "file", "ctu"]) +def ctu_collect_phase(opts): + """Preprocess source by generating all data needed by CTU analysis.""" + + def generate_ast(triple_arch): + """Generates ASTs for the current compilation command.""" + + args = opts["direct_args"] + opts["flags"] + ast_joined_path = os.path.join( + opts["ctu"].dir, + triple_arch, + "ast", + os.path.realpath(opts["file"])[1:] + ".ast", + ) + ast_path = os.path.abspath(ast_joined_path) + ast_dir = os.path.dirname(ast_path) + if not os.path.isdir(ast_dir): + try: + os.makedirs(ast_dir) + except OSError: + # In case an other process already created it. + pass + ast_command = [opts["clang"], "-emit-ast"] + ast_command.extend(args) + ast_command.append("-w") + ast_command.append(opts["file"]) + ast_command.append("-o") + ast_command.append(ast_path) + logging.debug("Generating AST using '%s'", ast_command) + run_command(ast_command, cwd=opts["directory"]) + + def map_extdefs(triple_arch): + """Generate external definition map file for the current source.""" + + args = opts["direct_args"] + opts["flags"] + extdefmap_command = [opts["ctu"].extdef_map_cmd] + extdefmap_command.append(opts["file"]) + extdefmap_command.append("--") + extdefmap_command.extend(args) + logging.debug( + "Generating external definition map using '%s'", extdefmap_command + ) + extdef_src_list = run_command(extdefmap_command, cwd=opts["directory"]) + extdef_ast_list = extdef_map_list_src_to_ast(extdef_src_list) + extern_defs_map_folder = os.path.join( + opts["ctu"].dir, triple_arch, CTU_TEMP_DEFMAP_FOLDER + ) + if not os.path.isdir(extern_defs_map_folder): + try: + os.makedirs(extern_defs_map_folder) + except OSError: + # In case an other process already created it. + pass + if extdef_ast_list: + with tempfile.NamedTemporaryFile( + mode="w", dir=extern_defs_map_folder, delete=False + ) as out_file: + out_file.write("\n".join(extdef_ast_list) + "\n") + + cwd = opts["directory"] + cmd = ( + [opts["clang"], "--analyze"] + + opts["direct_args"] + + opts["flags"] + + [opts["file"]] + ) + triple_arch = get_triple_arch(cmd, cwd) + generate_ast(triple_arch) + map_extdefs(triple_arch) + + +@require(["ctu"]) +def dispatch_ctu(opts, continuation=run_analyzer): + """Execute only one phase of 2 phases of CTU if needed.""" + + ctu_config = opts["ctu"] + + if ctu_config.collect or ctu_config.analyze: + assert ctu_config.collect != ctu_config.analyze + if ctu_config.collect: + return ctu_collect_phase(opts) + if ctu_config.analyze: + cwd = opts["directory"] + cmd = ( + [opts["clang"], "--analyze"] + + opts["direct_args"] + + opts["flags"] + + [opts["file"]] + ) + triarch = get_triple_arch(cmd, cwd) + ctu_options = [ + "ctu-dir=" + os.path.join(ctu_config.dir, triarch), + "experimental-enable-naive-ctu-analysis=true", + ] + analyzer_options = prefix_with("-analyzer-config", ctu_options) + direct_options = prefix_with("-Xanalyzer", analyzer_options) + opts["direct_args"].extend(direct_options) + + return continuation(opts) + + +@require(["flags", "force_debug"]) +def filter_debug_flags(opts, continuation=dispatch_ctu): + """Filter out nondebug macros when requested.""" + + if opts.pop("force_debug"): + # lazy implementation just append an undefine macro at the end + opts.update({"flags": opts["flags"] + ["-UNDEBUG"]}) + + return continuation(opts) + + +@require(["language", "compiler", "file", "flags"]) +def language_check(opts, continuation=filter_debug_flags): + """Find out the language from command line parameters or file name + extension. The decision also influenced by the compiler invocation.""" + + accepted = frozenset( + { + "c", + "c++", + "objective-c", + "objective-c++", + "c-cpp-output", + "c++-cpp-output", + "objective-c-cpp-output", + } + ) + + # language can be given as a parameter... + language = opts.pop("language") + compiler = opts.pop("compiler") + # ... or find out from source file extension + if language is None and compiler is not None: + language = classify_source(opts["file"], compiler == "c") + + if language is None: + logging.debug("skip analysis, language not known") + return None + elif language not in accepted: + logging.debug("skip analysis, language not supported") + return None + else: + logging.debug("analysis, language: %s", language) + opts.update({"language": language, "flags": ["-x", language] + opts["flags"]}) + return continuation(opts) + + +@require(["arch_list", "flags"]) +def arch_check(opts, continuation=language_check): + """Do run analyzer through one of the given architectures.""" + + disabled = frozenset({"ppc", "ppc64"}) + + received_list = opts.pop("arch_list") + if received_list: + # filter out disabled architectures and -arch switches + filtered_list = [a for a in received_list if a not in disabled] + if filtered_list: + # There should be only one arch given (or the same multiple + # times). If there are multiple arch are given and are not + # the same, those should not change the pre-processing step. + # But that's the only pass we have before run the analyzer. + current = filtered_list.pop() + logging.debug("analysis, on arch: %s", current) + + opts.update({"flags": ["-arch", current] + opts["flags"]}) + return continuation(opts) + else: + logging.debug("skip analysis, found not supported arch") + return None + else: + logging.debug("analysis, on default arch") + return continuation(opts) + + +# To have good results from static analyzer certain compiler options shall be +# omitted. The compiler flag filtering only affects the static analyzer run. +# +# Keys are the option name, value number of options to skip +IGNORED_FLAGS = { + "-c": 0, # compile option will be overwritten + "-fsyntax-only": 0, # static analyzer option will be overwritten + "-o": 1, # will set up own output file + # flags below are inherited from the perl implementation. + "-g": 0, + "-save-temps": 0, + "-install_name": 1, + "-exported_symbols_list": 1, + "-current_version": 1, + "-compatibility_version": 1, + "-init": 1, + "-e": 1, + "-seg1addr": 1, + "-bundle_loader": 1, + "-multiply_defined": 1, + "-sectorder": 3, + "--param": 1, + "--serialize-diagnostics": 1, +} + + +def classify_parameters(command): + """Prepare compiler flags (filters some and add others) and take out + language (-x) and architecture (-arch) flags for future processing.""" + + result = { + "flags": [], # the filtered compiler flags + "arch_list": [], # list of architecture flags + "language": None, # compilation language, None, if not specified + "compiler": compiler_language(command), # 'c' or 'c++' + } + + # iterate on the compile options + args = iter(command[1:]) + for arg in args: + # take arch flags into a separate basket + if arg == "-arch": + result["arch_list"].append(next(args)) + # take language + elif arg == "-x": + result["language"] = next(args) + # parameters which looks source file are not flags + elif re.match(r"^[^-].+", arg) and classify_source(arg): + pass + # ignore some flags + elif arg in IGNORED_FLAGS: + count = IGNORED_FLAGS[arg] + for _ in range(count): + next(args) + # we don't care about extra warnings, but we should suppress ones + # that we don't want to see. + elif re.match(r"^-W.+", arg) and not re.match(r"^-Wno-.+", arg): + pass + # and consider everything else as compilation flag. + else: + result["flags"].append(arg) + + return result diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/arguments.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/arguments.py new file mode 100755 index 0000000..e9794e7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/arguments.py @@ -0,0 +1,567 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module parses and validates arguments for command-line interfaces. + +It uses argparse module to create the command line parser. (This library is +in the standard python library since 3.2 and backported to 2.7, but not +earlier.) + +It also implements basic validation methods, related to the command. +Validations are mostly calling specific help methods, or mangling values. +""" +from __future__ import absolute_import, division, print_function + +import os +import sys +import argparse +import logging +import tempfile +from libscanbuild import reconfigure_logging, CtuConfig +from libscanbuild.clang import get_checkers, is_ctu_capable + +__all__ = [ + "parse_args_for_intercept_build", + "parse_args_for_analyze_build", + "parse_args_for_scan_build", +] + + +def parse_args_for_intercept_build(): + """Parse and validate command-line arguments for intercept-build.""" + + parser = create_intercept_parser() + args = parser.parse_args() + + reconfigure_logging(args.verbose) + logging.debug("Raw arguments %s", sys.argv) + + # short validation logic + if not args.build: + parser.error(message="missing build command") + + logging.debug("Parsed arguments: %s", args) + return args + + +def parse_args_for_analyze_build(): + """Parse and validate command-line arguments for analyze-build.""" + + from_build_command = False + parser = create_analyze_parser(from_build_command) + args = parser.parse_args() + + reconfigure_logging(args.verbose) + logging.debug("Raw arguments %s", sys.argv) + + normalize_args_for_analyze(args, from_build_command) + validate_args_for_analyze(parser, args, from_build_command) + logging.debug("Parsed arguments: %s", args) + return args + + +def parse_args_for_scan_build(): + """Parse and validate command-line arguments for scan-build.""" + + from_build_command = True + parser = create_analyze_parser(from_build_command) + args = parser.parse_args() + + reconfigure_logging(args.verbose) + logging.debug("Raw arguments %s", sys.argv) + + normalize_args_for_analyze(args, from_build_command) + validate_args_for_analyze(parser, args, from_build_command) + logging.debug("Parsed arguments: %s", args) + return args + + +def normalize_args_for_analyze(args, from_build_command): + """Normalize parsed arguments for analyze-build and scan-build. + + :param args: Parsed argument object. (Will be mutated.) + :param from_build_command: Boolean value tells is the command suppose + to run the analyzer against a build command or a compilation db.""" + + # make plugins always a list. (it might be None when not specified.) + if args.plugins is None: + args.plugins = [] + + # make exclude directory list unique and absolute. + uniq_excludes = set(os.path.abspath(entry) for entry in args.excludes) + args.excludes = list(uniq_excludes) + + # because shared codes for all tools, some common used methods are + # expecting some argument to be present. so, instead of query the args + # object about the presence of the flag, we fake it here. to make those + # methods more readable. (it's an arguable choice, took it only for those + # which have good default value.) + if from_build_command: + # add cdb parameter invisibly to make report module working. + args.cdb = "compile_commands.json" + + # Make ctu_dir an abspath as it is needed inside clang + if ( + not from_build_command + and hasattr(args, "ctu_phases") + and hasattr(args.ctu_phases, "dir") + ): + args.ctu_dir = os.path.abspath(args.ctu_dir) + + +def validate_args_for_analyze(parser, args, from_build_command): + """Command line parsing is done by the argparse module, but semantic + validation still needs to be done. This method is doing it for + analyze-build and scan-build commands. + + :param parser: The command line parser object. + :param args: Parsed argument object. + :param from_build_command: Boolean value tells is the command suppose + to run the analyzer against a build command or a compilation db. + :return: No return value, but this call might throw when validation + fails.""" + + if args.help_checkers_verbose: + print_checkers(get_checkers(args.clang, args.plugins)) + parser.exit(status=0) + elif args.help_checkers: + print_active_checkers(get_checkers(args.clang, args.plugins)) + parser.exit(status=0) + elif from_build_command and not args.build: + parser.error(message="missing build command") + elif not from_build_command and not os.path.exists(args.cdb): + parser.error(message="compilation database is missing") + + # If the user wants CTU mode + if ( + not from_build_command + and hasattr(args, "ctu_phases") + and hasattr(args.ctu_phases, "dir") + ): + # If CTU analyze_only, the input directory should exist + if ( + args.ctu_phases.analyze + and not args.ctu_phases.collect + and not os.path.exists(args.ctu_dir) + ): + parser.error(message="missing CTU directory") + # Check CTU capability via checking clang-extdef-mapping + if not is_ctu_capable(args.extdef_map_cmd): + parser.error( + message="""This version of clang does not support CTU + functionality or clang-extdef-mapping command not found.""" + ) + + +def create_intercept_parser(): + """Creates a parser for command-line arguments to 'intercept'.""" + + parser = create_default_parser() + parser_add_cdb(parser) + + parser_add_prefer_wrapper(parser) + parser_add_compilers(parser) + + advanced = parser.add_argument_group("advanced options") + group = advanced.add_mutually_exclusive_group() + group.add_argument( + "--append", + action="store_true", + help="""Extend existing compilation database with new entries. + Duplicate entries are detected and not present in the final output. + The output is not continuously updated, it's done when the build + command finished. """, + ) + + parser.add_argument( + dest="build", nargs=argparse.REMAINDER, help="""Command to run.""" + ) + return parser + + +def create_analyze_parser(from_build_command): + """Creates a parser for command-line arguments to 'analyze'.""" + + parser = create_default_parser() + + if from_build_command: + parser_add_prefer_wrapper(parser) + parser_add_compilers(parser) + + parser.add_argument( + "--intercept-first", + action="store_true", + help="""Run the build commands first, intercept compiler + calls and then run the static analyzer afterwards. + Generally speaking it has better coverage on build commands. + With '--override-compiler' it use compiler wrapper, but does + not run the analyzer till the build is finished.""", + ) + else: + parser_add_cdb(parser) + + parser.add_argument( + "--status-bugs", + action="store_true", + help="""The exit status of '%(prog)s' is the same as the executed + build command. This option ignores the build exit status and sets to + be non zero if it found potential bugs or zero otherwise.""", + ) + parser.add_argument( + "--exclude", + metavar="", + dest="excludes", + action="append", + default=[], + help="""Do not run static analyzer against files found in this + directory. (You can specify this option multiple times.) + Could be useful when project contains 3rd party libraries.""", + ) + + output = parser.add_argument_group("output control options") + output.add_argument( + "--output", + "-o", + metavar="", + default=tempfile.gettempdir(), + help="""Specifies the output directory for analyzer reports. + Subdirectory will be created if default directory is targeted.""", + ) + output.add_argument( + "--keep-empty", + action="store_true", + help="""Don't remove the build results directory even if no issues + were reported.""", + ) + output.add_argument( + "--html-title", + metavar="", + help="""Specify the title used on generated HTML pages. + If not specified, a default title will be used.""", + ) + format_group = output.add_mutually_exclusive_group() + format_group.add_argument( + "--plist", + "-plist", + dest="output_format", + const="plist", + default="html", + action="store_const", + help="""Cause the results as a set of .plist files.""", + ) + format_group.add_argument( + "--plist-html", + "-plist-html", + dest="output_format", + const="plist-html", + default="html", + action="store_const", + help="""Cause the results as a set of .html and .plist files.""", + ) + format_group.add_argument( + "--plist-multi-file", + "-plist-multi-file", + dest="output_format", + const="plist-multi-file", + default="html", + action="store_const", + help="""Cause the results as a set of .plist files with extra + information on related files.""", + ) + format_group.add_argument( + "--sarif", + "-sarif", + dest="output_format", + const="sarif", + default="html", + action="store_const", + help="""Cause the results as a result.sarif file.""", + ) + format_group.add_argument( + "--sarif-html", + "-sarif-html", + dest="output_format", + const="sarif-html", + default="html", + action="store_const", + help="""Cause the results as a result.sarif file and .html files.""", + ) + + advanced = parser.add_argument_group("advanced options") + advanced.add_argument( + "--use-analyzer", + metavar="<path>", + dest="clang", + default="clang", + help="""'%(prog)s' uses the 'clang' executable relative to itself for + static analysis. One can override this behavior with this option by + using the 'clang' packaged with Xcode (on OS X) or from the PATH.""", + ) + advanced.add_argument( + "--no-failure-reports", + "-no-failure-reports", + dest="output_failures", + action="store_false", + help="""Do not create a 'failures' subdirectory that includes analyzer + crash reports and preprocessed source files.""", + ) + parser.add_argument( + "--analyze-headers", + action="store_true", + help="""Also analyze functions in #included files. By default, such + functions are skipped unless they are called by functions within the + main source file.""", + ) + advanced.add_argument( + "--stats", + "-stats", + action="store_true", + help="""Generates visitation statistics for the project.""", + ) + advanced.add_argument( + "--internal-stats", + action="store_true", + help="""Generate internal analyzer statistics.""", + ) + advanced.add_argument( + "--maxloop", + "-maxloop", + metavar="<loop count>", + type=int, + help="""Specify the number of times a block can be visited before + giving up. Increase for more comprehensive coverage at a cost of + speed.""", + ) + advanced.add_argument( + "--store", + "-store", + metavar="<model>", + dest="store_model", + choices=["region", "basic"], + help="""Specify the store model used by the analyzer. 'region' + specifies a field- sensitive store model. 'basic' which is far less + precise but can more quickly analyze code. 'basic' was the default + store model for checker-0.221 and earlier.""", + ) + advanced.add_argument( + "--constraints", + "-constraints", + metavar="<model>", + dest="constraints_model", + choices=["range", "basic"], + help="""Specify the constraint engine used by the analyzer. Specifying + 'basic' uses a simpler, less powerful constraint model used by + checker-0.160 and earlier.""", + ) + advanced.add_argument( + "--analyzer-config", + "-analyzer-config", + metavar="<options>", + help="""Provide options to pass through to the analyzer's + -analyzer-config flag. Several options are separated with comma: + 'key1=val1,key2=val2' + + Available options: + stable-report-filename=true or false (default) + + Switch the page naming to: + report-<filename>-<function/method name>-<id>.html + instead of report-XXXXXX.html""", + ) + advanced.add_argument( + "--force-analyze-debug-code", + dest="force_debug", + action="store_true", + help="""Tells analyzer to enable assertions in code even if they were + disabled during compilation, enabling more precise results.""", + ) + + plugins = parser.add_argument_group("checker options") + plugins.add_argument( + "--load-plugin", + "-load-plugin", + metavar="<plugin library>", + dest="plugins", + action="append", + help="""Loading external checkers using the clang plugin interface.""", + ) + plugins.add_argument( + "--enable-checker", + "-enable-checker", + metavar="<checker name>", + action=AppendCommaSeparated, + help="""Enable specific checker.""", + ) + plugins.add_argument( + "--disable-checker", + "-disable-checker", + metavar="<checker name>", + action=AppendCommaSeparated, + help="""Disable specific checker.""", + ) + plugins.add_argument( + "--help-checkers", + action="store_true", + help="""A default group of checkers is run unless explicitly disabled. + Exactly which checkers constitute the default group is a function of + the operating system in use. These can be printed with this flag.""", + ) + plugins.add_argument( + "--help-checkers-verbose", + action="store_true", + help="""Print all available checkers and mark the enabled ones.""", + ) + + if from_build_command: + parser.add_argument( + dest="build", nargs=argparse.REMAINDER, help="""Command to run.""" + ) + else: + ctu = parser.add_argument_group("cross translation unit analysis") + ctu_mutex_group = ctu.add_mutually_exclusive_group() + ctu_mutex_group.add_argument( + "--ctu", + action="store_const", + const=CtuConfig(collect=True, analyze=True, dir="", extdef_map_cmd=""), + dest="ctu_phases", + help="""Perform cross translation unit (ctu) analysis (both collect + and analyze phases) using default <ctu-dir> for temporary output. + At the end of the analysis, the temporary directory is removed.""", + ) + ctu.add_argument( + "--ctu-dir", + metavar="<ctu-dir>", + dest="ctu_dir", + default="ctu-dir", + help="""Defines the temporary directory used between ctu + phases.""", + ) + ctu_mutex_group.add_argument( + "--ctu-collect-only", + action="store_const", + const=CtuConfig(collect=True, analyze=False, dir="", extdef_map_cmd=""), + dest="ctu_phases", + help="""Perform only the collect phase of ctu. + Keep <ctu-dir> for further use.""", + ) + ctu_mutex_group.add_argument( + "--ctu-analyze-only", + action="store_const", + const=CtuConfig(collect=False, analyze=True, dir="", extdef_map_cmd=""), + dest="ctu_phases", + help="""Perform only the analyze phase of ctu. <ctu-dir> should be + present and will not be removed after analysis.""", + ) + ctu.add_argument( + "--use-extdef-map-cmd", + metavar="<path>", + dest="extdef_map_cmd", + default="clang-extdef-mapping", + help="""'%(prog)s' uses the 'clang-extdef-mapping' executable + relative to itself for generating external definition maps for + static analysis. One can override this behavior with this option + by using the 'clang-extdef-mapping' packaged with Xcode (on OS X) + or from the PATH.""", + ) + return parser + + +def create_default_parser(): + """Creates command line parser for all build wrapper commands.""" + + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + + parser.add_argument( + "--verbose", + "-v", + action="count", + default=0, + help="""Enable verbose output from '%(prog)s'. A second, third and + fourth flags increases verbosity.""", + ) + return parser + + +def parser_add_cdb(parser): + parser.add_argument( + "--cdb", + metavar="<file>", + default="compile_commands.json", + help="""The JSON compilation database.""", + ) + + +def parser_add_prefer_wrapper(parser): + parser.add_argument( + "--override-compiler", + action="store_true", + help="""Always resort to the compiler wrapper even when better + intercept methods are available.""", + ) + + +def parser_add_compilers(parser): + parser.add_argument( + "--use-cc", + metavar="<path>", + dest="cc", + default=os.getenv("CC", "cc"), + help="""When '%(prog)s' analyzes a project by interposing a compiler + wrapper, which executes a real compiler for compilation and do other + tasks (record the compiler invocation). Because of this interposing, + '%(prog)s' does not know what compiler your project normally uses. + Instead, it simply overrides the CC environment variable, and guesses + your default compiler. + + If you need '%(prog)s' to use a specific compiler for *compilation* + then you can use this option to specify a path to that compiler.""", + ) + parser.add_argument( + "--use-c++", + metavar="<path>", + dest="cxx", + default=os.getenv("CXX", "c++"), + help="""This is the same as "--use-cc" but for C++ code.""", + ) + + +class AppendCommaSeparated(argparse.Action): + """argparse Action class to support multiple comma separated lists.""" + + def __call__(self, __parser, namespace, values, __option_string): + # getattr(obj, attr, default) does not really returns default but none + if getattr(namespace, self.dest, None) is None: + setattr(namespace, self.dest, []) + # once it's fixed we can use as expected + actual = getattr(namespace, self.dest) + actual.extend(values.split(",")) + setattr(namespace, self.dest, actual) + + +def print_active_checkers(checkers): + """Print active checkers to stdout.""" + + for name in sorted(name for name, (_, active) in checkers.items() if active): + print(name) + + +def print_checkers(checkers): + """Print verbose checker help to stdout.""" + + print("") + print("available checkers:") + print("") + for name in sorted(checkers.keys()): + description, active = checkers[name] + prefix = "+" if active else " " + if len(name) > 30: + print(" {0} {1}".format(prefix, name)) + print(" " * 35 + description) + else: + print(" {0} {1: <30} {2}".format(prefix, name, description)) + print("") + print('NOTE: "+" indicates that an analysis is enabled by default.') + print("") diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/clang.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/clang.py new file mode 100755 index 0000000..25a50b6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/clang.py @@ -0,0 +1,191 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module is responsible for the Clang executable. + +Since Clang command line interface is so rich, but this project is using only +a subset of that, it makes sense to create a function specific wrapper. """ + +import subprocess +import re +from libscanbuild import run_command +from libscanbuild.shell import decode + +__all__ = [ + "get_version", + "get_arguments", + "get_checkers", + "is_ctu_capable", + "get_triple_arch", +] + +# regex for activated checker +ACTIVE_CHECKER_PATTERN = re.compile(r"^-analyzer-checker=(.*)$") + + +class ClangErrorException(Exception): + def __init__(self, error): + self.error = error + + +def get_version(clang): + """Returns the compiler version as string. + + :param clang: the compiler we are using + :return: the version string printed to stderr""" + + output = run_command([clang, "-v"]) + # the relevant version info is in the first line + return output[0] + + +def get_arguments(command, cwd): + """Capture Clang invocation. + + :param command: the compilation command + :param cwd: the current working directory + :return: the detailed front-end invocation command""" + + cmd = command[:] + cmd.insert(1, "-###") + cmd.append("-fno-color-diagnostics") + + output = run_command(cmd, cwd=cwd) + # The relevant information is in the last line of the output. + # Don't check if finding last line fails, would throw exception anyway. + last_line = output[-1] + if re.search(r"clang(.*): error:", last_line): + raise ClangErrorException(last_line) + return decode(last_line) + + +def get_active_checkers(clang, plugins): + """Get the active checker list. + + :param clang: the compiler we are using + :param plugins: list of plugins which was requested by the user + :return: list of checker names which are active + + To get the default checkers we execute Clang to print how this + compilation would be called. And take out the enabled checker from the + arguments. For input file we specify stdin and pass only language + information.""" + + def get_active_checkers_for(language): + """Returns a list of active checkers for the given language.""" + + load_args = [ + arg for plugin in plugins for arg in ["-Xclang", "-load", "-Xclang", plugin] + ] + cmd = [clang, "--analyze"] + load_args + ["-x", language, "-"] + return [ + ACTIVE_CHECKER_PATTERN.match(arg).group(1) + for arg in get_arguments(cmd, ".") + if ACTIVE_CHECKER_PATTERN.match(arg) + ] + + result = set() + for language in ["c", "c++", "objective-c", "objective-c++"]: + result.update(get_active_checkers_for(language)) + return frozenset(result) + + +def is_active(checkers): + """Returns a method, which classifies the checker active or not, + based on the received checker name list.""" + + def predicate(checker): + """Returns True if the given checker is active.""" + + return any(pattern.match(checker) for pattern in predicate.patterns) + + predicate.patterns = [re.compile(r"^" + a + r"(\.|$)") for a in checkers] + return predicate + + +def parse_checkers(stream): + """Parse clang -analyzer-checker-help output. + + Below the line 'CHECKERS:' are there the name description pairs. + Many of them are in one line, but some long named checker has the + name and the description in separate lines. + + The checker name is always prefixed with two space character. The + name contains no whitespaces. Then followed by newline (if it's + too long) or other space characters comes the description of the + checker. The description ends with a newline character. + + :param stream: list of lines to parse + :return: generator of tuples + + (<checker name>, <checker description>)""" + + lines = iter(stream) + # find checkers header + for line in lines: + if re.match(r"^CHECKERS:", line): + break + # find entries + state = None + for line in lines: + if state and not re.match(r"^\s\s\S", line): + yield (state, line.strip()) + state = None + elif re.match(r"^\s\s\S+$", line.rstrip()): + state = line.strip() + else: + pattern = re.compile(r"^\s\s(?P<key>\S*)\s*(?P<value>.*)") + match = pattern.match(line.rstrip()) + if match: + current = match.groupdict() + yield (current["key"], current["value"]) + + +def get_checkers(clang, plugins): + """Get all the available checkers from default and from the plugins. + + :param clang: the compiler we are using + :param plugins: list of plugins which was requested by the user + :return: a dictionary of all available checkers and its status + + {<checker name>: (<checker description>, <is active by default>)}""" + + load = [elem for plugin in plugins for elem in ["-load", plugin]] + cmd = [clang, "-cc1"] + load + ["-analyzer-checker-help"] + + lines = run_command(cmd) + + is_active_checker = is_active(get_active_checkers(clang, plugins)) + + checkers = { + name: (description, is_active_checker(name)) + for name, description in parse_checkers(lines) + } + if not checkers: + raise Exception("Could not query Clang for available checkers.") + + return checkers + + +def is_ctu_capable(extdef_map_cmd): + """Detects if the current (or given) clang and external definition mapping + executables are CTU compatible.""" + + try: + run_command([extdef_map_cmd, "-version"]) + except (OSError, subprocess.CalledProcessError): + return False + return True + + +def get_triple_arch(command, cwd): + """Returns the architecture part of the target triple for the given + compilation command.""" + + cmd = get_arguments(command, cwd) + try: + separator = cmd.index("-triple") + return cmd[separator + 1] + except (IndexError, ValueError): + return "" diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/compilation.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/compilation.py new file mode 100755 index 0000000..6b9e3ca --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/compilation.py @@ -0,0 +1,141 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module is responsible for to parse a compiler invocation. """ + +import re +import os +import collections + +__all__ = ["split_command", "classify_source", "compiler_language"] + +# Ignored compiler options map for compilation database creation. +# The map is used in `split_command` method. (Which does ignore and classify +# parameters.) Please note, that these are not the only parameters which +# might be ignored. +# +# Keys are the option name, value number of options to skip +IGNORED_FLAGS = { + # compiling only flag, ignored because the creator of compilation + # database will explicitly set it. + "-c": 0, + # preprocessor macros, ignored because would cause duplicate entries in + # the output (the only difference would be these flags). this is actual + # finding from users, who suffered longer execution time caused by the + # duplicates. + "-MD": 0, + "-MMD": 0, + "-MG": 0, + "-MP": 0, + "-MF": 1, + "-MT": 1, + "-MQ": 1, + # linker options, ignored because for compilation database will contain + # compilation commands only. so, the compiler would ignore these flags + # anyway. the benefit to get rid of them is to make the output more + # readable. + "-static": 0, + "-shared": 0, + "-s": 0, + "-rdynamic": 0, + "-l": 1, + "-L": 1, + "-u": 1, + "-z": 1, + "-T": 1, + "-Xlinker": 1, +} + +# Known C/C++ compiler executable name patterns +COMPILER_PATTERNS = frozenset( + [ + re.compile(r"^(intercept-|analyze-|)c(c|\+\+)$"), + re.compile(r"^([^-]*-)*[mg](cc|\+\+)(-\d+(\.\d+){0,2})?$"), + re.compile(r"^([^-]*-)*clang(\+\+)?(-\d+(\.\d+){0,2})?$"), + re.compile(r"^llvm-g(cc|\+\+)$"), + ] +) + + +def split_command(command): + """Returns a value when the command is a compilation, None otherwise. + + The value on success is a named tuple with the following attributes: + + files: list of source files + flags: list of compile options + compiler: string value of 'c' or 'c++'""" + + # the result of this method + result = collections.namedtuple("Compilation", ["compiler", "flags", "files"]) + result.compiler = compiler_language(command) + result.flags = [] + result.files = [] + # quit right now, if the program was not a C/C++ compiler + if not result.compiler: + return None + # iterate on the compile options + args = iter(command[1:]) + for arg in args: + # quit when compilation pass is not involved + if arg in {"-E", "-S", "-cc1", "-M", "-MM", "-###"}: + return None + # ignore some flags + elif arg in IGNORED_FLAGS: + count = IGNORED_FLAGS[arg] + for _ in range(count): + next(args) + elif re.match(r"^-(l|L|Wl,).+", arg): + pass + # some parameters could look like filename, take as compile option + elif arg in {"-D", "-I"}: + result.flags.extend([arg, next(args)]) + # parameter which looks source file is taken... + elif re.match(r"^[^-].+", arg) and classify_source(arg): + result.files.append(arg) + # and consider everything else as compile option. + else: + result.flags.append(arg) + # do extra check on number of source files + return result if result.files else None + + +def classify_source(filename, c_compiler=True): + """Return the language from file name extension.""" + + mapping = { + ".c": "c" if c_compiler else "c++", + ".i": "c-cpp-output" if c_compiler else "c++-cpp-output", + ".ii": "c++-cpp-output", + ".m": "objective-c", + ".mi": "objective-c-cpp-output", + ".mm": "objective-c++", + ".mii": "objective-c++-cpp-output", + ".C": "c++", + ".cc": "c++", + ".CC": "c++", + ".cp": "c++", + ".cpp": "c++", + ".cxx": "c++", + ".c++": "c++", + ".C++": "c++", + ".txx": "c++", + } + + __, extension = os.path.splitext(os.path.basename(filename)) + return mapping.get(extension) + + +def compiler_language(command): + """A predicate to decide the command is a compiler call or not. + + Returns 'c' or 'c++' when it match. None otherwise.""" + + cplusplus = re.compile(r"^(.+)(\+\+)(-.+|)$") + + if command: + executable = os.path.basename(command[0]) + if any(pattern.match(executable) for pattern in COMPILER_PATTERNS): + return "c++" if cplusplus.match(executable) else "c" + return None diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/intercept.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/intercept.py new file mode 100755 index 0000000..59789f6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/intercept.py @@ -0,0 +1,271 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module is responsible to capture the compiler invocation of any +build process. The result of that should be a compilation database. + +This implementation is using the LD_PRELOAD or DYLD_INSERT_LIBRARIES +mechanisms provided by the dynamic linker. The related library is implemented +in C language and can be found under 'libear' directory. + +The 'libear' library is capturing all child process creation and logging the +relevant information about it into separate files in a specified directory. +The parameter of this process is the output directory name, where the report +files shall be placed. This parameter is passed as an environment variable. + +The module also implements compiler wrappers to intercept the compiler calls. + +The module implements the build command execution and the post-processing of +the output files, which will condensates into a compilation database. """ + +import sys +import os +import os.path +import re +import itertools +import json +import glob +import logging +from libear import build_libear, TemporaryDirectory +from libscanbuild import ( + command_entry_point, + compiler_wrapper, + wrapper_environment, + run_command, + run_build, +) +from libscanbuild import duplicate_check +from libscanbuild.compilation import split_command +from libscanbuild.arguments import parse_args_for_intercept_build +from libscanbuild.shell import encode, decode + +__all__ = ["capture", "intercept_build", "intercept_compiler_wrapper"] + +GS = chr(0x1D) +RS = chr(0x1E) +US = chr(0x1F) + +COMPILER_WRAPPER_CC = "intercept-cc" +COMPILER_WRAPPER_CXX = "intercept-c++" +TRACE_FILE_EXTENSION = ".cmd" # same as in ear.c +WRAPPER_ONLY_PLATFORMS = frozenset({"win32", "cygwin"}) + + +@command_entry_point +def intercept_build(): + """Entry point for 'intercept-build' command.""" + + args = parse_args_for_intercept_build() + return capture(args) + + +def capture(args): + """The entry point of build command interception.""" + + def post_processing(commands): + """To make a compilation database, it needs to filter out commands + which are not compiler calls. Needs to find the source file name + from the arguments. And do shell escaping on the command. + + To support incremental builds, it is desired to read elements from + an existing compilation database from a previous run. These elements + shall be merged with the new elements.""" + + # create entries from the current run + current = itertools.chain.from_iterable( + # creates a sequence of entry generators from an exec, + format_entry(command) + for command in commands + ) + # read entries from previous run + if "append" in args and args.append and os.path.isfile(args.cdb): + with open(args.cdb) as handle: + previous = iter(json.load(handle)) + else: + previous = iter([]) + # filter out duplicate entries from both + duplicate = duplicate_check(entry_hash) + return ( + entry + for entry in itertools.chain(previous, current) + if os.path.exists(entry["file"]) and not duplicate(entry) + ) + + with TemporaryDirectory(prefix="intercept-") as tmp_dir: + # run the build command + environment = setup_environment(args, tmp_dir) + exit_code = run_build(args.build, env=environment) + # read the intercepted exec calls + exec_traces = itertools.chain.from_iterable( + parse_exec_trace(os.path.join(tmp_dir, filename)) + for filename in sorted(glob.iglob(os.path.join(tmp_dir, "*.cmd"))) + ) + # do post processing + entries = post_processing(exec_traces) + # dump the compilation database + with open(args.cdb, "w+") as handle: + json.dump(list(entries), handle, sort_keys=True, indent=4) + return exit_code + + +def setup_environment(args, destination): + """Sets up the environment for the build command. + + It sets the required environment variables and execute the given command. + The exec calls will be logged by the 'libear' preloaded library or by the + 'wrapper' programs.""" + + c_compiler = args.cc if "cc" in args else "cc" + cxx_compiler = args.cxx if "cxx" in args else "c++" + + libear_path = ( + None + if args.override_compiler or is_preload_disabled(sys.platform) + else build_libear(c_compiler, destination) + ) + + environment = dict(os.environ) + environment.update({"INTERCEPT_BUILD_TARGET_DIR": destination}) + + if not libear_path: + logging.debug("intercept gonna use compiler wrappers") + environment.update(wrapper_environment(args)) + environment.update({"CC": COMPILER_WRAPPER_CC, "CXX": COMPILER_WRAPPER_CXX}) + elif sys.platform == "darwin": + logging.debug("intercept gonna preload libear on OSX") + environment.update( + {"DYLD_INSERT_LIBRARIES": libear_path, "DYLD_FORCE_FLAT_NAMESPACE": "1"} + ) + else: + logging.debug("intercept gonna preload libear on UNIX") + environment.update({"LD_PRELOAD": libear_path}) + + return environment + + +@command_entry_point +def intercept_compiler_wrapper(): + """Entry point for `intercept-cc` and `intercept-c++`.""" + + return compiler_wrapper(intercept_compiler_wrapper_impl) + + +def intercept_compiler_wrapper_impl(_, execution): + """Implement intercept compiler wrapper functionality. + + It does generate execution report into target directory. + The target directory name is from environment variables.""" + + message_prefix = "execution report might be incomplete: %s" + + target_dir = os.getenv("INTERCEPT_BUILD_TARGET_DIR") + if not target_dir: + logging.warning(message_prefix, "missing target directory") + return + # write current execution info to the pid file + try: + target_file_name = str(os.getpid()) + TRACE_FILE_EXTENSION + target_file = os.path.join(target_dir, target_file_name) + logging.debug("writing execution report to: %s", target_file) + write_exec_trace(target_file, execution) + except IOError: + logging.warning(message_prefix, "io problem") + + +def write_exec_trace(filename, entry): + """Write execution report file. + + This method shall be sync with the execution report writer in interception + library. The entry in the file is a JSON objects. + + :param filename: path to the output execution trace file, + :param entry: the Execution object to append to that file.""" + + with open(filename, "ab") as handler: + pid = str(entry.pid) + command = US.join(entry.cmd) + US + content = RS.join([pid, pid, "wrapper", entry.cwd, command]) + GS + handler.write(content.encode("utf-8")) + + +def parse_exec_trace(filename): + """Parse the file generated by the 'libear' preloaded library. + + Given filename points to a file which contains the basic report + generated by the interception library or wrapper command. A single + report file _might_ contain multiple process creation info.""" + + logging.debug("parse exec trace file: %s", filename) + with open(filename, "r") as handler: + content = handler.read() + for group in filter(bool, content.split(GS)): + records = group.split(RS) + yield { + "pid": records[0], + "ppid": records[1], + "function": records[2], + "directory": records[3], + "command": records[4].split(US)[:-1], + } + + +def format_entry(exec_trace): + """Generate the desired fields for compilation database entries.""" + + def abspath(cwd, name): + """Create normalized absolute path from input filename.""" + fullname = name if os.path.isabs(name) else os.path.join(cwd, name) + return os.path.normpath(fullname) + + logging.debug("format this command: %s", exec_trace["command"]) + compilation = split_command(exec_trace["command"]) + if compilation: + for source in compilation.files: + compiler = "c++" if compilation.compiler == "c++" else "cc" + command = [compiler, "-c"] + compilation.flags + [source] + logging.debug("formated as: %s", command) + yield { + "directory": exec_trace["directory"], + "command": encode(command), + "file": abspath(exec_trace["directory"], source), + } + + +def is_preload_disabled(platform): + """Library-based interposition will fail silently if SIP is enabled, + so this should be detected. You can detect whether SIP is enabled on + Darwin by checking whether (1) there is a binary called 'csrutil' in + the path and, if so, (2) whether the output of executing 'csrutil status' + contains 'System Integrity Protection status: enabled'. + + :param platform: name of the platform (returned by sys.platform), + :return: True if library preload will fail by the dynamic linker.""" + + if platform in WRAPPER_ONLY_PLATFORMS: + return True + elif platform == "darwin": + command = ["csrutil", "status"] + pattern = re.compile(r"System Integrity Protection status:\s+enabled") + try: + return any(pattern.match(line) for line in run_command(command)) + except: + return False + else: + return False + + +def entry_hash(entry): + """Implement unique hash method for compilation database entries.""" + + # For faster lookup in set filename is reverted + filename = entry["file"][::-1] + # For faster lookup in set directory is reverted + directory = entry["directory"][::-1] + # On OS X the 'cc' and 'c++' compilers are wrappers for + # 'clang' therefore both call would be logged. To avoid + # this the hash does not contain the first word of the + # command. + command = " ".join(decode(entry["command"])[1:]) + + return "<>".join([filename, directory, command]) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/report.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/report.py new file mode 100755 index 0000000..c745d76 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/report.py @@ -0,0 +1,691 @@ +# -*- coding: utf-8 -*- +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +""" This module is responsible to generate 'index.html' for the report. + +The input for this step is the output directory, where individual reports +could be found. It parses those reports and generates 'index.html'. """ + +import re +import os +import os.path +import sys +import shutil +import plistlib +import glob +import json +import logging +import datetime +from libscanbuild import duplicate_check +from libscanbuild.clang import get_version + +__all__ = ["document"] + + +def document(args): + """Generates cover report and returns the number of bugs/crashes.""" + + html_reports_available = args.output_format in {"html", "plist-html", "sarif-html"} + sarif_reports_available = args.output_format in {"sarif", "sarif-html"} + + logging.debug("count crashes and bugs") + crash_count = sum(1 for _ in read_crashes(args.output)) + bug_counter = create_counters() + for bug in read_bugs(args.output, html_reports_available): + bug_counter(bug) + result = crash_count + bug_counter.total + + if html_reports_available and result: + use_cdb = os.path.exists(args.cdb) + + logging.debug("generate index.html file") + # common prefix for source files to have sorter path + prefix = commonprefix_from(args.cdb) if use_cdb else os.getcwd() + # assemble the cover from multiple fragments + fragments = [] + try: + if bug_counter.total: + fragments.append(bug_summary(args.output, bug_counter)) + fragments.append(bug_report(args.output, prefix)) + if crash_count: + fragments.append(crash_report(args.output, prefix)) + assemble_cover(args, prefix, fragments) + # copy additional files to the report + copy_resource_files(args.output) + if use_cdb: + shutil.copy(args.cdb, args.output) + finally: + for fragment in fragments: + os.remove(fragment) + + if sarif_reports_available: + logging.debug("merging sarif files") + merge_sarif_files(args.output) + + return result + + +def assemble_cover(args, prefix, fragments): + """Put together the fragments into a final report.""" + + import getpass + import socket + + if args.html_title is None: + args.html_title = os.path.basename(prefix) + " - analyzer results" + + with open(os.path.join(args.output, "index.html"), "w") as handle: + indent = 0 + handle.write( + reindent( + """ + |<!DOCTYPE html> + |<html> + | <head> + | <title>{html_title} + | + | + | + | """, + indent, + ).format(html_title=args.html_title) + ) + handle.write(comment("SUMMARYENDHEAD")) + handle.write( + reindent( + """ + | + |

{html_title}

+ | + | + | + | + | + | + |
User:{user_name}@{host_name}
Working Directory:{current_dir}
Command Line:{cmd_args}
Clang Version:{clang_version}
Date:{date}
""", + indent, + ).format( + html_title=args.html_title, + user_name=getpass.getuser(), + host_name=socket.gethostname(), + current_dir=prefix, + cmd_args=" ".join(sys.argv), + clang_version=get_version(args.clang), + date=datetime.datetime.today().strftime("%c"), + ) + ) + for fragment in fragments: + # copy the content of fragments + with open(fragment, "r") as input_handle: + shutil.copyfileobj(input_handle, handle) + handle.write( + reindent( + """ + | + |""", + indent, + ) + ) + + +def bug_summary(output_dir, bug_counter): + """Bug summary is a HTML table to give a better overview of the bugs.""" + + name = os.path.join(output_dir, "summary.html.fragment") + with open(name, "w") as handle: + indent = 4 + handle.write( + reindent( + """ + |

Bug Summary

+ | + | + | + | + | + | + | + | + | """, + indent, + ) + ) + handle.write( + reindent( + """ + | + | + | + | + | """, + indent, + ).format(bug_counter.total) + ) + for category, types in bug_counter.categories.items(): + handle.write( + reindent( + """ + | + | + | """, + indent, + ).format(category) + ) + for bug_type in types.values(): + handle.write( + reindent( + """ + | + | + | + | + | """, + indent, + ).format(**bug_type) + ) + handle.write( + reindent( + """ + | + |
Bug TypeQuantityDisplay?
All Bugs{0} + |
+ | + |
+ |
{0}
{bug_type}{bug_count} + |
+ | + |
+ |
""", + indent, + ) + ) + handle.write(comment("SUMMARYBUGEND")) + return name + + +def bug_report(output_dir, prefix): + """Creates a fragment from the analyzer reports.""" + + pretty = prettify_bug(prefix, output_dir) + bugs = (pretty(bug) for bug in read_bugs(output_dir, True)) + + name = os.path.join(output_dir, "bugs.html.fragment") + with open(name, "w") as handle: + indent = 4 + handle.write( + reindent( + """ + |

Reports

+ | + | + | + | + | + | + | + | + | + | + | + | + | """, + indent, + ) + ) + handle.write(comment("REPORTBUGCOL")) + for current in bugs: + handle.write( + reindent( + """ + | + | + | + | + | + | + | + | + | """, + indent, + ).format(**current) + ) + handle.write(comment("REPORTBUG", {"id": current["report_file"]})) + handle.write( + reindent( + """ + | + |
Bug Group + | Bug Type + |  ▾ + | FileFunction/MethodLinePath Length
{bug_category}{bug_type}{bug_file}{bug_function}{bug_line}{bug_path_length}View Report
""", + indent, + ) + ) + handle.write(comment("REPORTBUGEND")) + return name + + +def crash_report(output_dir, prefix): + """Creates a fragment from the compiler crashes.""" + + pretty = prettify_crash(prefix, output_dir) + crashes = (pretty(crash) for crash in read_crashes(output_dir)) + + name = os.path.join(output_dir, "crashes.html.fragment") + with open(name, "w") as handle: + indent = 4 + handle.write( + reindent( + """ + |

Analyzer Failures

+ |

The analyzer had problems processing the following files:

+ | + | + | + | + | + | + | + | + | + | """, + indent, + ) + ) + for current in crashes: + handle.write( + reindent( + """ + | + | + | + | + | + | """, + indent, + ).format(**current) + ) + handle.write(comment("REPORTPROBLEM", current)) + handle.write( + reindent( + """ + | + |
ProblemSource FilePreprocessed FileSTDERR Output
{problem}{source}preprocessor outputanalyzer std err
""", + indent, + ) + ) + handle.write(comment("REPORTCRASHES")) + return name + + +def read_crashes(output_dir): + """Generate a unique sequence of crashes from given output directory.""" + + return ( + parse_crash(filename) + for filename in glob.iglob(os.path.join(output_dir, "failures", "*.info.txt")) + ) + + +def read_bugs(output_dir, html): + # type: (str, bool) -> Generator[Dict[str, Any], None, None] + """Generate a unique sequence of bugs from given output directory. + + Duplicates can be in a project if the same module was compiled multiple + times with different compiler options. These would be better to show in + the final report (cover) only once.""" + + def empty(file_name): + return os.stat(file_name).st_size == 0 + + duplicate = duplicate_check( + lambda bug: "{bug_line}.{bug_path_length}:{bug_file}".format(**bug) + ) + + # get the right parser for the job. + parser = parse_bug_html if html else parse_bug_plist + # get the input files, which are not empty. + pattern = os.path.join(output_dir, "*.html" if html else "*.plist") + bug_files = (file for file in glob.iglob(pattern) if not empty(file)) + + for bug_file in bug_files: + for bug in parser(bug_file): + if not duplicate(bug): + yield bug + + +def merge_sarif_files(output_dir, sort_files=False): + """Reads and merges all .sarif files in the given output directory. + + Each sarif file in the output directory is understood as a single run + and thus appear separate in the top level runs array. This requires + modifying the run index of any embedded links in messages. + """ + + def empty(file_name): + return os.stat(file_name).st_size == 0 + + def update_sarif_object(sarif_object, runs_count_offset): + """ + Given a SARIF object, checks its dictionary entries for a 'message' property. + If it exists, updates the message index of embedded links in the run index. + + Recursively looks through entries in the dictionary. + """ + if not isinstance(sarif_object, dict): + return sarif_object + + if "message" in sarif_object: + sarif_object["message"] = match_and_update_run( + sarif_object["message"], runs_count_offset + ) + + for key in sarif_object: + if isinstance(sarif_object[key], list): + # iterate through subobjects and update it. + arr = [ + update_sarif_object(entry, runs_count_offset) + for entry in sarif_object[key] + ] + sarif_object[key] = arr + elif isinstance(sarif_object[key], dict): + sarif_object[key] = update_sarif_object( + sarif_object[key], runs_count_offset + ) + else: + # do nothing + pass + + return sarif_object + + def match_and_update_run(message, runs_count_offset): + """ + Given a SARIF message object, checks if the text property contains an embedded link and + updates the run index if necessary. + """ + if "text" not in message: + return message + + # we only merge runs, so we only need to update the run index + pattern = re.compile(r"sarif:/runs/(\d+)") + + text = message["text"] + matches = re.finditer(pattern, text) + matches_list = list(matches) + + # update matches from right to left to make increasing character length (9->10) smoother + for idx in range(len(matches_list) - 1, -1, -1): + match = matches_list[idx] + new_run_count = str(runs_count_offset + int(match.group(1))) + text = text[0 : match.start(1)] + new_run_count + text[match.end(1) :] + + message["text"] = text + return message + + sarif_files = ( + file + for file in glob.iglob(os.path.join(output_dir, "*.sarif")) + if not empty(file) + ) + # exposed for testing since the order of files returned by glob is not guaranteed to be sorted + if sort_files: + sarif_files = list(sarif_files) + sarif_files.sort() + + runs_count = 0 + merged = {} + for sarif_file in sarif_files: + with open(sarif_file) as fp: + sarif = json.load(fp) + if "runs" not in sarif: + continue + + # start with the first file + if not merged: + merged = sarif + else: + # extract the run and append it to the merged output + for run in sarif["runs"]: + new_run = update_sarif_object(run, runs_count) + merged["runs"].append(new_run) + + runs_count += len(sarif["runs"]) + + with open(os.path.join(output_dir, "results-merged.sarif"), "w") as out: + json.dump(merged, out, indent=4, sort_keys=True) + + +def parse_bug_plist(filename): + """Returns the generator of bugs from a single .plist file.""" + + with open(filename, "rb") as fp: + content = plistlib.load(fp) + files = content.get("files") + for bug in content.get("diagnostics", []): + if len(files) <= int(bug["location"]["file"]): + logging.warning('Parsing bug from "%s" failed', filename) + continue + + yield { + "result": filename, + "bug_type": bug["type"], + "bug_category": bug["category"], + "bug_line": int(bug["location"]["line"]), + "bug_path_length": int(bug["location"]["col"]), + "bug_file": files[int(bug["location"]["file"])], + } + + +def parse_bug_html(filename): + """Parse out the bug information from HTML output.""" + + patterns = [ + re.compile(r"$"), + re.compile(r"$"), + re.compile(r"$"), + re.compile(r"$"), + re.compile(r"$"), + re.compile(r"$"), + re.compile(r"$"), + ] + endsign = re.compile(r"") + + bug = { + "report_file": filename, + "bug_function": "n/a", # compatibility with < clang-3.5 + "bug_category": "Other", + "bug_line": 0, + "bug_path_length": 1, + } + + with open(filename, encoding="utf-8") as handler: + for line in handler.readlines(): + # do not read the file further + if endsign.match(line): + break + # search for the right lines + for regex in patterns: + match = regex.match(line.strip()) + if match: + bug.update(match.groupdict()) + break + + encode_value(bug, "bug_line", int) + encode_value(bug, "bug_path_length", int) + + yield bug + + +def parse_crash(filename): + """Parse out the crash information from the report file.""" + + match = re.match(r"(.*)\.info\.txt", filename) + name = match.group(1) if match else None + with open(filename, mode="rb") as handler: + # this is a workaround to fix windows read '\r\n' as new lines. + lines = [line.decode().rstrip() for line in handler.readlines()] + return { + "source": lines[0], + "problem": lines[1], + "file": name, + "info": name + ".info.txt", + "stderr": name + ".stderr.txt", + } + + +def category_type_name(bug): + """Create a new bug attribute from bug by category and type. + + The result will be used as CSS class selector in the final report.""" + + def smash(key): + """Make value ready to be HTML attribute value.""" + + return bug.get(key, "").lower().replace(" ", "_").replace("'", "") + + return escape("bt_" + smash("bug_category") + "_" + smash("bug_type")) + + +def create_counters(): + """Create counters for bug statistics. + + Two entries are maintained: 'total' is an integer, represents the + number of bugs. The 'categories' is a two level categorisation of bug + counters. The first level is 'bug category' the second is 'bug type'. + Each entry in this classification is a dictionary of 'count', 'type' + and 'label'.""" + + def predicate(bug): + bug_category = bug["bug_category"] + bug_type = bug["bug_type"] + current_category = predicate.categories.get(bug_category, dict()) + current_type = current_category.get( + bug_type, + { + "bug_type": bug_type, + "bug_type_class": category_type_name(bug), + "bug_count": 0, + }, + ) + current_type.update({"bug_count": current_type["bug_count"] + 1}) + current_category.update({bug_type: current_type}) + predicate.categories.update({bug_category: current_category}) + predicate.total += 1 + + predicate.total = 0 + predicate.categories = dict() + return predicate + + +def prettify_bug(prefix, output_dir): + def predicate(bug): + """Make safe this values to embed into HTML.""" + + bug["bug_type_class"] = category_type_name(bug) + + encode_value(bug, "bug_file", lambda x: escape(chop(prefix, x))) + encode_value(bug, "bug_category", escape) + encode_value(bug, "bug_type", escape) + encode_value(bug, "report_file", lambda x: escape(chop(output_dir, x))) + return bug + + return predicate + + +def prettify_crash(prefix, output_dir): + def predicate(crash): + """Make safe this values to embed into HTML.""" + + encode_value(crash, "source", lambda x: escape(chop(prefix, x))) + encode_value(crash, "problem", escape) + encode_value(crash, "file", lambda x: escape(chop(output_dir, x))) + encode_value(crash, "info", lambda x: escape(chop(output_dir, x))) + encode_value(crash, "stderr", lambda x: escape(chop(output_dir, x))) + return crash + + return predicate + + +def copy_resource_files(output_dir): + """Copy the javascript and css files to the report directory.""" + + this_dir = os.path.dirname(os.path.realpath(__file__)) + for resource in os.listdir(os.path.join(this_dir, "resources")): + shutil.copy(os.path.join(this_dir, "resources", resource), output_dir) + + +def encode_value(container, key, encode): + """Run 'encode' on 'container[key]' value and update it.""" + + if key in container: + value = encode(container[key]) + container.update({key: value}) + + +def chop(prefix, filename): + """Create 'filename' from '/prefix/filename'""" + + return filename if not len(prefix) else os.path.relpath(filename, prefix) + + +def escape(text): + """Paranoid HTML escape method. (Python version independent)""" + + escape_table = { + "&": "&", + '"': """, + "'": "'", + ">": ">", + "<": "<", + } + return "".join(escape_table.get(c, c) for c in text) + + +def reindent(text, indent): + """Utility function to format html output and keep indentation.""" + + result = "" + for line in text.splitlines(): + if len(line.strip()): + result += " " * indent + line.split("|")[1] + os.linesep + return result + + +def comment(name, opts=dict()): + """Utility function to format meta information as comment.""" + + attributes = "" + for key, value in opts.items(): + attributes += ' {0}="{1}"'.format(key, value) + + return "{2}".format(name, attributes, os.linesep) + + +def commonprefix_from(filename): + """Create file prefix from a compilation database entries.""" + + with open(filename, "r") as handle: + return commonprefix(item["file"] for item in json.load(handle)) + + +def commonprefix(files): + """Fixed version of os.path.commonprefix. + + :param files: list of file names. + :return: the longest path prefix that is a prefix of all files.""" + result = None + for current in files: + if result is not None: + result = os.path.commonprefix([result, current]) + else: + result = current + + if result is None: + return "" + elif not os.path.isdir(result): + return os.path.dirname(result) + else: + return os.path.abspath(result) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/scanview.css b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/scanview.css new file mode 100755 index 0000000..cf8a5a6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/selectable.js b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/selectable.js new file mode 100755 index 0000000..c88ee78 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/selectable.js @@ -0,0 +1,45 @@ +function SetDisplay(RowClass, DisplayVal) { + var Rows = document.getElementsByTagName("tr"); + for (var i = 0; i < Rows.length; ++i) { + if (Rows[i].className == RowClass) { + Rows[i].style.display = DisplayVal; + } + } +} + +function CopyCheckedStateToCheckButtons(SummaryCheckButton) { + var Inputs = document.getElementsByTagName("input"); + for (var i = 0; i < Inputs.length; ++i) { + if (Inputs[i].type == "checkbox") { + if (Inputs[i] != SummaryCheckButton) { + Inputs[i].checked = SummaryCheckButton.checked; + Inputs[i].onclick(); + } + } + } +} + +function returnObjById(id) { + if (document.getElementById) + var returnVar = document.getElementById(id); + else if (document.all) + var returnVar = document.all[id]; + else if (document.layers) + var returnVar = document.layers[id]; + return returnVar; +} + +var NumUnchecked = 0; + +function ToggleDisplay(CheckButton, ClassName) { + if (CheckButton.checked) { + SetDisplay(ClassName, ""); + if (--NumUnchecked == 0) { + returnObjById("AllBugsCheck").checked = true; + } + } else { + SetDisplay(ClassName, "none"); + NumUnchecked++; + returnObjById("AllBugsCheck").checked = false; + } +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/sorttable.js b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/sorttable.js new file mode 100755 index 0000000..b98f012 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/lib/libscanbuild/resources/sorttable.js @@ -0,0 +1,535 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + +var stIsIE = /*@cc_on!@*/ false; + +sorttable = { + init : function() { + // quit if this function has already been called + if (arguments.callee.done) + return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) + clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) + return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + }, + + makeSortable : function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the, table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) + table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) + return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i = 0; i < table.rows.length; i++) { + if (table.rows[i].className.search(/\bsortbottom\b/) != -1) { + sortbottomrows[sortbottomrows.length] = table.rows[i]; + } + } + if (sortbottomrows) { + if (table.tFoot == null) { + // table doesn't have a tfoot. Create one. + tfo = document.createElement('tfoot'); + table.appendChild(tfo); + } + for (var i = 0; i < sortbottomrows.length; i++) { + tfo.appendChild(sortbottomrows[i]); + } + delete sortbottomrows; + } + + // work through each column and calculate its type + headrow = table.tHead.rows[0].cells; + for (var i = 0; i < headrow.length; i++) { + // manually override the type with a sorttable_type attribute + if (!headrow[i].className.match( + /\bsorttable_nosort\b/)) { // skip this col + mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/); + if (mtch) { + override = mtch[1]; + } + if (mtch && typeof sorttable["sort_" + override] == 'function') { + headrow[i].sorttable_sortfunction = sorttable["sort_" + override]; + } else { + headrow[i].sorttable_sortfunction = sorttable.guessType(table, i); + } + // make it clickable to sort + headrow[i].sorttable_columnindex = i; + headrow[i].sorttable_tbody = table.tBodies[0]; + dean_addEvent(headrow[i], "click", function(e) { + if (this.className.search(/\bsorttable_sorted\b/) != -1) { + // if we're already sorted by this column, just + // reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted', + 'sorttable_sorted_reverse'); + this.removeChild(document.getElementById('sorttable_sortfwdind')); + sortrevind = document.createElement('span'); + sortrevind.id = "sorttable_sortrevind"; + sortrevind.innerHTML = stIsIE + ? ' 5' + : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE + ? ' 6' + : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = + cell.className.replace('sorttable_sorted_reverse', ''); + cell.className = cell.className.replace('sorttable_sorted', ''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { + sortfwdind.parentNode.removeChild(sortfwdind); + } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { + sortrevind.parentNode.removeChild(sortrevind); + } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = + stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j = 0; j < rows.length; j++) { + row_array[row_array.length] = + [ sorttable.getInnerText(rows[j].cells[col]), rows[j] ]; + } + /* If you want a stable sort, uncomment the following line */ + sorttable.shaker_sort(row_array, this.sorttable_sortfunction); + /* and comment out this one */ + // row_array.sort(this.sorttable_sortfunction); + + tb = this.sorttable_tbody; + for (var j = 0; j < row_array.length; j++) { + tb.appendChild(row_array[j][1]); + } + + delete row_array; + }); + } + } + }, + + guessType : function(table, column) { + // guess the type of a column based on its first non-blank row + sortfn = sorttable.sort_alpha; + for (var i = 0; i < table.tBodies[0].rows.length; i++) { + text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]); + if (text != '') { + if (text.match(/^-?[ο½£$ο½€]?[\d,.]+%?$/)) { + return sorttable.sort_numeric; + } + // check for a date: dd/mm/yyyy or dd/mm/yy + // can have / or . or - as separator + // can be mm/dd as well + possdate = text.match(sorttable.DATE_RE) + if (possdate) { + // looks like a date + first = parseInt(possdate[1]); + second = parseInt(possdate[2]); + if (first > 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText : function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse : function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i = 0; i < tbody.rows.length; i++) { + newrows[newrows.length] = tbody.rows[i]; + } + for (var i = newrows.length - 1; i >= 0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric : function(a, b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g, '')); + if (isNaN(aa)) + aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g, '')); + if (isNaN(bb)) + bb = 0; + return aa - bb; + }, + sort_alpha : function(a, b) { + if (a[0] == b[0]) + return 0; + if (a[0] < b[0]) + return -1; + return 1; + }, + sort_ddmm : function(a, b) { + mtch = a[0].match(sorttable.DATE_RE); + y = mtch[3]; + m = mtch[2]; + d = mtch[1]; + if (m.length == 1) + m = '0' + m; + if (d.length == 1) + d = '0' + d; + dt1 = y + m + d; + mtch = b[0].match(sorttable.DATE_RE); + y = mtch[3]; + m = mtch[2]; + d = mtch[1]; + if (m.length == 1) + m = '0' + m; + if (d.length == 1) + d = '0' + d; + dt2 = y + m + d; + if (dt1 == dt2) + return 0; + if (dt1 < dt2) + return -1; + return 1; + }, + sort_mmdd : function(a, b) { + mtch = a[0].match(sorttable.DATE_RE); + y = mtch[3]; + d = mtch[2]; + m = mtch[1]; + if (m.length == 1) + m = '0' + m; + if (d.length == 1) + d = '0' + d; + dt1 = y + m + d; + mtch = b[0].match(sorttable.DATE_RE); + y = mtch[3]; + d = mtch[2]; + m = mtch[1]; + if (m.length == 1) + m = '0' + m; + if (d.length == 1) + d = '0' + d; + dt2 = y + m + d; + if (dt1 == dt2) + return 0; + if (dt1 < dt2) + return -1; + return 1; + }, + + shaker_sort : function(list, comp_func) { + // A stable sort function to allow multi-level sorting of data + // see: http://en.wikipedia.org/wiki/Cocktail_sort + // thanks to Joseph Nahmias + var b = 0; + var t = list.length - 1; + var swap = true; + + while (swap) { + swap = false; + for (var i = b; i < t; ++i) { + if (comp_func(list[i], list[i + 1]) > 0) { + var q = list[i]; + list[i] = list[i + 1]; + list[i + 1] = q; + swap = true; + } + } // for + t--; + + if (!swap) + break; + + for (var i = t; i > b; --i) { + if (comp_func(list[i], list[i - 1]) < 0) { + var q = list[i]; + list[i] = list[i - 1]; + list[i - 1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write(" + + +
+ + + + + +""".format( + os.path.basename(self.filename) + ), + file=self.stream, + ) + self.render_source_lines(self.source_stream, line_remarks) + + print( + """ + +
Line +Hotness +Optimization +Source +Inline Context +
+ +""", + file=self.stream, + ) + + +class IndexRenderer: + def __init__( + self, output_dir, should_display_hotness, max_hottest_remarks_on_index + ): + self.stream = io.open( + os.path.join(output_dir, "index.html"), "w", encoding="utf-8" + ) + self.should_display_hotness = should_display_hotness + self.max_hottest_remarks_on_index = max_hottest_remarks_on_index + + def render_entry(self, r, odd): + escaped_name = html.escape(r.DemangledFunctionName) + print( + """ + +{r.DebugLocString} +{r.RelativeHotness} +{escaped_name} +{r.PassWithDiffPrefix} +""".format( + **locals() + ), + file=self.stream, + ) + + def render(self, all_remarks): + print( + """ + + + + + + +
+ + + + + + +""", + file=self.stream, + ) + + max_entries = None + if self.should_display_hotness: + max_entries = self.max_hottest_remarks_on_index + + for i, remark in enumerate(all_remarks[:max_entries]): + if not suppress(remark): + self.render_entry(remark, i % 2) + print( + """ +
Source LocationHotnessFunctionPass
+ +""", + file=self.stream, + ) + + +def _render_file(source_dir, output_dir, ctx, no_highlight, entry, filter_): + global context + context = ctx + filename, remarks = entry + SourceFileRenderer(source_dir, output_dir, filename, no_highlight).render(remarks) + + +def map_remarks(all_remarks): + # Set up a map between function names and their source location for + # function where inlining happened + for remark in optrecord.itervalues(all_remarks): + if ( + isinstance(remark, optrecord.Passed) + and remark.Pass == "inline" + and remark.Name == "Inlined" + ): + for arg in remark.Args: + arg_dict = dict(list(arg)) + caller = arg_dict.get("Caller") + if caller: + try: + context.caller_loc[caller] = arg_dict["DebugLoc"] + except KeyError: + pass + + +def generate_report( + all_remarks, + file_remarks, + source_dir, + output_dir, + no_highlight, + should_display_hotness, + max_hottest_remarks_on_index, + num_jobs, + should_print_progress, +): + try: + os.makedirs(output_dir) + except OSError as e: + if e.errno == errno.EEXIST and os.path.isdir(output_dir): + pass + else: + raise + + if should_print_progress: + print("Rendering index page...") + if should_display_hotness: + sorted_remarks = sorted( + optrecord.itervalues(all_remarks), + key=lambda r: ( + r.Hotness, + r.File, + r.Line, + r.Column, + r.PassWithDiffPrefix, + r.yaml_tag, + r.Function, + ), + reverse=True, + ) + else: + sorted_remarks = sorted( + optrecord.itervalues(all_remarks), + key=lambda r: ( + r.File, + r.Line, + r.Column, + r.PassWithDiffPrefix, + r.yaml_tag, + r.Function, + ), + ) + IndexRenderer( + output_dir, should_display_hotness, max_hottest_remarks_on_index + ).render(sorted_remarks) + + shutil.copy( + os.path.join(os.path.dirname(os.path.realpath(__file__)), "style.css"), + output_dir, + ) + + _render_file_bound = functools.partial( + _render_file, source_dir, output_dir, context, no_highlight + ) + if should_print_progress: + print("Rendering HTML files...") + optpmap.pmap( + _render_file_bound, file_remarks.items(), num_jobs, should_print_progress + ) + + +def main(): + parser = argparse.ArgumentParser(description=desc) + parser.add_argument( + "yaml_dirs_or_files", + nargs="+", + help="List of optimization record files or directories searched " + "for optimization record files.", + ) + parser.add_argument( + "--output-dir", + "-o", + default="html", + help="Path to a directory where generated HTML files will be output. " + "If the directory does not already exist, it will be created. " + '"%(default)s" by default.', + ) + parser.add_argument( + "--jobs", + "-j", + default=None, + type=int, + help="Max job count (defaults to %(default)s, the current CPU count)", + ) + parser.add_argument("--source-dir", "-s", default="", help="set source directory") + parser.add_argument( + "--no-progress-indicator", + "-n", + action="store_true", + default=False, + help="Do not display any indicator of how many YAML files were read " + "or rendered into HTML.", + ) + parser.add_argument( + "--max-hottest-remarks-on-index", + default=1000, + type=int, + help="Maximum number of the hottest remarks to appear on the index page", + ) + parser.add_argument( + "--no-highlight", + action="store_true", + default=False, + help="Do not use a syntax highlighter when rendering the source code", + ) + parser.add_argument( + "--demangler", + help="Set the demangler to be used (defaults to %s)" + % optrecord.Remark.default_demangler, + ) + + parser.add_argument( + "--filter", + default="", + help="Only display remarks from passes matching filter expression", + ) + + # Do not make this a global variable. Values needed to be propagated through + # to individual classes and functions to be portable with multiprocessing across + # Windows and non-Windows. + args = parser.parse_args() + + print_progress = not args.no_progress_indicator + if args.demangler: + optrecord.Remark.set_demangler(args.demangler) + + files = optrecord.find_opt_files(*args.yaml_dirs_or_files) + if not files: + parser.error("No *.opt.yaml files found") + sys.exit(1) + + all_remarks, file_remarks, should_display_hotness = optrecord.gather_results( + files, args.jobs, print_progress, args.filter + ) + + map_remarks(all_remarks) + + generate_report( + all_remarks, + file_remarks, + args.source_dir, + args.output_dir, + args.no_highlight, + should_display_hotness, + args.max_hottest_remarks_on_index, + args.jobs, + print_progress, + ) + + +if __name__ == "__main__": + main() diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/optpmap.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/optpmap.py new file mode 100755 index 0000000..28c608d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/optpmap.py @@ -0,0 +1,63 @@ +import sys +import multiprocessing + + +_current = None +_total = None + + +def _init(current, total): + global _current + global _total + _current = current + _total = total + + +def _wrapped_func(func_and_args): + func, argument, should_print_progress, filter_ = func_and_args + + if should_print_progress: + with _current.get_lock(): + _current.value += 1 + sys.stdout.write("\r\t{} of {}".format(_current.value, _total.value)) + sys.stdout.flush() + + return func(argument, filter_) + + +def pmap( + func, iterable, processes, should_print_progress, filter_=None, *args, **kwargs +): + """ + A parallel map function that reports on its progress. + + Applies `func` to every item of `iterable` and return a list of the + results. If `processes` is greater than one, a process pool is used to run + the functions in parallel. `should_print_progress` is a boolean value that + indicates whether a string 'N of M' should be printed to indicate how many + of the functions have finished being run. + """ + global _current + global _total + _current = multiprocessing.Value("i", 0) + _total = multiprocessing.Value("i", len(iterable)) + + func_and_args = [(func, arg, should_print_progress, filter_) for arg in iterable] + if processes == 1: + result = list(map(_wrapped_func, func_and_args, *args, **kwargs)) + else: + pool = multiprocessing.Pool( + initializer=_init, + initargs=( + _current, + _total, + ), + processes=processes, + ) + result = pool.map(_wrapped_func, func_and_args, *args, **kwargs) + pool.close() + pool.join() + + if should_print_progress: + sys.stdout.write("\r") + return result diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/optrecord.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/optrecord.py new file mode 100755 index 0000000..8014204 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/optrecord.py @@ -0,0 +1,366 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import io +import yaml + +# Try to use the C parser. +try: + from yaml import CLoader as Loader +except ImportError: + print("For faster parsing, you may want to install libYAML for PyYAML") + from yaml import Loader + +import html +from collections import defaultdict +import fnmatch +import functools +from multiprocessing import Lock +import os, os.path +import subprocess + +try: + # The previously builtin function `intern()` was moved + # to the `sys` module in Python 3. + from sys import intern +except: + pass + +import re + +import optpmap + +try: + dict.iteritems +except AttributeError: + # Python 3 + def itervalues(d): + return iter(d.values()) + + def iteritems(d): + return iter(d.items()) + +else: + # Python 2 + def itervalues(d): + return d.itervalues() + + def iteritems(d): + return d.iteritems() + + +def html_file_name(filename): + return filename.replace("/", "_").replace("#", "_") + ".html" + + +def make_link(File, Line): + return '"{}#L{}"'.format(html_file_name(File), Line) + + +class Remark(yaml.YAMLObject): + # Work-around for http://pyyaml.org/ticket/154. + yaml_loader = Loader + + default_demangler = "c++filt -n" + demangler_proc = None + demangler_lock = Lock() + + @classmethod + def set_demangler(cls, demangler): + cls.demangler_proc = subprocess.Popen( + demangler.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE + ) + + @classmethod + def demangle(cls, name): + with cls.demangler_lock: + if not cls.demangler_proc: + cls.set_demangler(cls.default_demangler) + cls.demangler_proc.stdin.write((name + "\n").encode("utf-8")) + cls.demangler_proc.stdin.flush() + return cls.demangler_proc.stdout.readline().rstrip().decode("utf-8") + + # Intern all strings since we have lot of duplication across filenames, + # remark text. + # + # Change Args from a list of dicts to a tuple of tuples. This saves + # memory in two ways. One, a small tuple is significantly smaller than a + # small dict. Two, using tuple instead of list allows Args to be directly + # used as part of the key (in Python only immutable types are hashable). + def _reduce_memory(self): + self.Pass = intern(self.Pass) + self.Name = intern(self.Name) + try: + # Can't intern unicode strings. + self.Function = intern(self.Function) + except: + pass + + def _reduce_memory_dict(old_dict): + new_dict = dict() + for (k, v) in iteritems(old_dict): + if type(k) is str: + k = intern(k) + + if type(v) is str: + v = intern(v) + elif type(v) is dict: + # This handles [{'Caller': ..., 'DebugLoc': { 'File': ... }}] + v = _reduce_memory_dict(v) + new_dict[k] = v + return tuple(new_dict.items()) + + self.Args = tuple([_reduce_memory_dict(arg_dict) for arg_dict in self.Args]) + + # The inverse operation of the dictonary-related memory optimization in + # _reduce_memory_dict. E.g. + # (('DebugLoc', (('File', ...) ... ))) -> [{'DebugLoc': {'File': ...} ....}] + def recover_yaml_structure(self): + def tuple_to_dict(t): + d = dict() + for (k, v) in t: + if type(v) is tuple: + v = tuple_to_dict(v) + d[k] = v + return d + + self.Args = [tuple_to_dict(arg_tuple) for arg_tuple in self.Args] + + def canonicalize(self): + if not hasattr(self, "Hotness"): + self.Hotness = 0 + if not hasattr(self, "Args"): + self.Args = [] + self._reduce_memory() + + @property + def File(self): + return self.DebugLoc["File"] + + @property + def Line(self): + return int(self.DebugLoc["Line"]) + + @property + def Column(self): + return self.DebugLoc["Column"] + + @property + def DebugLocString(self): + return "{}:{}:{}".format(self.File, self.Line, self.Column) + + @property + def DemangledFunctionName(self): + return self.demangle(self.Function) + + @property + def Link(self): + return make_link(self.File, self.Line) + + def getArgString(self, mapping): + mapping = dict(list(mapping)) + dl = mapping.get("DebugLoc") + if dl: + del mapping["DebugLoc"] + + assert len(mapping) == 1 + (key, value) = list(mapping.items())[0] + + if key == "Caller" or key == "Callee" or key == "DirectCallee": + value = html.escape(self.demangle(value)) + + if dl and key != "Caller": + dl_dict = dict(list(dl)) + return "{}".format( + make_link(dl_dict["File"], dl_dict["Line"]), value + ) + else: + return value + + # Return a cached dictionary for the arguments. The key for each entry is + # the argument key (e.g. 'Callee' for inlining remarks. The value is a + # list containing the value (e.g. for 'Callee' the function) and + # optionally a DebugLoc. + def getArgDict(self): + if hasattr(self, "ArgDict"): + return self.ArgDict + self.ArgDict = {} + for arg in self.Args: + if len(arg) == 2: + if arg[0][0] == "DebugLoc": + dbgidx = 0 + else: + assert arg[1][0] == "DebugLoc" + dbgidx = 1 + + key = arg[1 - dbgidx][0] + entry = (arg[1 - dbgidx][1], arg[dbgidx][1]) + else: + arg = arg[0] + key = arg[0] + entry = (arg[1],) + + self.ArgDict[key] = entry + return self.ArgDict + + def getDiffPrefix(self): + if hasattr(self, "Added"): + if self.Added: + return "+" + else: + return "-" + return "" + + @property + def PassWithDiffPrefix(self): + return self.getDiffPrefix() + self.Pass + + @property + def message(self): + # Args is a list of mappings (dictionaries) + values = [self.getArgString(mapping) for mapping in self.Args] + return "".join(values) + + @property + def RelativeHotness(self): + if self.max_hotness: + return "{0:.2f}%".format(self.Hotness * 100.0 / self.max_hotness) + else: + return "" + + @property + def key(self): + return ( + self.__class__, + self.PassWithDiffPrefix, + self.Name, + self.File, + self.Line, + self.Column, + self.Function, + self.Args, + ) + + def __hash__(self): + return hash(self.key) + + def __eq__(self, other): + return self.key == other.key + + def __repr__(self): + return str(self.key) + + +class Analysis(Remark): + yaml_tag = "!Analysis" + + @property + def color(self): + return "white" + + +class AnalysisFPCommute(Analysis): + yaml_tag = "!AnalysisFPCommute" + + +class AnalysisAliasing(Analysis): + yaml_tag = "!AnalysisAliasing" + + +class Passed(Remark): + yaml_tag = "!Passed" + + @property + def color(self): + return "green" + + +class Missed(Remark): + yaml_tag = "!Missed" + + @property + def color(self): + return "red" + + +class Failure(Missed): + yaml_tag = "!Failure" + + +def get_remarks(input_file, filter_=None): + max_hotness = 0 + all_remarks = dict() + file_remarks = defaultdict(functools.partial(defaultdict, list)) + + with io.open(input_file, encoding="utf-8") as f: + docs = yaml.load_all(f, Loader=Loader) + + filter_e = None + if filter_: + filter_e = re.compile(filter_) + for remark in docs: + remark.canonicalize() + # Avoid remarks withoug debug location or if they are duplicated + if not hasattr(remark, "DebugLoc") or remark.key in all_remarks: + continue + + if filter_e and not filter_e.search(remark.Pass): + continue + + all_remarks[remark.key] = remark + + file_remarks[remark.File][remark.Line].append(remark) + + # If we're reading a back a diff yaml file, max_hotness is already + # captured which may actually be less than the max hotness found + # in the file. + if hasattr(remark, "max_hotness"): + max_hotness = remark.max_hotness + max_hotness = max(max_hotness, remark.Hotness) + + return max_hotness, all_remarks, file_remarks + + +def gather_results(filenames, num_jobs, should_print_progress, filter_=None): + if should_print_progress: + print("Reading YAML files...") + remarks = optpmap.pmap( + get_remarks, filenames, num_jobs, should_print_progress, filter_ + ) + max_hotness = max(entry[0] for entry in remarks) + + def merge_file_remarks(file_remarks_job, all_remarks, merged): + for filename, d in iteritems(file_remarks_job): + for line, remarks in iteritems(d): + for remark in remarks: + # Bring max_hotness into the remarks so that + # RelativeHotness does not depend on an external global. + remark.max_hotness = max_hotness + if remark.key not in all_remarks: + merged[filename][line].append(remark) + + all_remarks = dict() + file_remarks = defaultdict(functools.partial(defaultdict, list)) + for _, all_remarks_job, file_remarks_job in remarks: + merge_file_remarks(file_remarks_job, all_remarks, file_remarks) + all_remarks.update(all_remarks_job) + + return all_remarks, file_remarks, max_hotness != 0 + + +def find_opt_files(*dirs_or_files): + all = [] + for dir_or_file in dirs_or_files: + if os.path.isfile(dir_or_file): + all.append(dir_or_file) + else: + for dir, subdirs, files in os.walk(dir_or_file): + # Exclude mounted directories and symlinks (os.walk default). + subdirs[:] = [ + d for d in subdirs if not os.path.ismount(os.path.join(dir, d)) + ] + for file in files: + if fnmatch.fnmatch(file, "*.opt.yaml*"): + all.append(os.path.join(dir, file)) + return all diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/style.css b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/style.css new file mode 100755 index 0000000..550c7e1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/opt-viewer/style.css @@ -0,0 +1,218 @@ +.source { + table-layout: fixed; + width: 100%; + white-space: nowrap; +} +.source td { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.red { + background-color: #ffd0d0; +} +.cyan { + background-color: cyan; +} +body { + font-family: -apple-system, sans-serif; +} +pre { + margin-top: 0px !important; + margin-bottom: 0px !important; +} +.source-name-title { + padding: 5px 10px; + border-bottom: 1px solid #dbdbdb; + background-color: #eee; + line-height: 35px; +} +.centered { + display: table; + margin-left: left; + margin-right: auto; + border: 1px solid #dbdbdb; + border-radius: 3px; +} +.expansion-view { + background-color: rgba(0, 0, 0, 0); + margin-left: 0px; + margin-top: 5px; + margin-right: 5px; + margin-bottom: 5px; + border: 1px solid #dbdbdb; + border-radius: 3px; +} +table { + border-collapse: collapse; +} +.light-row { + background: #ffffff; + border: 1px solid #dbdbdb; +} +.column-entry { + text-align: right; +} +.column-entry-left { + text-align: left; +} +.column-entry-white { + text-align: right; + background-color: #ffffff; +} +.column-entry-red { + text-align: right; + background-color: #ffd0d0; +} +.column-entry-green { + text-align: right; + background-color: #d0ffd0; +} +.column-entry-yellow { + text-align: left; + background-color: #ffe1a6; +} +.column-entry-0 { + background-color: #ffffff; +} +.column-entry-1 { + background-color: #eeeeee; +} +.line-number { + text-align: right; + color: #aaa; +} +.covered-line { + text-align: right; + color: #0080ff; +} +.uncovered-line { + text-align: right; + color: #ff3300; +} +.tooltip { + position: relative; + display: inline; + background-color: #b3e6ff; + text-decoration: none; +} +.tooltip span.tooltip-content { + position: absolute; + width: 100px; + margin-left: -50px; + color: #FFFFFF; + background: #000000; + height: 30px; + line-height: 30px; + text-align: center; + visibility: hidden; + border-radius: 6px; +} +.tooltip span.tooltip-content:after { + content: ''; + position: absolute; + top: 100%; + left: 50%; + margin-left: -8px; + width: 0; height: 0; + border-top: 8px solid #000000; + border-right: 8px solid transparent; + border-left: 8px solid transparent; +} +:hover.tooltip span.tooltip-content { + visibility: visible; + opacity: 0.8; + bottom: 30px; + left: 50%; + z-index: 999; +} +th, td { + vertical-align: top; + padding: 2px 5px; + border-collapse: collapse; + border-right: solid 1px #eee; + border-left: solid 1px #eee; +} +td:first-child { + border-left: none; +} +td:last-child { + border-right: none; +} +.expanded { + background-color: #f2f2f2; + padding-top: 5px; + padding-left: 5px; +} +.col-left { + float: left; + margin-bottom: -99999px; + padding-bottom: 99999px; +} + +/* Generated with pygmentize -S colorful -f html >> style.css */ + +.hll { background-color: #ffffcc } +.c { color: #888888 } /* Comment */ +.err { color: #FF0000; background-color: #FFAAAA } /* Error */ +.k { color: #008800; font-weight: bold } /* Keyword */ +.o { color: #333333 } /* Operator */ +.ch { color: #888888 } /* Comment.Hashbang */ +.cm { color: #888888 } /* Comment.Multiline */ +.cp { color: #557799 } /* Comment.Preproc */ +.cpf { color: #888888 } /* Comment.PreprocFile */ +.c1 { color: #888888 } /* Comment.Single */ +.cs { color: #cc0000; font-weight: bold } /* Comment.Special */ +.gd { color: #A00000 } /* Generic.Deleted */ +.ge { font-style: italic } /* Generic.Emph */ +.gr { color: #FF0000 } /* Generic.Error */ +.gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.gi { color: #00A000 } /* Generic.Inserted */ +.go { color: #888888 } /* Generic.Output */ +.gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ +.gs { font-weight: bold } /* Generic.Strong */ +.gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.gt { color: #0044DD } /* Generic.Traceback */ +.kc { color: #008800; font-weight: bold } /* Keyword.Constant */ +.kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ +.kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ +.kp { color: #003388; font-weight: bold } /* Keyword.Pseudo */ +.kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ +.kt { color: #333399; font-weight: bold } /* Keyword.Type */ +.m { color: #6600EE; font-weight: bold } /* Literal.Number */ +.s { background-color: #fff0f0 } /* Literal.String */ +.na { color: #0000CC } /* Name.Attribute */ +.nb { color: #007020 } /* Name.Builtin */ +.nc { color: #BB0066; font-weight: bold } /* Name.Class */ +.no { color: #003366; font-weight: bold } /* Name.Constant */ +.nd { color: #555555; font-weight: bold } /* Name.Decorator */ +.ni { color: #880000; font-weight: bold } /* Name.Entity */ +.ne { color: #FF0000; font-weight: bold } /* Name.Exception */ +.nf { color: #0066BB; font-weight: bold } /* Name.Function */ +.nl { color: #997700; font-weight: bold } /* Name.Label */ +.nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ +.nt { color: #007700 } /* Name.Tag */ +.nv { color: #996633 } /* Name.Variable */ +.ow { color: #000000; font-weight: bold } /* Operator.Word */ +.w { color: #bbbbbb } /* Text.Whitespace */ +.mb { color: #6600EE; font-weight: bold } /* Literal.Number.Bin */ +.mf { color: #6600EE; font-weight: bold } /* Literal.Number.Float */ +.mh { color: #005588; font-weight: bold } /* Literal.Number.Hex */ +.mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ +.mo { color: #4400EE; font-weight: bold } /* Literal.Number.Oct */ +.sb { background-color: #fff0f0 } /* Literal.String.Backtick */ +.sc { color: #0044DD } /* Literal.String.Char */ +.sd { color: #DD4422 } /* Literal.String.Doc */ +.s2 { background-color: #fff0f0 } /* Literal.String.Double */ +.se { color: #666666; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */ +.sh { background-color: #fff0f0 } /* Literal.String.Heredoc */ +.si { background-color: #eeeeee } /* Literal.String.Interpol */ +.sx { color: #DD2200; background-color: #fff0f0 } /* Literal.String.Other */ +.sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */ +.s1 { background-color: #fff0f0 } /* Literal.String.Single */ +.ss { color: #AA6600 } /* Literal.String.Symbol */ +.bp { color: #007020 } /* Name.Builtin.Pseudo */ +.vc { color: #336699 } /* Name.Variable.Class */ +.vg { color: #dd7700; font-weight: bold } /* Name.Variable.Global */ +.vi { color: #3333BB } /* Name.Variable.Instance */ +.il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-build/scanview.css b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-build/scanview.css new file mode 100755 index 0000000..cf8a5a6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-build/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-build/sorttable.js b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-build/sorttable.js new file mode 100755 index 0000000..e608daa --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-build/sorttable.js @@ -0,0 +1,512 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("""", + ) +) + +# Insert additional columns. +kReportReplacements.append((re.compile(""), "")) + +# Insert report bug and open file links. +kReportReplacements.append( + ( + re.compile(''), + ( + 'Report Bug' + + 'Open File' + ), + ) +) + +kReportReplacements.append( + ( + re.compile(""), + '

Summary > Report %(report)s

', + ) +) + +kReportReplacements.append( + ( + re.compile(""), + 'Report Bug', + ) +) + +# Insert report crashes link. + +# Disabled for the time being until we decide exactly when this should +# be enabled. Also the radar reporter needs to be fixed to report +# multiple files. + +# kReportReplacements.append((re.compile(''), +# '
These files will automatically be attached to ' + +# 'reports filed here: Report Crashes.')) + +### +# Other simple parameters + +kShare = posixpath.join(posixpath.dirname(__file__), "../share/scan-view") +kConfigPath = os.path.expanduser("~/.scanview.cfg") + +### + +__version__ = "0.1" + +__all__ = ["create_server"] + + +class ReporterThread(threading.Thread): + def __init__(self, report, reporter, parameters, server): + threading.Thread.__init__(self) + self.report = report + self.server = server + self.reporter = reporter + self.parameters = parameters + self.success = False + self.status = None + + def run(self): + result = None + try: + if self.server.options.debug: + print("%s: SERVER: submitting bug." % (sys.argv[0],), file=sys.stderr) + self.status = self.reporter.fileReport(self.report, self.parameters) + self.success = True + time.sleep(3) + if self.server.options.debug: + print( + "%s: SERVER: submission complete." % (sys.argv[0],), file=sys.stderr + ) + except Reporter.ReportFailure as e: + self.status = e.value + except Exception as e: + s = StringIO() + import traceback + + print("Unhandled Exception
", file=s)
+            traceback.print_exc(file=s)
+            print("
", file=s) + self.status = s.getvalue() + + +class ScanViewServer(HTTPServer): + def __init__(self, address, handler, root, reporters, options): + HTTPServer.__init__(self, address, handler) + self.root = root + self.reporters = reporters + self.options = options + self.halted = False + self.config = None + self.load_config() + + def load_config(self): + self.config = configparser.RawConfigParser() + + # Add defaults + self.config.add_section("ScanView") + for r in self.reporters: + self.config.add_section(r.getName()) + for p in r.getParameters(): + if p.saveConfigValue(): + self.config.set(r.getName(), p.getName(), "") + + # Ignore parse errors + try: + self.config.read([kConfigPath]) + except: + pass + + # Save on exit + import atexit + + atexit.register(lambda: self.save_config()) + + def save_config(self): + # Ignore errors (only called on exit). + try: + f = open(kConfigPath, "w") + self.config.write(f) + f.close() + except: + pass + + def halt(self): + self.halted = True + if self.options.debug: + print("%s: SERVER: halting." % (sys.argv[0],), file=sys.stderr) + + def serve_forever(self): + while not self.halted: + if self.options.debug > 1: + print("%s: SERVER: waiting..." % (sys.argv[0],), file=sys.stderr) + try: + self.handle_request() + except OSError as e: + print("OSError", e.errno) + + def finish_request(self, request, client_address): + if self.options.autoReload: + import ScanView + + self.RequestHandlerClass = reload(ScanView).ScanViewRequestHandler + HTTPServer.finish_request(self, request, client_address) + + def handle_error(self, request, client_address): + # Ignore socket errors + info = sys.exc_info() + if info and isinstance(info[1], socket.error): + if self.options.debug > 1: + print( + "%s: SERVER: ignored socket error." % (sys.argv[0],), + file=sys.stderr, + ) + return + HTTPServer.handle_error(self, request, client_address) + + +# Borrowed from Quixote, with simplifications. +def parse_query(qs, fields=None): + if fields is None: + fields = {} + for chunk in (_f for _f in qs.split("&") if _f): + if "=" not in chunk: + name = chunk + value = "" + else: + name, value = chunk.split("=", 1) + name = unquote(name.replace("+", " ")) + value = unquote(value.replace("+", " ")) + item = fields.get(name) + if item is None: + fields[name] = [value] + else: + item.append(value) + return fields + + +class ScanViewRequestHandler(SimpleHTTPRequestHandler): + server_version = "ScanViewServer/" + __version__ + dynamic_mtime = time.time() + + def do_HEAD(self): + try: + SimpleHTTPRequestHandler.do_HEAD(self) + except Exception as e: + self.handle_exception(e) + + def do_GET(self): + try: + SimpleHTTPRequestHandler.do_GET(self) + except Exception as e: + self.handle_exception(e) + + def do_POST(self): + """Serve a POST request.""" + try: + length = self.headers.getheader("content-length") or "0" + try: + length = int(length) + except: + length = 0 + content = self.rfile.read(length) + fields = parse_query(content) + f = self.send_head(fields) + if f: + self.copyfile(f, self.wfile) + f.close() + except Exception as e: + self.handle_exception(e) + + def log_message(self, format, *args): + if self.server.options.debug: + sys.stderr.write( + "%s: SERVER: %s - - [%s] %s\n" + % ( + sys.argv[0], + self.address_string(), + self.log_date_time_string(), + format % args, + ) + ) + + def load_report(self, report): + path = os.path.join(self.server.root, "report-%s.html" % report) + data = open(path).read() + keys = {} + for item in kBugKeyValueRE.finditer(data): + k, v = item.groups() + keys[k] = v + return keys + + def load_crashes(self): + path = posixpath.join(self.server.root, "index.html") + data = open(path).read() + problems = [] + for item in kReportCrashEntryRE.finditer(data): + fieldData = item.group(1) + fields = dict( + [i.groups() for i in kReportCrashEntryKeyValueRE.finditer(fieldData)] + ) + problems.append(fields) + return problems + + def handle_exception(self, exc): + import traceback + + s = StringIO() + print("INTERNAL ERROR\n", file=s) + traceback.print_exc(file=s) + f = self.send_string(s.getvalue(), "text/plain") + if f: + self.copyfile(f, self.wfile) + f.close() + + def get_scalar_field(self, name): + if name in self.fields: + return self.fields[name][0] + else: + return None + + def submit_bug(self, c): + title = self.get_scalar_field("title") + description = self.get_scalar_field("description") + report = self.get_scalar_field("report") + reporterIndex = self.get_scalar_field("reporter") + files = [] + for fileID in self.fields.get("files", []): + try: + i = int(fileID) + except: + i = None + if i is None or i < 0 or i >= len(c.files): + return (False, "Invalid file ID") + files.append(c.files[i]) + + if not title: + return (False, "Missing title.") + if not description: + return (False, "Missing description.") + try: + reporterIndex = int(reporterIndex) + except: + return (False, "Invalid report method.") + + # Get the reporter and parameters. + reporter = self.server.reporters[reporterIndex] + parameters = {} + for o in reporter.getParameters(): + name = "%s_%s" % (reporter.getName(), o.getName()) + if name not in self.fields: + return ( + False, + 'Missing field "%s" for %s report method.' + % (name, reporter.getName()), + ) + parameters[o.getName()] = self.get_scalar_field(name) + + # Update config defaults. + if report != "None": + self.server.config.set("ScanView", "reporter", reporterIndex) + for o in reporter.getParameters(): + if o.saveConfigValue(): + name = o.getName() + self.server.config.set(reporter.getName(), name, parameters[name]) + + # Create the report. + bug = Reporter.BugReport(title, description, files) + + # Kick off a reporting thread. + t = ReporterThread(bug, reporter, parameters, self.server) + t.start() + + # Wait for thread to die... + while t.isAlive(): + time.sleep(0.25) + submitStatus = t.status + + return (t.success, t.status) + + def send_report_submit(self): + report = self.get_scalar_field("report") + c = self.get_report_context(report) + if c.reportSource is None: + reportingFor = "Report Crashes > " + fileBug = ( + """\ +File Bug > """ + % locals() + ) + else: + reportingFor = 'Report %s > ' % (c.reportSource, report) + fileBug = 'File Bug > ' % report + title = self.get_scalar_field("title") + description = self.get_scalar_field("description") + + res, message = self.submit_bug(c) + + if res: + statusClass = "SubmitOk" + statusName = "Succeeded" + else: + statusClass = "SubmitFail" + statusName = "Failed" + + result = ( + """ + + Bug Submission + + + +

+Summary > +%(reportingFor)s +%(fileBug)s +Submit

+
+ + +
+ + + + + + + + +
Title: + +
Description: + +
+
+
+

Submission %(statusName)s

+%(message)s +

+


+Return to Summary + +""" + % locals() + ) + return self.send_string(result) + + def send_open_report(self, report): + try: + keys = self.load_report(report) + except IOError: + return self.send_error(400, "Invalid report.") + + file = keys.get("FILE") + if not file or not posixpath.exists(file): + return self.send_error(400, 'File does not exist: "%s"' % file) + + import startfile + + if self.server.options.debug: + print('%s: SERVER: opening "%s"' % (sys.argv[0], file), file=sys.stderr) + + status = startfile.open(file) + if status: + res = 'Opened: "%s"' % file + else: + res = 'Open failed: "%s"' % file + + return self.send_string(res, "text/plain") + + def get_report_context(self, report): + class Context(object): + pass + + if report is None or report == "None": + data = self.load_crashes() + # Don't allow empty reports. + if not data: + raise ValueError("No crashes detected!") + c = Context() + c.title = "clang static analyzer failures" + + stderrSummary = "" + for item in data: + if "stderr" in item: + path = posixpath.join(self.server.root, item["stderr"]) + if os.path.exists(path): + lns = itertools.islice(open(path), 0, 10) + stderrSummary += "%s\n--\n%s" % ( + item.get("src", ""), + "".join(lns), + ) + + c.description = """\ +The clang static analyzer failed on these inputs: +%s + +STDERR Summary +-------------- +%s +""" % ( + "\n".join([item.get("src", "") for item in data]), + stderrSummary, + ) + c.reportSource = None + c.navMarkup = "Report Crashes > " + c.files = [] + for item in data: + c.files.append(item.get("src", "")) + c.files.append(posixpath.join(self.server.root, item.get("file", ""))) + c.files.append( + posixpath.join(self.server.root, item.get("clangfile", "")) + ) + c.files.append(posixpath.join(self.server.root, item.get("stderr", ""))) + c.files.append(posixpath.join(self.server.root, item.get("info", ""))) + # Just in case something failed, ignore files which don't + # exist. + c.files = [f for f in c.files if os.path.exists(f) and os.path.isfile(f)] + else: + # Check that this is a valid report. + path = posixpath.join(self.server.root, "report-%s.html" % report) + if not posixpath.exists(path): + raise ValueError("Invalid report ID") + keys = self.load_report(report) + c = Context() + c.title = keys.get("DESC", "clang error (unrecognized") + c.description = """\ +Bug reported by the clang static analyzer. + +Description: %s +File: %s +Line: %s +""" % ( + c.title, + keys.get("FILE", ""), + keys.get("LINE", ""), + ) + c.reportSource = "report-%s.html" % report + c.navMarkup = """Report %s > """ % ( + c.reportSource, + report, + ) + + c.files = [path] + return c + + def send_report(self, report, configOverrides=None): + def getConfigOption(section, field): + if ( + configOverrides is not None + and section in configOverrides + and field in configOverrides[section] + ): + return configOverrides[section][field] + return self.server.config.get(section, field) + + # report is None is used for crashes + try: + c = self.get_report_context(report) + except ValueError as e: + return self.send_error(400, e.message) + + title = c.title + description = c.description + reportingFor = c.navMarkup + if c.reportSource is None: + extraIFrame = "" + else: + extraIFrame = """\ +""" % ( + c.reportSource, + c.reportSource, + ) + + reporterSelections = [] + reporterOptions = [] + + try: + active = int(getConfigOption("ScanView", "reporter")) + except: + active = 0 + for i, r in enumerate(self.server.reporters): + selected = i == active + if selected: + selectedStr = " selected" + else: + selectedStr = "" + reporterSelections.append( + '' % (i, selectedStr, r.getName()) + ) + options = "\n".join( + [o.getHTML(r, title, getConfigOption) for o in r.getParameters()] + ) + display = ("none", "")[selected] + reporterOptions.append( + """\ + + %s Options + + +%s +
+ + +""" + % (r.getName(), display, r.getName(), options) + ) + reporterSelections = "\n".join(reporterSelections) + reporterOptionsDivs = "\n".join(reporterOptions) + reportersArray = "[%s]" % ( + ",".join([repr(r.getName()) for r in self.server.reporters]) + ) + + if c.files: + fieldSize = min(5, len(c.files)) + attachFileOptions = "\n".join( + [ + """\ +""" + % (i, v) + for i, v in enumerate(c.files) + ] + ) + attachFileRow = """\ + + Attach: + + + + +""" % ( + min(5, len(c.files)), + attachFileOptions, + ) + else: + attachFileRow = "" + + result = ( + """ + + File Bug + + + + +

+Summary > +%(reportingFor)s +File Bug

+
+ + + + + +
+ + + + + + + + + + +%(attachFileRow)s + +
Title: + +
Description: + +
+
+ + + + + +%(reporterOptionsDivs)s +
Method: + +
+
+
+ +
+
+ +%(extraIFrame)s + + +""" + % locals() + ) + + return self.send_string(result) + + def send_head(self, fields=None): + if self.server.options.onlyServeLocal and self.client_address[0] != "127.0.0.1": + return self.send_error(401, "Unauthorized host.") + + if fields is None: + fields = {} + self.fields = fields + + o = urlparse(self.path) + self.fields = parse_query(o.query, fields) + path = posixpath.normpath(unquote(o.path)) + + # Split the components and strip the root prefix. + components = path.split("/")[1:] + + # Special case some top-level entries. + if components: + name = components[0] + if len(components) == 2: + if name == "report": + return self.send_report(components[1]) + elif name == "open": + return self.send_open_report(components[1]) + elif len(components) == 1: + if name == "quit": + self.server.halt() + return self.send_string("Goodbye.", "text/plain") + elif name == "report_submit": + return self.send_report_submit() + elif name == "report_crashes": + overrides = {"ScanView": {}, "Radar": {}, "Email": {}} + for i, r in enumerate(self.server.reporters): + if r.getName() == "Radar": + overrides["ScanView"]["reporter"] = i + break + overrides["Radar"]["Component"] = "llvm - checker" + overrides["Radar"]["Component Version"] = "X" + return self.send_report(None, overrides) + elif name == "favicon.ico": + return self.send_path(posixpath.join(kShare, "bugcatcher.ico")) + + # Match directory entries. + if components[-1] == "": + components[-1] = "index.html" + + relpath = "/".join(components) + path = posixpath.join(self.server.root, relpath) + + if self.server.options.debug > 1: + print( + '%s: SERVER: sending path "%s"' % (sys.argv[0], path), file=sys.stderr + ) + return self.send_path(path) + + def send_404(self): + self.send_error(404, "File not found") + return None + + def send_path(self, path): + # If the requested path is outside the root directory, do not open it + rel = os.path.abspath(path) + if not rel.startswith(os.path.abspath(self.server.root)): + return self.send_404() + + ctype = self.guess_type(path) + if ctype.startswith("text/"): + # Patch file instead + return self.send_patched_file(path, ctype) + else: + mode = "rb" + try: + f = open(path, mode) + except IOError: + return self.send_404() + return self.send_file(f, ctype) + + def send_file(self, f, ctype): + # Patch files to add links, but skip binary files. + self.send_response(200) + self.send_header("Content-type", ctype) + fs = os.fstat(f.fileno()) + self.send_header("Content-Length", str(fs[6])) + self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) + self.end_headers() + return f + + def send_string(self, s, ctype="text/html", headers=True, mtime=None): + encoded_s = s.encode("utf-8") + if headers: + self.send_response(200) + self.send_header("Content-type", ctype) + self.send_header("Content-Length", str(len(encoded_s))) + if mtime is None: + mtime = self.dynamic_mtime + self.send_header("Last-Modified", self.date_time_string(mtime)) + self.end_headers() + return BytesIO(encoded_s) + + def send_patched_file(self, path, ctype): + # Allow a very limited set of variables. This is pretty gross. + variables = {} + variables["report"] = "" + m = kReportFileRE.match(path) + if m: + variables["report"] = m.group(2) + + try: + f = open(path, "rb") + except IOError: + return self.send_404() + fs = os.fstat(f.fileno()) + data = f.read().decode("utf-8") + for a, b in kReportReplacements: + data = a.sub(b % variables, data) + return self.send_string(data, ctype, mtime=fs.st_mtime) + + +def create_server(address, options, root): + import Reporter + + reporters = Reporter.getReporters() + + return ScanViewServer(address, ScanViewRequestHandler, root, reporters, options) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-view/bugcatcher.ico b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-view/bugcatcher.ico new file mode 100755 index 0000000..22d39b5 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-view/bugcatcher.ico differ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-view/startfile.py b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-view/startfile.py new file mode 100755 index 0000000..c72475e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/staging_dir/host/llvm-bpf-21.1.6.Linux-x86_64/share/scan-view/startfile.py @@ -0,0 +1,216 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Utility for opening a file using the default application in a cross-platform +manner. Modified from http://code.activestate.com/recipes/511443/. +""" + +__version__ = "1.1x" +__all__ = ["open"] + +import os +import sys +import webbrowser +import subprocess + +_controllers = {} +_open = None + + +class BaseController(object): + """Base class for open program controllers.""" + + def __init__(self, name): + self.name = name + + def open(self, filename): + raise NotImplementedError + + +class Controller(BaseController): + """Controller for a generic open program.""" + + def __init__(self, *args): + super(Controller, self).__init__(os.path.basename(args[0])) + self.args = list(args) + + def _invoke(self, cmdline): + if sys.platform[:3] == "win": + closefds = False + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + else: + closefds = True + startupinfo = None + + if ( + os.environ.get("DISPLAY") + or sys.platform[:3] == "win" + or sys.platform == "darwin" + ): + inout = subprocess.DEVNULL + else: + # for TTY programs, we need stdin/out + inout = None + + # if possible, put the child precess in separate process group, + # so keyboard interrupts don't affect child precess as well as + # Python + setsid = getattr(os, "setsid", None) + if not setsid: + setsid = getattr(os, "setpgrp", None) + + pipe = subprocess.Popen( + cmdline, + stdin=inout, + stdout=inout, + stderr=inout, + close_fds=closefds, + preexec_fn=setsid, + startupinfo=startupinfo, + ) + + # It is assumed that this kind of tools (gnome-open, kfmclient, + # exo-open, xdg-open and open for OSX) immediately exit after launching + # the specific application + returncode = pipe.wait() + if hasattr(self, "fixreturncode"): + returncode = self.fixreturncode(returncode) + return not returncode + + def open(self, filename): + if isinstance(filename, basestring): + cmdline = self.args + [filename] + else: + # assume it is a sequence + cmdline = self.args + filename + try: + return self._invoke(cmdline) + except OSError: + return False + + +# Platform support for Windows +if sys.platform[:3] == "win": + + class Start(BaseController): + """Controller for the win32 start program through os.startfile.""" + + def open(self, filename): + try: + os.startfile(filename) + except WindowsError: + # [Error 22] No application is associated with the specified + # file for this operation: '' + return False + else: + return True + + _controllers["windows-default"] = Start("start") + _open = _controllers["windows-default"].open + + +# Platform support for MacOS +elif sys.platform == "darwin": + _controllers["open"] = Controller("open") + _open = _controllers["open"].open + + +# Platform support for Unix +else: + + try: + from commands import getoutput + except ImportError: + from subprocess import getoutput + + # @WARNING: use the private API of the webbrowser module + from webbrowser import _iscommand + + class KfmClient(Controller): + """Controller for the KDE kfmclient program.""" + + def __init__(self, kfmclient="kfmclient"): + super(KfmClient, self).__init__(kfmclient, "exec") + self.kde_version = self.detect_kde_version() + + def detect_kde_version(self): + kde_version = None + try: + info = getoutput("kde-config --version") + + for line in info.splitlines(): + if line.startswith("KDE"): + kde_version = line.split(":")[-1].strip() + break + except (OSError, RuntimeError): + pass + + return kde_version + + def fixreturncode(self, returncode): + if returncode is not None and self.kde_version > "3.5.4": + return returncode + else: + return os.EX_OK + + def detect_desktop_environment(): + """Checks for known desktop environments + + Return the desktop environments name, lowercase (kde, gnome, xfce) + or "generic" + + """ + + desktop_environment = "generic" + + if os.environ.get("KDE_FULL_SESSION") == "true": + desktop_environment = "kde" + elif os.environ.get("GNOME_DESKTOP_SESSION_ID"): + desktop_environment = "gnome" + else: + try: + info = getoutput("xprop -root _DT_SAVE_MODE") + if ' = "xfce4"' in info: + desktop_environment = "xfce" + except (OSError, RuntimeError): + pass + + return desktop_environment + + def register_X_controllers(): + if _iscommand("kfmclient"): + _controllers["kde-open"] = KfmClient() + + for command in ("gnome-open", "exo-open", "xdg-open"): + if _iscommand(command): + _controllers[command] = Controller(command) + + def get(): + controllers_map = { + "gnome": "gnome-open", + "kde": "kde-open", + "xfce": "exo-open", + } + + desktop_environment = detect_desktop_environment() + + try: + controller_name = controllers_map[desktop_environment] + return _controllers[controller_name].open + + except KeyError: + if "xdg-open" in _controllers: + return _controllers["xdg-open"].open + else: + return webbrowser.open + + if os.environ.get("DISPLAY"): + register_X_controllers() + _open = get() + + +def open(filename): + """Open a file or a URL in the registered default application.""" + + return _open(filename) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/PATCHES.md b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/PATCHES.md new file mode 100755 index 0000000..0462a59 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/PATCHES.md @@ -0,0 +1,84 @@ +# OpenWrt kernel patches + +All patches must be in a way that they are potentially upstreamable, meaning: + +* They must contain a proper subject. +* They must contain a proper commit message explaining what they change and why. +* They must contain a valid Signed-off-by line. + +The build system applies the patches in the following order: + +1. target/linux/generic/backport-*/ +2. target/linux/generic/pending-*/ +3. target/linux/generic/hack-*/ +4. target/linux/``/patches-*/ + +## OpenWrt generic + +The generic target patches are applied to every OpenWrt target before any of the specific target patches are applied. + +### backport + +The `backport-*` subdirectories contain the kernel patches backported from newer kernels. + +In order to save naming space for newer patches to come, when adding a new subset of patches which are related between them the following naming convention shall be used: `NNN-SS-vX.Y-lowercase_shortname.patch`. +For single patches, the following naming convention shall be used instead: `NNN-vX.Y-lowercase_shortname.patch`. + +| Item | Description | +| ----- |:------------------------:| +| NNN | Main patch number. | +| SS | Subset patch number. | +| vX.Y | Upstream kernel version. | + +### hack + +The `hack-*` subdirectories contain the downstream kernel patches that are less likely to be accepted upstream but are still needed in OpenWrt. +Some of these patches are potentially upstreamable if properly reworked and others aren't simply worth the effort. + +All patches should be named `NNN-lowercase_shortname.patch`. + +### pending + +The `pending-*` subdirectories contain the kernel patches awaiting upstream merge. + +All patches should be named `NNN-lowercase_shortname.patch`. + +### Patch number guidelines + +The following patch numbering guidelines shall be followed: + +| NNN | Description | +| ---- |:-------------------------------:| +| 0xx | - | +| 1xx | - | +| 2xx | Kernel build / config / header | +| 3xx | Architecture specific | +| 4xx | MTD | +| 5xx | Filesystem | +| 6xx | Generic network | +| 7xx | Network / PHY | +| 8xx | Other drivers | +| 9xx | Uncategorized | + +## OpenWrt targets + +The `patches-*` subdirectories contain the kernel patches applied for every OpenWrt target. + +All patches should be named `NNN-lowercase_shortname.patch`. + +### Patch number guidelines + +The following patch numbering guidelines shall be followed: + +| NNN | Description | +| ---- |:-------------------------------:| +| 0xx | Upstream backports | +| 1xx | Awaiting upstream merge | +| 2xx | Kernel build / config / header | +| 3xx | Architecture specific | +| 4xx | MTD | +| 5xx | Filesystem | +| 6xx | Generic network | +| 7xx | Network / PHY | +| 8xx | Other drivers | +| 9xx | Uncategorized | diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/010-v6.19-nvmem-layouts-u-boot-env-add-optional-env-size-property.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/010-v6.19-nvmem-layouts-u-boot-env-add-optional-env-size-property.patch new file mode 100755 index 0000000..207161a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/010-v6.19-nvmem-layouts-u-boot-env-add-optional-env-size-property.patch @@ -0,0 +1,62 @@ +From 06e92afca89075628b12c9b4085b4cc7320081ac Mon Sep 17 00:00:00 2001 +From: Jascha Sundaresan +Date: Thu, 23 Oct 2025 03:07:41 +0400 +Subject: nvmem: layouts: u-boot-env: add optional "env-size" property + +Some devices reserve a larger NVMEM region for the U-Boot environment +than the actual environment data length used by U-Boot itself. The CRC32 +in the U-Boot header is calculated over the smaller data length, causing +CRC validation to fail when Linux reads the full partition. + +Allow an optional device tree property "env-size" to specify the +environment data size to use for CRC computation. + +v2: add missing $ref line to DT binding + +Signed-off-by: Jascha Sundaresan +Reviewed-by: Rob Herring (Arm) +Signed-off-by: Srinivas Kandagatla +--- + Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml | 7 +++++++ + drivers/nvmem/layouts/u-boot-env.c | 4 +++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +--- a/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml ++++ b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml +@@ -46,6 +46,12 @@ properties: + type: object + description: Command to use for automatic booting + ++ env-size: ++ description: ++ Size in bytes of the environment data used by U-Boot for CRC ++ calculation. If omitted, the full NVMEM region size is used. ++ $ref: /schemas/types.yaml#/definitions/uint32 ++ + ethaddr: + type: object + description: Ethernet interfaces base MAC address. +@@ -104,6 +110,7 @@ examples: + + partition-u-boot-env { + compatible = "brcm,env"; ++ env-size = <0x20000>; + + ethaddr { + }; +--- a/drivers/nvmem/layouts/u-boot-env.c ++++ b/drivers/nvmem/layouts/u-boot-env.c +@@ -99,10 +99,12 @@ int u_boot_env_parse(struct device *dev, + uint32_t crc32; + uint32_t calc; + uint8_t *buf; ++ u32 env_size; + int bytes; + int err; + +- dev_size = nvmem_dev_size(nvmem); ++ dev_size = device_property_read_u32(dev, "env-size", &env_size) ? ++ nvmem_dev_size(nvmem) : (size_t)env_size; + + buf = kzalloc(dev_size, GFP_KERNEL); + if (!buf) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/152-v6.16-net-wireguard-add-nonstring-annotation-to-fix-build-with-GCC15.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/152-v6.16-net-wireguard-add-nonstring-annotation-to-fix-build-with-GCC15.patch new file mode 100755 index 0000000..1fdf2f1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/152-v6.16-net-wireguard-add-nonstring-annotation-to-fix-build-with-GCC15.patch @@ -0,0 +1,63 @@ +From 71e5da46e78c1cd24e2feed251a2845327447ad8 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Wed, 21 May 2025 23:27:04 +0200 +Subject: wireguard: global: add __nonstring annotations for unterminated + strings + +When a character array without a terminating NUL character has a static +initializer, GCC 15's -Wunterminated-string-initialization will only +warn if the array lacks the "nonstring" attribute[1]. Mark the arrays +with __nonstring to correctly identify the char array as "not a C string" +and thereby eliminate the warning: + +../drivers/net/wireguard/cookie.c:29:56: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization] + 29 | static const u8 mac1_key_label[COOKIE_KEY_LABEL_LEN] = "mac1----"; + | ^~~~~~~~~~ +../drivers/net/wireguard/cookie.c:30:58: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization] + 30 | static const u8 cookie_key_label[COOKIE_KEY_LABEL_LEN] = "cookie--"; + | ^~~~~~~~~~ +../drivers/net/wireguard/noise.c:28:38: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (38 chars into 37 available) [-Wunterminated-string-initialization] + 28 | static const u8 handshake_name[37] = "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"; + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +../drivers/net/wireguard/noise.c:29:39: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (35 chars into 34 available) [-Wunterminated-string-initialization] + 29 | static const u8 identifier_name[34] = "WireGuard v1 zx2c4 Jason@zx2c4.com"; + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The arrays are always used with their fixed size, so use __nonstring. + +Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] +Signed-off-by: Kees Cook +Signed-off-by: Jason A. Donenfeld +Link: https://patch.msgid.link/20250521212707.1767879-3-Jason@zx2c4.com +Signed-off-by: Paolo Abeni +--- + drivers/net/wireguard/cookie.c | 4 ++-- + drivers/net/wireguard/noise.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/net/wireguard/cookie.c ++++ b/drivers/net/wireguard/cookie.c +@@ -26,8 +26,8 @@ void wg_cookie_checker_init(struct cooki + } + + enum { COOKIE_KEY_LABEL_LEN = 8 }; +-static const u8 mac1_key_label[COOKIE_KEY_LABEL_LEN] = "mac1----"; +-static const u8 cookie_key_label[COOKIE_KEY_LABEL_LEN] = "cookie--"; ++static const u8 mac1_key_label[COOKIE_KEY_LABEL_LEN] __nonstring = "mac1----"; ++static const u8 cookie_key_label[COOKIE_KEY_LABEL_LEN] __nonstring = "cookie--"; + + static void precompute_key(u8 key[NOISE_SYMMETRIC_KEY_LEN], + const u8 pubkey[NOISE_PUBLIC_KEY_LEN], +--- a/drivers/net/wireguard/noise.c ++++ b/drivers/net/wireguard/noise.c +@@ -25,8 +25,8 @@ + * <- e, ee, se, psk, {} + */ + +-static const u8 handshake_name[37] = "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"; +-static const u8 identifier_name[34] = "WireGuard v1 zx2c4 Jason@zx2c4.com"; ++static const u8 handshake_name[37] __nonstring = "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"; ++static const u8 identifier_name[34] __nonstring = "WireGuard v1 zx2c4 Jason@zx2c4.com"; + static u8 handshake_init_hash[NOISE_HASH_LEN] __ro_after_init; + static u8 handshake_init_chaining_key[NOISE_HASH_LEN] __ro_after_init; + static atomic64_t keypair_counter = ATOMIC64_INIT(0); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/200-01-v6.13-jiffies-Define-secs_to_jiffies.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/200-01-v6.13-jiffies-Define-secs_to_jiffies.patch new file mode 100755 index 0000000..ad9af1d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/200-01-v6.13-jiffies-Define-secs_to_jiffies.patch @@ -0,0 +1,60 @@ +From b35108a51cf7bab58d7eace1267d7965978bcdb8 Mon Sep 17 00:00:00 2001 +From: Easwar Hariharan +Date: Wed, 30 Oct 2024 17:47:35 +0000 +Subject: [PATCH] jiffies: Define secs_to_jiffies() + +secs_to_jiffies() is defined in hci_event.c and cannot be reused by +other call sites. Hoist it into the core code to allow conversion of the +~1150 usages of msecs_to_jiffies() that either: + + - use a multiplier value of 1000 or equivalently MSEC_PER_SEC, or + - have timeouts that are denominated in seconds (i.e. end in 000) + +It's implemented as a macro to allow usage in static initializers. + +This will also allow conversion of yet more sites that use (sec * HZ) +directly, and improve their readability. + +Suggested-by: Michael Kelley +Signed-off-by: Easwar Hariharan +Signed-off-by: Thomas Gleixner +Reviewed-by: Luiz Augusto von Dentz +Link: https://lore.kernel.org/all/20241030-open-coded-timeouts-v3-1-9ba123facf88@linux.microsoft.com +--- + include/linux/jiffies.h | 13 +++++++++++++ + net/bluetooth/hci_event.c | 2 -- + 2 files changed, 13 insertions(+), 2 deletions(-) + +--- a/include/linux/jiffies.h ++++ b/include/linux/jiffies.h +@@ -526,6 +526,19 @@ static __always_inline unsigned long mse + } + } + ++/** ++ * secs_to_jiffies: - convert seconds to jiffies ++ * @_secs: time in seconds ++ * ++ * Conversion is done by simple multiplication with HZ ++ * ++ * secs_to_jiffies() is defined as a macro rather than a static inline ++ * function so it can be used in static initializers. ++ * ++ * Return: jiffies value ++ */ ++#define secs_to_jiffies(_secs) ((_secs) * HZ) ++ + extern unsigned long __usecs_to_jiffies(const unsigned int u); + #if !(USEC_PER_SEC % HZ) + static inline unsigned long _usecs_to_jiffies(const unsigned int u) +--- a/net/bluetooth/hci_event.c ++++ b/net/bluetooth/hci_event.c +@@ -42,8 +42,6 @@ + #define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \ + "\x00\x00\x00\x00\x00\x00\x00\x00" + +-#define secs_to_jiffies(_secs) msecs_to_jiffies((_secs) * 1000) +- + /* Handle HCI Event packets */ + + static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/200-02-v6.14-jiffies-Cast-to-unsigned-long-in-secs_to_jiffies-con.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/200-02-v6.14-jiffies-Cast-to-unsigned-long-in-secs_to_jiffies-con.patch new file mode 100755 index 0000000..cddd558 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/200-02-v6.14-jiffies-Cast-to-unsigned-long-in-secs_to_jiffies-con.patch @@ -0,0 +1,35 @@ +From bb2784d9ab49587ba4fbff37a319fff2924db289 Mon Sep 17 00:00:00 2001 +From: Easwar Hariharan +Date: Thu, 30 Jan 2025 19:26:58 +0000 +Subject: [PATCH] jiffies: Cast to unsigned long in secs_to_jiffies() + conversion + +While converting users of msecs_to_jiffies(), lkp reported that some range +checks would always be true because of the mismatch between the implied int +value of secs_to_jiffies() vs the unsigned long return value of the +msecs_to_jiffies() calls it was replacing. + +Fix this by casting the secs_to_jiffies() input value to unsigned long. + +Fixes: b35108a51cf7ba ("jiffies: Define secs_to_jiffies()") +Reported-by: kernel test robot +Signed-off-by: Easwar Hariharan +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Link: https://lore.kernel.org/all/20250130192701.99626-1-eahariha@linux.microsoft.com +Closes: https://lore.kernel.org/oe-kbuild-all/202501301334.NB6NszQR-lkp@intel.com/ +--- + include/linux/jiffies.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/linux/jiffies.h ++++ b/include/linux/jiffies.h +@@ -537,7 +537,7 @@ static __always_inline unsigned long mse + * + * Return: jiffies value + */ +-#define secs_to_jiffies(_secs) ((_secs) * HZ) ++#define secs_to_jiffies(_secs) (unsigned long)((_secs) * HZ) + + extern unsigned long __usecs_to_jiffies(const unsigned int u); + #if !(USEC_PER_SEC % HZ) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/201-v6.13-of-property-add-of_graph_get_next_port.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/201-v6.13-of-property-add-of_graph_get_next_port.patch new file mode 100755 index 0000000..5178dc8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/201-v6.13-of-property-add-of_graph_get_next_port.patch @@ -0,0 +1,199 @@ +From 02ac5f9d6caec96071103f7c62b5117526e47b64 Mon Sep 17 00:00:00 2001 +From: Kuninori Morimoto +Date: Thu, 24 Oct 2024 02:20:02 +0000 +Subject: [PATCH] of: property: add of_graph_get_next_port() + +We have endpoint base functions + - of_graph_get_next_endpoint() + - of_graph_get_endpoint_count() + - for_each_endpoint_of_node() + +Here, for_each_endpoint_of_node() loop finds each endpoints + + ports { + port@0 { +(1) endpoint {...}; + }; + port@1 { +(2) endpoint {...}; + }; + ... + }; + +In above case, it finds endpoint as (1) -> (2) -> ... + +Basically, user/driver knows which port is used for what, but not in +all cases. For example on flexible/generic driver case, how many ports +are used is not fixed. + +For example Sound Generic Card driver which is very flexible/generic and +used from many venders can't know how many ports are used, and used for +what, because it depends on each vender SoC and/or its used board. + +And more, the port can have multi endpoints. For example Generic Sound +Card case, it supports many type of connection between CPU / Codec, and +some of them uses multi endpoint in one port. see below. + + ports { +(A) port@0 { +(1) endpoint@0 {...}; +(2) endpoint@1 {...}; + }; +(B) port@1 { +(3) endpoint {...}; + }; + ... + }; + +Generic Sound Card want to handle each connection via "port" base instead +of "endpoint" base. But, it is very difficult to handle each "port" via +existing for_each_endpoint_of_node(). Because getting each "port" via +of_get_parent() from each "endpoint" doesn't work. For example in above +case, both (1) (2) endpoint has same "port" (= A). + +Add "port" base functions. + +Signed-off-by: Kuninori Morimoto +Link: https://lore.kernel.org/r/87ldyeb5t9.wl-kuninori.morimoto.gx@renesas.com +Signed-off-by: Rob Herring (Arm) +--- + drivers/of/property.c | 54 ++++++++++++++++++++++++++++++++++++++++ + include/linux/of_graph.h | 28 +++++++++++++++++++++ + 2 files changed, 82 insertions(+) + +--- a/drivers/of/property.c ++++ b/drivers/of/property.c +@@ -631,6 +631,43 @@ struct device_node *of_graph_get_port_by + EXPORT_SYMBOL(of_graph_get_port_by_id); + + /** ++ * of_graph_get_next_port() - get next port node. ++ * @parent: pointer to the parent device node, or parent ports node ++ * @prev: previous port node, or NULL to get first ++ * ++ * Parent device node can be used as @parent whether device node has ports node ++ * or not. It will work same as ports@0 node. ++ * ++ * Return: A 'port' node pointer with refcount incremented. Refcount ++ * of the passed @prev node is decremented. ++ */ ++struct device_node *of_graph_get_next_port(const struct device_node *parent, ++ struct device_node *prev) ++{ ++ if (!parent) ++ return NULL; ++ ++ if (!prev) { ++ struct device_node *node __free(device_node) = ++ of_get_child_by_name(parent, "ports"); ++ ++ if (node) ++ parent = node; ++ ++ return of_get_child_by_name(parent, "port"); ++ } ++ ++ do { ++ prev = of_get_next_child(parent, prev); ++ if (!prev) ++ break; ++ } while (!of_node_name_eq(prev, "port")); ++ ++ return prev; ++} ++EXPORT_SYMBOL(of_graph_get_next_port); ++ ++/** + * of_graph_get_next_endpoint() - get next endpoint node + * @parent: pointer to the parent device node + * @prev: previous endpoint node, or NULL to get first +@@ -824,6 +861,23 @@ unsigned int of_graph_get_endpoint_count + EXPORT_SYMBOL(of_graph_get_endpoint_count); + + /** ++ * of_graph_get_port_count() - get the number of port in a device or ports node ++ * @np: pointer to the device or ports node ++ * ++ * Return: count of port of this device or ports node ++ */ ++unsigned int of_graph_get_port_count(struct device_node *np) ++{ ++ unsigned int num = 0; ++ ++ for_each_of_graph_port(np, port) ++ num++; ++ ++ return num; ++} ++EXPORT_SYMBOL(of_graph_get_port_count); ++ ++/** + * of_graph_get_remote_node() - get remote parent device_node for given port/endpoint + * @node: pointer to parent device_node containing graph port/endpoint + * @port: identifier (value of reg property) of the parent port node +--- a/include/linux/of_graph.h ++++ b/include/linux/of_graph.h +@@ -11,6 +11,7 @@ + #ifndef __LINUX_OF_GRAPH_H + #define __LINUX_OF_GRAPH_H + ++#include + #include + #include + +@@ -37,14 +38,29 @@ struct of_endpoint { + for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \ + child = of_graph_get_next_endpoint(parent, child)) + ++/** ++ * for_each_of_graph_port - iterate over every port in a device or ports node ++ * @parent: parent device or ports node containing port ++ * @child: loop variable pointing to the current port node ++ * ++ * When breaking out of the loop, and continue to use the @child, you need to ++ * use return_ptr(@child) or no_free_ptr(@child) not to call __free() for it. ++ */ ++#define for_each_of_graph_port(parent, child) \ ++ for (struct device_node *child __free(device_node) = of_graph_get_next_port(parent, NULL);\ ++ child != NULL; child = of_graph_get_next_port(parent, child)) ++ + #ifdef CONFIG_OF + bool of_graph_is_present(const struct device_node *node); + int of_graph_parse_endpoint(const struct device_node *node, + struct of_endpoint *endpoint); + unsigned int of_graph_get_endpoint_count(const struct device_node *np); ++unsigned int of_graph_get_port_count(struct device_node *np); + struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); + struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, + struct device_node *previous); ++struct device_node *of_graph_get_next_port(const struct device_node *parent, ++ struct device_node *port); + struct device_node *of_graph_get_endpoint_by_regs( + const struct device_node *parent, int port_reg, int reg); + struct device_node *of_graph_get_remote_endpoint( +@@ -73,6 +89,11 @@ static inline unsigned int of_graph_get_ + return 0; + } + ++static inline unsigned int of_graph_get_port_count(struct device_node *np) ++{ ++ return 0; ++} ++ + static inline struct device_node *of_graph_get_port_by_id( + struct device_node *node, u32 id) + { +@@ -83,6 +104,13 @@ static inline struct device_node *of_gra + const struct device_node *parent, + struct device_node *previous) + { ++ return NULL; ++} ++ ++static inline struct device_node *of_graph_get_next_port( ++ const struct device_node *parent, ++ struct device_node *previous) ++{ + return NULL; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/202-v6.13-clk-Provide-devm_clk_bulk_get_all_enabled-helper.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/202-v6.13-clk-Provide-devm_clk_bulk_get_all_enabled-helper.patch new file mode 100755 index 0000000..cf52b59 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/202-v6.13-clk-Provide-devm_clk_bulk_get_all_enabled-helper.patch @@ -0,0 +1,118 @@ +From 51e32e897539663957f7a0950f66b48f8896efee Mon Sep 17 00:00:00 2001 +From: Cristian Ciocaltea +Date: Sat, 19 Oct 2024 14:16:00 +0300 +Subject: [PATCH] clk: Provide devm_clk_bulk_get_all_enabled() helper + +Commit 265b07df758a ("clk: Provide managed helper to get and enable bulk +clocks") added devm_clk_bulk_get_all_enable() function, but missed to +return the number of clocks stored in the clk_bulk_data table referenced +by the clks argument. Without knowing the number, it's not possible to +iterate these clocks when needed, hence the argument is useless and +could have been simply removed. + +Introduce devm_clk_bulk_get_all_enabled() variant, which is consistent +with devm_clk_bulk_get_all() in terms of the returned value: + + > 0 if one or more clocks have been stored + = 0 if there are no clocks + < 0 if an error occurred + +Moreover, the naming is consistent with devm_clk_get_enabled(), i.e. use +the past form of 'enable'. + +To reduce code duplication and improve patch readability, make +devm_clk_bulk_get_all_enable() use the new helper, as suggested by +Stephen Boyd. + +Reviewed-by: AngeloGioacchino Del Regno +Reviewed-by: Manivannan Sadhasivam +Signed-off-by: Cristian Ciocaltea +Link: https://lore.kernel.org/r/20241019-clk_bulk_ena_fix-v4-1-57f108f64e70@collabora.com +Signed-off-by: Stephen Boyd +--- + drivers/clk/clk-devres.c | 9 +++++---- + include/linux/clk.h | 21 ++++++++++++++++----- + 2 files changed, 21 insertions(+), 9 deletions(-) + +--- a/drivers/clk/clk-devres.c ++++ b/drivers/clk/clk-devres.c +@@ -218,8 +218,8 @@ static void devm_clk_bulk_release_all_en + clk_bulk_put_all(devres->num_clks, devres->clks); + } + +-int __must_check devm_clk_bulk_get_all_enable(struct device *dev, +- struct clk_bulk_data **clks) ++int __must_check devm_clk_bulk_get_all_enabled(struct device *dev, ++ struct clk_bulk_data **clks) + { + struct clk_bulk_devres *devres; + int ret; +@@ -244,11 +244,12 @@ int __must_check devm_clk_bulk_get_all_e + } else { + clk_bulk_put_all(devres->num_clks, devres->clks); + devres_free(devres); ++ return ret; + } + +- return ret; ++ return devres->num_clks; + } +-EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enable); ++EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enabled); + + static int devm_clk_match(struct device *dev, void *res, void *data) + { +--- a/include/linux/clk.h ++++ b/include/linux/clk.h +@@ -496,11 +496,13 @@ int __must_check devm_clk_bulk_get_all(s + struct clk_bulk_data **clks); + + /** +- * devm_clk_bulk_get_all_enable - Get and enable all clocks of the consumer (managed) ++ * devm_clk_bulk_get_all_enabled - Get and enable all clocks of the consumer (managed) + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * +- * Returns success (0) or negative errno. ++ * Returns a positive value for the number of clocks obtained while the ++ * clock references are stored in the clk_bulk_data table in @clks field. ++ * Returns 0 if there're none and a negative value if something failed. + * + * This helper function allows drivers to get all clocks of the + * consumer and enables them in one operation with management. +@@ -508,8 +510,8 @@ int __must_check devm_clk_bulk_get_all(s + * is unbound. + */ + +-int __must_check devm_clk_bulk_get_all_enable(struct device *dev, +- struct clk_bulk_data **clks); ++int __must_check devm_clk_bulk_get_all_enabled(struct device *dev, ++ struct clk_bulk_data **clks); + + /** + * devm_clk_get - lookup and obtain a managed reference to a clock producer. +@@ -1034,7 +1036,7 @@ static inline int __must_check devm_clk_ + return 0; + } + +-static inline int __must_check devm_clk_bulk_get_all_enable(struct device *dev, ++static inline int __must_check devm_clk_bulk_get_all_enabled(struct device *dev, + struct clk_bulk_data **clks) + { + return 0; +@@ -1136,6 +1138,15 @@ static inline void clk_restore_context(v + + #endif + ++/* Deprecated. Use devm_clk_bulk_get_all_enabled() */ ++static inline int __must_check ++devm_clk_bulk_get_all_enable(struct device *dev, struct clk_bulk_data **clks) ++{ ++ int ret = devm_clk_bulk_get_all_enabled(dev, clks); ++ ++ return ret > 0 ? 0 : ret; ++} ++ + /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ + static inline int clk_prepare_enable(struct clk *clk) + { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/203-01-v6.13-of-address-Rework-bus-matching-to-avoid-warnings.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/203-01-v6.13-of-address-Rework-bus-matching-to-avoid-warnings.patch new file mode 100755 index 0000000..d7a6751 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/203-01-v6.13-of-address-Rework-bus-matching-to-avoid-warnings.patch @@ -0,0 +1,61 @@ +From 64ee3cf096ac590e7da2ceac1c390546bff5e240 Mon Sep 17 00:00:00 2001 +From: "Rob Herring (Arm)" +Date: Fri, 8 Nov 2024 13:35:48 -0600 +Subject: [PATCH] of/address: Rework bus matching to avoid warnings + +With warnings added for deprecated #address-cells/#size-cells handling, +the DT address handling code causes warnings when used on nodes with no +address. This happens frequently with calls to of_platform_populate() as +it is perfectly acceptable to have devices without a 'reg' property. The +desired behavior is to just silently return an error when retrieving an +address. + +The warnings can be avoided by checking for "#address-cells" presence +first and checking for an address property before fetching +"#address-cells" and "#size-cells". + +Reported-by: Marek Szyprowski +Reported-by: Steven Price +Tested-by: Marek Szyprowski +Link: https://lore.kernel.org/r/20241108193547.2647986-2-robh@kernel.org +Signed-off-by: Rob Herring (Arm) +--- + drivers/of/address.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +--- a/drivers/of/address.c ++++ b/drivers/of/address.c +@@ -331,7 +331,11 @@ static unsigned int of_bus_isa_get_flags + + static int of_bus_default_flags_match(struct device_node *np) + { +- return of_bus_n_addr_cells(np) == 3; ++ /* ++ * Check for presence first since of_bus_n_addr_cells() will warn when ++ * walking parent nodes. ++ */ ++ return of_property_present(np, "#address-cells") && (of_bus_n_addr_cells(np) == 3); + } + + /* +@@ -700,16 +704,16 @@ const __be32 *__of_get_address(struct de + if (strcmp(bus->name, "pci") && (bar_no >= 0)) + return NULL; + +- bus->count_cells(dev, &na, &ns); +- if (!OF_CHECK_ADDR_COUNT(na)) +- return NULL; +- + /* Get "reg" or "assigned-addresses" property */ + prop = of_get_property(dev, bus->addresses, &psize); + if (prop == NULL) + return NULL; + psize /= 4; + ++ bus->count_cells(dev, &na, &ns); ++ if (!OF_CHECK_ADDR_COUNT(na)) ++ return NULL; ++ + onesize = na + ns; + for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++) { + u32 val = be32_to_cpu(prop[0]); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/203-02-v6.13-of-address-Fix-WARN-when-attempting-translating-non-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/203-02-v6.13-of-address-Fix-WARN-when-attempting-translating-non-.patch new file mode 100755 index 0000000..2ad67cb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/203-02-v6.13-of-address-Fix-WARN-when-attempting-translating-non-.patch @@ -0,0 +1,85 @@ +From 6e5773d52f4a2d9c80692245f295069260cff6fc Mon Sep 17 00:00:00 2001 +From: "Rob Herring (Arm)" +Date: Fri, 10 Jan 2025 15:50:29 -0600 +Subject: [PATCH] of/address: Fix WARN when attempting translating + non-translatable addresses + +The recently added WARN() for deprecated #address-cells and #size-cells +triggered a WARN when of_platform_populate() (which calls +of_address_to_resource()) is used on nodes with non-translatable +addresses. This case is expected to return an error. + +Rework the bus matching to allow no match and make the default require +an #address-cells property. That should be safe to do as any platform +missing #address-cells would have a warning already. + +Fixes: 045b14ca5c36 ("of: WARN on deprecated #address-cells/#size-cells handling") +Tested-by: Sean Anderson +Link: https://lore.kernel.org/r/20250110215030.3637845-2-robh@kernel.org +Signed-off-by: Rob Herring (Arm) +--- + drivers/of/address.c | 18 +++++++++++++++--- + 1 file changed, 15 insertions(+), 3 deletions(-) + +--- a/drivers/of/address.c ++++ b/drivers/of/address.c +@@ -338,6 +338,15 @@ static int of_bus_default_flags_match(st + return of_property_present(np, "#address-cells") && (of_bus_n_addr_cells(np) == 3); + } + ++static int of_bus_default_match(struct device_node *np) ++{ ++ /* ++ * Check for presence first since of_bus_n_addr_cells() will warn when ++ * walking parent nodes. ++ */ ++ return of_property_present(np, "#address-cells"); ++} ++ + /* + * Array of bus specific translators + */ +@@ -382,7 +391,7 @@ static struct of_bus of_busses[] = { + { + .name = "default", + .addresses = "reg", +- .match = NULL, ++ .match = of_bus_default_match, + .count_cells = of_bus_default_count_cells, + .map = of_bus_default_map, + .translate = of_bus_default_translate, +@@ -397,7 +406,6 @@ static struct of_bus *of_match_bus(struc + for (i = 0; i < ARRAY_SIZE(of_busses); i++) + if (!of_busses[i].match || of_busses[i].match(np)) + return &of_busses[i]; +- BUG(); + return NULL; + } + +@@ -519,6 +527,8 @@ static u64 __of_translate_address(struct + if (parent == NULL) + return OF_BAD_ADDR; + bus = of_match_bus(parent); ++ if (!bus) ++ return OF_BAD_ADDR; + + /* Count address cells & copy address locally */ + bus->count_cells(dev, &na, &ns); +@@ -562,6 +572,8 @@ static u64 __of_translate_address(struct + + /* Get new parent bus and counts */ + pbus = of_match_bus(parent); ++ if (!pbus) ++ return OF_BAD_ADDR; + pbus->count_cells(dev, &pna, &pns); + if (!OF_CHECK_COUNTS(pna, pns)) { + pr_err("Bad cell count for %pOF\n", dev); +@@ -701,7 +713,7 @@ const __be32 *__of_get_address(struct de + + /* match the parent's bus type */ + bus = of_match_bus(parent); +- if (strcmp(bus->name, "pci") && (bar_no >= 0)) ++ if (!bus || (strcmp(bus->name, "pci") && (bar_no >= 0))) + return NULL; + + /* Get "reg" or "assigned-addresses" property */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/204-v6.13-resource-Add-resource-set-range-and-size-helpers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/204-v6.13-resource-Add-resource-set-range-and-size-helpers.patch new file mode 100755 index 0000000..0ea3e2a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/204-v6.13-resource-Add-resource-set-range-and-size-helpers.patch @@ -0,0 +1,73 @@ +From 9fb6fef0fb49124291837af1da5028f79d53f98e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Fri, 14 Jun 2024 13:06:03 +0300 +Subject: [PATCH] resource: Add resource set range and size helpers +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Setting the end address for a resource with a given size lacks a helper and +is therefore coded manually unlike the getter side which has a helper for +resource size calculation. Also, almost all callsites that calculate the +end address for a resource also set the start address right before it like +this: + + res->start = start_addr; + res->end = res->start + size - 1; + +Add resource_set_range(res, start_addr, size) that sets the start address +and calculates the end address to simplify this often repeated fragment. + +Also add resource_set_size() for the cases where setting the start address +of the resource is not necessary but mention in its kerneldoc that +resource_set_range() is preferred when setting both addresses. + +Link: https://lore.kernel.org/r/20240614100606.15830-2-ilpo.jarvinen@linux.intel.com +Signed-off-by: Ilpo JΓ€rvinen +Signed-off-by: Bjorn Helgaas +Reviewed-by: Jonathan Cameron +--- + include/linux/ioport.h | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + +--- a/include/linux/ioport.h ++++ b/include/linux/ioport.h +@@ -249,6 +249,38 @@ struct resource *lookup_resource(struct + int adjust_resource(struct resource *res, resource_size_t start, + resource_size_t size); + resource_size_t resource_alignment(struct resource *res); ++ ++/** ++ * resource_set_size - Calculate resource end address from size and start ++ * @res: Resource descriptor ++ * @size: Size of the resource ++ * ++ * Calculate the end address for @res based on @size. ++ * ++ * Note: The start address of @res must be set when calling this function. ++ * Prefer resource_set_range() if setting both the start address and @size. ++ */ ++static inline void resource_set_size(struct resource *res, resource_size_t size) ++{ ++ res->end = res->start + size - 1; ++} ++ ++/** ++ * resource_set_range - Set resource start and end addresses ++ * @res: Resource descriptor ++ * @start: Start address for the resource ++ * @size: Size of the resource ++ * ++ * Set @res start address and calculate the end address based on @size. ++ */ ++static inline void resource_set_range(struct resource *res, ++ resource_size_t start, ++ resource_size_t size) ++{ ++ res->start = start; ++ resource_set_size(res, size); ++} ++ + static inline resource_size_t resource_size(const struct resource *res) + { + return res->end - res->start + 1; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/205-v6.16-of-reserved_mem-Add-functions-to-parse-memory-region.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/205-v6.16-of-reserved_mem-Add-functions-to-parse-memory-region.patch new file mode 100755 index 0000000..b5bbb6e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/205-v6.16-of-reserved_mem-Add-functions-to-parse-memory-region.patch @@ -0,0 +1,163 @@ +From f4fcfdda2fd8834c62dcb9bfddcf1f89d190b70e Mon Sep 17 00:00:00 2001 +From: "Rob Herring (Arm)" +Date: Wed, 23 Apr 2025 14:42:13 -0500 +Subject: [PATCH] of: reserved_mem: Add functions to parse "memory-region" + +Drivers with "memory-region" properties currently have to do their own +parsing of "memory-region" properties. The result is all the drivers +have similar patterns of a call to parse "memory-region" and then get +the region's address and size. As this is a standard property, it should +have common functions for drivers to use. Add new functions to count the +number of regions and retrieve the region's address as a resource. + +Reviewed-by: Daniel Baluta +Acked-by: Arnaud Pouliquen +Link: https://lore.kernel.org/r/20250423-dt-memory-region-v2-v2-1-2fbd6ebd3c88@kernel.org +Signed-off-by: Rob Herring (Arm) +--- + drivers/of/of_reserved_mem.c | 80 +++++++++++++++++++++++++++++++++ + include/linux/of_reserved_mem.h | 26 +++++++++++ + 2 files changed, 106 insertions(+) + +--- a/drivers/of/of_reserved_mem.c ++++ b/drivers/of/of_reserved_mem.c +@@ -12,6 +12,7 @@ + #define pr_fmt(fmt) "OF: reserved mem: " fmt + + #include ++#include + #include + #include + #include +@@ -694,3 +695,82 @@ struct reserved_mem *of_reserved_mem_loo + return NULL; + } + EXPORT_SYMBOL_GPL(of_reserved_mem_lookup); ++ ++/** ++ * of_reserved_mem_region_to_resource() - Get a reserved memory region as a resource ++ * @np: node containing 'memory-region' property ++ * @idx: index of 'memory-region' property to lookup ++ * @res: Pointer to a struct resource to fill in with reserved region ++ * ++ * This function allows drivers to lookup a node's 'memory-region' property ++ * entries by index and return a struct resource for the entry. ++ * ++ * Returns 0 on success with @res filled in. Returns -ENODEV if 'memory-region' ++ * is missing or unavailable, -EINVAL for any other error. ++ */ ++int of_reserved_mem_region_to_resource(const struct device_node *np, ++ unsigned int idx, struct resource *res) ++{ ++ struct reserved_mem *rmem; ++ ++ if (!np) ++ return -EINVAL; ++ ++ struct device_node __free(device_node) *target = of_parse_phandle(np, "memory-region", idx); ++ if (!target || !of_device_is_available(target)) ++ return -ENODEV; ++ ++ rmem = of_reserved_mem_lookup(target); ++ if (!rmem) ++ return -EINVAL; ++ ++ resource_set_range(res, rmem->base, rmem->size); ++ res->name = rmem->name; ++ return 0; ++} ++EXPORT_SYMBOL_GPL(of_reserved_mem_region_to_resource); ++ ++/** ++ * of_reserved_mem_region_to_resource_byname() - Get a reserved memory region as a resource ++ * @np: node containing 'memory-region' property ++ * @name: name of 'memory-region' property entry to lookup ++ * @res: Pointer to a struct resource to fill in with reserved region ++ * ++ * This function allows drivers to lookup a node's 'memory-region' property ++ * entries by name and return a struct resource for the entry. ++ * ++ * Returns 0 on success with @res filled in, or a negative error-code on ++ * failure. ++ */ ++int of_reserved_mem_region_to_resource_byname(const struct device_node *np, ++ const char *name, ++ struct resource *res) ++{ ++ int idx; ++ ++ if (!name) ++ return -EINVAL; ++ ++ idx = of_property_match_string(np, "memory-region-names", name); ++ if (idx < 0) ++ return idx; ++ ++ return of_reserved_mem_region_to_resource(np, idx, res); ++} ++EXPORT_SYMBOL_GPL(of_reserved_mem_region_to_resource_byname); ++ ++/** ++ * of_reserved_mem_region_count() - Return the number of 'memory-region' entries ++ * @np: node containing 'memory-region' property ++ * ++ * This function allows drivers to retrieve the number of entries for a node's ++ * 'memory-region' property. ++ * ++ * Returns the number of entries on success, or negative error code on a ++ * malformed property. ++ */ ++int of_reserved_mem_region_count(const struct device_node *np) ++{ ++ return of_count_phandle_with_args(np, "memory-region", NULL); ++} ++EXPORT_SYMBOL_GPL(of_reserved_mem_region_count); +--- a/include/linux/of_reserved_mem.h ++++ b/include/linux/of_reserved_mem.h +@@ -7,6 +7,7 @@ + + struct of_phandle_args; + struct reserved_mem_ops; ++struct resource; + + struct reserved_mem { + const char *name; +@@ -39,6 +40,12 @@ int of_reserved_mem_device_init_by_name( + void of_reserved_mem_device_release(struct device *dev); + + struct reserved_mem *of_reserved_mem_lookup(struct device_node *np); ++int of_reserved_mem_region_to_resource(const struct device_node *np, ++ unsigned int idx, struct resource *res); ++int of_reserved_mem_region_to_resource_byname(const struct device_node *np, ++ const char *name, struct resource *res); ++int of_reserved_mem_region_count(const struct device_node *np); ++ + #else + + #define RESERVEDMEM_OF_DECLARE(name, compat, init) \ +@@ -63,6 +70,25 @@ static inline struct reserved_mem *of_re + { + return NULL; + } ++ ++static inline int of_reserved_mem_region_to_resource(const struct device_node *np, ++ unsigned int idx, ++ struct resource *res) ++{ ++ return -ENOSYS; ++} ++ ++static inline int of_reserved_mem_region_to_resource_byname(const struct device_node *np, ++ const char *name, ++ struct resource *res) ++{ ++ return -ENOSYS; ++} ++ ++static inline int of_reserved_mem_region_count(const struct device_node *np) ++{ ++ return 0; ++} + #endif + + /** diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/210-v6.13-fortify-Hide-run-time-copy-size-from-value-range-tracking.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/210-v6.13-fortify-Hide-run-time-copy-size-from-value-range-tracking.patch new file mode 100755 index 0000000..8dca649 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/210-v6.13-fortify-Hide-run-time-copy-size-from-value-range-tracking.patch @@ -0,0 +1,155 @@ +From 239d87327dcd361b0098038995f8908f3296864f Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Thu, 12 Dec 2024 17:28:06 -0800 +Subject: fortify: Hide run-time copy size from value range tracking +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GCC performs value range tracking for variables as a way to provide better +diagnostics. One place this is regularly seen is with warnings associated +with bounds-checking, e.g. -Wstringop-overflow, -Wstringop-overread, +-Warray-bounds, etc. In order to keep the signal-to-noise ratio high, +warnings aren't emitted when a value range spans the entire value range +representable by a given variable. For example: + + unsigned int len; + char dst[8]; + ... + memcpy(dst, src, len); + +If len's value is unknown, it has the full "unsigned int" range of [0, +UINT_MAX], and GCC's compile-time bounds checks against memcpy() will +be ignored. However, when a code path has been able to narrow the range: + + if (len > 16) + return; + memcpy(dst, src, len); + +Then the range will be updated for the execution path. Above, len is +now [0, 16] when reading memcpy(), so depending on other optimizations, +we might see a -Wstringop-overflow warning like: + + error: '__builtin_memcpy' writing between 9 and 16 bytes into region of size 8 [-Werror=stringop-overflow] + +When building with CONFIG_FORTIFY_SOURCE, the fortified run-time bounds +checking can appear to narrow value ranges of lengths for memcpy(), +depending on how the compiler constructs the execution paths during +optimization passes, due to the checks against the field sizes. For +example: + + if (p_size_field != SIZE_MAX && + p_size != p_size_field && p_size_field < size) + +As intentionally designed, these checks only affect the kernel warnings +emitted at run-time and do not block the potentially overflowing memcpy(), +so GCC thinks it needs to produce a warning about the resulting value +range that might be reaching the memcpy(). + +We have seen this manifest a few times now, with the most recent being +with cpumasks: + +In function β€˜bitmap_copy’, + inlined from β€˜cpumask_copy’ at ./include/linux/cpumask.h:839:2, + inlined from β€˜__padata_set_cpumasks’ at kernel/padata.c:730:2: +./include/linux/fortify-string.h:114:33: error: β€˜__builtin_memcpy’ reading between 257 and 536870904 bytes from a region of size 256 [-Werror=stringop-overread] + 114 | #define __underlying_memcpy __builtin_memcpy + | ^ +./include/linux/fortify-string.h:633:9: note: in expansion of macro β€˜__underlying_memcpy’ + 633 | __underlying_##op(p, q, __fortify_size); \ + | ^~~~~~~~~~~~~ +./include/linux/fortify-string.h:678:26: note: in expansion of macro β€˜__fortify_memcpy_chk’ + 678 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ + | ^~~~~~~~~~~~~~~~~~~~ +./include/linux/bitmap.h:259:17: note: in expansion of macro β€˜memcpy’ + 259 | memcpy(dst, src, len); + | ^~~~~~ +kernel/padata.c: In function β€˜__padata_set_cpumasks’: +kernel/padata.c:713:48: note: source object β€˜pcpumask’ of size [0, 256] + 713 | cpumask_var_t pcpumask, + | ~~~~~~~~~~~~~~^~~~~~~~ + +This warning is _not_ emitted when CONFIG_FORTIFY_SOURCE is disabled, +and with the recent -fdiagnostics-details we can confirm the origin of +the warning is due to FORTIFY's bounds checking: + +../include/linux/bitmap.h:259:17: note: in expansion of macro 'memcpy' + 259 | memcpy(dst, src, len); + | ^~~~~~ + '__padata_set_cpumasks': events 1-2 +../include/linux/fortify-string.h:613:36: + 612 | if (p_size_field != SIZE_MAX && + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 613 | p_size != p_size_field && p_size_field < size) + | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ + | | + | (1) when the condition is evaluated to false + | (2) when the condition is evaluated to true + '__padata_set_cpumasks': event 3 + 114 | #define __underlying_memcpy __builtin_memcpy + | ^ + | | + | (3) out of array bounds here + +Note that the cpumask warning started appearing since bitmap functions +were recently marked __always_inline in commit ed8cd2b3bd9f ("bitmap: +Switch from inline to __always_inline"), which allowed GCC to gain +visibility into the variables as they passed through the FORTIFY +implementation. + +In order to silence these false positives but keep otherwise deterministic +compile-time warnings intact, hide the length variable from GCC with +OPTIMIZE_HIDE_VAR() before calling the builtin memcpy. + +Additionally add a comment about why all the macro args have copies with +const storage. + +Reported-by: "Thomas Weißschuh" +Closes: https://lore.kernel.org/all/db7190c8-d17f-4a0d-bc2f-5903c79f36c2@t-8ch.de/ +Reported-by: Nilay Shroff +Closes: https://lore.kernel.org/all/20241112124127.1666300-1-nilay@linux.ibm.com/ +Tested-by: Nilay Shroff +Acked-by: Yury Norov +Acked-by: Greg Kroah-Hartman +Signed-off-by: Kees Cook +--- + include/linux/fortify-string.h | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +--- a/include/linux/fortify-string.h ++++ b/include/linux/fortify-string.h +@@ -616,6 +616,12 @@ __FORTIFY_INLINE bool fortify_memcpy_chk + return false; + } + ++/* ++ * To work around what seems to be an optimizer bug, the macro arguments ++ * need to have const copies or the values end up changed by the time they ++ * reach fortify_warn_once(). See commit 6f7630b1b5bc ("fortify: Capture ++ * __bos() results in const temp vars") for more details. ++ */ + #define __fortify_memcpy_chk(p, q, size, p_size, q_size, \ + p_size_field, q_size_field, op) ({ \ + const size_t __fortify_size = (size_t)(size); \ +@@ -623,6 +629,8 @@ __FORTIFY_INLINE bool fortify_memcpy_chk + const size_t __q_size = (q_size); \ + const size_t __p_size_field = (p_size_field); \ + const size_t __q_size_field = (q_size_field); \ ++ /* Keep a mutable version of the size for the final copy. */ \ ++ size_t __copy_size = __fortify_size; \ + fortify_warn_once(fortify_memcpy_chk(__fortify_size, __p_size, \ + __q_size, __p_size_field, \ + __q_size_field, FORTIFY_FUNC_ ##op), \ +@@ -630,7 +638,11 @@ __FORTIFY_INLINE bool fortify_memcpy_chk + __fortify_size, \ + "field \"" #p "\" at " FILE_LINE, \ + __p_size_field); \ +- __underlying_##op(p, q, __fortify_size); \ ++ /* Hide only the run-time size from value range tracking to */ \ ++ /* silence compile-time false positive bounds warnings. */ \ ++ if (!__builtin_constant_p(__copy_size)) \ ++ OPTIMIZER_HIDE_VAR(__copy_size); \ ++ __underlying_##op(p, q, __copy_size); \ + }) + + /* diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/212-v6.17-of-reserved_mem-Add-missing-IORESOURCE_MEM-flag-on-r.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/212-v6.17-of-reserved_mem-Add-missing-IORESOURCE_MEM-flag-on-r.patch new file mode 100755 index 0000000..1f2d52a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/212-v6.17-of-reserved_mem-Add-missing-IORESOURCE_MEM-flag-on-r.patch @@ -0,0 +1,32 @@ +From aea70964b5a7ca491a3701f2dde6c9d05d51878d Mon Sep 17 00:00:00 2001 +From: "Rob Herring (Arm)" +Date: Wed, 20 Aug 2025 14:28:04 -0500 +Subject: of: reserved_mem: Add missing IORESOURCE_MEM flag on resources + +Commit f4fcfdda2fd8 ('of: reserved_mem: Add functions to parse +"memory-region"') failed to set IORESOURCE_MEM flag on the resources. +The result is functions such as devm_ioremap_resource_wc() will fail. +Add the missing flag. + +Fixes: f4fcfdda2fd8 ('of: reserved_mem: Add functions to parse "memory-region"') +Reported-by: Iuliana Prodan +Reported-by: Daniel Baluta +Tested-by: Iuliana Prodan +Reviewed-by: Iuliana Prodan +Reviewed-by: Saravana Kannan +Link: https://lore.kernel.org/r/20250820192805.565568-1-robh@kernel.org +Signed-off-by: Rob Herring (Arm) +--- + drivers/of/of_reserved_mem.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/of/of_reserved_mem.c ++++ b/drivers/of/of_reserved_mem.c +@@ -725,6 +725,7 @@ int of_reserved_mem_region_to_resource(c + return -EINVAL; + + resource_set_range(res, rmem->base, rmem->size); ++ res->flags = IORESOURCE_MEM; + res->name = rmem->name; + return 0; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/400-v6.14-mtd-spinand-add-support-for-FORESEE-F35SQA001G.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/400-v6.14-mtd-spinand-add-support-for-FORESEE-F35SQA001G.patch new file mode 100755 index 0000000..84b3b2a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/400-v6.14-mtd-spinand-add-support-for-FORESEE-F35SQA001G.patch @@ -0,0 +1,38 @@ +From ae461cde5c559675fc4c0ba351c7c31ace705f56 Mon Sep 17 00:00:00 2001 +From: Bohdan Chubuk +Date: Sun, 10 Nov 2024 22:50:47 +0200 +Subject: [PATCH] mtd: spinand: add support for FORESEE F35SQA001G + +Add support for FORESEE F35SQA001G SPI NAND. + +Similar to F35SQA002G, but differs in capacity. +Datasheet: + - https://cdn.ozdisan.com/ETicaret_Dosya/704795_871495.pdf + +Tested on Xiaomi AX3000T flashed with OpenWRT. + +Signed-off-by: Bohdan Chubuk +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/foresee.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/mtd/nand/spi/foresee.c ++++ b/drivers/mtd/nand/spi/foresee.c +@@ -81,6 +81,16 @@ static const struct spinand_info foresee + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&f35sqa002g_ooblayout, + f35sqa002g_ecc_get_status)), ++ SPINAND_INFO("F35SQA001G", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x71, 0x71), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), ++ NAND_ECCREQ(1, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_HAS_QE_BIT, ++ SPINAND_ECCINFO(&f35sqa002g_ooblayout, ++ f35sqa002g_ecc_get_status)), + }; + + static const struct spinand_manufacturer_ops foresee_spinand_manuf_ops = { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/401-v6.17-mtd-spinand-add-support-for-FudanMicro-FM25S01A.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/401-v6.17-mtd-spinand-add-support-for-FudanMicro-FM25S01A.patch new file mode 100755 index 0000000..a27933c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/401-v6.17-mtd-spinand-add-support-for-FudanMicro-FM25S01A.patch @@ -0,0 +1,124 @@ +From 5f284dc15ca8695d0394414045ac64616a3b0e69 Mon Sep 17 00:00:00 2001 +From: Tianling Shen +Date: Mon, 25 Aug 2025 01:00:13 +0800 +Subject: [PATCH] mtd: spinand: add support for FudanMicro FM25S01A + +Add support for FudanMicro FM25S01A SPI NAND. +Datasheet: http://eng.fmsh.com/nvm/FM25S01A_ds_eng.pdf + +Signed-off-by: Tianling Shen +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20250824170013.3328777-1-cnsztl@gmail.com +--- + drivers/mtd/nand/spi/Makefile | 2 +- + drivers/mtd/nand/spi/core.c | 1 + + drivers/mtd/nand/spi/fmsh.c | 74 +++++++++++++++++++++++++++++++++++ + include/linux/mtd/spinand.h | 1 + + 4 files changed, 77 insertions(+), 1 deletion(-) + create mode 100644 drivers/mtd/nand/spi/fmsh.c + +--- a/drivers/mtd/nand/spi/Makefile ++++ b/drivers/mtd/nand/spi/Makefile +@@ -1,4 +1,4 @@ + # SPDX-License-Identifier: GPL-2.0 +-spinand-objs := core.o alliancememory.o ato.o esmt.o foresee.o gigadevice.o macronix.o ++spinand-objs := core.o alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o + spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o + obj-$(CONFIG_MTD_SPI_NAND) += spinand.o +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -1115,6 +1115,7 @@ static const struct spinand_manufacturer + &alliancememory_spinand_manufacturer, + &ato_spinand_manufacturer, + &esmt_c8_spinand_manufacturer, ++ &fmsh_spinand_manufacturer, + &foresee_spinand_manufacturer, + &gigadevice_spinand_manufacturer, + ¯onix_spinand_manufacturer, +--- /dev/null ++++ b/drivers/mtd/nand/spi/fmsh.c +@@ -0,0 +1,74 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2020-2021 Rockchip Electronics Co., Ltd. ++ * ++ * Author: Dingqiang Lin ++ */ ++ ++#include ++#include ++#include ++ ++#define SPINAND_MFR_FMSH 0xA1 ++ ++static SPINAND_OP_VARIANTS(read_cache_variants, ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(write_cache_variants, ++ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), ++ SPINAND_PROG_LOAD(true, 0, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(update_cache_variants, ++ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), ++ SPINAND_PROG_LOAD(false, 0, NULL, 0)); ++ ++static int fm25s01a_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ return -ERANGE; ++} ++ ++static int fm25s01a_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section) ++ return -ERANGE; ++ ++ region->offset = 2; ++ region->length = 62; ++ ++ return 0; ++} ++ ++static const struct mtd_ooblayout_ops fm25s01a_ooblayout = { ++ .ecc = fm25s01a_ooblayout_ecc, ++ .free = fm25s01a_ooblayout_free, ++}; ++ ++static const struct spinand_info fmsh_spinand_table[] = { ++ SPINAND_INFO("FM25S01A", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), ++ NAND_ECCREQ(1, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_HAS_QE_BIT, ++ SPINAND_ECCINFO(&fm25s01a_ooblayout, NULL)), ++}; ++ ++static const struct spinand_manufacturer_ops fmsh_spinand_manuf_ops = { ++}; ++ ++const struct spinand_manufacturer fmsh_spinand_manufacturer = { ++ .id = SPINAND_MFR_FMSH, ++ .name = "Fudan Micro", ++ .chips = fmsh_spinand_table, ++ .nchips = ARRAY_SIZE(fmsh_spinand_table), ++ .ops = &fmsh_spinand_manuf_ops, ++}; +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -263,6 +263,7 @@ struct spinand_manufacturer { + extern const struct spinand_manufacturer alliancememory_spinand_manufacturer; + extern const struct spinand_manufacturer ato_spinand_manufacturer; + extern const struct spinand_manufacturer esmt_c8_spinand_manufacturer; ++extern const struct spinand_manufacturer fmsh_spinand_manufacturer; + extern const struct spinand_manufacturer foresee_spinand_manufacturer; + extern const struct spinand_manufacturer gigadevice_spinand_manufacturer; + extern const struct spinand_manufacturer macronix_spinand_manufacturer; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/402-v6.18-mtd-nand-move-chunk-to-core.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/402-v6.18-mtd-nand-move-chunk-to-core.patch new file mode 100755 index 0000000..7933874 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/402-v6.18-mtd-nand-move-chunk-to-core.patch @@ -0,0 +1,329 @@ +From 6b88293aae7fb78872e5cc1ec36e2f750ae12e38 Mon Sep 17 00:00:00 2001 +From: Markus Stockhausen +Date: Wed, 10 Sep 2025 14:32:58 -0400 +Subject: mtd: nand: move nand_check_erased_ecc_chunk() to nand/core + +The check function for bitflips in erased blocks will be needed +by the Realtek ECC engine driver (which is currently under +development). Right now it is located in raw/nand_base.c. +While this is sufficient for the current usecases, there is +no real dependency for an ECC engine on the raw nand library. + +Move the function over to a more generic place in core library. + +Suggested-by: Miquel Raynal +Signed-off-by: Markus Stockhausen +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/core.c | 131 +++++++++++++++++++++++++++++++++++++++ + drivers/mtd/nand/raw/nand_base.c | 131 --------------------------------------- + include/linux/mtd/nand.h | 5 ++ + include/linux/mtd/rawnand.h | 5 -- + 4 files changed, 136 insertions(+), 136 deletions(-) + +--- a/drivers/mtd/nand/core.c ++++ b/drivers/mtd/nand/core.c +@@ -13,6 +13,137 @@ + #include + + /** ++ * nand_check_erased_buf - check if a buffer contains (almost) only 0xff data ++ * @buf: buffer to test ++ * @len: buffer length ++ * @bitflips_threshold: maximum number of bitflips ++ * ++ * Check if a buffer contains only 0xff, which means the underlying region ++ * has been erased and is ready to be programmed. ++ * The bitflips_threshold specify the maximum number of bitflips before ++ * considering the region is not erased. ++ * Note: The logic of this function has been extracted from the memweight ++ * implementation, except that nand_check_erased_buf function exit before ++ * testing the whole buffer if the number of bitflips exceed the ++ * bitflips_threshold value. ++ * ++ * Returns a positive number of bitflips less than or equal to ++ * bitflips_threshold, or -ERROR_CODE for bitflips in excess of the ++ * threshold. ++ */ ++static int nand_check_erased_buf(void *buf, int len, int bitflips_threshold) ++{ ++ const unsigned char *bitmap = buf; ++ int bitflips = 0; ++ int weight; ++ ++ for (; len && ((uintptr_t)bitmap) % sizeof(long); ++ len--, bitmap++) { ++ weight = hweight8(*bitmap); ++ bitflips += BITS_PER_BYTE - weight; ++ if (unlikely(bitflips > bitflips_threshold)) ++ return -EBADMSG; ++ } ++ ++ for (; len >= sizeof(long); ++ len -= sizeof(long), bitmap += sizeof(long)) { ++ unsigned long d = *((unsigned long *)bitmap); ++ if (d == ~0UL) ++ continue; ++ weight = hweight_long(d); ++ bitflips += BITS_PER_LONG - weight; ++ if (unlikely(bitflips > bitflips_threshold)) ++ return -EBADMSG; ++ } ++ ++ for (; len > 0; len--, bitmap++) { ++ weight = hweight8(*bitmap); ++ bitflips += BITS_PER_BYTE - weight; ++ if (unlikely(bitflips > bitflips_threshold)) ++ return -EBADMSG; ++ } ++ ++ return bitflips; ++} ++ ++/** ++ * nand_check_erased_ecc_chunk - check if an ECC chunk contains (almost) only ++ * 0xff data ++ * @data: data buffer to test ++ * @datalen: data length ++ * @ecc: ECC buffer ++ * @ecclen: ECC length ++ * @extraoob: extra OOB buffer ++ * @extraooblen: extra OOB length ++ * @bitflips_threshold: maximum number of bitflips ++ * ++ * Check if a data buffer and its associated ECC and OOB data contains only ++ * 0xff pattern, which means the underlying region has been erased and is ++ * ready to be programmed. ++ * The bitflips_threshold specify the maximum number of bitflips before ++ * considering the region as not erased. ++ * ++ * Note: ++ * 1/ ECC algorithms are working on pre-defined block sizes which are usually ++ * different from the NAND page size. When fixing bitflips, ECC engines will ++ * report the number of errors per chunk, and the NAND core infrastructure ++ * expect you to return the maximum number of bitflips for the whole page. ++ * This is why you should always use this function on a single chunk and ++ * not on the whole page. After checking each chunk you should update your ++ * max_bitflips value accordingly. ++ * 2/ When checking for bitflips in erased pages you should not only check ++ * the payload data but also their associated ECC data, because a user might ++ * have programmed almost all bits to 1 but a few. In this case, we ++ * shouldn't consider the chunk as erased, and checking ECC bytes prevent ++ * this case. ++ * 3/ The extraoob argument is optional, and should be used if some of your OOB ++ * data are protected by the ECC engine. ++ * It could also be used if you support subpages and want to attach some ++ * extra OOB data to an ECC chunk. ++ * ++ * Returns a positive number of bitflips less than or equal to ++ * bitflips_threshold, or -ERROR_CODE for bitflips in excess of the ++ * threshold. In case of success, the passed buffers are filled with 0xff. ++ */ ++int nand_check_erased_ecc_chunk(void *data, int datalen, ++ void *ecc, int ecclen, ++ void *extraoob, int extraooblen, ++ int bitflips_threshold) ++{ ++ int data_bitflips = 0, ecc_bitflips = 0, extraoob_bitflips = 0; ++ ++ data_bitflips = nand_check_erased_buf(data, datalen, ++ bitflips_threshold); ++ if (data_bitflips < 0) ++ return data_bitflips; ++ ++ bitflips_threshold -= data_bitflips; ++ ++ ecc_bitflips = nand_check_erased_buf(ecc, ecclen, bitflips_threshold); ++ if (ecc_bitflips < 0) ++ return ecc_bitflips; ++ ++ bitflips_threshold -= ecc_bitflips; ++ ++ extraoob_bitflips = nand_check_erased_buf(extraoob, extraooblen, ++ bitflips_threshold); ++ if (extraoob_bitflips < 0) ++ return extraoob_bitflips; ++ ++ if (data_bitflips) ++ memset(data, 0xff, datalen); ++ ++ if (ecc_bitflips) ++ memset(ecc, 0xff, ecclen); ++ ++ if (extraoob_bitflips) ++ memset(extraoob, 0xff, extraooblen); ++ ++ return data_bitflips + ecc_bitflips + extraoob_bitflips; ++} ++EXPORT_SYMBOL(nand_check_erased_ecc_chunk); ++ ++/** + * nanddev_isbad() - Check if a block is bad + * @nand: NAND device + * @pos: position pointing to the block we want to check +--- a/drivers/mtd/nand/raw/nand_base.c ++++ b/drivers/mtd/nand/raw/nand_base.c +@@ -2784,137 +2784,6 @@ int nand_set_features(struct nand_chip * + } + + /** +- * nand_check_erased_buf - check if a buffer contains (almost) only 0xff data +- * @buf: buffer to test +- * @len: buffer length +- * @bitflips_threshold: maximum number of bitflips +- * +- * Check if a buffer contains only 0xff, which means the underlying region +- * has been erased and is ready to be programmed. +- * The bitflips_threshold specify the maximum number of bitflips before +- * considering the region is not erased. +- * Note: The logic of this function has been extracted from the memweight +- * implementation, except that nand_check_erased_buf function exit before +- * testing the whole buffer if the number of bitflips exceed the +- * bitflips_threshold value. +- * +- * Returns a positive number of bitflips less than or equal to +- * bitflips_threshold, or -ERROR_CODE for bitflips in excess of the +- * threshold. +- */ +-static int nand_check_erased_buf(void *buf, int len, int bitflips_threshold) +-{ +- const unsigned char *bitmap = buf; +- int bitflips = 0; +- int weight; +- +- for (; len && ((uintptr_t)bitmap) % sizeof(long); +- len--, bitmap++) { +- weight = hweight8(*bitmap); +- bitflips += BITS_PER_BYTE - weight; +- if (unlikely(bitflips > bitflips_threshold)) +- return -EBADMSG; +- } +- +- for (; len >= sizeof(long); +- len -= sizeof(long), bitmap += sizeof(long)) { +- unsigned long d = *((unsigned long *)bitmap); +- if (d == ~0UL) +- continue; +- weight = hweight_long(d); +- bitflips += BITS_PER_LONG - weight; +- if (unlikely(bitflips > bitflips_threshold)) +- return -EBADMSG; +- } +- +- for (; len > 0; len--, bitmap++) { +- weight = hweight8(*bitmap); +- bitflips += BITS_PER_BYTE - weight; +- if (unlikely(bitflips > bitflips_threshold)) +- return -EBADMSG; +- } +- +- return bitflips; +-} +- +-/** +- * nand_check_erased_ecc_chunk - check if an ECC chunk contains (almost) only +- * 0xff data +- * @data: data buffer to test +- * @datalen: data length +- * @ecc: ECC buffer +- * @ecclen: ECC length +- * @extraoob: extra OOB buffer +- * @extraooblen: extra OOB length +- * @bitflips_threshold: maximum number of bitflips +- * +- * Check if a data buffer and its associated ECC and OOB data contains only +- * 0xff pattern, which means the underlying region has been erased and is +- * ready to be programmed. +- * The bitflips_threshold specify the maximum number of bitflips before +- * considering the region as not erased. +- * +- * Note: +- * 1/ ECC algorithms are working on pre-defined block sizes which are usually +- * different from the NAND page size. When fixing bitflips, ECC engines will +- * report the number of errors per chunk, and the NAND core infrastructure +- * expect you to return the maximum number of bitflips for the whole page. +- * This is why you should always use this function on a single chunk and +- * not on the whole page. After checking each chunk you should update your +- * max_bitflips value accordingly. +- * 2/ When checking for bitflips in erased pages you should not only check +- * the payload data but also their associated ECC data, because a user might +- * have programmed almost all bits to 1 but a few. In this case, we +- * shouldn't consider the chunk as erased, and checking ECC bytes prevent +- * this case. +- * 3/ The extraoob argument is optional, and should be used if some of your OOB +- * data are protected by the ECC engine. +- * It could also be used if you support subpages and want to attach some +- * extra OOB data to an ECC chunk. +- * +- * Returns a positive number of bitflips less than or equal to +- * bitflips_threshold, or -ERROR_CODE for bitflips in excess of the +- * threshold. In case of success, the passed buffers are filled with 0xff. +- */ +-int nand_check_erased_ecc_chunk(void *data, int datalen, +- void *ecc, int ecclen, +- void *extraoob, int extraooblen, +- int bitflips_threshold) +-{ +- int data_bitflips = 0, ecc_bitflips = 0, extraoob_bitflips = 0; +- +- data_bitflips = nand_check_erased_buf(data, datalen, +- bitflips_threshold); +- if (data_bitflips < 0) +- return data_bitflips; +- +- bitflips_threshold -= data_bitflips; +- +- ecc_bitflips = nand_check_erased_buf(ecc, ecclen, bitflips_threshold); +- if (ecc_bitflips < 0) +- return ecc_bitflips; +- +- bitflips_threshold -= ecc_bitflips; +- +- extraoob_bitflips = nand_check_erased_buf(extraoob, extraooblen, +- bitflips_threshold); +- if (extraoob_bitflips < 0) +- return extraoob_bitflips; +- +- if (data_bitflips) +- memset(data, 0xff, datalen); +- +- if (ecc_bitflips) +- memset(ecc, 0xff, ecclen); +- +- if (extraoob_bitflips) +- memset(extraoob, 0xff, extraooblen); +- +- return data_bitflips + ecc_bitflips + extraoob_bitflips; +-} +-EXPORT_SYMBOL(nand_check_erased_ecc_chunk); +- +-/** + * nand_read_page_raw_notsupp - dummy read raw page function + * @chip: nand chip info structure + * @buf: buffer to store read data +--- a/include/linux/mtd/nand.h ++++ b/include/linux/mtd/nand.h +@@ -1136,4 +1136,9 @@ static inline bool nanddev_bbt_is_initia + int nanddev_mtd_erase(struct mtd_info *mtd, struct erase_info *einfo); + int nanddev_mtd_max_bad_blocks(struct mtd_info *mtd, loff_t offs, size_t len); + ++int nand_check_erased_ecc_chunk(void *data, int datalen, ++ void *ecc, int ecclen, ++ void *extraoob, int extraooblen, ++ int threshold); ++ + #endif /* __LINUX_MTD_NAND_H */ +--- a/include/linux/mtd/rawnand.h ++++ b/include/linux/mtd/rawnand.h +@@ -1519,11 +1519,6 @@ int rawnand_sw_bch_correct(struct nand_c + unsigned char *read_ecc, unsigned char *calc_ecc); + void rawnand_sw_bch_cleanup(struct nand_chip *chip); + +-int nand_check_erased_ecc_chunk(void *data, int datalen, +- void *ecc, int ecclen, +- void *extraoob, int extraooblen, +- int threshold); +- + int nand_ecc_choose_conf(struct nand_chip *chip, + const struct nand_ecc_caps *caps, int oobavail); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/404-v6.19-mtd-spinand-fmsh-remove-QE-bit-for-FM25S01A-flash.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/404-v6.19-mtd-spinand-fmsh-remove-QE-bit-for-FM25S01A-flash.patch new file mode 100755 index 0000000..7f9ec6a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/404-v6.19-mtd-spinand-fmsh-remove-QE-bit-for-FM25S01A-flash.patch @@ -0,0 +1,28 @@ +From a1d3bc606bf5c3b3ea811cc2019df6285d75b00f Mon Sep 17 00:00:00 2001 +From: Mikhail Kshevetskiy +Date: Mon, 3 Nov 2025 04:01:48 +0300 +Subject: [PATCH] mtd: spinand: fmsh: remove QE bit for FM25S01A flash + +According to datasheet (http://eng.fmsh.com/nvm/FM25S01A_ds_eng.pdf) +there is no QE (Quad Enable) bit for FM25S01A flash, so remove it. + +Fixes: 5f284dc15ca86 ("mtd: spinand: add support for FudanMicro FM25S01A") +Signed-off-by: Mikhail Kshevetskiy +Tested-by: Tianling Shen +Signed-off-by: Miquel Raynal +Link: Link: https://lore.kernel.org/linux-mtd/176216634975.908445.2776312239779833518.b4-ty@bootlin.com +--- + drivers/mtd/nand/spi/fmsh.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/nand/spi/fmsh.c ++++ b/drivers/mtd/nand/spi/fmsh.c +@@ -58,7 +58,7 @@ static const struct spinand_info fmsh_sp + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), +- SPINAND_HAS_QE_BIT, ++ 0, + SPINAND_ECCINFO(&fm25s01a_ooblayout, NULL)), + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-01-v6.14-mtd-rawnand-qcom-cleanup-qcom_nandc-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-01-v6.14-mtd-rawnand-qcom-cleanup-qcom_nandc-driver.patch new file mode 100755 index 0000000..1d1288e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-01-v6.14-mtd-rawnand-qcom-cleanup-qcom_nandc-driver.patch @@ -0,0 +1,1026 @@ +From 8c52932da5e6756fa66f52f0720da283fba13aa6 Mon Sep 17 00:00:00 2001 +From: Md Sadre Alam +Date: Wed, 20 Nov 2024 14:45:00 +0530 +Subject: [PATCH 1/4] mtd: rawnand: qcom: cleanup qcom_nandc driver + +Perform a global cleanup of the Qualcomm NAND +controller driver with the following improvements: + +- Remove register value indirection API + +- Remove set_reg() API + +- Convert read_loc_first & read_loc_last macro to functions + +- Rename multiple variables + +Signed-off-by: Md Sadre Alam +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/raw/qcom_nandc.c | 516 ++++++++++++++---------------- + 1 file changed, 234 insertions(+), 282 deletions(-) + +--- a/drivers/mtd/nand/raw/qcom_nandc.c ++++ b/drivers/mtd/nand/raw/qcom_nandc.c +@@ -189,17 +189,6 @@ + #define ECC_BCH_4BIT BIT(2) + #define ECC_BCH_8BIT BIT(3) + +-#define nandc_set_read_loc_first(chip, reg, cw_offset, read_size, is_last_read_loc) \ +-nandc_set_reg(chip, reg, \ +- ((cw_offset) << READ_LOCATION_OFFSET) | \ +- ((read_size) << READ_LOCATION_SIZE) | \ +- ((is_last_read_loc) << READ_LOCATION_LAST)) +- +-#define nandc_set_read_loc_last(chip, reg, cw_offset, read_size, is_last_read_loc) \ +-nandc_set_reg(chip, reg, \ +- ((cw_offset) << READ_LOCATION_OFFSET) | \ +- ((read_size) << READ_LOCATION_SIZE) | \ +- ((is_last_read_loc) << READ_LOCATION_LAST)) + /* + * Returns the actual register address for all NAND_DEV_ registers + * (i.e. NAND_DEV_CMD0, NAND_DEV_CMD1, NAND_DEV_CMD2 and NAND_DEV_CMD_VLD) +@@ -257,8 +246,6 @@ nandc_set_reg(chip, reg, \ + * @tx_sgl_start - start index in data sgl for tx. + * @rx_sgl_pos - current index in data sgl for rx. + * @rx_sgl_start - start index in data sgl for rx. +- * @wait_second_completion - wait for second DMA desc completion before making +- * the NAND transfer completion. + */ + struct bam_transaction { + struct bam_cmd_element *bam_ce; +@@ -275,7 +262,6 @@ struct bam_transaction { + u32 tx_sgl_start; + u32 rx_sgl_pos; + u32 rx_sgl_start; +- bool wait_second_completion; + }; + + /* +@@ -471,9 +457,9 @@ struct qcom_op { + unsigned int data_instr_idx; + unsigned int rdy_timeout_ms; + unsigned int rdy_delay_ns; +- u32 addr1_reg; +- u32 addr2_reg; +- u32 cmd_reg; ++ __le32 addr1_reg; ++ __le32 addr2_reg; ++ __le32 cmd_reg; + u8 flag; + }; + +@@ -549,17 +535,17 @@ struct qcom_nand_host { + * among different NAND controllers. + * @ecc_modes - ecc mode for NAND + * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset +- * @is_bam - whether NAND controller is using BAM +- * @is_qpic - whether NAND CTRL is part of qpic IP +- * @qpic_v2 - flag to indicate QPIC IP version 2 ++ * @supports_bam - whether NAND controller is using Bus Access Manager (BAM) ++ * @nandc_part_of_qpic - whether NAND controller is part of qpic IP ++ * @qpic_version2 - flag to indicate QPIC IP version 2 + * @use_codeword_fixup - whether NAND has different layout for boot partitions + */ + struct qcom_nandc_props { + u32 ecc_modes; + u32 dev_cmd_reg_start; +- bool is_bam; +- bool is_qpic; +- bool qpic_v2; ++ bool supports_bam; ++ bool nandc_part_of_qpic; ++ bool qpic_version2; + bool use_codeword_fixup; + }; + +@@ -613,19 +599,11 @@ static void clear_bam_transaction(struct + { + struct bam_transaction *bam_txn = nandc->bam_txn; + +- if (!nandc->props->is_bam) ++ if (!nandc->props->supports_bam) + return; + +- bam_txn->bam_ce_pos = 0; +- bam_txn->bam_ce_start = 0; +- bam_txn->cmd_sgl_pos = 0; +- bam_txn->cmd_sgl_start = 0; +- bam_txn->tx_sgl_pos = 0; +- bam_txn->tx_sgl_start = 0; +- bam_txn->rx_sgl_pos = 0; +- bam_txn->rx_sgl_start = 0; ++ memset(&bam_txn->bam_ce_pos, 0, sizeof(u32) * 8); + bam_txn->last_data_desc = NULL; +- bam_txn->wait_second_completion = false; + + sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage * + QPIC_PER_CW_CMD_SGL); +@@ -640,46 +618,35 @@ static void qpic_bam_dma_done(void *data + { + struct bam_transaction *bam_txn = data; + +- /* +- * In case of data transfer with NAND, 2 callbacks will be generated. +- * One for command channel and another one for data channel. +- * If current transaction has data descriptors +- * (i.e. wait_second_completion is true), then set this to false +- * and wait for second DMA descriptor completion. +- */ +- if (bam_txn->wait_second_completion) +- bam_txn->wait_second_completion = false; +- else +- complete(&bam_txn->txn_done); ++ complete(&bam_txn->txn_done); + } + +-static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip) ++static struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip) + { + return container_of(chip, struct qcom_nand_host, chip); + } + +-static inline struct qcom_nand_controller * ++static struct qcom_nand_controller * + get_qcom_nand_controller(struct nand_chip *chip) + { + return container_of(chip->controller, struct qcom_nand_controller, + controller); + } + +-static inline u32 nandc_read(struct qcom_nand_controller *nandc, int offset) ++static u32 nandc_read(struct qcom_nand_controller *nandc, int offset) + { + return ioread32(nandc->base + offset); + } + +-static inline void nandc_write(struct qcom_nand_controller *nandc, int offset, +- u32 val) ++static void nandc_write(struct qcom_nand_controller *nandc, int offset, ++ u32 val) + { + iowrite32(val, nandc->base + offset); + } + +-static inline void nandc_read_buffer_sync(struct qcom_nand_controller *nandc, +- bool is_cpu) ++static void nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu) + { +- if (!nandc->props->is_bam) ++ if (!nandc->props->supports_bam) + return; + + if (is_cpu) +@@ -694,93 +661,90 @@ static inline void nandc_read_buffer_syn + DMA_FROM_DEVICE); + } + +-static __le32 *offset_to_nandc_reg(struct nandc_regs *regs, int offset) +-{ +- switch (offset) { +- case NAND_FLASH_CMD: +- return ®s->cmd; +- case NAND_ADDR0: +- return ®s->addr0; +- case NAND_ADDR1: +- return ®s->addr1; +- case NAND_FLASH_CHIP_SELECT: +- return ®s->chip_sel; +- case NAND_EXEC_CMD: +- return ®s->exec; +- case NAND_FLASH_STATUS: +- return ®s->clrflashstatus; +- case NAND_DEV0_CFG0: +- return ®s->cfg0; +- case NAND_DEV0_CFG1: +- return ®s->cfg1; +- case NAND_DEV0_ECC_CFG: +- return ®s->ecc_bch_cfg; +- case NAND_READ_STATUS: +- return ®s->clrreadstatus; +- case NAND_DEV_CMD1: +- return ®s->cmd1; +- case NAND_DEV_CMD1_RESTORE: +- return ®s->orig_cmd1; +- case NAND_DEV_CMD_VLD: +- return ®s->vld; +- case NAND_DEV_CMD_VLD_RESTORE: +- return ®s->orig_vld; +- case NAND_EBI2_ECC_BUF_CFG: +- return ®s->ecc_buf_cfg; +- case NAND_READ_LOCATION_0: +- return ®s->read_location0; +- case NAND_READ_LOCATION_1: +- return ®s->read_location1; +- case NAND_READ_LOCATION_2: +- return ®s->read_location2; +- case NAND_READ_LOCATION_3: +- return ®s->read_location3; +- case NAND_READ_LOCATION_LAST_CW_0: +- return ®s->read_location_last0; +- case NAND_READ_LOCATION_LAST_CW_1: +- return ®s->read_location_last1; +- case NAND_READ_LOCATION_LAST_CW_2: +- return ®s->read_location_last2; +- case NAND_READ_LOCATION_LAST_CW_3: +- return ®s->read_location_last3; +- default: +- return NULL; +- } +-} +- +-static void nandc_set_reg(struct nand_chip *chip, int offset, +- u32 val) +-{ +- struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); +- struct nandc_regs *regs = nandc->regs; +- __le32 *reg; +- +- reg = offset_to_nandc_reg(regs, offset); +- +- if (reg) +- *reg = cpu_to_le32(val); +-} +- +-/* Helper to check the code word, whether it is last cw or not */ ++/* Helper to check whether this is the last CW or not */ + static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw) + { + return cw == (ecc->steps - 1); + } + ++/** ++ * nandc_set_read_loc_first() - to set read location first register ++ * @chip: NAND Private Flash Chip Data ++ * @reg_base: location register base ++ * @cw_offset: code word offset ++ * @read_size: code word read length ++ * @is_last_read_loc: is this the last read location ++ * ++ * This function will set location register value ++ */ ++static void nandc_set_read_loc_first(struct nand_chip *chip, ++ int reg_base, u32 cw_offset, ++ u32 read_size, u32 is_last_read_loc) ++{ ++ struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); ++ __le32 locreg_val; ++ u32 val = (((cw_offset) << READ_LOCATION_OFFSET) | ++ ((read_size) << READ_LOCATION_SIZE) | ++ ((is_last_read_loc) << READ_LOCATION_LAST)); ++ ++ locreg_val = cpu_to_le32(val); ++ ++ if (reg_base == NAND_READ_LOCATION_0) ++ nandc->regs->read_location0 = locreg_val; ++ else if (reg_base == NAND_READ_LOCATION_1) ++ nandc->regs->read_location1 = locreg_val; ++ else if (reg_base == NAND_READ_LOCATION_2) ++ nandc->regs->read_location2 = locreg_val; ++ else if (reg_base == NAND_READ_LOCATION_3) ++ nandc->regs->read_location3 = locreg_val; ++} ++ ++/** ++ * nandc_set_read_loc_last - to set read location last register ++ * @chip: NAND Private Flash Chip Data ++ * @reg_base: location register base ++ * @cw_offset: code word offset ++ * @read_size: code word read length ++ * @is_last_read_loc: is this the last read location ++ * ++ * This function will set location last register value ++ */ ++static void nandc_set_read_loc_last(struct nand_chip *chip, ++ int reg_base, u32 cw_offset, ++ u32 read_size, u32 is_last_read_loc) ++{ ++ struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); ++ __le32 locreg_val; ++ u32 val = (((cw_offset) << READ_LOCATION_OFFSET) | ++ ((read_size) << READ_LOCATION_SIZE) | ++ ((is_last_read_loc) << READ_LOCATION_LAST)); ++ ++ locreg_val = cpu_to_le32(val); ++ ++ if (reg_base == NAND_READ_LOCATION_LAST_CW_0) ++ nandc->regs->read_location_last0 = locreg_val; ++ else if (reg_base == NAND_READ_LOCATION_LAST_CW_1) ++ nandc->regs->read_location_last1 = locreg_val; ++ else if (reg_base == NAND_READ_LOCATION_LAST_CW_2) ++ nandc->regs->read_location_last2 = locreg_val; ++ else if (reg_base == NAND_READ_LOCATION_LAST_CW_3) ++ nandc->regs->read_location_last3 = locreg_val; ++} ++ + /* helper to configure location register values */ + static void nandc_set_read_loc(struct nand_chip *chip, int cw, int reg, +- int cw_offset, int read_size, int is_last_read_loc) ++ u32 cw_offset, u32 read_size, u32 is_last_read_loc) + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + struct nand_ecc_ctrl *ecc = &chip->ecc; + int reg_base = NAND_READ_LOCATION_0; + +- if (nandc->props->qpic_v2 && qcom_nandc_is_last_cw(ecc, cw)) ++ if (nandc->props->qpic_version2 && qcom_nandc_is_last_cw(ecc, cw)) + reg_base = NAND_READ_LOCATION_LAST_CW_0; + + reg_base += reg * 4; + +- if (nandc->props->qpic_v2 && qcom_nandc_is_last_cw(ecc, cw)) ++ if (nandc->props->qpic_version2 && qcom_nandc_is_last_cw(ecc, cw)) + return nandc_set_read_loc_last(chip, reg_base, cw_offset, + read_size, is_last_read_loc); + else +@@ -792,12 +756,13 @@ static void nandc_set_read_loc(struct na + static void set_address(struct qcom_nand_host *host, u16 column, int page) + { + struct nand_chip *chip = &host->chip; ++ struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + + if (chip->options & NAND_BUSWIDTH_16) + column >>= 1; + +- nandc_set_reg(chip, NAND_ADDR0, page << 16 | column); +- nandc_set_reg(chip, NAND_ADDR1, page >> 16 & 0xff); ++ nandc->regs->addr0 = cpu_to_le32(page << 16 | column); ++ nandc->regs->addr1 = cpu_to_le32(page >> 16 & 0xff); + } + + /* +@@ -811,41 +776,43 @@ static void set_address(struct qcom_nand + static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read, int cw) + { + struct nand_chip *chip = &host->chip; +- u32 cmd, cfg0, cfg1, ecc_bch_cfg; ++ __le32 cmd, cfg0, cfg1, ecc_bch_cfg; + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + + if (read) { + if (host->use_ecc) +- cmd = OP_PAGE_READ_WITH_ECC | PAGE_ACC | LAST_PAGE; ++ cmd = cpu_to_le32(OP_PAGE_READ_WITH_ECC | PAGE_ACC | LAST_PAGE); + else +- cmd = OP_PAGE_READ | PAGE_ACC | LAST_PAGE; ++ cmd = cpu_to_le32(OP_PAGE_READ | PAGE_ACC | LAST_PAGE); + } else { +- cmd = OP_PROGRAM_PAGE | PAGE_ACC | LAST_PAGE; ++ cmd = cpu_to_le32(OP_PROGRAM_PAGE | PAGE_ACC | LAST_PAGE); + } + + if (host->use_ecc) { +- cfg0 = (host->cfg0 & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = cpu_to_le32((host->cfg0 & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE); + +- cfg1 = host->cfg1; +- ecc_bch_cfg = host->ecc_bch_cfg; ++ cfg1 = cpu_to_le32(host->cfg1); ++ ecc_bch_cfg = cpu_to_le32(host->ecc_bch_cfg); + } else { +- cfg0 = (host->cfg0_raw & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = cpu_to_le32((host->cfg0_raw & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE); + +- cfg1 = host->cfg1_raw; +- ecc_bch_cfg = 1 << ECC_CFG_ECC_DISABLE; ++ cfg1 = cpu_to_le32(host->cfg1_raw); ++ ecc_bch_cfg = cpu_to_le32(1 << ECC_CFG_ECC_DISABLE); + } + +- nandc_set_reg(chip, NAND_FLASH_CMD, cmd); +- nandc_set_reg(chip, NAND_DEV0_CFG0, cfg0); +- nandc_set_reg(chip, NAND_DEV0_CFG1, cfg1); +- nandc_set_reg(chip, NAND_DEV0_ECC_CFG, ecc_bch_cfg); +- if (!nandc->props->qpic_v2) +- nandc_set_reg(chip, NAND_EBI2_ECC_BUF_CFG, host->ecc_buf_cfg); +- nandc_set_reg(chip, NAND_FLASH_STATUS, host->clrflashstatus); +- nandc_set_reg(chip, NAND_READ_STATUS, host->clrreadstatus); +- nandc_set_reg(chip, NAND_EXEC_CMD, 1); ++ nandc->regs->cmd = cmd; ++ nandc->regs->cfg0 = cfg0; ++ nandc->regs->cfg1 = cfg1; ++ nandc->regs->ecc_bch_cfg = ecc_bch_cfg; ++ ++ if (!nandc->props->qpic_version2) ++ nandc->regs->ecc_buf_cfg = cpu_to_le32(host->ecc_buf_cfg); ++ ++ nandc->regs->clrflashstatus = cpu_to_le32(host->clrflashstatus); ++ nandc->regs->clrreadstatus = cpu_to_le32(host->clrreadstatus); ++ nandc->regs->exec = cpu_to_le32(1); + + if (read) + nandc_set_read_loc(chip, cw, 0, 0, host->use_ecc ? +@@ -1121,7 +1088,7 @@ static int read_reg_dma(struct qcom_nand + if (first == NAND_DEV_CMD_VLD || first == NAND_DEV_CMD1) + first = dev_cmd_reg_addr(nandc, first); + +- if (nandc->props->is_bam) ++ if (nandc->props->supports_bam) + return prep_bam_dma_desc_cmd(nandc, true, first, vaddr, + num_regs, flags); + +@@ -1136,25 +1103,16 @@ static int read_reg_dma(struct qcom_nand + * write_reg_dma: prepares a descriptor to write a given number of + * contiguous registers + * ++ * @vaddr: contiguous memory from where register value will ++ * be written + * @first: offset of the first register in the contiguous block + * @num_regs: number of registers to write + * @flags: flags to control DMA descriptor preparation + */ +-static int write_reg_dma(struct qcom_nand_controller *nandc, int first, +- int num_regs, unsigned int flags) ++static int write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, ++ int first, int num_regs, unsigned int flags) + { + bool flow_control = false; +- struct nandc_regs *regs = nandc->regs; +- void *vaddr; +- +- vaddr = offset_to_nandc_reg(regs, first); +- +- if (first == NAND_ERASED_CW_DETECT_CFG) { +- if (flags & NAND_ERASED_CW_SET) +- vaddr = ®s->erased_cw_detect_cfg_set; +- else +- vaddr = ®s->erased_cw_detect_cfg_clr; +- } + + if (first == NAND_EXEC_CMD) + flags |= NAND_BAM_NWD; +@@ -1165,7 +1123,7 @@ static int write_reg_dma(struct qcom_nan + if (first == NAND_DEV_CMD_VLD_RESTORE || first == NAND_DEV_CMD_VLD) + first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD); + +- if (nandc->props->is_bam) ++ if (nandc->props->supports_bam) + return prep_bam_dma_desc_cmd(nandc, false, first, vaddr, + num_regs, flags); + +@@ -1188,7 +1146,7 @@ static int write_reg_dma(struct qcom_nan + static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off, + const u8 *vaddr, int size, unsigned int flags) + { +- if (nandc->props->is_bam) ++ if (nandc->props->supports_bam) + return prep_bam_dma_desc_data(nandc, true, vaddr, size, flags); + + return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false); +@@ -1206,7 +1164,7 @@ static int read_data_dma(struct qcom_nan + static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off, + const u8 *vaddr, int size, unsigned int flags) + { +- if (nandc->props->is_bam) ++ if (nandc->props->supports_bam) + return prep_bam_dma_desc_data(nandc, false, vaddr, size, flags); + + return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false); +@@ -1220,13 +1178,14 @@ static void config_nand_page_read(struct + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + +- write_reg_dma(nandc, NAND_ADDR0, 2, 0); +- write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0); +- if (!nandc->props->qpic_v2) +- write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0); +- write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, 0); +- write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, +- NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0); ++ write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ if (!nandc->props->qpic_version2) ++ write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, 0); ++ write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_clr, ++ NAND_ERASED_CW_DETECT_CFG, 1, 0); ++ write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_set, ++ NAND_ERASED_CW_DETECT_CFG, 1, NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); + } + + /* +@@ -1239,16 +1198,16 @@ config_nand_cw_read(struct nand_chip *ch + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + struct nand_ecc_ctrl *ecc = &chip->ecc; + +- int reg = NAND_READ_LOCATION_0; ++ __le32 *reg = &nandc->regs->read_location0; + +- if (nandc->props->qpic_v2 && qcom_nandc_is_last_cw(ecc, cw)) +- reg = NAND_READ_LOCATION_LAST_CW_0; ++ if (nandc->props->qpic_version2 && qcom_nandc_is_last_cw(ecc, cw)) ++ reg = &nandc->regs->read_location_last0; + +- if (nandc->props->is_bam) +- write_reg_dma(nandc, reg, 4, NAND_BAM_NEXT_SGL); ++ if (nandc->props->supports_bam) ++ write_reg_dma(nandc, reg, NAND_READ_LOCATION_0, 4, NAND_BAM_NEXT_SGL); + +- write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + + if (use_ecc) { + read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0); +@@ -1279,10 +1238,10 @@ static void config_nand_page_write(struc + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + +- write_reg_dma(nandc, NAND_ADDR0, 2, 0); +- write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0); +- if (!nandc->props->qpic_v2) +- write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, ++ write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0); ++ write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ if (!nandc->props->qpic_version2) ++ write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, + NAND_BAM_NEXT_SGL); + } + +@@ -1294,13 +1253,13 @@ static void config_nand_cw_write(struct + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + +- write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + + read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + +- write_reg_dma(nandc, NAND_FLASH_STATUS, 1, 0); +- write_reg_dma(nandc, NAND_READ_STATUS, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->clrflashstatus, NAND_FLASH_STATUS, 1, 0); ++ write_reg_dma(nandc, &nandc->regs->clrreadstatus, NAND_READ_STATUS, 1, NAND_BAM_NEXT_SGL); + } + + /* helpers to submit/free our list of dma descriptors */ +@@ -1311,7 +1270,7 @@ static int submit_descs(struct qcom_nand + struct bam_transaction *bam_txn = nandc->bam_txn; + int ret = 0; + +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + if (bam_txn->rx_sgl_pos > bam_txn->rx_sgl_start) { + ret = prepare_bam_async_desc(nandc, nandc->rx_chan, 0); + if (ret) +@@ -1336,14 +1295,9 @@ static int submit_descs(struct qcom_nand + list_for_each_entry(desc, &nandc->desc_list, node) + cookie = dmaengine_submit(desc->dma_desc); + +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + bam_txn->last_cmd_desc->callback = qpic_bam_dma_done; + bam_txn->last_cmd_desc->callback_param = bam_txn; +- if (bam_txn->last_data_desc) { +- bam_txn->last_data_desc->callback = qpic_bam_dma_done; +- bam_txn->last_data_desc->callback_param = bam_txn; +- bam_txn->wait_second_completion = true; +- } + + dma_async_issue_pending(nandc->tx_chan); + dma_async_issue_pending(nandc->rx_chan); +@@ -1365,7 +1319,7 @@ err_unmap_free_desc: + list_for_each_entry_safe(desc, n, &nandc->desc_list, node) { + list_del(&desc->node); + +- if (nandc->props->is_bam) ++ if (nandc->props->supports_bam) + dma_unmap_sg(nandc->dev, desc->bam_sgl, + desc->sgl_cnt, desc->dir); + else +@@ -1382,7 +1336,7 @@ err_unmap_free_desc: + static void clear_read_regs(struct qcom_nand_controller *nandc) + { + nandc->reg_read_pos = 0; +- nandc_read_buffer_sync(nandc, false); ++ nandc_dev_to_mem(nandc, false); + } + + /* +@@ -1446,7 +1400,7 @@ static int check_flash_errors(struct qco + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + int i; + +- nandc_read_buffer_sync(nandc, true); ++ nandc_dev_to_mem(nandc, true); + + for (i = 0; i < cw_cnt; i++) { + u32 flash = le32_to_cpu(nandc->reg_read_buf[i]); +@@ -1476,7 +1430,7 @@ qcom_nandc_read_cw_raw(struct mtd_info * + clear_read_regs(nandc); + host->use_ecc = false; + +- if (nandc->props->qpic_v2) ++ if (nandc->props->qpic_version2) + raw_cw = ecc->steps - 1; + + clear_bam_transaction(nandc); +@@ -1497,7 +1451,7 @@ qcom_nandc_read_cw_raw(struct mtd_info * + oob_size2 = host->ecc_bytes_hw + host->spare_bytes; + } + +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + nandc_set_read_loc(chip, cw, 0, read_loc, data_size1, 0); + read_loc += data_size1; + +@@ -1621,7 +1575,7 @@ static int parse_read_errors(struct qcom + u8 *data_buf_start = data_buf, *oob_buf_start = oob_buf; + + buf = (struct read_stats *)nandc->reg_read_buf; +- nandc_read_buffer_sync(nandc, true); ++ nandc_dev_to_mem(nandc, true); + + for (i = 0; i < ecc->steps; i++, buf++) { + u32 flash, buffer, erased_cw; +@@ -1734,7 +1688,7 @@ static int read_page_ecc(struct qcom_nan + oob_size = host->ecc_bytes_hw + host->spare_bytes; + } + +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + if (data_buf && oob_buf) { + nandc_set_read_loc(chip, i, 0, 0, data_size, 0); + nandc_set_read_loc(chip, i, 1, data_size, +@@ -2455,14 +2409,14 @@ static int qcom_nand_attach_chip(struct + + mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops); + /* Free the initially allocated BAM transaction for reading the ONFI params */ +- if (nandc->props->is_bam) ++ if (nandc->props->supports_bam) + free_bam_transaction(nandc); + + nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage, + cwperpage); + + /* Now allocate the BAM transaction based on updated max_cwperpage */ +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + nandc->bam_txn = alloc_bam_transaction(nandc); + if (!nandc->bam_txn) { + dev_err(nandc->dev, +@@ -2522,7 +2476,7 @@ static int qcom_nand_attach_chip(struct + | ecc_mode << ECC_MODE + | host->ecc_bytes_hw << ECC_PARITY_SIZE_BYTES_BCH; + +- if (!nandc->props->qpic_v2) ++ if (!nandc->props->qpic_version2) + host->ecc_buf_cfg = 0x203 << NUM_STEPS; + + host->clrflashstatus = FS_READY_BSY_N; +@@ -2556,7 +2510,7 @@ static int qcom_op_cmd_mapping(struct na + cmd = OP_FETCH_ID; + break; + case NAND_CMD_PARAM: +- if (nandc->props->qpic_v2) ++ if (nandc->props->qpic_version2) + cmd = OP_PAGE_READ_ONFI_READ; + else + cmd = OP_PAGE_READ; +@@ -2609,7 +2563,7 @@ static int qcom_parse_instructions(struc + if (ret < 0) + return ret; + +- q_op->cmd_reg = ret; ++ q_op->cmd_reg = cpu_to_le32(ret); + q_op->rdy_delay_ns = instr->delay_ns; + break; + +@@ -2619,10 +2573,10 @@ static int qcom_parse_instructions(struc + addrs = &instr->ctx.addr.addrs[offset]; + + for (i = 0; i < min_t(unsigned int, 4, naddrs); i++) +- q_op->addr1_reg |= addrs[i] << (i * 8); ++ q_op->addr1_reg |= cpu_to_le32(addrs[i] << (i * 8)); + + if (naddrs > 4) +- q_op->addr2_reg |= addrs[4]; ++ q_op->addr2_reg |= cpu_to_le32(addrs[4]); + + q_op->rdy_delay_ns = instr->delay_ns; + break; +@@ -2663,7 +2617,7 @@ static int qcom_wait_rdy_poll(struct nan + unsigned long start = jiffies + msecs_to_jiffies(time_ms); + u32 flash; + +- nandc_read_buffer_sync(nandc, true); ++ nandc_dev_to_mem(nandc, true); + + do { + flash = le32_to_cpu(nandc->reg_read_buf[0]); +@@ -2706,11 +2660,11 @@ static int qcom_read_status_exec(struct + clear_read_regs(nandc); + clear_bam_transaction(nandc); + +- nandc_set_reg(chip, NAND_FLASH_CMD, q_op.cmd_reg); +- nandc_set_reg(chip, NAND_EXEC_CMD, 1); ++ nandc->regs->cmd = q_op.cmd_reg; ++ nandc->regs->exec = cpu_to_le32(1); + +- write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + + ret = submit_descs(nandc); +@@ -2719,7 +2673,7 @@ static int qcom_read_status_exec(struct + goto err_out; + } + +- nandc_read_buffer_sync(nandc, true); ++ nandc_dev_to_mem(nandc, true); + + for (i = 0; i < num_cw; i++) { + flash_status = le32_to_cpu(nandc->reg_read_buf[i]); +@@ -2763,16 +2717,14 @@ static int qcom_read_id_type_exec(struct + clear_read_regs(nandc); + clear_bam_transaction(nandc); + +- nandc_set_reg(chip, NAND_FLASH_CMD, q_op.cmd_reg); +- nandc_set_reg(chip, NAND_ADDR0, q_op.addr1_reg); +- nandc_set_reg(chip, NAND_ADDR1, q_op.addr2_reg); +- nandc_set_reg(chip, NAND_FLASH_CHIP_SELECT, +- nandc->props->is_bam ? 0 : DM_EN); ++ nandc->regs->cmd = q_op.cmd_reg; ++ nandc->regs->addr0 = q_op.addr1_reg; ++ nandc->regs->addr1 = q_op.addr2_reg; ++ nandc->regs->chip_sel = cpu_to_le32(nandc->props->supports_bam ? 0 : DM_EN); ++ nandc->regs->exec = cpu_to_le32(1); + +- nandc_set_reg(chip, NAND_EXEC_CMD, 1); +- +- write_reg_dma(nandc, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + + read_reg_dma(nandc, NAND_READ_ID, 1, NAND_BAM_NEXT_SGL); + +@@ -2786,7 +2738,7 @@ static int qcom_read_id_type_exec(struct + op_id = q_op.data_instr_idx; + len = nand_subop_get_data_len(subop, op_id); + +- nandc_read_buffer_sync(nandc, true); ++ nandc_dev_to_mem(nandc, true); + memcpy(instr->ctx.data.buf.in, nandc->reg_read_buf, len); + + err_out: +@@ -2807,15 +2759,14 @@ static int qcom_misc_cmd_type_exec(struc + + if (q_op.flag == OP_PROGRAM_PAGE) { + goto wait_rdy; +- } else if (q_op.cmd_reg == OP_BLOCK_ERASE) { +- q_op.cmd_reg |= PAGE_ACC | LAST_PAGE; +- nandc_set_reg(chip, NAND_ADDR0, q_op.addr1_reg); +- nandc_set_reg(chip, NAND_ADDR1, q_op.addr2_reg); +- nandc_set_reg(chip, NAND_DEV0_CFG0, +- host->cfg0_raw & ~(7 << CW_PER_PAGE)); +- nandc_set_reg(chip, NAND_DEV0_CFG1, host->cfg1_raw); ++ } else if (q_op.cmd_reg == cpu_to_le32(OP_BLOCK_ERASE)) { ++ q_op.cmd_reg |= cpu_to_le32(PAGE_ACC | LAST_PAGE); ++ nandc->regs->addr0 = q_op.addr1_reg; ++ nandc->regs->addr1 = q_op.addr2_reg; ++ nandc->regs->cfg0 = cpu_to_le32(host->cfg0_raw & ~(7 << CW_PER_PAGE)); ++ nandc->regs->cfg1 = cpu_to_le32(host->cfg1_raw); + instrs = 3; +- } else if (q_op.cmd_reg != OP_RESET_DEVICE) { ++ } else if (q_op.cmd_reg != cpu_to_le32(OP_RESET_DEVICE)) { + return 0; + } + +@@ -2826,14 +2777,14 @@ static int qcom_misc_cmd_type_exec(struc + clear_read_regs(nandc); + clear_bam_transaction(nandc); + +- nandc_set_reg(chip, NAND_FLASH_CMD, q_op.cmd_reg); +- nandc_set_reg(chip, NAND_EXEC_CMD, 1); ++ nandc->regs->cmd = q_op.cmd_reg; ++ nandc->regs->exec = cpu_to_le32(1); + +- write_reg_dma(nandc, NAND_FLASH_CMD, instrs, NAND_BAM_NEXT_SGL); +- if (q_op.cmd_reg == OP_BLOCK_ERASE) +- write_reg_dma(nandc, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, instrs, NAND_BAM_NEXT_SGL); ++ if (q_op.cmd_reg == cpu_to_le32(OP_BLOCK_ERASE)) ++ write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); + +- write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + + ret = submit_descs(nandc); +@@ -2862,14 +2813,14 @@ static int qcom_param_page_type_exec(str + + reg_base = NAND_READ_LOCATION_0; + +- if (nandc->props->qpic_v2) ++ if (nandc->props->qpic_version2) + reg_base = NAND_READ_LOCATION_LAST_CW_0; + + ret = qcom_parse_instructions(chip, subop, &q_op); + if (ret) + return ret; + +- q_op.cmd_reg |= PAGE_ACC | LAST_PAGE; ++ q_op.cmd_reg |= cpu_to_le32(PAGE_ACC | LAST_PAGE); + + nandc->buf_count = 0; + nandc->buf_start = 0; +@@ -2877,52 +2828,52 @@ static int qcom_param_page_type_exec(str + clear_read_regs(nandc); + clear_bam_transaction(nandc); + +- nandc_set_reg(chip, NAND_FLASH_CMD, q_op.cmd_reg); ++ nandc->regs->cmd = q_op.cmd_reg; ++ nandc->regs->addr0 = 0; ++ nandc->regs->addr1 = 0; ++ ++ nandc->regs->cfg0 = cpu_to_le32(0 << CW_PER_PAGE | ++ 512 << UD_SIZE_BYTES | ++ 5 << NUM_ADDR_CYCLES | ++ 0 << SPARE_SIZE_BYTES); ++ ++ nandc->regs->cfg1 = cpu_to_le32(7 << NAND_RECOVERY_CYCLES | ++ 0 << CS_ACTIVE_BSY | ++ 17 << BAD_BLOCK_BYTE_NUM | ++ 1 << BAD_BLOCK_IN_SPARE_AREA | ++ 2 << WR_RD_BSY_GAP | ++ 0 << WIDE_FLASH | ++ 1 << DEV0_CFG1_ECC_DISABLE); + +- nandc_set_reg(chip, NAND_ADDR0, 0); +- nandc_set_reg(chip, NAND_ADDR1, 0); +- nandc_set_reg(chip, NAND_DEV0_CFG0, 0 << CW_PER_PAGE +- | 512 << UD_SIZE_BYTES +- | 5 << NUM_ADDR_CYCLES +- | 0 << SPARE_SIZE_BYTES); +- nandc_set_reg(chip, NAND_DEV0_CFG1, 7 << NAND_RECOVERY_CYCLES +- | 0 << CS_ACTIVE_BSY +- | 17 << BAD_BLOCK_BYTE_NUM +- | 1 << BAD_BLOCK_IN_SPARE_AREA +- | 2 << WR_RD_BSY_GAP +- | 0 << WIDE_FLASH +- | 1 << DEV0_CFG1_ECC_DISABLE); +- if (!nandc->props->qpic_v2) +- nandc_set_reg(chip, NAND_EBI2_ECC_BUF_CFG, 1 << ECC_CFG_ECC_DISABLE); ++ if (!nandc->props->qpic_version2) ++ nandc->regs->ecc_buf_cfg = cpu_to_le32(1 << ECC_CFG_ECC_DISABLE); + + /* configure CMD1 and VLD for ONFI param probing in QPIC v1 */ +- if (!nandc->props->qpic_v2) { +- nandc_set_reg(chip, NAND_DEV_CMD_VLD, +- (nandc->vld & ~READ_START_VLD)); +- nandc_set_reg(chip, NAND_DEV_CMD1, +- (nandc->cmd1 & ~(0xFF << READ_ADDR)) +- | NAND_CMD_PARAM << READ_ADDR); ++ if (!nandc->props->qpic_version2) { ++ nandc->regs->vld = cpu_to_le32((nandc->vld & ~READ_START_VLD)); ++ nandc->regs->cmd1 = cpu_to_le32((nandc->cmd1 & ~(0xFF << READ_ADDR)) ++ | NAND_CMD_PARAM << READ_ADDR); + } + +- nandc_set_reg(chip, NAND_EXEC_CMD, 1); +- +- if (!nandc->props->qpic_v2) { +- nandc_set_reg(chip, NAND_DEV_CMD1_RESTORE, nandc->cmd1); +- nandc_set_reg(chip, NAND_DEV_CMD_VLD_RESTORE, nandc->vld); ++ nandc->regs->exec = cpu_to_le32(1); ++ ++ if (!nandc->props->qpic_version2) { ++ nandc->regs->orig_cmd1 = cpu_to_le32(nandc->cmd1); ++ nandc->regs->orig_vld = cpu_to_le32(nandc->vld); + } + + instr = q_op.data_instr; + op_id = q_op.data_instr_idx; + len = nand_subop_get_data_len(subop, op_id); + +- if (nandc->props->qpic_v2) ++ if (nandc->props->qpic_version2) + nandc_set_read_loc_last(chip, reg_base, 0, len, 1); + else + nandc_set_read_loc_first(chip, reg_base, 0, len, 1); + +- if (!nandc->props->qpic_v2) { +- write_reg_dma(nandc, NAND_DEV_CMD_VLD, 1, 0); +- write_reg_dma(nandc, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL); ++ if (!nandc->props->qpic_version2) { ++ write_reg_dma(nandc, &nandc->regs->vld, NAND_DEV_CMD_VLD, 1, 0); ++ write_reg_dma(nandc, &nandc->regs->cmd1, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL); + } + + nandc->buf_count = 512; +@@ -2934,9 +2885,10 @@ static int qcom_param_page_type_exec(str + nandc->buf_count, 0); + + /* restore CMD1 and VLD regs */ +- if (!nandc->props->qpic_v2) { +- write_reg_dma(nandc, NAND_DEV_CMD1_RESTORE, 1, 0); +- write_reg_dma(nandc, NAND_DEV_CMD_VLD_RESTORE, 1, NAND_BAM_NEXT_SGL); ++ if (!nandc->props->qpic_version2) { ++ write_reg_dma(nandc, &nandc->regs->orig_cmd1, NAND_DEV_CMD1_RESTORE, 1, 0); ++ write_reg_dma(nandc, &nandc->regs->orig_vld, NAND_DEV_CMD_VLD_RESTORE, 1, ++ NAND_BAM_NEXT_SGL); + } + + ret = submit_descs(nandc); +@@ -3025,7 +2977,7 @@ static const struct nand_controller_ops + + static void qcom_nandc_unalloc(struct qcom_nand_controller *nandc) + { +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + if (!dma_mapping_error(nandc->dev, nandc->reg_read_dma)) + dma_unmap_single(nandc->dev, nandc->reg_read_dma, + MAX_REG_RD * +@@ -3078,7 +3030,7 @@ static int qcom_nandc_alloc(struct qcom_ + if (!nandc->reg_read_buf) + return -ENOMEM; + +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + nandc->reg_read_dma = + dma_map_single(nandc->dev, nandc->reg_read_buf, + MAX_REG_RD * +@@ -3159,15 +3111,15 @@ static int qcom_nandc_setup(struct qcom_ + u32 nand_ctrl; + + /* kill onenand */ +- if (!nandc->props->is_qpic) ++ if (!nandc->props->nandc_part_of_qpic) + nandc_write(nandc, SFLASHC_BURST_CFG, 0); + +- if (!nandc->props->qpic_v2) ++ if (!nandc->props->qpic_version2) + nandc_write(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD), + NAND_DEV_CMD_VLD_VAL); + + /* enable ADM or BAM DMA */ +- if (nandc->props->is_bam) { ++ if (nandc->props->supports_bam) { + nand_ctrl = nandc_read(nandc, NAND_CTRL); + + /* +@@ -3184,7 +3136,7 @@ static int qcom_nandc_setup(struct qcom_ + } + + /* save the original values of these registers */ +- if (!nandc->props->qpic_v2) { ++ if (!nandc->props->qpic_version2) { + nandc->cmd1 = nandc_read(nandc, dev_cmd_reg_addr(nandc, NAND_DEV_CMD1)); + nandc->vld = NAND_DEV_CMD_VLD_VAL; + } +@@ -3357,7 +3309,7 @@ static int qcom_nandc_parse_dt(struct pl + struct device_node *np = nandc->dev->of_node; + int ret; + +- if (!nandc->props->is_bam) { ++ if (!nandc->props->supports_bam) { + ret = of_property_read_u32(np, "qcom,cmd-crci", + &nandc->cmd_crci); + if (ret) { +@@ -3482,30 +3434,30 @@ static void qcom_nandc_remove(struct pla + + static const struct qcom_nandc_props ipq806x_nandc_props = { + .ecc_modes = (ECC_RS_4BIT | ECC_BCH_8BIT), +- .is_bam = false, ++ .supports_bam = false, + .use_codeword_fixup = true, + .dev_cmd_reg_start = 0x0, + }; + + static const struct qcom_nandc_props ipq4019_nandc_props = { + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT), +- .is_bam = true, +- .is_qpic = true, ++ .supports_bam = true, ++ .nandc_part_of_qpic = true, + .dev_cmd_reg_start = 0x0, + }; + + static const struct qcom_nandc_props ipq8074_nandc_props = { + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT), +- .is_bam = true, +- .is_qpic = true, ++ .supports_bam = true, ++ .nandc_part_of_qpic = true, + .dev_cmd_reg_start = 0x7000, + }; + + static const struct qcom_nandc_props sdx55_nandc_props = { + .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT), +- .is_bam = true, +- .is_qpic = true, +- .qpic_v2 = true, ++ .supports_bam = true, ++ .nandc_part_of_qpic = true, ++ .qpic_version2 = true, + .dev_cmd_reg_start = 0x7000, + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-02-v6.14-mtd-rawnand-qcom-Add-qcom-prefix-to-common-api.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-02-v6.14-mtd-rawnand-qcom-Add-qcom-prefix-to-common-api.patch new file mode 100755 index 0000000..23ef86f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-02-v6.14-mtd-rawnand-qcom-Add-qcom-prefix-to-common-api.patch @@ -0,0 +1,880 @@ +From 1d479f5b345e0c3650fec4dddeef9fc6fab30c8b Mon Sep 17 00:00:00 2001 +From: Md Sadre Alam +Date: Wed, 20 Nov 2024 14:45:01 +0530 +Subject: [PATCH 2/4] mtd: rawnand: qcom: Add qcom prefix to common api + +Add qcom prefix to all the api which will be commonly +used by spi nand driver and raw nand driver. + +Reviewed-by: Konrad Dybcio +Signed-off-by: Md Sadre Alam +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/raw/qcom_nandc.c | 320 +++++++++++++++--------------- + 1 file changed, 160 insertions(+), 160 deletions(-) + +--- a/drivers/mtd/nand/raw/qcom_nandc.c ++++ b/drivers/mtd/nand/raw/qcom_nandc.c +@@ -53,7 +53,7 @@ + #define NAND_READ_LOCATION_LAST_CW_2 0xf48 + #define NAND_READ_LOCATION_LAST_CW_3 0xf4c + +-/* dummy register offsets, used by write_reg_dma */ ++/* dummy register offsets, used by qcom_write_reg_dma */ + #define NAND_DEV_CMD1_RESTORE 0xdead + #define NAND_DEV_CMD_VLD_RESTORE 0xbeef + +@@ -211,7 +211,7 @@ + + /* + * Flags used in DMA descriptor preparation helper functions +- * (i.e. read_reg_dma/write_reg_dma/read_data_dma/write_data_dma) ++ * (i.e. qcom_read_reg_dma/qcom_write_reg_dma/qcom_read_data_dma/qcom_write_data_dma) + */ + /* Don't set the EOT in current tx BAM sgl */ + #define NAND_BAM_NO_EOT BIT(0) +@@ -550,7 +550,7 @@ struct qcom_nandc_props { + }; + + /* Frees the BAM transaction memory */ +-static void free_bam_transaction(struct qcom_nand_controller *nandc) ++static void qcom_free_bam_transaction(struct qcom_nand_controller *nandc) + { + struct bam_transaction *bam_txn = nandc->bam_txn; + +@@ -559,7 +559,7 @@ static void free_bam_transaction(struct + + /* Allocates and Initializes the BAM transaction */ + static struct bam_transaction * +-alloc_bam_transaction(struct qcom_nand_controller *nandc) ++qcom_alloc_bam_transaction(struct qcom_nand_controller *nandc) + { + struct bam_transaction *bam_txn; + size_t bam_txn_size; +@@ -595,7 +595,7 @@ alloc_bam_transaction(struct qcom_nand_c + } + + /* Clears the BAM transaction indexes */ +-static void clear_bam_transaction(struct qcom_nand_controller *nandc) ++static void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc) + { + struct bam_transaction *bam_txn = nandc->bam_txn; + +@@ -614,7 +614,7 @@ static void clear_bam_transaction(struct + } + + /* Callback for DMA descriptor completion */ +-static void qpic_bam_dma_done(void *data) ++static void qcom_qpic_bam_dma_done(void *data) + { + struct bam_transaction *bam_txn = data; + +@@ -644,7 +644,7 @@ static void nandc_write(struct qcom_nand + iowrite32(val, nandc->base + offset); + } + +-static void nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu) ++static void qcom_nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu) + { + if (!nandc->props->supports_bam) + return; +@@ -824,9 +824,9 @@ static void update_rw_regs(struct qcom_n + * for BAM. This descriptor will be added in the NAND DMA descriptor queue + * which will be submitted to DMA engine. + */ +-static int prepare_bam_async_desc(struct qcom_nand_controller *nandc, +- struct dma_chan *chan, +- unsigned long flags) ++static int qcom_prepare_bam_async_desc(struct qcom_nand_controller *nandc, ++ struct dma_chan *chan, ++ unsigned long flags) + { + struct desc_info *desc; + struct scatterlist *sgl; +@@ -903,9 +903,9 @@ static int prepare_bam_async_desc(struct + * NAND_BAM_NEXT_SGL will be used for starting the separate SGL + * after the current command element. + */ +-static int prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read, +- int reg_off, const void *vaddr, +- int size, unsigned int flags) ++static int qcom_prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read, ++ int reg_off, const void *vaddr, ++ int size, unsigned int flags) + { + int bam_ce_size; + int i, ret; +@@ -943,9 +943,9 @@ static int prep_bam_dma_desc_cmd(struct + bam_txn->bam_ce_start = bam_txn->bam_ce_pos; + + if (flags & NAND_BAM_NWD) { +- ret = prepare_bam_async_desc(nandc, nandc->cmd_chan, +- DMA_PREP_FENCE | +- DMA_PREP_CMD); ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan, ++ DMA_PREP_FENCE | ++ DMA_PREP_CMD); + if (ret) + return ret; + } +@@ -958,9 +958,8 @@ static int prep_bam_dma_desc_cmd(struct + * Prepares the data descriptor for BAM DMA which will be used for NAND + * data reads and writes. + */ +-static int prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, +- const void *vaddr, +- int size, unsigned int flags) ++static int qcom_prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, ++ const void *vaddr, int size, unsigned int flags) + { + int ret; + struct bam_transaction *bam_txn = nandc->bam_txn; +@@ -979,8 +978,8 @@ static int prep_bam_dma_desc_data(struct + * is not set, form the DMA descriptor + */ + if (!(flags & NAND_BAM_NO_EOT)) { +- ret = prepare_bam_async_desc(nandc, nandc->tx_chan, +- DMA_PREP_INTERRUPT); ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan, ++ DMA_PREP_INTERRUPT); + if (ret) + return ret; + } +@@ -989,9 +988,9 @@ static int prep_bam_dma_desc_data(struct + return 0; + } + +-static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, +- int reg_off, const void *vaddr, int size, +- bool flow_control) ++static int qcom_prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, ++ int reg_off, const void *vaddr, int size, ++ bool flow_control) + { + struct desc_info *desc; + struct dma_async_tx_descriptor *dma_desc; +@@ -1069,15 +1068,15 @@ err: + } + + /* +- * read_reg_dma: prepares a descriptor to read a given number of ++ * qcom_read_reg_dma: prepares a descriptor to read a given number of + * contiguous registers to the reg_read_buf pointer + * + * @first: offset of the first register in the contiguous block + * @num_regs: number of registers to read + * @flags: flags to control DMA descriptor preparation + */ +-static int read_reg_dma(struct qcom_nand_controller *nandc, int first, +- int num_regs, unsigned int flags) ++static int qcom_read_reg_dma(struct qcom_nand_controller *nandc, int first, ++ int num_regs, unsigned int flags) + { + bool flow_control = false; + void *vaddr; +@@ -1089,18 +1088,18 @@ static int read_reg_dma(struct qcom_nand + first = dev_cmd_reg_addr(nandc, first); + + if (nandc->props->supports_bam) +- return prep_bam_dma_desc_cmd(nandc, true, first, vaddr, ++ return qcom_prep_bam_dma_desc_cmd(nandc, true, first, vaddr, + num_regs, flags); + + if (first == NAND_READ_ID || first == NAND_FLASH_STATUS) + flow_control = true; + +- return prep_adm_dma_desc(nandc, true, first, vaddr, ++ return qcom_prep_adm_dma_desc(nandc, true, first, vaddr, + num_regs * sizeof(u32), flow_control); + } + + /* +- * write_reg_dma: prepares a descriptor to write a given number of ++ * qcom_write_reg_dma: prepares a descriptor to write a given number of + * contiguous registers + * + * @vaddr: contiguous memory from where register value will +@@ -1109,8 +1108,8 @@ static int read_reg_dma(struct qcom_nand + * @num_regs: number of registers to write + * @flags: flags to control DMA descriptor preparation + */ +-static int write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, +- int first, int num_regs, unsigned int flags) ++static int qcom_write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, ++ int first, int num_regs, unsigned int flags) + { + bool flow_control = false; + +@@ -1124,18 +1123,18 @@ static int write_reg_dma(struct qcom_nan + first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD); + + if (nandc->props->supports_bam) +- return prep_bam_dma_desc_cmd(nandc, false, first, vaddr, ++ return qcom_prep_bam_dma_desc_cmd(nandc, false, first, vaddr, + num_regs, flags); + + if (first == NAND_FLASH_CMD) + flow_control = true; + +- return prep_adm_dma_desc(nandc, false, first, vaddr, ++ return qcom_prep_adm_dma_desc(nandc, false, first, vaddr, + num_regs * sizeof(u32), flow_control); + } + + /* +- * read_data_dma: prepares a DMA descriptor to transfer data from the ++ * qcom_read_data_dma: prepares a DMA descriptor to transfer data from the + * controller's internal buffer to the buffer 'vaddr' + * + * @reg_off: offset within the controller's data buffer +@@ -1143,17 +1142,17 @@ static int write_reg_dma(struct qcom_nan + * @size: DMA transaction size in bytes + * @flags: flags to control DMA descriptor preparation + */ +-static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off, +- const u8 *vaddr, int size, unsigned int flags) ++static int qcom_read_data_dma(struct qcom_nand_controller *nandc, int reg_off, ++ const u8 *vaddr, int size, unsigned int flags) + { + if (nandc->props->supports_bam) +- return prep_bam_dma_desc_data(nandc, true, vaddr, size, flags); ++ return qcom_prep_bam_dma_desc_data(nandc, true, vaddr, size, flags); + +- return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false); ++ return qcom_prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false); + } + + /* +- * write_data_dma: prepares a DMA descriptor to transfer data from ++ * qcom_write_data_dma: prepares a DMA descriptor to transfer data from + * 'vaddr' to the controller's internal buffer + * + * @reg_off: offset within the controller's data buffer +@@ -1161,13 +1160,13 @@ static int read_data_dma(struct qcom_nan + * @size: DMA transaction size in bytes + * @flags: flags to control DMA descriptor preparation + */ +-static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off, +- const u8 *vaddr, int size, unsigned int flags) ++static int qcom_write_data_dma(struct qcom_nand_controller *nandc, int reg_off, ++ const u8 *vaddr, int size, unsigned int flags) + { + if (nandc->props->supports_bam) +- return prep_bam_dma_desc_data(nandc, false, vaddr, size, flags); ++ return qcom_prep_bam_dma_desc_data(nandc, false, vaddr, size, flags); + +- return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false); ++ return qcom_prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false); + } + + /* +@@ -1178,14 +1177,14 @@ static void config_nand_page_read(struct + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + +- write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0); +- write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); + if (!nandc->props->qpic_version2) +- write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, 0); +- write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_clr, +- NAND_ERASED_CW_DETECT_CFG, 1, 0); +- write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_set, +- NAND_ERASED_CW_DETECT_CFG, 1, NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_clr, ++ NAND_ERASED_CW_DETECT_CFG, 1, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->erased_cw_detect_cfg_set, ++ NAND_ERASED_CW_DETECT_CFG, 1, NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); + } + + /* +@@ -1204,17 +1203,17 @@ config_nand_cw_read(struct nand_chip *ch + reg = &nandc->regs->read_location_last0; + + if (nandc->props->supports_bam) +- write_reg_dma(nandc, reg, NAND_READ_LOCATION_0, 4, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, reg, NAND_READ_LOCATION_0, 4, NAND_BAM_NEXT_SGL); + +- write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + + if (use_ecc) { +- read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0); +- read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1, +- NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 2, 0); ++ qcom_read_reg_dma(nandc, NAND_ERASED_CW_DETECT_STATUS, 1, ++ NAND_BAM_NEXT_SGL); + } else { +- read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + } + } + +@@ -1238,11 +1237,11 @@ static void config_nand_page_write(struc + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + +- write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0); +- write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); + if (!nandc->props->qpic_version2) +- write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, +- NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, ++ NAND_BAM_NEXT_SGL); + } + + /* +@@ -1253,17 +1252,18 @@ static void config_nand_cw_write(struct + { + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + +- write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + +- read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + +- write_reg_dma(nandc, &nandc->regs->clrflashstatus, NAND_FLASH_STATUS, 1, 0); +- write_reg_dma(nandc, &nandc->regs->clrreadstatus, NAND_READ_STATUS, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->clrflashstatus, NAND_FLASH_STATUS, 1, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->clrreadstatus, NAND_READ_STATUS, 1, ++ NAND_BAM_NEXT_SGL); + } + + /* helpers to submit/free our list of dma descriptors */ +-static int submit_descs(struct qcom_nand_controller *nandc) ++static int qcom_submit_descs(struct qcom_nand_controller *nandc) + { + struct desc_info *desc, *n; + dma_cookie_t cookie = 0; +@@ -1272,21 +1272,21 @@ static int submit_descs(struct qcom_nand + + if (nandc->props->supports_bam) { + if (bam_txn->rx_sgl_pos > bam_txn->rx_sgl_start) { +- ret = prepare_bam_async_desc(nandc, nandc->rx_chan, 0); ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->rx_chan, 0); + if (ret) + goto err_unmap_free_desc; + } + + if (bam_txn->tx_sgl_pos > bam_txn->tx_sgl_start) { +- ret = prepare_bam_async_desc(nandc, nandc->tx_chan, +- DMA_PREP_INTERRUPT); ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan, ++ DMA_PREP_INTERRUPT); + if (ret) + goto err_unmap_free_desc; + } + + if (bam_txn->cmd_sgl_pos > bam_txn->cmd_sgl_start) { +- ret = prepare_bam_async_desc(nandc, nandc->cmd_chan, +- DMA_PREP_CMD); ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan, ++ DMA_PREP_CMD); + if (ret) + goto err_unmap_free_desc; + } +@@ -1296,7 +1296,7 @@ static int submit_descs(struct qcom_nand + cookie = dmaengine_submit(desc->dma_desc); + + if (nandc->props->supports_bam) { +- bam_txn->last_cmd_desc->callback = qpic_bam_dma_done; ++ bam_txn->last_cmd_desc->callback = qcom_qpic_bam_dma_done; + bam_txn->last_cmd_desc->callback_param = bam_txn; + + dma_async_issue_pending(nandc->tx_chan); +@@ -1314,7 +1314,7 @@ static int submit_descs(struct qcom_nand + err_unmap_free_desc: + /* + * Unmap the dma sg_list and free the desc allocated by both +- * prepare_bam_async_desc() and prep_adm_dma_desc() functions. ++ * qcom_prepare_bam_async_desc() and qcom_prep_adm_dma_desc() functions. + */ + list_for_each_entry_safe(desc, n, &nandc->desc_list, node) { + list_del(&desc->node); +@@ -1333,10 +1333,10 @@ err_unmap_free_desc: + } + + /* reset the register read buffer for next NAND operation */ +-static void clear_read_regs(struct qcom_nand_controller *nandc) ++static void qcom_clear_read_regs(struct qcom_nand_controller *nandc) + { + nandc->reg_read_pos = 0; +- nandc_dev_to_mem(nandc, false); ++ qcom_nandc_dev_to_mem(nandc, false); + } + + /* +@@ -1400,7 +1400,7 @@ static int check_flash_errors(struct qco + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + int i; + +- nandc_dev_to_mem(nandc, true); ++ qcom_nandc_dev_to_mem(nandc, true); + + for (i = 0; i < cw_cnt; i++) { + u32 flash = le32_to_cpu(nandc->reg_read_buf[i]); +@@ -1427,13 +1427,13 @@ qcom_nandc_read_cw_raw(struct mtd_info * + nand_read_page_op(chip, page, 0, NULL, 0); + nandc->buf_count = 0; + nandc->buf_start = 0; +- clear_read_regs(nandc); ++ qcom_clear_read_regs(nandc); + host->use_ecc = false; + + if (nandc->props->qpic_version2) + raw_cw = ecc->steps - 1; + +- clear_bam_transaction(nandc); ++ qcom_clear_bam_transaction(nandc); + set_address(host, host->cw_size * cw, page); + update_rw_regs(host, 1, true, raw_cw); + config_nand_page_read(chip); +@@ -1466,18 +1466,18 @@ qcom_nandc_read_cw_raw(struct mtd_info * + + config_nand_cw_read(chip, false, raw_cw); + +- read_data_dma(nandc, reg_off, data_buf, data_size1, 0); ++ qcom_read_data_dma(nandc, reg_off, data_buf, data_size1, 0); + reg_off += data_size1; + +- read_data_dma(nandc, reg_off, oob_buf, oob_size1, 0); ++ qcom_read_data_dma(nandc, reg_off, oob_buf, oob_size1, 0); + reg_off += oob_size1; + +- read_data_dma(nandc, reg_off, data_buf + data_size1, data_size2, 0); ++ qcom_read_data_dma(nandc, reg_off, data_buf + data_size1, data_size2, 0); + reg_off += data_size2; + +- read_data_dma(nandc, reg_off, oob_buf + oob_size1, oob_size2, 0); ++ qcom_read_data_dma(nandc, reg_off, oob_buf + oob_size1, oob_size2, 0); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure to read raw cw %d\n", cw); + return ret; +@@ -1575,7 +1575,7 @@ static int parse_read_errors(struct qcom + u8 *data_buf_start = data_buf, *oob_buf_start = oob_buf; + + buf = (struct read_stats *)nandc->reg_read_buf; +- nandc_dev_to_mem(nandc, true); ++ qcom_nandc_dev_to_mem(nandc, true); + + for (i = 0; i < ecc->steps; i++, buf++) { + u32 flash, buffer, erased_cw; +@@ -1704,8 +1704,8 @@ static int read_page_ecc(struct qcom_nan + config_nand_cw_read(chip, true, i); + + if (data_buf) +- read_data_dma(nandc, FLASH_BUF_ACC, data_buf, +- data_size, 0); ++ qcom_read_data_dma(nandc, FLASH_BUF_ACC, data_buf, ++ data_size, 0); + + /* + * when ecc is enabled, the controller doesn't read the real +@@ -1720,8 +1720,8 @@ static int read_page_ecc(struct qcom_nan + for (j = 0; j < host->bbm_size; j++) + *oob_buf++ = 0xff; + +- read_data_dma(nandc, FLASH_BUF_ACC + data_size, +- oob_buf, oob_size, 0); ++ qcom_read_data_dma(nandc, FLASH_BUF_ACC + data_size, ++ oob_buf, oob_size, 0); + } + + if (data_buf) +@@ -1730,7 +1730,7 @@ static int read_page_ecc(struct qcom_nan + oob_buf += oob_size; + } + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure to read page/oob\n"); + return ret; +@@ -1751,7 +1751,7 @@ static int copy_last_cw(struct qcom_nand + int size; + int ret; + +- clear_read_regs(nandc); ++ qcom_clear_read_regs(nandc); + + size = host->use_ecc ? host->cw_data : host->cw_size; + +@@ -1763,9 +1763,9 @@ static int copy_last_cw(struct qcom_nand + + config_nand_single_cw_page_read(chip, host->use_ecc, ecc->steps - 1); + +- read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size, 0); ++ qcom_read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, size, 0); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) + dev_err(nandc->dev, "failed to copy last codeword\n"); + +@@ -1851,14 +1851,14 @@ static int qcom_nandc_read_page(struct n + nandc->buf_count = 0; + nandc->buf_start = 0; + host->use_ecc = true; +- clear_read_regs(nandc); ++ qcom_clear_read_regs(nandc); + set_address(host, 0, page); + update_rw_regs(host, ecc->steps, true, 0); + + data_buf = buf; + oob_buf = oob_required ? chip->oob_poi : NULL; + +- clear_bam_transaction(nandc); ++ qcom_clear_bam_transaction(nandc); + + return read_page_ecc(host, data_buf, oob_buf, page); + } +@@ -1899,8 +1899,8 @@ static int qcom_nandc_read_oob(struct na + if (host->nr_boot_partitions) + qcom_nandc_codeword_fixup(host, page); + +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + host->use_ecc = true; + set_address(host, 0, page); +@@ -1927,8 +1927,8 @@ static int qcom_nandc_write_page(struct + set_address(host, 0, page); + nandc->buf_count = 0; + nandc->buf_start = 0; +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + data_buf = (u8 *)buf; + oob_buf = chip->oob_poi; +@@ -1949,8 +1949,8 @@ static int qcom_nandc_write_page(struct + oob_size = ecc->bytes; + } + +- write_data_dma(nandc, FLASH_BUF_ACC, data_buf, data_size, +- i == (ecc->steps - 1) ? NAND_BAM_NO_EOT : 0); ++ qcom_write_data_dma(nandc, FLASH_BUF_ACC, data_buf, data_size, ++ i == (ecc->steps - 1) ? NAND_BAM_NO_EOT : 0); + + /* + * when ECC is enabled, we don't really need to write anything +@@ -1962,8 +1962,8 @@ static int qcom_nandc_write_page(struct + if (qcom_nandc_is_last_cw(ecc, i)) { + oob_buf += host->bbm_size; + +- write_data_dma(nandc, FLASH_BUF_ACC + data_size, +- oob_buf, oob_size, 0); ++ qcom_write_data_dma(nandc, FLASH_BUF_ACC + data_size, ++ oob_buf, oob_size, 0); + } + + config_nand_cw_write(chip); +@@ -1972,7 +1972,7 @@ static int qcom_nandc_write_page(struct + oob_buf += oob_size; + } + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure to write page\n"); + return ret; +@@ -1997,8 +1997,8 @@ static int qcom_nandc_write_page_raw(str + qcom_nandc_codeword_fixup(host, page); + + nand_prog_page_begin_op(chip, page, 0, NULL, 0); +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + data_buf = (u8 *)buf; + oob_buf = chip->oob_poi; +@@ -2024,28 +2024,28 @@ static int qcom_nandc_write_page_raw(str + oob_size2 = host->ecc_bytes_hw + host->spare_bytes; + } + +- write_data_dma(nandc, reg_off, data_buf, data_size1, +- NAND_BAM_NO_EOT); ++ qcom_write_data_dma(nandc, reg_off, data_buf, data_size1, ++ NAND_BAM_NO_EOT); + reg_off += data_size1; + data_buf += data_size1; + +- write_data_dma(nandc, reg_off, oob_buf, oob_size1, +- NAND_BAM_NO_EOT); ++ qcom_write_data_dma(nandc, reg_off, oob_buf, oob_size1, ++ NAND_BAM_NO_EOT); + reg_off += oob_size1; + oob_buf += oob_size1; + +- write_data_dma(nandc, reg_off, data_buf, data_size2, +- NAND_BAM_NO_EOT); ++ qcom_write_data_dma(nandc, reg_off, data_buf, data_size2, ++ NAND_BAM_NO_EOT); + reg_off += data_size2; + data_buf += data_size2; + +- write_data_dma(nandc, reg_off, oob_buf, oob_size2, 0); ++ qcom_write_data_dma(nandc, reg_off, oob_buf, oob_size2, 0); + oob_buf += oob_size2; + + config_nand_cw_write(chip); + } + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure to write raw page\n"); + return ret; +@@ -2075,7 +2075,7 @@ static int qcom_nandc_write_oob(struct n + qcom_nandc_codeword_fixup(host, page); + + host->use_ecc = true; +- clear_bam_transaction(nandc); ++ qcom_clear_bam_transaction(nandc); + + /* calculate the data and oob size for the last codeword/step */ + data_size = ecc->size - ((ecc->steps - 1) << 2); +@@ -2090,11 +2090,11 @@ static int qcom_nandc_write_oob(struct n + update_rw_regs(host, 1, false, 0); + + config_nand_page_write(chip); +- write_data_dma(nandc, FLASH_BUF_ACC, +- nandc->data_buffer, data_size + oob_size, 0); ++ qcom_write_data_dma(nandc, FLASH_BUF_ACC, ++ nandc->data_buffer, data_size + oob_size, 0); + config_nand_cw_write(chip); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure to write oob\n"); + return ret; +@@ -2121,7 +2121,7 @@ static int qcom_nandc_block_bad(struct n + */ + host->use_ecc = false; + +- clear_bam_transaction(nandc); ++ qcom_clear_bam_transaction(nandc); + ret = copy_last_cw(host, page); + if (ret) + goto err; +@@ -2148,8 +2148,8 @@ static int qcom_nandc_block_markbad(stru + struct nand_ecc_ctrl *ecc = &chip->ecc; + int page, ret; + +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + /* + * to mark the BBM as bad, we flash the entire last codeword with 0s. +@@ -2166,11 +2166,11 @@ static int qcom_nandc_block_markbad(stru + update_rw_regs(host, 1, false, ecc->steps - 1); + + config_nand_page_write(chip); +- write_data_dma(nandc, FLASH_BUF_ACC, +- nandc->data_buffer, host->cw_size, 0); ++ qcom_write_data_dma(nandc, FLASH_BUF_ACC, ++ nandc->data_buffer, host->cw_size, 0); + config_nand_cw_write(chip); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure to update BBM\n"); + return ret; +@@ -2410,14 +2410,14 @@ static int qcom_nand_attach_chip(struct + mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops); + /* Free the initially allocated BAM transaction for reading the ONFI params */ + if (nandc->props->supports_bam) +- free_bam_transaction(nandc); ++ qcom_free_bam_transaction(nandc); + + nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage, + cwperpage); + + /* Now allocate the BAM transaction based on updated max_cwperpage */ + if (nandc->props->supports_bam) { +- nandc->bam_txn = alloc_bam_transaction(nandc); ++ nandc->bam_txn = qcom_alloc_bam_transaction(nandc); + if (!nandc->bam_txn) { + dev_err(nandc->dev, + "failed to allocate bam transaction\n"); +@@ -2617,7 +2617,7 @@ static int qcom_wait_rdy_poll(struct nan + unsigned long start = jiffies + msecs_to_jiffies(time_ms); + u32 flash; + +- nandc_dev_to_mem(nandc, true); ++ qcom_nandc_dev_to_mem(nandc, true); + + do { + flash = le32_to_cpu(nandc->reg_read_buf[0]); +@@ -2657,23 +2657,23 @@ static int qcom_read_status_exec(struct + nandc->buf_start = 0; + host->use_ecc = false; + +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + nandc->regs->cmd = q_op.cmd_reg; + nandc->regs->exec = cpu_to_le32(1); + +- write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); +- read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure in submitting status descriptor\n"); + goto err_out; + } + +- nandc_dev_to_mem(nandc, true); ++ qcom_nandc_dev_to_mem(nandc, true); + + for (i = 0; i < num_cw; i++) { + flash_status = le32_to_cpu(nandc->reg_read_buf[i]); +@@ -2714,8 +2714,8 @@ static int qcom_read_id_type_exec(struct + nandc->buf_start = 0; + host->use_ecc = false; + +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + nandc->regs->cmd = q_op.cmd_reg; + nandc->regs->addr0 = q_op.addr1_reg; +@@ -2723,12 +2723,12 @@ static int qcom_read_id_type_exec(struct + nandc->regs->chip_sel = cpu_to_le32(nandc->props->supports_bam ? 0 : DM_EN); + nandc->regs->exec = cpu_to_le32(1); + +- write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL); +- write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); + +- read_reg_dma(nandc, NAND_READ_ID, 1, NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(nandc, NAND_READ_ID, 1, NAND_BAM_NEXT_SGL); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure in submitting read id descriptor\n"); + goto err_out; +@@ -2738,7 +2738,7 @@ static int qcom_read_id_type_exec(struct + op_id = q_op.data_instr_idx; + len = nand_subop_get_data_len(subop, op_id); + +- nandc_dev_to_mem(nandc, true); ++ qcom_nandc_dev_to_mem(nandc, true); + memcpy(instr->ctx.data.buf.in, nandc->reg_read_buf, len); + + err_out: +@@ -2774,20 +2774,20 @@ static int qcom_misc_cmd_type_exec(struc + nandc->buf_start = 0; + host->use_ecc = false; + +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + nandc->regs->cmd = q_op.cmd_reg; + nandc->regs->exec = cpu_to_le32(1); + +- write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, instrs, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->cmd, NAND_FLASH_CMD, instrs, NAND_BAM_NEXT_SGL); + if (q_op.cmd_reg == cpu_to_le32(OP_BLOCK_ERASE)) +- write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->cfg0, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); + +- write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); +- read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure in submitting misc descriptor\n"); + goto err_out; +@@ -2825,8 +2825,8 @@ static int qcom_param_page_type_exec(str + nandc->buf_count = 0; + nandc->buf_start = 0; + host->use_ecc = false; +- clear_read_regs(nandc); +- clear_bam_transaction(nandc); ++ qcom_clear_read_regs(nandc); ++ qcom_clear_bam_transaction(nandc); + + nandc->regs->cmd = q_op.cmd_reg; + nandc->regs->addr0 = 0; +@@ -2872,8 +2872,8 @@ static int qcom_param_page_type_exec(str + nandc_set_read_loc_first(chip, reg_base, 0, len, 1); + + if (!nandc->props->qpic_version2) { +- write_reg_dma(nandc, &nandc->regs->vld, NAND_DEV_CMD_VLD, 1, 0); +- write_reg_dma(nandc, &nandc->regs->cmd1, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->vld, NAND_DEV_CMD_VLD, 1, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->cmd1, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL); + } + + nandc->buf_count = 512; +@@ -2881,17 +2881,17 @@ static int qcom_param_page_type_exec(str + + config_nand_single_cw_page_read(chip, false, 0); + +- read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, +- nandc->buf_count, 0); ++ qcom_read_data_dma(nandc, FLASH_BUF_ACC, nandc->data_buffer, ++ nandc->buf_count, 0); + + /* restore CMD1 and VLD regs */ + if (!nandc->props->qpic_version2) { +- write_reg_dma(nandc, &nandc->regs->orig_cmd1, NAND_DEV_CMD1_RESTORE, 1, 0); +- write_reg_dma(nandc, &nandc->regs->orig_vld, NAND_DEV_CMD_VLD_RESTORE, 1, +- NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(nandc, &nandc->regs->orig_cmd1, NAND_DEV_CMD1_RESTORE, 1, 0); ++ qcom_write_reg_dma(nandc, &nandc->regs->orig_vld, NAND_DEV_CMD_VLD_RESTORE, 1, ++ NAND_BAM_NEXT_SGL); + } + +- ret = submit_descs(nandc); ++ ret = qcom_submit_descs(nandc); + if (ret) { + dev_err(nandc->dev, "failure in submitting param page descriptor\n"); + goto err_out; +@@ -3075,7 +3075,7 @@ static int qcom_nandc_alloc(struct qcom_ + * maximum codeword size + */ + nandc->max_cwperpage = 1; +- nandc->bam_txn = alloc_bam_transaction(nandc); ++ nandc->bam_txn = qcom_alloc_bam_transaction(nandc); + if (!nandc->bam_txn) { + dev_err(nandc->dev, + "failed to allocate bam transaction\n"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-03-v6.14-mtd-nand-Add-qpic_common-API-file.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-03-v6.14-mtd-nand-Add-qpic_common-API-file.patch new file mode 100755 index 0000000..9272f98 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-03-v6.14-mtd-nand-Add-qpic_common-API-file.patch @@ -0,0 +1,2436 @@ +From fdf3ee5c6e5278dab4f60b998b47ed2d510bf80f Mon Sep 17 00:00:00 2001 +From: Md Sadre Alam +Date: Wed, 20 Nov 2024 14:45:02 +0530 +Subject: [PATCH 3/4] mtd: nand: Add qpic_common API file + +Add qpic_common.c file which hold all the common +qpic APIs which will be used by both qpic raw nand +driver and qpic spi nand driver. + +Signed-off-by: Md Sadre Alam +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/Makefile | 2 +- + drivers/mtd/nand/qpic_common.c | 759 ++++++++++++++++++ + drivers/mtd/nand/raw/qcom_nandc.c | 1092 +------------------------- + include/linux/mtd/nand-qpic-common.h | 468 +++++++++++ + 4 files changed, 1240 insertions(+), 1081 deletions(-) + create mode 100644 drivers/mtd/nand/qpic_common.c + create mode 100644 include/linux/mtd/nand-qpic-common.h + +--- a/drivers/mtd/nand/Makefile ++++ b/drivers/mtd/nand/Makefile +@@ -3,7 +3,7 @@ + nandcore-objs := core.o bbt.o + obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o + obj-$(CONFIG_MTD_NAND_ECC_MEDIATEK) += ecc-mtk.o +- ++obj-$(CONFIG_MTD_NAND_QCOM) += qpic_common.o + obj-y += onenand/ + obj-y += raw/ + obj-y += spi/ +--- /dev/null ++++ b/drivers/mtd/nand/qpic_common.c +@@ -0,0 +1,759 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Copyright (c) 2016, The Linux Foundation. All rights reserved. ++ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * qcom_free_bam_transaction() - Frees the BAM transaction memory ++ * @nandc: qpic nand controller ++ * ++ * This function frees the bam transaction memory ++ */ ++void qcom_free_bam_transaction(struct qcom_nand_controller *nandc) ++{ ++ struct bam_transaction *bam_txn = nandc->bam_txn; ++ ++ kfree(bam_txn); ++} ++EXPORT_SYMBOL(qcom_free_bam_transaction); ++ ++/** ++ * qcom_alloc_bam_transaction() - allocate BAM transaction ++ * @nandc: qpic nand controller ++ * ++ * This function will allocate and initialize the BAM transaction structure ++ */ ++struct bam_transaction * ++qcom_alloc_bam_transaction(struct qcom_nand_controller *nandc) ++{ ++ struct bam_transaction *bam_txn; ++ size_t bam_txn_size; ++ unsigned int num_cw = nandc->max_cwperpage; ++ void *bam_txn_buf; ++ ++ bam_txn_size = ++ sizeof(*bam_txn) + num_cw * ++ ((sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS) + ++ (sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) + ++ (sizeof(*bam_txn->data_sgl) * QPIC_PER_CW_DATA_SGL)); ++ ++ bam_txn_buf = kzalloc(bam_txn_size, GFP_KERNEL); ++ if (!bam_txn_buf) ++ return NULL; ++ ++ bam_txn = bam_txn_buf; ++ bam_txn_buf += sizeof(*bam_txn); ++ ++ bam_txn->bam_ce = bam_txn_buf; ++ bam_txn_buf += ++ sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS * num_cw; ++ ++ bam_txn->cmd_sgl = bam_txn_buf; ++ bam_txn_buf += ++ sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL * num_cw; ++ ++ bam_txn->data_sgl = bam_txn_buf; ++ ++ init_completion(&bam_txn->txn_done); ++ ++ return bam_txn; ++} ++EXPORT_SYMBOL(qcom_alloc_bam_transaction); ++ ++/** ++ * qcom_clear_bam_transaction() - Clears the BAM transaction ++ * @nandc: qpic nand controller ++ * ++ * This function will clear the BAM transaction indexes. ++ */ ++void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc) ++{ ++ struct bam_transaction *bam_txn = nandc->bam_txn; ++ ++ if (!nandc->props->supports_bam) ++ return; ++ ++ memset(&bam_txn->bam_ce_pos, 0, sizeof(u32) * 8); ++ bam_txn->last_data_desc = NULL; ++ ++ sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage * ++ QPIC_PER_CW_CMD_SGL); ++ sg_init_table(bam_txn->data_sgl, nandc->max_cwperpage * ++ QPIC_PER_CW_DATA_SGL); ++ ++ reinit_completion(&bam_txn->txn_done); ++} ++EXPORT_SYMBOL(qcom_clear_bam_transaction); ++ ++/** ++ * qcom_qpic_bam_dma_done() - Callback for DMA descriptor completion ++ * @data: data pointer ++ * ++ * This function is a callback for DMA descriptor completion ++ */ ++void qcom_qpic_bam_dma_done(void *data) ++{ ++ struct bam_transaction *bam_txn = data; ++ ++ complete(&bam_txn->txn_done); ++} ++EXPORT_SYMBOL(qcom_qpic_bam_dma_done); ++ ++/** ++ * qcom_nandc_dev_to_mem() - Check for dma sync for cpu or device ++ * @nandc: qpic nand controller ++ * @is_cpu: cpu or Device ++ * ++ * This function will check for dma sync for cpu or device ++ */ ++inline void qcom_nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu) ++{ ++ if (!nandc->props->supports_bam) ++ return; ++ ++ if (is_cpu) ++ dma_sync_single_for_cpu(nandc->dev, nandc->reg_read_dma, ++ MAX_REG_RD * ++ sizeof(*nandc->reg_read_buf), ++ DMA_FROM_DEVICE); ++ else ++ dma_sync_single_for_device(nandc->dev, nandc->reg_read_dma, ++ MAX_REG_RD * ++ sizeof(*nandc->reg_read_buf), ++ DMA_FROM_DEVICE); ++} ++EXPORT_SYMBOL(qcom_nandc_dev_to_mem); ++ ++/** ++ * qcom_prepare_bam_async_desc() - Prepare DMA descriptor ++ * @nandc: qpic nand controller ++ * @chan: dma channel ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function maps the scatter gather list for DMA transfer and forms the ++ * DMA descriptor for BAM.This descriptor will be added in the NAND DMA ++ * descriptor queue which will be submitted to DMA engine. ++ */ ++int qcom_prepare_bam_async_desc(struct qcom_nand_controller *nandc, ++ struct dma_chan *chan, unsigned long flags) ++{ ++ struct desc_info *desc; ++ struct scatterlist *sgl; ++ unsigned int sgl_cnt; ++ int ret; ++ struct bam_transaction *bam_txn = nandc->bam_txn; ++ enum dma_transfer_direction dir_eng; ++ struct dma_async_tx_descriptor *dma_desc; ++ ++ desc = kzalloc(sizeof(*desc), GFP_KERNEL); ++ if (!desc) ++ return -ENOMEM; ++ ++ if (chan == nandc->cmd_chan) { ++ sgl = &bam_txn->cmd_sgl[bam_txn->cmd_sgl_start]; ++ sgl_cnt = bam_txn->cmd_sgl_pos - bam_txn->cmd_sgl_start; ++ bam_txn->cmd_sgl_start = bam_txn->cmd_sgl_pos; ++ dir_eng = DMA_MEM_TO_DEV; ++ desc->dir = DMA_TO_DEVICE; ++ } else if (chan == nandc->tx_chan) { ++ sgl = &bam_txn->data_sgl[bam_txn->tx_sgl_start]; ++ sgl_cnt = bam_txn->tx_sgl_pos - bam_txn->tx_sgl_start; ++ bam_txn->tx_sgl_start = bam_txn->tx_sgl_pos; ++ dir_eng = DMA_MEM_TO_DEV; ++ desc->dir = DMA_TO_DEVICE; ++ } else { ++ sgl = &bam_txn->data_sgl[bam_txn->rx_sgl_start]; ++ sgl_cnt = bam_txn->rx_sgl_pos - bam_txn->rx_sgl_start; ++ bam_txn->rx_sgl_start = bam_txn->rx_sgl_pos; ++ dir_eng = DMA_DEV_TO_MEM; ++ desc->dir = DMA_FROM_DEVICE; ++ } ++ ++ sg_mark_end(sgl + sgl_cnt - 1); ++ ret = dma_map_sg(nandc->dev, sgl, sgl_cnt, desc->dir); ++ if (ret == 0) { ++ dev_err(nandc->dev, "failure in mapping desc\n"); ++ kfree(desc); ++ return -ENOMEM; ++ } ++ ++ desc->sgl_cnt = sgl_cnt; ++ desc->bam_sgl = sgl; ++ ++ dma_desc = dmaengine_prep_slave_sg(chan, sgl, sgl_cnt, dir_eng, ++ flags); ++ ++ if (!dma_desc) { ++ dev_err(nandc->dev, "failure in prep desc\n"); ++ dma_unmap_sg(nandc->dev, sgl, sgl_cnt, desc->dir); ++ kfree(desc); ++ return -EINVAL; ++ } ++ ++ desc->dma_desc = dma_desc; ++ ++ /* update last data/command descriptor */ ++ if (chan == nandc->cmd_chan) ++ bam_txn->last_cmd_desc = dma_desc; ++ else ++ bam_txn->last_data_desc = dma_desc; ++ ++ list_add_tail(&desc->node, &nandc->desc_list); ++ ++ return 0; ++} ++EXPORT_SYMBOL(qcom_prepare_bam_async_desc); ++ ++/** ++ * qcom_prep_bam_dma_desc_cmd() - Prepares the command descriptor for BAM DMA ++ * @nandc: qpic nand controller ++ * @read: read or write type ++ * @reg_off: offset within the controller's data buffer ++ * @vaddr: virtual address of the buffer we want to write to ++ * @size: DMA transaction size in bytes ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function will prepares the command descriptor for BAM DMA ++ * which will be used for NAND register reads and writes. ++ */ ++int qcom_prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read, ++ int reg_off, const void *vaddr, ++ int size, unsigned int flags) ++{ ++ int bam_ce_size; ++ int i, ret; ++ struct bam_cmd_element *bam_ce_buffer; ++ struct bam_transaction *bam_txn = nandc->bam_txn; ++ ++ bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_pos]; ++ ++ /* fill the command desc */ ++ for (i = 0; i < size; i++) { ++ if (read) ++ bam_prep_ce(&bam_ce_buffer[i], ++ nandc_reg_phys(nandc, reg_off + 4 * i), ++ BAM_READ_COMMAND, ++ reg_buf_dma_addr(nandc, ++ (__le32 *)vaddr + i)); ++ else ++ bam_prep_ce_le32(&bam_ce_buffer[i], ++ nandc_reg_phys(nandc, reg_off + 4 * i), ++ BAM_WRITE_COMMAND, ++ *((__le32 *)vaddr + i)); ++ } ++ ++ bam_txn->bam_ce_pos += size; ++ ++ /* use the separate sgl after this command */ ++ if (flags & NAND_BAM_NEXT_SGL) { ++ bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_start]; ++ bam_ce_size = (bam_txn->bam_ce_pos - ++ bam_txn->bam_ce_start) * ++ sizeof(struct bam_cmd_element); ++ sg_set_buf(&bam_txn->cmd_sgl[bam_txn->cmd_sgl_pos], ++ bam_ce_buffer, bam_ce_size); ++ bam_txn->cmd_sgl_pos++; ++ bam_txn->bam_ce_start = bam_txn->bam_ce_pos; ++ ++ if (flags & NAND_BAM_NWD) { ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan, ++ DMA_PREP_FENCE | DMA_PREP_CMD); ++ if (ret) ++ return ret; ++ } ++ } ++ ++ return 0; ++} ++EXPORT_SYMBOL(qcom_prep_bam_dma_desc_cmd); ++ ++/** ++ * qcom_prep_bam_dma_desc_data() - Prepares the data descriptor for BAM DMA ++ * @nandc: qpic nand controller ++ * @read: read or write type ++ * @vaddr: virtual address of the buffer we want to write to ++ * @size: DMA transaction size in bytes ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function will prepares the data descriptor for BAM DMA which ++ * will be used for NAND data reads and writes. ++ */ ++int qcom_prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, ++ const void *vaddr, int size, unsigned int flags) ++{ ++ int ret; ++ struct bam_transaction *bam_txn = nandc->bam_txn; ++ ++ if (read) { ++ sg_set_buf(&bam_txn->data_sgl[bam_txn->rx_sgl_pos], ++ vaddr, size); ++ bam_txn->rx_sgl_pos++; ++ } else { ++ sg_set_buf(&bam_txn->data_sgl[bam_txn->tx_sgl_pos], ++ vaddr, size); ++ bam_txn->tx_sgl_pos++; ++ ++ /* ++ * BAM will only set EOT for DMA_PREP_INTERRUPT so if this flag ++ * is not set, form the DMA descriptor ++ */ ++ if (!(flags & NAND_BAM_NO_EOT)) { ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan, ++ DMA_PREP_INTERRUPT); ++ if (ret) ++ return ret; ++ } ++ } ++ ++ return 0; ++} ++EXPORT_SYMBOL(qcom_prep_bam_dma_desc_data); ++ ++/** ++ * qcom_prep_adm_dma_desc() - Prepare descriptor for adma ++ * @nandc: qpic nand controller ++ * @read: read or write type ++ * @reg_off: offset within the controller's data buffer ++ * @vaddr: virtual address of the buffer we want to write to ++ * @size: adm dma transaction size in bytes ++ * @flow_control: flow controller ++ * ++ * This function will prepare descriptor for adma ++ */ ++int qcom_prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, ++ int reg_off, const void *vaddr, int size, ++ bool flow_control) ++{ ++ struct qcom_adm_peripheral_config periph_conf = {}; ++ struct dma_async_tx_descriptor *dma_desc; ++ struct dma_slave_config slave_conf = {0}; ++ enum dma_transfer_direction dir_eng; ++ struct desc_info *desc; ++ struct scatterlist *sgl; ++ int ret; ++ ++ desc = kzalloc(sizeof(*desc), GFP_KERNEL); ++ if (!desc) ++ return -ENOMEM; ++ ++ sgl = &desc->adm_sgl; ++ ++ sg_init_one(sgl, vaddr, size); ++ ++ if (read) { ++ dir_eng = DMA_DEV_TO_MEM; ++ desc->dir = DMA_FROM_DEVICE; ++ } else { ++ dir_eng = DMA_MEM_TO_DEV; ++ desc->dir = DMA_TO_DEVICE; ++ } ++ ++ ret = dma_map_sg(nandc->dev, sgl, 1, desc->dir); ++ if (!ret) { ++ ret = -ENOMEM; ++ goto err; ++ } ++ ++ slave_conf.device_fc = flow_control; ++ if (read) { ++ slave_conf.src_maxburst = 16; ++ slave_conf.src_addr = nandc->base_dma + reg_off; ++ if (nandc->data_crci) { ++ periph_conf.crci = nandc->data_crci; ++ slave_conf.peripheral_config = &periph_conf; ++ slave_conf.peripheral_size = sizeof(periph_conf); ++ } ++ } else { ++ slave_conf.dst_maxburst = 16; ++ slave_conf.dst_addr = nandc->base_dma + reg_off; ++ if (nandc->cmd_crci) { ++ periph_conf.crci = nandc->cmd_crci; ++ slave_conf.peripheral_config = &periph_conf; ++ slave_conf.peripheral_size = sizeof(periph_conf); ++ } ++ } ++ ++ ret = dmaengine_slave_config(nandc->chan, &slave_conf); ++ if (ret) { ++ dev_err(nandc->dev, "failed to configure dma channel\n"); ++ goto err; ++ } ++ ++ dma_desc = dmaengine_prep_slave_sg(nandc->chan, sgl, 1, dir_eng, 0); ++ if (!dma_desc) { ++ dev_err(nandc->dev, "failed to prepare desc\n"); ++ ret = -EINVAL; ++ goto err; ++ } ++ ++ desc->dma_desc = dma_desc; ++ ++ list_add_tail(&desc->node, &nandc->desc_list); ++ ++ return 0; ++err: ++ kfree(desc); ++ ++ return ret; ++} ++EXPORT_SYMBOL(qcom_prep_adm_dma_desc); ++ ++/** ++ * qcom_read_reg_dma() - read a given number of registers to the reg_read_buf pointer ++ * @nandc: qpic nand controller ++ * @first: offset of the first register in the contiguous block ++ * @num_regs: number of registers to read ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function will prepares a descriptor to read a given number of ++ * contiguous registers to the reg_read_buf pointer. ++ */ ++int qcom_read_reg_dma(struct qcom_nand_controller *nandc, int first, ++ int num_regs, unsigned int flags) ++{ ++ bool flow_control = false; ++ void *vaddr; ++ ++ vaddr = nandc->reg_read_buf + nandc->reg_read_pos; ++ nandc->reg_read_pos += num_regs; ++ ++ if (first == NAND_DEV_CMD_VLD || first == NAND_DEV_CMD1) ++ first = dev_cmd_reg_addr(nandc, first); ++ ++ if (nandc->props->supports_bam) ++ return qcom_prep_bam_dma_desc_cmd(nandc, true, first, vaddr, ++ num_regs, flags); ++ ++ if (first == NAND_READ_ID || first == NAND_FLASH_STATUS) ++ flow_control = true; ++ ++ return qcom_prep_adm_dma_desc(nandc, true, first, vaddr, ++ num_regs * sizeof(u32), flow_control); ++} ++EXPORT_SYMBOL(qcom_read_reg_dma); ++ ++/** ++ * qcom_write_reg_dma() - write a given number of registers ++ * @nandc: qpic nand controller ++ * @vaddr: contiguous memory from where register value will ++ * be written ++ * @first: offset of the first register in the contiguous block ++ * @num_regs: number of registers to write ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function will prepares a descriptor to write a given number of ++ * contiguous registers ++ */ ++int qcom_write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, ++ int first, int num_regs, unsigned int flags) ++{ ++ bool flow_control = false; ++ ++ if (first == NAND_EXEC_CMD) ++ flags |= NAND_BAM_NWD; ++ ++ if (first == NAND_DEV_CMD1_RESTORE || first == NAND_DEV_CMD1) ++ first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD1); ++ ++ if (first == NAND_DEV_CMD_VLD_RESTORE || first == NAND_DEV_CMD_VLD) ++ first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD); ++ ++ if (nandc->props->supports_bam) ++ return qcom_prep_bam_dma_desc_cmd(nandc, false, first, vaddr, ++ num_regs, flags); ++ ++ if (first == NAND_FLASH_CMD) ++ flow_control = true; ++ ++ return qcom_prep_adm_dma_desc(nandc, false, first, vaddr, ++ num_regs * sizeof(u32), flow_control); ++} ++EXPORT_SYMBOL(qcom_write_reg_dma); ++ ++/** ++ * qcom_read_data_dma() - transfer data ++ * @nandc: qpic nand controller ++ * @reg_off: offset within the controller's data buffer ++ * @vaddr: virtual address of the buffer we want to write to ++ * @size: DMA transaction size in bytes ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function will prepares a DMA descriptor to transfer data from the ++ * controller's internal buffer to the buffer 'vaddr' ++ */ ++int qcom_read_data_dma(struct qcom_nand_controller *nandc, int reg_off, ++ const u8 *vaddr, int size, unsigned int flags) ++{ ++ if (nandc->props->supports_bam) ++ return qcom_prep_bam_dma_desc_data(nandc, true, vaddr, size, flags); ++ ++ return qcom_prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false); ++} ++EXPORT_SYMBOL(qcom_read_data_dma); ++ ++/** ++ * qcom_write_data_dma() - transfer data ++ * @nandc: qpic nand controller ++ * @reg_off: offset within the controller's data buffer ++ * @vaddr: virtual address of the buffer we want to read from ++ * @size: DMA transaction size in bytes ++ * @flags: flags to control DMA descriptor preparation ++ * ++ * This function will prepares a DMA descriptor to transfer data from ++ * 'vaddr' to the controller's internal buffer ++ */ ++int qcom_write_data_dma(struct qcom_nand_controller *nandc, int reg_off, ++ const u8 *vaddr, int size, unsigned int flags) ++{ ++ if (nandc->props->supports_bam) ++ return qcom_prep_bam_dma_desc_data(nandc, false, vaddr, size, flags); ++ ++ return qcom_prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false); ++} ++EXPORT_SYMBOL(qcom_write_data_dma); ++ ++/** ++ * qcom_submit_descs() - submit dma descriptor ++ * @nandc: qpic nand controller ++ * ++ * This function will submit all the prepared dma descriptor ++ * cmd or data descriptor ++ */ ++int qcom_submit_descs(struct qcom_nand_controller *nandc) ++{ ++ struct desc_info *desc, *n; ++ dma_cookie_t cookie = 0; ++ struct bam_transaction *bam_txn = nandc->bam_txn; ++ int ret = 0; ++ ++ if (nandc->props->supports_bam) { ++ if (bam_txn->rx_sgl_pos > bam_txn->rx_sgl_start) { ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->rx_chan, 0); ++ if (ret) ++ goto err_unmap_free_desc; ++ } ++ ++ if (bam_txn->tx_sgl_pos > bam_txn->tx_sgl_start) { ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan, ++ DMA_PREP_INTERRUPT); ++ if (ret) ++ goto err_unmap_free_desc; ++ } ++ ++ if (bam_txn->cmd_sgl_pos > bam_txn->cmd_sgl_start) { ++ ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan, ++ DMA_PREP_CMD); ++ if (ret) ++ goto err_unmap_free_desc; ++ } ++ } ++ ++ list_for_each_entry(desc, &nandc->desc_list, node) ++ cookie = dmaengine_submit(desc->dma_desc); ++ ++ if (nandc->props->supports_bam) { ++ bam_txn->last_cmd_desc->callback = qcom_qpic_bam_dma_done; ++ bam_txn->last_cmd_desc->callback_param = bam_txn; ++ ++ dma_async_issue_pending(nandc->tx_chan); ++ dma_async_issue_pending(nandc->rx_chan); ++ dma_async_issue_pending(nandc->cmd_chan); ++ ++ if (!wait_for_completion_timeout(&bam_txn->txn_done, ++ QPIC_NAND_COMPLETION_TIMEOUT)) ++ ret = -ETIMEDOUT; ++ } else { ++ if (dma_sync_wait(nandc->chan, cookie) != DMA_COMPLETE) ++ ret = -ETIMEDOUT; ++ } ++ ++err_unmap_free_desc: ++ /* ++ * Unmap the dma sg_list and free the desc allocated by both ++ * qcom_prepare_bam_async_desc() and qcom_prep_adm_dma_desc() functions. ++ */ ++ list_for_each_entry_safe(desc, n, &nandc->desc_list, node) { ++ list_del(&desc->node); ++ ++ if (nandc->props->supports_bam) ++ dma_unmap_sg(nandc->dev, desc->bam_sgl, ++ desc->sgl_cnt, desc->dir); ++ else ++ dma_unmap_sg(nandc->dev, &desc->adm_sgl, 1, ++ desc->dir); ++ ++ kfree(desc); ++ } ++ ++ return ret; ++} ++EXPORT_SYMBOL(qcom_submit_descs); ++ ++/** ++ * qcom_clear_read_regs() - reset the read register buffer ++ * @nandc: qpic nand controller ++ * ++ * This function reset the register read buffer for next NAND operation ++ */ ++void qcom_clear_read_regs(struct qcom_nand_controller *nandc) ++{ ++ nandc->reg_read_pos = 0; ++ qcom_nandc_dev_to_mem(nandc, false); ++} ++EXPORT_SYMBOL(qcom_clear_read_regs); ++ ++/** ++ * qcom_nandc_unalloc() - unallocate qpic nand controller ++ * @nandc: qpic nand controller ++ * ++ * This function will unallocate memory alloacted for qpic nand controller ++ */ ++void qcom_nandc_unalloc(struct qcom_nand_controller *nandc) ++{ ++ if (nandc->props->supports_bam) { ++ if (!dma_mapping_error(nandc->dev, nandc->reg_read_dma)) ++ dma_unmap_single(nandc->dev, nandc->reg_read_dma, ++ MAX_REG_RD * ++ sizeof(*nandc->reg_read_buf), ++ DMA_FROM_DEVICE); ++ ++ if (nandc->tx_chan) ++ dma_release_channel(nandc->tx_chan); ++ ++ if (nandc->rx_chan) ++ dma_release_channel(nandc->rx_chan); ++ ++ if (nandc->cmd_chan) ++ dma_release_channel(nandc->cmd_chan); ++ } else { ++ if (nandc->chan) ++ dma_release_channel(nandc->chan); ++ } ++} ++EXPORT_SYMBOL(qcom_nandc_unalloc); ++ ++/** ++ * qcom_nandc_alloc() - Allocate qpic nand controller ++ * @nandc: qpic nand controller ++ * ++ * This function will allocate memory for qpic nand controller ++ */ ++int qcom_nandc_alloc(struct qcom_nand_controller *nandc) ++{ ++ int ret; ++ ++ ret = dma_set_coherent_mask(nandc->dev, DMA_BIT_MASK(32)); ++ if (ret) { ++ dev_err(nandc->dev, "failed to set DMA mask\n"); ++ return ret; ++ } ++ ++ /* ++ * we use the internal buffer for reading ONFI params, reading small ++ * data like ID and status, and preforming read-copy-write operations ++ * when writing to a codeword partially. 532 is the maximum possible ++ * size of a codeword for our nand controller ++ */ ++ nandc->buf_size = 532; ++ ++ nandc->data_buffer = devm_kzalloc(nandc->dev, nandc->buf_size, GFP_KERNEL); ++ if (!nandc->data_buffer) ++ return -ENOMEM; ++ ++ nandc->regs = devm_kzalloc(nandc->dev, sizeof(*nandc->regs), GFP_KERNEL); ++ if (!nandc->regs) ++ return -ENOMEM; ++ ++ nandc->reg_read_buf = devm_kcalloc(nandc->dev, MAX_REG_RD, ++ sizeof(*nandc->reg_read_buf), ++ GFP_KERNEL); ++ if (!nandc->reg_read_buf) ++ return -ENOMEM; ++ ++ if (nandc->props->supports_bam) { ++ nandc->reg_read_dma = ++ dma_map_single(nandc->dev, nandc->reg_read_buf, ++ MAX_REG_RD * ++ sizeof(*nandc->reg_read_buf), ++ DMA_FROM_DEVICE); ++ if (dma_mapping_error(nandc->dev, nandc->reg_read_dma)) { ++ dev_err(nandc->dev, "failed to DMA MAP reg buffer\n"); ++ return -EIO; ++ } ++ ++ nandc->tx_chan = dma_request_chan(nandc->dev, "tx"); ++ if (IS_ERR(nandc->tx_chan)) { ++ ret = PTR_ERR(nandc->tx_chan); ++ nandc->tx_chan = NULL; ++ dev_err_probe(nandc->dev, ret, ++ "tx DMA channel request failed\n"); ++ goto unalloc; ++ } ++ ++ nandc->rx_chan = dma_request_chan(nandc->dev, "rx"); ++ if (IS_ERR(nandc->rx_chan)) { ++ ret = PTR_ERR(nandc->rx_chan); ++ nandc->rx_chan = NULL; ++ dev_err_probe(nandc->dev, ret, ++ "rx DMA channel request failed\n"); ++ goto unalloc; ++ } ++ ++ nandc->cmd_chan = dma_request_chan(nandc->dev, "cmd"); ++ if (IS_ERR(nandc->cmd_chan)) { ++ ret = PTR_ERR(nandc->cmd_chan); ++ nandc->cmd_chan = NULL; ++ dev_err_probe(nandc->dev, ret, ++ "cmd DMA channel request failed\n"); ++ goto unalloc; ++ } ++ ++ /* ++ * Initially allocate BAM transaction to read ONFI param page. ++ * After detecting all the devices, this BAM transaction will ++ * be freed and the next BAM transaction will be allocated with ++ * maximum codeword size ++ */ ++ nandc->max_cwperpage = 1; ++ nandc->bam_txn = qcom_alloc_bam_transaction(nandc); ++ if (!nandc->bam_txn) { ++ dev_err(nandc->dev, ++ "failed to allocate bam transaction\n"); ++ ret = -ENOMEM; ++ goto unalloc; ++ } ++ } else { ++ nandc->chan = dma_request_chan(nandc->dev, "rxtx"); ++ if (IS_ERR(nandc->chan)) { ++ ret = PTR_ERR(nandc->chan); ++ nandc->chan = NULL; ++ dev_err_probe(nandc->dev, ret, ++ "rxtx DMA channel request failed\n"); ++ return ret; ++ } ++ } ++ ++ INIT_LIST_HEAD(&nandc->desc_list); ++ INIT_LIST_HEAD(&nandc->host_list); ++ ++ return 0; ++unalloc: ++ qcom_nandc_unalloc(nandc); ++ return ret; ++} ++EXPORT_SYMBOL(qcom_nandc_alloc); ++ ++MODULE_DESCRIPTION("QPIC controller common api"); ++MODULE_LICENSE("GPL"); +--- a/drivers/mtd/nand/raw/qcom_nandc.c ++++ b/drivers/mtd/nand/raw/qcom_nandc.c +@@ -15,417 +15,7 @@ + #include + #include + #include +- +-/* NANDc reg offsets */ +-#define NAND_FLASH_CMD 0x00 +-#define NAND_ADDR0 0x04 +-#define NAND_ADDR1 0x08 +-#define NAND_FLASH_CHIP_SELECT 0x0c +-#define NAND_EXEC_CMD 0x10 +-#define NAND_FLASH_STATUS 0x14 +-#define NAND_BUFFER_STATUS 0x18 +-#define NAND_DEV0_CFG0 0x20 +-#define NAND_DEV0_CFG1 0x24 +-#define NAND_DEV0_ECC_CFG 0x28 +-#define NAND_AUTO_STATUS_EN 0x2c +-#define NAND_DEV1_CFG0 0x30 +-#define NAND_DEV1_CFG1 0x34 +-#define NAND_READ_ID 0x40 +-#define NAND_READ_STATUS 0x44 +-#define NAND_DEV_CMD0 0xa0 +-#define NAND_DEV_CMD1 0xa4 +-#define NAND_DEV_CMD2 0xa8 +-#define NAND_DEV_CMD_VLD 0xac +-#define SFLASHC_BURST_CFG 0xe0 +-#define NAND_ERASED_CW_DETECT_CFG 0xe8 +-#define NAND_ERASED_CW_DETECT_STATUS 0xec +-#define NAND_EBI2_ECC_BUF_CFG 0xf0 +-#define FLASH_BUF_ACC 0x100 +- +-#define NAND_CTRL 0xf00 +-#define NAND_VERSION 0xf08 +-#define NAND_READ_LOCATION_0 0xf20 +-#define NAND_READ_LOCATION_1 0xf24 +-#define NAND_READ_LOCATION_2 0xf28 +-#define NAND_READ_LOCATION_3 0xf2c +-#define NAND_READ_LOCATION_LAST_CW_0 0xf40 +-#define NAND_READ_LOCATION_LAST_CW_1 0xf44 +-#define NAND_READ_LOCATION_LAST_CW_2 0xf48 +-#define NAND_READ_LOCATION_LAST_CW_3 0xf4c +- +-/* dummy register offsets, used by qcom_write_reg_dma */ +-#define NAND_DEV_CMD1_RESTORE 0xdead +-#define NAND_DEV_CMD_VLD_RESTORE 0xbeef +- +-/* NAND_FLASH_CMD bits */ +-#define PAGE_ACC BIT(4) +-#define LAST_PAGE BIT(5) +- +-/* NAND_FLASH_CHIP_SELECT bits */ +-#define NAND_DEV_SEL 0 +-#define DM_EN BIT(2) +- +-/* NAND_FLASH_STATUS bits */ +-#define FS_OP_ERR BIT(4) +-#define FS_READY_BSY_N BIT(5) +-#define FS_MPU_ERR BIT(8) +-#define FS_DEVICE_STS_ERR BIT(16) +-#define FS_DEVICE_WP BIT(23) +- +-/* NAND_BUFFER_STATUS bits */ +-#define BS_UNCORRECTABLE_BIT BIT(8) +-#define BS_CORRECTABLE_ERR_MSK 0x1f +- +-/* NAND_DEVn_CFG0 bits */ +-#define DISABLE_STATUS_AFTER_WRITE 4 +-#define CW_PER_PAGE 6 +-#define UD_SIZE_BYTES 9 +-#define UD_SIZE_BYTES_MASK GENMASK(18, 9) +-#define ECC_PARITY_SIZE_BYTES_RS 19 +-#define SPARE_SIZE_BYTES 23 +-#define SPARE_SIZE_BYTES_MASK GENMASK(26, 23) +-#define NUM_ADDR_CYCLES 27 +-#define STATUS_BFR_READ 30 +-#define SET_RD_MODE_AFTER_STATUS 31 +- +-/* NAND_DEVn_CFG0 bits */ +-#define DEV0_CFG1_ECC_DISABLE 0 +-#define WIDE_FLASH 1 +-#define NAND_RECOVERY_CYCLES 2 +-#define CS_ACTIVE_BSY 5 +-#define BAD_BLOCK_BYTE_NUM 6 +-#define BAD_BLOCK_IN_SPARE_AREA 16 +-#define WR_RD_BSY_GAP 17 +-#define ENABLE_BCH_ECC 27 +- +-/* NAND_DEV0_ECC_CFG bits */ +-#define ECC_CFG_ECC_DISABLE 0 +-#define ECC_SW_RESET 1 +-#define ECC_MODE 4 +-#define ECC_PARITY_SIZE_BYTES_BCH 8 +-#define ECC_NUM_DATA_BYTES 16 +-#define ECC_NUM_DATA_BYTES_MASK GENMASK(25, 16) +-#define ECC_FORCE_CLK_OPEN 30 +- +-/* NAND_DEV_CMD1 bits */ +-#define READ_ADDR 0 +- +-/* NAND_DEV_CMD_VLD bits */ +-#define READ_START_VLD BIT(0) +-#define READ_STOP_VLD BIT(1) +-#define WRITE_START_VLD BIT(2) +-#define ERASE_START_VLD BIT(3) +-#define SEQ_READ_START_VLD BIT(4) +- +-/* NAND_EBI2_ECC_BUF_CFG bits */ +-#define NUM_STEPS 0 +- +-/* NAND_ERASED_CW_DETECT_CFG bits */ +-#define ERASED_CW_ECC_MASK 1 +-#define AUTO_DETECT_RES 0 +-#define MASK_ECC BIT(ERASED_CW_ECC_MASK) +-#define RESET_ERASED_DET BIT(AUTO_DETECT_RES) +-#define ACTIVE_ERASED_DET (0 << AUTO_DETECT_RES) +-#define CLR_ERASED_PAGE_DET (RESET_ERASED_DET | MASK_ECC) +-#define SET_ERASED_PAGE_DET (ACTIVE_ERASED_DET | MASK_ECC) +- +-/* NAND_ERASED_CW_DETECT_STATUS bits */ +-#define PAGE_ALL_ERASED BIT(7) +-#define CODEWORD_ALL_ERASED BIT(6) +-#define PAGE_ERASED BIT(5) +-#define CODEWORD_ERASED BIT(4) +-#define ERASED_PAGE (PAGE_ALL_ERASED | PAGE_ERASED) +-#define ERASED_CW (CODEWORD_ALL_ERASED | CODEWORD_ERASED) +- +-/* NAND_READ_LOCATION_n bits */ +-#define READ_LOCATION_OFFSET 0 +-#define READ_LOCATION_SIZE 16 +-#define READ_LOCATION_LAST 31 +- +-/* Version Mask */ +-#define NAND_VERSION_MAJOR_MASK 0xf0000000 +-#define NAND_VERSION_MAJOR_SHIFT 28 +-#define NAND_VERSION_MINOR_MASK 0x0fff0000 +-#define NAND_VERSION_MINOR_SHIFT 16 +- +-/* NAND OP_CMDs */ +-#define OP_PAGE_READ 0x2 +-#define OP_PAGE_READ_WITH_ECC 0x3 +-#define OP_PAGE_READ_WITH_ECC_SPARE 0x4 +-#define OP_PAGE_READ_ONFI_READ 0x5 +-#define OP_PROGRAM_PAGE 0x6 +-#define OP_PAGE_PROGRAM_WITH_ECC 0x7 +-#define OP_PROGRAM_PAGE_SPARE 0x9 +-#define OP_BLOCK_ERASE 0xa +-#define OP_CHECK_STATUS 0xc +-#define OP_FETCH_ID 0xb +-#define OP_RESET_DEVICE 0xd +- +-/* Default Value for NAND_DEV_CMD_VLD */ +-#define NAND_DEV_CMD_VLD_VAL (READ_START_VLD | WRITE_START_VLD | \ +- ERASE_START_VLD | SEQ_READ_START_VLD) +- +-/* NAND_CTRL bits */ +-#define BAM_MODE_EN BIT(0) +- +-/* +- * the NAND controller performs reads/writes with ECC in 516 byte chunks. +- * the driver calls the chunks 'step' or 'codeword' interchangeably +- */ +-#define NANDC_STEP_SIZE 512 +- +-/* +- * the largest page size we support is 8K, this will have 16 steps/codewords +- * of 512 bytes each +- */ +-#define MAX_NUM_STEPS (SZ_8K / NANDC_STEP_SIZE) +- +-/* we read at most 3 registers per codeword scan */ +-#define MAX_REG_RD (3 * MAX_NUM_STEPS) +- +-/* ECC modes supported by the controller */ +-#define ECC_NONE BIT(0) +-#define ECC_RS_4BIT BIT(1) +-#define ECC_BCH_4BIT BIT(2) +-#define ECC_BCH_8BIT BIT(3) +- +-/* +- * Returns the actual register address for all NAND_DEV_ registers +- * (i.e. NAND_DEV_CMD0, NAND_DEV_CMD1, NAND_DEV_CMD2 and NAND_DEV_CMD_VLD) +- */ +-#define dev_cmd_reg_addr(nandc, reg) ((nandc)->props->dev_cmd_reg_start + (reg)) +- +-/* Returns the NAND register physical address */ +-#define nandc_reg_phys(chip, offset) ((chip)->base_phys + (offset)) +- +-/* Returns the dma address for reg read buffer */ +-#define reg_buf_dma_addr(chip, vaddr) \ +- ((chip)->reg_read_dma + \ +- ((u8 *)(vaddr) - (u8 *)(chip)->reg_read_buf)) +- +-#define QPIC_PER_CW_CMD_ELEMENTS 32 +-#define QPIC_PER_CW_CMD_SGL 32 +-#define QPIC_PER_CW_DATA_SGL 8 +- +-#define QPIC_NAND_COMPLETION_TIMEOUT msecs_to_jiffies(2000) +- +-/* +- * Flags used in DMA descriptor preparation helper functions +- * (i.e. qcom_read_reg_dma/qcom_write_reg_dma/qcom_read_data_dma/qcom_write_data_dma) +- */ +-/* Don't set the EOT in current tx BAM sgl */ +-#define NAND_BAM_NO_EOT BIT(0) +-/* Set the NWD flag in current BAM sgl */ +-#define NAND_BAM_NWD BIT(1) +-/* Finish writing in the current BAM sgl and start writing in another BAM sgl */ +-#define NAND_BAM_NEXT_SGL BIT(2) +-/* +- * Erased codeword status is being used two times in single transfer so this +- * flag will determine the current value of erased codeword status register +- */ +-#define NAND_ERASED_CW_SET BIT(4) +- +-#define MAX_ADDRESS_CYCLE 5 +- +-/* +- * This data type corresponds to the BAM transaction which will be used for all +- * NAND transfers. +- * @bam_ce - the array of BAM command elements +- * @cmd_sgl - sgl for NAND BAM command pipe +- * @data_sgl - sgl for NAND BAM consumer/producer pipe +- * @last_data_desc - last DMA desc in data channel (tx/rx). +- * @last_cmd_desc - last DMA desc in command channel. +- * @txn_done - completion for NAND transfer. +- * @bam_ce_pos - the index in bam_ce which is available for next sgl +- * @bam_ce_start - the index in bam_ce which marks the start position ce +- * for current sgl. It will be used for size calculation +- * for current sgl +- * @cmd_sgl_pos - current index in command sgl. +- * @cmd_sgl_start - start index in command sgl. +- * @tx_sgl_pos - current index in data sgl for tx. +- * @tx_sgl_start - start index in data sgl for tx. +- * @rx_sgl_pos - current index in data sgl for rx. +- * @rx_sgl_start - start index in data sgl for rx. +- */ +-struct bam_transaction { +- struct bam_cmd_element *bam_ce; +- struct scatterlist *cmd_sgl; +- struct scatterlist *data_sgl; +- struct dma_async_tx_descriptor *last_data_desc; +- struct dma_async_tx_descriptor *last_cmd_desc; +- struct completion txn_done; +- u32 bam_ce_pos; +- u32 bam_ce_start; +- u32 cmd_sgl_pos; +- u32 cmd_sgl_start; +- u32 tx_sgl_pos; +- u32 tx_sgl_start; +- u32 rx_sgl_pos; +- u32 rx_sgl_start; +-}; +- +-/* +- * This data type corresponds to the nand dma descriptor +- * @dma_desc - low level DMA engine descriptor +- * @list - list for desc_info +- * +- * @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by +- * ADM +- * @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM +- * @sgl_cnt - number of SGL in bam_sgl. Only used by BAM +- * @dir - DMA transfer direction +- */ +-struct desc_info { +- struct dma_async_tx_descriptor *dma_desc; +- struct list_head node; +- +- union { +- struct scatterlist adm_sgl; +- struct { +- struct scatterlist *bam_sgl; +- int sgl_cnt; +- }; +- }; +- enum dma_data_direction dir; +-}; +- +-/* +- * holds the current register values that we want to write. acts as a contiguous +- * chunk of memory which we use to write the controller registers through DMA. +- */ +-struct nandc_regs { +- __le32 cmd; +- __le32 addr0; +- __le32 addr1; +- __le32 chip_sel; +- __le32 exec; +- +- __le32 cfg0; +- __le32 cfg1; +- __le32 ecc_bch_cfg; +- +- __le32 clrflashstatus; +- __le32 clrreadstatus; +- +- __le32 cmd1; +- __le32 vld; +- +- __le32 orig_cmd1; +- __le32 orig_vld; +- +- __le32 ecc_buf_cfg; +- __le32 read_location0; +- __le32 read_location1; +- __le32 read_location2; +- __le32 read_location3; +- __le32 read_location_last0; +- __le32 read_location_last1; +- __le32 read_location_last2; +- __le32 read_location_last3; +- +- __le32 erased_cw_detect_cfg_clr; +- __le32 erased_cw_detect_cfg_set; +-}; +- +-/* +- * NAND controller data struct +- * +- * @dev: parent device +- * +- * @base: MMIO base +- * +- * @core_clk: controller clock +- * @aon_clk: another controller clock +- * +- * @regs: a contiguous chunk of memory for DMA register +- * writes. contains the register values to be +- * written to controller +- * +- * @props: properties of current NAND controller, +- * initialized via DT match data +- * +- * @controller: base controller structure +- * @host_list: list containing all the chips attached to the +- * controller +- * +- * @chan: dma channel +- * @cmd_crci: ADM DMA CRCI for command flow control +- * @data_crci: ADM DMA CRCI for data flow control +- * +- * @desc_list: DMA descriptor list (list of desc_infos) +- * +- * @data_buffer: our local DMA buffer for page read/writes, +- * used when we can't use the buffer provided +- * by upper layers directly +- * @reg_read_buf: local buffer for reading back registers via DMA +- * +- * @base_phys: physical base address of controller registers +- * @base_dma: dma base address of controller registers +- * @reg_read_dma: contains dma address for register read buffer +- * +- * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf +- * functions +- * @max_cwperpage: maximum QPIC codewords required. calculated +- * from all connected NAND devices pagesize +- * +- * @reg_read_pos: marker for data read in reg_read_buf +- * +- * @cmd1/vld: some fixed controller register values +- * +- * @exec_opwrite: flag to select correct number of code word +- * while reading status +- */ +-struct qcom_nand_controller { +- struct device *dev; +- +- void __iomem *base; +- +- struct clk *core_clk; +- struct clk *aon_clk; +- +- struct nandc_regs *regs; +- struct bam_transaction *bam_txn; +- +- const struct qcom_nandc_props *props; +- +- struct nand_controller controller; +- struct list_head host_list; +- +- union { +- /* will be used only by QPIC for BAM DMA */ +- struct { +- struct dma_chan *tx_chan; +- struct dma_chan *rx_chan; +- struct dma_chan *cmd_chan; +- }; +- +- /* will be used only by EBI2 for ADM DMA */ +- struct { +- struct dma_chan *chan; +- unsigned int cmd_crci; +- unsigned int data_crci; +- }; +- }; +- +- struct list_head desc_list; +- +- u8 *data_buffer; +- __le32 *reg_read_buf; +- +- phys_addr_t base_phys; +- dma_addr_t base_dma; +- dma_addr_t reg_read_dma; +- +- int buf_size; +- int buf_count; +- int buf_start; +- unsigned int max_cwperpage; +- +- int reg_read_pos; +- +- u32 cmd1, vld; +- bool exec_opwrite; +-}; ++#include + + /* + * NAND special boot partitions +@@ -530,97 +120,6 @@ struct qcom_nand_host { + bool bch_enabled; + }; + +-/* +- * This data type corresponds to the NAND controller properties which varies +- * among different NAND controllers. +- * @ecc_modes - ecc mode for NAND +- * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset +- * @supports_bam - whether NAND controller is using Bus Access Manager (BAM) +- * @nandc_part_of_qpic - whether NAND controller is part of qpic IP +- * @qpic_version2 - flag to indicate QPIC IP version 2 +- * @use_codeword_fixup - whether NAND has different layout for boot partitions +- */ +-struct qcom_nandc_props { +- u32 ecc_modes; +- u32 dev_cmd_reg_start; +- bool supports_bam; +- bool nandc_part_of_qpic; +- bool qpic_version2; +- bool use_codeword_fixup; +-}; +- +-/* Frees the BAM transaction memory */ +-static void qcom_free_bam_transaction(struct qcom_nand_controller *nandc) +-{ +- struct bam_transaction *bam_txn = nandc->bam_txn; +- +- devm_kfree(nandc->dev, bam_txn); +-} +- +-/* Allocates and Initializes the BAM transaction */ +-static struct bam_transaction * +-qcom_alloc_bam_transaction(struct qcom_nand_controller *nandc) +-{ +- struct bam_transaction *bam_txn; +- size_t bam_txn_size; +- unsigned int num_cw = nandc->max_cwperpage; +- void *bam_txn_buf; +- +- bam_txn_size = +- sizeof(*bam_txn) + num_cw * +- ((sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS) + +- (sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) + +- (sizeof(*bam_txn->data_sgl) * QPIC_PER_CW_DATA_SGL)); +- +- bam_txn_buf = devm_kzalloc(nandc->dev, bam_txn_size, GFP_KERNEL); +- if (!bam_txn_buf) +- return NULL; +- +- bam_txn = bam_txn_buf; +- bam_txn_buf += sizeof(*bam_txn); +- +- bam_txn->bam_ce = bam_txn_buf; +- bam_txn_buf += +- sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS * num_cw; +- +- bam_txn->cmd_sgl = bam_txn_buf; +- bam_txn_buf += +- sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL * num_cw; +- +- bam_txn->data_sgl = bam_txn_buf; +- +- init_completion(&bam_txn->txn_done); +- +- return bam_txn; +-} +- +-/* Clears the BAM transaction indexes */ +-static void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc) +-{ +- struct bam_transaction *bam_txn = nandc->bam_txn; +- +- if (!nandc->props->supports_bam) +- return; +- +- memset(&bam_txn->bam_ce_pos, 0, sizeof(u32) * 8); +- bam_txn->last_data_desc = NULL; +- +- sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage * +- QPIC_PER_CW_CMD_SGL); +- sg_init_table(bam_txn->data_sgl, nandc->max_cwperpage * +- QPIC_PER_CW_DATA_SGL); +- +- reinit_completion(&bam_txn->txn_done); +-} +- +-/* Callback for DMA descriptor completion */ +-static void qcom_qpic_bam_dma_done(void *data) +-{ +- struct bam_transaction *bam_txn = data; +- +- complete(&bam_txn->txn_done); +-} +- + static struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip) + { + return container_of(chip, struct qcom_nand_host, chip); +@@ -629,8 +128,8 @@ static struct qcom_nand_host *to_qcom_na + static struct qcom_nand_controller * + get_qcom_nand_controller(struct nand_chip *chip) + { +- return container_of(chip->controller, struct qcom_nand_controller, +- controller); ++ return (struct qcom_nand_controller *) ++ ((u8 *)chip->controller - sizeof(struct qcom_nand_controller)); + } + + static u32 nandc_read(struct qcom_nand_controller *nandc, int offset) +@@ -644,23 +143,6 @@ static void nandc_write(struct qcom_nand + iowrite32(val, nandc->base + offset); + } + +-static void qcom_nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu) +-{ +- if (!nandc->props->supports_bam) +- return; +- +- if (is_cpu) +- dma_sync_single_for_cpu(nandc->dev, nandc->reg_read_dma, +- MAX_REG_RD * +- sizeof(*nandc->reg_read_buf), +- DMA_FROM_DEVICE); +- else +- dma_sync_single_for_device(nandc->dev, nandc->reg_read_dma, +- MAX_REG_RD * +- sizeof(*nandc->reg_read_buf), +- DMA_FROM_DEVICE); +-} +- + /* Helper to check whether this is the last CW or not */ + static bool qcom_nandc_is_last_cw(struct nand_ecc_ctrl *ecc, int cw) + { +@@ -820,356 +302,6 @@ static void update_rw_regs(struct qcom_n + } + + /* +- * Maps the scatter gather list for DMA transfer and forms the DMA descriptor +- * for BAM. This descriptor will be added in the NAND DMA descriptor queue +- * which will be submitted to DMA engine. +- */ +-static int qcom_prepare_bam_async_desc(struct qcom_nand_controller *nandc, +- struct dma_chan *chan, +- unsigned long flags) +-{ +- struct desc_info *desc; +- struct scatterlist *sgl; +- unsigned int sgl_cnt; +- int ret; +- struct bam_transaction *bam_txn = nandc->bam_txn; +- enum dma_transfer_direction dir_eng; +- struct dma_async_tx_descriptor *dma_desc; +- +- desc = kzalloc(sizeof(*desc), GFP_KERNEL); +- if (!desc) +- return -ENOMEM; +- +- if (chan == nandc->cmd_chan) { +- sgl = &bam_txn->cmd_sgl[bam_txn->cmd_sgl_start]; +- sgl_cnt = bam_txn->cmd_sgl_pos - bam_txn->cmd_sgl_start; +- bam_txn->cmd_sgl_start = bam_txn->cmd_sgl_pos; +- dir_eng = DMA_MEM_TO_DEV; +- desc->dir = DMA_TO_DEVICE; +- } else if (chan == nandc->tx_chan) { +- sgl = &bam_txn->data_sgl[bam_txn->tx_sgl_start]; +- sgl_cnt = bam_txn->tx_sgl_pos - bam_txn->tx_sgl_start; +- bam_txn->tx_sgl_start = bam_txn->tx_sgl_pos; +- dir_eng = DMA_MEM_TO_DEV; +- desc->dir = DMA_TO_DEVICE; +- } else { +- sgl = &bam_txn->data_sgl[bam_txn->rx_sgl_start]; +- sgl_cnt = bam_txn->rx_sgl_pos - bam_txn->rx_sgl_start; +- bam_txn->rx_sgl_start = bam_txn->rx_sgl_pos; +- dir_eng = DMA_DEV_TO_MEM; +- desc->dir = DMA_FROM_DEVICE; +- } +- +- sg_mark_end(sgl + sgl_cnt - 1); +- ret = dma_map_sg(nandc->dev, sgl, sgl_cnt, desc->dir); +- if (ret == 0) { +- dev_err(nandc->dev, "failure in mapping desc\n"); +- kfree(desc); +- return -ENOMEM; +- } +- +- desc->sgl_cnt = sgl_cnt; +- desc->bam_sgl = sgl; +- +- dma_desc = dmaengine_prep_slave_sg(chan, sgl, sgl_cnt, dir_eng, +- flags); +- +- if (!dma_desc) { +- dev_err(nandc->dev, "failure in prep desc\n"); +- dma_unmap_sg(nandc->dev, sgl, sgl_cnt, desc->dir); +- kfree(desc); +- return -EINVAL; +- } +- +- desc->dma_desc = dma_desc; +- +- /* update last data/command descriptor */ +- if (chan == nandc->cmd_chan) +- bam_txn->last_cmd_desc = dma_desc; +- else +- bam_txn->last_data_desc = dma_desc; +- +- list_add_tail(&desc->node, &nandc->desc_list); +- +- return 0; +-} +- +-/* +- * Prepares the command descriptor for BAM DMA which will be used for NAND +- * register reads and writes. The command descriptor requires the command +- * to be formed in command element type so this function uses the command +- * element from bam transaction ce array and fills the same with required +- * data. A single SGL can contain multiple command elements so +- * NAND_BAM_NEXT_SGL will be used for starting the separate SGL +- * after the current command element. +- */ +-static int qcom_prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read, +- int reg_off, const void *vaddr, +- int size, unsigned int flags) +-{ +- int bam_ce_size; +- int i, ret; +- struct bam_cmd_element *bam_ce_buffer; +- struct bam_transaction *bam_txn = nandc->bam_txn; +- +- bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_pos]; +- +- /* fill the command desc */ +- for (i = 0; i < size; i++) { +- if (read) +- bam_prep_ce(&bam_ce_buffer[i], +- nandc_reg_phys(nandc, reg_off + 4 * i), +- BAM_READ_COMMAND, +- reg_buf_dma_addr(nandc, +- (__le32 *)vaddr + i)); +- else +- bam_prep_ce_le32(&bam_ce_buffer[i], +- nandc_reg_phys(nandc, reg_off + 4 * i), +- BAM_WRITE_COMMAND, +- *((__le32 *)vaddr + i)); +- } +- +- bam_txn->bam_ce_pos += size; +- +- /* use the separate sgl after this command */ +- if (flags & NAND_BAM_NEXT_SGL) { +- bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_start]; +- bam_ce_size = (bam_txn->bam_ce_pos - +- bam_txn->bam_ce_start) * +- sizeof(struct bam_cmd_element); +- sg_set_buf(&bam_txn->cmd_sgl[bam_txn->cmd_sgl_pos], +- bam_ce_buffer, bam_ce_size); +- bam_txn->cmd_sgl_pos++; +- bam_txn->bam_ce_start = bam_txn->bam_ce_pos; +- +- if (flags & NAND_BAM_NWD) { +- ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan, +- DMA_PREP_FENCE | +- DMA_PREP_CMD); +- if (ret) +- return ret; +- } +- } +- +- return 0; +-} +- +-/* +- * Prepares the data descriptor for BAM DMA which will be used for NAND +- * data reads and writes. +- */ +-static int qcom_prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, +- const void *vaddr, int size, unsigned int flags) +-{ +- int ret; +- struct bam_transaction *bam_txn = nandc->bam_txn; +- +- if (read) { +- sg_set_buf(&bam_txn->data_sgl[bam_txn->rx_sgl_pos], +- vaddr, size); +- bam_txn->rx_sgl_pos++; +- } else { +- sg_set_buf(&bam_txn->data_sgl[bam_txn->tx_sgl_pos], +- vaddr, size); +- bam_txn->tx_sgl_pos++; +- +- /* +- * BAM will only set EOT for DMA_PREP_INTERRUPT so if this flag +- * is not set, form the DMA descriptor +- */ +- if (!(flags & NAND_BAM_NO_EOT)) { +- ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan, +- DMA_PREP_INTERRUPT); +- if (ret) +- return ret; +- } +- } +- +- return 0; +-} +- +-static int qcom_prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, +- int reg_off, const void *vaddr, int size, +- bool flow_control) +-{ +- struct desc_info *desc; +- struct dma_async_tx_descriptor *dma_desc; +- struct scatterlist *sgl; +- struct dma_slave_config slave_conf; +- struct qcom_adm_peripheral_config periph_conf = {}; +- enum dma_transfer_direction dir_eng; +- int ret; +- +- desc = kzalloc(sizeof(*desc), GFP_KERNEL); +- if (!desc) +- return -ENOMEM; +- +- sgl = &desc->adm_sgl; +- +- sg_init_one(sgl, vaddr, size); +- +- if (read) { +- dir_eng = DMA_DEV_TO_MEM; +- desc->dir = DMA_FROM_DEVICE; +- } else { +- dir_eng = DMA_MEM_TO_DEV; +- desc->dir = DMA_TO_DEVICE; +- } +- +- ret = dma_map_sg(nandc->dev, sgl, 1, desc->dir); +- if (ret == 0) { +- ret = -ENOMEM; +- goto err; +- } +- +- memset(&slave_conf, 0x00, sizeof(slave_conf)); +- +- slave_conf.device_fc = flow_control; +- if (read) { +- slave_conf.src_maxburst = 16; +- slave_conf.src_addr = nandc->base_dma + reg_off; +- if (nandc->data_crci) { +- periph_conf.crci = nandc->data_crci; +- slave_conf.peripheral_config = &periph_conf; +- slave_conf.peripheral_size = sizeof(periph_conf); +- } +- } else { +- slave_conf.dst_maxburst = 16; +- slave_conf.dst_addr = nandc->base_dma + reg_off; +- if (nandc->cmd_crci) { +- periph_conf.crci = nandc->cmd_crci; +- slave_conf.peripheral_config = &periph_conf; +- slave_conf.peripheral_size = sizeof(periph_conf); +- } +- } +- +- ret = dmaengine_slave_config(nandc->chan, &slave_conf); +- if (ret) { +- dev_err(nandc->dev, "failed to configure dma channel\n"); +- goto err; +- } +- +- dma_desc = dmaengine_prep_slave_sg(nandc->chan, sgl, 1, dir_eng, 0); +- if (!dma_desc) { +- dev_err(nandc->dev, "failed to prepare desc\n"); +- ret = -EINVAL; +- goto err; +- } +- +- desc->dma_desc = dma_desc; +- +- list_add_tail(&desc->node, &nandc->desc_list); +- +- return 0; +-err: +- kfree(desc); +- +- return ret; +-} +- +-/* +- * qcom_read_reg_dma: prepares a descriptor to read a given number of +- * contiguous registers to the reg_read_buf pointer +- * +- * @first: offset of the first register in the contiguous block +- * @num_regs: number of registers to read +- * @flags: flags to control DMA descriptor preparation +- */ +-static int qcom_read_reg_dma(struct qcom_nand_controller *nandc, int first, +- int num_regs, unsigned int flags) +-{ +- bool flow_control = false; +- void *vaddr; +- +- vaddr = nandc->reg_read_buf + nandc->reg_read_pos; +- nandc->reg_read_pos += num_regs; +- +- if (first == NAND_DEV_CMD_VLD || first == NAND_DEV_CMD1) +- first = dev_cmd_reg_addr(nandc, first); +- +- if (nandc->props->supports_bam) +- return qcom_prep_bam_dma_desc_cmd(nandc, true, first, vaddr, +- num_regs, flags); +- +- if (first == NAND_READ_ID || first == NAND_FLASH_STATUS) +- flow_control = true; +- +- return qcom_prep_adm_dma_desc(nandc, true, first, vaddr, +- num_regs * sizeof(u32), flow_control); +-} +- +-/* +- * qcom_write_reg_dma: prepares a descriptor to write a given number of +- * contiguous registers +- * +- * @vaddr: contiguous memory from where register value will +- * be written +- * @first: offset of the first register in the contiguous block +- * @num_regs: number of registers to write +- * @flags: flags to control DMA descriptor preparation +- */ +-static int qcom_write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, +- int first, int num_regs, unsigned int flags) +-{ +- bool flow_control = false; +- +- if (first == NAND_EXEC_CMD) +- flags |= NAND_BAM_NWD; +- +- if (first == NAND_DEV_CMD1_RESTORE || first == NAND_DEV_CMD1) +- first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD1); +- +- if (first == NAND_DEV_CMD_VLD_RESTORE || first == NAND_DEV_CMD_VLD) +- first = dev_cmd_reg_addr(nandc, NAND_DEV_CMD_VLD); +- +- if (nandc->props->supports_bam) +- return qcom_prep_bam_dma_desc_cmd(nandc, false, first, vaddr, +- num_regs, flags); +- +- if (first == NAND_FLASH_CMD) +- flow_control = true; +- +- return qcom_prep_adm_dma_desc(nandc, false, first, vaddr, +- num_regs * sizeof(u32), flow_control); +-} +- +-/* +- * qcom_read_data_dma: prepares a DMA descriptor to transfer data from the +- * controller's internal buffer to the buffer 'vaddr' +- * +- * @reg_off: offset within the controller's data buffer +- * @vaddr: virtual address of the buffer we want to write to +- * @size: DMA transaction size in bytes +- * @flags: flags to control DMA descriptor preparation +- */ +-static int qcom_read_data_dma(struct qcom_nand_controller *nandc, int reg_off, +- const u8 *vaddr, int size, unsigned int flags) +-{ +- if (nandc->props->supports_bam) +- return qcom_prep_bam_dma_desc_data(nandc, true, vaddr, size, flags); +- +- return qcom_prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false); +-} +- +-/* +- * qcom_write_data_dma: prepares a DMA descriptor to transfer data from +- * 'vaddr' to the controller's internal buffer +- * +- * @reg_off: offset within the controller's data buffer +- * @vaddr: virtual address of the buffer we want to read from +- * @size: DMA transaction size in bytes +- * @flags: flags to control DMA descriptor preparation +- */ +-static int qcom_write_data_dma(struct qcom_nand_controller *nandc, int reg_off, +- const u8 *vaddr, int size, unsigned int flags) +-{ +- if (nandc->props->supports_bam) +- return qcom_prep_bam_dma_desc_data(nandc, false, vaddr, size, flags); +- +- return qcom_prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false); +-} +- +-/* + * Helper to prepare DMA descriptors for configuring registers + * before reading a NAND page. + */ +@@ -1262,83 +394,6 @@ static void config_nand_cw_write(struct + NAND_BAM_NEXT_SGL); + } + +-/* helpers to submit/free our list of dma descriptors */ +-static int qcom_submit_descs(struct qcom_nand_controller *nandc) +-{ +- struct desc_info *desc, *n; +- dma_cookie_t cookie = 0; +- struct bam_transaction *bam_txn = nandc->bam_txn; +- int ret = 0; +- +- if (nandc->props->supports_bam) { +- if (bam_txn->rx_sgl_pos > bam_txn->rx_sgl_start) { +- ret = qcom_prepare_bam_async_desc(nandc, nandc->rx_chan, 0); +- if (ret) +- goto err_unmap_free_desc; +- } +- +- if (bam_txn->tx_sgl_pos > bam_txn->tx_sgl_start) { +- ret = qcom_prepare_bam_async_desc(nandc, nandc->tx_chan, +- DMA_PREP_INTERRUPT); +- if (ret) +- goto err_unmap_free_desc; +- } +- +- if (bam_txn->cmd_sgl_pos > bam_txn->cmd_sgl_start) { +- ret = qcom_prepare_bam_async_desc(nandc, nandc->cmd_chan, +- DMA_PREP_CMD); +- if (ret) +- goto err_unmap_free_desc; +- } +- } +- +- list_for_each_entry(desc, &nandc->desc_list, node) +- cookie = dmaengine_submit(desc->dma_desc); +- +- if (nandc->props->supports_bam) { +- bam_txn->last_cmd_desc->callback = qcom_qpic_bam_dma_done; +- bam_txn->last_cmd_desc->callback_param = bam_txn; +- +- dma_async_issue_pending(nandc->tx_chan); +- dma_async_issue_pending(nandc->rx_chan); +- dma_async_issue_pending(nandc->cmd_chan); +- +- if (!wait_for_completion_timeout(&bam_txn->txn_done, +- QPIC_NAND_COMPLETION_TIMEOUT)) +- ret = -ETIMEDOUT; +- } else { +- if (dma_sync_wait(nandc->chan, cookie) != DMA_COMPLETE) +- ret = -ETIMEDOUT; +- } +- +-err_unmap_free_desc: +- /* +- * Unmap the dma sg_list and free the desc allocated by both +- * qcom_prepare_bam_async_desc() and qcom_prep_adm_dma_desc() functions. +- */ +- list_for_each_entry_safe(desc, n, &nandc->desc_list, node) { +- list_del(&desc->node); +- +- if (nandc->props->supports_bam) +- dma_unmap_sg(nandc->dev, desc->bam_sgl, +- desc->sgl_cnt, desc->dir); +- else +- dma_unmap_sg(nandc->dev, &desc->adm_sgl, 1, +- desc->dir); +- +- kfree(desc); +- } +- +- return ret; +-} +- +-/* reset the register read buffer for next NAND operation */ +-static void qcom_clear_read_regs(struct qcom_nand_controller *nandc) +-{ +- nandc->reg_read_pos = 0; +- qcom_nandc_dev_to_mem(nandc, false); +-} +- + /* + * when using BCH ECC, the HW flags an error in NAND_FLASH_STATUS if it read + * an erased CW, and reports an erased CW in NAND_ERASED_CW_DETECT_STATUS. +@@ -2975,141 +2030,14 @@ static const struct nand_controller_ops + .exec_op = qcom_nand_exec_op, + }; + +-static void qcom_nandc_unalloc(struct qcom_nand_controller *nandc) +-{ +- if (nandc->props->supports_bam) { +- if (!dma_mapping_error(nandc->dev, nandc->reg_read_dma)) +- dma_unmap_single(nandc->dev, nandc->reg_read_dma, +- MAX_REG_RD * +- sizeof(*nandc->reg_read_buf), +- DMA_FROM_DEVICE); +- +- if (nandc->tx_chan) +- dma_release_channel(nandc->tx_chan); +- +- if (nandc->rx_chan) +- dma_release_channel(nandc->rx_chan); +- +- if (nandc->cmd_chan) +- dma_release_channel(nandc->cmd_chan); +- } else { +- if (nandc->chan) +- dma_release_channel(nandc->chan); +- } +-} +- +-static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) +-{ +- int ret; +- +- ret = dma_set_coherent_mask(nandc->dev, DMA_BIT_MASK(32)); +- if (ret) { +- dev_err(nandc->dev, "failed to set DMA mask\n"); +- return ret; +- } +- +- /* +- * we use the internal buffer for reading ONFI params, reading small +- * data like ID and status, and preforming read-copy-write operations +- * when writing to a codeword partially. 532 is the maximum possible +- * size of a codeword for our nand controller +- */ +- nandc->buf_size = 532; +- +- nandc->data_buffer = devm_kzalloc(nandc->dev, nandc->buf_size, GFP_KERNEL); +- if (!nandc->data_buffer) +- return -ENOMEM; +- +- nandc->regs = devm_kzalloc(nandc->dev, sizeof(*nandc->regs), GFP_KERNEL); +- if (!nandc->regs) +- return -ENOMEM; +- +- nandc->reg_read_buf = devm_kcalloc(nandc->dev, MAX_REG_RD, +- sizeof(*nandc->reg_read_buf), +- GFP_KERNEL); +- if (!nandc->reg_read_buf) +- return -ENOMEM; +- +- if (nandc->props->supports_bam) { +- nandc->reg_read_dma = +- dma_map_single(nandc->dev, nandc->reg_read_buf, +- MAX_REG_RD * +- sizeof(*nandc->reg_read_buf), +- DMA_FROM_DEVICE); +- if (dma_mapping_error(nandc->dev, nandc->reg_read_dma)) { +- dev_err(nandc->dev, "failed to DMA MAP reg buffer\n"); +- return -EIO; +- } +- +- nandc->tx_chan = dma_request_chan(nandc->dev, "tx"); +- if (IS_ERR(nandc->tx_chan)) { +- ret = PTR_ERR(nandc->tx_chan); +- nandc->tx_chan = NULL; +- dev_err_probe(nandc->dev, ret, +- "tx DMA channel request failed\n"); +- goto unalloc; +- } +- +- nandc->rx_chan = dma_request_chan(nandc->dev, "rx"); +- if (IS_ERR(nandc->rx_chan)) { +- ret = PTR_ERR(nandc->rx_chan); +- nandc->rx_chan = NULL; +- dev_err_probe(nandc->dev, ret, +- "rx DMA channel request failed\n"); +- goto unalloc; +- } +- +- nandc->cmd_chan = dma_request_chan(nandc->dev, "cmd"); +- if (IS_ERR(nandc->cmd_chan)) { +- ret = PTR_ERR(nandc->cmd_chan); +- nandc->cmd_chan = NULL; +- dev_err_probe(nandc->dev, ret, +- "cmd DMA channel request failed\n"); +- goto unalloc; +- } +- +- /* +- * Initially allocate BAM transaction to read ONFI param page. +- * After detecting all the devices, this BAM transaction will +- * be freed and the next BAM transaction will be allocated with +- * maximum codeword size +- */ +- nandc->max_cwperpage = 1; +- nandc->bam_txn = qcom_alloc_bam_transaction(nandc); +- if (!nandc->bam_txn) { +- dev_err(nandc->dev, +- "failed to allocate bam transaction\n"); +- ret = -ENOMEM; +- goto unalloc; +- } +- } else { +- nandc->chan = dma_request_chan(nandc->dev, "rxtx"); +- if (IS_ERR(nandc->chan)) { +- ret = PTR_ERR(nandc->chan); +- nandc->chan = NULL; +- dev_err_probe(nandc->dev, ret, +- "rxtx DMA channel request failed\n"); +- return ret; +- } +- } +- +- INIT_LIST_HEAD(&nandc->desc_list); +- INIT_LIST_HEAD(&nandc->host_list); +- +- nand_controller_init(&nandc->controller); +- nandc->controller.ops = &qcom_nandc_ops; +- +- return 0; +-unalloc: +- qcom_nandc_unalloc(nandc); +- return ret; +-} +- + /* one time setup of a few nand controller registers */ + static int qcom_nandc_setup(struct qcom_nand_controller *nandc) + { + u32 nand_ctrl; + ++ nand_controller_init(nandc->controller); ++ nandc->controller->ops = &qcom_nandc_ops; ++ + /* kill onenand */ + if (!nandc->props->nandc_part_of_qpic) + nandc_write(nandc, SFLASHC_BURST_CFG, 0); +@@ -3248,7 +2176,7 @@ static int qcom_nand_host_init_and_regis + chip->legacy.block_bad = qcom_nandc_block_bad; + chip->legacy.block_markbad = qcom_nandc_block_markbad; + +- chip->controller = &nandc->controller; ++ chip->controller = nandc->controller; + chip->options |= NAND_NO_SUBPAGE_WRITE | NAND_USES_DMA | + NAND_SKIP_BBTSCAN; + +@@ -3331,17 +2259,21 @@ static int qcom_nandc_parse_dt(struct pl + static int qcom_nandc_probe(struct platform_device *pdev) + { + struct qcom_nand_controller *nandc; ++ struct nand_controller *controller; + const void *dev_data; + struct device *dev = &pdev->dev; + struct resource *res; + int ret; + +- nandc = devm_kzalloc(&pdev->dev, sizeof(*nandc), GFP_KERNEL); ++ nandc = devm_kzalloc(&pdev->dev, sizeof(*nandc) + sizeof(*controller), ++ GFP_KERNEL); + if (!nandc) + return -ENOMEM; ++ controller = (struct nand_controller *)&nandc[1]; + + platform_set_drvdata(pdev, nandc); + nandc->dev = dev; ++ nandc->controller = controller; + + dev_data = of_device_get_match_data(dev); + if (!dev_data) { +--- /dev/null ++++ b/include/linux/mtd/nand-qpic-common.h +@@ -0,0 +1,468 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * QCOM QPIC common APIs header file ++ * ++ * Copyright (c) 2023 Qualcomm Inc. ++ * Authors: Md sadre Alam ++ * ++ */ ++#ifndef __MTD_NAND_QPIC_COMMON_H__ ++#define __MTD_NAND_QPIC_COMMON_H__ ++ ++/* NANDc reg offsets */ ++#define NAND_FLASH_CMD 0x00 ++#define NAND_ADDR0 0x04 ++#define NAND_ADDR1 0x08 ++#define NAND_FLASH_CHIP_SELECT 0x0c ++#define NAND_EXEC_CMD 0x10 ++#define NAND_FLASH_STATUS 0x14 ++#define NAND_BUFFER_STATUS 0x18 ++#define NAND_DEV0_CFG0 0x20 ++#define NAND_DEV0_CFG1 0x24 ++#define NAND_DEV0_ECC_CFG 0x28 ++#define NAND_AUTO_STATUS_EN 0x2c ++#define NAND_DEV1_CFG0 0x30 ++#define NAND_DEV1_CFG1 0x34 ++#define NAND_READ_ID 0x40 ++#define NAND_READ_STATUS 0x44 ++#define NAND_DEV_CMD0 0xa0 ++#define NAND_DEV_CMD1 0xa4 ++#define NAND_DEV_CMD2 0xa8 ++#define NAND_DEV_CMD_VLD 0xac ++#define SFLASHC_BURST_CFG 0xe0 ++#define NAND_ERASED_CW_DETECT_CFG 0xe8 ++#define NAND_ERASED_CW_DETECT_STATUS 0xec ++#define NAND_EBI2_ECC_BUF_CFG 0xf0 ++#define FLASH_BUF_ACC 0x100 ++ ++#define NAND_CTRL 0xf00 ++#define NAND_VERSION 0xf08 ++#define NAND_READ_LOCATION_0 0xf20 ++#define NAND_READ_LOCATION_1 0xf24 ++#define NAND_READ_LOCATION_2 0xf28 ++#define NAND_READ_LOCATION_3 0xf2c ++#define NAND_READ_LOCATION_LAST_CW_0 0xf40 ++#define NAND_READ_LOCATION_LAST_CW_1 0xf44 ++#define NAND_READ_LOCATION_LAST_CW_2 0xf48 ++#define NAND_READ_LOCATION_LAST_CW_3 0xf4c ++ ++/* dummy register offsets, used by qcom_write_reg_dma */ ++#define NAND_DEV_CMD1_RESTORE 0xdead ++#define NAND_DEV_CMD_VLD_RESTORE 0xbeef ++ ++/* NAND_FLASH_CMD bits */ ++#define PAGE_ACC BIT(4) ++#define LAST_PAGE BIT(5) ++ ++/* NAND_FLASH_CHIP_SELECT bits */ ++#define NAND_DEV_SEL 0 ++#define DM_EN BIT(2) ++ ++/* NAND_FLASH_STATUS bits */ ++#define FS_OP_ERR BIT(4) ++#define FS_READY_BSY_N BIT(5) ++#define FS_MPU_ERR BIT(8) ++#define FS_DEVICE_STS_ERR BIT(16) ++#define FS_DEVICE_WP BIT(23) ++ ++/* NAND_BUFFER_STATUS bits */ ++#define BS_UNCORRECTABLE_BIT BIT(8) ++#define BS_CORRECTABLE_ERR_MSK 0x1f ++ ++/* NAND_DEVn_CFG0 bits */ ++#define DISABLE_STATUS_AFTER_WRITE 4 ++#define CW_PER_PAGE 6 ++#define UD_SIZE_BYTES 9 ++#define UD_SIZE_BYTES_MASK GENMASK(18, 9) ++#define ECC_PARITY_SIZE_BYTES_RS 19 ++#define SPARE_SIZE_BYTES 23 ++#define SPARE_SIZE_BYTES_MASK GENMASK(26, 23) ++#define NUM_ADDR_CYCLES 27 ++#define STATUS_BFR_READ 30 ++#define SET_RD_MODE_AFTER_STATUS 31 ++ ++/* NAND_DEVn_CFG0 bits */ ++#define DEV0_CFG1_ECC_DISABLE 0 ++#define WIDE_FLASH 1 ++#define NAND_RECOVERY_CYCLES 2 ++#define CS_ACTIVE_BSY 5 ++#define BAD_BLOCK_BYTE_NUM 6 ++#define BAD_BLOCK_IN_SPARE_AREA 16 ++#define WR_RD_BSY_GAP 17 ++#define ENABLE_BCH_ECC 27 ++ ++/* NAND_DEV0_ECC_CFG bits */ ++#define ECC_CFG_ECC_DISABLE 0 ++#define ECC_SW_RESET 1 ++#define ECC_MODE 4 ++#define ECC_PARITY_SIZE_BYTES_BCH 8 ++#define ECC_NUM_DATA_BYTES 16 ++#define ECC_NUM_DATA_BYTES_MASK GENMASK(25, 16) ++#define ECC_FORCE_CLK_OPEN 30 ++ ++/* NAND_DEV_CMD1 bits */ ++#define READ_ADDR 0 ++ ++/* NAND_DEV_CMD_VLD bits */ ++#define READ_START_VLD BIT(0) ++#define READ_STOP_VLD BIT(1) ++#define WRITE_START_VLD BIT(2) ++#define ERASE_START_VLD BIT(3) ++#define SEQ_READ_START_VLD BIT(4) ++ ++/* NAND_EBI2_ECC_BUF_CFG bits */ ++#define NUM_STEPS 0 ++ ++/* NAND_ERASED_CW_DETECT_CFG bits */ ++#define ERASED_CW_ECC_MASK 1 ++#define AUTO_DETECT_RES 0 ++#define MASK_ECC BIT(ERASED_CW_ECC_MASK) ++#define RESET_ERASED_DET BIT(AUTO_DETECT_RES) ++#define ACTIVE_ERASED_DET (0 << AUTO_DETECT_RES) ++#define CLR_ERASED_PAGE_DET (RESET_ERASED_DET | MASK_ECC) ++#define SET_ERASED_PAGE_DET (ACTIVE_ERASED_DET | MASK_ECC) ++ ++/* NAND_ERASED_CW_DETECT_STATUS bits */ ++#define PAGE_ALL_ERASED BIT(7) ++#define CODEWORD_ALL_ERASED BIT(6) ++#define PAGE_ERASED BIT(5) ++#define CODEWORD_ERASED BIT(4) ++#define ERASED_PAGE (PAGE_ALL_ERASED | PAGE_ERASED) ++#define ERASED_CW (CODEWORD_ALL_ERASED | CODEWORD_ERASED) ++ ++/* NAND_READ_LOCATION_n bits */ ++#define READ_LOCATION_OFFSET 0 ++#define READ_LOCATION_SIZE 16 ++#define READ_LOCATION_LAST 31 ++ ++/* Version Mask */ ++#define NAND_VERSION_MAJOR_MASK 0xf0000000 ++#define NAND_VERSION_MAJOR_SHIFT 28 ++#define NAND_VERSION_MINOR_MASK 0x0fff0000 ++#define NAND_VERSION_MINOR_SHIFT 16 ++ ++/* NAND OP_CMDs */ ++#define OP_PAGE_READ 0x2 ++#define OP_PAGE_READ_WITH_ECC 0x3 ++#define OP_PAGE_READ_WITH_ECC_SPARE 0x4 ++#define OP_PAGE_READ_ONFI_READ 0x5 ++#define OP_PROGRAM_PAGE 0x6 ++#define OP_PAGE_PROGRAM_WITH_ECC 0x7 ++#define OP_PROGRAM_PAGE_SPARE 0x9 ++#define OP_BLOCK_ERASE 0xa ++#define OP_CHECK_STATUS 0xc ++#define OP_FETCH_ID 0xb ++#define OP_RESET_DEVICE 0xd ++ ++/* Default Value for NAND_DEV_CMD_VLD */ ++#define NAND_DEV_CMD_VLD_VAL (READ_START_VLD | WRITE_START_VLD | \ ++ ERASE_START_VLD | SEQ_READ_START_VLD) ++ ++/* NAND_CTRL bits */ ++#define BAM_MODE_EN BIT(0) ++ ++/* ++ * the NAND controller performs reads/writes with ECC in 516 byte chunks. ++ * the driver calls the chunks 'step' or 'codeword' interchangeably ++ */ ++#define NANDC_STEP_SIZE 512 ++ ++/* ++ * the largest page size we support is 8K, this will have 16 steps/codewords ++ * of 512 bytes each ++ */ ++#define MAX_NUM_STEPS (SZ_8K / NANDC_STEP_SIZE) ++ ++/* we read at most 3 registers per codeword scan */ ++#define MAX_REG_RD (3 * MAX_NUM_STEPS) ++ ++/* ECC modes supported by the controller */ ++#define ECC_NONE BIT(0) ++#define ECC_RS_4BIT BIT(1) ++#define ECC_BCH_4BIT BIT(2) ++#define ECC_BCH_8BIT BIT(3) ++ ++/* ++ * Returns the actual register address for all NAND_DEV_ registers ++ * (i.e. NAND_DEV_CMD0, NAND_DEV_CMD1, NAND_DEV_CMD2 and NAND_DEV_CMD_VLD) ++ */ ++#define dev_cmd_reg_addr(nandc, reg) ((nandc)->props->dev_cmd_reg_start + (reg)) ++ ++/* Returns the NAND register physical address */ ++#define nandc_reg_phys(chip, offset) ((chip)->base_phys + (offset)) ++ ++/* Returns the dma address for reg read buffer */ ++#define reg_buf_dma_addr(chip, vaddr) \ ++ ((chip)->reg_read_dma + \ ++ ((u8 *)(vaddr) - (u8 *)(chip)->reg_read_buf)) ++ ++#define QPIC_PER_CW_CMD_ELEMENTS 32 ++#define QPIC_PER_CW_CMD_SGL 32 ++#define QPIC_PER_CW_DATA_SGL 8 ++ ++#define QPIC_NAND_COMPLETION_TIMEOUT msecs_to_jiffies(2000) ++ ++/* ++ * Flags used in DMA descriptor preparation helper functions ++ * (i.e. qcom_read_reg_dma/qcom_write_reg_dma/qcom_read_data_dma/qcom_write_data_dma) ++ */ ++/* Don't set the EOT in current tx BAM sgl */ ++#define NAND_BAM_NO_EOT BIT(0) ++/* Set the NWD flag in current BAM sgl */ ++#define NAND_BAM_NWD BIT(1) ++/* Finish writing in the current BAM sgl and start writing in another BAM sgl */ ++#define NAND_BAM_NEXT_SGL BIT(2) ++/* ++ * Erased codeword status is being used two times in single transfer so this ++ * flag will determine the current value of erased codeword status register ++ */ ++#define NAND_ERASED_CW_SET BIT(4) ++ ++#define MAX_ADDRESS_CYCLE 5 ++ ++/* ++ * This data type corresponds to the BAM transaction which will be used for all ++ * NAND transfers. ++ * @bam_ce - the array of BAM command elements ++ * @cmd_sgl - sgl for NAND BAM command pipe ++ * @data_sgl - sgl for NAND BAM consumer/producer pipe ++ * @last_data_desc - last DMA desc in data channel (tx/rx). ++ * @last_cmd_desc - last DMA desc in command channel. ++ * @txn_done - completion for NAND transfer. ++ * @bam_ce_pos - the index in bam_ce which is available for next sgl ++ * @bam_ce_start - the index in bam_ce which marks the start position ce ++ * for current sgl. It will be used for size calculation ++ * for current sgl ++ * @cmd_sgl_pos - current index in command sgl. ++ * @cmd_sgl_start - start index in command sgl. ++ * @tx_sgl_pos - current index in data sgl for tx. ++ * @tx_sgl_start - start index in data sgl for tx. ++ * @rx_sgl_pos - current index in data sgl for rx. ++ * @rx_sgl_start - start index in data sgl for rx. ++ */ ++struct bam_transaction { ++ struct bam_cmd_element *bam_ce; ++ struct scatterlist *cmd_sgl; ++ struct scatterlist *data_sgl; ++ struct dma_async_tx_descriptor *last_data_desc; ++ struct dma_async_tx_descriptor *last_cmd_desc; ++ struct completion txn_done; ++ u32 bam_ce_pos; ++ u32 bam_ce_start; ++ u32 cmd_sgl_pos; ++ u32 cmd_sgl_start; ++ u32 tx_sgl_pos; ++ u32 tx_sgl_start; ++ u32 rx_sgl_pos; ++ u32 rx_sgl_start; ++}; ++ ++/* ++ * This data type corresponds to the nand dma descriptor ++ * @dma_desc - low level DMA engine descriptor ++ * @list - list for desc_info ++ * ++ * @adm_sgl - sgl which will be used for single sgl dma descriptor. Only used by ++ * ADM ++ * @bam_sgl - sgl which will be used for dma descriptor. Only used by BAM ++ * @sgl_cnt - number of SGL in bam_sgl. Only used by BAM ++ * @dir - DMA transfer direction ++ */ ++struct desc_info { ++ struct dma_async_tx_descriptor *dma_desc; ++ struct list_head node; ++ ++ union { ++ struct scatterlist adm_sgl; ++ struct { ++ struct scatterlist *bam_sgl; ++ int sgl_cnt; ++ }; ++ }; ++ enum dma_data_direction dir; ++}; ++ ++/* ++ * holds the current register values that we want to write. acts as a contiguous ++ * chunk of memory which we use to write the controller registers through DMA. ++ */ ++struct nandc_regs { ++ __le32 cmd; ++ __le32 addr0; ++ __le32 addr1; ++ __le32 chip_sel; ++ __le32 exec; ++ ++ __le32 cfg0; ++ __le32 cfg1; ++ __le32 ecc_bch_cfg; ++ ++ __le32 clrflashstatus; ++ __le32 clrreadstatus; ++ ++ __le32 cmd1; ++ __le32 vld; ++ ++ __le32 orig_cmd1; ++ __le32 orig_vld; ++ ++ __le32 ecc_buf_cfg; ++ __le32 read_location0; ++ __le32 read_location1; ++ __le32 read_location2; ++ __le32 read_location3; ++ __le32 read_location_last0; ++ __le32 read_location_last1; ++ __le32 read_location_last2; ++ __le32 read_location_last3; ++ ++ __le32 erased_cw_detect_cfg_clr; ++ __le32 erased_cw_detect_cfg_set; ++}; ++ ++/* ++ * NAND controller data struct ++ * ++ * @dev: parent device ++ * ++ * @base: MMIO base ++ * ++ * @core_clk: controller clock ++ * @aon_clk: another controller clock ++ * ++ * @regs: a contiguous chunk of memory for DMA register ++ * writes. contains the register values to be ++ * written to controller ++ * ++ * @props: properties of current NAND controller, ++ * initialized via DT match data ++ * ++ * @controller: base controller structure ++ * @host_list: list containing all the chips attached to the ++ * controller ++ * ++ * @chan: dma channel ++ * @cmd_crci: ADM DMA CRCI for command flow control ++ * @data_crci: ADM DMA CRCI for data flow control ++ * ++ * @desc_list: DMA descriptor list (list of desc_infos) ++ * ++ * @data_buffer: our local DMA buffer for page read/writes, ++ * used when we can't use the buffer provided ++ * by upper layers directly ++ * @reg_read_buf: local buffer for reading back registers via DMA ++ * ++ * @base_phys: physical base address of controller registers ++ * @base_dma: dma base address of controller registers ++ * @reg_read_dma: contains dma address for register read buffer ++ * ++ * @buf_size/count/start: markers for chip->legacy.read_buf/write_buf ++ * functions ++ * @max_cwperpage: maximum QPIC codewords required. calculated ++ * from all connected NAND devices pagesize ++ * ++ * @reg_read_pos: marker for data read in reg_read_buf ++ * ++ * @cmd1/vld: some fixed controller register values ++ * ++ * @exec_opwrite: flag to select correct number of code word ++ * while reading status ++ */ ++struct qcom_nand_controller { ++ struct device *dev; ++ ++ void __iomem *base; ++ ++ struct clk *core_clk; ++ struct clk *aon_clk; ++ ++ struct nandc_regs *regs; ++ struct bam_transaction *bam_txn; ++ ++ const struct qcom_nandc_props *props; ++ ++ struct nand_controller *controller; ++ struct list_head host_list; ++ ++ union { ++ /* will be used only by QPIC for BAM DMA */ ++ struct { ++ struct dma_chan *tx_chan; ++ struct dma_chan *rx_chan; ++ struct dma_chan *cmd_chan; ++ }; ++ ++ /* will be used only by EBI2 for ADM DMA */ ++ struct { ++ struct dma_chan *chan; ++ unsigned int cmd_crci; ++ unsigned int data_crci; ++ }; ++ }; ++ ++ struct list_head desc_list; ++ ++ u8 *data_buffer; ++ __le32 *reg_read_buf; ++ ++ phys_addr_t base_phys; ++ dma_addr_t base_dma; ++ dma_addr_t reg_read_dma; ++ ++ int buf_size; ++ int buf_count; ++ int buf_start; ++ unsigned int max_cwperpage; ++ ++ int reg_read_pos; ++ ++ u32 cmd1, vld; ++ bool exec_opwrite; ++}; ++ ++/* ++ * This data type corresponds to the NAND controller properties which varies ++ * among different NAND controllers. ++ * @ecc_modes - ecc mode for NAND ++ * @dev_cmd_reg_start - NAND_DEV_CMD_* registers starting offset ++ * @supports_bam - whether NAND controller is using BAM ++ * @nandc_part_of_qpic - whether NAND controller is part of qpic IP ++ * @qpic_version2 - flag to indicate QPIC IP version 2 ++ * @use_codeword_fixup - whether NAND has different layout for boot partitions ++ */ ++struct qcom_nandc_props { ++ u32 ecc_modes; ++ u32 dev_cmd_reg_start; ++ bool supports_bam; ++ bool nandc_part_of_qpic; ++ bool qpic_version2; ++ bool use_codeword_fixup; ++}; ++ ++void qcom_free_bam_transaction(struct qcom_nand_controller *nandc); ++struct bam_transaction *qcom_alloc_bam_transaction(struct qcom_nand_controller *nandc); ++void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc); ++void qcom_qpic_bam_dma_done(void *data); ++void qcom_nandc_dev_to_mem(struct qcom_nand_controller *nandc, bool is_cpu); ++int qcom_prepare_bam_async_desc(struct qcom_nand_controller *nandc, ++ struct dma_chan *chan, unsigned long flags); ++int qcom_prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read, ++ int reg_off, const void *vaddr, int size, unsigned int flags); ++int qcom_prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool read, ++ const void *vaddr, int size, unsigned int flags); ++int qcom_prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read, int reg_off, ++ const void *vaddr, int size, bool flow_control); ++int qcom_read_reg_dma(struct qcom_nand_controller *nandc, int first, int num_regs, ++ unsigned int flags); ++int qcom_write_reg_dma(struct qcom_nand_controller *nandc, __le32 *vaddr, int first, ++ int num_regs, unsigned int flags); ++int qcom_read_data_dma(struct qcom_nand_controller *nandc, int reg_off, const u8 *vaddr, ++ int size, unsigned int flags); ++int qcom_write_data_dma(struct qcom_nand_controller *nandc, int reg_off, const u8 *vaddr, ++ int size, unsigned int flags); ++int qcom_submit_descs(struct qcom_nand_controller *nandc); ++void qcom_clear_read_regs(struct qcom_nand_controller *nandc); ++void qcom_nandc_unalloc(struct qcom_nand_controller *nandc); ++int qcom_nandc_alloc(struct qcom_nand_controller *nandc); ++#endif ++ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-04-v6.14-mtd-rawnand-qcom-use-FIELD_PREP-and-GENMASK.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-04-v6.14-mtd-rawnand-qcom-use-FIELD_PREP-and-GENMASK.patch new file mode 100755 index 0000000..c19f681 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-04-v6.14-mtd-rawnand-qcom-use-FIELD_PREP-and-GENMASK.patch @@ -0,0 +1,198 @@ +From 0c08080fd71cd5dd59643104b39d3c89d793ab3c Mon Sep 17 00:00:00 2001 +From: Md Sadre Alam +Date: Wed, 20 Nov 2024 14:45:03 +0530 +Subject: [PATCH 4/4] mtd: rawnand: qcom: use FIELD_PREP and GENMASK + +Use the bitfield macro FIELD_PREP, and GENMASK to +do the shift and mask in one go. This makes the code +more readable. + +Reviewed-by: Konrad Dybcio +Signed-off-by: Md Sadre Alam +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/raw/qcom_nandc.c | 97 ++++++++++++++-------------- + include/linux/mtd/nand-qpic-common.h | 31 +++++---- + 2 files changed, 67 insertions(+), 61 deletions(-) + +--- a/drivers/mtd/nand/raw/qcom_nandc.c ++++ b/drivers/mtd/nand/raw/qcom_nandc.c +@@ -281,7 +281,7 @@ static void update_rw_regs(struct qcom_n + (num_cw - 1) << CW_PER_PAGE); + + cfg1 = cpu_to_le32(host->cfg1_raw); +- ecc_bch_cfg = cpu_to_le32(1 << ECC_CFG_ECC_DISABLE); ++ ecc_bch_cfg = cpu_to_le32(ECC_CFG_ECC_DISABLE); + } + + nandc->regs->cmd = cmd; +@@ -1494,42 +1494,41 @@ static int qcom_nand_attach_chip(struct + host->cw_size = host->cw_data + ecc->bytes; + bad_block_byte = mtd->writesize - host->cw_size * (cwperpage - 1) + 1; + +- host->cfg0 = (cwperpage - 1) << CW_PER_PAGE +- | host->cw_data << UD_SIZE_BYTES +- | 0 << DISABLE_STATUS_AFTER_WRITE +- | 5 << NUM_ADDR_CYCLES +- | host->ecc_bytes_hw << ECC_PARITY_SIZE_BYTES_RS +- | 0 << STATUS_BFR_READ +- | 1 << SET_RD_MODE_AFTER_STATUS +- | host->spare_bytes << SPARE_SIZE_BYTES; +- +- host->cfg1 = 7 << NAND_RECOVERY_CYCLES +- | 0 << CS_ACTIVE_BSY +- | bad_block_byte << BAD_BLOCK_BYTE_NUM +- | 0 << BAD_BLOCK_IN_SPARE_AREA +- | 2 << WR_RD_BSY_GAP +- | wide_bus << WIDE_FLASH +- | host->bch_enabled << ENABLE_BCH_ECC; +- +- host->cfg0_raw = (cwperpage - 1) << CW_PER_PAGE +- | host->cw_size << UD_SIZE_BYTES +- | 5 << NUM_ADDR_CYCLES +- | 0 << SPARE_SIZE_BYTES; +- +- host->cfg1_raw = 7 << NAND_RECOVERY_CYCLES +- | 0 << CS_ACTIVE_BSY +- | 17 << BAD_BLOCK_BYTE_NUM +- | 1 << BAD_BLOCK_IN_SPARE_AREA +- | 2 << WR_RD_BSY_GAP +- | wide_bus << WIDE_FLASH +- | 1 << DEV0_CFG1_ECC_DISABLE; +- +- host->ecc_bch_cfg = !host->bch_enabled << ECC_CFG_ECC_DISABLE +- | 0 << ECC_SW_RESET +- | host->cw_data << ECC_NUM_DATA_BYTES +- | 1 << ECC_FORCE_CLK_OPEN +- | ecc_mode << ECC_MODE +- | host->ecc_bytes_hw << ECC_PARITY_SIZE_BYTES_BCH; ++ host->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | ++ FIELD_PREP(UD_SIZE_BYTES_MASK, host->cw_data) | ++ FIELD_PREP(DISABLE_STATUS_AFTER_WRITE, 0) | ++ FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | ++ FIELD_PREP(ECC_PARITY_SIZE_BYTES_RS, host->ecc_bytes_hw) | ++ FIELD_PREP(STATUS_BFR_READ, 0) | ++ FIELD_PREP(SET_RD_MODE_AFTER_STATUS, 1) | ++ FIELD_PREP(SPARE_SIZE_BYTES_MASK, host->spare_bytes); ++ ++ host->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | ++ FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, bad_block_byte) | ++ FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 0) | ++ FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | ++ FIELD_PREP(WIDE_FLASH, wide_bus) | ++ FIELD_PREP(ENABLE_BCH_ECC, host->bch_enabled); ++ ++ host->cfg0_raw = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | ++ FIELD_PREP(UD_SIZE_BYTES_MASK, host->cw_size) | ++ FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | ++ FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); ++ ++ host->cfg1_raw = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | ++ FIELD_PREP(CS_ACTIVE_BSY, 0) | ++ FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | ++ FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | ++ FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | ++ FIELD_PREP(WIDE_FLASH, wide_bus) | ++ FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); ++ ++ host->ecc_bch_cfg = FIELD_PREP(ECC_CFG_ECC_DISABLE, !host->bch_enabled) | ++ FIELD_PREP(ECC_SW_RESET, 0) | ++ FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, host->cw_data) | ++ FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) | ++ FIELD_PREP(ECC_MODE_MASK, ecc_mode) | ++ FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, host->ecc_bytes_hw); + + if (!nandc->props->qpic_version2) + host->ecc_buf_cfg = 0x203 << NUM_STEPS; +@@ -1887,21 +1886,21 @@ static int qcom_param_page_type_exec(str + nandc->regs->addr0 = 0; + nandc->regs->addr1 = 0; + +- nandc->regs->cfg0 = cpu_to_le32(0 << CW_PER_PAGE | +- 512 << UD_SIZE_BYTES | +- 5 << NUM_ADDR_CYCLES | +- 0 << SPARE_SIZE_BYTES); +- +- nandc->regs->cfg1 = cpu_to_le32(7 << NAND_RECOVERY_CYCLES | +- 0 << CS_ACTIVE_BSY | +- 17 << BAD_BLOCK_BYTE_NUM | +- 1 << BAD_BLOCK_IN_SPARE_AREA | +- 2 << WR_RD_BSY_GAP | +- 0 << WIDE_FLASH | +- 1 << DEV0_CFG1_ECC_DISABLE); ++ host->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, 0) | ++ FIELD_PREP(UD_SIZE_BYTES_MASK, 512) | ++ FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | ++ FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); ++ ++ host->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | ++ FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | ++ FIELD_PREP(CS_ACTIVE_BSY, 0) | ++ FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | ++ FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | ++ FIELD_PREP(WIDE_FLASH, 0) | ++ FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); + + if (!nandc->props->qpic_version2) +- nandc->regs->ecc_buf_cfg = cpu_to_le32(1 << ECC_CFG_ECC_DISABLE); ++ nandc->regs->ecc_buf_cfg = cpu_to_le32(ECC_CFG_ECC_DISABLE); + + /* configure CMD1 and VLD for ONFI param probing in QPIC v1 */ + if (!nandc->props->qpic_version2) { +--- a/include/linux/mtd/nand-qpic-common.h ++++ b/include/linux/mtd/nand-qpic-common.h +@@ -70,35 +70,42 @@ + #define BS_CORRECTABLE_ERR_MSK 0x1f + + /* NAND_DEVn_CFG0 bits */ +-#define DISABLE_STATUS_AFTER_WRITE 4 ++#define DISABLE_STATUS_AFTER_WRITE BIT(4) + #define CW_PER_PAGE 6 ++#define CW_PER_PAGE_MASK GENMASK(8, 6) + #define UD_SIZE_BYTES 9 + #define UD_SIZE_BYTES_MASK GENMASK(18, 9) +-#define ECC_PARITY_SIZE_BYTES_RS 19 ++#define ECC_PARITY_SIZE_BYTES_RS GENMASK(22, 19) + #define SPARE_SIZE_BYTES 23 + #define SPARE_SIZE_BYTES_MASK GENMASK(26, 23) + #define NUM_ADDR_CYCLES 27 +-#define STATUS_BFR_READ 30 +-#define SET_RD_MODE_AFTER_STATUS 31 ++#define NUM_ADDR_CYCLES_MASK GENMASK(29, 27) ++#define STATUS_BFR_READ BIT(30) ++#define SET_RD_MODE_AFTER_STATUS BIT(31) + + /* NAND_DEVn_CFG0 bits */ +-#define DEV0_CFG1_ECC_DISABLE 0 +-#define WIDE_FLASH 1 ++#define DEV0_CFG1_ECC_DISABLE BIT(0) ++#define WIDE_FLASH BIT(1) + #define NAND_RECOVERY_CYCLES 2 +-#define CS_ACTIVE_BSY 5 ++#define NAND_RECOVERY_CYCLES_MASK GENMASK(4, 2) ++#define CS_ACTIVE_BSY BIT(5) + #define BAD_BLOCK_BYTE_NUM 6 +-#define BAD_BLOCK_IN_SPARE_AREA 16 ++#define BAD_BLOCK_BYTE_NUM_MASK GENMASK(15, 6) ++#define BAD_BLOCK_IN_SPARE_AREA BIT(16) + #define WR_RD_BSY_GAP 17 +-#define ENABLE_BCH_ECC 27 ++#define WR_RD_BSY_GAP_MASK GENMASK(22, 17) ++#define ENABLE_BCH_ECC BIT(27) + + /* NAND_DEV0_ECC_CFG bits */ +-#define ECC_CFG_ECC_DISABLE 0 +-#define ECC_SW_RESET 1 ++#define ECC_CFG_ECC_DISABLE BIT(0) ++#define ECC_SW_RESET BIT(1) + #define ECC_MODE 4 ++#define ECC_MODE_MASK GENMASK(5, 4) + #define ECC_PARITY_SIZE_BYTES_BCH 8 ++#define ECC_PARITY_SIZE_BYTES_BCH_MASK GENMASK(12, 8) + #define ECC_NUM_DATA_BYTES 16 + #define ECC_NUM_DATA_BYTES_MASK GENMASK(25, 16) +-#define ECC_FORCE_CLK_OPEN 30 ++#define ECC_FORCE_CLK_OPEN BIT(30) + + /* NAND_DEV_CMD1 bits */ + #define READ_ADDR 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-05-v6.14-mtd-rawnand-qcom-fix-broken-config-in-qcom_param_pag.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-05-v6.14-mtd-rawnand-qcom-fix-broken-config-in-qcom_param_pag.patch new file mode 100755 index 0000000..238a1f9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-05-v6.14-mtd-rawnand-qcom-fix-broken-config-in-qcom_param_pag.patch @@ -0,0 +1,64 @@ +From 9d4ffbcfde283f2a87ea45128ddf7e6651facdd9 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Fri, 7 Feb 2025 20:42:38 +0100 +Subject: [PATCH] mtd: rawnand: qcom: fix broken config in + qcom_param_page_type_exec + +Fix broken config in qcom_param_page_type_exec caused by copy-paste error +from commit 0c08080fd71c ("mtd: rawnand: qcom: use FIELD_PREP and GENMASK") + +In qcom_param_page_type_exec the value needs to be set to +nandc->regs->cfg0 instead of host->cfg0. This wrong configuration caused +the Qcom NANDC driver to malfunction on any device that makes use of it +(IPQ806x, IPQ40xx, IPQ807x, IPQ60xx) with the following error: + +[ 0.885369] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xaa +[ 0.885909] nand: Micron NAND 256MiB 1,8V 8-bit +[ 0.892499] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64 +[ 0.896823] nand: ECC (step, strength) = (512, 8) does not fit in OOB +[ 0.896836] qcom-nandc 79b0000.nand-controller: No valid ECC settings possible +[ 0.910996] bam-dma-engine 7984000.dma-controller: Cannot free busy channel +[ 0.918070] qcom-nandc: probe of 79b0000.nand-controller failed with error -28 + +Restore original configuration fix the problem and makes the driver work +again. + +Cc: stable@vger.kernel.org +Fixes: 0c08080fd71c ("mtd: rawnand: qcom: use FIELD_PREP and GENMASK") +Signed-off-by: Christian Marangi +--- + drivers/mtd/nand/raw/qcom_nandc.c | 24 ++++++++++++------------ + 1 file changed, 12 insertions(+), 12 deletions(-) + +--- a/drivers/mtd/nand/raw/qcom_nandc.c ++++ b/drivers/mtd/nand/raw/qcom_nandc.c +@@ -1886,18 +1886,18 @@ static int qcom_param_page_type_exec(str + nandc->regs->addr0 = 0; + nandc->regs->addr1 = 0; + +- host->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, 0) | +- FIELD_PREP(UD_SIZE_BYTES_MASK, 512) | +- FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | +- FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); ++ nandc->regs->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, 0) | ++ FIELD_PREP(UD_SIZE_BYTES_MASK, 512) | ++ FIELD_PREP(NUM_ADDR_CYCLES_MASK, 5) | ++ FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); + +- host->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | +- FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | +- FIELD_PREP(CS_ACTIVE_BSY, 0) | +- FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | +- FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | +- FIELD_PREP(WIDE_FLASH, 0) | +- FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); ++ nandc->regs->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 7) | ++ FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | ++ FIELD_PREP(CS_ACTIVE_BSY, 0) | ++ FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | ++ FIELD_PREP(WR_RD_BSY_GAP_MASK, 2) | ++ FIELD_PREP(WIDE_FLASH, 0) | ++ FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); + + if (!nandc->props->qpic_version2) + nandc->regs->ecc_buf_cfg = cpu_to_le32(ECC_CFG_ECC_DISABLE); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-06-v6.14-mtd-rawnand-qcom-Fix-build-issue-on-x86-architecture.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-06-v6.14-mtd-rawnand-qcom-Fix-build-issue-on-x86-architecture.patch new file mode 100755 index 0000000..67beed3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-06-v6.14-mtd-rawnand-qcom-Fix-build-issue-on-x86-architecture.patch @@ -0,0 +1,77 @@ +From b9371866799d67a80be0ea9e01bd41987db22f26 Mon Sep 17 00:00:00 2001 +From: Md Sadre Alam +Date: Mon, 6 Jan 2025 18:45:58 +0530 +Subject: [PATCH] mtd: rawnand: qcom: Fix build issue on x86 architecture +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fix a buffer overflow issue in qcom_clear_bam_transaction by using +struct_group to group related fields and avoid FORTIFY_SOURCE warnings. + +On x86 architecture, the following error occurs due to warnings being +treated as errors: + +In function β€˜fortify_memset_chk’, + inlined from β€˜qcom_clear_bam_transaction’ at +drivers/mtd/nand/qpic_common.c:88:2: +./include/linux/fortify-string.h:480:25: error: call to β€˜__write_overflow_field’ +declared with attribute warning: detected write beyond size of field +(1st parameter); maybe use struct_group()? [-Werror=attribute-warning] + 480 | __write_overflow_field(p_size_field, size); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + LD [M] drivers/mtd/nand/nandcore.o + CC [M] drivers/w1/masters/mxc_w1.o +cc1: all warnings being treated as errors + +This patch addresses the issue by grouping the related fields in +struct bam_transaction using struct_group and updating the memset call +accordingly. + +Fixes: 8c52932da5e6 ("mtd: rawnand: qcom: cleanup qcom_nandc driver") +Signed-off-by: Md Sadre Alam +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/qpic_common.c | 2 +- + include/linux/mtd/nand-qpic-common.h | 19 +++++++++++-------- + 2 files changed, 12 insertions(+), 9 deletions(-) + +--- a/drivers/mtd/nand/qpic_common.c ++++ b/drivers/mtd/nand/qpic_common.c +@@ -85,7 +85,7 @@ void qcom_clear_bam_transaction(struct q + if (!nandc->props->supports_bam) + return; + +- memset(&bam_txn->bam_ce_pos, 0, sizeof(u32) * 8); ++ memset(&bam_txn->bam_positions, 0, sizeof(bam_txn->bam_positions)); + bam_txn->last_data_desc = NULL; + + sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage * +--- a/include/linux/mtd/nand-qpic-common.h ++++ b/include/linux/mtd/nand-qpic-common.h +@@ -254,14 +254,17 @@ struct bam_transaction { + struct dma_async_tx_descriptor *last_data_desc; + struct dma_async_tx_descriptor *last_cmd_desc; + struct completion txn_done; +- u32 bam_ce_pos; +- u32 bam_ce_start; +- u32 cmd_sgl_pos; +- u32 cmd_sgl_start; +- u32 tx_sgl_pos; +- u32 tx_sgl_start; +- u32 rx_sgl_pos; +- u32 rx_sgl_start; ++ struct_group(bam_positions, ++ u32 bam_ce_pos; ++ u32 bam_ce_start; ++ u32 cmd_sgl_pos; ++ u32 cmd_sgl_start; ++ u32 tx_sgl_pos; ++ u32 tx_sgl_start; ++ u32 rx_sgl_pos; ++ u32 rx_sgl_start; ++ ++ ); + }; + + /* diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-07-v6.15-spi-spi-qpic-add-driver-for-QCOM-SPI-NAND-flash-Inte.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-07-v6.15-spi-spi-qpic-add-driver-for-QCOM-SPI-NAND-flash-Inte.patch new file mode 100755 index 0000000..310d902 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-07-v6.15-spi-spi-qpic-add-driver-for-QCOM-SPI-NAND-flash-Inte.patch @@ -0,0 +1,1737 @@ +From 7304d1909080ef0c9da703500a97f46c98393fcd Mon Sep 17 00:00:00 2001 +From: Md Sadre Alam +Date: Mon, 24 Feb 2025 16:44:14 +0530 +Subject: [PATCH] spi: spi-qpic: add driver for QCOM SPI NAND flash Interface + +This driver implements support for the SPI-NAND mode of QCOM NAND Flash +Interface as a SPI-MEM controller with pipelined ECC capability. + +Co-developed-by: Sricharan Ramabadhran +Signed-off-by: Sricharan Ramabadhran +Co-developed-by: Varadarajan Narayanan +Signed-off-by: Varadarajan Narayanan +Signed-off-by: Md Sadre Alam +Link: https://patch.msgid.link/20250224111414.2809669-3-quic_mdalam@quicinc.com +Signed-off-by: Mark Brown +--- + drivers/mtd/nand/Makefile | 4 + + drivers/spi/Kconfig | 9 + + drivers/spi/Makefile | 1 + + drivers/spi/spi-qpic-snand.c | 1631 ++++++++++++++++++++++++++ + include/linux/mtd/nand-qpic-common.h | 7 + + 5 files changed, 1652 insertions(+) + create mode 100644 drivers/spi/spi-qpic-snand.c + +--- a/drivers/mtd/nand/Makefile ++++ b/drivers/mtd/nand/Makefile +@@ -3,7 +3,11 @@ + nandcore-objs := core.o bbt.o + obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o + obj-$(CONFIG_MTD_NAND_ECC_MEDIATEK) += ecc-mtk.o ++ifeq ($(CONFIG_SPI_QPIC_SNAND),y) ++obj-$(CONFIG_SPI_QPIC_SNAND) += qpic_common.o ++else + obj-$(CONFIG_MTD_NAND_QCOM) += qpic_common.o ++endif + obj-y += onenand/ + obj-y += raw/ + obj-y += spi/ +--- a/drivers/spi/Kconfig ++++ b/drivers/spi/Kconfig +@@ -898,6 +898,15 @@ config SPI_QCOM_QSPI + help + QSPI(Quad SPI) driver for Qualcomm QSPI controller. + ++config SPI_QPIC_SNAND ++ bool "QPIC SNAND controller" ++ depends on ARCH_QCOM || COMPILE_TEST ++ select MTD ++ help ++ QPIC_SNAND (QPIC SPI NAND) driver for Qualcomm QPIC controller. ++ QPIC controller supports both parallel nand and serial nand. ++ This config will enable serial nand driver for QPIC controller. ++ + config SPI_QUP + tristate "Qualcomm SPI controller with QUP interface" + depends on ARCH_QCOM || COMPILE_TEST +--- a/drivers/spi/Makefile ++++ b/drivers/spi/Makefile +@@ -114,6 +114,7 @@ obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx- + obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o + obj-$(CONFIG_SPI_QCOM_GENI) += spi-geni-qcom.o + obj-$(CONFIG_SPI_QCOM_QSPI) += spi-qcom-qspi.o ++obj-$(CONFIG_SPI_QPIC_SNAND) += spi-qpic-snand.o + obj-$(CONFIG_SPI_QUP) += spi-qup.o + obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o + obj-$(CONFIG_SPI_ROCKCHIP_SFC) += spi-rockchip-sfc.o +--- /dev/null ++++ b/drivers/spi/spi-qpic-snand.c +@@ -0,0 +1,1631 @@ ++/* ++ * SPDX-License-Identifier: GPL-2.0 ++ * ++ * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. ++ * ++ * Authors: ++ * Md Sadre Alam ++ * Sricharan R ++ * Varadarajan Narayanan ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define NAND_FLASH_SPI_CFG 0xc0 ++#define NAND_NUM_ADDR_CYCLES 0xc4 ++#define NAND_BUSY_CHECK_WAIT_CNT 0xc8 ++#define NAND_FLASH_FEATURES 0xf64 ++ ++/* QSPI NAND config reg bits */ ++#define LOAD_CLK_CNTR_INIT_EN BIT(28) ++#define CLK_CNTR_INIT_VAL_VEC 0x924 ++#define CLK_CNTR_INIT_VAL_VEC_MASK GENMASK(27, 16) ++#define FEA_STATUS_DEV_ADDR 0xc0 ++#define FEA_STATUS_DEV_ADDR_MASK GENMASK(15, 8) ++#define SPI_CFG BIT(0) ++#define SPI_NUM_ADDR 0xDA4DB ++#define SPI_WAIT_CNT 0x10 ++#define QPIC_QSPI_NUM_CS 1 ++#define SPI_TRANSFER_MODE_x1 BIT(29) ++#define SPI_TRANSFER_MODE_x4 (3 << 29) ++#define SPI_WP BIT(28) ++#define SPI_HOLD BIT(27) ++#define QPIC_SET_FEATURE BIT(31) ++ ++#define SPINAND_RESET 0xff ++#define SPINAND_READID 0x9f ++#define SPINAND_GET_FEATURE 0x0f ++#define SPINAND_SET_FEATURE 0x1f ++#define SPINAND_READ 0x13 ++#define SPINAND_ERASE 0xd8 ++#define SPINAND_WRITE_EN 0x06 ++#define SPINAND_PROGRAM_EXECUTE 0x10 ++#define SPINAND_PROGRAM_LOAD 0x84 ++ ++#define ACC_FEATURE 0xe ++#define BAD_BLOCK_MARKER_SIZE 0x2 ++#define OOB_BUF_SIZE 128 ++#define ecceng_to_qspi(eng) container_of(eng, struct qpic_spi_nand, ecc_eng) ++ ++struct qpic_snand_op { ++ u32 cmd_reg; ++ u32 addr1_reg; ++ u32 addr2_reg; ++}; ++ ++struct snandc_read_status { ++ __le32 snandc_flash; ++ __le32 snandc_buffer; ++ __le32 snandc_erased_cw; ++}; ++ ++/* ++ * ECC state struct ++ * @corrected: ECC corrected ++ * @bitflips: Max bit flip ++ * @failed: ECC failed ++ */ ++struct qcom_ecc_stats { ++ u32 corrected; ++ u32 bitflips; ++ u32 failed; ++}; ++ ++struct qpic_ecc { ++ struct device *dev; ++ int ecc_bytes_hw; ++ int spare_bytes; ++ int bbm_size; ++ int ecc_mode; ++ int bytes; ++ int steps; ++ int step_size; ++ int strength; ++ int cw_size; ++ int cw_data; ++ u32 cfg0; ++ u32 cfg1; ++ u32 cfg0_raw; ++ u32 cfg1_raw; ++ u32 ecc_buf_cfg; ++ u32 ecc_bch_cfg; ++ u32 clrflashstatus; ++ u32 clrreadstatus; ++ bool bch_enabled; ++}; ++ ++struct qpic_spi_nand { ++ struct qcom_nand_controller *snandc; ++ struct spi_controller *ctlr; ++ struct mtd_info *mtd; ++ struct clk *iomacro_clk; ++ struct qpic_ecc *ecc; ++ struct qcom_ecc_stats ecc_stats; ++ struct nand_ecc_engine ecc_eng; ++ u8 *data_buf; ++ u8 *oob_buf; ++ u32 wlen; ++ __le32 addr1; ++ __le32 addr2; ++ __le32 cmd; ++ u32 num_cw; ++ bool oob_rw; ++ bool page_rw; ++ bool raw_rw; ++}; ++ ++static void qcom_spi_set_read_loc_first(struct qcom_nand_controller *snandc, ++ int reg, int cw_offset, int read_size, ++ int is_last_read_loc) ++{ ++ __le32 locreg_val; ++ u32 val = (((cw_offset) << READ_LOCATION_OFFSET) | ++ ((read_size) << READ_LOCATION_SIZE) | ((is_last_read_loc) ++ << READ_LOCATION_LAST)); ++ ++ locreg_val = cpu_to_le32(val); ++ ++ if (reg == NAND_READ_LOCATION_0) ++ snandc->regs->read_location0 = locreg_val; ++ else if (reg == NAND_READ_LOCATION_1) ++ snandc->regs->read_location1 = locreg_val; ++ else if (reg == NAND_READ_LOCATION_2) ++ snandc->regs->read_location1 = locreg_val; ++ else if (reg == NAND_READ_LOCATION_3) ++ snandc->regs->read_location3 = locreg_val; ++} ++ ++static void qcom_spi_set_read_loc_last(struct qcom_nand_controller *snandc, ++ int reg, int cw_offset, int read_size, ++ int is_last_read_loc) ++{ ++ __le32 locreg_val; ++ u32 val = (((cw_offset) << READ_LOCATION_OFFSET) | ++ ((read_size) << READ_LOCATION_SIZE) | ((is_last_read_loc) ++ << READ_LOCATION_LAST)); ++ ++ locreg_val = cpu_to_le32(val); ++ ++ if (reg == NAND_READ_LOCATION_LAST_CW_0) ++ snandc->regs->read_location_last0 = locreg_val; ++ else if (reg == NAND_READ_LOCATION_LAST_CW_1) ++ snandc->regs->read_location_last1 = locreg_val; ++ else if (reg == NAND_READ_LOCATION_LAST_CW_2) ++ snandc->regs->read_location_last2 = locreg_val; ++ else if (reg == NAND_READ_LOCATION_LAST_CW_3) ++ snandc->regs->read_location_last3 = locreg_val; ++} ++ ++static struct qcom_nand_controller *nand_to_qcom_snand(struct nand_device *nand) ++{ ++ struct nand_ecc_engine *eng = nand->ecc.engine; ++ struct qpic_spi_nand *qspi = ecceng_to_qspi(eng); ++ ++ return qspi->snandc; ++} ++ ++static int qcom_spi_init(struct qcom_nand_controller *snandc) ++{ ++ u32 snand_cfg_val = 0x0; ++ int ret; ++ ++ snand_cfg_val = FIELD_PREP(CLK_CNTR_INIT_VAL_VEC_MASK, CLK_CNTR_INIT_VAL_VEC) | ++ FIELD_PREP(LOAD_CLK_CNTR_INIT_EN, 0) | ++ FIELD_PREP(FEA_STATUS_DEV_ADDR_MASK, FEA_STATUS_DEV_ADDR) | ++ FIELD_PREP(SPI_CFG, 0); ++ ++ snandc->regs->spi_cfg = cpu_to_le32(snand_cfg_val); ++ snandc->regs->num_addr_cycle = cpu_to_le32(SPI_NUM_ADDR); ++ snandc->regs->busy_wait_cnt = cpu_to_le32(SPI_WAIT_CNT); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->spi_cfg, NAND_FLASH_SPI_CFG, 1, 0); ++ ++ snand_cfg_val &= ~LOAD_CLK_CNTR_INIT_EN; ++ snandc->regs->spi_cfg = cpu_to_le32(snand_cfg_val); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->spi_cfg, NAND_FLASH_SPI_CFG, 1, 0); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->num_addr_cycle, NAND_NUM_ADDR_CYCLES, 1, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->busy_wait_cnt, NAND_BUSY_CHECK_WAIT_CNT, 1, ++ NAND_BAM_NEXT_SGL); ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure in submitting spi init descriptor\n"); ++ return ret; ++ } ++ ++ return ret; ++} ++ ++static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *oobregion) ++{ ++ struct nand_device *nand = mtd_to_nanddev(mtd); ++ struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); ++ struct qpic_ecc *qecc = snandc->qspi->ecc; ++ ++ if (section > 1) ++ return -ERANGE; ++ ++ oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes; ++ oobregion->offset = mtd->oobsize - oobregion->length; ++ ++ return 0; ++} ++ ++static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *oobregion) ++{ ++ struct nand_device *nand = mtd_to_nanddev(mtd); ++ struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); ++ struct qpic_ecc *qecc = snandc->qspi->ecc; ++ ++ if (section) ++ return -ERANGE; ++ ++ oobregion->length = qecc->steps * 4; ++ oobregion->offset = ((qecc->steps - 1) * qecc->bytes) + qecc->bbm_size; ++ ++ return 0; ++} ++ ++static const struct mtd_ooblayout_ops qcom_spi_ooblayout = { ++ .ecc = qcom_spi_ooblayout_ecc, ++ .free = qcom_spi_ooblayout_free, ++}; ++ ++static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand) ++{ ++ struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); ++ struct nand_ecc_props *conf = &nand->ecc.ctx.conf; ++ struct mtd_info *mtd = nanddev_to_mtd(nand); ++ int cwperpage, bad_block_byte; ++ struct qpic_ecc *ecc_cfg; ++ ++ cwperpage = mtd->writesize / NANDC_STEP_SIZE; ++ snandc->qspi->num_cw = cwperpage; ++ ++ ecc_cfg = kzalloc(sizeof(*ecc_cfg), GFP_KERNEL); ++ if (!ecc_cfg) ++ return -ENOMEM; ++ snandc->qspi->oob_buf = kzalloc(mtd->writesize + mtd->oobsize, ++ GFP_KERNEL); ++ if (!snandc->qspi->oob_buf) ++ return -ENOMEM; ++ ++ memset(snandc->qspi->oob_buf, 0xff, mtd->writesize + mtd->oobsize); ++ ++ nand->ecc.ctx.priv = ecc_cfg; ++ snandc->qspi->mtd = mtd; ++ ++ ecc_cfg->ecc_bytes_hw = 7; ++ ecc_cfg->spare_bytes = 4; ++ ecc_cfg->bbm_size = 1; ++ ecc_cfg->bch_enabled = true; ++ ecc_cfg->bytes = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes + ecc_cfg->bbm_size; ++ ++ ecc_cfg->steps = 4; ++ ecc_cfg->strength = 4; ++ ecc_cfg->step_size = 512; ++ ecc_cfg->cw_data = 516; ++ ecc_cfg->cw_size = ecc_cfg->cw_data + ecc_cfg->bytes; ++ bad_block_byte = mtd->writesize - ecc_cfg->cw_size * (cwperpage - 1) + 1; ++ ++ mtd_set_ooblayout(mtd, &qcom_spi_ooblayout); ++ ++ ecc_cfg->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | ++ FIELD_PREP(UD_SIZE_BYTES_MASK, ecc_cfg->cw_data) | ++ FIELD_PREP(DISABLE_STATUS_AFTER_WRITE, 1) | ++ FIELD_PREP(NUM_ADDR_CYCLES_MASK, 3) | ++ FIELD_PREP(ECC_PARITY_SIZE_BYTES_RS, ecc_cfg->ecc_bytes_hw) | ++ FIELD_PREP(STATUS_BFR_READ, 0) | ++ FIELD_PREP(SET_RD_MODE_AFTER_STATUS, 1) | ++ FIELD_PREP(SPARE_SIZE_BYTES_MASK, ecc_cfg->spare_bytes); ++ ++ ecc_cfg->cfg1 = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 0) | ++ FIELD_PREP(CS_ACTIVE_BSY, 0) | ++ FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, bad_block_byte) | ++ FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 0) | ++ FIELD_PREP(WR_RD_BSY_GAP_MASK, 20) | ++ FIELD_PREP(WIDE_FLASH, 0) | ++ FIELD_PREP(ENABLE_BCH_ECC, ecc_cfg->bch_enabled); ++ ++ ecc_cfg->cfg0_raw = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | ++ FIELD_PREP(NUM_ADDR_CYCLES_MASK, 3) | ++ FIELD_PREP(UD_SIZE_BYTES_MASK, ecc_cfg->cw_size) | ++ FIELD_PREP(SPARE_SIZE_BYTES_MASK, 0); ++ ++ ecc_cfg->cfg1_raw = FIELD_PREP(NAND_RECOVERY_CYCLES_MASK, 0) | ++ FIELD_PREP(CS_ACTIVE_BSY, 0) | ++ FIELD_PREP(BAD_BLOCK_BYTE_NUM_MASK, 17) | ++ FIELD_PREP(BAD_BLOCK_IN_SPARE_AREA, 1) | ++ FIELD_PREP(WR_RD_BSY_GAP_MASK, 20) | ++ FIELD_PREP(WIDE_FLASH, 0) | ++ FIELD_PREP(DEV0_CFG1_ECC_DISABLE, 1); ++ ++ ecc_cfg->ecc_bch_cfg = FIELD_PREP(ECC_CFG_ECC_DISABLE, !ecc_cfg->bch_enabled) | ++ FIELD_PREP(ECC_SW_RESET, 0) | ++ FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, ecc_cfg->cw_data) | ++ FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) | ++ FIELD_PREP(ECC_MODE_MASK, 0) | ++ FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw); ++ ++ ecc_cfg->ecc_buf_cfg = 0x203 << NUM_STEPS; ++ ecc_cfg->clrflashstatus = FS_READY_BSY_N; ++ ecc_cfg->clrreadstatus = 0xc0; ++ ++ conf->step_size = ecc_cfg->step_size; ++ conf->strength = ecc_cfg->strength; ++ ++ snandc->regs->erased_cw_detect_cfg_clr = cpu_to_le32(CLR_ERASED_PAGE_DET); ++ snandc->regs->erased_cw_detect_cfg_set = cpu_to_le32(SET_ERASED_PAGE_DET); ++ ++ dev_dbg(snandc->dev, "ECC strength: %u bits per %u bytes\n", ++ ecc_cfg->strength, ecc_cfg->step_size); ++ ++ return 0; ++} ++ ++static void qcom_spi_ecc_cleanup_ctx_pipelined(struct nand_device *nand) ++{ ++ struct qpic_ecc *ecc_cfg = nand_to_ecc_ctx(nand); ++ ++ kfree(ecc_cfg); ++} ++ ++static int qcom_spi_ecc_prepare_io_req_pipelined(struct nand_device *nand, ++ struct nand_page_io_req *req) ++{ ++ struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); ++ struct qpic_ecc *ecc_cfg = nand_to_ecc_ctx(nand); ++ ++ snandc->qspi->ecc = ecc_cfg; ++ snandc->qspi->raw_rw = false; ++ snandc->qspi->oob_rw = false; ++ snandc->qspi->page_rw = false; ++ ++ if (req->datalen) ++ snandc->qspi->page_rw = true; ++ ++ if (req->ooblen) ++ snandc->qspi->oob_rw = true; ++ ++ if (req->mode == MTD_OPS_RAW) ++ snandc->qspi->raw_rw = true; ++ ++ return 0; ++} ++ ++static int qcom_spi_ecc_finish_io_req_pipelined(struct nand_device *nand, ++ struct nand_page_io_req *req) ++{ ++ struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); ++ struct mtd_info *mtd = nanddev_to_mtd(nand); ++ ++ if (req->mode == MTD_OPS_RAW || req->type != NAND_PAGE_READ) ++ return 0; ++ ++ if (snandc->qspi->ecc_stats.failed) ++ mtd->ecc_stats.failed += snandc->qspi->ecc_stats.failed; ++ else ++ mtd->ecc_stats.corrected += snandc->qspi->ecc_stats.corrected; ++ ++ if (snandc->qspi->ecc_stats.failed) ++ return -EBADMSG; ++ else ++ return snandc->qspi->ecc_stats.bitflips; ++} ++ ++static struct nand_ecc_engine_ops qcom_spi_ecc_engine_ops_pipelined = { ++ .init_ctx = qcom_spi_ecc_init_ctx_pipelined, ++ .cleanup_ctx = qcom_spi_ecc_cleanup_ctx_pipelined, ++ .prepare_io_req = qcom_spi_ecc_prepare_io_req_pipelined, ++ .finish_io_req = qcom_spi_ecc_finish_io_req_pipelined, ++}; ++ ++/* helper to configure location register values */ ++static void qcom_spi_set_read_loc(struct qcom_nand_controller *snandc, int cw, int reg, ++ int cw_offset, int read_size, int is_last_read_loc) ++{ ++ int reg_base = NAND_READ_LOCATION_0; ++ int num_cw = snandc->qspi->num_cw; ++ ++ if (cw == (num_cw - 1)) ++ reg_base = NAND_READ_LOCATION_LAST_CW_0; ++ ++ reg_base += reg * 4; ++ ++ if (cw == (num_cw - 1)) ++ return qcom_spi_set_read_loc_last(snandc, reg_base, cw_offset, ++ read_size, is_last_read_loc); ++ else ++ return qcom_spi_set_read_loc_first(snandc, reg_base, cw_offset, ++ read_size, is_last_read_loc); ++} ++ ++static void ++qcom_spi_config_cw_read(struct qcom_nand_controller *snandc, bool use_ecc, int cw) ++{ ++ __le32 *reg = &snandc->regs->read_location0; ++ int num_cw = snandc->qspi->num_cw; ++ ++ qcom_write_reg_dma(snandc, reg, NAND_READ_LOCATION_0, 4, NAND_BAM_NEXT_SGL); ++ if (cw == (num_cw - 1)) { ++ reg = &snandc->regs->read_location_last0; ++ qcom_write_reg_dma(snandc, reg, NAND_READ_LOCATION_LAST_CW_0, 4, ++ NAND_BAM_NEXT_SGL); ++ } ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(snandc, &snandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ ++ qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 2, 0); ++ qcom_read_reg_dma(snandc, NAND_ERASED_CW_DETECT_STATUS, 1, ++ NAND_BAM_NEXT_SGL); ++} ++ ++static int qcom_spi_block_erase(struct qcom_nand_controller *snandc) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ int ret; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->addr0 = snandc->qspi->addr1; ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cfg0 = cpu_to_le32(ecc_cfg->cfg0_raw & ~(7 << CW_PER_PAGE)); ++ snandc->regs->cfg1 = cpu_to_le32(ecc_cfg->cfg1_raw); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->cmd, NAND_FLASH_CMD, 3, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(snandc, &snandc->regs->cfg0, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(snandc, &snandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to erase block\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static void qcom_spi_config_single_cw_page_read(struct qcom_nand_controller *snandc, ++ bool use_ecc, int cw) ++{ ++ __le32 *reg = &snandc->regs->read_location0; ++ int num_cw = snandc->qspi->num_cw; ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_clr, ++ NAND_ERASED_CW_DETECT_CFG, 1, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_set, ++ NAND_ERASED_CW_DETECT_CFG, 1, ++ NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); ++ ++ if (cw == (num_cw - 1)) { ++ reg = &snandc->regs->read_location_last0; ++ qcom_write_reg_dma(snandc, reg, NAND_READ_LOCATION_LAST_CW_0, 4, NAND_BAM_NEXT_SGL); ++ } ++ qcom_write_reg_dma(snandc, &snandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(snandc, &snandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ ++ qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 1, 0); ++} ++ ++static int qcom_spi_read_last_cw(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ struct mtd_info *mtd = snandc->qspi->mtd; ++ int size, ret = 0; ++ int col, bbpos; ++ u32 cfg0, cfg1, ecc_bch_cfg; ++ u32 num_cw = snandc->qspi->num_cw; ++ ++ qcom_clear_bam_transaction(snandc); ++ qcom_clear_read_regs(snandc); ++ ++ size = ecc_cfg->cw_size; ++ col = ecc_cfg->cw_size * (num_cw - 1); ++ ++ memset(snandc->data_buffer, 0xff, size); ++ snandc->regs->addr0 = (snandc->qspi->addr1 | cpu_to_le32(col)); ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ ++ cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | ++ 0 << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1_raw; ++ ecc_bch_cfg = 1 << ECC_CFG_ECC_DISABLE; ++ ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->clrflashstatus = cpu_to_le32(ecc_cfg->clrflashstatus); ++ snandc->regs->clrreadstatus = cpu_to_le32(ecc_cfg->clrreadstatus); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_spi_set_read_loc(snandc, num_cw - 1, 0, 0, ecc_cfg->cw_size, 1); ++ ++ qcom_spi_config_single_cw_page_read(snandc, false, num_cw - 1); ++ ++ qcom_read_data_dma(snandc, FLASH_BUF_ACC, snandc->data_buffer, size, 0); ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failed to read last cw\n"); ++ return ret; ++ } ++ ++ qcom_nandc_dev_to_mem(snandc, true); ++ u32 flash = le32_to_cpu(snandc->reg_read_buf[0]); ++ ++ if (flash & (FS_OP_ERR | FS_MPU_ERR)) ++ return -EIO; ++ ++ bbpos = mtd->writesize - ecc_cfg->cw_size * (num_cw - 1); ++ ++ if (snandc->data_buffer[bbpos] == 0xff) ++ snandc->data_buffer[bbpos + 1] = 0xff; ++ if (snandc->data_buffer[bbpos] != 0xff) ++ snandc->data_buffer[bbpos + 1] = snandc->data_buffer[bbpos]; ++ ++ memcpy(op->data.buf.in, snandc->data_buffer + bbpos, op->data.nbytes); ++ ++ return ret; ++} ++ ++static int qcom_spi_check_error(struct qcom_nand_controller *snandc, u8 *data_buf, u8 *oob_buf) ++{ ++ struct snandc_read_status *buf; ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ int i, num_cw = snandc->qspi->num_cw; ++ bool flash_op_err = false, erased; ++ unsigned int max_bitflips = 0; ++ unsigned int uncorrectable_cws = 0; ++ ++ snandc->qspi->ecc_stats.failed = 0; ++ snandc->qspi->ecc_stats.corrected = 0; ++ ++ qcom_nandc_dev_to_mem(snandc, true); ++ buf = (struct snandc_read_status *)snandc->reg_read_buf; ++ ++ for (i = 0; i < num_cw; i++, buf++) { ++ u32 flash, buffer, erased_cw; ++ int data_len, oob_len; ++ ++ if (i == (num_cw - 1)) { ++ data_len = NANDC_STEP_SIZE - ((num_cw - 1) << 2); ++ oob_len = num_cw << 2; ++ } else { ++ data_len = ecc_cfg->cw_data; ++ oob_len = 0; ++ } ++ ++ flash = le32_to_cpu(buf->snandc_flash); ++ buffer = le32_to_cpu(buf->snandc_buffer); ++ erased_cw = le32_to_cpu(buf->snandc_erased_cw); ++ ++ if ((flash & FS_OP_ERR) && (buffer & BS_UNCORRECTABLE_BIT)) { ++ if (ecc_cfg->bch_enabled) ++ erased = (erased_cw & ERASED_CW) == ERASED_CW; ++ else ++ erased = false; ++ ++ if (!erased) ++ uncorrectable_cws |= BIT(i); ++ ++ } else if (flash & (FS_OP_ERR | FS_MPU_ERR)) { ++ flash_op_err = true; ++ } else { ++ unsigned int stat; ++ ++ stat = buffer & BS_CORRECTABLE_ERR_MSK; ++ snandc->qspi->ecc_stats.corrected += stat; ++ max_bitflips = max(max_bitflips, stat); ++ } ++ ++ if (data_buf) ++ data_buf += data_len; ++ if (oob_buf) ++ oob_buf += oob_len + ecc_cfg->bytes; ++ } ++ ++ if (flash_op_err) ++ return -EIO; ++ ++ if (!uncorrectable_cws) ++ snandc->qspi->ecc_stats.bitflips = max_bitflips; ++ else ++ snandc->qspi->ecc_stats.failed++; ++ ++ return 0; ++} ++ ++static int qcom_spi_check_raw_flash_errors(struct qcom_nand_controller *snandc, int cw_cnt) ++{ ++ int i; ++ ++ qcom_nandc_dev_to_mem(snandc, true); ++ ++ for (i = 0; i < cw_cnt; i++) { ++ u32 flash = le32_to_cpu(snandc->reg_read_buf[i]); ++ ++ if (flash & (FS_OP_ERR | FS_MPU_ERR)) ++ return -EIO; ++ } ++ ++ return 0; ++} ++ ++static int qcom_spi_read_cw_raw(struct qcom_nand_controller *snandc, u8 *data_buf, ++ u8 *oob_buf, int cw) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ struct mtd_info *mtd = snandc->qspi->mtd; ++ int data_size1, data_size2, oob_size1, oob_size2; ++ int ret, reg_off = FLASH_BUF_ACC, read_loc = 0; ++ int raw_cw = cw; ++ u32 cfg0, cfg1, ecc_bch_cfg, num_cw = snandc->qspi->num_cw; ++ int col; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ raw_cw = num_cw - 1; ++ ++ cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | ++ 0 << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1_raw; ++ ecc_bch_cfg = ECC_CFG_ECC_DISABLE; ++ ++ col = ecc_cfg->cw_size * cw; ++ ++ snandc->regs->addr0 = (snandc->qspi->addr1 | cpu_to_le32(col)); ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->clrflashstatus = cpu_to_le32(ecc_cfg->clrflashstatus); ++ snandc->regs->clrreadstatus = cpu_to_le32(ecc_cfg->clrreadstatus); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_spi_set_read_loc(snandc, raw_cw, 0, 0, ecc_cfg->cw_size, 1); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, 1, 0); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_clr, ++ NAND_ERASED_CW_DETECT_CFG, 1, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_set, ++ NAND_ERASED_CW_DETECT_CFG, 1, ++ NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); ++ ++ data_size1 = mtd->writesize - ecc_cfg->cw_size * (num_cw - 1); ++ oob_size1 = ecc_cfg->bbm_size; ++ ++ if (cw == (num_cw - 1)) { ++ data_size2 = NANDC_STEP_SIZE - data_size1 - ++ ((num_cw - 1) * 4); ++ oob_size2 = (num_cw * 4) + ecc_cfg->ecc_bytes_hw + ++ ecc_cfg->spare_bytes; ++ } else { ++ data_size2 = ecc_cfg->cw_data - data_size1; ++ oob_size2 = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes; ++ } ++ ++ qcom_spi_set_read_loc(snandc, cw, 0, read_loc, data_size1, 0); ++ read_loc += data_size1; ++ ++ qcom_spi_set_read_loc(snandc, cw, 1, read_loc, oob_size1, 0); ++ read_loc += oob_size1; ++ ++ qcom_spi_set_read_loc(snandc, cw, 2, read_loc, data_size2, 0); ++ read_loc += data_size2; ++ ++ qcom_spi_set_read_loc(snandc, cw, 3, read_loc, oob_size2, 1); ++ ++ qcom_spi_config_cw_read(snandc, false, raw_cw); ++ ++ qcom_read_data_dma(snandc, reg_off, data_buf, data_size1, 0); ++ reg_off += data_size1; ++ ++ qcom_read_data_dma(snandc, reg_off, oob_buf, oob_size1, 0); ++ reg_off += oob_size1; ++ ++ qcom_read_data_dma(snandc, reg_off, data_buf + data_size1, data_size2, 0); ++ reg_off += data_size2; ++ ++ qcom_read_data_dma(snandc, reg_off, oob_buf + oob_size1, oob_size2, 0); ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to read raw cw %d\n", cw); ++ return ret; ++ } ++ ++ return qcom_spi_check_raw_flash_errors(snandc, 1); ++} ++ ++static int qcom_spi_read_page_raw(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ u8 *data_buf = NULL, *oob_buf = NULL; ++ int ret, cw; ++ u32 num_cw = snandc->qspi->num_cw; ++ ++ if (snandc->qspi->page_rw) ++ data_buf = op->data.buf.in; ++ ++ oob_buf = snandc->qspi->oob_buf; ++ memset(oob_buf, 0xff, OOB_BUF_SIZE); ++ ++ for (cw = 0; cw < num_cw; cw++) { ++ ret = qcom_spi_read_cw_raw(snandc, data_buf, oob_buf, cw); ++ if (ret) ++ return ret; ++ ++ if (data_buf) ++ data_buf += ecc_cfg->cw_data; ++ if (oob_buf) ++ oob_buf += ecc_cfg->bytes; ++ } ++ ++ return 0; ++} ++ ++static int qcom_spi_read_page_ecc(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ u8 *data_buf = NULL, *data_buf_start, *oob_buf = NULL, *oob_buf_start; ++ int ret, i; ++ u32 cfg0, cfg1, ecc_bch_cfg, num_cw = snandc->qspi->num_cw; ++ ++ data_buf = op->data.buf.in; ++ data_buf_start = data_buf; ++ ++ oob_buf = snandc->qspi->oob_buf; ++ oob_buf_start = oob_buf; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ ++ cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1; ++ ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; ++ ++ snandc->regs->addr0 = snandc->qspi->addr1; ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->clrflashstatus = cpu_to_le32(ecc_cfg->clrflashstatus); ++ snandc->regs->clrreadstatus = cpu_to_le32(ecc_cfg->clrreadstatus); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_spi_set_read_loc(snandc, 0, 0, 0, ecc_cfg->cw_data, 1); ++ ++ qcom_clear_bam_transaction(snandc); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_clr, ++ NAND_ERASED_CW_DETECT_CFG, 1, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_set, ++ NAND_ERASED_CW_DETECT_CFG, 1, ++ NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); ++ ++ for (i = 0; i < num_cw; i++) { ++ int data_size, oob_size; ++ ++ if (i == (num_cw - 1)) { ++ data_size = 512 - ((num_cw - 1) << 2); ++ oob_size = (num_cw << 2) + ecc_cfg->ecc_bytes_hw + ++ ecc_cfg->spare_bytes; ++ } else { ++ data_size = ecc_cfg->cw_data; ++ oob_size = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes; ++ } ++ ++ if (data_buf && oob_buf) { ++ qcom_spi_set_read_loc(snandc, i, 0, 0, data_size, 0); ++ qcom_spi_set_read_loc(snandc, i, 1, data_size, oob_size, 1); ++ } else if (data_buf) { ++ qcom_spi_set_read_loc(snandc, i, 0, 0, data_size, 1); ++ } else { ++ qcom_spi_set_read_loc(snandc, i, 0, data_size, oob_size, 1); ++ } ++ ++ qcom_spi_config_cw_read(snandc, true, i); ++ ++ if (data_buf) ++ qcom_read_data_dma(snandc, FLASH_BUF_ACC, data_buf, ++ data_size, 0); ++ if (oob_buf) { ++ int j; ++ ++ for (j = 0; j < ecc_cfg->bbm_size; j++) ++ *oob_buf++ = 0xff; ++ ++ qcom_read_data_dma(snandc, FLASH_BUF_ACC + data_size, ++ oob_buf, oob_size, 0); ++ } ++ ++ if (data_buf) ++ data_buf += data_size; ++ if (oob_buf) ++ oob_buf += oob_size; ++ } ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to read page\n"); ++ return ret; ++ } ++ ++ return qcom_spi_check_error(snandc, data_buf_start, oob_buf_start); ++} ++ ++static int qcom_spi_read_page_oob(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ u8 *data_buf = NULL, *data_buf_start, *oob_buf = NULL, *oob_buf_start; ++ int ret, i; ++ u32 cfg0, cfg1, ecc_bch_cfg, num_cw = snandc->qspi->num_cw; ++ ++ oob_buf = op->data.buf.in; ++ oob_buf_start = oob_buf; ++ ++ data_buf_start = data_buf; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ ++ cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1; ++ ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; ++ ++ snandc->regs->addr0 = snandc->qspi->addr1; ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->clrflashstatus = cpu_to_le32(ecc_cfg->clrflashstatus); ++ snandc->regs->clrreadstatus = cpu_to_le32(ecc_cfg->clrreadstatus); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_spi_set_read_loc(snandc, 0, 0, 0, ecc_cfg->cw_data, 1); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_clr, ++ NAND_ERASED_CW_DETECT_CFG, 1, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_set, ++ NAND_ERASED_CW_DETECT_CFG, 1, ++ NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL); ++ ++ for (i = 0; i < num_cw; i++) { ++ int data_size, oob_size; ++ ++ if (i == (num_cw - 1)) { ++ data_size = NANDC_STEP_SIZE - ((num_cw - 1) << 2); ++ oob_size = (num_cw << 2) + ecc_cfg->ecc_bytes_hw + ++ ecc_cfg->spare_bytes; ++ } else { ++ data_size = ecc_cfg->cw_data; ++ oob_size = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes; ++ } ++ ++ qcom_spi_set_read_loc(snandc, i, 0, data_size, oob_size, 1); ++ ++ qcom_spi_config_cw_read(snandc, true, i); ++ ++ if (oob_buf) { ++ int j; ++ ++ for (j = 0; j < ecc_cfg->bbm_size; j++) ++ *oob_buf++ = 0xff; ++ ++ qcom_read_data_dma(snandc, FLASH_BUF_ACC + data_size, ++ oob_buf, oob_size, 0); ++ } ++ ++ if (oob_buf) ++ oob_buf += oob_size; ++ } ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to read oob\n"); ++ return ret; ++ } ++ ++ return qcom_spi_check_error(snandc, data_buf_start, oob_buf_start); ++} ++ ++static int qcom_spi_read_page(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ if (snandc->qspi->page_rw && snandc->qspi->raw_rw) ++ return qcom_spi_read_page_raw(snandc, op); ++ ++ if (snandc->qspi->page_rw) ++ return qcom_spi_read_page_ecc(snandc, op); ++ ++ if (snandc->qspi->oob_rw && snandc->qspi->raw_rw) ++ return qcom_spi_read_last_cw(snandc, op); ++ ++ if (snandc->qspi->oob_rw) ++ return qcom_spi_read_page_oob(snandc, op); ++ ++ return 0; ++} ++ ++static void qcom_spi_config_page_write(struct qcom_nand_controller *snandc) ++{ ++ qcom_write_reg_dma(snandc, &snandc->regs->addr0, NAND_ADDR0, 2, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->cfg0, NAND_DEV0_CFG0, 3, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->ecc_buf_cfg, NAND_EBI2_ECC_BUF_CFG, ++ 1, NAND_BAM_NEXT_SGL); ++} ++ ++static void qcom_spi_config_cw_write(struct qcom_nand_controller *snandc) ++{ ++ qcom_write_reg_dma(snandc, &snandc->regs->cmd, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(snandc, &snandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->clrflashstatus, NAND_FLASH_STATUS, 1, 0); ++ qcom_write_reg_dma(snandc, &snandc->regs->clrreadstatus, NAND_READ_STATUS, 1, ++ NAND_BAM_NEXT_SGL); ++} ++ ++static int qcom_spi_program_raw(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ struct mtd_info *mtd = snandc->qspi->mtd; ++ u8 *data_buf = NULL, *oob_buf = NULL; ++ int i, ret; ++ int num_cw = snandc->qspi->num_cw; ++ u32 cfg0, cfg1, ecc_bch_cfg; ++ ++ cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1_raw; ++ ecc_bch_cfg = ECC_CFG_ECC_DISABLE; ++ ++ data_buf = snandc->qspi->data_buf; ++ ++ oob_buf = snandc->qspi->oob_buf; ++ memset(oob_buf, 0xff, OOB_BUF_SIZE); ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ ++ snandc->regs->addr0 = snandc->qspi->addr1; ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->clrflashstatus = cpu_to_le32(ecc_cfg->clrflashstatus); ++ snandc->regs->clrreadstatus = cpu_to_le32(ecc_cfg->clrreadstatus); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_spi_config_page_write(snandc); ++ ++ for (i = 0; i < num_cw; i++) { ++ int data_size1, data_size2, oob_size1, oob_size2; ++ int reg_off = FLASH_BUF_ACC; ++ ++ data_size1 = mtd->writesize - ecc_cfg->cw_size * (num_cw - 1); ++ oob_size1 = ecc_cfg->bbm_size; ++ ++ if (i == (num_cw - 1)) { ++ data_size2 = NANDC_STEP_SIZE - data_size1 - ++ ((num_cw - 1) << 2); ++ oob_size2 = (num_cw << 2) + ecc_cfg->ecc_bytes_hw + ++ ecc_cfg->spare_bytes; ++ } else { ++ data_size2 = ecc_cfg->cw_data - data_size1; ++ oob_size2 = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes; ++ } ++ ++ qcom_write_data_dma(snandc, reg_off, data_buf, data_size1, ++ NAND_BAM_NO_EOT); ++ reg_off += data_size1; ++ data_buf += data_size1; ++ ++ qcom_write_data_dma(snandc, reg_off, oob_buf, oob_size1, ++ NAND_BAM_NO_EOT); ++ oob_buf += oob_size1; ++ reg_off += oob_size1; ++ ++ qcom_write_data_dma(snandc, reg_off, data_buf, data_size2, ++ NAND_BAM_NO_EOT); ++ reg_off += data_size2; ++ data_buf += data_size2; ++ ++ qcom_write_data_dma(snandc, reg_off, oob_buf, oob_size2, 0); ++ oob_buf += oob_size2; ++ ++ qcom_spi_config_cw_write(snandc); ++ } ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to write raw page\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int qcom_spi_program_ecc(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ u8 *data_buf = NULL, *oob_buf = NULL; ++ int i, ret; ++ int num_cw = snandc->qspi->num_cw; ++ u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg; ++ ++ cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1; ++ ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; ++ ecc_buf_cfg = ecc_cfg->ecc_buf_cfg; ++ ++ if (snandc->qspi->data_buf) ++ data_buf = snandc->qspi->data_buf; ++ ++ oob_buf = snandc->qspi->oob_buf; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ ++ snandc->regs->addr0 = snandc->qspi->addr1; ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->ecc_buf_cfg = cpu_to_le32(ecc_buf_cfg); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ qcom_spi_config_page_write(snandc); ++ ++ for (i = 0; i < num_cw; i++) { ++ int data_size, oob_size; ++ ++ if (i == (num_cw - 1)) { ++ data_size = NANDC_STEP_SIZE - ((num_cw - 1) << 2); ++ oob_size = (num_cw << 2) + ecc_cfg->ecc_bytes_hw + ++ ecc_cfg->spare_bytes; ++ } else { ++ data_size = ecc_cfg->cw_data; ++ oob_size = ecc_cfg->bytes; ++ } ++ ++ if (data_buf) ++ qcom_write_data_dma(snandc, FLASH_BUF_ACC, data_buf, data_size, ++ i == (num_cw - 1) ? NAND_BAM_NO_EOT : 0); ++ ++ if (i == (num_cw - 1)) { ++ if (oob_buf) { ++ oob_buf += ecc_cfg->bbm_size; ++ qcom_write_data_dma(snandc, FLASH_BUF_ACC + data_size, ++ oob_buf, oob_size, 0); ++ } ++ } ++ ++ qcom_spi_config_cw_write(snandc); ++ ++ if (data_buf) ++ data_buf += data_size; ++ if (oob_buf) ++ oob_buf += oob_size; ++ } ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to write page\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int qcom_spi_program_oob(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_ecc *ecc_cfg = snandc->qspi->ecc; ++ u8 *oob_buf = NULL; ++ int ret, col, data_size, oob_size; ++ int num_cw = snandc->qspi->num_cw; ++ u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg; ++ ++ cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | ++ (num_cw - 1) << CW_PER_PAGE; ++ cfg1 = ecc_cfg->cfg1; ++ ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; ++ ecc_buf_cfg = ecc_cfg->ecc_buf_cfg; ++ ++ col = ecc_cfg->cw_size * (num_cw - 1); ++ ++ oob_buf = snandc->qspi->data_buf; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ snandc->regs->addr0 = (snandc->qspi->addr1 | cpu_to_le32(col)); ++ snandc->regs->addr1 = snandc->qspi->addr2; ++ snandc->regs->cmd = snandc->qspi->cmd; ++ snandc->regs->cfg0 = cpu_to_le32(cfg0); ++ snandc->regs->cfg1 = cpu_to_le32(cfg1); ++ snandc->regs->ecc_bch_cfg = cpu_to_le32(ecc_bch_cfg); ++ snandc->regs->ecc_buf_cfg = cpu_to_le32(ecc_buf_cfg); ++ snandc->regs->exec = cpu_to_le32(1); ++ ++ /* calculate the data and oob size for the last codeword/step */ ++ data_size = NANDC_STEP_SIZE - ((num_cw - 1) << 2); ++ oob_size = snandc->qspi->mtd->oobavail; ++ ++ memset(snandc->data_buffer, 0xff, ecc_cfg->cw_data); ++ /* override new oob content to last codeword */ ++ mtd_ooblayout_get_databytes(snandc->qspi->mtd, snandc->data_buffer + data_size, ++ oob_buf, 0, snandc->qspi->mtd->oobavail); ++ qcom_spi_config_page_write(snandc); ++ qcom_write_data_dma(snandc, FLASH_BUF_ACC, snandc->data_buffer, data_size + oob_size, 0); ++ qcom_spi_config_cw_write(snandc); ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) { ++ dev_err(snandc->dev, "failure to write oob\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int qcom_spi_program_execute(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ if (snandc->qspi->page_rw && snandc->qspi->raw_rw) ++ return qcom_spi_program_raw(snandc, op); ++ ++ if (snandc->qspi->page_rw) ++ return qcom_spi_program_ecc(snandc, op); ++ ++ if (snandc->qspi->oob_rw) ++ return qcom_spi_program_oob(snandc, op); ++ ++ return 0; ++} ++ ++static int qcom_spi_cmd_mapping(struct qcom_nand_controller *snandc, u32 opcode, u32 *cmd) ++{ ++ switch (opcode) { ++ case SPINAND_RESET: ++ *cmd = (SPI_WP | SPI_HOLD | SPI_TRANSFER_MODE_x1 | OP_RESET_DEVICE); ++ break; ++ case SPINAND_READID: ++ *cmd = (SPI_WP | SPI_HOLD | SPI_TRANSFER_MODE_x1 | OP_FETCH_ID); ++ break; ++ case SPINAND_GET_FEATURE: ++ *cmd = (SPI_TRANSFER_MODE_x1 | SPI_WP | SPI_HOLD | ACC_FEATURE); ++ break; ++ case SPINAND_SET_FEATURE: ++ *cmd = (SPI_TRANSFER_MODE_x1 | SPI_WP | SPI_HOLD | ACC_FEATURE | ++ QPIC_SET_FEATURE); ++ break; ++ case SPINAND_READ: ++ if (snandc->qspi->raw_rw) { ++ *cmd = (PAGE_ACC | LAST_PAGE | SPI_TRANSFER_MODE_x1 | ++ SPI_WP | SPI_HOLD | OP_PAGE_READ); ++ } else { ++ *cmd = (PAGE_ACC | LAST_PAGE | SPI_TRANSFER_MODE_x1 | ++ SPI_WP | SPI_HOLD | OP_PAGE_READ_WITH_ECC); ++ } ++ ++ break; ++ case SPINAND_ERASE: ++ *cmd = OP_BLOCK_ERASE | PAGE_ACC | LAST_PAGE | SPI_WP | ++ SPI_HOLD | SPI_TRANSFER_MODE_x1; ++ break; ++ case SPINAND_WRITE_EN: ++ *cmd = SPINAND_WRITE_EN; ++ break; ++ case SPINAND_PROGRAM_EXECUTE: ++ *cmd = (PAGE_ACC | LAST_PAGE | SPI_TRANSFER_MODE_x1 | ++ SPI_WP | SPI_HOLD | OP_PROGRAM_PAGE); ++ break; ++ case SPINAND_PROGRAM_LOAD: ++ *cmd = SPINAND_PROGRAM_LOAD; ++ break; ++ default: ++ dev_err(snandc->dev, "Opcode not supported: %u\n", opcode); ++ return -EOPNOTSUPP; ++ } ++ ++ return 0; ++} ++ ++static int qcom_spi_write_page(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ int ret; ++ u32 cmd; ++ ++ ret = qcom_spi_cmd_mapping(snandc, op->cmd.opcode, &cmd); ++ if (ret < 0) ++ return ret; ++ ++ if (op->cmd.opcode == SPINAND_PROGRAM_LOAD) ++ snandc->qspi->data_buf = (u8 *)op->data.buf.out; ++ ++ return 0; ++} ++ ++static int qcom_spi_send_cmdaddr(struct qcom_nand_controller *snandc, ++ const struct spi_mem_op *op) ++{ ++ struct qpic_snand_op s_op = {}; ++ u32 cmd; ++ int ret, opcode; ++ ++ ret = qcom_spi_cmd_mapping(snandc, op->cmd.opcode, &cmd); ++ if (ret < 0) ++ return ret; ++ ++ s_op.cmd_reg = cmd; ++ s_op.addr1_reg = op->addr.val; ++ s_op.addr2_reg = 0; ++ ++ opcode = op->cmd.opcode; ++ ++ switch (opcode) { ++ case SPINAND_WRITE_EN: ++ return 0; ++ case SPINAND_PROGRAM_EXECUTE: ++ s_op.addr1_reg = op->addr.val << 16; ++ s_op.addr2_reg = op->addr.val >> 16 & 0xff; ++ snandc->qspi->addr1 = cpu_to_le32(s_op.addr1_reg); ++ snandc->qspi->addr2 = cpu_to_le32(s_op.addr2_reg); ++ snandc->qspi->cmd = cpu_to_le32(cmd); ++ return qcom_spi_program_execute(snandc, op); ++ case SPINAND_READ: ++ s_op.addr1_reg = (op->addr.val << 16); ++ s_op.addr2_reg = op->addr.val >> 16 & 0xff; ++ snandc->qspi->addr1 = cpu_to_le32(s_op.addr1_reg); ++ snandc->qspi->addr2 = cpu_to_le32(s_op.addr2_reg); ++ snandc->qspi->cmd = cpu_to_le32(cmd); ++ return 0; ++ case SPINAND_ERASE: ++ s_op.addr2_reg = (op->addr.val >> 16) & 0xffff; ++ s_op.addr1_reg = op->addr.val; ++ snandc->qspi->addr1 = cpu_to_le32(s_op.addr1_reg << 16); ++ snandc->qspi->addr2 = cpu_to_le32(s_op.addr2_reg); ++ snandc->qspi->cmd = cpu_to_le32(cmd); ++ qcom_spi_block_erase(snandc); ++ return 0; ++ default: ++ break; ++ } ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ ++ snandc->regs->cmd = cpu_to_le32(s_op.cmd_reg); ++ snandc->regs->exec = cpu_to_le32(1); ++ snandc->regs->addr0 = cpu_to_le32(s_op.addr1_reg); ++ snandc->regs->addr1 = cpu_to_le32(s_op.addr2_reg); ++ ++ qcom_write_reg_dma(snandc, &snandc->regs->cmd, NAND_FLASH_CMD, 3, NAND_BAM_NEXT_SGL); ++ qcom_write_reg_dma(snandc, &snandc->regs->exec, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) ++ dev_err(snandc->dev, "failure in submitting cmd descriptor\n"); ++ ++ return ret; ++} ++ ++static int qcom_spi_io_op(struct qcom_nand_controller *snandc, const struct spi_mem_op *op) ++{ ++ int ret, val, opcode; ++ bool copy = false, copy_ftr = false; ++ ++ ret = qcom_spi_send_cmdaddr(snandc, op); ++ if (ret) ++ return ret; ++ ++ snandc->buf_count = 0; ++ snandc->buf_start = 0; ++ qcom_clear_read_regs(snandc); ++ qcom_clear_bam_transaction(snandc); ++ opcode = op->cmd.opcode; ++ ++ switch (opcode) { ++ case SPINAND_READID: ++ snandc->buf_count = 4; ++ qcom_read_reg_dma(snandc, NAND_READ_ID, 1, NAND_BAM_NEXT_SGL); ++ copy = true; ++ break; ++ case SPINAND_GET_FEATURE: ++ snandc->buf_count = 4; ++ qcom_read_reg_dma(snandc, NAND_FLASH_FEATURES, 1, NAND_BAM_NEXT_SGL); ++ copy_ftr = true; ++ break; ++ case SPINAND_SET_FEATURE: ++ snandc->regs->flash_feature = cpu_to_le32(*(u32 *)op->data.buf.out); ++ qcom_write_reg_dma(snandc, &snandc->regs->flash_feature, ++ NAND_FLASH_FEATURES, 1, NAND_BAM_NEXT_SGL); ++ break; ++ case SPINAND_PROGRAM_EXECUTE: ++ case SPINAND_WRITE_EN: ++ case SPINAND_RESET: ++ case SPINAND_ERASE: ++ case SPINAND_READ: ++ return 0; ++ default: ++ return -EOPNOTSUPP; ++ } ++ ++ ret = qcom_submit_descs(snandc); ++ if (ret) ++ dev_err(snandc->dev, "failure in submitting descriptor for:%d\n", opcode); ++ ++ if (copy) { ++ qcom_nandc_dev_to_mem(snandc, true); ++ memcpy(op->data.buf.in, snandc->reg_read_buf, snandc->buf_count); ++ } ++ ++ if (copy_ftr) { ++ qcom_nandc_dev_to_mem(snandc, true); ++ val = le32_to_cpu(*(__le32 *)snandc->reg_read_buf); ++ val >>= 8; ++ memcpy(op->data.buf.in, &val, snandc->buf_count); ++ } ++ ++ return ret; ++} ++ ++static bool qcom_spi_is_page_op(const struct spi_mem_op *op) ++{ ++ if (op->addr.buswidth != 1 && op->addr.buswidth != 2 && op->addr.buswidth != 4) ++ return false; ++ ++ if (op->data.dir == SPI_MEM_DATA_IN) { ++ if (op->addr.buswidth == 4 && op->data.buswidth == 4) ++ return true; ++ ++ if (op->addr.nbytes == 2 && op->addr.buswidth == 1) ++ return true; ++ ++ } else if (op->data.dir == SPI_MEM_DATA_OUT) { ++ if (op->data.buswidth == 4) ++ return true; ++ if (op->addr.nbytes == 2 && op->addr.buswidth == 1) ++ return true; ++ } ++ ++ return false; ++} ++ ++static bool qcom_spi_supports_op(struct spi_mem *mem, const struct spi_mem_op *op) ++{ ++ if (!spi_mem_default_supports_op(mem, op)) ++ return false; ++ ++ if (op->cmd.nbytes != 1 || op->cmd.buswidth != 1) ++ return false; ++ ++ if (qcom_spi_is_page_op(op)) ++ return true; ++ ++ return ((!op->addr.nbytes || op->addr.buswidth == 1) && ++ (!op->dummy.nbytes || op->dummy.buswidth == 1) && ++ (!op->data.nbytes || op->data.buswidth == 1)); ++} ++ ++static int qcom_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) ++{ ++ struct qcom_nand_controller *snandc = spi_controller_get_devdata(mem->spi->controller); ++ ++ dev_dbg(snandc->dev, "OP %02x ADDR %08llX@%d:%u DATA %d:%u", op->cmd.opcode, ++ op->addr.val, op->addr.buswidth, op->addr.nbytes, ++ op->data.buswidth, op->data.nbytes); ++ ++ if (qcom_spi_is_page_op(op)) { ++ if (op->data.dir == SPI_MEM_DATA_IN) ++ return qcom_spi_read_page(snandc, op); ++ if (op->data.dir == SPI_MEM_DATA_OUT) ++ return qcom_spi_write_page(snandc, op); ++ } else { ++ return qcom_spi_io_op(snandc, op); ++ } ++ ++ return 0; ++} ++ ++static const struct spi_controller_mem_ops qcom_spi_mem_ops = { ++ .supports_op = qcom_spi_supports_op, ++ .exec_op = qcom_spi_exec_op, ++}; ++ ++static const struct spi_controller_mem_caps qcom_spi_mem_caps = { ++ .ecc = true, ++}; ++ ++static int qcom_spi_probe(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct spi_controller *ctlr; ++ struct qcom_nand_controller *snandc; ++ struct qpic_spi_nand *qspi; ++ struct qpic_ecc *ecc; ++ struct resource *res; ++ const void *dev_data; ++ int ret; ++ ++ ecc = devm_kzalloc(dev, sizeof(*ecc), GFP_KERNEL); ++ if (!ecc) ++ return -ENOMEM; ++ ++ qspi = devm_kzalloc(dev, sizeof(*qspi), GFP_KERNEL); ++ if (!qspi) ++ return -ENOMEM; ++ ++ ctlr = __devm_spi_alloc_controller(dev, sizeof(*snandc), false); ++ if (!ctlr) ++ return -ENOMEM; ++ ++ platform_set_drvdata(pdev, ctlr); ++ ++ snandc = spi_controller_get_devdata(ctlr); ++ qspi->snandc = snandc; ++ ++ snandc->dev = dev; ++ snandc->qspi = qspi; ++ snandc->qspi->ctlr = ctlr; ++ snandc->qspi->ecc = ecc; ++ ++ dev_data = of_device_get_match_data(dev); ++ if (!dev_data) { ++ dev_err(&pdev->dev, "failed to get device data\n"); ++ return -ENODEV; ++ } ++ ++ snandc->props = dev_data; ++ snandc->dev = &pdev->dev; ++ ++ snandc->core_clk = devm_clk_get(dev, "core"); ++ if (IS_ERR(snandc->core_clk)) ++ return PTR_ERR(snandc->core_clk); ++ ++ snandc->aon_clk = devm_clk_get(dev, "aon"); ++ if (IS_ERR(snandc->aon_clk)) ++ return PTR_ERR(snandc->aon_clk); ++ ++ snandc->qspi->iomacro_clk = devm_clk_get(dev, "iom"); ++ if (IS_ERR(snandc->qspi->iomacro_clk)) ++ return PTR_ERR(snandc->qspi->iomacro_clk); ++ ++ snandc->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); ++ if (IS_ERR(snandc->base)) ++ return PTR_ERR(snandc->base); ++ ++ snandc->base_phys = res->start; ++ snandc->base_dma = dma_map_resource(dev, res->start, resource_size(res), ++ DMA_BIDIRECTIONAL, 0); ++ if (dma_mapping_error(dev, snandc->base_dma)) ++ return -ENXIO; ++ ++ ret = clk_prepare_enable(snandc->core_clk); ++ if (ret) ++ goto err_dis_core_clk; ++ ++ ret = clk_prepare_enable(snandc->aon_clk); ++ if (ret) ++ goto err_dis_aon_clk; ++ ++ ret = clk_prepare_enable(snandc->qspi->iomacro_clk); ++ if (ret) ++ goto err_dis_iom_clk; ++ ++ ret = qcom_nandc_alloc(snandc); ++ if (ret) ++ goto err_snand_alloc; ++ ++ ret = qcom_spi_init(snandc); ++ if (ret) ++ goto err_spi_init; ++ ++ /* setup ECC engine */ ++ snandc->qspi->ecc_eng.dev = &pdev->dev; ++ snandc->qspi->ecc_eng.integration = NAND_ECC_ENGINE_INTEGRATION_PIPELINED; ++ snandc->qspi->ecc_eng.ops = &qcom_spi_ecc_engine_ops_pipelined; ++ snandc->qspi->ecc_eng.priv = snandc; ++ ++ ret = nand_ecc_register_on_host_hw_engine(&snandc->qspi->ecc_eng); ++ if (ret) { ++ dev_err(&pdev->dev, "failed to register ecc engine:%d\n", ret); ++ goto err_spi_init; ++ } ++ ++ ctlr->num_chipselect = QPIC_QSPI_NUM_CS; ++ ctlr->mem_ops = &qcom_spi_mem_ops; ++ ctlr->mem_caps = &qcom_spi_mem_caps; ++ ctlr->dev.of_node = pdev->dev.of_node; ++ ctlr->mode_bits = SPI_TX_DUAL | SPI_RX_DUAL | ++ SPI_TX_QUAD | SPI_RX_QUAD; ++ ++ ret = spi_register_controller(ctlr); ++ if (ret) { ++ dev_err(&pdev->dev, "spi_register_controller failed.\n"); ++ goto err_spi_init; ++ } ++ ++ return 0; ++ ++err_spi_init: ++ qcom_nandc_unalloc(snandc); ++err_snand_alloc: ++ clk_disable_unprepare(snandc->qspi->iomacro_clk); ++err_dis_iom_clk: ++ clk_disable_unprepare(snandc->aon_clk); ++err_dis_aon_clk: ++ clk_disable_unprepare(snandc->core_clk); ++err_dis_core_clk: ++ dma_unmap_resource(dev, res->start, resource_size(res), ++ DMA_BIDIRECTIONAL, 0); ++ return ret; ++} ++ ++static void qcom_spi_remove(struct platform_device *pdev) ++{ ++ struct spi_controller *ctlr = platform_get_drvdata(pdev); ++ struct qcom_nand_controller *snandc = spi_controller_get_devdata(ctlr); ++ struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ ++ spi_unregister_controller(ctlr); ++ ++ qcom_nandc_unalloc(snandc); ++ ++ clk_disable_unprepare(snandc->aon_clk); ++ clk_disable_unprepare(snandc->core_clk); ++ clk_disable_unprepare(snandc->qspi->iomacro_clk); ++ ++ dma_unmap_resource(&pdev->dev, snandc->base_dma, resource_size(res), ++ DMA_BIDIRECTIONAL, 0); ++} ++ ++static const struct qcom_nandc_props ipq9574_snandc_props = { ++ .dev_cmd_reg_start = 0x7000, ++ .supports_bam = true, ++}; ++ ++static const struct of_device_id qcom_snandc_of_match[] = { ++ { ++ .compatible = "qcom,ipq9574-snand", ++ .data = &ipq9574_snandc_props, ++ }, ++ {} ++} ++MODULE_DEVICE_TABLE(of, qcom_snandc_of_match); ++ ++static struct platform_driver qcom_spi_driver = { ++ .driver = { ++ .name = "qcom_snand", ++ .of_match_table = qcom_snandc_of_match, ++ }, ++ .probe = qcom_spi_probe, ++ .remove_new = qcom_spi_remove, ++}; ++module_platform_driver(qcom_spi_driver); ++ ++MODULE_DESCRIPTION("SPI driver for QPIC QSPI cores"); ++MODULE_AUTHOR("Md Sadre Alam "); ++MODULE_LICENSE("GPL"); ++ +--- a/include/linux/mtd/nand-qpic-common.h ++++ b/include/linux/mtd/nand-qpic-common.h +@@ -325,6 +325,10 @@ struct nandc_regs { + __le32 read_location_last1; + __le32 read_location_last2; + __le32 read_location_last3; ++ __le32 spi_cfg; ++ __le32 num_addr_cycle; ++ __le32 busy_wait_cnt; ++ __le32 flash_feature; + + __le32 erased_cw_detect_cfg_clr; + __le32 erased_cw_detect_cfg_set; +@@ -339,6 +343,7 @@ struct nandc_regs { + * + * @core_clk: controller clock + * @aon_clk: another controller clock ++ * @iomacro_clk: io macro clock + * + * @regs: a contiguous chunk of memory for DMA register + * writes. contains the register values to be +@@ -348,6 +353,7 @@ struct nandc_regs { + * initialized via DT match data + * + * @controller: base controller structure ++ * @qspi: qpic spi structure + * @host_list: list containing all the chips attached to the + * controller + * +@@ -392,6 +398,7 @@ struct qcom_nand_controller { + const struct qcom_nandc_props *props; + + struct nand_controller *controller; ++ struct qpic_spi_nand *qspi; + struct list_head host_list; + + union { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-08-v6.15-spi-spi-qpic-snand-Fix-ECC_CFG_ECC_DISABLE-shift-in-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-08-v6.15-spi-spi-qpic-snand-Fix-ECC_CFG_ECC_DISABLE-shift-in-.patch new file mode 100755 index 0000000..ad43f8d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-08-v6.15-spi-spi-qpic-snand-Fix-ECC_CFG_ECC_DISABLE-shift-in-.patch @@ -0,0 +1,28 @@ +From cf1ba3cb245020459f2ca446b7a7b199839f5d83 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Thu, 6 Mar 2025 12:40:01 +0300 +Subject: [PATCH] spi: spi-qpic-snand: Fix ECC_CFG_ECC_DISABLE shift in + qcom_spi_read_last_cw() + +The ECC_CFG_ECC_DISABLE define is BIT(0). It's supposed to be used +directly instead of used as a shifter. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Dan Carpenter +Link: https://patch.msgid.link/2f4b0a0b-2c03-41c0-8a4a-3d789a83832d@stanley.mountain +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -514,7 +514,7 @@ static int qcom_spi_read_last_cw(struct + cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | + 0 << CW_PER_PAGE; + cfg1 = ecc_cfg->cfg1_raw; +- ecc_bch_cfg = 1 << ECC_CFG_ECC_DISABLE; ++ ecc_bch_cfg = ECC_CFG_ECC_DISABLE; + + snandc->regs->cmd = snandc->qspi->cmd; + snandc->regs->cfg0 = cpu_to_le32(cfg0); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-09-v6.15-spi-spi-qpic-snand-avoid-memleak-in-qcom_spi_ecc_ini.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-09-v6.15-spi-spi-qpic-snand-avoid-memleak-in-qcom_spi_ecc_ini.patch new file mode 100755 index 0000000..1e2a3b0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-09-v6.15-spi-spi-qpic-snand-avoid-memleak-in-qcom_spi_ecc_ini.patch @@ -0,0 +1,35 @@ +From d450cdd9c4398add1f2aa7200f2c95f1e3b9f9fa Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 13 Mar 2025 19:31:21 +0100 +Subject: [PATCH] spi: spi-qpic-snand: avoid memleak in + qcom_spi_ecc_init_ctx_pipelined() + +When the allocation of the OOB buffer fails, the +qcom_spi_ecc_init_ctx_pipelined() function returns without freeing +the memory allocated for 'ecc_cfg' thus it can cause a memory leak. + +Call kfree() to free 'ecc_cfg' before returning from the function +to avoid that. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250313-qpic-snand-memleak-fix-v1-1-e54e78d1da3a@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -263,8 +263,10 @@ static int qcom_spi_ecc_init_ctx_pipelin + return -ENOMEM; + snandc->qspi->oob_buf = kzalloc(mtd->writesize + mtd->oobsize, + GFP_KERNEL); +- if (!snandc->qspi->oob_buf) ++ if (!snandc->qspi->oob_buf) { ++ kfree(ecc_cfg); + return -ENOMEM; ++ } + + memset(snandc->qspi->oob_buf, 0xff, mtd->writesize + mtd->oobsize); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-10-v6.15-spi-SPI_QPIC_SNAND-should-be-tristate-and-depend-on-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-10-v6.15-spi-SPI_QPIC_SNAND-should-be-tristate-and-depend-on-.patch new file mode 100755 index 0000000..5e92048 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-10-v6.15-spi-SPI_QPIC_SNAND-should-be-tristate-and-depend-on-.patch @@ -0,0 +1,49 @@ +From d32c4e58545f17caaa854415f854691e32d42075 Mon Sep 17 00:00:00 2001 +From: Geert Uytterhoeven +Date: Wed, 26 Mar 2025 15:22:19 +0100 +Subject: [PATCH] spi: SPI_QPIC_SNAND should be tristate and depend on MTD + +SPI_QPIC_SNAND is the only driver that selects MTD instead of depending +on it, which could lead to circular dependencies. Moreover, as +SPI_QPIC_SNAND is bool, this forces MTD (and various related symbols) to +be built-in, as can be seen in an allmodconfig kernel. + +Except for a missing semicolon, there is no reason why SPI_QPIC_SNAND +cannot be tristate; all MODULE_*() boilerplate is already present. +Hence make SPI_QPIC_SNAND tristate, let it depend on MTD, and add the +missing semicolon. + +Fixes: 7304d1909080ef0c ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Geert Uytterhoeven +Link: https://patch.msgid.link/b63db431cbf35223a4400e44c296293d32c4543c.1742998909.git.geert+renesas@glider.be +Signed-off-by: Mark Brown +--- + drivers/spi/Kconfig | 4 ++-- + drivers/spi/spi-qpic-snand.c | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/spi/Kconfig ++++ b/drivers/spi/Kconfig +@@ -899,9 +899,9 @@ config SPI_QCOM_QSPI + QSPI(Quad SPI) driver for Qualcomm QSPI controller. + + config SPI_QPIC_SNAND +- bool "QPIC SNAND controller" ++ tristate "QPIC SNAND controller" + depends on ARCH_QCOM || COMPILE_TEST +- select MTD ++ depends on MTD + help + QPIC_SNAND (QPIC SPI NAND) driver for Qualcomm QPIC controller. + QPIC controller supports both parallel nand and serial nand. +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -1614,7 +1614,7 @@ static const struct of_device_id qcom_sn + .data = &ipq9574_snandc_props, + }, + {} +-} ++}; + MODULE_DEVICE_TABLE(of, qcom_snandc_of_match); + + static struct platform_driver qcom_spi_driver = { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-11-v6.15-spi-spi-qpic-snand-propagate-errors-from-qcom_spi_block_erase.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-11-v6.15-spi-spi-qpic-snand-propagate-errors-from-qcom_spi_block_erase.patch new file mode 100755 index 0000000..9da531b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-11-v6.15-spi-spi-qpic-snand-propagate-errors-from-qcom_spi_block_erase.patch @@ -0,0 +1,36 @@ +From: Gabor Juhos +Date: Wed, 23 Apr 2025 21:31:57 +0200 +Subject: [PATCH] spi: spi-qpic-snand: propagate errors from + qcom_spi_block_erase() + +The qcom_spi_block_erase() function returns with error in case of +failure. Change the qcom_spi_send_cmdaddr() function to propagate +these errors to the callers instead of returning with success. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Reviewed-by: Abel Vesa +Reviewed-by: Md Sadre Alam +--- + drivers/spi/spi-qpic-snand.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + + +--- +base-commit: 9c32cda43eb78f78c73aee4aa344b777714e259b +change-id: 20250422-qpic-snand-propagate-error-9c95811ab811 + +Best regards, + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -1307,8 +1307,7 @@ static int qcom_spi_send_cmdaddr(struct + snandc->qspi->addr1 = cpu_to_le32(s_op.addr1_reg << 16); + snandc->qspi->addr2 = cpu_to_le32(s_op.addr2_reg); + snandc->qspi->cmd = cpu_to_le32(cmd); +- qcom_spi_block_erase(snandc); +- return 0; ++ return qcom_spi_block_erase(snandc); + default: + break; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-12-v6.15-spi-spi-qpic-snand-fix-NAND_READ_LOCATION_2-register-handling.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-12-v6.15-spi-spi-qpic-snand-fix-NAND_READ_LOCATION_2-register-handling.patch new file mode 100755 index 0000000..a2cd636 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-12-v6.15-spi-spi-qpic-snand-fix-NAND_READ_LOCATION_2-register-handling.patch @@ -0,0 +1,35 @@ +From: Gabor Juhos +Date: Mon, 28 Apr 2025 09:30:55 +0200 +Subject: [PATCH] spi: spi-qpic-snand: fix NAND_READ_LOCATION_2 register + handling + +The precomputed value for the NAND_READ_LOCATION_2 register should be +stored in 'snandc->regs->read_location2'. + +Fix the qcom_spi_set_read_loc_first() function accordingly. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Reviewed-by: Md Sadre Alam +--- + drivers/spi/spi-qpic-snand.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + +--- +base-commit: 15cfe55ec58ace931a73e19e5367598734ceb074 +change-id: 20250428-qpic-snand-readloc2-fix-bccd07cf26d3 + +Best regards, + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -142,7 +142,7 @@ static void qcom_spi_set_read_loc_first( + else if (reg == NAND_READ_LOCATION_1) + snandc->regs->read_location1 = locreg_val; + else if (reg == NAND_READ_LOCATION_2) +- snandc->regs->read_location1 = locreg_val; ++ snandc->regs->read_location2 = locreg_val; + else if (reg == NAND_READ_LOCATION_3) + snandc->regs->read_location3 = locreg_val; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-13-v6.15-spi-spi-qpic-snand-use-kmalloc-for-OOB-buffer-alloca.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-13-v6.15-spi-spi-qpic-snand-use-kmalloc-for-OOB-buffer-alloca.patch new file mode 100755 index 0000000..5a3d498 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-13-v6.15-spi-spi-qpic-snand-use-kmalloc-for-OOB-buffer-alloca.patch @@ -0,0 +1,29 @@ +From f48d80503504257682e493dc17408f2f0b47bcfa Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 20 Mar 2025 19:11:59 +0100 +Subject: [PATCH] spi: spi-qpic-snand: use kmalloc() for OOB buffer allocation + +The qcom_spi_ecc_init_ctx_pipelined() function allocates zeroed +memory for the OOB buffer, then it fills the buffer with '0xff' +bytes right after the allocation. In this case zeroing the memory +during allocation is superfluous, so use kmalloc() instead of +kzalloc() to avoid that. + +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250320-qpic-snand-kmalloc-v1-1-94e267550675@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -261,7 +261,7 @@ static int qcom_spi_ecc_init_ctx_pipelin + ecc_cfg = kzalloc(sizeof(*ecc_cfg), GFP_KERNEL); + if (!ecc_cfg) + return -ENOMEM; +- snandc->qspi->oob_buf = kzalloc(mtd->writesize + mtd->oobsize, ++ snandc->qspi->oob_buf = kmalloc(mtd->writesize + mtd->oobsize, + GFP_KERNEL); + if (!snandc->qspi->oob_buf) { + kfree(ecc_cfg); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-14-v6.16-spi-spi-qpic-snand-remove-unused-wlen-member-of-struct-qpic_spi_nand.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-14-v6.16-spi-spi-qpic-snand-remove-unused-wlen-member-of-struct-qpic_spi_nand.patch new file mode 100755 index 0000000..55e84da --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/410-14-v6.16-spi-spi-qpic-snand-remove-unused-wlen-member-of-struct-qpic_spi_nand.patch @@ -0,0 +1,30 @@ +From: Gabor Juhos +Date: Thu, 24 Apr 2025 20:10:59 +0200 +Subject: [PATCH] spi: spi-qpic-snand: remove unused 'wlen' member of + 'struct qpic_spi_nand' + +The 'wlen' member of the qpic_spi_nand structure is never used in the +code so remove that. + +Signed-off-by: Gabor Juhos +--- + drivers/spi/spi-qpic-snand.c | 1 - + 1 file changed, 1 deletion(-) + + +--- +base-commit: 9c32cda43eb78f78c73aee4aa344b777714e259b +change-id: 20250424-qpic-snand-remove-wlen-c0cef3801a7f + +Best regards, + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -116,7 +116,6 @@ struct qpic_spi_nand { + struct nand_ecc_engine ecc_eng; + u8 *data_buf; + u8 *oob_buf; +- u32 wlen; + __le32 addr1; + __le32 addr2; + __le32 cmd; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/411-v6.15-mtd-nand-Drop-explicit-test-for-built-in-CONFIG_SPI_.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/411-v6.15-mtd-nand-Drop-explicit-test-for-built-in-CONFIG_SPI_.patch new file mode 100755 index 0000000..8019d2c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/411-v6.15-mtd-nand-Drop-explicit-test-for-built-in-CONFIG_SPI_.patch @@ -0,0 +1,37 @@ +From 36c6468724aa98d33fea9a1d7e07ddda6302f5d4 Mon Sep 17 00:00:00 2001 +From: Geert Uytterhoeven +Date: Fri, 28 Mar 2025 09:24:01 +0100 +Subject: mtd: nand: Drop explicit test for built-in CONFIG_SPI_QPIC_SNAND + +If CONFIG_SPI_QPIC_SNAND=m, but CONFIG_MTD_NAND_QCOM=n: + + ERROR: modpost: "qcom_nandc_unalloc" [drivers/spi/spi-qpic-snand.ko] undefined! + ... + +Fix this by dropping the explicit test for a built-in +CONFIG_SPI_QPIC_SNAND completely. Kbuild handles multiple and mixed +obj-y/obj-m rules for the same object file fine. + +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202503280759.XhwLcV7m-lkp@intel.com/ +Fixes: 7304d1909080ef0c ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Geert Uytterhoeven +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/Makefile | 3 --- + 1 file changed, 3 deletions(-) + +--- a/drivers/mtd/nand/Makefile ++++ b/drivers/mtd/nand/Makefile +@@ -3,11 +3,8 @@ + nandcore-objs := core.o bbt.o + obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o + obj-$(CONFIG_MTD_NAND_ECC_MEDIATEK) += ecc-mtk.o +-ifeq ($(CONFIG_SPI_QPIC_SNAND),y) + obj-$(CONFIG_SPI_QPIC_SNAND) += qpic_common.o +-else + obj-$(CONFIG_MTD_NAND_QCOM) += qpic_common.o +-endif + obj-y += onenand/ + obj-y += raw/ + obj-y += spi/ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/412-v6.16-next-spi-spi-qpic-snand-validate-user-chip-specific-ECC-properties.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/412-v6.16-next-spi-spi-qpic-snand-validate-user-chip-specific-ECC-properties.patch new file mode 100755 index 0000000..2f95156 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/412-v6.16-next-spi-spi-qpic-snand-validate-user-chip-specific-ECC-properties.patch @@ -0,0 +1,166 @@ +From 65cb56d49f6edea409600a3c61effc70ee5d43d8 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 1 May 2025 18:19:16 +0200 +Subject: spi: spi-qpic-snand: validate user/chip specific ECC properties + +The driver only supports 512 bytes ECC step size and 4 bit ECC strength +at the moment, however it does not reject unsupported step/strength +configurations. Due to this, whenever the driver is used with a flash +chip which needs stronger ECC protection, the following warning is shown +in the kernel log: + + [ 0.574648] spi-nand spi0.0: GigaDevice SPI NAND was found. + [ 0.635748] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128 + [ 0.649079] nand: WARNING: (null): the ECC used on your system is too weak compared to the one required by the NAND chip + +Although the message indicates that something is wrong, but it often gets +unnoticed, which can cause serious problems. For example when the user +writes something into the flash chip despite the warning, the written data +may won't be readable by the bootloader or by the boot ROM. In the worst +case, when the attached SPI NAND chip is the boot device, the board may not +be able to boot anymore. + +Also, it is not even possible to create a backup of the flash, because +reading its content results in bogus data. For example, dumping the first +page of the flash gives this: + + # hexdump -C -n 2048 /dev/mtd0 + 00000000 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000040 0f 0f 0f 0f 0f 0f 0f 0d 0f 0f 0f 0f 0f 0f 0f 0f |................| + 00000050 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 000001c0 0f 0f 0f 0f ff 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + 000001d0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000200 0f 0f 0f 0f f5 5b ff ff 0f 0f 0f 0f 0f 0f 0f 0f |.....[..........| + 00000210 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 000002f0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 1f 0f 0f |................| + 00000300 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 000003c0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f ff 0f 0f 0f |................| + 000003d0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000400 0f 0f 0f 0f 0f 0f 0f 0f e9 74 c9 06 f5 5b ff ff |.........t...[..| + 00000410 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 000005d0 0f 0f 0f 0f ff 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + 000005e0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000600 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f c6 be 0f c3 |................| + 00000610 e9 74 c9 06 f5 5b ff ff 0f 0f 0f 0f 0f 0f 0f 0f |.t...[..........| + 00000620 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000770 0f 0f 0f 0f 8f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + 00000780 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000800 + # + +Doing the same by using the downstream kernel results in different output: + + # hexdump -C -n 2048 /dev/mtd0 + 00000000 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f |................| + * + 00000800 + # + +This patch adds some sanity checks to the code to prevent using the driver +with unsupported ECC step/strength configurations. After the change, probing +of the driver fails in such cases: + + [ 0.655038] spi-nand spi0.0: GigaDevice SPI NAND was found. + [ 0.659159] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128 + [ 0.669138] qcom_snand 79b0000.spi: only 4 bits ECC strength is supported + [ 0.677476] nand: No suitable ECC configuration + [ 0.689909] spi-nand spi0.0: probe with driver spi-nand failed with error -95 + +This helps to avoid the aforementioned hassles until support for 8 bit ECC +strength gets implemented. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250501-qpic-snand-validate-ecc-v1-1-532776581a66@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 42 +++++++++++++++++++++++++++++++----- + 1 file changed, 37 insertions(+), 5 deletions(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -249,9 +249,11 @@ static const struct mtd_ooblayout_ops qc + static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand) + { + struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); ++ struct nand_ecc_props *reqs = &nand->ecc.requirements; ++ struct nand_ecc_props *user = &nand->ecc.user_conf; + struct nand_ecc_props *conf = &nand->ecc.ctx.conf; + struct mtd_info *mtd = nanddev_to_mtd(nand); +- int cwperpage, bad_block_byte; ++ int cwperpage, bad_block_byte, ret; + struct qpic_ecc *ecc_cfg; + + cwperpage = mtd->writesize / NANDC_STEP_SIZE; +@@ -260,11 +262,39 @@ static int qcom_spi_ecc_init_ctx_pipelin + ecc_cfg = kzalloc(sizeof(*ecc_cfg), GFP_KERNEL); + if (!ecc_cfg) + return -ENOMEM; ++ ++ if (user->step_size && user->strength) { ++ ecc_cfg->step_size = user->step_size; ++ ecc_cfg->strength = user->strength; ++ } else if (reqs->step_size && reqs->strength) { ++ ecc_cfg->step_size = reqs->step_size; ++ ecc_cfg->strength = reqs->strength; ++ } else { ++ /* use defaults */ ++ ecc_cfg->step_size = NANDC_STEP_SIZE; ++ ecc_cfg->strength = 4; ++ } ++ ++ if (ecc_cfg->step_size != NANDC_STEP_SIZE) { ++ dev_err(snandc->dev, ++ "only %u bytes ECC step size is supported\n", ++ NANDC_STEP_SIZE); ++ ret = -EOPNOTSUPP; ++ goto err_free_ecc_cfg; ++ } ++ ++ if (ecc_cfg->strength != 4) { ++ dev_err(snandc->dev, ++ "only 4 bits ECC strength is supported\n"); ++ ret = -EOPNOTSUPP; ++ goto err_free_ecc_cfg; ++ } ++ + snandc->qspi->oob_buf = kmalloc(mtd->writesize + mtd->oobsize, + GFP_KERNEL); + if (!snandc->qspi->oob_buf) { +- kfree(ecc_cfg); +- return -ENOMEM; ++ ret = -ENOMEM; ++ goto err_free_ecc_cfg; + } + + memset(snandc->qspi->oob_buf, 0xff, mtd->writesize + mtd->oobsize); +@@ -279,8 +309,6 @@ static int qcom_spi_ecc_init_ctx_pipelin + ecc_cfg->bytes = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes + ecc_cfg->bbm_size; + + ecc_cfg->steps = 4; +- ecc_cfg->strength = 4; +- ecc_cfg->step_size = 512; + ecc_cfg->cw_data = 516; + ecc_cfg->cw_size = ecc_cfg->cw_data + ecc_cfg->bytes; + bad_block_byte = mtd->writesize - ecc_cfg->cw_size * (cwperpage - 1) + 1; +@@ -338,6 +366,10 @@ static int qcom_spi_ecc_init_ctx_pipelin + ecc_cfg->strength, ecc_cfg->step_size); + + return 0; ++ ++err_free_ecc_cfg: ++ kfree(ecc_cfg); ++ return ret; + } + + static void qcom_spi_ecc_cleanup_ctx_pipelined(struct nand_device *nand) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/413-v6.16-spi-spi-qpic-snand-use-CW_PER_PAGE_MASK-bitmask.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/413-v6.16-spi-spi-qpic-snand-use-CW_PER_PAGE_MASK-bitmask.patch new file mode 100755 index 0000000..10c1651 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/413-v6.16-spi-spi-qpic-snand-use-CW_PER_PAGE_MASK-bitmask.patch @@ -0,0 +1,113 @@ +From 2abf107dcd797c60c86e9f17319cd1658862f6b2 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Thu, 15 May 2025 20:58:05 +0200 +Subject: spi: spi-qpic-snand: use CW_PER_PAGE_MASK bitmask + +Change the code to use the already defined CW_PER_PAGE_MASK +bitmask along with the FIELD_PREP() macro instead of using +magic values. + +This makes the code more readable. It also syncs the affected +codes with their counterparts in the 'qcom_nandc' driver, so it +makes it easier to spot the differences between the two +implementations. + +No functional changes intended. + +Signed-off-by: Gabor Juhos +Reviewed-by: Md Sadre Alam +Link: https://patch.msgid.link/20250515-qpic-snand-use-bitmasks-v1-1-11729aeae73b@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 31 ++++++++++++++++--------------- + 1 file changed, 16 insertions(+), 15 deletions(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -483,7 +483,8 @@ static int qcom_spi_block_erase(struct q + snandc->regs->cmd = snandc->qspi->cmd; + snandc->regs->addr0 = snandc->qspi->addr1; + snandc->regs->addr1 = snandc->qspi->addr2; +- snandc->regs->cfg0 = cpu_to_le32(ecc_cfg->cfg0_raw & ~(7 << CW_PER_PAGE)); ++ snandc->regs->cfg0 = cpu_to_le32((ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, 0)); + snandc->regs->cfg1 = cpu_to_le32(ecc_cfg->cfg1_raw); + snandc->regs->exec = cpu_to_le32(1); + +@@ -544,8 +545,8 @@ static int qcom_spi_read_last_cw(struct + snandc->regs->addr0 = (snandc->qspi->addr1 | cpu_to_le32(col)); + snandc->regs->addr1 = snandc->qspi->addr2; + +- cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | +- 0 << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, 0); + cfg1 = ecc_cfg->cfg1_raw; + ecc_bch_cfg = ECC_CFG_ECC_DISABLE; + +@@ -687,8 +688,8 @@ static int qcom_spi_read_cw_raw(struct q + qcom_clear_bam_transaction(snandc); + raw_cw = num_cw - 1; + +- cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | +- 0 << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, 0); + cfg1 = ecc_cfg->cfg1_raw; + ecc_bch_cfg = ECC_CFG_ECC_DISABLE; + +@@ -808,8 +809,8 @@ static int qcom_spi_read_page_ecc(struct + snandc->buf_start = 0; + qcom_clear_read_regs(snandc); + +- cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); + cfg1 = ecc_cfg->cfg1; + ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; + +@@ -904,8 +905,8 @@ static int qcom_spi_read_page_oob(struct + qcom_clear_read_regs(snandc); + qcom_clear_bam_transaction(snandc); + +- cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); + cfg1 = ecc_cfg->cfg1; + ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; + +@@ -1015,8 +1016,8 @@ static int qcom_spi_program_raw(struct q + int num_cw = snandc->qspi->num_cw; + u32 cfg0, cfg1, ecc_bch_cfg; + +- cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); + cfg1 = ecc_cfg->cfg1_raw; + ecc_bch_cfg = ECC_CFG_ECC_DISABLE; + +@@ -1098,8 +1099,8 @@ static int qcom_spi_program_ecc(struct q + int num_cw = snandc->qspi->num_cw; + u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg; + +- cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); + cfg1 = ecc_cfg->cfg1; + ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; + ecc_buf_cfg = ecc_cfg->ecc_buf_cfg; +@@ -1175,8 +1176,8 @@ static int qcom_spi_program_oob(struct q + int num_cw = snandc->qspi->num_cw; + u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg; + +- cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) | +- (num_cw - 1) << CW_PER_PAGE; ++ cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) | ++ FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); + cfg1 = ecc_cfg->cfg1; + ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; + ecc_buf_cfg = ecc_cfg->ecc_buf_cfg; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/414-v6.16-spi-spi-qpic-snand-reallocate-BAM-transactions.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/414-v6.16-spi-spi-qpic-snand-reallocate-BAM-transactions.patch new file mode 100755 index 0000000..6d61016 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/414-v6.16-spi-spi-qpic-snand-reallocate-BAM-transactions.patch @@ -0,0 +1,81 @@ +From d85d0380292a7e618915069c3579ae23c7c80339 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 18 Jun 2025 22:22:49 +0200 +Subject: spi: spi-qpic-snand: reallocate BAM transactions + +Using the mtd_nandbiterrs module for testing the driver occasionally +results in weird things like below. + +1. swiotlb mapping fails with the following message: + + [ 85.926216] qcom_snand 79b0000.spi: swiotlb buffer is full (sz: 4294967294 bytes), total 512 (slots), used 0 (slots) + [ 85.932937] qcom_snand 79b0000.spi: failure in mapping desc + [ 87.999314] qcom_snand 79b0000.spi: failure to write raw page + [ 87.999352] mtd_nandbiterrs: error: write_oob failed (-110) + + Rebooting the board after this causes a panic due to a NULL pointer + dereference. + +2. If the swiotlb mapping does not fail, rebooting the board may result + in a different panic due to a bad spinlock magic: + + [ 256.104459] BUG: spinlock bad magic on CPU#3, procd/2241 + [ 256.104488] Unable to handle kernel paging request at virtual address ffffffff0000049b + ... + +Investigating the issue revealed that these symptoms are results of +memory corruption which is caused by out of bounds access within the +driver. + +The driver uses a dynamically allocated structure for BAM transactions, +which structure must have enough space for all possible variations of +different flash operations initiated by the driver. The required space +heavily depends on the actual number of 'codewords' which is calculated +from the pagesize of the actual NAND chip. + +Although the qcom_nandc_alloc() function allocates memory for the BAM +transactions during probe, but since the actual number of 'codewords' +is not yet know the allocation is done for one 'codeword' only. + +Because of this, whenever the driver does a flash operation, and the +number of the required transactions exceeds the size of the allocated +arrays the driver accesses memory out of the allocated range. + +To avoid this, change the code to free the initially allocated BAM +transactions memory, and allocate a new one once the actual number of +'codewords' required for a given NAND chip is known. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Reviewed-by: Md Sadre Alam +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250618-qpic-snand-avoid-mem-corruption-v3-1-319c71296cda@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -315,6 +315,22 @@ static int qcom_spi_ecc_init_ctx_pipelin + + mtd_set_ooblayout(mtd, &qcom_spi_ooblayout); + ++ /* ++ * Free the temporary BAM transaction allocated initially by ++ * qcom_nandc_alloc(), and allocate a new one based on the ++ * updated max_cwperpage value. ++ */ ++ qcom_free_bam_transaction(snandc); ++ ++ snandc->max_cwperpage = cwperpage; ++ ++ snandc->bam_txn = qcom_alloc_bam_transaction(snandc); ++ if (!snandc->bam_txn) { ++ dev_err(snandc->dev, "failed to allocate BAM transaction\n"); ++ ret = -ENOMEM; ++ goto err_free_ecc_cfg; ++ } ++ + ecc_cfg->cfg0 = FIELD_PREP(CW_PER_PAGE_MASK, (cwperpage - 1)) | + FIELD_PREP(UD_SIZE_BYTES_MASK, ecc_cfg->cw_data) | + FIELD_PREP(DISABLE_STATUS_AFTER_WRITE, 1) | diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/415-v6.16-spi-spi-qpic-snand-don-t-hardcode-ECC-steps.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/415-v6.16-spi-spi-qpic-snand-don-t-hardcode-ECC-steps.patch new file mode 100755 index 0000000..eab7b79 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/415-v6.16-spi-spi-qpic-snand-don-t-hardcode-ECC-steps.patch @@ -0,0 +1,31 @@ +From f820034864dd463cdcd2bebe7940f2eca0eb4223 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 23 Jul 2025 10:06:43 +0200 +Subject: spi: spi-qpic-snand: don't hardcode ECC steps + +NAND devices with different page sizes requires different number +of ECC steps, yet the qcom_spi_ecc_init_ctx_pipelined() function +sets 4 steps in 'ecc_cfg' unconditionally. + +The correct number of the steps is calculated earlier in the +function already, so use that instead of the hardcoded value. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250723-qpic-snand-fix-steps-v1-1-d800695dde4c@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -308,7 +308,7 @@ static int qcom_spi_ecc_init_ctx_pipelin + ecc_cfg->bch_enabled = true; + ecc_cfg->bytes = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes + ecc_cfg->bbm_size; + +- ecc_cfg->steps = 4; ++ ecc_cfg->steps = cwperpage; + ecc_cfg->cw_data = 516; + ecc_cfg->cw_size = ecc_cfg->cw_data + ecc_cfg->bytes; + bad_block_byte = mtd->writesize - ecc_cfg->cw_size * (cwperpage - 1) + 1; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/416-v6.17-mtd-nand-qpic-common-add-defines-for-ECC_MODE-values.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/416-v6.17-mtd-nand-qpic-common-add-defines-for-ECC_MODE-values.patch new file mode 100755 index 0000000..7ddf15e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/416-v6.17-mtd-nand-qpic-common-add-defines-for-ECC_MODE-values.patch @@ -0,0 +1,74 @@ +From 0dc7e656ddd54c3267b7cc18c1ac8ec1297ed02f Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 2 Jul 2025 14:35:23 +0200 +Subject: mtd: nand: qpic-common: add defines for ECC_MODE values + +Add defines for the values of the ECC_MODE field of the NAND_DEV0_ECC_CFG +register and change both the 'qcom-nandc' and 'spi-qpic-snand' drivers to +use those instead of magic numbers. + +No functional changes. This is in preparation for adding 8 bit ECC strength +support for the 'spi-qpic-snand' driver. + +Reviewed-by: Md Sadre Alam +Signed-off-by: Gabor Juhos +Acked-by: Miquel Raynal +Link: https://patch.msgid.link/20250702-qpic-snand-8bit-ecc-v2-1-ae2c17a30bb7@gmail.com +Signed-off-by: Mark Brown +--- + drivers/mtd/nand/raw/qcom_nandc.c | 6 +++--- + drivers/spi/spi-qpic-snand.c | 2 +- + include/linux/mtd/nand-qpic-common.h | 2 ++ + 3 files changed, 6 insertions(+), 4 deletions(-) + +--- a/drivers/mtd/nand/raw/qcom_nandc.c ++++ b/drivers/mtd/nand/raw/qcom_nandc.c +@@ -1379,7 +1379,7 @@ static int qcom_nand_attach_chip(struct + struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); + int cwperpage, bad_block_byte, ret; + bool wide_bus; +- int ecc_mode = 1; ++ int ecc_mode = ECC_MODE_8BIT; + + /* controller only supports 512 bytes data steps */ + ecc->size = NANDC_STEP_SIZE; +@@ -1400,7 +1400,7 @@ static int qcom_nand_attach_chip(struct + if (ecc->strength >= 8) { + /* 8 bit ECC defaults to BCH ECC on all platforms */ + host->bch_enabled = true; +- ecc_mode = 1; ++ ecc_mode = ECC_MODE_8BIT; + + if (wide_bus) { + host->ecc_bytes_hw = 14; +@@ -1420,7 +1420,7 @@ static int qcom_nand_attach_chip(struct + if (nandc->props->ecc_modes & ECC_BCH_4BIT) { + /* BCH */ + host->bch_enabled = true; +- ecc_mode = 0; ++ ecc_mode = ECC_MODE_4BIT; + + if (wide_bus) { + host->ecc_bytes_hw = 8; +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -365,7 +365,7 @@ static int qcom_spi_ecc_init_ctx_pipelin + FIELD_PREP(ECC_SW_RESET, 0) | + FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, ecc_cfg->cw_data) | + FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) | +- FIELD_PREP(ECC_MODE_MASK, 0) | ++ FIELD_PREP(ECC_MODE_MASK, ECC_MODE_4BIT) | + FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw); + + ecc_cfg->ecc_buf_cfg = 0x203 << NUM_STEPS; +--- a/include/linux/mtd/nand-qpic-common.h ++++ b/include/linux/mtd/nand-qpic-common.h +@@ -101,6 +101,8 @@ + #define ECC_SW_RESET BIT(1) + #define ECC_MODE 4 + #define ECC_MODE_MASK GENMASK(5, 4) ++#define ECC_MODE_4BIT 0 ++#define ECC_MODE_8BIT 1 + #define ECC_PARITY_SIZE_BYTES_BCH 8 + #define ECC_PARITY_SIZE_BYTES_BCH_MASK GENMASK(12, 8) + #define ECC_NUM_DATA_BYTES 16 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/417-v6.17-spi-spi-qpic-snand-add-support-for-8-bits-ECC-strength.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/417-v6.17-spi-spi-qpic-snand-add-support-for-8-bits-ECC-strength.patch new file mode 100755 index 0000000..4eff84f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/417-v6.17-spi-spi-qpic-snand-add-support-for-8-bits-ECC-strength.patch @@ -0,0 +1,66 @@ +From 913bf8d50cbd144c87e9660b591781179182ff59 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 2 Jul 2025 14:35:24 +0200 +Subject: spi: spi-qpic-snand: add support for 8 bits ECC strength + +Even though the hardware supports 8 bits ECC strength, but that is not +handled in the driver yet. This change adds the missing bits in order +to allow using the driver with chips which require 8 bits ECC strength. + +No functional changes intended with regard to the existing 4 bits ECC +strength support. + +Tested on an IPQ9574 platform using a GigaDevice GD5F2GM7REYIG chip. + +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250702-qpic-snand-8bit-ecc-v2-2-ae2c17a30bb7@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 21 ++++++++++++++++----- + 1 file changed, 16 insertions(+), 5 deletions(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -283,9 +283,22 @@ static int qcom_spi_ecc_init_ctx_pipelin + goto err_free_ecc_cfg; + } + +- if (ecc_cfg->strength != 4) { ++ switch (ecc_cfg->strength) { ++ case 4: ++ ecc_cfg->ecc_mode = ECC_MODE_4BIT; ++ ecc_cfg->ecc_bytes_hw = 7; ++ ecc_cfg->spare_bytes = 4; ++ break; ++ ++ case 8: ++ ecc_cfg->ecc_mode = ECC_MODE_8BIT; ++ ecc_cfg->ecc_bytes_hw = 13; ++ ecc_cfg->spare_bytes = 2; ++ break; ++ ++ default: + dev_err(snandc->dev, +- "only 4 bits ECC strength is supported\n"); ++ "only 4 or 8 bits ECC strength is supported\n"); + ret = -EOPNOTSUPP; + goto err_free_ecc_cfg; + } +@@ -302,8 +315,6 @@ static int qcom_spi_ecc_init_ctx_pipelin + nand->ecc.ctx.priv = ecc_cfg; + snandc->qspi->mtd = mtd; + +- ecc_cfg->ecc_bytes_hw = 7; +- ecc_cfg->spare_bytes = 4; + ecc_cfg->bbm_size = 1; + ecc_cfg->bch_enabled = true; + ecc_cfg->bytes = ecc_cfg->ecc_bytes_hw + ecc_cfg->spare_bytes + ecc_cfg->bbm_size; +@@ -365,7 +376,7 @@ static int qcom_spi_ecc_init_ctx_pipelin + FIELD_PREP(ECC_SW_RESET, 0) | + FIELD_PREP(ECC_NUM_DATA_BYTES_MASK, ecc_cfg->cw_data) | + FIELD_PREP(ECC_FORCE_CLK_OPEN, 1) | +- FIELD_PREP(ECC_MODE_MASK, ECC_MODE_4BIT) | ++ FIELD_PREP(ECC_MODE_MASK, ecc_cfg->ecc_mode) | + FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw); + + ecc_cfg->ecc_buf_cfg = 0x203 << NUM_STEPS; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/418-v6.17-spi-spi-qpic-snand-use-correct-CW_PER_PAGE-value-for.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/418-v6.17-spi-spi-qpic-snand-use-correct-CW_PER_PAGE-value-for.patch new file mode 100755 index 0000000..b67645e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/418-v6.17-spi-spi-qpic-snand-use-correct-CW_PER_PAGE-value-for.patch @@ -0,0 +1,56 @@ +From 6bc829220b33da8522572cc50fdf5067c51d3bf3 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Fri, 1 Aug 2025 09:58:35 +0200 +Subject: spi: spi-qpic-snand: use correct CW_PER_PAGE value for OOB write + +The qcom_spi_program_oob() function uses only the last codeword to write +the OOB data into the flash, but it sets the CW_PER_PAGE field in the +CFG0 register as it would use all codewords. + +It seems that this confuses the hardware somehow, and any access to the +flash fails with a timeout error after the function is called. The problem +can be easily reproduced with the following commands: + + # dd if=/dev/zero bs=2176 count=1 > /tmp/test.bin + 1+0 records in + 1+0 records out + # flash_erase /dev/mtd4 0 0 + Erasing 128 Kibyte @ 0 -- 100 % complete + # nandwrite -O /dev/mtd4 /tmp/test.bin + Writing data to block 0 at offset 0x0 + # nanddump -o /dev/mtd4 >/dev/null + ECC failed: 0 + ECC corrected: 0 + Number of bad blocks: 0 + Number of bbt blocks: 0 + Block size 131072, page size 2048, OOB size 128 + Dumping data starting at 0x00000000 and ending at 0x00020000... + [ 33.197605] qcom_snand 79b0000.spi: failure to read oob + libmtd: error!: MEMREADOOB64 ioctl failed for mtd4, offset 0 (eraseblock 0) + error 110 (Operation timed out) + [ 35.277582] qcom_snand 79b0000.spi: failure in submitting cmd descriptor + libmtd: error!: cannot read 2048 bytes from mtd4 (eraseblock 0, offset 2048) + error 110 (Operation timed out) + nanddump: error!: mtd_read + +Change the code to use the correct CW_PER_PAGE value to avoid this. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Link: https://patch.msgid.link/20250801-qpic-snand-oob-cwpp-fix-v1-1-f5a41b86af2e@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -1204,7 +1204,7 @@ static int qcom_spi_program_oob(struct q + u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg; + + cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) | +- FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1); ++ FIELD_PREP(CW_PER_PAGE_MASK, 0); + cfg1 = ecc_cfg->cfg1; + ecc_bch_cfg = ecc_cfg->ecc_bch_cfg; + ecc_buf_cfg = ecc_cfg->ecc_buf_cfg; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/419-v6.17-spi-spi-qpic-snand-fix-calculating-of-ECC-OOB-region.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/419-v6.17-spi-spi-qpic-snand-fix-calculating-of-ECC-OOB-region.patch new file mode 100755 index 0000000..35d5d30 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/419-v6.17-spi-spi-qpic-snand-fix-calculating-of-ECC-OOB-region.patch @@ -0,0 +1,69 @@ +From 13d0fe84a214658254a7412b2b46ec1507dc51f0 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Tue, 5 Aug 2025 18:05:42 +0200 +Subject: spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties + +The OOB layout used by the driver has two distinct regions which contains +hardware specific ECC data, yet the qcom_spi_ooblayout_ecc() function sets +the same offset and length values for both regions which is clearly wrong. + +Change the code to calculate the correct values for both regions. + +For reference, the following table shows the computed offset and length +values for various OOB size/ECC strength configurations: + + +-----------------+-----------------+ + |before the change| after the change| + +-------+----------+--------+--------+--------+--------+--------+ + | OOB | ECC | region | region | region | region | region | + | size | strength | index | offset | length | offset | length | + +-------+----------+--------+--------+--------+--------+--------+ + | 128 | 8 | 0 | 113 | 15 | 0 | 49 | + | | | 1 | 113 | 15 | 65 | 63 | + +-------+----------+--------+--------+--------+--------+--------+ + | 128 | 4 | 0 | 117 | 11 | 0 | 37 | + | | | 1 | 117 | 11 | 53 | 75 | + +-------+----------+--------+--------+--------+--------+--------+ + | 64 | 4 | 0 | 53 | 11 | 0 | 37 | + | | | 1 | 53 | 11 | 53 | 11 | + +-------+----------+--------+--------+--------+--------+--------+ + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Reviewed-by: Konrad Dybcio +Link: https://patch.msgid.link/20250805-qpic-snand-oob-ecc-fix-v2-1-e6f811c70d6f@gmail.com +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 20 ++++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -216,13 +216,21 @@ static int qcom_spi_ooblayout_ecc(struct + struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand); + struct qpic_ecc *qecc = snandc->qspi->ecc; + +- if (section > 1) +- return -ERANGE; ++ switch (section) { ++ case 0: ++ oobregion->offset = 0; ++ oobregion->length = qecc->bytes * (qecc->steps - 1) + ++ qecc->bbm_size; ++ return 0; ++ case 1: ++ oobregion->offset = qecc->bytes * (qecc->steps - 1) + ++ qecc->bbm_size + ++ qecc->steps * 4; ++ oobregion->length = mtd->oobsize - oobregion->offset; ++ return 0; ++ } + +- oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes; +- oobregion->offset = mtd->oobsize - oobregion->length; +- +- return 0; ++ return -ERANGE; + } + + static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-01-v6.16-mtd-rawnand-brcmnand-remove-unused-parameters.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-01-v6.16-mtd-rawnand-brcmnand-remove-unused-parameters.patch new file mode 100755 index 0000000..3bc6038 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-01-v6.16-mtd-rawnand-brcmnand-remove-unused-parameters.patch @@ -0,0 +1,88 @@ +From 56fce75470041b5b0d92ae10637416e1a4cceb1b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Wed, 14 May 2025 08:14:54 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: remove unused parameters +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +last_cmd and last_byte are now unused brcmnand_host members. +last_addr is only written and never read so we can remove it too. + +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Reviewed-by: Florian Fainelli +Reviewed-by: William Zhang +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 24 ++++++------------------ + 1 file changed, 6 insertions(+), 18 deletions(-) + +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -310,9 +310,6 @@ struct brcmnand_host { + struct platform_device *pdev; + int cs; + +- unsigned int last_cmd; +- unsigned int last_byte; +- u64 last_addr; + struct brcmnand_cfg hwcfg; + struct brcmnand_controller *ctrl; + }; +@@ -2233,14 +2230,11 @@ static int brcmnand_read_page(struct nan + int oob_required, int page) + { + struct mtd_info *mtd = nand_to_mtd(chip); +- struct brcmnand_host *host = nand_get_controller_data(chip); + u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL; + u64 addr = (u64)page << chip->page_shift; + +- host->last_addr = addr; +- +- return brcmnand_read(mtd, chip, host->last_addr, +- mtd->writesize >> FC_SHIFT, (u32 *)buf, oob); ++ return brcmnand_read(mtd, chip, addr, mtd->writesize >> FC_SHIFT, ++ (u32 *)buf, oob); + } + + static int brcmnand_read_page_raw(struct nand_chip *chip, uint8_t *buf, +@@ -2252,11 +2246,9 @@ static int brcmnand_read_page_raw(struct + int ret; + u64 addr = (u64)page << chip->page_shift; + +- host->last_addr = addr; +- + brcmnand_set_ecc_enabled(host, 0); +- ret = brcmnand_read(mtd, chip, host->last_addr, +- mtd->writesize >> FC_SHIFT, (u32 *)buf, oob); ++ ret = brcmnand_read(mtd, chip, addr, mtd->writesize >> FC_SHIFT, ++ (u32 *)buf, oob); + brcmnand_set_ecc_enabled(host, 1); + return ret; + } +@@ -2363,13 +2355,10 @@ static int brcmnand_write_page(struct na + int oob_required, int page) + { + struct mtd_info *mtd = nand_to_mtd(chip); +- struct brcmnand_host *host = nand_get_controller_data(chip); + void *oob = oob_required ? chip->oob_poi : NULL; + u64 addr = (u64)page << chip->page_shift; + +- host->last_addr = addr; +- +- return brcmnand_write(mtd, chip, host->last_addr, (const u32 *)buf, oob); ++ return brcmnand_write(mtd, chip, addr, (const u32 *)buf, oob); + } + + static int brcmnand_write_page_raw(struct nand_chip *chip, const uint8_t *buf, +@@ -2381,9 +2370,8 @@ static int brcmnand_write_page_raw(struc + u64 addr = (u64)page << chip->page_shift; + int ret = 0; + +- host->last_addr = addr; + brcmnand_set_ecc_enabled(host, 0); +- ret = brcmnand_write(mtd, chip, host->last_addr, (const u32 *)buf, oob); ++ ret = brcmnand_write(mtd, chip, addr, (const u32 *)buf, oob); + brcmnand_set_ecc_enabled(host, 1); + + return ret; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-02-v6.16-mtd-nand-brcmnand-fix-NAND-timeout-when-accessing-eM.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-02-v6.16-mtd-nand-brcmnand-fix-NAND-timeout-when-accessing-eM.patch new file mode 100755 index 0000000..d3dbde8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-02-v6.16-mtd-nand-brcmnand-fix-NAND-timeout-when-accessing-eM.patch @@ -0,0 +1,30 @@ +From 528b541b71cf03e263272b051b70696f92258e9d Mon Sep 17 00:00:00 2001 +From: David Regan +Date: Thu, 22 May 2025 10:25:17 -0700 +Subject: [PATCH] mtd: nand: brcmnand: fix NAND timeout when accessing eMMC + +When booting a board to NAND and accessing NAND while eMMC +transactions are occurring the NAND will sometimes timeout. This +is due to both NAND and eMMC controller sharing the same data bus +on BCMBCA chips. Fix is to extend NAND timeout to allow eMMC +transactions time to complete. + +Signed-off-by: David Regan +Reviewed-by: William Zhang +Reviewed-by: Florian Fainelli +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -101,7 +101,7 @@ struct brcm_nand_dma_desc { + #define BRCMNAND_MIN_DEVSIZE (4ULL * 1024 * 1024) + + #define NAND_CTRL_RDY (INTFC_CTLR_READY | INTFC_FLASH_READY) +-#define NAND_POLL_STATUS_TIMEOUT_MS 100 ++#define NAND_POLL_STATUS_TIMEOUT_MS 500 + + #define EDU_CMD_WRITE 0x00 + #define EDU_CMD_READ 0x01 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-03-v6.16-mtd-rawnand-brcmnand-legacy-exec_op-implementation.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-03-v6.16-mtd-rawnand-brcmnand-legacy-exec_op-implementation.patch new file mode 100755 index 0000000..6c75c2b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/420-03-v6.16-mtd-rawnand-brcmnand-legacy-exec_op-implementation.patch @@ -0,0 +1,299 @@ +From 3bfb22cecfe6b6f0d8ee56ef4b533cf68599c5d9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Wed, 21 May 2025 10:03:25 +0200 +Subject: [PATCH] mtd: rawnand: brcmnand: legacy exec_op implementation +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit 3c8260ce7663 ("mtd: rawnand: brcmnand: exec_op implementation") +removed legacy interface functions, breaking < v5.0 controllers support. +In order to fix older controllers we need to add an alternative exec_op +implementation which doesn't rely on low level registers. + +Fixes: 3c8260ce7663 ("mtd: rawnand: brcmnand: exec_op implementation") +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Reviewed-by: David Regan +Reviewed-by: Florian Fainelli +Reviewed-by: William Zhang +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/raw/brcmnand/brcmnand.c | 222 ++++++++++++++++++++++- + 1 file changed, 215 insertions(+), 7 deletions(-) + +--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c ++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c +@@ -65,6 +65,7 @@ module_param(wp_on, int, 0444); + #define CMD_PARAMETER_READ 0x0e + #define CMD_PARAMETER_CHANGE_COL 0x0f + #define CMD_LOW_LEVEL_OP 0x10 ++#define CMD_NOT_SUPPORTED 0xff + + struct brcm_nand_dma_desc { + u32 next_desc; +@@ -199,6 +200,30 @@ static const u16 flash_dma_regs_v4[] = { + [FLASH_DMA_CURRENT_DESC_EXT] = 0x34, + }; + ++/* Native command conversion for legacy controllers (< v5.0) */ ++static const u8 native_cmd_conv[] = { ++ [NAND_CMD_READ0] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_READ1] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_RNDOUT] = CMD_PARAMETER_CHANGE_COL, ++ [NAND_CMD_PAGEPROG] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_READOOB] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_ERASE1] = CMD_BLOCK_ERASE, ++ [NAND_CMD_STATUS] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_SEQIN] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_RNDIN] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_READID] = CMD_DEVICE_ID_READ, ++ [NAND_CMD_ERASE2] = CMD_NULL, ++ [NAND_CMD_PARAM] = CMD_PARAMETER_READ, ++ [NAND_CMD_GET_FEATURES] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_SET_FEATURES] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_RESET] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_READSTART] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_READCACHESEQ] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_READCACHEEND] = CMD_NOT_SUPPORTED, ++ [NAND_CMD_RNDOUTSTART] = CMD_NULL, ++ [NAND_CMD_CACHEDPROG] = CMD_NOT_SUPPORTED, ++}; ++ + /* Controller feature flags */ + enum { + BRCMNAND_HAS_1K_SECTORS = BIT(0), +@@ -237,6 +262,12 @@ struct brcmnand_controller { + /* List of NAND hosts (one for each chip-select) */ + struct list_head host_list; + ++ /* Functions to be called from exec_op */ ++ int (*check_instr)(struct nand_chip *chip, ++ const struct nand_operation *op); ++ int (*exec_instr)(struct nand_chip *chip, ++ const struct nand_operation *op); ++ + /* EDU info, per-transaction */ + const u16 *edu_offsets; + void __iomem *edu_base; +@@ -2478,18 +2509,190 @@ static int brcmnand_op_is_reset(const st + return 0; + } + ++static int brcmnand_check_instructions(struct nand_chip *chip, ++ const struct nand_operation *op) ++{ ++ return 0; ++} ++ ++static int brcmnand_exec_instructions(struct nand_chip *chip, ++ const struct nand_operation *op) ++{ ++ struct brcmnand_host *host = nand_get_controller_data(chip); ++ unsigned int i; ++ int ret = 0; ++ ++ for (i = 0; i < op->ninstrs; i++) { ++ ret = brcmnand_exec_instr(host, i, op); ++ if (ret) ++ break; ++ } ++ ++ return ret; ++} ++ ++static int brcmnand_check_instructions_legacy(struct nand_chip *chip, ++ const struct nand_operation *op) ++{ ++ const struct nand_op_instr *instr; ++ unsigned int i; ++ u8 cmd; ++ ++ for (i = 0; i < op->ninstrs; i++) { ++ instr = &op->instrs[i]; ++ ++ switch (instr->type) { ++ case NAND_OP_CMD_INSTR: ++ cmd = native_cmd_conv[instr->ctx.cmd.opcode]; ++ if (cmd == CMD_NOT_SUPPORTED) ++ return -EOPNOTSUPP; ++ break; ++ case NAND_OP_ADDR_INSTR: ++ case NAND_OP_DATA_IN_INSTR: ++ case NAND_OP_WAITRDY_INSTR: ++ break; ++ default: ++ return -EOPNOTSUPP; ++ } ++ } ++ ++ return 0; ++} ++ ++static int brcmnand_exec_instructions_legacy(struct nand_chip *chip, ++ const struct nand_operation *op) ++{ ++ struct mtd_info *mtd = nand_to_mtd(chip); ++ struct brcmnand_host *host = nand_get_controller_data(chip); ++ struct brcmnand_controller *ctrl = host->ctrl; ++ const struct nand_op_instr *instr; ++ unsigned int i, j; ++ u8 cmd = CMD_NULL, last_cmd = CMD_NULL; ++ int ret = 0; ++ u64 last_addr; ++ ++ for (i = 0; i < op->ninstrs; i++) { ++ instr = &op->instrs[i]; ++ ++ if (instr->type == NAND_OP_CMD_INSTR) { ++ cmd = native_cmd_conv[instr->ctx.cmd.opcode]; ++ if (cmd == CMD_NOT_SUPPORTED) { ++ dev_err(ctrl->dev, "unsupported cmd=%d\n", ++ instr->ctx.cmd.opcode); ++ ret = -EOPNOTSUPP; ++ break; ++ } ++ } else if (instr->type == NAND_OP_ADDR_INSTR) { ++ u64 addr = 0; ++ ++ if (cmd == CMD_NULL) ++ continue; ++ ++ if (instr->ctx.addr.naddrs > 8) { ++ dev_err(ctrl->dev, "unsupported naddrs=%u\n", ++ instr->ctx.addr.naddrs); ++ ret = -EOPNOTSUPP; ++ break; ++ } ++ ++ for (j = 0; j < instr->ctx.addr.naddrs; j++) ++ addr |= (instr->ctx.addr.addrs[j]) << (j << 3); ++ ++ if (cmd == CMD_BLOCK_ERASE) ++ addr <<= chip->page_shift; ++ else if (cmd == CMD_PARAMETER_CHANGE_COL) ++ addr &= ~((u64)(FC_BYTES - 1)); ++ ++ brcmnand_set_cmd_addr(mtd, addr); ++ brcmnand_send_cmd(host, cmd); ++ last_addr = addr; ++ last_cmd = cmd; ++ cmd = CMD_NULL; ++ brcmnand_waitfunc(chip); ++ ++ if (last_cmd == CMD_PARAMETER_READ || ++ last_cmd == CMD_PARAMETER_CHANGE_COL) { ++ /* Copy flash cache word-wise */ ++ u32 *flash_cache = (u32 *)ctrl->flash_cache; ++ ++ brcmnand_soc_data_bus_prepare(ctrl->soc, true); ++ ++ /* ++ * Must cache the FLASH_CACHE now, since changes in ++ * SECTOR_SIZE_1K may invalidate it ++ */ ++ for (j = 0; j < FC_WORDS; j++) ++ /* ++ * Flash cache is big endian for parameter pages, at ++ * least on STB SoCs ++ */ ++ flash_cache[j] = be32_to_cpu(brcmnand_read_fc(ctrl, j)); ++ ++ brcmnand_soc_data_bus_unprepare(ctrl->soc, true); ++ } ++ } else if (instr->type == NAND_OP_DATA_IN_INSTR) { ++ u8 *in = instr->ctx.data.buf.in; ++ ++ if (last_cmd == CMD_DEVICE_ID_READ) { ++ u32 val; ++ ++ if (instr->ctx.data.len > 8) { ++ dev_err(ctrl->dev, "unsupported len=%u\n", ++ instr->ctx.data.len); ++ ret = -EOPNOTSUPP; ++ break; ++ } ++ ++ for (j = 0; j < instr->ctx.data.len; j++) { ++ if (j == 0) ++ val = brcmnand_read_reg(ctrl, BRCMNAND_ID); ++ else if (j == 4) ++ val = brcmnand_read_reg(ctrl, BRCMNAND_ID_EXT); ++ ++ in[j] = (val >> (24 - ((j % 4) << 3))) & 0xff; ++ } ++ } else if (last_cmd == CMD_PARAMETER_READ || ++ last_cmd == CMD_PARAMETER_CHANGE_COL) { ++ u64 addr; ++ u32 offs; ++ ++ for (j = 0; j < instr->ctx.data.len; j++) { ++ addr = last_addr + j; ++ offs = addr & (FC_BYTES - 1); ++ ++ if (j > 0 && offs == 0) ++ nand_change_read_column_op(chip, addr, NULL, 0, ++ false); ++ ++ in[j] = ctrl->flash_cache[offs]; ++ } ++ } ++ } else if (instr->type == NAND_OP_WAITRDY_INSTR) { ++ ret = bcmnand_ctrl_poll_status(host, NAND_CTRL_RDY, NAND_CTRL_RDY, 0); ++ if (ret) ++ break; ++ } else { ++ dev_err(ctrl->dev, "unsupported instruction type: %d\n", instr->type); ++ ret = -EOPNOTSUPP; ++ break; ++ } ++ } ++ ++ return ret; ++} ++ + static int brcmnand_exec_op(struct nand_chip *chip, + const struct nand_operation *op, + bool check_only) + { + struct brcmnand_host *host = nand_get_controller_data(chip); ++ struct brcmnand_controller *ctrl = host->ctrl; + struct mtd_info *mtd = nand_to_mtd(chip); + u8 *status; +- unsigned int i; + int ret = 0; + + if (check_only) +- return 0; ++ return ctrl->check_instr(chip, op); + + if (brcmnand_op_is_status(op)) { + status = op->instrs[1].ctx.data.buf.in; +@@ -2513,11 +2716,7 @@ static int brcmnand_exec_op(struct nand_ + if (op->deassert_wp) + brcmnand_wp(mtd, 0); + +- for (i = 0; i < op->ninstrs; i++) { +- ret = brcmnand_exec_instr(host, i, op); +- if (ret) +- break; +- } ++ ret = ctrl->exec_instr(chip, op); + + if (op->deassert_wp) + brcmnand_wp(mtd, 1); +@@ -3130,6 +3329,15 @@ int brcmnand_probe(struct platform_devic + if (ret) + goto err; + ++ /* Only v5.0+ controllers have low level ops support */ ++ if (ctrl->nand_version >= 0x0500) { ++ ctrl->check_instr = brcmnand_check_instructions; ++ ctrl->exec_instr = brcmnand_exec_instructions; ++ } else { ++ ctrl->check_instr = brcmnand_check_instructions_legacy; ++ ctrl->exec_instr = brcmnand_exec_instructions_legacy; ++ } ++ + /* + * Most chips have this cache at a fixed offset within 'nand' block. + * Some must specify this region separately. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/422-v6.17-spi-spi-qpic-snand-unregister-ECC-engine-on-probe-er.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/422-v6.17-spi-spi-qpic-snand-unregister-ECC-engine-on-probe-er.patch new file mode 100755 index 0000000..46184b5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/422-v6.17-spi-spi-qpic-snand-unregister-ECC-engine-on-probe-er.patch @@ -0,0 +1,48 @@ +From 1991a458528588ff34e98b6365362560d208710f Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Wed, 3 Sep 2025 13:56:24 +0200 +Subject: spi: spi-qpic-snand: unregister ECC engine on probe error and device + remove + +The on-host hardware ECC engine remains registered both when +the spi_register_controller() function returns with an error +and also on device removal. + +Change the qcom_spi_probe() function to unregister the engine +on the error path, and add the missing unregistering call to +qcom_spi_remove() to avoid possible use-after-free issues. + +Fixes: 7304d1909080 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") +Signed-off-by: Gabor Juhos +Message-ID: <20250903-qpic-snand-unregister-ecceng-v1-1-ef5387b0abdc@gmail.com> +Signed-off-by: Mark Brown +--- + drivers/spi/spi-qpic-snand.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/spi/spi-qpic-snand.c ++++ b/drivers/spi/spi-qpic-snand.c +@@ -1632,11 +1632,13 @@ static int qcom_spi_probe(struct platfor + ret = spi_register_controller(ctlr); + if (ret) { + dev_err(&pdev->dev, "spi_register_controller failed.\n"); +- goto err_spi_init; ++ goto err_register_controller; + } + + return 0; + ++err_register_controller: ++ nand_ecc_unregister_on_host_hw_engine(&snandc->qspi->ecc_eng); + err_spi_init: + qcom_nandc_unalloc(snandc); + err_snand_alloc: +@@ -1658,7 +1660,7 @@ static void qcom_spi_remove(struct platf + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + + spi_unregister_controller(ctlr); +- ++ nand_ecc_unregister_on_host_hw_engine(&snandc->qspi->ecc_eng); + qcom_nandc_unalloc(snandc); + + clk_disable_unprepare(snandc->aon_clk); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-01-v6.18-mtd-spinand-fix-direct-mapping-creation-sizes.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-01-v6.18-mtd-spinand-fix-direct-mapping-creation-sizes.patch new file mode 100755 index 0000000..994e06e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-01-v6.18-mtd-spinand-fix-direct-mapping-creation-sizes.patch @@ -0,0 +1,63 @@ +From e4a0cf9f1d90e6888e5373da3314f761024f6c97 Mon Sep 17 00:00:00 2001 +From: Mikhail Kshevetskiy +Date: Thu, 18 Sep 2025 00:53:59 +0300 +Subject: mtd: spinand: fix direct mapping creation sizes + +Continuous mode is only supported for data reads, thus writing +requires only single flash page mapping. + +Signed-off-by: Mikhail Kshevetskiy +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/core.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -1028,18 +1028,13 @@ static int spinand_create_dirmap(struct + unsigned int plane) + { + struct nand_device *nand = spinand_to_nand(spinand); +- struct spi_mem_dirmap_info info = { +- .length = nanddev_page_size(nand) + +- nanddev_per_page_oobsize(nand), +- }; ++ struct spi_mem_dirmap_info info = { 0 }; + struct spi_mem_dirmap_desc *desc; + +- if (spinand->cont_read_possible) +- info.length = nanddev_eraseblock_size(nand); +- + /* The plane number is passed in MSB just above the column address */ + info.offset = plane << fls(nand->memorg.pagesize); + ++ info.length = nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); + info.op_tmpl = *spinand->op_templates.update_cache; + desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, + spinand->spimem, &info); +@@ -1048,6 +1043,8 @@ static int spinand_create_dirmap(struct + + spinand->dirmaps[plane].wdesc = desc; + ++ if (spinand->cont_read_possible) ++ info.length = nanddev_eraseblock_size(nand); + info.op_tmpl = *spinand->op_templates.read_cache; + desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, + spinand->spimem, &info); +@@ -1063,6 +1060,7 @@ static int spinand_create_dirmap(struct + return 0; + } + ++ info.length = nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); + info.op_tmpl = *spinand->op_templates.update_cache; + info.op_tmpl.data.ecc = true; + desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, +@@ -1072,6 +1070,8 @@ static int spinand_create_dirmap(struct + + spinand->dirmaps[plane].wdesc_ecc = desc; + ++ if (spinand->cont_read_possible) ++ info.length = nanddev_eraseblock_size(nand); + info.op_tmpl = *spinand->op_templates.read_cache; + info.op_tmpl.data.ecc = true; + desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-02-v6.18-mtd-spinand-try-a-regular-dirmap-if-creating-a-di.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-02-v6.18-mtd-spinand-try-a-regular-dirmap-if-creating-a-di.patch new file mode 100755 index 0000000..005c0aa --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-02-v6.18-mtd-spinand-try-a-regular-dirmap-if-creating-a-di.patch @@ -0,0 +1,98 @@ +From 004f8ea0d9917398aabff7388b3bf62a84a4088b Mon Sep 17 00:00:00 2001 +From: Mikhail Kshevetskiy +Date: Thu, 18 Sep 2025 00:54:00 +0300 +Subject: mtd: spinand: try a regular dirmap if creating a dirmap for + continuous reading fails + +Continuous reading may result in multiple flash pages reading in one +operation. Typically only one flash page has read/written (a little bit +more than 2-4 Kb), but continuous reading requires the spi controller +to read up to 512 Kb in one operation without toggling CS in beetween. + +Roughly speaking spi controllers can be divided on 2 categories: + * spi controllers without dirmap acceleration support + * spi controllers with dirmap acceleration support + +Firt of them will have issues with continuous reading if restriction on +the transfer length is implemented in the adjust_op_size() handler. +Second group often supports acceleration of single page only reading. +Thus enabling of continuous reading can break flash reading. + +This patch tries to create dirmap for continuous reading first and +fallback to regular reading if spi controller refuses to create it. + +Signed-off-by: Mikhail Kshevetskiy +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/core.c | 43 ++++++++++++++++++++++++++++++------- + 1 file changed, 35 insertions(+), 8 deletions(-) + +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -1024,6 +1024,39 @@ static int spinand_mtd_block_isreserved( + return ret; + } + ++static struct spi_mem_dirmap_desc *spinand_create_rdesc( ++ struct spinand_device *spinand, ++ struct spi_mem_dirmap_info *info) ++{ ++ struct nand_device *nand = spinand_to_nand(spinand); ++ struct spi_mem_dirmap_desc *desc = NULL; ++ ++ if (spinand->cont_read_possible) { ++ /* ++ * spi controller may return an error if info->length is ++ * too large ++ */ ++ info->length = nanddev_eraseblock_size(nand); ++ desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, ++ spinand->spimem, info); ++ } ++ ++ if (IS_ERR_OR_NULL(desc)) { ++ /* ++ * continuous reading is not supported by flash or ++ * its spi controller, use regular reading ++ */ ++ spinand->cont_read_possible = false; ++ ++ info->length = nanddev_page_size(nand) + ++ nanddev_per_page_oobsize(nand); ++ desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, ++ spinand->spimem, info); ++ } ++ ++ return desc; ++} ++ + static int spinand_create_dirmap(struct spinand_device *spinand, + unsigned int plane) + { +@@ -1043,11 +1076,8 @@ static int spinand_create_dirmap(struct + + spinand->dirmaps[plane].wdesc = desc; + +- if (spinand->cont_read_possible) +- info.length = nanddev_eraseblock_size(nand); + info.op_tmpl = *spinand->op_templates.read_cache; +- desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, +- spinand->spimem, &info); ++ desc = spinand_create_rdesc(spinand, &info); + if (IS_ERR(desc)) + return PTR_ERR(desc); + +@@ -1070,12 +1100,9 @@ static int spinand_create_dirmap(struct + + spinand->dirmaps[plane].wdesc_ecc = desc; + +- if (spinand->cont_read_possible) +- info.length = nanddev_eraseblock_size(nand); + info.op_tmpl = *spinand->op_templates.read_cache; + info.op_tmpl.data.ecc = true; +- desc = devm_spi_mem_dirmap_create(&spinand->spimem->spi->dev, +- spinand->spimem, &info); ++ desc = spinand_create_rdesc(spinand, &info); + if (IS_ERR(desc)) + return PTR_ERR(desc); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-03-v6.18-mtd-spinand-repeat-reading-in-regular-mode-if-con.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-03-v6.18-mtd-spinand-repeat-reading-in-regular-mode-if-con.patch new file mode 100755 index 0000000..af53d20 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/429-03-v6.18-mtd-spinand-repeat-reading-in-regular-mode-if-con.patch @@ -0,0 +1,64 @@ +From 010dc7f2dd6a0078ade3f88f627ed5fbf45ceb94 Mon Sep 17 00:00:00 2001 +From: Mikhail Kshevetskiy +Date: Thu, 18 Sep 2025 00:54:01 +0300 +Subject: mtd: spinand: repeat reading in regular mode if continuous reading + fails + +Continuous reading may result in multiple flash pages reading in one +operation. Unfortunately, not all spinand controllers support such +large reading. They will read less data. Unfortunately, the operation +can't be continued. + +In this case: + * disable continuous reading on this (not good enough) spi controller + * repeat reading in regular mode. + +Signed-off-by: Mikhail Kshevetskiy +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/core.c | 25 +++++++++++++++++++++---- + 1 file changed, 21 insertions(+), 4 deletions(-) + +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -427,8 +427,16 @@ static int spinand_read_from_cache_op(st + * Dirmap accesses are allowed to toggle the CS. + * Toggling the CS during a continuous read is forbidden. + */ +- if (nbytes && req->continuous) +- return -EIO; ++ if (nbytes && req->continuous) { ++ /* ++ * Spi controller with broken support of continuous ++ * reading was detected. Disable future use of ++ * continuous reading and return -EAGAIN to retry ++ * reading within regular mode. ++ */ ++ spinand->cont_read_possible = false; ++ return -EAGAIN; ++ } + } + + if (req->datalen) +@@ -841,10 +849,19 @@ static int spinand_mtd_read(struct mtd_i + + old_stats = mtd->ecc_stats; + +- if (spinand_use_cont_read(mtd, from, ops)) ++ if (spinand_use_cont_read(mtd, from, ops)) { + ret = spinand_mtd_continuous_page_read(mtd, from, ops, &max_bitflips); +- else ++ if (ret == -EAGAIN && !spinand->cont_read_possible) { ++ /* ++ * Spi controller with broken support of continuous ++ * reading was detected (see spinand_read_from_cache_op()), ++ * repeat reading in regular mode. ++ */ ++ ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips); ++ } ++ } else { + ret = spinand_mtd_regular_page_read(mtd, from, ops, &max_bitflips); ++ } + + if (ops->stats) { + ops->stats->uncorrectable_errors += diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/430-v6.14-mtd-spinand-Introduce-a-way-to-avoid-raw-access.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/430-v6.14-mtd-spinand-Introduce-a-way-to-avoid-raw-access.patch new file mode 100755 index 0000000..d7d7772 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/430-v6.14-mtd-spinand-Introduce-a-way-to-avoid-raw-access.patch @@ -0,0 +1,81 @@ +From 6d9d6ab3a82af50e36e13e7bc8e2d1b970e39f79 Mon Sep 17 00:00:00 2001 +From: Takahiro Kuwano +Date: Tue, 3 Dec 2024 11:46:49 +0900 +Subject: [PATCH 1/1] mtd: spinand: Introduce a way to avoid raw access + +SkyHigh spinand device has ECC enable bit in configuration register but +it must be always enabled. If ECC is disabled, read and write ops +results in undetermined state. For such devices, a way to avoid raw +access is needed. + +Introduce SPINAND_NO_RAW_ACCESS flag to advertise the device does not +support raw access. In such devices, the on-die ECC engine ops returns +error to I/O request in raw mode. + +Checking and marking BBM need to be cared as special case, by adding +fallback mechanism that tries read/write OOB with ECC enabled. + +Signed-off-by: Takahiro Kuwano +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/core.c | 22 ++++++++++++++++++++-- + include/linux/mtd/spinand.h | 1 + + 2 files changed, 21 insertions(+), 2 deletions(-) + +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -294,6 +294,9 @@ static int spinand_ondie_ecc_prepare_io_ + struct spinand_device *spinand = nand_to_spinand(nand); + bool enable = (req->mode != MTD_OPS_RAW); + ++ if (!enable && spinand->flags & SPINAND_NO_RAW_ACCESS) ++ return -EOPNOTSUPP; ++ + memset(spinand->oobbuf, 0xff, nanddev_per_page_oobsize(nand)); + + /* Only enable or disable the engine */ +@@ -921,9 +924,17 @@ static bool spinand_isbad(struct nand_de + .oobbuf.in = marker, + .mode = MTD_OPS_RAW, + }; ++ int ret; + + spinand_select_target(spinand, pos->target); +- spinand_read_page(spinand, &req); ++ ++ ret = spinand_read_page(spinand, &req); ++ if (ret == -EOPNOTSUPP) { ++ /* Retry with ECC in case raw access is not supported */ ++ req.mode = MTD_OPS_PLACE_OOB; ++ spinand_read_page(spinand, &req); ++ } ++ + if (marker[0] != 0xff || marker[1] != 0xff) + return true; + +@@ -966,7 +977,14 @@ static int spinand_markbad(struct nand_d + if (ret) + return ret; + +- return spinand_write_page(spinand, &req); ++ ret = spinand_write_page(spinand, &req); ++ if (ret == -EOPNOTSUPP) { ++ /* Retry with ECC in case raw access is not supported */ ++ req.mode = MTD_OPS_PLACE_OOB; ++ ret = spinand_write_page(spinand, &req); ++ } ++ ++ return ret; + } + + static int spinand_mtd_block_markbad(struct mtd_info *mtd, loff_t offs) +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -315,6 +315,7 @@ struct spinand_ecc_info { + #define SPINAND_HAS_CR_FEAT_BIT BIT(1) + #define SPINAND_HAS_PROG_PLANE_SELECT_BIT BIT(2) + #define SPINAND_HAS_READ_PLANE_SELECT_BIT BIT(3) ++#define SPINAND_NO_RAW_ACCESS BIT(4) + + /** + * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/431-v6.14-mtd-spinand-Add-support-for-SkyHigh-S35ML-3-family.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/431-v6.14-mtd-spinand-Add-support-for-SkyHigh-S35ML-3-family.patch new file mode 100755 index 0000000..f5d7d9a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/431-v6.14-mtd-spinand-Add-support-for-SkyHigh-S35ML-3-family.patch @@ -0,0 +1,201 @@ +From 1a50e3612de9187857f55ee14a573f7f8e7d4ebc Mon Sep 17 00:00:00 2001 +From: Takahiro Kuwano +Date: Tue, 3 Dec 2024 11:46:50 +0900 +Subject: [PATCH] mtd: spinand: Add support for SkyHigh S35ML-3 family + +SkyHigh S35ML01G300, S35ML01G301, S35ML02G300, and S35ML04G300 are 1Gb, +2Gb, and 4Gb SLC SPI NAND flash family. This family of devices has +on-die ECC which parity bits are stored to hidden area. In this family +the on-die ECC cannot be disabled so raw access needs to be prevented. + +Link: https://www.skyhighmemory.com/download/SPI_S35ML01_04G3_002_19205.pdf?v=P +Co-developed-by: KR Kim +Signed-off-by: KR Kim +Signed-off-by: Takahiro Kuwano +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/Makefile | 2 +- + drivers/mtd/nand/spi/core.c | 1 + + drivers/mtd/nand/spi/skyhigh.c | 147 +++++++++++++++++++++++++++++++++ + include/linux/mtd/spinand.h | 1 + + 4 files changed, 150 insertions(+), 1 deletion(-) + create mode 100644 drivers/mtd/nand/spi/skyhigh.c + +--- a/drivers/mtd/nand/spi/Makefile ++++ b/drivers/mtd/nand/spi/Makefile +@@ -1,4 +1,4 @@ + # SPDX-License-Identifier: GPL-2.0 + spinand-objs := core.o alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o +-spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o ++spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o + obj-$(CONFIG_MTD_SPI_NAND) += spinand.o +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -1183,6 +1183,7 @@ static const struct spinand_manufacturer + ¯onix_spinand_manufacturer, + µn_spinand_manufacturer, + ¶gon_spinand_manufacturer, ++ &skyhigh_spinand_manufacturer, + &toshiba_spinand_manufacturer, + &winbond_spinand_manufacturer, + &xtx_spinand_manufacturer, +--- /dev/null ++++ b/drivers/mtd/nand/spi/skyhigh.c +@@ -0,0 +1,147 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2024 SkyHigh Memory Limited ++ * ++ * Author: Takahiro Kuwano ++ * Co-Author: KR Kim ++ */ ++ ++#include ++#include ++#include ++ ++#define SPINAND_MFR_SKYHIGH 0x01 ++#define SKYHIGH_STATUS_ECC_1TO2_BITFLIPS (1 << 4) ++#define SKYHIGH_STATUS_ECC_3TO6_BITFLIPS (2 << 4) ++#define SKYHIGH_STATUS_ECC_UNCOR_ERROR (3 << 4) ++#define SKYHIGH_CONFIG_PROTECT_EN BIT(1) ++ ++static SPINAND_OP_VARIANTS(read_cache_variants, ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(write_cache_variants, ++ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), ++ SPINAND_PROG_LOAD(true, 0, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(update_cache_variants, ++ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), ++ SPINAND_PROG_LOAD(false, 0, NULL, 0)); ++ ++static int skyhigh_spinand_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ /* ECC bytes are stored in hidden area. */ ++ return -ERANGE; ++} ++ ++static int skyhigh_spinand_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section) ++ return -ERANGE; ++ ++ /* ECC bytes are stored in hidden area. Reserve 2 bytes for the BBM. */ ++ region->offset = 2; ++ region->length = mtd->oobsize - 2; ++ ++ return 0; ++} ++ ++static const struct mtd_ooblayout_ops skyhigh_spinand_ooblayout = { ++ .ecc = skyhigh_spinand_ooblayout_ecc, ++ .free = skyhigh_spinand_ooblayout_free, ++}; ++ ++static int skyhigh_spinand_ecc_get_status(struct spinand_device *spinand, ++ u8 status) ++{ ++ switch (status & STATUS_ECC_MASK) { ++ case STATUS_ECC_NO_BITFLIPS: ++ return 0; ++ ++ case SKYHIGH_STATUS_ECC_UNCOR_ERROR: ++ return -EBADMSG; ++ ++ case SKYHIGH_STATUS_ECC_1TO2_BITFLIPS: ++ return 2; ++ ++ case SKYHIGH_STATUS_ECC_3TO6_BITFLIPS: ++ return 6; ++ ++ default: ++ break; ++ } ++ ++ return -EINVAL; ++} ++ ++static const struct spinand_info skyhigh_spinand_table[] = { ++ SPINAND_INFO("S35ML01G301", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), ++ NAND_ECCREQ(6, 32), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_NO_RAW_ACCESS, ++ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, ++ skyhigh_spinand_ecc_get_status)), ++ SPINAND_INFO("S35ML01G300", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14), ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), ++ NAND_ECCREQ(6, 32), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_NO_RAW_ACCESS, ++ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, ++ skyhigh_spinand_ecc_get_status)), ++ SPINAND_INFO("S35ML02G300", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25), ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1), ++ NAND_ECCREQ(6, 32), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_NO_RAW_ACCESS, ++ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, ++ skyhigh_spinand_ecc_get_status)), ++ SPINAND_INFO("S35ML04G300", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35), ++ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1), ++ NAND_ECCREQ(6, 32), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_NO_RAW_ACCESS, ++ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout, ++ skyhigh_spinand_ecc_get_status)), ++}; ++ ++static int skyhigh_spinand_init(struct spinand_device *spinand) ++{ ++ /* ++ * Config_Protect_En (bit 1 in Block Lock register) must be set to 1 ++ * before writing other bits. Do it here before core unlocks all blocks ++ * by writing block protection bits. ++ */ ++ return spinand_write_reg_op(spinand, REG_BLOCK_LOCK, ++ SKYHIGH_CONFIG_PROTECT_EN); ++} ++ ++static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = { ++ .init = skyhigh_spinand_init, ++}; ++ ++const struct spinand_manufacturer skyhigh_spinand_manufacturer = { ++ .id = SPINAND_MFR_SKYHIGH, ++ .name = "SkyHigh", ++ .chips = skyhigh_spinand_table, ++ .nchips = ARRAY_SIZE(skyhigh_spinand_table), ++ .ops = &skyhigh_spinand_manuf_ops, ++}; +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -269,6 +269,7 @@ extern const struct spinand_manufacturer + extern const struct spinand_manufacturer macronix_spinand_manufacturer; + extern const struct spinand_manufacturer micron_spinand_manufacturer; + extern const struct spinand_manufacturer paragon_spinand_manufacturer; ++extern const struct spinand_manufacturer skyhigh_spinand_manufacturer; + extern const struct spinand_manufacturer toshiba_spinand_manufacturer; + extern const struct spinand_manufacturer winbond_spinand_manufacturer; + extern const struct spinand_manufacturer xtx_spinand_manufacturer; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/434-v6.19-mtd-spinand-esmt-add-support-for-F50L1G41LC.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/434-v6.19-mtd-spinand-esmt-add-support-for-F50L1G41LC.patch new file mode 100755 index 0000000..f10d26f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/434-v6.19-mtd-spinand-esmt-add-support-for-F50L1G41LC.patch @@ -0,0 +1,84 @@ +From b98994cb9bc24f5c7575c86650f96c384576fdfa Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 17 Nov 2025 02:54:19 +0000 +Subject: [PATCH] mtd: spinand: esmt: add support for F50L1G41LC + +This adds support for ESMT F50L1G41LC, which appears to be an updated +version of the already supported F50L1G41LB. +Add esmt_8c SPI_NAND manufacturer to account for the newly used vendor +ID with support for the ESMT F50L1G41LC chip. + +Link: https://github.com/openwrt/openwrt/pull/15214#issuecomment-3514824435 +Signed-off-by: Daniel Golle +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/core.c | 1 + + drivers/mtd/nand/spi/esmt.c | 24 ++++++++++++++++++++++++ + include/linux/mtd/spinand.h | 1 + + 3 files changed, 26 insertions(+) + +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -1176,6 +1176,7 @@ static const struct nand_ops spinand_ops + static const struct spinand_manufacturer *spinand_manufacturers[] = { + &alliancememory_spinand_manufacturer, + &ato_spinand_manufacturer, ++ &esmt_8c_spinand_manufacturer, + &esmt_c8_spinand_manufacturer, + &fmsh_spinand_manufacturer, + &foresee_spinand_manufacturer, +--- a/drivers/mtd/nand/spi/esmt.c ++++ b/drivers/mtd/nand/spi/esmt.c +@@ -11,6 +11,7 @@ + + /* ESMT uses GigaDevice 0xc8 JECDEC ID on some SPI NANDs */ + #define SPINAND_MFR_ESMT_C8 0xc8 ++#define SPINAND_MFR_ESMT_8C 0x8c + + static SPINAND_OP_VARIANTS(read_cache_variants, + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), +@@ -102,6 +103,19 @@ static const struct mtd_ooblayout_ops f5 + .free = f50l1g41lb_ooblayout_free, + }; + ++ ++static const struct spinand_info esmt_8c_spinand_table[] = { ++ SPINAND_INFO("F50L1G41LC", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x2C), ++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), ++ NAND_ECCREQ(1, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ 0, ++ SPINAND_ECCINFO(&f50l1g41lb_ooblayout, NULL)), ++}; ++ + static const struct spinand_info esmt_c8_spinand_table[] = { + SPINAND_INFO("F50L1G41LB", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x01, 0x7f, +@@ -138,6 +152,14 @@ static const struct spinand_info esmt_c8 + static const struct spinand_manufacturer_ops esmt_spinand_manuf_ops = { + }; + ++const struct spinand_manufacturer esmt_8c_spinand_manufacturer = { ++ .id = SPINAND_MFR_ESMT_8C, ++ .name = "ESMT", ++ .chips = esmt_8c_spinand_table, ++ .nchips = ARRAY_SIZE(esmt_8c_spinand_table), ++ .ops = &esmt_spinand_manuf_ops, ++}; ++ + const struct spinand_manufacturer esmt_c8_spinand_manufacturer = { + .id = SPINAND_MFR_ESMT_C8, + .name = "ESMT", +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -262,6 +262,7 @@ struct spinand_manufacturer { + /* SPI NAND manufacturers */ + extern const struct spinand_manufacturer alliancememory_spinand_manufacturer; + extern const struct spinand_manufacturer ato_spinand_manufacturer; ++extern const struct spinand_manufacturer esmt_8c_spinand_manufacturer; + extern const struct spinand_manufacturer esmt_c8_spinand_manufacturer; + extern const struct spinand_manufacturer fmsh_spinand_manufacturer; + extern const struct spinand_manufacturer foresee_spinand_manufacturer; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/435-v6.19-mtd-spinand-add-support-for-FudanMicro-FM25S01BI3.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/435-v6.19-mtd-spinand-add-support-for-FudanMicro-FM25S01BI3.patch new file mode 100755 index 0000000..7355efe --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/435-v6.19-mtd-spinand-add-support-for-FudanMicro-FM25S01BI3.patch @@ -0,0 +1,115 @@ +From f6dffe2a9ed1bdcee1879e2728310fb1e08602cf Mon Sep 17 00:00:00 2001 +From: Mikhail Zhilkin +Date: Thu, 27 Nov 2025 22:59:00 +0300 +Subject: mtd: spinand: add support for FudanMicro FM25S01BI3 + +Add support for FudanMicro FM25S01BI3 SPI NAND. + +Link: https://www.fmsh.com/nvm/FM25S01BI3_ds_eng.pdf + +Signed-off-by: Mikhail Zhilkin +Signed-off-by: Miquel Raynal +--- + drivers/mtd/nand/spi/fmsh.c | 72 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 72 insertions(+) + +--- a/drivers/mtd/nand/spi/fmsh.c ++++ b/drivers/mtd/nand/spi/fmsh.c +@@ -9,6 +9,13 @@ + #include + #include + ++#define FM25S01BI3_STATUS_ECC_MASK (7 << 4) ++ #define FM25S01BI3_STATUS_ECC_NO_BITFLIPS (0 << 4) ++ #define FM25S01BI3_STATUS_ECC_1_3_BITFLIPS (1 << 4) ++ #define FM25S01BI3_STATUS_ECC_UNCOR_ERROR (2 << 4) ++ #define FM25S01BI3_STATUS_ECC_4_6_BITFLIPS (3 << 4) ++ #define FM25S01BI3_STATUS_ECC_7_8_BITFLIPS (5 << 4) ++ + #define SPINAND_MFR_FMSH 0xA1 + + static SPINAND_OP_VARIANTS(read_cache_variants, +@@ -45,11 +52,66 @@ static int fm25s01a_ooblayout_free(struc + return 0; + } + ++static int fm25s01bi3_ecc_get_status(struct spinand_device *spinand, ++ u8 status) ++{ ++ switch (status & FM25S01BI3_STATUS_ECC_MASK) { ++ case FM25S01BI3_STATUS_ECC_NO_BITFLIPS: ++ return 0; ++ ++ case FM25S01BI3_STATUS_ECC_UNCOR_ERROR: ++ return -EBADMSG; ++ ++ case FM25S01BI3_STATUS_ECC_1_3_BITFLIPS: ++ return 3; ++ ++ case FM25S01BI3_STATUS_ECC_4_6_BITFLIPS: ++ return 6; ++ ++ case FM25S01BI3_STATUS_ECC_7_8_BITFLIPS: ++ return 8; ++ ++ default: ++ break; ++ } ++ ++ return -EINVAL; ++} ++ ++static int fm25s01bi3_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section) ++ return -ERANGE; ++ ++ region->offset = 64; ++ region->length = 64; ++ ++ return 0; ++} ++ ++static int fm25s01bi3_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *region) ++{ ++ if (section > 3) ++ return -ERANGE; ++ ++ region->offset = (16 * section) + 4; ++ region->length = 12; ++ ++ return 0; ++} ++ + static const struct mtd_ooblayout_ops fm25s01a_ooblayout = { + .ecc = fm25s01a_ooblayout_ecc, + .free = fm25s01a_ooblayout_free, + }; + ++static const struct mtd_ooblayout_ops fm25s01bi3_ooblayout = { ++ .ecc = fm25s01bi3_ooblayout_ecc, ++ .free = fm25s01bi3_ooblayout_free, ++}; ++ + static const struct spinand_info fmsh_spinand_table[] = { + SPINAND_INFO("FM25S01A", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4), +@@ -60,6 +122,16 @@ static const struct spinand_info fmsh_sp + &update_cache_variants), + 0, + SPINAND_ECCINFO(&fm25s01a_ooblayout, NULL)), ++ SPINAND_INFO("FM25S01BI3", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xd4), ++ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_HAS_QE_BIT, ++ SPINAND_ECCINFO(&fm25s01bi3_ooblayout, ++ fm25s01bi3_ecc_get_status)), + }; + + static const struct spinand_manufacturer_ops fmsh_spinand_manuf_ops = { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-01-v6.13-block-add-support-for-defining-read-only-partitions.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-01-v6.13-block-add-support-for-defining-read-only-partitions.patch new file mode 100755 index 0000000..9e2977f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-01-v6.13-block-add-support-for-defining-read-only-partitions.patch @@ -0,0 +1,53 @@ +From 03cb793b26834ddca170ba87057c8f883772dd45 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 3 Oct 2024 00:11:41 +0200 +Subject: [PATCH 1/5] block: add support for defining read-only partitions + +Add support for defining read-only partitions and complete support for +it in the cmdline partition parser as the additional "ro" after a +partition is scanned but never actually applied. + +Signed-off-by: Christian Marangi +Reviewed-by: Christoph Hellwig +Link: https://lore.kernel.org/r/20241002221306.4403-2-ansuelsmth@gmail.com +Signed-off-by: Jens Axboe +--- + block/blk.h | 1 + + block/partitions/cmdline.c | 3 +++ + block/partitions/core.c | 3 +++ + 3 files changed, 7 insertions(+) + +--- a/block/blk.h ++++ b/block/blk.h +@@ -570,6 +570,7 @@ void blk_free_ext_minor(unsigned int min + #define ADDPART_FLAG_NONE 0 + #define ADDPART_FLAG_RAID 1 + #define ADDPART_FLAG_WHOLEDISK 2 ++#define ADDPART_FLAG_READONLY 4 + int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, + sector_t length); + int bdev_del_partition(struct gendisk *disk, int partno); +--- a/block/partitions/cmdline.c ++++ b/block/partitions/cmdline.c +@@ -237,6 +237,9 @@ static int add_part(int slot, struct cmd + put_partition(state, slot, subpart->from >> 9, + subpart->size >> 9); + ++ if (subpart->flags & PF_RDONLY) ++ state->parts[slot].flags |= ADDPART_FLAG_READONLY; ++ + info = &state->parts[slot].info; + + strscpy(info->volname, subpart->name, sizeof(info->volname)); +--- a/block/partitions/core.c ++++ b/block/partitions/core.c +@@ -373,6 +373,9 @@ static struct block_device *add_partitio + goto out_del; + } + ++ if (flags & ADDPART_FLAG_READONLY) ++ bdev_set_flag(bdev, BD_READ_ONLY); ++ + /* everything is up and running, commence */ + err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); + if (err) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-02-v6.13-block-introduce-add_disk_fwnode.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-02-v6.13-block-introduce-add_disk_fwnode.patch new file mode 100755 index 0000000..381838d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-02-v6.13-block-introduce-add_disk_fwnode.patch @@ -0,0 +1,94 @@ +From e5f587242b6072ffab4f4a084a459a59f3035873 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 3 Oct 2024 00:11:43 +0200 +Subject: [PATCH 3/5] block: introduce add_disk_fwnode() + +Introduce add_disk_fwnode() as a replacement of device_add_disk() that +permits to pass and attach a fwnode to disk dev. + +This variant can be useful for eMMC that might have the partition table +for the disk defined in DT. A parser can later make use of the attached +fwnode to parse the related table and init the hardcoded partition for +the disk. + +device_add_disk() is converted to a simple wrapper of add_disk_fwnode() +with the fwnode entry set as NULL. + +Signed-off-by: Christian Marangi +Reviewed-by: Christoph Hellwig +Link: https://lore.kernel.org/r/20241002221306.4403-4-ansuelsmth@gmail.com +Signed-off-by: Jens Axboe +--- + block/genhd.c | 28 ++++++++++++++++++++++++---- + include/linux/blkdev.h | 3 +++ + 2 files changed, 27 insertions(+), 4 deletions(-) + +--- a/block/genhd.c ++++ b/block/genhd.c +@@ -383,16 +383,18 @@ int disk_scan_partitions(struct gendisk + } + + /** +- * device_add_disk - add disk information to kernel list ++ * add_disk_fwnode - add disk information to kernel list with fwnode + * @parent: parent device for the disk + * @disk: per-device partitioning information + * @groups: Additional per-device sysfs groups ++ * @fwnode: attached disk fwnode + * + * This function registers the partitioning information in @disk +- * with the kernel. ++ * with the kernel. Also attach a fwnode to the disk device. + */ +-int __must_check device_add_disk(struct device *parent, struct gendisk *disk, +- const struct attribute_group **groups) ++int __must_check add_disk_fwnode(struct device *parent, struct gendisk *disk, ++ const struct attribute_group **groups, ++ struct fwnode_handle *fwnode) + + { + struct device *ddev = disk_to_dev(disk); +@@ -452,6 +454,8 @@ int __must_check device_add_disk(struct + ddev->parent = parent; + ddev->groups = groups; + dev_set_name(ddev, "%s", disk->disk_name); ++ if (fwnode) ++ device_set_node(ddev, fwnode); + if (!(disk->flags & GENHD_FL_HIDDEN)) + ddev->devt = MKDEV(disk->major, disk->first_minor); + ret = device_add(ddev); +@@ -553,6 +557,22 @@ out_exit_elevator: + elevator_exit(disk->queue); + return ret; + } ++EXPORT_SYMBOL_GPL(add_disk_fwnode); ++ ++/** ++ * device_add_disk - add disk information to kernel list ++ * @parent: parent device for the disk ++ * @disk: per-device partitioning information ++ * @groups: Additional per-device sysfs groups ++ * ++ * This function registers the partitioning information in @disk ++ * with the kernel. ++ */ ++int __must_check device_add_disk(struct device *parent, struct gendisk *disk, ++ const struct attribute_group **groups) ++{ ++ return add_disk_fwnode(parent, disk, groups, NULL); ++} + EXPORT_SYMBOL(device_add_disk); + + static void blk_report_disk_dead(struct gendisk *disk, bool surprise) +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -789,6 +789,9 @@ static inline unsigned int blk_queue_dep + #define for_each_bio(_bio) \ + for (; _bio; _bio = _bio->bi_next) + ++int __must_check add_disk_fwnode(struct device *parent, struct gendisk *disk, ++ const struct attribute_group **groups, ++ struct fwnode_handle *fwnode); + int __must_check device_add_disk(struct device *parent, struct gendisk *disk, + const struct attribute_group **groups); + static inline int __must_check add_disk(struct gendisk *disk) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-03-v6.13-mmc-block-attach-partitions-fwnode-if-found-in-mmc-c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-03-v6.13-mmc-block-attach-partitions-fwnode-if-found-in-mmc-c.patch new file mode 100755 index 0000000..0bdeaa8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-03-v6.13-mmc-block-attach-partitions-fwnode-if-found-in-mmc-c.patch @@ -0,0 +1,104 @@ +From 45ff6c340ddfc2dade74d5b7a8962c778ab7042c Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 3 Oct 2024 00:11:44 +0200 +Subject: [PATCH 4/5] mmc: block: attach partitions fwnode if found in mmc-card + +Attach partitions fwnode if found in mmc-card and register disk with it. + +This permits block partition to reference the node and register a +partition table defined in DT for the special case for embedded device +that doesn't have a partition table flashed but have an hardcoded +partition table passed from the system. + +JEDEC BOOT partition boot0/boot1 are supported but in DT we refer with +the JEDEC name of boot1 and boot2 to better adhere to documentation. + +Also JEDEC GP partition gp0/1/2/3 are supported but in DT we refer with +the JEDEC name of gp1/2/3/4 to better adhere to documentration. + +Signed-off-by: Christian Marangi +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20241002221306.4403-5-ansuelsmth@gmail.com +Signed-off-by: Jens Axboe +--- + drivers/mmc/core/block.c | 55 +++++++++++++++++++++++++++++++++++++++- + 1 file changed, 54 insertions(+), 1 deletion(-) + +--- a/drivers/mmc/core/block.c ++++ b/drivers/mmc/core/block.c +@@ -2517,6 +2517,56 @@ static inline int mmc_blk_readonly(struc + !(card->csd.cmdclass & CCC_BLOCK_WRITE); + } + ++/* ++ * Search for a declared partitions node for the disk in mmc-card related node. ++ * ++ * This is to permit support for partition table defined in DT in special case ++ * where a partition table is not written in the disk and is expected to be ++ * passed from the running system. ++ * ++ * For the user disk, "partitions" node is searched. ++ * For the special HW disk, "partitions-" node with the appended name is used ++ * following this conversion table (to adhere to JEDEC naming) ++ * - boot0 -> partitions-boot1 ++ * - boot1 -> partitions-boot2 ++ * - gp0 -> partitions-gp1 ++ * - gp1 -> partitions-gp2 ++ * - gp2 -> partitions-gp3 ++ * - gp3 -> partitions-gp4 ++ */ ++static struct fwnode_handle *mmc_blk_get_partitions_node(struct device *mmc_dev, ++ const char *subname) ++{ ++ const char *node_name = "partitions"; ++ ++ if (subname) { ++ mmc_dev = mmc_dev->parent; ++ ++ /* ++ * Check if we are allocating a BOOT disk boot0/1 disk. ++ * In DT we use the JEDEC naming boot1/2. ++ */ ++ if (!strcmp(subname, "boot0")) ++ node_name = "partitions-boot1"; ++ if (!strcmp(subname, "boot1")) ++ node_name = "partitions-boot2"; ++ /* ++ * Check if we are allocating a GP disk gp0/1/2/3 disk. ++ * In DT we use the JEDEC naming gp1/2/3/4. ++ */ ++ if (!strcmp(subname, "gp0")) ++ node_name = "partitions-gp1"; ++ if (!strcmp(subname, "gp1")) ++ node_name = "partitions-gp2"; ++ if (!strcmp(subname, "gp2")) ++ node_name = "partitions-gp3"; ++ if (!strcmp(subname, "gp3")) ++ node_name = "partitions-gp4"; ++ } ++ ++ return device_get_named_child_node(mmc_dev, node_name); ++} ++ + static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, + struct device *parent, + sector_t size, +@@ -2525,6 +2575,7 @@ static struct mmc_blk_data *mmc_blk_allo + int area_type, + unsigned int part_type) + { ++ struct fwnode_handle *disk_fwnode; + struct mmc_blk_data *md; + int devidx, ret; + char cap_str[10]; +@@ -2626,7 +2677,9 @@ static struct mmc_blk_data *mmc_blk_allo + /* used in ->open, must be set before add_disk: */ + if (area_type == MMC_BLK_DATA_AREA_MAIN) + dev_set_drvdata(&card->dev, md); +- ret = device_add_disk(md->parent, md->disk, mmc_disk_attr_groups); ++ disk_fwnode = mmc_blk_get_partitions_node(parent, subname); ++ ret = add_disk_fwnode(md->parent, md->disk, mmc_disk_attr_groups, ++ disk_fwnode); + if (ret) + goto err_put_disk; + return md; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-04-v6.13-block-add-support-for-partition-table-defined-in-OF.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-04-v6.13-block-add-support-for-partition-table-defined-in-OF.patch new file mode 100755 index 0000000..d260be1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/500-04-v6.13-block-add-support-for-partition-table-defined-in-OF.patch @@ -0,0 +1,200 @@ +From 884555b557e5e6d41c866e2cd8d7b32f50ec974b Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 3 Oct 2024 00:11:45 +0200 +Subject: [PATCH 5/5] block: add support for partition table defined in OF + +Add support for partition table defined in Device Tree. Similar to how +it's done with MTD, add support for defining a fixed partition table in +device tree. + +A common scenario for this is fixed block (eMMC) embedded devices that +have no MBR or GPT partition table to save storage space. Bootloader +access the block device with absolute address of data. + +This is to complete the functionality with an equivalent implementation +with providing partition table with bootargs, for case where the booargs +can't be modified and tweaking the Device Tree is the only solution to +have an usabe partition table. + +The implementation follow the fixed-partitions parser used on MTD +devices where a "partitions" node is expected to be declared with +"fixed-partitions" compatible in the OF node of the disk device +(mmc-card for eMMC for example) and each child node declare a label +and a reg with offset and size. If label is not declared, the node name +is used as fallback. Eventually is also possible to declare the read-only +property to flag the partition as read-only. + +Signed-off-by: Christian Marangi +Reviewed-by: Christoph Hellwig +Link: https://lore.kernel.org/r/20241002221306.4403-6-ansuelsmth@gmail.com +Signed-off-by: Jens Axboe +--- + block/partitions/Kconfig | 9 ++++ + block/partitions/Makefile | 1 + + block/partitions/check.h | 1 + + block/partitions/core.c | 3 ++ + block/partitions/of.c | 110 ++++++++++++++++++++++++++++++++++++++ + 5 files changed, 124 insertions(+) + create mode 100644 block/partitions/of.c + +--- a/block/partitions/Kconfig ++++ b/block/partitions/Kconfig +@@ -270,4 +270,13 @@ config CMDLINE_PARTITION + Say Y here if you want to read the partition table from bootargs. + The format for the command line is just like mtdparts. + ++config OF_PARTITION ++ bool "Device Tree partition support" if PARTITION_ADVANCED ++ depends on OF ++ help ++ Say Y here if you want to enable support for partition table ++ defined in Device Tree. (mainly for eMMC) ++ The format for the device tree node is just like MTD fixed-partition ++ schema. ++ + endmenu +--- a/block/partitions/Makefile ++++ b/block/partitions/Makefile +@@ -12,6 +12,7 @@ obj-$(CONFIG_CMDLINE_PARTITION) += cmdli + obj-$(CONFIG_MAC_PARTITION) += mac.o + obj-$(CONFIG_LDM_PARTITION) += ldm.o + obj-$(CONFIG_MSDOS_PARTITION) += msdos.o ++obj-$(CONFIG_OF_PARTITION) += of.o + obj-$(CONFIG_OSF_PARTITION) += osf.o + obj-$(CONFIG_SGI_PARTITION) += sgi.o + obj-$(CONFIG_SUN_PARTITION) += sun.o +--- a/block/partitions/check.h ++++ b/block/partitions/check.h +@@ -62,6 +62,7 @@ int karma_partition(struct parsed_partit + int ldm_partition(struct parsed_partitions *state); + int mac_partition(struct parsed_partitions *state); + int msdos_partition(struct parsed_partitions *state); ++int of_partition(struct parsed_partitions *state); + int osf_partition(struct parsed_partitions *state); + int sgi_partition(struct parsed_partitions *state); + int sun_partition(struct parsed_partitions *state); +--- a/block/partitions/core.c ++++ b/block/partitions/core.c +@@ -43,6 +43,9 @@ static int (*const check_part[])(struct + #ifdef CONFIG_CMDLINE_PARTITION + cmdline_partition, + #endif ++#ifdef CONFIG_OF_PARTITION ++ of_partition, /* cmdline have priority to OF */ ++#endif + #ifdef CONFIG_EFI_PARTITION + efi_partition, /* this must come before msdos */ + #endif +--- /dev/null ++++ b/block/partitions/of.c +@@ -0,0 +1,110 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++#include ++#include ++#include "check.h" ++ ++static int validate_of_partition(struct device_node *np, int slot) ++{ ++ u64 offset, size; ++ int len; ++ ++ const __be32 *reg = of_get_property(np, "reg", &len); ++ int a_cells = of_n_addr_cells(np); ++ int s_cells = of_n_size_cells(np); ++ ++ /* Make sure reg len match the expected addr and size cells */ ++ if (len / sizeof(*reg) != a_cells + s_cells) ++ return -EINVAL; ++ ++ /* Validate offset conversion from bytes to sectors */ ++ offset = of_read_number(reg, a_cells); ++ if (offset % SECTOR_SIZE) ++ return -EINVAL; ++ ++ /* Validate size conversion from bytes to sectors */ ++ size = of_read_number(reg + a_cells, s_cells); ++ if (!size || size % SECTOR_SIZE) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static void add_of_partition(struct parsed_partitions *state, int slot, ++ struct device_node *np) ++{ ++ struct partition_meta_info *info; ++ char tmp[sizeof(info->volname) + 4]; ++ const char *partname; ++ int len; ++ ++ const __be32 *reg = of_get_property(np, "reg", &len); ++ int a_cells = of_n_addr_cells(np); ++ int s_cells = of_n_size_cells(np); ++ ++ /* Convert bytes to sector size */ ++ u64 offset = of_read_number(reg, a_cells) / SECTOR_SIZE; ++ u64 size = of_read_number(reg + a_cells, s_cells) / SECTOR_SIZE; ++ ++ put_partition(state, slot, offset, size); ++ ++ if (of_property_read_bool(np, "read-only")) ++ state->parts[slot].flags |= ADDPART_FLAG_READONLY; ++ ++ /* ++ * Follow MTD label logic, search for label property, ++ * fallback to node name if not found. ++ */ ++ info = &state->parts[slot].info; ++ partname = of_get_property(np, "label", &len); ++ if (!partname) ++ partname = of_get_property(np, "name", &len); ++ strscpy(info->volname, partname, sizeof(info->volname)); ++ ++ snprintf(tmp, sizeof(tmp), "(%s)", info->volname); ++ strlcat(state->pp_buf, tmp, PAGE_SIZE); ++} ++ ++int of_partition(struct parsed_partitions *state) ++{ ++ struct device *ddev = disk_to_dev(state->disk); ++ struct device_node *np; ++ int slot; ++ ++ struct device_node *partitions_np = of_node_get(ddev->of_node); ++ ++ if (!partitions_np || ++ !of_device_is_compatible(partitions_np, "fixed-partitions")) ++ return 0; ++ ++ slot = 1; ++ /* Validate parition offset and size */ ++ for_each_child_of_node(partitions_np, np) { ++ if (validate_of_partition(np, slot)) { ++ of_node_put(np); ++ of_node_put(partitions_np); ++ ++ return -1; ++ } ++ ++ slot++; ++ } ++ ++ slot = 1; ++ for_each_child_of_node(partitions_np, np) { ++ if (slot >= state->limit) { ++ of_node_put(np); ++ break; ++ } ++ ++ add_of_partition(state, slot, np); ++ ++ slot++; ++ } ++ ++ strlcat(state->pp_buf, "\n", PAGE_SIZE); ++ ++ return 1; ++} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-01-v6.13-net-phylink-move-manual-flow-control-setting.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-01-v6.13-net-phylink-move-manual-flow-control-setting.patch new file mode 100755 index 0000000..a9b86c2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-01-v6.13-net-phylink-move-manual-flow-control-setting.patch @@ -0,0 +1,41 @@ +From 8cc5f4cb94c0b1c7c1ba8013c14fd02ffb1a25f3 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Fri, 8 Nov 2024 16:01:44 +0000 +Subject: [PATCH 1/5] net: phylink: move manual flow control setting + +Move the handling of manual flow control configuration to a common +location during resolve. We currently evaluate this for all but +fixed links. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1t9RQe-002Feh-T1@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1484,7 +1484,6 @@ static void phylink_resolve(struct work_ + switch (pl->cur_link_an_mode) { + case MLO_AN_PHY: + link_state = pl->phy_state; +- phylink_apply_manual_flow(pl, &link_state); + mac_config = link_state.link; + break; + +@@ -1545,11 +1544,13 @@ static void phylink_resolve(struct work_ + link_state.pause = pl->phy_state.pause; + mac_config = true; + } +- phylink_apply_manual_flow(pl, &link_state); + break; + } + } + ++ if (pl->cur_link_an_mode != MLO_AN_FIXED) ++ phylink_apply_manual_flow(pl, &link_state); ++ + if (mac_config) { + if (link_state.interface != pl->link_config.interface) { + /* The interface has changed, force the link down and diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-02-v6.13-net-phylink-move-MLO_AN_FIXED-resolve-handling-to-if.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-02-v6.13-net-phylink-move-MLO_AN_FIXED-resolve-handling-to-if.patch new file mode 100755 index 0000000..7ff091e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-02-v6.13-net-phylink-move-MLO_AN_FIXED-resolve-handling-to-if.patch @@ -0,0 +1,42 @@ +From 92abfcb4ced482afbe65d18980e6734fe1e62a34 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Fri, 8 Nov 2024 16:01:50 +0000 +Subject: [PATCH 2/5] net: phylink: move MLO_AN_FIXED resolve handling to if() + statement + +The switch() statement doesn't sit very well with the preceeding if() +statements, and results in excessive indentation that spoils code +readability. Begin cleaning this up by converting the MLO_AN_FIXED case +to an if() statement. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1t9RQk-002Fen-1A@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1480,6 +1480,9 @@ static void phylink_resolve(struct work_ + } else if (pl->link_failed) { + link_state.link = false; + retrigger = true; ++ } else if (pl->cur_link_an_mode == MLO_AN_FIXED) { ++ phylink_get_fixed_state(pl, &link_state); ++ mac_config = link_state.link; + } else { + switch (pl->cur_link_an_mode) { + case MLO_AN_PHY: +@@ -1487,11 +1490,6 @@ static void phylink_resolve(struct work_ + mac_config = link_state.link; + break; + +- case MLO_AN_FIXED: +- phylink_get_fixed_state(pl, &link_state); +- mac_config = link_state.link; +- break; +- + case MLO_AN_INBAND: + phylink_mac_pcs_get_state(pl, &link_state); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-03-v6.13-net-phylink-move-MLO_AN_PHY-resolve-handling-to-if-s.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-03-v6.13-net-phylink-move-MLO_AN_PHY-resolve-handling-to-if-s.patch new file mode 100755 index 0000000..76e76fb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-03-v6.13-net-phylink-move-MLO_AN_PHY-resolve-handling-to-if-s.patch @@ -0,0 +1,37 @@ +From f0f46c2a3d8ea9d1427298c8103a777d9e616c29 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Fri, 8 Nov 2024 16:01:55 +0000 +Subject: [PATCH 3/5] net: phylink: move MLO_AN_PHY resolve handling to if() + statement + +The switch() statement doesn't sit very well with the preceeding if() +statements, and results in excessive indentation that spoils code +readability. Continue cleaning this up by converting the MLO_AN_PHY +case to use an if() statmeent. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1t9RQp-002Fet-5W@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1483,13 +1483,11 @@ static void phylink_resolve(struct work_ + } else if (pl->cur_link_an_mode == MLO_AN_FIXED) { + phylink_get_fixed_state(pl, &link_state); + mac_config = link_state.link; ++ } else if (pl->cur_link_an_mode == MLO_AN_PHY) { ++ link_state = pl->phy_state; ++ mac_config = link_state.link; + } else { + switch (pl->cur_link_an_mode) { +- case MLO_AN_PHY: +- link_state = pl->phy_state; +- mac_config = link_state.link; +- break; +- + case MLO_AN_INBAND: + phylink_mac_pcs_get_state(pl, &link_state); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-04-v6.13-net-phylink-remove-switch-statement-in-resolve-handl.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-04-v6.13-net-phylink-remove-switch-statement-in-resolve-handl.patch new file mode 100755 index 0000000..989fc10 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-04-v6.13-net-phylink-remove-switch-statement-in-resolve-handl.patch @@ -0,0 +1,127 @@ +From d1a16dbbd84e02d2a6dcfcb8d5c4b8b2c0289f00 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Fri, 8 Nov 2024 16:02:00 +0000 +Subject: [PATCH 4/5] net: phylink: remove switch() statement in resolve + handling + +The switch() statement doesn't sit very well with the preceeding if() +statements, so let's just convert everything to if()s. As a result of +the two preceding commits, there is now only one case in the switch() +statement. Remove the switch statement and reduce the code indentation. +Code reformatting will be in the following commit. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1t9RQu-002Fez-AA@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 94 +++++++++++++++++++-------------------- + 1 file changed, 45 insertions(+), 49 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1487,60 +1487,56 @@ static void phylink_resolve(struct work_ + link_state = pl->phy_state; + mac_config = link_state.link; + } else { +- switch (pl->cur_link_an_mode) { +- case MLO_AN_INBAND: +- phylink_mac_pcs_get_state(pl, &link_state); +- +- /* The PCS may have a latching link-fail indicator. +- * If the link was up, bring the link down and +- * re-trigger the resolve. Otherwise, re-read the +- * PCS state to get the current status of the link. ++ phylink_mac_pcs_get_state(pl, &link_state); ++ ++ /* The PCS may have a latching link-fail indicator. ++ * If the link was up, bring the link down and ++ * re-trigger the resolve. Otherwise, re-read the ++ * PCS state to get the current status of the link. ++ */ ++ if (!link_state.link) { ++ if (cur_link_state) ++ retrigger = true; ++ else ++ phylink_mac_pcs_get_state(pl, ++ &link_state); ++ } ++ ++ /* If we have a phy, the "up" state is the union of ++ * both the PHY and the MAC ++ */ ++ if (pl->phydev) ++ link_state.link &= pl->phy_state.link; ++ ++ /* Only update if the PHY link is up */ ++ if (pl->phydev && pl->phy_state.link) { ++ /* If the interface has changed, force a ++ * link down event if the link isn't already ++ * down, and re-resolve. + */ +- if (!link_state.link) { +- if (cur_link_state) +- retrigger = true; +- else +- phylink_mac_pcs_get_state(pl, +- &link_state); ++ if (link_state.interface != ++ pl->phy_state.interface) { ++ retrigger = true; ++ link_state.link = false; + } ++ link_state.interface = pl->phy_state.interface; + +- /* If we have a phy, the "up" state is the union of +- * both the PHY and the MAC ++ /* If we are doing rate matching, then the ++ * link speed/duplex comes from the PHY + */ +- if (pl->phydev) +- link_state.link &= pl->phy_state.link; +- +- /* Only update if the PHY link is up */ +- if (pl->phydev && pl->phy_state.link) { +- /* If the interface has changed, force a +- * link down event if the link isn't already +- * down, and re-resolve. +- */ +- if (link_state.interface != +- pl->phy_state.interface) { +- retrigger = true; +- link_state.link = false; +- } +- link_state.interface = pl->phy_state.interface; +- +- /* If we are doing rate matching, then the +- * link speed/duplex comes from the PHY +- */ +- if (pl->phy_state.rate_matching) { +- link_state.rate_matching = +- pl->phy_state.rate_matching; +- link_state.speed = pl->phy_state.speed; +- link_state.duplex = +- pl->phy_state.duplex; +- } +- +- /* If we have a PHY, we need to update with +- * the PHY flow control bits. +- */ +- link_state.pause = pl->phy_state.pause; +- mac_config = true; ++ if (pl->phy_state.rate_matching) { ++ link_state.rate_matching = ++ pl->phy_state.rate_matching; ++ link_state.speed = pl->phy_state.speed; ++ link_state.duplex = ++ pl->phy_state.duplex; + } +- break; ++ ++ /* If we have a PHY, we need to update with ++ * the PHY flow control bits. ++ */ ++ link_state.pause = pl->phy_state.pause; ++ mac_config = true; + } + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-05-v6.13-net-phylink-clean-up-phylink_resolve.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-05-v6.13-net-phylink-clean-up-phylink_resolve.patch new file mode 100755 index 0000000..285eea8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/600-05-v6.13-net-phylink-clean-up-phylink_resolve.patch @@ -0,0 +1,85 @@ +From bc08ce37d99a3992e975a0f397503cb23404f25a Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Fri, 8 Nov 2024 16:02:05 +0000 +Subject: [PATCH 5/5] net: phylink: clean up phylink_resolve() + +Now that we have reduced the indentation level, clean up the code +formatting. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1t9RQz-002Ff5-EA@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 35 ++++++++++++++++------------------- + 1 file changed, 16 insertions(+), 19 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1489,51 +1489,48 @@ static void phylink_resolve(struct work_ + } else { + phylink_mac_pcs_get_state(pl, &link_state); + +- /* The PCS may have a latching link-fail indicator. +- * If the link was up, bring the link down and +- * re-trigger the resolve. Otherwise, re-read the +- * PCS state to get the current status of the link. ++ /* The PCS may have a latching link-fail indicator. If the link ++ * was up, bring the link down and re-trigger the resolve. ++ * Otherwise, re-read the PCS state to get the current status ++ * of the link. + */ + if (!link_state.link) { + if (cur_link_state) + retrigger = true; + else +- phylink_mac_pcs_get_state(pl, +- &link_state); ++ phylink_mac_pcs_get_state(pl, &link_state); + } + +- /* If we have a phy, the "up" state is the union of +- * both the PHY and the MAC ++ /* If we have a phy, the "up" state is the union of both the ++ * PHY and the MAC + */ + if (pl->phydev) + link_state.link &= pl->phy_state.link; + + /* Only update if the PHY link is up */ + if (pl->phydev && pl->phy_state.link) { +- /* If the interface has changed, force a +- * link down event if the link isn't already +- * down, and re-resolve. ++ /* If the interface has changed, force a link down ++ * event if the link isn't already down, and re-resolve. + */ +- if (link_state.interface != +- pl->phy_state.interface) { ++ if (link_state.interface != pl->phy_state.interface) { + retrigger = true; + link_state.link = false; + } ++ + link_state.interface = pl->phy_state.interface; + +- /* If we are doing rate matching, then the +- * link speed/duplex comes from the PHY ++ /* If we are doing rate matching, then the link ++ * speed/duplex comes from the PHY + */ + if (pl->phy_state.rate_matching) { + link_state.rate_matching = + pl->phy_state.rate_matching; + link_state.speed = pl->phy_state.speed; +- link_state.duplex = +- pl->phy_state.duplex; ++ link_state.duplex = pl->phy_state.duplex; + } + +- /* If we have a PHY, we need to update with +- * the PHY flow control bits. ++ /* If we have a PHY, we need to update with the PHY ++ * flow control bits. + */ + link_state.pause = pl->phy_state.pause; + mac_config = true; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-01-v6.14-net-phylink-pass-phylink-and-pcs-into-phylink_pcs_ne.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-01-v6.14-net-phylink-pass-phylink-and-pcs-into-phylink_pcs_ne.patch new file mode 100755 index 0000000..6868cd1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-01-v6.14-net-phylink-pass-phylink-and-pcs-into-phylink_pcs_ne.patch @@ -0,0 +1,95 @@ +From 17ed1911f9c8d4f9af8e13b2c95103ee06dadc0f Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:30:47 +0000 +Subject: [PATCH 01/13] net: phylink: pass phylink and pcs into + phylink_pcs_neg_mode() + +Move the call to phylink_pcs_neg_mode() in phylink_major_config() after +we have selected the appropriate PCS to allow the PCS to be passed in. + +Add struct phylink and struct phylink_pcs pointers to +phylink_pcs_neg_mode() and pass in the appropriate structures. Set +pl->pcs_neg_mode before returning, and remove the return value. + +This will allow the capabilities of the PCS and any PHY to be used when +deciding which pcs_neg_mode should be used. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUrP-006ITh-6u@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1102,7 +1102,8 @@ static void phylink_pcs_an_restart(struc + + /** + * phylink_pcs_neg_mode() - helper to determine PCS inband mode +- * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND. ++ * @pl: a pointer to a &struct phylink returned from phylink_create() ++ * @pcs: a pointer to &struct phylink_pcs + * @interface: interface mode to be used + * @advertising: adertisement ethtool link mode mask + * +@@ -1119,11 +1120,13 @@ static void phylink_pcs_an_restart(struc + * Note: this is for cases where the PCS itself is involved in negotiation + * (e.g. Clause 37, SGMII and similar) not Clause 73. + */ +-static unsigned int phylink_pcs_neg_mode(unsigned int mode, +- phy_interface_t interface, +- const unsigned long *advertising) ++static void phylink_pcs_neg_mode(struct phylink *pl, struct phylink_pcs *pcs, ++ phy_interface_t interface, ++ const unsigned long *advertising) + { +- unsigned int neg_mode; ++ unsigned int neg_mode, mode; ++ ++ mode = pl->cur_link_an_mode; + + switch (interface) { + case PHY_INTERFACE_MODE_SGMII: +@@ -1164,7 +1167,7 @@ static unsigned int phylink_pcs_neg_mode + break; + } + +- return neg_mode; ++ pl->pcs_neg_mode = neg_mode; + } + + static void phylink_major_config(struct phylink *pl, bool restart, +@@ -1178,10 +1181,6 @@ static void phylink_major_config(struct + + phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); + +- pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, +- state->interface, +- state->advertising); +- + if (pl->using_mac_select_pcs) { + pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); + if (IS_ERR(pcs)) { +@@ -1194,6 +1193,8 @@ static void phylink_major_config(struct + pcs_changed = pcs && pl->pcs != pcs; + } + ++ phylink_pcs_neg_mode(pl, pcs, state->interface, state->advertising); ++ + phylink_pcs_poll_stop(pl); + + if (pl->mac_ops->mac_prepare) { +@@ -1284,9 +1285,8 @@ static int phylink_change_inband_advert( + pl->link_config.pause); + + /* Recompute the PCS neg mode */ +- pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, +- pl->link_config.interface, +- pl->link_config.advertising); ++ phylink_pcs_neg_mode(pl, pl->pcs, pl->link_config.interface, ++ pl->link_config.advertising); + + neg_mode = pl->cur_link_an_mode; + if (pl->pcs->neg_mode) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-02-v6.14-net-phylink-split-cur_link_an_mode-into-requested-an.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-02-v6.14-net-phylink-split-cur_link_an_mode-into-requested-an.patch new file mode 100755 index 0000000..76f4d5a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-02-v6.14-net-phylink-split-cur_link_an_mode-into-requested-an.patch @@ -0,0 +1,290 @@ +From 1f92ead7e15003f632b5f138e8138095e0997d3d Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:30:52 +0000 +Subject: [PATCH 02/13] net: phylink: split cur_link_an_mode into requested and + active + +There is an interdependence between the current link_an_mode and +pcs_neg_mode that some drivers rely upon to know whether inband or PHY +mode will be used. + +In order to support detection of PCS and PHY inband capabilities +resulting in automatic selection of inband or PHY mode, we need to +cater for this, and support changing the MAC link_an_mode. However, we +end up with an inter-dependency between the current link_an_mode and +pcs_neg_mode. + +To solve this, split the current link_an_mode into the requested +link_an_mode and active link_an_mode. The requested link_an_mode will +always be passed to phylink_pcs_neg_mode(), and the active link_an_mode +will be used for everything else, and only updated during +phylink_major_config(). This will ensure that phylink_pcs_neg_mode()'s +link_an_mode will not depend on the active link_an_mode that will, +in a future patch, depend on pcs_neg_mode. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUrU-006ITn-Ai@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 60 ++++++++++++++++++++------------------- + 1 file changed, 31 insertions(+), 29 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -56,7 +56,8 @@ struct phylink { + struct phy_device *phydev; + phy_interface_t link_interface; /* PHY_INTERFACE_xxx */ + u8 cfg_link_an_mode; /* MLO_AN_xxx */ +- u8 cur_link_an_mode; ++ u8 req_link_an_mode; /* Requested MLO_AN_xxx mode */ ++ u8 act_link_an_mode; /* Active MLO_AN_xxx mode */ + u8 link_port; /* The current non-phy ethtool port */ + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); + +@@ -1082,13 +1083,13 @@ static void phylink_mac_config(struct ph + + phylink_dbg(pl, + "%s: mode=%s/%s/%s adv=%*pb pause=%02x\n", +- __func__, phylink_an_mode_str(pl->cur_link_an_mode), ++ __func__, phylink_an_mode_str(pl->act_link_an_mode), + phy_modes(st.interface), + phy_rate_matching_to_str(st.rate_matching), + __ETHTOOL_LINK_MODE_MASK_NBITS, st.advertising, + st.pause); + +- pl->mac_ops->mac_config(pl->config, pl->cur_link_an_mode, &st); ++ pl->mac_ops->mac_config(pl->config, pl->act_link_an_mode, &st); + } + + static void phylink_pcs_an_restart(struct phylink *pl) +@@ -1096,7 +1097,7 @@ static void phylink_pcs_an_restart(struc + if (pl->pcs && linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + pl->link_config.advertising) && + phy_interface_mode_is_8023z(pl->link_config.interface) && +- phylink_autoneg_inband(pl->cur_link_an_mode)) ++ phylink_autoneg_inband(pl->act_link_an_mode)) + pl->pcs->ops->pcs_an_restart(pl->pcs); + } + +@@ -1126,7 +1127,7 @@ static void phylink_pcs_neg_mode(struct + { + unsigned int neg_mode, mode; + +- mode = pl->cur_link_an_mode; ++ mode = pl->req_link_an_mode; + + switch (interface) { + case PHY_INTERFACE_MODE_SGMII: +@@ -1168,6 +1169,7 @@ static void phylink_pcs_neg_mode(struct + } + + pl->pcs_neg_mode = neg_mode; ++ pl->act_link_an_mode = mode; + } + + static void phylink_major_config(struct phylink *pl, bool restart, +@@ -1198,7 +1200,7 @@ static void phylink_major_config(struct + phylink_pcs_poll_stop(pl); + + if (pl->mac_ops->mac_prepare) { +- err = pl->mac_ops->mac_prepare(pl->config, pl->cur_link_an_mode, ++ err = pl->mac_ops->mac_prepare(pl->config, pl->act_link_an_mode, + state->interface); + if (err < 0) { + phylink_err(pl, "mac_prepare failed: %pe\n", +@@ -1232,7 +1234,7 @@ static void phylink_major_config(struct + if (pl->pcs_state == PCS_STATE_STARTING || pcs_changed) + phylink_pcs_enable(pl->pcs); + +- neg_mode = pl->cur_link_an_mode; ++ neg_mode = pl->act_link_an_mode; + if (pl->pcs && pl->pcs->neg_mode) + neg_mode = pl->pcs_neg_mode; + +@@ -1248,7 +1250,7 @@ static void phylink_major_config(struct + phylink_pcs_an_restart(pl); + + if (pl->mac_ops->mac_finish) { +- err = pl->mac_ops->mac_finish(pl->config, pl->cur_link_an_mode, ++ err = pl->mac_ops->mac_finish(pl->config, pl->act_link_an_mode, + state->interface); + if (err < 0) + phylink_err(pl, "mac_finish failed: %pe\n", +@@ -1279,7 +1281,7 @@ static int phylink_change_inband_advert( + return 0; + + phylink_dbg(pl, "%s: mode=%s/%s adv=%*pb pause=%02x\n", __func__, +- phylink_an_mode_str(pl->cur_link_an_mode), ++ phylink_an_mode_str(pl->req_link_an_mode), + phy_modes(pl->link_config.interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, pl->link_config.advertising, + pl->link_config.pause); +@@ -1288,7 +1290,7 @@ static int phylink_change_inband_advert( + phylink_pcs_neg_mode(pl, pl->pcs, pl->link_config.interface, + pl->link_config.advertising); + +- neg_mode = pl->cur_link_an_mode; ++ neg_mode = pl->act_link_an_mode; + if (pl->pcs->neg_mode) + neg_mode = pl->pcs_neg_mode; + +@@ -1353,7 +1355,7 @@ static void phylink_mac_initial_config(s + { + struct phylink_link_state link_state; + +- switch (pl->cur_link_an_mode) { ++ switch (pl->req_link_an_mode) { + case MLO_AN_PHY: + link_state = pl->phy_state; + break; +@@ -1427,14 +1429,14 @@ static void phylink_link_up(struct phyli + + pl->cur_interface = link_state.interface; + +- neg_mode = pl->cur_link_an_mode; ++ neg_mode = pl->act_link_an_mode; + if (pl->pcs && pl->pcs->neg_mode) + neg_mode = pl->pcs_neg_mode; + + phylink_pcs_link_up(pl->pcs, neg_mode, pl->cur_interface, speed, + duplex); + +- pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->cur_link_an_mode, ++ pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->act_link_an_mode, + pl->cur_interface, speed, duplex, + !!(link_state.pause & MLO_PAUSE_TX), rx_pause); + +@@ -1454,7 +1456,7 @@ static void phylink_link_down(struct phy + + if (ndev) + netif_carrier_off(ndev); +- pl->mac_ops->mac_link_down(pl->config, pl->cur_link_an_mode, ++ pl->mac_ops->mac_link_down(pl->config, pl->act_link_an_mode, + pl->cur_interface); + phylink_info(pl, "Link is Down\n"); + } +@@ -1480,10 +1482,10 @@ static void phylink_resolve(struct work_ + } else if (pl->link_failed) { + link_state.link = false; + retrigger = true; +- } else if (pl->cur_link_an_mode == MLO_AN_FIXED) { ++ } else if (pl->act_link_an_mode == MLO_AN_FIXED) { + phylink_get_fixed_state(pl, &link_state); + mac_config = link_state.link; +- } else if (pl->cur_link_an_mode == MLO_AN_PHY) { ++ } else if (pl->act_link_an_mode == MLO_AN_PHY) { + link_state = pl->phy_state; + mac_config = link_state.link; + } else { +@@ -1537,7 +1539,7 @@ static void phylink_resolve(struct work_ + } + } + +- if (pl->cur_link_an_mode != MLO_AN_FIXED) ++ if (pl->act_link_an_mode != MLO_AN_FIXED) + phylink_apply_manual_flow(pl, &link_state); + + if (mac_config) { +@@ -1661,7 +1663,7 @@ int phylink_set_fixed_link(struct phylin + pl->link_config.an_complete = 1; + + pl->cfg_link_an_mode = MLO_AN_FIXED; +- pl->cur_link_an_mode = pl->cfg_link_an_mode; ++ pl->req_link_an_mode = pl->cfg_link_an_mode; + + return 0; + } +@@ -1756,7 +1758,7 @@ struct phylink *phylink_create(struct ph + } + } + +- pl->cur_link_an_mode = pl->cfg_link_an_mode; ++ pl->req_link_an_mode = pl->cfg_link_an_mode; + + ret = phylink_register_sfp(pl, fwnode); + if (ret < 0) { +@@ -2213,7 +2215,7 @@ void phylink_start(struct phylink *pl) + ASSERT_RTNL(); + + phylink_info(pl, "configuring for %s/%s link mode\n", +- phylink_an_mode_str(pl->cur_link_an_mode), ++ phylink_an_mode_str(pl->req_link_an_mode), + phy_modes(pl->link_config.interface)); + + /* Always set the carrier off */ +@@ -2472,7 +2474,7 @@ int phylink_ethtool_ksettings_get(struct + + linkmode_copy(kset->link_modes.supported, pl->supported); + +- switch (pl->cur_link_an_mode) { ++ switch (pl->act_link_an_mode) { + case MLO_AN_FIXED: + /* We are using fixed settings. Report these as the + * current link settings - and note that these also +@@ -2564,7 +2566,7 @@ int phylink_ethtool_ksettings_set(struct + /* If we have a fixed link, refuse to change link parameters. + * If the link parameters match, accept them but do nothing. + */ +- if (pl->cur_link_an_mode == MLO_AN_FIXED) { ++ if (pl->req_link_an_mode == MLO_AN_FIXED) { + if (s->speed != pl->link_config.speed || + s->duplex != pl->link_config.duplex) + return -EINVAL; +@@ -2580,7 +2582,7 @@ int phylink_ethtool_ksettings_set(struct + * is our default case) but do not allow the advertisement to + * be changed. If the advertisement matches, simply return. + */ +- if (pl->cur_link_an_mode == MLO_AN_FIXED) { ++ if (pl->req_link_an_mode == MLO_AN_FIXED) { + if (!linkmode_equal(config.advertising, + pl->link_config.advertising)) + return -EINVAL; +@@ -2620,7 +2622,7 @@ int phylink_ethtool_ksettings_set(struct + linkmode_copy(support, pl->supported); + if (phylink_validate(pl, support, &config)) { + phylink_err(pl, "validation of %s/%s with support %*pb failed\n", +- phylink_an_mode_str(pl->cur_link_an_mode), ++ phylink_an_mode_str(pl->req_link_an_mode), + phy_modes(config.interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, support); + return -EINVAL; +@@ -2720,7 +2722,7 @@ int phylink_ethtool_set_pauseparam(struc + + ASSERT_RTNL(); + +- if (pl->cur_link_an_mode == MLO_AN_FIXED) ++ if (pl->req_link_an_mode == MLO_AN_FIXED) + return -EOPNOTSUPP; + + if (!phylink_test(pl->supported, Pause) && +@@ -2984,7 +2986,7 @@ static int phylink_mii_read(struct phyli + struct phylink_link_state state; + int val = 0xffff; + +- switch (pl->cur_link_an_mode) { ++ switch (pl->act_link_an_mode) { + case MLO_AN_FIXED: + if (phy_id == 0) { + phylink_get_fixed_state(pl, &state); +@@ -3009,7 +3011,7 @@ static int phylink_mii_read(struct phyli + static int phylink_mii_write(struct phylink *pl, unsigned int phy_id, + unsigned int reg, unsigned int val) + { +- switch (pl->cur_link_an_mode) { ++ switch (pl->act_link_an_mode) { + case MLO_AN_FIXED: + break; + +@@ -3199,9 +3201,9 @@ static void phylink_sfp_set_config(struc + changed = true; + } + +- if (pl->cur_link_an_mode != mode || ++ if (pl->req_link_an_mode != mode || + pl->link_config.interface != state->interface) { +- pl->cur_link_an_mode = mode; ++ pl->req_link_an_mode = mode; + pl->link_config.interface = state->interface; + + changed = true; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-03-v6.14-net-phylink-add-debug-for-phylink_major_config.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-03-v6.14-net-phylink-add-debug-for-phylink_major_config.patch new file mode 100755 index 0000000..ee625c7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-03-v6.14-net-phylink-add-debug-for-phylink_major_config.patch @@ -0,0 +1,66 @@ +From 4e7d000286fe8e12f2d88032711ffab3ab658b12 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:30:57 +0000 +Subject: [PATCH 03/13] net: phylink: add debug for phylink_major_config() + +Now that we have a more complexity in phylink_major_config(), augment +the debugging so we can see what's going on there. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUrZ-006ITt-Fa@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 27 ++++++++++++++++++++++++++- + 1 file changed, 26 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -176,6 +176,24 @@ static const char *phylink_an_mode_str(u + return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; + } + ++static const char *phylink_pcs_mode_str(unsigned int mode) ++{ ++ if (!mode) ++ return "none"; ++ ++ if (mode & PHYLINK_PCS_NEG_OUTBAND) ++ return "outband"; ++ ++ if (mode & PHYLINK_PCS_NEG_INBAND) { ++ if (mode & PHYLINK_PCS_NEG_ENABLED) ++ return "inband,an-enabled"; ++ else ++ return "inband,an-disabled"; ++ } ++ ++ return "unknown"; ++} ++ + static unsigned int phylink_interface_signal_rate(phy_interface_t interface) + { + switch (interface) { +@@ -1181,7 +1199,9 @@ static void phylink_major_config(struct + unsigned int neg_mode; + int err; + +- phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); ++ phylink_dbg(pl, "major config, requested %s/%s\n", ++ phylink_an_mode_str(pl->req_link_an_mode), ++ phy_modes(state->interface)); + + if (pl->using_mac_select_pcs) { + pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); +@@ -1197,6 +1217,11 @@ static void phylink_major_config(struct + + phylink_pcs_neg_mode(pl, pcs, state->interface, state->advertising); + ++ phylink_dbg(pl, "major config, active %s/%s/%s\n", ++ phylink_an_mode_str(pl->act_link_an_mode), ++ phylink_pcs_mode_str(pl->pcs_neg_mode), ++ phy_modes(state->interface)); ++ + phylink_pcs_poll_stop(pl); + + if (pl->mac_ops->mac_prepare) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-04-v6.14-net-phy-add-phy_inband_caps.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-04-v6.14-net-phy-add-phy_inband_caps.patch new file mode 100755 index 0000000..0cd38f0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-04-v6.14-net-phy-add-phy_inband_caps.patch @@ -0,0 +1,118 @@ +From b4c7698dd95f253c6958d8c6ac219098009bf28a Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:02 +0000 +Subject: [PATCH 04/13] net: phy: add phy_inband_caps() + +Add a method to query the PHY's in-band capabilities for a PHY +interface mode. + +Where the interface mode does not have in-band capability, or the PHY +driver has not been updated to return this information, then +phy_inband_caps() should return zero. Otherwise, PHY drivers will +return a value consisting of the following flags: + +LINK_INBAND_DISABLE indicates that the hardware does not support +in-band signalling, or can have in-band signalling configured via +software to be disabled. + +LINK_INBAND_ENABLE indicates that the hardware will use in-band +signalling, or can have in-band signalling configured via software +to be enabled. + +LINK_INBAND_BYPASS indicates that the hardware has the ability to +bypass in-band signalling when enabled after a timeout if the link +partner does not respond to its in-band signalling. + +This reports the PHY capabilities for the particular interface mode, +not the current configuration. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUre-006ITz-KF@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phy.c | 21 +++++++++++++++++++++ + include/linux/phy.h | 28 ++++++++++++++++++++++++++++ + 2 files changed, 49 insertions(+) + +--- a/drivers/net/phy/phy.c ++++ b/drivers/net/phy/phy.c +@@ -1049,6 +1049,27 @@ static int phy_check_link_status(struct + } + + /** ++ * phy_inband_caps - query which in-band signalling modes are supported ++ * @phydev: a pointer to a &struct phy_device ++ * @interface: the interface mode for the PHY ++ * ++ * Returns zero if it is unknown what in-band signalling is supported by the ++ * PHY (e.g. because the PHY driver doesn't implement the method.) Otherwise, ++ * returns a bit mask of the LINK_INBAND_* values from ++ * &enum link_inband_signalling to describe which inband modes are supported ++ * by the PHY for this interface mode. ++ */ ++unsigned int phy_inband_caps(struct phy_device *phydev, ++ phy_interface_t interface) ++{ ++ if (phydev->drv && phydev->drv->inband_caps) ++ return phydev->drv->inband_caps(phydev, interface); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(phy_inband_caps); ++ ++/** + * _phy_start_aneg - start auto-negotiation for this PHY device + * @phydev: the phy_device struct + * +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -826,6 +826,24 @@ struct phy_tdr_config { + #define PHY_PAIR_ALL -1 + + /** ++ * enum link_inband_signalling - in-band signalling modes that are supported ++ * ++ * @LINK_INBAND_DISABLE: in-band signalling can be disabled ++ * @LINK_INBAND_ENABLE: in-band signalling can be enabled without bypass ++ * @LINK_INBAND_BYPASS: in-band signalling can be enabled with bypass ++ * ++ * The possible and required bits can only be used if the valid bit is set. ++ * If possible is clear, that means inband signalling can not be used. ++ * Required is only valid when possible is set, and means that inband ++ * signalling must be used. ++ */ ++enum link_inband_signalling { ++ LINK_INBAND_DISABLE = BIT(0), ++ LINK_INBAND_ENABLE = BIT(1), ++ LINK_INBAND_BYPASS = BIT(2), ++}; ++ ++/** + * struct phy_plca_cfg - Configuration of the PLCA (Physical Layer Collision + * Avoidance) Reconciliation Sublayer. + * +@@ -964,6 +982,14 @@ struct phy_driver { + int (*get_features)(struct phy_device *phydev); + + /** ++ * @inband_caps: query whether in-band is supported for the given PHY ++ * interface mode. Returns a bitmask of bits defined by enum ++ * link_inband_signalling. ++ */ ++ unsigned int (*inband_caps)(struct phy_device *phydev, ++ phy_interface_t interface); ++ ++ /** + * @get_rate_matching: Get the supported type of rate matching for a + * particular phy interface. This is used by phy consumers to determine + * whether to advertise lower-speed modes for that interface. It is +@@ -1842,6 +1868,8 @@ int phy_config_aneg(struct phy_device *p + int _phy_start_aneg(struct phy_device *phydev); + int phy_start_aneg(struct phy_device *phydev); + int phy_aneg_done(struct phy_device *phydev); ++unsigned int phy_inband_caps(struct phy_device *phydev, ++ phy_interface_t interface); + int phy_speed_down(struct phy_device *phydev, bool sync); + int phy_speed_up(struct phy_device *phydev); + bool phy_check_valid(int speed, int duplex, unsigned long *features); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-05-v6.14-net-phy-bcm84881-implement-phy_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-05-v6.14-net-phy-bcm84881-implement-phy_inband_caps-method.patch new file mode 100755 index 0000000..0ba3cd2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-05-v6.14-net-phy-bcm84881-implement-phy_inband_caps-method.patch @@ -0,0 +1,41 @@ +From c64c7fa0a774d9da72071a8517e359992baac982 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:07 +0000 +Subject: [PATCH 05/13] net: phy: bcm84881: implement phy_inband_caps() method + +BCM84881 has no support for inband signalling, so this is a trivial +implementation that returns no support for inband. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Acked-by: Florian Fainelli +Link: https://patch.msgid.link/E1tIUrj-006IU6-ON@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/bcm84881.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/net/phy/bcm84881.c ++++ b/drivers/net/phy/bcm84881.c +@@ -235,11 +235,21 @@ static int bcm84881_read_status(struct p + return genphy_c45_read_mdix(phydev); + } + ++/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII ++ * or 802.3z control word, so inband will not work. ++ */ ++static unsigned int bcm84881_inband_caps(struct phy_device *phydev, ++ phy_interface_t interface) ++{ ++ return LINK_INBAND_DISABLE; ++} ++ + static struct phy_driver bcm84881_drivers[] = { + { + .phy_id = 0xae025150, + .phy_id_mask = 0xfffffff0, + .name = "Broadcom BCM84881", ++ .inband_caps = bcm84881_inband_caps, + .config_init = bcm84881_config_init, + .probe = bcm84881_probe, + .get_features = bcm84881_get_features, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-06-v6.14-net-phy-marvell-implement-phy_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-06-v6.14-net-phy-marvell-implement-phy_inband_caps-method.patch new file mode 100755 index 0000000..e2dfeba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-06-v6.14-net-phy-marvell-implement-phy_inband_caps-method.patch @@ -0,0 +1,63 @@ +From 1c86828dff88e28b8ade6bddeee0163a023faf91 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:12 +0000 +Subject: [PATCH 06/13] net: phy: marvell: implement phy_inband_caps() method + +Provide an implementation for phy_inband_caps() for Marvell PHYs used +on SFP modules, so that phylink knows the PHYs capabilities. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUro-006IUC-Rq@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/marvell.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +--- a/drivers/net/phy/marvell.c ++++ b/drivers/net/phy/marvell.c +@@ -716,6 +716,20 @@ static int marvell_config_aneg_fiber(str + return genphy_check_and_restart_aneg(phydev, changed); + } + ++static unsigned int m88e1111_inband_caps(struct phy_device *phydev, ++ phy_interface_t interface) ++{ ++ /* In 1000base-X and SGMII modes, the inband mode can be changed ++ * through the Fibre page BMCR ANENABLE bit. ++ */ ++ if (interface == PHY_INTERFACE_MODE_1000BASEX || ++ interface == PHY_INTERFACE_MODE_SGMII) ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE | ++ LINK_INBAND_BYPASS; ++ ++ return 0; ++} ++ + static int m88e1111_config_aneg(struct phy_device *phydev) + { + int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); +@@ -3704,6 +3718,7 @@ static struct phy_driver marvell_drivers + .name = "Marvell 88E1112", + /* PHY_GBIT_FEATURES */ + .probe = marvell_probe, ++ .inband_caps = m88e1111_inband_caps, + .config_init = m88e1112_config_init, + .config_aneg = marvell_config_aneg, + .config_intr = marvell_config_intr, +@@ -3725,6 +3740,7 @@ static struct phy_driver marvell_drivers + /* PHY_GBIT_FEATURES */ + .flags = PHY_POLL_CABLE_TEST, + .probe = marvell_probe, ++ .inband_caps = m88e1111_inband_caps, + .config_init = m88e1111gbe_config_init, + .config_aneg = m88e1111_config_aneg, + .read_status = marvell_read_status, +@@ -3748,6 +3764,7 @@ static struct phy_driver marvell_drivers + .name = "Marvell 88E1111 (Finisar)", + /* PHY_GBIT_FEATURES */ + .probe = marvell_probe, ++ .inband_caps = m88e1111_inband_caps, + .config_init = m88e1111gbe_config_init, + .config_aneg = m88e1111_config_aneg, + .read_status = marvell_read_status, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-07-v6.14-net-phy-add-phy_config_inband.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-07-v6.14-net-phy-add-phy_config_inband.patch new file mode 100755 index 0000000..d667bcb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-07-v6.14-net-phy-add-phy_config_inband.patch @@ -0,0 +1,79 @@ +From 5d58a890c02770ba8d790b1f3c6e8c0e20514dc2 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:18 +0000 +Subject: [PATCH 07/13] net: phy: add phy_config_inband() + +Add a method to configure the PHY's in-band mode. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUru-006IUI-08@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phy.c | 32 ++++++++++++++++++++++++++++++++ + include/linux/phy.h | 6 ++++++ + 2 files changed, 38 insertions(+) + +--- a/drivers/net/phy/phy.c ++++ b/drivers/net/phy/phy.c +@@ -1070,6 +1070,38 @@ unsigned int phy_inband_caps(struct phy_ + EXPORT_SYMBOL_GPL(phy_inband_caps); + + /** ++ * phy_config_inband - configure the desired PHY in-band mode ++ * @phydev: the phy_device struct ++ * @modes: in-band modes to configure ++ * ++ * Description: disables, enables or enables-with-bypass in-band signalling ++ * between the PHY and host system. ++ * ++ * Returns: zero on success, or negative errno value. ++ */ ++int phy_config_inband(struct phy_device *phydev, unsigned int modes) ++{ ++ int err; ++ ++ if (!!(modes & LINK_INBAND_DISABLE) + ++ !!(modes & LINK_INBAND_ENABLE) + ++ !!(modes & LINK_INBAND_BYPASS) != 1) ++ return -EINVAL; ++ ++ mutex_lock(&phydev->lock); ++ if (!phydev->drv) ++ err = -EIO; ++ else if (!phydev->drv->config_inband) ++ err = -EOPNOTSUPP; ++ else ++ err = phydev->drv->config_inband(phydev, modes); ++ mutex_unlock(&phydev->lock); ++ ++ return err; ++} ++EXPORT_SYMBOL(phy_config_inband); ++ ++/** + * _phy_start_aneg - start auto-negotiation for this PHY device + * @phydev: the phy_device struct + * +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -990,6 +990,11 @@ struct phy_driver { + phy_interface_t interface); + + /** ++ * @config_inband: configure in-band mode for the PHY ++ */ ++ int (*config_inband)(struct phy_device *phydev, unsigned int modes); ++ ++ /** + * @get_rate_matching: Get the supported type of rate matching for a + * particular phy interface. This is used by phy consumers to determine + * whether to advertise lower-speed modes for that interface. It is +@@ -1870,6 +1875,7 @@ int phy_start_aneg(struct phy_device *ph + int phy_aneg_done(struct phy_device *phydev); + unsigned int phy_inband_caps(struct phy_device *phydev, + phy_interface_t interface); ++int phy_config_inband(struct phy_device *phydev, unsigned int modes); + int phy_speed_down(struct phy_device *phydev, bool sync); + int phy_speed_up(struct phy_device *phydev); + bool phy_check_valid(int speed, int duplex, unsigned long *features); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-08-v6.14-net-phy-marvell-implement-config_inband-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-08-v6.14-net-phy-marvell-implement-config_inband-method.patch new file mode 100755 index 0000000..4531c50 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-08-v6.14-net-phy-marvell-implement-config_inband-method.patch @@ -0,0 +1,77 @@ +From a219912e0fec73c346e64ef47013cb2e152f88fc Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:23 +0000 +Subject: [PATCH 08/13] net: phy: marvell: implement config_inband() method + +Implement the config_inband() method for Marvell 88E1112, 88E1111, +and Finisar's 88E1111 variant. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUrz-006IUO-3r@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/marvell.c | 31 +++++++++++++++++++++++++++++++ + 1 file changed, 31 insertions(+) + +--- a/drivers/net/phy/marvell.c ++++ b/drivers/net/phy/marvell.c +@@ -730,6 +730,34 @@ static unsigned int m88e1111_inband_caps + return 0; + } + ++static int m88e1111_config_inband(struct phy_device *phydev, unsigned int modes) ++{ ++ u16 extsr, bmcr; ++ int err; ++ ++ if (phydev->interface != PHY_INTERFACE_MODE_1000BASEX && ++ phydev->interface != PHY_INTERFACE_MODE_SGMII) ++ return -EINVAL; ++ ++ if (modes == LINK_INBAND_BYPASS) ++ extsr = MII_M1111_HWCFG_SERIAL_AN_BYPASS; ++ else ++ extsr = 0; ++ ++ if (modes == LINK_INBAND_DISABLE) ++ bmcr = 0; ++ else ++ bmcr = BMCR_ANENABLE; ++ ++ err = phy_modify(phydev, MII_M1111_PHY_EXT_SR, ++ MII_M1111_HWCFG_SERIAL_AN_BYPASS, extsr); ++ if (err < 0) ++ return extsr; ++ ++ return phy_modify_paged(phydev, MII_MARVELL_FIBER_PAGE, MII_BMCR, ++ BMCR_ANENABLE, bmcr); ++} ++ + static int m88e1111_config_aneg(struct phy_device *phydev) + { + int extsr = phy_read(phydev, MII_M1111_PHY_EXT_SR); +@@ -3719,6 +3747,7 @@ static struct phy_driver marvell_drivers + /* PHY_GBIT_FEATURES */ + .probe = marvell_probe, + .inband_caps = m88e1111_inband_caps, ++ .config_inband = m88e1111_config_inband, + .config_init = m88e1112_config_init, + .config_aneg = marvell_config_aneg, + .config_intr = marvell_config_intr, +@@ -3741,6 +3770,7 @@ static struct phy_driver marvell_drivers + .flags = PHY_POLL_CABLE_TEST, + .probe = marvell_probe, + .inband_caps = m88e1111_inband_caps, ++ .config_inband = m88e1111_config_inband, + .config_init = m88e1111gbe_config_init, + .config_aneg = m88e1111_config_aneg, + .read_status = marvell_read_status, +@@ -3765,6 +3795,7 @@ static struct phy_driver marvell_drivers + /* PHY_GBIT_FEATURES */ + .probe = marvell_probe, + .inband_caps = m88e1111_inband_caps, ++ .config_inband = m88e1111_config_inband, + .config_init = m88e1111gbe_config_init, + .config_aneg = m88e1111_config_aneg, + .read_status = marvell_read_status, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-09-v6.14-net-phylink-add-pcs_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-09-v6.14-net-phylink-add-pcs_inband_caps-method.patch new file mode 100755 index 0000000..4228024 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-09-v6.14-net-phylink-add-pcs_inband_caps-method.patch @@ -0,0 +1,159 @@ +From df874f9e52c340cc6f0a0014a97b778f67d46849 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:28 +0000 +Subject: [PATCH 09/13] net: phylink: add pcs_inband_caps() method + +Add a pcs_inband_caps() method to query the PCS for its inband link +capabilities, and use this to determine whether link modes used with +optical SFPs can be supported. + +When a PCS does not provide a method, we allow inband negotiation to +be either on or off, making this a no-op until the pcs_inband_caps() +method is implemented by a PCS driver. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUs4-006IUU-7K@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 60 +++++++++++++++++++++++++++++++++++++++ + include/linux/phylink.h | 17 +++++++++++ + 2 files changed, 77 insertions(+) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1007,6 +1007,15 @@ static void phylink_resolve_an_pause(str + } + } + ++static unsigned int phylink_pcs_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface) ++{ ++ if (pcs && pcs->ops->pcs_inband_caps) ++ return pcs->ops->pcs_inband_caps(pcs, interface); ++ ++ return 0; ++} ++ + static void phylink_pcs_pre_config(struct phylink_pcs *pcs, + phy_interface_t interface) + { +@@ -1060,6 +1069,24 @@ static void phylink_pcs_link_up(struct p + pcs->ops->pcs_link_up(pcs, neg_mode, interface, speed, duplex); + } + ++/* Query inband for a specific interface mode, asking the MAC for the ++ * PCS which will be used to handle the interface mode. ++ */ ++static unsigned int phylink_inband_caps(struct phylink *pl, ++ phy_interface_t interface) ++{ ++ struct phylink_pcs *pcs; ++ ++ if (!pl->mac_ops->mac_select_pcs) ++ return 0; ++ ++ pcs = pl->mac_ops->mac_select_pcs(pl->config, interface); ++ if (!pcs) ++ return 0; ++ ++ return phylink_pcs_inband_caps(pcs, interface); ++} ++ + static void phylink_pcs_poll_stop(struct phylink *pl) + { + if (pl->cfg_link_an_mode == MLO_AN_INBAND) +@@ -2530,6 +2557,26 @@ int phylink_ethtool_ksettings_get(struct + } + EXPORT_SYMBOL_GPL(phylink_ethtool_ksettings_get); + ++static bool phylink_validate_pcs_inband_autoneg(struct phylink *pl, ++ phy_interface_t interface, ++ unsigned long *adv) ++{ ++ unsigned int inband = phylink_inband_caps(pl, interface); ++ unsigned int mask; ++ ++ /* If the PCS doesn't implement inband support, be permissive. */ ++ if (!inband) ++ return true; ++ ++ if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, adv)) ++ mask = LINK_INBAND_ENABLE; ++ else ++ mask = LINK_INBAND_DISABLE; ++ ++ /* Check whether the PCS implements the required mode */ ++ return !!(inband & mask); ++} ++ + /** + * phylink_ethtool_ksettings_set() - set the link settings + * @pl: a pointer to a &struct phylink returned from phylink_create() +@@ -2665,6 +2712,13 @@ int phylink_ethtool_ksettings_set(struct + phylink_is_empty_linkmode(config.advertising)) + return -EINVAL; + ++ /* Validate the autonegotiation state. We don't have a PHY in this ++ * situation, so the PCS is the media-facing entity. ++ */ ++ if (!phylink_validate_pcs_inband_autoneg(pl, config.interface, ++ config.advertising)) ++ return -EINVAL; ++ + mutex_lock(&pl->state_mutex); + pl->link_config.speed = config.speed; + pl->link_config.duplex = config.duplex; +@@ -3349,6 +3403,12 @@ static int phylink_sfp_config_optical(st + phylink_dbg(pl, "optical SFP: chosen %s interface\n", + phy_modes(interface)); + ++ if (!phylink_validate_pcs_inband_autoneg(pl, interface, ++ config.advertising)) { ++ phylink_err(pl, "autoneg setting not compatible with PCS"); ++ return -EINVAL; ++ } ++ + config.interface = interface; + + /* Ignore errors if we're expecting a PHY to attach later */ +--- a/include/linux/phylink.h ++++ b/include/linux/phylink.h +@@ -419,6 +419,7 @@ struct phylink_pcs { + /** + * struct phylink_pcs_ops - MAC PCS operations structure. + * @pcs_validate: validate the link configuration. ++ * @pcs_inband_caps: query inband support for interface mode. + * @pcs_enable: enable the PCS. + * @pcs_disable: disable the PCS. + * @pcs_pre_config: pre-mac_config method (for errata) +@@ -434,6 +435,8 @@ struct phylink_pcs { + struct phylink_pcs_ops { + int (*pcs_validate)(struct phylink_pcs *pcs, unsigned long *supported, + const struct phylink_link_state *state); ++ unsigned int (*pcs_inband_caps)(struct phylink_pcs *pcs, ++ phy_interface_t interface); + int (*pcs_enable)(struct phylink_pcs *pcs); + void (*pcs_disable)(struct phylink_pcs *pcs); + void (*pcs_pre_config)(struct phylink_pcs *pcs, +@@ -471,6 +474,20 @@ int pcs_validate(struct phylink_pcs *pcs + const struct phylink_link_state *state); + + /** ++ * pcs_inband_caps - query PCS in-band capabilities for interface mode. ++ * @pcs: a pointer to a &struct phylink_pcs. ++ * @interface: interface mode to be queried ++ * ++ * Returns zero if it is unknown what in-band signalling is supported by the ++ * PHY (e.g. because the PHY driver doesn't implement the method.) Otherwise, ++ * returns a bit mask of the LINK_INBAND_* values from ++ * &enum link_inband_signalling to describe which inband modes are supported ++ * for this interface mode. ++ */ ++unsigned int pcs_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface); ++ ++/** + * pcs_enable() - enable the PCS. + * @pcs: a pointer to a &struct phylink_pcs. + */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-10-v6.14-net-mvneta-implement-pcs_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-10-v6.14-net-mvneta-implement-pcs_inband_caps-method.patch new file mode 100755 index 0000000..0937ad1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-10-v6.14-net-mvneta-implement-pcs_inband_caps-method.patch @@ -0,0 +1,64 @@ +From 513e8fb8fa32035b3325e2e14fb9598f8cb545e9 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:33 +0000 +Subject: [PATCH 10/13] net: mvneta: implement pcs_inband_caps() method + +Report the PCS in-band capabilities to phylink for Marvell NETA +interfaces. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUs9-006IUb-Au@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/marvell/mvneta.c | 27 +++++++++++++++++---------- + 1 file changed, 17 insertions(+), 10 deletions(-) + +--- a/drivers/net/ethernet/marvell/mvneta.c ++++ b/drivers/net/ethernet/marvell/mvneta.c +@@ -3960,20 +3960,27 @@ static struct mvneta_port *mvneta_pcs_to + return container_of(pcs, struct mvneta_port, phylink_pcs); + } + +-static int mvneta_pcs_validate(struct phylink_pcs *pcs, +- unsigned long *supported, +- const struct phylink_link_state *state) ++static unsigned int mvneta_pcs_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface) + { +- /* We only support QSGMII, SGMII, 802.3z and RGMII modes. +- * When in 802.3z mode, we must have AN enabled: ++ /* When operating in an 802.3z mode, we must have AN enabled: + * "Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ... + * When = 1 (1000BASE-X) this field must be set to 1." ++ * Therefore, inband is "required". + */ +- if (phy_interface_mode_is_8023z(state->interface) && +- !phylink_test(state->advertising, Autoneg)) +- return -EINVAL; ++ if (phy_interface_mode_is_8023z(interface)) ++ return LINK_INBAND_ENABLE; + +- return 0; ++ /* QSGMII, SGMII and RGMII can be configured to use inband ++ * signalling of the AN result. Indicate these as "possible". ++ */ ++ if (interface == PHY_INTERFACE_MODE_SGMII || ++ interface == PHY_INTERFACE_MODE_QSGMII || ++ phy_interface_mode_is_rgmii(interface)) ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ ++ /* For any other modes, indicate that inband is not supported. */ ++ return LINK_INBAND_DISABLE; + } + + static void mvneta_pcs_get_state(struct phylink_pcs *pcs, +@@ -4071,7 +4078,7 @@ static void mvneta_pcs_an_restart(struct + } + + static const struct phylink_pcs_ops mvneta_phylink_pcs_ops = { +- .pcs_validate = mvneta_pcs_validate, ++ .pcs_inband_caps = mvneta_pcs_inband_caps, + .pcs_get_state = mvneta_pcs_get_state, + .pcs_config = mvneta_pcs_config, + .pcs_an_restart = mvneta_pcs_an_restart, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-11-v6.14-net-mvpp2-implement-pcs_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-11-v6.14-net-mvpp2-implement-pcs_inband_caps-method.patch new file mode 100755 index 0000000..846d9df --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-11-v6.14-net-mvpp2-implement-pcs_inband_caps-method.patch @@ -0,0 +1,62 @@ +From d4169f0c7665afb8d8adb5e1b1df3db88517d0ad Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:38 +0000 +Subject: [PATCH 11/13] net: mvpp2: implement pcs_inband_caps() method + +Report the PCS in-band capabilities to phylink for Marvell PP2 +interfaces. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUsE-006IUh-E7@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 25 ++++++++++++------- + 1 file changed, 16 insertions(+), 9 deletions(-) + +--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c ++++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +@@ -6237,19 +6237,26 @@ static const struct phylink_pcs_ops mvpp + .pcs_config = mvpp2_xlg_pcs_config, + }; + +-static int mvpp2_gmac_pcs_validate(struct phylink_pcs *pcs, +- unsigned long *supported, +- const struct phylink_link_state *state) ++static unsigned int mvpp2_gmac_pcs_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface) + { +- /* When in 802.3z mode, we must have AN enabled: ++ /* When operating in an 802.3z mode, we must have AN enabled: + * Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ... + * When = 1 (1000BASE-X) this field must be set to 1. ++ * Therefore, inband is "required". + */ +- if (phy_interface_mode_is_8023z(state->interface) && +- !phylink_test(state->advertising, Autoneg)) +- return -EINVAL; ++ if (phy_interface_mode_is_8023z(interface)) ++ return LINK_INBAND_ENABLE; + +- return 0; ++ /* SGMII and RGMII can be configured to use inband signalling of the ++ * AN result. Indicate these as "possible". ++ */ ++ if (interface == PHY_INTERFACE_MODE_SGMII || ++ phy_interface_mode_is_rgmii(interface)) ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ ++ /* For any other modes, indicate that inband is not supported. */ ++ return LINK_INBAND_DISABLE; + } + + static void mvpp2_gmac_pcs_get_state(struct phylink_pcs *pcs, +@@ -6356,7 +6363,7 @@ static void mvpp2_gmac_pcs_an_restart(st + } + + static const struct phylink_pcs_ops mvpp2_phylink_gmac_pcs_ops = { +- .pcs_validate = mvpp2_gmac_pcs_validate, ++ .pcs_inband_caps = mvpp2_gmac_pcs_inband_caps, + .pcs_get_state = mvpp2_gmac_pcs_get_state, + .pcs_config = mvpp2_gmac_pcs_config, + .pcs_an_restart = mvpp2_gmac_pcs_an_restart, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-12-v6.14-net-phylink-add-negotiation-of-in-band-capabilities.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-12-v6.14-net-phylink-add-negotiation-of-in-band-capabilities.patch new file mode 100755 index 0000000..f629133 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-12-v6.14-net-phylink-add-negotiation-of-in-band-capabilities.patch @@ -0,0 +1,228 @@ +From 5fd0f1a02e750e2db4038dee60edea669ce5aab1 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:43 +0000 +Subject: [PATCH 12/13] net: phylink: add negotiation of in-band capabilities + +Support for in-band signalling with Serdes links is uncertain. Some +PHYs do not support in-band for e.g. SGMII. Some PCS do not support +in-band for 2500Base-X. Some PCS require in-band for Base-X protocols. + +Simply using what is in DT is insufficient when we have hot-pluggable +PHYs e.g. in the form of SFP modules, which may not provide the +in-band signalling. + +In order to address this, we have introduced phy_inband_caps() and +pcs_inband_caps() functions to allow phylink to retrieve the +capabilities from each end of the PCS/PHY link. This commit adds code +to resolve whether in-band will be used in the various scenarios that +we have: In-band not being used, PHY present using SGMII or Base-X, +PHY not present. We also deal with no capabilties provided. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUsJ-006IUn-H3@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 154 +++++++++++++++++++++++++++++++++++--- + 1 file changed, 144 insertions(+), 10 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -75,6 +75,7 @@ struct phylink { + + struct mutex state_mutex; + struct phylink_link_state phy_state; ++ unsigned int phy_ib_mode; + struct work_struct resolve; + unsigned int pcs_neg_mode; + unsigned int pcs_state; +@@ -1170,10 +1171,18 @@ static void phylink_pcs_neg_mode(struct + phy_interface_t interface, + const unsigned long *advertising) + { ++ unsigned int pcs_ib_caps = 0; ++ unsigned int phy_ib_caps = 0; + unsigned int neg_mode, mode; ++ enum { ++ INBAND_CISCO_SGMII, ++ INBAND_BASEX, ++ } type; + + mode = pl->req_link_an_mode; + ++ pl->phy_ib_mode = 0; ++ + switch (interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_QSGMII: +@@ -1185,10 +1194,7 @@ static void phylink_pcs_neg_mode(struct + * inband communication. Note: there exist PHYs that run + * with SGMII but do not send the inband data. + */ +- if (!phylink_autoneg_inband(mode)) +- neg_mode = PHYLINK_PCS_NEG_OUTBAND; +- else +- neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; ++ type = INBAND_CISCO_SGMII; + break; + + case PHY_INTERFACE_MODE_1000BASEX: +@@ -1199,18 +1205,139 @@ static void phylink_pcs_neg_mode(struct + * as well, but drivers may not support this, so may + * need to override this. + */ +- if (!phylink_autoneg_inband(mode)) ++ type = INBAND_BASEX; ++ break; ++ ++ default: ++ pl->pcs_neg_mode = PHYLINK_PCS_NEG_NONE; ++ pl->act_link_an_mode = mode; ++ return; ++ } ++ ++ if (pcs) ++ pcs_ib_caps = phylink_pcs_inband_caps(pcs, interface); ++ ++ if (pl->phydev) ++ phy_ib_caps = phy_inband_caps(pl->phydev, interface); ++ ++ phylink_dbg(pl, "interface %s inband modes: pcs=%02x phy=%02x\n", ++ phy_modes(interface), pcs_ib_caps, phy_ib_caps); ++ ++ if (!phylink_autoneg_inband(mode)) { ++ bool pcs_ib_only = false; ++ bool phy_ib_only = false; ++ ++ if (pcs_ib_caps && pcs_ib_caps != LINK_INBAND_DISABLE) { ++ /* PCS supports reporting in-band capabilities, and ++ * supports more than disable mode. ++ */ ++ if (pcs_ib_caps & LINK_INBAND_DISABLE) ++ neg_mode = PHYLINK_PCS_NEG_OUTBAND; ++ else if (pcs_ib_caps & LINK_INBAND_ENABLE) ++ pcs_ib_only = true; ++ } ++ ++ if (phy_ib_caps && phy_ib_caps != LINK_INBAND_DISABLE) { ++ /* PHY supports in-band capabilities, and supports ++ * more than disable mode. ++ */ ++ if (phy_ib_caps & LINK_INBAND_DISABLE) ++ pl->phy_ib_mode = LINK_INBAND_DISABLE; ++ else if (phy_ib_caps & LINK_INBAND_BYPASS) ++ pl->phy_ib_mode = LINK_INBAND_BYPASS; ++ else if (phy_ib_caps & LINK_INBAND_ENABLE) ++ phy_ib_only = true; ++ } ++ ++ /* If either the PCS or PHY requires inband to be enabled, ++ * this is an invalid configuration. Provide a diagnostic ++ * message for this case, but don't try to force the issue. ++ */ ++ if (pcs_ib_only || phy_ib_only) ++ phylink_warn(pl, ++ "firmware wants %s mode, but %s%s%s requires inband\n", ++ phylink_an_mode_str(mode), ++ pcs_ib_only ? "PCS" : "", ++ pcs_ib_only && phy_ib_only ? " and " : "", ++ phy_ib_only ? "PHY" : ""); ++ ++ neg_mode = PHYLINK_PCS_NEG_OUTBAND; ++ } else if (type == INBAND_CISCO_SGMII || pl->phydev) { ++ /* For SGMII modes which are designed to be used with PHYs, or ++ * Base-X with a PHY, we try to use in-band mode where-ever ++ * possible. However, there are some PHYs e.g. BCM84881 which ++ * do not support in-band. ++ */ ++ const unsigned int inband_ok = LINK_INBAND_ENABLE | ++ LINK_INBAND_BYPASS; ++ const unsigned int outband_ok = LINK_INBAND_DISABLE | ++ LINK_INBAND_BYPASS; ++ /* PCS PHY ++ * D E D E ++ * 0 0 0 0 no information inband enabled ++ * 1 0 0 0 pcs doesn't support outband ++ * 0 1 0 0 pcs required inband enabled ++ * 1 1 0 0 pcs optional inband enabled ++ * 0 0 1 0 phy doesn't support outband ++ * 1 0 1 0 pcs+phy doesn't support outband ++ * 0 1 1 0 pcs required, phy doesn't support, invalid ++ * 1 1 1 0 pcs optional, phy doesn't support, outband ++ * 0 0 0 1 phy required inband enabled ++ * 1 0 0 1 pcs doesn't support, phy required, invalid ++ * 0 1 0 1 pcs+phy required inband enabled ++ * 1 1 0 1 pcs optional, phy required inband enabled ++ * 0 0 1 1 phy optional inband enabled ++ * 1 0 1 1 pcs doesn't support, phy optional, outband ++ * 0 1 1 1 pcs required, phy optional inband enabled ++ * 1 1 1 1 pcs+phy optional inband enabled ++ */ ++ if ((!pcs_ib_caps || pcs_ib_caps & inband_ok) && ++ (!phy_ib_caps || phy_ib_caps & inband_ok)) { ++ /* In-band supported or unknown at both ends. Enable ++ * in-band mode with or without bypass at the PHY. ++ */ ++ if (phy_ib_caps & LINK_INBAND_ENABLE) ++ pl->phy_ib_mode = LINK_INBAND_ENABLE; ++ else if (phy_ib_caps & LINK_INBAND_BYPASS) ++ pl->phy_ib_mode = LINK_INBAND_BYPASS; ++ ++ neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; ++ } else if ((!pcs_ib_caps || pcs_ib_caps & outband_ok) && ++ (!phy_ib_caps || phy_ib_caps & outband_ok)) { ++ /* Either in-band not supported at at least one end. ++ * In-band bypass at the other end is possible. ++ */ ++ if (phy_ib_caps & LINK_INBAND_DISABLE) ++ pl->phy_ib_mode = LINK_INBAND_DISABLE; ++ else if (phy_ib_caps & LINK_INBAND_BYPASS) ++ pl->phy_ib_mode = LINK_INBAND_BYPASS; ++ + neg_mode = PHYLINK_PCS_NEG_OUTBAND; ++ if (pl->phydev) ++ mode = MLO_AN_PHY; ++ } else { ++ /* invalid */ ++ phylink_warn(pl, "%s: incompatible in-band capabilities, trying in-band", ++ phy_modes(interface)); ++ neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; ++ } ++ } else { ++ /* For Base-X without a PHY */ ++ if (pcs_ib_caps == LINK_INBAND_DISABLE) ++ /* If the PCS doesn't support inband, then inband must ++ * be disabled. ++ */ ++ neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED; ++ else if (pcs_ib_caps == LINK_INBAND_ENABLE) ++ /* If the PCS requires inband, then inband must always ++ * be enabled. ++ */ ++ neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; + else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, + advertising)) + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; + else + neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED; +- break; +- +- default: +- neg_mode = PHYLINK_PCS_NEG_NONE; +- break; + } + + pl->pcs_neg_mode = neg_mode; +@@ -1309,6 +1436,13 @@ static void phylink_major_config(struct + ERR_PTR(err)); + } + ++ if (pl->phydev && pl->phy_ib_mode) { ++ err = phy_config_inband(pl->phydev, pl->phy_ib_mode); ++ if (err < 0) ++ phylink_err(pl, "phy_config_inband: %pe\n", ++ ERR_PTR(err)); ++ } ++ + if (pl->sfp_bus) { + rate_kbd = phylink_interface_signal_rate(state->interface); + if (rate_kbd) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-13-v6.14-net-phylink-remove-phylink_phy_no_inband.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-13-v6.14-net-phylink-remove-phylink_phy_no_inband.patch new file mode 100755 index 0000000..8be74a2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/601-13-v6.14-net-phylink-remove-phylink_phy_no_inband.patch @@ -0,0 +1,110 @@ +From 77ac9a8b2536e0eaca6c6f21070068458bf55981 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Tue, 3 Dec 2024 15:31:48 +0000 +Subject: [PATCH 13/13] net: phylink: remove phylink_phy_no_inband() + +Remove phylink_phy_no_inband() now that we are handling the lack of +inband negotiation by querying the capabilities of the PHY and PCS, +and the BCM84881 PHY driver provides us the information necessary to +make the decision. + +Reviewed-by: Andrew Lunn +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tIUsO-006IUt-KN@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 27 ++++++--------------------- + 1 file changed, 6 insertions(+), 21 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -3394,10 +3394,11 @@ static phy_interface_t phylink_choose_sf + return interface; + } + +-static void phylink_sfp_set_config(struct phylink *pl, u8 mode, ++static void phylink_sfp_set_config(struct phylink *pl, + unsigned long *supported, + struct phylink_link_state *state) + { ++ u8 mode = MLO_AN_INBAND; + bool changed = false; + + phylink_dbg(pl, "requesting link mode %s/%s with support %*pb\n", +@@ -3431,8 +3432,7 @@ static void phylink_sfp_set_config(struc + phylink_mac_initial_config(pl, false); + } + +-static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, +- struct phy_device *phy) ++static int phylink_sfp_config_phy(struct phylink *pl, struct phy_device *phy) + { + __ETHTOOL_DECLARE_LINK_MODE_MASK(support1); + __ETHTOOL_DECLARE_LINK_MODE_MASK(support); +@@ -3472,7 +3472,7 @@ static int phylink_sfp_config_phy(struct + if (ret) { + phylink_err(pl, + "validation of %s/%s with support %*pb failed: %pe\n", +- phylink_an_mode_str(mode), ++ phylink_an_mode_str(pl->req_link_an_mode), + phy_modes(config.interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, support, + ERR_PTR(ret)); +@@ -3481,7 +3481,7 @@ static int phylink_sfp_config_phy(struct + + pl->link_port = pl->sfp_port; + +- phylink_sfp_set_config(pl, mode, support, &config); ++ phylink_sfp_set_config(pl, support, &config); + + return 0; + } +@@ -3556,7 +3556,7 @@ static int phylink_sfp_config_optical(st + + pl->link_port = pl->sfp_port; + +- phylink_sfp_set_config(pl, MLO_AN_INBAND, pl->sfp_support, &config); ++ phylink_sfp_set_config(pl, pl->sfp_support, &config); + + return 0; + } +@@ -3627,20 +3627,10 @@ static void phylink_sfp_link_up(void *up + phylink_enable_and_run_resolve(pl, PHYLINK_DISABLE_LINK); + } + +-/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII +- * or 802.3z control word, so inband will not work. +- */ +-static bool phylink_phy_no_inband(struct phy_device *phy) +-{ +- return phy->is_c45 && phy_id_compare(phy->c45_ids.device_ids[1], +- 0xae025150, 0xfffffff0); +-} +- + static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) + { + struct phylink *pl = upstream; + phy_interface_t interface; +- u8 mode; + int ret; + + /* +@@ -3652,17 +3642,12 @@ static int phylink_sfp_connect_phy(void + */ + phy_support_asym_pause(phy); + +- if (phylink_phy_no_inband(phy)) +- mode = MLO_AN_PHY; +- else +- mode = MLO_AN_INBAND; +- + /* Set the PHY's host supported interfaces */ + phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces, + pl->config->supported_interfaces); + + /* Do the initial configuration */ +- ret = phylink_sfp_config_phy(pl, mode, phy); ++ ret = phylink_sfp_config_phy(pl, phy); + if (ret < 0) + return ret; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-01-v6.14-net-pcs-pcs-lynx-implement-pcs_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-01-v6.14-net-pcs-pcs-lynx-implement-pcs_inband_caps-method.patch new file mode 100755 index 0000000..32ba605 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-01-v6.14-net-pcs-pcs-lynx-implement-pcs_inband_caps-method.patch @@ -0,0 +1,53 @@ +From 6561f0e547be221f411fda5eddfcc5bd8bb058a5 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Thu, 5 Dec 2024 09:42:24 +0000 +Subject: [PATCH 1/3] net: pcs: pcs-lynx: implement pcs_inband_caps() method + +Report the PCS in-band capabilities to phylink for the Lynx PCS. + +Reviewed-by: Maxime Chevallier +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tJ8NM-006L5J-AH@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/pcs/pcs-lynx.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +--- a/drivers/net/pcs/pcs-lynx.c ++++ b/drivers/net/pcs/pcs-lynx.c +@@ -35,6 +35,27 @@ enum sgmii_speed { + #define phylink_pcs_to_lynx(pl_pcs) container_of((pl_pcs), struct lynx_pcs, pcs) + #define lynx_to_phylink_pcs(lynx) (&(lynx)->pcs) + ++static unsigned int lynx_pcs_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface) ++{ ++ switch (interface) { ++ case PHY_INTERFACE_MODE_1000BASEX: ++ case PHY_INTERFACE_MODE_SGMII: ++ case PHY_INTERFACE_MODE_QSGMII: ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ ++ case PHY_INTERFACE_MODE_10GBASER: ++ case PHY_INTERFACE_MODE_2500BASEX: ++ return LINK_INBAND_DISABLE; ++ ++ case PHY_INTERFACE_MODE_USXGMII: ++ return LINK_INBAND_ENABLE; ++ ++ default: ++ return 0; ++ } ++} ++ + static void lynx_pcs_get_state_usxgmii(struct mdio_device *pcs, + struct phylink_link_state *state) + { +@@ -306,6 +327,7 @@ static void lynx_pcs_link_up(struct phyl + } + + static const struct phylink_pcs_ops lynx_pcs_phylink_ops = { ++ .pcs_inband_caps = lynx_pcs_inband_caps, + .pcs_get_state = lynx_pcs_get_state, + .pcs_config = lynx_pcs_config, + .pcs_an_restart = lynx_pcs_an_restart, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-02-v6.14-net-pcs-pcs-mtk-lynxi-implement-pcs_inband_caps-meth.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-02-v6.14-net-pcs-pcs-mtk-lynxi-implement-pcs_inband_caps-meth.patch new file mode 100755 index 0000000..1cfd3ba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-02-v6.14-net-pcs-pcs-mtk-lynxi-implement-pcs_inband_caps-meth.patch @@ -0,0 +1,47 @@ +From 520d29bdda86915b3caf8c72825a574bff212553 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Thu, 5 Dec 2024 09:42:29 +0000 +Subject: [PATCH 2/3] net: pcs: pcs-mtk-lynxi: implement pcs_inband_caps() + method + +Report the PCS in-band capabilities to phylink for the LynxI PCS. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tJ8NR-006L5P-E3@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/pcs/pcs-mtk-lynxi.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +--- a/drivers/net/pcs/pcs-mtk-lynxi.c ++++ b/drivers/net/pcs/pcs-mtk-lynxi.c +@@ -88,6 +88,21 @@ static struct mtk_pcs_lynxi *pcs_to_mtk_ + return container_of(pcs, struct mtk_pcs_lynxi, pcs); + } + ++static unsigned int mtk_pcs_lynxi_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface) ++{ ++ switch (interface) { ++ case PHY_INTERFACE_MODE_1000BASEX: ++ case PHY_INTERFACE_MODE_2500BASEX: ++ case PHY_INTERFACE_MODE_SGMII: ++ case PHY_INTERFACE_MODE_QSGMII: ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ ++ default: ++ return 0; ++ } ++} ++ + static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs, + struct phylink_link_state *state) + { +@@ -241,6 +256,7 @@ static void mtk_pcs_lynxi_disable(struct + } + + static const struct phylink_pcs_ops mtk_pcs_lynxi_ops = { ++ .pcs_inband_caps = mtk_pcs_lynxi_inband_caps, + .pcs_get_state = mtk_pcs_lynxi_get_state, + .pcs_config = mtk_pcs_lynxi_config, + .pcs_an_restart = mtk_pcs_lynxi_restart_an, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-03-v6.14-net-pcs-xpcs-implement-pcs_inband_caps-method.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-03-v6.14-net-pcs-xpcs-implement-pcs_inband_caps-method.patch new file mode 100755 index 0000000..8dc495b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/602-03-v6.14-net-pcs-xpcs-implement-pcs_inband_caps-method.patch @@ -0,0 +1,58 @@ +From 484d0170d6c6bbb5213d037664e9a551f793bacd Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Thu, 5 Dec 2024 09:42:34 +0000 +Subject: [PATCH 3/3] net: pcs: xpcs: implement pcs_inband_caps() method + +Report the PCS inband capabilities to phylink for XPCS. + +Signed-off-by: Russell King (Oracle) +Link: https://patch.msgid.link/E1tJ8NW-006L5V-I9@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/pcs/pcs-xpcs.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +--- a/drivers/net/pcs/pcs-xpcs.c ++++ b/drivers/net/pcs/pcs-xpcs.c +@@ -608,6 +608,33 @@ static int xpcs_validate(struct phylink_ + return 0; + } + ++static unsigned int xpcs_inband_caps(struct phylink_pcs *pcs, ++ phy_interface_t interface) ++{ ++ struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); ++ const struct dw_xpcs_compat *compat; ++ ++ compat = xpcs_find_compat(xpcs->desc, interface); ++ if (!compat) ++ return 0; ++ ++ switch (compat->an_mode) { ++ case DW_AN_C73: ++ return LINK_INBAND_ENABLE; ++ ++ case DW_AN_C37_SGMII: ++ case DW_AN_C37_1000BASEX: ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ ++ case DW_10GBASER: ++ case DW_2500BASEX: ++ return LINK_INBAND_DISABLE; ++ ++ default: ++ return 0; ++ } ++} ++ + void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) + { + int i, j; +@@ -1365,6 +1392,7 @@ static const struct dw_xpcs_desc xpcs_de + + static const struct phylink_pcs_ops xpcs_phylink_ops = { + .pcs_validate = xpcs_validate, ++ .pcs_inband_caps = xpcs_inband_caps, + .pcs_config = xpcs_config, + .pcs_get_state = xpcs_get_state, + .pcs_an_restart = xpcs_an_restart, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/605-02-v6.17-net-phylink-provide-phylink_get_inband_type.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/605-02-v6.17-net-phylink-provide-phylink_get_inband_type.patch new file mode 100755 index 0000000..e944f57 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/605-02-v6.17-net-phylink-provide-phylink_get_inband_type.patch @@ -0,0 +1,117 @@ +From 1bd905dfea9897eafef532000702e63a66849f54 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Sun, 31 Aug 2025 18:34:38 +0100 +Subject: net: phylink: provide phylink_get_inband_type() + +Provide a function to get the type of the inband signalling used for +a PHY interface type. This will be used in the subsequent patch to +address problems with 10G optical modules. + +Signed-off-by: Russell King (Oracle) +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/E1uslws-00000001SP5-1R2R@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 79 ++++++++++++++++++++++----------------- + 1 file changed, 44 insertions(+), 35 deletions(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -1147,6 +1147,42 @@ static void phylink_pcs_an_restart(struc + pl->pcs->ops->pcs_an_restart(pl->pcs); + } + ++enum inband_type { ++ INBAND_NONE, ++ INBAND_CISCO_SGMII, ++ INBAND_BASEX, ++}; ++ ++static enum inband_type phylink_get_inband_type(phy_interface_t interface) ++{ ++ switch (interface) { ++ case PHY_INTERFACE_MODE_SGMII: ++ case PHY_INTERFACE_MODE_QSGMII: ++ case PHY_INTERFACE_MODE_QUSGMII: ++ case PHY_INTERFACE_MODE_USXGMII: ++ case PHY_INTERFACE_MODE_10G_QXGMII: ++ /* These protocols are designed for use with a PHY which ++ * communicates its negotiation result back to the MAC via ++ * inband communication. Note: there exist PHYs that run ++ * with SGMII but do not send the inband data. ++ */ ++ return INBAND_CISCO_SGMII; ++ ++ case PHY_INTERFACE_MODE_1000BASEX: ++ case PHY_INTERFACE_MODE_2500BASEX: ++ /* 1000base-X is designed for use media-side for Fibre ++ * connections, and thus the Autoneg bit needs to be ++ * taken into account. We also do this for 2500base-X ++ * as well, but drivers may not support this, so may ++ * need to override this. ++ */ ++ return INBAND_BASEX; ++ ++ default: ++ return INBAND_NONE; ++ } ++} ++ + /** + * phylink_pcs_neg_mode() - helper to determine PCS inband mode + * @pl: a pointer to a &struct phylink returned from phylink_create() +@@ -1174,46 +1210,19 @@ static void phylink_pcs_neg_mode(struct + unsigned int pcs_ib_caps = 0; + unsigned int phy_ib_caps = 0; + unsigned int neg_mode, mode; +- enum { +- INBAND_CISCO_SGMII, +- INBAND_BASEX, +- } type; +- +- mode = pl->req_link_an_mode; ++ enum inband_type type; + +- pl->phy_ib_mode = 0; +- +- switch (interface) { +- case PHY_INTERFACE_MODE_SGMII: +- case PHY_INTERFACE_MODE_QSGMII: +- case PHY_INTERFACE_MODE_QUSGMII: +- case PHY_INTERFACE_MODE_USXGMII: +- case PHY_INTERFACE_MODE_10G_QXGMII: +- /* These protocols are designed for use with a PHY which +- * communicates its negotiation result back to the MAC via +- * inband communication. Note: there exist PHYs that run +- * with SGMII but do not send the inband data. +- */ +- type = INBAND_CISCO_SGMII; +- break; +- +- case PHY_INTERFACE_MODE_1000BASEX: +- case PHY_INTERFACE_MODE_2500BASEX: +- /* 1000base-X is designed for use media-side for Fibre +- * connections, and thus the Autoneg bit needs to be +- * taken into account. We also do this for 2500base-X +- * as well, but drivers may not support this, so may +- * need to override this. +- */ +- type = INBAND_BASEX; +- break; +- +- default: ++ type = phylink_get_inband_type(interface); ++ if (type == INBAND_NONE) { + pl->pcs_neg_mode = PHYLINK_PCS_NEG_NONE; +- pl->act_link_an_mode = mode; ++ pl->act_link_an_mode = pl->req_link_an_mode; + return; + } + ++ mode = pl->req_link_an_mode; ++ ++ pl->phy_ib_mode = 0; ++ + if (pcs) + pcs_ib_caps = phylink_pcs_inband_caps(pcs, interface); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/605-03-v6.17-net-phylink-disable-autoneg-for-interfaces-that-have.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/605-03-v6.17-net-phylink-disable-autoneg-for-interfaces-that-have.patch new file mode 100755 index 0000000..0861bb8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/605-03-v6.17-net-phylink-disable-autoneg-for-interfaces-that-have.patch @@ -0,0 +1,68 @@ +From a21202743f9ce4063e86b99cccaef48ef9813379 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Sun, 31 Aug 2025 18:34:43 +0100 +Subject: net: phylink: disable autoneg for interfaces that have no inband + +Mathew reports that as a result of commit 6561f0e547be ("net: pcs: +pcs-lynx: implement pcs_inband_caps() method"), 10G SFP modules no +longer work with the Lynx PCS. + +This problem is not specific to the Lynx PCS, but is caused by commit +df874f9e52c3 ("net: phylink: add pcs_inband_caps() method") which added +validation of the autoneg state to the optical SFP configuration path. + +Fix this by handling interface modes that fundamentally have no +inband negotiation more correctly - if we only have a single interface +mode, clear the Autoneg support bit and the advertising mask. If the +module can operate with several different interface modes, autoneg may +be supported for other modes, so leave the support mask alone and just +clear the Autoneg bit in the advertising mask. + +This restores 10G optical module functionality with PCS that supply +their inband support, and makes ethtool output look sane. + +Reported-by: Mathew McBride +Closes: https://lore.kernel.org/r/025c0ebe-5537-4fa3-b05a-8b835e5ad317@app.fastmail.com +Fixes: df874f9e52c3 ("net: phylink: add pcs_inband_caps() method") +Signed-off-by: Russell King (Oracle) +Tested-by: Vladimir Oltean +Link: https://patch.msgid.link/E1uslwx-00000001SPB-2kiM@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phylink.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -3500,6 +3500,7 @@ static int phylink_sfp_config_optical(st + __ETHTOOL_DECLARE_LINK_MODE_MASK(support); + DECLARE_PHY_INTERFACE_MASK(interfaces); + struct phylink_link_state config; ++ enum inband_type inband_type; + phy_interface_t interface; + int ret; + +@@ -3546,6 +3547,23 @@ static int phylink_sfp_config_optical(st + phylink_dbg(pl, "optical SFP: chosen %s interface\n", + phy_modes(interface)); + ++ inband_type = phylink_get_inband_type(interface); ++ if (inband_type == INBAND_NONE) { ++ /* If this is the sole interface, and there is no inband ++ * support, clear the advertising mask and Autoneg bit in ++ * the support mask. Otherwise, just clear the Autoneg bit ++ * in the advertising mask. ++ */ ++ if (phy_interface_weight(pl->sfp_interfaces) == 1) { ++ linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, ++ pl->sfp_support); ++ linkmode_zero(config.advertising); ++ } else { ++ linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, ++ config.advertising); ++ } ++ } ++ + if (!phylink_validate_pcs_inband_autoneg(pl, interface, + config.advertising)) { + phylink_err(pl, "autoneg setting not compatible with PCS"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-01-v6.13-net-dsa-use-ethtool-string-helpers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-01-v6.13-net-dsa-use-ethtool-string-helpers.patch new file mode 100755 index 0000000..a435e29 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-01-v6.13-net-dsa-use-ethtool-string-helpers.patch @@ -0,0 +1,30 @@ +From f12b363887c706c40611fba645265527a8415832 Mon Sep 17 00:00:00 2001 +From: Rosen Penev +Date: Sun, 27 Oct 2024 21:48:28 -0700 +Subject: [PATCH] net: dsa: use ethtool string helpers + +These are the preferred way to copy ethtool strings. + +Avoids incrementing pointers all over the place. + +Signed-off-by: Rosen Penev +(for hellcreek driver) +Reviewed-by: Kurt Kanzenbach +Link: https://patch.msgid.link/20241028044828.1639668-1-rosenp@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1086,8 +1086,7 @@ void b53_get_strings(struct dsa_switch * + + if (stringset == ETH_SS_STATS) { + for (i = 0; i < mib_size; i++) +- strscpy(data + i * ETH_GSTRING_LEN, +- mibs[i].name, ETH_GSTRING_LEN); ++ ethtool_puts(&data, mibs[i].name); + } else if (stringset == ETH_SS_PHY_STATS) { + phydev = b53_get_phy_device(ds, port); + if (!phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-02-v6.15-net-dsa-b53-mdio-add-support-for-BCM53101.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-02-v6.15-net-dsa-b53-mdio-add-support-for-BCM53101.patch new file mode 100755 index 0000000..6cbe547 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-02-v6.15-net-dsa-b53-mdio-add-support-for-BCM53101.patch @@ -0,0 +1,76 @@ +From c4f873c2b65c839ff5e7c996bd9ef5a1e7eae11a Mon Sep 17 00:00:00 2001 +From: Torben Nielsen +Date: Mon, 17 Feb 2025 09:05:01 +0100 +Subject: [PATCH] net: dsa: b53: mdio: add support for BCM53101 + +BCM53101 is a ethernet switch, very similar to the BCM53115. +Enable support for it, in the existing b53 dsa driver. + +Signed-off-by: Torben Nielsen +Signed-off-by: Claus Stovgaard +Link: https://patch.msgid.link/20250217080503.1390282-1-claus.stovgaard@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 14 ++++++++++++++ + drivers/net/dsa/b53/b53_mdio.c | 1 + + drivers/net/dsa/b53/b53_priv.h | 2 ++ + 3 files changed, 17 insertions(+) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2606,6 +2606,19 @@ static const struct b53_chip_data b53_sw + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, + }, + { ++ .chip_id = BCM53101_DEVICE_ID, ++ .dev_name = "BCM53101", ++ .vlans = 4096, ++ .enabled_ports = 0x11f, ++ .arl_bins = 4, ++ .arl_buckets = 512, ++ .vta_regs = B53_VTA_REGS, ++ .imp_port = 8, ++ .duplex_reg = B53_DUPLEX_STAT_GE, ++ .jumbo_pm_reg = B53_JUMBO_PORT_MASK, ++ .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ }, ++ { + .chip_id = BCM53115_DEVICE_ID, + .dev_name = "BCM53115", + .vlans = 4096, +@@ -2986,6 +2999,7 @@ int b53_switch_detect(struct b53_device + return ret; + + switch (id32) { ++ case BCM53101_DEVICE_ID: + case BCM53115_DEVICE_ID: + case BCM53125_DEVICE_ID: + case BCM53128_DEVICE_ID: +--- a/drivers/net/dsa/b53/b53_mdio.c ++++ b/drivers/net/dsa/b53/b53_mdio.c +@@ -374,6 +374,7 @@ static void b53_mdio_shutdown(struct mdi + + static const struct of_device_id b53_of_match[] = { + { .compatible = "brcm,bcm5325" }, ++ { .compatible = "brcm,bcm53101" }, + { .compatible = "brcm,bcm53115" }, + { .compatible = "brcm,bcm53125" }, + { .compatible = "brcm,bcm53128" }, +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -66,6 +66,7 @@ enum { + BCM5395_DEVICE_ID = 0x95, + BCM5397_DEVICE_ID = 0x97, + BCM5398_DEVICE_ID = 0x98, ++ BCM53101_DEVICE_ID = 0x53101, + BCM53115_DEVICE_ID = 0x53115, + BCM53125_DEVICE_ID = 0x53125, + BCM53128_DEVICE_ID = 0x53128, +@@ -190,6 +191,7 @@ static inline int is531x5(struct b53_dev + { + return dev->chip_id == BCM53115_DEVICE_ID || + dev->chip_id == BCM53125_DEVICE_ID || ++ dev->chip_id == BCM53101_DEVICE_ID || + dev->chip_id == BCM53128_DEVICE_ID || + dev->chip_id == BCM53134_DEVICE_ID; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-03-v6.16-net-dsa-b53-implement-setting-ageing-time.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-03-v6.16-net-dsa-b53-implement-setting-ageing-time.patch new file mode 100755 index 0000000..196e70c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-03-v6.16-net-dsa-b53-implement-setting-ageing-time.patch @@ -0,0 +1,105 @@ +From e39d14a760c039af0653e3df967e7525413924a0 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Sat, 10 May 2025 11:22:11 +0200 +Subject: [PATCH] net: dsa: b53: implement setting ageing time + +b53 supported switches support configuring ageing time between 1 and +1,048,575 seconds, so add an appropriate setter. + +This allows b53 to pass the FDB learning test for both vlan aware and +vlan unaware bridges. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250510092211.276541-1-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 28 ++++++++++++++++++++++++++++ + drivers/net/dsa/b53/b53_priv.h | 1 + + drivers/net/dsa/b53/b53_regs.h | 7 +++++++ + 3 files changed, 36 insertions(+) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1227,6 +1228,10 @@ static int b53_setup(struct dsa_switch * + */ + ds->untag_vlan_aware_bridge_pvid = true; + ++ /* Ageing time is set in seconds */ ++ ds->ageing_time_min = 1 * 1000; ++ ds->ageing_time_max = AGE_TIME_MAX * 1000; ++ + ret = b53_reset_switch(dev); + if (ret) { + dev_err(ds->dev, "failed to reset switch\n"); +@@ -2466,6 +2471,28 @@ static int b53_get_max_mtu(struct dsa_sw + return B53_MAX_MTU; + } + ++int b53_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) ++{ ++ struct b53_device *dev = ds->priv; ++ u32 atc; ++ int reg; ++ ++ if (is63xx(dev)) ++ reg = B53_AGING_TIME_CONTROL_63XX; ++ else ++ reg = B53_AGING_TIME_CONTROL; ++ ++ atc = DIV_ROUND_CLOSEST(msecs, 1000); ++ ++ if (!is5325(dev) && !is5365(dev)) ++ atc |= AGE_CHANGE; ++ ++ b53_write32(dev, B53_MGMT_PAGE, reg, atc); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(b53_set_ageing_time); ++ + static const struct phylink_mac_ops b53_phylink_mac_ops = { + .mac_select_pcs = b53_phylink_mac_select_pcs, + .mac_config = b53_phylink_mac_config, +@@ -2490,6 +2517,7 @@ static const struct dsa_switch_ops b53_s + .support_eee = b53_support_eee, + .get_mac_eee = b53_get_mac_eee, + .set_mac_eee = b53_set_mac_eee, ++ .set_ageing_time = b53_set_ageing_time, + .port_bridge_join = b53_br_join, + .port_bridge_leave = b53_br_leave, + .port_pre_bridge_flags = b53_br_flags_pre, +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -343,6 +343,7 @@ void b53_get_strings(struct dsa_switch * + void b53_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data); + int b53_get_sset_count(struct dsa_switch *ds, int port, int sset); + void b53_get_ethtool_phy_stats(struct dsa_switch *ds, int port, uint64_t *data); ++int b53_set_ageing_time(struct dsa_switch *ds, unsigned int msecs); + int b53_br_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, + bool *tx_fwd_offload, struct netlink_ext_ack *extack); + void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge); +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -224,6 +224,13 @@ + #define BRCM_HDR_P5_EN BIT(1) /* Enable tagging on port 5 */ + #define BRCM_HDR_P7_EN BIT(2) /* Enable tagging on port 7 */ + ++/* Aging Time control register (32 bit) */ ++#define B53_AGING_TIME_CONTROL 0x06 ++#define B53_AGING_TIME_CONTROL_63XX 0x08 ++#define AGE_CHANGE BIT(20) ++#define AGE_TIME_MASK 0x7ffff ++#define AGE_TIME_MAX 1048575 ++ + /* Mirror capture control register (16 bit) */ + #define B53_MIR_CAP_CTL 0x10 + #define CAP_PORT_MASK 0xf diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-04-v6.16-net-dsa-b53-do-not-configure-bcm63xx-s-IMP-port-inte.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-04-v6.16-net-dsa-b53-do-not-configure-bcm63xx-s-IMP-port-inte.patch new file mode 100755 index 0000000..e70f09e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/610-04-v6.16-net-dsa-b53-do-not-configure-bcm63xx-s-IMP-port-inte.patch @@ -0,0 +1,70 @@ +From 75f4f7b2b13008803f84768ff90396f9d7553221 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Mon, 2 Jun 2025 21:39:51 +0200 +Subject: [PATCH] net: dsa: b53: do not configure bcm63xx's IMP port interface + +The IMP port is not a valid RGMII interface, but hard wired to internal, +so we shouldn't touch the undefined register B53_RGMII_CTRL_IMP. + +While this does not seem to have any side effects, let's not touch it at +all, so limit RGMII configuration on bcm63xx to the actual RGMII ports. + +Fixes: ce3bf94871f7 ("net: dsa: b53: add support for BCM63xx RGMIIs") +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250602193953.1010487-4-jonas.gorski@gmail.com +Signed-off-by: Paolo Abeni +--- + drivers/net/dsa/b53/b53_common.c | 22 ++++++++-------------- + 1 file changed, 8 insertions(+), 14 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1369,24 +1370,17 @@ static void b53_adjust_63xx_rgmii(struct + phy_interface_t interface) + { + struct b53_device *dev = ds->priv; +- u8 rgmii_ctrl = 0, off; +- +- if (port == dev->imp_port) +- off = B53_RGMII_CTRL_IMP; +- else +- off = B53_RGMII_CTRL_P(port); ++ u8 rgmii_ctrl = 0; + +- b53_read8(dev, B53_CTRL_PAGE, off, &rgmii_ctrl); ++ b53_read8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), &rgmii_ctrl); + rgmii_ctrl &= ~(RGMII_CTRL_DLL_RXC | RGMII_CTRL_DLL_TXC); + +- if (port != dev->imp_port) { +- if (is63268(dev)) +- rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE; ++ if (is63268(dev)) ++ rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE; + +- rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII; +- } ++ rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII; + +- b53_write8(dev, B53_CTRL_PAGE, off, rgmii_ctrl); ++ b53_write8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), rgmii_ctrl); + + dev_dbg(ds->dev, "Configured port %d for %s\n", port, + phy_modes(interface)); +@@ -1537,7 +1531,7 @@ static void b53_phylink_mac_config(struc + struct b53_device *dev = ds->priv; + int port = dp->index; + +- if (is63xx(dev) && port >= B53_63XX_RGMII0) ++ if (is63xx(dev) && in_range(port, B53_63XX_RGMII0, 4)) + b53_adjust_63xx_rgmii(ds, port, interface); + + if (mode == MLO_AN_FIXED) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-01-v6.17-net-dsa-tag_brcm-add-support-for-legacy-FCS-tags.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-01-v6.17-net-dsa-tag_brcm-add-support-for-legacy-FCS-tags.patch new file mode 100755 index 0000000..88f10be --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-01-v6.17-net-dsa-tag_brcm-add-support-for-legacy-FCS-tags.patch @@ -0,0 +1,188 @@ +From ef07df397a621707903ef0d294a7df11f80cf206 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 14 Jun 2025 09:59:48 +0200 +Subject: [PATCH] net: dsa: tag_brcm: add support for legacy FCS tags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add support for legacy Broadcom FCS tags, which are similar to +DSA_TAG_PROTO_BRCM_LEGACY. +BCM5325 and BCM5365 switches require including the original FCS value and +length, as opposed to BCM63xx switches. +Adding the original FCS value and length to DSA_TAG_PROTO_BRCM_LEGACY would +impact performance of BCM63xx switches, so it's better to create a new tag. + +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250614080000.1884236-3-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + include/net/dsa.h | 2 ++ + net/dsa/Kconfig | 16 ++++++++-- + net/dsa/tag_brcm.c | 73 +++++++++++++++++++++++++++++++++++++++++++++- + 3 files changed, 88 insertions(+), 3 deletions(-) + +--- a/include/net/dsa.h ++++ b/include/net/dsa.h +@@ -54,11 +54,13 @@ struct tc_action; + #define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26 + #define DSA_TAG_PROTO_LAN937X_VALUE 27 + #define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28 ++#define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29 + + enum dsa_tag_protocol { + DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE, + DSA_TAG_PROTO_BRCM = DSA_TAG_PROTO_BRCM_VALUE, + DSA_TAG_PROTO_BRCM_LEGACY = DSA_TAG_PROTO_BRCM_LEGACY_VALUE, ++ DSA_TAG_PROTO_BRCM_LEGACY_FCS = DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE, + DSA_TAG_PROTO_BRCM_PREPEND = DSA_TAG_PROTO_BRCM_PREPEND_VALUE, + DSA_TAG_PROTO_DSA = DSA_TAG_PROTO_DSA_VALUE, + DSA_TAG_PROTO_EDSA = DSA_TAG_PROTO_EDSA_VALUE, +--- a/net/dsa/Kconfig ++++ b/net/dsa/Kconfig +@@ -42,12 +42,24 @@ config NET_DSA_TAG_BRCM + Broadcom switches which place the tag after the MAC source address. + + config NET_DSA_TAG_BRCM_LEGACY +- tristate "Tag driver for Broadcom legacy switches using in-frame headers" ++ tristate "Tag driver for BCM63xx legacy switches using in-frame headers" + select NET_DSA_TAG_BRCM_COMMON + help + Say Y if you want to enable support for tagging frames for the +- Broadcom legacy switches which place the tag after the MAC source ++ BCM63xx legacy switches which place the tag after the MAC source + address. ++ This tag is used in BCM63xx legacy switches which work without the ++ original FCS and length before the tag insertion. ++ ++config NET_DSA_TAG_BRCM_LEGACY_FCS ++ tristate "Tag driver for BCM53xx legacy switches using in-frame headers" ++ select NET_DSA_TAG_BRCM_COMMON ++ help ++ Say Y if you want to enable support for tagging frames for the ++ BCM53xx legacy switches which place the tag after the MAC source ++ address. ++ This tag is used in BCM53xx legacy switches which expect original ++ FCS and length before the tag insertion to be present. + + config NET_DSA_TAG_BRCM_PREPEND + tristate "Tag driver for Broadcom switches using prepended headers" +--- a/net/dsa/tag_brcm.c ++++ b/net/dsa/tag_brcm.c +@@ -15,6 +15,7 @@ + + #define BRCM_NAME "brcm" + #define BRCM_LEGACY_NAME "brcm-legacy" ++#define BRCM_LEGACY_FCS_NAME "brcm-legacy-fcs" + #define BRCM_PREPEND_NAME "brcm-prepend" + + /* Legacy Broadcom tag (6 bytes) */ +@@ -32,6 +33,10 @@ + #define BRCM_LEG_MULTICAST (1 << 5) + #define BRCM_LEG_EGRESS (2 << 5) + #define BRCM_LEG_INGRESS (3 << 5) ++#define BRCM_LEG_LEN_HI(x) (((x) >> 8) & 0x7) ++ ++/* 4th byte in the tag */ ++#define BRCM_LEG_LEN_LO(x) ((x) & 0xff) + + /* 6th byte in the tag */ + #define BRCM_LEG_PORT_ID (0xf) +@@ -212,7 +217,8 @@ DSA_TAG_DRIVER(brcm_netdev_ops); + MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_BRCM, BRCM_NAME); + #endif + +-#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY) ++#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY) || \ ++ IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY_FCS) + static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb, + struct net_device *dev) + { +@@ -250,7 +256,9 @@ static struct sk_buff *brcm_leg_tag_rcv( + + return skb; + } ++#endif /* CONFIG_NET_DSA_TAG_BRCM_LEGACY || CONFIG_NET_DSA_TAG_BRCM_LEGACY_FCS */ + ++#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY) + static struct sk_buff *brcm_leg_tag_xmit(struct sk_buff *skb, + struct net_device *dev) + { +@@ -300,6 +308,66 @@ DSA_TAG_DRIVER(brcm_legacy_netdev_ops); + MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_BRCM_LEGACY, BRCM_LEGACY_NAME); + #endif /* CONFIG_NET_DSA_TAG_BRCM_LEGACY */ + ++#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY_FCS) ++static struct sk_buff *brcm_leg_fcs_tag_xmit(struct sk_buff *skb, ++ struct net_device *dev) ++{ ++ struct dsa_port *dp = dsa_user_to_port(dev); ++ unsigned int fcs_len; ++ __le32 fcs_val; ++ u8 *brcm_tag; ++ ++ /* The Ethernet switch we are interfaced with needs packets to be at ++ * least 64 bytes (including FCS) otherwise they will be discarded when ++ * they enter the switch port logic. When Broadcom tags are enabled, we ++ * need to make sure that packets are at least 70 bytes (including FCS ++ * and tag) because the length verification is done after the Broadcom ++ * tag is stripped off the ingress packet. ++ * ++ * Let dsa_user_xmit() free the SKB. ++ */ ++ if (__skb_put_padto(skb, ETH_ZLEN + BRCM_LEG_TAG_LEN, false)) ++ return NULL; ++ ++ fcs_len = skb->len; ++ fcs_val = cpu_to_le32(crc32_le(~0, skb->data, fcs_len) ^ ~0); ++ ++ skb_push(skb, BRCM_LEG_TAG_LEN); ++ ++ dsa_alloc_etype_header(skb, BRCM_LEG_TAG_LEN); ++ ++ brcm_tag = skb->data + 2 * ETH_ALEN; ++ ++ /* Broadcom tag type */ ++ brcm_tag[0] = BRCM_LEG_TYPE_HI; ++ brcm_tag[1] = BRCM_LEG_TYPE_LO; ++ ++ /* Broadcom tag value */ ++ brcm_tag[2] = BRCM_LEG_EGRESS | BRCM_LEG_LEN_HI(fcs_len); ++ brcm_tag[3] = BRCM_LEG_LEN_LO(fcs_len); ++ brcm_tag[4] = 0; ++ brcm_tag[5] = dp->index & BRCM_LEG_PORT_ID; ++ ++ /* Original FCS value */ ++ if (__skb_pad(skb, ETH_FCS_LEN, false)) ++ return NULL; ++ skb_put_data(skb, &fcs_val, ETH_FCS_LEN); ++ ++ return skb; ++} ++ ++static const struct dsa_device_ops brcm_legacy_fcs_netdev_ops = { ++ .name = BRCM_LEGACY_FCS_NAME, ++ .proto = DSA_TAG_PROTO_BRCM_LEGACY_FCS, ++ .xmit = brcm_leg_fcs_tag_xmit, ++ .rcv = brcm_leg_tag_rcv, ++ .needed_headroom = BRCM_LEG_TAG_LEN, ++}; ++ ++DSA_TAG_DRIVER(brcm_legacy_fcs_netdev_ops); ++MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_BRCM_LEGACY_FCS, BRCM_LEGACY_FCS_NAME); ++#endif /* CONFIG_NET_DSA_TAG_BRCM_LEGACY_FCS */ ++ + #if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_PREPEND) + static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb, + struct net_device *dev) +@@ -334,6 +402,9 @@ static struct dsa_tag_driver *dsa_tag_dr + #if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY) + &DSA_TAG_DRIVER_NAME(brcm_legacy_netdev_ops), + #endif ++#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY_FCS) ++ &DSA_TAG_DRIVER_NAME(brcm_legacy_fcs_netdev_ops), ++#endif + #if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_PREPEND) + &DSA_TAG_DRIVER_NAME(brcm_prepend_netdev_ops), + #endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-02-v6.17-net-dsa-b53-support-legacy-FCS-tags.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-02-v6.17-net-dsa-b53-support-legacy-FCS-tags.patch new file mode 100755 index 0000000..b04c8ea --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-02-v6.17-net-dsa-b53-support-legacy-FCS-tags.patch @@ -0,0 +1,48 @@ +From c3cf059a4d419b9c888ce7e9952fa13ba7569b61 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 14 Jun 2025 09:59:49 +0200 +Subject: [PATCH] net: dsa: b53: support legacy FCS tags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit 46c5176c586c ("net: dsa: b53: support legacy tags") introduced +support for legacy tags, but it turns out that BCM5325 and BCM5365 +switches require the original FCS value and length, so they have to be +treated differently. + +Reviewed-by: Florian Fainelli +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Link: https://patch.msgid.link/20250614080000.1884236-4-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/Kconfig | 1 + + drivers/net/dsa/b53/b53_common.c | 7 +++++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/net/dsa/b53/Kconfig ++++ b/drivers/net/dsa/b53/Kconfig +@@ -5,6 +5,7 @@ menuconfig B53 + select NET_DSA_TAG_NONE + select NET_DSA_TAG_BRCM + select NET_DSA_TAG_BRCM_LEGACY ++ select NET_DSA_TAG_BRCM_LEGACY_FCS + select NET_DSA_TAG_BRCM_PREPEND + help + This driver adds support for Broadcom managed switch chips. It supports +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2307,8 +2307,11 @@ enum dsa_tag_protocol b53_get_tag_protoc + goto out; + } + +- /* Older models require a different 6 byte tag */ +- if (is5325(dev) || is5365(dev) || is63xx(dev)) { ++ /* Older models require different 6 byte tags */ ++ if (is5325(dev) || is5365(dev)) { ++ dev->tag_protocol = DSA_TAG_PROTO_BRCM_LEGACY_FCS; ++ goto out; ++ } else if (is63xx(dev)) { + dev->tag_protocol = DSA_TAG_PROTO_BRCM_LEGACY; + goto out; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-03-v6.17-net-dsa-b53-detect-BCM5325-variants.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-03-v6.17-net-dsa-b53-detect-BCM5325-variants.patch new file mode 100755 index 0000000..3c2fa2d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-03-v6.17-net-dsa-b53-detect-BCM5325-variants.patch @@ -0,0 +1,112 @@ +From 0cbec9aef5a86194117a956546dc1aec95031f37 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 14 Jun 2025 09:59:50 +0200 +Subject: [PATCH] net: dsa: b53: detect BCM5325 variants +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We need to be able to differentiate the BCM5325 variants because: +- BCM5325M switches lack the ARLIO_PAGE->VLAN_ID_IDX register. +- BCM5325E have less 512 ARL buckets instead of 1024. + +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250614080000.1884236-5-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 24 +++++++++++++++++++++--- + drivers/net/dsa/b53/b53_priv.h | 19 +++++++++++++++++++ + 2 files changed, 40 insertions(+), 3 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1835,7 +1835,8 @@ static int b53_arl_op(struct b53_device + + /* Perform a read for the given MAC and VID */ + b53_write48(dev, B53_ARLIO_PAGE, B53_MAC_ADDR_IDX, mac); +- b53_write16(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid); ++ if (!is5325m(dev)) ++ b53_write16(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid); + + /* Issue a read operation for this MAC */ + ret = b53_arl_rw_op(dev, 1); +@@ -2906,6 +2907,9 @@ static int b53_switch_init(struct b53_de + } + } + ++ if (is5325e(dev)) ++ dev->num_arl_buckets = 512; ++ + dev->num_ports = fls(dev->enabled_ports); + + dev->ds->num_ports = min_t(unsigned int, dev->num_ports, DSA_MAX_PORTS); +@@ -3007,10 +3011,24 @@ int b53_switch_detect(struct b53_device + b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, 0xf); + b53_read16(dev, B53_VLAN_PAGE, B53_VLAN_TABLE_ACCESS_25, &tmp); + +- if (tmp == 0xf) ++ if (tmp == 0xf) { ++ u32 phy_id; ++ int val; ++ + dev->chip_id = BCM5325_DEVICE_ID; +- else ++ ++ val = b53_phy_read16(dev->ds, 0, MII_PHYSID1); ++ phy_id = (val & 0xffff) << 16; ++ val = b53_phy_read16(dev->ds, 0, MII_PHYSID2); ++ phy_id |= (val & 0xfff0); ++ ++ if (phy_id == 0x00406330) ++ dev->variant_id = B53_VARIANT_5325M; ++ else if (phy_id == 0x0143bc30) ++ dev->variant_id = B53_VARIANT_5325E; ++ } else { + dev->chip_id = BCM5365_DEVICE_ID; ++ } + break; + case BCM5389_DEVICE_ID: + case BCM5395_DEVICE_ID: +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -84,6 +84,12 @@ enum { + BCM53134_DEVICE_ID = 0x5075, + }; + ++enum b53_variant_id { ++ B53_VARIANT_NONE = 0, ++ B53_VARIANT_5325E, ++ B53_VARIANT_5325M, ++}; ++ + struct b53_pcs { + struct phylink_pcs pcs; + struct b53_device *dev; +@@ -118,6 +124,7 @@ struct b53_device { + + /* chip specific data */ + u32 chip_id; ++ enum b53_variant_id variant_id; + u8 core_rev; + u8 vta_regs[3]; + u8 duplex_reg; +@@ -165,6 +172,18 @@ static inline int is5325(struct b53_devi + return dev->chip_id == BCM5325_DEVICE_ID; + } + ++static inline int is5325e(struct b53_device *dev) ++{ ++ return is5325(dev) && ++ dev->variant_id == B53_VARIANT_5325E; ++} ++ ++static inline int is5325m(struct b53_device *dev) ++{ ++ return is5325(dev) && ++ dev->variant_id == B53_VARIANT_5325M; ++} ++ + static inline int is5365(struct b53_device *dev) + { + #ifdef CONFIG_BCM47XX diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-04-v6.17-net-dsa-b53-add-support-for-FDB-operations-on-5325-5365.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-04-v6.17-net-dsa-b53-add-support-for-FDB-operations-on-5325-5365.patch new file mode 100755 index 0000000..9de7381 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-04-v6.17-net-dsa-b53-add-support-for-FDB-operations-on-5325-5365.patch @@ -0,0 +1,250 @@ +From c45655386e532c85ff1d679fc2aa40b3aaff9916 Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Sat, 14 Jun 2025 09:59:51 +0200 +Subject: [PATCH] net: dsa: b53: add support for FDB operations on 5325/5365 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BCM5325 and BCM5365 are part of a much older generation of switches which, +due to their limited number of ports and VLAN entries (up to 256) allowed +a single 64-bit register to hold a full ARL entry. +This requires a little bit of massaging when reading, writing and +converting ARL entries in both directions. + +Signed-off-by: Florian Fainelli +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Link: https://patch.msgid.link/20250614080000.1884236-6-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 101 +++++++++++++++++++++++++------ + drivers/net/dsa/b53/b53_priv.h | 29 +++++++++ + drivers/net/dsa/b53/b53_regs.h | 7 ++- + 3 files changed, 115 insertions(+), 22 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1821,6 +1821,45 @@ static int b53_arl_read(struct b53_devic + return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; + } + ++static int b53_arl_read_25(struct b53_device *dev, u64 mac, ++ u16 vid, struct b53_arl_entry *ent, u8 *idx) ++{ ++ DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES); ++ unsigned int i; ++ int ret; ++ ++ ret = b53_arl_op_wait(dev); ++ if (ret) ++ return ret; ++ ++ bitmap_zero(free_bins, dev->num_arl_bins); ++ ++ /* Read the bins */ ++ for (i = 0; i < dev->num_arl_bins; i++) { ++ u64 mac_vid; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, ++ B53_ARLTBL_MAC_VID_ENTRY(i), &mac_vid); ++ ++ b53_arl_to_entry_25(ent, mac_vid); ++ ++ if (!(mac_vid & ARLTBL_VALID_25)) { ++ set_bit(i, free_bins); ++ continue; ++ } ++ if ((mac_vid & ARLTBL_MAC_MASK) != mac) ++ continue; ++ if (dev->vlan_enabled && ++ ((mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25) != vid) ++ continue; ++ *idx = i; ++ return 0; ++ } ++ ++ *idx = find_first_bit(free_bins, dev->num_arl_bins); ++ return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; ++} ++ + static int b53_arl_op(struct b53_device *dev, int op, int port, + const unsigned char *addr, u16 vid, bool is_valid) + { +@@ -1843,7 +1882,10 @@ static int b53_arl_op(struct b53_device + if (ret) + return ret; + +- ret = b53_arl_read(dev, mac, vid, &ent, &idx); ++ if (is5325(dev) || is5365(dev)) ++ ret = b53_arl_read_25(dev, mac, vid, &ent, &idx); ++ else ++ ret = b53_arl_read(dev, mac, vid, &ent, &idx); + + /* If this is a read, just finish now */ + if (op) +@@ -1887,12 +1929,17 @@ static int b53_arl_op(struct b53_device + ent.is_static = true; + ent.is_age = false; + memcpy(ent.mac, addr, ETH_ALEN); +- b53_arl_from_entry(&mac_vid, &fwd_entry, &ent); ++ if (is5325(dev) || is5365(dev)) ++ b53_arl_from_entry_25(&mac_vid, &ent); ++ else ++ b53_arl_from_entry(&mac_vid, &fwd_entry, &ent); + + b53_write64(dev, B53_ARLIO_PAGE, + B53_ARLTBL_MAC_VID_ENTRY(idx), mac_vid); +- b53_write32(dev, B53_ARLIO_PAGE, +- B53_ARLTBL_DATA_ENTRY(idx), fwd_entry); ++ ++ if (!is5325(dev) && !is5365(dev)) ++ b53_write32(dev, B53_ARLIO_PAGE, ++ B53_ARLTBL_DATA_ENTRY(idx), fwd_entry); + + return b53_arl_rw_op(dev, 0); + } +@@ -1904,12 +1951,6 @@ int b53_fdb_add(struct dsa_switch *ds, i + struct b53_device *priv = ds->priv; + int ret; + +- /* 5325 and 5365 require some more massaging, but could +- * be supported eventually +- */ +- if (is5325(priv) || is5365(priv)) +- return -EOPNOTSUPP; +- + mutex_lock(&priv->arl_mutex); + ret = b53_arl_op(priv, 0, port, addr, vid, true); + mutex_unlock(&priv->arl_mutex); +@@ -1936,10 +1977,15 @@ EXPORT_SYMBOL(b53_fdb_del); + static int b53_arl_search_wait(struct b53_device *dev) + { + unsigned int timeout = 1000; +- u8 reg; ++ u8 reg, offset; ++ ++ if (is5325(dev) || is5365(dev)) ++ offset = B53_ARL_SRCH_CTL_25; ++ else ++ offset = B53_ARL_SRCH_CTL; + + do { +- b53_read8(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_CTL, ®); ++ b53_read8(dev, B53_ARLIO_PAGE, offset, ®); + if (!(reg & ARL_SRCH_STDN)) + return -ENOENT; + +@@ -1956,13 +2002,24 @@ static void b53_arl_search_rd(struct b53 + struct b53_arl_entry *ent) + { + u64 mac_vid; +- u32 fwd_entry; + +- b53_read64(dev, B53_ARLIO_PAGE, +- B53_ARL_SRCH_RSTL_MACVID(idx), &mac_vid); +- b53_read32(dev, B53_ARLIO_PAGE, +- B53_ARL_SRCH_RSTL(idx), &fwd_entry); +- b53_arl_to_entry(ent, mac_vid, fwd_entry); ++ if (is5325(dev)) { ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_25, ++ &mac_vid); ++ b53_arl_to_entry_25(ent, mac_vid); ++ } else if (is5365(dev)) { ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_65, ++ &mac_vid); ++ b53_arl_to_entry_25(ent, mac_vid); ++ } else { ++ u32 fwd_entry; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_MACVID(idx), ++ &mac_vid); ++ b53_read32(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL(idx), ++ &fwd_entry); ++ b53_arl_to_entry(ent, mac_vid, fwd_entry); ++ } + } + + static int b53_fdb_copy(int port, const struct b53_arl_entry *ent, +@@ -1986,14 +2043,20 @@ int b53_fdb_dump(struct dsa_switch *ds, + struct b53_device *priv = ds->priv; + struct b53_arl_entry results[2]; + unsigned int count = 0; ++ u8 offset; + int ret; + u8 reg; + + mutex_lock(&priv->arl_mutex); + ++ if (is5325(priv) || is5365(priv)) ++ offset = B53_ARL_SRCH_CTL_25; ++ else ++ offset = B53_ARL_SRCH_CTL; ++ + /* Start search operation */ + reg = ARL_SRCH_STDN; +- b53_write8(priv, B53_ARLIO_PAGE, B53_ARL_SRCH_CTL, reg); ++ b53_write8(priv, offset, B53_ARL_SRCH_CTL, reg); + + do { + ret = b53_arl_search_wait(priv); +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -317,6 +317,19 @@ static inline void b53_arl_to_entry(stru + ent->vid = mac_vid >> ARLTBL_VID_S; + } + ++static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent, ++ u64 mac_vid) ++{ ++ memset(ent, 0, sizeof(*ent)); ++ ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) & ++ ARLTBL_DATA_PORT_ID_MASK_25; ++ ent->is_valid = !!(mac_vid & ARLTBL_VALID_25); ++ ent->is_age = !!(mac_vid & ARLTBL_AGE_25); ++ ent->is_static = !!(mac_vid & ARLTBL_STATIC_25); ++ u64_to_ether_addr(mac_vid, ent->mac); ++ ent->vid = mac_vid >> ARLTBL_VID_S_65; ++} ++ + static inline void b53_arl_from_entry(u64 *mac_vid, u32 *fwd_entry, + const struct b53_arl_entry *ent) + { +@@ -331,6 +344,22 @@ static inline void b53_arl_from_entry(u6 + *fwd_entry |= ARLTBL_AGE; + } + ++static inline void b53_arl_from_entry_25(u64 *mac_vid, ++ const struct b53_arl_entry *ent) ++{ ++ *mac_vid = ether_addr_to_u64(ent->mac); ++ *mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) << ++ ARLTBL_DATA_PORT_ID_S_25; ++ *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) << ++ ARLTBL_VID_S_65; ++ if (ent->is_valid) ++ *mac_vid |= ARLTBL_VALID_25; ++ if (ent->is_static) ++ *mac_vid |= ARLTBL_STATIC_25; ++ if (ent->is_age) ++ *mac_vid |= ARLTBL_AGE_25; ++} ++ + #ifdef CONFIG_BCM47XX + + #include +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -328,9 +328,10 @@ + #define ARLTBL_VID_MASK 0xfff + #define ARLTBL_DATA_PORT_ID_S_25 48 + #define ARLTBL_DATA_PORT_ID_MASK_25 0xf +-#define ARLTBL_AGE_25 BIT(61) +-#define ARLTBL_STATIC_25 BIT(62) +-#define ARLTBL_VALID_25 BIT(63) ++#define ARLTBL_VID_S_65 53 ++#define ARLTBL_AGE_25 BIT_ULL(61) ++#define ARLTBL_STATIC_25 BIT_ULL(62) ++#define ARLTBL_VALID_25 BIT_ULL(63) + + /* ARL Table Data Entry N Registers (32 bit) */ + #define B53_ARLTBL_DATA_ENTRY(n) ((0x10 * (n)) + 0x18) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-05-v6.17-net-dsa-b53-prevent-FAST_AGE-access-on-BCM5325.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-05-v6.17-net-dsa-b53-prevent-FAST_AGE-access-on-BCM5325.patch new file mode 100755 index 0000000..7397e33 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-05-v6.17-net-dsa-b53-prevent-FAST_AGE-access-on-BCM5325.patch @@ -0,0 +1,51 @@ +From 9b6c767c312b4709e9aeb2314a6b47863e7fb72d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 14 Jun 2025 09:59:52 +0200 +Subject: [PATCH] net: dsa: b53: prevent FAST_AGE access on BCM5325 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BCM5325 doesn't implement FAST_AGE registers so we should avoid reading or +writing them. + +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250614080000.1884236-7-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -492,6 +492,9 @@ static int b53_flush_arl(struct b53_devi + { + unsigned int i; + ++ if (is5325(dev)) ++ return 0; ++ + b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_CTRL, + FAST_AGE_DONE | FAST_AGE_DYNAMIC | mask); + +@@ -516,6 +519,9 @@ out: + + static int b53_fast_age_port(struct b53_device *dev, int port) + { ++ if (is5325(dev)) ++ return 0; ++ + b53_write8(dev, B53_CTRL_PAGE, B53_FAST_AGE_PORT_CTRL, port); + + return b53_flush_arl(dev, FAST_AGE_PORT); +@@ -523,6 +529,9 @@ static int b53_fast_age_port(struct b53_ + + static int b53_fast_age_vlan(struct b53_device *dev, u16 vid) + { ++ if (is5325(dev)) ++ return 0; ++ + b53_write16(dev, B53_CTRL_PAGE, B53_FAST_AGE_VID_CTRL, vid); + + return b53_flush_arl(dev, FAST_AGE_VLAN); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-06-v6.17-net-dsa-b53-prevent-BRCM_HDR-access-on-older-devices.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-06-v6.17-net-dsa-b53-prevent-BRCM_HDR-access-on-older-devices.patch new file mode 100755 index 0000000..6ea8367 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-06-v6.17-net-dsa-b53-prevent-BRCM_HDR-access-on-older-devices.patch @@ -0,0 +1,33 @@ +From e17813968b08b1b09bf80699223dea48851cbd07 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 14 Jun 2025 09:59:56 +0200 +Subject: [PATCH] net: dsa: b53: prevent BRCM_HDR access on older devices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Older switches don't implement BRCM_HDR register so we should avoid +reading or writing it. + +Reviewed-by: Florian Fainelli +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Link: https://patch.msgid.link/20250614080000.1884236-11-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -747,6 +747,11 @@ void b53_brcm_hdr_setup(struct dsa_switc + hdr_ctl |= GC_FRM_MGMT_PORT_M; + b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, hdr_ctl); + ++ /* B53_BRCM_HDR not present on devices with legacy tags */ ++ if (dev->tag_protocol == DSA_TAG_PROTO_BRCM_LEGACY || ++ dev->tag_protocol == DSA_TAG_PROTO_BRCM_LEGACY_FCS) ++ return; ++ + /* Enable Broadcom tags for IMP port */ + b53_read8(dev, B53_MGMT_PAGE, B53_BRCM_HDR, &hdr_ctl); + if (tag_en) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-07-v6.17-net-dsa-b53-fix-unicast-multicast-flooding-on-BCM5325.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-07-v6.17-net-dsa-b53-fix-unicast-multicast-flooding-on-BCM5325.patch new file mode 100755 index 0000000..6b9c86e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-07-v6.17-net-dsa-b53-fix-unicast-multicast-flooding-on-BCM5325.patch @@ -0,0 +1,128 @@ +From 651c9e71ffe44e99b5a9b011271c2117f0353b32 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 14 Jun 2025 09:59:58 +0200 +Subject: [PATCH] net: dsa: b53: fix unicast/multicast flooding on BCM5325 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BCM5325 doesn't implement UC_FLOOD_MASK, MC_FLOOD_MASK and IPMC_FLOOD_MASK +registers. +This has to be handled differently with other pages and registers. + +Signed-off-by: Álvaro FernΓ‘ndez Rojas +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250614080000.1884236-13-noltari@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 60 ++++++++++++++++++++++---------- + drivers/net/dsa/b53/b53_regs.h | 13 +++++++ + 2 files changed, 55 insertions(+), 18 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -564,12 +564,24 @@ static void b53_port_set_ucast_flood(str + { + u16 uc; + +- b53_read16(dev, B53_CTRL_PAGE, B53_UC_FLOOD_MASK, &uc); +- if (unicast) +- uc |= BIT(port); +- else +- uc &= ~BIT(port); +- b53_write16(dev, B53_CTRL_PAGE, B53_UC_FLOOD_MASK, uc); ++ if (is5325(dev)) { ++ if (port == B53_CPU_PORT_25) ++ port = B53_CPU_PORT; ++ ++ b53_read16(dev, B53_IEEE_PAGE, B53_IEEE_UCAST_DLF, &uc); ++ if (unicast) ++ uc |= BIT(port) | B53_IEEE_UCAST_DROP_EN; ++ else ++ uc &= ~BIT(port); ++ b53_write16(dev, B53_IEEE_PAGE, B53_IEEE_UCAST_DLF, uc); ++ } else { ++ b53_read16(dev, B53_CTRL_PAGE, B53_UC_FLOOD_MASK, &uc); ++ if (unicast) ++ uc |= BIT(port); ++ else ++ uc &= ~BIT(port); ++ b53_write16(dev, B53_CTRL_PAGE, B53_UC_FLOOD_MASK, uc); ++ } + } + + static void b53_port_set_mcast_flood(struct b53_device *dev, int port, +@@ -577,19 +589,31 @@ static void b53_port_set_mcast_flood(str + { + u16 mc; + +- b53_read16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, &mc); +- if (multicast) +- mc |= BIT(port); +- else +- mc &= ~BIT(port); +- b53_write16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, mc); +- +- b53_read16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, &mc); +- if (multicast) +- mc |= BIT(port); +- else +- mc &= ~BIT(port); +- b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc); ++ if (is5325(dev)) { ++ if (port == B53_CPU_PORT_25) ++ port = B53_CPU_PORT; ++ ++ b53_read16(dev, B53_IEEE_PAGE, B53_IEEE_MCAST_DLF, &mc); ++ if (multicast) ++ mc |= BIT(port) | B53_IEEE_MCAST_DROP_EN; ++ else ++ mc &= ~BIT(port); ++ b53_write16(dev, B53_IEEE_PAGE, B53_IEEE_MCAST_DLF, mc); ++ } else { ++ b53_read16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, &mc); ++ if (multicast) ++ mc |= BIT(port); ++ else ++ mc &= ~BIT(port); ++ b53_write16(dev, B53_CTRL_PAGE, B53_MC_FLOOD_MASK, mc); ++ ++ b53_read16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, &mc); ++ if (multicast) ++ mc |= BIT(port); ++ else ++ mc &= ~BIT(port); ++ b53_write16(dev, B53_CTRL_PAGE, B53_IPMC_FLOOD_MASK, mc); ++ } + } + + static void b53_port_set_learning(struct b53_device *dev, int port, +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -29,6 +29,7 @@ + #define B53_ARLIO_PAGE 0x05 /* ARL Access */ + #define B53_FRAMEBUF_PAGE 0x06 /* Management frame access */ + #define B53_MEM_ACCESS_PAGE 0x08 /* Memory access */ ++#define B53_IEEE_PAGE 0x0a /* IEEE 802.1X */ + + /* PHY Registers */ + #define B53_PORT_MII_PAGE(i) (0x10 + (i)) /* Port i MII Registers */ +@@ -371,6 +372,18 @@ + #define B53_ARL_SRCH_RSTL(x) (B53_ARL_SRCH_RSTL_0 + ((x) * 0x10)) + + /************************************************************************* ++ * IEEE 802.1X Registers ++ *************************************************************************/ ++ ++/* Multicast DLF Drop Control register (16 bit) */ ++#define B53_IEEE_MCAST_DLF 0x94 ++#define B53_IEEE_MCAST_DROP_EN BIT(11) ++ ++/* Unicast DLF Drop Control register (16 bit) */ ++#define B53_IEEE_UCAST_DLF 0x96 ++#define B53_IEEE_UCAST_DROP_EN BIT(11) ++ ++/************************************************************************* + * Port VLAN Registers + *************************************************************************/ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-08-v6.18-net-dsa-b53-Add-phy_enable-phy_disable-methods.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-08-v6.18-net-dsa-b53-Add-phy_enable-phy_disable-methods.patch new file mode 100755 index 0000000..14106e3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-08-v6.18-net-dsa-b53-Add-phy_enable-phy_disable-methods.patch @@ -0,0 +1,50 @@ +From be7a79145d85af1a9d65a45560b9243b13a67782 Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 23 Jul 2025 20:52:40 -0700 +Subject: [PATCH] net: dsa: b53: Add phy_enable(), phy_disable() methods + +Add phy enable/disable to b53 ops to be called when +enabling/disabling ports. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250724035300.20497-2-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 6 ++++++ + drivers/net/dsa/b53/b53_priv.h | 2 ++ + 2 files changed, 8 insertions(+) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -689,6 +689,9 @@ int b53_enable_port(struct dsa_switch *d + + cpu_port = dsa_to_port(ds, port)->cpu_dp->index; + ++ if (dev->ops->phy_enable) ++ dev->ops->phy_enable(dev, port); ++ + if (dev->ops->irq_enable) + ret = dev->ops->irq_enable(dev, port); + if (ret) +@@ -727,6 +730,9 @@ void b53_disable_port(struct dsa_switch + reg |= PORT_CTRL_RX_DISABLE | PORT_CTRL_TX_DISABLE; + b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), reg); + ++ if (dev->ops->phy_disable) ++ dev->ops->phy_disable(dev, port); ++ + if (dev->ops->irq_disable) + dev->ops->irq_disable(dev, port); + } +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -45,6 +45,8 @@ struct b53_io_ops { + int (*phy_write16)(struct b53_device *dev, int addr, int reg, u16 value); + int (*irq_enable)(struct b53_device *dev, int port); + void (*irq_disable)(struct b53_device *dev, int port); ++ void (*phy_enable)(struct b53_device *dev, int port); ++ void (*phy_disable)(struct b53_device *dev, int port); + void (*phylink_get_caps)(struct b53_device *dev, int port, + struct phylink_config *config); + struct phylink_pcs *(*phylink_mac_select_pcs)(struct b53_device *dev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-09-v6.18-net-dsa-b53-Define-chip-IDs-for-more-bcm63xx-SoCs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-09-v6.18-net-dsa-b53-Define-chip-IDs-for-more-bcm63xx-SoCs.patch new file mode 100755 index 0000000..0e03916 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-09-v6.18-net-dsa-b53-Define-chip-IDs-for-more-bcm63xx-SoCs.patch @@ -0,0 +1,124 @@ +From fcf02a462fab52fbfcb24e617dd940745afd0dff Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 23 Jul 2025 20:52:42 -0700 +Subject: [PATCH] net: dsa: b53: Define chip IDs for more bcm63xx SoCs + +Add defines for bcm6318, bcm6328, bcm6362, bcm6368 chip IDs, +update tables and switch init. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250724035300.20497-4-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 21 ++++++--------------- + drivers/net/dsa/b53/b53_mmap.c | 8 ++++---- + drivers/net/dsa/b53/b53_priv.h | 13 +++++++++++-- + 3 files changed, 21 insertions(+), 21 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1419,7 +1419,7 @@ static void b53_adjust_63xx_rgmii(struct + b53_read8(dev, B53_CTRL_PAGE, B53_RGMII_CTRL_P(port), &rgmii_ctrl); + rgmii_ctrl &= ~(RGMII_CTRL_DLL_RXC | RGMII_CTRL_DLL_TXC); + +- if (is63268(dev)) ++ if (is6318_268(dev)) + rgmii_ctrl |= RGMII_CTRL_MII_OVERRIDE; + + rgmii_ctrl |= RGMII_CTRL_ENABLE_GMII; +@@ -2804,19 +2804,6 @@ static const struct b53_chip_data b53_sw + .jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX, + }, + { +- .chip_id = BCM63268_DEVICE_ID, +- .dev_name = "BCM63268", +- .vlans = 4096, +- .enabled_ports = 0, /* pdata must provide them */ +- .arl_bins = 4, +- .arl_buckets = 1024, +- .imp_port = 8, +- .vta_regs = B53_VTA_REGS_63XX, +- .duplex_reg = B53_DUPLEX_STAT_63XX, +- .jumbo_pm_reg = B53_JUMBO_PORT_MASK_63XX, +- .jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX, +- }, +- { + .chip_id = BCM53010_DEVICE_ID, + .dev_name = "BCM53010", + .vlans = 4096, +@@ -2965,13 +2952,17 @@ static const struct b53_chip_data b53_sw + + static int b53_switch_init(struct b53_device *dev) + { ++ u32 chip_id = dev->chip_id; + unsigned int i; + int ret; + ++ if (is63xx(dev)) ++ chip_id = BCM63XX_DEVICE_ID; ++ + for (i = 0; i < ARRAY_SIZE(b53_switch_chips); i++) { + const struct b53_chip_data *chip = &b53_switch_chips[i]; + +- if (chip->chip_id == dev->chip_id) { ++ if (chip->chip_id == chip_id) { + if (!dev->enabled_ports) + dev->enabled_ports = chip->enabled_ports; + dev->name = chip->dev_name; +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -348,16 +348,16 @@ static const struct of_device_id b53_mma + .data = (void *)BCM63XX_DEVICE_ID, + }, { + .compatible = "brcm,bcm6318-switch", +- .data = (void *)BCM63268_DEVICE_ID, ++ .data = (void *)BCM6318_DEVICE_ID, + }, { + .compatible = "brcm,bcm6328-switch", +- .data = (void *)BCM63XX_DEVICE_ID, ++ .data = (void *)BCM6328_DEVICE_ID, + }, { + .compatible = "brcm,bcm6362-switch", +- .data = (void *)BCM63XX_DEVICE_ID, ++ .data = (void *)BCM6362_DEVICE_ID, + }, { + .compatible = "brcm,bcm6368-switch", +- .data = (void *)BCM63XX_DEVICE_ID, ++ .data = (void *)BCM6368_DEVICE_ID, + }, { + .compatible = "brcm,bcm63268-switch", + .data = (void *)BCM63268_DEVICE_ID, +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -73,6 +73,10 @@ enum { + BCM53125_DEVICE_ID = 0x53125, + BCM53128_DEVICE_ID = 0x53128, + BCM63XX_DEVICE_ID = 0x6300, ++ BCM6318_DEVICE_ID = 0x6318, ++ BCM6328_DEVICE_ID = 0x6328, ++ BCM6362_DEVICE_ID = 0x6362, ++ BCM6368_DEVICE_ID = 0x6368, + BCM63268_DEVICE_ID = 0x63268, + BCM53010_DEVICE_ID = 0x53010, + BCM53011_DEVICE_ID = 0x53011, +@@ -220,12 +224,17 @@ static inline int is531x5(struct b53_dev + static inline int is63xx(struct b53_device *dev) + { + return dev->chip_id == BCM63XX_DEVICE_ID || ++ dev->chip_id == BCM6318_DEVICE_ID || ++ dev->chip_id == BCM6328_DEVICE_ID || ++ dev->chip_id == BCM6362_DEVICE_ID || ++ dev->chip_id == BCM6368_DEVICE_ID || + dev->chip_id == BCM63268_DEVICE_ID; + } + +-static inline int is63268(struct b53_device *dev) ++static inline int is6318_268(struct b53_device *dev) + { +- return dev->chip_id == BCM63268_DEVICE_ID; ++ return dev->chip_id == BCM6318_DEVICE_ID || ++ dev->chip_id == BCM63268_DEVICE_ID; + } + + static inline int is5301x(struct b53_device *dev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-10-v6.18-net-dsa-b53-mmap-Add-syscon-reference-and-register-layout-for-bcm63268.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-10-v6.18-net-dsa-b53-mmap-Add-syscon-reference-and-register-layout-for-bcm63268.patch new file mode 100755 index 0000000..92e540d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-10-v6.18-net-dsa-b53-mmap-Add-syscon-reference-and-register-layout-for-bcm63268.patch @@ -0,0 +1,69 @@ +From aed2aaa3c963f8aabbfa061a177022fee826ebfb Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 23 Jul 2025 20:52:43 -0700 +Subject: [PATCH] net: dsa: b53: mmap: Add syscon reference and register layout + for bcm63268 + +On bcm63xx SoCs there are registers that control the PHYs in +the GPIO controller. Allow the b53 driver to access them +by passing in the syscon through the device tree. + +Add a structure to describe the ephy control register +and add register info for bcm63268. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250724035300.20497-5-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_mmap.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -21,13 +21,32 @@ + #include + #include + #include ++#include + #include + #include + + #include "b53_priv.h" + ++struct b53_phy_info { ++ u32 ephy_enable_mask; ++ u32 ephy_port_mask; ++ u32 ephy_bias_bit; ++ const u32 *ephy_offset; ++}; ++ + struct b53_mmap_priv { + void __iomem *regs; ++ struct regmap *gpio_ctrl; ++ const struct b53_phy_info *phy_info; ++}; ++ ++static const u32 bcm63268_ephy_offsets[] = {4, 9, 14}; ++ ++static const struct b53_phy_info bcm63268_ephy_info = { ++ .ephy_enable_mask = GENMASK(4, 0), ++ .ephy_port_mask = GENMASK((ARRAY_SIZE(bcm63268_ephy_offsets) - 1), 0), ++ .ephy_bias_bit = 24, ++ .ephy_offset = bcm63268_ephy_offsets, + }; + + static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) +@@ -313,6 +332,12 @@ static int b53_mmap_probe(struct platfor + + priv->regs = pdata->regs; + ++ priv->gpio_ctrl = syscon_regmap_lookup_by_phandle(np, "brcm,gpio-ctrl"); ++ if (!IS_ERR(priv->gpio_ctrl)) { ++ if (pdata->chip_id == BCM63268_DEVICE_ID) ++ priv->phy_info = &bcm63268_ephy_info; ++ } ++ + dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, priv); + if (!dev) + return -ENOMEM; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-11-v6.18-net-dsa-b53-mmap-Add-register-layout-for-bcm6318.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-11-v6.18-net-dsa-b53-mmap-Add-register-layout-for-bcm6318.patch new file mode 100755 index 0000000..f6c1cba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-11-v6.18-net-dsa-b53-mmap-Add-register-layout-for-bcm6318.patch @@ -0,0 +1,47 @@ +From c251304ab021ff21c77e83e0babcb9eb76f8787a Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 23 Jul 2025 20:52:44 -0700 +Subject: [PATCH] net: dsa: b53: mmap: Add register layout for bcm6318 + +Add ephy register info for bcm6318, which also applies to +bcm6328 and bcm6362. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250724035300.20497-6-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_mmap.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -40,6 +40,15 @@ struct b53_mmap_priv { + const struct b53_phy_info *phy_info; + }; + ++static const u32 bcm6318_ephy_offsets[] = {4, 5, 6, 7}; ++ ++static const struct b53_phy_info bcm6318_ephy_info = { ++ .ephy_enable_mask = BIT(0) | BIT(4) | BIT(8) | BIT(12) | BIT(16), ++ .ephy_port_mask = GENMASK((ARRAY_SIZE(bcm6318_ephy_offsets) - 1), 0), ++ .ephy_bias_bit = 24, ++ .ephy_offset = bcm6318_ephy_offsets, ++}; ++ + static const u32 bcm63268_ephy_offsets[] = {4, 9, 14}; + + static const struct b53_phy_info bcm63268_ephy_info = { +@@ -334,7 +343,11 @@ static int b53_mmap_probe(struct platfor + + priv->gpio_ctrl = syscon_regmap_lookup_by_phandle(np, "brcm,gpio-ctrl"); + if (!IS_ERR(priv->gpio_ctrl)) { +- if (pdata->chip_id == BCM63268_DEVICE_ID) ++ if (pdata->chip_id == BCM6318_DEVICE_ID || ++ pdata->chip_id == BCM6328_DEVICE_ID || ++ pdata->chip_id == BCM6362_DEVICE_ID) ++ priv->phy_info = &bcm6318_ephy_info; ++ else if (pdata->chip_id == BCM63268_DEVICE_ID) + priv->phy_info = &bcm63268_ephy_info; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-12-v6.18-net-dsa-b53-mmap-Add-register-layout-for-bcm6368.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-12-v6.18-net-dsa-b53-mmap-Add-register-layout-for-bcm6368.patch new file mode 100755 index 0000000..f703804 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-12-v6.18-net-dsa-b53-mmap-Add-register-layout-for-bcm6368.patch @@ -0,0 +1,42 @@ +From e8e13073dff7052b144d002bae2cfe9ddfa27e2a Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 23 Jul 2025 20:52:45 -0700 +Subject: [PATCH] net: dsa: b53: mmap: Add register layout for bcm6368 + +Add ephy register info for bcm6368. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250724035300.20497-7-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_mmap.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -49,6 +49,15 @@ static const struct b53_phy_info bcm6318 + .ephy_offset = bcm6318_ephy_offsets, + }; + ++static const u32 bcm6368_ephy_offsets[] = {2, 3, 4, 5}; ++ ++static const struct b53_phy_info bcm6368_ephy_info = { ++ .ephy_enable_mask = BIT(0), ++ .ephy_port_mask = GENMASK((ARRAY_SIZE(bcm6368_ephy_offsets) - 1), 0), ++ .ephy_bias_bit = 0, ++ .ephy_offset = bcm6368_ephy_offsets, ++}; ++ + static const u32 bcm63268_ephy_offsets[] = {4, 9, 14}; + + static const struct b53_phy_info bcm63268_ephy_info = { +@@ -347,6 +356,8 @@ static int b53_mmap_probe(struct platfor + pdata->chip_id == BCM6328_DEVICE_ID || + pdata->chip_id == BCM6362_DEVICE_ID) + priv->phy_info = &bcm6318_ephy_info; ++ else if (pdata->chip_id == BCM6368_DEVICE_ID) ++ priv->phy_info = &bcm6368_ephy_info; + else if (pdata->chip_id == BCM63268_DEVICE_ID) + priv->phy_info = &bcm63268_ephy_info; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-13-v6.18-net-dsa-b53-mmap-Implement-bcm63xx-ephy-power-control.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-13-v6.18-net-dsa-b53-mmap-Implement-bcm63xx-ephy-power-control.patch new file mode 100755 index 0000000..bf3aeb7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-13-v6.18-net-dsa-b53-mmap-Implement-bcm63xx-ephy-power-control.patch @@ -0,0 +1,100 @@ +From 5ac00023852d960528a0c1d10ae6c17893fc4113 Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 23 Jul 2025 20:52:46 -0700 +Subject: [PATCH] net: dsa: b53: mmap: Implement bcm63xx ephy power control + +Implement the phy enable/disable calls for b53 mmap, and +set the power down registers in the ephy control register +appropriately. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250724035300.20497-8-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_mmap.c | 50 ++++++++++++++++++++++++++++++++++ + 1 file changed, 50 insertions(+) + +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -24,9 +24,12 @@ + #include + #include + #include ++#include + + #include "b53_priv.h" + ++#define BCM63XX_EPHY_REG 0x3C ++ + struct b53_phy_info { + u32 ephy_enable_mask; + u32 ephy_port_mask; +@@ -38,6 +41,7 @@ struct b53_mmap_priv { + void __iomem *regs; + struct regmap *gpio_ctrl; + const struct b53_phy_info *phy_info; ++ u32 phys_enabled; + }; + + static const u32 bcm6318_ephy_offsets[] = {4, 5, 6, 7}; +@@ -266,6 +270,50 @@ static int b53_mmap_phy_write16(struct b + return -EIO; + } + ++static int bcm63xx_ephy_set(struct b53_device *dev, int port, bool enable) ++{ ++ struct b53_mmap_priv *priv = dev->priv; ++ const struct b53_phy_info *info = priv->phy_info; ++ struct regmap *gpio_ctrl = priv->gpio_ctrl; ++ u32 mask, val; ++ ++ if (enable) { ++ mask = (info->ephy_enable_mask << info->ephy_offset[port]) ++ | BIT(info->ephy_bias_bit); ++ val = 0; ++ } else { ++ mask = (info->ephy_enable_mask << info->ephy_offset[port]); ++ if (!((priv->phys_enabled & ~BIT(port)) & info->ephy_port_mask)) ++ mask |= BIT(info->ephy_bias_bit); ++ val = mask; ++ } ++ return regmap_update_bits(gpio_ctrl, BCM63XX_EPHY_REG, mask, val); ++} ++ ++static void b53_mmap_phy_enable(struct b53_device *dev, int port) ++{ ++ struct b53_mmap_priv *priv = dev->priv; ++ int ret = 0; ++ ++ if (priv->phy_info && (BIT(port) & priv->phy_info->ephy_port_mask)) ++ ret = bcm63xx_ephy_set(dev, port, true); ++ ++ if (!ret) ++ priv->phys_enabled |= BIT(port); ++} ++ ++static void b53_mmap_phy_disable(struct b53_device *dev, int port) ++{ ++ struct b53_mmap_priv *priv = dev->priv; ++ int ret = 0; ++ ++ if (priv->phy_info && (BIT(port) & priv->phy_info->ephy_port_mask)) ++ ret = bcm63xx_ephy_set(dev, port, false); ++ ++ if (!ret) ++ priv->phys_enabled &= ~BIT(port); ++} ++ + static const struct b53_io_ops b53_mmap_ops = { + .read8 = b53_mmap_read8, + .read16 = b53_mmap_read16, +@@ -279,6 +327,8 @@ static const struct b53_io_ops b53_mmap_ + .write64 = b53_mmap_write64, + .phy_read16 = b53_mmap_phy_read16, + .phy_write16 = b53_mmap_phy_write16, ++ .phy_enable = b53_mmap_phy_enable, ++ .phy_disable = b53_mmap_phy_disable, + }; + + static int b53_mmap_probe_of(struct platform_device *pdev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-14-v6.18-net-dsa-b53-mmap-Add-gphy-port-to-phy-info-for-bcm63268.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-14-v6.18-net-dsa-b53-mmap-Add-gphy-port-to-phy-info-for-bcm63268.patch new file mode 100755 index 0000000..9aa99d2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-14-v6.18-net-dsa-b53-mmap-Add-gphy-port-to-phy-info-for-bcm63268.patch @@ -0,0 +1,33 @@ +From 7f95f04fe1903a31b61085e3ab1b4730f9d72941 Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 13 Aug 2025 17:25:27 -0700 +Subject: [PATCH] net: dsa: b53: mmap: Add gphy port to phy info for bcm63268 + +Add gphy mask to bcm63xx phy info struct and add data for bcm63268 + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250814002530.5866-2-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_mmap.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -31,6 +31,7 @@ + #define BCM63XX_EPHY_REG 0x3C + + struct b53_phy_info { ++ u32 gphy_port_mask; + u32 ephy_enable_mask; + u32 ephy_port_mask; + u32 ephy_bias_bit; +@@ -65,6 +66,7 @@ static const struct b53_phy_info bcm6368 + static const u32 bcm63268_ephy_offsets[] = {4, 9, 14}; + + static const struct b53_phy_info bcm63268_ephy_info = { ++ .gphy_port_mask = BIT(3), + .ephy_enable_mask = GENMASK(4, 0), + .ephy_port_mask = GENMASK((ARRAY_SIZE(bcm63268_ephy_offsets) - 1), 0), + .ephy_bias_bit = 24, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-15-v6.18-net-dsa-b53-mmap-Implement-bcm63268-gphy-power-control.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-15-v6.18-net-dsa-b53-mmap-Implement-bcm63268-gphy-power-control.patch new file mode 100755 index 0000000..8dda51e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-15-v6.18-net-dsa-b53-mmap-Implement-bcm63268-gphy-power-control.patch @@ -0,0 +1,77 @@ +From 61730ac10ba90c52563861a0119504f6a9be9868 Mon Sep 17 00:00:00 2001 +From: Kyle Hendry +Date: Wed, 13 Aug 2025 17:25:28 -0700 +Subject: [PATCH] net: dsa: b53: mmap: Implement bcm63268 gphy power control + +Add check for gphy in enable/disable phy calls and set power bits +in gphy control register. + +Signed-off-by: Kyle Hendry +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250814002530.5866-3-kylehendrydev@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_mmap.c | 33 +++++++++++++++++++++++++++++---- + 1 file changed, 29 insertions(+), 4 deletions(-) + +--- a/drivers/net/dsa/b53/b53_mmap.c ++++ b/drivers/net/dsa/b53/b53_mmap.c +@@ -29,6 +29,10 @@ + #include "b53_priv.h" + + #define BCM63XX_EPHY_REG 0x3C ++#define BCM63268_GPHY_REG 0x54 ++ ++#define GPHY_CTRL_LOW_PWR BIT(3) ++#define GPHY_CTRL_IDDQ_BIAS BIT(0) + + struct b53_phy_info { + u32 gphy_port_mask; +@@ -292,13 +296,30 @@ static int bcm63xx_ephy_set(struct b53_d + return regmap_update_bits(gpio_ctrl, BCM63XX_EPHY_REG, mask, val); + } + ++static int bcm63268_gphy_set(struct b53_device *dev, bool enable) ++{ ++ struct b53_mmap_priv *priv = dev->priv; ++ struct regmap *gpio_ctrl = priv->gpio_ctrl; ++ u32 mask = GPHY_CTRL_IDDQ_BIAS | GPHY_CTRL_LOW_PWR; ++ u32 val = 0; ++ ++ if (!enable) ++ val = mask; ++ ++ return regmap_update_bits(gpio_ctrl, BCM63268_GPHY_REG, mask, val); ++} ++ + static void b53_mmap_phy_enable(struct b53_device *dev, int port) + { + struct b53_mmap_priv *priv = dev->priv; + int ret = 0; + +- if (priv->phy_info && (BIT(port) & priv->phy_info->ephy_port_mask)) +- ret = bcm63xx_ephy_set(dev, port, true); ++ if (priv->phy_info) { ++ if (BIT(port) & priv->phy_info->ephy_port_mask) ++ ret = bcm63xx_ephy_set(dev, port, true); ++ else if (BIT(port) & priv->phy_info->gphy_port_mask) ++ ret = bcm63268_gphy_set(dev, true); ++ } + + if (!ret) + priv->phys_enabled |= BIT(port); +@@ -309,8 +330,12 @@ static void b53_mmap_phy_disable(struct + struct b53_mmap_priv *priv = dev->priv; + int ret = 0; + +- if (priv->phy_info && (BIT(port) & priv->phy_info->ephy_port_mask)) +- ret = bcm63xx_ephy_set(dev, port, false); ++ if (priv->phy_info) { ++ if (BIT(port) & priv->phy_info->ephy_port_mask) ++ ret = bcm63xx_ephy_set(dev, port, false); ++ else if (BIT(port) & priv->phy_info->gphy_port_mask) ++ ret = bcm63268_gphy_set(dev, false); ++ } + + if (!ret) + priv->phys_enabled &= ~BIT(port); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-16-v6.18-net-dsa-b53-fix-reserved-register-access-in-b53_fdb_dump.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-16-v6.18-net-dsa-b53-fix-reserved-register-access-in-b53_fdb_dump.patch new file mode 100755 index 0000000..5190cf9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-16-v6.18-net-dsa-b53-fix-reserved-register-access-in-b53_fdb_dump.patch @@ -0,0 +1,72 @@ +From 89eb9a62aed77b409663ba1eac152e8f758815b7 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 15 Aug 2025 22:18:09 +0200 +Subject: [PATCH] net: dsa: b53: fix reserved register access in b53_fdb_dump() + +When BCM5325 support was added in c45655386e53 ("net: dsa: b53: add +support for FDB operations on 5325/5365"), the register used for ARL access +was made conditional on the chip. + +But in b53_fdb_dump(), instead of the register argument the page +argument was replaced, causing it to write to a reserved page 0x50 on +!BCM5325*. Writing to this page seems to completely lock the switch up: + +[ 89.680000] b53-switch spi0.1 lan2: Link is Down +[ 89.680000] WARNING: CPU: 1 PID: 26 at drivers/net/phy/phy.c:1350 _phy_state_machine+0x1bc/0x454 +[ 89.720000] phy_check_link_status+0x0/0x114: returned: -5 +[ 89.730000] Modules linked in: nft_fib_inet nf_flow_table_inet nft_reject_ipv6 nft_reject_ipv4 nft_reject_inet nft_reject nft_redir nft_quota nft_numgen nft_nat nft_masq nft_log nft_limit nft_hash nft_flow_offload nft_fib_ipv6 nft_fib_ipv4 nft_fib nft_ct nft_chain_nat nf_tables nf_nat nf_flow_table nf_conntrack nfnetlink nf_reject_ipv6 nf_reject_ipv4 nf_log_syslog nf_defrag_ipv6 nf_defrag_ipv4 cls_flower sch_tbf sch_ingress sch_htb sch_hfsc em_u32 cls_u32 cls_route cls_matchall cls_fw cls_flow cls_basic act_skbedit act_mirred act_gact vrf md5 crc32c_cryptoapi +[ 89.780000] CPU: 1 UID: 0 PID: 26 Comm: kworker/u10:0 Tainted: G W 6.16.0-rc1+ #0 NONE +[ 89.780000] Tainted: [W]=WARN +[ 89.780000] Hardware name: Netgear DGND3700 v1 +[ 89.780000] Workqueue: events_power_efficient phy_state_machine +[ 89.780000] Stack : 809c762c 8006b050 00000001 820a9ce3 0000114c 000affff 805d22d0 8200ba00 +[ 89.780000] 82005000 6576656e 74735f70 6f776572 5f656666 10008b00 820a9cb8 82088700 +[ 89.780000] 00000000 00000000 809c762c 820a9a98 00000000 00000000 ffffefff 80a7a76c +[ 89.780000] 80a70000 820a9af8 80a70000 80a70000 80a70000 00000000 809c762c 820a9dd4 +[ 89.780000] 00000000 805d1494 80a029e4 80a70000 00000003 00000000 00000004 81a60004 +[ 89.780000] ... +[ 89.780000] Call Trace: +[ 89.780000] [<800228b8>] show_stack+0x38/0x118 +[ 89.780000] [<8001afc4>] dump_stack_lvl+0x6c/0xac +[ 89.780000] [<80046b90>] __warn+0x9c/0x114 +[ 89.780000] [<80046da8>] warn_slowpath_fmt+0x1a0/0x1b0 +[ 89.780000] [<805d1494>] _phy_state_machine+0x1bc/0x454 +[ 89.780000] [<805d22fc>] phy_state_machine+0x2c/0x70 +[ 89.780000] [<80066b08>] process_one_work+0x1e8/0x3e0 +[ 89.780000] [<80067a1c>] worker_thread+0x354/0x4e4 +[ 89.780000] [<800706cc>] kthread+0x130/0x274 +[ 89.780000] [<8001d808>] ret_from_kernel_thread+0x14/0x1c + +And any further accesses fail: + +[ 120.790000] b53-switch spi0.1: timeout waiting for ARL to finish: 0x81 +[ 120.800000] b53-switch spi0.1: port 2 failed to add 2c:b0:5d:27:9a:bd vid 3 to fdb: -145 +[ 121.010000] b53-switch spi0.1: timeout waiting for ARL to finish: 0xbf +[ 121.020000] b53-switch spi0.1: port 3 failed to add 2c:b0:5d:27:9a:bd vid 3 to fdb: -145 + +Restore the correct page B53_ARLIO_PAGE again, and move the offset +argument to the correct place. + +*On BCM5325, this became a write to the MIB page of Port 1. Still +a reserved offset, but likely less brokenness from that write. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250815201809.549195-1-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2100,7 +2100,7 @@ int b53_fdb_dump(struct dsa_switch *ds, + + /* Start search operation */ + reg = ARL_SRCH_STDN; +- b53_write8(priv, offset, B53_ARL_SRCH_CTL, reg); ++ b53_write8(priv, B53_ARLIO_PAGE, offset, reg); + + do { + ret = b53_arl_search_wait(priv); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-17-v6.18-net-dsa-b53-fix-ageing-time-for-BCM53101.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-17-v6.18-net-dsa-b53-fix-ageing-time-for-BCM53101.patch new file mode 100755 index 0000000..0eb0870 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-17-v6.18-net-dsa-b53-fix-ageing-time-for-BCM53101.patch @@ -0,0 +1,77 @@ +From 674b34c4c770551e916ae707829c7faea4782d3a Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 5 Sep 2025 14:45:07 +0200 +Subject: [PATCH] net: dsa: b53: fix ageing time for BCM53101 + +For some reason Broadcom decided that BCM53101 uses 0.5s increments for +the ageing time register, but kept the field width the same [1]. Due to +this, the actual ageing time was always half of what was configured. + +Fix this by adapting the limits and value calculation for BCM53101. + +So far it looks like this is the only chip with the increased tick +speed: + +$ grep -l -r "Specifies the aging time in 0.5 seconds" cdk/PKG/chip | sort +cdk/PKG/chip/bcm53101/bcm53101_a0_defs.h + +$ grep -l -r "Specifies the aging time in seconds" cdk/PKG/chip | sort +cdk/PKG/chip/bcm53010/bcm53010_a0_defs.h +cdk/PKG/chip/bcm53020/bcm53020_a0_defs.h +cdk/PKG/chip/bcm53084/bcm53084_a0_defs.h +cdk/PKG/chip/bcm53115/bcm53115_a0_defs.h +cdk/PKG/chip/bcm53118/bcm53118_a0_defs.h +cdk/PKG/chip/bcm53125/bcm53125_a0_defs.h +cdk/PKG/chip/bcm53128/bcm53128_a0_defs.h +cdk/PKG/chip/bcm53134/bcm53134_a0_defs.h +cdk/PKG/chip/bcm53242/bcm53242_a0_defs.h +cdk/PKG/chip/bcm53262/bcm53262_a0_defs.h +cdk/PKG/chip/bcm53280/bcm53280_a0_defs.h +cdk/PKG/chip/bcm53280/bcm53280_b0_defs.h +cdk/PKG/chip/bcm53600/bcm53600_a0_defs.h +cdk/PKG/chip/bcm89500/bcm89500_a0_defs.h + +[1] https://github.com/Broadcom/OpenMDK/blob/a5d3fc9b12af3eeb68f2ca0ce7ec4056cd14d6c2/cdk/PKG/chip/bcm53101/bcm53101_a0_defs.h#L28966 + +Fixes: e39d14a760c0 ("net: dsa: b53: implement setting ageing time") +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20250905124507.59186-1-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1273,9 +1273,15 @@ static int b53_setup(struct dsa_switch * + */ + ds->untag_vlan_aware_bridge_pvid = true; + +- /* Ageing time is set in seconds */ +- ds->ageing_time_min = 1 * 1000; +- ds->ageing_time_max = AGE_TIME_MAX * 1000; ++ if (dev->chip_id == BCM53101_DEVICE_ID) { ++ /* BCM53101 uses 0.5 second increments */ ++ ds->ageing_time_min = 1 * 500; ++ ds->ageing_time_max = AGE_TIME_MAX * 500; ++ } else { ++ /* Everything else uses 1 second increments */ ++ ds->ageing_time_min = 1 * 1000; ++ ds->ageing_time_max = AGE_TIME_MAX * 1000; ++ } + + ret = b53_reset_switch(dev); + if (ret) { +@@ -2587,7 +2593,10 @@ int b53_set_ageing_time(struct dsa_switc + else + reg = B53_AGING_TIME_CONTROL; + +- atc = DIV_ROUND_CLOSEST(msecs, 1000); ++ if (dev->chip_id == BCM53101_DEVICE_ID) ++ atc = DIV_ROUND_CLOSEST(msecs, 500); ++ else ++ atc = DIV_ROUND_CLOSEST(msecs, 1000); + + if (!is5325(dev) && !is5365(dev)) + atc |= AGE_CHANGE; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-18-v6.18-net-dsa-b53-properly-bound-ARL-searches-for-4-ARL-bin-chips.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-18-v6.18-net-dsa-b53-properly-bound-ARL-searches-for-4-ARL-bin-chips.patch new file mode 100755 index 0000000..50ddcf9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-18-v6.18-net-dsa-b53-properly-bound-ARL-searches-for-4-ARL-bin-chips.patch @@ -0,0 +1,61 @@ +From e57723fe536f040cc2635ec1545dd0a7919a321e Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Sun, 2 Nov 2025 11:07:58 +0100 +Subject: [PATCH] net: dsa: b53: properly bound ARL searches for < 4 ARL bin + chips + +When iterating over the ARL table we stop at max ARL entries / 2, but +this is only valid if the chip actually returns 2 results at once. For +chips with only one result register we will stop before reaching the end +of the table if it is more than half full. + +Fix this by only dividing the maximum results by two if we have a chip +with more than one result register (i.e. those with 4 ARL bins). + +Fixes: cd169d799bee ("net: dsa: b53: Bound check ARL searches") +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251102100758.28352-4-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2090,13 +2090,16 @@ static int b53_fdb_copy(int port, const + int b53_fdb_dump(struct dsa_switch *ds, int port, + dsa_fdb_dump_cb_t *cb, void *data) + { ++ unsigned int count = 0, results_per_hit = 1; + struct b53_device *priv = ds->priv; + struct b53_arl_entry results[2]; +- unsigned int count = 0; + u8 offset; + int ret; + u8 reg; + ++ if (priv->num_arl_bins > 2) ++ results_per_hit = 2; ++ + mutex_lock(&priv->arl_mutex); + + if (is5325(priv) || is5365(priv)) +@@ -2118,7 +2121,7 @@ int b53_fdb_dump(struct dsa_switch *ds, + if (ret) + break; + +- if (priv->num_arl_bins > 2) { ++ if (results_per_hit == 2) { + b53_arl_search_rd(priv, 1, &results[1]); + ret = b53_fdb_copy(port, &results[1], cb, data); + if (ret) +@@ -2128,7 +2131,7 @@ int b53_fdb_dump(struct dsa_switch *ds, + break; + } + +- } while (count++ < b53_max_arl_entries(priv) / 2); ++ } while (count++ < b53_max_arl_entries(priv) / results_per_hit); + + mutex_unlock(&priv->arl_mutex); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-19-v6.18-net-dsa-tag_brcm-do-not-mark-link-local-traffic-as-offloaded.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-19-v6.18-net-dsa-tag_brcm-do-not-mark-link-local-traffic-as-offloaded.patch new file mode 100755 index 0000000..7c3d062 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/611-19-v6.18-net-dsa-tag_brcm-do-not-mark-link-local-traffic-as-offloaded.patch @@ -0,0 +1,59 @@ +From 762e7e174da91cf4babfe77e45bc6b67334b1503 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Sun, 9 Nov 2025 14:46:35 +0100 +Subject: [PATCH] net: dsa: tag_brcm: do not mark link local traffic as + offloaded + +Broadcom switches locally terminate link local traffic and do not +forward it, so we should not mark it as offloaded. + +In some situations we still want/need to flood this traffic, e.g. if STP +is disabled, or it is explicitly enabled via the group_fwd_mask. But if +the skb is marked as offloaded, the kernel will assume this was already +done in hardware, and the packets never reach other bridge ports. + +So ensure that link local traffic is never marked as offloaded, so that +the kernel can forward/flood these packets in software if needed. + +Since the local termination in not configurable, check the destination +MAC, and never mark packets as offloaded if it is a link local ether +address. + +While modern switches set the tag reason code to BRCM_EG_RC_PROT_TERM +for trapped link local traffic, they also set it for link local traffic +that is flooded (01:80:c2:00:00:10 to 01:80:c2:00:00:2f), so we cannot +use it and need to look at the destination address for them as well. + +Fixes: 964dbf186eaa ("net: dsa: tag_brcm: add support for legacy tags") +Fixes: 0e62f543bed0 ("net: dsa: Fix duplicate frames flooded by learning") +Signed-off-by: Jonas Gorski +Reviewed-by: Vladimir Oltean +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251109134635.243951-1-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + net/dsa/tag_brcm.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/net/dsa/tag_brcm.c ++++ b/net/dsa/tag_brcm.c +@@ -176,7 +176,8 @@ static struct sk_buff *brcm_tag_rcv_ll(s + /* Remove Broadcom tag and update checksum */ + skb_pull_rcsum(skb, BRCM_TAG_LEN); + +- dsa_default_offload_fwd_mark(skb); ++ if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest))) ++ dsa_default_offload_fwd_mark(skb); + + return skb; + } +@@ -250,7 +251,8 @@ static struct sk_buff *brcm_leg_tag_rcv( + /* Remove Broadcom tag and update checksum */ + skb_pull_rcsum(skb, len); + +- dsa_default_offload_fwd_mark(skb); ++ if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest))) ++ dsa_default_offload_fwd_mark(skb); + + dsa_strip_etype_header(skb, len); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-01-v6.19-net-dsa-b53-b53_arl_read-25-use-the-entry-for-comparision.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-01-v6.19-net-dsa-b53-b53_arl_read-25-use-the-entry-for-comparision.patch new file mode 100755 index 0000000..2b6cff7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-01-v6.19-net-dsa-b53-b53_arl_read-25-use-the-entry-for-comparision.patch @@ -0,0 +1,85 @@ +From a6e4fd38bf2f2e2363b61c27f4e6c49b14e4bb07 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:42 +0100 +Subject: [PATCH] net: dsa: b53: b53_arl_read{,25}(): use the entry for + comparision + +Align the b53_arl_read{,25}() functions by consistently using the +parsed arl entry instead of parsing the raw registers again. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-2-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 22 ++++++++++------------ + 1 file changed, 10 insertions(+), 12 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1830,7 +1830,7 @@ static int b53_arl_rw_op(struct b53_devi + return b53_arl_op_wait(dev); + } + +-static int b53_arl_read(struct b53_device *dev, u64 mac, ++static int b53_arl_read(struct b53_device *dev, const u8 *mac, + u16 vid, struct b53_arl_entry *ent, u8 *idx) + { + DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES); +@@ -1854,14 +1854,13 @@ static int b53_arl_read(struct b53_devic + B53_ARLTBL_DATA_ENTRY(i), &fwd_entry); + b53_arl_to_entry(ent, mac_vid, fwd_entry); + +- if (!(fwd_entry & ARLTBL_VALID)) { ++ if (!ent->is_valid) { + set_bit(i, free_bins); + continue; + } +- if ((mac_vid & ARLTBL_MAC_MASK) != mac) ++ if (!ether_addr_equal(ent->mac, mac)) + continue; +- if (dev->vlan_enabled && +- ((mac_vid >> ARLTBL_VID_S) & ARLTBL_VID_MASK) != vid) ++ if (dev->vlan_enabled && ent->vid != vid) + continue; + *idx = i; + return 0; +@@ -1871,7 +1870,7 @@ static int b53_arl_read(struct b53_devic + return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; + } + +-static int b53_arl_read_25(struct b53_device *dev, u64 mac, ++static int b53_arl_read_25(struct b53_device *dev, const u8 *mac, + u16 vid, struct b53_arl_entry *ent, u8 *idx) + { + DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES); +@@ -1893,14 +1892,13 @@ static int b53_arl_read_25(struct b53_de + + b53_arl_to_entry_25(ent, mac_vid); + +- if (!(mac_vid & ARLTBL_VALID_25)) { ++ if (!ent->is_valid) { + set_bit(i, free_bins); + continue; + } +- if ((mac_vid & ARLTBL_MAC_MASK) != mac) ++ if (!ether_addr_equal(ent->mac, mac)) + continue; +- if (dev->vlan_enabled && +- ((mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25) != vid) ++ if (dev->vlan_enabled && ent->vid != vid) + continue; + *idx = i; + return 0; +@@ -1933,9 +1931,9 @@ static int b53_arl_op(struct b53_device + return ret; + + if (is5325(dev) || is5365(dev)) +- ret = b53_arl_read_25(dev, mac, vid, &ent, &idx); ++ ret = b53_arl_read_25(dev, addr, vid, &ent, &idx); + else +- ret = b53_arl_read(dev, mac, vid, &ent, &idx); ++ ret = b53_arl_read(dev, addr, vid, &ent, &idx); + + /* If this is a read, just finish now */ + if (op) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-02-v6.19-net-dsa-b53-move-reading-ARL-entries-into-their-own-function.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-02-v6.19-net-dsa-b53-move-reading-ARL-entries-into-their-own-function.patch new file mode 100755 index 0000000..8cf85ce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-02-v6.19-net-dsa-b53-move-reading-ARL-entries-into-their-own-function.patch @@ -0,0 +1,117 @@ +From 4a291fe7226736a465ddb3fa93c21fcef7162ec7 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:43 +0100 +Subject: [PATCH] net: dsa: b53: move reading ARL entries into their own + function + +Instead of duplicating the whole code iterating over all bins for +BCM5325, factor out reading and parsing the entry into its own +functions, and name it the modern one after the first chip with that ARL +format, (BCM53)95. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-3-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 69 +++++++++++--------------------- + 1 file changed, 23 insertions(+), 46 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1830,48 +1830,30 @@ static int b53_arl_rw_op(struct b53_devi + return b53_arl_op_wait(dev); + } + +-static int b53_arl_read(struct b53_device *dev, const u8 *mac, +- u16 vid, struct b53_arl_entry *ent, u8 *idx) ++static void b53_arl_read_entry_25(struct b53_device *dev, ++ struct b53_arl_entry *ent, u8 idx) + { +- DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES); +- unsigned int i; +- int ret; +- +- ret = b53_arl_op_wait(dev); +- if (ret) +- return ret; ++ u64 mac_vid; + +- bitmap_zero(free_bins, dev->num_arl_bins); +- +- /* Read the bins */ +- for (i = 0; i < dev->num_arl_bins; i++) { +- u64 mac_vid; +- u32 fwd_entry; +- +- b53_read64(dev, B53_ARLIO_PAGE, +- B53_ARLTBL_MAC_VID_ENTRY(i), &mac_vid); +- b53_read32(dev, B53_ARLIO_PAGE, +- B53_ARLTBL_DATA_ENTRY(i), &fwd_entry); +- b53_arl_to_entry(ent, mac_vid, fwd_entry); ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), ++ &mac_vid); ++ b53_arl_to_entry_25(ent, mac_vid); ++} + +- if (!ent->is_valid) { +- set_bit(i, free_bins); +- continue; +- } +- if (!ether_addr_equal(ent->mac, mac)) +- continue; +- if (dev->vlan_enabled && ent->vid != vid) +- continue; +- *idx = i; +- return 0; +- } ++static void b53_arl_read_entry_95(struct b53_device *dev, ++ struct b53_arl_entry *ent, u8 idx) ++{ ++ u32 fwd_entry; ++ u64 mac_vid; + +- *idx = find_first_bit(free_bins, dev->num_arl_bins); +- return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT; ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), ++ &mac_vid); ++ b53_read32(dev, B53_ARLIO_PAGE, B53_ARLTBL_DATA_ENTRY(idx), &fwd_entry); ++ b53_arl_to_entry(ent, mac_vid, fwd_entry); + } + +-static int b53_arl_read_25(struct b53_device *dev, const u8 *mac, +- u16 vid, struct b53_arl_entry *ent, u8 *idx) ++static int b53_arl_read(struct b53_device *dev, const u8 *mac, ++ u16 vid, struct b53_arl_entry *ent, u8 *idx) + { + DECLARE_BITMAP(free_bins, B53_ARLTBL_MAX_BIN_ENTRIES); + unsigned int i; +@@ -1885,12 +1867,10 @@ static int b53_arl_read_25(struct b53_de + + /* Read the bins */ + for (i = 0; i < dev->num_arl_bins; i++) { +- u64 mac_vid; +- +- b53_read64(dev, B53_ARLIO_PAGE, +- B53_ARLTBL_MAC_VID_ENTRY(i), &mac_vid); +- +- b53_arl_to_entry_25(ent, mac_vid); ++ if (is5325(dev) || is5365(dev)) ++ b53_arl_read_entry_25(dev, ent, i); ++ else ++ b53_arl_read_entry_95(dev, ent, i); + + if (!ent->is_valid) { + set_bit(i, free_bins); +@@ -1930,10 +1910,7 @@ static int b53_arl_op(struct b53_device + if (ret) + return ret; + +- if (is5325(dev) || is5365(dev)) +- ret = b53_arl_read_25(dev, addr, vid, &ent, &idx); +- else +- ret = b53_arl_read(dev, addr, vid, &ent, &idx); ++ ret = b53_arl_read(dev, addr, vid, &ent, &idx); + + /* If this is a read, just finish now */ + if (op) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-03-v6.19-net-dsa-b53-move-writing-ARL-entries-into-their-own-functions.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-03-v6.19-net-dsa-b53-move-writing-ARL-entries-into-their-own-functions.patch new file mode 100755 index 0000000..a171232 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-03-v6.19-net-dsa-b53-move-writing-ARL-entries-into-their-own-functions.patch @@ -0,0 +1,93 @@ +From bf6e9d2ae1dbafee53ec4ccd126595172e1e5278 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:44 +0100 +Subject: [PATCH] net: dsa: b53: move writing ARL entries into their own + functions + +Move writing ARL entries into individual functions for each format. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-4-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 38 ++++++++++++++++++++++---------- + 1 file changed, 26 insertions(+), 12 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1840,6 +1840,16 @@ static void b53_arl_read_entry_25(struct + b53_arl_to_entry_25(ent, mac_vid); + } + ++static void b53_arl_write_entry_25(struct b53_device *dev, ++ const struct b53_arl_entry *ent, u8 idx) ++{ ++ u64 mac_vid; ++ ++ b53_arl_from_entry_25(&mac_vid, ent); ++ b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), ++ mac_vid); ++} ++ + static void b53_arl_read_entry_95(struct b53_device *dev, + struct b53_arl_entry *ent, u8 idx) + { +@@ -1852,6 +1862,19 @@ static void b53_arl_read_entry_95(struct + b53_arl_to_entry(ent, mac_vid, fwd_entry); + } + ++static void b53_arl_write_entry_95(struct b53_device *dev, ++ const struct b53_arl_entry *ent, u8 idx) ++{ ++ u32 fwd_entry; ++ u64 mac_vid; ++ ++ b53_arl_from_entry(&mac_vid, &fwd_entry, ent); ++ b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), ++ mac_vid); ++ b53_write32(dev, B53_ARLIO_PAGE, B53_ARLTBL_DATA_ENTRY(idx), ++ fwd_entry); ++} ++ + static int b53_arl_read(struct b53_device *dev, const u8 *mac, + u16 vid, struct b53_arl_entry *ent, u8 *idx) + { +@@ -1892,9 +1915,8 @@ static int b53_arl_op(struct b53_device + const unsigned char *addr, u16 vid, bool is_valid) + { + struct b53_arl_entry ent; +- u32 fwd_entry; +- u64 mac, mac_vid = 0; + u8 idx = 0; ++ u64 mac; + int ret; + + /* Convert the array into a 64-bit MAC */ +@@ -1927,7 +1949,6 @@ static int b53_arl_op(struct b53_device + /* We could not find a matching MAC, so reset to a new entry */ + dev_dbg(dev->dev, "{%pM,%.4d} not found, using idx: %d\n", + addr, vid, idx); +- fwd_entry = 0; + break; + default: + dev_dbg(dev->dev, "{%pM,%.4d} found, using idx: %d\n", +@@ -1955,16 +1976,9 @@ static int b53_arl_op(struct b53_device + ent.is_age = false; + memcpy(ent.mac, addr, ETH_ALEN); + if (is5325(dev) || is5365(dev)) +- b53_arl_from_entry_25(&mac_vid, &ent); ++ b53_arl_write_entry_25(dev, &ent, idx); + else +- b53_arl_from_entry(&mac_vid, &fwd_entry, &ent); +- +- b53_write64(dev, B53_ARLIO_PAGE, +- B53_ARLTBL_MAC_VID_ENTRY(idx), mac_vid); +- +- if (!is5325(dev) && !is5365(dev)) +- b53_write32(dev, B53_ARLIO_PAGE, +- B53_ARLTBL_DATA_ENTRY(idx), fwd_entry); ++ b53_arl_write_entry_95(dev, &ent, idx); + + return b53_arl_rw_op(dev, 0); + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-04-v6.19-net-dsa-b53-provide-accessors-for-accessing-ARL_SRCH_CTL.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-04-v6.19-net-dsa-b53-provide-accessors-for-accessing-ARL_SRCH_CTL.patch new file mode 100755 index 0000000..2922427 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-04-v6.19-net-dsa-b53-provide-accessors-for-accessing-ARL_SRCH_CTL.patch @@ -0,0 +1,85 @@ +From 1716be6db04af53bac9b869f01156a460595cf41 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:45 +0100 +Subject: [PATCH] net: dsa: b53: provide accessors for accessing ARL_SRCH_CTL + +In order to more easily support more formats, move accessing +ARL_SRCH_CTL into helper functions to contain the differences. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-5-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 37 +++++++++++++++++++++----------- + 1 file changed, 24 insertions(+), 13 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2013,18 +2013,37 @@ int b53_fdb_del(struct dsa_switch *ds, i + } + EXPORT_SYMBOL(b53_fdb_del); + +-static int b53_arl_search_wait(struct b53_device *dev) ++static void b53_read_arl_srch_ctl(struct b53_device *dev, u8 *val) + { +- unsigned int timeout = 1000; +- u8 reg, offset; ++ u8 offset; ++ ++ if (is5325(dev) || is5365(dev)) ++ offset = B53_ARL_SRCH_CTL_25; ++ else ++ offset = B53_ARL_SRCH_CTL; ++ ++ b53_read8(dev, B53_ARLIO_PAGE, offset, val); ++} ++ ++static void b53_write_arl_srch_ctl(struct b53_device *dev, u8 val) ++{ ++ u8 offset; + + if (is5325(dev) || is5365(dev)) + offset = B53_ARL_SRCH_CTL_25; + else + offset = B53_ARL_SRCH_CTL; + ++ b53_write8(dev, B53_ARLIO_PAGE, offset, val); ++} ++ ++static int b53_arl_search_wait(struct b53_device *dev) ++{ ++ unsigned int timeout = 1000; ++ u8 reg; ++ + do { +- b53_read8(dev, B53_ARLIO_PAGE, offset, ®); ++ b53_read_arl_srch_ctl(dev, ®); + if (!(reg & ARL_SRCH_STDN)) + return -ENOENT; + +@@ -2082,23 +2101,15 @@ int b53_fdb_dump(struct dsa_switch *ds, + unsigned int count = 0, results_per_hit = 1; + struct b53_device *priv = ds->priv; + struct b53_arl_entry results[2]; +- u8 offset; + int ret; +- u8 reg; + + if (priv->num_arl_bins > 2) + results_per_hit = 2; + + mutex_lock(&priv->arl_mutex); + +- if (is5325(priv) || is5365(priv)) +- offset = B53_ARL_SRCH_CTL_25; +- else +- offset = B53_ARL_SRCH_CTL; +- + /* Start search operation */ +- reg = ARL_SRCH_STDN; +- b53_write8(priv, B53_ARLIO_PAGE, offset, reg); ++ b53_write_arl_srch_ctl(priv, ARL_SRCH_STDN); + + do { + ret = b53_arl_search_wait(priv); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-05-v6.19-net-dsa-b53-split-reading-search-entry-into-their-own-functions.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-05-v6.19-net-dsa-b53-split-reading-search-entry-into-their-own-functions.patch new file mode 100755 index 0000000..3e263f8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-05-v6.19-net-dsa-b53-split-reading-search-entry-into-their-own-functions.patch @@ -0,0 +1,86 @@ +From e0c476f325a8c9b961a3d446c24d3c8ecae7d186 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:46 +0100 +Subject: [PATCH] net: dsa: b53: split reading search entry into their own + functions + +Split reading search entries into a function for each format. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-6-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 56 ++++++++++++++++++++++---------- + 1 file changed, 38 insertions(+), 18 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2056,28 +2056,48 @@ static int b53_arl_search_wait(struct b5 + return -ETIMEDOUT; + } + +-static void b53_arl_search_rd(struct b53_device *dev, u8 idx, +- struct b53_arl_entry *ent) ++static void b53_arl_search_read_25(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) + { + u64 mac_vid; + +- if (is5325(dev)) { +- b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_25, +- &mac_vid); +- b53_arl_to_entry_25(ent, mac_vid); +- } else if (is5365(dev)) { +- b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_65, +- &mac_vid); +- b53_arl_to_entry_25(ent, mac_vid); +- } else { +- u32 fwd_entry; +- +- b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_MACVID(idx), +- &mac_vid); +- b53_read32(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL(idx), +- &fwd_entry); +- b53_arl_to_entry(ent, mac_vid, fwd_entry); +- } ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_25, ++ &mac_vid); ++ b53_arl_to_entry_25(ent, mac_vid); ++} ++ ++static void b53_arl_search_read_65(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) ++{ ++ u64 mac_vid; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_65, ++ &mac_vid); ++ b53_arl_to_entry_25(ent, mac_vid); ++} ++ ++static void b53_arl_search_read_95(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) ++{ ++ u32 fwd_entry; ++ u64 mac_vid; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_MACVID(idx), ++ &mac_vid); ++ b53_read32(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL(idx), ++ &fwd_entry); ++ b53_arl_to_entry(ent, mac_vid, fwd_entry); ++} ++ ++static void b53_arl_search_rd(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) ++{ ++ if (is5325(dev)) ++ b53_arl_search_read_25(dev, idx, ent); ++ else if (is5365(dev)) ++ b53_arl_search_read_65(dev, idx, ent); ++ else ++ b53_arl_search_read_95(dev, idx, ent); + } + + static int b53_fdb_copy(int port, const struct b53_arl_entry *ent, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-06-v6.19-net-dsa-b53-move-ARL-entry-functions-into-ops-struct.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-06-v6.19-net-dsa-b53-move-ARL-entry-functions-into-ops-struct.patch new file mode 100755 index 0000000..110e160 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-06-v6.19-net-dsa-b53-move-ARL-entry-functions-into-ops-struct.patch @@ -0,0 +1,348 @@ +From a7e73339ad46ade76d29fb6cc7d7854222608c26 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:47 +0100 +Subject: [PATCH] net: dsa: b53: move ARL entry functions into ops struct + +Now that the differences in ARL entry formats are neatly contained into +functions per chip family, wrap them into an ops struct and add wrapper +functions to access them. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-7-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 67 ++++++++++++++++++++++---------- + drivers/net/dsa/b53/b53_priv.h | 30 ++++++++++++++ + 2 files changed, 76 insertions(+), 21 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1890,10 +1890,7 @@ static int b53_arl_read(struct b53_devic + + /* Read the bins */ + for (i = 0; i < dev->num_arl_bins; i++) { +- if (is5325(dev) || is5365(dev)) +- b53_arl_read_entry_25(dev, ent, i); +- else +- b53_arl_read_entry_95(dev, ent, i); ++ b53_arl_read_entry(dev, ent, i); + + if (!ent->is_valid) { + set_bit(i, free_bins); +@@ -1975,10 +1972,7 @@ static int b53_arl_op(struct b53_device + ent.is_static = true; + ent.is_age = false; + memcpy(ent.mac, addr, ETH_ALEN); +- if (is5325(dev) || is5365(dev)) +- b53_arl_write_entry_25(dev, &ent, idx); +- else +- b53_arl_write_entry_95(dev, &ent, idx); ++ b53_arl_write_entry(dev, &ent, idx); + + return b53_arl_rw_op(dev, 0); + } +@@ -2089,17 +2083,6 @@ static void b53_arl_search_read_95(struc + b53_arl_to_entry(ent, mac_vid, fwd_entry); + } + +-static void b53_arl_search_rd(struct b53_device *dev, u8 idx, +- struct b53_arl_entry *ent) +-{ +- if (is5325(dev)) +- b53_arl_search_read_25(dev, idx, ent); +- else if (is5365(dev)) +- b53_arl_search_read_65(dev, idx, ent); +- else +- b53_arl_search_read_95(dev, idx, ent); +-} +- + static int b53_fdb_copy(int port, const struct b53_arl_entry *ent, + dsa_fdb_dump_cb_t *cb, void *data) + { +@@ -2136,13 +2119,13 @@ int b53_fdb_dump(struct dsa_switch *ds, + if (ret) + break; + +- b53_arl_search_rd(priv, 0, &results[0]); ++ b53_arl_search_read(priv, 0, &results[0]); + ret = b53_fdb_copy(port, &results[0], cb, data); + if (ret) + break; + + if (results_per_hit == 2) { +- b53_arl_search_rd(priv, 1, &results[1]); ++ b53_arl_search_read(priv, 1, &results[1]); + ret = b53_fdb_copy(port, &results[1], cb, data); + if (ret) + break; +@@ -2675,6 +2658,24 @@ static const struct dsa_switch_ops b53_s + .port_change_mtu = b53_change_mtu, + }; + ++static const struct b53_arl_ops b53_arl_ops_25 = { ++ .arl_read_entry = b53_arl_read_entry_25, ++ .arl_write_entry = b53_arl_write_entry_25, ++ .arl_search_read = b53_arl_search_read_25, ++}; ++ ++static const struct b53_arl_ops b53_arl_ops_65 = { ++ .arl_read_entry = b53_arl_read_entry_25, ++ .arl_write_entry = b53_arl_write_entry_25, ++ .arl_search_read = b53_arl_search_read_65, ++}; ++ ++static const struct b53_arl_ops b53_arl_ops_95 = { ++ .arl_read_entry = b53_arl_read_entry_95, ++ .arl_write_entry = b53_arl_write_entry_95, ++ .arl_search_read = b53_arl_search_read_95, ++}; ++ + struct b53_chip_data { + u32 chip_id; + const char *dev_name; +@@ -2688,6 +2689,7 @@ struct b53_chip_data { + u8 duplex_reg; + u8 jumbo_pm_reg; + u8 jumbo_size_reg; ++ const struct b53_arl_ops *arl_ops; + }; + + #define B53_VTA_REGS \ +@@ -2707,6 +2709,7 @@ static const struct b53_chip_data b53_sw + .arl_buckets = 1024, + .imp_port = 5, + .duplex_reg = B53_DUPLEX_STAT_FE, ++ .arl_ops = &b53_arl_ops_25, + }, + { + .chip_id = BCM5365_DEVICE_ID, +@@ -2717,6 +2720,7 @@ static const struct b53_chip_data b53_sw + .arl_buckets = 1024, + .imp_port = 5, + .duplex_reg = B53_DUPLEX_STAT_FE, ++ .arl_ops = &b53_arl_ops_65, + }, + { + .chip_id = BCM5389_DEVICE_ID, +@@ -2730,6 +2734,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM5395_DEVICE_ID, +@@ -2743,6 +2748,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM5397_DEVICE_ID, +@@ -2756,6 +2762,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM5398_DEVICE_ID, +@@ -2769,6 +2776,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53101_DEVICE_ID, +@@ -2782,6 +2790,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53115_DEVICE_ID, +@@ -2795,6 +2804,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53125_DEVICE_ID, +@@ -2808,6 +2818,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53128_DEVICE_ID, +@@ -2821,6 +2832,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM63XX_DEVICE_ID, +@@ -2834,6 +2846,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_63XX, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK_63XX, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53010_DEVICE_ID, +@@ -2847,6 +2860,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53011_DEVICE_ID, +@@ -2860,6 +2874,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53012_DEVICE_ID, +@@ -2873,6 +2888,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53018_DEVICE_ID, +@@ -2886,6 +2902,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53019_DEVICE_ID, +@@ -2899,6 +2916,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM58XX_DEVICE_ID, +@@ -2912,6 +2930,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM583XX_DEVICE_ID, +@@ -2925,6 +2944,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + /* Starfighter 2 */ + { +@@ -2939,6 +2959,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM7445_DEVICE_ID, +@@ -2952,6 +2973,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM7278_DEVICE_ID, +@@ -2965,6 +2987,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + { + .chip_id = BCM53134_DEVICE_ID, +@@ -2979,6 +3002,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, ++ .arl_ops = &b53_arl_ops_95, + }, + }; + +@@ -3007,6 +3031,7 @@ static int b53_switch_init(struct b53_de + dev->num_vlans = chip->vlans; + dev->num_arl_bins = chip->arl_bins; + dev->num_arl_buckets = chip->arl_buckets; ++ dev->arl_ops = chip->arl_ops; + break; + } + } +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -58,6 +58,17 @@ struct b53_io_ops { + bool link_up); + }; + ++struct b53_arl_entry; ++ ++struct b53_arl_ops { ++ void (*arl_read_entry)(struct b53_device *dev, ++ struct b53_arl_entry *ent, u8 idx); ++ void (*arl_write_entry)(struct b53_device *dev, ++ const struct b53_arl_entry *ent, u8 idx); ++ void (*arl_search_read)(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent); ++}; ++ + #define B53_INVALID_LANE 0xff + + enum { +@@ -127,6 +138,7 @@ struct b53_device { + struct mutex stats_mutex; + struct mutex arl_mutex; + const struct b53_io_ops *ops; ++ const struct b53_arl_ops *arl_ops; + + /* chip specific data */ + u32 chip_id; +@@ -371,6 +383,24 @@ static inline void b53_arl_from_entry_25 + *mac_vid |= ARLTBL_AGE_25; + } + ++static inline void b53_arl_read_entry(struct b53_device *dev, ++ struct b53_arl_entry *ent, u8 idx) ++{ ++ dev->arl_ops->arl_read_entry(dev, ent, idx); ++} ++ ++static inline void b53_arl_write_entry(struct b53_device *dev, ++ const struct b53_arl_entry *ent, u8 idx) ++{ ++ dev->arl_ops->arl_write_entry(dev, ent, idx); ++} ++ ++static inline void b53_arl_search_read(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) ++{ ++ dev->arl_ops->arl_search_read(dev, idx, ent); ++} ++ + #ifdef CONFIG_BCM47XX + + #include diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-07-v6.19-net-dsa-b53-add-support-for-5389-5397-5398-ARL-entry-format.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-07-v6.19-net-dsa-b53-add-support-for-5389-5397-5398-ARL-entry-format.patch new file mode 100755 index 0000000..948b4ab --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-07-v6.19-net-dsa-b53-add-support-for-5389-5397-5398-ARL-entry-format.patch @@ -0,0 +1,221 @@ +From 300f78e8b6b7be17c2c78afeded75be68acb1aa7 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:48 +0100 +Subject: [PATCH] net: dsa: b53: add support for 5389/5397/5398 ARL entry + format + +BCM5389, BCM5397 and BCM5398 use a different ARL entry format with just +a 16 bit fwdentry register, as well as different search control and data +offsets. + +So add appropriate ops for them and switch those chips to use them. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-8-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 53 ++++++++++++++++++++++++++++++-- + drivers/net/dsa/b53/b53_priv.h | 26 ++++++++++++++++ + drivers/net/dsa/b53/b53_regs.h | 13 ++++++++ + 3 files changed, 89 insertions(+), 3 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1850,6 +1850,31 @@ static void b53_arl_write_entry_25(struc + mac_vid); + } + ++static void b53_arl_read_entry_89(struct b53_device *dev, ++ struct b53_arl_entry *ent, u8 idx) ++{ ++ u64 mac_vid; ++ u16 fwd_entry; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), ++ &mac_vid); ++ b53_read16(dev, B53_ARLIO_PAGE, B53_ARLTBL_DATA_ENTRY(idx), &fwd_entry); ++ b53_arl_to_entry_89(ent, mac_vid, fwd_entry); ++} ++ ++static void b53_arl_write_entry_89(struct b53_device *dev, ++ const struct b53_arl_entry *ent, u8 idx) ++{ ++ u32 fwd_entry; ++ u64 mac_vid; ++ ++ b53_arl_from_entry_89(&mac_vid, &fwd_entry, ent); ++ b53_write64(dev, B53_ARLIO_PAGE, ++ B53_ARLTBL_MAC_VID_ENTRY(idx), mac_vid); ++ b53_write16(dev, B53_ARLIO_PAGE, ++ B53_ARLTBL_DATA_ENTRY(idx), fwd_entry); ++} ++ + static void b53_arl_read_entry_95(struct b53_device *dev, + struct b53_arl_entry *ent, u8 idx) + { +@@ -2013,6 +2038,8 @@ static void b53_read_arl_srch_ctl(struct + + if (is5325(dev) || is5365(dev)) + offset = B53_ARL_SRCH_CTL_25; ++ else if (dev->chip_id == BCM5389_DEVICE_ID || is5397_98(dev)) ++ offset = B53_ARL_SRCH_CTL_89; + else + offset = B53_ARL_SRCH_CTL; + +@@ -2025,6 +2052,8 @@ static void b53_write_arl_srch_ctl(struc + + if (is5325(dev) || is5365(dev)) + offset = B53_ARL_SRCH_CTL_25; ++ else if (dev->chip_id == BCM5389_DEVICE_ID || is5397_98(dev)) ++ offset = B53_ARL_SRCH_CTL_89; + else + offset = B53_ARL_SRCH_CTL; + +@@ -2070,6 +2099,18 @@ static void b53_arl_search_read_65(struc + b53_arl_to_entry_25(ent, mac_vid); + } + ++static void b53_arl_search_read_89(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) ++{ ++ u16 fwd_entry; ++ u64 mac_vid; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_MACVID_89, ++ &mac_vid); ++ b53_read16(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_89, &fwd_entry); ++ b53_arl_to_entry_89(ent, mac_vid, fwd_entry); ++} ++ + static void b53_arl_search_read_95(struct b53_device *dev, u8 idx, + struct b53_arl_entry *ent) + { +@@ -2670,6 +2711,12 @@ static const struct b53_arl_ops b53_arl_ + .arl_search_read = b53_arl_search_read_65, + }; + ++static const struct b53_arl_ops b53_arl_ops_89 = { ++ .arl_read_entry = b53_arl_read_entry_89, ++ .arl_write_entry = b53_arl_write_entry_89, ++ .arl_search_read = b53_arl_search_read_89, ++}; ++ + static const struct b53_arl_ops b53_arl_ops_95 = { + .arl_read_entry = b53_arl_read_entry_95, + .arl_write_entry = b53_arl_write_entry_95, +@@ -2734,7 +2781,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, +- .arl_ops = &b53_arl_ops_95, ++ .arl_ops = &b53_arl_ops_89, + }, + { + .chip_id = BCM5395_DEVICE_ID, +@@ -2762,7 +2809,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, +- .arl_ops = &b53_arl_ops_95, ++ .arl_ops = &b53_arl_ops_89, + }, + { + .chip_id = BCM5398_DEVICE_ID, +@@ -2776,7 +2823,7 @@ static const struct b53_chip_data b53_sw + .duplex_reg = B53_DUPLEX_STAT_GE, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE, +- .arl_ops = &b53_arl_ops_95, ++ .arl_ops = &b53_arl_ops_89, + }, + { + .chip_id = BCM53101_DEVICE_ID, +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -353,6 +353,18 @@ static inline void b53_arl_to_entry_25(s + ent->vid = mac_vid >> ARLTBL_VID_S_65; + } + ++static inline void b53_arl_to_entry_89(struct b53_arl_entry *ent, ++ u64 mac_vid, u16 fwd_entry) ++{ ++ memset(ent, 0, sizeof(*ent)); ++ ent->port = fwd_entry & ARLTBL_DATA_PORT_ID_MASK_89; ++ ent->is_valid = !!(fwd_entry & ARLTBL_VALID_89); ++ ent->is_age = !!(fwd_entry & ARLTBL_AGE_89); ++ ent->is_static = !!(fwd_entry & ARLTBL_STATIC_89); ++ u64_to_ether_addr(mac_vid, ent->mac); ++ ent->vid = mac_vid >> ARLTBL_VID_S; ++} ++ + static inline void b53_arl_from_entry(u64 *mac_vid, u32 *fwd_entry, + const struct b53_arl_entry *ent) + { +@@ -383,6 +395,20 @@ static inline void b53_arl_from_entry_25 + *mac_vid |= ARLTBL_AGE_25; + } + ++static inline void b53_arl_from_entry_89(u64 *mac_vid, u32 *fwd_entry, ++ const struct b53_arl_entry *ent) ++{ ++ *mac_vid = ether_addr_to_u64(ent->mac); ++ *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK) << ARLTBL_VID_S; ++ *fwd_entry = ent->port & ARLTBL_DATA_PORT_ID_MASK_89; ++ if (ent->is_valid) ++ *fwd_entry |= ARLTBL_VALID_89; ++ if (ent->is_static) ++ *fwd_entry |= ARLTBL_STATIC_89; ++ if (ent->is_age) ++ *fwd_entry |= ARLTBL_AGE_89; ++} ++ + static inline void b53_arl_read_entry(struct b53_device *dev, + struct b53_arl_entry *ent, u8 idx) + { +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -342,12 +342,20 @@ + #define ARLTBL_STATIC BIT(15) + #define ARLTBL_VALID BIT(16) + ++/* BCM5389 ARL Table Data Entry N Register format (16 bit) */ ++#define ARLTBL_DATA_PORT_ID_MASK_89 GENMASK(8, 0) ++#define ARLTBL_TC_MASK_89 GENMASK(12, 10) ++#define ARLTBL_AGE_89 BIT(13) ++#define ARLTBL_STATIC_89 BIT(14) ++#define ARLTBL_VALID_89 BIT(15) ++ + /* Maximum number of bin entries in the ARL for all switches */ + #define B53_ARLTBL_MAX_BIN_ENTRIES 4 + + /* ARL Search Control Register (8 bit) */ + #define B53_ARL_SRCH_CTL 0x50 + #define B53_ARL_SRCH_CTL_25 0x20 ++#define B53_ARL_SRCH_CTL_89 0x30 + #define ARL_SRCH_VLID BIT(0) + #define ARL_SRCH_STDN BIT(7) + +@@ -355,10 +363,12 @@ + #define B53_ARL_SRCH_ADDR 0x51 + #define B53_ARL_SRCH_ADDR_25 0x22 + #define B53_ARL_SRCH_ADDR_65 0x24 ++#define B53_ARL_SRCH_ADDR_89 0x31 + #define ARL_ADDR_MASK GENMASK(14, 0) + + /* ARL Search MAC/VID Result (64 bit) */ + #define B53_ARL_SRCH_RSTL_0_MACVID 0x60 ++#define B53_ARL_SRCH_RSLT_MACVID_89 0x33 + + /* Single register search result on 5325 */ + #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24 +@@ -368,6 +378,9 @@ + /* ARL Search Data Result (32 bit) */ + #define B53_ARL_SRCH_RSTL_0 0x68 + ++/* BCM5389 ARL Search Data Result (16 bit) */ ++#define B53_ARL_SRCH_RSLT_89 0x3b ++ + #define B53_ARL_SRCH_RSTL_MACVID(x) (B53_ARL_SRCH_RSTL_0_MACVID + ((x) * 0x10)) + #define B53_ARL_SRCH_RSTL(x) (B53_ARL_SRCH_RSTL_0 + ((x) * 0x10)) + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-08-v6.19-net-dsa-b53-add-support-for-bcm63xx-ARL-entry-format.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-08-v6.19-net-dsa-b53-add-support-for-bcm63xx-ARL-entry-format.patch new file mode 100755 index 0000000..ec0e85e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/612-08-v6.19-net-dsa-b53-add-support-for-bcm63xx-ARL-entry-format.patch @@ -0,0 +1,177 @@ +From 2b3013ac03028a2364d8779719bb6bfbc0212435 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 7 Nov 2025 09:07:49 +0100 +Subject: [PATCH] net: dsa: b53: add support for bcm63xx ARL entry format + +The ARL registers of BCM63XX embedded switches are somewhat unique. The +normal ARL table access registers have the same format as BCM5389, but +the ARL search registers differ: + +* SRCH_CTL is at the same offset of BCM5389, but 16 bits wide. It does + not have more fields, just needs to be accessed by a 16 bit read. +* SRCH_RSLT_MACVID and SRCH_RSLT are aligned to 32 bit, and have shifted + offsets. +* SRCH_RSLT has a different format than the normal ARL data entry + register. +* There is only one set of ENTRY_N registers, implying a 1 bin layout. + +So add appropriate ops for bcm63xx and let it use it. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251107080749.26936-9-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 44 +++++++++++++++++++++++++++----- + drivers/net/dsa/b53/b53_priv.h | 15 +++++++++++ + drivers/net/dsa/b53/b53_regs.h | 9 +++++++ + 3 files changed, 61 insertions(+), 7 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2038,12 +2038,20 @@ static void b53_read_arl_srch_ctl(struct + + if (is5325(dev) || is5365(dev)) + offset = B53_ARL_SRCH_CTL_25; +- else if (dev->chip_id == BCM5389_DEVICE_ID || is5397_98(dev)) ++ else if (dev->chip_id == BCM5389_DEVICE_ID || is5397_98(dev) || ++ is63xx(dev)) + offset = B53_ARL_SRCH_CTL_89; + else + offset = B53_ARL_SRCH_CTL; + +- b53_read8(dev, B53_ARLIO_PAGE, offset, val); ++ if (is63xx(dev)) { ++ u16 val16; ++ ++ b53_read16(dev, B53_ARLIO_PAGE, offset, &val16); ++ *val = val16 & 0xff; ++ } else { ++ b53_read8(dev, B53_ARLIO_PAGE, offset, val); ++ } + } + + static void b53_write_arl_srch_ctl(struct b53_device *dev, u8 val) +@@ -2052,12 +2060,16 @@ static void b53_write_arl_srch_ctl(struc + + if (is5325(dev) || is5365(dev)) + offset = B53_ARL_SRCH_CTL_25; +- else if (dev->chip_id == BCM5389_DEVICE_ID || is5397_98(dev)) ++ else if (dev->chip_id == BCM5389_DEVICE_ID || is5397_98(dev) || ++ is63xx(dev)) + offset = B53_ARL_SRCH_CTL_89; + else + offset = B53_ARL_SRCH_CTL; + +- b53_write8(dev, B53_ARLIO_PAGE, offset, val); ++ if (is63xx(dev)) ++ b53_write16(dev, B53_ARLIO_PAGE, offset, val); ++ else ++ b53_write8(dev, B53_ARLIO_PAGE, offset, val); + } + + static int b53_arl_search_wait(struct b53_device *dev) +@@ -2111,6 +2123,18 @@ static void b53_arl_search_read_89(struc + b53_arl_to_entry_89(ent, mac_vid, fwd_entry); + } + ++static void b53_arl_search_read_63xx(struct b53_device *dev, u8 idx, ++ struct b53_arl_entry *ent) ++{ ++ u16 fwd_entry; ++ u64 mac_vid; ++ ++ b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_MACVID_63XX, ++ &mac_vid); ++ b53_read16(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_63XX, &fwd_entry); ++ b53_arl_search_to_entry_63xx(ent, mac_vid, fwd_entry); ++} ++ + static void b53_arl_search_read_95(struct b53_device *dev, u8 idx, + struct b53_arl_entry *ent) + { +@@ -2717,6 +2741,12 @@ static const struct b53_arl_ops b53_arl_ + .arl_search_read = b53_arl_search_read_89, + }; + ++static const struct b53_arl_ops b53_arl_ops_63xx = { ++ .arl_read_entry = b53_arl_read_entry_89, ++ .arl_write_entry = b53_arl_write_entry_89, ++ .arl_search_read = b53_arl_search_read_63xx, ++}; ++ + static const struct b53_arl_ops b53_arl_ops_95 = { + .arl_read_entry = b53_arl_read_entry_95, + .arl_write_entry = b53_arl_write_entry_95, +@@ -2886,14 +2916,14 @@ static const struct b53_chip_data b53_sw + .dev_name = "BCM63xx", + .vlans = 4096, + .enabled_ports = 0, /* pdata must provide them */ +- .arl_bins = 4, +- .arl_buckets = 1024, ++ .arl_bins = 1, ++ .arl_buckets = 4096, + .imp_port = 8, + .vta_regs = B53_VTA_REGS_63XX, + .duplex_reg = B53_DUPLEX_STAT_63XX, + .jumbo_pm_reg = B53_JUMBO_PORT_MASK_63XX, + .jumbo_size_reg = B53_JUMBO_MAX_SIZE_63XX, +- .arl_ops = &b53_arl_ops_95, ++ .arl_ops = &b53_arl_ops_63xx, + }, + { + .chip_id = BCM53010_DEVICE_ID, +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -409,6 +409,21 @@ static inline void b53_arl_from_entry_89 + *fwd_entry |= ARLTBL_AGE_89; + } + ++static inline void b53_arl_search_to_entry_63xx(struct b53_arl_entry *ent, ++ u64 mac_vid, u16 fwd_entry) ++{ ++ memset(ent, 0, sizeof(*ent)); ++ u64_to_ether_addr(mac_vid, ent->mac); ++ ent->vid = mac_vid >> ARLTBL_VID_S; ++ ++ ent->port = fwd_entry & ARL_SRST_PORT_ID_MASK_63XX; ++ ent->port >>= 1; ++ ++ ent->is_age = !!(fwd_entry & ARL_SRST_AGE_63XX); ++ ent->is_static = !!(fwd_entry & ARL_SRST_STATIC_63XX); ++ ent->is_valid = 1; ++} ++ + static inline void b53_arl_read_entry(struct b53_device *dev, + struct b53_arl_entry *ent, u8 idx) + { +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -364,11 +364,13 @@ + #define B53_ARL_SRCH_ADDR_25 0x22 + #define B53_ARL_SRCH_ADDR_65 0x24 + #define B53_ARL_SRCH_ADDR_89 0x31 ++#define B53_ARL_SRCH_ADDR_63XX 0x32 + #define ARL_ADDR_MASK GENMASK(14, 0) + + /* ARL Search MAC/VID Result (64 bit) */ + #define B53_ARL_SRCH_RSTL_0_MACVID 0x60 + #define B53_ARL_SRCH_RSLT_MACVID_89 0x33 ++#define B53_ARL_SRCH_RSLT_MACVID_63XX 0x34 + + /* Single register search result on 5325 */ + #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24 +@@ -384,6 +386,13 @@ + #define B53_ARL_SRCH_RSTL_MACVID(x) (B53_ARL_SRCH_RSTL_0_MACVID + ((x) * 0x10)) + #define B53_ARL_SRCH_RSTL(x) (B53_ARL_SRCH_RSTL_0 + ((x) * 0x10)) + ++/* 63XX ARL Search Data Result (16 bit) */ ++#define B53_ARL_SRCH_RSLT_63XX 0x3c ++#define ARL_SRST_PORT_ID_MASK_63XX GENMASK(9, 1) ++#define ARL_SRST_TC_MASK_63XX GENMASK(13, 11) ++#define ARL_SRST_AGE_63XX BIT(14) ++#define ARL_SRST_STATIC_63XX BIT(15) ++ + /************************************************************************* + * IEEE 802.1X Registers + *************************************************************************/ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-01-v6.19-net-dsa-b53-fix-VLAN_ID_IDX-write-size-for-BCM5325-65.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-01-v6.19-net-dsa-b53-fix-VLAN_ID_IDX-write-size-for-BCM5325-65.patch new file mode 100755 index 0000000..d953ea7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-01-v6.19-net-dsa-b53-fix-VLAN_ID_IDX-write-size-for-BCM5325-65.patch @@ -0,0 +1,38 @@ +From 6f268e275c74dae0536e0b61982a8db25bcf4f16 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:19 +0100 +Subject: [PATCH] net: dsa: b53: fix VLAN_ID_IDX write size for BCM5325/65 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since BCM5325 and BCM5365 only support up to 256 VLANs, the VLAN_ID_IDX +register is only 8 bit wide, not 16 bit, so use an appropriate accessor. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Reviewed-by: Florian Fainelli +Tested-by: Álvaro FernΓ‘ndez Rojas +Signed-off-by: Jonas Gorski +Link: https://patch.msgid.link/20251128080625.27181-2-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1946,8 +1946,12 @@ static int b53_arl_op(struct b53_device + + /* Perform a read for the given MAC and VID */ + b53_write48(dev, B53_ARLIO_PAGE, B53_MAC_ADDR_IDX, mac); +- if (!is5325m(dev)) +- b53_write16(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid); ++ if (!is5325m(dev)) { ++ if (is5325(dev) || is5365(dev)) ++ b53_write8(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid); ++ else ++ b53_write16(dev, B53_ARLIO_PAGE, B53_VLAN_ID_IDX, vid); ++ } + + /* Issue a read operation for this MAC */ + ret = b53_arl_rw_op(dev, 1); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-02-v6.19-net-dsa-b53-fix-extracting-VID-from-entry-for-BCM5325-65.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-02-v6.19-net-dsa-b53-fix-extracting-VID-from-entry-for-BCM5325-65.patch new file mode 100755 index 0000000..72f81d0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-02-v6.19-net-dsa-b53-fix-extracting-VID-from-entry-for-BCM5325-65.patch @@ -0,0 +1,35 @@ +From 9316012dd01952f75e37035360138ccc786ef727 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:20 +0100 +Subject: [PATCH] net: dsa: b53: fix extracting VID from entry for BCM5325/65 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BCM5325/65's Entry register uses the highest three bits for +VALID/STATIC/AGE, so shifting by 53 only will add these to +b53_arl_entry::vid. + +So make sure to mask the vid value as well, to not get invalid VIDs. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Reviewed-by: Florian Fainelli +Tested-by: Álvaro FernΓ‘ndez Rojas +Signed-off-by: Jonas Gorski +Link: https://patch.msgid.link/20251128080625.27181-3-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_priv.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -350,7 +350,7 @@ static inline void b53_arl_to_entry_25(s + ent->is_age = !!(mac_vid & ARLTBL_AGE_25); + ent->is_static = !!(mac_vid & ARLTBL_STATIC_25); + u64_to_ether_addr(mac_vid, ent->mac); +- ent->vid = mac_vid >> ARLTBL_VID_S_65; ++ ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25; + } + + static inline void b53_arl_to_entry_89(struct b53_arl_entry *ent, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-03-v6.19-net-dsa-b53-use-same-ARL-search-result-offset-for-BCM5325-65.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-03-v6.19-net-dsa-b53-use-same-ARL-search-result-offset-for-BCM5325-65.patch new file mode 100755 index 0000000..ddb95df --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-03-v6.19-net-dsa-b53-use-same-ARL-search-result-offset-for-BCM5325-65.patch @@ -0,0 +1,78 @@ +From 8e46aacea4264bcb8d4265fb07577afff58ae78d Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:21 +0100 +Subject: [PATCH] net: dsa: b53: use same ARL search result offset for BCM5325/65 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +BCM5365's search result is at the same offset as BCM5325's search +result, and they (mostly) share the same format, so switch BCM5365 to +BCM5325's arl ops. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Reviewed-by: Florian Fainelli +Tested-by: Álvaro FernΓ‘ndez Rojas +Signed-off-by: Jonas Gorski +Link: https://patch.msgid.link/20251128080625.27181-4-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 18 +----------------- + drivers/net/dsa/b53/b53_regs.h | 4 +--- + 2 files changed, 2 insertions(+), 20 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2105,16 +2105,6 @@ static void b53_arl_search_read_25(struc + b53_arl_to_entry_25(ent, mac_vid); + } + +-static void b53_arl_search_read_65(struct b53_device *dev, u8 idx, +- struct b53_arl_entry *ent) +-{ +- u64 mac_vid; +- +- b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_65, +- &mac_vid); +- b53_arl_to_entry_25(ent, mac_vid); +-} +- + static void b53_arl_search_read_89(struct b53_device *dev, u8 idx, + struct b53_arl_entry *ent) + { +@@ -2733,12 +2723,6 @@ static const struct b53_arl_ops b53_arl_ + .arl_search_read = b53_arl_search_read_25, + }; + +-static const struct b53_arl_ops b53_arl_ops_65 = { +- .arl_read_entry = b53_arl_read_entry_25, +- .arl_write_entry = b53_arl_write_entry_25, +- .arl_search_read = b53_arl_search_read_65, +-}; +- + static const struct b53_arl_ops b53_arl_ops_89 = { + .arl_read_entry = b53_arl_read_entry_89, + .arl_write_entry = b53_arl_write_entry_89, +@@ -2801,7 +2785,7 @@ static const struct b53_chip_data b53_sw + .arl_buckets = 1024, + .imp_port = 5, + .duplex_reg = B53_DUPLEX_STAT_FE, +- .arl_ops = &b53_arl_ops_65, ++ .arl_ops = &b53_arl_ops_25, + }, + { + .chip_id = BCM5389_DEVICE_ID, +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -372,10 +372,8 @@ + #define B53_ARL_SRCH_RSLT_MACVID_89 0x33 + #define B53_ARL_SRCH_RSLT_MACVID_63XX 0x34 + +-/* Single register search result on 5325 */ ++/* Single register search result on 5325/5365 */ + #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24 +-/* Single register search result on 5365 */ +-#define B53_ARL_SRCH_RSTL_0_MACVID_65 0x30 + + /* ARL Search Data Result (32 bit) */ + #define B53_ARL_SRCH_RSTL_0 0x68 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-04-v6.19-net-dsa-b53-fix-CPU-port-unicast-ARL-entries-for-BCM5325-65.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-04-v6.19-net-dsa-b53-fix-CPU-port-unicast-ARL-entries-for-BCM5325-65.patch new file mode 100755 index 0000000..3748892 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-04-v6.19-net-dsa-b53-fix-CPU-port-unicast-ARL-entries-for-BCM5325-65.patch @@ -0,0 +1,51 @@ +From 85132103f700b1340fc17df8a981509d17bf4872 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:22 +0100 +Subject: [PATCH] net: dsa: b53: fix CPU port unicast ARL entries for BCM5325/65 + +On BCM5325 and BCM5365, unicast ARL entries use 8 as the value for the +CPU port, so we need to translate it to/from 5 as used for the CPU port +at most other places. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251128080625.27181-5-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_priv.h | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -344,12 +344,14 @@ static inline void b53_arl_to_entry_25(s + u64 mac_vid) + { + memset(ent, 0, sizeof(*ent)); +- ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) & +- ARLTBL_DATA_PORT_ID_MASK_25; + ent->is_valid = !!(mac_vid & ARLTBL_VALID_25); + ent->is_age = !!(mac_vid & ARLTBL_AGE_25); + ent->is_static = !!(mac_vid & ARLTBL_STATIC_25); + u64_to_ether_addr(mac_vid, ent->mac); ++ ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) & ++ ARLTBL_DATA_PORT_ID_MASK_25; ++ if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT) ++ ent->port = B53_CPU_PORT_25; + ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25; + } + +@@ -383,8 +385,11 @@ static inline void b53_arl_from_entry_25 + const struct b53_arl_entry *ent) + { + *mac_vid = ether_addr_to_u64(ent->mac); +- *mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) << +- ARLTBL_DATA_PORT_ID_S_25; ++ if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT_25) ++ *mac_vid |= (u64)B53_CPU_PORT << ARLTBL_DATA_PORT_ID_S_25; ++ else ++ *mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) << ++ ARLTBL_DATA_PORT_ID_S_25; + *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) << + ARLTBL_VID_S_65; + if (ent->is_valid) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-05-v6.19-net-dsa-b53-fix-BCM5325-65-ARL-entry-multicast-port-masks.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-05-v6.19-net-dsa-b53-fix-BCM5325-65-ARL-entry-multicast-port-masks.patch new file mode 100755 index 0000000..c0f5b5d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-05-v6.19-net-dsa-b53-fix-BCM5325-65-ARL-entry-multicast-port-masks.patch @@ -0,0 +1,120 @@ +From 3b08863469aa6028ac7c3120966f4e2f6051cf6b Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:23 +0100 +Subject: [PATCH] net: dsa: b53: fix BCM5325/65 ARL entry multicast port masks + +We currently use the mask 0xf for writing and reading b53_entry::port, +but this is only correct for unicast ARL entries. Multicast ARL entries +use a bitmask, and 0xf is not enough space for ports > 3, which includes +the CPU port. + +So extend the mask accordingly to also fit port 4 (bit 4) and MII (bit +5). According to the datasheet the multicast port mask is [60:48], +making it 12 bit wide, but bits 60-55 are reserved anyway, and collide +with the priority field at [60:59], so I am not sure if this is valid. +Therefore leave it at the actual used range, [53:48]. + +The ARL search result register differs a bit, and there the mask is only +[52:48], so only spanning the user ports. The MII port bit is +contained in the Search Result Extension register. So create a separate +search result parse function that properly handles this. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Reviewed-by: Florian Fainelli +Signed-off-by: Jonas Gorski +Link: https://patch.msgid.link/20251128080625.27181-6-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 4 +++- + drivers/net/dsa/b53/b53_priv.h | 25 +++++++++++++++++++++---- + drivers/net/dsa/b53/b53_regs.h | 8 +++++++- + 3 files changed, 31 insertions(+), 6 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -2099,10 +2099,12 @@ static void b53_arl_search_read_25(struc + struct b53_arl_entry *ent) + { + u64 mac_vid; ++ u8 ext; + ++ b53_read8(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSLT_EXT_25, &ext); + b53_read64(dev, B53_ARLIO_PAGE, B53_ARL_SRCH_RSTL_0_MACVID_25, + &mac_vid); +- b53_arl_to_entry_25(ent, mac_vid); ++ b53_arl_search_to_entry_25(ent, mac_vid, ext); + } + + static void b53_arl_search_read_89(struct b53_device *dev, u8 idx, +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -348,8 +348,8 @@ static inline void b53_arl_to_entry_25(s + ent->is_age = !!(mac_vid & ARLTBL_AGE_25); + ent->is_static = !!(mac_vid & ARLTBL_STATIC_25); + u64_to_ether_addr(mac_vid, ent->mac); +- ent->port = (mac_vid >> ARLTBL_DATA_PORT_ID_S_25) & +- ARLTBL_DATA_PORT_ID_MASK_25; ++ ent->port = (mac_vid & ARLTBL_DATA_PORT_ID_MASK_25) >> ++ ARLTBL_DATA_PORT_ID_S_25; + if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT) + ent->port = B53_CPU_PORT_25; + ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25; +@@ -388,8 +388,8 @@ static inline void b53_arl_from_entry_25 + if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT_25) + *mac_vid |= (u64)B53_CPU_PORT << ARLTBL_DATA_PORT_ID_S_25; + else +- *mac_vid |= (u64)(ent->port & ARLTBL_DATA_PORT_ID_MASK_25) << +- ARLTBL_DATA_PORT_ID_S_25; ++ *mac_vid |= ((u64)ent->port << ARLTBL_DATA_PORT_ID_S_25) & ++ ARLTBL_DATA_PORT_ID_MASK_25; + *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) << + ARLTBL_VID_S_65; + if (ent->is_valid) +@@ -414,6 +414,23 @@ static inline void b53_arl_from_entry_89 + *fwd_entry |= ARLTBL_AGE_89; + } + ++static inline void b53_arl_search_to_entry_25(struct b53_arl_entry *ent, ++ u64 mac_vid, u8 ext) ++{ ++ memset(ent, 0, sizeof(*ent)); ++ ent->is_valid = !!(mac_vid & ARLTBL_VALID_25); ++ ent->is_age = !!(mac_vid & ARLTBL_AGE_25); ++ ent->is_static = !!(mac_vid & ARLTBL_STATIC_25); ++ u64_to_ether_addr(mac_vid, ent->mac); ++ ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25; ++ ent->port = (mac_vid & ARL_SRCH_RSLT_PORT_ID_MASK_25) >> ++ ARL_SRCH_RSLT_PORT_ID_S_25; ++ if (is_multicast_ether_addr(ent->mac) && (ext & ARL_SRCH_RSLT_EXT_MC_MII)) ++ ent->port |= BIT(B53_CPU_PORT_25); ++ else if (!is_multicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT) ++ ent->port = B53_CPU_PORT_25; ++} ++ + static inline void b53_arl_search_to_entry_63xx(struct b53_arl_entry *ent, + u64 mac_vid, u16 fwd_entry) + { +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -328,7 +328,7 @@ + #define ARLTBL_VID_MASK_25 0xff + #define ARLTBL_VID_MASK 0xfff + #define ARLTBL_DATA_PORT_ID_S_25 48 +-#define ARLTBL_DATA_PORT_ID_MASK_25 0xf ++#define ARLTBL_DATA_PORT_ID_MASK_25 GENMASK_ULL(53, 48) + #define ARLTBL_VID_S_65 53 + #define ARLTBL_AGE_25 BIT_ULL(61) + #define ARLTBL_STATIC_25 BIT_ULL(62) +@@ -374,6 +374,12 @@ + + /* Single register search result on 5325/5365 */ + #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24 ++#define ARL_SRCH_RSLT_PORT_ID_S_25 48 ++#define ARL_SRCH_RSLT_PORT_ID_MASK_25 GENMASK_ULL(52, 48) ++ ++/* BCM5325/5365 Search result extend register (8 bit) */ ++#define B53_ARL_SRCH_RSLT_EXT_25 0x2c ++#define ARL_SRCH_RSLT_EXT_MC_MII BIT(2) + + /* ARL Search Data Result (32 bit) */ + #define B53_ARL_SRCH_RSTL_0 0x68 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-06-v6.19-net-dsa-b53-fix-BCM5325-65-ARL-entry-VIDs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-06-v6.19-net-dsa-b53-fix-BCM5325-65-ARL-entry-VIDs.patch new file mode 100755 index 0000000..a2025f9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-06-v6.19-net-dsa-b53-fix-BCM5325-65-ARL-entry-VIDs.patch @@ -0,0 +1,140 @@ +From d39514e6a2d14f57830d649e2bf03b49612c2f73 Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:24 +0100 +Subject: [PATCH] net: dsa: b53: fix BCM5325/65 ARL entry VIDs + +BCM5325/65's ARL entry registers do not contain the VID, only the search +result register does. ARL entries have a separate VID entry register for +the index into the VLAN table. + +So make ARL entry accessors use the VID entry registers instead, and +move the VLAN ID field definition to the search register definition. + +Fixes: c45655386e53 ("net: dsa: b53: add support for FDB operations on 5325/5365") +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251128080625.27181-7-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 9 +++++++-- + drivers/net/dsa/b53/b53_priv.h | 12 ++++++------ + drivers/net/dsa/b53/b53_regs.h | 7 +++++-- + 3 files changed, 18 insertions(+), 10 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -1833,19 +1833,24 @@ static int b53_arl_rw_op(struct b53_devi + static void b53_arl_read_entry_25(struct b53_device *dev, + struct b53_arl_entry *ent, u8 idx) + { ++ u8 vid_entry; + u64 mac_vid; + ++ b53_read8(dev, B53_ARLIO_PAGE, B53_ARLTBL_VID_ENTRY_25(idx), ++ &vid_entry); + b53_read64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), + &mac_vid); +- b53_arl_to_entry_25(ent, mac_vid); ++ b53_arl_to_entry_25(ent, mac_vid, vid_entry); + } + + static void b53_arl_write_entry_25(struct b53_device *dev, + const struct b53_arl_entry *ent, u8 idx) + { ++ u8 vid_entry; + u64 mac_vid; + +- b53_arl_from_entry_25(&mac_vid, ent); ++ b53_arl_from_entry_25(&mac_vid, &vid_entry, ent); ++ b53_write8(dev, B53_ARLIO_PAGE, B53_ARLTBL_VID_ENTRY_25(idx), vid_entry); + b53_write64(dev, B53_ARLIO_PAGE, B53_ARLTBL_MAC_VID_ENTRY(idx), + mac_vid); + } +--- a/drivers/net/dsa/b53/b53_priv.h ++++ b/drivers/net/dsa/b53/b53_priv.h +@@ -341,7 +341,7 @@ static inline void b53_arl_to_entry(stru + } + + static inline void b53_arl_to_entry_25(struct b53_arl_entry *ent, +- u64 mac_vid) ++ u64 mac_vid, u8 vid_entry) + { + memset(ent, 0, sizeof(*ent)); + ent->is_valid = !!(mac_vid & ARLTBL_VALID_25); +@@ -352,7 +352,7 @@ static inline void b53_arl_to_entry_25(s + ARLTBL_DATA_PORT_ID_S_25; + if (is_unicast_ether_addr(ent->mac) && ent->port == B53_CPU_PORT) + ent->port = B53_CPU_PORT_25; +- ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25; ++ ent->vid = vid_entry; + } + + static inline void b53_arl_to_entry_89(struct b53_arl_entry *ent, +@@ -381,7 +381,7 @@ static inline void b53_arl_from_entry(u6 + *fwd_entry |= ARLTBL_AGE; + } + +-static inline void b53_arl_from_entry_25(u64 *mac_vid, ++static inline void b53_arl_from_entry_25(u64 *mac_vid, u8 *vid_entry, + const struct b53_arl_entry *ent) + { + *mac_vid = ether_addr_to_u64(ent->mac); +@@ -390,14 +390,13 @@ static inline void b53_arl_from_entry_25 + else + *mac_vid |= ((u64)ent->port << ARLTBL_DATA_PORT_ID_S_25) & + ARLTBL_DATA_PORT_ID_MASK_25; +- *mac_vid |= (u64)(ent->vid & ARLTBL_VID_MASK_25) << +- ARLTBL_VID_S_65; + if (ent->is_valid) + *mac_vid |= ARLTBL_VALID_25; + if (ent->is_static) + *mac_vid |= ARLTBL_STATIC_25; + if (ent->is_age) + *mac_vid |= ARLTBL_AGE_25; ++ *vid_entry = ent->vid; + } + + static inline void b53_arl_from_entry_89(u64 *mac_vid, u32 *fwd_entry, +@@ -422,7 +421,8 @@ static inline void b53_arl_search_to_ent + ent->is_age = !!(mac_vid & ARLTBL_AGE_25); + ent->is_static = !!(mac_vid & ARLTBL_STATIC_25); + u64_to_ether_addr(mac_vid, ent->mac); +- ent->vid = (mac_vid >> ARLTBL_VID_S_65) & ARLTBL_VID_MASK_25; ++ ent->vid = (mac_vid & ARL_SRCH_RSLT_VID_MASK_25) >> ++ ARL_SRCH_RSLT_VID_S_25; + ent->port = (mac_vid & ARL_SRCH_RSLT_PORT_ID_MASK_25) >> + ARL_SRCH_RSLT_PORT_ID_S_25; + if (is_multicast_ether_addr(ent->mac) && (ext & ARL_SRCH_RSLT_EXT_MC_MII)) +--- a/drivers/net/dsa/b53/b53_regs.h ++++ b/drivers/net/dsa/b53/b53_regs.h +@@ -325,11 +325,9 @@ + #define B53_ARLTBL_MAC_VID_ENTRY(n) ((0x10 * (n)) + 0x10) + #define ARLTBL_MAC_MASK 0xffffffffffffULL + #define ARLTBL_VID_S 48 +-#define ARLTBL_VID_MASK_25 0xff + #define ARLTBL_VID_MASK 0xfff + #define ARLTBL_DATA_PORT_ID_S_25 48 + #define ARLTBL_DATA_PORT_ID_MASK_25 GENMASK_ULL(53, 48) +-#define ARLTBL_VID_S_65 53 + #define ARLTBL_AGE_25 BIT_ULL(61) + #define ARLTBL_STATIC_25 BIT_ULL(62) + #define ARLTBL_VALID_25 BIT_ULL(63) +@@ -349,6 +347,9 @@ + #define ARLTBL_STATIC_89 BIT(14) + #define ARLTBL_VALID_89 BIT(15) + ++/* BCM5325/BCM565 ARL Table VID Entry N Registers (8 bit) */ ++#define B53_ARLTBL_VID_ENTRY_25(n) ((0x2 * (n)) + 0x30) ++ + /* Maximum number of bin entries in the ARL for all switches */ + #define B53_ARLTBL_MAX_BIN_ENTRIES 4 + +@@ -376,6 +377,8 @@ + #define B53_ARL_SRCH_RSTL_0_MACVID_25 0x24 + #define ARL_SRCH_RSLT_PORT_ID_S_25 48 + #define ARL_SRCH_RSLT_PORT_ID_MASK_25 GENMASK_ULL(52, 48) ++#define ARL_SRCH_RSLT_VID_S_25 53 ++#define ARL_SRCH_RSLT_VID_MASK_25 GENMASK_ULL(60, 53) + + /* BCM5325/5365 Search result extend register (8 bit) */ + #define B53_ARL_SRCH_RSLT_EXT_25 0x2c diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-07-v6.19-net-dsa-b53-allow-VID-0-for-BCM5325-65.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-07-v6.19-net-dsa-b53-allow-VID-0-for-BCM5325-65.patch new file mode 100755 index 0000000..7c6a63f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/613-07-v6.19-net-dsa-b53-allow-VID-0-for-BCM5325-65.patch @@ -0,0 +1,44 @@ +From 0b2b27058692d437b12d3f2a3bf0fa699af7376e Mon Sep 17 00:00:00 2001 +From: Jonas Gorski +Date: Fri, 28 Nov 2025 09:06:25 +0100 +Subject: [PATCH] net: dsa: b53: allow VID 0 for BCM5325/65 + +Now that writing ARL entries works properly, we can actually use VID 0 +as the default untagged VLAN for BCM5325 and BCM5365 as well. + +So use 0 as default PVID for all chips and do not reject VLAN 0 anymore, +which we ignored since commit 45e9d59d3950 ("net: dsa: b53: do not allow +to configure VLAN 0") anyway. + +Signed-off-by: Jonas Gorski +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20251128080625.27181-8-jonas.gorski@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/b53/b53_common.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +--- a/drivers/net/dsa/b53/b53_common.c ++++ b/drivers/net/dsa/b53/b53_common.c +@@ -852,10 +852,7 @@ static void b53_enable_stp(struct b53_de + + static u16 b53_default_pvid(struct b53_device *dev) + { +- if (is5325(dev) || is5365(dev)) +- return 1; +- else +- return 0; ++ return 0; + } + + static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port) +@@ -1679,9 +1676,6 @@ static int b53_vlan_prepare(struct dsa_s + { + struct b53_device *dev = ds->priv; + +- if ((is5325(dev) || is5365(dev)) && vlan->vid == 0) +- return -EOPNOTSUPP; +- + /* Port 7 on 7278 connects to the ASP's UniMAC which is not capable of + * receiving VLAN tagged frames at all, we can still allow the port to + * be configured for egress untagged. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/620-v6.15-ppp-use-IFF_NO_QUEUE-in-virtual-interfaces.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/620-v6.15-ppp-use-IFF_NO_QUEUE-in-virtual-interfaces.patch new file mode 100755 index 0000000..333627a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/620-v6.15-ppp-use-IFF_NO_QUEUE-in-virtual-interfaces.patch @@ -0,0 +1,79 @@ +From: Qingfang Deng +Date: Sat, 1 Mar 2025 21:55:16 +0800 +Subject: [PATCH] ppp: use IFF_NO_QUEUE in virtual interfaces +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For PPPoE, PPTP, and PPPoL2TP, the start_xmit() function directly +forwards packets to the underlying network stack and never returns +anything other than 1. So these interfaces do not require a qdisc, +and the IFF_NO_QUEUE flag should be set. + +Introduces a direct_xmit flag in struct ppp_channel to indicate when +IFF_NO_QUEUE should be applied. The flag is set in ppp_connect_channel() +for relevant protocols. + +While at it, remove the usused latency member from struct ppp_channel. + +Signed-off-by: Qingfang Deng +Reviewed-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20250301135517.695809-1-dqfext@gmail.com +Signed-off-by: Jakub Kicinski +--- + +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -3504,6 +3504,10 @@ ppp_connect_channel(struct channel *pch, + ret = -ENOTCONN; + goto outl; + } ++ if (pch->chan->direct_xmit) ++ ppp->dev->priv_flags |= IFF_NO_QUEUE; ++ else ++ ppp->dev->priv_flags &= ~IFF_NO_QUEUE; + spin_unlock_bh(&pch->downl); + if (pch->file.hdrlen > ppp->file.hdrlen) + ppp->file.hdrlen = pch->file.hdrlen; +--- a/drivers/net/ppp/pppoe.c ++++ b/drivers/net/ppp/pppoe.c +@@ -693,6 +693,7 @@ static int pppoe_connect(struct socket * + po->chan.mtu = dev->mtu - sizeof(struct pppoe_hdr) - 2; + po->chan.private = sk; + po->chan.ops = &pppoe_chan_ops; ++ po->chan.direct_xmit = true; + + error = ppp_register_net_channel(dev_net(dev), &po->chan); + if (error) { +--- a/drivers/net/ppp/pptp.c ++++ b/drivers/net/ppp/pptp.c +@@ -469,6 +469,7 @@ static int pptp_connect(struct socket *s + po->chan.mtu -= PPTP_HEADER_OVERHEAD; + + po->chan.hdrlen = 2 + sizeof(struct pptp_gre_header); ++ po->chan.direct_xmit = true; + error = ppp_register_channel(&po->chan); + if (error) { + pr_err("PPTP: failed to register PPP channel (%d)\n", error); +--- a/include/linux/ppp_channel.h ++++ b/include/linux/ppp_channel.h +@@ -42,8 +42,7 @@ struct ppp_channel { + int hdrlen; /* amount of headroom channel needs */ + void *ppp; /* opaque to channel */ + int speed; /* transfer rate (bytes/second) */ +- /* the following is not used at present */ +- int latency; /* overhead time in milliseconds */ ++ bool direct_xmit; /* no qdisc, xmit directly */ + }; + + #ifdef __KERNEL__ +--- a/net/l2tp/l2tp_ppp.c ++++ b/net/l2tp/l2tp_ppp.c +@@ -796,6 +796,7 @@ static int pppol2tp_connect(struct socke + po->chan.private = sk; + po->chan.ops = &pppol2tp_chan_ops; + po->chan.mtu = pppol2tp_tunnel_mtu(tunnel); ++ po->chan.direct_xmit = true; + + error = ppp_register_net_channel(sock_net(sk), &po->chan); + if (error) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/621-v6.17-ppp-convert-to-percpu-netstats.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/621-v6.17-ppp-convert-to-percpu-netstats.patch new file mode 100755 index 0000000..874d2bf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/621-v6.17-ppp-convert-to-percpu-netstats.patch @@ -0,0 +1,126 @@ +From 1a3e9b7a6b09e8ab3d2af019e4a392622685855e Mon Sep 17 00:00:00 2001 +From: Qingfang Deng +Date: Tue, 10 Jun 2025 16:32:10 +0800 +Subject: [PATCH] ppp: convert to percpu netstats + +Convert to percpu netstats to avoid lock contention when reading them. + +Signed-off-by: Qingfang Deng +Link: https://patch.msgid.link/20250610083211.909015-1-dqfext@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ppp/ppp_generic.c | 52 +++++++++++++---------------------- + 1 file changed, 19 insertions(+), 33 deletions(-) + +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -108,18 +108,6 @@ struct ppp_file { + #define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel) + + /* +- * Data structure to hold primary network stats for which +- * we want to use 64 bit storage. Other network stats +- * are stored in dev->stats of the ppp strucute. +- */ +-struct ppp_link_stats { +- u64 rx_packets; +- u64 tx_packets; +- u64 rx_bytes; +- u64 tx_bytes; +-}; +- +-/* + * Data structure describing one ppp unit. + * A ppp unit corresponds to a ppp network interface device + * and represents a multilink bundle. +@@ -162,7 +150,6 @@ struct ppp { + struct bpf_prog *active_filter; /* filter for pkts to reset idle */ + #endif /* CONFIG_PPP_FILTER */ + struct net *ppp_net; /* the net we belong to */ +- struct ppp_link_stats stats64; /* 64 bit network stats */ + }; + + /* +@@ -1541,23 +1528,12 @@ ppp_net_siocdevprivate(struct net_device + static void + ppp_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats64) + { +- struct ppp *ppp = netdev_priv(dev); +- +- ppp_recv_lock(ppp); +- stats64->rx_packets = ppp->stats64.rx_packets; +- stats64->rx_bytes = ppp->stats64.rx_bytes; +- ppp_recv_unlock(ppp); +- +- ppp_xmit_lock(ppp); +- stats64->tx_packets = ppp->stats64.tx_packets; +- stats64->tx_bytes = ppp->stats64.tx_bytes; +- ppp_xmit_unlock(ppp); +- + stats64->rx_errors = dev->stats.rx_errors; + stats64->tx_errors = dev->stats.tx_errors; + stats64->rx_dropped = dev->stats.rx_dropped; + stats64->tx_dropped = dev->stats.tx_dropped; + stats64->rx_length_errors = dev->stats.rx_length_errors; ++ dev_fetch_sw_netstats(stats64, dev->tstats); + } + + static int ppp_dev_init(struct net_device *dev) +@@ -1655,6 +1631,7 @@ static void ppp_setup(struct net_device + dev->type = ARPHRD_PPP; + dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; + dev->priv_destructor = ppp_dev_priv_destructor; ++ dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; + netif_keep_dst(dev); + } + +@@ -1800,8 +1777,7 @@ ppp_send_frame(struct ppp *ppp, struct s + #endif /* CONFIG_PPP_FILTER */ + } + +- ++ppp->stats64.tx_packets; +- ppp->stats64.tx_bytes += skb->len - PPP_PROTO_LEN; ++ dev_sw_netstats_tx_add(ppp->dev, 1, skb->len - PPP_PROTO_LEN); + + switch (proto) { + case PPP_IP: +@@ -2479,8 +2455,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, + break; + } + +- ++ppp->stats64.rx_packets; +- ppp->stats64.rx_bytes += skb->len - 2; ++ dev_sw_netstats_rx_add(ppp->dev, skb->len - PPP_PROTO_LEN); + + npi = proto_to_npindex(proto); + if (npi < 0) { +@@ -3308,14 +3283,25 @@ static void + ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) + { + struct slcompress *vj = ppp->vj; ++ int cpu; + + memset(st, 0, sizeof(*st)); +- st->p.ppp_ipackets = ppp->stats64.rx_packets; ++ for_each_possible_cpu(cpu) { ++ struct pcpu_sw_netstats *p = per_cpu_ptr(ppp->dev->tstats, cpu); ++ u64 rx_packets, rx_bytes, tx_packets, tx_bytes; ++ ++ rx_packets = u64_stats_read(&p->rx_packets); ++ rx_bytes = u64_stats_read(&p->rx_bytes); ++ tx_packets = u64_stats_read(&p->tx_packets); ++ tx_bytes = u64_stats_read(&p->tx_bytes); ++ ++ st->p.ppp_ipackets += rx_packets; ++ st->p.ppp_ibytes += rx_bytes; ++ st->p.ppp_opackets += tx_packets; ++ st->p.ppp_obytes += tx_bytes; ++ } + st->p.ppp_ierrors = ppp->dev->stats.rx_errors; +- st->p.ppp_ibytes = ppp->stats64.rx_bytes; +- st->p.ppp_opackets = ppp->stats64.tx_packets; + st->p.ppp_oerrors = ppp->dev->stats.tx_errors; +- st->p.ppp_obytes = ppp->stats64.tx_bytes; + if (!vj) + return; + st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/622-v6.18-ppp-remove-rwlock-usage.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/622-v6.18-ppp-remove-rwlock-usage.patch new file mode 100755 index 0000000..f66a522 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/622-v6.18-ppp-remove-rwlock-usage.patch @@ -0,0 +1,334 @@ +From b8844aab519a154808dbce15a132f3e8f1c34af6 Mon Sep 17 00:00:00 2001 +From: Qingfang Deng +Date: Fri, 22 Aug 2025 09:25:47 +0800 +Subject: [PATCH] ppp: remove rwlock usage + +In struct channel, the upl lock is implemented using rwlock_t, +protecting access to pch->ppp and pch->bridge. + +As previously discussed on the list, using rwlock in the network fast +path is not recommended. +This patch replaces the rwlock with a spinlock for writers, and uses RCU +for readers. + +- pch->ppp and pch->bridge are now declared as __rcu pointers. +- Readers use rcu_dereference_bh() under rcu_read_lock_bh(). +- Writers use spin_lock() to update. + +Signed-off-by: Qingfang Deng +Link: https://patch.msgid.link/20250822012548.6232-1-dqfext@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ppp/ppp_generic.c | 120 ++++++++++++++++++---------------- + 1 file changed, 63 insertions(+), 57 deletions(-) + +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -173,11 +173,11 @@ struct channel { + struct ppp_channel *chan; /* public channel data structure */ + struct rw_semaphore chan_sem; /* protects `chan' during chan ioctl */ + spinlock_t downl; /* protects `chan', file.xq dequeue */ +- struct ppp *ppp; /* ppp unit we're connected to */ ++ struct ppp __rcu *ppp; /* ppp unit we're connected to */ + struct net *chan_net; /* the net channel belongs to */ + netns_tracker ns_tracker; + struct list_head clist; /* link in list of channels per unit */ +- rwlock_t upl; /* protects `ppp' and 'bridge' */ ++ spinlock_t upl; /* protects `ppp' and 'bridge' */ + struct channel __rcu *bridge; /* "bridged" ppp channel */ + #ifdef CONFIG_PPP_MULTILINK + u8 avail; /* flag used in multilink stuff */ +@@ -639,34 +639,34 @@ static struct bpf_prog *compat_ppp_get_f + */ + static int ppp_bridge_channels(struct channel *pch, struct channel *pchb) + { +- write_lock_bh(&pch->upl); +- if (pch->ppp || ++ spin_lock(&pch->upl); ++ if (rcu_dereference_protected(pch->ppp, lockdep_is_held(&pch->upl)) || + rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl))) { +- write_unlock_bh(&pch->upl); ++ spin_unlock(&pch->upl); + return -EALREADY; + } + refcount_inc(&pchb->file.refcnt); + rcu_assign_pointer(pch->bridge, pchb); +- write_unlock_bh(&pch->upl); ++ spin_unlock(&pch->upl); + +- write_lock_bh(&pchb->upl); +- if (pchb->ppp || ++ spin_lock(&pchb->upl); ++ if (rcu_dereference_protected(pchb->ppp, lockdep_is_held(&pchb->upl)) || + rcu_dereference_protected(pchb->bridge, lockdep_is_held(&pchb->upl))) { +- write_unlock_bh(&pchb->upl); ++ spin_unlock(&pchb->upl); + goto err_unset; + } + refcount_inc(&pch->file.refcnt); + rcu_assign_pointer(pchb->bridge, pch); +- write_unlock_bh(&pchb->upl); ++ spin_unlock(&pchb->upl); + + return 0; + + err_unset: +- write_lock_bh(&pch->upl); ++ spin_lock(&pch->upl); + /* Re-read pch->bridge with upl held in case it was modified concurrently */ + pchb = rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl)); + RCU_INIT_POINTER(pch->bridge, NULL); +- write_unlock_bh(&pch->upl); ++ spin_unlock(&pch->upl); + synchronize_rcu(); + + if (pchb) +@@ -680,25 +680,25 @@ static int ppp_unbridge_channels(struct + { + struct channel *pchb, *pchbb; + +- write_lock_bh(&pch->upl); ++ spin_lock(&pch->upl); + pchb = rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl)); + if (!pchb) { +- write_unlock_bh(&pch->upl); ++ spin_unlock(&pch->upl); + return -EINVAL; + } + RCU_INIT_POINTER(pch->bridge, NULL); +- write_unlock_bh(&pch->upl); ++ spin_unlock(&pch->upl); + + /* Only modify pchb if phcb->bridge points back to pch. + * If not, it implies that there has been a race unbridging (and possibly + * even rebridging) pchb. We should leave pchb alone to avoid either a + * refcount underflow, or breaking another established bridge instance. + */ +- write_lock_bh(&pchb->upl); ++ spin_lock(&pchb->upl); + pchbb = rcu_dereference_protected(pchb->bridge, lockdep_is_held(&pchb->upl)); + if (pchbb == pch) + RCU_INIT_POINTER(pchb->bridge, NULL); +- write_unlock_bh(&pchb->upl); ++ spin_unlock(&pchb->upl); + + synchronize_rcu(); + +@@ -2144,10 +2144,9 @@ static int ppp_mp_explode(struct ppp *pp + #endif /* CONFIG_PPP_MULTILINK */ + + /* Try to send data out on a channel */ +-static void __ppp_channel_push(struct channel *pch) ++static void __ppp_channel_push(struct channel *pch, struct ppp *ppp) + { + struct sk_buff *skb; +- struct ppp *ppp; + + spin_lock(&pch->downl); + if (pch->chan) { +@@ -2166,7 +2165,6 @@ static void __ppp_channel_push(struct ch + spin_unlock(&pch->downl); + /* see if there is anything from the attached unit to be sent */ + if (skb_queue_empty(&pch->file.xq)) { +- ppp = pch->ppp; + if (ppp) + __ppp_xmit_process(ppp, NULL); + } +@@ -2174,15 +2172,18 @@ static void __ppp_channel_push(struct ch + + static void ppp_channel_push(struct channel *pch) + { +- read_lock_bh(&pch->upl); +- if (pch->ppp) { +- (*this_cpu_ptr(pch->ppp->xmit_recursion))++; +- __ppp_channel_push(pch); +- (*this_cpu_ptr(pch->ppp->xmit_recursion))--; ++ struct ppp *ppp; ++ ++ rcu_read_lock_bh(); ++ ppp = rcu_dereference_bh(pch->ppp); ++ if (ppp) { ++ (*this_cpu_ptr(ppp->xmit_recursion))++; ++ __ppp_channel_push(pch, ppp); ++ (*this_cpu_ptr(ppp->xmit_recursion))--; + } else { +- __ppp_channel_push(pch); ++ __ppp_channel_push(pch, NULL); + } +- read_unlock_bh(&pch->upl); ++ rcu_read_unlock_bh(); + } + + /* +@@ -2284,6 +2285,7 @@ void + ppp_input(struct ppp_channel *chan, struct sk_buff *skb) + { + struct channel *pch = chan->ppp; ++ struct ppp *ppp; + int proto; + + if (!pch) { +@@ -2295,18 +2297,19 @@ ppp_input(struct ppp_channel *chan, stru + if (ppp_channel_bridge_input(pch, skb)) + return; + +- read_lock_bh(&pch->upl); ++ rcu_read_lock_bh(); ++ ppp = rcu_dereference_bh(pch->ppp); + if (!ppp_decompress_proto(skb)) { + kfree_skb(skb); +- if (pch->ppp) { +- ++pch->ppp->dev->stats.rx_length_errors; +- ppp_receive_error(pch->ppp); ++ if (ppp) { ++ ++ppp->dev->stats.rx_length_errors; ++ ppp_receive_error(ppp); + } + goto done; + } + + proto = PPP_PROTO(skb); +- if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { ++ if (!ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { + /* put it on the channel queue */ + skb_queue_tail(&pch->file.rq, skb); + /* drop old frames if queue too long */ +@@ -2315,11 +2318,11 @@ ppp_input(struct ppp_channel *chan, stru + kfree_skb(skb); + wake_up_interruptible(&pch->file.rwait); + } else { +- ppp_do_recv(pch->ppp, skb, pch); ++ ppp_do_recv(ppp, skb, pch); + } + + done: +- read_unlock_bh(&pch->upl); ++ rcu_read_unlock_bh(); + } + + /* Put a 0-length skb in the receive queue as an error indication */ +@@ -2328,20 +2331,22 @@ ppp_input_error(struct ppp_channel *chan + { + struct channel *pch = chan->ppp; + struct sk_buff *skb; ++ struct ppp *ppp; + + if (!pch) + return; + +- read_lock_bh(&pch->upl); +- if (pch->ppp) { ++ rcu_read_lock_bh(); ++ ppp = rcu_dereference_bh(pch->ppp); ++ if (ppp) { + skb = alloc_skb(0, GFP_ATOMIC); + if (skb) { + skb->len = 0; /* probably unnecessary */ + skb->cb[0] = code; +- ppp_do_recv(pch->ppp, skb, pch); ++ ppp_do_recv(ppp, skb, pch); + } + } +- read_unlock_bh(&pch->upl); ++ rcu_read_unlock_bh(); + } + + /* +@@ -2889,7 +2894,6 @@ int ppp_register_net_channel(struct net + + pn = ppp_pernet(net); + +- pch->ppp = NULL; + pch->chan = chan; + pch->chan_net = get_net_track(net, &pch->ns_tracker, GFP_KERNEL); + chan->ppp = pch; +@@ -2900,7 +2904,7 @@ int ppp_register_net_channel(struct net + #endif /* CONFIG_PPP_MULTILINK */ + init_rwsem(&pch->chan_sem); + spin_lock_init(&pch->downl); +- rwlock_init(&pch->upl); ++ spin_lock_init(&pch->upl); + + spin_lock_bh(&pn->all_channels_lock); + pch->file.index = ++pn->last_channel_index; +@@ -2929,13 +2933,15 @@ int ppp_channel_index(struct ppp_channel + int ppp_unit_number(struct ppp_channel *chan) + { + struct channel *pch = chan->ppp; ++ struct ppp *ppp; + int unit = -1; + + if (pch) { +- read_lock_bh(&pch->upl); +- if (pch->ppp) +- unit = pch->ppp->file.index; +- read_unlock_bh(&pch->upl); ++ rcu_read_lock(); ++ ppp = rcu_dereference(pch->ppp); ++ if (ppp) ++ unit = ppp->file.index; ++ rcu_read_unlock(); + } + return unit; + } +@@ -2947,12 +2953,14 @@ char *ppp_dev_name(struct ppp_channel *c + { + struct channel *pch = chan->ppp; + char *name = NULL; ++ struct ppp *ppp; + + if (pch) { +- read_lock_bh(&pch->upl); +- if (pch->ppp && pch->ppp->dev) +- name = pch->ppp->dev->name; +- read_unlock_bh(&pch->upl); ++ rcu_read_lock(); ++ ppp = rcu_dereference(pch->ppp); ++ if (ppp && ppp->dev) ++ name = ppp->dev->name; ++ rcu_read_unlock(); + } + return name; + } +@@ -3475,9 +3483,9 @@ ppp_connect_channel(struct channel *pch, + ppp = ppp_find_unit(pn, unit); + if (!ppp) + goto out; +- write_lock_bh(&pch->upl); ++ spin_lock(&pch->upl); + ret = -EINVAL; +- if (pch->ppp || ++ if (rcu_dereference_protected(pch->ppp, lockdep_is_held(&pch->upl)) || + rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl))) + goto outl; + +@@ -3502,13 +3510,13 @@ ppp_connect_channel(struct channel *pch, + ppp->dev->hard_header_len = hdrlen; + list_add_tail_rcu(&pch->clist, &ppp->channels); + ++ppp->n_channels; +- pch->ppp = ppp; ++ rcu_assign_pointer(pch->ppp, ppp); + refcount_inc(&ppp->file.refcnt); + ppp_unlock(ppp); + ret = 0; + + outl: +- write_unlock_bh(&pch->upl); ++ spin_unlock(&pch->upl); + out: + mutex_unlock(&pn->all_ppp_mutex); + return ret; +@@ -3523,10 +3531,9 @@ ppp_disconnect_channel(struct channel *p + struct ppp *ppp; + int err = -EINVAL; + +- write_lock_bh(&pch->upl); +- ppp = pch->ppp; +- pch->ppp = NULL; +- write_unlock_bh(&pch->upl); ++ spin_lock(&pch->upl); ++ ppp = rcu_replace_pointer(pch->ppp, NULL, lockdep_is_held(&pch->upl)); ++ spin_unlock(&pch->upl); + if (ppp) { + /* remove it from the ppp unit's list */ + ppp_lock(ppp); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/623-v6.18-pppoe-remove-rwlock-usage.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/623-v6.18-pppoe-remove-rwlock-usage.patch new file mode 100755 index 0000000..619f1cb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/623-v6.18-pppoe-remove-rwlock-usage.patch @@ -0,0 +1,321 @@ +From 72cdc67e7fa74931b055df3a76852bab551f1a04 Mon Sep 17 00:00:00 2001 +From: Qingfang Deng +Date: Thu, 28 Aug 2025 09:20:16 +0800 +Subject: [PATCH] pppoe: remove rwlock usage + +Like ppp_generic.c, convert the PPPoE socket hash table to use RCU for +lookups and a spinlock for updates. This removes rwlock usage and allows +lockless readers on the fast path. + +- Mark hash table and list pointers as __rcu. +- Use spin_lock() to protect writers. +- Readers use rcu_dereference() under rcu_read_lock(). All known callers + of get_item() already hold the RCU read lock, so no additional locking + is needed. +- get_item() now uses refcount_inc_not_zero() instead of sock_hold() to + safely take a reference. This prevents crashes if a socket is already + in the process of being freed (sk_refcnt == 0). +- Set SOCK_RCU_FREE to defer socket freeing until after an RCU grace + period. +- Move skb_queue_purge() into sk_destruct callback to ensure purge + happens after an RCU grace period. + +Signed-off-by: Qingfang Deng +Reviewed-by: Eric Dumazet +Link: https://patch.msgid.link/20250828012018.15922-1-dqfext@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ppp/pppoe.c | 94 ++++++++++++++++++++++------------------ + include/linux/if_pppox.h | 2 +- + 2 files changed, 54 insertions(+), 42 deletions(-) + +--- a/drivers/net/ppp/pppoe.c ++++ b/drivers/net/ppp/pppoe.c +@@ -100,8 +100,8 @@ struct pppoe_net { + * as well, moreover in case of SMP less locking + * controversy here + */ +- struct pppox_sock *hash_table[PPPOE_HASH_SIZE]; +- rwlock_t hash_lock; ++ struct pppox_sock __rcu *hash_table[PPPOE_HASH_SIZE]; ++ spinlock_t hash_lock; + }; + + /* +@@ -162,13 +162,13 @@ static struct pppox_sock *__get_item(str + int hash = hash_item(sid, addr); + struct pppox_sock *ret; + +- ret = pn->hash_table[hash]; ++ ret = rcu_dereference(pn->hash_table[hash]); + while (ret) { + if (cmp_addr(&ret->pppoe_pa, sid, addr) && + ret->pppoe_ifindex == ifindex) + return ret; + +- ret = ret->next; ++ ret = rcu_dereference(ret->next); + } + + return NULL; +@@ -177,19 +177,20 @@ static struct pppox_sock *__get_item(str + static int __set_item(struct pppoe_net *pn, struct pppox_sock *po) + { + int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote); +- struct pppox_sock *ret; ++ struct pppox_sock *ret, *first; + +- ret = pn->hash_table[hash]; ++ first = rcu_dereference_protected(pn->hash_table[hash], lockdep_is_held(&pn->hash_lock)); ++ ret = first; + while (ret) { + if (cmp_2_addr(&ret->pppoe_pa, &po->pppoe_pa) && + ret->pppoe_ifindex == po->pppoe_ifindex) + return -EALREADY; + +- ret = ret->next; ++ ret = rcu_dereference_protected(ret->next, lockdep_is_held(&pn->hash_lock)); + } + +- po->next = pn->hash_table[hash]; +- pn->hash_table[hash] = po; ++ RCU_INIT_POINTER(po->next, first); ++ rcu_assign_pointer(pn->hash_table[hash], po); + + return 0; + } +@@ -198,20 +199,24 @@ static void __delete_item(struct pppoe_n + char *addr, int ifindex) + { + int hash = hash_item(sid, addr); +- struct pppox_sock *ret, **src; ++ struct pppox_sock *ret, __rcu **src; + +- ret = pn->hash_table[hash]; ++ ret = rcu_dereference_protected(pn->hash_table[hash], lockdep_is_held(&pn->hash_lock)); + src = &pn->hash_table[hash]; + + while (ret) { + if (cmp_addr(&ret->pppoe_pa, sid, addr) && + ret->pppoe_ifindex == ifindex) { +- *src = ret->next; ++ struct pppox_sock *next; ++ ++ next = rcu_dereference_protected(ret->next, ++ lockdep_is_held(&pn->hash_lock)); ++ rcu_assign_pointer(*src, next); + break; + } + + src = &ret->next; +- ret = ret->next; ++ ret = rcu_dereference_protected(ret->next, lockdep_is_held(&pn->hash_lock)); + } + } + +@@ -225,11 +230,9 @@ static inline struct pppox_sock *get_ite + { + struct pppox_sock *po; + +- read_lock_bh(&pn->hash_lock); + po = __get_item(pn, sid, addr, ifindex); +- if (po) +- sock_hold(sk_pppox(po)); +- read_unlock_bh(&pn->hash_lock); ++ if (po && !refcount_inc_not_zero(&sk_pppox(po)->sk_refcnt)) ++ po = NULL; + + return po; + } +@@ -258,9 +261,9 @@ static inline struct pppox_sock *get_ite + static inline void delete_item(struct pppoe_net *pn, __be16 sid, + char *addr, int ifindex) + { +- write_lock_bh(&pn->hash_lock); ++ spin_lock(&pn->hash_lock); + __delete_item(pn, sid, addr, ifindex); +- write_unlock_bh(&pn->hash_lock); ++ spin_unlock(&pn->hash_lock); + } + + /*************************************************************************** +@@ -276,14 +279,16 @@ static void pppoe_flush_dev(struct net_d + int i; + + pn = pppoe_pernet(dev_net(dev)); +- write_lock_bh(&pn->hash_lock); ++ spin_lock(&pn->hash_lock); + for (i = 0; i < PPPOE_HASH_SIZE; i++) { +- struct pppox_sock *po = pn->hash_table[i]; ++ struct pppox_sock *po = rcu_dereference_protected(pn->hash_table[i], ++ lockdep_is_held(&pn->hash_lock)); + struct sock *sk; + + while (po) { + while (po && po->pppoe_dev != dev) { +- po = po->next; ++ po = rcu_dereference_protected(po->next, ++ lockdep_is_held(&pn->hash_lock)); + } + + if (!po) +@@ -300,7 +305,7 @@ static void pppoe_flush_dev(struct net_d + */ + + sock_hold(sk); +- write_unlock_bh(&pn->hash_lock); ++ spin_unlock(&pn->hash_lock); + lock_sock(sk); + + if (po->pppoe_dev == dev && +@@ -320,11 +325,12 @@ static void pppoe_flush_dev(struct net_d + */ + + BUG_ON(pppoe_pernet(dev_net(dev)) == NULL); +- write_lock_bh(&pn->hash_lock); +- po = pn->hash_table[i]; ++ spin_lock(&pn->hash_lock); ++ po = rcu_dereference_protected(pn->hash_table[i], ++ lockdep_is_held(&pn->hash_lock)); + } + } +- write_unlock_bh(&pn->hash_lock); ++ spin_unlock(&pn->hash_lock); + } + + static int pppoe_device_event(struct notifier_block *this, +@@ -528,6 +534,11 @@ static struct proto pppoe_sk_proto __rea + .obj_size = sizeof(struct pppox_sock), + }; + ++static void pppoe_destruct(struct sock *sk) ++{ ++ skb_queue_purge(&sk->sk_receive_queue); ++} ++ + /*********************************************************************** + * + * Initialize a new struct sock. +@@ -542,11 +553,13 @@ static int pppoe_create(struct net *net, + return -ENOMEM; + + sock_init_data(sock, sk); ++ sock_set_flag(sk, SOCK_RCU_FREE); + + sock->state = SS_UNCONNECTED; + sock->ops = &pppoe_ops; + + sk->sk_backlog_rcv = pppoe_rcv_core; ++ sk->sk_destruct = pppoe_destruct; + sk->sk_state = PPPOX_NONE; + sk->sk_type = SOCK_STREAM; + sk->sk_family = PF_PPPOX; +@@ -599,7 +612,6 @@ static int pppoe_release(struct socket * + sock_orphan(sk); + sock->sk = NULL; + +- skb_queue_purge(&sk->sk_receive_queue); + release_sock(sk); + sock_put(sk); + +@@ -681,9 +693,9 @@ static int pppoe_connect(struct socket * + &sp->sa_addr.pppoe, + sizeof(struct pppoe_addr)); + +- write_lock_bh(&pn->hash_lock); ++ spin_lock(&pn->hash_lock); + error = __set_item(pn, po); +- write_unlock_bh(&pn->hash_lock); ++ spin_unlock(&pn->hash_lock); + if (error < 0) + goto err_put; + +@@ -1052,11 +1064,11 @@ static inline struct pppox_sock *pppoe_g + int i; + + for (i = 0; i < PPPOE_HASH_SIZE; i++) { +- po = pn->hash_table[i]; ++ po = rcu_dereference(pn->hash_table[i]); + while (po) { + if (!pos--) + goto out; +- po = po->next; ++ po = rcu_dereference(po->next); + } + } + +@@ -1065,19 +1077,19 @@ out: + } + + static void *pppoe_seq_start(struct seq_file *seq, loff_t *pos) +- __acquires(pn->hash_lock) ++ __acquires(RCU) + { + struct pppoe_net *pn = pppoe_pernet(seq_file_net(seq)); + loff_t l = *pos; + +- read_lock_bh(&pn->hash_lock); ++ rcu_read_lock(); + return l ? pppoe_get_idx(pn, --l) : SEQ_START_TOKEN; + } + + static void *pppoe_seq_next(struct seq_file *seq, void *v, loff_t *pos) + { + struct pppoe_net *pn = pppoe_pernet(seq_file_net(seq)); +- struct pppox_sock *po; ++ struct pppox_sock *po, *next; + + ++*pos; + if (v == SEQ_START_TOKEN) { +@@ -1085,14 +1097,15 @@ static void *pppoe_seq_next(struct seq_f + goto out; + } + po = v; +- if (po->next) +- po = po->next; ++ next = rcu_dereference(po->next); ++ if (next) ++ po = next; + else { + int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote); + + po = NULL; + while (++hash < PPPOE_HASH_SIZE) { +- po = pn->hash_table[hash]; ++ po = rcu_dereference(pn->hash_table[hash]); + if (po) + break; + } +@@ -1103,10 +1116,9 @@ out: + } + + static void pppoe_seq_stop(struct seq_file *seq, void *v) +- __releases(pn->hash_lock) ++ __releases(RCU) + { +- struct pppoe_net *pn = pppoe_pernet(seq_file_net(seq)); +- read_unlock_bh(&pn->hash_lock); ++ rcu_read_unlock(); + } + + static const struct seq_operations pppoe_seq_ops = { +@@ -1149,7 +1161,7 @@ static __net_init int pppoe_init_net(str + struct pppoe_net *pn = pppoe_pernet(net); + struct proc_dir_entry *pde; + +- rwlock_init(&pn->hash_lock); ++ spin_lock_init(&pn->hash_lock); + + pde = proc_create_net("pppoe", 0444, net->proc_net, + &pppoe_seq_ops, sizeof(struct seq_net_private)); +--- a/include/linux/if_pppox.h ++++ b/include/linux/if_pppox.h +@@ -43,7 +43,7 @@ struct pppox_sock { + /* struct sock must be the first member of pppox_sock */ + struct sock sk; + struct ppp_channel chan; +- struct pppox_sock *next; /* for hash table */ ++ struct pppox_sock __rcu *next; /* for hash table */ + union { + struct pppoe_opt pppoe; + struct pptp_opt pptp; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/624-v6.18-pppoe-drop-sock-reference-counting-on-fast-path.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/624-v6.18-pppoe-drop-sock-reference-counting-on-fast-path.patch new file mode 100755 index 0000000..2637621 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/624-v6.18-pppoe-drop-sock-reference-counting-on-fast-path.patch @@ -0,0 +1,124 @@ +From 4f54dff818d7b5b1d84becd5d90bc46e6233c0d7 Mon Sep 17 00:00:00 2001 +From: Qingfang Deng +Date: Thu, 28 Aug 2025 09:20:17 +0800 +Subject: [PATCH] pppoe: drop sock reference counting on fast path + +Now that PPPoE sockets are freed via RCU (SOCK_RCU_FREE), it is no longer +necessary to take a reference count when looking up sockets on the receive +path. Readers are protected by RCU, so the socket memory remains valid +until after a grace period. + +Convert fast-path lookups to avoid refcounting: + - Replace get_item() and sk_receive_skb() in pppoe_rcv() with + __get_item() and __sk_receive_skb(). + - Rework get_item_by_addr() into __get_item_by_addr() (no refcount and + move RCU lock into pppoe_ioctl) + - Remove unnecessary sock_put() calls. + +This avoids cacheline bouncing from atomic reference counting and improves +performance on the receive fast path. + +Signed-off-by: Qingfang Deng +Reviewed-by: Eric Dumazet +Link: https://patch.msgid.link/20250828012018.15922-2-dqfext@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ppp/pppoe.c | 35 +++++++++++++---------------------- + 1 file changed, 13 insertions(+), 22 deletions(-) + +--- a/drivers/net/ppp/pppoe.c ++++ b/drivers/net/ppp/pppoe.c +@@ -237,8 +237,8 @@ static inline struct pppox_sock *get_ite + return po; + } + +-static inline struct pppox_sock *get_item_by_addr(struct net *net, +- struct sockaddr_pppox *sp) ++static inline struct pppox_sock *__get_item_by_addr(struct net *net, ++ struct sockaddr_pppox *sp) + { + struct net_device *dev; + struct pppoe_net *pn; +@@ -246,15 +246,13 @@ static inline struct pppox_sock *get_ite + + int ifindex; + +- rcu_read_lock(); + dev = dev_get_by_name_rcu(net, sp->sa_addr.pppoe.dev); + if (dev) { + ifindex = dev->ifindex; + pn = pppoe_pernet(net); +- pppox_sock = get_item(pn, sp->sa_addr.pppoe.sid, +- sp->sa_addr.pppoe.remote, ifindex); ++ pppox_sock = __get_item(pn, sp->sa_addr.pppoe.sid, ++ sp->sa_addr.pppoe.remote, ifindex); + } +- rcu_read_unlock(); + return pppox_sock; + } + +@@ -384,18 +382,16 @@ static int pppoe_rcv_core(struct sock *s + if (sk->sk_state & PPPOX_BOUND) { + ppp_input(&po->chan, skb); + } else if (sk->sk_state & PPPOX_RELAY) { +- relay_po = get_item_by_addr(sock_net(sk), +- &po->pppoe_relay); ++ relay_po = __get_item_by_addr(sock_net(sk), ++ &po->pppoe_relay); + if (relay_po == NULL) + goto abort_kfree; + + if ((sk_pppox(relay_po)->sk_state & PPPOX_CONNECTED) == 0) +- goto abort_put; ++ goto abort_kfree; + + if (!__pppoe_xmit(sk_pppox(relay_po), skb)) +- goto abort_put; +- +- sock_put(sk_pppox(relay_po)); ++ goto abort_kfree; + } else { + if (sock_queue_rcv_skb(sk, skb)) + goto abort_kfree; +@@ -403,9 +399,6 @@ static int pppoe_rcv_core(struct sock *s + + return NET_RX_SUCCESS; + +-abort_put: +- sock_put(sk_pppox(relay_po)); +- + abort_kfree: + kfree_skb(skb); + return NET_RX_DROP; +@@ -447,14 +440,11 @@ static int pppoe_rcv(struct sk_buff *skb + ph = pppoe_hdr(skb); + pn = pppoe_pernet(dev_net(dev)); + +- /* Note that get_item does a sock_hold(), so sk_pppox(po) +- * is known to be safe. +- */ +- po = get_item(pn, ph->sid, eth_hdr(skb)->h_source, dev->ifindex); ++ po = __get_item(pn, ph->sid, eth_hdr(skb)->h_source, dev->ifindex); + if (!po) + goto drop; + +- return sk_receive_skb(sk_pppox(po), skb, 0); ++ return __sk_receive_skb(sk_pppox(po), skb, 0, 1, false); + + drop: + kfree_skb(skb); +@@ -820,11 +810,12 @@ static int pppoe_ioctl(struct socket *so + + /* Check that the socket referenced by the address + actually exists. */ +- relay_po = get_item_by_addr(sock_net(sk), &po->pppoe_relay); ++ rcu_read_lock(); ++ relay_po = __get_item_by_addr(sock_net(sk), &po->pppoe_relay); ++ rcu_read_unlock(); + if (!relay_po) + break; + +- sock_put(sk_pppox(relay_po)); + sk->sk_state |= PPPOX_RELAY; + err = 0; + break; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/625-v7.0-ppp-enable-TX-scatter-gather.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/625-v7.0-ppp-enable-TX-scatter-gather.patch new file mode 100755 index 0000000..5ea56f5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/625-v7.0-ppp-enable-TX-scatter-gather.patch @@ -0,0 +1,104 @@ +From 42fcb213e58a7da33d5d2d7517b4e521025c68c3 Mon Sep 17 00:00:00 2001 +From: Qingfang Deng +Date: Thu, 29 Jan 2026 09:29:02 +0800 +Subject: [PATCH] ppp: enable TX scatter-gather + +PPP channels using chan->direct_xmit prepend the PPP header to a skb and +call dev_queue_xmit() directly. In this mode the skb does not need to be +linear, but the PPP netdevice currently does not advertise +scatter-gather features, causing unnecessary linearization and +preventing GSO. + +Enable NETIF_F_SG and NETIF_F_FRAGLIST on PPP devices. In case a linear +buffer is required (PPP compression, multilink, and channels without +direct_xmit), call skb_linearize() explicitly. + +Signed-off-by: Qingfang Deng +Link: https://patch.msgid.link/20260129012902.941-1-dqfext@gmail.com +Signed-off-by: Paolo Abeni +--- + drivers/net/ppp/ppp_generic.c | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) + +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -1632,6 +1632,8 @@ static void ppp_setup(struct net_device + dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; + dev->priv_destructor = ppp_dev_priv_destructor; + dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; ++ dev->features = NETIF_F_SG | NETIF_F_FRAGLIST; ++ dev->hw_features = dev->features; + netif_keep_dst(dev); + } + +@@ -1696,6 +1698,10 @@ pad_compress_skb(struct ppp *ppp, struct + ppp->xcomp->comp_extra + ppp->dev->hard_header_len; + int compressor_skb_size = ppp->dev->mtu + + ppp->xcomp->comp_extra + PPP_HDRLEN; ++ ++ if (skb_linearize(skb)) ++ return NULL; ++ + new_skb = alloc_skb(new_skb_size, GFP_ATOMIC); + if (!new_skb) { + if (net_ratelimit()) +@@ -1783,6 +1789,10 @@ ppp_send_frame(struct ppp *ppp, struct s + case PPP_IP: + if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0) + break; ++ ++ if (skb_linearize(skb)) ++ goto drop; ++ + /* try to do VJ TCP header compression */ + new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2, + GFP_ATOMIC); +@@ -1880,19 +1890,26 @@ ppp_push(struct ppp *ppp) + } + + if ((ppp->flags & SC_MULTILINK) == 0) { ++ struct ppp_channel *chan; + /* not doing multilink: send it down the first channel */ + list = list->next; + pch = list_entry(list, struct channel, clist); + + spin_lock(&pch->downl); +- if (pch->chan) { +- if (pch->chan->ops->start_xmit(pch->chan, skb)) +- ppp->xmit_pending = NULL; +- } else { +- /* channel got unregistered */ ++ chan = pch->chan; ++ if (unlikely(!chan || (!chan->direct_xmit && skb_linearize(skb)))) { ++ /* channel got unregistered, or it requires a linear ++ * skb but linearization failed ++ */ + kfree_skb(skb); + ppp->xmit_pending = NULL; ++ goto out; + } ++ ++ if (chan->ops->start_xmit(chan, skb)) ++ ppp->xmit_pending = NULL; ++ ++out: + spin_unlock(&pch->downl); + return; + } +@@ -1977,6 +1994,8 @@ static int ppp_mp_explode(struct ppp *pp + return 0; /* can't take now, leave it in xmit_pending */ + + /* Do protocol field compression */ ++ if (skb_linearize(skb)) ++ goto err_linearize; + p = skb->data; + len = skb->len; + if (*p == 0 && mp_protocol_compress) { +@@ -2135,6 +2154,7 @@ static int ppp_mp_explode(struct ppp *pp + + noskb: + spin_unlock(&pch->downl); ++ err_linearize: + if (ppp->debug & 1) + netdev_err(ppp->dev, "PPP: no memory (fragment)\n"); + ++ppp->dev->stats.tx_errors; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-01-v6.13-net-pse-pd-Add-power-limit-check.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-01-v6.13-net-pse-pd-Add-power-limit-check.patch new file mode 100755 index 0000000..fbcc3ec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-01-v6.13-net-pse-pd-Add-power-limit-check.patch @@ -0,0 +1,41 @@ +From 6e56a6d47a7fad705a1a1d088237b0858c01a770 Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:22 +0100 +Subject: [PATCH] net: pse-pd: Add power limit check + +Checking only the current limit is not sufficient. According to the +standard, voltage can reach up to 57V and current up to 1.92A, which +exceeds the power limit described in the standard (99.9W). Add a power +limit check to prevent this. + +Acked-by: Oleksij Rempel +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pse_core.c | 3 +++ + include/linux/pse-pd/pse.h | 2 ++ + 2 files changed, 5 insertions(+) +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -868,6 +868,9 @@ int pse_ethtool_set_pw_limit(struct pse_ + int uV, uA, ret; + s64 tmp_64; + ++ if (pw_limit > MAX_PI_PW) ++ return -ERANGE; ++ + ret = regulator_get_voltage(psec->ps); + if (!ret) { + NL_SET_ERR_MSG(extack, +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -11,6 +11,8 @@ + + /* Maximum current in uA according to IEEE 802.3-2022 Table 145-1 */ + #define MAX_PI_CURRENT 1920000 ++/* Maximum power in mW according to IEEE 802.3-2022 Table 145-16 */ ++#define MAX_PI_PW 99900 + + struct phy_device; + struct pse_controller_dev; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-02-v6.13-net-pse-pd-tps23881-Simplify-function-returns.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-02-v6.13-net-pse-pd-tps23881-Simplify-function-returns.patch new file mode 100755 index 0000000..fc6d532 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-02-v6.13-net-pse-pd-tps23881-Simplify-function-returns.patch @@ -0,0 +1,112 @@ +From 0b567519d1152de52b29b2da2c47aa0f39a46266 Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:23 +0100 +Subject: [PATCH] net: pse-pd: tps23881: Simplify function returns by removing + redundant checks + +Cleaned up several functions in tps23881 by removing redundant checks on +return values at the end of functions. These check has been removed, and +the return statement now directly returns the function result, reducing +the code's complexity and making it more concise. + +Reviewed-by: Andrew Lunn +Acked-by: Oleksij Rempel +Reviewed-by: Kyle Swenson +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 34 ++++++---------------------------- + 1 file changed, 6 insertions(+), 28 deletions(-) +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -59,7 +59,6 @@ static int tps23881_pi_enable(struct pse + struct i2c_client *client = priv->client; + u8 chan; + u16 val; +- int ret; + + if (id >= TPS23881_MAX_CHANS) + return -ERANGE; +@@ -78,11 +77,7 @@ static int tps23881_pi_enable(struct pse + val |= BIT(chan + 4); + } + +- ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); +- if (ret) +- return ret; +- +- return 0; ++ return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); + } + + static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id) +@@ -91,7 +86,6 @@ static int tps23881_pi_disable(struct ps + struct i2c_client *client = priv->client; + u8 chan; + u16 val; +- int ret; + + if (id >= TPS23881_MAX_CHANS) + return -ERANGE; +@@ -110,11 +104,7 @@ static int tps23881_pi_disable(struct ps + val |= BIT(chan + 8); + } + +- ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); +- if (ret) +- return ret; +- +- return 0; ++ return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); + } + + static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id) +@@ -480,7 +470,7 @@ tps23881_write_port_matrix(struct tps238 + struct i2c_client *client = priv->client; + u8 pi_id, lgcl_chan, hw_chan; + u16 val = 0; +- int i, ret; ++ int i; + + for (i = 0; i < port_cnt; i++) { + pi_id = port_matrix[i].pi_id; +@@ -511,11 +501,7 @@ tps23881_write_port_matrix(struct tps238 + } + + /* Write hardware ports matrix */ +- ret = i2c_smbus_write_word_data(client, TPS23881_REG_PORT_MAP, val); +- if (ret) +- return ret; +- +- return 0; ++ return i2c_smbus_write_word_data(client, TPS23881_REG_PORT_MAP, val); + } + + static int +@@ -564,11 +550,7 @@ tps23881_set_ports_conf(struct tps23881_ + val |= BIT(port_matrix[i].lgcl_chan[1]) | + BIT(port_matrix[i].lgcl_chan[1] + 4); + } +- ret = i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val); +- if (ret) +- return ret; +- +- return 0; ++ return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val); + } + + static int +@@ -594,11 +576,7 @@ tps23881_set_ports_matrix(struct tps2388 + if (ret) + return ret; + +- ret = tps23881_set_ports_conf(priv, port_matrix); +- if (ret) +- return ret; +- +- return 0; ++ return tps23881_set_ports_conf(priv, port_matrix); + } + + static int tps23881_setup_pi_matrix(struct pse_controller_dev *pcdev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-03-v6.13-net-pse-pd-tps23881-Use-helpers-to-calculate-bit-offset.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-03-v6.13-net-pse-pd-tps23881-Use-helpers-to-calculate-bit-offset.patch new file mode 100755 index 0000000..3b390ea --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-03-v6.13-net-pse-pd-tps23881-Use-helpers-to-calculate-bit-offset.patch @@ -0,0 +1,190 @@ +From 4c2bab507eb7edc8e497e91b9b7f05d76d7e32bb Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:24 +0100 +Subject: [PATCH] net: pse-pd: tps23881: Use helpers to calculate bit offset + for a channel + +This driver frequently follows a pattern where two registers are read or +written in a single operation, followed by calculating the bit offset for +a specific channel. + +Introduce helpers to streamline this process and reduce code redundancy, +making the codebase cleaner and more maintainable. + +Acked-by: Oleksij Rempel +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 107 ++++++++++++++++++++++------------ + 1 file changed, 69 insertions(+), 38 deletions(-) +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -53,6 +53,55 @@ static struct tps23881_priv *to_tps23881 + return container_of(pcdev, struct tps23881_priv, pcdev); + } + ++/* ++ * Helper to extract a value from a u16 register value, which is made of two ++ * u8 registers. The function calculates the bit offset based on the channel ++ * and extracts the relevant bits using a provided field mask. ++ * ++ * @param reg_val: The u16 register value (composed of two u8 registers). ++ * @param chan: The channel number (0-7). ++ * @param field_offset: The base bit offset to apply (e.g., 0 or 4). ++ * @param field_mask: The mask to apply to extract the required bits. ++ * @return: The extracted value for the specific channel. ++ */ ++static u16 tps23881_calc_val(u16 reg_val, u8 chan, u8 field_offset, ++ u16 field_mask) ++{ ++ if (chan >= 4) ++ reg_val >>= 8; ++ ++ return (reg_val >> field_offset) & field_mask; ++} ++ ++/* ++ * Helper to combine individual channel values into a u16 register value. ++ * The function sets the value for a specific channel in the appropriate ++ * position. ++ * ++ * @param reg_val: The current u16 register value. ++ * @param chan: The channel number (0-7). ++ * @param field_offset: The base bit offset to apply (e.g., 0 or 4). ++ * @param field_mask: The mask to apply for the field (e.g., 0x0F). ++ * @param field_val: The value to set for the specific channel (masked by ++ * field_mask). ++ * @return: The updated u16 register value with the channel value set. ++ */ ++static u16 tps23881_set_val(u16 reg_val, u8 chan, u8 field_offset, ++ u16 field_mask, u16 field_val) ++{ ++ field_val &= field_mask; ++ ++ if (chan < 4) { ++ reg_val &= ~(field_mask << field_offset); ++ reg_val |= (field_val << field_offset); ++ } else { ++ reg_val &= ~(field_mask << (field_offset + 8)); ++ reg_val |= (field_val << (field_offset + 8)); ++ } ++ ++ return reg_val; ++} ++ + static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id) + { + struct tps23881_priv *priv = to_tps23881_priv(pcdev); +@@ -64,17 +113,12 @@ static int tps23881_pi_enable(struct pse + return -ERANGE; + + chan = priv->port[id].chan[0]; +- if (chan < 4) +- val = BIT(chan); +- else +- val = BIT(chan + 4); ++ val = tps23881_set_val(0, chan, 0, BIT(chan % 4), BIT(chan % 4)); + + if (priv->port[id].is_4p) { + chan = priv->port[id].chan[1]; +- if (chan < 4) +- val |= BIT(chan); +- else +- val |= BIT(chan + 4); ++ val = tps23881_set_val(val, chan, 0, BIT(chan % 4), ++ BIT(chan % 4)); + } + + return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); +@@ -91,17 +135,12 @@ static int tps23881_pi_disable(struct ps + return -ERANGE; + + chan = priv->port[id].chan[0]; +- if (chan < 4) +- val = BIT(chan + 4); +- else +- val = BIT(chan + 8); ++ val = tps23881_set_val(0, chan, 4, BIT(chan % 4), BIT(chan % 4)); + + if (priv->port[id].is_4p) { + chan = priv->port[id].chan[1]; +- if (chan < 4) +- val |= BIT(chan + 4); +- else +- val |= BIT(chan + 8); ++ val = tps23881_set_val(val, chan, 4, BIT(chan % 4), ++ BIT(chan % 4)); + } + + return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); +@@ -113,6 +152,7 @@ static int tps23881_pi_is_enabled(struct + struct i2c_client *client = priv->client; + bool enabled; + u8 chan; ++ u16 val; + int ret; + + ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS); +@@ -120,17 +160,13 @@ static int tps23881_pi_is_enabled(struct + return ret; + + chan = priv->port[id].chan[0]; +- if (chan < 4) +- enabled = ret & BIT(chan); +- else +- enabled = ret & BIT(chan + 4); ++ val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); ++ enabled = !!(val); + + if (priv->port[id].is_4p) { + chan = priv->port[id].chan[1]; +- if (chan < 4) +- enabled &= !!(ret & BIT(chan)); +- else +- enabled &= !!(ret & BIT(chan + 4)); ++ val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); ++ enabled &= !!(val); + } + + /* Return enabled status only if both channel are on this state */ +@@ -146,6 +182,7 @@ static int tps23881_ethtool_get_status(s + struct i2c_client *client = priv->client; + bool enabled, delivering; + u8 chan; ++ u16 val; + int ret; + + ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS); +@@ -153,23 +190,17 @@ static int tps23881_ethtool_get_status(s + return ret; + + chan = priv->port[id].chan[0]; +- if (chan < 4) { +- enabled = ret & BIT(chan); +- delivering = ret & BIT(chan + 4); +- } else { +- enabled = ret & BIT(chan + 4); +- delivering = ret & BIT(chan + 8); +- } ++ val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); ++ enabled = !!(val); ++ val = tps23881_calc_val(ret, chan, 4, BIT(chan % 4)); ++ delivering = !!(val); + + if (priv->port[id].is_4p) { + chan = priv->port[id].chan[1]; +- if (chan < 4) { +- enabled &= !!(ret & BIT(chan)); +- delivering &= !!(ret & BIT(chan + 4)); +- } else { +- enabled &= !!(ret & BIT(chan + 4)); +- delivering &= !!(ret & BIT(chan + 8)); +- } ++ val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); ++ enabled &= !!(val); ++ val = tps23881_calc_val(ret, chan, 4, BIT(chan % 4)); ++ delivering &= !!(val); + } + + /* Return delivering status only if both channel are on this state */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-04-v6.13-net-pse-pd-tps23881-Add-missing-configuration-register.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-04-v6.13-net-pse-pd-tps23881-Add-missing-configuration-register.patch new file mode 100755 index 0000000..c00dd90 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-04-v6.13-net-pse-pd-tps23881-Add-missing-configuration-register.patch @@ -0,0 +1,63 @@ +From f3cb3c7bea0c08e821d8e9dfd2f96acd1db7c24e Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:25 +0100 +Subject: [PATCH] net: pse-pd: tps23881: Add missing configuration register + after disable + +When setting the PWOFF register, the controller resets multiple +configuration registers. This patch ensures these registers are +reconfigured as needed following a disable operation. + +Acked-by: Oleksij Rempel +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 30 +++++++++++++++++++++++++++++- + 1 file changed, 29 insertions(+), 1 deletion(-) +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -130,6 +130,7 @@ static int tps23881_pi_disable(struct ps + struct i2c_client *client = priv->client; + u8 chan; + u16 val; ++ int ret; + + if (id >= TPS23881_MAX_CHANS) + return -ERANGE; +@@ -143,7 +144,34 @@ static int tps23881_pi_disable(struct ps + BIT(chan % 4)); + } + +- return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); ++ if (ret) ++ return ret; ++ ++ /* PWOFF command resets lots of register which need to be ++ * configured again. According to the datasheet "It may take upwards ++ * of 5ms after PWOFFn command for all register values to be updated" ++ */ ++ mdelay(5); ++ ++ /* Enable detection and classification */ ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_DET_CLA_EN); ++ if (ret < 0) ++ return ret; ++ ++ chan = priv->port[id].chan[0]; ++ val = tps23881_set_val(ret, chan, 0, BIT(chan % 4), BIT(chan % 4)); ++ val = tps23881_set_val(val, chan, 4, BIT(chan % 4), BIT(chan % 4)); ++ ++ if (priv->port[id].is_4p) { ++ chan = priv->port[id].chan[1]; ++ val = tps23881_set_val(ret, chan, 0, BIT(chan % 4), ++ BIT(chan % 4)); ++ val = tps23881_set_val(val, chan, 4, BIT(chan % 4), ++ BIT(chan % 4)); ++ } ++ ++ return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val); + } + + static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-05-v6.13-net-pse-pd-Split-ethtool_get_status-into-multiple-callbacks.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-05-v6.13-net-pse-pd-Split-ethtool_get_status-into-multiple-callbacks.patch new file mode 100755 index 0000000..71a2379 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-05-v6.13-net-pse-pd-Split-ethtool_get_status-into-multiple-callbacks.patch @@ -0,0 +1,714 @@ +From 3e9dbfec499807767d03592ebdf19d9c15fd495b Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:27 +0100 +Subject: [PATCH] net: pse-pd: Split ethtool_get_status into multiple callbacks + +The ethtool_get_status callback currently handles all status and PSE +information within a single function. This approach has two key +drawbacks: + +1. If the core requires some information for purposes other than + ethtool_get_status, redundant code will be needed to fetch the same + data from the driver (like is_enabled). + +2. Drivers currently have access to all information passed to ethtool. + New variables will soon be added to ethtool status, such as PSE ID, + power domain IDs, and budget evaluation strategies, which are meant + to be managed solely by the core. Drivers should not have the ability + to modify these variables. + +To resolve these issues, ethtool_get_status has been split into multiple +callbacks, with each handling a specific piece of information required +by ethtool or the core. + +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 153 ++++++++++++++++++++--------- + drivers/net/pse-pd/pse_core.c | 83 ++++++++++++++-- + drivers/net/pse-pd/pse_regulator.c | 26 +++-- + drivers/net/pse-pd/tps23881.c | 60 ++++++++--- + include/linux/pse-pd/pse.h | 87 +++++++++++++--- + net/ethtool/pse-pd.c | 8 +- + 6 files changed, 323 insertions(+), 94 deletions(-) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -517,21 +517,38 @@ pd692x0_pse_ext_state_map[] = { + { /* sentinel */ } + }; + +-static void +-pd692x0_get_ext_state(struct ethtool_c33_pse_ext_state_info *c33_ext_state_info, +- u32 status_code) ++static int ++pd692x0_pi_get_ext_state(struct pse_controller_dev *pcdev, int id, ++ struct pse_ext_state_info *ext_state_info) + { ++ struct ethtool_c33_pse_ext_state_info *c33_ext_state_info; + const struct pd692x0_pse_ext_state_mapping *ext_state_map; ++ struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); ++ struct pd692x0_msg msg, buf = {0}; ++ int ret; ++ ++ ret = pd692x0_fw_unavailable(priv); ++ if (ret) ++ return ret; + ++ msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_STATUS]; ++ msg.sub[2] = id; ++ ret = pd692x0_sendrecv_msg(priv, &msg, &buf); ++ if (ret < 0) ++ return ret; ++ ++ c33_ext_state_info = &ext_state_info->c33_ext_state_info; + ext_state_map = pd692x0_pse_ext_state_map; + while (ext_state_map->status_code) { +- if (ext_state_map->status_code == status_code) { ++ if (ext_state_map->status_code == buf.sub[0]) { + c33_ext_state_info->c33_pse_ext_state = ext_state_map->pse_ext_state; + c33_ext_state_info->__c33_pse_ext_substate = ext_state_map->pse_ext_substate; +- return; ++ return 0; + } + ext_state_map++; + } ++ ++ return 0; + } + + struct pd692x0_class_pw { +@@ -613,35 +630,36 @@ static int pd692x0_pi_set_pw_from_table( + } + + static int +-pd692x0_pi_get_pw_ranges(struct pse_control_status *st) ++pd692x0_pi_get_pw_limit_ranges(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_limit_ranges *pw_limit_ranges) + { ++ struct ethtool_c33_pse_pw_limit_range *c33_pw_limit_ranges; + const struct pd692x0_class_pw *pw_table; + int i; + + pw_table = pd692x0_class_pw_table; +- st->c33_pw_limit_ranges = kcalloc(PD692X0_CLASS_PW_TABLE_SIZE, +- sizeof(struct ethtool_c33_pse_pw_limit_range), +- GFP_KERNEL); +- if (!st->c33_pw_limit_ranges) ++ c33_pw_limit_ranges = kcalloc(PD692X0_CLASS_PW_TABLE_SIZE, ++ sizeof(*c33_pw_limit_ranges), ++ GFP_KERNEL); ++ if (!c33_pw_limit_ranges) + return -ENOMEM; + + for (i = 0; i < PD692X0_CLASS_PW_TABLE_SIZE; i++, pw_table++) { +- st->c33_pw_limit_ranges[i].min = pw_table->class_pw; +- st->c33_pw_limit_ranges[i].max = pw_table->class_pw + pw_table->max_added_class_pw; ++ c33_pw_limit_ranges[i].min = pw_table->class_pw; ++ c33_pw_limit_ranges[i].max = pw_table->class_pw + ++ pw_table->max_added_class_pw; + } + +- st->c33_pw_limit_nb_ranges = i; +- return 0; ++ pw_limit_ranges->c33_pw_limit_ranges = c33_pw_limit_ranges; ++ return i; + } + +-static int pd692x0_ethtool_get_status(struct pse_controller_dev *pcdev, +- unsigned long id, +- struct netlink_ext_ack *extack, +- struct pse_control_status *status) ++static int ++pd692x0_pi_get_admin_state(struct pse_controller_dev *pcdev, int id, ++ struct pse_admin_state *admin_state) + { + struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); + struct pd692x0_msg msg, buf = {0}; +- u32 class; + int ret; + + ret = pd692x0_fw_unavailable(priv); +@@ -654,39 +672,65 @@ static int pd692x0_ethtool_get_status(st + if (ret < 0) + return ret; + +- /* Compare Port Status (Communication Protocol Document par. 7.1) */ +- if ((buf.sub[0] & 0xf0) == 0x80 || (buf.sub[0] & 0xf0) == 0x90) +- status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING; +- else if (buf.sub[0] == 0x1b || buf.sub[0] == 0x22) +- status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING; +- else if (buf.sub[0] == 0x12) +- status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_FAULT; +- else +- status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED; +- + if (buf.sub[1]) +- status->c33_admin_state = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; + else +- status->c33_admin_state = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; + +- priv->admin_state[id] = status->c33_admin_state; ++ priv->admin_state[id] = admin_state->c33_admin_state; + +- pd692x0_get_ext_state(&status->c33_ext_state_info, buf.sub[0]); +- status->c33_actual_pw = (buf.data[0] << 4 | buf.data[1]) * 100; ++ return 0; ++} + +- msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_PARAM]; ++static int ++pd692x0_pi_get_pw_status(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_status *pw_status) ++{ ++ struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); ++ struct pd692x0_msg msg, buf = {0}; ++ int ret; ++ ++ ret = pd692x0_fw_unavailable(priv); ++ if (ret) ++ return ret; ++ ++ msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_STATUS]; + msg.sub[2] = id; +- memset(&buf, 0, sizeof(buf)); + ret = pd692x0_sendrecv_msg(priv, &msg, &buf); + if (ret < 0) + return ret; + +- ret = pd692x0_pi_get_pw_from_table(buf.data[0], buf.data[1]); +- if (ret < 0) ++ /* Compare Port Status (Communication Protocol Document par. 7.1) */ ++ if ((buf.sub[0] & 0xf0) == 0x80 || (buf.sub[0] & 0xf0) == 0x90) ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING; ++ else if (buf.sub[0] == 0x1b || buf.sub[0] == 0x22) ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING; ++ else if (buf.sub[0] == 0x12) ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_FAULT; ++ else ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED; ++ ++ return 0; ++} ++ ++static int ++pd692x0_pi_get_pw_class(struct pse_controller_dev *pcdev, int id) ++{ ++ struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); ++ struct pd692x0_msg msg, buf = {0}; ++ u32 class; ++ int ret; ++ ++ ret = pd692x0_fw_unavailable(priv); ++ if (ret) + return ret; +- status->c33_avail_pw_limit = ret; + +- memset(&buf, 0, sizeof(buf)); + msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_CLASS]; + msg.sub[2] = id; + ret = pd692x0_sendrecv_msg(priv, &msg, &buf); +@@ -695,13 +739,29 @@ static int pd692x0_ethtool_get_status(st + + class = buf.data[3] >> 4; + if (class <= 8) +- status->c33_pw_class = class; ++ return class; ++ ++ return 0; ++} ++ ++static int ++pd692x0_pi_get_actual_pw(struct pse_controller_dev *pcdev, int id) ++{ ++ struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); ++ struct pd692x0_msg msg, buf = {0}; ++ int ret; ++ ++ ret = pd692x0_fw_unavailable(priv); ++ if (ret) ++ return ret; + +- ret = pd692x0_pi_get_pw_ranges(status); ++ msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_STATUS]; ++ msg.sub[2] = id; ++ ret = pd692x0_sendrecv_msg(priv, &msg, &buf); + if (ret < 0) + return ret; + +- return 0; ++ return (buf.data[0] << 4 | buf.data[1]) * 100; + } + + static struct pd692x0_msg_ver pd692x0_get_sw_version(struct pd692x0_priv *priv) +@@ -1038,13 +1098,18 @@ static int pd692x0_pi_set_pw_limit(struc + + static const struct pse_controller_ops pd692x0_ops = { + .setup_pi_matrix = pd692x0_setup_pi_matrix, +- .ethtool_get_status = pd692x0_ethtool_get_status, ++ .pi_get_admin_state = pd692x0_pi_get_admin_state, ++ .pi_get_pw_status = pd692x0_pi_get_pw_status, ++ .pi_get_ext_state = pd692x0_pi_get_ext_state, ++ .pi_get_pw_class = pd692x0_pi_get_pw_class, ++ .pi_get_actual_pw = pd692x0_pi_get_actual_pw, + .pi_enable = pd692x0_pi_enable, + .pi_disable = pd692x0_pi_disable, + .pi_is_enabled = pd692x0_pi_is_enabled, + .pi_get_voltage = pd692x0_pi_get_voltage, + .pi_get_pw_limit = pd692x0_pi_get_pw_limit, + .pi_set_pw_limit = pd692x0_pi_set_pw_limit, ++ .pi_get_pw_limit_ranges = pd692x0_pi_get_pw_limit_ranges, + }; + + #define PD692X0_FW_LINE_MAX_SZ 0xff +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -443,6 +443,13 @@ int pse_controller_register(struct pse_c + if (!pcdev->nr_lines) + pcdev->nr_lines = 1; + ++ if (!pcdev->ops->pi_get_admin_state || ++ !pcdev->ops->pi_get_pw_status) { ++ dev_err(pcdev->dev, ++ "Mandatory status report callbacks are missing"); ++ return -EINVAL; ++ } ++ + ret = of_load_pse_pis(pcdev); + if (ret) + return ret; +@@ -745,25 +752,81 @@ EXPORT_SYMBOL_GPL(of_pse_control_get); + */ + int pse_ethtool_get_status(struct pse_control *psec, + struct netlink_ext_ack *extack, +- struct pse_control_status *status) ++ struct ethtool_pse_control_status *status) + { ++ struct pse_admin_state admin_state = {0}; ++ struct pse_pw_status pw_status = {0}; + const struct pse_controller_ops *ops; + struct pse_controller_dev *pcdev; +- int err; ++ int ret; + + pcdev = psec->pcdev; + ops = pcdev->ops; +- if (!ops->ethtool_get_status) { +- NL_SET_ERR_MSG(extack, +- "PSE driver does not support status report"); +- return -EOPNOTSUPP; ++ mutex_lock(&pcdev->lock); ++ ret = ops->pi_get_admin_state(pcdev, psec->id, &admin_state); ++ if (ret) ++ goto out; ++ status->podl_admin_state = admin_state.podl_admin_state; ++ status->c33_admin_state = admin_state.c33_admin_state; ++ ++ ret = ops->pi_get_pw_status(pcdev, psec->id, &pw_status); ++ if (ret) ++ goto out; ++ status->podl_pw_status = pw_status.podl_pw_status; ++ status->c33_pw_status = pw_status.c33_pw_status; ++ ++ if (ops->pi_get_ext_state) { ++ struct pse_ext_state_info ext_state_info = {0}; ++ ++ ret = ops->pi_get_ext_state(pcdev, psec->id, ++ &ext_state_info); ++ if (ret) ++ goto out; ++ ++ memcpy(&status->c33_ext_state_info, ++ &ext_state_info.c33_ext_state_info, ++ sizeof(status->c33_ext_state_info)); + } + +- mutex_lock(&pcdev->lock); +- err = ops->ethtool_get_status(pcdev, psec->id, extack, status); +- mutex_unlock(&pcdev->lock); ++ if (ops->pi_get_pw_class) { ++ ret = ops->pi_get_pw_class(pcdev, psec->id); ++ if (ret < 0) ++ goto out; ++ ++ status->c33_pw_class = ret; ++ } ++ ++ if (ops->pi_get_actual_pw) { ++ ret = ops->pi_get_actual_pw(pcdev, psec->id); ++ if (ret < 0) ++ goto out; ++ ++ status->c33_actual_pw = ret; ++ } ++ ++ if (ops->pi_get_pw_limit) { ++ ret = ops->pi_get_pw_limit(pcdev, psec->id); ++ if (ret < 0) ++ goto out; ++ ++ status->c33_avail_pw_limit = ret; ++ } ++ ++ if (ops->pi_get_pw_limit_ranges) { ++ struct pse_pw_limit_ranges pw_limit_ranges = {0}; + +- return err; ++ ret = ops->pi_get_pw_limit_ranges(pcdev, psec->id, ++ &pw_limit_ranges); ++ if (ret < 0) ++ goto out; ++ ++ status->c33_pw_limit_ranges = ++ pw_limit_ranges.c33_pw_limit_ranges; ++ status->c33_pw_limit_nb_ranges = ret; ++ } ++out: ++ mutex_unlock(&psec->pcdev->lock); ++ return ret; + } + EXPORT_SYMBOL_GPL(pse_ethtool_get_status); + +--- a/drivers/net/pse-pd/pse_regulator.c ++++ b/drivers/net/pse-pd/pse_regulator.c +@@ -60,9 +60,19 @@ pse_reg_pi_is_enabled(struct pse_control + } + + static int +-pse_reg_ethtool_get_status(struct pse_controller_dev *pcdev, unsigned long id, +- struct netlink_ext_ack *extack, +- struct pse_control_status *status) ++pse_reg_pi_get_admin_state(struct pse_controller_dev *pcdev, int id, ++ struct pse_admin_state *admin_state) ++{ ++ struct pse_reg_priv *priv = to_pse_reg(pcdev); ++ ++ admin_state->podl_admin_state = priv->admin_state; ++ ++ return 0; ++} ++ ++static int ++pse_reg_pi_get_pw_status(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_status *pw_status) + { + struct pse_reg_priv *priv = to_pse_reg(pcdev); + int ret; +@@ -72,18 +82,18 @@ pse_reg_ethtool_get_status(struct pse_co + return ret; + + if (!ret) +- status->podl_pw_status = ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED; ++ pw_status->podl_pw_status = ++ ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED; + else +- status->podl_pw_status = ++ pw_status->podl_pw_status = + ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING; + +- status->podl_admin_state = priv->admin_state; +- + return 0; + } + + static const struct pse_controller_ops pse_reg_ops = { +- .ethtool_get_status = pse_reg_ethtool_get_status, ++ .pi_get_admin_state = pse_reg_pi_get_admin_state, ++ .pi_get_pw_status = pse_reg_pi_get_pw_status, + .pi_enable = pse_reg_pi_enable, + .pi_is_enabled = pse_reg_pi_is_enabled, + .pi_disable = pse_reg_pi_disable, +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -201,14 +201,13 @@ static int tps23881_pi_is_enabled(struct + return enabled; + } + +-static int tps23881_ethtool_get_status(struct pse_controller_dev *pcdev, +- unsigned long id, +- struct netlink_ext_ack *extack, +- struct pse_control_status *status) ++static int ++tps23881_pi_get_admin_state(struct pse_controller_dev *pcdev, int id, ++ struct pse_admin_state *admin_state) + { + struct tps23881_priv *priv = to_tps23881_priv(pcdev); + struct i2c_client *client = priv->client; +- bool enabled, delivering; ++ bool enabled; + u8 chan; + u16 val; + int ret; +@@ -220,28 +219,56 @@ static int tps23881_ethtool_get_status(s + chan = priv->port[id].chan[0]; + val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); + enabled = !!(val); +- val = tps23881_calc_val(ret, chan, 4, BIT(chan % 4)); +- delivering = !!(val); + + if (priv->port[id].is_4p) { + chan = priv->port[id].chan[1]; + val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); + enabled &= !!(val); ++ } ++ ++ /* Return enabled status only if both channel are on this state */ ++ if (enabled) ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; ++ else ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; ++ ++ return 0; ++} ++ ++static int ++tps23881_pi_get_pw_status(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_status *pw_status) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ struct i2c_client *client = priv->client; ++ bool delivering; ++ u8 chan; ++ u16 val; ++ int ret; ++ ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS); ++ if (ret < 0) ++ return ret; ++ ++ chan = priv->port[id].chan[0]; ++ val = tps23881_calc_val(ret, chan, 4, BIT(chan % 4)); ++ delivering = !!(val); ++ ++ if (priv->port[id].is_4p) { ++ chan = priv->port[id].chan[1]; + val = tps23881_calc_val(ret, chan, 4, BIT(chan % 4)); + delivering &= !!(val); + } + + /* Return delivering status only if both channel are on this state */ + if (delivering) +- status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING; +- else +- status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED; +- +- /* Return enabled status only if both channel are on this state */ +- if (enabled) +- status->c33_admin_state = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING; + else +- status->c33_admin_state = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED; + + return 0; + } +@@ -664,7 +691,8 @@ static const struct pse_controller_ops t + .pi_enable = tps23881_pi_enable, + .pi_disable = tps23881_pi_disable, + .pi_is_enabled = tps23881_pi_is_enabled, +- .ethtool_get_status = tps23881_ethtool_get_status, ++ .pi_get_admin_state = tps23881_pi_get_admin_state, ++ .pi_get_pw_status = tps23881_pi_get_pw_status, + }; + + static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin"; +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -31,7 +31,52 @@ struct pse_control_config { + }; + + /** +- * struct pse_control_status - PSE control/channel status. ++ * struct pse_admin_state - PSE operational state ++ * ++ * @podl_admin_state: operational state of the PoDL PSE ++ * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState ++ * @c33_admin_state: operational state of the PSE ++ * functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState ++ */ ++struct pse_admin_state { ++ enum ethtool_podl_pse_admin_state podl_admin_state; ++ enum ethtool_c33_pse_admin_state c33_admin_state; ++}; ++ ++/** ++ * struct pse_pw_status - PSE power detection status ++ * ++ * @podl_pw_status: power detection status of the PoDL PSE. ++ * IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus: ++ * @c33_pw_status: power detection status of the PSE. ++ * IEEE 802.3-2022 30.9.1.1.5 aPSEPowerDetectionStatus: ++ */ ++struct pse_pw_status { ++ enum ethtool_podl_pse_pw_d_status podl_pw_status; ++ enum ethtool_c33_pse_pw_d_status c33_pw_status; ++}; ++ ++/** ++ * struct pse_ext_state_info - PSE extended state information ++ * ++ * @c33_ext_state_info: extended state information of the PSE ++ */ ++struct pse_ext_state_info { ++ struct ethtool_c33_pse_ext_state_info c33_ext_state_info; ++}; ++ ++/** ++ * struct pse_pw_limit_ranges - PSE power limit configuration range ++ * ++ * @c33_pw_limit_ranges: supported power limit configuration range. The driver ++ * is in charge of the memory allocation. ++ */ ++struct pse_pw_limit_ranges { ++ struct ethtool_c33_pse_pw_limit_range *c33_pw_limit_ranges; ++}; ++ ++/** ++ * struct ethtool_pse_control_status - PSE control/channel status. + * + * @podl_admin_state: operational state of the PoDL PSE + * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState +@@ -49,11 +94,11 @@ struct pse_control_config { + * @c33_avail_pw_limit: available power limit of the PSE in mW + * IEEE 802.3-2022 145.2.5.4 pse_avail_pwr + * @c33_pw_limit_ranges: supported power limit configuration range. The driver +- * is in charge of the memory allocation. ++ * is in charge of the memory allocation + * @c33_pw_limit_nb_ranges: number of supported power limit configuration + * ranges + */ +-struct pse_control_status { ++struct ethtool_pse_control_status { + enum ethtool_podl_pse_admin_state podl_admin_state; + enum ethtool_podl_pse_pw_d_status podl_pw_status; + enum ethtool_c33_pse_admin_state c33_admin_state; +@@ -69,22 +114,37 @@ struct pse_control_status { + /** + * struct pse_controller_ops - PSE controller driver callbacks + * +- * @ethtool_get_status: get PSE control status for ethtool interface + * @setup_pi_matrix: setup PI matrix of the PSE controller ++ * @pi_get_admin_state: Get the operational state of the PSE PI. This ops ++ * is mandatory. ++ * @pi_get_pw_status: Get the power detection status of the PSE PI. This ++ * ops is mandatory. ++ * @pi_get_ext_state: Get the extended state of the PSE PI. ++ * @pi_get_pw_class: Get the power class of the PSE PI. ++ * @pi_get_actual_pw: Get actual power of the PSE PI in mW. + * @pi_is_enabled: Return 1 if the PSE PI is enabled, 0 if not. + * May also return negative errno. + * @pi_enable: Configure the PSE PI as enabled. + * @pi_disable: Configure the PSE PI as disabled. + * @pi_get_voltage: Return voltage similarly to get_voltage regulator +- * callback. +- * @pi_get_pw_limit: Get the configured power limit of the PSE PI. +- * @pi_set_pw_limit: Configure the power limit of the PSE PI. ++ * callback in uV. ++ * @pi_get_pw_limit: Get the configured power limit of the PSE PI in mW. ++ * @pi_set_pw_limit: Configure the power limit of the PSE PI in mW. ++ * @pi_get_pw_limit_ranges: Get the supported power limit configuration ++ * range. The driver is in charge of the memory ++ * allocation and should return the number of ++ * ranges. + */ + struct pse_controller_ops { +- int (*ethtool_get_status)(struct pse_controller_dev *pcdev, +- unsigned long id, struct netlink_ext_ack *extack, +- struct pse_control_status *status); + int (*setup_pi_matrix)(struct pse_controller_dev *pcdev); ++ int (*pi_get_admin_state)(struct pse_controller_dev *pcdev, int id, ++ struct pse_admin_state *admin_state); ++ int (*pi_get_pw_status)(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_status *pw_status); ++ int (*pi_get_ext_state)(struct pse_controller_dev *pcdev, int id, ++ struct pse_ext_state_info *ext_state_info); ++ int (*pi_get_pw_class)(struct pse_controller_dev *pcdev, int id); ++ int (*pi_get_actual_pw)(struct pse_controller_dev *pcdev, int id); + int (*pi_is_enabled)(struct pse_controller_dev *pcdev, int id); + int (*pi_enable)(struct pse_controller_dev *pcdev, int id); + int (*pi_disable)(struct pse_controller_dev *pcdev, int id); +@@ -93,12 +153,15 @@ struct pse_controller_ops { + int id); + int (*pi_set_pw_limit)(struct pse_controller_dev *pcdev, + int id, int max_mW); ++ int (*pi_get_pw_limit_ranges)(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_limit_ranges *pw_limit_ranges); + }; + + struct module; + struct device_node; + struct of_phandle_args; + struct pse_control; ++struct ethtool_pse_control_status; + + /* PSE PI pairset pinout can either be Alternative A or Alternative B */ + enum pse_pi_pairset_pinout { +@@ -175,7 +238,7 @@ void pse_control_put(struct pse_control + + int pse_ethtool_get_status(struct pse_control *psec, + struct netlink_ext_ack *extack, +- struct pse_control_status *status); ++ struct ethtool_pse_control_status *status); + int pse_ethtool_set_config(struct pse_control *psec, + struct netlink_ext_ack *extack, + const struct pse_control_config *config); +@@ -201,7 +264,7 @@ static inline void pse_control_put(struc + + static inline int pse_ethtool_get_status(struct pse_control *psec, + struct netlink_ext_ack *extack, +- struct pse_control_status *status) ++ struct ethtool_pse_control_status *status) + { + return -EOPNOTSUPP; + } +--- a/net/ethtool/pse-pd.c ++++ b/net/ethtool/pse-pd.c +@@ -19,7 +19,7 @@ struct pse_req_info { + + struct pse_reply_data { + struct ethnl_reply_data base; +- struct pse_control_status status; ++ struct ethtool_pse_control_status status; + }; + + #define PSE_REPDATA(__reply_base) \ +@@ -80,7 +80,7 @@ static int pse_reply_size(const struct e + const struct ethnl_reply_data *reply_base) + { + const struct pse_reply_data *data = PSE_REPDATA(reply_base); +- const struct pse_control_status *st = &data->status; ++ const struct ethtool_pse_control_status *st = &data->status; + int len = 0; + + if (st->podl_admin_state > 0) +@@ -114,7 +114,7 @@ static int pse_reply_size(const struct e + } + + static int pse_put_pw_limit_ranges(struct sk_buff *skb, +- const struct pse_control_status *st) ++ const struct ethtool_pse_control_status *st) + { + const struct ethtool_c33_pse_pw_limit_range *pw_limit_ranges; + int i; +@@ -146,7 +146,7 @@ static int pse_fill_reply(struct sk_buff + const struct ethnl_reply_data *reply_base) + { + const struct pse_reply_data *data = PSE_REPDATA(reply_base); +- const struct pse_control_status *st = &data->status; ++ const struct ethtool_pse_control_status *st = &data->status; + + if (st->podl_admin_state > 0 && + nla_put_u32(skb, ETHTOOL_A_PODL_PSE_ADMIN_STATE, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-06-v6.13-net-pse-pd-Remove-is_enabled-callback-from-drivers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-06-v6.13-net-pse-pd-Remove-is_enabled-callback-from-drivers.patch new file mode 100755 index 0000000..dd7a20e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-06-v6.13-net-pse-pd-Remove-is_enabled-callback-from-drivers.patch @@ -0,0 +1,184 @@ +From 4640a1f0d8f2246f34d6e74330d7e7d2cf75605b Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:28 +0100 +Subject: [PATCH] net: pse-pd: Remove is_enabled callback from drivers + +The is_enabled callback is now redundant as the admin_state can be obtained +directly from the driver and provides the same information. + +To simplify functionality, the core will handle this internally, making +the is_enabled callback unnecessary at the driver level. Remove the +callback from all drivers. + +Acked-by: Oleksij Rempel +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 26 -------------------------- + drivers/net/pse-pd/pse_core.c | 13 +++++++++++-- + drivers/net/pse-pd/pse_regulator.c | 9 --------- + drivers/net/pse-pd/tps23881.c | 28 ---------------------------- + include/linux/pse-pd/pse.h | 3 --- + 5 files changed, 11 insertions(+), 68 deletions(-) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -431,31 +431,6 @@ static int pd692x0_pi_disable(struct pse + return 0; + } + +-static int pd692x0_pi_is_enabled(struct pse_controller_dev *pcdev, int id) +-{ +- struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); +- struct pd692x0_msg msg, buf = {0}; +- int ret; +- +- ret = pd692x0_fw_unavailable(priv); +- if (ret) +- return ret; +- +- msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_STATUS]; +- msg.sub[2] = id; +- ret = pd692x0_sendrecv_msg(priv, &msg, &buf); +- if (ret < 0) +- return ret; +- +- if (buf.sub[1]) { +- priv->admin_state[id] = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; +- return 1; +- } else { +- priv->admin_state[id] = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; +- return 0; +- } +-} +- + struct pd692x0_pse_ext_state_mapping { + u32 status_code; + enum ethtool_c33_pse_ext_state pse_ext_state; +@@ -1105,7 +1080,6 @@ static const struct pse_controller_ops p + .pi_get_actual_pw = pd692x0_pi_get_actual_pw, + .pi_enable = pd692x0_pi_enable, + .pi_disable = pd692x0_pi_disable, +- .pi_is_enabled = pd692x0_pi_is_enabled, + .pi_get_voltage = pd692x0_pi_get_voltage, + .pi_get_pw_limit = pd692x0_pi_get_pw_limit, + .pi_set_pw_limit = pd692x0_pi_set_pw_limit, +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -210,16 +210,25 @@ out: + static int pse_pi_is_enabled(struct regulator_dev *rdev) + { + struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev); ++ struct pse_admin_state admin_state = {0}; + const struct pse_controller_ops *ops; + int id, ret; + + ops = pcdev->ops; +- if (!ops->pi_is_enabled) ++ if (!ops->pi_get_admin_state) + return -EOPNOTSUPP; + + id = rdev_get_id(rdev); + mutex_lock(&pcdev->lock); +- ret = ops->pi_is_enabled(pcdev, id); ++ ret = ops->pi_get_admin_state(pcdev, id, &admin_state); ++ if (ret) ++ goto out; ++ ++ if (admin_state.podl_admin_state == ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED || ++ admin_state.c33_admin_state == ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED) ++ ret = 1; ++ ++out: + mutex_unlock(&pcdev->lock); + + return ret; +--- a/drivers/net/pse-pd/pse_regulator.c ++++ b/drivers/net/pse-pd/pse_regulator.c +@@ -52,14 +52,6 @@ pse_reg_pi_disable(struct pse_controller + } + + static int +-pse_reg_pi_is_enabled(struct pse_controller_dev *pcdev, int id) +-{ +- struct pse_reg_priv *priv = to_pse_reg(pcdev); +- +- return regulator_is_enabled(priv->ps); +-} +- +-static int + pse_reg_pi_get_admin_state(struct pse_controller_dev *pcdev, int id, + struct pse_admin_state *admin_state) + { +@@ -95,7 +87,6 @@ static const struct pse_controller_ops p + .pi_get_admin_state = pse_reg_pi_get_admin_state, + .pi_get_pw_status = pse_reg_pi_get_pw_status, + .pi_enable = pse_reg_pi_enable, +- .pi_is_enabled = pse_reg_pi_is_enabled, + .pi_disable = pse_reg_pi_disable, + }; + +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -174,33 +174,6 @@ static int tps23881_pi_disable(struct ps + return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val); + } + +-static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id) +-{ +- struct tps23881_priv *priv = to_tps23881_priv(pcdev); +- struct i2c_client *client = priv->client; +- bool enabled; +- u8 chan; +- u16 val; +- int ret; +- +- ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS); +- if (ret < 0) +- return ret; +- +- chan = priv->port[id].chan[0]; +- val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); +- enabled = !!(val); +- +- if (priv->port[id].is_4p) { +- chan = priv->port[id].chan[1]; +- val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4)); +- enabled &= !!(val); +- } +- +- /* Return enabled status only if both channel are on this state */ +- return enabled; +-} +- + static int + tps23881_pi_get_admin_state(struct pse_controller_dev *pcdev, int id, + struct pse_admin_state *admin_state) +@@ -690,7 +663,6 @@ static const struct pse_controller_ops t + .setup_pi_matrix = tps23881_setup_pi_matrix, + .pi_enable = tps23881_pi_enable, + .pi_disable = tps23881_pi_disable, +- .pi_is_enabled = tps23881_pi_is_enabled, + .pi_get_admin_state = tps23881_pi_get_admin_state, + .pi_get_pw_status = tps23881_pi_get_pw_status, + }; +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -122,8 +122,6 @@ struct ethtool_pse_control_status { + * @pi_get_ext_state: Get the extended state of the PSE PI. + * @pi_get_pw_class: Get the power class of the PSE PI. + * @pi_get_actual_pw: Get actual power of the PSE PI in mW. +- * @pi_is_enabled: Return 1 if the PSE PI is enabled, 0 if not. +- * May also return negative errno. + * @pi_enable: Configure the PSE PI as enabled. + * @pi_disable: Configure the PSE PI as disabled. + * @pi_get_voltage: Return voltage similarly to get_voltage regulator +@@ -145,7 +143,6 @@ struct pse_controller_ops { + struct pse_ext_state_info *ext_state_info); + int (*pi_get_pw_class)(struct pse_controller_dev *pcdev, int id); + int (*pi_get_actual_pw)(struct pse_controller_dev *pcdev, int id); +- int (*pi_is_enabled)(struct pse_controller_dev *pcdev, int id); + int (*pi_enable)(struct pse_controller_dev *pcdev, int id); + int (*pi_disable)(struct pse_controller_dev *pcdev, int id); + int (*pi_get_voltage)(struct pse_controller_dev *pcdev, int id); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-07-v6.13-net-pse-pd-tps23881-Add-power-limit-and-measurement-features.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-07-v6.13-net-pse-pd-tps23881-Add-power-limit-and-measurement-features.patch new file mode 100755 index 0000000..de3cc76 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-07-v6.13-net-pse-pd-tps23881-Add-power-limit-and-measurement-features.patch @@ -0,0 +1,337 @@ +From 7f076ce3f17334964590c2cce49a02c0851c099a Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:29 +0100 +Subject: [PATCH] net: pse-pd: tps23881: Add support for power limit and + measurement features + +Expand PSE callbacks to support the newly introduced +pi_get/set_pw_limit() and pi_get_voltage() functions. These callbacks +allow for power limit configuration in the TPS23881 controller. + +Additionally, the patch includes the pi_get_pw_class() the +pi_get_actual_pw(), and the pi_get_pw_limit_ranges') callbacks providing +more comprehensive PoE status reporting. + +Acked-by: Oleksij Rempel +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 258 +++++++++++++++++++++++++++++++++- + 1 file changed, 256 insertions(+), 2 deletions(-) + +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -25,20 +25,32 @@ + #define TPS23881_REG_GEN_MASK 0x17 + #define TPS23881_REG_NBITACC BIT(5) + #define TPS23881_REG_PW_EN 0x19 ++#define TPS23881_REG_2PAIR_POL1 0x1e + #define TPS23881_REG_PORT_MAP 0x26 + #define TPS23881_REG_PORT_POWER 0x29 +-#define TPS23881_REG_POEPLUS 0x40 ++#define TPS23881_REG_4PAIR_POL1 0x2a ++#define TPS23881_REG_INPUT_V 0x2e ++#define TPS23881_REG_CHAN1_A 0x30 ++#define TPS23881_REG_CHAN1_V 0x32 ++#define TPS23881_REG_FOLDBACK 0x40 + #define TPS23881_REG_TPON BIT(0) + #define TPS23881_REG_FWREV 0x41 + #define TPS23881_REG_DEVID 0x43 + #define TPS23881_REG_DEVID_MASK 0xF0 + #define TPS23881_DEVICE_ID 0x02 ++#define TPS23881_REG_CHAN1_CLASS 0x4c + #define TPS23881_REG_SRAM_CTRL 0x60 + #define TPS23881_REG_SRAM_DATA 0x61 + ++#define TPS23881_UV_STEP 3662 ++#define TPS23881_NA_STEP 70190 ++#define TPS23881_MW_STEP 500 ++#define TPS23881_MIN_PI_PW_LIMIT_MW 2000 ++ + struct tps23881_port_desc { + u8 chan[2]; + bool is_4p; ++ int pw_pol; + }; + + struct tps23881_priv { +@@ -102,6 +114,54 @@ static u16 tps23881_set_val(u16 reg_val, + return reg_val; + } + ++static int ++tps23881_pi_set_pw_pol_limit(struct tps23881_priv *priv, int id, u8 pw_pol, ++ bool is_4p) ++{ ++ struct i2c_client *client = priv->client; ++ int ret, reg; ++ u16 val; ++ u8 chan; ++ ++ chan = priv->port[id].chan[0]; ++ if (!is_4p) { ++ reg = TPS23881_REG_2PAIR_POL1 + (chan % 4); ++ } else { ++ /* One chan is enough to configure the 4p PI power limit */ ++ if ((chan % 4) < 2) ++ reg = TPS23881_REG_4PAIR_POL1; ++ else ++ reg = TPS23881_REG_4PAIR_POL1 + 1; ++ } ++ ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_set_val(ret, chan, 0, 0xff, pw_pol); ++ return i2c_smbus_write_word_data(client, reg, val); ++} ++ ++static int tps23881_pi_enable_manual_pol(struct tps23881_priv *priv, int id) ++{ ++ struct i2c_client *client = priv->client; ++ int ret; ++ u8 chan; ++ u16 val; ++ ++ ret = i2c_smbus_read_byte_data(client, TPS23881_REG_FOLDBACK); ++ if (ret < 0) ++ return ret; ++ ++ /* No need to test if the chan is PoE4 as setting either bit for a ++ * 4P configured port disables the automatic configuration on both ++ * channels. ++ */ ++ chan = priv->port[id].chan[0]; ++ val = tps23881_set_val(ret, chan, 0, BIT(chan % 4), BIT(chan % 4)); ++ return i2c_smbus_write_byte_data(client, TPS23881_REG_FOLDBACK, val); ++} ++ + static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id) + { + struct tps23881_priv *priv = to_tps23881_priv(pcdev); +@@ -171,7 +231,21 @@ static int tps23881_pi_disable(struct ps + BIT(chan % 4)); + } + +- return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val); ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val); ++ if (ret) ++ return ret; ++ ++ /* No power policy */ ++ if (priv->port[id].pw_pol < 0) ++ return 0; ++ ++ ret = tps23881_pi_enable_manual_pol(priv, id); ++ if (ret < 0) ++ return ret; ++ ++ /* Set power policy */ ++ return tps23881_pi_set_pw_pol_limit(priv, id, priv->port[id].pw_pol, ++ priv->port[id].is_4p); + } + + static int +@@ -246,6 +320,177 @@ tps23881_pi_get_pw_status(struct pse_con + return 0; + } + ++static int tps23881_pi_get_voltage(struct pse_controller_dev *pcdev, int id) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ struct i2c_client *client = priv->client; ++ int ret; ++ u64 uV; ++ ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_INPUT_V); ++ if (ret < 0) ++ return ret; ++ ++ uV = ret & 0x3fff; ++ uV *= TPS23881_UV_STEP; ++ ++ return (int)uV; ++} ++ ++static int ++tps23881_pi_get_chan_current(struct tps23881_priv *priv, u8 chan) ++{ ++ struct i2c_client *client = priv->client; ++ int reg, ret; ++ u64 tmp_64; ++ ++ /* Registers 0x30 to 0x3d */ ++ reg = TPS23881_REG_CHAN1_A + (chan % 4) * 4 + (chan >= 4); ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ tmp_64 = ret & 0x3fff; ++ tmp_64 *= TPS23881_NA_STEP; ++ /* uA = nA / 1000 */ ++ tmp_64 = DIV_ROUND_CLOSEST_ULL(tmp_64, 1000); ++ return (int)tmp_64; ++} ++ ++static int tps23881_pi_get_pw_class(struct pse_controller_dev *pcdev, ++ int id) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ struct i2c_client *client = priv->client; ++ int ret, reg; ++ u8 chan; ++ ++ chan = priv->port[id].chan[0]; ++ reg = TPS23881_REG_CHAN1_CLASS + (chan % 4); ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ return tps23881_calc_val(ret, chan, 4, 0x0f); ++} ++ ++static int ++tps23881_pi_get_actual_pw(struct pse_controller_dev *pcdev, int id) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ int ret, uV, uA; ++ u64 tmp_64; ++ u8 chan; ++ ++ ret = tps23881_pi_get_voltage(&priv->pcdev, id); ++ if (ret < 0) ++ return ret; ++ uV = ret; ++ ++ chan = priv->port[id].chan[0]; ++ ret = tps23881_pi_get_chan_current(priv, chan); ++ if (ret < 0) ++ return ret; ++ uA = ret; ++ ++ if (priv->port[id].is_4p) { ++ chan = priv->port[id].chan[1]; ++ ret = tps23881_pi_get_chan_current(priv, chan); ++ if (ret < 0) ++ return ret; ++ uA += ret; ++ } ++ ++ tmp_64 = uV; ++ tmp_64 *= uA; ++ /* mW = uV * uA / 1000000000 */ ++ return DIV_ROUND_CLOSEST_ULL(tmp_64, 1000000000); ++} ++ ++static int ++tps23881_pi_get_pw_limit_chan(struct tps23881_priv *priv, u8 chan) ++{ ++ struct i2c_client *client = priv->client; ++ int ret, reg; ++ u16 val; ++ ++ reg = TPS23881_REG_2PAIR_POL1 + (chan % 4); ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_calc_val(ret, chan, 0, 0xff); ++ return val * TPS23881_MW_STEP; ++} ++ ++static int tps23881_pi_get_pw_limit(struct pse_controller_dev *pcdev, int id) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ int ret, mW; ++ u8 chan; ++ ++ chan = priv->port[id].chan[0]; ++ ret = tps23881_pi_get_pw_limit_chan(priv, chan); ++ if (ret < 0) ++ return ret; ++ ++ mW = ret; ++ if (priv->port[id].is_4p) { ++ chan = priv->port[id].chan[1]; ++ ret = tps23881_pi_get_pw_limit_chan(priv, chan); ++ if (ret < 0) ++ return ret; ++ mW += ret; ++ } ++ ++ return mW; ++} ++ ++static int tps23881_pi_set_pw_limit(struct pse_controller_dev *pcdev, ++ int id, int max_mW) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ u8 pw_pol; ++ int ret; ++ ++ if (max_mW < TPS23881_MIN_PI_PW_LIMIT_MW || MAX_PI_PW < max_mW) { ++ dev_err(&priv->client->dev, ++ "power limit %d out of ranges [%d,%d]", ++ max_mW, TPS23881_MIN_PI_PW_LIMIT_MW, MAX_PI_PW); ++ return -ERANGE; ++ } ++ ++ ret = tps23881_pi_enable_manual_pol(priv, id); ++ if (ret < 0) ++ return ret; ++ ++ pw_pol = DIV_ROUND_CLOSEST_ULL(max_mW, TPS23881_MW_STEP); ++ ++ /* Save power policy to reconfigure it after a disabled call */ ++ priv->port[id].pw_pol = pw_pol; ++ return tps23881_pi_set_pw_pol_limit(priv, id, pw_pol, ++ priv->port[id].is_4p); ++} ++ ++static int ++tps23881_pi_get_pw_limit_ranges(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_limit_ranges *pw_limit_ranges) ++{ ++ struct ethtool_c33_pse_pw_limit_range *c33_pw_limit_ranges; ++ ++ c33_pw_limit_ranges = kzalloc(sizeof(*c33_pw_limit_ranges), ++ GFP_KERNEL); ++ if (!c33_pw_limit_ranges) ++ return -ENOMEM; ++ ++ c33_pw_limit_ranges->min = TPS23881_MIN_PI_PW_LIMIT_MW; ++ c33_pw_limit_ranges->max = MAX_PI_PW; ++ pw_limit_ranges->c33_pw_limit_ranges = c33_pw_limit_ranges; ++ ++ /* Return the number of ranges */ ++ return 1; ++} ++ + /* Parse managers subnode into a array of device node */ + static int + tps23881_get_of_channels(struct tps23881_priv *priv, +@@ -540,6 +785,9 @@ tps23881_write_port_matrix(struct tps238 + if (port_matrix[i].exist) + priv->port[pi_id].chan[0] = lgcl_chan; + ++ /* Initialize power policy internal value */ ++ priv->port[pi_id].pw_pol = -1; ++ + /* Set hardware port matrix for all ports */ + val |= hw_chan << (lgcl_chan * 2); + +@@ -665,6 +913,12 @@ static const struct pse_controller_ops t + .pi_disable = tps23881_pi_disable, + .pi_get_admin_state = tps23881_pi_get_admin_state, + .pi_get_pw_status = tps23881_pi_get_pw_status, ++ .pi_get_pw_class = tps23881_pi_get_pw_class, ++ .pi_get_actual_pw = tps23881_pi_get_actual_pw, ++ .pi_get_voltage = tps23881_pi_get_voltage, ++ .pi_get_pw_limit = tps23881_pi_get_pw_limit, ++ .pi_set_pw_limit = tps23881_pi_set_pw_limit, ++ .pi_get_pw_limit_ranges = tps23881_pi_get_pw_limit_ranges, + }; + + static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin"; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-08-v6.13-net-pse-pd-Fix-missing-PI-of_node-description.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-08-v6.13-net-pse-pd-Fix-missing-PI-of_node-description.patch new file mode 100755 index 0000000..3aa46cd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-08-v6.13-net-pse-pd-Fix-missing-PI-of_node-description.patch @@ -0,0 +1,28 @@ +From 10276f3e1c7e7f5de9f0bba58f8a849cb195253d Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:30 +0100 +Subject: [PATCH] net: pse-pd: Fix missing PI of_node description + +The PI of_node was not assigned in the regulator_config structure, leading +to failures in resolving the correct supply when different power supplies +are assigned to multiple PIs of a PSE controller. This fix ensures that the +of_node is properly set in the regulator_config, allowing accurate supply +resolution for each PI. + +Acked-by: Oleksij Rempel +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pse_core.c | 1 + + 1 file changed, 1 insertion(+) +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -422,6 +422,7 @@ devm_pse_pi_regulator_register(struct ps + rconfig.dev = pcdev->dev; + rconfig.driver_data = pcdev; + rconfig.init_data = rinit_data; ++ rconfig.of_node = pcdev->pi[id].np; + + rdev = devm_regulator_register(pcdev->dev, rdesc, &rconfig); + if (IS_ERR(rdev)) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-09-v6.13-net-pse-pd-Clean-ethtool-header-of-PSE-structures.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-09-v6.13-net-pse-pd-Clean-ethtool-header-of-PSE-structures.patch new file mode 100755 index 0000000..7d33812 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-09-v6.13-net-pse-pd-Clean-ethtool-header-of-PSE-structures.patch @@ -0,0 +1,92 @@ +From 5385f1e1923ca8131eb143567d509b101a344e06 Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Fri, 10 Jan 2025 10:40:31 +0100 +Subject: [PATCH] net: pse-pd: Clean ethtool header of PSE structures + +Remove PSE-specific structures from the ethtool header to improve code +modularity, maintain independent headers, and reduce incremental build +time. + +Signed-off-by: Kory Maincent +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pse_core.c | 1 + + include/linux/ethtool.h | 20 -------------------- + include/linux/pse-pd/pse.h | 22 +++++++++++++++++++++- + 3 files changed, 22 insertions(+), 21 deletions(-) +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -6,6 +6,7 @@ + // + + #include ++#include + #include + #include + #include +--- a/include/linux/ethtool.h ++++ b/include/linux/ethtool.h +@@ -1322,24 +1322,4 @@ struct ethtool_forced_speed_map { + + void + ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size); +- +-/* C33 PSE extended state and substate. */ +-struct ethtool_c33_pse_ext_state_info { +- enum ethtool_c33_pse_ext_state c33_pse_ext_state; +- union { +- enum ethtool_c33_pse_ext_substate_error_condition error_condition; +- enum ethtool_c33_pse_ext_substate_mr_pse_enable mr_pse_enable; +- enum ethtool_c33_pse_ext_substate_option_detect_ted option_detect_ted; +- enum ethtool_c33_pse_ext_substate_option_vport_lim option_vport_lim; +- enum ethtool_c33_pse_ext_substate_ovld_detected ovld_detected; +- enum ethtool_c33_pse_ext_substate_power_not_available power_not_available; +- enum ethtool_c33_pse_ext_substate_short_detected short_detected; +- u32 __c33_pse_ext_substate; +- }; +-}; +- +-struct ethtool_c33_pse_pw_limit_range { +- u32 min; +- u32 max; +-}; + #endif /* _LINUX_ETHTOOL_H */ +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -5,7 +5,6 @@ + #ifndef _LINUX_PSE_CONTROLLER_H + #define _LINUX_PSE_CONTROLLER_H + +-#include + #include + #include + +@@ -16,6 +15,27 @@ + + struct phy_device; + struct pse_controller_dev; ++struct netlink_ext_ack; ++ ++/* C33 PSE extended state and substate. */ ++struct ethtool_c33_pse_ext_state_info { ++ enum ethtool_c33_pse_ext_state c33_pse_ext_state; ++ union { ++ enum ethtool_c33_pse_ext_substate_error_condition error_condition; ++ enum ethtool_c33_pse_ext_substate_mr_pse_enable mr_pse_enable; ++ enum ethtool_c33_pse_ext_substate_option_detect_ted option_detect_ted; ++ enum ethtool_c33_pse_ext_substate_option_vport_lim option_vport_lim; ++ enum ethtool_c33_pse_ext_substate_ovld_detected ovld_detected; ++ enum ethtool_c33_pse_ext_substate_power_not_available power_not_available; ++ enum ethtool_c33_pse_ext_substate_short_detected short_detected; ++ u32 __c33_pse_ext_substate; ++ }; ++}; ++ ++struct ethtool_c33_pse_pw_limit_range { ++ u32 min; ++ u32 max; ++}; + + /** + * struct pse_control_config - PSE control/channel configuration. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-10-v6.17-net-pse-pd-Introduce-attached_phydev-to-pse-control.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-10-v6.17-net-pse-pd-Introduce-attached_phydev-to-pse-control.patch new file mode 100755 index 0000000..b00c0e1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-10-v6.17-net-pse-pd-Introduce-attached_phydev-to-pse-control.patch @@ -0,0 +1,171 @@ +From fa2f0454174c2f33005f5a6e6f70c7160a15b2a1 Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:00 +0200 +Subject: [PATCH] net: pse-pd: Introduce attached_phydev to pse control + +In preparation for reporting PSE events via ethtool notifications, +introduce an attached_phydev field in the pse_control structure. +This field stores the phy_device associated with the PSE PI, +ensuring that notifications are sent to the correct network +interface. + +The attached_phydev pointer is directly tied to the PHY lifecycle. It +is set when the PHY is registered and cleared when the PHY is removed. +There is no need to use a refcount, as doing so could interfere with +the PHY removal process. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-1-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/mdio/fwnode_mdio.c | 26 ++++++++++++++------------ + drivers/net/pse-pd/pse_core.c | 11 ++++++++--- + include/linux/pse-pd/pse.h | 6 ++++-- + 3 files changed, 26 insertions(+), 17 deletions(-) +--- a/drivers/net/mdio/fwnode_mdio.c ++++ b/drivers/net/mdio/fwnode_mdio.c +@@ -18,7 +18,8 @@ MODULE_LICENSE("GPL"); + MODULE_DESCRIPTION("FWNODE MDIO bus (Ethernet PHY) accessors"); + + static struct pse_control * +-fwnode_find_pse_control(struct fwnode_handle *fwnode) ++fwnode_find_pse_control(struct fwnode_handle *fwnode, ++ struct phy_device *phydev) + { + struct pse_control *psec; + struct device_node *np; +@@ -30,7 +31,7 @@ fwnode_find_pse_control(struct fwnode_ha + if (!np) + return NULL; + +- psec = of_pse_control_get(np); ++ psec = of_pse_control_get(np, phydev); + if (PTR_ERR(psec) == -ENOENT) + return NULL; + +@@ -128,15 +129,9 @@ int fwnode_mdiobus_register_phy(struct m + u32 phy_id; + int rc; + +- psec = fwnode_find_pse_control(child); +- if (IS_ERR(psec)) +- return PTR_ERR(psec); +- + mii_ts = fwnode_find_mii_timestamper(child); +- if (IS_ERR(mii_ts)) { +- rc = PTR_ERR(mii_ts); +- goto clean_pse; +- } ++ if (IS_ERR(mii_ts)) ++ return PTR_ERR(mii_ts); + + is_c45 = fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45"); + if (is_c45 || fwnode_get_phy_id(child, &phy_id)) +@@ -169,6 +164,12 @@ int fwnode_mdiobus_register_phy(struct m + goto clean_phy; + } + ++ psec = fwnode_find_pse_control(child, phy); ++ if (IS_ERR(psec)) { ++ rc = PTR_ERR(psec); ++ goto unregister_phy; ++ } ++ + phy->psec = psec; + + /* phy->mii_ts may already be defined by the PHY driver. A +@@ -180,12 +181,13 @@ int fwnode_mdiobus_register_phy(struct m + + return 0; + ++unregister_phy: ++ if (is_acpi_node(child) || is_of_node(child)) ++ phy_device_remove(phy); + clean_phy: + phy_device_free(phy); + clean_mii_ts: + unregister_mii_timestamper(mii_ts); +-clean_pse: +- pse_control_put(psec); + + return rc; + } +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -23,6 +23,7 @@ static LIST_HEAD(pse_controller_list); + * @list: list entry for the pcdev's PSE controller list + * @id: ID of the PSE line in the PSE controller device + * @refcnt: Number of gets of this pse_control ++ * @attached_phydev: PHY device pointer attached by the PSE control + */ + struct pse_control { + struct pse_controller_dev *pcdev; +@@ -30,6 +31,7 @@ struct pse_control { + struct list_head list; + unsigned int id; + struct kref refcnt; ++ struct phy_device *attached_phydev; + }; + + static int of_load_single_pse_pi_pairset(struct device_node *node, +@@ -599,7 +601,8 @@ void pse_control_put(struct pse_control + EXPORT_SYMBOL_GPL(pse_control_put); + + static struct pse_control * +-pse_control_get_internal(struct pse_controller_dev *pcdev, unsigned int index) ++pse_control_get_internal(struct pse_controller_dev *pcdev, unsigned int index, ++ struct phy_device *phydev) + { + struct pse_control *psec; + int ret; +@@ -638,6 +641,7 @@ pse_control_get_internal(struct pse_cont + psec->pcdev = pcdev; + list_add(&psec->list, &pcdev->pse_control_head); + psec->id = index; ++ psec->attached_phydev = phydev; + kref_init(&psec->refcnt); + + return psec; +@@ -693,7 +697,8 @@ static int psec_id_xlate(struct pse_cont + return pse_spec->args[0]; + } + +-struct pse_control *of_pse_control_get(struct device_node *node) ++struct pse_control *of_pse_control_get(struct device_node *node, ++ struct phy_device *phydev) + { + struct pse_controller_dev *r, *pcdev; + struct of_phandle_args args; +@@ -743,7 +748,7 @@ struct pse_control *of_pse_control_get(s + } + + /* pse_list_mutex also protects the pcdev's pse_control list */ +- psec = pse_control_get_internal(pcdev, psec_id); ++ psec = pse_control_get_internal(pcdev, psec_id, phydev); + + out: + mutex_unlock(&pse_list_mutex); +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -250,7 +250,8 @@ struct device; + int devm_pse_controller_register(struct device *dev, + struct pse_controller_dev *pcdev); + +-struct pse_control *of_pse_control_get(struct device_node *node); ++struct pse_control *of_pse_control_get(struct device_node *node, ++ struct phy_device *phydev); + void pse_control_put(struct pse_control *psec); + + int pse_ethtool_get_status(struct pse_control *psec, +@@ -270,7 +271,8 @@ bool pse_has_c33(struct pse_control *pse + + #else + +-static inline struct pse_control *of_pse_control_get(struct device_node *node) ++static inline struct pse_control *of_pse_control_get(struct device_node *node, ++ struct phy_device *phydev) + { + return ERR_PTR(-ENOENT); + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-11-v6.17-net-pse-pd-Add-support-for-reporting-events.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-11-v6.17-net-pse-pd-Add-support-for-reporting-events.patch new file mode 100755 index 0000000..ec99fca --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-11-v6.17-net-pse-pd-Add-support-for-reporting-events.patch @@ -0,0 +1,363 @@ +# ADAPTED FOR OPENWRT 6.12.67 - Documentation changes removed +# Original commit: fc0e6db30941 +From fc0e6db30941a66e284b8516b82356f97f31061d Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:01 +0200 +Subject: [PATCH] net: pse-pd: Add support for reporting events + +Add support for devm_pse_irq_helper() to register PSE interrupts and report +events such as over-current or over-temperature conditions. This follows a +similar approach to the regulator API but also sends notifications using a +dedicated PSE ethtool netlink socket. + +Signed-off-by: Kory Maincent (Dent Project) +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-2-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + Documentation/netlink/specs/ethtool.yaml | 34 ++++ + Documentation/networking/ethtool-netlink.rst | 19 ++ + drivers/net/pse-pd/pse_core.c | 179 ++++++++++++++++++ + include/linux/ethtool_netlink.h | 7 + + include/linux/pse-pd/pse.h | 20 ++ + .../uapi/linux/ethtool_netlink_generated.h | 19 ++ + net/ethtool/pse-pd.c | 39 ++++ + 7 files changed, 317 insertions(+) + +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -7,10 +7,14 @@ + + #include + #include ++#include + #include ++#include + #include + #include + #include ++#include ++#include + + static DEFINE_MUTEX(pse_list_mutex); + static LIST_HEAD(pse_controller_list); +@@ -210,6 +214,48 @@ out: + return ret; + } + ++/** ++ * pse_control_find_net_by_id - Find net attached to the pse control id ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE control ++ * ++ * Return: pse_control pointer or NULL. The device returned has had a ++ * reference added and the pointer is safe until the user calls ++ * pse_control_put() to indicate they have finished with it. ++ */ ++static struct pse_control * ++pse_control_find_by_id(struct pse_controller_dev *pcdev, int id) ++{ ++ struct pse_control *psec; ++ ++ mutex_lock(&pse_list_mutex); ++ list_for_each_entry(psec, &pcdev->pse_control_head, list) { ++ if (psec->id == id) { ++ kref_get(&psec->refcnt); ++ mutex_unlock(&pse_list_mutex); ++ return psec; ++ } ++ } ++ mutex_unlock(&pse_list_mutex); ++ return NULL; ++} ++ ++/** ++ * pse_control_get_netdev - Return netdev associated to a PSE control ++ * @psec: PSE control pointer ++ * ++ * Return: netdev pointer or NULL ++ */ ++static struct net_device *pse_control_get_netdev(struct pse_control *psec) ++{ ++ ASSERT_RTNL(); ++ ++ if (!psec || !psec->attached_phydev) ++ return NULL; ++ ++ return psec->attached_phydev->attached_dev; ++} ++ + static int pse_pi_is_enabled(struct regulator_dev *rdev) + { + struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev); +@@ -559,6 +605,139 @@ int devm_pse_controller_register(struct + } + EXPORT_SYMBOL_GPL(devm_pse_controller_register); + ++struct pse_irq { ++ struct pse_controller_dev *pcdev; ++ struct pse_irq_desc desc; ++ unsigned long *notifs; ++}; ++ ++/** ++ * pse_to_regulator_notifs - Convert PSE notifications to Regulator ++ * notifications ++ * @notifs: PSE notifications ++ * ++ * Return: Regulator notifications ++ */ ++static unsigned long pse_to_regulator_notifs(unsigned long notifs) ++{ ++ unsigned long rnotifs = 0; ++ ++ if (notifs & ETHTOOL_PSE_EVENT_OVER_CURRENT) ++ rnotifs |= REGULATOR_EVENT_OVER_CURRENT; ++ if (notifs & ETHTOOL_PSE_EVENT_OVER_TEMP) ++ rnotifs |= REGULATOR_EVENT_OVER_TEMP; ++ ++ return rnotifs; ++} ++ ++/** ++ * pse_isr - IRQ handler for PSE ++ * @irq: irq number ++ * @data: pointer to user interrupt structure ++ * ++ * Return: irqreturn_t - status of IRQ ++ */ ++static irqreturn_t pse_isr(int irq, void *data) ++{ ++ struct pse_controller_dev *pcdev; ++ unsigned long notifs_mask = 0; ++ struct pse_irq_desc *desc; ++ struct pse_irq *h = data; ++ int ret, i; ++ ++ desc = &h->desc; ++ pcdev = h->pcdev; ++ ++ /* Clear notifs mask */ ++ memset(h->notifs, 0, pcdev->nr_lines * sizeof(*h->notifs)); ++ mutex_lock(&pcdev->lock); ++ ret = desc->map_event(irq, pcdev, h->notifs, ¬ifs_mask); ++ mutex_unlock(&pcdev->lock); ++ if (ret || !notifs_mask) ++ return IRQ_NONE; ++ ++ for_each_set_bit(i, ¬ifs_mask, pcdev->nr_lines) { ++ unsigned long notifs, rnotifs; ++ struct net_device *netdev; ++ struct pse_control *psec; ++ ++ /* Do nothing PI not described */ ++ if (!pcdev->pi[i].rdev) ++ continue; ++ ++ notifs = h->notifs[i]; ++ dev_dbg(h->pcdev->dev, ++ "Sending PSE notification EVT 0x%lx\n", notifs); ++ ++ psec = pse_control_find_by_id(pcdev, i); ++ rtnl_lock(); ++ netdev = pse_control_get_netdev(psec); ++ if (netdev) ++ ethnl_pse_send_ntf(netdev, notifs); ++ rtnl_unlock(); ++ pse_control_put(psec); ++ ++ rnotifs = pse_to_regulator_notifs(notifs); ++ regulator_notifier_call_chain(pcdev->pi[i].rdev, rnotifs, ++ NULL); ++ } ++ ++ return IRQ_HANDLED; ++} ++ ++/** ++ * devm_pse_irq_helper - Register IRQ based PSE event notifier ++ * @pcdev: a pointer to the PSE ++ * @irq: the irq value to be passed to request_irq ++ * @irq_flags: the flags to be passed to request_irq ++ * @d: PSE interrupt description ++ * ++ * Return: 0 on success and errno on failure ++ */ ++int devm_pse_irq_helper(struct pse_controller_dev *pcdev, int irq, ++ int irq_flags, const struct pse_irq_desc *d) ++{ ++ struct device *dev = pcdev->dev; ++ size_t irq_name_len; ++ struct pse_irq *h; ++ char *irq_name; ++ int ret; ++ ++ if (!d || !d->map_event || !d->name) ++ return -EINVAL; ++ ++ h = devm_kzalloc(dev, sizeof(*h), GFP_KERNEL); ++ if (!h) ++ return -ENOMEM; ++ ++ h->pcdev = pcdev; ++ h->desc = *d; ++ ++ /* IRQ name len is pcdev dev name + 5 char + irq desc name + 1 */ ++ irq_name_len = strlen(dev_name(pcdev->dev)) + 5 + strlen(d->name) + 1; ++ irq_name = devm_kzalloc(dev, irq_name_len, GFP_KERNEL); ++ if (!irq_name) ++ return -ENOMEM; ++ ++ snprintf(irq_name, irq_name_len, "pse-%s:%s", dev_name(pcdev->dev), ++ d->name); ++ ++ h->notifs = devm_kcalloc(dev, pcdev->nr_lines, ++ sizeof(*h->notifs), GFP_KERNEL); ++ if (!h->notifs) ++ return -ENOMEM; ++ ++ ret = devm_request_threaded_irq(dev, irq, NULL, pse_isr, ++ IRQF_ONESHOT | irq_flags, ++ irq_name, h); ++ if (ret) ++ dev_err(pcdev->dev, "Failed to request IRQ %d\n", irq); ++ ++ pcdev->irq = irq; ++ return ret; ++} ++EXPORT_SYMBOL_GPL(devm_pse_irq_helper); ++ + /* PSE control section */ + + static void __pse_control_release(struct kref *kref) +--- a/include/linux/ethtool_netlink.h ++++ b/include/linux/ethtool_netlink.h +@@ -43,6 +43,8 @@ void ethtool_aggregate_rmon_stats(struct + struct ethtool_rmon_stats *rmon_stats); + bool ethtool_dev_mm_supported(struct net_device *dev); + ++void ethnl_pse_send_ntf(struct net_device *netdev, unsigned long notif); ++ + #else + static inline int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd) + { +@@ -120,6 +122,11 @@ static inline bool ethtool_dev_mm_suppor + return false; + } + ++static inline void ethnl_pse_send_ntf(struct phy_device *phydev, ++ unsigned long notif) ++{ ++} ++ + #endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */ + + static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -7,12 +7,15 @@ + + #include + #include ++#include ++#include + + /* Maximum current in uA according to IEEE 802.3-2022 Table 145-1 */ + #define MAX_PI_CURRENT 1920000 + /* Maximum power in mW according to IEEE 802.3-2022 Table 145-16 */ + #define MAX_PI_PW 99900 + ++struct net_device; + struct phy_device; + struct pse_controller_dev; + struct netlink_ext_ack; +@@ -38,6 +41,19 @@ struct ethtool_c33_pse_pw_limit_range { + }; + + /** ++ * struct pse_irq_desc - notification sender description for IRQ based events. ++ * ++ * @name: the visible name for the IRQ ++ * @map_event: driver callback to map IRQ status into PSE devices with events. ++ */ ++struct pse_irq_desc { ++ const char *name; ++ int (*map_event)(int irq, struct pse_controller_dev *pcdev, ++ unsigned long *notifs, ++ unsigned long *notifs_mask); ++}; ++ ++/** + * struct pse_control_config - PSE control/channel configuration. + * + * @podl_admin_control: set PoDL PSE admin control as described in +@@ -228,6 +244,7 @@ struct pse_pi { + * @types: types of the PSE controller + * @pi: table of PSE PIs described in this controller device + * @no_of_pse_pi: flag set if the pse_pis devicetree node is not used ++ * @irq: PSE interrupt + */ + struct pse_controller_dev { + const struct pse_controller_ops *ops; +@@ -241,6 +258,7 @@ struct pse_controller_dev { + enum ethtool_pse_types types; + struct pse_pi *pi; + bool no_of_pse_pi; ++ int irq; + }; + + #if IS_ENABLED(CONFIG_PSE_CONTROLLER) +@@ -249,6 +267,8 @@ void pse_controller_unregister(struct ps + struct device; + int devm_pse_controller_register(struct device *dev, + struct pse_controller_dev *pcdev); ++int devm_pse_irq_helper(struct pse_controller_dev *pcdev, int irq, ++ int irq_flags, const struct pse_irq_desc *d); + + struct pse_control *of_pse_control_get(struct device_node *node, + struct phy_device *phydev); +--- a/net/ethtool/pse-pd.c ++++ b/net/ethtool/pse-pd.c +@@ -315,3 +315,42 @@ const struct ethnl_request_ops ethnl_pse + .set = ethnl_set_pse, + /* PSE has no notification */ + }; ++ ++void ethnl_pse_send_ntf(struct net_device *netdev, unsigned long notifs) ++{ ++ void *reply_payload; ++ struct sk_buff *skb; ++ int reply_len; ++ int ret; ++ ++ ASSERT_RTNL(); ++ ++ if (!netdev || !notifs) ++ return; ++ ++ reply_len = ethnl_reply_header_size() + ++ nla_total_size(sizeof(u32)); /* _PSE_NTF_EVENTS */ ++ ++ skb = genlmsg_new(reply_len, GFP_KERNEL); ++ if (!skb) ++ return; ++ ++ reply_payload = ethnl_bcastmsg_put(skb, ETHTOOL_MSG_PSE_NTF); ++ if (!reply_payload) ++ goto err_skb; ++ ++ ret = ethnl_fill_reply_header(skb, netdev, ETHTOOL_A_PSE_NTF_HEADER); ++ if (ret < 0) ++ goto err_skb; ++ ++ if (nla_put_uint(skb, ETHTOOL_A_PSE_NTF_EVENTS, notifs)) ++ goto err_skb; ++ ++ genlmsg_end(skb, reply_payload); ++ ethnl_multicast(skb, netdev); ++ return; ++ ++err_skb: ++ nlmsg_free(skb); ++} ++EXPORT_SYMBOL_GPL(ethnl_pse_send_ntf); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-12-v6.17-net-pse-pd-tps23881-Add-support-for-PSE-events.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-12-v6.17-net-pse-pd-tps23881-Add-support-for-PSE-events.patch new file mode 100755 index 0000000..8afcb3f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-12-v6.17-net-pse-pd-tps23881-Add-support-for-PSE-events.patch @@ -0,0 +1,252 @@ +From f5e7aecaa4efcd4c85477b6a62f94fea668031db Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:02 +0200 +Subject: [PATCH] net: pse-pd: tps23881: Add support for PSE events and + interrupts + +Add support for PSE event reporting through interrupts. Set up the newly +introduced devm_pse_irq_helper helper to register the interrupt. Events are +reported for over-current and over-temperature conditions. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-3-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 189 +++++++++++++++++++++++++++++++++- + 1 file changed, 187 insertions(+), 2 deletions(-) + +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -16,7 +16,15 @@ + #include + + #define TPS23881_MAX_CHANS 8 ++#define TPS23881_MAX_IRQ_RETRIES 10 + ++#define TPS23881_REG_IT 0x0 ++#define TPS23881_REG_IT_MASK 0x1 ++#define TPS23881_REG_IT_IFAULT BIT(5) ++#define TPS23881_REG_IT_SUPF BIT(7) ++#define TPS23881_REG_FAULT 0x7 ++#define TPS23881_REG_SUPF_EVENT 0xb ++#define TPS23881_REG_TSD BIT(7) + #define TPS23881_REG_PW_STATUS 0x10 + #define TPS23881_REG_OP_MODE 0x12 + #define TPS23881_OP_MODE_SEMIAUTO 0xaaaa +@@ -24,6 +32,7 @@ + #define TPS23881_REG_DET_CLA_EN 0x14 + #define TPS23881_REG_GEN_MASK 0x17 + #define TPS23881_REG_NBITACC BIT(5) ++#define TPS23881_REG_INTEN BIT(7) + #define TPS23881_REG_PW_EN 0x19 + #define TPS23881_REG_2PAIR_POL1 0x1e + #define TPS23881_REG_PORT_MAP 0x26 +@@ -51,6 +60,7 @@ struct tps23881_port_desc { + u8 chan[2]; + bool is_4p; + int pw_pol; ++ bool exist; + }; + + struct tps23881_priv { +@@ -782,8 +792,10 @@ tps23881_write_port_matrix(struct tps238 + hw_chan = port_matrix[i].hw_chan[0] % 4; + + /* Set software port matrix for existing ports */ +- if (port_matrix[i].exist) ++ if (port_matrix[i].exist) { + priv->port[pi_id].chan[0] = lgcl_chan; ++ priv->port[pi_id].exist = true; ++ } + + /* Initialize power policy internal value */ + priv->port[pi_id].pw_pol = -1; +@@ -1017,6 +1029,173 @@ static int tps23881_flash_sram_fw(struct + return 0; + } + ++/* Convert interrupt events to 0xff to be aligned with the chan ++ * number. ++ */ ++static u8 tps23881_irq_export_chans_helper(u16 reg_val, u8 field_offset) ++{ ++ u8 val; ++ ++ val = (reg_val >> (4 + field_offset) & 0xf0) | ++ (reg_val >> field_offset & 0x0f); ++ ++ return val; ++} ++ ++/* Convert chan number to port number */ ++static void tps23881_set_notifs_helper(struct tps23881_priv *priv, ++ u8 chans, ++ unsigned long *notifs, ++ unsigned long *notifs_mask, ++ enum ethtool_pse_event event) ++{ ++ u8 chan; ++ int i; ++ ++ if (!chans) ++ return; ++ ++ for (i = 0; i < TPS23881_MAX_CHANS; i++) { ++ if (!priv->port[i].exist) ++ continue; ++ /* No need to look at the 2nd channel in case of PoE4 as ++ * both registers are set. ++ */ ++ chan = priv->port[i].chan[0]; ++ ++ if (BIT(chan) & chans) { ++ *notifs_mask |= BIT(i); ++ notifs[i] |= event; ++ } ++ } ++} ++ ++static void tps23881_irq_event_over_temp(struct tps23881_priv *priv, ++ u16 reg_val, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ int i; ++ ++ if (reg_val & TPS23881_REG_TSD) { ++ for (i = 0; i < TPS23881_MAX_CHANS; i++) { ++ if (!priv->port[i].exist) ++ continue; ++ ++ *notifs_mask |= BIT(i); ++ notifs[i] |= ETHTOOL_PSE_EVENT_OVER_TEMP; ++ } ++ } ++} ++ ++static void tps23881_irq_event_over_current(struct tps23881_priv *priv, ++ u16 reg_val, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ u8 chans; ++ ++ chans = tps23881_irq_export_chans_helper(reg_val, 0); ++ if (chans) ++ tps23881_set_notifs_helper(priv, chans, notifs, notifs_mask, ++ ETHTOOL_PSE_EVENT_OVER_CURRENT); ++} ++ ++static int tps23881_irq_event_handler(struct tps23881_priv *priv, u16 reg, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ struct i2c_client *client = priv->client; ++ int ret; ++ ++ /* The Supply event bit is repeated twice so we only need to read ++ * the one from the first byte. ++ */ ++ if (reg & TPS23881_REG_IT_SUPF) { ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_SUPF_EVENT); ++ if (ret < 0) ++ return ret; ++ tps23881_irq_event_over_temp(priv, ret, notifs, notifs_mask); ++ } ++ ++ if (reg & (TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_IFAULT << 8)) { ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_FAULT); ++ if (ret < 0) ++ return ret; ++ tps23881_irq_event_over_current(priv, ret, notifs, notifs_mask); ++ } ++ ++ return 0; ++} ++ ++static int tps23881_irq_handler(int irq, struct pse_controller_dev *pcdev, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ struct i2c_client *client = priv->client; ++ int ret, it_mask, retry; ++ ++ /* Get interruption mask */ ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_IT_MASK); ++ if (ret < 0) ++ return ret; ++ it_mask = ret; ++ ++ /* Read interrupt register until it frees the interruption pin. */ ++ retry = 0; ++ while (true) { ++ if (retry > TPS23881_MAX_IRQ_RETRIES) { ++ dev_err(&client->dev, "interrupt never freed"); ++ return -ETIMEDOUT; ++ } ++ ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_IT); ++ if (ret < 0) ++ return ret; ++ ++ /* No more relevant interruption */ ++ if (!(ret & it_mask)) ++ return 0; ++ ++ ret = tps23881_irq_event_handler(priv, (u16)ret, notifs, ++ notifs_mask); ++ if (ret) ++ return ret; ++ ++ retry++; ++ } ++ return 0; ++} ++ ++static int tps23881_setup_irq(struct tps23881_priv *priv, int irq) ++{ ++ struct i2c_client *client = priv->client; ++ struct pse_irq_desc irq_desc = { ++ .name = "tps23881-irq", ++ .map_event = tps23881_irq_handler, ++ }; ++ int ret; ++ u16 val; ++ ++ val = TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_SUPF; ++ val |= val << 8; ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_IT_MASK, val); ++ if (ret) ++ return ret; ++ ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_GEN_MASK); ++ if (ret < 0) ++ return ret; ++ ++ val = (u16)(ret | TPS23881_REG_INTEN | TPS23881_REG_INTEN << 8); ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_GEN_MASK, val); ++ if (ret < 0) ++ return ret; ++ ++ return devm_pse_irq_helper(&priv->pcdev, irq, 0, &irq_desc); ++} ++ + static int tps23881_i2c_probe(struct i2c_client *client) + { + struct device *dev = &client->dev; +@@ -1097,6 +1276,12 @@ static int tps23881_i2c_probe(struct i2c + "failed to register PSE controller\n"); + } + ++ if (client->irq) { ++ ret = tps23881_setup_irq(priv, client->irq); ++ if (ret) ++ return ret; ++ } ++ + return ret; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-13-v6.17-net-pse-pd-Add-support-for-PSE-power-domains.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-13-v6.17-net-pse-pd-Add-support-for-PSE-power-domains.patch new file mode 100755 index 0000000..a02bbbc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-13-v6.17-net-pse-pd-Add-support-for-PSE-power-domains.patch @@ -0,0 +1,218 @@ +From 50f8b341d26826aa5fdccb8f497fbff2500934b3 Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:03 +0200 +Subject: [PATCH] net: pse-pd: Add support for PSE power domains + +Introduce PSE power domain support as groundwork for upcoming port +priority features. Multiple PSE PIs can now be grouped under a single +PSE power domain, enabling future enhancements like defining available +power budgets, port priority modes, and disconnection policies. This +setup will allow the system to assess whether activating a port would +exceed the available power budget, preventing over-budget states +proactively. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-4-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pse_core.c | 140 ++++++++++++++++++++++++++++++++++ + include/linux/pse-pd/pse.h | 2 + + 2 files changed, 142 insertions(+) +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -16,8 +16,12 @@ + #include + #include + ++#define PSE_PW_D_LIMIT INT_MAX ++ + static DEFINE_MUTEX(pse_list_mutex); + static LIST_HEAD(pse_controller_list); ++static DEFINE_XARRAY_ALLOC(pse_pw_d_map); ++static DEFINE_MUTEX(pse_pw_d_mutex); + + /** + * struct pse_control - a PSE control +@@ -38,6 +42,18 @@ struct pse_control { + struct phy_device *attached_phydev; + }; + ++/** ++ * struct pse_power_domain - a PSE power domain ++ * @id: ID of the power domain ++ * @supply: Power supply the Power Domain ++ * @refcnt: Number of gets of this pse_power_domain ++ */ ++struct pse_power_domain { ++ int id; ++ struct regulator *supply; ++ struct kref refcnt; ++}; ++ + static int of_load_single_pse_pi_pairset(struct device_node *node, + struct pse_pi *pi, + int pairset_num) +@@ -485,6 +501,125 @@ devm_pse_pi_regulator_register(struct ps + return 0; + } + ++static void __pse_pw_d_release(struct kref *kref) ++{ ++ struct pse_power_domain *pw_d = container_of(kref, ++ struct pse_power_domain, ++ refcnt); ++ ++ regulator_put(pw_d->supply); ++ xa_erase(&pse_pw_d_map, pw_d->id); ++ mutex_unlock(&pse_pw_d_mutex); ++} ++ ++/** ++ * pse_flush_pw_ds - flush all PSE power domains of a PSE ++ * @pcdev: a pointer to the initialized PSE controller device ++ */ ++static void pse_flush_pw_ds(struct pse_controller_dev *pcdev) ++{ ++ struct pse_power_domain *pw_d; ++ int i; ++ ++ for (i = 0; i < pcdev->nr_lines; i++) { ++ if (!pcdev->pi[i].pw_d) ++ continue; ++ ++ pw_d = xa_load(&pse_pw_d_map, pcdev->pi[i].pw_d->id); ++ if (!pw_d) ++ continue; ++ ++ kref_put_mutex(&pw_d->refcnt, __pse_pw_d_release, ++ &pse_pw_d_mutex); ++ } ++} ++ ++/** ++ * devm_pse_alloc_pw_d - allocate a new PSE power domain for a device ++ * @dev: device that is registering this PSE power domain ++ * ++ * Return: Pointer to the newly allocated PSE power domain or error pointers ++ */ ++static struct pse_power_domain *devm_pse_alloc_pw_d(struct device *dev) ++{ ++ struct pse_power_domain *pw_d; ++ int index, ret; ++ ++ pw_d = devm_kzalloc(dev, sizeof(*pw_d), GFP_KERNEL); ++ if (!pw_d) ++ return ERR_PTR(-ENOMEM); ++ ++ ret = xa_alloc(&pse_pw_d_map, &index, pw_d, XA_LIMIT(1, PSE_PW_D_LIMIT), ++ GFP_KERNEL); ++ if (ret) ++ return ERR_PTR(ret); ++ ++ kref_init(&pw_d->refcnt); ++ pw_d->id = index; ++ return pw_d; ++} ++ ++/** ++ * pse_register_pw_ds - register the PSE power domains for a PSE ++ * @pcdev: a pointer to the PSE controller device ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int pse_register_pw_ds(struct pse_controller_dev *pcdev) ++{ ++ int i, ret = 0; ++ ++ mutex_lock(&pse_pw_d_mutex); ++ for (i = 0; i < pcdev->nr_lines; i++) { ++ struct regulator_dev *rdev = pcdev->pi[i].rdev; ++ struct pse_power_domain *pw_d; ++ struct regulator *supply; ++ bool present = false; ++ unsigned long index; ++ ++ /* No regulator or regulator parent supply registered. ++ * We need a regulator parent to register a PSE power domain ++ */ ++ if (!rdev || !rdev->supply) ++ continue; ++ ++ xa_for_each(&pse_pw_d_map, index, pw_d) { ++ /* Power supply already registered as a PSE power ++ * domain. ++ */ ++ if (regulator_is_equal(pw_d->supply, rdev->supply)) { ++ present = true; ++ pcdev->pi[i].pw_d = pw_d; ++ break; ++ } ++ } ++ if (present) { ++ kref_get(&pw_d->refcnt); ++ continue; ++ } ++ ++ pw_d = devm_pse_alloc_pw_d(pcdev->dev); ++ if (IS_ERR(pw_d)) { ++ ret = PTR_ERR(pw_d); ++ goto out; ++ } ++ ++ supply = regulator_get(&rdev->dev, rdev->supply_name); ++ if (IS_ERR(supply)) { ++ xa_erase(&pse_pw_d_map, pw_d->id); ++ ret = PTR_ERR(supply); ++ goto out; ++ } ++ ++ pw_d->supply = supply; ++ pcdev->pi[i].pw_d = pw_d; ++ } ++ ++out: ++ mutex_unlock(&pse_pw_d_mutex); ++ return ret; ++} ++ + /** + * pse_controller_register - register a PSE controller device + * @pcdev: a pointer to the initialized PSE controller device +@@ -544,6 +679,10 @@ int pse_controller_register(struct pse_c + return ret; + } + ++ ret = pse_register_pw_ds(pcdev); ++ if (ret) ++ return ret; ++ + mutex_lock(&pse_list_mutex); + list_add(&pcdev->list, &pse_controller_list); + mutex_unlock(&pse_list_mutex); +@@ -558,6 +697,7 @@ EXPORT_SYMBOL_GPL(pse_controller_registe + */ + void pse_controller_unregister(struct pse_controller_dev *pcdev) + { ++ pse_flush_pw_ds(pcdev); + pse_release_pis(pcdev); + mutex_lock(&pse_list_mutex); + list_del(&pcdev->list); +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -222,12 +222,14 @@ struct pse_pi_pairset { + * @np: device node pointer of the PSE PI node + * @rdev: regulator represented by the PSE PI + * @admin_state_enabled: PI enabled state ++ * @pw_d: Power domain of the PSE PI + */ + struct pse_pi { + struct pse_pi_pairset pairset[2]; + struct device_node *np; + struct regulator_dev *rdev; + bool admin_state_enabled; ++ struct pse_power_domain *pw_d; + }; + + /** diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-14-v6.17-net-pse-pd-ethtool-Add-support-for-power-domains-index.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-14-v6.17-net-pse-pd-ethtool-Add-support-for-power-domains-index.patch new file mode 100755 index 0000000..1124882 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-14-v6.17-net-pse-pd-ethtool-Add-support-for-power-domains-index.patch @@ -0,0 +1,78 @@ +# ADAPTED FOR OPENWRT 6.12.67 - Documentation changes removed +# Original commit: 1176978ed851 +From 1176978ed851952652ddea3685e2f71a0e5d61ff Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:04 +0200 +Subject: [PATCH] net: ethtool: Add support for new power domains index + description + +Report the index of the newly introduced PSE power domain to the user, +enabling improved management of the power budget for PSE devices. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-5-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + Documentation/netlink/specs/ethtool.yaml | 5 +++++ + Documentation/networking/ethtool-netlink.rst | 4 ++++ + drivers/net/pse-pd/pse_core.c | 3 +++ + include/linux/pse-pd/pse.h | 2 ++ + include/uapi/linux/ethtool_netlink_generated.h | 1 + + net/ethtool/pse-pd.c | 7 +++++++ + 6 files changed, 22 insertions(+) + +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -1098,6 +1098,9 @@ int pse_ethtool_get_status(struct pse_co + pcdev = psec->pcdev; + ops = pcdev->ops; + mutex_lock(&pcdev->lock); ++ if (pcdev->pi[psec->id].pw_d) ++ status->pw_d_id = pcdev->pi[psec->id].pw_d->id; ++ + ret = ops->pi_get_admin_state(pcdev, psec->id, &admin_state); + if (ret) + goto out; +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -114,6 +114,7 @@ struct pse_pw_limit_ranges { + /** + * struct ethtool_pse_control_status - PSE control/channel status. + * ++ * @pw_d_id: PSE power domain index. + * @podl_admin_state: operational state of the PoDL PSE + * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState + * @podl_pw_status: power detection status of the PoDL PSE. +@@ -135,6 +136,7 @@ struct pse_pw_limit_ranges { + * ranges + */ + struct ethtool_pse_control_status { ++ u32 pw_d_id; + enum ethtool_podl_pse_admin_state podl_admin_state; + enum ethtool_podl_pse_pw_d_status podl_pw_status; + enum ethtool_c33_pse_admin_state c33_admin_state; +--- a/net/ethtool/pse-pd.c ++++ b/net/ethtool/pse-pd.c +@@ -83,6 +83,8 @@ static int pse_reply_size(const struct e + const struct ethtool_pse_control_status *st = &data->status; + int len = 0; + ++ if (st->pw_d_id) ++ len += nla_total_size(sizeof(u32)); /* _PSE_PW_D_ID */ + if (st->podl_admin_state > 0) + len += nla_total_size(sizeof(u32)); /* _PODL_PSE_ADMIN_STATE */ + if (st->podl_pw_status > 0) +@@ -148,6 +150,11 @@ static int pse_fill_reply(struct sk_buff + const struct pse_reply_data *data = PSE_REPDATA(reply_base); + const struct ethtool_pse_control_status *st = &data->status; + ++ if (st->pw_d_id && ++ nla_put_u32(skb, ETHTOOL_A_PSE_PW_D_ID, ++ st->pw_d_id)) ++ return -EMSGSIZE; ++ + if (st->podl_admin_state > 0 && + nla_put_u32(skb, ETHTOOL_A_PODL_PSE_ADMIN_STATE, + st->podl_admin_state)) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-15-v6.17-net-pse-pd-Add-helper-to-report-hw-enable-status.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-15-v6.17-net-pse-pd-Add-helper-to-report-hw-enable-status.patch new file mode 100755 index 0000000..ed51289 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-15-v6.17-net-pse-pd-Add-helper-to-report-hw-enable-status.patch @@ -0,0 +1,74 @@ +From c394e757dedd9cf947f9ac470d615d28fd2b07d1 Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:05 +0200 +Subject: [PATCH] net: pse-pd: Add helper to report hardware enable status of + the PI + +Refactor code by introducing a helper function to retrieve the hardware +enabled state of the PI, avoiding redundant implementations in the +future. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-6-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pse_core.c | 36 +++++++++++++++++++++++++---------- + 1 file changed, 26 insertions(+), 10 deletions(-) + +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -272,10 +272,34 @@ static struct net_device *pse_control_ge + return psec->attached_phydev->attached_dev; + } + ++/** ++ * pse_pi_is_hw_enabled - Is PI enabled at the hardware level ++ * @pcdev: a pointer to the PSE controller device ++ * @id: Index of the PI ++ * ++ * Return: 1 if the PI is enabled at the hardware level, 0 if not, and ++ * a failure value on error ++ */ ++static int pse_pi_is_hw_enabled(struct pse_controller_dev *pcdev, int id) ++{ ++ struct pse_admin_state admin_state = {0}; ++ int ret; ++ ++ ret = pcdev->ops->pi_get_admin_state(pcdev, id, &admin_state); ++ if (ret < 0) ++ return ret; ++ ++ /* PI is well enabled at the hardware level */ ++ if (admin_state.podl_admin_state == ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED || ++ admin_state.c33_admin_state == ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED) ++ return 1; ++ ++ return 0; ++} ++ + static int pse_pi_is_enabled(struct regulator_dev *rdev) + { + struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev); +- struct pse_admin_state admin_state = {0}; + const struct pse_controller_ops *ops; + int id, ret; + +@@ -285,15 +309,7 @@ static int pse_pi_is_enabled(struct regu + + id = rdev_get_id(rdev); + mutex_lock(&pcdev->lock); +- ret = ops->pi_get_admin_state(pcdev, id, &admin_state); +- if (ret) +- goto out; +- +- if (admin_state.podl_admin_state == ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED || +- admin_state.c33_admin_state == ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED) +- ret = 1; +- +-out: ++ ret = pse_pi_is_hw_enabled(pcdev, id); + mutex_unlock(&pcdev->lock); + + return ret; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-16-v6.17-net-pse-pd-Add-support-for-budget-evaluation-strategies.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-16-v6.17-net-pse-pd-Add-support-for-budget-evaluation-strategies.patch new file mode 100755 index 0000000..c95d8f0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-16-v6.17-net-pse-pd-Add-support-for-budget-evaluation-strategies.patch @@ -0,0 +1,1104 @@ +From ffef61d6d27374542f1bce4452200d9bdd2e1edd Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:06 +0200 +Subject: [PATCH] net: pse-pd: Add support for budget evaluation strategies + +ADAPTED FOR OPENWRT 6.12.67 - Documentation and ethtool_netlink_generated.h changes removed + +This patch introduces the ability to configure the PSE PI budget evaluation +strategies. Budget evaluation strategies is utilized by PSE controllers to +determine which ports to turn off first in scenarios such as power budget +exceedance. + +The pis_prio_max value is used to define the maximum priority level +supported by the controller. Both the current priority and the maximum +priority are exposed to the user through the pse_ethtool_get_status call. + +This patch add support for two mode of budget evaluation strategies. +1. Static Method: + This method involves distributing power based on PD classification. + +2. Dynamic Method: + Budget evaluation strategy based on the current consumption per ports + compared to the total power budget. + +Signed-off-by: Kory Maincent (Dent Project) +Acked-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-7-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pse_core.c | 729 +++++++++++++++++++++++++++++++++- + include/linux/pse-pd/pse.h | 76 ++++ + 2 files changed, 791 insertions(+), 14 deletions(-) + +--- a/drivers/net/pse-pd/pse_core.c ++++ b/drivers/net/pse-pd/pse_core.c +@@ -47,11 +47,14 @@ struct pse_control { + * @id: ID of the power domain + * @supply: Power supply the Power Domain + * @refcnt: Number of gets of this pse_power_domain ++ * @budget_eval_strategy: Current power budget evaluation strategy of the ++ * power domain + */ + struct pse_power_domain { + int id; + struct regulator *supply; + struct kref refcnt; ++ u32 budget_eval_strategy; + }; + + static int of_load_single_pse_pi_pairset(struct device_node *node, +@@ -297,6 +300,115 @@ static int pse_pi_is_hw_enabled(struct p + return 0; + } + ++/** ++ * pse_pi_is_admin_enable_pending - Check if PI is in admin enable pending state ++ * which mean the power is not yet being ++ * delivered ++ * @pcdev: a pointer to the PSE controller device ++ * @id: Index of the PI ++ * ++ * Detects if a PI is enabled in software with a PD detected, but the hardware ++ * admin state hasn't been applied yet. ++ * ++ * This function is used in the power delivery and retry mechanisms to determine ++ * which PIs need to have power delivery attempted again. ++ * ++ * Return: true if the PI has admin enable flag set in software but not yet ++ * reflected in the hardware admin state, false otherwise. ++ */ ++static bool ++pse_pi_is_admin_enable_pending(struct pse_controller_dev *pcdev, int id) ++{ ++ int ret; ++ ++ /* PI not enabled or nothing is plugged */ ++ if (!pcdev->pi[id].admin_state_enabled || ++ !pcdev->pi[id].isr_pd_detected) ++ return false; ++ ++ ret = pse_pi_is_hw_enabled(pcdev, id); ++ /* PSE PI is already enabled at hardware level */ ++ if (ret == 1) ++ return false; ++ ++ return true; ++} ++ ++static int _pse_pi_delivery_power_sw_pw_ctrl(struct pse_controller_dev *pcdev, ++ int id, ++ struct netlink_ext_ack *extack); ++ ++/** ++ * pse_pw_d_retry_power_delivery - Retry power delivery for pending ports in a ++ * PSE power domain ++ * @pcdev: a pointer to the PSE controller device ++ * @pw_d: a pointer to the PSE power domain ++ * ++ * Scans all ports in the specified power domain and attempts to enable power ++ * delivery to any ports that have admin enable state set but don't yet have ++ * hardware power enabled. Used when there are changes in connection status, ++ * admin state, or priority that might allow previously unpowered ports to ++ * receive power, especially in over-budget conditions. ++ */ ++static void pse_pw_d_retry_power_delivery(struct pse_controller_dev *pcdev, ++ struct pse_power_domain *pw_d) ++{ ++ int i, ret = 0; ++ ++ for (i = 0; i < pcdev->nr_lines; i++) { ++ int prio_max = pcdev->nr_lines; ++ struct netlink_ext_ack extack; ++ ++ if (pcdev->pi[i].pw_d != pw_d) ++ continue; ++ ++ if (!pse_pi_is_admin_enable_pending(pcdev, i)) ++ continue; ++ ++ /* Do not try to enable PI with a lower prio (higher value) ++ * than one which already can't be enabled. ++ */ ++ if (pcdev->pi[i].prio > prio_max) ++ continue; ++ ++ ret = _pse_pi_delivery_power_sw_pw_ctrl(pcdev, i, &extack); ++ if (ret == -ERANGE) ++ prio_max = pcdev->pi[i].prio; ++ } ++} ++ ++/** ++ * pse_pw_d_is_sw_pw_control - Determine if power control is software managed ++ * @pcdev: a pointer to the PSE controller device ++ * @pw_d: a pointer to the PSE power domain ++ * ++ * This function determines whether the power control for a specific power ++ * domain is managed by software in the interrupt handler rather than directly ++ * by hardware. ++ * ++ * Software power control is active in the following cases: ++ * - When the budget evaluation strategy is set to static ++ * - When the budget evaluation strategy is disabled but the PSE controller ++ * has an interrupt handler that can report if a Powered Device is connected ++ * ++ * Return: true if the power control of the power domain is managed by software, ++ * false otherwise ++ */ ++static bool pse_pw_d_is_sw_pw_control(struct pse_controller_dev *pcdev, ++ struct pse_power_domain *pw_d) ++{ ++ if (!pw_d) ++ return false; ++ ++ if (pw_d->budget_eval_strategy == PSE_BUDGET_EVAL_STRAT_STATIC) ++ return true; ++ if (pw_d->budget_eval_strategy == PSE_BUDGET_EVAL_STRAT_DISABLED && ++ pcdev->ops->pi_enable && pcdev->irq) ++ return true; ++ ++ return false; ++} ++ + static int pse_pi_is_enabled(struct regulator_dev *rdev) + { + struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev); +@@ -309,17 +421,252 @@ static int pse_pi_is_enabled(struct regu + + id = rdev_get_id(rdev); + mutex_lock(&pcdev->lock); ++ if (pse_pw_d_is_sw_pw_control(pcdev, pcdev->pi[id].pw_d)) { ++ ret = pcdev->pi[id].admin_state_enabled; ++ goto out; ++ } ++ + ret = pse_pi_is_hw_enabled(pcdev, id); ++ ++out: + mutex_unlock(&pcdev->lock); + + return ret; + } + ++/** ++ * pse_pi_deallocate_pw_budget - Deallocate power budget of the PI ++ * @pi: a pointer to the PSE PI ++ */ ++static void pse_pi_deallocate_pw_budget(struct pse_pi *pi) ++{ ++ if (!pi->pw_d || !pi->pw_allocated_mW) ++ return; ++ ++ regulator_free_power_budget(pi->pw_d->supply, pi->pw_allocated_mW); ++ pi->pw_allocated_mW = 0; ++} ++ ++/** ++ * _pse_pi_disable - Call disable operation. Assumes the PSE lock has been ++ * acquired. ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE control ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int _pse_pi_disable(struct pse_controller_dev *pcdev, int id) ++{ ++ const struct pse_controller_ops *ops = pcdev->ops; ++ int ret; ++ ++ if (!ops->pi_disable) ++ return -EOPNOTSUPP; ++ ++ ret = ops->pi_disable(pcdev, id); ++ if (ret) ++ return ret; ++ ++ pse_pi_deallocate_pw_budget(&pcdev->pi[id]); ++ ++ if (pse_pw_d_is_sw_pw_control(pcdev, pcdev->pi[id].pw_d)) ++ pse_pw_d_retry_power_delivery(pcdev, pcdev->pi[id].pw_d); ++ ++ return 0; ++} ++ ++/** ++ * pse_disable_pi_pol - Disable a PI on a power budget policy ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE PI ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int pse_disable_pi_pol(struct pse_controller_dev *pcdev, int id) ++{ ++ unsigned long notifs = ETHTOOL_PSE_EVENT_OVER_BUDGET; ++ struct pse_ntf ntf = {}; ++ int ret; ++ ++ dev_dbg(pcdev->dev, "Disabling PI %d to free power budget\n", id); ++ ++ ret = _pse_pi_disable(pcdev, id); ++ if (ret) ++ notifs |= ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR; ++ ++ ntf.notifs = notifs; ++ ntf.id = id; ++ kfifo_in_spinlocked(&pcdev->ntf_fifo, &ntf, 1, &pcdev->ntf_fifo_lock); ++ schedule_work(&pcdev->ntf_work); ++ ++ return ret; ++} ++ ++/** ++ * pse_disable_pi_prio - Disable all PIs of a given priority inside a PSE ++ * power domain ++ * @pcdev: a pointer to the PSE ++ * @pw_d: a pointer to the PSE power domain ++ * @prio: priority ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int pse_disable_pi_prio(struct pse_controller_dev *pcdev, ++ struct pse_power_domain *pw_d, ++ int prio) ++{ ++ int i; ++ ++ for (i = 0; i < pcdev->nr_lines; i++) { ++ int ret; ++ ++ if (pcdev->pi[i].prio != prio || ++ pcdev->pi[i].pw_d != pw_d || ++ pse_pi_is_hw_enabled(pcdev, i) <= 0) ++ continue; ++ ++ ret = pse_disable_pi_pol(pcdev, i); ++ if (ret) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++/** ++ * pse_pi_allocate_pw_budget_static_prio - Allocate power budget for the PI ++ * when the budget eval strategy is ++ * static ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE control ++ * @pw_req: power requested in mW ++ * @extack: extack for error reporting ++ * ++ * Allocates power using static budget evaluation strategy, where allocation ++ * is based on PD classification. When insufficient budget is available, ++ * lower-priority ports (higher priority numbers) are turned off first. ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int ++pse_pi_allocate_pw_budget_static_prio(struct pse_controller_dev *pcdev, int id, ++ int pw_req, struct netlink_ext_ack *extack) ++{ ++ struct pse_pi *pi = &pcdev->pi[id]; ++ int ret, _prio; ++ ++ _prio = pcdev->nr_lines; ++ while (regulator_request_power_budget(pi->pw_d->supply, pw_req) == -ERANGE) { ++ if (_prio <= pi->prio) { ++ NL_SET_ERR_MSG_FMT(extack, ++ "PI %d: not enough power budget available", ++ id); ++ return -ERANGE; ++ } ++ ++ ret = pse_disable_pi_prio(pcdev, pi->pw_d, _prio); ++ if (ret < 0) ++ return ret; ++ ++ _prio--; ++ } ++ ++ pi->pw_allocated_mW = pw_req; ++ return 0; ++} ++ ++/** ++ * pse_pi_allocate_pw_budget - Allocate power budget for the PI ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE control ++ * @pw_req: power requested in mW ++ * @extack: extack for error reporting ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int pse_pi_allocate_pw_budget(struct pse_controller_dev *pcdev, int id, ++ int pw_req, struct netlink_ext_ack *extack) ++{ ++ struct pse_pi *pi = &pcdev->pi[id]; ++ ++ if (!pi->pw_d) ++ return 0; ++ ++ /* PSE_BUDGET_EVAL_STRAT_STATIC */ ++ if (pi->pw_d->budget_eval_strategy == PSE_BUDGET_EVAL_STRAT_STATIC) ++ return pse_pi_allocate_pw_budget_static_prio(pcdev, id, pw_req, ++ extack); ++ ++ return 0; ++} ++ ++/** ++ * _pse_pi_delivery_power_sw_pw_ctrl - Enable PSE PI in case of software power ++ * control. Assumes the PSE lock has been ++ * acquired. ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE control ++ * @extack: extack for error reporting ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int _pse_pi_delivery_power_sw_pw_ctrl(struct pse_controller_dev *pcdev, ++ int id, ++ struct netlink_ext_ack *extack) ++{ ++ const struct pse_controller_ops *ops = pcdev->ops; ++ struct pse_pi *pi = &pcdev->pi[id]; ++ int ret, pw_req; ++ ++ if (!ops->pi_get_pw_req) { ++ /* No power allocation management */ ++ ret = ops->pi_enable(pcdev, id); ++ if (ret) ++ NL_SET_ERR_MSG_FMT(extack, ++ "PI %d: enable error %d", ++ id, ret); ++ return ret; ++ } ++ ++ ret = ops->pi_get_pw_req(pcdev, id); ++ if (ret < 0) ++ return ret; ++ ++ pw_req = ret; ++ ++ /* Compare requested power with port power limit and use the lowest ++ * one. ++ */ ++ if (ops->pi_get_pw_limit) { ++ ret = ops->pi_get_pw_limit(pcdev, id); ++ if (ret < 0) ++ return ret; ++ ++ if (ret < pw_req) ++ pw_req = ret; ++ } ++ ++ ret = pse_pi_allocate_pw_budget(pcdev, id, pw_req, extack); ++ if (ret) ++ return ret; ++ ++ ret = ops->pi_enable(pcdev, id); ++ if (ret) { ++ pse_pi_deallocate_pw_budget(pi); ++ NL_SET_ERR_MSG_FMT(extack, ++ "PI %d: enable error %d", ++ id, ret); ++ return ret; ++ } ++ ++ return 0; ++} ++ + static int pse_pi_enable(struct regulator_dev *rdev) + { + struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev); + const struct pse_controller_ops *ops; +- int id, ret; ++ int id, ret = 0; + + ops = pcdev->ops; + if (!ops->pi_enable) +@@ -327,6 +674,23 @@ static int pse_pi_enable(struct regulato + + id = rdev_get_id(rdev); + mutex_lock(&pcdev->lock); ++ if (pse_pw_d_is_sw_pw_control(pcdev, pcdev->pi[id].pw_d)) { ++ /* Manage enabled status by software. ++ * Real enable process will happen if a port is connected. ++ */ ++ if (pcdev->pi[id].isr_pd_detected) { ++ struct netlink_ext_ack extack; ++ ++ ret = _pse_pi_delivery_power_sw_pw_ctrl(pcdev, id, &extack); ++ } ++ if (!ret || ret == -ERANGE) { ++ pcdev->pi[id].admin_state_enabled = 1; ++ ret = 0; ++ } ++ mutex_unlock(&pcdev->lock); ++ return ret; ++ } ++ + ret = ops->pi_enable(pcdev, id); + if (!ret) + pcdev->pi[id].admin_state_enabled = 1; +@@ -338,21 +702,18 @@ static int pse_pi_enable(struct regulato + static int pse_pi_disable(struct regulator_dev *rdev) + { + struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev); +- const struct pse_controller_ops *ops; ++ struct pse_pi *pi; + int id, ret; + +- ops = pcdev->ops; +- if (!ops->pi_disable) +- return -EOPNOTSUPP; +- + id = rdev_get_id(rdev); ++ pi = &pcdev->pi[id]; + mutex_lock(&pcdev->lock); +- ret = ops->pi_disable(pcdev, id); ++ ret = _pse_pi_disable(pcdev, id); + if (!ret) +- pcdev->pi[id].admin_state_enabled = 0; +- mutex_unlock(&pcdev->lock); ++ pi->admin_state_enabled = 0; + +- return ret; ++ mutex_unlock(&pcdev->lock); ++ return 0; + } + + static int _pse_pi_get_voltage(struct regulator_dev *rdev) +@@ -628,6 +989,11 @@ static int pse_register_pw_ds(struct pse + } + + pw_d->supply = supply; ++ if (pcdev->supp_budget_eval_strategies) ++ pw_d->budget_eval_strategy = pcdev->supp_budget_eval_strategies; ++ else ++ pw_d->budget_eval_strategy = PSE_BUDGET_EVAL_STRAT_DISABLED; ++ kref_init(&pw_d->refcnt); + pcdev->pi[i].pw_d = pw_d; + } + +@@ -637,6 +1003,34 @@ out: + } + + /** ++ * pse_send_ntf_worker - Worker to send PSE notifications ++ * @work: work object ++ * ++ * Manage and send PSE netlink notifications using a workqueue to avoid ++ * deadlock between pcdev_lock and pse_list_mutex. ++ */ ++static void pse_send_ntf_worker(struct work_struct *work) ++{ ++ struct pse_controller_dev *pcdev; ++ struct pse_ntf ntf; ++ ++ pcdev = container_of(work, struct pse_controller_dev, ntf_work); ++ ++ while (kfifo_out(&pcdev->ntf_fifo, &ntf, 1)) { ++ struct net_device *netdev; ++ struct pse_control *psec; ++ ++ psec = pse_control_find_by_id(pcdev, ntf.id); ++ rtnl_lock(); ++ netdev = pse_control_get_netdev(psec); ++ if (netdev) ++ ethnl_pse_send_ntf(netdev, ntf.notifs); ++ rtnl_unlock(); ++ pse_control_put(psec); ++ } ++} ++ ++/** + * pse_controller_register - register a PSE controller device + * @pcdev: a pointer to the initialized PSE controller device + * +@@ -649,6 +1043,13 @@ int pse_controller_register(struct pse_c + + mutex_init(&pcdev->lock); + INIT_LIST_HEAD(&pcdev->pse_control_head); ++ spin_lock_init(&pcdev->ntf_fifo_lock); ++ ret = kfifo_alloc(&pcdev->ntf_fifo, pcdev->nr_lines, GFP_KERNEL); ++ if (ret) { ++ dev_err(pcdev->dev, "failed to allocate kfifo notifications\n"); ++ return ret; ++ } ++ INIT_WORK(&pcdev->ntf_work, pse_send_ntf_worker); + + if (!pcdev->nr_lines) + pcdev->nr_lines = 1; +@@ -715,6 +1116,10 @@ void pse_controller_unregister(struct ps + { + pse_flush_pw_ds(pcdev); + pse_release_pis(pcdev); ++ if (pcdev->irq) ++ disable_irq(pcdev->irq); ++ cancel_work_sync(&pcdev->ntf_work); ++ kfifo_free(&pcdev->ntf_fifo); + mutex_lock(&pse_list_mutex); + list_del(&pcdev->list); + mutex_unlock(&pse_list_mutex); +@@ -787,6 +1192,52 @@ static unsigned long pse_to_regulator_no + } + + /** ++ * pse_set_config_isr - Set PSE control config according to the PSE ++ * notifications ++ * @pcdev: a pointer to the PSE ++ * @id: index of the PSE control ++ * @notifs: PSE event notifications ++ * ++ * Return: 0 on success and failure value on error ++ */ ++static int pse_set_config_isr(struct pse_controller_dev *pcdev, int id, ++ unsigned long notifs) ++{ ++ int ret = 0; ++ ++ if (notifs & PSE_BUDGET_EVAL_STRAT_DYNAMIC) ++ return 0; ++ ++ if ((notifs & ETHTOOL_C33_PSE_EVENT_DISCONNECTION) && ++ ((notifs & ETHTOOL_C33_PSE_EVENT_DETECTION) || ++ (notifs & ETHTOOL_C33_PSE_EVENT_CLASSIFICATION))) { ++ dev_dbg(pcdev->dev, ++ "PI %d: error, connection and disconnection reported simultaneously", ++ id); ++ return -EINVAL; ++ } ++ ++ if (notifs & ETHTOOL_C33_PSE_EVENT_CLASSIFICATION) { ++ struct netlink_ext_ack extack; ++ ++ pcdev->pi[id].isr_pd_detected = true; ++ if (pcdev->pi[id].admin_state_enabled) { ++ ret = _pse_pi_delivery_power_sw_pw_ctrl(pcdev, id, ++ &extack); ++ if (ret == -ERANGE) ++ ret = 0; ++ } ++ } else if (notifs & ETHTOOL_C33_PSE_EVENT_DISCONNECTION) { ++ if (pcdev->pi[id].admin_state_enabled && ++ pcdev->pi[id].isr_pd_detected) ++ ret = _pse_pi_disable(pcdev, id); ++ pcdev->pi[id].isr_pd_detected = false; ++ } ++ ++ return ret; ++} ++ ++/** + * pse_isr - IRQ handler for PSE + * @irq: irq number + * @data: pointer to user interrupt structure +@@ -808,36 +1259,42 @@ static irqreturn_t pse_isr(int irq, void + memset(h->notifs, 0, pcdev->nr_lines * sizeof(*h->notifs)); + mutex_lock(&pcdev->lock); + ret = desc->map_event(irq, pcdev, h->notifs, ¬ifs_mask); +- mutex_unlock(&pcdev->lock); +- if (ret || !notifs_mask) ++ if (ret || !notifs_mask) { ++ mutex_unlock(&pcdev->lock); + return IRQ_NONE; ++ } + + for_each_set_bit(i, ¬ifs_mask, pcdev->nr_lines) { + unsigned long notifs, rnotifs; +- struct net_device *netdev; +- struct pse_control *psec; ++ struct pse_ntf ntf = {}; + + /* Do nothing PI not described */ + if (!pcdev->pi[i].rdev) + continue; + + notifs = h->notifs[i]; ++ if (pse_pw_d_is_sw_pw_control(pcdev, pcdev->pi[i].pw_d)) { ++ ret = pse_set_config_isr(pcdev, i, notifs); ++ if (ret) ++ notifs |= ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR; ++ } ++ + dev_dbg(h->pcdev->dev, + "Sending PSE notification EVT 0x%lx\n", notifs); + +- psec = pse_control_find_by_id(pcdev, i); +- rtnl_lock(); +- netdev = pse_control_get_netdev(psec); +- if (netdev) +- ethnl_pse_send_ntf(netdev, notifs); +- rtnl_unlock(); +- pse_control_put(psec); ++ ntf.notifs = notifs; ++ ntf.id = i; ++ kfifo_in_spinlocked(&pcdev->ntf_fifo, &ntf, 1, ++ &pcdev->ntf_fifo_lock); ++ schedule_work(&pcdev->ntf_work); + + rnotifs = pse_to_regulator_notifs(notifs); + regulator_notifier_call_chain(pcdev->pi[i].rdev, rnotifs, + NULL); + } + ++ mutex_unlock(&pcdev->lock); ++ + return IRQ_HANDLED; + } + +@@ -960,6 +1417,20 @@ pse_control_get_internal(struct pse_cont + goto free_psec; + } + ++ if (!pcdev->ops->pi_get_admin_state) { ++ ret = -EOPNOTSUPP; ++ goto free_psec; ++ } ++ ++ /* Initialize admin_state_enabled before the regulator_get. This ++ * aims to have the right value reported in the first is_enabled ++ * call in case of control managed by software. ++ */ ++ ret = pse_pi_is_hw_enabled(pcdev, index); ++ if (ret < 0) ++ goto free_psec; ++ ++ pcdev->pi[index].admin_state_enabled = ret; + psec->ps = devm_regulator_get_exclusive(pcdev->dev, + rdev_get_name(pcdev->pi[index].rdev)); + if (IS_ERR(psec->ps)) { +@@ -967,12 +1438,6 @@ pse_control_get_internal(struct pse_cont + goto put_module; + } + +- ret = regulator_is_enabled(psec->ps); +- if (ret < 0) +- goto regulator_put; +- +- pcdev->pi[index].admin_state_enabled = ret; +- + psec->pcdev = pcdev; + list_add(&psec->list, &pcdev->pse_control_head); + psec->id = index; +@@ -981,8 +1446,6 @@ pse_control_get_internal(struct pse_cont + + return psec; + +-regulator_put: +- devm_regulator_put(psec->ps); + put_module: + module_put(pcdev->owner); + free_psec: +@@ -1094,6 +1557,35 @@ out: + EXPORT_SYMBOL_GPL(of_pse_control_get); + + /** ++ * pse_get_sw_admin_state - Convert the software admin state to c33 or podl ++ * admin state value used in the standard ++ * @psec: PSE control pointer ++ * @admin_state: a pointer to the admin_state structure ++ */ ++static void pse_get_sw_admin_state(struct pse_control *psec, ++ struct pse_admin_state *admin_state) ++{ ++ struct pse_pi *pi = &psec->pcdev->pi[psec->id]; ++ ++ if (pse_has_podl(psec)) { ++ if (pi->admin_state_enabled) ++ admin_state->podl_admin_state = ++ ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED; ++ else ++ admin_state->podl_admin_state = ++ ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED; ++ } ++ if (pse_has_c33(psec)) { ++ if (pi->admin_state_enabled) ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; ++ else ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; ++ } ++} ++ ++/** + * pse_ethtool_get_status - get status of PSE control + * @psec: PSE control pointer + * @extack: extack for reporting useful error messages +@@ -1109,19 +1601,46 @@ int pse_ethtool_get_status(struct pse_co + struct pse_pw_status pw_status = {0}; + const struct pse_controller_ops *ops; + struct pse_controller_dev *pcdev; ++ struct pse_pi *pi; + int ret; + + pcdev = psec->pcdev; + ops = pcdev->ops; ++ ++ pi = &pcdev->pi[psec->id]; + mutex_lock(&pcdev->lock); +- if (pcdev->pi[psec->id].pw_d) +- status->pw_d_id = pcdev->pi[psec->id].pw_d->id; ++ if (pi->pw_d) { ++ status->pw_d_id = pi->pw_d->id; ++ if (pse_pw_d_is_sw_pw_control(pcdev, pi->pw_d)) { ++ pse_get_sw_admin_state(psec, &admin_state); ++ } else { ++ ret = ops->pi_get_admin_state(pcdev, psec->id, ++ &admin_state); ++ if (ret) ++ goto out; ++ } ++ status->podl_admin_state = admin_state.podl_admin_state; ++ status->c33_admin_state = admin_state.c33_admin_state; + +- ret = ops->pi_get_admin_state(pcdev, psec->id, &admin_state); +- if (ret) +- goto out; +- status->podl_admin_state = admin_state.podl_admin_state; +- status->c33_admin_state = admin_state.c33_admin_state; ++ switch (pi->pw_d->budget_eval_strategy) { ++ case PSE_BUDGET_EVAL_STRAT_STATIC: ++ status->prio_max = pcdev->nr_lines - 1; ++ status->prio = pi->prio; ++ break; ++ case PSE_BUDGET_EVAL_STRAT_DYNAMIC: ++ status->prio_max = pcdev->pis_prio_max; ++ if (ops->pi_get_prio) { ++ ret = ops->pi_get_prio(pcdev, psec->id); ++ if (ret < 0) ++ goto out; ++ ++ status->prio = ret; ++ } ++ break; ++ default: ++ break; ++ } ++ } + + ret = ops->pi_get_pw_status(pcdev, psec->id, &pw_status); + if (ret) +@@ -1271,6 +1790,52 @@ int pse_ethtool_set_config(struct pse_co + EXPORT_SYMBOL_GPL(pse_ethtool_set_config); + + /** ++ * pse_pi_update_pw_budget - Update PSE power budget allocated with new ++ * power in mW ++ * @pcdev: a pointer to the PSE controller device ++ * @id: index of the PSE PI ++ * @pw_req: power requested ++ * @extack: extack for reporting useful error messages ++ * ++ * Return: Previous power allocated on success and failure value on error ++ */ ++static int pse_pi_update_pw_budget(struct pse_controller_dev *pcdev, int id, ++ const unsigned int pw_req, ++ struct netlink_ext_ack *extack) ++{ ++ struct pse_pi *pi = &pcdev->pi[id]; ++ int previous_pw_allocated; ++ int pw_diff, ret = 0; ++ ++ /* We don't want pw_allocated_mW value change in the middle of an ++ * power budget update ++ */ ++ mutex_lock(&pcdev->lock); ++ previous_pw_allocated = pi->pw_allocated_mW; ++ pw_diff = pw_req - previous_pw_allocated; ++ if (!pw_diff) { ++ goto out; ++ } else if (pw_diff > 0) { ++ ret = regulator_request_power_budget(pi->pw_d->supply, pw_diff); ++ if (ret) { ++ NL_SET_ERR_MSG_FMT(extack, ++ "PI %d: not enough power budget available", ++ id); ++ goto out; ++ } ++ ++ } else { ++ regulator_free_power_budget(pi->pw_d->supply, -pw_diff); ++ } ++ pi->pw_allocated_mW = pw_req; ++ ret = previous_pw_allocated; ++ ++out: ++ mutex_unlock(&pcdev->lock); ++ return ret; ++} ++ ++/** + * pse_ethtool_set_pw_limit - set PSE control power limit + * @psec: PSE control pointer + * @extack: extack for reporting useful error messages +@@ -1282,7 +1847,7 @@ int pse_ethtool_set_pw_limit(struct pse_ + struct netlink_ext_ack *extack, + const unsigned int pw_limit) + { +- int uV, uA, ret; ++ int uV, uA, ret, previous_pw_allocated = 0; + s64 tmp_64; + + if (pw_limit > MAX_PI_PW) +@@ -1306,10 +1871,100 @@ int pse_ethtool_set_pw_limit(struct pse_ + /* uA = mW * 1000000000 / uV */ + uA = DIV_ROUND_CLOSEST_ULL(tmp_64, uV); + +- return regulator_set_current_limit(psec->ps, 0, uA); ++ /* Update power budget only in software power control case and ++ * if a Power Device is powered. ++ */ ++ if (pse_pw_d_is_sw_pw_control(psec->pcdev, ++ psec->pcdev->pi[psec->id].pw_d) && ++ psec->pcdev->pi[psec->id].admin_state_enabled && ++ psec->pcdev->pi[psec->id].isr_pd_detected) { ++ ret = pse_pi_update_pw_budget(psec->pcdev, psec->id, ++ pw_limit, extack); ++ if (ret < 0) ++ return ret; ++ previous_pw_allocated = ret; ++ } ++ ++ ret = regulator_set_current_limit(psec->ps, 0, uA); ++ if (ret < 0 && previous_pw_allocated) { ++ pse_pi_update_pw_budget(psec->pcdev, psec->id, ++ previous_pw_allocated, extack); ++ } ++ ++ return ret; + } + EXPORT_SYMBOL_GPL(pse_ethtool_set_pw_limit); + ++/** ++ * pse_ethtool_set_prio - Set PSE PI priority according to the budget ++ * evaluation strategy ++ * @psec: PSE control pointer ++ * @extack: extack for reporting useful error messages ++ * @prio: priovity value ++ * ++ * Return: 0 on success and failure value on error ++ */ ++int pse_ethtool_set_prio(struct pse_control *psec, ++ struct netlink_ext_ack *extack, ++ unsigned int prio) ++{ ++ struct pse_controller_dev *pcdev = psec->pcdev; ++ const struct pse_controller_ops *ops; ++ int ret = 0; ++ ++ if (!pcdev->pi[psec->id].pw_d) { ++ NL_SET_ERR_MSG(extack, "no power domain attached"); ++ return -EOPNOTSUPP; ++ } ++ ++ /* We don't want priority change in the middle of an ++ * enable/disable call or a priority mode change ++ */ ++ mutex_lock(&pcdev->lock); ++ switch (pcdev->pi[psec->id].pw_d->budget_eval_strategy) { ++ case PSE_BUDGET_EVAL_STRAT_STATIC: ++ if (prio >= pcdev->nr_lines) { ++ NL_SET_ERR_MSG_FMT(extack, ++ "priority %d exceed priority max %d", ++ prio, pcdev->nr_lines); ++ ret = -ERANGE; ++ goto out; ++ } ++ ++ pcdev->pi[psec->id].prio = prio; ++ pse_pw_d_retry_power_delivery(pcdev, pcdev->pi[psec->id].pw_d); ++ break; ++ ++ case PSE_BUDGET_EVAL_STRAT_DYNAMIC: ++ ops = psec->pcdev->ops; ++ if (!ops->pi_set_prio) { ++ NL_SET_ERR_MSG(extack, ++ "pse driver does not support setting port priority"); ++ ret = -EOPNOTSUPP; ++ goto out; ++ } ++ ++ if (prio > pcdev->pis_prio_max) { ++ NL_SET_ERR_MSG_FMT(extack, ++ "priority %d exceed priority max %d", ++ prio, pcdev->pis_prio_max); ++ ret = -ERANGE; ++ goto out; ++ } ++ ++ ret = ops->pi_set_prio(pcdev, psec->id, prio); ++ break; ++ ++ default: ++ ret = -EOPNOTSUPP; ++ } ++ ++out: ++ mutex_unlock(&pcdev->lock); ++ return ret; ++} ++EXPORT_SYMBOL_GPL(pse_ethtool_set_prio); ++ + bool pse_has_podl(struct pse_control *psec) + { + return psec->pcdev->types & ETHTOOL_PSE_PODL; +--- a/include/linux/pse-pd/pse.h ++++ b/include/linux/pse-pd/pse.h +@@ -6,6 +6,8 @@ + #define _LINUX_PSE_CONTROLLER_H + + #include ++#include ++#include + #include + #include + #include +@@ -134,6 +136,9 @@ struct pse_pw_limit_ranges { + * is in charge of the memory allocation + * @c33_pw_limit_nb_ranges: number of supported power limit configuration + * ranges ++ * @prio_max: max priority allowed for the c33_prio variable value. ++ * @prio: priority of the PSE. Managed by PSE core in case of static budget ++ * evaluation strategy. + */ + struct ethtool_pse_control_status { + u32 pw_d_id; +@@ -147,6 +152,8 @@ struct ethtool_pse_control_status { + u32 c33_avail_pw_limit; + struct ethtool_c33_pse_pw_limit_range *c33_pw_limit_ranges; + u32 c33_pw_limit_nb_ranges; ++ u32 prio_max; ++ u32 prio; + }; + + /** +@@ -170,6 +177,11 @@ struct ethtool_pse_control_status { + * range. The driver is in charge of the memory + * allocation and should return the number of + * ranges. ++ * @pi_get_prio: Get the PSE PI priority. ++ * @pi_set_prio: Configure the PSE PI priority. ++ * @pi_get_pw_req: Get the power requested by a PD before enabling the PSE PI. ++ * This is only relevant when an interrupt is registered using ++ * devm_pse_irq_helper helper. + */ + struct pse_controller_ops { + int (*setup_pi_matrix)(struct pse_controller_dev *pcdev); +@@ -190,6 +202,10 @@ struct pse_controller_ops { + int id, int max_mW); + int (*pi_get_pw_limit_ranges)(struct pse_controller_dev *pcdev, int id, + struct pse_pw_limit_ranges *pw_limit_ranges); ++ int (*pi_get_prio)(struct pse_controller_dev *pcdev, int id); ++ int (*pi_set_prio)(struct pse_controller_dev *pcdev, int id, ++ unsigned int prio); ++ int (*pi_get_pw_req)(struct pse_controller_dev *pcdev, int id); + }; + + struct module; +@@ -225,6 +241,13 @@ struct pse_pi_pairset { + * @rdev: regulator represented by the PSE PI + * @admin_state_enabled: PI enabled state + * @pw_d: Power domain of the PSE PI ++ * @prio: Priority of the PSE PI. Used in static budget evaluation strategy ++ * @isr_pd_detected: PSE PI detection status managed by the interruption ++ * handler. This variable is relevant when the power enabled ++ * management is managed in software like the static ++ * budget evaluation strategy. ++ * @pw_allocated_mW: Power allocated to a PSE PI to manage power budget in ++ * static budget evaluation strategy. + */ + struct pse_pi { + struct pse_pi_pairset pairset[2]; +@@ -232,6 +255,20 @@ struct pse_pi { + struct regulator_dev *rdev; + bool admin_state_enabled; + struct pse_power_domain *pw_d; ++ int prio; ++ bool isr_pd_detected; ++ int pw_allocated_mW; ++}; ++ ++/** ++ * struct pse_ntf - PSE notification element ++ * ++ * @id: ID of the PSE control ++ * @notifs: PSE notifications to be reported ++ */ ++struct pse_ntf { ++ int id; ++ unsigned long notifs; + }; + + /** +@@ -249,6 +286,12 @@ struct pse_pi { + * @pi: table of PSE PIs described in this controller device + * @no_of_pse_pi: flag set if the pse_pis devicetree node is not used + * @irq: PSE interrupt ++ * @pis_prio_max: Maximum value allowed for the PSE PIs priority ++ * @supp_budget_eval_strategies: budget evaluation strategies supported ++ * by the PSE ++ * @ntf_work: workqueue for PSE notification management ++ * @ntf_fifo: PSE notifications FIFO ++ * @ntf_fifo_lock: protect @ntf_fifo writer + */ + struct pse_controller_dev { + const struct pse_controller_ops *ops; +@@ -263,6 +306,29 @@ struct pse_controller_dev { + struct pse_pi *pi; + bool no_of_pse_pi; + int irq; ++ unsigned int pis_prio_max; ++ u32 supp_budget_eval_strategies; ++ struct work_struct ntf_work; ++ DECLARE_KFIFO_PTR(ntf_fifo, struct pse_ntf); ++ spinlock_t ntf_fifo_lock; /* Protect @ntf_fifo writer */ ++}; ++ ++/** ++ * enum pse_budget_eval_strategies - PSE budget evaluation strategies. ++ * @PSE_BUDGET_EVAL_STRAT_DISABLED: Budget evaluation strategy disabled. ++ * @PSE_BUDGET_EVAL_STRAT_STATIC: PSE static budget evaluation strategy. ++ * Budget evaluation strategy based on the power requested during PD ++ * classification. This strategy is managed by the PSE core. ++ * @PSE_BUDGET_EVAL_STRAT_DYNAMIC: PSE dynamic budget evaluation ++ * strategy. Budget evaluation strategy based on the current consumption ++ * per ports compared to the total power budget. This mode is managed by ++ * the PSE controller. ++ */ ++ ++enum pse_budget_eval_strategies { ++ PSE_BUDGET_EVAL_STRAT_DISABLED = 1 << 0, ++ PSE_BUDGET_EVAL_STRAT_STATIC = 1 << 1, ++ PSE_BUDGET_EVAL_STRAT_DYNAMIC = 1 << 2, + }; + + #if IS_ENABLED(CONFIG_PSE_CONTROLLER) +@@ -287,6 +353,9 @@ int pse_ethtool_set_config(struct pse_co + int pse_ethtool_set_pw_limit(struct pse_control *psec, + struct netlink_ext_ack *extack, + const unsigned int pw_limit); ++int pse_ethtool_set_prio(struct pse_control *psec, ++ struct netlink_ext_ack *extack, ++ unsigned int prio); + int pse_ethtool_get_pw_limit(struct pse_control *psec, + struct netlink_ext_ack *extack); + +@@ -331,6 +400,13 @@ static inline int pse_ethtool_get_pw_lim + { + return -EOPNOTSUPP; + } ++ ++static inline int pse_ethtool_set_prio(struct pse_control *psec, ++ struct netlink_ext_ack *extack, ++ unsigned int prio) ++{ ++ return -EOPNOTSUPP; ++} + + static inline bool pse_has_podl(struct pse_control *psec) + { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-16b-v6.17-regulator-Add-support-for-power-budget.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-16b-v6.17-regulator-Add-support-for-power-budget.patch new file mode 100755 index 0000000..8f63044 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-16b-v6.17-regulator-Add-support-for-power-budget.patch @@ -0,0 +1,257 @@ +From 42d7c87b4e1251f36eceac987e74623e7cda8577 Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Wed, 15 Jan 2025 15:41:57 +0100 +Subject: [PATCH] regulator: Add support for power budget + +Introduce power budget management for the regulator device. Enable tracking +of available power capacity by providing helpers to request and release +power budget allocations. + +Signed-off-by: Kory Maincent +Link: https://patch.msgid.link/20250115-feature_regulator_pw_budget-v2-1-0a44b949e6bc@bootlin.com +Signed-off-by: Mark Brown +Signed-off-by: Bevan Weiss +--- + drivers/regulator/core.c | 114 +++++++++++++++++++++++++++++ + drivers/regulator/of_regulator.c | 3 + + include/linux/regulator/consumer.h | 21 ++++++ + include/linux/regulator/driver.h | 2 + + include/linux/regulator/machine.h | 2 + + 5 files changed, 142 insertions(+) + +--- a/drivers/regulator/core.c ++++ b/drivers/regulator/core.c +@@ -916,6 +916,26 @@ static ssize_t bypass_show(struct device + } + static DEVICE_ATTR_RO(bypass); + ++static ssize_t power_budget_milliwatt_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct regulator_dev *rdev = dev_get_drvdata(dev); ++ ++ return sprintf(buf, "%d\n", rdev->constraints->pw_budget_mW); ++} ++static DEVICE_ATTR_RO(power_budget_milliwatt); ++ ++static ssize_t power_requested_milliwatt_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct regulator_dev *rdev = dev_get_drvdata(dev); ++ ++ return sprintf(buf, "%d\n", rdev->pw_requested_mW); ++} ++static DEVICE_ATTR_RO(power_requested_milliwatt); ++ + #define REGULATOR_ERROR_ATTR(name, bit) \ + static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \ + char *buf) \ +@@ -1148,6 +1168,10 @@ static void print_constraints_debug(stru + if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY) + count += scnprintf(buf + count, len - count, "standby "); + ++ if (constraints->pw_budget_mW) ++ count += scnprintf(buf + count, len - count, "%d mW budget", ++ constraints->pw_budget_mW); ++ + if (!count) + count = scnprintf(buf, len, "no parameters"); + else +@@ -1631,6 +1655,9 @@ static int set_machine_constraints(struc + rdev->last_off = ktime_get(); + } + ++ if (!rdev->constraints->pw_budget_mW) ++ rdev->constraints->pw_budget_mW = INT_MAX; ++ + print_constraints(rdev); + return 0; + } +@@ -4646,6 +4673,87 @@ int regulator_get_current_limit(struct r + EXPORT_SYMBOL_GPL(regulator_get_current_limit); + + /** ++ * regulator_get_unclaimed_power_budget - get regulator unclaimed power budget ++ * @regulator: regulator source ++ * ++ * Return: Unclaimed power budget of the regulator in mW. ++ */ ++int regulator_get_unclaimed_power_budget(struct regulator *regulator) ++{ ++ return regulator->rdev->constraints->pw_budget_mW - ++ regulator->rdev->pw_requested_mW; ++} ++EXPORT_SYMBOL_GPL(regulator_get_unclaimed_power_budget); ++ ++/** ++ * regulator_request_power_budget - request power budget on a regulator ++ * @regulator: regulator source ++ * @pw_req: Power requested ++ * ++ * Return: 0 on success or a negative error number on failure. ++ */ ++int regulator_request_power_budget(struct regulator *regulator, ++ unsigned int pw_req) ++{ ++ struct regulator_dev *rdev = regulator->rdev; ++ int ret = 0, pw_tot_req; ++ ++ regulator_lock(rdev); ++ if (rdev->supply) { ++ ret = regulator_request_power_budget(rdev->supply, pw_req); ++ if (ret < 0) ++ goto out; ++ } ++ ++ pw_tot_req = rdev->pw_requested_mW + pw_req; ++ if (pw_tot_req > rdev->constraints->pw_budget_mW) { ++ rdev_warn(rdev, "power requested %d mW out of budget %d mW", ++ pw_req, ++ rdev->constraints->pw_budget_mW - rdev->pw_requested_mW); ++ regulator_notifier_call_chain(rdev, ++ REGULATOR_EVENT_OVER_CURRENT_WARN, ++ NULL); ++ ret = -ERANGE; ++ goto out; ++ } ++ ++ rdev->pw_requested_mW = pw_tot_req; ++out: ++ regulator_unlock(rdev); ++ return ret; ++} ++EXPORT_SYMBOL_GPL(regulator_request_power_budget); ++ ++/** ++ * regulator_free_power_budget - free power budget on a regulator ++ * @regulator: regulator source ++ * @pw: Power to be released. ++ * ++ * Return: Power budget of the regulator in mW. ++ */ ++void regulator_free_power_budget(struct regulator *regulator, ++ unsigned int pw) ++{ ++ struct regulator_dev *rdev = regulator->rdev; ++ int pw_tot_req; ++ ++ regulator_lock(rdev); ++ if (rdev->supply) ++ regulator_free_power_budget(rdev->supply, pw); ++ ++ pw_tot_req = rdev->pw_requested_mW - pw; ++ if (pw_tot_req >= 0) ++ rdev->pw_requested_mW = pw_tot_req; ++ else ++ rdev_warn(rdev, ++ "too much power freed %d mW (already requested %d mW)", ++ pw, rdev->pw_requested_mW); ++ ++ regulator_unlock(rdev); ++} ++EXPORT_SYMBOL_GPL(regulator_free_power_budget); ++ ++/** + * regulator_set_mode - set regulator operating mode + * @regulator: regulator source + * @mode: operating mode - one of the REGULATOR_MODE constants +@@ -5283,6 +5391,8 @@ static struct attribute *regulator_dev_a + &dev_attr_suspend_standby_mode.attr, + &dev_attr_suspend_mem_mode.attr, + &dev_attr_suspend_disk_mode.attr, ++ &dev_attr_power_budget_milliwatt.attr, ++ &dev_attr_power_requested_milliwatt.attr, + NULL + }; + +@@ -5364,6 +5474,10 @@ static umode_t regulator_attr_is_visible + attr == &dev_attr_suspend_disk_mode.attr) + return ops->set_suspend_mode ? mode : 0; + ++ if (attr == &dev_attr_power_budget_milliwatt.attr || ++ attr == &dev_attr_power_requested_milliwatt.attr) ++ return rdev->constraints->pw_budget_mW != INT_MAX ? mode : 0; ++ + return mode; + } + +--- a/drivers/regulator/of_regulator.c ++++ b/drivers/regulator/of_regulator.c +@@ -125,6 +125,9 @@ static int of_get_regulation_constraints + if (constraints->min_uA != constraints->max_uA) + constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; + ++ if (!of_property_read_u32(np, "regulator-power-budget-milliwatt", &pval)) ++ constraints->pw_budget_mW = pval; ++ + constraints->boot_on = of_property_read_bool(np, "regulator-boot-on"); + constraints->always_on = of_property_read_bool(np, "regulator-always-on"); + if (!constraints->always_on) /* status change should be possible. */ +--- a/include/linux/regulator/consumer.h ++++ b/include/linux/regulator/consumer.h +@@ -235,6 +235,11 @@ int regulator_sync_voltage(struct regula + int regulator_set_current_limit(struct regulator *regulator, + int min_uA, int max_uA); + int regulator_get_current_limit(struct regulator *regulator); ++int regulator_get_unclaimed_power_budget(struct regulator *regulator); ++int regulator_request_power_budget(struct regulator *regulator, ++ unsigned int pw_req); ++void regulator_free_power_budget(struct regulator *regulator, ++ unsigned int pw); + + int regulator_set_mode(struct regulator *regulator, unsigned int mode); + unsigned int regulator_get_mode(struct regulator *regulator); +@@ -534,6 +539,22 @@ static inline int regulator_get_current_ + return 0; + } + ++static inline int regulator_get_unclaimed_power_budget(struct regulator *regulator) ++{ ++ return INT_MAX; ++} ++ ++static inline int regulator_request_power_budget(struct regulator *regulator, ++ unsigned int pw_req) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static inline void regulator_free_power_budget(struct regulator *regulator, ++ unsigned int pw) ++{ ++} ++ + static inline int regulator_set_mode(struct regulator *regulator, + unsigned int mode) + { +--- a/include/linux/regulator/driver.h ++++ b/include/linux/regulator/driver.h +@@ -649,6 +649,8 @@ struct regulator_dev { + int cached_err; + bool use_cached_err; + spinlock_t err_lock; ++ ++ int pw_requested_mW; + }; + + /* +--- a/include/linux/regulator/machine.h ++++ b/include/linux/regulator/machine.h +@@ -113,6 +113,7 @@ struct notification_limit { + * @min_uA: Smallest current consumers may set. + * @max_uA: Largest current consumers may set. + * @ilim_uA: Maximum input current. ++ * @pw_budget_mW: Power budget for the regulator in mW. + * @system_load: Load that isn't captured by any consumer requests. + * + * @over_curr_limits: Limits for acting on over current. +@@ -185,6 +186,7 @@ struct regulation_constraints { + int max_uA; + int ilim_uA; + ++ int pw_budget_mW; + int system_load; + + /* used for coupled regulators */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-17-v6.17-net-pse-pd-pd692x0-Add-PSE-PI-priority-feature.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-17-v6.17-net-pse-pd-pd692x0-Add-PSE-PI-priority-feature.patch new file mode 100755 index 0000000..6e1f2d6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-17-v6.17-net-pse-pd-pd692x0-Add-PSE-PI-priority-feature.patch @@ -0,0 +1,326 @@ +From 359754013e6a7fc81af6735ebbfedd4a01999f68 Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:08 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Add support for PSE PI priority feature + +This patch extends the PSE callbacks by adding support for the newly +introduced pi_set_prio() callback, enabling the configuration of PSE PI +priorities. The current port priority is now also included in the status +information returned to users. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-9-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 205 +++++++++++++++++++++++++++++++++++ + 1 file changed, 205 insertions(+) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -12,6 +12,8 @@ + #include + #include + #include ++#include ++#include + + #define PD692X0_PSE_NAME "pd692x0_pse" + +@@ -76,6 +78,8 @@ enum { + PD692X0_MSG_GET_PORT_CLASS, + PD692X0_MSG_GET_PORT_MEAS, + PD692X0_MSG_GET_PORT_PARAM, ++ PD692X0_MSG_GET_POWER_BANK, ++ PD692X0_MSG_SET_POWER_BANK, + + /* add new message above here */ + PD692X0_MSG_CNT +@@ -95,6 +99,8 @@ struct pd692x0_priv { + unsigned long last_cmd_key_time; + + enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS]; ++ struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS]; ++ int manager_pw_budget[PD692X0_MAX_MANAGERS]; + }; + + /* Template list of communication messages. The non-null bytes defined here +@@ -170,6 +176,16 @@ static const struct pd692x0_msg pd692x0_ + .data = {0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4e, 0x4e}, + }, ++ [PD692X0_MSG_GET_POWER_BANK] = { ++ .key = PD692X0_KEY_REQ, ++ .sub = {0x07, 0x0b, 0x57}, ++ .data = { 0, 0x4e, 0x4e, 0x4e, ++ 0x4e, 0x4e, 0x4e, 0x4e}, ++ }, ++ [PD692X0_MSG_SET_POWER_BANK] = { ++ .key = PD692X0_KEY_CMD, ++ .sub = {0x07, 0x0b, 0x57}, ++ }, + }; + + static u8 pd692x0_build_msg(struct pd692x0_msg *msg, u8 echo) +@@ -739,6 +755,29 @@ pd692x0_pi_get_actual_pw(struct pse_cont + return (buf.data[0] << 4 | buf.data[1]) * 100; + } + ++static int ++pd692x0_pi_get_prio(struct pse_controller_dev *pcdev, int id) ++{ ++ struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); ++ struct pd692x0_msg msg, buf = {0}; ++ int ret; ++ ++ ret = pd692x0_fw_unavailable(priv); ++ if (ret) ++ return ret; ++ ++ msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_PARAM]; ++ msg.sub[2] = id; ++ ret = pd692x0_sendrecv_msg(priv, &msg, &buf); ++ if (ret < 0) ++ return ret; ++ if (!buf.data[2] || buf.data[2] > pcdev->pis_prio_max + 1) ++ return -ERANGE; ++ ++ /* PSE core priority start at 0 */ ++ return buf.data[2] - 1; ++} ++ + static struct pd692x0_msg_ver pd692x0_get_sw_version(struct pd692x0_priv *priv) + { + struct device *dev = &priv->client->dev; +@@ -766,6 +805,7 @@ static struct pd692x0_msg_ver pd692x0_ge + + struct pd692x0_manager { + struct device_node *port_node[PD692X0_MAX_MANAGER_PORTS]; ++ struct device_node *node; + int nports; + }; + +@@ -857,6 +897,8 @@ pd692x0_of_get_managers(struct pd692x0_p + if (ret) + goto out; + ++ of_node_get(node); ++ manager[manager_id].node = node; + nmanagers++; + } + +@@ -869,6 +911,8 @@ out: + of_node_put(manager[i].port_node[j]); + manager[i].port_node[j] = NULL; + } ++ of_node_put(manager[i].node); ++ manager[i].node = NULL; + } + + of_node_put(node); +@@ -876,6 +920,130 @@ out: + return ret; + } + ++static const struct regulator_ops dummy_ops; ++ ++static struct regulator_dev * ++pd692x0_register_manager_regulator(struct device *dev, char *reg_name, ++ struct device_node *node) ++{ ++ struct regulator_init_data *rinit_data; ++ struct regulator_config rconfig = {0}; ++ struct regulator_desc *rdesc; ++ struct regulator_dev *rdev; ++ ++ rinit_data = devm_kzalloc(dev, sizeof(*rinit_data), ++ GFP_KERNEL); ++ if (!rinit_data) ++ return ERR_PTR(-ENOMEM); ++ ++ rdesc = devm_kzalloc(dev, sizeof(*rdesc), GFP_KERNEL); ++ if (!rdesc) ++ return ERR_PTR(-ENOMEM); ++ ++ rdesc->name = reg_name; ++ rdesc->type = REGULATOR_VOLTAGE; ++ rdesc->ops = &dummy_ops; ++ rdesc->owner = THIS_MODULE; ++ ++ rinit_data->supply_regulator = "vmain"; ++ ++ rconfig.dev = dev; ++ rconfig.init_data = rinit_data; ++ rconfig.of_node = node; ++ ++ rdev = devm_regulator_register(dev, rdesc, &rconfig); ++ if (IS_ERR(rdev)) { ++ dev_err_probe(dev, PTR_ERR(rdev), ++ "Failed to register regulator\n"); ++ return rdev; ++ } ++ ++ return rdev; ++} ++ ++static int ++pd692x0_register_managers_regulator(struct pd692x0_priv *priv, ++ const struct pd692x0_manager *manager, ++ int nmanagers) ++{ ++ struct device *dev = &priv->client->dev; ++ size_t reg_name_len; ++ int i; ++ ++ /* Each regulator name len is dev name + 12 char + ++ * int max digit number (10) + 1 ++ */ ++ reg_name_len = strlen(dev_name(dev)) + 23; ++ ++ for (i = 0; i < nmanagers; i++) { ++ struct regulator_dev *rdev; ++ char *reg_name; ++ ++ reg_name = devm_kzalloc(dev, reg_name_len, GFP_KERNEL); ++ if (!reg_name) ++ return -ENOMEM; ++ snprintf(reg_name, 26, "pse-%s-manager%d", dev_name(dev), i); ++ rdev = pd692x0_register_manager_regulator(dev, reg_name, ++ manager[i].node); ++ if (IS_ERR(rdev)) ++ return PTR_ERR(rdev); ++ ++ priv->manager_reg[i] = rdev; ++ } ++ ++ return 0; ++} ++ ++static int ++pd692x0_conf_manager_power_budget(struct pd692x0_priv *priv, int id, int pw) ++{ ++ struct pd692x0_msg msg, buf; ++ int ret, pw_mW = pw / 1000; ++ ++ msg = pd692x0_msg_template_list[PD692X0_MSG_GET_POWER_BANK]; ++ msg.data[0] = id; ++ ret = pd692x0_sendrecv_msg(priv, &msg, &buf); ++ if (ret < 0) ++ return ret; ++ ++ msg = pd692x0_msg_template_list[PD692X0_MSG_SET_POWER_BANK]; ++ msg.data[0] = id; ++ msg.data[1] = pw_mW >> 8; ++ msg.data[2] = pw_mW & 0xff; ++ msg.data[3] = buf.sub[2]; ++ msg.data[4] = buf.data[0]; ++ msg.data[5] = buf.data[1]; ++ msg.data[6] = buf.data[2]; ++ msg.data[7] = buf.data[3]; ++ return pd692x0_sendrecv_msg(priv, &msg, &buf); ++} ++ ++static int ++pd692x0_configure_managers(struct pd692x0_priv *priv, int nmanagers) ++{ ++ int i, ret; ++ ++ for (i = 0; i < nmanagers; i++) { ++ struct regulator *supply = priv->manager_reg[i]->supply; ++ int pw_budget; ++ ++ pw_budget = regulator_get_unclaimed_power_budget(supply); ++ /* Max power budget per manager */ ++ if (pw_budget > 6000000) ++ pw_budget = 6000000; ++ ret = regulator_request_power_budget(supply, pw_budget); ++ if (ret < 0) ++ return ret; ++ ++ priv->manager_pw_budget[i] = pw_budget; ++ ret = pd692x0_conf_manager_power_budget(priv, i, pw_budget); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return 0; ++} ++ + static int + pd692x0_set_port_matrix(const struct pse_pi_pairset *pairset, + const struct pd692x0_manager *manager, +@@ -998,6 +1166,14 @@ static int pd692x0_setup_pi_matrix(struc + return ret; + + nmanagers = ret; ++ ret = pd692x0_register_managers_regulator(priv, manager, nmanagers); ++ if (ret) ++ goto out; ++ ++ ret = pd692x0_configure_managers(priv, nmanagers); ++ if (ret) ++ goto out; ++ + ret = pd692x0_set_ports_matrix(priv, manager, nmanagers, port_matrix); + if (ret) + goto out; +@@ -1008,8 +1184,14 @@ static int pd692x0_setup_pi_matrix(struc + + out: + for (i = 0; i < nmanagers; i++) { ++ struct regulator *supply = priv->manager_reg[i]->supply; ++ ++ regulator_free_power_budget(supply, ++ priv->manager_pw_budget[i]); ++ + for (j = 0; j < manager[i].nports; j++) + of_node_put(manager[i].port_node[j]); ++ of_node_put(manager[i].node); + } + return ret; + } +@@ -1071,6 +1253,25 @@ static int pd692x0_pi_set_pw_limit(struc + return pd692x0_sendrecv_msg(priv, &msg, &buf); + } + ++static int pd692x0_pi_set_prio(struct pse_controller_dev *pcdev, int id, ++ unsigned int prio) ++{ ++ struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); ++ struct pd692x0_msg msg, buf = {0}; ++ int ret; ++ ++ ret = pd692x0_fw_unavailable(priv); ++ if (ret) ++ return ret; ++ ++ msg = pd692x0_msg_template_list[PD692X0_MSG_SET_PORT_PARAM]; ++ msg.sub[2] = id; ++ /* Controller priority from 1 to 3 */ ++ msg.data[4] = prio + 1; ++ ++ return pd692x0_sendrecv_msg(priv, &msg, &buf); ++} ++ + static const struct pse_controller_ops pd692x0_ops = { + .setup_pi_matrix = pd692x0_setup_pi_matrix, + .pi_get_admin_state = pd692x0_pi_get_admin_state, +@@ -1084,6 +1285,8 @@ static const struct pse_controller_ops p + .pi_get_pw_limit = pd692x0_pi_get_pw_limit, + .pi_set_pw_limit = pd692x0_pi_set_pw_limit, + .pi_get_pw_limit_ranges = pd692x0_pi_get_pw_limit_ranges, ++ .pi_get_prio = pd692x0_pi_get_prio, ++ .pi_set_prio = pd692x0_pi_set_prio, + }; + + #define PD692X0_FW_LINE_MAX_SZ 0xff +@@ -1500,6 +1703,8 @@ static int pd692x0_i2c_probe(struct i2c_ + priv->pcdev.ops = &pd692x0_ops; + priv->pcdev.dev = dev; + priv->pcdev.types = ETHTOOL_PSE_C33; ++ priv->pcdev.supp_budget_eval_strategies = PSE_BUDGET_EVAL_STRAT_DYNAMIC; ++ priv->pcdev.pis_prio_max = 2; + ret = devm_pse_controller_register(dev, &priv->pcdev); + if (ret) + return dev_err_probe(dev, ret, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-18-v6.17-net-pse-pd-pd692x0-Add-controller-and-manager-power.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-18-v6.17-net-pse-pd-pd692x0-Add-controller-and-manager-power.patch new file mode 100755 index 0000000..a93dca0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-18-v6.17-net-pse-pd-pd692x0-Add-controller-and-manager-power.patch @@ -0,0 +1,71 @@ +From 24a4e3a05dd0eadd0c9585c411880e5dcb6be97f Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:09 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Add support for controller and manager + power supplies + +Add support for managing the VDD and VDDA power supplies for the PD692x0 +PSE controller, as well as the VAUX5 and VAUX3P3 power supplies for the +PD6920x PSE managers. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-10-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -976,8 +976,10 @@ pd692x0_register_managers_regulator(stru + reg_name_len = strlen(dev_name(dev)) + 23; + + for (i = 0; i < nmanagers; i++) { ++ static const char * const regulators[] = { "vaux5", "vaux3p3" }; + struct regulator_dev *rdev; + char *reg_name; ++ int ret; + + reg_name = devm_kzalloc(dev, reg_name_len, GFP_KERNEL); + if (!reg_name) +@@ -988,6 +990,17 @@ pd692x0_register_managers_regulator(stru + if (IS_ERR(rdev)) + return PTR_ERR(rdev); + ++ /* VMAIN is described as main supply for the manager. ++ * Add other VAUX power supplies and link them to the ++ * virtual device rdev->dev. ++ */ ++ ret = devm_regulator_bulk_get_enable(&rdev->dev, ++ ARRAY_SIZE(regulators), ++ regulators); ++ if (ret) ++ return dev_err_probe(&rdev->dev, ret, ++ "Failed to enable regulators\n"); ++ + priv->manager_reg[i] = rdev; + } + +@@ -1640,6 +1653,7 @@ static const struct fw_upload_ops pd692x + + static int pd692x0_i2c_probe(struct i2c_client *client) + { ++ static const char * const regulators[] = { "vdd", "vdda" }; + struct pd692x0_msg msg, buf = {0}, zero = {0}; + struct device *dev = &client->dev; + struct pd692x0_msg_ver ver; +@@ -1647,6 +1661,12 @@ static int pd692x0_i2c_probe(struct i2c_ + struct fw_upload *fwl; + int ret; + ++ ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), ++ regulators); ++ if (ret) ++ return dev_err_probe(dev, ret, ++ "Failed to enable regulators\n"); ++ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + dev_err(dev, "i2c check functionality failed\n"); + return -ENXIO; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-19-v6.17-net-pse-pd-tps23881-Add-static-port-priority-feature.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-19-v6.17-net-pse-pd-tps23881-Add-static-port-priority-feature.patch new file mode 100755 index 0000000..739233a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-19-v6.17-net-pse-pd-tps23881-Add-static-port-priority-feature.patch @@ -0,0 +1,392 @@ +From 56cfc97635e9164395c9242f72746454347155ab Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:11 +0200 +Subject: [PATCH] net: pse-pd: tps23881: Add support for static port priority + feature + +This patch enhances PSE callbacks by introducing support for the static +port priority feature. It extends interrupt management to handle and report +detection, classification, and disconnection events. Additionally, it +introduces the pi_get_pw_req() callback, which provides information about +the power requested by the Powered Devices. + +Interrupt support is essential for the proper functioning of the TPS23881 +controller. Without it, after a power-on (PWON), the controller will +no longer perform detection and classification. This could lead to +potential hazards, such as connecting a non-PoE device after a PoE device, +which might result in magic smoke. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-12-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 244 +++++++++++++++++++++++++++++++--- + 1 file changed, 228 insertions(+), 16 deletions(-) + +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -20,20 +20,30 @@ + + #define TPS23881_REG_IT 0x0 + #define TPS23881_REG_IT_MASK 0x1 ++#define TPS23881_REG_IT_DISF BIT(2) ++#define TPS23881_REG_IT_DETC BIT(3) ++#define TPS23881_REG_IT_CLASC BIT(4) + #define TPS23881_REG_IT_IFAULT BIT(5) + #define TPS23881_REG_IT_SUPF BIT(7) ++#define TPS23881_REG_DET_EVENT 0x5 + #define TPS23881_REG_FAULT 0x7 + #define TPS23881_REG_SUPF_EVENT 0xb + #define TPS23881_REG_TSD BIT(7) ++#define TPS23881_REG_DISC 0xc + #define TPS23881_REG_PW_STATUS 0x10 + #define TPS23881_REG_OP_MODE 0x12 ++#define TPS23881_REG_DISC_EN 0x13 + #define TPS23881_OP_MODE_SEMIAUTO 0xaaaa + #define TPS23881_REG_DIS_EN 0x13 + #define TPS23881_REG_DET_CLA_EN 0x14 + #define TPS23881_REG_GEN_MASK 0x17 ++#define TPS23881_REG_CLCHE BIT(2) ++#define TPS23881_REG_DECHE BIT(3) + #define TPS23881_REG_NBITACC BIT(5) + #define TPS23881_REG_INTEN BIT(7) + #define TPS23881_REG_PW_EN 0x19 ++#define TPS23881_REG_RESET 0x1a ++#define TPS23881_REG_CLRAIN BIT(7) + #define TPS23881_REG_2PAIR_POL1 0x1e + #define TPS23881_REG_PORT_MAP 0x26 + #define TPS23881_REG_PORT_POWER 0x29 +@@ -178,6 +188,7 @@ static int tps23881_pi_enable(struct pse + struct i2c_client *client = priv->client; + u8 chan; + u16 val; ++ int ret; + + if (id >= TPS23881_MAX_CHANS) + return -ERANGE; +@@ -191,7 +202,22 @@ static int tps23881_pi_enable(struct pse + BIT(chan % 4)); + } + +- return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val); ++ if (ret) ++ return ret; ++ ++ /* Enable DC disconnect*/ ++ chan = priv->port[id].chan[0]; ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_DISC_EN); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_set_val(ret, chan, 0, BIT(chan % 4), BIT(chan % 4)); ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_DISC_EN, val); ++ if (ret) ++ return ret; ++ ++ return 0; + } + + static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id) +@@ -224,6 +250,17 @@ static int tps23881_pi_disable(struct ps + */ + mdelay(5); + ++ /* Disable DC disconnect*/ ++ chan = priv->port[id].chan[0]; ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_DISC_EN); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_set_val(ret, chan, 0, 0, BIT(chan % 4)); ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_DISC_EN, val); ++ if (ret) ++ return ret; ++ + /* Enable detection and classification */ + ret = i2c_smbus_read_word_data(client, TPS23881_REG_DET_CLA_EN); + if (ret < 0) +@@ -919,6 +956,47 @@ static int tps23881_setup_pi_matrix(stru + return ret; + } + ++static int tps23881_power_class_table[] = { ++ -ERANGE, ++ 4000, ++ 7000, ++ 15500, ++ 30000, ++ 15500, ++ 15500, ++ -ERANGE, ++ 45000, ++ 60000, ++ 75000, ++ 90000, ++ 15500, ++ 45000, ++ -ERANGE, ++ -ERANGE, ++}; ++ ++static int tps23881_pi_get_pw_req(struct pse_controller_dev *pcdev, int id) ++{ ++ struct tps23881_priv *priv = to_tps23881_priv(pcdev); ++ struct i2c_client *client = priv->client; ++ u8 reg, chan; ++ int ret; ++ u16 val; ++ ++ /* For a 4-pair the classification need 5ms to be completed */ ++ if (priv->port[id].is_4p) ++ mdelay(5); ++ ++ chan = priv->port[id].chan[0]; ++ reg = TPS23881_REG_DISC + (chan % 4); ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_calc_val(ret, chan, 4, 0xf); ++ return tps23881_power_class_table[val]; ++} ++ + static const struct pse_controller_ops tps23881_ops = { + .setup_pi_matrix = tps23881_setup_pi_matrix, + .pi_enable = tps23881_pi_enable, +@@ -931,6 +1009,7 @@ static const struct pse_controller_ops t + .pi_get_pw_limit = tps23881_pi_get_pw_limit, + .pi_set_pw_limit = tps23881_pi_set_pw_limit, + .pi_get_pw_limit_ranges = tps23881_pi_get_pw_limit_ranges, ++ .pi_get_pw_req = tps23881_pi_get_pw_req, + }; + + static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin"; +@@ -1088,17 +1167,113 @@ static void tps23881_irq_event_over_temp + } + } + +-static void tps23881_irq_event_over_current(struct tps23881_priv *priv, +- u16 reg_val, +- unsigned long *notifs, +- unsigned long *notifs_mask) ++static int tps23881_irq_event_over_current(struct tps23881_priv *priv, ++ u16 reg_val, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) + { ++ int i, ret; + u8 chans; + + chans = tps23881_irq_export_chans_helper(reg_val, 0); ++ if (!chans) ++ return 0; ++ ++ tps23881_set_notifs_helper(priv, chans, notifs, notifs_mask, ++ ETHTOOL_PSE_EVENT_OVER_CURRENT | ++ ETHTOOL_C33_PSE_EVENT_DISCONNECTION); ++ ++ /* Over Current event resets the power limit registers so we need ++ * to configured it again. ++ */ ++ for_each_set_bit(i, notifs_mask, priv->pcdev.nr_lines) { ++ if (priv->port[i].pw_pol < 0) ++ continue; ++ ++ ret = tps23881_pi_enable_manual_pol(priv, i); ++ if (ret < 0) ++ return ret; ++ ++ /* Set power policy */ ++ ret = tps23881_pi_set_pw_pol_limit(priv, i, ++ priv->port[i].pw_pol, ++ priv->port[i].is_4p); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static void tps23881_irq_event_disconnection(struct tps23881_priv *priv, ++ u16 reg_val, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ u8 chans; ++ ++ chans = tps23881_irq_export_chans_helper(reg_val, 4); + if (chans) + tps23881_set_notifs_helper(priv, chans, notifs, notifs_mask, +- ETHTOOL_PSE_EVENT_OVER_CURRENT); ++ ETHTOOL_C33_PSE_EVENT_DISCONNECTION); ++} ++ ++static int tps23881_irq_event_detection(struct tps23881_priv *priv, ++ u16 reg_val, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ enum ethtool_pse_event event; ++ int reg, ret, i, val; ++ unsigned long chans; ++ ++ chans = tps23881_irq_export_chans_helper(reg_val, 0); ++ for_each_set_bit(i, &chans, TPS23881_MAX_CHANS) { ++ reg = TPS23881_REG_DISC + (i % 4); ++ ret = i2c_smbus_read_word_data(priv->client, reg); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_calc_val(ret, i, 0, 0xf); ++ /* If detection valid */ ++ if (val == 0x4) ++ event = ETHTOOL_C33_PSE_EVENT_DETECTION; ++ else ++ event = ETHTOOL_C33_PSE_EVENT_DISCONNECTION; ++ ++ tps23881_set_notifs_helper(priv, BIT(i), notifs, ++ notifs_mask, event); ++ } ++ ++ return 0; ++} ++ ++static int tps23881_irq_event_classification(struct tps23881_priv *priv, ++ u16 reg_val, ++ unsigned long *notifs, ++ unsigned long *notifs_mask) ++{ ++ int reg, ret, val, i; ++ unsigned long chans; ++ ++ chans = tps23881_irq_export_chans_helper(reg_val, 4); ++ for_each_set_bit(i, &chans, TPS23881_MAX_CHANS) { ++ reg = TPS23881_REG_DISC + (i % 4); ++ ret = i2c_smbus_read_word_data(priv->client, reg); ++ if (ret < 0) ++ return ret; ++ ++ val = tps23881_calc_val(ret, i, 4, 0xf); ++ /* Do not report classification event for unknown class */ ++ if (!val || val == 0x8 || val == 0xf) ++ continue; ++ ++ tps23881_set_notifs_helper(priv, BIT(i), notifs, ++ notifs_mask, ++ ETHTOOL_C33_PSE_EVENT_CLASSIFICATION); ++ } ++ ++ return 0; + } + + static int tps23881_irq_event_handler(struct tps23881_priv *priv, u16 reg, +@@ -1106,7 +1281,7 @@ static int tps23881_irq_event_handler(st + unsigned long *notifs_mask) + { + struct i2c_client *client = priv->client; +- int ret; ++ int ret, val; + + /* The Supply event bit is repeated twice so we only need to read + * the one from the first byte. +@@ -1118,13 +1293,36 @@ static int tps23881_irq_event_handler(st + tps23881_irq_event_over_temp(priv, ret, notifs, notifs_mask); + } + +- if (reg & (TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_IFAULT << 8)) { ++ if (reg & (TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_IFAULT << 8 | ++ TPS23881_REG_IT_DISF | TPS23881_REG_IT_DISF << 8)) { + ret = i2c_smbus_read_word_data(client, TPS23881_REG_FAULT); + if (ret < 0) + return ret; +- tps23881_irq_event_over_current(priv, ret, notifs, notifs_mask); ++ ret = tps23881_irq_event_over_current(priv, ret, notifs, ++ notifs_mask); ++ if (ret) ++ return ret; ++ ++ tps23881_irq_event_disconnection(priv, ret, notifs, notifs_mask); + } + ++ if (reg & (TPS23881_REG_IT_DETC | TPS23881_REG_IT_DETC << 8 | ++ TPS23881_REG_IT_CLASC | TPS23881_REG_IT_CLASC << 8)) { ++ ret = i2c_smbus_read_word_data(client, TPS23881_REG_DET_EVENT); ++ if (ret < 0) ++ return ret; ++ ++ val = ret; ++ ret = tps23881_irq_event_detection(priv, val, notifs, ++ notifs_mask); ++ if (ret) ++ return ret; ++ ++ ret = tps23881_irq_event_classification(priv, val, notifs, ++ notifs_mask); ++ if (ret) ++ return ret; ++ } + return 0; + } + +@@ -1178,7 +1376,14 @@ static int tps23881_setup_irq(struct tps + int ret; + u16 val; + +- val = TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_SUPF; ++ if (!irq) { ++ dev_err(&client->dev, "interrupt is missing"); ++ return -EINVAL; ++ } ++ ++ val = TPS23881_REG_IT_IFAULT | TPS23881_REG_IT_SUPF | ++ TPS23881_REG_IT_DETC | TPS23881_REG_IT_CLASC | ++ TPS23881_REG_IT_DISF; + val |= val << 8; + ret = i2c_smbus_write_word_data(client, TPS23881_REG_IT_MASK, val); + if (ret) +@@ -1188,11 +1393,19 @@ static int tps23881_setup_irq(struct tps + if (ret < 0) + return ret; + +- val = (u16)(ret | TPS23881_REG_INTEN | TPS23881_REG_INTEN << 8); ++ val = TPS23881_REG_INTEN | TPS23881_REG_CLCHE | TPS23881_REG_DECHE; ++ val |= val << 8; ++ val |= (u16)ret; + ret = i2c_smbus_write_word_data(client, TPS23881_REG_GEN_MASK, val); + if (ret < 0) + return ret; + ++ /* Reset interrupts registers */ ++ ret = i2c_smbus_write_word_data(client, TPS23881_REG_RESET, ++ TPS23881_REG_CLRAIN); ++ if (ret < 0) ++ return ret; ++ + return devm_pse_irq_helper(&priv->pcdev, irq, 0, &irq_desc); + } + +@@ -1270,17 +1483,16 @@ static int tps23881_i2c_probe(struct i2c + priv->pcdev.dev = dev; + priv->pcdev.types = ETHTOOL_PSE_C33; + priv->pcdev.nr_lines = TPS23881_MAX_CHANS; ++ priv->pcdev.supp_budget_eval_strategies = PSE_BUDGET_EVAL_STRAT_STATIC; + ret = devm_pse_controller_register(dev, &priv->pcdev); + if (ret) { + return dev_err_probe(dev, ret, + "failed to register PSE controller\n"); + } + +- if (client->irq) { +- ret = tps23881_setup_irq(priv, client->irq); +- if (ret) +- return ret; +- } ++ ret = tps23881_setup_irq(priv, client->irq); ++ if (ret) ++ return ret; + + return ret; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-20-v6.17-net-pse-pd-pd692x0-reduce-stack-usage.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-20-v6.17-net-pse-pd-pd692x0-reduce-stack-usage.patch new file mode 100755 index 0000000..d5e1aaf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-20-v6.17-net-pse-pd-pd692x0-reduce-stack-usage.patch @@ -0,0 +1,55 @@ +From d12b3dc106090b358fb67b7c0c717a0884327ddf Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Wed, 9 Jul 2025 17:32:04 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: reduce stack usage in + pd692x0_setup_pi_matrix + +The pd692x0_manager array in this function is really too big to fit on the +stack, though this never triggered a warning until a recent patch made +it slightly bigger: + +drivers/net/pse-pd/pd692x0.c: In function 'pd692x0_setup_pi_matrix': +drivers/net/pse-pd/pd692x0.c:1210:1: error: the frame size of 1584 bytes is larger than 1536 bytes [-Werror=frame-larger-than=] + +Change the function to dynamically allocate the array here. + +Fixes: 359754013e6a ("net: pse-pd: pd692x0: Add support for PSE PI priority feature") +Signed-off-by: Arnd Bergmann +Reviewed-by: Kory Maincent +Link: https://patch.msgid.link/20250709153210.1920125-1-arnd@kernel.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -860,7 +860,7 @@ out: + + static int + pd692x0_of_get_managers(struct pd692x0_priv *priv, +- struct pd692x0_manager manager[PD692X0_MAX_MANAGERS]) ++ struct pd692x0_manager *manager) + { + struct device_node *managers_node, *node; + int ret, nmanagers, i, j; +@@ -1164,7 +1164,7 @@ pd692x0_write_ports_matrix(struct pd692x + + static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) + { +- struct pd692x0_manager manager[PD692X0_MAX_MANAGERS] = {0}; ++ struct pd692x0_manager *manager __free(kfree) = NULL; + struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); + struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; + int ret, i, j, nmanagers; +@@ -1174,6 +1174,10 @@ static int pd692x0_setup_pi_matrix(struc + priv->fw_state != PD692X0_FW_COMPLETE) + return 0; + ++ manager = kcalloc(PD692X0_MAX_MANAGERS, sizeof(*manager), GFP_KERNEL); ++ if (!manager) ++ return -ENOMEM; ++ + ret = pd692x0_of_get_managers(priv, manager); + if (ret < 0) + return ret; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-21-v6.18-net-pse-pd-pd692x0-Fix-power-budget-leak.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-21-v6.18-net-pse-pd-pd692x0-Fix-power-budget-leak.patch new file mode 100755 index 0000000..af23745 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-21-v6.18-net-pse-pd-pd692x0-Fix-power-budget-leak.patch @@ -0,0 +1,121 @@ +From 1c67f9c54cdc70627e3f6472b89cd3d895df974c Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Wed, 20 Aug 2025 15:27:07 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Fix power budget leak in manager setup + error path + +Fix a resource leak where manager power budgets were freed on both +success and error paths during manager setup. Power budgets should +only be freed on error paths after regulator registration or during +driver removal. + +Refactor cleanup logic by extracting OF node cleanup and power budget +freeing into separate helper functions for better maintainability. + +Fixes: 359754013e6a ("net: pse-pd: pd692x0: Add support for PSE PI priority feature") +Signed-off-by: Kory Maincent +Link: https://patch.msgid.link/20250820132708.837255-1-kory.maincent@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 59 +++++++++++++++++++++++++++--------- + 1 file changed, 44 insertions(+), 15 deletions(-) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -1162,12 +1162,44 @@ pd692x0_write_ports_matrix(struct pd692x + return 0; + } + ++static void pd692x0_of_put_managers(struct pd692x0_priv *priv, ++ struct pd692x0_manager *manager, ++ int nmanagers) ++{ ++ int i, j; ++ ++ for (i = 0; i < nmanagers; i++) { ++ for (j = 0; j < manager[i].nports; j++) ++ of_node_put(manager[i].port_node[j]); ++ of_node_put(manager[i].node); ++ } ++} ++ ++static void pd692x0_managers_free_pw_budget(struct pd692x0_priv *priv) ++{ ++ int i; ++ ++ for (i = 0; i < PD692X0_MAX_MANAGERS; i++) { ++ struct regulator *supply; ++ ++ if (!priv->manager_reg[i] || !priv->manager_pw_budget[i]) ++ continue; ++ ++ supply = priv->manager_reg[i]->supply; ++ if (!supply) ++ continue; ++ ++ regulator_free_power_budget(supply, ++ priv->manager_pw_budget[i]); ++ } ++} ++ + static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) + { + struct pd692x0_manager *manager __free(kfree) = NULL; + struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); + struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; +- int ret, i, j, nmanagers; ++ int ret, nmanagers; + + /* Should we flash the port matrix */ + if (priv->fw_state != PD692X0_FW_OK && +@@ -1185,31 +1217,27 @@ static int pd692x0_setup_pi_matrix(struc + nmanagers = ret; + ret = pd692x0_register_managers_regulator(priv, manager, nmanagers); + if (ret) +- goto out; ++ goto err_of_managers; + + ret = pd692x0_configure_managers(priv, nmanagers); + if (ret) +- goto out; ++ goto err_of_managers; + + ret = pd692x0_set_ports_matrix(priv, manager, nmanagers, port_matrix); + if (ret) +- goto out; ++ goto err_managers_req_pw; + + ret = pd692x0_write_ports_matrix(priv, port_matrix); + if (ret) +- goto out; +- +-out: +- for (i = 0; i < nmanagers; i++) { +- struct regulator *supply = priv->manager_reg[i]->supply; ++ goto err_managers_req_pw; + +- regulator_free_power_budget(supply, +- priv->manager_pw_budget[i]); ++ pd692x0_of_put_managers(priv, manager, nmanagers); ++ return 0; + +- for (j = 0; j < manager[i].nports; j++) +- of_node_put(manager[i].port_node[j]); +- of_node_put(manager[i].node); +- } ++err_managers_req_pw: ++ pd692x0_managers_free_pw_budget(priv); ++err_of_managers: ++ pd692x0_of_put_managers(priv, manager, nmanagers); + return ret; + } + +@@ -1748,6 +1776,7 @@ static void pd692x0_i2c_remove(struct i2 + { + struct pd692x0_priv *priv = i2c_get_clientdata(client); + ++ pd692x0_managers_free_pw_budget(priv); + firmware_upload_unregister(priv->fwl); + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-22-v6.18-net-pse-pd-pd692x0-Skip-power-budget-when-undefined.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-22-v6.18-net-pse-pd-pd692x0-Skip-power-budget-when-undefined.patch new file mode 100755 index 0000000..98da7b5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-22-v6.18-net-pse-pd-pd692x0-Skip-power-budget-when-undefined.patch @@ -0,0 +1,37 @@ +From 7ef353879f714602b43f98662069f4fb86536761 Mon Sep 17 00:00:00 2001 +From: Kory Maincent +Date: Wed, 20 Aug 2025 15:33:21 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Skip power budget configuration when + undefined + +If the power supply's power budget is not defined in the device tree, +the current code still requests power and configures the PSE manager +with a 0W power limit, which is undesirable behavior. + +Skip power budget configuration entirely when the budget is zero, +avoiding unnecessary power requests and preventing invalid 0W limits +from being set on the PSE manager. + +Fixes: 359754013e6a ("net: pse-pd: pd692x0: Add support for PSE PI priority feature") +Signed-off-by: Kory Maincent +Acked-by: Oleksij Rempel +Link: https://patch.msgid.link/20250820133321.841054-1-kory.maincent@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -1041,6 +1041,10 @@ pd692x0_configure_managers(struct pd692x + int pw_budget; + + pw_budget = regulator_get_unclaimed_power_budget(supply); ++ if (!pw_budget) ++ /* Do nothing if no power budget */ ++ continue; ++ + /* Max power budget per manager */ + if (pw_budget > 6000000) + pw_budget = 6000000; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-23-v6.18-net-pse-pd-Add-Si3474-PSE-controller-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-23-v6.18-net-pse-pd-Add-Si3474-PSE-controller-driver.patch new file mode 100755 index 0000000..2f4087f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-23-v6.18-net-pse-pd-Add-Si3474-PSE-controller-driver.patch @@ -0,0 +1,636 @@ +From a2317231df4b22e6634fe3d8645e7cef848acf49 Mon Sep 17 00:00:00 2001 +From: Piotr Kubik +Date: Tue, 26 Aug 2025 14:41:58 +0000 +Subject: [PATCH] net: pse-pd: Add Si3474 PSE controller driver + +Add a driver for the Skyworks Si3474 I2C Power Sourcing Equipment +controller. + +Driver supports basic features of Si3474 IC: +- get port status, +- get port power, +- get port voltage, +- enable/disable port power. + +Only 4p configurations are supported at this moment. + +Signed-off-by: Piotr Kubik +Reviewed-by: Kory Maincent +Link: https://patch.msgid.link/9b72c8cd-c8d3-4053-9c80-671b9481d166@adtran.com +Signed-off-by: Paolo Abeni +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/Kconfig | 11 + + drivers/net/pse-pd/Makefile | 1 + + drivers/net/pse-pd/si3474.c | 578 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 590 insertions(+) + create mode 100644 drivers/net/pse-pd/si3474.c +--- a/drivers/net/pse-pd/Kconfig ++++ b/drivers/net/pse-pd/Kconfig +@@ -32,6 +32,17 @@ config PSE_PD692X0 + To compile this driver as a module, choose M here: the + module will be called pd692x0. + ++config PSE_SI3474 ++ tristate "Si3474 PSE controller" ++ depends on I2C ++ help ++ This module provides support for Si3474 regulator based Ethernet ++ Power Sourcing Equipment. ++ Only 4-pair PSE configurations are supported. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called si3474. ++ + config PSE_TPS23881 + tristate "TPS23881 PSE controller" + depends on I2C +--- a/drivers/net/pse-pd/Makefile ++++ b/drivers/net/pse-pd/Makefile +@@ -5,4 +5,5 @@ obj-$(CONFIG_PSE_CONTROLLER) += pse_core + + obj-$(CONFIG_PSE_REGULATOR) += pse_regulator.o + obj-$(CONFIG_PSE_PD692X0) += pd692x0.o ++obj-$(CONFIG_PSE_SI3474) += si3474.o + obj-$(CONFIG_PSE_TPS23881) += tps23881.o +--- /dev/null ++++ b/drivers/net/pse-pd/si3474.c +@@ -0,0 +1,578 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Driver for the Skyworks Si3474 PoE PSE Controller ++ * ++ * Chip Architecture & Terminology: ++ * ++ * The Si3474 is a single-chip PoE PSE controller managing 8 physical power ++ * delivery channels. Internally, it's structured into two logical "Quads". ++ * ++ * Quad 0: Manages physical channels ('ports' in datasheet) 0, 1, 2, 3 ++ * Quad 1: Manages physical channels ('ports' in datasheet) 4, 5, 6, 7 ++ * ++ * Each Quad is accessed via a separate I2C address. The base address range is ++ * set by hardware pins A1-A4, and the specific address selects Quad 0 (usually ++ * the lower/even address) or Quad 1 (usually the higher/odd address). ++ * See datasheet Table 2.2 for the address mapping. ++ * ++ * While the Quads manage channel-specific operations, the Si3474 package has ++ * several resources shared across the entire chip: ++ * - Single RESETb input pin. ++ * - Single INTb output pin (signals interrupts from *either* Quad). ++ * - Single OSS input pin (Emergency Shutdown). ++ * - Global I2C Address (0x7F) used for firmware updates. ++ * - Global status monitoring (Temperature, VDD/VPWR Undervoltage Lockout). ++ * ++ * Driver Architecture: ++ * ++ * To handle the mix of per-Quad access and shared resources correctly, this ++ * driver treats the entire Si3474 package as one logical device. The driver ++ * instance associated with the primary I2C address (Quad 0) takes ownership. ++ * It discovers and manages the I2C client for the secondary address (Quad 1). ++ * This primary instance handles shared resources like IRQ management and ++ * registers a single PSE controller device representing all logical PIs. ++ * Internal functions route I2C commands to the appropriate Quad's i2c_client ++ * based on the target channel or PI. ++ * ++ * Terminology Mapping: ++ * ++ * - "PI" (Power Interface): Refers to the logical PSE port as defined by ++ * IEEE 802.3 (typically corresponds to an RJ45 connector). This is the ++ * `id` (0-7) used in the pse_controller_ops. ++ * - "Channel": Refers to one of the 8 physical power control paths within ++ * the Si3474 chip itself (hardware channels 0-7). This terminology is ++ * used internally within the driver to avoid confusion with 'ports'. ++ * - "Quad": One of the two internal 4-channel management units within the ++ * Si3474, each accessed via its own I2C address. ++ * ++ * Relationship: ++ * - A 2-Pair PoE PI uses 1 Channel. ++ * - A 4-Pair PoE PI uses 2 Channels. ++ * ++ * ASCII Schematic: ++ * ++ * +-----------------------------------------------------+ ++ * | Si3474 Chip | ++ * | | ++ * | +---------------------+ +---------------------+ | ++ * | | Quad 0 | | Quad 1 | | ++ * | | Channels 0, 1, 2, 3 | | Channels 4, 5, 6, 7 | | ++ * | +----------^----------+ +-------^-------------+ | ++ * | I2C Addr 0 | | I2C Addr 1 | ++ * | +------------------------+ | ++ * | (Primary Driver Instance) (Managed by Primary) | ++ * | | ++ * | Shared Resources (affect whole chip): | ++ * | - Single INTb Output -> Handled by Primary | ++ * | - Single RESETb Input | ++ * | - Single OSS Input -> Handled by Primary | ++ * | - Global I2C Addr (0x7F) for Firmware Update | ++ * | - Global Status (Temp, VDD/VPWR UVLO) | ++ * +-----------------------------------------------------+ ++ * | | | | | | | | ++ * Ch0 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 (Physical Channels) ++ * ++ * Example Mapping (Logical PI to Physical Channel(s)): ++ * * 2-Pair Mode (8 PIs): ++ * PI 0 -> Ch 0 ++ * PI 1 -> Ch 1 ++ * ... ++ * PI 7 -> Ch 7 ++ * * 4-Pair Mode (4 PIs): ++ * PI 0 -> Ch 0 + Ch 1 (Managed via Quad 0 Addr) ++ * PI 1 -> Ch 2 + Ch 3 (Managed via Quad 0 Addr) ++ * PI 2 -> Ch 4 + Ch 5 (Managed via Quad 1 Addr) ++ * PI 3 -> Ch 6 + Ch 7 (Managed via Quad 1 Addr) ++ * (Note: Actual mapping depends on Device Tree and PORT_REMAP config) ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define SI3474_MAX_CHANS 8 ++ ++#define MANUFACTURER_ID 0x08 ++#define IC_ID 0x05 ++#define SI3474_DEVICE_ID (MANUFACTURER_ID << 3 | IC_ID) ++ ++/* Misc registers */ ++#define VENDOR_IC_ID_REG 0x1B ++#define TEMPERATURE_REG 0x2C ++#define FIRMWARE_REVISION_REG 0x41 ++#define CHIP_REVISION_REG 0x43 ++ ++/* Main status registers */ ++#define POWER_STATUS_REG 0x10 ++#define PORT_MODE_REG 0x12 ++#define DETECT_CLASS_ENABLE_REG 0x14 ++ ++/* PORTn Current */ ++#define PORT1_CURRENT_LSB_REG 0x30 ++ ++/* PORTn Current [mA], return in [nA] */ ++/* 1000 * ((PORTn_CURRENT_MSB << 8) + PORTn_CURRENT_LSB) / 16384 */ ++#define SI3474_NA_STEP (1000 * 1000 * 1000 / 16384) ++ ++/* VPWR Voltage */ ++#define VPWR_LSB_REG 0x2E ++#define VPWR_MSB_REG 0x2F ++ ++/* PORTn Voltage */ ++#define PORT1_VOLTAGE_LSB_REG 0x32 ++ ++/* VPWR Voltage [V], return in [uV] */ ++/* 60 * (( VPWR_MSB << 8) + VPWR_LSB) / 16384 */ ++#define SI3474_UV_STEP (1000 * 1000 * 60 / 16384) ++ ++/* Helper macros */ ++#define CHAN_IDX(chan) ((chan) % 4) ++#define CHAN_BIT(chan) BIT(CHAN_IDX(chan)) ++#define CHAN_UPPER_BIT(chan) BIT(CHAN_IDX(chan) + 4) ++ ++#define CHAN_MASK(chan) (0x03U << (2 * CHAN_IDX(chan))) ++#define CHAN_REG(base, chan) ((base) + (CHAN_IDX(chan) * 4)) ++ ++struct si3474_pi_desc { ++ u8 chan[2]; ++ bool is_4p; ++}; ++ ++struct si3474_priv { ++ struct i2c_client *client[2]; ++ struct pse_controller_dev pcdev; ++ struct device_node *np; ++ struct si3474_pi_desc pi[SI3474_MAX_CHANS]; ++}; ++ ++static struct si3474_priv *to_si3474_priv(struct pse_controller_dev *pcdev) ++{ ++ return container_of(pcdev, struct si3474_priv, pcdev); ++} ++ ++static void si3474_get_channels(struct si3474_priv *priv, int id, ++ u8 *chan0, u8 *chan1) ++{ ++ *chan0 = priv->pi[id].chan[0]; ++ *chan1 = priv->pi[id].chan[1]; ++} ++ ++static struct i2c_client *si3474_get_chan_client(struct si3474_priv *priv, ++ u8 chan) ++{ ++ return (chan < 4) ? priv->client[0] : priv->client[1]; ++} ++ ++static int si3474_pi_get_admin_state(struct pse_controller_dev *pcdev, int id, ++ struct pse_admin_state *admin_state) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ struct i2c_client *client; ++ bool is_enabled; ++ u8 chan0, chan1; ++ s32 ret; ++ ++ si3474_get_channels(priv, id, &chan0, &chan1); ++ client = si3474_get_chan_client(priv, chan0); ++ ++ ret = i2c_smbus_read_byte_data(client, PORT_MODE_REG); ++ if (ret < 0) { ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN; ++ return ret; ++ } ++ ++ is_enabled = ret & (CHAN_MASK(chan0) | CHAN_MASK(chan1)); ++ ++ if (is_enabled) ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED; ++ else ++ admin_state->c33_admin_state = ++ ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED; ++ ++ return 0; ++} ++ ++static int si3474_pi_get_pw_status(struct pse_controller_dev *pcdev, int id, ++ struct pse_pw_status *pw_status) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ struct i2c_client *client; ++ bool delivering; ++ u8 chan0, chan1; ++ s32 ret; ++ ++ si3474_get_channels(priv, id, &chan0, &chan1); ++ client = si3474_get_chan_client(priv, chan0); ++ ++ ret = i2c_smbus_read_byte_data(client, POWER_STATUS_REG); ++ if (ret < 0) { ++ pw_status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN; ++ return ret; ++ } ++ ++ delivering = ret & (CHAN_UPPER_BIT(chan0) | CHAN_UPPER_BIT(chan1)); ++ ++ if (delivering) ++ pw_status->c33_pw_status = ++ ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING; ++ else ++ pw_status->c33_pw_status = ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED; ++ ++ return 0; ++} ++ ++static int si3474_get_of_channels(struct si3474_priv *priv) ++{ ++ struct pse_pi *pi; ++ u32 chan_id; ++ u8 pi_no; ++ s32 ret; ++ ++ for (pi_no = 0; pi_no < SI3474_MAX_CHANS; pi_no++) { ++ pi = &priv->pcdev.pi[pi_no]; ++ bool pairset_found = false; ++ u8 pairset_no; ++ ++ for (pairset_no = 0; pairset_no < 2; pairset_no++) { ++ if (!pi->pairset[pairset_no].np) ++ continue; ++ ++ pairset_found = true; ++ ++ ret = of_property_read_u32(pi->pairset[pairset_no].np, ++ "reg", &chan_id); ++ if (ret) { ++ dev_err(&priv->client[0]->dev, ++ "Failed to read channel reg property\n"); ++ return ret; ++ } ++ if (chan_id > SI3474_MAX_CHANS) { ++ dev_err(&priv->client[0]->dev, ++ "Incorrect channel number: %d\n", chan_id); ++ return -EINVAL; ++ } ++ ++ priv->pi[pi_no].chan[pairset_no] = chan_id; ++ /* Mark as 4-pair if second pairset is present */ ++ priv->pi[pi_no].is_4p = (pairset_no == 1); ++ } ++ ++ if (pairset_found && !priv->pi[pi_no].is_4p) { ++ dev_err(&priv->client[0]->dev, ++ "Second pairset is missing for PI %pOF, only 4p configs are supported\n", ++ pi->np); ++ return -EINVAL; ++ } ++ } ++ ++ return 0; ++} ++ ++static int si3474_setup_pi_matrix(struct pse_controller_dev *pcdev) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ s32 ret; ++ ++ ret = si3474_get_of_channels(priv); ++ if (ret < 0) ++ dev_warn(&priv->client[0]->dev, ++ "Unable to parse DT PSE power interface matrix\n"); ++ ++ return ret; ++} ++ ++static int si3474_pi_enable(struct pse_controller_dev *pcdev, int id) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ struct i2c_client *client; ++ u8 chan0, chan1; ++ s32 ret; ++ u8 val; ++ ++ si3474_get_channels(priv, id, &chan0, &chan1); ++ client = si3474_get_chan_client(priv, chan0); ++ ++ /* Release PI from shutdown */ ++ ret = i2c_smbus_read_byte_data(client, PORT_MODE_REG); ++ if (ret < 0) ++ return ret; ++ ++ val = (u8)ret; ++ val |= CHAN_MASK(chan0); ++ val |= CHAN_MASK(chan1); ++ ++ ret = i2c_smbus_write_byte_data(client, PORT_MODE_REG, val); ++ if (ret) ++ return ret; ++ ++ /* DETECT_CLASS_ENABLE must be set when using AUTO mode, ++ * otherwise PI does not power up - datasheet section 2.10.2 ++ */ ++ val = CHAN_BIT(chan0) | CHAN_UPPER_BIT(chan0) | ++ CHAN_BIT(chan1) | CHAN_UPPER_BIT(chan1); ++ ++ ret = i2c_smbus_write_byte_data(client, DETECT_CLASS_ENABLE_REG, val); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++static int si3474_pi_disable(struct pse_controller_dev *pcdev, int id) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ struct i2c_client *client; ++ u8 chan0, chan1; ++ s32 ret; ++ u8 val; ++ ++ si3474_get_channels(priv, id, &chan0, &chan1); ++ client = si3474_get_chan_client(priv, chan0); ++ ++ /* Set PI in shutdown mode */ ++ ret = i2c_smbus_read_byte_data(client, PORT_MODE_REG); ++ if (ret < 0) ++ return ret; ++ ++ val = (u8)ret; ++ val &= ~CHAN_MASK(chan0); ++ val &= ~CHAN_MASK(chan1); ++ ++ ret = i2c_smbus_write_byte_data(client, PORT_MODE_REG, val); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++static int si3474_pi_get_chan_current(struct si3474_priv *priv, u8 chan) ++{ ++ struct i2c_client *client; ++ u64 tmp_64; ++ s32 ret; ++ u8 reg; ++ ++ client = si3474_get_chan_client(priv, chan); ++ ++ /* Registers 0x30 to 0x3d */ ++ reg = CHAN_REG(PORT1_CURRENT_LSB_REG, chan); ++ ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ tmp_64 = ret * SI3474_NA_STEP; ++ ++ /* uA = nA / 1000 */ ++ tmp_64 = DIV_ROUND_CLOSEST_ULL(tmp_64, 1000); ++ return (int)tmp_64; ++} ++ ++static int si3474_pi_get_chan_voltage(struct si3474_priv *priv, u8 chan) ++{ ++ struct i2c_client *client; ++ s32 ret; ++ u32 val; ++ u8 reg; ++ ++ client = si3474_get_chan_client(priv, chan); ++ ++ /* Registers 0x32 to 0x3f */ ++ reg = CHAN_REG(PORT1_VOLTAGE_LSB_REG, chan); ++ ++ ret = i2c_smbus_read_word_data(client, reg); ++ if (ret < 0) ++ return ret; ++ ++ val = ret * SI3474_UV_STEP; ++ ++ return (int)val; ++} ++ ++static int si3474_pi_get_voltage(struct pse_controller_dev *pcdev, int id) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ struct i2c_client *client; ++ u8 chan0, chan1; ++ s32 ret; ++ ++ si3474_get_channels(priv, id, &chan0, &chan1); ++ client = si3474_get_chan_client(priv, chan0); ++ ++ /* Check which channels are enabled*/ ++ ret = i2c_smbus_read_byte_data(client, POWER_STATUS_REG); ++ if (ret < 0) ++ return ret; ++ ++ /* Take voltage from the first enabled channel */ ++ if (ret & CHAN_BIT(chan0)) ++ ret = si3474_pi_get_chan_voltage(priv, chan0); ++ else if (ret & CHAN_BIT(chan1)) ++ ret = si3474_pi_get_chan_voltage(priv, chan1); ++ else ++ /* 'should' be no voltage in this case */ ++ return 0; ++ ++ return ret; ++} ++ ++static int si3474_pi_get_actual_pw(struct pse_controller_dev *pcdev, int id) ++{ ++ struct si3474_priv *priv = to_si3474_priv(pcdev); ++ u8 chan0, chan1; ++ u32 uV, uA; ++ u64 tmp_64; ++ s32 ret; ++ ++ ret = si3474_pi_get_voltage(&priv->pcdev, id); ++ ++ /* Do not read currents if voltage is 0 */ ++ if (ret <= 0) ++ return ret; ++ uV = ret; ++ ++ si3474_get_channels(priv, id, &chan0, &chan1); ++ ++ ret = si3474_pi_get_chan_current(priv, chan0); ++ if (ret < 0) ++ return ret; ++ uA = ret; ++ ++ ret = si3474_pi_get_chan_current(priv, chan1); ++ if (ret < 0) ++ return ret; ++ uA += ret; ++ ++ tmp_64 = uV; ++ tmp_64 *= uA; ++ /* mW = uV * uA / 1000000000 */ ++ return DIV_ROUND_CLOSEST_ULL(tmp_64, 1000000000); ++} ++ ++static const struct pse_controller_ops si3474_ops = { ++ .setup_pi_matrix = si3474_setup_pi_matrix, ++ .pi_enable = si3474_pi_enable, ++ .pi_disable = si3474_pi_disable, ++ .pi_get_actual_pw = si3474_pi_get_actual_pw, ++ .pi_get_voltage = si3474_pi_get_voltage, ++ .pi_get_admin_state = si3474_pi_get_admin_state, ++ .pi_get_pw_status = si3474_pi_get_pw_status, ++}; ++ ++static void si3474_ancillary_i2c_remove(void *data) ++{ ++ struct i2c_client *client = data; ++ ++ i2c_unregister_device(client); ++} ++ ++static int si3474_i2c_probe(struct i2c_client *client) ++{ ++ struct device *dev = &client->dev; ++ struct si3474_priv *priv; ++ u8 fw_version; ++ s32 ret; ++ ++ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { ++ dev_err(dev, "i2c check functionality failed\n"); ++ return -ENXIO; ++ } ++ ++ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ ret = i2c_smbus_read_byte_data(client, VENDOR_IC_ID_REG); ++ if (ret < 0) ++ return ret; ++ ++ if (ret != SI3474_DEVICE_ID) { ++ dev_err(dev, "Wrong device ID: 0x%x\n", ret); ++ return -ENXIO; ++ } ++ ++ ret = i2c_smbus_read_byte_data(client, FIRMWARE_REVISION_REG); ++ if (ret < 0) ++ return ret; ++ fw_version = ret; ++ ++ ret = i2c_smbus_read_byte_data(client, CHIP_REVISION_REG); ++ if (ret < 0) ++ return ret; ++ ++ dev_dbg(dev, "Chip revision: 0x%x, firmware version: 0x%x\n", ++ ret, fw_version); ++ ++ priv->client[0] = client; ++ i2c_set_clientdata(client, priv); ++ ++ priv->client[1] = i2c_new_ancillary_device(priv->client[0], "secondary", ++ priv->client[0]->addr + 1); ++ if (IS_ERR(priv->client[1])) ++ return PTR_ERR(priv->client[1]); ++ ++ ret = devm_add_action_or_reset(dev, si3474_ancillary_i2c_remove, priv->client[1]); ++ if (ret < 0) { ++ dev_err(&priv->client[1]->dev, "Cannot register remove callback\n"); ++ return ret; ++ } ++ ++ ret = i2c_smbus_read_byte_data(priv->client[1], VENDOR_IC_ID_REG); ++ if (ret < 0) { ++ dev_err(&priv->client[1]->dev, "Cannot access secondary PSE controller\n"); ++ return ret; ++ } ++ ++ if (ret != SI3474_DEVICE_ID) { ++ dev_err(&priv->client[1]->dev, ++ "Wrong device ID for secondary PSE controller: 0x%x\n", ret); ++ return -ENXIO; ++ } ++ ++ priv->np = dev->of_node; ++ priv->pcdev.owner = THIS_MODULE; ++ priv->pcdev.ops = &si3474_ops; ++ priv->pcdev.dev = dev; ++ priv->pcdev.types = ETHTOOL_PSE_C33; ++ priv->pcdev.nr_lines = SI3474_MAX_CHANS; ++ ++ ret = devm_pse_controller_register(dev, &priv->pcdev); ++ if (ret) { ++ dev_err(dev, "Failed to register PSE controller: 0x%x\n", ret); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static const struct i2c_device_id si3474_id[] = { ++ { "si3474" }, ++ {} ++}; ++MODULE_DEVICE_TABLE(i2c, si3474_id); ++ ++static const struct of_device_id si3474_of_match[] = { ++ { ++ .compatible = "skyworks,si3474", ++ }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, si3474_of_match); ++ ++static struct i2c_driver si3474_driver = { ++ .probe = si3474_i2c_probe, ++ .id_table = si3474_id, ++ .driver = { ++ .name = "si3474", ++ .of_match_table = si3474_of_match, ++ }, ++}; ++module_i2c_driver(si3474_driver); ++ ++MODULE_AUTHOR("Piotr Kubik "); ++MODULE_DESCRIPTION("Skyworks Si3474 PoE PSE Controller driver"); ++MODULE_LICENSE("GPL"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-24-v6.19-net-pse-pd-tps23881-Fix-current-measurement-scaling.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-24-v6.19-net-pse-pd-tps23881-Fix-current-measurement-scaling.patch new file mode 100755 index 0000000..5150da3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-24-v6.19-net-pse-pd-tps23881-Fix-current-measurement-scaling.patch @@ -0,0 +1,31 @@ +From 2c95a756e0cfc19af6d0b32b0c6cf3bada334998 Mon Sep 17 00:00:00 2001 +From: Thomas Wismer +Date: Mon, 6 Oct 2025 22:40:29 +0200 +Subject: [PATCH] net: pse-pd: tps23881: Fix current measurement scaling + +The TPS23881 improves on the TPS23880 with current sense resistors reduced +from 255 mOhm to 200 mOhm. This has a direct impact on the scaling of the +current measurement. However, the latest TPS23881 data sheet from May 2023 +still shows the scaling of the TPS23880 model. + +Fixes: 7f076ce3f1733 ("net: pse-pd: tps23881: Add support for power limit and measurement features") +Signed-off-by: Thomas Wismer +Acked-by: Kory Maincent +Link: https://patch.msgid.link/20251006204029.7169-2-thomas@wismer.xyz +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -62,7 +62,7 @@ + #define TPS23881_REG_SRAM_DATA 0x61 + + #define TPS23881_UV_STEP 3662 +-#define TPS23881_NA_STEP 70190 ++#define TPS23881_NA_STEP 89500 + #define TPS23881_MW_STEP 500 + #define TPS23881_MIN_PI_PW_LIMIT_MW 2000 + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-25-v6.19-net-pse-pd-pd692x0-Replace-__free-macro.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-25-v6.19-net-pse-pd-pd692x0-Replace-__free-macro.patch new file mode 100755 index 0000000..fafa5af --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-25-v6.19-net-pse-pd-pd692x0-Replace-__free-macro.patch @@ -0,0 +1,57 @@ +From f197902cd21ae833850679b216bb62c0d056bbb3 Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Mon, 13 Oct 2025 16:05:31 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Replace __free macro with explicit + kfree calls + +Replace __free(kfree) with explicit kfree() calls to follow the net +subsystem policy of avoiding automatic cleanup macros as described in +the documentation. + +Signed-off-by: Kory Maincent +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/20251013-feature_pd692x0_reboot_keep_conf-v2-1-68ab082a93dd@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -1200,9 +1200,9 @@ static void pd692x0_managers_free_pw_bud + + static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) + { +- struct pd692x0_manager *manager __free(kfree) = NULL; + struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); + struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; ++ struct pd692x0_manager *manager; + int ret, nmanagers; + + /* Should we flash the port matrix */ +@@ -1216,7 +1216,7 @@ static int pd692x0_setup_pi_matrix(struc + + ret = pd692x0_of_get_managers(priv, manager); + if (ret < 0) +- return ret; ++ goto err_free_manager; + + nmanagers = ret; + ret = pd692x0_register_managers_regulator(priv, manager, nmanagers); +@@ -1236,12 +1236,15 @@ static int pd692x0_setup_pi_matrix(struc + goto err_managers_req_pw; + + pd692x0_of_put_managers(priv, manager, nmanagers); ++ kfree(manager); + return 0; + + err_managers_req_pw: + pd692x0_managers_free_pw_budget(priv); + err_of_managers: + pd692x0_of_put_managers(priv, manager, nmanagers); ++err_free_manager: ++ kfree(manager); + return ret; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-26-v6.19-net-pse-pd-pd692x0-Separate-configuration-parsing.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-26-v6.19-net-pse-pd-pd692x0-Separate-configuration-parsing.patch new file mode 100755 index 0000000..e88bbd0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-26-v6.19-net-pse-pd-pd692x0-Separate-configuration-parsing.patch @@ -0,0 +1,291 @@ +From 6fa1f8b64a47edd7d8420d8fd1008507aee2853e Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Mon, 13 Oct 2025 16:05:32 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Separate configuration parsing from + hardware setup + +Cache the port matrix configuration in driver private data to enable +PSE controller reconfiguration. This refactoring separates device tree +parsing from hardware configuration application, allowing settings to be +reapplied without reparsing the device tree. + +This refactoring is a prerequisite for preserving PSE configuration +across reboots to prevent power disruption to connected devices. + +Signed-off-by: Kory Maincent +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/20251013-feature_pd692x0_reboot_keep_conf-v2-2-68ab082a93dd@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 115 +++++++++++++++++++++++------------ + 1 file changed, 76 insertions(+), 39 deletions(-) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -85,6 +85,11 @@ enum { + PD692X0_MSG_CNT + }; + ++struct pd692x0_matrix { ++ u8 hw_port_a; ++ u8 hw_port_b; ++}; ++ + struct pd692x0_priv { + struct i2c_client *client; + struct pse_controller_dev pcdev; +@@ -101,6 +106,8 @@ struct pd692x0_priv { + enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS]; + struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS]; + int manager_pw_budget[PD692X0_MAX_MANAGERS]; ++ int nmanagers; ++ struct pd692x0_matrix *port_matrix; + }; + + /* Template list of communication messages. The non-null bytes defined here +@@ -809,11 +816,6 @@ struct pd692x0_manager { + int nports; + }; + +-struct pd692x0_matrix { +- u8 hw_port_a; +- u8 hw_port_b; +-}; +- + static int + pd692x0_of_get_ports_manager(struct pd692x0_priv *priv, + struct pd692x0_manager *manager, +@@ -903,7 +905,8 @@ pd692x0_of_get_managers(struct pd692x0_p + } + + of_node_put(managers_node); +- return nmanagers; ++ priv->nmanagers = nmanagers; ++ return 0; + + out: + for (i = 0; i < nmanagers; i++) { +@@ -963,8 +966,7 @@ pd692x0_register_manager_regulator(struc + + static int + pd692x0_register_managers_regulator(struct pd692x0_priv *priv, +- const struct pd692x0_manager *manager, +- int nmanagers) ++ const struct pd692x0_manager *manager) + { + struct device *dev = &priv->client->dev; + size_t reg_name_len; +@@ -975,7 +977,7 @@ pd692x0_register_managers_regulator(stru + */ + reg_name_len = strlen(dev_name(dev)) + 23; + +- for (i = 0; i < nmanagers; i++) { ++ for (i = 0; i < priv->nmanagers; i++) { + static const char * const regulators[] = { "vaux5", "vaux3p3" }; + struct regulator_dev *rdev; + char *reg_name; +@@ -1008,10 +1010,14 @@ pd692x0_register_managers_regulator(stru + } + + static int +-pd692x0_conf_manager_power_budget(struct pd692x0_priv *priv, int id, int pw) ++pd692x0_conf_manager_power_budget(struct pd692x0_priv *priv, int id) + { + struct pd692x0_msg msg, buf; +- int ret, pw_mW = pw / 1000; ++ int ret, pw_mW; ++ ++ pw_mW = priv->manager_pw_budget[id] / 1000; ++ if (!pw_mW) ++ return 0; + + msg = pd692x0_msg_template_list[PD692X0_MSG_GET_POWER_BANK]; + msg.data[0] = id; +@@ -1032,11 +1038,11 @@ pd692x0_conf_manager_power_budget(struct + } + + static int +-pd692x0_configure_managers(struct pd692x0_priv *priv, int nmanagers) ++pd692x0_req_managers_pw_budget(struct pd692x0_priv *priv) + { + int i, ret; + +- for (i = 0; i < nmanagers; i++) { ++ for (i = 0; i < priv->nmanagers; i++) { + struct regulator *supply = priv->manager_reg[i]->supply; + int pw_budget; + +@@ -1053,7 +1059,18 @@ pd692x0_configure_managers(struct pd692x + return ret; + + priv->manager_pw_budget[i] = pw_budget; +- ret = pd692x0_conf_manager_power_budget(priv, i, pw_budget); ++ } ++ ++ return 0; ++} ++ ++static int ++pd692x0_configure_managers(struct pd692x0_priv *priv) ++{ ++ int i, ret; ++ ++ for (i = 0; i < priv->nmanagers; i++) { ++ ret = pd692x0_conf_manager_power_budget(priv, i); + if (ret < 0) + return ret; + } +@@ -1101,10 +1118,9 @@ pd692x0_set_port_matrix(const struct pse + + static int + pd692x0_set_ports_matrix(struct pd692x0_priv *priv, +- const struct pd692x0_manager *manager, +- int nmanagers, +- struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]) ++ const struct pd692x0_manager *manager) + { ++ struct pd692x0_matrix *port_matrix = priv->port_matrix; + struct pse_controller_dev *pcdev = &priv->pcdev; + int i, ret; + +@@ -1117,7 +1133,7 @@ pd692x0_set_ports_matrix(struct pd692x0_ + /* Update with values for every PSE PIs */ + for (i = 0; i < pcdev->nr_lines; i++) { + ret = pd692x0_set_port_matrix(&pcdev->pi[i].pairset[0], +- manager, nmanagers, ++ manager, priv->nmanagers, + &port_matrix[i]); + if (ret) { + dev_err(&priv->client->dev, +@@ -1126,7 +1142,7 @@ pd692x0_set_ports_matrix(struct pd692x0_ + } + + ret = pd692x0_set_port_matrix(&pcdev->pi[i].pairset[1], +- manager, nmanagers, ++ manager, priv->nmanagers, + &port_matrix[i]); + if (ret) { + dev_err(&priv->client->dev, +@@ -1139,9 +1155,9 @@ pd692x0_set_ports_matrix(struct pd692x0_ + } + + static int +-pd692x0_write_ports_matrix(struct pd692x0_priv *priv, +- const struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]) ++pd692x0_write_ports_matrix(struct pd692x0_priv *priv) + { ++ struct pd692x0_matrix *port_matrix = priv->port_matrix; + struct pd692x0_msg msg, buf; + int ret, i; + +@@ -1166,13 +1182,32 @@ pd692x0_write_ports_matrix(struct pd692x + return 0; + } + ++static int pd692x0_hw_conf_init(struct pd692x0_priv *priv) ++{ ++ int ret; ++ ++ /* Is PD692x0 ready to be configured? */ ++ if (priv->fw_state != PD692X0_FW_OK && ++ priv->fw_state != PD692X0_FW_COMPLETE) ++ return 0; ++ ++ ret = pd692x0_configure_managers(priv); ++ if (ret) ++ return ret; ++ ++ ret = pd692x0_write_ports_matrix(priv); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ + static void pd692x0_of_put_managers(struct pd692x0_priv *priv, +- struct pd692x0_manager *manager, +- int nmanagers) ++ struct pd692x0_manager *manager) + { + int i, j; + +- for (i = 0; i < nmanagers; i++) { ++ for (i = 0; i < priv->nmanagers; i++) { + for (j = 0; j < manager[i].nports; j++) + of_node_put(manager[i].port_node[j]); + of_node_put(manager[i].node); +@@ -1201,48 +1236,50 @@ static void pd692x0_managers_free_pw_bud + static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) + { + struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); +- struct pd692x0_matrix port_matrix[PD692X0_MAX_PIS]; ++ struct pd692x0_matrix *port_matrix; + struct pd692x0_manager *manager; +- int ret, nmanagers; +- +- /* Should we flash the port matrix */ +- if (priv->fw_state != PD692X0_FW_OK && +- priv->fw_state != PD692X0_FW_COMPLETE) +- return 0; ++ int ret; + + manager = kcalloc(PD692X0_MAX_MANAGERS, sizeof(*manager), GFP_KERNEL); + if (!manager) + return -ENOMEM; + ++ port_matrix = devm_kcalloc(&priv->client->dev, PD692X0_MAX_PIS, ++ sizeof(*port_matrix), GFP_KERNEL); ++ if (!port_matrix) { ++ ret = -ENOMEM; ++ goto err_free_manager; ++ } ++ priv->port_matrix = port_matrix; ++ + ret = pd692x0_of_get_managers(priv, manager); + if (ret < 0) + goto err_free_manager; + +- nmanagers = ret; +- ret = pd692x0_register_managers_regulator(priv, manager, nmanagers); ++ ret = pd692x0_register_managers_regulator(priv, manager); + if (ret) + goto err_of_managers; + +- ret = pd692x0_configure_managers(priv, nmanagers); ++ ret = pd692x0_req_managers_pw_budget(priv); + if (ret) + goto err_of_managers; + +- ret = pd692x0_set_ports_matrix(priv, manager, nmanagers, port_matrix); ++ ret = pd692x0_set_ports_matrix(priv, manager); + if (ret) + goto err_managers_req_pw; + +- ret = pd692x0_write_ports_matrix(priv, port_matrix); ++ ret = pd692x0_hw_conf_init(priv); + if (ret) + goto err_managers_req_pw; + +- pd692x0_of_put_managers(priv, manager, nmanagers); ++ pd692x0_of_put_managers(priv, manager); + kfree(manager); + return 0; + + err_managers_req_pw: + pd692x0_managers_free_pw_budget(priv); + err_of_managers: +- pd692x0_of_put_managers(priv, manager, nmanagers); ++ pd692x0_of_put_managers(priv, manager); + err_free_manager: + kfree(manager); + return ret; +@@ -1647,7 +1684,7 @@ static enum fw_upload_err pd692x0_fw_pol + return FW_UPLOAD_ERR_FW_INVALID; + } + +- ret = pd692x0_setup_pi_matrix(&priv->pcdev); ++ ret = pd692x0_hw_conf_init(priv); + if (ret < 0) { + dev_err(&client->dev, "Error configuring ports matrix (%pe)\n", + ERR_PTR(ret)); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-27-v6.19-net-pse-pd-pd692x0-Preserve-PSE-configuration.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-27-v6.19-net-pse-pd-pd692x0-Preserve-PSE-configuration.patch new file mode 100755 index 0000000..4ae835e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-27-v6.19-net-pse-pd-pd692x0-Preserve-PSE-configuration.patch @@ -0,0 +1,111 @@ +From 8f3d044b34fe99b894046edb84605456195cabc0 Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Mon, 13 Oct 2025 16:05:33 +0200 +Subject: [PATCH] net: pse-pd: pd692x0: Preserve PSE configuration across + reboots + +Detect when PSE hardware is already configured (user byte == 42) and +skip hardware initialization to prevent power interruption to connected +devices during system reboots. + +Previously, the driver would always reconfigure the PSE hardware on +probe, causing a port matrix reflash that resulted in temporary power +loss to all connected devices. This change maintains power continuity +by preserving existing configuration when the PSE has been previously +initialized. + +Signed-off-by: Kory Maincent +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/20251013-feature_pd692x0_reboot_keep_conf-v2-3-68ab082a93dd@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/pd692x0.c | 35 ++++++++++++++++++++++++++++++++--- + 1 file changed, 32 insertions(+), 3 deletions(-) + +--- a/drivers/net/pse-pd/pd692x0.c ++++ b/drivers/net/pse-pd/pd692x0.c +@@ -30,6 +30,8 @@ + #define PD692X0_FW_MIN_VER 5 + #define PD692X0_FW_PATCH_VER 5 + ++#define PD692X0_USER_BYTE 42 ++ + enum pd692x0_fw_state { + PD692X0_FW_UNKNOWN, + PD692X0_FW_OK, +@@ -80,6 +82,7 @@ enum { + PD692X0_MSG_GET_PORT_PARAM, + PD692X0_MSG_GET_POWER_BANK, + PD692X0_MSG_SET_POWER_BANK, ++ PD692X0_MSG_SET_USER_BYTE, + + /* add new message above here */ + PD692X0_MSG_CNT +@@ -103,6 +106,7 @@ struct pd692x0_priv { + bool last_cmd_key; + unsigned long last_cmd_key_time; + ++ bool cfg_saved; + enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS]; + struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS]; + int manager_pw_budget[PD692X0_MAX_MANAGERS]; +@@ -193,6 +197,12 @@ static const struct pd692x0_msg pd692x0_ + .key = PD692X0_KEY_CMD, + .sub = {0x07, 0x0b, 0x57}, + }, ++ [PD692X0_MSG_SET_USER_BYTE] = { ++ .key = PD692X0_KEY_PRG, ++ .sub = {0x41, PD692X0_USER_BYTE}, ++ .data = {0x4e, 0x4e, 0x4e, 0x4e, ++ 0x4e, 0x4e, 0x4e, 0x4e}, ++ }, + }; + + static u8 pd692x0_build_msg(struct pd692x0_msg *msg, u8 echo) +@@ -1233,6 +1243,15 @@ static void pd692x0_managers_free_pw_bud + } + } + ++static int ++pd692x0_save_user_byte(struct pd692x0_priv *priv) ++{ ++ struct pd692x0_msg msg, buf; ++ ++ msg = pd692x0_msg_template_list[PD692X0_MSG_SET_USER_BYTE]; ++ return pd692x0_sendrecv_msg(priv, &msg, &buf); ++} ++ + static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) + { + struct pd692x0_priv *priv = to_pd692x0_priv(pcdev); +@@ -1268,9 +1287,16 @@ static int pd692x0_setup_pi_matrix(struc + if (ret) + goto err_managers_req_pw; + +- ret = pd692x0_hw_conf_init(priv); +- if (ret) +- goto err_managers_req_pw; ++ /* Do not init the conf if it is already saved */ ++ if (!priv->cfg_saved) { ++ ret = pd692x0_hw_conf_init(priv); ++ if (ret) ++ goto err_managers_req_pw; ++ ++ ret = pd692x0_save_user_byte(priv); ++ if (ret) ++ goto err_managers_req_pw; ++ } + + pd692x0_of_put_managers(priv, manager); + kfree(manager); +@@ -1793,6 +1819,9 @@ static int pd692x0_i2c_probe(struct i2c_ + } + } + ++ if (buf.data[2] == PD692X0_USER_BYTE) ++ priv->cfg_saved = true; ++ + priv->np = dev->of_node; + priv->pcdev.nr_lines = PD692X0_MAX_PIS; + priv->pcdev.owner = THIS_MODULE; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-28-v6.19-net-pse-pd-tps23881-Add-support-for-TPS23881B.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-28-v6.19-net-pse-pd-tps23881-Add-support-for-TPS23881B.patch new file mode 100755 index 0000000..2c188db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-28-v6.19-net-pse-pd-tps23881-Add-support-for-TPS23881B.patch @@ -0,0 +1,170 @@ +From 4d07797faaa19aa8e80e10a04ca1a72c643ef5cf Mon Sep 17 00:00:00 2001 +From: Thomas Wismer +Date: Wed, 29 Oct 2025 22:23:09 +0100 +Subject: [PATCH] net: pse-pd: tps23881: Add support for TPS23881B + +The TPS23881B uses different firmware than the TPS23881. Trying to load the +TPS23881 firmware on a TPS23881B device fails and must be omitted. + +The TPS23881B ships with a more recent ROM firmware. Moreover, no updated +firmware has been released yet and so the firmware loading step must be +skipped. As of today, the TPS23881B is intended to use its ROM firmware. + +Signed-off-by: Thomas Wismer +Reviewed-by: Kory Maincent +Acked-by: Oleksij Rempel +Link: https://patch.msgid.link/20251029212312.108749-2-thomas@wismer.xyz +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + drivers/net/pse-pd/tps23881.c | 69 +++++++++++++++++++++++++++-------- + 1 file changed, 54 insertions(+), 15 deletions(-) + +--- a/drivers/net/pse-pd/tps23881.c ++++ b/drivers/net/pse-pd/tps23881.c +@@ -55,8 +55,6 @@ + #define TPS23881_REG_TPON BIT(0) + #define TPS23881_REG_FWREV 0x41 + #define TPS23881_REG_DEVID 0x43 +-#define TPS23881_REG_DEVID_MASK 0xF0 +-#define TPS23881_DEVICE_ID 0x02 + #define TPS23881_REG_CHAN1_CLASS 0x4c + #define TPS23881_REG_SRAM_CTRL 0x60 + #define TPS23881_REG_SRAM_DATA 0x61 +@@ -1012,8 +1010,28 @@ static const struct pse_controller_ops t + .pi_get_pw_req = tps23881_pi_get_pw_req, + }; + +-static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin"; +-static const char fw_sram_name[] = "ti/tps23881/tps23881-sram-14.bin"; ++struct tps23881_info { ++ u8 dev_id; /* device ID and silicon revision */ ++ const char *fw_parity_name; /* parity code firmware file name */ ++ const char *fw_sram_name; /* SRAM code firmware file name */ ++}; ++ ++enum tps23881_model { ++ TPS23881, ++ TPS23881B, ++}; ++ ++static const struct tps23881_info tps23881_info[] = { ++ [TPS23881] = { ++ .dev_id = 0x22, ++ .fw_parity_name = "ti/tps23881/tps23881-parity-14.bin", ++ .fw_sram_name = "ti/tps23881/tps23881-sram-14.bin", ++ }, ++ [TPS23881B] = { ++ .dev_id = 0x24, ++ /* skip SRAM load, ROM provides Clause 145 hardware-level support */ ++ }, ++}; + + struct tps23881_fw_conf { + u8 reg; +@@ -1085,16 +1103,17 @@ out: + return ret; + } + +-static int tps23881_flash_sram_fw(struct i2c_client *client) ++static int tps23881_flash_sram_fw(struct i2c_client *client, ++ const struct tps23881_info *info) + { + int ret; + +- ret = tps23881_flash_sram_fw_part(client, fw_parity_name, ++ ret = tps23881_flash_sram_fw_part(client, info->fw_parity_name, + tps23881_fw_parity_conf); + if (ret) + return ret; + +- ret = tps23881_flash_sram_fw_part(client, fw_sram_name, ++ ret = tps23881_flash_sram_fw_part(client, info->fw_sram_name, + tps23881_fw_sram_conf); + if (ret) + return ret; +@@ -1412,6 +1431,7 @@ static int tps23881_setup_irq(struct tps + static int tps23881_i2c_probe(struct i2c_client *client) + { + struct device *dev = &client->dev; ++ const struct tps23881_info *info; + struct tps23881_priv *priv; + struct gpio_desc *reset; + int ret; +@@ -1422,6 +1442,10 @@ static int tps23881_i2c_probe(struct i2c + return -ENXIO; + } + ++ info = i2c_get_match_data(client); ++ if (!info) ++ return -EINVAL; ++ + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; +@@ -1440,7 +1464,7 @@ static int tps23881_i2c_probe(struct i2c + * to Load TPS2388x SRAM and Parity Code over I2C" (Rev E)) + * indicates we should delay that programming by at least 50ms. So + * we'll wait the entire 50ms here to ensure we're safe to go to the +- * SRAM loading proceedure. ++ * SRAM loading procedure. + */ + msleep(50); + } +@@ -1449,20 +1473,27 @@ static int tps23881_i2c_probe(struct i2c + if (ret < 0) + return ret; + +- if (FIELD_GET(TPS23881_REG_DEVID_MASK, ret) != TPS23881_DEVICE_ID) { ++ if (ret != info->dev_id) { + dev_err(dev, "Wrong device ID\n"); + return -ENXIO; + } + +- ret = tps23881_flash_sram_fw(client); +- if (ret < 0) +- return ret; ++ if (info->fw_sram_name) { ++ ret = tps23881_flash_sram_fw(client, info); ++ if (ret < 0) ++ return ret; ++ } + + ret = i2c_smbus_read_byte_data(client, TPS23881_REG_FWREV); + if (ret < 0) + return ret; + +- dev_info(&client->dev, "Firmware revision 0x%x\n", ret); ++ if (ret == 0xFF) { ++ dev_err(&client->dev, "Device entered safe mode\n"); ++ return -ENXIO; ++ } ++ dev_info(&client->dev, "Firmware revision 0x%x%s\n", ret, ++ ret == 0x00 ? " (ROM firmware)" : ""); + + /* Set configuration B, 16 bit access on a single device address */ + ret = i2c_smbus_read_byte_data(client, TPS23881_REG_GEN_MASK); +@@ -1498,13 +1529,21 @@ static int tps23881_i2c_probe(struct i2c + } + + static const struct i2c_device_id tps23881_id[] = { +- { "tps23881" }, ++ { "tps23881", .driver_data = (kernel_ulong_t)&tps23881_info[TPS23881] }, ++ { "tps23881b", .driver_data = (kernel_ulong_t)&tps23881_info[TPS23881B] }, + { } + }; + MODULE_DEVICE_TABLE(i2c, tps23881_id); + + static const struct of_device_id tps23881_of_match[] = { +- { .compatible = "ti,tps23881", }, ++ { ++ .compatible = "ti,tps23881", ++ .data = &tps23881_info[TPS23881] ++ }, ++ { ++ .compatible = "ti,tps23881b", ++ .data = &tps23881_info[TPS23881B] ++ }, + { }, + }; + MODULE_DEVICE_TABLE(of, tps23881_of_match); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-v6.16-net-bridge-locally-receive-all-multicast-packets-if-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-v6.16-net-bridge-locally-receive-all-multicast-packets-if-.patch new file mode 100755 index 0000000..d9bd8c7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/626-v6.16-net-bridge-locally-receive-all-multicast-packets-if-.patch @@ -0,0 +1,41 @@ +From a496d2f0fd612ab9e10700afe00dc9267bad788b Mon Sep 17 00:00:00 2001 +From: Shengyu Qu +Date: Mon, 14 Apr 2025 18:56:01 +0800 +Subject: net: bridge: locally receive all multicast packets if IFF_ALLMULTI is + set + +If multicast snooping is enabled, multicast packets may not always end up +on the local bridge interface, if the host is not a member of the multicast +group. Similar to how IFF_PROMISC allows all packets to be received +locally, let IFF_ALLMULTI allow all multicast packets to be received. + +OpenWrt uses a user space daemon for DHCPv6/RA/NDP handling, and in relay +mode it sets the ALLMULTI flag in order to receive all relevant queries on +the network. + +This works for normal network interfaces and non-snooping bridges, but not +snooping bridges (unless multicast routing is enabled). + +Reported-by: Felix Fietkau +Closes: https://github.com/openwrt/openwrt/issues/15857#issuecomment-2662851243 +Signed-off-by: Shengyu Qu +Reviewed-by: Ido Schimmel +Acked-by: Nikolay Aleksandrov +Link: https://patch.msgid.link/OSZPR01MB8434308370ACAFA90A22980798B32@OSZPR01MB8434.jpnprd01.prod.outlook.com +Signed-off-by: Jakub Kicinski +--- + net/bridge/br_input.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/net/bridge/br_input.c ++++ b/net/bridge/br_input.c +@@ -184,7 +184,8 @@ int br_handle_frame_finish(struct net *n + if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && + br_multicast_querier_exists(brmctx, eth_hdr(skb), mdst)) { + if ((mdst && mdst->host_joined) || +- br_multicast_is_router(brmctx, skb)) { ++ br_multicast_is_router(brmctx, skb) || ++ br->dev->flags & IFF_ALLMULTI) { + local_rcv = true; + DEV_STATS_INC(br->dev, multicast); + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/627-01-v6.17-net-pse-pd-Add-ethtool_netlink_generated-header.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/627-01-v6.17-net-pse-pd-Add-ethtool_netlink_generated-header.patch new file mode 100755 index 0000000..f773fb6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/627-01-v6.17-net-pse-pd-Add-ethtool_netlink_generated-header.patch @@ -0,0 +1,79 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: OpenWrt PSE-PD Backport +Date: Fri, 31 Jan 2025 00:00:00 +0000 +Subject: [PATCH] net: pse-pd: Add ethtool netlink definitions for PSE events + and priority + +GENERATED PATCH - OpenWrt PSE-PD Backport + +This patch: +1. Adds ETHTOOL_A_PSE_PW_D_ID, ETHTOOL_A_PSE_PRIO_MAX, ETHTOOL_A_PSE_PRIO to + the ETHTOOL_A_PSE_* enum in ethtool_netlink.h (backported from kernel 6.17+) +2. Creates include/uapi/linux/ethtool_netlink_generated.h with PSE event + definitions (in mainline 6.17+, this file is auto-generated) +3. Adds ETHTOOL_MSG_PSE_NTF to the kernel message types enum + +These definitions are required by PSE event reporting and priority patches. + +Signed-off-by: OpenWrt PSE-PD Backport +Signed-off-by: Carlo Szelinsky +--- + include/uapi/linux/ethtool_netlink.h | 4 ++ + include/uapi/linux/ethtool_netlink_generated.h | 31 ++++++++++++++++++++++++++ + 2 files changed, 35 insertions(+) + create mode 100644 include/uapi/linux/ethtool_netlink_generated.h + +--- a/include/uapi/linux/ethtool_netlink.h ++++ b/include/uapi/linux/ethtool_netlink.h +@@ -115,6 +115,7 @@ enum { + ETHTOOL_MSG_PHY_GET_REPLY, + ETHTOOL_MSG_PHY_NTF, + ++ ETHTOOL_MSG_PSE_NTF, + /* add new constants above here */ + __ETHTOOL_MSG_KERNEL_CNT, + ETHTOOL_MSG_KERNEL_MAX = __ETHTOOL_MSG_KERNEL_CNT - 1 +@@ -970,6 +971,9 @@ enum { + ETHTOOL_A_C33_PSE_EXT_SUBSTATE, /* u32 */ + ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT, /* u32 */ + ETHTOOL_A_C33_PSE_PW_LIMIT_RANGES, /* nest - _C33_PSE_PW_LIMIT_* */ ++ ETHTOOL_A_PSE_PW_D_ID, /* u32 */ ++ ETHTOOL_A_PSE_PRIO_MAX, /* u32 */ ++ ETHTOOL_A_PSE_PRIO, /* u32 */ + + /* add new constants above here */ + __ETHTOOL_A_PSE_CNT, +--- /dev/null ++++ b/include/uapi/linux/ethtool_netlink_generated.h +@@ -0,0 +1,31 @@ ++/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ ++/* PSE ethtool netlink definitions - OpenWrt backport for 6.12 */ ++ ++#ifndef _UAPI_LINUX_ETHTOOL_NETLINK_GENERATED_H ++#define _UAPI_LINUX_ETHTOOL_NETLINK_GENERATED_H ++ ++enum ethtool_pse_event { ++ ETHTOOL_PSE_EVENT_OVER_CURRENT = 1, ++ ETHTOOL_PSE_EVENT_OVER_TEMP = 2, ++ ETHTOOL_C33_PSE_EVENT_DETECTION = 4, ++ ETHTOOL_C33_PSE_EVENT_CLASSIFICATION = 8, ++ ETHTOOL_C33_PSE_EVENT_DISCONNECTION = 16, ++ ETHTOOL_PSE_EVENT_OVER_BUDGET = 32, ++ ETHTOOL_PSE_EVENT_SW_PW_CONTROL_ERROR = 64, ++}; ++ ++enum { ++ ETHTOOL_A_PSE_NTF_HEADER = 1, ++ ETHTOOL_A_PSE_NTF_EVENTS, ++ __ETHTOOL_A_PSE_NTF_CNT, ++ ETHTOOL_A_PSE_NTF_MAX = (__ETHTOOL_A_PSE_NTF_CNT - 1) ++}; ++ ++enum { ++ ETHTOOL_A_PSE_NTF_EVT_UNSPEC, ++ ETHTOOL_A_PSE_NTF_EVT_INDEX, ++ __ETHTOOL_A_PSE_NTF_EVT_CNT, ++ ETHTOOL_A_PSE_NTF_EVT_MAX = (__ETHTOOL_A_PSE_NTF_EVT_CNT - 1) ++}; ++ ++#endif /* _UAPI_LINUX_ETHTOOL_NETLINK_GENERATED_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/627-02-v6.17-net-ethtool-Add-PSE-port-priority-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/627-02-v6.17-net-ethtool-Add-PSE-port-priority-support.patch new file mode 100755 index 0000000..06d9b11 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/627-02-v6.17-net-ethtool-Add-PSE-port-priority-support.patch @@ -0,0 +1,68 @@ +# ADAPTED FOR OPENWRT 6.12 - Documentation changes removed +# Original commit: eeb0c8f72f49 +From eeb0c8f72f49a21984981188404cfd3700edbaff Mon Sep 17 00:00:00 2001 +From: "Kory Maincent (Dent Project)" +Date: Tue, 17 Jun 2025 14:12:07 +0200 +Subject: [PATCH] net: ethtool: Add PSE port priority support feature + +This patch expands the status information provided by ethtool for PSE c33 +with current port priority and max port priority. It also adds a call to +pse_ethtool_set_prio() to configure the PSE port priority. + +Signed-off-by: Kory Maincent (Dent Project) +Reviewed-by: Oleksij Rempel +Link: https://patch.msgid.link/20250617-feature_poe_port_prio-v14-8-78a1a645e2ee@bootlin.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Carlo Szelinsky +--- + net/ethtool/pse-pd.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +--- a/net/ethtool/pse-pd.c ++++ b/net/ethtool/pse-pd.c +@@ -111,6 +111,9 @@ static int pse_reply_size(const struct e + len += st->c33_pw_limit_nb_ranges * + (nla_total_size(0) + + nla_total_size(sizeof(u32)) * 2); ++ if (st->prio_max) ++ /* _PSE_PRIO_MAX + _PSE_PRIO */ ++ len += nla_total_size(sizeof(u32)) * 2; + + return len; + } +@@ -205,6 +208,11 @@ static int pse_fill_reply(struct sk_buff + pse_put_pw_limit_ranges(skb, st)) + return -EMSGSIZE; + ++ if (st->prio_max && ++ (nla_put_u32(skb, ETHTOOL_A_PSE_PRIO_MAX, st->prio_max) || ++ nla_put_u32(skb, ETHTOOL_A_PSE_PRIO, st->prio))) ++ return -EMSGSIZE; ++ + return 0; + } + +@@ -226,6 +234,7 @@ const struct nla_policy ethnl_pse_set_po + NLA_POLICY_RANGE(NLA_U32, ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED, + ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED), + [ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT] = { .type = NLA_U32 }, ++ [ETHTOOL_A_PSE_PRIO] = { .type = NLA_U32 }, + }; + + static int +@@ -283,6 +292,15 @@ ethnl_set_pse(struct ethnl_req_info *req + if (ret) + return ret; + } ++ ++ if (tb[ETHTOOL_A_PSE_PRIO]) { ++ unsigned int prio; ++ ++ prio = nla_get_u32(tb[ETHTOOL_A_PSE_PRIO]); ++ ret = pse_ethtool_set_prio(phydev->psec, info->extack, prio); ++ if (ret) ++ return ret; ++ } + + /* These values are already validated by the ethnl_pse_set_policy */ + if (tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL] || diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/630-v6.13-net-usb-qmi_wwan-add-Quectel-RG255C.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/630-v6.13-net-usb-qmi_wwan-add-Quectel-RG255C.patch new file mode 100755 index 0000000..a1eb835 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/630-v6.13-net-usb-qmi_wwan-add-Quectel-RG255C.patch @@ -0,0 +1,47 @@ +From 5c964c8a97c12145104f5d2782aa1ffccf3a93dd Mon Sep 17 00:00:00 2001 +From: Martin Hou +Date: Mon, 16 Dec 2024 11:06:18 +0800 +Subject: [PATCH] net: usb: qmi_wwan: add Quectel RG255C + +Add support for Quectel RG255C which is based on Qualcomm SDX35 chip. +The composition is DM / NMEA / AT / QMI. + +T: Bus=01 Lev=01 Prnt=01 Port=04 Cnt=01 Dev#= 2 Spd=480 MxCh= 0 +D: Ver= 2.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 +P: Vendor=2c7c ProdID=0316 Rev= 5.15 +S: Manufacturer=Quectel +S: Product=RG255C-CN +S: SerialNumber=c68192c1 +C:* #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA +I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option +E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option +E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option +E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms +E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms +I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan +E: Ad=86(I) Atr=03(Int.) MxPS= 8 Ivl=32ms +E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms +E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms + +Signed-off-by: Martin Hou +Link: https://patch.msgid.link/tencent_17DDD787B48E8A5AB8379ED69E23A0CD9309@qq.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/usb/qmi_wwan.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/usb/qmi_wwan.c ++++ b/drivers/net/usb/qmi_wwan.c +@@ -1442,6 +1442,7 @@ static const struct usb_device_id produc + {QMI_QUIRK_SET_DTR(0x2c7c, 0x0195, 4)}, /* Quectel EG95 */ + {QMI_FIXED_INTF(0x2c7c, 0x0296, 4)}, /* Quectel BG96 */ + {QMI_QUIRK_SET_DTR(0x2c7c, 0x030e, 4)}, /* Quectel EM05GV2 */ ++ {QMI_QUIRK_SET_DTR(0x2c7c, 0x0316, 3)}, /* Quectel RG255C */ + {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */ + {QMI_QUIRK_SET_DTR(0x2cb7, 0x0112, 0)}, /* Fibocom FG132 */ + {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/630-v6.14-PM-sleep-wakeirq-Introduce-device-managed-variant-of.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/630-v6.14-PM-sleep-wakeirq-Introduce-device-managed-variant-of.patch new file mode 100755 index 0000000..081bcda --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/630-v6.14-PM-sleep-wakeirq-Introduce-device-managed-variant-of.patch @@ -0,0 +1,74 @@ +From fd8318a32573d73eb20637a0c80689de0dc98169 Mon Sep 17 00:00:00 2001 +From: Peng Fan +Date: Fri, 3 Jan 2025 16:41:13 +0800 +Subject: [PATCH] PM: sleep: wakeirq: Introduce device-managed variant of + dev_pm_set_wake_irq() + +Add device-managed variant of dev_pm_set_wake_irq which automatically +clear the wake irq on device destruction to simplify error handling +and resource management in drivers. + +Signed-off-by: Peng Fan +Link: https://patch.msgid.link/20250103-wake_irq-v2-1-e3aeff5e9966@nxp.com +Signed-off-by: Rafael J. Wysocki +--- + drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++ + include/linux/pm_wakeirq.h | 6 ++++++ + 2 files changed, 32 insertions(+) + +--- a/drivers/base/power/wakeirq.c ++++ b/drivers/base/power/wakeirq.c +@@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device + } + EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq); + ++static void devm_pm_clear_wake_irq(void *dev) ++{ ++ dev_pm_clear_wake_irq(dev); ++} ++ ++/** ++ * devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq ++ * @dev: Device entry ++ * @irq: Device IO interrupt ++ * ++ * ++ * Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq, ++ * but the device will be auto clear wake capability on driver detach. ++ */ ++int devm_pm_set_wake_irq(struct device *dev, int irq) ++{ ++ int ret; ++ ++ ret = dev_pm_set_wake_irq(dev, irq); ++ if (ret) ++ return ret; ++ ++ return devm_add_action_or_reset(dev, devm_pm_clear_wake_irq, dev); ++} ++EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq); ++ + /** + * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts + * @irq: Device specific dedicated wake-up interrupt +--- a/include/linux/pm_wakeirq.h ++++ b/include/linux/pm_wakeirq.h +@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct de + extern int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq); + extern int dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq); + extern void dev_pm_clear_wake_irq(struct device *dev); ++extern int devm_pm_set_wake_irq(struct device *dev, int irq); + + #else /* !CONFIG_PM */ + +@@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq + { + } + ++static inline int devm_pm_set_wake_irq(struct device *dev, int irq) ++{ ++ return 0; ++} ++ + #endif /* CONFIG_PM */ + #endif /* _LINUX_PM_WAKEIRQ_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-01-v7.0-net-sched-Export-mq-functions-for-reuse.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-01-v7.0-net-sched-Export-mq-functions-for-reuse.patch new file mode 100755 index 0000000..01439cd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-01-v7.0-net-sched-Export-mq-functions-for-reuse.patch @@ -0,0 +1,255 @@ +From 8560edcc05114e42d4d580baaf124bce8c291d55 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Fri, 9 Jan 2026 14:15:30 +0100 +Subject: [PATCH 1/7] net/sched: Export mq functions for reuse +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +To enable the cake_mq qdisc to reuse code from the mq qdisc, export a +bunch of functions from sch_mq. Split common functionality out from some +functions so it can be composed with other code, and export other +functions wholesale. To discourage wanton reuse, put the symbols into a +new NET_SCHED_INTERNAL namespace, and a sch_priv.h header file. + +No functional change intended. + +Reviewed-by: Willem de Bruijn +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-1-8d613fece5d8@redhat.com +Signed-off-by: Paolo Abeni +--- + MAINTAINERS | 1 + + include/net/sch_priv.h | 27 ++++++++++++++++ + net/sched/sch_mq.c | 71 +++++++++++++++++++++++++++++------------- + 3 files changed, 77 insertions(+), 22 deletions(-) + create mode 100644 include/net/sch_priv.h + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -22541,6 +22541,7 @@ L: netdev@vger.kernel.org + S: Maintained + F: include/net/pkt_cls.h + F: include/net/pkt_sched.h ++F: include/net/sch_priv.h + F: include/net/tc_act/ + F: include/uapi/linux/pkt_cls.h + F: include/uapi/linux/pkt_sched.h +--- /dev/null ++++ b/include/net/sch_priv.h +@@ -0,0 +1,27 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef __NET_SCHED_PRIV_H ++#define __NET_SCHED_PRIV_H ++ ++#include ++ ++struct mq_sched { ++ struct Qdisc **qdiscs; ++}; ++ ++int mq_init_common(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack, ++ const struct Qdisc_ops *qdisc_ops); ++void mq_destroy_common(struct Qdisc *sch); ++void mq_attach(struct Qdisc *sch); ++void mq_dump_common(struct Qdisc *sch, struct sk_buff *skb); ++struct netdev_queue *mq_select_queue(struct Qdisc *sch, ++ struct tcmsg *tcm); ++struct Qdisc *mq_leaf(struct Qdisc *sch, unsigned long cl); ++unsigned long mq_find(struct Qdisc *sch, u32 classid); ++int mq_dump_class(struct Qdisc *sch, unsigned long cl, ++ struct sk_buff *skb, struct tcmsg *tcm); ++int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl, ++ struct gnet_dump *d); ++void mq_walk(struct Qdisc *sch, struct qdisc_walker *arg); ++ ++#endif +--- a/net/sched/sch_mq.c ++++ b/net/sched/sch_mq.c +@@ -15,11 +15,7 @@ + #include + #include + #include +-#include +- +-struct mq_sched { +- struct Qdisc **qdiscs; +-}; ++#include + + static int mq_offload(struct Qdisc *sch, enum tc_mq_command cmd) + { +@@ -49,23 +45,29 @@ static int mq_offload_stats(struct Qdisc + return qdisc_offload_dump_helper(sch, TC_SETUP_QDISC_MQ, &opt); + } + +-static void mq_destroy(struct Qdisc *sch) ++void mq_destroy_common(struct Qdisc *sch) + { + struct net_device *dev = qdisc_dev(sch); + struct mq_sched *priv = qdisc_priv(sch); + unsigned int ntx; + +- mq_offload(sch, TC_MQ_DESTROY); +- + if (!priv->qdiscs) + return; + for (ntx = 0; ntx < dev->num_tx_queues && priv->qdiscs[ntx]; ntx++) + qdisc_put(priv->qdiscs[ntx]); + kfree(priv->qdiscs); + } ++EXPORT_SYMBOL_NS_GPL(mq_destroy_common, NET_SCHED_INTERNAL); + +-static int mq_init(struct Qdisc *sch, struct nlattr *opt, +- struct netlink_ext_ack *extack) ++static void mq_destroy(struct Qdisc *sch) ++{ ++ mq_offload(sch, TC_MQ_DESTROY); ++ mq_destroy_common(sch); ++} ++ ++int mq_init_common(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack, ++ const struct Qdisc_ops *qdisc_ops) + { + struct net_device *dev = qdisc_dev(sch); + struct mq_sched *priv = qdisc_priv(sch); +@@ -87,7 +89,8 @@ static int mq_init(struct Qdisc *sch, st + + for (ntx = 0; ntx < dev->num_tx_queues; ntx++) { + dev_queue = netdev_get_tx_queue(dev, ntx); +- qdisc = qdisc_create_dflt(dev_queue, get_default_qdisc_ops(dev, ntx), ++ qdisc = qdisc_create_dflt(dev_queue, ++ qdisc_ops ?: get_default_qdisc_ops(dev, ntx), + TC_H_MAKE(TC_H_MAJ(sch->handle), + TC_H_MIN(ntx + 1)), + extack); +@@ -98,12 +101,24 @@ static int mq_init(struct Qdisc *sch, st + } + + sch->flags |= TCQ_F_MQROOT; ++ return 0; ++} ++EXPORT_SYMBOL_NS_GPL(mq_init_common, NET_SCHED_INTERNAL); ++ ++static int mq_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++ int ret; ++ ++ ret = mq_init_common(sch, opt, extack, NULL); ++ if (ret) ++ return ret; + + mq_offload(sch, TC_MQ_CREATE); + return 0; + } + +-static void mq_attach(struct Qdisc *sch) ++void mq_attach(struct Qdisc *sch) + { + struct net_device *dev = qdisc_dev(sch); + struct mq_sched *priv = qdisc_priv(sch); +@@ -124,8 +139,9 @@ static void mq_attach(struct Qdisc *sch) + kfree(priv->qdiscs); + priv->qdiscs = NULL; + } ++EXPORT_SYMBOL_NS_GPL(mq_attach, NET_SCHED_INTERNAL); + +-static int mq_dump(struct Qdisc *sch, struct sk_buff *skb) ++void mq_dump_common(struct Qdisc *sch, struct sk_buff *skb) + { + struct net_device *dev = qdisc_dev(sch); + struct Qdisc *qdisc; +@@ -152,7 +168,12 @@ static int mq_dump(struct Qdisc *sch, st + + spin_unlock_bh(qdisc_lock(qdisc)); + } ++} ++EXPORT_SYMBOL_NS_GPL(mq_dump_common, NET_SCHED_INTERNAL); + ++static int mq_dump(struct Qdisc *sch, struct sk_buff *skb) ++{ ++ mq_dump_common(sch, skb); + return mq_offload_stats(sch); + } + +@@ -166,11 +187,12 @@ static struct netdev_queue *mq_queue_get + return netdev_get_tx_queue(dev, ntx); + } + +-static struct netdev_queue *mq_select_queue(struct Qdisc *sch, +- struct tcmsg *tcm) ++struct netdev_queue *mq_select_queue(struct Qdisc *sch, ++ struct tcmsg *tcm) + { + return mq_queue_get(sch, TC_H_MIN(tcm->tcm_parent)); + } ++EXPORT_SYMBOL_NS_GPL(mq_select_queue, NET_SCHED_INTERNAL); + + static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, + struct Qdisc **old, struct netlink_ext_ack *extack) +@@ -198,14 +220,15 @@ static int mq_graft(struct Qdisc *sch, u + return 0; + } + +-static struct Qdisc *mq_leaf(struct Qdisc *sch, unsigned long cl) ++struct Qdisc *mq_leaf(struct Qdisc *sch, unsigned long cl) + { + struct netdev_queue *dev_queue = mq_queue_get(sch, cl); + + return rtnl_dereference(dev_queue->qdisc_sleeping); + } ++EXPORT_SYMBOL_NS_GPL(mq_leaf, NET_SCHED_INTERNAL); + +-static unsigned long mq_find(struct Qdisc *sch, u32 classid) ++unsigned long mq_find(struct Qdisc *sch, u32 classid) + { + unsigned int ntx = TC_H_MIN(classid); + +@@ -213,9 +236,10 @@ static unsigned long mq_find(struct Qdis + return 0; + return ntx; + } ++EXPORT_SYMBOL_NS_GPL(mq_find, NET_SCHED_INTERNAL); + +-static int mq_dump_class(struct Qdisc *sch, unsigned long cl, +- struct sk_buff *skb, struct tcmsg *tcm) ++int mq_dump_class(struct Qdisc *sch, unsigned long cl, ++ struct sk_buff *skb, struct tcmsg *tcm) + { + struct netdev_queue *dev_queue = mq_queue_get(sch, cl); + +@@ -224,9 +248,10 @@ static int mq_dump_class(struct Qdisc *s + tcm->tcm_info = rtnl_dereference(dev_queue->qdisc_sleeping)->handle; + return 0; + } ++EXPORT_SYMBOL_NS_GPL(mq_dump_class, NET_SCHED_INTERNAL); + +-static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl, +- struct gnet_dump *d) ++int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl, ++ struct gnet_dump *d) + { + struct netdev_queue *dev_queue = mq_queue_get(sch, cl); + +@@ -236,8 +261,9 @@ static int mq_dump_class_stats(struct Qd + return -1; + return 0; + } ++EXPORT_SYMBOL_NS_GPL(mq_dump_class_stats, NET_SCHED_INTERNAL); + +-static void mq_walk(struct Qdisc *sch, struct qdisc_walker *arg) ++void mq_walk(struct Qdisc *sch, struct qdisc_walker *arg) + { + struct net_device *dev = qdisc_dev(sch); + unsigned int ntx; +@@ -251,6 +277,7 @@ static void mq_walk(struct Qdisc *sch, s + break; + } + } ++EXPORT_SYMBOL_NS_GPL(mq_walk, NET_SCHED_INTERNAL); + + static const struct Qdisc_class_ops mq_class_ops = { + .select_queue = mq_select_queue, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-02-v7.0-net-sched-sch_cake-Factor-out-config-variables-into-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-02-v7.0-net-sched-sch_cake-Factor-out-config-variables-into-.patch new file mode 100755 index 0000000..8df110b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-02-v7.0-net-sched-sch_cake-Factor-out-config-variables-into-.patch @@ -0,0 +1,636 @@ +From 23090d3e9db80c2a374df1e636247eff9b6dd972 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Fri, 9 Jan 2026 14:15:31 +0100 +Subject: [PATCH 2/7] net/sched: sch_cake: Factor out config variables into + separate struct +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Factor out all the user-configurable variables into a separate struct +and embed it into struct cake_sched_data. This is done in preparation +for sharing the configuration across multiple instances of cake in an mq +setup. + +No functional change is intended with this patch. + +Reviewed-by: Jamal Hadi Salim +Reviewed-by: Willem de Bruijn +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-2-8d613fece5d8@redhat.com +Signed-off-by: Paolo Abeni +--- + net/sched/sch_cake.c | 245 +++++++++++++++++++++++-------------------- + 1 file changed, 133 insertions(+), 112 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -197,40 +197,42 @@ struct cake_tin_data { + u32 way_collisions; + }; /* number of tins is small, so size of this struct doesn't matter much */ + ++struct cake_sched_config { ++ u64 rate_bps; ++ u64 interval; ++ u64 target; ++ u32 buffer_config_limit; ++ u32 fwmark_mask; ++ u16 fwmark_shft; ++ s16 rate_overhead; ++ u16 rate_mpu; ++ u16 rate_flags; ++ u8 tin_mode; ++ u8 flow_mode; ++ u8 atm_mode; ++ u8 ack_filter; ++}; ++ + struct cake_sched_data { + struct tcf_proto __rcu *filter_list; /* optional external classifier */ + struct tcf_block *block; + struct cake_tin_data *tins; ++ struct cake_sched_config *config; + + struct cake_heap_entry overflow_heap[CAKE_QUEUES * CAKE_MAX_TINS]; +- u16 overflow_timeout; +- +- u16 tin_cnt; +- u8 tin_mode; +- u8 flow_mode; +- u8 ack_filter; +- u8 atm_mode; +- +- u32 fwmark_mask; +- u16 fwmark_shft; + + /* time_next = time_this + ((len * rate_ns) >> rate_shft) */ +- u16 rate_shft; + ktime_t time_next_packet; + ktime_t failsafe_next_packet; + u64 rate_ns; +- u64 rate_bps; +- u16 rate_flags; +- s16 rate_overhead; +- u16 rate_mpu; +- u64 interval; +- u64 target; ++ u16 rate_shft; ++ u16 overflow_timeout; ++ u16 tin_cnt; + + /* resource tracking */ + u32 buffer_used; + u32 buffer_max_used; + u32 buffer_limit; +- u32 buffer_config_limit; + + /* indices for dequeue */ + u16 cur_tin; +@@ -1195,7 +1197,7 @@ static bool cake_tcph_may_drop(const str + static struct sk_buff *cake_ack_filter(struct cake_sched_data *q, + struct cake_flow *flow) + { +- bool aggressive = q->ack_filter == CAKE_ACK_AGGRESSIVE; ++ bool aggressive = q->config->ack_filter == CAKE_ACK_AGGRESSIVE; + struct sk_buff *elig_ack = NULL, *elig_ack_prev = NULL; + struct sk_buff *skb_check, *skb_prev = NULL; + const struct ipv6hdr *ipv6h, *ipv6h_check; +@@ -1355,15 +1357,17 @@ static u64 cake_ewma(u64 avg, u64 sample + return avg; + } + +-static u32 cake_calc_overhead(struct cake_sched_data *q, u32 len, u32 off) ++static u32 cake_calc_overhead(struct cake_sched_data *qd, u32 len, u32 off) + { ++ struct cake_sched_config *q = qd->config; ++ + if (q->rate_flags & CAKE_FLAG_OVERHEAD) + len -= off; + +- if (q->max_netlen < len) +- q->max_netlen = len; +- if (q->min_netlen > len) +- q->min_netlen = len; ++ if (qd->max_netlen < len) ++ qd->max_netlen = len; ++ if (qd->min_netlen > len) ++ qd->min_netlen = len; + + len += q->rate_overhead; + +@@ -1382,10 +1386,10 @@ static u32 cake_calc_overhead(struct cak + len += (len + 63) / 64; + } + +- if (q->max_adjlen < len) +- q->max_adjlen = len; +- if (q->min_adjlen > len) +- q->min_adjlen = len; ++ if (qd->max_adjlen < len) ++ qd->max_adjlen = len; ++ if (qd->min_adjlen > len) ++ qd->min_adjlen = len; + + return len; + } +@@ -1587,7 +1591,7 @@ static unsigned int cake_drop(struct Qdi + b->tin_dropped++; + sch->qstats.drops++; + +- if (q->rate_flags & CAKE_FLAG_INGRESS) ++ if (q->config->rate_flags & CAKE_FLAG_INGRESS) + cake_advance_shaper(q, b, skb, now, true); + + __qdisc_drop(skb, to_free); +@@ -1657,7 +1661,8 @@ static u8 cake_handle_diffserv(struct sk + static struct cake_tin_data *cake_select_tin(struct Qdisc *sch, + struct sk_buff *skb) + { +- struct cake_sched_data *q = qdisc_priv(sch); ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ struct cake_sched_config *q = qd->config; + u32 tin, mark; + bool wash; + u8 dscp; +@@ -1674,24 +1679,24 @@ static struct cake_tin_data *cake_select + if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT) + tin = 0; + +- else if (mark && mark <= q->tin_cnt) +- tin = q->tin_order[mark - 1]; ++ else if (mark && mark <= qd->tin_cnt) ++ tin = qd->tin_order[mark - 1]; + + else if (TC_H_MAJ(skb->priority) == sch->handle && + TC_H_MIN(skb->priority) > 0 && +- TC_H_MIN(skb->priority) <= q->tin_cnt) +- tin = q->tin_order[TC_H_MIN(skb->priority) - 1]; ++ TC_H_MIN(skb->priority) <= qd->tin_cnt) ++ tin = qd->tin_order[TC_H_MIN(skb->priority) - 1]; + + else { + if (!wash) + dscp = cake_handle_diffserv(skb, wash); +- tin = q->tin_index[dscp]; ++ tin = qd->tin_index[dscp]; + +- if (unlikely(tin >= q->tin_cnt)) ++ if (unlikely(tin >= qd->tin_cnt)) + tin = 0; + } + +- return &q->tins[tin]; ++ return &qd->tins[tin]; + } + + static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t, +@@ -1747,7 +1752,7 @@ static s32 cake_enqueue(struct sk_buff * + bool same_flow = false; + + /* choose flow to insert into */ +- idx = cake_classify(sch, &b, skb, q->flow_mode, &ret); ++ idx = cake_classify(sch, &b, skb, q->config->flow_mode, &ret); + if (idx == 0) { + if (ret & __NET_XMIT_BYPASS) + qdisc_qstats_drop(sch); +@@ -1782,7 +1787,7 @@ static s32 cake_enqueue(struct sk_buff * + if (unlikely(len > b->max_skblen)) + b->max_skblen = len; + +- if (skb_is_gso(skb) && q->rate_flags & CAKE_FLAG_SPLIT_GSO) { ++ if (skb_is_gso(skb) && q->config->rate_flags & CAKE_FLAG_SPLIT_GSO) { + struct sk_buff *segs, *nskb; + netdev_features_t features = netif_skb_features(skb); + unsigned int slen = 0, numsegs = 0; +@@ -1823,7 +1828,7 @@ static s32 cake_enqueue(struct sk_buff * + get_cobalt_cb(skb)->adjusted_len = cake_overhead(q, skb); + flow_queue_add(flow, skb); + +- if (q->ack_filter) ++ if (q->config->ack_filter) + ack = cake_ack_filter(q, flow); + + if (ack) { +@@ -1832,7 +1837,7 @@ static s32 cake_enqueue(struct sk_buff * + ack_pkt_len = qdisc_pkt_len(ack); + b->bytes += ack_pkt_len; + q->buffer_used += skb->truesize - ack->truesize; +- if (q->rate_flags & CAKE_FLAG_INGRESS) ++ if (q->config->rate_flags & CAKE_FLAG_INGRESS) + cake_advance_shaper(q, b, ack, now, true); + + qdisc_tree_reduce_backlog(sch, 1, ack_pkt_len); +@@ -1855,7 +1860,7 @@ static s32 cake_enqueue(struct sk_buff * + cake_heapify_up(q, b->overflow_idx[idx]); + + /* incoming bandwidth capacity estimate */ +- if (q->rate_flags & CAKE_FLAG_AUTORATE_INGRESS) { ++ if (q->config->rate_flags & CAKE_FLAG_AUTORATE_INGRESS) { + u64 packet_interval = \ + ktime_to_ns(ktime_sub(now, q->last_packet_time)); + +@@ -1887,7 +1892,7 @@ static s32 cake_enqueue(struct sk_buff * + if (ktime_after(now, + ktime_add_ms(q->last_reconfig_time, + 250))) { +- q->rate_bps = (q->avg_peak_bandwidth * 15) >> 4; ++ q->config->rate_bps = (q->avg_peak_bandwidth * 15) >> 4; + cake_reconfigure(sch); + } + } +@@ -1907,7 +1912,7 @@ static s32 cake_enqueue(struct sk_buff * + flow->set = CAKE_SET_SPARSE; + b->sparse_flow_count++; + +- flow->deficit = cake_get_flow_quantum(b, flow, q->flow_mode); ++ flow->deficit = cake_get_flow_quantum(b, flow, q->config->flow_mode); + } else if (flow->set == CAKE_SET_SPARSE_WAIT) { + /* this flow was empty, accounted as a sparse flow, but actually + * in the bulk rotation. +@@ -1916,8 +1921,8 @@ static s32 cake_enqueue(struct sk_buff * + b->sparse_flow_count--; + b->bulk_flow_count++; + +- cake_inc_srchost_bulk_flow_count(b, flow, q->flow_mode); +- cake_inc_dsthost_bulk_flow_count(b, flow, q->flow_mode); ++ cake_inc_srchost_bulk_flow_count(b, flow, q->config->flow_mode); ++ cake_inc_dsthost_bulk_flow_count(b, flow, q->config->flow_mode); + } + + if (q->buffer_used > q->buffer_max_used) +@@ -2103,8 +2108,8 @@ retry: + b->sparse_flow_count--; + b->bulk_flow_count++; + +- cake_inc_srchost_bulk_flow_count(b, flow, q->flow_mode); +- cake_inc_dsthost_bulk_flow_count(b, flow, q->flow_mode); ++ cake_inc_srchost_bulk_flow_count(b, flow, q->config->flow_mode); ++ cake_inc_dsthost_bulk_flow_count(b, flow, q->config->flow_mode); + + flow->set = CAKE_SET_BULK; + } else { +@@ -2116,7 +2121,7 @@ retry: + } + } + +- flow->deficit += cake_get_flow_quantum(b, flow, q->flow_mode); ++ flow->deficit += cake_get_flow_quantum(b, flow, q->config->flow_mode); + list_move_tail(&flow->flowchain, &b->old_flows); + + goto retry; +@@ -2140,8 +2145,8 @@ retry: + if (flow->set == CAKE_SET_BULK) { + b->bulk_flow_count--; + +- cake_dec_srchost_bulk_flow_count(b, flow, q->flow_mode); +- cake_dec_dsthost_bulk_flow_count(b, flow, q->flow_mode); ++ cake_dec_srchost_bulk_flow_count(b, flow, q->config->flow_mode); ++ cake_dec_dsthost_bulk_flow_count(b, flow, q->config->flow_mode); + + b->decaying_flow_count++; + } else if (flow->set == CAKE_SET_SPARSE || +@@ -2159,8 +2164,8 @@ retry: + else if (flow->set == CAKE_SET_BULK) { + b->bulk_flow_count--; + +- cake_dec_srchost_bulk_flow_count(b, flow, q->flow_mode); +- cake_dec_dsthost_bulk_flow_count(b, flow, q->flow_mode); ++ cake_dec_srchost_bulk_flow_count(b, flow, q->config->flow_mode); ++ cake_dec_dsthost_bulk_flow_count(b, flow, q->config->flow_mode); + } else + b->decaying_flow_count--; + +@@ -2172,13 +2177,13 @@ retry: + /* Last packet in queue may be marked, shouldn't be dropped */ + if (!cobalt_should_drop(&flow->cvars, &b->cparams, now, skb, + (b->bulk_flow_count * +- !!(q->rate_flags & ++ !!(q->config->rate_flags & + CAKE_FLAG_INGRESS))) || + !flow->head) + break; + + /* drop this packet, get another one */ +- if (q->rate_flags & CAKE_FLAG_INGRESS) { ++ if (q->config->rate_flags & CAKE_FLAG_INGRESS) { + len = cake_advance_shaper(q, b, skb, + now, true); + flow->deficit -= len; +@@ -2189,7 +2194,7 @@ retry: + qdisc_tree_reduce_backlog(sch, 1, qdisc_pkt_len(skb)); + qdisc_qstats_drop(sch); + kfree_skb(skb); +- if (q->rate_flags & CAKE_FLAG_INGRESS) ++ if (q->config->rate_flags & CAKE_FLAG_INGRESS) + goto retry; + } + +@@ -2311,7 +2316,7 @@ static int cake_config_besteffort(struct + struct cake_sched_data *q = qdisc_priv(sch); + struct cake_tin_data *b = &q->tins[0]; + u32 mtu = psched_mtu(qdisc_dev(sch)); +- u64 rate = q->rate_bps; ++ u64 rate = q->config->rate_bps; + + q->tin_cnt = 1; + +@@ -2319,7 +2324,7 @@ static int cake_config_besteffort(struct + q->tin_order = normal_order; + + cake_set_rate(b, rate, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + b->tin_quantum = 65535; + + return 0; +@@ -2330,7 +2335,7 @@ static int cake_config_precedence(struct + /* convert high-level (user visible) parameters into internal format */ + struct cake_sched_data *q = qdisc_priv(sch); + u32 mtu = psched_mtu(qdisc_dev(sch)); +- u64 rate = q->rate_bps; ++ u64 rate = q->config->rate_bps; + u32 quantum = 256; + u32 i; + +@@ -2341,8 +2346,8 @@ static int cake_config_precedence(struct + for (i = 0; i < q->tin_cnt; i++) { + struct cake_tin_data *b = &q->tins[i]; + +- cake_set_rate(b, rate, mtu, us_to_ns(q->target), +- us_to_ns(q->interval)); ++ cake_set_rate(b, rate, mtu, us_to_ns(q->config->target), ++ us_to_ns(q->config->interval)); + + b->tin_quantum = max_t(u16, 1U, quantum); + +@@ -2419,7 +2424,7 @@ static int cake_config_diffserv8(struct + + struct cake_sched_data *q = qdisc_priv(sch); + u32 mtu = psched_mtu(qdisc_dev(sch)); +- u64 rate = q->rate_bps; ++ u64 rate = q->config->rate_bps; + u32 quantum = 256; + u32 i; + +@@ -2433,8 +2438,8 @@ static int cake_config_diffserv8(struct + for (i = 0; i < q->tin_cnt; i++) { + struct cake_tin_data *b = &q->tins[i]; + +- cake_set_rate(b, rate, mtu, us_to_ns(q->target), +- us_to_ns(q->interval)); ++ cake_set_rate(b, rate, mtu, us_to_ns(q->config->target), ++ us_to_ns(q->config->interval)); + + b->tin_quantum = max_t(u16, 1U, quantum); + +@@ -2463,7 +2468,7 @@ static int cake_config_diffserv4(struct + + struct cake_sched_data *q = qdisc_priv(sch); + u32 mtu = psched_mtu(qdisc_dev(sch)); +- u64 rate = q->rate_bps; ++ u64 rate = q->config->rate_bps; + u32 quantum = 1024; + + q->tin_cnt = 4; +@@ -2474,13 +2479,13 @@ static int cake_config_diffserv4(struct + + /* class characteristics */ + cake_set_rate(&q->tins[0], rate, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + cake_set_rate(&q->tins[1], rate >> 4, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + cake_set_rate(&q->tins[2], rate >> 1, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + cake_set_rate(&q->tins[3], rate >> 2, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + + /* bandwidth-sharing weights */ + q->tins[0].tin_quantum = quantum; +@@ -2500,7 +2505,7 @@ static int cake_config_diffserv3(struct + */ + struct cake_sched_data *q = qdisc_priv(sch); + u32 mtu = psched_mtu(qdisc_dev(sch)); +- u64 rate = q->rate_bps; ++ u64 rate = q->config->rate_bps; + u32 quantum = 1024; + + q->tin_cnt = 3; +@@ -2511,11 +2516,11 @@ static int cake_config_diffserv3(struct + + /* class characteristics */ + cake_set_rate(&q->tins[0], rate, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + cake_set_rate(&q->tins[1], rate >> 4, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + cake_set_rate(&q->tins[2], rate >> 2, mtu, +- us_to_ns(q->target), us_to_ns(q->interval)); ++ us_to_ns(q->config->target), us_to_ns(q->config->interval)); + + /* bandwidth-sharing weights */ + q->tins[0].tin_quantum = quantum; +@@ -2527,7 +2532,8 @@ static int cake_config_diffserv3(struct + + static void cake_reconfigure(struct Qdisc *sch) + { +- struct cake_sched_data *q = qdisc_priv(sch); ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ struct cake_sched_config *q = qd->config; + int c, ft; + + switch (q->tin_mode) { +@@ -2553,36 +2559,37 @@ static void cake_reconfigure(struct Qdis + break; + } + +- for (c = q->tin_cnt; c < CAKE_MAX_TINS; c++) { ++ for (c = qd->tin_cnt; c < CAKE_MAX_TINS; c++) { + cake_clear_tin(sch, c); +- q->tins[c].cparams.mtu_time = q->tins[ft].cparams.mtu_time; ++ qd->tins[c].cparams.mtu_time = qd->tins[ft].cparams.mtu_time; + } + +- q->rate_ns = q->tins[ft].tin_rate_ns; +- q->rate_shft = q->tins[ft].tin_rate_shft; ++ qd->rate_ns = qd->tins[ft].tin_rate_ns; ++ qd->rate_shft = qd->tins[ft].tin_rate_shft; + + if (q->buffer_config_limit) { +- q->buffer_limit = q->buffer_config_limit; ++ qd->buffer_limit = q->buffer_config_limit; + } else if (q->rate_bps) { + u64 t = q->rate_bps * q->interval; + + do_div(t, USEC_PER_SEC / 4); +- q->buffer_limit = max_t(u32, t, 4U << 20); ++ qd->buffer_limit = max_t(u32, t, 4U << 20); + } else { +- q->buffer_limit = ~0; ++ qd->buffer_limit = ~0; + } + + sch->flags &= ~TCQ_F_CAN_BYPASS; + +- q->buffer_limit = min(q->buffer_limit, +- max(sch->limit * psched_mtu(qdisc_dev(sch)), +- q->buffer_config_limit)); ++ qd->buffer_limit = min(qd->buffer_limit, ++ max(sch->limit * psched_mtu(qdisc_dev(sch)), ++ q->buffer_config_limit)); + } + + static int cake_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) + { +- struct cake_sched_data *q = qdisc_priv(sch); ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ struct cake_sched_config *q = qd->config; + struct nlattr *tb[TCA_CAKE_MAX + 1]; + u16 rate_flags; + u8 flow_mode; +@@ -2636,19 +2643,19 @@ static int cake_change(struct Qdisc *sch + nla_get_s32(tb[TCA_CAKE_OVERHEAD])); + rate_flags |= CAKE_FLAG_OVERHEAD; + +- q->max_netlen = 0; +- q->max_adjlen = 0; +- q->min_netlen = ~0; +- q->min_adjlen = ~0; ++ qd->max_netlen = 0; ++ qd->max_adjlen = 0; ++ qd->min_netlen = ~0; ++ qd->min_adjlen = ~0; + } + + if (tb[TCA_CAKE_RAW]) { + rate_flags &= ~CAKE_FLAG_OVERHEAD; + +- q->max_netlen = 0; +- q->max_adjlen = 0; +- q->min_netlen = ~0; +- q->min_adjlen = ~0; ++ qd->max_netlen = 0; ++ qd->max_adjlen = 0; ++ qd->min_netlen = ~0; ++ qd->min_adjlen = ~0; + } + + if (tb[TCA_CAKE_MPU]) +@@ -2704,7 +2711,7 @@ static int cake_change(struct Qdisc *sch + + WRITE_ONCE(q->rate_flags, rate_flags); + WRITE_ONCE(q->flow_mode, flow_mode); +- if (q->tins) { ++ if (qd->tins) { + sch_tree_lock(sch); + cake_reconfigure(sch); + sch_tree_unlock(sch); +@@ -2720,14 +2727,20 @@ static void cake_destroy(struct Qdisc *s + qdisc_watchdog_cancel(&q->watchdog); + tcf_block_put(q->block); + kvfree(q->tins); ++ kvfree(q->config); + } + + static int cake_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) + { +- struct cake_sched_data *q = qdisc_priv(sch); ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ struct cake_sched_config *q; + int i, j, err; + ++ q = kzalloc(sizeof(*q), GFP_KERNEL); ++ if (!q) ++ return -ENOMEM; ++ + sch->limit = 10240; + q->tin_mode = CAKE_DIFFSERV_DIFFSERV3; + q->flow_mode = CAKE_FLOW_TRIPLE; +@@ -2739,33 +2752,36 @@ static int cake_init(struct Qdisc *sch, + * for 5 to 10% of interval + */ + q->rate_flags |= CAKE_FLAG_SPLIT_GSO; +- q->cur_tin = 0; +- q->cur_flow = 0; ++ qd->cur_tin = 0; ++ qd->cur_flow = 0; ++ qd->config = q; + +- qdisc_watchdog_init(&q->watchdog, sch); ++ qdisc_watchdog_init(&qd->watchdog, sch); + + if (opt) { + err = cake_change(sch, opt, extack); + + if (err) +- return err; ++ goto err; + } + +- err = tcf_block_get(&q->block, &q->filter_list, sch, extack); ++ err = tcf_block_get(&qd->block, &qd->filter_list, sch, extack); + if (err) +- return err; ++ goto err; + + quantum_div[0] = ~0; + for (i = 1; i <= CAKE_QUEUES; i++) + quantum_div[i] = 65535 / i; + +- q->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data), +- GFP_KERNEL); +- if (!q->tins) +- return -ENOMEM; ++ qd->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data), ++ GFP_KERNEL); ++ if (!qd->tins) { ++ err = -ENOMEM; ++ goto err; ++ } + + for (i = 0; i < CAKE_MAX_TINS; i++) { +- struct cake_tin_data *b = q->tins + i; ++ struct cake_tin_data *b = qd->tins + i; + + INIT_LIST_HEAD(&b->new_flows); + INIT_LIST_HEAD(&b->old_flows); +@@ -2781,22 +2797,27 @@ static int cake_init(struct Qdisc *sch, + INIT_LIST_HEAD(&flow->flowchain); + cobalt_vars_init(&flow->cvars); + +- q->overflow_heap[k].t = i; +- q->overflow_heap[k].b = j; ++ qd->overflow_heap[k].t = i; ++ qd->overflow_heap[k].b = j; + b->overflow_idx[j] = k; + } + } + + cake_reconfigure(sch); +- q->avg_peak_bandwidth = q->rate_bps; +- q->min_netlen = ~0; +- q->min_adjlen = ~0; ++ qd->avg_peak_bandwidth = q->rate_bps; ++ qd->min_netlen = ~0; ++ qd->min_adjlen = ~0; + return 0; ++err: ++ kvfree(qd->config); ++ qd->config = NULL; ++ return err; + } + + static int cake_dump(struct Qdisc *sch, struct sk_buff *skb) + { +- struct cake_sched_data *q = qdisc_priv(sch); ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ struct cake_sched_config *q = qd->config; + struct nlattr *opts; + u16 rate_flags; + u8 flow_mode; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-03-v7.0-net-sched-sch_cake-Add-cake_mq-qdisc-for-using-cake-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-03-v7.0-net-sched-sch_cake-Add-cake_mq-qdisc-for-using-cake-.patch new file mode 100755 index 0000000..645b27f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-03-v7.0-net-sched-sch_cake-Add-cake_mq-qdisc-for-using-cake-.patch @@ -0,0 +1,130 @@ +From c076e98c66afe06e41e118eb96d6b15019b822f2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Fri, 9 Jan 2026 14:15:32 +0100 +Subject: [PATCH 3/7] net/sched: sch_cake: Add cake_mq qdisc for using cake on + mq devices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add a cake_mq qdisc which installs cake instances on each hardware +queue on a multi-queue device. + +This is just a copy of sch_mq that installs cake instead of the default +qdisc on each queue. Subsequent commits will add sharing of the config +between cake instances, as well as a multi-queue aware shaper algorithm. + +Reviewed-by: Willem de Bruijn +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-3-8d613fece5d8@redhat.com +Signed-off-by: Paolo Abeni +--- + net/sched/sch_cake.c | 79 +++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 78 insertions(+), 1 deletion(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -67,6 +67,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -3154,14 +3155,89 @@ static struct Qdisc_ops cake_qdisc_ops _ + }; + MODULE_ALIAS_NET_SCH("cake"); + ++struct cake_mq_sched { ++ struct mq_sched mq_priv; /* must be first */ ++}; ++ ++static void cake_mq_destroy(struct Qdisc *sch) ++{ ++ mq_destroy_common(sch); ++} ++ ++static int cake_mq_init(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++ int ret; ++ ++ ret = mq_init_common(sch, opt, extack, &cake_qdisc_ops); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++static int cake_mq_dump(struct Qdisc *sch, struct sk_buff *skb) ++{ ++ mq_dump_common(sch, skb); ++ return 0; ++} ++ ++static int cake_mq_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static int cake_mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, ++ struct Qdisc **old, struct netlink_ext_ack *extack) ++{ ++ NL_SET_ERR_MSG(extack, "can't replace cake_mq sub-qdiscs"); ++ return -EOPNOTSUPP; ++} ++ ++static const struct Qdisc_class_ops cake_mq_class_ops = { ++ .select_queue = mq_select_queue, ++ .graft = cake_mq_graft, ++ .leaf = mq_leaf, ++ .find = mq_find, ++ .walk = mq_walk, ++ .dump = mq_dump_class, ++ .dump_stats = mq_dump_class_stats, ++}; ++ ++static struct Qdisc_ops cake_mq_qdisc_ops __read_mostly = { ++ .cl_ops = &cake_mq_class_ops, ++ .id = "cake_mq", ++ .priv_size = sizeof(struct cake_mq_sched), ++ .init = cake_mq_init, ++ .destroy = cake_mq_destroy, ++ .attach = mq_attach, ++ .change = cake_mq_change, ++ .change_real_num_tx = mq_change_real_num_tx, ++ .dump = cake_mq_dump, ++ .owner = THIS_MODULE, ++}; ++MODULE_ALIAS_NET_SCH("cake_mq"); ++ + static int __init cake_module_init(void) + { +- return register_qdisc(&cake_qdisc_ops); ++ int ret; ++ ++ ret = register_qdisc(&cake_qdisc_ops); ++ if (ret) ++ return ret; ++ ++ ret = register_qdisc(&cake_mq_qdisc_ops); ++ if (ret) ++ unregister_qdisc(&cake_qdisc_ops); ++ ++ return ret; + } + + static void __exit cake_module_exit(void) + { + unregister_qdisc(&cake_qdisc_ops); ++ unregister_qdisc(&cake_mq_qdisc_ops); + } + + module_init(cake_module_init) +@@ -3169,3 +3245,4 @@ module_exit(cake_module_exit) + MODULE_AUTHOR("Jonathan Morton"); + MODULE_LICENSE("Dual BSD/GPL"); + MODULE_DESCRIPTION("The CAKE shaper."); ++MODULE_IMPORT_NS(NET_SCHED_INTERNAL); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-04-v7.0-net-sched-sch_cake-Share-config-across-cake_mq-sub-q.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-04-v7.0-net-sched-sch_cake-Share-config-across-cake_mq-sub-q.patch new file mode 100755 index 0000000..e481ef9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-04-v7.0-net-sched-sch_cake-Share-config-across-cake_mq-sub-q.patch @@ -0,0 +1,318 @@ +From 68e71714d1e02ca388ea99defbe76061b7dd09a3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Fri, 9 Jan 2026 14:15:33 +0100 +Subject: [PATCH 4/7] net/sched: sch_cake: Share config across cake_mq + sub-qdiscs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This adds support for configuring the cake_mq instance directly, sharing +the config across the cake sub-qdiscs. + +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-4-8d613fece5d8@redhat.com +Signed-off-by: Paolo Abeni +--- + net/sched/sch_cake.c | 173 +++++++++++++++++++++++++++++++++---------- + 1 file changed, 133 insertions(+), 40 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -212,6 +212,7 @@ struct cake_sched_config { + u8 flow_mode; + u8 atm_mode; + u8 ack_filter; ++ u8 is_shared; + }; + + struct cake_sched_data { +@@ -2586,14 +2587,12 @@ static void cake_reconfigure(struct Qdis + q->buffer_config_limit)); + } + +-static int cake_change(struct Qdisc *sch, struct nlattr *opt, +- struct netlink_ext_ack *extack) ++static int cake_config_change(struct cake_sched_config *q, struct nlattr *opt, ++ struct netlink_ext_ack *extack, bool *overhead_changed) + { +- struct cake_sched_data *qd = qdisc_priv(sch); +- struct cake_sched_config *q = qd->config; + struct nlattr *tb[TCA_CAKE_MAX + 1]; +- u16 rate_flags; +- u8 flow_mode; ++ u16 rate_flags = q->rate_flags; ++ u8 flow_mode = q->flow_mode; + int err; + + err = nla_parse_nested_deprecated(tb, TCA_CAKE_MAX, opt, cake_policy, +@@ -2601,7 +2600,6 @@ static int cake_change(struct Qdisc *sch + if (err < 0) + return err; + +- flow_mode = q->flow_mode; + if (tb[TCA_CAKE_NAT]) { + #if IS_ENABLED(CONFIG_NF_CONNTRACK) + flow_mode &= ~CAKE_FLOW_NAT_FLAG; +@@ -2614,6 +2612,19 @@ static int cake_change(struct Qdisc *sch + #endif + } + ++ if (tb[TCA_CAKE_AUTORATE]) { ++ if (!!nla_get_u32(tb[TCA_CAKE_AUTORATE])) { ++ if (q->is_shared) { ++ NL_SET_ERR_MSG_ATTR(extack, tb[TCA_CAKE_AUTORATE], ++ "Can't use autorate-ingress with cake_mq"); ++ return -EOPNOTSUPP; ++ } ++ rate_flags |= CAKE_FLAG_AUTORATE_INGRESS; ++ } else { ++ rate_flags &= ~CAKE_FLAG_AUTORATE_INGRESS; ++ } ++ } ++ + if (tb[TCA_CAKE_BASE_RATE64]) + WRITE_ONCE(q->rate_bps, + nla_get_u64(tb[TCA_CAKE_BASE_RATE64])); +@@ -2622,7 +2633,6 @@ static int cake_change(struct Qdisc *sch + WRITE_ONCE(q->tin_mode, + nla_get_u32(tb[TCA_CAKE_DIFFSERV_MODE])); + +- rate_flags = q->rate_flags; + if (tb[TCA_CAKE_WASH]) { + if (!!nla_get_u32(tb[TCA_CAKE_WASH])) + rate_flags |= CAKE_FLAG_WASH; +@@ -2643,20 +2653,12 @@ static int cake_change(struct Qdisc *sch + WRITE_ONCE(q->rate_overhead, + nla_get_s32(tb[TCA_CAKE_OVERHEAD])); + rate_flags |= CAKE_FLAG_OVERHEAD; +- +- qd->max_netlen = 0; +- qd->max_adjlen = 0; +- qd->min_netlen = ~0; +- qd->min_adjlen = ~0; ++ *overhead_changed = true; + } + + if (tb[TCA_CAKE_RAW]) { + rate_flags &= ~CAKE_FLAG_OVERHEAD; +- +- qd->max_netlen = 0; +- qd->max_adjlen = 0; +- qd->min_netlen = ~0; +- qd->min_adjlen = ~0; ++ *overhead_changed = true; + } + + if (tb[TCA_CAKE_MPU]) +@@ -2675,13 +2677,6 @@ static int cake_change(struct Qdisc *sch + WRITE_ONCE(q->target, max(target, 1U)); + } + +- if (tb[TCA_CAKE_AUTORATE]) { +- if (!!nla_get_u32(tb[TCA_CAKE_AUTORATE])) +- rate_flags |= CAKE_FLAG_AUTORATE_INGRESS; +- else +- rate_flags &= ~CAKE_FLAG_AUTORATE_INGRESS; +- } +- + if (tb[TCA_CAKE_INGRESS]) { + if (!!nla_get_u32(tb[TCA_CAKE_INGRESS])) + rate_flags |= CAKE_FLAG_INGRESS; +@@ -2712,6 +2707,34 @@ static int cake_change(struct Qdisc *sch + + WRITE_ONCE(q->rate_flags, rate_flags); + WRITE_ONCE(q->flow_mode, flow_mode); ++ ++ return 0; ++} ++ ++static int cake_change(struct Qdisc *sch, struct nlattr *opt, ++ struct netlink_ext_ack *extack) ++{ ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ struct cake_sched_config *q = qd->config; ++ bool overhead_changed = false; ++ int ret; ++ ++ if (q->is_shared) { ++ NL_SET_ERR_MSG(extack, "can't reconfigure cake_mq sub-qdiscs"); ++ return -EOPNOTSUPP; ++ } ++ ++ ret = cake_config_change(q, opt, extack, &overhead_changed); ++ if (ret) ++ return ret; ++ ++ if (overhead_changed) { ++ qd->max_netlen = 0; ++ qd->max_adjlen = 0; ++ qd->min_netlen = ~0; ++ qd->min_adjlen = ~0; ++ } ++ + if (qd->tins) { + sch_tree_lock(sch); + cake_reconfigure(sch); +@@ -2728,7 +2751,23 @@ static void cake_destroy(struct Qdisc *s + qdisc_watchdog_cancel(&q->watchdog); + tcf_block_put(q->block); + kvfree(q->tins); +- kvfree(q->config); ++ if (q->config && !q->config->is_shared) ++ kvfree(q->config); ++} ++ ++static void cake_config_init(struct cake_sched_config *q, bool is_shared) ++{ ++ q->tin_mode = CAKE_DIFFSERV_DIFFSERV3; ++ q->flow_mode = CAKE_FLOW_TRIPLE; ++ ++ q->rate_bps = 0; /* unlimited by default */ ++ ++ q->interval = 100000; /* 100ms default */ ++ q->target = 5000; /* 5ms: codel RFC argues ++ * for 5 to 10% of interval ++ */ ++ q->rate_flags |= CAKE_FLAG_SPLIT_GSO; ++ q->is_shared = is_shared; + } + + static int cake_init(struct Qdisc *sch, struct nlattr *opt, +@@ -2742,17 +2781,9 @@ static int cake_init(struct Qdisc *sch, + if (!q) + return -ENOMEM; + +- sch->limit = 10240; +- q->tin_mode = CAKE_DIFFSERV_DIFFSERV3; +- q->flow_mode = CAKE_FLOW_TRIPLE; ++ cake_config_init(q, false); + +- q->rate_bps = 0; /* unlimited by default */ +- +- q->interval = 100000; /* 100ms default */ +- q->target = 5000; /* 5ms: codel RFC argues +- * for 5 to 10% of interval +- */ +- q->rate_flags |= CAKE_FLAG_SPLIT_GSO; ++ sch->limit = 10240; + qd->cur_tin = 0; + qd->cur_flow = 0; + qd->config = q; +@@ -2815,10 +2846,21 @@ err: + return err; + } + +-static int cake_dump(struct Qdisc *sch, struct sk_buff *skb) ++static void cake_config_replace(struct Qdisc *sch, struct cake_sched_config *cfg) + { + struct cake_sched_data *qd = qdisc_priv(sch); + struct cake_sched_config *q = qd->config; ++ ++ qd->config = cfg; ++ ++ if (!q->is_shared) ++ kvfree(q); ++ ++ cake_reconfigure(sch); ++} ++ ++static int cake_config_dump(struct cake_sched_config *q, struct sk_buff *skb) ++{ + struct nlattr *opts; + u16 rate_flags; + u8 flow_mode; +@@ -2894,6 +2936,13 @@ nla_put_failure: + return -1; + } + ++static int cake_dump(struct Qdisc *sch, struct sk_buff *skb) ++{ ++ struct cake_sched_data *qd = qdisc_priv(sch); ++ ++ return cake_config_dump(qd->config, skb); ++} ++ + static int cake_dump_stats(struct Qdisc *sch, struct gnet_dump *d) + { + struct nlattr *stats = nla_nest_start_noflag(d->skb, TCA_STATS_APP); +@@ -3157,6 +3206,7 @@ MODULE_ALIAS_NET_SCH("cake"); + + struct cake_mq_sched { + struct mq_sched mq_priv; /* must be first */ ++ struct cake_sched_config cake_config; + }; + + static void cake_mq_destroy(struct Qdisc *sch) +@@ -3167,25 +3217,68 @@ static void cake_mq_destroy(struct Qdisc + static int cake_mq_init(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) + { +- int ret; ++ struct cake_mq_sched *priv = qdisc_priv(sch); ++ struct net_device *dev = qdisc_dev(sch); ++ int ret, ntx; ++ bool _unused; ++ ++ cake_config_init(&priv->cake_config, true); ++ if (opt) { ++ ret = cake_config_change(&priv->cake_config, opt, extack, &_unused); ++ if (ret) ++ return ret; ++ } + + ret = mq_init_common(sch, opt, extack, &cake_qdisc_ops); + if (ret) + return ret; + ++ for (ntx = 0; ntx < dev->num_tx_queues; ntx++) ++ cake_config_replace(priv->mq_priv.qdiscs[ntx], &priv->cake_config); ++ + return 0; + } + + static int cake_mq_dump(struct Qdisc *sch, struct sk_buff *skb) + { ++ struct cake_mq_sched *priv = qdisc_priv(sch); ++ + mq_dump_common(sch, skb); +- return 0; ++ return cake_config_dump(&priv->cake_config, skb); + } + + static int cake_mq_change(struct Qdisc *sch, struct nlattr *opt, + struct netlink_ext_ack *extack) + { +- return -EOPNOTSUPP; ++ struct cake_mq_sched *priv = qdisc_priv(sch); ++ struct net_device *dev = qdisc_dev(sch); ++ bool overhead_changed = false; ++ unsigned int ntx; ++ int ret; ++ ++ ret = cake_config_change(&priv->cake_config, opt, extack, &overhead_changed); ++ if (ret) ++ return ret; ++ ++ for (ntx = 0; ntx < dev->num_tx_queues; ntx++) { ++ struct Qdisc *chld = rtnl_dereference(netdev_get_tx_queue(dev, ntx)->qdisc_sleeping); ++ struct cake_sched_data *qd = qdisc_priv(chld); ++ ++ if (overhead_changed) { ++ qd->max_netlen = 0; ++ qd->max_adjlen = 0; ++ qd->min_netlen = ~0; ++ qd->min_adjlen = ~0; ++ } ++ ++ if (qd->tins) { ++ sch_tree_lock(chld); ++ cake_reconfigure(chld); ++ sch_tree_unlock(chld); ++ } ++ } ++ ++ return 0; + } + + static int cake_mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-05-v7.0-net-sched-sch_cake-share-shaper-state-across-sub-ins.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-05-v7.0-net-sched-sch_cake-share-shaper-state-across-sub-ins.patch new file mode 100755 index 0000000..62bf38d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-05-v7.0-net-sched-sch_cake-share-shaper-state-across-sub-ins.patch @@ -0,0 +1,175 @@ +From 090dde0780266eb80126fa970870bafdb4e937c3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20K=C3=B6ppeler?= +Date: Fri, 9 Jan 2026 14:15:34 +0100 +Subject: [PATCH 5/7] net/sched: sch_cake: share shaper state across + sub-instances of cake_mq +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This commit adds shared shaper state across the cake instances beneath a +cake_mq qdisc. It works by periodically tracking the number of active +instances, and scaling the configured rate by the number of active +queues. + +The scan is lockless and simply reads the qlen and the last_active state +variable of each of the instances configured beneath the parent cake_mq +instance. Locking is not required since the values are only updated by +the owning instance, and eventual consistency is sufficient for the +purpose of estimating the number of active queues. + +The interval for scanning the number of active queues is set to 200 us. +We found this to be a good tradeoff between overhead and response time. +For a detailed analysis of this aspect see the Netdevconf talk: + +https://netdevconf.info/0x19/docs/netdev-0x19-paper16-talk-paper.pdf + +Reviewed-by: Jamal Hadi Salim +Signed-off-by: Jonas KΓΆppeler +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-5-8d613fece5d8@redhat.com +Signed-off-by: Paolo Abeni +--- + Documentation/netlink/specs/tc.yaml | 3 ++ + include/uapi/linux/pkt_sched.h | 1 + + net/sched/sch_cake.c | 51 +++++++++++++++++++++++++++++ + 3 files changed, 55 insertions(+) + +--- a/Documentation/netlink/specs/tc.yaml ++++ b/Documentation/netlink/specs/tc.yaml +@@ -2161,6 +2161,9 @@ attribute-sets: + - + name: blue-timer-us + type: s32 ++ - ++ name: active-queues ++ type: u32 + - + name: tc-cake-tin-stats-attrs + attributes: +--- a/include/uapi/linux/pkt_sched.h ++++ b/include/uapi/linux/pkt_sched.h +@@ -1034,6 +1034,7 @@ enum { + TCA_CAKE_STATS_DROP_NEXT_US, + TCA_CAKE_STATS_P_DROP, + TCA_CAKE_STATS_BLUE_TIMER_US, ++ TCA_CAKE_STATS_ACTIVE_QUEUES, + __TCA_CAKE_STATS_MAX + }; + #define TCA_CAKE_STATS_MAX (__TCA_CAKE_STATS_MAX - 1) +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -202,6 +202,7 @@ struct cake_sched_config { + u64 rate_bps; + u64 interval; + u64 target; ++ u64 sync_time; + u32 buffer_config_limit; + u32 fwmark_mask; + u16 fwmark_shft; +@@ -258,6 +259,11 @@ struct cake_sched_data { + u16 max_adjlen; + u16 min_netlen; + u16 min_adjlen; ++ ++ /* mq sync state */ ++ u64 last_checked_active; ++ u64 last_active; ++ u32 active_queues; + }; + + enum { +@@ -384,6 +390,8 @@ static const u32 inv_sqrt_cache[REC_INV_ + 1239850263, 1191209601, 1147878294, 1108955788 + }; + ++static void cake_set_rate(struct cake_tin_data *b, u64 rate, u32 mtu, ++ u64 target_ns, u64 rtt_est_ns); + /* http://en.wikipedia.org/wiki/Methods_of_computing_square_roots + * new_invsqrt = (invsqrt / 2) * (3 - count * invsqrt^2) + * +@@ -2003,6 +2011,40 @@ static struct sk_buff *cake_dequeue(stru + u64 delay; + u32 len; + ++ if (q->config->is_shared && now - q->last_checked_active >= q->config->sync_time) { ++ struct net_device *dev = qdisc_dev(sch); ++ struct cake_sched_data *other_priv; ++ u64 new_rate = q->config->rate_bps; ++ u64 other_qlen, other_last_active; ++ struct Qdisc *other_sch; ++ u32 num_active_qs = 1; ++ unsigned int ntx; ++ ++ for (ntx = 0; ntx < dev->num_tx_queues; ntx++) { ++ other_sch = rcu_dereference(netdev_get_tx_queue(dev, ntx)->qdisc_sleeping); ++ other_priv = qdisc_priv(other_sch); ++ ++ if (other_priv == q) ++ continue; ++ ++ other_qlen = READ_ONCE(other_sch->q.qlen); ++ other_last_active = READ_ONCE(other_priv->last_active); ++ ++ if (other_qlen || other_last_active > q->last_checked_active) ++ num_active_qs++; ++ } ++ ++ if (num_active_qs > 1) ++ new_rate = div64_u64(q->config->rate_bps, num_active_qs); ++ ++ /* mtu = 0 is used to only update the rate and not mess with cobalt params */ ++ cake_set_rate(b, new_rate, 0, 0, 0); ++ q->last_checked_active = now; ++ q->active_queues = num_active_qs; ++ q->rate_ns = b->tin_rate_ns; ++ q->rate_shft = b->tin_rate_shft; ++ } ++ + begin: + if (!sch->q.qlen) + return NULL; +@@ -2202,6 +2244,7 @@ retry: + + b->tin_ecn_mark += !!flow->cvars.ecn_marked; + qdisc_bstats_update(sch, skb); ++ WRITE_ONCE(q->last_active, now); + + /* collect delay stats */ + delay = ktime_to_ns(ktime_sub(now, cobalt_get_enqueue_time(skb))); +@@ -2302,6 +2345,9 @@ static void cake_set_rate(struct cake_ti + b->tin_rate_ns = rate_ns; + b->tin_rate_shft = rate_shft; + ++ if (mtu == 0) ++ return; ++ + byte_target_ns = (byte_target * rate_ns) >> rate_shft; + + b->cparams.target = max((byte_target_ns * 3) / 2, target_ns); +@@ -2768,6 +2814,7 @@ static void cake_config_init(struct cake + */ + q->rate_flags |= CAKE_FLAG_SPLIT_GSO; + q->is_shared = is_shared; ++ q->sync_time = 200 * NSEC_PER_USEC; + } + + static int cake_init(struct Qdisc *sch, struct nlattr *opt, +@@ -2839,6 +2886,9 @@ static int cake_init(struct Qdisc *sch, + qd->avg_peak_bandwidth = q->rate_bps; + qd->min_netlen = ~0; + qd->min_adjlen = ~0; ++ qd->active_queues = 0; ++ qd->last_checked_active = 0; ++ + return 0; + err: + kvfree(qd->config); +@@ -2971,6 +3021,7 @@ static int cake_dump_stats(struct Qdisc + PUT_STAT_U32(MAX_ADJLEN, q->max_adjlen); + PUT_STAT_U32(MIN_NETLEN, q->min_netlen); + PUT_STAT_U32(MIN_ADJLEN, q->min_adjlen); ++ PUT_STAT_U32(ACTIVE_QUEUES, q->active_queues); + + #undef PUT_STAT_U32 + #undef PUT_STAT_U64 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-06-v7.0-selftests-tc-testing-add-selftests-for-cake_mq-qdisc.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-06-v7.0-selftests-tc-testing-add-selftests-for-cake_mq-qdisc.patch new file mode 100755 index 0000000..c012a15 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-06-v7.0-selftests-tc-testing-add-selftests-for-cake_mq-qdisc.patch @@ -0,0 +1,606 @@ +From e5e7c7c6a027ce2f001fc60dc388a560c01427fd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20K=C3=B6ppeler?= +Date: Fri, 9 Jan 2026 14:15:35 +0100 +Subject: [PATCH 6/7] selftests/tc-testing: add selftests for cake_mq qdisc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Test 684b: Create CAKE_MQ with default setting (4 queues) +Test 7ee8: Create CAKE_MQ with bandwidth limit (4 queues) +Test 1f87: Create CAKE_MQ with rtt time (4 queues) +Test e9cf: Create CAKE_MQ with besteffort flag (4 queues) +Test 7c05: Create CAKE_MQ with diffserv8 flag (4 queues) +Test 5a77: Create CAKE_MQ with diffserv4 flag (4 queues) +Test 8f7a: Create CAKE_MQ with flowblind flag (4 queues) +Test 7ef7: Create CAKE_MQ with dsthost and nat flag (4 queues) +Test 2e4d: Create CAKE_MQ with wash flag (4 queues) +Test b3e6: Create CAKE_MQ with flowblind and no-split-gso flag (4 queues) +Test 62cd: Create CAKE_MQ with dual-srchost and ack-filter flag (4 queues) +Test 0df3: Create CAKE_MQ with dual-dsthost and ack-filter-aggressive flag (4 queues) +Test 9a75: Create CAKE_MQ with memlimit and ptm flag (4 queues) +Test cdef: Create CAKE_MQ with fwmark and atm flag (4 queues) +Test 93dd: Create CAKE_MQ with overhead 0 and mpu (4 queues) +Test 1475: Create CAKE_MQ with conservative and ingress flag (4 queues) +Test 7bf1: Delete CAKE_MQ with conservative and ingress flag (4 queues) +Test ee55: Replace CAKE_MQ with mpu (4 queues) +Test 6df9: Change CAKE_MQ with mpu (4 queues) +Test 67e2: Show CAKE_MQ class (4 queues) +Test 2de4: Change bandwidth of CAKE_MQ (4 queues) +Test 5f62: Fail to create CAKE_MQ with autorate-ingress flag (4 queues) +Test 038e: Fail to change setting of sub-qdisc under CAKE_MQ +Test 7bdc: Fail to replace sub-qdisc under CAKE_MQ +Test 18e0: Fail to install CAKE_MQ on single queue device + +Reviewed-by: Victor Nogueira +Signed-off-by: Jonas KΓΆppeler +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Link: https://patch.msgid.link/20260109-mq-cake-sub-qdisc-v8-6-8d613fece5d8@redhat.com +Signed-off-by: Paolo Abeni +--- + .../tc-testing/tc-tests/qdiscs/cake_mq.json | 559 ++++++++++++++++++ + 1 file changed, 559 insertions(+) + create mode 100644 tools/testing/selftests/tc-testing/tc-tests/qdiscs/cake_mq.json + +--- /dev/null ++++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/cake_mq.json +@@ -0,0 +1,559 @@ ++[ ++ { ++ "id": "684b", ++ "name": "Create CAKE_MQ with default setting (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device || true", ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "7ee8", ++ "name": "Create CAKE_MQ with bandwidth limit (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq bandwidth 1000", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth 1Kbit diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "1f87", ++ "name": "Create CAKE_MQ with rtt time (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq rtt 200", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 200us raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "e9cf", ++ "name": "Create CAKE_MQ with besteffort flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq besteffort", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited besteffort triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "7c05", ++ "name": "Create CAKE_MQ with diffserv8 flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq diffserv8", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv8 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "5a77", ++ "name": "Create CAKE_MQ with diffserv4 flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq diffserv4", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv4 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "8f7a", ++ "name": "Create CAKE_MQ with flowblind flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq flowblind", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 flowblind nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "7ef7", ++ "name": "Create CAKE_MQ with dsthost and nat flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq dsthost nat", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 dsthost nat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "2e4d", ++ "name": "Create CAKE_MQ with wash flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq hosts wash", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 hosts nonat wash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "b3e6", ++ "name": "Create CAKE_MQ with flowblind and no-split-gso flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq flowblind no-split-gso", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 flowblind nonat nowash no-ack-filter no-split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "62cd", ++ "name": "Create CAKE_MQ with dual-srchost and ack-filter flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq dual-srchost ack-filter", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 dual-srchost nonat nowash ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "0df3", ++ "name": "Create CAKE_MQ with dual-dsthost and ack-filter-aggressive flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq dual-dsthost ack-filter-aggressive", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 dual-dsthost nonat nowash ack-filter-aggressive split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "9a75", ++ "name": "Create CAKE_MQ with memlimit and ptm flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq memlimit 10000 ptm", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw ptm overhead 0 memlimit 10000b ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "cdef", ++ "name": "Create CAKE_MQ with fwmark and atm flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq fwmark 8 atm", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw atm overhead 0 fwmark 0x8 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "93dd", ++ "name": "Create CAKE_MQ with overhead 0 and mpu (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq overhead 128 mpu 256", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms noatm overhead 128 mpu 256 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "1475", ++ "name": "Create CAKE_MQ with conservative and ingress flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq conservative ingress", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash ingress no-ack-filter split-gso rtt 100ms atm overhead 48 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "7bf1", ++ "name": "Delete CAKE_MQ with conservative and ingress flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", ++ "$TC qdisc add dev $ETH handle 1: root cake_mq conservative ingress" ++ ], ++ "cmdUnderTest": "$TC qdisc del dev $ETH handle 1: root", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash ingress no-ack-filter split-gso rtt 100ms atm overhead 48 ", ++ "matchCount": "0", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "ee55", ++ "name": "Replace CAKE_MQ with mpu (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", ++ "$TC qdisc add dev $ETH handle 1: root cake_mq overhead 128 mpu 256" ++ ], ++ "cmdUnderTest": "$TC qdisc replace dev $ETH handle 1: root cake_mq mpu 128", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms noatm overhead 128 mpu 128 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "6df9", ++ "name": "Change CAKE_MQ with mpu (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", ++ "$TC qdisc add dev $ETH handle 1: root cake_mq overhead 128 mpu 256" ++ ], ++ "cmdUnderTest": "$TC qdisc change dev $ETH handle 1: root cake_mq mpu 128", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms noatm overhead 128 mpu 128 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "67e2", ++ "name": "Show CAKE_MQ class (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq", ++ "expExitCode": "0", ++ "verifyCmd": "$TC class show dev $ETH", ++ "matchPattern": "class cake_mq", ++ "matchCount": "4", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "2de4", ++ "name": "Change bandwidth of CAKE_MQ (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", ++ "$TC qdisc add dev $ETH handle 1: root cake_mq" ++ ], ++ "cmdUnderTest": "$TC qdisc replace dev $ETH handle 1: root cake_mq bandwidth 1000", ++ "expExitCode": "0", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth 1Kbit diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "5f62", ++ "name": "Fail to create CAKE_MQ with autorate-ingress flag (4 queues)", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq autorate-ingress", ++ "expExitCode": "2", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited autorate-ingress diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "0", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "038e", ++ "name": "Fail to change setting of sub-qdisc under CAKE_MQ", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", ++ "$TC qdisc add dev $ETH handle 1: root cake_mq" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH parent 1:1 cake besteffort flows", ++ "expExitCode": "2", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "7bdc", ++ "name": "Fail to replace sub-qdisc under CAKE_MQ", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", ++ "$TC qdisc add dev $ETH handle 1: root cake_mq" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH parent 1:1 fq", ++ "expExitCode": "2", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "5", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ }, ++ { ++ "id": "18e0", ++ "name": "Fail to install CAKE_MQ on single queue device", ++ "category": [ ++ "qdisc", ++ "cake_mq" ++ ], ++ "plugins": { ++ "requires": "nsPlugin" ++ }, ++ "setup": [ ++ "echo \"1 1 1\" > /sys/bus/netdevsim/new_device" ++ ], ++ "cmdUnderTest": "$TC qdisc add dev $ETH handle 1: root cake_mq", ++ "expExitCode": "2", ++ "verifyCmd": "$TC qdisc show dev $ETH", ++ "matchPattern": "qdisc (cake_mq 1: root|cake 0: parent 1:[1-4]) bandwidth unlimited diffserv3 triple-isolate nonat nowash no-ack-filter split-gso rtt 100ms raw overhead 0 ", ++ "matchCount": "0", ++ "teardown": [ ++ "echo \"1\" > /sys/bus/netdevsim/del_device" ++ ] ++ } ++] diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-07-v7.0-net-sched-cake-avoid-separate-allocation-of-struct-c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-07-v7.0-net-sched-cake-avoid-separate-allocation-of-struct-c.patch new file mode 100755 index 0000000..1ba4cd3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/700-07-v7.0-net-sched-cake-avoid-separate-allocation-of-struct-c.patch @@ -0,0 +1,112 @@ +From 060969bc048d2f85149b7f1a8bbb56e6b1434cae Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Tue, 13 Jan 2026 15:31:56 +0100 +Subject: [PATCH 7/7] net/sched: cake: avoid separate allocation of struct + cake_sched_config +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Paolo pointed out that we can avoid separately allocating struct +cake_sched_config even in the non-mq case, by embedding it into struct +cake_sched_data. This reduces the complexity of the logic that swaps the +pointers and frees the old value, at the cost of adding 56 bytes to the +latter. Since cake_sched_data is already almost 17k bytes, this seems +like a reasonable tradeoff. + +Suggested-by: Paolo Abeni +Signed-off-by: Toke HΓΈiland-JΓΈrgensen +Fixes: bc0ce2bad36c ("net/sched: sch_cake: Factor out config variables into separate struct") +Link: https://patch.msgid.link/20260113143157.2581680-1-toke@redhat.com +Signed-off-by: Jakub Kicinski +--- + net/sched/sch_cake.c | 29 ++++++----------------------- + 1 file changed, 6 insertions(+), 23 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -221,6 +221,7 @@ struct cake_sched_data { + struct tcf_block *block; + struct cake_tin_data *tins; + struct cake_sched_config *config; ++ struct cake_sched_config initial_config; + + struct cake_heap_entry overflow_heap[CAKE_QUEUES * CAKE_MAX_TINS]; + +@@ -2797,8 +2798,6 @@ static void cake_destroy(struct Qdisc *s + qdisc_watchdog_cancel(&q->watchdog); + tcf_block_put(q->block); + kvfree(q->tins); +- if (q->config && !q->config->is_shared) +- kvfree(q->config); + } + + static void cake_config_init(struct cake_sched_config *q, bool is_shared) +@@ -2821,13 +2820,9 @@ static int cake_init(struct Qdisc *sch, + struct netlink_ext_ack *extack) + { + struct cake_sched_data *qd = qdisc_priv(sch); +- struct cake_sched_config *q; ++ struct cake_sched_config *q = &qd->initial_config; + int i, j, err; + +- q = kzalloc(sizeof(*q), GFP_KERNEL); +- if (!q) +- return -ENOMEM; +- + cake_config_init(q, false); + + sch->limit = 10240; +@@ -2839,14 +2834,13 @@ static int cake_init(struct Qdisc *sch, + + if (opt) { + err = cake_change(sch, opt, extack); +- + if (err) +- goto err; ++ return err; + } + + err = tcf_block_get(&qd->block, &qd->filter_list, sch, extack); + if (err) +- goto err; ++ return err; + + quantum_div[0] = ~0; + for (i = 1; i <= CAKE_QUEUES; i++) +@@ -2854,10 +2848,8 @@ static int cake_init(struct Qdisc *sch, + + qd->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data), + GFP_KERNEL); +- if (!qd->tins) { +- err = -ENOMEM; +- goto err; +- } ++ if (!qd->tins) ++ return -ENOMEM; + + for (i = 0; i < CAKE_MAX_TINS; i++) { + struct cake_tin_data *b = qd->tins + i; +@@ -2890,22 +2882,13 @@ static int cake_init(struct Qdisc *sch, + qd->last_checked_active = 0; + + return 0; +-err: +- kvfree(qd->config); +- qd->config = NULL; +- return err; + } + + static void cake_config_replace(struct Qdisc *sch, struct cake_sched_config *cfg) + { + struct cake_sched_data *qd = qdisc_priv(sch); +- struct cake_sched_config *q = qd->config; + + qd->config = cfg; +- +- if (!q->is_shared) +- kvfree(q); +- + cake_reconfigure(sch); + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/710-v6.16-igc-enable-HW-vlan-tag-insertion-stripping-by-defaul.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/710-v6.16-igc-enable-HW-vlan-tag-insertion-stripping-by-defaul.patch new file mode 100755 index 0000000..48d03f1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/710-v6.16-igc-enable-HW-vlan-tag-insertion-stripping-by-defaul.patch @@ -0,0 +1,32 @@ +From 8cae5a0d91fea01d90ce7c1827e26934a22ca2fa Mon Sep 17 00:00:00 2001 +From: Rui Salvaterra +Date: Wed, 5 Mar 2025 11:53:56 +0000 +Subject: [PATCH] igc: enable HW vlan tag insertion/stripping by default + +This is enabled by default in other Intel drivers I've checked (e1000, e1000e, +iavf, igb and ice). Fixes an out-of-the-box performance issue when running +OpenWrt on typical mini-PCs with igc-supported Ethernet controllers and 802.1Q +VLAN configurations, as ethtool isn't part of the default packages and sane +defaults are expected. + +In my specific case, with an Intel N100-based machine with four I226-V Ethernet +controllers, my upload performance increased from under 30 Mb/s to the expected +~1 Gb/s. + +Signed-off-by: Rui Salvaterra +--- + drivers/net/ethernet/intel/igc/igc_main.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/ethernet/intel/igc/igc_main.c ++++ b/drivers/net/ethernet/intel/igc/igc_main.c +@@ -7070,6 +7070,9 @@ static int igc_probe(struct pci_dev *pde + netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | + NETDEV_XDP_ACT_XSK_ZEROCOPY; + ++ /* enable HW vlan tag insertion/stripping by default */ ++ netdev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; ++ + /* MTU range: 68 - 9216 */ + netdev->min_mtu = ETH_MIN_MTU; + netdev->max_mtu = MAX_STD_JUMBO_FRAME_SIZE; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-01-v6.13-net-phy-mediatek-ge-soc-Fix-coding-style.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-01-v6.13-net-phy-mediatek-ge-soc-Fix-coding-style.patch new file mode 100755 index 0000000..25bd96f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-01-v6.13-net-phy-mediatek-ge-soc-Fix-coding-style.patch @@ -0,0 +1,88 @@ +From 277f96c1f3f71d6e1d3bcf650d7cd84c1442210f Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Thu, 17 Oct 2024 11:22:11 +0800 +Subject: [PATCH 01/20] net: phy: mediatek-ge-soc: Fix coding style + +This patch fixes spelling errors, re-arrange vars with +reverse Xmas tree and remove unnecessary parens in +mediatek-ge-soc.c. + +Signed-off-by: SkyLake.Huang +Reviewed-by: Simon Horman +Signed-off-by: Andrew Lunn +--- + drivers/net/phy/mediatek-ge-soc.c | 36 ++++++++++++++++--------------- + 1 file changed, 19 insertions(+), 17 deletions(-) + +--- a/drivers/net/phy/mediatek-ge-soc.c ++++ b/drivers/net/phy/mediatek-ge-soc.c +@@ -408,16 +408,17 @@ static int tx_offset_cal_efuse(struct ph + + static int tx_amp_fill_result(struct phy_device *phydev, u16 *buf) + { +- int i; +- int bias[16] = {}; +- const int vals_9461[16] = { 7, 1, 4, 7, +- 7, 1, 4, 7, +- 7, 1, 4, 7, +- 7, 1, 4, 7 }; + const int vals_9481[16] = { 10, 6, 6, 10, + 10, 6, 6, 10, + 10, 6, 6, 10, + 10, 6, 6, 10 }; ++ const int vals_9461[16] = { 7, 1, 4, 7, ++ 7, 1, 4, 7, ++ 7, 1, 4, 7, ++ 7, 1, 4, 7 }; ++ int bias[16] = {}; ++ int i; ++ + switch (phydev->drv->phy_id) { + case MTK_GPHY_ID_MT7981: + /* We add some calibration to efuse values +@@ -1069,10 +1070,10 @@ static int start_cal(struct phy_device * + + static int mt798x_phy_calibration(struct phy_device *phydev) + { ++ struct nvmem_cell *cell; + int ret = 0; +- u32 *buf; + size_t len; +- struct nvmem_cell *cell; ++ u32 *buf; + + cell = nvmem_cell_get(&phydev->mdio.dev, "phy-cal-data"); + if (IS_ERR(cell)) { +@@ -1210,14 +1211,15 @@ static int mt798x_phy_led_brightness_set + return mt798x_phy_hw_led_on_set(phydev, index, (value != LED_OFF)); + } + +-static const unsigned long supported_triggers = (BIT(TRIGGER_NETDEV_FULL_DUPLEX) | +- BIT(TRIGGER_NETDEV_HALF_DUPLEX) | +- BIT(TRIGGER_NETDEV_LINK) | +- BIT(TRIGGER_NETDEV_LINK_10) | +- BIT(TRIGGER_NETDEV_LINK_100) | +- BIT(TRIGGER_NETDEV_LINK_1000) | +- BIT(TRIGGER_NETDEV_RX) | +- BIT(TRIGGER_NETDEV_TX)); ++static const unsigned long supported_triggers = ++ BIT(TRIGGER_NETDEV_FULL_DUPLEX) | ++ BIT(TRIGGER_NETDEV_HALF_DUPLEX) | ++ BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX); + + static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) +@@ -1415,7 +1417,7 @@ static int mt7988_phy_probe_shared(struc + * LED_C and LED_D respectively. At the same time those pins are used to + * bootstrap configuration of the reference clock source (LED_A), + * DRAM DDRx16b x2/x1 (LED_B) and boot device (LED_C, LED_D). +- * In practise this is done using a LED and a resistor pulling the pin ++ * In practice this is done using a LED and a resistor pulling the pin + * either to GND or to VIO. + * The detected value at boot time is accessible at run-time using the + * TPBANK0 register located in the gpio base of the pinctrl, in order diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-02-v6.13-net-phy-mediatek-ge-soc-Shrink-line-wrapping-to-80-c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-02-v6.13-net-phy-mediatek-ge-soc-Shrink-line-wrapping-to-80-c.patch new file mode 100755 index 0000000..fbf3a99 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-02-v6.13-net-phy-mediatek-ge-soc-Shrink-line-wrapping-to-80-c.patch @@ -0,0 +1,271 @@ +From c0dc1b412f9d840c51c5ee8927bf066e15a59550 Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Thu, 17 Oct 2024 11:22:12 +0800 +Subject: [PATCH 02/20] net: phy: mediatek-ge-soc: Shrink line wrapping to 80 + characters + +This patch shrinks line wrapping to 80 chars. Also, in +tx_amp_fill_result(), use FIELD_PREP() to prettify code. + +Signed-off-by: SkyLake.Huang +Reviewed-by: Simon Horman +Signed-off-by: Andrew Lunn +--- + drivers/net/phy/mediatek-ge-soc.c | 125 +++++++++++++++++++++--------- + 1 file changed, 88 insertions(+), 37 deletions(-) + +--- a/drivers/net/phy/mediatek-ge-soc.c ++++ b/drivers/net/phy/mediatek-ge-soc.c +@@ -342,7 +342,8 @@ static int cal_cycle(struct phy_device * + ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, + MTK_PHY_RG_AD_CAL_CLK, reg_val, + reg_val & MTK_PHY_DA_CAL_CLK, 500, +- ANALOG_INTERNAL_OPERATION_MAX_US, false); ++ ANALOG_INTERNAL_OPERATION_MAX_US, ++ false); + if (ret) { + phydev_err(phydev, "Calibration cycle timeout\n"); + return ret; +@@ -441,40 +442,72 @@ static int tx_amp_fill_result(struct phy + } + + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, +- MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, (buf[0] + bias[0]) << 10); ++ MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, ++ buf[0] + bias[0])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, +- MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, buf[0] + bias[1]); ++ MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, ++ buf[0] + bias[1])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, +- MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, (buf[0] + bias[2]) << 10); ++ MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, ++ buf[0] + bias[2])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, +- MTK_PHY_DA_TX_I2MPB_A_TST_MASK, buf[0] + bias[3]); ++ MTK_PHY_DA_TX_I2MPB_A_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_TST_MASK, ++ buf[0] + bias[3])); + + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, +- MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, (buf[1] + bias[4]) << 8); ++ MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, ++ buf[1] + bias[4])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, +- MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, buf[1] + bias[5]); ++ MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, ++ buf[1] + bias[5])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, +- MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, (buf[1] + bias[6]) << 8); ++ MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, ++ buf[1] + bias[6])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, +- MTK_PHY_DA_TX_I2MPB_B_TST_MASK, buf[1] + bias[7]); ++ MTK_PHY_DA_TX_I2MPB_B_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_TST_MASK, ++ buf[1] + bias[7])); + + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, +- MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, (buf[2] + bias[8]) << 8); ++ MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, ++ buf[2] + bias[8])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, +- MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, buf[2] + bias[9]); ++ MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, ++ buf[2] + bias[9])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, +- MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, (buf[2] + bias[10]) << 8); ++ MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, ++ buf[2] + bias[10])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, +- MTK_PHY_DA_TX_I2MPB_C_TST_MASK, buf[2] + bias[11]); ++ MTK_PHY_DA_TX_I2MPB_C_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_TST_MASK, ++ buf[2] + bias[11])); + + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, +- MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, (buf[3] + bias[12]) << 8); ++ MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, ++ buf[3] + bias[12])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, +- MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, buf[3] + bias[13]); ++ MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, ++ buf[3] + bias[13])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, +- MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, (buf[3] + bias[14]) << 8); ++ MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, ++ buf[3] + bias[14])); + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, +- MTK_PHY_DA_TX_I2MPB_D_TST_MASK, buf[3] + bias[15]); ++ MTK_PHY_DA_TX_I2MPB_D_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_TST_MASK, ++ buf[3] + bias[15])); + + return 0; + } +@@ -663,7 +696,8 @@ static int tx_vcm_cal_sw(struct phy_devi + goto restore; + + /* We calibrate TX-VCM in different logic. Check upper index and then +- * lower index. If this calibration is valid, apply lower index's result. ++ * lower index. If this calibration is valid, apply lower index's ++ * result. + */ + ret = upper_ret - lower_ret; + if (ret == 1) { +@@ -692,7 +726,8 @@ static int tx_vcm_cal_sw(struct phy_devi + } else if (upper_idx == TXRESERVE_MAX && upper_ret == 0 && + lower_ret == 0) { + ret = 0; +- phydev_warn(phydev, "TX-VCM SW cal result at high margin 0x%x\n", ++ phydev_warn(phydev, ++ "TX-VCM SW cal result at high margin 0x%x\n", + upper_idx); + } else { + ret = -EINVAL; +@@ -796,7 +831,8 @@ static void mt7981_phy_finetune(struct p + + /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 9 */ + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, +- MTK_PHY_TR_OPEN_LOOP_EN_MASK | MTK_PHY_LPF_X_AVERAGE_MASK, ++ MTK_PHY_TR_OPEN_LOOP_EN_MASK | ++ MTK_PHY_LPF_X_AVERAGE_MASK, + BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0x9)); + + /* rg_tr_lpf_cnt_val = 512 */ +@@ -865,7 +901,8 @@ static void mt7988_phy_finetune(struct p + + /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 10 */ + phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, +- MTK_PHY_TR_OPEN_LOOP_EN_MASK | MTK_PHY_LPF_X_AVERAGE_MASK, ++ MTK_PHY_TR_OPEN_LOOP_EN_MASK | ++ MTK_PHY_LPF_X_AVERAGE_MASK, + BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0xa)); + + /* rg_tr_lpf_cnt_val = 1023 */ +@@ -977,7 +1014,8 @@ static void mt798x_phy_eee(struct phy_de + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); + + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3); +- __phy_modify(phydev, MTK_PHY_LPI_REG_14, MTK_PHY_LPI_WAKE_TIMER_1000_MASK, ++ __phy_modify(phydev, MTK_PHY_LPI_REG_14, ++ MTK_PHY_LPI_WAKE_TIMER_1000_MASK, + FIELD_PREP(MTK_PHY_LPI_WAKE_TIMER_1000_MASK, 0x19c)); + + __phy_modify(phydev, MTK_PHY_LPI_REG_1c, MTK_PHY_SMI_DET_ON_THRESH_MASK, +@@ -987,7 +1025,8 @@ static void mt798x_phy_eee(struct phy_de + phy_modify_mmd(phydev, MDIO_MMD_VEND1, + MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122, + MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, +- FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, 0xff)); ++ FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, ++ 0xff)); + } + + static int cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item, +@@ -1147,7 +1186,8 @@ static int mt798x_phy_hw_led_on_set(stru + (index ? 16 : 0), &priv->led_state); + if (changed) + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL, ++ MTK_PHY_LED1_ON_CTRL : ++ MTK_PHY_LED0_ON_CTRL, + MTK_PHY_LED_ON_MASK, + on ? MTK_PHY_LED_ON_FORCE_ON : 0); + else +@@ -1157,7 +1197,8 @@ static int mt798x_phy_hw_led_on_set(stru + static int mt798x_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, + bool blinking) + { +- unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + (index ? 16 : 0); ++ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + ++ (index ? 16 : 0); + struct mtk_socphy_priv *priv = phydev->priv; + bool changed; + +@@ -1170,8 +1211,10 @@ static int mt798x_phy_hw_led_blink_set(s + (index ? 16 : 0), &priv->led_state); + if (changed) + return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_BLINK_CTRL : MTK_PHY_LED0_BLINK_CTRL, +- blinking ? MTK_PHY_LED_BLINK_FORCE_BLINK : 0); ++ MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL, ++ blinking ? ++ MTK_PHY_LED_BLINK_FORCE_BLINK : 0); + else + return 0; + } +@@ -1237,7 +1280,8 @@ static int mt798x_phy_led_hw_is_supporte + static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index, + unsigned long *rules) + { +- unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + (index ? 16 : 0); ++ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + ++ (index ? 16 : 0); + unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); + unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); + struct mtk_socphy_priv *priv = phydev->priv; +@@ -1258,8 +1302,8 @@ static int mt798x_phy_led_hw_control_get + if (blink < 0) + return -EIO; + +- if ((on & (MTK_PHY_LED_ON_LINK | MTK_PHY_LED_ON_FDX | MTK_PHY_LED_ON_HDX | +- MTK_PHY_LED_ON_LINKDOWN)) || ++ if ((on & (MTK_PHY_LED_ON_LINK | MTK_PHY_LED_ON_FDX | ++ MTK_PHY_LED_ON_HDX | MTK_PHY_LED_ON_LINKDOWN)) || + (blink & (MTK_PHY_LED_BLINK_RX | MTK_PHY_LED_BLINK_TX))) + set_bit(bit_netdev, &priv->led_state); + else +@@ -1333,17 +1377,23 @@ static int mt798x_phy_led_hw_control_set + + if (rules & BIT(TRIGGER_NETDEV_RX)) { + blink |= (on & MTK_PHY_LED_ON_LINK) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? MTK_PHY_LED_BLINK_10RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? MTK_PHY_LED_BLINK_100RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? MTK_PHY_LED_BLINK_1000RX : 0)) : ++ (((on & MTK_PHY_LED_ON_LINK10) ? ++ MTK_PHY_LED_BLINK_10RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK100) ? ++ MTK_PHY_LED_BLINK_100RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK1000) ? ++ MTK_PHY_LED_BLINK_1000RX : 0)) : + MTK_PHY_LED_BLINK_RX; + } + + if (rules & BIT(TRIGGER_NETDEV_TX)) { + blink |= (on & MTK_PHY_LED_ON_LINK) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? MTK_PHY_LED_BLINK_10TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? MTK_PHY_LED_BLINK_100TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? MTK_PHY_LED_BLINK_1000TX : 0)) : ++ (((on & MTK_PHY_LED_ON_LINK10) ? ++ MTK_PHY_LED_BLINK_10TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK100) ? ++ MTK_PHY_LED_BLINK_100TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK1000) ? ++ MTK_PHY_LED_BLINK_1000TX : 0)) : + MTK_PHY_LED_BLINK_TX; + } + +@@ -1400,7 +1450,8 @@ static int mt7988_phy_fix_leds_polaritie + /* Only now setup pinctrl to avoid bogus blinking */ + pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led"); + if (IS_ERR(pinctrl)) +- dev_err(&phydev->mdio.bus->dev, "Failed to setup PHY LED pinctrl\n"); ++ dev_err(&phydev->mdio.bus->dev, ++ "Failed to setup PHY LED pinctrl\n"); + + return 0; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-03-v6.13-net-phy-mediatek-ge-soc-Propagate-error-code-correct.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-03-v6.13-net-phy-mediatek-ge-soc-Propagate-error-code-correct.patch new file mode 100755 index 0000000..1f6f5f5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-03-v6.13-net-phy-mediatek-ge-soc-Propagate-error-code-correct.patch @@ -0,0 +1,40 @@ +From bcbbfb4f62c4ba35783cc617997a2e92d91e3940 Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Thu, 17 Oct 2024 11:22:13 +0800 +Subject: [PATCH 03/20] net: phy: mediatek-ge-soc: Propagate error code + correctly in cal_cycle() + +This patch propagates error code correctly in cal_cycle() +and improve with FIELD_GET(). + +Signed-off-by: SkyLake.Huang +Reviewed-by: Simon Horman +Signed-off-by: Andrew Lunn +--- + drivers/net/phy/mediatek-ge-soc.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/mediatek-ge-soc.c ++++ b/drivers/net/phy/mediatek-ge-soc.c +@@ -110,7 +110,7 @@ + #define MTK_PHY_CR_TX_AMP_OFFSET_D_MASK GENMASK(6, 0) + + #define MTK_PHY_RG_AD_CAL_COMP 0x17a +-#define MTK_PHY_AD_CAL_COMP_OUT_SHIFT (8) ++#define MTK_PHY_AD_CAL_COMP_OUT_MASK GENMASK(8, 8) + + #define MTK_PHY_RG_AD_CAL_CLK 0x17b + #define MTK_PHY_DA_CAL_CLK BIT(0) +@@ -351,8 +351,10 @@ static int cal_cycle(struct phy_device * + + phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, + MTK_PHY_DA_CALIN_FLAG); +- ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP) >> +- MTK_PHY_AD_CAL_COMP_OUT_SHIFT; ++ ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP); ++ if (ret < 0) ++ return ret; ++ ret = FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret); + phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret); + + return ret; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-04-v6.13-net-phy-mediatek-Re-organize-MediaTek-ethernet-phy-d.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-04-v6.13-net-phy-mediatek-Re-organize-MediaTek-ethernet-phy-d.patch new file mode 100755 index 0000000..81e2510 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-04-v6.13-net-phy-mediatek-Re-organize-MediaTek-ethernet-phy-d.patch @@ -0,0 +1,3565 @@ +From e062f073dc0df4fcd338043cb0b69b6bcd31e4af Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Sat, 9 Nov 2024 00:34:51 +0800 +Subject: [PATCH 04/20] net: phy: mediatek: Re-organize MediaTek ethernet phy + drivers + +Re-organize MediaTek ethernet phy driver files and get ready to integrate +some common functions and add new 2.5G phy driver. +mtk-ge.c: MT7530 Gphy on MT7621 & MT7531 Gphy +mtk-ge-soc.c: Built-in Gphy on MT7981 & Built-in switch Gphy on MT7988 +mtk-2p5ge.c: Planned for built-in 2.5G phy on MT7988 + +Reviewed-by: Andrew Lunn +Signed-off-by: SkyLake.Huang +Signed-off-by: David S. Miller +--- + MAINTAINERS | 4 ++-- + drivers/net/phy/Kconfig | 17 +------------- + drivers/net/phy/Makefile | 3 +-- + drivers/net/phy/mediatek/Kconfig | 22 +++++++++++++++++++ + drivers/net/phy/mediatek/Makefile | 3 +++ + .../mtk-ge-soc.c} | 0 + .../phy/{mediatek-ge.c => mediatek/mtk-ge.c} | 0 + 7 files changed, 29 insertions(+), 20 deletions(-) + create mode 100644 drivers/net/phy/mediatek/Kconfig + create mode 100644 drivers/net/phy/mediatek/Makefile + rename drivers/net/phy/{mediatek-ge-soc.c => mediatek/mtk-ge-soc.c} (100%) + rename drivers/net/phy/{mediatek-ge.c => mediatek/mtk-ge.c} (100%) + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -14427,8 +14427,8 @@ M: Qingfang Deng + M: SkyLake Huang + L: netdev@vger.kernel.org + S: Maintained +-F: drivers/net/phy/mediatek-ge-soc.c +-F: drivers/net/phy/mediatek-ge.c ++F: drivers/net/phy/mediatek/mtk-ge-soc.c ++F: drivers/net/phy/mediatek/mtk-ge.c + F: drivers/phy/mediatek/phy-mtk-xfi-tphy.c + + MEDIATEK I2C CONTROLLER DRIVER +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -266,22 +266,7 @@ config MAXLINEAR_GPHY + Support for the Maxlinear GPY115, GPY211, GPY212, GPY215, + GPY241, GPY245 PHYs. + +-config MEDIATEK_GE_PHY +- tristate "MediaTek Gigabit Ethernet PHYs" +- help +- Supports the MediaTek Gigabit Ethernet PHYs. +- +-config MEDIATEK_GE_SOC_PHY +- tristate "MediaTek SoC Ethernet PHYs" +- depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST +- depends on NVMEM_MTK_EFUSE +- help +- Supports MediaTek SoC built-in Gigabit Ethernet PHYs. +- +- Include support for built-in Ethernet PHYs which are present in +- the MT7981 and MT7988 SoCs. These PHYs need calibration data +- present in the SoCs efuse and will dynamically calibrate VCM +- (common-mode voltage) during startup. ++source "drivers/net/phy/mediatek/Kconfig" + + config MICREL_PHY + tristate "Micrel PHYs" +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -74,8 +74,7 @@ obj-$(CONFIG_MARVELL_PHY) += marvell.o + obj-$(CONFIG_MARVELL_88Q2XXX_PHY) += marvell-88q2xxx.o + obj-$(CONFIG_MARVELL_88X2222_PHY) += marvell-88x2222.o + obj-$(CONFIG_MAXLINEAR_GPHY) += mxl-gpy.o +-obj-$(CONFIG_MEDIATEK_GE_PHY) += mediatek-ge.o +-obj-$(CONFIG_MEDIATEK_GE_SOC_PHY) += mediatek-ge-soc.o ++obj-y += mediatek/ + obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o + obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o + obj-$(CONFIG_MICREL_PHY) += micrel.o +--- /dev/null ++++ b/drivers/net/phy/mediatek/Kconfig +@@ -0,0 +1,22 @@ ++# SPDX-License-Identifier: GPL-2.0-only ++config MEDIATEK_GE_PHY ++ tristate "MediaTek Gigabit Ethernet PHYs" ++ help ++ Supports the MediaTek non-built-in Gigabit Ethernet PHYs. ++ ++ Non-built-in Gigabit Ethernet PHYs include mt7530/mt7531. ++ You may find mt7530 inside mt7621. This driver shares some ++ common operations with MediaTek SoC built-in Gigabit ++ Ethernet PHYs. ++ ++config MEDIATEK_GE_SOC_PHY ++ tristate "MediaTek SoC Ethernet PHYs" ++ depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST ++ depends on NVMEM_MTK_EFUSE ++ help ++ Supports MediaTek SoC built-in Gigabit Ethernet PHYs. ++ ++ Include support for built-in Ethernet PHYs which are present in ++ the MT7981 and MT7988 SoCs. These PHYs need calibration data ++ present in the SoCs efuse and will dynamically calibrate VCM ++ (common-mode voltage) during startup. +--- /dev/null ++++ b/drivers/net/phy/mediatek/Makefile +@@ -0,0 +1,3 @@ ++# SPDX-License-Identifier: GPL-2.0 ++obj-$(CONFIG_MEDIATEK_GE_PHY) += mtk-ge.o ++obj-$(CONFIG_MEDIATEK_GE_SOC_PHY) += mtk-ge-soc.o +--- a/drivers/net/phy/mediatek-ge-soc.c ++++ /dev/null +@@ -1,1610 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0+ +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#define MTK_GPHY_ID_MT7981 0x03a29461 +-#define MTK_GPHY_ID_MT7988 0x03a29481 +- +-#define MTK_EXT_PAGE_ACCESS 0x1f +-#define MTK_PHY_PAGE_STANDARD 0x0000 +-#define MTK_PHY_PAGE_EXTENDED_3 0x0003 +- +-#define MTK_PHY_LPI_REG_14 0x14 +-#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK GENMASK(8, 0) +- +-#define MTK_PHY_LPI_REG_1c 0x1c +-#define MTK_PHY_SMI_DET_ON_THRESH_MASK GENMASK(13, 8) +- +-#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 +-#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 +- +-#define ANALOG_INTERNAL_OPERATION_MAX_US 20 +-#define TXRESERVE_MIN 0 +-#define TXRESERVE_MAX 7 +- +-#define MTK_PHY_ANARG_RG 0x10 +-#define MTK_PHY_TCLKOFFSET_MASK GENMASK(12, 8) +- +-/* Registers on MDIO_MMD_VEND1 */ +-#define MTK_PHY_TXVLD_DA_RG 0x12 +-#define MTK_PHY_DA_TX_I2MPB_A_GBE_MASK GENMASK(15, 10) +-#define MTK_PHY_DA_TX_I2MPB_A_TBT_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_A2 0x16 +-#define MTK_PHY_DA_TX_I2MPB_A_HBT_MASK GENMASK(15, 10) +-#define MTK_PHY_DA_TX_I2MPB_A_TST_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_B1 0x17 +-#define MTK_PHY_DA_TX_I2MPB_B_GBE_MASK GENMASK(13, 8) +-#define MTK_PHY_DA_TX_I2MPB_B_TBT_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_B2 0x18 +-#define MTK_PHY_DA_TX_I2MPB_B_HBT_MASK GENMASK(13, 8) +-#define MTK_PHY_DA_TX_I2MPB_B_TST_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_C1 0x19 +-#define MTK_PHY_DA_TX_I2MPB_C_GBE_MASK GENMASK(13, 8) +-#define MTK_PHY_DA_TX_I2MPB_C_TBT_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_C2 0x20 +-#define MTK_PHY_DA_TX_I2MPB_C_HBT_MASK GENMASK(13, 8) +-#define MTK_PHY_DA_TX_I2MPB_C_TST_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_D1 0x21 +-#define MTK_PHY_DA_TX_I2MPB_D_GBE_MASK GENMASK(13, 8) +-#define MTK_PHY_DA_TX_I2MPB_D_TBT_MASK GENMASK(5, 0) +- +-#define MTK_PHY_TX_I2MPB_TEST_MODE_D2 0x22 +-#define MTK_PHY_DA_TX_I2MPB_D_HBT_MASK GENMASK(13, 8) +-#define MTK_PHY_DA_TX_I2MPB_D_TST_MASK GENMASK(5, 0) +- +-#define MTK_PHY_RXADC_CTRL_RG7 0xc6 +-#define MTK_PHY_DA_AD_BUF_BIAS_LP_MASK GENMASK(9, 8) +- +-#define MTK_PHY_RXADC_CTRL_RG9 0xc8 +-#define MTK_PHY_DA_RX_PSBN_TBT_MASK GENMASK(14, 12) +-#define MTK_PHY_DA_RX_PSBN_HBT_MASK GENMASK(10, 8) +-#define MTK_PHY_DA_RX_PSBN_GBE_MASK GENMASK(6, 4) +-#define MTK_PHY_DA_RX_PSBN_LP_MASK GENMASK(2, 0) +- +-#define MTK_PHY_LDO_OUTPUT_V 0xd7 +- +-#define MTK_PHY_RG_ANA_CAL_RG0 0xdb +-#define MTK_PHY_RG_CAL_CKINV BIT(12) +-#define MTK_PHY_RG_ANA_CALEN BIT(8) +-#define MTK_PHY_RG_ZCALEN_A BIT(0) +- +-#define MTK_PHY_RG_ANA_CAL_RG1 0xdc +-#define MTK_PHY_RG_ZCALEN_B BIT(12) +-#define MTK_PHY_RG_ZCALEN_C BIT(8) +-#define MTK_PHY_RG_ZCALEN_D BIT(4) +-#define MTK_PHY_RG_TXVOS_CALEN BIT(0) +- +-#define MTK_PHY_RG_ANA_CAL_RG5 0xe0 +-#define MTK_PHY_RG_REXT_TRIM_MASK GENMASK(13, 8) +- +-#define MTK_PHY_RG_TX_FILTER 0xfe +- +-#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120 0x120 +-#define MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK GENMASK(12, 8) +-#define MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK GENMASK(4, 0) +- +-#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122 0x122 +-#define MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK GENMASK(7, 0) +- +-#define MTK_PHY_RG_TESTMUX_ADC_CTRL 0x144 +-#define MTK_PHY_RG_TXEN_DIG_MASK GENMASK(5, 5) +- +-#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B 0x172 +-#define MTK_PHY_CR_TX_AMP_OFFSET_A_MASK GENMASK(13, 8) +-#define MTK_PHY_CR_TX_AMP_OFFSET_B_MASK GENMASK(6, 0) +- +-#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D 0x173 +-#define MTK_PHY_CR_TX_AMP_OFFSET_C_MASK GENMASK(13, 8) +-#define MTK_PHY_CR_TX_AMP_OFFSET_D_MASK GENMASK(6, 0) +- +-#define MTK_PHY_RG_AD_CAL_COMP 0x17a +-#define MTK_PHY_AD_CAL_COMP_OUT_MASK GENMASK(8, 8) +- +-#define MTK_PHY_RG_AD_CAL_CLK 0x17b +-#define MTK_PHY_DA_CAL_CLK BIT(0) +- +-#define MTK_PHY_RG_AD_CALIN 0x17c +-#define MTK_PHY_DA_CALIN_FLAG BIT(0) +- +-#define MTK_PHY_RG_DASN_DAC_IN0_A 0x17d +-#define MTK_PHY_DASN_DAC_IN0_A_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN0_B 0x17e +-#define MTK_PHY_DASN_DAC_IN0_B_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN0_C 0x17f +-#define MTK_PHY_DASN_DAC_IN0_C_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN0_D 0x180 +-#define MTK_PHY_DASN_DAC_IN0_D_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN1_A 0x181 +-#define MTK_PHY_DASN_DAC_IN1_A_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN1_B 0x182 +-#define MTK_PHY_DASN_DAC_IN1_B_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN1_C 0x183 +-#define MTK_PHY_DASN_DAC_IN1_C_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DASN_DAC_IN1_D 0x184 +-#define MTK_PHY_DASN_DAC_IN1_D_MASK GENMASK(9, 0) +- +-#define MTK_PHY_RG_DEV1E_REG19b 0x19b +-#define MTK_PHY_BYPASS_DSP_LPI_READY BIT(8) +- +-#define MTK_PHY_RG_LP_IIR2_K1_L 0x22a +-#define MTK_PHY_RG_LP_IIR2_K1_U 0x22b +-#define MTK_PHY_RG_LP_IIR2_K2_L 0x22c +-#define MTK_PHY_RG_LP_IIR2_K2_U 0x22d +-#define MTK_PHY_RG_LP_IIR2_K3_L 0x22e +-#define MTK_PHY_RG_LP_IIR2_K3_U 0x22f +-#define MTK_PHY_RG_LP_IIR2_K4_L 0x230 +-#define MTK_PHY_RG_LP_IIR2_K4_U 0x231 +-#define MTK_PHY_RG_LP_IIR2_K5_L 0x232 +-#define MTK_PHY_RG_LP_IIR2_K5_U 0x233 +- +-#define MTK_PHY_RG_DEV1E_REG234 0x234 +-#define MTK_PHY_TR_OPEN_LOOP_EN_MASK GENMASK(0, 0) +-#define MTK_PHY_LPF_X_AVERAGE_MASK GENMASK(7, 4) +-#define MTK_PHY_TR_LP_IIR_EEE_EN BIT(12) +- +-#define MTK_PHY_RG_LPF_CNT_VAL 0x235 +- +-#define MTK_PHY_RG_DEV1E_REG238 0x238 +-#define MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK GENMASK(8, 0) +-#define MTK_PHY_LPI_SLV_SEND_TX_EN BIT(12) +- +-#define MTK_PHY_RG_DEV1E_REG239 0x239 +-#define MTK_PHY_LPI_SEND_LOC_TIMER_MASK GENMASK(8, 0) +-#define MTK_PHY_LPI_TXPCS_LOC_RCV BIT(12) +- +-#define MTK_PHY_RG_DEV1E_REG27C 0x27c +-#define MTK_PHY_VGASTATE_FFE_THR_ST1_MASK GENMASK(12, 8) +-#define MTK_PHY_RG_DEV1E_REG27D 0x27d +-#define MTK_PHY_VGASTATE_FFE_THR_ST2_MASK GENMASK(4, 0) +- +-#define MTK_PHY_RG_DEV1E_REG2C7 0x2c7 +-#define MTK_PHY_MAX_GAIN_MASK GENMASK(4, 0) +-#define MTK_PHY_MIN_GAIN_MASK GENMASK(12, 8) +- +-#define MTK_PHY_RG_DEV1E_REG2D1 0x2d1 +-#define MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK GENMASK(7, 0) +-#define MTK_PHY_LPI_SKIP_SD_SLV_TR BIT(8) +-#define MTK_PHY_LPI_TR_READY BIT(9) +-#define MTK_PHY_LPI_VCO_EEE_STG0_EN BIT(10) +- +-#define MTK_PHY_RG_DEV1E_REG323 0x323 +-#define MTK_PHY_EEE_WAKE_MAS_INT_DC BIT(0) +-#define MTK_PHY_EEE_WAKE_SLV_INT_DC BIT(4) +- +-#define MTK_PHY_RG_DEV1E_REG324 0x324 +-#define MTK_PHY_SMI_DETCNT_MAX_MASK GENMASK(5, 0) +-#define MTK_PHY_SMI_DET_MAX_EN BIT(8) +- +-#define MTK_PHY_RG_DEV1E_REG326 0x326 +-#define MTK_PHY_LPI_MODE_SD_ON BIT(0) +-#define MTK_PHY_RESET_RANDUPD_CNT BIT(1) +-#define MTK_PHY_TREC_UPDATE_ENAB_CLR BIT(2) +-#define MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF BIT(4) +-#define MTK_PHY_TR_READY_SKIP_AFE_WAKEUP BIT(5) +- +-#define MTK_PHY_LDO_PUMP_EN_PAIRAB 0x502 +-#define MTK_PHY_LDO_PUMP_EN_PAIRCD 0x503 +- +-#define MTK_PHY_DA_TX_R50_PAIR_A 0x53d +-#define MTK_PHY_DA_TX_R50_PAIR_B 0x53e +-#define MTK_PHY_DA_TX_R50_PAIR_C 0x53f +-#define MTK_PHY_DA_TX_R50_PAIR_D 0x540 +- +-/* Registers on MDIO_MMD_VEND2 */ +-#define MTK_PHY_LED0_ON_CTRL 0x24 +-#define MTK_PHY_LED1_ON_CTRL 0x26 +-#define MTK_PHY_LED_ON_MASK GENMASK(6, 0) +-#define MTK_PHY_LED_ON_LINK1000 BIT(0) +-#define MTK_PHY_LED_ON_LINK100 BIT(1) +-#define MTK_PHY_LED_ON_LINK10 BIT(2) +-#define MTK_PHY_LED_ON_LINK (MTK_PHY_LED_ON_LINK10 |\ +- MTK_PHY_LED_ON_LINK100 |\ +- MTK_PHY_LED_ON_LINK1000) +-#define MTK_PHY_LED_ON_LINKDOWN BIT(3) +-#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */ +-#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */ +-#define MTK_PHY_LED_ON_FORCE_ON BIT(6) +-#define MTK_PHY_LED_ON_POLARITY BIT(14) +-#define MTK_PHY_LED_ON_ENABLE BIT(15) +- +-#define MTK_PHY_LED0_BLINK_CTRL 0x25 +-#define MTK_PHY_LED1_BLINK_CTRL 0x27 +-#define MTK_PHY_LED_BLINK_1000TX BIT(0) +-#define MTK_PHY_LED_BLINK_1000RX BIT(1) +-#define MTK_PHY_LED_BLINK_100TX BIT(2) +-#define MTK_PHY_LED_BLINK_100RX BIT(3) +-#define MTK_PHY_LED_BLINK_10TX BIT(4) +-#define MTK_PHY_LED_BLINK_10RX BIT(5) +-#define MTK_PHY_LED_BLINK_RX (MTK_PHY_LED_BLINK_10RX |\ +- MTK_PHY_LED_BLINK_100RX |\ +- MTK_PHY_LED_BLINK_1000RX) +-#define MTK_PHY_LED_BLINK_TX (MTK_PHY_LED_BLINK_10TX |\ +- MTK_PHY_LED_BLINK_100TX |\ +- MTK_PHY_LED_BLINK_1000TX) +-#define MTK_PHY_LED_BLINK_COLLISION BIT(6) +-#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7) +-#define MTK_PHY_LED_BLINK_RX_IDLE_ERR BIT(8) +-#define MTK_PHY_LED_BLINK_FORCE_BLINK BIT(9) +- +-#define MTK_PHY_LED1_DEFAULT_POLARITIES BIT(1) +- +-#define MTK_PHY_RG_BG_RASEL 0x115 +-#define MTK_PHY_RG_BG_RASEL_MASK GENMASK(2, 0) +- +-/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */ +-#define RG_GPIO_MISC_TPBANK0 0x6f0 +-#define RG_GPIO_MISC_TPBANK0_BOOTMODE GENMASK(11, 8) +- +-/* These macro privides efuse parsing for internal phy. */ +-#define EFS_DA_TX_I2MPB_A(x) (((x) >> 0) & GENMASK(5, 0)) +-#define EFS_DA_TX_I2MPB_B(x) (((x) >> 6) & GENMASK(5, 0)) +-#define EFS_DA_TX_I2MPB_C(x) (((x) >> 12) & GENMASK(5, 0)) +-#define EFS_DA_TX_I2MPB_D(x) (((x) >> 18) & GENMASK(5, 0)) +-#define EFS_DA_TX_AMP_OFFSET_A(x) (((x) >> 24) & GENMASK(5, 0)) +- +-#define EFS_DA_TX_AMP_OFFSET_B(x) (((x) >> 0) & GENMASK(5, 0)) +-#define EFS_DA_TX_AMP_OFFSET_C(x) (((x) >> 6) & GENMASK(5, 0)) +-#define EFS_DA_TX_AMP_OFFSET_D(x) (((x) >> 12) & GENMASK(5, 0)) +-#define EFS_DA_TX_R50_A(x) (((x) >> 18) & GENMASK(5, 0)) +-#define EFS_DA_TX_R50_B(x) (((x) >> 24) & GENMASK(5, 0)) +- +-#define EFS_DA_TX_R50_C(x) (((x) >> 0) & GENMASK(5, 0)) +-#define EFS_DA_TX_R50_D(x) (((x) >> 6) & GENMASK(5, 0)) +- +-#define EFS_RG_BG_RASEL(x) (((x) >> 4) & GENMASK(2, 0)) +-#define EFS_RG_REXT_TRIM(x) (((x) >> 7) & GENMASK(5, 0)) +- +-enum { +- NO_PAIR, +- PAIR_A, +- PAIR_B, +- PAIR_C, +- PAIR_D, +-}; +- +-enum calibration_mode { +- EFUSE_K, +- SW_K +-}; +- +-enum CAL_ITEM { +- REXT, +- TX_OFFSET, +- TX_AMP, +- TX_R50, +- TX_VCM +-}; +- +-enum CAL_MODE { +- EFUSE_M, +- SW_M +-}; +- +-#define MTK_PHY_LED_STATE_FORCE_ON 0 +-#define MTK_PHY_LED_STATE_FORCE_BLINK 1 +-#define MTK_PHY_LED_STATE_NETDEV 2 +- +-struct mtk_socphy_priv { +- unsigned long led_state; +-}; +- +-struct mtk_socphy_shared { +- u32 boottrap; +- struct mtk_socphy_priv priv[4]; +-}; +- +-static int mtk_socphy_read_page(struct phy_device *phydev) +-{ +- return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +-} +- +-static int mtk_socphy_write_page(struct phy_device *phydev, int page) +-{ +- return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); +-} +- +-/* One calibration cycle consists of: +- * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high +- * until AD_CAL_COMP is ready to output calibration result. +- * 2.Wait until DA_CAL_CLK is available. +- * 3.Fetch AD_CAL_COMP_OUT. +- */ +-static int cal_cycle(struct phy_device *phydev, int devad, +- u32 regnum, u16 mask, u16 cal_val) +-{ +- int reg_val; +- int ret; +- +- phy_modify_mmd(phydev, devad, regnum, +- mask, cal_val); +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, +- MTK_PHY_DA_CALIN_FLAG); +- +- ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_AD_CAL_CLK, reg_val, +- reg_val & MTK_PHY_DA_CAL_CLK, 500, +- ANALOG_INTERNAL_OPERATION_MAX_US, +- false); +- if (ret) { +- phydev_err(phydev, "Calibration cycle timeout\n"); +- return ret; +- } +- +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, +- MTK_PHY_DA_CALIN_FLAG); +- ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP); +- if (ret < 0) +- return ret; +- ret = FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret); +- phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret); +- +- return ret; +-} +- +-static int rext_fill_result(struct phy_device *phydev, u16 *buf) +-{ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5, +- MTK_PHY_RG_REXT_TRIM_MASK, buf[0] << 8); +- phy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL, +- MTK_PHY_RG_BG_RASEL_MASK, buf[1]); +- +- return 0; +-} +- +-static int rext_cal_efuse(struct phy_device *phydev, u32 *buf) +-{ +- u16 rext_cal_val[2]; +- +- rext_cal_val[0] = EFS_RG_REXT_TRIM(buf[3]); +- rext_cal_val[1] = EFS_RG_BG_RASEL(buf[3]); +- rext_fill_result(phydev, rext_cal_val); +- +- return 0; +-} +- +-static int tx_offset_fill_result(struct phy_device *phydev, u16 *buf) +-{ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B, +- MTK_PHY_CR_TX_AMP_OFFSET_A_MASK, buf[0] << 8); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B, +- MTK_PHY_CR_TX_AMP_OFFSET_B_MASK, buf[1]); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D, +- MTK_PHY_CR_TX_AMP_OFFSET_C_MASK, buf[2] << 8); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D, +- MTK_PHY_CR_TX_AMP_OFFSET_D_MASK, buf[3]); +- +- return 0; +-} +- +-static int tx_offset_cal_efuse(struct phy_device *phydev, u32 *buf) +-{ +- u16 tx_offset_cal_val[4]; +- +- tx_offset_cal_val[0] = EFS_DA_TX_AMP_OFFSET_A(buf[0]); +- tx_offset_cal_val[1] = EFS_DA_TX_AMP_OFFSET_B(buf[1]); +- tx_offset_cal_val[2] = EFS_DA_TX_AMP_OFFSET_C(buf[1]); +- tx_offset_cal_val[3] = EFS_DA_TX_AMP_OFFSET_D(buf[1]); +- +- tx_offset_fill_result(phydev, tx_offset_cal_val); +- +- return 0; +-} +- +-static int tx_amp_fill_result(struct phy_device *phydev, u16 *buf) +-{ +- const int vals_9481[16] = { 10, 6, 6, 10, +- 10, 6, 6, 10, +- 10, 6, 6, 10, +- 10, 6, 6, 10 }; +- const int vals_9461[16] = { 7, 1, 4, 7, +- 7, 1, 4, 7, +- 7, 1, 4, 7, +- 7, 1, 4, 7 }; +- int bias[16] = {}; +- int i; +- +- switch (phydev->drv->phy_id) { +- case MTK_GPHY_ID_MT7981: +- /* We add some calibration to efuse values +- * due to board level influence. +- * GBE: +7, TBT: +1, HBT: +4, TST: +7 +- */ +- memcpy(bias, (const void *)vals_9461, sizeof(bias)); +- break; +- case MTK_GPHY_ID_MT7988: +- memcpy(bias, (const void *)vals_9481, sizeof(bias)); +- break; +- } +- +- /* Prevent overflow */ +- for (i = 0; i < 12; i++) { +- if (buf[i >> 2] + bias[i] > 63) { +- buf[i >> 2] = 63; +- bias[i] = 0; +- } +- } +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, +- MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, +- buf[0] + bias[0])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, +- MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, +- buf[0] + bias[1])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, +- MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, +- buf[0] + bias[2])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, +- MTK_PHY_DA_TX_I2MPB_A_TST_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_TST_MASK, +- buf[0] + bias[3])); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, +- MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, +- buf[1] + bias[4])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, +- MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, +- buf[1] + bias[5])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, +- MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, +- buf[1] + bias[6])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, +- MTK_PHY_DA_TX_I2MPB_B_TST_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_TST_MASK, +- buf[1] + bias[7])); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, +- MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, +- buf[2] + bias[8])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, +- MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, +- buf[2] + bias[9])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, +- MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, +- buf[2] + bias[10])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, +- MTK_PHY_DA_TX_I2MPB_C_TST_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_TST_MASK, +- buf[2] + bias[11])); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, +- MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, +- buf[3] + bias[12])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, +- MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, +- buf[3] + bias[13])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, +- MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, +- buf[3] + bias[14])); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, +- MTK_PHY_DA_TX_I2MPB_D_TST_MASK, +- FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_TST_MASK, +- buf[3] + bias[15])); +- +- return 0; +-} +- +-static int tx_amp_cal_efuse(struct phy_device *phydev, u32 *buf) +-{ +- u16 tx_amp_cal_val[4]; +- +- tx_amp_cal_val[0] = EFS_DA_TX_I2MPB_A(buf[0]); +- tx_amp_cal_val[1] = EFS_DA_TX_I2MPB_B(buf[0]); +- tx_amp_cal_val[2] = EFS_DA_TX_I2MPB_C(buf[0]); +- tx_amp_cal_val[3] = EFS_DA_TX_I2MPB_D(buf[0]); +- tx_amp_fill_result(phydev, tx_amp_cal_val); +- +- return 0; +-} +- +-static int tx_r50_fill_result(struct phy_device *phydev, u16 tx_r50_cal_val, +- u8 txg_calen_x) +-{ +- int bias = 0; +- u16 reg, val; +- +- if (phydev->drv->phy_id == MTK_GPHY_ID_MT7988) +- bias = -1; +- +- val = clamp_val(bias + tx_r50_cal_val, 0, 63); +- +- switch (txg_calen_x) { +- case PAIR_A: +- reg = MTK_PHY_DA_TX_R50_PAIR_A; +- break; +- case PAIR_B: +- reg = MTK_PHY_DA_TX_R50_PAIR_B; +- break; +- case PAIR_C: +- reg = MTK_PHY_DA_TX_R50_PAIR_C; +- break; +- case PAIR_D: +- reg = MTK_PHY_DA_TX_R50_PAIR_D; +- break; +- default: +- return -EINVAL; +- } +- +- phy_write_mmd(phydev, MDIO_MMD_VEND1, reg, val | val << 8); +- +- return 0; +-} +- +-static int tx_r50_cal_efuse(struct phy_device *phydev, u32 *buf, +- u8 txg_calen_x) +-{ +- u16 tx_r50_cal_val; +- +- switch (txg_calen_x) { +- case PAIR_A: +- tx_r50_cal_val = EFS_DA_TX_R50_A(buf[1]); +- break; +- case PAIR_B: +- tx_r50_cal_val = EFS_DA_TX_R50_B(buf[1]); +- break; +- case PAIR_C: +- tx_r50_cal_val = EFS_DA_TX_R50_C(buf[2]); +- break; +- case PAIR_D: +- tx_r50_cal_val = EFS_DA_TX_R50_D(buf[2]); +- break; +- default: +- return -EINVAL; +- } +- tx_r50_fill_result(phydev, tx_r50_cal_val, txg_calen_x); +- +- return 0; +-} +- +-static int tx_vcm_cal_sw(struct phy_device *phydev, u8 rg_txreserve_x) +-{ +- u8 lower_idx, upper_idx, txreserve_val; +- u8 lower_ret, upper_ret; +- int ret; +- +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, +- MTK_PHY_RG_ANA_CALEN); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, +- MTK_PHY_RG_CAL_CKINV); +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, +- MTK_PHY_RG_TXVOS_CALEN); +- +- switch (rg_txreserve_x) { +- case PAIR_A: +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN0_A, +- MTK_PHY_DASN_DAC_IN0_A_MASK); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN1_A, +- MTK_PHY_DASN_DAC_IN1_A_MASK); +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_ANA_CAL_RG0, +- MTK_PHY_RG_ZCALEN_A); +- break; +- case PAIR_B: +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN0_B, +- MTK_PHY_DASN_DAC_IN0_B_MASK); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN1_B, +- MTK_PHY_DASN_DAC_IN1_B_MASK); +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_ANA_CAL_RG1, +- MTK_PHY_RG_ZCALEN_B); +- break; +- case PAIR_C: +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN0_C, +- MTK_PHY_DASN_DAC_IN0_C_MASK); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN1_C, +- MTK_PHY_DASN_DAC_IN1_C_MASK); +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_ANA_CAL_RG1, +- MTK_PHY_RG_ZCALEN_C); +- break; +- case PAIR_D: +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN0_D, +- MTK_PHY_DASN_DAC_IN0_D_MASK); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DASN_DAC_IN1_D, +- MTK_PHY_DASN_DAC_IN1_D_MASK); +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_ANA_CAL_RG1, +- MTK_PHY_RG_ZCALEN_D); +- break; +- default: +- ret = -EINVAL; +- goto restore; +- } +- +- lower_idx = TXRESERVE_MIN; +- upper_idx = TXRESERVE_MAX; +- +- phydev_dbg(phydev, "Start TX-VCM SW cal.\n"); +- while ((upper_idx - lower_idx) > 1) { +- txreserve_val = DIV_ROUND_CLOSEST(lower_idx + upper_idx, 2); +- ret = cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, +- MTK_PHY_DA_RX_PSBN_TBT_MASK | +- MTK_PHY_DA_RX_PSBN_HBT_MASK | +- MTK_PHY_DA_RX_PSBN_GBE_MASK | +- MTK_PHY_DA_RX_PSBN_LP_MASK, +- txreserve_val << 12 | txreserve_val << 8 | +- txreserve_val << 4 | txreserve_val); +- if (ret == 1) { +- upper_idx = txreserve_val; +- upper_ret = ret; +- } else if (ret == 0) { +- lower_idx = txreserve_val; +- lower_ret = ret; +- } else { +- goto restore; +- } +- } +- +- if (lower_idx == TXRESERVE_MIN) { +- lower_ret = cal_cycle(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RXADC_CTRL_RG9, +- MTK_PHY_DA_RX_PSBN_TBT_MASK | +- MTK_PHY_DA_RX_PSBN_HBT_MASK | +- MTK_PHY_DA_RX_PSBN_GBE_MASK | +- MTK_PHY_DA_RX_PSBN_LP_MASK, +- lower_idx << 12 | lower_idx << 8 | +- lower_idx << 4 | lower_idx); +- ret = lower_ret; +- } else if (upper_idx == TXRESERVE_MAX) { +- upper_ret = cal_cycle(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RXADC_CTRL_RG9, +- MTK_PHY_DA_RX_PSBN_TBT_MASK | +- MTK_PHY_DA_RX_PSBN_HBT_MASK | +- MTK_PHY_DA_RX_PSBN_GBE_MASK | +- MTK_PHY_DA_RX_PSBN_LP_MASK, +- upper_idx << 12 | upper_idx << 8 | +- upper_idx << 4 | upper_idx); +- ret = upper_ret; +- } +- if (ret < 0) +- goto restore; +- +- /* We calibrate TX-VCM in different logic. Check upper index and then +- * lower index. If this calibration is valid, apply lower index's +- * result. +- */ +- ret = upper_ret - lower_ret; +- if (ret == 1) { +- ret = 0; +- /* Make sure we use upper_idx in our calibration system */ +- cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, +- MTK_PHY_DA_RX_PSBN_TBT_MASK | +- MTK_PHY_DA_RX_PSBN_HBT_MASK | +- MTK_PHY_DA_RX_PSBN_GBE_MASK | +- MTK_PHY_DA_RX_PSBN_LP_MASK, +- upper_idx << 12 | upper_idx << 8 | +- upper_idx << 4 | upper_idx); +- phydev_dbg(phydev, "TX-VCM SW cal result: 0x%x\n", upper_idx); +- } else if (lower_idx == TXRESERVE_MIN && upper_ret == 1 && +- lower_ret == 1) { +- ret = 0; +- cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, +- MTK_PHY_DA_RX_PSBN_TBT_MASK | +- MTK_PHY_DA_RX_PSBN_HBT_MASK | +- MTK_PHY_DA_RX_PSBN_GBE_MASK | +- MTK_PHY_DA_RX_PSBN_LP_MASK, +- lower_idx << 12 | lower_idx << 8 | +- lower_idx << 4 | lower_idx); +- phydev_warn(phydev, "TX-VCM SW cal result at low margin 0x%x\n", +- lower_idx); +- } else if (upper_idx == TXRESERVE_MAX && upper_ret == 0 && +- lower_ret == 0) { +- ret = 0; +- phydev_warn(phydev, +- "TX-VCM SW cal result at high margin 0x%x\n", +- upper_idx); +- } else { +- ret = -EINVAL; +- } +- +-restore: +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, +- MTK_PHY_RG_ANA_CALEN); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, +- MTK_PHY_RG_TXVOS_CALEN); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, +- MTK_PHY_RG_ZCALEN_A); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, +- MTK_PHY_RG_ZCALEN_B | MTK_PHY_RG_ZCALEN_C | +- MTK_PHY_RG_ZCALEN_D); +- +- return ret; +-} +- +-static void mt798x_phy_common_finetune(struct phy_device *phydev) +-{ +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* SlvDSPreadyTime = 24, MasDSPreadyTime = 24 */ +- __phy_write(phydev, 0x11, 0xc71); +- __phy_write(phydev, 0x12, 0xc); +- __phy_write(phydev, 0x10, 0x8fae); +- +- /* EnabRandUpdTrig = 1 */ +- __phy_write(phydev, 0x11, 0x2f00); +- __phy_write(phydev, 0x12, 0xe); +- __phy_write(phydev, 0x10, 0x8fb0); +- +- /* NormMseLoThresh = 85 */ +- __phy_write(phydev, 0x11, 0x55a0); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x83aa); +- +- /* FfeUpdGainForce = 1(Enable), FfeUpdGainForceVal = 4 */ +- __phy_write(phydev, 0x11, 0x240); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x9680); +- +- /* TrFreeze = 0 (mt7988 default) */ +- __phy_write(phydev, 0x11, 0x0); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x9686); +- +- /* SSTrKp100 = 5 */ +- /* SSTrKf100 = 6 */ +- /* SSTrKp1000Mas = 5 */ +- /* SSTrKf1000Mas = 6 */ +- /* SSTrKp1000Slv = 5 */ +- /* SSTrKf1000Slv = 6 */ +- __phy_write(phydev, 0x11, 0xbaef); +- __phy_write(phydev, 0x12, 0x2e); +- __phy_write(phydev, 0x10, 0x968c); +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); +-} +- +-static void mt7981_phy_finetune(struct phy_device *phydev) +-{ +- u16 val[8] = { 0x01ce, 0x01c1, +- 0x020f, 0x0202, +- 0x03d0, 0x03c0, +- 0x0013, 0x0005 }; +- int i, k; +- +- /* 100M eye finetune: +- * Keep middle level of TX MLT3 shapper as default. +- * Only change TX MLT3 overshoot level here. +- */ +- for (k = 0, i = 1; i < 12; i++) { +- if (i % 3 == 0) +- continue; +- phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[k++]); +- } +- +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* ResetSyncOffset = 6 */ +- __phy_write(phydev, 0x11, 0x600); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x8fc0); +- +- /* VgaDecRate = 1 */ +- __phy_write(phydev, 0x11, 0x4c2a); +- __phy_write(phydev, 0x12, 0x3e); +- __phy_write(phydev, 0x10, 0x8fa4); +- +- /* MrvlTrFix100Kp = 3, MrvlTrFix100Kf = 2, +- * MrvlTrFix1000Kp = 3, MrvlTrFix1000Kf = 2 +- */ +- __phy_write(phydev, 0x11, 0xd10a); +- __phy_write(phydev, 0x12, 0x34); +- __phy_write(phydev, 0x10, 0x8f82); +- +- /* VcoSlicerThreshBitsHigh */ +- __phy_write(phydev, 0x11, 0x5555); +- __phy_write(phydev, 0x12, 0x55); +- __phy_write(phydev, 0x10, 0x8ec0); +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); +- +- /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 9 */ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, +- MTK_PHY_TR_OPEN_LOOP_EN_MASK | +- MTK_PHY_LPF_X_AVERAGE_MASK, +- BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0x9)); +- +- /* rg_tr_lpf_cnt_val = 512 */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x200); +- +- /* IIR2 related */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_L, 0x82); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_U, 0x0); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_L, 0x103); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_U, 0x0); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_L, 0x82); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_U, 0x0); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_L, 0xd177); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_U, 0x3); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_L, 0x2c82); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_U, 0xe); +- +- /* FFE peaking */ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27C, +- MTK_PHY_VGASTATE_FFE_THR_ST1_MASK, 0x1b << 8); +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27D, +- MTK_PHY_VGASTATE_FFE_THR_ST2_MASK, 0x1e); +- +- /* Disable LDO pump */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRAB, 0x0); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRCD, 0x0); +- /* Adjust LDO output voltage */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_OUTPUT_V, 0x2222); +-} +- +-static void mt7988_phy_finetune(struct phy_device *phydev) +-{ +- u16 val[12] = { 0x0187, 0x01cd, 0x01c8, 0x0182, +- 0x020d, 0x0206, 0x0384, 0x03d0, +- 0x03c6, 0x030a, 0x0011, 0x0005 }; +- int i; +- +- /* Set default MLT3 shaper first */ +- for (i = 0; i < 12; i++) +- phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[i]); +- +- /* TCT finetune */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_TX_FILTER, 0x5); +- +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* ResetSyncOffset = 5 */ +- __phy_write(phydev, 0x11, 0x500); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x8fc0); +- +- /* VgaDecRate is 1 at default on mt7988 */ +- +- /* MrvlTrFix100Kp = 6, MrvlTrFix100Kf = 7, +- * MrvlTrFix1000Kp = 6, MrvlTrFix1000Kf = 7 +- */ +- __phy_write(phydev, 0x11, 0xb90a); +- __phy_write(phydev, 0x12, 0x6f); +- __phy_write(phydev, 0x10, 0x8f82); +- +- /* RemAckCntLimitCtrl = 1 */ +- __phy_write(phydev, 0x11, 0xfbba); +- __phy_write(phydev, 0x12, 0xc3); +- __phy_write(phydev, 0x10, 0x87f8); +- +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); +- +- /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 10 */ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, +- MTK_PHY_TR_OPEN_LOOP_EN_MASK | +- MTK_PHY_LPF_X_AVERAGE_MASK, +- BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0xa)); +- +- /* rg_tr_lpf_cnt_val = 1023 */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x3ff); +-} +- +-static void mt798x_phy_eee(struct phy_device *phydev) +-{ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120, +- MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK | +- MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK, +- FIELD_PREP(MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK, 0x0) | +- FIELD_PREP(MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK, 0x14)); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122, +- MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, +- FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, +- 0xff)); +- +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_TESTMUX_ADC_CTRL, +- MTK_PHY_RG_TXEN_DIG_MASK); +- +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DEV1E_REG19b, MTK_PHY_BYPASS_DSP_LPI_READY); +- +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_DEV1E_REG234, MTK_PHY_TR_LP_IIR_EEE_EN); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG238, +- MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK | +- MTK_PHY_LPI_SLV_SEND_TX_EN, +- FIELD_PREP(MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK, 0x120)); +- +- /* Keep MTK_PHY_LPI_SEND_LOC_TIMER as 375 */ +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG239, +- MTK_PHY_LPI_TXPCS_LOC_RCV); +- +- /* This also fixes some IoT issues, such as CH340 */ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2C7, +- MTK_PHY_MAX_GAIN_MASK | MTK_PHY_MIN_GAIN_MASK, +- FIELD_PREP(MTK_PHY_MAX_GAIN_MASK, 0x8) | +- FIELD_PREP(MTK_PHY_MIN_GAIN_MASK, 0x13)); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2D1, +- MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK, +- FIELD_PREP(MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK, +- 0x33) | +- MTK_PHY_LPI_SKIP_SD_SLV_TR | MTK_PHY_LPI_TR_READY | +- MTK_PHY_LPI_VCO_EEE_STG0_EN); +- +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG323, +- MTK_PHY_EEE_WAKE_MAS_INT_DC | +- MTK_PHY_EEE_WAKE_SLV_INT_DC); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG324, +- MTK_PHY_SMI_DETCNT_MAX_MASK, +- FIELD_PREP(MTK_PHY_SMI_DETCNT_MAX_MASK, 0x3f) | +- MTK_PHY_SMI_DET_MAX_EN); +- +- phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG326, +- MTK_PHY_LPI_MODE_SD_ON | MTK_PHY_RESET_RANDUPD_CNT | +- MTK_PHY_TREC_UPDATE_ENAB_CLR | +- MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF | +- MTK_PHY_TR_READY_SKIP_AFE_WAKEUP); +- +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* Regsigdet_sel_1000 = 0 */ +- __phy_write(phydev, 0x11, 0xb); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x9690); +- +- /* REG_EEE_st2TrKf1000 = 2 */ +- __phy_write(phydev, 0x11, 0x114f); +- __phy_write(phydev, 0x12, 0x2); +- __phy_write(phydev, 0x10, 0x969a); +- +- /* RegEEE_slv_wake_tr_timer_tar = 6, RegEEE_slv_remtx_timer_tar = 20 */ +- __phy_write(phydev, 0x11, 0x3028); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x969e); +- +- /* RegEEE_slv_wake_int_timer_tar = 8 */ +- __phy_write(phydev, 0x11, 0x5010); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96a0); +- +- /* RegEEE_trfreeze_timer2 = 586 */ +- __phy_write(phydev, 0x11, 0x24a); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96a8); +- +- /* RegEEE100Stg1_tar = 16 */ +- __phy_write(phydev, 0x11, 0x3210); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96b8); +- +- /* REGEEE_wake_slv_tr_wait_dfesigdet_en = 0 */ +- __phy_write(phydev, 0x11, 0x1463); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96ca); +- +- /* DfeTailEnableVgaThresh1000 = 27 */ +- __phy_write(phydev, 0x11, 0x36); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x8f80); +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); +- +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3); +- __phy_modify(phydev, MTK_PHY_LPI_REG_14, +- MTK_PHY_LPI_WAKE_TIMER_1000_MASK, +- FIELD_PREP(MTK_PHY_LPI_WAKE_TIMER_1000_MASK, 0x19c)); +- +- __phy_modify(phydev, MTK_PHY_LPI_REG_1c, MTK_PHY_SMI_DET_ON_THRESH_MASK, +- FIELD_PREP(MTK_PHY_SMI_DET_ON_THRESH_MASK, 0xc)); +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); +- +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, +- MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122, +- MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, +- FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, +- 0xff)); +-} +- +-static int cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item, +- u8 start_pair, u8 end_pair) +-{ +- u8 pair_n; +- int ret; +- +- for (pair_n = start_pair; pair_n <= end_pair; pair_n++) { +- /* TX_OFFSET & TX_AMP have no SW calibration. */ +- switch (cal_item) { +- case TX_VCM: +- ret = tx_vcm_cal_sw(phydev, pair_n); +- break; +- default: +- return -EINVAL; +- } +- if (ret) +- return ret; +- } +- return 0; +-} +- +-static int cal_efuse(struct phy_device *phydev, enum CAL_ITEM cal_item, +- u8 start_pair, u8 end_pair, u32 *buf) +-{ +- u8 pair_n; +- int ret; +- +- for (pair_n = start_pair; pair_n <= end_pair; pair_n++) { +- /* TX_VCM has no efuse calibration. */ +- switch (cal_item) { +- case REXT: +- ret = rext_cal_efuse(phydev, buf); +- break; +- case TX_OFFSET: +- ret = tx_offset_cal_efuse(phydev, buf); +- break; +- case TX_AMP: +- ret = tx_amp_cal_efuse(phydev, buf); +- break; +- case TX_R50: +- ret = tx_r50_cal_efuse(phydev, buf, pair_n); +- break; +- default: +- return -EINVAL; +- } +- if (ret) +- return ret; +- } +- +- return 0; +-} +- +-static int start_cal(struct phy_device *phydev, enum CAL_ITEM cal_item, +- enum CAL_MODE cal_mode, u8 start_pair, +- u8 end_pair, u32 *buf) +-{ +- int ret; +- +- switch (cal_mode) { +- case EFUSE_M: +- ret = cal_efuse(phydev, cal_item, start_pair, +- end_pair, buf); +- break; +- case SW_M: +- ret = cal_sw(phydev, cal_item, start_pair, end_pair); +- break; +- default: +- return -EINVAL; +- } +- +- if (ret) { +- phydev_err(phydev, "cal %d failed\n", cal_item); +- return -EIO; +- } +- +- return 0; +-} +- +-static int mt798x_phy_calibration(struct phy_device *phydev) +-{ +- struct nvmem_cell *cell; +- int ret = 0; +- size_t len; +- u32 *buf; +- +- cell = nvmem_cell_get(&phydev->mdio.dev, "phy-cal-data"); +- if (IS_ERR(cell)) { +- if (PTR_ERR(cell) == -EPROBE_DEFER) +- return PTR_ERR(cell); +- return 0; +- } +- +- buf = (u32 *)nvmem_cell_read(cell, &len); +- nvmem_cell_put(cell); +- if (IS_ERR(buf)) +- return PTR_ERR(buf); +- +- if (!buf[0] || !buf[1] || !buf[2] || !buf[3] || len < 4 * sizeof(u32)) { +- phydev_err(phydev, "invalid efuse data\n"); +- ret = -EINVAL; +- goto out; +- } +- +- ret = start_cal(phydev, REXT, EFUSE_M, NO_PAIR, NO_PAIR, buf); +- if (ret) +- goto out; +- ret = start_cal(phydev, TX_OFFSET, EFUSE_M, NO_PAIR, NO_PAIR, buf); +- if (ret) +- goto out; +- ret = start_cal(phydev, TX_AMP, EFUSE_M, NO_PAIR, NO_PAIR, buf); +- if (ret) +- goto out; +- ret = start_cal(phydev, TX_R50, EFUSE_M, PAIR_A, PAIR_D, buf); +- if (ret) +- goto out; +- ret = start_cal(phydev, TX_VCM, SW_M, PAIR_A, PAIR_A, buf); +- if (ret) +- goto out; +- +-out: +- kfree(buf); +- return ret; +-} +- +-static int mt798x_phy_config_init(struct phy_device *phydev) +-{ +- switch (phydev->drv->phy_id) { +- case MTK_GPHY_ID_MT7981: +- mt7981_phy_finetune(phydev); +- break; +- case MTK_GPHY_ID_MT7988: +- mt7988_phy_finetune(phydev); +- break; +- } +- +- mt798x_phy_common_finetune(phydev); +- mt798x_phy_eee(phydev); +- +- return mt798x_phy_calibration(phydev); +-} +- +-static int mt798x_phy_hw_led_on_set(struct phy_device *phydev, u8 index, +- bool on) +-{ +- unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- bool changed; +- +- if (on) +- changed = !test_and_set_bit(bit_on, &priv->led_state); +- else +- changed = !!test_and_clear_bit(bit_on, &priv->led_state); +- +- changed |= !!test_and_clear_bit(MTK_PHY_LED_STATE_NETDEV + +- (index ? 16 : 0), &priv->led_state); +- if (changed) +- return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_ON_CTRL : +- MTK_PHY_LED0_ON_CTRL, +- MTK_PHY_LED_ON_MASK, +- on ? MTK_PHY_LED_ON_FORCE_ON : 0); +- else +- return 0; +-} +- +-static int mt798x_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, +- bool blinking) +-{ +- unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + +- (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- bool changed; +- +- if (blinking) +- changed = !test_and_set_bit(bit_blink, &priv->led_state); +- else +- changed = !!test_and_clear_bit(bit_blink, &priv->led_state); +- +- changed |= !!test_bit(MTK_PHY_LED_STATE_NETDEV + +- (index ? 16 : 0), &priv->led_state); +- if (changed) +- return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_BLINK_CTRL : +- MTK_PHY_LED0_BLINK_CTRL, +- blinking ? +- MTK_PHY_LED_BLINK_FORCE_BLINK : 0); +- else +- return 0; +-} +- +-static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index, +- unsigned long *delay_on, +- unsigned long *delay_off) +-{ +- bool blinking = false; +- int err = 0; +- +- if (index > 1) +- return -EINVAL; +- +- if (delay_on && delay_off && (*delay_on > 0) && (*delay_off > 0)) { +- blinking = true; +- *delay_on = 50; +- *delay_off = 50; +- } +- +- err = mt798x_phy_hw_led_blink_set(phydev, index, blinking); +- if (err) +- return err; +- +- return mt798x_phy_hw_led_on_set(phydev, index, false); +-} +- +-static int mt798x_phy_led_brightness_set(struct phy_device *phydev, +- u8 index, enum led_brightness value) +-{ +- int err; +- +- err = mt798x_phy_hw_led_blink_set(phydev, index, false); +- if (err) +- return err; +- +- return mt798x_phy_hw_led_on_set(phydev, index, (value != LED_OFF)); +-} +- +-static const unsigned long supported_triggers = +- BIT(TRIGGER_NETDEV_FULL_DUPLEX) | +- BIT(TRIGGER_NETDEV_HALF_DUPLEX) | +- BIT(TRIGGER_NETDEV_LINK) | +- BIT(TRIGGER_NETDEV_LINK_10) | +- BIT(TRIGGER_NETDEV_LINK_100) | +- BIT(TRIGGER_NETDEV_LINK_1000) | +- BIT(TRIGGER_NETDEV_RX) | +- BIT(TRIGGER_NETDEV_TX); +- +-static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, +- unsigned long rules) +-{ +- if (index > 1) +- return -EINVAL; +- +- /* All combinations of the supported triggers are allowed */ +- if (rules & ~supported_triggers) +- return -EOPNOTSUPP; +- +- return 0; +-}; +- +-static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index, +- unsigned long *rules) +-{ +- unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + +- (index ? 16 : 0); +- unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); +- unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- int on, blink; +- +- if (index > 1) +- return -EINVAL; +- +- on = phy_read_mmd(phydev, MDIO_MMD_VEND2, +- index ? MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL); +- +- if (on < 0) +- return -EIO; +- +- blink = phy_read_mmd(phydev, MDIO_MMD_VEND2, +- index ? MTK_PHY_LED1_BLINK_CTRL : +- MTK_PHY_LED0_BLINK_CTRL); +- if (blink < 0) +- return -EIO; +- +- if ((on & (MTK_PHY_LED_ON_LINK | MTK_PHY_LED_ON_FDX | +- MTK_PHY_LED_ON_HDX | MTK_PHY_LED_ON_LINKDOWN)) || +- (blink & (MTK_PHY_LED_BLINK_RX | MTK_PHY_LED_BLINK_TX))) +- set_bit(bit_netdev, &priv->led_state); +- else +- clear_bit(bit_netdev, &priv->led_state); +- +- if (on & MTK_PHY_LED_ON_FORCE_ON) +- set_bit(bit_on, &priv->led_state); +- else +- clear_bit(bit_on, &priv->led_state); +- +- if (blink & MTK_PHY_LED_BLINK_FORCE_BLINK) +- set_bit(bit_blink, &priv->led_state); +- else +- clear_bit(bit_blink, &priv->led_state); +- +- if (!rules) +- return 0; +- +- if (on & MTK_PHY_LED_ON_LINK) +- *rules |= BIT(TRIGGER_NETDEV_LINK); +- +- if (on & MTK_PHY_LED_ON_LINK10) +- *rules |= BIT(TRIGGER_NETDEV_LINK_10); +- +- if (on & MTK_PHY_LED_ON_LINK100) +- *rules |= BIT(TRIGGER_NETDEV_LINK_100); +- +- if (on & MTK_PHY_LED_ON_LINK1000) +- *rules |= BIT(TRIGGER_NETDEV_LINK_1000); +- +- if (on & MTK_PHY_LED_ON_FDX) +- *rules |= BIT(TRIGGER_NETDEV_FULL_DUPLEX); +- +- if (on & MTK_PHY_LED_ON_HDX) +- *rules |= BIT(TRIGGER_NETDEV_HALF_DUPLEX); +- +- if (blink & MTK_PHY_LED_BLINK_RX) +- *rules |= BIT(TRIGGER_NETDEV_RX); +- +- if (blink & MTK_PHY_LED_BLINK_TX) +- *rules |= BIT(TRIGGER_NETDEV_TX); +- +- return 0; +-}; +- +-static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index, +- unsigned long rules) +-{ +- unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- u16 on = 0, blink = 0; +- int ret; +- +- if (index > 1) +- return -EINVAL; +- +- if (rules & BIT(TRIGGER_NETDEV_FULL_DUPLEX)) +- on |= MTK_PHY_LED_ON_FDX; +- +- if (rules & BIT(TRIGGER_NETDEV_HALF_DUPLEX)) +- on |= MTK_PHY_LED_ON_HDX; +- +- if (rules & (BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK))) +- on |= MTK_PHY_LED_ON_LINK10; +- +- if (rules & (BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK))) +- on |= MTK_PHY_LED_ON_LINK100; +- +- if (rules & (BIT(TRIGGER_NETDEV_LINK_1000) | BIT(TRIGGER_NETDEV_LINK))) +- on |= MTK_PHY_LED_ON_LINK1000; +- +- if (rules & BIT(TRIGGER_NETDEV_RX)) { +- blink |= (on & MTK_PHY_LED_ON_LINK) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? +- MTK_PHY_LED_BLINK_10RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? +- MTK_PHY_LED_BLINK_100RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? +- MTK_PHY_LED_BLINK_1000RX : 0)) : +- MTK_PHY_LED_BLINK_RX; +- } +- +- if (rules & BIT(TRIGGER_NETDEV_TX)) { +- blink |= (on & MTK_PHY_LED_ON_LINK) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? +- MTK_PHY_LED_BLINK_10TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? +- MTK_PHY_LED_BLINK_100TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? +- MTK_PHY_LED_BLINK_1000TX : 0)) : +- MTK_PHY_LED_BLINK_TX; +- } +- +- if (blink || on) +- set_bit(bit_netdev, &priv->led_state); +- else +- clear_bit(bit_netdev, &priv->led_state); +- +- ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_ON_CTRL : +- MTK_PHY_LED0_ON_CTRL, +- MTK_PHY_LED_ON_FDX | +- MTK_PHY_LED_ON_HDX | +- MTK_PHY_LED_ON_LINK, +- on); +- +- if (ret) +- return ret; +- +- return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_BLINK_CTRL : +- MTK_PHY_LED0_BLINK_CTRL, blink); +-}; +- +-static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num) +-{ +- struct mtk_socphy_shared *priv = phydev->shared->priv; +- u32 polarities; +- +- if (led_num == 0) +- polarities = ~(priv->boottrap); +- else +- polarities = MTK_PHY_LED1_DEFAULT_POLARITIES; +- +- if (polarities & BIT(phydev->mdio.addr)) +- return true; +- +- return false; +-} +- +-static int mt7988_phy_fix_leds_polarities(struct phy_device *phydev) +-{ +- struct pinctrl *pinctrl; +- int index; +- +- /* Setup LED polarity according to bootstrap use of LED pins */ +- for (index = 0; index < 2; ++index) +- phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL, +- MTK_PHY_LED_ON_POLARITY, +- mt7988_phy_led_get_polarity(phydev, index) ? +- MTK_PHY_LED_ON_POLARITY : 0); +- +- /* Only now setup pinctrl to avoid bogus blinking */ +- pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led"); +- if (IS_ERR(pinctrl)) +- dev_err(&phydev->mdio.bus->dev, +- "Failed to setup PHY LED pinctrl\n"); +- +- return 0; +-} +- +-static int mt7988_phy_probe_shared(struct phy_device *phydev) +-{ +- struct device_node *np = dev_of_node(&phydev->mdio.bus->dev); +- struct mtk_socphy_shared *shared = phydev->shared->priv; +- struct regmap *regmap; +- u32 reg; +- int ret; +- +- /* The LED0 of the 4 PHYs in MT7988 are wired to SoC pins LED_A, LED_B, +- * LED_C and LED_D respectively. At the same time those pins are used to +- * bootstrap configuration of the reference clock source (LED_A), +- * DRAM DDRx16b x2/x1 (LED_B) and boot device (LED_C, LED_D). +- * In practice this is done using a LED and a resistor pulling the pin +- * either to GND or to VIO. +- * The detected value at boot time is accessible at run-time using the +- * TPBANK0 register located in the gpio base of the pinctrl, in order +- * to read it here it needs to be referenced by a phandle called +- * 'mediatek,pio' in the MDIO bus hosting the PHY. +- * The 4 bits in TPBANK0 are kept as package shared data and are used to +- * set LED polarity for each of the LED0. +- */ +- regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,pio"); +- if (IS_ERR(regmap)) +- return PTR_ERR(regmap); +- +- ret = regmap_read(regmap, RG_GPIO_MISC_TPBANK0, ®); +- if (ret) +- return ret; +- +- shared->boottrap = FIELD_GET(RG_GPIO_MISC_TPBANK0_BOOTMODE, reg); +- +- return 0; +-} +- +-static void mt798x_phy_leds_state_init(struct phy_device *phydev) +-{ +- int i; +- +- for (i = 0; i < 2; ++i) +- mt798x_phy_led_hw_control_get(phydev, i, NULL); +-} +- +-static int mt7988_phy_probe(struct phy_device *phydev) +-{ +- struct mtk_socphy_shared *shared; +- struct mtk_socphy_priv *priv; +- int err; +- +- if (phydev->mdio.addr > 3) +- return -EINVAL; +- +- err = devm_phy_package_join(&phydev->mdio.dev, phydev, 0, +- sizeof(struct mtk_socphy_shared)); +- if (err) +- return err; +- +- if (phy_package_probe_once(phydev)) { +- err = mt7988_phy_probe_shared(phydev); +- if (err) +- return err; +- } +- +- shared = phydev->shared->priv; +- priv = &shared->priv[phydev->mdio.addr]; +- +- phydev->priv = priv; +- +- mt798x_phy_leds_state_init(phydev); +- +- err = mt7988_phy_fix_leds_polarities(phydev); +- if (err) +- return err; +- +- /* Disable TX power saving at probing to: +- * 1. Meet common mode compliance test criteria +- * 2. Make sure that TX-VCM calibration works fine +- */ +- phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG7, +- MTK_PHY_DA_AD_BUF_BIAS_LP_MASK, 0x3 << 8); +- +- return mt798x_phy_calibration(phydev); +-} +- +-static int mt7981_phy_probe(struct phy_device *phydev) +-{ +- struct mtk_socphy_priv *priv; +- +- priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct mtk_socphy_priv), +- GFP_KERNEL); +- if (!priv) +- return -ENOMEM; +- +- phydev->priv = priv; +- +- mt798x_phy_leds_state_init(phydev); +- +- return mt798x_phy_calibration(phydev); +-} +- +-static struct phy_driver mtk_socphy_driver[] = { +- { +- PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981), +- .name = "MediaTek MT7981 PHY", +- .config_init = mt798x_phy_config_init, +- .config_intr = genphy_no_config_intr, +- .handle_interrupt = genphy_handle_interrupt_no_ack, +- .probe = mt7981_phy_probe, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = mtk_socphy_read_page, +- .write_page = mtk_socphy_write_page, +- .led_blink_set = mt798x_phy_led_blink_set, +- .led_brightness_set = mt798x_phy_led_brightness_set, +- .led_hw_is_supported = mt798x_phy_led_hw_is_supported, +- .led_hw_control_set = mt798x_phy_led_hw_control_set, +- .led_hw_control_get = mt798x_phy_led_hw_control_get, +- }, +- { +- PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988), +- .name = "MediaTek MT7988 PHY", +- .config_init = mt798x_phy_config_init, +- .config_intr = genphy_no_config_intr, +- .handle_interrupt = genphy_handle_interrupt_no_ack, +- .probe = mt7988_phy_probe, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = mtk_socphy_read_page, +- .write_page = mtk_socphy_write_page, +- .led_blink_set = mt798x_phy_led_blink_set, +- .led_brightness_set = mt798x_phy_led_brightness_set, +- .led_hw_is_supported = mt798x_phy_led_hw_is_supported, +- .led_hw_control_set = mt798x_phy_led_hw_control_set, +- .led_hw_control_get = mt798x_phy_led_hw_control_get, +- }, +-}; +- +-module_phy_driver(mtk_socphy_driver); +- +-static struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = { +- { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) }, +- { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) }, +- { } +-}; +- +-MODULE_DESCRIPTION("MediaTek SoC Gigabit Ethernet PHY driver"); +-MODULE_AUTHOR("Daniel Golle "); +-MODULE_AUTHOR("SkyLake Huang "); +-MODULE_LICENSE("GPL"); +- +-MODULE_DEVICE_TABLE(mdio, mtk_socphy_tbl); +--- a/drivers/net/phy/mediatek-ge.c ++++ /dev/null +@@ -1,111 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0+ +-#include +-#include +-#include +- +-#define MTK_EXT_PAGE_ACCESS 0x1f +-#define MTK_PHY_PAGE_STANDARD 0x0000 +-#define MTK_PHY_PAGE_EXTENDED 0x0001 +-#define MTK_PHY_PAGE_EXTENDED_2 0x0002 +-#define MTK_PHY_PAGE_EXTENDED_3 0x0003 +-#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 +-#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 +- +-static int mtk_gephy_read_page(struct phy_device *phydev) +-{ +- return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +-} +- +-static int mtk_gephy_write_page(struct phy_device *phydev, int page) +-{ +- return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); +-} +- +-static void mtk_gephy_config_init(struct phy_device *phydev) +-{ +- /* Enable HW auto downshift */ +- phy_modify_paged(phydev, MTK_PHY_PAGE_EXTENDED, 0x14, 0, BIT(4)); +- +- /* Increase SlvDPSready time */ +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- __phy_write(phydev, 0x10, 0xafae); +- __phy_write(phydev, 0x12, 0x2f); +- __phy_write(phydev, 0x10, 0x8fae); +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); +- +- /* Adjust 100_mse_threshold */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x123, 0xffff); +- +- /* Disable mcc */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xa6, 0x300); +-} +- +-static int mt7530_phy_config_init(struct phy_device *phydev) +-{ +- mtk_gephy_config_init(phydev); +- +- /* Increase post_update_timer */ +- phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_3, 0x11, 0x4b); +- +- return 0; +-} +- +-static int mt7531_phy_config_init(struct phy_device *phydev) +-{ +- mtk_gephy_config_init(phydev); +- +- /* PHY link down power saving enable */ +- phy_set_bits(phydev, 0x17, BIT(4)); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0xc6, 0x300); +- +- /* Set TX Pair delay selection */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x13, 0x404); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x14, 0x404); +- +- return 0; +-} +- +-static struct phy_driver mtk_gephy_driver[] = { +- { +- PHY_ID_MATCH_EXACT(0x03a29412), +- .name = "MediaTek MT7530 PHY", +- .config_init = mt7530_phy_config_init, +- /* Interrupts are handled by the switch, not the PHY +- * itself. +- */ +- .config_intr = genphy_no_config_intr, +- .handle_interrupt = genphy_handle_interrupt_no_ack, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = mtk_gephy_read_page, +- .write_page = mtk_gephy_write_page, +- }, +- { +- PHY_ID_MATCH_EXACT(0x03a29441), +- .name = "MediaTek MT7531 PHY", +- .config_init = mt7531_phy_config_init, +- /* Interrupts are handled by the switch, not the PHY +- * itself. +- */ +- .config_intr = genphy_no_config_intr, +- .handle_interrupt = genphy_handle_interrupt_no_ack, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = mtk_gephy_read_page, +- .write_page = mtk_gephy_write_page, +- }, +-}; +- +-module_phy_driver(mtk_gephy_driver); +- +-static struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = { +- { PHY_ID_MATCH_EXACT(0x03a29441) }, +- { PHY_ID_MATCH_EXACT(0x03a29412) }, +- { } +-}; +- +-MODULE_DESCRIPTION("MediaTek Gigabit Ethernet PHY driver"); +-MODULE_AUTHOR("DENG, Qingfang "); +-MODULE_LICENSE("GPL"); +- +-MODULE_DEVICE_TABLE(mdio, mtk_gephy_tbl); +--- /dev/null ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -0,0 +1,1610 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MTK_GPHY_ID_MT7981 0x03a29461 ++#define MTK_GPHY_ID_MT7988 0x03a29481 ++ ++#define MTK_EXT_PAGE_ACCESS 0x1f ++#define MTK_PHY_PAGE_STANDARD 0x0000 ++#define MTK_PHY_PAGE_EXTENDED_3 0x0003 ++ ++#define MTK_PHY_LPI_REG_14 0x14 ++#define MTK_PHY_LPI_WAKE_TIMER_1000_MASK GENMASK(8, 0) ++ ++#define MTK_PHY_LPI_REG_1c 0x1c ++#define MTK_PHY_SMI_DET_ON_THRESH_MASK GENMASK(13, 8) ++ ++#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 ++#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 ++ ++#define ANALOG_INTERNAL_OPERATION_MAX_US 20 ++#define TXRESERVE_MIN 0 ++#define TXRESERVE_MAX 7 ++ ++#define MTK_PHY_ANARG_RG 0x10 ++#define MTK_PHY_TCLKOFFSET_MASK GENMASK(12, 8) ++ ++/* Registers on MDIO_MMD_VEND1 */ ++#define MTK_PHY_TXVLD_DA_RG 0x12 ++#define MTK_PHY_DA_TX_I2MPB_A_GBE_MASK GENMASK(15, 10) ++#define MTK_PHY_DA_TX_I2MPB_A_TBT_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_A2 0x16 ++#define MTK_PHY_DA_TX_I2MPB_A_HBT_MASK GENMASK(15, 10) ++#define MTK_PHY_DA_TX_I2MPB_A_TST_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_B1 0x17 ++#define MTK_PHY_DA_TX_I2MPB_B_GBE_MASK GENMASK(13, 8) ++#define MTK_PHY_DA_TX_I2MPB_B_TBT_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_B2 0x18 ++#define MTK_PHY_DA_TX_I2MPB_B_HBT_MASK GENMASK(13, 8) ++#define MTK_PHY_DA_TX_I2MPB_B_TST_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_C1 0x19 ++#define MTK_PHY_DA_TX_I2MPB_C_GBE_MASK GENMASK(13, 8) ++#define MTK_PHY_DA_TX_I2MPB_C_TBT_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_C2 0x20 ++#define MTK_PHY_DA_TX_I2MPB_C_HBT_MASK GENMASK(13, 8) ++#define MTK_PHY_DA_TX_I2MPB_C_TST_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_D1 0x21 ++#define MTK_PHY_DA_TX_I2MPB_D_GBE_MASK GENMASK(13, 8) ++#define MTK_PHY_DA_TX_I2MPB_D_TBT_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_TX_I2MPB_TEST_MODE_D2 0x22 ++#define MTK_PHY_DA_TX_I2MPB_D_HBT_MASK GENMASK(13, 8) ++#define MTK_PHY_DA_TX_I2MPB_D_TST_MASK GENMASK(5, 0) ++ ++#define MTK_PHY_RXADC_CTRL_RG7 0xc6 ++#define MTK_PHY_DA_AD_BUF_BIAS_LP_MASK GENMASK(9, 8) ++ ++#define MTK_PHY_RXADC_CTRL_RG9 0xc8 ++#define MTK_PHY_DA_RX_PSBN_TBT_MASK GENMASK(14, 12) ++#define MTK_PHY_DA_RX_PSBN_HBT_MASK GENMASK(10, 8) ++#define MTK_PHY_DA_RX_PSBN_GBE_MASK GENMASK(6, 4) ++#define MTK_PHY_DA_RX_PSBN_LP_MASK GENMASK(2, 0) ++ ++#define MTK_PHY_LDO_OUTPUT_V 0xd7 ++ ++#define MTK_PHY_RG_ANA_CAL_RG0 0xdb ++#define MTK_PHY_RG_CAL_CKINV BIT(12) ++#define MTK_PHY_RG_ANA_CALEN BIT(8) ++#define MTK_PHY_RG_ZCALEN_A BIT(0) ++ ++#define MTK_PHY_RG_ANA_CAL_RG1 0xdc ++#define MTK_PHY_RG_ZCALEN_B BIT(12) ++#define MTK_PHY_RG_ZCALEN_C BIT(8) ++#define MTK_PHY_RG_ZCALEN_D BIT(4) ++#define MTK_PHY_RG_TXVOS_CALEN BIT(0) ++ ++#define MTK_PHY_RG_ANA_CAL_RG5 0xe0 ++#define MTK_PHY_RG_REXT_TRIM_MASK GENMASK(13, 8) ++ ++#define MTK_PHY_RG_TX_FILTER 0xfe ++ ++#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120 0x120 ++#define MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK GENMASK(12, 8) ++#define MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK GENMASK(4, 0) ++ ++#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122 0x122 ++#define MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK GENMASK(7, 0) ++ ++#define MTK_PHY_RG_TESTMUX_ADC_CTRL 0x144 ++#define MTK_PHY_RG_TXEN_DIG_MASK GENMASK(5, 5) ++ ++#define MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B 0x172 ++#define MTK_PHY_CR_TX_AMP_OFFSET_A_MASK GENMASK(13, 8) ++#define MTK_PHY_CR_TX_AMP_OFFSET_B_MASK GENMASK(6, 0) ++ ++#define MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D 0x173 ++#define MTK_PHY_CR_TX_AMP_OFFSET_C_MASK GENMASK(13, 8) ++#define MTK_PHY_CR_TX_AMP_OFFSET_D_MASK GENMASK(6, 0) ++ ++#define MTK_PHY_RG_AD_CAL_COMP 0x17a ++#define MTK_PHY_AD_CAL_COMP_OUT_MASK GENMASK(8, 8) ++ ++#define MTK_PHY_RG_AD_CAL_CLK 0x17b ++#define MTK_PHY_DA_CAL_CLK BIT(0) ++ ++#define MTK_PHY_RG_AD_CALIN 0x17c ++#define MTK_PHY_DA_CALIN_FLAG BIT(0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN0_A 0x17d ++#define MTK_PHY_DASN_DAC_IN0_A_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN0_B 0x17e ++#define MTK_PHY_DASN_DAC_IN0_B_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN0_C 0x17f ++#define MTK_PHY_DASN_DAC_IN0_C_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN0_D 0x180 ++#define MTK_PHY_DASN_DAC_IN0_D_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN1_A 0x181 ++#define MTK_PHY_DASN_DAC_IN1_A_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN1_B 0x182 ++#define MTK_PHY_DASN_DAC_IN1_B_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN1_C 0x183 ++#define MTK_PHY_DASN_DAC_IN1_C_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DASN_DAC_IN1_D 0x184 ++#define MTK_PHY_DASN_DAC_IN1_D_MASK GENMASK(9, 0) ++ ++#define MTK_PHY_RG_DEV1E_REG19b 0x19b ++#define MTK_PHY_BYPASS_DSP_LPI_READY BIT(8) ++ ++#define MTK_PHY_RG_LP_IIR2_K1_L 0x22a ++#define MTK_PHY_RG_LP_IIR2_K1_U 0x22b ++#define MTK_PHY_RG_LP_IIR2_K2_L 0x22c ++#define MTK_PHY_RG_LP_IIR2_K2_U 0x22d ++#define MTK_PHY_RG_LP_IIR2_K3_L 0x22e ++#define MTK_PHY_RG_LP_IIR2_K3_U 0x22f ++#define MTK_PHY_RG_LP_IIR2_K4_L 0x230 ++#define MTK_PHY_RG_LP_IIR2_K4_U 0x231 ++#define MTK_PHY_RG_LP_IIR2_K5_L 0x232 ++#define MTK_PHY_RG_LP_IIR2_K5_U 0x233 ++ ++#define MTK_PHY_RG_DEV1E_REG234 0x234 ++#define MTK_PHY_TR_OPEN_LOOP_EN_MASK GENMASK(0, 0) ++#define MTK_PHY_LPF_X_AVERAGE_MASK GENMASK(7, 4) ++#define MTK_PHY_TR_LP_IIR_EEE_EN BIT(12) ++ ++#define MTK_PHY_RG_LPF_CNT_VAL 0x235 ++ ++#define MTK_PHY_RG_DEV1E_REG238 0x238 ++#define MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK GENMASK(8, 0) ++#define MTK_PHY_LPI_SLV_SEND_TX_EN BIT(12) ++ ++#define MTK_PHY_RG_DEV1E_REG239 0x239 ++#define MTK_PHY_LPI_SEND_LOC_TIMER_MASK GENMASK(8, 0) ++#define MTK_PHY_LPI_TXPCS_LOC_RCV BIT(12) ++ ++#define MTK_PHY_RG_DEV1E_REG27C 0x27c ++#define MTK_PHY_VGASTATE_FFE_THR_ST1_MASK GENMASK(12, 8) ++#define MTK_PHY_RG_DEV1E_REG27D 0x27d ++#define MTK_PHY_VGASTATE_FFE_THR_ST2_MASK GENMASK(4, 0) ++ ++#define MTK_PHY_RG_DEV1E_REG2C7 0x2c7 ++#define MTK_PHY_MAX_GAIN_MASK GENMASK(4, 0) ++#define MTK_PHY_MIN_GAIN_MASK GENMASK(12, 8) ++ ++#define MTK_PHY_RG_DEV1E_REG2D1 0x2d1 ++#define MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK GENMASK(7, 0) ++#define MTK_PHY_LPI_SKIP_SD_SLV_TR BIT(8) ++#define MTK_PHY_LPI_TR_READY BIT(9) ++#define MTK_PHY_LPI_VCO_EEE_STG0_EN BIT(10) ++ ++#define MTK_PHY_RG_DEV1E_REG323 0x323 ++#define MTK_PHY_EEE_WAKE_MAS_INT_DC BIT(0) ++#define MTK_PHY_EEE_WAKE_SLV_INT_DC BIT(4) ++ ++#define MTK_PHY_RG_DEV1E_REG324 0x324 ++#define MTK_PHY_SMI_DETCNT_MAX_MASK GENMASK(5, 0) ++#define MTK_PHY_SMI_DET_MAX_EN BIT(8) ++ ++#define MTK_PHY_RG_DEV1E_REG326 0x326 ++#define MTK_PHY_LPI_MODE_SD_ON BIT(0) ++#define MTK_PHY_RESET_RANDUPD_CNT BIT(1) ++#define MTK_PHY_TREC_UPDATE_ENAB_CLR BIT(2) ++#define MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF BIT(4) ++#define MTK_PHY_TR_READY_SKIP_AFE_WAKEUP BIT(5) ++ ++#define MTK_PHY_LDO_PUMP_EN_PAIRAB 0x502 ++#define MTK_PHY_LDO_PUMP_EN_PAIRCD 0x503 ++ ++#define MTK_PHY_DA_TX_R50_PAIR_A 0x53d ++#define MTK_PHY_DA_TX_R50_PAIR_B 0x53e ++#define MTK_PHY_DA_TX_R50_PAIR_C 0x53f ++#define MTK_PHY_DA_TX_R50_PAIR_D 0x540 ++ ++/* Registers on MDIO_MMD_VEND2 */ ++#define MTK_PHY_LED0_ON_CTRL 0x24 ++#define MTK_PHY_LED1_ON_CTRL 0x26 ++#define MTK_PHY_LED_ON_MASK GENMASK(6, 0) ++#define MTK_PHY_LED_ON_LINK1000 BIT(0) ++#define MTK_PHY_LED_ON_LINK100 BIT(1) ++#define MTK_PHY_LED_ON_LINK10 BIT(2) ++#define MTK_PHY_LED_ON_LINK (MTK_PHY_LED_ON_LINK10 |\ ++ MTK_PHY_LED_ON_LINK100 |\ ++ MTK_PHY_LED_ON_LINK1000) ++#define MTK_PHY_LED_ON_LINKDOWN BIT(3) ++#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */ ++#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */ ++#define MTK_PHY_LED_ON_FORCE_ON BIT(6) ++#define MTK_PHY_LED_ON_POLARITY BIT(14) ++#define MTK_PHY_LED_ON_ENABLE BIT(15) ++ ++#define MTK_PHY_LED0_BLINK_CTRL 0x25 ++#define MTK_PHY_LED1_BLINK_CTRL 0x27 ++#define MTK_PHY_LED_BLINK_1000TX BIT(0) ++#define MTK_PHY_LED_BLINK_1000RX BIT(1) ++#define MTK_PHY_LED_BLINK_100TX BIT(2) ++#define MTK_PHY_LED_BLINK_100RX BIT(3) ++#define MTK_PHY_LED_BLINK_10TX BIT(4) ++#define MTK_PHY_LED_BLINK_10RX BIT(5) ++#define MTK_PHY_LED_BLINK_RX (MTK_PHY_LED_BLINK_10RX |\ ++ MTK_PHY_LED_BLINK_100RX |\ ++ MTK_PHY_LED_BLINK_1000RX) ++#define MTK_PHY_LED_BLINK_TX (MTK_PHY_LED_BLINK_10TX |\ ++ MTK_PHY_LED_BLINK_100TX |\ ++ MTK_PHY_LED_BLINK_1000TX) ++#define MTK_PHY_LED_BLINK_COLLISION BIT(6) ++#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7) ++#define MTK_PHY_LED_BLINK_RX_IDLE_ERR BIT(8) ++#define MTK_PHY_LED_BLINK_FORCE_BLINK BIT(9) ++ ++#define MTK_PHY_LED1_DEFAULT_POLARITIES BIT(1) ++ ++#define MTK_PHY_RG_BG_RASEL 0x115 ++#define MTK_PHY_RG_BG_RASEL_MASK GENMASK(2, 0) ++ ++/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */ ++#define RG_GPIO_MISC_TPBANK0 0x6f0 ++#define RG_GPIO_MISC_TPBANK0_BOOTMODE GENMASK(11, 8) ++ ++/* These macro privides efuse parsing for internal phy. */ ++#define EFS_DA_TX_I2MPB_A(x) (((x) >> 0) & GENMASK(5, 0)) ++#define EFS_DA_TX_I2MPB_B(x) (((x) >> 6) & GENMASK(5, 0)) ++#define EFS_DA_TX_I2MPB_C(x) (((x) >> 12) & GENMASK(5, 0)) ++#define EFS_DA_TX_I2MPB_D(x) (((x) >> 18) & GENMASK(5, 0)) ++#define EFS_DA_TX_AMP_OFFSET_A(x) (((x) >> 24) & GENMASK(5, 0)) ++ ++#define EFS_DA_TX_AMP_OFFSET_B(x) (((x) >> 0) & GENMASK(5, 0)) ++#define EFS_DA_TX_AMP_OFFSET_C(x) (((x) >> 6) & GENMASK(5, 0)) ++#define EFS_DA_TX_AMP_OFFSET_D(x) (((x) >> 12) & GENMASK(5, 0)) ++#define EFS_DA_TX_R50_A(x) (((x) >> 18) & GENMASK(5, 0)) ++#define EFS_DA_TX_R50_B(x) (((x) >> 24) & GENMASK(5, 0)) ++ ++#define EFS_DA_TX_R50_C(x) (((x) >> 0) & GENMASK(5, 0)) ++#define EFS_DA_TX_R50_D(x) (((x) >> 6) & GENMASK(5, 0)) ++ ++#define EFS_RG_BG_RASEL(x) (((x) >> 4) & GENMASK(2, 0)) ++#define EFS_RG_REXT_TRIM(x) (((x) >> 7) & GENMASK(5, 0)) ++ ++enum { ++ NO_PAIR, ++ PAIR_A, ++ PAIR_B, ++ PAIR_C, ++ PAIR_D, ++}; ++ ++enum calibration_mode { ++ EFUSE_K, ++ SW_K ++}; ++ ++enum CAL_ITEM { ++ REXT, ++ TX_OFFSET, ++ TX_AMP, ++ TX_R50, ++ TX_VCM ++}; ++ ++enum CAL_MODE { ++ EFUSE_M, ++ SW_M ++}; ++ ++#define MTK_PHY_LED_STATE_FORCE_ON 0 ++#define MTK_PHY_LED_STATE_FORCE_BLINK 1 ++#define MTK_PHY_LED_STATE_NETDEV 2 ++ ++struct mtk_socphy_priv { ++ unsigned long led_state; ++}; ++ ++struct mtk_socphy_shared { ++ u32 boottrap; ++ struct mtk_socphy_priv priv[4]; ++}; ++ ++static int mtk_socphy_read_page(struct phy_device *phydev) ++{ ++ return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); ++} ++ ++static int mtk_socphy_write_page(struct phy_device *phydev, int page) ++{ ++ return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); ++} ++ ++/* One calibration cycle consists of: ++ * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high ++ * until AD_CAL_COMP is ready to output calibration result. ++ * 2.Wait until DA_CAL_CLK is available. ++ * 3.Fetch AD_CAL_COMP_OUT. ++ */ ++static int cal_cycle(struct phy_device *phydev, int devad, ++ u32 regnum, u16 mask, u16 cal_val) ++{ ++ int reg_val; ++ int ret; ++ ++ phy_modify_mmd(phydev, devad, regnum, ++ mask, cal_val); ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, ++ MTK_PHY_DA_CALIN_FLAG); ++ ++ ret = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_AD_CAL_CLK, reg_val, ++ reg_val & MTK_PHY_DA_CAL_CLK, 500, ++ ANALOG_INTERNAL_OPERATION_MAX_US, ++ false); ++ if (ret) { ++ phydev_err(phydev, "Calibration cycle timeout\n"); ++ return ret; ++ } ++ ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CALIN, ++ MTK_PHY_DA_CALIN_FLAG); ++ ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_AD_CAL_COMP); ++ if (ret < 0) ++ return ret; ++ ret = FIELD_GET(MTK_PHY_AD_CAL_COMP_OUT_MASK, ret); ++ phydev_dbg(phydev, "cal_val: 0x%x, ret: %d\n", cal_val, ret); ++ ++ return ret; ++} ++ ++static int rext_fill_result(struct phy_device *phydev, u16 *buf) ++{ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG5, ++ MTK_PHY_RG_REXT_TRIM_MASK, buf[0] << 8); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_RG_BG_RASEL, ++ MTK_PHY_RG_BG_RASEL_MASK, buf[1]); ++ ++ return 0; ++} ++ ++static int rext_cal_efuse(struct phy_device *phydev, u32 *buf) ++{ ++ u16 rext_cal_val[2]; ++ ++ rext_cal_val[0] = EFS_RG_REXT_TRIM(buf[3]); ++ rext_cal_val[1] = EFS_RG_BG_RASEL(buf[3]); ++ rext_fill_result(phydev, rext_cal_val); ++ ++ return 0; ++} ++ ++static int tx_offset_fill_result(struct phy_device *phydev, u16 *buf) ++{ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B, ++ MTK_PHY_CR_TX_AMP_OFFSET_A_MASK, buf[0] << 8); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_A_B, ++ MTK_PHY_CR_TX_AMP_OFFSET_B_MASK, buf[1]); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D, ++ MTK_PHY_CR_TX_AMP_OFFSET_C_MASK, buf[2] << 8); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_CR_TX_AMP_OFFSET_C_D, ++ MTK_PHY_CR_TX_AMP_OFFSET_D_MASK, buf[3]); ++ ++ return 0; ++} ++ ++static int tx_offset_cal_efuse(struct phy_device *phydev, u32 *buf) ++{ ++ u16 tx_offset_cal_val[4]; ++ ++ tx_offset_cal_val[0] = EFS_DA_TX_AMP_OFFSET_A(buf[0]); ++ tx_offset_cal_val[1] = EFS_DA_TX_AMP_OFFSET_B(buf[1]); ++ tx_offset_cal_val[2] = EFS_DA_TX_AMP_OFFSET_C(buf[1]); ++ tx_offset_cal_val[3] = EFS_DA_TX_AMP_OFFSET_D(buf[1]); ++ ++ tx_offset_fill_result(phydev, tx_offset_cal_val); ++ ++ return 0; ++} ++ ++static int tx_amp_fill_result(struct phy_device *phydev, u16 *buf) ++{ ++ const int vals_9481[16] = { 10, 6, 6, 10, ++ 10, 6, 6, 10, ++ 10, 6, 6, 10, ++ 10, 6, 6, 10 }; ++ const int vals_9461[16] = { 7, 1, 4, 7, ++ 7, 1, 4, 7, ++ 7, 1, 4, 7, ++ 7, 1, 4, 7 }; ++ int bias[16] = {}; ++ int i; ++ ++ switch (phydev->drv->phy_id) { ++ case MTK_GPHY_ID_MT7981: ++ /* We add some calibration to efuse values ++ * due to board level influence. ++ * GBE: +7, TBT: +1, HBT: +4, TST: +7 ++ */ ++ memcpy(bias, (const void *)vals_9461, sizeof(bias)); ++ break; ++ case MTK_GPHY_ID_MT7988: ++ memcpy(bias, (const void *)vals_9481, sizeof(bias)); ++ break; ++ } ++ ++ /* Prevent overflow */ ++ for (i = 0; i < 12; i++) { ++ if (buf[i >> 2] + bias[i] > 63) { ++ buf[i >> 2] = 63; ++ bias[i] = 0; ++ } ++ } ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, ++ MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_GBE_MASK, ++ buf[0] + bias[0])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TXVLD_DA_RG, ++ MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_TBT_MASK, ++ buf[0] + bias[1])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, ++ MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_HBT_MASK, ++ buf[0] + bias[2])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_A2, ++ MTK_PHY_DA_TX_I2MPB_A_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_A_TST_MASK, ++ buf[0] + bias[3])); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, ++ MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_GBE_MASK, ++ buf[1] + bias[4])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B1, ++ MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_TBT_MASK, ++ buf[1] + bias[5])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, ++ MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_HBT_MASK, ++ buf[1] + bias[6])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_B2, ++ MTK_PHY_DA_TX_I2MPB_B_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_B_TST_MASK, ++ buf[1] + bias[7])); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, ++ MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_GBE_MASK, ++ buf[2] + bias[8])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C1, ++ MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_TBT_MASK, ++ buf[2] + bias[9])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, ++ MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_HBT_MASK, ++ buf[2] + bias[10])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_C2, ++ MTK_PHY_DA_TX_I2MPB_C_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_C_TST_MASK, ++ buf[2] + bias[11])); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, ++ MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_GBE_MASK, ++ buf[3] + bias[12])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D1, ++ MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_TBT_MASK, ++ buf[3] + bias[13])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, ++ MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_HBT_MASK, ++ buf[3] + bias[14])); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TX_I2MPB_TEST_MODE_D2, ++ MTK_PHY_DA_TX_I2MPB_D_TST_MASK, ++ FIELD_PREP(MTK_PHY_DA_TX_I2MPB_D_TST_MASK, ++ buf[3] + bias[15])); ++ ++ return 0; ++} ++ ++static int tx_amp_cal_efuse(struct phy_device *phydev, u32 *buf) ++{ ++ u16 tx_amp_cal_val[4]; ++ ++ tx_amp_cal_val[0] = EFS_DA_TX_I2MPB_A(buf[0]); ++ tx_amp_cal_val[1] = EFS_DA_TX_I2MPB_B(buf[0]); ++ tx_amp_cal_val[2] = EFS_DA_TX_I2MPB_C(buf[0]); ++ tx_amp_cal_val[3] = EFS_DA_TX_I2MPB_D(buf[0]); ++ tx_amp_fill_result(phydev, tx_amp_cal_val); ++ ++ return 0; ++} ++ ++static int tx_r50_fill_result(struct phy_device *phydev, u16 tx_r50_cal_val, ++ u8 txg_calen_x) ++{ ++ int bias = 0; ++ u16 reg, val; ++ ++ if (phydev->drv->phy_id == MTK_GPHY_ID_MT7988) ++ bias = -1; ++ ++ val = clamp_val(bias + tx_r50_cal_val, 0, 63); ++ ++ switch (txg_calen_x) { ++ case PAIR_A: ++ reg = MTK_PHY_DA_TX_R50_PAIR_A; ++ break; ++ case PAIR_B: ++ reg = MTK_PHY_DA_TX_R50_PAIR_B; ++ break; ++ case PAIR_C: ++ reg = MTK_PHY_DA_TX_R50_PAIR_C; ++ break; ++ case PAIR_D: ++ reg = MTK_PHY_DA_TX_R50_PAIR_D; ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, reg, val | val << 8); ++ ++ return 0; ++} ++ ++static int tx_r50_cal_efuse(struct phy_device *phydev, u32 *buf, ++ u8 txg_calen_x) ++{ ++ u16 tx_r50_cal_val; ++ ++ switch (txg_calen_x) { ++ case PAIR_A: ++ tx_r50_cal_val = EFS_DA_TX_R50_A(buf[1]); ++ break; ++ case PAIR_B: ++ tx_r50_cal_val = EFS_DA_TX_R50_B(buf[1]); ++ break; ++ case PAIR_C: ++ tx_r50_cal_val = EFS_DA_TX_R50_C(buf[2]); ++ break; ++ case PAIR_D: ++ tx_r50_cal_val = EFS_DA_TX_R50_D(buf[2]); ++ break; ++ default: ++ return -EINVAL; ++ } ++ tx_r50_fill_result(phydev, tx_r50_cal_val, txg_calen_x); ++ ++ return 0; ++} ++ ++static int tx_vcm_cal_sw(struct phy_device *phydev, u8 rg_txreserve_x) ++{ ++ u8 lower_idx, upper_idx, txreserve_val; ++ u8 lower_ret, upper_ret; ++ int ret; ++ ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, ++ MTK_PHY_RG_ANA_CALEN); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, ++ MTK_PHY_RG_CAL_CKINV); ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, ++ MTK_PHY_RG_TXVOS_CALEN); ++ ++ switch (rg_txreserve_x) { ++ case PAIR_A: ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN0_A, ++ MTK_PHY_DASN_DAC_IN0_A_MASK); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN1_A, ++ MTK_PHY_DASN_DAC_IN1_A_MASK); ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_ANA_CAL_RG0, ++ MTK_PHY_RG_ZCALEN_A); ++ break; ++ case PAIR_B: ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN0_B, ++ MTK_PHY_DASN_DAC_IN0_B_MASK); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN1_B, ++ MTK_PHY_DASN_DAC_IN1_B_MASK); ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_ANA_CAL_RG1, ++ MTK_PHY_RG_ZCALEN_B); ++ break; ++ case PAIR_C: ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN0_C, ++ MTK_PHY_DASN_DAC_IN0_C_MASK); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN1_C, ++ MTK_PHY_DASN_DAC_IN1_C_MASK); ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_ANA_CAL_RG1, ++ MTK_PHY_RG_ZCALEN_C); ++ break; ++ case PAIR_D: ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN0_D, ++ MTK_PHY_DASN_DAC_IN0_D_MASK); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DASN_DAC_IN1_D, ++ MTK_PHY_DASN_DAC_IN1_D_MASK); ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_ANA_CAL_RG1, ++ MTK_PHY_RG_ZCALEN_D); ++ break; ++ default: ++ ret = -EINVAL; ++ goto restore; ++ } ++ ++ lower_idx = TXRESERVE_MIN; ++ upper_idx = TXRESERVE_MAX; ++ ++ phydev_dbg(phydev, "Start TX-VCM SW cal.\n"); ++ while ((upper_idx - lower_idx) > 1) { ++ txreserve_val = DIV_ROUND_CLOSEST(lower_idx + upper_idx, 2); ++ ret = cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, ++ MTK_PHY_DA_RX_PSBN_TBT_MASK | ++ MTK_PHY_DA_RX_PSBN_HBT_MASK | ++ MTK_PHY_DA_RX_PSBN_GBE_MASK | ++ MTK_PHY_DA_RX_PSBN_LP_MASK, ++ txreserve_val << 12 | txreserve_val << 8 | ++ txreserve_val << 4 | txreserve_val); ++ if (ret == 1) { ++ upper_idx = txreserve_val; ++ upper_ret = ret; ++ } else if (ret == 0) { ++ lower_idx = txreserve_val; ++ lower_ret = ret; ++ } else { ++ goto restore; ++ } ++ } ++ ++ if (lower_idx == TXRESERVE_MIN) { ++ lower_ret = cal_cycle(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RXADC_CTRL_RG9, ++ MTK_PHY_DA_RX_PSBN_TBT_MASK | ++ MTK_PHY_DA_RX_PSBN_HBT_MASK | ++ MTK_PHY_DA_RX_PSBN_GBE_MASK | ++ MTK_PHY_DA_RX_PSBN_LP_MASK, ++ lower_idx << 12 | lower_idx << 8 | ++ lower_idx << 4 | lower_idx); ++ ret = lower_ret; ++ } else if (upper_idx == TXRESERVE_MAX) { ++ upper_ret = cal_cycle(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RXADC_CTRL_RG9, ++ MTK_PHY_DA_RX_PSBN_TBT_MASK | ++ MTK_PHY_DA_RX_PSBN_HBT_MASK | ++ MTK_PHY_DA_RX_PSBN_GBE_MASK | ++ MTK_PHY_DA_RX_PSBN_LP_MASK, ++ upper_idx << 12 | upper_idx << 8 | ++ upper_idx << 4 | upper_idx); ++ ret = upper_ret; ++ } ++ if (ret < 0) ++ goto restore; ++ ++ /* We calibrate TX-VCM in different logic. Check upper index and then ++ * lower index. If this calibration is valid, apply lower index's ++ * result. ++ */ ++ ret = upper_ret - lower_ret; ++ if (ret == 1) { ++ ret = 0; ++ /* Make sure we use upper_idx in our calibration system */ ++ cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, ++ MTK_PHY_DA_RX_PSBN_TBT_MASK | ++ MTK_PHY_DA_RX_PSBN_HBT_MASK | ++ MTK_PHY_DA_RX_PSBN_GBE_MASK | ++ MTK_PHY_DA_RX_PSBN_LP_MASK, ++ upper_idx << 12 | upper_idx << 8 | ++ upper_idx << 4 | upper_idx); ++ phydev_dbg(phydev, "TX-VCM SW cal result: 0x%x\n", upper_idx); ++ } else if (lower_idx == TXRESERVE_MIN && upper_ret == 1 && ++ lower_ret == 1) { ++ ret = 0; ++ cal_cycle(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG9, ++ MTK_PHY_DA_RX_PSBN_TBT_MASK | ++ MTK_PHY_DA_RX_PSBN_HBT_MASK | ++ MTK_PHY_DA_RX_PSBN_GBE_MASK | ++ MTK_PHY_DA_RX_PSBN_LP_MASK, ++ lower_idx << 12 | lower_idx << 8 | ++ lower_idx << 4 | lower_idx); ++ phydev_warn(phydev, "TX-VCM SW cal result at low margin 0x%x\n", ++ lower_idx); ++ } else if (upper_idx == TXRESERVE_MAX && upper_ret == 0 && ++ lower_ret == 0) { ++ ret = 0; ++ phydev_warn(phydev, ++ "TX-VCM SW cal result at high margin 0x%x\n", ++ upper_idx); ++ } else { ++ ret = -EINVAL; ++ } ++ ++restore: ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, ++ MTK_PHY_RG_ANA_CALEN); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, ++ MTK_PHY_RG_TXVOS_CALEN); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG0, ++ MTK_PHY_RG_ZCALEN_A); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_ANA_CAL_RG1, ++ MTK_PHY_RG_ZCALEN_B | MTK_PHY_RG_ZCALEN_C | ++ MTK_PHY_RG_ZCALEN_D); ++ ++ return ret; ++} ++ ++static void mt798x_phy_common_finetune(struct phy_device *phydev) ++{ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); ++ /* SlvDSPreadyTime = 24, MasDSPreadyTime = 24 */ ++ __phy_write(phydev, 0x11, 0xc71); ++ __phy_write(phydev, 0x12, 0xc); ++ __phy_write(phydev, 0x10, 0x8fae); ++ ++ /* EnabRandUpdTrig = 1 */ ++ __phy_write(phydev, 0x11, 0x2f00); ++ __phy_write(phydev, 0x12, 0xe); ++ __phy_write(phydev, 0x10, 0x8fb0); ++ ++ /* NormMseLoThresh = 85 */ ++ __phy_write(phydev, 0x11, 0x55a0); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x83aa); ++ ++ /* FfeUpdGainForce = 1(Enable), FfeUpdGainForceVal = 4 */ ++ __phy_write(phydev, 0x11, 0x240); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x9680); ++ ++ /* TrFreeze = 0 (mt7988 default) */ ++ __phy_write(phydev, 0x11, 0x0); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x9686); ++ ++ /* SSTrKp100 = 5 */ ++ /* SSTrKf100 = 6 */ ++ /* SSTrKp1000Mas = 5 */ ++ /* SSTrKf1000Mas = 6 */ ++ /* SSTrKp1000Slv = 5 */ ++ /* SSTrKf1000Slv = 6 */ ++ __phy_write(phydev, 0x11, 0xbaef); ++ __phy_write(phydev, 0x12, 0x2e); ++ __phy_write(phydev, 0x10, 0x968c); ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++} ++ ++static void mt7981_phy_finetune(struct phy_device *phydev) ++{ ++ u16 val[8] = { 0x01ce, 0x01c1, ++ 0x020f, 0x0202, ++ 0x03d0, 0x03c0, ++ 0x0013, 0x0005 }; ++ int i, k; ++ ++ /* 100M eye finetune: ++ * Keep middle level of TX MLT3 shapper as default. ++ * Only change TX MLT3 overshoot level here. ++ */ ++ for (k = 0, i = 1; i < 12; i++) { ++ if (i % 3 == 0) ++ continue; ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[k++]); ++ } ++ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); ++ /* ResetSyncOffset = 6 */ ++ __phy_write(phydev, 0x11, 0x600); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x8fc0); ++ ++ /* VgaDecRate = 1 */ ++ __phy_write(phydev, 0x11, 0x4c2a); ++ __phy_write(phydev, 0x12, 0x3e); ++ __phy_write(phydev, 0x10, 0x8fa4); ++ ++ /* MrvlTrFix100Kp = 3, MrvlTrFix100Kf = 2, ++ * MrvlTrFix1000Kp = 3, MrvlTrFix1000Kf = 2 ++ */ ++ __phy_write(phydev, 0x11, 0xd10a); ++ __phy_write(phydev, 0x12, 0x34); ++ __phy_write(phydev, 0x10, 0x8f82); ++ ++ /* VcoSlicerThreshBitsHigh */ ++ __phy_write(phydev, 0x11, 0x5555); ++ __phy_write(phydev, 0x12, 0x55); ++ __phy_write(phydev, 0x10, 0x8ec0); ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++ ++ /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 9 */ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, ++ MTK_PHY_TR_OPEN_LOOP_EN_MASK | ++ MTK_PHY_LPF_X_AVERAGE_MASK, ++ BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0x9)); ++ ++ /* rg_tr_lpf_cnt_val = 512 */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x200); ++ ++ /* IIR2 related */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_L, 0x82); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K1_U, 0x0); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_L, 0x103); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K2_U, 0x0); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_L, 0x82); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K3_U, 0x0); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_L, 0xd177); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K4_U, 0x3); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_L, 0x2c82); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LP_IIR2_K5_U, 0xe); ++ ++ /* FFE peaking */ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27C, ++ MTK_PHY_VGASTATE_FFE_THR_ST1_MASK, 0x1b << 8); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG27D, ++ MTK_PHY_VGASTATE_FFE_THR_ST2_MASK, 0x1e); ++ ++ /* Disable LDO pump */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRAB, 0x0); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_PUMP_EN_PAIRCD, 0x0); ++ /* Adjust LDO output voltage */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_LDO_OUTPUT_V, 0x2222); ++} ++ ++static void mt7988_phy_finetune(struct phy_device *phydev) ++{ ++ u16 val[12] = { 0x0187, 0x01cd, 0x01c8, 0x0182, ++ 0x020d, 0x0206, 0x0384, 0x03d0, ++ 0x03c6, 0x030a, 0x0011, 0x0005 }; ++ int i; ++ ++ /* Set default MLT3 shaper first */ ++ for (i = 0; i < 12; i++) ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, i, val[i]); ++ ++ /* TCT finetune */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_TX_FILTER, 0x5); ++ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); ++ /* ResetSyncOffset = 5 */ ++ __phy_write(phydev, 0x11, 0x500); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x8fc0); ++ ++ /* VgaDecRate is 1 at default on mt7988 */ ++ ++ /* MrvlTrFix100Kp = 6, MrvlTrFix100Kf = 7, ++ * MrvlTrFix1000Kp = 6, MrvlTrFix1000Kf = 7 ++ */ ++ __phy_write(phydev, 0x11, 0xb90a); ++ __phy_write(phydev, 0x12, 0x6f); ++ __phy_write(phydev, 0x10, 0x8f82); ++ ++ /* RemAckCntLimitCtrl = 1 */ ++ __phy_write(phydev, 0x11, 0xfbba); ++ __phy_write(phydev, 0x12, 0xc3); ++ __phy_write(phydev, 0x10, 0x87f8); ++ ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++ ++ /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 10 */ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG234, ++ MTK_PHY_TR_OPEN_LOOP_EN_MASK | ++ MTK_PHY_LPF_X_AVERAGE_MASK, ++ BIT(0) | FIELD_PREP(MTK_PHY_LPF_X_AVERAGE_MASK, 0xa)); ++ ++ /* rg_tr_lpf_cnt_val = 1023 */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_LPF_CNT_VAL, 0x3ff); ++} ++ ++static void mt798x_phy_eee(struct phy_device *phydev) ++{ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG120, ++ MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK | ++ MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK, ++ FIELD_PREP(MTK_PHY_LPI_SIG_EN_LO_THRESH1000_MASK, 0x0) | ++ FIELD_PREP(MTK_PHY_LPI_SIG_EN_HI_THRESH1000_MASK, 0x14)); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122, ++ MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, ++ FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, ++ 0xff)); ++ ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_TESTMUX_ADC_CTRL, ++ MTK_PHY_RG_TXEN_DIG_MASK); ++ ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DEV1E_REG19b, MTK_PHY_BYPASS_DSP_LPI_READY); ++ ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_DEV1E_REG234, MTK_PHY_TR_LP_IIR_EEE_EN); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG238, ++ MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK | ++ MTK_PHY_LPI_SLV_SEND_TX_EN, ++ FIELD_PREP(MTK_PHY_LPI_SLV_SEND_TX_TIMER_MASK, 0x120)); ++ ++ /* Keep MTK_PHY_LPI_SEND_LOC_TIMER as 375 */ ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG239, ++ MTK_PHY_LPI_TXPCS_LOC_RCV); ++ ++ /* This also fixes some IoT issues, such as CH340 */ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2C7, ++ MTK_PHY_MAX_GAIN_MASK | MTK_PHY_MIN_GAIN_MASK, ++ FIELD_PREP(MTK_PHY_MAX_GAIN_MASK, 0x8) | ++ FIELD_PREP(MTK_PHY_MIN_GAIN_MASK, 0x13)); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG2D1, ++ MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK, ++ FIELD_PREP(MTK_PHY_VCO_SLICER_THRESH_BITS_HIGH_EEE_MASK, ++ 0x33) | ++ MTK_PHY_LPI_SKIP_SD_SLV_TR | MTK_PHY_LPI_TR_READY | ++ MTK_PHY_LPI_VCO_EEE_STG0_EN); ++ ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG323, ++ MTK_PHY_EEE_WAKE_MAS_INT_DC | ++ MTK_PHY_EEE_WAKE_SLV_INT_DC); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG324, ++ MTK_PHY_SMI_DETCNT_MAX_MASK, ++ FIELD_PREP(MTK_PHY_SMI_DETCNT_MAX_MASK, 0x3f) | ++ MTK_PHY_SMI_DET_MAX_EN); ++ ++ phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_DEV1E_REG326, ++ MTK_PHY_LPI_MODE_SD_ON | MTK_PHY_RESET_RANDUPD_CNT | ++ MTK_PHY_TREC_UPDATE_ENAB_CLR | ++ MTK_PHY_LPI_QUIT_WAIT_DFE_SIG_DET_OFF | ++ MTK_PHY_TR_READY_SKIP_AFE_WAKEUP); ++ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); ++ /* Regsigdet_sel_1000 = 0 */ ++ __phy_write(phydev, 0x11, 0xb); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x9690); ++ ++ /* REG_EEE_st2TrKf1000 = 2 */ ++ __phy_write(phydev, 0x11, 0x114f); ++ __phy_write(phydev, 0x12, 0x2); ++ __phy_write(phydev, 0x10, 0x969a); ++ ++ /* RegEEE_slv_wake_tr_timer_tar = 6, RegEEE_slv_remtx_timer_tar = 20 */ ++ __phy_write(phydev, 0x11, 0x3028); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x969e); ++ ++ /* RegEEE_slv_wake_int_timer_tar = 8 */ ++ __phy_write(phydev, 0x11, 0x5010); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x96a0); ++ ++ /* RegEEE_trfreeze_timer2 = 586 */ ++ __phy_write(phydev, 0x11, 0x24a); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x96a8); ++ ++ /* RegEEE100Stg1_tar = 16 */ ++ __phy_write(phydev, 0x11, 0x3210); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x96b8); ++ ++ /* REGEEE_wake_slv_tr_wait_dfesigdet_en = 0 */ ++ __phy_write(phydev, 0x11, 0x1463); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x96ca); ++ ++ /* DfeTailEnableVgaThresh1000 = 27 */ ++ __phy_write(phydev, 0x11, 0x36); ++ __phy_write(phydev, 0x12, 0x0); ++ __phy_write(phydev, 0x10, 0x8f80); ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3); ++ __phy_modify(phydev, MTK_PHY_LPI_REG_14, ++ MTK_PHY_LPI_WAKE_TIMER_1000_MASK, ++ FIELD_PREP(MTK_PHY_LPI_WAKE_TIMER_1000_MASK, 0x19c)); ++ ++ __phy_modify(phydev, MTK_PHY_LPI_REG_1c, MTK_PHY_SMI_DET_ON_THRESH_MASK, ++ FIELD_PREP(MTK_PHY_SMI_DET_ON_THRESH_MASK, 0xc)); ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG122, ++ MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, ++ FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH1000_MASK, ++ 0xff)); ++} ++ ++static int cal_sw(struct phy_device *phydev, enum CAL_ITEM cal_item, ++ u8 start_pair, u8 end_pair) ++{ ++ u8 pair_n; ++ int ret; ++ ++ for (pair_n = start_pair; pair_n <= end_pair; pair_n++) { ++ /* TX_OFFSET & TX_AMP have no SW calibration. */ ++ switch (cal_item) { ++ case TX_VCM: ++ ret = tx_vcm_cal_sw(phydev, pair_n); ++ break; ++ default: ++ return -EINVAL; ++ } ++ if (ret) ++ return ret; ++ } ++ return 0; ++} ++ ++static int cal_efuse(struct phy_device *phydev, enum CAL_ITEM cal_item, ++ u8 start_pair, u8 end_pair, u32 *buf) ++{ ++ u8 pair_n; ++ int ret; ++ ++ for (pair_n = start_pair; pair_n <= end_pair; pair_n++) { ++ /* TX_VCM has no efuse calibration. */ ++ switch (cal_item) { ++ case REXT: ++ ret = rext_cal_efuse(phydev, buf); ++ break; ++ case TX_OFFSET: ++ ret = tx_offset_cal_efuse(phydev, buf); ++ break; ++ case TX_AMP: ++ ret = tx_amp_cal_efuse(phydev, buf); ++ break; ++ case TX_R50: ++ ret = tx_r50_cal_efuse(phydev, buf, pair_n); ++ break; ++ default: ++ return -EINVAL; ++ } ++ if (ret) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int start_cal(struct phy_device *phydev, enum CAL_ITEM cal_item, ++ enum CAL_MODE cal_mode, u8 start_pair, ++ u8 end_pair, u32 *buf) ++{ ++ int ret; ++ ++ switch (cal_mode) { ++ case EFUSE_M: ++ ret = cal_efuse(phydev, cal_item, start_pair, ++ end_pair, buf); ++ break; ++ case SW_M: ++ ret = cal_sw(phydev, cal_item, start_pair, end_pair); ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ if (ret) { ++ phydev_err(phydev, "cal %d failed\n", cal_item); ++ return -EIO; ++ } ++ ++ return 0; ++} ++ ++static int mt798x_phy_calibration(struct phy_device *phydev) ++{ ++ struct nvmem_cell *cell; ++ int ret = 0; ++ size_t len; ++ u32 *buf; ++ ++ cell = nvmem_cell_get(&phydev->mdio.dev, "phy-cal-data"); ++ if (IS_ERR(cell)) { ++ if (PTR_ERR(cell) == -EPROBE_DEFER) ++ return PTR_ERR(cell); ++ return 0; ++ } ++ ++ buf = (u32 *)nvmem_cell_read(cell, &len); ++ if (IS_ERR(buf)) ++ return PTR_ERR(buf); ++ nvmem_cell_put(cell); ++ ++ if (!buf[0] || !buf[1] || !buf[2] || !buf[3] || len < 4 * sizeof(u32)) { ++ phydev_err(phydev, "invalid efuse data\n"); ++ ret = -EINVAL; ++ goto out; ++ } ++ ++ ret = start_cal(phydev, REXT, EFUSE_M, NO_PAIR, NO_PAIR, buf); ++ if (ret) ++ goto out; ++ ret = start_cal(phydev, TX_OFFSET, EFUSE_M, NO_PAIR, NO_PAIR, buf); ++ if (ret) ++ goto out; ++ ret = start_cal(phydev, TX_AMP, EFUSE_M, NO_PAIR, NO_PAIR, buf); ++ if (ret) ++ goto out; ++ ret = start_cal(phydev, TX_R50, EFUSE_M, PAIR_A, PAIR_D, buf); ++ if (ret) ++ goto out; ++ ret = start_cal(phydev, TX_VCM, SW_M, PAIR_A, PAIR_A, buf); ++ if (ret) ++ goto out; ++ ++out: ++ kfree(buf); ++ return ret; ++} ++ ++static int mt798x_phy_config_init(struct phy_device *phydev) ++{ ++ switch (phydev->drv->phy_id) { ++ case MTK_GPHY_ID_MT7981: ++ mt7981_phy_finetune(phydev); ++ break; ++ case MTK_GPHY_ID_MT7988: ++ mt7988_phy_finetune(phydev); ++ break; ++ } ++ ++ mt798x_phy_common_finetune(phydev); ++ mt798x_phy_eee(phydev); ++ ++ return mt798x_phy_calibration(phydev); ++} ++ ++static int mt798x_phy_hw_led_on_set(struct phy_device *phydev, u8 index, ++ bool on) ++{ ++ unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ bool changed; ++ ++ if (on) ++ changed = !test_and_set_bit(bit_on, &priv->led_state); ++ else ++ changed = !!test_and_clear_bit(bit_on, &priv->led_state); ++ ++ changed |= !!test_and_clear_bit(MTK_PHY_LED_STATE_NETDEV + ++ (index ? 16 : 0), &priv->led_state); ++ if (changed) ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_ON_CTRL : ++ MTK_PHY_LED0_ON_CTRL, ++ MTK_PHY_LED_ON_MASK, ++ on ? MTK_PHY_LED_ON_FORCE_ON : 0); ++ else ++ return 0; ++} ++ ++static int mt798x_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, ++ bool blinking) ++{ ++ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + ++ (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ bool changed; ++ ++ if (blinking) ++ changed = !test_and_set_bit(bit_blink, &priv->led_state); ++ else ++ changed = !!test_and_clear_bit(bit_blink, &priv->led_state); ++ ++ changed |= !!test_bit(MTK_PHY_LED_STATE_NETDEV + ++ (index ? 16 : 0), &priv->led_state); ++ if (changed) ++ return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL, ++ blinking ? ++ MTK_PHY_LED_BLINK_FORCE_BLINK : 0); ++ else ++ return 0; ++} ++ ++static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index, ++ unsigned long *delay_on, ++ unsigned long *delay_off) ++{ ++ bool blinking = false; ++ int err = 0; ++ ++ if (index > 1) ++ return -EINVAL; ++ ++ if (delay_on && delay_off && (*delay_on > 0) && (*delay_off > 0)) { ++ blinking = true; ++ *delay_on = 50; ++ *delay_off = 50; ++ } ++ ++ err = mt798x_phy_hw_led_blink_set(phydev, index, blinking); ++ if (err) ++ return err; ++ ++ return mt798x_phy_hw_led_on_set(phydev, index, false); ++} ++ ++static int mt798x_phy_led_brightness_set(struct phy_device *phydev, ++ u8 index, enum led_brightness value) ++{ ++ int err; ++ ++ err = mt798x_phy_hw_led_blink_set(phydev, index, false); ++ if (err) ++ return err; ++ ++ return mt798x_phy_hw_led_on_set(phydev, index, (value != LED_OFF)); ++} ++ ++static const unsigned long supported_triggers = ++ BIT(TRIGGER_NETDEV_FULL_DUPLEX) | ++ BIT(TRIGGER_NETDEV_HALF_DUPLEX) | ++ BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX); ++ ++static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ if (index > 1) ++ return -EINVAL; ++ ++ /* All combinations of the supported triggers are allowed */ ++ if (rules & ~supported_triggers) ++ return -EOPNOTSUPP; ++ ++ return 0; ++}; ++ ++static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + ++ (index ? 16 : 0); ++ unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); ++ unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ int on, blink; ++ ++ if (index > 1) ++ return -EINVAL; ++ ++ on = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ index ? MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL); ++ ++ if (on < 0) ++ return -EIO; ++ ++ blink = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ index ? MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL); ++ if (blink < 0) ++ return -EIO; ++ ++ if ((on & (MTK_PHY_LED_ON_LINK | MTK_PHY_LED_ON_FDX | ++ MTK_PHY_LED_ON_HDX | MTK_PHY_LED_ON_LINKDOWN)) || ++ (blink & (MTK_PHY_LED_BLINK_RX | MTK_PHY_LED_BLINK_TX))) ++ set_bit(bit_netdev, &priv->led_state); ++ else ++ clear_bit(bit_netdev, &priv->led_state); ++ ++ if (on & MTK_PHY_LED_ON_FORCE_ON) ++ set_bit(bit_on, &priv->led_state); ++ else ++ clear_bit(bit_on, &priv->led_state); ++ ++ if (blink & MTK_PHY_LED_BLINK_FORCE_BLINK) ++ set_bit(bit_blink, &priv->led_state); ++ else ++ clear_bit(bit_blink, &priv->led_state); ++ ++ if (!rules) ++ return 0; ++ ++ if (on & MTK_PHY_LED_ON_LINK) ++ *rules |= BIT(TRIGGER_NETDEV_LINK); ++ ++ if (on & MTK_PHY_LED_ON_LINK10) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_10); ++ ++ if (on & MTK_PHY_LED_ON_LINK100) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_100); ++ ++ if (on & MTK_PHY_LED_ON_LINK1000) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_1000); ++ ++ if (on & MTK_PHY_LED_ON_FDX) ++ *rules |= BIT(TRIGGER_NETDEV_FULL_DUPLEX); ++ ++ if (on & MTK_PHY_LED_ON_HDX) ++ *rules |= BIT(TRIGGER_NETDEV_HALF_DUPLEX); ++ ++ if (blink & MTK_PHY_LED_BLINK_RX) ++ *rules |= BIT(TRIGGER_NETDEV_RX); ++ ++ if (blink & MTK_PHY_LED_BLINK_TX) ++ *rules |= BIT(TRIGGER_NETDEV_TX); ++ ++ return 0; ++}; ++ ++static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ u16 on = 0, blink = 0; ++ int ret; ++ ++ if (index > 1) ++ return -EINVAL; ++ ++ if (rules & BIT(TRIGGER_NETDEV_FULL_DUPLEX)) ++ on |= MTK_PHY_LED_ON_FDX; ++ ++ if (rules & BIT(TRIGGER_NETDEV_HALF_DUPLEX)) ++ on |= MTK_PHY_LED_ON_HDX; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK10; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK100; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_1000) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK1000; ++ ++ if (rules & BIT(TRIGGER_NETDEV_RX)) { ++ blink |= (on & MTK_PHY_LED_ON_LINK) ? ++ (((on & MTK_PHY_LED_ON_LINK10) ? ++ MTK_PHY_LED_BLINK_10RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK100) ? ++ MTK_PHY_LED_BLINK_100RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK1000) ? ++ MTK_PHY_LED_BLINK_1000RX : 0)) : ++ MTK_PHY_LED_BLINK_RX; ++ } ++ ++ if (rules & BIT(TRIGGER_NETDEV_TX)) { ++ blink |= (on & MTK_PHY_LED_ON_LINK) ? ++ (((on & MTK_PHY_LED_ON_LINK10) ? ++ MTK_PHY_LED_BLINK_10TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK100) ? ++ MTK_PHY_LED_BLINK_100TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK1000) ? ++ MTK_PHY_LED_BLINK_1000TX : 0)) : ++ MTK_PHY_LED_BLINK_TX; ++ } ++ ++ if (blink || on) ++ set_bit(bit_netdev, &priv->led_state); ++ else ++ clear_bit(bit_netdev, &priv->led_state); ++ ++ ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_ON_CTRL : ++ MTK_PHY_LED0_ON_CTRL, ++ MTK_PHY_LED_ON_FDX | ++ MTK_PHY_LED_ON_HDX | ++ MTK_PHY_LED_ON_LINK, ++ on); ++ ++ if (ret) ++ return ret; ++ ++ return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL, blink); ++}; ++ ++static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num) ++{ ++ struct mtk_socphy_shared *priv = phydev->shared->priv; ++ u32 polarities; ++ ++ if (led_num == 0) ++ polarities = ~(priv->boottrap); ++ else ++ polarities = MTK_PHY_LED1_DEFAULT_POLARITIES; ++ ++ if (polarities & BIT(phydev->mdio.addr)) ++ return true; ++ ++ return false; ++} ++ ++static int mt7988_phy_fix_leds_polarities(struct phy_device *phydev) ++{ ++ struct pinctrl *pinctrl; ++ int index; ++ ++ /* Setup LED polarity according to bootstrap use of LED pins */ ++ for (index = 0; index < 2; ++index) ++ phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL, ++ MTK_PHY_LED_ON_POLARITY, ++ mt7988_phy_led_get_polarity(phydev, index) ? ++ MTK_PHY_LED_ON_POLARITY : 0); ++ ++ /* Only now setup pinctrl to avoid bogus blinking */ ++ pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led"); ++ if (IS_ERR(pinctrl)) ++ dev_err(&phydev->mdio.bus->dev, ++ "Failed to setup PHY LED pinctrl\n"); ++ ++ return 0; ++} ++ ++static int mt7988_phy_probe_shared(struct phy_device *phydev) ++{ ++ struct device_node *np = dev_of_node(&phydev->mdio.bus->dev); ++ struct mtk_socphy_shared *shared = phydev->shared->priv; ++ struct regmap *regmap; ++ u32 reg; ++ int ret; ++ ++ /* The LED0 of the 4 PHYs in MT7988 are wired to SoC pins LED_A, LED_B, ++ * LED_C and LED_D respectively. At the same time those pins are used to ++ * bootstrap configuration of the reference clock source (LED_A), ++ * DRAM DDRx16b x2/x1 (LED_B) and boot device (LED_C, LED_D). ++ * In practice this is done using a LED and a resistor pulling the pin ++ * either to GND or to VIO. ++ * The detected value at boot time is accessible at run-time using the ++ * TPBANK0 register located in the gpio base of the pinctrl, in order ++ * to read it here it needs to be referenced by a phandle called ++ * 'mediatek,pio' in the MDIO bus hosting the PHY. ++ * The 4 bits in TPBANK0 are kept as package shared data and are used to ++ * set LED polarity for each of the LED0. ++ */ ++ regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,pio"); ++ if (IS_ERR(regmap)) ++ return PTR_ERR(regmap); ++ ++ ret = regmap_read(regmap, RG_GPIO_MISC_TPBANK0, ®); ++ if (ret) ++ return ret; ++ ++ shared->boottrap = FIELD_GET(RG_GPIO_MISC_TPBANK0_BOOTMODE, reg); ++ ++ return 0; ++} ++ ++static void mt798x_phy_leds_state_init(struct phy_device *phydev) ++{ ++ int i; ++ ++ for (i = 0; i < 2; ++i) ++ mt798x_phy_led_hw_control_get(phydev, i, NULL); ++} ++ ++static int mt7988_phy_probe(struct phy_device *phydev) ++{ ++ struct mtk_socphy_shared *shared; ++ struct mtk_socphy_priv *priv; ++ int err; ++ ++ if (phydev->mdio.addr > 3) ++ return -EINVAL; ++ ++ err = devm_phy_package_join(&phydev->mdio.dev, phydev, 0, ++ sizeof(struct mtk_socphy_shared)); ++ if (err) ++ return err; ++ ++ if (phy_package_probe_once(phydev)) { ++ err = mt7988_phy_probe_shared(phydev); ++ if (err) ++ return err; ++ } ++ ++ shared = phydev->shared->priv; ++ priv = &shared->priv[phydev->mdio.addr]; ++ ++ phydev->priv = priv; ++ ++ mt798x_phy_leds_state_init(phydev); ++ ++ err = mt7988_phy_fix_leds_polarities(phydev); ++ if (err) ++ return err; ++ ++ /* Disable TX power saving at probing to: ++ * 1. Meet common mode compliance test criteria ++ * 2. Make sure that TX-VCM calibration works fine ++ */ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG7, ++ MTK_PHY_DA_AD_BUF_BIAS_LP_MASK, 0x3 << 8); ++ ++ return mt798x_phy_calibration(phydev); ++} ++ ++static int mt7981_phy_probe(struct phy_device *phydev) ++{ ++ struct mtk_socphy_priv *priv; ++ ++ priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct mtk_socphy_priv), ++ GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ phydev->priv = priv; ++ ++ mt798x_phy_leds_state_init(phydev); ++ ++ return mt798x_phy_calibration(phydev); ++} ++ ++static struct phy_driver mtk_socphy_driver[] = { ++ { ++ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981), ++ .name = "MediaTek MT7981 PHY", ++ .config_init = mt798x_phy_config_init, ++ .config_intr = genphy_no_config_intr, ++ .handle_interrupt = genphy_handle_interrupt_no_ack, ++ .probe = mt7981_phy_probe, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = mtk_socphy_read_page, ++ .write_page = mtk_socphy_write_page, ++ .led_blink_set = mt798x_phy_led_blink_set, ++ .led_brightness_set = mt798x_phy_led_brightness_set, ++ .led_hw_is_supported = mt798x_phy_led_hw_is_supported, ++ .led_hw_control_set = mt798x_phy_led_hw_control_set, ++ .led_hw_control_get = mt798x_phy_led_hw_control_get, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988), ++ .name = "MediaTek MT7988 PHY", ++ .config_init = mt798x_phy_config_init, ++ .config_intr = genphy_no_config_intr, ++ .handle_interrupt = genphy_handle_interrupt_no_ack, ++ .probe = mt7988_phy_probe, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = mtk_socphy_read_page, ++ .write_page = mtk_socphy_write_page, ++ .led_blink_set = mt798x_phy_led_blink_set, ++ .led_brightness_set = mt798x_phy_led_brightness_set, ++ .led_hw_is_supported = mt798x_phy_led_hw_is_supported, ++ .led_hw_control_set = mt798x_phy_led_hw_control_set, ++ .led_hw_control_get = mt798x_phy_led_hw_control_get, ++ }, ++}; ++ ++module_phy_driver(mtk_socphy_driver); ++ ++static struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = { ++ { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) }, ++ { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) }, ++ { } ++}; ++ ++MODULE_DESCRIPTION("MediaTek SoC Gigabit Ethernet PHY driver"); ++MODULE_AUTHOR("Daniel Golle "); ++MODULE_AUTHOR("SkyLake Huang "); ++MODULE_LICENSE("GPL"); ++ ++MODULE_DEVICE_TABLE(mdio, mtk_socphy_tbl); +--- /dev/null ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -0,0 +1,111 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++#include ++#include ++#include ++ ++#define MTK_EXT_PAGE_ACCESS 0x1f ++#define MTK_PHY_PAGE_STANDARD 0x0000 ++#define MTK_PHY_PAGE_EXTENDED 0x0001 ++#define MTK_PHY_PAGE_EXTENDED_2 0x0002 ++#define MTK_PHY_PAGE_EXTENDED_3 0x0003 ++#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 ++#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 ++ ++static int mtk_gephy_read_page(struct phy_device *phydev) ++{ ++ return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); ++} ++ ++static int mtk_gephy_write_page(struct phy_device *phydev, int page) ++{ ++ return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); ++} ++ ++static void mtk_gephy_config_init(struct phy_device *phydev) ++{ ++ /* Enable HW auto downshift */ ++ phy_modify_paged(phydev, MTK_PHY_PAGE_EXTENDED, 0x14, 0, BIT(4)); ++ ++ /* Increase SlvDPSready time */ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); ++ __phy_write(phydev, 0x10, 0xafae); ++ __phy_write(phydev, 0x12, 0x2f); ++ __phy_write(phydev, 0x10, 0x8fae); ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++ ++ /* Adjust 100_mse_threshold */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x123, 0xffff); ++ ++ /* Disable mcc */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xa6, 0x300); ++} ++ ++static int mt7530_phy_config_init(struct phy_device *phydev) ++{ ++ mtk_gephy_config_init(phydev); ++ ++ /* Increase post_update_timer */ ++ phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_3, 0x11, 0x4b); ++ ++ return 0; ++} ++ ++static int mt7531_phy_config_init(struct phy_device *phydev) ++{ ++ mtk_gephy_config_init(phydev); ++ ++ /* PHY link down power saving enable */ ++ phy_set_bits(phydev, 0x17, BIT(4)); ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0xc6, 0x300); ++ ++ /* Set TX Pair delay selection */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x13, 0x404); ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x14, 0x404); ++ ++ return 0; ++} ++ ++static struct phy_driver mtk_gephy_driver[] = { ++ { ++ PHY_ID_MATCH_EXACT(0x03a29412), ++ .name = "MediaTek MT7530 PHY", ++ .config_init = mt7530_phy_config_init, ++ /* Interrupts are handled by the switch, not the PHY ++ * itself. ++ */ ++ .config_intr = genphy_no_config_intr, ++ .handle_interrupt = genphy_handle_interrupt_no_ack, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = mtk_gephy_read_page, ++ .write_page = mtk_gephy_write_page, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(0x03a29441), ++ .name = "MediaTek MT7531 PHY", ++ .config_init = mt7531_phy_config_init, ++ /* Interrupts are handled by the switch, not the PHY ++ * itself. ++ */ ++ .config_intr = genphy_no_config_intr, ++ .handle_interrupt = genphy_handle_interrupt_no_ack, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = mtk_gephy_read_page, ++ .write_page = mtk_gephy_write_page, ++ }, ++}; ++ ++module_phy_driver(mtk_gephy_driver); ++ ++static struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = { ++ { PHY_ID_MATCH_EXACT(0x03a29441) }, ++ { PHY_ID_MATCH_EXACT(0x03a29412) }, ++ { } ++}; ++ ++MODULE_DESCRIPTION("MediaTek Gigabit Ethernet PHY driver"); ++MODULE_AUTHOR("DENG, Qingfang "); ++MODULE_LICENSE("GPL"); ++ ++MODULE_DEVICE_TABLE(mdio, mtk_gephy_tbl); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-05-v6.13-net-phy-mediatek-Move-LED-helper-functions-into-mtk-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-05-v6.13-net-phy-mediatek-Move-LED-helper-functions-into-mtk-.patch new file mode 100755 index 0000000..63407ac --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-05-v6.13-net-phy-mediatek-Move-LED-helper-functions-into-mtk-.patch @@ -0,0 +1,774 @@ +From 71d88c7409b91c853d7f9c933f5e27933d656e5e Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Sat, 9 Nov 2024 00:34:52 +0800 +Subject: [PATCH 05/20] net: phy: mediatek: Move LED helper functions into mtk + phy lib + +This patch creates mtk-phy-lib.c & mtk-phy.h and integrates mtk-ge-soc.c's +LED helper functions so that we can use those helper functions in other +MTK's ethernet phy driver. + +Reviewed-by: Andrew Lunn +Signed-off-by: SkyLake.Huang +Signed-off-by: David S. Miller +--- + MAINTAINERS | 2 + + drivers/net/phy/mediatek/Kconfig | 4 + + drivers/net/phy/mediatek/Makefile | 1 + + drivers/net/phy/mediatek/mtk-ge-soc.c | 280 +++---------------------- + drivers/net/phy/mediatek/mtk-phy-lib.c | 254 ++++++++++++++++++++++ + drivers/net/phy/mediatek/mtk.h | 86 ++++++++ + 6 files changed, 372 insertions(+), 255 deletions(-) + create mode 100644 drivers/net/phy/mediatek/mtk-phy-lib.c + create mode 100644 drivers/net/phy/mediatek/mtk.h + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -14428,7 +14428,9 @@ M: SkyLake Huang + #include + ++#include "mtk.h" ++ + #define MTK_GPHY_ID_MT7981 0x03a29461 + #define MTK_GPHY_ID_MT7988 0x03a29481 + +@@ -210,41 +212,6 @@ + #define MTK_PHY_DA_TX_R50_PAIR_D 0x540 + + /* Registers on MDIO_MMD_VEND2 */ +-#define MTK_PHY_LED0_ON_CTRL 0x24 +-#define MTK_PHY_LED1_ON_CTRL 0x26 +-#define MTK_PHY_LED_ON_MASK GENMASK(6, 0) +-#define MTK_PHY_LED_ON_LINK1000 BIT(0) +-#define MTK_PHY_LED_ON_LINK100 BIT(1) +-#define MTK_PHY_LED_ON_LINK10 BIT(2) +-#define MTK_PHY_LED_ON_LINK (MTK_PHY_LED_ON_LINK10 |\ +- MTK_PHY_LED_ON_LINK100 |\ +- MTK_PHY_LED_ON_LINK1000) +-#define MTK_PHY_LED_ON_LINKDOWN BIT(3) +-#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */ +-#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */ +-#define MTK_PHY_LED_ON_FORCE_ON BIT(6) +-#define MTK_PHY_LED_ON_POLARITY BIT(14) +-#define MTK_PHY_LED_ON_ENABLE BIT(15) +- +-#define MTK_PHY_LED0_BLINK_CTRL 0x25 +-#define MTK_PHY_LED1_BLINK_CTRL 0x27 +-#define MTK_PHY_LED_BLINK_1000TX BIT(0) +-#define MTK_PHY_LED_BLINK_1000RX BIT(1) +-#define MTK_PHY_LED_BLINK_100TX BIT(2) +-#define MTK_PHY_LED_BLINK_100RX BIT(3) +-#define MTK_PHY_LED_BLINK_10TX BIT(4) +-#define MTK_PHY_LED_BLINK_10RX BIT(5) +-#define MTK_PHY_LED_BLINK_RX (MTK_PHY_LED_BLINK_10RX |\ +- MTK_PHY_LED_BLINK_100RX |\ +- MTK_PHY_LED_BLINK_1000RX) +-#define MTK_PHY_LED_BLINK_TX (MTK_PHY_LED_BLINK_10TX |\ +- MTK_PHY_LED_BLINK_100TX |\ +- MTK_PHY_LED_BLINK_1000TX) +-#define MTK_PHY_LED_BLINK_COLLISION BIT(6) +-#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7) +-#define MTK_PHY_LED_BLINK_RX_IDLE_ERR BIT(8) +-#define MTK_PHY_LED_BLINK_FORCE_BLINK BIT(9) +- + #define MTK_PHY_LED1_DEFAULT_POLARITIES BIT(1) + + #define MTK_PHY_RG_BG_RASEL 0x115 +@@ -299,14 +266,6 @@ enum CAL_MODE { + SW_M + }; + +-#define MTK_PHY_LED_STATE_FORCE_ON 0 +-#define MTK_PHY_LED_STATE_FORCE_BLINK 1 +-#define MTK_PHY_LED_STATE_NETDEV 2 +- +-struct mtk_socphy_priv { +- unsigned long led_state; +-}; +- + struct mtk_socphy_shared { + u32 boottrap; + struct mtk_socphy_priv priv[4]; +@@ -1172,76 +1131,23 @@ static int mt798x_phy_config_init(struct + return mt798x_phy_calibration(phydev); + } + +-static int mt798x_phy_hw_led_on_set(struct phy_device *phydev, u8 index, +- bool on) +-{ +- unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- bool changed; +- +- if (on) +- changed = !test_and_set_bit(bit_on, &priv->led_state); +- else +- changed = !!test_and_clear_bit(bit_on, &priv->led_state); +- +- changed |= !!test_and_clear_bit(MTK_PHY_LED_STATE_NETDEV + +- (index ? 16 : 0), &priv->led_state); +- if (changed) +- return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_ON_CTRL : +- MTK_PHY_LED0_ON_CTRL, +- MTK_PHY_LED_ON_MASK, +- on ? MTK_PHY_LED_ON_FORCE_ON : 0); +- else +- return 0; +-} +- +-static int mt798x_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, +- bool blinking) +-{ +- unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + +- (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- bool changed; +- +- if (blinking) +- changed = !test_and_set_bit(bit_blink, &priv->led_state); +- else +- changed = !!test_and_clear_bit(bit_blink, &priv->led_state); +- +- changed |= !!test_bit(MTK_PHY_LED_STATE_NETDEV + +- (index ? 16 : 0), &priv->led_state); +- if (changed) +- return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_BLINK_CTRL : +- MTK_PHY_LED0_BLINK_CTRL, +- blinking ? +- MTK_PHY_LED_BLINK_FORCE_BLINK : 0); +- else +- return 0; +-} +- + static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index, + unsigned long *delay_on, + unsigned long *delay_off) + { + bool blinking = false; +- int err = 0; +- +- if (index > 1) +- return -EINVAL; ++ int err; + +- if (delay_on && delay_off && (*delay_on > 0) && (*delay_off > 0)) { +- blinking = true; +- *delay_on = 50; +- *delay_off = 50; +- } ++ err = mtk_phy_led_num_dly_cfg(index, delay_on, delay_off, &blinking); ++ if (err < 0) ++ return err; + +- err = mt798x_phy_hw_led_blink_set(phydev, index, blinking); ++ err = mtk_phy_hw_led_blink_set(phydev, index, blinking); + if (err) + return err; + +- return mt798x_phy_hw_led_on_set(phydev, index, false); ++ return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK, ++ false); + } + + static int mt798x_phy_led_brightness_set(struct phy_device *phydev, +@@ -1249,11 +1155,12 @@ static int mt798x_phy_led_brightness_set + { + int err; + +- err = mt798x_phy_hw_led_blink_set(phydev, index, false); ++ err = mtk_phy_hw_led_blink_set(phydev, index, false); + if (err) + return err; + +- return mt798x_phy_hw_led_on_set(phydev, index, (value != LED_OFF)); ++ return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK, ++ (value != LED_OFF)); + } + + static const unsigned long supported_triggers = +@@ -1269,155 +1176,26 @@ static const unsigned long supported_tri + static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) + { +- if (index > 1) +- return -EINVAL; +- +- /* All combinations of the supported triggers are allowed */ +- if (rules & ~supported_triggers) +- return -EOPNOTSUPP; +- +- return 0; +-}; ++ return mtk_phy_led_hw_is_supported(phydev, index, rules, ++ supported_triggers); ++} + + static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index, + unsigned long *rules) + { +- unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + +- (index ? 16 : 0); +- unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); +- unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- int on, blink; +- +- if (index > 1) +- return -EINVAL; +- +- on = phy_read_mmd(phydev, MDIO_MMD_VEND2, +- index ? MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL); +- +- if (on < 0) +- return -EIO; +- +- blink = phy_read_mmd(phydev, MDIO_MMD_VEND2, +- index ? MTK_PHY_LED1_BLINK_CTRL : +- MTK_PHY_LED0_BLINK_CTRL); +- if (blink < 0) +- return -EIO; +- +- if ((on & (MTK_PHY_LED_ON_LINK | MTK_PHY_LED_ON_FDX | +- MTK_PHY_LED_ON_HDX | MTK_PHY_LED_ON_LINKDOWN)) || +- (blink & (MTK_PHY_LED_BLINK_RX | MTK_PHY_LED_BLINK_TX))) +- set_bit(bit_netdev, &priv->led_state); +- else +- clear_bit(bit_netdev, &priv->led_state); +- +- if (on & MTK_PHY_LED_ON_FORCE_ON) +- set_bit(bit_on, &priv->led_state); +- else +- clear_bit(bit_on, &priv->led_state); +- +- if (blink & MTK_PHY_LED_BLINK_FORCE_BLINK) +- set_bit(bit_blink, &priv->led_state); +- else +- clear_bit(bit_blink, &priv->led_state); +- +- if (!rules) +- return 0; +- +- if (on & MTK_PHY_LED_ON_LINK) +- *rules |= BIT(TRIGGER_NETDEV_LINK); +- +- if (on & MTK_PHY_LED_ON_LINK10) +- *rules |= BIT(TRIGGER_NETDEV_LINK_10); +- +- if (on & MTK_PHY_LED_ON_LINK100) +- *rules |= BIT(TRIGGER_NETDEV_LINK_100); +- +- if (on & MTK_PHY_LED_ON_LINK1000) +- *rules |= BIT(TRIGGER_NETDEV_LINK_1000); +- +- if (on & MTK_PHY_LED_ON_FDX) +- *rules |= BIT(TRIGGER_NETDEV_FULL_DUPLEX); +- +- if (on & MTK_PHY_LED_ON_HDX) +- *rules |= BIT(TRIGGER_NETDEV_HALF_DUPLEX); +- +- if (blink & MTK_PHY_LED_BLINK_RX) +- *rules |= BIT(TRIGGER_NETDEV_RX); +- +- if (blink & MTK_PHY_LED_BLINK_TX) +- *rules |= BIT(TRIGGER_NETDEV_TX); +- +- return 0; ++ return mtk_phy_led_hw_ctrl_get(phydev, index, rules, ++ MTK_GPHY_LED_ON_SET, ++ MTK_GPHY_LED_RX_BLINK_SET, ++ MTK_GPHY_LED_TX_BLINK_SET); + }; + + static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index, + unsigned long rules) + { +- unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); +- struct mtk_socphy_priv *priv = phydev->priv; +- u16 on = 0, blink = 0; +- int ret; +- +- if (index > 1) +- return -EINVAL; +- +- if (rules & BIT(TRIGGER_NETDEV_FULL_DUPLEX)) +- on |= MTK_PHY_LED_ON_FDX; +- +- if (rules & BIT(TRIGGER_NETDEV_HALF_DUPLEX)) +- on |= MTK_PHY_LED_ON_HDX; +- +- if (rules & (BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK))) +- on |= MTK_PHY_LED_ON_LINK10; +- +- if (rules & (BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK))) +- on |= MTK_PHY_LED_ON_LINK100; +- +- if (rules & (BIT(TRIGGER_NETDEV_LINK_1000) | BIT(TRIGGER_NETDEV_LINK))) +- on |= MTK_PHY_LED_ON_LINK1000; +- +- if (rules & BIT(TRIGGER_NETDEV_RX)) { +- blink |= (on & MTK_PHY_LED_ON_LINK) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? +- MTK_PHY_LED_BLINK_10RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? +- MTK_PHY_LED_BLINK_100RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? +- MTK_PHY_LED_BLINK_1000RX : 0)) : +- MTK_PHY_LED_BLINK_RX; +- } +- +- if (rules & BIT(TRIGGER_NETDEV_TX)) { +- blink |= (on & MTK_PHY_LED_ON_LINK) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? +- MTK_PHY_LED_BLINK_10TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? +- MTK_PHY_LED_BLINK_100TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? +- MTK_PHY_LED_BLINK_1000TX : 0)) : +- MTK_PHY_LED_BLINK_TX; +- } +- +- if (blink || on) +- set_bit(bit_netdev, &priv->led_state); +- else +- clear_bit(bit_netdev, &priv->led_state); +- +- ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_ON_CTRL : +- MTK_PHY_LED0_ON_CTRL, +- MTK_PHY_LED_ON_FDX | +- MTK_PHY_LED_ON_HDX | +- MTK_PHY_LED_ON_LINK, +- on); +- +- if (ret) +- return ret; +- +- return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? +- MTK_PHY_LED1_BLINK_CTRL : +- MTK_PHY_LED0_BLINK_CTRL, blink); ++ return mtk_phy_led_hw_ctrl_set(phydev, index, rules, ++ MTK_GPHY_LED_ON_SET, ++ MTK_GPHY_LED_RX_BLINK_SET, ++ MTK_GPHY_LED_TX_BLINK_SET); + }; + + static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num) +@@ -1492,14 +1270,6 @@ static int mt7988_phy_probe_shared(struc + return 0; + } + +-static void mt798x_phy_leds_state_init(struct phy_device *phydev) +-{ +- int i; +- +- for (i = 0; i < 2; ++i) +- mt798x_phy_led_hw_control_get(phydev, i, NULL); +-} +- + static int mt7988_phy_probe(struct phy_device *phydev) + { + struct mtk_socphy_shared *shared; +@@ -1525,7 +1295,7 @@ static int mt7988_phy_probe(struct phy_d + + phydev->priv = priv; + +- mt798x_phy_leds_state_init(phydev); ++ mtk_phy_leds_state_init(phydev); + + err = mt7988_phy_fix_leds_polarities(phydev); + if (err) +@@ -1552,7 +1322,7 @@ static int mt7981_phy_probe(struct phy_d + + phydev->priv = priv; + +- mt798x_phy_leds_state_init(phydev); ++ mtk_phy_leds_state_init(phydev); + + return mt798x_phy_calibration(phydev); + } +--- /dev/null ++++ b/drivers/net/phy/mediatek/mtk-phy-lib.c +@@ -0,0 +1,254 @@ ++// SPDX-License-Identifier: GPL-2.0 ++#include ++#include ++ ++#include ++ ++#include "mtk.h" ++ ++int mtk_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules, ++ unsigned long supported_triggers) ++{ ++ if (index > 1) ++ return -EINVAL; ++ ++ /* All combinations of the supported triggers are allowed */ ++ if (rules & ~supported_triggers) ++ return -EOPNOTSUPP; ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(mtk_phy_led_hw_is_supported); ++ ++int mtk_phy_led_hw_ctrl_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules, u16 on_set, ++ u16 rx_blink_set, u16 tx_blink_set) ++{ ++ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + ++ (index ? 16 : 0); ++ unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); ++ unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ int on, blink; ++ ++ if (index > 1) ++ return -EINVAL; ++ ++ on = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ index ? MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL); ++ ++ if (on < 0) ++ return -EIO; ++ ++ blink = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ index ? MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL); ++ if (blink < 0) ++ return -EIO; ++ ++ if ((on & (on_set | MTK_PHY_LED_ON_FDX | ++ MTK_PHY_LED_ON_HDX | MTK_PHY_LED_ON_LINKDOWN)) || ++ (blink & (rx_blink_set | tx_blink_set))) ++ set_bit(bit_netdev, &priv->led_state); ++ else ++ clear_bit(bit_netdev, &priv->led_state); ++ ++ if (on & MTK_PHY_LED_ON_FORCE_ON) ++ set_bit(bit_on, &priv->led_state); ++ else ++ clear_bit(bit_on, &priv->led_state); ++ ++ if (blink & MTK_PHY_LED_BLINK_FORCE_BLINK) ++ set_bit(bit_blink, &priv->led_state); ++ else ++ clear_bit(bit_blink, &priv->led_state); ++ ++ if (!rules) ++ return 0; ++ ++ if (on & on_set) ++ *rules |= BIT(TRIGGER_NETDEV_LINK); ++ ++ if (on & MTK_PHY_LED_ON_LINK10) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_10); ++ ++ if (on & MTK_PHY_LED_ON_LINK100) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_100); ++ ++ if (on & MTK_PHY_LED_ON_LINK1000) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_1000); ++ ++ if (on & MTK_PHY_LED_ON_LINK2500) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_2500); ++ ++ if (on & MTK_PHY_LED_ON_FDX) ++ *rules |= BIT(TRIGGER_NETDEV_FULL_DUPLEX); ++ ++ if (on & MTK_PHY_LED_ON_HDX) ++ *rules |= BIT(TRIGGER_NETDEV_HALF_DUPLEX); ++ ++ if (blink & rx_blink_set) ++ *rules |= BIT(TRIGGER_NETDEV_RX); ++ ++ if (blink & tx_blink_set) ++ *rules |= BIT(TRIGGER_NETDEV_TX); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(mtk_phy_led_hw_ctrl_get); ++ ++int mtk_phy_led_hw_ctrl_set(struct phy_device *phydev, u8 index, ++ unsigned long rules, u16 on_set, ++ u16 rx_blink_set, u16 tx_blink_set) ++{ ++ unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ u16 on = 0, blink = 0; ++ int ret; ++ ++ if (index > 1) ++ return -EINVAL; ++ ++ if (rules & BIT(TRIGGER_NETDEV_FULL_DUPLEX)) ++ on |= MTK_PHY_LED_ON_FDX; ++ ++ if (rules & BIT(TRIGGER_NETDEV_HALF_DUPLEX)) ++ on |= MTK_PHY_LED_ON_HDX; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK10; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK100; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_1000) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK1000; ++ ++ if (rules & (BIT(TRIGGER_NETDEV_LINK_2500) | BIT(TRIGGER_NETDEV_LINK))) ++ on |= MTK_PHY_LED_ON_LINK2500; ++ ++ if (rules & BIT(TRIGGER_NETDEV_RX)) { ++ blink |= (on & on_set) ? ++ (((on & MTK_PHY_LED_ON_LINK10) ? ++ MTK_PHY_LED_BLINK_10RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK100) ? ++ MTK_PHY_LED_BLINK_100RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK1000) ? ++ MTK_PHY_LED_BLINK_1000RX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK2500) ? ++ MTK_PHY_LED_BLINK_2500RX : 0)) : ++ rx_blink_set; ++ } ++ ++ if (rules & BIT(TRIGGER_NETDEV_TX)) { ++ blink |= (on & on_set) ? ++ (((on & MTK_PHY_LED_ON_LINK10) ? ++ MTK_PHY_LED_BLINK_10TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK100) ? ++ MTK_PHY_LED_BLINK_100TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK1000) ? ++ MTK_PHY_LED_BLINK_1000TX : 0) | ++ ((on & MTK_PHY_LED_ON_LINK2500) ? ++ MTK_PHY_LED_BLINK_2500TX : 0)) : ++ tx_blink_set; ++ } ++ ++ if (blink || on) ++ set_bit(bit_netdev, &priv->led_state); ++ else ++ clear_bit(bit_netdev, &priv->led_state); ++ ++ ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL, ++ MTK_PHY_LED_ON_FDX | MTK_PHY_LED_ON_HDX | on_set, ++ on); ++ ++ if (ret) ++ return ret; ++ ++ return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL, blink); ++} ++EXPORT_SYMBOL_GPL(mtk_phy_led_hw_ctrl_set); ++ ++int mtk_phy_led_num_dly_cfg(u8 index, unsigned long *delay_on, ++ unsigned long *delay_off, bool *blinking) ++{ ++ if (index > 1) ++ return -EINVAL; ++ ++ if (delay_on && delay_off && (*delay_on > 0) && (*delay_off > 0)) { ++ *blinking = true; ++ *delay_on = 50; ++ *delay_off = 50; ++ } ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(mtk_phy_led_num_dly_cfg); ++ ++int mtk_phy_hw_led_on_set(struct phy_device *phydev, u8 index, ++ u16 led_on_mask, bool on) ++{ ++ unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ bool changed; ++ ++ if (on) ++ changed = !test_and_set_bit(bit_on, &priv->led_state); ++ else ++ changed = !!test_and_clear_bit(bit_on, &priv->led_state); ++ ++ changed |= !!test_and_clear_bit(MTK_PHY_LED_STATE_NETDEV + ++ (index ? 16 : 0), &priv->led_state); ++ if (changed) ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_ON_CTRL : ++ MTK_PHY_LED0_ON_CTRL, ++ led_on_mask, ++ on ? MTK_PHY_LED_ON_FORCE_ON : 0); ++ else ++ return 0; ++} ++EXPORT_SYMBOL_GPL(mtk_phy_hw_led_on_set); ++ ++int mtk_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, bool blinking) ++{ ++ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + ++ (index ? 16 : 0); ++ struct mtk_socphy_priv *priv = phydev->priv; ++ bool changed; ++ ++ if (blinking) ++ changed = !test_and_set_bit(bit_blink, &priv->led_state); ++ else ++ changed = !!test_and_clear_bit(bit_blink, &priv->led_state); ++ ++ changed |= !!test_bit(MTK_PHY_LED_STATE_NETDEV + ++ (index ? 16 : 0), &priv->led_state); ++ if (changed) ++ return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_BLINK_CTRL : ++ MTK_PHY_LED0_BLINK_CTRL, ++ blinking ? ++ MTK_PHY_LED_BLINK_FORCE_BLINK : 0); ++ else ++ return 0; ++} ++EXPORT_SYMBOL_GPL(mtk_phy_hw_led_blink_set); ++ ++void mtk_phy_leds_state_init(struct phy_device *phydev) ++{ ++ int i; ++ ++ for (i = 0; i < 2; ++i) ++ phydev->drv->led_hw_control_get(phydev, i, NULL); ++} ++EXPORT_SYMBOL_GPL(mtk_phy_leds_state_init); ++ ++MODULE_DESCRIPTION("MediaTek Ethernet PHY driver common"); ++MODULE_AUTHOR("Sky Huang "); ++MODULE_AUTHOR("Daniel Golle "); ++MODULE_LICENSE("GPL"); +--- /dev/null ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -0,0 +1,86 @@ ++/* SPDX-License-Identifier: GPL-2.0 ++ * ++ * Common definition for Mediatek Ethernet PHYs ++ * Author: SkyLake Huang ++ * Copyright (c) 2024 MediaTek Inc. ++ */ ++ ++#ifndef _MTK_EPHY_H_ ++#define _MTK_EPHY_H_ ++ ++#define MTK_EXT_PAGE_ACCESS 0x1f ++ ++/* Registers on MDIO_MMD_VEND2 */ ++#define MTK_PHY_LED0_ON_CTRL 0x24 ++#define MTK_PHY_LED1_ON_CTRL 0x26 ++#define MTK_GPHY_LED_ON_MASK GENMASK(6, 0) ++#define MTK_2P5GPHY_LED_ON_MASK GENMASK(7, 0) ++#define MTK_PHY_LED_ON_LINK1000 BIT(0) ++#define MTK_PHY_LED_ON_LINK100 BIT(1) ++#define MTK_PHY_LED_ON_LINK10 BIT(2) ++#define MTK_PHY_LED_ON_LINKDOWN BIT(3) ++#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */ ++#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */ ++#define MTK_PHY_LED_ON_FORCE_ON BIT(6) ++#define MTK_PHY_LED_ON_LINK2500 BIT(7) ++#define MTK_PHY_LED_ON_POLARITY BIT(14) ++#define MTK_PHY_LED_ON_ENABLE BIT(15) ++ ++#define MTK_PHY_LED0_BLINK_CTRL 0x25 ++#define MTK_PHY_LED1_BLINK_CTRL 0x27 ++#define MTK_PHY_LED_BLINK_1000TX BIT(0) ++#define MTK_PHY_LED_BLINK_1000RX BIT(1) ++#define MTK_PHY_LED_BLINK_100TX BIT(2) ++#define MTK_PHY_LED_BLINK_100RX BIT(3) ++#define MTK_PHY_LED_BLINK_10TX BIT(4) ++#define MTK_PHY_LED_BLINK_10RX BIT(5) ++#define MTK_PHY_LED_BLINK_COLLISION BIT(6) ++#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7) ++#define MTK_PHY_LED_BLINK_RX_IDLE_ERR BIT(8) ++#define MTK_PHY_LED_BLINK_FORCE_BLINK BIT(9) ++#define MTK_PHY_LED_BLINK_2500TX BIT(10) ++#define MTK_PHY_LED_BLINK_2500RX BIT(11) ++ ++#define MTK_GPHY_LED_ON_SET (MTK_PHY_LED_ON_LINK1000 | \ ++ MTK_PHY_LED_ON_LINK100 | \ ++ MTK_PHY_LED_ON_LINK10) ++#define MTK_GPHY_LED_RX_BLINK_SET (MTK_PHY_LED_BLINK_1000RX | \ ++ MTK_PHY_LED_BLINK_100RX | \ ++ MTK_PHY_LED_BLINK_10RX) ++#define MTK_GPHY_LED_TX_BLINK_SET (MTK_PHY_LED_BLINK_1000RX | \ ++ MTK_PHY_LED_BLINK_100RX | \ ++ MTK_PHY_LED_BLINK_10RX) ++ ++#define MTK_2P5GPHY_LED_ON_SET (MTK_PHY_LED_ON_LINK2500 | \ ++ MTK_GPHY_LED_ON_SET) ++#define MTK_2P5GPHY_LED_RX_BLINK_SET (MTK_PHY_LED_BLINK_2500RX | \ ++ MTK_GPHY_LED_RX_BLINK_SET) ++#define MTK_2P5GPHY_LED_TX_BLINK_SET (MTK_PHY_LED_BLINK_2500RX | \ ++ MTK_GPHY_LED_TX_BLINK_SET) ++ ++#define MTK_PHY_LED_STATE_FORCE_ON 0 ++#define MTK_PHY_LED_STATE_FORCE_BLINK 1 ++#define MTK_PHY_LED_STATE_NETDEV 2 ++ ++struct mtk_socphy_priv { ++ unsigned long led_state; ++}; ++ ++int mtk_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules, ++ unsigned long supported_triggers); ++int mtk_phy_led_hw_ctrl_set(struct phy_device *phydev, u8 index, ++ unsigned long rules, u16 on_set, ++ u16 rx_blink_set, u16 tx_blink_set); ++int mtk_phy_led_hw_ctrl_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules, u16 on_set, ++ u16 rx_blink_set, u16 tx_blink_set); ++int mtk_phy_led_num_dly_cfg(u8 index, unsigned long *delay_on, ++ unsigned long *delay_off, bool *blinking); ++int mtk_phy_hw_led_on_set(struct phy_device *phydev, u8 index, ++ u16 led_on_mask, bool on); ++int mtk_phy_hw_led_blink_set(struct phy_device *phydev, u8 index, ++ bool blinking); ++void mtk_phy_leds_state_init(struct phy_device *phydev); ++ ++#endif /* _MTK_EPHY_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-06-v6.13-net-phy-mediatek-Improve-readability-of-mtk-phy-lib..patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-06-v6.13-net-phy-mediatek-Improve-readability-of-mtk-phy-lib..patch new file mode 100755 index 0000000..19f3a84 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-06-v6.13-net-phy-mediatek-Improve-readability-of-mtk-phy-lib..patch @@ -0,0 +1,72 @@ +From 3efd0595fc7aaae300f5d9f4f0ae86f432c8d2c7 Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Sat, 9 Nov 2024 00:34:53 +0800 +Subject: [PATCH 06/20] net: phy: mediatek: Improve readability of + mtk-phy-lib.c's mtk_phy_led_hw_ctrl_set() + +This patch removes parens around TRIGGER_NETDEV_RX/TRIGGER_NETDEV_TX in +mtk_phy_led_hw_ctrl_set(), which improves readability. + +Reviewed-by: Andrew Lunn +Signed-off-by: SkyLake.Huang +Signed-off-by: David S. Miller +--- + drivers/net/phy/mediatek/mtk-phy-lib.c | 44 ++++++++++++++------------ + 1 file changed, 24 insertions(+), 20 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-phy-lib.c ++++ b/drivers/net/phy/mediatek/mtk-phy-lib.c +@@ -129,29 +129,33 @@ int mtk_phy_led_hw_ctrl_set(struct phy_d + on |= MTK_PHY_LED_ON_LINK2500; + + if (rules & BIT(TRIGGER_NETDEV_RX)) { +- blink |= (on & on_set) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? +- MTK_PHY_LED_BLINK_10RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? +- MTK_PHY_LED_BLINK_100RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? +- MTK_PHY_LED_BLINK_1000RX : 0) | +- ((on & MTK_PHY_LED_ON_LINK2500) ? +- MTK_PHY_LED_BLINK_2500RX : 0)) : +- rx_blink_set; ++ if (on & on_set) { ++ if (on & MTK_PHY_LED_ON_LINK10) ++ blink |= MTK_PHY_LED_BLINK_10RX; ++ if (on & MTK_PHY_LED_ON_LINK100) ++ blink |= MTK_PHY_LED_BLINK_100RX; ++ if (on & MTK_PHY_LED_ON_LINK1000) ++ blink |= MTK_PHY_LED_BLINK_1000RX; ++ if (on & MTK_PHY_LED_ON_LINK2500) ++ blink |= MTK_PHY_LED_BLINK_2500RX; ++ } else { ++ blink |= rx_blink_set; ++ } + } + + if (rules & BIT(TRIGGER_NETDEV_TX)) { +- blink |= (on & on_set) ? +- (((on & MTK_PHY_LED_ON_LINK10) ? +- MTK_PHY_LED_BLINK_10TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK100) ? +- MTK_PHY_LED_BLINK_100TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK1000) ? +- MTK_PHY_LED_BLINK_1000TX : 0) | +- ((on & MTK_PHY_LED_ON_LINK2500) ? +- MTK_PHY_LED_BLINK_2500TX : 0)) : +- tx_blink_set; ++ if (on & on_set) { ++ if (on & MTK_PHY_LED_ON_LINK10) ++ blink |= MTK_PHY_LED_BLINK_10TX; ++ if (on & MTK_PHY_LED_ON_LINK100) ++ blink |= MTK_PHY_LED_BLINK_100TX; ++ if (on & MTK_PHY_LED_ON_LINK1000) ++ blink |= MTK_PHY_LED_BLINK_1000TX; ++ if (on & MTK_PHY_LED_ON_LINK2500) ++ blink |= MTK_PHY_LED_BLINK_2500TX; ++ } else { ++ blink |= tx_blink_set; ++ } + } + + if (blink || on) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-07-v6.13-net-phy-mediatek-Integrate-read-write-page-helper-fu.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-07-v6.13-net-phy-mediatek-Integrate-read-write-page-helper-fu.patch new file mode 100755 index 0000000..a5828bc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-07-v6.13-net-phy-mediatek-Integrate-read-write-page-helper-fu.patch @@ -0,0 +1,153 @@ +From 50a97d716105a5f35aaecca0bdfe8e23cba0e87f Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Sat, 9 Nov 2024 00:34:54 +0800 +Subject: [PATCH 07/20] net: phy: mediatek: Integrate read/write page helper + functions + +This patch integrates read/write page helper functions as MTK phy lib. +They are basically the same in mtk-ge.c & mtk-ge-soc.c. + +Signed-off-by: SkyLake.Huang +Signed-off-by: David S. Miller +--- + drivers/net/phy/mediatek/Kconfig | 1 + + drivers/net/phy/mediatek/mtk-ge-soc.c | 18 ++++-------------- + drivers/net/phy/mediatek/mtk-ge.c | 20 ++++++-------------- + drivers/net/phy/mediatek/mtk-phy-lib.c | 12 ++++++++++++ + drivers/net/phy/mediatek/mtk.h | 3 +++ + 5 files changed, 26 insertions(+), 28 deletions(-) + +--- a/drivers/net/phy/mediatek/Kconfig ++++ b/drivers/net/phy/mediatek/Kconfig +@@ -4,6 +4,7 @@ config MTK_NET_PHYLIB + + config MEDIATEK_GE_PHY + tristate "MediaTek Gigabit Ethernet PHYs" ++ select MTK_NET_PHYLIB + help + Supports the MediaTek non-built-in Gigabit Ethernet PHYs. + +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -271,16 +271,6 @@ struct mtk_socphy_shared { + struct mtk_socphy_priv priv[4]; + }; + +-static int mtk_socphy_read_page(struct phy_device *phydev) +-{ +- return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +-} +- +-static int mtk_socphy_write_page(struct phy_device *phydev, int page) +-{ +- return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); +-} +- + /* One calibration cycle consists of: + * 1.Set DA_CALIN_FLAG high to start calibration. Keep it high + * until AD_CAL_COMP is ready to output calibration result. +@@ -1337,8 +1327,8 @@ static struct phy_driver mtk_socphy_driv + .probe = mt7981_phy_probe, + .suspend = genphy_suspend, + .resume = genphy_resume, +- .read_page = mtk_socphy_read_page, +- .write_page = mtk_socphy_write_page, ++ .read_page = mtk_phy_read_page, ++ .write_page = mtk_phy_write_page, + .led_blink_set = mt798x_phy_led_blink_set, + .led_brightness_set = mt798x_phy_led_brightness_set, + .led_hw_is_supported = mt798x_phy_led_hw_is_supported, +@@ -1354,8 +1344,8 @@ static struct phy_driver mtk_socphy_driv + .probe = mt7988_phy_probe, + .suspend = genphy_suspend, + .resume = genphy_resume, +- .read_page = mtk_socphy_read_page, +- .write_page = mtk_socphy_write_page, ++ .read_page = mtk_phy_read_page, ++ .write_page = mtk_phy_write_page, + .led_blink_set = mt798x_phy_led_blink_set, + .led_brightness_set = mt798x_phy_led_brightness_set, + .led_hw_is_supported = mt798x_phy_led_hw_is_supported, +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -3,6 +3,8 @@ + #include + #include + ++#include "mtk.h" ++ + #define MTK_EXT_PAGE_ACCESS 0x1f + #define MTK_PHY_PAGE_STANDARD 0x0000 + #define MTK_PHY_PAGE_EXTENDED 0x0001 +@@ -11,16 +13,6 @@ + #define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 + #define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 + +-static int mtk_gephy_read_page(struct phy_device *phydev) +-{ +- return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +-} +- +-static int mtk_gephy_write_page(struct phy_device *phydev, int page) +-{ +- return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); +-} +- + static void mtk_gephy_config_init(struct phy_device *phydev) + { + /* Enable HW auto downshift */ +@@ -77,8 +69,8 @@ static struct phy_driver mtk_gephy_drive + .handle_interrupt = genphy_handle_interrupt_no_ack, + .suspend = genphy_suspend, + .resume = genphy_resume, +- .read_page = mtk_gephy_read_page, +- .write_page = mtk_gephy_write_page, ++ .read_page = mtk_phy_read_page, ++ .write_page = mtk_phy_write_page, + }, + { + PHY_ID_MATCH_EXACT(0x03a29441), +@@ -91,8 +83,8 @@ static struct phy_driver mtk_gephy_drive + .handle_interrupt = genphy_handle_interrupt_no_ack, + .suspend = genphy_suspend, + .resume = genphy_resume, +- .read_page = mtk_gephy_read_page, +- .write_page = mtk_gephy_write_page, ++ .read_page = mtk_phy_read_page, ++ .write_page = mtk_phy_write_page, + }, + }; + +--- a/drivers/net/phy/mediatek/mtk-phy-lib.c ++++ b/drivers/net/phy/mediatek/mtk-phy-lib.c +@@ -6,6 +6,18 @@ + + #include "mtk.h" + ++int mtk_phy_read_page(struct phy_device *phydev) ++{ ++ return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); ++} ++EXPORT_SYMBOL_GPL(mtk_phy_read_page); ++ ++int mtk_phy_write_page(struct phy_device *phydev, int page) ++{ ++ return __phy_write(phydev, MTK_EXT_PAGE_ACCESS, page); ++} ++EXPORT_SYMBOL_GPL(mtk_phy_write_page); ++ + int mtk_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules, + unsigned long supported_triggers) +--- a/drivers/net/phy/mediatek/mtk.h ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -66,6 +66,9 @@ struct mtk_socphy_priv { + unsigned long led_state; + }; + ++int mtk_phy_read_page(struct phy_device *phydev); ++int mtk_phy_write_page(struct phy_device *phydev, int page); ++ + int mtk_phy_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules, + unsigned long supported_triggers); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-08-v6.13-net-phy-mediatek-add-MT7530-MT7531-s-PHY-ID-macros.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-08-v6.13-net-phy-mediatek-add-MT7530-MT7531-s-PHY-ID-macros.patch new file mode 100755 index 0000000..1c87384 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-08-v6.13-net-phy-mediatek-add-MT7530-MT7531-s-PHY-ID-macros.patch @@ -0,0 +1,56 @@ +From e6579df175d5b1baa605c82f8e759542262637cf Mon Sep 17 00:00:00 2001 +From: "SkyLake.Huang" +Date: Sat, 9 Nov 2024 00:34:55 +0800 +Subject: [PATCH 08/20] net: phy: mediatek: add MT7530 & MT7531's PHY ID macros + +This patch adds MT7530 & MT7531's PHY ID macros in mtk-ge.c so that +it follows the same rule of mtk-ge-soc.c. + +Reviewed-by: Andrew Lunn +Signed-off-by: SkyLake.Huang +Signed-off-by: David S. Miller +--- + drivers/net/phy/mediatek/mtk-ge.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -5,6 +5,9 @@ + + #include "mtk.h" + ++#define MTK_GPHY_ID_MT7530 0x03a29412 ++#define MTK_GPHY_ID_MT7531 0x03a29441 ++ + #define MTK_EXT_PAGE_ACCESS 0x1f + #define MTK_PHY_PAGE_STANDARD 0x0000 + #define MTK_PHY_PAGE_EXTENDED 0x0001 +@@ -59,7 +62,7 @@ static int mt7531_phy_config_init(struct + + static struct phy_driver mtk_gephy_driver[] = { + { +- PHY_ID_MATCH_EXACT(0x03a29412), ++ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7530), + .name = "MediaTek MT7530 PHY", + .config_init = mt7530_phy_config_init, + /* Interrupts are handled by the switch, not the PHY +@@ -73,7 +76,7 @@ static struct phy_driver mtk_gephy_drive + .write_page = mtk_phy_write_page, + }, + { +- PHY_ID_MATCH_EXACT(0x03a29441), ++ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7531), + .name = "MediaTek MT7531 PHY", + .config_init = mt7531_phy_config_init, + /* Interrupts are handled by the switch, not the PHY +@@ -91,8 +94,8 @@ static struct phy_driver mtk_gephy_drive + module_phy_driver(mtk_gephy_driver); + + static struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = { +- { PHY_ID_MATCH_EXACT(0x03a29441) }, +- { PHY_ID_MATCH_EXACT(0x03a29412) }, ++ { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7530) }, ++ { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7531) }, + { } + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-09-v6.14-net-phy-Constify-struct-mdio_device_id.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-09-v6.14-net-phy-Constify-struct-mdio_device_id.patch new file mode 100755 index 0000000..c0c840d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-09-v6.14-net-phy-Constify-struct-mdio_device_id.patch @@ -0,0 +1,700 @@ +From e127f7380aaf2cd1614961d826a4af7ab297d37f Mon Sep 17 00:00:00 2001 +From: Christophe JAILLET +Date: Sun, 12 Jan 2025 15:14:50 +0100 +Subject: [PATCH 09/20] net: phy: Constify struct mdio_device_id + +'struct mdio_device_id' is not modified in these drivers. + +Constifying these structures moves some data to a read-only section, so +increase overall security. + +On a x86_64, with allmodconfig, as an example: +Before: +====== + text data bss dec hex filename + 27014 12792 0 39806 9b7e drivers/net/phy/broadcom.o + +After: +===== + text data bss dec hex filename + 27206 12600 0 39806 9b7e drivers/net/phy/broadcom.o + +Signed-off-by: Christophe JAILLET +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/403c381b7d9156b67ad68ffc44b8eee70c5e86a9.1736691226.git.christophe.jaillet@wanadoo.fr +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/adin.c | 2 +- + drivers/net/phy/adin1100.c | 2 +- + drivers/net/phy/air_en8811h.c | 2 +- + drivers/net/phy/amd.c | 2 +- + drivers/net/phy/aquantia/aquantia_main.c | 2 +- + drivers/net/phy/ax88796b.c | 2 +- + drivers/net/phy/bcm-cygnus.c | 2 +- + drivers/net/phy/bcm54140.c | 2 +- + drivers/net/phy/bcm63xx.c | 2 +- + drivers/net/phy/bcm7xxx.c | 2 +- + drivers/net/phy/bcm84881.c | 2 +- + drivers/net/phy/broadcom.c | 2 +- + drivers/net/phy/cicada.c | 2 +- + drivers/net/phy/cortina.c | 2 +- + drivers/net/phy/davicom.c | 2 +- + drivers/net/phy/dp83640.c | 2 +- + drivers/net/phy/dp83822.c | 2 +- + drivers/net/phy/dp83848.c | 2 +- + drivers/net/phy/dp83867.c | 2 +- + drivers/net/phy/dp83869.c | 2 +- + drivers/net/phy/dp83tc811.c | 2 +- + drivers/net/phy/dp83td510.c | 2 +- + drivers/net/phy/dp83tg720.c | 2 +- + drivers/net/phy/et1011c.c | 2 +- + drivers/net/phy/icplus.c | 2 +- + drivers/net/phy/intel-xway.c | 2 +- + drivers/net/phy/lxt.c | 2 +- + drivers/net/phy/marvell-88q2xxx.c | 2 +- + drivers/net/phy/marvell-88x2222.c | 2 +- + drivers/net/phy/marvell.c | 2 +- + drivers/net/phy/marvell10g.c | 2 +- + drivers/net/phy/mediatek/mtk-ge-soc.c | 2 +- + drivers/net/phy/mediatek/mtk-ge.c | 2 +- + drivers/net/phy/meson-gxl.c | 2 +- + drivers/net/phy/micrel.c | 2 +- + drivers/net/phy/microchip.c | 2 +- + drivers/net/phy/microchip_t1.c | 2 +- + drivers/net/phy/microchip_t1s.c | 2 +- + drivers/net/phy/mscc/mscc_main.c | 2 +- + drivers/net/phy/mxl-gpy.c | 2 +- + drivers/net/phy/national.c | 2 +- + drivers/net/phy/ncn26000.c | 2 +- + drivers/net/phy/nxp-c45-tja11xx.c | 2 +- + drivers/net/phy/nxp-cbtx.c | 2 +- + drivers/net/phy/nxp-tja11xx.c | 2 +- + drivers/net/phy/qcom/at803x.c | 2 +- + drivers/net/phy/qcom/qca807x.c | 2 +- + drivers/net/phy/qcom/qca808x.c | 2 +- + drivers/net/phy/qcom/qca83xx.c | 2 +- + drivers/net/phy/qsemi.c | 2 +- + drivers/net/phy/rockchip.c | 2 +- + drivers/net/phy/smsc.c | 2 +- + drivers/net/phy/ste10Xp.c | 2 +- + drivers/net/phy/teranetics.c | 2 +- + drivers/net/phy/uPD60620.c | 2 +- + drivers/net/phy/vitesse.c | 2 +- + 56 files changed, 56 insertions(+), 56 deletions(-) + +--- a/drivers/net/phy/adin.c ++++ b/drivers/net/phy/adin.c +@@ -1040,7 +1040,7 @@ static struct phy_driver adin_driver[] = + + module_phy_driver(adin_driver); + +-static struct mdio_device_id __maybe_unused adin_tbl[] = { ++static const struct mdio_device_id __maybe_unused adin_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_ADIN1200) }, + { PHY_ID_MATCH_MODEL(PHY_ID_ADIN1300) }, + { } +--- a/drivers/net/phy/adin1100.c ++++ b/drivers/net/phy/adin1100.c +@@ -340,7 +340,7 @@ static struct phy_driver adin_driver[] = + + module_phy_driver(adin_driver); + +-static struct mdio_device_id __maybe_unused adin_tbl[] = { ++static const struct mdio_device_id __maybe_unused adin_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_ADIN1100) }, + { PHY_ID_MATCH_MODEL(PHY_ID_ADIN1110) }, + { PHY_ID_MATCH_MODEL(PHY_ID_ADIN2111) }, +--- a/drivers/net/phy/air_en8811h.c ++++ b/drivers/net/phy/air_en8811h.c +@@ -1075,7 +1075,7 @@ static struct phy_driver en8811h_driver[ + + module_phy_driver(en8811h_driver); + +-static struct mdio_device_id __maybe_unused en8811h_tbl[] = { ++static const struct mdio_device_id __maybe_unused en8811h_tbl[] = { + { PHY_ID_MATCH_MODEL(EN8811H_PHY_ID) }, + { } + }; +--- a/drivers/net/phy/amd.c ++++ b/drivers/net/phy/amd.c +@@ -111,7 +111,7 @@ static struct phy_driver am79c_drivers[] + + module_phy_driver(am79c_drivers); + +-static struct mdio_device_id __maybe_unused amd_tbl[] = { ++static const struct mdio_device_id __maybe_unused amd_tbl[] = { + { PHY_ID_AC101L, 0xfffffff0 }, + { PHY_ID_AM79C874, 0xfffffff0 }, + { } +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -1096,7 +1096,7 @@ static struct phy_driver aqr_driver[] = + + module_phy_driver(aqr_driver); + +-static struct mdio_device_id __maybe_unused aqr_tbl[] = { ++static const struct mdio_device_id __maybe_unused aqr_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_AQ1202) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQ2104) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR105) }, +--- a/drivers/net/phy/ax88796b.c ++++ b/drivers/net/phy/ax88796b.c +@@ -121,7 +121,7 @@ static struct phy_driver asix_driver[] = + + module_phy_driver(asix_driver); + +-static struct mdio_device_id __maybe_unused asix_tbl[] = { ++static const struct mdio_device_id __maybe_unused asix_tbl[] = { + { PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772A) }, + { PHY_ID_MATCH_EXACT(PHY_ID_ASIX_AX88772C) }, + { PHY_ID_ASIX_AX88796B, 0xfffffff0 }, +--- a/drivers/net/phy/bcm-cygnus.c ++++ b/drivers/net/phy/bcm-cygnus.c +@@ -278,7 +278,7 @@ static struct phy_driver bcm_cygnus_phy_ + } + }; + +-static struct mdio_device_id __maybe_unused bcm_cygnus_phy_tbl[] = { ++static const struct mdio_device_id __maybe_unused bcm_cygnus_phy_tbl[] = { + { PHY_ID_BCM_CYGNUS, 0xfffffff0, }, + { PHY_ID_BCM_OMEGA, 0xfffffff0, }, + { } +--- a/drivers/net/phy/bcm54140.c ++++ b/drivers/net/phy/bcm54140.c +@@ -883,7 +883,7 @@ static struct phy_driver bcm54140_driver + }; + module_phy_driver(bcm54140_drivers); + +-static struct mdio_device_id __maybe_unused bcm54140_tbl[] = { ++static const struct mdio_device_id __maybe_unused bcm54140_tbl[] = { + { PHY_ID_BCM54140, BCM54140_PHY_ID_MASK }, + { } + }; +--- a/drivers/net/phy/bcm63xx.c ++++ b/drivers/net/phy/bcm63xx.c +@@ -93,7 +93,7 @@ static struct phy_driver bcm63xx_driver[ + + module_phy_driver(bcm63xx_driver); + +-static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = { ++static const struct mdio_device_id __maybe_unused bcm63xx_tbl[] = { + { 0x00406000, 0xfffffc00 }, + { 0x002bdc00, 0xfffffc00 }, + { } +--- a/drivers/net/phy/bcm7xxx.c ++++ b/drivers/net/phy/bcm7xxx.c +@@ -929,7 +929,7 @@ static struct phy_driver bcm7xxx_driver[ + BCM7XXX_16NM_EPHY(PHY_ID_BCM7712, "Broadcom BCM7712"), + }; + +-static struct mdio_device_id __maybe_unused bcm7xxx_tbl[] = { ++static const struct mdio_device_id __maybe_unused bcm7xxx_tbl[] = { + { PHY_ID_BCM72113, 0xfffffff0 }, + { PHY_ID_BCM72116, 0xfffffff0, }, + { PHY_ID_BCM72165, 0xfffffff0, }, +--- a/drivers/net/phy/bcm84881.c ++++ b/drivers/net/phy/bcm84881.c +@@ -262,7 +262,7 @@ static struct phy_driver bcm84881_driver + module_phy_driver(bcm84881_drivers); + + /* FIXME: module auto-loading for Clause 45 PHYs seems non-functional */ +-static struct mdio_device_id __maybe_unused bcm84881_tbl[] = { ++static const struct mdio_device_id __maybe_unused bcm84881_tbl[] = { + { 0xae025150, 0xfffffff0 }, + { }, + }; +--- a/drivers/net/phy/broadcom.c ++++ b/drivers/net/phy/broadcom.c +@@ -1734,7 +1734,7 @@ static struct phy_driver broadcom_driver + + module_phy_driver(broadcom_drivers); + +-static struct mdio_device_id __maybe_unused broadcom_tbl[] = { ++static const struct mdio_device_id __maybe_unused broadcom_tbl[] = { + { PHY_ID_BCM5411, 0xfffffff0 }, + { PHY_ID_BCM5421, 0xfffffff0 }, + { PHY_ID_BCM54210E, 0xfffffff0 }, +--- a/drivers/net/phy/cicada.c ++++ b/drivers/net/phy/cicada.c +@@ -145,7 +145,7 @@ static struct phy_driver cis820x_driver[ + + module_phy_driver(cis820x_driver); + +-static struct mdio_device_id __maybe_unused cicada_tbl[] = { ++static const struct mdio_device_id __maybe_unused cicada_tbl[] = { + { 0x000fc410, 0x000ffff0 }, + { 0x000fc440, 0x000fffc0 }, + { } +--- a/drivers/net/phy/cortina.c ++++ b/drivers/net/phy/cortina.c +@@ -87,7 +87,7 @@ static struct phy_driver cortina_driver[ + + module_phy_driver(cortina_driver); + +-static struct mdio_device_id __maybe_unused cortina_tbl[] = { ++static const struct mdio_device_id __maybe_unused cortina_tbl[] = { + { PHY_ID_CS4340, 0xffffffff}, + {}, + }; +--- a/drivers/net/phy/davicom.c ++++ b/drivers/net/phy/davicom.c +@@ -209,7 +209,7 @@ static struct phy_driver dm91xx_driver[] + + module_phy_driver(dm91xx_driver); + +-static struct mdio_device_id __maybe_unused davicom_tbl[] = { ++static const struct mdio_device_id __maybe_unused davicom_tbl[] = { + { 0x0181b880, 0x0ffffff0 }, + { 0x0181b8b0, 0x0ffffff0 }, + { 0x0181b8a0, 0x0ffffff0 }, +--- a/drivers/net/phy/dp83640.c ++++ b/drivers/net/phy/dp83640.c +@@ -1548,7 +1548,7 @@ MODULE_LICENSE("GPL"); + module_init(dp83640_init); + module_exit(dp83640_exit); + +-static struct mdio_device_id __maybe_unused dp83640_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83640_tbl[] = { + { DP83640_PHY_ID, 0xfffffff0 }, + { } + }; +--- a/drivers/net/phy/dp83822.c ++++ b/drivers/net/phy/dp83822.c +@@ -825,7 +825,7 @@ static struct phy_driver dp83822_driver[ + }; + module_phy_driver(dp83822_driver); + +-static struct mdio_device_id __maybe_unused dp83822_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83822_tbl[] = { + { DP83822_PHY_ID, 0xfffffff0 }, + { DP83825I_PHY_ID, 0xfffffff0 }, + { DP83826C_PHY_ID, 0xfffffff0 }, +--- a/drivers/net/phy/dp83848.c ++++ b/drivers/net/phy/dp83848.c +@@ -123,7 +123,7 @@ static int dp83848_config_init(struct ph + return 0; + } + +-static struct mdio_device_id __maybe_unused dp83848_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83848_tbl[] = { + { TI_DP83848C_PHY_ID, 0xfffffff0 }, + { NS_DP83848C_PHY_ID, 0xfffffff0 }, + { TI_DP83620_PHY_ID, 0xfffffff0 }, +--- a/drivers/net/phy/dp83867.c ++++ b/drivers/net/phy/dp83867.c +@@ -1210,7 +1210,7 @@ static struct phy_driver dp83867_driver[ + }; + module_phy_driver(dp83867_driver); + +-static struct mdio_device_id __maybe_unused dp83867_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83867_tbl[] = { + { DP83867_PHY_ID, 0xfffffff0 }, + { } + }; +--- a/drivers/net/phy/dp83869.c ++++ b/drivers/net/phy/dp83869.c +@@ -928,7 +928,7 @@ static struct phy_driver dp83869_driver[ + }; + module_phy_driver(dp83869_driver); + +-static struct mdio_device_id __maybe_unused dp83869_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83869_tbl[] = { + { PHY_ID_MATCH_MODEL(DP83869_PHY_ID) }, + { PHY_ID_MATCH_MODEL(DP83561_PHY_ID) }, + { } +--- a/drivers/net/phy/dp83tc811.c ++++ b/drivers/net/phy/dp83tc811.c +@@ -403,7 +403,7 @@ static struct phy_driver dp83811_driver[ + }; + module_phy_driver(dp83811_driver); + +-static struct mdio_device_id __maybe_unused dp83811_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83811_tbl[] = { + { DP83TC811_PHY_ID, 0xfffffff0 }, + { }, + }; +--- a/drivers/net/phy/dp83td510.c ++++ b/drivers/net/phy/dp83td510.c +@@ -605,7 +605,7 @@ static struct phy_driver dp83td510_drive + } }; + module_phy_driver(dp83td510_driver); + +-static struct mdio_device_id __maybe_unused dp83td510_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83td510_tbl[] = { + { PHY_ID_MATCH_MODEL(DP83TD510E_PHY_ID) }, + { } + }; +--- a/drivers/net/phy/dp83tg720.c ++++ b/drivers/net/phy/dp83tg720.c +@@ -361,7 +361,7 @@ static struct phy_driver dp83tg720_drive + } }; + module_phy_driver(dp83tg720_driver); + +-static struct mdio_device_id __maybe_unused dp83tg720_tbl[] = { ++static const struct mdio_device_id __maybe_unused dp83tg720_tbl[] = { + { PHY_ID_MATCH_MODEL(DP83TG720S_PHY_ID) }, + { } + }; +--- a/drivers/net/phy/et1011c.c ++++ b/drivers/net/phy/et1011c.c +@@ -94,7 +94,7 @@ static struct phy_driver et1011c_driver[ + + module_phy_driver(et1011c_driver); + +-static struct mdio_device_id __maybe_unused et1011c_tbl[] = { ++static const struct mdio_device_id __maybe_unused et1011c_tbl[] = { + { 0x0282f014, 0xfffffff0 }, + { } + }; +--- a/drivers/net/phy/icplus.c ++++ b/drivers/net/phy/icplus.c +@@ -624,7 +624,7 @@ static struct phy_driver icplus_driver[] + + module_phy_driver(icplus_driver); + +-static struct mdio_device_id __maybe_unused icplus_tbl[] = { ++static const struct mdio_device_id __maybe_unused icplus_tbl[] = { + { PHY_ID_MATCH_MODEL(IP175C_PHY_ID) }, + { PHY_ID_MATCH_MODEL(IP1001_PHY_ID) }, + { PHY_ID_MATCH_EXACT(IP101A_PHY_ID) }, +--- a/drivers/net/phy/intel-xway.c ++++ b/drivers/net/phy/intel-xway.c +@@ -456,7 +456,7 @@ static struct phy_driver xway_gphy[] = { + }; + module_phy_driver(xway_gphy); + +-static struct mdio_device_id __maybe_unused xway_gphy_tbl[] = { ++static const struct mdio_device_id __maybe_unused xway_gphy_tbl[] = { + { PHY_ID_PHY11G_1_3, 0xffffffff }, + { PHY_ID_PHY22F_1_3, 0xffffffff }, + { PHY_ID_PHY11G_1_4, 0xffffffff }, +--- a/drivers/net/phy/lxt.c ++++ b/drivers/net/phy/lxt.c +@@ -348,7 +348,7 @@ static struct phy_driver lxt97x_driver[] + + module_phy_driver(lxt97x_driver); + +-static struct mdio_device_id __maybe_unused lxt_tbl[] = { ++static const struct mdio_device_id __maybe_unused lxt_tbl[] = { + { 0x78100000, 0xfffffff0 }, + { 0x001378e0, 0xfffffff0 }, + { 0x00137a10, 0xfffffff0 }, +--- a/drivers/net/phy/marvell-88q2xxx.c ++++ b/drivers/net/phy/marvell-88q2xxx.c +@@ -940,7 +940,7 @@ static struct phy_driver mv88q2xxx_drive + + module_phy_driver(mv88q2xxx_driver); + +-static struct mdio_device_id __maybe_unused mv88q2xxx_tbl[] = { ++static const struct mdio_device_id __maybe_unused mv88q2xxx_tbl[] = { + { MARVELL_PHY_ID_88Q2110, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88Q2220, MARVELL_PHY_ID_MASK }, + { /*sentinel*/ } +--- a/drivers/net/phy/marvell-88x2222.c ++++ b/drivers/net/phy/marvell-88x2222.c +@@ -613,7 +613,7 @@ static struct phy_driver mv2222_drivers[ + }; + module_phy_driver(mv2222_drivers); + +-static struct mdio_device_id __maybe_unused mv2222_tbl[] = { ++static const struct mdio_device_id __maybe_unused mv2222_tbl[] = { + { MARVELL_PHY_ID_88X2222, MARVELL_PHY_ID_MASK }, + { } + }; +--- a/drivers/net/phy/marvell.c ++++ b/drivers/net/phy/marvell.c +@@ -4218,7 +4218,7 @@ static struct phy_driver marvell_drivers + + module_phy_driver(marvell_drivers); + +-static struct mdio_device_id __maybe_unused marvell_tbl[] = { ++static const struct mdio_device_id __maybe_unused marvell_tbl[] = { + { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88E3082, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK }, +--- a/drivers/net/phy/marvell10g.c ++++ b/drivers/net/phy/marvell10g.c +@@ -1484,7 +1484,7 @@ static struct phy_driver mv3310_drivers[ + + module_phy_driver(mv3310_drivers); + +-static struct mdio_device_id __maybe_unused mv3310_tbl[] = { ++static const struct mdio_device_id __maybe_unused mv3310_tbl[] = { + { MARVELL_PHY_ID_88X3310, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88E2110, MARVELL_PHY_ID_MASK }, + { }, +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -1356,7 +1356,7 @@ static struct phy_driver mtk_socphy_driv + + module_phy_driver(mtk_socphy_driver); + +-static struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = { ++static const struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = { + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) }, + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) }, + { } +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -93,7 +93,7 @@ static struct phy_driver mtk_gephy_drive + + module_phy_driver(mtk_gephy_driver); + +-static struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = { ++static const struct mdio_device_id __maybe_unused mtk_gephy_tbl[] = { + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7530) }, + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7531) }, + { } +--- a/drivers/net/phy/meson-gxl.c ++++ b/drivers/net/phy/meson-gxl.c +@@ -221,7 +221,7 @@ static struct phy_driver meson_gxl_phy[] + }, + }; + +-static struct mdio_device_id __maybe_unused meson_gxl_tbl[] = { ++static const struct mdio_device_id __maybe_unused meson_gxl_tbl[] = { + { PHY_ID_MATCH_VENDOR(0x01814400) }, + { PHY_ID_MATCH_VENDOR(0x01803301) }, + { } +--- a/drivers/net/phy/micrel.c ++++ b/drivers/net/phy/micrel.c +@@ -5835,7 +5835,7 @@ MODULE_DESCRIPTION("Micrel PHY driver"); + MODULE_AUTHOR("David J. Choi"); + MODULE_LICENSE("GPL"); + +-static struct mdio_device_id __maybe_unused micrel_tbl[] = { ++static const struct mdio_device_id __maybe_unused micrel_tbl[] = { + { PHY_ID_KSZ9021, 0x000ffffe }, + { PHY_ID_KSZ9031, MICREL_PHY_ID_MASK }, + { PHY_ID_KSZ9131, MICREL_PHY_ID_MASK }, +--- a/drivers/net/phy/microchip.c ++++ b/drivers/net/phy/microchip.c +@@ -509,7 +509,7 @@ static struct phy_driver microchip_phy_d + + module_phy_driver(microchip_phy_driver); + +-static struct mdio_device_id __maybe_unused microchip_tbl[] = { ++static const struct mdio_device_id __maybe_unused microchip_tbl[] = { + { 0x0007c132, 0xfffffff2 }, + { PHY_ID_MATCH_MODEL(PHY_ID_LAN937X_TX) }, + { } +--- a/drivers/net/phy/microchip_t1.c ++++ b/drivers/net/phy/microchip_t1.c +@@ -1886,7 +1886,7 @@ static struct phy_driver microchip_t1_ph + + module_phy_driver(microchip_t1_phy_driver); + +-static struct mdio_device_id __maybe_unused microchip_t1_tbl[] = { ++static const struct mdio_device_id __maybe_unused microchip_t1_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_LAN87XX) }, + { PHY_ID_MATCH_MODEL(PHY_ID_LAN937X) }, + { PHY_ID_MATCH_MODEL(PHY_ID_LAN887X) }, +--- a/drivers/net/phy/microchip_t1s.c ++++ b/drivers/net/phy/microchip_t1s.c +@@ -323,7 +323,7 @@ static struct phy_driver microchip_t1s_d + + module_phy_driver(microchip_t1s_driver); + +-static struct mdio_device_id __maybe_unused tbl[] = { ++static const struct mdio_device_id __maybe_unused tbl[] = { + { PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVB1) }, + { PHY_ID_MATCH_EXACT(PHY_ID_LAN865X_REVB0) }, + { } +--- a/drivers/net/phy/mscc/mscc_main.c ++++ b/drivers/net/phy/mscc/mscc_main.c +@@ -2710,7 +2710,7 @@ static struct phy_driver vsc85xx_driver[ + + module_phy_driver(vsc85xx_driver); + +-static struct mdio_device_id __maybe_unused vsc85xx_tbl[] = { ++static const struct mdio_device_id __maybe_unused vsc85xx_tbl[] = { + { PHY_ID_MATCH_VENDOR(PHY_VENDOR_MSCC) }, + { } + }; +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -1047,7 +1047,7 @@ static struct phy_driver gpy_drivers[] = + }; + module_phy_driver(gpy_drivers); + +-static struct mdio_device_id __maybe_unused gpy_tbl[] = { ++static const struct mdio_device_id __maybe_unused gpy_tbl[] = { + {PHY_ID_MATCH_MODEL(PHY_ID_GPY2xx)}, + {PHY_ID_GPY115B, PHY_ID_GPYx15B_MASK}, + {PHY_ID_MATCH_MODEL(PHY_ID_GPY115C)}, +--- a/drivers/net/phy/national.c ++++ b/drivers/net/phy/national.c +@@ -173,7 +173,7 @@ MODULE_DESCRIPTION("NatSemi PHY driver") + MODULE_AUTHOR("Stuart Menefy"); + MODULE_LICENSE("GPL"); + +-static struct mdio_device_id __maybe_unused ns_tbl[] = { ++static const struct mdio_device_id __maybe_unused ns_tbl[] = { + { DP83865_PHY_ID, 0xfffffff0 }, + { } + }; +--- a/drivers/net/phy/ncn26000.c ++++ b/drivers/net/phy/ncn26000.c +@@ -159,7 +159,7 @@ static struct phy_driver ncn26000_driver + + module_phy_driver(ncn26000_driver); + +-static struct mdio_device_id __maybe_unused ncn26000_tbl[] = { ++static const struct mdio_device_id __maybe_unused ncn26000_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_NCN26000) }, + { } + }; +--- a/drivers/net/phy/nxp-c45-tja11xx.c ++++ b/drivers/net/phy/nxp-c45-tja11xx.c +@@ -2102,7 +2102,7 @@ static struct phy_driver nxp_c45_driver[ + + module_phy_driver(nxp_c45_driver); + +-static struct mdio_device_id __maybe_unused nxp_c45_tbl[] = { ++static const struct mdio_device_id __maybe_unused nxp_c45_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103) }, + { PHY_ID_MATCH_MODEL(PHY_ID_TJA_1120) }, + { /*sentinel*/ }, +--- a/drivers/net/phy/nxp-cbtx.c ++++ b/drivers/net/phy/nxp-cbtx.c +@@ -215,7 +215,7 @@ static struct phy_driver cbtx_driver[] = + + module_phy_driver(cbtx_driver); + +-static struct mdio_device_id __maybe_unused cbtx_tbl[] = { ++static const struct mdio_device_id __maybe_unused cbtx_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_CBTX_SJA1110) }, + { }, + }; +--- a/drivers/net/phy/nxp-tja11xx.c ++++ b/drivers/net/phy/nxp-tja11xx.c +@@ -888,7 +888,7 @@ static struct phy_driver tja11xx_driver[ + + module_phy_driver(tja11xx_driver); + +-static struct mdio_device_id __maybe_unused tja11xx_tbl[] = { ++static const struct mdio_device_id __maybe_unused tja11xx_tbl[] = { + { PHY_ID_MATCH_MODEL(PHY_ID_TJA1100) }, + { PHY_ID_MATCH_MODEL(PHY_ID_TJA1101) }, + { PHY_ID_MATCH_MODEL(PHY_ID_TJA1102) }, +--- a/drivers/net/phy/qcom/at803x.c ++++ b/drivers/net/phy/qcom/at803x.c +@@ -1071,7 +1071,7 @@ static struct phy_driver at803x_driver[] + + module_phy_driver(at803x_driver); + +-static struct mdio_device_id __maybe_unused atheros_tbl[] = { ++static const struct mdio_device_id __maybe_unused atheros_tbl[] = { + { ATH8030_PHY_ID, AT8030_PHY_ID_MASK }, + { PHY_ID_MATCH_EXACT(ATH8031_PHY_ID) }, + { PHY_ID_MATCH_EXACT(ATH8032_PHY_ID) }, +--- a/drivers/net/phy/qcom/qca807x.c ++++ b/drivers/net/phy/qcom/qca807x.c +@@ -828,7 +828,7 @@ static struct phy_driver qca807x_drivers + }; + module_phy_driver(qca807x_drivers); + +-static struct mdio_device_id __maybe_unused qca807x_tbl[] = { ++static const struct mdio_device_id __maybe_unused qca807x_tbl[] = { + { PHY_ID_MATCH_EXACT(PHY_ID_QCA8072) }, + { PHY_ID_MATCH_EXACT(PHY_ID_QCA8075) }, + { } +--- a/drivers/net/phy/qcom/qca808x.c ++++ b/drivers/net/phy/qcom/qca808x.c +@@ -655,7 +655,7 @@ static struct phy_driver qca808x_driver[ + + module_phy_driver(qca808x_driver); + +-static struct mdio_device_id __maybe_unused qca808x_tbl[] = { ++static const struct mdio_device_id __maybe_unused qca808x_tbl[] = { + { PHY_ID_MATCH_EXACT(QCA8081_PHY_ID) }, + { } + }; +--- a/drivers/net/phy/qcom/qca83xx.c ++++ b/drivers/net/phy/qcom/qca83xx.c +@@ -261,7 +261,7 @@ static struct phy_driver qca83xx_driver[ + + module_phy_driver(qca83xx_driver); + +-static struct mdio_device_id __maybe_unused qca83xx_tbl[] = { ++static const struct mdio_device_id __maybe_unused qca83xx_tbl[] = { + { PHY_ID_MATCH_EXACT(QCA8337_PHY_ID) }, + { PHY_ID_MATCH_EXACT(QCA8327_A_PHY_ID) }, + { PHY_ID_MATCH_EXACT(QCA8327_B_PHY_ID) }, +--- a/drivers/net/phy/qsemi.c ++++ b/drivers/net/phy/qsemi.c +@@ -155,7 +155,7 @@ static struct phy_driver qs6612_driver[] + + module_phy_driver(qs6612_driver); + +-static struct mdio_device_id __maybe_unused qs6612_tbl[] = { ++static const struct mdio_device_id __maybe_unused qs6612_tbl[] = { + { 0x00181440, 0xfffffff0 }, + { } + }; +--- a/drivers/net/phy/rockchip.c ++++ b/drivers/net/phy/rockchip.c +@@ -188,7 +188,7 @@ static struct phy_driver rockchip_phy_dr + + module_phy_driver(rockchip_phy_driver); + +-static struct mdio_device_id __maybe_unused rockchip_phy_tbl[] = { ++static const struct mdio_device_id __maybe_unused rockchip_phy_tbl[] = { + { INTERNAL_EPHY_ID, 0xfffffff0 }, + { } + }; +--- a/drivers/net/phy/smsc.c ++++ b/drivers/net/phy/smsc.c +@@ -885,7 +885,7 @@ MODULE_DESCRIPTION("SMSC PHY driver"); + MODULE_AUTHOR("Herbert Valerio Riedel"); + MODULE_LICENSE("GPL"); + +-static struct mdio_device_id __maybe_unused smsc_tbl[] = { ++static const struct mdio_device_id __maybe_unused smsc_tbl[] = { + { 0x0007c0a0, 0xfffffff0 }, + { 0x0007c0b0, 0xfffffff0 }, + { 0x0007c0c0, 0xfffffff0 }, +--- a/drivers/net/phy/ste10Xp.c ++++ b/drivers/net/phy/ste10Xp.c +@@ -124,7 +124,7 @@ static struct phy_driver ste10xp_pdriver + + module_phy_driver(ste10xp_pdriver); + +-static struct mdio_device_id __maybe_unused ste10Xp_tbl[] = { ++static const struct mdio_device_id __maybe_unused ste10Xp_tbl[] = { + { STE101P_PHY_ID, 0xfffffff0 }, + { STE100P_PHY_ID, 0xffffffff }, + { } +--- a/drivers/net/phy/teranetics.c ++++ b/drivers/net/phy/teranetics.c +@@ -87,7 +87,7 @@ static struct phy_driver teranetics_driv + + module_phy_driver(teranetics_driver); + +-static struct mdio_device_id __maybe_unused teranetics_tbl[] = { ++static const struct mdio_device_id __maybe_unused teranetics_tbl[] = { + { PHY_ID_TN2020, 0xffffffff }, + { } + }; +--- a/drivers/net/phy/uPD60620.c ++++ b/drivers/net/phy/uPD60620.c +@@ -90,7 +90,7 @@ static struct phy_driver upd60620_driver + + module_phy_driver(upd60620_driver); + +-static struct mdio_device_id __maybe_unused upd60620_tbl[] = { ++static const struct mdio_device_id __maybe_unused upd60620_tbl[] = { + { UPD60620_PHY_ID, 0xfffffffe }, + { } + }; +--- a/drivers/net/phy/vitesse.c ++++ b/drivers/net/phy/vitesse.c +@@ -674,7 +674,7 @@ static struct phy_driver vsc82xx_driver[ + + module_phy_driver(vsc82xx_driver); + +-static struct mdio_device_id __maybe_unused vitesse_tbl[] = { ++static const struct mdio_device_id __maybe_unused vitesse_tbl[] = { + { PHY_ID_VSC8234, 0x000ffff0 }, + { PHY_ID_VSC8244, 0x000fffc0 }, + { PHY_ID_VSC8572, 0x000ffff0 }, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-10-v6.15-net-phy-mediatek-Change-to-more-meaningful-macros.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-10-v6.15-net-phy-mediatek-Change-to-more-meaningful-macros.patch new file mode 100755 index 0000000..545e929 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-10-v6.15-net-phy-mediatek-Change-to-more-meaningful-macros.patch @@ -0,0 +1,146 @@ +From 7e06c3dbfa5f1e39eba92eb79d854fab2a7ad5fe Mon Sep 17 00:00:00 2001 +From: Sky Huang +Date: Thu, 13 Feb 2025 16:05:49 +0800 +Subject: [PATCH 10/20] net: phy: mediatek: Change to more meaningful macros + +Replace magic number with more meaningful macros in mtk-ge.c. +Also, move some common macros into mtk-phy-lib.c. + +Signed-off-by: Sky Huang +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250213080553.921434-2-SkyLake.Huang@mediatek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/mtk-ge-soc.c | 1 - + drivers/net/phy/mediatek/mtk-ge.c | 71 +++++++++++++++++++++------ + drivers/net/phy/mediatek/mtk.h | 2 + + 3 files changed, 57 insertions(+), 17 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -24,7 +24,6 @@ + #define MTK_PHY_SMI_DET_ON_THRESH_MASK GENMASK(13, 8) + + #define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 +-#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 + + #define ANALOG_INTERNAL_OPERATION_MAX_US 20 + #define TXRESERVE_MIN 0 +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -8,18 +8,38 @@ + #define MTK_GPHY_ID_MT7530 0x03a29412 + #define MTK_GPHY_ID_MT7531 0x03a29441 + +-#define MTK_EXT_PAGE_ACCESS 0x1f +-#define MTK_PHY_PAGE_STANDARD 0x0000 +-#define MTK_PHY_PAGE_EXTENDED 0x0001 +-#define MTK_PHY_PAGE_EXTENDED_2 0x0002 +-#define MTK_PHY_PAGE_EXTENDED_3 0x0003 +-#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 +-#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 ++#define MTK_PHY_PAGE_EXTENDED_1 0x0001 ++#define MTK_PHY_AUX_CTRL_AND_STATUS 0x14 ++#define MTK_PHY_ENABLE_DOWNSHIFT BIT(4) ++ ++#define MTK_PHY_PAGE_EXTENDED_2 0x0002 ++#define MTK_PHY_PAGE_EXTENDED_3 0x0003 ++#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG11 0x11 ++ ++#define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 ++ ++/* Registers on MDIO_MMD_VEND1 */ ++#define MTK_PHY_GBE_MODE_TX_DELAY_SEL 0x13 ++#define MTK_PHY_TEST_MODE_TX_DELAY_SEL 0x14 ++#define MTK_TX_DELAY_PAIR_B_MASK GENMASK(10, 8) ++#define MTK_TX_DELAY_PAIR_D_MASK GENMASK(2, 0) ++ ++#define MTK_PHY_MCC_CTRL_AND_TX_POWER_CTRL 0xa6 ++#define MTK_MCC_NEARECHO_OFFSET_MASK GENMASK(15, 8) ++ ++#define MTK_PHY_RXADC_CTRL_RG7 0xc6 ++#define MTK_PHY_DA_AD_BUF_BIAS_LP_MASK GENMASK(9, 8) ++ ++#define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG123 0x123 ++#define MTK_PHY_LPI_NORM_MSE_LO_THRESH100_MASK GENMASK(15, 8) ++#define MTK_PHY_LPI_NORM_MSE_HI_THRESH100_MASK GENMASK(7, 0) + + static void mtk_gephy_config_init(struct phy_device *phydev) + { + /* Enable HW auto downshift */ +- phy_modify_paged(phydev, MTK_PHY_PAGE_EXTENDED, 0x14, 0, BIT(4)); ++ phy_modify_paged(phydev, MTK_PHY_PAGE_EXTENDED_1, ++ MTK_PHY_AUX_CTRL_AND_STATUS, ++ 0, MTK_PHY_ENABLE_DOWNSHIFT); + + /* Increase SlvDPSready time */ + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +@@ -29,10 +49,20 @@ static void mtk_gephy_config_init(struct + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); + + /* Adjust 100_mse_threshold */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x123, 0xffff); +- +- /* Disable mcc */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xa6, 0x300); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG123, ++ MTK_PHY_LPI_NORM_MSE_LO_THRESH100_MASK | ++ MTK_PHY_LPI_NORM_MSE_HI_THRESH100_MASK, ++ FIELD_PREP(MTK_PHY_LPI_NORM_MSE_LO_THRESH100_MASK, ++ 0xff) | ++ FIELD_PREP(MTK_PHY_LPI_NORM_MSE_HI_THRESH100_MASK, ++ 0xff)); ++ ++ /* If echo time is narrower than 0x3, it will be regarded as noise */ ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ MTK_PHY_MCC_CTRL_AND_TX_POWER_CTRL, ++ MTK_MCC_NEARECHO_OFFSET_MASK, ++ FIELD_PREP(MTK_MCC_NEARECHO_OFFSET_MASK, 0x3)); + } + + static int mt7530_phy_config_init(struct phy_device *phydev) +@@ -40,7 +70,8 @@ static int mt7530_phy_config_init(struct + mtk_gephy_config_init(phydev); + + /* Increase post_update_timer */ +- phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_3, 0x11, 0x4b); ++ phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_3, ++ MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG11, 0x4b); + + return 0; + } +@@ -51,11 +82,19 @@ static int mt7531_phy_config_init(struct + + /* PHY link down power saving enable */ + phy_set_bits(phydev, 0x17, BIT(4)); +- phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 0xc6, 0x300); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RXADC_CTRL_RG7, ++ MTK_PHY_DA_AD_BUF_BIAS_LP_MASK, ++ FIELD_PREP(MTK_PHY_DA_AD_BUF_BIAS_LP_MASK, 0x3)); + + /* Set TX Pair delay selection */ +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x13, 0x404); +- phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x14, 0x404); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_GBE_MODE_TX_DELAY_SEL, ++ MTK_TX_DELAY_PAIR_B_MASK | MTK_TX_DELAY_PAIR_D_MASK, ++ FIELD_PREP(MTK_TX_DELAY_PAIR_B_MASK, 0x4) | ++ FIELD_PREP(MTK_TX_DELAY_PAIR_D_MASK, 0x4)); ++ phy_modify_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_TEST_MODE_TX_DELAY_SEL, ++ MTK_TX_DELAY_PAIR_B_MASK | MTK_TX_DELAY_PAIR_D_MASK, ++ FIELD_PREP(MTK_TX_DELAY_PAIR_B_MASK, 0x4) | ++ FIELD_PREP(MTK_TX_DELAY_PAIR_D_MASK, 0x4)); + + return 0; + } +--- a/drivers/net/phy/mediatek/mtk.h ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -9,6 +9,8 @@ + #define _MTK_EPHY_H_ + + #define MTK_EXT_PAGE_ACCESS 0x1f ++#define MTK_PHY_PAGE_STANDARD 0x0000 ++#define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 + + /* Registers on MDIO_MMD_VEND2 */ + #define MTK_PHY_LED0_ON_CTRL 0x24 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-11-v6.15-net-phy-mediatek-Add-token-ring-access-helper-functi.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-11-v6.15-net-phy-mediatek-Add-token-ring-access-helper-functi.patch new file mode 100755 index 0000000..40ce29f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-11-v6.15-net-phy-mediatek-Add-token-ring-access-helper-functi.patch @@ -0,0 +1,448 @@ +From 6e7370079669b0d55c9464bb7c3fb8fb7368b912 Mon Sep 17 00:00:00 2001 +From: Sky Huang +Date: Thu, 13 Feb 2025 16:05:50 +0800 +Subject: [PATCH 11/20] net: phy: mediatek: Add token ring access helper + functions in mtk-phy-lib + +This patch adds TR(token ring) manipulations and adds correct +macro names for those magic numbers. TR is a way to access +proprietary registers on page 52b5. Use these helper functions +so we can see which fields we're going to modify/set/clear. + +TR functions with __* prefix mean that the operations inside +aren't wrapped by page select/restore functions. + +This patch doesn't really change registers' settings but just +enhances readability and maintainability. + +Signed-off-by: Sky Huang +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250213080553.921434-3-SkyLake.Huang@mediatek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/mtk-ge-soc.c | 231 +++++++++++++++++-------- + drivers/net/phy/mediatek/mtk-ge.c | 11 +- + drivers/net/phy/mediatek/mtk-phy-lib.c | 63 +++++++ + drivers/net/phy/mediatek/mtk.h | 5 + + 4 files changed, 230 insertions(+), 80 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -25,6 +25,90 @@ + + #define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 + ++/* Registers on Token Ring debug nodes */ ++/* ch_addr = 0x0, node_addr = 0x7, data_addr = 0x15 */ ++/* NormMseLoThresh */ ++#define NORMAL_MSE_LO_THRESH_MASK GENMASK(15, 8) ++ ++/* ch_addr = 0x0, node_addr = 0xf, data_addr = 0x3c */ ++/* RemAckCntLimitCtrl */ ++#define REMOTE_ACK_COUNT_LIMIT_CTRL_MASK GENMASK(2, 1) ++ ++/* ch_addr = 0x1, node_addr = 0xd, data_addr = 0x20 */ ++/* VcoSlicerThreshBitsHigh */ ++#define VCO_SLICER_THRESH_HIGH_MASK GENMASK(23, 0) ++ ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x0 */ ++/* DfeTailEnableVgaThresh1000 */ ++#define DFE_TAIL_EANBLE_VGA_TRHESH_1000 GENMASK(5, 1) ++ ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x1 */ ++/* MrvlTrFix100Kp */ ++#define MRVL_TR_FIX_100KP_MASK GENMASK(22, 20) ++/* MrvlTrFix100Kf */ ++#define MRVL_TR_FIX_100KF_MASK GENMASK(19, 17) ++/* MrvlTrFix1000Kp */ ++#define MRVL_TR_FIX_1000KP_MASK GENMASK(16, 14) ++/* MrvlTrFix1000Kf */ ++#define MRVL_TR_FIX_1000KF_MASK GENMASK(13, 11) ++ ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x12 */ ++/* VgaDecRate */ ++#define VGA_DECIMATION_RATE_MASK GENMASK(8, 5) ++ ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x17 */ ++/* SlvDSPreadyTime */ ++#define SLAVE_DSP_READY_TIME_MASK GENMASK(22, 15) ++/* MasDSPreadyTime */ ++#define MASTER_DSP_READY_TIME_MASK GENMASK(14, 7) ++ ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x20 */ ++/* ResetSyncOffset */ ++#define RESET_SYNC_OFFSET_MASK GENMASK(11, 8) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x0 */ ++/* FfeUpdGainForceVal */ ++#define FFE_UPDATE_GAIN_FORCE_VAL_MASK GENMASK(9, 7) ++/* FfeUpdGainForce */ ++#define FFE_UPDATE_GAIN_FORCE BIT(6) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x6 */ ++/* SS: Steady-state, KP: Proportional Gain */ ++/* SSTrKp100 */ ++#define SS_TR_KP100_MASK GENMASK(21, 19) ++/* SSTrKf100 */ ++#define SS_TR_KF100_MASK GENMASK(18, 16) ++/* SSTrKp1000Mas */ ++#define SS_TR_KP1000_MASTER_MASK GENMASK(15, 13) ++/* SSTrKf1000Mas */ ++#define SS_TR_KF1000_MASTER_MASK GENMASK(12, 10) ++/* SSTrKp1000Slv */ ++#define SS_TR_KP1000_SLAVE_MASK GENMASK(9, 7) ++/* SSTrKf1000Slv */ ++#define SS_TR_KF1000_SLAVE_MASK GENMASK(6, 4) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xd */ ++/* RegEEE_st2TrKf1000 */ ++#define EEE1000_STAGE2_TR_KF_MASK GENMASK(13, 11) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xf */ ++/* RegEEE_slv_waketr_timer_tar */ ++#define SLAVE_WAKETR_TIMER_MASK GENMASK(20, 11) ++/* RegEEE_slv_remtx_timer_tar */ ++#define SLAVE_REMTX_TIMER_MASK GENMASK(10, 1) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x10 */ ++/* RegEEE_slv_wake_int_timer_tar */ ++#define SLAVE_WAKEINT_TIMER_MASK GENMASK(10, 1) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x14 */ ++/* RegEEE_trfreeze_timer2 */ ++#define TR_FREEZE_TIMER2_MASK GENMASK(9, 0) ++ ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x1c */ ++/* RegEEE100Stg1_tar */ ++#define EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK GENMASK(8, 0) ++ + #define ANALOG_INTERNAL_OPERATION_MAX_US 20 + #define TXRESERVE_MIN 0 + #define TXRESERVE_MAX 7 +@@ -700,40 +784,41 @@ restore: + static void mt798x_phy_common_finetune(struct phy_device *phydev) + { + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* SlvDSPreadyTime = 24, MasDSPreadyTime = 24 */ +- __phy_write(phydev, 0x11, 0xc71); +- __phy_write(phydev, 0x12, 0xc); +- __phy_write(phydev, 0x10, 0x8fae); ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x17, ++ SLAVE_DSP_READY_TIME_MASK | MASTER_DSP_READY_TIME_MASK, ++ FIELD_PREP(SLAVE_DSP_READY_TIME_MASK, 0x18) | ++ FIELD_PREP(MASTER_DSP_READY_TIME_MASK, 0x18)); + + /* EnabRandUpdTrig = 1 */ + __phy_write(phydev, 0x11, 0x2f00); + __phy_write(phydev, 0x12, 0xe); + __phy_write(phydev, 0x10, 0x8fb0); + +- /* NormMseLoThresh = 85 */ +- __phy_write(phydev, 0x11, 0x55a0); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x83aa); +- +- /* FfeUpdGainForce = 1(Enable), FfeUpdGainForceVal = 4 */ +- __phy_write(phydev, 0x11, 0x240); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x9680); ++ __mtk_tr_modify(phydev, 0x0, 0x7, 0x15, ++ NORMAL_MSE_LO_THRESH_MASK, ++ FIELD_PREP(NORMAL_MSE_LO_THRESH_MASK, 0x55)); ++ ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0x0, ++ FFE_UPDATE_GAIN_FORCE_VAL_MASK, ++ FIELD_PREP(FFE_UPDATE_GAIN_FORCE_VAL_MASK, 0x4) | ++ FFE_UPDATE_GAIN_FORCE); + + /* TrFreeze = 0 (mt7988 default) */ + __phy_write(phydev, 0x11, 0x0); + __phy_write(phydev, 0x12, 0x0); + __phy_write(phydev, 0x10, 0x9686); + +- /* SSTrKp100 = 5 */ +- /* SSTrKf100 = 6 */ +- /* SSTrKp1000Mas = 5 */ +- /* SSTrKf1000Mas = 6 */ +- /* SSTrKp1000Slv = 5 */ +- /* SSTrKf1000Slv = 6 */ +- __phy_write(phydev, 0x11, 0xbaef); +- __phy_write(phydev, 0x12, 0x2e); +- __phy_write(phydev, 0x10, 0x968c); ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0x6, ++ SS_TR_KP100_MASK | SS_TR_KF100_MASK | ++ SS_TR_KP1000_MASTER_MASK | SS_TR_KF1000_MASTER_MASK | ++ SS_TR_KP1000_SLAVE_MASK | SS_TR_KF1000_SLAVE_MASK, ++ FIELD_PREP(SS_TR_KP100_MASK, 0x5) | ++ FIELD_PREP(SS_TR_KF100_MASK, 0x6) | ++ FIELD_PREP(SS_TR_KP1000_MASTER_MASK, 0x5) | ++ FIELD_PREP(SS_TR_KF1000_MASTER_MASK, 0x6) | ++ FIELD_PREP(SS_TR_KP1000_SLAVE_MASK, 0x5) | ++ FIELD_PREP(SS_TR_KF1000_SLAVE_MASK, 0x6)); ++ + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); + } + +@@ -756,27 +841,29 @@ static void mt7981_phy_finetune(struct p + } + + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* ResetSyncOffset = 6 */ +- __phy_write(phydev, 0x11, 0x600); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x8fc0); +- +- /* VgaDecRate = 1 */ +- __phy_write(phydev, 0x11, 0x4c2a); +- __phy_write(phydev, 0x12, 0x3e); +- __phy_write(phydev, 0x10, 0x8fa4); ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x20, ++ RESET_SYNC_OFFSET_MASK, ++ FIELD_PREP(RESET_SYNC_OFFSET_MASK, 0x6)); ++ ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x12, ++ VGA_DECIMATION_RATE_MASK, ++ FIELD_PREP(VGA_DECIMATION_RATE_MASK, 0x1)); + + /* MrvlTrFix100Kp = 3, MrvlTrFix100Kf = 2, + * MrvlTrFix1000Kp = 3, MrvlTrFix1000Kf = 2 + */ +- __phy_write(phydev, 0x11, 0xd10a); +- __phy_write(phydev, 0x12, 0x34); +- __phy_write(phydev, 0x10, 0x8f82); ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x1, ++ MRVL_TR_FIX_100KP_MASK | MRVL_TR_FIX_100KF_MASK | ++ MRVL_TR_FIX_1000KP_MASK | MRVL_TR_FIX_1000KF_MASK, ++ FIELD_PREP(MRVL_TR_FIX_100KP_MASK, 0x3) | ++ FIELD_PREP(MRVL_TR_FIX_100KF_MASK, 0x2) | ++ FIELD_PREP(MRVL_TR_FIX_1000KP_MASK, 0x3) | ++ FIELD_PREP(MRVL_TR_FIX_1000KF_MASK, 0x2)); + + /* VcoSlicerThreshBitsHigh */ +- __phy_write(phydev, 0x11, 0x5555); +- __phy_write(phydev, 0x12, 0x55); +- __phy_write(phydev, 0x10, 0x8ec0); ++ __mtk_tr_modify(phydev, 0x1, 0xd, 0x20, ++ VCO_SLICER_THRESH_HIGH_MASK, ++ FIELD_PREP(VCO_SLICER_THRESH_HIGH_MASK, 0x555555)); + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); + + /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 9 */ +@@ -828,25 +915,23 @@ static void mt7988_phy_finetune(struct p + phy_write_mmd(phydev, MDIO_MMD_VEND1, MTK_PHY_RG_TX_FILTER, 0x5); + + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* ResetSyncOffset = 5 */ +- __phy_write(phydev, 0x11, 0x500); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x8fc0); ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x20, ++ RESET_SYNC_OFFSET_MASK, ++ FIELD_PREP(RESET_SYNC_OFFSET_MASK, 0x5)); + + /* VgaDecRate is 1 at default on mt7988 */ + +- /* MrvlTrFix100Kp = 6, MrvlTrFix100Kf = 7, +- * MrvlTrFix1000Kp = 6, MrvlTrFix1000Kf = 7 +- */ +- __phy_write(phydev, 0x11, 0xb90a); +- __phy_write(phydev, 0x12, 0x6f); +- __phy_write(phydev, 0x10, 0x8f82); +- +- /* RemAckCntLimitCtrl = 1 */ +- __phy_write(phydev, 0x11, 0xfbba); +- __phy_write(phydev, 0x12, 0xc3); +- __phy_write(phydev, 0x10, 0x87f8); +- ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x1, ++ MRVL_TR_FIX_100KP_MASK | MRVL_TR_FIX_100KF_MASK | ++ MRVL_TR_FIX_1000KP_MASK | MRVL_TR_FIX_1000KF_MASK, ++ FIELD_PREP(MRVL_TR_FIX_100KP_MASK, 0x6) | ++ FIELD_PREP(MRVL_TR_FIX_100KF_MASK, 0x7) | ++ FIELD_PREP(MRVL_TR_FIX_1000KP_MASK, 0x6) | ++ FIELD_PREP(MRVL_TR_FIX_1000KF_MASK, 0x7)); ++ ++ __mtk_tr_modify(phydev, 0x0, 0xf, 0x3c, ++ REMOTE_ACK_COUNT_LIMIT_CTRL_MASK, ++ FIELD_PREP(REMOTE_ACK_COUNT_LIMIT_CTRL_MASK, 0x1)); + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); + + /* TR_OPEN_LOOP_EN = 1, lpf_x_average = 10 */ +@@ -927,40 +1012,36 @@ static void mt798x_phy_eee(struct phy_de + __phy_write(phydev, 0x12, 0x0); + __phy_write(phydev, 0x10, 0x9690); + +- /* REG_EEE_st2TrKf1000 = 2 */ +- __phy_write(phydev, 0x11, 0x114f); +- __phy_write(phydev, 0x12, 0x2); +- __phy_write(phydev, 0x10, 0x969a); +- +- /* RegEEE_slv_wake_tr_timer_tar = 6, RegEEE_slv_remtx_timer_tar = 20 */ +- __phy_write(phydev, 0x11, 0x3028); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x969e); +- +- /* RegEEE_slv_wake_int_timer_tar = 8 */ +- __phy_write(phydev, 0x11, 0x5010); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96a0); +- +- /* RegEEE_trfreeze_timer2 = 586 */ +- __phy_write(phydev, 0x11, 0x24a); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96a8); +- +- /* RegEEE100Stg1_tar = 16 */ +- __phy_write(phydev, 0x11, 0x3210); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96b8); ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0xd, ++ EEE1000_STAGE2_TR_KF_MASK, ++ FIELD_PREP(EEE1000_STAGE2_TR_KF_MASK, 0x2)); ++ ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0xf, ++ SLAVE_WAKETR_TIMER_MASK | SLAVE_REMTX_TIMER_MASK, ++ FIELD_PREP(SLAVE_WAKETR_TIMER_MASK, 0x6) | ++ FIELD_PREP(SLAVE_REMTX_TIMER_MASK, 0x14)); ++ ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0x10, ++ SLAVE_WAKEINT_TIMER_MASK, ++ FIELD_PREP(SLAVE_WAKEINT_TIMER_MASK, 0x8)); ++ ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0x14, ++ TR_FREEZE_TIMER2_MASK, ++ FIELD_PREP(TR_FREEZE_TIMER2_MASK, 0x24a)); ++ ++ __mtk_tr_modify(phydev, 0x2, 0xd, 0x1c, ++ EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK, ++ FIELD_PREP(EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK, ++ 0x10)); + + /* REGEEE_wake_slv_tr_wait_dfesigdet_en = 0 */ + __phy_write(phydev, 0x11, 0x1463); + __phy_write(phydev, 0x12, 0x0); + __phy_write(phydev, 0x10, 0x96ca); + +- /* DfeTailEnableVgaThresh1000 = 27 */ +- __phy_write(phydev, 0x11, 0x36); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x8f80); ++ __mtk_tr_modify(phydev, 0x1, 0xf, 0x0, ++ DFE_TAIL_EANBLE_VGA_TRHESH_1000, ++ FIELD_PREP(DFE_TAIL_EANBLE_VGA_TRHESH_1000, 0x1b)); + phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); + + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_3); +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -18,6 +18,10 @@ + + #define MTK_PHY_PAGE_EXTENDED_2A30 0x2a30 + ++/* Registers on Token Ring debug nodes */ ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x17 */ ++#define SLAVE_DSP_READY_TIME_MASK GENMASK(22, 15) ++ + /* Registers on MDIO_MMD_VEND1 */ + #define MTK_PHY_GBE_MODE_TX_DELAY_SEL 0x13 + #define MTK_PHY_TEST_MODE_TX_DELAY_SEL 0x14 +@@ -42,11 +46,8 @@ static void mtk_gephy_config_init(struct + 0, MTK_PHY_ENABLE_DOWNSHIFT); + + /* Increase SlvDPSready time */ +- phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- __phy_write(phydev, 0x10, 0xafae); +- __phy_write(phydev, 0x12, 0x2f); +- __phy_write(phydev, 0x10, 0x8fae); +- phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++ mtk_tr_modify(phydev, 0x1, 0xf, 0x17, SLAVE_DSP_READY_TIME_MASK, ++ FIELD_PREP(SLAVE_DSP_READY_TIME_MASK, 0x5e)); + + /* Adjust 100_mse_threshold */ + phy_modify_mmd(phydev, MDIO_MMD_VEND1, +--- a/drivers/net/phy/mediatek/mtk-phy-lib.c ++++ b/drivers/net/phy/mediatek/mtk-phy-lib.c +@@ -6,6 +6,69 @@ + + #include "mtk.h" + ++/* Difference between functions with mtk_tr* and __mtk_tr* prefixes is ++ * mtk_tr* functions: wrapped by page switching operations ++ * __mtk_tr* functions: no page switching operations ++ */ ++ ++static void __mtk_tr_access(struct phy_device *phydev, bool read, u8 ch_addr, ++ u8 node_addr, u8 data_addr) ++{ ++ u16 tr_cmd = BIT(15); /* bit 14 & 0 are reserved */ ++ ++ if (read) ++ tr_cmd |= BIT(13); ++ ++ tr_cmd |= (((ch_addr & 0x3) << 11) | ++ ((node_addr & 0xf) << 7) | ++ ((data_addr & 0x3f) << 1)); ++ dev_dbg(&phydev->mdio.dev, "tr_cmd: 0x%x\n", tr_cmd); ++ __phy_write(phydev, 0x10, tr_cmd); ++} ++ ++static void __mtk_tr_read(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u16 *tr_high, u16 *tr_low) ++{ ++ __mtk_tr_access(phydev, true, ch_addr, node_addr, data_addr); ++ *tr_low = __phy_read(phydev, 0x11); ++ *tr_high = __phy_read(phydev, 0x12); ++ dev_dbg(&phydev->mdio.dev, "tr_high read: 0x%x, tr_low read: 0x%x\n", ++ *tr_high, *tr_low); ++} ++ ++static void __mtk_tr_write(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 tr_data) ++{ ++ __phy_write(phydev, 0x11, tr_data & 0xffff); ++ __phy_write(phydev, 0x12, tr_data >> 16); ++ dev_dbg(&phydev->mdio.dev, "tr_high write: 0x%x, tr_low write: 0x%x\n", ++ tr_data >> 16, tr_data & 0xffff); ++ __mtk_tr_access(phydev, false, ch_addr, node_addr, data_addr); ++} ++ ++void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 mask, u32 set) ++{ ++ u32 tr_data; ++ u16 tr_high; ++ u16 tr_low; ++ ++ __mtk_tr_read(phydev, ch_addr, node_addr, data_addr, &tr_high, &tr_low); ++ tr_data = (tr_high << 16) | tr_low; ++ tr_data = (tr_data & ~mask) | set; ++ __mtk_tr_write(phydev, ch_addr, node_addr, data_addr, tr_data); ++} ++EXPORT_SYMBOL_GPL(__mtk_tr_modify); ++ ++void mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 mask, u32 set) ++{ ++ phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); ++ __mtk_tr_modify(phydev, ch_addr, node_addr, data_addr, mask, set); ++ phy_restore_page(phydev, MTK_PHY_PAGE_STANDARD, 0); ++} ++EXPORT_SYMBOL_GPL(mtk_tr_modify); ++ + int mtk_phy_read_page(struct phy_device *phydev) + { + return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +--- a/drivers/net/phy/mediatek/mtk.h ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -68,6 +68,11 @@ struct mtk_socphy_priv { + unsigned long led_state; + }; + ++void __mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 mask, u32 set); ++void mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 mask, u32 set); ++ + int mtk_phy_read_page(struct phy_device *phydev); + int mtk_phy_write_page(struct phy_device *phydev, int page); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-12-v6.15-net-phy-mediatek-Add-token-ring-set-bit-operation-su.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-12-v6.15-net-phy-mediatek-Add-token-ring-set-bit-operation-su.patch new file mode 100755 index 0000000..972a9c0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-12-v6.15-net-phy-mediatek-Add-token-ring-set-bit-operation-su.patch @@ -0,0 +1,73 @@ +From c7e2fb3421ef5ebbb4c91f44bd735ab10edd755a Mon Sep 17 00:00:00 2001 +From: Sky Huang +Date: Thu, 13 Feb 2025 16:05:51 +0800 +Subject: [PATCH 12/20] net: phy: mediatek: Add token ring set bit operation + support + +Previously in mtk-ge-soc.c, we set some register bits via token +ring, which were implemented in three __phy_write(). +Now we can do the same thing via __mtk_tr_set_bits() helper. + +Signed-off-by: Sky Huang +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250213080553.921434-4-SkyLake.Huang@mediatek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/mtk-ge-soc.c | 10 ++++++---- + drivers/net/phy/mediatek/mtk-phy-lib.c | 7 +++++++ + drivers/net/phy/mediatek/mtk.h | 2 ++ + 3 files changed, 15 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -62,6 +62,10 @@ + /* MasDSPreadyTime */ + #define MASTER_DSP_READY_TIME_MASK GENMASK(14, 7) + ++/* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x18 */ ++/* EnabRandUpdTrig */ ++#define ENABLE_RANDOM_UPDOWN_COUNTER_TRIGGER BIT(8) ++ + /* ch_addr = 0x1, node_addr = 0xf, data_addr = 0x20 */ + /* ResetSyncOffset */ + #define RESET_SYNC_OFFSET_MASK GENMASK(11, 8) +@@ -789,10 +793,8 @@ static void mt798x_phy_common_finetune(s + FIELD_PREP(SLAVE_DSP_READY_TIME_MASK, 0x18) | + FIELD_PREP(MASTER_DSP_READY_TIME_MASK, 0x18)); + +- /* EnabRandUpdTrig = 1 */ +- __phy_write(phydev, 0x11, 0x2f00); +- __phy_write(phydev, 0x12, 0xe); +- __phy_write(phydev, 0x10, 0x8fb0); ++ __mtk_tr_set_bits(phydev, 0x1, 0xf, 0x18, ++ ENABLE_RANDOM_UPDOWN_COUNTER_TRIGGER); + + __mtk_tr_modify(phydev, 0x0, 0x7, 0x15, + NORMAL_MSE_LO_THRESH_MASK, +--- a/drivers/net/phy/mediatek/mtk-phy-lib.c ++++ b/drivers/net/phy/mediatek/mtk-phy-lib.c +@@ -69,6 +69,13 @@ void mtk_tr_modify(struct phy_device *ph + } + EXPORT_SYMBOL_GPL(mtk_tr_modify); + ++void __mtk_tr_set_bits(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 set) ++{ ++ __mtk_tr_modify(phydev, ch_addr, node_addr, data_addr, 0, set); ++} ++EXPORT_SYMBOL_GPL(__mtk_tr_set_bits); ++ + int mtk_phy_read_page(struct phy_device *phydev) + { + return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +--- a/drivers/net/phy/mediatek/mtk.h ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -72,6 +72,8 @@ void __mtk_tr_modify(struct phy_device * + u8 data_addr, u32 mask, u32 set); + void mtk_tr_modify(struct phy_device *phydev, u8 ch_addr, u8 node_addr, + u8 data_addr, u32 mask, u32 set); ++void __mtk_tr_set_bits(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 set); + + int mtk_phy_read_page(struct phy_device *phydev); + int mtk_phy_write_page(struct phy_device *phydev, int page); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-13-v6.15-net-phy-mediatek-Add-token-ring-clear-bit-operation-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-13-v6.15-net-phy-mediatek-Add-token-ring-clear-bit-operation-.patch new file mode 100755 index 0000000..47d891e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-13-v6.15-net-phy-mediatek-Add-token-ring-clear-bit-operation-.patch @@ -0,0 +1,122 @@ +From 7851c73a416b15aff6f9ada9c88affc5f48ff011 Mon Sep 17 00:00:00 2001 +From: Sky Huang +Date: Thu, 13 Feb 2025 16:05:52 +0800 +Subject: [PATCH 13/20] net: phy: mediatek: Add token ring clear bit operation + support + +Similar to __mtk_tr_set_bits() support. Previously in mtk-ge-soc.c, +we clear some register bits via token ring, which were also implemented +in three __phy_write(). Now we can do the same thing via +__mtk_tr_clr_bits() helper. + +Signed-off-by: Sky Huang +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250213080553.921434-5-SkyLake.Huang@mediatek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/mtk-ge-soc.c | 30 +++++++++++++++----------- + drivers/net/phy/mediatek/mtk-phy-lib.c | 7 ++++++ + drivers/net/phy/mediatek/mtk.h | 2 ++ + 3 files changed, 27 insertions(+), 12 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -76,6 +76,10 @@ + /* FfeUpdGainForce */ + #define FFE_UPDATE_GAIN_FORCE BIT(6) + ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x3 */ ++/* TrFreeze */ ++#define TR_FREEZE_MASK GENMASK(11, 0) ++ + /* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x6 */ + /* SS: Steady-state, KP: Proportional Gain */ + /* SSTrKp100 */ +@@ -91,6 +95,11 @@ + /* SSTrKf1000Slv */ + #define SS_TR_KF1000_SLAVE_MASK GENMASK(6, 4) + ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x8 */ ++/* clear this bit if wanna select from AFE */ ++/* Regsigdet_sel_1000 */ ++#define EEE1000_SELECT_SIGNAL_DETECTION_FROM_DFE BIT(4) ++ + /* ch_addr = 0x2, node_addr = 0xd, data_addr = 0xd */ + /* RegEEE_st2TrKf1000 */ + #define EEE1000_STAGE2_TR_KF_MASK GENMASK(13, 11) +@@ -113,6 +122,10 @@ + /* RegEEE100Stg1_tar */ + #define EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK GENMASK(8, 0) + ++/* ch_addr = 0x2, node_addr = 0xd, data_addr = 0x25 */ ++/* REGEEE_wake_slv_tr_wait_dfesigdet_en */ ++#define WAKE_SLAVE_TR_WAIT_DFE_DETECTION_EN BIT(11) ++ + #define ANALOG_INTERNAL_OPERATION_MAX_US 20 + #define TXRESERVE_MIN 0 + #define TXRESERVE_MAX 7 +@@ -805,10 +818,7 @@ static void mt798x_phy_common_finetune(s + FIELD_PREP(FFE_UPDATE_GAIN_FORCE_VAL_MASK, 0x4) | + FFE_UPDATE_GAIN_FORCE); + +- /* TrFreeze = 0 (mt7988 default) */ +- __phy_write(phydev, 0x11, 0x0); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x9686); ++ __mtk_tr_clr_bits(phydev, 0x2, 0xd, 0x3, TR_FREEZE_MASK); + + __mtk_tr_modify(phydev, 0x2, 0xd, 0x6, + SS_TR_KP100_MASK | SS_TR_KF100_MASK | +@@ -1009,10 +1019,8 @@ static void mt798x_phy_eee(struct phy_de + MTK_PHY_TR_READY_SKIP_AFE_WAKEUP); + + phy_select_page(phydev, MTK_PHY_PAGE_EXTENDED_52B5); +- /* Regsigdet_sel_1000 = 0 */ +- __phy_write(phydev, 0x11, 0xb); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x9690); ++ __mtk_tr_clr_bits(phydev, 0x2, 0xd, 0x8, ++ EEE1000_SELECT_SIGNAL_DETECTION_FROM_DFE); + + __mtk_tr_modify(phydev, 0x2, 0xd, 0xd, + EEE1000_STAGE2_TR_KF_MASK, +@@ -1036,10 +1044,8 @@ static void mt798x_phy_eee(struct phy_de + FIELD_PREP(EEE100_LPSYNC_STAGE1_UPDATE_TIMER_MASK, + 0x10)); + +- /* REGEEE_wake_slv_tr_wait_dfesigdet_en = 0 */ +- __phy_write(phydev, 0x11, 0x1463); +- __phy_write(phydev, 0x12, 0x0); +- __phy_write(phydev, 0x10, 0x96ca); ++ __mtk_tr_clr_bits(phydev, 0x2, 0xd, 0x25, ++ WAKE_SLAVE_TR_WAIT_DFE_DETECTION_EN); + + __mtk_tr_modify(phydev, 0x1, 0xf, 0x0, + DFE_TAIL_EANBLE_VGA_TRHESH_1000, +--- a/drivers/net/phy/mediatek/mtk-phy-lib.c ++++ b/drivers/net/phy/mediatek/mtk-phy-lib.c +@@ -76,6 +76,13 @@ void __mtk_tr_set_bits(struct phy_device + } + EXPORT_SYMBOL_GPL(__mtk_tr_set_bits); + ++void __mtk_tr_clr_bits(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 clr) ++{ ++ __mtk_tr_modify(phydev, ch_addr, node_addr, data_addr, clr, 0); ++} ++EXPORT_SYMBOL_GPL(__mtk_tr_clr_bits); ++ + int mtk_phy_read_page(struct phy_device *phydev) + { + return __phy_read(phydev, MTK_EXT_PAGE_ACCESS); +--- a/drivers/net/phy/mediatek/mtk.h ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -74,6 +74,8 @@ void mtk_tr_modify(struct phy_device *ph + u8 data_addr, u32 mask, u32 set); + void __mtk_tr_set_bits(struct phy_device *phydev, u8 ch_addr, u8 node_addr, + u8 data_addr, u32 set); ++void __mtk_tr_clr_bits(struct phy_device *phydev, u8 ch_addr, u8 node_addr, ++ u8 data_addr, u32 clr); + + int mtk_phy_read_page(struct phy_device *phydev); + int mtk_phy_write_page(struct phy_device *phydev, int page); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-14-v6.15-net-phy-mediatek-Move-some-macros-to-phy-lib-for-lat.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-14-v6.15-net-phy-mediatek-Move-some-macros-to-phy-lib-for-lat.patch new file mode 100755 index 0000000..858de09 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-14-v6.15-net-phy-mediatek-Move-some-macros-to-phy-lib-for-lat.patch @@ -0,0 +1,45 @@ +From bae8c61522c4d5a5250a24dcb57d120ea593fab1 Mon Sep 17 00:00:00 2001 +From: Sky Huang +Date: Thu, 13 Feb 2025 16:05:53 +0800 +Subject: [PATCH 14/20] net: phy: mediatek: Move some macros to phy-lib for + later use + +Move some macros to phy-lib because MediaTek's 2.5G built-in +ethernet PHY will also use them. + +Signed-off-by: Sky Huang +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250213080553.921434-6-SkyLake.Huang@mediatek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/mtk-ge.c | 4 ---- + drivers/net/phy/mediatek/mtk.h | 4 ++++ + 2 files changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -8,10 +8,6 @@ + #define MTK_GPHY_ID_MT7530 0x03a29412 + #define MTK_GPHY_ID_MT7531 0x03a29441 + +-#define MTK_PHY_PAGE_EXTENDED_1 0x0001 +-#define MTK_PHY_AUX_CTRL_AND_STATUS 0x14 +-#define MTK_PHY_ENABLE_DOWNSHIFT BIT(4) +- + #define MTK_PHY_PAGE_EXTENDED_2 0x0002 + #define MTK_PHY_PAGE_EXTENDED_3 0x0003 + #define MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG11 0x11 +--- a/drivers/net/phy/mediatek/mtk.h ++++ b/drivers/net/phy/mediatek/mtk.h +@@ -8,7 +8,11 @@ + #ifndef _MTK_EPHY_H_ + #define _MTK_EPHY_H_ + ++#define MTK_PHY_AUX_CTRL_AND_STATUS 0x14 ++#define MTK_PHY_ENABLE_DOWNSHIFT BIT(4) ++ + #define MTK_EXT_PAGE_ACCESS 0x1f ++#define MTK_PHY_PAGE_EXTENDED_1 0x0001 + #define MTK_PHY_PAGE_STANDARD 0x0000 + #define MTK_PHY_PAGE_EXTENDED_52B5 0x52b5 + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-15-v6.16-net-phy-mediatek-permit-to-compile-test-GE-SOC-PHY-d.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-15-v6.16-net-phy-mediatek-permit-to-compile-test-GE-SOC-PHY-d.patch new file mode 100755 index 0000000..9778ea1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-15-v6.16-net-phy-mediatek-permit-to-compile-test-GE-SOC-PHY-d.patch @@ -0,0 +1,37 @@ +From e5566162af8b9690e096d2e6089e4ed955a0d13d Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 10 Apr 2025 12:04:03 +0200 +Subject: [PATCH] net: phy: mediatek: permit to compile test GE SOC PHY driver + +When commit 462a3daad679 ("net: phy: mediatek: fix compile-test +dependencies") fixed the dependency, it should have also introduced +an or on COMPILE_TEST to permit this driver to be compile-tested even if +NVMEM_MTK_EFUSE wasn't selected. The driver makes use of NVMEM API that +are always compiled (return error) so the driver can actually be +compiled even without that config. + +Fix and simplify the dependency condition of this kernel config. + +Fixes: 462a3daad679 ("net: phy: mediatek: fix compile-test dependencies") +Acked-by: Daniel Golle +Reviewed-by: Andrew Lunn +Signed-off-by: Christian Marangi +Acked-by: Arnd Bergmann +Link: https://patch.msgid.link/20250410100410.348-1-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/Kconfig | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/net/phy/mediatek/Kconfig ++++ b/drivers/net/phy/mediatek/Kconfig +@@ -15,8 +15,7 @@ config MEDIATEK_GE_PHY + + config MEDIATEK_GE_SOC_PHY + tristate "MediaTek SoC Ethernet PHYs" +- depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST +- depends on NVMEM_MTK_EFUSE ++ depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST + select MTK_NET_PHYLIB + help + Supports MediaTek SoC built-in Gigabit Ethernet PHYs. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-16-v6.16-net-phy-mediatek-add-Airoha-PHY-ID-to-SoC-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-16-v6.16-net-phy-mediatek-add-Airoha-PHY-ID-to-SoC-driver.patch new file mode 100755 index 0000000..5498ecb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-16-v6.16-net-phy-mediatek-add-Airoha-PHY-ID-to-SoC-driver.patch @@ -0,0 +1,129 @@ +From 4590c8bc10951feee3e439bf7fff1b458c2e6fad Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 10 Apr 2025 12:04:04 +0200 +Subject: [PATCH 17/20] net: phy: mediatek: add Airoha PHY ID to SoC driver + +Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded +in other SoC like the MT7581 and the MT7988. Similar to these they +require configuring some pin to enable LED PHYs. + +Add support for the PHY ID for the Airoha embedded Switch and define a +simple probe function to toggle these pins. Also fill the LED functions +and add dedicated function to define LED polarity. + +Reviewed-by: Andrew Lunn +Signed-off-by: Christian Marangi +Link: https://patch.msgid.link/20250410100410.348-2-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/Kconfig | 4 +- + drivers/net/phy/mediatek/mtk-ge-soc.c | 62 +++++++++++++++++++++++++++ + 2 files changed, 65 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/mediatek/Kconfig ++++ b/drivers/net/phy/mediatek/Kconfig +@@ -15,7 +15,9 @@ config MEDIATEK_GE_PHY + + config MEDIATEK_GE_SOC_PHY + tristate "MediaTek SoC Ethernet PHYs" +- depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST ++ depends on ARM64 || COMPILE_TEST ++ depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \ ++ COMPILE_TEST + select MTK_NET_PHYLIB + help + Supports MediaTek SoC built-in Gigabit Ethernet PHYs. +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -10,8 +10,11 @@ + + #include "mtk.h" + ++#define MTK_PHY_MAX_LEDS 2 ++ + #define MTK_GPHY_ID_MT7981 0x03a29461 + #define MTK_GPHY_ID_MT7988 0x03a29481 ++#define MTK_GPHY_ID_AN7581 0x03a294c1 + + #define MTK_EXT_PAGE_ACCESS 0x1f + #define MTK_PHY_PAGE_STANDARD 0x0000 +@@ -1405,6 +1408,53 @@ static int mt7981_phy_probe(struct phy_d + return mt798x_phy_calibration(phydev); + } + ++static int an7581_phy_probe(struct phy_device *phydev) ++{ ++ struct mtk_socphy_priv *priv; ++ struct pinctrl *pinctrl; ++ ++ /* Toggle pinctrl to enable PHY LED */ ++ pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led"); ++ if (IS_ERR(pinctrl)) ++ dev_err(&phydev->mdio.bus->dev, ++ "Failed to setup PHY LED pinctrl\n"); ++ ++ priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ phydev->priv = priv; ++ ++ return 0; ++} ++ ++static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index, ++ unsigned long modes) ++{ ++ u32 mode; ++ u16 val; ++ ++ if (index >= MTK_PHY_MAX_LEDS) ++ return -EINVAL; ++ ++ for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { ++ switch (mode) { ++ case PHY_LED_ACTIVE_LOW: ++ val = MTK_PHY_LED_ON_POLARITY; ++ break; ++ case PHY_LED_ACTIVE_HIGH: ++ val = 0; ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? ++ MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL, ++ MTK_PHY_LED_ON_POLARITY, val); ++} ++ + static struct phy_driver mtk_socphy_driver[] = { + { + PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981), +@@ -1440,6 +1490,17 @@ static struct phy_driver mtk_socphy_driv + .led_hw_control_set = mt798x_phy_led_hw_control_set, + .led_hw_control_get = mt798x_phy_led_hw_control_get, + }, ++ { ++ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581), ++ .name = "Airoha AN7581 PHY", ++ .probe = an7581_phy_probe, ++ .led_blink_set = mt798x_phy_led_blink_set, ++ .led_brightness_set = mt798x_phy_led_brightness_set, ++ .led_hw_is_supported = mt798x_phy_led_hw_is_supported, ++ .led_hw_control_set = mt798x_phy_led_hw_control_set, ++ .led_hw_control_get = mt798x_phy_led_hw_control_get, ++ .led_polarity_set = an7581_phy_led_polarity_set, ++ }, + }; + + module_phy_driver(mtk_socphy_driver); +@@ -1447,6 +1508,7 @@ module_phy_driver(mtk_socphy_driver); + static const struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = { + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) }, + { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) }, ++ { PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581) }, + { } + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-17-v6.16-net-phy-mediatek-init-val-in-.phy_led_polarity_set-f.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-17-v6.16-net-phy-mediatek-init-val-in-.phy_led_polarity_set-f.patch new file mode 100755 index 0000000..1b1dda2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/720-17-v6.16-net-phy-mediatek-init-val-in-.phy_led_polarity_set-f.patch @@ -0,0 +1,40 @@ +From 34501d047ac0a6cbb13285ba9d15f75c1deb7da7 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 15 Apr 2025 12:53:05 +0200 +Subject: [PATCH 18/20] net: phy: mediatek: init val in .phy_led_polarity_set + for AN7581 + +Fix smatch warning for uninitialised val in .phy_led_polarity_set for +AN7581 driver. + +Correctly init to 0 to set polarity high by default. + +Reported-by: Simon Horman +Fixes: 6a325aed130b ("net: phy: mediatek: add Airoha PHY ID to SoC driver") +Signed-off-by: Christian Marangi +Link: https://patch.msgid.link/20250415105313.3409-1-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mediatek/mtk-ge-soc.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/net/phy/mediatek/mtk-ge-soc.c ++++ b/drivers/net/phy/mediatek/mtk-ge-soc.c +@@ -1431,8 +1431,8 @@ static int an7581_phy_probe(struct phy_d + static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index, + unsigned long modes) + { ++ u16 val = 0; + u32 mode; +- u16 val; + + if (index >= MTK_PHY_MAX_LEDS) + return -EINVAL; +@@ -1443,7 +1443,6 @@ static int an7581_phy_led_polarity_set(s + val = MTK_PHY_LED_ON_POLARITY; + break; + case PHY_LED_ACTIVE_HIGH: +- val = 0; + break; + default: + return -EINVAL; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/721-01-v6.15-net-ethernet-mediatek-add-EEE-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/721-01-v6.15-net-ethernet-mediatek-add-EEE-support.patch new file mode 100755 index 0000000..c58635a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/721-01-v6.15-net-ethernet-mediatek-add-EEE-support.patch @@ -0,0 +1,157 @@ +From 952d7325362ffbefa6ce5619fb4e53c2159ec7a7 Mon Sep 17 00:00:00 2001 +From: Qingfang Deng +Date: Mon, 17 Feb 2025 17:40:21 +0800 +Subject: [PATCH] net: ethernet: mediatek: add EEE support + +Add EEE support to MediaTek SoC Ethernet. The register fields are +similar to the ones in MT7531, except that the LPI threshold is in +milliseconds. + +Signed-off-by: Qingfang Deng +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 64 +++++++++++++++++++++ + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 11 ++++ + 2 files changed, 75 insertions(+) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -782,6 +782,7 @@ static void mtk_mac_link_up(struct phyli + + mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); + mcr &= ~(MAC_MCR_SPEED_100 | MAC_MCR_SPEED_1000 | ++ MAC_MCR_EEE100M | MAC_MCR_EEE1G | + MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_TX_FC | + MAC_MCR_FORCE_RX_FC); + +@@ -807,6 +808,15 @@ static void mtk_mac_link_up(struct phyli + if (rx_pause) + mcr |= MAC_MCR_FORCE_RX_FC; + ++ if (mode == MLO_AN_PHY && phy && mac->tx_lpi_enabled && phy_init_eee(phy, false) >= 0) { ++ mcr |= MAC_MCR_EEE100M | MAC_MCR_EEE1G; ++ mtk_w32(mac->hw, ++ FIELD_PREP(MAC_EEE_WAKEUP_TIME_1000, 17) | ++ FIELD_PREP(MAC_EEE_WAKEUP_TIME_100, 36) | ++ FIELD_PREP(MAC_EEE_LPI_TXIDLE_THD, mac->txidle_thd_ms), ++ MTK_MAC_EEECR(mac->id)); ++ } ++ + mcr |= MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK; + mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); + } +@@ -4514,6 +4524,61 @@ static int mtk_set_pauseparam(struct net + return phylink_ethtool_set_pauseparam(mac->phylink, pause); + } + ++static int mtk_get_eee(struct net_device *dev, struct ethtool_keee *eee) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ u32 reg; ++ int ret; ++ ++ ret = phylink_ethtool_get_eee(mac->phylink, eee); ++ if (ret) ++ return ret; ++ ++ reg = mtk_r32(mac->hw, MTK_MAC_EEECR(mac->id)); ++ eee->tx_lpi_enabled = mac->tx_lpi_enabled; ++ eee->tx_lpi_timer = FIELD_GET(MAC_EEE_LPI_TXIDLE_THD, reg) * 1000; ++ ++ return 0; ++} ++ ++static int mtk_set_eee(struct net_device *dev, struct ethtool_keee *eee) ++{ ++ struct mtk_mac *mac = netdev_priv(dev); ++ u32 txidle_thd_ms, reg; ++ int ret; ++ ++ /* Tx idle timer in ms */ ++ txidle_thd_ms = DIV_ROUND_UP(eee->tx_lpi_timer, 1000); ++ if (!FIELD_FIT(MAC_EEE_LPI_TXIDLE_THD, txidle_thd_ms)) ++ return -EINVAL; ++ ++ reg = FIELD_PREP(MAC_EEE_LPI_TXIDLE_THD, txidle_thd_ms); ++ ++ /* PHY Wake-up time, this field does not have a reset value, so use the ++ * reset value from MT7531 (36us for 100BaseT and 17us for 1000BaseT). ++ */ ++ reg |= FIELD_PREP(MAC_EEE_WAKEUP_TIME_1000, 17) | ++ FIELD_PREP(MAC_EEE_WAKEUP_TIME_100, 36); ++ ++ if (!txidle_thd_ms) ++ /* Force LPI Mode without a delay */ ++ reg |= MAC_EEE_LPI_MODE; ++ ++ ret = phylink_ethtool_set_eee(mac->phylink, eee); ++ if (ret) ++ return ret; ++ ++ mac->tx_lpi_enabled = eee->tx_lpi_enabled; ++ mac->txidle_thd_ms = txidle_thd_ms; ++ mtk_w32(mac->hw, reg, MTK_MAC_EEECR(mac->id)); ++ if (eee->eee_enabled && eee->eee_active && eee->tx_lpi_enabled) ++ mtk_m32(mac->hw, 0, MAC_MCR_EEE100M | MAC_MCR_EEE1G, MTK_MAC_MCR(mac->id)); ++ else ++ mtk_m32(mac->hw, MAC_MCR_EEE100M | MAC_MCR_EEE1G, 0, MTK_MAC_MCR(mac->id)); ++ ++ return 0; ++} ++ + static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb, + struct net_device *sb_dev) + { +@@ -4546,6 +4611,8 @@ static const struct ethtool_ops mtk_etht + .set_pauseparam = mtk_set_pauseparam, + .get_rxnfc = mtk_get_rxnfc, + .set_rxnfc = mtk_set_rxnfc, ++ .get_eee = mtk_get_eee, ++ .set_eee = mtk_set_eee, + }; + + static const struct net_device_ops mtk_netdev_ops = { +@@ -4606,6 +4673,8 @@ static int mtk_add_mac(struct mtk_eth *e + } + mac = netdev_priv(eth->netdev[id]); + eth->mac[id] = mac; ++ mac->tx_lpi_enabled = true; ++ mac->txidle_thd_ms = 1; + mac->id = id; + mac->hw = eth; + mac->of_node = np; +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -461,6 +461,8 @@ + #define MAC_MCR_RX_FIFO_CLR_DIS BIT(12) + #define MAC_MCR_BACKOFF_EN BIT(9) + #define MAC_MCR_BACKPR_EN BIT(8) ++#define MAC_MCR_EEE1G BIT(7) ++#define MAC_MCR_EEE100M BIT(6) + #define MAC_MCR_FORCE_RX_FC BIT(5) + #define MAC_MCR_FORCE_TX_FC BIT(4) + #define MAC_MCR_SPEED_1000 BIT(3) +@@ -469,6 +471,15 @@ + #define MAC_MCR_FORCE_LINK BIT(0) + #define MAC_MCR_FORCE_LINK_DOWN (MAC_MCR_FORCE_MODE) + ++/* Mac EEE control registers */ ++#define MTK_MAC_EEECR(x) (0x10104 + (x * 0x100)) ++#define MAC_EEE_WAKEUP_TIME_1000 GENMASK(31, 24) ++#define MAC_EEE_WAKEUP_TIME_100 GENMASK(23, 16) ++#define MAC_EEE_LPI_TXIDLE_THD GENMASK(15, 8) ++#define MAC_EEE_CKG_TXIDLE BIT(3) ++#define MAC_EEE_CKG_RXLPI BIT(2) ++#define MAC_EEE_LPI_MODE BIT(0) ++ + /* Mac status registers */ + #define MTK_MAC_MSR(x) (0x10108 + (x * 0x100)) + #define MAC_MSR_EEE1G BIT(7) +@@ -1316,6 +1327,8 @@ struct mtk_mac { + int id; + phy_interface_t interface; + u8 ppe_idx; ++ bool tx_lpi_enabled; ++ u8 txidle_thd_ms; + int speed; + struct device_node *of_node; + struct phylink *phylink; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-01-v6.13-net-phy-aquantia-allow-forcing-order-of-MDI-pairs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-01-v6.13-net-phy-aquantia-allow-forcing-order-of-MDI-pairs.patch new file mode 100755 index 0000000..aabaa33 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-01-v6.13-net-phy-aquantia-allow-forcing-order-of-MDI-pairs.patch @@ -0,0 +1,107 @@ +From a2e1ba275eae96a8171deb19e9c7c2f5978fee7b Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Fri, 4 Oct 2024 17:18:16 +0100 +Subject: [PATCH] net: phy: aquantia: allow forcing order of MDI pairs + +Despite supporting Auto MDI-X, it looks like Aquantia only supports +swapping pair (1,2) with pair (3,6) like it used to be for MDI-X on +100MBit/s networks. + +When all 4 pairs are in use (for 1000MBit/s or faster) the link does not +come up with pair order is not configured correctly, either using +MDI_CFG pin or using the "PMA Receive Reserved Vendor Provisioning 1" +register. + +Normally, the order of MDI pairs being either ABCD or DCBA is configured +by pulling the MDI_CFG pin. + +However, some hardware designs require overriding the value configured +by that bootstrap pin. The PHY allows doing that by setting a bit in +"PMA Receive Reserved Vendor Provisioning 1" register which allows +ignoring the state of the MDI_CFG pin and another bit configuring +whether the order of MDI pairs should be normal (ABCD) or reverse +(DCBA). Pair polarity is not affected and remains identical in both +settings. + +Introduce property "marvell,mdi-cfg-order" which allows forcing either +normal or reverse order of the MDI pairs from DT. + +If the property isn't present, the behavior is unchanged and MDI pair +order configuration is untouched (ie. either the result of MDI_CFG pin +pull-up/pull-down, or pair order override already configured by the +bootloader before Linux is started). + +Forcing normal pair order is required on the Adtran SDG-8733A Wi-Fi 7 +residential gateway. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/9ed760ff87d5fc456f31e407ead548bbb754497d.1728058550.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/aquantia/aquantia_main.c | 33 ++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + #include + + #include "aquantia.h" +@@ -71,6 +72,11 @@ + #define MDIO_AN_TX_VEND_INT_MASK2 0xd401 + #define MDIO_AN_TX_VEND_INT_MASK2_LINK BIT(0) + ++#define PMAPMD_RSVD_VEND_PROV 0xe400 ++#define PMAPMD_RSVD_VEND_PROV_MDI_CONF GENMASK(1, 0) ++#define PMAPMD_RSVD_VEND_PROV_MDI_REVERSE BIT(0) ++#define PMAPMD_RSVD_VEND_PROV_MDI_FORCE BIT(1) ++ + #define MDIO_AN_RX_LP_STAT1 0xe820 + #define MDIO_AN_RX_LP_STAT1_1000BASET_FULL BIT(15) + #define MDIO_AN_RX_LP_STAT1_1000BASET_HALF BIT(14) +@@ -485,6 +491,29 @@ static void aqr107_chip_info(struct phy_ + fw_major, fw_minor, build_id, prov_id); + } + ++static int aqr107_config_mdi(struct phy_device *phydev) ++{ ++ struct device_node *np = phydev->mdio.dev.of_node; ++ u32 mdi_conf; ++ int ret; ++ ++ ret = of_property_read_u32(np, "marvell,mdi-cfg-order", &mdi_conf); ++ ++ /* Do nothing in case property "marvell,mdi-cfg-order" is not present */ ++ if (ret == -ENOENT) ++ return 0; ++ ++ if (ret) ++ return ret; ++ ++ if (mdi_conf & ~PMAPMD_RSVD_VEND_PROV_MDI_REVERSE) ++ return -EINVAL; ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, PMAPMD_RSVD_VEND_PROV, ++ PMAPMD_RSVD_VEND_PROV_MDI_CONF, ++ mdi_conf | PMAPMD_RSVD_VEND_PROV_MDI_FORCE); ++} ++ + static int aqr107_config_init(struct phy_device *phydev) + { + struct aqr107_priv *priv = phydev->priv; +@@ -514,6 +543,10 @@ static int aqr107_config_init(struct phy + if (ret) + return ret; + ++ ret = aqr107_config_mdi(phydev); ++ if (ret) ++ return ret; ++ + /* Restore LED polarity state after reset */ + for_each_set_bit(led_active_low, &priv->leds_active_low, AQR_MAX_LEDS) { + ret = aqr_phy_led_active_low_set(phydev, led_active_low, true); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-02-v6.13-net-phy-aquantia-fix-return-value-check-in-aqr107_co.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-02-v6.13-net-phy-aquantia-fix-return-value-check-in-aqr107_co.patch new file mode 100755 index 0000000..565edbd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-02-v6.13-net-phy-aquantia-fix-return-value-check-in-aqr107_co.patch @@ -0,0 +1,31 @@ +From ce21b8fb255ebf0b49913fb4c62741d7eb05c6f6 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Fri, 11 Oct 2024 22:28:43 +0100 +Subject: [PATCH] net: phy: aquantia: fix return value check in + aqr107_config_mdi() + +of_property_read_u32() returns -EINVAL in case the property cannot be +found rather than -ENOENT. Fix the check to not abort probing in case +of the property being missing, and also in case CONFIG_OF is not set +which will result in -ENOSYS. + +Fixes: a2e1ba275eae ("net: phy: aquantia: allow forcing order of MDI pairs") +Reported-by: Jon Hunter +Closes: https://lore.kernel.org/all/114b4c03-5d16-42ed-945d-cf78eabea12b@nvidia.com/ +Suggested-by: Hans-Frieder Vogt +Signed-off-by: Daniel Golle +--- + drivers/net/phy/aquantia/aquantia_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -500,7 +500,7 @@ static int aqr107_config_mdi(struct phy_ + ret = of_property_read_u32(np, "marvell,mdi-cfg-order", &mdi_conf); + + /* Do nothing in case property "marvell,mdi-cfg-order" is not present */ +- if (ret == -ENOENT) ++ if (ret == -EINVAL || ret == -ENOSYS) + return 0; + + if (ret) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-03-v6.13-net-phy-support-active-high-property-for-PHY-LEDs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-03-v6.13-net-phy-support-active-high-property-for-PHY-LEDs.patch new file mode 100755 index 0000000..6822dc0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-03-v6.13-net-phy-support-active-high-property-for-PHY-LEDs.patch @@ -0,0 +1,53 @@ +From a274465cc3bef2dfd9c9ea5100848dda0a8641e1 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 13:54:19 +0100 +Subject: [PATCH 1/4] net: phy: support 'active-high' property for PHY LEDs + +In addition to 'active-low' and 'inactive-high-impedance' also +support 'active-high' property for PHY LED pin configuration. +As only either 'active-high' or 'active-low' can be set at the +same time, WARN and return an error in case both are set. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/91598487773d768f254d5faf06cf65b13e972f0e.1728558223.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/phy_device.c | 6 ++++++ + include/linux/phy.h | 5 +++-- + 2 files changed, 9 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -3387,11 +3387,17 @@ static int of_phy_led(struct phy_device + if (index > U8_MAX) + return -EINVAL; + ++ if (of_property_read_bool(led, "active-high")) ++ set_bit(PHY_LED_ACTIVE_HIGH, &modes); + if (of_property_read_bool(led, "active-low")) + set_bit(PHY_LED_ACTIVE_LOW, &modes); + if (of_property_read_bool(led, "inactive-high-impedance")) + set_bit(PHY_LED_INACTIVE_HIGH_IMPEDANCE, &modes); + ++ if (WARN_ON(modes & BIT(PHY_LED_ACTIVE_LOW) && ++ modes & BIT(PHY_LED_ACTIVE_HIGH))) ++ return -EINVAL; ++ + if (modes) { + /* Return error if asked to set polarity modes but not supported */ + if (!phydev->drv->led_polarity_set) +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -902,8 +902,9 @@ struct phy_plca_status { + + /* Modes for PHY LED configuration */ + enum phy_led_modes { +- PHY_LED_ACTIVE_LOW = 0, +- PHY_LED_INACTIVE_HIGH_IMPEDANCE = 1, ++ PHY_LED_ACTIVE_HIGH = 0, ++ PHY_LED_ACTIVE_LOW = 1, ++ PHY_LED_INACTIVE_HIGH_IMPEDANCE = 2, + + /* keep it last */ + __PHY_LED_MODES_NUM, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-04-v6.13-net-phy-aquantia-correctly-describe-LED-polarity-ove.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-04-v6.13-net-phy-aquantia-correctly-describe-LED-polarity-ove.patch new file mode 100755 index 0000000..155f796 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-04-v6.13-net-phy-aquantia-correctly-describe-LED-polarity-ove.patch @@ -0,0 +1,108 @@ +From 9d55e68b19f222e6334ef4021c5527998f5ab537 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 13:55:00 +0100 +Subject: [PATCH 2/4] net: phy: aquantia: correctly describe LED polarity + override + +Use newly defined 'active-high' property to set the +VEND1_GLOBAL_LED_DRIVE_VDD bit and let 'active-low' clear that bit. This +reflects the technical reality which was inverted in the previous +description in which the 'active-low' property was used to actually set +the VEND1_GLOBAL_LED_DRIVE_VDD bit, which means that VDD (ie. supply +voltage) of the LED is driven rather than GND. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/86a413b4387c42dcb54f587cc2433a06f16aae83.1728558223.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/aquantia/aquantia.h | 1 + + drivers/net/phy/aquantia/aquantia_leds.c | 19 ++++++++++++++----- + drivers/net/phy/aquantia/aquantia_main.c | 12 +++++++++--- + 3 files changed, 24 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/aquantia/aquantia.h ++++ b/drivers/net/phy/aquantia/aquantia.h +@@ -177,6 +177,7 @@ static const struct aqr107_hw_stat aqr10 + struct aqr107_priv { + u64 sgmii_stats[AQR107_SGMII_STAT_SZ]; + unsigned long leds_active_low; ++ unsigned long leds_active_high; + }; + + #if IS_REACHABLE(CONFIG_HWMON) +--- a/drivers/net/phy/aquantia/aquantia_leds.c ++++ b/drivers/net/phy/aquantia/aquantia_leds.c +@@ -121,13 +121,13 @@ int aqr_phy_led_active_low_set(struct ph + { + return phy_modify_mmd(phydev, MDIO_MMD_VEND1, AQR_LED_DRIVE(index), + VEND1_GLOBAL_LED_DRIVE_VDD, +- enable ? VEND1_GLOBAL_LED_DRIVE_VDD : 0); ++ enable ? 0 : VEND1_GLOBAL_LED_DRIVE_VDD); + } + + int aqr_phy_led_polarity_set(struct phy_device *phydev, int index, unsigned long modes) + { ++ bool force_active_low = false, force_active_high = false; + struct aqr107_priv *priv = phydev->priv; +- bool active_low = false; + u32 mode; + + if (index >= AQR_MAX_LEDS) +@@ -136,7 +136,10 @@ int aqr_phy_led_polarity_set(struct phy_ + for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { + switch (mode) { + case PHY_LED_ACTIVE_LOW: +- active_low = true; ++ force_active_low = true; ++ break; ++ case PHY_LED_ACTIVE_HIGH: ++ force_active_high = true; + break; + default: + return -EINVAL; +@@ -144,8 +147,14 @@ int aqr_phy_led_polarity_set(struct phy_ + } + + /* Save LED driver vdd state to restore on SW reset */ +- if (active_low) ++ if (force_active_low) + priv->leds_active_low |= BIT(index); + +- return aqr_phy_led_active_low_set(phydev, index, active_low); ++ if (force_active_high) ++ priv->leds_active_high |= BIT(index); ++ ++ if (force_active_high || force_active_low) ++ return aqr_phy_led_active_low_set(phydev, index, force_active_low); ++ ++ unreachable(); + } +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -517,7 +517,7 @@ static int aqr107_config_mdi(struct phy_ + static int aqr107_config_init(struct phy_device *phydev) + { + struct aqr107_priv *priv = phydev->priv; +- u32 led_active_low; ++ u32 led_idx; + int ret; + + /* Check that the PHY interface type is compatible */ +@@ -548,8 +548,14 @@ static int aqr107_config_init(struct phy + return ret; + + /* Restore LED polarity state after reset */ +- for_each_set_bit(led_active_low, &priv->leds_active_low, AQR_MAX_LEDS) { +- ret = aqr_phy_led_active_low_set(phydev, led_active_low, true); ++ for_each_set_bit(led_idx, &priv->leds_active_low, AQR_MAX_LEDS) { ++ ret = aqr_phy_led_active_low_set(phydev, led_idx, true); ++ if (ret) ++ return ret; ++ } ++ ++ for_each_set_bit(led_idx, &priv->leds_active_high, AQR_MAX_LEDS) { ++ ret = aqr_phy_led_active_low_set(phydev, led_idx, false); + if (ret) + return ret; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-05-v6.13-net-phy-mxl-gpy-add-basic-LED-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-05-v6.13-net-phy-mxl-gpy-add-basic-LED-support.patch new file mode 100755 index 0000000..c785f8a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-05-v6.13-net-phy-mxl-gpy-add-basic-LED-support.patch @@ -0,0 +1,332 @@ +From 78997e9a5e4d8a4df561e083a92c91ae23010e07 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 1 Oct 2024 01:17:18 +0100 +Subject: [PATCH] net: phy: mxl-gpy: add basic LED support + +Add basic support for LEDs connected to MaxLinear GPY2xx and GPY115 PHYs. +The PHYs allow up to 4 LEDs to be connected. +Implement controlling LEDs in software as well as netdev trigger offloading +and LED polarity setup. + +The hardware claims to support 16 PWM brightness levels but there is no +documentation on how to use that feature, hence this is not supported. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/b6ec9050339f8244ff898898a1cecc33b13a48fc.1727741563.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mxl-gpy.c | 218 ++++++++++++++++++++++++++++++++++++++ + 1 file changed, 218 insertions(+) + +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -38,6 +38,7 @@ + #define PHY_MIISTAT 0x18 /* MII state */ + #define PHY_IMASK 0x19 /* interrupt mask */ + #define PHY_ISTAT 0x1A /* interrupt status */ ++#define PHY_LED 0x1B /* LEDs */ + #define PHY_FWV 0x1E /* firmware version */ + + #define PHY_MIISTAT_SPD_MASK GENMASK(2, 0) +@@ -61,6 +62,11 @@ + PHY_IMASK_ADSC | \ + PHY_IMASK_ANC) + ++#define GPY_MAX_LEDS 4 ++#define PHY_LED_POLARITY(idx) BIT(12 + (idx)) ++#define PHY_LED_HWCONTROL(idx) BIT(8 + (idx)) ++#define PHY_LED_ON(idx) BIT(idx) ++ + #define PHY_FWV_REL_MASK BIT(15) + #define PHY_FWV_MAJOR_MASK GENMASK(11, 8) + #define PHY_FWV_MINOR_MASK GENMASK(7, 0) +@@ -72,6 +78,23 @@ + #define PHY_MDI_MDI_X_CD 0x1 + #define PHY_MDI_MDI_X_CROSS 0x0 + ++/* LED */ ++#define VSPEC1_LED(idx) (1 + (idx)) ++#define VSPEC1_LED_BLINKS GENMASK(15, 12) ++#define VSPEC1_LED_PULSE GENMASK(11, 8) ++#define VSPEC1_LED_CON GENMASK(7, 4) ++#define VSPEC1_LED_BLINKF GENMASK(3, 0) ++ ++#define VSPEC1_LED_LINK10 BIT(0) ++#define VSPEC1_LED_LINK100 BIT(1) ++#define VSPEC1_LED_LINK1000 BIT(2) ++#define VSPEC1_LED_LINK2500 BIT(3) ++ ++#define VSPEC1_LED_TXACT BIT(0) ++#define VSPEC1_LED_RXACT BIT(1) ++#define VSPEC1_LED_COL BIT(2) ++#define VSPEC1_LED_NO_CON BIT(3) ++ + /* SGMII */ + #define VSPEC1_SGMII_CTRL 0x08 + #define VSPEC1_SGMII_CTRL_ANEN BIT(12) /* Aneg enable */ +@@ -835,6 +858,156 @@ static int gpy115_loopback(struct phy_de + return genphy_soft_reset(phydev); + } + ++static int gpy_led_brightness_set(struct phy_device *phydev, ++ u8 index, enum led_brightness value) ++{ ++ int ret; ++ ++ if (index >= GPY_MAX_LEDS) ++ return -EINVAL; ++ ++ /* clear HWCONTROL and set manual LED state */ ++ ret = phy_modify(phydev, PHY_LED, ++ ((value == LED_OFF) ? PHY_LED_HWCONTROL(index) : 0) | ++ PHY_LED_ON(index), ++ (value == LED_OFF) ? 0 : PHY_LED_ON(index)); ++ if (ret) ++ return ret; ++ ++ /* ToDo: set PWM brightness */ ++ ++ /* clear HW LED setup */ ++ if (value == LED_OFF) ++ return phy_write_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_LED(index), 0); ++ else ++ return 0; ++} ++ ++static const unsigned long supported_triggers = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_LINK_2500) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)); ++ ++static int gpy_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ if (index >= GPY_MAX_LEDS) ++ return -EINVAL; ++ ++ /* All combinations of the supported triggers are allowed */ ++ if (rules & ~supported_triggers) ++ return -EOPNOTSUPP; ++ ++ return 0; ++} ++ ++static int gpy_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int val; ++ ++ if (index >= GPY_MAX_LEDS) ++ return -EINVAL; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_LED(index)); ++ if (val < 0) ++ return val; ++ ++ if (FIELD_GET(VSPEC1_LED_CON, val) & VSPEC1_LED_LINK10) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_10); ++ ++ if (FIELD_GET(VSPEC1_LED_CON, val) & VSPEC1_LED_LINK100) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_100); ++ ++ if (FIELD_GET(VSPEC1_LED_CON, val) & VSPEC1_LED_LINK1000) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_1000); ++ ++ if (FIELD_GET(VSPEC1_LED_CON, val) & VSPEC1_LED_LINK2500) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_2500); ++ ++ if (FIELD_GET(VSPEC1_LED_CON, val) == (VSPEC1_LED_LINK10 | ++ VSPEC1_LED_LINK100 | ++ VSPEC1_LED_LINK1000 | ++ VSPEC1_LED_LINK2500)) ++ *rules |= BIT(TRIGGER_NETDEV_LINK); ++ ++ if (FIELD_GET(VSPEC1_LED_PULSE, val) & VSPEC1_LED_TXACT) ++ *rules |= BIT(TRIGGER_NETDEV_TX); ++ ++ if (FIELD_GET(VSPEC1_LED_PULSE, val) & VSPEC1_LED_RXACT) ++ *rules |= BIT(TRIGGER_NETDEV_RX); ++ ++ return 0; ++} ++ ++static int gpy_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ u16 val = 0; ++ int ret; ++ ++ if (index >= GPY_MAX_LEDS) ++ return -EINVAL; ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_10)) ++ val |= FIELD_PREP(VSPEC1_LED_CON, VSPEC1_LED_LINK10); ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_100)) ++ val |= FIELD_PREP(VSPEC1_LED_CON, VSPEC1_LED_LINK100); ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_1000)) ++ val |= FIELD_PREP(VSPEC1_LED_CON, VSPEC1_LED_LINK1000); ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_2500)) ++ val |= FIELD_PREP(VSPEC1_LED_CON, VSPEC1_LED_LINK2500); ++ ++ if (rules & BIT(TRIGGER_NETDEV_TX)) ++ val |= FIELD_PREP(VSPEC1_LED_PULSE, VSPEC1_LED_TXACT); ++ ++ if (rules & BIT(TRIGGER_NETDEV_RX)) ++ val |= FIELD_PREP(VSPEC1_LED_PULSE, VSPEC1_LED_RXACT); ++ ++ /* allow RX/TX pulse without link indication */ ++ if ((rules & BIT(TRIGGER_NETDEV_TX) || rules & BIT(TRIGGER_NETDEV_RX)) && ++ !(val & VSPEC1_LED_CON)) ++ val |= FIELD_PREP(VSPEC1_LED_PULSE, VSPEC1_LED_NO_CON) | VSPEC1_LED_CON; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_LED(index), val); ++ if (ret) ++ return ret; ++ ++ return phy_set_bits(phydev, PHY_LED, PHY_LED_HWCONTROL(index)); ++} ++ ++static int gpy_led_polarity_set(struct phy_device *phydev, int index, ++ unsigned long modes) ++{ ++ bool active_low = false; ++ u32 mode; ++ ++ if (index >= GPY_MAX_LEDS) ++ return -EINVAL; ++ ++ for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { ++ switch (mode) { ++ case PHY_LED_ACTIVE_LOW: ++ active_low = true; ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ ++ return phy_modify(phydev, PHY_LED, PHY_LED_POLARITY(index), ++ active_low ? 0 : PHY_LED_POLARITY(index)); ++} ++ + static struct phy_driver gpy_drivers[] = { + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY2xx), +@@ -852,6 +1025,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + .phy_id = PHY_ID_GPY115B, +@@ -870,6 +1048,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy115_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY115C), +@@ -887,6 +1070,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy115_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + .phy_id = PHY_ID_GPY211B, +@@ -905,6 +1093,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY211C), +@@ -922,6 +1115,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + .phy_id = PHY_ID_GPY212B, +@@ -940,6 +1138,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY212C), +@@ -957,6 +1160,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + .phy_id = PHY_ID_GPY215B, +@@ -975,6 +1183,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY215C), +@@ -992,6 +1205,11 @@ static struct phy_driver gpy_drivers[] = + .set_wol = gpy_set_wol, + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, + }, + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY241B), diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-06-v6.13-net-phy-mxl-gpy-add-missing-support-for-TRIGGER_NETD.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-06-v6.13-net-phy-mxl-gpy-add-missing-support-for-TRIGGER_NETD.patch new file mode 100755 index 0000000..39bef9b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-06-v6.13-net-phy-mxl-gpy-add-missing-support-for-TRIGGER_NETD.patch @@ -0,0 +1,28 @@ +From f95b4725e796b12e5f347a0d161e1d3843142aa8 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Fri, 4 Oct 2024 16:56:35 +0100 +Subject: [PATCH] net: phy: mxl-gpy: add missing support for + TRIGGER_NETDEV_LINK_10 + +The PHY also support 10MBit/s links as well as the corresponding link +indication trigger to be offloaded. Add TRIGGER_NETDEV_LINK_10 to the +supported triggers. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/cc5da0a989af8b0d49d823656d88053c4de2ab98.1728057367.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mxl-gpy.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -884,6 +884,7 @@ static int gpy_led_brightness_set(struct + } + + static const unsigned long supported_triggers = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_10) | + BIT(TRIGGER_NETDEV_LINK_100) | + BIT(TRIGGER_NETDEV_LINK_1000) | + BIT(TRIGGER_NETDEV_LINK_2500) | diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-07-v6.13-net-phy-mxl-gpy-correctly-describe-LED-polarity.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-07-v6.13-net-phy-mxl-gpy-correctly-describe-LED-polarity.patch new file mode 100755 index 0000000..5fd3dcc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-07-v6.13-net-phy-mxl-gpy-correctly-describe-LED-polarity.patch @@ -0,0 +1,58 @@ +From eb89c79c1b8f17fc1611540768678e60df89ac42 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 13:55:17 +0100 +Subject: [PATCH 3/4] net: phy: mxl-gpy: correctly describe LED polarity + +According the datasheet covering the LED (0x1b) register: +0B Active High LEDx pin driven high when activated +1B Active Low LEDx pin driven low when activated + +Make use of the now available 'active-high' property and correctly +reflect the polarity setting which was previously inverted. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/180ccafa837f09908b852a8a874a3808c5ecd2d0.1728558223.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/mxl-gpy.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -989,7 +989,7 @@ static int gpy_led_hw_control_set(struct + static int gpy_led_polarity_set(struct phy_device *phydev, int index, + unsigned long modes) + { +- bool active_low = false; ++ bool force_active_low = false, force_active_high = false; + u32 mode; + + if (index >= GPY_MAX_LEDS) +@@ -998,15 +998,23 @@ static int gpy_led_polarity_set(struct p + for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { + switch (mode) { + case PHY_LED_ACTIVE_LOW: +- active_low = true; ++ force_active_low = true; ++ break; ++ case PHY_LED_ACTIVE_HIGH: ++ force_active_high = true; + break; + default: + return -EINVAL; + } + } + +- return phy_modify(phydev, PHY_LED, PHY_LED_POLARITY(index), +- active_low ? 0 : PHY_LED_POLARITY(index)); ++ if (force_active_low) ++ return phy_set_bits(phydev, PHY_LED, PHY_LED_POLARITY(index)); ++ ++ if (force_active_high) ++ return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index)); ++ ++ unreachable(); + } + + static struct phy_driver gpy_drivers[] = { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-08-v6.13-net-phy-intel-xway-add-support-for-PHY-LEDs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-08-v6.13-net-phy-intel-xway-add-support-for-PHY-LEDs.patch new file mode 100755 index 0000000..c57b577 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-08-v6.13-net-phy-intel-xway-add-support-for-PHY-LEDs.patch @@ -0,0 +1,379 @@ +From 1758af47b98c17da464cb45f476875150955dd48 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 13:55:29 +0100 +Subject: [PATCH 4/4] net: phy: intel-xway: add support for PHY LEDs + +The intel-xway PHY driver predates the PHY LED framework and currently +initializes all LED pins to equal default values. + +Add PHY LED functions to the drivers and don't set default values if +LEDs are defined in device tree. + +According the datasheets 3 LEDs are supported on all Intel XWAY PHYs. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/81f4717ab9acf38f3239727a4540ae96fd01109b.1728558223.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/intel-xway.c | 253 +++++++++++++++++++++++++++++++++-- + 1 file changed, 244 insertions(+), 9 deletions(-) + +--- a/drivers/net/phy/intel-xway.c ++++ b/drivers/net/phy/intel-xway.c +@@ -151,6 +151,13 @@ + #define XWAY_MMD_LED3H 0x01E8 + #define XWAY_MMD_LED3L 0x01E9 + ++#define XWAY_GPHY_MAX_LEDS 3 ++#define XWAY_GPHY_LED_INV(idx) BIT(12 + (idx)) ++#define XWAY_GPHY_LED_EN(idx) BIT(8 + (idx)) ++#define XWAY_GPHY_LED_DA(idx) BIT(idx) ++#define XWAY_MMD_LEDxH(idx) (XWAY_MMD_LED0H + 2 * (idx)) ++#define XWAY_MMD_LEDxL(idx) (XWAY_MMD_LED0L + 2 * (idx)) ++ + #define PHY_ID_PHY11G_1_3 0x030260D1 + #define PHY_ID_PHY22F_1_3 0x030260E1 + #define PHY_ID_PHY11G_1_4 0xD565A400 +@@ -229,20 +236,12 @@ static int xway_gphy_rgmii_init(struct p + XWAY_MDIO_MIICTRL_TXSKEW_MASK, val); + } + +-static int xway_gphy_config_init(struct phy_device *phydev) ++static int xway_gphy_init_leds(struct phy_device *phydev) + { + int err; + u32 ledxh; + u32 ledxl; + +- /* Mask all interrupts */ +- err = phy_write(phydev, XWAY_MDIO_IMASK, 0); +- if (err) +- return err; +- +- /* Clear all pending interrupts */ +- phy_read(phydev, XWAY_MDIO_ISTAT); +- + /* Ensure that integrated led function is enabled for all leds */ + err = phy_write(phydev, XWAY_MDIO_LED, + XWAY_MDIO_LED_LED0_EN | +@@ -276,6 +275,26 @@ static int xway_gphy_config_init(struct + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED2H, ledxh); + phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LED2L, ledxl); + ++ return 0; ++} ++ ++static int xway_gphy_config_init(struct phy_device *phydev) ++{ ++ struct device_node *np = phydev->mdio.dev.of_node; ++ int err; ++ ++ /* Mask all interrupts */ ++ err = phy_write(phydev, XWAY_MDIO_IMASK, 0); ++ if (err) ++ return err; ++ ++ /* Use default LED configuration if 'leds' node isn't defined */ ++ if (!of_get_child_by_name(np, "leds")) ++ xway_gphy_init_leds(phydev); ++ ++ /* Clear all pending interrupts */ ++ phy_read(phydev, XWAY_MDIO_ISTAT); ++ + err = xway_gphy_rgmii_init(phydev); + if (err) + return err; +@@ -347,6 +366,172 @@ static irqreturn_t xway_gphy_handle_inte + return IRQ_HANDLED; + } + ++static int xway_gphy_led_brightness_set(struct phy_device *phydev, ++ u8 index, enum led_brightness value) ++{ ++ int ret; ++ ++ if (index >= XWAY_GPHY_MAX_LEDS) ++ return -EINVAL; ++ ++ /* clear EN and set manual LED state */ ++ ret = phy_modify(phydev, XWAY_MDIO_LED, ++ ((value == LED_OFF) ? XWAY_GPHY_LED_EN(index) : 0) | ++ XWAY_GPHY_LED_DA(index), ++ (value == LED_OFF) ? 0 : XWAY_GPHY_LED_DA(index)); ++ if (ret) ++ return ret; ++ ++ /* clear HW LED setup */ ++ if (value == LED_OFF) { ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDxH(index), 0); ++ if (ret) ++ return ret; ++ ++ return phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDxL(index), 0); ++ } else { ++ return 0; ++ } ++} ++ ++static const unsigned long supported_triggers = (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX)); ++ ++static int xway_gphy_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ if (index >= XWAY_GPHY_MAX_LEDS) ++ return -EINVAL; ++ ++ /* activity triggers are not possible without combination with a link ++ * trigger. ++ */ ++ if (rules & (BIT(TRIGGER_NETDEV_RX) | BIT(TRIGGER_NETDEV_TX)) && ++ !(rules & (BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000)))) ++ return -EOPNOTSUPP; ++ ++ /* All other combinations of the supported triggers are allowed */ ++ if (rules & ~supported_triggers) ++ return -EOPNOTSUPP; ++ ++ return 0; ++} ++ ++static int xway_gphy_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int lval, hval; ++ ++ if (index >= XWAY_GPHY_MAX_LEDS) ++ return -EINVAL; ++ ++ hval = phy_read_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDxH(index)); ++ if (hval < 0) ++ return hval; ++ ++ lval = phy_read_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDxL(index)); ++ if (lval < 0) ++ return lval; ++ ++ if (hval & XWAY_MMD_LEDxH_CON_LINK10) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_10); ++ ++ if (hval & XWAY_MMD_LEDxH_CON_LINK100) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_100); ++ ++ if (hval & XWAY_MMD_LEDxH_CON_LINK1000) ++ *rules |= BIT(TRIGGER_NETDEV_LINK_1000); ++ ++ if ((hval & XWAY_MMD_LEDxH_CON_LINK10) && ++ (hval & XWAY_MMD_LEDxH_CON_LINK100) && ++ (hval & XWAY_MMD_LEDxH_CON_LINK1000)) ++ *rules |= BIT(TRIGGER_NETDEV_LINK); ++ ++ if (lval & XWAY_MMD_LEDxL_PULSE_TXACT) ++ *rules |= BIT(TRIGGER_NETDEV_TX); ++ ++ if (lval & XWAY_MMD_LEDxL_PULSE_RXACT) ++ *rules |= BIT(TRIGGER_NETDEV_RX); ++ ++ return 0; ++} ++ ++static int xway_gphy_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ u16 hval = 0, lval = 0; ++ int ret; ++ ++ if (index >= XWAY_GPHY_MAX_LEDS) ++ return -EINVAL; ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_10)) ++ hval |= XWAY_MMD_LEDxH_CON_LINK10; ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_100)) ++ hval |= XWAY_MMD_LEDxH_CON_LINK100; ++ ++ if (rules & BIT(TRIGGER_NETDEV_LINK) || ++ rules & BIT(TRIGGER_NETDEV_LINK_1000)) ++ hval |= XWAY_MMD_LEDxH_CON_LINK1000; ++ ++ if (rules & BIT(TRIGGER_NETDEV_TX)) ++ lval |= XWAY_MMD_LEDxL_PULSE_TXACT; ++ ++ if (rules & BIT(TRIGGER_NETDEV_RX)) ++ lval |= XWAY_MMD_LEDxL_PULSE_RXACT; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDxH(index), hval); ++ if (ret) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, XWAY_MMD_LEDxL(index), lval); ++ if (ret) ++ return ret; ++ ++ return phy_set_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_EN(index)); ++} ++ ++static int xway_gphy_led_polarity_set(struct phy_device *phydev, int index, ++ unsigned long modes) ++{ ++ bool force_active_low = false, force_active_high = false; ++ u32 mode; ++ ++ if (index >= XWAY_GPHY_MAX_LEDS) ++ return -EINVAL; ++ ++ for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { ++ switch (mode) { ++ case PHY_LED_ACTIVE_LOW: ++ force_active_low = true; ++ break; ++ case PHY_LED_ACTIVE_HIGH: ++ force_active_high = true; ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ ++ if (force_active_low) ++ return phy_set_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_INV(index)); ++ ++ if (force_active_high) ++ return phy_clear_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_INV(index)); ++ ++ unreachable(); ++} ++ + static struct phy_driver xway_gphy[] = { + { + .phy_id = PHY_ID_PHY11G_1_3, +@@ -359,6 +544,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY22F_1_3, + .phy_id_mask = 0xffffffff, +@@ -370,6 +560,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY11G_1_4, + .phy_id_mask = 0xffffffff, +@@ -381,6 +576,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY22F_1_4, + .phy_id_mask = 0xffffffff, +@@ -392,6 +592,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY11G_1_5, + .phy_id_mask = 0xffffffff, +@@ -402,6 +607,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY22F_1_5, + .phy_id_mask = 0xffffffff, +@@ -412,6 +622,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY11G_VR9_1_1, + .phy_id_mask = 0xffffffff, +@@ -422,6 +637,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY22F_VR9_1_1, + .phy_id_mask = 0xffffffff, +@@ -432,6 +652,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY11G_VR9_1_2, + .phy_id_mask = 0xffffffff, +@@ -442,6 +667,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, { + .phy_id = PHY_ID_PHY22F_VR9_1_2, + .phy_id_mask = 0xffffffff, +@@ -452,6 +682,11 @@ static struct phy_driver xway_gphy[] = { + .config_intr = xway_gphy_config_intr, + .suspend = genphy_suspend, + .resume = genphy_resume, ++ .led_brightness_set = xway_gphy_led_brightness_set, ++ .led_hw_is_supported = xway_gphy_led_hw_is_supported, ++ .led_hw_control_get = xway_gphy_led_hw_control_get, ++ .led_hw_control_set = xway_gphy_led_hw_control_set, ++ .led_polarity_set = xway_gphy_led_polarity_set, + }, + }; + module_phy_driver(xway_gphy); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-09-v6.18-net-phy-mxl-gpy-fix-link-properties-on-USXGMII-and-i.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-09-v6.18-net-phy-mxl-gpy-fix-link-properties-on-USXGMII-and-i.patch new file mode 100755 index 0000000..6f3bbfc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-09-v6.18-net-phy-mxl-gpy-fix-link-properties-on-USXGMII-and-i.patch @@ -0,0 +1,56 @@ +From 081156ce13f8fa4e97b5148dc54d8c0ddf02117b Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 20 Nov 2025 15:02:19 +0000 +Subject: [PATCH] net: phy: mxl-gpy: fix link properties on USXGMII and + internal PHYs + +gpy_update_interface() returns early in case the PHY is internal or +connected via USXGMII. In this case the gigabit master/slave property +as well as MDI/MDI-X status also won't be read which seems wrong. +Always read those properties by moving the logic to retrieve them to +gpy_read_status(). + +Fixes: fd8825cd8c6fc ("net: phy: mxl-gpy: Add PHY Auto/MDI/MDI-X set driver for GPY211 chips") +Fixes: 311abcdddc00a ("net: phy: add support to get Master-Slave configuration") +Suggested-by: "Russell King (Oracle)" +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/71fccf3f56742116eb18cc070d2a9810479ea7f9.1763650701.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/mxl-gpy.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -584,13 +584,7 @@ static int gpy_update_interface(struct p + break; + } + +- if (phydev->speed == SPEED_2500 || phydev->speed == SPEED_1000) { +- ret = genphy_read_master_slave(phydev); +- if (ret < 0) +- return ret; +- } +- +- return gpy_update_mdix(phydev); ++ return 0; + } + + static int gpy_read_status(struct phy_device *phydev) +@@ -645,6 +639,16 @@ static int gpy_read_status(struct phy_de + ret = gpy_update_interface(phydev); + if (ret < 0) + return ret; ++ ++ if (phydev->speed == SPEED_2500 || phydev->speed == SPEED_1000) { ++ ret = genphy_read_master_slave(phydev); ++ if (ret < 0) ++ return ret; ++ } ++ ++ ret = gpy_update_mdix(phydev); ++ if (ret < 0) ++ return ret; + } + + return 0; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-10-v6.19-net-phy-mxl-gpy-add-support-for-MxL86211C.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-10-v6.19-net-phy-mxl-gpy-add-support-for-MxL86211C.patch new file mode 100755 index 0000000..7707337 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-10-v6.19-net-phy-mxl-gpy-add-support-for-MxL86211C.patch @@ -0,0 +1,64 @@ +From 9d844da693d6d0813714d9b5b7a58ac05c4cf7f0 Mon Sep 17 00:00:00 2001 +From: Chad Monroe +Date: Sat, 22 Nov 2025 13:32:15 +0000 +Subject: [PATCH] net: phy: mxl-gpy: add support for MxL86211C + +MxL86211C is a smaller and more efficient version of the GPY211C. +Add the PHY ID and phy_driver instance to the mxl-gpy driver. + +Signed-off-by: Chad Monroe +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/cabf3559d6511bed6b8a925f540e3162efc20f6b.1763818120.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mxl-gpy.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -30,6 +30,7 @@ + #define PHY_ID_GPY241B 0x67C9DE40 + #define PHY_ID_GPY241BM 0x67C9DE80 + #define PHY_ID_GPY245B 0x67C9DEC0 ++#define PHY_ID_MXL86211C 0xC1335400 + + #define PHY_CTL1 0x13 + #define PHY_CTL1_MDICD BIT(3) +@@ -1275,6 +1276,28 @@ static struct phy_driver gpy_drivers[] = + .get_wol = gpy_get_wol, + .set_loopback = gpy_loopback, + }, ++ { ++ PHY_ID_MATCH_MODEL(PHY_ID_MXL86211C), ++ .name = "Maxlinear Ethernet MxL86211C", ++ .get_features = genphy_c45_pma_read_abilities, ++ .config_init = gpy_config_init, ++ .probe = gpy_probe, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .config_aneg = gpy_config_aneg, ++ .aneg_done = genphy_c45_aneg_done, ++ .read_status = gpy_read_status, ++ .config_intr = gpy_config_intr, ++ .handle_interrupt = gpy_handle_interrupt, ++ .set_wol = gpy_set_wol, ++ .get_wol = gpy_get_wol, ++ .set_loopback = gpy_loopback, ++ .led_brightness_set = gpy_led_brightness_set, ++ .led_hw_is_supported = gpy_led_hw_is_supported, ++ .led_hw_control_get = gpy_led_hw_control_get, ++ .led_hw_control_set = gpy_led_hw_control_set, ++ .led_polarity_set = gpy_led_polarity_set, ++ }, + }; + module_phy_driver(gpy_drivers); + +@@ -1291,6 +1314,7 @@ static const struct mdio_device_id __may + {PHY_ID_MATCH_MODEL(PHY_ID_GPY241B)}, + {PHY_ID_MATCH_MODEL(PHY_ID_GPY241BM)}, + {PHY_ID_MATCH_MODEL(PHY_ID_GPY245B)}, ++ {PHY_ID_MATCH_MODEL(PHY_ID_MXL86211C)}, + { } + }; + MODULE_DEVICE_TABLE(mdio, gpy_tbl); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-11-v7.0-net-phy-mxl-gpy-implement-SGMII-in-band-configuratio.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-11-v7.0-net-phy-mxl-gpy-implement-SGMII-in-band-configuratio.patch new file mode 100755 index 0000000..0e99bfe --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/730-11-v7.0-net-phy-mxl-gpy-implement-SGMII-in-band-configuratio.patch @@ -0,0 +1,187 @@ +From 9da9633f2f02df7da67ab3b6f84eda4956ae1c5a Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 7 Jan 2026 15:39:16 +0000 +Subject: [PATCH] net: phy: mxl-gpy: implement SGMII in-band configuration + +SGMII in-band autonegotiation was previously kept untouched (and restored +after switching back from 2500Base-X to SGMII). Now that the kernel offers +a way to announce in-band capabilities and nable/disable in-band AN, +implement the .inband_caps and .config_inband driver ops. +This moves the responsibility to configure SGMII in-band AN from the PHY +driver to phylink. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/70f07e46dd96e239a9711e6073e8c04c1d8672d4.1767800226.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/mxl-gpy.c | 61 ++++++++++++++++++++++++++++++--------- + 1 file changed, 47 insertions(+), 14 deletions(-) + +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -568,20 +568,6 @@ static int gpy_update_interface(struct p + case SPEED_100: + case SPEED_10: + phydev->interface = PHY_INTERFACE_MODE_SGMII; +- if (gpy_sgmii_aneg_en(phydev)) +- break; +- /* Enable and restart SGMII ANEG for 10/100/1000Mbps link speed +- * if ANEG is disabled (in 2500-BaseX mode). +- */ +- ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL, +- VSPEC1_SGMII_ANEN_ANRS, +- VSPEC1_SGMII_ANEN_ANRS); +- if (ret < 0) { +- phydev_err(phydev, +- "Error: Enable of SGMII ANEG failed: %d\n", +- ret); +- return ret; +- } + break; + } + +@@ -1022,6 +1008,27 @@ static int gpy_led_polarity_set(struct p + unreachable(); + } + ++static unsigned int gpy_inband_caps(struct phy_device *phydev, ++ phy_interface_t interface) ++{ ++ switch (interface) { ++ case PHY_INTERFACE_MODE_SGMII: ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ case PHY_INTERFACE_MODE_2500BASEX: ++ return LINK_INBAND_DISABLE; ++ default: ++ return 0; ++ } ++} ++ ++static int gpy_config_inband(struct phy_device *phydev, unsigned int modes) ++{ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND1, VSPEC1_SGMII_CTRL, ++ VSPEC1_SGMII_ANEN_ANRS, ++ (modes == LINK_INBAND_DISABLE) ? 0 : ++ VSPEC1_SGMII_ANEN_ANRS); ++} ++ + static struct phy_driver gpy_drivers[] = { + { + PHY_ID_MATCH_MODEL(PHY_ID_GPY2xx), +@@ -1029,6 +1036,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1052,6 +1061,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1074,6 +1085,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1097,6 +1110,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy21x_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1119,6 +1134,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy21x_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1141,6 +1158,8 @@ static struct phy_driver gpy_drivers[] = + .name = "Maxlinear Ethernet GPY212B", + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy21x_config_init, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .probe = gpy_probe, + .suspend = genphy_suspend, + .resume = genphy_resume, +@@ -1164,6 +1183,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy21x_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1187,6 +1208,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy21x_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1209,6 +1232,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy21x_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1231,6 +1256,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1248,6 +1275,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1265,6 +1294,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, +@@ -1282,6 +1313,8 @@ static struct phy_driver gpy_drivers[] = + .get_features = genphy_c45_pma_read_abilities, + .config_init = gpy_config_init, + .probe = gpy_probe, ++ .inband_caps = gpy_inband_caps, ++ .config_inband = gpy_config_inband, + .suspend = genphy_suspend, + .resume = genphy_resume, + .config_aneg = gpy_config_aneg, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/731-v6.18-net-mediatek-wed-Introduce-MT7992-WED-support-to-MT7.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/731-v6.18-net-mediatek-wed-Introduce-MT7992-WED-support-to-MT7.patch new file mode 100755 index 0000000..8b1844d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/731-v6.18-net-mediatek-wed-Introduce-MT7992-WED-support-to-MT7.patch @@ -0,0 +1,116 @@ +From: Lorenzo Bianconi +Date: Tue, 12 Aug 2025 06:57:23 +0200 +Subject: [PATCH] net: mediatek: wed: Introduce MT7992 WED support to MT7988 + SoC + +Introduce the second WDMA RX ring in WED driver for MT7988 SoC since the +Mediatek MT7992 WiFi chipset supports two separated WDMA rings. +Add missing MT7988 configurations to properly support WED for MT7992 in +MT76 driver. + +Co-developed-by: Rex Lu +Signed-off-by: Rex Lu +Signed-off-by: Lorenzo Bianconi +Link: https://patch.msgid.link/20250812-mt7992-wed-support-v3-1-9ada78a819a4@kernel.org +Signed-off-by: Jakub Kicinski +--- + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -59,7 +59,9 @@ struct mtk_wed_flow_block_priv { + static const struct mtk_wed_soc_data mt7622_data = { + .regmap = { + .tx_bm_tkid = 0x088, +- .wpdma_rx_ring0 = 0x770, ++ .wpdma_rx_ring = { ++ 0x770, ++ }, + .reset_idx_tx_mask = GENMASK(3, 0), + .reset_idx_rx_mask = GENMASK(17, 16), + }, +@@ -70,7 +72,9 @@ static const struct mtk_wed_soc_data mt7 + static const struct mtk_wed_soc_data mt7986_data = { + .regmap = { + .tx_bm_tkid = 0x0c8, +- .wpdma_rx_ring0 = 0x770, ++ .wpdma_rx_ring = { ++ 0x770, ++ }, + .reset_idx_tx_mask = GENMASK(1, 0), + .reset_idx_rx_mask = GENMASK(7, 6), + }, +@@ -81,7 +85,10 @@ static const struct mtk_wed_soc_data mt7 + static const struct mtk_wed_soc_data mt7988_data = { + .regmap = { + .tx_bm_tkid = 0x0c8, +- .wpdma_rx_ring0 = 0x7d0, ++ .wpdma_rx_ring = { ++ 0x7d0, ++ 0x7d8, ++ }, + .reset_idx_tx_mask = GENMASK(1, 0), + .reset_idx_rx_mask = GENMASK(7, 6), + }, +@@ -621,8 +628,8 @@ mtk_wed_amsdu_init(struct mtk_wed_device + return ret; + } + +- /* eagle E1 PCIE1 tx ring 22 flow control issue */ +- if (dev->wlan.id == 0x7991) ++ /* Kite and Eagle E1 PCIE1 tx ring 22 flow control issue */ ++ if (dev->wlan.id == 0x7991 || dev->wlan.id == 0x7992) + wed_clr(dev, MTK_WED_AMSDU_FIFO, MTK_WED_AMSDU_IS_PRIOR0_RING); + + wed_set(dev, MTK_WED_CTRL, MTK_WED_CTRL_TX_AMSDU_EN); +@@ -1239,7 +1246,11 @@ mtk_wed_set_wpdma(struct mtk_wed_device + return; + + wed_w32(dev, MTK_WED_WPDMA_RX_GLO_CFG, dev->wlan.wpdma_rx_glo); +- wed_w32(dev, dev->hw->soc->regmap.wpdma_rx_ring0, dev->wlan.wpdma_rx); ++ wed_w32(dev, dev->hw->soc->regmap.wpdma_rx_ring[0], ++ dev->wlan.wpdma_rx[0]); ++ if (mtk_wed_is_v3_or_greater(dev->hw)) ++ wed_w32(dev, dev->hw->soc->regmap.wpdma_rx_ring[1], ++ dev->wlan.wpdma_rx[1]); + + if (!dev->wlan.hw_rro) + return; +@@ -2335,6 +2346,16 @@ mtk_wed_start(struct mtk_wed_device *dev + if (!dev->rx_wdma[i].desc) + mtk_wed_wdma_rx_ring_setup(dev, i, 16, false); + ++ if (dev->wlan.hw_rro) { ++ for (i = 0; i < MTK_WED_RX_PAGE_QUEUES; i++) { ++ u32 addr = MTK_WED_RRO_MSDU_PG_CTRL0(i) + ++ MTK_WED_RING_OFS_COUNT; ++ ++ if (!wed_r32(dev, addr)) ++ wed_w32(dev, addr, 1); ++ } ++ } ++ + mtk_wed_hw_init(dev); + mtk_wed_configure_irq(dev, irq_mask); + +--- a/drivers/net/ethernet/mediatek/mtk_wed.h ++++ b/drivers/net/ethernet/mediatek/mtk_wed.h +@@ -17,7 +17,7 @@ struct mtk_wed_wo; + struct mtk_wed_soc_data { + struct { + u32 tx_bm_tkid; +- u32 wpdma_rx_ring0; ++ u32 wpdma_rx_ring[MTK_WED_RX_QUEUES]; + u32 reset_idx_tx_mask; + u32 reset_idx_rx_mask; + } regmap; +--- a/include/linux/soc/mediatek/mtk_wed.h ++++ b/include/linux/soc/mediatek/mtk_wed.h +@@ -147,7 +147,7 @@ struct mtk_wed_device { + u32 wpdma_tx; + u32 wpdma_txfree; + u32 wpdma_rx_glo; +- u32 wpdma_rx; ++ u32 wpdma_rx[MTK_WED_RX_QUEUES]; + u32 wpdma_rx_rro[MTK_WED_RX_QUEUES]; + u32 wpdma_rx_pg; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/732-v6.18-wifi-mt76-wed-use-proper-wed-reference-in-mt76-wed-d.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/732-v6.18-wifi-mt76-wed-use-proper-wed-reference-in-mt76-wed-d.patch new file mode 100755 index 0000000..883de54 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/732-v6.18-wifi-mt76-wed-use-proper-wed-reference-in-mt76-wed-d.patch @@ -0,0 +1,79 @@ +From: Lorenzo Bianconi +Date: Wed, 8 Oct 2025 12:41:48 +0200 +Subject: [PATCH] wifi: mt76: wed: use proper wed reference in mt76 wed driver + callabacks + +MT7996 driver can use both wed and wed_hif2 devices to offload traffic +from/to the wireless NIC. In the current codebase we assume to always +use the primary wed device in wed callbacks resulting in the following +crash if the hw runs wed_hif2 (e.g. 6GHz link). + +[ 297.455876] Unable to handle kernel read from unreadable memory at virtual address 000000000000080a +[ 297.464928] Mem abort info: +[ 297.467722] ESR = 0x0000000096000005 +[ 297.471461] EC = 0x25: DABT (current EL), IL = 32 bits +[ 297.476766] SET = 0, FnV = 0 +[ 297.479809] EA = 0, S1PTW = 0 +[ 297.482940] FSC = 0x05: level 1 translation fault +[ 297.487809] Data abort info: +[ 297.490679] ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000 +[ 297.496156] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 +[ 297.501196] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 +[ 297.506500] user pgtable: 4k pages, 39-bit VAs, pgdp=0000000107480000 +[ 297.512927] [000000000000080a] pgd=08000001097fb003, p4d=08000001097fb003, pud=08000001097fb003, pmd=0000000000000000 +[ 297.523532] Internal error: Oops: 0000000096000005 [#1] SMP +[ 297.715393] CPU: 2 UID: 0 PID: 45 Comm: kworker/u16:2 Tainted: G O 6.12.50 #0 +[ 297.723908] Tainted: [O]=OOT_MODULE +[ 297.727384] Hardware name: Banana Pi BPI-R4 (2x SFP+) (DT) +[ 297.732857] Workqueue: nf_ft_offload_del nf_flow_rule_route_ipv6 [nf_flow_table] +[ 297.740254] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) +[ 297.747205] pc : mt76_wed_offload_disable+0x64/0xa0 [mt76] +[ 297.752688] lr : mtk_wed_flow_remove+0x58/0x80 +[ 297.757126] sp : ffffffc080fe3ae0 +[ 297.760430] x29: ffffffc080fe3ae0 x28: ffffffc080fe3be0 x27: 00000000deadbef7 +[ 297.767557] x26: ffffff80c5ebca00 x25: 0000000000000001 x24: ffffff80c85f4c00 +[ 297.774683] x23: ffffff80c1875b78 x22: ffffffc080d42cd0 x21: ffffffc080660018 +[ 297.781809] x20: ffffff80c6a076d0 x19: ffffff80c6a043c8 x18: 0000000000000000 +[ 297.788935] x17: 0000000000000000 x16: 0000000000000001 x15: 0000000000000000 +[ 297.796060] x14: 0000000000000019 x13: ffffff80c0ad8ec0 x12: 00000000fa83b2da +[ 297.803185] x11: ffffff80c02700c0 x10: ffffff80c0ad8ec0 x9 : ffffff81fef96200 +[ 297.810311] x8 : ffffff80c02700c0 x7 : ffffff80c02700d0 x6 : 0000000000000002 +[ 297.817435] x5 : 0000000000000400 x4 : 0000000000000000 x3 : 0000000000000000 +[ 297.824561] x2 : 0000000000000001 x1 : 0000000000000800 x0 : ffffff80c6a063c8 +[ 297.831686] Call trace: +[ 297.834123] mt76_wed_offload_disable+0x64/0xa0 [mt76] +[ 297.839254] mtk_wed_flow_remove+0x58/0x80 +[ 297.843342] mtk_flow_offload_cmd+0x434/0x574 +[ 297.847689] mtk_wed_setup_tc_block_cb+0x30/0x40 +[ 297.852295] nf_flow_offload_ipv6_hook+0x7f4/0x964 [nf_flow_table] +[ 297.858466] nf_flow_rule_route_ipv6+0x438/0x4a4 [nf_flow_table] +[ 297.864463] process_one_work+0x174/0x300 +[ 297.868465] worker_thread+0x278/0x430 +[ 297.872204] kthread+0xd8/0xdc +[ 297.875251] ret_from_fork+0x10/0x20 +[ 297.878820] Code: 928b5ae0 8b000273 91400a60 f943fa61 (79401421) +[ 297.884901] ---[ end trace 0000000000000000 ]--- + +Fix the issue detecting the proper wed reference to use running wed +callabacks. + +-- Partial backport for data structure change only (rest is in the mt76 package) + +Fixes: 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support") +Tested-by: Daniel Pawlik +Tested-by: Matteo Croce +Signed-off-by: Lorenzo Bianconi +Link: https://patch.msgid.link/20251008-wed-fixes-v1-1-8f7678583385@kernel.org +Signed-off-by: Felix Fietkau +--- + +--- a/include/linux/soc/mediatek/mtk_wed.h ++++ b/include/linux/soc/mediatek/mtk_wed.h +@@ -154,6 +154,7 @@ struct mtk_wed_device { + bool wcid_512; + bool hw_rro; + bool msi; ++ bool hif2; + + u16 token_start; + unsigned int nbuf; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/733-v6.18-net-mtk-wed-add-dma-mask-limitation-and-GFP_DMA32-fo.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/733-v6.18-net-mtk-wed-add-dma-mask-limitation-and-GFP_DMA32-fo.patch new file mode 100755 index 0000000..c1bb1b9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/733-v6.18-net-mtk-wed-add-dma-mask-limitation-and-GFP_DMA32-fo.patch @@ -0,0 +1,50 @@ +From: Rex Lu +Date: Thu, 9 Oct 2025 08:29:34 +0200 +Subject: [PATCH] net: mtk: wed: add dma mask limitation and GFP_DMA32 for + device with more than 4GB DRAM + +Limit tx/rx buffer address to 32-bit address space for board with more +than 4GB DRAM. + +Fixes: 804775dfc2885 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Fixes: 6757d345dd7db ("net: ethernet: mtk_wed: introduce hw_rro support for MT7988") +Tested-by: Daniel Pawlik +Tested-by: Matteo Croce +Signed-off-by: Rex Lu +Co-developed-by: Lorenzo Bianconi +Signed-off-by: Lorenzo Bianconi +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +--- + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -677,7 +677,7 @@ mtk_wed_tx_buffer_alloc(struct mtk_wed_d + void *buf; + int s; + +- page = __dev_alloc_page(GFP_KERNEL); ++ page = __dev_alloc_page(GFP_KERNEL | GFP_DMA32); + if (!page) + return -ENOMEM; + +@@ -800,7 +800,7 @@ mtk_wed_hwrro_buffer_alloc(struct mtk_we + struct page *page; + int s; + +- page = __dev_alloc_page(GFP_KERNEL); ++ page = __dev_alloc_page(GFP_KERNEL | GFP_DMA32); + if (!page) + return -ENOMEM; + +@@ -2438,6 +2438,10 @@ mtk_wed_attach(struct mtk_wed_device *de + dev->version = hw->version; + dev->hw->pcie_base = mtk_wed_get_pcie_base(dev); + ++ ret = dma_set_mask_and_coherent(hw->dev, DMA_BIT_MASK(32)); ++ if (ret) ++ goto out; ++ + if (hw->eth->dma_dev == hw->eth->dev && + of_dma_is_coherent(hw->eth->dev->of_node)) + mtk_eth_set_dma_device(hw->eth, hw->dev); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/735-v6.13-net-phy-avoid-undefined-behavior-in-_led_polarity_se.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/735-v6.13-net-phy-avoid-undefined-behavior-in-_led_polarity_se.patch new file mode 100755 index 0000000..622d2c3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/735-v6.13-net-phy-avoid-undefined-behavior-in-_led_polarity_se.patch @@ -0,0 +1,64 @@ +From cff865c700711ecc3824b2dfe181637f3ed23c80 Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Tue, 17 Dec 2024 09:10:34 +0100 +Subject: net: phy: avoid undefined behavior in *_led_polarity_set() + +gcc runs into undefined behavior at the end of the three led_polarity_set() +callback functions if it were called with a zero 'modes' argument and it +just ends the function there without returning from it. + +This gets flagged by 'objtool' as a function that continues on +to the next one: + +drivers/net/phy/aquantia/aquantia_leds.o: warning: objtool: aqr_phy_led_polarity_set+0xf: can't find jump dest instruction at .text+0x5d9 +drivers/net/phy/intel-xway.o: warning: objtool: xway_gphy_led_polarity_set() falls through to next function xway_gphy_config_init() +drivers/net/phy/mxl-gpy.o: warning: objtool: gpy_led_polarity_set() falls through to next function gpy_led_hw_control_get() + +There is no point to micro-optimize the behavior here to save a single-digit +number of bytes in the kernel, so just change this to a "return -EINVAL" +as we do when any unexpected bits are set. + +Fixes: 1758af47b98c ("net: phy: intel-xway: add support for PHY LEDs") +Fixes: 9d55e68b19f2 ("net: phy: aquantia: correctly describe LED polarity override") +Fixes: eb89c79c1b8f ("net: phy: mxl-gpy: correctly describe LED polarity") +Signed-off-by: Arnd Bergmann +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20241217081056.238792-1-arnd@kernel.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/aquantia/aquantia_leds.c | 2 +- + drivers/net/phy/intel-xway.c | 2 +- + drivers/net/phy/mxl-gpy.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/aquantia/aquantia_leds.c ++++ b/drivers/net/phy/aquantia/aquantia_leds.c +@@ -156,5 +156,5 @@ int aqr_phy_led_polarity_set(struct phy_ + if (force_active_high || force_active_low) + return aqr_phy_led_active_low_set(phydev, index, force_active_low); + +- unreachable(); ++ return -EINVAL; + } +--- a/drivers/net/phy/intel-xway.c ++++ b/drivers/net/phy/intel-xway.c +@@ -529,7 +529,7 @@ static int xway_gphy_led_polarity_set(st + if (force_active_high) + return phy_clear_bits(phydev, XWAY_MDIO_LED, XWAY_GPHY_LED_INV(index)); + +- unreachable(); ++ return -EINVAL; + } + + static struct phy_driver xway_gphy[] = { +--- a/drivers/net/phy/mxl-gpy.c ++++ b/drivers/net/phy/mxl-gpy.c +@@ -1005,7 +1005,7 @@ static int gpy_led_polarity_set(struct p + if (force_active_high) + return phy_clear_bits(phydev, PHY_LED, PHY_LED_POLARITY(index)); + +- unreachable(); ++ return -EINVAL; + } + + static unsigned int gpy_inband_caps(struct phy_device *phydev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/740-v6.13-net-dsa-mv88e6xxx-Support-LED-control.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/740-v6.13-net-dsa-mv88e6xxx-Support-LED-control.patch new file mode 100755 index 0000000..19268cf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/740-v6.13-net-dsa-mv88e6xxx-Support-LED-control.patch @@ -0,0 +1,1250 @@ +From 7b590490e3aa6bfa38bf6e2069a529017fd3c1d2 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Fri, 13 Oct 2023 00:08:35 +0200 +Subject: [PATCH] net: dsa: mv88e6xxx: Support LED control + +This adds control over the hardware LEDs in the Marvell +MV88E6xxx DSA switch and enables it for MV88E6352. + +This fixes an imminent problem on the Inteno XG6846 which +has a WAN LED that simply do not work with hardware +defaults: driver amendment is necessary. + +The patch is modeled after Christian Marangis LED support +code for the QCA8k DSA switch, I got help with the register +definitions from Tim Harvey. + +After this patch it is possible to activate hardware link +indication like this (or with a similar script): + + cd /sys/class/leds/Marvell\ 88E6352:05:00:green:wan/ + echo netdev > trigger + echo 1 > link + +This makes the green link indicator come up on any link +speed. It is also possible to be more elaborate, like this: + + cd /sys/class/leds/Marvell\ 88E6352:05:00:green:wan/ + echo netdev > trigger + echo 1 > link_1000 + cd /sys/class/leds/Marvell\ 88E6352:05:01:amber:wan/ + echo netdev > trigger + echo 1 > link_100 + +Making the green LED come on for a gigabit link and the +amber LED come on for a 100 mbit link. + +Each port has 2 LED slots (the hardware may use just one or +none) and the hardware triggers are specified in four bits per +LED, and some of the hardware triggers are only available on the +SFP (fiber) uplink. The restrictions are described in the +port.h header file where the registers are described. For +example, selector 1 set for LED 1 on port 5 or 6 will indicate +Fiber 1000 (gigabit) and activity with a blinking LED, but +ONLY for an SFP connection. If port 5/6 is used with something +not SFP, this selector is a noop: something else need to be +selected. + +After the previous series rewriting the MV88E6xxx DT +bindings to use YAML a "leds" subnode is already valid +for each port, in my scratch device tree it looks like +this: + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "off"; + linux,default-trigger = "netdev"; + }; + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "off"; + }; + }; + +This DT config is not yet configuring everything: when the netdev +default trigger is assigned the hw acceleration callbacks are +not called, and there is no way to set the netdev sub-trigger +type (such as link_1000) from the device tree, such as if you want +a gigabit link indicator. This has to be done from userspace at +this point. + +We add LED operations to all switches in the 6352 family: +6172, 6176, 6240 and 6352. + +Signed-off-by: Linus Walleij +--- + drivers/net/dsa/mv88e6xxx/Kconfig | 10 + + drivers/net/dsa/mv88e6xxx/Makefile | 1 + + drivers/net/dsa/mv88e6xxx/chip.c | 38 +- + drivers/net/dsa/mv88e6xxx/chip.h | 11 + + drivers/net/dsa/mv88e6xxx/leds.c | 839 +++++++++++++++++++++++++++++ + drivers/net/dsa/mv88e6xxx/port.c | 1 + + drivers/net/dsa/mv88e6xxx/port.h | 133 +++++ + 7 files changed, 1031 insertions(+), 2 deletions(-) + create mode 100644 drivers/net/dsa/mv88e6xxx/leds.c + +--- a/drivers/net/dsa/mv88e6xxx/Kconfig ++++ b/drivers/net/dsa/mv88e6xxx/Kconfig +@@ -17,3 +17,13 @@ config NET_DSA_MV88E6XXX_PTP + help + Say Y to enable PTP hardware timestamping on Marvell 88E6xxx switch + chips that support it. ++ ++config NET_DSA_MV88E6XXX_LEDS ++ bool "LED support for Marvell 88E6xxx" ++ default y ++ depends on NET_DSA_MV88E6XXX ++ depends on LEDS_CLASS=y || LEDS_CLASS=NET_DSA_MV88E6XXX ++ depends on LEDS_TRIGGERS ++ help ++ This enabled support for controlling the LEDs attached to the ++ Marvell 88E6xxx switch chips. +--- a/drivers/net/dsa/mv88e6xxx/Makefile ++++ b/drivers/net/dsa/mv88e6xxx/Makefile +@@ -9,6 +9,7 @@ mv88e6xxx-objs += global2.o + mv88e6xxx-objs += global2_avb.o + mv88e6xxx-objs += global2_scratch.o + mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += hwtstamp.o ++mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_LEDS) += leds.o + mv88e6xxx-objs += pcs-6185.o + mv88e6xxx-objs += pcs-6352.o + mv88e6xxx-objs += pcs-639x.o +--- a/drivers/net/dsa/mv88e6xxx/chip.c ++++ b/drivers/net/dsa/mv88e6xxx/chip.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -3412,14 +3413,43 @@ static int mv88e6xxx_setup_upstream_port + static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) + { + struct device_node *phy_handle = NULL; ++ struct fwnode_handle *ports_fwnode; ++ struct fwnode_handle *port_fwnode; + struct dsa_switch *ds = chip->ds; ++ struct mv88e6xxx_port *p; + struct dsa_port *dp; + int tx_amp; + int err; + u16 reg; ++ u32 val; + +- chip->ports[port].chip = chip; +- chip->ports[port].port = port; ++ p = &chip->ports[port]; ++ p->chip = chip; ++ p->port = port; ++ ++ /* Look up corresponding fwnode if any */ ++ ports_fwnode = device_get_named_child_node(chip->dev, "ethernet-ports"); ++ if (!ports_fwnode) ++ ports_fwnode = device_get_named_child_node(chip->dev, "ports"); ++ if (ports_fwnode) { ++ fwnode_for_each_child_node(ports_fwnode, port_fwnode) { ++ if (fwnode_property_read_u32(port_fwnode, "reg", &val)) ++ continue; ++ if (val == port) { ++ p->fwnode = port_fwnode; ++ p->fiber = fwnode_property_present(port_fwnode, "sfp"); ++ break; ++ } ++ } ++ } else { ++ dev_dbg(chip->dev, "no ethernet ports node defined for the device\n"); ++ } ++ ++ if (chip->info->ops->port_setup_leds) { ++ err = chip->info->ops->port_setup_leds(chip, port); ++ if (err && err != -EOPNOTSUPP) ++ return err; ++ } + + err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, + SPEED_UNFORCED, DUPLEX_UNFORCED, +@@ -4653,6 +4683,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +@@ -4755,6 +4786,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +@@ -5030,6 +5062,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +@@ -5460,6 +5493,7 @@ static const struct mv88e6xxx_ops mv88e6 + .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, + .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, + .port_get_cmode = mv88e6352_port_get_cmode, ++ .port_setup_leds = mv88e6xxx_port_setup_leds, + .port_setup_message_port = mv88e6xxx_setup_message_port, + .stats_snapshot = mv88e6320_g1_stats_snapshot, + .stats_set_histogram = mv88e6095_g1_stats_set_histogram, +--- a/drivers/net/dsa/mv88e6xxx/chip.h ++++ b/drivers/net/dsa/mv88e6xxx/chip.h +@@ -13,7 +13,9 @@ + #include + #include + #include ++#include + #include ++#include + #include + #include + #include +@@ -276,6 +278,7 @@ struct mv88e6xxx_vlan { + struct mv88e6xxx_port { + struct mv88e6xxx_chip *chip; + int port; ++ struct fwnode_handle *fwnode; + struct mv88e6xxx_vlan bridge_pvid; + u64 serdes_stats[2]; + u64 atu_member_violation; +@@ -290,6 +293,11 @@ struct mv88e6xxx_port { + struct devlink_region *region; + void *pcs_private; + ++ /* LED related information */ ++ bool fiber; ++ struct led_classdev led0; ++ struct led_classdev led1; ++ + /* MacAuth Bypass control flag */ + bool mab; + }; +@@ -574,6 +582,9 @@ struct mv88e6xxx_ops { + phy_interface_t mode); + int (*port_get_cmode)(struct mv88e6xxx_chip *chip, int port, u8 *cmode); + ++ /* LED control */ ++ int (*port_setup_leds)(struct mv88e6xxx_chip *chip, int port); ++ + /* Some devices have a per port register indicating what is + * the upstream port this port should forward to. + */ +--- /dev/null ++++ b/drivers/net/dsa/mv88e6xxx/leds.c +@@ -0,0 +1,839 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++#include ++#include ++#include ++ ++#include "chip.h" ++#include "global2.h" ++#include "port.h" ++ ++/* Offset 0x16: LED control */ ++ ++static int mv88e6xxx_port_led_write(struct mv88e6xxx_chip *chip, int port, u16 reg) ++{ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_UPDATE; ++ ++ return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_LED_CONTROL, reg); ++} ++ ++static int mv88e6xxx_port_led_read(struct mv88e6xxx_chip *chip, int port, ++ u16 ptr, u16 *val) ++{ ++ int err; ++ ++ err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_LED_CONTROL, ptr); ++ if (err) ++ return err; ++ ++ err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_LED_CONTROL, val); ++ *val &= 0x3ff; ++ ++ return err; ++} ++ ++static int mv88e6xxx_led_brightness_set(struct mv88e6xxx_port *p, int led, ++ int brightness) ++{ ++ u16 reg; ++ int err; ++ ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, ++ ®); ++ if (err) ++ return err; ++ ++ if (led == 1) ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ else ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ ++ if (brightness) { ++ /* Selector 0x0f == Force LED ON */ ++ if (led == 1) ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELF; ++ else ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELF; ++ } else { ++ /* Selector 0x0e == Force LED OFF */ ++ if (led == 1) ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELE; ++ else ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELE; ++ } ++ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL; ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int mv88e6xxx_led0_brightness_set_blocking(struct led_classdev *ldev, ++ enum led_brightness brightness) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_brightness_set(p, 0, brightness); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int mv88e6xxx_led1_brightness_set_blocking(struct led_classdev *ldev, ++ enum led_brightness brightness) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_brightness_set(p, 1, brightness); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++struct mv88e6xxx_led_hwconfig { ++ int led; ++ u8 portmask; ++ unsigned long rules; ++ bool fiber; ++ bool blink_activity; ++ u16 selector; ++}; ++ ++/* The following is a lookup table to check what rules we can support on a ++ * certain LED given restrictions such as that some rules only work with fiber ++ * (SFP) connections and some blink on activity by default. ++ */ ++#define MV88E6XXX_PORTS_0_3 (BIT(0) | BIT(1) | BIT(2) | BIT(3)) ++#define MV88E6XXX_PORTS_4_5 (BIT(4) | BIT(5)) ++#define MV88E6XXX_PORT_4 BIT(4) ++#define MV88E6XXX_PORT_5 BIT(5) ++ ++/* Entries are listed in selector order. ++ * ++ * These configurations vary across different switch families, list ++ * different tables per-family here. ++ */ ++static const struct mv88e6xxx_led_hwconfig mv88e6352_led_hwconfigs[] = { ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORT_4, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL0, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL0, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL3, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_1000), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL3, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_4_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .fiber = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL3, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_4, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL4, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL5, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL6, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL6, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORT_4, ++ .rules = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL6, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL6, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL7, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL7, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL8, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL8, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORT_5, ++ .rules = BIT(TRIGGER_NETDEV_LINK), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL8, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SEL9, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SEL9, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_10), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SELA, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SELA, ++ }, ++ { ++ .led = 0, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED0_SELB, ++ }, ++ { ++ .led = 1, ++ .portmask = MV88E6XXX_PORTS_0_3, ++ .rules = BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK_1000), ++ .blink_activity = true, ++ .selector = MV88E6XXX_PORT_LED_CONTROL_LED1_SELB, ++ }, ++}; ++ ++/* mv88e6xxx_led_match_selector() - look up the appropriate LED mode selector ++ * @p: port state container ++ * @led: LED number, 0 or 1 ++ * @blink_activity: blink the LED (usually blink on indicated activity) ++ * @fiber: the link is connected to fiber such as SFP ++ * @rules: LED status flags from the LED classdev core ++ * @selector: fill in the selector in this parameter with an OR operation ++ */ ++static int mv88e6xxx_led_match_selector(struct mv88e6xxx_port *p, int led, bool blink_activity, ++ bool fiber, unsigned long rules, u16 *selector) ++{ ++ const struct mv88e6xxx_led_hwconfig *conf; ++ int i; ++ ++ /* No rules means we turn the LED off */ ++ if (!rules) { ++ if (led == 1) ++ *selector |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELE; ++ else ++ *selector |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELE; ++ return 0; ++ } ++ ++ /* TODO: these rules are for MV88E6352, when adding other families, ++ * think about making sure you select the table that match the ++ * specific switch family. ++ */ ++ for (i = 0; i < ARRAY_SIZE(mv88e6352_led_hwconfigs); i++) { ++ conf = &mv88e6352_led_hwconfigs[i]; ++ ++ if (conf->led != led) ++ continue; ++ ++ if (!(conf->portmask & BIT(p->port))) ++ continue; ++ ++ if (conf->blink_activity != blink_activity) ++ continue; ++ ++ if (conf->fiber != fiber) ++ continue; ++ ++ if (conf->rules == rules) { ++ dev_dbg(p->chip->dev, "port%d LED %d set selector %04x for rules %08lx\n", ++ p->port, led, conf->selector, rules); ++ *selector |= conf->selector; ++ return 0; ++ } ++ } ++ ++ return -EOPNOTSUPP; ++} ++ ++/* mv88e6xxx_led_match_selector() - find Linux netdev rules from a selector value ++ * @p: port state container ++ * @selector: the selector value from the LED actity register ++ * @led: LED number, 0 or 1 ++ * @rules: Linux netdev activity rules found from selector ++ */ ++static int ++mv88e6xxx_led_match_rule(struct mv88e6xxx_port *p, u16 selector, int led, unsigned long *rules) ++{ ++ const struct mv88e6xxx_led_hwconfig *conf; ++ int i; ++ ++ /* Find the selector in the table, we just look for the right selector ++ * and ignore if the activity has special properties such as blinking ++ * or is fiber-only. ++ */ ++ for (i = 0; i < ARRAY_SIZE(mv88e6352_led_hwconfigs); i++) { ++ conf = &mv88e6352_led_hwconfigs[i]; ++ ++ if (conf->led != led) ++ continue; ++ ++ if (!(conf->portmask & BIT(p->port))) ++ continue; ++ ++ if (conf->selector == selector) { ++ dev_dbg(p->chip->dev, "port%d LED %d has selector %04x, rules %08lx\n", ++ p->port, led, selector, conf->rules); ++ *rules = conf->rules; ++ return 0; ++ } ++ } ++ ++ return -EINVAL; ++} ++ ++/* mv88e6xxx_led_get_selector() - get the appropriate LED mode selector ++ * @p: port state container ++ * @led: LED number, 0 or 1 ++ * @fiber: the link is connected to fiber such as SFP ++ * @rules: LED status flags from the LED classdev core ++ * @selector: fill in the selector in this parameter with an OR operation ++ */ ++static int mv88e6xxx_led_get_selector(struct mv88e6xxx_port *p, int led, ++ bool fiber, unsigned long rules, u16 *selector) ++{ ++ int err; ++ ++ /* What happens here is that we first try to locate a trigger with solid ++ * indicator (such as LED is on for a 1000 link) else we try a second ++ * sweep to find something suitable with a trigger that will blink on ++ * activity. ++ */ ++ err = mv88e6xxx_led_match_selector(p, led, false, fiber, rules, selector); ++ if (err) ++ return mv88e6xxx_led_match_selector(p, led, true, fiber, rules, selector); ++ ++ return 0; ++} ++ ++/* Sets up the hardware blinking period */ ++static int mv88e6xxx_led_set_blinking_period(struct mv88e6xxx_port *p, int led, ++ unsigned long delay_on, unsigned long delay_off) ++{ ++ unsigned long period; ++ u16 reg; ++ ++ period = delay_on + delay_off; ++ ++ reg = 0; ++ ++ switch (period) { ++ case 21: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_21MS; ++ break; ++ case 42: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_42MS; ++ break; ++ case 84: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_84MS; ++ break; ++ case 168: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_168MS; ++ break; ++ case 336: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_336MS; ++ break; ++ case 672: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_672MS; ++ break; ++ default: ++ /* Fall back to software blinking */ ++ return -EINVAL; ++ } ++ ++ /* This is essentially PWM duty cycle: how long time of the period ++ * will the LED be on. Zero isn't great in most cases. ++ */ ++ switch (delay_on) { ++ case 0: ++ /* This is usually pretty useless and will make the LED look OFF */ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_NONE; ++ break; ++ case 21: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_21MS; ++ break; ++ case 42: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_42MS; ++ break; ++ case 84: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_84MS; ++ break; ++ case 168: ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_168MS; ++ break; ++ default: ++ /* Just use something non-zero */ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_21MS; ++ break; ++ } ++ ++ /* Set up blink rate */ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_STRETCH_BLINK; ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int mv88e6xxx_led_blink_set(struct mv88e6xxx_port *p, int led, ++ unsigned long *delay_on, unsigned long *delay_off) ++{ ++ u16 reg; ++ int err; ++ ++ /* Choose a sensible default 336 ms (~3 Hz) */ ++ if ((*delay_on == 0) && (*delay_off == 0)) { ++ *delay_on = 168; ++ *delay_off = 168; ++ } ++ ++ /* No off delay is just on */ ++ if (*delay_off == 0) ++ return mv88e6xxx_led_brightness_set(p, led, 1); ++ ++ err = mv88e6xxx_led_set_blinking_period(p, led, *delay_on, *delay_off); ++ if (err) ++ return err; ++ ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, ++ ®); ++ if (err) ++ return err; ++ ++ if (led == 1) ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ else ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ ++ /* This will select the forced blinking status */ ++ if (led == 1) ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED1_SELD; ++ else ++ reg |= MV88E6XXX_PORT_LED_CONTROL_LED0_SELD; ++ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL; ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int mv88e6xxx_led0_blink_set(struct led_classdev *ldev, ++ unsigned long *delay_on, ++ unsigned long *delay_off) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_blink_set(p, 0, delay_on, delay_off); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int mv88e6xxx_led1_blink_set(struct led_classdev *ldev, ++ unsigned long *delay_on, ++ unsigned long *delay_off) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_blink_set(p, 1, delay_on, delay_off); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int ++mv88e6xxx_led0_hw_control_is_supported(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ u16 selector = 0; ++ ++ return mv88e6xxx_led_get_selector(p, 0, p->fiber, rules, &selector); ++} ++ ++static int ++mv88e6xxx_led1_hw_control_is_supported(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ u16 selector = 0; ++ ++ return mv88e6xxx_led_get_selector(p, 1, p->fiber, rules, &selector); ++} ++ ++static int mv88e6xxx_led_hw_control_set(struct mv88e6xxx_port *p, ++ int led, unsigned long rules) ++{ ++ u16 reg; ++ int err; ++ ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, ++ ®); ++ if (err) ++ return err; ++ ++ if (led == 1) ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ else ++ reg &= ~MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ ++ err = mv88e6xxx_led_get_selector(p, led, p->fiber, rules, ®); ++ if (err) ++ return err; ++ ++ reg |= MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL; ++ ++ if (led == 0) ++ dev_dbg(p->chip->dev, "LED 0 hw control on port %d trigger selector 0x%02x\n", ++ p->port, ++ (unsigned int)(reg & MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK)); ++ else ++ dev_dbg(p->chip->dev, "LED 1 hw control on port %d trigger selector 0x%02x\n", ++ p->port, ++ (unsigned int)(reg & MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK) >> 4); ++ ++ return mv88e6xxx_port_led_write(p->chip, p->port, reg); ++} ++ ++static int ++mv88e6xxx_led_hw_control_get(struct mv88e6xxx_port *p, int led, unsigned long *rules) ++{ ++ u16 val; ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_port_led_read(p->chip, p->port, ++ MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL, &val); ++ mv88e6xxx_reg_unlock(p->chip); ++ if (err) ++ return err; ++ ++ /* Mask out the selector bits for this port */ ++ if (led == 1) { ++ val &= MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK; ++ /* It's forced blinking/OFF/ON */ ++ if (val == MV88E6XXX_PORT_LED_CONTROL_LED1_SELD || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED1_SELE || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED1_SELF) { ++ *rules = 0; ++ return 0; ++ } ++ } else { ++ val &= MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK; ++ /* It's forced blinking/OFF/ON */ ++ if (val == MV88E6XXX_PORT_LED_CONTROL_LED0_SELD || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED0_SELE || ++ val == MV88E6XXX_PORT_LED_CONTROL_LED0_SELF) { ++ *rules = 0; ++ return 0; ++ } ++ } ++ ++ err = mv88e6xxx_led_match_rule(p, val, led, rules); ++ if (!err) ++ return 0; ++ ++ dev_dbg(p->chip->dev, "couldn't find matching selector for %04x\n", val); ++ *rules = 0; ++ return 0; ++} ++ ++static int ++mv88e6xxx_led0_hw_control_set(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_hw_control_set(p, 0, rules); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int ++mv88e6xxx_led1_hw_control_set(struct led_classdev *ldev, unsigned long rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ int err; ++ ++ mv88e6xxx_reg_lock(p->chip); ++ err = mv88e6xxx_led_hw_control_set(p, 1, rules); ++ mv88e6xxx_reg_unlock(p->chip); ++ ++ return err; ++} ++ ++static int ++mv88e6xxx_led0_hw_control_get(struct led_classdev *ldev, unsigned long *rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ ++ return mv88e6xxx_led_hw_control_get(p, 0, rules); ++} ++ ++static int ++mv88e6xxx_led1_hw_control_get(struct led_classdev *ldev, unsigned long *rules) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ ++ return mv88e6xxx_led_hw_control_get(p, 1, rules); ++} ++ ++static struct device *mv88e6xxx_led_hw_control_get_device(struct mv88e6xxx_port *p) ++{ ++ struct dsa_port *dp; ++ ++ dp = dsa_to_port(p->chip->ds, p->port); ++ if (!dp) ++ return NULL; ++ if (dp->user) ++ return &dp->user->dev; ++ return NULL; ++} ++ ++static struct device * ++mv88e6xxx_led0_hw_control_get_device(struct led_classdev *ldev) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led0); ++ ++ return mv88e6xxx_led_hw_control_get_device(p); ++} ++ ++static struct device * ++mv88e6xxx_led1_hw_control_get_device(struct led_classdev *ldev) ++{ ++ struct mv88e6xxx_port *p = container_of(ldev, struct mv88e6xxx_port, led1); ++ ++ return mv88e6xxx_led_hw_control_get_device(p); ++} ++ ++int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port) ++{ ++ struct fwnode_handle *led = NULL, *leds = NULL; ++ struct led_init_data init_data = { }; ++ enum led_default_state state; ++ struct mv88e6xxx_port *p; ++ struct led_classdev *l; ++ struct device *dev; ++ u32 led_num; ++ int ret; ++ ++ /* LEDs are on ports 1,2,3,4, 5 and 6 (index 0..5), no more */ ++ if (port > 5) ++ return -EOPNOTSUPP; ++ ++ p = &chip->ports[port]; ++ if (!p->fwnode) ++ return 0; ++ ++ dev = chip->dev; ++ ++ leds = fwnode_get_named_child_node(p->fwnode, "leds"); ++ if (!leds) { ++ dev_dbg(dev, "No Leds node specified in device tree for port %d!\n", ++ port); ++ return 0; ++ } ++ ++ fwnode_for_each_child_node(leds, led) { ++ /* Reg represent the led number of the port, max 2 ++ * LEDs can be connected to each port, in some designs ++ * only one LED is connected. ++ */ ++ if (fwnode_property_read_u32(led, "reg", &led_num)) ++ continue; ++ if (led_num > 1) { ++ dev_err(dev, "invalid LED specified port %d\n", port); ++ return -EINVAL; ++ } ++ ++ if (led_num == 0) ++ l = &p->led0; ++ else ++ l = &p->led1; ++ ++ state = led_init_default_state_get(led); ++ switch (state) { ++ case LEDS_DEFSTATE_ON: ++ l->brightness = 1; ++ mv88e6xxx_led_brightness_set(p, led_num, 1); ++ break; ++ case LEDS_DEFSTATE_KEEP: ++ break; ++ default: ++ l->brightness = 0; ++ mv88e6xxx_led_brightness_set(p, led_num, 0); ++ } ++ ++ l->max_brightness = 1; ++ if (led_num == 0) { ++ l->brightness_set_blocking = mv88e6xxx_led0_brightness_set_blocking; ++ l->blink_set = mv88e6xxx_led0_blink_set; ++ l->hw_control_is_supported = mv88e6xxx_led0_hw_control_is_supported; ++ l->hw_control_set = mv88e6xxx_led0_hw_control_set; ++ l->hw_control_get = mv88e6xxx_led0_hw_control_get; ++ l->hw_control_get_device = mv88e6xxx_led0_hw_control_get_device; ++ } else { ++ l->brightness_set_blocking = mv88e6xxx_led1_brightness_set_blocking; ++ l->blink_set = mv88e6xxx_led1_blink_set; ++ l->hw_control_is_supported = mv88e6xxx_led1_hw_control_is_supported; ++ l->hw_control_set = mv88e6xxx_led1_hw_control_set; ++ l->hw_control_get = mv88e6xxx_led1_hw_control_get; ++ l->hw_control_get_device = mv88e6xxx_led1_hw_control_get_device; ++ } ++ l->hw_control_trigger = "netdev"; ++ ++ init_data.default_label = ":port"; ++ init_data.fwnode = led; ++ init_data.devname_mandatory = true; ++ init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d:0%d", chip->info->name, ++ port, led_num); ++ if (!init_data.devicename) ++ return -ENOMEM; ++ ++ ret = devm_led_classdev_register_ext(dev, l, &init_data); ++ kfree(init_data.devicename); ++ ++ if (ret) { ++ dev_err(dev, "Failed to init LED %d for port %d", led_num, port); ++ return ret; ++ } ++ } ++ ++ return 0; ++} +--- a/drivers/net/dsa/mv88e6xxx/port.c ++++ b/drivers/net/dsa/mv88e6xxx/port.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + + #include "chip.h" + #include "global2.h" +--- a/drivers/net/dsa/mv88e6xxx/port.h ++++ b/drivers/net/dsa/mv88e6xxx/port.h +@@ -309,6 +309,130 @@ + /* Offset 0x13: OutFiltered Counter */ + #define MV88E6XXX_PORT_OUT_FILTERED 0x13 + ++/* Offset 0x16: LED Control */ ++#define MV88E6XXX_PORT_LED_CONTROL 0x16 ++#define MV88E6XXX_PORT_LED_CONTROL_UPDATE BIT(15) ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_MASK GENMASK(14, 12) ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_LED01_CTRL (0x00 << 12) /* Control for LED 0 and 1 */ ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_STRETCH_BLINK (0x06 << 12) /* Stetch and Blink Rate */ ++#define MV88E6XXX_PORT_LED_CONTROL_POINTER_CNTL_SPECIAL (0x07 << 12) /* Control for the Port's Special LED */ ++#define MV88E6XXX_PORT_LED_CONTROL_DATA_MASK GENMASK(10, 0) ++/* Selection masks valid for either port 1,2,3,4 or 5 */ ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL_MASK GENMASK(3, 0) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL_MASK GENMASK(7, 4) ++/* Selection control for LED 0 and 1, ports 5 and 6 only has LED 0 ++ * Bits Function ++ * 0..3 LED 0 control selector on ports 1-5 ++ * 4..7 LED 1 control selector on ports 1-4 on port 5 this controls LED 0 of port 6 ++ * ++ * Sel Port LED Function for the 6352 family: ++ * 0 1-4 0 Link/Act/Speed by Blink Rate (off=no link, on=link, blink=activity, blink speed=link speed) ++ * 1-4 1 Port 2's Special LED ++ * 5-6 0 Port 5 Link/Act (off=no link, on=link, blink=activity) ++ * 5-6 1 Port 6 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 1 1-4 0 100/1000 Link/Act (off=no link, on=100 or 1000 link, blink=activity) ++ * 1-4 1 10/100 Link Act (off=no link, on=10 or 100 link, blink=activity) ++ * 5-6 0 Fiber 100 Link/Act (off=no link, on=link 100, blink=activity) ++ * 5-6 1 Fiber 1000 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 2 1-4 0 1000 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 1-4 1 10/100 Link/Act (off=no link, on=10 or 100 link, blink=activity) ++ * 5-6 0 Fiber 1000 Link/Act (off=no link, on=link 1000, blink=activity) ++ * 5-6 1 Fiber 100 Link/Act (off=no link, on=link 100, blink=activity) ++ * 3 1-4 0 Link/Act (off=no link, on=link, blink=activity) ++ * 1-4 1 1000 Link (off=no link, on=1000 link) ++ * 5-6 0 Port 0's Special LED ++ * 5-6 1 Fiber Link (off=no link, on=link) ++ * 4 1-4 0 Port 0's Special LED ++ * 1-4 1 Port 1's Special LED ++ * 5-6 0 Port 1's Special LED ++ * 5-6 1 Port 5 Link/Act (off=no link, on=link, blink=activity) ++ * 5 1-4 0 Reserved ++ * 1-4 1 Reserved ++ * 5-6 0 Port 2's Special LED ++ * 5-6 1 Port 6 Link (off=no link, on=link) ++ * 6 1-4 0 Duplex/Collision (off=half-duplex,on=full-duplex,blink=collision) ++ * 1-4 1 10/1000 Link/Act (off=no link, on=10 or 1000 link, blink=activity) ++ * 5-6 0 Port 5 Duplex/Collision (off=half-duplex, on=full-duplex, blink=col) ++ * 5-6 1 Port 6 Duplex/Collision (off=half-duplex, on=full-duplex, blink=col) ++ * 7 1-4 0 10/1000 Link/Act (off=no link, on=10 or 1000 link, blink=activity) ++ * 1-4 1 10/1000 Link (off=no link, on=10 or 1000 link) ++ * 5-6 0 Port 5 Link/Act/Speed by Blink rate (off=no link, on=link, blink=activity, blink speed=link speed) ++ * 5-6 1 Port 6 Link/Act/Speed by Blink rate (off=no link, on=link, blink=activity, blink speed=link speed) ++ * 8 1-4 0 Link (off=no link, on=link) ++ * 1-4 1 Activity (off=no link, blink on=activity) ++ * 5-6 0 Port 6 Link/Act (off=no link, on=link, blink=activity) ++ * 5-6 1 Port 0's Special LED ++ * 9 1-4 0 10 Link (off=no link, on=10 link) ++ * 1-4 1 100 Link (off=no link, on=100 link) ++ * 5-6 0 Reserved ++ * 5-6 1 Port 1's Special LED ++ * a 1-4 0 10 Link/Act (off=no link, on=10 link, blink=activity) ++ * 1-4 1 100 Link/Act (off=no link, on=100 link, blink=activity) ++ * 5-6 0 Reserved ++ * 5-6 1 Port 2's Special LED ++ * b 1-4 0 100/1000 Link (off=no link, on=100 or 1000 link) ++ * 1-4 1 10/100 Link (off=no link, on=100 link, blink=activity) ++ * 5-6 0 Reserved ++ * 5-6 1 Reserved ++ * c * * PTP Act (blink on=PTP activity) ++ * d * * Force Blink ++ * e * * Force Off ++ * f * * Force On ++ */ ++/* Select LED0 output */ ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL0 0x0 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL1 0x1 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL2 0x2 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL3 0x3 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL4 0x4 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL5 0x5 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL6 0x6 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL7 0x7 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL8 0x8 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SEL9 0x9 ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELA 0xa ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELB 0xb ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELC 0xc ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELD 0xd ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELE 0xe ++#define MV88E6XXX_PORT_LED_CONTROL_LED0_SELF 0xf ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL0 (0x0 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL1 (0x1 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL2 (0x2 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL3 (0x3 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL4 (0x4 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL5 (0x5 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL6 (0x6 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL7 (0x7 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL8 (0x8 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SEL9 (0x9 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELA (0xa << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELB (0xb << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELC (0xc << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELD (0xd << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELE (0xe << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_LED1_SELF (0xf << 4) ++/* Stretch and Blink Rate Control (Index 0x06 of LED Control) */ ++/* Pulse Stretch Selection for all LED's on this port */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_NONE (0 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_21MS (1 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_42MS (2 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_84MS (3 << 4) ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_PULSE_STRETCH_168MS (4 << 4) ++/* Blink Rate Selection for all LEDs on this port */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_21MS 0 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_42MS 1 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_84MS 2 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_168MS 3 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_336MS 4 ++#define MV88E6XXX_PORT_LED_CONTROL_0x06_BLINK_RATE_672MS 5 ++ /* Control for Special LED (Index 0x7 of LED Control on Port0) */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x07_P0_LAN_LINKACT_SHIFT 0 /* bits 6:0 LAN Link Activity LED */ ++/* Control for Special LED (Index 0x7 of LED Control on Port 1) */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x07_P1_WAN_LINKACT_SHIFT 0 /* bits 6:0 WAN Link Activity LED */ ++/* Control for Special LED (Index 0x7 of LED Control on Port 2) */ ++#define MV88E6XXX_PORT_LED_CONTROL_0x07_P2_PTP_ACT 0 /* bits 6:0 PTP Activity */ ++ + /* Offset 0x18: IEEE Priority Mapping Table */ + #define MV88E6390_PORT_IEEE_PRIO_MAP_TABLE 0x18 + #define MV88E6390_PORT_IEEE_PRIO_MAP_TABLE_UPDATE 0x8000 +@@ -457,6 +581,15 @@ int mv88e6393x_port_set_cmode(struct mv8 + phy_interface_t mode); + int mv88e6185_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode); + int mv88e6352_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode); ++#ifdef CONFIG_NET_DSA_MV88E6XXX_LEDS ++int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, int port); ++#else ++static inline int mv88e6xxx_port_setup_leds(struct mv88e6xxx_chip *chip, ++ int port) ++{ ++ return 0; ++} ++#endif + int mv88e6xxx_port_drop_untagged(struct mv88e6xxx_chip *chip, int port, + bool drop_untagged); + int mv88e6xxx_port_set_map_da(struct mv88e6xxx_chip *chip, int port, bool map); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/741-v6.13-net-dsa-mv88e6xxx-fix-unreleased-fwnode_handle-in-se.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/741-v6.13-net-dsa-mv88e6xxx-fix-unreleased-fwnode_handle-in-se.patch new file mode 100755 index 0000000..2c81983 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/741-v6.13-net-dsa-mv88e6xxx-fix-unreleased-fwnode_handle-in-se.patch @@ -0,0 +1,31 @@ +From b8ee7a11c75436b85fa1641aa5f970de0f8a575c Mon Sep 17 00:00:00 2001 +From: Javier Carrasco +Date: Sat, 19 Oct 2024 22:16:49 +0200 +Subject: net: dsa: mv88e6xxx: fix unreleased fwnode_handle in setup_port() + +'ports_fwnode' is initialized via device_get_named_child_node(), which +requires a call to fwnode_handle_put() when the variable is no longer +required to avoid leaking memory. + +Add the missing fwnode_handle_put() after 'ports_fwnode' has been used +and is no longer required. + +Fixes: 94a2a84f5e9e ("net: dsa: mv88e6xxx: Support LED control") +Signed-off-by: Javier Carrasco +Reviewed-by: Andrew Lunn +Reviewed-by: Linus Walleij +Signed-off-by: David S. Miller +--- + drivers/net/dsa/mv88e6xxx/chip.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/dsa/mv88e6xxx/chip.c ++++ b/drivers/net/dsa/mv88e6xxx/chip.c +@@ -3441,6 +3441,7 @@ static int mv88e6xxx_setup_port(struct m + break; + } + } ++ fwnode_handle_put(ports_fwnode); + } else { + dev_dbg(chip->dev, "no ethernet ports node defined for the device\n"); + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/742-v6.17-net-dsa-mv88e6xxx-Fix-fwnode-reference-leaks-in-mv88.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/742-v6.17-net-dsa-mv88e6xxx-Fix-fwnode-reference-leaks-in-mv88.patch new file mode 100755 index 0000000..6e0fbb8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/742-v6.17-net-dsa-mv88e6xxx-Fix-fwnode-reference-leaks-in-mv88.patch @@ -0,0 +1,68 @@ +From f63e7c8a83892781f6ceb55566f9497639c44555 Mon Sep 17 00:00:00 2001 +From: Miaoqian Lin +Date: Mon, 1 Sep 2025 15:32:23 +0800 +Subject: net: dsa: mv88e6xxx: Fix fwnode reference leaks in + mv88e6xxx_port_setup_leds + +Fix multiple fwnode reference leaks: + +1. The function calls fwnode_get_named_child_node() to get the "leds" node, + but never calls fwnode_handle_put(leds) to release this reference. + +2. Within the fwnode_for_each_child_node() loop, the early return + paths that don't properly release the "led" fwnode reference. + +This fix follows the same pattern as commit d029edefed39 +("net dsa: qca8k: fix usages of device_get_named_child_node()") + +Fixes: 94a2a84f5e9e ("net: dsa: mv88e6xxx: Support LED control") +Cc: stable@vger.kernel.org +Signed-off-by: Miaoqian Lin +Reviewed-by: Linus Walleij +Link: https://patch.msgid.link/20250901073224.2273103-1-linmq006@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/mv88e6xxx/leds.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +--- a/drivers/net/dsa/mv88e6xxx/leds.c ++++ b/drivers/net/dsa/mv88e6xxx/leds.c +@@ -779,7 +779,8 @@ int mv88e6xxx_port_setup_leds(struct mv8 + continue; + if (led_num > 1) { + dev_err(dev, "invalid LED specified port %d\n", port); +- return -EINVAL; ++ ret = -EINVAL; ++ goto err_put_led; + } + + if (led_num == 0) +@@ -823,17 +824,25 @@ int mv88e6xxx_port_setup_leds(struct mv8 + init_data.devname_mandatory = true; + init_data.devicename = kasprintf(GFP_KERNEL, "%s:0%d:0%d", chip->info->name, + port, led_num); +- if (!init_data.devicename) +- return -ENOMEM; ++ if (!init_data.devicename) { ++ ret = -ENOMEM; ++ goto err_put_led; ++ } + + ret = devm_led_classdev_register_ext(dev, l, &init_data); + kfree(init_data.devicename); + + if (ret) { + dev_err(dev, "Failed to init LED %d for port %d", led_num, port); +- return ret; ++ goto err_put_led; + } + } + ++ fwnode_handle_put(leds); + return 0; ++ ++err_put_led: ++ fwnode_handle_put(led); ++ fwnode_handle_put(leds); ++ return ret; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/750-v7.0-net-phy-move-mmd_phy_read-and-mmd_phy_write-to-phyli.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/750-v7.0-net-phy-move-mmd_phy_read-and-mmd_phy_write-to-phyli.patch new file mode 100755 index 0000000..50c9155 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/750-v7.0-net-phy-move-mmd_phy_read-and-mmd_phy_write-to-phyli.patch @@ -0,0 +1,65 @@ +From 65de36f5eae1c540115bf8f705f853718e9b6451 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 5 Jan 2026 16:38:29 +0000 +Subject: [PATCH 3/5] net: phy: move mmd_phy_read and mmd_phy_write to phylib.h + +Helper functions mmd_phy_read and mmd_phy_write are useful for PHYs +which require custom MMD access functions for some but not all MMDs. +Move mmd_phy_read and mmd_phy_write function prototypes from +phylib-internal.h to phylib.h to make them available for PHY drivers. + +Signed-off-by: Daniel Golle +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/79169cd624a3572d426e42c7b13cd2654a35d0cb.1767630451.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni + +Note that this patch replaces the commit above as neither phylink.h nor +phylink-internal.h exist in Linux 6.12. +--- a/drivers/net/phy/phy-core.c ++++ b/drivers/net/phy/phy-core.c +@@ -542,8 +542,8 @@ static void mmd_phy_indirect(struct mii_ + devad | MII_MMD_CTRL_NOINCR); + } + +-static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45, +- int devad, u32 regnum) ++int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45, ++ int devad, u32 regnum) + { + if (is_c45) + return __mdiobus_c45_read(bus, phy_addr, devad, regnum); +@@ -552,9 +552,10 @@ static int mmd_phy_read(struct mii_bus * + /* Read the content of the MMD's selected register */ + return __mdiobus_read(bus, phy_addr, MII_MMD_DATA); + } ++EXPORT_SYMBOL_GPL(mmd_phy_read); + +-static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45, +- int devad, u32 regnum, u16 val) ++int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45, ++ int devad, u32 regnum, u16 val) + { + if (is_c45) + return __mdiobus_c45_write(bus, phy_addr, devad, regnum, val); +@@ -563,6 +564,7 @@ static int mmd_phy_write(struct mii_bus + /* Write the data into MMD's selected register */ + return __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val); + } ++EXPORT_SYMBOL_GPL(mmd_phy_write); + + /** + * __phy_read_mmd - Convenience function for reading a register +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -2032,6 +2032,11 @@ extern struct phy_driver genphy_c45_driv + /* The gen10g_* functions are the old Clause 45 stub */ + int gen10g_config_aneg(struct phy_device *phydev); + ++int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45, ++ int devad, u32 regnum); ++int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45, ++ int devad, u32 regnum, u16 val); ++ + static inline int phy_read_status(struct phy_device *phydev) + { + if (!phydev->drv) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-01-v6.13-r8169-remove-original-workaround-for-RTL8125-broken-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-01-v6.13-r8169-remove-original-workaround-for-RTL8125-broken-.patch new file mode 100755 index 0000000..bd10a96 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-01-v6.13-r8169-remove-original-workaround-for-RTL8125-broken-.patch @@ -0,0 +1,33 @@ +From 854d71c555dfc3383c1fde7d9989b6046e21093d Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 9 Oct 2024 07:48:05 +0200 +Subject: [PATCH] r8169: remove original workaround for RTL8125 broken rx issue + +Now that we have b9c7ac4fe22c ("r8169: disable ALDPS per default for +RTL8125"), the first attempt to fix the issue shouldn't be needed +any longer. So let's effectively revert 621735f59064 ("r8169: fix +rare issue with broken rx after link-down on RTL8125") and see +whether anybody complains. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/382d8c88-cbce-400f-ad62-fda0181c7e38@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 4 ---- + 1 file changed, 4 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -4810,11 +4810,7 @@ static void r8169_phylink_handler(struct + if (netif_carrier_ok(ndev)) { + rtl_link_chg_patch(tp); + pm_request_resume(d); +- netif_wake_queue(tp->dev); + } else { +- /* In few cases rx is broken after link-down otherwise */ +- if (rtl_is_8125(tp)) +- rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE); + pm_runtime_idle(d); + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-02-v6.13-r8169-enable-SG-TSO-on-selected-chip-versions-per-de.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-02-v6.13-r8169-enable-SG-TSO-on-selected-chip-versions-per-de.patch new file mode 100755 index 0000000..7ea1a11 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-02-v6.13-r8169-enable-SG-TSO-on-selected-chip-versions-per-de.patch @@ -0,0 +1,52 @@ +From b8bf38440ba94e8ed8e2ae55c5dfb0276d30e843 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 10 Oct 2024 12:58:02 +0200 +Subject: [PATCH] r8169: enable SG/TSO on selected chip versions per default + +Due to problem reports in the past SG and TSO/TSO6 are disabled per +default. It's not fully clear which chip versions are affected, so we +may impact also users of unaffected chip versions, unless they know +how to use ethtool for enabling SG/TSO/TSO6. +Vendor drivers r8168/r8125 enable SG/TSO/TSO6 for selected chip +versions per default, I'd interpret this as confirmation that these +chip versions are unaffected. So let's do the same here. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/realtek/r8169_main.c | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5524,11 +5524,6 @@ static int rtl_init_one(struct pci_dev * + + dev->features |= dev->hw_features; + +- /* There has been a number of reports that using SG/TSO results in +- * tx timeouts. However for a lot of people SG/TSO works fine. +- * Therefore disable both features by default, but allow users to +- * enable them. Use at own risk! +- */ + if (rtl_chip_supports_csum_v2(tp)) { + dev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6; + netif_set_tso_max_size(dev, RTL_GSO_MAX_SIZE_V2); +@@ -5539,6 +5534,17 @@ static int rtl_init_one(struct pci_dev * + netif_set_tso_max_segs(dev, RTL_GSO_MAX_SEGS_V1); + } + ++ /* There has been a number of reports that using SG/TSO results in ++ * tx timeouts. However for a lot of people SG/TSO works fine. ++ * It's not fully clear which chip versions are affected. Vendor ++ * drivers enable SG/TSO for certain chip versions per default, ++ * let's mimic this here. On other chip versions users can ++ * use ethtool to enable SG/TSO, use at own risk! ++ */ ++ if (tp->mac_version >= RTL_GIGA_MAC_VER_46 && ++ tp->mac_version != RTL_GIGA_MAC_VER_61) ++ dev->features |= dev->hw_features; ++ + dev->hw_features |= NETIF_F_RXALL; + dev->hw_features |= NETIF_F_RXFCS; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-03-v6.13-r8169-implement-additional-ethtool-stats-ops.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-03-v6.13-r8169-implement-additional-ethtool-stats-ops.patch new file mode 100755 index 0000000..594a8fa --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-03-v6.13-r8169-implement-additional-ethtool-stats-ops.patch @@ -0,0 +1,130 @@ +From e3fc5139bd8ffaa1498adc21be4e8ecbc6aed508 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sun, 13 Oct 2024 11:17:39 +0200 +Subject: [PATCH] r8169: implement additional ethtool stats ops + +This adds support for ethtool standard statistics, and makes use of the +extended hardware statistics being available from RTl8125. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/58e0da73-a7dd-4be3-82ae-d5b3f9069bde@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 82 +++++++++++++++++++++++ + 1 file changed, 82 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2160,6 +2160,19 @@ static void rtl8169_get_ringparam(struct + data->tx_pending = NUM_TX_DESC; + } + ++static void rtl8169_get_pause_stats(struct net_device *dev, ++ struct ethtool_pause_stats *pause_stats) ++{ ++ struct rtl8169_private *tp = netdev_priv(dev); ++ ++ if (!rtl_is_8125(tp)) ++ return; ++ ++ rtl8169_update_counters(tp); ++ pause_stats->tx_pause_frames = le32_to_cpu(tp->counters->tx_pause_on); ++ pause_stats->rx_pause_frames = le32_to_cpu(tp->counters->rx_pause_on); ++} ++ + static void rtl8169_get_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *data) + { +@@ -2186,6 +2199,69 @@ static int rtl8169_set_pauseparam(struct + return 0; + } + ++static void rtl8169_get_eth_mac_stats(struct net_device *dev, ++ struct ethtool_eth_mac_stats *mac_stats) ++{ ++ struct rtl8169_private *tp = netdev_priv(dev); ++ ++ rtl8169_update_counters(tp); ++ ++ mac_stats->FramesTransmittedOK = ++ le64_to_cpu(tp->counters->tx_packets); ++ mac_stats->SingleCollisionFrames = ++ le32_to_cpu(tp->counters->tx_one_collision); ++ mac_stats->MultipleCollisionFrames = ++ le32_to_cpu(tp->counters->tx_multi_collision); ++ mac_stats->FramesReceivedOK = ++ le64_to_cpu(tp->counters->rx_packets); ++ mac_stats->AlignmentErrors = ++ le16_to_cpu(tp->counters->align_errors); ++ mac_stats->FramesLostDueToIntMACXmitError = ++ le64_to_cpu(tp->counters->tx_errors); ++ mac_stats->BroadcastFramesReceivedOK = ++ le64_to_cpu(tp->counters->rx_broadcast); ++ mac_stats->MulticastFramesReceivedOK = ++ le32_to_cpu(tp->counters->rx_multicast); ++ ++ if (!rtl_is_8125(tp)) ++ return; ++ ++ mac_stats->AlignmentErrors = ++ le32_to_cpu(tp->counters->align_errors32); ++ mac_stats->OctetsTransmittedOK = ++ le64_to_cpu(tp->counters->tx_octets); ++ mac_stats->LateCollisions = ++ le32_to_cpu(tp->counters->tx_late_collision); ++ mac_stats->FramesAbortedDueToXSColls = ++ le32_to_cpu(tp->counters->tx_aborted32); ++ mac_stats->OctetsReceivedOK = ++ le64_to_cpu(tp->counters->rx_octets); ++ mac_stats->FramesLostDueToIntMACRcvError = ++ le32_to_cpu(tp->counters->rx_mac_error); ++ mac_stats->MulticastFramesXmittedOK = ++ le64_to_cpu(tp->counters->tx_multicast64); ++ mac_stats->BroadcastFramesXmittedOK = ++ le64_to_cpu(tp->counters->tx_broadcast64); ++ mac_stats->MulticastFramesReceivedOK = ++ le64_to_cpu(tp->counters->rx_multicast64); ++ mac_stats->FrameTooLongErrors = ++ le32_to_cpu(tp->counters->rx_frame_too_long); ++} ++ ++static void rtl8169_get_eth_ctrl_stats(struct net_device *dev, ++ struct ethtool_eth_ctrl_stats *ctrl_stats) ++{ ++ struct rtl8169_private *tp = netdev_priv(dev); ++ ++ if (!rtl_is_8125(tp)) ++ return; ++ ++ rtl8169_update_counters(tp); ++ ++ ctrl_stats->UnsupportedOpcodesReceived = ++ le32_to_cpu(tp->counters->rx_unknown_opcode); ++} ++ + static const struct ethtool_ops rtl8169_ethtool_ops = { + .supported_coalesce_params = ETHTOOL_COALESCE_USECS | + ETHTOOL_COALESCE_MAX_FRAMES, +@@ -2207,8 +2283,11 @@ static const struct ethtool_ops rtl8169_ + .get_link_ksettings = phy_ethtool_get_link_ksettings, + .set_link_ksettings = phy_ethtool_set_link_ksettings, + .get_ringparam = rtl8169_get_ringparam, ++ .get_pause_stats = rtl8169_get_pause_stats, + .get_pauseparam = rtl8169_get_pauseparam, + .set_pauseparam = rtl8169_set_pauseparam, ++ .get_eth_mac_stats = rtl8169_get_eth_mac_stats, ++ .get_eth_ctrl_stats = rtl8169_get_eth_ctrl_stats, + }; + + static enum mac_version rtl8169_get_mac_version(u16 xid, bool gmii) +@@ -3926,6 +4005,9 @@ static void rtl_hw_start_8125(struct rtl + break; + } + ++ /* enable extended tally counter */ ++ r8168_mac_ocp_modify(tp, 0xea84, 0, BIT(1) | BIT(0)); ++ + rtl_hw_config(tp); + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-04-v6.13-r8169-don-t-take-RTNL-lock-in-rtl_task.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-04-v6.13-r8169-don-t-take-RTNL-lock-in-rtl_task.patch new file mode 100755 index 0000000..a125ebb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-04-v6.13-r8169-don-t-take-RTNL-lock-in-rtl_task.patch @@ -0,0 +1,50 @@ +From ac48430368c1a4f4e6c2fa92243b4b93fd25bee4 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 16 Oct 2024 22:05:57 +0200 +Subject: [PATCH] r8169: don't take RTNL lock in rtl_task() + +There's not really a benefit here in taking the RTNL lock. The task +handler does exception handling only, so we're in trouble anyway when +we come here, and there's no need to protect against e.g. a parallel +ethtool call. +A benefit of removing the RTNL lock here is that we now can +synchronously cancel the workqueue from a context holding the RTNL mutex. + +Signed-off-by: Heiner Kallweit +Signed-off-by: Andrew Lunn +--- + drivers/net/ethernet/realtek/r8169_main.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -4833,10 +4833,8 @@ static void rtl_task(struct work_struct + container_of(work, struct rtl8169_private, wk.work); + int ret; + +- rtnl_lock(); +- + if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) +- goto out_unlock; ++ return; + + if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) { + /* if chip isn't accessible, reset bus to revive it */ +@@ -4845,7 +4843,7 @@ static void rtl_task(struct work_struct + if (ret < 0) { + netdev_err(tp->dev, "Can't reset secondary PCI bus, detach NIC\n"); + netif_device_detach(tp->dev); +- goto out_unlock; ++ return; + } + } + +@@ -4864,8 +4862,6 @@ reset: + } else if (test_and_clear_bit(RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, tp->wk.flags)) { + rtl_reset_work(tp); + } +-out_unlock: +- rtnl_unlock(); + } + + static int rtl8169_poll(struct napi_struct *napi, int budget) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-05-v6.13-replace-custom-flag-with-disable_work-et-al.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-05-v6.13-replace-custom-flag-with-disable_work-et-al.patch new file mode 100755 index 0000000..49e274a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-05-v6.13-replace-custom-flag-with-disable_work-et-al.patch @@ -0,0 +1,94 @@ +From e2015942e90a021151a5751776f35830ba063be7 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 16 Oct 2024 22:06:53 +0200 +Subject: [PATCH] r8169: replace custom flag with disable_work() et al + +So far we use a custom flag to define when a task can be scheduled and +when not. Let's use the standard mechanism with disable_work() et al +instead. +Note that in rtl8169_close() we can remove the call to cancel_work() +because we now call disable_work_sync() in rtl8169_down() already. + +Signed-off-by: Heiner Kallweit +Signed-off-by: Andrew Lunn +--- + drivers/net/ethernet/realtek/r8169_main.c | 18 ++++++------------ + 1 file changed, 6 insertions(+), 12 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -619,7 +619,6 @@ struct rtl8169_tc_offsets { + }; + + enum rtl_flag { +- RTL_FLAG_TASK_ENABLED = 0, + RTL_FLAG_TASK_RESET_PENDING, + RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, + RTL_FLAG_TASK_TX_TIMEOUT, +@@ -2505,11 +2504,9 @@ u16 rtl8168h_2_get_adc_bias_ioffset(stru + + static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag) + { +- if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) +- return; +- + set_bit(flag, tp->wk.flags); +- schedule_work(&tp->wk.work); ++ if (!schedule_work(&tp->wk.work)) ++ clear_bit(flag, tp->wk.flags); + } + + static void rtl8169_init_phy(struct rtl8169_private *tp) +@@ -4833,9 +4830,6 @@ static void rtl_task(struct work_struct + container_of(work, struct rtl8169_private, wk.work); + int ret; + +- if (!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags)) +- return; +- + if (test_and_clear_bit(RTL_FLAG_TASK_TX_TIMEOUT, tp->wk.flags)) { + /* if chip isn't accessible, reset bus to revive it */ + if (RTL_R32(tp, TxConfig) == ~0) { +@@ -4919,6 +4913,7 @@ static int r8169_phy_connect(struct rtl8 + + static void rtl8169_down(struct rtl8169_private *tp) + { ++ disable_work_sync(&tp->wk.work); + /* Clear all task flags */ + bitmap_zero(tp->wk.flags, RTL_FLAG_MAX); + +@@ -4947,7 +4942,7 @@ static void rtl8169_up(struct rtl8169_pr + phy_resume(tp->phydev); + rtl8169_init_phy(tp); + napi_enable(&tp->napi); +- set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags); ++ enable_work(&tp->wk.work); + rtl_reset_work(tp); + + phy_start(tp->phydev); +@@ -4964,8 +4959,6 @@ static int rtl8169_close(struct net_devi + rtl8169_down(tp); + rtl8169_rx_clear(tp); + +- cancel_work(&tp->wk.work); +- + free_irq(tp->irq, tp); + + phy_disconnect(tp->phydev); +@@ -5199,7 +5192,7 @@ static void rtl_remove_one(struct pci_de + if (pci_dev_run_wake(pdev)) + pm_runtime_get_noresume(&pdev->dev); + +- cancel_work_sync(&tp->wk.work); ++ disable_work_sync(&tp->wk.work); + + if (IS_ENABLED(CONFIG_R8169_LEDS)) + r8169_remove_leds(tp->leds); +@@ -5577,6 +5570,7 @@ static int rtl_init_one(struct pci_dev * + tp->irq = pci_irq_vector(pdev, 0); + + INIT_WORK(&tp->wk.work, rtl_task); ++ disable_work(&tp->wk.work); + + rtl_init_mac_address(tp); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-06-v6.13-r8169-avoid-duplicated-messages-if-loading-firmware-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-06-v6.13-r8169-avoid-duplicated-messages-if-loading-firmware-.patch new file mode 100755 index 0000000..6430d32 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-06-v6.13-r8169-avoid-duplicated-messages-if-loading-firmware-.patch @@ -0,0 +1,41 @@ +From 1c105bacb160b5918e917ab811552b7be69fc69c Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 16 Oct 2024 22:29:39 +0200 +Subject: [PATCH] r8169: avoid duplicated messages if loading firmware fails + and switch to warn level + +In case of a problem with firmware loading we inform at the driver level, +in addition the firmware load code itself issues warnings. Therefore +switch to firmware_request_nowarn() to avoid duplicated error messages. +In addition switch to warn level because the firmware is optional and +typically just fixes compatibility issues. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Message-ID: +Signed-off-by: Andrew Lunn +--- + drivers/net/ethernet/realtek/r8169_firmware.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_firmware.c ++++ b/drivers/net/ethernet/realtek/r8169_firmware.c +@@ -215,7 +215,7 @@ int rtl_fw_request_firmware(struct rtl_f + { + int rc; + +- rc = request_firmware(&rtl_fw->fw, rtl_fw->fw_name, rtl_fw->dev); ++ rc = firmware_request_nowarn(&rtl_fw->fw, rtl_fw->fw_name, rtl_fw->dev); + if (rc < 0) + goto out; + +@@ -227,7 +227,7 @@ int rtl_fw_request_firmware(struct rtl_f + + return 0; + out: +- dev_err(rtl_fw->dev, "Unable to load firmware %s (%d)\n", +- rtl_fw->fw_name, rc); ++ dev_warn(rtl_fw->dev, "Unable to load firmware %s (%d)\n", ++ rtl_fw->fw_name, rc); + return rc; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-07-v6.13-r8169-remove-rtl_dash_loop_wait_high-low.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-07-v6.13-r8169-remove-rtl_dash_loop_wait_high-low.patch new file mode 100755 index 0000000..bc8f979 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-07-v6.13-r8169-remove-rtl_dash_loop_wait_high-low.patch @@ -0,0 +1,82 @@ +From d64113c6bb5ea5a70b7c9c3a6bcadef307638187 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 16 Oct 2024 22:31:10 +0200 +Subject: [PATCH] r8169: remove rtl_dash_loop_wait_high/low + +Remove rtl_dash_loop_wait_high/low to simplify the code. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Message-ID: +Signed-off-by: Andrew Lunn +--- + drivers/net/ethernet/realtek/r8169_main.c | 35 ++++++----------------- + 1 file changed, 8 insertions(+), 27 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -1348,40 +1348,19 @@ static void rtl8168ep_stop_cmac(struct r + RTL_W8(tp, IBCR0, RTL_R8(tp, IBCR0) & ~0x01); + } + +-static void rtl_dash_loop_wait(struct rtl8169_private *tp, +- const struct rtl_cond *c, +- unsigned long usecs, int n, bool high) +-{ +- if (!tp->dash_enabled) +- return; +- rtl_loop_wait(tp, c, usecs, n, high); +-} +- +-static void rtl_dash_loop_wait_high(struct rtl8169_private *tp, +- const struct rtl_cond *c, +- unsigned long d, int n) +-{ +- rtl_dash_loop_wait(tp, c, d, n, true); +-} +- +-static void rtl_dash_loop_wait_low(struct rtl8169_private *tp, +- const struct rtl_cond *c, +- unsigned long d, int n) +-{ +- rtl_dash_loop_wait(tp, c, d, n, false); +-} +- + static void rtl8168dp_driver_start(struct rtl8169_private *tp) + { + r8168dp_oob_notify(tp, OOB_CMD_DRIVER_START); +- rtl_dash_loop_wait_high(tp, &rtl_dp_ocp_read_cond, 10000, 10); ++ if (tp->dash_enabled) ++ rtl_loop_wait_high(tp, &rtl_dp_ocp_read_cond, 10000, 10); + } + + static void rtl8168ep_driver_start(struct rtl8169_private *tp) + { + r8168ep_ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_START); + r8168ep_ocp_write(tp, 0x01, 0x30, r8168ep_ocp_read(tp, 0x30) | 0x01); +- rtl_dash_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10000, 30); ++ if (tp->dash_enabled) ++ rtl_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10000, 30); + } + + static void rtl8168_driver_start(struct rtl8169_private *tp) +@@ -1395,7 +1374,8 @@ static void rtl8168_driver_start(struct + static void rtl8168dp_driver_stop(struct rtl8169_private *tp) + { + r8168dp_oob_notify(tp, OOB_CMD_DRIVER_STOP); +- rtl_dash_loop_wait_low(tp, &rtl_dp_ocp_read_cond, 10000, 10); ++ if (tp->dash_enabled) ++ rtl_loop_wait_low(tp, &rtl_dp_ocp_read_cond, 10000, 10); + } + + static void rtl8168ep_driver_stop(struct rtl8169_private *tp) +@@ -1403,7 +1383,8 @@ static void rtl8168ep_driver_stop(struct + rtl8168ep_stop_cmac(tp); + r8168ep_ocp_write(tp, 0x01, 0x180, OOB_CMD_DRIVER_STOP); + r8168ep_ocp_write(tp, 0x01, 0x30, r8168ep_ocp_read(tp, 0x30) | 0x01); +- rtl_dash_loop_wait_low(tp, &rtl_ep_ocp_read_cond, 10000, 10); ++ if (tp->dash_enabled) ++ rtl_loop_wait_low(tp, &rtl_ep_ocp_read_cond, 10000, 10); + } + + static void rtl8168_driver_stop(struct rtl8169_private *tp) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-08-v6.13-r8169-enable-EEE-at-2.5G-per-default-on-RTL8125B.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-08-v6.13-r8169-enable-EEE-at-2.5G-per-default-on-RTL8125B.patch new file mode 100755 index 0000000..4ec06cc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-08-v6.13-r8169-enable-EEE-at-2.5G-per-default-on-RTL8125B.patch @@ -0,0 +1,28 @@ +From c4e64095c00cb2de413cd6b90be047c273bcd491 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 17 Oct 2024 22:27:44 +0200 +Subject: [PATCH] r8169: enable EEE at 2.5G per default on RTL8125B + +Register a6d/12 is shadowing register MDIO_AN_EEE_ADV2. So this line +disables advertisement of EEE at 2.5G. Latest vendor driver r8125 +doesn't do this (any longer?), so this mode seems to be safe. +EEE saves quite some energy, therefore enable this mode per default. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Message-ID: <95dd5a0c-09ea-4847-94d9-b7aa3063e8ff@gmail.com> +Signed-off-by: Andrew Lunn +--- + drivers/net/ethernet/realtek/r8169_phy_config.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -99,7 +99,6 @@ static void rtl8125a_config_eee_phy(stru + + static void rtl8125b_config_eee_phy(struct phy_device *phydev) + { +- phy_modify_paged(phydev, 0xa6d, 0x12, 0x0001, 0x0000); + phy_modify_paged(phydev, 0xa6d, 0x14, 0x0010, 0x0000); + phy_modify_paged(phydev, 0xa42, 0x14, 0x0080, 0x0000); + phy_modify_paged(phydev, 0xa4a, 0x11, 0x0200, 0x0000); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-10-v6.13-r8169-fix-inconsistent-indenting-in-rtl8169_get_eth_.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-10-v6.13-r8169-fix-inconsistent-indenting-in-rtl8169_get_eth_.patch new file mode 100755 index 0000000..41bab55 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-10-v6.13-r8169-fix-inconsistent-indenting-in-rtl8169_get_eth_.patch @@ -0,0 +1,30 @@ +From b8bd8c44a266c9a7dcb907eab10fbb119e3f6494 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 24 Oct 2024 22:48:59 +0200 +Subject: [PATCH] r8169: fix inconsistent indenting in + rtl8169_get_eth_mac_stats + +This fixes an inconsistent indenting introduced with e3fc5139bd8f +("r8169: implement additional ethtool stats ops"). + +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202410220413.1gAxIJ4t-lkp@intel.com/ +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/20fd6f39-3c1b-4af0-9adc-7d1f49728fad@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2224,7 +2224,7 @@ static void rtl8169_get_eth_mac_stats(st + le64_to_cpu(tp->counters->tx_broadcast64); + mac_stats->MulticastFramesReceivedOK = + le64_to_cpu(tp->counters->rx_multicast64); +- mac_stats->FrameTooLongErrors = ++ mac_stats->FrameTooLongErrors = + le32_to_cpu(tp->counters->rx_frame_too_long); + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-11-v6.13-r8169-align-RTL8125-EEE-config-with-vendor-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-11-v6.13-r8169-align-RTL8125-EEE-config-with-vendor-driver.patch new file mode 100755 index 0000000..de2be01 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-11-v6.13-r8169-align-RTL8125-EEE-config-with-vendor-driver.patch @@ -0,0 +1,49 @@ +From eb90f876b7961d702d7fc549e14614860f531e60 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 31 Oct 2024 22:42:52 +0100 +Subject: [PATCH] r8169: align RTL8125 EEE config with vendor driver + +Align the EEE config for RTL8125A/RTL8125B with vendor driver r8125. +This should help to avoid compatibility issues. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/044c925e-8669-4b98-87df-95b4056f4f5f@gmail.com +Signed-off-by: Jakub Kicinski +--- + .../net/ethernet/realtek/r8169_phy_config.c | 18 ++++++++++++------ + 1 file changed, 12 insertions(+), 6 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -89,19 +89,25 @@ static void rtl8168h_config_eee_phy(stru + phy_modify_paged(phydev, 0xa42, 0x14, 0x0000, 0x0080); + } + +-static void rtl8125a_config_eee_phy(struct phy_device *phydev) ++static void rtl8125_common_config_eee_phy(struct phy_device *phydev) + { +- rtl8168h_config_eee_phy(phydev); ++ phy_modify_paged(phydev, 0xa6d, 0x14, 0x0010, 0x0000); ++ phy_modify_paged(phydev, 0xa42, 0x14, 0x0080, 0x0000); ++ phy_modify_paged(phydev, 0xa4a, 0x11, 0x0200, 0x0000); ++} + ++static void rtl8125a_config_eee_phy(struct phy_device *phydev) ++{ ++ rtl8168g_config_eee_phy(phydev); ++ /* disable EEE at 2.5Gbps */ + phy_modify_paged(phydev, 0xa6d, 0x12, 0x0001, 0x0000); +- phy_modify_paged(phydev, 0xa6d, 0x14, 0x0010, 0x0000); ++ rtl8125_common_config_eee_phy(phydev); + } + + static void rtl8125b_config_eee_phy(struct phy_device *phydev) + { +- phy_modify_paged(phydev, 0xa6d, 0x14, 0x0010, 0x0000); +- phy_modify_paged(phydev, 0xa42, 0x14, 0x0080, 0x0000); +- phy_modify_paged(phydev, 0xa4a, 0x11, 0x0200, 0x0000); ++ rtl8168g_config_eee_phy(phydev); ++ rtl8125_common_config_eee_phy(phydev); + } + + static void rtl8169s_hw_phy_config(struct rtl8169_private *tp, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-12-v6.13-r8169-align-RTL8125-RTL8126-PHY-config-with-vendor-d.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-12-v6.13-r8169-align-RTL8125-RTL8126-PHY-config-with-vendor-d.patch new file mode 100755 index 0000000..a546c42 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-12-v6.13-r8169-align-RTL8125-RTL8126-PHY-config-with-vendor-d.patch @@ -0,0 +1,46 @@ +From 4af2f60bf7378bd5c92b15a528d8c6c7d02bed6c Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 31 Oct 2024 22:43:45 +0100 +Subject: [PATCH] r8169: align RTL8125/RTL8126 PHY config with vendor driver + +This aligns some parameters with vendor driver r8125/r8126 to avoid +compatibility issues. Note that for RTL8125B there's no functional +change, just the open-coded version of the function is replaced. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/a8a9d896-fbe6-41f2-bf87-666567d3cdb3@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_phy_config.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1073,8 +1073,8 @@ static void rtl8125b_hw_phy_config(struc + struct phy_device *phydev) + { + r8169_apply_firmware(tp); ++ rtl8168g_enable_gphy_10m(phydev); + +- phy_modify_paged(phydev, 0xa44, 0x11, 0x0000, 0x0800); + phy_modify_paged(phydev, 0xac4, 0x13, 0x00f0, 0x0090); + phy_modify_paged(phydev, 0xad3, 0x10, 0x0003, 0x0001); + +@@ -1113,6 +1113,7 @@ static void rtl8125d_hw_phy_config(struc + struct phy_device *phydev) + { + r8169_apply_firmware(tp); ++ rtl8168g_enable_gphy_10m(phydev); + rtl8125_legacy_force_mode(phydev); + rtl8168g_disable_aldps(phydev); + rtl8125b_config_eee_phy(phydev); +@@ -1122,6 +1123,9 @@ static void rtl8126a_hw_phy_config(struc + struct phy_device *phydev) + { + r8169_apply_firmware(tp); ++ rtl8168g_enable_gphy_10m(phydev); ++ rtl8125_legacy_force_mode(phydev); ++ rtl8168g_disable_aldps(phydev); + } + + void r8169_hw_phy_config(struct rtl8169_private *tp, struct phy_device *phydev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-13-v6.13-r8169-align-RTL8126-EEE-config-with-vendor-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-13-v6.13-r8169-align-RTL8126-EEE-config-with-vendor-driver.patch new file mode 100755 index 0000000..36c8041 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-13-v6.13-r8169-align-RTL8126-EEE-config-with-vendor-driver.patch @@ -0,0 +1,25 @@ +From a3d8520e6a19ab018da6c7fc22512c913697a829 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 31 Oct 2024 22:44:36 +0100 +Subject: [PATCH] r8169: align RTL8126 EEE config with vendor driver + +Align the EEE config for RTL8126A with vendor driver r8126 to avoid +compatibility issues. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/71e4859e-4cd0-4b6b-b7fa-621d7721992f@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_phy_config.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1126,6 +1126,7 @@ static void rtl8126a_hw_phy_config(struc + rtl8168g_enable_gphy_10m(phydev); + rtl8125_legacy_force_mode(phydev); + rtl8168g_disable_aldps(phydev); ++ rtl8125_common_config_eee_phy(phydev); + } + + void r8169_hw_phy_config(struct rtl8169_private *tp, struct phy_device *phydev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-14-v6.13-r8169-improve-initialization-of-RSS-registers-on-RTL.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-14-v6.13-r8169-improve-initialization-of-RSS-registers-on-RTL.patch new file mode 100755 index 0000000..d00b08e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-14-v6.13-r8169-improve-initialization-of-RSS-registers-on-RTL.patch @@ -0,0 +1,38 @@ +From 2cd02f2fdd8a92e5b6b85ff64eab0fc549b30c07 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 2 Nov 2024 14:49:01 +0100 +Subject: [PATCH] r8169: improve initialization of RSS registers on + RTL8125/RTL8126 + +Replace the register addresses with the names used in r8125/r8126 +vendor driver, and consider that RSS_CTRL_8125 is a 32 bit register. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/3bf2f340-b369-4174-97bf-fd38d4217492@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -346,6 +346,8 @@ enum rtl8125_registers { + TxPoll_8125 = 0x90, + LEDSEL3 = 0x96, + MAC0_BKP = 0x19e0, ++ RSS_CTRL_8125 = 0x4500, ++ Q_NUM_CTRL_8125 = 0x4800, + EEE_TXIDLE_TIMER_8125 = 0x6048, + }; + +@@ -3788,8 +3790,8 @@ static void rtl_hw_start_8125_common(str + rtl_pcie_state_l2l3_disable(tp); + + RTL_W16(tp, 0x382, 0x221b); +- RTL_W8(tp, 0x4500, 0); +- RTL_W16(tp, 0x4800, 0); ++ RTL_W32(tp, RSS_CTRL_8125, 0); ++ RTL_W16(tp, Q_NUM_CTRL_8125, 0); + + /* disable UPS */ + r8168_mac_ocp_modify(tp, 0xd40a, 0x0010, 0x0000); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-15-v6.13-r8169-remove-leftover-locks-after-reverted-change.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-15-v6.13-r8169-remove-leftover-locks-after-reverted-change.patch new file mode 100755 index 0000000..19bcf08 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-15-v6.13-r8169-remove-leftover-locks-after-reverted-change.patch @@ -0,0 +1,113 @@ +From 83cb4b470c66b37b19a347a35cea01e0cbdd258d Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 4 Nov 2024 23:16:20 +0100 +Subject: [PATCH] r8169: remove leftover locks after reverted change + +After e31a9fedc7d8 ("Revert "r8169: disable ASPM during NAPI poll"") +these locks aren't needed any longer. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/680f2606-ac7d-4ced-8694-e5033855da9b@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 29 ++--------------------- + 1 file changed, 2 insertions(+), 27 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -661,13 +661,9 @@ struct rtl8169_private { + struct work_struct work; + } wk; + +- raw_spinlock_t config25_lock; + raw_spinlock_t mac_ocp_lock; + struct mutex led_lock; /* serialize LED ctrl RMW access */ + +- raw_spinlock_t cfg9346_usage_lock; +- int cfg9346_usage_count; +- + unsigned supports_gmii:1; + unsigned aspm_manageable:1; + unsigned dash_enabled:1; +@@ -721,22 +717,12 @@ static inline struct device *tp_to_dev(s + + static void rtl_lock_config_regs(struct rtl8169_private *tp) + { +- unsigned long flags; +- +- raw_spin_lock_irqsave(&tp->cfg9346_usage_lock, flags); +- if (!--tp->cfg9346_usage_count) +- RTL_W8(tp, Cfg9346, Cfg9346_Lock); +- raw_spin_unlock_irqrestore(&tp->cfg9346_usage_lock, flags); ++ RTL_W8(tp, Cfg9346, Cfg9346_Lock); + } + + static void rtl_unlock_config_regs(struct rtl8169_private *tp) + { +- unsigned long flags; +- +- raw_spin_lock_irqsave(&tp->cfg9346_usage_lock, flags); +- if (!tp->cfg9346_usage_count++) +- RTL_W8(tp, Cfg9346, Cfg9346_Unlock); +- raw_spin_unlock_irqrestore(&tp->cfg9346_usage_lock, flags); ++ RTL_W8(tp, Cfg9346, Cfg9346_Unlock); + } + + static void rtl_pci_commit(struct rtl8169_private *tp) +@@ -747,24 +733,18 @@ static void rtl_pci_commit(struct rtl816 + + static void rtl_mod_config2(struct rtl8169_private *tp, u8 clear, u8 set) + { +- unsigned long flags; + u8 val; + +- raw_spin_lock_irqsave(&tp->config25_lock, flags); + val = RTL_R8(tp, Config2); + RTL_W8(tp, Config2, (val & ~clear) | set); +- raw_spin_unlock_irqrestore(&tp->config25_lock, flags); + } + + static void rtl_mod_config5(struct rtl8169_private *tp, u8 clear, u8 set) + { +- unsigned long flags; + u8 val; + +- raw_spin_lock_irqsave(&tp->config25_lock, flags); + val = RTL_R8(tp, Config5); + RTL_W8(tp, Config5, (val & ~clear) | set); +- raw_spin_unlock_irqrestore(&tp->config25_lock, flags); + } + + static bool rtl_is_8125(struct rtl8169_private *tp) +@@ -1570,7 +1550,6 @@ static void __rtl8169_set_wol(struct rtl + { WAKE_MAGIC, Config3, MagicPacket } + }; + unsigned int i, tmp = ARRAY_SIZE(cfg); +- unsigned long flags; + u8 options; + + rtl_unlock_config_regs(tp); +@@ -1589,14 +1568,12 @@ static void __rtl8169_set_wol(struct rtl + r8168_mac_ocp_modify(tp, 0xc0b6, BIT(0), 0); + } + +- raw_spin_lock_irqsave(&tp->config25_lock, flags); + for (i = 0; i < tmp; i++) { + options = RTL_R8(tp, cfg[i].reg) & ~cfg[i].mask; + if (wolopts & cfg[i].opt) + options |= cfg[i].mask; + RTL_W8(tp, cfg[i].reg, options); + } +- raw_spin_unlock_irqrestore(&tp->config25_lock, flags); + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: +@@ -5477,8 +5454,6 @@ static int rtl_init_one(struct pci_dev * + tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1; + tp->ocp_base = OCP_STD_PHY_BASE; + +- raw_spin_lock_init(&tp->cfg9346_usage_lock); +- raw_spin_lock_init(&tp->config25_lock); + raw_spin_lock_init(&tp->mac_ocp_lock); + mutex_init(&tp->led_lock); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-16-v6.13-r8169-improve-__rtl8169_set_wol.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-16-v6.13-r8169-improve-__rtl8169_set_wol.patch new file mode 100755 index 0000000..3158ac5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-16-v6.13-r8169-improve-__rtl8169_set_wol.patch @@ -0,0 +1,108 @@ +From c507e96b5763b36b63ad50ad804341f72ea000e4 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 6 Nov 2024 17:55:45 +0100 +Subject: [PATCH] r8169: improve __rtl8169_set_wol + +Add helper r8169_mod_reg8_cond() what allows to significantly simplify +__rtl8169_set_wol(). + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/697b197a-8eac-40c6-8847-27093cacec36@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 55 ++++++++++------------- + 1 file changed, 24 insertions(+), 31 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -747,6 +747,20 @@ static void rtl_mod_config5(struct rtl81 + RTL_W8(tp, Config5, (val & ~clear) | set); + } + ++static void r8169_mod_reg8_cond(struct rtl8169_private *tp, int reg, ++ u8 bits, bool cond) ++{ ++ u8 val, old_val; ++ ++ old_val = RTL_R8(tp, reg); ++ if (cond) ++ val = old_val | bits; ++ else ++ val = old_val & ~bits; ++ if (val != old_val) ++ RTL_W8(tp, reg, val); ++} ++ + static bool rtl_is_8125(struct rtl8169_private *tp) + { + return tp->mac_version >= RTL_GIGA_MAC_VER_61; +@@ -1537,58 +1551,37 @@ static void rtl8169_get_wol(struct net_d + + static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) + { +- static const struct { +- u32 opt; +- u16 reg; +- u8 mask; +- } cfg[] = { +- { WAKE_PHY, Config3, LinkUp }, +- { WAKE_UCAST, Config5, UWF }, +- { WAKE_BCAST, Config5, BWF }, +- { WAKE_MCAST, Config5, MWF }, +- { WAKE_ANY, Config5, LanWake }, +- { WAKE_MAGIC, Config3, MagicPacket } +- }; +- unsigned int i, tmp = ARRAY_SIZE(cfg); +- u8 options; +- + rtl_unlock_config_regs(tp); + + if (rtl_is_8168evl_up(tp)) { +- tmp--; + if (wolopts & WAKE_MAGIC) + rtl_eri_set_bits(tp, 0x0dc, MagicPacket_v2); + else + rtl_eri_clear_bits(tp, 0x0dc, MagicPacket_v2); + } else if (rtl_is_8125(tp)) { +- tmp--; + if (wolopts & WAKE_MAGIC) + r8168_mac_ocp_modify(tp, 0xc0b6, 0, BIT(0)); + else + r8168_mac_ocp_modify(tp, 0xc0b6, BIT(0), 0); ++ } else { ++ r8169_mod_reg8_cond(tp, Config3, MagicPacket, ++ wolopts & WAKE_MAGIC); + } + +- for (i = 0; i < tmp; i++) { +- options = RTL_R8(tp, cfg[i].reg) & ~cfg[i].mask; +- if (wolopts & cfg[i].opt) +- options |= cfg[i].mask; +- RTL_W8(tp, cfg[i].reg, options); +- } ++ r8169_mod_reg8_cond(tp, Config3, LinkUp, wolopts & WAKE_PHY); ++ r8169_mod_reg8_cond(tp, Config5, UWF, wolopts & WAKE_UCAST); ++ r8169_mod_reg8_cond(tp, Config5, BWF, wolopts & WAKE_BCAST); ++ r8169_mod_reg8_cond(tp, Config5, MWF, wolopts & WAKE_MCAST); ++ r8169_mod_reg8_cond(tp, Config5, LanWake, wolopts); + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: +- options = RTL_R8(tp, Config1) & ~PMEnable; +- if (wolopts) +- options |= PMEnable; +- RTL_W8(tp, Config1, options); ++ r8169_mod_reg8_cond(tp, Config1, PMEnable, wolopts); + break; + case RTL_GIGA_MAC_VER_34: + case RTL_GIGA_MAC_VER_37: + case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_66: +- if (wolopts) +- rtl_mod_config2(tp, 0, PME_SIGNAL); +- else +- rtl_mod_config2(tp, PME_SIGNAL, 0); ++ r8169_mod_reg8_cond(tp, Config2, PME_SIGNAL, wolopts); + break; + default: + break; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-17-v6.13-r8169-improve-rtl_set_d3_pll_down.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-17-v6.13-r8169-improve-rtl_set_d3_pll_down.patch new file mode 100755 index 0000000..ede589e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-17-v6.13-r8169-improve-rtl_set_d3_pll_down.patch @@ -0,0 +1,44 @@ +From 330dc2297c82953dff402e0b4176a5383a618538 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 6 Nov 2024 17:56:28 +0100 +Subject: [PATCH] r8169: improve rtl_set_d3_pll_down + +Make use of new helper r8169_mod_reg8_cond() and move from a switch() +to an if() clause. Benefit is that we don't have to touch this piece of +code each time support for a new chip version is added. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/e1ccdb85-a4ed-4800-89c2-89770ff06452@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 18 +++++------------- + 1 file changed, 5 insertions(+), 13 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -1430,19 +1430,11 @@ static enum rtl_dash_type rtl_get_dash_t + + static void rtl_set_d3_pll_down(struct rtl8169_private *tp, bool enable) + { +- switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26: +- case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30: +- case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_37: +- case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_66: +- if (enable) +- RTL_W8(tp, PMCH, RTL_R8(tp, PMCH) & ~D3_NO_PLL_DOWN); +- else +- RTL_W8(tp, PMCH, RTL_R8(tp, PMCH) | D3_NO_PLL_DOWN); +- break; +- default: +- break; +- } ++ if (tp->mac_version >= RTL_GIGA_MAC_VER_25 && ++ tp->mac_version != RTL_GIGA_MAC_VER_28 && ++ tp->mac_version != RTL_GIGA_MAC_VER_31 && ++ tp->mac_version != RTL_GIGA_MAC_VER_38) ++ r8169_mod_reg8_cond(tp, PMCH, D3_NO_PLL_DOWN, !enable); + } + + static void rtl_reset_packet_filter(struct rtl8169_private *tp) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-18-v6.13-r8169-align-WAKE_PHY-handling-with-r8125-r8126-vendo.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-18-v6.13-r8169-align-WAKE_PHY-handling-with-r8125-r8126-vendo.patch new file mode 100755 index 0000000..ceb8c12 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-18-v6.13-r8169-align-WAKE_PHY-handling-with-r8125-r8126-vendo.patch @@ -0,0 +1,29 @@ +From e3e9e9039fa6ae885c7d5c954d7b9f105fa23e8f Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 6 Nov 2024 17:57:08 +0100 +Subject: [PATCH] r8169: align WAKE_PHY handling with r8125/r8126 vendor + drivers + +Vendor drivers r8125/r8126 apply this additional magic setting when +enabling WAKE_PHY, so do the same here. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/51130715-45be-4db5-abb7-05d87e1f5df9@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -1561,6 +1561,9 @@ static void __rtl8169_set_wol(struct rtl + } + + r8169_mod_reg8_cond(tp, Config3, LinkUp, wolopts & WAKE_PHY); ++ if (rtl_is_8125(tp)) ++ r8168_mac_ocp_modify(tp, 0xe0c6, 0x3f, ++ wolopts & WAKE_PHY ? 0x13 : 0); + r8169_mod_reg8_cond(tp, Config5, UWF, wolopts & WAKE_UCAST); + r8169_mod_reg8_cond(tp, Config5, BWF, wolopts & WAKE_BCAST); + r8169_mod_reg8_cond(tp, Config5, MWF, wolopts & WAKE_MCAST); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-19-v6.13-r8169-use-helper-r8169_mod_reg8_cond-to-simplify-rtl.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-19-v6.13-r8169-use-helper-r8169_mod_reg8_cond-to-simplify-rtl.patch new file mode 100755 index 0000000..d6332df --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-19-v6.13-r8169-use-helper-r8169_mod_reg8_cond-to-simplify-rtl.patch @@ -0,0 +1,117 @@ +From 7a3bcd39ae1f0e3ab896d9df62339ab4297a0bfd Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 9 Nov 2024 23:12:12 +0100 +Subject: [PATCH] r8169: use helper r8169_mod_reg8_cond to simplify + rtl_jumbo_config + +Use recently added helper r8169_mod_reg8_cond() to simplify jumbo +mode configuration. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/3df1d484-a02e-46e7-8f75-db5b428e422e@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 77 ++++------------------- + 1 file changed, 11 insertions(+), 66 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2542,86 +2542,31 @@ static void rtl8169_init_ring_indexes(st + tp->dirty_tx = tp->cur_tx = tp->cur_rx = 0; + } + +-static void r8168c_hw_jumbo_enable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0); +- RTL_W8(tp, Config4, RTL_R8(tp, Config4) | Jumbo_En1); +-} +- +-static void r8168c_hw_jumbo_disable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0); +- RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~Jumbo_En1); +-} +- +-static void r8168dp_hw_jumbo_enable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0); +-} +- +-static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0); +-} +- +-static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, MaxTxPacketSize, 0x24); +- RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0); +- RTL_W8(tp, Config4, RTL_R8(tp, Config4) | 0x01); +-} +- +-static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, MaxTxPacketSize, 0x3f); +- RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0); +- RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~0x01); +-} +- +-static void r8168b_1_hw_jumbo_enable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, Config4, RTL_R8(tp, Config4) | (1 << 0)); +-} +- +-static void r8168b_1_hw_jumbo_disable(struct rtl8169_private *tp) +-{ +- RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~(1 << 0)); +-} +- + static void rtl_jumbo_config(struct rtl8169_private *tp) + { + bool jumbo = tp->dev->mtu > ETH_DATA_LEN; + int readrq = 4096; + ++ if (jumbo && tp->mac_version >= RTL_GIGA_MAC_VER_17 && ++ tp->mac_version <= RTL_GIGA_MAC_VER_26) ++ readrq = 512; ++ + rtl_unlock_config_regs(tp); + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_17: +- if (jumbo) { +- readrq = 512; +- r8168b_1_hw_jumbo_enable(tp); +- } else { +- r8168b_1_hw_jumbo_disable(tp); +- } ++ r8169_mod_reg8_cond(tp, Config4, BIT(0), jumbo); + break; + case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_26: +- if (jumbo) { +- readrq = 512; +- r8168c_hw_jumbo_enable(tp); +- } else { +- r8168c_hw_jumbo_disable(tp); +- } ++ r8169_mod_reg8_cond(tp, Config3, Jumbo_En0, jumbo); ++ r8169_mod_reg8_cond(tp, Config4, Jumbo_En1, jumbo); + break; + case RTL_GIGA_MAC_VER_28: +- if (jumbo) +- r8168dp_hw_jumbo_enable(tp); +- else +- r8168dp_hw_jumbo_disable(tp); ++ r8169_mod_reg8_cond(tp, Config3, Jumbo_En0, jumbo); + break; + case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33: +- if (jumbo) +- r8168e_hw_jumbo_enable(tp); +- else +- r8168e_hw_jumbo_disable(tp); ++ RTL_W8(tp, MaxTxPacketSize, jumbo ? 0x24 : 0x3f); ++ r8169_mod_reg8_cond(tp, Config3, Jumbo_En0, jumbo); ++ r8169_mod_reg8_cond(tp, Config4, BIT(0), jumbo); + break; + default: + break; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-20-v6.13-r8169-copy-vendor-driver-2.5G-5G-EEE-advertisement-c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-20-v6.13-r8169-copy-vendor-driver-2.5G-5G-EEE-advertisement-c.patch new file mode 100755 index 0000000..fee9d95 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-20-v6.13-r8169-copy-vendor-driver-2.5G-5G-EEE-advertisement-c.patch @@ -0,0 +1,82 @@ +From e340bff27e63ed61a1e9895bed546107859e48a7 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 8 Nov 2024 08:08:24 +0100 +Subject: [PATCH] r8169: copy vendor driver 2.5G/5G EEE advertisement + constraints + +Vendor driver r8125 doesn't advertise 2.5G EEE on RTL8125A, and r8126 +doesn't advertise 5G EEE. Likely there are compatibility issues, +therefore do the same in r8169. +With this change we don't have to disable 2.5G EEE advertisement in +rtl8125a_config_eee_phy() any longer. +We use new phylib accessor phy_set_eee_broken() to mark the respective +EEE modes as broken. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/ce185e10-8a2f-4cf8-a49b-fd8fb3c3c8a1@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++ + drivers/net/ethernet/realtek/r8169_phy_config.c | 16 ++++------------ + 2 files changed, 10 insertions(+), 12 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5253,6 +5253,11 @@ static int r8169_mdio_register(struct rt + phy_support_eee(tp->phydev); + phy_support_asym_pause(tp->phydev); + ++ /* mimic behavior of r8125/r8126 vendor drivers */ ++ if (tp->mac_version == RTL_GIGA_MAC_VER_61) ++ tp->phydev->eee_broken_modes |= MDIO_EEE_2_5GT; ++ tp->phydev->eee_broken_modes |= MDIO_EEE_5GT; ++ + /* PHY will be woken up in rtl_open() */ + phy_suspend(tp->phydev); + +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -96,15 +96,7 @@ static void rtl8125_common_config_eee_ph + phy_modify_paged(phydev, 0xa4a, 0x11, 0x0200, 0x0000); + } + +-static void rtl8125a_config_eee_phy(struct phy_device *phydev) +-{ +- rtl8168g_config_eee_phy(phydev); +- /* disable EEE at 2.5Gbps */ +- phy_modify_paged(phydev, 0xa6d, 0x12, 0x0001, 0x0000); +- rtl8125_common_config_eee_phy(phydev); +-} +- +-static void rtl8125b_config_eee_phy(struct phy_device *phydev) ++static void rtl8125_config_eee_phy(struct phy_device *phydev) + { + rtl8168g_config_eee_phy(phydev); + rtl8125_common_config_eee_phy(phydev); +@@ -1066,7 +1058,7 @@ static void rtl8125a_2_hw_phy_config(str + rtl8168g_enable_gphy_10m(phydev); + + rtl8168g_disable_aldps(phydev); +- rtl8125a_config_eee_phy(phydev); ++ rtl8125_config_eee_phy(phydev); + } + + static void rtl8125b_hw_phy_config(struct rtl8169_private *tp, +@@ -1106,7 +1098,7 @@ static void rtl8125b_hw_phy_config(struc + + rtl8125_legacy_force_mode(phydev); + rtl8168g_disable_aldps(phydev); +- rtl8125b_config_eee_phy(phydev); ++ rtl8125_config_eee_phy(phydev); + } + + static void rtl8125d_hw_phy_config(struct rtl8169_private *tp, +@@ -1116,7 +1108,7 @@ static void rtl8125d_hw_phy_config(struc + rtl8168g_enable_gphy_10m(phydev); + rtl8125_legacy_force_mode(phydev); + rtl8168g_disable_aldps(phydev); +- rtl8125b_config_eee_phy(phydev); ++ rtl8125_config_eee_phy(phydev); + } + + static void rtl8126a_hw_phy_config(struct rtl8169_private *tp, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-21-v6.14-r8169-remove-unused-flag-RTL_FLAG_TASK_RESET_NO_QUEU.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-21-v6.14-r8169-remove-unused-flag-RTL_FLAG_TASK_RESET_NO_QUEU.patch new file mode 100755 index 0000000..182858a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-21-v6.14-r8169-remove-unused-flag-RTL_FLAG_TASK_RESET_NO_QUEU.patch @@ -0,0 +1,35 @@ +From 2e20bf8cc05766dcd0357cdfcada49e1bc45512b Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 2 Dec 2024 21:14:35 +0100 +Subject: [PATCH] r8169: remove unused flag RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE + +After 854d71c555dfc3 ("r8169: remove original workaround for RTL8125 +broken rx issue") this flag isn't used any longer. So remove it. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Michal Swiatkowski +Link: https://patch.msgid.link/d9dd214b-3027-4f60-b0e8-6f34a0c76582@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 3 --- + 1 file changed, 3 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -622,7 +622,6 @@ struct rtl8169_tc_offsets { + + enum rtl_flag { + RTL_FLAG_TASK_RESET_PENDING, +- RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, + RTL_FLAG_TASK_TX_TIMEOUT, + RTL_FLAG_MAX + }; +@@ -4746,8 +4745,6 @@ static void rtl_task(struct work_struct + reset: + rtl_reset_work(tp); + netif_wake_queue(tp->dev); +- } else if (test_and_clear_bit(RTL_FLAG_TASK_RESET_NO_QUEUE_WAKE, tp->wk.flags)) { +- rtl_reset_work(tp); + } + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-22-v6.14-r8169-remove-support-for-chip-version-11.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-22-v6.14-r8169-remove-support-for-chip-version-11.patch new file mode 100755 index 0000000..055e0f0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-22-v6.14-r8169-remove-support-for-chip-version-11.patch @@ -0,0 +1,114 @@ +From bb18265c3aba92b91a1355609769f3e967b65dee Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 2 Dec 2024 21:20:02 +0100 +Subject: [PATCH] r8169: remove support for chip version 11 + +This is a follow-up to 982300c115d2 ("r8169: remove detection of chip +version 11 (early RTL8168b)"). Nobody complained yet, so remove +support for this chip version. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/b689ab6d-20b5-4b64-bd7e-531a0a972ba3@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 2 +- + drivers/net/ethernet/realtek/r8169_main.c | 14 +------------- + drivers/net/ethernet/realtek/r8169_phy_config.c | 10 ---------- + 3 files changed, 2 insertions(+), 24 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -23,7 +23,7 @@ enum mac_version { + RTL_GIGA_MAC_VER_08, + RTL_GIGA_MAC_VER_09, + RTL_GIGA_MAC_VER_10, +- RTL_GIGA_MAC_VER_11, ++ /* support for RTL_GIGA_MAC_VER_11 has been removed */ + /* RTL_GIGA_MAC_VER_12 was handled the same as VER_17 */ + /* RTL_GIGA_MAC_VER_13 was merged with VER_10 */ + RTL_GIGA_MAC_VER_14, +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -103,7 +103,6 @@ static const struct { + [RTL_GIGA_MAC_VER_08] = {"RTL8102e" }, + [RTL_GIGA_MAC_VER_09] = {"RTL8102e/RTL8103e" }, + [RTL_GIGA_MAC_VER_10] = {"RTL8101e/RTL8100e" }, +- [RTL_GIGA_MAC_VER_11] = {"RTL8168b/8111b" }, + [RTL_GIGA_MAC_VER_14] = {"RTL8401" }, + [RTL_GIGA_MAC_VER_17] = {"RTL8168b/8111b" }, + [RTL_GIGA_MAC_VER_18] = {"RTL8168cp/8111cp" }, +@@ -2334,7 +2333,7 @@ static enum mac_version rtl8169_get_mac_ + + /* 8168B family. */ + { 0x7c8, 0x380, RTL_GIGA_MAC_VER_17 }, +- /* This one is very old and rare, let's see if anybody complains. ++ /* This one is very old and rare, support has been removed. + * { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11 }, + */ + +@@ -3826,7 +3825,6 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_08] = rtl_hw_start_8102e_3, + [RTL_GIGA_MAC_VER_09] = rtl_hw_start_8102e_2, + [RTL_GIGA_MAC_VER_10] = NULL, +- [RTL_GIGA_MAC_VER_11] = rtl_hw_start_8168b, + [RTL_GIGA_MAC_VER_14] = rtl_hw_start_8401, + [RTL_GIGA_MAC_VER_17] = rtl_hw_start_8168b, + [RTL_GIGA_MAC_VER_18] = rtl_hw_start_8168cp_1, +@@ -4702,12 +4700,6 @@ static irqreturn_t rtl8169_interrupt(int + if (status & LinkChg) + phy_mac_interrupt(tp->phydev); + +- if (unlikely(status & RxFIFOOver && +- tp->mac_version == RTL_GIGA_MAC_VER_11)) { +- netif_stop_queue(tp->dev); +- rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); +- } +- + rtl_irq_disable(tp); + napi_schedule(&tp->napi); + out: +@@ -5124,9 +5116,6 @@ static void rtl_set_irq_mask(struct rtl8 + + if (tp->mac_version <= RTL_GIGA_MAC_VER_06) + tp->irq_mask |= SYSErr | RxFIFOOver; +- else if (tp->mac_version == RTL_GIGA_MAC_VER_11) +- /* special workaround needed */ +- tp->irq_mask |= RxFIFOOver; + } + + static int rtl_alloc_irq(struct rtl8169_private *tp) +@@ -5321,7 +5310,6 @@ static int rtl_jumbo_max(struct rtl8169_ + case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06: + return JUMBO_7K; + /* RTL8168b */ +- case RTL_GIGA_MAC_VER_11: + case RTL_GIGA_MAC_VER_17: + return JUMBO_4K; + /* RTL8168c */ +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -276,15 +276,6 @@ static void rtl8169sce_hw_phy_config(str + rtl_writephy_batch(phydev, phy_reg_init); + } + +-static void rtl8168bb_hw_phy_config(struct rtl8169_private *tp, +- struct phy_device *phydev) +-{ +- phy_write(phydev, 0x1f, 0x0001); +- phy_set_bits(phydev, 0x16, BIT(0)); +- phy_write(phydev, 0x10, 0xf41b); +- phy_write(phydev, 0x1f, 0x0000); +-} +- + static void rtl8168bef_hw_phy_config(struct rtl8169_private *tp, + struct phy_device *phydev) + { +@@ -1136,7 +1127,6 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_08] = rtl8102e_hw_phy_config, + [RTL_GIGA_MAC_VER_09] = rtl8102e_hw_phy_config, + [RTL_GIGA_MAC_VER_10] = NULL, +- [RTL_GIGA_MAC_VER_11] = rtl8168bb_hw_phy_config, + [RTL_GIGA_MAC_VER_14] = rtl8401_hw_phy_config, + [RTL_GIGA_MAC_VER_17] = rtl8168bef_hw_phy_config, + [RTL_GIGA_MAC_VER_18] = rtl8168cp_1_hw_phy_config, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-23-v6.14-r8169-adjust-version-numbering-for-RTL8126.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-23-v6.14-r8169-adjust-version-numbering-for-RTL8126.patch new file mode 100755 index 0000000..7ea47bd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-23-v6.14-r8169-adjust-version-numbering-for-RTL8126.patch @@ -0,0 +1,257 @@ +From b299ea0069284186b0d3d54aebe87f0d195d457a Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 13 Dec 2024 20:01:41 +0100 +Subject: [PATCH] r8169: adjust version numbering for RTL8126 + +Adjust version numbering for RTL8126, so that it doesn't overlap with +new RTL8125 versions. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/6a354364-20e9-48ad-a198-468264288757@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 4 +- + drivers/net/ethernet/realtek/r8169_main.c | 62 +++++++++---------- + .../net/ethernet/realtek/r8169_phy_config.c | 4 +- + 3 files changed, 35 insertions(+), 35 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -69,8 +69,8 @@ enum mac_version { + RTL_GIGA_MAC_VER_61, + RTL_GIGA_MAC_VER_63, + RTL_GIGA_MAC_VER_64, +- RTL_GIGA_MAC_VER_65, +- RTL_GIGA_MAC_VER_66, ++ RTL_GIGA_MAC_VER_70, ++ RTL_GIGA_MAC_VER_71, + RTL_GIGA_MAC_NONE + }; + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -139,8 +139,8 @@ static const struct { + /* reserve 62 for CFG_METHOD_4 in the vendor driver */ + [RTL_GIGA_MAC_VER_63] = {"RTL8125B", FIRMWARE_8125B_2}, + [RTL_GIGA_MAC_VER_64] = {"RTL8125D", FIRMWARE_8125D_1}, +- [RTL_GIGA_MAC_VER_65] = {"RTL8126A", FIRMWARE_8126A_2}, +- [RTL_GIGA_MAC_VER_66] = {"RTL8126A", FIRMWARE_8126A_3}, ++ [RTL_GIGA_MAC_VER_70] = {"RTL8126A", FIRMWARE_8126A_2}, ++ [RTL_GIGA_MAC_VER_71] = {"RTL8126A", FIRMWARE_8126A_3}, + }; + + static const struct pci_device_id rtl8169_pci_tbl[] = { +@@ -1227,7 +1227,7 @@ static void rtl_writephy(struct rtl8169_ + case RTL_GIGA_MAC_VER_31: + r8168dp_2_mdio_write(tp, location, val); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: + r8168g_mdio_write(tp, location, val); + break; + default: +@@ -1242,7 +1242,7 @@ static int rtl_readphy(struct rtl8169_pr + case RTL_GIGA_MAC_VER_28: + case RTL_GIGA_MAC_VER_31: + return r8168dp_2_mdio_read(tp, location); +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: + return r8168g_mdio_read(tp, location); + default: + return r8169_mdio_read(tp, location); +@@ -1573,7 +1573,7 @@ static void __rtl8169_set_wol(struct rtl + break; + case RTL_GIGA_MAC_VER_34: + case RTL_GIGA_MAC_VER_37: +- case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_71: + r8169_mod_reg8_cond(tp, Config2, PME_SIGNAL, wolopts); + break; + default: +@@ -2046,7 +2046,7 @@ static void rtl_set_eee_txidle_timer(str + tp->tx_lpi_timer = timer_val; + r8168_mac_ocp_write(tp, 0xe048, timer_val); + break; +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: + tp->tx_lpi_timer = timer_val; + RTL_W16(tp, EEE_TXIDLE_TIMER_8125, timer_val); + break; +@@ -2254,8 +2254,8 @@ static enum mac_version rtl8169_get_mac_ + enum mac_version ver; + } mac_info[] = { + /* 8126A family. */ +- { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_66 }, +- { 0x7cf, 0x649, RTL_GIGA_MAC_VER_65 }, ++ { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_71 }, ++ { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70 }, + + /* 8125D family. */ + { 0x7cf, 0x688, RTL_GIGA_MAC_VER_64 }, +@@ -2525,7 +2525,7 @@ static void rtl_init_rxcfg(struct rtl816 + case RTL_GIGA_MAC_VER_61: + RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST); + break; +- case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_71: + RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST | + RX_PAUSE_SLOT_ON); + break; +@@ -2657,7 +2657,7 @@ static void rtl_wait_txrx_fifo_empty(str + case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_61: + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); + break; +- case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_71: + RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond_2, 100, 42); +@@ -2923,7 +2923,7 @@ static void rtl_enable_exit_l1(struct rt + case RTL_GIGA_MAC_VER_37 ... RTL_GIGA_MAC_VER_38: + rtl_eri_set_bits(tp, 0xd4, 0x0c00); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: + r8168_mac_ocp_modify(tp, 0xc0ac, 0, 0x1f80); + break; + default: +@@ -2937,7 +2937,7 @@ static void rtl_disable_exit_l1(struct r + case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: + rtl_eri_clear_bits(tp, 0xd4, 0x1f00); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: + r8168_mac_ocp_modify(tp, 0xc0ac, 0x1f80, 0); + break; + default: +@@ -2963,8 +2963,8 @@ static void rtl_hw_aspm_clkreq_enable(st + + rtl_mod_config5(tp, 0, ASPM_en); + switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_65: +- case RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_70: ++ case RTL_GIGA_MAC_VER_71: + val8 = RTL_R8(tp, INT_CFG0_8125) | INT_CFG0_CLKREQEN; + RTL_W8(tp, INT_CFG0_8125, val8); + break; +@@ -2975,7 +2975,7 @@ static void rtl_hw_aspm_clkreq_enable(st + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48: +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: + /* reset ephy tx/rx disable timer */ + r8168_mac_ocp_modify(tp, 0xe094, 0xff00, 0); + /* chip can trigger L1.2 */ +@@ -2987,7 +2987,7 @@ static void rtl_hw_aspm_clkreq_enable(st + } else { + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48: +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: + r8168_mac_ocp_modify(tp, 0xe092, 0x00ff, 0); + break; + default: +@@ -2995,8 +2995,8 @@ static void rtl_hw_aspm_clkreq_enable(st + } + + switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_65: +- case RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_70: ++ case RTL_GIGA_MAC_VER_71: + val8 = RTL_R8(tp, INT_CFG0_8125) & ~INT_CFG0_CLKREQEN; + RTL_W8(tp, INT_CFG0_8125, val8); + break; +@@ -3716,12 +3716,12 @@ static void rtl_hw_start_8125_common(str + /* disable new tx descriptor format */ + r8168_mac_ocp_modify(tp, 0xeb58, 0x0001, 0x0000); + +- if (tp->mac_version == RTL_GIGA_MAC_VER_65 || +- tp->mac_version == RTL_GIGA_MAC_VER_66) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70 || ++ tp->mac_version == RTL_GIGA_MAC_VER_71) + RTL_W8(tp, 0xD8, RTL_R8(tp, 0xD8) & ~0x02); + +- if (tp->mac_version == RTL_GIGA_MAC_VER_65 || +- tp->mac_version == RTL_GIGA_MAC_VER_66) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70 || ++ tp->mac_version == RTL_GIGA_MAC_VER_71) + r8168_mac_ocp_modify(tp, 0xe614, 0x0700, 0x0400); + else if (tp->mac_version == RTL_GIGA_MAC_VER_63) + r8168_mac_ocp_modify(tp, 0xe614, 0x0700, 0x0200); +@@ -3739,8 +3739,8 @@ static void rtl_hw_start_8125_common(str + r8168_mac_ocp_modify(tp, 0xe056, 0x00f0, 0x0000); + r8168_mac_ocp_modify(tp, 0xe040, 0x1000, 0x0000); + r8168_mac_ocp_modify(tp, 0xea1c, 0x0003, 0x0001); +- if (tp->mac_version == RTL_GIGA_MAC_VER_65 || +- tp->mac_version == RTL_GIGA_MAC_VER_66) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70 || ++ tp->mac_version == RTL_GIGA_MAC_VER_71) + r8168_mac_ocp_modify(tp, 0xea1c, 0x0300, 0x0000); + else + r8168_mac_ocp_modify(tp, 0xea1c, 0x0004, 0x0000); +@@ -3860,8 +3860,8 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_61] = rtl_hw_start_8125a_2, + [RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b, + [RTL_GIGA_MAC_VER_64] = rtl_hw_start_8125d, +- [RTL_GIGA_MAC_VER_65] = rtl_hw_start_8126a, +- [RTL_GIGA_MAC_VER_66] = rtl_hw_start_8126a, ++ [RTL_GIGA_MAC_VER_70] = rtl_hw_start_8126a, ++ [RTL_GIGA_MAC_VER_71] = rtl_hw_start_8126a, + }; + + if (hw_configs[tp->mac_version]) +@@ -3882,8 +3882,8 @@ static void rtl_hw_start_8125(struct rtl + RTL_W32(tp, i, 0); + break; + case RTL_GIGA_MAC_VER_63: +- case RTL_GIGA_MAC_VER_65: +- case RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_70: ++ case RTL_GIGA_MAC_VER_71: + for (i = 0xa00; i < 0xa80; i += 4) + RTL_W32(tp, i, 0); + RTL_W16(tp, INT_CFG1_8125, 0x0000); +@@ -4115,7 +4115,7 @@ static void rtl8169_cleanup(struct rtl81 + RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); + rtl_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: + rtl_enable_rxdvgate(tp); + fsleep(2000); + break; +@@ -4272,7 +4272,7 @@ static unsigned int rtl_quirk_packet_pad + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_34: +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: + padto = max_t(unsigned int, padto, ETH_ZLEN); + break; + default: +@@ -5291,7 +5291,7 @@ static void rtl_hw_initialize(struct rtl + case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_48: + rtl_hw_init_8168g(tp); + break; +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: + rtl_hw_init_8125(tp); + break; + default: +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1162,8 +1162,8 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_61] = rtl8125a_2_hw_phy_config, + [RTL_GIGA_MAC_VER_63] = rtl8125b_hw_phy_config, + [RTL_GIGA_MAC_VER_64] = rtl8125d_hw_phy_config, +- [RTL_GIGA_MAC_VER_65] = rtl8126a_hw_phy_config, +- [RTL_GIGA_MAC_VER_66] = rtl8126a_hw_phy_config, ++ [RTL_GIGA_MAC_VER_70] = rtl8126a_hw_phy_config, ++ [RTL_GIGA_MAC_VER_71] = rtl8126a_hw_phy_config, + }; + + if (phy_configs[ver]) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-24-v6.14-r8169-add-support-for-RTL8125D-rev.b.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-24-v6.14-r8169-add-support-for-RTL8125D-rev.b.patch new file mode 100755 index 0000000..bbc447f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-24-v6.14-r8169-add-support-for-RTL8125D-rev.b.patch @@ -0,0 +1,90 @@ +From b3593df26ab19f114d613693fa8a92ab202803d0 Mon Sep 17 00:00:00 2001 +From: ChunHao Lin +Date: Fri, 13 Dec 2024 20:02:58 +0100 +Subject: [PATCH] r8169: add support for RTL8125D rev.b + +Add support for RTL8125D rev.b. Its XID is 0x689. It is basically +based on the one with XID 0x688, but with different firmware file. + +Signed-off-by: ChunHao Lin +[hkallweit1@gmail.com: rebased after adjusted version numbering] +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/75e5e9ec-d01f-43ac-b0f4-e7456baf18d1@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 1 + + drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++ + drivers/net/ethernet/realtek/r8169_phy_config.c | 1 + + 3 files changed, 8 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -69,6 +69,7 @@ enum mac_version { + RTL_GIGA_MAC_VER_61, + RTL_GIGA_MAC_VER_63, + RTL_GIGA_MAC_VER_64, ++ RTL_GIGA_MAC_VER_65, + RTL_GIGA_MAC_VER_70, + RTL_GIGA_MAC_VER_71, + RTL_GIGA_MAC_NONE +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -56,6 +56,7 @@ + #define FIRMWARE_8125A_3 "rtl_nic/rtl8125a-3.fw" + #define FIRMWARE_8125B_2 "rtl_nic/rtl8125b-2.fw" + #define FIRMWARE_8125D_1 "rtl_nic/rtl8125d-1.fw" ++#define FIRMWARE_8125D_2 "rtl_nic/rtl8125d-2.fw" + #define FIRMWARE_8126A_2 "rtl_nic/rtl8126a-2.fw" + #define FIRMWARE_8126A_3 "rtl_nic/rtl8126a-3.fw" + +@@ -139,6 +140,7 @@ static const struct { + /* reserve 62 for CFG_METHOD_4 in the vendor driver */ + [RTL_GIGA_MAC_VER_63] = {"RTL8125B", FIRMWARE_8125B_2}, + [RTL_GIGA_MAC_VER_64] = {"RTL8125D", FIRMWARE_8125D_1}, ++ [RTL_GIGA_MAC_VER_65] = {"RTL8125D", FIRMWARE_8125D_2}, + [RTL_GIGA_MAC_VER_70] = {"RTL8126A", FIRMWARE_8126A_2}, + [RTL_GIGA_MAC_VER_71] = {"RTL8126A", FIRMWARE_8126A_3}, + }; +@@ -705,6 +707,7 @@ MODULE_FIRMWARE(FIRMWARE_8107E_2); + MODULE_FIRMWARE(FIRMWARE_8125A_3); + MODULE_FIRMWARE(FIRMWARE_8125B_2); + MODULE_FIRMWARE(FIRMWARE_8125D_1); ++MODULE_FIRMWARE(FIRMWARE_8125D_2); + MODULE_FIRMWARE(FIRMWARE_8126A_2); + MODULE_FIRMWARE(FIRMWARE_8126A_3); + +@@ -2258,6 +2261,7 @@ static enum mac_version rtl8169_get_mac_ + { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70 }, + + /* 8125D family. */ ++ { 0x7cf, 0x689, RTL_GIGA_MAC_VER_65 }, + { 0x7cf, 0x688, RTL_GIGA_MAC_VER_64 }, + + /* 8125B family. */ +@@ -3860,6 +3864,7 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_61] = rtl_hw_start_8125a_2, + [RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b, + [RTL_GIGA_MAC_VER_64] = rtl_hw_start_8125d, ++ [RTL_GIGA_MAC_VER_65] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_70] = rtl_hw_start_8126a, + [RTL_GIGA_MAC_VER_71] = rtl_hw_start_8126a, + }; +@@ -3878,6 +3883,7 @@ static void rtl_hw_start_8125(struct rtl + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_61: + case RTL_GIGA_MAC_VER_64: ++ case RTL_GIGA_MAC_VER_65: + for (i = 0xa00; i < 0xb00; i += 4) + RTL_W32(tp, i, 0); + break; +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1162,6 +1162,7 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_61] = rtl8125a_2_hw_phy_config, + [RTL_GIGA_MAC_VER_63] = rtl8125b_hw_phy_config, + [RTL_GIGA_MAC_VER_64] = rtl8125d_hw_phy_config, ++ [RTL_GIGA_MAC_VER_65] = rtl8125d_hw_phy_config, + [RTL_GIGA_MAC_VER_70] = rtl8126a_hw_phy_config, + [RTL_GIGA_MAC_VER_71] = rtl8126a_hw_phy_config, + }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-25-v6.14-r8169-add-support-for-RTL8125BP-rev.b.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-25-v6.14-r8169-add-support-for-RTL8125BP-rev.b.patch new file mode 100755 index 0000000..7b4f474 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-25-v6.14-r8169-add-support-for-RTL8125BP-rev.b.patch @@ -0,0 +1,184 @@ +From b11bff90f2ad52c5c55c822ecd20326619a73898 Mon Sep 17 00:00:00 2001 +From: ChunHao Lin +Date: Tue, 7 Jan 2025 14:43:55 +0800 +Subject: [PATCH] r8169: add support for RTL8125BP rev.b + +Add support for RTL8125BP rev.b. Its XID is 0x689. This chip supports +DASH and its dash type is "RTL_DASH_25_BP". + +Signed-off-by: ChunHao Lin +Reviewed-by: Heiner Kallweit +Link: https://patch.msgid.link/20250107064355.104711-1-hau@realtek.com +Signed-off-by: Paolo Abeni +--- + drivers/net/ethernet/realtek/r8169.h | 1 + + drivers/net/ethernet/realtek/r8169_main.c | 30 +++++++++++++++++++ + .../net/ethernet/realtek/r8169_phy_config.c | 23 ++++++++++++++ + 3 files changed, 54 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -70,6 +70,7 @@ enum mac_version { + RTL_GIGA_MAC_VER_63, + RTL_GIGA_MAC_VER_64, + RTL_GIGA_MAC_VER_65, ++ RTL_GIGA_MAC_VER_66, + RTL_GIGA_MAC_VER_70, + RTL_GIGA_MAC_VER_71, + RTL_GIGA_MAC_NONE +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -57,6 +57,7 @@ + #define FIRMWARE_8125B_2 "rtl_nic/rtl8125b-2.fw" + #define FIRMWARE_8125D_1 "rtl_nic/rtl8125d-1.fw" + #define FIRMWARE_8125D_2 "rtl_nic/rtl8125d-2.fw" ++#define FIRMWARE_8125BP_2 "rtl_nic/rtl8125bp-2.fw" + #define FIRMWARE_8126A_2 "rtl_nic/rtl8126a-2.fw" + #define FIRMWARE_8126A_3 "rtl_nic/rtl8126a-3.fw" + +@@ -141,6 +142,7 @@ static const struct { + [RTL_GIGA_MAC_VER_63] = {"RTL8125B", FIRMWARE_8125B_2}, + [RTL_GIGA_MAC_VER_64] = {"RTL8125D", FIRMWARE_8125D_1}, + [RTL_GIGA_MAC_VER_65] = {"RTL8125D", FIRMWARE_8125D_2}, ++ [RTL_GIGA_MAC_VER_66] = {"RTL8125BP", FIRMWARE_8125BP_2}, + [RTL_GIGA_MAC_VER_70] = {"RTL8126A", FIRMWARE_8126A_2}, + [RTL_GIGA_MAC_VER_71] = {"RTL8126A", FIRMWARE_8126A_3}, + }; +@@ -631,6 +633,7 @@ enum rtl_dash_type { + RTL_DASH_NONE, + RTL_DASH_DP, + RTL_DASH_EP, ++ RTL_DASH_25_BP, + }; + + struct rtl8169_private { +@@ -708,6 +711,7 @@ MODULE_FIRMWARE(FIRMWARE_8125A_3); + MODULE_FIRMWARE(FIRMWARE_8125B_2); + MODULE_FIRMWARE(FIRMWARE_8125D_1); + MODULE_FIRMWARE(FIRMWARE_8125D_2); ++MODULE_FIRMWARE(FIRMWARE_8125BP_2); + MODULE_FIRMWARE(FIRMWARE_8126A_2); + MODULE_FIRMWARE(FIRMWARE_8126A_3); + +@@ -1360,10 +1364,19 @@ static void rtl8168ep_driver_start(struc + rtl_loop_wait_high(tp, &rtl_ep_ocp_read_cond, 10000, 30); + } + ++static void rtl8125bp_driver_start(struct rtl8169_private *tp) ++{ ++ r8168ep_ocp_write(tp, 0x01, 0x14, OOB_CMD_DRIVER_START); ++ r8168ep_ocp_write(tp, 0x01, 0x18, 0x00); ++ r8168ep_ocp_write(tp, 0x01, 0x10, 0x01); ++} ++ + static void rtl8168_driver_start(struct rtl8169_private *tp) + { + if (tp->dash_type == RTL_DASH_DP) + rtl8168dp_driver_start(tp); ++ else if (tp->dash_type == RTL_DASH_25_BP) ++ rtl8125bp_driver_start(tp); + else + rtl8168ep_driver_start(tp); + } +@@ -1384,10 +1397,19 @@ static void rtl8168ep_driver_stop(struct + rtl_loop_wait_low(tp, &rtl_ep_ocp_read_cond, 10000, 10); + } + ++static void rtl8125bp_driver_stop(struct rtl8169_private *tp) ++{ ++ r8168ep_ocp_write(tp, 0x01, 0x14, OOB_CMD_DRIVER_STOP); ++ r8168ep_ocp_write(tp, 0x01, 0x18, 0x00); ++ r8168ep_ocp_write(tp, 0x01, 0x10, 0x01); ++} ++ + static void rtl8168_driver_stop(struct rtl8169_private *tp) + { + if (tp->dash_type == RTL_DASH_DP) + rtl8168dp_driver_stop(tp); ++ else if (tp->dash_type == RTL_DASH_25_BP) ++ rtl8125bp_driver_stop(tp); + else + rtl8168ep_driver_stop(tp); + } +@@ -1410,6 +1432,7 @@ static bool rtl_dash_is_enabled(struct r + case RTL_DASH_DP: + return r8168dp_check_dash(tp); + case RTL_DASH_EP: ++ case RTL_DASH_25_BP: + return r8168ep_check_dash(tp); + default: + return false; +@@ -1424,6 +1447,8 @@ static enum rtl_dash_type rtl_get_dash_t + return RTL_DASH_DP; + case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_53: + return RTL_DASH_EP; ++ case RTL_GIGA_MAC_VER_66: ++ return RTL_DASH_25_BP; + default: + return RTL_DASH_NONE; + } +@@ -2260,6 +2285,9 @@ static enum mac_version rtl8169_get_mac_ + { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_71 }, + { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70 }, + ++ /* 8125BP family. */ ++ { 0x7cf, 0x681, RTL_GIGA_MAC_VER_66 }, ++ + /* 8125D family. */ + { 0x7cf, 0x689, RTL_GIGA_MAC_VER_65 }, + { 0x7cf, 0x688, RTL_GIGA_MAC_VER_64 }, +@@ -3865,6 +3893,7 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b, + [RTL_GIGA_MAC_VER_64] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_65] = rtl_hw_start_8125d, ++ [RTL_GIGA_MAC_VER_66] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_70] = rtl_hw_start_8126a, + [RTL_GIGA_MAC_VER_71] = rtl_hw_start_8126a, + }; +@@ -3884,6 +3913,7 @@ static void rtl_hw_start_8125(struct rtl + case RTL_GIGA_MAC_VER_61: + case RTL_GIGA_MAC_VER_64: + case RTL_GIGA_MAC_VER_65: ++ case RTL_GIGA_MAC_VER_66: + for (i = 0xa00; i < 0xb00; i += 4) + RTL_W32(tp, i, 0); + break; +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1102,6 +1102,28 @@ static void rtl8125d_hw_phy_config(struc + rtl8125_config_eee_phy(phydev); + } + ++static void rtl8125bp_hw_phy_config(struct rtl8169_private *tp, ++ struct phy_device *phydev) ++{ ++ r8169_apply_firmware(tp); ++ rtl8168g_enable_gphy_10m(phydev); ++ ++ r8168g_phy_param(phydev, 0x8010, 0x0800, 0x0000); ++ ++ phy_write(phydev, 0x1f, 0x0b87); ++ phy_write(phydev, 0x16, 0x8088); ++ phy_modify(phydev, 0x17, 0xff00, 0x9000); ++ phy_write(phydev, 0x16, 0x808f); ++ phy_modify(phydev, 0x17, 0xff00, 0x9000); ++ phy_write(phydev, 0x1f, 0x0000); ++ ++ r8168g_phy_param(phydev, 0x8174, 0x2000, 0x1800); ++ ++ rtl8125_legacy_force_mode(phydev); ++ rtl8168g_disable_aldps(phydev); ++ rtl8125_config_eee_phy(phydev); ++} ++ + static void rtl8126a_hw_phy_config(struct rtl8169_private *tp, + struct phy_device *phydev) + { +@@ -1163,6 +1185,7 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_63] = rtl8125b_hw_phy_config, + [RTL_GIGA_MAC_VER_64] = rtl8125d_hw_phy_config, + [RTL_GIGA_MAC_VER_65] = rtl8125d_hw_phy_config, ++ [RTL_GIGA_MAC_VER_66] = rtl8125bp_hw_phy_config, + [RTL_GIGA_MAC_VER_70] = rtl8126a_hw_phy_config, + [RTL_GIGA_MAC_VER_71] = rtl8126a_hw_phy_config, + }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-26-v6.15-r8169-make-Kconfig-option-for-LED-support-user-visib.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-26-v6.15-r8169-make-Kconfig-option-for-LED-support-user-visib.patch new file mode 100755 index 0000000..62acd26 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-26-v6.15-r8169-make-Kconfig-option-for-LED-support-user-visib.patch @@ -0,0 +1,28 @@ +From 135c3c86a7cef4ba3d368da15b16c275b74582d3 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 3 Feb 2025 21:35:24 +0100 +Subject: [PATCH] r8169: make Kconfig option for LED support user-visible + +Make config option R8169_LEDS user-visible, so that users can remove +support if not needed. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/d29f0cdb-32bf-435f-b59d-dc96bca1e3ab@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/Kconfig | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/Kconfig ++++ b/drivers/net/ethernet/realtek/Kconfig +@@ -114,7 +114,8 @@ config R8169 + will be called r8169. This is recommended. + + config R8169_LEDS +- def_bool R8169 && LEDS_TRIGGER_NETDEV ++ bool "Support for controlling the NIC LEDs" ++ depends on R8169 && LEDS_TRIGGER_NETDEV + depends on !(R8169=y && LEDS_CLASS=m) + help + Optional support for controlling the NIC LED's with the netdev diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-28-v6.15-r8169-add-support-for-Intel-Killer-E5000.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-28-v6.15-r8169-add-support-for-Intel-Killer-E5000.patch new file mode 100755 index 0000000..d741d19 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-28-v6.15-r8169-add-support-for-Intel-Killer-E5000.patch @@ -0,0 +1,25 @@ +From d30460f42675fef5cd4b44ffbc49b545524555e3 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 12 Feb 2025 08:03:56 +0100 +Subject: [PATCH] r8169: add support for Intel Killer E5000 + +This adds support for the Intel Killer E5000 which seems to be a +rebranded RTL8126. Copied from r8126 vendor driver. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/9db73e9b-e2e8-45de-97a5-041c5f71d774@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -169,6 +169,7 @@ static const struct pci_device_id rtl816 + { PCI_VDEVICE(REALTEK, 0x8125) }, + { PCI_VDEVICE(REALTEK, 0x8126) }, + { PCI_VDEVICE(REALTEK, 0x3000) }, ++ { PCI_VDEVICE(REALTEK, 0x5000) }, + {} + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-29-v6.15-r8169-add-PHY-c45-ops-for-MDIO_MMD_VENDOR2-registers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-29-v6.15-r8169-add-PHY-c45-ops-for-MDIO_MMD_VENDOR2-registers.patch new file mode 100755 index 0000000..1336ec6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-29-v6.15-r8169-add-PHY-c45-ops-for-MDIO_MMD_VENDOR2-registers.patch @@ -0,0 +1,67 @@ +From 853e80369cfceb2331bf34f251ba11c6602cc67f Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 13 Feb 2025 20:15:42 +0100 +Subject: [PATCH] r8169: add PHY c45 ops for MDIO_MMD_VENDOR2 registers + +The integrated PHYs on chip versions from RTL8168g allow to address +MDIO_MMD_VEND2 registers. All c22 standard registers are mapped to +MDIO_MMD_VEND2 registers. So far the paging mechanism is used to +address PHY registers. Add support for c45 ops to address MDIO_MMD_VEND2 +registers directly, w/o the paging. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/d6f97eaa-0f13-468f-89cb-75a41087bc4a@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 32 +++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5225,6 +5225,33 @@ static int r8169_mdio_write_reg(struct m + return 0; + } + ++static int r8169_mdio_read_reg_c45(struct mii_bus *mii_bus, int addr, ++ int devnum, int regnum) ++{ ++ struct rtl8169_private *tp = mii_bus->priv; ++ ++ if (addr > 0) ++ return -ENODEV; ++ ++ if (devnum == MDIO_MMD_VEND2 && regnum > MDIO_STAT2) ++ return r8168_phy_ocp_read(tp, regnum); ++ ++ return 0; ++} ++ ++static int r8169_mdio_write_reg_c45(struct mii_bus *mii_bus, int addr, ++ int devnum, int regnum, u16 val) ++{ ++ struct rtl8169_private *tp = mii_bus->priv; ++ ++ if (addr > 0 || devnum != MDIO_MMD_VEND2 || regnum <= MDIO_STAT2) ++ return -ENODEV; ++ ++ r8168_phy_ocp_write(tp, regnum, val); ++ ++ return 0; ++} ++ + static int r8169_mdio_register(struct rtl8169_private *tp) + { + struct pci_dev *pdev = tp->pci_dev; +@@ -5255,6 +5282,11 @@ static int r8169_mdio_register(struct rt + new_bus->read = r8169_mdio_read_reg; + new_bus->write = r8169_mdio_write_reg; + ++ if (tp->mac_version >= RTL_GIGA_MAC_VER_40) { ++ new_bus->read_c45 = r8169_mdio_read_reg_c45; ++ new_bus->write_c45 = r8169_mdio_write_reg_c45; ++ } ++ + ret = devm_mdiobus_register(&pdev->dev, new_bus); + if (ret) + return ret; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-30-v6.15-r8169-increase-max-jumbo-packet-size-on-RTL8125-RTL8.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-30-v6.15-r8169-increase-max-jumbo-packet-size-on-RTL8125-RTL8.patch new file mode 100755 index 0000000..852c9a3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-30-v6.15-r8169-increase-max-jumbo-packet-size-on-RTL8125-RTL8.patch @@ -0,0 +1,40 @@ +From 473367a5ffe1607a61be481e2feda684eb5faea9 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 7 Mar 2025 08:29:47 +0100 +Subject: [PATCH] r8169: increase max jumbo packet size on RTL8125/RTL8126 + +Realtek confirmed that all RTL8125/RTL8126 chip versions support up to +16K jumbo packets. Reflect this in the driver. + +Tested by Rui on RTL8125B with 12K jumbo packets. + +Suggested-by: Rui Salvaterra +Tested-by: Rui Salvaterra +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/396762ad-cc65-4e60-b01e-8847db89e98b@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -89,6 +89,7 @@ + #define JUMBO_6K (6 * SZ_1K - VLAN_ETH_HLEN - ETH_FCS_LEN) + #define JUMBO_7K (7 * SZ_1K - VLAN_ETH_HLEN - ETH_FCS_LEN) + #define JUMBO_9K (9 * SZ_1K - VLAN_ETH_HLEN - ETH_FCS_LEN) ++#define JUMBO_16K (SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN) + + static const struct { + const char *name; +@@ -5384,6 +5385,9 @@ static int rtl_jumbo_max(struct rtl8169_ + /* RTL8168c */ + case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_24: + return JUMBO_6K; ++ /* RTL8125/8126 */ ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ return JUMBO_16K; + default: + return JUMBO_9K; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-31-v6.15-r8169-switch-away-from-deprecated-pcim_iomap_table.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-31-v6.15-r8169-switch-away-from-deprecated-pcim_iomap_table.patch new file mode 100755 index 0000000..0721247 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-31-v6.15-r8169-switch-away-from-deprecated-pcim_iomap_table.patch @@ -0,0 +1,35 @@ +From 34e5ededf4b8ad4c9e58f0cab8596e26c8fa59a2 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 12 Mar 2025 20:21:42 +0100 +Subject: [PATCH] r8169: switch away from deprecated pcim_iomap_table + +Avoid using deprecated pcim_iomap_table by switching to +pcim_iomap_region. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Jacob Keller +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/a36b4cf3-c792-40fa-8164-5dc9d5f14dd0@gmail.com +Signed-off-by: Paolo Abeni +--- + drivers/net/ethernet/realtek/r8169_main.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5471,11 +5471,10 @@ static int rtl_init_one(struct pci_dev * + if (region < 0) + return dev_err_probe(&pdev->dev, -ENODEV, "no MMIO resource found\n"); + +- rc = pcim_iomap_regions(pdev, BIT(region), KBUILD_MODNAME); +- if (rc < 0) +- return dev_err_probe(&pdev->dev, rc, "cannot remap MMIO, aborting\n"); +- +- tp->mmio_addr = pcim_iomap_table(pdev)[region]; ++ tp->mmio_addr = pcim_iomap_region(pdev, region, KBUILD_MODNAME); ++ if (IS_ERR(tp->mmio_addr)) ++ return dev_err_probe(&pdev->dev, PTR_ERR(tp->mmio_addr), ++ "cannot remap MMIO, aborting\n"); + + txconfig = RTL_R32(tp, TxConfig); + if (txconfig == ~0U) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-32-v6.15-r8169-enable-RTL8168H-RTL8168EP-RTL8168FP-ASPM-suppo.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-32-v6.15-r8169-enable-RTL8168H-RTL8168EP-RTL8168FP-ASPM-suppo.patch new file mode 100755 index 0000000..331d296 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-32-v6.15-r8169-enable-RTL8168H-RTL8168EP-RTL8168FP-ASPM-suppo.patch @@ -0,0 +1,27 @@ +From 3d9b8ac5341269d31e59fd5d58d47266ac78bc32 Mon Sep 17 00:00:00 2001 +From: ChunHao Lin +Date: Tue, 18 Mar 2025 16:37:20 +0800 +Subject: [PATCH] r8169: enable RTL8168H/RTL8168EP/RTL8168FP ASPM support + +This patch will enable RTL8168H/RTL8168EP/RTL8168FP ASPM support on +the platforms that have tested with ASPM enabled. + +Signed-off-by: ChunHao Lin +Reviewed-by: Heiner Kallweit +Link: https://patch.msgid.link/20250318083721.4127-2-hau@realtek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5422,7 +5422,7 @@ done: + /* register is set if system vendor successfully tested ASPM 1.2 */ + static bool rtl_aspm_is_safe(struct rtl8169_private *tp) + { +- if (tp->mac_version >= RTL_GIGA_MAC_VER_61 && ++ if (tp->mac_version >= RTL_GIGA_MAC_VER_46 && + r8168_mac_ocp_read(tp, 0xc0b2) & 0xf) + return true; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-34-v6.16-r8169-add-helper-rtl_csi_mod-for-accessing-extended.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-34-v6.16-r8169-add-helper-rtl_csi_mod-for-accessing-extended.patch new file mode 100755 index 0000000..383f9eb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-34-v6.16-r8169-add-helper-rtl_csi_mod-for-accessing-extended.patch @@ -0,0 +1,74 @@ +From 8c40d99e5f43e0545a3f4fea9156313847e2eb79 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 9 Apr 2025 21:05:37 +0200 +Subject: [PATCH] r8169: add helper rtl_csi_mod for accessing extended config + space + +Add a helper for the Realtek-specific mechanism for accessing extended +config space if native access isn't possible. +This avoids code duplication. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/b368fd91-57d7-4cb5-9342-98b4d8fe9aea@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 26 ++++++++++++++--------- + 1 file changed, 16 insertions(+), 10 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -2849,10 +2849,23 @@ static u32 rtl_csi_read(struct rtl8169_p + RTL_R32(tp, CSIDR) : ~0; + } + ++static void rtl_csi_mod(struct rtl8169_private *tp, int addr, ++ u32 mask, u32 set) ++{ ++ u32 val; ++ ++ WARN(addr % 4, "Invalid CSI address %#x\n", addr); ++ ++ netdev_notice_once(tp->dev, ++ "No native access to PCI extended config space, falling back to CSI\n"); ++ ++ val = rtl_csi_read(tp, addr); ++ rtl_csi_write(tp, addr, (val & ~mask) | set); ++} ++ + static void rtl_disable_zrxdc_timeout(struct rtl8169_private *tp) + { + struct pci_dev *pdev = tp->pci_dev; +- u32 csi; + int rc; + u8 val; + +@@ -2869,16 +2882,12 @@ static void rtl_disable_zrxdc_timeout(st + } + } + +- netdev_notice_once(tp->dev, +- "No native access to PCI extended config space, falling back to CSI\n"); +- csi = rtl_csi_read(tp, RTL_GEN3_RELATED_OFF); +- rtl_csi_write(tp, RTL_GEN3_RELATED_OFF, csi & ~RTL_GEN3_ZRXDC_NONCOMPL); ++ rtl_csi_mod(tp, RTL_GEN3_RELATED_OFF, RTL_GEN3_ZRXDC_NONCOMPL, 0); + } + + static void rtl_set_aspm_entry_latency(struct rtl8169_private *tp, u8 val) + { + struct pci_dev *pdev = tp->pci_dev; +- u32 csi; + + /* According to Realtek the value at config space address 0x070f + * controls the L0s/L1 entrance latency. We try standard ECAM access +@@ -2890,10 +2899,7 @@ static void rtl_set_aspm_entry_latency(s + pci_write_config_byte(pdev, 0x070f, val) == PCIBIOS_SUCCESSFUL) + return; + +- netdev_notice_once(tp->dev, +- "No native access to PCI extended config space, falling back to CSI\n"); +- csi = rtl_csi_read(tp, 0x070c) & 0x00ffffff; +- rtl_csi_write(tp, 0x070c, csi | val << 24); ++ rtl_csi_mod(tp, 0x070c, 0xff000000, val << 24); + } + + static void rtl_set_def_aspm_entry_latency(struct rtl8169_private *tp) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-35-v6.16-r8169-add-helper-rtl8125_phy_param.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-35-v6.16-r8169-add-helper-rtl8125_phy_param.patch new file mode 100755 index 0000000..30ebb4b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-35-v6.16-r8169-add-helper-rtl8125_phy_param.patch @@ -0,0 +1,82 @@ +From 0c49baf099ba2147a6ff3bbdc3197c6ddbee5469 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Wed, 9 Apr 2025 21:14:47 +0200 +Subject: [PATCH] r8169: add helper rtl8125_phy_param + +The integrated PHY's of RTL8125/8126 have an own mechanism to access +PHY parameters, similar to what r8168g_phy_param does on earlier PHY +versions. Add helper rtl8125_phy_param to simplify the code. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/847b7356-12d6-441b-ade9-4b6e1539b84a@gmail.com +Signed-off-by: Jakub Kicinski +--- + .../net/ethernet/realtek/r8169_phy_config.c | 36 +++++++++---------- + 1 file changed, 16 insertions(+), 20 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -50,6 +50,15 @@ static void r8168g_phy_param(struct phy_ + phy_restore_page(phydev, oldpage, 0); + } + ++static void rtl8125_phy_param(struct phy_device *phydev, u16 parm, ++ u16 mask, u16 val) ++{ ++ phy_lock_mdio_bus(phydev); ++ __phy_write_mmd(phydev, MDIO_MMD_VEND2, 0xb87c, parm); ++ __phy_modify_mmd(phydev, MDIO_MMD_VEND2, 0xb87e, mask, val); ++ phy_unlock_mdio_bus(phydev); ++} ++ + struct phy_reg { + u16 reg; + u16 val; +@@ -1004,12 +1013,8 @@ static void rtl8125a_2_hw_phy_config(str + phy_write_paged(phydev, 0xac5, 0x16, 0x01ff); + phy_modify_paged(phydev, 0xac8, 0x15, 0x00f0, 0x0030); + +- phy_write(phydev, 0x1f, 0x0b87); +- phy_write(phydev, 0x16, 0x80a2); +- phy_write(phydev, 0x17, 0x0153); +- phy_write(phydev, 0x16, 0x809c); +- phy_write(phydev, 0x17, 0x0153); +- phy_write(phydev, 0x1f, 0x0000); ++ rtl8125_phy_param(phydev, 0x80a2, 0xffff, 0x0153); ++ rtl8125_phy_param(phydev, 0x809c, 0xffff, 0x0153); + + phy_write(phydev, 0x1f, 0x0a43); + phy_write(phydev, 0x13, 0x81B3); +@@ -1061,14 +1066,9 @@ static void rtl8125b_hw_phy_config(struc + phy_modify_paged(phydev, 0xac4, 0x13, 0x00f0, 0x0090); + phy_modify_paged(phydev, 0xad3, 0x10, 0x0003, 0x0001); + +- phy_write(phydev, 0x1f, 0x0b87); +- phy_write(phydev, 0x16, 0x80f5); +- phy_write(phydev, 0x17, 0x760e); +- phy_write(phydev, 0x16, 0x8107); +- phy_write(phydev, 0x17, 0x360e); +- phy_write(phydev, 0x16, 0x8551); +- phy_modify(phydev, 0x17, 0xff00, 0x0800); +- phy_write(phydev, 0x1f, 0x0000); ++ rtl8125_phy_param(phydev, 0x80f5, 0xffff, 0x760e); ++ rtl8125_phy_param(phydev, 0x8107, 0xffff, 0x360e); ++ rtl8125_phy_param(phydev, 0x8551, 0xff00, 0x0800); + + phy_modify_paged(phydev, 0xbf0, 0x10, 0xe000, 0xa000); + phy_modify_paged(phydev, 0xbf4, 0x13, 0x0f00, 0x0300); +@@ -1110,12 +1110,8 @@ static void rtl8125bp_hw_phy_config(stru + + r8168g_phy_param(phydev, 0x8010, 0x0800, 0x0000); + +- phy_write(phydev, 0x1f, 0x0b87); +- phy_write(phydev, 0x16, 0x8088); +- phy_modify(phydev, 0x17, 0xff00, 0x9000); +- phy_write(phydev, 0x16, 0x808f); +- phy_modify(phydev, 0x17, 0xff00, 0x9000); +- phy_write(phydev, 0x1f, 0x0000); ++ rtl8125_phy_param(phydev, 0x8088, 0xff00, 0x9000); ++ rtl8125_phy_param(phydev, 0x808f, 0xff00, 0x9000); + + r8168g_phy_param(phydev, 0x8174, 0x2000, 0x1800); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-36-v6.16-r8169-refactor-chip-version-detection.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-36-v6.16-r8169-refactor-chip-version-detection.patch new file mode 100755 index 0000000..ae9cfb8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-36-v6.16-r8169-refactor-chip-version-detection.patch @@ -0,0 +1,401 @@ +From 2b065c098c37a3ed28df7c3be59dca61b9da8402 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Tue, 15 Apr 2025 21:29:34 +0200 +Subject: [PATCH] r8169: refactor chip version detection + +Refactor chip version detection and merge both configuration tables. +Apart from reducing the code by a third, this paves the way for +merging chip version handling if only difference is the firmware. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Michal Swiatkowski +Link: https://patch.msgid.link/1fea533a-dd5a-4198-a9e2-895e11083947@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 325 +++++++++------------- + 1 file changed, 128 insertions(+), 197 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -91,61 +91,114 @@ + #define JUMBO_9K (9 * SZ_1K - VLAN_ETH_HLEN - ETH_FCS_LEN) + #define JUMBO_16K (SZ_16K - VLAN_ETH_HLEN - ETH_FCS_LEN) + +-static const struct { ++static const struct rtl_chip_info { ++ u16 mask; ++ u16 val; ++ enum mac_version mac_version; + const char *name; + const char *fw_name; + } rtl_chip_infos[] = { +- /* PCI devices. */ +- [RTL_GIGA_MAC_VER_02] = {"RTL8169s" }, +- [RTL_GIGA_MAC_VER_03] = {"RTL8110s" }, +- [RTL_GIGA_MAC_VER_04] = {"RTL8169sb/8110sb" }, +- [RTL_GIGA_MAC_VER_05] = {"RTL8169sc/8110sc" }, +- [RTL_GIGA_MAC_VER_06] = {"RTL8169sc/8110sc" }, +- /* PCI-E devices. */ +- [RTL_GIGA_MAC_VER_07] = {"RTL8102e" }, +- [RTL_GIGA_MAC_VER_08] = {"RTL8102e" }, +- [RTL_GIGA_MAC_VER_09] = {"RTL8102e/RTL8103e" }, +- [RTL_GIGA_MAC_VER_10] = {"RTL8101e/RTL8100e" }, +- [RTL_GIGA_MAC_VER_14] = {"RTL8401" }, +- [RTL_GIGA_MAC_VER_17] = {"RTL8168b/8111b" }, +- [RTL_GIGA_MAC_VER_18] = {"RTL8168cp/8111cp" }, +- [RTL_GIGA_MAC_VER_19] = {"RTL8168c/8111c" }, +- [RTL_GIGA_MAC_VER_20] = {"RTL8168c/8111c" }, +- [RTL_GIGA_MAC_VER_21] = {"RTL8168c/8111c" }, +- [RTL_GIGA_MAC_VER_22] = {"RTL8168c/8111c" }, +- [RTL_GIGA_MAC_VER_23] = {"RTL8168cp/8111cp" }, +- [RTL_GIGA_MAC_VER_24] = {"RTL8168cp/8111cp" }, +- [RTL_GIGA_MAC_VER_25] = {"RTL8168d/8111d", FIRMWARE_8168D_1}, +- [RTL_GIGA_MAC_VER_26] = {"RTL8168d/8111d", FIRMWARE_8168D_2}, +- [RTL_GIGA_MAC_VER_28] = {"RTL8168dp/8111dp" }, +- [RTL_GIGA_MAC_VER_29] = {"RTL8105e", FIRMWARE_8105E_1}, +- [RTL_GIGA_MAC_VER_30] = {"RTL8105e", FIRMWARE_8105E_1}, +- [RTL_GIGA_MAC_VER_31] = {"RTL8168dp/8111dp" }, +- [RTL_GIGA_MAC_VER_32] = {"RTL8168e/8111e", FIRMWARE_8168E_1}, +- [RTL_GIGA_MAC_VER_33] = {"RTL8168e/8111e", FIRMWARE_8168E_2}, +- [RTL_GIGA_MAC_VER_34] = {"RTL8168evl/8111evl", FIRMWARE_8168E_3}, +- [RTL_GIGA_MAC_VER_35] = {"RTL8168f/8111f", FIRMWARE_8168F_1}, +- [RTL_GIGA_MAC_VER_36] = {"RTL8168f/8111f", FIRMWARE_8168F_2}, +- [RTL_GIGA_MAC_VER_37] = {"RTL8402", FIRMWARE_8402_1 }, +- [RTL_GIGA_MAC_VER_38] = {"RTL8411", FIRMWARE_8411_1 }, +- [RTL_GIGA_MAC_VER_39] = {"RTL8106e", FIRMWARE_8106E_1}, +- [RTL_GIGA_MAC_VER_40] = {"RTL8168g/8111g", FIRMWARE_8168G_2}, +- [RTL_GIGA_MAC_VER_42] = {"RTL8168gu/8111gu", FIRMWARE_8168G_3}, +- [RTL_GIGA_MAC_VER_43] = {"RTL8106eus", FIRMWARE_8106E_2}, +- [RTL_GIGA_MAC_VER_44] = {"RTL8411b", FIRMWARE_8411_2 }, +- [RTL_GIGA_MAC_VER_46] = {"RTL8168h/8111h", FIRMWARE_8168H_2}, +- [RTL_GIGA_MAC_VER_48] = {"RTL8107e", FIRMWARE_8107E_2}, +- [RTL_GIGA_MAC_VER_51] = {"RTL8168ep/8111ep" }, +- [RTL_GIGA_MAC_VER_52] = {"RTL8168fp/RTL8117", FIRMWARE_8168FP_3}, +- [RTL_GIGA_MAC_VER_53] = {"RTL8168fp/RTL8117", }, +- [RTL_GIGA_MAC_VER_61] = {"RTL8125A", FIRMWARE_8125A_3}, +- /* reserve 62 for CFG_METHOD_4 in the vendor driver */ +- [RTL_GIGA_MAC_VER_63] = {"RTL8125B", FIRMWARE_8125B_2}, +- [RTL_GIGA_MAC_VER_64] = {"RTL8125D", FIRMWARE_8125D_1}, +- [RTL_GIGA_MAC_VER_65] = {"RTL8125D", FIRMWARE_8125D_2}, +- [RTL_GIGA_MAC_VER_66] = {"RTL8125BP", FIRMWARE_8125BP_2}, +- [RTL_GIGA_MAC_VER_70] = {"RTL8126A", FIRMWARE_8126A_2}, +- [RTL_GIGA_MAC_VER_71] = {"RTL8126A", FIRMWARE_8126A_3}, ++ /* 8126A family. */ ++ { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_71, "RTL8126A", FIRMWARE_8126A_3 }, ++ { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70, "RTL8126A", FIRMWARE_8126A_2 }, ++ ++ /* 8125BP family. */ ++ { 0x7cf, 0x681, RTL_GIGA_MAC_VER_66, "RTL8125BP", FIRMWARE_8125BP_2 }, ++ ++ /* 8125D family. */ ++ { 0x7cf, 0x689, RTL_GIGA_MAC_VER_65, "RTL8125D", FIRMWARE_8125D_2 }, ++ { 0x7cf, 0x688, RTL_GIGA_MAC_VER_64, "RTL8125D", FIRMWARE_8125D_1 }, ++ ++ /* 8125B family. */ ++ { 0x7cf, 0x641, RTL_GIGA_MAC_VER_63, "RTL8125B", FIRMWARE_8125B_2 }, ++ ++ /* 8125A family. */ ++ { 0x7cf, 0x609, RTL_GIGA_MAC_VER_61, "RTL8125A", FIRMWARE_8125A_3 }, ++ ++ /* RTL8117 */ ++ { 0x7cf, 0x54b, RTL_GIGA_MAC_VER_53, "RTL8168fp/RTL8117" }, ++ { 0x7cf, 0x54a, RTL_GIGA_MAC_VER_52, "RTL8168fp/RTL8117", ++ FIRMWARE_8168FP_3 }, ++ ++ /* 8168EP family. */ ++ { 0x7cf, 0x502, RTL_GIGA_MAC_VER_51, "RTL8168ep/8111ep" }, ++ ++ /* 8168H family. */ ++ { 0x7cf, 0x541, RTL_GIGA_MAC_VER_46, "RTL8168h/8111h", ++ FIRMWARE_8168H_2 }, ++ /* Realtek calls it RTL8168M, but it's handled like RTL8168H */ ++ { 0x7cf, 0x6c0, RTL_GIGA_MAC_VER_46, "RTL8168M", FIRMWARE_8168H_2 }, ++ ++ /* 8168G family. */ ++ { 0x7cf, 0x5c8, RTL_GIGA_MAC_VER_44, "RTL8411b", FIRMWARE_8411_2 }, ++ { 0x7cf, 0x509, RTL_GIGA_MAC_VER_42, "RTL8168gu/8111gu", ++ FIRMWARE_8168G_3 }, ++ { 0x7cf, 0x4c0, RTL_GIGA_MAC_VER_40, "RTL8168g/8111g", ++ FIRMWARE_8168G_2 }, ++ ++ /* 8168F family. */ ++ { 0x7c8, 0x488, RTL_GIGA_MAC_VER_38, "RTL8411", FIRMWARE_8411_1 }, ++ { 0x7cf, 0x481, RTL_GIGA_MAC_VER_36, "RTL8168f/8111f", ++ FIRMWARE_8168F_2 }, ++ { 0x7cf, 0x480, RTL_GIGA_MAC_VER_35, "RTL8168f/8111f", ++ FIRMWARE_8168F_1 }, ++ ++ /* 8168E family. */ ++ { 0x7c8, 0x2c8, RTL_GIGA_MAC_VER_34, "RTL8168evl/8111evl", ++ FIRMWARE_8168E_3 }, ++ { 0x7cf, 0x2c1, RTL_GIGA_MAC_VER_32, "RTL8168e/8111e", ++ FIRMWARE_8168E_1 }, ++ { 0x7c8, 0x2c0, RTL_GIGA_MAC_VER_33, "RTL8168e/8111e", ++ FIRMWARE_8168E_2 }, ++ ++ /* 8168D family. */ ++ { 0x7cf, 0x281, RTL_GIGA_MAC_VER_25, "RTL8168d/8111d", ++ FIRMWARE_8168D_1 }, ++ { 0x7c8, 0x280, RTL_GIGA_MAC_VER_26, "RTL8168d/8111d", ++ FIRMWARE_8168D_2 }, ++ ++ /* 8168DP family. */ ++ { 0x7cf, 0x28a, RTL_GIGA_MAC_VER_28, "RTL8168dp/8111dp" }, ++ { 0x7cf, 0x28b, RTL_GIGA_MAC_VER_31, "RTL8168dp/8111dp" }, ++ ++ /* 8168C family. */ ++ { 0x7cf, 0x3c9, RTL_GIGA_MAC_VER_23, "RTL8168cp/8111cp" }, ++ { 0x7cf, 0x3c8, RTL_GIGA_MAC_VER_18, "RTL8168cp/8111cp" }, ++ { 0x7c8, 0x3c8, RTL_GIGA_MAC_VER_24, "RTL8168cp/8111cp" }, ++ { 0x7cf, 0x3c0, RTL_GIGA_MAC_VER_19, "RTL8168c/8111c" }, ++ { 0x7cf, 0x3c2, RTL_GIGA_MAC_VER_20, "RTL8168c/8111c" }, ++ { 0x7cf, 0x3c3, RTL_GIGA_MAC_VER_21, "RTL8168c/8111c" }, ++ { 0x7c8, 0x3c0, RTL_GIGA_MAC_VER_22, "RTL8168c/8111c" }, ++ ++ /* 8168B family. */ ++ { 0x7c8, 0x380, RTL_GIGA_MAC_VER_17, "RTL8168b/8111b" }, ++ /* This one is very old and rare, support has been removed. ++ * { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11, "RTL8168b/8111b" }, ++ */ ++ ++ /* 8101 family. */ ++ { 0x7c8, 0x448, RTL_GIGA_MAC_VER_39, "RTL8106e", FIRMWARE_8106E_1 }, ++ { 0x7c8, 0x440, RTL_GIGA_MAC_VER_37, "RTL8402", FIRMWARE_8402_1 }, ++ { 0x7cf, 0x409, RTL_GIGA_MAC_VER_29, "RTL8105e", FIRMWARE_8105E_1 }, ++ { 0x7c8, 0x408, RTL_GIGA_MAC_VER_30, "RTL8105e", FIRMWARE_8105E_1 }, ++ { 0x7cf, 0x349, RTL_GIGA_MAC_VER_08, "RTL8102e" }, ++ { 0x7cf, 0x249, RTL_GIGA_MAC_VER_08, "RTL8102e" }, ++ { 0x7cf, 0x348, RTL_GIGA_MAC_VER_07, "RTL8102e" }, ++ { 0x7cf, 0x248, RTL_GIGA_MAC_VER_07, "RTL8102e" }, ++ { 0x7cf, 0x240, RTL_GIGA_MAC_VER_14, "RTL8401" }, ++ { 0x7c8, 0x348, RTL_GIGA_MAC_VER_09, "RTL8102e/RTL8103e" }, ++ { 0x7c8, 0x248, RTL_GIGA_MAC_VER_09, "RTL8102e/RTL8103e" }, ++ { 0x7c8, 0x340, RTL_GIGA_MAC_VER_10, "RTL8101e/RTL8100e" }, ++ ++ /* 8110 family. */ ++ { 0xfc8, 0x980, RTL_GIGA_MAC_VER_06, "RTL8169sc/8110sc" }, ++ { 0xfc8, 0x180, RTL_GIGA_MAC_VER_05, "RTL8169sc/8110sc" }, ++ { 0xfc8, 0x100, RTL_GIGA_MAC_VER_04, "RTL8169sb/8110sb" }, ++ { 0xfc8, 0x040, RTL_GIGA_MAC_VER_03, "RTL8110s" }, ++ { 0xfc8, 0x008, RTL_GIGA_MAC_VER_02, "RTL8169s" }, ++ ++ /* Catch-all */ ++ { 0x000, 0x000, RTL_GIGA_MAC_NONE } + }; + + static const struct pci_device_id rtl8169_pci_tbl[] = { +@@ -2265,151 +2318,30 @@ static const struct ethtool_ops rtl8169_ + .get_eth_ctrl_stats = rtl8169_get_eth_ctrl_stats, + }; + +-static enum mac_version rtl8169_get_mac_version(u16 xid, bool gmii) ++static const struct rtl_chip_info *rtl8169_get_chip_version(u16 xid, bool gmii) + { +- /* +- * The driver currently handles the 8168Bf and the 8168Be identically +- * but they can be identified more specifically through the test below +- * if needed: +- * +- * (RTL_R32(tp, TxConfig) & 0x700000) == 0x500000 ? 8168Bf : 8168Be +- * +- * Same thing for the 8101Eb and the 8101Ec: +- * +- * (RTL_R32(tp, TxConfig) & 0x700000) == 0x200000 ? 8101Eb : 8101Ec +- */ +- static const struct rtl_mac_info { +- u16 mask; +- u16 val; +- enum mac_version ver; +- } mac_info[] = { +- /* 8126A family. */ +- { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_71 }, +- { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70 }, +- +- /* 8125BP family. */ +- { 0x7cf, 0x681, RTL_GIGA_MAC_VER_66 }, +- +- /* 8125D family. */ +- { 0x7cf, 0x689, RTL_GIGA_MAC_VER_65 }, +- { 0x7cf, 0x688, RTL_GIGA_MAC_VER_64 }, +- +- /* 8125B family. */ +- { 0x7cf, 0x641, RTL_GIGA_MAC_VER_63 }, +- +- /* 8125A family. */ +- { 0x7cf, 0x609, RTL_GIGA_MAC_VER_61 }, +- /* It seems only XID 609 made it to the mass market. +- * { 0x7cf, 0x608, RTL_GIGA_MAC_VER_60 }, +- * { 0x7c8, 0x608, RTL_GIGA_MAC_VER_61 }, +- */ +- +- /* RTL8117 */ +- { 0x7cf, 0x54b, RTL_GIGA_MAC_VER_53 }, +- { 0x7cf, 0x54a, RTL_GIGA_MAC_VER_52 }, +- +- /* 8168EP family. */ +- { 0x7cf, 0x502, RTL_GIGA_MAC_VER_51 }, +- /* It seems this chip version never made it to +- * the wild. Let's disable detection. +- * { 0x7cf, 0x501, RTL_GIGA_MAC_VER_50 }, +- * { 0x7cf, 0x500, RTL_GIGA_MAC_VER_49 }, +- */ +- +- /* 8168H family. */ +- { 0x7cf, 0x541, RTL_GIGA_MAC_VER_46 }, +- /* It seems this chip version never made it to +- * the wild. Let's disable detection. +- * { 0x7cf, 0x540, RTL_GIGA_MAC_VER_45 }, +- */ +- /* Realtek calls it RTL8168M, but it's handled like RTL8168H */ +- { 0x7cf, 0x6c0, RTL_GIGA_MAC_VER_46 }, +- +- /* 8168G family. */ +- { 0x7cf, 0x5c8, RTL_GIGA_MAC_VER_44 }, +- { 0x7cf, 0x509, RTL_GIGA_MAC_VER_42 }, +- /* It seems this chip version never made it to +- * the wild. Let's disable detection. +- * { 0x7cf, 0x4c1, RTL_GIGA_MAC_VER_41 }, +- */ +- { 0x7cf, 0x4c0, RTL_GIGA_MAC_VER_40 }, +- +- /* 8168F family. */ +- { 0x7c8, 0x488, RTL_GIGA_MAC_VER_38 }, +- { 0x7cf, 0x481, RTL_GIGA_MAC_VER_36 }, +- { 0x7cf, 0x480, RTL_GIGA_MAC_VER_35 }, +- +- /* 8168E family. */ +- { 0x7c8, 0x2c8, RTL_GIGA_MAC_VER_34 }, +- { 0x7cf, 0x2c1, RTL_GIGA_MAC_VER_32 }, +- { 0x7c8, 0x2c0, RTL_GIGA_MAC_VER_33 }, +- +- /* 8168D family. */ +- { 0x7cf, 0x281, RTL_GIGA_MAC_VER_25 }, +- { 0x7c8, 0x280, RTL_GIGA_MAC_VER_26 }, +- +- /* 8168DP family. */ +- /* It seems this early RTL8168dp version never made it to +- * the wild. Support has been removed. +- * { 0x7cf, 0x288, RTL_GIGA_MAC_VER_27 }, +- */ +- { 0x7cf, 0x28a, RTL_GIGA_MAC_VER_28 }, +- { 0x7cf, 0x28b, RTL_GIGA_MAC_VER_31 }, +- +- /* 8168C family. */ +- { 0x7cf, 0x3c9, RTL_GIGA_MAC_VER_23 }, +- { 0x7cf, 0x3c8, RTL_GIGA_MAC_VER_18 }, +- { 0x7c8, 0x3c8, RTL_GIGA_MAC_VER_24 }, +- { 0x7cf, 0x3c0, RTL_GIGA_MAC_VER_19 }, +- { 0x7cf, 0x3c2, RTL_GIGA_MAC_VER_20 }, +- { 0x7cf, 0x3c3, RTL_GIGA_MAC_VER_21 }, +- { 0x7c8, 0x3c0, RTL_GIGA_MAC_VER_22 }, +- +- /* 8168B family. */ +- { 0x7c8, 0x380, RTL_GIGA_MAC_VER_17 }, +- /* This one is very old and rare, support has been removed. +- * { 0x7c8, 0x300, RTL_GIGA_MAC_VER_11 }, +- */ +- +- /* 8101 family. */ +- { 0x7c8, 0x448, RTL_GIGA_MAC_VER_39 }, +- { 0x7c8, 0x440, RTL_GIGA_MAC_VER_37 }, +- { 0x7cf, 0x409, RTL_GIGA_MAC_VER_29 }, +- { 0x7c8, 0x408, RTL_GIGA_MAC_VER_30 }, +- { 0x7cf, 0x349, RTL_GIGA_MAC_VER_08 }, +- { 0x7cf, 0x249, RTL_GIGA_MAC_VER_08 }, +- { 0x7cf, 0x348, RTL_GIGA_MAC_VER_07 }, +- { 0x7cf, 0x248, RTL_GIGA_MAC_VER_07 }, +- { 0x7cf, 0x240, RTL_GIGA_MAC_VER_14 }, +- { 0x7c8, 0x348, RTL_GIGA_MAC_VER_09 }, +- { 0x7c8, 0x248, RTL_GIGA_MAC_VER_09 }, +- { 0x7c8, 0x340, RTL_GIGA_MAC_VER_10 }, +- +- /* 8110 family. */ +- { 0xfc8, 0x980, RTL_GIGA_MAC_VER_06 }, +- { 0xfc8, 0x180, RTL_GIGA_MAC_VER_05 }, +- { 0xfc8, 0x100, RTL_GIGA_MAC_VER_04 }, +- { 0xfc8, 0x040, RTL_GIGA_MAC_VER_03 }, +- { 0xfc8, 0x008, RTL_GIGA_MAC_VER_02 }, +- +- /* Catch-all */ +- { 0x000, 0x000, RTL_GIGA_MAC_NONE } ++ /* Chips combining a 1Gbps MAC with a 100Mbps PHY */ ++ static const struct rtl_chip_info rtl8106eus_info = { ++ .mac_version = RTL_GIGA_MAC_VER_43, ++ .name = "RTL8106eus", ++ .fw_name = FIRMWARE_8106E_2, + }; +- const struct rtl_mac_info *p = mac_info; +- enum mac_version ver; ++ static const struct rtl_chip_info rtl8107e_info = { ++ .mac_version = RTL_GIGA_MAC_VER_48, ++ .name = "RTL8107e", ++ .fw_name = FIRMWARE_8107E_2, ++ }; ++ const struct rtl_chip_info *p = rtl_chip_infos; + + while ((xid & p->mask) != p->val) + p++; +- ver = p->ver; + +- if (ver != RTL_GIGA_MAC_NONE && !gmii) { +- if (ver == RTL_GIGA_MAC_VER_42) +- ver = RTL_GIGA_MAC_VER_43; +- else if (ver == RTL_GIGA_MAC_VER_46) +- ver = RTL_GIGA_MAC_VER_48; +- } ++ if (p->mac_version == RTL_GIGA_MAC_VER_42 && !gmii) ++ return &rtl8106eus_info; ++ if (p->mac_version == RTL_GIGA_MAC_VER_46 && !gmii) ++ return &rtl8107e_info; + +- return ver; ++ return p; + } + + static void rtl_release_firmware(struct rtl8169_private *tp) +@@ -5437,9 +5369,9 @@ static bool rtl_aspm_is_safe(struct rtl8 + + static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) + { ++ const struct rtl_chip_info *chip; + struct rtl8169_private *tp; + int jumbo_max, region, rc; +- enum mac_version chipset; + struct net_device *dev; + u32 txconfig; + u16 xid; +@@ -5489,12 +5421,13 @@ static int rtl_init_one(struct pci_dev * + xid = (txconfig >> 20) & 0xfcf; + + /* Identify chip attached to board */ +- chipset = rtl8169_get_mac_version(xid, tp->supports_gmii); +- if (chipset == RTL_GIGA_MAC_NONE) ++ chip = rtl8169_get_chip_version(xid, tp->supports_gmii); ++ if (chip->mac_version == RTL_GIGA_MAC_NONE) + return dev_err_probe(&pdev->dev, -ENODEV, + "unknown chip XID %03x, contact r8169 maintainers (see MAINTAINERS file)\n", + xid); +- tp->mac_version = chipset; ++ tp->mac_version = chip->mac_version; ++ tp->fw_name = chip->fw_name; + + /* Disable ASPM L1 as that cause random device stop working + * problems as well as full system hangs for some PCIe devices users. +@@ -5599,8 +5532,6 @@ static int rtl_init_one(struct pci_dev * + + rtl_set_irq_mask(tp); + +- tp->fw_name = rtl_chip_infos[chipset].fw_name; +- + tp->counters = dmam_alloc_coherent (&pdev->dev, sizeof(*tp->counters), + &tp->counters_phys_addr, + GFP_KERNEL); +@@ -5625,7 +5556,7 @@ static int rtl_init_one(struct pci_dev * + } + + netdev_info(dev, "%s, %pM, XID %03x, IRQ %d\n", +- rtl_chip_infos[chipset].name, dev->dev_addr, xid, tp->irq); ++ chip->name, dev->dev_addr, xid, tp->irq); + + if (jumbo_max) + netdev_info(dev, "jumbo features [frames: %d bytes, tx checksumming: %s]\n", diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-37-v6.16-r8169-add-RTL_GIGA_MAC_VER_LAST-to-facilitate-adding.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-37-v6.16-r8169-add-RTL_GIGA_MAC_VER_LAST-to-facilitate-adding.patch new file mode 100755 index 0000000..6dad3f3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-37-v6.16-r8169-add-RTL_GIGA_MAC_VER_LAST-to-facilitate-adding.patch @@ -0,0 +1,159 @@ +From fe733618b27a8c033f0d246c2efff56fca322656 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Tue, 15 Apr 2025 21:39:23 +0200 +Subject: [PATCH] r8169: add RTL_GIGA_MAC_VER_LAST to facilitate adding support + for new chip versions + +Add a new mac_version enum value RTL_GIGA_MAC_VER_LAST. Benefit is that +when adding support for a new chip version we have to touch less code, +except something changes fundamentally. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/06991f47-2aec-4aa2-8918-2c6e79332303@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 3 ++- + drivers/net/ethernet/realtek/r8169_main.c | 28 +++++++++++------------ + 2 files changed, 16 insertions(+), 15 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -73,7 +73,8 @@ enum mac_version { + RTL_GIGA_MAC_VER_66, + RTL_GIGA_MAC_VER_70, + RTL_GIGA_MAC_VER_71, +- RTL_GIGA_MAC_NONE ++ RTL_GIGA_MAC_NONE, ++ RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1 + }; + + struct rtl8169_private; +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -1289,7 +1289,7 @@ static void rtl_writephy(struct rtl8169_ + case RTL_GIGA_MAC_VER_31: + r8168dp_2_mdio_write(tp, location, val); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_LAST: + r8168g_mdio_write(tp, location, val); + break; + default: +@@ -1304,7 +1304,7 @@ static int rtl_readphy(struct rtl8169_pr + case RTL_GIGA_MAC_VER_28: + case RTL_GIGA_MAC_VER_31: + return r8168dp_2_mdio_read(tp, location); +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_LAST: + return r8168g_mdio_read(tp, location); + default: + return r8169_mdio_read(tp, location); +@@ -1656,7 +1656,7 @@ static void __rtl8169_set_wol(struct rtl + break; + case RTL_GIGA_MAC_VER_34: + case RTL_GIGA_MAC_VER_37: +- case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_39 ... RTL_GIGA_MAC_VER_LAST: + r8169_mod_reg8_cond(tp, Config2, PME_SIGNAL, wolopts); + break; + default: +@@ -2129,7 +2129,7 @@ static void rtl_set_eee_txidle_timer(str + tp->tx_lpi_timer = timer_val; + r8168_mac_ocp_write(tp, 0xe048, timer_val); + break; +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_LAST: + tp->tx_lpi_timer = timer_val; + RTL_W16(tp, EEE_TXIDLE_TIMER_8125, timer_val); + break; +@@ -2491,7 +2491,7 @@ static void rtl_init_rxcfg(struct rtl816 + case RTL_GIGA_MAC_VER_61: + RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST); + break; +- case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_LAST: + RTL_W32(tp, RxConfig, RX_FETCH_DFLT_8125 | RX_DMA_BURST | + RX_PAUSE_SLOT_ON); + break; +@@ -2623,7 +2623,7 @@ static void rtl_wait_txrx_fifo_empty(str + case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_61: + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); + break; +- case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_63 ... RTL_GIGA_MAC_VER_LAST: + RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond_2, 100, 42); +@@ -2895,7 +2895,7 @@ static void rtl_enable_exit_l1(struct rt + case RTL_GIGA_MAC_VER_37 ... RTL_GIGA_MAC_VER_38: + rtl_eri_set_bits(tp, 0xd4, 0x0c00); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_LAST: + r8168_mac_ocp_modify(tp, 0xc0ac, 0, 0x1f80); + break; + default: +@@ -2909,7 +2909,7 @@ static void rtl_disable_exit_l1(struct r + case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38: + rtl_eri_clear_bits(tp, 0xd4, 0x1f00); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_LAST: + r8168_mac_ocp_modify(tp, 0xc0ac, 0x1f80, 0); + break; + default: +@@ -2947,7 +2947,7 @@ static void rtl_hw_aspm_clkreq_enable(st + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48: +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_LAST: + /* reset ephy tx/rx disable timer */ + r8168_mac_ocp_modify(tp, 0xe094, 0xff00, 0); + /* chip can trigger L1.2 */ +@@ -2959,7 +2959,7 @@ static void rtl_hw_aspm_clkreq_enable(st + } else { + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_46 ... RTL_GIGA_MAC_VER_48: +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_LAST: + r8168_mac_ocp_modify(tp, 0xe092, 0x00ff, 0); + break; + default: +@@ -4091,7 +4091,7 @@ static void rtl8169_cleanup(struct rtl81 + RTL_W8(tp, ChipCmd, RTL_R8(tp, ChipCmd) | StopReq); + rtl_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 666); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_LAST: + rtl_enable_rxdvgate(tp); + fsleep(2000); + break; +@@ -4248,7 +4248,7 @@ static unsigned int rtl_quirk_packet_pad + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_34: +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_LAST: + padto = max_t(unsigned int, padto, ETH_ZLEN); + break; + default: +@@ -5299,7 +5299,7 @@ static void rtl_hw_initialize(struct rtl + case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_48: + rtl_hw_init_8168g(tp); + break; +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_LAST: + rtl_hw_init_8125(tp); + break; + default: +@@ -5324,7 +5324,7 @@ static int rtl_jumbo_max(struct rtl8169_ + case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_24: + return JUMBO_6K; + /* RTL8125/8126 */ +- case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_71: ++ case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_LAST: + return JUMBO_16K; + default: + return JUMBO_9K; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-38-v6.16-r8169-use-pci_prepare_to_sleep-in-rtl_shutdown.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-38-v6.16-r8169-use-pci_prepare_to_sleep-in-rtl_shutdown.patch new file mode 100755 index 0000000..0f085f0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-38-v6.16-r8169-use-pci_prepare_to_sleep-in-rtl_shutdown.patch @@ -0,0 +1,37 @@ +From b7ed5d5a78fccee96cf8919ac2c7a064c2f4c45b Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 21 Apr 2025 11:25:18 +0200 +Subject: [PATCH] r8169: use pci_prepare_to_sleep in rtl_shutdown + +Use pci_prepare_to_sleep() like PCI core does in pci_pm_suspend_noirq. +This aligns setting a low-power mode during shutdown with the handling +of the transition to system suspend. Also the transition to runtime +suspend uses pci_target_state() instead of setting D3hot unconditionally. + +Note: pci_prepare_to_sleep() uses device_may_wakeup() to check whether + device may generate wakeup events. So we don't lose anything by + not passing tp->saved_wolopts any longer. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Jacob Keller +Link: https://patch.msgid.link/f573fdbd-ba6d-41c1-b68f-311d3c88db2c@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -5037,10 +5037,8 @@ static void rtl_shutdown(struct pci_dev + /* Restore original MAC address */ + rtl_rar_set(tp, tp->dev->perm_addr); + +- if (system_state == SYSTEM_POWER_OFF && !tp->dash_enabled) { +- pci_wake_from_d3(pdev, tp->saved_wolopts); +- pci_set_power_state(pdev, PCI_D3hot); +- } ++ if (system_state == SYSTEM_POWER_OFF && !tp->dash_enabled) ++ pci_prepare_to_sleep(pdev); + } + + static void rtl_remove_one(struct pci_dev *pdev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-39-v6.16-r8169-merge-chip-versions-70-and-71-RTL8126A.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-39-v6.16-r8169-merge-chip-versions-70-and-71-RTL8126A.patch new file mode 100755 index 0000000..caab6c6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-39-v6.16-r8169-merge-chip-versions-70-and-71-RTL8126A.patch @@ -0,0 +1,106 @@ +From 4dec0702b8627c364a0e1f2c5b249e06709a1c24 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 18 Apr 2025 11:23:45 +0200 +Subject: [PATCH] r8169: merge chip versions 70 and 71 (RTL8126A) + +Handling of both chip versions is the same, only difference is +the firmware. So we can merge handling of both chip versions. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/97d7ae79-d021-4b6b-b424-89e5e305b029@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 1 - + drivers/net/ethernet/realtek/r8169_main.c | 15 ++++----------- + drivers/net/ethernet/realtek/r8169_phy_config.c | 1 - + 3 files changed, 4 insertions(+), 13 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -72,7 +72,6 @@ enum mac_version { + RTL_GIGA_MAC_VER_65, + RTL_GIGA_MAC_VER_66, + RTL_GIGA_MAC_VER_70, +- RTL_GIGA_MAC_VER_71, + RTL_GIGA_MAC_NONE, + RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1 + }; +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -99,7 +99,7 @@ static const struct rtl_chip_info { + const char *fw_name; + } rtl_chip_infos[] = { + /* 8126A family. */ +- { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_71, "RTL8126A", FIRMWARE_8126A_3 }, ++ { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_70, "RTL8126A", FIRMWARE_8126A_3 }, + { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70, "RTL8126A", FIRMWARE_8126A_2 }, + + /* 8125BP family. */ +@@ -2936,7 +2936,6 @@ static void rtl_hw_aspm_clkreq_enable(st + rtl_mod_config5(tp, 0, ASPM_en); + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_70: +- case RTL_GIGA_MAC_VER_71: + val8 = RTL_R8(tp, INT_CFG0_8125) | INT_CFG0_CLKREQEN; + RTL_W8(tp, INT_CFG0_8125, val8); + break; +@@ -2968,7 +2967,6 @@ static void rtl_hw_aspm_clkreq_enable(st + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_70: +- case RTL_GIGA_MAC_VER_71: + val8 = RTL_R8(tp, INT_CFG0_8125) & ~INT_CFG0_CLKREQEN; + RTL_W8(tp, INT_CFG0_8125, val8); + break; +@@ -3688,12 +3686,10 @@ static void rtl_hw_start_8125_common(str + /* disable new tx descriptor format */ + r8168_mac_ocp_modify(tp, 0xeb58, 0x0001, 0x0000); + +- if (tp->mac_version == RTL_GIGA_MAC_VER_70 || +- tp->mac_version == RTL_GIGA_MAC_VER_71) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70) + RTL_W8(tp, 0xD8, RTL_R8(tp, 0xD8) & ~0x02); + +- if (tp->mac_version == RTL_GIGA_MAC_VER_70 || +- tp->mac_version == RTL_GIGA_MAC_VER_71) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70) + r8168_mac_ocp_modify(tp, 0xe614, 0x0700, 0x0400); + else if (tp->mac_version == RTL_GIGA_MAC_VER_63) + r8168_mac_ocp_modify(tp, 0xe614, 0x0700, 0x0200); +@@ -3711,8 +3707,7 @@ static void rtl_hw_start_8125_common(str + r8168_mac_ocp_modify(tp, 0xe056, 0x00f0, 0x0000); + r8168_mac_ocp_modify(tp, 0xe040, 0x1000, 0x0000); + r8168_mac_ocp_modify(tp, 0xea1c, 0x0003, 0x0001); +- if (tp->mac_version == RTL_GIGA_MAC_VER_70 || +- tp->mac_version == RTL_GIGA_MAC_VER_71) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70) + r8168_mac_ocp_modify(tp, 0xea1c, 0x0300, 0x0000); + else + r8168_mac_ocp_modify(tp, 0xea1c, 0x0004, 0x0000); +@@ -3835,7 +3830,6 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_65] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_66] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_70] = rtl_hw_start_8126a, +- [RTL_GIGA_MAC_VER_71] = rtl_hw_start_8126a, + }; + + if (hw_configs[tp->mac_version]) +@@ -3859,7 +3853,6 @@ static void rtl_hw_start_8125(struct rtl + break; + case RTL_GIGA_MAC_VER_63: + case RTL_GIGA_MAC_VER_70: +- case RTL_GIGA_MAC_VER_71: + for (i = 0xa00; i < 0xa80; i += 4) + RTL_W32(tp, i, 0); + RTL_W16(tp, INT_CFG1_8125, 0x0000); +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1183,7 +1183,6 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_65] = rtl8125d_hw_phy_config, + [RTL_GIGA_MAC_VER_66] = rtl8125bp_hw_phy_config, + [RTL_GIGA_MAC_VER_70] = rtl8126a_hw_phy_config, +- [RTL_GIGA_MAC_VER_71] = rtl8126a_hw_phy_config, + }; + + if (phy_configs[ver]) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-40-v6.16-r8169-merge-chip-versions-64-and-65-RTL8125D.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-40-v6.16-r8169-merge-chip-versions-64-and-65-RTL8125D.patch new file mode 100755 index 0000000..5110c27 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-40-v6.16-r8169-merge-chip-versions-64-and-65-RTL8125D.patch @@ -0,0 +1,65 @@ +From f372ef6ed5a6b0401c884561d4bba1843e54d46a Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 18 Apr 2025 11:24:30 +0200 +Subject: [PATCH] r8169: merge chip versions 64 and 65 (RTL8125D) + +Handling of both chip versions is the same, only difference is +the firmware. So we can merge handling of both chip versions. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/0baad123-c679-4154-923f-fdc12783e900@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 1 - + drivers/net/ethernet/realtek/r8169_main.c | 4 +--- + drivers/net/ethernet/realtek/r8169_phy_config.c | 1 - + 3 files changed, 1 insertion(+), 5 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -69,7 +69,6 @@ enum mac_version { + RTL_GIGA_MAC_VER_61, + RTL_GIGA_MAC_VER_63, + RTL_GIGA_MAC_VER_64, +- RTL_GIGA_MAC_VER_65, + RTL_GIGA_MAC_VER_66, + RTL_GIGA_MAC_VER_70, + RTL_GIGA_MAC_NONE, +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -106,7 +106,7 @@ static const struct rtl_chip_info { + { 0x7cf, 0x681, RTL_GIGA_MAC_VER_66, "RTL8125BP", FIRMWARE_8125BP_2 }, + + /* 8125D family. */ +- { 0x7cf, 0x689, RTL_GIGA_MAC_VER_65, "RTL8125D", FIRMWARE_8125D_2 }, ++ { 0x7cf, 0x689, RTL_GIGA_MAC_VER_64, "RTL8125D", FIRMWARE_8125D_2 }, + { 0x7cf, 0x688, RTL_GIGA_MAC_VER_64, "RTL8125D", FIRMWARE_8125D_1 }, + + /* 8125B family. */ +@@ -3827,7 +3827,6 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_61] = rtl_hw_start_8125a_2, + [RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b, + [RTL_GIGA_MAC_VER_64] = rtl_hw_start_8125d, +- [RTL_GIGA_MAC_VER_65] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_66] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_70] = rtl_hw_start_8126a, + }; +@@ -3846,7 +3845,6 @@ static void rtl_hw_start_8125(struct rtl + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_61: + case RTL_GIGA_MAC_VER_64: +- case RTL_GIGA_MAC_VER_65: + case RTL_GIGA_MAC_VER_66: + for (i = 0xa00; i < 0xb00; i += 4) + RTL_W32(tp, i, 0); +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1180,7 +1180,6 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_61] = rtl8125a_2_hw_phy_config, + [RTL_GIGA_MAC_VER_63] = rtl8125b_hw_phy_config, + [RTL_GIGA_MAC_VER_64] = rtl8125d_hw_phy_config, +- [RTL_GIGA_MAC_VER_65] = rtl8125d_hw_phy_config, + [RTL_GIGA_MAC_VER_66] = rtl8125bp_hw_phy_config, + [RTL_GIGA_MAC_VER_70] = rtl8126a_hw_phy_config, + }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-41-v6.16-r8169-merge-chip-versions-52-and-53-RTL8117.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-41-v6.16-r8169-merge-chip-versions-52-and-53-RTL8117.patch new file mode 100755 index 0000000..b28c28f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-41-v6.16-r8169-merge-chip-versions-52-and-53-RTL8117.patch @@ -0,0 +1,113 @@ +From 4f51e7d370a04122fa78470b031d6487c52298b1 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 18 Apr 2025 11:25:17 +0200 +Subject: [PATCH] r8169: merge chip versions 52 and 53 (RTL8117) + +Handling of both chip versions is the same, only difference is +the firmware. So we can merge handling of both chip versions. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/ae866b71-c904-434e-befb-848c831e33ff@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 1 - + drivers/net/ethernet/realtek/r8169_main.c | 17 +++++++---------- + drivers/net/ethernet/realtek/r8169_phy_config.c | 1 - + 3 files changed, 7 insertions(+), 12 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -64,7 +64,6 @@ enum mac_version { + /* support for RTL_GIGA_MAC_VER_50 has been removed */ + RTL_GIGA_MAC_VER_51, + RTL_GIGA_MAC_VER_52, +- RTL_GIGA_MAC_VER_53, + /* support for RTL_GIGA_MAC_VER_60 has been removed */ + RTL_GIGA_MAC_VER_61, + RTL_GIGA_MAC_VER_63, +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -116,7 +116,7 @@ static const struct rtl_chip_info { + { 0x7cf, 0x609, RTL_GIGA_MAC_VER_61, "RTL8125A", FIRMWARE_8125A_3 }, + + /* RTL8117 */ +- { 0x7cf, 0x54b, RTL_GIGA_MAC_VER_53, "RTL8168fp/RTL8117" }, ++ { 0x7cf, 0x54b, RTL_GIGA_MAC_VER_52, "RTL8168fp/RTL8117" }, + { 0x7cf, 0x54a, RTL_GIGA_MAC_VER_52, "RTL8168fp/RTL8117", + FIRMWARE_8168FP_3 }, + +@@ -830,7 +830,7 @@ static bool rtl_is_8168evl_up(struct rtl + { + return tp->mac_version >= RTL_GIGA_MAC_VER_34 && + tp->mac_version != RTL_GIGA_MAC_VER_39 && +- tp->mac_version <= RTL_GIGA_MAC_VER_53; ++ tp->mac_version <= RTL_GIGA_MAC_VER_52; + } + + static bool rtl_supports_eee(struct rtl8169_private *tp) +@@ -998,9 +998,7 @@ void r8169_get_led_name(struct rtl8169_p + static void r8168fp_adjust_ocp_cmd(struct rtl8169_private *tp, u32 *cmd, int type) + { + /* based on RTL8168FP_OOBMAC_BASE in vendor driver */ +- if (type == ERIAR_OOB && +- (tp->mac_version == RTL_GIGA_MAC_VER_52 || +- tp->mac_version == RTL_GIGA_MAC_VER_53)) ++ if (type == ERIAR_OOB && tp->mac_version == RTL_GIGA_MAC_VER_52) + *cmd |= 0xf70 << 18; + } + +@@ -1500,7 +1498,7 @@ static enum rtl_dash_type rtl_get_dash_t + case RTL_GIGA_MAC_VER_28: + case RTL_GIGA_MAC_VER_31: + return RTL_DASH_DP; +- case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_53: ++ case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_52: + return RTL_DASH_EP; + case RTL_GIGA_MAC_VER_66: + return RTL_DASH_25_BP; +@@ -2485,7 +2483,7 @@ static void rtl_init_rxcfg(struct rtl816 + case RTL_GIGA_MAC_VER_38: + RTL_W32(tp, RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST); + break; +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_53: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_52: + RTL_W32(tp, RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); + break; + case RTL_GIGA_MAC_VER_61: +@@ -2616,7 +2614,7 @@ DECLARE_RTL_COND(rtl_rxtx_empty_cond_2) + static void rtl_wait_txrx_fifo_empty(struct rtl8169_private *tp) + { + switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_53: ++ case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_52: + rtl_loop_wait_high(tp, &rtl_txcfg_empty_cond, 100, 42); + rtl_loop_wait_high(tp, &rtl_rxtx_empty_cond, 100, 42); + break; +@@ -3823,7 +3821,6 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_48] = rtl_hw_start_8168h_1, + [RTL_GIGA_MAC_VER_51] = rtl_hw_start_8168ep_3, + [RTL_GIGA_MAC_VER_52] = rtl_hw_start_8117, +- [RTL_GIGA_MAC_VER_53] = rtl_hw_start_8117, + [RTL_GIGA_MAC_VER_61] = rtl_hw_start_8125a_2, + [RTL_GIGA_MAC_VER_63] = rtl_hw_start_8125b, + [RTL_GIGA_MAC_VER_64] = rtl_hw_start_8125d, +@@ -5282,7 +5279,7 @@ static void rtl_hw_init_8125(struct rtl8 + static void rtl_hw_initialize(struct rtl8169_private *tp) + { + switch (tp->mac_version) { +- case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_53: ++ case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_52: + rtl8168ep_stop_cmac(tp); + fallthrough; + case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_48: +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1176,7 +1176,6 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_48] = rtl8168h_2_hw_phy_config, + [RTL_GIGA_MAC_VER_51] = rtl8168ep_2_hw_phy_config, + [RTL_GIGA_MAC_VER_52] = rtl8117_hw_phy_config, +- [RTL_GIGA_MAC_VER_53] = rtl8117_hw_phy_config, + [RTL_GIGA_MAC_VER_61] = rtl8125a_2_hw_phy_config, + [RTL_GIGA_MAC_VER_63] = rtl8125b_hw_phy_config, + [RTL_GIGA_MAC_VER_64] = rtl8125d_hw_phy_config, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-42-v6.16-r8169-add-support-for-RTL8127A.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-42-v6.16-r8169-add-support-for-RTL8127A.patch new file mode 100755 index 0000000..45587a3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/780-42-v6.16-r8169-add-support-for-RTL8127A.patch @@ -0,0 +1,323 @@ +From f24f7b2f3af9e008ded20f804d7829ee2efd43f2 Mon Sep 17 00:00:00 2001 +From: ChunHao Lin +Date: Thu, 15 May 2025 17:53:03 +0800 +Subject: [PATCH] r8169: add support for RTL8127A + +This adds support for 10Gbs chip RTL8127A. + +Signed-off-by: ChunHao Lin +Reviewed-by: Heiner Kallweit +Link: https://patch.msgid.link/20250515095303.3138-1-hau@realtek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169.h | 1 + + drivers/net/ethernet/realtek/r8169_main.c | 29 ++- + .../net/ethernet/realtek/r8169_phy_config.c | 166 ++++++++++++++++++ + 3 files changed, 193 insertions(+), 3 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -70,6 +70,7 @@ enum mac_version { + RTL_GIGA_MAC_VER_64, + RTL_GIGA_MAC_VER_66, + RTL_GIGA_MAC_VER_70, ++ RTL_GIGA_MAC_VER_80, + RTL_GIGA_MAC_NONE, + RTL_GIGA_MAC_VER_LAST = RTL_GIGA_MAC_NONE - 1 + }; +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -60,6 +60,7 @@ + #define FIRMWARE_8125BP_2 "rtl_nic/rtl8125bp-2.fw" + #define FIRMWARE_8126A_2 "rtl_nic/rtl8126a-2.fw" + #define FIRMWARE_8126A_3 "rtl_nic/rtl8126a-3.fw" ++#define FIRMWARE_8127A_1 "rtl_nic/rtl8127a-1.fw" + + #define TX_DMA_BURST 7 /* Maximum PCI burst, '7' is unlimited */ + #define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */ +@@ -98,6 +99,9 @@ static const struct rtl_chip_info { + const char *name; + const char *fw_name; + } rtl_chip_infos[] = { ++ /* 8127A family. */ ++ { 0x7cf, 0x6c9, RTL_GIGA_MAC_VER_80, "RTL8127A", FIRMWARE_8127A_1 }, ++ + /* 8126A family. */ + { 0x7cf, 0x64a, RTL_GIGA_MAC_VER_70, "RTL8126A", FIRMWARE_8126A_3 }, + { 0x7cf, 0x649, RTL_GIGA_MAC_VER_70, "RTL8126A", FIRMWARE_8126A_2 }, +@@ -222,8 +226,10 @@ static const struct pci_device_id rtl816 + { 0x0001, 0x8168, PCI_ANY_ID, 0x2410 }, + { PCI_VDEVICE(REALTEK, 0x8125) }, + { PCI_VDEVICE(REALTEK, 0x8126) }, ++ { PCI_VDEVICE(REALTEK, 0x8127) }, + { PCI_VDEVICE(REALTEK, 0x3000) }, + { PCI_VDEVICE(REALTEK, 0x5000) }, ++ { PCI_VDEVICE(REALTEK, 0x0e10) }, + {} + }; + +@@ -769,6 +775,7 @@ MODULE_FIRMWARE(FIRMWARE_8125D_2); + MODULE_FIRMWARE(FIRMWARE_8125BP_2); + MODULE_FIRMWARE(FIRMWARE_8126A_2); + MODULE_FIRMWARE(FIRMWARE_8126A_3); ++MODULE_FIRMWARE(FIRMWARE_8127A_1); + + static inline struct device *tp_to_dev(struct rtl8169_private *tp) + { +@@ -2934,6 +2941,7 @@ static void rtl_hw_aspm_clkreq_enable(st + rtl_mod_config5(tp, 0, ASPM_en); + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_70: ++ case RTL_GIGA_MAC_VER_80: + val8 = RTL_R8(tp, INT_CFG0_8125) | INT_CFG0_CLKREQEN; + RTL_W8(tp, INT_CFG0_8125, val8); + break; +@@ -2965,6 +2973,7 @@ static void rtl_hw_aspm_clkreq_enable(st + + switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_70: ++ case RTL_GIGA_MAC_VER_80: + val8 = RTL_R8(tp, INT_CFG0_8125) & ~INT_CFG0_CLKREQEN; + RTL_W8(tp, INT_CFG0_8125, val8); + break; +@@ -3684,10 +3693,13 @@ static void rtl_hw_start_8125_common(str + /* disable new tx descriptor format */ + r8168_mac_ocp_modify(tp, 0xeb58, 0x0001, 0x0000); + +- if (tp->mac_version == RTL_GIGA_MAC_VER_70) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70 || ++ tp->mac_version == RTL_GIGA_MAC_VER_80) + RTL_W8(tp, 0xD8, RTL_R8(tp, 0xD8) & ~0x02); + +- if (tp->mac_version == RTL_GIGA_MAC_VER_70) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_80) ++ r8168_mac_ocp_modify(tp, 0xe614, 0x0f00, 0x0f00); ++ else if (tp->mac_version == RTL_GIGA_MAC_VER_70) + r8168_mac_ocp_modify(tp, 0xe614, 0x0700, 0x0400); + else if (tp->mac_version == RTL_GIGA_MAC_VER_63) + r8168_mac_ocp_modify(tp, 0xe614, 0x0700, 0x0200); +@@ -3705,7 +3717,8 @@ static void rtl_hw_start_8125_common(str + r8168_mac_ocp_modify(tp, 0xe056, 0x00f0, 0x0000); + r8168_mac_ocp_modify(tp, 0xe040, 0x1000, 0x0000); + r8168_mac_ocp_modify(tp, 0xea1c, 0x0003, 0x0001); +- if (tp->mac_version == RTL_GIGA_MAC_VER_70) ++ if (tp->mac_version == RTL_GIGA_MAC_VER_70 || ++ tp->mac_version == RTL_GIGA_MAC_VER_80) + r8168_mac_ocp_modify(tp, 0xea1c, 0x0300, 0x0000); + else + r8168_mac_ocp_modify(tp, 0xea1c, 0x0004, 0x0000); +@@ -3783,6 +3796,12 @@ static void rtl_hw_start_8126a(struct rt + rtl_hw_start_8125_common(tp); + } + ++static void rtl_hw_start_8127a(struct rtl8169_private *tp) ++{ ++ rtl_set_def_aspm_entry_latency(tp); ++ rtl_hw_start_8125_common(tp); ++} ++ + static void rtl_hw_config(struct rtl8169_private *tp) + { + static const rtl_generic_fct hw_configs[] = { +@@ -3826,6 +3845,7 @@ static void rtl_hw_config(struct rtl8169 + [RTL_GIGA_MAC_VER_64] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_66] = rtl_hw_start_8125d, + [RTL_GIGA_MAC_VER_70] = rtl_hw_start_8126a, ++ [RTL_GIGA_MAC_VER_80] = rtl_hw_start_8127a, + }; + + if (hw_configs[tp->mac_version]) +@@ -3843,8 +3863,11 @@ static void rtl_hw_start_8125(struct rtl + case RTL_GIGA_MAC_VER_61: + case RTL_GIGA_MAC_VER_64: + case RTL_GIGA_MAC_VER_66: ++ case RTL_GIGA_MAC_VER_80: + for (i = 0xa00; i < 0xb00; i += 4) + RTL_W32(tp, i, 0); ++ if (tp->mac_version == RTL_GIGA_MAC_VER_80) ++ RTL_W16(tp, INT_CFG1_8125, 0x0000); + break; + case RTL_GIGA_MAC_VER_63: + case RTL_GIGA_MAC_VER_70: +--- a/drivers/net/ethernet/realtek/r8169_phy_config.c ++++ b/drivers/net/ethernet/realtek/r8169_phy_config.c +@@ -1130,6 +1130,171 @@ static void rtl8126a_hw_phy_config(struc + rtl8125_common_config_eee_phy(phydev); + } + ++static void rtl8127a_1_hw_phy_config(struct rtl8169_private *tp, ++ struct phy_device *phydev) ++{ ++ r8169_apply_firmware(tp); ++ rtl8168g_enable_gphy_10m(phydev); ++ ++ r8168g_phy_param(phydev, 0x8415, 0xff00, 0x9300); ++ r8168g_phy_param(phydev, 0x81a3, 0xff00, 0x0f00); ++ r8168g_phy_param(phydev, 0x81ae, 0xff00, 0x0f00); ++ r8168g_phy_param(phydev, 0x81b9, 0xff00, 0xb900); ++ rtl8125_phy_param(phydev, 0x83b0, 0x0e00, 0x0000); ++ rtl8125_phy_param(phydev, 0x83C5, 0x0e00, 0x0000); ++ rtl8125_phy_param(phydev, 0x83da, 0x0e00, 0x0000); ++ rtl8125_phy_param(phydev, 0x83ef, 0x0e00, 0x0000); ++ phy_modify_paged(phydev, 0x0bf3, 0x14, 0x01f0, 0x0160); ++ phy_modify_paged(phydev, 0x0bf3, 0x15, 0x001f, 0x0014); ++ phy_modify_paged(phydev, 0x0bf2, 0x14, 0x6000, 0x0000); ++ phy_modify_paged(phydev, 0x0bf2, 0x16, 0xc000, 0x0000); ++ phy_modify_paged(phydev, 0x0bf2, 0x14, 0x1fff, 0x0187); ++ phy_modify_paged(phydev, 0x0bf2, 0x15, 0x003f, 0x0003); ++ ++ r8168g_phy_param(phydev, 0x8173, 0xffff, 0x8620); ++ r8168g_phy_param(phydev, 0x8175, 0xffff, 0x8671); ++ r8168g_phy_param(phydev, 0x817c, 0x0000, 0x2000); ++ r8168g_phy_param(phydev, 0x8187, 0x0000, 0x2000); ++ r8168g_phy_param(phydev, 0x8192, 0x0000, 0x2000); ++ r8168g_phy_param(phydev, 0x819d, 0x0000, 0x2000); ++ r8168g_phy_param(phydev, 0x81a8, 0x2000, 0x0000); ++ r8168g_phy_param(phydev, 0x81b3, 0x2000, 0x0000); ++ r8168g_phy_param(phydev, 0x81be, 0x0000, 0x2000); ++ r8168g_phy_param(phydev, 0x817d, 0xff00, 0xa600); ++ r8168g_phy_param(phydev, 0x8188, 0xff00, 0xa600); ++ r8168g_phy_param(phydev, 0x8193, 0xff00, 0xa600); ++ r8168g_phy_param(phydev, 0x819e, 0xff00, 0xa600); ++ r8168g_phy_param(phydev, 0x81a9, 0xff00, 0x1400); ++ r8168g_phy_param(phydev, 0x81b4, 0xff00, 0x1400); ++ r8168g_phy_param(phydev, 0x81bf, 0xff00, 0xa600); ++ ++ phy_modify_paged(phydev, 0x0aea, 0x15, 0x0028, 0x0000); ++ ++ rtl8125_phy_param(phydev, 0x84f0, 0xffff, 0x201c); ++ rtl8125_phy_param(phydev, 0x84f2, 0xffff, 0x3117); ++ ++ phy_write_paged(phydev, 0x0aec, 0x13, 0x0000); ++ phy_write_paged(phydev, 0x0ae2, 0x10, 0xffff); ++ phy_write_paged(phydev, 0x0aec, 0x17, 0xffff); ++ phy_write_paged(phydev, 0x0aed, 0x11, 0xffff); ++ phy_write_paged(phydev, 0x0aec, 0x14, 0x0000); ++ phy_modify_paged(phydev, 0x0aed, 0x10, 0x0001, 0x0000); ++ phy_write_paged(phydev, 0x0adb, 0x14, 0x0150); ++ rtl8125_phy_param(phydev, 0x8197, 0xff00, 0x5000); ++ rtl8125_phy_param(phydev, 0x8231, 0xff00, 0x5000); ++ rtl8125_phy_param(phydev, 0x82cb, 0xff00, 0x5000); ++ rtl8125_phy_param(phydev, 0x82cd, 0xff00, 0x5700); ++ rtl8125_phy_param(phydev, 0x8233, 0xff00, 0x5700); ++ rtl8125_phy_param(phydev, 0x8199, 0xff00, 0x5700); ++ ++ rtl8125_phy_param(phydev, 0x815a, 0xffff, 0x0150); ++ rtl8125_phy_param(phydev, 0x81f4, 0xffff, 0x0150); ++ rtl8125_phy_param(phydev, 0x828e, 0xffff, 0x0150); ++ rtl8125_phy_param(phydev, 0x81b1, 0xffff, 0x0000); ++ rtl8125_phy_param(phydev, 0x824b, 0xffff, 0x0000); ++ rtl8125_phy_param(phydev, 0x82e5, 0xffff, 0x0000); ++ ++ rtl8125_phy_param(phydev, 0x84f7, 0xff00, 0x2800); ++ phy_modify_paged(phydev, 0x0aec, 0x11, 0x0000, 0x1000); ++ rtl8125_phy_param(phydev, 0x81b3, 0xff00, 0xad00); ++ rtl8125_phy_param(phydev, 0x824d, 0xff00, 0xad00); ++ rtl8125_phy_param(phydev, 0x82e7, 0xff00, 0xad00); ++ phy_modify_paged(phydev, 0x0ae4, 0x17, 0x000f, 0x0001); ++ rtl8125_phy_param(phydev, 0x82ce, 0xf000, 0x4000); ++ ++ rtl8125_phy_param(phydev, 0x84ac, 0xffff, 0x0000); ++ rtl8125_phy_param(phydev, 0x84ae, 0xffff, 0x0000); ++ rtl8125_phy_param(phydev, 0x84b0, 0xffff, 0xf818); ++ rtl8125_phy_param(phydev, 0x84b2, 0xff00, 0x6000); ++ ++ rtl8125_phy_param(phydev, 0x8ffc, 0xffff, 0x6008); ++ rtl8125_phy_param(phydev, 0x8ffe, 0xffff, 0xf450); ++ ++ rtl8125_phy_param(phydev, 0x8015, 0x0000, 0x0200); ++ rtl8125_phy_param(phydev, 0x8016, 0x0800, 0x0000); ++ rtl8125_phy_param(phydev, 0x8fe6, 0xff00, 0x0800); ++ rtl8125_phy_param(phydev, 0x8fe4, 0xffff, 0x2114); ++ ++ rtl8125_phy_param(phydev, 0x8647, 0xffff, 0xa7b1); ++ rtl8125_phy_param(phydev, 0x8649, 0xffff, 0xbbca); ++ rtl8125_phy_param(phydev, 0x864b, 0xff00, 0xdc00); ++ ++ rtl8125_phy_param(phydev, 0x8154, 0xc000, 0x4000); ++ rtl8125_phy_param(phydev, 0x8158, 0xc000, 0x0000); ++ ++ rtl8125_phy_param(phydev, 0x826c, 0xffff, 0xffff); ++ rtl8125_phy_param(phydev, 0x826e, 0xffff, 0xffff); ++ ++ rtl8125_phy_param(phydev, 0x8872, 0xff00, 0x0e00); ++ r8168g_phy_param(phydev, 0x8012, 0x0000, 0x0800); ++ r8168g_phy_param(phydev, 0x8012, 0x0000, 0x4000); ++ phy_modify_paged(phydev, 0x0b57, 0x13, 0x0000, 0x0001); ++ r8168g_phy_param(phydev, 0x834a, 0xff00, 0x0700); ++ rtl8125_phy_param(phydev, 0x8217, 0x3f00, 0x2a00); ++ r8168g_phy_param(phydev, 0x81b1, 0xff00, 0x0b00); ++ rtl8125_phy_param(phydev, 0x8fed, 0xff00, 0x4e00); ++ ++ rtl8125_phy_param(phydev, 0x88ac, 0xff00, 0x2300); ++ phy_modify_paged(phydev, 0x0bf0, 0x16, 0x0000, 0x3800); ++ rtl8125_phy_param(phydev, 0x88de, 0xff00, 0x0000); ++ rtl8125_phy_param(phydev, 0x80b4, 0xffff, 0x5195); ++ ++ r8168g_phy_param(phydev, 0x8370, 0xffff, 0x8671); ++ r8168g_phy_param(phydev, 0x8372, 0xffff, 0x86c8); ++ ++ r8168g_phy_param(phydev, 0x8401, 0xffff, 0x86c8); ++ r8168g_phy_param(phydev, 0x8403, 0xffff, 0x86da); ++ r8168g_phy_param(phydev, 0x8406, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x8408, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x840a, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x840c, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x840e, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x8410, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x8412, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x8414, 0x1800, 0x1000); ++ r8168g_phy_param(phydev, 0x8416, 0x1800, 0x1000); ++ ++ r8168g_phy_param(phydev, 0x82bd, 0xffff, 0x1f40); ++ ++ phy_modify_paged(phydev, 0x0bfb, 0x12, 0x07ff, 0x0328); ++ phy_write_paged(phydev, 0x0bfb, 0x13, 0x3e14); ++ ++ r8168g_phy_param(phydev, 0x81c4, 0xffff, 0x003b); ++ r8168g_phy_param(phydev, 0x81c6, 0xffff, 0x0086); ++ r8168g_phy_param(phydev, 0x81c8, 0xffff, 0x00b7); ++ r8168g_phy_param(phydev, 0x81ca, 0xffff, 0x00db); ++ r8168g_phy_param(phydev, 0x81cc, 0xffff, 0x00fe); ++ r8168g_phy_param(phydev, 0x81ce, 0xffff, 0x00fe); ++ r8168g_phy_param(phydev, 0x81d0, 0xffff, 0x00fe); ++ r8168g_phy_param(phydev, 0x81d2, 0xffff, 0x00fe); ++ r8168g_phy_param(phydev, 0x81d4, 0xffff, 0x00c3); ++ r8168g_phy_param(phydev, 0x81d6, 0xffff, 0x0078); ++ r8168g_phy_param(phydev, 0x81d8, 0xffff, 0x0047); ++ r8168g_phy_param(phydev, 0x81da, 0xffff, 0x0023); ++ ++ rtl8125_phy_param(phydev, 0x88d7, 0xffff, 0x01a0); ++ rtl8125_phy_param(phydev, 0x88d9, 0xffff, 0x01a0); ++ rtl8125_phy_param(phydev, 0x8ffa, 0xffff, 0x002a); ++ ++ rtl8125_phy_param(phydev, 0x8fee, 0xffff, 0xffdf); ++ rtl8125_phy_param(phydev, 0x8ff0, 0xffff, 0xffff); ++ rtl8125_phy_param(phydev, 0x8ff2, 0xffff, 0x0a4a); ++ rtl8125_phy_param(phydev, 0x8ff4, 0xffff, 0xaa5a); ++ rtl8125_phy_param(phydev, 0x8ff6, 0xffff, 0x0a4a); ++ ++ rtl8125_phy_param(phydev, 0x8ff8, 0xffff, 0xaa5a); ++ rtl8125_phy_param(phydev, 0x88d5, 0xff00, 0x0200); ++ ++ r8168g_phy_param(phydev, 0x84bb, 0xff00, 0x0a00); ++ r8168g_phy_param(phydev, 0x84c0, 0xff00, 0x1600); ++ ++ phy_modify_paged(phydev, 0x0a43, 0x10, 0x0000, 0x0003); ++ ++ rtl8125_legacy_force_mode(phydev); ++ rtl8168g_disable_aldps(phydev); ++ rtl8125_common_config_eee_phy(phydev); ++} ++ + void r8169_hw_phy_config(struct rtl8169_private *tp, struct phy_device *phydev, + enum mac_version ver) + { +@@ -1181,6 +1346,7 @@ void r8169_hw_phy_config(struct rtl8169_ + [RTL_GIGA_MAC_VER_64] = rtl8125d_hw_phy_config, + [RTL_GIGA_MAC_VER_66] = rtl8125bp_hw_phy_config, + [RTL_GIGA_MAC_VER_70] = rtl8126a_hw_phy_config, ++ [RTL_GIGA_MAC_VER_80] = rtl8127a_1_hw_phy_config, + }; + + if (phy_configs[ver]) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-01-v6.13-net-phy-realtek-read-duplex-and-gbit-master-from-PHY.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-01-v6.13-net-phy-realtek-read-duplex-and-gbit-master-from-PHY.patch new file mode 100755 index 0000000..31b8aab --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-01-v6.13-net-phy-realtek-read-duplex-and-gbit-master-from-PHY.patch @@ -0,0 +1,106 @@ +From 081c9c0265c91b8333165aa6230c20bcbc6f7cbf Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 14:07:16 +0100 +Subject: [PATCH] net: phy: realtek: read duplex and gbit master from PHYSR + register + +The PHYSR MMD register is present and defined equally for all RTL82xx +Ethernet PHYs. +Read duplex and Gbit master bits from rtlgen_decode_speed() and rename +it to rtlgen_decode_physr(). + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/b9a76341da851a18c985bc4774fa295babec79bb.1728565530.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek.c | 41 +++++++++++++++++++++++++++++++-------- + 1 file changed, 33 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -80,15 +80,18 @@ + + #define RTL822X_VND2_GANLPAR 0xa414 + +-#define RTL822X_VND2_PHYSR 0xa434 +- + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + + #define RTL9000A_GINMR 0x14 + #define RTL9000A_GINMR_LINK_STATUS BIT(4) + +-#define RTLGEN_SPEED_MASK 0x0630 ++#define RTL_VND2_PHYSR 0xa434 ++#define RTL_VND2_PHYSR_DUPLEX BIT(3) ++#define RTL_VND2_PHYSR_SPEEDL GENMASK(5, 4) ++#define RTL_VND2_PHYSR_SPEEDH GENMASK(10, 9) ++#define RTL_VND2_PHYSR_MASTER BIT(11) ++#define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR_SPEEDH) + + #define RTL_GENERIC_PHYID 0x001cc800 + #define RTL_8211FVD_PHYID 0x001cc878 +@@ -661,9 +664,18 @@ static int rtl8366rb_config_init(struct + } + + /* get actual speed to cover the downshift case */ +-static void rtlgen_decode_speed(struct phy_device *phydev, int val) ++static void rtlgen_decode_physr(struct phy_device *phydev, int val) + { +- switch (val & RTLGEN_SPEED_MASK) { ++ /* bit 3 ++ * 0: Half Duplex ++ * 1: Full Duplex ++ */ ++ if (val & RTL_VND2_PHYSR_DUPLEX) ++ phydev->duplex = DUPLEX_FULL; ++ else ++ phydev->duplex = DUPLEX_HALF; ++ ++ switch (val & RTL_VND2_PHYSR_SPEED_MASK) { + case 0x0000: + phydev->speed = SPEED_10; + break; +@@ -685,6 +697,19 @@ static void rtlgen_decode_speed(struct p + default: + break; + } ++ ++ /* bit 11 ++ * 0: Slave Mode ++ * 1: Master Mode ++ */ ++ if (phydev->speed >= 1000) { ++ if (val & RTL_VND2_PHYSR_MASTER) ++ phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; ++ else ++ phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; ++ } else { ++ phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; ++ } + } + + static int rtlgen_read_status(struct phy_device *phydev) +@@ -702,7 +727,7 @@ static int rtlgen_read_status(struct phy + if (val < 0) + return val; + +- rtlgen_decode_speed(phydev, val); ++ rtlgen_decode_physr(phydev, val); + + return 0; + } +@@ -1008,11 +1033,11 @@ static int rtl822x_c45_read_status(struc + return 0; + + /* Read actual speed from vendor register. */ +- val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_PHYSR); ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR); + if (val < 0) + return val; + +- rtlgen_decode_speed(phydev, val); ++ rtlgen_decode_physr(phydev, val); + + return 0; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-02-v6.13-net-phy-realtek-change-order-of-calls-in-C22-read_st.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-02-v6.13-net-phy-realtek-change-order-of-calls-in-C22-read_st.patch new file mode 100755 index 0000000..2e5d7bb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-02-v6.13-net-phy-realtek-change-order-of-calls-in-C22-read_st.patch @@ -0,0 +1,53 @@ +From 68d5cd09e8919679ce13b85950debea4b2e98e04 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 14:07:26 +0100 +Subject: [PATCH] net: phy: realtek: change order of calls in C22 read_status() + +Always call rtlgen_read_status() first, so genphy_read_status() which +is called by it clears bits in case auto-negotiation has not completed. +Also clear 10GBT link-partner advertisement bits in case auto-negotiation +is disabled or has not completed. + +Suggested-by: Russell King (Oracle) +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/b15929a41621d215c6b2b57393368086589569ec.1728565530.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek.c | 22 +++++++++++++++------- + 1 file changed, 15 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -950,17 +950,25 @@ static void rtl822xb_update_interface(st + + static int rtl822x_read_status(struct phy_device *phydev) + { +- if (phydev->autoneg == AUTONEG_ENABLE) { +- int lpadv = phy_read_paged(phydev, 0xa5d, 0x13); ++ int lpadv, ret; + +- if (lpadv < 0) +- return lpadv; ++ ret = rtlgen_read_status(phydev); ++ if (ret < 0) ++ return ret; + +- mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, +- lpadv); ++ if (phydev->autoneg == AUTONEG_DISABLE || ++ !phydev->autoneg_complete) { ++ mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); ++ return 0; + } + +- return rtlgen_read_status(phydev); ++ lpadv = phy_read_paged(phydev, 0xa5d, 0x13); ++ if (lpadv < 0) ++ return lpadv; ++ ++ mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, lpadv); ++ ++ return 0; + } + + static int rtl822xb_read_status(struct phy_device *phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-03-v6.13-net-phy-realtek-clear-1000Base-T-link-partner-advert.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-03-v6.13-net-phy-realtek-clear-1000Base-T-link-partner-advert.patch new file mode 100755 index 0000000..f7d8a5a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-03-v6.13-net-phy-realtek-clear-1000Base-T-link-partner-advert.patch @@ -0,0 +1,30 @@ +From 5cb409b3960e75467cbb0a8e1e5596b4490570e3 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 10 Oct 2024 14:07:39 +0100 +Subject: [PATCH] net: phy: realtek: clear 1000Base-T link partner + advertisement + +Clear 1000Base-T link partner advertisement bits in Clause-45 +read_status() function in case auto-negotiation is disabled or has not +been completed. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/9dc9b47b2d675708afef3ad366bfd78eb584d958.1728565530.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -1027,6 +1027,10 @@ static int rtl822x_c45_read_status(struc + if (ret < 0) + return ret; + ++ if (phydev->autoneg == AUTONEG_DISABLE || ++ !genphy_c45_aneg_done(phydev)) ++ mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0); ++ + /* Vendor register as C45 has no standardized support for 1000BaseT */ + if (phydev->autoneg == AUTONEG_ENABLE) { + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-06-v6.14-net-phy-realtek-add-support-for-reading-MDIO_MMD_VEN.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-06-v6.14-net-phy-realtek-add-support-for-reading-MDIO_MMD_VEN.patch new file mode 100755 index 0000000..2add672 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-06-v6.14-net-phy-realtek-add-support-for-reading-MDIO_MMD_VEN.patch @@ -0,0 +1,47 @@ +From 3d483a10327f38595f714f9f9e9dde43a622cb0f Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 11 Jan 2025 21:49:31 +0100 +Subject: [PATCH] net: phy: realtek: add support for reading MDIO_MMD_VEND2 + regs on RTL8125/RTL8126 + +RTL8125/RTL8126 don't support MMD access to the internal PHY, but +provide a mechanism to access at least all MDIO_MMD_VEND2 registers. +By exposing this mechanism standard MMD access functions can be used +to access the MDIO_MMD_VEND2 registers. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/e821b302-5fe6-49ab-aabd-05da500581c0@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -736,7 +736,11 @@ static int rtlgen_read_mmd(struct phy_de + { + int ret; + +- if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) { ++ if (devnum == MDIO_MMD_VEND2) { ++ rtl821x_write_page(phydev, regnum >> 4); ++ ret = __phy_read(phydev, 0x10 + ((regnum & 0xf) >> 1)); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) { + rtl821x_write_page(phydev, 0xa5c); + ret = __phy_read(phydev, 0x12); + rtl821x_write_page(phydev, 0); +@@ -760,7 +764,11 @@ static int rtlgen_write_mmd(struct phy_d + { + int ret; + +- if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { ++ if (devnum == MDIO_MMD_VEND2) { ++ rtl821x_write_page(phydev, regnum >> 4); ++ ret = __phy_write(phydev, 0x10 + ((regnum & 0xf) >> 1), val); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { + rtl821x_write_page(phydev, 0xa5d); + ret = __phy_write(phydev, 0x10, val); + rtl821x_write_page(phydev, 0); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-07-v6.14-net-phy-realtek-clear-1000Base-T-lpa-if-link-is-down.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-07-v6.14-net-phy-realtek-clear-1000Base-T-lpa-if-link-is-down.patch new file mode 100755 index 0000000..002b99e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-07-v6.14-net-phy-realtek-clear-1000Base-T-lpa-if-link-is-down.patch @@ -0,0 +1,52 @@ +From 34d5a86ff7bbe225fba3ad91f9b4dc85fb408e18 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 15 Jan 2025 14:43:35 +0000 +Subject: [PATCH] net: phy: realtek: clear 1000Base-T lpa if link is down + +Only read 1000Base-T link partner advertisement if autonegotiation has +completed and otherwise 1000Base-T link partner advertisement bits. + +This fixes bogus 1000Base-T link partner advertisement after link goes +down (eg. by disconnecting the wire). +Fixes: 5cb409b3960e ("net: phy: realtek: clear 1000Base-T link partner advertisement") +Signed-off-by: Daniel Golle +Reviewed-by: Michal Swiatkowski +Signed-off-by: David S. Miller +--- + drivers/net/phy/realtek.c | 19 ++++++++----------- + 1 file changed, 8 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -1031,23 +1031,20 @@ static int rtl822x_c45_read_status(struc + { + int ret, val; + +- ret = genphy_c45_read_status(phydev); +- if (ret < 0) +- return ret; +- +- if (phydev->autoneg == AUTONEG_DISABLE || +- !genphy_c45_aneg_done(phydev)) +- mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, 0); +- + /* Vendor register as C45 has no standardized support for 1000BaseT */ +- if (phydev->autoneg == AUTONEG_ENABLE) { ++ if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) { + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, + RTL822X_VND2_GANLPAR); + if (val < 0) + return val; +- +- mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); ++ } else { ++ val = 0; + } ++ mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); ++ ++ ret = genphy_c45_read_status(phydev); ++ if (ret < 0) ++ return ret; + + if (!phydev->link) + return 0; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-08-v6.14-net-phy-realtek-clear-master_slave_state-if-link-is-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-08-v6.14-net-phy-realtek-clear-master_slave_state-if-link-is-.patch new file mode 100755 index 0000000..f8cfc4d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-08-v6.14-net-phy-realtek-clear-master_slave_state-if-link-is-.patch @@ -0,0 +1,35 @@ +From ea8318cb33e593bbfc59d637eae45a69732c5387 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 15 Jan 2025 14:43:43 +0000 +Subject: [PATCH] net: phy: realtek: clear master_slave_state if link is down + +rtlgen_decode_physr() which sets master_slave_state isn't called in case +the link is down and other than rtlgen_read_status(), +rtl822x_c45_read_status() doesn't implicitely clear master_slave_state. + +Avoid stale master_slave_state by always setting it to +MASTER_SLAVE_STATE_UNKNOWN in rtl822x_c45_read_status() in case the link +is down. + +Fixes: 081c9c0265c9 ("net: phy: realtek: read duplex and gbit master from PHYSR register") +Signed-off-by: Daniel Golle +Reviewed-by: Michal Swiatkowski +Signed-off-by: David S. Miller +--- + drivers/net/phy/realtek.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -1046,8 +1046,10 @@ static int rtl822x_c45_read_status(struc + if (ret < 0) + return ret; + +- if (!phydev->link) ++ if (!phydev->link) { ++ phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; + return 0; ++ } + + /* Read actual speed from vendor register. */ + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-09-v6.14-net-phy-realtek-always-clear-NBase-T-lpa.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-09-v6.14-net-phy-realtek-always-clear-NBase-T-lpa.patch new file mode 100755 index 0000000..e628bed --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-09-v6.14-net-phy-realtek-always-clear-NBase-T-lpa.patch @@ -0,0 +1,42 @@ +From d3eb58549842c60ed46f37da7f4da969e3d6ecd3 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 15 Jan 2025 14:45:00 +0000 +Subject: [PATCH] net: phy: realtek: always clear NBase-T lpa + +Clear NBase-T link partner advertisement before calling +rtlgen_read_status() to avoid phy_resolve_aneg_linkmode() wrongly +setting speed and duplex. + +This fixes bogus 2.5G/5G/10G link partner advertisement and thus +speed and duplex being set by phy_resolve_aneg_linkmode() due to stale +NBase-T lpa. + +Fixes: 68d5cd09e891 ("net: phy: realtek: change order of calls in C22 read_status()") +Signed-off-by: Daniel Golle +Reviewed-by: Michal Swiatkowski +Signed-off-by: David S. Miller +--- + drivers/net/phy/realtek.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -960,15 +960,15 @@ static int rtl822x_read_status(struct ph + { + int lpadv, ret; + ++ mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); ++ + ret = rtlgen_read_status(phydev); + if (ret < 0) + return ret; + + if (phydev->autoneg == AUTONEG_DISABLE || +- !phydev->autoneg_complete) { +- mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); ++ !phydev->autoneg_complete) + return 0; +- } + + lpadv = phy_read_paged(phydev, 0xa5d, 0x13); + if (lpadv < 0) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-10-v6.14-net-phy-move-realtek-PHY-driver-to-its-own-subdirect.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-10-v6.14-net-phy-move-realtek-PHY-driver-to-its-own-subdirect.patch new file mode 100755 index 0000000..633468f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-10-v6.14-net-phy-move-realtek-PHY-driver-to-its-own-subdirect.patch @@ -0,0 +1,3247 @@ +From 1416a9b2ba710d31954131c06d46f298e340aa2c Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 11 Jan 2025 21:50:19 +0100 +Subject: [PATCH] net: phy: move realtek PHY driver to its own subdirectory + +In preparation of adding a source file with hwmon support, move the +Realtek PHY driver to its own subdirectory and rename realtek.c to +realtek_main.c. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/c566551b-c915-4e34-9b33-129a6ddd6e4c@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/Kconfig | 5 +---- + drivers/net/phy/Makefile | 2 +- + drivers/net/phy/realtek/Kconfig | 5 +++++ + drivers/net/phy/realtek/Makefile | 3 +++ + drivers/net/phy/{realtek.c => realtek/realtek_main.c} | 0 + 5 files changed, 10 insertions(+), 5 deletions(-) + create mode 100644 drivers/net/phy/realtek/Kconfig + create mode 100644 drivers/net/phy/realtek/Makefile + rename drivers/net/phy/{realtek.c => realtek/realtek_main.c} (100%) + +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -343,10 +343,7 @@ config QSEMI_PHY + help + Currently supports the qs6612 + +-config REALTEK_PHY +- tristate "Realtek PHYs" +- help +- Supports the Realtek 821x PHY. ++source "drivers/net/phy/realtek/Kconfig" + + config RENESAS_PHY + tristate "Renesas PHYs" +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -94,7 +94,7 @@ obj-$(CONFIG_NXP_CBTX_PHY) += nxp-cbtx.o + obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o + obj-y += qcom/ + obj-$(CONFIG_QSEMI_PHY) += qsemi.o +-obj-$(CONFIG_REALTEK_PHY) += realtek.o ++obj-$(CONFIG_REALTEK_PHY) += realtek/ + obj-$(CONFIG_RENESAS_PHY) += uPD60620.o + obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o + obj-$(CONFIG_SMSC_PHY) += smsc.o +--- /dev/null ++++ b/drivers/net/phy/realtek/Kconfig +@@ -0,0 +1,5 @@ ++# SPDX-License-Identifier: GPL-2.0-only ++config REALTEK_PHY ++ tristate "Realtek PHYs" ++ help ++ Currently supports RTL821x/RTL822x and fast ethernet PHYs +--- /dev/null ++++ b/drivers/net/phy/realtek/Makefile +@@ -0,0 +1,3 @@ ++# SPDX-License-Identifier: GPL-2.0 ++realtek-y += realtek_main.o ++obj-$(CONFIG_REALTEK_PHY) += realtek.o +--- a/drivers/net/phy/realtek.c ++++ /dev/null +@@ -1,1589 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0+ +-/* drivers/net/phy/realtek.c +- * +- * Driver for Realtek PHYs +- * +- * Author: Johnson Leung +- * +- * Copyright (c) 2004 Freescale Semiconductor, Inc. +- */ +-#include +-#include +-#include +-#include +-#include +-#include +- +-#define RTL821x_PHYSR 0x11 +-#define RTL821x_PHYSR_DUPLEX BIT(13) +-#define RTL821x_PHYSR_SPEED GENMASK(15, 14) +- +-#define RTL821x_INER 0x12 +-#define RTL8211B_INER_INIT 0x6400 +-#define RTL8211E_INER_LINK_STATUS BIT(10) +-#define RTL8211F_INER_LINK_STATUS BIT(4) +- +-#define RTL821x_INSR 0x13 +- +-#define RTL821x_EXT_PAGE_SELECT 0x1e +-#define RTL821x_PAGE_SELECT 0x1f +- +-#define RTL8211F_PHYCR1 0x18 +-#define RTL8211F_PHYCR2 0x19 +-#define RTL8211F_INSR 0x1d +- +-#define RTL8211F_LEDCR 0x10 +-#define RTL8211F_LEDCR_MODE BIT(15) +-#define RTL8211F_LEDCR_ACT_TXRX BIT(4) +-#define RTL8211F_LEDCR_LINK_1000 BIT(3) +-#define RTL8211F_LEDCR_LINK_100 BIT(1) +-#define RTL8211F_LEDCR_LINK_10 BIT(0) +-#define RTL8211F_LEDCR_MASK GENMASK(4, 0) +-#define RTL8211F_LEDCR_SHIFT 5 +- +-#define RTL8211F_TX_DELAY BIT(8) +-#define RTL8211F_RX_DELAY BIT(3) +- +-#define RTL8211F_ALDPS_PLL_OFF BIT(1) +-#define RTL8211F_ALDPS_ENABLE BIT(2) +-#define RTL8211F_ALDPS_XTAL_OFF BIT(12) +- +-#define RTL8211E_CTRL_DELAY BIT(13) +-#define RTL8211E_TX_DELAY BIT(12) +-#define RTL8211E_RX_DELAY BIT(11) +- +-#define RTL8211F_CLKOUT_EN BIT(0) +- +-#define RTL8201F_ISR 0x1e +-#define RTL8201F_ISR_ANERR BIT(15) +-#define RTL8201F_ISR_DUPLEX BIT(13) +-#define RTL8201F_ISR_LINK BIT(11) +-#define RTL8201F_ISR_MASK (RTL8201F_ISR_ANERR | \ +- RTL8201F_ISR_DUPLEX | \ +- RTL8201F_ISR_LINK) +-#define RTL8201F_IER 0x13 +- +-#define RTL822X_VND1_SERDES_OPTION 0x697a +-#define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0) +-#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII 0 +-#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX 2 +- +-#define RTL822X_VND1_SERDES_CTRL3 0x7580 +-#define RTL822X_VND1_SERDES_CTRL3_MODE_MASK GENMASK(5, 0) +-#define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 +-#define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 +- +-/* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 +- * is set, they cannot be accessed by C45-over-C22. +- */ +-#define RTL822X_VND2_GBCR 0xa412 +- +-#define RTL822X_VND2_GANLPAR 0xa414 +- +-#define RTL8366RB_POWER_SAVE 0x15 +-#define RTL8366RB_POWER_SAVE_ON BIT(12) +- +-#define RTL9000A_GINMR 0x14 +-#define RTL9000A_GINMR_LINK_STATUS BIT(4) +- +-#define RTL_VND2_PHYSR 0xa434 +-#define RTL_VND2_PHYSR_DUPLEX BIT(3) +-#define RTL_VND2_PHYSR_SPEEDL GENMASK(5, 4) +-#define RTL_VND2_PHYSR_SPEEDH GENMASK(10, 9) +-#define RTL_VND2_PHYSR_MASTER BIT(11) +-#define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR_SPEEDH) +- +-#define RTL_GENERIC_PHYID 0x001cc800 +-#define RTL_8211FVD_PHYID 0x001cc878 +-#define RTL_8221B 0x001cc840 +-#define RTL_8221B_VB_CG 0x001cc849 +-#define RTL_8221B_VN_CG 0x001cc84a +-#define RTL_8251B 0x001cc862 +- +-#define RTL8211F_LED_COUNT 3 +- +-MODULE_DESCRIPTION("Realtek PHY driver"); +-MODULE_AUTHOR("Johnson Leung"); +-MODULE_LICENSE("GPL"); +- +-struct rtl821x_priv { +- u16 phycr1; +- u16 phycr2; +- bool has_phycr2; +- struct clk *clk; +-}; +- +-static int rtl821x_read_page(struct phy_device *phydev) +-{ +- return __phy_read(phydev, RTL821x_PAGE_SELECT); +-} +- +-static int rtl821x_write_page(struct phy_device *phydev, int page) +-{ +- return __phy_write(phydev, RTL821x_PAGE_SELECT, page); +-} +- +-static int rtl821x_probe(struct phy_device *phydev) +-{ +- struct device *dev = &phydev->mdio.dev; +- struct rtl821x_priv *priv; +- u32 phy_id = phydev->drv->phy_id; +- int ret; +- +- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); +- if (!priv) +- return -ENOMEM; +- +- priv->clk = devm_clk_get_optional_enabled(dev, NULL); +- if (IS_ERR(priv->clk)) +- return dev_err_probe(dev, PTR_ERR(priv->clk), +- "failed to get phy clock\n"); +- +- ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); +- if (ret < 0) +- return ret; +- +- priv->phycr1 = ret & (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF); +- if (of_property_read_bool(dev->of_node, "realtek,aldps-enable")) +- priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF; +- +- priv->has_phycr2 = !(phy_id == RTL_8211FVD_PHYID); +- if (priv->has_phycr2) { +- ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2); +- if (ret < 0) +- return ret; +- +- priv->phycr2 = ret & RTL8211F_CLKOUT_EN; +- if (of_property_read_bool(dev->of_node, "realtek,clkout-disable")) +- priv->phycr2 &= ~RTL8211F_CLKOUT_EN; +- } +- +- phydev->priv = priv; +- +- return 0; +-} +- +-static int rtl8201_ack_interrupt(struct phy_device *phydev) +-{ +- int err; +- +- err = phy_read(phydev, RTL8201F_ISR); +- +- return (err < 0) ? err : 0; +-} +- +-static int rtl821x_ack_interrupt(struct phy_device *phydev) +-{ +- int err; +- +- err = phy_read(phydev, RTL821x_INSR); +- +- return (err < 0) ? err : 0; +-} +- +-static int rtl8211f_ack_interrupt(struct phy_device *phydev) +-{ +- int err; +- +- err = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); +- +- return (err < 0) ? err : 0; +-} +- +-static int rtl8201_config_intr(struct phy_device *phydev) +-{ +- u16 val; +- int err; +- +- if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { +- err = rtl8201_ack_interrupt(phydev); +- if (err) +- return err; +- +- val = BIT(13) | BIT(12) | BIT(11); +- err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); +- } else { +- val = 0; +- err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); +- if (err) +- return err; +- +- err = rtl8201_ack_interrupt(phydev); +- } +- +- return err; +-} +- +-static int rtl8211b_config_intr(struct phy_device *phydev) +-{ +- int err; +- +- if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { +- err = rtl821x_ack_interrupt(phydev); +- if (err) +- return err; +- +- err = phy_write(phydev, RTL821x_INER, +- RTL8211B_INER_INIT); +- } else { +- err = phy_write(phydev, RTL821x_INER, 0); +- if (err) +- return err; +- +- err = rtl821x_ack_interrupt(phydev); +- } +- +- return err; +-} +- +-static int rtl8211e_config_intr(struct phy_device *phydev) +-{ +- int err; +- +- if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { +- err = rtl821x_ack_interrupt(phydev); +- if (err) +- return err; +- +- err = phy_write(phydev, RTL821x_INER, +- RTL8211E_INER_LINK_STATUS); +- } else { +- err = phy_write(phydev, RTL821x_INER, 0); +- if (err) +- return err; +- +- err = rtl821x_ack_interrupt(phydev); +- } +- +- return err; +-} +- +-static int rtl8211f_config_intr(struct phy_device *phydev) +-{ +- u16 val; +- int err; +- +- if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { +- err = rtl8211f_ack_interrupt(phydev); +- if (err) +- return err; +- +- val = RTL8211F_INER_LINK_STATUS; +- err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); +- } else { +- val = 0; +- err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); +- if (err) +- return err; +- +- err = rtl8211f_ack_interrupt(phydev); +- } +- +- return err; +-} +- +-static irqreturn_t rtl8201_handle_interrupt(struct phy_device *phydev) +-{ +- int irq_status; +- +- irq_status = phy_read(phydev, RTL8201F_ISR); +- if (irq_status < 0) { +- phy_error(phydev); +- return IRQ_NONE; +- } +- +- if (!(irq_status & RTL8201F_ISR_MASK)) +- return IRQ_NONE; +- +- phy_trigger_machine(phydev); +- +- return IRQ_HANDLED; +-} +- +-static irqreturn_t rtl821x_handle_interrupt(struct phy_device *phydev) +-{ +- int irq_status, irq_enabled; +- +- irq_status = phy_read(phydev, RTL821x_INSR); +- if (irq_status < 0) { +- phy_error(phydev); +- return IRQ_NONE; +- } +- +- irq_enabled = phy_read(phydev, RTL821x_INER); +- if (irq_enabled < 0) { +- phy_error(phydev); +- return IRQ_NONE; +- } +- +- if (!(irq_status & irq_enabled)) +- return IRQ_NONE; +- +- phy_trigger_machine(phydev); +- +- return IRQ_HANDLED; +-} +- +-static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev) +-{ +- int irq_status; +- +- irq_status = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); +- if (irq_status < 0) { +- phy_error(phydev); +- return IRQ_NONE; +- } +- +- if (!(irq_status & RTL8211F_INER_LINK_STATUS)) +- return IRQ_NONE; +- +- phy_trigger_machine(phydev); +- +- return IRQ_HANDLED; +-} +- +-static int rtl8211_config_aneg(struct phy_device *phydev) +-{ +- int ret; +- +- ret = genphy_config_aneg(phydev); +- if (ret < 0) +- return ret; +- +- /* Quirk was copied from vendor driver. Unfortunately it includes no +- * description of the magic numbers. +- */ +- if (phydev->speed == SPEED_100 && phydev->autoneg == AUTONEG_DISABLE) { +- phy_write(phydev, 0x17, 0x2138); +- phy_write(phydev, 0x0e, 0x0260); +- } else { +- phy_write(phydev, 0x17, 0x2108); +- phy_write(phydev, 0x0e, 0x0000); +- } +- +- return 0; +-} +- +-static int rtl8211c_config_init(struct phy_device *phydev) +-{ +- /* RTL8211C has an issue when operating in Gigabit slave mode */ +- return phy_set_bits(phydev, MII_CTRL1000, +- CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); +-} +- +-static int rtl8211f_config_init(struct phy_device *phydev) +-{ +- struct rtl821x_priv *priv = phydev->priv; +- struct device *dev = &phydev->mdio.dev; +- u16 val_txdly, val_rxdly; +- int ret; +- +- ret = phy_modify_paged_changed(phydev, 0xa43, RTL8211F_PHYCR1, +- RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF, +- priv->phycr1); +- if (ret < 0) { +- dev_err(dev, "aldps mode configuration failed: %pe\n", +- ERR_PTR(ret)); +- return ret; +- } +- +- switch (phydev->interface) { +- case PHY_INTERFACE_MODE_RGMII: +- val_txdly = 0; +- val_rxdly = 0; +- break; +- +- case PHY_INTERFACE_MODE_RGMII_RXID: +- val_txdly = 0; +- val_rxdly = RTL8211F_RX_DELAY; +- break; +- +- case PHY_INTERFACE_MODE_RGMII_TXID: +- val_txdly = RTL8211F_TX_DELAY; +- val_rxdly = 0; +- break; +- +- case PHY_INTERFACE_MODE_RGMII_ID: +- val_txdly = RTL8211F_TX_DELAY; +- val_rxdly = RTL8211F_RX_DELAY; +- break; +- +- default: /* the rest of the modes imply leaving delay as is. */ +- return 0; +- } +- +- ret = phy_modify_paged_changed(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, +- val_txdly); +- if (ret < 0) { +- dev_err(dev, "Failed to update the TX delay register\n"); +- return ret; +- } else if (ret) { +- dev_dbg(dev, +- "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n", +- val_txdly ? "Enabling" : "Disabling"); +- } else { +- dev_dbg(dev, +- "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n", +- val_txdly ? "enabled" : "disabled"); +- } +- +- ret = phy_modify_paged_changed(phydev, 0xd08, 0x15, RTL8211F_RX_DELAY, +- val_rxdly); +- if (ret < 0) { +- dev_err(dev, "Failed to update the RX delay register\n"); +- return ret; +- } else if (ret) { +- dev_dbg(dev, +- "%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n", +- val_rxdly ? "Enabling" : "Disabling"); +- } else { +- dev_dbg(dev, +- "2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n", +- val_rxdly ? "enabled" : "disabled"); +- } +- +- if (priv->has_phycr2) { +- ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, +- RTL8211F_CLKOUT_EN, priv->phycr2); +- if (ret < 0) { +- dev_err(dev, "clkout configuration failed: %pe\n", +- ERR_PTR(ret)); +- return ret; +- } +- +- return genphy_soft_reset(phydev); +- } +- +- return 0; +-} +- +-static int rtl821x_suspend(struct phy_device *phydev) +-{ +- struct rtl821x_priv *priv = phydev->priv; +- int ret = 0; +- +- if (!phydev->wol_enabled) { +- ret = genphy_suspend(phydev); +- +- if (ret) +- return ret; +- +- clk_disable_unprepare(priv->clk); +- } +- +- return ret; +-} +- +-static int rtl821x_resume(struct phy_device *phydev) +-{ +- struct rtl821x_priv *priv = phydev->priv; +- int ret; +- +- if (!phydev->wol_enabled) +- clk_prepare_enable(priv->clk); +- +- ret = genphy_resume(phydev); +- if (ret < 0) +- return ret; +- +- msleep(20); +- +- return 0; +-} +- +-static int rtl8211f_led_hw_is_supported(struct phy_device *phydev, u8 index, +- unsigned long rules) +-{ +- const unsigned long mask = BIT(TRIGGER_NETDEV_LINK_10) | +- BIT(TRIGGER_NETDEV_LINK_100) | +- BIT(TRIGGER_NETDEV_LINK_1000) | +- BIT(TRIGGER_NETDEV_RX) | +- BIT(TRIGGER_NETDEV_TX); +- +- /* The RTL8211F PHY supports these LED settings on up to three LEDs: +- * - Link: Configurable subset of 10/100/1000 link rates +- * - Active: Blink on activity, RX or TX is not differentiated +- * The Active option has two modes, A and B: +- * - A: Link and Active indication at configurable, but matching, +- * subset of 10/100/1000 link rates +- * - B: Link indication at configurable subset of 10/100/1000 link +- * rates and Active indication always at all three 10+100+1000 +- * link rates. +- * This code currently uses mode B only. +- */ +- +- if (index >= RTL8211F_LED_COUNT) +- return -EINVAL; +- +- /* Filter out any other unsupported triggers. */ +- if (rules & ~mask) +- return -EOPNOTSUPP; +- +- /* RX and TX are not differentiated, either both are set or not set. */ +- if (!(rules & BIT(TRIGGER_NETDEV_RX)) ^ !(rules & BIT(TRIGGER_NETDEV_TX))) +- return -EOPNOTSUPP; +- +- return 0; +-} +- +-static int rtl8211f_led_hw_control_get(struct phy_device *phydev, u8 index, +- unsigned long *rules) +-{ +- int val; +- +- if (index >= RTL8211F_LED_COUNT) +- return -EINVAL; +- +- val = phy_read_paged(phydev, 0xd04, RTL8211F_LEDCR); +- if (val < 0) +- return val; +- +- val >>= RTL8211F_LEDCR_SHIFT * index; +- val &= RTL8211F_LEDCR_MASK; +- +- if (val & RTL8211F_LEDCR_LINK_10) +- set_bit(TRIGGER_NETDEV_LINK_10, rules); +- +- if (val & RTL8211F_LEDCR_LINK_100) +- set_bit(TRIGGER_NETDEV_LINK_100, rules); +- +- if (val & RTL8211F_LEDCR_LINK_1000) +- set_bit(TRIGGER_NETDEV_LINK_1000, rules); +- +- if (val & RTL8211F_LEDCR_ACT_TXRX) { +- set_bit(TRIGGER_NETDEV_RX, rules); +- set_bit(TRIGGER_NETDEV_TX, rules); +- } +- +- return 0; +-} +- +-static int rtl8211f_led_hw_control_set(struct phy_device *phydev, u8 index, +- unsigned long rules) +-{ +- const u16 mask = RTL8211F_LEDCR_MASK << (RTL8211F_LEDCR_SHIFT * index); +- u16 reg = 0; +- +- if (index >= RTL8211F_LED_COUNT) +- return -EINVAL; +- +- if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) +- reg |= RTL8211F_LEDCR_LINK_10; +- +- if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) +- reg |= RTL8211F_LEDCR_LINK_100; +- +- if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) +- reg |= RTL8211F_LEDCR_LINK_1000; +- +- if (test_bit(TRIGGER_NETDEV_RX, &rules) || +- test_bit(TRIGGER_NETDEV_TX, &rules)) { +- reg |= RTL8211F_LEDCR_ACT_TXRX; +- } +- +- reg <<= RTL8211F_LEDCR_SHIFT * index; +- reg |= RTL8211F_LEDCR_MODE; /* Mode B */ +- +- return phy_modify_paged(phydev, 0xd04, RTL8211F_LEDCR, mask, reg); +-} +- +-static int rtl8211e_config_init(struct phy_device *phydev) +-{ +- int ret = 0, oldpage; +- u16 val; +- +- /* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */ +- switch (phydev->interface) { +- case PHY_INTERFACE_MODE_RGMII: +- val = RTL8211E_CTRL_DELAY | 0; +- break; +- case PHY_INTERFACE_MODE_RGMII_ID: +- val = RTL8211E_CTRL_DELAY | RTL8211E_TX_DELAY | RTL8211E_RX_DELAY; +- break; +- case PHY_INTERFACE_MODE_RGMII_RXID: +- val = RTL8211E_CTRL_DELAY | RTL8211E_RX_DELAY; +- break; +- case PHY_INTERFACE_MODE_RGMII_TXID: +- val = RTL8211E_CTRL_DELAY | RTL8211E_TX_DELAY; +- break; +- default: /* the rest of the modes imply leaving delays as is. */ +- return 0; +- } +- +- /* According to a sample driver there is a 0x1c config register on the +- * 0xa4 extension page (0x7) layout. It can be used to disable/enable +- * the RX/TX delays otherwise controlled by RXDLY/TXDLY pins. +- * The configuration register definition: +- * 14 = reserved +- * 13 = Force Tx RX Delay controlled by bit12 bit11, +- * 12 = RX Delay, 11 = TX Delay +- * 10:0 = Test && debug settings reserved by realtek +- */ +- oldpage = phy_select_page(phydev, 0x7); +- if (oldpage < 0) +- goto err_restore_page; +- +- ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0xa4); +- if (ret) +- goto err_restore_page; +- +- ret = __phy_modify(phydev, 0x1c, RTL8211E_CTRL_DELAY +- | RTL8211E_TX_DELAY | RTL8211E_RX_DELAY, +- val); +- +-err_restore_page: +- return phy_restore_page(phydev, oldpage, ret); +-} +- +-static int rtl8211b_suspend(struct phy_device *phydev) +-{ +- phy_write(phydev, MII_MMD_DATA, BIT(9)); +- +- return genphy_suspend(phydev); +-} +- +-static int rtl8211b_resume(struct phy_device *phydev) +-{ +- phy_write(phydev, MII_MMD_DATA, 0); +- +- return genphy_resume(phydev); +-} +- +-static int rtl8366rb_config_init(struct phy_device *phydev) +-{ +- int ret; +- +- ret = phy_set_bits(phydev, RTL8366RB_POWER_SAVE, +- RTL8366RB_POWER_SAVE_ON); +- if (ret) { +- dev_err(&phydev->mdio.dev, +- "error enabling power management\n"); +- } +- +- return ret; +-} +- +-/* get actual speed to cover the downshift case */ +-static void rtlgen_decode_physr(struct phy_device *phydev, int val) +-{ +- /* bit 3 +- * 0: Half Duplex +- * 1: Full Duplex +- */ +- if (val & RTL_VND2_PHYSR_DUPLEX) +- phydev->duplex = DUPLEX_FULL; +- else +- phydev->duplex = DUPLEX_HALF; +- +- switch (val & RTL_VND2_PHYSR_SPEED_MASK) { +- case 0x0000: +- phydev->speed = SPEED_10; +- break; +- case 0x0010: +- phydev->speed = SPEED_100; +- break; +- case 0x0020: +- phydev->speed = SPEED_1000; +- break; +- case 0x0200: +- phydev->speed = SPEED_10000; +- break; +- case 0x0210: +- phydev->speed = SPEED_2500; +- break; +- case 0x0220: +- phydev->speed = SPEED_5000; +- break; +- default: +- break; +- } +- +- /* bit 11 +- * 0: Slave Mode +- * 1: Master Mode +- */ +- if (phydev->speed >= 1000) { +- if (val & RTL_VND2_PHYSR_MASTER) +- phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; +- else +- phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; +- } else { +- phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; +- } +-} +- +-static int rtlgen_read_status(struct phy_device *phydev) +-{ +- int ret, val; +- +- ret = genphy_read_status(phydev); +- if (ret < 0) +- return ret; +- +- if (!phydev->link) +- return 0; +- +- val = phy_read_paged(phydev, 0xa43, 0x12); +- if (val < 0) +- return val; +- +- rtlgen_decode_physr(phydev, val); +- +- return 0; +-} +- +-static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) +-{ +- int ret; +- +- if (devnum == MDIO_MMD_VEND2) { +- rtl821x_write_page(phydev, regnum >> 4); +- ret = __phy_read(phydev, 0x10 + ((regnum & 0xf) >> 1)); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) { +- rtl821x_write_page(phydev, 0xa5c); +- ret = __phy_read(phydev, 0x12); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { +- rtl821x_write_page(phydev, 0xa5d); +- ret = __phy_read(phydev, 0x10); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE) { +- rtl821x_write_page(phydev, 0xa5d); +- ret = __phy_read(phydev, 0x11); +- rtl821x_write_page(phydev, 0); +- } else { +- ret = -EOPNOTSUPP; +- } +- +- return ret; +-} +- +-static int rtlgen_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, +- u16 val) +-{ +- int ret; +- +- if (devnum == MDIO_MMD_VEND2) { +- rtl821x_write_page(phydev, regnum >> 4); +- ret = __phy_write(phydev, 0x10 + ((regnum & 0xf) >> 1), val); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { +- rtl821x_write_page(phydev, 0xa5d); +- ret = __phy_write(phydev, 0x10, val); +- rtl821x_write_page(phydev, 0); +- } else { +- ret = -EOPNOTSUPP; +- } +- +- return ret; +-} +- +-static int rtl822x_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) +-{ +- int ret = rtlgen_read_mmd(phydev, devnum, regnum); +- +- if (ret != -EOPNOTSUPP) +- return ret; +- +- if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE2) { +- rtl821x_write_page(phydev, 0xa6e); +- ret = __phy_read(phydev, 0x16); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) { +- rtl821x_write_page(phydev, 0xa6d); +- ret = __phy_read(phydev, 0x12); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE2) { +- rtl821x_write_page(phydev, 0xa6d); +- ret = __phy_read(phydev, 0x10); +- rtl821x_write_page(phydev, 0); +- } +- +- return ret; +-} +- +-static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, +- u16 val) +-{ +- int ret = rtlgen_write_mmd(phydev, devnum, regnum, val); +- +- if (ret != -EOPNOTSUPP) +- return ret; +- +- if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) { +- rtl821x_write_page(phydev, 0xa6d); +- ret = __phy_write(phydev, 0x12, val); +- rtl821x_write_page(phydev, 0); +- } +- +- return ret; +-} +- +-static int rtl822xb_config_init(struct phy_device *phydev) +-{ +- bool has_2500, has_sgmii; +- u16 mode; +- int ret; +- +- has_2500 = test_bit(PHY_INTERFACE_MODE_2500BASEX, +- phydev->host_interfaces) || +- phydev->interface == PHY_INTERFACE_MODE_2500BASEX; +- +- has_sgmii = test_bit(PHY_INTERFACE_MODE_SGMII, +- phydev->host_interfaces) || +- phydev->interface == PHY_INTERFACE_MODE_SGMII; +- +- /* fill in possible interfaces */ +- __assign_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces, +- has_2500); +- __assign_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces, +- has_sgmii); +- +- if (!has_2500 && !has_sgmii) +- return 0; +- +- /* determine SerDes option mode */ +- if (has_2500 && !has_sgmii) { +- mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX; +- phydev->rate_matching = RATE_MATCH_PAUSE; +- } else { +- mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII; +- phydev->rate_matching = RATE_MATCH_NONE; +- } +- +- /* the following sequence with magic numbers sets up the SerDes +- * option mode +- */ +- ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0); +- if (ret < 0) +- return ret; +- +- ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1, +- RTL822X_VND1_SERDES_OPTION, +- RTL822X_VND1_SERDES_OPTION_MODE_MASK, +- mode); +- if (ret < 0) +- return ret; +- +- ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6a04, 0x0503); +- if (ret < 0) +- return ret; +- +- ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f10, 0xd455); +- if (ret < 0) +- return ret; +- +- return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); +-} +- +-static int rtl822xb_get_rate_matching(struct phy_device *phydev, +- phy_interface_t iface) +-{ +- int val; +- +- /* Only rate matching at 2500base-x */ +- if (iface != PHY_INTERFACE_MODE_2500BASEX) +- return RATE_MATCH_NONE; +- +- val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_OPTION); +- if (val < 0) +- return val; +- +- if ((val & RTL822X_VND1_SERDES_OPTION_MODE_MASK) == +- RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX) +- return RATE_MATCH_PAUSE; +- +- /* RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII */ +- return RATE_MATCH_NONE; +-} +- +-static int rtl822x_get_features(struct phy_device *phydev) +-{ +- int val; +- +- val = phy_read_paged(phydev, 0xa61, 0x13); +- if (val < 0) +- return val; +- +- linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, +- phydev->supported, val & MDIO_PMA_SPEED_2_5G); +- linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, +- phydev->supported, val & MDIO_PMA_SPEED_5G); +- linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, +- phydev->supported, val & MDIO_SPEED_10G); +- +- return genphy_read_abilities(phydev); +-} +- +-static int rtl822x_config_aneg(struct phy_device *phydev) +-{ +- int ret = 0; +- +- if (phydev->autoneg == AUTONEG_ENABLE) { +- u16 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); +- +- ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, +- MDIO_AN_10GBT_CTRL_ADV2_5G | +- MDIO_AN_10GBT_CTRL_ADV5G, +- adv); +- if (ret < 0) +- return ret; +- } +- +- return __genphy_config_aneg(phydev, ret); +-} +- +-static void rtl822xb_update_interface(struct phy_device *phydev) +-{ +- int val; +- +- if (!phydev->link) +- return; +- +- /* Change interface according to serdes mode */ +- val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_CTRL3); +- if (val < 0) +- return; +- +- switch (val & RTL822X_VND1_SERDES_CTRL3_MODE_MASK) { +- case RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX: +- phydev->interface = PHY_INTERFACE_MODE_2500BASEX; +- break; +- case RTL822X_VND1_SERDES_CTRL3_MODE_SGMII: +- phydev->interface = PHY_INTERFACE_MODE_SGMII; +- break; +- } +-} +- +-static int rtl822x_read_status(struct phy_device *phydev) +-{ +- int lpadv, ret; +- +- mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); +- +- ret = rtlgen_read_status(phydev); +- if (ret < 0) +- return ret; +- +- if (phydev->autoneg == AUTONEG_DISABLE || +- !phydev->autoneg_complete) +- return 0; +- +- lpadv = phy_read_paged(phydev, 0xa5d, 0x13); +- if (lpadv < 0) +- return lpadv; +- +- mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, lpadv); +- +- return 0; +-} +- +-static int rtl822xb_read_status(struct phy_device *phydev) +-{ +- int ret; +- +- ret = rtl822x_read_status(phydev); +- if (ret < 0) +- return ret; +- +- rtl822xb_update_interface(phydev); +- +- return 0; +-} +- +-static int rtl822x_c45_get_features(struct phy_device *phydev) +-{ +- linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, +- phydev->supported); +- +- return genphy_c45_pma_read_abilities(phydev); +-} +- +-static int rtl822x_c45_config_aneg(struct phy_device *phydev) +-{ +- bool changed = false; +- int ret, val; +- +- if (phydev->autoneg == AUTONEG_DISABLE) +- return genphy_c45_pma_setup_forced(phydev); +- +- ret = genphy_c45_an_config_aneg(phydev); +- if (ret < 0) +- return ret; +- if (ret > 0) +- changed = true; +- +- val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); +- +- /* Vendor register as C45 has no standardized support for 1000BaseT */ +- ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR, +- ADVERTISE_1000FULL, val); +- if (ret < 0) +- return ret; +- if (ret > 0) +- changed = true; +- +- return genphy_c45_check_and_restart_aneg(phydev, changed); +-} +- +-static int rtl822x_c45_read_status(struct phy_device *phydev) +-{ +- int ret, val; +- +- /* Vendor register as C45 has no standardized support for 1000BaseT */ +- if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) { +- val = phy_read_mmd(phydev, MDIO_MMD_VEND2, +- RTL822X_VND2_GANLPAR); +- if (val < 0) +- return val; +- } else { +- val = 0; +- } +- mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); +- +- ret = genphy_c45_read_status(phydev); +- if (ret < 0) +- return ret; +- +- if (!phydev->link) { +- phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; +- return 0; +- } +- +- /* Read actual speed from vendor register. */ +- val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR); +- if (val < 0) +- return val; +- +- rtlgen_decode_physr(phydev, val); +- +- return 0; +-} +- +-static int rtl822xb_c45_read_status(struct phy_device *phydev) +-{ +- int ret; +- +- ret = rtl822x_c45_read_status(phydev); +- if (ret < 0) +- return ret; +- +- rtl822xb_update_interface(phydev); +- +- return 0; +-} +- +-static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) +-{ +- int val; +- +- phy_write(phydev, RTL821x_PAGE_SELECT, 0xa61); +- val = phy_read(phydev, 0x13); +- phy_write(phydev, RTL821x_PAGE_SELECT, 0); +- +- return val >= 0 && val & MDIO_PMA_SPEED_2_5G; +-} +- +-/* On internal PHY's MMD reads over C22 always return 0. +- * Check a MMD register which is known to be non-zero. +- */ +-static bool rtlgen_supports_mmd(struct phy_device *phydev) +-{ +- int val; +- +- phy_lock_mdio_bus(phydev); +- __phy_write(phydev, MII_MMD_CTRL, MDIO_MMD_PCS); +- __phy_write(phydev, MII_MMD_DATA, MDIO_PCS_EEE_ABLE); +- __phy_write(phydev, MII_MMD_CTRL, MDIO_MMD_PCS | MII_MMD_CTRL_NOINCR); +- val = __phy_read(phydev, MII_MMD_DATA); +- phy_unlock_mdio_bus(phydev); +- +- return val > 0; +-} +- +-static int rtlgen_match_phy_device(struct phy_device *phydev) +-{ +- return phydev->phy_id == RTL_GENERIC_PHYID && +- !rtlgen_supports_2_5gbps(phydev); +-} +- +-static int rtl8226_match_phy_device(struct phy_device *phydev) +-{ +- return phydev->phy_id == RTL_GENERIC_PHYID && +- rtlgen_supports_2_5gbps(phydev) && +- rtlgen_supports_mmd(phydev); +-} +- +-static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id, +- bool is_c45) +-{ +- if (phydev->is_c45) +- return is_c45 && (id == phydev->c45_ids.device_ids[1]); +- else +- return !is_c45 && (id == phydev->phy_id); +-} +- +-static int rtl8221b_match_phy_device(struct phy_device *phydev) +-{ +- return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev); +-} +- +-static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); +-} +- +-static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); +-} +- +-static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false); +-} +- +-static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true); +-} +- +-static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev) +-{ +- if (phydev->is_c45) +- return false; +- +- switch (phydev->phy_id) { +- case RTL_GENERIC_PHYID: +- case RTL_8221B: +- case RTL_8251B: +- case 0x001cc841: +- break; +- default: +- return false; +- } +- +- return rtlgen_supports_2_5gbps(phydev) && !rtlgen_supports_mmd(phydev); +-} +- +-static int rtl8251b_c45_match_phy_device(struct phy_device *phydev) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8251B, true); +-} +- +-static int rtlgen_resume(struct phy_device *phydev) +-{ +- int ret = genphy_resume(phydev); +- +- /* Internal PHY's from RTL8168h up may not be instantly ready */ +- msleep(20); +- +- return ret; +-} +- +-static int rtlgen_c45_resume(struct phy_device *phydev) +-{ +- int ret = genphy_c45_pma_resume(phydev); +- +- msleep(20); +- +- return ret; +-} +- +-static int rtl9000a_config_init(struct phy_device *phydev) +-{ +- phydev->autoneg = AUTONEG_DISABLE; +- phydev->speed = SPEED_100; +- phydev->duplex = DUPLEX_FULL; +- +- return 0; +-} +- +-static int rtl9000a_config_aneg(struct phy_device *phydev) +-{ +- int ret; +- u16 ctl = 0; +- +- switch (phydev->master_slave_set) { +- case MASTER_SLAVE_CFG_MASTER_FORCE: +- ctl |= CTL1000_AS_MASTER; +- break; +- case MASTER_SLAVE_CFG_SLAVE_FORCE: +- break; +- case MASTER_SLAVE_CFG_UNKNOWN: +- case MASTER_SLAVE_CFG_UNSUPPORTED: +- return 0; +- default: +- phydev_warn(phydev, "Unsupported Master/Slave mode\n"); +- return -EOPNOTSUPP; +- } +- +- ret = phy_modify_changed(phydev, MII_CTRL1000, CTL1000_AS_MASTER, ctl); +- if (ret == 1) +- ret = genphy_soft_reset(phydev); +- +- return ret; +-} +- +-static int rtl9000a_read_status(struct phy_device *phydev) +-{ +- int ret; +- +- phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; +- phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; +- +- ret = genphy_update_link(phydev); +- if (ret) +- return ret; +- +- ret = phy_read(phydev, MII_CTRL1000); +- if (ret < 0) +- return ret; +- if (ret & CTL1000_AS_MASTER) +- phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; +- else +- phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; +- +- ret = phy_read(phydev, MII_STAT1000); +- if (ret < 0) +- return ret; +- if (ret & LPA_1000MSRES) +- phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; +- else +- phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; +- +- return 0; +-} +- +-static int rtl9000a_ack_interrupt(struct phy_device *phydev) +-{ +- int err; +- +- err = phy_read(phydev, RTL8211F_INSR); +- +- return (err < 0) ? err : 0; +-} +- +-static int rtl9000a_config_intr(struct phy_device *phydev) +-{ +- u16 val; +- int err; +- +- if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { +- err = rtl9000a_ack_interrupt(phydev); +- if (err) +- return err; +- +- val = (u16)~RTL9000A_GINMR_LINK_STATUS; +- err = phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); +- } else { +- val = ~0; +- err = phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); +- if (err) +- return err; +- +- err = rtl9000a_ack_interrupt(phydev); +- } +- +- return phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); +-} +- +-static irqreturn_t rtl9000a_handle_interrupt(struct phy_device *phydev) +-{ +- int irq_status; +- +- irq_status = phy_read(phydev, RTL8211F_INSR); +- if (irq_status < 0) { +- phy_error(phydev); +- return IRQ_NONE; +- } +- +- if (!(irq_status & RTL8211F_INER_LINK_STATUS)) +- return IRQ_NONE; +- +- phy_trigger_machine(phydev); +- +- return IRQ_HANDLED; +-} +- +-static struct phy_driver realtek_drvs[] = { +- { +- PHY_ID_MATCH_EXACT(0x00008201), +- .name = "RTL8201CP Ethernet", +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc816), +- .name = "RTL8201F Fast Ethernet", +- .config_intr = &rtl8201_config_intr, +- .handle_interrupt = rtl8201_handle_interrupt, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_MODEL(0x001cc880), +- .name = "RTL8208 Fast Ethernet", +- .read_mmd = genphy_read_mmd_unsupported, +- .write_mmd = genphy_write_mmd_unsupported, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc910), +- .name = "RTL8211 Gigabit Ethernet", +- .config_aneg = rtl8211_config_aneg, +- .read_mmd = &genphy_read_mmd_unsupported, +- .write_mmd = &genphy_write_mmd_unsupported, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc912), +- .name = "RTL8211B Gigabit Ethernet", +- .config_intr = &rtl8211b_config_intr, +- .handle_interrupt = rtl821x_handle_interrupt, +- .read_mmd = &genphy_read_mmd_unsupported, +- .write_mmd = &genphy_write_mmd_unsupported, +- .suspend = rtl8211b_suspend, +- .resume = rtl8211b_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc913), +- .name = "RTL8211C Gigabit Ethernet", +- .config_init = rtl8211c_config_init, +- .read_mmd = &genphy_read_mmd_unsupported, +- .write_mmd = &genphy_write_mmd_unsupported, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc914), +- .name = "RTL8211DN Gigabit Ethernet", +- .config_intr = rtl8211e_config_intr, +- .handle_interrupt = rtl821x_handle_interrupt, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc915), +- .name = "RTL8211E Gigabit Ethernet", +- .config_init = &rtl8211e_config_init, +- .config_intr = &rtl8211e_config_intr, +- .handle_interrupt = rtl821x_handle_interrupt, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc916), +- .name = "RTL8211F Gigabit Ethernet", +- .probe = rtl821x_probe, +- .config_init = &rtl8211f_config_init, +- .read_status = rtlgen_read_status, +- .config_intr = &rtl8211f_config_intr, +- .handle_interrupt = rtl8211f_handle_interrupt, +- .suspend = rtl821x_suspend, +- .resume = rtl821x_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- .flags = PHY_ALWAYS_CALL_SUSPEND, +- .led_hw_is_supported = rtl8211f_led_hw_is_supported, +- .led_hw_control_get = rtl8211f_led_hw_control_get, +- .led_hw_control_set = rtl8211f_led_hw_control_set, +- }, { +- PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID), +- .name = "RTL8211F-VD Gigabit Ethernet", +- .probe = rtl821x_probe, +- .config_init = &rtl8211f_config_init, +- .read_status = rtlgen_read_status, +- .config_intr = &rtl8211f_config_intr, +- .handle_interrupt = rtl8211f_handle_interrupt, +- .suspend = rtl821x_suspend, +- .resume = rtl821x_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- .flags = PHY_ALWAYS_CALL_SUSPEND, +- }, { +- .name = "Generic FE-GE Realtek PHY", +- .match_phy_device = rtlgen_match_phy_device, +- .read_status = rtlgen_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- .read_mmd = rtlgen_read_mmd, +- .write_mmd = rtlgen_write_mmd, +- }, { +- .name = "RTL8226 2.5Gbps PHY", +- .match_phy_device = rtl8226_match_phy_device, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- .match_phy_device = rtl8221b_match_phy_device, +- .name = "RTL8226B_RTL8221B 2.5Gbps PHY", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc838), +- .name = "RTL8226-CG 2.5Gbps PHY", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc848), +- .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, +- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, +- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", +- .config_init = rtl822xb_config_init, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822xb_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, +- }, { +- .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device, +- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device, +- .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", +- .config_init = rtl822xb_config_init, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822xb_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, +- }, { +- .match_phy_device = rtl8251b_c45_match_phy_device, +- .name = "RTL8251B 5Gbps PHY", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- .match_phy_device = rtl_internal_nbaset_match_phy_device, +- .name = "Realtek Internal NBASE-T PHY", +- .flags = PHY_IS_INTERNAL, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- .read_mmd = rtl822x_read_mmd, +- .write_mmd = rtl822x_write_mmd, +- }, { +- PHY_ID_MATCH_EXACT(0x001ccad0), +- .name = "RTL8224 2.5Gbps PHY", +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822x_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc961), +- .name = "RTL8366RB Gigabit Ethernet", +- .config_init = &rtl8366rb_config_init, +- /* These interrupts are handled by the irq controller +- * embedded inside the RTL8366RB, they get unmasked when the +- * irq is requested and ACKed by reading the status register, +- * which is done by the irqchip code. +- */ +- .config_intr = genphy_no_config_intr, +- .handle_interrupt = genphy_handle_interrupt_no_ack, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- }, { +- PHY_ID_MATCH_EXACT(0x001ccb00), +- .name = "RTL9000AA_RTL9000AN Ethernet", +- .features = PHY_BASIC_T1_FEATURES, +- .config_init = rtl9000a_config_init, +- .config_aneg = rtl9000a_config_aneg, +- .read_status = rtl9000a_read_status, +- .config_intr = rtl9000a_config_intr, +- .handle_interrupt = rtl9000a_handle_interrupt, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc942), +- .name = "RTL8365MB-VC Gigabit Ethernet", +- /* Interrupt handling analogous to RTL8366RB */ +- .config_intr = genphy_no_config_intr, +- .handle_interrupt = genphy_handle_interrupt_no_ack, +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- }, { +- PHY_ID_MATCH_EXACT(0x001cc960), +- .name = "RTL8366S Gigabit Ethernet", +- .suspend = genphy_suspend, +- .resume = genphy_resume, +- .read_mmd = genphy_read_mmd_unsupported, +- .write_mmd = genphy_write_mmd_unsupported, +- }, +-}; +- +-module_phy_driver(realtek_drvs); +- +-static const struct mdio_device_id __maybe_unused realtek_tbl[] = { +- { PHY_ID_MATCH_VENDOR(0x001cc800) }, +- { } +-}; +- +-MODULE_DEVICE_TABLE(mdio, realtek_tbl); +--- /dev/null ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -0,0 +1,1589 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* drivers/net/phy/realtek.c ++ * ++ * Driver for Realtek PHYs ++ * ++ * Author: Johnson Leung ++ * ++ * Copyright (c) 2004 Freescale Semiconductor, Inc. ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define RTL821x_PHYSR 0x11 ++#define RTL821x_PHYSR_DUPLEX BIT(13) ++#define RTL821x_PHYSR_SPEED GENMASK(15, 14) ++ ++#define RTL821x_INER 0x12 ++#define RTL8211B_INER_INIT 0x6400 ++#define RTL8211E_INER_LINK_STATUS BIT(10) ++#define RTL8211F_INER_LINK_STATUS BIT(4) ++ ++#define RTL821x_INSR 0x13 ++ ++#define RTL821x_EXT_PAGE_SELECT 0x1e ++#define RTL821x_PAGE_SELECT 0x1f ++ ++#define RTL8211F_PHYCR1 0x18 ++#define RTL8211F_PHYCR2 0x19 ++#define RTL8211F_INSR 0x1d ++ ++#define RTL8211F_LEDCR 0x10 ++#define RTL8211F_LEDCR_MODE BIT(15) ++#define RTL8211F_LEDCR_ACT_TXRX BIT(4) ++#define RTL8211F_LEDCR_LINK_1000 BIT(3) ++#define RTL8211F_LEDCR_LINK_100 BIT(1) ++#define RTL8211F_LEDCR_LINK_10 BIT(0) ++#define RTL8211F_LEDCR_MASK GENMASK(4, 0) ++#define RTL8211F_LEDCR_SHIFT 5 ++ ++#define RTL8211F_TX_DELAY BIT(8) ++#define RTL8211F_RX_DELAY BIT(3) ++ ++#define RTL8211F_ALDPS_PLL_OFF BIT(1) ++#define RTL8211F_ALDPS_ENABLE BIT(2) ++#define RTL8211F_ALDPS_XTAL_OFF BIT(12) ++ ++#define RTL8211E_CTRL_DELAY BIT(13) ++#define RTL8211E_TX_DELAY BIT(12) ++#define RTL8211E_RX_DELAY BIT(11) ++ ++#define RTL8211F_CLKOUT_EN BIT(0) ++ ++#define RTL8201F_ISR 0x1e ++#define RTL8201F_ISR_ANERR BIT(15) ++#define RTL8201F_ISR_DUPLEX BIT(13) ++#define RTL8201F_ISR_LINK BIT(11) ++#define RTL8201F_ISR_MASK (RTL8201F_ISR_ANERR | \ ++ RTL8201F_ISR_DUPLEX | \ ++ RTL8201F_ISR_LINK) ++#define RTL8201F_IER 0x13 ++ ++#define RTL822X_VND1_SERDES_OPTION 0x697a ++#define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0) ++#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII 0 ++#define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX 2 ++ ++#define RTL822X_VND1_SERDES_CTRL3 0x7580 ++#define RTL822X_VND1_SERDES_CTRL3_MODE_MASK GENMASK(5, 0) ++#define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 ++#define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 ++ ++/* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 ++ * is set, they cannot be accessed by C45-over-C22. ++ */ ++#define RTL822X_VND2_GBCR 0xa412 ++ ++#define RTL822X_VND2_GANLPAR 0xa414 ++ ++#define RTL8366RB_POWER_SAVE 0x15 ++#define RTL8366RB_POWER_SAVE_ON BIT(12) ++ ++#define RTL9000A_GINMR 0x14 ++#define RTL9000A_GINMR_LINK_STATUS BIT(4) ++ ++#define RTL_VND2_PHYSR 0xa434 ++#define RTL_VND2_PHYSR_DUPLEX BIT(3) ++#define RTL_VND2_PHYSR_SPEEDL GENMASK(5, 4) ++#define RTL_VND2_PHYSR_SPEEDH GENMASK(10, 9) ++#define RTL_VND2_PHYSR_MASTER BIT(11) ++#define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR_SPEEDH) ++ ++#define RTL_GENERIC_PHYID 0x001cc800 ++#define RTL_8211FVD_PHYID 0x001cc878 ++#define RTL_8221B 0x001cc840 ++#define RTL_8221B_VB_CG 0x001cc849 ++#define RTL_8221B_VN_CG 0x001cc84a ++#define RTL_8251B 0x001cc862 ++ ++#define RTL8211F_LED_COUNT 3 ++ ++MODULE_DESCRIPTION("Realtek PHY driver"); ++MODULE_AUTHOR("Johnson Leung"); ++MODULE_LICENSE("GPL"); ++ ++struct rtl821x_priv { ++ u16 phycr1; ++ u16 phycr2; ++ bool has_phycr2; ++ struct clk *clk; ++}; ++ ++static int rtl821x_read_page(struct phy_device *phydev) ++{ ++ return __phy_read(phydev, RTL821x_PAGE_SELECT); ++} ++ ++static int rtl821x_write_page(struct phy_device *phydev, int page) ++{ ++ return __phy_write(phydev, RTL821x_PAGE_SELECT, page); ++} ++ ++static int rtl821x_probe(struct phy_device *phydev) ++{ ++ struct device *dev = &phydev->mdio.dev; ++ struct rtl821x_priv *priv; ++ u32 phy_id = phydev->drv->phy_id; ++ int ret; ++ ++ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ priv->clk = devm_clk_get_optional_enabled(dev, NULL); ++ if (IS_ERR(priv->clk)) ++ return dev_err_probe(dev, PTR_ERR(priv->clk), ++ "failed to get phy clock\n"); ++ ++ ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); ++ if (ret < 0) ++ return ret; ++ ++ priv->phycr1 = ret & (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF); ++ if (of_property_read_bool(dev->of_node, "realtek,aldps-enable")) ++ priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF; ++ ++ priv->has_phycr2 = !(phy_id == RTL_8211FVD_PHYID); ++ if (priv->has_phycr2) { ++ ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2); ++ if (ret < 0) ++ return ret; ++ ++ priv->phycr2 = ret & RTL8211F_CLKOUT_EN; ++ if (of_property_read_bool(dev->of_node, "realtek,clkout-disable")) ++ priv->phycr2 &= ~RTL8211F_CLKOUT_EN; ++ } ++ ++ phydev->priv = priv; ++ ++ return 0; ++} ++ ++static int rtl8201_ack_interrupt(struct phy_device *phydev) ++{ ++ int err; ++ ++ err = phy_read(phydev, RTL8201F_ISR); ++ ++ return (err < 0) ? err : 0; ++} ++ ++static int rtl821x_ack_interrupt(struct phy_device *phydev) ++{ ++ int err; ++ ++ err = phy_read(phydev, RTL821x_INSR); ++ ++ return (err < 0) ? err : 0; ++} ++ ++static int rtl8211f_ack_interrupt(struct phy_device *phydev) ++{ ++ int err; ++ ++ err = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); ++ ++ return (err < 0) ? err : 0; ++} ++ ++static int rtl8201_config_intr(struct phy_device *phydev) ++{ ++ u16 val; ++ int err; ++ ++ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { ++ err = rtl8201_ack_interrupt(phydev); ++ if (err) ++ return err; ++ ++ val = BIT(13) | BIT(12) | BIT(11); ++ err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); ++ } else { ++ val = 0; ++ err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); ++ if (err) ++ return err; ++ ++ err = rtl8201_ack_interrupt(phydev); ++ } ++ ++ return err; ++} ++ ++static int rtl8211b_config_intr(struct phy_device *phydev) ++{ ++ int err; ++ ++ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { ++ err = rtl821x_ack_interrupt(phydev); ++ if (err) ++ return err; ++ ++ err = phy_write(phydev, RTL821x_INER, ++ RTL8211B_INER_INIT); ++ } else { ++ err = phy_write(phydev, RTL821x_INER, 0); ++ if (err) ++ return err; ++ ++ err = rtl821x_ack_interrupt(phydev); ++ } ++ ++ return err; ++} ++ ++static int rtl8211e_config_intr(struct phy_device *phydev) ++{ ++ int err; ++ ++ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { ++ err = rtl821x_ack_interrupt(phydev); ++ if (err) ++ return err; ++ ++ err = phy_write(phydev, RTL821x_INER, ++ RTL8211E_INER_LINK_STATUS); ++ } else { ++ err = phy_write(phydev, RTL821x_INER, 0); ++ if (err) ++ return err; ++ ++ err = rtl821x_ack_interrupt(phydev); ++ } ++ ++ return err; ++} ++ ++static int rtl8211f_config_intr(struct phy_device *phydev) ++{ ++ u16 val; ++ int err; ++ ++ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { ++ err = rtl8211f_ack_interrupt(phydev); ++ if (err) ++ return err; ++ ++ val = RTL8211F_INER_LINK_STATUS; ++ err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); ++ } else { ++ val = 0; ++ err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); ++ if (err) ++ return err; ++ ++ err = rtl8211f_ack_interrupt(phydev); ++ } ++ ++ return err; ++} ++ ++static irqreturn_t rtl8201_handle_interrupt(struct phy_device *phydev) ++{ ++ int irq_status; ++ ++ irq_status = phy_read(phydev, RTL8201F_ISR); ++ if (irq_status < 0) { ++ phy_error(phydev); ++ return IRQ_NONE; ++ } ++ ++ if (!(irq_status & RTL8201F_ISR_MASK)) ++ return IRQ_NONE; ++ ++ phy_trigger_machine(phydev); ++ ++ return IRQ_HANDLED; ++} ++ ++static irqreturn_t rtl821x_handle_interrupt(struct phy_device *phydev) ++{ ++ int irq_status, irq_enabled; ++ ++ irq_status = phy_read(phydev, RTL821x_INSR); ++ if (irq_status < 0) { ++ phy_error(phydev); ++ return IRQ_NONE; ++ } ++ ++ irq_enabled = phy_read(phydev, RTL821x_INER); ++ if (irq_enabled < 0) { ++ phy_error(phydev); ++ return IRQ_NONE; ++ } ++ ++ if (!(irq_status & irq_enabled)) ++ return IRQ_NONE; ++ ++ phy_trigger_machine(phydev); ++ ++ return IRQ_HANDLED; ++} ++ ++static irqreturn_t rtl8211f_handle_interrupt(struct phy_device *phydev) ++{ ++ int irq_status; ++ ++ irq_status = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); ++ if (irq_status < 0) { ++ phy_error(phydev); ++ return IRQ_NONE; ++ } ++ ++ if (!(irq_status & RTL8211F_INER_LINK_STATUS)) ++ return IRQ_NONE; ++ ++ phy_trigger_machine(phydev); ++ ++ return IRQ_HANDLED; ++} ++ ++static int rtl8211_config_aneg(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = genphy_config_aneg(phydev); ++ if (ret < 0) ++ return ret; ++ ++ /* Quirk was copied from vendor driver. Unfortunately it includes no ++ * description of the magic numbers. ++ */ ++ if (phydev->speed == SPEED_100 && phydev->autoneg == AUTONEG_DISABLE) { ++ phy_write(phydev, 0x17, 0x2138); ++ phy_write(phydev, 0x0e, 0x0260); ++ } else { ++ phy_write(phydev, 0x17, 0x2108); ++ phy_write(phydev, 0x0e, 0x0000); ++ } ++ ++ return 0; ++} ++ ++static int rtl8211c_config_init(struct phy_device *phydev) ++{ ++ /* RTL8211C has an issue when operating in Gigabit slave mode */ ++ return phy_set_bits(phydev, MII_CTRL1000, ++ CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); ++} ++ ++static int rtl8211f_config_init(struct phy_device *phydev) ++{ ++ struct rtl821x_priv *priv = phydev->priv; ++ struct device *dev = &phydev->mdio.dev; ++ u16 val_txdly, val_rxdly; ++ int ret; ++ ++ ret = phy_modify_paged_changed(phydev, 0xa43, RTL8211F_PHYCR1, ++ RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF, ++ priv->phycr1); ++ if (ret < 0) { ++ dev_err(dev, "aldps mode configuration failed: %pe\n", ++ ERR_PTR(ret)); ++ return ret; ++ } ++ ++ switch (phydev->interface) { ++ case PHY_INTERFACE_MODE_RGMII: ++ val_txdly = 0; ++ val_rxdly = 0; ++ break; ++ ++ case PHY_INTERFACE_MODE_RGMII_RXID: ++ val_txdly = 0; ++ val_rxdly = RTL8211F_RX_DELAY; ++ break; ++ ++ case PHY_INTERFACE_MODE_RGMII_TXID: ++ val_txdly = RTL8211F_TX_DELAY; ++ val_rxdly = 0; ++ break; ++ ++ case PHY_INTERFACE_MODE_RGMII_ID: ++ val_txdly = RTL8211F_TX_DELAY; ++ val_rxdly = RTL8211F_RX_DELAY; ++ break; ++ ++ default: /* the rest of the modes imply leaving delay as is. */ ++ return 0; ++ } ++ ++ ret = phy_modify_paged_changed(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, ++ val_txdly); ++ if (ret < 0) { ++ dev_err(dev, "Failed to update the TX delay register\n"); ++ return ret; ++ } else if (ret) { ++ dev_dbg(dev, ++ "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n", ++ val_txdly ? "Enabling" : "Disabling"); ++ } else { ++ dev_dbg(dev, ++ "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n", ++ val_txdly ? "enabled" : "disabled"); ++ } ++ ++ ret = phy_modify_paged_changed(phydev, 0xd08, 0x15, RTL8211F_RX_DELAY, ++ val_rxdly); ++ if (ret < 0) { ++ dev_err(dev, "Failed to update the RX delay register\n"); ++ return ret; ++ } else if (ret) { ++ dev_dbg(dev, ++ "%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n", ++ val_rxdly ? "Enabling" : "Disabling"); ++ } else { ++ dev_dbg(dev, ++ "2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n", ++ val_rxdly ? "enabled" : "disabled"); ++ } ++ ++ if (priv->has_phycr2) { ++ ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, ++ RTL8211F_CLKOUT_EN, priv->phycr2); ++ if (ret < 0) { ++ dev_err(dev, "clkout configuration failed: %pe\n", ++ ERR_PTR(ret)); ++ return ret; ++ } ++ ++ return genphy_soft_reset(phydev); ++ } ++ ++ return 0; ++} ++ ++static int rtl821x_suspend(struct phy_device *phydev) ++{ ++ struct rtl821x_priv *priv = phydev->priv; ++ int ret = 0; ++ ++ if (!phydev->wol_enabled) { ++ ret = genphy_suspend(phydev); ++ ++ if (ret) ++ return ret; ++ ++ clk_disable_unprepare(priv->clk); ++ } ++ ++ return ret; ++} ++ ++static int rtl821x_resume(struct phy_device *phydev) ++{ ++ struct rtl821x_priv *priv = phydev->priv; ++ int ret; ++ ++ if (!phydev->wol_enabled) ++ clk_prepare_enable(priv->clk); ++ ++ ret = genphy_resume(phydev); ++ if (ret < 0) ++ return ret; ++ ++ msleep(20); ++ ++ return 0; ++} ++ ++static int rtl8211f_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ const unsigned long mask = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_RX) | ++ BIT(TRIGGER_NETDEV_TX); ++ ++ /* The RTL8211F PHY supports these LED settings on up to three LEDs: ++ * - Link: Configurable subset of 10/100/1000 link rates ++ * - Active: Blink on activity, RX or TX is not differentiated ++ * The Active option has two modes, A and B: ++ * - A: Link and Active indication at configurable, but matching, ++ * subset of 10/100/1000 link rates ++ * - B: Link indication at configurable subset of 10/100/1000 link ++ * rates and Active indication always at all three 10+100+1000 ++ * link rates. ++ * This code currently uses mode B only. ++ */ ++ ++ if (index >= RTL8211F_LED_COUNT) ++ return -EINVAL; ++ ++ /* Filter out any other unsupported triggers. */ ++ if (rules & ~mask) ++ return -EOPNOTSUPP; ++ ++ /* RX and TX are not differentiated, either both are set or not set. */ ++ if (!(rules & BIT(TRIGGER_NETDEV_RX)) ^ !(rules & BIT(TRIGGER_NETDEV_TX))) ++ return -EOPNOTSUPP; ++ ++ return 0; ++} ++ ++static int rtl8211f_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int val; ++ ++ if (index >= RTL8211F_LED_COUNT) ++ return -EINVAL; ++ ++ val = phy_read_paged(phydev, 0xd04, RTL8211F_LEDCR); ++ if (val < 0) ++ return val; ++ ++ val >>= RTL8211F_LEDCR_SHIFT * index; ++ val &= RTL8211F_LEDCR_MASK; ++ ++ if (val & RTL8211F_LEDCR_LINK_10) ++ set_bit(TRIGGER_NETDEV_LINK_10, rules); ++ ++ if (val & RTL8211F_LEDCR_LINK_100) ++ set_bit(TRIGGER_NETDEV_LINK_100, rules); ++ ++ if (val & RTL8211F_LEDCR_LINK_1000) ++ set_bit(TRIGGER_NETDEV_LINK_1000, rules); ++ ++ if (val & RTL8211F_LEDCR_ACT_TXRX) { ++ set_bit(TRIGGER_NETDEV_RX, rules); ++ set_bit(TRIGGER_NETDEV_TX, rules); ++ } ++ ++ return 0; ++} ++ ++static int rtl8211f_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ const u16 mask = RTL8211F_LEDCR_MASK << (RTL8211F_LEDCR_SHIFT * index); ++ u16 reg = 0; ++ ++ if (index >= RTL8211F_LED_COUNT) ++ return -EINVAL; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) ++ reg |= RTL8211F_LEDCR_LINK_10; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) ++ reg |= RTL8211F_LEDCR_LINK_100; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) ++ reg |= RTL8211F_LEDCR_LINK_1000; ++ ++ if (test_bit(TRIGGER_NETDEV_RX, &rules) || ++ test_bit(TRIGGER_NETDEV_TX, &rules)) { ++ reg |= RTL8211F_LEDCR_ACT_TXRX; ++ } ++ ++ reg <<= RTL8211F_LEDCR_SHIFT * index; ++ reg |= RTL8211F_LEDCR_MODE; /* Mode B */ ++ ++ return phy_modify_paged(phydev, 0xd04, RTL8211F_LEDCR, mask, reg); ++} ++ ++static int rtl8211e_config_init(struct phy_device *phydev) ++{ ++ int ret = 0, oldpage; ++ u16 val; ++ ++ /* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */ ++ switch (phydev->interface) { ++ case PHY_INTERFACE_MODE_RGMII: ++ val = RTL8211E_CTRL_DELAY | 0; ++ break; ++ case PHY_INTERFACE_MODE_RGMII_ID: ++ val = RTL8211E_CTRL_DELAY | RTL8211E_TX_DELAY | RTL8211E_RX_DELAY; ++ break; ++ case PHY_INTERFACE_MODE_RGMII_RXID: ++ val = RTL8211E_CTRL_DELAY | RTL8211E_RX_DELAY; ++ break; ++ case PHY_INTERFACE_MODE_RGMII_TXID: ++ val = RTL8211E_CTRL_DELAY | RTL8211E_TX_DELAY; ++ break; ++ default: /* the rest of the modes imply leaving delays as is. */ ++ return 0; ++ } ++ ++ /* According to a sample driver there is a 0x1c config register on the ++ * 0xa4 extension page (0x7) layout. It can be used to disable/enable ++ * the RX/TX delays otherwise controlled by RXDLY/TXDLY pins. ++ * The configuration register definition: ++ * 14 = reserved ++ * 13 = Force Tx RX Delay controlled by bit12 bit11, ++ * 12 = RX Delay, 11 = TX Delay ++ * 10:0 = Test && debug settings reserved by realtek ++ */ ++ oldpage = phy_select_page(phydev, 0x7); ++ if (oldpage < 0) ++ goto err_restore_page; ++ ++ ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0xa4); ++ if (ret) ++ goto err_restore_page; ++ ++ ret = __phy_modify(phydev, 0x1c, RTL8211E_CTRL_DELAY ++ | RTL8211E_TX_DELAY | RTL8211E_RX_DELAY, ++ val); ++ ++err_restore_page: ++ return phy_restore_page(phydev, oldpage, ret); ++} ++ ++static int rtl8211b_suspend(struct phy_device *phydev) ++{ ++ phy_write(phydev, MII_MMD_DATA, BIT(9)); ++ ++ return genphy_suspend(phydev); ++} ++ ++static int rtl8211b_resume(struct phy_device *phydev) ++{ ++ phy_write(phydev, MII_MMD_DATA, 0); ++ ++ return genphy_resume(phydev); ++} ++ ++static int rtl8366rb_config_init(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = phy_set_bits(phydev, RTL8366RB_POWER_SAVE, ++ RTL8366RB_POWER_SAVE_ON); ++ if (ret) { ++ dev_err(&phydev->mdio.dev, ++ "error enabling power management\n"); ++ } ++ ++ return ret; ++} ++ ++/* get actual speed to cover the downshift case */ ++static void rtlgen_decode_physr(struct phy_device *phydev, int val) ++{ ++ /* bit 3 ++ * 0: Half Duplex ++ * 1: Full Duplex ++ */ ++ if (val & RTL_VND2_PHYSR_DUPLEX) ++ phydev->duplex = DUPLEX_FULL; ++ else ++ phydev->duplex = DUPLEX_HALF; ++ ++ switch (val & RTL_VND2_PHYSR_SPEED_MASK) { ++ case 0x0000: ++ phydev->speed = SPEED_10; ++ break; ++ case 0x0010: ++ phydev->speed = SPEED_100; ++ break; ++ case 0x0020: ++ phydev->speed = SPEED_1000; ++ break; ++ case 0x0200: ++ phydev->speed = SPEED_10000; ++ break; ++ case 0x0210: ++ phydev->speed = SPEED_2500; ++ break; ++ case 0x0220: ++ phydev->speed = SPEED_5000; ++ break; ++ default: ++ break; ++ } ++ ++ /* bit 11 ++ * 0: Slave Mode ++ * 1: Master Mode ++ */ ++ if (phydev->speed >= 1000) { ++ if (val & RTL_VND2_PHYSR_MASTER) ++ phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; ++ else ++ phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; ++ } else { ++ phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED; ++ } ++} ++ ++static int rtlgen_read_status(struct phy_device *phydev) ++{ ++ int ret, val; ++ ++ ret = genphy_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ if (!phydev->link) ++ return 0; ++ ++ val = phy_read_paged(phydev, 0xa43, 0x12); ++ if (val < 0) ++ return val; ++ ++ rtlgen_decode_physr(phydev, val); ++ ++ return 0; ++} ++ ++static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) ++{ ++ int ret; ++ ++ if (devnum == MDIO_MMD_VEND2) { ++ rtl821x_write_page(phydev, regnum >> 4); ++ ret = __phy_read(phydev, 0x10 + ((regnum & 0xf) >> 1)); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) { ++ rtl821x_write_page(phydev, 0xa5c); ++ ret = __phy_read(phydev, 0x12); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { ++ rtl821x_write_page(phydev, 0xa5d); ++ ret = __phy_read(phydev, 0x10); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE) { ++ rtl821x_write_page(phydev, 0xa5d); ++ ret = __phy_read(phydev, 0x11); ++ rtl821x_write_page(phydev, 0); ++ } else { ++ ret = -EOPNOTSUPP; ++ } ++ ++ return ret; ++} ++ ++static int rtlgen_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, ++ u16 val) ++{ ++ int ret; ++ ++ if (devnum == MDIO_MMD_VEND2) { ++ rtl821x_write_page(phydev, regnum >> 4); ++ ret = __phy_write(phydev, 0x10 + ((regnum & 0xf) >> 1), val); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { ++ rtl821x_write_page(phydev, 0xa5d); ++ ret = __phy_write(phydev, 0x10, val); ++ rtl821x_write_page(phydev, 0); ++ } else { ++ ret = -EOPNOTSUPP; ++ } ++ ++ return ret; ++} ++ ++static int rtl822x_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) ++{ ++ int ret = rtlgen_read_mmd(phydev, devnum, regnum); ++ ++ if (ret != -EOPNOTSUPP) ++ return ret; ++ ++ if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE2) { ++ rtl821x_write_page(phydev, 0xa6e); ++ ret = __phy_read(phydev, 0x16); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) { ++ rtl821x_write_page(phydev, 0xa6d); ++ ret = __phy_read(phydev, 0x12); ++ rtl821x_write_page(phydev, 0); ++ } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE2) { ++ rtl821x_write_page(phydev, 0xa6d); ++ ret = __phy_read(phydev, 0x10); ++ rtl821x_write_page(phydev, 0); ++ } ++ ++ return ret; ++} ++ ++static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, ++ u16 val) ++{ ++ int ret = rtlgen_write_mmd(phydev, devnum, regnum, val); ++ ++ if (ret != -EOPNOTSUPP) ++ return ret; ++ ++ if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) { ++ rtl821x_write_page(phydev, 0xa6d); ++ ret = __phy_write(phydev, 0x12, val); ++ rtl821x_write_page(phydev, 0); ++ } ++ ++ return ret; ++} ++ ++static int rtl822xb_config_init(struct phy_device *phydev) ++{ ++ bool has_2500, has_sgmii; ++ u16 mode; ++ int ret; ++ ++ has_2500 = test_bit(PHY_INTERFACE_MODE_2500BASEX, ++ phydev->host_interfaces) || ++ phydev->interface == PHY_INTERFACE_MODE_2500BASEX; ++ ++ has_sgmii = test_bit(PHY_INTERFACE_MODE_SGMII, ++ phydev->host_interfaces) || ++ phydev->interface == PHY_INTERFACE_MODE_SGMII; ++ ++ /* fill in possible interfaces */ ++ __assign_bit(PHY_INTERFACE_MODE_2500BASEX, phydev->possible_interfaces, ++ has_2500); ++ __assign_bit(PHY_INTERFACE_MODE_SGMII, phydev->possible_interfaces, ++ has_sgmii); ++ ++ if (!has_2500 && !has_sgmii) ++ return 0; ++ ++ /* determine SerDes option mode */ ++ if (has_2500 && !has_sgmii) { ++ mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX; ++ phydev->rate_matching = RATE_MATCH_PAUSE; ++ } else { ++ mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII; ++ phydev->rate_matching = RATE_MATCH_NONE; ++ } ++ ++ /* the following sequence with magic numbers sets up the SerDes ++ * option mode ++ */ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1, ++ RTL822X_VND1_SERDES_OPTION, ++ RTL822X_VND1_SERDES_OPTION_MODE_MASK, ++ mode); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6a04, 0x0503); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f10, 0xd455); ++ if (ret < 0) ++ return ret; ++ ++ return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); ++} ++ ++static int rtl822xb_get_rate_matching(struct phy_device *phydev, ++ phy_interface_t iface) ++{ ++ int val; ++ ++ /* Only rate matching at 2500base-x */ ++ if (iface != PHY_INTERFACE_MODE_2500BASEX) ++ return RATE_MATCH_NONE; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_OPTION); ++ if (val < 0) ++ return val; ++ ++ if ((val & RTL822X_VND1_SERDES_OPTION_MODE_MASK) == ++ RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX) ++ return RATE_MATCH_PAUSE; ++ ++ /* RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII */ ++ return RATE_MATCH_NONE; ++} ++ ++static int rtl822x_get_features(struct phy_device *phydev) ++{ ++ int val; ++ ++ val = phy_read_paged(phydev, 0xa61, 0x13); ++ if (val < 0) ++ return val; ++ ++ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, ++ phydev->supported, val & MDIO_PMA_SPEED_2_5G); ++ linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, ++ phydev->supported, val & MDIO_PMA_SPEED_5G); ++ linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, ++ phydev->supported, val & MDIO_SPEED_10G); ++ ++ return genphy_read_abilities(phydev); ++} ++ ++static int rtl822x_config_aneg(struct phy_device *phydev) ++{ ++ int ret = 0; ++ ++ if (phydev->autoneg == AUTONEG_ENABLE) { ++ u16 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); ++ ++ ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, ++ MDIO_AN_10GBT_CTRL_ADV2_5G | ++ MDIO_AN_10GBT_CTRL_ADV5G, ++ adv); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return __genphy_config_aneg(phydev, ret); ++} ++ ++static void rtl822xb_update_interface(struct phy_device *phydev) ++{ ++ int val; ++ ++ if (!phydev->link) ++ return; ++ ++ /* Change interface according to serdes mode */ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_CTRL3); ++ if (val < 0) ++ return; ++ ++ switch (val & RTL822X_VND1_SERDES_CTRL3_MODE_MASK) { ++ case RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX: ++ phydev->interface = PHY_INTERFACE_MODE_2500BASEX; ++ break; ++ case RTL822X_VND1_SERDES_CTRL3_MODE_SGMII: ++ phydev->interface = PHY_INTERFACE_MODE_SGMII; ++ break; ++ } ++} ++ ++static int rtl822x_read_status(struct phy_device *phydev) ++{ ++ int lpadv, ret; ++ ++ mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, 0); ++ ++ ret = rtlgen_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ if (phydev->autoneg == AUTONEG_DISABLE || ++ !phydev->autoneg_complete) ++ return 0; ++ ++ lpadv = phy_read_paged(phydev, 0xa5d, 0x13); ++ if (lpadv < 0) ++ return lpadv; ++ ++ mii_10gbt_stat_mod_linkmode_lpa_t(phydev->lp_advertising, lpadv); ++ ++ return 0; ++} ++ ++static int rtl822xb_read_status(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = rtl822x_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ rtl822xb_update_interface(phydev); ++ ++ return 0; ++} ++ ++static int rtl822x_c45_get_features(struct phy_device *phydev) ++{ ++ linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, ++ phydev->supported); ++ ++ return genphy_c45_pma_read_abilities(phydev); ++} ++ ++static int rtl822x_c45_config_aneg(struct phy_device *phydev) ++{ ++ bool changed = false; ++ int ret, val; ++ ++ if (phydev->autoneg == AUTONEG_DISABLE) ++ return genphy_c45_pma_setup_forced(phydev); ++ ++ ret = genphy_c45_an_config_aneg(phydev); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); ++ ++ /* Vendor register as C45 has no standardized support for 1000BaseT */ ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR, ++ ADVERTISE_1000FULL, val); ++ if (ret < 0) ++ return ret; ++ if (ret > 0) ++ changed = true; ++ ++ return genphy_c45_check_and_restart_aneg(phydev, changed); ++} ++ ++static int rtl822x_c45_read_status(struct phy_device *phydev) ++{ ++ int ret, val; ++ ++ /* Vendor register as C45 has no standardized support for 1000BaseT */ ++ if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) { ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_GANLPAR); ++ if (val < 0) ++ return val; ++ } else { ++ val = 0; ++ } ++ mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); ++ ++ ret = genphy_c45_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ if (!phydev->link) { ++ phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; ++ return 0; ++ } ++ ++ /* Read actual speed from vendor register. */ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR); ++ if (val < 0) ++ return val; ++ ++ rtlgen_decode_physr(phydev, val); ++ ++ return 0; ++} ++ ++static int rtl822xb_c45_read_status(struct phy_device *phydev) ++{ ++ int ret; ++ ++ ret = rtl822x_c45_read_status(phydev); ++ if (ret < 0) ++ return ret; ++ ++ rtl822xb_update_interface(phydev); ++ ++ return 0; ++} ++ ++static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) ++{ ++ int val; ++ ++ phy_write(phydev, RTL821x_PAGE_SELECT, 0xa61); ++ val = phy_read(phydev, 0x13); ++ phy_write(phydev, RTL821x_PAGE_SELECT, 0); ++ ++ return val >= 0 && val & MDIO_PMA_SPEED_2_5G; ++} ++ ++/* On internal PHY's MMD reads over C22 always return 0. ++ * Check a MMD register which is known to be non-zero. ++ */ ++static bool rtlgen_supports_mmd(struct phy_device *phydev) ++{ ++ int val; ++ ++ phy_lock_mdio_bus(phydev); ++ __phy_write(phydev, MII_MMD_CTRL, MDIO_MMD_PCS); ++ __phy_write(phydev, MII_MMD_DATA, MDIO_PCS_EEE_ABLE); ++ __phy_write(phydev, MII_MMD_CTRL, MDIO_MMD_PCS | MII_MMD_CTRL_NOINCR); ++ val = __phy_read(phydev, MII_MMD_DATA); ++ phy_unlock_mdio_bus(phydev); ++ ++ return val > 0; ++} ++ ++static int rtlgen_match_phy_device(struct phy_device *phydev) ++{ ++ return phydev->phy_id == RTL_GENERIC_PHYID && ++ !rtlgen_supports_2_5gbps(phydev); ++} ++ ++static int rtl8226_match_phy_device(struct phy_device *phydev) ++{ ++ return phydev->phy_id == RTL_GENERIC_PHYID && ++ rtlgen_supports_2_5gbps(phydev) && ++ rtlgen_supports_mmd(phydev); ++} ++ ++static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id, ++ bool is_c45) ++{ ++ if (phydev->is_c45) ++ return is_c45 && (id == phydev->c45_ids.device_ids[1]); ++ else ++ return !is_c45 && (id == phydev->phy_id); ++} ++ ++static int rtl8221b_match_phy_device(struct phy_device *phydev) ++{ ++ return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev); ++} ++ ++static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); ++} ++ ++static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); ++} ++ ++static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false); ++} ++ ++static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true); ++} ++ ++static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev) ++{ ++ if (phydev->is_c45) ++ return false; ++ ++ switch (phydev->phy_id) { ++ case RTL_GENERIC_PHYID: ++ case RTL_8221B: ++ case RTL_8251B: ++ case 0x001cc841: ++ break; ++ default: ++ return false; ++ } ++ ++ return rtlgen_supports_2_5gbps(phydev) && !rtlgen_supports_mmd(phydev); ++} ++ ++static int rtl8251b_c45_match_phy_device(struct phy_device *phydev) ++{ ++ return rtlgen_is_c45_match(phydev, RTL_8251B, true); ++} ++ ++static int rtlgen_resume(struct phy_device *phydev) ++{ ++ int ret = genphy_resume(phydev); ++ ++ /* Internal PHY's from RTL8168h up may not be instantly ready */ ++ msleep(20); ++ ++ return ret; ++} ++ ++static int rtlgen_c45_resume(struct phy_device *phydev) ++{ ++ int ret = genphy_c45_pma_resume(phydev); ++ ++ msleep(20); ++ ++ return ret; ++} ++ ++static int rtl9000a_config_init(struct phy_device *phydev) ++{ ++ phydev->autoneg = AUTONEG_DISABLE; ++ phydev->speed = SPEED_100; ++ phydev->duplex = DUPLEX_FULL; ++ ++ return 0; ++} ++ ++static int rtl9000a_config_aneg(struct phy_device *phydev) ++{ ++ int ret; ++ u16 ctl = 0; ++ ++ switch (phydev->master_slave_set) { ++ case MASTER_SLAVE_CFG_MASTER_FORCE: ++ ctl |= CTL1000_AS_MASTER; ++ break; ++ case MASTER_SLAVE_CFG_SLAVE_FORCE: ++ break; ++ case MASTER_SLAVE_CFG_UNKNOWN: ++ case MASTER_SLAVE_CFG_UNSUPPORTED: ++ return 0; ++ default: ++ phydev_warn(phydev, "Unsupported Master/Slave mode\n"); ++ return -EOPNOTSUPP; ++ } ++ ++ ret = phy_modify_changed(phydev, MII_CTRL1000, CTL1000_AS_MASTER, ctl); ++ if (ret == 1) ++ ret = genphy_soft_reset(phydev); ++ ++ return ret; ++} ++ ++static int rtl9000a_read_status(struct phy_device *phydev) ++{ ++ int ret; ++ ++ phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN; ++ phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN; ++ ++ ret = genphy_update_link(phydev); ++ if (ret) ++ return ret; ++ ++ ret = phy_read(phydev, MII_CTRL1000); ++ if (ret < 0) ++ return ret; ++ if (ret & CTL1000_AS_MASTER) ++ phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE; ++ else ++ phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE; ++ ++ ret = phy_read(phydev, MII_STAT1000); ++ if (ret < 0) ++ return ret; ++ if (ret & LPA_1000MSRES) ++ phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; ++ else ++ phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; ++ ++ return 0; ++} ++ ++static int rtl9000a_ack_interrupt(struct phy_device *phydev) ++{ ++ int err; ++ ++ err = phy_read(phydev, RTL8211F_INSR); ++ ++ return (err < 0) ? err : 0; ++} ++ ++static int rtl9000a_config_intr(struct phy_device *phydev) ++{ ++ u16 val; ++ int err; ++ ++ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { ++ err = rtl9000a_ack_interrupt(phydev); ++ if (err) ++ return err; ++ ++ val = (u16)~RTL9000A_GINMR_LINK_STATUS; ++ err = phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); ++ } else { ++ val = ~0; ++ err = phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); ++ if (err) ++ return err; ++ ++ err = rtl9000a_ack_interrupt(phydev); ++ } ++ ++ return phy_write_paged(phydev, 0xa42, RTL9000A_GINMR, val); ++} ++ ++static irqreturn_t rtl9000a_handle_interrupt(struct phy_device *phydev) ++{ ++ int irq_status; ++ ++ irq_status = phy_read(phydev, RTL8211F_INSR); ++ if (irq_status < 0) { ++ phy_error(phydev); ++ return IRQ_NONE; ++ } ++ ++ if (!(irq_status & RTL8211F_INER_LINK_STATUS)) ++ return IRQ_NONE; ++ ++ phy_trigger_machine(phydev); ++ ++ return IRQ_HANDLED; ++} ++ ++static struct phy_driver realtek_drvs[] = { ++ { ++ PHY_ID_MATCH_EXACT(0x00008201), ++ .name = "RTL8201CP Ethernet", ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc816), ++ .name = "RTL8201F Fast Ethernet", ++ .config_intr = &rtl8201_config_intr, ++ .handle_interrupt = rtl8201_handle_interrupt, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_MODEL(0x001cc880), ++ .name = "RTL8208 Fast Ethernet", ++ .read_mmd = genphy_read_mmd_unsupported, ++ .write_mmd = genphy_write_mmd_unsupported, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc910), ++ .name = "RTL8211 Gigabit Ethernet", ++ .config_aneg = rtl8211_config_aneg, ++ .read_mmd = &genphy_read_mmd_unsupported, ++ .write_mmd = &genphy_write_mmd_unsupported, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc912), ++ .name = "RTL8211B Gigabit Ethernet", ++ .config_intr = &rtl8211b_config_intr, ++ .handle_interrupt = rtl821x_handle_interrupt, ++ .read_mmd = &genphy_read_mmd_unsupported, ++ .write_mmd = &genphy_write_mmd_unsupported, ++ .suspend = rtl8211b_suspend, ++ .resume = rtl8211b_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc913), ++ .name = "RTL8211C Gigabit Ethernet", ++ .config_init = rtl8211c_config_init, ++ .read_mmd = &genphy_read_mmd_unsupported, ++ .write_mmd = &genphy_write_mmd_unsupported, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc914), ++ .name = "RTL8211DN Gigabit Ethernet", ++ .config_intr = rtl8211e_config_intr, ++ .handle_interrupt = rtl821x_handle_interrupt, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc915), ++ .name = "RTL8211E Gigabit Ethernet", ++ .config_init = &rtl8211e_config_init, ++ .config_intr = &rtl8211e_config_intr, ++ .handle_interrupt = rtl821x_handle_interrupt, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc916), ++ .name = "RTL8211F Gigabit Ethernet", ++ .probe = rtl821x_probe, ++ .config_init = &rtl8211f_config_init, ++ .read_status = rtlgen_read_status, ++ .config_intr = &rtl8211f_config_intr, ++ .handle_interrupt = rtl8211f_handle_interrupt, ++ .suspend = rtl821x_suspend, ++ .resume = rtl821x_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ .flags = PHY_ALWAYS_CALL_SUSPEND, ++ .led_hw_is_supported = rtl8211f_led_hw_is_supported, ++ .led_hw_control_get = rtl8211f_led_hw_control_get, ++ .led_hw_control_set = rtl8211f_led_hw_control_set, ++ }, { ++ PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID), ++ .name = "RTL8211F-VD Gigabit Ethernet", ++ .probe = rtl821x_probe, ++ .config_init = &rtl8211f_config_init, ++ .read_status = rtlgen_read_status, ++ .config_intr = &rtl8211f_config_intr, ++ .handle_interrupt = rtl8211f_handle_interrupt, ++ .suspend = rtl821x_suspend, ++ .resume = rtl821x_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ .flags = PHY_ALWAYS_CALL_SUSPEND, ++ }, { ++ .name = "Generic FE-GE Realtek PHY", ++ .match_phy_device = rtlgen_match_phy_device, ++ .read_status = rtlgen_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ .read_mmd = rtlgen_read_mmd, ++ .write_mmd = rtlgen_write_mmd, ++ }, { ++ .name = "RTL8226 2.5Gbps PHY", ++ .match_phy_device = rtl8226_match_phy_device, ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ .match_phy_device = rtl8221b_match_phy_device, ++ .name = "RTL8226B_RTL8221B 2.5Gbps PHY", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc838), ++ .name = "RTL8226-CG 2.5Gbps PHY", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc848), ++ .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, ++ }, { ++ .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device, ++ .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device, ++ .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", ++ .config_init = rtl822xb_config_init, ++ .get_rate_matching = rtl822xb_get_rate_matching, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, ++ }, { ++ .match_phy_device = rtl8251b_c45_match_phy_device, ++ .name = "RTL8251B 5Gbps PHY", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ .match_phy_device = rtl_internal_nbaset_match_phy_device, ++ .name = "Realtek Internal NBASE-T PHY", ++ .flags = PHY_IS_INTERNAL, ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ .read_mmd = rtl822x_read_mmd, ++ .write_mmd = rtl822x_write_mmd, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001ccad0), ++ .name = "RTL8224 2.5Gbps PHY", ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822x_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc961), ++ .name = "RTL8366RB Gigabit Ethernet", ++ .config_init = &rtl8366rb_config_init, ++ /* These interrupts are handled by the irq controller ++ * embedded inside the RTL8366RB, they get unmasked when the ++ * irq is requested and ACKed by reading the status register, ++ * which is done by the irqchip code. ++ */ ++ .config_intr = genphy_no_config_intr, ++ .handle_interrupt = genphy_handle_interrupt_no_ack, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001ccb00), ++ .name = "RTL9000AA_RTL9000AN Ethernet", ++ .features = PHY_BASIC_T1_FEATURES, ++ .config_init = rtl9000a_config_init, ++ .config_aneg = rtl9000a_config_aneg, ++ .read_status = rtl9000a_read_status, ++ .config_intr = rtl9000a_config_intr, ++ .handle_interrupt = rtl9000a_handle_interrupt, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc942), ++ .name = "RTL8365MB-VC Gigabit Ethernet", ++ /* Interrupt handling analogous to RTL8366RB */ ++ .config_intr = genphy_no_config_intr, ++ .handle_interrupt = genphy_handle_interrupt_no_ack, ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ }, { ++ PHY_ID_MATCH_EXACT(0x001cc960), ++ .name = "RTL8366S Gigabit Ethernet", ++ .suspend = genphy_suspend, ++ .resume = genphy_resume, ++ .read_mmd = genphy_read_mmd_unsupported, ++ .write_mmd = genphy_write_mmd_unsupported, ++ }, ++}; ++ ++module_phy_driver(realtek_drvs); ++ ++static const struct mdio_device_id __maybe_unused realtek_tbl[] = { ++ { PHY_ID_MATCH_VENDOR(0x001cc800) }, ++ { } ++}; ++ ++MODULE_DEVICE_TABLE(mdio, realtek_tbl); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-11-v6.14-net-phy-realtek-add-hwmon-support-for-temp-sensor-on.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-11-v6.14-net-phy-realtek-add-hwmon-support-for-temp-sensor-on.patch new file mode 100755 index 0000000..2dec701 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-11-v6.14-net-phy-realtek-add-hwmon-support-for-temp-sensor-on.patch @@ -0,0 +1,173 @@ +From 33700ca45b7d2e1655d4cad95e25671e8a94e2f0 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 11 Jan 2025 21:51:24 +0100 +Subject: [PATCH] net: phy: realtek: add hwmon support for temp sensor on + RTL822x + +This adds hwmon support for the temperature sensor on RTL822x. +It's available on the standalone versions of the PHY's, and on +the integrated PHY's in RTL8125B/RTL8125D/RTL8126. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/ad6bfe9f-6375-4a00-84b4-bfb38a21bd71@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/Kconfig | 6 ++ + drivers/net/phy/realtek/Makefile | 1 + + drivers/net/phy/realtek/realtek.h | 10 ++++ + drivers/net/phy/realtek/realtek_hwmon.c | 79 +++++++++++++++++++++++++ + drivers/net/phy/realtek/realtek_main.c | 12 ++++ + 5 files changed, 108 insertions(+) + create mode 100644 drivers/net/phy/realtek/realtek.h + create mode 100644 drivers/net/phy/realtek/realtek_hwmon.c + +--- a/drivers/net/phy/realtek/Kconfig ++++ b/drivers/net/phy/realtek/Kconfig +@@ -3,3 +3,9 @@ config REALTEK_PHY + tristate "Realtek PHYs" + help + Currently supports RTL821x/RTL822x and fast ethernet PHYs ++ ++config REALTEK_PHY_HWMON ++ def_bool REALTEK_PHY && HWMON ++ depends on !(REALTEK_PHY=y && HWMON=m) ++ help ++ Optional hwmon support for the temperature sensor +--- a/drivers/net/phy/realtek/Makefile ++++ b/drivers/net/phy/realtek/Makefile +@@ -1,3 +1,4 @@ + # SPDX-License-Identifier: GPL-2.0 + realtek-y += realtek_main.o ++realtek-$(CONFIG_REALTEK_PHY_HWMON) += realtek_hwmon.o + obj-$(CONFIG_REALTEK_PHY) += realtek.o +--- /dev/null ++++ b/drivers/net/phy/realtek/realtek.h +@@ -0,0 +1,10 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++#ifndef REALTEK_H ++#define REALTEK_H ++ ++#include ++ ++int rtl822x_hwmon_init(struct phy_device *phydev); ++ ++#endif /* REALTEK_H */ +--- /dev/null ++++ b/drivers/net/phy/realtek/realtek_hwmon.c +@@ -0,0 +1,79 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * HWMON support for Realtek PHY's ++ * ++ * Author: Heiner Kallweit ++ */ ++ ++#include ++#include ++ ++#include "realtek.h" ++ ++#define RTL822X_VND2_TSALRM 0xa662 ++#define RTL822X_VND2_TSRR 0xbd84 ++#define RTL822X_VND2_TSSR 0xb54c ++ ++static int rtl822x_hwmon_get_temp(int raw) ++{ ++ if (raw >= 512) ++ raw -= 1024; ++ ++ return 1000 * raw / 2; ++} ++ ++static int rtl822x_hwmon_read(struct device *dev, enum hwmon_sensor_types type, ++ u32 attr, int channel, long *val) ++{ ++ struct phy_device *phydev = dev_get_drvdata(dev); ++ int raw; ++ ++ switch (attr) { ++ case hwmon_temp_input: ++ raw = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSRR) & 0x3ff; ++ *val = rtl822x_hwmon_get_temp(raw); ++ break; ++ case hwmon_temp_max: ++ /* Chip reduces speed to 1G if threshold is exceeded */ ++ raw = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSSR) >> 6; ++ *val = rtl822x_hwmon_get_temp(raw); ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static const struct hwmon_ops rtl822x_hwmon_ops = { ++ .visible = 0444, ++ .read = rtl822x_hwmon_read, ++}; ++ ++static const struct hwmon_channel_info * const rtl822x_hwmon_info[] = { ++ HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX), ++ NULL ++}; ++ ++static const struct hwmon_chip_info rtl822x_hwmon_chip_info = { ++ .ops = &rtl822x_hwmon_ops, ++ .info = rtl822x_hwmon_info, ++}; ++ ++int rtl822x_hwmon_init(struct phy_device *phydev) ++{ ++ struct device *hwdev, *dev = &phydev->mdio.dev; ++ const char *name; ++ ++ /* Ensure over-temp alarm is reset. */ ++ phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSALRM, 3); ++ ++ name = devm_hwmon_sanitize_name(dev, dev_name(dev)); ++ if (IS_ERR(name)) ++ return PTR_ERR(name); ++ ++ hwdev = devm_hwmon_device_register_with_info(dev, name, phydev, ++ &rtl822x_hwmon_chip_info, ++ NULL); ++ return PTR_ERR_OR_ZERO(hwdev); ++} +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -14,6 +14,8 @@ + #include + #include + ++#include "realtek.h" ++ + #define RTL821x_PHYSR 0x11 + #define RTL821x_PHYSR_DUPLEX BIT(13) + #define RTL821x_PHYSR_SPEED GENMASK(15, 14) +@@ -820,6 +822,15 @@ static int rtl822x_write_mmd(struct phy_ + return ret; + } + ++static int rtl822x_probe(struct phy_device *phydev) ++{ ++ if (IS_ENABLED(CONFIG_REALTEK_PHY_HWMON) && ++ phydev->phy_id != RTL_GENERIC_PHYID) ++ return rtl822x_hwmon_init(phydev); ++ ++ return 0; ++} ++ + static int rtl822xb_config_init(struct phy_device *phydev) + { + bool has_2500, has_sgmii; +@@ -1518,6 +1529,7 @@ static struct phy_driver realtek_drvs[] + .match_phy_device = rtl_internal_nbaset_match_phy_device, + .name = "Realtek Internal NBASE-T PHY", + .flags = PHY_IS_INTERNAL, ++ .probe = rtl822x_probe, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .read_status = rtl822x_read_status, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-12-v6.14-net-phy-realtek-HWMON-support-for-standalone-version.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-12-v6.14-net-phy-realtek-HWMON-support-for-standalone-version.patch new file mode 100755 index 0000000..8b8c97c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-12-v6.14-net-phy-realtek-HWMON-support-for-standalone-version.patch @@ -0,0 +1,64 @@ +From 64ff63aeefb03139ae27454bd4208244579ae88e Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Fri, 17 Jan 2025 23:24:21 +0100 +Subject: [PATCH] net: phy: realtek: HWMON support for standalone versions of + RTL8221B and RTL8251 + +HWMON support has been added for the RTL8221/8251 PHYs integrated together +with the MAC inside the RTL8125/8126 chips. This patch extends temperature +reading support for standalone variants of the mentioned PHYs. + +I don't know whether the earlier revisions of the RTL8226 also have a +built-in temperature sensor, so they have been skipped for now. + +Tested on RTL8221B-VB-CG. + +Signed-off-by: Aleksander Jan Bajkowski +Reviewed-by: Andrew Lunn +Signed-off-by: David S. Miller +--- + drivers/net/phy/realtek/realtek_main.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1474,6 +1474,7 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", ++ .probe = rtl822x_probe, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, +@@ -1486,6 +1487,7 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", ++ .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, + .get_features = rtl822x_c45_get_features, +@@ -1496,6 +1498,7 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device, + .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", ++ .probe = rtl822x_probe, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, +@@ -1508,6 +1511,7 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device, + .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", ++ .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, + .get_features = rtl822x_c45_get_features, +@@ -1518,6 +1522,7 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8251b_c45_match_phy_device, + .name = "RTL8251B 5Gbps PHY", ++ .probe = rtl822x_probe, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .read_status = rtl822x_read_status, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-13-v6.15-net-phy-realtek-make-HWMON-support-a-user-visible-Kc.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-13-v6.15-net-phy-realtek-make-HWMON-support-a-user-visible-Kc.patch new file mode 100755 index 0000000..821d7ee --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-13-v6.15-net-phy-realtek-make-HWMON-support-a-user-visible-Kc.patch @@ -0,0 +1,35 @@ +From 51773846fab24a353bed4ebb660997ced4bc32d7 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 3 Feb 2025 21:33:39 +0100 +Subject: [PATCH] net: phy: realtek: make HWMON support a user-visible Kconfig + symbol + +Make config symbol REALTEK_PHY_HWMON user-visible, so that users can +remove support if not needed. + +Suggested-by: Geert Uytterhoeven +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/3466ee92-166a-4b0f-9ae7-42b9e046f333@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/Kconfig | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/realtek/Kconfig ++++ b/drivers/net/phy/realtek/Kconfig +@@ -4,8 +4,12 @@ config REALTEK_PHY + help + Currently supports RTL821x/RTL822x and fast ethernet PHYs + ++if REALTEK_PHY ++ + config REALTEK_PHY_HWMON +- def_bool REALTEK_PHY && HWMON +- depends on !(REALTEK_PHY=y && HWMON=m) ++ bool "HWMON support for Realtek PHYs" ++ depends on HWMON && !(REALTEK_PHY=y && HWMON=m) + help + Optional hwmon support for the temperature sensor ++ ++endif # REALTEK_PHY diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-14-v6.15-net-phy-realtek-use-string-choices-helpers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-14-v6.15-net-phy-realtek-use-string-choices-helpers.patch new file mode 100755 index 0000000..d3e09bc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-14-v6.15-net-phy-realtek-use-string-choices-helpers.patch @@ -0,0 +1,54 @@ +From 0bea93fdbaf8675b7e8124bdcaf51497dcc8bcfa Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Mon, 3 Feb 2025 21:41:36 +0100 +Subject: [PATCH] net: phy: realtek: use string choices helpers + +Use string choices helpers to simplify the code. + +Reported-by: kernel test robot +Closes: https://lore.kernel.org/oe-kbuild-all/202501190707.qQS8PGHW-lkp@intel.com/ +Signed-off-by: Heiner Kallweit +Reviewed-by: Simon Horman +Signed-off-by: David S. Miller +--- + drivers/net/phy/realtek/realtek_main.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + + #include "realtek.h" + +@@ -422,11 +423,11 @@ static int rtl8211f_config_init(struct p + } else if (ret) { + dev_dbg(dev, + "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n", +- val_txdly ? "Enabling" : "Disabling"); ++ str_enable_disable(val_txdly)); + } else { + dev_dbg(dev, + "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n", +- val_txdly ? "enabled" : "disabled"); ++ str_enabled_disabled(val_txdly)); + } + + ret = phy_modify_paged_changed(phydev, 0xd08, 0x15, RTL8211F_RX_DELAY, +@@ -437,11 +438,11 @@ static int rtl8211f_config_init(struct p + } else if (ret) { + dev_dbg(dev, + "%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n", +- val_rxdly ? "Enabling" : "Disabling"); ++ str_enable_disable(val_rxdly)); + } else { + dev_dbg(dev, + "2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n", +- val_rxdly ? "enabled" : "disabled"); ++ str_enabled_disabled(val_rxdly)); + } + + if (priv->has_phycr2) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-15-v6.15-net-phy-realtek-improve-mmd-register-access-for-inte.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-15-v6.15-net-phy-realtek-improve-mmd-register-access-for-inte.patch new file mode 100755 index 0000000..3a3a20d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-15-v6.15-net-phy-realtek-improve-mmd-register-access-for-inte.patch @@ -0,0 +1,134 @@ +From da681ed73fb980286fc29de707b35d76bb33e123 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 13 Feb 2025 20:18:17 +0100 +Subject: [PATCH] net: phy: realtek: improve mmd register access for internal + PHY's + +r8169 provides the MDIO bus for the internal PHY's. It has been extended +with c45 access functions for addressing MDIO_MMD_VEND2 registers. +So we can switch from paged access to directly addressing the +MDIO_MMD_VEND2 registers. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/a5f2333c-dda9-48ad-9801-77049766e632@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 79 +++++++++++--------------- + 1 file changed, 33 insertions(+), 46 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -735,29 +735,31 @@ static int rtlgen_read_status(struct phy + return 0; + } + ++static int rtlgen_read_vend2(struct phy_device *phydev, int regnum) ++{ ++ return __mdiobus_c45_read(phydev->mdio.bus, 0, MDIO_MMD_VEND2, regnum); ++} ++ ++static int rtlgen_write_vend2(struct phy_device *phydev, int regnum, u16 val) ++{ ++ return __mdiobus_c45_write(phydev->mdio.bus, 0, MDIO_MMD_VEND2, regnum, ++ val); ++} ++ + static int rtlgen_read_mmd(struct phy_device *phydev, int devnum, u16 regnum) + { + int ret; + +- if (devnum == MDIO_MMD_VEND2) { +- rtl821x_write_page(phydev, regnum >> 4); +- ret = __phy_read(phydev, 0x10 + ((regnum & 0xf) >> 1)); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) { +- rtl821x_write_page(phydev, 0xa5c); +- ret = __phy_read(phydev, 0x12); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { +- rtl821x_write_page(phydev, 0xa5d); +- ret = __phy_read(phydev, 0x10); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE) { +- rtl821x_write_page(phydev, 0xa5d); +- ret = __phy_read(phydev, 0x11); +- rtl821x_write_page(phydev, 0); +- } else { ++ if (devnum == MDIO_MMD_VEND2) ++ ret = rtlgen_read_vend2(phydev, regnum); ++ else if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) ++ ret = rtlgen_read_vend2(phydev, 0xa5c4); ++ else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) ++ ret = rtlgen_read_vend2(phydev, 0xa5d0); ++ else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE) ++ ret = rtlgen_read_vend2(phydev, 0xa5d2); ++ else + ret = -EOPNOTSUPP; +- } + + return ret; + } +@@ -767,17 +769,12 @@ static int rtlgen_write_mmd(struct phy_d + { + int ret; + +- if (devnum == MDIO_MMD_VEND2) { +- rtl821x_write_page(phydev, regnum >> 4); +- ret = __phy_write(phydev, 0x10 + ((regnum & 0xf) >> 1), val); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) { +- rtl821x_write_page(phydev, 0xa5d); +- ret = __phy_write(phydev, 0x10, val); +- rtl821x_write_page(phydev, 0); +- } else { ++ if (devnum == MDIO_MMD_VEND2) ++ ret = rtlgen_write_vend2(phydev, regnum, val); ++ else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) ++ ret = rtlgen_write_vend2(phydev, regnum, 0xa5d0); ++ else + ret = -EOPNOTSUPP; +- } + + return ret; + } +@@ -789,19 +786,12 @@ static int rtl822x_read_mmd(struct phy_d + if (ret != -EOPNOTSUPP) + return ret; + +- if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE2) { +- rtl821x_write_page(phydev, 0xa6e); +- ret = __phy_read(phydev, 0x16); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) { +- rtl821x_write_page(phydev, 0xa6d); +- ret = __phy_read(phydev, 0x12); +- rtl821x_write_page(phydev, 0); +- } else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE2) { +- rtl821x_write_page(phydev, 0xa6d); +- ret = __phy_read(phydev, 0x10); +- rtl821x_write_page(phydev, 0); +- } ++ if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE2) ++ ret = rtlgen_read_vend2(phydev, 0xa6ec); ++ else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) ++ ret = rtlgen_read_vend2(phydev, 0xa6d4); ++ else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE2) ++ ret = rtlgen_read_vend2(phydev, 0xa6d0); + + return ret; + } +@@ -814,11 +804,8 @@ static int rtl822x_write_mmd(struct phy_ + if (ret != -EOPNOTSUPP) + return ret; + +- if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) { +- rtl821x_write_page(phydev, 0xa6d); +- ret = __phy_write(phydev, 0x12, val); +- rtl821x_write_page(phydev, 0); +- } ++ if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) ++ ret = rtlgen_write_vend2(phydev, 0xa6d4, val); + + return ret; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-16-v6.15-net-phy-realtek-switch-from-paged-to-MMD-ops-in-rtl8.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-16-v6.15-net-phy-realtek-switch-from-paged-to-MMD-ops-in-rtl8.patch new file mode 100755 index 0000000..5e3c3ce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-16-v6.15-net-phy-realtek-switch-from-paged-to-MMD-ops-in-rtl8.patch @@ -0,0 +1,52 @@ +From 02d3b306ac2f0b174753d1c5b9e4e5fb8ec5057e Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 13 Feb 2025 20:19:14 +0100 +Subject: [PATCH] net: phy: realtek: switch from paged to MMD ops in rtl822x + functions + +The MDIO bus provided by r8169 for the internal PHY's now supports +c45 ops for the MDIO_MMD_VEND2 device. So we can switch to standard +MMD ops here. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/81416f95-0fac-4225-87b4-828e3738b8ed@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -901,7 +901,7 @@ static int rtl822x_get_features(struct p + { + int val; + +- val = phy_read_paged(phydev, 0xa61, 0x13); ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa616); + if (val < 0) + return val; + +@@ -922,10 +922,9 @@ static int rtl822x_config_aneg(struct ph + if (phydev->autoneg == AUTONEG_ENABLE) { + u16 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); + +- ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12, +- MDIO_AN_10GBT_CTRL_ADV2_5G | +- MDIO_AN_10GBT_CTRL_ADV5G, +- adv); ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, 0xa5d4, ++ MDIO_AN_10GBT_CTRL_ADV2_5G | ++ MDIO_AN_10GBT_CTRL_ADV5G, adv); + if (ret < 0) + return ret; + } +@@ -969,7 +968,7 @@ static int rtl822x_read_status(struct ph + !phydev->autoneg_complete) + return 0; + +- lpadv = phy_read_paged(phydev, 0xa5d, 0x13); ++ lpadv = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa5d6); + if (lpadv < 0) + return lpadv; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-17-v6.15-net-phy-realtek-add-helper-RTL822X_VND2_C22_REG.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-17-v6.15-net-phy-realtek-add-helper-RTL822X_VND2_C22_REG.patch new file mode 100755 index 0000000..5134d08 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-17-v6.15-net-phy-realtek-add-helper-RTL822X_VND2_C22_REG.patch @@ -0,0 +1,48 @@ +From 8af2136e77989a64fae0284bf76fd584e32edd3a Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Fri, 14 Feb 2025 21:31:14 +0100 +Subject: [PATCH] net: phy: realtek: add helper RTL822X_VND2_C22_REG + +C22 register space is mapped to 0xa400 in MMD VEND2 register space. +Add a helper to access mapped C22 registers. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/6344277b-c5c7-449b-ac89-d5425306ca76@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -79,9 +79,7 @@ + /* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 + * is set, they cannot be accessed by C45-over-C22. + */ +-#define RTL822X_VND2_GBCR 0xa412 +- +-#define RTL822X_VND2_GANLPAR 0xa414 ++#define RTL822X_VND2_C22_REG(reg) (0xa400 + 2 * (reg)) + + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) +@@ -1015,7 +1013,8 @@ static int rtl822x_c45_config_aneg(struc + val = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); + + /* Vendor register as C45 has no standardized support for 1000BaseT */ +- ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL822X_VND2_GBCR, ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(MII_CTRL1000), + ADVERTISE_1000FULL, val); + if (ret < 0) + return ret; +@@ -1032,7 +1031,7 @@ static int rtl822x_c45_read_status(struc + /* Vendor register as C45 has no standardized support for 1000BaseT */ + if (phydev->autoneg == AUTONEG_ENABLE && genphy_c45_aneg_done(phydev)) { + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, +- RTL822X_VND2_GANLPAR); ++ RTL822X_VND2_C22_REG(MII_STAT1000)); + if (val < 0) + return val; + } else { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-18-v6.15-net-phy-realtek-add-defines-for-shadowed-c45-standar.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-18-v6.15-net-phy-realtek-add-defines-for-shadowed-c45-standar.patch new file mode 100755 index 0000000..ff7d5b1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-18-v6.15-net-phy-realtek-add-defines-for-shadowed-c45-standar.patch @@ -0,0 +1,113 @@ +From fabcfd6d10999024a721ae1b965b57eb8a305ace Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 15 Feb 2025 14:29:15 +0100 +Subject: [PATCH] net: phy: realtek: add defines for shadowed c45 standard + registers + +Realtek shadows standard c45 registers in VEND2 device register space. +Add defines for these VEND2 registers, based on the names of the +standard c45 registers. + +Signed-off-by: Heiner Kallweit +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/c90bdf76-f8b8-4d06-9656-7a52d5658ee6@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 33 +++++++++++++++++--------- + 1 file changed, 22 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -94,6 +94,16 @@ + #define RTL_VND2_PHYSR_MASTER BIT(11) + #define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR_SPEEDH) + ++#define RTL_MDIO_PCS_EEE_ABLE 0xa5c4 ++#define RTL_MDIO_AN_EEE_ADV 0xa5d0 ++#define RTL_MDIO_AN_EEE_LPABLE 0xa5d2 ++#define RTL_MDIO_AN_10GBT_CTRL 0xa5d4 ++#define RTL_MDIO_AN_10GBT_STAT 0xa5d6 ++#define RTL_MDIO_PMA_SPEED 0xa616 ++#define RTL_MDIO_AN_EEE_LPABLE2 0xa6d0 ++#define RTL_MDIO_AN_EEE_ADV2 0xa6d4 ++#define RTL_MDIO_PCS_EEE_ABLE2 0xa6ec ++ + #define RTL_GENERIC_PHYID 0x001cc800 + #define RTL_8211FVD_PHYID 0x001cc878 + #define RTL_8221B 0x001cc840 +@@ -751,11 +761,11 @@ static int rtlgen_read_mmd(struct phy_de + if (devnum == MDIO_MMD_VEND2) + ret = rtlgen_read_vend2(phydev, regnum); + else if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE) +- ret = rtlgen_read_vend2(phydev, 0xa5c4); ++ ret = rtlgen_read_vend2(phydev, RTL_MDIO_PCS_EEE_ABLE); + else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) +- ret = rtlgen_read_vend2(phydev, 0xa5d0); ++ ret = rtlgen_read_vend2(phydev, RTL_MDIO_AN_EEE_ADV); + else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE) +- ret = rtlgen_read_vend2(phydev, 0xa5d2); ++ ret = rtlgen_read_vend2(phydev, RTL_MDIO_AN_EEE_LPABLE); + else + ret = -EOPNOTSUPP; + +@@ -770,7 +780,7 @@ static int rtlgen_write_mmd(struct phy_d + if (devnum == MDIO_MMD_VEND2) + ret = rtlgen_write_vend2(phydev, regnum, val); + else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV) +- ret = rtlgen_write_vend2(phydev, regnum, 0xa5d0); ++ ret = rtlgen_write_vend2(phydev, regnum, RTL_MDIO_AN_EEE_ADV); + else + ret = -EOPNOTSUPP; + +@@ -785,11 +795,11 @@ static int rtl822x_read_mmd(struct phy_d + return ret; + + if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE2) +- ret = rtlgen_read_vend2(phydev, 0xa6ec); ++ ret = rtlgen_read_vend2(phydev, RTL_MDIO_PCS_EEE_ABLE2); + else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) +- ret = rtlgen_read_vend2(phydev, 0xa6d4); ++ ret = rtlgen_read_vend2(phydev, RTL_MDIO_AN_EEE_ADV2); + else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE2) +- ret = rtlgen_read_vend2(phydev, 0xa6d0); ++ ret = rtlgen_read_vend2(phydev, RTL_MDIO_AN_EEE_LPABLE2); + + return ret; + } +@@ -803,7 +813,7 @@ static int rtl822x_write_mmd(struct phy_ + return ret; + + if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) +- ret = rtlgen_write_vend2(phydev, 0xa6d4, val); ++ ret = rtlgen_write_vend2(phydev, RTL_MDIO_AN_EEE_ADV2, val); + + return ret; + } +@@ -899,7 +909,7 @@ static int rtl822x_get_features(struct p + { + int val; + +- val = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa616); ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_MDIO_PMA_SPEED); + if (val < 0) + return val; + +@@ -920,7 +930,8 @@ static int rtl822x_config_aneg(struct ph + if (phydev->autoneg == AUTONEG_ENABLE) { + u16 adv = linkmode_adv_to_mii_10gbt_adv_t(phydev->advertising); + +- ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, 0xa5d4, ++ ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, ++ RTL_MDIO_AN_10GBT_CTRL, + MDIO_AN_10GBT_CTRL_ADV2_5G | + MDIO_AN_10GBT_CTRL_ADV5G, adv); + if (ret < 0) +@@ -966,7 +977,7 @@ static int rtl822x_read_status(struct ph + !phydev->autoneg_complete) + return 0; + +- lpadv = phy_read_mmd(phydev, MDIO_MMD_VEND2, 0xa5d6); ++ lpadv = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_MDIO_AN_10GBT_STAT); + if (lpadv < 0) + return lpadv; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-19-v6.15-net-phy-realtek-disable-PHY-mode-EEE.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-19-v6.15-net-phy-realtek-disable-PHY-mode-EEE.patch new file mode 100755 index 0000000..4d755d4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-19-v6.15-net-phy-realtek-disable-PHY-mode-EEE.patch @@ -0,0 +1,54 @@ +From bfc17c1658353f22843c7c13e27c2d31950f1887 Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Sun, 16 Mar 2025 12:39:54 +0000 +Subject: [PATCH] net: phy: realtek: disable PHY-mode EEE + +Realtek RTL8211F has a "PHY-mode" EEE support which interferes with an +IEEE 802.3 compliant implementation. This mode defaults to enabled, and +results in the MAC receive path not seeing the link transition to LPI +state. + +Fix this by disabling PHY-mode EEE. + +Signed-off-by: Russell King (Oracle) +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/E1ttnHW-00785s-Uq@rmk-PC.armlinux.org.uk +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -33,6 +33,9 @@ + + #define RTL8211F_PHYCR1 0x18 + #define RTL8211F_PHYCR2 0x19 ++#define RTL8211F_CLKOUT_EN BIT(0) ++#define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) ++ + #define RTL8211F_INSR 0x1d + + #define RTL8211F_LEDCR 0x10 +@@ -55,8 +58,6 @@ + #define RTL8211E_TX_DELAY BIT(12) + #define RTL8211E_RX_DELAY BIT(11) + +-#define RTL8211F_CLKOUT_EN BIT(0) +- + #define RTL8201F_ISR 0x1e + #define RTL8201F_ISR_ANERR BIT(15) + #define RTL8201F_ISR_DUPLEX BIT(13) +@@ -453,6 +454,12 @@ static int rtl8211f_config_init(struct p + str_enabled_disabled(val_rxdly)); + } + ++ /* Disable PHY-mode EEE so LPI is passed to the MAC */ ++ ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, ++ RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); ++ if (ret) ++ return ret; ++ + if (priv->has_phycr2) { + ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, + RTL8211F_CLKOUT_EN, priv->phycr2); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-20-v6.16-net-phy-realtek-Add-support-for-WOL-magic-packet-on.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-20-v6.16-net-phy-realtek-Add-support-for-WOL-magic-packet-on.patch new file mode 100755 index 0000000..4ba06cc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-20-v6.16-net-phy-realtek-Add-support-for-WOL-magic-packet-on.patch @@ -0,0 +1,126 @@ +From 7840e4d6f48a75413470935ebdc4bab4fc0c035e Mon Sep 17 00:00:00 2001 +From: Daniel Braunwarth +Date: Tue, 29 Apr 2025 13:33:37 +0200 +Subject: [PATCH] net: phy: realtek: Add support for WOL magic packet on + RTL8211F + +The RTL8211F supports multiple WOL modes. This patch adds support for +magic packets. + +The PHY notifies the system via the INTB/PMEB pin when a WOL event +occurs. + +Signed-off-by: Daniel Braunwarth +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250429-realtek_wol-v2-1-8f84def1ef2c@kuka.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 69 ++++++++++++++++++++++++++ + 1 file changed, 69 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -38,6 +39,24 @@ + + #define RTL8211F_INSR 0x1d + ++/* RTL8211F WOL interrupt configuration */ ++#define RTL8211F_INTBCR_PAGE 0xd40 ++#define RTL8211F_INTBCR 0x16 ++#define RTL8211F_INTBCR_INTB_PMEB BIT(5) ++ ++/* RTL8211F WOL settings */ ++#define RTL8211F_WOL_SETTINGS_PAGE 0xd8a ++#define RTL8211F_WOL_SETTINGS_EVENTS 16 ++#define RTL8211F_WOL_EVENT_MAGIC BIT(12) ++#define RTL8211F_WOL_SETTINGS_STATUS 17 ++#define RTL8211F_WOL_STATUS_RESET (BIT(15) | 0x1fff) ++ ++/* RTL8211F Unique phyiscal and multicast address (WOL) */ ++#define RTL8211F_PHYSICAL_ADDR_PAGE 0xd8c ++#define RTL8211F_PHYSICAL_ADDR_WORD0 16 ++#define RTL8211F_PHYSICAL_ADDR_WORD1 17 ++#define RTL8211F_PHYSICAL_ADDR_WORD2 18 ++ + #define RTL8211F_LEDCR 0x10 + #define RTL8211F_LEDCR_MODE BIT(15) + #define RTL8211F_LEDCR_ACT_TXRX BIT(4) +@@ -123,6 +142,7 @@ struct rtl821x_priv { + u16 phycr2; + bool has_phycr2; + struct clk *clk; ++ u32 saved_wolopts; + }; + + static int rtl821x_read_page(struct phy_device *phydev) +@@ -354,6 +374,53 @@ static irqreturn_t rtl8211f_handle_inter + return IRQ_HANDLED; + } + ++static void rtl8211f_get_wol(struct phy_device *dev, struct ethtool_wolinfo *wol) ++{ ++ wol->supported = WAKE_MAGIC; ++ if (phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS) ++ & RTL8211F_WOL_EVENT_MAGIC) ++ wol->wolopts = WAKE_MAGIC; ++} ++ ++static int rtl8211f_set_wol(struct phy_device *dev, struct ethtool_wolinfo *wol) ++{ ++ const u8 *mac_addr = dev->attached_dev->dev_addr; ++ int oldpage; ++ ++ oldpage = phy_save_page(dev); ++ if (oldpage < 0) ++ goto err; ++ ++ if (wol->wolopts & WAKE_MAGIC) { ++ /* Store the device address for the magic packet */ ++ rtl821x_write_page(dev, RTL8211F_PHYSICAL_ADDR_PAGE); ++ __phy_write(dev, RTL8211F_PHYSICAL_ADDR_WORD0, mac_addr[1] << 8 | (mac_addr[0])); ++ __phy_write(dev, RTL8211F_PHYSICAL_ADDR_WORD1, mac_addr[3] << 8 | (mac_addr[2])); ++ __phy_write(dev, RTL8211F_PHYSICAL_ADDR_WORD2, mac_addr[5] << 8 | (mac_addr[4])); ++ ++ /* Enable magic packet matching and reset WOL status */ ++ rtl821x_write_page(dev, RTL8211F_WOL_SETTINGS_PAGE); ++ __phy_write(dev, RTL8211F_WOL_SETTINGS_EVENTS, RTL8211F_WOL_EVENT_MAGIC); ++ __phy_write(dev, RTL8211F_WOL_SETTINGS_STATUS, RTL8211F_WOL_STATUS_RESET); ++ ++ /* Enable the WOL interrupt */ ++ rtl821x_write_page(dev, RTL8211F_INTBCR_PAGE); ++ __phy_set_bits(dev, RTL8211F_INTBCR, RTL8211F_INTBCR_INTB_PMEB); ++ } else { ++ /* Disable the WOL interrupt */ ++ rtl821x_write_page(dev, RTL8211F_INTBCR_PAGE); ++ __phy_clear_bits(dev, RTL8211F_INTBCR, RTL8211F_INTBCR_INTB_PMEB); ++ ++ /* Disable magic packet matching and reset WOL status */ ++ rtl821x_write_page(dev, RTL8211F_WOL_SETTINGS_PAGE); ++ __phy_write(dev, RTL8211F_WOL_SETTINGS_EVENTS, 0); ++ __phy_write(dev, RTL8211F_WOL_SETTINGS_STATUS, RTL8211F_WOL_STATUS_RESET); ++ } ++ ++err: ++ return phy_restore_page(dev, oldpage, 0); ++} ++ + static int rtl8211_config_aneg(struct phy_device *phydev) + { + int ret; +@@ -1400,6 +1467,8 @@ static struct phy_driver realtek_drvs[] + .read_status = rtlgen_read_status, + .config_intr = &rtl8211f_config_intr, + .handle_interrupt = rtl8211f_handle_interrupt, ++ .set_wol = rtl8211f_set_wol, ++ .get_wol = rtl8211f_get_wol, + .suspend = rtl821x_suspend, + .resume = rtl821x_resume, + .read_page = rtl821x_read_page, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-21-v6.16-net-phy-realtek-remove-unsed-RTL821x_PHYSR-macros.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-21-v6.16-net-phy-realtek-remove-unsed-RTL821x_PHYSR-macros.patch new file mode 100755 index 0000000..e054937 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-21-v6.16-net-phy-realtek-remove-unsed-RTL821x_PHYSR-macros.patch @@ -0,0 +1,28 @@ +From f3b265358b911fe9e495619bdfa7797749474f95 Mon Sep 17 00:00:00 2001 +From: Michael Klein +Date: Sun, 4 May 2025 19:29:11 +0200 +Subject: [PATCH] net: phy: realtek: remove unsed RTL821x_PHYSR* macros + +These macros have there since the first revision but were never used, so +let's just remove them. + +Signed-off-by: Michael Klein +Link: https://patch.msgid.link/20250504172916.243185-2-michael@fossekall.de +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 4 ---- + 1 file changed, 4 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -18,10 +18,6 @@ + + #include "realtek.h" + +-#define RTL821x_PHYSR 0x11 +-#define RTL821x_PHYSR_DUPLEX BIT(13) +-#define RTL821x_PHYSR_SPEED GENMASK(15, 14) +- + #define RTL821x_INER 0x12 + #define RTL8211B_INER_INIT 0x6400 + #define RTL8211E_INER_LINK_STATUS BIT(10) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-22-v6.16-net-phy-realtek-Clean-up-RTL821x-ExtPage-access.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-22-v6.16-net-phy-realtek-Clean-up-RTL821x-ExtPage-access.patch new file mode 100755 index 0000000..62bbf32 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-22-v6.16-net-phy-realtek-Clean-up-RTL821x-ExtPage-access.patch @@ -0,0 +1,95 @@ +From 7c6fa3ffd2650347b1d37f028e232e53d617c1af Mon Sep 17 00:00:00 2001 +From: Michael Klein +Date: Sun, 4 May 2025 19:29:12 +0200 +Subject: [PATCH] net: phy: realtek: Clean up RTL821x ExtPage access + +Factor out RTL8211E extension page access code to +rtl821x_modify_ext_page() and clean up rtl8211e_config_init() + +Signed-off-by: Michael Klein +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250504172916.243185-3-michael@fossekall.de +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 38 ++++++++++++++++---------- + 1 file changed, 23 insertions(+), 15 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -26,7 +26,9 @@ + #define RTL821x_INSR 0x13 + + #define RTL821x_EXT_PAGE_SELECT 0x1e ++ + #define RTL821x_PAGE_SELECT 0x1f ++#define RTL821x_SET_EXT_PAGE 0x07 + + #define RTL8211F_PHYCR1 0x18 + #define RTL8211F_PHYCR2 0x19 +@@ -69,9 +71,12 @@ + #define RTL8211F_ALDPS_ENABLE BIT(2) + #define RTL8211F_ALDPS_XTAL_OFF BIT(12) + ++#define RTL8211E_RGMII_EXT_PAGE 0xa4 ++#define RTL8211E_RGMII_DELAY 0x1c + #define RTL8211E_CTRL_DELAY BIT(13) + #define RTL8211E_TX_DELAY BIT(12) + #define RTL8211E_RX_DELAY BIT(11) ++#define RTL8211E_DELAY_MASK GENMASK(13, 11) + + #define RTL8201F_ISR 0x1e + #define RTL8201F_ISR_ANERR BIT(15) +@@ -151,6 +156,21 @@ static int rtl821x_write_page(struct phy + return __phy_write(phydev, RTL821x_PAGE_SELECT, page); + } + ++static int rtl821x_modify_ext_page(struct phy_device *phydev, u16 ext_page, ++ u32 regnum, u16 mask, u16 set) ++{ ++ int oldpage, ret = 0; ++ ++ oldpage = phy_select_page(phydev, RTL821x_SET_EXT_PAGE); ++ if (oldpage >= 0) { ++ ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, ext_page); ++ if (ret == 0) ++ ret = __phy_modify(phydev, regnum, mask, set); ++ } ++ ++ return phy_restore_page(phydev, oldpage, ret); ++} ++ + static int rtl821x_probe(struct phy_device *phydev) + { + struct device *dev = &phydev->mdio.dev; +@@ -670,7 +690,6 @@ static int rtl8211f_led_hw_control_set(s + + static int rtl8211e_config_init(struct phy_device *phydev) + { +- int ret = 0, oldpage; + u16 val; + + /* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */ +@@ -700,20 +719,9 @@ static int rtl8211e_config_init(struct p + * 12 = RX Delay, 11 = TX Delay + * 10:0 = Test && debug settings reserved by realtek + */ +- oldpage = phy_select_page(phydev, 0x7); +- if (oldpage < 0) +- goto err_restore_page; +- +- ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, 0xa4); +- if (ret) +- goto err_restore_page; +- +- ret = __phy_modify(phydev, 0x1c, RTL8211E_CTRL_DELAY +- | RTL8211E_TX_DELAY | RTL8211E_RX_DELAY, +- val); +- +-err_restore_page: +- return phy_restore_page(phydev, oldpage, ret); ++ return rtl821x_modify_ext_page(phydev, RTL8211E_RGMII_EXT_PAGE, ++ RTL8211E_RGMII_DELAY, ++ RTL8211E_DELAY_MASK, val); + } + + static int rtl8211b_suspend(struct phy_device *phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-23-v6.16-net-phy-realtek-add-RTL8211F-register-defines.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-23-v6.16-net-phy-realtek-add-RTL8211F-register-defines.patch new file mode 100755 index 0000000..9116992 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-23-v6.16-net-phy-realtek-add-RTL8211F-register-defines.patch @@ -0,0 +1,139 @@ +From 12d40df259e38851a0d973535e6023b33e2ea4f9 Mon Sep 17 00:00:00 2001 +From: Michael Klein +Date: Sun, 4 May 2025 19:29:13 +0200 +Subject: [PATCH] net: phy: realtek: add RTL8211F register defines + +Add some more defines for RTL8211F page and register numbers. + +Signed-off-by: Michael Klein +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250504172916.243185-4-michael@fossekall.de +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 34 ++++++++++++++++++-------- + 1 file changed, 24 insertions(+), 10 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -30,11 +30,14 @@ + #define RTL821x_PAGE_SELECT 0x1f + #define RTL821x_SET_EXT_PAGE 0x07 + ++/* RTL8211F PHY configuration */ ++#define RTL8211F_PHYCR_PAGE 0xa43 + #define RTL8211F_PHYCR1 0x18 + #define RTL8211F_PHYCR2 0x19 + #define RTL8211F_CLKOUT_EN BIT(0) + #define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) + ++#define RTL8211F_INSR_PAGE 0xa43 + #define RTL8211F_INSR 0x1d + + /* RTL8211F WOL interrupt configuration */ +@@ -55,6 +58,8 @@ + #define RTL8211F_PHYSICAL_ADDR_WORD1 17 + #define RTL8211F_PHYSICAL_ADDR_WORD2 18 + ++/* RTL8211F LED configuration */ ++#define RTL8211F_LEDCR_PAGE 0xd04 + #define RTL8211F_LEDCR 0x10 + #define RTL8211F_LEDCR_MODE BIT(15) + #define RTL8211F_LEDCR_ACT_TXRX BIT(4) +@@ -64,7 +69,13 @@ + #define RTL8211F_LEDCR_MASK GENMASK(4, 0) + #define RTL8211F_LEDCR_SHIFT 5 + ++/* RTL8211F RGMII configuration */ ++#define RTL8211F_RGMII_PAGE 0xd08 ++ ++#define RTL8211F_TXCR 0x11 + #define RTL8211F_TX_DELAY BIT(8) ++ ++#define RTL8211F_RXCR 0x15 + #define RTL8211F_RX_DELAY BIT(3) + + #define RTL8211F_ALDPS_PLL_OFF BIT(1) +@@ -187,7 +198,7 @@ static int rtl821x_probe(struct phy_devi + return dev_err_probe(dev, PTR_ERR(priv->clk), + "failed to get phy clock\n"); + +- ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); ++ ret = phy_read_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1); + if (ret < 0) + return ret; + +@@ -197,7 +208,7 @@ static int rtl821x_probe(struct phy_devi + + priv->has_phycr2 = !(phy_id == RTL_8211FVD_PHYID); + if (priv->has_phycr2) { +- ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2); ++ ret = phy_read_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2); + if (ret < 0) + return ret; + +@@ -233,7 +244,7 @@ static int rtl8211f_ack_interrupt(struct + { + int err; + +- err = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); ++ err = phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); + + return (err < 0) ? err : 0; + } +@@ -376,7 +387,7 @@ static irqreturn_t rtl8211f_handle_inter + { + int irq_status; + +- irq_status = phy_read_paged(phydev, 0xa43, RTL8211F_INSR); ++ irq_status = phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; +@@ -473,7 +484,7 @@ static int rtl8211f_config_init(struct p + u16 val_txdly, val_rxdly; + int ret; + +- ret = phy_modify_paged_changed(phydev, 0xa43, RTL8211F_PHYCR1, ++ ret = phy_modify_paged_changed(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, + RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF, + priv->phycr1); + if (ret < 0) { +@@ -507,7 +518,8 @@ static int rtl8211f_config_init(struct p + return 0; + } + +- ret = phy_modify_paged_changed(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, ++ ret = phy_modify_paged_changed(phydev, RTL8211F_RGMII_PAGE, ++ RTL8211F_TXCR, RTL8211F_TX_DELAY, + val_txdly); + if (ret < 0) { + dev_err(dev, "Failed to update the TX delay register\n"); +@@ -522,7 +534,8 @@ static int rtl8211f_config_init(struct p + str_enabled_disabled(val_txdly)); + } + +- ret = phy_modify_paged_changed(phydev, 0xd08, 0x15, RTL8211F_RX_DELAY, ++ ret = phy_modify_paged_changed(phydev, RTL8211F_RGMII_PAGE, ++ RTL8211F_RXCR, RTL8211F_RX_DELAY, + val_rxdly); + if (ret < 0) { + dev_err(dev, "Failed to update the RX delay register\n"); +@@ -538,14 +551,15 @@ static int rtl8211f_config_init(struct p + } + + /* Disable PHY-mode EEE so LPI is passed to the MAC */ +- ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, ++ ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, + RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); + if (ret) + return ret; + + if (priv->has_phycr2) { +- ret = phy_modify_paged(phydev, 0xa43, RTL8211F_PHYCR2, +- RTL8211F_CLKOUT_EN, priv->phycr2); ++ ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, ++ RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, ++ priv->phycr2); + if (ret < 0) { + dev_err(dev, "clkout configuration failed: %pe\n", + ERR_PTR(ret)); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-24-v6.16-net-phy-realtek-Group-RTL82-macro-definitions.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-24-v6.16-net-phy-realtek-Group-RTL82-macro-definitions.patch new file mode 100755 index 0000000..0319a2b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-24-v6.16-net-phy-realtek-Group-RTL82-macro-definitions.patch @@ -0,0 +1,123 @@ +From 8c4d0172657c1f2d86b9c19172150abcd0e35c39 Mon Sep 17 00:00:00 2001 +From: Michael Klein +Date: Sun, 4 May 2025 19:29:14 +0200 +Subject: [PATCH] net: phy: realtek: Group RTL82* macro definitions + +Group macro definitions by PHY in lexicographic order. Within each PHY +block, definitions are order by page number and then register number. + +Signed-off-by: Michael Klein +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250504172916.243185-5-michael@fossekall.de +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 72 +++++++++++++------------- + 1 file changed, 37 insertions(+), 35 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -18,6 +18,16 @@ + + #include "realtek.h" + ++#define RTL8201F_IER 0x13 ++ ++#define RTL8201F_ISR 0x1e ++#define RTL8201F_ISR_ANERR BIT(15) ++#define RTL8201F_ISR_DUPLEX BIT(13) ++#define RTL8201F_ISR_LINK BIT(11) ++#define RTL8201F_ISR_MASK (RTL8201F_ISR_ANERR | \ ++ RTL8201F_ISR_DUPLEX | \ ++ RTL8201F_ISR_LINK) ++ + #define RTL821x_INER 0x12 + #define RTL8211B_INER_INIT 0x6400 + #define RTL8211E_INER_LINK_STATUS BIT(10) +@@ -30,9 +40,21 @@ + #define RTL821x_PAGE_SELECT 0x1f + #define RTL821x_SET_EXT_PAGE 0x07 + ++/* RTL8211E extension page 164/0xa4 */ ++#define RTL8211E_RGMII_EXT_PAGE 0xa4 ++#define RTL8211E_RGMII_DELAY 0x1c ++#define RTL8211E_CTRL_DELAY BIT(13) ++#define RTL8211E_TX_DELAY BIT(12) ++#define RTL8211E_RX_DELAY BIT(11) ++#define RTL8211E_DELAY_MASK GENMASK(13, 11) ++ + /* RTL8211F PHY configuration */ + #define RTL8211F_PHYCR_PAGE 0xa43 + #define RTL8211F_PHYCR1 0x18 ++#define RTL8211F_ALDPS_PLL_OFF BIT(1) ++#define RTL8211F_ALDPS_ENABLE BIT(2) ++#define RTL8211F_ALDPS_XTAL_OFF BIT(12) ++ + #define RTL8211F_PHYCR2 0x19 + #define RTL8211F_CLKOUT_EN BIT(0) + #define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) +@@ -40,24 +62,6 @@ + #define RTL8211F_INSR_PAGE 0xa43 + #define RTL8211F_INSR 0x1d + +-/* RTL8211F WOL interrupt configuration */ +-#define RTL8211F_INTBCR_PAGE 0xd40 +-#define RTL8211F_INTBCR 0x16 +-#define RTL8211F_INTBCR_INTB_PMEB BIT(5) +- +-/* RTL8211F WOL settings */ +-#define RTL8211F_WOL_SETTINGS_PAGE 0xd8a +-#define RTL8211F_WOL_SETTINGS_EVENTS 16 +-#define RTL8211F_WOL_EVENT_MAGIC BIT(12) +-#define RTL8211F_WOL_SETTINGS_STATUS 17 +-#define RTL8211F_WOL_STATUS_RESET (BIT(15) | 0x1fff) +- +-/* RTL8211F Unique phyiscal and multicast address (WOL) */ +-#define RTL8211F_PHYSICAL_ADDR_PAGE 0xd8c +-#define RTL8211F_PHYSICAL_ADDR_WORD0 16 +-#define RTL8211F_PHYSICAL_ADDR_WORD1 17 +-#define RTL8211F_PHYSICAL_ADDR_WORD2 18 +- + /* RTL8211F LED configuration */ + #define RTL8211F_LEDCR_PAGE 0xd04 + #define RTL8211F_LEDCR 0x10 +@@ -78,25 +82,23 @@ + #define RTL8211F_RXCR 0x15 + #define RTL8211F_RX_DELAY BIT(3) + +-#define RTL8211F_ALDPS_PLL_OFF BIT(1) +-#define RTL8211F_ALDPS_ENABLE BIT(2) +-#define RTL8211F_ALDPS_XTAL_OFF BIT(12) ++/* RTL8211F WOL interrupt configuration */ ++#define RTL8211F_INTBCR_PAGE 0xd40 ++#define RTL8211F_INTBCR 0x16 ++#define RTL8211F_INTBCR_INTB_PMEB BIT(5) + +-#define RTL8211E_RGMII_EXT_PAGE 0xa4 +-#define RTL8211E_RGMII_DELAY 0x1c +-#define RTL8211E_CTRL_DELAY BIT(13) +-#define RTL8211E_TX_DELAY BIT(12) +-#define RTL8211E_RX_DELAY BIT(11) +-#define RTL8211E_DELAY_MASK GENMASK(13, 11) ++/* RTL8211F WOL settings */ ++#define RTL8211F_WOL_SETTINGS_PAGE 0xd8a ++#define RTL8211F_WOL_SETTINGS_EVENTS 16 ++#define RTL8211F_WOL_EVENT_MAGIC BIT(12) ++#define RTL8211F_WOL_SETTINGS_STATUS 17 ++#define RTL8211F_WOL_STATUS_RESET (BIT(15) | 0x1fff) + +-#define RTL8201F_ISR 0x1e +-#define RTL8201F_ISR_ANERR BIT(15) +-#define RTL8201F_ISR_DUPLEX BIT(13) +-#define RTL8201F_ISR_LINK BIT(11) +-#define RTL8201F_ISR_MASK (RTL8201F_ISR_ANERR | \ +- RTL8201F_ISR_DUPLEX | \ +- RTL8201F_ISR_LINK) +-#define RTL8201F_IER 0x13 ++/* RTL8211F Unique phyiscal and multicast address (WOL) */ ++#define RTL8211F_PHYSICAL_ADDR_PAGE 0xd8c ++#define RTL8211F_PHYSICAL_ADDR_WORD0 16 ++#define RTL8211F_PHYSICAL_ADDR_WORD1 17 ++#define RTL8211F_PHYSICAL_ADDR_WORD2 18 + + #define RTL822X_VND1_SERDES_OPTION 0x697a + #define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-25-v6.16-net-phy-realtek-use-__set_bit-in-rtl8211f_led_hw_con.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-25-v6.16-net-phy-realtek-use-__set_bit-in-rtl8211f_led_hw_con.patch new file mode 100755 index 0000000..a9e3f90 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-25-v6.16-net-phy-realtek-use-__set_bit-in-rtl8211f_led_hw_con.patch @@ -0,0 +1,42 @@ +From be1cc96ddf82bb0c0a159751f73239d6d3e9594a Mon Sep 17 00:00:00 2001 +From: Michael Klein +Date: Sun, 4 May 2025 19:29:15 +0200 +Subject: [PATCH] net: phy: realtek: use __set_bit() in + rtl8211f_led_hw_control_get() + +rtl8211f_led_hw_control_get() does not need atomic bit operations, +replace set_bit() by __set_bit(). + +Signed-off-by: Michael Klein +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250504172916.243185-6-michael@fossekall.de +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -659,17 +659,17 @@ static int rtl8211f_led_hw_control_get(s + val &= RTL8211F_LEDCR_MASK; + + if (val & RTL8211F_LEDCR_LINK_10) +- set_bit(TRIGGER_NETDEV_LINK_10, rules); ++ __set_bit(TRIGGER_NETDEV_LINK_10, rules); + + if (val & RTL8211F_LEDCR_LINK_100) +- set_bit(TRIGGER_NETDEV_LINK_100, rules); ++ __set_bit(TRIGGER_NETDEV_LINK_100, rules); + + if (val & RTL8211F_LEDCR_LINK_1000) +- set_bit(TRIGGER_NETDEV_LINK_1000, rules); ++ __set_bit(TRIGGER_NETDEV_LINK_1000, rules); + + if (val & RTL8211F_LEDCR_ACT_TXRX) { +- set_bit(TRIGGER_NETDEV_RX, rules); +- set_bit(TRIGGER_NETDEV_TX, rules); ++ __set_bit(TRIGGER_NETDEV_RX, rules); ++ __set_bit(TRIGGER_NETDEV_TX, rules); + } + + return 0; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-26-v6.16-net-phy-realtek-Add-support-for-PHY-LEDs-on-RTL8211E.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-26-v6.16-net-phy-realtek-Add-support-for-PHY-LEDs-on-RTL8211E.patch new file mode 100755 index 0000000..a4b6450 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-26-v6.16-net-phy-realtek-Add-support-for-PHY-LEDs-on-RTL8211E.patch @@ -0,0 +1,215 @@ +From 708686132ba02659267c0cebcc414348ece389a5 Mon Sep 17 00:00:00 2001 +From: Michael Klein +Date: Sun, 4 May 2025 19:29:16 +0200 +Subject: [PATCH] net: phy: realtek: Add support for PHY LEDs on RTL8211E + +Like the RTL8211F, the RTL8211E PHY supports up to three LEDs. +Add netdev trigger support for them, too. + +Signed-off-by: Michael Klein +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250504172916.243185-7-michael@fossekall.de +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 125 +++++++++++++++++++++++-- + 1 file changed, 119 insertions(+), 6 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -40,6 +40,20 @@ + #define RTL821x_PAGE_SELECT 0x1f + #define RTL821x_SET_EXT_PAGE 0x07 + ++/* RTL8211E extension page 44/0x2c */ ++#define RTL8211E_LEDCR_EXT_PAGE 0x2c ++#define RTL8211E_LEDCR1 0x1a ++#define RTL8211E_LEDCR1_ACT_TXRX BIT(4) ++#define RTL8211E_LEDCR1_MASK BIT(4) ++#define RTL8211E_LEDCR1_SHIFT 1 ++ ++#define RTL8211E_LEDCR2 0x1c ++#define RTL8211E_LEDCR2_LINK_1000 BIT(2) ++#define RTL8211E_LEDCR2_LINK_100 BIT(1) ++#define RTL8211E_LEDCR2_LINK_10 BIT(0) ++#define RTL8211E_LEDCR2_MASK GENMASK(2, 0) ++#define RTL8211E_LEDCR2_SHIFT 4 ++ + /* RTL8211E extension page 164/0xa4 */ + #define RTL8211E_RGMII_EXT_PAGE 0xa4 + #define RTL8211E_RGMII_DELAY 0x1c +@@ -145,7 +159,8 @@ + #define RTL_8221B_VN_CG 0x001cc84a + #define RTL_8251B 0x001cc862 + +-#define RTL8211F_LED_COUNT 3 ++/* RTL8211E and RTL8211F support up to three LEDs */ ++#define RTL8211x_LED_COUNT 3 + + MODULE_DESCRIPTION("Realtek PHY driver"); + MODULE_AUTHOR("Johnson Leung"); +@@ -169,6 +184,21 @@ static int rtl821x_write_page(struct phy + return __phy_write(phydev, RTL821x_PAGE_SELECT, page); + } + ++static int rtl821x_read_ext_page(struct phy_device *phydev, u16 ext_page, ++ u32 regnum) ++{ ++ int oldpage, ret = 0; ++ ++ oldpage = phy_select_page(phydev, RTL821x_SET_EXT_PAGE); ++ if (oldpage >= 0) { ++ ret = __phy_write(phydev, RTL821x_EXT_PAGE_SELECT, ext_page); ++ if (ret == 0) ++ ret = __phy_read(phydev, regnum); ++ } ++ ++ return phy_restore_page(phydev, oldpage, ret); ++} ++ + static int rtl821x_modify_ext_page(struct phy_device *phydev, u16 ext_page, + u32 regnum, u16 mask, u16 set) + { +@@ -608,7 +638,7 @@ static int rtl821x_resume(struct phy_dev + return 0; + } + +-static int rtl8211f_led_hw_is_supported(struct phy_device *phydev, u8 index, ++static int rtl8211x_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) + { + const unsigned long mask = BIT(TRIGGER_NETDEV_LINK_10) | +@@ -627,9 +657,11 @@ static int rtl8211f_led_hw_is_supported( + * rates and Active indication always at all three 10+100+1000 + * link rates. + * This code currently uses mode B only. ++ * ++ * RTL8211E PHY LED has one mode, which works like RTL8211F mode B. + */ + +- if (index >= RTL8211F_LED_COUNT) ++ if (index >= RTL8211x_LED_COUNT) + return -EINVAL; + + /* Filter out any other unsupported triggers. */ +@@ -648,7 +680,7 @@ static int rtl8211f_led_hw_control_get(s + { + int val; + +- if (index >= RTL8211F_LED_COUNT) ++ if (index >= RTL8211x_LED_COUNT) + return -EINVAL; + + val = phy_read_paged(phydev, 0xd04, RTL8211F_LEDCR); +@@ -681,7 +713,7 @@ static int rtl8211f_led_hw_control_set(s + const u16 mask = RTL8211F_LEDCR_MASK << (RTL8211F_LEDCR_SHIFT * index); + u16 reg = 0; + +- if (index >= RTL8211F_LED_COUNT) ++ if (index >= RTL8211x_LED_COUNT) + return -EINVAL; + + if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) +@@ -704,6 +736,84 @@ static int rtl8211f_led_hw_control_set(s + return phy_modify_paged(phydev, 0xd04, RTL8211F_LEDCR, mask, reg); + } + ++static int rtl8211e_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int ret; ++ u16 cr1, cr2; ++ ++ if (index >= RTL8211x_LED_COUNT) ++ return -EINVAL; ++ ++ ret = rtl821x_read_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE, ++ RTL8211E_LEDCR1); ++ if (ret < 0) ++ return ret; ++ ++ cr1 = ret >> RTL8211E_LEDCR1_SHIFT * index; ++ if (cr1 & RTL8211E_LEDCR1_ACT_TXRX) { ++ __set_bit(TRIGGER_NETDEV_RX, rules); ++ __set_bit(TRIGGER_NETDEV_TX, rules); ++ } ++ ++ ret = rtl821x_read_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE, ++ RTL8211E_LEDCR2); ++ if (ret < 0) ++ return ret; ++ ++ cr2 = ret >> RTL8211E_LEDCR2_SHIFT * index; ++ if (cr2 & RTL8211E_LEDCR2_LINK_10) ++ __set_bit(TRIGGER_NETDEV_LINK_10, rules); ++ ++ if (cr2 & RTL8211E_LEDCR2_LINK_100) ++ __set_bit(TRIGGER_NETDEV_LINK_100, rules); ++ ++ if (cr2 & RTL8211E_LEDCR2_LINK_1000) ++ __set_bit(TRIGGER_NETDEV_LINK_1000, rules); ++ ++ return ret; ++} ++ ++static int rtl8211e_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ const u16 cr1mask = ++ RTL8211E_LEDCR1_MASK << (RTL8211E_LEDCR1_SHIFT * index); ++ const u16 cr2mask = ++ RTL8211E_LEDCR2_MASK << (RTL8211E_LEDCR2_SHIFT * index); ++ u16 cr1 = 0, cr2 = 0; ++ int ret; ++ ++ if (index >= RTL8211x_LED_COUNT) ++ return -EINVAL; ++ ++ if (test_bit(TRIGGER_NETDEV_RX, &rules) || ++ test_bit(TRIGGER_NETDEV_TX, &rules)) { ++ cr1 |= RTL8211E_LEDCR1_ACT_TXRX; ++ } ++ ++ cr1 <<= RTL8211E_LEDCR1_SHIFT * index; ++ ret = rtl821x_modify_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE, ++ RTL8211E_LEDCR1, cr1mask, cr1); ++ if (ret < 0) ++ return ret; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) ++ cr2 |= RTL8211E_LEDCR2_LINK_10; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) ++ cr2 |= RTL8211E_LEDCR2_LINK_100; ++ ++ if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) ++ cr2 |= RTL8211E_LEDCR2_LINK_1000; ++ ++ cr2 <<= RTL8211E_LEDCR2_SHIFT * index; ++ ret = rtl821x_modify_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE, ++ RTL8211E_LEDCR2, cr2mask, cr2); ++ ++ return ret; ++} ++ + static int rtl8211e_config_init(struct phy_device *phydev) + { + u16 val; +@@ -1479,6 +1589,9 @@ static struct phy_driver realtek_drvs[] + .resume = genphy_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, ++ .led_hw_is_supported = rtl8211x_led_hw_is_supported, ++ .led_hw_control_get = rtl8211e_led_hw_control_get, ++ .led_hw_control_set = rtl8211e_led_hw_control_set, + }, { + PHY_ID_MATCH_EXACT(0x001cc916), + .name = "RTL8211F Gigabit Ethernet", +@@ -1494,7 +1607,7 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, +- .led_hw_is_supported = rtl8211f_led_hw_is_supported, ++ .led_hw_is_supported = rtl8211x_led_hw_is_supported, + .led_hw_control_get = rtl8211f_led_hw_control_get, + .led_hw_control_set = rtl8211f_led_hw_control_set, + }, { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-27-v6.16-net-phy-realtek-add-RTL8127-internal-PHY.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-27-v6.16-net-phy-realtek-add-RTL8127-internal-PHY.patch new file mode 100755 index 0000000..04c631d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-27-v6.16-net-phy-realtek-add-RTL8127-internal-PHY.patch @@ -0,0 +1,35 @@ +From 83d9623161283f5f6883ee3fdb88ef2177b8a5f1 Mon Sep 17 00:00:00 2001 +From: ChunHao Lin +Date: Fri, 16 May 2025 13:56:22 +0800 +Subject: [PATCH] net: phy: realtek: add RTL8127-internal PHY + +RTL8127-internal PHY is RTL8261C which is a integrated 10Gbps PHY with ID +0x001cc890. It follows the code path of RTL8125/RTL8126 internal NBase-T +PHY. + +Signed-off-by: ChunHao Lin +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250516055622.3772-1-hau@realtek.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -158,6 +158,7 @@ + #define RTL_8221B_VB_CG 0x001cc849 + #define RTL_8221B_VN_CG 0x001cc84a + #define RTL_8251B 0x001cc862 ++#define RTL_8261C 0x001cc890 + + /* RTL8211E and RTL8211F support up to three LEDs */ + #define RTL8211x_LED_COUNT 3 +@@ -1370,6 +1371,7 @@ static int rtl_internal_nbaset_match_phy + case RTL_GENERIC_PHYID: + case RTL_8221B: + case RTL_8251B: ++ case RTL_8261C: + case 0x001cc841: + break; + default: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-28-v6.18-net-phy-realtek-convert-RTL8226-CG-to-c45-only.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-28-v6.18-net-phy-realtek-convert-RTL8226-CG-to-c45-only.patch new file mode 100755 index 0000000..43f2c7b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-28-v6.18-net-phy-realtek-convert-RTL8226-CG-to-c45-only.patch @@ -0,0 +1,169 @@ +From 34167f1a024d2c5abae0b0325a6d0b8257160f86 Mon Sep 17 00:00:00 2001 +From: Markus Stockhausen +Date: Wed, 13 Aug 2025 01:44:07 -0400 +Subject: net: phy: realtek: convert RTL8226-CG to c45 only + +Short: Convert the RTL8226-CG to c45 so it can be used in its +Realtek based ecosystems. + +Long: The RTL8226-CG can be mainly found on devices of the +Realtek Otto switch platform. Devices like the Zyxel XGS1210-12 +are based on it. These implement a hardware based phy polling +in the background to update SoC status registers. + +The hardware provides 4 smi busses where phys are attached to. +For each bus one can decide if it is polled in c45 or c22 mode. +See https://svanheule.net/realtek/longan/register/smi_glb_ctrl +With this setting the register access will be limited by the +hardware. This is very complex (including caching and special +c45-over-c22 handling). But basically it boils down to "enable +protocol x and SoC will disable register access via protocol y". + +Mainline already gained support for the rtl9300 mdio driver +in commit 24e31e474769 ("net: mdio: Add RTL9300 MDIO driver"). + +It covers the basic features, but a lot effort is still needed +to understand hardware properly. So it runs a simple setup by +selecting the proper bus mode during startup. + + /* Put the interfaces into C45 mode if required */ + glb_ctrl_mask = GENMASK(19, 16); + for (i = 0; i < MAX_SMI_BUSSES; i++) + if (priv->smi_bus_is_c45[i]) + glb_ctrl_val |= GLB_CTRL_INTF_SEL(i); + ... + err = regmap_update_bits(regmap, SMI_GLB_CTRL, + glb_ctrl_mask, glb_ctrl_val); + +To avoid complex coding later on, it limits access by only +providing either c22 or c45: + + bus->name = "Realtek Switch MDIO Bus"; + if (priv->smi_bus_is_c45[mdio_bus]) { + bus->read_c45 = rtl9300_mdio_read_c45; + bus->write_c45 = rtl9300_mdio_write_c45; + } else { + bus->read = rtl9300_mdio_read_c22; + bus->write = rtl9300_mdio_write_c22; + } + +Because of these limitations the existing RTL8226 phy driver +is not working at all on Realtek switches. Convert the driver +to c45-only. + +Luckily the RTL8226 seems to support proper MDIO_PMA_EXTABLE +flags. So standard function genphy_c45_pma_read_abilities() can +call genphy_c45_pma_read_ext_abilities() and 10/100/1000 is +populated right. Thus conversion is straight forward. + +Outputs before - REMARK: For this a "hacked" bus was used that +toggles the mode for each c22/c45 access. But that is slow and +produces unstable data in the SoC status registers). + +Settings for lan9: + Supported ports: [ TP MII ] + Supported link modes: 10baseT/Half 10baseT/Full + 100baseT/Half 100baseT/Full + 1000baseT/Full + 2500baseT/Full + Supported pause frame use: Symmetric Receive-only + Supports auto-negotiation: Yes + Supported FEC modes: Not reported + Advertised link modes: 10baseT/Half 10baseT/Full + 100baseT/Half 100baseT/Full + 1000baseT/Full + 2500baseT/Full + Advertised pause frame use: Symmetric Receive-only + Advertised auto-negotiation: Yes + Advertised FEC modes: Not reported + Speed: Unknown! + Duplex: Unknown! (255) + Port: Twisted Pair + PHYAD: 24 + Transceiver: external + Auto-negotiation: on + MDI-X: Unknown + Supports Wake-on: d + Wake-on: d + Link detected: no + +Outputs with this commit: + +Settings for lan9: + Supported ports: [ TP ] + Supported link modes: 10baseT/Half 10baseT/Full + 100baseT/Half 100baseT/Full + 1000baseT/Full + 2500baseT/Full + Supported pause frame use: Symmetric Receive-only + Supports auto-negotiation: Yes + Supported FEC modes: Not reported + Advertised link modes: 10baseT/Half 10baseT/Full + 100baseT/Half 100baseT/Full + 1000baseT/Full + 2500baseT/Full + Advertised pause frame use: Symmetric Receive-only + Advertised auto-negotiation: Yes + Advertised FEC modes: Not reported + Speed: Unknown! + Duplex: Unknown! (255) + Port: Twisted Pair + PHYAD: 24 + Transceiver: external + Auto-negotiation: on + MDI-X: Unknown + Supports Wake-on: d + Wake-on: d + Link detected: no + +Signed-off-by: Markus Stockhausen +Link: https://patch.msgid.link/20250813054407.1108285-1-markus.stockhausen@gmx.de +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 28 +++++++++++++++++++++------- + 1 file changed, 21 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1274,6 +1274,21 @@ static int rtl822x_c45_read_status(struc + return 0; + } + ++static int rtl822x_c45_soft_reset(struct phy_device *phydev) ++{ ++ int ret, val; ++ ++ ret = phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, ++ MDIO_CTRL1_RESET, MDIO_CTRL1_RESET); ++ if (ret < 0) ++ return ret; ++ ++ return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PMAPMD, ++ MDIO_CTRL1, val, ++ !(val & MDIO_CTRL1_RESET), ++ 5000, 100000, true); ++} ++ + static int rtl822xb_c45_read_status(struct phy_device *phydev) + { + int ret; +@@ -1660,13 +1675,12 @@ static struct phy_driver realtek_drvs[] + }, { + PHY_ID_MATCH_EXACT(0x001cc838), + .name = "RTL8226-CG 2.5Gbps PHY", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, ++ .soft_reset = rtl822x_c45_soft_reset, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822x_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, + }, { + PHY_ID_MATCH_EXACT(0x001cc848), + .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-29-v6.18-net-phy-realtek-enable-serdes-option-mode-for-RTL8226-CG.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-29-v6.18-net-phy-realtek-enable-serdes-option-mode-for-RTL8226-CG.patch new file mode 100755 index 0000000..9ffb260 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/781-29-v6.18-net-phy-realtek-enable-serdes-option-mode-for-RTL8226-CG.patch @@ -0,0 +1,92 @@ +From 3a752e67800106a5c42d802d67e06c60aa71d07b Mon Sep 17 00:00:00 2001 +From: Markus Stockhausen +Date: Fri, 15 Aug 2025 04:20:09 -0400 +Subject: net: phy: realtek: enable serdes option mode for RTL8226-CG + +The RTL8226-CG can make use of the serdes option mode feature to +dynamically switch between SGMII and 2500base-X. From what is +known the setup sequence is much simpler with no magic values. + +Convert the exiting config_init() into a helper that configures +the PHY depending on generation 1 or 2. Call the helper from two +separated new config_init() functions. + +Finally convert the phy_driver specs of the RTL8226-CG to make +use of the new configuration and switch over to the extended +read_status() function to dynamically change the interface +according to the serdes mode. + +Remark! The logic could be simpler if the serdes mode could be +set before all other generation 2 magic values. Due to missing +RTL8221B test hardware the mmd command order was kept. + +Tested on Zyxel XGS1210-12. + +Signed-off-by: Markus Stockhausen +Link: https://patch.msgid.link/20250815082009.3678865-1-markus.stockhausen@gmx.de +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 26 ++++++++++++++++++++------ + 1 file changed, 20 insertions(+), 6 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1032,7 +1032,7 @@ static int rtl822x_probe(struct phy_devi + return 0; + } + +-static int rtl822xb_config_init(struct phy_device *phydev) ++static int rtl822x_set_serdes_option_mode(struct phy_device *phydev, bool gen1) + { + bool has_2500, has_sgmii; + u16 mode; +@@ -1067,15 +1067,18 @@ static int rtl822xb_config_init(struct p + /* the following sequence with magic numbers sets up the SerDes + * option mode + */ +- ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0); +- if (ret < 0) +- return ret; ++ ++ if (!gen1) { ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x75f3, 0); ++ if (ret < 0) ++ return ret; ++ } + + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND1, + RTL822X_VND1_SERDES_OPTION, + RTL822X_VND1_SERDES_OPTION_MODE_MASK, + mode); +- if (ret < 0) ++ if (gen1 || ret < 0) + return ret; + + ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6a04, 0x0503); +@@ -1089,6 +1092,16 @@ static int rtl822xb_config_init(struct p + return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); + } + ++static int rtl822x_config_init(struct phy_device *phydev) ++{ ++ return rtl822x_set_serdes_option_mode(phydev, true); ++} ++ ++static int rtl822xb_config_init(struct phy_device *phydev) ++{ ++ return rtl822x_set_serdes_option_mode(phydev, false); ++} ++ + static int rtl822xb_get_rate_matching(struct phy_device *phydev, + phy_interface_t iface) + { +@@ -1678,7 +1691,8 @@ static struct phy_driver realtek_drvs[] + .soft_reset = rtl822x_c45_soft_reset, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822x_c45_read_status, ++ .config_init = rtl822x_config_init, ++ .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, + }, { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-01-v6.16-net-phy-pass-PHY-driver-to-.match_phy_device-OP.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-01-v6.16-net-phy-pass-PHY-driver-to-.match_phy_device-OP.patch new file mode 100755 index 0000000..c22231e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-01-v6.16-net-phy-pass-PHY-driver-to-.match_phy_device-OP.patch @@ -0,0 +1,303 @@ +From 31afd6bc55cc0093c3e5b0a368319e423d4de8ea Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sat, 17 May 2025 22:13:45 +0200 +Subject: [PATCH] net: phy: pass PHY driver to .match_phy_device OP + +Pass PHY driver pointer to .match_phy_device OP in addition to phydev. +Having access to the PHY driver struct might be useful to check the +PHY ID of the driver is being matched for in case the PHY ID scanned in +the phydev is not consistent. + +A scenario for this is a PHY that change PHY ID after a firmware is +loaded, in such case, the PHY ID stored in PHY device struct is not +valid anymore and PHY will manually scan the ID in the match_phy_device +function. + +Having the PHY driver info is also useful for those PHY driver that +implement multiple simple .match_phy_device OP to match specific MMD PHY +ID. With this extra info if the parsing logic is the same, the matching +function can be generalized by using the phy_id in the PHY driver +instead of hardcoding. + +Rust wrapper callback is updated to align to the new match_phy_device +arguments. + +Suggested-by: Russell King (Oracle) +Reviewed-by: Russell King (Oracle) +Signed-off-by: Christian Marangi +Reviewed-by: Benno Lossin # for Rust +Reviewed-by: FUJITA Tomonori +Link: https://patch.msgid.link/20250517201353.5137-2-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/bcm87xx.c | 6 ++++-- + drivers/net/phy/icplus.c | 6 ++++-- + drivers/net/phy/marvell10g.c | 12 ++++++++---- + drivers/net/phy/micrel.c | 6 ++++-- + drivers/net/phy/nxp-c45-tja11xx.c | 12 ++++++++---- + drivers/net/phy/nxp-tja11xx.c | 6 ++++-- + drivers/net/phy/phy_device.c | 2 +- + drivers/net/phy/realtek/realtek_main.c | 27 +++++++++++++++++--------- + drivers/net/phy/teranetics.c | 3 ++- + include/linux/phy.h | 3 ++- + rust/kernel/net/phy.rs | 1 + + 11 files changed, 56 insertions(+), 28 deletions(-) + +--- a/drivers/net/phy/bcm87xx.c ++++ b/drivers/net/phy/bcm87xx.c +@@ -185,12 +185,14 @@ static irqreturn_t bcm87xx_handle_interr + return IRQ_HANDLED; + } + +-static int bcm8706_match_phy_device(struct phy_device *phydev) ++static int bcm8706_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phydev->c45_ids.device_ids[4] == PHY_ID_BCM8706; + } + +-static int bcm8727_match_phy_device(struct phy_device *phydev) ++static int bcm8727_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phydev->c45_ids.device_ids[4] == PHY_ID_BCM8727; + } +--- a/drivers/net/phy/icplus.c ++++ b/drivers/net/phy/icplus.c +@@ -520,12 +520,14 @@ static int ip101a_g_match_phy_device(str + return ip101a == !ret; + } + +-static int ip101a_match_phy_device(struct phy_device *phydev) ++static int ip101a_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return ip101a_g_match_phy_device(phydev, true); + } + +-static int ip101g_match_phy_device(struct phy_device *phydev) ++static int ip101g_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return ip101a_g_match_phy_device(phydev, false); + } +--- a/drivers/net/phy/marvell10g.c ++++ b/drivers/net/phy/marvell10g.c +@@ -1284,7 +1284,8 @@ static int mv3310_get_number_of_ports(st + return ret + 1; + } + +-static int mv3310_match_phy_device(struct phy_device *phydev) ++static int mv3310_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] & + MARVELL_PHY_ID_MASK) != MARVELL_PHY_ID_88X3310) +@@ -1293,7 +1294,8 @@ static int mv3310_match_phy_device(struc + return mv3310_get_number_of_ports(phydev) == 1; + } + +-static int mv3340_match_phy_device(struct phy_device *phydev) ++static int mv3340_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] & + MARVELL_PHY_ID_MASK) != MARVELL_PHY_ID_88X3310) +@@ -1317,12 +1319,14 @@ static int mv211x_match_phy_device(struc + return !!(val & MDIO_PCS_SPEED_5G) == has_5g; + } + +-static int mv2110_match_phy_device(struct phy_device *phydev) ++static int mv2110_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return mv211x_match_phy_device(phydev, true); + } + +-static int mv2111_match_phy_device(struct phy_device *phydev) ++static int mv2111_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return mv211x_match_phy_device(phydev, false); + } +--- a/drivers/net/phy/micrel.c ++++ b/drivers/net/phy/micrel.c +@@ -768,7 +768,8 @@ static int ksz8051_ksz8795_match_phy_dev + return !ret; + } + +-static int ksz8051_match_phy_device(struct phy_device *phydev) ++static int ksz8051_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return ksz8051_ksz8795_match_phy_device(phydev, true); + } +@@ -888,7 +889,8 @@ static int ksz8061_config_init(struct ph + return kszphy_config_init(phydev); + } + +-static int ksz8795_match_phy_device(struct phy_device *phydev) ++static int ksz8795_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return ksz8051_ksz8795_match_phy_device(phydev, false); + } +--- a/drivers/net/phy/nxp-c45-tja11xx.c ++++ b/drivers/net/phy/nxp-c45-tja11xx.c +@@ -1944,13 +1944,15 @@ static int nxp_c45_macsec_ability(struct + return macsec_ability; + } + +-static int tja1103_match_phy_device(struct phy_device *phydev) ++static int tja1103_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1103, PHY_ID_MASK) && + !nxp_c45_macsec_ability(phydev); + } + +-static int tja1104_match_phy_device(struct phy_device *phydev) ++static int tja1104_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phy_id_compare(phydev->phy_id, PHY_ID_TJA_1103, PHY_ID_MASK) && + nxp_c45_macsec_ability(phydev); +--- a/drivers/net/phy/nxp-tja11xx.c ++++ b/drivers/net/phy/nxp-tja11xx.c +@@ -646,12 +646,14 @@ static int tja1102_match_phy_device(stru + return !ret; + } + +-static int tja1102_p0_match_phy_device(struct phy_device *phydev) ++static int tja1102_p0_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return tja1102_match_phy_device(phydev, true); + } + +-static int tja1102_p1_match_phy_device(struct phy_device *phydev) ++static int tja1102_p1_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return tja1102_match_phy_device(phydev, false); + } +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -600,7 +600,7 @@ static int phy_bus_match(struct device * + return 0; + + if (phydrv->match_phy_device) +- return phydrv->match_phy_device(phydev); ++ return phydrv->match_phy_device(phydev, phydrv); + + if (phydev->is_c45) { + for (i = 1; i < num_ids; i++) { +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1343,13 +1343,15 @@ static bool rtlgen_supports_mmd(struct p + return val > 0; + } + +-static int rtlgen_match_phy_device(struct phy_device *phydev) ++static int rtlgen_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phydev->phy_id == RTL_GENERIC_PHYID && + !rtlgen_supports_2_5gbps(phydev); + } + +-static int rtl8226_match_phy_device(struct phy_device *phydev) ++static int rtl8226_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phydev->phy_id == RTL_GENERIC_PHYID && + rtlgen_supports_2_5gbps(phydev) && +@@ -1365,32 +1367,38 @@ static int rtlgen_is_c45_match(struct ph + return !is_c45 && (id == phydev->phy_id); + } + +-static int rtl8221b_match_phy_device(struct phy_device *phydev) ++static int rtl8221b_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev); + } + +-static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev) ++static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); + } + +-static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev) ++static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); + } + +-static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev) ++static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false); + } + +-static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev) ++static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true); + } + +-static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev) ++static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + if (phydev->is_c45) + return false; +@@ -1409,7 +1417,8 @@ static int rtl_internal_nbaset_match_phy + return rtlgen_supports_2_5gbps(phydev) && !rtlgen_supports_mmd(phydev); + } + +-static int rtl8251b_c45_match_phy_device(struct phy_device *phydev) ++static int rtl8251b_c45_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return rtlgen_is_c45_match(phydev, RTL_8251B, true); + } +--- a/drivers/net/phy/teranetics.c ++++ b/drivers/net/phy/teranetics.c +@@ -67,7 +67,8 @@ static int teranetics_read_status(struct + return 0; + } + +-static int teranetics_match_phy_device(struct phy_device *phydev) ++static int teranetics_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { + return phydev->c45_ids.device_ids[3] == PHY_ID_TN2020; + } +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1045,7 +1045,8 @@ struct phy_driver { + * driver for the given phydev. If NULL, matching is based on + * phy_id and phy_id_mask. + */ +- int (*match_phy_device)(struct phy_device *phydev); ++ int (*match_phy_device)(struct phy_device *phydev, ++ const struct phy_driver *phydrv); + + /** + * @set_wol: Some devices (e.g. qnap TS-119P II) require PHY +--- a/rust/kernel/net/phy.rs ++++ b/rust/kernel/net/phy.rs +@@ -421,6 +421,7 @@ impl Adapter { + /// `phydev` must be passed by the corresponding callback in `phy_driver`. + unsafe extern "C" fn match_phy_device_callback( + phydev: *mut bindings::phy_device, ++ _phydrv: *const bindings::phy_driver, + ) -> crate::ffi::c_int { + // SAFETY: This callback is called only in contexts + // where we hold `phy_device->lock`, so the accessors on diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-04-v6.16-net-phy-introduce-genphy_match_phy_device.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-04-v6.16-net-phy-introduce-genphy_match_phy_device.patch new file mode 100755 index 0000000..1ac3b23 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-04-v6.16-net-phy-introduce-genphy_match_phy_device.patch @@ -0,0 +1,109 @@ +From d6c45707ac84c2d9f274ece1cea4dddb97996bde Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sat, 17 May 2025 22:13:48 +0200 +Subject: [PATCH 4/5] net: phy: introduce genphy_match_phy_device() + +Introduce new API, genphy_match_phy_device(), to provide a way to check +to match a PHY driver for a PHY device based on the info stored in the +PHY device struct. + +The function generalize the logic used in phy_bus_match() to check the +PHY ID whether if C45 or C22 ID should be used for matching. + +This is useful for custom .match_phy_device function that wants to use +the generic logic under some condition. (example a PHY is already setup +and provide the correct PHY ID) + +Reviewed-by: Russell King (Oracle) +Signed-off-by: Christian Marangi +Link: https://patch.msgid.link/20250517201353.5137-5-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/phy_device.c | 52 +++++++++++++++++++++++++----------- + include/linux/phy.h | 3 +++ + 2 files changed, 40 insertions(+), 15 deletions(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -589,20 +589,26 @@ static int phy_scan_fixups(struct phy_de + return 0; + } + +-static int phy_bus_match(struct device *dev, const struct device_driver *drv) ++/** ++ * genphy_match_phy_device - match a PHY device with a PHY driver ++ * @phydev: target phy_device struct ++ * @phydrv: target phy_driver struct ++ * ++ * Description: Checks whether the given PHY device matches the specified ++ * PHY driver. For Clause 45 PHYs, iterates over the available device ++ * identifiers and compares them against the driver's expected PHY ID, ++ * applying the provided mask. For Clause 22 PHYs, a direct ID comparison ++ * is performed. ++ * ++ * Return: 1 if the PHY device matches the driver, 0 otherwise. ++ */ ++int genphy_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { +- struct phy_device *phydev = to_phy_device(dev); +- const struct phy_driver *phydrv = to_phy_driver(drv); +- const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); +- int i; +- +- if (!(phydrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY)) +- return 0; +- +- if (phydrv->match_phy_device) +- return phydrv->match_phy_device(phydev, phydrv); +- + if (phydev->is_c45) { ++ const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); ++ int i; ++ + for (i = 1; i < num_ids; i++) { + if (phydev->c45_ids.device_ids[i] == 0xffffffff) + continue; +@@ -611,11 +617,27 @@ static int phy_bus_match(struct device * + phydrv->phy_id, phydrv->phy_id_mask)) + return 1; + } ++ + return 0; +- } else { +- return phy_id_compare(phydev->phy_id, phydrv->phy_id, +- phydrv->phy_id_mask); + } ++ ++ return phy_id_compare(phydev->phy_id, phydrv->phy_id, ++ phydrv->phy_id_mask); ++} ++EXPORT_SYMBOL_GPL(genphy_match_phy_device); ++ ++static int phy_bus_match(struct device *dev, const struct device_driver *drv) ++{ ++ struct phy_device *phydev = to_phy_device(dev); ++ const struct phy_driver *phydrv = to_phy_driver(drv); ++ ++ if (!(phydrv->mdiodrv.flags & MDIO_DEVICE_IS_PHY)) ++ return 0; ++ ++ if (phydrv->match_phy_device) ++ return phydrv->match_phy_device(phydev, phydrv); ++ ++ return genphy_match_phy_device(phydev, phydrv); + } + + static ssize_t +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1950,6 +1950,9 @@ char *phy_attached_info_irq(struct phy_d + __malloc; + void phy_attached_info(struct phy_device *phydev); + ++int genphy_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv); ++ + /* Clause 22 PHY */ + int genphy_read_abilities(struct phy_device *phydev); + int genphy_setup_forced(struct phy_device *phydev); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-05-v6.16-net-phy-Add-support-for-Aeonsemi-AS21xxx-PHYs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-05-v6.16-net-phy-Add-support-for-Aeonsemi-AS21xxx-PHYs.patch new file mode 100755 index 0000000..f1bcb35 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/782-05-v6.16-net-phy-Add-support-for-Aeonsemi-AS21xxx-PHYs.patch @@ -0,0 +1,1180 @@ +From 830877d89edcd834e4b4d0fcc021ff619d89505e Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sat, 17 May 2025 22:13:49 +0200 +Subject: [PATCH 5/5] net: phy: Add support for Aeonsemi AS21xxx PHYs + +Add support for Aeonsemi AS21xxx 10G C45 PHYs. These PHYs integrate +an IPC to setup some configuration and require special handling to +sync with the parity bit. The parity bit is a way the IPC use to +follow correct order of command sent. + +Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, +AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, +AS21210PB1 that all register with the PHY ID 0x7500 0x7510 +before the firmware is loaded. + +They all support up to 5 LEDs with various HW mode supported. + +While implementing it was found some strange coincidence with using the +same logic for implementing C22 in MMD regs in Broadcom PHYs. + +For reference here the AS21xxx PHY name logic: + +AS21x1xxB1 + ^ ^^ + | |J: Supports SyncE/PTP + | |P: No SyncE/PTP support + | 1: Supports 2nd Serdes + | 2: Not 2nd Serdes support + 0: 10G, 5G, 2.5G + 5: 5G, 2.5G + 2: 2.5G + +Reviewed-by: Andrew Lunn +Signed-off-by: Christian Marangi +Link: https://patch.msgid.link/20250517201353.5137-6-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + MAINTAINERS | 6 + + drivers/net/phy/Kconfig | 12 + + drivers/net/phy/Makefile | 1 + + drivers/net/phy/as21xxx.c | 1087 +++++++++++++++++++++++++++++++++++++ + 4 files changed, 1106 insertions(+) + create mode 100644 drivers/net/phy/as21xxx.c + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -637,6 +637,12 @@ F: drivers/iio/accel/adxl380.h + F: drivers/iio/accel/adxl380_i2c.c + F: drivers/iio/accel/adxl380_spi.c + ++AEONSEMI PHY DRIVER ++M: Christian Marangi ++L: netdev@vger.kernel.org ++S: Maintained ++F: drivers/net/phy/as21xxx.c ++ + AF8133J THREE-AXIS MAGNETOMETER DRIVER + M: OndΕ™ej Jirman + S: Maintained +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -79,6 +79,18 @@ config SFP + + comment "MII PHY device drivers" + ++config AS21XXX_PHY ++ tristate "Aeonsemi AS21xxx PHYs" ++ help ++ Currently supports the Aeonsemi AS21xxx PHY. ++ ++ These are C45 PHYs 10G that require all a generic firmware. ++ ++ Supported PHYs AS21011JB1, AS21011PB1, AS21010JB1, AS21010PB1, ++ AS21511JB1, AS21511PB1, AS21510JB1, AS21510PB1, AS21210JB1, ++ AS21210PB1 that all register with the PHY ID 0x7500 0x7500 ++ before the firmware is loaded. ++ + config AIR_EN8811H_PHY + tristate "Airoha EN8811H 2.5 Gigabit PHY" + help +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -39,6 +39,7 @@ obj-$(CONFIG_AIR_EN8811H_PHY) += air_e + obj-$(CONFIG_AMD_PHY) += amd.o + obj-$(CONFIG_AMCC_QT2025_PHY) += qt2025.o + obj-$(CONFIG_AQUANTIA_PHY) += aquantia/ ++obj-$(CONFIG_AS21XXX_PHY) += as21xxx.o + ifdef CONFIG_AX88796B_RUST_PHY + obj-$(CONFIG_AX88796B_PHY) += ax88796b_rust.o + else +--- /dev/null ++++ b/drivers/net/phy/as21xxx.c +@@ -0,0 +1,1087 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Aeonsemi AS21XXxX PHY Driver ++ * ++ * Author: Christian Marangi ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define VEND1_GLB_REG_CPU_RESET_ADDR_LO_BASEADDR 0x3 ++#define VEND1_GLB_REG_CPU_RESET_ADDR_HI_BASEADDR 0x4 ++ ++#define VEND1_GLB_REG_CPU_CTRL 0xe ++#define VEND1_GLB_CPU_CTRL_MASK GENMASK(4, 0) ++#define VEND1_GLB_CPU_CTRL_LED_POLARITY_MASK GENMASK(12, 8) ++#define VEND1_GLB_CPU_CTRL_LED_POLARITY(_n) FIELD_PREP(VEND1_GLB_CPU_CTRL_LED_POLARITY_MASK, \ ++ BIT(_n)) ++ ++#define VEND1_FW_START_ADDR 0x100 ++ ++#define VEND1_GLB_REG_MDIO_INDIRECT_ADDRCMD 0x101 ++#define VEND1_GLB_REG_MDIO_INDIRECT_LOAD 0x102 ++ ++#define VEND1_GLB_REG_MDIO_INDIRECT_STATUS 0x103 ++ ++#define VEND1_PTP_CLK 0x142 ++#define VEND1_PTP_CLK_EN BIT(6) ++ ++/* 5 LED at step of 0x20 ++ * FE: Fast-Ethernet (10/100) ++ * GE: Gigabit-Ethernet (1000) ++ * NG: New-Generation (2500/5000/10000) ++ */ ++#define VEND1_LED_REG(_n) (0x1800 + ((_n) * 0x10)) ++#define VEND1_LED_REG_A_EVENT GENMASK(15, 11) ++#define VEND1_LED_CONF 0x1881 ++#define VEND1_LED_CONFG_BLINK GENMASK(7, 0) ++ ++#define VEND1_SPEED_STATUS 0x4002 ++#define VEND1_SPEED_MASK GENMASK(7, 0) ++#define VEND1_SPEED_10000 FIELD_PREP_CONST(VEND1_SPEED_MASK, 0x3) ++#define VEND1_SPEED_5000 FIELD_PREP_CONST(VEND1_SPEED_MASK, 0x5) ++#define VEND1_SPEED_2500 FIELD_PREP_CONST(VEND1_SPEED_MASK, 0x9) ++#define VEND1_SPEED_1000 FIELD_PREP_CONST(VEND1_SPEED_MASK, 0x10) ++#define VEND1_SPEED_100 FIELD_PREP_CONST(VEND1_SPEED_MASK, 0x20) ++#define VEND1_SPEED_10 FIELD_PREP_CONST(VEND1_SPEED_MASK, 0x0) ++ ++#define VEND1_IPC_CMD 0x5801 ++#define AEON_IPC_CMD_PARITY BIT(15) ++#define AEON_IPC_CMD_SIZE GENMASK(10, 6) ++#define AEON_IPC_CMD_OPCODE GENMASK(5, 0) ++ ++#define IPC_CMD_NOOP 0x0 /* Do nothing */ ++#define IPC_CMD_INFO 0x1 /* Get Firmware Version */ ++#define IPC_CMD_SYS_CPU 0x2 /* SYS_CPU */ ++#define IPC_CMD_BULK_DATA 0xa /* Pass bulk data in ipc registers. */ ++#define IPC_CMD_BULK_WRITE 0xc /* Write bulk data to memory */ ++#define IPC_CMD_CFG_PARAM 0x1a /* Write config parameters to memory */ ++#define IPC_CMD_NG_TESTMODE 0x1b /* Set NG test mode and tone */ ++#define IPC_CMD_TEMP_MON 0x15 /* Temperature monitoring function */ ++#define IPC_CMD_SET_LED 0x23 /* Set led */ ++ ++#define VEND1_IPC_STS 0x5802 ++#define AEON_IPC_STS_PARITY BIT(15) ++#define AEON_IPC_STS_SIZE GENMASK(14, 10) ++#define AEON_IPC_STS_OPCODE GENMASK(9, 4) ++#define AEON_IPC_STS_STATUS GENMASK(3, 0) ++#define AEON_IPC_STS_STATUS_RCVD FIELD_PREP_CONST(AEON_IPC_STS_STATUS, 0x1) ++#define AEON_IPC_STS_STATUS_PROCESS FIELD_PREP_CONST(AEON_IPC_STS_STATUS, 0x2) ++#define AEON_IPC_STS_STATUS_SUCCESS FIELD_PREP_CONST(AEON_IPC_STS_STATUS, 0x4) ++#define AEON_IPC_STS_STATUS_ERROR FIELD_PREP_CONST(AEON_IPC_STS_STATUS, 0x8) ++#define AEON_IPC_STS_STATUS_BUSY FIELD_PREP_CONST(AEON_IPC_STS_STATUS, 0xe) ++#define AEON_IPC_STS_STATUS_READY FIELD_PREP_CONST(AEON_IPC_STS_STATUS, 0xf) ++ ++#define VEND1_IPC_DATA0 0x5808 ++#define VEND1_IPC_DATA1 0x5809 ++#define VEND1_IPC_DATA2 0x580a ++#define VEND1_IPC_DATA3 0x580b ++#define VEND1_IPC_DATA4 0x580c ++#define VEND1_IPC_DATA5 0x580d ++#define VEND1_IPC_DATA6 0x580e ++#define VEND1_IPC_DATA7 0x580f ++#define VEND1_IPC_DATA(_n) (VEND1_IPC_DATA0 + (_n)) ++ ++/* Sub command of CMD_INFO */ ++#define IPC_INFO_VERSION 0x1 ++ ++/* Sub command of CMD_SYS_CPU */ ++#define IPC_SYS_CPU_REBOOT 0x3 ++#define IPC_SYS_CPU_IMAGE_OFST 0x4 ++#define IPC_SYS_CPU_IMAGE_CHECK 0x5 ++#define IPC_SYS_CPU_PHY_ENABLE 0x6 ++ ++/* Sub command of CMD_CFG_PARAM */ ++#define IPC_CFG_PARAM_DIRECT 0x4 ++ ++/* CFG DIRECT sub command */ ++#define IPC_CFG_PARAM_DIRECT_NG_PHYCTRL 0x1 ++#define IPC_CFG_PARAM_DIRECT_CU_AN 0x2 ++#define IPC_CFG_PARAM_DIRECT_SDS_PCS 0x3 ++#define IPC_CFG_PARAM_DIRECT_AUTO_EEE 0x4 ++#define IPC_CFG_PARAM_DIRECT_SDS_PMA 0x5 ++#define IPC_CFG_PARAM_DIRECT_DPC_RA 0x6 ++#define IPC_CFG_PARAM_DIRECT_DPC_PKT_CHK 0x7 ++#define IPC_CFG_PARAM_DIRECT_DPC_SDS_WAIT_ETH 0x8 ++#define IPC_CFG_PARAM_DIRECT_WDT 0x9 ++#define IPC_CFG_PARAM_DIRECT_SDS_RESTART_AN 0x10 ++#define IPC_CFG_PARAM_DIRECT_TEMP_MON 0x11 ++#define IPC_CFG_PARAM_DIRECT_WOL 0x12 ++ ++/* Sub command of CMD_TEMP_MON */ ++#define IPC_CMD_TEMP_MON_GET 0x4 ++ ++#define AS21XXX_MDIO_AN_C22 0xffe0 ++ ++#define PHY_ID_AS21XXX 0x75009410 ++/* AS21xxx ID Legend ++ * AS21x1xxB1 ++ * ^ ^^ ++ * | |J: Supports SyncE/PTP ++ * | |P: No SyncE/PTP support ++ * | 1: Supports 2nd Serdes ++ * | 2: Not 2nd Serdes support ++ * 0: 10G, 5G, 2.5G ++ * 5: 5G, 2.5G ++ * 2: 2.5G ++ */ ++#define PHY_ID_AS21011JB1 0x75009402 ++#define PHY_ID_AS21011PB1 0x75009412 ++#define PHY_ID_AS21010JB1 0x75009422 ++#define PHY_ID_AS21010PB1 0x75009432 ++#define PHY_ID_AS21511JB1 0x75009442 ++#define PHY_ID_AS21511PB1 0x75009452 ++#define PHY_ID_AS21510JB1 0x75009462 ++#define PHY_ID_AS21510PB1 0x75009472 ++#define PHY_ID_AS21210JB1 0x75009482 ++#define PHY_ID_AS21210PB1 0x75009492 ++#define PHY_VENDOR_AEONSEMI 0x75009400 ++ ++#define AEON_MAX_LEDS 5 ++#define AEON_IPC_DELAY 10000 ++#define AEON_IPC_TIMEOUT (AEON_IPC_DELAY * 100) ++#define AEON_IPC_DATA_NUM_REGISTERS 8 ++#define AEON_IPC_DATA_MAX (AEON_IPC_DATA_NUM_REGISTERS * sizeof(u16)) ++ ++#define AEON_BOOT_ADDR 0x1000 ++#define AEON_CPU_BOOT_ADDR 0x2000 ++#define AEON_CPU_CTRL_FW_LOAD (BIT(4) | BIT(2) | BIT(1) | BIT(0)) ++#define AEON_CPU_CTRL_FW_START BIT(0) ++ ++enum as21xxx_led_event { ++ VEND1_LED_REG_A_EVENT_ON_10 = 0x0, ++ VEND1_LED_REG_A_EVENT_ON_100, ++ VEND1_LED_REG_A_EVENT_ON_1000, ++ VEND1_LED_REG_A_EVENT_ON_2500, ++ VEND1_LED_REG_A_EVENT_ON_5000, ++ VEND1_LED_REG_A_EVENT_ON_10000, ++ VEND1_LED_REG_A_EVENT_ON_FE_GE, ++ VEND1_LED_REG_A_EVENT_ON_NG, ++ VEND1_LED_REG_A_EVENT_ON_FULL_DUPLEX, ++ VEND1_LED_REG_A_EVENT_ON_COLLISION, ++ VEND1_LED_REG_A_EVENT_BLINK_TX, ++ VEND1_LED_REG_A_EVENT_BLINK_RX, ++ VEND1_LED_REG_A_EVENT_BLINK_ACT, ++ VEND1_LED_REG_A_EVENT_ON_LINK, ++ VEND1_LED_REG_A_EVENT_ON_LINK_BLINK_ACT, ++ VEND1_LED_REG_A_EVENT_ON_LINK_BLINK_RX, ++ VEND1_LED_REG_A_EVENT_ON_FE_GE_BLINK_ACT, ++ VEND1_LED_REG_A_EVENT_ON_NG_BLINK_ACT, ++ VEND1_LED_REG_A_EVENT_ON_NG_BLINK_FE_GE, ++ VEND1_LED_REG_A_EVENT_ON_FD_BLINK_COLLISION, ++ VEND1_LED_REG_A_EVENT_ON, ++ VEND1_LED_REG_A_EVENT_OFF, ++}; ++ ++struct as21xxx_led_pattern_info { ++ unsigned int pattern; ++ u16 val; ++}; ++ ++struct as21xxx_priv { ++ bool parity_status; ++ /* Protect concurrent IPC access */ ++ struct mutex ipc_lock; ++}; ++ ++static struct as21xxx_led_pattern_info as21xxx_led_supported_pattern[] = { ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10), ++ .val = VEND1_LED_REG_A_EVENT_ON_10 ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_100), ++ .val = VEND1_LED_REG_A_EVENT_ON_100 ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_1000), ++ .val = VEND1_LED_REG_A_EVENT_ON_1000 ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_2500), ++ .val = VEND1_LED_REG_A_EVENT_ON_2500 ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_5000), ++ .val = VEND1_LED_REG_A_EVENT_ON_5000 ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10000), ++ .val = VEND1_LED_REG_A_EVENT_ON_10000 ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK), ++ .val = VEND1_LED_REG_A_EVENT_ON_LINK ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000), ++ .val = VEND1_LED_REG_A_EVENT_ON_FE_GE ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_2500) | ++ BIT(TRIGGER_NETDEV_LINK_5000) | ++ BIT(TRIGGER_NETDEV_LINK_10000), ++ .val = VEND1_LED_REG_A_EVENT_ON_NG ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_FULL_DUPLEX), ++ .val = VEND1_LED_REG_A_EVENT_ON_FULL_DUPLEX ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_TX), ++ .val = VEND1_LED_REG_A_EVENT_BLINK_TX ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_RX), ++ .val = VEND1_LED_REG_A_EVENT_BLINK_RX ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_TX) | ++ BIT(TRIGGER_NETDEV_RX), ++ .val = VEND1_LED_REG_A_EVENT_BLINK_ACT ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_LINK_2500) | ++ BIT(TRIGGER_NETDEV_LINK_5000) | ++ BIT(TRIGGER_NETDEV_LINK_10000), ++ .val = VEND1_LED_REG_A_EVENT_ON_LINK ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_LINK_2500) | ++ BIT(TRIGGER_NETDEV_LINK_5000) | ++ BIT(TRIGGER_NETDEV_LINK_10000) | ++ BIT(TRIGGER_NETDEV_TX) | ++ BIT(TRIGGER_NETDEV_RX), ++ .val = VEND1_LED_REG_A_EVENT_ON_LINK_BLINK_ACT ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_LINK_2500) | ++ BIT(TRIGGER_NETDEV_LINK_5000) | ++ BIT(TRIGGER_NETDEV_LINK_10000) | ++ BIT(TRIGGER_NETDEV_RX), ++ .val = VEND1_LED_REG_A_EVENT_ON_LINK_BLINK_RX ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_10) | ++ BIT(TRIGGER_NETDEV_LINK_100) | ++ BIT(TRIGGER_NETDEV_LINK_1000) | ++ BIT(TRIGGER_NETDEV_TX) | ++ BIT(TRIGGER_NETDEV_RX), ++ .val = VEND1_LED_REG_A_EVENT_ON_FE_GE_BLINK_ACT ++ }, ++ { ++ .pattern = BIT(TRIGGER_NETDEV_LINK_2500) | ++ BIT(TRIGGER_NETDEV_LINK_5000) | ++ BIT(TRIGGER_NETDEV_LINK_10000) | ++ BIT(TRIGGER_NETDEV_TX) | ++ BIT(TRIGGER_NETDEV_RX), ++ .val = VEND1_LED_REG_A_EVENT_ON_NG_BLINK_ACT ++ } ++}; ++ ++static int aeon_firmware_boot(struct phy_device *phydev, const u8 *data, ++ size_t size) ++{ ++ int i, ret; ++ u16 val; ++ ++ ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLB_REG_CPU_CTRL, ++ VEND1_GLB_CPU_CTRL_MASK, AEON_CPU_CTRL_FW_LOAD); ++ if (ret) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_FW_START_ADDR, ++ AEON_BOOT_ADDR); ++ if (ret) ++ return ret; ++ ++ ret = phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_GLB_REG_MDIO_INDIRECT_ADDRCMD, ++ 0x3ffc, 0xc000); ++ if (ret) ++ return ret; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_GLB_REG_MDIO_INDIRECT_STATUS); ++ if (val > 1) { ++ phydev_err(phydev, "wrong origin mdio_indirect_status: %x\n", val); ++ return -EINVAL; ++ } ++ ++ /* Firmware is always aligned to u16 */ ++ for (i = 0; i < size; i += 2) { ++ val = data[i + 1] << 8 | data[i]; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_GLB_REG_MDIO_INDIRECT_LOAD, val); ++ if (ret) ++ return ret; ++ } ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_GLB_REG_CPU_RESET_ADDR_LO_BASEADDR, ++ lower_16_bits(AEON_CPU_BOOT_ADDR)); ++ if (ret) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_GLB_REG_CPU_RESET_ADDR_HI_BASEADDR, ++ upper_16_bits(AEON_CPU_BOOT_ADDR)); ++ if (ret) ++ return ret; ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND1, VEND1_GLB_REG_CPU_CTRL, ++ VEND1_GLB_CPU_CTRL_MASK, AEON_CPU_CTRL_FW_START); ++} ++ ++static int aeon_firmware_load(struct phy_device *phydev) ++{ ++ struct device *dev = &phydev->mdio.dev; ++ const struct firmware *fw; ++ const char *fw_name; ++ int ret; ++ ++ ret = of_property_read_string(dev->of_node, "firmware-name", ++ &fw_name); ++ if (ret) ++ return ret; ++ ++ ret = request_firmware(&fw, fw_name, dev); ++ if (ret) { ++ phydev_err(phydev, "failed to find FW file %s (%d)\n", ++ fw_name, ret); ++ return ret; ++ } ++ ++ ret = aeon_firmware_boot(phydev, fw->data, fw->size); ++ ++ release_firmware(fw); ++ ++ return ret; ++} ++ ++static bool aeon_ipc_ready(u16 val, bool parity_status) ++{ ++ u16 status; ++ ++ if (FIELD_GET(AEON_IPC_STS_PARITY, val) != parity_status) ++ return false; ++ ++ status = val & AEON_IPC_STS_STATUS; ++ ++ return status != AEON_IPC_STS_STATUS_RCVD && ++ status != AEON_IPC_STS_STATUS_PROCESS && ++ status != AEON_IPC_STS_STATUS_BUSY; ++} ++ ++static int aeon_ipc_wait_cmd(struct phy_device *phydev, bool parity_status) ++{ ++ u16 val; ++ ++ /* Exit condition logic: ++ * - Wait for parity bit equal ++ * - Wait for status success, error OR ready ++ */ ++ return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, VEND1_IPC_STS, val, ++ aeon_ipc_ready(val, parity_status), ++ AEON_IPC_DELAY, AEON_IPC_TIMEOUT, false); ++} ++ ++static int aeon_ipc_send_cmd(struct phy_device *phydev, ++ struct as21xxx_priv *priv, ++ u16 cmd, u16 *ret_sts) ++{ ++ bool curr_parity; ++ int ret; ++ ++ /* The IPC sync by using a single parity bit. ++ * Each CMD have alternately this bit set or clear ++ * to understand correct flow and packet order. ++ */ ++ curr_parity = priv->parity_status; ++ if (priv->parity_status) ++ cmd |= AEON_IPC_CMD_PARITY; ++ ++ /* Always update parity for next packet */ ++ priv->parity_status = !priv->parity_status; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_IPC_CMD, cmd); ++ if (ret) ++ return ret; ++ ++ /* Wait for packet to be processed */ ++ usleep_range(AEON_IPC_DELAY, AEON_IPC_DELAY + 5000); ++ ++ /* With no ret_sts, ignore waiting for packet completion ++ * (ipc parity bit sync) ++ */ ++ if (!ret_sts) ++ return 0; ++ ++ ret = aeon_ipc_wait_cmd(phydev, curr_parity); ++ if (ret) ++ return ret; ++ ++ ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_IPC_STS); ++ if (ret < 0) ++ return ret; ++ ++ *ret_sts = ret; ++ if ((*ret_sts & AEON_IPC_STS_STATUS) != AEON_IPC_STS_STATUS_SUCCESS) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++/* If data is NULL, return 0 or negative error. ++ * If data not NULL, return number of Bytes received from IPC or ++ * a negative error. ++ */ ++static int aeon_ipc_send_msg(struct phy_device *phydev, ++ u16 opcode, u16 *data, unsigned int data_len, ++ u16 *ret_data) ++{ ++ struct as21xxx_priv *priv = phydev->priv; ++ unsigned int ret_size; ++ u16 cmd, ret_sts; ++ int ret; ++ int i; ++ ++ /* IPC have a max of 8 register to transfer data, ++ * make sure we never exceed this. ++ */ ++ if (data_len > AEON_IPC_DATA_MAX) ++ return -EINVAL; ++ ++ for (i = 0; i < data_len / sizeof(u16); i++) ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_IPC_DATA(i), ++ data[i]); ++ ++ cmd = FIELD_PREP(AEON_IPC_CMD_SIZE, data_len) | ++ FIELD_PREP(AEON_IPC_CMD_OPCODE, opcode); ++ ++ mutex_lock(&priv->ipc_lock); ++ ++ ret = aeon_ipc_send_cmd(phydev, priv, cmd, &ret_sts); ++ if (ret) { ++ phydev_err(phydev, "failed to send ipc msg for %x: %d\n", ++ opcode, ret); ++ goto out; ++ } ++ ++ if (!data) ++ goto out; ++ ++ if ((ret_sts & AEON_IPC_STS_STATUS) == AEON_IPC_STS_STATUS_ERROR) { ++ ret = -EINVAL; ++ goto out; ++ } ++ ++ /* Prevent IPC from stack smashing the kernel. ++ * We can't trust IPC to return a good value and we always ++ * preallocate space for 16 Bytes. ++ */ ++ ret_size = FIELD_GET(AEON_IPC_STS_SIZE, ret_sts); ++ if (ret_size > AEON_IPC_DATA_MAX) { ++ ret = -EINVAL; ++ goto out; ++ } ++ ++ /* Read data from IPC data register for ret_size value from IPC */ ++ for (i = 0; i < DIV_ROUND_UP(ret_size, sizeof(u16)); i++) { ++ ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_IPC_DATA(i)); ++ if (ret < 0) ++ goto out; ++ ++ ret_data[i] = ret; ++ } ++ ++ ret = ret_size; ++ ++out: ++ mutex_unlock(&priv->ipc_lock); ++ ++ return ret; ++} ++ ++static int aeon_ipc_noop(struct phy_device *phydev, ++ struct as21xxx_priv *priv, u16 *ret_sts) ++{ ++ u16 cmd; ++ ++ cmd = FIELD_PREP(AEON_IPC_CMD_SIZE, 0) | ++ FIELD_PREP(AEON_IPC_CMD_OPCODE, IPC_CMD_NOOP); ++ ++ return aeon_ipc_send_cmd(phydev, priv, cmd, ret_sts); ++} ++ ++/* Logic to sync parity bit with IPC. ++ * We send 2 NOP cmd with same partity and we wait for IPC ++ * to handle the packet only for the second one. This way ++ * we make sure we are sync for every next cmd. ++ */ ++static int aeon_ipc_sync_parity(struct phy_device *phydev, ++ struct as21xxx_priv *priv) ++{ ++ u16 ret_sts; ++ int ret; ++ ++ mutex_lock(&priv->ipc_lock); ++ ++ /* Send NOP with no parity */ ++ aeon_ipc_noop(phydev, priv, NULL); ++ ++ /* Reset packet parity */ ++ priv->parity_status = false; ++ ++ /* Send second NOP with no parity */ ++ ret = aeon_ipc_noop(phydev, priv, &ret_sts); ++ ++ mutex_unlock(&priv->ipc_lock); ++ ++ /* We expect to return -EINVAL */ ++ if (ret != -EINVAL) ++ return ret; ++ ++ if ((ret_sts & AEON_IPC_STS_STATUS) != AEON_IPC_STS_STATUS_READY) { ++ phydev_err(phydev, "Invalid IPC status on sync parity: %x\n", ++ ret_sts); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static int aeon_ipc_get_fw_version(struct phy_device *phydev) ++{ ++ u16 ret_data[AEON_IPC_DATA_NUM_REGISTERS], data[1]; ++ char fw_version[AEON_IPC_DATA_MAX + 1]; ++ int ret; ++ ++ data[0] = IPC_INFO_VERSION; ++ ++ ret = aeon_ipc_send_msg(phydev, IPC_CMD_INFO, data, ++ sizeof(data), ret_data); ++ if (ret < 0) ++ return ret; ++ ++ /* Make sure FW version is NULL terminated */ ++ memcpy(fw_version, ret_data, ret); ++ fw_version[ret] = '\0'; ++ ++ phydev_info(phydev, "Firmware Version: %s\n", fw_version); ++ ++ return 0; ++} ++ ++static int aeon_dpc_ra_enable(struct phy_device *phydev) ++{ ++ u16 data[2]; ++ ++ data[0] = IPC_CFG_PARAM_DIRECT; ++ data[1] = IPC_CFG_PARAM_DIRECT_DPC_RA; ++ ++ return aeon_ipc_send_msg(phydev, IPC_CMD_CFG_PARAM, data, ++ sizeof(data), NULL); ++} ++ ++static int as21xxx_probe(struct phy_device *phydev) ++{ ++ struct as21xxx_priv *priv; ++ int ret; ++ ++ priv = devm_kzalloc(&phydev->mdio.dev, ++ sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ phydev->priv = priv; ++ ++ ret = devm_mutex_init(&phydev->mdio.dev, ++ &priv->ipc_lock); ++ if (ret) ++ return ret; ++ ++ ret = aeon_ipc_sync_parity(phydev, priv); ++ if (ret) ++ return ret; ++ ++ ret = aeon_ipc_get_fw_version(phydev); ++ if (ret) ++ return ret; ++ ++ /* Enable PTP clk if not already Enabled */ ++ ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PTP_CLK, ++ VEND1_PTP_CLK_EN); ++ if (ret) ++ return ret; ++ ++ return aeon_dpc_ra_enable(phydev); ++} ++ ++static int as21xxx_read_link(struct phy_device *phydev, int *bmcr) ++{ ++ int status; ++ ++ /* Normal C22 BMCR report inconsistent data, use ++ * the mapped C22 in C45 to have more consistent link info. ++ */ ++ *bmcr = phy_read_mmd(phydev, MDIO_MMD_AN, ++ AS21XXX_MDIO_AN_C22 + MII_BMCR); ++ if (*bmcr < 0) ++ return *bmcr; ++ ++ /* Autoneg is being started, therefore disregard current ++ * link status and report link as down. ++ */ ++ if (*bmcr & BMCR_ANRESTART) { ++ phydev->link = 0; ++ return 0; ++ } ++ ++ status = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); ++ if (status < 0) ++ return status; ++ ++ phydev->link = !!(status & MDIO_STAT1_LSTATUS); ++ ++ return 0; ++} ++ ++static int as21xxx_read_c22_lpa(struct phy_device *phydev) ++{ ++ int lpagb; ++ ++ /* MII_STAT1000 are only filled in the mapped C22 ++ * in C45, use that to fill lpagb values and check. ++ */ ++ lpagb = phy_read_mmd(phydev, MDIO_MMD_AN, ++ AS21XXX_MDIO_AN_C22 + MII_STAT1000); ++ if (lpagb < 0) ++ return lpagb; ++ ++ if (lpagb & LPA_1000MSFAIL) { ++ int adv = phy_read_mmd(phydev, MDIO_MMD_AN, ++ AS21XXX_MDIO_AN_C22 + MII_CTRL1000); ++ ++ if (adv < 0) ++ return adv; ++ ++ if (adv & CTL1000_ENABLE_MASTER) ++ phydev_err(phydev, "Master/Slave resolution failed, maybe conflicting manual settings?\n"); ++ else ++ phydev_err(phydev, "Master/Slave resolution failed\n"); ++ return -ENOLINK; ++ } ++ ++ mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, ++ lpagb); ++ ++ return 0; ++} ++ ++static int as21xxx_read_status(struct phy_device *phydev) ++{ ++ int bmcr, old_link = phydev->link; ++ int ret; ++ ++ ret = as21xxx_read_link(phydev, &bmcr); ++ if (ret) ++ return ret; ++ ++ /* why bother the PHY if nothing can have changed */ ++ if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) ++ return 0; ++ ++ phydev->speed = SPEED_UNKNOWN; ++ phydev->duplex = DUPLEX_UNKNOWN; ++ phydev->pause = 0; ++ phydev->asym_pause = 0; ++ ++ if (phydev->autoneg == AUTONEG_ENABLE) { ++ ret = genphy_c45_read_lpa(phydev); ++ if (ret) ++ return ret; ++ ++ ret = as21xxx_read_c22_lpa(phydev); ++ if (ret) ++ return ret; ++ ++ phy_resolve_aneg_linkmode(phydev); ++ } else { ++ int speed; ++ ++ linkmode_zero(phydev->lp_advertising); ++ ++ speed = phy_read_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_SPEED_STATUS); ++ if (speed < 0) ++ return speed; ++ ++ switch (speed & VEND1_SPEED_STATUS) { ++ case VEND1_SPEED_10000: ++ phydev->speed = SPEED_10000; ++ phydev->duplex = DUPLEX_FULL; ++ break; ++ case VEND1_SPEED_5000: ++ phydev->speed = SPEED_5000; ++ phydev->duplex = DUPLEX_FULL; ++ break; ++ case VEND1_SPEED_2500: ++ phydev->speed = SPEED_2500; ++ phydev->duplex = DUPLEX_FULL; ++ break; ++ case VEND1_SPEED_1000: ++ phydev->speed = SPEED_1000; ++ if (bmcr & BMCR_FULLDPLX) ++ phydev->duplex = DUPLEX_FULL; ++ else ++ phydev->duplex = DUPLEX_HALF; ++ break; ++ case VEND1_SPEED_100: ++ phydev->speed = SPEED_100; ++ phydev->duplex = DUPLEX_FULL; ++ break; ++ case VEND1_SPEED_10: ++ phydev->speed = SPEED_10; ++ phydev->duplex = DUPLEX_FULL; ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ ++ return 0; ++} ++ ++static int as21xxx_led_brightness_set(struct phy_device *phydev, ++ u8 index, enum led_brightness value) ++{ ++ u16 val = VEND1_LED_REG_A_EVENT_OFF; ++ ++ if (index > AEON_MAX_LEDS) ++ return -EINVAL; ++ ++ if (value) ++ val = VEND1_LED_REG_A_EVENT_ON; ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_LED_REG(index), ++ VEND1_LED_REG_A_EVENT, ++ FIELD_PREP(VEND1_LED_REG_A_EVENT, val)); ++} ++ ++static int as21xxx_led_hw_is_supported(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ int i; ++ ++ if (index > AEON_MAX_LEDS) ++ return -EINVAL; ++ ++ for (i = 0; i < ARRAY_SIZE(as21xxx_led_supported_pattern); i++) ++ if (rules == as21xxx_led_supported_pattern[i].pattern) ++ return 0; ++ ++ return -EOPNOTSUPP; ++} ++ ++static int as21xxx_led_hw_control_get(struct phy_device *phydev, u8 index, ++ unsigned long *rules) ++{ ++ int i, val; ++ ++ if (index > AEON_MAX_LEDS) ++ return -EINVAL; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_LED_REG(index)); ++ if (val < 0) ++ return val; ++ ++ val = FIELD_GET(VEND1_LED_REG_A_EVENT, val); ++ for (i = 0; i < ARRAY_SIZE(as21xxx_led_supported_pattern); i++) ++ if (val == as21xxx_led_supported_pattern[i].val) { ++ *rules = as21xxx_led_supported_pattern[i].pattern; ++ return 0; ++ } ++ ++ /* Should be impossible */ ++ return -EINVAL; ++} ++ ++static int as21xxx_led_hw_control_set(struct phy_device *phydev, u8 index, ++ unsigned long rules) ++{ ++ u16 val = 0; ++ int i; ++ ++ if (index > AEON_MAX_LEDS) ++ return -EINVAL; ++ ++ for (i = 0; i < ARRAY_SIZE(as21xxx_led_supported_pattern); i++) ++ if (rules == as21xxx_led_supported_pattern[i].pattern) { ++ val = as21xxx_led_supported_pattern[i].val; ++ break; ++ } ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_LED_REG(index), ++ VEND1_LED_REG_A_EVENT, ++ FIELD_PREP(VEND1_LED_REG_A_EVENT, val)); ++} ++ ++static int as21xxx_led_polarity_set(struct phy_device *phydev, int index, ++ unsigned long modes) ++{ ++ bool led_active_low = false; ++ u16 mask, val = 0; ++ u32 mode; ++ ++ if (index > AEON_MAX_LEDS) ++ return -EINVAL; ++ ++ for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { ++ switch (mode) { ++ case PHY_LED_ACTIVE_LOW: ++ led_active_low = true; ++ break; ++ case PHY_LED_ACTIVE_HIGH: /* default mode */ ++ led_active_low = false; ++ break; ++ default: ++ return -EINVAL; ++ } ++ } ++ ++ mask = VEND1_GLB_CPU_CTRL_LED_POLARITY(index); ++ if (led_active_low) ++ val = VEND1_GLB_CPU_CTRL_LED_POLARITY(index); ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND1, ++ VEND1_GLB_REG_CPU_CTRL, ++ mask, val); ++} ++ ++static int as21xxx_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) ++{ ++ struct as21xxx_priv *priv; ++ u16 ret_sts; ++ u32 phy_id; ++ int ret; ++ ++ /* Skip PHY that are not AS21xxx or already have firmware loaded */ ++ if (phydev->c45_ids.device_ids[MDIO_MMD_PCS] != PHY_ID_AS21XXX) ++ return genphy_match_phy_device(phydev, phydrv); ++ ++ /* Read PHY ID to handle firmware just loaded */ ++ ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MII_PHYSID1); ++ if (ret < 0) ++ return ret; ++ phy_id = ret << 16; ++ ++ ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MII_PHYSID2); ++ if (ret < 0) ++ return ret; ++ phy_id |= ret; ++ ++ /* With PHY ID not the generic AS21xxx one assume ++ * the firmware just loaded ++ */ ++ if (phy_id != PHY_ID_AS21XXX) ++ return phy_id == phydrv->phy_id; ++ ++ /* Allocate temp priv and load the firmware */ ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ mutex_init(&priv->ipc_lock); ++ ++ ret = aeon_firmware_load(phydev); ++ if (ret) ++ goto out; ++ ++ /* Sync parity... */ ++ ret = aeon_ipc_sync_parity(phydev, priv); ++ if (ret) ++ goto out; ++ ++ /* ...and send a third NOOP cmd to wait for firmware finish loading */ ++ ret = aeon_ipc_noop(phydev, priv, &ret_sts); ++ if (ret) ++ goto out; ++ ++out: ++ mutex_destroy(&priv->ipc_lock); ++ kfree(priv); ++ ++ /* Return can either be 0 or a negative error code. ++ * Returning 0 here means THIS is NOT a suitable PHY. ++ * ++ * For the specific case of the generic Aeonsemi PHY ID that ++ * needs the firmware the be loaded first to have a correct PHY ID, ++ * this is OK as a matching PHY ID will be found right after. ++ * This relies on the driver probe order where the first PHY driver ++ * probed is the generic one. ++ */ ++ return ret; ++} ++ ++static struct phy_driver as21xxx_drivers[] = { ++ { ++ /* PHY expose in C45 as 0x7500 0x9410 ++ * before firmware is loaded. ++ * This driver entry must be attempted first to load ++ * the firmware and thus update the ID registers. ++ */ ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21XXX), ++ .name = "Aeonsemi AS21xxx", ++ .match_phy_device = as21xxx_match_phy_device, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21011JB1), ++ .name = "Aeonsemi AS21011JB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21011PB1), ++ .name = "Aeonsemi AS21011PB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21010PB1), ++ .name = "Aeonsemi AS21010PB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21010JB1), ++ .name = "Aeonsemi AS21010JB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21210PB1), ++ .name = "Aeonsemi AS21210PB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21510JB1), ++ .name = "Aeonsemi AS21510JB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21510PB1), ++ .name = "Aeonsemi AS21510PB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21511JB1), ++ .name = "Aeonsemi AS21511JB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21210JB1), ++ .name = "Aeonsemi AS21210JB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++ { ++ PHY_ID_MATCH_EXACT(PHY_ID_AS21511PB1), ++ .name = "Aeonsemi AS21511PB1", ++ .probe = as21xxx_probe, ++ .match_phy_device = as21xxx_match_phy_device, ++ .read_status = as21xxx_read_status, ++ .led_brightness_set = as21xxx_led_brightness_set, ++ .led_hw_is_supported = as21xxx_led_hw_is_supported, ++ .led_hw_control_set = as21xxx_led_hw_control_set, ++ .led_hw_control_get = as21xxx_led_hw_control_get, ++ .led_polarity_set = as21xxx_led_polarity_set, ++ }, ++}; ++module_phy_driver(as21xxx_drivers); ++ ++static struct mdio_device_id __maybe_unused as21xxx_tbl[] = { ++ { PHY_ID_MATCH_VENDOR(PHY_VENDOR_AEONSEMI) }, ++ { } ++}; ++MODULE_DEVICE_TABLE(mdio, as21xxx_tbl); ++ ++MODULE_DESCRIPTION("Aeonsemi AS21xxx PHY driver"); ++MODULE_AUTHOR("Christian Marangi "); ++MODULE_LICENSE("GPL"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-01-v6.18-net-dsa-Move-KS8995-to-the-DSA-subsystem.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-01-v6.18-net-dsa-Move-KS8995-to-the-DSA-subsystem.patch new file mode 100755 index 0000000..2045956 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-01-v6.18-net-dsa-Move-KS8995-to-the-DSA-subsystem.patch @@ -0,0 +1,1092 @@ +From 9c370f7f92b0232fe925ca2caefb5e3126a0357d Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 13 Aug 2025 23:43:03 +0200 +Subject: [PATCH 1/4] net: dsa: Move KS8995 to the DSA subsystem + +By reading the datasheets for the KS8995 it is obvious that this +is a 100 Mbit DSA switch. + +Let us start the refactoring by moving it to the DSA subsystem to +preserve development history. + +Verified that the chip still probes the same after this patch +provided CONFIG_HAVE_NET_DSA, CONFIG_NET_DSA and CONFIG_DSA_KS8995 +are selected. + +Signed-off-by: Linus Walleij +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250813-ks8995-to-dsa-v1-1-75c359ede3a5@linaro.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/Kconfig | 7 +++++++ + drivers/net/dsa/Makefile | 1 + + drivers/net/{phy/spi_ks8995.c => dsa/ks8995.c} | 0 + drivers/net/phy/Kconfig | 4 ---- + drivers/net/phy/Makefile | 1 - + 5 files changed, 8 insertions(+), 5 deletions(-) + rename drivers/net/{phy/spi_ks8995.c => dsa/ks8995.c} (100%) + +--- a/drivers/net/dsa/Kconfig ++++ b/drivers/net/dsa/Kconfig +@@ -98,6 +98,13 @@ config NET_DSA_RZN1_A5PSW + This driver supports the A5PSW switch, which is embedded in Renesas + RZ/N1 SoC. + ++config NET_DSA_KS8995 ++ tristate "Micrel KS8995 family 5-ports 10/100 Ethernet switches" ++ depends on SPI ++ help ++ This driver supports the Micrel KS8995 family of 10/100 Mbit ethernet ++ switches, managed over SPI. ++ + config NET_DSA_SMSC_LAN9303 + tristate + select NET_DSA_TAG_LAN9303 +--- a/drivers/net/dsa/Makefile ++++ b/drivers/net/dsa/Makefile +@@ -5,6 +5,7 @@ obj-$(CONFIG_NET_DSA_LOOP) += dsa_loop.o + ifdef CONFIG_NET_DSA_LOOP + obj-$(CONFIG_FIXED_PHY) += dsa_loop_bdinfo.o + endif ++obj-$(CONFIG_NET_DSA_KS8995) += ks8995.o + obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o + obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o + obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -443,7 +443,3 @@ config XILINX_GMII2RGMII + Ethernet physical media devices and the Gigabit Ethernet controller. + + endif # PHYLIB +- +-config MICREL_KS8995MA +- tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch" +- depends on SPI +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -77,7 +77,6 @@ obj-$(CONFIG_MARVELL_88X2222_PHY) += mar + obj-$(CONFIG_MAXLINEAR_GPHY) += mxl-gpy.o + obj-y += mediatek/ + obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o +-obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o + obj-$(CONFIG_MICREL_PHY) += micrel.o + obj-$(CONFIG_MICROCHIP_PHY) += microchip.o + obj-$(CONFIG_MICROCHIP_T1_PHY) += microchip_t1.o +--- /dev/null ++++ b/drivers/net/dsa/ks8995.c +@@ -0,0 +1,506 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * SPI driver for Micrel/Kendin KS8995M and KSZ8864RMN ethernet switches ++ * ++ * Copyright (C) 2008 Gabor Juhos ++ * ++ * This file was based on: drivers/spi/at25.c ++ * Copyright (C) 2006 David Brownell ++ */ ++ ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#define DRV_VERSION "0.1.1" ++#define DRV_DESC "Micrel KS8995 Ethernet switch SPI driver" ++ ++/* ------------------------------------------------------------------------ */ ++ ++#define KS8995_REG_ID0 0x00 /* Chip ID0 */ ++#define KS8995_REG_ID1 0x01 /* Chip ID1 */ ++ ++#define KS8995_REG_GC0 0x02 /* Global Control 0 */ ++#define KS8995_REG_GC1 0x03 /* Global Control 1 */ ++#define KS8995_REG_GC2 0x04 /* Global Control 2 */ ++#define KS8995_REG_GC3 0x05 /* Global Control 3 */ ++#define KS8995_REG_GC4 0x06 /* Global Control 4 */ ++#define KS8995_REG_GC5 0x07 /* Global Control 5 */ ++#define KS8995_REG_GC6 0x08 /* Global Control 6 */ ++#define KS8995_REG_GC7 0x09 /* Global Control 7 */ ++#define KS8995_REG_GC8 0x0a /* Global Control 8 */ ++#define KS8995_REG_GC9 0x0b /* Global Control 9 */ ++ ++#define KS8995_REG_PC(p, r) ((0x10 * p) + r) /* Port Control */ ++#define KS8995_REG_PS(p, r) ((0x10 * p) + r + 0xe) /* Port Status */ ++ ++#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */ ++#define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */ ++#define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */ ++#define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */ ++#define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */ ++#define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */ ++#define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */ ++#define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */ ++ ++#define KS8995_REG_MAC0 0x68 /* MAC address 0 */ ++#define KS8995_REG_MAC1 0x69 /* MAC address 1 */ ++#define KS8995_REG_MAC2 0x6a /* MAC address 2 */ ++#define KS8995_REG_MAC3 0x6b /* MAC address 3 */ ++#define KS8995_REG_MAC4 0x6c /* MAC address 4 */ ++#define KS8995_REG_MAC5 0x6d /* MAC address 5 */ ++ ++#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */ ++#define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */ ++#define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */ ++#define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */ ++#define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */ ++#define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */ ++#define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */ ++#define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */ ++#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */ ++#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */ ++ ++#define KSZ8864_REG_ID1 0xfe /* Chip ID in bit 7 */ ++ ++#define KS8995_REGS_SIZE 0x80 ++#define KSZ8864_REGS_SIZE 0x100 ++#define KSZ8795_REGS_SIZE 0x100 ++ ++#define ID1_CHIPID_M 0xf ++#define ID1_CHIPID_S 4 ++#define ID1_REVISION_M 0x7 ++#define ID1_REVISION_S 1 ++#define ID1_START_SW 1 /* start the switch */ ++ ++#define FAMILY_KS8995 0x95 ++#define FAMILY_KSZ8795 0x87 ++#define CHIPID_M 0 ++#define KS8995_CHIP_ID 0x00 ++#define KSZ8864_CHIP_ID 0x01 ++#define KSZ8795_CHIP_ID 0x09 ++ ++#define KS8995_CMD_WRITE 0x02U ++#define KS8995_CMD_READ 0x03U ++ ++#define KS8995_RESET_DELAY 10 /* usec */ ++ ++enum ks8995_chip_variant { ++ ks8995, ++ ksz8864, ++ ksz8795, ++ max_variant ++}; ++ ++struct ks8995_chip_params { ++ char *name; ++ int family_id; ++ int chip_id; ++ int regs_size; ++ int addr_width; ++ int addr_shift; ++}; ++ ++static const struct ks8995_chip_params ks8995_chip[] = { ++ [ks8995] = { ++ .name = "KS8995MA", ++ .family_id = FAMILY_KS8995, ++ .chip_id = KS8995_CHIP_ID, ++ .regs_size = KS8995_REGS_SIZE, ++ .addr_width = 8, ++ .addr_shift = 0, ++ }, ++ [ksz8864] = { ++ .name = "KSZ8864RMN", ++ .family_id = FAMILY_KS8995, ++ .chip_id = KSZ8864_CHIP_ID, ++ .regs_size = KSZ8864_REGS_SIZE, ++ .addr_width = 8, ++ .addr_shift = 0, ++ }, ++ [ksz8795] = { ++ .name = "KSZ8795CLX", ++ .family_id = FAMILY_KSZ8795, ++ .chip_id = KSZ8795_CHIP_ID, ++ .regs_size = KSZ8795_REGS_SIZE, ++ .addr_width = 12, ++ .addr_shift = 1, ++ }, ++}; ++ ++struct ks8995_switch { ++ struct spi_device *spi; ++ struct mutex lock; ++ struct gpio_desc *reset_gpio; ++ struct bin_attribute regs_attr; ++ const struct ks8995_chip_params *chip; ++ int revision_id; ++}; ++ ++static const struct spi_device_id ks8995_id[] = { ++ {"ks8995", ks8995}, ++ {"ksz8864", ksz8864}, ++ {"ksz8795", ksz8795}, ++ { } ++}; ++MODULE_DEVICE_TABLE(spi, ks8995_id); ++ ++static const struct of_device_id ks8895_spi_of_match[] = { ++ { .compatible = "micrel,ks8995" }, ++ { .compatible = "micrel,ksz8864" }, ++ { .compatible = "micrel,ksz8795" }, ++ { }, ++}; ++MODULE_DEVICE_TABLE(of, ks8895_spi_of_match); ++ ++static inline u8 get_chip_id(u8 val) ++{ ++ return (val >> ID1_CHIPID_S) & ID1_CHIPID_M; ++} ++ ++static inline u8 get_chip_rev(u8 val) ++{ ++ return (val >> ID1_REVISION_S) & ID1_REVISION_M; ++} ++ ++/* create_spi_cmd - create a chip specific SPI command header ++ * @ks: pointer to switch instance ++ * @cmd: SPI command for switch ++ * @address: register address for command ++ * ++ * Different chip families use different bit pattern to address the switches ++ * registers: ++ * ++ * KS8995: 8bit command + 8bit address ++ * KSZ8795: 3bit command + 12bit address + 1bit TR (?) ++ */ ++static inline __be16 create_spi_cmd(struct ks8995_switch *ks, int cmd, ++ unsigned address) ++{ ++ u16 result = cmd; ++ ++ /* make room for address (incl. address shift) */ ++ result <<= ks->chip->addr_width + ks->chip->addr_shift; ++ /* add address */ ++ result |= address << ks->chip->addr_shift; ++ /* SPI protocol needs big endian */ ++ return cpu_to_be16(result); ++} ++/* ------------------------------------------------------------------------ */ ++static int ks8995_read(struct ks8995_switch *ks, char *buf, ++ unsigned offset, size_t count) ++{ ++ __be16 cmd; ++ struct spi_transfer t[2]; ++ struct spi_message m; ++ int err; ++ ++ cmd = create_spi_cmd(ks, KS8995_CMD_READ, offset); ++ spi_message_init(&m); ++ ++ memset(&t, 0, sizeof(t)); ++ ++ t[0].tx_buf = &cmd; ++ t[0].len = sizeof(cmd); ++ spi_message_add_tail(&t[0], &m); ++ ++ t[1].rx_buf = buf; ++ t[1].len = count; ++ spi_message_add_tail(&t[1], &m); ++ ++ mutex_lock(&ks->lock); ++ err = spi_sync(ks->spi, &m); ++ mutex_unlock(&ks->lock); ++ ++ return err ? err : count; ++} ++ ++static int ks8995_write(struct ks8995_switch *ks, char *buf, ++ unsigned offset, size_t count) ++{ ++ __be16 cmd; ++ struct spi_transfer t[2]; ++ struct spi_message m; ++ int err; ++ ++ cmd = create_spi_cmd(ks, KS8995_CMD_WRITE, offset); ++ spi_message_init(&m); ++ ++ memset(&t, 0, sizeof(t)); ++ ++ t[0].tx_buf = &cmd; ++ t[0].len = sizeof(cmd); ++ spi_message_add_tail(&t[0], &m); ++ ++ t[1].tx_buf = buf; ++ t[1].len = count; ++ spi_message_add_tail(&t[1], &m); ++ ++ mutex_lock(&ks->lock); ++ err = spi_sync(ks->spi, &m); ++ mutex_unlock(&ks->lock); ++ ++ return err ? err : count; ++} ++ ++static inline int ks8995_read_reg(struct ks8995_switch *ks, u8 addr, u8 *buf) ++{ ++ return ks8995_read(ks, buf, addr, 1) != 1; ++} ++ ++static inline int ks8995_write_reg(struct ks8995_switch *ks, u8 addr, u8 val) ++{ ++ char buf = val; ++ ++ return ks8995_write(ks, &buf, addr, 1) != 1; ++} ++ ++/* ------------------------------------------------------------------------ */ ++ ++static int ks8995_stop(struct ks8995_switch *ks) ++{ ++ return ks8995_write_reg(ks, KS8995_REG_ID1, 0); ++} ++ ++static int ks8995_start(struct ks8995_switch *ks) ++{ ++ return ks8995_write_reg(ks, KS8995_REG_ID1, 1); ++} ++ ++static int ks8995_reset(struct ks8995_switch *ks) ++{ ++ int err; ++ ++ err = ks8995_stop(ks); ++ if (err) ++ return err; ++ ++ udelay(KS8995_RESET_DELAY); ++ ++ return ks8995_start(ks); ++} ++ ++static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj, ++ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) ++{ ++ struct device *dev; ++ struct ks8995_switch *ks8995; ++ ++ dev = kobj_to_dev(kobj); ++ ks8995 = dev_get_drvdata(dev); ++ ++ return ks8995_read(ks8995, buf, off, count); ++} ++ ++static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj, ++ struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) ++{ ++ struct device *dev; ++ struct ks8995_switch *ks8995; ++ ++ dev = kobj_to_dev(kobj); ++ ks8995 = dev_get_drvdata(dev); ++ ++ return ks8995_write(ks8995, buf, off, count); ++} ++ ++/* ks8995_get_revision - get chip revision ++ * @ks: pointer to switch instance ++ * ++ * Verify chip family and id and get chip revision. ++ */ ++static int ks8995_get_revision(struct ks8995_switch *ks) ++{ ++ int err; ++ u8 id0, id1, ksz8864_id; ++ ++ /* read family id */ ++ err = ks8995_read_reg(ks, KS8995_REG_ID0, &id0); ++ if (err) { ++ err = -EIO; ++ goto err_out; ++ } ++ ++ /* verify family id */ ++ if (id0 != ks->chip->family_id) { ++ dev_err(&ks->spi->dev, "chip family id mismatch: expected 0x%02x but 0x%02x read\n", ++ ks->chip->family_id, id0); ++ err = -ENODEV; ++ goto err_out; ++ } ++ ++ switch (ks->chip->family_id) { ++ case FAMILY_KS8995: ++ /* try reading chip id at CHIP ID1 */ ++ err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1); ++ if (err) { ++ err = -EIO; ++ goto err_out; ++ } ++ ++ /* verify chip id */ ++ if ((get_chip_id(id1) == CHIPID_M) && ++ (get_chip_id(id1) == ks->chip->chip_id)) { ++ /* KS8995MA */ ++ ks->revision_id = get_chip_rev(id1); ++ } else if (get_chip_id(id1) != CHIPID_M) { ++ /* KSZ8864RMN */ ++ err = ks8995_read_reg(ks, KS8995_REG_ID1, &ksz8864_id); ++ if (err) { ++ err = -EIO; ++ goto err_out; ++ } ++ ++ if ((ksz8864_id & 0x80) && ++ (ks->chip->chip_id == KSZ8864_CHIP_ID)) { ++ ks->revision_id = get_chip_rev(id1); ++ } ++ ++ } else { ++ dev_err(&ks->spi->dev, "unsupported chip id for KS8995 family: 0x%02x\n", ++ id1); ++ err = -ENODEV; ++ } ++ break; ++ case FAMILY_KSZ8795: ++ /* try reading chip id at CHIP ID1 */ ++ err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1); ++ if (err) { ++ err = -EIO; ++ goto err_out; ++ } ++ ++ if (get_chip_id(id1) == ks->chip->chip_id) { ++ ks->revision_id = get_chip_rev(id1); ++ } else { ++ dev_err(&ks->spi->dev, "unsupported chip id for KSZ8795 family: 0x%02x\n", ++ id1); ++ err = -ENODEV; ++ } ++ break; ++ default: ++ dev_err(&ks->spi->dev, "unsupported family id: 0x%02x\n", id0); ++ err = -ENODEV; ++ break; ++ } ++err_out: ++ return err; ++} ++ ++static const struct bin_attribute ks8995_registers_attr = { ++ .attr = { ++ .name = "registers", ++ .mode = 0600, ++ }, ++ .size = KS8995_REGS_SIZE, ++ .read = ks8995_registers_read, ++ .write = ks8995_registers_write, ++}; ++ ++/* ------------------------------------------------------------------------ */ ++static int ks8995_probe(struct spi_device *spi) ++{ ++ struct ks8995_switch *ks; ++ int err; ++ int variant = spi_get_device_id(spi)->driver_data; ++ ++ if (variant >= max_variant) { ++ dev_err(&spi->dev, "bad chip variant %d\n", variant); ++ return -ENODEV; ++ } ++ ++ ks = devm_kzalloc(&spi->dev, sizeof(*ks), GFP_KERNEL); ++ if (!ks) ++ return -ENOMEM; ++ ++ mutex_init(&ks->lock); ++ ks->spi = spi; ++ ks->chip = &ks8995_chip[variant]; ++ ++ ks->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", ++ GPIOD_OUT_HIGH); ++ err = PTR_ERR_OR_ZERO(ks->reset_gpio); ++ if (err) { ++ dev_err(&spi->dev, ++ "failed to get reset gpio: %d\n", err); ++ return err; ++ } ++ ++ err = gpiod_set_consumer_name(ks->reset_gpio, "switch-reset"); ++ if (err) ++ return err; ++ ++ /* de-assert switch reset */ ++ /* FIXME: this likely requires a delay */ ++ gpiod_set_value_cansleep(ks->reset_gpio, 0); ++ ++ spi_set_drvdata(spi, ks); ++ ++ spi->mode = SPI_MODE_0; ++ spi->bits_per_word = 8; ++ err = spi_setup(spi); ++ if (err) { ++ dev_err(&spi->dev, "spi_setup failed, err=%d\n", err); ++ return err; ++ } ++ ++ err = ks8995_get_revision(ks); ++ if (err) ++ return err; ++ ++ memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr)); ++ ks->regs_attr.size = ks->chip->regs_size; ++ ++ err = ks8995_reset(ks); ++ if (err) ++ return err; ++ ++ sysfs_attr_init(&ks->regs_attr.attr); ++ err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr); ++ if (err) { ++ dev_err(&spi->dev, "unable to create sysfs file, err=%d\n", ++ err); ++ return err; ++ } ++ ++ dev_info(&spi->dev, "%s device found, Chip ID:%x, Revision:%x\n", ++ ks->chip->name, ks->chip->chip_id, ks->revision_id); ++ ++ return 0; ++} ++ ++static void ks8995_remove(struct spi_device *spi) ++{ ++ struct ks8995_switch *ks = spi_get_drvdata(spi); ++ ++ sysfs_remove_bin_file(&spi->dev.kobj, &ks->regs_attr); ++ ++ /* assert reset */ ++ gpiod_set_value_cansleep(ks->reset_gpio, 1); ++} ++ ++/* ------------------------------------------------------------------------ */ ++static struct spi_driver ks8995_driver = { ++ .driver = { ++ .name = "spi-ks8995", ++ .of_match_table = ks8895_spi_of_match, ++ }, ++ .probe = ks8995_probe, ++ .remove = ks8995_remove, ++ .id_table = ks8995_id, ++}; ++ ++module_spi_driver(ks8995_driver); ++ ++MODULE_DESCRIPTION(DRV_DESC); ++MODULE_VERSION(DRV_VERSION); ++MODULE_AUTHOR("Gabor Juhos "); ++MODULE_LICENSE("GPL v2"); +--- a/drivers/net/phy/spi_ks8995.c ++++ /dev/null +@@ -1,506 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0 +-/* +- * SPI driver for Micrel/Kendin KS8995M and KSZ8864RMN ethernet switches +- * +- * Copyright (C) 2008 Gabor Juhos +- * +- * This file was based on: drivers/spi/at25.c +- * Copyright (C) 2006 David Brownell +- */ +- +-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#include +- +-#define DRV_VERSION "0.1.1" +-#define DRV_DESC "Micrel KS8995 Ethernet switch SPI driver" +- +-/* ------------------------------------------------------------------------ */ +- +-#define KS8995_REG_ID0 0x00 /* Chip ID0 */ +-#define KS8995_REG_ID1 0x01 /* Chip ID1 */ +- +-#define KS8995_REG_GC0 0x02 /* Global Control 0 */ +-#define KS8995_REG_GC1 0x03 /* Global Control 1 */ +-#define KS8995_REG_GC2 0x04 /* Global Control 2 */ +-#define KS8995_REG_GC3 0x05 /* Global Control 3 */ +-#define KS8995_REG_GC4 0x06 /* Global Control 4 */ +-#define KS8995_REG_GC5 0x07 /* Global Control 5 */ +-#define KS8995_REG_GC6 0x08 /* Global Control 6 */ +-#define KS8995_REG_GC7 0x09 /* Global Control 7 */ +-#define KS8995_REG_GC8 0x0a /* Global Control 8 */ +-#define KS8995_REG_GC9 0x0b /* Global Control 9 */ +- +-#define KS8995_REG_PC(p, r) ((0x10 * p) + r) /* Port Control */ +-#define KS8995_REG_PS(p, r) ((0x10 * p) + r + 0xe) /* Port Status */ +- +-#define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */ +-#define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */ +-#define KS8995_REG_TPC2 0x62 /* TOS Priority Control 2 */ +-#define KS8995_REG_TPC3 0x63 /* TOS Priority Control 3 */ +-#define KS8995_REG_TPC4 0x64 /* TOS Priority Control 4 */ +-#define KS8995_REG_TPC5 0x65 /* TOS Priority Control 5 */ +-#define KS8995_REG_TPC6 0x66 /* TOS Priority Control 6 */ +-#define KS8995_REG_TPC7 0x67 /* TOS Priority Control 7 */ +- +-#define KS8995_REG_MAC0 0x68 /* MAC address 0 */ +-#define KS8995_REG_MAC1 0x69 /* MAC address 1 */ +-#define KS8995_REG_MAC2 0x6a /* MAC address 2 */ +-#define KS8995_REG_MAC3 0x6b /* MAC address 3 */ +-#define KS8995_REG_MAC4 0x6c /* MAC address 4 */ +-#define KS8995_REG_MAC5 0x6d /* MAC address 5 */ +- +-#define KS8995_REG_IAC0 0x6e /* Indirect Access Control 0 */ +-#define KS8995_REG_IAC1 0x6f /* Indirect Access Control 0 */ +-#define KS8995_REG_IAD7 0x70 /* Indirect Access Data 7 */ +-#define KS8995_REG_IAD6 0x71 /* Indirect Access Data 6 */ +-#define KS8995_REG_IAD5 0x72 /* Indirect Access Data 5 */ +-#define KS8995_REG_IAD4 0x73 /* Indirect Access Data 4 */ +-#define KS8995_REG_IAD3 0x74 /* Indirect Access Data 3 */ +-#define KS8995_REG_IAD2 0x75 /* Indirect Access Data 2 */ +-#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */ +-#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */ +- +-#define KSZ8864_REG_ID1 0xfe /* Chip ID in bit 7 */ +- +-#define KS8995_REGS_SIZE 0x80 +-#define KSZ8864_REGS_SIZE 0x100 +-#define KSZ8795_REGS_SIZE 0x100 +- +-#define ID1_CHIPID_M 0xf +-#define ID1_CHIPID_S 4 +-#define ID1_REVISION_M 0x7 +-#define ID1_REVISION_S 1 +-#define ID1_START_SW 1 /* start the switch */ +- +-#define FAMILY_KS8995 0x95 +-#define FAMILY_KSZ8795 0x87 +-#define CHIPID_M 0 +-#define KS8995_CHIP_ID 0x00 +-#define KSZ8864_CHIP_ID 0x01 +-#define KSZ8795_CHIP_ID 0x09 +- +-#define KS8995_CMD_WRITE 0x02U +-#define KS8995_CMD_READ 0x03U +- +-#define KS8995_RESET_DELAY 10 /* usec */ +- +-enum ks8995_chip_variant { +- ks8995, +- ksz8864, +- ksz8795, +- max_variant +-}; +- +-struct ks8995_chip_params { +- char *name; +- int family_id; +- int chip_id; +- int regs_size; +- int addr_width; +- int addr_shift; +-}; +- +-static const struct ks8995_chip_params ks8995_chip[] = { +- [ks8995] = { +- .name = "KS8995MA", +- .family_id = FAMILY_KS8995, +- .chip_id = KS8995_CHIP_ID, +- .regs_size = KS8995_REGS_SIZE, +- .addr_width = 8, +- .addr_shift = 0, +- }, +- [ksz8864] = { +- .name = "KSZ8864RMN", +- .family_id = FAMILY_KS8995, +- .chip_id = KSZ8864_CHIP_ID, +- .regs_size = KSZ8864_REGS_SIZE, +- .addr_width = 8, +- .addr_shift = 0, +- }, +- [ksz8795] = { +- .name = "KSZ8795CLX", +- .family_id = FAMILY_KSZ8795, +- .chip_id = KSZ8795_CHIP_ID, +- .regs_size = KSZ8795_REGS_SIZE, +- .addr_width = 12, +- .addr_shift = 1, +- }, +-}; +- +-struct ks8995_switch { +- struct spi_device *spi; +- struct mutex lock; +- struct gpio_desc *reset_gpio; +- struct bin_attribute regs_attr; +- const struct ks8995_chip_params *chip; +- int revision_id; +-}; +- +-static const struct spi_device_id ks8995_id[] = { +- {"ks8995", ks8995}, +- {"ksz8864", ksz8864}, +- {"ksz8795", ksz8795}, +- { } +-}; +-MODULE_DEVICE_TABLE(spi, ks8995_id); +- +-static const struct of_device_id ks8895_spi_of_match[] = { +- { .compatible = "micrel,ks8995" }, +- { .compatible = "micrel,ksz8864" }, +- { .compatible = "micrel,ksz8795" }, +- { }, +-}; +-MODULE_DEVICE_TABLE(of, ks8895_spi_of_match); +- +-static inline u8 get_chip_id(u8 val) +-{ +- return (val >> ID1_CHIPID_S) & ID1_CHIPID_M; +-} +- +-static inline u8 get_chip_rev(u8 val) +-{ +- return (val >> ID1_REVISION_S) & ID1_REVISION_M; +-} +- +-/* create_spi_cmd - create a chip specific SPI command header +- * @ks: pointer to switch instance +- * @cmd: SPI command for switch +- * @address: register address for command +- * +- * Different chip families use different bit pattern to address the switches +- * registers: +- * +- * KS8995: 8bit command + 8bit address +- * KSZ8795: 3bit command + 12bit address + 1bit TR (?) +- */ +-static inline __be16 create_spi_cmd(struct ks8995_switch *ks, int cmd, +- unsigned address) +-{ +- u16 result = cmd; +- +- /* make room for address (incl. address shift) */ +- result <<= ks->chip->addr_width + ks->chip->addr_shift; +- /* add address */ +- result |= address << ks->chip->addr_shift; +- /* SPI protocol needs big endian */ +- return cpu_to_be16(result); +-} +-/* ------------------------------------------------------------------------ */ +-static int ks8995_read(struct ks8995_switch *ks, char *buf, +- unsigned offset, size_t count) +-{ +- __be16 cmd; +- struct spi_transfer t[2]; +- struct spi_message m; +- int err; +- +- cmd = create_spi_cmd(ks, KS8995_CMD_READ, offset); +- spi_message_init(&m); +- +- memset(&t, 0, sizeof(t)); +- +- t[0].tx_buf = &cmd; +- t[0].len = sizeof(cmd); +- spi_message_add_tail(&t[0], &m); +- +- t[1].rx_buf = buf; +- t[1].len = count; +- spi_message_add_tail(&t[1], &m); +- +- mutex_lock(&ks->lock); +- err = spi_sync(ks->spi, &m); +- mutex_unlock(&ks->lock); +- +- return err ? err : count; +-} +- +-static int ks8995_write(struct ks8995_switch *ks, char *buf, +- unsigned offset, size_t count) +-{ +- __be16 cmd; +- struct spi_transfer t[2]; +- struct spi_message m; +- int err; +- +- cmd = create_spi_cmd(ks, KS8995_CMD_WRITE, offset); +- spi_message_init(&m); +- +- memset(&t, 0, sizeof(t)); +- +- t[0].tx_buf = &cmd; +- t[0].len = sizeof(cmd); +- spi_message_add_tail(&t[0], &m); +- +- t[1].tx_buf = buf; +- t[1].len = count; +- spi_message_add_tail(&t[1], &m); +- +- mutex_lock(&ks->lock); +- err = spi_sync(ks->spi, &m); +- mutex_unlock(&ks->lock); +- +- return err ? err : count; +-} +- +-static inline int ks8995_read_reg(struct ks8995_switch *ks, u8 addr, u8 *buf) +-{ +- return ks8995_read(ks, buf, addr, 1) != 1; +-} +- +-static inline int ks8995_write_reg(struct ks8995_switch *ks, u8 addr, u8 val) +-{ +- char buf = val; +- +- return ks8995_write(ks, &buf, addr, 1) != 1; +-} +- +-/* ------------------------------------------------------------------------ */ +- +-static int ks8995_stop(struct ks8995_switch *ks) +-{ +- return ks8995_write_reg(ks, KS8995_REG_ID1, 0); +-} +- +-static int ks8995_start(struct ks8995_switch *ks) +-{ +- return ks8995_write_reg(ks, KS8995_REG_ID1, 1); +-} +- +-static int ks8995_reset(struct ks8995_switch *ks) +-{ +- int err; +- +- err = ks8995_stop(ks); +- if (err) +- return err; +- +- udelay(KS8995_RESET_DELAY); +- +- return ks8995_start(ks); +-} +- +-static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj, +- struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) +-{ +- struct device *dev; +- struct ks8995_switch *ks8995; +- +- dev = kobj_to_dev(kobj); +- ks8995 = dev_get_drvdata(dev); +- +- return ks8995_read(ks8995, buf, off, count); +-} +- +-static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj, +- struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) +-{ +- struct device *dev; +- struct ks8995_switch *ks8995; +- +- dev = kobj_to_dev(kobj); +- ks8995 = dev_get_drvdata(dev); +- +- return ks8995_write(ks8995, buf, off, count); +-} +- +-/* ks8995_get_revision - get chip revision +- * @ks: pointer to switch instance +- * +- * Verify chip family and id and get chip revision. +- */ +-static int ks8995_get_revision(struct ks8995_switch *ks) +-{ +- int err; +- u8 id0, id1, ksz8864_id; +- +- /* read family id */ +- err = ks8995_read_reg(ks, KS8995_REG_ID0, &id0); +- if (err) { +- err = -EIO; +- goto err_out; +- } +- +- /* verify family id */ +- if (id0 != ks->chip->family_id) { +- dev_err(&ks->spi->dev, "chip family id mismatch: expected 0x%02x but 0x%02x read\n", +- ks->chip->family_id, id0); +- err = -ENODEV; +- goto err_out; +- } +- +- switch (ks->chip->family_id) { +- case FAMILY_KS8995: +- /* try reading chip id at CHIP ID1 */ +- err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1); +- if (err) { +- err = -EIO; +- goto err_out; +- } +- +- /* verify chip id */ +- if ((get_chip_id(id1) == CHIPID_M) && +- (get_chip_id(id1) == ks->chip->chip_id)) { +- /* KS8995MA */ +- ks->revision_id = get_chip_rev(id1); +- } else if (get_chip_id(id1) != CHIPID_M) { +- /* KSZ8864RMN */ +- err = ks8995_read_reg(ks, KS8995_REG_ID1, &ksz8864_id); +- if (err) { +- err = -EIO; +- goto err_out; +- } +- +- if ((ksz8864_id & 0x80) && +- (ks->chip->chip_id == KSZ8864_CHIP_ID)) { +- ks->revision_id = get_chip_rev(id1); +- } +- +- } else { +- dev_err(&ks->spi->dev, "unsupported chip id for KS8995 family: 0x%02x\n", +- id1); +- err = -ENODEV; +- } +- break; +- case FAMILY_KSZ8795: +- /* try reading chip id at CHIP ID1 */ +- err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1); +- if (err) { +- err = -EIO; +- goto err_out; +- } +- +- if (get_chip_id(id1) == ks->chip->chip_id) { +- ks->revision_id = get_chip_rev(id1); +- } else { +- dev_err(&ks->spi->dev, "unsupported chip id for KSZ8795 family: 0x%02x\n", +- id1); +- err = -ENODEV; +- } +- break; +- default: +- dev_err(&ks->spi->dev, "unsupported family id: 0x%02x\n", id0); +- err = -ENODEV; +- break; +- } +-err_out: +- return err; +-} +- +-static const struct bin_attribute ks8995_registers_attr = { +- .attr = { +- .name = "registers", +- .mode = 0600, +- }, +- .size = KS8995_REGS_SIZE, +- .read = ks8995_registers_read, +- .write = ks8995_registers_write, +-}; +- +-/* ------------------------------------------------------------------------ */ +-static int ks8995_probe(struct spi_device *spi) +-{ +- struct ks8995_switch *ks; +- int err; +- int variant = spi_get_device_id(spi)->driver_data; +- +- if (variant >= max_variant) { +- dev_err(&spi->dev, "bad chip variant %d\n", variant); +- return -ENODEV; +- } +- +- ks = devm_kzalloc(&spi->dev, sizeof(*ks), GFP_KERNEL); +- if (!ks) +- return -ENOMEM; +- +- mutex_init(&ks->lock); +- ks->spi = spi; +- ks->chip = &ks8995_chip[variant]; +- +- ks->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", +- GPIOD_OUT_HIGH); +- err = PTR_ERR_OR_ZERO(ks->reset_gpio); +- if (err) { +- dev_err(&spi->dev, +- "failed to get reset gpio: %d\n", err); +- return err; +- } +- +- err = gpiod_set_consumer_name(ks->reset_gpio, "switch-reset"); +- if (err) +- return err; +- +- /* de-assert switch reset */ +- /* FIXME: this likely requires a delay */ +- gpiod_set_value_cansleep(ks->reset_gpio, 0); +- +- spi_set_drvdata(spi, ks); +- +- spi->mode = SPI_MODE_0; +- spi->bits_per_word = 8; +- err = spi_setup(spi); +- if (err) { +- dev_err(&spi->dev, "spi_setup failed, err=%d\n", err); +- return err; +- } +- +- err = ks8995_get_revision(ks); +- if (err) +- return err; +- +- memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr)); +- ks->regs_attr.size = ks->chip->regs_size; +- +- err = ks8995_reset(ks); +- if (err) +- return err; +- +- sysfs_attr_init(&ks->regs_attr.attr); +- err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr); +- if (err) { +- dev_err(&spi->dev, "unable to create sysfs file, err=%d\n", +- err); +- return err; +- } +- +- dev_info(&spi->dev, "%s device found, Chip ID:%x, Revision:%x\n", +- ks->chip->name, ks->chip->chip_id, ks->revision_id); +- +- return 0; +-} +- +-static void ks8995_remove(struct spi_device *spi) +-{ +- struct ks8995_switch *ks = spi_get_drvdata(spi); +- +- sysfs_remove_bin_file(&spi->dev.kobj, &ks->regs_attr); +- +- /* assert reset */ +- gpiod_set_value_cansleep(ks->reset_gpio, 1); +-} +- +-/* ------------------------------------------------------------------------ */ +-static struct spi_driver ks8995_driver = { +- .driver = { +- .name = "spi-ks8995", +- .of_match_table = ks8895_spi_of_match, +- }, +- .probe = ks8995_probe, +- .remove = ks8995_remove, +- .id_table = ks8995_id, +-}; +- +-module_spi_driver(ks8995_driver); +- +-MODULE_DESCRIPTION(DRV_DESC); +-MODULE_VERSION(DRV_VERSION); +-MODULE_AUTHOR("Gabor Juhos "); +-MODULE_LICENSE("GPL v2"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-02-v6.18-net-dsa-ks8995-Add-proper-RESET-delay.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-02-v6.18-net-dsa-ks8995-Add-proper-RESET-delay.patch new file mode 100755 index 0000000..3b0b731 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-02-v6.18-net-dsa-ks8995-Add-proper-RESET-delay.patch @@ -0,0 +1,40 @@ +From 7367bfc8b34d7ad5b0c06e19fe24533db22ed8ea Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 13 Aug 2025 23:43:04 +0200 +Subject: [PATCH 2/4] net: dsa: ks8995: Add proper RESET delay + +According to the datasheet we need to wait 100us before accessing +any registers in the KS8995 after a reset de-assertion. + +Add this delay, if and only if we obtained a GPIO descriptor, +otherwise it is just a pointless delay. + +Signed-off-by: Linus Walleij +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250813-ks8995-to-dsa-v1-2-75c359ede3a5@linaro.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/ks8995.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +--- a/drivers/net/dsa/ks8995.c ++++ b/drivers/net/dsa/ks8995.c +@@ -438,9 +438,15 @@ static int ks8995_probe(struct spi_devic + if (err) + return err; + +- /* de-assert switch reset */ +- /* FIXME: this likely requires a delay */ +- gpiod_set_value_cansleep(ks->reset_gpio, 0); ++ if (ks->reset_gpio) { ++ /* ++ * If a reset line was obtained, wait for 100us after ++ * de-asserting RESET before accessing any registers, see ++ * the KS8995MA datasheet, page 44. ++ */ ++ gpiod_set_value_cansleep(ks->reset_gpio, 0); ++ udelay(100); ++ } + + spi_set_drvdata(spi, ks); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-03-v6.18-net-dsa-ks8995-Delete-sysfs-register-access.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-03-v6.18-net-dsa-ks8995-Delete-sysfs-register-access.patch new file mode 100755 index 0000000..78b9141 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-03-v6.18-net-dsa-ks8995-Delete-sysfs-register-access.patch @@ -0,0 +1,109 @@ +From 0e8d3f3623a45f69b6641ff9921ecd0c5afaa4ca Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 13 Aug 2025 23:43:05 +0200 +Subject: [PATCH 3/4] net: dsa: ks8995: Delete sysfs register access + +There is some sysfs file to read and write registers randomly +in the ks8995 driver. + +The contemporary way to achieve the same thing is to implement +regmap abstractions, if needed. Delete this and implement +regmap later if we want to be able to inspect individual registers. + +Signed-off-by: Linus Walleij +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250813-ks8995-to-dsa-v1-3-75c359ede3a5@linaro.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/ks8995.c | 48 ---------------------------------------- + 1 file changed, 48 deletions(-) + +--- a/drivers/net/dsa/ks8995.c ++++ b/drivers/net/dsa/ks8995.c +@@ -140,7 +140,6 @@ struct ks8995_switch { + struct spi_device *spi; + struct mutex lock; + struct gpio_desc *reset_gpio; +- struct bin_attribute regs_attr; + const struct ks8995_chip_params *chip; + int revision_id; + }; +@@ -288,30 +287,6 @@ static int ks8995_reset(struct ks8995_sw + return ks8995_start(ks); + } + +-static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj, +- struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) +-{ +- struct device *dev; +- struct ks8995_switch *ks8995; +- +- dev = kobj_to_dev(kobj); +- ks8995 = dev_get_drvdata(dev); +- +- return ks8995_read(ks8995, buf, off, count); +-} +- +-static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj, +- struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) +-{ +- struct device *dev; +- struct ks8995_switch *ks8995; +- +- dev = kobj_to_dev(kobj); +- ks8995 = dev_get_drvdata(dev); +- +- return ks8995_write(ks8995, buf, off, count); +-} +- + /* ks8995_get_revision - get chip revision + * @ks: pointer to switch instance + * +@@ -395,16 +370,6 @@ err_out: + return err; + } + +-static const struct bin_attribute ks8995_registers_attr = { +- .attr = { +- .name = "registers", +- .mode = 0600, +- }, +- .size = KS8995_REGS_SIZE, +- .read = ks8995_registers_read, +- .write = ks8995_registers_write, +-}; +- + /* ------------------------------------------------------------------------ */ + static int ks8995_probe(struct spi_device *spi) + { +@@ -462,21 +427,10 @@ static int ks8995_probe(struct spi_devic + if (err) + return err; + +- memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr)); +- ks->regs_attr.size = ks->chip->regs_size; +- + err = ks8995_reset(ks); + if (err) + return err; + +- sysfs_attr_init(&ks->regs_attr.attr); +- err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr); +- if (err) { +- dev_err(&spi->dev, "unable to create sysfs file, err=%d\n", +- err); +- return err; +- } +- + dev_info(&spi->dev, "%s device found, Chip ID:%x, Revision:%x\n", + ks->chip->name, ks->chip->chip_id, ks->revision_id); + +@@ -487,8 +441,6 @@ static void ks8995_remove(struct spi_dev + { + struct ks8995_switch *ks = spi_get_drvdata(spi); + +- sysfs_remove_bin_file(&spi->dev.kobj, &ks->regs_attr); +- + /* assert reset */ + gpiod_set_value_cansleep(ks->reset_gpio, 1); + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-04-v6.18-net-dsa-ks8995-Add-basic-switch-set-up.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-04-v6.18-net-dsa-ks8995-Add-basic-switch-set-up.patch new file mode 100755 index 0000000..670fe61 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/783-04-v6.18-net-dsa-ks8995-Add-basic-switch-set-up.patch @@ -0,0 +1,546 @@ +From 4b486b63e07313e1e3807f9d5e6636aa564e0fbc Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Wed, 13 Aug 2025 23:43:06 +0200 +Subject: [PATCH 4/4] net: dsa: ks8995: Add basic switch set-up + +We start to extend the KS8995 driver by simply registering it +as a DSA device and implementing a few switch callbacks for +STP set-up and such to begin with. + +No special tags or other advanced stuff: we use DSA_TAG_NONE +and rely on the default set-up in the switch with the special +DSA tags turned off. This makes the switch wire up properly +to all its PHY's and simple bridge traffic works properly. + +After this the bridge DT bindings are respected, ports and their +PHYs get connected to the switch and react appropriately through +the phylib when cables are plugged in etc. + +Tested like this in a hacky OpenWrt image: + +Bring up conduit interface manually: +ixp4xx_eth c8009000.ethernet eth0: eth0: link up, + speed 100 Mb/s, full duplex + +spi-ks8995 spi0.0: enable port 0 +spi-ks8995 spi0.0: set KS8995_REG_PC2 for port 0 to 06 +spi-ks8995 spi0.0 lan1: configuring for phy/mii link mode +spi-ks8995 spi0.0 lan1: Link is Up - 100Mbps/Full - flow control rx/tx + +PING 169.254.1.1 (169.254.1.1): 56 data bytes +64 bytes from 169.254.1.1: seq=0 ttl=64 time=1.629 ms +64 bytes from 169.254.1.1: seq=1 ttl=64 time=0.951 ms + +I also tested SSH from the device to the host and it works fine. + +It also works fine to ping the device from the host and to SSH +into the device from the host. + +This brings the ks8995 driver to a reasonable state where it can +be used from the current device tree bindings and the existing +device trees in the kernel. + +Signed-off-by: Linus Walleij +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250813-ks8995-to-dsa-v1-4-75c359ede3a5@linaro.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/dsa/Kconfig | 1 + + drivers/net/dsa/ks8995.c | 398 ++++++++++++++++++++++++++++++++++++++- + 2 files changed, 396 insertions(+), 3 deletions(-) + +--- a/drivers/net/dsa/Kconfig ++++ b/drivers/net/dsa/Kconfig +@@ -101,6 +101,7 @@ config NET_DSA_RZN1_A5PSW + config NET_DSA_KS8995 + tristate "Micrel KS8995 family 5-ports 10/100 Ethernet switches" + depends on SPI ++ select NET_DSA_TAG_NONE + help + This driver supports the Micrel KS8995 family of 10/100 Mbit ethernet + switches, managed over SPI. +--- a/drivers/net/dsa/ks8995.c ++++ b/drivers/net/dsa/ks8995.c +@@ -3,6 +3,7 @@ + * SPI driver for Micrel/Kendin KS8995M and KSZ8864RMN ethernet switches + * + * Copyright (C) 2008 Gabor Juhos ++ * Copyright (C) 2025 Linus Walleij + * + * This file was based on: drivers/spi/at25.c + * Copyright (C) 2006 David Brownell +@@ -10,6 +11,9 @@ + + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + ++#include ++#include ++#include + #include + #include + #include +@@ -17,8 +21,8 @@ + #include + #include + #include +- + #include ++#include + + #define DRV_VERSION "0.1.1" + #define DRV_DESC "Micrel KS8995 Ethernet switch SPI driver" +@@ -29,18 +33,59 @@ + #define KS8995_REG_ID1 0x01 /* Chip ID1 */ + + #define KS8995_REG_GC0 0x02 /* Global Control 0 */ ++ ++#define KS8995_GC0_P5_PHY BIT(3) /* Port 5 PHY enabled */ ++ + #define KS8995_REG_GC1 0x03 /* Global Control 1 */ + #define KS8995_REG_GC2 0x04 /* Global Control 2 */ ++ ++#define KS8995_GC2_HUGE BIT(2) /* Huge packet support */ ++#define KS8995_GC2_LEGAL BIT(1) /* Legal size override */ ++ + #define KS8995_REG_GC3 0x05 /* Global Control 3 */ + #define KS8995_REG_GC4 0x06 /* Global Control 4 */ ++ ++#define KS8995_GC4_10BT BIT(4) /* Force switch to 10Mbit */ ++#define KS8995_GC4_MII_FLOW BIT(5) /* MII full-duplex flow control enable */ ++#define KS8995_GC4_MII_HD BIT(6) /* MII half-duplex mode enable */ ++ + #define KS8995_REG_GC5 0x07 /* Global Control 5 */ + #define KS8995_REG_GC6 0x08 /* Global Control 6 */ + #define KS8995_REG_GC7 0x09 /* Global Control 7 */ + #define KS8995_REG_GC8 0x0a /* Global Control 8 */ + #define KS8995_REG_GC9 0x0b /* Global Control 9 */ + +-#define KS8995_REG_PC(p, r) ((0x10 * p) + r) /* Port Control */ +-#define KS8995_REG_PS(p, r) ((0x10 * p) + r + 0xe) /* Port Status */ ++#define KS8995_GC9_SPECIAL BIT(0) /* Special tagging mode (DSA) */ ++ ++/* In DSA the ports 1-4 are numbered 0-3 and the CPU port is port 4 */ ++#define KS8995_REG_PC(p, r) (0x10 + (0x10 * (p)) + (r)) /* Port Control */ ++#define KS8995_REG_PS(p, r) (0x1e + (0x10 * (p)) + (r)) /* Port Status */ ++ ++#define KS8995_REG_PC0 0x00 /* Port Control 0 */ ++#define KS8995_REG_PC1 0x01 /* Port Control 1 */ ++#define KS8995_REG_PC2 0x02 /* Port Control 2 */ ++#define KS8995_REG_PC3 0x03 /* Port Control 3 */ ++#define KS8995_REG_PC4 0x04 /* Port Control 4 */ ++#define KS8995_REG_PC5 0x05 /* Port Control 5 */ ++#define KS8995_REG_PC6 0x06 /* Port Control 6 */ ++#define KS8995_REG_PC7 0x07 /* Port Control 7 */ ++#define KS8995_REG_PC8 0x08 /* Port Control 8 */ ++#define KS8995_REG_PC9 0x09 /* Port Control 9 */ ++#define KS8995_REG_PC10 0x0a /* Port Control 10 */ ++#define KS8995_REG_PC11 0x0b /* Port Control 11 */ ++#define KS8995_REG_PC12 0x0c /* Port Control 12 */ ++#define KS8995_REG_PC13 0x0d /* Port Control 13 */ ++ ++#define KS8995_PC0_TAG_INS BIT(2) /* Enable tag insertion on port */ ++#define KS8995_PC0_TAG_REM BIT(1) /* Enable tag removal on port */ ++#define KS8995_PC0_PRIO_EN BIT(0) /* Enable priority handling */ ++ ++#define KS8995_PC2_TXEN BIT(2) /* Enable TX on port */ ++#define KS8995_PC2_RXEN BIT(1) /* Enable RX on port */ ++#define KS8995_PC2_LEARN_DIS BIT(0) /* Disable learning on port */ ++ ++#define KS8995_PC13_TXDIS BIT(6) /* Disable transmitter */ ++#define KS8995_PC13_PWDN BIT(3) /* Power down */ + + #define KS8995_REG_TPC0 0x60 /* TOS Priority Control 0 */ + #define KS8995_REG_TPC1 0x61 /* TOS Priority Control 1 */ +@@ -91,6 +136,8 @@ + #define KS8995_CMD_WRITE 0x02U + #define KS8995_CMD_READ 0x03U + ++#define KS8995_CPU_PORT 4 ++#define KS8995_NUM_PORTS 5 /* 5 ports including the CPU port */ + #define KS8995_RESET_DELAY 10 /* usec */ + + enum ks8995_chip_variant { +@@ -138,10 +185,13 @@ static const struct ks8995_chip_params k + + struct ks8995_switch { + struct spi_device *spi; ++ struct device *dev; ++ struct dsa_switch *ds; + struct mutex lock; + struct gpio_desc *reset_gpio; + const struct ks8995_chip_params *chip; + int revision_id; ++ unsigned int max_mtu[KS8995_NUM_PORTS]; + }; + + static const struct spi_device_id ks8995_id[] = { +@@ -370,6 +420,327 @@ err_out: + return err; + } + ++static int ks8995_check_config(struct ks8995_switch *ks) ++{ ++ int ret; ++ u8 val; ++ ++ ret = ks8995_read_reg(ks, KS8995_REG_GC0, &val); ++ if (ret) { ++ dev_err(ks->dev, "failed to read KS8995_REG_GC0\n"); ++ return ret; ++ } ++ ++ dev_dbg(ks->dev, "port 5 PHY %senabled\n", ++ (val & KS8995_GC0_P5_PHY) ? "" : "not "); ++ ++ val |= KS8995_GC0_P5_PHY; ++ ret = ks8995_write_reg(ks, KS8995_REG_GC0, val); ++ if (ret) ++ dev_err(ks->dev, "failed to set KS8995_REG_GC0\n"); ++ ++ dev_dbg(ks->dev, "set KS8995_REG_GC0 to 0x%02x\n", val); ++ ++ return 0; ++} ++ ++static void ++ks8995_mac_config(struct phylink_config *config, unsigned int mode, ++ const struct phylink_link_state *state) ++{ ++} ++ ++static void ++ks8995_mac_link_up(struct phylink_config *config, struct phy_device *phydev, ++ unsigned int mode, phy_interface_t interface, ++ int speed, int duplex, bool tx_pause, bool rx_pause) ++{ ++ struct dsa_port *dp = dsa_phylink_to_port(config); ++ struct ks8995_switch *ks = dp->ds->priv; ++ int port = dp->index; ++ int ret; ++ u8 val; ++ ++ /* Allow forcing the mode on the fixed CPU port, no autonegotiation. ++ * We assume autonegotiation works on the PHY-facing ports. ++ */ ++ if (port != KS8995_CPU_PORT) ++ return; ++ ++ dev_dbg(ks->dev, "MAC link up on CPU port (%d)\n", port); ++ ++ ret = ks8995_read_reg(ks, KS8995_REG_GC4, &val); ++ if (ret) { ++ dev_err(ks->dev, "failed to read KS8995_REG_GC4\n"); ++ return; ++ } ++ ++ /* Conjure port config */ ++ switch (speed) { ++ case SPEED_10: ++ dev_dbg(ks->dev, "set switch MII to 100Mbit mode\n"); ++ val |= KS8995_GC4_10BT; ++ break; ++ case SPEED_100: ++ default: ++ dev_dbg(ks->dev, "set switch MII to 100Mbit mode\n"); ++ val &= ~KS8995_GC4_10BT; ++ break; ++ } ++ ++ if (duplex == DUPLEX_HALF) { ++ dev_dbg(ks->dev, "set switch MII to half duplex\n"); ++ val |= KS8995_GC4_MII_HD; ++ } else { ++ dev_dbg(ks->dev, "set switch MII to full duplex\n"); ++ val &= ~KS8995_GC4_MII_HD; ++ } ++ ++ dev_dbg(ks->dev, "set KS8995_REG_GC4 to %02x\n", val); ++ ++ /* Enable the CPU port */ ++ ret = ks8995_write_reg(ks, KS8995_REG_GC4, val); ++ if (ret) ++ dev_err(ks->dev, "failed to set KS8995_REG_GC4\n"); ++} ++ ++static void ++ks8995_mac_link_down(struct phylink_config *config, unsigned int mode, ++ phy_interface_t interface) ++{ ++ struct dsa_port *dp = dsa_phylink_to_port(config); ++ struct ks8995_switch *ks = dp->ds->priv; ++ int port = dp->index; ++ ++ if (port != KS8995_CPU_PORT) ++ return; ++ ++ dev_dbg(ks->dev, "MAC link down on CPU port (%d)\n", port); ++ ++ /* Disable the CPU port */ ++} ++ ++static const struct phylink_mac_ops ks8995_phylink_mac_ops = { ++ .mac_config = ks8995_mac_config, ++ .mac_link_up = ks8995_mac_link_up, ++ .mac_link_down = ks8995_mac_link_down, ++}; ++ ++static enum ++dsa_tag_protocol ks8995_get_tag_protocol(struct dsa_switch *ds, ++ int port, ++ enum dsa_tag_protocol mp) ++{ ++ /* This switch actually uses the 6 byte KS8995 protocol */ ++ return DSA_TAG_PROTO_NONE; ++} ++ ++static int ks8995_setup(struct dsa_switch *ds) ++{ ++ return 0; ++} ++ ++static int ks8995_port_enable(struct dsa_switch *ds, int port, ++ struct phy_device *phy) ++{ ++ struct ks8995_switch *ks = ds->priv; ++ ++ dev_dbg(ks->dev, "enable port %d\n", port); ++ ++ return 0; ++} ++ ++static void ks8995_port_disable(struct dsa_switch *ds, int port) ++{ ++ struct ks8995_switch *ks = ds->priv; ++ ++ dev_dbg(ks->dev, "disable port %d\n", port); ++} ++ ++static int ks8995_port_pre_bridge_flags(struct dsa_switch *ds, int port, ++ struct switchdev_brport_flags flags, ++ struct netlink_ext_ack *extack) ++{ ++ /* We support enabling/disabling learning */ ++ if (flags.mask & ~(BR_LEARNING)) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int ks8995_port_bridge_flags(struct dsa_switch *ds, int port, ++ struct switchdev_brport_flags flags, ++ struct netlink_ext_ack *extack) ++{ ++ struct ks8995_switch *ks = ds->priv; ++ int ret; ++ u8 val; ++ ++ if (flags.mask & BR_LEARNING) { ++ ret = ks8995_read_reg(ks, KS8995_REG_PC(port, KS8995_REG_PC2), &val); ++ if (ret) { ++ dev_err(ks->dev, "failed to read KS8995_REG_PC2 on port %d\n", port); ++ return ret; ++ } ++ ++ if (flags.val & BR_LEARNING) ++ val &= ~KS8995_PC2_LEARN_DIS; ++ else ++ val |= KS8995_PC2_LEARN_DIS; ++ ++ ret = ks8995_write_reg(ks, KS8995_REG_PC(port, KS8995_REG_PC2), val); ++ if (ret) { ++ dev_err(ks->dev, "failed to write KS8995_REG_PC2 on port %d\n", port); ++ return ret; ++ } ++ } ++ ++ return 0; ++} ++ ++static void ks8995_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) ++{ ++ struct ks8995_switch *ks = ds->priv; ++ int ret; ++ u8 val; ++ ++ ret = ks8995_read_reg(ks, KS8995_REG_PC(port, KS8995_REG_PC2), &val); ++ if (ret) { ++ dev_err(ks->dev, "failed to read KS8995_REG_PC2 on port %d\n", port); ++ return; ++ } ++ ++ /* Set the bits for the different STP states in accordance with ++ * the datasheet, pages 36-37 "Spanning tree support". ++ */ ++ switch (state) { ++ case BR_STATE_DISABLED: ++ case BR_STATE_BLOCKING: ++ case BR_STATE_LISTENING: ++ val &= ~KS8995_PC2_TXEN; ++ val &= ~KS8995_PC2_RXEN; ++ val |= KS8995_PC2_LEARN_DIS; ++ break; ++ case BR_STATE_LEARNING: ++ val &= ~KS8995_PC2_TXEN; ++ val &= ~KS8995_PC2_RXEN; ++ val &= ~KS8995_PC2_LEARN_DIS; ++ break; ++ case BR_STATE_FORWARDING: ++ val |= KS8995_PC2_TXEN; ++ val |= KS8995_PC2_RXEN; ++ val &= ~KS8995_PC2_LEARN_DIS; ++ break; ++ default: ++ dev_err(ks->dev, "unknown bridge state requested\n"); ++ return; ++ } ++ ++ ret = ks8995_write_reg(ks, KS8995_REG_PC(port, KS8995_REG_PC2), val); ++ if (ret) { ++ dev_err(ks->dev, "failed to write KS8995_REG_PC2 on port %d\n", port); ++ return; ++ } ++ ++ dev_dbg(ks->dev, "set KS8995_REG_PC2 for port %d to %02x\n", port, val); ++} ++ ++static void ks8995_phylink_get_caps(struct dsa_switch *dsa, int port, ++ struct phylink_config *config) ++{ ++ unsigned long *interfaces = config->supported_interfaces; ++ ++ if (port == KS8995_CPU_PORT) ++ __set_bit(PHY_INTERFACE_MODE_MII, interfaces); ++ ++ if (port <= 3) { ++ /* Internal PHYs */ ++ __set_bit(PHY_INTERFACE_MODE_INTERNAL, interfaces); ++ /* phylib default */ ++ __set_bit(PHY_INTERFACE_MODE_MII, interfaces); ++ } ++ ++ config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100; ++} ++ ++/* Huge packet support up to 1916 byte packages "inclusive" ++ * which means that tags are included. If the bit is not set ++ * it is 1536 bytes "inclusive". We present the length without ++ * tags or ethernet headers. The setting affects all ports. ++ */ ++static int ks8995_change_mtu(struct dsa_switch *ds, int port, int new_mtu) ++{ ++ struct ks8995_switch *ks = ds->priv; ++ unsigned int max_mtu; ++ int ret; ++ u8 val; ++ int i; ++ ++ ks->max_mtu[port] = new_mtu; ++ ++ /* Roof out the MTU for the entire switch to the greatest ++ * common denominator: the biggest set for any one port will ++ * be the biggest MTU for the switch. ++ */ ++ max_mtu = ETH_DATA_LEN; ++ for (i = 0; i < KS8995_NUM_PORTS; i++) { ++ if (ks->max_mtu[i] > max_mtu) ++ max_mtu = ks->max_mtu[i]; ++ } ++ ++ /* Translate to layer 2 size. ++ * Add ethernet and (possible) VLAN headers, and checksum to the size. ++ * For ETH_DATA_LEN (1500 bytes) this will add up to 1522 bytes. ++ */ ++ max_mtu += VLAN_ETH_HLEN; ++ max_mtu += ETH_FCS_LEN; ++ ++ ret = ks8995_read_reg(ks, KS8995_REG_GC2, &val); ++ if (ret) { ++ dev_err(ks->dev, "failed to read KS8995_REG_GC2\n"); ++ return ret; ++ } ++ ++ if (max_mtu <= 1522) { ++ val &= ~KS8995_GC2_HUGE; ++ val &= ~KS8995_GC2_LEGAL; ++ } else if (max_mtu > 1522 && max_mtu <= 1536) { ++ /* This accepts packets up to 1536 bytes */ ++ val &= ~KS8995_GC2_HUGE; ++ val |= KS8995_GC2_LEGAL; ++ } else { ++ /* This accepts packets up to 1916 bytes */ ++ val |= KS8995_GC2_HUGE; ++ val |= KS8995_GC2_LEGAL; ++ } ++ ++ dev_dbg(ks->dev, "new max MTU %d bytes (inclusive)\n", max_mtu); ++ ++ ret = ks8995_write_reg(ks, KS8995_REG_GC2, val); ++ if (ret) ++ dev_err(ks->dev, "failed to set KS8995_REG_GC2\n"); ++ ++ return ret; ++} ++ ++static int ks8995_get_max_mtu(struct dsa_switch *ds, int port) ++{ ++ return 1916 - ETH_HLEN - ETH_FCS_LEN; ++} ++ ++static const struct dsa_switch_ops ks8995_ds_ops = { ++ .get_tag_protocol = ks8995_get_tag_protocol, ++ .setup = ks8995_setup, ++ .port_pre_bridge_flags = ks8995_port_pre_bridge_flags, ++ .port_bridge_flags = ks8995_port_bridge_flags, ++ .port_enable = ks8995_port_enable, ++ .port_disable = ks8995_port_disable, ++ .port_stp_state_set = ks8995_port_stp_state_set, ++ .port_change_mtu = ks8995_change_mtu, ++ .port_max_mtu = ks8995_get_max_mtu, ++ .phylink_get_caps = ks8995_phylink_get_caps, ++}; ++ + /* ------------------------------------------------------------------------ */ + static int ks8995_probe(struct spi_device *spi) + { +@@ -388,6 +759,7 @@ static int ks8995_probe(struct spi_devic + + mutex_init(&ks->lock); + ks->spi = spi; ++ ks->dev = &spi->dev; + ks->chip = &ks8995_chip[variant]; + + ks->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", +@@ -434,6 +806,25 @@ static int ks8995_probe(struct spi_devic + dev_info(&spi->dev, "%s device found, Chip ID:%x, Revision:%x\n", + ks->chip->name, ks->chip->chip_id, ks->revision_id); + ++ err = ks8995_check_config(ks); ++ if (err) ++ return err; ++ ++ ks->ds = devm_kzalloc(&spi->dev, sizeof(*ks->ds), GFP_KERNEL); ++ if (!ks->ds) ++ return -ENOMEM; ++ ++ ks->ds->dev = &spi->dev; ++ ks->ds->num_ports = KS8995_NUM_PORTS; ++ ks->ds->ops = &ks8995_ds_ops; ++ ks->ds->phylink_mac_ops = &ks8995_phylink_mac_ops; ++ ks->ds->priv = ks; ++ ++ err = dsa_register_switch(ks->ds); ++ if (err) ++ return dev_err_probe(&spi->dev, err, ++ "unable to register DSA switch\n"); ++ + return 0; + } + +@@ -441,6 +832,7 @@ static void ks8995_remove(struct spi_dev + { + struct ks8995_switch *ks = spi_get_drvdata(spi); + ++ dsa_unregister_switch(ks->ds); + /* assert reset */ + gpiod_set_value_cansleep(ks->reset_gpio, 1); + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-01-v6.17-net-phy-realtek-add-error-handling-to-rtl8211f_get_w.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-01-v6.17-net-phy-realtek-add-error-handling-to-rtl8211f_get_w.patch new file mode 100755 index 0000000..5f3b119 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-01-v6.17-net-phy-realtek-add-error-handling-to-rtl8211f_get_w.patch @@ -0,0 +1,39 @@ +From a9b24b3583ae1da7dbda031f141264f2da260219 Mon Sep 17 00:00:00 2001 +From: Daniel Braunwarth +Date: Tue, 24 Jun 2025 16:17:33 +0200 +Subject: [PATCH] net: phy: realtek: add error handling to rtl8211f_get_wol + +We should check if the WOL settings was successfully read from the PHY. + +In case this fails we cannot just use the error code and proceed. + +Signed-off-by: Daniel Braunwarth +Reported-by: Jon Hunter +Closes: https://lore.kernel.org/baaa083b-9a69-460f-ab35-2a7cb3246ffd@nvidia.com +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250624-realtek_fixes-v1-1-02a0b7c369bc@kuka.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -436,9 +436,15 @@ static irqreturn_t rtl8211f_handle_inter + + static void rtl8211f_get_wol(struct phy_device *dev, struct ethtool_wolinfo *wol) + { ++ int wol_events; ++ + wol->supported = WAKE_MAGIC; +- if (phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS) +- & RTL8211F_WOL_EVENT_MAGIC) ++ ++ wol_events = phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS); ++ if (wol_events < 0) ++ return; ++ ++ if (wol_events & RTL8211F_WOL_EVENT_MAGIC) + wol->wolopts = WAKE_MAGIC; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-02-v6.18-net-phy-realtek-Avoid-PHYCR2-access-if-PHYCR2-not-pr.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-02-v6.18-net-phy-realtek-Avoid-PHYCR2-access-if-PHYCR2-not-pr.patch new file mode 100755 index 0000000..681b234 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-02-v6.18-net-phy-realtek-Avoid-PHYCR2-access-if-PHYCR2-not-pr.patch @@ -0,0 +1,61 @@ +From 2c67301584f2671e320236df6bbe75ae09feb4d0 Mon Sep 17 00:00:00 2001 +From: Marek Vasut +Date: Sat, 11 Oct 2025 13:02:49 +0200 +Subject: [PATCH] net: phy: realtek: Avoid PHYCR2 access if PHYCR2 not present + +The driver is currently checking for PHYCR2 register presence in +rtl8211f_config_init(), but it does so after accessing PHYCR2 to +disable EEE. This was introduced in commit bfc17c165835 ("net: +phy: realtek: disable PHY-mode EEE"). Move the PHYCR2 presence +test before the EEE disablement and simplify the code. + +Fixes: bfc17c165835 ("net: phy: realtek: disable PHY-mode EEE") +Signed-off-by: Marek Vasut +Reviewed-by: Maxime Chevallier +Reviewed-by: Russell King (Oracle) +Link: https://patch.msgid.link/20251011110309.12664-1-marek.vasut@mailbox.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 23 +++++++++++------------ + 1 file changed, 11 insertions(+), 12 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -589,26 +589,25 @@ static int rtl8211f_config_init(struct p + str_enabled_disabled(val_rxdly)); + } + ++ if (!priv->has_phycr2) ++ return 0; ++ + /* Disable PHY-mode EEE so LPI is passed to the MAC */ + ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, + RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); + if (ret) + return ret; + +- if (priv->has_phycr2) { +- ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, +- RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, +- priv->phycr2); +- if (ret < 0) { +- dev_err(dev, "clkout configuration failed: %pe\n", +- ERR_PTR(ret)); +- return ret; +- } +- +- return genphy_soft_reset(phydev); ++ ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, ++ RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, ++ priv->phycr2); ++ if (ret < 0) { ++ dev_err(dev, "clkout configuration failed: %pe\n", ++ ERR_PTR(ret)); ++ return ret; + } + +- return 0; ++ return genphy_soft_reset(phydev); + } + + static int rtl821x_suspend(struct phy_device *phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-02-v6.18-net-phy-realtek-fix-RTL8211F-wake-on-lan-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-02-v6.18-net-phy-realtek-fix-RTL8211F-wake-on-lan-support.patch new file mode 100755 index 0000000..b5c4f8f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-02-v6.18-net-phy-realtek-fix-RTL8211F-wake-on-lan-support.patch @@ -0,0 +1,352 @@ +From b826bf795564ddef6402cf2cb522ae035bd117ae Mon Sep 17 00:00:00 2001 +From: "Russell King (Oracle)" +Date: Wed, 13 Aug 2025 11:04:45 +0100 +Subject: [PATCH] net: phy: realtek: fix RTL8211F wake-on-lan support + +Implement Wake-on-Lan for RTL8211F correctly. The existing +implementation has multiple issues: + +1. It assumes that Wake-on-Lan can always be used, whether or not the + interrupt is wired, and whether or not the interrupt is capable of + waking the system. This breaks the ability for MAC drivers to detect + whether the PHY WoL is functional. +2. switching the interrupt pin in the .set_wol() method to PMEB mode + immediately silences link-state interrupts, which breaks phylib + when interrupts are being used rather than polling mode. +3. the code claiming to "reset WOL status" was doing nothing of the + sort. Bit 15 in page 0xd8a register 17 controls WoL reset, and + needs to be pulsed low to reset the WoL state. This bit was always + written as '1', resulting in no reset. +4. not resetting WoL state results in the PMEB pin remaining asserted, + which in turn leads to an interrupt storm. Only resetting the WoL + state in .set_wol() is not sufficient. +5. PMEB mode does not allow software detection of the wake-up event as + there is no status bit to indicate we received the WoL packet. +6. across reboots of at least the Jetson Xavier NX system, the WoL + configuration is preserved. + +Fix all of these issues by essentially rewriting the support. We: +1. clear the WoL event enable register at probe time. +2. detect whether we can support wake-up by having a valid interrupt, + and the "wakeup-source" property in DT. If we can, then we mark + the MDIO device as wakeup capable, and associate the interrupt + with the wakeup source. +3. arrange for the get_wol() and set_wol() implementations to handle + the case where the MDIO device has not been marked as wakeup + capable (thereby returning no WoL support, and refusing to enable + WoL support.) +4. avoid switching to PMEB mode, instead using INTB mode with the + interrupt enable, reconfiguring the interrupt enables at suspend + time, and restoring their original state at resume time (we track + the state of the interrupt enable register in .config_intr() + register.) +5. move WoL reset from .set_wol() to the suspend function to ensure + that WoL state is cleared prior to suspend. This is necessary + after the PME interrupt has been enabled as a second WoL packet + will not re-raise a previously cleared PME interrupt. +6. when a PME interrupt (for wakeup) is asserted, pass this to the + PM wakeup so it knows which device woke the system. + +This fixes WoL support in the Realtek RTL8211F driver when used on the +nVidia Jetson Xavier NX platform, and needs to be applied before stmmac +patches which allow these platforms to forward the ethtool WoL commands +to the Realtek PHY. + +Signed-off-by: Russell King (Oracle) +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/E1um8Ld-008jxD-Mc@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 172 ++++++++++++++++++++----- + 1 file changed, 140 insertions(+), 32 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -10,6 +10,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -31,6 +32,7 @@ + #define RTL821x_INER 0x12 + #define RTL8211B_INER_INIT 0x6400 + #define RTL8211E_INER_LINK_STATUS BIT(10) ++#define RTL8211F_INER_PME BIT(7) + #define RTL8211F_INER_LINK_STATUS BIT(4) + + #define RTL821x_INSR 0x13 +@@ -96,17 +98,13 @@ + #define RTL8211F_RXCR 0x15 + #define RTL8211F_RX_DELAY BIT(3) + +-/* RTL8211F WOL interrupt configuration */ +-#define RTL8211F_INTBCR_PAGE 0xd40 +-#define RTL8211F_INTBCR 0x16 +-#define RTL8211F_INTBCR_INTB_PMEB BIT(5) +- + /* RTL8211F WOL settings */ +-#define RTL8211F_WOL_SETTINGS_PAGE 0xd8a ++#define RTL8211F_WOL_PAGE 0xd8a + #define RTL8211F_WOL_SETTINGS_EVENTS 16 + #define RTL8211F_WOL_EVENT_MAGIC BIT(12) +-#define RTL8211F_WOL_SETTINGS_STATUS 17 +-#define RTL8211F_WOL_STATUS_RESET (BIT(15) | 0x1fff) ++#define RTL8211F_WOL_RST_RMSQ 17 ++#define RTL8211F_WOL_RG_RSTB BIT(15) ++#define RTL8211F_WOL_RMSQ 0x1fff + + /* RTL8211F Unique phyiscal and multicast address (WOL) */ + #define RTL8211F_PHYSICAL_ADDR_PAGE 0xd8c +@@ -172,7 +170,8 @@ struct rtl821x_priv { + u16 phycr2; + bool has_phycr2; + struct clk *clk; +- u32 saved_wolopts; ++ /* rtl8211f */ ++ u16 iner; + }; + + static int rtl821x_read_page(struct phy_device *phydev) +@@ -255,6 +254,34 @@ static int rtl821x_probe(struct phy_devi + return 0; + } + ++static int rtl8211f_probe(struct phy_device *phydev) ++{ ++ struct device *dev = &phydev->mdio.dev; ++ int ret; ++ ++ ret = rtl821x_probe(phydev); ++ if (ret < 0) ++ return ret; ++ ++ /* Disable all PME events */ ++ ret = phy_write_paged(phydev, RTL8211F_WOL_PAGE, ++ RTL8211F_WOL_SETTINGS_EVENTS, 0); ++ if (ret < 0) ++ return ret; ++ ++ /* Mark this PHY as wakeup capable and register the interrupt as a ++ * wakeup IRQ if the PHY is marked as a wakeup source in firmware, ++ * and the interrupt is valid. ++ */ ++ if (device_property_read_bool(dev, "wakeup-source") && ++ phy_interrupt_is_valid(phydev)) { ++ device_set_wakeup_capable(dev, true); ++ devm_pm_set_wake_irq(dev, phydev->irq); ++ } ++ ++ return ret; ++} ++ + static int rtl8201_ack_interrupt(struct phy_device *phydev) + { + int err; +@@ -352,6 +379,7 @@ static int rtl8211e_config_intr(struct p + + static int rtl8211f_config_intr(struct phy_device *phydev) + { ++ struct rtl821x_priv *priv = phydev->priv; + u16 val; + int err; + +@@ -362,8 +390,10 @@ static int rtl8211f_config_intr(struct p + + val = RTL8211F_INER_LINK_STATUS; + err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); ++ if (err == 0) ++ priv->iner = val; + } else { +- val = 0; ++ priv->iner = val = 0; + err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); + if (err) + return err; +@@ -426,21 +456,34 @@ static irqreturn_t rtl8211f_handle_inter + return IRQ_NONE; + } + +- if (!(irq_status & RTL8211F_INER_LINK_STATUS)) +- return IRQ_NONE; ++ if (irq_status & RTL8211F_INER_LINK_STATUS) { ++ phy_trigger_machine(phydev); ++ return IRQ_HANDLED; ++ } + +- phy_trigger_machine(phydev); ++ if (irq_status & RTL8211F_INER_PME) { ++ pm_wakeup_event(&phydev->mdio.dev, 0); ++ return IRQ_HANDLED; ++ } + +- return IRQ_HANDLED; ++ return IRQ_NONE; + } + + static void rtl8211f_get_wol(struct phy_device *dev, struct ethtool_wolinfo *wol) + { + int wol_events; + ++ /* If the PHY is not capable of waking the system, then WoL can not ++ * be supported. ++ */ ++ if (!device_can_wakeup(&dev->mdio.dev)) { ++ wol->supported = 0; ++ return; ++ } ++ + wol->supported = WAKE_MAGIC; + +- wol_events = phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS); ++ wol_events = phy_read_paged(dev, RTL8211F_WOL_PAGE, RTL8211F_WOL_SETTINGS_EVENTS); + if (wol_events < 0) + return; + +@@ -453,6 +496,9 @@ static int rtl8211f_set_wol(struct phy_d + const u8 *mac_addr = dev->attached_dev->dev_addr; + int oldpage; + ++ if (!device_can_wakeup(&dev->mdio.dev)) ++ return -EOPNOTSUPP; ++ + oldpage = phy_save_page(dev); + if (oldpage < 0) + goto err; +@@ -464,25 +510,23 @@ static int rtl8211f_set_wol(struct phy_d + __phy_write(dev, RTL8211F_PHYSICAL_ADDR_WORD1, mac_addr[3] << 8 | (mac_addr[2])); + __phy_write(dev, RTL8211F_PHYSICAL_ADDR_WORD2, mac_addr[5] << 8 | (mac_addr[4])); + +- /* Enable magic packet matching and reset WOL status */ +- rtl821x_write_page(dev, RTL8211F_WOL_SETTINGS_PAGE); ++ /* Enable magic packet matching */ ++ rtl821x_write_page(dev, RTL8211F_WOL_PAGE); + __phy_write(dev, RTL8211F_WOL_SETTINGS_EVENTS, RTL8211F_WOL_EVENT_MAGIC); +- __phy_write(dev, RTL8211F_WOL_SETTINGS_STATUS, RTL8211F_WOL_STATUS_RESET); +- +- /* Enable the WOL interrupt */ +- rtl821x_write_page(dev, RTL8211F_INTBCR_PAGE); +- __phy_set_bits(dev, RTL8211F_INTBCR, RTL8211F_INTBCR_INTB_PMEB); ++ /* Set the maximum packet size, and assert WoL reset */ ++ __phy_write(dev, RTL8211F_WOL_RST_RMSQ, RTL8211F_WOL_RMSQ); + } else { +- /* Disable the WOL interrupt */ +- rtl821x_write_page(dev, RTL8211F_INTBCR_PAGE); +- __phy_clear_bits(dev, RTL8211F_INTBCR, RTL8211F_INTBCR_INTB_PMEB); +- +- /* Disable magic packet matching and reset WOL status */ +- rtl821x_write_page(dev, RTL8211F_WOL_SETTINGS_PAGE); ++ /* Disable magic packet matching */ ++ rtl821x_write_page(dev, RTL8211F_WOL_PAGE); + __phy_write(dev, RTL8211F_WOL_SETTINGS_EVENTS, 0); +- __phy_write(dev, RTL8211F_WOL_SETTINGS_STATUS, RTL8211F_WOL_STATUS_RESET); ++ ++ /* Place WoL in reset */ ++ __phy_clear_bits(dev, RTL8211F_WOL_RST_RMSQ, ++ RTL8211F_WOL_RG_RSTB); + } + ++ device_set_wakeup_enable(&dev->mdio.dev, !!(wol->wolopts & WAKE_MAGIC)); ++ + err: + return phy_restore_page(dev, oldpage, 0); + } +@@ -627,6 +671,52 @@ static int rtl821x_suspend(struct phy_de + return ret; + } + ++static int rtl8211f_suspend(struct phy_device *phydev) ++{ ++ u16 wol_rst; ++ int ret; ++ ++ ret = rtl821x_suspend(phydev); ++ if (ret < 0) ++ return ret; ++ ++ /* If a PME event is enabled, then configure the interrupt for ++ * PME events only, disabling link interrupt. We avoid switching ++ * to PMEB mode as we don't have a status bit for that. ++ */ ++ if (device_may_wakeup(&phydev->mdio.dev)) { ++ ret = phy_write_paged(phydev, 0xa42, RTL821x_INER, ++ RTL8211F_INER_PME); ++ if (ret < 0) ++ goto err; ++ ++ /* Read the INSR to clear any pending interrupt */ ++ phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); ++ ++ /* Reset the WoL to ensure that an event is picked up. ++ * Unless we do this, even if we receive another packet, ++ * we may not have a PME interrupt raised. ++ */ ++ ret = phy_read_paged(phydev, RTL8211F_WOL_PAGE, ++ RTL8211F_WOL_RST_RMSQ); ++ if (ret < 0) ++ goto err; ++ ++ wol_rst = ret & ~RTL8211F_WOL_RG_RSTB; ++ ret = phy_write_paged(phydev, RTL8211F_WOL_PAGE, ++ RTL8211F_WOL_RST_RMSQ, wol_rst); ++ if (ret < 0) ++ goto err; ++ ++ wol_rst |= RTL8211F_WOL_RG_RSTB; ++ ret = phy_write_paged(phydev, RTL8211F_WOL_PAGE, ++ RTL8211F_WOL_RST_RMSQ, wol_rst); ++ } ++ ++err: ++ return ret; ++} ++ + static int rtl821x_resume(struct phy_device *phydev) + { + struct rtl821x_priv *priv = phydev->priv; +@@ -644,6 +734,24 @@ static int rtl821x_resume(struct phy_dev + return 0; + } + ++static int rtl8211f_resume(struct phy_device *phydev) ++{ ++ struct rtl821x_priv *priv = phydev->priv; ++ int ret; ++ ++ ret = rtl821x_resume(phydev); ++ if (ret < 0) ++ return ret; ++ ++ /* If the device was programmed for a PME event, restore the interrupt ++ * enable so phylib can receive link state interrupts. ++ */ ++ if (device_may_wakeup(&phydev->mdio.dev)) ++ ret = phy_write_paged(phydev, 0xa42, RTL821x_INER, priv->iner); ++ ++ return ret; ++} ++ + static int rtl8211x_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) + { +@@ -1639,15 +1747,15 @@ static struct phy_driver realtek_drvs[] + }, { + PHY_ID_MATCH_EXACT(0x001cc916), + .name = "RTL8211F Gigabit Ethernet", +- .probe = rtl821x_probe, ++ .probe = rtl8211f_probe, + .config_init = &rtl8211f_config_init, + .read_status = rtlgen_read_status, + .config_intr = &rtl8211f_config_intr, + .handle_interrupt = rtl8211f_handle_interrupt, + .set_wol = rtl8211f_set_wol, + .get_wol = rtl8211f_get_wol, +- .suspend = rtl821x_suspend, +- .resume = rtl821x_resume, ++ .suspend = rtl8211f_suspend, ++ .resume = rtl8211f_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-03-v6.18-net-phy-realtek-fix-rtl8221b-vm-cg-name.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-03-v6.18-net-phy-realtek-fix-rtl8221b-vm-cg-name.patch new file mode 100755 index 0000000..ab319f0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-03-v6.18-net-phy-realtek-fix-rtl8221b-vm-cg-name.patch @@ -0,0 +1,70 @@ +From ffff5c8fc2af2218a3332b3d5b97654599d50cde Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Thu, 16 Oct 2025 21:22:52 +0200 +Subject: [PATCH] net: phy: realtek: fix rtl8221b-vm-cg name + +When splitting the RTL8221B-VM-CG into C22 and C45 variants, the name was +accidentally changed to RTL8221B-VN-CG. This patch brings back the previous +part number. + +Fixes: ad5ce743a6b0 ("net: phy: realtek: Add driver instances for rtl8221b via Clause 45") +Signed-off-by: Aleksander Jan Bajkowski +Reviewed-by: Simon Horman +Link: https://patch.msgid.link/20251016192325.2306757-1-olek2@wp.pl +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -154,7 +154,7 @@ + #define RTL_8211FVD_PHYID 0x001cc878 + #define RTL_8221B 0x001cc840 + #define RTL_8221B_VB_CG 0x001cc849 +-#define RTL_8221B_VN_CG 0x001cc84a ++#define RTL_8221B_VM_CG 0x001cc84a + #define RTL_8251B 0x001cc862 + #define RTL_8261C 0x001cc890 + +@@ -1498,16 +1498,16 @@ static int rtl8221b_vb_cg_c45_match_phy_ + return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); + } + +-static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device *phydev, ++static int rtl8221b_vm_cg_c22_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) + { +- return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, false); ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false); + } + +-static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device *phydev, ++static int rtl8221b_vm_cg_c45_match_phy_device(struct phy_device *phydev, + const struct phy_driver *phydrv) + { +- return rtlgen_is_c45_match(phydev, RTL_8221B_VN_CG, true); ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true); + } + + static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev, +@@ -1854,7 +1854,7 @@ static struct phy_driver realtek_drvs[] + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, + }, { +- .match_phy_device = rtl8221b_vn_cg_c22_match_phy_device, ++ .match_phy_device = rtl8221b_vm_cg_c22_match_phy_device, + .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", + .probe = rtl822x_probe, + .get_features = rtl822x_get_features, +@@ -1867,8 +1867,8 @@ static struct phy_driver realtek_drvs[] + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { +- .match_phy_device = rtl8221b_vn_cg_c45_match_phy_device, +- .name = "RTL8221B-VN-CG 2.5Gbps PHY (C45)", ++ .match_phy_device = rtl8221b_vm_cg_c45_match_phy_device, ++ .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)", + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-03-v6.18-net-phy-realtek-support-for-TRIGGER_NETDEV_LINK-on-R.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-03-v6.18-net-phy-realtek-support-for-TRIGGER_NETDEV_LINK-on-R.patch new file mode 100755 index 0000000..dc8d247 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-03-v6.18-net-phy-realtek-support-for-TRIGGER_NETDEV_LINK-on-R.patch @@ -0,0 +1,105 @@ +From f63f21e82ecafd288b100ea161247820bf1e92c4 Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Mon, 25 Aug 2025 23:09:49 +0200 +Subject: [PATCH] net: phy: realtek: support for TRIGGER_NETDEV_LINK on + RTL8211E and RTL8211F + +This patch adds support for the TRIGGER_NETDEV_LINK trigger. It activates +the LED when a link is established, regardless of the speed. + +Tested on Orange Pi PC2 with RTL8211E PHY. + +Signed-off-by: Aleksander Jan Bajkowski +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250825211059.143231-1-olek2@wp.pl +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 39 +++++++++++++++++++++----- + 1 file changed, 32 insertions(+), 7 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -755,7 +755,8 @@ static int rtl8211f_resume(struct phy_de + static int rtl8211x_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) + { +- const unsigned long mask = BIT(TRIGGER_NETDEV_LINK_10) | ++ const unsigned long mask = BIT(TRIGGER_NETDEV_LINK) | ++ BIT(TRIGGER_NETDEV_LINK_10) | + BIT(TRIGGER_NETDEV_LINK_100) | + BIT(TRIGGER_NETDEV_LINK_1000) | + BIT(TRIGGER_NETDEV_RX) | +@@ -813,6 +814,12 @@ static int rtl8211f_led_hw_control_get(s + if (val & RTL8211F_LEDCR_LINK_1000) + __set_bit(TRIGGER_NETDEV_LINK_1000, rules); + ++ if ((val & RTL8211F_LEDCR_LINK_10) && ++ (val & RTL8211F_LEDCR_LINK_100) && ++ (val & RTL8211F_LEDCR_LINK_1000)) { ++ __set_bit(TRIGGER_NETDEV_LINK, rules); ++ } ++ + if (val & RTL8211F_LEDCR_ACT_TXRX) { + __set_bit(TRIGGER_NETDEV_RX, rules); + __set_bit(TRIGGER_NETDEV_TX, rules); +@@ -830,14 +837,20 @@ static int rtl8211f_led_hw_control_set(s + if (index >= RTL8211x_LED_COUNT) + return -EINVAL; + +- if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) ++ if (test_bit(TRIGGER_NETDEV_LINK, &rules) || ++ test_bit(TRIGGER_NETDEV_LINK_10, &rules)) { + reg |= RTL8211F_LEDCR_LINK_10; ++ } + +- if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) ++ if (test_bit(TRIGGER_NETDEV_LINK, &rules) || ++ test_bit(TRIGGER_NETDEV_LINK_100, &rules)) { + reg |= RTL8211F_LEDCR_LINK_100; ++ } + +- if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) ++ if (test_bit(TRIGGER_NETDEV_LINK, &rules) || ++ test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) { + reg |= RTL8211F_LEDCR_LINK_1000; ++ } + + if (test_bit(TRIGGER_NETDEV_RX, &rules) || + test_bit(TRIGGER_NETDEV_TX, &rules)) { +@@ -885,6 +898,12 @@ static int rtl8211e_led_hw_control_get(s + if (cr2 & RTL8211E_LEDCR2_LINK_1000) + __set_bit(TRIGGER_NETDEV_LINK_1000, rules); + ++ if ((cr2 & RTL8211E_LEDCR2_LINK_10) && ++ (cr2 & RTL8211E_LEDCR2_LINK_100) && ++ (cr2 & RTL8211E_LEDCR2_LINK_1000)) { ++ __set_bit(TRIGGER_NETDEV_LINK, rules); ++ } ++ + return ret; + } + +@@ -912,14 +931,20 @@ static int rtl8211e_led_hw_control_set(s + if (ret < 0) + return ret; + +- if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) ++ if (test_bit(TRIGGER_NETDEV_LINK, &rules) || ++ test_bit(TRIGGER_NETDEV_LINK_10, &rules)) { + cr2 |= RTL8211E_LEDCR2_LINK_10; ++ } + +- if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) ++ if (test_bit(TRIGGER_NETDEV_LINK, &rules) || ++ test_bit(TRIGGER_NETDEV_LINK_100, &rules)) { + cr2 |= RTL8211E_LEDCR2_LINK_100; ++ } + +- if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) ++ if (test_bit(TRIGGER_NETDEV_LINK, &rules) || ++ test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) { + cr2 |= RTL8211E_LEDCR2_LINK_1000; ++ } + + cr2 <<= RTL8211E_LEDCR2_SHIFT * index; + ret = rtl821x_modify_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-06-v6.19-net-phy-realtek-Add-RTL8224-cable-testing-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-06-v6.19-net-phy-realtek-Add-RTL8224-cable-testing-support.patch new file mode 100755 index 0000000..d95211d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-06-v6.19-net-phy-realtek-Add-RTL8224-cable-testing-support.patch @@ -0,0 +1,272 @@ +From 61958b33ef0bab1c1874c933cd3910f495526782 Mon Sep 17 00:00:00 2001 +From: Issam Hamdi +Date: Fri, 24 Oct 2025 11:49:00 +0200 +Subject: [PATCH] net: phy: realtek: Add RTL8224 cable testing support + +The RTL8224 can detect open pairs and short types (in same pair or some +other pair). The distance to this problem can be estimated. This is done +for each of the 4 pairs separately. + +It is not meant to be run while there is an active link partner because +this interferes with the active test pulses. + +Output with open 50 m cable: + + Pair A code Open Circuit, source: TDR + Pair A, fault length: 51.79m, source: TDR + Pair B code Open Circuit, source: TDR + Pair B, fault length: 51.28m, source: TDR + Pair C code Open Circuit, source: TDR + Pair C, fault length: 50.46m, source: TDR + Pair D code Open Circuit, source: TDR + Pair D, fault length: 51.12m, source: TDR + +Terminated cable: + + Pair A code OK, source: TDR + Pair B code OK, source: TDR + Pair C code OK, source: TDR + Pair D code OK, source: TDR + +Shorted cable (both short types are at roughly the same distance) + + Pair A code Short to another pair, source: TDR + Pair A, fault length: 2.35m, source: TDR + Pair B code Short to another pair, source: TDR + Pair B, fault length: 2.15m, source: TDR + Pair C code OK, source: TDR + Pair D code Short within Pair, source: TDR + Pair D, fault length: 1.94m, source: TDR + +Signed-off-by: Issam Hamdi +Co-developed-by: Sven Eckelmann +Signed-off-by: Sven Eckelmann +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20251024-rtl8224-cable-test-v1-1-e3cda89ac98f@simonwunderlich.de +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 187 +++++++++++++++++++++++++ + 1 file changed, 187 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -8,6 +8,7 @@ + * Copyright (c) 2004 Freescale Semiconductor, Inc. + */ + #include ++#include + #include + #include + #include +@@ -127,6 +128,27 @@ + */ + #define RTL822X_VND2_C22_REG(reg) (0xa400 + 2 * (reg)) + ++#define RTL8224_MII_RTCT 0x11 ++#define RTL8224_MII_RTCT_ENABLE BIT(0) ++#define RTL8224_MII_RTCT_PAIR_A BIT(4) ++#define RTL8224_MII_RTCT_PAIR_B BIT(5) ++#define RTL8224_MII_RTCT_PAIR_C BIT(6) ++#define RTL8224_MII_RTCT_PAIR_D BIT(7) ++#define RTL8224_MII_RTCT_DONE BIT(15) ++ ++#define RTL8224_MII_SRAM_ADDR 0x1b ++#define RTL8224_MII_SRAM_DATA 0x1c ++ ++#define RTL8224_SRAM_RTCT_FAULT(pair) (0x8026 + (pair) * 4) ++#define RTL8224_SRAM_RTCT_FAULT_BUSY BIT(0) ++#define RTL8224_SRAM_RTCT_FAULT_OPEN BIT(3) ++#define RTL8224_SRAM_RTCT_FAULT_SAME_SHORT BIT(4) ++#define RTL8224_SRAM_RTCT_FAULT_OK BIT(5) ++#define RTL8224_SRAM_RTCT_FAULT_DONE BIT(6) ++#define RTL8224_SRAM_RTCT_FAULT_CROSS_SHORT BIT(7) ++ ++#define RTL8224_SRAM_RTCT_LEN(pair) (0x8028 + (pair) * 4) ++ + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + +@@ -1453,6 +1475,168 @@ static int rtl822xb_c45_read_status(stru + return 0; + } + ++static int rtl8224_cable_test_start(struct phy_device *phydev) ++{ ++ u32 val; ++ int ret; ++ ++ /* disable auto-negotiation and force 1000/Full */ ++ ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(MII_BMCR), ++ BMCR_ANENABLE | BMCR_SPEED100 | BMCR_SPEED10, ++ BMCR_SPEED1000 | BMCR_FULLDPLX); ++ if (ret) ++ return ret; ++ ++ mdelay(500); ++ ++ /* trigger cable test */ ++ val = RTL8224_MII_RTCT_ENABLE; ++ val |= RTL8224_MII_RTCT_PAIR_A; ++ val |= RTL8224_MII_RTCT_PAIR_B; ++ val |= RTL8224_MII_RTCT_PAIR_C; ++ val |= RTL8224_MII_RTCT_PAIR_D; ++ ++ return phy_modify_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(RTL8224_MII_RTCT), ++ RTL8224_MII_RTCT_DONE, val); ++} ++ ++static int rtl8224_sram_read(struct phy_device *phydev, u32 reg) ++{ ++ int ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(RTL8224_MII_SRAM_ADDR), ++ reg); ++ if (ret) ++ return ret; ++ ++ return phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(RTL8224_MII_SRAM_DATA)); ++} ++ ++static int rtl8224_pair_len_get(struct phy_device *phydev, u32 pair) ++{ ++ int cable_len; ++ u32 reg_len; ++ int ret; ++ u32 cm; ++ ++ reg_len = RTL8224_SRAM_RTCT_LEN(pair); ++ ++ ret = rtl8224_sram_read(phydev, reg_len); ++ if (ret < 0) ++ return ret; ++ ++ cable_len = ret & 0xff00; ++ ++ ret = rtl8224_sram_read(phydev, reg_len + 1); ++ if (ret < 0) ++ return ret; ++ ++ cable_len |= (ret & 0xff00) >> 8; ++ ++ cable_len -= 620; ++ cable_len = max(cable_len, 0); ++ ++ cm = cable_len * 100 / 78; ++ ++ return cm; ++} ++ ++static int rtl8224_cable_test_result_trans(u32 result) ++{ ++ if (!(result & RTL8224_SRAM_RTCT_FAULT_DONE)) ++ return -EBUSY; ++ ++ if (result & RTL8224_SRAM_RTCT_FAULT_OK) ++ return ETHTOOL_A_CABLE_RESULT_CODE_OK; ++ ++ if (result & RTL8224_SRAM_RTCT_FAULT_OPEN) ++ return ETHTOOL_A_CABLE_RESULT_CODE_OPEN; ++ ++ if (result & RTL8224_SRAM_RTCT_FAULT_SAME_SHORT) ++ return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT; ++ ++ if (result & RTL8224_SRAM_RTCT_FAULT_BUSY) ++ return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; ++ ++ if (result & RTL8224_SRAM_RTCT_FAULT_CROSS_SHORT) ++ return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT; ++ ++ return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; ++} ++ ++static int rtl8224_cable_test_report_pair(struct phy_device *phydev, unsigned int pair) ++{ ++ int fault_rslt; ++ int ret; ++ ++ ret = rtl8224_sram_read(phydev, RTL8224_SRAM_RTCT_FAULT(pair)); ++ if (ret < 0) ++ return ret; ++ ++ fault_rslt = rtl8224_cable_test_result_trans(ret); ++ if (fault_rslt < 0) ++ return 0; ++ ++ ret = ethnl_cable_test_result(phydev, pair, fault_rslt); ++ if (ret < 0) ++ return ret; ++ ++ switch (fault_rslt) { ++ case ETHTOOL_A_CABLE_RESULT_CODE_OPEN: ++ case ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT: ++ case ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT: ++ ret = rtl8224_pair_len_get(phydev, pair); ++ if (ret < 0) ++ return ret; ++ ++ return ethnl_cable_test_fault_length(phydev, pair, ret); ++ default: ++ return 0; ++ } ++} ++ ++static int rtl8224_cable_test_report(struct phy_device *phydev, bool *finished) ++{ ++ unsigned int pair; ++ int ret; ++ ++ for (pair = ETHTOOL_A_CABLE_PAIR_A; pair <= ETHTOOL_A_CABLE_PAIR_D; pair++) { ++ ret = rtl8224_cable_test_report_pair(phydev, pair); ++ if (ret == -EBUSY) { ++ *finished = false; ++ return 0; ++ } ++ ++ if (ret < 0) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int rtl8224_cable_test_get_status(struct phy_device *phydev, bool *finished) ++{ ++ int ret; ++ ++ *finished = false; ++ ++ ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(RTL8224_MII_RTCT)); ++ if (ret < 0) ++ return ret; ++ ++ if (!(ret & RTL8224_MII_RTCT_DONE)) ++ return 0; ++ ++ *finished = true; ++ ++ return rtl8224_cable_test_report(phydev, finished); ++} ++ + static bool rtlgen_supports_2_5gbps(struct phy_device *phydev) + { + int val; +@@ -1930,11 +2114,14 @@ static struct phy_driver realtek_drvs[] + }, { + PHY_ID_MATCH_EXACT(0x001ccad0), + .name = "RTL8224 2.5Gbps PHY", ++ .flags = PHY_POLL_CABLE_TEST, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .read_status = rtl822x_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, ++ .cable_test_start = rtl8224_cable_test_start, ++ .cable_test_get_status = rtl8224_cable_test_get_status, + }, { + PHY_ID_MATCH_EXACT(0x001cc961), + .name = "RTL8366RB Gigabit Ethernet", diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-07-v6.19-net-phy-realtek-add-interrupt-support-for-RTL8221B.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-07-v6.19-net-phy-realtek-add-interrupt-support-for-RTL8221B.patch new file mode 100755 index 0000000..2efa4e9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-07-v6.19-net-phy-realtek-add-interrupt-support-for-RTL8221B.patch @@ -0,0 +1,105 @@ +From 18aa36238a4d835c1644dcccd63d32c7fdd4b310 Mon Sep 17 00:00:00 2001 +From: Jianhui Zhao +Date: Sun, 2 Nov 2025 16:26:37 +0100 +Subject: [PATCH] net: phy: realtek: add interrupt support for RTL8221B + +This commit introduces interrupt support for RTL8221B (C45 mode). +Interrupts are mapped on the VEND2 page. VEND2 registers are only +accessible via C45 reads and cannot be accessed by C45 over C22. + +Signed-off-by: Jianhui Zhao +[Enable only link state change interrupts] +Signed-off-by: Aleksander Jan Bajkowski +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20251102152644.1676482-1-olek2@wp.pl +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 56 ++++++++++++++++++++++++++ + 1 file changed, 56 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -128,6 +128,11 @@ + */ + #define RTL822X_VND2_C22_REG(reg) (0xa400 + 2 * (reg)) + ++#define RTL8221B_VND2_INER 0xa4d2 ++#define RTL8221B_VND2_INER_LINK_STATUS BIT(4) ++ ++#define RTL8221B_VND2_INSR 0xa4d4 ++ + #define RTL8224_MII_RTCT 0x11 + #define RTL8224_MII_RTCT_ENABLE BIT(0) + #define RTL8224_MII_RTCT_PAIR_A BIT(4) +@@ -1880,6 +1885,53 @@ static irqreturn_t rtl9000a_handle_inter + return IRQ_HANDLED; + } + ++static int rtl8221b_ack_interrupt(struct phy_device *phydev) ++{ ++ int err; ++ ++ err = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL8221B_VND2_INSR); ++ ++ return (err < 0) ? err : 0; ++} ++ ++static int rtl8221b_config_intr(struct phy_device *phydev) ++{ ++ int err; ++ ++ if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { ++ err = rtl8221b_ack_interrupt(phydev); ++ if (err) ++ return err; ++ ++ err = phy_write_mmd(phydev, MDIO_MMD_VEND2, RTL8221B_VND2_INER, ++ RTL8221B_VND2_INER_LINK_STATUS); ++ } else { ++ err = phy_write_mmd(phydev, MDIO_MMD_VEND2, ++ RTL8221B_VND2_INER, 0); ++ if (err) ++ return err; ++ ++ err = rtl8221b_ack_interrupt(phydev); ++ } ++ ++ return err; ++} ++ ++static irqreturn_t rtl8221b_handle_interrupt(struct phy_device *phydev) ++{ ++ int err; ++ ++ err = rtl8221b_ack_interrupt(phydev); ++ if (err) { ++ phy_error(phydev); ++ return IRQ_NONE; ++ } ++ ++ phy_trigger_machine(phydev); ++ ++ return IRQ_HANDLED; ++} ++ + static struct phy_driver realtek_drvs[] = { + { + PHY_ID_MATCH_EXACT(0x00008201), +@@ -2054,6 +2106,8 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", ++ .config_intr = rtl8221b_config_intr, ++ .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, +@@ -2078,6 +2132,8 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vm_cg_c45_match_phy_device, + .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)", ++ .config_intr = rtl8221b_config_intr, ++ .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-08-v6.19-net-phy-realtek-create-rtl8211f_config_rgmii_delay.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-08-v6.19-net-phy-realtek-create-rtl8211f_config_rgmii_delay.patch new file mode 100755 index 0000000..0c523ee --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-08-v6.19-net-phy-realtek-create-rtl8211f_config_rgmii_delay.patch @@ -0,0 +1,128 @@ +From 8e982441ba601d982dd0739972115d85ae01d99b Mon Sep 17 00:00:00 2001 +From: Vladimir Oltean +Date: Tue, 18 Nov 2025 01:40:28 +0200 +Subject: [PATCH] net: phy: realtek: create rtl8211f_config_rgmii_delay() + +The control flow in rtl8211f_config_init() has some pitfalls which were +probably unintended. Specifically it has an early return: + + switch (phydev->interface) { + ... + default: /* the rest of the modes imply leaving delay as is. */ + return 0; + } + +which exits the entire config_init() function. This means it also skips +doing things such as disabling CLKOUT or disabling PHY-mode EEE. + +For the RTL8211FS, which uses PHY_INTERFACE_MODE_SGMII, this might be a +problem. However, I don't know that it is, so there is no Fixes: tag. +The issue was observed through code inspection. + +Signed-off-by: Vladimir Oltean +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20251117234033.345679-2-vladimir.oltean@nxp.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 65 +++++++++++++++----------- + 1 file changed, 39 insertions(+), 26 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -587,22 +587,11 @@ static int rtl8211c_config_init(struct p + CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER); + } + +-static int rtl8211f_config_init(struct phy_device *phydev) ++static int rtl8211f_config_rgmii_delay(struct phy_device *phydev) + { +- struct rtl821x_priv *priv = phydev->priv; +- struct device *dev = &phydev->mdio.dev; + u16 val_txdly, val_rxdly; + int ret; + +- ret = phy_modify_paged_changed(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, +- RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF, +- priv->phycr1); +- if (ret < 0) { +- dev_err(dev, "aldps mode configuration failed: %pe\n", +- ERR_PTR(ret)); +- return ret; +- } +- + switch (phydev->interface) { + case PHY_INTERFACE_MODE_RGMII: + val_txdly = 0; +@@ -632,34 +621,58 @@ static int rtl8211f_config_init(struct p + RTL8211F_TXCR, RTL8211F_TX_DELAY, + val_txdly); + if (ret < 0) { +- dev_err(dev, "Failed to update the TX delay register\n"); ++ phydev_err(phydev, "Failed to update the TX delay register: %pe\n", ++ ERR_PTR(ret)); + return ret; + } else if (ret) { +- dev_dbg(dev, +- "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n", +- str_enable_disable(val_txdly)); ++ phydev_dbg(phydev, ++ "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n", ++ str_enable_disable(val_txdly)); + } else { +- dev_dbg(dev, +- "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n", +- str_enabled_disabled(val_txdly)); ++ phydev_dbg(phydev, ++ "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n", ++ str_enabled_disabled(val_txdly)); + } + + ret = phy_modify_paged_changed(phydev, RTL8211F_RGMII_PAGE, + RTL8211F_RXCR, RTL8211F_RX_DELAY, + val_rxdly); + if (ret < 0) { +- dev_err(dev, "Failed to update the RX delay register\n"); ++ phydev_err(phydev, "Failed to update the RX delay register: %pe\n", ++ ERR_PTR(ret)); + return ret; + } else if (ret) { +- dev_dbg(dev, +- "%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n", +- str_enable_disable(val_rxdly)); ++ phydev_dbg(phydev, ++ "%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n", ++ str_enable_disable(val_rxdly)); + } else { +- dev_dbg(dev, +- "2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n", +- str_enabled_disabled(val_rxdly)); ++ phydev_dbg(phydev, ++ "2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n", ++ str_enabled_disabled(val_rxdly)); + } + ++ return 0; ++} ++ ++static int rtl8211f_config_init(struct phy_device *phydev) ++{ ++ struct rtl821x_priv *priv = phydev->priv; ++ struct device *dev = &phydev->mdio.dev; ++ int ret; ++ ++ ret = phy_modify_paged_changed(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, ++ RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF, ++ priv->phycr1); ++ if (ret < 0) { ++ dev_err(dev, "aldps mode configuration failed: %pe\n", ++ ERR_PTR(ret)); ++ return ret; ++ } ++ ++ ret = rtl8211f_config_rgmii_delay(phydev); ++ if (ret) ++ return ret; ++ + if (!priv->has_phycr2) + return 0; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-09-v6.19-net-phy-realtek-eliminate-priv-phycr2-variable.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-09-v6.19-net-phy-realtek-eliminate-priv-phycr2-variable.patch new file mode 100755 index 0000000..1c67961 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-09-v6.19-net-phy-realtek-eliminate-priv-phycr2-variable.patch @@ -0,0 +1,101 @@ +From 27033d06917758d47162581da7e9de8004049dee Mon Sep 17 00:00:00 2001 +From: Vladimir Oltean +Date: Tue, 18 Nov 2025 01:40:29 +0200 +Subject: [PATCH] net: phy: realtek: eliminate priv->phycr2 variable + +The RTL8211F(D)(I)-VD-CG PHY also has support for disabling the CLKOUT, +and we'd like to introduce the "realtek,clkout-disable" property for +that. + +But it isn't done through the PHYCR2 register, and it becomes awkward to +have the driver pretend that it is. So just replace the machine-level +"u16 phycr2" variable with a logical "bool disable_clk_out", which +scales better to the other PHY as well. + +The change is a complete functional equivalent. Before, if the device +tree property was absent, priv->phycr2 would contain the RTL8211F_CLKOUT_EN +bit as read from hardware. Now, we don't save priv->phycr2, but we just +don't call phy_modify_paged() on it. Also, we can simply call +phy_modify_paged() with the "set" argument to 0. + +Signed-off-by: Vladimir Oltean +Link: https://patch.msgid.link/20251117234033.345679-3-vladimir.oltean@nxp.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 38 ++++++++++++++++---------- + 1 file changed, 23 insertions(+), 15 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -194,8 +194,8 @@ MODULE_LICENSE("GPL"); + + struct rtl821x_priv { + u16 phycr1; +- u16 phycr2; + bool has_phycr2; ++ bool disable_clk_out; + struct clk *clk; + /* rtl8211f */ + u16 iner; +@@ -266,15 +266,8 @@ static int rtl821x_probe(struct phy_devi + priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF; + + priv->has_phycr2 = !(phy_id == RTL_8211FVD_PHYID); +- if (priv->has_phycr2) { +- ret = phy_read_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2); +- if (ret < 0) +- return ret; +- +- priv->phycr2 = ret & RTL8211F_CLKOUT_EN; +- if (of_property_read_bool(dev->of_node, "realtek,clkout-disable")) +- priv->phycr2 &= ~RTL8211F_CLKOUT_EN; +- } ++ priv->disable_clk_out = of_property_read_bool(dev->of_node, ++ "realtek,clkout-disable"); + + phydev->priv = priv; + +@@ -654,6 +647,23 @@ static int rtl8211f_config_rgmii_delay(s + return 0; + } + ++static int rtl8211f_config_clk_out(struct phy_device *phydev) ++{ ++ struct rtl821x_priv *priv = phydev->priv; ++ int ret; ++ ++ /* The value is preserved if the device tree property is absent */ ++ if (!priv->disable_clk_out) ++ return 0; ++ ++ ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, ++ RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, 0); ++ if (ret) ++ return ret; ++ ++ return genphy_soft_reset(phydev); ++} ++ + static int rtl8211f_config_init(struct phy_device *phydev) + { + struct rtl821x_priv *priv = phydev->priv; +@@ -682,16 +692,14 @@ static int rtl8211f_config_init(struct p + if (ret) + return ret; + +- ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, +- RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, +- priv->phycr2); +- if (ret < 0) { ++ ret = rtl8211f_config_clk_out(phydev); ++ if (ret) { + dev_err(dev, "clkout configuration failed: %pe\n", + ERR_PTR(ret)); + return ret; + } + +- return genphy_soft_reset(phydev); ++ return 0; + } + + static int rtl821x_suspend(struct phy_device *phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-10-v6.19-net-phy-realtek-eliminate-has_phycr2-variable.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-10-v6.19-net-phy-realtek-eliminate-has_phycr2-variable.patch new file mode 100755 index 0000000..a78cb3d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-10-v6.19-net-phy-realtek-eliminate-has_phycr2-variable.patch @@ -0,0 +1,55 @@ +From 910ac7bfb1af1ae4cd141ef80e03a6729213c189 Mon Sep 17 00:00:00 2001 +From: Vladimir Oltean +Date: Tue, 18 Nov 2025 01:40:30 +0200 +Subject: [PATCH] net: phy: realtek: eliminate has_phycr2 variable + +This variable is assigned in rtl821x_probe() and used in +rtl8211f_config_init(), which is more complex than it needs to be. +Simply testing the same condition from rtl821x_probe() in +rtl8211f_config_init() yields the same result (the PHY driver ID is a +runtime invariant), but with one temporary variable less. + +Signed-off-by: Vladimir Oltean +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20251117234033.345679-4-vladimir.oltean@nxp.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -194,7 +194,6 @@ MODULE_LICENSE("GPL"); + + struct rtl821x_priv { + u16 phycr1; +- bool has_phycr2; + bool disable_clk_out; + struct clk *clk; + /* rtl8211f */ +@@ -245,7 +244,6 @@ static int rtl821x_probe(struct phy_devi + { + struct device *dev = &phydev->mdio.dev; + struct rtl821x_priv *priv; +- u32 phy_id = phydev->drv->phy_id; + int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); +@@ -265,7 +263,6 @@ static int rtl821x_probe(struct phy_devi + if (of_property_read_bool(dev->of_node, "realtek,aldps-enable")) + priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF; + +- priv->has_phycr2 = !(phy_id == RTL_8211FVD_PHYID); + priv->disable_clk_out = of_property_read_bool(dev->of_node, + "realtek,clkout-disable"); + +@@ -683,7 +680,8 @@ static int rtl8211f_config_init(struct p + if (ret) + return ret; + +- if (!priv->has_phycr2) ++ /* RTL8211FVD has no PHYCR2 register */ ++ if (phydev->drv->phy_id == RTL_8211FVD_PHYID) + return 0; + + /* Disable PHY-mode EEE so LPI is passed to the MAC */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-11-v6.19-net-phy-realtek-allow-CLKOUT-to-be-disabled-on-RTL82.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-11-v6.19-net-phy-realtek-allow-CLKOUT-to-be-disabled-on-RTL82.patch new file mode 100755 index 0000000..2a3239d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-11-v6.19-net-phy-realtek-allow-CLKOUT-to-be-disabled-on-RTL82.patch @@ -0,0 +1,101 @@ +From e1a31c41bef678afe0d99b7f0dc3711a80c68447 Mon Sep 17 00:00:00 2001 +From: Vladimir Oltean +Date: Tue, 18 Nov 2025 01:40:31 +0200 +Subject: [PATCH] net: phy: realtek: allow CLKOUT to be disabled on + RTL8211F(D)(I)-VD-CG + +Add CLKOUT disable support for RTL8211F(D)(I)-VD-CG. Like with other PHY +variants, this feature might be requested by customers when the clock +output is not used, in order to reduce electromagnetic interference (EMI). + +In the common driver, the CLKOUT configuration is done through PHYCR2. +The RTL_8211FVD_PHYID is singled out as not having that register, and +execution in rtl8211f_config_init() returns early after commit +2c67301584f2 ("net: phy: realtek: Avoid PHYCR2 access if PHYCR2 not +present"). + +But actually CLKOUT is configured through a different register for this +PHY. Instead of pretending this is PHYCR2 (which it is not), just add +some code for modifying this register inside the rtl8211f_disable_clk_out() +function, and move that outside the code portion that runs only if +PHYCR2 exists. + +In practice this reorders the PHYCR2 writes to disable PHY-mode EEE and +to disable the CLKOUT for the normal RTL8211F variants, but this should +be perfectly fine. + +It was not noted that RTL8211F(D)(I)-VD-CG would need a genphy_soft_reset() +call after disabling the CLKOUT. Despite that, we do it out of caution +and for symmetry with the other RTL8211F models. + +Co-developed-by: Clark Wang +Signed-off-by: Clark Wang +Signed-off-by: Vladimir Oltean +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20251117234033.345679-5-vladimir.oltean@nxp.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 31 ++++++++++++++++++-------- + 1 file changed, 22 insertions(+), 9 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -90,6 +90,14 @@ + #define RTL8211F_LEDCR_MASK GENMASK(4, 0) + #define RTL8211F_LEDCR_SHIFT 5 + ++/* RTL8211F(D)(I)-VD-CG CLKOUT configuration is specified via magic values ++ * to undocumented register pages. The names here do not reflect the datasheet. ++ * Unlike other PHY models, CLKOUT configuration does not go through PHYCR2. ++ */ ++#define RTL8211FVD_CLKOUT_PAGE 0xd05 ++#define RTL8211FVD_CLKOUT_REG 0x11 ++#define RTL8211FVD_CLKOUT_EN BIT(8) ++ + /* RTL8211F RGMII configuration */ + #define RTL8211F_RGMII_PAGE 0xd08 + +@@ -653,8 +661,13 @@ static int rtl8211f_config_clk_out(struc + if (!priv->disable_clk_out) + return 0; + +- ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, +- RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, 0); ++ if (phydev->drv->phy_id == RTL_8211FVD_PHYID) ++ ret = phy_modify_paged(phydev, RTL8211FVD_CLKOUT_PAGE, ++ RTL8211FVD_CLKOUT_REG, ++ RTL8211FVD_CLKOUT_EN, 0); ++ else ++ ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, ++ RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, 0); + if (ret) + return ret; + +@@ -680,6 +693,13 @@ static int rtl8211f_config_init(struct p + if (ret) + return ret; + ++ ret = rtl8211f_config_clk_out(phydev); ++ if (ret) { ++ dev_err(dev, "clkout configuration failed: %pe\n", ++ ERR_PTR(ret)); ++ return ret; ++ } ++ + /* RTL8211FVD has no PHYCR2 register */ + if (phydev->drv->phy_id == RTL_8211FVD_PHYID) + return 0; +@@ -690,13 +710,6 @@ static int rtl8211f_config_init(struct p + if (ret) + return ret; + +- ret = rtl8211f_config_clk_out(phydev); +- if (ret) { +- dev_err(dev, "clkout configuration failed: %pe\n", +- ERR_PTR(ret)); +- return ret; +- } +- + return 0; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-12-v6.19-net-phy-realtek-eliminate-priv-phycr1-variable.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-12-v6.19-net-phy-realtek-eliminate-priv-phycr1-variable.patch new file mode 100755 index 0000000..a2e5abe --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-12-v6.19-net-phy-realtek-eliminate-priv-phycr1-variable.patch @@ -0,0 +1,107 @@ +From bb78b71faf60d11a15f07e3390fcfd31e5e523bb Mon Sep 17 00:00:00 2001 +From: Vladimir Oltean +Date: Tue, 18 Nov 2025 01:40:32 +0200 +Subject: [PATCH] net: phy: realtek: eliminate priv->phycr1 variable + +Previous changes have replaced the machine-level priv->phycr2 with a +high-level priv->disable_clk_out. This created a discrepancy with +priv->phycr1 which is resolved here, for uniformity. + +One advantage of this new implementation is that we don't read +priv->phycr1 in rtl821x_probe() if we're never going to modify it. + +We never test the positive return code from phy_modify_mmd_changed(), so +we could just as well use phy_modify_mmd(). + +I took the ALDPS feature description from commit d90db36a9e74 ("net: +phy: realtek: add dt property to enable ALDPS mode") and transformed it +into a function comment - the feature is sufficiently non-obvious to +deserve that. + +Signed-off-by: Vladimir Oltean +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20251117234033.345679-6-vladimir.oltean@nxp.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 44 ++++++++++++++++---------- + 1 file changed, 28 insertions(+), 16 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -201,7 +201,7 @@ MODULE_AUTHOR("Johnson Leung"); + MODULE_LICENSE("GPL"); + + struct rtl821x_priv { +- u16 phycr1; ++ bool enable_aldps; + bool disable_clk_out; + struct clk *clk; + /* rtl8211f */ +@@ -252,7 +252,6 @@ static int rtl821x_probe(struct phy_devi + { + struct device *dev = &phydev->mdio.dev; + struct rtl821x_priv *priv; +- int ret; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) +@@ -263,14 +262,8 @@ static int rtl821x_probe(struct phy_devi + return dev_err_probe(dev, PTR_ERR(priv->clk), + "failed to get phy clock\n"); + +- ret = phy_read_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1); +- if (ret < 0) +- return ret; +- +- priv->phycr1 = ret & (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF); +- if (of_property_read_bool(dev->of_node, "realtek,aldps-enable")) +- priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF; +- ++ priv->enable_aldps = of_property_read_bool(dev->of_node, ++ "realtek,aldps-enable"); + priv->disable_clk_out = of_property_read_bool(dev->of_node, + "realtek,clkout-disable"); + +@@ -674,17 +667,36 @@ static int rtl8211f_config_clk_out(struc + return genphy_soft_reset(phydev); + } + +-static int rtl8211f_config_init(struct phy_device *phydev) ++/* Advance Link Down Power Saving (ALDPS) mode changes crystal/clock behaviour, ++ * which causes the RXC clock signal to stop for tens to hundreds of ++ * milliseconds. ++ * ++ * Some MACs need the RXC clock to support their internal RX logic, so ALDPS is ++ * only enabled based on an opt-in device tree property. ++ */ ++static int rtl8211f_config_aldps(struct phy_device *phydev) + { + struct rtl821x_priv *priv = phydev->priv; ++ u16 mask = RTL8211F_ALDPS_PLL_OFF | ++ RTL8211F_ALDPS_ENABLE | ++ RTL8211F_ALDPS_XTAL_OFF; ++ ++ /* The value is preserved if the device tree property is absent */ ++ if (!priv->enable_aldps) ++ return 0; ++ ++ return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, ++ mask, mask); ++} ++ ++static int rtl8211f_config_init(struct phy_device *phydev) ++{ + struct device *dev = &phydev->mdio.dev; + int ret; + +- ret = phy_modify_paged_changed(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, +- RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF, +- priv->phycr1); +- if (ret < 0) { +- dev_err(dev, "aldps mode configuration failed: %pe\n", ++ ret = rtl8211f_config_aldps(phydev); ++ if (ret) { ++ dev_err(dev, "aldps mode configuration failed: %pe\n", + ERR_PTR(ret)); + return ret; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-13-v6.19-net-phy-realtek-create-rtl8211f_config_phy_eee-helpe.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-13-v6.19-net-phy-realtek-create-rtl8211f_config_phy_eee-helpe.patch new file mode 100755 index 0000000..54ec217 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/784-13-v6.19-net-phy-realtek-create-rtl8211f_config_phy_eee-helpe.patch @@ -0,0 +1,58 @@ +From 4465ae435ddc0162d5033a543658449d53d46d08 Mon Sep 17 00:00:00 2001 +From: Vladimir Oltean +Date: Tue, 18 Nov 2025 01:40:33 +0200 +Subject: [PATCH] net: phy: realtek: create rtl8211f_config_phy_eee() helper + +To simplify the rtl8211f_config_init() control flow and get rid of +"early" returns for PHYs where the PHYCR2 register is absent, move the +entire logic sub-block that deals with disabling PHY-mode EEE to a +separate function. There, it is much more obvious what the early +"return 0" skips, and it becomes more difficult to accidentally skip +unintended stuff. + +Signed-off-by: Vladimir Oltean +Link: https://patch.msgid.link/20251117234033.345679-7-vladimir.oltean@nxp.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 23 ++++++++++++----------- + 1 file changed, 12 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -689,6 +689,17 @@ static int rtl8211f_config_aldps(struct + mask, mask); + } + ++static int rtl8211f_config_phy_eee(struct phy_device *phydev) ++{ ++ /* RTL8211FVD has no PHYCR2 register */ ++ if (phydev->drv->phy_id == RTL_8211FVD_PHYID) ++ return 0; ++ ++ /* Disable PHY-mode EEE so LPI is passed to the MAC */ ++ return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, ++ RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); ++} ++ + static int rtl8211f_config_init(struct phy_device *phydev) + { + struct device *dev = &phydev->mdio.dev; +@@ -712,17 +723,7 @@ static int rtl8211f_config_init(struct p + return ret; + } + +- /* RTL8211FVD has no PHYCR2 register */ +- if (phydev->drv->phy_id == RTL_8211FVD_PHYID) +- return 0; +- +- /* Disable PHY-mode EEE so LPI is passed to the MAC */ +- ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, +- RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); +- if (ret) +- return ret; +- +- return 0; ++ return rtl8211f_config_phy_eee(phydev); + } + + static int rtl821x_suspend(struct phy_device *phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/785-v6.18-r8169-fix-RTL8127-hang-on-suspend-shutdown.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/785-v6.18-r8169-fix-RTL8127-hang-on-suspend-shutdown.patch new file mode 100755 index 0000000..269fc89 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/785-v6.18-r8169-fix-RTL8127-hang-on-suspend-shutdown.patch @@ -0,0 +1,50 @@ +From ae1737e7339b513f8c2fc21b500a0fc215d155c3 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 22 Nov 2025 15:23:02 +0100 +Subject: r8169: fix RTL8127 hang on suspend/shutdown + +There have been reports that RTL8127 hangs on suspend and shutdown, +partially disappearing from lspci until power-cycling. +According to Realtek disabling PLL's when switching to D3 should be +avoided on that chip version. Fix this by aligning disabling PLL's +with the vendor drivers, what in addition results in PLL's not being +disabled when switching to D3hot on other chip versions. + +Fixes: f24f7b2f3af9 ("r8169: add support for RTL8127A") +Tested-by: Fabio Baltieri +Cc: stable@vger.kernel.org +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/d7faae7e-66bc-404a-a432-3a496600575f@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/realtek/r8169_main.c | 19 ++++++++++++++----- + 1 file changed, 14 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -1516,11 +1516,20 @@ static enum rtl_dash_type rtl_get_dash_t + + static void rtl_set_d3_pll_down(struct rtl8169_private *tp, bool enable) + { +- if (tp->mac_version >= RTL_GIGA_MAC_VER_25 && +- tp->mac_version != RTL_GIGA_MAC_VER_28 && +- tp->mac_version != RTL_GIGA_MAC_VER_31 && +- tp->mac_version != RTL_GIGA_MAC_VER_38) +- r8169_mod_reg8_cond(tp, PMCH, D3_NO_PLL_DOWN, !enable); ++ switch (tp->mac_version) { ++ case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_24: ++ case RTL_GIGA_MAC_VER_28: ++ case RTL_GIGA_MAC_VER_31: ++ case RTL_GIGA_MAC_VER_38: ++ break; ++ case RTL_GIGA_MAC_VER_80: ++ r8169_mod_reg8_cond(tp, PMCH, D3_NO_PLL_DOWN, true); ++ break; ++ default: ++ r8169_mod_reg8_cond(tp, PMCH, D3HOT_NO_PLL_DOWN, true); ++ r8169_mod_reg8_cond(tp, PMCH, D3COLD_NO_PLL_DOWN, !enable); ++ break; ++ } + } + + static void rtl_reset_packet_filter(struct rtl8169_private *tp) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/786-01-v6.18-net-phy-introduce-phy_id_compare_vendor-PHY-ID-helpe.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/786-01-v6.18-net-phy-introduce-phy_id_compare_vendor-PHY-ID-helpe.patch new file mode 100755 index 0000000..82e9e06 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/786-01-v6.18-net-phy-introduce-phy_id_compare_vendor-PHY-ID-helpe.patch @@ -0,0 +1,58 @@ +From 1abe21ef1adf0c5b6dbb5878c2fa4573df8d29fc Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sat, 23 Aug 2025 15:44:28 +0200 +Subject: net: phy: introduce phy_id_compare_vendor() PHY ID helper + +Introduce phy_id_compare_vendor() PHY ID helper to compare a PHY ID with +the PHY ID Vendor using the generic PHY ID Vendor mask. + +While at it also rework the PHY_ID_MATCH macro and move the mask to +dedicated define so that PHY driver can make use of the mask if needed. + +Signed-off-by: Christian Marangi +Reviewed-by: Andrew Lunn +Link: https://patch.msgid.link/20250823134431.4854-1-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + include/linux/phy.h | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1266,9 +1266,13 @@ struct phy_driver { + #define PHY_ANY_ID "MATCH ANY PHY" + #define PHY_ANY_UID 0xffffffff + +-#define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 0) +-#define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 4) +-#define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = GENMASK(31, 10) ++#define PHY_ID_MATCH_EXTACT_MASK GENMASK(31, 0) ++#define PHY_ID_MATCH_MODEL_MASK GENMASK(31, 4) ++#define PHY_ID_MATCH_VENDOR_MASK GENMASK(31, 10) ++ ++#define PHY_ID_MATCH_EXACT(id) .phy_id = (id), .phy_id_mask = PHY_ID_MATCH_EXTACT_MASK ++#define PHY_ID_MATCH_MODEL(id) .phy_id = (id), .phy_id_mask = PHY_ID_MATCH_MODEL_MASK ++#define PHY_ID_MATCH_VENDOR(id) .phy_id = (id), .phy_id_mask = PHY_ID_MATCH_VENDOR_MASK + + /** + * phy_id_compare - compare @id1 with @id2 taking account of @mask +@@ -1285,6 +1289,19 @@ static inline bool phy_id_compare(u32 id + } + + /** ++ * phy_id_compare_vendor - compare @id with @vendor mask ++ * @id: PHY ID ++ * @vendor_mask: PHY Vendor mask ++ * ++ * Return: true if the bits from @id match @vendor using the ++ * generic PHY Vendor mask. ++ */ ++static inline bool phy_id_compare_vendor(u32 id, u32 vendor_mask) ++{ ++ return phy_id_compare(id, vendor_mask, PHY_ID_MATCH_VENDOR_MASK); ++} ++ ++/** + * phydev_id_compare - compare @id with the PHY's Clause 22 ID + * @phydev: the PHY device + * @id: the PHY ID to be matched diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/786-02-v6.18-net-phy-as21xxx-better-handle-PHY-HW-reset-on-soft-r.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/786-02-v6.18-net-phy-as21xxx-better-handle-PHY-HW-reset-on-soft-r.patch new file mode 100755 index 0000000..5b00da4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/786-02-v6.18-net-phy-as21xxx-better-handle-PHY-HW-reset-on-soft-r.patch @@ -0,0 +1,45 @@ +From b4d5cd20507b252c746fa6971d82ac96f3b3e5b7 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sat, 23 Aug 2025 15:44:29 +0200 +Subject: net: phy: as21xxx: better handle PHY HW reset on soft-reboot + +On soft-reboot, with a reset GPIO defined for an Aeonsemi PHY, the +special match_phy_device fails to correctly identify that the PHY +needs to load the firmware again. + +This is caused by the fact that PHY ID is read BEFORE the PHY reset +GPIO (if present) is asserted, so we can be in the scenario where the +phydev have the previous PHY ID (with the PHY firmware loaded) but +after reset the generic AS21xxx PHY is present in the PHY ID registers. + +To better handle this, skip reading the PHY ID register only for the PHY +that are not AS21xxx (by matching for the Aeonsemi Vendor) and always +read the PHY ID for the other case to handle both firmware already +loaded or an HW reset. + +Fixes: 830877d89edc ("net: phy: Add support for Aeonsemi AS21xxx PHYs") +Signed-off-by: Christian Marangi +Link: https://patch.msgid.link/20250823134431.4854-2-ansuelsmth@gmail.com +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/as21xxx.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/as21xxx.c ++++ b/drivers/net/phy/as21xxx.c +@@ -884,11 +884,12 @@ static int as21xxx_match_phy_device(stru + u32 phy_id; + int ret; + +- /* Skip PHY that are not AS21xxx or already have firmware loaded */ +- if (phydev->c45_ids.device_ids[MDIO_MMD_PCS] != PHY_ID_AS21XXX) ++ /* Skip PHY that are not AS21xxx */ ++ if (!phy_id_compare_vendor(phydev->c45_ids.device_ids[MDIO_MMD_PCS], ++ PHY_VENDOR_AEONSEMI)) + return genphy_match_phy_device(phydev, phydrv); + +- /* Read PHY ID to handle firmware just loaded */ ++ /* Read PHY ID to handle firmware loaded or HW reset */ + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MII_PHYSID1); + if (ret < 0) + return ret; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/787-v6.19-net-phy-RTL8211FVD-Restore-disabling-of-PHY-mode-EEE.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/787-v6.19-net-phy-RTL8211FVD-Restore-disabling-of-PHY-mode-EEE.patch new file mode 100755 index 0000000..37290c4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/787-v6.19-net-phy-RTL8211FVD-Restore-disabling-of-PHY-mode-EEE.patch @@ -0,0 +1,61 @@ +From 4f0638b12451112de4138689fa679315c8d388dc Mon Sep 17 00:00:00 2001 +From: Ivan Galkin +Date: Tue, 2 Dec 2025 10:07:42 +0100 +Subject: net: phy: RTL8211FVD: Restore disabling of PHY-mode EEE + +When support for RTL8211F(D)(I)-VD-CG was introduced in commit +bb726b753f75 ("net: phy: realtek: add support for RTL8211F(D)(I)-VD-CG") +the implementation assumed that this PHY model doesn't have the +control register PHYCR2 (Page 0xa43 Address 0x19). This +assumption was based on the differences in CLKOUT configurations +between RTL8211FVD and the remaining RTL8211F PHYs. In the latter +commit 2c67301584f2 +("net: phy: realtek: Avoid PHYCR2 access if PHYCR2 not present") +this assumption was expanded to the PHY-mode EEE. + +I performed tests on RTL8211FI-VD-CG and confirmed that disabling +PHY-mode EEE works correctly and is uniform with other PHYs +supported by the driver. To validate the correctness, +I contacted Realtek support. Realtek confirmed that PHY-mode EEE on +RTL8211F(D)(I)-VD-CG is configured via Page 0xa43 Address 0x19 bit 5. + +Moreover, Realtek informed me that the most recent datasheet +for RTL8211F(D)(I)-VD-CG v1.1 is incomplete and the naming of +control registers is partly inconsistent. The errata I +received from Realtek corrects the naming as follows: + +| Register | Datasheet v1.1 | Errata | +|-------------------------|----------------|--------| +| Page 0xa44 Address 0x11 | PHYCR2 | PHYCR3 | +| Page 0xa43 Address 0x19 | N/A | PHYCR2 | + +This information confirms that the supposedly missing control register, +PHYCR2, exists in the RTL8211F(D)(I)-VD-CG under the same address and +the same name. It controls widely the same configs as other PHYs from +the RTL8211F series (e.g. PHY-mode EEE). Clock out configuration is an +exception. + +Given all this information, restore disabling of the PHY-mode EEE. + +Fixes: 2c67301584f2 ("net: phy: realtek: Avoid PHYCR2 access if PHYCR2 not present") +Signed-off-by: Ivan Galkin +Reviewed-by: Vladimir Oltean +Link: https://patch.msgid.link/20251202-phy_eee-v1-1-fe0bf6ab3df0@axis.com +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 4 ---- + 1 file changed, 4 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -691,10 +691,6 @@ static int rtl8211f_config_aldps(struct + + static int rtl8211f_config_phy_eee(struct phy_device *phydev) + { +- /* RTL8211FVD has no PHYCR2 register */ +- if (phydev->drv->phy_id == RTL_8211FVD_PHYID) +- return 0; +- + /* Disable PHY-mode EEE so LPI is passed to the MAC */ + return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, + RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/788-v7.0-net-phy-realtek-fix-whitespace-in-struct-phy_driver-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/788-v7.0-net-phy-realtek-fix-whitespace-in-struct-phy_driver-.patch new file mode 100755 index 0000000..e577166 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/788-v7.0-net-phy-realtek-fix-whitespace-in-struct-phy_driver-.patch @@ -0,0 +1,229 @@ +From 50326b48f0cfbd9324668c5d2e08b39b59dc199f Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 5 Jan 2026 16:37:54 +0000 +Subject: [PATCH 1/5] net: phy: realtek: fix whitespace in struct phy_driver + initializers + +Consistently use tabs instead of spaces in struct phy_driver +initializers. + +Signed-off-by: Daniel Golle +Reviewed-by: Maxime Chevallier +Link: https://patch.msgid.link/42b0fac53c5c5646707ce3f3a6dacd2bc082a5b2.1767630451.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 146 ++++++++++++------------- + 1 file changed, 73 insertions(+), 73 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1976,7 +1976,7 @@ static irqreturn_t rtl8221b_handle_inter + static struct phy_driver realtek_drvs[] = { + { + PHY_ID_MATCH_EXACT(0x00008201), +- .name = "RTL8201CP Ethernet", ++ .name = "RTL8201CP Ethernet", + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + }, { +@@ -2102,7 +2102,7 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8226B_RTL8221B 2.5Gbps PHY", + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, ++ .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, +@@ -2111,112 +2111,112 @@ static struct phy_driver realtek_drvs[] + .write_page = rtl821x_write_page, + }, { + PHY_ID_MATCH_EXACT(0x001cc838), +- .name = "RTL8226-CG 2.5Gbps PHY", +- .soft_reset = rtl822x_c45_soft_reset, +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .config_init = rtl822x_config_init, +- .read_status = rtl822xb_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, ++ .name = "RTL8226-CG 2.5Gbps PHY", ++ .soft_reset = rtl822x_c45_soft_reset, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .config_init = rtl822x_config_init, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, + }, { + PHY_ID_MATCH_EXACT(0x001cc848), +- .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, ++ .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, + }, { + .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, +- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", + .probe = rtl822x_probe, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, + }, { + .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, +- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", + .config_intr = rtl8221b_config_intr, + .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, +- .config_init = rtl822xb_config_init, ++ .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822xb_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, + }, { + .match_phy_device = rtl8221b_vm_cg_c22_match_phy_device, +- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", ++ .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", + .probe = rtl822x_probe, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, ++ .read_status = rtl822xb_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, + }, { + .match_phy_device = rtl8221b_vm_cg_c45_match_phy_device, +- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)", ++ .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)", + .config_intr = rtl8221b_config_intr, + .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, +- .config_init = rtl822xb_config_init, ++ .config_init = rtl822xb_config_init, + .get_rate_matching = rtl822xb_get_rate_matching, +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822xb_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822xb_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, + }, { + .match_phy_device = rtl8251b_c45_match_phy_device, +- .name = "RTL8251B 5Gbps PHY", ++ .name = "RTL8251B 5Gbps PHY", + .probe = rtl822x_probe, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, + }, { + .match_phy_device = rtl_internal_nbaset_match_phy_device, +- .name = "Realtek Internal NBASE-T PHY", ++ .name = "Realtek Internal NBASE-T PHY", + .flags = PHY_IS_INTERNAL, + .probe = rtl822x_probe, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .read_status = rtl822x_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, ++ .get_features = rtl822x_get_features, ++ .config_aneg = rtl822x_config_aneg, ++ .read_status = rtl822x_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, + .read_mmd = rtl822x_read_mmd, + .write_mmd = rtl822x_write_mmd, + }, { + PHY_ID_MATCH_EXACT(0x001ccad0), + .name = "RTL8224 2.5Gbps PHY", + .flags = PHY_POLL_CABLE_TEST, +- .get_features = rtl822x_c45_get_features, +- .config_aneg = rtl822x_c45_config_aneg, +- .read_status = rtl822x_c45_read_status, +- .suspend = genphy_c45_pma_suspend, +- .resume = rtlgen_c45_resume, ++ .get_features = rtl822x_c45_get_features, ++ .config_aneg = rtl822x_c45_config_aneg, ++ .read_status = rtl822x_c45_read_status, ++ .suspend = genphy_c45_pma_suspend, ++ .resume = rtlgen_c45_resume, + .cable_test_start = rtl8224_cable_test_start, + .cable_test_get_status = rtl8224_cable_test_get_status, + }, { +@@ -2235,7 +2235,7 @@ static struct phy_driver realtek_drvs[] + }, { + PHY_ID_MATCH_EXACT(0x001ccb00), + .name = "RTL9000AA_RTL9000AN Ethernet", +- .features = PHY_BASIC_T1_FEATURES, ++ .features = PHY_BASIC_T1_FEATURES, + .config_init = rtl9000a_config_init, + .config_aneg = rtl9000a_config_aneg, + .read_status = rtl9000a_read_status, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/789-v7.0-net-phy-realtek-implement-configuring-in-band-an.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/789-v7.0-net-phy-realtek-implement-configuring-in-band-an.patch new file mode 100755 index 0000000..16e6de2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/789-v7.0-net-phy-realtek-implement-configuring-in-band-an.patch @@ -0,0 +1,148 @@ +From 10fbd71fc5f9bef5018a35103d493307683ddca1 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 5 Jan 2026 16:38:12 +0000 +Subject: [PATCH 2/5] net: phy: realtek: implement configuring in-band an + +Implement the inband_caps() and config_inband() PHY driver methods to +allow configuring the use of in-band-status with SGMII and 2500Base-X on +RTL8226 and RTL8221B 2.5GE PHYs. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/82a78a06d67be19e856d646cf880b2021ea9d837.1767630451.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 67 ++++++++++++++++++++++++++ + 1 file changed, 67 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -131,6 +131,15 @@ + #define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02 + #define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16 + ++#define RTL822X_VND1_SERDES_CMD 0x7587 ++#define RTL822X_VND1_SERDES_CMD_WRITE BIT(1) ++#define RTL822X_VND1_SERDES_CMD_BUSY BIT(0) ++#define RTL822X_VND1_SERDES_ADDR 0x7588 ++#define RTL822X_VND1_SERDES_ADDR_AUTONEG 0x2 ++#define RTL822X_VND1_SERDES_INBAND_DISABLE 0x71d0 ++#define RTL822X_VND1_SERDES_INBAND_ENABLE 0x70d0 ++#define RTL822X_VND1_SERDES_DATA 0x7589 ++ + /* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 + * is set, they cannot be accessed by C45-over-C22. + */ +@@ -1308,6 +1317,50 @@ static int rtl822xb_config_init(struct p + return rtl822x_set_serdes_option_mode(phydev, false); + } + ++static int rtl822x_serdes_write(struct phy_device *phydev, u16 reg, u16 val) ++{ ++ int ret, poll; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_ADDR, reg); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_DATA, val); ++ if (ret < 0) ++ return ret; ++ ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, RTL822X_VND1_SERDES_CMD, ++ RTL822X_VND1_SERDES_CMD_WRITE | ++ RTL822X_VND1_SERDES_CMD_BUSY); ++ if (ret < 0) ++ return ret; ++ ++ return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_VEND1, ++ RTL822X_VND1_SERDES_CMD, poll, ++ !(poll & RTL822X_VND1_SERDES_CMD_BUSY), ++ 500, 100000, false); ++} ++ ++static int rtl822x_config_inband(struct phy_device *phydev, unsigned int modes) ++{ ++ return rtl822x_serdes_write(phydev, RTL822X_VND1_SERDES_ADDR_AUTONEG, ++ (modes != LINK_INBAND_DISABLE) ? ++ RTL822X_VND1_SERDES_INBAND_ENABLE : ++ RTL822X_VND1_SERDES_INBAND_DISABLE); ++} ++ ++static unsigned int rtl822x_inband_caps(struct phy_device *phydev, ++ phy_interface_t interface) ++{ ++ switch (interface) { ++ case PHY_INTERFACE_MODE_2500BASEX: ++ case PHY_INTERFACE_MODE_SGMII: ++ return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; ++ default: ++ return 0; ++ } ++} ++ + static int rtl822xb_get_rate_matching(struct phy_device *phydev, + phy_interface_t iface) + { +@@ -2103,6 +2156,8 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, +@@ -2116,6 +2171,8 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, + .config_init = rtl822x_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, +@@ -2125,6 +2182,8 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, +@@ -2138,6 +2197,8 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, +@@ -2151,6 +2212,8 @@ static struct phy_driver realtek_drvs[] + .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .get_rate_matching = rtl822xb_get_rate_matching, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, +@@ -2164,6 +2227,8 @@ static struct phy_driver realtek_drvs[] + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .get_rate_matching = rtl822xb_get_rate_matching, + .read_status = rtl822xb_read_status, + .suspend = genphy_suspend, +@@ -2177,6 +2242,8 @@ static struct phy_driver realtek_drvs[] + .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, ++ .inband_caps = rtl822x_inband_caps, ++ .config_inband = rtl822x_config_inband, + .get_rate_matching = rtl822xb_get_rate_matching, + .get_features = rtl822x_c45_get_features, + .config_aneg = rtl822x_c45_config_aneg, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/790-v7.0-net-phy-realtek-use-paged-access-for-MDIO_MMD_VEND2-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/790-v7.0-net-phy-realtek-use-paged-access-for-MDIO_MMD_VEND2-.patch new file mode 100755 index 0000000..d84fb6a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/790-v7.0-net-phy-realtek-use-paged-access-for-MDIO_MMD_VEND2-.patch @@ -0,0 +1,172 @@ +From 1850ec20d6e71218c02329e5975591075dc972d3 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 5 Jan 2026 16:38:59 +0000 +Subject: [PATCH 4/5] net: phy: realtek: use paged access for MDIO_MMD_VEND2 in + C22 mode + +RTL822x cannot access MDIO_MMD_VEND2 via MII_MMD_CTRL/MII_MMD_DATA. A +mapping to use paged access needs to be used instead. All other MMD +devices can be accessed as usual. + +Implement phy_read_mmd and phy_write_mmd using paged access for +MDIO_MMD_VEND2 in Clause-22 mode instead of relying on +MII_MMD_CTRL/MII_MMD_DATA. This allows eg. rtl822x_config_aneg to work +as expected in case the MDIO bus doesn't support Clause-45 access. + +Suggested-by: Bevan Weiss +Signed-off-by: Daniel Golle +Reviewed-by: Maxime Chevallier +Link: https://patch.msgid.link/25aab7f02dac7c6022171455523e3db1435b0881.1767630451.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 91 +++++++++++++++++++++++++- + 1 file changed, 88 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -140,9 +140,8 @@ + #define RTL822X_VND1_SERDES_INBAND_ENABLE 0x70d0 + #define RTL822X_VND1_SERDES_DATA 0x7589 + +-/* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45 +- * is set, they cannot be accessed by C45-over-C22. +- */ ++#define RTL822X_VND2_TO_PAGE(reg) ((reg) >> 4) ++#define RTL822X_VND2_TO_PAGE_REG(reg) (16 + (((reg) & GENMASK(3, 0)) >> 1)) + #define RTL822X_VND2_C22_REG(reg) (0xa400 + 2 * (reg)) + + #define RTL8221B_VND2_INER 0xa4d2 +@@ -1247,6 +1246,79 @@ static int rtl822x_probe(struct phy_devi + return 0; + } + ++/* RTL822x cannot access MDIO_MMD_VEND2 via MII_MMD_CTRL/MII_MMD_DATA. ++ * A mapping to use paged access needs to be used instead. ++ * All other MMD devices can be accessed as usual. ++ */ ++static int rtl822xb_read_mmd(struct phy_device *phydev, int devnum, u16 reg) ++{ ++ int oldpage, ret, read_ret; ++ u16 page; ++ ++ /* Use default method for all MMDs except MDIO_MMD_VEND2 or in case ++ * Clause-45 access is available ++ */ ++ if (devnum != MDIO_MMD_VEND2 || phydev->is_c45) ++ return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr, ++ phydev->is_c45, devnum, reg); ++ ++ /* Use paged access for MDIO_MMD_VEND2 over Clause-22 */ ++ page = RTL822X_VND2_TO_PAGE(reg); ++ oldpage = __phy_read(phydev, RTL821x_PAGE_SELECT); ++ if (oldpage < 0) ++ return oldpage; ++ ++ if (oldpage != page) { ++ ret = __phy_write(phydev, RTL821x_PAGE_SELECT, page); ++ if (ret < 0) ++ return ret; ++ } ++ ++ read_ret = __phy_read(phydev, RTL822X_VND2_TO_PAGE_REG(reg)); ++ if (oldpage != page) { ++ ret = __phy_write(phydev, RTL821x_PAGE_SELECT, oldpage); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return read_ret; ++} ++ ++static int rtl822xb_write_mmd(struct phy_device *phydev, int devnum, u16 reg, ++ u16 val) ++{ ++ int oldpage, ret, write_ret; ++ u16 page; ++ ++ /* Use default method for all MMDs except MDIO_MMD_VEND2 or in case ++ * Clause-45 access is available ++ */ ++ if (devnum != MDIO_MMD_VEND2 || phydev->is_c45) ++ return mmd_phy_write(phydev->mdio.bus, phydev->mdio.addr, ++ phydev->is_c45, devnum, reg, val); ++ ++ /* Use paged access for MDIO_MMD_VEND2 over Clause-22 */ ++ page = RTL822X_VND2_TO_PAGE(reg); ++ oldpage = __phy_read(phydev, RTL821x_PAGE_SELECT); ++ if (oldpage < 0) ++ return oldpage; ++ ++ if (oldpage != page) { ++ ret = __phy_write(phydev, RTL821x_PAGE_SELECT, page); ++ if (ret < 0) ++ return ret; ++ } ++ ++ write_ret = __phy_write(phydev, RTL822X_VND2_TO_PAGE_REG(reg), val); ++ if (oldpage != page) { ++ ret = __phy_write(phydev, RTL821x_PAGE_SELECT, oldpage); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return write_ret; ++} ++ + static int rtl822x_set_serdes_option_mode(struct phy_device *phydev, bool gen1) + { + bool has_2500, has_sgmii; +@@ -2150,6 +2222,8 @@ static struct phy_driver realtek_drvs[] + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + .match_phy_device = rtl8221b_match_phy_device, + .name = "RTL8226B_RTL8221B 2.5Gbps PHY", +@@ -2164,6 +2238,8 @@ static struct phy_driver realtek_drvs[] + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + PHY_ID_MATCH_EXACT(0x001cc838), + .name = "RTL8226-CG 2.5Gbps PHY", +@@ -2176,6 +2252,8 @@ static struct phy_driver realtek_drvs[] + .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + PHY_ID_MATCH_EXACT(0x001cc848), + .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", +@@ -2190,6 +2268,8 @@ static struct phy_driver realtek_drvs[] + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", +@@ -2205,6 +2285,8 @@ static struct phy_driver realtek_drvs[] + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", +@@ -2235,6 +2317,8 @@ static struct phy_driver realtek_drvs[] + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + .match_phy_device = rtl8221b_vm_cg_c45_match_phy_device, + .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)", diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/791-v7.0-net-phy-realtek-get-rid-of-magic-number-in-rtlgen_re.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/791-v7.0-net-phy-realtek-get-rid-of-magic-number-in-rtlgen_re.patch new file mode 100755 index 0000000..992e660 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/791-v7.0-net-phy-realtek-get-rid-of-magic-number-in-rtlgen_re.patch @@ -0,0 +1,30 @@ +From d8489935f5979b72e73de585037fe6fde7088bc3 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 5 Jan 2026 16:39:26 +0000 +Subject: [PATCH 5/5] net: phy: realtek: get rid of magic number in + rtlgen_read_status() + +Use newly introduced helper macros RTL822X_VND2_TO_PAGE and +RTL822X_VND2_TO_PAGE_REG to access RTL_VEND2_PHYSR register over Clause-22 +paged access instead of using magic numbers. + +Signed-off-by: Daniel Golle +Reviewed-by: Maxime Chevallier +Link: https://patch.msgid.link/a53d4577335fdda4d363db9bc4bf614fd3a56c9b.1767630451.git.daniel@makrotopia.org +Signed-off-by: Paolo Abeni +--- + drivers/net/phy/realtek/realtek_main.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1153,7 +1153,8 @@ static int rtlgen_read_status(struct phy + if (!phydev->link) + return 0; + +- val = phy_read_paged(phydev, 0xa43, 0x12); ++ val = phy_read_paged(phydev, RTL822X_VND2_TO_PAGE(RTL_VND2_PHYSR), ++ RTL822X_VND2_TO_PAGE_REG(RTL_VND2_PHYSR)); + if (val < 0) + return val; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/792-v7.0-net-phy-realtek-add-dummy-PHY-driver-for-RTL8127ATF.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/792-v7.0-net-phy-realtek-add-dummy-PHY-driver-for-RTL8127ATF.patch new file mode 100755 index 0000000..85b4111 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/792-v7.0-net-phy-realtek-add-dummy-PHY-driver-for-RTL8127ATF.patch @@ -0,0 +1,123 @@ +From c4277d21ab694c7964a48759a5452e5bbbe12965 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Sat, 10 Jan 2026 16:14:05 +0100 +Subject: [PATCH] net: phy: realtek: add dummy PHY driver for RTL8127ATF + +RTL8127ATF supports a SFP+ port for fiber modules (10GBASE-SR/LR/ER/ZR and +DAC). The list of supported modes was provided by Realtek. According to the +r8127 vendor driver also 1G modules are supported, but this needs some more +complexity in the driver, and only 10G mode has been tested so far. +Therefore mainline support will be limited to 10G for now. +The SFP port signals are hidden in the chip IP and driven by firmware. +Therefore mainline SFP support can't be used here. +This PHY driver is used by the RTL8127ATF support in r8169. +RTL8127ATF reports the same PHY ID as the TP version. Therefore use a dummy +PHY ID. This PHY driver is used by the RTL8127ATF support in r8169. + +Signed-off-by: Heiner Kallweit +Link: https://patch.msgid.link/e3d55162-210a-4fab-9abf-99c6954eee10@gmail.com +Signed-off-by: Jakub Kicinski +--- + MAINTAINERS | 1 + + drivers/net/phy/realtek/realtek_main.c | 54 ++++++++++++++++++++++++++ + include/net/phy/realtek_phy.h | 7 ++++ + 3 files changed, 62 insertions(+) + create mode 100644 include/net/phy/realtek_phy.h + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -8459,6 +8459,7 @@ F: include/linux/phy_link_topology.h + F: include/linux/phylib_stubs.h + F: include/linux/platform_data/mdio-bcm-unimac.h + F: include/linux/platform_data/mdio-gpio.h ++F: include/net/phy/ + F: include/trace/events/mdio.h + F: include/uapi/linux/mdio.h + F: include/uapi/linux/mii.h +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + + #include "realtek.h" + +@@ -2099,6 +2100,45 @@ static irqreturn_t rtl8221b_handle_inter + return IRQ_HANDLED; + } + ++static int rtlgen_sfp_get_features(struct phy_device *phydev) ++{ ++ linkmode_set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, ++ phydev->supported); ++ ++ /* set default mode */ ++ phydev->speed = SPEED_10000; ++ phydev->duplex = DUPLEX_FULL; ++ ++ phydev->port = PORT_FIBRE; ++ ++ return 0; ++} ++ ++static int rtlgen_sfp_read_status(struct phy_device *phydev) ++{ ++ int val, err; ++ ++ err = genphy_update_link(phydev); ++ if (err) ++ return err; ++ ++ if (!phydev->link) ++ return 0; ++ ++ val = rtlgen_read_vend2(phydev, RTL_VND2_PHYSR); ++ if (val < 0) ++ return val; ++ ++ rtlgen_decode_physr(phydev, val); ++ ++ return 0; ++} ++ ++static int rtlgen_sfp_config_aneg(struct phy_device *phydev) ++{ ++ return 0; ++} ++ + static struct phy_driver realtek_drvs[] = { + { + PHY_ID_MATCH_EXACT(0x00008201), +@@ -2357,6 +2397,20 @@ static struct phy_driver realtek_drvs[] + .suspend = genphy_suspend, + .resume = rtlgen_resume, + .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ .read_mmd = rtl822x_read_mmd, ++ .write_mmd = rtl822x_write_mmd, ++ }, { ++ PHY_ID_MATCH_EXACT(PHY_ID_RTL_DUMMY_SFP), ++ .name = "Realtek SFP PHY Mode", ++ .flags = PHY_IS_INTERNAL, ++ .probe = rtl822x_probe, ++ .get_features = rtlgen_sfp_get_features, ++ .config_aneg = rtlgen_sfp_config_aneg, ++ .read_status = rtlgen_sfp_read_status, ++ .suspend = genphy_suspend, ++ .resume = rtlgen_resume, ++ .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + .read_mmd = rtl822x_read_mmd, + .write_mmd = rtl822x_write_mmd, +--- /dev/null ++++ b/include/net/phy/realtek_phy.h +@@ -0,0 +1,7 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef _REALTEK_PHY_H ++#define _REALTEK_PHY_H ++ ++#define PHY_ID_RTL_DUMMY_SFP 0x001ccbff ++ ++#endif /* _REALTEK_PHY_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/793-v7.0-net-phy-realtek-fix-in-band-capabilities-for-2.5G-PH.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/793-v7.0-net-phy-realtek-fix-in-band-capabilities-for-2.5G-PH.patch new file mode 100755 index 0000000..7e44ea9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/793-v7.0-net-phy-realtek-fix-in-band-capabilities-for-2.5G-PH.patch @@ -0,0 +1,35 @@ +From 8744b63e8a9ac4a3c30b557ca6bc115851a980e9 Mon Sep 17 00:00:00 2001 +From: Jan Hoffmann +Date: Tue, 13 Jan 2026 21:55:44 +0100 +Subject: [PATCH] net: phy: realtek: fix in-band capabilities for 2.5G PHYs + +It looks like the configuration of in-band AN only affects SGMII, and it +is always disabled for 2500Base-X. Adjust the reported capabilities +accordingly. + +This is based on testing using OpenWrt on Zyxel XGS1010-12 rev A1 with +RTL8226-CG, and Zyxel XGS1210-12 rev B1 with RTL8221B-VB-CG. On these +devices, 2500Base-X in-band AN is known to work with some SFP modules +(containing an unknown PHY). However, with the built-in Realtek PHYs, +no auto-negotiation takes place, irrespective of the configuration of +the PHY. + +Fixes: 10fbd71fc5f9b ("net: phy: realtek: implement configuring in-band an") +Signed-off-by: Jan Hoffmann +Reviewed-by: Daniel Golle +Link: https://patch.msgid.link/20260113205557.503409-1-jan@3e8.eu +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1428,6 +1428,7 @@ static unsigned int rtl822x_inband_caps( + { + switch (interface) { + case PHY_INTERFACE_MODE_2500BASEX: ++ return LINK_INBAND_DISABLE; + case PHY_INTERFACE_MODE_SGMII: + return LINK_INBAND_DISABLE | LINK_INBAND_ENABLE; + default: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/794-v7.0-net-phy-realtek-support-interrupt-also-for-C22-varia.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/794-v7.0-net-phy-realtek-support-interrupt-also-for-C22-varia.patch new file mode 100755 index 0000000..ea3347d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/794-v7.0-net-phy-realtek-support-interrupt-also-for-C22-varia.patch @@ -0,0 +1,38 @@ +From 84fb8b93fae2a4c53323b2bf6d81e7ddcc8e7cf4 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 13 Jan 2026 03:44:00 +0000 +Subject: [PATCH 1/5] net: phy: realtek: support interrupt also for C22 + variants + +Now that access to MDIO_MMD_VEND2 works transparently also in Clause-22 +mode, add interrupt support also for the C22 variants of the +RTL8221B-VB-CG and RTL8221B-VM-CG. This results in the C22 and C45 +driver instances now having all the same features implemented. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/7620084b1de01580edc2d0e1b9548507fb4643a8.1768275364.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -2315,6 +2315,8 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", ++ .config_intr = rtl8221b_config_intr, ++ .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, +@@ -2347,6 +2349,8 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_vm_cg_c22_match_phy_device, + .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", ++ .config_intr = rtl8221b_config_intr, ++ .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/795-v7.0-net-phy-realtek-simplify-C22-reg-access-via-MDIO_MMD.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/795-v7.0-net-phy-realtek-simplify-C22-reg-access-via-MDIO_MMD.patch new file mode 100755 index 0000000..a67b0ef --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/795-v7.0-net-phy-realtek-simplify-C22-reg-access-via-MDIO_MMD.patch @@ -0,0 +1,61 @@ +From 2809a1c4340437f2ff6b73c0094d7ca51b575e1b Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 13 Jan 2026 03:44:17 +0000 +Subject: [PATCH 2/5] net: phy: realtek: simplify C22 reg access via + MDIO_MMD_VEND2 + +RealTek 2.5GE PHYs have all standard Clause-22 registers mapped also +inside MDIO_MMD_VEND2 at offset 0xa400. This is used mainly in case the +PHY is connected to a Clause-45-only bus. The RTL8221B is frequently +used in copper SFP module which uses the RollBall MDIO-over-I2C +method which *only* supports Clause-45, for example. + +In order to support using the PHY on Clause-45-only busses, the PHY +driver has previously been split into a C22-only and C45-only instances, +creating quite a bit of redundancy and confusion. + +In preparation of reunifying the two driver instances, add support for +translating MDIO_MMD_VEND2 registers 0xa400 to 0xa43c back to Clause-22 +registers 0 to 30 in case the PHY is accessed on a Clause-22 bus. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/fd49d86bd0445b76269fd3ea456c709c2066683f.1768275364.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -143,6 +143,7 @@ + + #define RTL822X_VND2_TO_PAGE(reg) ((reg) >> 4) + #define RTL822X_VND2_TO_PAGE_REG(reg) (16 + (((reg) & GENMASK(3, 0)) >> 1)) ++#define RTL822X_VND2_TO_C22_REG(reg) (((reg) - 0xa400) / 2) + #define RTL822X_VND2_C22_REG(reg) (0xa400 + 2 * (reg)) + + #define RTL8221B_VND2_INER 0xa4d2 +@@ -1264,6 +1265,11 @@ static int rtl822xb_read_mmd(struct phy_ + return mmd_phy_read(phydev->mdio.bus, phydev->mdio.addr, + phydev->is_c45, devnum, reg); + ++ /* Simplify access to C22-registers addressed inside MDIO_MMD_VEND2 */ ++ if (reg >= RTL822X_VND2_C22_REG(0) && ++ reg <= RTL822X_VND2_C22_REG(30)) ++ return __phy_read(phydev, RTL822X_VND2_TO_C22_REG(reg)); ++ + /* Use paged access for MDIO_MMD_VEND2 over Clause-22 */ + page = RTL822X_VND2_TO_PAGE(reg); + oldpage = __phy_read(phydev, RTL821x_PAGE_SELECT); +@@ -1299,6 +1305,11 @@ static int rtl822xb_write_mmd(struct phy + return mmd_phy_write(phydev->mdio.bus, phydev->mdio.addr, + phydev->is_c45, devnum, reg, val); + ++ /* Simplify access to C22-registers addressed inside MDIO_MMD_VEND2 */ ++ if (reg >= RTL822X_VND2_C22_REG(0) && ++ reg <= RTL822X_VND2_C22_REG(30)) ++ return __phy_write(phydev, RTL822X_VND2_TO_C22_REG(reg), val); ++ + /* Use paged access for MDIO_MMD_VEND2 over Clause-22 */ + page = RTL822X_VND2_TO_PAGE(reg); + oldpage = __phy_read(phydev, RTL821x_PAGE_SELECT); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/796-v7.0-net-phy-realtek-reunify-C22-and-C45-drivers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/796-v7.0-net-phy-realtek-reunify-C22-and-C45-drivers.patch new file mode 100755 index 0000000..5bca303 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/796-v7.0-net-phy-realtek-reunify-C22-and-C45-drivers.patch @@ -0,0 +1,133 @@ +From 85f75da86a0adc4798d3675aab3365e721a1dbf5 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 13 Jan 2026 03:44:25 +0000 +Subject: [PATCH 3/5] net: phy: realtek: reunify C22 and C45 drivers + +Reunify the split C22/C45 drivers for the RTL8221B-VB-CG 2.5Gbps and +RTL8221B-VM-CG 2.5Gbps PHYs back into a single driver. + +This is possible now by using all the driver operations previously used +by the C45 driver, as transparent access to all MMDs including +MDIO_MMD_VEND2 is now possible also over Clause-22 MDIO. + +The unified driver will still only use Clause-45 access on any Clause-45 +capable busses while still working fine on Clause-22 busses. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/bffcb85fdc20e07056976962d3caaa1be5d0ddb0.1768275364.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 72 ++++++-------------------- + 1 file changed, 16 insertions(+), 56 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1880,28 +1880,18 @@ static int rtl8221b_match_phy_device(str + return phydev->phy_id == RTL_8221B && rtlgen_supports_mmd(phydev); + } + +-static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device *phydev, +- const struct phy_driver *phydrv) ++static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { +- return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true) || ++ rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, false); + } + +-static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device *phydev, +- const struct phy_driver *phydrv) ++static int rtl8221b_vm_cg_match_phy_device(struct phy_device *phydev, ++ const struct phy_driver *phydrv) + { +- return rtlgen_is_c45_match(phydev, RTL_8221B_VB_CG, true); +-} +- +-static int rtl8221b_vm_cg_c22_match_phy_device(struct phy_device *phydev, +- const struct phy_driver *phydrv) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false); +-} +- +-static int rtl8221b_vm_cg_c45_match_phy_device(struct phy_device *phydev, +- const struct phy_driver *phydrv) +-{ +- return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true); ++ return rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, true) || ++ rtlgen_is_c45_match(phydev, RTL_8221B_VM_CG, false); + } + + static int rtl_internal_nbaset_match_phy_device(struct phy_device *phydev, +@@ -2324,27 +2314,8 @@ static struct phy_driver realtek_drvs[] + .read_mmd = rtl822xb_read_mmd, + .write_mmd = rtl822xb_write_mmd, + }, { +- .match_phy_device = rtl8221b_vb_cg_c22_match_phy_device, +- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C22)", +- .config_intr = rtl8221b_config_intr, +- .handle_interrupt = rtl8221b_handle_interrupt, +- .probe = rtl822x_probe, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, +- .inband_caps = rtl822x_inband_caps, +- .config_inband = rtl822x_config_inband, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, +- .read_page = rtl821x_read_page, +- .write_page = rtl821x_write_page, +- .read_mmd = rtl822xb_read_mmd, +- .write_mmd = rtl822xb_write_mmd, +- }, { +- .match_phy_device = rtl8221b_vb_cg_c45_match_phy_device, +- .name = "RTL8221B-VB-CG 2.5Gbps PHY (C45)", ++ .match_phy_device = rtl8221b_vb_cg_match_phy_device, ++ .name = "RTL8221B-VB-CG 2.5Gbps PHY", + .config_intr = rtl8221b_config_intr, + .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, +@@ -2357,28 +2328,13 @@ static struct phy_driver realtek_drvs[] + .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, +- }, { +- .match_phy_device = rtl8221b_vm_cg_c22_match_phy_device, +- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C22)", +- .config_intr = rtl8221b_config_intr, +- .handle_interrupt = rtl8221b_handle_interrupt, +- .probe = rtl822x_probe, +- .get_features = rtl822x_get_features, +- .config_aneg = rtl822x_config_aneg, +- .config_init = rtl822xb_config_init, +- .inband_caps = rtl822x_inband_caps, +- .config_inband = rtl822x_config_inband, +- .get_rate_matching = rtl822xb_get_rate_matching, +- .read_status = rtl822xb_read_status, +- .suspend = genphy_suspend, +- .resume = rtlgen_resume, + .read_page = rtl821x_read_page, + .write_page = rtl821x_write_page, + .read_mmd = rtl822xb_read_mmd, + .write_mmd = rtl822xb_write_mmd, + }, { +- .match_phy_device = rtl8221b_vm_cg_c45_match_phy_device, +- .name = "RTL8221B-VM-CG 2.5Gbps PHY (C45)", ++ .match_phy_device = rtl8221b_vm_cg_match_phy_device, ++ .name = "RTL8221B-VM-CG 2.5Gbps PHY", + .config_intr = rtl8221b_config_intr, + .handle_interrupt = rtl8221b_handle_interrupt, + .probe = rtl822x_probe, +@@ -2391,6 +2347,10 @@ static struct phy_driver realtek_drvs[] + .read_status = rtl822xb_c45_read_status, + .suspend = genphy_c45_pma_suspend, + .resume = rtlgen_c45_resume, ++ .read_page = rtl821x_read_page, ++ .write_page = rtl821x_write_page, ++ .read_mmd = rtl822xb_read_mmd, ++ .write_mmd = rtl822xb_write_mmd, + }, { + .match_phy_device = rtl8251b_c45_match_phy_device, + .name = "RTL8251B 5Gbps PHY", diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/797-v7.0-net-phy-realtek-demystify-PHYSR-register-location.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/797-v7.0-net-phy-realtek-demystify-PHYSR-register-location.patch new file mode 100755 index 0000000..185e0fd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/797-v7.0-net-phy-realtek-demystify-PHYSR-register-location.patch @@ -0,0 +1,90 @@ +From 46ff862d376cfadf0f9e36a6edce41a003175708 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 13 Jan 2026 03:44:33 +0000 +Subject: [PATCH 4/5] net: phy: realtek: demystify PHYSR register location + +Turns out that register address RTL_VND2_PHYSR (0xa434) maps to +Clause-22 register MII_RESV2. Use that to get rid of yet another magic +number, and rename access macros accordingly. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/6ed246e0aa3ca8038d2fa432d51518959fb89b6b.1768275364.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -178,12 +178,12 @@ + #define RTL9000A_GINMR 0x14 + #define RTL9000A_GINMR_LINK_STATUS BIT(4) + +-#define RTL_VND2_PHYSR 0xa434 +-#define RTL_VND2_PHYSR_DUPLEX BIT(3) +-#define RTL_VND2_PHYSR_SPEEDL GENMASK(5, 4) +-#define RTL_VND2_PHYSR_SPEEDH GENMASK(10, 9) +-#define RTL_VND2_PHYSR_MASTER BIT(11) +-#define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR_SPEEDH) ++#define RTL_PHYSR MII_RESV2 ++#define RTL_PHYSR_DUPLEX BIT(3) ++#define RTL_PHYSR_SPEEDL GENMASK(5, 4) ++#define RTL_PHYSR_SPEEDH GENMASK(10, 9) ++#define RTL_PHYSR_MASTER BIT(11) ++#define RTL_PHYSR_SPEED_MASK (RTL_PHYSR_SPEEDL | RTL_PHYSR_SPEEDH) + + #define RTL_MDIO_PCS_EEE_ABLE 0xa5c4 + #define RTL_MDIO_AN_EEE_ADV 0xa5d0 +@@ -1102,12 +1102,12 @@ static void rtlgen_decode_physr(struct p + * 0: Half Duplex + * 1: Full Duplex + */ +- if (val & RTL_VND2_PHYSR_DUPLEX) ++ if (val & RTL_PHYSR_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + +- switch (val & RTL_VND2_PHYSR_SPEED_MASK) { ++ switch (val & RTL_PHYSR_SPEED_MASK) { + case 0x0000: + phydev->speed = SPEED_10; + break; +@@ -1135,7 +1135,7 @@ static void rtlgen_decode_physr(struct p + * 1: Master Mode + */ + if (phydev->speed >= 1000) { +- if (val & RTL_VND2_PHYSR_MASTER) ++ if (val & RTL_PHYSR_MASTER) + phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER; + else + phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE; +@@ -1155,8 +1155,7 @@ static int rtlgen_read_status(struct phy + if (!phydev->link) + return 0; + +- val = phy_read_paged(phydev, RTL822X_VND2_TO_PAGE(RTL_VND2_PHYSR), +- RTL822X_VND2_TO_PAGE_REG(RTL_VND2_PHYSR)); ++ val = phy_read(phydev, RTL_PHYSR); + if (val < 0) + return val; + +@@ -1623,7 +1622,8 @@ static int rtl822x_c45_read_status(struc + } + + /* Read actual speed from vendor register. */ +- val = phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL_VND2_PHYSR); ++ val = phy_read_mmd(phydev, MDIO_MMD_VEND2, ++ RTL822X_VND2_C22_REG(RTL_PHYSR)); + if (val < 0) + return val; + +@@ -2127,7 +2127,7 @@ static int rtlgen_sfp_read_status(struct + if (!phydev->link) + return 0; + +- val = rtlgen_read_vend2(phydev, RTL_VND2_PHYSR); ++ val = phy_read(phydev, RTL_PHYSR); + if (val < 0) + return val; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/798-v7.0-net-phy-realtek-simplify-bogus-paged-operations.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/798-v7.0-net-phy-realtek-simplify-bogus-paged-operations.patch new file mode 100755 index 0000000..f03ad66 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/798-v7.0-net-phy-realtek-simplify-bogus-paged-operations.patch @@ -0,0 +1,93 @@ +From 650e55f224a575cdb18c984b95036109519502d1 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 13 Jan 2026 03:44:42 +0000 +Subject: [PATCH 5/5] net: phy: realtek: simplify bogus paged operations + +Only registers 0x10~0x17 are affected by the value in the page +selection register 0x1f. Hence there is no point in using paged +operations when accessing any other registers. +Simplify the driver by using the normal phy_read and phy_write +operations for registers which are anyway not affected by paging. + +Signed-off-by: Daniel Golle +Link: https://patch.msgid.link/0c5cbb66ce3e72a011d76f8c3d61ebcac44483bb.1768275364.git.daniel@makrotopia.org +Signed-off-by: Jakub Kicinski +--- + drivers/net/phy/realtek/realtek_main.c | 19 ++++++++----------- + 1 file changed, 8 insertions(+), 11 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -67,7 +67,6 @@ + #define RTL8211E_DELAY_MASK GENMASK(13, 11) + + /* RTL8211F PHY configuration */ +-#define RTL8211F_PHYCR_PAGE 0xa43 + #define RTL8211F_PHYCR1 0x18 + #define RTL8211F_ALDPS_PLL_OFF BIT(1) + #define RTL8211F_ALDPS_ENABLE BIT(2) +@@ -77,7 +76,6 @@ + #define RTL8211F_CLKOUT_EN BIT(0) + #define RTL8211F_PHYCR2_PHY_EEE_ENABLE BIT(5) + +-#define RTL8211F_INSR_PAGE 0xa43 + #define RTL8211F_INSR 0x1d + + /* RTL8211F LED configuration */ +@@ -332,7 +330,7 @@ static int rtl8211f_ack_interrupt(struct + { + int err; + +- err = phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); ++ err = phy_read(phydev, RTL8211F_INSR); + + return (err < 0) ? err : 0; + } +@@ -478,7 +476,7 @@ static irqreturn_t rtl8211f_handle_inter + { + int irq_status; + +- irq_status = phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); ++ irq_status = phy_read(phydev, RTL8211F_INSR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; +@@ -669,8 +667,8 @@ static int rtl8211f_config_clk_out(struc + RTL8211FVD_CLKOUT_REG, + RTL8211FVD_CLKOUT_EN, 0); + else +- ret = phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, +- RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, 0); ++ ret = phy_modify(phydev, RTL8211F_PHYCR2, RTL8211F_CLKOUT_EN, ++ 0); + if (ret) + return ret; + +@@ -695,15 +693,14 @@ static int rtl8211f_config_aldps(struct + if (!priv->enable_aldps) + return 0; + +- return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR1, +- mask, mask); ++ return phy_modify(phydev, RTL8211F_PHYCR1, mask, mask); + } + + static int rtl8211f_config_phy_eee(struct phy_device *phydev) + { + /* Disable PHY-mode EEE so LPI is passed to the MAC */ +- return phy_modify_paged(phydev, RTL8211F_PHYCR_PAGE, RTL8211F_PHYCR2, +- RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); ++ return phy_modify(phydev, RTL8211F_PHYCR2, ++ RTL8211F_PHYCR2_PHY_EEE_ENABLE, 0); + } + + static int rtl8211f_config_init(struct phy_device *phydev) +@@ -769,7 +766,7 @@ static int rtl8211f_suspend(struct phy_d + goto err; + + /* Read the INSR to clear any pending interrupt */ +- phy_read_paged(phydev, RTL8211F_INSR_PAGE, RTL8211F_INSR); ++ phy_read(phydev, RTL8211F_INSR); + + /* Reset the WoL to ensure that an event is picked up. + * Unless we do this, even if we receive another packet, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/799-v7.0-mtd-physmap-core-Prioritize-ofparts-for-OF-probe.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/799-v7.0-mtd-physmap-core-Prioritize-ofparts-for-OF-probe.patch new file mode 100755 index 0000000..4aac643 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/799-v7.0-mtd-physmap-core-Prioritize-ofparts-for-OF-probe.patch @@ -0,0 +1,33 @@ +From cd3303e9081050ad09b031bc5b58c89fe6902f86 Mon Sep 17 00:00:00 2001 +From: Linus Walleij +Date: Thu, 29 Jan 2026 00:48:36 +0100 +Subject: [PATCH] mtd: physmap-core: Prioritize ofparts for OF probe + +Place the ofparts before RedBoot partitions in the OF probe +path: this makes it possible to override any existing +RedBoot partitions with fixed-partitions which may be necessary, +such as when you need to repartition the flash from Linux' +point of view but not necessary from the bootloaders point +of view. + +This happens when a device such as Raidsonic IB-4220-B has +three partitions named "Kern", "Ramdisk" and "Application" +that we want to merge into one for more efficient use +of the flash memory in OpenWrt. + +Signed-off-by: Linus Walleij +--- + drivers/mtd/maps/physmap-core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/maps/physmap-core.c ++++ b/drivers/mtd/maps/physmap-core.c +@@ -268,7 +268,7 @@ static const struct of_device_id of_flas + MODULE_DEVICE_TABLE(of, of_flash_match); + + static const char * const of_default_part_probes[] = { +- "cmdlinepart", "RedBoot", "ofpart", "ofoldpart", NULL ++ "cmdlinepart", "ofpart", "ofoldpart", "RedBoot", NULL + }; + + static const char * const *of_get_part_probes(struct platform_device *dev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/800-v6.13-hwmon-Add-static-visibility-member-to-struct-hwmon_o.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/800-v6.13-hwmon-Add-static-visibility-member-to-struct-hwmon_o.patch new file mode 100755 index 0000000..0c9f920 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/800-v6.13-hwmon-Add-static-visibility-member-to-struct-hwmon_o.patch @@ -0,0 +1,88 @@ +From 79bc0af904db647979c735563299c9b0d820e432 Mon Sep 17 00:00:00 2001 +From: Heiner Kallweit +Date: Thu, 10 Oct 2024 21:35:42 +0200 +Subject: [PATCH] hwmon: Add static visibility member to struct hwmon_ops + +Several drivers return the same static value in their is_visible +callback, what results in code duplication. Therefore add an option +for drivers to specify a static visibility directly. + +Signed-off-by: Heiner Kallweit +Message-ID: <89690b81-2c73-47ae-9ae9-45c77b45ca0c@gmail.com> +groeck: Renamed hwmon_ops_is_visible -> hwmon_is_visible +Signed-off-by: Guenter Roeck +--- + drivers/hwmon/hwmon.c | 19 +++++++++++++++---- + include/linux/hwmon.h | 5 ++++- + 2 files changed, 19 insertions(+), 5 deletions(-) + +--- a/drivers/hwmon/hwmon.c ++++ b/drivers/hwmon/hwmon.c +@@ -145,6 +145,17 @@ static const struct class hwmon_class = + + static DEFINE_IDA(hwmon_ida); + ++static umode_t hwmon_is_visible(const struct hwmon_ops *ops, ++ const void *drvdata, ++ enum hwmon_sensor_types type, ++ u32 attr, int channel) ++{ ++ if (ops->visible) ++ return ops->visible; ++ ++ return ops->is_visible(drvdata, type, attr, channel); ++} ++ + /* Thermal zone handling */ + + /* +@@ -267,8 +278,8 @@ static int hwmon_thermal_register_sensor + int err; + + if (!(info[i]->config[j] & HWMON_T_INPUT) || +- !chip->ops->is_visible(drvdata, hwmon_temp, +- hwmon_temp_input, j)) ++ !hwmon_is_visible(chip->ops, drvdata, hwmon_temp, ++ hwmon_temp_input, j)) + continue; + + err = hwmon_thermal_add_sensor(dev, j); +@@ -506,7 +517,7 @@ static struct attribute *hwmon_genattr(c + const char *name; + bool is_string = is_string_attr(type, attr); + +- mode = ops->is_visible(drvdata, type, attr, index); ++ mode = hwmon_is_visible(ops, drvdata, type, attr, index); + if (!mode) + return ERR_PTR(-ENOENT); + +@@ -1033,7 +1044,7 @@ hwmon_device_register_with_info(struct d + if (!dev || !name || !chip) + return ERR_PTR(-EINVAL); + +- if (!chip->ops || !chip->ops->is_visible || !chip->info) ++ if (!chip->ops || !(chip->ops->visible || chip->ops->is_visible) || !chip->info) + return ERR_PTR(-EINVAL); + + return __hwmon_device_register(dev, name, drvdata, chip, extra_groups); +--- a/include/linux/hwmon.h ++++ b/include/linux/hwmon.h +@@ -368,7 +368,9 @@ enum hwmon_intrusion_attributes { + + /** + * struct hwmon_ops - hwmon device operations +- * @is_visible: Callback to return attribute visibility. Mandatory. ++ * @visible: Static visibility. If non-zero, 'is_visible' is ignored. ++ * @is_visible: Callback to return attribute visibility. Mandatory unless ++ * 'visible' is non-zero. + * Parameters are: + * @const void *drvdata: + * Pointer to driver-private data structure passed +@@ -412,6 +414,7 @@ enum hwmon_intrusion_attributes { + * The function returns 0 on success or a negative error number. + */ + struct hwmon_ops { ++ umode_t visible; + umode_t (*is_visible)(const void *drvdata, enum hwmon_sensor_types type, + u32 attr, int channel); + int (*read)(struct device *dev, enum hwmon_sensor_types type, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-01-v6.13-dt-bindings-clocks-add-binding-for-gated-fixed-clock.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-01-v6.13-dt-bindings-clocks-add-binding-for-gated-fixed-clock.patch new file mode 100755 index 0000000..f5ab8a0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-01-v6.13-dt-bindings-clocks-add-binding-for-gated-fixed-clock.patch @@ -0,0 +1,82 @@ +From a4a7cbe36623ffaabbae413c0eacf40d033db71f Mon Sep 17 00:00:00 2001 +From: Heiko Stuebner +Date: Fri, 6 Sep 2024 10:25:07 +0200 +Subject: dt-bindings: clocks: add binding for gated-fixed-clocks + +In contrast to fixed clocks that are described as ungateable, boards +sometimes use additional oscillators for things like PCIe reference +clocks, that need actual supplies to get enabled and enable-gpios to be +toggled for them to work. + +This adds a binding for such oscillators that are not configurable +themself, but need to handle supplies for them to work. + +In schematics they often can be seen as + + ---------------- +Enable - | 100MHz,3.3V, | - VDD + | 3225 | + GND - | | - OUT + ---------------- + +or similar. The enable pin might be separate but can also just be tied +to the vdd supply, hence it is optional in the binding. + +Signed-off-by: Heiko Stuebner +Reviewed-by: Rob Herring (Arm) +Reviewed-by: Conor Dooley +Link: https://lore.kernel.org/r/20240906082511.2963890-2-heiko@sntech.de +Signed-off-by: Stephen Boyd + +--- /dev/null ++++ b/Documentation/devicetree/bindings/clock/gated-fixed-clock.yaml +@@ -0,0 +1,49 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/clock/gated-fixed-clock.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: Gated Fixed clock ++ ++maintainers: ++ - Heiko Stuebner ++ ++properties: ++ compatible: ++ const: gated-fixed-clock ++ ++ "#clock-cells": ++ const: 0 ++ ++ clock-frequency: true ++ ++ clock-output-names: ++ maxItems: 1 ++ ++ enable-gpios: ++ description: ++ Contains a single GPIO specifier for the GPIO that enables and disables ++ the oscillator. ++ maxItems: 1 ++ ++ vdd-supply: ++ description: handle of the regulator that provides the supply voltage ++ ++required: ++ - compatible ++ - "#clock-cells" ++ - clock-frequency ++ - vdd-supply ++ ++additionalProperties: false ++ ++examples: ++ - | ++ clock-1000000000 { ++ compatible = "gated-fixed-clock"; ++ #clock-cells = <0>; ++ clock-frequency = <1000000000>; ++ vdd-supply = <®_vdd>; ++ }; ++... diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-02-v6.13-clk-clk-gpio-update-documentation-for-gpio-gate-cloc.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-02-v6.13-clk-clk-gpio-update-documentation-for-gpio-gate-cloc.patch new file mode 100755 index 0000000..99e41a1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-02-v6.13-clk-clk-gpio-update-documentation-for-gpio-gate-cloc.patch @@ -0,0 +1,27 @@ +From 6cb137c7e99f8307f1f0fcccb1896f2d3b0651d3 Mon Sep 17 00:00:00 2001 +From: Heiko Stuebner +Date: Fri, 6 Sep 2024 10:25:08 +0200 +Subject: clk: clk-gpio: update documentation for gpio-gate clock + +The main documentation block seems to be from a time before the driver +handled sleeping and non-sleeping gpios and with that change it seems +updating the doc was overlooked. So do that now. + +Signed-off-by: Heiko Stuebner +Link: https://lore.kernel.org/r/20240906082511.2963890-3-heiko@sntech.de +Signed-off-by: Stephen Boyd + +--- a/drivers/clk/clk-gpio.c ++++ b/drivers/clk/clk-gpio.c +@@ -22,8 +22,9 @@ + * DOC: basic gpio gated clock which can be enabled and disabled + * with gpio output + * Traits of this clock: +- * prepare - clk_(un)prepare only ensures parent is (un)prepared +- * enable - clk_enable and clk_disable are functional & control gpio ++ * prepare - clk_(un)prepare are functional and control a gpio that can sleep ++ * enable - clk_enable and clk_disable are functional & control ++ * non-sleeping gpio + * rate - inherits rate from parent. No clk_set_rate support + * parent - fixed parent. No clk_set_parent support + */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-03-v6.13-clk-clk-gpio-use-dev_err_probe-for-gpio-get-failure.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-03-v6.13-clk-clk-gpio-use-dev_err_probe-for-gpio-get-failure.patch new file mode 100755 index 0000000..1982bb3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-03-v6.13-clk-clk-gpio-use-dev_err_probe-for-gpio-get-failure.patch @@ -0,0 +1,44 @@ +From 36abe81d9c3fa200a57ef2363e93a2991e387e19 Mon Sep 17 00:00:00 2001 +From: Heiko Stuebner +Date: Fri, 6 Sep 2024 10:25:09 +0200 +Subject: clk: clk-gpio: use dev_err_probe for gpio-get failure + +This is a real driver and dev_err_probe will hide the distinction between +EPROBE_DEFER and other errors automatically, so there is no need to +open-code this. + +Signed-off-by: Heiko Stuebner +Link: https://lore.kernel.org/r/20240906082511.2963890-4-heiko@sntech.de +Signed-off-by: Stephen Boyd + +--- a/drivers/clk/clk-gpio.c ++++ b/drivers/clk/clk-gpio.c +@@ -200,7 +200,6 @@ static int gpio_clk_driver_probe(struct + struct gpio_desc *gpiod; + struct clk_hw *hw; + bool is_mux; +- int ret; + + is_mux = of_device_is_compatible(node, "gpio-mux-clock"); + +@@ -212,17 +211,9 @@ static int gpio_clk_driver_probe(struct + + gpio_name = is_mux ? "select" : "enable"; + gpiod = devm_gpiod_get(dev, gpio_name, GPIOD_OUT_LOW); +- if (IS_ERR(gpiod)) { +- ret = PTR_ERR(gpiod); +- if (ret == -EPROBE_DEFER) +- pr_debug("%pOFn: %s: GPIOs not yet available, retry later\n", +- node, __func__); +- else +- pr_err("%pOFn: %s: Can't get '%s' named GPIO property\n", +- node, __func__, +- gpio_name); +- return ret; +- } ++ if (IS_ERR(gpiod)) ++ return dev_err_probe(dev, PTR_ERR(gpiod), ++ "Can't get '%s' named GPIO property\n", gpio_name); + + if (is_mux) + hw = clk_hw_register_gpio_mux(dev, gpiod); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-04-v6.13-clk-clk-gpio-add-driver-for-gated-fixed-clocks.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-04-v6.13-clk-clk-gpio-add-driver-for-gated-fixed-clocks.patch new file mode 100755 index 0000000..44da746 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/801-04-v6.13-clk-clk-gpio-add-driver-for-gated-fixed-clocks.patch @@ -0,0 +1,229 @@ +From 4940071d962827467f7297be3b874c96186ca0b7 Mon Sep 17 00:00:00 2001 +From: Heiko Stuebner +Date: Fri, 6 Sep 2024 10:25:10 +0200 +Subject: clk: clk-gpio: add driver for gated-fixed-clocks + +In contrast to fixed clocks that are described as ungateable, boards +sometimes use additional oscillators for things like PCIe reference +clocks, that need actual supplies to get enabled and enable-gpios to be +toggled for them to work. + +This adds a driver for those generic gated-fixed-clocks +that can show up in schematics looking like + + ---------------- +Enable - | 100MHz,3.3V, | - VDD + | 3225 | + GND - | | - OUT + ---------------- + +The new driver gets grouped together with the existing gpio-gate and +gpio-mux, as it for one re-uses a lot of the gpio-gate functions +and also in its core it's just another gpio-controlled clock, just +with a fixed rate and a regulator-supply added in. + +The regulator-API provides function stubs for the !CONFIG_REGULATOR case, +so no special handling is necessary. + +Signed-off-by: Heiko Stuebner +Link: https://lore.kernel.org/r/20240906082511.2963890-5-heiko@sntech.de +Signed-off-by: Stephen Boyd + +--- a/drivers/clk/clk-gpio.c ++++ b/drivers/clk/clk-gpio.c +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + + /** + * DOC: basic gpio gated clock which can be enabled and disabled +@@ -239,3 +240,187 @@ static struct platform_driver gpio_clk_d + }, + }; + builtin_platform_driver(gpio_clk_driver); ++ ++/** ++ * DOC: gated fixed clock, controlled with a gpio output and a regulator ++ * Traits of this clock: ++ * prepare - clk_prepare and clk_unprepare are function & control regulator ++ * optionally a gpio that can sleep ++ * enable - clk_enable and clk_disable are functional & control gpio ++ * rate - rate is fixed and set on clock registration ++ * parent - fixed clock is a root clock and has no parent ++ */ ++ ++/** ++ * struct clk_gated_fixed - Gateable fixed rate clock ++ * @clk_gpio: instance of clk_gpio for gate-gpio ++ * @supply: supply regulator ++ * @rate: fixed rate ++ */ ++struct clk_gated_fixed { ++ struct clk_gpio clk_gpio; ++ struct regulator *supply; ++ unsigned long rate; ++}; ++ ++#define to_clk_gated_fixed(_clk_gpio) container_of(_clk_gpio, struct clk_gated_fixed, clk_gpio) ++ ++static unsigned long clk_gated_fixed_recalc_rate(struct clk_hw *hw, ++ unsigned long parent_rate) ++{ ++ return to_clk_gated_fixed(to_clk_gpio(hw))->rate; ++} ++ ++static int clk_gated_fixed_prepare(struct clk_hw *hw) ++{ ++ struct clk_gated_fixed *clk = to_clk_gated_fixed(to_clk_gpio(hw)); ++ ++ if (!clk->supply) ++ return 0; ++ ++ return regulator_enable(clk->supply); ++} ++ ++static void clk_gated_fixed_unprepare(struct clk_hw *hw) ++{ ++ struct clk_gated_fixed *clk = to_clk_gated_fixed(to_clk_gpio(hw)); ++ ++ if (!clk->supply) ++ return; ++ ++ regulator_disable(clk->supply); ++} ++ ++static int clk_gated_fixed_is_prepared(struct clk_hw *hw) ++{ ++ struct clk_gated_fixed *clk = to_clk_gated_fixed(to_clk_gpio(hw)); ++ ++ if (!clk->supply) ++ return true; ++ ++ return regulator_is_enabled(clk->supply); ++} ++ ++/* ++ * Fixed gated clock with non-sleeping gpio. ++ * ++ * Prepare operation turns on the supply regulator ++ * and the enable operation switches the enable-gpio. ++ */ ++static const struct clk_ops clk_gated_fixed_ops = { ++ .prepare = clk_gated_fixed_prepare, ++ .unprepare = clk_gated_fixed_unprepare, ++ .is_prepared = clk_gated_fixed_is_prepared, ++ .enable = clk_gpio_gate_enable, ++ .disable = clk_gpio_gate_disable, ++ .is_enabled = clk_gpio_gate_is_enabled, ++ .recalc_rate = clk_gated_fixed_recalc_rate, ++}; ++ ++static int clk_sleeping_gated_fixed_prepare(struct clk_hw *hw) ++{ ++ int ret; ++ ++ ret = clk_gated_fixed_prepare(hw); ++ if (ret) ++ return ret; ++ ++ ret = clk_sleeping_gpio_gate_prepare(hw); ++ if (ret) ++ clk_gated_fixed_unprepare(hw); ++ ++ return ret; ++} ++ ++static void clk_sleeping_gated_fixed_unprepare(struct clk_hw *hw) ++{ ++ clk_gated_fixed_unprepare(hw); ++ clk_sleeping_gpio_gate_unprepare(hw); ++} ++ ++/* ++ * Fixed gated clock with non-sleeping gpio. ++ * ++ * Enabling the supply regulator and switching the enable-gpio happens ++ * both in the prepare step. ++ * is_prepared only needs to check the gpio state, as toggling the ++ * gpio is the last step when preparing. ++ */ ++static const struct clk_ops clk_sleeping_gated_fixed_ops = { ++ .prepare = clk_sleeping_gated_fixed_prepare, ++ .unprepare = clk_sleeping_gated_fixed_unprepare, ++ .is_prepared = clk_sleeping_gpio_gate_is_prepared, ++ .recalc_rate = clk_gated_fixed_recalc_rate, ++}; ++ ++static int clk_gated_fixed_probe(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct clk_gated_fixed *clk; ++ const struct clk_ops *ops; ++ const char *clk_name; ++ u32 rate; ++ int ret; ++ ++ clk = devm_kzalloc(dev, sizeof(*clk), GFP_KERNEL); ++ if (!clk) ++ return -ENOMEM; ++ ++ ret = device_property_read_u32(dev, "clock-frequency", &rate); ++ if (ret) ++ return dev_err_probe(dev, ret, "Failed to get clock-frequency\n"); ++ clk->rate = rate; ++ ++ ret = device_property_read_string(dev, "clock-output-names", &clk_name); ++ if (ret) ++ clk_name = fwnode_get_name(dev->fwnode); ++ ++ clk->supply = devm_regulator_get_optional(dev, "vdd"); ++ if (IS_ERR(clk->supply)) { ++ if (PTR_ERR(clk->supply) != -ENODEV) ++ return dev_err_probe(dev, PTR_ERR(clk->supply), ++ "Failed to get regulator\n"); ++ clk->supply = NULL; ++ } ++ ++ clk->clk_gpio.gpiod = devm_gpiod_get_optional(dev, "enable", ++ GPIOD_OUT_LOW); ++ if (IS_ERR(clk->clk_gpio.gpiod)) ++ return dev_err_probe(dev, PTR_ERR(clk->clk_gpio.gpiod), ++ "Failed to get gpio\n"); ++ ++ if (gpiod_cansleep(clk->clk_gpio.gpiod)) ++ ops = &clk_sleeping_gated_fixed_ops; ++ else ++ ops = &clk_gated_fixed_ops; ++ ++ clk->clk_gpio.hw.init = CLK_HW_INIT_NO_PARENT(clk_name, ops, 0); ++ ++ /* register the clock */ ++ ret = devm_clk_hw_register(dev, &clk->clk_gpio.hw); ++ if (ret) ++ return dev_err_probe(dev, ret, ++ "Failed to register clock\n"); ++ ++ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, ++ &clk->clk_gpio.hw); ++ if (ret) ++ return dev_err_probe(dev, ret, ++ "Failed to register clock provider\n"); ++ ++ return 0; ++} ++ ++static const struct of_device_id gated_fixed_clk_match_table[] = { ++ { .compatible = "gated-fixed-clock" }, ++ { /* sentinel */ } ++}; ++ ++static struct platform_driver gated_fixed_clk_driver = { ++ .probe = clk_gated_fixed_probe, ++ .driver = { ++ .name = "gated-fixed-clk", ++ .of_match_table = gated_fixed_clk_match_table, ++ }, ++}; ++builtin_platform_driver(gated_fixed_clk_driver); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/810-v6.14-gpio-regmap-Use-generic-request-free-ops.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/810-v6.14-gpio-regmap-Use-generic-request-free-ops.patch new file mode 100755 index 0000000..d696acf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/810-v6.14-gpio-regmap-Use-generic-request-free-ops.patch @@ -0,0 +1,30 @@ +From b0fa00fe38f673c986633c11087274deeb7ce7b0 Mon Sep 17 00:00:00 2001 +From: Sander Vanheule +Date: Tue, 7 Jan 2025 21:16:20 +0100 +Subject: [PATCH] gpio: regmap: Use generic request/free ops + +Set the gpiochip request and free ops to the generic implementations. +This way a user can provide a gpio-ranges property defined for a pinmux, +easing muxing of gpio functions. Provided that the pin controller +implementents the pinmux op .gpio_request_enable(), pins will +automatically be muxed to their GPIO function when requested. + +Signed-off-by: Sander Vanheule +Acked-by: Michael Walle +Link: https://lore.kernel.org/r/20250107201621.12467-1-sander@svanheule.net +Signed-off-by: Bartosz Golaszewski +--- + drivers/gpio/gpio-regmap.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/gpio/gpio-regmap.c ++++ b/drivers/gpio/gpio-regmap.c +@@ -276,6 +276,8 @@ struct gpio_regmap *gpio_regmap_register + chip->label = config->label ?: dev_name(config->parent); + chip->can_sleep = regmap_might_sleep(config->regmap); + ++ chip->request = gpiochip_generic_request; ++ chip->free = gpiochip_generic_free; + chip->get = gpio_regmap_get; + if (gpio->reg_set_base && gpio->reg_clr_base) + chip->set = gpio_regmap_set_with_clear; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/813-v6.16-pinctrl-aw9523-fix-can_sleep-flag-for-GPIO-chip.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/813-v6.16-pinctrl-aw9523-fix-can_sleep-flag-for-GPIO-chip.patch new file mode 100755 index 0000000..97b3921 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/813-v6.16-pinctrl-aw9523-fix-can_sleep-flag-for-GPIO-chip.patch @@ -0,0 +1,28 @@ +From 5285b5ed04ab6ad40f7b654eefbccd6ae8cbf415 Mon Sep 17 00:00:00 2001 +From: Milan Krstic +Date: Thu, 3 Jul 2025 14:30:39 +0000 +Subject: [PATCH] pinctrl: aw9523: fix can_sleep flag for GPIO chip + +The GPIO expander is connected via I2C, thus the can_sleep flag has to +be set to true. This fixes spurious "scheduling while atomic" bugs +in the kernel ringbuffer. + +Signed-off-by: David Bauer +Signed-off-by: Milan Krstic +Link: https://lore.kernel.org/20250703143039.5809-1-milan.krstic@gmail.com +Signed-off-by: Linus Walleij +--- + drivers/pinctrl/pinctrl-aw9523.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/pinctrl/pinctrl-aw9523.c ++++ b/drivers/pinctrl/pinctrl-aw9523.c +@@ -784,7 +784,7 @@ static int aw9523_init_gpiochip(struct a + gc->set_config = gpiochip_generic_config; + gc->parent = dev; + gc->owner = THIS_MODULE; +- gc->can_sleep = false; ++ gc->can_sleep = true; + + return 0; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/820-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/820-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch new file mode 100755 index 0000000..48f9c1c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/820-v6.15-power-supply-sysfs-remove-duplicate-nul-termination-to-fix-build-with-GCC15.patch @@ -0,0 +1,39 @@ +From 77f5bb150132bbbcd6bc37ffdc80c9e140e373a4 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Wed, 16 Apr 2025 15:27:41 -0700 +Subject: [PATCH] power: supply: sysfs: Remove duplicate NUL termination + +GCC 15's new -Wunterminated-string-initialization notices that one of +the sysfs attr strings would lack the implicit trailing NUL byte during +initialization: + +drivers/power/supply/power_supply_sysfs.c:183:57: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (32 chars into 31 available) [-Wunterminated-string-initialization] + 183 | POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD), + | ^ +drivers/power/supply/power_supply_sysfs.c:36:23: note: in definition of macro '_POWER_SUPPLY_ATTR' + 36 | .attr_name = #_name "\0", \ + | ^~~~~ +drivers/power/supply/power_supply_sysfs.c:183:9: note: in expansion of macro 'POWER_SUPPLY_ATTR' + 183 | POWER_SUPPLY_ATTR(CHARGE_CONTROL_START_THRESHOLD), + | ^~~~~~~~~~~~~~~~~ + +However, the macro used was explicitly adding a trailing NUL byte (which +is not needed). Remove this to avoid the GCC warning. No binary +differences are seen after this change (there was always run for a NUL +byte, it's just that the _second_ NUL byte was getting truncated). + +Signed-off-by: Kees Cook +Link: https://lore.kernel.org/r/20250416222740.work.569-kees@kernel.org +Signed-off-by: Sebastian Reichel + +--- a/drivers/power/supply/power_supply_sysfs.c ++++ b/drivers/power/supply/power_supply_sysfs.c +@@ -33,7 +33,7 @@ struct power_supply_attr { + [POWER_SUPPLY_PROP_ ## _name] = \ + { \ + .prop_name = #_name, \ +- .attr_name = #_name "\0", \ ++ .attr_name = #_name, \ + .text_values = _text, \ + .text_values_len = _len, \ + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-01-v7.0-dt-bindings-gpio-add-gpio-line-mux-controller.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-01-v7.0-dt-bindings-gpio-add-gpio-line-mux-controller.patch new file mode 100755 index 0000000..12e6fed --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-01-v7.0-dt-bindings-gpio-add-gpio-line-mux-controller.patch @@ -0,0 +1,128 @@ +From 2a7618ba8698874e9871a8ec5453e0068e94d9e5 Mon Sep 17 00:00:00 2001 +From: Jonas Jelonek +Date: Sat, 27 Dec 2025 18:01:33 +0000 +Subject: [PATCH] dt-bindings: gpio: add gpio-line-mux controller + +Add dt-schema for a gpio-line-mux controller which exposes virtual +GPIOs for a shared GPIO controlled by a multiplexer, e.g. a gpio-mux. + +The gpio-line-mux controller is a gpio-controller, thus has mostly the +same semantics. However, it requires a mux-control to be specified upon +which it will operate. + +Signed-off-by: Jonas Jelonek +Reviewed-by: Conor Dooley +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20251227180134.1262138-2-jelonek.jonas@gmail.com +Signed-off-by: Bartosz Golaszewski + +--- /dev/null ++++ b/Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml +@@ -0,0 +1,107 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/gpio/gpio-line-mux.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: GPIO line mux ++ ++maintainers: ++ - Jonas Jelonek ++ ++description: | ++ A GPIO controller to provide virtual GPIOs for a 1-to-many input-only mapping ++ backed by a single shared GPIO and a multiplexer. A simple illustrated ++ example is: ++ ++ +----- A ++ IN / ++ <-----o------- B ++ / |\ ++ | | +----- C ++ | | \ ++ | | +--- D ++ | | ++ M1 M0 ++ ++ MUX CONTROL ++ ++ M1 M0 IN ++ 0 0 A ++ 0 1 B ++ 1 0 C ++ 1 1 D ++ ++ This can be used in case a real GPIO is connected to multiple inputs and ++ controlled by a multiplexer, and another subsystem/driver does not work ++ directly with the multiplexer subsystem. ++ ++properties: ++ compatible: ++ const: gpio-line-mux ++ ++ gpio-controller: true ++ ++ "#gpio-cells": ++ const: 2 ++ ++ gpio-line-mux-states: ++ description: Mux states corresponding to the virtual GPIOs. ++ $ref: /schemas/types.yaml#/definitions/uint32-array ++ ++ gpio-line-names: true ++ ++ mux-controls: ++ maxItems: 1 ++ description: ++ Phandle to the multiplexer to control access to the GPIOs. ++ ++ ngpios: false ++ ++ muxed-gpios: ++ maxItems: 1 ++ description: ++ GPIO which is the '1' in 1-to-many and is shared by the virtual GPIOs ++ and controlled via the mux. ++ ++required: ++ - compatible ++ - gpio-controller ++ - gpio-line-mux-states ++ - mux-controls ++ - muxed-gpios ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ #include ++ ++ sfp_gpio_mux: mux-controller-1 { ++ compatible = "gpio-mux"; ++ mux-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>, ++ <&gpio0 1 GPIO_ACTIVE_HIGH>; ++ #mux-control-cells = <0>; ++ idle-state = ; ++ }; ++ ++ sfp1_gpio: sfp-gpio-1 { ++ compatible = "gpio-line-mux"; ++ gpio-controller; ++ #gpio-cells = <2>; ++ ++ mux-controls = <&sfp_gpio_mux>; ++ muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; ++ ++ gpio-line-mux-states = <0>, <1>, <3>; ++ }; ++ ++ sfp1: sfp-p1 { ++ compatible = "sff,sfp"; ++ ++ i2c-bus = <&sfp1_i2c>; ++ los-gpios = <&sfp1_gpio 0 GPIO_ACTIVE_HIGH>; ++ mod-def0-gpios = <&sfp1_gpio 1 GPIO_ACTIVE_LOW>; ++ tx-fault-gpios = <&sfp1_gpio 2 GPIO_ACTIVE_HIGH>; ++ }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-02-v7.0-gpio-add-gpio-line-mux-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-02-v7.0-gpio-add-gpio-line-mux-driver.patch new file mode 100755 index 0000000..3569615 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-02-v7.0-gpio-add-gpio-line-mux-driver.patch @@ -0,0 +1,209 @@ +From 2b03d9a40cd1fea42fd65d2b66df80edc0f374c8 Mon Sep 17 00:00:00 2001 +From: Jonas Jelonek +Date: Sat, 27 Dec 2025 18:01:34 +0000 +Subject: [PATCH] gpio: add gpio-line-mux driver + +Add a new driver which provides a 1-to-many mapping for a single real +GPIO using a multiplexer. Each virtual GPIO corresponds to a multiplexer +state which, if set for the multiplexer, connects the real GPIO to the +corresponding virtual GPIO. + +This can help in various usecases. One practical case is the special +hardware design of the Realtek-based XS1930-10 switch from Zyxel. It +features two SFP+ ports/cages whose signals are wired directly to the +switch SoC. Although Realtek SoCs are short on GPIOs, there are usually +enough the fit the SFP signals without any hacks. + +However, Zyxel did some weird design and connected RX_LOS, MOD_ABS and +TX_FAULT of one SFP cage onto a single GPIO line controlled by a +multiplexer (the same for the other SFP cage). The single multiplexer +controls the lines for both SFP and depending on the state, the +designated 'signal GPIO lines' are connected to one of the three SFP +signals. + +Because the SFP core/driver doesn't support multiplexer but needs single +GPIOs for each of the signals, this driver fills the gap between both. +It registers a gpio_chip, provides multiple virtual GPIOs and sets the +backing multiplexer accordingly. + +Due to several practical issues, this is input-only and doesn't support +IRQs. + +Signed-off-by: Jonas Jelonek +Reviewed-by: Thomas Richard +Reviewed-by: Linus Walleij +Link: https://lore.kernel.org/r/20251227180134.1262138-3-jelonek.jonas@gmail.com +Signed-off-by: Bartosz Golaszewski + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -9704,6 +9704,12 @@ S: Maintained + F: Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.yaml + F: drivers/media/rc/gpio-ir-tx.c + ++GPIO LINE MUX ++M: Jonas Jelonek ++S: Maintained ++F: Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml ++F: drivers/gpio/gpio-line-mux.c ++ + GPIO MOCKUP DRIVER + M: Bamvor Jian Zhang + L: linux-gpio@vger.kernel.org +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -1866,6 +1866,15 @@ config GPIO_LATCH + Say yes here to enable a driver for GPIO multiplexers based on latches + connected to other GPIOs. + ++config GPIO_LINE_MUX ++ tristate "GPIO line mux driver" ++ depends on OF_GPIO ++ select MULTIPLEXER ++ help ++ Say Y here to support the GPIO line mux, which can provide virtual ++ GPIOs backed by a shared real GPIO and a multiplexer in a 1-to-many ++ fashion. ++ + config GPIO_MOCKUP + tristate "GPIO Testing Driver (DEPRECATED)" + select IRQ_SIM +--- a/drivers/gpio/Makefile ++++ b/drivers/gpio/Makefile +@@ -84,6 +84,7 @@ obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4x + obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o + obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o + obj-$(CONFIG_GPIO_LATCH) += gpio-latch.o ++obj-$(CONFIG_GPIO_LINE_MUX) += gpio-line-mux.o + obj-$(CONFIG_GPIO_LJCA) += gpio-ljca.o + obj-$(CONFIG_GPIO_LOGICVC) += gpio-logicvc.o + obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o +--- /dev/null ++++ b/drivers/gpio/gpio-line-mux.c +@@ -0,0 +1,126 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * GPIO line mux which acts as virtual gpiochip and provides a 1-to-many ++ * mapping between virtual GPIOs and a real GPIO + multiplexer. ++ * ++ * Copyright (c) 2025 Jonas Jelonek ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MUX_SELECT_DELAY_US 100 ++ ++struct gpio_lmux { ++ struct gpio_chip gc; ++ struct mux_control *mux; ++ struct gpio_desc *muxed_gpio; ++ ++ u32 num_gpio_mux_states; ++ unsigned int gpio_mux_states[] __counted_by(num_gpio_mux_states); ++}; ++ ++static int gpio_lmux_gpio_get(struct gpio_chip *gc, unsigned int offset) ++{ ++ struct gpio_lmux *glm = gpiochip_get_data(gc); ++ int ret; ++ ++ if (offset > gc->ngpio) ++ return -EINVAL; ++ ++ ret = mux_control_select_delay(glm->mux, glm->gpio_mux_states[offset], ++ MUX_SELECT_DELAY_US); ++ if (ret < 0) ++ return ret; ++ ++ ret = gpiod_get_raw_value_cansleep(glm->muxed_gpio); ++ mux_control_deselect(glm->mux); ++ return ret; ++} ++ ++static int gpio_lmux_gpio_set(struct gpio_chip *gc, unsigned int offset, ++ int value) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static int gpio_lmux_gpio_get_direction(struct gpio_chip *gc, ++ unsigned int offset) ++{ ++ return GPIO_LINE_DIRECTION_IN; ++} ++ ++static int gpio_lmux_probe(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct gpio_lmux *glm; ++ unsigned int ngpio; ++ size_t size; ++ int ret; ++ ++ ngpio = device_property_count_u32(dev, "gpio-line-mux-states"); ++ if (!ngpio) ++ return -EINVAL; ++ ++ size = struct_size(glm, gpio_mux_states, ngpio); ++ glm = devm_kzalloc(dev, size, GFP_KERNEL); ++ if (!glm) ++ return -ENOMEM; ++ ++ glm->gc.base = -1; ++ glm->gc.can_sleep = true; ++ glm->gc.fwnode = dev_fwnode(dev); ++ glm->gc.label = dev_name(dev); ++ glm->gc.ngpio = ngpio; ++ glm->gc.owner = THIS_MODULE; ++ glm->gc.parent = dev; ++ ++ glm->gc.get = gpio_lmux_gpio_get; ++ glm->gc.set = gpio_lmux_gpio_set; ++ glm->gc.get_direction = gpio_lmux_gpio_get_direction; ++ ++ glm->mux = devm_mux_control_get(dev, NULL); ++ if (IS_ERR(glm->mux)) ++ return dev_err_probe(dev, PTR_ERR(glm->mux), ++ "could not get mux controller\n"); ++ ++ glm->muxed_gpio = devm_gpiod_get(dev, "muxed", GPIOD_IN); ++ if (IS_ERR(glm->muxed_gpio)) ++ return dev_err_probe(dev, PTR_ERR(glm->muxed_gpio), ++ "could not get muxed-gpio\n"); ++ ++ glm->num_gpio_mux_states = ngpio; ++ ret = device_property_read_u32_array(dev, "gpio-line-mux-states", ++ &glm->gpio_mux_states[0], ngpio); ++ if (ret) ++ return dev_err_probe(dev, ret, "could not get mux states\n"); ++ ++ ret = devm_gpiochip_add_data(dev, &glm->gc, glm); ++ if (ret) ++ return dev_err_probe(dev, ret, "failed to add gpiochip\n"); ++ ++ return 0; ++} ++ ++static const struct of_device_id gpio_lmux_of_match[] = { ++ { .compatible = "gpio-line-mux" }, ++ { } ++}; ++MODULE_DEVICE_TABLE(of, gpio_lmux_of_match); ++ ++static struct platform_driver gpio_lmux_driver = { ++ .driver = { ++ .name = "gpio-line-mux", ++ .of_match_table = gpio_lmux_of_match, ++ }, ++ .probe = gpio_lmux_probe, ++}; ++module_platform_driver(gpio_lmux_driver); ++ ++MODULE_AUTHOR("Jonas Jelonek "); ++MODULE_DESCRIPTION("GPIO line mux driver"); ++MODULE_LICENSE("GPL"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-03-v7.0-gpio-line-mux-remove-bits-already-handled-by-GPIO-co.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-03-v7.0-gpio-line-mux-remove-bits-already-handled-by-GPIO-co.patch new file mode 100755 index 0000000..717421e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/821-03-v7.0-gpio-line-mux-remove-bits-already-handled-by-GPIO-co.patch @@ -0,0 +1,52 @@ +From e034e058897a12bc856f8b22d1796964c742f732 Mon Sep 17 00:00:00 2001 +From: Bartosz Golaszewski +Date: Wed, 7 Jan 2026 09:58:33 +0100 +Subject: [PATCH] gpio: line-mux: remove bits already handled by GPIO core + +GPIO core already handles checking the offset against the number of +GPIOs as well as missing any of the GPIO chip callbacks. Remove the +unnecessary bits. + +Also, the offset check was off-by-one as reported by Dan. + +Fixes: 2b03d9a40cd1 ("gpio: add gpio-line-mux driver") +Reported-by: Dan Carpenter +Closes: https://lore.kernel.org/all/aV4b6GAGz1zyf8Xy@stanley.mountain/ +Tested-by: Jonas Jelonek +Reviewed-by: Jonas Jelonek +Link: https://lore.kernel.org/r/20260107085833.17338-1-bartosz.golaszewski@oss.qualcomm.com +Signed-off-by: Bartosz Golaszewski + +--- a/drivers/gpio/gpio-line-mux.c ++++ b/drivers/gpio/gpio-line-mux.c +@@ -29,9 +29,6 @@ static int gpio_lmux_gpio_get(struct gpi + struct gpio_lmux *glm = gpiochip_get_data(gc); + int ret; + +- if (offset > gc->ngpio) +- return -EINVAL; +- + ret = mux_control_select_delay(glm->mux, glm->gpio_mux_states[offset], + MUX_SELECT_DELAY_US); + if (ret < 0) +@@ -42,12 +39,6 @@ static int gpio_lmux_gpio_get(struct gpi + return ret; + } + +-static int gpio_lmux_gpio_set(struct gpio_chip *gc, unsigned int offset, +- int value) +-{ +- return -EOPNOTSUPP; +-} +- + static int gpio_lmux_gpio_get_direction(struct gpio_chip *gc, + unsigned int offset) + { +@@ -80,7 +71,6 @@ static int gpio_lmux_probe(struct platfo + glm->gc.parent = dev; + + glm->gc.get = gpio_lmux_gpio_get; +- glm->gc.set = gpio_lmux_gpio_set; + glm->gc.get_direction = gpio_lmux_gpio_get_direction; + + glm->mux = devm_mux_control_get(dev, NULL); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/891-v6.14-dt-bindings-leds-Add-LED1202-LED-Controller.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/891-v6.14-dt-bindings-leds-Add-LED1202-LED-Controller.patch new file mode 100755 index 0000000..9901d13 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/891-v6.14-dt-bindings-leds-Add-LED1202-LED-Controller.patch @@ -0,0 +1,160 @@ +From 599b92fd0efa8b7c43e7f58c9dd0f7951f7cbf09 Mon Sep 17 00:00:00 2001 +From: Vicentiu Galanopulo +Date: Wed, 18 Dec 2024 18:33:58 +0000 +Subject: dt-bindings: leds: Add LED1202 LED Controller + +The LED1202 is a 12-channel low quiescent current LED driver with: + * Supply range from 2.6 V to 5 V + * 20 mA current capability per channel + * 1.8 V compatible I2C control interface + * 8-bit analog dimming individual control + * 12-bit local PWM resolution + * 8 programmable patterns + +If the led node is present in the controller then the channel is +set to active. + +Signed-off-by: Vicentiu Galanopulo +Reviewed-by: Krzysztof Kozlowski +Link: https://lore.kernel.org/r/20241218183401.41687-3-vicentiu.galanopulo@remote-tech.co.uk +Signed-off-by: Lee Jones +--- + .../devicetree/bindings/leds/st,led1202.yaml | 132 ++++++++++++++++++ + 1 file changed, 132 insertions(+) + create mode 100644 Documentation/devicetree/bindings/leds/st,led1202.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/leds/st,led1202.yaml +@@ -0,0 +1,132 @@ ++# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/leds/st,led1202.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: ST LED1202 LED controllers ++ ++maintainers: ++ - Vicentiu Galanopulo ++ ++description: | ++ The LED1202 is a 12-channel low quiescent current LED controller ++ programmable via I2C; The output current can be adjusted separately ++ for each channel by 8-bit analog and 12-bit digital dimming control. ++ Datasheet available at ++ https://www.st.com/en/power-management/led1202.html ++ ++properties: ++ compatible: ++ const: st,led1202 ++ ++ reg: ++ maxItems: 1 ++ ++ "#address-cells": ++ const: 1 ++ ++ "#size-cells": ++ const: 0 ++ ++patternProperties: ++ "^led@[0-9a-f]$": ++ type: object ++ $ref: common.yaml# ++ unevaluatedProperties: false ++ ++ properties: ++ reg: ++ minimum: 0 ++ maximum: 11 ++ ++ required: ++ - reg ++ ++required: ++ - compatible ++ - reg ++ - "#address-cells" ++ - "#size-cells" ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ ++ i2c { ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ led-controller@58 { ++ compatible = "st,led1202"; ++ reg = <0x58>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ led@0 { ++ reg = <0x0>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <1>; ++ }; ++ ++ led@1 { ++ reg = <0x1>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <2>; ++ }; ++ ++ led@2 { ++ reg = <0x2>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <3>; ++ }; ++ ++ led@3 { ++ reg = <0x3>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <4>; ++ }; ++ ++ led@4 { ++ reg = <0x4>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <5>; ++ }; ++ ++ led@5 { ++ reg = <0x5>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <6>; ++ }; ++ ++ led@6 { ++ reg = <0x6>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <7>; ++ }; ++ ++ led@7 { ++ reg = <0x7>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <8>; ++ }; ++ ++ led@8 { ++ reg = <0x8>; ++ function = LED_FUNCTION_STATUS; ++ color = ; ++ function-enumerator = <9>; ++ }; ++ }; ++ }; ++... diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/892-v6.14-leds-Add-LED1202-I2C-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/892-v6.14-leds-Add-LED1202-I2C-driver.patch new file mode 100755 index 0000000..ee2ea07 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/892-v6.14-leds-Add-LED1202-I2C-driver.patch @@ -0,0 +1,475 @@ +From 939757aafeb9c266dda37657ee5f7a73ffd35ae2 Mon Sep 17 00:00:00 2001 +From: Vicentiu Galanopulo +Date: Wed, 18 Dec 2024 18:33:59 +0000 +Subject: leds: Add LED1202 I2C driver + +The output current can be adjusted separately for each channel by 8-bit +analog (current sink input) and 12-bit digital (PWM) dimming control. The +LED1202 implements 12 low-side current generators with independent dimming +control. +Internal volatile memory allows the user to store up to 8 different patterns, +each pattern is a particular output configuration in terms of PWM +duty-cycle (on 4096 steps). Analog dimming (on 256 steps) is per channel but +common to all patterns. Each device tree LED node will have a corresponding +entry in /sys/class/leds with the label name. The brightness property +corresponds to the per channel analog dimming, while the patterns[1-8] to the +PWM dimming control. + +Signed-off-by: Vicentiu Galanopulo +Link: https://lore.kernel.org/r/20241218183401.41687-4-vicentiu.galanopulo@remote-tech.co.uk +Signed-off-by: Lee Jones +--- + drivers/leds/Kconfig | 10 + + drivers/leds/Makefile | 1 + + drivers/leds/leds-st1202.c | 416 +++++++++++++++++++++++++++++++++++++ + 3 files changed, 427 insertions(+) + create mode 100644 drivers/leds/leds-st1202.c + +--- a/drivers/leds/Kconfig ++++ b/drivers/leds/Kconfig +@@ -931,6 +931,16 @@ config LEDS_LM36274 + Say Y to enable the LM36274 LED driver for TI LMU devices. + This supports the LED device LM36274. + ++config LEDS_ST1202 ++ tristate "LED Support for STMicroelectronics LED1202 I2C chips" ++ depends on LEDS_CLASS ++ depends on I2C ++ depends on OF ++ select LEDS_TRIGGERS ++ help ++ Say Y to enable support for LEDs connected to LED1202 ++ LED driver chips accessed via the I2C bus. ++ + config LEDS_TPS6105X + tristate "LED support for TI TPS6105X" + depends on LEDS_CLASS +--- a/drivers/leds/Makefile ++++ b/drivers/leds/Makefile +@@ -81,6 +81,7 @@ obj-$(CONFIG_LEDS_POWERNV) += leds-powe + obj-$(CONFIG_LEDS_PWM) += leds-pwm.o + obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o + obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o ++obj-$(CONFIG_LEDS_ST1202) += leds-st1202.o + obj-$(CONFIG_LEDS_SUN50I_A100) += leds-sun50i-a100.o + obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o + obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o +--- /dev/null ++++ b/drivers/leds/leds-st1202.c +@@ -0,0 +1,416 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * LED driver for STMicroelectronics LED1202 chip ++ * ++ * Copyright (C) 2024 Remote-Tech Ltd. UK ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define ST1202_CHAN_DISABLE_ALL 0x00 ++#define ST1202_CHAN_ENABLE_HIGH 0x03 ++#define ST1202_CHAN_ENABLE_LOW 0x02 ++#define ST1202_CONFIG_REG 0x04 ++/* PATS: Pattern sequence feature enable */ ++#define ST1202_CONFIG_REG_PATS BIT(7) ++/* PATSR: Pattern sequence runs (self-clear when sequence is finished) */ ++#define ST1202_CONFIG_REG_PATSR BIT(6) ++#define ST1202_CONFIG_REG_SHFT BIT(3) ++#define ST1202_DEV_ENABLE 0x01 ++#define ST1202_DEV_ENABLE_ON BIT(0) ++#define ST1202_DEV_ENABLE_RESET BIT(7) ++#define ST1202_DEVICE_ID 0x00 ++#define ST1202_ILED_REG0 0x09 ++#define ST1202_MAX_LEDS 12 ++#define ST1202_MAX_PATTERNS 8 ++#define ST1202_MILLIS_PATTERN_DUR_MAX 5660 ++#define ST1202_MILLIS_PATTERN_DUR_MIN 22 ++#define ST1202_PATTERN_DUR 0x16 ++#define ST1202_PATTERN_PWM 0x1E ++#define ST1202_PATTERN_REP 0x15 ++ ++struct st1202_led { ++ struct fwnode_handle *fwnode; ++ struct led_classdev led_cdev; ++ struct st1202_chip *chip; ++ bool is_active; ++ int led_num; ++}; ++ ++struct st1202_chip { ++ struct i2c_client *client; ++ struct mutex lock; ++ struct st1202_led leds[ST1202_MAX_LEDS]; ++}; ++ ++static struct st1202_led *cdev_to_st1202_led(struct led_classdev *cdev) ++{ ++ return container_of(cdev, struct st1202_led, led_cdev); ++} ++ ++static int st1202_read_reg(struct st1202_chip *chip, int reg, uint8_t *val) ++{ ++ struct device *dev = &chip->client->dev; ++ int ret; ++ ++ ret = i2c_smbus_read_byte_data(chip->client, reg); ++ if (ret < 0) { ++ dev_err(dev, "Failed to read register [0x%x]: %d\n", reg, ret); ++ return ret; ++ } ++ ++ *val = (uint8_t)ret; ++ return 0; ++} ++ ++static int st1202_write_reg(struct st1202_chip *chip, int reg, uint8_t val) ++{ ++ struct device *dev = &chip->client->dev; ++ int ret; ++ ++ ret = i2c_smbus_write_byte_data(chip->client, reg, val); ++ if (ret != 0) ++ dev_err(dev, "Failed to write %d to register [0x%x]: %d\n", val, reg, ret); ++ ++ return ret; ++} ++ ++static uint8_t st1202_prescalar_to_miliseconds(unsigned int value) ++{ ++ return value / ST1202_MILLIS_PATTERN_DUR_MIN - 1; ++} ++ ++static int st1202_pwm_pattern_write(struct st1202_chip *chip, int led_num, ++ int pattern, unsigned int value) ++{ ++ u8 value_l, value_h; ++ int ret; ++ ++ value_l = (u8)value; ++ value_h = (u8)(value >> 8); ++ ++ /* ++ * Datasheet: Register address low = 1Eh + 2*(xh) + 18h*(yh), ++ * where x is the channel number (led number) in hexadecimal (x = 00h .. 0Bh) ++ * and y is the pattern number in hexadecimal (y = 00h .. 07h) ++ */ ++ ret = st1202_write_reg(chip, (ST1202_PATTERN_PWM + (led_num * 2) + 0x18 * pattern), ++ value_l); ++ if (ret != 0) ++ return ret; ++ ++ /* ++ * Datasheet: Register address high = 1Eh + 01h + 2(xh) +18h*(yh), ++ * where x is the channel number in hexadecimal (x = 00h .. 0Bh) ++ * and y is the pattern number in hexadecimal (y = 00h .. 07h) ++ */ ++ ret = st1202_write_reg(chip, (ST1202_PATTERN_PWM + 0x1 + (led_num * 2) + 0x18 * pattern), ++ value_h); ++ if (ret != 0) ++ return ret; ++ ++ return 0; ++} ++ ++static int st1202_duration_pattern_write(struct st1202_chip *chip, int pattern, ++ unsigned int value) ++{ ++ return st1202_write_reg(chip, (ST1202_PATTERN_DUR + pattern), ++ st1202_prescalar_to_miliseconds(value)); ++} ++ ++static void st1202_brightness_set(struct led_classdev *led_cdev, ++ enum led_brightness value) ++{ ++ struct st1202_led *led = cdev_to_st1202_led(led_cdev); ++ struct st1202_chip *chip = led->chip; ++ ++ guard(mutex)(&chip->lock); ++ ++ st1202_write_reg(chip, ST1202_ILED_REG0 + led->led_num, value); ++} ++ ++static enum led_brightness st1202_brightness_get(struct led_classdev *led_cdev) ++{ ++ struct st1202_led *led = cdev_to_st1202_led(led_cdev); ++ struct st1202_chip *chip = led->chip; ++ u8 value = 0; ++ ++ guard(mutex)(&chip->lock); ++ ++ st1202_read_reg(chip, ST1202_ILED_REG0 + led->led_num, &value); ++ ++ return value; ++} ++ ++static int st1202_channel_set(struct st1202_chip *chip, int led_num, bool active) ++{ ++ u8 chan_low, chan_high; ++ int ret; ++ ++ guard(mutex)(&chip->lock); ++ ++ if (led_num <= 7) { ++ ret = st1202_read_reg(chip, ST1202_CHAN_ENABLE_LOW, &chan_low); ++ if (ret < 0) ++ return ret; ++ ++ chan_low = active ? chan_low | BIT(led_num) : chan_low & ~BIT(led_num); ++ ++ ret = st1202_write_reg(chip, ST1202_CHAN_ENABLE_LOW, chan_low); ++ if (ret < 0) ++ return ret; ++ ++ } else { ++ ret = st1202_read_reg(chip, ST1202_CHAN_ENABLE_HIGH, &chan_high); ++ if (ret < 0) ++ return ret; ++ ++ chan_high = active ? chan_high | (BIT(led_num) >> 8) : ++ chan_high & ~(BIT(led_num) >> 8); ++ ++ ret = st1202_write_reg(chip, ST1202_CHAN_ENABLE_HIGH, chan_high); ++ if (ret < 0) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int st1202_led_set(struct led_classdev *ldev, enum led_brightness value) ++{ ++ struct st1202_led *led = cdev_to_st1202_led(ldev); ++ struct st1202_chip *chip = led->chip; ++ ++ return st1202_channel_set(chip, led->led_num, value == LED_OFF ? false : true); ++} ++ ++static int st1202_led_pattern_clear(struct led_classdev *ldev) ++{ ++ struct st1202_led *led = cdev_to_st1202_led(ldev); ++ struct st1202_chip *chip = led->chip; ++ int ret; ++ ++ guard(mutex)(&chip->lock); ++ ++ for (int patt = 0; patt < ST1202_MAX_PATTERNS; patt++) { ++ ret = st1202_pwm_pattern_write(chip, led->led_num, patt, LED_OFF); ++ if (ret != 0) ++ return ret; ++ ++ ret = st1202_duration_pattern_write(chip, patt, ST1202_MILLIS_PATTERN_DUR_MIN); ++ if (ret != 0) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int st1202_led_pattern_set(struct led_classdev *ldev, ++ struct led_pattern *pattern, ++ u32 len, int repeat) ++{ ++ struct st1202_led *led = cdev_to_st1202_led(ldev); ++ struct st1202_chip *chip = led->chip; ++ int ret; ++ ++ if (len > ST1202_MAX_PATTERNS) ++ return -EINVAL; ++ ++ guard(mutex)(&chip->lock); ++ ++ for (int patt = 0; patt < len; patt++) { ++ if (pattern[patt].delta_t < ST1202_MILLIS_PATTERN_DUR_MIN || ++ pattern[patt].delta_t > ST1202_MILLIS_PATTERN_DUR_MAX) ++ return -EINVAL; ++ ++ ret = st1202_pwm_pattern_write(chip, led->led_num, patt, pattern[patt].brightness); ++ if (ret != 0) ++ return ret; ++ ++ ret = st1202_duration_pattern_write(chip, patt, pattern[patt].delta_t); ++ if (ret != 0) ++ return ret; ++ } ++ ++ ret = st1202_write_reg(chip, ST1202_PATTERN_REP, repeat); ++ if (ret != 0) ++ return ret; ++ ++ ret = st1202_write_reg(chip, ST1202_CONFIG_REG, (ST1202_CONFIG_REG_PATSR | ++ ST1202_CONFIG_REG_PATS | ST1202_CONFIG_REG_SHFT)); ++ if (ret != 0) ++ return ret; ++ ++ return 0; ++} ++ ++static int st1202_dt_init(struct st1202_chip *chip) ++{ ++ struct device *dev = &chip->client->dev; ++ struct st1202_led *led; ++ int err, reg; ++ ++ for_each_available_child_of_node_scoped(dev_of_node(dev), child) { ++ struct led_init_data init_data = {}; ++ ++ err = of_property_read_u32(child, "reg", ®); ++ if (err) ++ return dev_err_probe(dev, err, "Invalid register\n"); ++ ++ led = &chip->leds[reg]; ++ led->is_active = true; ++ led->fwnode = of_fwnode_handle(child); ++ ++ led->led_cdev.max_brightness = U8_MAX; ++ led->led_cdev.brightness_set_blocking = st1202_led_set; ++ led->led_cdev.pattern_set = st1202_led_pattern_set; ++ led->led_cdev.pattern_clear = st1202_led_pattern_clear; ++ led->led_cdev.default_trigger = "pattern"; ++ ++ init_data.fwnode = led->fwnode; ++ init_data.devicename = "st1202"; ++ init_data.default_label = ":"; ++ ++ err = devm_led_classdev_register_ext(dev, &led->led_cdev, &init_data); ++ if (err < 0) ++ return dev_err_probe(dev, err, "Failed to register LED class device\n"); ++ ++ led->led_cdev.brightness_set = st1202_brightness_set; ++ led->led_cdev.brightness_get = st1202_brightness_get; ++ } ++ ++ return 0; ++} ++ ++static int st1202_setup(struct st1202_chip *chip) ++{ ++ int ret; ++ ++ guard(mutex)(&chip->lock); ++ ++ /* ++ * Once the supply voltage is applied, the LED1202 executes some internal checks, ++ * afterwords it stops the oscillator and puts the internal LDO in quiescent mode. ++ * To start the device, EN bit must be set inside the β€œDevice Enable” register at ++ * address 01h. As soon as EN is set, the LED1202 loads the adjustment parameters ++ * from the internal non-volatile memory and performs an auto-calibration procedure ++ * in order to increase the output current precision. ++ * Such initialization lasts about 6.5 ms. ++ */ ++ ++ /* Reset the chip during setup */ ++ ret = st1202_write_reg(chip, ST1202_DEV_ENABLE, ST1202_DEV_ENABLE_RESET); ++ if (ret < 0) ++ return ret; ++ ++ /* Enable phase-shift delay feature */ ++ ret = st1202_write_reg(chip, ST1202_CONFIG_REG, ST1202_CONFIG_REG_SHFT); ++ if (ret < 0) ++ return ret; ++ ++ /* Enable the device */ ++ ret = st1202_write_reg(chip, ST1202_DEV_ENABLE, ST1202_DEV_ENABLE_ON); ++ if (ret < 0) ++ return ret; ++ ++ /* Duration of initialization */ ++ usleep_range(6500, 10000); ++ ++ /* Deactivate all LEDS (channels) and activate only the ones found in Device Tree */ ++ ret = st1202_write_reg(chip, ST1202_CHAN_ENABLE_LOW, ST1202_CHAN_DISABLE_ALL); ++ if (ret < 0) ++ return ret; ++ ++ ret = st1202_write_reg(chip, ST1202_CHAN_ENABLE_HIGH, ST1202_CHAN_DISABLE_ALL); ++ if (ret < 0) ++ return ret; ++ ++ ret = st1202_write_reg(chip, ST1202_CONFIG_REG, ++ ST1202_CONFIG_REG_PATS | ST1202_CONFIG_REG_PATSR); ++ if (ret < 0) ++ return ret; ++ ++ return 0; ++} ++ ++static int st1202_probe(struct i2c_client *client) ++{ ++ struct st1202_chip *chip; ++ struct st1202_led *led; ++ int ret; ++ ++ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) ++ return dev_err_probe(&client->dev, -EIO, "SMBUS Byte Data not Supported\n"); ++ ++ chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); ++ if (!chip) ++ return -ENOMEM; ++ ++ devm_mutex_init(&client->dev, &chip->lock); ++ chip->client = client; ++ ++ ret = st1202_dt_init(chip); ++ if (ret < 0) ++ return ret; ++ ++ ret = st1202_setup(chip); ++ if (ret < 0) ++ return ret; ++ ++ for (int i = 0; i < ST1202_MAX_LEDS; i++) { ++ led = &chip->leds[i]; ++ led->chip = chip; ++ led->led_num = i; ++ ++ if (!led->is_active) ++ continue; ++ ++ ret = st1202_channel_set(led->chip, led->led_num, true); ++ if (ret < 0) ++ return dev_err_probe(&client->dev, ret, ++ "Failed to activate LED channel\n"); ++ ++ ret = st1202_led_pattern_clear(&led->led_cdev); ++ if (ret < 0) ++ return dev_err_probe(&client->dev, ret, ++ "Failed to clear LED pattern\n"); ++ } ++ ++ return 0; ++} ++ ++static const struct i2c_device_id st1202_id[] = { ++ { "st1202-i2c" }, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(i2c, st1202_id); ++ ++static const struct of_device_id st1202_dt_ids[] = { ++ { .compatible = "st,led1202" }, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, st1202_dt_ids); ++ ++static struct i2c_driver st1202_driver = { ++ .driver = { ++ .name = "leds-st1202", ++ .of_match_table = of_match_ptr(st1202_dt_ids), ++ }, ++ .probe = st1202_probe, ++ .id_table = st1202_id, ++}; ++module_i2c_driver(st1202_driver); ++ ++MODULE_AUTHOR("Remote Tech LTD"); ++MODULE_DESCRIPTION("STMicroelectronics LED1202 : 12-channel constant current LED driver"); ++MODULE_LICENSE("GPL"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/893-v6.14-leds_st1202-Fix-NULL-pointer-access-error.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/893-v6.14-leds_st1202-Fix-NULL-pointer-access-error.patch new file mode 100755 index 0000000..39d8ddb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/893-v6.14-leds_st1202-Fix-NULL-pointer-access-error.patch @@ -0,0 +1,73 @@ +From c72e455b89f216b43cd0dbb518036ec4c98f5c46 Mon Sep 17 00:00:00 2001 +From: Manuel Fombuena +Date: Tue, 25 Feb 2025 22:01:02 +0000 +Subject: leds: leds-st1202: Fix NULL pointer access on race condition + +st1202_dt_init() calls devm_led_classdev_register_ext() before the +internal data structures are properly set up, so the LEDs become visible +to user space while being partially initialized, leading to a window +where trying to access them causes a NULL pointer access. + +Move devm_led_classdev_register_ext() from DT initialization +to the end of the probe function when DT and hardware are fully +initialized and ready to interact with user space. + +Fixes: 259230378c65 ("leds: Add LED1202 I2C driver") +Signed-off-by: Manuel Fombuena +Link: https://lore.kernel.org/r/CWLP123MB54732771AC0CE5491B3C84DCC5C32@CWLP123MB5473.GBRP123.PROD.OUTLOOK.COM +Signed-off-by: Lee Jones +--- + drivers/leds/leds-st1202.c | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +--- a/drivers/leds/leds-st1202.c ++++ b/drivers/leds/leds-st1202.c +@@ -261,8 +261,6 @@ static int st1202_dt_init(struct st1202_ + int err, reg; + + for_each_available_child_of_node_scoped(dev_of_node(dev), child) { +- struct led_init_data init_data = {}; +- + err = of_property_read_u32(child, "reg", ®); + if (err) + return dev_err_probe(dev, err, "Invalid register\n"); +@@ -276,15 +274,6 @@ static int st1202_dt_init(struct st1202_ + led->led_cdev.pattern_set = st1202_led_pattern_set; + led->led_cdev.pattern_clear = st1202_led_pattern_clear; + led->led_cdev.default_trigger = "pattern"; +- +- init_data.fwnode = led->fwnode; +- init_data.devicename = "st1202"; +- init_data.default_label = ":"; +- +- err = devm_led_classdev_register_ext(dev, &led->led_cdev, &init_data); +- if (err < 0) +- return dev_err_probe(dev, err, "Failed to register LED class device\n"); +- + led->led_cdev.brightness_set = st1202_brightness_set; + led->led_cdev.brightness_get = st1202_brightness_get; + } +@@ -368,6 +357,7 @@ static int st1202_probe(struct i2c_clien + return ret; + + for (int i = 0; i < ST1202_MAX_LEDS; i++) { ++ struct led_init_data init_data = {}; + led = &chip->leds[i]; + led->chip = chip; + led->led_num = i; +@@ -384,6 +374,15 @@ static int st1202_probe(struct i2c_clien + if (ret < 0) + return dev_err_probe(&client->dev, ret, + "Failed to clear LED pattern\n"); ++ ++ init_data.fwnode = led->fwnode; ++ init_data.devicename = "st1202"; ++ init_data.default_label = ":"; ++ ++ ret = devm_led_classdev_register_ext(&client->dev, &led->led_cdev, &init_data); ++ if (ret < 0) ++ return dev_err_probe(&client->dev, ret, ++ "Failed to register LED class device\n"); + } + + return 0; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/900-v6.14-driver-core-add-a-faux-bus-for-use-when-a-simple-dev.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/900-v6.14-driver-core-add-a-faux-bus-for-use-when-a-simple-dev.patch new file mode 100755 index 0000000..1ada8a6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/900-v6.14-driver-core-add-a-faux-bus-for-use-when-a-simple-dev.patch @@ -0,0 +1,386 @@ +From 35fa2d88ca9481e5caf533d58b99ca259c63b2fe Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Mon, 10 Feb 2025 13:30:25 +0100 +Subject: [PATCH] driver core: add a faux bus for use when a simple device/bus + is needed +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Many drivers abuse the platform driver/bus system as it provides a +simple way to create and bind a device to a driver-specific set of +probe/release functions. Instead of doing that, and wasting all of the +memory associated with a platform device, here is a "faux" bus that +can be used instead. + +Reviewed-by: Jonathan Cameron +Reviewed-by: Danilo Krummrich +Reviewed-by: Lyude Paul +Reviewed-by: Thomas Weißschuh +Reviewed-by: Zijun Hu +Link: https://lore.kernel.org/r/2025021026-atlantic-gibberish-3f0c@gregkh +Signed-off-by: Greg Kroah-Hartman +--- + Documentation/driver-api/infrastructure.rst | 6 + + drivers/base/Makefile | 2 +- + drivers/base/base.h | 1 + + drivers/base/faux.c | 232 ++++++++++++++++++++ + drivers/base/init.c | 1 + + include/linux/device/faux.h | 69 ++++++ + 6 files changed, 310 insertions(+), 1 deletion(-) + create mode 100644 drivers/base/faux.c + create mode 100644 include/linux/device/faux.h + +--- a/Documentation/driver-api/infrastructure.rst ++++ b/Documentation/driver-api/infrastructure.rst +@@ -41,6 +41,12 @@ Device Drivers Base + .. kernel-doc:: drivers/base/class.c + :export: + ++.. kernel-doc:: include/linux/device/faux.h ++ :internal: ++ ++.. kernel-doc:: drivers/base/faux.c ++ :export: ++ + .. kernel-doc:: drivers/base/node.c + :internal: + +--- a/drivers/base/Makefile ++++ b/drivers/base/Makefile +@@ -6,7 +6,7 @@ obj-y := component.o core.o bus.o dd.o + cpu.o firmware.o init.o map.o devres.o \ + attribute_container.o transport_class.o \ + topology.o container.o property.o cacheinfo.o \ +- swnode.o ++ swnode.o faux.o + obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o + obj-$(CONFIG_DEVTMPFS) += devtmpfs.o + obj-y += power/ +--- a/drivers/base/base.h ++++ b/drivers/base/base.h +@@ -138,6 +138,7 @@ int hypervisor_init(void); + static inline int hypervisor_init(void) { return 0; } + #endif + int platform_bus_init(void); ++int faux_bus_init(void); + void cpu_dev_init(void); + void container_dev_init(void); + #ifdef CONFIG_AUXILIARY_BUS +--- /dev/null ++++ b/drivers/base/faux.c +@@ -0,0 +1,232 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Copyright (c) 2025 Greg Kroah-Hartman ++ * Copyright (c) 2025 The Linux Foundation ++ * ++ * A "simple" faux bus that allows devices to be created and added ++ * automatically to it. This is to be used whenever you need to create a ++ * device that is not associated with any "real" system resources, and do ++ * not want to have to deal with a bus/driver binding logic. It is ++ * intended to be very simple, with only a create and a destroy function ++ * available. ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include "base.h" ++ ++/* ++ * Internal wrapper structure so we can hold a pointer to the ++ * faux_device_ops for this device. ++ */ ++struct faux_object { ++ struct faux_device faux_dev; ++ const struct faux_device_ops *faux_ops; ++}; ++#define to_faux_object(dev) container_of_const(dev, struct faux_object, faux_dev.dev) ++ ++static struct device faux_bus_root = { ++ .init_name = "faux", ++}; ++ ++static int faux_match(struct device *dev, const struct device_driver *drv) ++{ ++ /* Match always succeeds, we only have one driver */ ++ return 1; ++} ++ ++static int faux_probe(struct device *dev) ++{ ++ struct faux_object *faux_obj = to_faux_object(dev); ++ struct faux_device *faux_dev = &faux_obj->faux_dev; ++ const struct faux_device_ops *faux_ops = faux_obj->faux_ops; ++ int ret = 0; ++ ++ if (faux_ops && faux_ops->probe) ++ ret = faux_ops->probe(faux_dev); ++ ++ return ret; ++} ++ ++static void faux_remove(struct device *dev) ++{ ++ struct faux_object *faux_obj = to_faux_object(dev); ++ struct faux_device *faux_dev = &faux_obj->faux_dev; ++ const struct faux_device_ops *faux_ops = faux_obj->faux_ops; ++ ++ if (faux_ops && faux_ops->remove) ++ faux_ops->remove(faux_dev); ++} ++ ++static const struct bus_type faux_bus_type = { ++ .name = "faux", ++ .match = faux_match, ++ .probe = faux_probe, ++ .remove = faux_remove, ++}; ++ ++static struct device_driver faux_driver = { ++ .name = "faux_driver", ++ .bus = &faux_bus_type, ++ .probe_type = PROBE_FORCE_SYNCHRONOUS, ++}; ++ ++static void faux_device_release(struct device *dev) ++{ ++ struct faux_object *faux_obj = to_faux_object(dev); ++ ++ kfree(faux_obj); ++} ++ ++/** ++ * faux_device_create_with_groups - Create and register with the driver ++ * core a faux device and populate the device with an initial ++ * set of sysfs attributes. ++ * @name: The name of the device we are adding, must be unique for ++ * all faux devices. ++ * @parent: Pointer to a potential parent struct device. If set to ++ * NULL, the device will be created in the "root" of the faux ++ * device tree in sysfs. ++ * @faux_ops: struct faux_device_ops that the new device will call back ++ * into, can be NULL. ++ * @groups: The set of sysfs attributes that will be created for this ++ * device when it is registered with the driver core. ++ * ++ * Create a new faux device and register it in the driver core properly. ++ * If present, callbacks in @faux_ops will be called with the device that ++ * for the caller to do something with at the proper time given the ++ * device's lifecycle. ++ * ++ * Note, when this function is called, the functions specified in struct ++ * faux_ops can be called before the function returns, so be prepared for ++ * everything to be properly initialized before that point in time. ++ * ++ * Return: ++ * * NULL if an error happened with creating the device ++ * * pointer to a valid struct faux_device that is registered with sysfs ++ */ ++struct faux_device *faux_device_create_with_groups(const char *name, ++ struct device *parent, ++ const struct faux_device_ops *faux_ops, ++ const struct attribute_group **groups) ++{ ++ struct faux_object *faux_obj; ++ struct faux_device *faux_dev; ++ struct device *dev; ++ int ret; ++ ++ faux_obj = kzalloc(sizeof(*faux_obj), GFP_KERNEL); ++ if (!faux_obj) ++ return NULL; ++ ++ /* Save off the callbacks so we can use them in the future */ ++ faux_obj->faux_ops = faux_ops; ++ ++ /* Initialize the device portion and register it with the driver core */ ++ faux_dev = &faux_obj->faux_dev; ++ dev = &faux_dev->dev; ++ ++ device_initialize(dev); ++ dev->release = faux_device_release; ++ if (parent) ++ dev->parent = parent; ++ else ++ dev->parent = &faux_bus_root; ++ dev->bus = &faux_bus_type; ++ dev->groups = groups; ++ dev_set_name(dev, "%s", name); ++ ++ ret = device_add(dev); ++ if (ret) { ++ pr_err("%s: device_add for faux device '%s' failed with %d\n", ++ __func__, name, ret); ++ put_device(dev); ++ return NULL; ++ } ++ ++ return faux_dev; ++} ++EXPORT_SYMBOL_GPL(faux_device_create_with_groups); ++ ++/** ++ * faux_device_create - create and register with the driver core a faux device ++ * @name: The name of the device we are adding, must be unique for all ++ * faux devices. ++ * @parent: Pointer to a potential parent struct device. If set to ++ * NULL, the device will be created in the "root" of the faux ++ * device tree in sysfs. ++ * @faux_ops: struct faux_device_ops that the new device will call back ++ * into, can be NULL. ++ * ++ * Create a new faux device and register it in the driver core properly. ++ * If present, callbacks in @faux_ops will be called with the device that ++ * for the caller to do something with at the proper time given the ++ * device's lifecycle. ++ * ++ * Note, when this function is called, the functions specified in struct ++ * faux_ops can be called before the function returns, so be prepared for ++ * everything to be properly initialized before that point in time. ++ * ++ * Return: ++ * * NULL if an error happened with creating the device ++ * * pointer to a valid struct faux_device that is registered with sysfs ++ */ ++struct faux_device *faux_device_create(const char *name, ++ struct device *parent, ++ const struct faux_device_ops *faux_ops) ++{ ++ return faux_device_create_with_groups(name, parent, faux_ops, NULL); ++} ++EXPORT_SYMBOL_GPL(faux_device_create); ++ ++/** ++ * faux_device_destroy - destroy a faux device ++ * @faux_dev: faux device to destroy ++ * ++ * Unregisters and cleans up a device that was created with a call to ++ * faux_device_create() ++ */ ++void faux_device_destroy(struct faux_device *faux_dev) ++{ ++ struct device *dev = &faux_dev->dev; ++ ++ if (!faux_dev) ++ return; ++ ++ device_del(dev); ++ ++ /* The final put_device() will clean up the memory we allocated for this device. */ ++ put_device(dev); ++} ++EXPORT_SYMBOL_GPL(faux_device_destroy); ++ ++int __init faux_bus_init(void) ++{ ++ int ret; ++ ++ ret = device_register(&faux_bus_root); ++ if (ret) { ++ put_device(&faux_bus_root); ++ return ret; ++ } ++ ++ ret = bus_register(&faux_bus_type); ++ if (ret) ++ goto error_bus; ++ ++ ret = driver_register(&faux_driver); ++ if (ret) ++ goto error_driver; ++ ++ return ret; ++ ++error_driver: ++ bus_unregister(&faux_bus_type); ++ ++error_bus: ++ device_unregister(&faux_bus_root); ++ return ret; ++} +--- a/drivers/base/init.c ++++ b/drivers/base/init.c +@@ -32,6 +32,7 @@ void __init driver_init(void) + /* These are also core pieces, but must come after the + * core core pieces. + */ ++ faux_bus_init(); + of_core_init(); + platform_bus_init(); + auxiliary_bus_init(); +--- /dev/null ++++ b/include/linux/device/faux.h +@@ -0,0 +1,69 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++/* ++ * Copyright (c) 2025 Greg Kroah-Hartman ++ * Copyright (c) 2025 The Linux Foundation ++ * ++ * A "simple" faux bus that allows devices to be created and added ++ * automatically to it. This is to be used whenever you need to create a ++ * device that is not associated with any "real" system resources, and do ++ * not want to have to deal with a bus/driver binding logic. It is ++ * intended to be very simple, with only a create and a destroy function ++ * available. ++ */ ++#ifndef _FAUX_DEVICE_H_ ++#define _FAUX_DEVICE_H_ ++ ++#include ++#include ++ ++/** ++ * struct faux_device - a "faux" device ++ * @dev: internal struct device of the object ++ * ++ * A simple faux device that can be created/destroyed. To be used when a ++ * driver only needs to have a device to "hang" something off. This can be ++ * used for downloading firmware or other basic tasks. Use this instead of ++ * a struct platform_device if the device has no resources assigned to ++ * it at all. ++ */ ++struct faux_device { ++ struct device dev; ++}; ++#define to_faux_device(x) container_of_const((x), struct faux_device, dev) ++ ++/** ++ * struct faux_device_ops - a set of callbacks for a struct faux_device ++ * @probe: called when a faux device is probed by the driver core ++ * before the device is fully bound to the internal faux bus ++ * code. If probe succeeds, return 0, otherwise return a ++ * negative error number to stop the probe sequence from ++ * succeeding. ++ * @remove: called when a faux device is removed from the system ++ * ++ * Both @probe and @remove are optional, if not needed, set to NULL. ++ */ ++struct faux_device_ops { ++ int (*probe)(struct faux_device *faux_dev); ++ void (*remove)(struct faux_device *faux_dev); ++}; ++ ++struct faux_device *faux_device_create(const char *name, ++ struct device *parent, ++ const struct faux_device_ops *faux_ops); ++struct faux_device *faux_device_create_with_groups(const char *name, ++ struct device *parent, ++ const struct faux_device_ops *faux_ops, ++ const struct attribute_group **groups); ++void faux_device_destroy(struct faux_device *faux_dev); ++ ++static inline void *faux_device_get_drvdata(const struct faux_device *faux_dev) ++{ ++ return dev_get_drvdata(&faux_dev->dev); ++} ++ ++static inline void faux_device_set_drvdata(struct faux_device *faux_dev, void *data) ++{ ++ dev_set_drvdata(&faux_dev->dev, data); ++} ++ ++#endif /* _FAUX_DEVICE_H_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/910-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-sha.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/910-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-sha.patch new file mode 100755 index 0000000..4957677 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/910-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-sha.patch @@ -0,0 +1,354 @@ +From 030218dedee2628ea3f035d71431e1b7c4191cfb Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Sat, 31 Jan 2026 18:38:47 +0100 +Subject: [PATCH] crypto: testmgr - Add test vectors for + authenc(hmac(sha384),cbc(aes)) + +Test vectors were generated starting from existing CBC(AES) test vectors +(RFC3602, NIST SP800-38A) and adding HMAC(SHA384) computed with Python +script. Then, the results were double-checked on Mediatek MT7981 (safexcel) +and NXP P2020 (talitos). Both platforms pass self-tests. + +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: Herbert Xu +--- + crypto/testmgr.c | 7 ++ + crypto/testmgr.h | 311 +++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 318 insertions(+) + +--- a/crypto/testmgr.c ++++ b/crypto/testmgr.c +@@ -4453,6 +4453,13 @@ static const struct alg_test_desc alg_te + .test = alg_test_null, + .fips_allowed = 1, + }, { ++ .alg = "authenc(hmac(sha384),cbc(aes))", ++ .generic_driver = "authenc(hmac-sha384-lib,cbc(aes-generic))", ++ .test = alg_test_aead, ++ .suite = { ++ .aead = __VECS(hmac_sha384_aes_cbc_tv_temp) ++ } ++ }, { + .alg = "authenc(hmac(sha384),cbc(des))", + .test = alg_test_aead, + .suite = { +--- a/crypto/testmgr.h ++++ b/crypto/testmgr.h +@@ -17773,6 +17773,317 @@ static const struct aead_testvec hmac_sh + }, + }; + ++static const struct aead_testvec hmac_sha384_aes_cbc_tv_temp[] = { ++ { /* RFC 3602 Case 1 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" ++ "\x51\x2e\x03\xd5\x34\x12\x00\x06", ++ .klen = 8 + 48 + 16, ++ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" ++ "\xb4\x22\xda\x80\x2c\x9f\xac\x41", ++ .assoc = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" ++ "\xb4\x22\xda\x80\x2c\x9f\xac\x41", ++ .alen = 16, ++ .ptext = "Single block msg", ++ .plen = 16, ++ .ctext = "\xe3\x53\x77\x9c\x10\x79\xae\xb8" ++ "\x27\x08\x94\x2d\xbe\x77\x18\x1a" ++ "\x79\x1c\xf1\x22\x95\x80\xe0\x60" ++ "\x7f\xf9\x92\x60\x83\xbd\x60\x9c" ++ "\xf6\x62\x8b\xa9\x7d\x56\xe2\xaf" ++ "\x80\x43\xbc\x41\x4a\x63\x0b\xa0" ++ "\x16\x25\xe2\xfe\x0a\x96\xf6\xa5" ++ "\x6c\x0b\xc2\x53\xb4\x27\xd9\x42", ++ .clen = 16 + 48, ++ }, { /* RFC 3602 Case 2 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x20\x21\x22\x23\x24\x25\x26\x27" ++ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" ++ "\x30\x31\x32\x33\x34\x35\x36\x37" ++ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" ++ "\x40\x41\x42\x43\x44\x45\x46\x47" ++ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" ++ "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0" ++ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a", ++ .klen = 8 + 48 + 16, ++ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" ++ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", ++ .assoc = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" ++ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", ++ .alen = 16, ++ .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" ++ "\x10\x11\x12\x13\x14\x15\x16\x17" ++ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", ++ .plen = 32, ++ .ctext = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a" ++ "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a" ++ "\x75\x86\x60\x2d\x25\x3c\xff\xf9" ++ "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1" ++ "\x4e\x5b\xa8\x65\x51\xc6\x58\xaf" ++ "\x31\x57\x50\x3d\x01\xa1\xa4\x3f" ++ "\x42\xd1\xd7\x31\x76\x8d\xf8\xc8" ++ "\xe4\xd2\x7e\xc5\x23\xe7\xc6\x2e" ++ "\x2d\xfd\x9d\xc1\xac\x50\x1e\xcf" ++ "\xa0\x10\xeb\x1a\x9c\xb7\xe1\xca", ++ .clen = 32 + 48, ++ }, { /* RFC 3602 Case 3 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd\xee\xff\x11\x22" ++ "\x33\x44\x55\x66\x77\x88\x99\xaa" ++ "\xbb\xcc\xdd\xee\xff\x11\x22\x33" ++ "\x6c\x3e\xa0\x47\x76\x30\xce\x21" ++ "\xa2\xce\x33\x4a\xa7\x46\xc2\xcd", ++ .klen = 8 + 48 + 16, ++ .iv = "\xc7\x82\xdc\x4c\x09\x8c\x66\xcb" ++ "\xd9\xcd\x27\xd8\x25\x68\x2c\x81", ++ .assoc = "\xc7\x82\xdc\x4c\x09\x8c\x66\xcb" ++ "\xd9\xcd\x27\xd8\x25\x68\x2c\x81", ++ .alen = 16, ++ .ptext = "This is a 48-byte message (exactly 3 AES blocks)", ++ .plen = 48, ++ .ctext = "\xd0\xa0\x2b\x38\x36\x45\x17\x53" ++ "\xd4\x93\x66\x5d\x33\xf0\xe8\x86" ++ "\x2d\xea\x54\xcd\xb2\x93\xab\xc7" ++ "\x50\x69\x39\x27\x67\x72\xf8\xd5" ++ "\x02\x1c\x19\x21\x6b\xad\x52\x5c" ++ "\x85\x79\x69\x5d\x83\xba\x26\x84" ++ "\xa1\x52\xe7\xda\xf7\x05\xb6\xca" ++ "\xad\x0f\x51\xed\x5a\xd3\x0f\xdf" ++ "\xde\xeb\x3f\x31\xed\x3a\x43\x93" ++ "\x3b\xb7\xca\xc8\x1b\xe7\x3b\x61" ++ "\x6a\x05\xfd\x2d\x6a\x5c\xb1\x0d" ++ "\x6e\x7a\xeb\x1c\x84\xec\xdb\xde", ++ .clen = 48 + 48, ++ }, { /* RFC 3602 Case 4 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd\xee\xff\x11\x22" ++ "\x33\x44\x55\x66\x77\x88\x99\xaa" ++ "\xbb\xcc\xdd\xee\xff\x11\x22\x33" ++ "\x56\xe4\x7a\x38\xc5\x59\x89\x74" ++ "\xbc\x46\x90\x3d\xba\x29\x03\x49", ++ .klen = 8 + 48 + 16, ++ .iv = "\x8c\xe8\x2e\xef\xbe\xa0\xda\x3c" ++ "\x44\x69\x9e\xd7\xdb\x51\xb7\xd9", ++ .assoc = "\x8c\xe8\x2e\xef\xbe\xa0\xda\x3c" ++ "\x44\x69\x9e\xd7\xdb\x51\xb7\xd9", ++ .alen = 16, ++ .ptext = "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" ++ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" ++ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" ++ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" ++ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" ++ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" ++ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" ++ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf", ++ .plen = 64, ++ .ctext = "\xc3\x0e\x32\xff\xed\xc0\x77\x4e" ++ "\x6a\xff\x6a\xf0\x86\x9f\x71\xaa" ++ "\x0f\x3a\xf0\x7a\x9a\x31\xa9\xc6" ++ "\x84\xdb\x20\x7e\xb0\xef\x8e\x4e" ++ "\x35\x90\x7a\xa6\x32\xc3\xff\xdf" ++ "\x86\x8b\xb7\xb2\x9d\x3d\x46\xad" ++ "\x83\xce\x9f\x9a\x10\x2e\xe9\x9d" ++ "\x49\xa5\x3e\x87\xf4\xc3\xda\x55" ++ "\x85\x7b\x91\xe0\x29\xeb\xd3\x59" ++ "\x7c\xe3\x67\x14\xbe\x71\x2a\xd2" ++ "\x8a\x1a\xd2\x35\x78\x6b\x69\xba" ++ "\x64\xa5\x04\x00\x19\xc3\x4c\xae" ++ "\x71\xff\x76\x9f\xbb\xc3\x29\x22" ++ "\xc2\xc6\x51\xf1\xe6\x29\x5e\xa5", ++ .clen = 64 + 48, ++ }, { /* RFC 3602 Case 5 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd\xee\xff\x11\x22" ++ "\x33\x44\x55\x66\x77\x88\x99\xaa" ++ "\xbb\xcc\xdd\xee\xff\x11\x22\x33" ++ "\x90\xd3\x82\xb4\x10\xee\xba\x7a" ++ "\xd9\x38\xc4\x6c\xec\x1a\x82\xbf", ++ .klen = 8 + 48 + 16, ++ .iv = "\xe9\x6e\x8c\x08\xab\x46\x57\x63" ++ "\xfd\x09\x8d\x45\xdd\x3f\xf8\x93", ++ .assoc = "\x00\x00\x43\x21\x00\x00\x00\x01" ++ "\xe9\x6e\x8c\x08\xab\x46\x57\x63" ++ "\xfd\x09\x8d\x45\xdd\x3f\xf8\x93", ++ .alen = 24, ++ .ptext = "\x08\x00\x0e\xbd\xa7\x0a\x00\x00" ++ "\x8e\x9c\x08\x3d\xb9\x5b\x07\x00" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" ++ "\x10\x11\x12\x13\x14\x15\x16\x17" ++ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" ++ "\x20\x21\x22\x23\x24\x25\x26\x27" ++ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" ++ "\x30\x31\x32\x33\x34\x35\x36\x37" ++ "\x01\x02\x03\x04\x05\x06\x07\x08" ++ "\x09\x0a\x0b\x0c\x0d\x0e\x0e\x01", ++ .plen = 80, ++ .ctext = "\xf6\x63\xc2\x5d\x32\x5c\x18\xc6" ++ "\xa9\x45\x3e\x19\x4e\x12\x08\x49" ++ "\xa4\x87\x0b\x66\xcc\x6b\x99\x65" ++ "\x33\x00\x13\xb4\x89\x8d\xc8\x56" ++ "\xa4\x69\x9e\x52\x3a\x55\xdb\x08" ++ "\x0b\x59\xec\x3a\x8e\x4b\x7e\x52" ++ "\x77\x5b\x07\xd1\xdb\x34\xed\x9c" ++ "\x53\x8a\xb5\x0c\x55\x1b\x87\x4a" ++ "\xa2\x69\xad\xd0\x47\xad\x2d\x59" ++ "\x13\xac\x19\xb7\xcf\xba\xd4\xa6" ++ "\x57\x5f\xb4\xd7\x74\x6f\x18\x97" ++ "\xb7\xde\xfc\xf3\x4e\x0d\x29\x4d" ++ "\xa0\xff\x39\x9e\x2d\xbf\x27\xac" ++ "\x54\xb9\x8a\x3e\xab\x3b\xac\xd3" ++ "\x36\x43\x74\xfc\xc2\x64\x81\x8a" ++ "\x2c\x15\x72\xdf\x3f\x9d\x5b\xa4", ++ .clen = 80 + 48, ++ }, { /* NIST SP800-38A F.2.3 CBC-AES192.Encrypt */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x18" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd\xee\xff\x11\x22" ++ "\x33\x44\x55\x66\x77\x88\x99\xaa" ++ "\xbb\xcc\xdd\xee\xff\x11\x22\x33" ++ "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" ++ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" ++ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", ++ .klen = 8 + 48 + 24, ++ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .alen = 16, ++ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" ++ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" ++ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" ++ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" ++ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" ++ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" ++ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" ++ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", ++ .plen = 64, ++ .ctext = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d" ++ "\x71\x78\x18\x3a\x9f\xa0\x71\xe8" ++ "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4" ++ "\xe5\xe7\x38\x76\x3f\x69\x14\x5a" ++ "\x57\x1b\x24\x20\x12\xfb\x7a\xe0" ++ "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0" ++ "\x08\xb0\xe2\x79\x88\x59\x88\x81" ++ "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd" ++ "\x29\x9b\x42\x47\x0b\xbf\xf3\x54" ++ "\x54\x95\xb0\x89\xd5\xa0\xc3\x78" ++ "\x60\x6c\x18\x39\x6d\xc9\xfb\x2a" ++ "\x34\x1c\xed\x95\x10\x1e\x43\x0a" ++ "\x72\xce\x26\xbc\x74\xd9\x6f\xa2" ++ "\xf1\xd9\xd0\xb1\xdf\x3d\x93\x14", ++ .clen = 64 + 48, ++ }, { /* NIST SP800-38A F.2.5 CBC-AES256.Encrypt */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x20" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd\xee\xff\x11\x22" ++ "\x33\x44\x55\x66\x77\x88\x99\xaa" ++ "\xbb\xcc\xdd\xee\xff\x11\x22\x33" ++ "\x60\x3d\xeb\x10\x15\xca\x71\xbe" ++ "\x2b\x73\xae\xf0\x85\x7d\x77\x81" ++ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" ++ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", ++ .klen = 8 + 48 + 32, ++ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .alen = 16, ++ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" ++ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" ++ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" ++ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" ++ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" ++ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" ++ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" ++ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", ++ .plen = 64, ++ .ctext = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba" ++ "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6" ++ "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d" ++ "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d" ++ "\x39\xf2\x33\x69\xa9\xd9\xba\xcf" ++ "\xa5\x30\xe2\x63\x04\x23\x14\x61" ++ "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc" ++ "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b" ++ "\x9f\x50\xce\x64\xd9\xa3\xc9\x7a" ++ "\x15\x3a\x3d\x46\x9a\x90\xf3\x06" ++ "\x22\xad\xc5\x24\x77\x50\xb8\xfe" ++ "\xbe\x37\x16\x86\x34\x5f\xaf\x97" ++ "\x00\x9d\x86\xc8\x32\x4f\x72\x2f" ++ "\x48\x97\xad\xb6\xb9\x77\x33\xbc", ++ .clen = 64 + 48, ++ }, ++}; ++ + static const struct aead_testvec hmac_sha512_aes_cbc_tv_temp[] = { + { /* RFC 3602 Case 1 */ + #ifdef __LITTLE_ENDIAN diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/911-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-sha.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/911-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-sha.patch new file mode 100755 index 0000000..8649c1e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/911-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-sha.patch @@ -0,0 +1,328 @@ +From a22d48cbe55814061d46db2f87090ba5e36aaf7f Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Sat, 31 Jan 2026 18:43:03 +0100 +Subject: [PATCH] crypto: testmgr - Add test vectors for + authenc(hmac(sha224),cbc(aes)) + +Test vectors were generated starting from existing CBC(AES) test vectors +(RFC3602, NIST SP800-38A) and adding HMAC(SHA224) computed with Python +script. Then, the results were double-checked on Mediatek MT7981 (safexcel) +and NXP P2020 (talitos). Both platforms pass self-tests. + +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: Herbert Xu +--- + crypto/testmgr.c | 7 ++ + crypto/testmgr.h | 285 +++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 292 insertions(+) + +--- a/crypto/testmgr.c ++++ b/crypto/testmgr.c +@@ -4414,6 +4414,13 @@ static const struct alg_test_desc alg_te + .test = alg_test_null, + .fips_allowed = 1, + }, { ++ .alg = "authenc(hmac(sha224),cbc(aes))", ++ .generic_driver = "authenc(hmac-sha224-lib,cbc(aes-generic))", ++ .test = alg_test_aead, ++ .suite = { ++ .aead = __VECS(hmac_sha224_aes_cbc_tv_temp) ++ } ++ }, { + .alg = "authenc(hmac(sha224),cbc(des))", + .test = alg_test_aead, + .suite = { +--- a/crypto/testmgr.h ++++ b/crypto/testmgr.h +@@ -17490,6 +17490,291 @@ static const struct aead_testvec hmac_sh + }, + }; + ++static const struct aead_testvec hmac_sha224_aes_cbc_tv_temp[] = { ++ { /* RFC 3602 Case 1 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x00\x00\x00\x00" ++ "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" ++ "\x51\x2e\x03\xd5\x34\x12\x00\x06", ++ .klen = 8 + 28 + 16, ++ .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" ++ "\xb4\x22\xda\x80\x2c\x9f\xac\x41", ++ .assoc = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" ++ "\xb4\x22\xda\x80\x2c\x9f\xac\x41", ++ .alen = 16, ++ .ptext = "Single block msg", ++ .plen = 16, ++ .ctext = "\xe3\x53\x77\x9c\x10\x79\xae\xb8" ++ "\x27\x08\x94\x2d\xbe\x77\x18\x1a" ++ "\x17\xe8\x00\x76\x70\x71\xd1\x72" ++ "\xf8\xd0\x91\x51\x67\xf9\xdf\xd6" ++ "\x0d\x56\x1a\xb3\x52\x19\x85\xae" ++ "\x46\x74\xb6\x98", ++ .clen = 16 + 28, ++ }, { /* RFC 3602 Case 2 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x20\x21\x22\x23\x24\x25\x26\x27" ++ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" ++ "\x30\x31\x32\x33\x34\x35\x36\x37" ++ "\x38\x39\x3a\x3b" ++ "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0" ++ "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a", ++ .klen = 8 + 28 + 16, ++ .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" ++ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", ++ .assoc = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" ++ "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", ++ .alen = 16, ++ .ptext = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" ++ "\x10\x11\x12\x13\x14\x15\x16\x17" ++ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", ++ .plen = 32, ++ .ctext = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a" ++ "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a" ++ "\x75\x86\x60\x2d\x25\x3c\xff\xf9" ++ "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1" ++ "\xa1\x11\xfa\xbb\x1e\x04\x7e\xe7" ++ "\x4c\x5f\x65\xbf\x68\x8d\x33\x9d" ++ "\xbc\x74\x9b\xf3\x15\xf3\x8f\x8d" ++ "\xe8\xaf\x33\xe0", ++ ++ .clen = 32 + 28, ++ }, { /* RFC 3602 Case 3 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd" ++ "\x6c\x3e\xa0\x47\x76\x30\xce\x21" ++ "\xa2\xce\x33\x4a\xa7\x46\xc2\xcd", ++ .klen = 8 + 28 + 16, ++ .iv = "\xc7\x82\xdc\x4c\x09\x8c\x66\xcb" ++ "\xd9\xcd\x27\xd8\x25\x68\x2c\x81", ++ .assoc = "\xc7\x82\xdc\x4c\x09\x8c\x66\xcb" ++ "\xd9\xcd\x27\xd8\x25\x68\x2c\x81", ++ .alen = 16, ++ .ptext = "This is a 48-byte message (exactly 3 AES blocks)", ++ .plen = 48, ++ .ctext = "\xd0\xa0\x2b\x38\x36\x45\x17\x53" ++ "\xd4\x93\x66\x5d\x33\xf0\xe8\x86" ++ "\x2d\xea\x54\xcd\xb2\x93\xab\xc7" ++ "\x50\x69\x39\x27\x67\x72\xf8\xd5" ++ "\x02\x1c\x19\x21\x6b\xad\x52\x5c" ++ "\x85\x79\x69\x5d\x83\xba\x26\x84" ++ "\x60\xb3\xca\x0e\xc1\xfe\xf2\x27" ++ "\x5a\x41\xe4\x99\xa8\x19\x56\xf1" ++ "\x44\x98\x27\x9f\x99\xb0\x4a\xad" ++ "\x4d\xc1\x1e\x88", ++ .clen = 48 + 28, ++ }, { /* RFC 3602 Case 4 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd" ++ "\x56\xe4\x7a\x38\xc5\x59\x89\x74" ++ "\xbc\x46\x90\x3d\xba\x29\x03\x49", ++ .klen = 8 + 28 + 16, ++ .iv = "\x8c\xe8\x2e\xef\xbe\xa0\xda\x3c" ++ "\x44\x69\x9e\xd7\xdb\x51\xb7\xd9", ++ .assoc = "\x8c\xe8\x2e\xef\xbe\xa0\xda\x3c" ++ "\x44\x69\x9e\xd7\xdb\x51\xb7\xd9", ++ .alen = 16, ++ .ptext = "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" ++ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" ++ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" ++ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" ++ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" ++ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" ++ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" ++ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf", ++ .plen = 64, ++ .ctext = "\xc3\x0e\x32\xff\xed\xc0\x77\x4e" ++ "\x6a\xff\x6a\xf0\x86\x9f\x71\xaa" ++ "\x0f\x3a\xf0\x7a\x9a\x31\xa9\xc6" ++ "\x84\xdb\x20\x7e\xb0\xef\x8e\x4e" ++ "\x35\x90\x7a\xa6\x32\xc3\xff\xdf" ++ "\x86\x8b\xb7\xb2\x9d\x3d\x46\xad" ++ "\x83\xce\x9f\x9a\x10\x2e\xe9\x9d" ++ "\x49\xa5\x3e\x87\xf4\xc3\xda\x55" ++ "\xbb\xe9\x38\xf8\xb9\xbf\xcb\x7b" ++ "\xa8\x22\x91\xea\x1e\xaf\x13\xba" ++ "\x24\x18\x64\x9c\xcb\xb4\xa9\x16" ++ "\x4b\x83\x9c\xec", ++ .clen = 64 + 28, ++ }, { /* RFC 3602 Case 5 */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x10" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd" ++ "\x90\xd3\x82\xb4\x10\xee\xba\x7a" ++ "\xd9\x38\xc4\x6c\xec\x1a\x82\xbf", ++ .klen = 8 + 28 + 16, ++ .iv = "\xe9\x6e\x8c\x08\xab\x46\x57\x63" ++ "\xfd\x09\x8d\x45\xdd\x3f\xf8\x93", ++ .assoc = "\x00\x00\x43\x21\x00\x00\x00\x01" ++ "\xe9\x6e\x8c\x08\xab\x46\x57\x63" ++ "\xfd\x09\x8d\x45\xdd\x3f\xf8\x93", ++ .alen = 24, ++ .ptext = "\x08\x00\x0e\xbd\xa7\x0a\x00\x00" ++ "\x8e\x9c\x08\x3d\xb9\x5b\x07\x00" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" ++ "\x10\x11\x12\x13\x14\x15\x16\x17" ++ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" ++ "\x20\x21\x22\x23\x24\x25\x26\x27" ++ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" ++ "\x30\x31\x32\x33\x34\x35\x36\x37" ++ "\x01\x02\x03\x04\x05\x06\x07\x08" ++ "\x09\x0a\x0b\x0c\x0d\x0e\x0e\x01", ++ .plen = 80, ++ .ctext = "\xf6\x63\xc2\x5d\x32\x5c\x18\xc6" ++ "\xa9\x45\x3e\x19\x4e\x12\x08\x49" ++ "\xa4\x87\x0b\x66\xcc\x6b\x99\x65" ++ "\x33\x00\x13\xb4\x89\x8d\xc8\x56" ++ "\xa4\x69\x9e\x52\x3a\x55\xdb\x08" ++ "\x0b\x59\xec\x3a\x8e\x4b\x7e\x52" ++ "\x77\x5b\x07\xd1\xdb\x34\xed\x9c" ++ "\x53\x8a\xb5\x0c\x55\x1b\x87\x4a" ++ "\xa2\x69\xad\xd0\x47\xad\x2d\x59" ++ "\x13\xac\x19\xb7\xcf\xba\xd4\xa6" ++ "\x04\x5e\x83\x45\xc5\x6a\x5b\xe2" ++ "\x5e\xd8\x59\x06\xbd\xc7\xd2\x9b" ++ "\x0b\x65\x1f\x31\xc7\xe6\x9c\x39" ++ "\xa3\x66\xdb\xb8", ++ .clen = 80 + 28, ++ }, { /* NIST SP800-38A F.2.3 CBC-AES192.Encrypt */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x18" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd" ++ "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" ++ "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" ++ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", ++ .klen = 8 + 28 + 24, ++ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .alen = 16, ++ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" ++ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" ++ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" ++ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" ++ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" ++ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" ++ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" ++ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", ++ .plen = 64, ++ .ctext = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d" ++ "\x71\x78\x18\x3a\x9f\xa0\x71\xe8" ++ "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4" ++ "\xe5\xe7\x38\x76\x3f\x69\x14\x5a" ++ "\x57\x1b\x24\x20\x12\xfb\x7a\xe0" ++ "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0" ++ "\x08\xb0\xe2\x79\x88\x59\x88\x81" ++ "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd" ++ "\x67\x35\xcd\x86\x94\x51\x3b\x3a" ++ "\xaa\x07\xb1\xed\x18\x55\x62\x01" ++ "\x95\xb2\x53\xb5\x20\x78\x16\xd7" ++ "\xb8\x49\x7f\x96", ++ ++ .clen = 64 + 28, ++ }, { /* NIST SP800-38A F.2.5 CBC-AES256.Encrypt */ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x20" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\x22\x33\x44\x55\x66\x77\x88\x99" ++ "\xaa\xbb\xcc\xdd" ++ "\x60\x3d\xeb\x10\x15\xca\x71\xbe" ++ "\x2b\x73\xae\xf0\x85\x7d\x77\x81" ++ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" ++ "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", ++ .klen = 8 + 28 + 32, ++ .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" ++ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", ++ .alen = 16, ++ .ptext = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" ++ "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" ++ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" ++ "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" ++ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" ++ "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" ++ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" ++ "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", ++ .plen = 64, ++ .ctext = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba" ++ "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6" ++ "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d" ++ "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d" ++ "\x39\xf2\x33\x69\xa9\xd9\xba\xcf" ++ "\xa5\x30\xe2\x63\x04\x23\x14\x61" ++ "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc" ++ "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b" ++ "\xe0\xe2\x3d\x3f\x55\x24\x2c\x4d" ++ "\xb9\x13\x2a\xc0\x07\xbb\x3b\xda" ++ "\xfd\xa4\x51\x32\x3f\x44\xb1\x13" ++ "\x98\xf9\xbc\xb9", ++ .clen = 64 + 28, ++ }, ++}; ++ + static const struct aead_testvec hmac_sha256_aes_cbc_tv_temp[] = { + { /* RFC 3602 Case 1 */ + #ifdef __LITTLE_ENDIAN diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/912-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-md5.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/912-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-md5.patch new file mode 100755 index 0000000..0e36006 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/backport-6.12/912-v7.0-crypto-testmgr-Add-test-vectors-for-authenc-hmac-md5.patch @@ -0,0 +1,102 @@ +From dc8f3d9ae804e8bb47dd49b051fe8b303db3b95c Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Sun, 1 Feb 2026 12:27:08 +0100 +Subject: [PATCH] crypto: testmgr - Add test vectors for + authenc(hmac(md5),cbc(des3_ede)) + +Test vector was generated using a software implementation and then double +checked using a hardware implementation on NXP P2020 (talitos). The +encryption part is identical to authenc(hmac(sha1),cbc(des3_ede)), +only HMAC is different. + +Signed-off-by: Aleksander Jan Bajkowski +Signed-off-by: Herbert Xu +--- + crypto/testmgr.c | 7 ++++++ + crypto/testmgr.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 66 insertions(+) + +--- a/crypto/testmgr.c ++++ b/crypto/testmgr.c +@@ -4375,6 +4375,13 @@ static const struct alg_test_desc alg_te + .cprng = __VECS(ansi_cprng_aes_tv_template) + } + }, { ++ .alg = "authenc(hmac(md5),cbc(des3_ede))", ++ .generic_driver = "authenc(hmac-md5-lib,cbc(des3_ede-generic))", ++ .test = alg_test_aead, ++ .suite = { ++ .aead = __VECS(hmac_md5_des3_ede_cbc_tv_temp) ++ } ++ }, { + .alg = "authenc(hmac(md5),ecb(cipher_null))", + .test = alg_test_aead, + .suite = { +--- a/crypto/testmgr.h ++++ b/crypto/testmgr.h +@@ -19021,6 +19021,65 @@ static const struct aead_testvec hmac_sh + }, + }; + ++static const struct aead_testvec hmac_md5_des3_ede_cbc_tv_temp[] = { ++ { /*Generated with cryptopp*/ ++#ifdef __LITTLE_ENDIAN ++ .key = "\x08\x00" /* rta length */ ++ "\x01\x00" /* rta type */ ++#else ++ .key = "\x00\x08" /* rta length */ ++ "\x00\x01" /* rta type */ ++#endif ++ "\x00\x00\x00\x18" /* enc key length */ ++ "\x11\x22\x33\x44\x55\x66\x77\x88" ++ "\x99\xaa\xbb\xcc\xdd\xee\xff\x11" ++ "\xE9\xC0\xFF\x2E\x76\x0B\x64\x24" ++ "\x44\x4D\x99\x5A\x12\xD6\x40\xC0" ++ "\xEA\xC2\x84\xE8\x14\x95\xDB\xE8", ++ .klen = 8 + 16 + 24, ++ .iv = "\x7D\x33\x88\x93\x0F\x93\xB2\x42", ++ .assoc = "\x00\x00\x43\x21\x00\x00\x00\x01" ++ "\x7D\x33\x88\x93\x0F\x93\xB2\x42", ++ .alen = 16, ++ .ptext = "\x6f\x54\x20\x6f\x61\x4d\x79\x6e" ++ "\x53\x20\x63\x65\x65\x72\x73\x74" ++ "\x54\x20\x6f\x6f\x4d\x20\x6e\x61" ++ "\x20\x79\x65\x53\x72\x63\x74\x65" ++ "\x20\x73\x6f\x54\x20\x6f\x61\x4d" ++ "\x79\x6e\x53\x20\x63\x65\x65\x72" ++ "\x73\x74\x54\x20\x6f\x6f\x4d\x20" ++ "\x6e\x61\x20\x79\x65\x53\x72\x63" ++ "\x74\x65\x20\x73\x6f\x54\x20\x6f" ++ "\x61\x4d\x79\x6e\x53\x20\x63\x65" ++ "\x65\x72\x73\x74\x54\x20\x6f\x6f" ++ "\x4d\x20\x6e\x61\x20\x79\x65\x53" ++ "\x72\x63\x74\x65\x20\x73\x6f\x54" ++ "\x20\x6f\x61\x4d\x79\x6e\x53\x20" ++ "\x63\x65\x65\x72\x73\x74\x54\x20" ++ "\x6f\x6f\x4d\x20\x6e\x61\x0a\x79", ++ .plen = 128, ++ .ctext = "\x0e\x2d\xb6\x97\x3c\x56\x33\xf4" ++ "\x67\x17\x21\xc7\x6e\x8a\xd5\x49" ++ "\x74\xb3\x49\x05\xc5\x1c\xd0\xed" ++ "\x12\x56\x5c\x53\x96\xb6\x00\x7d" ++ "\x90\x48\xfc\xf5\x8d\x29\x39\xcc" ++ "\x8a\xd5\x35\x18\x36\x23\x4e\xd7" ++ "\x76\xd1\xda\x0c\x94\x67\xbb\x04" ++ "\x8b\xf2\x03\x6c\xa8\xcf\xb6\xea" ++ "\x22\x64\x47\xaa\x8f\x75\x13\xbf" ++ "\x9f\xc2\xc3\xf0\xc9\x56\xc5\x7a" ++ "\x71\x63\x2e\x89\x7b\x1e\x12\xca" ++ "\xe2\x5f\xaf\xd8\xa4\xf8\xc9\x7a" ++ "\xd6\xf9\x21\x31\x62\x44\x45\xa6" ++ "\xd6\xbc\x5a\xd3\x2d\x54\x43\xcc" ++ "\x9d\xde\xa5\x70\xe9\x42\x45\x8a" ++ "\x6b\xfa\xb1\x91\x13\xb0\xd9\x19" ++ "\x99\x09\xfb\x05\x35\xc8\xcc\x38" ++ "\xc3\x1e\x5e\xe1\xe6\x96\x84\xc8", ++ .clen = 128 + 16, ++ }, ++}; ++ + static const struct aead_testvec hmac_sha1_des3_ede_cbc_tv_temp[] = { + { /*Generated with cryptopp*/ + #ifdef __LITTLE_ENDIAN diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/config-6.12 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/config-6.12 new file mode 100755 index 0000000..53bebdd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/config-6.12 @@ -0,0 +1,7831 @@ +# CONFIG_104_QUAD_8 is not set +CONFIG_32BIT=y +# CONFIG_6LOWPAN is not set +# CONFIG_6LOWPAN_DEBUGFS is not set +# CONFIG_6PACK is not set +# CONFIG_8139CP is not set +# CONFIG_8139TOO is not set +# CONFIG_9P_FS is not set +# CONFIG_AB8500_CORE is not set +# CONFIG_ABP060MG is not set +# CONFIG_ABX500_CORE is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_ACENIC is not set +# CONFIG_ACERHDF is not set +# CONFIG_ACER_WIRELESS is not set +# CONFIG_ACER_WMI is not set +# CONFIG_ACORN_PARTITION is not set +# CONFIG_ACPI_AGDI is not set +# CONFIG_ACPI_ALS is not set +# CONFIG_ACPI_APEI is not set +# CONFIG_ACPI_APEI_PCIEAER is not set +# CONFIG_ACPI_BUTTON is not set +# CONFIG_ACPI_CONFIGFS is not set +# CONFIG_ACPI_EXTLOG is not set +# CONFIG_ACPI_HED is not set +# CONFIG_ACPI_NFIT is not set +# CONFIG_ACPI_REDUCED_HARDWARE_ONLY is not set +# CONFIG_ACPI_TABLE_UPGRADE is not set +# CONFIG_ACPI_TOSHIBA is not set +# CONFIG_ACPI_VIDEO is not set +# CONFIG_AD2S1200 is not set +# CONFIG_AD2S1210 is not set +# CONFIG_AD2S90 is not set +# CONFIG_AD3552R is not set +# CONFIG_AD4000 is not set +# CONFIG_AD4130 is not set +# CONFIG_AD4695 is not set +# CONFIG_AD5064 is not set +# CONFIG_AD5110 is not set +# CONFIG_AD525X_DPOT is not set +# CONFIG_AD5272 is not set +# CONFIG_AD5360 is not set +# CONFIG_AD5380 is not set +# CONFIG_AD5421 is not set +# CONFIG_AD5446 is not set +# CONFIG_AD5449 is not set +# CONFIG_AD5504 is not set +# CONFIG_AD5592R is not set +# CONFIG_AD5593R is not set +# CONFIG_AD5624R_SPI is not set +# CONFIG_AD5686 is not set +# CONFIG_AD5686_SPI is not set +# CONFIG_AD5696_I2C is not set +# CONFIG_AD5755 is not set +# CONFIG_AD5758 is not set +# CONFIG_AD5761 is not set +# CONFIG_AD5764 is not set +# CONFIG_AD5766 is not set +# CONFIG_AD5770R is not set +# CONFIG_AD5791 is not set +# CONFIG_AD5933 is not set +# CONFIG_AD7091R5 is not set +# CONFIG_AD7091R8 is not set +# CONFIG_AD7124 is not set +# CONFIG_AD7150 is not set +# CONFIG_AD7173 is not set +# CONFIG_AD7192 is not set +# CONFIG_AD7266 is not set +# CONFIG_AD7280 is not set +# CONFIG_AD7291 is not set +# CONFIG_AD7292 is not set +# CONFIG_AD7293 is not set +# CONFIG_AD7298 is not set +# CONFIG_AD7303 is not set +# CONFIG_AD7380 is not set +# CONFIG_AD74115 is not set +# CONFIG_AD74413R is not set +# CONFIG_AD7476 is not set +# CONFIG_AD7606 is not set +# CONFIG_AD7606_IFACE_PARALLEL is not set +# CONFIG_AD7606_IFACE_SPI is not set +# CONFIG_AD7746 is not set +# CONFIG_AD7766 is not set +# CONFIG_AD7768_1 is not set +# CONFIG_AD7780 is not set +# CONFIG_AD7791 is not set +# CONFIG_AD7793 is not set +# CONFIG_AD7816 is not set +# CONFIG_AD7887 is not set +# CONFIG_AD7923 is not set +# CONFIG_AD7944 is not set +# CONFIG_AD7949 is not set +# CONFIG_AD799X is not set +# CONFIG_AD8366 is not set +# CONFIG_AD8801 is not set +# CONFIG_AD9467 is not set +# CONFIG_AD9523 is not set +# CONFIG_AD9739A is not set +# CONFIG_AD9832 is not set +# CONFIG_AD9834 is not set +# CONFIG_ADA4250 is not set +# CONFIG_ADAPTEC_STARFIRE is not set +# CONFIG_ADF4350 is not set +# CONFIG_ADF4371 is not set +# CONFIG_ADF4377 is not set +# CONFIG_ADFS_FS is not set +# CONFIG_ADIN1100_PHY is not set +# CONFIG_ADIN1110 is not set +# CONFIG_ADIN_PHY is not set +# CONFIG_ADIS16080 is not set +# CONFIG_ADIS16130 is not set +# CONFIG_ADIS16136 is not set +# CONFIG_ADIS16201 is not set +# CONFIG_ADIS16203 is not set +# CONFIG_ADIS16209 is not set +# CONFIG_ADIS16240 is not set +# CONFIG_ADIS16260 is not set +# CONFIG_ADIS16400 is not set +# CONFIG_ADIS16460 is not set +# CONFIG_ADIS16475 is not set +# CONFIG_ADIS16480 is not set +# CONFIG_ADI_AXI_ADC is not set +# CONFIG_ADI_AXI_DAC is not set +# CONFIG_ADJD_S311 is not set +# CONFIG_ADM6996_PHY is not set +# CONFIG_ADM8211 is not set +# CONFIG_ADMFM2000 is not set +# CONFIG_ADMV1013 is not set +# CONFIG_ADMV1014 is not set +# CONFIG_ADMV4420 is not set +# CONFIG_ADMV8818 is not set +# CONFIG_ADRF6780 is not set +# CONFIG_ADT7316 is not set +# CONFIG_ADUX1020 is not set +CONFIG_ADVISE_SYSCALLS=y +# CONFIG_ADXL313_I2C is not set +# CONFIG_ADXL313_SPI is not set +# CONFIG_ADXL345_I2C is not set +# CONFIG_ADXL345_SPI is not set +# CONFIG_ADXL355_I2C is not set +# CONFIG_ADXL355_SPI is not set +# CONFIG_ADXL367_I2C is not set +# CONFIG_ADXL367_SPI is not set +# CONFIG_ADXL372_I2C is not set +# CONFIG_ADXL372_SPI is not set +# CONFIG_ADXL380_I2C is not set +# CONFIG_ADXL380_SPI is not set +# CONFIG_ADXRS290 is not set +# CONFIG_ADXRS450 is not set +CONFIG_AEABI=y +# CONFIG_AF8133J is not set +# CONFIG_AFE4403 is not set +# CONFIG_AFE4404 is not set +# CONFIG_AFFS_FS is not set +# CONFIG_AFS_DEBUG_CURSOR is not set +# CONFIG_AFS_FS is not set +# CONFIG_AF_KCM is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_AF_RXRPC_INJECT_LOSS is not set +# CONFIG_AF_RXRPC_INJECT_RX_DELAY is not set +# CONFIG_AF_RXRPC_IPV6 is not set +CONFIG_AF_UNIX_OOB=y +# CONFIG_AGP is not set +# CONFIG_AHCI_BRCM is not set +# CONFIG_AHCI_CEVA is not set +# CONFIG_AHCI_DWC is not set +# CONFIG_AHCI_IMX is not set +# CONFIG_AHCI_MVEBU is not set +# CONFIG_AHCI_QORIQ is not set +# CONFIG_AHCI_XGENE is not set +CONFIG_AIO=y +# CONFIG_AIR_EN8811H_PHY is not set +# CONFIG_AIX_PARTITION is not set +# CONFIG_AK09911 is not set +# CONFIG_AK8974 is not set +# CONFIG_AK8975 is not set +# CONFIG_AL3010 is not set +# CONFIG_AL3320A is not set +# CONFIG_ALIM7101_WDT is not set +CONFIG_ALLOW_DEV_COREDUMP=y +# CONFIG_ALTERA_MBOX is not set +# CONFIG_ALTERA_MSGDMA is not set +# CONFIG_ALTERA_STAPL is not set +# CONFIG_ALTERA_TSE is not set +# CONFIG_ALX is not set +# CONFIG_AL_FIC is not set +# CONFIG_AM2315 is not set +# CONFIG_AM335X_PHY_USB is not set +# CONFIG_AMBA_PL08X is not set +# CONFIG_AMD8111_ETH is not set +# CONFIG_AMD_MEM_ENCRYPT is not set +# CONFIG_AMD_PHY is not set +# CONFIG_AMD_QDMA is not set +# CONFIG_AMD_XGBE is not set +# CONFIG_AMD_XGBE_HAVE_ECC is not set +# CONFIG_AMIGA_PARTITION is not set +# CONFIG_AMILO_RFKILL is not set +# CONFIG_AMPERE_ERRATUM_AC03_CPU_38 is not set +# CONFIG_AMT is not set +# CONFIG_ANDROID_BINDER_IPC is not set +# CONFIG_ANON_VMA_NAME is not set +# CONFIG_AOSONG_AGS02MA is not set +# CONFIG_APDS9300 is not set +# CONFIG_APDS9306 is not set +# CONFIG_APDS9802ALS is not set +# CONFIG_APDS9960 is not set +# CONFIG_APM_EMULATION is not set +# CONFIG_APPLE_GMUX is not set +# CONFIG_APPLE_MFI_FASTCHARGE is not set +# CONFIG_APPLE_PROPERTIES is not set +# CONFIG_APPLICOM is not set +# CONFIG_AQTION is not set +# CONFIG_AQUANTIA_PHY is not set +# CONFIG_AR5523 is not set +# CONFIG_AR8216_PHY is not set +# CONFIG_AR8216_PHY_LEDS is not set +# CONFIG_ARCH_ACTIONS is not set +# CONFIG_ARCH_AIROHA is not set +# CONFIG_ARCH_ALPINE is not set +# CONFIG_ARCH_APPLE is not set +# CONFIG_ARCH_ARTPEC is not set +# CONFIG_ARCH_ASPEED is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_AXXIA is not set +# CONFIG_ARCH_BCM is not set +# CONFIG_ARCH_BCM2835 is not set +# CONFIG_ARCH_BCMBCA is not set +# CONFIG_ARCH_BCM_21664 is not set +# CONFIG_ARCH_BCM_23550 is not set +# CONFIG_ARCH_BCM_281XX is not set +# CONFIG_ARCH_BCM_5301X is not set +# CONFIG_ARCH_BCM_53573 is not set +# CONFIG_ARCH_BCM_CYGNUS is not set +# CONFIG_ARCH_BCM_HR2 is not set +# CONFIG_ARCH_BCM_IPROC is not set +# CONFIG_ARCH_BCM_NSP is not set +# CONFIG_ARCH_BERLIN is not set +CONFIG_ARCH_BINFMT_ELF_STATE=y +# CONFIG_ARCH_BITMAIN is not set +# CONFIG_ARCH_BRCMSTB is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_DAVINCI is not set +CONFIG_ARCH_DEFAULT_CRASH_DUMP=y +# CONFIG_ARCH_DIGICOLOR is not set +# CONFIG_ARCH_DMA_ADDR_T_64BIT is not set +# CONFIG_ARCH_DOVE is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_EXYNOS is not set +CONFIG_ARCH_FLATMEM_ENABLE=y +# CONFIG_ARCH_FOOTBRIDGE is not set +CONFIG_ARCH_FORCE_MAX_ORDER=11 +# CONFIG_ARCH_GEMINI is not set +# CONFIG_ARCH_HI3xxx is not set +# CONFIG_ARCH_HIGHBANK is not set +# CONFIG_ARCH_HISI is not set +# CONFIG_ARCH_HPE is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_INTEL_SOCFPGA is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_K3 is not set +# CONFIG_ARCH_KEEMBAY is not set +# CONFIG_ARCH_KEYSTONE is not set +# CONFIG_ARCH_LAYERSCAPE is not set +# CONFIG_ARCH_LG1K is not set +# CONFIG_ARCH_LPC32XX is not set +# CONFIG_ARCH_MA35 is not set +# CONFIG_ARCH_MEDIATEK is not set +# CONFIG_ARCH_MESON is not set +# CONFIG_ARCH_MILBEAUT is not set +CONFIG_ARCH_MMAP_RND_BITS=8 +CONFIG_ARCH_MMAP_RND_BITS_MAX=16 +CONFIG_ARCH_MMAP_RND_BITS_MIN=8 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8 +# CONFIG_ARCH_MMP is not set +# CONFIG_ARCH_MSTARV7 is not set +# CONFIG_ARCH_MULTIPLATFORM is not set +# CONFIG_ARCH_MULTI_V6 is not set +# CONFIG_ARCH_MULTI_V7 is not set +# CONFIG_ARCH_MV78XX0 is not set +# CONFIG_ARCH_MVEBU is not set +# CONFIG_ARCH_MXC is not set +# CONFIG_ARCH_MXS is not set +# CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set +# CONFIG_ARCH_NOMADIK is not set +# CONFIG_ARCH_NPCM is not set +# CONFIG_ARCH_NSPIRE is not set +# CONFIG_ARCH_NXP is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_OMAP1 is not set +# CONFIG_ARCH_OMAP2 is not set +# CONFIG_ARCH_OMAP2PLUS is not set +# CONFIG_ARCH_OMAP3 is not set +# CONFIG_ARCH_OMAP4 is not set +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PENSANDO is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_QCOM is not set +# CONFIG_ARCH_RDA is not set +# CONFIG_ARCH_REALTEK is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_RENESAS is not set +# CONFIG_ARCH_ROCKCHIP is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_S32 is not set +# CONFIG_ARCH_S3C64XX is not set +# CONFIG_ARCH_S5PV210 is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_SEATTLE is not set +# CONFIG_ARCH_SHMOBILE is not set +# CONFIG_ARCH_SPARX5 is not set +# CONFIG_ARCH_SPRD is not set +# CONFIG_ARCH_STI is not set +# CONFIG_ARCH_STM32 is not set +# CONFIG_ARCH_SUNPLUS is not set +# CONFIG_ARCH_SUNXI is not set +# CONFIG_ARCH_SYNQUACER is not set +# CONFIG_ARCH_TEGRA is not set +# CONFIG_ARCH_THUNDER is not set +# CONFIG_ARCH_THUNDER2 is not set +# CONFIG_ARCH_U8500 is not set +# CONFIG_ARCH_UNIPHIER is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_VEXPRESS is not set +# CONFIG_ARCH_VIRT is not set +# CONFIG_ARCH_VISCONTI is not set +# CONFIG_ARCH_VT8500 is not set +# CONFIG_ARCH_WANTS_THP_SWAP is not set +# CONFIG_ARCH_WM8505 is not set +# CONFIG_ARCH_WM8750 is not set +# CONFIG_ARCH_WM8850 is not set +# CONFIG_ARCH_XGENE is not set +# CONFIG_ARCH_ZYNQ is not set +# CONFIG_ARCH_ZYNQMP is not set +# CONFIG_ARCNET is not set +# CONFIG_ARC_IRQ_NO_AUTOSAVE is not set +# CONFIG_ARM64_16K_PAGES is not set +# CONFIG_ARM64_64K_PAGES is not set +# CONFIG_ARM64_AMU_EXTN is not set +# CONFIG_ARM64_BTI is not set +CONFIG_ARM64_CNP=y +# CONFIG_ARM64_CONTPTE is not set +# CONFIG_ARM64_E0PD is not set +# CONFIG_ARM64_EPAN is not set +# CONFIG_ARM64_ERRATUM_1024718 is not set +# CONFIG_ARM64_ERRATUM_1165522 is not set +# CONFIG_ARM64_ERRATUM_1286807 is not set +# CONFIG_ARM64_ERRATUM_1319367 is not set +# CONFIG_ARM64_ERRATUM_1418040 is not set +# CONFIG_ARM64_ERRATUM_1463225 is not set +# CONFIG_ARM64_ERRATUM_1508412 is not set +# CONFIG_ARM64_ERRATUM_1530923 is not set +# CONFIG_ARM64_ERRATUM_1542419 is not set +# CONFIG_ARM64_ERRATUM_1742098 is not set +# CONFIG_ARM64_ERRATUM_2051678 is not set +# CONFIG_ARM64_ERRATUM_2054223 is not set +# CONFIG_ARM64_ERRATUM_2067961 is not set +# CONFIG_ARM64_ERRATUM_2077057 is not set +# CONFIG_ARM64_ERRATUM_2441007 is not set +# CONFIG_ARM64_ERRATUM_2441009 is not set +# CONFIG_ARM64_ERRATUM_2645198 is not set +# CONFIG_ARM64_ERRATUM_2658417 is not set +# CONFIG_ARM64_ERRATUM_2966298 is not set +# CONFIG_ARM64_ERRATUM_3117295 is not set +# CONFIG_ARM64_ERRATUM_3194386 is not set +# CONFIG_ARM64_ERRATUM_819472 is not set +# CONFIG_ARM64_ERRATUM_824069 is not set +# CONFIG_ARM64_ERRATUM_826319 is not set +# CONFIG_ARM64_ERRATUM_827319 is not set +# CONFIG_ARM64_ERRATUM_832075 is not set +# CONFIG_ARM64_ERRATUM_834220 is not set +# CONFIG_ARM64_ERRATUM_843419 is not set +# CONFIG_ARM64_ERRATUM_845719 is not set +# CONFIG_ARM64_ERRATUM_858921 is not set +# CONFIG_ARM64_HW_AFDBM is not set +# CONFIG_ARM64_LSE_ATOMICS is not set +# CONFIG_ARM64_MTE is not set +CONFIG_ARM64_PAN=y +# CONFIG_ARM64_PMEM is not set +# CONFIG_ARM64_POE is not set +# CONFIG_ARM64_PSEUDO_NMI is not set +# CONFIG_ARM64_PTR_AUTH is not set +# CONFIG_ARM64_RAS_EXTN is not set +# CONFIG_ARM64_RELOC_TEST is not set +# CONFIG_ARM64_SME is not set +# CONFIG_ARM64_SVE is not set +CONFIG_ARM64_SW_TTBR0_PAN=y +# CONFIG_ARM64_TLB_RANGE is not set +# CONFIG_ARM64_USE_LSE_ATOMICS is not set +# CONFIG_ARM64_VA_BITS_48 is not set +# CONFIG_ARM64_VA_BITS_52 is not set +# CONFIG_ARM_APPENDED_DTB is not set +# CONFIG_ARM_ARCH_TIMER is not set +# CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND is not set +# CONFIG_ARM_CCI is not set +# CONFIG_ARM_CCI400_PMU is not set +# CONFIG_ARM_CCI5xx_PMU is not set +# CONFIG_ARM_CCI_PMU is not set +# CONFIG_ARM_CCN is not set +# CONFIG_ARM_CMN is not set +# CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU is not set +# CONFIG_ARM_CPUIDLE is not set +CONFIG_ARM_CPU_TOPOLOGY=y +# CONFIG_ARM_DEBUG_WX is not set +CONFIG_ARM_DMA_MEM_BUFFERABLE=y +# CONFIG_ARM_DSU_PMU is not set +# CONFIG_ARM_ERRATA_326103 is not set +# CONFIG_ARM_ERRATA_364296 is not set +# CONFIG_ARM_ERRATA_411920 is not set +# CONFIG_ARM_ERRATA_430973 is not set +# CONFIG_ARM_ERRATA_458693 is not set +# CONFIG_ARM_ERRATA_460075 is not set +# CONFIG_ARM_ERRATA_643719 is not set +# CONFIG_ARM_ERRATA_720789 is not set +# CONFIG_ARM_ERRATA_742230 is not set +# CONFIG_ARM_ERRATA_742231 is not set +# CONFIG_ARM_ERRATA_743622 is not set +# CONFIG_ARM_ERRATA_751472 is not set +# CONFIG_ARM_ERRATA_754322 is not set +# CONFIG_ARM_ERRATA_754327 is not set +# CONFIG_ARM_ERRATA_764319 is not set +# CONFIG_ARM_ERRATA_764369 is not set +# CONFIG_ARM_ERRATA_773022 is not set +# CONFIG_ARM_ERRATA_775420 is not set +# CONFIG_ARM_ERRATA_798181 is not set +# CONFIG_ARM_ERRATA_814220 is not set +# CONFIG_ARM_ERRATA_818325_852422 is not set +# CONFIG_ARM_ERRATA_821420 is not set +# CONFIG_ARM_ERRATA_825619 is not set +# CONFIG_ARM_ERRATA_852421 is not set +# CONFIG_ARM_ERRATA_852423 is not set +# CONFIG_ARM_ERRATA_857271 is not set +# CONFIG_ARM_ERRATA_857272 is not set +# CONFIG_ARM_FFA_TRANSPORT is not set +CONFIG_ARM_GIC_MAX_NR=1 +# CONFIG_ARM_KIRKWOOD_CPUFREQ is not set +# CONFIG_ARM_KPROBES_TEST is not set +# CONFIG_ARM_LPAE is not set +# CONFIG_ARM_MEDIATEK_CPUFREQ_HW is not set +# CONFIG_ARM_MHU is not set +CONFIG_ARM_MODULE_PLTS=y +# CONFIG_ARM_NI is not set +# CONFIG_ARM_PAN is not set +# CONFIG_ARM_PATCH_PHYS_VIRT is not set +# CONFIG_ARM_PSCI is not set +# CONFIG_ARM_PSCI_CHECKER is not set +# CONFIG_ARM_PSCI_CPUIDLE is not set +# CONFIG_ARM_PTDUMP_DEBUGFS is not set +# CONFIG_ARM_SBSA_WATCHDOG is not set +# CONFIG_ARM_SCMI_PROTOCOL is not set +# CONFIG_ARM_SCPI_PROTOCOL is not set +# CONFIG_ARM_SDE_INTERFACE is not set +# CONFIG_ARM_SMCCC_SOC_ID is not set +# CONFIG_ARM_SMC_WATCHDOG is not set +# CONFIG_ARM_SMMU_V3_PMU is not set +# CONFIG_ARM_SP805_WATCHDOG is not set +# CONFIG_ARM_SPE_PMU is not set +# CONFIG_ARM_THUMBEE is not set +# CONFIG_ARM_TIMER_SP804 is not set +# CONFIG_ARM_UNWIND is not set +# CONFIG_ARM_VIRT_EXT is not set +# CONFIG_AS21XXX_PHY is not set +# CONFIG_AS3935 is not set +# CONFIG_AS73211 is not set +# CONFIG_ASM9260_TIMER is not set +# CONFIG_ASN1 is not set +# CONFIG_ASUS_LAPTOP is not set +# CONFIG_ASUS_TF103C_DOCK is not set +# CONFIG_ASUS_WIRELESS is not set +# CONFIG_ASUS_WMI is not set +# CONFIG_ASYMMETRIC_KEY_TYPE is not set +# CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE is not set +# CONFIG_ASYNC_RAID6_TEST is not set +# CONFIG_ASYNC_TX_DMA is not set +# CONFIG_AT76C50X_USB is not set +# CONFIG_AT803X_PHY is not set +# CONFIG_AT91_SAMA5D2_ADC is not set +# CONFIG_ATA is not set +# CONFIG_ATAGS is not set +CONFIG_ATAGS_PROC=y +# CONFIG_ATALK is not set +# CONFIG_ATARI_PARTITION is not set +# CONFIG_ATA_ACPI is not set +CONFIG_ATA_BMDMA=y +# CONFIG_ATA_FORCE is not set +# CONFIG_ATA_GENERIC is not set +# CONFIG_ATA_LEDS is not set +# CONFIG_ATA_NONSTANDARD is not set +# CONFIG_ATA_OVER_ETH is not set +# CONFIG_ATA_PIIX is not set +CONFIG_ATA_SFF=y +# CONFIG_ATA_VERBOSE_ERROR is not set +# CONFIG_ATH10K is not set +# CONFIG_ATH25 is not set +# CONFIG_ATH5K is not set +# CONFIG_ATH6KL is not set +# CONFIG_ATH79 is not set +# CONFIG_ATH9K is not set +# CONFIG_ATH9K_HTC is not set +# CONFIG_ATH_DEBUG is not set +# CONFIG_ATL1 is not set +# CONFIG_ATL1C is not set +# CONFIG_ATL1E is not set +# CONFIG_ATL2 is not set +# CONFIG_ATLAS_EZO_SENSOR is not set +# CONFIG_ATLAS_PH_SENSOR is not set +# CONFIG_ATM is not set +# CONFIG_ATMEL_PIT is not set +# CONFIG_ATMEL_SSC is not set +# CONFIG_ATM_BR2684 is not set +CONFIG_ATM_BR2684_IPFILTER=y +# CONFIG_ATM_CLIP is not set +CONFIG_ATM_CLIP_NO_ICMP=y +# CONFIG_ATM_DRIVERS is not set +# CONFIG_ATM_DUMMY is not set +# CONFIG_ATM_ENI is not set +# CONFIG_ATM_FORE200E is not set +# CONFIG_ATM_HE is not set +# CONFIG_ATM_IA is not set +# CONFIG_ATM_IDT77252 is not set +# CONFIG_ATM_LANAI is not set +# CONFIG_ATM_LANE is not set +# CONFIG_ATM_MPOA is not set +# CONFIG_ATM_NICSTAR is not set +# CONFIG_ATM_SOLOS is not set +# CONFIG_ATM_TCP is not set +# CONFIG_ATOMIC64_SELFTEST is not set +# CONFIG_ATP is not set +# CONFIG_AUDIT is not set +# CONFIG_AUDIT_ARCH_COMPAT_GENERIC is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTO_ZRELADDR is not set +# CONFIG_AUXDISPLAY is not set +# CONFIG_AW96103 is not set +# CONFIG_AX25 is not set +# CONFIG_AX25_DAMA_SLAVE is not set +# CONFIG_AX88796 is not set +# CONFIG_AX88796B_PHY is not set +# CONFIG_AXP20X_ADC is not set +# CONFIG_AXP20X_POWER is not set +# CONFIG_AXP288_ADC is not set +# CONFIG_AXP288_FUEL_GAUGE is not set +# CONFIG_B43 is not set +# CONFIG_B43LEGACY is not set +# CONFIG_B44 is not set +# CONFIG_B53 is not set +# CONFIG_B53_MDIO_DRIVER is not set +# CONFIG_B53_MMAP_DRIVER is not set +# CONFIG_B53_SERDES is not set +# CONFIG_B53_SPI_DRIVER is not set +# CONFIG_B53_SRAB_DRIVER is not set +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set +# CONFIG_BACKLIGHT_APPLE is not set +# CONFIG_BACKLIGHT_ARCXCNN is not set +# CONFIG_BACKLIGHT_BD6107 is not set +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set +# CONFIG_BACKLIGHT_GPIO is not set +# CONFIG_BACKLIGHT_KTD253 is not set +# CONFIG_BACKLIGHT_KTD2801 is not set +# CONFIG_BACKLIGHT_KTZ8866 is not set +# CONFIG_BACKLIGHT_LED is not set +# CONFIG_BACKLIGHT_LM3509 is not set +# CONFIG_BACKLIGHT_LM3630A is not set +# CONFIG_BACKLIGHT_LM3639 is not set +# CONFIG_BACKLIGHT_LP855X is not set +# CONFIG_BACKLIGHT_LV5207LP is not set +# CONFIG_BACKLIGHT_MP3309C is not set +# CONFIG_BACKLIGHT_PANDORA is not set +# CONFIG_BACKLIGHT_PWM is not set +# CONFIG_BACKLIGHT_QCOM_WLED is not set +# CONFIG_BACKLIGHT_SAHARA is not set +# CONFIG_BACKTRACE_SELF_TEST is not set +# CONFIG_BACKTRACE_VERBOSE is not set +# CONFIG_BAREUDP is not set +# CONFIG_BASE_SMALL is not set +# CONFIG_BATMAN_ADV is not set +# CONFIG_BATTERY_BQ27XXX is not set +# CONFIG_BATTERY_BQ27XXX_HDQ is not set +# CONFIG_BATTERY_CW2015 is not set +# CONFIG_BATTERY_DS2760 is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2781 is not set +# CONFIG_BATTERY_DS2782 is not set +# CONFIG_BATTERY_GAUGE_LTC2941 is not set +# CONFIG_BATTERY_GOLDFISH is not set +# CONFIG_BATTERY_LEGO_EV3 is not set +# CONFIG_BATTERY_MAX17040 is not set +# CONFIG_BATTERY_MAX17042 is not set +# CONFIG_BATTERY_MAX1720X is not set +# CONFIG_BATTERY_MAX1721X is not set +# CONFIG_BATTERY_PM8916_BMS_VM is not set +# CONFIG_BATTERY_RT5033 is not set +# CONFIG_BATTERY_SAMSUNG_SDI is not set +# CONFIG_BATTERY_SBS is not set +# CONFIG_BATTERY_UG3105 is not set +# CONFIG_BAYCOM_EPP is not set +# CONFIG_BAYCOM_PAR is not set +# CONFIG_BAYCOM_SER_FDX is not set +# CONFIG_BAYCOM_SER_HDX is not set +# CONFIG_BCACHE is not set +# CONFIG_BCACHEFS_FS is not set +# CONFIG_BCM47XX is not set +# CONFIG_BCM54140_PHY is not set +# CONFIG_BCM63XX is not set +# CONFIG_BCM63XX_PHY is not set +# CONFIG_BCM7038_L1_IRQ is not set +# CONFIG_BCM7038_WDT is not set +# CONFIG_BCM7120_L2_IRQ is not set +# CONFIG_BCM7XXX_PHY is not set +# CONFIG_BCM84881_PHY is not set +# CONFIG_BCM87XX_PHY is not set +# CONFIG_BCMA is not set +# CONFIG_BCMA_DRIVER_GPIO is not set +CONFIG_BCMA_POSSIBLE=y +# CONFIG_BCMGENET is not set +# CONFIG_BCM_IPROC_ADC is not set +# CONFIG_BCM_KONA_USB2_PHY is not set +# CONFIG_BCM_SBA_RAID is not set +# CONFIG_BCM_VK is not set +# CONFIG_BDI_SWITCH is not set +# CONFIG_BE2ISCSI is not set +# CONFIG_BE2NET is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_BGMAC is not set +# CONFIG_BH1745 is not set +# CONFIG_BH1750 is not set +# CONFIG_BH1780 is not set +# CONFIG_BIG_KEYS is not set +# CONFIG_BIG_LITTLE is not set +CONFIG_BINARY_PRINTF=y +CONFIG_BINFMT_ELF=y +# CONFIG_BINFMT_ELF_FDPIC is not set +# CONFIG_BINFMT_FLAT is not set +# CONFIG_BINFMT_MISC is not set +CONFIG_BINFMT_SCRIPT=y +CONFIG_BITREVERSE=y +# CONFIG_BLK_CGROUP_IOCOST is not set +# CONFIG_BLK_CGROUP_IOLATENCY is not set +# CONFIG_BLK_CGROUP_IOPRIO is not set +# CONFIG_BLK_DEBUG_FS is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_3W_XXXX_RAID is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_BSGLIB is not set +# CONFIG_BLK_DEV_COW_COMMON is not set +# CONFIG_BLK_DEV_DM is not set +# CONFIG_BLK_DEV_DRBD is not set +# CONFIG_BLK_DEV_FD is not set +CONFIG_BLK_DEV_INITRD=y +# CONFIG_BLK_DEV_INTEGRITY is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_BLK_DEV_LOOP is not set +CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 +# CONFIG_BLK_DEV_MD is not set +# CONFIG_BLK_DEV_NBD is not set +# CONFIG_BLK_DEV_NULL_BLK is not set +# CONFIG_BLK_DEV_NVME is not set +# CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set +# CONFIG_BLK_DEV_PMEM is not set +# CONFIG_BLK_DEV_RAM is not set +# CONFIG_BLK_DEV_RBD is not set +# CONFIG_BLK_DEV_SD is not set +# CONFIG_BLK_DEV_SR is not set +# CONFIG_BLK_DEV_THROTTLING is not set +# CONFIG_BLK_DEV_UBLK is not set +CONFIG_BLK_DEV_WRITE_MOUNTED=y +# CONFIG_BLK_DEV_ZONED is not set +# CONFIG_BLK_INLINE_ENCRYPTION is not set +# CONFIG_BLK_SED_OPAL is not set +# CONFIG_BLK_WBT is not set +CONFIG_BLOCK=y +# CONFIG_BLOCK_LEGACY_AUTOLOAD is not set +# CONFIG_BLOCK_NOTIFIERS is not set +# CONFIG_BMA180 is not set +# CONFIG_BMA220 is not set +# CONFIG_BMA400 is not set +# CONFIG_BMC150_ACCEL is not set +# CONFIG_BMC150_MAGN is not set +# CONFIG_BMC150_MAGN_I2C is not set +# CONFIG_BMC150_MAGN_SPI is not set +# CONFIG_BME680 is not set +# CONFIG_BMG160 is not set +# CONFIG_BMI088_ACCEL is not set +# CONFIG_BMI160_I2C is not set +# CONFIG_BMI160_SPI is not set +# CONFIG_BMI323_I2C is not set +# CONFIG_BMI323_SPI is not set +# CONFIG_BMIPS_GENERIC is not set +# CONFIG_BMP280 is not set +# CONFIG_BNA is not set +# CONFIG_BNX2 is not set +# CONFIG_BNX2X is not set +# CONFIG_BNX2X_SRIOV is not set +# CONFIG_BNXT is not set +# CONFIG_BONDING is not set +# CONFIG_BOOKE_WDT is not set +CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3 +# CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is not set +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set +# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set +# CONFIG_BOOTTIME_TRACING is not set +# CONFIG_BOOT_CONFIG is not set +# CONFIG_BOOT_PRINTK_DELAY is not set +CONFIG_BOOT_RAW=y +# CONFIG_BOSCH_BNO055_I2C is not set +# CONFIG_BOSCH_BNO055_SERIAL is not set +# CONFIG_BOUNCE is not set +CONFIG_BPF=y +CONFIG_BPF_JIT=y +# CONFIG_BPF_JIT_ALWAYS_ON is not set +CONFIG_BPF_JIT_DEFAULT_ON=y +# CONFIG_BPF_LSM is not set +# CONFIG_BPF_PRELOAD is not set +# CONFIG_BPF_STREAM_PARSER is not set +CONFIG_BPF_SYSCALL=y +CONFIG_BPF_UNPRIV_DEFAULT_OFF=y +# CONFIG_BPQETHER is not set +CONFIG_BQL=y +CONFIG_BRANCH_PROFILE_NONE=y +# CONFIG_BRCMFMAC is not set +# CONFIG_BRCMSMAC is not set +# CONFIG_BRCMSTB_GISB_ARB is not set +# CONFIG_BRCMSTB_L2_IRQ is not set +CONFIG_BRIDGE=y +# CONFIG_BRIDGE_CFM is not set +# CONFIG_BRIDGE_EBT_802_3 is not set +# CONFIG_BRIDGE_EBT_AMONG is not set +# CONFIG_BRIDGE_EBT_ARP is not set +# CONFIG_BRIDGE_EBT_ARPREPLY is not set +# CONFIG_BRIDGE_EBT_BROUTE is not set +# CONFIG_BRIDGE_EBT_DNAT is not set +# CONFIG_BRIDGE_EBT_IP is not set +# CONFIG_BRIDGE_EBT_IP6 is not set +# CONFIG_BRIDGE_EBT_LIMIT is not set +# CONFIG_BRIDGE_EBT_LOG is not set +# CONFIG_BRIDGE_EBT_MARK is not set +# CONFIG_BRIDGE_EBT_MARK_T is not set +# CONFIG_BRIDGE_EBT_NFLOG is not set +# CONFIG_BRIDGE_EBT_PKTTYPE is not set +# CONFIG_BRIDGE_EBT_REDIRECT is not set +# CONFIG_BRIDGE_EBT_SNAT is not set +# CONFIG_BRIDGE_EBT_STP is not set +# CONFIG_BRIDGE_EBT_T_FILTER is not set +# CONFIG_BRIDGE_EBT_T_NAT is not set +# CONFIG_BRIDGE_EBT_VLAN is not set +CONFIG_BRIDGE_IGMP_SNOOPING=y +# CONFIG_BRIDGE_MRP is not set +# CONFIG_BRIDGE_NETFILTER is not set +# CONFIG_BRIDGE_NF_EBTABLES is not set +CONFIG_BRIDGE_VLAN_FILTERING=y +# CONFIG_BROADCOM_PHY is not set +CONFIG_BROKEN_ON_SMP=y +# CONFIG_BSD_DISKLABEL is not set +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_BSD_PROCESS_ACCT_V3 is not set +# CONFIG_BT is not set +# CONFIG_BTRFS_ASSERT is not set +# CONFIG_BTRFS_DEBUG is not set +# CONFIG_BTRFS_FS is not set +# CONFIG_BTRFS_FS_POSIX_ACL is not set +# CONFIG_BTRFS_FS_REF_VERIFY is not set +# CONFIG_BTRFS_FS_RUN_SANITY_TESTS is not set +# CONFIG_BT_AOSPEXT is not set +# CONFIG_BT_ATH3K is not set +# CONFIG_BT_BNEP is not set +CONFIG_BT_BNEP_MC_FILTER=y +CONFIG_BT_BNEP_PROTO_FILTER=y +# CONFIG_BT_BREDR is not set +# CONFIG_BT_CMTP is not set +# CONFIG_BT_FEATURE_DEBUG is not set +# CONFIG_BT_HCIBCM203X is not set +# CONFIG_BT_HCIBCM4377 is not set +# CONFIG_BT_HCIBFUSB is not set +# CONFIG_BT_HCIBLUECARD is not set +# CONFIG_BT_HCIBPA10X is not set +# CONFIG_BT_HCIBT3C is not set +# CONFIG_BT_HCIBTSDIO is not set +# CONFIG_BT_HCIBTUSB is not set +# CONFIG_BT_HCIBTUSB_AUTOSUSPEND is not set +# CONFIG_BT_HCIBTUSB_MTK is not set +CONFIG_BT_HCIBTUSB_POLL_SYNC=y +# CONFIG_BT_HCIBTUSB_RTL is not set +# CONFIG_BT_HCIDTL1 is not set +# CONFIG_BT_HCIUART is not set +# CONFIG_BT_HCIUART_3WIRE is not set +# CONFIG_BT_HCIUART_AG6XX is not set +# CONFIG_BT_HCIUART_AML is not set +# CONFIG_BT_HCIUART_ATH3K is not set +CONFIG_BT_HCIUART_BCSP=y +CONFIG_BT_HCIUART_H4=y +# CONFIG_BT_HCIUART_LL is not set +# CONFIG_BT_HCIUART_MRVL is not set +# CONFIG_BT_HCIUART_QCA is not set +# CONFIG_BT_HCIUART_RTL is not set +# CONFIG_BT_HCIVHCI is not set +# CONFIG_BT_HIDP is not set +# CONFIG_BT_INTEL_PCIE is not set +# CONFIG_BT_LE is not set +# CONFIG_BT_LEDS is not set +CONFIG_BT_LE_L2CAP_ECRED=y +# CONFIG_BT_MRVL is not set +# CONFIG_BT_MSFTEXT is not set +# CONFIG_BT_MTKSDIO is not set +# CONFIG_BT_MTKUART is not set +# CONFIG_BT_NXPUART is not set +# CONFIG_BT_RFCOMM is not set +CONFIG_BT_RFCOMM_TTY=y +# CONFIG_BT_SELFTEST is not set +# CONFIG_BT_VIRTIO is not set +CONFIG_BUG=y +# CONFIG_BUG_ON_DATA_CORRUPTION is not set +CONFIG_BUILDTIME_TABLE_SORT=y +CONFIG_BUILD_SALT="" +# CONFIG_C2PORT is not set +# CONFIG_CACHESTAT_SYSCALL is not set +CONFIG_CACHE_L2X0_PMU=y +# CONFIG_CADENCE_WATCHDOG is not set +# CONFIG_CAIF is not set +# CONFIG_CAN is not set +# CONFIG_CAN_BCM is not set +# CONFIG_CAN_CAN327 is not set +# CONFIG_CAN_CTUCANFD_PCI is not set +# CONFIG_CAN_CTUCANFD_PLATFORM is not set +# CONFIG_CAN_DEBUG_DEVICES is not set +# CONFIG_CAN_DEV is not set +# CONFIG_CAN_ESD_402_PCI is not set +# CONFIG_CAN_ESD_USB is not set +# CONFIG_CAN_ETAS_ES58X is not set +# CONFIG_CAN_F81604 is not set +# CONFIG_CAN_GS_USB is not set +# CONFIG_CAN_GW is not set +# CONFIG_CAN_HI311X is not set +# CONFIG_CAN_IFI_CANFD is not set +# CONFIG_CAN_ISOTP is not set +# CONFIG_CAN_J1939 is not set +# CONFIG_CAN_KVASER_PCIEFD is not set +# CONFIG_CAN_MCBA_USB is not set +# CONFIG_CAN_MCP251XFD is not set +# CONFIG_CAN_M_CAN is not set +# CONFIG_CAN_NETLINK is not set +# CONFIG_CAN_PEAK_PCIEFD is not set +# CONFIG_CAN_RAW is not set +# CONFIG_CAN_RCAR is not set +# CONFIG_CAN_RCAR_CANFD is not set +# CONFIG_CAN_ROCKCHIP_CANFD is not set +# CONFIG_CAN_SLCAN is not set +# CONFIG_CAN_SUN4I is not set +# CONFIG_CAN_UCAN is not set +# CONFIG_CAN_VCAN is not set +# CONFIG_CAN_VXCAN is not set +# CONFIG_CAPI_TRACE is not set +CONFIG_CARDBUS=y +# CONFIG_CARL9170 is not set +# CONFIG_CASSINI is not set +# CONFIG_CAVIUM_CPT is not set +# CONFIG_CAVIUM_ERRATUM_22375 is not set +# CONFIG_CAVIUM_ERRATUM_23144 is not set +# CONFIG_CAVIUM_ERRATUM_23154 is not set +# CONFIG_CAVIUM_ERRATUM_27456 is not set +# CONFIG_CAVIUM_ERRATUM_30115 is not set +# CONFIG_CAVIUM_OCTEON_SOC is not set +# CONFIG_CAVIUM_PTP is not set +# CONFIG_CAVIUM_TX2_ERRATUM_219 is not set +# CONFIG_CB710_CORE is not set +# CONFIG_CC10001_ADC is not set +# CONFIG_CCS811 is not set +CONFIG_CC_CAN_LINK=y +CONFIG_CC_NO_STRINGOP_OVERFLOW=y +CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_CDX_BUS is not set +# CONFIG_CEPH_FS is not set +# CONFIG_CEPH_LIB is not set +# CONFIG_CFG80211 is not set +# CONFIG_CFG80211_CERTIFICATION_ONUS is not set +CONFIG_CFG80211_HEADERS=y +# CONFIG_CGROUPS is not set +# CONFIG_CGROUP_FAVOR_DYNMODS is not set +# CONFIG_CGROUP_MISC is not set +# CONFIG_CHARGER_ADP5061 is not set +# CONFIG_CHARGER_BD99954 is not set +# CONFIG_CHARGER_BQ2415X is not set +# CONFIG_CHARGER_BQ24190 is not set +# CONFIG_CHARGER_BQ24257 is not set +# CONFIG_CHARGER_BQ24735 is not set +# CONFIG_CHARGER_BQ2515X is not set +# CONFIG_CHARGER_BQ256XX is not set +# CONFIG_CHARGER_BQ25890 is not set +# CONFIG_CHARGER_BQ25980 is not set +# CONFIG_CHARGER_DETECTOR_MAX14656 is not set +# CONFIG_CHARGER_GPIO is not set +# CONFIG_CHARGER_ISP1704 is not set +# CONFIG_CHARGER_LP8727 is not set +# CONFIG_CHARGER_LT3651 is not set +# CONFIG_CHARGER_LTC4162L is not set +# CONFIG_CHARGER_MANAGER is not set +# CONFIG_CHARGER_MAX77976 is not set +# CONFIG_CHARGER_MAX8903 is not set +# CONFIG_CHARGER_PM8916_LBC is not set +# CONFIG_CHARGER_QCOM_SMB2 is not set +# CONFIG_CHARGER_QCOM_SMBB is not set +# CONFIG_CHARGER_RT9455 is not set +# CONFIG_CHARGER_RT9467 is not set +# CONFIG_CHARGER_RT9471 is not set +# CONFIG_CHARGER_SBS is not set +# CONFIG_CHARGER_SMB347 is not set +# CONFIG_CHARGER_TWL4030 is not set +# CONFIG_CHARGER_UCS1002 is not set +# CONFIG_CHECKPOINT_RESTORE is not set +# CONFIG_CHELSIO_T1 is not set +# CONFIG_CHELSIO_T3 is not set +# CONFIG_CHELSIO_T4 is not set +# CONFIG_CHELSIO_T4VF is not set +# CONFIG_CHROME_PLATFORMS is not set +# CONFIG_CHR_DEV_SCH is not set +# CONFIG_CHR_DEV_SG is not set +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CICADA_PHY is not set +# CONFIG_CIFS is not set +CONFIG_CIFS_ALLOW_INSECURE_LEGACY=y +# CONFIG_CIFS_COMPRESSION is not set +# CONFIG_CIFS_DEBUG is not set +# CONFIG_CIFS_DEBUG2 is not set +# CONFIG_CIFS_FSCACHE is not set +# CONFIG_CIFS_NFSD_EXPORT is not set +CONFIG_CIFS_POSIX=y +# CONFIG_CIFS_STATS2 is not set +# CONFIG_CIFS_SWN_UPCALL is not set +CONFIG_CIFS_XATTR=y +# CONFIG_CIO_DAC is not set +# CONFIG_CLKSRC_PISTACHIO is not set +# CONFIG_CLKSRC_VERSATILE is not set +# CONFIG_CLK_GFM_LPASS_SM8250 is not set +# CONFIG_CLK_HSDK is not set +# CONFIG_CLK_ICST is not set +# CONFIG_CLK_QORIQ is not set +# CONFIG_CLK_SP810 is not set +# CONFIG_CLK_TWL is not set +CONFIG_CLS_U32_MARK=y +# CONFIG_CLS_U32_PERF is not set +# CONFIG_CM32181 is not set +# CONFIG_CM3232 is not set +# CONFIG_CM3323 is not set +# CONFIG_CM3605 is not set +# CONFIG_CM36651 is not set +# CONFIG_CMA is not set +CONFIG_CMDLINE="" +# CONFIG_CMDLINE_BOOL is not set +# CONFIG_CMDLINE_EXTEND is not set +# CONFIG_CMDLINE_FORCE is not set +# CONFIG_CMDLINE_FROM_BOOTLOADER is not set +# CONFIG_CMDLINE_PARTITION is not set +# CONFIG_CNIC is not set +# CONFIG_CODA_FS is not set +# CONFIG_CODE_PATCHING_SELFTEST is not set +# CONFIG_COMEDI is not set +# CONFIG_COMMON_CLK_AXI_CLKGEN is not set +# CONFIG_COMMON_CLK_BOSTON is not set +# CONFIG_COMMON_CLK_CDCE706 is not set +# CONFIG_COMMON_CLK_CDCE925 is not set +# CONFIG_COMMON_CLK_CS2000_CP is not set +# CONFIG_COMMON_CLK_FIXED_MMIO is not set +# CONFIG_COMMON_CLK_IPROC is not set +# CONFIG_COMMON_CLK_MAX9485 is not set +# CONFIG_COMMON_CLK_MEDIATEK_FHCTL is not set +# CONFIG_COMMON_CLK_MT6765 is not set +# CONFIG_COMMON_CLK_MT8167 is not set +# CONFIG_COMMON_CLK_MT8167_AUDSYS is not set +# CONFIG_COMMON_CLK_MT8167_IMGSYS is not set +# CONFIG_COMMON_CLK_MT8167_MFGCFG is not set +# CONFIG_COMMON_CLK_MT8167_MMSYS is not set +# CONFIG_COMMON_CLK_MT8167_VDECSYS is not set +# CONFIG_COMMON_CLK_MT8188 is not set +# CONFIG_COMMON_CLK_MT8192 is not set +# CONFIG_COMMON_CLK_NXP is not set +# CONFIG_COMMON_CLK_PIC32 is not set +# CONFIG_COMMON_CLK_PISTACHIO is not set +# CONFIG_COMMON_CLK_PWM is not set +# CONFIG_COMMON_CLK_PXA is not set +# CONFIG_COMMON_CLK_QCOM is not set +# CONFIG_COMMON_CLK_RS9_PCIE is not set +# CONFIG_COMMON_CLK_SI514 is not set +# CONFIG_COMMON_CLK_SI521XX is not set +# CONFIG_COMMON_CLK_SI5341 is not set +# CONFIG_COMMON_CLK_SI5351 is not set +# CONFIG_COMMON_CLK_SI544 is not set +# CONFIG_COMMON_CLK_SI570 is not set +# CONFIG_COMMON_CLK_VC3 is not set +# CONFIG_COMMON_CLK_VC5 is not set +# CONFIG_COMMON_CLK_VC7 is not set +# CONFIG_COMMON_CLK_XGENE is not set +# CONFIG_COMMON_CLK_XLNX_CLKWZRD is not set +CONFIG_COMPACTION=y +# CONFIG_COMPAL_LAPTOP is not set +# CONFIG_COMPAT is not set +# CONFIG_COMPAT_BRK is not set +# CONFIG_COMPILE_TEST is not set +# CONFIG_COMPRESSED_INSTALL is not set +# CONFIG_CONFIGFS_FS is not set +# CONFIG_CONNECTOR is not set +CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7 +CONFIG_CONSOLE_LOGLEVEL_QUIET=4 +CONFIG_CONSTRUCTORS=y +# CONFIG_CONTEXT_SWITCH_TRACER is not set +# CONFIG_CORDIC is not set +# CONFIG_COREDUMP is not set +# CONFIG_CORESIGHT is not set +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +# CONFIG_CORTINA_PHY is not set +# CONFIG_COUNTER is not set +# CONFIG_CPA_DEBUG is not set +# CONFIG_CPUFREQ_DT is not set +# CONFIG_CPUFREQ_DT_PLATDEV is not set +# CONFIG_CPU_BIG_ENDIAN is not set +# CONFIG_CPU_BPREDICT_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_FREQ is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set +# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set +# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set +# CONFIG_CPU_FREQ_THERMAL is not set +# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_ICACHE_MISMATCH_WORKAROUND is not set +# CONFIG_CPU_IDLE is not set +# CONFIG_CPU_IDLE_GOV_LADDER is not set +# CONFIG_CPU_IDLE_GOV_MENU is not set +# CONFIG_CPU_IDLE_GOV_TEO is not set +# CONFIG_CPU_IDLE_MULTIPLE_DRIVERS is not set +# CONFIG_CPU_ISOLATION is not set +# CONFIG_CPU_LITTLE_ENDIAN is not set +# CONFIG_CPU_NO_EFFICIENT_FFS is not set +CONFIG_CPU_SW_DOMAIN_PAN=y +# CONFIG_CPU_THERMAL is not set +# CONFIG_CRAMFS is not set +CONFIG_CRAMFS_BLOCKDEV=y +# CONFIG_CRAMFS_MTD is not set +# CONFIG_CRASH_DUMP is not set +# CONFIG_CRASH_HOTPLUG is not set +# CONFIG_CRC16 is not set +CONFIG_CRC32=y +# CONFIG_CRC32_BIT is not set +# CONFIG_CRC32_SARWATE is not set +# CONFIG_CRC32_SELFTEST is not set +# CONFIG_CRC32_SLICEBY4 is not set +CONFIG_CRC32_SLICEBY8=y +# CONFIG_CRC4 is not set +# CONFIG_CRC64 is not set +# CONFIG_CRC64_ROCKSOFT is not set +# CONFIG_CRC7 is not set +# CONFIG_CRC8 is not set +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC_ITU_T is not set +# CONFIG_CRC_T10DIF is not set +# CONFIG_CROSS_MEMORY_ATTACH is not set +# CONFIG_CROS_HPS_I2C is not set +CONFIG_CRYPTO=y +# CONFIG_CRYPTO_842 is not set +CONFIG_CRYPTO_ACOMP2=y +# CONFIG_CRYPTO_ADIANTUM is not set +CONFIG_CRYPTO_AEAD=y +CONFIG_CRYPTO_AEAD2=y +# CONFIG_CRYPTO_AEGIS128 is not set +# CONFIG_CRYPTO_AEGIS128_AESNI_SSE2 is not set +CONFIG_CRYPTO_AES=y +# CONFIG_CRYPTO_AES_ARM is not set +# CONFIG_CRYPTO_AES_ARM64 is not set +# CONFIG_CRYPTO_AES_ARM64_BS is not set +# CONFIG_CRYPTO_AES_ARM64_CE is not set +# CONFIG_CRYPTO_AES_ARM64_CE_BLK is not set +# CONFIG_CRYPTO_AES_ARM64_CE_CCM is not set +# CONFIG_CRYPTO_AES_ARM64_NEON_BLK is not set +# CONFIG_CRYPTO_AES_ARM_BS is not set +# CONFIG_CRYPTO_AES_ARM_CE is not set +# CONFIG_CRYPTO_AES_NI_INTEL is not set +# CONFIG_CRYPTO_AES_RISCV64 is not set +# CONFIG_CRYPTO_AES_TI is not set +CONFIG_CRYPTO_AKCIPHER=y +CONFIG_CRYPTO_AKCIPHER2=y +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_ARIA is not set +# CONFIG_CRYPTO_AUTHENC is not set +# CONFIG_CRYPTO_BLAKE2B is not set +# CONFIG_CRYPTO_BLAKE2B_NEON is not set +# CONFIG_CRYPTO_BLAKE2S_ARM is not set +# CONFIG_CRYPTO_BLAKE2S_X86 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +# CONFIG_CRYPTO_CBC is not set +CONFIG_CRYPTO_CCM=y +# CONFIG_CRYPTO_CHACHA20 is not set +# CONFIG_CRYPTO_CHACHA20POLY1305 is not set +# CONFIG_CRYPTO_CHACHA20_NEON is not set +# CONFIG_CRYPTO_CHACHA20_X86_64 is not set +# CONFIG_CRYPTO_CHACHA_MIPS is not set +# CONFIG_CRYPTO_CHACHA_RISCV64 is not set +# CONFIG_CRYPTO_CMAC is not set +# CONFIG_CRYPTO_CRC32 is not set +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_CRC32C_INTEL is not set +# CONFIG_CRYPTO_CRC32_ARM_CE is not set +# CONFIG_CRYPTO_CRCT10DIF is not set +# CONFIG_CRYPTO_CRCT10DIF_ARM64_CE is not set +# CONFIG_CRYPTO_CRCT10DIF_ARM_CE is not set +# CONFIG_CRYPTO_CRYPTD is not set +CONFIG_CRYPTO_CTR=y +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_CURVE25519 is not set +# CONFIG_CRYPTO_CURVE25519_NEON is not set +# CONFIG_CRYPTO_CURVE25519_X86 is not set +# CONFIG_CRYPTO_DEFLATE is not set +# CONFIG_CRYPTO_DES is not set +# CONFIG_CRYPTO_DEV_AMLOGIC_GXL is not set +# CONFIG_CRYPTO_DEV_ATMEL_AES is not set +# CONFIG_CRYPTO_DEV_ATMEL_AUTHENC is not set +# CONFIG_CRYPTO_DEV_ATMEL_ECC is not set +# CONFIG_CRYPTO_DEV_ATMEL_SHA is not set +# CONFIG_CRYPTO_DEV_ATMEL_SHA204A is not set +# CONFIG_CRYPTO_DEV_ATMEL_TDES is not set +# CONFIG_CRYPTO_DEV_CAVIUM_ZIP is not set +# CONFIG_CRYPTO_DEV_CCP is not set +# CONFIG_CRYPTO_DEV_CCP_DEBUGFS is not set +# CONFIG_CRYPTO_DEV_CCREE is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_CRYPTO_API_DESC is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_INTC is not set +# CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_TEST is not set +# CONFIG_CRYPTO_DEV_HIFN_795X is not set +# CONFIG_CRYPTO_DEV_HISI_SEC is not set +# CONFIG_CRYPTO_DEV_HISI_ZIP is not set +# CONFIG_CRYPTO_DEV_IMGTEC_HASH is not set +# CONFIG_CRYPTO_DEV_MARVELL_CESA is not set +# CONFIG_CRYPTO_DEV_MXS_DCP is not set +# CONFIG_CRYPTO_DEV_NITROX_CNN55XX is not set +# CONFIG_CRYPTO_DEV_OCTEONTX_CPT is not set +# CONFIG_CRYPTO_DEV_QAT_420XX is not set +# CONFIG_CRYPTO_DEV_QAT_4XXX is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXX is not set +# CONFIG_CRYPTO_DEV_QAT_C3XXXVF is not set +# CONFIG_CRYPTO_DEV_QAT_C62X is not set +# CONFIG_CRYPTO_DEV_QAT_C62XVF is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCC is not set +# CONFIG_CRYPTO_DEV_QAT_DH895xCCVF is not set +# CONFIG_CRYPTO_DEV_QCE is not set +# CONFIG_CRYPTO_DEV_S5P is not set +# CONFIG_CRYPTO_DEV_SAFEXCEL is not set +# CONFIG_CRYPTO_DEV_SAHARA is not set +# CONFIG_CRYPTO_DEV_SP_PSP is not set +# CONFIG_CRYPTO_DEV_TALITOS is not set +# CONFIG_CRYPTO_DEV_VIRTIO is not set +# CONFIG_CRYPTO_DH is not set +# CONFIG_CRYPTO_DRBG_CTR is not set +# CONFIG_CRYPTO_DRBG_HASH is not set +# CONFIG_CRYPTO_DRBG_MENU is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_ECDH is not set +# CONFIG_CRYPTO_ECDSA is not set +# CONFIG_CRYPTO_ECHAINIV is not set +# CONFIG_CRYPTO_ECRDSA is not set +# CONFIG_CRYPTO_ESSIV is not set +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_GCM=y +CONFIG_CRYPTO_GHASH=y +# CONFIG_CRYPTO_GHASH_ARM64_CE is not set +# CONFIG_CRYPTO_GHASH_ARM_CE is not set +# CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL is not set +# CONFIG_CRYPTO_GHASH_RISCV64 is not set +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +# CONFIG_CRYPTO_HCTR2 is not set +# CONFIG_CRYPTO_HMAC is not set +# CONFIG_CRYPTO_HW is not set +# CONFIG_CRYPTO_JITTERENTROPY is not set +# CONFIG_CRYPTO_JITTERENTROPY_TESTINTERFACE is not set +# CONFIG_CRYPTO_KEYWRAP is not set +# CONFIG_CRYPTO_KHAZAD is not set +CONFIG_CRYPTO_KPP=y +CONFIG_CRYPTO_KPP2=y +CONFIG_CRYPTO_LIB_AES=y +CONFIG_CRYPTO_LIB_ARC4=y +# CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC is not set +# CONFIG_CRYPTO_LIB_CHACHA is not set +# CONFIG_CRYPTO_LIB_CHACHA20POLY1305 is not set +# CONFIG_CRYPTO_LIB_CURVE25519 is not set +# CONFIG_CRYPTO_LIB_POLY1305 is not set +CONFIG_CRYPTO_LIB_POLY1305_RSIZE=9 +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_LZ4 is not set +# CONFIG_CRYPTO_LZ4HC is not set +# CONFIG_CRYPTO_LZO is not set +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y +# CONFIG_CRYPTO_MD4 is not set +# CONFIG_CRYPTO_MD5 is not set +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_NHPOLY1305_NEON is not set +CONFIG_CRYPTO_NULL=y +CONFIG_CRYPTO_NULL2=y +# CONFIG_CRYPTO_PCBC is not set +CONFIG_CRYPTO_PCRYPT=y +# CONFIG_CRYPTO_POLY1305 is not set +# CONFIG_CRYPTO_POLY1305_ARM is not set +# CONFIG_CRYPTO_POLY1305_MIPS is not set +# CONFIG_CRYPTO_POLY1305_NEON is not set +# CONFIG_CRYPTO_POLY1305_X86_64 is not set +# CONFIG_CRYPTO_POLYVAL_ARM64_CE is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RNG is not set +# CONFIG_CRYPTO_RSA is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SEQIV is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_SHA1 is not set +# CONFIG_CRYPTO_SHA1_ARM is not set +# CONFIG_CRYPTO_SHA1_ARM64_CE is not set +# CONFIG_CRYPTO_SHA1_ARM_CE is not set +# CONFIG_CRYPTO_SHA1_ARM_NEON is not set +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA256_ARM is not set +# CONFIG_CRYPTO_SHA256_ARM64 is not set +# CONFIG_CRYPTO_SHA256_RISCV64 is not set +# CONFIG_CRYPTO_SHA2_ARM64_CE is not set +# CONFIG_CRYPTO_SHA2_ARM_CE is not set +# CONFIG_CRYPTO_SHA3 is not set +# CONFIG_CRYPTO_SHA3_ARM64 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_SHA512_ARM is not set +# CONFIG_CRYPTO_SHA512_ARM64 is not set +# CONFIG_CRYPTO_SHA512_ARM64_CE is not set +# CONFIG_CRYPTO_SHA512_RISCV64 is not set +# CONFIG_CRYPTO_SIMD is not set +CONFIG_CRYPTO_SKCIPHER=y +CONFIG_CRYPTO_SKCIPHER2=y +# CONFIG_CRYPTO_SM3 is not set +# CONFIG_CRYPTO_SM3_ARM64_CE is not set +# CONFIG_CRYPTO_SM3_GENERIC is not set +# CONFIG_CRYPTO_SM3_NEON is not set +# CONFIG_CRYPTO_SM3_RISCV64 is not set +# CONFIG_CRYPTO_SM4 is not set +# CONFIG_CRYPTO_SM4_ARM64_CE is not set +# CONFIG_CRYPTO_SM4_ARM64_CE_BLK is not set +# CONFIG_CRYPTO_SM4_ARM64_CE_CCM is not set +# CONFIG_CRYPTO_SM4_ARM64_CE_GCM is not set +# CONFIG_CRYPTO_SM4_ARM64_NEON_BLK is not set +# CONFIG_CRYPTO_SM4_GENERIC is not set +# CONFIG_CRYPTO_SM4_RISCV64 is not set +# CONFIG_CRYPTO_STREEBOG is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TEST is not set +# CONFIG_CRYPTO_TWOFISH is not set +# CONFIG_CRYPTO_TWOFISH_586 is not set +# CONFIG_CRYPTO_TWOFISH_COMMON is not set +# CONFIG_CRYPTO_USER is not set +# CONFIG_CRYPTO_USER_API_AEAD is not set +# CONFIG_CRYPTO_USER_API_ENABLE_OBSOLETE is not set +# CONFIG_CRYPTO_USER_API_HASH is not set +# CONFIG_CRYPTO_USER_API_RNG is not set +# CONFIG_CRYPTO_USER_API_RNG_CAVP is not set +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set +# CONFIG_CRYPTO_VMAC is not set +# CONFIG_CRYPTO_WP512 is not set +# CONFIG_CRYPTO_XCBC is not set +# CONFIG_CRYPTO_XTS is not set +# CONFIG_CRYPTO_XXHASH is not set +# CONFIG_CRYPTO_ZSTD is not set +# CONFIG_CS5535_MFGPT is not set +# CONFIG_CS89x0 is not set +# CONFIG_CS89x0_PLATFORM is not set +# CONFIG_CSD_LOCK_WAIT_DEBUG is not set +# CONFIG_CUSE is not set +# CONFIG_CW1200 is not set +# CONFIG_CXD2880_SPI_DRV is not set +# CONFIG_CXL_BASE is not set +# CONFIG_CXL_BUS is not set +# CONFIG_CYPRESS_FIRMWARE is not set +# CONFIG_CZNIC_PLATFORMS is not set +# CONFIG_DA280 is not set +# CONFIG_DA311 is not set +# CONFIG_DAMON is not set +# CONFIG_DAVICOM_PHY is not set +# CONFIG_DAX is not set +# CONFIG_DCB is not set +# CONFIG_DDR is not set +# CONFIG_DEBUG_ALIGN_RODATA is not set +# CONFIG_DEBUG_ATOMIC_SLEEP is not set +# CONFIG_DEBUG_BUGVERBOSE is not set +# CONFIG_DEBUG_CGROUP_REF is not set +# CONFIG_DEBUG_DEVRES is not set +# CONFIG_DEBUG_DRIVER is not set +# CONFIG_DEBUG_EFI is not set +# CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B is not set +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set +CONFIG_DEBUG_FS=y +CONFIG_DEBUG_FS_ALLOW_ALL=y +# CONFIG_DEBUG_FS_ALLOW_NONE is not set +# CONFIG_DEBUG_FS_DISALLOW_MOUNT is not set +# CONFIG_DEBUG_GPIO is not set +# CONFIG_DEBUG_HIGHMEM is not set +# CONFIG_DEBUG_ICEDCC is not set +# CONFIG_DEBUG_INFO is not set +# CONFIG_DEBUG_INFO_BTF is not set +CONFIG_DEBUG_INFO_COMPRESSED_NONE=y +# CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set +# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set +# CONFIG_DEBUG_INFO_DWARF4 is not set +# CONFIG_DEBUG_INFO_DWARF5 is not set +CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y +# CONFIG_DEBUG_INFO_NONE is not set +# CONFIG_DEBUG_INFO_REDUCED is not set +# CONFIG_DEBUG_INFO_SPLIT is not set +# CONFIG_DEBUG_IRQFLAGS is not set +CONFIG_DEBUG_KERNEL=y +# CONFIG_DEBUG_KMAP_LOCAL is not set +# CONFIG_DEBUG_KMEMLEAK is not set +# CONFIG_DEBUG_KOBJECT is not set +# CONFIG_DEBUG_KOBJECT_RELEASE is not set +# CONFIG_DEBUG_LIST is not set +# CONFIG_DEBUG_LL is not set +# CONFIG_DEBUG_LL_UART_8250 is not set +# CONFIG_DEBUG_LL_UART_PL01X is not set +# CONFIG_DEBUG_LOCKDEP is not set +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set +# CONFIG_DEBUG_LOCK_ALLOC is not set +# CONFIG_DEBUG_MAPLE_TREE is not set +# CONFIG_DEBUG_MEMORY_INIT is not set +# CONFIG_DEBUG_MISC is not set +# CONFIG_DEBUG_MUTEXES is not set +# CONFIG_DEBUG_NET is not set +# CONFIG_DEBUG_NOTIFIERS is not set +# CONFIG_DEBUG_OBJECTS is not set +# CONFIG_DEBUG_PAGEALLOC is not set +# CONFIG_DEBUG_PAGE_REF is not set +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set +# CONFIG_DEBUG_PER_CPU_MAPS is not set +# CONFIG_DEBUG_PINCTRL is not set +# CONFIG_DEBUG_PLIST is not set +# CONFIG_DEBUG_PREEMPT is not set +# CONFIG_DEBUG_RODATA_TEST is not set +# CONFIG_DEBUG_RSEQ is not set +# CONFIG_DEBUG_RT_MUTEXES is not set +# CONFIG_DEBUG_RWSEMS is not set +# CONFIG_DEBUG_SECTION_MISMATCH is not set +# CONFIG_DEBUG_SEMIHOSTING is not set +# CONFIG_DEBUG_SG is not set +# CONFIG_DEBUG_SHIRQ is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_STACKOVERFLOW is not set +# CONFIG_DEBUG_STACK_USAGE is not set +# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set +# CONFIG_DEBUG_UART_8250_PALMCHIP is not set +# CONFIG_DEBUG_UART_8250_WORD is not set +# CONFIG_DEBUG_UART_FLOW_CONTROL is not set +# CONFIG_DEBUG_USER is not set +# CONFIG_DEBUG_VIRTUAL is not set +# CONFIG_DEBUG_VM is not set +# CONFIG_DEBUG_VM_MAPLE_TREE is not set +# CONFIG_DEBUG_VM_PGFLAGS is not set +# CONFIG_DEBUG_VM_PGTABLE is not set +# CONFIG_DEBUG_VM_RB is not set +# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set +# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set +# CONFIG_DEBUG_WX is not set +# CONFIG_DEBUG_ZBOOT is not set +# CONFIG_DEFAULT_CODEL is not set +CONFIG_DEFAULT_CUBIC=y +# CONFIG_DEFAULT_FQ is not set +CONFIG_DEFAULT_FQ_CODEL=y +# CONFIG_DEFAULT_FQ_PIE is not set +CONFIG_DEFAULT_HOSTNAME="(none)" +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 +CONFIG_DEFAULT_INIT="" +CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 +CONFIG_DEFAULT_NET_SCH="fq_codel" +# CONFIG_DEFAULT_PFIFO_FAST is not set +# CONFIG_DEFAULT_RENO is not set +CONFIG_DEFAULT_SECURITY_DAC=y +# CONFIG_DEFAULT_SECURITY_SELINUX is not set +# CONFIG_DEFAULT_SFQ is not set +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set +# CONFIG_DELL_LAPTOP is not set +# CONFIG_DELL_RBTN is not set +# CONFIG_DELL_SMBIOS is not set +# CONFIG_DELL_SMO8800 is not set +# CONFIG_DEPRECATED_PARAM_STRUCT is not set +# CONFIG_DETECT_HUNG_TASK is not set +# CONFIG_DEVMEM is not set +CONFIG_DEVPORT=y +# CONFIG_DEVTMPFS is not set +# CONFIG_DEVTMPFS_MOUNT is not set +# CONFIG_DEVTMPFS_SAFE is not set +# CONFIG_DEV_DAX is not set +# CONFIG_DHT11 is not set +CONFIG_DIMLIB=y +# CONFIG_DL2K is not set +# CONFIG_DLHL60D is not set +# CONFIG_DLM is not set +# CONFIG_DM9000 is not set +# CONFIG_DM9051 is not set +# CONFIG_DMABUF_DEBUG is not set +# CONFIG_DMABUF_HEAPS is not set +# CONFIG_DMABUF_MOVE_NOTIFY is not set +# CONFIG_DMABUF_SELFTESTS is not set +# CONFIG_DMABUF_SYSFS_STATS is not set +# CONFIG_DMADEVICES is not set +# CONFIG_DMADEVICES_DEBUG is not set +# CONFIG_DMAPOOL_TEST is not set +# CONFIG_DMARD06 is not set +# CONFIG_DMARD09 is not set +# CONFIG_DMARD10 is not set +# CONFIG_DMATEST is not set +# CONFIG_DMA_API_DEBUG is not set +CONFIG_DMA_COHERENT_POOL=y +CONFIG_DMA_DECLARE_COHERENT=y +# CONFIG_DMA_ENGINE is not set +# CONFIG_DMA_FENCE_TRACE is not set +# CONFIG_DMA_JZ4780 is not set +# CONFIG_DMA_MAP_BENCHMARK is not set +CONFIG_DMA_NONCOHERENT_MMAP=y +# CONFIG_DMA_RESTRICTED_POOL is not set +# CONFIG_DMA_SHARED_BUFFER is not set +# CONFIG_DM_AUDIT is not set +# CONFIG_DM_CACHE is not set +# CONFIG_DM_CLONE is not set +# CONFIG_DM_DEBUG is not set +# CONFIG_DM_DELAY is not set +# CONFIG_DM_DUST is not set +# CONFIG_DM_EBS is not set +# CONFIG_DM_ERA is not set +# CONFIG_DM_FLAKEY is not set +# CONFIG_DM_INTEGRITY is not set +# CONFIG_DM_LOG_USERSPACE is not set +# CONFIG_DM_LOG_WRITES is not set +# CONFIG_DM_MULTIPATH is not set +# CONFIG_DM_RAID is not set +# CONFIG_DM_SWITCH is not set +# CONFIG_DM_THIN_PROVISIONING is not set +# CONFIG_DM_UEVENT is not set +# CONFIG_DM_UNSTRIPED is not set +# CONFIG_DM_VDO is not set +# CONFIG_DM_VERITY is not set +# CONFIG_DM_WRITECACHE is not set +# CONFIG_DM_ZERO is not set +# CONFIG_DM_ZONED is not set +# CONFIG_DNET is not set +# CONFIG_DNOTIFY is not set +# CONFIG_DNS_RESOLVER is not set +# CONFIG_DP83640_PHY is not set +# CONFIG_DP83822_PHY is not set +# CONFIG_DP83848_PHY is not set +# CONFIG_DP83867_PHY is not set +# CONFIG_DP83869_PHY is not set +# CONFIG_DP83TC811_PHY is not set +# CONFIG_DP83TD510_PHY is not set +# CONFIG_DP83TG720_PHY is not set +# CONFIG_DPM_WATCHDOG is not set +# CONFIG_DPOT_DAC is not set +# CONFIG_DPS310 is not set +CONFIG_DQL=y +# CONFIG_DRAGONRISE_FF is not set +# CONFIG_DRM is not set +# CONFIG_DRM_ACCEL is not set +# CONFIG_DRM_ACCEL_HABANALABS is not set +# CONFIG_DRM_ACCEL_IVPU is not set +# CONFIG_DRM_ACCEL_QAIC is not set +# CONFIG_DRM_AMDGPU is not set +# CONFIG_DRM_AMDGPU_CIK is not set +# CONFIG_DRM_AMDGPU_SI is not set +# CONFIG_DRM_AMDGPU_USERPTR is not set +# CONFIG_DRM_AMDGPU_WERROR is not set +# CONFIG_DRM_AMD_ACP is not set +# CONFIG_DRM_AMD_DC_SI is not set +# CONFIG_DRM_AMD_ISP is not set +# CONFIG_DRM_AMD_SECURE_DISPLAY is not set +# CONFIG_DRM_ANALOGIX_ANX6345 is not set +# CONFIG_DRM_ANALOGIX_ANX7625 is not set +# CONFIG_DRM_ANALOGIX_ANX78XX is not set +# CONFIG_DRM_ARCPGU is not set +# CONFIG_DRM_ARMADA is not set +# CONFIG_DRM_AST is not set +# CONFIG_DRM_ATMEL_HLCDC is not set +# CONFIG_DRM_BOCHS is not set +# CONFIG_DRM_CDNS_DSI is not set +# CONFIG_DRM_CDNS_MHDP8546 is not set +# CONFIG_DRM_CHIPONE_ICN6211 is not set +# CONFIG_DRM_CHRONTEL_CH7033 is not set +# CONFIG_DRM_CIRRUS_QEMU is not set +# CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS is not set +# CONFIG_DRM_DEBUG_MM is not set +# CONFIG_DRM_DEBUG_MODESET_LOCK is not set +# CONFIG_DRM_DISPLAY_CONNECTOR is not set +# CONFIG_DRM_DISPLAY_DP_AUX_CEC is not set +# CONFIG_DRM_DISPLAY_DP_AUX_CHARDEV is not set +# CONFIG_DRM_DW_HDMI_CEC is not set +# CONFIG_DRM_ETNAVIV is not set +# CONFIG_DRM_EXYNOS is not set +# CONFIG_DRM_FBDEV_EMULATION is not set +# CONFIG_DRM_FBDEV_LEAK_PHYS_SMEM is not set +# CONFIG_DRM_FSL_DCU is not set +# CONFIG_DRM_GM12U320 is not set +# CONFIG_DRM_GMA500 is not set +# CONFIG_DRM_GUD is not set +# CONFIG_DRM_HDLCD is not set +# CONFIG_DRM_HISI_HIBMC is not set +# CONFIG_DRM_HISI_KIRIN is not set +# CONFIG_DRM_I2C_ADV7511 is not set +# CONFIG_DRM_I2C_CH7006 is not set +# CONFIG_DRM_I2C_NXP_TDA9950 is not set +# CONFIG_DRM_I2C_NXP_TDA998X is not set +# CONFIG_DRM_I2C_SIL164 is not set +# CONFIG_DRM_I915 is not set +# CONFIG_DRM_I915_DEBUG_WAKEREF is not set +# CONFIG_DRM_I915_GVT_KVMGT is not set +# CONFIG_DRM_I915_REPLAY_GPU_HANGS_API is not set +# CONFIG_DRM_IMX_LCDIF is not set +# CONFIG_DRM_ITE_IT6505 is not set +# CONFIG_DRM_ITE_IT66121 is not set +# CONFIG_DRM_KOMEDA is not set +# CONFIG_DRM_LIB_RANDOM is not set +# CONFIG_DRM_LIMA is not set +# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set +# CONFIG_DRM_LOGICVC is not set +# CONFIG_DRM_LONTIUM_LT8912B is not set +# CONFIG_DRM_LONTIUM_LT9211 is not set +# CONFIG_DRM_LONTIUM_LT9611 is not set +# CONFIG_DRM_LONTIUM_LT9611UXC is not set +# CONFIG_DRM_LOONGSON is not set +# CONFIG_DRM_LVDS_CODEC is not set +# CONFIG_DRM_MALI_DISPLAY is not set +# CONFIG_DRM_MCDE is not set +# CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW is not set +# CONFIG_DRM_MGAG200 is not set +# CONFIG_DRM_MXSFB is not set +# CONFIG_DRM_NOUVEAU is not set +# CONFIG_DRM_NWL_MIPI_DSI is not set +# CONFIG_DRM_NXP_PTN3460 is not set +# CONFIG_DRM_OFDRM is not set +# CONFIG_DRM_OMAP is not set +# CONFIG_DRM_PANEL_ABT_Y030XX067A is not set +# CONFIG_DRM_PANEL_ARM_VERSATILE is not set +# CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596 is not set +# CONFIG_DRM_PANEL_AUO_A030JTN01 is not set +# CONFIG_DRM_PANEL_BOE_BF060Y8M_AJ0 is not set +# CONFIG_DRM_PANEL_BOE_HIMAX8279D is not set +# CONFIG_DRM_PANEL_BOE_TH101MB31UIG002_28A is not set +# CONFIG_DRM_PANEL_BOE_TV101WUM_LL2 is not set +# CONFIG_DRM_PANEL_BOE_TV101WUM_NL6 is not set +# CONFIG_DRM_PANEL_DSI_CM is not set +# CONFIG_DRM_PANEL_EBBG_FT8719 is not set +# CONFIG_DRM_PANEL_EDP is not set +# CONFIG_DRM_PANEL_ELIDA_KD35T133 is not set +# CONFIG_DRM_PANEL_FEIXIN_K101_IM2BA02 is not set +# CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D is not set +# CONFIG_DRM_PANEL_HIMAX_HX83102 is not set +# CONFIG_DRM_PANEL_HIMAX_HX83112A is not set +# CONFIG_DRM_PANEL_HIMAX_HX8394 is not set +# CONFIG_DRM_PANEL_ILITEK_IL9322 is not set +# CONFIG_DRM_PANEL_ILITEK_ILI9341 is not set +# CONFIG_DRM_PANEL_ILITEK_ILI9805 is not set +# CONFIG_DRM_PANEL_ILITEK_ILI9806E is not set +# CONFIG_DRM_PANEL_ILITEK_ILI9881C is not set +# CONFIG_DRM_PANEL_ILITEK_ILI9882T is not set +# CONFIG_DRM_PANEL_INNOLUX_EJ030NA is not set +# CONFIG_DRM_PANEL_INNOLUX_P079ZCA is not set +# CONFIG_DRM_PANEL_JADARD_JD9365DA_H3 is not set +# CONFIG_DRM_PANEL_JDI_LPM102A188A is not set +# CONFIG_DRM_PANEL_JDI_LT070ME05000 is not set +# CONFIG_DRM_PANEL_JDI_R63452 is not set +# CONFIG_DRM_PANEL_KHADAS_TS050 is not set +# CONFIG_DRM_PANEL_KINGDISPLAY_KD097D04 is not set +# CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W is not set +# CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829 is not set +# CONFIG_DRM_PANEL_LG_LB035Q02 is not set +# CONFIG_DRM_PANEL_LG_LG4573 is not set +# CONFIG_DRM_PANEL_LG_SW43408 is not set +# CONFIG_DRM_PANEL_LINCOLNTECH_LCD197 is not set +# CONFIG_DRM_PANEL_LVDS is not set +# CONFIG_DRM_PANEL_MAGNACHIP_D53E6EA8966 is not set +# CONFIG_DRM_PANEL_MANTIX_MLAF057WE51 is not set +# CONFIG_DRM_PANEL_MIPI_DBI is not set +# CONFIG_DRM_PANEL_NEC_NL8048HL11 is not set +# CONFIG_DRM_PANEL_NEWVISION_NV3051D is not set +# CONFIG_DRM_PANEL_NEWVISION_NV3052C is not set +# CONFIG_DRM_PANEL_NOVATEK_NT35510 is not set +# CONFIG_DRM_PANEL_NOVATEK_NT35560 is not set +# CONFIG_DRM_PANEL_NOVATEK_NT35950 is not set +# CONFIG_DRM_PANEL_NOVATEK_NT36523 is not set +# CONFIG_DRM_PANEL_NOVATEK_NT36672A is not set +# CONFIG_DRM_PANEL_NOVATEK_NT36672E is not set +# CONFIG_DRM_PANEL_NOVATEK_NT39016 is not set +# CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO is not set +# CONFIG_DRM_PANEL_ORISETECH_OTA5601A is not set +# CONFIG_DRM_PANEL_ORISETECH_OTM8009A is not set +# CONFIG_DRM_PANEL_OSD_OSD101T2587_53TS is not set +# CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00 is not set +# CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN is not set +# CONFIG_DRM_PANEL_RAYDIUM_RM67191 is not set +# CONFIG_DRM_PANEL_RAYDIUM_RM68200 is not set +# CONFIG_DRM_PANEL_RAYDIUM_RM692E5 is not set +# CONFIG_DRM_PANEL_RAYDIUM_RM69380 is not set +# CONFIG_DRM_PANEL_RONBO_RB070D30 is not set +# CONFIG_DRM_PANEL_SAMSUNG_ATNA33XC20 is not set +# CONFIG_DRM_PANEL_SAMSUNG_DB7430 is not set +# CONFIG_DRM_PANEL_SAMSUNG_LD9040 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6D16D0 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6D27A1 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6D7AA0 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E3FA7 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E63M0 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01 is not set +# CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0 is not set +# CONFIG_DRM_PANEL_SAMSUNG_SOFEF00 is not set +# CONFIG_DRM_PANEL_SEIKO_43WVF1G is not set +# CONFIG_DRM_PANEL_SHARP_LQ101R1SX01 is not set +# CONFIG_DRM_PANEL_SHARP_LS037V7DW01 is not set +# CONFIG_DRM_PANEL_SHARP_LS043T1LE01 is not set +# CONFIG_DRM_PANEL_SHARP_LS060T1SX01 is not set +# CONFIG_DRM_PANEL_SIMPLE is not set +# CONFIG_DRM_PANEL_SITRONIX_ST7701 is not set +# CONFIG_DRM_PANEL_SITRONIX_ST7703 is not set +# CONFIG_DRM_PANEL_SITRONIX_ST7789V is not set +# CONFIG_DRM_PANEL_SONY_ACX565AKM is not set +# CONFIG_DRM_PANEL_SONY_TD4353_JDI is not set +# CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521 is not set +# CONFIG_DRM_PANEL_STARTEK_KD070FHFID015 is not set +# CONFIG_DRM_PANEL_SYNAPTICS_R63353 is not set +# CONFIG_DRM_PANEL_TDO_TL070WSH30 is not set +# CONFIG_DRM_PANEL_TPO_TD028TTEC1 is not set +# CONFIG_DRM_PANEL_TPO_TD043MTEA1 is not set +# CONFIG_DRM_PANEL_TPO_TPG110 is not set +# CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA is not set +# CONFIG_DRM_PANEL_VISIONOX_R66451 is not set +# CONFIG_DRM_PANEL_VISIONOX_RM69299 is not set +# CONFIG_DRM_PANEL_VISIONOX_VTDR6130 is not set +# CONFIG_DRM_PANEL_WIDECHIPS_WS2401 is not set +# CONFIG_DRM_PANEL_XINPENG_XPP055C272 is not set +# CONFIG_DRM_PANFROST is not set +# CONFIG_DRM_PANIC is not set +# CONFIG_DRM_PANTHOR is not set +# CONFIG_DRM_PARADE_PS8622 is not set +# CONFIG_DRM_PARADE_PS8640 is not set +# CONFIG_DRM_PL111 is not set +# CONFIG_DRM_POWERVR is not set +# CONFIG_DRM_QXL is not set +# CONFIG_DRM_RADEON is not set +# CONFIG_DRM_RADEON_USERPTR is not set +# CONFIG_DRM_RCAR_DW_HDMI is not set +# CONFIG_DRM_RCAR_LVDS is not set +# CONFIG_DRM_RCAR_USE_LVDS is not set +# CONFIG_DRM_RCAR_USE_MIPI_DSI is not set +# CONFIG_DRM_ROCKCHIP is not set +# CONFIG_DRM_SAMSUNG_DSIM is not set +# CONFIG_DRM_SII902X is not set +# CONFIG_DRM_SII9234 is not set +# CONFIG_DRM_SIL_SII8620 is not set +# CONFIG_DRM_SIMPLEDRM is not set +# CONFIG_DRM_SIMPLE_BRIDGE is not set +# CONFIG_DRM_SSD130X is not set +# CONFIG_DRM_STI is not set +# CONFIG_DRM_STM is not set +# CONFIG_DRM_SUN4I is not set +# CONFIG_DRM_THINE_THC63LVD1024 is not set +# CONFIG_DRM_TIDSS is not set +# CONFIG_DRM_TILCDC is not set +# CONFIG_DRM_TI_DLPC3433 is not set +# CONFIG_DRM_TI_SN65DSI83 is not set +# CONFIG_DRM_TI_SN65DSI86 is not set +# CONFIG_DRM_TI_TFP410 is not set +# CONFIG_DRM_TI_TPD12S015 is not set +# CONFIG_DRM_TOSHIBA_TC358762 is not set +# CONFIG_DRM_TOSHIBA_TC358764 is not set +# CONFIG_DRM_TOSHIBA_TC358767 is not set +# CONFIG_DRM_TOSHIBA_TC358768 is not set +# CONFIG_DRM_TOSHIBA_TC358775 is not set +# CONFIG_DRM_TVE200 is not set +# CONFIG_DRM_UDL is not set +# CONFIG_DRM_V3D is not set +# CONFIG_DRM_VBOXVIDEO is not set +# CONFIG_DRM_VC4_HDMI_CEC is not set +# CONFIG_DRM_VGEM is not set +# CONFIG_DRM_VIRTIO_GPU is not set +# CONFIG_DRM_VKMS is not set +# CONFIG_DRM_VMWGFX is not set +# CONFIG_DRM_WERROR is not set +# CONFIG_DRM_XE is not set +# CONFIG_DRM_XEN is not set +# CONFIG_DRM_XEN_FRONTEND is not set +# CONFIG_DS1682 is not set +# CONFIG_DS1803 is not set +# CONFIG_DS4424 is not set +# CONFIG_DST_CACHE is not set +# CONFIG_DTLK is not set +# CONFIG_DUMMY is not set +CONFIG_DUMMY_CONSOLE_COLUMNS=80 +CONFIG_DUMMY_CONSOLE_ROWS=25 +# CONFIG_DUMMY_IRQ is not set +# CONFIG_DVB_A8293 is not set +# CONFIG_DVB_AF9013 is not set +# CONFIG_DVB_AF9033 is not set +# CONFIG_DVB_AS102 is not set +# CONFIG_DVB_ASCOT2E is not set +# CONFIG_DVB_ATBM8830 is not set +# CONFIG_DVB_AU8522_DTV is not set +# CONFIG_DVB_AU8522_V4L is not set +# CONFIG_DVB_B2C2_FLEXCOP_PCI is not set +# CONFIG_DVB_B2C2_FLEXCOP_USB is not set +# CONFIG_DVB_BCM3510 is not set +# CONFIG_DVB_CORE is not set +# CONFIG_DVB_CX22700 is not set +# CONFIG_DVB_CX22702 is not set +# CONFIG_DVB_CX24110 is not set +# CONFIG_DVB_CX24116 is not set +# CONFIG_DVB_CX24117 is not set +# CONFIG_DVB_CX24120 is not set +# CONFIG_DVB_CX24123 is not set +# CONFIG_DVB_CXD2099 is not set +# CONFIG_DVB_CXD2820R is not set +# CONFIG_DVB_CXD2841ER is not set +# CONFIG_DVB_CXD2880 is not set +# CONFIG_DVB_DDBRIDGE is not set +# CONFIG_DVB_DEMUX_SECTION_LOSS_LOG is not set +# CONFIG_DVB_DIB3000MB is not set +# CONFIG_DVB_DIB3000MC is not set +# CONFIG_DVB_DIB7000M is not set +# CONFIG_DVB_DIB7000P is not set +# CONFIG_DVB_DIB8000 is not set +# CONFIG_DVB_DIB9000 is not set +# CONFIG_DVB_DRX39XYJ is not set +# CONFIG_DVB_DRXD is not set +# CONFIG_DVB_DRXK is not set +# CONFIG_DVB_DS3000 is not set +# CONFIG_DVB_DUMMY_FE is not set +# CONFIG_DVB_DYNAMIC_MINORS is not set +# CONFIG_DVB_EC100 is not set +# CONFIG_DVB_FIREDTV is not set +# CONFIG_DVB_HELENE is not set +# CONFIG_DVB_HORUS3A is not set +# CONFIG_DVB_ISL6405 is not set +# CONFIG_DVB_ISL6421 is not set +# CONFIG_DVB_ISL6423 is not set +# CONFIG_DVB_IX2505V is not set +# CONFIG_DVB_L64781 is not set +# CONFIG_DVB_LG2160 is not set +# CONFIG_DVB_LGDT3305 is not set +# CONFIG_DVB_LGDT3306A is not set +# CONFIG_DVB_LGDT330X is not set +# CONFIG_DVB_LGS8GL5 is not set +# CONFIG_DVB_LGS8GXX is not set +# CONFIG_DVB_LNBH25 is not set +# CONFIG_DVB_LNBH29 is not set +# CONFIG_DVB_LNBP21 is not set +# CONFIG_DVB_LNBP22 is not set +# CONFIG_DVB_M88DS3103 is not set +# CONFIG_DVB_M88RS2000 is not set +CONFIG_DVB_MAX_ADAPTERS=16 +# CONFIG_DVB_MB86A16 is not set +# CONFIG_DVB_MB86A20S is not set +# CONFIG_DVB_MMAP is not set +# CONFIG_DVB_MN88443X is not set +# CONFIG_DVB_MN88472 is not set +# CONFIG_DVB_MN88473 is not set +# CONFIG_DVB_MT312 is not set +# CONFIG_DVB_MT352 is not set +# CONFIG_DVB_MXL5XX is not set +# CONFIG_DVB_MXL692 is not set +# CONFIG_DVB_NET is not set +# CONFIG_DVB_NETUP_UNIDVB is not set +# CONFIG_DVB_NGENE is not set +# CONFIG_DVB_NXT200X is not set +# CONFIG_DVB_NXT6000 is not set +# CONFIG_DVB_OR51132 is not set +# CONFIG_DVB_OR51211 is not set +# CONFIG_DVB_PLATFORM_DRIVERS is not set +# CONFIG_DVB_PLL is not set +# CONFIG_DVB_PLUTO2 is not set +# CONFIG_DVB_PT1 is not set +# CONFIG_DVB_PT3 is not set +# CONFIG_DVB_RTL2830 is not set +# CONFIG_DVB_RTL2832 is not set +# CONFIG_DVB_RTL2832_SDR is not set +# CONFIG_DVB_S5H1409 is not set +# CONFIG_DVB_S5H1411 is not set +# CONFIG_DVB_S5H1420 is not set +# CONFIG_DVB_S5H1432 is not set +# CONFIG_DVB_S921 is not set +# CONFIG_DVB_SI2165 is not set +# CONFIG_DVB_SI2168 is not set +# CONFIG_DVB_SI21XX is not set +# CONFIG_DVB_SP2 is not set +# CONFIG_DVB_SP8870 is not set +# CONFIG_DVB_SP887X is not set +# CONFIG_DVB_STB0899 is not set +# CONFIG_DVB_STB6000 is not set +# CONFIG_DVB_STB6100 is not set +# CONFIG_DVB_STV0288 is not set +# CONFIG_DVB_STV0297 is not set +# CONFIG_DVB_STV0299 is not set +# CONFIG_DVB_STV0367 is not set +# CONFIG_DVB_STV0900 is not set +# CONFIG_DVB_STV090x is not set +# CONFIG_DVB_STV0910 is not set +# CONFIG_DVB_STV6110 is not set +# CONFIG_DVB_STV6110x is not set +# CONFIG_DVB_STV6111 is not set +# CONFIG_DVB_TC90522 is not set +# CONFIG_DVB_TDA10021 is not set +# CONFIG_DVB_TDA10023 is not set +# CONFIG_DVB_TDA10048 is not set +# CONFIG_DVB_TDA1004X is not set +# CONFIG_DVB_TDA10071 is not set +# CONFIG_DVB_TDA10086 is not set +# CONFIG_DVB_TDA18271C2DD is not set +# CONFIG_DVB_TDA665x is not set +# CONFIG_DVB_TDA8083 is not set +# CONFIG_DVB_TDA8261 is not set +# CONFIG_DVB_TDA826X is not set +# CONFIG_DVB_TEST_DRIVERS is not set +# CONFIG_DVB_TS2020 is not set +# CONFIG_DVB_TTUSB_BUDGET is not set +# CONFIG_DVB_TTUSB_DEC is not set +# CONFIG_DVB_TUA6100 is not set +# CONFIG_DVB_TUNER_CX24113 is not set +# CONFIG_DVB_TUNER_DIB0070 is not set +# CONFIG_DVB_TUNER_DIB0090 is not set +# CONFIG_DVB_TUNER_ITD1000 is not set +# CONFIG_DVB_ULE_DEBUG is not set +# CONFIG_DVB_USB is not set +# CONFIG_DVB_USB_V2 is not set +# CONFIG_DVB_VES1820 is not set +# CONFIG_DVB_VES1X93 is not set +# CONFIG_DVB_ZD1301_DEMOD is not set +# CONFIG_DVB_ZL10036 is not set +# CONFIG_DVB_ZL10039 is not set +# CONFIG_DVB_ZL10353 is not set +# CONFIG_DWC_PCIE_PMU is not set +# CONFIG_DWC_XLGMAC is not set +# CONFIG_DWMAC_DWC_QOS_ETH is not set +# CONFIG_DWMAC_INTEL_PLAT is not set +# CONFIG_DWMAC_IPQ806X is not set +# CONFIG_DWMAC_LOONGSON is not set +# CONFIG_DWMAC_LPC18XX is not set +# CONFIG_DWMAC_MESON is not set +# CONFIG_DWMAC_ROCKCHIP is not set +# CONFIG_DWMAC_SOCFPGA is not set +# CONFIG_DWMAC_STI is not set +# CONFIG_DW_AXI_DMAC is not set +# CONFIG_DW_DMAC is not set +# CONFIG_DW_DMAC_PCI is not set +# CONFIG_DW_EDMA is not set +# CONFIG_DW_EDMA_PCIE is not set +# CONFIG_DW_WATCHDOG is not set +# CONFIG_DW_XDATA_PCIE is not set +# CONFIG_DYNAMIC_DEBUG is not set +# CONFIG_DYNAMIC_DEBUG_CORE is not set +# CONFIG_E100 is not set +# CONFIG_E1000 is not set +# CONFIG_E1000E is not set +# CONFIG_E1000E_HWTS is not set +# CONFIG_EARLY_PRINTK_8250 is not set +# CONFIG_EARLY_PRINTK_USB_XDBC is not set +# CONFIG_EBC_C384_WDT is not set +# CONFIG_ECHO is not set +# CONFIG_ECRYPT_FS is not set +# CONFIG_EC_LENOVO_YOGA_C630 is not set +# CONFIG_EDAC is not set +# CONFIG_EEEPC_LAPTOP is not set +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_EEPROM_93XX46 is not set +# CONFIG_EEPROM_AT24 is not set +# CONFIG_EEPROM_AT25 is not set +# CONFIG_EEPROM_DIGSY_MTC_CFG is not set +# CONFIG_EEPROM_EE1004 is not set +# CONFIG_EEPROM_IDT_89HPESX is not set +# CONFIG_EEPROM_MAX6875 is not set +# CONFIG_EFI is not set +CONFIG_EFI_PARTITION=y +# CONFIG_EFI_VARS_PSTORE is not set +# CONFIG_EFS_FS is not set +CONFIG_ELFCORE=y +# CONFIG_ELF_CORE is not set +# CONFIG_EMAC_ROCKCHIP is not set +# CONFIG_EM_TIMER_STI is not set +# CONFIG_ENA_ETHERNET is not set +# CONFIG_ENC28J60 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_ENCRYPTED_KEYS is not set +# CONFIG_ENCX24J600 is not set +# CONFIG_ENERGY_MODEL is not set +# CONFIG_ENIC is not set +# CONFIG_ENS160 is not set +# CONFIG_ENS210 is not set +# CONFIG_ENVELOPE_DETECTOR is not set +# CONFIG_EPAPR_PARAVIRT is not set +# CONFIG_EPIC100 is not set +CONFIG_EPOLL=y +# CONFIG_EQUALIZER is not set +# CONFIG_EROFS_FS is not set +# CONFIG_EROFS_FS_BACKED_BY_FILE is not set +# CONFIG_EROFS_FS_DEBUG is not set +# CONFIG_EROFS_FS_ONDEMAND is not set +CONFIG_EROFS_FS_PCPU_KTHREAD=y +CONFIG_EROFS_FS_PCPU_KTHREAD_HIPRI=y +# CONFIG_EROFS_FS_POSIX_ACL is not set +# CONFIG_EROFS_FS_SECURITY is not set +# CONFIG_EROFS_FS_XATTR is not set +# CONFIG_EROFS_FS_ZIP is not set +# CONFIG_EROFS_FS_ZIP_DEFLATE is not set +# CONFIG_EROFS_FS_ZIP_ZSTD is not set +# CONFIG_ET131X is not set +CONFIG_ETHERNET=y +# CONFIG_ETHOC is not set +CONFIG_ETHTOOL_NETLINK=y +CONFIG_EVENTFD=y +# CONFIG_EVM is not set +CONFIG_EXECMEM=y +# CONFIG_EXFAT_FS is not set +CONFIG_EXPERT=y +CONFIG_EXPORTFS=y +# CONFIG_EXPORTFS_BLOCK_OPS is not set +# CONFIG_EXT2_FS is not set +CONFIG_EXT2_FS_XATTR=y +# CONFIG_EXT3_FS is not set +# CONFIG_EXT4_DEBUG is not set +# CONFIG_EXT4_FS is not set +# CONFIG_EXT4_FS_POSIX_ACL is not set +# CONFIG_EXT4_FS_SECURITY is not set +CONFIG_EXT4_USE_FOR_EXT2=y +# CONFIG_EXTCON is not set +# CONFIG_EXTCON_ADC_JACK is not set +# CONFIG_EXTCON_AXP288 is not set +# CONFIG_EXTCON_FSA9480 is not set +# CONFIG_EXTCON_GPIO is not set +# CONFIG_EXTCON_INTEL_INT3496 is not set +# CONFIG_EXTCON_LC824206XA is not set +# CONFIG_EXTCON_MAX3355 is not set +# CONFIG_EXTCON_PTN5150 is not set +# CONFIG_EXTCON_QCOM_SPMI_MISC is not set +# CONFIG_EXTCON_RT8973A is not set +# CONFIG_EXTCON_SM5502 is not set +# CONFIG_EXTCON_USBC_TUSB320 is not set +# CONFIG_EXTCON_USB_GPIO is not set +CONFIG_EXTRA_FIRMWARE="" +CONFIG_EXTRA_TARGETS="" +# CONFIG_EXYNOS_ADC is not set +# CONFIG_EYEQ is not set +# CONFIG_EZCHIP_NPS_MANAGEMENT_ENET is not set +# CONFIG_EZX_PCAP is not set +# CONFIG_F2FS_CHECK_FS is not set +# CONFIG_F2FS_FAULT_INJECTION is not set +# CONFIG_F2FS_FS is not set +# CONFIG_F2FS_FS_COMPRESSION is not set +# CONFIG_F2FS_FS_POSIX_ACL is not set +# CONFIG_F2FS_FS_SECURITY is not set +CONFIG_F2FS_FS_XATTR=y +# CONFIG_F2FS_IOSTAT is not set +CONFIG_F2FS_STAT_FS=y +# CONFIG_F2FS_UNFAIR_RWSEM is not set +# CONFIG_FAILOVER is not set +# CONFIG_FAIR_GROUP_SCHED is not set +# CONFIG_FANOTIFY is not set +# CONFIG_FANOTIFY_ACCESS_PERMISSIONS is not set +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +# CONFIG_FAT_DEFAULT_UTF8 is not set +# CONFIG_FAT_FS is not set +# CONFIG_FAULT_INJECTION is not set +# CONFIG_FB is not set +# CONFIG_FBNIC is not set +# CONFIG_FB_3DFX is not set +# CONFIG_FB_ARC is not set +# CONFIG_FB_ARK is not set +# CONFIG_FB_ASILIANT is not set +# CONFIG_FB_ATMEL is not set +# CONFIG_FB_ATY is not set +# CONFIG_FB_ATY128 is not set +# CONFIG_FB_BACKLIGHT is not set +# CONFIG_FB_BIG_ENDIAN is not set +# CONFIG_FB_BOTH_ENDIAN is not set +# CONFIG_FB_BROADSHEET is not set +# CONFIG_FB_CARMINE is not set +# CONFIG_FB_CFB_COPYAREA is not set +# CONFIG_FB_CFB_FILLRECT is not set +# CONFIG_FB_CFB_IMAGEBLIT is not set +# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set +# CONFIG_FB_CIRRUS is not set +# CONFIG_FB_CYBER2000 is not set +# CONFIG_FB_DDC is not set +# CONFIG_FB_DEVICE is not set +# CONFIG_FB_FOREIGN_ENDIAN is not set +# CONFIG_FB_FSL_DIU is not set +# CONFIG_FB_GEODE is not set +# CONFIG_FB_GOLDFISH is not set +# CONFIG_FB_HGA is not set +# CONFIG_FB_I740 is not set +# CONFIG_FB_IBM_GXT4500 is not set +# CONFIG_FB_IMSTT is not set +# CONFIG_FB_IMX is not set +# CONFIG_FB_KYRO is not set +# CONFIG_FB_LITTLE_ENDIAN is not set +# CONFIG_FB_MACMODES is not set +# CONFIG_FB_MATROX is not set +# CONFIG_FB_MB862XX is not set +# CONFIG_FB_METRONOME is not set +# CONFIG_FB_MODE_HELPERS is not set +# CONFIG_FB_N411 is not set +# CONFIG_FB_NEOMAGIC is not set +CONFIG_FB_NOTIFY=y +# CONFIG_FB_NVIDIA is not set +# CONFIG_FB_OF is not set +# CONFIG_FB_OMAP2 is not set +# CONFIG_FB_OPENCORES is not set +# CONFIG_FB_PM2 is not set +# CONFIG_FB_PM3 is not set +# CONFIG_FB_PS3 is not set +# CONFIG_FB_PXA is not set +# CONFIG_FB_RADEON is not set +# CONFIG_FB_RIVA is not set +# CONFIG_FB_S1D13XXX is not set +# CONFIG_FB_S3 is not set +# CONFIG_FB_SAVAGE is not set +# CONFIG_FB_SIMPLE is not set +# CONFIG_FB_SIS is not set +# CONFIG_FB_SM712 is not set +# CONFIG_FB_SM750 is not set +# CONFIG_FB_SMSCUFX is not set +# CONFIG_FB_SSD1307 is not set +# CONFIG_FB_SVGALIB is not set +# CONFIG_FB_SYS_COPYAREA is not set +# CONFIG_FB_SYS_FILLRECT is not set +# CONFIG_FB_SYS_IMAGEBLIT is not set +# CONFIG_FB_TFT is not set +# CONFIG_FB_TFT_AGM1264K_FL is not set +# CONFIG_FB_TFT_BD663474 is not set +# CONFIG_FB_TFT_HX8340BN is not set +# CONFIG_FB_TFT_HX8347D is not set +# CONFIG_FB_TFT_HX8353D is not set +# CONFIG_FB_TFT_HX8357D is not set +# CONFIG_FB_TFT_ILI9163 is not set +# CONFIG_FB_TFT_ILI9320 is not set +# CONFIG_FB_TFT_ILI9325 is not set +# CONFIG_FB_TFT_ILI9340 is not set +# CONFIG_FB_TFT_ILI9341 is not set +# CONFIG_FB_TFT_ILI9481 is not set +# CONFIG_FB_TFT_ILI9486 is not set +# CONFIG_FB_TFT_PCD8544 is not set +# CONFIG_FB_TFT_RA8875 is not set +# CONFIG_FB_TFT_S6D02A1 is not set +# CONFIG_FB_TFT_S6D1121 is not set +# CONFIG_FB_TFT_SEPS525 is not set +# CONFIG_FB_TFT_SH1106 is not set +# CONFIG_FB_TFT_SSD1289 is not set +# CONFIG_FB_TFT_SSD1305 is not set +# CONFIG_FB_TFT_SSD1306 is not set +# CONFIG_FB_TFT_SSD1331 is not set +# CONFIG_FB_TFT_SSD1351 is not set +# CONFIG_FB_TFT_ST7735R is not set +# CONFIG_FB_TFT_ST7789V is not set +# CONFIG_FB_TFT_TINYLCD is not set +# CONFIG_FB_TFT_TLS8204 is not set +# CONFIG_FB_TFT_UC1611 is not set +# CONFIG_FB_TFT_UC1701 is not set +# CONFIG_FB_TFT_UPD161704 is not set +# CONFIG_FB_TILEBLITTING is not set +# CONFIG_FB_TRIDENT is not set +# CONFIG_FB_UDL is not set +# CONFIG_FB_UVESA is not set +# CONFIG_FB_VGA16 is not set +# CONFIG_FB_VIA is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FB_VOODOO1 is not set +# CONFIG_FB_VT8623 is not set +# CONFIG_FCOE is not set +# CONFIG_FCOE_FNIC is not set +# CONFIG_FDDI is not set +# CONFIG_FEALNX is not set +# CONFIG_FHANDLE is not set +CONFIG_FIB_RULES=y +# CONFIG_FIELDBUS_DEV is not set +CONFIG_FILE_LOCKING=y +# CONFIG_FIND_BIT_BENCHMARK is not set +# CONFIG_FIREWIRE is not set +# CONFIG_FIREWIRE_NOSY is not set +# CONFIG_FIRMWARE_EDID is not set +# CONFIG_FIRMWARE_MEMMAP is not set +# CONFIG_FIXED_PHY is not set +CONFIG_FLATMEM=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_FM10K is not set +# CONFIG_FONTS is not set +# CONFIG_FONT_6x8 is not set +# CONFIG_FONT_TER16x32 is not set +# CONFIG_FORCEDETH is not set +# CONFIG_FORCE_NR_CPUS is not set +CONFIG_FORTIFY_SOURCE=y +# CONFIG_FPGA is not set +# CONFIG_FPROBE is not set +# CONFIG_FRAMEBUFFER_CONSOLE is not set +# CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is not set +# CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION is not set +# CONFIG_FRAME_POINTER is not set +# CONFIG_FREEZER is not set +# CONFIG_FSCACHE is not set +# CONFIG_FSI is not set +# CONFIG_FSL_DPAA2_SWITCH is not set +# CONFIG_FSL_EDMA is not set +# CONFIG_FSL_ENETC is not set +# CONFIG_FSL_ENETC_IERB is not set +# CONFIG_FSL_ENETC_MDIO is not set +# CONFIG_FSL_ENETC_VF is not set +# CONFIG_FSL_ERRATUM_A008585 is not set +# CONFIG_FSL_MC_BUS is not set +# CONFIG_FSL_PQ_MDIO is not set +# CONFIG_FSL_QDMA is not set +# CONFIG_FSL_RCPM is not set +# CONFIG_FSL_XGMAC_MDIO is not set +CONFIG_FSNOTIFY=y +# CONFIG_FS_DAX is not set +# CONFIG_FS_ENCRYPTION is not set +# CONFIG_FS_POSIX_ACL is not set +CONFIG_FS_STACK=y +# CONFIG_FS_VERITY is not set +# CONFIG_FTGMAC100 is not set +# CONFIG_FTL is not set +# CONFIG_FTMAC100 is not set +# CONFIG_FTRACE is not set +# CONFIG_FTRACE_RECORD_RECURSION is not set +# CONFIG_FTRACE_SORT_STARTUP_TEST is not set +# CONFIG_FTRACE_STARTUP_TEST is not set +# CONFIG_FTRACE_VALIDATE_RCU_IS_WATCHING is not set +# CONFIG_FTR_FIXUP_SELFTEST is not set +# CONFIG_FTWDT010_WATCHDOG is not set +# CONFIG_FUEL_GAUGE_MM8013 is not set +# CONFIG_FUJITSU_ERRATUM_010001 is not set +# CONFIG_FUJITSU_ES is not set +# CONFIG_FUJITSU_LAPTOP is not set +# CONFIG_FUJITSU_TABLET is not set +# CONFIG_FUNCTION_ERROR_INJECTION is not set +# CONFIG_FUNCTION_GRAPH_RETVAL is not set +# CONFIG_FUNCTION_TRACER is not set +# CONFIG_FUN_ETH is not set +# CONFIG_FUSE_FS is not set +# CONFIG_FUSE_PASSTHROUGH is not set +# CONFIG_FUSION is not set +# CONFIG_FUSION_FC is not set +# CONFIG_FUSION_SAS is not set +# CONFIG_FUSION_SPI is not set +CONFIG_FUTEX=y +CONFIG_FUTEX_PI=y +# CONFIG_FW_CFG_SYSFS is not set +# CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT is not set +CONFIG_FW_LOADER=y +# CONFIG_FW_LOADER_COMPRESS is not set +# CONFIG_FW_LOADER_DEBUG is not set +CONFIG_FW_LOADER_USER_HELPER=y +CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y +# CONFIG_FW_UPLOAD is not set +# CONFIG_FXAS21002C is not set +# CONFIG_FXLS8962AF_I2C is not set +# CONFIG_FXLS8962AF_SPI is not set +# CONFIG_FXOS8700_I2C is not set +# CONFIG_FXOS8700_SPI is not set +CONFIG_GACT_PROB=y +# CONFIG_GADGET_UAC1 is not set +# CONFIG_GAMEPORT is not set +CONFIG_GCC_NO_STRINGOP_OVERFLOW=y +# CONFIG_GCC_PLUGINS is not set +# CONFIG_GCOV is not set +# CONFIG_GCOV_KERNEL is not set +# CONFIG_GDB_SCRIPTS is not set +# CONFIG_GEMINI_ETHERNET is not set +# CONFIG_GENERIC_ADC_BATTERY is not set +# CONFIG_GENERIC_ADC_THERMAL is not set +CONFIG_GENERIC_CALIBRATE_DELAY=y +# CONFIG_GENERIC_CPU_DEVICES is not set +CONFIG_GENERIC_HWEIGHT=y +# CONFIG_GENERIC_IRQ_DEBUGFS is not set +CONFIG_GENERIC_IRQ_IPI=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_GENERIC_NET_UTILS=y +# CONFIG_GENERIC_PHY is not set +CONFIG_GENERIC_PTDUMP=y +CONFIG_GENERIC_VDSO_TIME_NS=y +# CONFIG_GENEVE is not set +# CONFIG_GENWQE is not set +# CONFIG_GFS2_FS is not set +# CONFIG_GIGABYTE_WMI is not set +# CONFIG_GLOB_SELFTEST is not set +# CONFIG_GNSS is not set +# CONFIG_GOLDFISH is not set +# CONFIG_GOOGLE_CBMEM is not set +# CONFIG_GOOGLE_FIRMWARE is not set +# CONFIG_GOOGLE_FRAMEBUFFER_COREBOOT is not set +# CONFIG_GOOGLE_MEMCONSOLE_X86_LEGACY is not set +# CONFIG_GOOGLE_SMI is not set +# CONFIG_GP2AP002 is not set +# CONFIG_GP2AP020A00F is not set +# CONFIG_GPD_POCKET_FAN is not set +CONFIG_GPIOLIB=y +CONFIG_GPIOLIB_FASTPATH_LIMIT=512 +# CONFIG_GPIO_104_DIO_48E is not set +# CONFIG_GPIO_104_IDIO_16 is not set +# CONFIG_GPIO_104_IDI_48 is not set +# CONFIG_GPIO_74X164 is not set +# CONFIG_GPIO_74XX_MMIO is not set +# CONFIG_GPIO_ADNP is not set +# CONFIG_GPIO_AGGREGATOR is not set +# CONFIG_GPIO_ALTERA is not set +# CONFIG_GPIO_AMD8111 is not set +# CONFIG_GPIO_AMDPT is not set +# CONFIG_GPIO_AMD_FCH is not set +# CONFIG_GPIO_BCM_KONA is not set +# CONFIG_GPIO_BRCMSTB is not set +# CONFIG_GPIO_BT8XX is not set +# CONFIG_GPIO_CADENCE is not set +# CONFIG_GPIO_CDEV is not set +# CONFIG_GPIO_CDEV_V1 is not set +# CONFIG_GPIO_CS5535 is not set +# CONFIG_GPIO_DS4520 is not set +# CONFIG_GPIO_DWAPB is not set +# CONFIG_GPIO_EM is not set +# CONFIG_GPIO_EXAR is not set +# CONFIG_GPIO_F7188X is not set +# CONFIG_GPIO_FTGPIO010 is not set +# CONFIG_GPIO_FXL6408 is not set +# CONFIG_GPIO_GENERIC_PLATFORM is not set +# CONFIG_GPIO_GPIO_MM is not set +# CONFIG_GPIO_GRGPIO is not set +# CONFIG_GPIO_GW_PLD is not set +# CONFIG_GPIO_HISI is not set +# CONFIG_GPIO_HLWD is not set +# CONFIG_GPIO_ICH is not set +# CONFIG_GPIO_IT87 is not set +# CONFIG_GPIO_LATCH is not set +# CONFIG_GPIO_LOGICVC is not set +# CONFIG_GPIO_LINE_MUX is not set +# CONFIG_GPIO_MAX3191X is not set +# CONFIG_GPIO_MAX7300 is not set +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_MB86S7X is not set +# CONFIG_GPIO_MC33880 is not set +# CONFIG_GPIO_ML_IOH is not set +# CONFIG_GPIO_MOCKUP is not set +# CONFIG_GPIO_MPC8XXX is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCA953X_IRQ is not set +# CONFIG_GPIO_PCA9570 is not set +# CONFIG_GPIO_PCF857X is not set +# CONFIG_GPIO_PCH is not set +# CONFIG_GPIO_PCIE_IDIO_24 is not set +# CONFIG_GPIO_PCI_IDIO_16 is not set +# CONFIG_GPIO_PISOSR is not set +# CONFIG_GPIO_PL061 is not set +# CONFIG_GPIO_RCAR is not set +# CONFIG_GPIO_RDC321X is not set +# CONFIG_GPIO_SAMA5D2_PIOBU is not set +# CONFIG_GPIO_SCH is not set +# CONFIG_GPIO_SCH311X is not set +# CONFIG_GPIO_SIFIVE is not set +# CONFIG_GPIO_SIM is not set +# CONFIG_GPIO_SLOPPY_LOGIC_ANALYZER is not set +# CONFIG_GPIO_SYSCON is not set +CONFIG_GPIO_SYSFS=y +# CONFIG_GPIO_TPIC2810 is not set +# CONFIG_GPIO_TS4900 is not set +# CONFIG_GPIO_TS5500 is not set +# CONFIG_GPIO_VIRTIO is not set +# CONFIG_GPIO_VIRTUSER is not set +# CONFIG_GPIO_VX855 is not set +# CONFIG_GPIO_WATCHDOG is not set +# CONFIG_GPIO_WINBOND is not set +# CONFIG_GPIO_WS16C48 is not set +# CONFIG_GPIO_XGENE is not set +# CONFIG_GPIO_XILINX is not set +# CONFIG_GPIO_XRA1403 is not set +# CONFIG_GPIO_ZEVIO is not set +# CONFIG_GP_PCI1XXXX is not set +# CONFIG_GREENASIA_FF is not set +# CONFIG_GREYBUS is not set +# CONFIG_GTP is not set +# CONFIG_GUP_TEST is not set +# CONFIG_GVE is not set +# CONFIG_HAMACHI is not set +# CONFIG_HAMRADIO is not set +# CONFIG_HAPPYMEAL is not set +CONFIG_HARDENED_USERCOPY=y +CONFIG_HARDEN_BRANCH_HISTORY=y +# CONFIG_HARDLOCKUP_DETECTOR is not set +# CONFIG_HAVE_ARM_ARCH_TIMER is not set +# CONFIG_HCALL_STATS is not set +# CONFIG_HDC100X is not set +# CONFIG_HDC2010 is not set +# CONFIG_HDC3020 is not set +# CONFIG_HDLC is not set +# CONFIG_HDLC_CISCO is not set +# CONFIG_HDLC_FR is not set +# CONFIG_HDLC_PPP is not set +# CONFIG_HDLC_RAW is not set +# CONFIG_HDLC_RAW_ETH is not set +# CONFIG_HDMI_LPE_AUDIO is not set +# CONFIG_HDQ_MASTER_OMAP is not set +# CONFIG_HEADERS_INSTALL is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HI6421V600_IRQ is not set +# CONFIG_HI8435 is not set +# CONFIG_HIBERNATION is not set +# CONFIG_HIBERNATION_COMP_LZ4 is not set +# CONFIG_HID is not set +# CONFIG_HIDRAW is not set +# CONFIG_HID_A4TECH is not set +# CONFIG_HID_ACCUTOUCH is not set +# CONFIG_HID_ACRUX is not set +# CONFIG_HID_ACRUX_FF is not set +# CONFIG_HID_ALPS is not set +# CONFIG_HID_APPLE is not set +# CONFIG_HID_APPLEIR is not set +# CONFIG_HID_ASUS is not set +# CONFIG_HID_AUREAL is not set +# CONFIG_HID_BATTERY_STRENGTH is not set +# CONFIG_HID_BELKIN is not set +# CONFIG_HID_BETOP_FF is not set +# CONFIG_HID_BIGBEN_FF is not set +# CONFIG_HID_BPF is not set +# CONFIG_HID_CHERRY is not set +# CONFIG_HID_CHICONY is not set +# CONFIG_HID_CMEDIA is not set +# CONFIG_HID_CORSAIR is not set +# CONFIG_HID_COUGAR is not set +# CONFIG_HID_CP2112 is not set +# CONFIG_HID_CREATIVE_SB0540 is not set +# CONFIG_HID_CYPRESS is not set +# CONFIG_HID_DRAGONRISE is not set +# CONFIG_HID_ELAN is not set +# CONFIG_HID_ELECOM is not set +# CONFIG_HID_ELO is not set +# CONFIG_HID_EMS_FF is not set +# CONFIG_HID_EVISION is not set +# CONFIG_HID_EZKEY is not set +# CONFIG_HID_FT260 is not set +# CONFIG_HID_GEMBIRD is not set +# CONFIG_HID_GENERIC is not set +# CONFIG_HID_GFRM is not set +# CONFIG_HID_GLORIOUS is not set +# CONFIG_HID_GOODIX_SPI is not set +# CONFIG_HID_GOOGLE_HAMMER is not set +# CONFIG_HID_GOOGLE_STADIA_FF is not set +# CONFIG_HID_GREENASIA is not set +# CONFIG_HID_GT683R is not set +# CONFIG_HID_GYRATION is not set +# CONFIG_HID_HOLTEK is not set +# CONFIG_HID_ICADE is not set +# CONFIG_HID_ITE is not set +# CONFIG_HID_JABRA is not set +# CONFIG_HID_KENSINGTON is not set +# CONFIG_HID_KEYTOUCH is not set +# CONFIG_HID_KYE is not set +# CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LED is not set +# CONFIG_HID_LENOVO is not set +# CONFIG_HID_LETSKETCH is not set +# CONFIG_HID_LOGITECH is not set +# CONFIG_HID_LOGITECH_DJ is not set +# CONFIG_HID_LOGITECH_HIDPP is not set +# CONFIG_HID_MACALLY is not set +# CONFIG_HID_MAGICMOUSE is not set +# CONFIG_HID_MALTRON is not set +# CONFIG_HID_MAYFLASH is not set +# CONFIG_HID_MCP2200 is not set +# CONFIG_HID_MCP2221 is not set +# CONFIG_HID_MEGAWORLD_FF is not set +# CONFIG_HID_MICROSOFT is not set +# CONFIG_HID_MONTEREY is not set +# CONFIG_HID_MULTITOUCH is not set +# CONFIG_HID_NINTENDO is not set +# CONFIG_HID_NTI is not set +# CONFIG_HID_NTRIG is not set +# CONFIG_HID_NVIDIA_SHIELD is not set +# CONFIG_HID_ORTEK is not set +# CONFIG_HID_PANTHERLORD is not set +# CONFIG_HID_PENMOUNT is not set +# CONFIG_HID_PETALYNX is not set +# CONFIG_HID_PICOLCD is not set +# CONFIG_HID_PID is not set +# CONFIG_HID_PLANTRONICS is not set +# CONFIG_HID_PLAYSTATION is not set +# CONFIG_HID_PRIMAX is not set +# CONFIG_HID_PRODIKEYS is not set +# CONFIG_HID_PXRC is not set +# CONFIG_HID_RAZER is not set +# CONFIG_HID_REDRAGON is not set +# CONFIG_HID_RETRODE is not set +# CONFIG_HID_RMI is not set +# CONFIG_HID_ROCCAT is not set +# CONFIG_HID_SAITEK is not set +# CONFIG_HID_SAMSUNG is not set +# CONFIG_HID_SEMITEK is not set +# CONFIG_HID_SENSOR_HUB is not set +# CONFIG_HID_SIGMAMICRO is not set +# CONFIG_HID_SMARTJOYPLUS is not set +# CONFIG_HID_SONY is not set +# CONFIG_HID_SPEEDLINK is not set +# CONFIG_HID_STEAM is not set +# CONFIG_HID_STEELSERIES is not set +# CONFIG_HID_SUNPLUS is not set +# CONFIG_HID_SUPPORT is not set +# CONFIG_HID_THINGM is not set +# CONFIG_HID_THRUSTMASTER is not set +# CONFIG_HID_TIVO is not set +# CONFIG_HID_TOPRE is not set +# CONFIG_HID_TOPSEED is not set +# CONFIG_HID_TWINHAN is not set +# CONFIG_HID_U2FZERO is not set +# CONFIG_HID_UCLOGIC is not set +# CONFIG_HID_UDRAW_PS3 is not set +# CONFIG_HID_VIEWSONIC is not set +# CONFIG_HID_VIVALDI is not set +# CONFIG_HID_VRC2 is not set +# CONFIG_HID_WACOM is not set +# CONFIG_HID_WALTOP is not set +# CONFIG_HID_WIIMOTE is not set +# CONFIG_HID_WINWING is not set +# CONFIG_HID_XIAOMI is not set +# CONFIG_HID_XINMO is not set +# CONFIG_HID_ZEROPLUS is not set +# CONFIG_HID_ZYDACRON is not set +# CONFIG_HIGHMEM is not set +CONFIG_HIGH_RES_TIMERS=y +# CONFIG_HINIC is not set +# CONFIG_HIP04_ETH is not set +# CONFIG_HIPPI is not set +# CONFIG_HISILICON_ERRATUM_161010101 is not set +# CONFIG_HISILICON_ERRATUM_161600802 is not set +# CONFIG_HISILICON_ERRATUM_162100801 is not set +# CONFIG_HISI_DMA is not set +# CONFIG_HISI_FEMAC is not set +# CONFIG_HISI_HIKEY_USB is not set +# CONFIG_HISI_PCIE_PMU is not set +# CONFIG_HISI_PTT is not set +# CONFIG_HIST_TRIGGERS_DEBUG is not set +# CONFIG_HIX5HD2_GMAC is not set +# CONFIG_HMC425 is not set +# CONFIG_HMC6352 is not set +# CONFIG_HNS is not set +# CONFIG_HNS3 is not set +# CONFIG_HNS3_PMU is not set +# CONFIG_HNS_DSAF is not set +# CONFIG_HNS_ENET is not set +# CONFIG_HOTPLUG_CPU is not set +# CONFIG_HOTPLUG_PCI is not set +# CONFIG_HP03 is not set +# CONFIG_HP206C is not set +CONFIG_HPET_MMAP_DEFAULT=y +# CONFIG_HPFS_FS is not set +# CONFIG_HP_ILO is not set +# CONFIG_HP_WATCHDOG is not set +# CONFIG_HSA_AMD is not set +# CONFIG_HSC030PA is not set +# CONFIG_HSI is not set +# CONFIG_HSR is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTE is not set +# CONFIG_HTS221 is not set +# CONFIG_HTU21 is not set +# CONFIG_HUAWEI_WMI is not set +# CONFIG_HUGETLBFS is not set +# CONFIG_HUGETLB_PAGE is not set +# CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON is not set +# CONFIG_HVC_DCC is not set +# CONFIG_HVC_UDBG is not set +# CONFIG_HWLAT_TRACER is not set +# CONFIG_HWMON is not set +# CONFIG_HWMON_DEBUG_CHIP is not set +# CONFIG_HWMON_VID is not set +# CONFIG_HWSPINLOCK is not set +# CONFIG_HWSPINLOCK_OMAP is not set +CONFIG_HW_PERF_EVENTS=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HW_RANDOM_AMD is not set +# CONFIG_HW_RANDOM_ARM_SMCCC_TRNG is not set +# CONFIG_HW_RANDOM_ATMEL is not set +# CONFIG_HW_RANDOM_BA431 is not set +# CONFIG_HW_RANDOM_BCM2835 is not set +# CONFIG_HW_RANDOM_CAVIUM is not set +# CONFIG_HW_RANDOM_CCTRNG is not set +# CONFIG_HW_RANDOM_CN10K is not set +# CONFIG_HW_RANDOM_EXYNOS is not set +# CONFIG_HW_RANDOM_GEODE is not set +# CONFIG_HW_RANDOM_INTEL is not set +# CONFIG_HW_RANDOM_IPROC_RNG200 is not set +# CONFIG_HW_RANDOM_MTK is not set +# CONFIG_HW_RANDOM_OMAP is not set +# CONFIG_HW_RANDOM_OMAP3_ROM is not set +# CONFIG_HW_RANDOM_PPC4XX is not set +# CONFIG_HW_RANDOM_TIMERIOMEM is not set +CONFIG_HW_RANDOM_TPM=y +# CONFIG_HW_RANDOM_VIA is not set +# CONFIG_HW_RANDOM_VIRTIO is not set +# CONFIG_HW_RANDOM_XIPHERA is not set +# CONFIG_HX711 is not set +# CONFIG_HX9023S is not set +# CONFIG_HYPERV is not set +CONFIG_HZ=100 +CONFIG_HZ_100=y +# CONFIG_HZ_1000 is not set +# CONFIG_HZ_1024 is not set +# CONFIG_HZ_128 is not set +# CONFIG_HZ_200 is not set +# CONFIG_HZ_24 is not set +# CONFIG_HZ_250 is not set +# CONFIG_HZ_256 is not set +# CONFIG_HZ_300 is not set +# CONFIG_HZ_48 is not set +# CONFIG_HZ_500 is not set +# CONFIG_HZ_PERIODIC is not set +# CONFIG_I2C is not set +# CONFIG_I2C_ALGOBIT is not set +# CONFIG_I2C_ALGOPCA is not set +# CONFIG_I2C_ALGOPCF is not set +# CONFIG_I2C_ALI1535 is not set +# CONFIG_I2C_ALI1563 is not set +# CONFIG_I2C_ALI15X3 is not set +# CONFIG_I2C_AMD756 is not set +# CONFIG_I2C_AMD8111 is not set +# CONFIG_I2C_ARB_GPIO_CHALLENGE is not set +# CONFIG_I2C_AU1550 is not set +# CONFIG_I2C_BCM2835 is not set +# CONFIG_I2C_BCM_IPROC is not set +# CONFIG_I2C_BRCMSTB is not set +# CONFIG_I2C_CADENCE is not set +# CONFIG_I2C_CBUS_GPIO is not set +# CONFIG_I2C_CHARDEV is not set +# CONFIG_I2C_CP2615 is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEMUX_PINCTRL is not set +# CONFIG_I2C_DESIGNWARE_AMDPSP is not set +# CONFIG_I2C_DESIGNWARE_BAYTRAIL is not set +# CONFIG_I2C_DESIGNWARE_CORE is not set +# CONFIG_I2C_DESIGNWARE_PCI is not set +# CONFIG_I2C_DESIGNWARE_PLATFORM is not set +# CONFIG_I2C_DESIGNWARE_SLAVE is not set +# CONFIG_I2C_DIOLAN_U2C is not set +# CONFIG_I2C_EG20T is not set +# CONFIG_I2C_ELEKTOR is not set +# CONFIG_I2C_EMEV2 is not set +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_GPIO_FAULT_INJECTOR is not set +# CONFIG_I2C_HELPER_AUTO is not set +# CONFIG_I2C_HID is not set +# CONFIG_I2C_HID_OF is not set +# CONFIG_I2C_HID_OF_ELAN is not set +# CONFIG_I2C_HID_OF_GOODIX is not set +# CONFIG_I2C_HISI is not set +# CONFIG_I2C_I801 is not set +# CONFIG_I2C_IBM_IIC is not set +# CONFIG_I2C_IMG is not set +# CONFIG_I2C_ISCH is not set +# CONFIG_I2C_ISMT is not set +# CONFIG_I2C_JZ4780 is not set +# CONFIG_I2C_MLXCPLD is not set +# CONFIG_I2C_MPC is not set +# CONFIG_I2C_MT65XX is not set +# CONFIG_I2C_MUX is not set +# CONFIG_I2C_MUX_GPIO is not set +# CONFIG_I2C_MUX_GPMUX is not set +# CONFIG_I2C_MUX_LTC4306 is not set +# CONFIG_I2C_MUX_MLXCPLD is not set +# CONFIG_I2C_MUX_PCA9541 is not set +# CONFIG_I2C_MUX_PCA954x is not set +# CONFIG_I2C_MUX_PINCTRL is not set +# CONFIG_I2C_MUX_REG is not set +# CONFIG_I2C_MV64XXX is not set +# CONFIG_I2C_NFORCE2 is not set +# CONFIG_I2C_NOMADIK is not set +# CONFIG_I2C_NVIDIA_GPU is not set +# CONFIG_I2C_OCORES is not set +# CONFIG_I2C_OCTEON is not set +# CONFIG_I2C_PARPORT is not set +# CONFIG_I2C_PCA_ISA is not set +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_PCI1XXXX is not set +# CONFIG_I2C_PIIX4 is not set +# CONFIG_I2C_PXA_PCI is not set +# CONFIG_I2C_PXA_SLAVE is not set +# CONFIG_I2C_RCAR is not set +# CONFIG_I2C_RK3X is not set +# CONFIG_I2C_ROBOTFUZZ_OSIF is not set +# CONFIG_I2C_S3C2410 is not set +# CONFIG_I2C_SCMI is not set +# CONFIG_I2C_SH_MOBILE is not set +# CONFIG_I2C_SIMTEC is not set +# CONFIG_I2C_SIS5595 is not set +# CONFIG_I2C_SIS630 is not set +# CONFIG_I2C_SIS96X is not set +# CONFIG_I2C_SLAVE is not set +# CONFIG_I2C_SLAVE_EEPROM is not set +# CONFIG_I2C_SMBUS is not set +# CONFIG_I2C_STUB is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_THUNDERX is not set +# CONFIG_I2C_TINY_USB is not set +# CONFIG_I2C_VERSATILE is not set +# CONFIG_I2C_VIA is not set +# CONFIG_I2C_VIAPRO is not set +# CONFIG_I2C_VIRTIO is not set +# CONFIG_I2C_XILINX is not set +# CONFIG_I3C is not set +# CONFIG_I40E is not set +# CONFIG_I40EVF is not set +# CONFIG_I6300ESB_WDT is not set +# CONFIG_I82092 is not set +# CONFIG_I82365 is not set +# CONFIG_IAQCORE is not set +# CONFIG_IBM_ASM is not set +# CONFIG_IBM_EMAC_DEBUG is not set +# CONFIG_IBM_EMAC_EMAC4 is not set +# CONFIG_IBM_EMAC_MAL_CLR_ICINTSTAT is not set +# CONFIG_IBM_EMAC_MAL_COMMON_ERR is not set +# CONFIG_IBM_EMAC_NO_FLOW_CTRL is not set +# CONFIG_IBM_EMAC_RGMII is not set +# CONFIG_IBM_EMAC_TAH is not set +# CONFIG_IBM_EMAC_ZMII is not set +# CONFIG_ICE is not set +# CONFIG_ICP10100 is not set +# CONFIG_ICPLUS_PHY is not set +# CONFIG_ICS932S401 is not set +# CONFIG_IDEAPAD_LAPTOP is not set +# CONFIG_IDLE_PAGE_TRACKING is not set +# CONFIG_IDPF is not set +# CONFIG_IEEE802154 is not set +# CONFIG_IEEE802154_ADF7242 is not set +# CONFIG_IEEE802154_ATUSB is not set +# CONFIG_IEEE802154_CA8210 is not set +# CONFIG_IEEE802154_HWSIM is not set +# CONFIG_IEEE802154_MCR20A is not set +# CONFIG_IFB is not set +# CONFIG_IGB is not set +# CONFIG_IGBVF is not set +# CONFIG_IGC is not set +# CONFIG_IIO is not set +# CONFIG_IIO_BUFFER is not set +# CONFIG_IIO_BUFFER_CB is not set +# CONFIG_IIO_BUFFER_DMA is not set +# CONFIG_IIO_BUFFER_DMAENGINE is not set +# CONFIG_IIO_BUFFER_HW_CONSUMER is not set +# CONFIG_IIO_CONFIGFS is not set +CONFIG_IIO_CONSUMERS_PER_TRIGGER=2 +# CONFIG_IIO_CROS_EC_ACCEL_LEGACY is not set +# CONFIG_IIO_INTERRUPT_TRIGGER is not set +# CONFIG_IIO_KX022A_I2C is not set +# CONFIG_IIO_KX022A_SPI is not set +# CONFIG_IIO_MUX is not set +# CONFIG_IIO_RESCALE is not set +# CONFIG_IIO_SIMPLE_DUMMY is not set +# CONFIG_IIO_SSP_SENSORHUB is not set +# CONFIG_IIO_ST_ACCEL_3AXIS is not set +# CONFIG_IIO_ST_GYRO_3AXIS is not set +# CONFIG_IIO_ST_LSM6DSX is not set +# CONFIG_IIO_ST_LSM9DS0 is not set +# CONFIG_IIO_ST_MAGN_3AXIS is not set +# CONFIG_IIO_ST_PRESS is not set +# CONFIG_IIO_SW_DEVICE is not set +# CONFIG_IIO_SW_TRIGGER is not set +# CONFIG_IIO_SYSFS_TRIGGER is not set +# CONFIG_IIO_TRIGGER is not set +# CONFIG_IIO_TRIGGERED_EVENT is not set +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set +# CONFIG_IKHEADERS is not set +# CONFIG_IMA is not set +# CONFIG_IMGPDC_WDT is not set +# CONFIG_IMG_MDC_DMA is not set +# CONFIG_IMX7D_ADC is not set +# CONFIG_IMX8QXP_ADC is not set +# CONFIG_IMX93_ADC is not set +# CONFIG_IMX_IPUV3_CORE is not set +# CONFIG_IMX_SCMI_BBM_EXT is not set +# CONFIG_IMX_SCMI_MISC_DRV is not set +# CONFIG_IMX_THERMAL is not set +# CONFIG_INA2XX_ADC is not set +# CONFIG_INDIRECT_PIO is not set +CONFIG_INET=y +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_ESPINTCP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_INET6_TUNNEL is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_DIAG is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_ESPINTCP is not set +# CONFIG_INET_IPCOMP is not set +CONFIG_INET_TABLE_PERTURB_ORDER=16 +# CONFIG_INET_TCP_DIAG is not set +# CONFIG_INET_TUNNEL is not set +# CONFIG_INET_UDP_DIAG is not set +# CONFIG_INET_XFRM_TUNNEL is not set +# CONFIG_INFINIBAND is not set +# CONFIG_INFTL is not set +# CONFIG_INGENIC_ADC is not set +# CONFIG_INGENIC_CGU_JZ4725B is not set +# CONFIG_INGENIC_CGU_JZ4740 is not set +# CONFIG_INGENIC_CGU_JZ4755 is not set +# CONFIG_INGENIC_CGU_JZ4760 is not set +# CONFIG_INGENIC_CGU_JZ4770 is not set +# CONFIG_INGENIC_CGU_JZ4780 is not set +# CONFIG_INGENIC_CGU_X1000 is not set +# CONFIG_INGENIC_CGU_X1830 is not set +# CONFIG_INGENIC_OST is not set +# CONFIG_INGENIC_SYSOST is not set +# CONFIG_INGENIC_TCU_CLK is not set +# CONFIG_INGENIC_TCU_IRQ is not set +# CONFIG_INGENIC_TIMER is not set +# CONFIG_INITRAMFS_PRESERVE_MTIME is not set +CONFIG_INIT_ENV_ARG_LIMIT=32 +# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set +# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set +# CONFIG_INIT_STACK_ALL_PATTERN is not set +# CONFIG_INIT_STACK_ALL_ZERO is not set +CONFIG_INIT_STACK_NONE=y +CONFIG_INOTIFY_USER=y +# CONFIG_INPUT is not set +# CONFIG_INPUT_AD714X is not set +# CONFIG_INPUT_ADXL34X is not set +# CONFIG_INPUT_APANEL is not set +# CONFIG_INPUT_ATI_REMOTE2 is not set +# CONFIG_INPUT_ATLAS_BTNS is not set +# CONFIG_INPUT_ATMEL_CAPTOUCH is not set +# CONFIG_INPUT_AXP20X_PEK is not set +# CONFIG_INPUT_BMA150 is not set +# CONFIG_INPUT_CM109 is not set +# CONFIG_INPUT_CMA3000 is not set +# CONFIG_INPUT_DA7280_HAPTICS is not set +# CONFIG_INPUT_DRV260X_HAPTICS is not set +# CONFIG_INPUT_DRV2665_HAPTICS is not set +# CONFIG_INPUT_DRV2667_HAPTICS is not set +# CONFIG_INPUT_E3X0_BUTTON is not set +# CONFIG_INPUT_EVBUG is not set +# CONFIG_INPUT_EVDEV is not set +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_GPIO_BEEPER is not set +# CONFIG_INPUT_GPIO_DECODER is not set +# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set +# CONFIG_INPUT_GPIO_VIBRA is not set +# CONFIG_INPUT_IBM_PANEL is not set +# CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set +# CONFIG_INPUT_IMS_PCU is not set +# CONFIG_INPUT_IQS269A is not set +# CONFIG_INPUT_IQS626A is not set +# CONFIG_INPUT_IQS7222 is not set +# CONFIG_INPUT_JOYDEV is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_KEYSPAN_REMOTE is not set +# CONFIG_INPUT_KXTJ9 is not set +# CONFIG_INPUT_LEDS is not set +# CONFIG_INPUT_MATRIXKMAP is not set +# CONFIG_INPUT_MAX8997_HAPTIC is not set +CONFIG_INPUT_MISC=y +# CONFIG_INPUT_MMA8450 is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_PALMAS_PWRBUTTON is not set +# CONFIG_INPUT_PCF8574 is not set +# CONFIG_INPUT_PCSPKR is not set +# CONFIG_INPUT_PM8941_PWRKEY is not set +# CONFIG_INPUT_PM8XXX_VIBRATOR is not set +# CONFIG_INPUT_POWERMATE is not set +# CONFIG_INPUT_PWM_BEEPER is not set +# CONFIG_INPUT_PWM_VIBRA is not set +# CONFIG_INPUT_REGULATOR_HAPTIC is not set +# CONFIG_INPUT_SOC_BUTTON_ARRAY is not set +# CONFIG_INPUT_SPARSEKMAP is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_TPS65218_PWRBUTTON is not set +# CONFIG_INPUT_TWL4030_PWRBUTTON is not set +# CONFIG_INPUT_TWL4030_VIBRA is not set +# CONFIG_INPUT_TWL6040_VIBRA is not set +# CONFIG_INPUT_UINPUT is not set +# CONFIG_INPUT_WISTRON_BTNS is not set +# CONFIG_INPUT_YEALINK is not set +# CONFIG_INSPUR_PLATFORM_PROFILE is not set +# CONFIG_INT340X_THERMAL is not set +# CONFIG_INTEGRITY is not set +# CONFIG_INTEGRITY_AUDIT is not set +# CONFIG_INTEGRITY_SIGNATURE is not set +# CONFIG_INTEL_ATOMISP2_LED is not set +# CONFIG_INTEL_ATOMISP2_PM is not set +# CONFIG_INTEL_HID_EVENT is not set +# CONFIG_INTEL_IDLE is not set +# CONFIG_INTEL_IDMA64 is not set +# CONFIG_INTEL_INT0002_VGPIO is not set +# CONFIG_INTEL_IOATDMA is not set +# CONFIG_INTEL_ISH_HID is not set +# CONFIG_INTEL_MEI is not set +# CONFIG_INTEL_MEI_GSC_PROXY is not set +# CONFIG_INTEL_MEI_HDCP is not set +# CONFIG_INTEL_MEI_ME is not set +# CONFIG_INTEL_MEI_PXP is not set +# CONFIG_INTEL_MEI_TXE is not set +# CONFIG_INTEL_OAKTRAIL is not set +# CONFIG_INTEL_PMC_CORE is not set +# CONFIG_INTEL_PUNIT_IPC is not set +# CONFIG_INTEL_RST is not set +# CONFIG_INTEL_SKL_INT3472 is not set +# CONFIG_INTEL_SMARTCONNECT is not set +# CONFIG_INTEL_SOC_PMIC is not set +# CONFIG_INTEL_SOC_PMIC_CHTDC_TI is not set +# CONFIG_INTEL_SOC_PMIC_CHTWC is not set +# CONFIG_INTEL_TH is not set +# CONFIG_INTEL_VBTN is not set +# CONFIG_INTEL_WMI_SBL_FW_UPDATE is not set +# CONFIG_INTEL_WMI_THUNDERBOLT is not set +# CONFIG_INTEL_XWAY_PHY is not set +# CONFIG_INTERCONNECT is not set +# CONFIG_INTERVAL_TREE_TEST is not set +# CONFIG_INV_ICM42600_I2C is not set +# CONFIG_INV_ICM42600_SPI is not set +# CONFIG_INV_MPU6050_I2C is not set +# CONFIG_INV_MPU6050_IIO is not set +# CONFIG_INV_MPU6050_SPI is not set +# CONFIG_IOMMU_SUPPORT is not set +# CONFIG_IONIC is not set +# CONFIG_IOSCHED_BFQ is not set +# CONFIG_IOSM is not set +CONFIG_IO_STRICT_DEVMEM=y +# CONFIG_IO_URING is not set +CONFIG_IO_WQ=y +# CONFIG_IP17XX_PHY is not set +# CONFIG_IP5XXX_POWER is not set +# CONFIG_IP6_NF_FILTER is not set +# CONFIG_IP6_NF_IPTABLES is not set +# CONFIG_IP6_NF_MANGLE is not set +# CONFIG_IP6_NF_MATCH_AH is not set +# CONFIG_IP6_NF_MATCH_EUI64 is not set +# CONFIG_IP6_NF_MATCH_FRAG is not set +# CONFIG_IP6_NF_MATCH_HL is not set +# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set +# CONFIG_IP6_NF_MATCH_MH is not set +# CONFIG_IP6_NF_MATCH_OPTS is not set +# CONFIG_IP6_NF_MATCH_RPFILTER is not set +# CONFIG_IP6_NF_MATCH_RT is not set +# CONFIG_IP6_NF_MATCH_SRH is not set +# CONFIG_IP6_NF_NAT is not set +# CONFIG_IP6_NF_RAW is not set +# CONFIG_IP6_NF_SECURITY is not set +# CONFIG_IP6_NF_TARGET_HL is not set +# CONFIG_IP6_NF_TARGET_MASQUERADE is not set +# CONFIG_IP6_NF_TARGET_REJECT is not set +# CONFIG_IP6_NF_TARGET_SYNPROXY is not set +# CONFIG_IPACK_BUS is not set +# CONFIG_IPC_NS is not set +# CONFIG_IPMB_DEVICE_INTERFACE is not set +# CONFIG_IPMI_HANDLER is not set +# CONFIG_IPU_BRIDGE is not set +# CONFIG_IPV6 is not set +# CONFIG_IPV6_FOU is not set +# CONFIG_IPV6_FOU_TUNNEL is not set +# CONFIG_IPV6_ILA is not set +# CONFIG_IPV6_IOAM6_LWTUNNEL is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_IPV6_MROUTE_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_ROUTE_INFO is not set +# CONFIG_IPV6_RPL_LWTUNNEL is not set +# CONFIG_IPV6_SEG6_HMAC is not set +# CONFIG_IPV6_SEG6_LWTUNNEL is not set +# CONFIG_IPV6_SIT is not set +# CONFIG_IPV6_SIT_6RD is not set +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_VTI is not set +# CONFIG_IPVLAN is not set +# CONFIG_IPVTAP is not set +# CONFIG_IPW2100 is not set +# CONFIG_IPW2100_DEBUG is not set +CONFIG_IPW2100_MONITOR=y +# CONFIG_IPW2200 is not set +# CONFIG_IPW2200_DEBUG is not set +CONFIG_IPW2200_MONITOR=y +# CONFIG_IPW2200_PROMISCUOUS is not set +# CONFIG_IPW2200_QOS is not set +# CONFIG_IPW2200_RADIOTAP is not set +# CONFIG_IPWIRELESS is not set +CONFIG_IP_ADVANCED_ROUTER=y +# CONFIG_IP_DCCP is not set +# CONFIG_IP_FIB_TRIE_STATS is not set +# CONFIG_IP_MROUTE is not set +CONFIG_IP_MROUTE_MULTIPLE_TABLES=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_MULTIPLE_TABLES=y +# CONFIG_IP_NF_ARPFILTER is not set +# CONFIG_IP_NF_ARPTABLES is not set +# CONFIG_IP_NF_ARP_MANGLE is not set +# CONFIG_IP_NF_FILTER is not set +# CONFIG_IP_NF_IPTABLES is not set +# CONFIG_IP_NF_MANGLE is not set +# CONFIG_IP_NF_MATCH_AH is not set +# CONFIG_IP_NF_MATCH_ECN is not set +# CONFIG_IP_NF_MATCH_RPFILTER is not set +# CONFIG_IP_NF_MATCH_TTL is not set +# CONFIG_IP_NF_RAW is not set +# CONFIG_IP_NF_SECURITY is not set +# CONFIG_IP_NF_TARGET_ECN is not set +# CONFIG_IP_NF_TARGET_MASQUERADE is not set +# CONFIG_IP_NF_TARGET_NETMAP is not set +# CONFIG_IP_NF_TARGET_REDIRECT is not set +# CONFIG_IP_NF_TARGET_REJECT is not set +# CONFIG_IP_NF_TARGET_SYNPROXY is not set +# CONFIG_IP_NF_TARGET_TTL is not set +# CONFIG_IP_PIMSM_V1 is not set +# CONFIG_IP_PIMSM_V2 is not set +# CONFIG_IP_PNP is not set +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +# CONFIG_IP_SCTP is not set +# CONFIG_IP_SET is not set +# CONFIG_IP_SET_HASH_IPMAC is not set +# CONFIG_IP_VS is not set +# CONFIG_IP_VS_MH is not set +CONFIG_IP_VS_MH_TAB_INDEX=10 +# CONFIG_IP_VS_TWOS is not set +# CONFIG_IRQSOFF_TRACER is not set +# CONFIG_IRQ_ALL_CPUS is not set +# CONFIG_IRQ_POLL is not set +# CONFIG_IRQ_TIME_ACCOUNTING is not set +# CONFIG_IRSD200 is not set +# CONFIG_IR_GPIO_CIR is not set +# CONFIG_IR_HIX5HD2 is not set +# CONFIG_IR_IGORPLUGUSB is not set +# CONFIG_IR_IGUANA is not set +# CONFIG_IR_IMG is not set +# CONFIG_IR_IMON is not set +# CONFIG_IR_IMON_RAW is not set +# CONFIG_IR_JVC_DECODER is not set +# CONFIG_IR_MCEUSB is not set +# CONFIG_IR_NEC_DECODER is not set +# CONFIG_IR_RC5_DECODER is not set +# CONFIG_IR_RC6_DECODER is not set +# CONFIG_IR_REDRAT3 is not set +# CONFIG_IR_SERIAL is not set +# CONFIG_IR_SONY_DECODER is not set +# CONFIG_IR_STREAMZAP is not set +# CONFIG_IR_TOY is not set +# CONFIG_IR_TTUSBIR is not set +# CONFIG_ISA_BUS is not set +# CONFIG_ISA_BUS_API is not set +# CONFIG_ISCSI_BOOT_SYSFS is not set +# CONFIG_ISCSI_TCP is not set +CONFIG_ISDN=y +# CONFIG_ISDN_CAPI is not set +# CONFIG_ISL29003 is not set +# CONFIG_ISL29020 is not set +# CONFIG_ISL29125 is not set +# CONFIG_ISL29501 is not set +# CONFIG_ISL76682 is not set +# CONFIG_ISO9660_FS is not set +# CONFIG_ISS4xx is not set +# CONFIG_ITG3200 is not set +# CONFIG_IWL3945 is not set +# CONFIG_IWLWIFI is not set +# CONFIG_IXGBE is not set +# CONFIG_IXGBEVF is not set +# CONFIG_JAILHOUSE_GUEST is not set +# CONFIG_JBD2_DEBUG is not set +# CONFIG_JFFS2_CMODE_FAVOURLZO is not set +# CONFIG_JFFS2_CMODE_NONE is not set +CONFIG_JFFS2_CMODE_PRIORITY=y +# CONFIG_JFFS2_CMODE_SIZE is not set +CONFIG_JFFS2_COMPRESSION_OPTIONS=y +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +# CONFIG_JFFS2_FS_POSIX_ACL is not set +# CONFIG_JFFS2_FS_SECURITY is not set +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +CONFIG_JFFS2_FS_WRITEBUFFER=y +CONFIG_JFFS2_FS_XATTR=y +CONFIG_JFFS2_LZMA=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +CONFIG_JFFS2_SUMMARY=y +# CONFIG_JFFS2_ZLIB is not set +# CONFIG_JFS_DEBUG is not set +# CONFIG_JFS_FS is not set +# CONFIG_JFS_POSIX_ACL is not set +# CONFIG_JFS_SECURITY is not set +# CONFIG_JFS_STATISTICS is not set +# CONFIG_JME is not set +CONFIG_JOLIET=y +# CONFIG_JSA1212 is not set +# CONFIG_JUMP_LABEL is not set +# CONFIG_JZ4740_WDT is not set +# CONFIG_KALLSYMS is not set +# CONFIG_KALLSYMS_ABSOLUTE_PERCPU is not set +# CONFIG_KALLSYMS_ALL is not set +# CONFIG_KALLSYMS_SELFTEST is not set +# CONFIG_KALLSYMS_UNCOMPRESSED is not set +# CONFIG_KARMA_PARTITION is not set +# CONFIG_KASAN is not set +# CONFIG_KASAN_MODULE_TEST is not set +CONFIG_KASAN_STACK=y +# CONFIG_KCMP is not set +# CONFIG_KCOV is not set +CONFIG_KCOV_IRQ_AREA_SIZE=0x40000 +# CONFIG_KCSAN is not set +# CONFIG_KEBA_CP500 is not set +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_GZIP is not set +# CONFIG_KERNEL_LZ4 is not set +# CONFIG_KERNEL_LZMA is not set +# CONFIG_KERNEL_LZO is not set +CONFIG_KERNEL_MODE_NEON=y +CONFIG_KERNEL_XZ=y +# CONFIG_KERNEL_ZSTD is not set +CONFIG_KERNFS=y +# CONFIG_KEXEC is not set +# CONFIG_KEXEC_FILE is not set +# CONFIG_KEXEC_SIG is not set +# CONFIG_KEYBOARD_ADC is not set +# CONFIG_KEYBOARD_ADP5588 is not set +# CONFIG_KEYBOARD_ADP5589 is not set +# CONFIG_KEYBOARD_APPLESPI is not set +# CONFIG_KEYBOARD_ATKBD is not set +# CONFIG_KEYBOARD_BCM is not set +# CONFIG_KEYBOARD_CAP11XX is not set +# CONFIG_KEYBOARD_CYPRESS_SF is not set +# CONFIG_KEYBOARD_DLINK_DIR685 is not set +# CONFIG_KEYBOARD_GPIO is not set +# CONFIG_KEYBOARD_GPIO_POLLED is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_LM8323 is not set +# CONFIG_KEYBOARD_LM8333 is not set +# CONFIG_KEYBOARD_MATRIX is not set +# CONFIG_KEYBOARD_MAX7359 is not set +# CONFIG_KEYBOARD_MPR121 is not set +# CONFIG_KEYBOARD_MT6779 is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_OMAP4 is not set +# CONFIG_KEYBOARD_OPENCORES is not set +# CONFIG_KEYBOARD_PINEPHONE is not set +# CONFIG_KEYBOARD_PXA27x is not set +# CONFIG_KEYBOARD_QT1050 is not set +# CONFIG_KEYBOARD_QT1070 is not set +# CONFIG_KEYBOARD_QT2160 is not set +# CONFIG_KEYBOARD_SAMSUNG is not set +# CONFIG_KEYBOARD_SH_KEYSC is not set +# CONFIG_KEYBOARD_SNVS_PWRKEY is not set +# CONFIG_KEYBOARD_STMPE is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_TCA6416 is not set +# CONFIG_KEYBOARD_TCA8418 is not set +# CONFIG_KEYBOARD_TEGRA is not set +# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set +# CONFIG_KEYBOARD_TWL4030 is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYS is not set +# CONFIG_KEYS_REQUEST_CACHE is not set +# CONFIG_KEY_DH_OPERATIONS is not set +# CONFIG_KFENCE is not set +# CONFIG_KGDB is not set +# CONFIG_KMX61 is not set +# CONFIG_KPROBES is not set +# CONFIG_KPROBES_SANITY_TEST is not set +# CONFIG_KPROBE_EVENTS_ON_NOTRACE is not set +# CONFIG_KPROBE_EVENT_GEN_TEST is not set +# CONFIG_KS8842 is not set +# CONFIG_KS8851 is not set +# CONFIG_KS8851_MLL is not set +# CONFIG_KSM is not set +# CONFIG_KSZ884X_PCI is not set +# CONFIG_KUNIT is not set +CONFIG_KUSER_HELPERS=y +# CONFIG_KVM_AMD is not set +# CONFIG_KVM_AMD_SEV is not set +# CONFIG_KVM_GUEST is not set +# CONFIG_KVM_HYPERV is not set +# CONFIG_KVM_INTEL is not set +# CONFIG_KVM_INTEL_PROVE_VE is not set +CONFIG_KVM_MAX_NR_VCPUS=1024 +# CONFIG_KVM_PROVE_MMU is not set +# CONFIG_KVM_SW_PROTECTED_VM is not set +# CONFIG_KVM_WERROR is not set +# CONFIG_KVM_XEN is not set +# CONFIG_KXCJK1013 is not set +# CONFIG_KXSD9 is not set +# CONFIG_L2TP is not set +# CONFIG_L2TP_ETH is not set +# CONFIG_L2TP_IP is not set +# CONFIG_L2TP_V3 is not set +# CONFIG_LAN743X is not set +# CONFIG_LAN865X is not set +# CONFIG_LAN966X_OIC is not set +# CONFIG_LAN966X_SWITCH is not set +# CONFIG_LANTIQ is not set +# CONFIG_LAPB is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_LATTICE_ECP3_CONFIG is not set +# CONFIG_LCD_AMS369FG06 is not set +# CONFIG_LCD_CLASS_DEVICE is not set +# CONFIG_LCD_HX8357 is not set +# CONFIG_LCD_ILI922X is not set +# CONFIG_LCD_ILI9320 is not set +# CONFIG_LCD_L4F00242T03 is not set +# CONFIG_LCD_LMS283GF05 is not set +# CONFIG_LCD_LMS501KF03 is not set +# CONFIG_LCD_LTV350QV is not set +# CONFIG_LCD_OTM3225A is not set +# CONFIG_LCD_TDO24M is not set +# CONFIG_LCD_VGG2432A4 is not set +CONFIG_LDISC_AUTOLOAD=y +# CONFIG_LDM_PARTITION is not set +CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y +# CONFIG_LD_HEAD_STUB_CATCH is not set +# CONFIG_LEDS_AN30259A is not set +# CONFIG_LEDS_APU is not set +# CONFIG_LEDS_AW200XX is not set +# CONFIG_LEDS_AW2013 is not set +# CONFIG_LEDS_BCM6328 is not set +# CONFIG_LEDS_BCM6358 is not set +# CONFIG_LEDS_BD2606MVV is not set +# CONFIG_LEDS_BD2802 is not set +# CONFIG_LEDS_BLINKM is not set +CONFIG_LEDS_BRIGHTNESS_HW_CHANGED=y +CONFIG_LEDS_CLASS=y +# CONFIG_LEDS_CLASS_FLASH is not set +CONFIG_LEDS_CLASS_MULTICOLOR=y +# CONFIG_LEDS_CR0014114 is not set +# CONFIG_LEDS_DAC124S085 is not set +# CONFIG_LEDS_EL15203000 is not set +# CONFIG_LEDS_GPIO is not set +# CONFIG_LEDS_GROUP_MULTICOLOR is not set +# CONFIG_LEDS_INTEL_SS4200 is not set +# CONFIG_LEDS_IS31FL319X is not set +# CONFIG_LEDS_IS31FL32XX is not set +# CONFIG_LEDS_KTD202X is not set +# CONFIG_LEDS_LM3530 is not set +# CONFIG_LEDS_LM3532 is not set +# CONFIG_LEDS_LM355x is not set +# CONFIG_LEDS_LM3642 is not set +# CONFIG_LEDS_LM3692X is not set +# CONFIG_LEDS_LM3697 is not set +# CONFIG_LEDS_LP3944 is not set +# CONFIG_LEDS_LP3952 is not set +# CONFIG_LEDS_LP50XX is not set +# CONFIG_LEDS_LP5521 is not set +# CONFIG_LEDS_LP5523 is not set +# CONFIG_LEDS_LP5562 is not set +# CONFIG_LEDS_LP5569 is not set +# CONFIG_LEDS_LP55XX_COMMON is not set +# CONFIG_LEDS_LP8501 is not set +# CONFIG_LEDS_LP8860 is not set +# CONFIG_LEDS_LT3593 is not set +# CONFIG_LEDS_MLXCPLD is not set +# CONFIG_LEDS_MLXREG is not set +# CONFIG_LEDS_NCP5623 is not set +# CONFIG_LEDS_NIC78BX is not set +# CONFIG_LEDS_NS2 is not set +# CONFIG_LEDS_OT200 is not set +# CONFIG_LEDS_PCA9532 is not set +# CONFIG_LEDS_PCA955X is not set +# CONFIG_LEDS_PCA963X is not set +# CONFIG_LEDS_PCA995X is not set +# CONFIG_LEDS_PWM is not set +# CONFIG_LEDS_PWM_MULTICOLOR is not set +# CONFIG_LEDS_REGULATOR is not set +# CONFIG_LEDS_SPI_BYTE is not set +# CONFIG_LEDS_ST1202 is not set +# CONFIG_LEDS_SUN50I_A100 is not set +# CONFIG_LEDS_SYSCON is not set +# CONFIG_LEDS_TCA6507 is not set +# CONFIG_LEDS_TI_LMU_COMMON is not set +# CONFIG_LEDS_TLC591XX is not set +CONFIG_LEDS_TRIGGERS=y +# CONFIG_LEDS_TRIGGER_ACTIVITY is not set +# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set +# CONFIG_LEDS_TRIGGER_CAMERA is not set +# CONFIG_LEDS_TRIGGER_CPU is not set +CONFIG_LEDS_TRIGGER_DEFAULT_ON=y +# CONFIG_LEDS_TRIGGER_DISK is not set +# CONFIG_LEDS_TRIGGER_GPIO is not set +CONFIG_LEDS_TRIGGER_HEARTBEAT=y +# CONFIG_LEDS_TRIGGER_INPUT_EVENTS is not set +# CONFIG_LEDS_TRIGGER_MTD is not set +CONFIG_LEDS_TRIGGER_NETDEV=y +# CONFIG_LEDS_TRIGGER_ONESHOT is not set +# CONFIG_LEDS_TRIGGER_PANIC is not set +# CONFIG_LEDS_TRIGGER_PATTERN is not set +CONFIG_LEDS_TRIGGER_TIMER=y +# CONFIG_LEDS_TRIGGER_TRANSIENT is not set +# CONFIG_LEDS_TRIGGER_TTY is not set +# CONFIG_LEDS_TURRIS_OMNIA is not set +# CONFIG_LEDS_USER is not set +# CONFIG_LED_TRIGGER_PHY is not set +# CONFIG_LEGACY_PTYS is not set +# CONFIG_LEGACY_TIOCSTI is not set +# CONFIG_LENOVO_WMI_CAMERA is not set +# CONFIG_LENOVO_YMC is not set +# CONFIG_LG_LAPTOP is not set +# CONFIG_LIB80211 is not set +# CONFIG_LIB80211_CRYPT_CCMP is not set +# CONFIG_LIB80211_CRYPT_TKIP is not set +# CONFIG_LIB80211_CRYPT_WEP is not set +# CONFIG_LIB80211_DEBUG is not set +# CONFIG_LIBCRC32C is not set +# CONFIG_LIBERTAS is not set +# CONFIG_LIBERTAS_THINFIRM is not set +# CONFIG_LIBERTAS_USB is not set +# CONFIG_LIBFC is not set +# CONFIG_LIBFCOE is not set +# CONFIG_LIBIPW_DEBUG is not set +# CONFIG_LIBNVDIMM is not set +# CONFIG_LIDAR_LITE_V2 is not set +CONFIG_LINEAR_RANGES=y +# CONFIG_LIQUIDIO is not set +# CONFIG_LIQUIDIO_VF is not set +# CONFIG_LIRC is not set +CONFIG_LIST_HARDENED=y +# CONFIG_LITEX_LITEETH is not set +# CONFIG_LITEX_SOC_CONTROLLER is not set +# CONFIG_LIVEPATCH is not set +# CONFIG_LKDTM is not set +CONFIG_LLC=y +# CONFIG_LLC2 is not set +# CONFIG_LMK04832 is not set +# CONFIG_LMP91000 is not set +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +# CONFIG_LOCKD is not set +CONFIG_LOCKDEP_BITS=15 +CONFIG_LOCKDEP_CHAINS_BITS=16 +CONFIG_LOCKDEP_CIRCULAR_QUEUE_BITS=12 +CONFIG_LOCKDEP_STACK_TRACE_BITS=19 +CONFIG_LOCKDEP_STACK_TRACE_HASH_BITS=14 +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_LOCKD_V4=y +# CONFIG_LOCKUP_DETECTOR is not set +# CONFIG_LOCK_EVENT_COUNTS is not set +CONFIG_LOCK_MM_AND_FIND_VMA=y +# CONFIG_LOCK_STAT is not set +# CONFIG_LOCK_TORTURE_TEST is not set +# CONFIG_LOGIG940_FF is not set +# CONFIG_LOGIRUMBLEPAD2_FF is not set +# CONFIG_LOGITECH_FF is not set +# CONFIG_LOGIWHEELS_FF is not set +# CONFIG_LOGO is not set +CONFIG_LOG_BUF_SHIFT=17 +CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 +# CONFIG_LOONGSON_MC146818 is not set +# CONFIG_LPC_ICH is not set +# CONFIG_LPC_SCH is not set +# CONFIG_LP_CONSOLE is not set +CONFIG_LRU_GEN=y +CONFIG_LRU_GEN_ENABLED=y +# CONFIG_LRU_GEN_STATS is not set +# CONFIG_LSI_ET1011C_PHY is not set +CONFIG_LSM="lockdown,yama,loadpin,safesetid,integrity" +CONFIG_LSM_MMAP_MIN_ADDR=65536 +# CONFIG_LTC1660 is not set +# CONFIG_LTC2309 is not set +# CONFIG_LTC2471 is not set +# CONFIG_LTC2485 is not set +# CONFIG_LTC2496 is not set +# CONFIG_LTC2497 is not set +# CONFIG_LTC2632 is not set +# CONFIG_LTC2664 is not set +# CONFIG_LTC2688 is not set +# CONFIG_LTC2983 is not set +# CONFIG_LTE_GDM724X is not set +CONFIG_LTO_NONE=y +# CONFIG_LTR390 is not set +# CONFIG_LTR501 is not set +# CONFIG_LTRF216A is not set +# CONFIG_LV0104CS is not set +# CONFIG_LWQ_TEST is not set +# CONFIG_LWTUNNEL is not set +# CONFIG_LXT_PHY is not set +# CONFIG_LZ4HC_COMPRESS is not set +# CONFIG_LZ4_COMPRESS is not set +# CONFIG_LZ4_DECOMPRESS is not set +CONFIG_LZMA_COMPRESS=y +CONFIG_LZMA_DECOMPRESS=y +# CONFIG_LZO_COMPRESS is not set +# CONFIG_LZO_DECOMPRESS is not set +# CONFIG_M62332 is not set +# CONFIG_MAC80211 is not set +# CONFIG_MAC80211_MESSAGE_TRACING is not set +CONFIG_MAC80211_STA_HASH_MAX_SIZE=0 +# CONFIG_MACB is not set +# CONFIG_MACH_ASM9260 is not set +# CONFIG_MACH_DECSTATION is not set +# CONFIG_MACH_INGENIC is not set +# CONFIG_MACH_INGENIC_SOC is not set +# CONFIG_MACH_JAZZ is not set +# CONFIG_MACH_JZ4740 is not set +# CONFIG_MACH_LOONGSON2EF is not set +# CONFIG_MACH_LOONGSON32 is not set +# CONFIG_MACH_LOONGSON64 is not set +# CONFIG_MACH_NINTENDO64 is not set +# CONFIG_MACH_PIC32 is not set +# CONFIG_MACH_REALTEK_RTL is not set +# CONFIG_MACH_TX49XX is not set +# CONFIG_MACINTOSH_DRIVERS is not set +# CONFIG_MACSEC is not set +# CONFIG_MACVLAN is not set +# CONFIG_MACVTAP is not set +# CONFIG_MAC_EMUMOUSEBTN is not set +# CONFIG_MAC_PARTITION is not set +# CONFIG_MAG3110 is not set +# CONFIG_MAGIC_SYSRQ is not set +CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1 +# CONFIG_MAGIC_SYSRQ_SERIAL is not set +CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE="" +# CONFIG_MAILBOX is not set +# CONFIG_MANAGER_SBS is not set +# CONFIG_MANGLE_BOOTARGS is not set +# CONFIG_MARVELL_10G_PHY is not set +# CONFIG_MARVELL_88Q2XXX_PHY is not set +# CONFIG_MARVELL_88X2222_PHY is not set +# CONFIG_MARVELL_PHY is not set +# CONFIG_MAX1027 is not set +# CONFIG_MAX11100 is not set +# CONFIG_MAX1118 is not set +# CONFIG_MAX11205 is not set +# CONFIG_MAX11410 is not set +# CONFIG_MAX1241 is not set +# CONFIG_MAX1363 is not set +# CONFIG_MAX30100 is not set +# CONFIG_MAX30102 is not set +# CONFIG_MAX30208 is not set +# CONFIG_MAX31827 is not set +# CONFIG_MAX31856 is not set +# CONFIG_MAX31865 is not set +# CONFIG_MAX34408 is not set +# CONFIG_MAX44000 is not set +# CONFIG_MAX44009 is not set +# CONFIG_MAX517 is not set +# CONFIG_MAX5432 is not set +# CONFIG_MAX5481 is not set +# CONFIG_MAX5487 is not set +# CONFIG_MAX5522 is not set +# CONFIG_MAX5821 is not set +# CONFIG_MAX63XX_WATCHDOG is not set +# CONFIG_MAX9611 is not set +# CONFIG_MAXIM_THERMOCOUPLE is not set +# CONFIG_MAXLINEAR_GPHY is not set +CONFIG_MAX_SKB_FRAGS=17 +# CONFIG_MB1232 is not set +# CONFIG_MC3230 is not set +# CONFIG_MCB is not set +# CONFIG_MCP320X is not set +# CONFIG_MCP3422 is not set +# CONFIG_MCP3564 is not set +# CONFIG_MCP3911 is not set +# CONFIG_MCP4018 is not set +# CONFIG_MCP41010 is not set +# CONFIG_MCP4131 is not set +# CONFIG_MCP4531 is not set +# CONFIG_MCP4725 is not set +# CONFIG_MCP4728 is not set +# CONFIG_MCP4821 is not set +# CONFIG_MCP4922 is not set +# CONFIG_MCP9600 is not set +# CONFIG_MCPM is not set +# CONFIG_MCTP is not set +# CONFIG_MD is not set +# CONFIG_MDIO_BCM_UNIMAC is not set +# CONFIG_MDIO_BITBANG is not set +# CONFIG_MDIO_BUS_MUX_GPIO is not set +# CONFIG_MDIO_BUS_MUX_MMIOREG is not set +# CONFIG_MDIO_BUS_MUX_MULTIPLEXER is not set +# CONFIG_MDIO_DEVICE is not set +# CONFIG_MDIO_DEVRES is not set +# CONFIG_MDIO_HISI_FEMAC is not set +# CONFIG_MDIO_IPQ4019 is not set +# CONFIG_MDIO_IPQ8064 is not set +# CONFIG_MDIO_MSCC_MIIM is not set +# CONFIG_MDIO_MVUSB is not set +# CONFIG_MDIO_OCTEON is not set +# CONFIG_MDIO_THUNDER is not set +# CONFIG_MDM_GCC_9607 is not set +# CONFIG_MD_BITMAP_FILE is not set +# CONFIG_MEDIATEK_GE_PHY is not set +# CONFIG_MEDIATEK_MT6577_AUXADC is not set +# CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set +# CONFIG_MEDIA_ATTACH is not set +# CONFIG_MEDIA_CAMERA_SUPPORT is not set +# CONFIG_MEDIA_CEC_SUPPORT is not set +# CONFIG_MEDIA_CONTROLLER is not set +# CONFIG_MEDIA_CONTROLLER_DVB is not set +# CONFIG_MEDIA_DIGITAL_TV_SUPPORT is not set +# CONFIG_MEDIA_PCI_SUPPORT is not set +# CONFIG_MEDIA_PLATFORM_DRIVERS is not set +# CONFIG_MEDIA_PLATFORM_SUPPORT is not set +# CONFIG_MEDIA_RADIO_SUPPORT is not set +# CONFIG_MEDIA_SDR_SUPPORT is not set +# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set +# CONFIG_MEDIA_SUPPORT is not set +# CONFIG_MEDIA_SUPPORT_FILTER is not set +# CONFIG_MEDIA_TEST_SUPPORT is not set +# CONFIG_MEDIA_TUNER_E4000 is not set +# CONFIG_MEDIA_TUNER_FC0011 is not set +# CONFIG_MEDIA_TUNER_FC0012 is not set +# CONFIG_MEDIA_TUNER_FC0013 is not set +# CONFIG_MEDIA_TUNER_FC2580 is not set +# CONFIG_MEDIA_TUNER_IT913X is not set +# CONFIG_MEDIA_TUNER_M88RS6000T is not set +# CONFIG_MEDIA_TUNER_MAX2165 is not set +# CONFIG_MEDIA_TUNER_MC44S803 is not set +# CONFIG_MEDIA_TUNER_MSI001 is not set +# CONFIG_MEDIA_TUNER_MT2060 is not set +# CONFIG_MEDIA_TUNER_MT2063 is not set +# CONFIG_MEDIA_TUNER_MT20XX is not set +# CONFIG_MEDIA_TUNER_MT2131 is not set +# CONFIG_MEDIA_TUNER_MT2266 is not set +# CONFIG_MEDIA_TUNER_MXL301RF is not set +# CONFIG_MEDIA_TUNER_MXL5005S is not set +# CONFIG_MEDIA_TUNER_MXL5007T is not set +# CONFIG_MEDIA_TUNER_QM1D1B0004 is not set +# CONFIG_MEDIA_TUNER_QM1D1C0042 is not set +# CONFIG_MEDIA_TUNER_QT1010 is not set +# CONFIG_MEDIA_TUNER_R820T is not set +# CONFIG_MEDIA_TUNER_SI2157 is not set +# CONFIG_MEDIA_TUNER_SIMPLE is not set +# CONFIG_MEDIA_TUNER_TDA18212 is not set +# CONFIG_MEDIA_TUNER_TDA18218 is not set +# CONFIG_MEDIA_TUNER_TDA18250 is not set +# CONFIG_MEDIA_TUNER_TDA18271 is not set +# CONFIG_MEDIA_TUNER_TDA827X is not set +# CONFIG_MEDIA_TUNER_TDA8290 is not set +# CONFIG_MEDIA_TUNER_TDA9887 is not set +# CONFIG_MEDIA_TUNER_TEA5761 is not set +# CONFIG_MEDIA_TUNER_TEA5767 is not set +# CONFIG_MEDIA_TUNER_TUA9001 is not set +# CONFIG_MEDIA_TUNER_XC2028 is not set +# CONFIG_MEDIA_TUNER_XC4000 is not set +# CONFIG_MEDIA_TUNER_XC5000 is not set +# CONFIG_MEDIA_USB_SUPPORT is not set +# CONFIG_MEGARAID_LEGACY is not set +# CONFIG_MEGARAID_NEWGEN is not set +# CONFIG_MEGARAID_SAS is not set +# CONFIG_MELLANOX_PLATFORM is not set +CONFIG_MEMBARRIER=y +CONFIG_MEMFD_CREATE=y +# CONFIG_MEMORY is not set +# CONFIG_MEMORY_FAILURE is not set +# CONFIG_MEMORY_HOTPLUG is not set +# CONFIG_MEMSTICK is not set +# CONFIG_MEMTEST is not set +# CONFIG_MEM_ALLOC_PROFILING is not set +# CONFIG_MEN_A21_WDT is not set +# CONFIG_MESON_SM is not set +CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 +# CONFIG_MFD_88PM800 is not set +# CONFIG_MFD_88PM805 is not set +# CONFIG_MFD_88PM860X is not set +# CONFIG_MFD_88PM886_PMIC is not set +# CONFIG_MFD_AAT2870_CORE is not set +# CONFIG_MFD_AC100 is not set +# CONFIG_MFD_ACT8945A is not set +# CONFIG_MFD_ADP5585 is not set +# CONFIG_MFD_ARIZONA_I2C is not set +# CONFIG_MFD_ARIZONA_SPI is not set +# CONFIG_MFD_AS3711 is not set +# CONFIG_MFD_AS3722 is not set +# CONFIG_MFD_ATC260X_I2C is not set +# CONFIG_MFD_ATMEL_FLEXCOM is not set +# CONFIG_MFD_ATMEL_HLCDC is not set +# CONFIG_MFD_AXP20X is not set +# CONFIG_MFD_AXP20X_I2C is not set +# CONFIG_MFD_BCM590XX is not set +# CONFIG_MFD_BD9571MWV is not set +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_CPCAP is not set +# CONFIG_MFD_CS40L50_I2C is not set +# CONFIG_MFD_CS40L50_SPI is not set +# CONFIG_MFD_CS42L43_I2C is not set +# CONFIG_MFD_CS5535 is not set +# CONFIG_MFD_DA9052_I2C is not set +# CONFIG_MFD_DA9052_SPI is not set +# CONFIG_MFD_DA9055 is not set +# CONFIG_MFD_DA9062 is not set +# CONFIG_MFD_DA9063 is not set +# CONFIG_MFD_DA9150 is not set +# CONFIG_MFD_DLN2 is not set +# CONFIG_MFD_EXYNOS_LPASS is not set +# CONFIG_MFD_GATEWORKS_GSC is not set +# CONFIG_MFD_HI6421_PMIC is not set +# CONFIG_MFD_INTEL_M10_BMC_SPI is not set +# CONFIG_MFD_INTEL_QUARK_I2C_GPIO is not set +# CONFIG_MFD_IQS62X is not set +# CONFIG_MFD_JANZ_CMODIO is not set +# CONFIG_MFD_KEMPLD is not set +# CONFIG_MFD_LM3533 is not set +# CONFIG_MFD_LOCHNAGAR is not set +# CONFIG_MFD_LP3943 is not set +# CONFIG_MFD_LP8788 is not set +# CONFIG_MFD_MADERA is not set +# CONFIG_MFD_MAX14577 is not set +# CONFIG_MFD_MAX5970 is not set +# CONFIG_MFD_MAX77541 is not set +# CONFIG_MFD_MAX77620 is not set +# CONFIG_MFD_MAX77650 is not set +# CONFIG_MFD_MAX77686 is not set +# CONFIG_MFD_MAX77693 is not set +# CONFIG_MFD_MAX77714 is not set +# CONFIG_MFD_MAX77843 is not set +# CONFIG_MFD_MAX8907 is not set +# CONFIG_MFD_MAX8925 is not set +# CONFIG_MFD_MAX8997 is not set +# CONFIG_MFD_MAX8998 is not set +# CONFIG_MFD_MC13XXX is not set +# CONFIG_MFD_MC13XXX_I2C is not set +# CONFIG_MFD_MC13XXX_SPI is not set +# CONFIG_MFD_MENF21BMC is not set +# CONFIG_MFD_MP2629 is not set +# CONFIG_MFD_MT6360 is not set +# CONFIG_MFD_MT6370 is not set +# CONFIG_MFD_MT6397 is not set +# CONFIG_MFD_NTXEC is not set +# CONFIG_MFD_OCELOT is not set +# CONFIG_MFD_OMAP_USB_HOST is not set +# CONFIG_MFD_PALMAS is not set +# CONFIG_MFD_PCF50633 is not set +# CONFIG_MFD_PM8XXX is not set +# CONFIG_MFD_QCOM_PM8008 is not set +# CONFIG_MFD_RC5T583 is not set +# CONFIG_MFD_RDC321X is not set +# CONFIG_MFD_RETU is not set +# CONFIG_MFD_RK8XX_I2C is not set +# CONFIG_MFD_RK8XX_SPI is not set +# CONFIG_MFD_RN5T618 is not set +# CONFIG_MFD_ROHM_BD71828 is not set +# CONFIG_MFD_ROHM_BD718XX is not set +# CONFIG_MFD_ROHM_BD957XMUF is not set +# CONFIG_MFD_ROHM_BD96801 is not set +# CONFIG_MFD_RSMU_I2C is not set +# CONFIG_MFD_RSMU_SPI is not set +# CONFIG_MFD_RT4831 is not set +# CONFIG_MFD_RT5033 is not set +# CONFIG_MFD_RT5120 is not set +# CONFIG_MFD_SEC_CORE is not set +# CONFIG_MFD_SI476X_CORE is not set +# CONFIG_MFD_SKY81452 is not set +# CONFIG_MFD_SL28CPLD is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_SMPRO is not set +# CONFIG_MFD_STMFX is not set +# CONFIG_MFD_STMPE is not set +# CONFIG_MFD_STPMIC1 is not set +# CONFIG_MFD_SY7636A is not set +# CONFIG_MFD_SYSCON is not set +# CONFIG_MFD_TC3589X is not set +# CONFIG_MFD_TIMBERDALE is not set +# CONFIG_MFD_TI_AM335X_TSCADC is not set +# CONFIG_MFD_TI_LMU is not set +# CONFIG_MFD_TI_LP873X is not set +# CONFIG_MFD_TI_LP87565 is not set +# CONFIG_MFD_TPS65086 is not set +# CONFIG_MFD_TPS65090 is not set +# CONFIG_MFD_TPS65217 is not set +# CONFIG_MFD_TPS65218 is not set +# CONFIG_MFD_TPS65219 is not set +# CONFIG_MFD_TPS6586X is not set +# CONFIG_MFD_TPS65910 is not set +# CONFIG_MFD_TPS65912 is not set +# CONFIG_MFD_TPS65912_I2C is not set +# CONFIG_MFD_TPS65912_SPI is not set +# CONFIG_MFD_TPS6594_I2C is not set +# CONFIG_MFD_TPS6594_SPI is not set +# CONFIG_MFD_TQMX86 is not set +# CONFIG_MFD_VIPERBOARD is not set +# CONFIG_MFD_VX855 is not set +# CONFIG_MFD_WL1273_CORE is not set +# CONFIG_MFD_WM831X is not set +# CONFIG_MFD_WM831X_I2C is not set +# CONFIG_MFD_WM831X_SPI is not set +# CONFIG_MFD_WM8350_I2C is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM8994 is not set +# CONFIG_MHI_BUS is not set +# CONFIG_MHI_BUS_DEBUG is not set +# CONFIG_MHI_BUS_EP is not set +# CONFIG_MHI_BUS_PCI_GENERIC is not set +# CONFIG_MHI_NET is not set +# CONFIG_MHI_WWAN_CTRL is not set +# CONFIG_MHI_WWAN_MBIM is not set +# CONFIG_MICREL_KS8995MA is not set +# CONFIG_MICREL_PHY is not set +# CONFIG_MICROCHIP_PHY is not set +# CONFIG_MICROCHIP_PIT64B is not set +# CONFIG_MICROCHIP_T1S_PHY is not set +# CONFIG_MICROCHIP_T1_PHY is not set +# CONFIG_MICROSEMI_PHY is not set +# CONFIG_MIGRATION is not set +CONFIG_MII=y +# CONFIG_MIKROTIK is not set +# CONFIG_MIKROTIK_RB532 is not set +# CONFIG_MINIX_FS is not set +# CONFIG_MINIX_FS_NATIVE_ENDIAN is not set +# CONFIG_MINIX_SUBPARTITION is not set +# CONFIG_MIPS32_N32 is not set +# CONFIG_MIPS32_O32 is not set +# CONFIG_MIPS_ALCHEMY is not set +# CONFIG_MIPS_CDMM is not set +# CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set +# CONFIG_MIPS_CMDLINE_FROM_DTB is not set +# CONFIG_MIPS_COBALT is not set +# CONFIG_MIPS_CPS is not set +# CONFIG_MIPS_ELF_APPENDED_DTB is not set +# CONFIG_MIPS_FP_SUPPORT is not set +# CONFIG_MIPS_GENERIC is not set +# CONFIG_MIPS_GENERIC_KERNEL is not set +# CONFIG_MIPS_MALTA is not set +# CONFIG_MIPS_O32_FP64_SUPPORT is not set +# CONFIG_MIPS_PLATFORM_DEVICES is not set +# CONFIG_MIPS_RAW_APPENDED_DTB is not set +# CONFIG_MIPS_VA_BITS_48 is not set +# CONFIG_MIPS_VPE_LOADER is not set +# CONFIG_MISC_ALCOR_PCI is not set +CONFIG_MISC_FILESYSTEMS=y +# CONFIG_MISC_RTSX_PCI is not set +# CONFIG_MISC_RTSX_USB is not set +# CONFIG_MISDN is not set +# CONFIG_MISDN_AVMFRITZ is not set +# CONFIG_MISDN_HFCPCI is not set +# CONFIG_MISDN_HFCUSB is not set +# CONFIG_MISDN_INFINEON is not set +# CONFIG_MISDN_NETJET is not set +# CONFIG_MISDN_SPEEDFAX is not set +# CONFIG_MISDN_W6692 is not set +CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY=y +# CONFIG_MKISS is not set +# CONFIG_MLX4_CORE is not set +# CONFIG_MLX4_EN is not set +# CONFIG_MLX5_CORE is not set +# CONFIG_MLX5_DPLL is not set +# CONFIG_MLX5_MACSEC is not set +# CONFIG_MLX5_SF is not set +# CONFIG_MLX5_VFIO_PCI is not set +# CONFIG_MLX90614 is not set +# CONFIG_MLX90632 is not set +# CONFIG_MLX90635 is not set +# CONFIG_MLXFW is not set +# CONFIG_MLXSW_CORE is not set +# CONFIG_MLX_PLATFORM is not set +# CONFIG_MMA7455_I2C is not set +# CONFIG_MMA7455_SPI is not set +# CONFIG_MMA7660 is not set +# CONFIG_MMA8452 is not set +# CONFIG_MMA9551 is not set +# CONFIG_MMA9553 is not set +# CONFIG_MMC is not set +# CONFIG_MMC35240 is not set +# CONFIG_MMC_ARMMMCI is not set +# CONFIG_MMC_AU1X is not set +# CONFIG_MMC_BLOCK is not set +CONFIG_MMC_BLOCK_MINORS=8 +# CONFIG_MMC_CAVIUM_THUNDERX is not set +# CONFIG_MMC_CB710 is not set +# CONFIG_MMC_CQHCI is not set +# CONFIG_MMC_DEBUG is not set +# CONFIG_MMC_DW is not set +# CONFIG_MMC_HSQ is not set +# CONFIG_MMC_JZ4740 is not set +# CONFIG_MMC_MTK is not set +# CONFIG_MMC_MVSDIO is not set +# CONFIG_MMC_SDHCI is not set +# CONFIG_MMC_SDHCI_ACPI is not set +# CONFIG_MMC_SDHCI_AM654 is not set +# CONFIG_MMC_SDHCI_BCM_KONA is not set +# CONFIG_MMC_SDHCI_BRCMSTB is not set +# CONFIG_MMC_SDHCI_CADENCE is not set +# CONFIG_MMC_SDHCI_F_SDH30 is not set +# CONFIG_MMC_SDHCI_IPROC is not set +# CONFIG_MMC_SDHCI_MILBEAUT is not set +# CONFIG_MMC_SDHCI_MSM is not set +# CONFIG_MMC_SDHCI_OF_ARASAN is not set +# CONFIG_MMC_SDHCI_OF_ASPEED is not set +# CONFIG_MMC_SDHCI_OF_AT91 is not set +# CONFIG_MMC_SDHCI_OF_DWCMSHC is not set +# CONFIG_MMC_SDHCI_OF_ESDHC is not set +# CONFIG_MMC_SDHCI_OF_HLWD is not set +# CONFIG_MMC_SDHCI_OMAP is not set +# CONFIG_MMC_SDHCI_PCI is not set +# CONFIG_MMC_SDHCI_PXAV2 is not set +# CONFIG_MMC_SDHCI_PXAV3 is not set +# CONFIG_MMC_SDHCI_S3C is not set +# CONFIG_MMC_SDHCI_XENON is not set +# CONFIG_MMC_SDRICOH_CS is not set +# CONFIG_MMC_SPI is not set +# CONFIG_MMC_STM32_SDMMC is not set +# CONFIG_MMC_TEST is not set +# CONFIG_MMC_TIFM_SD is not set +# CONFIG_MMC_TOSHIBA_PCI is not set +# CONFIG_MMC_USDHI6ROL0 is not set +# CONFIG_MMC_USHC is not set +# CONFIG_MMC_VIA_SDMMC is not set +# CONFIG_MMC_VUB300 is not set +# CONFIG_MMIOTRACE is not set +CONFIG_MMU=y +CONFIG_MMU_GATHER_RCU_TABLE_FREE=y +CONFIG_MMU_GATHER_TABLE_FREE=y +CONFIG_MODPROBE_PATH="/sbin/modprobe" +CONFIG_MODULES=y +# CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is not set +# CONFIG_MODULE_COMPRESS is not set +# CONFIG_MODULE_COMPRESS_GZIP is not set +# CONFIG_MODULE_COMPRESS_XZ is not set +# CONFIG_MODULE_COMPRESS_ZSTD is not set +# CONFIG_MODULE_DEBUG is not set +# CONFIG_MODULE_FORCE_LOAD is not set +# CONFIG_MODULE_FORCE_UNLOAD is not set +# CONFIG_MODULE_SIG is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_MODULE_STRIPPED=y +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_UNLOAD_TAINT_TRACKING is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MOST is not set +# CONFIG_MOTORCOMM_PHY is not set +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_CYAPA is not set +# CONFIG_MOUSE_ELAN_I2C is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_MOUSE_INPORT is not set +# CONFIG_MOUSE_LOGIBM is not set +# CONFIG_MOUSE_PC110PAD is not set +# CONFIG_MOUSE_PS2_FOCALTECH is not set +# CONFIG_MOUSE_PS2_SENTELIC is not set +# CONFIG_MOUSE_SERIAL is not set +# CONFIG_MOUSE_SYNAPTICS_I2C is not set +# CONFIG_MOUSE_SYNAPTICS_USB is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOXTET is not set +# CONFIG_MPL115 is not set +# CONFIG_MPL115_I2C is not set +# CONFIG_MPL115_SPI is not set +# CONFIG_MPL3115 is not set +# CONFIG_MPLS is not set +# CONFIG_MPLS_IPTUNNEL is not set +# CONFIG_MPLS_ROUTING is not set +# CONFIG_MPRLS0025PA is not set +# CONFIG_MPTCP is not set +# CONFIG_MPU3050_I2C is not set +# CONFIG_MQ_IOSCHED_DEADLINE is not set +# CONFIG_MQ_IOSCHED_KYBER is not set +# CONFIG_MS5611 is not set +# CONFIG_MS5637 is not set +# CONFIG_MSA311 is not set +# CONFIG_MSCC_OCELOT_SWITCH is not set +# CONFIG_MSDOS_FS is not set +CONFIG_MSDOS_PARTITION=y +# CONFIG_MSE102X is not set +# CONFIG_MSI_BITMAP_SELFTEST is not set +# CONFIG_MSI_LAPTOP is not set +# CONFIG_MSI_WMI is not set +# CONFIG_MSI_WMI_PLATFORM is not set +# CONFIG_MSM_GCC_8953 is not set +# CONFIG_MSM_MMCC_8994 is not set +# CONFIG_MST_IRQ is not set +CONFIG_MTD=y +# CONFIG_MTD_ABSENT is not set +# CONFIG_MTD_AFS_PARTS is not set +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_MTD_BLOCK2MTD is not set +CONFIG_MTD_CFI=y +# CONFIG_MTD_CFI_ADV_OPTIONS is not set +CONFIG_MTD_CFI_AMDSTD=y +# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +CONFIG_MTD_CFI_INTELEXT=y +# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set +CONFIG_MTD_CFI_NOSWAP=y +# CONFIG_MTD_CFI_STAA is not set +CONFIG_MTD_CFI_UTIL=y +# CONFIG_MTD_CMDLINE_PARTS is not set +CONFIG_MTD_COMPLEX_MAPPINGS=y +# CONFIG_MTD_DATAFLASH is not set +# CONFIG_MTD_DOCG3 is not set +CONFIG_MTD_GEN_PROBE=y +# CONFIG_MTD_HYPERBUS is not set +# CONFIG_MTD_IMPA7 is not set +# CONFIG_MTD_JEDECPROBE is not set +# CONFIG_MTD_LPDDR is not set +# CONFIG_MTD_LPDDR2_NVM is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +CONFIG_MTD_MAP_BANK_WIDTH_2=y +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MCHP23K256 is not set +# CONFIG_MTD_MCHP48L640 is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_MYLOADER_PARTS is not set +# CONFIG_MTD_NAND_AMS_DELTA is not set +# CONFIG_MTD_NAND_ARASAN is not set +# CONFIG_MTD_NAND_ATMEL is not set +# CONFIG_MTD_NAND_AU1550 is not set +# CONFIG_MTD_NAND_BRCMNAND is not set +# CONFIG_MTD_NAND_BRCMNAND_BCM63XX is not set +# CONFIG_MTD_NAND_BRCMNAND_BCMBCA is not set +# CONFIG_MTD_NAND_BRCMNAND_BRCMSTB is not set +# CONFIG_MTD_NAND_BRCMNAND_IPROC is not set +# CONFIG_MTD_NAND_CADENCE is not set +# CONFIG_MTD_NAND_CAFE is not set +# CONFIG_MTD_NAND_CS553X is not set +# CONFIG_MTD_NAND_DAVINCI is not set +# CONFIG_MTD_NAND_DENALI is not set +# CONFIG_MTD_NAND_DENALI_DT is not set +# CONFIG_MTD_NAND_DENALI_PCI is not set +# CONFIG_MTD_NAND_DISKONCHIP is not set +# CONFIG_MTD_NAND_ECC is not set +# CONFIG_MTD_NAND_ECC_MXIC is not set +# CONFIG_MTD_NAND_ECC_SW_BCH is not set +# CONFIG_MTD_NAND_ECC_SW_HAMMING is not set +# CONFIG_MTD_NAND_ECC_SW_HAMMING_SMC is not set +# CONFIG_MTD_NAND_FSL_ELBC is not set +# CONFIG_MTD_NAND_FSL_IFC is not set +# CONFIG_MTD_NAND_FSL_UPM is not set +# CONFIG_MTD_NAND_FSMC is not set +# CONFIG_MTD_NAND_GPIO is not set +# CONFIG_MTD_NAND_GPMI_NAND is not set +# CONFIG_MTD_NAND_HISI504 is not set +# CONFIG_MTD_NAND_INTEL_LGM is not set +# CONFIG_MTD_NAND_MPC5121_NFC is not set +# CONFIG_MTD_NAND_MTK is not set +# CONFIG_MTD_NAND_MTK_BMT is not set +# CONFIG_MTD_NAND_MXC is not set +# CONFIG_MTD_NAND_MXIC is not set +# CONFIG_MTD_NAND_NANDSIM is not set +# CONFIG_MTD_NAND_NDFC is not set +# CONFIG_MTD_NAND_OMAP2 is not set +# CONFIG_MTD_NAND_OMAP_BCH_BUILD is not set +# CONFIG_MTD_NAND_ORION is not set +# CONFIG_MTD_NAND_PASEMI is not set +# CONFIG_MTD_NAND_PLATFORM is not set +# CONFIG_MTD_NAND_RICOH is not set +# CONFIG_MTD_NAND_S3C2410 is not set +# CONFIG_MTD_NAND_SHARPSL is not set +# CONFIG_MTD_NAND_SH_FLCTL is not set +# CONFIG_MTD_NAND_SOCRATES is not set +# CONFIG_MTD_NAND_TXX9NDFMC is not set +CONFIG_MTD_OF_PARTS=y +# CONFIG_MTD_ONENAND is not set +# CONFIG_MTD_OOPS is not set +# CONFIG_MTD_OTP is not set +# CONFIG_MTD_PARSER_TRX is not set +# CONFIG_MTD_PARTITIONED_MASTER is not set +# CONFIG_MTD_PCI is not set +# CONFIG_MTD_PCMCIA is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_PHYSMAP is not set +# CONFIG_MTD_PHYSMAP_COMPAT is not set +# CONFIG_MTD_PHYSMAP_GEMINI is not set +# CONFIG_MTD_PHYSMAP_GPIO_ADDR is not set +# CONFIG_MTD_PHYSMAP_IXP4XX is not set +CONFIG_MTD_PHYSMAP_OF=y +# CONFIG_MTD_PHYSMAP_VERSATILE is not set +# CONFIG_MTD_PLATRAM is not set +# CONFIG_MTD_PMC551 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_RAW_NAND is not set +CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 +# CONFIG_MTD_REDBOOT_PARTS is not set +# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set +# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set +# CONFIG_MTD_ROM is not set +CONFIG_MTD_ROOTFS_ROOT_DEV=y +# CONFIG_MTD_ROUTERBOOT_PARTS is not set +# CONFIG_MTD_SERCOMM_PARTS is not set +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_SM_COMMON is not set +# CONFIG_MTD_SPI_NAND is not set +# CONFIG_MTD_SPI_NOR is not set +# CONFIG_MTD_SPI_NOR_SWP_DISABLE is not set +CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE=y +# CONFIG_MTD_SPI_NOR_SWP_KEEP is not set +# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set +# CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE is not set +CONFIG_MTD_SPLIT=y +# CONFIG_MTD_SPLIT_BCM63XX_FW is not set +# CONFIG_MTD_SPLIT_BCM_WFI_FW is not set +# CONFIG_MTD_SPLIT_BRNIMAGE_FW is not set +# CONFIG_MTD_SPLIT_ELF_FW is not set +# CONFIG_MTD_SPLIT_EVA_FW is not set +# CONFIG_MTD_SPLIT_FIRMWARE is not set +CONFIG_MTD_SPLIT_FIRMWARE_NAME="firmware" +# CONFIG_MTD_SPLIT_FIT_FW is not set +# CONFIG_MTD_SPLIT_H3C_VFS is not set +# CONFIG_MTD_SPLIT_JIMAGE_FW is not set +# CONFIG_MTD_SPLIT_LZMA_FW is not set +# CONFIG_MTD_SPLIT_MINOR_FW is not set +# CONFIG_MTD_SPLIT_MSTC_BOOT is not set +# CONFIG_MTD_SPLIT_OPENWRT_PROLOG is not set +# CONFIG_MTD_SPLIT_SEAMA_FW is not set +# CONFIG_MTD_SPLIT_SEIL_FW is not set +CONFIG_MTD_SPLIT_SQUASHFS_ROOT=y +CONFIG_MTD_SPLIT_SUPPORT=y +# CONFIG_MTD_SPLIT_TPLINK_FW is not set +# CONFIG_MTD_SPLIT_TRX_FW is not set +# CONFIG_MTD_SPLIT_UIMAGE_FW is not set +# CONFIG_MTD_SPLIT_WRGG_FW is not set +# CONFIG_MTD_SST25L is not set +# CONFIG_MTD_SWAP is not set +# CONFIG_MTD_TESTS is not set +# CONFIG_MTD_UBI is not set +# CONFIG_MTD_UBI_FASTMAP is not set +# CONFIG_MTD_UBI_GLUEBI is not set +# CONFIG_MTD_UBI_NVMEM is not set +# CONFIG_MTD_VIRT_CONCAT is not set +# CONFIG_MTK_DEVAPC is not set +# CONFIG_MTK_MMSYS is not set +# CONFIG_MTK_T7XX is not set +# CONFIG_MTK_THERMAL is not set +# CONFIG_MULTIPLEXER is not set +CONFIG_MULTIUSER=y +# CONFIG_MUTEX_SPIN_ON_OWNER is not set +# CONFIG_MUX_ADG792A is not set +# CONFIG_MUX_ADGS1408 is not set +# CONFIG_MUX_GPIO is not set +# CONFIG_MUX_MMIO is not set +# CONFIG_MV643XX_ETH is not set +# CONFIG_MVMDIO is not set +# CONFIG_MVNETA_BM is not set +# CONFIG_MV_XOR_V2 is not set +# CONFIG_MWAVE is not set +# CONFIG_MWL8K is not set +# CONFIG_MXC4005 is not set +# CONFIG_MXC6255 is not set +# CONFIG_MXM_WMI is not set +# CONFIG_MYRI10GE is not set +# CONFIG_NAMESPACES is not set +# CONFIG_NATIONAL_PHY is not set +# CONFIG_NATSEMI is not set +# CONFIG_NAU7802 is not set +# CONFIG_NBPFAXI_DMA is not set +# CONFIG_NCN26000_PHY is not set +# CONFIG_NE2000 is not set +# CONFIG_NE2K_PCI is not set +CONFIG_NEED_TASKS_RCU=y +CONFIG_NET=y +# CONFIG_NETCONSOLE is not set +# CONFIG_NETCONSOLE_EXTENDED_LOG is not set +CONFIG_NETDEVICES=y +# CONFIG_NETDEVSIM is not set +# CONFIG_NETFILTER is not set +# CONFIG_NETFILTER_ADVANCED is not set +# CONFIG_NETFILTER_EGRESS is not set +# CONFIG_NETFILTER_INGRESS is not set +# CONFIG_NETFILTER_NETLINK is not set +# CONFIG_NETFILTER_NETLINK_ACCT is not set +# CONFIG_NETFILTER_NETLINK_GLUE_CT is not set +# CONFIG_NETFILTER_NETLINK_HOOK is not set +# CONFIG_NETFILTER_NETLINK_LOG is not set +# CONFIG_NETFILTER_NETLINK_OSF is not set +# CONFIG_NETFILTER_NETLINK_QUEUE is not set +# CONFIG_NETFILTER_XTABLES is not set +# CONFIG_NETFILTER_XTABLES_COMPAT is not set +# CONFIG_NETFILTER_XT_CONNMARK is not set +# CONFIG_NETFILTER_XT_MARK is not set +# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set +# CONFIG_NETFILTER_XT_MATCH_BPF is not set +# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set +# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set +# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set +# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set +# CONFIG_NETFILTER_XT_MATCH_CONNLABEL is not set +# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set +# CONFIG_NETFILTER_XT_MATCH_CONNTRACK is not set +# CONFIG_NETFILTER_XT_MATCH_CPU is not set +# CONFIG_NETFILTER_XT_MATCH_DCCP is not set +# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set +# CONFIG_NETFILTER_XT_MATCH_DSCP is not set +# CONFIG_NETFILTER_XT_MATCH_ECN is not set +# CONFIG_NETFILTER_XT_MATCH_ESP is not set +# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_HELPER is not set +# CONFIG_NETFILTER_XT_MATCH_HL is not set +# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set +# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set +# CONFIG_NETFILTER_XT_MATCH_L2TP is not set +# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set +# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set +# CONFIG_NETFILTER_XT_MATCH_MAC is not set +# CONFIG_NETFILTER_XT_MATCH_MARK is not set +# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set +# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set +# CONFIG_NETFILTER_XT_MATCH_OSF is not set +# CONFIG_NETFILTER_XT_MATCH_OWNER is not set +# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set +# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set +# CONFIG_NETFILTER_XT_MATCH_POLICY is not set +# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set +# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set +# CONFIG_NETFILTER_XT_MATCH_REALM is not set +# CONFIG_NETFILTER_XT_MATCH_RECENT is not set +# CONFIG_NETFILTER_XT_MATCH_SCTP is not set +# CONFIG_NETFILTER_XT_MATCH_SOCKET is not set +# CONFIG_NETFILTER_XT_MATCH_STATE is not set +# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set +# CONFIG_NETFILTER_XT_MATCH_STRING is not set +# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set +# CONFIG_NETFILTER_XT_MATCH_TIME is not set +# CONFIG_NETFILTER_XT_MATCH_U32 is not set +# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set +# CONFIG_NETFILTER_XT_TARGET_CHECKSUM is not set +# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set +# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set +# CONFIG_NETFILTER_XT_TARGET_CT is not set +# CONFIG_NETFILTER_XT_TARGET_DSCP is not set +# CONFIG_NETFILTER_XT_TARGET_HL is not set +# CONFIG_NETFILTER_XT_TARGET_HMARK is not set +# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set +# CONFIG_NETFILTER_XT_TARGET_LED is not set +# CONFIG_NETFILTER_XT_TARGET_LOG is not set +# CONFIG_NETFILTER_XT_TARGET_MARK is not set +# CONFIG_NETFILTER_XT_TARGET_NETMAP is not set +# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set +# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set +# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set +# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set +# CONFIG_NETFILTER_XT_TARGET_REDIRECT is not set +# CONFIG_NETFILTER_XT_TARGET_SECMARK is not set +# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set +# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set +# CONFIG_NETFILTER_XT_TARGET_TEE is not set +# CONFIG_NETFILTER_XT_TARGET_TPROXY is not set +# CONFIG_NETFILTER_XT_TARGET_TRACE is not set +# CONFIG_NETFS_DEBUG is not set +# CONFIG_NETFS_STATS is not set +# CONFIG_NETKIT is not set +# CONFIG_NETLABEL is not set +# CONFIG_NETLINK_DIAG is not set +# CONFIG_NETPOLL is not set +# CONFIG_NETROM is not set +CONFIG_NETWORK_FILESYSTEMS=y +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETXEN_NIC is not set +# CONFIG_NET_9P is not set +# CONFIG_NET_9P_USBG is not set +# CONFIG_NET_9P_XEN is not set +# CONFIG_NET_ACT_BPF is not set +# CONFIG_NET_ACT_CSUM is not set +# CONFIG_NET_ACT_CT is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_GATE is not set +# CONFIG_NET_ACT_IFE is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_MPLS is not set +# CONFIG_NET_ACT_NAT is not set +# CONFIG_NET_ACT_PEDIT is not set +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_SAMPLE is not set +# CONFIG_NET_ACT_SIMP is not set +# CONFIG_NET_ACT_SKBEDIT is not set +# CONFIG_NET_ACT_SKBMOD is not set +# CONFIG_NET_ACT_TUNNEL_KEY is not set +# CONFIG_NET_ACT_VLAN is not set +# CONFIG_NET_CALXEDA_XGMAC is not set +CONFIG_NET_CLS=y +# CONFIG_NET_CLS_ACT is not set +# CONFIG_NET_CLS_BASIC is not set +# CONFIG_NET_CLS_BPF is not set +# CONFIG_NET_CLS_FLOW is not set +# CONFIG_NET_CLS_FLOWER is not set +# CONFIG_NET_CLS_FW is not set +# CONFIG_NET_CLS_MATCHALL is not set +# CONFIG_NET_CLS_ROUTE4 is not set +# CONFIG_NET_CLS_U32 is not set +CONFIG_NET_CORE=y +# CONFIG_NET_DEVLINK is not set +# CONFIG_NET_DEV_REFCNT_TRACKER is not set +# CONFIG_NET_DROP_MONITOR is not set +# CONFIG_NET_DSA is not set +# CONFIG_NET_DSA_AR9331 is not set +# CONFIG_NET_DSA_BCM_SF2 is not set +# CONFIG_NET_DSA_KS8995 is not set +# CONFIG_NET_DSA_LANTIQ_GSWIP is not set +# CONFIG_NET_DSA_LOOP is not set +# CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON is not set +# CONFIG_NET_DSA_MSCC_FELIX is not set +# CONFIG_NET_DSA_MSCC_OCELOT_EXT is not set +# CONFIG_NET_DSA_MSCC_SEVILLE is not set +# CONFIG_NET_DSA_MT7530 is not set +# CONFIG_NET_DSA_MV88E6060 is not set +# CONFIG_NET_DSA_MV88E6XXX is not set +# CONFIG_NET_DSA_MV88E6XXX_LEDS is not set +# CONFIG_NET_DSA_MV88E6XXX_PTP is not set +# CONFIG_NET_DSA_QCA8K is not set +# CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT is not set +# CONFIG_NET_DSA_REALTEK is not set +# CONFIG_NET_DSA_REALTEK_SMI is not set +# CONFIG_NET_DSA_SJA1105 is not set +# CONFIG_NET_DSA_SMSC_LAN9303_I2C is not set +# CONFIG_NET_DSA_SMSC_LAN9303_MDIO is not set +# CONFIG_NET_DSA_TAG_AR9331 is not set +# CONFIG_NET_DSA_TAG_BRCM is not set +# CONFIG_NET_DSA_TAG_BRCM_LEGACY is not set +# CONFIG_NET_DSA_TAG_BRCM_LEGACY_FCS is not set +# CONFIG_NET_DSA_TAG_BRCM_PREPEND is not set +# CONFIG_NET_DSA_TAG_DSA is not set +# CONFIG_NET_DSA_TAG_EDSA is not set +# CONFIG_NET_DSA_TAG_GSWIP is not set +# CONFIG_NET_DSA_TAG_HELLCREEK is not set +# CONFIG_NET_DSA_TAG_KSZ is not set +# CONFIG_NET_DSA_TAG_LAN9303 is not set +# CONFIG_NET_DSA_TAG_MTK is not set +# CONFIG_NET_DSA_TAG_NONE is not set +# CONFIG_NET_DSA_TAG_OCELOT is not set +# CONFIG_NET_DSA_TAG_OCELOT_8021Q is not set +# CONFIG_NET_DSA_TAG_QCA is not set +# CONFIG_NET_DSA_TAG_RTL4_A is not set +# CONFIG_NET_DSA_TAG_RTL8_4 is not set +# CONFIG_NET_DSA_TAG_RZN1_A5PSW is not set +# CONFIG_NET_DSA_TAG_SJA1105 is not set +# CONFIG_NET_DSA_TAG_TRAILER is not set +# CONFIG_NET_DSA_TAG_VSC73XX_8021Q is not set +# CONFIG_NET_DSA_TAG_XRS700X is not set +# CONFIG_NET_DSA_VITESSE_VSC73XX is not set +# CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM is not set +# CONFIG_NET_DSA_VITESSE_VSC73XX_SPI is not set +# CONFIG_NET_DSA_XRS700X_I2C is not set +# CONFIG_NET_DSA_XRS700X_MDIO is not set +# CONFIG_NET_EMATCH is not set +# CONFIG_NET_EMATCH_CANID is not set +# CONFIG_NET_EMATCH_CMP is not set +# CONFIG_NET_EMATCH_IPT is not set +# CONFIG_NET_EMATCH_META is not set +# CONFIG_NET_EMATCH_NBYTE is not set +CONFIG_NET_EMATCH_STACK=32 +# CONFIG_NET_EMATCH_TEXT is not set +# CONFIG_NET_EMATCH_U32 is not set +# CONFIG_NET_FAILOVER is not set +# CONFIG_NET_FC is not set +# CONFIG_NET_FOU is not set +# CONFIG_NET_FOU_IP_TUNNELS is not set +# CONFIG_NET_IFE is not set +# CONFIG_NET_IPGRE is not set +CONFIG_NET_IPGRE_BROADCAST=y +# CONFIG_NET_IPGRE_DEMUX is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPVTI is not set +# CONFIG_NET_IP_TUNNEL is not set +# CONFIG_NET_KEY is not set +# CONFIG_NET_KEY_MIGRATE is not set +# CONFIG_NET_L3_MASTER_DEV is not set +# CONFIG_NET_MEDIATEK_STAR_EMAC is not set +# CONFIG_NET_MPLS_GSO is not set +# CONFIG_NET_NCSI is not set +# CONFIG_NET_NSH is not set +# CONFIG_NET_NS_REFCNT_TRACKER is not set +# CONFIG_NET_PKTGEN is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_NET_PTP_CLASSIFY is not set +CONFIG_NET_RX_BUSY_POLL=y +# CONFIG_NET_SB1000 is not set +CONFIG_NET_SCHED=y +# CONFIG_NET_SCH_CAKE is not set +# CONFIG_NET_SCH_CBS is not set +# CONFIG_NET_SCH_CHOKE is not set +# CONFIG_NET_SCH_CODEL is not set +CONFIG_NET_SCH_DEFAULT=y +# CONFIG_NET_SCH_DRR is not set +# CONFIG_NET_SCH_ETF is not set +# CONFIG_NET_SCH_ETS is not set +CONFIG_NET_SCH_FIFO=y +# CONFIG_NET_SCH_FQ is not set +CONFIG_NET_SCH_FQ_CODEL=y +# CONFIG_NET_SCH_FQ_PIE is not set +# CONFIG_NET_SCH_GRED is not set +# CONFIG_NET_SCH_HFSC is not set +# CONFIG_NET_SCH_HHF is not set +# CONFIG_NET_SCH_HTB is not set +# CONFIG_NET_SCH_INGRESS is not set +# CONFIG_NET_SCH_MQPRIO is not set +# CONFIG_NET_SCH_MULTIQ is not set +# CONFIG_NET_SCH_NETEM is not set +# CONFIG_NET_SCH_PIE is not set +# CONFIG_NET_SCH_PLUG is not set +# CONFIG_NET_SCH_PRIO is not set +# CONFIG_NET_SCH_QFQ is not set +# CONFIG_NET_SCH_RED is not set +# CONFIG_NET_SCH_SFB is not set +# CONFIG_NET_SCH_SFQ is not set +# CONFIG_NET_SCH_SKBPRIO is not set +# CONFIG_NET_SCH_TAPRIO is not set +# CONFIG_NET_SCH_TBF is not set +# CONFIG_NET_SCH_TEQL is not set +# CONFIG_NET_SELFTESTS is not set +CONFIG_NET_SOCK_MSG=y +CONFIG_NET_SWITCHDEV=y +# CONFIG_NET_TC_SKB_EXT is not set +# CONFIG_NET_TEAM is not set +# CONFIG_NET_TEAM_MODE_ACTIVEBACKUP is not set +# CONFIG_NET_TEAM_MODE_BROADCAST is not set +# CONFIG_NET_TEAM_MODE_LOADBALANCE is not set +# CONFIG_NET_TEAM_MODE_RANDOM is not set +# CONFIG_NET_TEAM_MODE_ROUNDROBIN is not set +# CONFIG_NET_TULIP is not set +# CONFIG_NET_UDP_TUNNEL is not set +CONFIG_NET_VENDOR_3COM=y +CONFIG_NET_VENDOR_8390=y +CONFIG_NET_VENDOR_ADAPTEC=y +CONFIG_NET_VENDOR_ADI=y +CONFIG_NET_VENDOR_AGERE=y +CONFIG_NET_VENDOR_ALACRITECH=y +CONFIG_NET_VENDOR_ALTEON=y +CONFIG_NET_VENDOR_AMAZON=y +CONFIG_NET_VENDOR_AMD=y +CONFIG_NET_VENDOR_AQUANTIA=y +CONFIG_NET_VENDOR_ARC=y +# CONFIG_NET_VENDOR_ASIX is not set +CONFIG_NET_VENDOR_ATHEROS=y +CONFIG_NET_VENDOR_BROADCOM=y +CONFIG_NET_VENDOR_BROCADE=y +CONFIG_NET_VENDOR_CADENCE=y +CONFIG_NET_VENDOR_CAVIUM=y +CONFIG_NET_VENDOR_CHELSIO=y +CONFIG_NET_VENDOR_CIRRUS=y +CONFIG_NET_VENDOR_CISCO=y +CONFIG_NET_VENDOR_CORTINA=y +CONFIG_NET_VENDOR_DAVICOM=y +CONFIG_NET_VENDOR_DEC=y +CONFIG_NET_VENDOR_DLINK=y +CONFIG_NET_VENDOR_EMULEX=y +# CONFIG_NET_VENDOR_ENGLEDER is not set +CONFIG_NET_VENDOR_EZCHIP=y +CONFIG_NET_VENDOR_FARADAY=y +CONFIG_NET_VENDOR_FREESCALE=y +CONFIG_NET_VENDOR_FUJITSU=y +# CONFIG_NET_VENDOR_FUNGIBLE is not set +CONFIG_NET_VENDOR_GOOGLE=y +CONFIG_NET_VENDOR_HISILICON=y +CONFIG_NET_VENDOR_HUAWEI=y +CONFIG_NET_VENDOR_I825XX=y +CONFIG_NET_VENDOR_IBM=y +CONFIG_NET_VENDOR_INTEL=y +# CONFIG_NET_VENDOR_LITEX is not set +CONFIG_NET_VENDOR_MARVELL=y +CONFIG_NET_VENDOR_MELLANOX=y +CONFIG_NET_VENDOR_META=y +CONFIG_NET_VENDOR_MICREL=y +CONFIG_NET_VENDOR_MICROCHIP=y +CONFIG_NET_VENDOR_MICROSEMI=y +# CONFIG_NET_VENDOR_MICROSOFT is not set +CONFIG_NET_VENDOR_MYRI=y +CONFIG_NET_VENDOR_NATSEMI=y +CONFIG_NET_VENDOR_NETERION=y +CONFIG_NET_VENDOR_NETRONOME=y +CONFIG_NET_VENDOR_NI=y +CONFIG_NET_VENDOR_NVIDIA=y +CONFIG_NET_VENDOR_OKI=y +CONFIG_NET_VENDOR_PACKET_ENGINES=y +CONFIG_NET_VENDOR_PENSANDO=y +CONFIG_NET_VENDOR_QLOGIC=y +CONFIG_NET_VENDOR_QUALCOMM=y +CONFIG_NET_VENDOR_RDC=y +CONFIG_NET_VENDOR_REALTEK=y +CONFIG_NET_VENDOR_RENESAS=y +CONFIG_NET_VENDOR_ROCKER=y +CONFIG_NET_VENDOR_SAMSUNG=y +CONFIG_NET_VENDOR_SEEQ=y +CONFIG_NET_VENDOR_SILAN=y +CONFIG_NET_VENDOR_SIS=y +CONFIG_NET_VENDOR_SMSC=y +CONFIG_NET_VENDOR_SOCIONEXT=y +CONFIG_NET_VENDOR_SOLARFLARE=y +CONFIG_NET_VENDOR_STMICRO=y +CONFIG_NET_VENDOR_SUN=y +CONFIG_NET_VENDOR_SYNOPSYS=y +CONFIG_NET_VENDOR_TEHUTI=y +CONFIG_NET_VENDOR_TI=y +CONFIG_NET_VENDOR_TOSHIBA=y +# CONFIG_NET_VENDOR_VERTEXCOM is not set +CONFIG_NET_VENDOR_VIA=y +# CONFIG_NET_VENDOR_WANGXUN is not set +CONFIG_NET_VENDOR_WIZNET=y +CONFIG_NET_VENDOR_XILINX=y +CONFIG_NET_VENDOR_XIRCOM=y +# CONFIG_NET_VRF is not set +# CONFIG_NET_XGENE is not set +CONFIG_NEW_LEDS=y +# CONFIG_NFC is not set +# CONFIG_NFP is not set +# CONFIG_NFSD is not set +# CONFIG_NFSD_LEGACY_CLIENT_TRACKING is not set +# CONFIG_NFSD_V2 is not set +# CONFIG_NFSD_V2_ACL is not set +# CONFIG_NFSD_V3_ACL is not set +# CONFIG_NFSD_V4 is not set +# CONFIG_NFS_ACL_SUPPORT is not set +CONFIG_NFS_COMMON=y +# CONFIG_NFS_DISABLE_UDP_SUPPORT is not set +# CONFIG_NFS_FS is not set +# CONFIG_NFS_FSCACHE is not set +# CONFIG_NFS_LOCALIO is not set +# CONFIG_NFS_SWAP is not set +# CONFIG_NFS_V2 is not set +CONFIG_NFS_V3=y +# CONFIG_NFS_V3_ACL is not set +# CONFIG_NFS_V4 is not set +# CONFIG_NFS_V4_1 is not set +# CONFIG_NFTL is not set +# CONFIG_NFT_BRIDGE_META is not set +# CONFIG_NFT_BRIDGE_REJECT is not set +# CONFIG_NFT_CONNLIMIT is not set +# CONFIG_NFT_DUP_IPV4 is not set +# CONFIG_NFT_DUP_IPV6 is not set +# CONFIG_NFT_FIB_IPV4 is not set +# CONFIG_NFT_FIB_IPV6 is not set +# CONFIG_NFT_FIB_NETDEV is not set +# CONFIG_NFT_FLOW_OFFLOAD is not set +# CONFIG_NFT_OSF is not set +# CONFIG_NFT_REJECT_NETDEV is not set +# CONFIG_NFT_SOCKET is not set +# CONFIG_NFT_SYNPROXY is not set +# CONFIG_NFT_TPROXY is not set +# CONFIG_NFT_TUNNEL is not set +# CONFIG_NFT_XFRM is not set +# CONFIG_NF_CONNTRACK is not set +# CONFIG_NF_CONNTRACK_AMANDA is not set +# CONFIG_NF_CONNTRACK_BRIDGE is not set +# CONFIG_NF_CONNTRACK_EVENTS is not set +# CONFIG_NF_CONNTRACK_FTP is not set +# CONFIG_NF_CONNTRACK_H323 is not set +# CONFIG_NF_CONNTRACK_IRC is not set +# CONFIG_NF_CONNTRACK_LABELS is not set +# CONFIG_NF_CONNTRACK_MARK is not set +# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set +# CONFIG_NF_CONNTRACK_PPTP is not set +CONFIG_NF_CONNTRACK_PROCFS=y +# CONFIG_NF_CONNTRACK_SANE is not set +# CONFIG_NF_CONNTRACK_SECMARK is not set +# CONFIG_NF_CONNTRACK_SIP is not set +# CONFIG_NF_CONNTRACK_SNMP is not set +# CONFIG_NF_CONNTRACK_TFTP is not set +# CONFIG_NF_CONNTRACK_TIMEOUT is not set +# CONFIG_NF_CONNTRACK_TIMESTAMP is not set +# CONFIG_NF_CONNTRACK_ZONES is not set +# CONFIG_NF_CT_NETLINK is not set +# CONFIG_NF_CT_NETLINK_HELPER is not set +# CONFIG_NF_CT_NETLINK_TIMEOUT is not set +# CONFIG_NF_CT_PROTO_DCCP is not set +# CONFIG_NF_CT_PROTO_GRE is not set +# CONFIG_NF_CT_PROTO_SCTP is not set +# CONFIG_NF_CT_PROTO_UDPLITE is not set +# CONFIG_NF_DEFRAG_IPV4 is not set +# CONFIG_NF_DUP_IPV4 is not set +# CONFIG_NF_DUP_IPV6 is not set +# CONFIG_NF_FLOW_TABLE is not set +# CONFIG_NF_FLOW_TABLE_PROCFS is not set +# CONFIG_NF_LOG_ARP is not set +# CONFIG_NF_LOG_IPV4 is not set +# CONFIG_NF_LOG_SYSLOG is not set +# CONFIG_NF_NAT is not set +# CONFIG_NF_NAT_AMANDA is not set +# CONFIG_NF_NAT_FTP is not set +# CONFIG_NF_NAT_H323 is not set +# CONFIG_NF_NAT_IRC is not set +# CONFIG_NF_NAT_PPTP is not set +# CONFIG_NF_NAT_SIP is not set +# CONFIG_NF_NAT_SNMP_BASIC is not set +# CONFIG_NF_NAT_TFTP is not set +# CONFIG_NF_REJECT_IPV4 is not set +# CONFIG_NF_REJECT_IPV6 is not set +# CONFIG_NF_SOCKET_IPV4 is not set +# CONFIG_NF_SOCKET_IPV6 is not set +# CONFIG_NF_TABLES is not set +CONFIG_NF_TABLES_ARP=y +CONFIG_NF_TABLES_BRIDGE=y +CONFIG_NF_TABLES_INET=y +CONFIG_NF_TABLES_IPV4=y +CONFIG_NF_TABLES_IPV6=y +CONFIG_NF_TABLES_NETDEV=y +# CONFIG_NF_TPROXY_IPV4 is not set +# CONFIG_NF_TPROXY_IPV6 is not set +# CONFIG_NGBE is not set +# CONFIG_NI903X_WDT is not set +# CONFIG_NIC7018_WDT is not set +# CONFIG_NILFS2_FS is not set +# CONFIG_NIU is not set +# CONFIG_NI_XGE_MANAGEMENT_ENET is not set +CONFIG_NLATTR=y +# CONFIG_NLMON is not set +# CONFIG_NLS is not set +# CONFIG_NLS_ASCII is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +# CONFIG_NLS_CODEPAGE_437 is not set +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_CODEPAGE_932 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +CONFIG_NLS_DEFAULT="iso8859-1" +# CONFIG_NLS_ISO8859_1 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +# CONFIG_NLS_MAC_CELTIC is not set +# CONFIG_NLS_MAC_CENTEURO is not set +# CONFIG_NLS_MAC_CROATIAN is not set +# CONFIG_NLS_MAC_CYRILLIC is not set +# CONFIG_NLS_MAC_GAELIC is not set +# CONFIG_NLS_MAC_GREEK is not set +# CONFIG_NLS_MAC_ICELAND is not set +# CONFIG_NLS_MAC_INUIT is not set +# CONFIG_NLS_MAC_ROMAN is not set +# CONFIG_NLS_MAC_ROMANIAN is not set +# CONFIG_NLS_MAC_TURKISH is not set +# CONFIG_NLS_UCS2_UTILS is not set +# CONFIG_NLS_UTF8 is not set +# CONFIG_NOA1305 is not set +# CONFIG_NOP_USB_XCEIV is not set +# CONFIG_NOTIFIER_ERROR_INJECTION is not set +# CONFIG_NOZOMI is not set +# CONFIG_NO_HZ is not set +# CONFIG_NO_HZ_FULL is not set +# CONFIG_NO_HZ_IDLE is not set +# CONFIG_NS83820 is not set +# CONFIG_NTB is not set +# CONFIG_NTFS3_64BIT_CLUSTER is not set +# CONFIG_NTFS3_FS is not set +# CONFIG_NTFS3_FS_POSIX_ACL is not set +# CONFIG_NTFS3_LZX_XPRESS is not set +# CONFIG_NTFS_FS is not set +# CONFIG_NTP_PPS is not set +# CONFIG_NULL_TTY is not set +# CONFIG_NUMA is not set +# CONFIG_NVGRACE_GPU_VFIO_PCI is not set +# CONFIG_NVIDIA_CARMEL_CNP_ERRATUM is not set +# CONFIG_NVIDIA_WMI_EC_BACKLIGHT is not set +# CONFIG_NVMEM is not set +# CONFIG_NVMEM_BCM_OCOTP is not set +# CONFIG_NVMEM_BLOCK is not set +# CONFIG_NVMEM_IMX_OCOTP is not set +# CONFIG_NVMEM_LAYOUT_ASCII_ENV is not set +# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set +# CONFIG_NVMEM_LAYOUT_ONIE_TLV is not set +# CONFIG_NVMEM_LAYOUT_SL28_VPD is not set +# CONFIG_NVMEM_LAYOUT_U_BOOT_ENV is not set +# CONFIG_NVMEM_REBOOT_MODE is not set +# CONFIG_NVMEM_RMEM is not set +# CONFIG_NVMEM_SYSFS is not set +# CONFIG_NVMEM_U_BOOT_ENV is not set +# CONFIG_NVME_AUTH is not set +# CONFIG_NVME_FC is not set +# CONFIG_NVME_HOST_AUTH is not set +# CONFIG_NVME_TARGET is not set +# CONFIG_NVME_TCP is not set +# CONFIG_NVME_VERBOSE_ERRORS is not set +# CONFIG_NVRAM is not set +# CONFIG_NV_TCO is not set +# CONFIG_NXP_C45_TJA11XX_PHY is not set +# CONFIG_NXP_CBTX_PHY is not set +# CONFIG_NXP_TJA11XX_PHY is not set +# CONFIG_N_GSM is not set +# CONFIG_OABI_COMPAT is not set +# CONFIG_OA_TC6 is not set +# CONFIG_OCFS2_FS is not set +# CONFIG_OCTEONTX2_AF is not set +# CONFIG_OCTEONTX2_PF is not set +# CONFIG_OCTEON_EP is not set +# CONFIG_OCTEON_EP_VF is not set +# CONFIG_OF_OVERLAY is not set +CONFIG_OF_PARTITION=y +CONFIG_OF_RESERVED_MEM=y +# CONFIG_OF_UNITTEST is not set +# CONFIG_OID_REGISTRY is not set +# CONFIG_OMAP2_DSS_DEBUG is not set +# CONFIG_OMAP2_DSS_DEBUGFS is not set +# CONFIG_OMAP2_DSS_SDI is not set +# CONFIG_OMAP_OCP2SCP is not set +# CONFIG_OMAP_USB2 is not set +# CONFIG_OMFS_FS is not set +# CONFIG_OPENVSWITCH is not set +# CONFIG_OPEN_DICE is not set +# CONFIG_OPT3001 is not set +# CONFIG_OPT4001 is not set +# CONFIG_ORANGEFS_FS is not set +# CONFIG_ORION_WATCHDOG is not set +# CONFIG_OSF_PARTITION is not set +# CONFIG_OSNOISE_TRACER is not set +CONFIG_OVERLAY_FS=y +# CONFIG_OVERLAY_FS_DEBUG is not set +# CONFIG_OVERLAY_FS_INDEX is not set +# CONFIG_OVERLAY_FS_METACOPY is not set +CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW=y +# CONFIG_OVERLAY_FS_REDIRECT_DIR is not set +CONFIG_OVERLAY_FS_XINO_AUTO=y +# CONFIG_P54_COMMON is not set +# CONFIG_PA12203001 is not set +# CONFIG_PAC1921 is not set +# CONFIG_PAC1934 is not set +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +# CONFIG_PACKING is not set +# CONFIG_PAGE_EXTENSION is not set +# CONFIG_PAGE_OWNER is not set +# CONFIG_PAGE_POISONING is not set +# CONFIG_PAGE_POOL is not set +# CONFIG_PAGE_POOL_STATS is not set +# CONFIG_PAGE_REPORTING is not set +CONFIG_PAGE_SHIFT=12 +# CONFIG_PAGE_SIZE_16KB is not set +# CONFIG_PAGE_SIZE_32KB is not set +CONFIG_PAGE_SIZE_4KB=y +# CONFIG_PAGE_SIZE_64KB is not set +# CONFIG_PAGE_SIZE_8KB is not set +# CONFIG_PAGE_TABLE_CHECK is not set +# CONFIG_PALMAS_GPADC is not set +# CONFIG_PANASONIC_LAPTOP is not set +# CONFIG_PANEL is not set +CONFIG_PANIC_ON_OOPS=y +CONFIG_PANIC_ON_OOPS_VALUE=1 +CONFIG_PANIC_TIMEOUT=1 +# CONFIG_PANTHERLORD_FF is not set +# CONFIG_PARAVIRT is not set +# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set +# CONFIG_PARPORT is not set +# CONFIG_PARPORT_1284 is not set +# CONFIG_PARPORT_GSC is not set +# CONFIG_PARPORT_PC is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_PATA_ACPI is not set +# CONFIG_PATA_ALI is not set +# CONFIG_PATA_AMD is not set +# CONFIG_PATA_ARASAN_CF is not set +# CONFIG_PATA_ARTOP is not set +# CONFIG_PATA_ATIIXP is not set +# CONFIG_PATA_ATP867X is not set +# CONFIG_PATA_CMD640_PCI is not set +# CONFIG_PATA_CMD64X is not set +# CONFIG_PATA_CS5520 is not set +# CONFIG_PATA_CS5530 is not set +# CONFIG_PATA_CS5535 is not set +# CONFIG_PATA_CS5536 is not set +# CONFIG_PATA_CYPRESS is not set +# CONFIG_PATA_EFAR is not set +# CONFIG_PATA_HPT366 is not set +# CONFIG_PATA_HPT37X is not set +# CONFIG_PATA_HPT3X2N is not set +# CONFIG_PATA_HPT3X3 is not set +# CONFIG_PATA_IMX is not set +# CONFIG_PATA_ISAPNP is not set +# CONFIG_PATA_IT8213 is not set +# CONFIG_PATA_IT821X is not set +# CONFIG_PATA_JMICRON is not set +# CONFIG_PATA_LEGACY is not set +# CONFIG_PATA_MARVELL is not set +# CONFIG_PATA_MPIIX is not set +# CONFIG_PATA_NETCELL is not set +# CONFIG_PATA_NINJA32 is not set +# CONFIG_PATA_NS87410 is not set +# CONFIG_PATA_NS87415 is not set +# CONFIG_PATA_OCTEON_CF is not set +# CONFIG_PATA_OF_PLATFORM is not set +# CONFIG_PATA_OLDPIIX is not set +# CONFIG_PATA_OPTI is not set +# CONFIG_PATA_OPTIDMA is not set +# CONFIG_PATA_PARPORT is not set +# CONFIG_PATA_PCMCIA is not set +# CONFIG_PATA_PDC2027X is not set +# CONFIG_PATA_PDC_OLD is not set +# CONFIG_PATA_PLATFORM is not set +# CONFIG_PATA_QDI is not set +# CONFIG_PATA_RADISYS is not set +# CONFIG_PATA_RDC is not set +# CONFIG_PATA_RZ1000 is not set +# CONFIG_PATA_SC1200 is not set +# CONFIG_PATA_SCH is not set +# CONFIG_PATA_SERVERWORKS is not set +# CONFIG_PATA_SIL680 is not set +# CONFIG_PATA_SIS is not set +# CONFIG_PATA_TOSHIBA is not set +# CONFIG_PATA_TRIFLEX is not set +# CONFIG_PATA_VIA is not set +# CONFIG_PATA_WINBOND is not set +# CONFIG_PATA_WINBOND_VLB is not set +# CONFIG_PC104 is not set +# CONFIG_PC300TOO is not set +# CONFIG_PCCARD is not set +# CONFIG_PCH_DMA is not set +# CONFIG_PCH_GBE is not set +# CONFIG_PCH_PHUB is not set +# CONFIG_PCI is not set +# CONFIG_PCI200SYN is not set +# CONFIG_PCIEAER is not set +# CONFIG_PCIEAER_INJECT is not set +# CONFIG_PCIEASPM is not set +# CONFIG_PCIEPORTBUS is not set +# CONFIG_PCIE_AL is not set +# CONFIG_PCIE_ALTERA is not set +# CONFIG_PCIE_ARMADA_8K is not set +CONFIG_PCIE_BUS_DEFAULT=y +# CONFIG_PCIE_BUS_PEER2PEER is not set +# CONFIG_PCIE_BUS_PERFORMANCE is not set +# CONFIG_PCIE_BUS_SAFE is not set +# CONFIG_PCIE_BUS_TUNE_OFF is not set +# CONFIG_PCIE_CADENCE_HOST is not set +# CONFIG_PCIE_CADENCE_PLAT_HOST is not set +# CONFIG_PCIE_DPC is not set +# CONFIG_PCIE_DW_PLAT is not set +# CONFIG_PCIE_DW_PLAT_HOST is not set +# CONFIG_PCIE_ECRC is not set +# CONFIG_PCIE_IPROC is not set +# CONFIG_PCIE_KIRIN is not set +# CONFIG_PCIE_LAYERSCAPE_GEN4 is not set +# CONFIG_PCIE_MEDIATEK_GEN3 is not set +# CONFIG_PCIE_MICROCHIP_HOST is not set +# CONFIG_PCIE_PTM is not set +# CONFIG_PCIE_XILINX is not set +# CONFIG_PCIPCWATCHDOG is not set +# CONFIG_PCI_CNB20LE_QUIRK is not set +# CONFIG_PCI_DEBUG is not set +# CONFIG_PCI_DISABLE_COMMON_QUIRKS is not set +# CONFIG_PCI_DYNAMIC_OF_NODES is not set +# CONFIG_PCI_ENDPOINT is not set +# CONFIG_PCI_ENDPOINT_TEST is not set +# CONFIG_PCI_FTPCI100 is not set +# CONFIG_PCI_HISI is not set +# CONFIG_PCI_HOST_GENERIC is not set +# CONFIG_PCI_HOST_THUNDER_ECAM is not set +# CONFIG_PCI_HOST_THUNDER_PEM is not set +# CONFIG_PCI_IOV is not set +# CONFIG_PCI_J721E_HOST is not set +# CONFIG_PCI_LAYERSCAPE is not set +# CONFIG_PCI_MESON is not set +# CONFIG_PCI_MSI is not set +# CONFIG_PCI_NPEM is not set +# CONFIG_PCI_PASID is not set +# CONFIG_PCI_PF_STUB is not set +# CONFIG_PCI_PRI is not set +CONFIG_PCI_QUIRKS=y +# CONFIG_PCI_REALLOC_ENABLE_AUTO is not set +# CONFIG_PCI_STUB is not set +# CONFIG_PCI_SW_SWITCHTEC is not set +CONFIG_PCI_SYSCALL=y +# CONFIG_PCI_V3_SEMI is not set +# CONFIG_PCI_XGENE is not set +# CONFIG_PCMCIA is not set +# CONFIG_PCMCIA_3C574 is not set +# CONFIG_PCMCIA_3C589 is not set +# CONFIG_PCMCIA_AHA152X is not set +# CONFIG_PCMCIA_AXNET is not set +# CONFIG_PCMCIA_DEBUG is not set +# CONFIG_PCMCIA_FDOMAIN is not set +# CONFIG_PCMCIA_FMVJ18X is not set +# CONFIG_PCMCIA_LOAD_CIS is not set +# CONFIG_PCMCIA_NINJA_SCSI is not set +# CONFIG_PCMCIA_NMCLAN is not set +# CONFIG_PCMCIA_PCNET is not set +# CONFIG_PCMCIA_QLOGIC is not set +# CONFIG_PCMCIA_SMC91C92 is not set +# CONFIG_PCMCIA_SYM53C500 is not set +# CONFIG_PCMCIA_XIRC2PS is not set +# CONFIG_PCMCIA_XIRCOM is not set +# CONFIG_PCNET32 is not set +CONFIG_PCPU_DEV_REFCNT=y +CONFIG_PCP_BATCH_SCALE_MAX=5 +# CONFIG_PCSPKR_PLATFORM is not set +# CONFIG_PCS_MTK_USXGMII is not set +# CONFIG_PCS_XPCS is not set +# CONFIG_PD6729 is not set +# CONFIG_PDC_ADMA is not set +# CONFIG_PDS_CORE is not set +# CONFIG_PECI is not set +# CONFIG_PERCPU_STATS is not set +# CONFIG_PERCPU_TEST is not set +# CONFIG_PERF_EVENTS is not set +# CONFIG_PERF_EVENTS_AMD_POWER is not set +# CONFIG_PERSISTENT_KEYRINGS is not set +# CONFIG_PER_VMA_LOCK_STATS is not set +# CONFIG_PFCP is not set +# CONFIG_PHANTOM is not set +# CONFIG_PHONET is not set +# CONFIG_PHYLIB is not set +# CONFIG_PHYLIB_LEDS is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +# CONFIG_PHY_BRCM_USB is not set +# CONFIG_PHY_CADENCE_DPHY is not set +# CONFIG_PHY_CADENCE_DPHY_RX is not set +# CONFIG_PHY_CADENCE_SALVO is not set +# CONFIG_PHY_CADENCE_SIERRA is not set +# CONFIG_PHY_CADENCE_TORRENT is not set +# CONFIG_PHY_CAN_TRANSCEIVER is not set +# CONFIG_PHY_CPCAP_USB is not set +# CONFIG_PHY_EXYNOS_DP_VIDEO is not set +# CONFIG_PHY_EXYNOS_MIPI_VIDEO is not set +# CONFIG_PHY_FSL_IMX8MQ_USB is not set +# CONFIG_PHY_INGENIC_USB is not set +# CONFIG_PHY_INTEL_KEEMBAY_EMMC is not set +# CONFIG_PHY_LAN966X_SERDES is not set +# CONFIG_PHY_MAPPHONE_MDM6600 is not set +# CONFIG_PHY_MIXEL_MIPI_DPHY is not set +# CONFIG_PHY_MTK_HDMI is not set +# CONFIG_PHY_MTK_MIPI_DSI is not set +# CONFIG_PHY_MTK_XFI_TPHY is not set +# CONFIG_PHY_MVEBU_CP110_UTMI is not set +# CONFIG_PHY_OCELOT_SERDES is not set +# CONFIG_PHY_PISTACHIO_USB is not set +# CONFIG_PHY_PXA_28NM_HSIC is not set +# CONFIG_PHY_PXA_28NM_USB2 is not set +# CONFIG_PHY_QCOM_USB_HS is not set +# CONFIG_PHY_QCOM_USB_HSIC is not set +# CONFIG_PHY_SAMSUNG_USB2 is not set +# CONFIG_PHY_TUSB1210 is not set +# CONFIG_PHY_XGENE is not set +# CONFIG_PID_IN_CONTEXTIDR is not set +# CONFIG_PID_NS is not set +CONFIG_PINCONF=y +# CONFIG_PINCTRL is not set +# CONFIG_PINCTRL_AMD is not set +# CONFIG_PINCTRL_AW9523 is not set +# CONFIG_PINCTRL_AXP209 is not set +# CONFIG_PINCTRL_CEDARFORK is not set +# CONFIG_PINCTRL_CY8C95X0 is not set +# CONFIG_PINCTRL_EXYNOS is not set +# CONFIG_PINCTRL_ICELAKE is not set +# CONFIG_PINCTRL_IMX_SCMI is not set +# CONFIG_PINCTRL_INGENIC is not set +# CONFIG_PINCTRL_LPASS_LPI is not set +# CONFIG_PINCTRL_MCP23S08 is not set +# CONFIG_PINCTRL_MDM9607 is not set +# CONFIG_PINCTRL_MICROCHIP_SGPIO is not set +# CONFIG_PINCTRL_MSM8953 is not set +# CONFIG_PINCTRL_MSM8X74 is not set +# CONFIG_PINCTRL_MT6779 is not set +# CONFIG_PINCTRL_MT8167 is not set +# CONFIG_PINCTRL_MT8192 is not set +# CONFIG_PINCTRL_MT8195 is not set +# CONFIG_PINCTRL_MT8365 is not set +# CONFIG_PINCTRL_MTK_V2 is not set +# CONFIG_PINCTRL_OCELOT is not set +# CONFIG_PINCTRL_PISTACHIO is not set +# CONFIG_PINCTRL_SC7280 is not set +# CONFIG_PINCTRL_SC8180X is not set +# CONFIG_PINCTRL_SDX55 is not set +CONFIG_PINCTRL_SINGLE=y +# CONFIG_PINCTRL_SM6115 is not set +# CONFIG_PINCTRL_SM6125 is not set +# CONFIG_PINCTRL_SM8350 is not set +# CONFIG_PINCTRL_STMFX is not set +# CONFIG_PINCTRL_SX150X is not set +# CONFIG_PING is not set +CONFIG_PINMUX=y +# CONFIG_PKCS7_MESSAGE_PARSER is not set +# CONFIG_PL310_ERRATA_588369 is not set +# CONFIG_PL310_ERRATA_727915 is not set +# CONFIG_PL310_ERRATA_753970 is not set +# CONFIG_PL310_ERRATA_769419 is not set +# CONFIG_PL320_MBOX is not set +# CONFIG_PL330_DMA is not set +# CONFIG_PLATFORM_MHU is not set +# CONFIG_PLAT_SPEAR is not set +# CONFIG_PLIP is not set +# CONFIG_PLX_DMA is not set +# CONFIG_PM is not set +# CONFIG_PMBUS is not set +# CONFIG_PMIC_ADP5520 is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_PMS7003 is not set +# CONFIG_PM_AUTOSLEEP is not set +# CONFIG_PM_DEBUG is not set +# CONFIG_PM_DEVFREQ is not set +# CONFIG_PM_USERSPACE_AUTOSLEEP is not set +# CONFIG_PM_WAKELOCKS is not set +# CONFIG_POSIX_MQUEUE is not set +CONFIG_POSIX_TIMERS=y +# CONFIG_POWERCAP is not set +# CONFIG_POWER_RESET is not set +# CONFIG_POWER_RESET_BRCMKONA is not set +# CONFIG_POWER_RESET_BRCMSTB is not set +# CONFIG_POWER_RESET_GPIO is not set +# CONFIG_POWER_RESET_GPIO_RESTART is not set +# CONFIG_POWER_RESET_LINKSTATION is not set +# CONFIG_POWER_RESET_LTC2952 is not set +# CONFIG_POWER_RESET_PIIX4_POWEROFF is not set +# CONFIG_POWER_RESET_QNAP is not set +# CONFIG_POWER_RESET_REGULATOR is not set +# CONFIG_POWER_RESET_RESTART is not set +# CONFIG_POWER_RESET_SYSCON is not set +# CONFIG_POWER_RESET_SYSCON_POWEROFF is not set +# CONFIG_POWER_RESET_VERSATILE is not set +# CONFIG_POWER_RESET_XGENE is not set +# CONFIG_POWER_SEQUENCING is not set +# CONFIG_POWER_SUPPLY is not set +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_POWER_SUPPLY_HWMON is not set +# CONFIG_PPC4xx_GPIO is not set +# CONFIG_PPC_16K_PAGES is not set +# CONFIG_PPC_256K_PAGES is not set +CONFIG_PPC_4K_PAGES=y +# CONFIG_PPC_64K_PAGES is not set +# CONFIG_PPC_DISABLE_WERROR is not set +# CONFIG_PPC_EMULATED_STATS is not set +# CONFIG_PPC_EPAPR_HV_BYTECHAN is not set +# CONFIG_PPC_QUEUED_SPINLOCKS is not set +# CONFIG_PPP is not set +# CONFIG_PPPOATM is not set +# CONFIG_PPPOE is not set +# CONFIG_PPPOE_HASH_BITS_1 is not set +# CONFIG_PPPOE_HASH_BITS_2 is not set +CONFIG_PPPOE_HASH_BITS_4=y +# CONFIG_PPPOE_HASH_BITS_8 is not set +# CONFIG_PPPOL2TP is not set +# CONFIG_PPP_ASYNC is not set +# CONFIG_PPP_BSDCOMP is not set +# CONFIG_PPP_DEFLATE is not set +CONFIG_PPP_FILTER=y +# CONFIG_PPP_MPPE is not set +CONFIG_PPP_MULTILINK=y +# CONFIG_PPP_SYNC_TTY is not set +# CONFIG_PPS is not set +# CONFIG_PPS_CLIENT_GPIO is not set +# CONFIG_PPS_CLIENT_KTIMER is not set +# CONFIG_PPS_CLIENT_LDISC is not set +# CONFIG_PPS_CLIENT_PARPORT is not set +# CONFIG_PPS_DEBUG is not set +# CONFIG_PPTP is not set +# CONFIG_PREEMPT is not set +# CONFIG_PREEMPTIRQ_DELAY_TEST is not set +# CONFIG_PREEMPT_DYNAMIC is not set +CONFIG_PREEMPT_NONE=y +CONFIG_PREEMPT_NONE_BUILD=y +# CONFIG_PREEMPT_RT is not set +# CONFIG_PREEMPT_TRACER is not set +# CONFIG_PREEMPT_VOLUNTARY is not set +# CONFIG_PRESTERA is not set +CONFIG_PREVENT_FIRMWARE_BUILD=y +# CONFIG_PRIME_NUMBERS is not set +CONFIG_PRINTK=y +# CONFIG_PRINTK_CALLER is not set +# CONFIG_PRINTK_INDEX is not set +# CONFIG_PRINTK_TIME is not set +CONFIG_PRINT_STACK_DEPTH=64 +# CONFIG_PROC_CHILDREN is not set +CONFIG_PROC_FS=y +# CONFIG_PROC_KCORE is not set +CONFIG_PROC_MEM_ALWAYS_FORCE=y +# CONFIG_PROC_MEM_FORCE_PTRACE is not set +# CONFIG_PROC_MEM_NO_FORCE is not set +# CONFIG_PROC_PAGE_MONITOR is not set +# CONFIG_PROC_STRIPPED is not set +CONFIG_PROC_SYSCTL=y +# CONFIG_PROC_VMCORE_DEVICE_DUMP is not set +# CONFIG_PROFILE_ALL_BRANCHES is not set +# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set +# CONFIG_PROFILING is not set +# CONFIG_PROVE_LOCKING is not set +# CONFIG_PROVE_RAW_LOCK_NESTING is not set +# CONFIG_PROVE_RCU is not set +# CONFIG_PROVE_RCU_LIST is not set +# CONFIG_PSAMPLE is not set +# CONFIG_PSB6970_PHY is not set +# CONFIG_PSE_CONTROLLER is not set +# CONFIG_PSE_REGULATOR is not set +# CONFIG_PSE_PD692X0 is not set +# CONFIG_PSE_SI3474 is not set +# CONFIG_PSE_TPS23881 is not set +# CONFIG_PSI is not set +# CONFIG_PSI_DEFAULT_DISABLED is not set +# CONFIG_PSTORE is not set +# CONFIG_PSTORE_BLK is not set +# CONFIG_PSTORE_COMPRESS is not set +# CONFIG_PSTORE_CONSOLE is not set +CONFIG_PSTORE_DEFAULT_KMSG_BYTES=10240 +# CONFIG_PSTORE_FTRACE is not set +# CONFIG_PSTORE_PMSG is not set +# CONFIG_PSTORE_RAM is not set +# CONFIG_PTDUMP_DEBUGFS is not set +# CONFIG_PTP_1588_CLOCK is not set +# CONFIG_PTP_1588_CLOCK_FC3W is not set +# CONFIG_PTP_1588_CLOCK_IDT82P33 is not set +# CONFIG_PTP_1588_CLOCK_IDTCM is not set +# CONFIG_PTP_1588_CLOCK_IXP46X is not set +# CONFIG_PTP_1588_CLOCK_KVM is not set +# CONFIG_PTP_1588_CLOCK_MOCK is not set +# CONFIG_PTP_1588_CLOCK_OCP is not set +# CONFIG_PTP_1588_CLOCK_PCH is not set +# CONFIG_PTP_1588_CLOCK_VMW is not set +# CONFIG_PVPANIC is not set +# CONFIG_PWM is not set +# CONFIG_PWM_ATMEL_TCB is not set +# CONFIG_PWM_CLK is not set +# CONFIG_PWM_DEBUG is not set +# CONFIG_PWM_DWC is not set +# CONFIG_PWM_FSL_FTM is not set +# CONFIG_PWM_GPIO is not set +# CONFIG_PWM_IMG is not set +# CONFIG_PWM_JZ4740 is not set +# CONFIG_PWM_MEDIATEK is not set +# CONFIG_PWM_PCA9685 is not set +# CONFIG_PWM_RASPBERRYPI_POE is not set +# CONFIG_PWM_XILINX is not set +CONFIG_PWRSEQ_EMMC=y +# CONFIG_PWRSEQ_SD8787 is not set +CONFIG_PWRSEQ_SIMPLE=y +# CONFIG_QCA7000 is not set +# CONFIG_QCA7000_SPI is not set +# CONFIG_QCA7000_UART is not set +# CONFIG_QCA807X_PHY is not set +# CONFIG_QCA808X_PHY is not set +# CONFIG_QCA83XX_PHY is not set +# CONFIG_QCOM_A7PLL is not set +# CONFIG_QCOM_BAM_DMUX is not set +# CONFIG_QCOM_EMAC is not set +# CONFIG_QCOM_FALKOR_ERRATUM_1003 is not set +# CONFIG_QCOM_FALKOR_ERRATUM_1009 is not set +# CONFIG_QCOM_FALKOR_ERRATUM_E1041 is not set +# CONFIG_QCOM_GPI_DMA is not set +# CONFIG_QCOM_HIDMA is not set +# CONFIG_QCOM_HIDMA_MGMT is not set +# CONFIG_QCOM_LMH is not set +# CONFIG_QCOM_PBS is not set +# CONFIG_QCOM_PD_MAPPER is not set +# CONFIG_QCOM_PMIC_PDCHARGER_ULOG is not set +# CONFIG_QCOM_QDF2400_ERRATUM_0065 is not set +# CONFIG_QCOM_SPMI_ADC5 is not set +# CONFIG_QCOM_SPMI_ADC_TM5 is not set +# CONFIG_QCOM_SPMI_IADC is not set +# CONFIG_QCOM_SPMI_TEMP_ALARM is not set +# CONFIG_QCOM_SPMI_VADC is not set +# CONFIG_QCOM_SSC_BLOCK_BUS is not set +# CONFIG_QED is not set +# CONFIG_QFMT_V1 is not set +# CONFIG_QLA3XXX is not set +# CONFIG_QLCNIC is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_QNX6FS_FS is not set +# CONFIG_QORIQ_CPUFREQ is not set +# CONFIG_QORIQ_THERMAL is not set +# CONFIG_QRTR is not set +# CONFIG_QRTR_MHI is not set +# CONFIG_QRTR_TUN is not set +# CONFIG_QSEMI_PHY is not set +# CONFIG_QUICC_ENGINE is not set +# CONFIG_QUOTA is not set +# CONFIG_QUOTACTL is not set +# CONFIG_QUOTA_DEBUG is not set +# CONFIG_QUOTA_NETLINK_INTERFACE is not set +# CONFIG_R6040 is not set +# CONFIG_R8169 is not set +# CONFIG_R8169_LEDS is not set +# CONFIG_R8712U is not set +# CONFIG_RADIO_ADAPTERS is not set +# CONFIG_RADIO_AZTECH is not set +# CONFIG_RADIO_CADET is not set +# CONFIG_RADIO_GEMTEK is not set +# CONFIG_RADIO_MAXIRADIO is not set +# CONFIG_RADIO_RTRACK is not set +# CONFIG_RADIO_RTRACK2 is not set +# CONFIG_RADIO_SF16FMI is not set +# CONFIG_RADIO_SF16FMR2 is not set +# CONFIG_RADIO_TERRATEC is not set +# CONFIG_RADIO_TRUST is not set +# CONFIG_RADIO_TYPHOON is not set +# CONFIG_RADIO_ZOLTRIX is not set +# CONFIG_RAID6_PQ_BENCHMARK is not set +# CONFIG_RAID_ATTRS is not set +# CONFIG_RALINK is not set +# CONFIG_RANDOM32_SELFTEST is not set +# CONFIG_RANDOMIZE_BASE is not set +CONFIG_RANDOMIZE_KSTACK_OFFSET=y +# CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT is not set +# CONFIG_RANDOM_KMALLOC_CACHES is not set +# CONFIG_RANDSTRUCT_NONE is not set +# CONFIG_RAPIDIO is not set +# CONFIG_RAS is not set +# CONFIG_RBTREE_TEST is not set +# CONFIG_RCU_BOOST is not set +# CONFIG_RCU_CPU_STALL_CPUTIME is not set +CONFIG_RCU_CPU_STALL_TIMEOUT=60 +# CONFIG_RCU_EQS_DEBUG is not set +# CONFIG_RCU_EXPERT is not set +CONFIG_RCU_EXP_CPU_STALL_TIMEOUT=0 +CONFIG_RCU_NEED_SEGCBLIST=y +# CONFIG_RCU_REF_SCALE_TEST is not set +# CONFIG_RCU_SCALE_TEST is not set +CONFIG_RCU_STALL_COMMON=y +# CONFIG_RCU_STRICT_GRACE_PERIOD is not set +# CONFIG_RCU_TORTURE_TEST is not set +# CONFIG_RCU_TRACE is not set +# CONFIG_RC_ATI_REMOTE is not set +# CONFIG_RC_CORE is not set +# CONFIG_RC_DECODERS is not set +# CONFIG_RC_LOOPBACK is not set +# CONFIG_RC_MAP is not set +# CONFIG_RC_XBOX_DVD is not set +# CONFIG_RDS is not set +# CONFIG_RD_BZIP2 is not set +# CONFIG_RD_GZIP is not set +# CONFIG_RD_LZ4 is not set +# CONFIG_RD_LZMA is not set +# CONFIG_RD_LZO is not set +# CONFIG_RD_XZ is not set +# CONFIG_RD_ZSTD is not set +# CONFIG_READABLE_ASM is not set +# CONFIG_READ_ONLY_THP_FOR_FS is not set +# CONFIG_REALTEK_PHY is not set +# CONFIG_REDWOOD is not set +# CONFIG_REED_SOLOMON is not set +# CONFIG_REED_SOLOMON_DEC8 is not set +# CONFIG_REED_SOLOMON_ENC8 is not set +# CONFIG_REED_SOLOMON_TEST is not set +# CONFIG_REGMAP is not set +# CONFIG_REGMAP_I2C is not set +# CONFIG_REGMAP_MMIO is not set +# CONFIG_REGMAP_SPI is not set +# CONFIG_REGULATOR is not set +# CONFIG_REGULATOR_88PG86X is not set +# CONFIG_REGULATOR_ACT8865 is not set +# CONFIG_REGULATOR_AD5398 is not set +# CONFIG_REGULATOR_ANATOP is not set +# CONFIG_REGULATOR_AW37503 is not set +# CONFIG_REGULATOR_DA9121 is not set +# CONFIG_REGULATOR_DA9210 is not set +# CONFIG_REGULATOR_DA9211 is not set +# CONFIG_REGULATOR_DEBUG is not set +# CONFIG_REGULATOR_FAN53555 is not set +# CONFIG_REGULATOR_FAN53880 is not set +# CONFIG_REGULATOR_FIXED_VOLTAGE is not set +# CONFIG_REGULATOR_GPIO is not set +# CONFIG_REGULATOR_ISL6271A is not set +# CONFIG_REGULATOR_ISL9305 is not set +# CONFIG_REGULATOR_LP3971 is not set +# CONFIG_REGULATOR_LP3972 is not set +# CONFIG_REGULATOR_LP872X is not set +# CONFIG_REGULATOR_LP8755 is not set +# CONFIG_REGULATOR_LTC3589 is not set +# CONFIG_REGULATOR_LTC3676 is not set +# CONFIG_REGULATOR_MAX1586 is not set +# CONFIG_REGULATOR_MAX20086 is not set +# CONFIG_REGULATOR_MAX20411 is not set +# CONFIG_REGULATOR_MAX77503 is not set +# CONFIG_REGULATOR_MAX77620 is not set +# CONFIG_REGULATOR_MAX77826 is not set +# CONFIG_REGULATOR_MAX77857 is not set +# CONFIG_REGULATOR_MAX8649 is not set +# CONFIG_REGULATOR_MAX8660 is not set +# CONFIG_REGULATOR_MAX8893 is not set +# CONFIG_REGULATOR_MAX8952 is not set +# CONFIG_REGULATOR_MAX8973 is not set +# CONFIG_REGULATOR_MCP16502 is not set +# CONFIG_REGULATOR_MP5416 is not set +# CONFIG_REGULATOR_MP8859 is not set +# CONFIG_REGULATOR_MP886X is not set +# CONFIG_REGULATOR_MPQ7920 is not set +# CONFIG_REGULATOR_MT6311 is not set +# CONFIG_REGULATOR_MT6315 is not set +# CONFIG_REGULATOR_MT6359 is not set +# CONFIG_REGULATOR_NETLINK_EVENTS is not set +# CONFIG_REGULATOR_PCA9450 is not set +# CONFIG_REGULATOR_PF8X00 is not set +# CONFIG_REGULATOR_PFUZE100 is not set +# CONFIG_REGULATOR_PV88060 is not set +# CONFIG_REGULATOR_PV88080 is not set +# CONFIG_REGULATOR_PV88090 is not set +# CONFIG_REGULATOR_PWM is not set +# CONFIG_REGULATOR_QCOM_LABIBB is not set +# CONFIG_REGULATOR_QCOM_REFGEN is not set +# CONFIG_REGULATOR_QCOM_SPMI is not set +# CONFIG_REGULATOR_QCOM_USB_VBUS is not set +# CONFIG_REGULATOR_RAA215300 is not set +# CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY is not set +# CONFIG_REGULATOR_RT4801 is not set +# CONFIG_REGULATOR_RT4803 is not set +# CONFIG_REGULATOR_RT5190A is not set +# CONFIG_REGULATOR_RT5739 is not set +# CONFIG_REGULATOR_RT5759 is not set +# CONFIG_REGULATOR_RT6160 is not set +# CONFIG_REGULATOR_RT6190 is not set +# CONFIG_REGULATOR_RT6245 is not set +# CONFIG_REGULATOR_RTMV20 is not set +# CONFIG_REGULATOR_RTQ2134 is not set +# CONFIG_REGULATOR_RTQ2208 is not set +# CONFIG_REGULATOR_RTQ6752 is not set +# CONFIG_REGULATOR_SLG51000 is not set +# CONFIG_REGULATOR_SY8106A is not set +# CONFIG_REGULATOR_SY8824X is not set +# CONFIG_REGULATOR_SY8827N is not set +# CONFIG_REGULATOR_TI_ABB is not set +# CONFIG_REGULATOR_TPS51632 is not set +# CONFIG_REGULATOR_TPS62360 is not set +# CONFIG_REGULATOR_TPS6286X is not set +# CONFIG_REGULATOR_TPS6287X is not set +# CONFIG_REGULATOR_TPS65023 is not set +# CONFIG_REGULATOR_TPS6507X is not set +# CONFIG_REGULATOR_TPS65132 is not set +# CONFIG_REGULATOR_TPS6524X is not set +# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set +# CONFIG_REGULATOR_VCTRL is not set +# CONFIG_REGULATOR_VEXPRESS is not set +# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set +# CONFIG_REISERFS_CHECK is not set +# CONFIG_REISERFS_FS is not set +# CONFIG_REISERFS_FS_POSIX_ACL is not set +# CONFIG_REISERFS_FS_SECURITY is not set +CONFIG_REISERFS_FS_XATTR=y +# CONFIG_REISERFS_PROC_INFO is not set +# CONFIG_RELAY is not set +# CONFIG_RELOCATABLE is not set +CONFIG_RELR=y +# CONFIG_REMOTEPROC is not set +# CONFIG_RENESAS_PHY is not set +# CONFIG_RESET_ATH79 is not set +# CONFIG_RESET_BERLIN is not set +# CONFIG_RESET_BRCMSTB is not set +# CONFIG_RESET_BRCMSTB_RESCAL is not set +# CONFIG_RESET_CONTROLLER is not set +# CONFIG_RESET_GPIO is not set +# CONFIG_RESET_IMX7 is not set +# CONFIG_RESET_INTEL_GW is not set +# CONFIG_RESET_LANTIQ is not set +# CONFIG_RESET_LPC18XX is not set +# CONFIG_RESET_MESON is not set +# CONFIG_RESET_PISTACHIO is not set +# CONFIG_RESET_SIMPLE is not set +# CONFIG_RESET_SOCFPGA is not set +# CONFIG_RESET_SUNXI is not set +# CONFIG_RESET_TEGRA_BPMP is not set +# CONFIG_RESET_TI_SYSCON is not set +# CONFIG_RESET_TI_TPS380X is not set +# CONFIG_RESET_ZYNQ is not set +# CONFIG_RFD77402 is not set +# CONFIG_RFD_FTL is not set +CONFIG_RFKILL=y +# CONFIG_RFKILL_FULL is not set +# CONFIG_RFKILL_GPIO is not set +# CONFIG_RFKILL_INPUT is not set +# CONFIG_RFKILL_LEDS is not set +# CONFIG_RICHTEK_RTQ6056 is not set +# CONFIG_RING_BUFFER_BENCHMARK is not set +# CONFIG_RING_BUFFER_STARTUP_TEST is not set +# CONFIG_RING_BUFFER_VALIDATE_TIME_DELTAS is not set +# CONFIG_RISCV_PMU is not set +# CONFIG_RISCV_PMU_LEGACY is not set +# CONFIG_RISCV_PMU_SBI is not set +# CONFIG_RMI4_CORE is not set +# CONFIG_RMNET is not set +# CONFIG_ROCKCHIP_ERRATUM_3588001 is not set +# CONFIG_ROCKCHIP_PHY is not set +# CONFIG_ROCKER is not set +# CONFIG_ROHM_BM1390 is not set +# CONFIG_ROHM_BU27008 is not set +# CONFIG_ROHM_BU27034 is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_ROSE is not set +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_KRB5_ENCTYPES_AES_SHA1 is not set +# CONFIG_RPCSEC_GSS_KRB5_ENCTYPES_AES_SHA2 is not set +# CONFIG_RPCSEC_GSS_KRB5_ENCTYPES_CAMELLIA is not set +# CONFIG_RPMB is not set +# CONFIG_RPMSG_QCOM_GLINK_RPM is not set +# CONFIG_RPMSG_VIRTIO is not set +# CONFIG_RPMSG_WWAN_CTRL is not set +# CONFIG_RPR0521 is not set +# CONFIG_RSEQ is not set +# CONFIG_RT2X00 is not set +# CONFIG_RTASE is not set +# CONFIG_RTC_CLASS is not set +# CONFIG_RTC_DEBUG is not set +# CONFIG_RTC_DRV_ABB5ZES3 is not set +# CONFIG_RTC_DRV_ABEOZ9 is not set +# CONFIG_RTC_DRV_ABX80X is not set +# CONFIG_RTC_DRV_ARMADA38X is not set +# CONFIG_RTC_DRV_AU1XXX is not set +# CONFIG_RTC_DRV_BQ32K is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_CADENCE is not set +CONFIG_RTC_DRV_CMOS=y +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1302 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1307_CENTURY is not set +# CONFIG_RTC_DRV_DS1343 is not set +# CONFIG_RTC_DRV_DS1347 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_DS1685_FAMILY is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_DS2404 is not set +# CONFIG_RTC_DRV_DS3232 is not set +# CONFIG_RTC_DRV_EFI is not set +# CONFIG_RTC_DRV_EM3027 is not set +# CONFIG_RTC_DRV_EP93XX is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_FTRTC010 is not set +# CONFIG_RTC_DRV_GENERIC is not set +# CONFIG_RTC_DRV_GOLDFISH is not set +# CONFIG_RTC_DRV_HID_SENSOR_TIME is not set +# CONFIG_RTC_DRV_HYM8563 is not set +# CONFIG_RTC_DRV_ISL12022 is not set +# CONFIG_RTC_DRV_ISL12026 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_JZ4740 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_M41T93 is not set +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_MAX31335 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_MAX6916 is not set +# CONFIG_RTC_DRV_MAX77686 is not set +# CONFIG_RTC_DRV_MCP795 is not set +# CONFIG_RTC_DRV_MOXART is not set +# CONFIG_RTC_DRV_MPC5121 is not set +# CONFIG_RTC_DRV_MSM6242 is not set +# CONFIG_RTC_DRV_MT2712 is not set +# CONFIG_RTC_DRV_NCT3018Y is not set +# CONFIG_RTC_DRV_OMAP is not set +# CONFIG_RTC_DRV_PCF2123 is not set +# CONFIG_RTC_DRV_PCF2127 is not set +# CONFIG_RTC_DRV_PCF85063 is not set +# CONFIG_RTC_DRV_PCF8523 is not set +# CONFIG_RTC_DRV_PCF85363 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_PL030 is not set +# CONFIG_RTC_DRV_PL031 is not set +# CONFIG_RTC_DRV_PS3 is not set +# CONFIG_RTC_DRV_R7301 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RP5C01 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_RV3028 is not set +# CONFIG_RTC_DRV_RV3029C2 is not set +# CONFIG_RTC_DRV_RV3032 is not set +# CONFIG_RTC_DRV_RV8803 is not set +# CONFIG_RTC_DRV_RX4581 is not set +# CONFIG_RTC_DRV_RX6110 is not set +# CONFIG_RTC_DRV_RX8010 is not set +# CONFIG_RTC_DRV_RX8025 is not set +# CONFIG_RTC_DRV_RX8111 is not set +# CONFIG_RTC_DRV_RX8581 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_SD2405AL is not set +# CONFIG_RTC_DRV_SD3078 is not set +# CONFIG_RTC_DRV_SNVS is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_SUN6I is not set +# CONFIG_RTC_DRV_TEGRA is not set +# CONFIG_RTC_DRV_TEST is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_XGENE is not set +# CONFIG_RTC_DRV_ZYNQMP is not set +CONFIG_RTC_HCTOSYS=y +CONFIG_RTC_HCTOSYS_DEVICE="rtc0" +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_LIB=y +# CONFIG_RTC_NVMEM is not set +CONFIG_RTC_SYSTOHC=y +CONFIG_RTC_SYSTOHC_DEVICE="rtc0" +# CONFIG_RTL8180 is not set +# CONFIG_RTL8187 is not set +# CONFIG_RTL8192E is not set +# CONFIG_RTL8261N_PHY is not set +# CONFIG_RTL8306_PHY is not set +# CONFIG_RTL8366RB_PHY is not set +# CONFIG_RTL8366S_PHY is not set +# CONFIG_RTL8366_SMI is not set +# CONFIG_RTL8366_SMI_DEBUG_FS is not set +# CONFIG_RTL8367B_PHY is not set +# CONFIG_RTL8367_PHY is not set +# CONFIG_RTLLIB is not set +# CONFIG_RTL_CARDS is not set +# CONFIG_RTS5208 is not set +CONFIG_RT_MUTEXES=y +CONFIG_RUNTIME_TESTING_MENU=y +# CONFIG_RUST is not set +# CONFIG_RV is not set +CONFIG_RXKAD=y +# CONFIG_RXPERF is not set +# CONFIG_S2IO is not set +# CONFIG_SAMPLES is not set +# CONFIG_SAMSUNG_LAPTOP is not set +# CONFIG_SATA_ACARD_AHCI is not set +# CONFIG_SATA_AHCI is not set +# CONFIG_SATA_AHCI_PLATFORM is not set +# CONFIG_SATA_DWC is not set +# CONFIG_SATA_DWC_OLD_DMA is not set +# CONFIG_SATA_FSL is not set +# CONFIG_SATA_HIGHBANK is not set +# CONFIG_SATA_HOST is not set +# CONFIG_SATA_INIC162X is not set +CONFIG_SATA_MOBILE_LPM_POLICY=0 +# CONFIG_SATA_MV is not set +# CONFIG_SATA_NV is not set +# CONFIG_SATA_PMP is not set +# CONFIG_SATA_PROMISE is not set +# CONFIG_SATA_QSTOR is not set +# CONFIG_SATA_RCAR is not set +# CONFIG_SATA_SIL is not set +# CONFIG_SATA_SIL24 is not set +# CONFIG_SATA_SIS is not set +# CONFIG_SATA_SVW is not set +# CONFIG_SATA_SX4 is not set +# CONFIG_SATA_ULI is not set +# CONFIG_SATA_VIA is not set +# CONFIG_SATA_VITESSE is not set +# CONFIG_SBC_FITPC2_WATCHDOG is not set +CONFIG_SBITMAP=y +# CONFIG_SC92031 is not set +# CONFIG_SCA3000 is not set +# CONFIG_SCA3300 is not set +# CONFIG_SCACHE_DEBUGFS is not set +# CONFIG_SCC is not set +# CONFIG_SCD30_CORE is not set +# CONFIG_SCD4X is not set +# CONFIG_SCF_TORTURE_TEST is not set +# CONFIG_SCHEDSTATS is not set +# CONFIG_SCHED_AUTOGROUP is not set +# CONFIG_SCHED_CLASS_EXT is not set +# CONFIG_SCHED_CLUSTER is not set +# CONFIG_SCHED_DEBUG is not set +CONFIG_SCHED_HRTICK=y +# CONFIG_SCHED_MC is not set +CONFIG_SCHED_OMIT_FRAME_POINTER=y +# CONFIG_SCHED_SMT is not set +CONFIG_SCHED_STACK_END_CHECK=y +# CONFIG_SCHED_TRACER is not set +# CONFIG_SCSI is not set +# CONFIG_SCSI_3W_9XXX is not set +# CONFIG_SCSI_3W_SAS is not set +# CONFIG_SCSI_AACRAID is not set +# CONFIG_SCSI_ACARD is not set +# CONFIG_SCSI_ADVANSYS is not set +# CONFIG_SCSI_AHA152X is not set +# CONFIG_SCSI_AHA1542 is not set +# CONFIG_SCSI_AIC79XX is not set +# CONFIG_SCSI_AIC7XXX is not set +# CONFIG_SCSI_AIC94XX is not set +# CONFIG_SCSI_AM53C974 is not set +# CONFIG_SCSI_ARCMSR is not set +# CONFIG_SCSI_BFA_FC is not set +# CONFIG_SCSI_BNX2X_FCOE is not set +# CONFIG_SCSI_BNX2_ISCSI is not set +# CONFIG_SCSI_BUSLOGIC is not set +# CONFIG_SCSI_CHELSIO_FCOE is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_CXGB3_ISCSI is not set +# CONFIG_SCSI_CXGB4_ISCSI is not set +# CONFIG_SCSI_DC395x is not set +# CONFIG_SCSI_DEBUG is not set +# CONFIG_SCSI_DH is not set +CONFIG_SCSI_DMA=y +# CONFIG_SCSI_DMX3191D is not set +# CONFIG_SCSI_ESAS2R is not set +# CONFIG_SCSI_FC_ATTRS is not set +# CONFIG_SCSI_FDOMAIN_PCI is not set +# CONFIG_SCSI_GENERIC_NCR5380 is not set +# CONFIG_SCSI_HISI_SAS is not set +# CONFIG_SCSI_HPSA is not set +# CONFIG_SCSI_HPTIOP is not set +# CONFIG_SCSI_INIA100 is not set +# CONFIG_SCSI_INITIO is not set +# CONFIG_SCSI_IPR is not set +# CONFIG_SCSI_IPS is not set +# CONFIG_SCSI_ISCI is not set +# CONFIG_SCSI_ISCSI_ATTRS is not set +# CONFIG_SCSI_LOGGING is not set +CONFIG_SCSI_LOWLEVEL=y +# CONFIG_SCSI_LOWLEVEL_PCMCIA is not set +# CONFIG_SCSI_LPFC is not set +CONFIG_SCSI_MOD=y +# CONFIG_SCSI_MPI3MR is not set +# CONFIG_SCSI_MPT2SAS is not set +# CONFIG_SCSI_MPT3SAS is not set +# CONFIG_SCSI_MVSAS is not set +# CONFIG_SCSI_MVSAS_DEBUG is not set +# CONFIG_SCSI_MVUMI is not set +# CONFIG_SCSI_MYRB is not set +# CONFIG_SCSI_MYRS is not set +# CONFIG_SCSI_NETLINK is not set +# CONFIG_SCSI_NSP32 is not set +# CONFIG_SCSI_PM8001 is not set +# CONFIG_SCSI_PMCRAID is not set +CONFIG_SCSI_PROC_FS=y +# CONFIG_SCSI_QLA_FC is not set +# CONFIG_SCSI_QLA_ISCSI is not set +# CONFIG_SCSI_QLOGIC_1280 is not set +# CONFIG_SCSI_QLOGIC_FAS is not set +# CONFIG_SCSI_SAS_ATTRS is not set +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SCAN_ASYNC is not set +# CONFIG_SCSI_SMARTPQI is not set +# CONFIG_SCSI_SNIC is not set +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_STEX is not set +# CONFIG_SCSI_SYM53C8XX_2 is not set +# CONFIG_SCSI_UFSHCD is not set +# CONFIG_SCSI_UFSHCD_PCI is not set +# CONFIG_SCSI_UFSHCD_PLATFORM is not set +# CONFIG_SCSI_UFS_BSG is not set +# CONFIG_SCSI_UFS_CDNS_PLATFORM is not set +# CONFIG_SCSI_UFS_CRYPTO is not set +# CONFIG_SCSI_UFS_DWC_TC_PLATFORM is not set +# CONFIG_SCSI_UFS_EXYNOS is not set +# CONFIG_SCSI_UFS_FAULT_INJECTION is not set +# CONFIG_SCSI_UFS_HISI is not set +# CONFIG_SCSI_UFS_HWMON is not set +# CONFIG_SCSI_UFS_MEDIATEK is not set +# CONFIG_SCSI_UFS_QCOM is not set +# CONFIG_SCSI_UFS_RENESAS is not set +# CONFIG_SCSI_UFS_ROCKCHIP is not set +# CONFIG_SCSI_UFS_SPRD is not set +# CONFIG_SCSI_UFS_TI_J721E is not set +# CONFIG_SCSI_VIRTIO is not set +# CONFIG_SCSI_WD719X is not set +# CONFIG_SC_CAMCC_7180 is not set +# CONFIG_SC_DISPCC_7280 is not set +# CONFIG_SC_GCC_7280 is not set +# CONFIG_SC_GCC_8180X is not set +# CONFIG_SC_GPUCC_7280 is not set +# CONFIG_SC_GPUCC_8280XP is not set +# CONFIG_SC_VIDEOCC_7280 is not set +# CONFIG_SCx200_ACB is not set +# CONFIG_SDIO_UART is not set +# CONFIG_SDM_GPUCC_660 is not set +# CONFIG_SDM_MMCC_660 is not set +# CONFIG_SDP500 is not set +# CONFIG_SDR_MAX2175 is not set +# CONFIG_SDR_PLATFORM_DRIVERS is not set +# CONFIG_SDX_GCC_55 is not set +# CONFIG_SD_ADC_MODULATOR is not set +# CONFIG_SECCOMP is not set +# CONFIG_SECCOMP_CACHE_DEBUG is not set +# CONFIG_SECRETMEM is not set +CONFIG_SECTION_MISMATCH_WARN_ONLY=y +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_APPARMOR is not set +CONFIG_SECURITY_DMESG_RESTRICT=y +# CONFIG_SECURITY_LANDLOCK is not set +# CONFIG_SECURITY_LOADPIN is not set +# CONFIG_SECURITY_LOCKDOWN_LSM is not set +# CONFIG_SECURITY_NETWORK_XFRM is not set +# CONFIG_SECURITY_PATH is not set +# CONFIG_SECURITY_SAFESETID is not set +# CONFIG_SECURITY_SELINUX_AVC_STATS is not set +# CONFIG_SECURITY_SELINUX_BOOTPARAM is not set +# CONFIG_SECURITY_SELINUX_DEBUG is not set +# CONFIG_SECURITY_SELINUX_DEVELOP is not set +# CONFIG_SECURITY_SMACK is not set +# CONFIG_SECURITY_TOMOYO is not set +# CONFIG_SECURITY_YAMA is not set +CONFIG_SELECT_MEMORY_MODEL=y +# CONFIG_SENSEAIR_SUNRISE_CO2 is not set +# CONFIG_SENSIRION_SGP30 is not set +# CONFIG_SENSIRION_SGP40 is not set +# CONFIG_SENSORS_ABITUGURU is not set +# CONFIG_SENSORS_ABITUGURU3 is not set +# CONFIG_SENSORS_ACBEL_FSG032 is not set +# CONFIG_SENSORS_ACPI_POWER is not set +# CONFIG_SENSORS_AD7314 is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADC128D818 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM1177 is not set +# CONFIG_SENSORS_ADM1266 is not set +# CONFIG_SENSORS_ADM1275 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADP1050 is not set +# CONFIG_SENSORS_ADS7828 is not set +# CONFIG_SENSORS_ADS7871 is not set +# CONFIG_SENSORS_ADT7310 is not set +# CONFIG_SENSORS_ADT7410 is not set +# CONFIG_SENSORS_ADT7411 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7475 is not set +# CONFIG_SENSORS_AHT10 is not set +# CONFIG_SENSORS_AMC6821 is not set +# CONFIG_SENSORS_APDS990X is not set +# CONFIG_SENSORS_APPLESMC is not set +# CONFIG_SENSORS_AQUACOMPUTER_D5NEXT is not set +# CONFIG_SENSORS_AS370 is not set +# CONFIG_SENSORS_ASB100 is not set +# CONFIG_SENSORS_ASC7621 is not set +# CONFIG_SENSORS_ASPEED is not set +# CONFIG_SENSORS_ASUS_ROG_RYUJIN is not set +# CONFIG_SENSORS_ASUS_WMI is not set +# CONFIG_SENSORS_ATK0110 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_AXI_FAN_CONTROL is not set +# CONFIG_SENSORS_BEL_PFE is not set +# CONFIG_SENSORS_BH1770 is not set +# CONFIG_SENSORS_BPA_RS600 is not set +# CONFIG_SENSORS_CHIPCAP2 is not set +# CONFIG_SENSORS_CORETEMP is not set +# CONFIG_SENSORS_CORSAIR_CPRO is not set +# CONFIG_SENSORS_CORSAIR_PSU is not set +# CONFIG_SENSORS_DELL_SMM is not set +# CONFIG_SENSORS_DELTA_AHE50DC_FAN is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_DPS920AB is not set +# CONFIG_SENSORS_DRIVETEMP is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_DS620 is not set +# CONFIG_SENSORS_EMC1403 is not set +# CONFIG_SENSORS_EMC2103 is not set +# CONFIG_SENSORS_EMC2305 is not set +# CONFIG_SENSORS_EMC6W201 is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_FAM15H_POWER is not set +# CONFIG_SENSORS_FSCHMD is not set +# CONFIG_SENSORS_FSP_3Y is not set +# CONFIG_SENSORS_FTSTEUTATES is not set +# CONFIG_SENSORS_G760A is not set +# CONFIG_SENSORS_G762 is not set +# CONFIG_SENSORS_GIGABYTE_WATERFORCE is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_GPIO_FAN is not set +# CONFIG_SENSORS_GSC is not set +# CONFIG_SENSORS_HDAPS is not set +# CONFIG_SENSORS_HIH6130 is not set +# CONFIG_SENSORS_HMC5843 is not set +# CONFIG_SENSORS_HMC5843_I2C is not set +# CONFIG_SENSORS_HMC5843_SPI is not set +# CONFIG_SENSORS_HP_WMI is not set +# CONFIG_SENSORS_HS3001 is not set +# CONFIG_SENSORS_I5500 is not set +# CONFIG_SENSORS_I5K_AMB is not set +# CONFIG_SENSORS_IBM_CFFPS is not set +# CONFIG_SENSORS_IIO_HWMON is not set +# CONFIG_SENSORS_INA209 is not set +# CONFIG_SENSORS_INA238 is not set +# CONFIG_SENSORS_INA2XX is not set +# CONFIG_SENSORS_INA3221 is not set +# CONFIG_SENSORS_INSPUR_IPSPS is not set +# CONFIG_SENSORS_IR35221 is not set +# CONFIG_SENSORS_IR36021 is not set +# CONFIG_SENSORS_IR38064 is not set +# CONFIG_SENSORS_IRPS5401 is not set +# CONFIG_SENSORS_ISL29018 is not set +# CONFIG_SENSORS_ISL29028 is not set +# CONFIG_SENSORS_ISL68137 is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_JC42 is not set +# CONFIG_SENSORS_K10TEMP is not set +# CONFIG_SENSORS_K8TEMP is not set +# CONFIG_SENSORS_LINEAGE is not set +# CONFIG_SENSORS_LIS3LV02D is not set +# CONFIG_SENSORS_LIS3_I2C is not set +# CONFIG_SENSORS_LIS3_SPI is not set +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +# CONFIG_SENSORS_LM73 is not set +# CONFIG_SENSORS_LM75 is not set +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +# CONFIG_SENSORS_LM95234 is not set +# CONFIG_SENSORS_LM95241 is not set +# CONFIG_SENSORS_LM95245 is not set +# CONFIG_SENSORS_LT7182S is not set +# CONFIG_SENSORS_LTC2945 is not set +# CONFIG_SENSORS_LTC2947_I2C is not set +# CONFIG_SENSORS_LTC2947_SPI is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_LTC2990 is not set +# CONFIG_SENSORS_LTC2991 is not set +# CONFIG_SENSORS_LTC2992 is not set +# CONFIG_SENSORS_LTC3815 is not set +# CONFIG_SENSORS_LTC4151 is not set +# CONFIG_SENSORS_LTC4215 is not set +# CONFIG_SENSORS_LTC4222 is not set +# CONFIG_SENSORS_LTC4245 is not set +# CONFIG_SENSORS_LTC4260 is not set +# CONFIG_SENSORS_LTC4261 is not set +# CONFIG_SENSORS_LTC4282 is not set +# CONFIG_SENSORS_LTC4286 is not set +# CONFIG_SENSORS_LTQ_CPUTEMP is not set +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX127 is not set +# CONFIG_SENSORS_MAX15301 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX16065 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX16601 is not set +# CONFIG_SENSORS_MAX1668 is not set +# CONFIG_SENSORS_MAX197 is not set +# CONFIG_SENSORS_MAX20730 is not set +# CONFIG_SENSORS_MAX20751 is not set +# CONFIG_SENSORS_MAX31722 is not set +# CONFIG_SENSORS_MAX31730 is not set +# CONFIG_SENSORS_MAX31760 is not set +# CONFIG_SENSORS_MAX31785 is not set +# CONFIG_SENSORS_MAX31790 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX6620 is not set +# CONFIG_SENSORS_MAX6621 is not set +# CONFIG_SENSORS_MAX6639 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_MAX6697 is not set +# CONFIG_SENSORS_MAX8688 is not set +# CONFIG_SENSORS_MC34VR500 is not set +# CONFIG_SENSORS_MCP3021 is not set +# CONFIG_SENSORS_MP2856 is not set +# CONFIG_SENSORS_MP2888 is not set +# CONFIG_SENSORS_MP2891 is not set +# CONFIG_SENSORS_MP2975 is not set +# CONFIG_SENSORS_MP2993 is not set +# CONFIG_SENSORS_MP5023 is not set +# CONFIG_SENSORS_MP5920 is not set +# CONFIG_SENSORS_MP5990 is not set +# CONFIG_SENSORS_MP9941 is not set +# CONFIG_SENSORS_MPQ7932 is not set +# CONFIG_SENSORS_MPQ8785 is not set +# CONFIG_SENSORS_MR75203 is not set +# CONFIG_SENSORS_NCT6683 is not set +# CONFIG_SENSORS_NCT6775 is not set +# CONFIG_SENSORS_NCT6775_I2C is not set +# CONFIG_SENSORS_NCT7802 is not set +# CONFIG_SENSORS_NCT7904 is not set +# CONFIG_SENSORS_NPCM7XX is not set +# CONFIG_SENSORS_NSA320 is not set +# CONFIG_SENSORS_NTC_THERMISTOR is not set +# CONFIG_SENSORS_NZXT_KRAKEN2 is not set +# CONFIG_SENSORS_NZXT_KRAKEN3 is not set +# CONFIG_SENSORS_NZXT_SMART2 is not set +# CONFIG_SENSORS_OCC_P8_I2C is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_SENSORS_PIM4328 is not set +# CONFIG_SENSORS_PLI1209BC is not set +# CONFIG_SENSORS_PM6764TR is not set +# CONFIG_SENSORS_PMBUS is not set +# CONFIG_SENSORS_POWERZ is not set +# CONFIG_SENSORS_POWR1220 is not set +# CONFIG_SENSORS_PT5161L is not set +# CONFIG_SENSORS_PWM_FAN is not set +# CONFIG_SENSORS_PXE1610 is not set +# CONFIG_SENSORS_Q54SJ108A2 is not set +# CONFIG_SENSORS_RM3100_I2C is not set +# CONFIG_SENSORS_RM3100_SPI is not set +# CONFIG_SENSORS_SBRMI is not set +# CONFIG_SENSORS_SBTSI is not set +# CONFIG_SENSORS_SCH5627 is not set +# CONFIG_SENSORS_SCH5636 is not set +# CONFIG_SENSORS_SCH56XX_COMMON is not set +# CONFIG_SENSORS_SHT15 is not set +# CONFIG_SENSORS_SHT21 is not set +# CONFIG_SENSORS_SHT3x is not set +# CONFIG_SENSORS_SHT4x is not set +# CONFIG_SENSORS_SHTC1 is not set +# CONFIG_SENSORS_SIS5595 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SPD5118 is not set +# CONFIG_SENSORS_STPDDC60 is not set +# CONFIG_SENSORS_STTS751 is not set +# CONFIG_SENSORS_TC654 is not set +# CONFIG_SENSORS_TC74 is not set +# CONFIG_SENSORS_TDA38640 is not set +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_TMP102 is not set +# CONFIG_SENSORS_TMP103 is not set +# CONFIG_SENSORS_TMP108 is not set +# CONFIG_SENSORS_TMP401 is not set +# CONFIG_SENSORS_TMP421 is not set +# CONFIG_SENSORS_TMP464 is not set +# CONFIG_SENSORS_TMP513 is not set +# CONFIG_SENSORS_TPS23861 is not set +# CONFIG_SENSORS_TPS40422 is not set +# CONFIG_SENSORS_TPS53679 is not set +# CONFIG_SENSORS_TPS546D24 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_SENSORS_TSL2563 is not set +# CONFIG_SENSORS_UCD9000 is not set +# CONFIG_SENSORS_UCD9200 is not set +# CONFIG_SENSORS_VEXPRESS is not set +# CONFIG_SENSORS_VIA686A is not set +# CONFIG_SENSORS_VIA_CPUTEMP is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_VT8231 is not set +# CONFIG_SENSORS_W83627EHF is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83773G is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83795 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_XDP710 is not set +# CONFIG_SENSORS_XDPE122 is not set +# CONFIG_SENSORS_XDPE152 is not set +# CONFIG_SENSORS_XGENE is not set +# CONFIG_SENSORS_ZL6100 is not set +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_16550A_VARIANTS=y +# CONFIG_SERIAL_8250_ACCENT is not set +# CONFIG_SERIAL_8250_ASPEED_VUART is not set +# CONFIG_SERIAL_8250_BOCA is not set +CONFIG_SERIAL_8250_CONSOLE=y +# CONFIG_SERIAL_8250_CS is not set +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set +# CONFIG_SERIAL_8250_DETECT_IRQ is not set +CONFIG_SERIAL_8250_DMA=y +# CONFIG_SERIAL_8250_DW is not set +# CONFIG_SERIAL_8250_EM is not set +# CONFIG_SERIAL_8250_EXAR is not set +# CONFIG_SERIAL_8250_EXAR_ST16C554 is not set +# CONFIG_SERIAL_8250_EXTENDED is not set +# CONFIG_SERIAL_8250_FINTEK is not set +# CONFIG_SERIAL_8250_FOURPORT is not set +# CONFIG_SERIAL_8250_HUB6 is not set +# CONFIG_SERIAL_8250_INGENIC is not set +# CONFIG_SERIAL_8250_LPSS is not set +# CONFIG_SERIAL_8250_MANY_PORTS is not set +# CONFIG_SERIAL_8250_MID is not set +CONFIG_SERIAL_8250_NR_UARTS=2 +# CONFIG_SERIAL_8250_PCI is not set +# CONFIG_SERIAL_8250_PCI1XXXX is not set +# CONFIG_SERIAL_8250_PERICOM is not set +# CONFIG_SERIAL_8250_RSA is not set +# CONFIG_SERIAL_8250_RT288X is not set +CONFIG_SERIAL_8250_RUNTIME_UARTS=2 +# CONFIG_SERIAL_ALTERA_JTAGUART is not set +# CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_AMBA_PL010 is not set +# CONFIG_SERIAL_AMBA_PL011 is not set +# CONFIG_SERIAL_ARC is not set +# CONFIG_SERIAL_BCM63XX is not set +# CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +# CONFIG_SERIAL_DEV_BUS is not set +CONFIG_SERIAL_EARLYCON=y +# CONFIG_SERIAL_EARLYCON_SEMIHOST is not set +# CONFIG_SERIAL_FSL_LINFLEXUART is not set +# CONFIG_SERIAL_FSL_LPUART is not set +# CONFIG_SERIAL_GRLIB_GAISLER_APBUART is not set +# CONFIG_SERIAL_JSM is not set +# CONFIG_SERIAL_MAX3100 is not set +# CONFIG_SERIAL_MAX310X is not set +# CONFIG_SERIAL_MULTI_INSTANTIATE is not set +# CONFIG_SERIAL_NONSTANDARD is not set +# CONFIG_SERIAL_OF_PLATFORM is not set +# CONFIG_SERIAL_PCH_UART is not set +# CONFIG_SERIAL_RP2 is not set +# CONFIG_SERIAL_SC16IS7XX is not set +# CONFIG_SERIAL_SCCNXP is not set +# CONFIG_SERIAL_SH_SCI is not set +# CONFIG_SERIAL_SIFIVE is not set +# CONFIG_SERIAL_SPRD is not set +# CONFIG_SERIAL_STM32 is not set +# CONFIG_SERIAL_ST_ASC is not set +# CONFIG_SERIAL_TIMBERDALE is not set +# CONFIG_SERIAL_UARTLITE is not set +# CONFIG_SERIAL_XILINX_PS_UART is not set +# CONFIG_SERIO is not set +# CONFIG_SERIO_ALTERA_PS2 is not set +# CONFIG_SERIO_AMBAKMI is not set +# CONFIG_SERIO_APBPS2 is not set +# CONFIG_SERIO_ARC_PS2 is not set +# CONFIG_SERIO_CT82C710 is not set +# CONFIG_SERIO_GPIO_PS2 is not set +# CONFIG_SERIO_I8042 is not set +# CONFIG_SERIO_LIBPS2 is not set +# CONFIG_SERIO_PARKBD is not set +# CONFIG_SERIO_PCIPS2 is not set +# CONFIG_SERIO_PS2MULT is not set +# CONFIG_SERIO_RAW is not set +# CONFIG_SERIO_SERPORT is not set +# CONFIG_SERIO_SUN4I_PS2 is not set +# CONFIG_SERIO_XILINX_XPS_PS2 is not set +# CONFIG_SFC is not set +# CONFIG_SFC_FALCON is not set +# CONFIG_SFC_SIENA is not set +# CONFIG_SFP is not set +# CONFIG_SF_PDMA is not set +# CONFIG_SGETMASK_SYSCALL is not set +# CONFIG_SGI_IP22 is not set +# CONFIG_SGI_IP27 is not set +# CONFIG_SGI_IP28 is not set +# CONFIG_SGI_IP30 is not set +# CONFIG_SGI_IP32 is not set +# CONFIG_SGI_MFD_IOC3 is not set +# CONFIG_SGI_PARTITION is not set +# CONFIG_SG_POOL is not set +# CONFIG_SG_SPLIT is not set +# CONFIG_SHADOW_CALL_STACK is not set +CONFIG_SHMEM=y +# CONFIG_SHRINKER_DEBUG is not set +# CONFIG_SHUFFLE_PAGE_ALLOCATOR is not set +# CONFIG_SH_ETH is not set +# CONFIG_SH_TIMER_CMT is not set +# CONFIG_SH_TIMER_MTU2 is not set +# CONFIG_SH_TIMER_TMU is not set +# CONFIG_SI1133 is not set +# CONFIG_SI1145 is not set +# CONFIG_SI7005 is not set +# CONFIG_SI7020 is not set +# CONFIG_SIBYTE_BIGSUR is not set +# CONFIG_SIBYTE_CRHONE is not set +# CONFIG_SIBYTE_LITTLESUR is not set +# CONFIG_SIBYTE_RHONE is not set +# CONFIG_SIBYTE_SENTOSA is not set +# CONFIG_SIBYTE_SWARM is not set +CONFIG_SIGNALFD=y +# CONFIG_SIGNED_PE_FILE_VERIFICATION is not set +# CONFIG_SIOX is not set +# CONFIG_SIS190 is not set +# CONFIG_SIS900 is not set +# CONFIG_SKGE is not set +# CONFIG_SKY2 is not set +# CONFIG_SKY2_DEBUG is not set +CONFIG_SLAB_BUCKETS=y +CONFIG_SLAB_FREELIST_HARDENED=y +CONFIG_SLAB_FREELIST_RANDOM=y +CONFIG_SLAB_MERGE_DEFAULT=y +# CONFIG_SLHC is not set +# CONFIG_SLICOSS is not set +# CONFIG_SLIMBUS is not set +# CONFIG_SLIP is not set +CONFIG_SLUB=y +CONFIG_SLUB_CPU_PARTIAL=y +# CONFIG_SLUB_DEBUG is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +# CONFIG_SLUB_TINY is not set +# CONFIG_SMARTJOYPLUS_FF is not set +# CONFIG_SMB_SERVER is not set +# CONFIG_SMC9194 is not set +# CONFIG_SMC91X is not set +# CONFIG_SMP is not set +# CONFIG_SMSC911X is not set +# CONFIG_SMSC9420 is not set +# CONFIG_SMSC_PHY is not set +# CONFIG_SMS_SDIO_DRV is not set +# CONFIG_SMS_USB_DRV is not set +# CONFIG_SM_CAMCC_8250 is not set +# CONFIG_SM_FTL is not set +# CONFIG_SM_GCC_6115 is not set +# CONFIG_SM_GCC_6125 is not set +# CONFIG_SM_GCC_6350 is not set +# CONFIG_SM_GCC_6375 is not set +# CONFIG_SM_GCC_8350 is not set +# CONFIG_SND is not set +# CONFIG_SND_AC97_POWER_SAVE is not set +# CONFIG_SND_AD1816A is not set +# CONFIG_SND_AD1848 is not set +# CONFIG_SND_AD1889 is not set +# CONFIG_SND_ADLIB is not set +# CONFIG_SND_ALI5451 is not set +# CONFIG_SND_ALOOP is not set +# CONFIG_SND_ALS100 is not set +# CONFIG_SND_ALS300 is not set +# CONFIG_SND_ALS4000 is not set +# CONFIG_SND_AMD_ACP_CONFIG is not set +# CONFIG_SND_ARM is not set +# CONFIG_SND_ASIHPI is not set +# CONFIG_SND_ATIIXP is not set +# CONFIG_SND_ATIIXP_MODEM is not set +# CONFIG_SND_ATMEL_AC97C is not set +# CONFIG_SND_ATMEL_SOC is not set +# CONFIG_SND_AU8810 is not set +# CONFIG_SND_AU8820 is not set +# CONFIG_SND_AU8830 is not set +# CONFIG_SND_AUDIO_GRAPH_CARD is not set +# CONFIG_SND_AUDIO_GRAPH_CARD2 is not set +# CONFIG_SND_AW2 is not set +# CONFIG_SND_AZT2320 is not set +# CONFIG_SND_AZT3328 is not set +# CONFIG_SND_BCD2000 is not set +# CONFIG_SND_BCM2835 is not set +# CONFIG_SND_BCM63XX_I2S_WHISTLER is not set +# CONFIG_SND_BT87X is not set +# CONFIG_SND_CA0106 is not set +# CONFIG_SND_CMI8330 is not set +# CONFIG_SND_CMIPCI is not set +# CONFIG_SND_CS4231 is not set +# CONFIG_SND_CS4236 is not set +# CONFIG_SND_CS4281 is not set +# CONFIG_SND_CS46XX is not set +# CONFIG_SND_CS5530 is not set +# CONFIG_SND_CS5535AUDIO is not set +# CONFIG_SND_CTL_FAST_LOOKUP is not set +# CONFIG_SND_CTL_INPUT_VALIDATION is not set +# CONFIG_SND_CTXFI is not set +# CONFIG_SND_DARLA20 is not set +# CONFIG_SND_DARLA24 is not set +# CONFIG_SND_DEBUG is not set +# CONFIG_SND_DESIGNWARE_I2S is not set +CONFIG_SND_DRIVERS=y +# CONFIG_SND_DUMMY is not set +# CONFIG_SND_DYNAMIC_MINORS is not set +# CONFIG_SND_ECHO3G is not set +# CONFIG_SND_EMU10K1 is not set +# CONFIG_SND_EMU10K1X is not set +# CONFIG_SND_EMU10K1_SEQ is not set +# CONFIG_SND_ENS1370 is not set +# CONFIG_SND_ENS1371 is not set +# CONFIG_SND_ES1688 is not set +# CONFIG_SND_ES18XX is not set +# CONFIG_SND_ES1938 is not set +# CONFIG_SND_ES1968 is not set +# CONFIG_SND_FIREWIRE is not set +# CONFIG_SND_FM801 is not set +# CONFIG_SND_GINA20 is not set +# CONFIG_SND_GINA24 is not set +# CONFIG_SND_GUSCLASSIC is not set +# CONFIG_SND_GUSEXTREME is not set +# CONFIG_SND_GUSMAX is not set +# CONFIG_SND_HDA_CODEC_CS8409 is not set +# CONFIG_SND_HDA_CODEC_SENARYTECH is not set +# CONFIG_SND_HDA_CTL_DEV_ID is not set +# CONFIG_SND_HDA_INTEL is not set +# CONFIG_SND_HDA_INTEL_HDMI_SILENT_STREAM is not set +CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0 +CONFIG_SND_HDA_PREALLOC_SIZE=64 +# CONFIG_SND_HDA_SCODEC_CS35L41_I2C is not set +# CONFIG_SND_HDA_SCODEC_CS35L41_SPI is not set +# CONFIG_SND_HDA_SCODEC_CS35L56_I2C is not set +# CONFIG_SND_HDA_SCODEC_CS35L56_SPI is not set +# CONFIG_SND_HDA_SCODEC_TAS2781_I2C is not set +# CONFIG_SND_HDSP is not set +# CONFIG_SND_HDSPM is not set +# CONFIG_SND_HRTIMER is not set +# CONFIG_SND_HWDEP is not set +# CONFIG_SND_I2S_HI6210_I2S is not set +# CONFIG_SND_ICE1712 is not set +# CONFIG_SND_ICE1724 is not set +# CONFIG_SND_INDIGO is not set +# CONFIG_SND_INDIGODJ is not set +# CONFIG_SND_INDIGODJX is not set +# CONFIG_SND_INDIGOIO is not set +# CONFIG_SND_INDIGOIOX is not set +# CONFIG_SND_INTEL8X0 is not set +# CONFIG_SND_INTEL8X0M is not set +# CONFIG_SND_INTERWAVE is not set +# CONFIG_SND_INTERWAVE_STB is not set +# CONFIG_SND_ISA is not set +# CONFIG_SND_JZ4740_SOC_I2S is not set +# CONFIG_SND_KIRKWOOD_SOC is not set +# CONFIG_SND_KORG1212 is not set +# CONFIG_SND_LAYLA20 is not set +# CONFIG_SND_LAYLA24 is not set +# CONFIG_SND_LOLA is not set +# CONFIG_SND_LX6464ES is not set +# CONFIG_SND_MAESTRO3 is not set +CONFIG_SND_MAX_CARDS=16 +# CONFIG_SND_MIA is not set +# CONFIG_SND_MIPS is not set +# CONFIG_SND_MIRO is not set +# CONFIG_SND_MIXART is not set +# CONFIG_SND_MIXER_OSS is not set +# CONFIG_SND_MONA is not set +# CONFIG_SND_MPC52xx_SOC_EFIKA is not set +# CONFIG_SND_MPU401 is not set +# CONFIG_SND_MTPAV is not set +# CONFIG_SND_MTS64 is not set +# CONFIG_SND_MXS_SOC is not set +# CONFIG_SND_NM256 is not set +# CONFIG_SND_OPL3SA2 is not set +# CONFIG_SND_OPL3_LIB_SEQ is not set +# CONFIG_SND_OPL4_LIB_SEQ is not set +# CONFIG_SND_OPTI92X_AD1848 is not set +# CONFIG_SND_OPTI92X_CS4231 is not set +# CONFIG_SND_OPTI93X is not set +CONFIG_SND_OSSEMUL=y +# CONFIG_SND_OXYGEN is not set +CONFIG_SND_PCI=y +# CONFIG_SND_PCM is not set +# CONFIG_SND_PCMCIA is not set +# CONFIG_SND_PCMTEST is not set +# CONFIG_SND_PCM_OSS is not set +CONFIG_SND_PCM_OSS_PLUGINS=y +# CONFIG_SND_PCM_TIMER is not set +# CONFIG_SND_PCM_XRUN_DEBUG is not set +# CONFIG_SND_PCXHR is not set +# CONFIG_SND_PDAUDIOCF is not set +# CONFIG_SND_PORTMAN2X4 is not set +# CONFIG_SND_POWERPC_SOC is not set +# CONFIG_SND_PPC is not set +CONFIG_SND_PROC_FS=y +# CONFIG_SND_RAWMIDI is not set +# CONFIG_SND_RIPTIDE is not set +# CONFIG_SND_RME32 is not set +# CONFIG_SND_RME96 is not set +# CONFIG_SND_RME9652 is not set +# CONFIG_SND_SB16 is not set +# CONFIG_SND_SB8 is not set +# CONFIG_SND_SBAWE is not set +# CONFIG_SND_SBAWE_SEQ is not set +# CONFIG_SND_SE6X is not set +# CONFIG_SND_SEQUENCER is not set +# CONFIG_SND_SEQ_UMP is not set +# CONFIG_SND_SERIAL_GENERIC is not set +# CONFIG_SND_SERIAL_U16550 is not set +# CONFIG_SND_SIMPLE_CARD is not set +# CONFIG_SND_SIS7019 is not set +# CONFIG_SND_SOC is not set +# CONFIG_SND_SOC_AC97_CODEC is not set +# CONFIG_SND_SOC_AD193X_I2C is not set +# CONFIG_SND_SOC_AD193X_SPI is not set +# CONFIG_SND_SOC_ADAU1372_I2C is not set +# CONFIG_SND_SOC_ADAU1372_SPI is not set +# CONFIG_SND_SOC_ADAU1701 is not set +# CONFIG_SND_SOC_ADAU1761_I2C is not set +# CONFIG_SND_SOC_ADAU1761_SPI is not set +# CONFIG_SND_SOC_ADAU7002 is not set +# CONFIG_SND_SOC_ADAU7118_HW is not set +# CONFIG_SND_SOC_ADAU7118_I2C is not set +# CONFIG_SND_SOC_ADI is not set +# CONFIG_SND_SOC_AK4104 is not set +# CONFIG_SND_SOC_AK4118 is not set +# CONFIG_SND_SOC_AK4375 is not set +# CONFIG_SND_SOC_AK4458 is not set +# CONFIG_SND_SOC_AK4554 is not set +# CONFIG_SND_SOC_AK4613 is not set +# CONFIG_SND_SOC_AK4619 is not set +# CONFIG_SND_SOC_AK4642 is not set +# CONFIG_SND_SOC_AK5386 is not set +# CONFIG_SND_SOC_AK5558 is not set +# CONFIG_SND_SOC_ALC5623 is not set +# CONFIG_SND_SOC_AMD_ACP is not set +# CONFIG_SND_SOC_AMD_ACP3x is not set +# CONFIG_SND_SOC_AMD_ACP5x is not set +# CONFIG_SND_SOC_AMD_ACP6x is not set +# CONFIG_SND_SOC_AMD_ACP_COMMON is not set +# CONFIG_SND_SOC_AMD_PS is not set +# CONFIG_SND_SOC_AMD_RENOIR is not set +# CONFIG_SND_SOC_AMD_RPL_ACP6x is not set +# CONFIG_SND_SOC_AU1XAUDIO is not set +# CONFIG_SND_SOC_AU1XPSC is not set +# CONFIG_SND_SOC_AUDIO_IIO_AUX is not set +# CONFIG_SND_SOC_AW8738 is not set +# CONFIG_SND_SOC_AW87390 is not set +# CONFIG_SND_SOC_AW88261 is not set +# CONFIG_SND_SOC_AW88395 is not set +# CONFIG_SND_SOC_AW88399 is not set +# CONFIG_SND_SOC_BD28623 is not set +# CONFIG_SND_SOC_BT_SCO is not set +# CONFIG_SND_SOC_CHV3_CODEC is not set +# CONFIG_SND_SOC_CHV3_I2S is not set +# CONFIG_SND_SOC_CS35L32 is not set +# CONFIG_SND_SOC_CS35L33 is not set +# CONFIG_SND_SOC_CS35L34 is not set +# CONFIG_SND_SOC_CS35L35 is not set +# CONFIG_SND_SOC_CS35L36 is not set +# CONFIG_SND_SOC_CS35L41_I2C is not set +# CONFIG_SND_SOC_CS35L41_SPI is not set +# CONFIG_SND_SOC_CS35L45_I2C is not set +# CONFIG_SND_SOC_CS35L45_SPI is not set +# CONFIG_SND_SOC_CS35L56_I2C is not set +# CONFIG_SND_SOC_CS35L56_SPI is not set +# CONFIG_SND_SOC_CS4234 is not set +# CONFIG_SND_SOC_CS4265 is not set +# CONFIG_SND_SOC_CS4270 is not set +# CONFIG_SND_SOC_CS4271 is not set +# CONFIG_SND_SOC_CS4271_I2C is not set +# CONFIG_SND_SOC_CS4271_SPI is not set +# CONFIG_SND_SOC_CS42L42 is not set +# CONFIG_SND_SOC_CS42L51_I2C is not set +# CONFIG_SND_SOC_CS42L52 is not set +# CONFIG_SND_SOC_CS42L56 is not set +# CONFIG_SND_SOC_CS42L73 is not set +# CONFIG_SND_SOC_CS42L83 is not set +# CONFIG_SND_SOC_CS42XX8_I2C is not set +# CONFIG_SND_SOC_CS43130 is not set +# CONFIG_SND_SOC_CS4341 is not set +# CONFIG_SND_SOC_CS4349 is not set +# CONFIG_SND_SOC_CS530X_I2C is not set +# CONFIG_SND_SOC_CS53L30 is not set +# CONFIG_SND_SOC_CX2072X is not set +# CONFIG_SND_SOC_DA7213 is not set +# CONFIG_SND_SOC_DMIC is not set +# CONFIG_SND_SOC_ES7134 is not set +# CONFIG_SND_SOC_ES7241 is not set +# CONFIG_SND_SOC_ES8311 is not set +# CONFIG_SND_SOC_ES8316 is not set +# CONFIG_SND_SOC_ES8326 is not set +# CONFIG_SND_SOC_ES8328 is not set +# CONFIG_SND_SOC_ES8328_I2C is not set +# CONFIG_SND_SOC_ES8328_SPI is not set +# CONFIG_SND_SOC_EUKREA_TLV320 is not set +# CONFIG_SND_SOC_FSL_ASOC_CARD is not set +# CONFIG_SND_SOC_FSL_ASRC is not set +# CONFIG_SND_SOC_FSL_AUD2HTX is not set +# CONFIG_SND_SOC_FSL_AUDMIX is not set +# CONFIG_SND_SOC_FSL_ESAI is not set +# CONFIG_SND_SOC_FSL_MICFIL is not set +# CONFIG_SND_SOC_FSL_RPMSG is not set +# CONFIG_SND_SOC_FSL_SAI is not set +# CONFIG_SND_SOC_FSL_SPDIF is not set +# CONFIG_SND_SOC_FSL_SSI is not set +# CONFIG_SND_SOC_FSL_XCVR is not set +# CONFIG_SND_SOC_GTM601 is not set +# CONFIG_SND_SOC_HDA is not set +# CONFIG_SND_SOC_ICS43432 is not set +# CONFIG_SND_SOC_IDT821034 is not set +# CONFIG_SND_SOC_IMG is not set +# CONFIG_SND_SOC_IMX_AUDMIX is not set +# CONFIG_SND_SOC_IMX_AUDMUX is not set +# CONFIG_SND_SOC_IMX_CARD is not set +# CONFIG_SND_SOC_IMX_ES8328 is not set +# CONFIG_SND_SOC_IMX_HDMI is not set +# CONFIG_SND_SOC_IMX_RPMSG is not set +# CONFIG_SND_SOC_INNO_RK3036 is not set +# CONFIG_SND_SOC_INTEL_AVS is not set +# CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH is not set +# CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH is not set +# CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH is not set +# CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH is not set +# CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH is not set +# CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH is not set +# CONFIG_SND_SOC_INTEL_CATPT is not set +# CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH is not set +# CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH is not set +# CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH is not set +# CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH is not set +# CONFIG_SND_SOC_INTEL_HASWELL is not set +# CONFIG_SND_SOC_INTEL_KEEMBAY is not set +# CONFIG_SND_SOC_INTEL_SST is not set +CONFIG_SND_SOC_INTEL_SST_TOPLEVEL=y +# CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES is not set +# CONFIG_SND_SOC_JZ4725B_CODEC is not set +# CONFIG_SND_SOC_JZ4740_CODEC is not set +# CONFIG_SND_SOC_JZ4770_CODEC is not set +# CONFIG_SND_SOC_LOONGSON_CARD is not set +# CONFIG_SND_SOC_LOONGSON_I2S_PCI is not set +# CONFIG_SND_SOC_LPASS_RX_MACRO is not set +# CONFIG_SND_SOC_LPASS_TX_MACRO is not set +# CONFIG_SND_SOC_LPASS_VA_MACRO is not set +# CONFIG_SND_SOC_LPASS_WSA_MACRO is not set +# CONFIG_SND_SOC_MAX9759 is not set +# CONFIG_SND_SOC_MAX98088 is not set +# CONFIG_SND_SOC_MAX98090 is not set +# CONFIG_SND_SOC_MAX98357A is not set +# CONFIG_SND_SOC_MAX98373 is not set +# CONFIG_SND_SOC_MAX98373_I2C is not set +# CONFIG_SND_SOC_MAX98388 is not set +# CONFIG_SND_SOC_MAX98390 is not set +# CONFIG_SND_SOC_MAX98396 is not set +# CONFIG_SND_SOC_MAX98504 is not set +# CONFIG_SND_SOC_MAX98520 is not set +# CONFIG_SND_SOC_MAX9860 is not set +# CONFIG_SND_SOC_MAX9867 is not set +# CONFIG_SND_SOC_MAX98927 is not set +# CONFIG_SND_SOC_MEDIATEK is not set +# CONFIG_SND_SOC_MPC5200_AC97 is not set +# CONFIG_SND_SOC_MPC5200_I2S is not set +# CONFIG_SND_SOC_MSM8916_WCD_ANALOG is not set +# CONFIG_SND_SOC_MSM8916_WCD_DIGITAL is not set +# CONFIG_SND_SOC_MT2701 is not set +# CONFIG_SND_SOC_MT6351 is not set +# CONFIG_SND_SOC_MT6357 is not set +# CONFIG_SND_SOC_MT6358 is not set +# CONFIG_SND_SOC_MT6359 is not set +# CONFIG_SND_SOC_MT6359_ACCDET is not set +# CONFIG_SND_SOC_MT6660 is not set +# CONFIG_SND_SOC_MT6797 is not set +# CONFIG_SND_SOC_MT8173 is not set +# CONFIG_SND_SOC_MT8183 is not set +# CONFIG_SND_SOC_MT8186 is not set +# CONFIG_SND_SOC_MT8188 is not set +# CONFIG_SND_SOC_MT8192 is not set +# CONFIG_SND_SOC_MT8195 is not set +# CONFIG_SND_SOC_MT8365 is not set +# CONFIG_SND_SOC_MTK_BTCVSD is not set +# CONFIG_SND_SOC_NAU8315 is not set +# CONFIG_SND_SOC_NAU8325 is not set +# CONFIG_SND_SOC_NAU8540 is not set +# CONFIG_SND_SOC_NAU8810 is not set +# CONFIG_SND_SOC_NAU8821 is not set +# CONFIG_SND_SOC_NAU8822 is not set +# CONFIG_SND_SOC_NAU8824 is not set +# CONFIG_SND_SOC_PCM1681 is not set +# CONFIG_SND_SOC_PCM1789_I2C is not set +# CONFIG_SND_SOC_PCM179X_I2C is not set +# CONFIG_SND_SOC_PCM179X_SPI is not set +# CONFIG_SND_SOC_PCM186X_I2C is not set +# CONFIG_SND_SOC_PCM186X_SPI is not set +# CONFIG_SND_SOC_PCM3060_I2C is not set +# CONFIG_SND_SOC_PCM3060_SPI is not set +# CONFIG_SND_SOC_PCM3168A_I2C is not set +# CONFIG_SND_SOC_PCM3168A_SPI is not set +# CONFIG_SND_SOC_PCM5102A is not set +# CONFIG_SND_SOC_PCM512x_I2C is not set +# CONFIG_SND_SOC_PCM512x_SPI is not set +# CONFIG_SND_SOC_PCM6240 is not set +# CONFIG_SND_SOC_PEB2466 is not set +# CONFIG_SND_SOC_QCOM is not set +# CONFIG_SND_SOC_RK3308 is not set +# CONFIG_SND_SOC_RK3328 is not set +# CONFIG_SND_SOC_RK817 is not set +# CONFIG_SND_SOC_ROCKCHIP is not set +# CONFIG_SND_SOC_RT5616 is not set +# CONFIG_SND_SOC_RT5631 is not set +# CONFIG_SND_SOC_RT5640 is not set +# CONFIG_SND_SOC_RT5659 is not set +# CONFIG_SND_SOC_RT5677_SPI is not set +# CONFIG_SND_SOC_RT9120 is not set +# CONFIG_SND_SOC_RTQ9128 is not set +# CONFIG_SND_SOC_SGTL5000 is not set +# CONFIG_SND_SOC_SIMPLE_AMPLIFIER is not set +# CONFIG_SND_SOC_SIMPLE_MUX is not set +# CONFIG_SND_SOC_SMA1303 is not set +# CONFIG_SND_SOC_SOF_TOPLEVEL is not set +# CONFIG_SND_SOC_SPDIF is not set +# CONFIG_SND_SOC_SRC4XXX_I2C is not set +# CONFIG_SND_SOC_SSM2305 is not set +# CONFIG_SND_SOC_SSM2518 is not set +# CONFIG_SND_SOC_SSM2602_I2C is not set +# CONFIG_SND_SOC_SSM2602_SPI is not set +# CONFIG_SND_SOC_SSM3515 is not set +# CONFIG_SND_SOC_SSM4567 is not set +# CONFIG_SND_SOC_STA32X is not set +# CONFIG_SND_SOC_STA350 is not set +# CONFIG_SND_SOC_STI_SAS is not set +# CONFIG_SND_SOC_TAS2552 is not set +# CONFIG_SND_SOC_TAS2562 is not set +# CONFIG_SND_SOC_TAS2764 is not set +# CONFIG_SND_SOC_TAS2770 is not set +# CONFIG_SND_SOC_TAS2780 is not set +# CONFIG_SND_SOC_TAS2781_I2C is not set +# CONFIG_SND_SOC_TAS5086 is not set +# CONFIG_SND_SOC_TAS571X is not set +# CONFIG_SND_SOC_TAS5720 is not set +# CONFIG_SND_SOC_TAS5805M is not set +# CONFIG_SND_SOC_TAS6424 is not set +# CONFIG_SND_SOC_TDA7419 is not set +# CONFIG_SND_SOC_TFA9879 is not set +# CONFIG_SND_SOC_TFA989X is not set +# CONFIG_SND_SOC_TLV320ADC3XXX is not set +# CONFIG_SND_SOC_TLV320ADCX140 is not set +# CONFIG_SND_SOC_TLV320AIC23_I2C is not set +# CONFIG_SND_SOC_TLV320AIC23_SPI is not set +# CONFIG_SND_SOC_TLV320AIC31XX is not set +# CONFIG_SND_SOC_TLV320AIC32X4_I2C is not set +# CONFIG_SND_SOC_TLV320AIC32X4_SPI is not set +# CONFIG_SND_SOC_TLV320AIC3X is not set +# CONFIG_SND_SOC_TLV320AIC3X_I2C is not set +# CONFIG_SND_SOC_TLV320AIC3X_SPI is not set +# CONFIG_SND_SOC_TPA6130A2 is not set +# CONFIG_SND_SOC_TS3A227E is not set +# CONFIG_SND_SOC_TSCS42XX is not set +# CONFIG_SND_SOC_TSCS454 is not set +# CONFIG_SND_SOC_UDA1334 is not set +# CONFIG_SND_SOC_WM8510 is not set +# CONFIG_SND_SOC_WM8523 is not set +# CONFIG_SND_SOC_WM8524 is not set +# CONFIG_SND_SOC_WM8580 is not set +# CONFIG_SND_SOC_WM8711 is not set +# CONFIG_SND_SOC_WM8728 is not set +# CONFIG_SND_SOC_WM8731 is not set +# CONFIG_SND_SOC_WM8731_I2C is not set +# CONFIG_SND_SOC_WM8731_SPI is not set +# CONFIG_SND_SOC_WM8737 is not set +# CONFIG_SND_SOC_WM8741 is not set +# CONFIG_SND_SOC_WM8750 is not set +# CONFIG_SND_SOC_WM8753 is not set +# CONFIG_SND_SOC_WM8770 is not set +# CONFIG_SND_SOC_WM8776 is not set +# CONFIG_SND_SOC_WM8782 is not set +# CONFIG_SND_SOC_WM8804_I2C is not set +# CONFIG_SND_SOC_WM8804_SPI is not set +# CONFIG_SND_SOC_WM8903 is not set +# CONFIG_SND_SOC_WM8904 is not set +# CONFIG_SND_SOC_WM8940 is not set +# CONFIG_SND_SOC_WM8960 is not set +# CONFIG_SND_SOC_WM8961 is not set +# CONFIG_SND_SOC_WM8962 is not set +# CONFIG_SND_SOC_WM8974 is not set +# CONFIG_SND_SOC_WM8978 is not set +# CONFIG_SND_SOC_WM8985 is not set +# CONFIG_SND_SOC_XILINX_AUDIO_FORMATTER is not set +# CONFIG_SND_SOC_XILINX_I2S is not set +# CONFIG_SND_SOC_XILINX_SPDIF is not set +# CONFIG_SND_SOC_XTFPGA_I2S is not set +# CONFIG_SND_SOC_ZL38060 is not set +# CONFIG_SND_SONICVIBES is not set +# CONFIG_SND_SPI is not set +# CONFIG_SND_SSCAPE is not set +# CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI is not set +# CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_PCI is not set +# CONFIG_SND_SUN4I_CODEC is not set +# CONFIG_SND_SUPPORT_OLD_API is not set +# CONFIG_SND_TEST_COMPONENT is not set +# CONFIG_SND_TIMER is not set +# CONFIG_SND_TRIDENT is not set +CONFIG_SND_USB=y +# CONFIG_SND_USB_6FIRE is not set +# CONFIG_SND_USB_AUDIO is not set +# CONFIG_SND_USB_AUDIO_MIDI_V2 is not set +# CONFIG_SND_USB_CAIAQ is not set +# CONFIG_SND_USB_HIFACE is not set +# CONFIG_SND_USB_POD is not set +# CONFIG_SND_USB_PODHD is not set +# CONFIG_SND_USB_TONEPORT is not set +# CONFIG_SND_USB_UA101 is not set +# CONFIG_SND_USB_US122L is not set +# CONFIG_SND_USB_USX2Y is not set +# CONFIG_SND_USB_VARIAX is not set +# CONFIG_SND_UTIMER is not set +CONFIG_SND_VERBOSE_PROCFS=y +# CONFIG_SND_VIA82XX is not set +# CONFIG_SND_VIA82XX_MODEM is not set +# CONFIG_SND_VIRTIO is not set +# CONFIG_SND_VIRTUOSO is not set +# CONFIG_SND_VX222 is not set +# CONFIG_SND_VXPOCKET is not set +# CONFIG_SND_WAVEFRONT is not set +CONFIG_SND_X86=y +# CONFIG_SND_XEN_FRONTEND is not set +# CONFIG_SND_YMFPCI is not set +# CONFIG_SNI_RM is not set +# CONFIG_SOCIONEXT_SYNQUACER_PREITS is not set +# CONFIG_SOCK_CGROUP_DATA is not set +# CONFIG_SOC_AM33XX is not set +# CONFIG_SOC_AM43XX is not set +# CONFIG_SOC_BRCMSTB is not set +# CONFIG_SOC_DRA7XX is not set +# CONFIG_SOC_HAS_OMAP2_SDRC is not set +# CONFIG_SOC_OMAP5 is not set +# CONFIG_SOC_TI is not set +# CONFIG_SOFTLOCKUP_DETECTOR is not set +# CONFIG_SOFTLOCKUP_DETECTOR_INTR_STORM is not set +# CONFIG_SOFT_WATCHDOG is not set +# CONFIG_SOLARIS_X86_PARTITION is not set +# CONFIG_SONYPI is not set +# CONFIG_SONY_LAPTOP is not set +# CONFIG_SOUND is not set +# CONFIG_SOUNDWIRE is not set +# CONFIG_SOUND_OSS_CORE is not set +# CONFIG_SOUND_OSS_CORE_PRECLAIM is not set +# CONFIG_SP5100_TCO is not set +# CONFIG_SPARSEMEM_MANUAL is not set +# CONFIG_SPARSEMEM_STATIC is not set +# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set +# CONFIG_SPARSE_IRQ is not set +# CONFIG_SPEAKUP is not set +# CONFIG_SPI is not set +# CONFIG_SPINLOCK_TEST is not set +# CONFIG_SPI_ALTERA is not set +# CONFIG_SPI_AMD is not set +# CONFIG_SPI_AU1550 is not set +# CONFIG_SPI_AX88796C is not set +# CONFIG_SPI_AXI_SPI_ENGINE is not set +# CONFIG_SPI_BCM2835 is not set +# CONFIG_SPI_BCM63XX_HSSPI is not set +# CONFIG_SPI_BCMBCA_HSSPI is not set +# CONFIG_SPI_BCM_QSPI is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_SPI_BUTTERFLY is not set +# CONFIG_SPI_CADENCE is not set +# CONFIG_SPI_CADENCE_QUADSPI is not set +# CONFIG_SPI_CADENCE_XSPI is not set +# CONFIG_SPI_CH341 is not set +# CONFIG_SPI_DEBUG is not set +# CONFIG_SPI_DESIGNWARE is not set +# CONFIG_SPI_DW_BT1 is not set +# CONFIG_SPI_DW_BT1_DIRMAP is not set +# CONFIG_SPI_DW_DMA is not set +# CONFIG_SPI_DW_MMIO is not set +# CONFIG_SPI_DW_PCI is not set +# CONFIG_SPI_FSL_DSPI is not set +# CONFIG_SPI_FSL_ESPI is not set +# CONFIG_SPI_FSL_SPI is not set +# CONFIG_SPI_GPIO is not set +# CONFIG_SPI_IMG_SPFI is not set +# CONFIG_SPI_LANTIQ_SSC is not set +# CONFIG_SPI_LM70_LLP is not set +# CONFIG_SPI_LOOPBACK_TEST is not set +# CONFIG_SPI_MASTER is not set +# CONFIG_SPI_MEM is not set +# CONFIG_SPI_MICROCHIP_CORE is not set +# CONFIG_SPI_MICROCHIP_CORE_QSPI is not set +# CONFIG_SPI_MPC52xx is not set +# CONFIG_SPI_MPC52xx_PSC is not set +# CONFIG_SPI_MUX is not set +# CONFIG_SPI_MXIC is not set +# CONFIG_SPI_NXP_FLEXSPI is not set +# CONFIG_SPI_OCTEON is not set +# CONFIG_SPI_OC_TINY is not set +# CONFIG_SPI_ORION is not set +# CONFIG_SPI_PCI1XXXX is not set +# CONFIG_SPI_PL022 is not set +# CONFIG_SPI_PPC4xx is not set +# CONFIG_SPI_PXA2XX is not set +# CONFIG_SPI_PXA2XX_PCI is not set +# CONFIG_SPI_QCOM_QSPI is not set +# CONFIG_SPI_ROCKCHIP is not set +# CONFIG_SPI_S3C64XX is not set +# CONFIG_SPI_SC18IS602 is not set +# CONFIG_SPI_SIFIVE is not set +# CONFIG_SPI_SLAVE is not set +# CONFIG_SPI_SN_F_OSPI is not set +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_THUNDERX is not set +# CONFIG_SPI_TI_QSPI is not set +# CONFIG_SPI_TLE62X0 is not set +# CONFIG_SPI_TOPCLIFF_PCH is not set +# CONFIG_SPI_XCOMM is not set +# CONFIG_SPI_XILINX is not set +# CONFIG_SPI_ZYNQMP_GQSPI is not set +# CONFIG_SPMI is not set +# CONFIG_SPS30 is not set +# CONFIG_SPS30_I2C is not set +# CONFIG_SPS30_SERIAL is not set +CONFIG_SQUASHFS=y +# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set +# CONFIG_SQUASHFS_CHOICE_DECOMP_BY_MOUNT is not set +# CONFIG_SQUASHFS_COMPILE_DECOMP_MULTI is not set +CONFIG_SQUASHFS_COMPILE_DECOMP_MULTI_PERCPU=y +# CONFIG_SQUASHFS_COMPILE_DECOMP_SINGLE is not set +CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU=y +CONFIG_SQUASHFS_EMBEDDED=y +# CONFIG_SQUASHFS_FILE_CACHE is not set +CONFIG_SQUASHFS_FILE_DIRECT=y +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 +# CONFIG_SQUASHFS_LZ4 is not set +# CONFIG_SQUASHFS_LZO is not set +# CONFIG_SQUASHFS_XATTR is not set +CONFIG_SQUASHFS_XZ=y +# CONFIG_SQUASHFS_ZLIB is not set +# CONFIG_SQUASHFS_ZSTD is not set +# CONFIG_SRAM is not set +# CONFIG_SRF04 is not set +# CONFIG_SRF08 is not set +# CONFIG_SSB is not set +# CONFIG_SSB_DRIVER_GPIO is not set +# CONFIG_SSB_HOST_SOC is not set +# CONFIG_SSB_PCMCIAHOST is not set +CONFIG_SSB_POSSIBLE=y +# CONFIG_SSB_SDIOHOST is not set +# CONFIG_SSFDC is not set +# CONFIG_SSIF_IPMI_BMC is not set +CONFIG_STACKDEPOT_MAX_FRAMES=64 +# CONFIG_STACKPROTECTOR is not set +# CONFIG_STACKPROTECTOR_PER_TASK is not set +# CONFIG_STACKPROTECTOR_STRONG is not set +# CONFIG_STACKTRACE is not set +# CONFIG_STACKTRACE_BUILD_ID is not set +CONFIG_STACKTRACE_SUPPORT=y +# CONFIG_STACK_TRACER is not set +# CONFIG_STACK_VALIDATION is not set +CONFIG_STAGING=y +# CONFIG_STAGING_MEDIA is not set +CONFIG_STANDALONE=y +# CONFIG_STATIC_KEYS_SELFTEST is not set +# CONFIG_STATIC_USERMODEHELPER is not set +# CONFIG_STE10XP is not set +# CONFIG_STK3310 is not set +# CONFIG_STK8312 is not set +# CONFIG_STK8BA50 is not set +# CONFIG_STM is not set +# CONFIG_STMMAC_ETH is not set +# CONFIG_STMMAC_PCI is not set +# CONFIG_STMMAC_PLATFORM is not set +# CONFIG_STMMAC_SELFTESTS is not set +# CONFIG_STMPE_ADC is not set +# CONFIG_STM_DUMMY is not set +# CONFIG_STM_SOURCE_CONSOLE is not set +CONFIG_STP=y +# CONFIG_STREAM_PARSER is not set +# CONFIG_STRICT_DEVMEM is not set +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_STRICT_MODULE_RWX=y +CONFIG_STRIP_ASM_SYMS=y +# CONFIG_STX104 is not set +# CONFIG_ST_UVIS25 is not set +# CONFIG_SUN4I_GPADC is not set +# CONFIG_SUN50I_DE2_BUS is not set +# CONFIG_SUN50I_ERRATUM_UNKNOWN1 is not set +# CONFIG_SUNDANCE is not set +# CONFIG_SUNGEM is not set +# CONFIG_SUNRPC is not set +# CONFIG_SUNRPC_DEBUG is not set +# CONFIG_SUNRPC_GSS is not set +# CONFIG_SUNXI_SRAM is not set +# CONFIG_SUN_PARTITION is not set +# CONFIG_SURFACE_PLATFORMS is not set +# CONFIG_SUSPEND is not set +# CONFIG_SUSPEND_SKIP_SYNC is not set +CONFIG_SWAP=y +# CONFIG_SWCONFIG is not set +# CONFIG_SWCONFIG_B53 is not set +# CONFIG_SWCONFIG_B53_MMAP_DRIVER is not set +# CONFIG_SWCONFIG_B53_SPI_DRIVER is not set +# CONFIG_SWCONFIG_B53_SRAB_DRIVER is not set +# CONFIG_SWCONFIG_LEDS is not set +# CONFIG_SWIOTLB is not set +# CONFIG_SWIOTLB_DYNAMIC is not set +# CONFIG_SW_SYNC is not set +# CONFIG_SX9310 is not set +# CONFIG_SX9324 is not set +# CONFIG_SX9360 is not set +# CONFIG_SX9500 is not set +# CONFIG_SXGBE_ETH is not set +CONFIG_SYMBOLIC_ERRNAME=y +# CONFIG_SYNC_FILE is not set +# CONFIG_SYNTH_EVENTS is not set +# CONFIG_SYNTH_EVENT_GEN_TEST is not set +CONFIG_SYN_COOKIES=y +# CONFIG_SYSCON_REBOOT_MODE is not set +CONFIG_SYSCTL=y +CONFIG_SYSFS=y +# CONFIG_SYSFS_SYSCALL is not set +# CONFIG_SYSTEMPORT is not set +# CONFIG_SYSTEM_BLACKLIST_KEYRING is not set +# CONFIG_SYSTEM_DATA_VERIFICATION is not set +# CONFIG_SYSTEM_TRUSTED_KEYRING is not set +CONFIG_SYSTEM_TRUSTED_KEYS="" +# CONFIG_SYSV68_PARTITION is not set +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +# CONFIG_SYSV_FS is not set +# CONFIG_SYS_HYPERVISOR is not set +# CONFIG_T5403 is not set +# CONFIG_TARGET_CORE is not set +# CONFIG_TASKSTATS is not set +# CONFIG_TASKS_RCU is not set +# CONFIG_TASK_XACCT is not set +# CONFIG_TC35815 is not set +# CONFIG_TCG_ATMEL is not set +# CONFIG_TCG_CRB is not set +# CONFIG_TCG_FTPM_TEE is not set +# CONFIG_TCG_INFINEON is not set +# CONFIG_TCG_NSC is not set +# CONFIG_TCG_TIS is not set +# CONFIG_TCG_TIS_I2C is not set +# CONFIG_TCG_TIS_I2C_ATMEL is not set +# CONFIG_TCG_TIS_I2C_CR50 is not set +# CONFIG_TCG_TIS_I2C_INFINEON is not set +# CONFIG_TCG_TIS_I2C_NUVOTON is not set +# CONFIG_TCG_TIS_SPI is not set +# CONFIG_TCG_TIS_ST33ZP24_I2C is not set +# CONFIG_TCG_TIS_ST33ZP24_SPI is not set +# CONFIG_TCG_TPM is not set +# CONFIG_TCG_TPM2_HMAC is not set +# CONFIG_TCG_VTPM_PROXY is not set +# CONFIG_TCG_XEN is not set +# CONFIG_TCIC is not set +# CONFIG_TCP_AO is not set +CONFIG_TCP_CONG_ADVANCED=y +# CONFIG_TCP_CONG_BBR is not set +# CONFIG_TCP_CONG_BIC is not set +# CONFIG_TCP_CONG_CDG is not set +CONFIG_TCP_CONG_CUBIC=y +# CONFIG_TCP_CONG_DCTCP is not set +# CONFIG_TCP_CONG_HSTCP is not set +# CONFIG_TCP_CONG_HTCP is not set +# CONFIG_TCP_CONG_HYBLA is not set +# CONFIG_TCP_CONG_ILLINOIS is not set +# CONFIG_TCP_CONG_LP is not set +# CONFIG_TCP_CONG_NV is not set +# CONFIG_TCP_CONG_SCALABLE is not set +# CONFIG_TCP_CONG_VEGAS is not set +# CONFIG_TCP_CONG_VENO is not set +# CONFIG_TCP_CONG_WESTWOOD is not set +# CONFIG_TCP_CONG_YEAH is not set +# CONFIG_TCP_MD5SIG is not set +# CONFIG_TCS3414 is not set +# CONFIG_TCS3472 is not set +# CONFIG_TEE is not set +# CONFIG_TEGRA_AHB is not set +# CONFIG_TEGRA_HOST1X is not set +# CONFIG_TEHUTI is not set +# CONFIG_TEHUTI_TN40 is not set +# CONFIG_TERANETICS_PHY is not set +# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set +# CONFIG_TEST_BITMAP is not set +# CONFIG_TEST_BITOPS is not set +# CONFIG_TEST_BLACKHOLE_DEV is not set +# CONFIG_TEST_BPF is not set +# CONFIG_TEST_CLOCKSOURCE_WATCHDOG is not set +# CONFIG_TEST_DEBUG_VIRTUAL is not set +# CONFIG_TEST_DHRY is not set +# CONFIG_TEST_DIV64 is not set +# CONFIG_TEST_DYNAMIC_DEBUG is not set +# CONFIG_TEST_FIRMWARE is not set +# CONFIG_TEST_FPU is not set +# CONFIG_TEST_FREE_PAGES is not set +# CONFIG_TEST_HEXDUMP is not set +# CONFIG_TEST_IDA is not set +# CONFIG_TEST_KMOD is not set +# CONFIG_TEST_KSTRTOX is not set +# CONFIG_TEST_LIST_SORT is not set +# CONFIG_TEST_LKM is not set +# CONFIG_TEST_LOCKUP is not set +# CONFIG_TEST_MAPLE_TREE is not set +# CONFIG_TEST_MEMCAT_P is not set +# CONFIG_TEST_MEMINIT is not set +# CONFIG_TEST_MIN_HEAP is not set +# CONFIG_TEST_MULDIV64 is not set +# CONFIG_TEST_OBJPOOL is not set +# CONFIG_TEST_POWER is not set +# CONFIG_TEST_PRINTF is not set +# CONFIG_TEST_REF_TRACKER is not set +# CONFIG_TEST_RHASHTABLE is not set +# CONFIG_TEST_SCANF is not set +# CONFIG_TEST_SORT is not set +# CONFIG_TEST_STATIC_KEYS is not set +# CONFIG_TEST_SYSCTL is not set +# CONFIG_TEST_UBSAN is not set +# CONFIG_TEST_UDELAY is not set +# CONFIG_TEST_UUID is not set +# CONFIG_TEST_VMALLOC is not set +# CONFIG_TEST_XARRAY is not set +CONFIG_TEXTSEARCH=y +# CONFIG_TEXTSEARCH_BM is not set +# CONFIG_TEXTSEARCH_FSM is not set +# CONFIG_TEXTSEARCH_KMP is not set +# CONFIG_THERMAL is not set +# CONFIG_THERMAL_CORE_TESTING is not set +# CONFIG_THERMAL_DEBUGFS is not set +# CONFIG_THERMAL_DEFAULT_GOV_BANG_BANG is not set +# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set +# CONFIG_THERMAL_DEFAULT_GOV_POWER_ALLOCATOR is not set +# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set +# CONFIG_THERMAL_EMULATION is not set +# CONFIG_THERMAL_GOV_BANG_BANG is not set +# CONFIG_THERMAL_GOV_FAIR_SHARE is not set +# CONFIG_THERMAL_GOV_POWER_ALLOCATOR is not set +# CONFIG_THERMAL_GOV_USER_SPACE is not set +# CONFIG_THERMAL_HWMON is not set +# CONFIG_THERMAL_MMIO is not set +# CONFIG_THERMAL_NETLINK is not set +# CONFIG_THERMAL_STATISTICS is not set +# CONFIG_THINKPAD_ACPI is not set +# CONFIG_THINKPAD_LMI is not set +# CONFIG_THRUSTMASTER_FF is not set +# CONFIG_THUMB2_KERNEL is not set +# CONFIG_THUNDER_NIC_BGX is not set +# CONFIG_THUNDER_NIC_PF is not set +# CONFIG_THUNDER_NIC_RGX is not set +# CONFIG_THUNDER_NIC_VF is not set +# CONFIG_TICK_CPU_ACCOUNTING is not set +CONFIG_TICK_ONESHOT=y +# CONFIG_TIFM_CORE is not set +# CONFIG_TIGON3 is not set +# CONFIG_TIMB_DMA is not set +CONFIG_TIMERFD=y +# CONFIG_TIMERLAT_TRACER is not set +# CONFIG_TIME_NS is not set +# CONFIG_TINYDRM_HX8357D is not set +# CONFIG_TINYDRM_ILI9163 is not set +# CONFIG_TINYDRM_ILI9225 is not set +# CONFIG_TINYDRM_ILI9341 is not set +# CONFIG_TINYDRM_ILI9486 is not set +# CONFIG_TINYDRM_MI0283QT is not set +# CONFIG_TINYDRM_REPAPER is not set +# CONFIG_TINYDRM_ST7586 is not set +# CONFIG_TINYDRM_ST7735R is not set +CONFIG_TINY_RCU=y +# CONFIG_TIPC is not set +# CONFIG_TI_ADC081C is not set +# CONFIG_TI_ADC0832 is not set +# CONFIG_TI_ADC084S021 is not set +# CONFIG_TI_ADC108S102 is not set +# CONFIG_TI_ADC12138 is not set +# CONFIG_TI_ADC128S052 is not set +# CONFIG_TI_ADC161S626 is not set +# CONFIG_TI_ADS1015 is not set +# CONFIG_TI_ADS1100 is not set +# CONFIG_TI_ADS1119 is not set +# CONFIG_TI_ADS124S08 is not set +# CONFIG_TI_ADS1298 is not set +# CONFIG_TI_ADS131E08 is not set +# CONFIG_TI_ADS7924 is not set +# CONFIG_TI_ADS7950 is not set +# CONFIG_TI_ADS8344 is not set +# CONFIG_TI_ADS8688 is not set +# CONFIG_TI_AM335X_ADC is not set +# CONFIG_TI_CPSW is not set +# CONFIG_TI_CPSW_PHY_SEL is not set +# CONFIG_TI_CPTS is not set +# CONFIG_TI_DAC082S085 is not set +# CONFIG_TI_DAC5571 is not set +# CONFIG_TI_DAC7311 is not set +# CONFIG_TI_DAC7612 is not set +# CONFIG_TI_DAVINCI_MDIO is not set +# CONFIG_TI_LMP92064 is not set +# CONFIG_TI_ST is not set +# CONFIG_TI_TLC4541 is not set +# CONFIG_TI_TMAG5273 is not set +# CONFIG_TI_TSC2046 is not set +# CONFIG_TLAN is not set +# CONFIG_TLS is not set +# CONFIG_TLS_DEVICE is not set +# CONFIG_TLS_TOE is not set +# CONFIG_TMP006 is not set +# CONFIG_TMP007 is not set +# CONFIG_TMP117 is not set +CONFIG_TMPFS=y +# CONFIG_TMPFS_INODE64 is not set +# CONFIG_TMPFS_POSIX_ACL is not set +# CONFIG_TMPFS_QUOTA is not set +CONFIG_TMPFS_XATTR=y +# CONFIG_TOPSTAR_LAPTOP is not set +# CONFIG_TORTURE_TEST is not set +# CONFIG_TOSHIBA_HAPS is not set +# CONFIG_TOSHIBA_WMI is not set +# CONFIG_TOUCHSCREEN_88PM860X is not set +# CONFIG_TOUCHSCREEN_AD7877 is not set +# CONFIG_TOUCHSCREEN_AD7879 is not set +# CONFIG_TOUCHSCREEN_AD7879_I2C is not set +# CONFIG_TOUCHSCREEN_AD7879_SPI is not set +# CONFIG_TOUCHSCREEN_ADC is not set +# CONFIG_TOUCHSCREEN_ADS7846 is not set +# CONFIG_TOUCHSCREEN_AR1021_I2C is not set +# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set +# CONFIG_TOUCHSCREEN_ATMEL_MXT_T37 is not set +# CONFIG_TOUCHSCREEN_AUO_PIXCIR is not set +# CONFIG_TOUCHSCREEN_BU21013 is not set +# CONFIG_TOUCHSCREEN_BU21029 is not set +# CONFIG_TOUCHSCREEN_CHIPONE_ICN8318 is not set +# CONFIG_TOUCHSCREEN_CHIPONE_ICN8505 is not set +# CONFIG_TOUCHSCREEN_COLIBRI_VF50 is not set +# CONFIG_TOUCHSCREEN_CY8CTMA140 is not set +# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set +# CONFIG_TOUCHSCREEN_CYTTSP5 is not set +# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set +# CONFIG_TOUCHSCREEN_CYTTSP_I2C is not set +# CONFIG_TOUCHSCREEN_CYTTSP_SPI is not set +# CONFIG_TOUCHSCREEN_DA9034 is not set +# CONFIG_TOUCHSCREEN_DA9052 is not set +# CONFIG_TOUCHSCREEN_DYNAPRO is not set +# CONFIG_TOUCHSCREEN_EDT_FT5X06 is not set +# CONFIG_TOUCHSCREEN_EETI is not set +# CONFIG_TOUCHSCREEN_EGALAX is not set +# CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set +# CONFIG_TOUCHSCREEN_EKTF2127 is not set +# CONFIG_TOUCHSCREEN_ELAN is not set +# CONFIG_TOUCHSCREEN_ELO is not set +# CONFIG_TOUCHSCREEN_EXC3000 is not set +# CONFIG_TOUCHSCREEN_FUJITSU is not set +# CONFIG_TOUCHSCREEN_GOODIX is not set +# CONFIG_TOUCHSCREEN_GOODIX_BERLIN_I2C is not set +# CONFIG_TOUCHSCREEN_GOODIX_BERLIN_SPI is not set +# CONFIG_TOUCHSCREEN_GUNZE is not set +# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set +# CONFIG_TOUCHSCREEN_HIDEEP is not set +# CONFIG_TOUCHSCREEN_HIMAX_HX83112B is not set +# CONFIG_TOUCHSCREEN_HP600 is not set +# CONFIG_TOUCHSCREEN_HP7XX is not set +# CONFIG_TOUCHSCREEN_HTCPEN is not set +# CONFIG_TOUCHSCREEN_HYCON_HY46XX is not set +# CONFIG_TOUCHSCREEN_HYNITRON_CSTXXX is not set +# CONFIG_TOUCHSCREEN_ILI210X is not set +# CONFIG_TOUCHSCREEN_ILITEK is not set +# CONFIG_TOUCHSCREEN_IMAGIS is not set +# CONFIG_TOUCHSCREEN_IMX6UL_TSC is not set +# CONFIG_TOUCHSCREEN_INEXIO is not set +# CONFIG_TOUCHSCREEN_IPAQ_MICRO is not set +# CONFIG_TOUCHSCREEN_IPROC is not set +# CONFIG_TOUCHSCREEN_IQS5XX is not set +# CONFIG_TOUCHSCREEN_IQS7211 is not set +# CONFIG_TOUCHSCREEN_LPC32XX is not set +# CONFIG_TOUCHSCREEN_MAX11801 is not set +# CONFIG_TOUCHSCREEN_MC13783 is not set +# CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set +# CONFIG_TOUCHSCREEN_MIGOR is not set +# CONFIG_TOUCHSCREEN_MK712 is not set +# CONFIG_TOUCHSCREEN_MMS114 is not set +# CONFIG_TOUCHSCREEN_MSG2638 is not set +# CONFIG_TOUCHSCREEN_MTOUCH is not set +# CONFIG_TOUCHSCREEN_MX25 is not set +# CONFIG_TOUCHSCREEN_MXS_LRADC is not set +# CONFIG_TOUCHSCREEN_NOVATEK_NVT_TS is not set +# CONFIG_TOUCHSCREEN_PCAP is not set +# CONFIG_TOUCHSCREEN_PENMOUNT is not set +# CONFIG_TOUCHSCREEN_PIXCIR is not set +# CONFIG_TOUCHSCREEN_RASPBERRYPI_FW is not set +# CONFIG_TOUCHSCREEN_RM_TS is not set +# CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set +# CONFIG_TOUCHSCREEN_S6SY761 is not set +# CONFIG_TOUCHSCREEN_SILEAD is not set +# CONFIG_TOUCHSCREEN_SIS_I2C is not set +# CONFIG_TOUCHSCREEN_ST1232 is not set +# CONFIG_TOUCHSCREEN_STMFTS is not set +# CONFIG_TOUCHSCREEN_STMPE is not set +# CONFIG_TOUCHSCREEN_SUN4I is not set +# CONFIG_TOUCHSCREEN_SUR40 is not set +# CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set +# CONFIG_TOUCHSCREEN_SX8654 is not set +# CONFIG_TOUCHSCREEN_TI_AM335X_TSC is not set +# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set +# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set +# CONFIG_TOUCHSCREEN_TOUCHWIN is not set +# CONFIG_TOUCHSCREEN_TPS6507X is not set +# CONFIG_TOUCHSCREEN_TS4800 is not set +# CONFIG_TOUCHSCREEN_TSC2004 is not set +# CONFIG_TOUCHSCREEN_TSC2005 is not set +# CONFIG_TOUCHSCREEN_TSC2007 is not set +# CONFIG_TOUCHSCREEN_TSC2007_IIO is not set +# CONFIG_TOUCHSCREEN_TSC200X_CORE is not set +# CONFIG_TOUCHSCREEN_TSC_SERIO is not set +# CONFIG_TOUCHSCREEN_USB_3M is not set +# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set +# CONFIG_TOUCHSCREEN_USB_DMC_TSC10 is not set +# CONFIG_TOUCHSCREEN_USB_E2I is not set +# CONFIG_TOUCHSCREEN_USB_EASYTOUCH is not set +# CONFIG_TOUCHSCREEN_USB_EGALAX is not set +# CONFIG_TOUCHSCREEN_USB_ELO is not set +# CONFIG_TOUCHSCREEN_USB_ETT_TC45USB is not set +# CONFIG_TOUCHSCREEN_USB_ETURBO is not set +# CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH is not set +# CONFIG_TOUCHSCREEN_USB_GOTOP is not set +# CONFIG_TOUCHSCREEN_USB_GUNZE is not set +# CONFIG_TOUCHSCREEN_USB_IDEALTEK is not set +# CONFIG_TOUCHSCREEN_USB_IRTOUCH is not set +# CONFIG_TOUCHSCREEN_USB_ITM is not set +# CONFIG_TOUCHSCREEN_USB_JASTEC is not set +# CONFIG_TOUCHSCREEN_USB_NEXIO is not set +# CONFIG_TOUCHSCREEN_USB_PANJIT is not set +# CONFIG_TOUCHSCREEN_USB_ZYTRONIC is not set +# CONFIG_TOUCHSCREEN_WACOM_I2C is not set +# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set +# CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set +# CONFIG_TOUCHSCREEN_WM831X is not set +# CONFIG_TOUCHSCREEN_WM9705 is not set +# CONFIG_TOUCHSCREEN_WM9712 is not set +# CONFIG_TOUCHSCREEN_WM9713 is not set +# CONFIG_TOUCHSCREEN_WM97XX is not set +# CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE is not set +# CONFIG_TOUCHSCREEN_ZET6223 is not set +# CONFIG_TOUCHSCREEN_ZFORCE is not set +# CONFIG_TOUCHSCREEN_ZINITIX is not set +# CONFIG_TPL0102 is not set +# CONFIG_TPS6105X is not set +# CONFIG_TPS65010 is not set +# CONFIG_TPS6507X is not set +# CONFIG_TRACEPOINT_BENCHMARK is not set +# CONFIG_TRACER_SNAPSHOT is not set +# CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP is not set +# CONFIG_TRACE_BRANCH_PROFILING is not set +# CONFIG_TRACE_EVAL_MAP_FILE is not set +# CONFIG_TRACE_EVENT_INJECT is not set +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +# CONFIG_TRACE_MMIO_ACCESS is not set +CONFIG_TRACING_SUPPORT=y +CONFIG_TRAD_SIGNALS=y +# CONFIG_TRANSPARENT_HUGEPAGE is not set +# CONFIG_TREE_RCU is not set +# CONFIG_TRIM_UNUSED_KSYMS is not set +# CONFIG_TRUSTED_FOUNDATIONS is not set +# CONFIG_TRUSTED_KEYS is not set +# CONFIG_TRUSTED_KEYS_CAAM is not set +# CONFIG_TRUSTED_KEYS_DCP is not set +# CONFIG_TRUSTED_KEYS_TEE is not set +# CONFIG_TRUSTED_KEYS_TPM is not set +# CONFIG_TSL2583 is not set +# CONFIG_TSL2591 is not set +# CONFIG_TSL2772 is not set +# CONFIG_TSL4531 is not set +# CONFIG_TSNEP is not set +# CONFIG_TSYS01 is not set +# CONFIG_TSYS02D is not set +# CONFIG_TTPCI_EEPROM is not set +CONFIG_TTY=y +# CONFIG_TTY_PRINTK is not set +# CONFIG_TUN is not set +# CONFIG_TUN_VNET_CROSS_LE is not set +# CONFIG_TWL4030_CORE is not set +# CONFIG_TWL4030_MADC is not set +# CONFIG_TWL6030_GPADC is not set +# CONFIG_TWL6040_CORE is not set +# CONFIG_TXGBE is not set +# CONFIG_TYPEC is not set +# CONFIG_TYPEC_DP_ALTMODE is not set +# CONFIG_TYPEC_TCPM is not set +# CONFIG_TYPEC_UCSI is not set +# CONFIG_TYPHOON is not set +# CONFIG_UACCE is not set +# CONFIG_UACCESS_WITH_MEMCPY is not set +# CONFIG_UBIFS_ATIME_SUPPORT is not set +# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set +# CONFIG_UBIFS_FS_AUTHENTICATION is not set +CONFIG_UBIFS_FS_LZO=y +# CONFIG_UBIFS_FS_SECURITY is not set +CONFIG_UBIFS_FS_XATTR=y +CONFIG_UBIFS_FS_ZLIB=y +CONFIG_UBIFS_FS_ZSTD=y +# CONFIG_UBSAN is not set +CONFIG_UBSAN_ALIGNMENT=y +CONFIG_UBSAN_BOOL=y +# CONFIG_UBSAN_DIV_ZERO is not set +CONFIG_UBSAN_ENUM=y +CONFIG_UBSAN_SHIFT=y +# CONFIG_UBSAN_UNREACHABLE is not set +# CONFIG_UDF_FS is not set +# CONFIG_UDMABUF is not set +CONFIG_UEVENT_HELPER=y +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +# CONFIG_UFS_FS is not set +# CONFIG_UHID is not set +CONFIG_UID16=y +# CONFIG_UIMAGE_FIT_BLK is not set +# CONFIG_UIO is not set +# CONFIG_ULTRA is not set +# CONFIG_ULTRIX_PARTITION is not set +# CONFIG_UNICODE is not set +CONFIG_UNIX=y +CONFIG_UNIX98_PTYS=y +# CONFIG_UNIXWARE_DISKLABEL is not set +# CONFIG_UNIX_DIAG is not set +# CONFIG_UNWINDER_FRAME_POINTER is not set +# CONFIG_UPROBES is not set +# CONFIG_UPROBE_EVENTS is not set +# CONFIG_US5182D is not set +# CONFIG_USB is not set +# CONFIG_USB4 is not set +# CONFIG_USBIP_CORE is not set +CONFIG_USBIP_VHCI_HC_PORTS=8 +CONFIG_USBIP_VHCI_NR_HCS=1 +# CONFIG_USBIP_VUDC is not set +# CONFIG_USBPCWATCHDOG is not set +# CONFIG_USB_ACM is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_AIRSPY is not set +CONFIG_USB_ALI_M5632=y +# CONFIG_USB_AMD5536UDC is not set +CONFIG_USB_AN2720=y +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set +# CONFIG_USB_APPLEDISPLAY is not set +CONFIG_USB_ARCH_HAS_HCD=y +CONFIG_USB_ARMLINUX=y +# CONFIG_USB_ATM is not set +# CONFIG_USB_AUDIO is not set +CONFIG_USB_AUTOSUSPEND_DELAY=2 +# CONFIG_USB_BDC_UDC is not set +CONFIG_USB_BELKIN=y +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_CATC is not set +# CONFIG_USB_CDC_COMPOSITE is not set +# CONFIG_USB_CDNS3 is not set +# CONFIG_USB_CDNS3_IMX is not set +# CONFIG_USB_CDNS3_PCI_WRAP is not set +# CONFIG_USB_CDNSP_PCI is not set +# CONFIG_USB_CDNS_SUPPORT is not set +# CONFIG_USB_CHAOSKEY is not set +# CONFIG_USB_CHIPIDEA is not set +# CONFIG_USB_CHIPIDEA_GENERIC is not set +# CONFIG_USB_CHIPIDEA_IMX is not set +# CONFIG_USB_CHIPIDEA_MSM is not set +# CONFIG_USB_CHIPIDEA_NPCM is not set +# CONFIG_USB_CHIPIDEA_PCI is not set +# CONFIG_USB_CHIPIDEA_TEGRA is not set +# CONFIG_USB_CONFIGFS is not set +# CONFIG_USB_CONN_GPIO is not set +# CONFIG_USB_CXACRU is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +CONFIG_USB_DEFAULT_AUTHORIZATION_MODE=1 +CONFIG_USB_DEFAULT_PERSIST=y +# CONFIG_USB_DSBR is not set +# CONFIG_USB_DUMMY_HCD is not set +# CONFIG_USB_DWC2 is not set +# CONFIG_USB_DWC2_DEBUG is not set +# CONFIG_USB_DWC2_DUAL_ROLE is not set +# CONFIG_USB_DWC2_HOST is not set +# CONFIG_USB_DWC2_PERIPHERAL is not set +# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set +# CONFIG_USB_DWC3 is not set +# CONFIG_USB_DWC3_EXYNOS is not set +# CONFIG_USB_DWC3_HAPS is not set +# CONFIG_USB_DWC3_KEYSTONE is not set +# CONFIG_USB_DWC3_OCTEON is not set +# CONFIG_USB_DWC3_OF_SIMPLE is not set +# CONFIG_USB_DWC3_PCI is not set +# CONFIG_USB_DWC3_QCOM is not set +# CONFIG_USB_DWC3_ULPI is not set +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_EG20T is not set +# CONFIG_USB_EHCI_FSL is not set +# CONFIG_USB_EHCI_HCD is not set +# CONFIG_USB_EHCI_HCD_AT91 is not set +# CONFIG_USB_EHCI_HCD_OMAP is not set +# CONFIG_USB_EHCI_HCD_PPC_OF is not set +# CONFIG_USB_EHCI_MV is not set +CONFIG_USB_EHCI_ROOT_HUB_TT=y +CONFIG_USB_EHCI_TT_NEWSCHED=y +# CONFIG_USB_EHSET_TEST_FIXTURE is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EPSON2888 is not set +# CONFIG_USB_ETH is not set +# CONFIG_USB_EZUSB_FX2 is not set +# CONFIG_USB_FEW_INIT_RETRIES is not set +# CONFIG_USB_FOTG210_HCD is not set +# CONFIG_USB_FOTG210_UDC is not set +# CONFIG_USB_FSL_USB2 is not set +# CONFIG_USB_FUNCTIONFS is not set +# CONFIG_USB_FUSB300 is not set +# CONFIG_USB_GADGET is not set +# CONFIG_USB_GADGETFS is not set +# CONFIG_USB_GADGET_DEBUG is not set +# CONFIG_USB_GADGET_DEBUG_FILES is not set +# CONFIG_USB_GADGET_DEBUG_FS is not set +CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2 +CONFIG_USB_GADGET_VBUS_DRAW=2 +# CONFIG_USB_GADGET_XILINX is not set +# CONFIG_USB_GL860 is not set +# CONFIG_USB_GOKU is not set +# CONFIG_USB_GPIO_VBUS is not set +# CONFIG_USB_GR_UDC is not set +# CONFIG_USB_GSPCA is not set +# CONFIG_USB_GSPCA_BENQ is not set +# CONFIG_USB_GSPCA_CONEX is not set +# CONFIG_USB_GSPCA_CPIA1 is not set +# CONFIG_USB_GSPCA_DTCS033 is not set +# CONFIG_USB_GSPCA_ETOMS is not set +# CONFIG_USB_GSPCA_FINEPIX is not set +# CONFIG_USB_GSPCA_JEILINJ is not set +# CONFIG_USB_GSPCA_JL2005BCD is not set +# CONFIG_USB_GSPCA_KINECT is not set +# CONFIG_USB_GSPCA_KONICA is not set +# CONFIG_USB_GSPCA_MARS is not set +# CONFIG_USB_GSPCA_MR97310A is not set +# CONFIG_USB_GSPCA_NW80X is not set +# CONFIG_USB_GSPCA_OV519 is not set +# CONFIG_USB_GSPCA_OV534 is not set +# CONFIG_USB_GSPCA_OV534_9 is not set +# CONFIG_USB_GSPCA_PAC207 is not set +# CONFIG_USB_GSPCA_PAC7302 is not set +# CONFIG_USB_GSPCA_PAC7311 is not set +# CONFIG_USB_GSPCA_SE401 is not set +# CONFIG_USB_GSPCA_SN9C2028 is not set +# CONFIG_USB_GSPCA_SN9C20X is not set +# CONFIG_USB_GSPCA_SONIXB is not set +# CONFIG_USB_GSPCA_SONIXJ is not set +# CONFIG_USB_GSPCA_SPCA1528 is not set +# CONFIG_USB_GSPCA_SPCA500 is not set +# CONFIG_USB_GSPCA_SPCA501 is not set +# CONFIG_USB_GSPCA_SPCA505 is not set +# CONFIG_USB_GSPCA_SPCA506 is not set +# CONFIG_USB_GSPCA_SPCA508 is not set +# CONFIG_USB_GSPCA_SPCA561 is not set +# CONFIG_USB_GSPCA_SQ905 is not set +# CONFIG_USB_GSPCA_SQ905C is not set +# CONFIG_USB_GSPCA_SQ930X is not set +# CONFIG_USB_GSPCA_STK014 is not set +# CONFIG_USB_GSPCA_STK1135 is not set +# CONFIG_USB_GSPCA_STV0680 is not set +# CONFIG_USB_GSPCA_SUNPLUS is not set +# CONFIG_USB_GSPCA_T613 is not set +# CONFIG_USB_GSPCA_TOPRO is not set +# CONFIG_USB_GSPCA_TOUPTEK is not set +# CONFIG_USB_GSPCA_TV8532 is not set +# CONFIG_USB_GSPCA_VC032X is not set +# CONFIG_USB_GSPCA_VICAM is not set +# CONFIG_USB_GSPCA_XIRLINK_CIT is not set +# CONFIG_USB_GSPCA_ZC3XX is not set +# CONFIG_USB_G_ACM_MS is not set +# CONFIG_USB_G_DBGP is not set +# CONFIG_USB_G_HID is not set +# CONFIG_USB_G_MULTI is not set +# CONFIG_USB_G_NCM is not set +# CONFIG_USB_G_NOKIA is not set +# CONFIG_USB_G_PRINTER is not set +# CONFIG_USB_G_SERIAL is not set +# CONFIG_USB_G_WEBCAM is not set +# CONFIG_USB_HACKRF is not set +# CONFIG_USB_HCD_TEST_MODE is not set +# CONFIG_USB_HID is not set +# CONFIG_USB_HIDDEV is not set +# CONFIG_USB_HSIC_USB3503 is not set +# CONFIG_USB_HSIC_USB4604 is not set +# CONFIG_USB_HSO is not set +# CONFIG_USB_HUB_USB251XB is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_IPHETH is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_ISP1301 is not set +# CONFIG_USB_ISP1362_HCD is not set +# CONFIG_USB_ISP1760 is not set +# CONFIG_USB_ISP1760_HCD is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_KBD is not set +# CONFIG_USB_KC2190 is not set +# CONFIG_USB_LAN78XX is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_LEDS_TRIGGER_USBPORT is not set +# CONFIG_USB_LED_TRIG is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LGM_PHY is not set +# CONFIG_USB_LINK_LAYER_TEST is not set +# CONFIG_USB_M5602 is not set +# CONFIG_USB_M66592 is not set +# CONFIG_USB_MASS_STORAGE is not set +# CONFIG_USB_MAX3420_UDC is not set +# CONFIG_USB_MAX3421_HCD is not set +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_MOUSE is not set +# CONFIG_USB_MSI2500 is not set +# CONFIG_USB_MTU3 is not set +# CONFIG_USB_MUSB_GADGET is not set +# CONFIG_USB_MUSB_HDRC is not set +# CONFIG_USB_MUSB_HOST is not set +# CONFIG_USB_MV_U3D is not set +# CONFIG_USB_MV_UDC is not set +# CONFIG_USB_MXS_PHY is not set +# CONFIG_USB_NET2272 is not set +# CONFIG_USB_NET2280 is not set +# CONFIG_USB_NET_AQC111 is not set +# CONFIG_USB_NET_AX88179_178A is not set +# CONFIG_USB_NET_AX8817X is not set +# CONFIG_USB_NET_CDCETHER is not set +# CONFIG_USB_NET_CDC_EEM is not set +# CONFIG_USB_NET_CDC_MBIM is not set +# CONFIG_USB_NET_CDC_NCM is not set +# CONFIG_USB_NET_CDC_SUBSET is not set +# CONFIG_USB_NET_CH9200 is not set +# CONFIG_USB_NET_CX82310_ETH is not set +# CONFIG_USB_NET_DM9601 is not set +CONFIG_USB_NET_DRIVERS=y +# CONFIG_USB_NET_GL620A is not set +# CONFIG_USB_NET_HUAWEI_CDC_NCM is not set +# CONFIG_USB_NET_INT51X1 is not set +# CONFIG_USB_NET_KALMIA is not set +# CONFIG_USB_NET_MCS7830 is not set +# CONFIG_USB_NET_NET1080 is not set +# CONFIG_USB_NET_PLUSB is not set +# CONFIG_USB_NET_QMI_WWAN is not set +# CONFIG_USB_NET_RNDIS_HOST is not set +# CONFIG_USB_NET_SMSC75XX is not set +# CONFIG_USB_NET_SMSC95XX is not set +# CONFIG_USB_NET_SR9700 is not set +# CONFIG_USB_NET_SR9800 is not set +# CONFIG_USB_NET_ZAURUS is not set +# CONFIG_USB_OHCI_HCD is not set +# CONFIG_USB_OHCI_HCD_PCI is not set +# CONFIG_USB_OHCI_HCD_PPC_OF is not set +# CONFIG_USB_OHCI_HCD_PPC_OF_BE is not set +# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set +# CONFIG_USB_OHCI_HCD_SSB is not set +CONFIG_USB_OHCI_LITTLE_ENDIAN=y +# CONFIG_USB_ONBOARD_DEV is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_OTG_DISABLE_EXTERNAL_HUB is not set +# CONFIG_USB_OTG_FSM is not set +# CONFIG_USB_OTG_PRODUCTLIST is not set +# CONFIG_USB_OXU210HP_HCD is not set +# CONFIG_USB_PCI is not set +# CONFIG_USB_PCI_AMD is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_PHY is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_PWC_INPUT_EVDEV is not set +# CONFIG_USB_PXA27X is not set +# CONFIG_USB_QCOM_EUD is not set +# CONFIG_USB_R8A66597 is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_RAW_GADGET is not set +# CONFIG_USB_RENESAS_USBHS is not set +# CONFIG_USB_ROLES_INTEL_XHCI is not set +# CONFIG_USB_ROLE_SWITCH is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_RTL8152 is not set +# CONFIG_USB_RTL8153_ECM is not set +# CONFIG_USB_S2255 is not set +# CONFIG_USB_SERIAL is not set +# CONFIG_USB_SERIAL_AIRCABLE is not set +# CONFIG_USB_SERIAL_ARK3116 is not set +# CONFIG_USB_SERIAL_BELKIN is not set +# CONFIG_USB_SERIAL_CH341 is not set +# CONFIG_USB_SERIAL_CH348 is not set +# CONFIG_USB_SERIAL_CP210X is not set +# CONFIG_USB_SERIAL_CYBERJACK is not set +# CONFIG_USB_SERIAL_CYPRESS_M8 is not set +# CONFIG_USB_SERIAL_DEBUG is not set +# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set +# CONFIG_USB_SERIAL_EDGEPORT is not set +# CONFIG_USB_SERIAL_EDGEPORT_TI is not set +# CONFIG_USB_SERIAL_EMPEG is not set +# CONFIG_USB_SERIAL_F81232 is not set +# CONFIG_USB_SERIAL_F8153X is not set +# CONFIG_USB_SERIAL_FTDI_SIO is not set +# CONFIG_USB_SERIAL_GARMIN is not set +CONFIG_USB_SERIAL_GENERIC=y +# CONFIG_USB_SERIAL_IPAQ is not set +# CONFIG_USB_SERIAL_IPW is not set +# CONFIG_USB_SERIAL_IR is not set +# CONFIG_USB_SERIAL_IUU is not set +# CONFIG_USB_SERIAL_KEYSPAN is not set +# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set +# CONFIG_USB_SERIAL_KLSI is not set +# CONFIG_USB_SERIAL_KOBIL_SCT is not set +# CONFIG_USB_SERIAL_MCT_U232 is not set +# CONFIG_USB_SERIAL_METRO is not set +# CONFIG_USB_SERIAL_MOS7715_PARPORT is not set +# CONFIG_USB_SERIAL_MOS7720 is not set +# CONFIG_USB_SERIAL_MOS7840 is not set +# CONFIG_USB_SERIAL_MXUPORT is not set +# CONFIG_USB_SERIAL_NAVMAN is not set +# CONFIG_USB_SERIAL_OMNINET is not set +# CONFIG_USB_SERIAL_OPTICON is not set +# CONFIG_USB_SERIAL_OPTION is not set +# CONFIG_USB_SERIAL_OTI6858 is not set +# CONFIG_USB_SERIAL_PL2303 is not set +# CONFIG_USB_SERIAL_QCAUX is not set +# CONFIG_USB_SERIAL_QT2 is not set +# CONFIG_USB_SERIAL_QUALCOMM is not set +# CONFIG_USB_SERIAL_SAFE is not set +CONFIG_USB_SERIAL_SAFE_PADDED=y +# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set +# CONFIG_USB_SERIAL_SIMPLE is not set +# CONFIG_USB_SERIAL_SPCP8X5 is not set +# CONFIG_USB_SERIAL_SSU100 is not set +# CONFIG_USB_SERIAL_SYMBOL is not set +# CONFIG_USB_SERIAL_TI is not set +# CONFIG_USB_SERIAL_UPD78F0730 is not set +# CONFIG_USB_SERIAL_VISOR is not set +# CONFIG_USB_SERIAL_WHITEHEAT is not set +# CONFIG_USB_SERIAL_WISHBONE is not set +# CONFIG_USB_SERIAL_XR is not set +# CONFIG_USB_SERIAL_XSENS_MT is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_SIERRA_NET is not set +# CONFIG_USB_SISUSBVGA is not set +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_SNP_UDC_PLAT is not set +# CONFIG_USB_SPEEDTOUCH is not set +# CONFIG_USB_STORAGE is not set +# CONFIG_USB_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_ENE_UB6250 is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_REALTEK is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STV06XX is not set +# CONFIG_USB_SUPPORT is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_TMC is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_UAS is not set +# CONFIG_USB_UEAGLEATM is not set +# CONFIG_USB_ULPI is not set +# CONFIG_USB_ULPI_BUS is not set +# CONFIG_USB_USBNET is not set +# CONFIG_USB_USS720 is not set +# CONFIG_USB_VIDEO_CLASS is not set +CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y +# CONFIG_USB_VL600 is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_XEN_HCD is not set +# CONFIG_USB_XHCI_DBGCAP is not set +# CONFIG_USB_XHCI_HCD is not set +# CONFIG_USB_XHCI_MVEBU is not set +# CONFIG_USB_XHCI_PCI_RENESAS is not set +# CONFIG_USB_XUSBATM is not set +# CONFIG_USB_YUREX is not set +# CONFIG_USB_ZERO is not set +# CONFIG_USELIB is not set +# CONFIG_USERFAULTFD is not set +# CONFIG_USERIO is not set +# CONFIG_USER_DECRYPTED_DATA is not set +# CONFIG_USER_EVENTS is not set +# CONFIG_USE_OF is not set +# CONFIG_UTS_NS is not set +# CONFIG_U_SERIAL_CONSOLE is not set +# CONFIG_V4L_MEM2MEM_DRIVERS is not set +# CONFIG_V4L_PLATFORM_DRIVERS is not set +# CONFIG_V4L_TEST_DRIVERS is not set +# CONFIG_VALIDATE_FS_PARSER is not set +# CONFIG_VBOXGUEST is not set +# CONFIG_VCAP is not set +# CONFIG_VCNL3020 is not set +# CONFIG_VCNL4000 is not set +# CONFIG_VCNL4035 is not set +# CONFIG_VCPU_STALL_DETECTOR is not set +# CONFIG_VDPA is not set +CONFIG_VDSO=y +# CONFIG_VEML6030 is not set +# CONFIG_VEML6040 is not set +# CONFIG_VEML6070 is not set +# CONFIG_VEML6075 is not set +# CONFIG_VETH is not set +# CONFIG_VEXPRESS_CONFIG is not set +# CONFIG_VF610_ADC is not set +# CONFIG_VF610_DAC is not set +# CONFIG_VFAT_FS is not set +# CONFIG_VFIO is not set +# CONFIG_VFIO_DEBUGFS is not set +# CONFIG_VFIO_FSL_MC is not set +# CONFIG_VFIO_PLATFORM is not set +# CONFIG_VGASTATE is not set +# CONFIG_VGA_ARB is not set +# CONFIG_VGA_CONSOLE is not set +# CONFIG_VGA_SWITCHEROO is not set +# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set +CONFIG_VHOST_ENABLE_FORK_OWNER_CONTROL=y +CONFIG_VHOST_MENU=y +# CONFIG_VHOST_NET is not set +# CONFIG_VHOST_VSOCK is not set +# CONFIG_VIA_RHINE is not set +# CONFIG_VIA_VELOCITY is not set +# CONFIG_VIDEO_AD5820 is not set +# CONFIG_VIDEO_ADP1653 is not set +# CONFIG_VIDEO_ADV7170 is not set +# CONFIG_VIDEO_ADV7175 is not set +# CONFIG_VIDEO_ADV7180 is not set +# CONFIG_VIDEO_ADV7183 is not set +# CONFIG_VIDEO_ADV7343 is not set +# CONFIG_VIDEO_ADV7393 is not set +# CONFIG_VIDEO_ADV748X is not set +# CONFIG_VIDEO_ADV7511 is not set +# CONFIG_VIDEO_ADV7604 is not set +# CONFIG_VIDEO_ADV7842 is not set +# CONFIG_VIDEO_ADV_DEBUG is not set +# CONFIG_VIDEO_AK7375 is not set +# CONFIG_VIDEO_AK881X is not set +# CONFIG_VIDEO_ALVIUM_CSI2 is not set +# CONFIG_VIDEO_AM437X_VPFE is not set +# CONFIG_VIDEO_AR0521 is not set +# CONFIG_VIDEO_ASPEED is not set +# CONFIG_VIDEO_ATMEL_ISC is not set +# CONFIG_VIDEO_ATMEL_ISI is not set +# CONFIG_VIDEO_AU0828 is not set +# CONFIG_VIDEO_BCM2835 is not set +# CONFIG_VIDEO_BCM2835_UNICAM is not set +# CONFIG_VIDEO_BT819 is not set +# CONFIG_VIDEO_BT848 is not set +# CONFIG_VIDEO_BT856 is not set +# CONFIG_VIDEO_BT866 is not set +# CONFIG_VIDEO_CADENCE_CSI2RX is not set +# CONFIG_VIDEO_CADENCE_CSI2TX is not set +# CONFIG_VIDEO_CAFE_CCIC is not set +# CONFIG_VIDEO_CAMERA_SENSOR is not set +# CONFIG_VIDEO_CCS is not set +# CONFIG_VIDEO_COBALT is not set +# CONFIG_VIDEO_CODA is not set +# CONFIG_VIDEO_CS3308 is not set +# CONFIG_VIDEO_CS5345 is not set +# CONFIG_VIDEO_CS53L32A is not set +# CONFIG_VIDEO_CX231XX is not set +# CONFIG_VIDEO_CX2341X is not set +# CONFIG_VIDEO_CX25821 is not set +# CONFIG_VIDEO_CX25840 is not set +# CONFIG_VIDEO_CX88 is not set +# CONFIG_VIDEO_DEV is not set +# CONFIG_VIDEO_DS90UB913 is not set +# CONFIG_VIDEO_DS90UB953 is not set +# CONFIG_VIDEO_DS90UB960 is not set +# CONFIG_VIDEO_DT3155 is not set +# CONFIG_VIDEO_DW9714 is not set +# CONFIG_VIDEO_DW9719 is not set +# CONFIG_VIDEO_DW9768 is not set +# CONFIG_VIDEO_DW9807_VCM is not set +# CONFIG_VIDEO_EM28XX is not set +# CONFIG_VIDEO_ET8EK8 is not set +# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set +# CONFIG_VIDEO_GC0308 is not set +# CONFIG_VIDEO_GC05A2 is not set +# CONFIG_VIDEO_GC08A3 is not set +# CONFIG_VIDEO_GC2145 is not set +# CONFIG_VIDEO_GO7007 is not set +# CONFIG_VIDEO_GS1662 is not set +# CONFIG_VIDEO_HDPVR is not set +# CONFIG_VIDEO_HEXIUM_GEMINI is not set +# CONFIG_VIDEO_HEXIUM_ORION is not set +# CONFIG_VIDEO_HI556 is not set +# CONFIG_VIDEO_HI846 is not set +# CONFIG_VIDEO_HI847 is not set +# CONFIG_VIDEO_I2C is not set +# CONFIG_VIDEO_IMX208 is not set +# CONFIG_VIDEO_IMX214 is not set +# CONFIG_VIDEO_IMX219 is not set +# CONFIG_VIDEO_IMX258 is not set +# CONFIG_VIDEO_IMX274 is not set +# CONFIG_VIDEO_IMX283 is not set +# CONFIG_VIDEO_IMX290 is not set +# CONFIG_VIDEO_IMX296 is not set +# CONFIG_VIDEO_IMX319 is not set +# CONFIG_VIDEO_IMX334 is not set +# CONFIG_VIDEO_IMX335 is not set +# CONFIG_VIDEO_IMX355 is not set +# CONFIG_VIDEO_IMX412 is not set +# CONFIG_VIDEO_IMX415 is not set +# CONFIG_VIDEO_IMX500 is not set +# CONFIG_VIDEO_IMX7_CSI is not set +# CONFIG_VIDEO_IMX8MQ_MIPI_CSI2 is not set +# CONFIG_VIDEO_IMX8_ISI is not set +# CONFIG_VIDEO_IMX8_JPEG is not set +# CONFIG_VIDEO_IMX_MIPI_CSIS is not set +# CONFIG_VIDEO_IMX_PXP is not set +# CONFIG_VIDEO_INTEL_IPU6 is not set +# CONFIG_VIDEO_IPU3_CIO2 is not set +# CONFIG_VIDEO_IR_I2C is not set +# CONFIG_VIDEO_ISL7998X is not set +# CONFIG_VIDEO_IVTV is not set +# CONFIG_VIDEO_KS0127 is not set +# CONFIG_VIDEO_LM3560 is not set +# CONFIG_VIDEO_LM3646 is not set +# CONFIG_VIDEO_M52790 is not set +# CONFIG_VIDEO_MAX9286 is not set +# CONFIG_VIDEO_MAX96714 is not set +# CONFIG_VIDEO_MAX96717 is not set +# CONFIG_VIDEO_MEM2MEM_DEINTERLACE is not set +# CONFIG_VIDEO_MGB4 is not set +# CONFIG_VIDEO_ML86V7667 is not set +# CONFIG_VIDEO_MSP3400 is not set +# CONFIG_VIDEO_MT9M001 is not set +# CONFIG_VIDEO_MT9M111 is not set +# CONFIG_VIDEO_MT9M114 is not set +# CONFIG_VIDEO_MT9P031 is not set +# CONFIG_VIDEO_MT9T112 is not set +# CONFIG_VIDEO_MT9V011 is not set +# CONFIG_VIDEO_MT9V032 is not set +# CONFIG_VIDEO_MT9V111 is not set +# CONFIG_VIDEO_MUX is not set +# CONFIG_VIDEO_MXB is not set +# CONFIG_VIDEO_OG01A1B is not set +# CONFIG_VIDEO_OMAP2_VOUT is not set +# CONFIG_VIDEO_OV01A10 is not set +# CONFIG_VIDEO_OV02A10 is not set +# CONFIG_VIDEO_OV08D10 is not set +# CONFIG_VIDEO_OV08X40 is not set +# CONFIG_VIDEO_OV13858 is not set +# CONFIG_VIDEO_OV13B10 is not set +# CONFIG_VIDEO_OV2311 is not set +# CONFIG_VIDEO_OV2640 is not set +# CONFIG_VIDEO_OV2659 is not set +# CONFIG_VIDEO_OV2680 is not set +# CONFIG_VIDEO_OV2685 is not set +# CONFIG_VIDEO_OV2740 is not set +# CONFIG_VIDEO_OV4689 is not set +# CONFIG_VIDEO_OV5640 is not set +# CONFIG_VIDEO_OV5645 is not set +# CONFIG_VIDEO_OV5647 is not set +# CONFIG_VIDEO_OV5648 is not set +# CONFIG_VIDEO_OV5670 is not set +# CONFIG_VIDEO_OV5675 is not set +# CONFIG_VIDEO_OV5693 is not set +# CONFIG_VIDEO_OV5695 is not set +# CONFIG_VIDEO_OV64A40 is not set +# CONFIG_VIDEO_OV6650 is not set +# CONFIG_VIDEO_OV7251 is not set +# CONFIG_VIDEO_OV7640 is not set +# CONFIG_VIDEO_OV7670 is not set +# CONFIG_VIDEO_OV772X is not set +# CONFIG_VIDEO_OV7740 is not set +# CONFIG_VIDEO_OV8856 is not set +# CONFIG_VIDEO_OV8858 is not set +# CONFIG_VIDEO_OV8865 is not set +# CONFIG_VIDEO_OV9282 is not set +# CONFIG_VIDEO_OV9640 is not set +# CONFIG_VIDEO_OV9650 is not set +# CONFIG_VIDEO_OV9734 is not set +# CONFIG_VIDEO_PVRUSB2 is not set +# CONFIG_VIDEO_RASPBERRYPI_PISP_BE is not set +# CONFIG_VIDEO_RCAR_CSI2 is not set +# CONFIG_VIDEO_RCAR_ISP is not set +# CONFIG_VIDEO_RCAR_VIN is not set +# CONFIG_VIDEO_RDACM20 is not set +# CONFIG_VIDEO_RDACM21 is not set +# CONFIG_VIDEO_RJ54N1 is not set +# CONFIG_VIDEO_ROCKCHIP_ISP1 is not set +# CONFIG_VIDEO_S5C73M3 is not set +# CONFIG_VIDEO_S5K5BAF is not set +# CONFIG_VIDEO_S5K6A3 is not set +# CONFIG_VIDEO_SAA6588 is not set +# CONFIG_VIDEO_SAA6752HS is not set +# CONFIG_VIDEO_SAA7110 is not set +# CONFIG_VIDEO_SAA711X is not set +# CONFIG_VIDEO_SAA7127 is not set +# CONFIG_VIDEO_SAA7134 is not set +# CONFIG_VIDEO_SAA7164 is not set +# CONFIG_VIDEO_SAA717X is not set +# CONFIG_VIDEO_SAA7185 is not set +# CONFIG_VIDEO_SOLO6X10 is not set +# CONFIG_VIDEO_SONY_BTF_MPX is not set +# CONFIG_VIDEO_STK1160 is not set +# CONFIG_VIDEO_ST_MIPID02 is not set +# CONFIG_VIDEO_SUN4I_CSI is not set +# CONFIG_VIDEO_SUN6I_CSI is not set +# CONFIG_VIDEO_SUN8I_A83T_MIPI_CSI2 is not set +# CONFIG_VIDEO_TC358743 is not set +# CONFIG_VIDEO_TC358746 is not set +# CONFIG_VIDEO_TDA1997X is not set +# CONFIG_VIDEO_TDA7432 is not set +# CONFIG_VIDEO_TDA9840 is not set +# CONFIG_VIDEO_TEA6415C is not set +# CONFIG_VIDEO_TEA6420 is not set +# CONFIG_VIDEO_THP7312 is not set +# CONFIG_VIDEO_THS7303 is not set +# CONFIG_VIDEO_THS8200 is not set +# CONFIG_VIDEO_TLV320AIC23B is not set +# CONFIG_VIDEO_TVAUDIO is not set +# CONFIG_VIDEO_TVP514X is not set +# CONFIG_VIDEO_TVP5150 is not set +# CONFIG_VIDEO_TVP7002 is not set +# CONFIG_VIDEO_TW2804 is not set +# CONFIG_VIDEO_TW5864 is not set +# CONFIG_VIDEO_TW68 is not set +# CONFIG_VIDEO_TW9900 is not set +# CONFIG_VIDEO_TW9903 is not set +# CONFIG_VIDEO_TW9906 is not set +# CONFIG_VIDEO_TW9910 is not set +# CONFIG_VIDEO_UDA1342 is not set +# CONFIG_VIDEO_UPD64031A is not set +# CONFIG_VIDEO_UPD64083 is not set +# CONFIG_VIDEO_USBTV is not set +# CONFIG_VIDEO_VGXY61 is not set +# CONFIG_VIDEO_VP27SMPX is not set +# CONFIG_VIDEO_VPX3220 is not set +# CONFIG_VIDEO_WM8739 is not set +# CONFIG_VIDEO_WM8775 is not set +# CONFIG_VIDEO_XILINX is not set +# CONFIG_VIDEO_ZORAN is not set +# CONFIG_VIRTIO_BALLOON is not set +# CONFIG_VIRTIO_CONSOLE is not set +# CONFIG_VIRTIO_FS is not set +# CONFIG_VIRTIO_INPUT is not set +CONFIG_VIRTIO_MENU=y +# CONFIG_VIRTIO_MMIO is not set +# CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES is not set +# CONFIG_VIRTIO_PCI is not set +# CONFIG_VIRTIO_VFIO_PCI is not set +# CONFIG_VIRTUALIZATION is not set +# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set +# CONFIG_VIRT_DRIVERS is not set +# CONFIG_VITESSE_PHY is not set +# CONFIG_VL53L0X_I2C is not set +# CONFIG_VL6180 is not set +CONFIG_VLAN_8021Q=y +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_VLAN_8021Q_MVRP is not set +# CONFIG_VMAP_STACK is not set +# CONFIG_VME_BUS is not set +# CONFIG_VMLINUX_MAP is not set +# CONFIG_VMSPLIT_1G is not set +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_2G_OPT is not set +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_3G_OPT is not set +# CONFIG_VMWARE_PVSCSI is not set +# CONFIG_VMWARE_VMCI is not set +# CONFIG_VMXNET3 is not set +# CONFIG_VM_EVENT_COUNTERS is not set +# CONFIG_VORTEX is not set +# CONFIG_VSOCKETS is not set +# CONFIG_VSOCKETS_DIAG is not set +# CONFIG_VT is not set +# CONFIG_VT6655 is not set +# CONFIG_VT6656 is not set +# CONFIG_VXFS_FS is not set +# CONFIG_VXLAN is not set +# CONFIG_VZ89X is not set +# CONFIG_W1 is not set +# CONFIG_W1_CON is not set +# CONFIG_W1_MASTER_AMD_AXI is not set +# CONFIG_W1_MASTER_DS2482 is not set +# CONFIG_W1_MASTER_DS2490 is not set +# CONFIG_W1_MASTER_GPIO is not set +# CONFIG_W1_MASTER_MATROX is not set +# CONFIG_W1_MASTER_SGI is not set +# CONFIG_W1_MASTER_UART is not set +# CONFIG_W1_SLAVE_DS2405 is not set +# CONFIG_W1_SLAVE_DS2406 is not set +# CONFIG_W1_SLAVE_DS2408 is not set +# CONFIG_W1_SLAVE_DS2413 is not set +# CONFIG_W1_SLAVE_DS2423 is not set +# CONFIG_W1_SLAVE_DS2430 is not set +# CONFIG_W1_SLAVE_DS2431 is not set +# CONFIG_W1_SLAVE_DS2433 is not set +# CONFIG_W1_SLAVE_DS2438 is not set +# CONFIG_W1_SLAVE_DS250X is not set +# CONFIG_W1_SLAVE_DS2780 is not set +# CONFIG_W1_SLAVE_DS2781 is not set +# CONFIG_W1_SLAVE_DS2805 is not set +# CONFIG_W1_SLAVE_DS28E04 is not set +# CONFIG_W1_SLAVE_DS28E17 is not set +# CONFIG_W1_SLAVE_SMEM is not set +# CONFIG_W1_SLAVE_THERM is not set +# CONFIG_W83627HF_WDT is not set +# CONFIG_W83877F_WDT is not set +# CONFIG_W83977F_WDT is not set +# CONFIG_WAN is not set +# CONFIG_WANXL is not set +# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_CORE is not set +CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y +# CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT is not set +# CONFIG_WATCHDOG_NOWAYOUT is not set +CONFIG_WATCHDOG_OPEN_TIMEOUT=0 +# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set +# CONFIG_WATCHDOG_SYSFS is not set +# CONFIG_WATCH_QUEUE is not set +# CONFIG_WD80x3 is not set +# CONFIG_WDAT_WDT is not set +# CONFIG_WDTPCI is not set +# CONFIG_WERROR is not set +# CONFIG_WEXT_CORE is not set +# CONFIG_WEXT_PRIV is not set +# CONFIG_WEXT_PROC is not set +# CONFIG_WEXT_SPY is not set +# CONFIG_WIREGUARD is not set +CONFIG_WIRELESS=y +# CONFIG_WIRELESS_EXT is not set +# CONFIG_WIZNET_W5100 is not set +# CONFIG_WIZNET_W5300 is not set +# CONFIG_WL1251 is not set +# CONFIG_WL12XX is not set +# CONFIG_WL18XX is not set +CONFIG_WLAN=y +# CONFIG_WLAN_VENDOR_ADMTEK is not set +# CONFIG_WLAN_VENDOR_ATH is not set +# CONFIG_WLAN_VENDOR_ATMEL is not set +# CONFIG_WLAN_VENDOR_BROADCOM is not set +# CONFIG_WLAN_VENDOR_INTEL is not set +# CONFIG_WLAN_VENDOR_INTERSIL is not set +# CONFIG_WLAN_VENDOR_MARVELL is not set +# CONFIG_WLAN_VENDOR_MEDIATEK is not set +# CONFIG_WLAN_VENDOR_MICROCHIP is not set +# CONFIG_WLAN_VENDOR_PURELIFI is not set +# CONFIG_WLAN_VENDOR_QUANTENNA is not set +# CONFIG_WLAN_VENDOR_RALINK is not set +# CONFIG_WLAN_VENDOR_REALTEK is not set +# CONFIG_WLAN_VENDOR_RSI is not set +# CONFIG_WLAN_VENDOR_SILABS is not set +# CONFIG_WLAN_VENDOR_ST is not set +# CONFIG_WLAN_VENDOR_TI is not set +# CONFIG_WLAN_VENDOR_ZYDAS is not set +# CONFIG_WLCORE is not set +# CONFIG_WMI_BMOF is not set +# CONFIG_WPCM450_SOC is not set +# CONFIG_WQ_CPU_INTENSIVE_REPORT is not set +CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y +# CONFIG_WQ_WATCHDOG is not set +# CONFIG_WWAN is not set +# CONFIG_WWAN_HWSIM is not set +# CONFIG_WW_MUTEX_SELFTEST is not set +# CONFIG_X25 is not set +# CONFIG_X509_CERTIFICATE_PARSER is not set +# CONFIG_X86_KERNEL_IBT is not set +# CONFIG_X86_PKG_TEMP_THERMAL is not set +# CONFIG_X86_USER_SHADOW_STACK is not set +# CONFIG_X9250 is not set +# CONFIG_XDP_SOCKETS is not set +# CONFIG_XEN is not set +# CONFIG_XEN_GRANT_DMA_ALLOC is not set +# CONFIG_XEN_PVCALLS_FRONTEND is not set +CONFIG_XEN_SCRUB_PAGES_DEFAULT=y +CONFIG_XFRM=y +# CONFIG_XFRM_INTERFACE is not set +# CONFIG_XFRM_IPCOMP is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_USER is not set +# CONFIG_XFS_DEBUG is not set +# CONFIG_XFS_FS is not set +# CONFIG_XFS_ONLINE_SCRUB is not set +# CONFIG_XFS_POSIX_ACL is not set +# CONFIG_XFS_QUOTA is not set +# CONFIG_XFS_RT is not set +# CONFIG_XFS_SUPPORT_ASCII_CI is not set +# CONFIG_XFS_SUPPORT_V4 is not set +# CONFIG_XFS_WARN is not set +# CONFIG_XIAOMI_WMI is not set +# CONFIG_XILINX_AXI_EMAC is not set +# CONFIG_XILINX_DMA is not set +# CONFIG_XILINX_EMACLITE is not set +# CONFIG_XILINX_GMII2RGMII is not set +# CONFIG_XILINX_INTC is not set +# CONFIG_XILINX_LL_TEMAC is not set +# CONFIG_XILINX_SDFEC is not set +# CONFIG_XILINX_VCU is not set +# CONFIG_XILINX_WATCHDOG is not set +# CONFIG_XILINX_WINDOW_WATCHDOG is not set +# CONFIG_XILINX_XADC is not set +# CONFIG_XILINX_XDMA is not set +# CONFIG_XILINX_ZYNQMP_DMA is not set +# CONFIG_XILINX_ZYNQMP_DPDMA is not set +# CONFIG_XILLYBUS is not set +# CONFIG_XILLYUSB is not set +# CONFIG_XIL_AXIS_FIFO is not set +# CONFIG_XIP_KERNEL is not set +# CONFIG_XMON is not set +CONFIG_XZ_DEC=y +# CONFIG_XZ_DEC_ARM is not set +# CONFIG_XZ_DEC_ARM64 is not set +# CONFIG_XZ_DEC_ARMTHUMB is not set +# CONFIG_XZ_DEC_BCJ is not set +# CONFIG_XZ_DEC_MICROLZMA is not set +# CONFIG_XZ_DEC_POWERPC is not set +# CONFIG_XZ_DEC_RISCV is not set +# CONFIG_XZ_DEC_SPARC is not set +# CONFIG_XZ_DEC_TEST is not set +# CONFIG_XZ_DEC_X86 is not set +# CONFIG_YAM is not set +# CONFIG_YAMAHA_YAS530 is not set +# CONFIG_YELLOWFIN is not set +# CONFIG_YENTA is not set +# CONFIG_YENTA_O2 is not set +# CONFIG_YENTA_RICOH is not set +# CONFIG_YENTA_TI is not set +# CONFIG_YENTA_TOSHIBA is not set +# CONFIG_YOGABOOK is not set +# CONFIG_ZBUD is not set +# CONFIG_ZD1211RW is not set +# CONFIG_ZD1211RW_DEBUG is not set +# CONFIG_ZEROPLUS_FF is not set +# CONFIG_ZERO_CALL_USED_REGS is not set +# CONFIG_ZIIRAVE_WATCHDOG is not set +# CONFIG_ZISOFS is not set +# CONFIG_ZLIB_DEFLATE is not set +# CONFIG_ZLIB_INFLATE is not set +CONFIG_ZONE_DMA=y +# CONFIG_ZOPT2201 is not set +# CONFIG_ZPA2326 is not set +# CONFIG_ZPOOL is not set +# CONFIG_ZRAM is not set +# CONFIG_ZRAM_BACKEND_842 is not set +# CONFIG_ZRAM_BACKEND_DEFLATE is not set +# CONFIG_ZRAM_BACKEND_LZ4 is not set +# CONFIG_ZRAM_BACKEND_LZ4HC is not set +# CONFIG_ZRAM_BACKEND_LZO is not set +# CONFIG_ZRAM_BACKEND_ZSTD is not set +CONFIG_ZRAM_DEF_COMP="unset-value" +# CONFIG_ZRAM_DEF_COMP_842 is not set +# CONFIG_ZRAM_DEF_COMP_LZ4 is not set +# CONFIG_ZRAM_DEF_COMP_LZ4HC is not set +# CONFIG_ZRAM_DEF_COMP_LZO is not set +# CONFIG_ZRAM_DEF_COMP_LZORLE is not set +# CONFIG_ZRAM_DEF_COMP_ZSTD is not set +# CONFIG_ZRAM_MEMORY_TRACKING is not set +# CONFIG_ZRAM_MULTI_COMP is not set +# CONFIG_ZRAM_TRACK_ENTRY_ACTIME is not set +# CONFIG_ZSMALLOC is not set +CONFIG_ZSMALLOC_CHAIN_SIZE=8 +# CONFIG_ZSWAP is not set diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/config-filter b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/config-filter new file mode 100755 index 0000000..d1e2f70 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/config-filter @@ -0,0 +1,26 @@ +# CONFIG_ARCH_(ENABLE|HAS|HAVE|INLINE|SUPPORTS|USE|WANT|STACKWALK)_.* is not set +# CONFIG_ARM64_AS_.* is not set +# CONFIG_ARM64_CONT_.*_SHIFT is not set +# CONFIG_AS_.* is not set +# CONFIG_CC_(CAN|HAS|IS|VERSION)_.* is not set +# CONFIG_CC_IMPLICIT_FALLTHROUGH is not set +# CONFIG_CC_NO_ARRAY_BOUNDS is not set +CONFIG_CLANG_VERSION=.* +CONFIG_FRAME_WARN=.* +# CONFIG_GCC10_NO_ARRAY_BOUNDS is not set +# CONFIG_GCC_VERSION is not set +# CONFIG_HAVE_(?!(ARCH_TIMER|TCM|SMP)).* is not set +# CONFIG_INLINE_.* is not set +# CONFIG_LD_.* is not set +CONFIG_LLD_VERSION=.* +CONFIG_PAHOLE_HAS_LANG_EXCLUDE=.* +CONFIG_PAHOLE_HAS_SPLIT_BTF=.* +CONFIG_PAHOLE_VERSION=.* +CONFIG_PLUGIN_HOSTCC=".*" +CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES=.* +CONFIG_RUSTC_LLVM_VERSION=.* +CONFIG_RUSTC_SUPPORTS_.*=.* +CONFIG_RUSTC_VERSION=.* +CONFIG_RUST_IS_AVAILABLE=.* +# CONFIG_SET_FS is not set +# CONFIG_TASKS_.* is not set diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/200-tools_portability.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/200-tools_portability.patch new file mode 100755 index 0000000..58ef223 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/200-tools_portability.patch @@ -0,0 +1,176 @@ +From a7ae4ed0a3951c45d4a59ee575951b64ae4a23fb Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Tue, 7 May 2024 12:22:15 +0200 +Subject: [PATCH] kernel: fix tools build breakage on macos with x86 + +Signed-off-by: Felix Fietkau +--- +--- a/tools/scripts/Makefile.include ++++ b/tools/scripts/Makefile.include +@@ -72,8 +72,6 @@ $(call allow-override,CXX,$(CROSS_COMPIL + $(call allow-override,STRIP,$(CROSS_COMPILE)strip) + endif + +-CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) +- + ifneq ($(LLVM),) + HOSTAR ?= $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX) + HOSTCC ?= $(LLVM_PREFIX)clang$(LLVM_SUFFIX) +@@ -84,6 +82,9 @@ HOSTCC ?= gcc + HOSTLD ?= ld + endif + ++CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) ++HOSTCC_NO_CLANG := $(shell $(HOSTCC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) ++ + # Some tools require Clang, LLC and/or LLVM utils + CLANG ?= clang + LLC ?= llc +@@ -92,8 +93,9 @@ LLVM_OBJCOPY ?= llvm-objcopy + LLVM_STRIP ?= llvm-strip + + ifeq ($(CC_NO_CLANG), 1) +-EXTRA_WARNINGS += -Wstrict-aliasing=3 +- ++ ifeq ($(HOSTCC_NO_CLANG), 1) ++ EXTRA_WARNINGS += -Wstrict-aliasing=3 ++ endif + else ifneq ($(CROSS_COMPILE),) + # Allow userspace to override CLANG_CROSS_FLAGS to specify their own + # sysroots and flags or to avoid the GCC call in pure Clang builds. +--- a/tools/include/linux/types.h ++++ b/tools/include/linux/types.h +@@ -56,6 +56,7 @@ typedef __s8 s8; + #define __user + #endif + #define __must_check ++#undef __cold + #define __cold + + typedef __u16 __bitwise __le16; +--- a/tools/objtool/include/objtool/objtool.h ++++ b/tools/objtool/include/objtool/objtool.h +@@ -12,6 +12,7 @@ + + #include + ++#undef __weak + #define __weak __attribute__((weak)) + + struct pv_state { +--- a/tools/include/asm-generic/bitops/fls.h ++++ b/tools/include/asm-generic/bitops/fls.h +@@ -2,6 +2,8 @@ + #ifndef _ASM_GENERIC_BITOPS_FLS_H_ + #define _ASM_GENERIC_BITOPS_FLS_H_ + ++#include ++ + /** + * generic_fls - find last (most-significant) bit set + * @x: the word to search +@@ -10,6 +12,7 @@ + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ + ++#define generic_fls __linux_fls + static __always_inline int generic_fls(unsigned int x) + { + int r = 32; +--- a/tools/lib/string.c ++++ b/tools/lib/string.c +@@ -96,6 +96,7 @@ int strtobool(const char *s, bool *res) + * If libc has strlcpy() then that version will override this + * implementation: + */ ++#ifndef __APPLE__ + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wignored-attributes" +@@ -114,6 +115,7 @@ size_t __weak strlcpy(char *dest, const + #ifdef __clang__ + #pragma clang diagnostic pop + #endif ++#endif + + /** + * skip_spaces - Removes leading whitespace from @str. +--- a/tools/arch/x86/include/asm/insn.h ++++ b/tools/arch/x86/include/asm/insn.h +@@ -7,7 +7,7 @@ + * Copyright (C) IBM Corporation, 2009 + */ + +-#include ++#include + /* insn_attr_t is defined in inat.h */ + #include "inat.h" /* __ignore_sync_check__ */ + +--- a/tools/arch/x86/include/asm/orc_types.h ++++ b/tools/arch/x86/include/asm/orc_types.h +@@ -46,7 +46,17 @@ + #define ORC_TYPE_REGS_PARTIAL 4 + + #ifndef __ASSEMBLY__ ++#ifdef __APPLE__ ++#include ++ ++#if __BYTE_ORDER == __LITTLE_ENDIAN ++#define __LITTLE_ENDIAN_BITFIELD ++#elif __BYTE_ORDER == __BIG_ENDIAN ++#define __BIG_ENDIAN_BITFIELD ++#endif ++#else + #include ++#endif + + /* + * This struct is more or less a vastly simplified version of the DWARF Call +--- a/tools/include/linux/rbtree.h ++++ b/tools/include/linux/rbtree.h +@@ -18,7 +18,6 @@ + #define __TOOLS_LINUX_PERF_RBTREE_H + + #include +-#include + + struct rb_node { + unsigned long __rb_parent_color; +--- a/tools/lib/subcmd/exec-cmd.c ++++ b/tools/lib/subcmd/exec-cmd.c +@@ -12,7 +12,10 @@ + #include "subcmd-config.h" + + #define MAX_ARGS 32 ++ ++#ifndef PATH_MAX + #define PATH_MAX 4096 ++#endif + + static const char *argv_exec_path; + static const char *argv0_path; +--- a/tools/objtool/Makefile ++++ b/tools/objtool/Makefile +@@ -39,6 +39,8 @@ OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBS + elfshdr := $(shell echo '$(pound)include ' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - | grep elf_getshdr) + OBJTOOL_CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) + ++OBJTOOL_CFLAGS += $(HOST_EXTRACFLAGS) ++ + # Always want host compilation. + HOST_OVERRIDES := CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" + +--- a/tools/arch/x86/lib/insn.c ++++ b/tools/arch/x86/lib/insn.c +@@ -15,7 +15,11 @@ + #include "../include/asm/insn.h" /* __ignore_sync_check__ */ + #include /* __ignore_sync_check__ */ + ++#ifdef __KERNEL__ + #include ++#else ++#include ++#endif + #include + + #include "../include/asm/emulate_prefix.h" /* __ignore_sync_check__ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/204-module_strip.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/204-module_strip.patch new file mode 100755 index 0000000..1c67eb5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/204-module_strip.patch @@ -0,0 +1,201 @@ +From a779a482fb9b9f8fcdf8b2519c789b4b9bb5dd05 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Fri, 7 Jul 2017 16:56:48 +0200 +Subject: build: add a hack for removing non-essential module info + +Signed-off-by: Felix Fietkau +--- + include/linux/module.h | 13 ++++++++----- + include/linux/moduleparam.h | 15 ++++++++++++--- + init/Kconfig | 7 +++++++ + kernel/module.c | 5 ++++- + scripts/mod/modpost.c | 12 ++++++++++++ + 5 files changed, 43 insertions(+), 9 deletions(-) + +--- a/include/linux/module.h ++++ b/include/linux/module.h +@@ -166,6 +166,7 @@ struct module_kobject *lookup_or_create_ + + /* Generic info of form tag = "info" */ + #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info) ++#define MODULE_INFO_STRIP(tag, info) __MODULE_INFO_STRIP(tag, tag, info) + + /* For userspace: you can also call me... */ + #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) +@@ -241,12 +242,12 @@ struct module_kobject *lookup_or_create_ + * Author(s), use "Name " or just "Name", for multiple + * authors use multiple MODULE_AUTHOR() statements/lines. + */ +-#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) ++#define MODULE_AUTHOR(_author) MODULE_INFO_STRIP(author, _author) + + /* What your module does. */ +-#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) ++#define MODULE_DESCRIPTION(_description) MODULE_INFO_STRIP(description, _description) + +-#ifdef MODULE ++#if defined(MODULE) && !defined(CONFIG_MODULE_STRIPPED) + /* Creates an alias so file2alias.c can find device table. */ + #define MODULE_DEVICE_TABLE(type, name) \ + extern typeof(name) __mod_##type##__##name##_device_table \ +@@ -273,7 +274,9 @@ extern typeof(name) __mod_##type##__##na + */ + + #if defined(MODULE) || !defined(CONFIG_SYSFS) +-#define MODULE_VERSION(_version) MODULE_INFO(version, _version) ++#define MODULE_VERSION(_version) MODULE_INFO_STRIP(version, _version) ++#elif defined(CONFIG_MODULE_STRIPPED) ++#define MODULE_VERSION(_version) __MODULE_INFO_DISABLED(version) + #else + #define MODULE_VERSION(_version) \ + MODULE_INFO(version, _version); \ +@@ -296,7 +299,7 @@ extern typeof(name) __mod_##type##__##na + /* Optional firmware file (or files) needed by the module + * format is simply firmware file name. Multiple firmware + * files require multiple MODULE_FIRMWARE() specifiers */ +-#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware) ++#define MODULE_FIRMWARE(_firmware) MODULE_INFO_STRIP(firmware, _firmware) + + #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, __stringify(ns)) + +--- a/include/linux/moduleparam.h ++++ b/include/linux/moduleparam.h +@@ -20,6 +20,16 @@ + /* Chosen so that structs with an unsigned long line up. */ + #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) + ++/* This struct is here for syntactic coherency, it is not used */ ++#define __MODULE_INFO_DISABLED(name) \ ++ struct __UNIQUE_ID(name) {} ++ ++#ifdef CONFIG_MODULE_STRIPPED ++#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO_DISABLED(name) ++#else ++#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO(tag, name, info) ++#endif ++ + #define __MODULE_INFO(tag, name, info) \ + static const char __UNIQUE_ID(name)[] \ + __used __section(".modinfo") __aligned(1) \ +@@ -31,7 +41,7 @@ + /* One for each parameter, describing how to use it. Some files do + multiple of these per line, so can't just use MODULE_INFO. */ + #define MODULE_PARM_DESC(_parm, desc) \ +- __MODULE_INFO(parm, _parm, #_parm ":" desc) ++ __MODULE_INFO_STRIP(parm, _parm, #_parm ":" desc) + + struct kernel_param; + +--- a/kernel/module/Kconfig ++++ b/kernel/module/Kconfig +@@ -402,4 +402,11 @@ config MODULES_TREE_LOOKUP + def_bool y + depends on PERF_EVENTS || TRACING || CFI_CLANG + ++config MODULE_STRIPPED ++ bool "Reduce module size" ++ depends on MODULES ++ help ++ Remove module parameter descriptions, author info, version, aliases, ++ device tables, etc. ++ + endif # MODULES +--- a/kernel/module/main.c ++++ b/kernel/module/main.c +@@ -1001,6 +1001,7 @@ size_t modinfo_attrs_count = ARRAY_SIZE( + + static const char vermagic[] = VERMAGIC_STRING; + ++#if defined(CONFIG_MODVERSIONS) || !defined(CONFIG_MODULE_STRIPPED) + int try_to_force_load(struct module *mod, const char *reason) + { + #ifdef CONFIG_MODULE_FORCE_LOAD +@@ -1012,6 +1013,7 @@ int try_to_force_load(struct module *mod + return -ENOEXEC; + #endif + } ++#endif + + /* Parse tag=value strings from .modinfo section */ + char *module_next_tag_pair(char *string, unsigned long *secsize) +@@ -2095,9 +2097,11 @@ static void module_augment_kernel_taints + + static int check_modinfo(struct module *mod, struct load_info *info, int flags) + { +- const char *modmagic = get_modinfo(info, "vermagic"); + int err; + ++#ifndef CONFIG_MODULE_STRIPPED ++ const char *modmagic = get_modinfo(info, "vermagic"); ++ + if (flags & MODULE_INIT_IGNORE_VERMAGIC) + modmagic = NULL; + +@@ -2111,6 +2115,7 @@ static int check_modinfo(struct module * + info->name, modmagic, vermagic); + return -ENOEXEC; + } ++#endif + + err = check_modinfo_livepatch(mod, info); + if (err) +--- a/scripts/mod/modpost.c ++++ b/scripts/mod/modpost.c +@@ -1601,7 +1601,9 @@ static void read_symbols(const char *mod + symname = remove_dot(info.strtab + sym->st_name); + + handle_symbol(mod, &info, sym, symname); ++#ifndef CONFIG_MODULE_STRIPPED + handle_moddevtable(mod, &info, sym, symname); ++#endif + } + + check_sec_ref(mod, &info); +@@ -1758,7 +1760,9 @@ static void add_header(struct buffer *b, + buf_printf(b, "#include \n"); + buf_printf(b, "#include \n"); + buf_printf(b, "\n"); ++#ifndef CONFIG_MODULE_STRIPPED + buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); ++#endif + buf_printf(b, "\n"); + buf_printf(b, "__visible struct module __this_module\n"); + buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n"); +@@ -1772,11 +1776,13 @@ static void add_header(struct buffer *b, + buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n"); + buf_printf(b, "};\n"); + ++#ifndef CONFIG_MODULE_STRIPPED + if (!external_module) + buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); + + if (strstarts(mod->name, "drivers/staging")) + buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); ++#endif + + if (strstarts(mod->name, "tools/testing")) + buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n"); +@@ -1886,11 +1892,13 @@ static void add_depends(struct buffer *b + + static void add_srcversion(struct buffer *b, struct module *mod) + { ++#ifndef CONFIG_MODULE_STRIPPED + if (mod->srcversion[0]) { + buf_printf(b, "\n"); + buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n", + mod->srcversion); + } ++#endif + } + + static void write_buf(struct buffer *b, const char *fname) +@@ -1973,7 +1981,9 @@ static void write_mod_c_file(struct modu + add_exported_symbols(&buf, mod); + add_versions(&buf, mod); + add_depends(&buf, mod); ++#ifndef CONFIG_MODULE_STRIPPED + add_moddevtable(&buf, mod); ++#endif + add_srcversion(&buf, mod); + + ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/205-kconfig-abort-configuration-on-unset-symbol.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/205-kconfig-abort-configuration-on-unset-symbol.patch new file mode 100755 index 0000000..d7416d8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/205-kconfig-abort-configuration-on-unset-symbol.patch @@ -0,0 +1,41 @@ +From 310e8e04a05d9eb43fa9dd7f00143300afcaa37a Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Fri, 11 Nov 2022 13:33:44 +0100 +Subject: [PATCH] kconfig: abort configuration on unset symbol + +When a target configuration has unset Kconfig symbols, the build will +fail when OpenWrt is compiled with V=s and stdin is connected to a tty. + +In case OpenWrt is compiled without either of these preconditions, the +build will succeed with the symbols in question being unset. + +Modify the kernel configuration in a way it fails on unset symbols +regardless of the aforementioned preconditions. + +Signed-off-by: David Bauer +--- + scripts/kconfig/conf.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/scripts/kconfig/conf.c ++++ b/scripts/kconfig/conf.c +@@ -312,6 +312,9 @@ static int conf_askvalue(struct symbol * + } + /* fall through */ + default: ++ if (!tty_stdio && getenv("FAIL_ON_UNCONFIGURED")) { ++ exit(1); ++ } + fflush(stdout); + xfgets(line, sizeof(line), stdin); + break; +@@ -470,6 +473,9 @@ static void conf_choice(struct menu *men + } + /* fall through */ + case oldaskconfig: ++ if (!tty_stdio && getenv("FAIL_ON_UNCONFIGURED")) { ++ exit(1); ++ } + fflush(stdout); + xfgets(line, sizeof(line), stdin); + strip(line); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/210-darwin_scripts_include.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/210-darwin_scripts_include.patch new file mode 100755 index 0000000..be59ca4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/210-darwin_scripts_include.patch @@ -0,0 +1,3053 @@ +From db7c30dcd9a0391bf13b62c9f91e144d762ef43a Mon Sep 17 00:00:00 2001 +From: Florian Fainelli +Date: Fri, 7 Jul 2017 17:00:49 +0200 +Subject: Add an OSX specific patch to make the kernel be compiled + +lede-commit: 3fc2a24f0422b2f55f9ed43f116db3111f700526 +Signed-off-by: Florian Fainelli +--- + scripts/kconfig/Makefile | 3 + + scripts/mod/elf.h | 3007 ++++++++++++++++++++++++++++++++++++++++++++ + scripts/mod/mk_elfconfig.c | 4 + + scripts/mod/modpost.h | 4 + + 4 files changed, 3018 insertions(+) + create mode 100644 scripts/mod/elf.h + +--- /dev/null ++++ b/scripts/mod/elf.h +@@ -0,0 +1,3007 @@ ++/* This file defines standard ELF types, structures, and macros. ++ Copyright (C) 1995-2012 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#ifndef _ELF_H ++#define _ELF_H 1 ++ ++/* Standard ELF types. */ ++ ++#include ++ ++/* Type for a 16-bit quantity. */ ++typedef uint16_t Elf32_Half; ++typedef uint16_t Elf64_Half; ++ ++/* Types for signed and unsigned 32-bit quantities. */ ++typedef uint32_t Elf32_Word; ++typedef int32_t Elf32_Sword; ++typedef uint32_t Elf64_Word; ++typedef int32_t Elf64_Sword; ++ ++/* Types for signed and unsigned 64-bit quantities. */ ++typedef uint64_t Elf32_Xword; ++typedef int64_t Elf32_Sxword; ++typedef uint64_t Elf64_Xword; ++typedef int64_t Elf64_Sxword; ++ ++/* Type of addresses. */ ++typedef uint32_t Elf32_Addr; ++typedef uint64_t Elf64_Addr; ++ ++/* Type of file offsets. */ ++typedef uint32_t Elf32_Off; ++typedef uint64_t Elf64_Off; ++ ++/* Type for section indices, which are 16-bit quantities. */ ++typedef uint16_t Elf32_Section; ++typedef uint16_t Elf64_Section; ++ ++/* Type for version symbol information. */ ++typedef Elf32_Half Elf32_Versym; ++typedef Elf64_Half Elf64_Versym; ++ ++ ++/* The ELF file header. This appears at the start of every ELF file. */ ++ ++#define EI_NIDENT (16) ++ ++typedef struct ++{ ++ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ ++ Elf32_Half e_type; /* Object file type */ ++ Elf32_Half e_machine; /* Architecture */ ++ Elf32_Word e_version; /* Object file version */ ++ Elf32_Addr e_entry; /* Entry point virtual address */ ++ Elf32_Off e_phoff; /* Program header table file offset */ ++ Elf32_Off e_shoff; /* Section header table file offset */ ++ Elf32_Word e_flags; /* Processor-specific flags */ ++ Elf32_Half e_ehsize; /* ELF header size in bytes */ ++ Elf32_Half e_phentsize; /* Program header table entry size */ ++ Elf32_Half e_phnum; /* Program header table entry count */ ++ Elf32_Half e_shentsize; /* Section header table entry size */ ++ Elf32_Half e_shnum; /* Section header table entry count */ ++ Elf32_Half e_shstrndx; /* Section header string table index */ ++} Elf32_Ehdr; ++ ++typedef struct ++{ ++ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ ++ Elf64_Half e_type; /* Object file type */ ++ Elf64_Half e_machine; /* Architecture */ ++ Elf64_Word e_version; /* Object file version */ ++ Elf64_Addr e_entry; /* Entry point virtual address */ ++ Elf64_Off e_phoff; /* Program header table file offset */ ++ Elf64_Off e_shoff; /* Section header table file offset */ ++ Elf64_Word e_flags; /* Processor-specific flags */ ++ Elf64_Half e_ehsize; /* ELF header size in bytes */ ++ Elf64_Half e_phentsize; /* Program header table entry size */ ++ Elf64_Half e_phnum; /* Program header table entry count */ ++ Elf64_Half e_shentsize; /* Section header table entry size */ ++ Elf64_Half e_shnum; /* Section header table entry count */ ++ Elf64_Half e_shstrndx; /* Section header string table index */ ++} Elf64_Ehdr; ++ ++/* Fields in the e_ident array. The EI_* macros are indices into the ++ array. The macros under each EI_* macro are the values the byte ++ may have. */ ++ ++#define EI_MAG0 0 /* File identification byte 0 index */ ++#define ELFMAG0 0x7f /* Magic number byte 0 */ ++ ++#define EI_MAG1 1 /* File identification byte 1 index */ ++#define ELFMAG1 'E' /* Magic number byte 1 */ ++ ++#define EI_MAG2 2 /* File identification byte 2 index */ ++#define ELFMAG2 'L' /* Magic number byte 2 */ ++ ++#define EI_MAG3 3 /* File identification byte 3 index */ ++#define ELFMAG3 'F' /* Magic number byte 3 */ ++ ++/* Conglomeration of the identification bytes, for easy testing as a word. */ ++#define ELFMAG "\177ELF" ++#define SELFMAG 4 ++ ++#define EI_CLASS 4 /* File class byte index */ ++#define ELFCLASSNONE 0 /* Invalid class */ ++#define ELFCLASS32 1 /* 32-bit objects */ ++#define ELFCLASS64 2 /* 64-bit objects */ ++#define ELFCLASSNUM 3 ++ ++#define EI_DATA 5 /* Data encoding byte index */ ++#define ELFDATANONE 0 /* Invalid data encoding */ ++#define ELFDATA2LSB 1 /* 2's complement, little endian */ ++#define ELFDATA2MSB 2 /* 2's complement, big endian */ ++#define ELFDATANUM 3 ++ ++#define EI_VERSION 6 /* File version byte index */ ++ /* Value must be EV_CURRENT */ ++ ++#define EI_OSABI 7 /* OS ABI identification */ ++#define ELFOSABI_NONE 0 /* UNIX System V ABI */ ++#define ELFOSABI_SYSV 0 /* Alias. */ ++#define ELFOSABI_HPUX 1 /* HP-UX */ ++#define ELFOSABI_NETBSD 2 /* NetBSD. */ ++#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */ ++#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */ ++#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ ++#define ELFOSABI_AIX 7 /* IBM AIX. */ ++#define ELFOSABI_IRIX 8 /* SGI Irix. */ ++#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ ++#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ ++#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ ++#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ ++#define ELFOSABI_ARM_AEABI 64 /* ARM EABI */ ++#define ELFOSABI_ARM 97 /* ARM */ ++#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ ++ ++#define EI_ABIVERSION 8 /* ABI version */ ++ ++#define EI_PAD 9 /* Byte index of padding bytes */ ++ ++/* Legal values for e_type (object file type). */ ++ ++#define ET_NONE 0 /* No file type */ ++#define ET_REL 1 /* Relocatable file */ ++#define ET_EXEC 2 /* Executable file */ ++#define ET_DYN 3 /* Shared object file */ ++#define ET_CORE 4 /* Core file */ ++#define ET_NUM 5 /* Number of defined types */ ++#define ET_LOOS 0xfe00 /* OS-specific range start */ ++#define ET_HIOS 0xfeff /* OS-specific range end */ ++#define ET_LOPROC 0xff00 /* Processor-specific range start */ ++#define ET_HIPROC 0xffff /* Processor-specific range end */ ++ ++/* Legal values for e_machine (architecture). */ ++ ++#define EM_NONE 0 /* No machine */ ++#define EM_M32 1 /* AT&T WE 32100 */ ++#define EM_SPARC 2 /* SUN SPARC */ ++#define EM_386 3 /* Intel 80386 */ ++#define EM_68K 4 /* Motorola m68k family */ ++#define EM_88K 5 /* Motorola m88k family */ ++#define EM_860 7 /* Intel 80860 */ ++#define EM_MIPS 8 /* MIPS R3000 big-endian */ ++#define EM_S370 9 /* IBM System/370 */ ++#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ ++ ++#define EM_PARISC 15 /* HPPA */ ++#define EM_VPP500 17 /* Fujitsu VPP500 */ ++#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ ++#define EM_960 19 /* Intel 80960 */ ++#define EM_PPC 20 /* PowerPC */ ++#define EM_PPC64 21 /* PowerPC 64-bit */ ++#define EM_S390 22 /* IBM S390 */ ++ ++#define EM_V800 36 /* NEC V800 series */ ++#define EM_FR20 37 /* Fujitsu FR20 */ ++#define EM_RH32 38 /* TRW RH-32 */ ++#define EM_RCE 39 /* Motorola RCE */ ++#define EM_ARM 40 /* ARM */ ++#define EM_FAKE_ALPHA 41 /* Digital Alpha */ ++#define EM_SH 42 /* Hitachi SH */ ++#define EM_SPARCV9 43 /* SPARC v9 64-bit */ ++#define EM_TRICORE 44 /* Siemens Tricore */ ++#define EM_ARC 45 /* Argonaut RISC Core */ ++#define EM_H8_300 46 /* Hitachi H8/300 */ ++#define EM_H8_300H 47 /* Hitachi H8/300H */ ++#define EM_H8S 48 /* Hitachi H8S */ ++#define EM_H8_500 49 /* Hitachi H8/500 */ ++#define EM_IA_64 50 /* Intel Merced */ ++#define EM_MIPS_X 51 /* Stanford MIPS-X */ ++#define EM_COLDFIRE 52 /* Motorola Coldfire */ ++#define EM_68HC12 53 /* Motorola M68HC12 */ ++#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ ++#define EM_PCP 55 /* Siemens PCP */ ++#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ ++#define EM_NDR1 57 /* Denso NDR1 microprocessor */ ++#define EM_STARCORE 58 /* Motorola Start*Core processor */ ++#define EM_ME16 59 /* Toyota ME16 processor */ ++#define EM_ST100 60 /* STMicroelectronic ST100 processor */ ++#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ ++#define EM_X86_64 62 /* AMD x86-64 architecture */ ++#define EM_PDSP 63 /* Sony DSP Processor */ ++ ++#define EM_FX66 66 /* Siemens FX66 microcontroller */ ++#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ ++#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ ++#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ ++#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ ++#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ ++#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ ++#define EM_SVX 73 /* Silicon Graphics SVx */ ++#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ ++#define EM_VAX 75 /* Digital VAX */ ++#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ ++#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ ++#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ ++#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ ++#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ ++#define EM_HUANY 81 /* Harvard University machine-independent object files */ ++#define EM_PRISM 82 /* SiTera Prism */ ++#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ ++#define EM_FR30 84 /* Fujitsu FR30 */ ++#define EM_D10V 85 /* Mitsubishi D10V */ ++#define EM_D30V 86 /* Mitsubishi D30V */ ++#define EM_V850 87 /* NEC v850 */ ++#define EM_M32R 88 /* Mitsubishi M32R */ ++#define EM_MN10300 89 /* Matsushita MN10300 */ ++#define EM_MN10200 90 /* Matsushita MN10200 */ ++#define EM_PJ 91 /* picoJava */ ++#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ ++#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ ++#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ ++#define EM_TILEPRO 188 /* Tilera TILEPro */ ++#define EM_TILEGX 191 /* Tilera TILE-Gx */ ++#define EM_NUM 192 ++ ++/* If it is necessary to assign new unofficial EM_* values, please ++ pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the ++ chances of collision with official or non-GNU unofficial values. */ ++ ++#define EM_ALPHA 0x9026 ++ ++/* Legal values for e_version (version). */ ++ ++#define EV_NONE 0 /* Invalid ELF version */ ++#define EV_CURRENT 1 /* Current version */ ++#define EV_NUM 2 ++ ++/* Section header. */ ++ ++typedef struct ++{ ++ Elf32_Word sh_name; /* Section name (string tbl index) */ ++ Elf32_Word sh_type; /* Section type */ ++ Elf32_Word sh_flags; /* Section flags */ ++ Elf32_Addr sh_addr; /* Section virtual addr at execution */ ++ Elf32_Off sh_offset; /* Section file offset */ ++ Elf32_Word sh_size; /* Section size in bytes */ ++ Elf32_Word sh_link; /* Link to another section */ ++ Elf32_Word sh_info; /* Additional section information */ ++ Elf32_Word sh_addralign; /* Section alignment */ ++ Elf32_Word sh_entsize; /* Entry size if section holds table */ ++} Elf32_Shdr; ++ ++typedef struct ++{ ++ Elf64_Word sh_name; /* Section name (string tbl index) */ ++ Elf64_Word sh_type; /* Section type */ ++ Elf64_Xword sh_flags; /* Section flags */ ++ Elf64_Addr sh_addr; /* Section virtual addr at execution */ ++ Elf64_Off sh_offset; /* Section file offset */ ++ Elf64_Xword sh_size; /* Section size in bytes */ ++ Elf64_Word sh_link; /* Link to another section */ ++ Elf64_Word sh_info; /* Additional section information */ ++ Elf64_Xword sh_addralign; /* Section alignment */ ++ Elf64_Xword sh_entsize; /* Entry size if section holds table */ ++} Elf64_Shdr; ++ ++/* Special section indices. */ ++ ++#define SHN_UNDEF 0 /* Undefined section */ ++#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ ++#define SHN_LOPROC 0xff00 /* Start of processor-specific */ ++#define SHN_BEFORE 0xff00 /* Order section before all others ++ (Solaris). */ ++#define SHN_AFTER 0xff01 /* Order section after all others ++ (Solaris). */ ++#define SHN_HIPROC 0xff1f /* End of processor-specific */ ++#define SHN_LOOS 0xff20 /* Start of OS-specific */ ++#define SHN_HIOS 0xff3f /* End of OS-specific */ ++#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ ++#define SHN_COMMON 0xfff2 /* Associated symbol is common */ ++#define SHN_XINDEX 0xffff /* Index is in extra table. */ ++#define SHN_HIRESERVE 0xffff /* End of reserved indices */ ++ ++/* Legal values for sh_type (section type). */ ++ ++#define SHT_NULL 0 /* Section header table entry unused */ ++#define SHT_PROGBITS 1 /* Program data */ ++#define SHT_SYMTAB 2 /* Symbol table */ ++#define SHT_STRTAB 3 /* String table */ ++#define SHT_RELA 4 /* Relocation entries with addends */ ++#define SHT_HASH 5 /* Symbol hash table */ ++#define SHT_DYNAMIC 6 /* Dynamic linking information */ ++#define SHT_NOTE 7 /* Notes */ ++#define SHT_NOBITS 8 /* Program space with no data (bss) */ ++#define SHT_REL 9 /* Relocation entries, no addends */ ++#define SHT_SHLIB 10 /* Reserved */ ++#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ ++#define SHT_INIT_ARRAY 14 /* Array of constructors */ ++#define SHT_FINI_ARRAY 15 /* Array of destructors */ ++#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ ++#define SHT_GROUP 17 /* Section group */ ++#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ ++#define SHT_NUM 19 /* Number of defined types. */ ++#define SHT_LOOS 0x60000000 /* Start OS-specific. */ ++#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */ ++#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */ ++#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ ++#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ ++#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ ++#define SHT_SUNW_move 0x6ffffffa ++#define SHT_SUNW_COMDAT 0x6ffffffb ++#define SHT_SUNW_syminfo 0x6ffffffc ++#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ ++#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ ++#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ ++#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ ++#define SHT_HIOS 0x6fffffff /* End OS-specific type */ ++#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ ++#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ ++#define SHT_LOUSER 0x80000000 /* Start of application-specific */ ++#define SHT_HIUSER 0x8fffffff /* End of application-specific */ ++ ++/* Legal values for sh_flags (section flags). */ ++ ++#define SHF_WRITE (1 << 0) /* Writable */ ++#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ ++#define SHF_EXECINSTR (1 << 2) /* Executable */ ++#define SHF_MERGE (1 << 4) /* Might be merged */ ++#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ ++#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ ++#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ ++#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling ++ required */ ++#define SHF_GROUP (1 << 9) /* Section is member of a group. */ ++#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ ++#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ ++#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ ++#define SHF_ORDERED (1 << 30) /* Special ordering requirement ++ (Solaris). */ ++#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless ++ referenced or allocated (Solaris).*/ ++ ++/* Section group handling. */ ++#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ ++ ++/* Symbol table entry. */ ++ ++typedef struct ++{ ++ Elf32_Word st_name; /* Symbol name (string tbl index) */ ++ Elf32_Addr st_value; /* Symbol value */ ++ Elf32_Word st_size; /* Symbol size */ ++ unsigned char st_info; /* Symbol type and binding */ ++ unsigned char st_other; /* Symbol visibility */ ++ Elf32_Section st_shndx; /* Section index */ ++} Elf32_Sym; ++ ++typedef struct ++{ ++ Elf64_Word st_name; /* Symbol name (string tbl index) */ ++ unsigned char st_info; /* Symbol type and binding */ ++ unsigned char st_other; /* Symbol visibility */ ++ Elf64_Section st_shndx; /* Section index */ ++ Elf64_Addr st_value; /* Symbol value */ ++ Elf64_Xword st_size; /* Symbol size */ ++} Elf64_Sym; ++ ++/* The syminfo section if available contains additional information about ++ every dynamic symbol. */ ++ ++typedef struct ++{ ++ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ ++ Elf32_Half si_flags; /* Per symbol flags */ ++} Elf32_Syminfo; ++ ++typedef struct ++{ ++ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ ++ Elf64_Half si_flags; /* Per symbol flags */ ++} Elf64_Syminfo; ++ ++/* Possible values for si_boundto. */ ++#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ ++#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ ++#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ ++ ++/* Possible bitmasks for si_flags. */ ++#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ ++#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ ++#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ ++#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy ++ loaded */ ++/* Syminfo version values. */ ++#define SYMINFO_NONE 0 ++#define SYMINFO_CURRENT 1 ++#define SYMINFO_NUM 2 ++ ++ ++/* How to extract and insert information held in the st_info field. */ ++ ++#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) ++#define ELF32_ST_TYPE(val) ((val) & 0xf) ++#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) ++ ++/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ ++#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) ++#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) ++#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) ++ ++/* Legal values for ST_BIND subfield of st_info (symbol binding). */ ++ ++#define STB_LOCAL 0 /* Local symbol */ ++#define STB_GLOBAL 1 /* Global symbol */ ++#define STB_WEAK 2 /* Weak symbol */ ++#define STB_NUM 3 /* Number of defined types. */ ++#define STB_LOOS 10 /* Start of OS-specific */ ++#define STB_GNU_UNIQUE 10 /* Unique symbol. */ ++#define STB_HIOS 12 /* End of OS-specific */ ++#define STB_LOPROC 13 /* Start of processor-specific */ ++#define STB_HIPROC 15 /* End of processor-specific */ ++ ++/* Legal values for ST_TYPE subfield of st_info (symbol type). */ ++ ++#define STT_NOTYPE 0 /* Symbol type is unspecified */ ++#define STT_OBJECT 1 /* Symbol is a data object */ ++#define STT_FUNC 2 /* Symbol is a code object */ ++#define STT_SECTION 3 /* Symbol associated with a section */ ++#define STT_FILE 4 /* Symbol's name is file name */ ++#define STT_COMMON 5 /* Symbol is a common data object */ ++#define STT_TLS 6 /* Symbol is thread-local data object*/ ++#define STT_NUM 7 /* Number of defined types. */ ++#define STT_LOOS 10 /* Start of OS-specific */ ++#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */ ++#define STT_HIOS 12 /* End of OS-specific */ ++#define STT_LOPROC 13 /* Start of processor-specific */ ++#define STT_HIPROC 15 /* End of processor-specific */ ++ ++ ++/* Symbol table indices are found in the hash buckets and chain table ++ of a symbol hash table section. This special index value indicates ++ the end of a chain, meaning no further symbols are found in that bucket. */ ++ ++#define STN_UNDEF 0 /* End of a chain. */ ++ ++ ++/* How to extract and insert information held in the st_other field. */ ++ ++#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) ++ ++/* For ELF64 the definitions are the same. */ ++#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) ++ ++/* Symbol visibility specification encoded in the st_other field. */ ++#define STV_DEFAULT 0 /* Default symbol visibility rules */ ++#define STV_INTERNAL 1 /* Processor specific hidden class */ ++#define STV_HIDDEN 2 /* Sym unavailable in other modules */ ++#define STV_PROTECTED 3 /* Not preemptible, not exported */ ++ ++ ++/* Relocation table entry without addend (in section of type SHT_REL). */ ++ ++typedef struct ++{ ++ Elf32_Addr r_offset; /* Address */ ++ Elf32_Word r_info; /* Relocation type and symbol index */ ++} Elf32_Rel; ++ ++/* I have seen two different definitions of the Elf64_Rel and ++ Elf64_Rela structures, so we'll leave them out until Novell (or ++ whoever) gets their act together. */ ++/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ ++ ++typedef struct ++{ ++ Elf64_Addr r_offset; /* Address */ ++ Elf64_Xword r_info; /* Relocation type and symbol index */ ++} Elf64_Rel; ++ ++/* Relocation table entry with addend (in section of type SHT_RELA). */ ++ ++typedef struct ++{ ++ Elf32_Addr r_offset; /* Address */ ++ Elf32_Word r_info; /* Relocation type and symbol index */ ++ Elf32_Sword r_addend; /* Addend */ ++} Elf32_Rela; ++ ++typedef struct ++{ ++ Elf64_Addr r_offset; /* Address */ ++ Elf64_Xword r_info; /* Relocation type and symbol index */ ++ Elf64_Sxword r_addend; /* Addend */ ++} Elf64_Rela; ++ ++/* How to extract and insert information held in the r_info field. */ ++ ++#define ELF32_R_SYM(val) ((val) >> 8) ++#define ELF32_R_TYPE(val) ((val) & 0xff) ++#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) ++ ++#define ELF64_R_SYM(i) ((i) >> 32) ++#define ELF64_R_TYPE(i) ((i) & 0xffffffff) ++#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) ++ ++/* Program segment header. */ ++ ++typedef struct ++{ ++ Elf32_Word p_type; /* Segment type */ ++ Elf32_Off p_offset; /* Segment file offset */ ++ Elf32_Addr p_vaddr; /* Segment virtual address */ ++ Elf32_Addr p_paddr; /* Segment physical address */ ++ Elf32_Word p_filesz; /* Segment size in file */ ++ Elf32_Word p_memsz; /* Segment size in memory */ ++ Elf32_Word p_flags; /* Segment flags */ ++ Elf32_Word p_align; /* Segment alignment */ ++} Elf32_Phdr; ++ ++typedef struct ++{ ++ Elf64_Word p_type; /* Segment type */ ++ Elf64_Word p_flags; /* Segment flags */ ++ Elf64_Off p_offset; /* Segment file offset */ ++ Elf64_Addr p_vaddr; /* Segment virtual address */ ++ Elf64_Addr p_paddr; /* Segment physical address */ ++ Elf64_Xword p_filesz; /* Segment size in file */ ++ Elf64_Xword p_memsz; /* Segment size in memory */ ++ Elf64_Xword p_align; /* Segment alignment */ ++} Elf64_Phdr; ++ ++/* Special value for e_phnum. This indicates that the real number of ++ program headers is too large to fit into e_phnum. Instead the real ++ value is in the field sh_info of section 0. */ ++ ++#define PN_XNUM 0xffff ++ ++/* Legal values for p_type (segment type). */ ++ ++#define PT_NULL 0 /* Program header table entry unused */ ++#define PT_LOAD 1 /* Loadable program segment */ ++#define PT_DYNAMIC 2 /* Dynamic linking information */ ++#define PT_INTERP 3 /* Program interpreter */ ++#define PT_NOTE 4 /* Auxiliary information */ ++#define PT_SHLIB 5 /* Reserved */ ++#define PT_PHDR 6 /* Entry for header table itself */ ++#define PT_TLS 7 /* Thread-local storage segment */ ++#define PT_NUM 8 /* Number of defined types */ ++#define PT_LOOS 0x60000000 /* Start of OS-specific */ ++#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ ++#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ ++#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ ++#define PT_LOSUNW 0x6ffffffa ++#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ ++#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ ++#define PT_HISUNW 0x6fffffff ++#define PT_HIOS 0x6fffffff /* End of OS-specific */ ++#define PT_LOPROC 0x70000000 /* Start of processor-specific */ ++#define PT_HIPROC 0x7fffffff /* End of processor-specific */ ++ ++/* Legal values for p_flags (segment flags). */ ++ ++#define PF_X (1 << 0) /* Segment is executable */ ++#define PF_W (1 << 1) /* Segment is writable */ ++#define PF_R (1 << 2) /* Segment is readable */ ++#define PF_MASKOS 0x0ff00000 /* OS-specific */ ++#define PF_MASKPROC 0xf0000000 /* Processor-specific */ ++ ++/* Legal values for note segment descriptor types for core files. */ ++ ++#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ ++#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ ++#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ ++#define NT_PRXREG 4 /* Contains copy of prxregset struct */ ++#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ ++#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ ++#define NT_AUXV 6 /* Contains copy of auxv array */ ++#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ ++#define NT_ASRS 8 /* Contains copy of asrset struct */ ++#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ ++#define NT_PSINFO 13 /* Contains copy of psinfo struct */ ++#define NT_PRCRED 14 /* Contains copy of prcred struct */ ++#define NT_UTSNAME 15 /* Contains copy of utsname struct */ ++#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ ++#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ ++#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct */ ++#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */ ++#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ ++#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */ ++#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ ++#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */ ++#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */ ++#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ ++ ++/* Legal values for the note segment descriptor types for object files. */ ++ ++#define NT_VERSION 1 /* Contains a version string. */ ++ ++ ++/* Dynamic section entry. */ ++ ++typedef struct ++{ ++ Elf32_Sword d_tag; /* Dynamic entry type */ ++ union ++ { ++ Elf32_Word d_val; /* Integer value */ ++ Elf32_Addr d_ptr; /* Address value */ ++ } d_un; ++} Elf32_Dyn; ++ ++typedef struct ++{ ++ Elf64_Sxword d_tag; /* Dynamic entry type */ ++ union ++ { ++ Elf64_Xword d_val; /* Integer value */ ++ Elf64_Addr d_ptr; /* Address value */ ++ } d_un; ++} Elf64_Dyn; ++ ++/* Legal values for d_tag (dynamic entry type). */ ++ ++#define DT_NULL 0 /* Marks end of dynamic section */ ++#define DT_NEEDED 1 /* Name of needed library */ ++#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ ++#define DT_PLTGOT 3 /* Processor defined value */ ++#define DT_HASH 4 /* Address of symbol hash table */ ++#define DT_STRTAB 5 /* Address of string table */ ++#define DT_SYMTAB 6 /* Address of symbol table */ ++#define DT_RELA 7 /* Address of Rela relocs */ ++#define DT_RELASZ 8 /* Total size of Rela relocs */ ++#define DT_RELAENT 9 /* Size of one Rela reloc */ ++#define DT_STRSZ 10 /* Size of string table */ ++#define DT_SYMENT 11 /* Size of one symbol table entry */ ++#define DT_INIT 12 /* Address of init function */ ++#define DT_FINI 13 /* Address of termination function */ ++#define DT_SONAME 14 /* Name of shared object */ ++#define DT_RPATH 15 /* Library search path (deprecated) */ ++#define DT_SYMBOLIC 16 /* Start symbol search here */ ++#define DT_REL 17 /* Address of Rel relocs */ ++#define DT_RELSZ 18 /* Total size of Rel relocs */ ++#define DT_RELENT 19 /* Size of one Rel reloc */ ++#define DT_PLTREL 20 /* Type of reloc in PLT */ ++#define DT_DEBUG 21 /* For debugging; unspecified */ ++#define DT_TEXTREL 22 /* Reloc might modify .text */ ++#define DT_JMPREL 23 /* Address of PLT relocs */ ++#define DT_BIND_NOW 24 /* Process relocations of object */ ++#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ ++#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ ++#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ ++#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ ++#define DT_RUNPATH 29 /* Library search path */ ++#define DT_FLAGS 30 /* Flags for the object being loaded */ ++#define DT_ENCODING 32 /* Start of encoded range */ ++#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ ++#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ ++#define DT_NUM 34 /* Number used */ ++#define DT_LOOS 0x6000000d /* Start of OS-specific */ ++#define DT_HIOS 0x6ffff000 /* End of OS-specific */ ++#define DT_LOPROC 0x70000000 /* Start of processor-specific */ ++#define DT_HIPROC 0x7fffffff /* End of processor-specific */ ++#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ ++ ++/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the ++ Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's ++ approach. */ ++#define DT_VALRNGLO 0x6ffffd00 ++#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ ++#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ ++#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ ++#define DT_CHECKSUM 0x6ffffdf8 ++#define DT_PLTPADSZ 0x6ffffdf9 ++#define DT_MOVEENT 0x6ffffdfa ++#define DT_MOVESZ 0x6ffffdfb ++#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ ++#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting ++ the following DT_* entry. */ ++#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ ++#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ ++#define DT_VALRNGHI 0x6ffffdff ++#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ ++#define DT_VALNUM 12 ++ ++/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the ++ Dyn.d_un.d_ptr field of the Elf*_Dyn structure. ++ ++ If any adjustment is made to the ELF object after it has been ++ built these entries will need to be adjusted. */ ++#define DT_ADDRRNGLO 0x6ffffe00 ++#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */ ++#define DT_TLSDESC_PLT 0x6ffffef6 ++#define DT_TLSDESC_GOT 0x6ffffef7 ++#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ ++#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ ++#define DT_CONFIG 0x6ffffefa /* Configuration information. */ ++#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ ++#define DT_AUDIT 0x6ffffefc /* Object auditing. */ ++#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ ++#define DT_MOVETAB 0x6ffffefe /* Move table. */ ++#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ ++#define DT_ADDRRNGHI 0x6ffffeff ++#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ ++#define DT_ADDRNUM 11 ++ ++/* The versioning entry types. The next are defined as part of the ++ GNU extension. */ ++#define DT_VERSYM 0x6ffffff0 ++ ++#define DT_RELACOUNT 0x6ffffff9 ++#define DT_RELCOUNT 0x6ffffffa ++ ++/* These were chosen by Sun. */ ++#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ ++#define DT_VERDEF 0x6ffffffc /* Address of version definition ++ table */ ++#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ ++#define DT_VERNEED 0x6ffffffe /* Address of table with needed ++ versions */ ++#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ ++#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ ++#define DT_VERSIONTAGNUM 16 ++ ++/* Sun added these machine-independent extensions in the "processor-specific" ++ range. Be compatible. */ ++#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ ++#define DT_FILTER 0x7fffffff /* Shared object to get values from */ ++#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) ++#define DT_EXTRANUM 3 ++ ++/* Values of `d_un.d_val' in the DT_FLAGS entry. */ ++#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ ++#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ ++#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ ++#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ ++#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ ++ ++/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 ++ entry in the dynamic section. */ ++#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ ++#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ ++#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ ++#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ ++#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ ++#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ ++#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ ++#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ ++#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ ++#define DF_1_TRANS 0x00000200 ++#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ ++#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ ++#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ ++#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ ++#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ ++#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ ++#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ ++ ++/* Flags for the feature selection in DT_FEATURE_1. */ ++#define DTF_1_PARINIT 0x00000001 ++#define DTF_1_CONFEXP 0x00000002 ++ ++/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ ++#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ ++#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not ++ generally available. */ ++ ++/* Version definition sections. */ ++ ++typedef struct ++{ ++ Elf32_Half vd_version; /* Version revision */ ++ Elf32_Half vd_flags; /* Version information */ ++ Elf32_Half vd_ndx; /* Version Index */ ++ Elf32_Half vd_cnt; /* Number of associated aux entries */ ++ Elf32_Word vd_hash; /* Version name hash value */ ++ Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ ++ Elf32_Word vd_next; /* Offset in bytes to next verdef ++ entry */ ++} Elf32_Verdef; ++ ++typedef struct ++{ ++ Elf64_Half vd_version; /* Version revision */ ++ Elf64_Half vd_flags; /* Version information */ ++ Elf64_Half vd_ndx; /* Version Index */ ++ Elf64_Half vd_cnt; /* Number of associated aux entries */ ++ Elf64_Word vd_hash; /* Version name hash value */ ++ Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ ++ Elf64_Word vd_next; /* Offset in bytes to next verdef ++ entry */ ++} Elf64_Verdef; ++ ++ ++/* Legal values for vd_version (version revision). */ ++#define VER_DEF_NONE 0 /* No version */ ++#define VER_DEF_CURRENT 1 /* Current version */ ++#define VER_DEF_NUM 2 /* Given version number */ ++ ++/* Legal values for vd_flags (version information flags). */ ++#define VER_FLG_BASE 0x1 /* Version definition of file itself */ ++#define VER_FLG_WEAK 0x2 /* Weak version identifier */ ++ ++/* Versym symbol index values. */ ++#define VER_NDX_LOCAL 0 /* Symbol is local. */ ++#define VER_NDX_GLOBAL 1 /* Symbol is global. */ ++#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ ++#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ ++ ++/* Auxialiary version information. */ ++ ++typedef struct ++{ ++ Elf32_Word vda_name; /* Version or dependency names */ ++ Elf32_Word vda_next; /* Offset in bytes to next verdaux ++ entry */ ++} Elf32_Verdaux; ++ ++typedef struct ++{ ++ Elf64_Word vda_name; /* Version or dependency names */ ++ Elf64_Word vda_next; /* Offset in bytes to next verdaux ++ entry */ ++} Elf64_Verdaux; ++ ++ ++/* Version dependency section. */ ++ ++typedef struct ++{ ++ Elf32_Half vn_version; /* Version of structure */ ++ Elf32_Half vn_cnt; /* Number of associated aux entries */ ++ Elf32_Word vn_file; /* Offset of filename for this ++ dependency */ ++ Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ ++ Elf32_Word vn_next; /* Offset in bytes to next verneed ++ entry */ ++} Elf32_Verneed; ++ ++typedef struct ++{ ++ Elf64_Half vn_version; /* Version of structure */ ++ Elf64_Half vn_cnt; /* Number of associated aux entries */ ++ Elf64_Word vn_file; /* Offset of filename for this ++ dependency */ ++ Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ ++ Elf64_Word vn_next; /* Offset in bytes to next verneed ++ entry */ ++} Elf64_Verneed; ++ ++ ++/* Legal values for vn_version (version revision). */ ++#define VER_NEED_NONE 0 /* No version */ ++#define VER_NEED_CURRENT 1 /* Current version */ ++#define VER_NEED_NUM 2 /* Given version number */ ++ ++/* Auxiliary needed version information. */ ++ ++typedef struct ++{ ++ Elf32_Word vna_hash; /* Hash value of dependency name */ ++ Elf32_Half vna_flags; /* Dependency specific information */ ++ Elf32_Half vna_other; /* Unused */ ++ Elf32_Word vna_name; /* Dependency name string offset */ ++ Elf32_Word vna_next; /* Offset in bytes to next vernaux ++ entry */ ++} Elf32_Vernaux; ++ ++typedef struct ++{ ++ Elf64_Word vna_hash; /* Hash value of dependency name */ ++ Elf64_Half vna_flags; /* Dependency specific information */ ++ Elf64_Half vna_other; /* Unused */ ++ Elf64_Word vna_name; /* Dependency name string offset */ ++ Elf64_Word vna_next; /* Offset in bytes to next vernaux ++ entry */ ++} Elf64_Vernaux; ++ ++ ++/* Legal values for vna_flags. */ ++#define VER_FLG_WEAK 0x2 /* Weak version identifier */ ++ ++ ++/* Auxiliary vector. */ ++ ++/* This vector is normally only used by the program interpreter. The ++ usual definition in an ABI supplement uses the name auxv_t. The ++ vector is not usually defined in a standard file, but it ++ can't hurt. We rename it to avoid conflicts. The sizes of these ++ types are an arrangement between the exec server and the program ++ interpreter, so we don't fully specify them here. */ ++ ++typedef struct ++{ ++ uint32_t a_type; /* Entry type */ ++ union ++ { ++ uint32_t a_val; /* Integer value */ ++ /* We use to have pointer elements added here. We cannot do that, ++ though, since it does not work when using 32-bit definitions ++ on 64-bit platforms and vice versa. */ ++ } a_un; ++} Elf32_auxv_t; ++ ++typedef struct ++{ ++ uint64_t a_type; /* Entry type */ ++ union ++ { ++ uint64_t a_val; /* Integer value */ ++ /* We use to have pointer elements added here. We cannot do that, ++ though, since it does not work when using 32-bit definitions ++ on 64-bit platforms and vice versa. */ ++ } a_un; ++} Elf64_auxv_t; ++ ++/* Legal values for a_type (entry type). */ ++ ++#define AT_NULL 0 /* End of vector */ ++#define AT_IGNORE 1 /* Entry should be ignored */ ++#define AT_EXECFD 2 /* File descriptor of program */ ++#define AT_PHDR 3 /* Program headers for program */ ++#define AT_PHENT 4 /* Size of program header entry */ ++#define AT_PHNUM 5 /* Number of program headers */ ++#define AT_PAGESZ 6 /* System page size */ ++#define AT_BASE 7 /* Base address of interpreter */ ++#define AT_FLAGS 8 /* Flags */ ++#define AT_ENTRY 9 /* Entry point of program */ ++#define AT_NOTELF 10 /* Program is not ELF */ ++#define AT_UID 11 /* Real uid */ ++#define AT_EUID 12 /* Effective uid */ ++#define AT_GID 13 /* Real gid */ ++#define AT_EGID 14 /* Effective gid */ ++#define AT_CLKTCK 17 /* Frequency of times() */ ++ ++/* Some more special a_type values describing the hardware. */ ++#define AT_PLATFORM 15 /* String identifying platform. */ ++#define AT_HWCAP 16 /* Machine dependent hints about ++ processor capabilities. */ ++ ++/* This entry gives some information about the FPU initialization ++ performed by the kernel. */ ++#define AT_FPUCW 18 /* Used FPU control word. */ ++ ++/* Cache block sizes. */ ++#define AT_DCACHEBSIZE 19 /* Data cache block size. */ ++#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ ++#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ ++ ++/* A special ignored value for PPC, used by the kernel to control the ++ interpretation of the AUXV. Must be > 16. */ ++#define AT_IGNOREPPC 22 /* Entry should be ignored. */ ++ ++#define AT_SECURE 23 /* Boolean, was exec setuid-like? */ ++ ++#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/ ++ ++#define AT_RANDOM 25 /* Address of 16 random bytes. */ ++ ++#define AT_EXECFN 31 /* Filename of executable. */ ++ ++/* Pointer to the global system page used for system calls and other ++ nice things. */ ++#define AT_SYSINFO 32 ++#define AT_SYSINFO_EHDR 33 ++ ++/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains ++ log2 of line size; mask those to get cache size. */ ++#define AT_L1I_CACHESHAPE 34 ++#define AT_L1D_CACHESHAPE 35 ++#define AT_L2_CACHESHAPE 36 ++#define AT_L3_CACHESHAPE 37 ++ ++/* Note section contents. Each entry in the note section begins with ++ a header of a fixed form. */ ++ ++typedef struct ++{ ++ Elf32_Word n_namesz; /* Length of the note's name. */ ++ Elf32_Word n_descsz; /* Length of the note's descriptor. */ ++ Elf32_Word n_type; /* Type of the note. */ ++} Elf32_Nhdr; ++ ++typedef struct ++{ ++ Elf64_Word n_namesz; /* Length of the note's name. */ ++ Elf64_Word n_descsz; /* Length of the note's descriptor. */ ++ Elf64_Word n_type; /* Type of the note. */ ++} Elf64_Nhdr; ++ ++/* Known names of notes. */ ++ ++/* Solaris entries in the note section have this name. */ ++#define ELF_NOTE_SOLARIS "SUNW Solaris" ++ ++/* Note entries for GNU systems have this name. */ ++#define ELF_NOTE_GNU "GNU" ++ ++ ++/* Defined types of notes for Solaris. */ ++ ++/* Value of descriptor (one word) is desired pagesize for the binary. */ ++#define ELF_NOTE_PAGESIZE_HINT 1 ++ ++ ++/* Defined note types for GNU systems. */ ++ ++/* ABI information. The descriptor consists of words: ++ word 0: OS descriptor ++ word 1: major version of the ABI ++ word 2: minor version of the ABI ++ word 3: subminor version of the ABI ++*/ ++#define NT_GNU_ABI_TAG 1 ++#define ELF_NOTE_ABI NT_GNU_ABI_TAG /* Old name. */ ++ ++/* Known OSes. These values can appear in word 0 of an ++ NT_GNU_ABI_TAG note section entry. */ ++#define ELF_NOTE_OS_LINUX 0 ++#define ELF_NOTE_OS_GNU 1 ++#define ELF_NOTE_OS_SOLARIS2 2 ++#define ELF_NOTE_OS_FREEBSD 3 ++ ++/* Synthetic hwcap information. The descriptor begins with two words: ++ word 0: number of entries ++ word 1: bitmask of enabled entries ++ Then follow variable-length entries, one byte followed by a ++ '\0'-terminated hwcap name string. The byte gives the bit ++ number to test if enabled, (1U << bit) & bitmask. */ ++#define NT_GNU_HWCAP 2 ++ ++/* Build ID bits as generated by ld --build-id. ++ The descriptor consists of any nonzero number of bytes. */ ++#define NT_GNU_BUILD_ID 3 ++ ++/* Version note generated by GNU gold containing a version string. */ ++#define NT_GNU_GOLD_VERSION 4 ++ ++ ++/* Move records. */ ++typedef struct ++{ ++ Elf32_Xword m_value; /* Symbol value. */ ++ Elf32_Word m_info; /* Size and index. */ ++ Elf32_Word m_poffset; /* Symbol offset. */ ++ Elf32_Half m_repeat; /* Repeat count. */ ++ Elf32_Half m_stride; /* Stride info. */ ++} Elf32_Move; ++ ++typedef struct ++{ ++ Elf64_Xword m_value; /* Symbol value. */ ++ Elf64_Xword m_info; /* Size and index. */ ++ Elf64_Xword m_poffset; /* Symbol offset. */ ++ Elf64_Half m_repeat; /* Repeat count. */ ++ Elf64_Half m_stride; /* Stride info. */ ++} Elf64_Move; ++ ++/* Macro to construct move records. */ ++#define ELF32_M_SYM(info) ((info) >> 8) ++#define ELF32_M_SIZE(info) ((unsigned char) (info)) ++#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) ++ ++#define ELF64_M_SYM(info) ELF32_M_SYM (info) ++#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) ++#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) ++ ++ ++/* Motorola 68k specific definitions. */ ++ ++/* Values for Elf32_Ehdr.e_flags. */ ++#define EF_CPU32 0x00810000 ++ ++/* m68k relocs. */ ++ ++#define R_68K_NONE 0 /* No reloc */ ++#define R_68K_32 1 /* Direct 32 bit */ ++#define R_68K_16 2 /* Direct 16 bit */ ++#define R_68K_8 3 /* Direct 8 bit */ ++#define R_68K_PC32 4 /* PC relative 32 bit */ ++#define R_68K_PC16 5 /* PC relative 16 bit */ ++#define R_68K_PC8 6 /* PC relative 8 bit */ ++#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ ++#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ ++#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ ++#define R_68K_GOT32O 10 /* 32 bit GOT offset */ ++#define R_68K_GOT16O 11 /* 16 bit GOT offset */ ++#define R_68K_GOT8O 12 /* 8 bit GOT offset */ ++#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ ++#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ ++#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ ++#define R_68K_PLT32O 16 /* 32 bit PLT offset */ ++#define R_68K_PLT16O 17 /* 16 bit PLT offset */ ++#define R_68K_PLT8O 18 /* 8 bit PLT offset */ ++#define R_68K_COPY 19 /* Copy symbol at runtime */ ++#define R_68K_GLOB_DAT 20 /* Create GOT entry */ ++#define R_68K_JMP_SLOT 21 /* Create PLT entry */ ++#define R_68K_RELATIVE 22 /* Adjust by program base */ ++#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */ ++#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */ ++#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */ ++#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */ ++#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */ ++#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */ ++#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */ ++#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */ ++#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */ ++#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */ ++#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */ ++#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */ ++#define R_68K_TLS_LE32 37 /* 32 bit offset relative to ++ static TLS block */ ++#define R_68K_TLS_LE16 38 /* 16 bit offset relative to ++ static TLS block */ ++#define R_68K_TLS_LE8 39 /* 8 bit offset relative to ++ static TLS block */ ++#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */ ++#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */ ++#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */ ++/* Keep this the last entry. */ ++#define R_68K_NUM 43 ++ ++/* Intel 80386 specific definitions. */ ++ ++/* i386 relocs. */ ++ ++#define R_386_NONE 0 /* No reloc */ ++#define R_386_32 1 /* Direct 32 bit */ ++#define R_386_PC32 2 /* PC relative 32 bit */ ++#define R_386_GOT32 3 /* 32 bit GOT entry */ ++#define R_386_PLT32 4 /* 32 bit PLT address */ ++#define R_386_COPY 5 /* Copy symbol at runtime */ ++#define R_386_GLOB_DAT 6 /* Create GOT entry */ ++#define R_386_JMP_SLOT 7 /* Create PLT entry */ ++#define R_386_RELATIVE 8 /* Adjust by program base */ ++#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ ++#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ ++#define R_386_32PLT 11 ++#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ ++#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS ++ block offset */ ++#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block ++ offset */ ++#define R_386_TLS_LE 17 /* Offset relative to static TLS ++ block */ ++#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of ++ general dynamic thread local data */ ++#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of ++ local dynamic thread local data ++ in LE code */ ++#define R_386_16 20 ++#define R_386_PC16 21 ++#define R_386_8 22 ++#define R_386_PC8 23 ++#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic ++ thread local data */ ++#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ ++#define R_386_TLS_GD_CALL 26 /* Relocation for call to ++ __tls_get_addr() */ ++#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ ++#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic ++ thread local data in LE code */ ++#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ ++#define R_386_TLS_LDM_CALL 30 /* Relocation for call to ++ __tls_get_addr() in LDM code */ ++#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ ++#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ ++#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS ++ block offset */ ++#define R_386_TLS_LE_32 34 /* Negated offset relative to static ++ TLS block */ ++#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ ++#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ ++#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ ++/* 38? */ ++#define R_386_TLS_GOTDESC 39 /* GOT offset for TLS descriptor. */ ++#define R_386_TLS_DESC_CALL 40 /* Marker of call through TLS ++ descriptor for ++ relaxation. */ ++#define R_386_TLS_DESC 41 /* TLS descriptor containing ++ pointer to code and to ++ argument, returning the TLS ++ offset for the symbol. */ ++#define R_386_IRELATIVE 42 /* Adjust indirectly by program base */ ++/* Keep this the last entry. */ ++#define R_386_NUM 43 ++ ++/* SUN SPARC specific definitions. */ ++ ++/* Legal values for ST_TYPE subfield of st_info (symbol type). */ ++ ++#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */ ++ ++/* Values for Elf64_Ehdr.e_flags. */ ++ ++#define EF_SPARCV9_MM 3 ++#define EF_SPARCV9_TSO 0 ++#define EF_SPARCV9_PSO 1 ++#define EF_SPARCV9_RMO 2 ++#define EF_SPARC_LEDATA 0x800000 /* little endian data */ ++#define EF_SPARC_EXT_MASK 0xFFFF00 ++#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ ++#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ ++#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ ++#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ ++ ++/* SPARC relocs. */ ++ ++#define R_SPARC_NONE 0 /* No reloc */ ++#define R_SPARC_8 1 /* Direct 8 bit */ ++#define R_SPARC_16 2 /* Direct 16 bit */ ++#define R_SPARC_32 3 /* Direct 32 bit */ ++#define R_SPARC_DISP8 4 /* PC relative 8 bit */ ++#define R_SPARC_DISP16 5 /* PC relative 16 bit */ ++#define R_SPARC_DISP32 6 /* PC relative 32 bit */ ++#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ ++#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ ++#define R_SPARC_HI22 9 /* High 22 bit */ ++#define R_SPARC_22 10 /* Direct 22 bit */ ++#define R_SPARC_13 11 /* Direct 13 bit */ ++#define R_SPARC_LO10 12 /* Truncated 10 bit */ ++#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ ++#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ ++#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ ++#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ ++#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ ++#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ ++#define R_SPARC_COPY 19 /* Copy symbol at runtime */ ++#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ ++#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ ++#define R_SPARC_RELATIVE 22 /* Adjust by program base */ ++#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ ++ ++/* Additional Sparc64 relocs. */ ++ ++#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ ++#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ ++#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ ++#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ ++#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ ++#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ ++#define R_SPARC_10 30 /* Direct 10 bit */ ++#define R_SPARC_11 31 /* Direct 11 bit */ ++#define R_SPARC_64 32 /* Direct 64 bit */ ++#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ ++#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ ++#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ ++#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ ++#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ ++#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ ++#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ ++#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ ++#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ ++#define R_SPARC_GLOB_JMP 42 /* was part of v9 ABI but was removed */ ++#define R_SPARC_7 43 /* Direct 7 bit */ ++#define R_SPARC_5 44 /* Direct 5 bit */ ++#define R_SPARC_6 45 /* Direct 6 bit */ ++#define R_SPARC_DISP64 46 /* PC relative 64 bit */ ++#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ ++#define R_SPARC_HIX22 48 /* High 22 bit complemented */ ++#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ ++#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ ++#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ ++#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ ++#define R_SPARC_REGISTER 53 /* Global register usage */ ++#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ ++#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ ++#define R_SPARC_TLS_GD_HI22 56 ++#define R_SPARC_TLS_GD_LO10 57 ++#define R_SPARC_TLS_GD_ADD 58 ++#define R_SPARC_TLS_GD_CALL 59 ++#define R_SPARC_TLS_LDM_HI22 60 ++#define R_SPARC_TLS_LDM_LO10 61 ++#define R_SPARC_TLS_LDM_ADD 62 ++#define R_SPARC_TLS_LDM_CALL 63 ++#define R_SPARC_TLS_LDO_HIX22 64 ++#define R_SPARC_TLS_LDO_LOX10 65 ++#define R_SPARC_TLS_LDO_ADD 66 ++#define R_SPARC_TLS_IE_HI22 67 ++#define R_SPARC_TLS_IE_LO10 68 ++#define R_SPARC_TLS_IE_LD 69 ++#define R_SPARC_TLS_IE_LDX 70 ++#define R_SPARC_TLS_IE_ADD 71 ++#define R_SPARC_TLS_LE_HIX22 72 ++#define R_SPARC_TLS_LE_LOX10 73 ++#define R_SPARC_TLS_DTPMOD32 74 ++#define R_SPARC_TLS_DTPMOD64 75 ++#define R_SPARC_TLS_DTPOFF32 76 ++#define R_SPARC_TLS_DTPOFF64 77 ++#define R_SPARC_TLS_TPOFF32 78 ++#define R_SPARC_TLS_TPOFF64 79 ++#define R_SPARC_GOTDATA_HIX22 80 ++#define R_SPARC_GOTDATA_LOX10 81 ++#define R_SPARC_GOTDATA_OP_HIX22 82 ++#define R_SPARC_GOTDATA_OP_LOX10 83 ++#define R_SPARC_GOTDATA_OP 84 ++#define R_SPARC_H34 85 ++#define R_SPARC_SIZE32 86 ++#define R_SPARC_SIZE64 87 ++#define R_SPARC_WDISP10 88 ++#define R_SPARC_JMP_IREL 248 ++#define R_SPARC_IRELATIVE 249 ++#define R_SPARC_GNU_VTINHERIT 250 ++#define R_SPARC_GNU_VTENTRY 251 ++#define R_SPARC_REV32 252 ++/* Keep this the last entry. */ ++#define R_SPARC_NUM 253 ++ ++/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ ++ ++#define DT_SPARC_REGISTER 0x70000001 ++#define DT_SPARC_NUM 2 ++ ++/* MIPS R3000 specific definitions. */ ++ ++/* Legal values for e_flags field of Elf32_Ehdr. */ ++ ++#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ ++#define EF_MIPS_PIC 2 /* Contains PIC code */ ++#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ ++#define EF_MIPS_XGOT 8 ++#define EF_MIPS_64BIT_WHIRL 16 ++#define EF_MIPS_ABI2 32 ++#define EF_MIPS_ABI_ON32 64 ++#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ ++ ++/* Legal values for MIPS architecture level. */ ++ ++#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ ++#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ ++#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ ++#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ ++#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ ++#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ ++#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ ++ ++/* The following are non-official names and should not be used. */ ++ ++#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ ++#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ ++#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ ++#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ ++#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ ++#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ ++#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ ++ ++/* Special section indices. */ ++ ++#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ ++#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ ++#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ ++#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ ++#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ ++ ++/* Legal values for sh_type field of Elf32_Shdr. */ ++ ++#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ ++#define SHT_MIPS_MSYM 0x70000001 ++#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ ++#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ ++#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ ++#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ ++#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ ++#define SHT_MIPS_PACKAGE 0x70000007 ++#define SHT_MIPS_PACKSYM 0x70000008 ++#define SHT_MIPS_RELD 0x70000009 ++#define SHT_MIPS_IFACE 0x7000000b ++#define SHT_MIPS_CONTENT 0x7000000c ++#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ ++#define SHT_MIPS_SHDR 0x70000010 ++#define SHT_MIPS_FDESC 0x70000011 ++#define SHT_MIPS_EXTSYM 0x70000012 ++#define SHT_MIPS_DENSE 0x70000013 ++#define SHT_MIPS_PDESC 0x70000014 ++#define SHT_MIPS_LOCSYM 0x70000015 ++#define SHT_MIPS_AUXSYM 0x70000016 ++#define SHT_MIPS_OPTSYM 0x70000017 ++#define SHT_MIPS_LOCSTR 0x70000018 ++#define SHT_MIPS_LINE 0x70000019 ++#define SHT_MIPS_RFDESC 0x7000001a ++#define SHT_MIPS_DELTASYM 0x7000001b ++#define SHT_MIPS_DELTAINST 0x7000001c ++#define SHT_MIPS_DELTACLASS 0x7000001d ++#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ ++#define SHT_MIPS_DELTADECL 0x7000001f ++#define SHT_MIPS_SYMBOL_LIB 0x70000020 ++#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ ++#define SHT_MIPS_TRANSLATE 0x70000022 ++#define SHT_MIPS_PIXIE 0x70000023 ++#define SHT_MIPS_XLATE 0x70000024 ++#define SHT_MIPS_XLATE_DEBUG 0x70000025 ++#define SHT_MIPS_WHIRL 0x70000026 ++#define SHT_MIPS_EH_REGION 0x70000027 ++#define SHT_MIPS_XLATE_OLD 0x70000028 ++#define SHT_MIPS_PDR_EXCEPTION 0x70000029 ++ ++/* Legal values for sh_flags field of Elf32_Shdr. */ ++ ++#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ ++#define SHF_MIPS_MERGE 0x20000000 ++#define SHF_MIPS_ADDR 0x40000000 ++#define SHF_MIPS_STRINGS 0x80000000 ++#define SHF_MIPS_NOSTRIP 0x08000000 ++#define SHF_MIPS_LOCAL 0x04000000 ++#define SHF_MIPS_NAMES 0x02000000 ++#define SHF_MIPS_NODUPE 0x01000000 ++ ++ ++/* Symbol tables. */ ++ ++/* MIPS specific values for `st_other'. */ ++#define STO_MIPS_DEFAULT 0x0 ++#define STO_MIPS_INTERNAL 0x1 ++#define STO_MIPS_HIDDEN 0x2 ++#define STO_MIPS_PROTECTED 0x3 ++#define STO_MIPS_PLT 0x8 ++#define STO_MIPS_SC_ALIGN_UNUSED 0xff ++ ++/* MIPS specific values for `st_info'. */ ++#define STB_MIPS_SPLIT_COMMON 13 ++ ++/* Entries found in sections of type SHT_MIPS_GPTAB. */ ++ ++typedef union ++{ ++ struct ++ { ++ Elf32_Word gt_current_g_value; /* -G value used for compilation */ ++ Elf32_Word gt_unused; /* Not used */ ++ } gt_header; /* First entry in section */ ++ struct ++ { ++ Elf32_Word gt_g_value; /* If this value were used for -G */ ++ Elf32_Word gt_bytes; /* This many bytes would be used */ ++ } gt_entry; /* Subsequent entries in section */ ++} Elf32_gptab; ++ ++/* Entry found in sections of type SHT_MIPS_REGINFO. */ ++ ++typedef struct ++{ ++ Elf32_Word ri_gprmask; /* General registers used */ ++ Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ ++ Elf32_Sword ri_gp_value; /* $gp register value */ ++} Elf32_RegInfo; ++ ++/* Entries found in sections of type SHT_MIPS_OPTIONS. */ ++ ++typedef struct ++{ ++ unsigned char kind; /* Determines interpretation of the ++ variable part of descriptor. */ ++ unsigned char size; /* Size of descriptor, including header. */ ++ Elf32_Section section; /* Section header index of section affected, ++ 0 for global options. */ ++ Elf32_Word info; /* Kind-specific information. */ ++} Elf_Options; ++ ++/* Values for `kind' field in Elf_Options. */ ++ ++#define ODK_NULL 0 /* Undefined. */ ++#define ODK_REGINFO 1 /* Register usage information. */ ++#define ODK_EXCEPTIONS 2 /* Exception processing options. */ ++#define ODK_PAD 3 /* Section padding options. */ ++#define ODK_HWPATCH 4 /* Hardware workarounds performed */ ++#define ODK_FILL 5 /* record the fill value used by the linker. */ ++#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ ++#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ ++#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ ++ ++/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ ++ ++#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ ++#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ ++#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ ++#define OEX_SMM 0x20000 /* Force sequential memory mode? */ ++#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ ++#define OEX_PRECISEFP OEX_FPDBUG ++#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ ++ ++#define OEX_FPU_INVAL 0x10 ++#define OEX_FPU_DIV0 0x08 ++#define OEX_FPU_OFLO 0x04 ++#define OEX_FPU_UFLO 0x02 ++#define OEX_FPU_INEX 0x01 ++ ++/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ ++ ++#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ ++#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ ++#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ ++#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ ++ ++#define OPAD_PREFIX 0x1 ++#define OPAD_POSTFIX 0x2 ++#define OPAD_SYMBOL 0x4 ++ ++/* Entry found in `.options' section. */ ++ ++typedef struct ++{ ++ Elf32_Word hwp_flags1; /* Extra flags. */ ++ Elf32_Word hwp_flags2; /* Extra flags. */ ++} Elf_Options_Hw; ++ ++/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ ++ ++#define OHWA0_R4KEOP_CHECKED 0x00000001 ++#define OHWA1_R4KEOP_CLEAN 0x00000002 ++ ++/* MIPS relocs. */ ++ ++#define R_MIPS_NONE 0 /* No reloc */ ++#define R_MIPS_16 1 /* Direct 16 bit */ ++#define R_MIPS_32 2 /* Direct 32 bit */ ++#define R_MIPS_REL32 3 /* PC relative 32 bit */ ++#define R_MIPS_26 4 /* Direct 26 bit shifted */ ++#define R_MIPS_HI16 5 /* High 16 bit */ ++#define R_MIPS_LO16 6 /* Low 16 bit */ ++#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ ++#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ ++#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ ++#define R_MIPS_PC16 10 /* PC relative 16 bit */ ++#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ ++#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ ++ ++#define R_MIPS_SHIFT5 16 ++#define R_MIPS_SHIFT6 17 ++#define R_MIPS_64 18 ++#define R_MIPS_GOT_DISP 19 ++#define R_MIPS_GOT_PAGE 20 ++#define R_MIPS_GOT_OFST 21 ++#define R_MIPS_GOT_HI16 22 ++#define R_MIPS_GOT_LO16 23 ++#define R_MIPS_SUB 24 ++#define R_MIPS_INSERT_A 25 ++#define R_MIPS_INSERT_B 26 ++#define R_MIPS_DELETE 27 ++#define R_MIPS_HIGHER 28 ++#define R_MIPS_HIGHEST 29 ++#define R_MIPS_CALL_HI16 30 ++#define R_MIPS_CALL_LO16 31 ++#define R_MIPS_SCN_DISP 32 ++#define R_MIPS_REL16 33 ++#define R_MIPS_ADD_IMMEDIATE 34 ++#define R_MIPS_PJUMP 35 ++#define R_MIPS_RELGOT 36 ++#define R_MIPS_JALR 37 ++#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ ++#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ ++#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ ++#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ ++#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ ++#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ ++#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ ++#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ ++#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ ++#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ ++#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ ++#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ ++#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ ++#define R_MIPS_GLOB_DAT 51 ++#define R_MIPS_COPY 126 ++#define R_MIPS_JUMP_SLOT 127 ++/* Keep this the last entry. */ ++#define R_MIPS_NUM 128 ++ ++/* Legal values for p_type field of Elf32_Phdr. */ ++ ++#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ ++#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ ++#define PT_MIPS_OPTIONS 0x70000002 ++ ++/* Special program header types. */ ++ ++#define PF_MIPS_LOCAL 0x10000000 ++ ++/* Legal values for d_tag field of Elf32_Dyn. */ ++ ++#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ ++#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ ++#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ ++#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ ++#define DT_MIPS_FLAGS 0x70000005 /* Flags */ ++#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ ++#define DT_MIPS_MSYM 0x70000007 ++#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ ++#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ ++#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ ++#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ ++#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ ++#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ ++#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ ++#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ ++#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ ++#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ ++#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ ++#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in ++ DT_MIPS_DELTA_CLASS. */ ++#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ ++#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in ++ DT_MIPS_DELTA_INSTANCE. */ ++#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ ++#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in ++ DT_MIPS_DELTA_RELOC. */ ++#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta ++ relocations refer to. */ ++#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in ++ DT_MIPS_DELTA_SYM. */ ++#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the ++ class declaration. */ ++#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in ++ DT_MIPS_DELTA_CLASSSYM. */ ++#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ ++#define DT_MIPS_PIXIE_INIT 0x70000023 ++#define DT_MIPS_SYMBOL_LIB 0x70000024 ++#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 ++#define DT_MIPS_LOCAL_GOTIDX 0x70000026 ++#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 ++#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 ++#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ ++#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ ++#define DT_MIPS_DYNSTR_ALIGN 0x7000002b ++#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ ++#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve ++ function stored in GOT. */ ++#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added ++ by rld on dlopen() calls. */ ++#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ ++#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ ++#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ ++/* The address of .got.plt in an executable using the new non-PIC ABI. */ ++#define DT_MIPS_PLTGOT 0x70000032 ++/* The base of the PLT in an executable using the new non-PIC ABI if that ++ PLT is writable. For a non-writable PLT, this is omitted or has a zero ++ value. */ ++#define DT_MIPS_RWPLT 0x70000034 ++#define DT_MIPS_NUM 0x35 ++ ++/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ ++ ++#define RHF_NONE 0 /* No flags */ ++#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ ++#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ ++#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ ++#define RHF_NO_MOVE (1 << 3) ++#define RHF_SGI_ONLY (1 << 4) ++#define RHF_GUARANTEE_INIT (1 << 5) ++#define RHF_DELTA_C_PLUS_PLUS (1 << 6) ++#define RHF_GUARANTEE_START_INIT (1 << 7) ++#define RHF_PIXIE (1 << 8) ++#define RHF_DEFAULT_DELAY_LOAD (1 << 9) ++#define RHF_REQUICKSTART (1 << 10) ++#define RHF_REQUICKSTARTED (1 << 11) ++#define RHF_CORD (1 << 12) ++#define RHF_NO_UNRES_UNDEF (1 << 13) ++#define RHF_RLD_ORDER_SAFE (1 << 14) ++ ++/* Entries found in sections of type SHT_MIPS_LIBLIST. */ ++ ++typedef struct ++{ ++ Elf32_Word l_name; /* Name (string table index) */ ++ Elf32_Word l_time_stamp; /* Timestamp */ ++ Elf32_Word l_checksum; /* Checksum */ ++ Elf32_Word l_version; /* Interface version */ ++ Elf32_Word l_flags; /* Flags */ ++} Elf32_Lib; ++ ++typedef struct ++{ ++ Elf64_Word l_name; /* Name (string table index) */ ++ Elf64_Word l_time_stamp; /* Timestamp */ ++ Elf64_Word l_checksum; /* Checksum */ ++ Elf64_Word l_version; /* Interface version */ ++ Elf64_Word l_flags; /* Flags */ ++} Elf64_Lib; ++ ++ ++/* Legal values for l_flags. */ ++ ++#define LL_NONE 0 ++#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ ++#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ ++#define LL_REQUIRE_MINOR (1 << 2) ++#define LL_EXPORTS (1 << 3) ++#define LL_DELAY_LOAD (1 << 4) ++#define LL_DELTA (1 << 5) ++ ++/* Entries found in sections of type SHT_MIPS_CONFLICT. */ ++ ++typedef Elf32_Addr Elf32_Conflict; ++ ++ ++/* HPPA specific definitions. */ ++ ++/* Legal values for e_flags field of Elf32_Ehdr. */ ++ ++#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ ++#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ ++#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ ++#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ ++#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch ++ prediction. */ ++#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ ++#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ ++ ++/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ ++ ++#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ ++#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ ++#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ ++ ++/* Additional section indeces. */ ++ ++#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared ++ symbols in ANSI C. */ ++#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ ++ ++/* Legal values for sh_type field of Elf32_Shdr. */ ++ ++#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ ++#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ ++#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ ++ ++/* Legal values for sh_flags field of Elf32_Shdr. */ ++ ++#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ ++#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ ++#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ ++ ++/* Legal values for ST_TYPE subfield of st_info (symbol type). */ ++ ++#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ ++ ++#define STT_HP_OPAQUE (STT_LOOS + 0x1) ++#define STT_HP_STUB (STT_LOOS + 0x2) ++ ++/* HPPA relocs. */ ++ ++#define R_PARISC_NONE 0 /* No reloc. */ ++#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ ++#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ ++#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ ++#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ ++#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ ++#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ ++#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ ++#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ ++#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ ++#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ ++#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ ++#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ ++#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ ++#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ ++#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ ++#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ ++#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ ++#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ ++#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ ++#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ ++#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ ++#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ ++#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ ++#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ ++#define R_PARISC_FPTR64 64 /* 64 bits function address. */ ++#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ ++#define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */ ++#define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */ ++#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ ++#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ ++#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ ++#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ ++#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ ++#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ ++#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ ++#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ ++#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ ++#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ ++#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ ++#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ ++#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ ++#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ ++#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ ++#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ ++#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ ++#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ ++#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ ++#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ ++#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ ++#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ ++#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ ++#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ ++#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ ++#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ ++#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ ++#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ ++#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ ++#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ ++#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ ++#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ ++#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ ++#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ ++#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ ++#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ ++#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ ++#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ ++#define R_PARISC_LORESERVE 128 ++#define R_PARISC_COPY 128 /* Copy relocation. */ ++#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ ++#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ ++#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ ++#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ ++#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ ++#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ ++#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ ++#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ ++#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ ++#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ ++#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ ++#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ ++#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ ++#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ ++#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ ++#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ ++#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ ++#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ ++#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ ++#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ ++#define R_PARISC_GNU_VTENTRY 232 ++#define R_PARISC_GNU_VTINHERIT 233 ++#define R_PARISC_TLS_GD21L 234 /* GD 21-bit left. */ ++#define R_PARISC_TLS_GD14R 235 /* GD 14-bit right. */ ++#define R_PARISC_TLS_GDCALL 236 /* GD call to __t_g_a. */ ++#define R_PARISC_TLS_LDM21L 237 /* LD module 21-bit left. */ ++#define R_PARISC_TLS_LDM14R 238 /* LD module 14-bit right. */ ++#define R_PARISC_TLS_LDMCALL 239 /* LD module call to __t_g_a. */ ++#define R_PARISC_TLS_LDO21L 240 /* LD offset 21-bit left. */ ++#define R_PARISC_TLS_LDO14R 241 /* LD offset 14-bit right. */ ++#define R_PARISC_TLS_DTPMOD32 242 /* DTP module 32-bit. */ ++#define R_PARISC_TLS_DTPMOD64 243 /* DTP module 64-bit. */ ++#define R_PARISC_TLS_DTPOFF32 244 /* DTP offset 32-bit. */ ++#define R_PARISC_TLS_DTPOFF64 245 /* DTP offset 32-bit. */ ++#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L ++#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R ++#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L ++#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R ++#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 ++#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 ++#define R_PARISC_HIRESERVE 255 ++ ++/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ ++ ++#define PT_HP_TLS (PT_LOOS + 0x0) ++#define PT_HP_CORE_NONE (PT_LOOS + 0x1) ++#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) ++#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) ++#define PT_HP_CORE_COMM (PT_LOOS + 0x4) ++#define PT_HP_CORE_PROC (PT_LOOS + 0x5) ++#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) ++#define PT_HP_CORE_STACK (PT_LOOS + 0x7) ++#define PT_HP_CORE_SHM (PT_LOOS + 0x8) ++#define PT_HP_CORE_MMF (PT_LOOS + 0x9) ++#define PT_HP_PARALLEL (PT_LOOS + 0x10) ++#define PT_HP_FASTBIND (PT_LOOS + 0x11) ++#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) ++#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) ++#define PT_HP_STACK (PT_LOOS + 0x14) ++ ++#define PT_PARISC_ARCHEXT 0x70000000 ++#define PT_PARISC_UNWIND 0x70000001 ++ ++/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ ++ ++#define PF_PARISC_SBP 0x08000000 ++ ++#define PF_HP_PAGE_SIZE 0x00100000 ++#define PF_HP_FAR_SHARED 0x00200000 ++#define PF_HP_NEAR_SHARED 0x00400000 ++#define PF_HP_CODE 0x01000000 ++#define PF_HP_MODIFY 0x02000000 ++#define PF_HP_LAZYSWAP 0x04000000 ++#define PF_HP_SBP 0x08000000 ++ ++ ++/* Alpha specific definitions. */ ++ ++/* Legal values for e_flags field of Elf64_Ehdr. */ ++ ++#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ ++#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ ++ ++/* Legal values for sh_type field of Elf64_Shdr. */ ++ ++/* These two are primerily concerned with ECOFF debugging info. */ ++#define SHT_ALPHA_DEBUG 0x70000001 ++#define SHT_ALPHA_REGINFO 0x70000002 ++ ++/* Legal values for sh_flags field of Elf64_Shdr. */ ++ ++#define SHF_ALPHA_GPREL 0x10000000 ++ ++/* Legal values for st_other field of Elf64_Sym. */ ++#define STO_ALPHA_NOPV 0x80 /* No PV required. */ ++#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ ++ ++/* Alpha relocs. */ ++ ++#define R_ALPHA_NONE 0 /* No reloc */ ++#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ ++#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ ++#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ ++#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ ++#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ ++#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ ++#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ ++#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ ++#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ ++#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ ++#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ ++#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ ++#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ ++#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ ++#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ ++#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ ++#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ ++#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ ++#define R_ALPHA_TLS_GD_HI 28 ++#define R_ALPHA_TLSGD 29 ++#define R_ALPHA_TLS_LDM 30 ++#define R_ALPHA_DTPMOD64 31 ++#define R_ALPHA_GOTDTPREL 32 ++#define R_ALPHA_DTPREL64 33 ++#define R_ALPHA_DTPRELHI 34 ++#define R_ALPHA_DTPRELLO 35 ++#define R_ALPHA_DTPREL16 36 ++#define R_ALPHA_GOTTPREL 37 ++#define R_ALPHA_TPREL64 38 ++#define R_ALPHA_TPRELHI 39 ++#define R_ALPHA_TPRELLO 40 ++#define R_ALPHA_TPREL16 41 ++/* Keep this the last entry. */ ++#define R_ALPHA_NUM 46 ++ ++/* Magic values of the LITUSE relocation addend. */ ++#define LITUSE_ALPHA_ADDR 0 ++#define LITUSE_ALPHA_BASE 1 ++#define LITUSE_ALPHA_BYTOFF 2 ++#define LITUSE_ALPHA_JSR 3 ++#define LITUSE_ALPHA_TLS_GD 4 ++#define LITUSE_ALPHA_TLS_LDM 5 ++ ++/* Legal values for d_tag of Elf64_Dyn. */ ++#define DT_ALPHA_PLTRO (DT_LOPROC + 0) ++#define DT_ALPHA_NUM 1 ++ ++/* PowerPC specific declarations */ ++ ++/* Values for Elf32/64_Ehdr.e_flags. */ ++#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ ++ ++/* Cygnus local bits below */ ++#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ ++#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib ++ flag */ ++ ++/* PowerPC relocations defined by the ABIs */ ++#define R_PPC_NONE 0 ++#define R_PPC_ADDR32 1 /* 32bit absolute address */ ++#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ ++#define R_PPC_ADDR16 3 /* 16bit absolute address */ ++#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ ++#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ ++#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ ++#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ ++#define R_PPC_ADDR14_BRTAKEN 8 ++#define R_PPC_ADDR14_BRNTAKEN 9 ++#define R_PPC_REL24 10 /* PC relative 26 bit */ ++#define R_PPC_REL14 11 /* PC relative 16 bit */ ++#define R_PPC_REL14_BRTAKEN 12 ++#define R_PPC_REL14_BRNTAKEN 13 ++#define R_PPC_GOT16 14 ++#define R_PPC_GOT16_LO 15 ++#define R_PPC_GOT16_HI 16 ++#define R_PPC_GOT16_HA 17 ++#define R_PPC_PLTREL24 18 ++#define R_PPC_COPY 19 ++#define R_PPC_GLOB_DAT 20 ++#define R_PPC_JMP_SLOT 21 ++#define R_PPC_RELATIVE 22 ++#define R_PPC_LOCAL24PC 23 ++#define R_PPC_UADDR32 24 ++#define R_PPC_UADDR16 25 ++#define R_PPC_REL32 26 ++#define R_PPC_PLT32 27 ++#define R_PPC_PLTREL32 28 ++#define R_PPC_PLT16_LO 29 ++#define R_PPC_PLT16_HI 30 ++#define R_PPC_PLT16_HA 31 ++#define R_PPC_SDAREL16 32 ++#define R_PPC_SECTOFF 33 ++#define R_PPC_SECTOFF_LO 34 ++#define R_PPC_SECTOFF_HI 35 ++#define R_PPC_SECTOFF_HA 36 ++ ++/* PowerPC relocations defined for the TLS access ABI. */ ++#define R_PPC_TLS 67 /* none (sym+add)@tls */ ++#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ ++#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ ++#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ ++#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ ++#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ ++#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ ++#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ ++#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ ++#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ ++#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ ++#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ ++#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ ++#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ ++#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ ++#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ ++#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ ++#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ ++#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ ++#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ ++#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ ++#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ ++#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ ++#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ ++#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ ++#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ ++#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ ++#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ ++ ++/* The remaining relocs are from the Embedded ELF ABI, and are not ++ in the SVR4 ELF ABI. */ ++#define R_PPC_EMB_NADDR32 101 ++#define R_PPC_EMB_NADDR16 102 ++#define R_PPC_EMB_NADDR16_LO 103 ++#define R_PPC_EMB_NADDR16_HI 104 ++#define R_PPC_EMB_NADDR16_HA 105 ++#define R_PPC_EMB_SDAI16 106 ++#define R_PPC_EMB_SDA2I16 107 ++#define R_PPC_EMB_SDA2REL 108 ++#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ ++#define R_PPC_EMB_MRKREF 110 ++#define R_PPC_EMB_RELSEC16 111 ++#define R_PPC_EMB_RELST_LO 112 ++#define R_PPC_EMB_RELST_HI 113 ++#define R_PPC_EMB_RELST_HA 114 ++#define R_PPC_EMB_BIT_FLD 115 ++#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ ++ ++/* Diab tool relocations. */ ++#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ ++#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ ++#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ ++#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ ++#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ ++#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ ++ ++/* GNU extension to support local ifunc. */ ++#define R_PPC_IRELATIVE 248 ++ ++/* GNU relocs used in PIC code sequences. */ ++#define R_PPC_REL16 249 /* half16 (sym+add-.) */ ++#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */ ++#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */ ++#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */ ++ ++/* This is a phony reloc to handle any old fashioned TOC16 references ++ that may still be in object files. */ ++#define R_PPC_TOC16 255 ++ ++/* PowerPC specific values for the Dyn d_tag field. */ ++#define DT_PPC_GOT (DT_LOPROC + 0) ++#define DT_PPC_NUM 1 ++ ++/* PowerPC64 relocations defined by the ABIs */ ++#define R_PPC64_NONE R_PPC_NONE ++#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ ++#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ ++#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ ++#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ ++#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ ++#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ ++#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ ++#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN ++#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN ++#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ ++#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ ++#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN ++#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN ++#define R_PPC64_GOT16 R_PPC_GOT16 ++#define R_PPC64_GOT16_LO R_PPC_GOT16_LO ++#define R_PPC64_GOT16_HI R_PPC_GOT16_HI ++#define R_PPC64_GOT16_HA R_PPC_GOT16_HA ++ ++#define R_PPC64_COPY R_PPC_COPY ++#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT ++#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT ++#define R_PPC64_RELATIVE R_PPC_RELATIVE ++ ++#define R_PPC64_UADDR32 R_PPC_UADDR32 ++#define R_PPC64_UADDR16 R_PPC_UADDR16 ++#define R_PPC64_REL32 R_PPC_REL32 ++#define R_PPC64_PLT32 R_PPC_PLT32 ++#define R_PPC64_PLTREL32 R_PPC_PLTREL32 ++#define R_PPC64_PLT16_LO R_PPC_PLT16_LO ++#define R_PPC64_PLT16_HI R_PPC_PLT16_HI ++#define R_PPC64_PLT16_HA R_PPC_PLT16_HA ++ ++#define R_PPC64_SECTOFF R_PPC_SECTOFF ++#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO ++#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI ++#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA ++#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ ++#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ ++#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ ++#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ ++#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ ++#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ ++#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ ++#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ ++#define R_PPC64_PLT64 45 /* doubleword64 L + A */ ++#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ ++#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ ++#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ ++#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ ++#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ ++#define R_PPC64_TOC 51 /* doubleword64 .TOC */ ++#define R_PPC64_PLTGOT16 52 /* half16* M + A */ ++#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ ++#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ ++#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ ++ ++#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ ++#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ ++#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ ++#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ ++#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ ++#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ ++#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ ++#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ ++#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ ++#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ ++#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ ++ ++/* PowerPC64 relocations defined for the TLS access ABI. */ ++#define R_PPC64_TLS 67 /* none (sym+add)@tls */ ++#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ ++#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ ++#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ ++#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ ++#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ ++#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ ++#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ ++#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ ++#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ ++#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ ++#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ ++#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ ++#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ ++#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ ++#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ ++#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ ++#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ ++#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ ++#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ ++#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ ++#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ ++#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ ++#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ ++#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ ++#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ ++#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ ++#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ ++#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ ++#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ ++#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ ++#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ ++#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ ++#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ ++#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ ++#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ ++#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ ++#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ ++#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ ++#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ ++ ++/* GNU extension to support local ifunc. */ ++#define R_PPC64_JMP_IREL 247 ++#define R_PPC64_IRELATIVE 248 ++#define R_PPC64_REL16 249 /* half16 (sym+add-.) */ ++#define R_PPC64_REL16_LO 250 /* half16 (sym+add-.)@l */ ++#define R_PPC64_REL16_HI 251 /* half16 (sym+add-.)@h */ ++#define R_PPC64_REL16_HA 252 /* half16 (sym+add-.)@ha */ ++ ++/* PowerPC64 specific values for the Dyn d_tag field. */ ++#define DT_PPC64_GLINK (DT_LOPROC + 0) ++#define DT_PPC64_OPD (DT_LOPROC + 1) ++#define DT_PPC64_OPDSZ (DT_LOPROC + 2) ++#define DT_PPC64_NUM 3 ++ ++ ++/* ARM specific declarations */ ++ ++/* Processor specific flags for the ELF header e_flags field. */ ++#define EF_ARM_RELEXEC 0x01 ++#define EF_ARM_HASENTRY 0x02 ++#define EF_ARM_INTERWORK 0x04 ++#define EF_ARM_APCS_26 0x08 ++#define EF_ARM_APCS_FLOAT 0x10 ++#define EF_ARM_PIC 0x20 ++#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ ++#define EF_ARM_NEW_ABI 0x80 ++#define EF_ARM_OLD_ABI 0x100 ++#define EF_ARM_SOFT_FLOAT 0x200 ++#define EF_ARM_VFP_FLOAT 0x400 ++#define EF_ARM_MAVERICK_FLOAT 0x800 ++ ++ ++/* Other constants defined in the ARM ELF spec. version B-01. */ ++/* NB. These conflict with values defined above. */ ++#define EF_ARM_SYMSARESORTED 0x04 ++#define EF_ARM_DYNSYMSUSESEGIDX 0x08 ++#define EF_ARM_MAPSYMSFIRST 0x10 ++#define EF_ARM_EABIMASK 0XFF000000 ++ ++/* Constants defined in AAELF. */ ++#define EF_ARM_BE8 0x00800000 ++#define EF_ARM_LE8 0x00400000 ++ ++#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) ++#define EF_ARM_EABI_UNKNOWN 0x00000000 ++#define EF_ARM_EABI_VER1 0x01000000 ++#define EF_ARM_EABI_VER2 0x02000000 ++#define EF_ARM_EABI_VER3 0x03000000 ++#define EF_ARM_EABI_VER4 0x04000000 ++#define EF_ARM_EABI_VER5 0x05000000 ++ ++/* Additional symbol types for Thumb. */ ++#define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ ++#define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ ++ ++/* ARM-specific values for sh_flags */ ++#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ ++#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined ++ in the input to a link step. */ ++ ++/* ARM-specific program header flags */ ++#define PF_ARM_SB 0x10000000 /* Segment contains the location ++ addressed by the static base. */ ++#define PF_ARM_PI 0x20000000 /* Position-independent segment. */ ++#define PF_ARM_ABS 0x40000000 /* Absolute segment. */ ++ ++/* Processor specific values for the Phdr p_type field. */ ++#define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */ ++ ++/* Processor specific values for the Shdr sh_type field. */ ++#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */ ++#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */ ++#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */ ++ ++ ++/* ARM relocs. */ ++ ++#define R_ARM_NONE 0 /* No reloc */ ++#define R_ARM_PC24 1 /* PC relative 26 bit branch */ ++#define R_ARM_ABS32 2 /* Direct 32 bit */ ++#define R_ARM_REL32 3 /* PC relative 32 bit */ ++#define R_ARM_PC13 4 ++#define R_ARM_ABS16 5 /* Direct 16 bit */ ++#define R_ARM_ABS12 6 /* Direct 12 bit */ ++#define R_ARM_THM_ABS5 7 ++#define R_ARM_ABS8 8 /* Direct 8 bit */ ++#define R_ARM_SBREL32 9 ++#define R_ARM_THM_PC22 10 ++#define R_ARM_THM_PC8 11 ++#define R_ARM_AMP_VCALL9 12 ++#define R_ARM_SWI24 13 /* Obsolete static relocation. */ ++#define R_ARM_TLS_DESC 13 /* Dynamic relocation. */ ++#define R_ARM_THM_SWI8 14 ++#define R_ARM_XPC25 15 ++#define R_ARM_THM_XPC22 16 ++#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ ++#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ ++#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ ++#define R_ARM_COPY 20 /* Copy symbol at runtime */ ++#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ ++#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ ++#define R_ARM_RELATIVE 23 /* Adjust by program base */ ++#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ ++#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ ++#define R_ARM_GOT32 26 /* 32 bit GOT entry */ ++#define R_ARM_PLT32 27 /* 32 bit PLT address */ ++#define R_ARM_ALU_PCREL_7_0 32 ++#define R_ARM_ALU_PCREL_15_8 33 ++#define R_ARM_ALU_PCREL_23_15 34 ++#define R_ARM_LDR_SBREL_11_0 35 ++#define R_ARM_ALU_SBREL_19_12 36 ++#define R_ARM_ALU_SBREL_27_20 37 ++#define R_ARM_TLS_GOTDESC 90 ++#define R_ARM_TLS_CALL 91 ++#define R_ARM_TLS_DESCSEQ 92 ++#define R_ARM_THM_TLS_CALL 93 ++#define R_ARM_GNU_VTENTRY 100 ++#define R_ARM_GNU_VTINHERIT 101 ++#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ ++#define R_ARM_THM_PC9 103 /* thumb conditional branch */ ++#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic ++ thread local data */ ++#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic ++ thread local data */ ++#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS ++ block */ ++#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of ++ static TLS block offset */ ++#define R_ARM_TLS_LE32 108 /* 32 bit offset relative to static ++ TLS block */ ++#define R_ARM_THM_TLS_DESCSEQ 129 ++#define R_ARM_IRELATIVE 160 ++#define R_ARM_RXPC25 249 ++#define R_ARM_RSBREL32 250 ++#define R_ARM_THM_RPC22 251 ++#define R_ARM_RREL32 252 ++#define R_ARM_RABS22 253 ++#define R_ARM_RPC24 254 ++#define R_ARM_RBASE 255 ++/* Keep this the last entry. */ ++#define R_ARM_NUM 256 ++ ++/* IA-64 specific declarations. */ ++ ++/* Processor specific flags for the Ehdr e_flags field. */ ++#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ ++#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ ++#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ ++ ++/* Processor specific values for the Phdr p_type field. */ ++#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ ++#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ ++#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) ++#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) ++#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) ++ ++/* Processor specific flags for the Phdr p_flags field. */ ++#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ ++ ++/* Processor specific values for the Shdr sh_type field. */ ++#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ ++#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ ++ ++/* Processor specific flags for the Shdr sh_flags field. */ ++#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ ++#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ ++ ++/* Processor specific values for the Dyn d_tag field. */ ++#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) ++#define DT_IA_64_NUM 1 ++ ++/* IA-64 relocations. */ ++#define R_IA64_NONE 0x00 /* none */ ++#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ ++#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ ++#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ ++#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ ++#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ ++#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ ++#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ ++#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ ++#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ ++#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ ++#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ ++#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ ++#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ ++#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ ++#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ ++#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ ++#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ ++#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ ++#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ ++#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ ++#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ ++#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ ++#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ ++#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ ++#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ ++#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ ++#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ ++#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ ++#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ ++#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ ++#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ ++#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ ++#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ ++#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ ++#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ ++#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ ++#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ ++#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ ++#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ ++#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ ++#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ ++#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ ++#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ ++#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ ++#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ ++#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ ++#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ ++#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ ++#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ ++#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ ++#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ ++#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ ++#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ ++#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ ++#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ ++#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ ++#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ ++#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ ++#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ ++#define R_IA64_COPY 0x84 /* copy relocation */ ++#define R_IA64_SUB 0x85 /* Addend and symbol difference */ ++#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ ++#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ ++#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ ++#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ ++#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ ++#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ ++#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ ++#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ ++#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ ++#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ ++#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ ++#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ ++#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ ++#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ ++#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ ++#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ ++#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ ++#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ ++#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ ++ ++/* SH specific declarations */ ++ ++/* Processor specific flags for the ELF header e_flags field. */ ++#define EF_SH_MACH_MASK 0x1f ++#define EF_SH_UNKNOWN 0x0 ++#define EF_SH1 0x1 ++#define EF_SH2 0x2 ++#define EF_SH3 0x3 ++#define EF_SH_DSP 0x4 ++#define EF_SH3_DSP 0x5 ++#define EF_SH4AL_DSP 0x6 ++#define EF_SH3E 0x8 ++#define EF_SH4 0x9 ++#define EF_SH2E 0xb ++#define EF_SH4A 0xc ++#define EF_SH2A 0xd ++#define EF_SH4_NOFPU 0x10 ++#define EF_SH4A_NOFPU 0x11 ++#define EF_SH4_NOMMU_NOFPU 0x12 ++#define EF_SH2A_NOFPU 0x13 ++#define EF_SH3_NOMMU 0x14 ++#define EF_SH2A_SH4_NOFPU 0x15 ++#define EF_SH2A_SH3_NOFPU 0x16 ++#define EF_SH2A_SH4 0x17 ++#define EF_SH2A_SH3E 0x18 ++ ++/* SH relocs. */ ++#define R_SH_NONE 0 ++#define R_SH_DIR32 1 ++#define R_SH_REL32 2 ++#define R_SH_DIR8WPN 3 ++#define R_SH_IND12W 4 ++#define R_SH_DIR8WPL 5 ++#define R_SH_DIR8WPZ 6 ++#define R_SH_DIR8BP 7 ++#define R_SH_DIR8W 8 ++#define R_SH_DIR8L 9 ++#define R_SH_SWITCH16 25 ++#define R_SH_SWITCH32 26 ++#define R_SH_USES 27 ++#define R_SH_COUNT 28 ++#define R_SH_ALIGN 29 ++#define R_SH_CODE 30 ++#define R_SH_DATA 31 ++#define R_SH_LABEL 32 ++#define R_SH_SWITCH8 33 ++#define R_SH_GNU_VTINHERIT 34 ++#define R_SH_GNU_VTENTRY 35 ++#define R_SH_TLS_GD_32 144 ++#define R_SH_TLS_LD_32 145 ++#define R_SH_TLS_LDO_32 146 ++#define R_SH_TLS_IE_32 147 ++#define R_SH_TLS_LE_32 148 ++#define R_SH_TLS_DTPMOD32 149 ++#define R_SH_TLS_DTPOFF32 150 ++#define R_SH_TLS_TPOFF32 151 ++#define R_SH_GOT32 160 ++#define R_SH_PLT32 161 ++#define R_SH_COPY 162 ++#define R_SH_GLOB_DAT 163 ++#define R_SH_JMP_SLOT 164 ++#define R_SH_RELATIVE 165 ++#define R_SH_GOTOFF 166 ++#define R_SH_GOTPC 167 ++/* Keep this the last entry. */ ++#define R_SH_NUM 256 ++ ++/* S/390 specific definitions. */ ++ ++/* Valid values for the e_flags field. */ ++ ++#define EF_S390_HIGH_GPRS 0x00000001 /* High GPRs kernel facility needed. */ ++ ++/* Additional s390 relocs */ ++ ++#define R_390_NONE 0 /* No reloc. */ ++#define R_390_8 1 /* Direct 8 bit. */ ++#define R_390_12 2 /* Direct 12 bit. */ ++#define R_390_16 3 /* Direct 16 bit. */ ++#define R_390_32 4 /* Direct 32 bit. */ ++#define R_390_PC32 5 /* PC relative 32 bit. */ ++#define R_390_GOT12 6 /* 12 bit GOT offset. */ ++#define R_390_GOT32 7 /* 32 bit GOT offset. */ ++#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ ++#define R_390_COPY 9 /* Copy symbol at runtime. */ ++#define R_390_GLOB_DAT 10 /* Create GOT entry. */ ++#define R_390_JMP_SLOT 11 /* Create PLT entry. */ ++#define R_390_RELATIVE 12 /* Adjust by program base. */ ++#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ ++#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ ++#define R_390_GOT16 15 /* 16 bit GOT offset. */ ++#define R_390_PC16 16 /* PC relative 16 bit. */ ++#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ ++#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ ++#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ ++#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ ++#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ ++#define R_390_64 22 /* Direct 64 bit. */ ++#define R_390_PC64 23 /* PC relative 64 bit. */ ++#define R_390_GOT64 24 /* 64 bit GOT offset. */ ++#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ ++#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ ++#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ ++#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ ++#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ ++#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ ++#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ ++#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ ++#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ ++#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ ++#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ ++#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ ++#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ ++#define R_390_TLS_GDCALL 38 /* Tag for function call in general ++ dynamic TLS code. */ ++#define R_390_TLS_LDCALL 39 /* Tag for function call in local ++ dynamic TLS code. */ ++#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic ++ thread local data. */ ++#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic ++ thread local data. */ ++#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS ++ block offset. */ ++#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS ++ block offset. */ ++#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS ++ block offset. */ ++#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic ++ thread local data in LE code. */ ++#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic ++ thread local data in LE code. */ ++#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for ++ negated static TLS block offset. */ ++#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for ++ negated static TLS block offset. */ ++#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for ++ negated static TLS block offset. */ ++#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to ++ static TLS block. */ ++#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to ++ static TLS block. */ ++#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS ++ block. */ ++#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS ++ block. */ ++#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ ++#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ ++#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS ++ block. */ ++#define R_390_20 57 /* Direct 20 bit. */ ++#define R_390_GOT20 58 /* 20 bit GOT offset. */ ++#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */ ++#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS ++ block offset. */ ++#define R_390_IRELATIVE 61 /* STT_GNU_IFUNC relocation. */ ++/* Keep this the last entry. */ ++#define R_390_NUM 62 ++ ++ ++/* CRIS relocations. */ ++#define R_CRIS_NONE 0 ++#define R_CRIS_8 1 ++#define R_CRIS_16 2 ++#define R_CRIS_32 3 ++#define R_CRIS_8_PCREL 4 ++#define R_CRIS_16_PCREL 5 ++#define R_CRIS_32_PCREL 6 ++#define R_CRIS_GNU_VTINHERIT 7 ++#define R_CRIS_GNU_VTENTRY 8 ++#define R_CRIS_COPY 9 ++#define R_CRIS_GLOB_DAT 10 ++#define R_CRIS_JUMP_SLOT 11 ++#define R_CRIS_RELATIVE 12 ++#define R_CRIS_16_GOT 13 ++#define R_CRIS_32_GOT 14 ++#define R_CRIS_16_GOTPLT 15 ++#define R_CRIS_32_GOTPLT 16 ++#define R_CRIS_32_GOTREL 17 ++#define R_CRIS_32_PLT_GOTREL 18 ++#define R_CRIS_32_PLT_PCREL 19 ++ ++#define R_CRIS_NUM 20 ++ ++ ++/* AMD x86-64 relocations. */ ++#define R_X86_64_NONE 0 /* No reloc */ ++#define R_X86_64_64 1 /* Direct 64 bit */ ++#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ ++#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ ++#define R_X86_64_PLT32 4 /* 32 bit PLT address */ ++#define R_X86_64_COPY 5 /* Copy symbol at runtime */ ++#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ ++#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ ++#define R_X86_64_RELATIVE 8 /* Adjust by program base */ ++#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative ++ offset to GOT */ ++#define R_X86_64_32 10 /* Direct 32 bit zero extended */ ++#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ ++#define R_X86_64_16 12 /* Direct 16 bit zero extended */ ++#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ ++#define R_X86_64_8 14 /* Direct 8 bit sign extended */ ++#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ ++#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ ++#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ ++#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ ++#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset ++ to two GOT entries for GD symbol */ ++#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset ++ to two GOT entries for LD symbol */ ++#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ ++#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset ++ to GOT entry for IE symbol */ ++#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ ++#define R_X86_64_PC64 24 /* PC relative 64 bit */ ++#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */ ++#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative ++ offset to GOT */ ++#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */ ++#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset ++ to GOT entry */ ++#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */ ++#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */ ++#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset ++ to PLT entry */ ++#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */ ++#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */ ++#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */ ++#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS ++ descriptor. */ ++#define R_X86_64_TLSDESC 36 /* TLS descriptor. */ ++#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */ ++#define R_X86_64_RELATIVE64 38 /* 64-bit adjust by program base */ ++ ++#define R_X86_64_NUM 39 ++ ++ ++/* AM33 relocations. */ ++#define R_MN10300_NONE 0 /* No reloc. */ ++#define R_MN10300_32 1 /* Direct 32 bit. */ ++#define R_MN10300_16 2 /* Direct 16 bit. */ ++#define R_MN10300_8 3 /* Direct 8 bit. */ ++#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */ ++#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */ ++#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */ ++#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */ ++#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */ ++#define R_MN10300_24 9 /* Direct 24 bit. */ ++#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */ ++#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */ ++#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */ ++#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */ ++#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */ ++#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */ ++#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */ ++#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */ ++#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */ ++#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */ ++#define R_MN10300_COPY 20 /* Copy symbol at runtime. */ ++#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */ ++#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */ ++#define R_MN10300_RELATIVE 23 /* Adjust by program base. */ ++ ++#define R_MN10300_NUM 24 ++ ++ ++/* M32R relocs. */ ++#define R_M32R_NONE 0 /* No reloc. */ ++#define R_M32R_16 1 /* Direct 16 bit. */ ++#define R_M32R_32 2 /* Direct 32 bit. */ ++#define R_M32R_24 3 /* Direct 24 bit. */ ++#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */ ++#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */ ++#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */ ++#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */ ++#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */ ++#define R_M32R_LO16 9 /* Low 16 bit. */ ++#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */ ++#define R_M32R_GNU_VTINHERIT 11 ++#define R_M32R_GNU_VTENTRY 12 ++/* M32R relocs use SHT_RELA. */ ++#define R_M32R_16_RELA 33 /* Direct 16 bit. */ ++#define R_M32R_32_RELA 34 /* Direct 32 bit. */ ++#define R_M32R_24_RELA 35 /* Direct 24 bit. */ ++#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */ ++#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */ ++#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */ ++#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */ ++#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */ ++#define R_M32R_LO16_RELA 41 /* Low 16 bit */ ++#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */ ++#define R_M32R_RELA_GNU_VTINHERIT 43 ++#define R_M32R_RELA_GNU_VTENTRY 44 ++#define R_M32R_REL32 45 /* PC relative 32 bit. */ ++ ++#define R_M32R_GOT24 48 /* 24 bit GOT entry */ ++#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */ ++#define R_M32R_COPY 50 /* Copy symbol at runtime */ ++#define R_M32R_GLOB_DAT 51 /* Create GOT entry */ ++#define R_M32R_JMP_SLOT 52 /* Create PLT entry */ ++#define R_M32R_RELATIVE 53 /* Adjust by program base */ ++#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */ ++#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */ ++#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned ++ low */ ++#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed ++ low */ ++#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */ ++#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to ++ GOT with unsigned low */ ++#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to ++ GOT with signed low */ ++#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to ++ GOT */ ++#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT ++ with unsigned low */ ++#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT ++ with signed low */ ++#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ ++#define R_M32R_NUM 256 /* Keep this the last entry. */ ++ ++ ++/* TILEPro relocations. */ ++#define R_TILEPRO_NONE 0 /* No reloc */ ++#define R_TILEPRO_32 1 /* Direct 32 bit */ ++#define R_TILEPRO_16 2 /* Direct 16 bit */ ++#define R_TILEPRO_8 3 /* Direct 8 bit */ ++#define R_TILEPRO_32_PCREL 4 /* PC relative 32 bit */ ++#define R_TILEPRO_16_PCREL 5 /* PC relative 16 bit */ ++#define R_TILEPRO_8_PCREL 6 /* PC relative 8 bit */ ++#define R_TILEPRO_LO16 7 /* Low 16 bit */ ++#define R_TILEPRO_HI16 8 /* High 16 bit */ ++#define R_TILEPRO_HA16 9 /* High 16 bit, adjusted */ ++#define R_TILEPRO_COPY 10 /* Copy relocation */ ++#define R_TILEPRO_GLOB_DAT 11 /* Create GOT entry */ ++#define R_TILEPRO_JMP_SLOT 12 /* Create PLT entry */ ++#define R_TILEPRO_RELATIVE 13 /* Adjust by program base */ ++#define R_TILEPRO_BROFF_X1 14 /* X1 pipe branch offset */ ++#define R_TILEPRO_JOFFLONG_X1 15 /* X1 pipe jump offset */ ++#define R_TILEPRO_JOFFLONG_X1_PLT 16 /* X1 pipe jump offset to PLT */ ++#define R_TILEPRO_IMM8_X0 17 /* X0 pipe 8-bit */ ++#define R_TILEPRO_IMM8_Y0 18 /* Y0 pipe 8-bit */ ++#define R_TILEPRO_IMM8_X1 19 /* X1 pipe 8-bit */ ++#define R_TILEPRO_IMM8_Y1 20 /* Y1 pipe 8-bit */ ++#define R_TILEPRO_MT_IMM15_X1 21 /* X1 pipe mtspr */ ++#define R_TILEPRO_MF_IMM15_X1 22 /* X1 pipe mfspr */ ++#define R_TILEPRO_IMM16_X0 23 /* X0 pipe 16-bit */ ++#define R_TILEPRO_IMM16_X1 24 /* X1 pipe 16-bit */ ++#define R_TILEPRO_IMM16_X0_LO 25 /* X0 pipe low 16-bit */ ++#define R_TILEPRO_IMM16_X1_LO 26 /* X1 pipe low 16-bit */ ++#define R_TILEPRO_IMM16_X0_HI 27 /* X0 pipe high 16-bit */ ++#define R_TILEPRO_IMM16_X1_HI 28 /* X1 pipe high 16-bit */ ++#define R_TILEPRO_IMM16_X0_HA 29 /* X0 pipe high 16-bit, adjusted */ ++#define R_TILEPRO_IMM16_X1_HA 30 /* X1 pipe high 16-bit, adjusted */ ++#define R_TILEPRO_IMM16_X0_PCREL 31 /* X0 pipe PC relative 16 bit */ ++#define R_TILEPRO_IMM16_X1_PCREL 32 /* X1 pipe PC relative 16 bit */ ++#define R_TILEPRO_IMM16_X0_LO_PCREL 33 /* X0 pipe PC relative low 16 bit */ ++#define R_TILEPRO_IMM16_X1_LO_PCREL 34 /* X1 pipe PC relative low 16 bit */ ++#define R_TILEPRO_IMM16_X0_HI_PCREL 35 /* X0 pipe PC relative high 16 bit */ ++#define R_TILEPRO_IMM16_X1_HI_PCREL 36 /* X1 pipe PC relative high 16 bit */ ++#define R_TILEPRO_IMM16_X0_HA_PCREL 37 /* X0 pipe PC relative ha() 16 bit */ ++#define R_TILEPRO_IMM16_X1_HA_PCREL 38 /* X1 pipe PC relative ha() 16 bit */ ++#define R_TILEPRO_IMM16_X0_GOT 39 /* X0 pipe 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X1_GOT 40 /* X1 pipe 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X0_GOT_LO 41 /* X0 pipe low 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X1_GOT_LO 42 /* X1 pipe low 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X0_GOT_HI 43 /* X0 pipe high 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X1_GOT_HI 44 /* X1 pipe high 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X0_GOT_HA 45 /* X0 pipe ha() 16-bit GOT offset */ ++#define R_TILEPRO_IMM16_X1_GOT_HA 46 /* X1 pipe ha() 16-bit GOT offset */ ++#define R_TILEPRO_MMSTART_X0 47 /* X0 pipe mm "start" */ ++#define R_TILEPRO_MMEND_X0 48 /* X0 pipe mm "end" */ ++#define R_TILEPRO_MMSTART_X1 49 /* X1 pipe mm "start" */ ++#define R_TILEPRO_MMEND_X1 50 /* X1 pipe mm "end" */ ++#define R_TILEPRO_SHAMT_X0 51 /* X0 pipe shift amount */ ++#define R_TILEPRO_SHAMT_X1 52 /* X1 pipe shift amount */ ++#define R_TILEPRO_SHAMT_Y0 53 /* Y0 pipe shift amount */ ++#define R_TILEPRO_SHAMT_Y1 54 /* Y1 pipe shift amount */ ++#define R_TILEPRO_DEST_IMM8_X1 55 /* X1 pipe destination 8-bit */ ++/* Relocs 56-59 are currently not defined. */ ++#define R_TILEPRO_TLS_GD_CALL 60 /* "jal" for TLS GD */ ++#define R_TILEPRO_IMM8_X0_TLS_GD_ADD 61 /* X0 pipe "addi" for TLS GD */ ++#define R_TILEPRO_IMM8_X1_TLS_GD_ADD 62 /* X1 pipe "addi" for TLS GD */ ++#define R_TILEPRO_IMM8_Y0_TLS_GD_ADD 63 /* Y0 pipe "addi" for TLS GD */ ++#define R_TILEPRO_IMM8_Y1_TLS_GD_ADD 64 /* Y1 pipe "addi" for TLS GD */ ++#define R_TILEPRO_TLS_IE_LOAD 65 /* "lw_tls" for TLS IE */ ++#define R_TILEPRO_IMM16_X0_TLS_GD 66 /* X0 pipe 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X1_TLS_GD 67 /* X1 pipe 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X0_TLS_GD_LO 68 /* X0 pipe low 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X1_TLS_GD_LO 69 /* X1 pipe low 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X0_TLS_GD_HI 70 /* X0 pipe high 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X1_TLS_GD_HI 71 /* X1 pipe high 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X0_TLS_GD_HA 72 /* X0 pipe ha() 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X1_TLS_GD_HA 73 /* X1 pipe ha() 16-bit TLS GD offset */ ++#define R_TILEPRO_IMM16_X0_TLS_IE 74 /* X0 pipe 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_IE 75 /* X1 pipe 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X0_TLS_IE_LO 76 /* X0 pipe low 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_IE_LO 77 /* X1 pipe low 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X0_TLS_IE_HI 78 /* X0 pipe high 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_IE_HI 79 /* X1 pipe high 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X0_TLS_IE_HA 80 /* X0 pipe ha() 16-bit TLS IE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_IE_HA 81 /* X1 pipe ha() 16-bit TLS IE offset */ ++#define R_TILEPRO_TLS_DTPMOD32 82 /* ID of module containing symbol */ ++#define R_TILEPRO_TLS_DTPOFF32 83 /* Offset in TLS block */ ++#define R_TILEPRO_TLS_TPOFF32 84 /* Offset in static TLS block */ ++#define R_TILEPRO_IMM16_X0_TLS_LE 85 /* X0 pipe 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_LE 86 /* X1 pipe 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X0_TLS_LE_LO 87 /* X0 pipe low 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_LE_LO 88 /* X1 pipe low 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X0_TLS_LE_HI 89 /* X0 pipe high 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_LE_HI 90 /* X1 pipe high 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X0_TLS_LE_HA 91 /* X0 pipe ha() 16-bit TLS LE offset */ ++#define R_TILEPRO_IMM16_X1_TLS_LE_HA 92 /* X1 pipe ha() 16-bit TLS LE offset */ ++ ++#define R_TILEPRO_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */ ++#define R_TILEPRO_GNU_VTENTRY 129 /* GNU C++ vtable member usage */ ++ ++#define R_TILEPRO_NUM 130 ++ ++ ++/* TILE-Gx relocations. */ ++#define R_TILEGX_NONE 0 /* No reloc */ ++#define R_TILEGX_64 1 /* Direct 64 bit */ ++#define R_TILEGX_32 2 /* Direct 32 bit */ ++#define R_TILEGX_16 3 /* Direct 16 bit */ ++#define R_TILEGX_8 4 /* Direct 8 bit */ ++#define R_TILEGX_64_PCREL 5 /* PC relative 64 bit */ ++#define R_TILEGX_32_PCREL 6 /* PC relative 32 bit */ ++#define R_TILEGX_16_PCREL 7 /* PC relative 16 bit */ ++#define R_TILEGX_8_PCREL 8 /* PC relative 8 bit */ ++#define R_TILEGX_HW0 9 /* hword 0 16-bit */ ++#define R_TILEGX_HW1 10 /* hword 1 16-bit */ ++#define R_TILEGX_HW2 11 /* hword 2 16-bit */ ++#define R_TILEGX_HW3 12 /* hword 3 16-bit */ ++#define R_TILEGX_HW0_LAST 13 /* last hword 0 16-bit */ ++#define R_TILEGX_HW1_LAST 14 /* last hword 1 16-bit */ ++#define R_TILEGX_HW2_LAST 15 /* last hword 2 16-bit */ ++#define R_TILEGX_COPY 16 /* Copy relocation */ ++#define R_TILEGX_GLOB_DAT 17 /* Create GOT entry */ ++#define R_TILEGX_JMP_SLOT 18 /* Create PLT entry */ ++#define R_TILEGX_RELATIVE 19 /* Adjust by program base */ ++#define R_TILEGX_BROFF_X1 20 /* X1 pipe branch offset */ ++#define R_TILEGX_JUMPOFF_X1 21 /* X1 pipe jump offset */ ++#define R_TILEGX_JUMPOFF_X1_PLT 22 /* X1 pipe jump offset to PLT */ ++#define R_TILEGX_IMM8_X0 23 /* X0 pipe 8-bit */ ++#define R_TILEGX_IMM8_Y0 24 /* Y0 pipe 8-bit */ ++#define R_TILEGX_IMM8_X1 25 /* X1 pipe 8-bit */ ++#define R_TILEGX_IMM8_Y1 26 /* Y1 pipe 8-bit */ ++#define R_TILEGX_DEST_IMM8_X1 27 /* X1 pipe destination 8-bit */ ++#define R_TILEGX_MT_IMM14_X1 28 /* X1 pipe mtspr */ ++#define R_TILEGX_MF_IMM14_X1 29 /* X1 pipe mfspr */ ++#define R_TILEGX_MMSTART_X0 30 /* X0 pipe mm "start" */ ++#define R_TILEGX_MMEND_X0 31 /* X0 pipe mm "end" */ ++#define R_TILEGX_SHAMT_X0 32 /* X0 pipe shift amount */ ++#define R_TILEGX_SHAMT_X1 33 /* X1 pipe shift amount */ ++#define R_TILEGX_SHAMT_Y0 34 /* Y0 pipe shift amount */ ++#define R_TILEGX_SHAMT_Y1 35 /* Y1 pipe shift amount */ ++#define R_TILEGX_IMM16_X0_HW0 36 /* X0 pipe hword 0 */ ++#define R_TILEGX_IMM16_X1_HW0 37 /* X1 pipe hword 0 */ ++#define R_TILEGX_IMM16_X0_HW1 38 /* X0 pipe hword 1 */ ++#define R_TILEGX_IMM16_X1_HW1 39 /* X1 pipe hword 1 */ ++#define R_TILEGX_IMM16_X0_HW2 40 /* X0 pipe hword 2 */ ++#define R_TILEGX_IMM16_X1_HW2 41 /* X1 pipe hword 2 */ ++#define R_TILEGX_IMM16_X0_HW3 42 /* X0 pipe hword 3 */ ++#define R_TILEGX_IMM16_X1_HW3 43 /* X1 pipe hword 3 */ ++#define R_TILEGX_IMM16_X0_HW0_LAST 44 /* X0 pipe last hword 0 */ ++#define R_TILEGX_IMM16_X1_HW0_LAST 45 /* X1 pipe last hword 0 */ ++#define R_TILEGX_IMM16_X0_HW1_LAST 46 /* X0 pipe last hword 1 */ ++#define R_TILEGX_IMM16_X1_HW1_LAST 47 /* X1 pipe last hword 1 */ ++#define R_TILEGX_IMM16_X0_HW2_LAST 48 /* X0 pipe last hword 2 */ ++#define R_TILEGX_IMM16_X1_HW2_LAST 49 /* X1 pipe last hword 2 */ ++#define R_TILEGX_IMM16_X0_HW0_PCREL 50 /* X0 pipe PC relative hword 0 */ ++#define R_TILEGX_IMM16_X1_HW0_PCREL 51 /* X1 pipe PC relative hword 0 */ ++#define R_TILEGX_IMM16_X0_HW1_PCREL 52 /* X0 pipe PC relative hword 1 */ ++#define R_TILEGX_IMM16_X1_HW1_PCREL 53 /* X1 pipe PC relative hword 1 */ ++#define R_TILEGX_IMM16_X0_HW2_PCREL 54 /* X0 pipe PC relative hword 2 */ ++#define R_TILEGX_IMM16_X1_HW2_PCREL 55 /* X1 pipe PC relative hword 2 */ ++#define R_TILEGX_IMM16_X0_HW3_PCREL 56 /* X0 pipe PC relative hword 3 */ ++#define R_TILEGX_IMM16_X1_HW3_PCREL 57 /* X1 pipe PC relative hword 3 */ ++#define R_TILEGX_IMM16_X0_HW0_LAST_PCREL 58 /* X0 pipe PC-rel last hword 0 */ ++#define R_TILEGX_IMM16_X1_HW0_LAST_PCREL 59 /* X1 pipe PC-rel last hword 0 */ ++#define R_TILEGX_IMM16_X0_HW1_LAST_PCREL 60 /* X0 pipe PC-rel last hword 1 */ ++#define R_TILEGX_IMM16_X1_HW1_LAST_PCREL 61 /* X1 pipe PC-rel last hword 1 */ ++#define R_TILEGX_IMM16_X0_HW2_LAST_PCREL 62 /* X0 pipe PC-rel last hword 2 */ ++#define R_TILEGX_IMM16_X1_HW2_LAST_PCREL 63 /* X1 pipe PC-rel last hword 2 */ ++#define R_TILEGX_IMM16_X0_HW0_GOT 64 /* X0 pipe hword 0 GOT offset */ ++#define R_TILEGX_IMM16_X1_HW0_GOT 65 /* X1 pipe hword 0 GOT offset */ ++/* Relocs 66-71 are currently not defined. */ ++#define R_TILEGX_IMM16_X0_HW0_LAST_GOT 72 /* X0 pipe last hword 0 GOT offset */ ++#define R_TILEGX_IMM16_X1_HW0_LAST_GOT 73 /* X1 pipe last hword 0 GOT offset */ ++#define R_TILEGX_IMM16_X0_HW1_LAST_GOT 74 /* X0 pipe last hword 1 GOT offset */ ++#define R_TILEGX_IMM16_X1_HW1_LAST_GOT 75 /* X1 pipe last hword 1 GOT offset */ ++/* Relocs 76-77 are currently not defined. */ ++#define R_TILEGX_IMM16_X0_HW0_TLS_GD 78 /* X0 pipe hword 0 TLS GD offset */ ++#define R_TILEGX_IMM16_X1_HW0_TLS_GD 79 /* X1 pipe hword 0 TLS GD offset */ ++#define R_TILEGX_IMM16_X0_HW0_TLS_LE 80 /* X0 pipe hword 0 TLS LE offset */ ++#define R_TILEGX_IMM16_X1_HW0_TLS_LE 81 /* X1 pipe hword 0 TLS LE offset */ ++#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE 82 /* X0 pipe last hword 0 LE off */ ++#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE 83 /* X1 pipe last hword 0 LE off */ ++#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE 84 /* X0 pipe last hword 1 LE off */ ++#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE 85 /* X1 pipe last hword 1 LE off */ ++#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD 86 /* X0 pipe last hword 0 GD off */ ++#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD 87 /* X1 pipe last hword 0 GD off */ ++#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD 88 /* X0 pipe last hword 1 GD off */ ++#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD 89 /* X1 pipe last hword 1 GD off */ ++/* Relocs 90-91 are currently not defined. */ ++#define R_TILEGX_IMM16_X0_HW0_TLS_IE 92 /* X0 pipe hword 0 TLS IE offset */ ++#define R_TILEGX_IMM16_X1_HW0_TLS_IE 93 /* X1 pipe hword 0 TLS IE offset */ ++/* Relocs 94-99 are currently not defined. */ ++#define R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE 100 /* X0 pipe last hword 0 IE off */ ++#define R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE 101 /* X1 pipe last hword 0 IE off */ ++#define R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE 102 /* X0 pipe last hword 1 IE off */ ++#define R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE 103 /* X1 pipe last hword 1 IE off */ ++/* Relocs 104-105 are currently not defined. */ ++#define R_TILEGX_TLS_DTPMOD64 106 /* 64-bit ID of symbol's module */ ++#define R_TILEGX_TLS_DTPOFF64 107 /* 64-bit offset in TLS block */ ++#define R_TILEGX_TLS_TPOFF64 108 /* 64-bit offset in static TLS block */ ++#define R_TILEGX_TLS_DTPMOD32 109 /* 32-bit ID of symbol's module */ ++#define R_TILEGX_TLS_DTPOFF32 110 /* 32-bit offset in TLS block */ ++#define R_TILEGX_TLS_TPOFF32 111 /* 32-bit offset in static TLS block */ ++#define R_TILEGX_TLS_GD_CALL 112 /* "jal" for TLS GD */ ++#define R_TILEGX_IMM8_X0_TLS_GD_ADD 113 /* X0 pipe "addi" for TLS GD */ ++#define R_TILEGX_IMM8_X1_TLS_GD_ADD 114 /* X1 pipe "addi" for TLS GD */ ++#define R_TILEGX_IMM8_Y0_TLS_GD_ADD 115 /* Y0 pipe "addi" for TLS GD */ ++#define R_TILEGX_IMM8_Y1_TLS_GD_ADD 116 /* Y1 pipe "addi" for TLS GD */ ++#define R_TILEGX_TLS_IE_LOAD 117 /* "ld_tls" for TLS IE */ ++#define R_TILEGX_IMM8_X0_TLS_ADD 118 /* X0 pipe "addi" for TLS GD/IE */ ++#define R_TILEGX_IMM8_X1_TLS_ADD 119 /* X1 pipe "addi" for TLS GD/IE */ ++#define R_TILEGX_IMM8_Y0_TLS_ADD 120 /* Y0 pipe "addi" for TLS GD/IE */ ++#define R_TILEGX_IMM8_Y1_TLS_ADD 121 /* Y1 pipe "addi" for TLS GD/IE */ ++ ++#define R_TILEGX_GNU_VTINHERIT 128 /* GNU C++ vtable hierarchy */ ++#define R_TILEGX_GNU_VTENTRY 129 /* GNU C++ vtable member usage */ ++ ++#define R_TILEGX_NUM 130 ++ ++#endif /* elf.h */ +--- a/scripts/mod/mk_elfconfig.c ++++ b/scripts/mod/mk_elfconfig.c +@@ -2,7 +2,11 @@ + #include + #include + #include ++#ifndef __APPLE__ + #include ++#else ++#include "elf.h" ++#endif + + int + main(int argc, char **argv) +--- a/scripts/mod/modpost.h ++++ b/scripts/mod/modpost.h +@@ -10,7 +10,11 @@ + #include + #include + #include ++#if !(defined(__APPLE__) || defined(__CYGWIN__)) + #include ++#else ++#include "elf.h" ++#endif + #include "../../include/linux/module_symbol.h" + + #include diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/211-darwin-uuid-typedef-clash.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/211-darwin-uuid-typedef-clash.patch new file mode 100755 index 0000000..c0e0b24 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/211-darwin-uuid-typedef-clash.patch @@ -0,0 +1,22 @@ +From e44fc2af1ddc452b6659d08c16973d65c73b7d0a Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Wed, 5 Feb 2020 18:36:43 +0000 +Subject: [PATCH] file2alias: build on macos + +Signed-off-by: Kevin Darbyshire-Bryant +--- + scripts/mod/file2alias.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/scripts/mod/file2alias.c ++++ b/scripts/mod/file2alias.c +@@ -35,6 +35,9 @@ typedef uint32_t __u32; + typedef uint16_t __u16; + typedef unsigned char __u8; + ++#ifdef __APPLE__ ++#define uuid_t compat_uuid_t ++#endif + /* UUID types for backward compatibility, don't use in new code */ + typedef struct { + __u8 b[16]; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/214-spidev_h_portability.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/214-spidev_h_portability.patch new file mode 100755 index 0000000..db754a2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/214-spidev_h_portability.patch @@ -0,0 +1,24 @@ +From be9be95ff10e16a5b4ad36f903978d0cc5747024 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Fri, 7 Jul 2017 17:04:08 +0200 +Subject: kernel: fix linux/spi/spidev.h portability issues with musl + +Felix will try to get this define included into musl + +lede-commit: 795e7cf60de19e7a076a46874fab7bb88b43bbff +Signed-off-by: Felix Fietkau +--- + include/uapi/linux/spi/spidev.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/uapi/linux/spi/spidev.h ++++ b/include/uapi/linux/spi/spidev.h +@@ -93,7 +93,7 @@ struct spi_ioc_transfer { + + /* not all platforms use or _IOC_TYPECHECK() ... */ + #define SPI_MSGSIZE(N) \ +- ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << _IOC_SIZEBITS)) \ ++ ((((N)*(sizeof (struct spi_ioc_transfer))) < (1 << 13)) \ + ? ((N)*(sizeof (struct spi_ioc_transfer))) : 0) + #define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)]) + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/230-openwrt_lzma_options.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/230-openwrt_lzma_options.patch new file mode 100755 index 0000000..20f2b29 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/230-openwrt_lzma_options.patch @@ -0,0 +1,38 @@ +From b3d00b452467f621317953d9e4c6f9ae8dcfd271 Mon Sep 17 00:00:00 2001 +From: Imre Kaloz +Date: Fri, 7 Jul 2017 17:06:55 +0200 +Subject: use the openwrt lzma options for now + +lede-commit: 548de949f392049420a6a1feeef118b30ab8ea8c +Signed-off-by: Imre Kaloz +--- + lib/decompress.c | 1 + + scripts/Makefile.lib | 2 +- + usr/gen_initramfs_list.sh | 10 +++++----- + 3 files changed, 7 insertions(+), 6 deletions(-) + +--- a/lib/decompress.c ++++ b/lib/decompress.c +@@ -53,6 +53,7 @@ static const struct compress_format comp + { {0x1f, 0x9e}, "gzip", gunzip }, + { {0x42, 0x5a}, "bzip2", bunzip2 }, + { {0x5d, 0x00}, "lzma", unlzma }, ++ { {0x6d, 0x00}, "lzma-openwrt", unlzma }, + { {0xfd, 0x37}, "xz", unxz }, + { {0x89, 0x4c}, "lzo", unlzo }, + { {0x02, 0x21}, "lz4", unlz4 }, +--- a/scripts/Makefile.lib ++++ b/scripts/Makefile.lib +@@ -359,10 +359,10 @@ quiet_cmd_bzip2_with_size = BZIP2 $@ + # --------------------------------------------------------------------------- + + quiet_cmd_lzma = LZMA $@ +- cmd_lzma = cat $(real-prereqs) | $(LZMA) -9 > $@ ++ cmd_lzma = cat $(real-prereqs) | $(LZMA) e -d20 -lc1 -lp2 -pb2 -eos -si -so > $@ + + quiet_cmd_lzma_with_size = LZMA $@ +- cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ ++ cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) e -d20 -lc1 -lp2 -pb2 -eos -si -so; $(size_append); } > $@ + + quiet_cmd_lzo = LZO $@ + cmd_lzo = cat $(real-prereqs) | $(KLZOP) -9 > $@ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/249-udp-tunnel-selection.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/249-udp-tunnel-selection.patch new file mode 100755 index 0000000..7f7e5f1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/249-udp-tunnel-selection.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Andy Chiang +Date: Thu, 20 Nov 2025 20:37:53 +0700 +Subject: [PATCH] kernel: fix build of kmod-udptunnel4 and kmod-udptunnel6 + +This fixes the following errors: +``` +make[4]: Entering directory '/home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.12.57' + MODPOST /home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/ovpn-dco-0.2.20250801/drivers/net/ovpn-dco/Module.symvers +ERROR: modpost: "udp_tunnel6_xmit_skb" [/home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/ovpn-dco-0.2.20250801/drivers/net/ovpn-dco/ovpn-dco-v2.ko] undefined! +ERROR: modpost: "setup_udp_tunnel_sock" [/home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/ovpn-dco-0.2.20250801/drivers/net/ovpn-dco/ovpn-dco-v2.ko] undefined! +ERROR: modpost: "udp_tunnel_xmit_skb" [/home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/ovpn-dco-0.2.20250801/drivers/net/ovpn-dco/ovpn-dco-v2.ko] undefined! +make[6]: *** [scripts/Makefile.modpost:145: /home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/ovpn-dco-0.2.20250801/drivers/net/ovpn-dco/Module.symvers] Error 1 +make[5]: *** [/home/runner/work/OP/OP/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.12.57/Makefile:1897: modpost] Error 2 +make[4]: *** [Makefile:224: __sub-make] Error 2 +``` + +ref https://github.com/openwrt/openwrt/commit/1d15a96b29dcd0947690951a7c36aead79a27129 +fixes: https://github.com/openwrt/packages/issues/22998 + +Signed-off-by: Andy Chiang +--- + net/ipv4/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/ipv4/Kconfig ++++ b/net/ipv4/Kconfig +@@ -315,7 +315,7 @@ config NET_IPVTI + on top. + + config NET_UDP_TUNNEL +- tristate ++ tristate "IP: UDP tunneling support" + select NET_IP_TUNNEL + default n + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/250-netfilter_depends.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/250-netfilter_depends.patch new file mode 100755 index 0000000..43faa99 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/250-netfilter_depends.patch @@ -0,0 +1,27 @@ +From: Felix Fietkau +Subject: hack: net: remove bogus netfilter dependencies + +lede-commit: 589d2a377dee27d206fc3725325309cf649e4df6 +Signed-off-by: Felix Fietkau +--- + net/netfilter/Kconfig | 2 -- + 1 file changed, 2 deletions(-) + +--- a/net/netfilter/Kconfig ++++ b/net/netfilter/Kconfig +@@ -259,7 +259,6 @@ config NF_CONNTRACK_FTP + + config NF_CONNTRACK_H323 + tristate "H.323 protocol support" +- depends on IPV6 || IPV6=n + depends on NETFILTER_ADVANCED + help + H.323 is a VoIP signalling protocol from ITU-T. As one of the most +@@ -1120,7 +1119,6 @@ config NETFILTER_XT_TARGET_SECMARK + + config NETFILTER_XT_TARGET_TCPMSS + tristate '"TCPMSS" target support' +- depends on IPV6 || IPV6=n + default m if NETFILTER_ADVANCED=n + help + This option adds a `TCPMSS' target, which allows you to alter the diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/251-kconfig.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/251-kconfig.patch new file mode 100755 index 0000000..dd73e79 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/251-kconfig.patch @@ -0,0 +1,157 @@ +From da3c50704f14132f4adf80d48e9a4cd5d46e54c9 Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Fri, 7 Jul 2017 17:09:21 +0200 +Subject: kconfig: owrt specifc dependencies + +Signed-off-by: John Crispin +--- + crypto/Kconfig | 10 +++++----- + drivers/bcma/Kconfig | 1 + + drivers/ssb/Kconfig | 3 ++- + lib/Kconfig | 8 ++++---- + net/netfilter/Kconfig | 2 +- + net/wireless/Kconfig | 17 ++++++++++------- + sound/core/Kconfig | 4 ++-- + 7 files changed, 25 insertions(+), 20 deletions(-) + +--- a/crypto/Kconfig ++++ b/crypto/Kconfig +@@ -55,7 +55,7 @@ config CRYPTO_FIPS_VERSION + By default the KERNELRELEASE value is used. + + config CRYPTO_ALGAPI +- tristate ++ tristate "ALGAPI" + select CRYPTO_ALGAPI2 + help + This option provides the API for cryptographic algorithms. +@@ -64,7 +64,7 @@ config CRYPTO_ALGAPI2 + tristate + + config CRYPTO_AEAD +- tristate ++ tristate "AEAD" + select CRYPTO_AEAD2 + select CRYPTO_ALGAPI + +@@ -82,7 +82,7 @@ config CRYPTO_SIG2 + select CRYPTO_ALGAPI2 + + config CRYPTO_SKCIPHER +- tristate ++ tristate "SKCIPHER" + select CRYPTO_SKCIPHER2 + select CRYPTO_ALGAPI + select CRYPTO_ECB +@@ -92,7 +92,7 @@ config CRYPTO_SKCIPHER2 + select CRYPTO_ALGAPI2 + + config CRYPTO_HASH +- tristate ++ tristate "HASH" + select CRYPTO_HASH2 + select CRYPTO_ALGAPI + +@@ -101,7 +101,7 @@ config CRYPTO_HASH2 + select CRYPTO_ALGAPI2 + + config CRYPTO_RNG +- tristate ++ tristate "RNG" + select CRYPTO_RNG2 + select CRYPTO_ALGAPI + +--- a/drivers/bcma/Kconfig ++++ b/drivers/bcma/Kconfig +@@ -16,6 +16,7 @@ if BCMA + # Support for Block-I/O. SELECT this from the driver that needs it. + config BCMA_BLOCKIO + bool ++ default y + + config BCMA_HOST_PCI_POSSIBLE + bool +--- a/drivers/ssb/Kconfig ++++ b/drivers/ssb/Kconfig +@@ -29,6 +29,7 @@ config SSB_SPROM + config SSB_BLOCKIO + bool + depends on SSB ++ default y + + config SSB_PCIHOST_POSSIBLE + bool +@@ -49,7 +50,7 @@ config SSB_PCIHOST + config SSB_B43_PCI_BRIDGE + bool + depends on SSB_PCIHOST +- default n ++ default y + + config SSB_PCMCIAHOST_POSSIBLE + bool +--- a/lib/Kconfig ++++ b/lib/Kconfig +@@ -457,16 +457,16 @@ config BCH_CONST_T + # Textsearch support is select'ed if needed + # + config TEXTSEARCH +- bool ++ bool "Textsearch support" + + config TEXTSEARCH_KMP +- tristate ++ tristate "Textsearch KMP" + + config TEXTSEARCH_BM +- tristate ++ tristate "Textsearch BM" + + config TEXTSEARCH_FSM +- tristate ++ tristate "Textsearch FSM" + + config BTREE + bool +--- a/net/netfilter/Kconfig ++++ b/net/netfilter/Kconfig +@@ -22,7 +22,7 @@ config NETFILTER_SKIP_EGRESS + def_bool NETFILTER_EGRESS && (NET_CLS_ACT || IFB) + + config NETFILTER_NETLINK +- tristate ++ tristate "Netfilter NFNETLINK interface" + + config NETFILTER_FAMILY_BRIDGE + bool +--- a/sound/core/Kconfig ++++ b/sound/core/Kconfig +@@ -17,7 +17,7 @@ config SND_DMAENGINE_PCM + tristate + + config SND_HWDEP +- tristate ++ tristate "Sound hardware support" + + config SND_SEQ_DEVICE + tristate +@@ -57,7 +57,7 @@ config SND_CORE_TEST + + + config SND_COMPRESS_OFFLOAD +- tristate ++ tristate "Compression offloading support" + + config SND_JACK + bool +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -484,7 +484,7 @@ config NET_DEVLINK + default n + + config PAGE_POOL +- bool ++ bool "Page pool support" + + config PAGE_POOL_STATS + default n diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/253-ksmbd-config.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/253-ksmbd-config.patch new file mode 100755 index 0000000..d9587fb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/253-ksmbd-config.patch @@ -0,0 +1,32 @@ +From dcd966fa7ca63f38cf7147e1184d13d66e2ca340 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 13:33:30 +0200 +Subject: [PATCH] Kconfig: add tristate for OID and ASNI string + +--- + init/Kconfig | 2 +- + lib/Kconfig | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -2063,7 +2063,7 @@ config PADATA + bool + + config ASN1 +- tristate ++ tristate "ASN1" + help + Build a simple ASN.1 grammar compiler that produces a bytecode output + that can be interpreted by the ASN.1 stream decoder and used to +--- a/lib/Kconfig ++++ b/lib/Kconfig +@@ -642,7 +642,7 @@ config LIBFDT + bool + + config OID_REGISTRY +- tristate ++ tristate "OID" + help + Enable fast lookup object identifier registry. + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/259-regmap_dynamic.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/259-regmap_dynamic.patch new file mode 100755 index 0000000..4f48fc0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/259-regmap_dynamic.patch @@ -0,0 +1,156 @@ +From 811d9e2268a62b830cfe93cd8bc929afcb8b198b Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sat, 15 Jul 2017 21:12:38 +0200 +Subject: kernel: move regmap bloat out of the kernel image if it is only being used in modules + +lede-commit: 96f39119815028073583e4fca3a9c5fe9141e998 +Signed-off-by: Felix Fietkau +--- + drivers/base/regmap/Kconfig | 15 ++++++++++----- + drivers/base/regmap/Makefile | 12 ++++++++---- + drivers/base/regmap/regmap.c | 3 +++ + include/linux/regmap.h | 2 +- + 4 files changed, 22 insertions(+), 10 deletions(-) + +--- a/drivers/base/regmap/Kconfig ++++ b/drivers/base/regmap/Kconfig +@@ -4,8 +4,7 @@ + # subsystems should select the appropriate symbols. + + config REGMAP +- bool +- default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO || REGMAP_FSI) ++ tristate + select IRQ_DOMAIN if REGMAP_IRQ + select MDIO_BUS if REGMAP_MDIO + help +@@ -19,7 +18,7 @@ config REGMAP + + config REGMAP_KUNIT + tristate "KUnit tests for regmap" +- depends on KUNIT && REGMAP ++ depends on KUNIT + default KUNIT_ALL_TESTS + select REGMAP_RAM + +@@ -34,60 +33,76 @@ config REGMAP_BUILD + normally enabled. + + config REGMAP_AC97 ++ select REGMAP + tristate + + config REGMAP_I2C ++ select REGMAP + tristate + depends on I2C + + config REGMAP_SLIMBUS ++ select REGMAP + tristate + depends on SLIMBUS + + config REGMAP_SPI ++ select REGMAP + tristate + depends on SPI + + config REGMAP_SPMI ++ select REGMAP + tristate + depends on SPMI + + config REGMAP_W1 ++ select REGMAP + tristate + depends on W1 + + config REGMAP_MDIO ++ select REGMAP + tristate + + config REGMAP_MMIO ++ select REGMAP + tristate + + config REGMAP_IRQ ++ select REGMAP + bool + + config REGMAP_RAM ++ select REGMAP + tristate + + config REGMAP_SOUNDWIRE ++ select REGMAP + tristate + depends on SOUNDWIRE + + config REGMAP_SOUNDWIRE_MBQ ++ select REGMAP + tristate + depends on SOUNDWIRE + + config REGMAP_SCCB ++ select REGMAP + tristate + depends on I2C + + config REGMAP_I3C ++ select REGMAP + tristate + depends on I3C + + config REGMAP_SPI_AVMM ++ select REGMAP + tristate + depends on SPI + + config REGMAP_FSI ++ select REGMAP + tristate + depends on FSI +--- a/drivers/base/regmap/Makefile ++++ b/drivers/base/regmap/Makefile +@@ -2,9 +2,11 @@ + # For include/trace/define_trace.h to include trace.h + CFLAGS_regmap.o := -I$(src) + +-obj-$(CONFIG_REGMAP) += regmap.o regcache.o +-obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o regcache-maple.o +-obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o ++regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o regcache-maple.o ++ifdef CONFIG_DEBUG_FS ++regmap-core-objs += regmap-debugfs.o ++endif ++obj-$(CONFIG_REGMAP) += regmap-core.o + obj-$(CONFIG_REGMAP_KUNIT) += regmap-kunit.o + obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o + obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o +--- a/drivers/base/regmap/regmap.c ++++ b/drivers/base/regmap/regmap.c +@@ -9,6 +9,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -3523,3 +3524,5 @@ static int __init regmap_initcall(void) + return 0; + } + postcore_initcall(regmap_initcall); ++ ++MODULE_LICENSE("GPL"); +--- a/include/linux/regmap.h ++++ b/include/linux/regmap.h +@@ -197,7 +197,7 @@ struct reg_sequence { + __ret ?: __tmp; \ + }) + +-#ifdef CONFIG_REGMAP ++#if IS_REACHABLE(CONFIG_REGMAP) + + enum regmap_endian { + /* Unspecified -> 0 -> Backwards compatible default */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/260-crypto_test_dependencies.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/260-crypto_test_dependencies.patch new file mode 100755 index 0000000..ce900a8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/260-crypto_test_dependencies.patch @@ -0,0 +1,54 @@ +From fd1799b0bf5efa46dd3e6dfbbf3955564807e508 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Fri, 7 Jul 2017 17:12:51 +0200 +Subject: kernel: prevent cryptomgr from pulling in useless extra dependencies for tests that are not run + +Reduces kernel size after LZMA by about 5k on MIPS + +lede-commit: 044c316167e076479a344c59905e5b435b84a77f +Signed-off-by: Felix Fietkau +--- + crypto/Kconfig | 13 ++++++------- + crypto/algboss.c | 4 ++++ + 2 files changed, 10 insertions(+), 7 deletions(-) + +--- a/crypto/Kconfig ++++ b/crypto/Kconfig +@@ -149,15 +149,15 @@ config CRYPTO_MANAGER + cbc(aes). + + config CRYPTO_MANAGER2 +- def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y) +- select CRYPTO_ACOMP2 +- select CRYPTO_AEAD2 +- select CRYPTO_AKCIPHER2 +- select CRYPTO_SIG2 +- select CRYPTO_HASH2 +- select CRYPTO_KPP2 +- select CRYPTO_RNG2 +- select CRYPTO_SKCIPHER2 ++ def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y && !CRYPTO_MANAGER_DISABLE_TESTS) ++ select CRYPTO_ACOMP2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_AEAD2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_AKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_SIG2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_HASH2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_KPP2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_RNG2 if !CRYPTO_MANAGER_DISABLE_TESTS ++ select CRYPTO_SKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS + + config CRYPTO_USER + tristate "Userspace cryptographic algorithm configuration" +--- a/crypto/algboss.c ++++ b/crypto/algboss.c +@@ -203,6 +203,10 @@ static int cryptomgr_schedule_test(struc + memcpy(param->alg, alg->cra_name, sizeof(param->alg)); + param->type = alg->cra_flags; + ++#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS ++ param->type |= CRYPTO_ALG_TESTED; ++#endif ++ + thread = kthread_run(cryptomgr_test, param, "cryptomgr_test"); + if (IS_ERR(thread)) + goto err_free_param; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/261-lib-arc4-unhide.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/261-lib-arc4-unhide.patch new file mode 100755 index 0000000..f1e1ad4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/261-lib-arc4-unhide.patch @@ -0,0 +1,24 @@ +From 241e5d3f7b0dd3c01f8c7fa83cbc9a3882286d53 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 13:35:18 +0200 +Subject: [PATCH] lib/crypto: add tristate string for ARC4 + +This makes it possible to select CONFIG_CRYPTO_LIB_ARC4 directly. We +need this to be able to compile this into the kernel and make use of it +from backports. + +--- + lib/crypto/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/lib/crypto/Kconfig ++++ b/lib/crypto/Kconfig +@@ -20,7 +20,7 @@ config CRYPTO_LIB_AESGCM + select CRYPTO_LIB_UTILS + + config CRYPTO_LIB_ARC4 +- tristate ++ tristate "ARC4 cipher library" + + config CRYPTO_LIB_GF128MUL + tristate diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/280-rfkill-stubs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/280-rfkill-stubs.patch new file mode 100755 index 0000000..ff6638f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/280-rfkill-stubs.patch @@ -0,0 +1,84 @@ +From 236c1acdfef5958010ac9814a9872e0a46fd78ee Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Fri, 7 Jul 2017 17:13:44 +0200 +Subject: rfkill: add fake rfkill support + +allow building of modules depending on RFKILL even if RFKILL is not enabled. + +Signed-off-by: John Crispin +--- + include/linux/rfkill.h | 2 +- + net/Makefile | 2 +- + net/rfkill/Kconfig | 14 +++++++++----- + net/rfkill/Makefile | 2 +- + 4 files changed, 12 insertions(+), 8 deletions(-) + +--- a/include/linux/rfkill.h ++++ b/include/linux/rfkill.h +@@ -64,7 +64,7 @@ struct rfkill_ops { + int (*set_block)(void *data, bool blocked); + }; + +-#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) ++#if defined(CONFIG_RFKILL_FULL) || defined(CONFIG_RFKILL_FULL_MODULE) + /** + * rfkill_alloc - Allocate rfkill structure + * @name: name of the struct -- the string is not copied internally +--- a/net/Makefile ++++ b/net/Makefile +@@ -51,7 +51,7 @@ obj-$(CONFIG_TIPC) += tipc/ + obj-$(CONFIG_NETLABEL) += netlabel/ + obj-$(CONFIG_IUCV) += iucv/ + obj-$(CONFIG_SMC) += smc/ +-obj-$(CONFIG_RFKILL) += rfkill/ ++obj-$(CONFIG_RFKILL_FULL) += rfkill/ + obj-$(CONFIG_NET_9P) += 9p/ + obj-$(CONFIG_CAIF) += caif/ + obj-$(CONFIG_DCB) += dcb/ +--- a/net/rfkill/Kconfig ++++ b/net/rfkill/Kconfig +@@ -2,7 +2,11 @@ + # + # RF switch subsystem configuration + # +-menuconfig RFKILL ++config RFKILL ++ bool ++ default y ++ ++menuconfig RFKILL_FULL + tristate "RF switch subsystem support" + help + Say Y here if you want to have control over RF switches +@@ -14,19 +18,19 @@ menuconfig RFKILL + # LED trigger support + config RFKILL_LEDS + bool +- depends on RFKILL ++ depends on RFKILL_FULL + depends on LEDS_TRIGGERS = y || RFKILL = LEDS_TRIGGERS + default y + + config RFKILL_INPUT + bool "RF switch input support" if EXPERT +- depends on RFKILL ++ depends on RFKILL_FULL + depends on INPUT = y || RFKILL = INPUT + default y if !EXPERT + + config RFKILL_GPIO + tristate "GPIO RFKILL driver" +- depends on RFKILL ++ depends on RFKILL_FULL + depends on GPIOLIB || COMPILE_TEST + default n + help +--- a/net/rfkill/Makefile ++++ b/net/rfkill/Makefile +@@ -5,5 +5,5 @@ + + rfkill-y += core.o + rfkill-$(CONFIG_RFKILL_INPUT) += input.o +-obj-$(CONFIG_RFKILL) += rfkill.o ++obj-$(CONFIG_RFKILL_FULL) += rfkill.o + obj-$(CONFIG_RFKILL_GPIO) += rfkill-gpio.o diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch new file mode 100755 index 0000000..6ee98eb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch @@ -0,0 +1,64 @@ +From: Ben Menchaca +Date: Fri, 7 Jun 2013 18:35:22 -0500 +Subject: MIPS: r4k_cache: use more efficient cache blast + +Optimize the compiler output for larger cache blast cases that are +common for DMA-based networking. + +Signed-off-by: Ben Menchaca +Signed-off-by: Felix Fietkau +--- +--- a/arch/mips/include/asm/r4kcache.h ++++ b/arch/mips/include/asm/r4kcache.h +@@ -290,14 +290,46 @@ static inline void prot##extra##blast_## + unsigned long end) \ + { \ + unsigned long lsize = cpu_##desc##_line_size(); \ ++ unsigned long lsize_2 = lsize * 2; \ ++ unsigned long lsize_3 = lsize * 3; \ ++ unsigned long lsize_4 = lsize * 4; \ ++ unsigned long lsize_5 = lsize * 5; \ ++ unsigned long lsize_6 = lsize * 6; \ ++ unsigned long lsize_7 = lsize * 7; \ ++ unsigned long lsize_8 = lsize * 8; \ + unsigned long addr = start & ~(lsize - 1); \ +- unsigned long aend = (end - 1) & ~(lsize - 1); \ ++ unsigned long aend = (end + lsize - 1) & ~(lsize - 1); \ ++ int lines = (aend - addr) / lsize; \ + \ +- while (1) { \ ++ while (lines >= 8) { \ ++ prot##cache_op(hitop, addr); \ ++ prot##cache_op(hitop, addr + lsize); \ ++ prot##cache_op(hitop, addr + lsize_2); \ ++ prot##cache_op(hitop, addr + lsize_3); \ ++ prot##cache_op(hitop, addr + lsize_4); \ ++ prot##cache_op(hitop, addr + lsize_5); \ ++ prot##cache_op(hitop, addr + lsize_6); \ ++ prot##cache_op(hitop, addr + lsize_7); \ ++ addr += lsize_8; \ ++ lines -= 8; \ ++ } \ ++ \ ++ if (lines & 0x4) { \ ++ prot##cache_op(hitop, addr); \ ++ prot##cache_op(hitop, addr + lsize); \ ++ prot##cache_op(hitop, addr + lsize_2); \ ++ prot##cache_op(hitop, addr + lsize_3); \ ++ addr += lsize_4; \ ++ } \ ++ \ ++ if (lines & 0x2) { \ ++ prot##cache_op(hitop, addr); \ ++ prot##cache_op(hitop, addr + lsize); \ ++ addr += lsize_2; \ ++ } \ ++ \ ++ if (lines & 0x1) { \ + prot##cache_op(hitop, addr); \ +- if (addr == aend) \ +- break; \ +- addr += lsize; \ + } \ + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/301-01-mm-permit-to-declare-custom-execmem-alloc-free-funct.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/301-01-mm-permit-to-declare-custom-execmem-alloc-free-funct.patch new file mode 100755 index 0000000..3128ed3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/301-01-mm-permit-to-declare-custom-execmem-alloc-free-funct.patch @@ -0,0 +1,62 @@ +From: Christian Marangi +Date: Mon, 14 Apr 2025 18:04:25 +0200 +Subject: [PATCH 1/2] mm: permit to declare custom execmem alloc/free function + +Permit to declare custom execmem alloc/free function that bypass the +execmem API. This works by making the alloc/free function weak +permitting an arch to declare a replacement for them. + +Signed-off-by: Christian Marangi +Co-authored-by: Shiji Yang +--- + include/linux/moduleloader.h | 4 ++++ + mm/execmem.c | 14 ++++++++++++-- + 2 files changed, 16 insertions(+), 2 deletions(-) + +--- a/include/linux/moduleloader.h ++++ b/include/linux/moduleloader.h +@@ -122,4 +122,8 @@ void module_arch_cleanup(struct module * + /* Any cleanup before freeing mod->module_init */ + void module_arch_freeing_init(struct module *mod); + ++enum execmem_type; ++void *arch_execmem_alloc(enum execmem_type type, size_t size); ++void arch_execmem_free(void *ptr); ++ + #endif +--- a/mm/execmem.c ++++ b/mm/execmem.c +@@ -52,14 +52,19 @@ static void *__execmem_alloc(struct exec + return kasan_reset_tag(p); + } + +-void *execmem_alloc(enum execmem_type type, size_t size) ++void *__weak arch_execmem_alloc(enum execmem_type type, size_t size) + { + struct execmem_range *range = &execmem_info->ranges[type]; + + return __execmem_alloc(range, size); + } + +-void execmem_free(void *ptr) ++void *execmem_alloc(enum execmem_type type, size_t size) ++{ ++ return arch_execmem_alloc(type, size); ++} ++ ++void __weak arch_execmem_free(void *ptr) + { + /* + * This memory may be RO, and freeing RO memory in an interrupt is not +@@ -69,6 +74,11 @@ void execmem_free(void *ptr) + vfree(ptr); + } + ++void execmem_free(void *ptr) ++{ ++ arch_execmem_free(ptr); ++} ++ + static bool execmem_validate(struct execmem_info *info) + { + struct execmem_range *r = &info->ranges[EXECMEM_DEFAULT]; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/301-02-mips-replace-mlong-calls-with-mno-long-calls-if-poss.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/301-02-mips-replace-mlong-calls-with-mno-long-calls-if-poss.patch new file mode 100755 index 0000000..eaf4de1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/301-02-mips-replace-mlong-calls-with-mno-long-calls-if-poss.patch @@ -0,0 +1,396 @@ +From: Felix Fietkau +Date: Mon, 14 Apr 2025 18:05:45 +0200 +Subject: [PATCH 2/2] mips: replace -mlong-calls with -mno-long-calls if + possible + +This is a really old patch ported from MikroTik. It needs a an +additional patch to actually be implemented and both this and the old +one are considered HACK as they bypass normal kernel linux to make it +work. + +The original message quote: + +replace -mlong-calls with -mno-long-calls to make function +calls faster in kernel modules to achieve this, try to load +kernel modules to KSEG0 and if that doesn't work, use vmalloc +and fix up relocations with a jump table based on code from a +kernel patch by MikroTik. + +SVN-Revision: 16772 + +lede-commit: 3b3d64743ba2a874df9d70cd19e242205b0a788c +Signed-off-by: Felix Fietkau +Signed-off-by: Christian Marangi +--- + arch/mips/Makefile | 10 ++ + arch/mips/include/asm/module.h | 5 + + arch/mips/kernel/module.c | 281 ++++++++++++++++++++++++++++++++- + 3 files changed, 292 insertions(+), 4 deletions(-) + +--- a/arch/mips/Makefile ++++ b/arch/mips/Makefile +@@ -97,8 +97,18 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin + cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely + cflags-y += -msoft-float -Wa,-msoft-float + LDFLAGS_vmlinux += -G 0 -static -n -nostdlib ++ifdef CONFIG_64BIT + KBUILD_AFLAGS_MODULE += -mlong-calls + KBUILD_CFLAGS_MODULE += -mlong-calls ++else ++ ifdef CONFIG_DYNAMIC_FTRACE ++ KBUILD_AFLAGS_MODULE += -mlong-calls ++ KBUILD_CFLAGS_MODULE += -mlong-calls ++ else ++ KBUILD_AFLAGS_MODULE += -mno-long-calls ++ KBUILD_CFLAGS_MODULE += -mno-long-calls ++ endif ++endif + + ifeq ($(CONFIG_RELOCATABLE),y) + LDFLAGS_vmlinux += --emit-relocs +--- a/arch/mips/include/asm/module.h ++++ b/arch/mips/include/asm/module.h +@@ -12,6 +12,11 @@ struct mod_arch_specific { + const struct exception_table_entry *dbe_start; + const struct exception_table_entry *dbe_end; + struct mips_hi16 *r_mips_hi16_list; ++ ++ void *phys_plt_tbl; ++ void *virt_plt_tbl; ++ unsigned int phys_plt_offset; ++ unsigned int virt_plt_offset; + }; + + typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ +--- a/arch/mips/kernel/module.c ++++ b/arch/mips/kernel/module.c +@@ -8,6 +8,7 @@ + + #undef DEBUG + ++#include + #include + #include + #include +@@ -19,6 +20,7 @@ + #include + #include + #include ++#include + #include + + struct mips_hi16 { +@@ -30,14 +32,254 @@ struct mips_hi16 { + static LIST_HEAD(dbe_list); + static DEFINE_SPINLOCK(dbe_lock); + ++/* ++ * Get the potential max trampolines size required of the init and ++ * non-init sections. Only used if we cannot find enough contiguous ++ * physically mapped memory to put the module into. ++ */ ++static unsigned int ++get_plt_size(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, ++ const char *secstrings, unsigned int symindex, bool is_init) ++{ ++ unsigned long ret = 0; ++ unsigned int i, j; ++ Elf_Sym *syms; ++ ++ /* Everything marked ALLOC (this includes the exported symbols) */ ++ for (i = 1; i < hdr->e_shnum; ++i) { ++ unsigned int info = sechdrs[i].sh_info; ++ ++ if (sechdrs[i].sh_type != SHT_REL ++ && sechdrs[i].sh_type != SHT_RELA) ++ continue; ++ ++ /* Not a valid relocation section? */ ++ if (info >= hdr->e_shnum) ++ continue; ++ ++ /* Don't bother with non-allocated sections */ ++ if (!(sechdrs[info].sh_flags & SHF_ALLOC)) ++ continue; ++ ++ /* If it's called *.init*, and we're not init, we're ++ not interested */ ++ if ((strstr(secstrings + sechdrs[i].sh_name, ".init") != 0) ++ != is_init) ++ continue; ++ ++ syms = (Elf_Sym *) sechdrs[symindex].sh_addr; ++ if (sechdrs[i].sh_type == SHT_REL) { ++ Elf_Mips_Rel *rel = (void *) sechdrs[i].sh_addr; ++ unsigned int size = sechdrs[i].sh_size / sizeof(*rel); ++ ++ for (j = 0; j < size; ++j) { ++ Elf_Sym *sym; ++ ++ if (ELF_MIPS_R_TYPE(rel[j]) != R_MIPS_26) ++ continue; ++ ++ sym = syms + ELF_MIPS_R_SYM(rel[j]); ++ if (!is_init && sym->st_shndx != SHN_UNDEF) ++ continue; ++ ++ ret += 4 * sizeof(int); ++ } ++ } else { ++ Elf_Mips_Rela *rela = (void *) sechdrs[i].sh_addr; ++ unsigned int size = sechdrs[i].sh_size / sizeof(*rela); ++ ++ for (j = 0; j < size; ++j) { ++ Elf_Sym *sym; ++ ++ if (ELF_MIPS_R_TYPE(rela[j]) != R_MIPS_26) ++ continue; ++ ++ sym = syms + ELF_MIPS_R_SYM(rela[j]); ++ if (!is_init && sym->st_shndx != SHN_UNDEF) ++ continue; ++ ++ ret += 4 * sizeof(int); ++ } ++ } ++ } ++ ++ return ret; ++} ++ ++#ifndef MODULES_VADDR ++static void *alloc_phys(unsigned long size) ++{ ++ unsigned order; ++ struct page *page; ++ struct page *p; ++ ++ size = PAGE_ALIGN(size); ++ order = get_order(size); ++ ++ page = alloc_pages(GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN | ++ __GFP_THISNODE, order); ++ if (!page) ++ return NULL; ++ ++ split_page(page, order); ++ ++ /* mark all pages except for the last one */ ++ for (p = page; p + 1 < page + (size >> PAGE_SHIFT); ++p) ++ set_bit(PG_owner_priv_1, &p->flags); ++ ++ for (p = page + (size >> PAGE_SHIFT); p < page + (1 << order); ++p) ++ __free_page(p); ++ ++ return page_address(page); ++} ++ ++static void free_phys(void *ptr) ++{ ++ struct page *page; ++ bool free; ++ ++ page = virt_to_page(ptr); ++ do { ++ free = test_and_clear_bit(PG_owner_priv_1, &page->flags); ++ __free_page(page); ++ page++; ++ } while (free); ++} ++ ++void *arch_execmem_alloc(enum execmem_type type, ++ size_t size) ++{ ++ void *ptr; ++ ++ ptr = alloc_phys(size); ++ ++ /* If we failed to allocate physically contiguous memory, ++ * fall back to regular vmalloc. The module loader code will ++ * create jump tables to handle long jumps */ ++ if (!ptr) ++ return vmalloc(size); ++ ++ return ptr; ++} ++#endif ++ ++static inline bool is_phys_addr(void *ptr) ++{ ++#ifdef CONFIG_64BIT ++ return (KSEGX((unsigned long)ptr) == CKSEG0); ++#else ++ return (KSEGX(ptr) == KSEG0); ++#endif ++} ++ ++#ifndef MODULES_VADDR ++/* Free memory returned from module_alloc */ ++void arch_execmem_free(void *ptr) ++{ ++ if (is_phys_addr(ptr)) ++ free_phys(ptr); ++ else ++ vfree(ptr); ++} ++#endif ++ ++static void *__module_alloc(int size, bool phys) ++{ ++ void *ptr; ++ ++ if (phys) ++ ptr = kmalloc(size, GFP_KERNEL); ++ else ++ ptr = vmalloc(size); ++ return ptr; ++} ++ ++static void __module_free(void *ptr) ++{ ++ if (is_phys_addr(ptr)) ++ kfree(ptr); ++ else ++ vfree(ptr); ++} ++ ++int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, ++ char *secstrings, struct module *mod) ++{ ++ unsigned int symindex = 0; ++ unsigned int core_size, init_size; ++ int i; ++ ++ mod->arch.phys_plt_offset = 0; ++ mod->arch.virt_plt_offset = 0; ++ mod->arch.phys_plt_tbl = NULL; ++ mod->arch.virt_plt_tbl = NULL; ++ ++ if (IS_ENABLED(CONFIG_64BIT)) ++ return 0; ++ ++ for (i = 1; i < hdr->e_shnum; i++) ++ if (sechdrs[i].sh_type == SHT_SYMTAB) ++ symindex = i; ++ ++ core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false); ++ init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true); ++ ++ if ((core_size + init_size) == 0) ++ return 0; ++ ++ mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1); ++ if (!mod->arch.phys_plt_tbl) ++ return -ENOMEM; ++ ++ mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0); ++ if (!mod->arch.virt_plt_tbl) { ++ __module_free(mod->arch.phys_plt_tbl); ++ mod->arch.phys_plt_tbl = NULL; ++ return -ENOMEM; ++ } ++ ++ return 0; ++} ++ + static void apply_r_mips_32(u32 *location, u32 base, Elf_Addr v) + { + *location = base + v; + } + ++static Elf_Addr add_plt_entry_to(unsigned *plt_offset, ++ void *start, Elf_Addr v) ++{ ++ unsigned *tramp = start + *plt_offset; ++ *plt_offset += 4 * sizeof(int); ++ ++ /* adjust carry for addiu */ ++ if (v & 0x00008000) ++ v += 0x10000; ++ ++ tramp[0] = 0x3c190000 | (v >> 16); /* lui t9, hi16 */ ++ tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */ ++ tramp[2] = 0x03200008; /* jr t9 */ ++ tramp[3] = 0x00000000; /* nop */ ++ ++ return (Elf_Addr) tramp; ++} ++ ++static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) ++{ ++ if (is_phys_addr(location)) ++ return add_plt_entry_to(&me->arch.phys_plt_offset, ++ me->arch.phys_plt_tbl, v); ++ else ++ return add_plt_entry_to(&me->arch.virt_plt_offset, ++ me->arch.virt_plt_tbl, v); ++ ++} ++ + static int apply_r_mips_26(struct module *me, u32 *location, u32 base, + Elf_Addr v) + { ++ u32 ofs = base & 0x03ffffff; ++ + if (v % 4) { + pr_err("module %s: dangerous R_MIPS_26 relocation\n", + me->name); +@@ -45,13 +287,17 @@ static int apply_r_mips_26(struct module + } + + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { +- pr_err("module %s: relocation overflow\n", +- me->name); +- return -ENOEXEC; ++ v = add_plt_entry(me, location, v + (ofs << 2)); ++ if (!v) { ++ pr_err("module %s: relocation overflow\n", ++ me->name); ++ return -ENOEXEC; ++ } ++ ofs = 0; + } + + *location = (*location & ~0x03ffffff) | +- ((base + (v >> 2)) & 0x03ffffff); ++ ((ofs + (v >> 2)) & 0x03ffffff); + + return 0; + } +@@ -431,9 +677,36 @@ int module_finalize(const Elf_Ehdr *hdr, + list_add(&me->arch.dbe_list, &dbe_list); + spin_unlock_irq(&dbe_lock); + } ++ ++ /* Get rid of the fixup trampoline if we're running the module ++ * from physically mapped address space */ ++ if (me->arch.phys_plt_offset == 0) { ++ __module_free(me->arch.phys_plt_tbl); ++ me->arch.phys_plt_tbl = NULL; ++ } ++ if (me->arch.virt_plt_offset == 0) { ++ __module_free(me->arch.virt_plt_tbl); ++ me->arch.virt_plt_tbl = NULL; ++ } ++ + return 0; + } + ++void module_arch_freeing_init(struct module *mod) ++{ ++ if (mod->state == MODULE_STATE_LIVE) ++ return; ++ ++ if (mod->arch.phys_plt_tbl) { ++ __module_free(mod->arch.phys_plt_tbl); ++ mod->arch.phys_plt_tbl = NULL; ++ } ++ if (mod->arch.virt_plt_tbl) { ++ __module_free(mod->arch.virt_plt_tbl); ++ mod->arch.virt_plt_tbl = NULL; ++ } ++} ++ + void module_arch_cleanup(struct module *mod) + { + spin_lock_irq(&dbe_lock); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/402-mtd-blktrans-call-add-disks-after-mtd-device.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/402-mtd-blktrans-call-add-disks-after-mtd-device.patch new file mode 100755 index 0000000..d5a68d6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/402-mtd-blktrans-call-add-disks-after-mtd-device.patch @@ -0,0 +1,112 @@ +From 0bccc3722bdd88e8ae995e77ef9f7b77ee4cbdee Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 7 Apr 2021 22:45:54 +0100 +Subject: [PATCH 2/2] mtd: blktrans: call add disks after mtd device +To: linux-mtd@lists.infradead.org +Cc: Vignesh Raghavendra , + Richard Weinberger , + Miquel Raynal , + David Woodhouse + +Calling device_add_disk while holding mtd_table_mutex leads +to deadlock in case part_bits!=0 as block partition parsers +will try to open the newly created disks, trying to acquire +mutex once again. +Move device_add_disk to additional function called after +add partitions of an MTD device have been added and locks +have been released. + +Signed-off-by: Daniel Golle +--- + drivers/mtd/mtd_blkdevs.c | 33 ++++++++++++++++++++++++++------- + drivers/mtd/mtdcore.c | 3 +++ + include/linux/mtd/blktrans.h | 1 + + 3 files changed, 30 insertions(+), 7 deletions(-) + +--- a/drivers/mtd/mtd_blkdevs.c ++++ b/drivers/mtd/mtd_blkdevs.c +@@ -379,19 +379,8 @@ int add_mtd_blktrans_dev(struct mtd_blkt + if (new->readonly) + set_disk_ro(gd, 1); + +- ret = device_add_disk(&new->mtd->dev, gd, NULL); +- if (ret) +- goto out_cleanup_disk; +- +- if (new->disk_attributes) { +- ret = sysfs_create_group(&disk_to_dev(gd)->kobj, +- new->disk_attributes); +- WARN_ON(ret); +- } + return 0; + +-out_cleanup_disk: +- put_disk(new->disk); + out_free_tag_set: + blk_mq_free_tag_set(new->tag_set); + out_kfree_tag_set: +@@ -401,6 +390,35 @@ out_list_del: + return ret; + } + ++void register_mtd_blktrans_devs(void) ++{ ++ struct mtd_blktrans_ops *tr; ++ struct mtd_blktrans_dev *dev, *next; ++ int ret; ++ ++ list_for_each_entry(tr, &blktrans_majors, list) { ++ list_for_each_entry_safe(dev, next, &tr->devs, list) { ++ if (disk_live(dev->disk)) ++ continue; ++ ++ ret = device_add_disk(&dev->mtd->dev, dev->disk, NULL); ++ if (ret) ++ goto out_cleanup_disk; ++ ++ if (dev->disk_attributes) { ++ ret = sysfs_create_group(&disk_to_dev(dev->disk)->kobj, ++ dev->disk_attributes); ++ WARN_ON(ret); ++ } ++ } ++ } ++ ++ return; ++ ++out_cleanup_disk: ++ put_disk(dev->disk); ++} ++ + int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old) + { + unsigned long flags; +--- a/drivers/mtd/mtdcore.c ++++ b/drivers/mtd/mtdcore.c +@@ -34,6 +34,7 @@ + + #include + #include ++#include + + #include "mtdcore.h" + +@@ -1109,6 +1110,8 @@ int mtd_device_parse_register(struct mtd + register_reboot_notifier(&mtd->reboot_notifier); + } + ++ register_mtd_blktrans_devs(); ++ + out: + if (ret) { + nvmem_unregister(mtd->otp_user_nvmem); +--- a/include/linux/mtd/blktrans.h ++++ b/include/linux/mtd/blktrans.h +@@ -76,6 +76,7 @@ extern int deregister_mtd_blktrans(struc + extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); + extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); + extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev); ++extern void register_mtd_blktrans_devs(void); + + /** + * module_mtd_blktrans() - Helper macro for registering a mtd blktrans driver diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch new file mode 100755 index 0000000..1b17c2f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/420-mtd-support-OpenWrt-s-MTD_ROOTFS_ROOT_DEV.patch @@ -0,0 +1,24 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Mon, 7 Nov 2022 23:48:24 +0100 +Subject: [PATCH] mtd: support OpenWrt's MTD_ROOTFS_ROOT_DEV +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This allows setting ROOT_DEV to MTD partition named "rootfs". + +Signed-off-by: RafaΕ‚ MiΕ‚ecki +--- + +--- a/drivers/mtd/mtdcore.c ++++ b/drivers/mtd/mtdcore.c +@@ -780,7 +780,8 @@ int add_mtd_device(struct mtd_info *mtd) + + mutex_unlock(&mtd_table_mutex); + +- if (of_property_read_bool(mtd_get_of_node(mtd), "linux,rootfs")) { ++ if (of_property_read_bool(mtd_get_of_node(mtd), "linux,rootfs") || ++ (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && !strcmp(mtd->name, "rootfs") && ROOT_DEV == 0)) { + if (IS_BUILTIN(CONFIG_MTD)) { + pr_info("mtd: setting mtd%d (%s) as root device\n", mtd->index, mtd->name); + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/421-drivers-mtd-parsers-add-nvmem-support-to-cmdlinepart.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/421-drivers-mtd-parsers-add-nvmem-support-to-cmdlinepart.patch new file mode 100755 index 0000000..190fecc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/421-drivers-mtd-parsers-add-nvmem-support-to-cmdlinepart.patch @@ -0,0 +1,120 @@ +From 6fa9e3678eb002246df1280322b6a024853950a5 Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Mon, 11 Oct 2021 00:53:14 +0200 +Subject: [PATCH] drivers: mtd: parsers: add nvmem support to cmdlinepart + +Assuming cmdlinepart is only one level deep partition scheme and that +static partition are also defined in DTS, we can assign an of_node for +partition declared from bootargs. cmdlinepart have priority than +fiexed-partition parser so in this specific case the parser doesn't +assign an of_node. Fix this by searching a defined of_node using a +similar fixed_partition parser and if a partition is found with the same +label, check that it has the same offset and size and return the DT +of_node to correctly use NVMEM cells. + +Signed-off-by: Ansuel Smith +--- + drivers/mtd/parsers/cmdlinepart.c | 71 +++++++++++++++++++++++++++++++ + 1 file changed, 71 insertions(+) + +--- a/drivers/mtd/parsers/cmdlinepart.c ++++ b/drivers/mtd/parsers/cmdlinepart.c +@@ -43,6 +43,7 @@ + #include + #include + #include ++#include + + /* special size referring to all the remaining space in a partition */ + #define SIZE_REMAINING ULLONG_MAX +@@ -315,6 +316,68 @@ static int mtdpart_setup_real(char *s) + return 0; + } + ++static int search_fixed_partition(struct mtd_info *master, ++ struct mtd_partition *target_part, ++ struct mtd_partition *fixed_part) ++{ ++ struct device_node *mtd_node; ++ struct device_node *ofpart_node; ++ struct device_node *pp; ++ struct mtd_partition part; ++ const char *partname; ++ ++ mtd_node = mtd_get_of_node(master); ++ if (!mtd_node) ++ return -EINVAL; ++ ++ ofpart_node = of_get_child_by_name(mtd_node, "partitions"); ++ ++ for_each_child_of_node(ofpart_node, pp) { ++ const __be32 *reg; ++ int len; ++ int a_cells, s_cells; ++ ++ reg = of_get_property(pp, "reg", &len); ++ if (!reg) { ++ pr_debug("%s: ofpart partition %pOF (%pOF) missing reg property.\n", ++ master->name, pp, ++ mtd_node); ++ continue; ++ } ++ ++ a_cells = of_n_addr_cells(pp); ++ s_cells = of_n_size_cells(pp); ++ if (len / 4 != a_cells + s_cells) { ++ pr_debug("%s: ofpart partition %pOF (%pOF) error parsing reg property.\n", ++ master->name, pp, ++ mtd_node); ++ continue; ++ } ++ ++ part.offset = of_read_number(reg, a_cells); ++ part.size = of_read_number(reg + a_cells, s_cells); ++ part.of_node = pp; ++ ++ partname = of_get_property(pp, "label", &len); ++ if (!partname) ++ partname = of_get_property(pp, "name", &len); ++ part.name = partname; ++ ++ if (!strncmp(target_part->name, part.name, len)) { ++ if (part.offset != target_part->offset) ++ return -EINVAL; ++ ++ if (part.size != target_part->size) ++ return -EINVAL; ++ ++ memcpy(fixed_part, &part, sizeof(struct mtd_partition)); ++ return 0; ++ } ++ } ++ ++ return -EINVAL; ++} ++ + /* + * Main function to be called from the MTD mapping driver/device to + * obtain the partitioning information. At this point the command line +@@ -330,6 +393,7 @@ static int parse_cmdline_partitions(stru + int i, err; + struct cmdline_mtd_partition *part; + const char *mtd_id = master->name; ++ struct mtd_partition fixed_part; + + /* parse command line */ + if (!cmdline_parsed) { +@@ -374,6 +438,13 @@ static int parse_cmdline_partitions(stru + sizeof(*part->parts) * (part->num_parts - i)); + i--; + } ++ ++ err = search_fixed_partition(master, &part->parts[i], &fixed_part); ++ if (!err) { ++ part->parts[i].of_node = fixed_part.of_node; ++ pr_info("Found partition defined in DT for %s. Assigning OF node to support nvmem.", ++ part->parts[i].name); ++ } + } + + *pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/430-mtk-bmt-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/430-mtk-bmt-support.patch new file mode 100755 index 0000000..8d1c165 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/430-mtk-bmt-support.patch @@ -0,0 +1,33 @@ +From ac84397efb3b3868c71c10ad7521161773228a17 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 13:41:44 +0200 +Subject: [PATCH] mtd/nand: add MediaTek NAND bad block managment table + +--- + drivers/mtd/nand/Kconfig | 4 ++++ + drivers/mtd/nand/Makefile | 1 + + 2 files changed, 5 insertions(+) + +--- a/drivers/mtd/nand/Kconfig ++++ b/drivers/mtd/nand/Kconfig +@@ -46,6 +46,10 @@ config MTD_NAND_ECC_SW_BCH + ECC codes. They are used with NAND devices requiring more than 1 bit + of error correction. + ++config MTD_NAND_MTK_BMT ++ bool "Support MediaTek NAND Bad-block Management Table" ++ default n ++ + config MTD_NAND_ECC_MXIC + bool "Macronix external hardware ECC engine" + depends on HAS_IOMEM +--- a/drivers/mtd/nand/Makefile ++++ b/drivers/mtd/nand/Makefile +@@ -3,6 +3,7 @@ + nandcore-objs := core.o bbt.o + obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o + obj-$(CONFIG_MTD_NAND_ECC_MEDIATEK) += ecc-mtk.o ++obj-$(CONFIG_MTD_NAND_MTK_BMT) += mtk_bmt.o mtk_bmt_v2.o mtk_bmt_bbt.o mtk_bmt_nmbm.o + obj-$(CONFIG_SPI_QPIC_SNAND) += qpic_common.o + obj-$(CONFIG_MTD_NAND_QCOM) += qpic_common.o + obj-y += onenand/ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/499-LEGACY-block-partitions-populate-fwnode.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/499-LEGACY-block-partitions-populate-fwnode.patch new file mode 100755 index 0000000..f7ec9ef --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/499-LEGACY-block-partitions-populate-fwnode.patch @@ -0,0 +1,130 @@ +From: Daniel Golle +Subject: [PATCH] LEGACY block: partitions: populate fwnode + +Assign matching firmware nodes to block partitions in order to allow +them to be referenced e.g. as NVMEM providers. + +REMOVE THIS PATCH ONCE ALL TARGETS ARE USING LINUX 6.12 AND ALL BOARDS +HAVE MIGRATED TO UPSTREAM DT BINDINGS. + +Signed-off-by: Daniel Golle +--- a/block/partitions/core.c ++++ b/block/partitions/core.c +@@ -11,6 +11,8 @@ + #include + #include + #include ++#include ++ + #include "check.h" + + static int (*const check_part[])(struct parsed_partitions *) = { +@@ -285,6 +287,74 @@ static ssize_t whole_disk_show(struct de + } + static const DEVICE_ATTR(whole_disk, 0444, whole_disk_show, NULL); + ++static bool part_meta_match(const char *attr, const char *member, size_t length) ++{ ++ /* check if length of attr exceeds specified maximum length */ ++ if (strnlen(attr, length) == length) ++ return false; ++ ++ /* return true if strings match */ ++ return !strncmp(attr, member, length); ++} ++ ++static struct fwnode_handle *find_partition_fwnode(struct block_device *bdev) ++{ ++ struct fwnode_handle *fw_parts, *fw_part; ++ struct device *ddev = disk_to_dev(bdev->bd_disk); ++ const char *partname, *uuid; ++ u32 partno; ++ bool got_uuid, got_partname, got_partno; ++ ++ fw_parts = device_get_named_child_node(ddev, "partitions"); ++ if (!fw_parts) ++ return NULL; ++ ++ fwnode_for_each_child_node(fw_parts, fw_part) { ++ got_uuid = false; ++ got_partname = false; ++ got_partno = false; ++ /* ++ * In case 'uuid' is defined in the partitions firmware node ++ * require partition meta info being present and the specified ++ * uuid to match. ++ */ ++ got_uuid = !fwnode_property_read_string(fw_part, "uuid", &uuid); ++ if (got_uuid && (!bdev->bd_meta_info || ++ !part_meta_match(uuid, bdev->bd_meta_info->uuid, ++ PARTITION_META_INFO_UUIDLTH))) ++ continue; ++ ++ /* ++ * In case 'partname' is defined in the partitions firmware node ++ * require partition meta info being present and the specified ++ * volname to match. ++ */ ++ got_partname = !fwnode_property_read_string(fw_part, "partname", ++ &partname); ++ if (got_partname && (!bdev->bd_meta_info || ++ !part_meta_match(partname, ++ bdev->bd_meta_info->volname, ++ PARTITION_META_INFO_VOLNAMELTH))) ++ continue; ++ ++ /* ++ * In case 'partno' is defined in the partitions firmware node ++ * the specified partno needs to match. ++ */ ++ got_partno = !fwnode_property_read_u32(fw_part, "partno", &partno); ++ if (got_partno && bdev_partno(bdev) != partno) ++ continue; ++ ++ /* Skip if no matching criteria is present in firmware node */ ++ if (!got_uuid && !got_partname && !got_partno) ++ continue; ++ ++ return fw_part; ++ } ++ ++ return NULL; ++} ++ + /* + * Must be called either with open_mutex held, before a disk can be opened or + * after all disk users are gone. +@@ -361,6 +431,9 @@ static struct block_device *add_partitio + goto out_put; + } + ++ if (!pdev->fwnode && !pdev->of_node) ++ device_set_node(pdev, find_partition_fwnode(bdev)); ++ + /* delay uevent until 'holders' subdir is created */ + dev_set_uevent_suppress(pdev, 1); + err = device_add(pdev); +--- a/drivers/mmc/core/bus.c ++++ b/drivers/mmc/core/bus.c +@@ -368,6 +368,8 @@ int mmc_add_card(struct mmc_card *card) + + mmc_add_card_debugfs(card); + card->dev.of_node = mmc_of_find_child_device(card->host, 0); ++ if (card->dev.of_node && !card->dev.fwnode) ++ card->dev.fwnode = &card->dev.of_node->fwnode; + + device_enable_async_suspend(&card->dev); + +--- a/drivers/mmc/core/block.c ++++ b/drivers/mmc/core/block.c +@@ -2679,6 +2679,10 @@ static struct mmc_blk_data *mmc_blk_allo + if (area_type == MMC_BLK_DATA_AREA_MAIN) + dev_set_drvdata(&card->dev, md); + disk_fwnode = mmc_blk_get_partitions_node(parent, subname); ++ if (!disk_fwnode) ++ disk_fwnode = device_get_named_child_node(subname ? md->parent->parent : ++ md->parent, ++ subname ? subname : "block"); + ret = add_disk_fwnode(md->parent, md->disk, mmc_disk_attr_groups, + disk_fwnode); + if (ret) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/600-net-enable-fraglist-GRO-by-default.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/600-net-enable-fraglist-GRO-by-default.patch new file mode 100755 index 0000000..feed2cd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/600-net-enable-fraglist-GRO-by-default.patch @@ -0,0 +1,24 @@ +From: Felix Fietkau +Date: Tue, 23 Apr 2024 12:35:21 +0200 +Subject: [PATCH] net: enable fraglist GRO by default + +This can significantly improve performance for packet forwarding/bridging + +Signed-off-by: Felix Fietkau +--- + +--- a/include/linux/netdev_features.h ++++ b/include/linux/netdev_features.h +@@ -235,10 +235,10 @@ static inline int find_next_netdev_featu + #define NETIF_F_UPPER_DISABLES NETIF_F_LRO + + /* changeable features with no special hardware requirements */ +-#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO) ++#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO | NETIF_F_GRO_FRAGLIST) + + /* Changeable features with no special hardware requirements that defaults to off. */ +-#define NETIF_F_SOFT_FEATURES_OFF (NETIF_F_GRO_FRAGLIST | NETIF_F_GRO_UDP_FWD) ++#define NETIF_F_SOFT_FEATURES_OFF (NETIF_F_GRO_UDP_FWD) + + #define NETIF_F_VLAN_FEATURES (NETIF_F_HW_VLAN_CTAG_FILTER | \ + NETIF_F_HW_VLAN_CTAG_RX | \ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/610-net-page_pool-try-to-free-deferred-skbs-while-waitin.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/610-net-page_pool-try-to-free-deferred-skbs-while-waitin.patch new file mode 100755 index 0000000..7f79e04 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/610-net-page_pool-try-to-free-deferred-skbs-while-waitin.patch @@ -0,0 +1,51 @@ +From: Felix Fietkau +Date: Fri, 3 Jan 2025 19:29:00 +0100 +Subject: [PATCH] net: page_pool: try to free deferred skbs while waiting for + pool release + +The NAPI defer list can accumulate no longer used skbs, which can be reused +during alloc. If this happens on a CPU that otherwise does not do any +rx softirq processing, skbs can be held indefinitely, causing warnings +on releasing page pools. +Deal with this by scheduling rx softirq on all CPUs. + +Patch by Lorenzo Bianconi + +Signed-off-by: Felix Fietkau +--- + +--- a/net/core/page_pool.c ++++ b/net/core/page_pool.c +@@ -1155,8 +1155,9 @@ static void page_pool_release_retry(stru + { + struct delayed_work *dwq = to_delayed_work(wq); + struct page_pool *pool = container_of(dwq, typeof(*pool), release_dw); ++ unsigned long flags; + void *netdev; +- int inflight; ++ int cpu, inflight; + + inflight = page_pool_release(pool); + /* In rare cases, a driver bug may cause inflight to go negative. +@@ -1168,6 +1169,21 @@ static void page_pool_release_retry(stru + if (inflight <= 0) + return; + ++ /* Run NET_RX_SOFTIRQ in order to free pending skbs in softnet_data ++ * defer_list that can stay in the list until we have enough queued ++ * traffic. ++ */ ++ local_irq_save(flags); ++ for_each_online_cpu(cpu) { ++ struct softnet_data *sd = &per_cpu(softnet_data, cpu); ++ ++ if (cpu == raw_smp_processor_id()) ++ raise_softirq_irqoff(NET_RX_SOFTIRQ); ++ else if (!cmpxchg(&sd->defer_ipi_scheduled, 0, 1)) ++ smp_call_function_single_async(cpu, &sd->defer_csd); ++ } ++ local_irq_restore(flags); ++ + /* Periodic warning for page pools the user can't see */ + netdev = READ_ONCE(pool->slow.netdev); + if (time_after_eq(jiffies, pool->defer_warn) && diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/645-netfilter-connmark-introduce-set-dscpmark.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/645-netfilter-connmark-introduce-set-dscpmark.patch new file mode 100755 index 0000000..bb80285 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/645-netfilter-connmark-introduce-set-dscpmark.patch @@ -0,0 +1,231 @@ +From eda40b8c8c82e0f2789d6bc8bf63846dce2e8f32 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Sat, 23 Mar 2019 09:29:49 +0000 +Subject: [PATCH] netfilter: connmark: introduce set-dscpmark + +set-dscpmark is a method of storing the DSCP of an ip packet into +conntrack mark. In combination with a suitable tc filter action +(act_ctinfo) DSCP values are able to be stored in the mark on egress and +restored on ingress across links that otherwise alter or bleach DSCP. + +This is useful for qdiscs such as CAKE which are able to shape according +to policies based on DSCP. + +Ingress classification is traditionally a challenging task since +iptables rules haven't yet run and tc filter/eBPF programs are pre-NAT +lookups, hence are unable to see internal IPv4 addresses as used on the +typical home masquerading gateway. + +x_tables CONNMARK set-dscpmark target solves the problem of storing the +DSCP to the conntrack mark in a way suitable for the new act_ctinfo tc +action to restore. + +The set-dscpmark option accepts 2 parameters, a 32bit 'dscpmask' and a +32bit 'statemask'. The dscp mask must be 6 contiguous bits and +represents the area where the DSCP will be stored in the connmark. The +state mask is a minimum 1 bit length mask that must not overlap with the +dscpmask. It represents a flag which is set when the DSCP has been +stored in the conntrack mark. This is useful to implement a 'one shot' +iptables based classification where the 'complicated' iptables rules are +only run once to classify the connection on initial (egress) packet and +subsequent packets are all marked/restored with the same DSCP. A state +mask of zero disables the setting of a status bit/s. + +example syntax with a suitably modified iptables user space application: + +iptables -A QOS_MARK_eth0 -t mangle -j CONNMARK --set-dscpmark 0xfc000000/0x01000000 + +Would store the DSCP in the top 6 bits of the 32bit mark field, and use +the LSB of the top byte as the 'DSCP has been stored' marker. + +|----0xFC----conntrack mark----000000---| +| Bits 31-26 | bit 25 | bit24 |~~~ Bit 0| +| DSCP | unused | flag |unused | +|-----------------------0x01---000000---| + ^ ^ + | | + ---| Conditional flag + | set this when dscp +|-ip diffserv-| stored in mark +| 6 bits | +|-------------| + +an identically configured tc action to restore looks like: + +tc filter show dev eth0 ingress +filter parent ffff: protocol all pref 10 u32 chain 0 +filter parent ffff: protocol all pref 10 u32 chain 0 fh 800: ht divisor 1 +filter parent ffff: protocol all pref 10 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1: not_in_hw + match 00000000/00000000 at 0 + action order 1: ctinfo zone 0 pipe + index 2 ref 1 bind 1 dscp 0xfc000000/0x1000000 + + action order 2: mirred (Egress Redirect to device ifb4eth0) stolen + index 1 ref 1 bind 1 + +|----0xFC----conntrack mark----000000---| +| Bits 31-26 | bit 25 | bit24 |~~~ Bit 0| +| DSCP | unused | flag |unused | +|-----------------------0x01---000000---| + | | + | | + ---| Conditional flag + v only restore if set +|-ip diffserv-| +| 6 bits | +|-------------| + +Signed-off-by: Kevin Darbyshire-Bryant +--- + include/uapi/linux/netfilter/xt_connmark.h | 10 ++++ + net/netfilter/xt_connmark.c | 55 ++++++++++++++++++---- + 2 files changed, 57 insertions(+), 8 deletions(-) + +--- a/include/uapi/linux/netfilter/xt_connmark.h ++++ b/include/uapi/linux/netfilter/xt_connmark.h +@@ -15,6 +15,11 @@ enum { + }; + + enum { ++ XT_CONNMARK_VALUE = (1 << 0), ++ XT_CONNMARK_DSCP = (1 << 1) ++}; ++ ++enum { + D_SHIFT_LEFT = 0, + D_SHIFT_RIGHT, + }; +@@ -29,6 +34,11 @@ struct xt_connmark_tginfo2 { + __u8 shift_dir, shift_bits, mode; + }; + ++struct xt_connmark_tginfo3 { ++ __u32 ctmark, ctmask, nfmask; ++ __u8 shift_dir, shift_bits, mode, func; ++}; ++ + struct xt_connmark_mtinfo1 { + __u32 mark, mask; + __u8 invert; +--- a/net/netfilter/xt_connmark.c ++++ b/net/netfilter/xt_connmark.c +@@ -24,13 +24,13 @@ MODULE_ALIAS("ipt_connmark"); + MODULE_ALIAS("ip6t_connmark"); + + static unsigned int +-connmark_tg_shift(struct sk_buff *skb, const struct xt_connmark_tginfo2 *info) ++connmark_tg_shift(struct sk_buff *skb, const struct xt_connmark_tginfo3 *info) + { + enum ip_conntrack_info ctinfo; + u_int32_t new_targetmark; + struct nf_conn *ct; + u_int32_t newmark; +- u_int32_t oldmark; ++ u_int8_t dscp; + + ct = nf_ct_get(skb, &ctinfo); + if (ct == NULL) +@@ -38,13 +38,24 @@ connmark_tg_shift(struct sk_buff *skb, c + + switch (info->mode) { + case XT_CONNMARK_SET: +- oldmark = READ_ONCE(ct->mark); +- newmark = (oldmark & ~info->ctmask) ^ info->ctmark; +- if (info->shift_dir == D_SHIFT_RIGHT) +- newmark >>= info->shift_bits; +- else +- newmark <<= info->shift_bits; ++ newmark = READ_ONCE(ct->mark); ++ if (info->func & XT_CONNMARK_VALUE) { ++ newmark = (newmark & ~info->ctmask) ^ info->ctmark; ++ if (info->shift_dir == D_SHIFT_RIGHT) ++ newmark >>= info->shift_bits; ++ else ++ newmark <<= info->shift_bits; ++ } else if (info->func & XT_CONNMARK_DSCP) { ++ if (skb->protocol == htons(ETH_P_IP)) ++ dscp = ipv4_get_dsfield(ip_hdr(skb)) >> 2; ++ else if (skb->protocol == htons(ETH_P_IPV6)) ++ dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2; ++ else /* protocol doesn't have diffserv */ ++ break; + ++ newmark = (newmark & ~info->ctmark) | ++ (info->ctmask | (dscp << info->shift_bits)); ++ } + if (READ_ONCE(ct->mark) != newmark) { + WRITE_ONCE(ct->mark, newmark); + nf_conntrack_event_cache(IPCT_MARK, ct); +@@ -83,20 +94,36 @@ static unsigned int + connmark_tg(struct sk_buff *skb, const struct xt_action_param *par) + { + const struct xt_connmark_tginfo1 *info = par->targinfo; +- const struct xt_connmark_tginfo2 info2 = { ++ const struct xt_connmark_tginfo3 info3 = { + .ctmark = info->ctmark, + .ctmask = info->ctmask, + .nfmask = info->nfmask, + .mode = info->mode, ++ .func = XT_CONNMARK_VALUE + }; + +- return connmark_tg_shift(skb, &info2); ++ return connmark_tg_shift(skb, &info3); + } + + static unsigned int + connmark_tg_v2(struct sk_buff *skb, const struct xt_action_param *par) + { + const struct xt_connmark_tginfo2 *info = par->targinfo; ++ const struct xt_connmark_tginfo3 info3 = { ++ .ctmark = info->ctmark, ++ .ctmask = info->ctmask, ++ .nfmask = info->nfmask, ++ .mode = info->mode, ++ .func = XT_CONNMARK_VALUE ++ }; ++ ++ return connmark_tg_shift(skb, &info3); ++} ++ ++static unsigned int ++connmark_tg_v3(struct sk_buff *skb, const struct xt_action_param *par) ++{ ++ const struct xt_connmark_tginfo3 *info = par->targinfo; + + return connmark_tg_shift(skb, info); + } +@@ -168,6 +195,16 @@ static struct xt_target connmark_tg_reg[ + .destroy = connmark_tg_destroy, + .me = THIS_MODULE, + }, ++ { ++ .name = "CONNMARK", ++ .revision = 3, ++ .family = NFPROTO_IPV4, ++ .checkentry = connmark_tg_check, ++ .target = connmark_tg_v3, ++ .targetsize = sizeof(struct xt_connmark_tginfo3), ++ .destroy = connmark_tg_destroy, ++ .me = THIS_MODULE, ++ }, + #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) + { + .name = "CONNMARK", +@@ -189,6 +226,16 @@ static struct xt_target connmark_tg_reg[ + .destroy = connmark_tg_destroy, + .me = THIS_MODULE, + }, ++ { ++ .name = "CONNMARK", ++ .revision = 3, ++ .family = NFPROTO_IPV6, ++ .checkentry = connmark_tg_check, ++ .target = connmark_tg_v3, ++ .targetsize = sizeof(struct xt_connmark_tginfo3), ++ .destroy = connmark_tg_destroy, ++ .me = THIS_MODULE, ++ }, + #endif + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/650-netfilter-add-xt_FLOWOFFLOAD-target.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/650-netfilter-add-xt_FLOWOFFLOAD-target.patch new file mode 100755 index 0000000..53093da --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/650-netfilter-add-xt_FLOWOFFLOAD-target.patch @@ -0,0 +1,812 @@ +From: Felix Fietkau +Date: Tue, 20 Feb 2018 15:56:02 +0100 +Subject: [PATCH] netfilter: add xt_FLOWOFFLOAD target + +Signed-off-by: Felix Fietkau +--- + create mode 100644 net/netfilter/xt_OFFLOAD.c + +--- a/net/netfilter/Kconfig ++++ b/net/netfilter/Kconfig +@@ -729,7 +729,6 @@ config NF_FLOW_TABLE + tristate "Netfilter flow table module" + depends on NETFILTER_INGRESS + depends on NF_CONNTRACK +- depends on NF_TABLES + help + This option adds the flow table core infrastructure. + +@@ -1025,6 +1024,15 @@ config NETFILTER_XT_TARGET_NOTRACK + depends on NETFILTER_ADVANCED + select NETFILTER_XT_TARGET_CT + ++config NETFILTER_XT_TARGET_FLOWOFFLOAD ++ tristate '"FLOWOFFLOAD" target support' ++ depends on NF_FLOW_TABLE ++ depends on NETFILTER_INGRESS ++ help ++ This option adds a `FLOWOFFLOAD' target, which uses the nf_flow_offload ++ module to speed up processing of packets by bypassing the usual ++ netfilter chains ++ + config NETFILTER_XT_TARGET_RATEEST + tristate '"RATEEST" target support' + depends on NETFILTER_ADVANCED +--- a/net/netfilter/Makefile ++++ b/net/netfilter/Makefile +@@ -168,6 +168,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIF + obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o + obj-$(CONFIG_NETFILTER_XT_TARGET_CT) += xt_CT.o + obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o ++obj-$(CONFIG_NETFILTER_XT_TARGET_FLOWOFFLOAD) += xt_FLOWOFFLOAD.o + obj-$(CONFIG_NETFILTER_XT_TARGET_HL) += xt_HL.o + obj-$(CONFIG_NETFILTER_XT_TARGET_HMARK) += xt_HMARK.o + obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o +--- /dev/null ++++ b/net/netfilter/xt_FLOWOFFLOAD.c +@@ -0,0 +1,703 @@ ++/* ++ * Copyright (C) 2018-2021 Felix Fietkau ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++struct xt_flowoffload_hook { ++ struct hlist_node list; ++ struct nf_hook_ops ops; ++ struct net *net; ++ bool registered; ++ bool used; ++}; ++ ++struct xt_flowoffload_table { ++ struct nf_flowtable ft; ++ struct hlist_head hooks; ++ struct delayed_work work; ++}; ++ ++struct nf_forward_info { ++ const struct net_device *indev; ++ const struct net_device *outdev; ++ const struct net_device *hw_outdev; ++ struct id { ++ __u16 id; ++ __be16 proto; ++ } encap[NF_FLOW_TABLE_ENCAP_MAX]; ++ u8 num_encaps; ++ u8 ingress_vlans; ++ u8 h_source[ETH_ALEN]; ++ u8 h_dest[ETH_ALEN]; ++ enum flow_offload_xmit_type xmit_type; ++}; ++ ++static DEFINE_SPINLOCK(hooks_lock); ++ ++struct xt_flowoffload_table flowtable[2]; ++ ++static unsigned int ++xt_flowoffload_net_hook(void *priv, struct sk_buff *skb, ++ const struct nf_hook_state *state) ++{ ++ struct vlan_ethhdr *veth; ++ __be16 proto; ++ ++ switch (skb->protocol) { ++ case htons(ETH_P_8021Q): ++ veth = (struct vlan_ethhdr *)skb_mac_header(skb); ++ proto = veth->h_vlan_encapsulated_proto; ++ break; ++ case htons(ETH_P_PPP_SES): ++ if (!nf_flow_pppoe_proto(skb, &proto)) ++ return NF_ACCEPT; ++ break; ++ default: ++ proto = skb->protocol; ++ break; ++ } ++ ++ switch (proto) { ++ case htons(ETH_P_IP): ++ return nf_flow_offload_ip_hook(priv, skb, state); ++ case htons(ETH_P_IPV6): ++ return nf_flow_offload_ipv6_hook(priv, skb, state); ++ } ++ ++ return NF_ACCEPT; ++} ++ ++static int ++xt_flowoffload_create_hook(struct xt_flowoffload_table *table, ++ struct net_device *dev) ++{ ++ struct xt_flowoffload_hook *hook; ++ struct nf_hook_ops *ops; ++ ++ hook = kzalloc(sizeof(*hook), GFP_ATOMIC); ++ if (!hook) ++ return -ENOMEM; ++ ++ ops = &hook->ops; ++ ops->pf = NFPROTO_NETDEV; ++ ops->hooknum = NF_NETDEV_INGRESS; ++ ops->priority = 10; ++ ops->priv = &table->ft; ++ ops->hook = xt_flowoffload_net_hook; ++ ops->dev = dev; ++ ++ hlist_add_head(&hook->list, &table->hooks); ++ mod_delayed_work(system_power_efficient_wq, &table->work, 0); ++ ++ return 0; ++} ++ ++static struct xt_flowoffload_hook * ++flow_offload_lookup_hook(struct xt_flowoffload_table *table, ++ struct net_device *dev) ++{ ++ struct xt_flowoffload_hook *hook; ++ ++ hlist_for_each_entry(hook, &table->hooks, list) { ++ if (hook->ops.dev == dev) ++ return hook; ++ } ++ ++ return NULL; ++} ++ ++static void ++xt_flowoffload_check_device(struct xt_flowoffload_table *table, ++ struct net_device *dev) ++{ ++ struct xt_flowoffload_hook *hook; ++ ++ if (!dev) ++ return; ++ ++ spin_lock_bh(&hooks_lock); ++ hook = flow_offload_lookup_hook(table, dev); ++ if (hook) ++ hook->used = true; ++ else ++ xt_flowoffload_create_hook(table, dev); ++ spin_unlock_bh(&hooks_lock); ++} ++ ++static void ++xt_flowoffload_register_hooks(struct xt_flowoffload_table *table) ++{ ++ struct xt_flowoffload_hook *hook; ++ ++restart: ++ hlist_for_each_entry(hook, &table->hooks, list) { ++ if (hook->registered) ++ continue; ++ ++ hook->registered = true; ++ hook->net = dev_net(hook->ops.dev); ++ spin_unlock_bh(&hooks_lock); ++ nf_register_net_hook(hook->net, &hook->ops); ++ if (table->ft.flags & NF_FLOWTABLE_HW_OFFLOAD) ++ table->ft.type->setup(&table->ft, hook->ops.dev, ++ FLOW_BLOCK_BIND); ++ spin_lock_bh(&hooks_lock); ++ goto restart; ++ } ++ ++} ++ ++static bool ++xt_flowoffload_cleanup_hooks(struct xt_flowoffload_table *table) ++{ ++ struct xt_flowoffload_hook *hook; ++ bool active = false; ++ ++restart: ++ spin_lock_bh(&hooks_lock); ++ hlist_for_each_entry(hook, &table->hooks, list) { ++ if (hook->used || !hook->registered) { ++ active = true; ++ continue; ++ } ++ ++ hlist_del(&hook->list); ++ spin_unlock_bh(&hooks_lock); ++ if (table->ft.flags & NF_FLOWTABLE_HW_OFFLOAD) ++ table->ft.type->setup(&table->ft, hook->ops.dev, ++ FLOW_BLOCK_UNBIND); ++ nf_unregister_net_hook(hook->net, &hook->ops); ++ kfree(hook); ++ goto restart; ++ } ++ spin_unlock_bh(&hooks_lock); ++ ++ return active; ++} ++ ++static void ++xt_flowoffload_check_hook(struct nf_flowtable *flowtable, ++ struct flow_offload *flow, void *data) ++{ ++ struct xt_flowoffload_table *table; ++ struct flow_offload_tuple *tuple0 = &flow->tuplehash[0].tuple; ++ struct flow_offload_tuple *tuple1 = &flow->tuplehash[1].tuple; ++ struct xt_flowoffload_hook *hook; ++ ++ table = container_of(flowtable, struct xt_flowoffload_table, ft); ++ ++ spin_lock_bh(&hooks_lock); ++ hlist_for_each_entry(hook, &table->hooks, list) { ++ if (hook->ops.dev->ifindex != tuple0->iifidx && ++ hook->ops.dev->ifindex != tuple1->iifidx) ++ continue; ++ ++ hook->used = true; ++ } ++ spin_unlock_bh(&hooks_lock); ++} ++ ++static void ++xt_flowoffload_hook_work(struct work_struct *work) ++{ ++ struct xt_flowoffload_table *table; ++ struct xt_flowoffload_hook *hook; ++ int err; ++ ++ table = container_of(work, struct xt_flowoffload_table, work.work); ++ ++ spin_lock_bh(&hooks_lock); ++ xt_flowoffload_register_hooks(table); ++ hlist_for_each_entry(hook, &table->hooks, list) ++ hook->used = false; ++ spin_unlock_bh(&hooks_lock); ++ ++ err = nf_flow_table_iterate(&table->ft, xt_flowoffload_check_hook, ++ NULL); ++ if (err && err != -EAGAIN) ++ goto out; ++ ++ if (!xt_flowoffload_cleanup_hooks(table)) ++ return; ++ ++out: ++ queue_delayed_work(system_power_efficient_wq, &table->work, HZ); ++} ++ ++static bool ++xt_flowoffload_skip(struct sk_buff *skb, int family) ++{ ++ if (skb_sec_path(skb)) ++ return true; ++ ++ if (family == NFPROTO_IPV4) { ++ const struct ip_options *opt = &(IPCB(skb)->opt); ++ ++ if (unlikely(opt->optlen)) ++ return true; ++ } ++ ++ return false; ++} ++ ++static enum flow_offload_xmit_type nf_xmit_type(struct dst_entry *dst) ++{ ++ if (dst_xfrm(dst)) ++ return FLOW_OFFLOAD_XMIT_XFRM; ++ ++ return FLOW_OFFLOAD_XMIT_NEIGH; ++} ++ ++static void nf_default_forward_path(struct nf_flow_route *route, ++ struct dst_entry *dst_cache, ++ enum ip_conntrack_dir dir, ++ struct net_device **dev) ++{ ++ dev[!dir] = dst_cache->dev; ++ route->tuple[!dir].in.ifindex = dst_cache->dev->ifindex; ++ route->tuple[dir].dst = dst_cache; ++ route->tuple[dir].xmit_type = nf_xmit_type(dst_cache); ++} ++ ++static bool nf_is_valid_ether_device(const struct net_device *dev) ++{ ++ if (!dev || (dev->flags & IFF_LOOPBACK) || dev->type != ARPHRD_ETHER || ++ dev->addr_len != ETH_ALEN || !is_valid_ether_addr(dev->dev_addr)) ++ return false; ++ ++ return true; ++} ++ ++static void nf_dev_path_info(const struct net_device_path_stack *stack, ++ struct nf_forward_info *info, ++ unsigned char *ha) ++{ ++ const struct net_device_path *path; ++ int i; ++ ++ memcpy(info->h_dest, ha, ETH_ALEN); ++ ++ for (i = 0; i < stack->num_paths; i++) { ++ path = &stack->path[i]; ++ switch (path->type) { ++ case DEV_PATH_ETHERNET: ++ case DEV_PATH_DSA: ++ case DEV_PATH_VLAN: ++ case DEV_PATH_PPPOE: ++ info->indev = path->dev; ++ if (is_zero_ether_addr(info->h_source)) ++ memcpy(info->h_source, path->dev->dev_addr, ETH_ALEN); ++ ++ if (path->type == DEV_PATH_ETHERNET) ++ break; ++ if (path->type == DEV_PATH_DSA) { ++ i = stack->num_paths; ++ break; ++ } ++ ++ /* DEV_PATH_VLAN and DEV_PATH_PPPOE */ ++ if (info->num_encaps >= NF_FLOW_TABLE_ENCAP_MAX) { ++ info->indev = NULL; ++ break; ++ } ++ if (!info->outdev) ++ info->outdev = path->dev; ++ info->encap[info->num_encaps].id = path->encap.id; ++ info->encap[info->num_encaps].proto = path->encap.proto; ++ info->num_encaps++; ++ if (path->type == DEV_PATH_PPPOE) ++ memcpy(info->h_dest, path->encap.h_dest, ETH_ALEN); ++ break; ++ case DEV_PATH_BRIDGE: ++ if (is_zero_ether_addr(info->h_source)) ++ memcpy(info->h_source, path->dev->dev_addr, ETH_ALEN); ++ ++ switch (path->bridge.vlan_mode) { ++ case DEV_PATH_BR_VLAN_UNTAG_HW: ++ info->ingress_vlans |= BIT(info->num_encaps - 1); ++ break; ++ case DEV_PATH_BR_VLAN_TAG: ++ info->encap[info->num_encaps].id = path->bridge.vlan_id; ++ info->encap[info->num_encaps].proto = path->bridge.vlan_proto; ++ info->num_encaps++; ++ break; ++ case DEV_PATH_BR_VLAN_UNTAG: ++ info->num_encaps--; ++ break; ++ case DEV_PATH_BR_VLAN_KEEP: ++ break; ++ } ++ break; ++ default: ++ info->indev = NULL; ++ break; ++ } ++ } ++ if (!info->outdev) ++ info->outdev = info->indev; ++ ++ info->hw_outdev = info->indev; ++ ++ if (nf_is_valid_ether_device(info->indev)) ++ info->xmit_type = FLOW_OFFLOAD_XMIT_DIRECT; ++} ++ ++static int nf_dev_fill_forward_path(const struct nf_flow_route *route, ++ const struct dst_entry *dst_cache, ++ const struct nf_conn *ct, ++ enum ip_conntrack_dir dir, u8 *ha, ++ struct net_device_path_stack *stack) ++{ ++ const void *daddr = &ct->tuplehash[!dir].tuple.src.u3; ++ struct net_device *dev = dst_cache->dev; ++ struct neighbour *n; ++ u8 nud_state; ++ ++ if (!nf_is_valid_ether_device(dev)) ++ goto out; ++ ++ n = dst_neigh_lookup(dst_cache, daddr); ++ if (!n) ++ return -1; ++ ++ read_lock_bh(&n->lock); ++ nud_state = n->nud_state; ++ ether_addr_copy(ha, n->ha); ++ read_unlock_bh(&n->lock); ++ neigh_release(n); ++ ++ if (!(nud_state & NUD_VALID)) ++ return -1; ++ ++out: ++ return dev_fill_forward_path(dev, ha, stack); ++} ++ ++static void nf_dev_forward_path(struct nf_flow_route *route, ++ const struct nf_conn *ct, ++ enum ip_conntrack_dir dir, ++ struct net_device **devs) ++{ ++ const struct dst_entry *dst = route->tuple[dir].dst; ++ struct net_device_path_stack stack; ++ struct nf_forward_info info = {}; ++ unsigned char ha[ETH_ALEN]; ++ int i; ++ ++ if (nf_dev_fill_forward_path(route, dst, ct, dir, ha, &stack) >= 0) ++ nf_dev_path_info(&stack, &info, ha); ++ ++ devs[!dir] = (struct net_device *)info.indev; ++ if (!info.indev) ++ return; ++ ++ route->tuple[!dir].in.ifindex = info.indev->ifindex; ++ for (i = 0; i < info.num_encaps; i++) { ++ route->tuple[!dir].in.encap[i].id = info.encap[i].id; ++ route->tuple[!dir].in.encap[i].proto = info.encap[i].proto; ++ } ++ route->tuple[!dir].in.num_encaps = info.num_encaps; ++ route->tuple[!dir].in.ingress_vlans = info.ingress_vlans; ++ ++ if (info.xmit_type == FLOW_OFFLOAD_XMIT_DIRECT) { ++ memcpy(route->tuple[dir].out.h_source, info.h_source, ETH_ALEN); ++ memcpy(route->tuple[dir].out.h_dest, info.h_dest, ETH_ALEN); ++ route->tuple[dir].out.ifindex = info.outdev->ifindex; ++ route->tuple[dir].out.hw_ifindex = info.hw_outdev->ifindex; ++ route->tuple[dir].xmit_type = info.xmit_type; ++ } ++} ++ ++static int ++xt_flowoffload_route(struct sk_buff *skb, const struct nf_conn *ct, ++ const struct xt_action_param *par, ++ struct nf_flow_route *route, enum ip_conntrack_dir dir, ++ struct net_device **devs) ++{ ++ struct dst_entry *this_dst = skb_dst(skb); ++ struct dst_entry *other_dst = NULL; ++ struct flowi fl; ++ ++ memset(&fl, 0, sizeof(fl)); ++ switch (xt_family(par)) { ++ case NFPROTO_IPV4: ++ fl.u.ip4.daddr = ct->tuplehash[dir].tuple.src.u3.ip; ++ fl.u.ip4.flowi4_oif = xt_in(par)->ifindex; ++ break; ++ case NFPROTO_IPV6: ++ fl.u.ip6.saddr = ct->tuplehash[!dir].tuple.dst.u3.in6; ++ fl.u.ip6.daddr = ct->tuplehash[dir].tuple.src.u3.in6; ++ fl.u.ip6.flowi6_oif = xt_in(par)->ifindex; ++ break; ++ } ++ ++ if (!dst_hold_safe(this_dst)) ++ return -ENOENT; ++ ++ nf_route(xt_net(par), &other_dst, &fl, false, xt_family(par)); ++ if (!other_dst) { ++ dst_release(this_dst); ++ return -ENOENT; ++ } ++ ++ nf_default_forward_path(route, this_dst, dir, devs); ++ nf_default_forward_path(route, other_dst, !dir, devs); ++ ++ if (route->tuple[dir].xmit_type == FLOW_OFFLOAD_XMIT_NEIGH && ++ route->tuple[!dir].xmit_type == FLOW_OFFLOAD_XMIT_NEIGH) { ++ nf_dev_forward_path(route, ct, dir, devs); ++ nf_dev_forward_path(route, ct, !dir, devs); ++ } ++ ++ return 0; ++} ++ ++static unsigned int ++flowoffload_tg(struct sk_buff *skb, const struct xt_action_param *par) ++{ ++ struct xt_flowoffload_table *table; ++ const struct xt_flowoffload_target_info *info = par->targinfo; ++ struct tcphdr _tcph, *tcph = NULL; ++ enum ip_conntrack_info ctinfo; ++ enum ip_conntrack_dir dir; ++ struct nf_flow_route route = {}; ++ struct flow_offload *flow = NULL; ++ struct net_device *devs[2] = {}; ++ struct nf_conn *ct; ++ struct net *net; ++ ++ if (xt_flowoffload_skip(skb, xt_family(par))) ++ return XT_CONTINUE; ++ ++ ct = nf_ct_get(skb, &ctinfo); ++ if (ct == NULL) ++ return XT_CONTINUE; ++ ++ switch (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum) { ++ case IPPROTO_TCP: ++ if (ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED) ++ return XT_CONTINUE; ++ ++ tcph = skb_header_pointer(skb, par->thoff, ++ sizeof(_tcph), &_tcph); ++ if (unlikely(!tcph || tcph->fin || tcph->rst)) ++ return XT_CONTINUE; ++ break; ++ case IPPROTO_UDP: ++ break; ++ default: ++ return XT_CONTINUE; ++ } ++ ++ if (nf_ct_ext_exist(ct, NF_CT_EXT_HELPER) || ++ ct->status & (IPS_SEQ_ADJUST | IPS_NAT_CLASH)) ++ return XT_CONTINUE; ++ ++ if (!nf_ct_is_confirmed(ct)) ++ return XT_CONTINUE; ++ ++ dir = CTINFO2DIR(ctinfo); ++ ++ devs[dir] = xt_out(par); ++ devs[!dir] = xt_in(par); ++ ++ if (!devs[dir] || !devs[!dir]) ++ return XT_CONTINUE; ++ ++ if (test_and_set_bit(IPS_OFFLOAD_BIT, &ct->status)) ++ return XT_CONTINUE; ++ ++ if (xt_flowoffload_route(skb, ct, par, &route, dir, devs) < 0) ++ goto err_flow_route; ++ ++ flow = flow_offload_alloc(ct); ++ if (!flow) ++ goto err_flow_alloc; ++ ++ flow_offload_route_init(flow, &route); ++ ++ if (tcph) { ++ ct->proto.tcp.seen[0].flags |= IP_CT_TCP_FLAG_BE_LIBERAL; ++ ct->proto.tcp.seen[1].flags |= IP_CT_TCP_FLAG_BE_LIBERAL; ++ } ++ ++ table = &flowtable[!!(info->flags & XT_FLOWOFFLOAD_HW)]; ++ ++ net = read_pnet(&table->ft.net); ++ if (!net) ++ write_pnet(&table->ft.net, xt_net(par)); ++ ++ __set_bit(NF_FLOW_HW_BIDIRECTIONAL, &flow->flags); ++ if (flow_offload_add(&table->ft, flow) < 0) ++ goto err_flow_add; ++ ++ xt_flowoffload_check_device(table, devs[0]); ++ xt_flowoffload_check_device(table, devs[1]); ++ ++ return XT_CONTINUE; ++ ++err_flow_add: ++ flow_offload_free(flow); ++err_flow_alloc: ++ dst_release(route.tuple[dir].dst); ++ dst_release(route.tuple[!dir].dst); ++err_flow_route: ++ clear_bit(IPS_OFFLOAD_BIT, &ct->status); ++ ++ return XT_CONTINUE; ++} ++ ++static int flowoffload_chk(const struct xt_tgchk_param *par) ++{ ++ struct xt_flowoffload_target_info *info = par->targinfo; ++ ++ if (info->flags & ~XT_FLOWOFFLOAD_MASK) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static struct xt_target offload_tg_reg __read_mostly = { ++ .family = NFPROTO_UNSPEC, ++ .name = "FLOWOFFLOAD", ++ .revision = 0, ++ .targetsize = sizeof(struct xt_flowoffload_target_info), ++ .usersize = sizeof(struct xt_flowoffload_target_info), ++ .checkentry = flowoffload_chk, ++ .target = flowoffload_tg, ++ .me = THIS_MODULE, ++}; ++ ++static int flow_offload_netdev_event(struct notifier_block *this, ++ unsigned long event, void *ptr) ++{ ++ struct xt_flowoffload_hook *hook0, *hook1; ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (event != NETDEV_UNREGISTER) ++ return NOTIFY_DONE; ++ ++ spin_lock_bh(&hooks_lock); ++ hook0 = flow_offload_lookup_hook(&flowtable[0], dev); ++ if (hook0) ++ hlist_del(&hook0->list); ++ ++ hook1 = flow_offload_lookup_hook(&flowtable[1], dev); ++ if (hook1) ++ hlist_del(&hook1->list); ++ spin_unlock_bh(&hooks_lock); ++ ++ if (hook0) { ++ nf_unregister_net_hook(hook0->net, &hook0->ops); ++ kfree(hook0); ++ } ++ ++ if (hook1) { ++ nf_unregister_net_hook(hook1->net, &hook1->ops); ++ kfree(hook1); ++ } ++ ++ nf_flow_table_cleanup(dev); ++ ++ return NOTIFY_DONE; ++} ++ ++static struct notifier_block flow_offload_netdev_notifier = { ++ .notifier_call = flow_offload_netdev_event, ++}; ++ ++static int nf_flow_rule_route_inet(struct net *net, ++ struct flow_offload *flow, ++ enum flow_offload_tuple_dir dir, ++ struct nf_flow_rule *flow_rule) ++{ ++ const struct flow_offload_tuple *flow_tuple = &flow->tuplehash[dir].tuple; ++ int err; ++ ++ switch (flow_tuple->l3proto) { ++ case NFPROTO_IPV4: ++ err = nf_flow_rule_route_ipv4(net, flow, dir, flow_rule); ++ break; ++ case NFPROTO_IPV6: ++ err = nf_flow_rule_route_ipv6(net, flow, dir, flow_rule); ++ break; ++ default: ++ err = -1; ++ break; ++ } ++ ++ return err; ++} ++ ++static struct nf_flowtable_type flowtable_inet = { ++ .family = NFPROTO_INET, ++ .init = nf_flow_table_init, ++ .setup = nf_flow_table_offload_setup, ++ .action = nf_flow_rule_route_inet, ++ .free = nf_flow_table_free, ++ .hook = xt_flowoffload_net_hook, ++ .owner = THIS_MODULE, ++}; ++ ++static int init_flowtable(struct xt_flowoffload_table *tbl) ++{ ++ INIT_DELAYED_WORK(&tbl->work, xt_flowoffload_hook_work); ++ tbl->ft.type = &flowtable_inet; ++ tbl->ft.flags = NF_FLOWTABLE_COUNTER; ++ ++ return nf_flow_table_init(&tbl->ft); ++} ++ ++static int __init xt_flowoffload_tg_init(void) ++{ ++ int ret; ++ ++ register_netdevice_notifier(&flow_offload_netdev_notifier); ++ ++ ret = init_flowtable(&flowtable[0]); ++ if (ret) ++ return ret; ++ ++ ret = init_flowtable(&flowtable[1]); ++ if (ret) ++ goto cleanup; ++ ++ flowtable[1].ft.flags |= NF_FLOWTABLE_HW_OFFLOAD; ++ ++ ret = xt_register_target(&offload_tg_reg); ++ if (ret) ++ goto cleanup2; ++ ++ return 0; ++ ++cleanup2: ++ nf_flow_table_free(&flowtable[1].ft); ++cleanup: ++ nf_flow_table_free(&flowtable[0].ft); ++ return ret; ++} ++ ++static void __exit xt_flowoffload_tg_exit(void) ++{ ++ xt_unregister_target(&offload_tg_reg); ++ unregister_netdevice_notifier(&flow_offload_netdev_notifier); ++ nf_flow_table_free(&flowtable[0].ft); ++ nf_flow_table_free(&flowtable[1].ft); ++} ++ ++MODULE_LICENSE("GPL"); ++module_init(xt_flowoffload_tg_init); ++module_exit(xt_flowoffload_tg_exit); +--- a/net/netfilter/nf_flow_table_core.c ++++ b/net/netfilter/nf_flow_table_core.c +@@ -7,7 +7,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -373,8 +372,7 @@ flow_offload_lookup(struct nf_flowtable + } + EXPORT_SYMBOL_GPL(flow_offload_lookup); + +-static int +-nf_flow_table_iterate(struct nf_flowtable *flow_table, ++int nf_flow_table_iterate(struct nf_flowtable *flow_table, + void (*iter)(struct nf_flowtable *flowtable, + struct flow_offload *flow, void *data), + void *data) +@@ -435,6 +433,7 @@ static void nf_flow_offload_gc_step(stru + nf_flow_offload_stats(flow_table, flow); + } + } ++EXPORT_SYMBOL_GPL(nf_flow_table_iterate); + + void nf_flow_table_gc_run(struct nf_flowtable *flow_table) + { +--- /dev/null ++++ b/include/uapi/linux/netfilter/xt_FLOWOFFLOAD.h +@@ -0,0 +1,17 @@ ++/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ ++#ifndef _XT_FLOWOFFLOAD_H ++#define _XT_FLOWOFFLOAD_H ++ ++#include ++ ++enum { ++ XT_FLOWOFFLOAD_HW = 1 << 0, ++ ++ XT_FLOWOFFLOAD_MASK = XT_FLOWOFFLOAD_HW ++}; ++ ++struct xt_flowoffload_target_info { ++ __u32 flags; ++}; ++ ++#endif /* _XT_FLOWOFFLOAD_H */ +--- a/include/net/netfilter/nf_flow_table.h ++++ b/include/net/netfilter/nf_flow_table.h +@@ -294,6 +294,11 @@ void nf_flow_table_free(struct nf_flowta + + void flow_offload_teardown(struct flow_offload *flow); + ++int nf_flow_table_iterate(struct nf_flowtable *flow_table, ++ void (*iter)(struct nf_flowtable *flowtable, ++ struct flow_offload *flow, void *data), ++ void *data); ++ + void nf_flow_snat_port(const struct flow_offload *flow, + struct sk_buff *skb, unsigned int thoff, + u8 protocol, enum flow_offload_tuple_dir dir); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/651-wireless_mesh_header.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/651-wireless_mesh_header.patch new file mode 100755 index 0000000..d3f85ea --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/651-wireless_mesh_header.patch @@ -0,0 +1,24 @@ +From 6d3bc769657b0ee7c7506dad9911111c4226a7ea Mon Sep 17 00:00:00 2001 +From: Imre Kaloz +Date: Fri, 7 Jul 2017 17:21:05 +0200 +Subject: mac80211: increase wireless mesh header size + +lede-commit 3d4466cfd8f75f717efdb1f96fdde3c70d865fc1 +Signed-off-by: Imre Kaloz +--- + include/linux/netdevice.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -159,8 +159,8 @@ static inline bool dev_xmit_complete(int + + #if defined(CONFIG_HYPERV_NET) + # define LL_MAX_HEADER 128 +-#elif defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25) +-# if defined(CONFIG_MAC80211_MESH) ++#elif defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25) || 1 ++# if defined(CONFIG_MAC80211_MESH) || 1 + # define LL_MAX_HEADER 128 + # else + # define LL_MAX_HEADER 96 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/660-fq_codel_defaults.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/660-fq_codel_defaults.patch new file mode 100755 index 0000000..4d7b01d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/660-fq_codel_defaults.patch @@ -0,0 +1,27 @@ +From a6ccb238939b25851474a279b20367fd24a0e816 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Fri, 7 Jul 2017 17:21:53 +0200 +Subject: hack: net: fq_codel: tune defaults for small devices + +Assume that x86_64 devices always have a big memory and do not need this +optimization compared to devices with only 32 MB or 64 MB RAM. + +Signed-off-by: Felix Fietkau +--- + net/sched/sch_fq_codel.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/sched/sch_fq_codel.c ++++ b/net/sched/sch_fq_codel.c +@@ -472,7 +472,11 @@ static int fq_codel_init(struct Qdisc *s + + sch->limit = 10*1024; + q->flows_cnt = 1024; ++#ifdef CONFIG_X86_64 + q->memory_limit = 32 << 20; /* 32 MBytes */ ++#else ++ q->memory_limit = 4 << 20; /* 4 MBytes */ ++#endif + q->drop_batch_size = 64; + q->quantum = psched_mtu(qdisc_dev(sch)); + INIT_LIST_HEAD(&q->new_flows); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/661-kernel-ct-size-the-hashtable-more-adequately.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/661-kernel-ct-size-the-hashtable-more-adequately.patch new file mode 100755 index 0000000..b4bf160 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/661-kernel-ct-size-the-hashtable-more-adequately.patch @@ -0,0 +1,25 @@ +From 804fbb3f2ec9283f7b778e057a68bfff440a0be6 Mon Sep 17 00:00:00 2001 +From: Rui Salvaterra +Date: Wed, 30 Mar 2022 22:51:55 +0100 +Subject: [PATCH] kernel: ct: size the hashtable more adequately + +To set the default size of the connection tracking hash table, a divider of +16384 becomes inadequate for a router handling lots of connections. Divide by +2048 instead, making the default size scale better with the available RAM. + +Signed-off-by: Rui Salvaterra +--- + net/netfilter/nf_conntrack_core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/netfilter/nf_conntrack_core.c ++++ b/net/netfilter/nf_conntrack_core.c +@@ -2648,7 +2648,7 @@ int nf_conntrack_init_start(void) + + if (!nf_conntrack_htable_size) { + nf_conntrack_htable_size +- = (((nr_pages << PAGE_SHIFT) / 16384) ++ = (((nr_pages << PAGE_SHIFT) / 2048) + / sizeof(struct hlist_head)); + if (BITS_PER_LONG >= 64 && + nr_pages > (4 * (1024 * 1024 * 1024 / PAGE_SIZE))) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/700-swconfig_switch_drivers.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/700-swconfig_switch_drivers.patch new file mode 100755 index 0000000..ff235dd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/700-swconfig_switch_drivers.patch @@ -0,0 +1,131 @@ +From 36e516290611e613aa92996cb4339561452695b4 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Fri, 7 Jul 2017 17:24:23 +0200 +Subject: net: swconfig: adds openwrt switch layer + +Signed-off-by: Felix Fietkau +--- + drivers/net/phy/Kconfig | 83 +++++++++++++++++++++++++++++++++++++++++++++++ + drivers/net/phy/Makefile | 15 +++++++++ + include/uapi/linux/Kbuild | 1 + + 3 files changed, 99 insertions(+) + +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -77,6 +77,80 @@ config SFP + depends on HWMON || HWMON=n + select MDIO_I2C + ++comment "Switch configuration API + drivers" ++ ++config SWCONFIG ++ tristate "Switch configuration API" ++ help ++ Switch configuration API using netlink. This allows ++ you to configure the VLAN features of certain switches. ++ ++config SWCONFIG_LEDS ++ bool "Switch LED trigger support" ++ depends on (SWCONFIG && LEDS_TRIGGERS) ++ ++config ADM6996_PHY ++ tristate "Driver for ADM6996 switches" ++ select SWCONFIG ++ help ++ Currently supports the ADM6996FC and ADM6996M switches. ++ Support for FC is very limited. ++ ++config AR8216_PHY ++ tristate "Driver for Atheros AR8216/8327 switches" ++ select SWCONFIG ++ select ETHERNET_PACKET_MANGLE ++ ++config AR8216_PHY_LEDS ++ bool "Atheros AR8216 switch LED support" ++ depends on (AR8216_PHY && LEDS_CLASS) ++ ++source "drivers/net/phy/b53/Kconfig" ++ ++config IP17XX_PHY ++ tristate "Driver for IC+ IP17xx switches" ++ select SWCONFIG ++ ++config PSB6970_PHY ++ tristate "Lantiq XWAY Tantos (PSB6970) Ethernet switch" ++ select SWCONFIG ++ ++config RTL8306_PHY ++ tristate "Driver for Realtek RTL8306S switches" ++ select SWCONFIG ++ ++config RTL8366_SMI ++ tristate "Driver for the RTL8366 SMI interface" ++ depends on GPIOLIB ++ help ++ This module implements the SMI interface protocol which is used ++ by some RTL8366 ethernet switch devices via the generic GPIO API. ++ ++if RTL8366_SMI ++ ++config RTL8366_SMI_DEBUG_FS ++ bool "RTL8366 SMI interface debugfs support" ++ depends on DEBUG_FS ++ default n ++ ++config RTL8366S_PHY ++ tristate "Driver for the Realtek RTL8366S switch" ++ select SWCONFIG ++ ++config RTL8366RB_PHY ++ tristate "Driver for the Realtek RTL8366RB switch" ++ select SWCONFIG ++ ++config RTL8367_PHY ++ tristate "Driver for the Realtek RTL8367R/M switches" ++ select SWCONFIG ++ ++config RTL8367B_PHY ++ tristate "Driver for the Realtek RTL8367R-VB switch" ++ select SWCONFIG ++ ++endif # RTL8366_SMI ++ + comment "MII PHY device drivers" + + config AS21XXX_PHY +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -27,6 +27,21 @@ libphy-$(CONFIG_OPEN_ALLIANCE_HELPERS) + + obj-$(CONFIG_PHYLINK) += phylink.o + obj-$(CONFIG_PHYLIB) += libphy.o + ++obj-$(CONFIG_SWCONFIG) += swconfig.o ++obj-$(CONFIG_ADM6996_PHY) += adm6996.o ++obj-$(CONFIG_AR8216_PHY) += ar8xxx.o ++ar8xxx-y += ar8216.o ++ar8xxx-y += ar8327.o ++obj-$(CONFIG_SWCONFIG_B53) += b53/ ++obj-$(CONFIG_IP17XX_PHY) += ip17xx.o ++obj-$(CONFIG_PSB6970_PHY) += psb6970.o ++obj-$(CONFIG_RTL8306_PHY) += rtl8306.o ++obj-$(CONFIG_RTL8366_SMI) += rtl8366_smi.o ++obj-$(CONFIG_RTL8366S_PHY) += rtl8366s.o ++obj-$(CONFIG_RTL8366RB_PHY) += rtl8366rb.o ++obj-$(CONFIG_RTL8367_PHY) += rtl8367.o ++obj-$(CONFIG_RTL8367B_PHY) += rtl8367b.o ++ + obj-$(CONFIG_NETWORK_PHY_TIMESTAMPING) += mii_timestamper.o + + obj-$(CONFIG_SFP) += sfp.o +--- a/include/linux/platform_data/b53.h ++++ b/include/linux/platform_data/b53.h +@@ -29,6 +29,9 @@ struct b53_platform_data { + u32 chip_id; + u16 enabled_ports; + ++ /* allow to specify an ethX alias */ ++ const char *alias; ++ + /* only used by MMAP'd driver */ + unsigned big_endian:1; + void __iomem *regs; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch new file mode 100755 index 0000000..29ac3e9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/711-net-dsa-mv88e6xxx-disable-ATU-violation.patch @@ -0,0 +1,21 @@ +From ebd924d773223593142d417c41d4ee6fa16f1805 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 13:45:56 +0200 +Subject: [PATCH] net/dsa/mv88e6xxx: disable ATU violation + +--- + drivers/net/dsa/mv88e6xxx/chip.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/dsa/mv88e6xxx/chip.c ++++ b/drivers/net/dsa/mv88e6xxx/chip.c +@@ -3583,6 +3583,9 @@ static int mv88e6xxx_setup_port(struct m + else + reg = 1 << port; + ++ /* Disable ATU member violation interrupt */ ++ reg |= MV88E6XXX_PORT_ASSOC_VECTOR_IGNORE_WRONG; ++ + err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, + reg); + if (err) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/721-net-add-packet-mangeling.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/721-net-add-packet-mangeling.patch new file mode 100755 index 0000000..599713b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/721-net-add-packet-mangeling.patch @@ -0,0 +1,159 @@ +From ffe387740bbe88dd88bbe04d6375902708003d6e Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Fri, 7 Jul 2017 17:25:00 +0200 +Subject: net: add packet mangeling + +ar8216 switches have a hardware bug, which renders normal 802.1q support +unusable. Packet mangling is required to fix up the vlan for incoming +packets. + +Signed-off-by: Felix Fietkau +--- + include/linux/netdevice.h | 10 ++++++++++ + include/linux/skbuff.h | 14 ++++---------- + net/Kconfig | 6 ++++++ + net/core/dev.c | 20 +++++++++++++++----- + net/core/skbuff.c | 17 +++++++++++++++++ + net/ethernet/eth.c | 6 ++++++ + 6 files changed, 58 insertions(+), 15 deletions(-) + +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1687,6 +1687,7 @@ enum netdev_priv_flags { + IFF_L3MDEV_RX_HANDLER = 1<<29, + IFF_NO_ADDRCONF = BIT_ULL(30), + IFF_TX_SKB_NO_LINEAR = BIT_ULL(31), ++ IFF_NO_IP_ALIGN = BIT_ULL(32), + }; + + /* Specifies the type of the struct net_device::ml_priv pointer */ +@@ -2168,6 +2169,11 @@ struct net_device { + const struct tlsdev_ops *tlsdev_ops; + #endif + ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE ++ void (*eth_mangle_rx)(struct net_device *dev, struct sk_buff *skb); ++ struct sk_buff *(*eth_mangle_tx)(struct net_device *dev, struct sk_buff *skb); ++#endif ++ + unsigned int operstate; + unsigned char link_mode; + +@@ -2237,6 +2243,10 @@ struct net_device { + struct mctp_dev __rcu *mctp_ptr; + #endif + ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE ++ void *phy_ptr; /* PHY device specific data */ ++#endif ++ + /* + * Cache lines mostly used on receive path (including eth_type_trans()) + */ +--- a/include/linux/skbuff.h ++++ b/include/linux/skbuff.h +@@ -3242,6 +3242,10 @@ static inline int pskb_trim(struct sk_bu + return (len < skb->len) ? __pskb_trim(skb, len) : 0; + } + ++extern struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, ++ unsigned int length, gfp_t gfp); ++ ++ + /** + * pskb_trim_unique - remove end from a paged unique (not cloned) buffer + * @skb: buffer to alter +@@ -3407,16 +3411,6 @@ static inline struct sk_buff *dev_alloc_ + } + + +-static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, +- unsigned int length, gfp_t gfp) +-{ +- struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); +- +- if (NET_IP_ALIGN && skb) +- skb_reserve(skb, NET_IP_ALIGN); +- return skb; +-} +- + static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length) + { +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -26,6 +26,12 @@ menuconfig NET + + if NET + ++config ETHERNET_PACKET_MANGLE ++ bool ++ help ++ This option can be selected by phy drivers that need to mangle ++ packets going in or out of an ethernet device. ++ + config WANT_COMPAT_NETLINK_MESSAGES + bool + help +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -3671,6 +3671,11 @@ static int xmit_one(struct sk_buff *skb, + if (dev_nit_active(dev)) + dev_queue_xmit_nit(skb, dev); + ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE ++ if (dev->eth_mangle_tx && !(skb = dev->eth_mangle_tx(dev, skb))) ++ return NETDEV_TX_OK; ++#endif ++ + len = skb->len; + trace_net_dev_start_xmit(skb, dev); + rc = netdev_start_xmit(skb, dev, txq, more); +--- a/net/core/skbuff.c ++++ b/net/core/skbuff.c +@@ -64,6 +64,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -326,6 +327,22 @@ void *__napi_alloc_frag_align(unsigned i + } + EXPORT_SYMBOL(__napi_alloc_frag_align); + ++struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, ++ unsigned int length, gfp_t gfp) ++{ ++ struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); ++ ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE ++ if (dev && (dev->priv_flags & IFF_NO_IP_ALIGN)) ++ return skb; ++#endif ++ ++ if (NET_IP_ALIGN && skb) ++ skb_reserve(skb, NET_IP_ALIGN); ++ return skb; ++} ++EXPORT_SYMBOL(__netdev_alloc_skb_ip_align); ++ + void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) + { + void *data; +--- a/net/ethernet/eth.c ++++ b/net/ethernet/eth.c +@@ -159,6 +159,12 @@ __be16 eth_type_trans(struct sk_buff *sk + const struct ethhdr *eth; + + skb->dev = dev; ++ ++#ifdef CONFIG_ETHERNET_PACKET_MANGLE ++ if (dev->eth_mangle_rx) ++ dev->eth_mangle_rx(dev, skb); ++#endif ++ + skb_reset_mac_header(skb); + + eth = eth_skb_pull_mac(skb); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch new file mode 100755 index 0000000..2d7edc9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/722-net-phy-aquantia-enable-AQR112-and-AQR412.patch @@ -0,0 +1,117 @@ +From 5f62951fba63a9f9cfff564209426bdea5fcc371 Mon Sep 17 00:00:00 2001 +From: Alex Marginean +Date: Tue, 27 Aug 2019 15:16:56 +0300 +Subject: [PATCH] drivers: net: phy: aquantia: enable AQR112 and AQR412 + +Adds support for AQR112 and AQR412 which is mostly based on existing code +with the addition of code configuring the protocol on system side. +This allows changing the system side protocol without having to deploy a +different firmware on the PHY. + +Signed-off-by: Alex Marginean +--- + drivers/net/phy/aquantia/aquantia_main.c | 88 +++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 88 insertions(+) + +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -97,6 +97,29 @@ + #define AQR107_OP_IN_PROG_SLEEP 1000 + #define AQR107_OP_IN_PROG_TIMEOUT 100000 + ++/* registers in MDIO_MMD_VEND1 region */ ++#define AQUANTIA_VND1_GLOBAL_SC 0x000 ++#define AQUANTIA_VND1_GLOBAL_SC_LP BIT(0xb) ++ ++/* global start rate, the protocol associated with this speed is used by default ++ * on SI. ++ */ ++#define AQUANTIA_VND1_GSTART_RATE 0x31a ++#define AQUANTIA_VND1_GSTART_RATE_OFF 0 ++#define AQUANTIA_VND1_GSTART_RATE_100M 1 ++#define AQUANTIA_VND1_GSTART_RATE_1G 2 ++#define AQUANTIA_VND1_GSTART_RATE_10G 3 ++#define AQUANTIA_VND1_GSTART_RATE_2_5G 4 ++#define AQUANTIA_VND1_GSTART_RATE_5G 5 ++ ++/* SYSCFG registers for 100M, 1G, 2.5G, 5G, 10G */ ++#define AQUANTIA_VND1_GSYSCFG_BASE 0x31b ++#define AQUANTIA_VND1_GSYSCFG_100M 0 ++#define AQUANTIA_VND1_GSYSCFG_1G 1 ++#define AQUANTIA_VND1_GSYSCFG_2_5G 2 ++#define AQUANTIA_VND1_GSYSCFG_5G 3 ++#define AQUANTIA_VND1_GSYSCFG_10G 4 ++ + static int aqr107_get_sset_count(struct phy_device *phydev) + { + return AQR107_SGMII_STAT_SZ; +@@ -203,6 +226,51 @@ static int aqr_config_aneg(struct phy_de + return genphy_c45_check_and_restart_aneg(phydev, changed); + } + ++static struct { ++ u16 syscfg; ++ int cnt; ++ u16 start_rate; ++} aquantia_syscfg[PHY_INTERFACE_MODE_MAX] = { ++ [PHY_INTERFACE_MODE_SGMII] = {0x04b, AQUANTIA_VND1_GSYSCFG_1G, ++ AQUANTIA_VND1_GSTART_RATE_1G}, ++ [PHY_INTERFACE_MODE_2500BASEX] = {0x144, AQUANTIA_VND1_GSYSCFG_2_5G, ++ AQUANTIA_VND1_GSTART_RATE_2_5G}, ++ [PHY_INTERFACE_MODE_XGMII] = {0x100, AQUANTIA_VND1_GSYSCFG_10G, ++ AQUANTIA_VND1_GSTART_RATE_10G}, ++ [PHY_INTERFACE_MODE_USXGMII] = {0x080, AQUANTIA_VND1_GSYSCFG_10G, ++ AQUANTIA_VND1_GSTART_RATE_10G}, ++}; ++ ++/* Sets up protocol on system side before calling aqr_config_aneg */ ++static int aqr_config_aneg_set_prot(struct phy_device *phydev) ++{ ++ int if_type = phydev->interface; ++ int i; ++ ++ if (!aquantia_syscfg[if_type].cnt) ++ return 0; ++ ++ /* set PHY in low power mode so we can configure protocols */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, ++ AQUANTIA_VND1_GLOBAL_SC_LP); ++ mdelay(10); ++ ++ /* set the default rate to enable the SI link */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GSTART_RATE, ++ aquantia_syscfg[if_type].start_rate); ++ ++ for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++) ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, ++ AQUANTIA_VND1_GSYSCFG_BASE + i, ++ aquantia_syscfg[if_type].syscfg); ++ ++ /* wake PHY back up */ ++ phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0); ++ mdelay(10); ++ ++ return aqr_config_aneg(phydev); ++} ++ + static int aqr_config_intr(struct phy_device *phydev) + { + bool en = phydev->interrupts == PHY_INTERRUPT_ENABLED; +@@ -972,7 +1040,7 @@ static struct phy_driver aqr_driver[] = + PHY_ID_MATCH_MODEL(PHY_ID_AQR112), + .name = "Aquantia AQR112", + .probe = aqr107_probe, +- .config_aneg = aqr_config_aneg, ++ .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .handle_interrupt = aqr_handle_interrupt, + .get_tunable = aqr107_get_tunable, +@@ -995,7 +1063,7 @@ static struct phy_driver aqr_driver[] = + PHY_ID_MATCH_MODEL(PHY_ID_AQR412), + .name = "Aquantia AQR412", + .probe = aqr107_probe, +- .config_aneg = aqr_config_aneg, ++ .config_aneg = aqr_config_aneg_set_prot, + .config_intr = aqr_config_intr, + .handle_interrupt = aqr_handle_interrupt, + .get_tunable = aqr107_get_tunable, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/723-net-phy-aquantia-fix-system-side-protocol-mi.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/723-net-phy-aquantia-fix-system-side-protocol-mi.patch new file mode 100755 index 0000000..eaeb3b6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/723-net-phy-aquantia-fix-system-side-protocol-mi.patch @@ -0,0 +1,34 @@ +From 5f008cb22f60da4e10375f22266c1a4e20b1252e Mon Sep 17 00:00:00 2001 +From: Alex Marginean +Date: Fri, 20 Sep 2019 18:22:52 +0300 +Subject: [PATCH] drivers: net: phy: aquantia: fix system side protocol + misconfiguration + +Do not set up protocols for speeds that are not supported by FW. Enabling +these protocols leads to link issues on system side. + +Signed-off-by: Alex Marginean +--- + drivers/net/phy/aquantia/aquantia_main.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -259,10 +259,16 @@ static int aqr_config_aneg_set_prot(stru + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GSTART_RATE, + aquantia_syscfg[if_type].start_rate); + +- for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++) ++ for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++) { ++ u16 reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, ++ AQUANTIA_VND1_GSYSCFG_BASE + i); ++ if (!reg) ++ continue; ++ + phy_write_mmd(phydev, MDIO_MMD_VEND1, + AQUANTIA_VND1_GSYSCFG_BASE + i, + aquantia_syscfg[if_type].syscfg); ++ } + + /* wake PHY back up */ + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch new file mode 100755 index 0000000..98c4186 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/725-net-phy-aquantia-add-PHY_IDs-for-AQR112-variants.patch @@ -0,0 +1,63 @@ +From 3b92ee7b7899b6beffb2b484c58326e36612a873 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 23 Dec 2021 14:52:56 +0000 +Subject: [PATCH] net: phy: aquantia: add PHY_ID for AQR112R + +As advised by Ian Chang this PHY is used in Puzzle devices. + +Signed-off-by: Daniel Golle +--- + drivers/net/phy/aquantia/aquantia_main.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/net/phy/aquantia/aquantia_main.c ++++ b/drivers/net/phy/aquantia/aquantia_main.c +@@ -32,6 +32,8 @@ + #define PHY_ID_AQR114C 0x31c31c22 + #define PHY_ID_AQR115C 0x31c31c33 + #define PHY_ID_AQR813 0x31c31cb2 ++#define PHY_ID_AQR112C 0x03a1b790 ++#define PHY_ID_AQR112R 0x31c31d12 + + #define MDIO_PHYXS_VEND_IF_STATUS 0xe812 + #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3) +@@ -1205,6 +1207,30 @@ static struct phy_driver aqr_driver[] = + .led_hw_control_get = aqr_phy_led_hw_control_get, + .led_polarity_set = aqr_phy_led_polarity_set, + }, ++{ ++ PHY_ID_MATCH_MODEL(PHY_ID_AQR112C), ++ .name = "Aquantia AQR112C", ++ .probe = aqr107_probe, ++ .config_aneg = aqr_config_aneg_set_prot, ++ .config_intr = aqr_config_intr, ++ .handle_interrupt = aqr_handle_interrupt, ++ .read_status = aqr107_read_status, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, ++}, ++{ ++ PHY_ID_MATCH_MODEL(PHY_ID_AQR112R), ++ .name = "Aquantia AQR112R", ++ .probe = aqr107_probe, ++ .config_aneg = aqr_config_aneg_set_prot, ++ .config_intr = aqr_config_intr, ++ .handle_interrupt = aqr_handle_interrupt, ++ .read_status = aqr107_read_status, ++ .get_sset_count = aqr107_get_sset_count, ++ .get_strings = aqr107_get_strings, ++ .get_stats = aqr107_get_stats, ++}, + }; + + module_phy_driver(aqr_driver); +@@ -1226,6 +1252,8 @@ static const struct mdio_device_id __may + { PHY_ID_MATCH_MODEL(PHY_ID_AQR114C) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR115C) }, + { PHY_ID_MATCH_MODEL(PHY_ID_AQR813) }, ++ { PHY_ID_MATCH_MODEL(PHY_ID_AQR112C) }, ++ { PHY_ID_MATCH_MODEL(PHY_ID_AQR112R) }, + { } + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/730-net-ethernet-mtk_eth_soc-add-hw-dump-for-forced-rese.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/730-net-ethernet-mtk_eth_soc-add-hw-dump-for-forced-rese.patch new file mode 100755 index 0000000..4cb8c29 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/730-net-ethernet-mtk_eth_soc-add-hw-dump-for-forced-rese.patch @@ -0,0 +1,115 @@ +From bc51c337a3147c4a02c743489885a6657bc5371c Mon Sep 17 00:00:00 2001 +From: Bo-Cun Chen +Date: Wed, 27 Nov 2024 13:36:49 +0800 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add hw dump for forced reset + +Without this patch, the ETH driver is unable to dump the registers +before triggering a forced reset. + +Signed-off-by: Bo-Cun Chen +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 55 +++++++++++++++++++++ + 1 files changed, 55 insertions(+) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -74,6 +74,7 @@ static const struct mtk_reg_map mtk_reg_ + .rx_ptr = 0x1900, + .rx_cnt_cfg = 0x1904, + .qcrx_ptr = 0x1908, ++ .page = 0x19f0, + .glo_cfg = 0x1a04, + .rst_idx = 0x1a08, + .delay_irq = 0x1a0c, +@@ -140,6 +141,7 @@ static const struct mtk_reg_map mt7986_r + .rx_ptr = 0x4500, + .rx_cnt_cfg = 0x4504, + .qcrx_ptr = 0x4508, ++ .page = 0x45f0, + .glo_cfg = 0x4604, + .rst_idx = 0x4608, + .delay_irq = 0x460c, +@@ -191,6 +193,7 @@ static const struct mtk_reg_map mt7988_r + .rx_ptr = 0x4500, + .rx_cnt_cfg = 0x4504, + .qcrx_ptr = 0x4508, ++ .page = 0x45f0, + .glo_cfg = 0x4604, + .rst_idx = 0x4608, + .delay_irq = 0x460c, +@@ -4060,6 +4063,56 @@ static void mtk_set_mcr_max_rx(struct mt + mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id)); + } + ++static void mtk_hw_dump_reg(struct mtk_eth *eth, char *name, u32 offset, u32 range) ++{ ++ u32 cur = offset; ++ ++ pr_info("\n==================== %s ====================\n", name); ++ while (cur < offset + range) { ++ pr_info("0x%08x: %08x %08x %08x %08x\n", ++ cur, mtk_r32(eth, cur), mtk_r32(eth, cur + 0x4), ++ mtk_r32(eth, cur + 0x8), mtk_r32(eth, cur + 0xc)); ++ cur += 0x10; ++ } ++} ++ ++static void mtk_hw_dump(struct mtk_eth *eth) ++{ ++ const struct mtk_reg_map *reg_map = eth->soc->reg_map; ++ u32 id; ++ ++ mtk_hw_dump_reg(eth, "FE", 0x0, 0x600); ++ mtk_hw_dump_reg(eth, "FE", 0x1400, 0x300); ++ mtk_hw_dump_reg(eth, "ADMA", reg_map->pdma.rx_ptr, 0x300); ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { ++ for (id = 0; id < MTK_QDMA_NUM_QUEUES / 16; id++) { ++ mtk_w32(eth, id, reg_map->qdma.page); ++ pr_info("\nQDMA PAGE:%x ", mtk_r32(eth, reg_map->qdma.page)); ++ mtk_hw_dump_reg(eth, "QDMA", reg_map->qdma.qtx_cfg, 0x100); ++ mtk_w32(eth, 0, reg_map->qdma.page); ++ } ++ mtk_hw_dump_reg(eth, "QDMA", reg_map->qdma.rx_ptr, 0x300); ++ } ++ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) { ++ mtk_hw_dump_reg(eth, "WDMA0", reg_map->wdma_base[0], 0x400); ++ mtk_hw_dump_reg(eth, "WDMA1", reg_map->wdma_base[1], 0x400); ++ if (mtk_is_netsys_v3_or_greater(eth)) ++ mtk_hw_dump_reg(eth, "WDMA2", reg_map->wdma_base[2], 0x400); ++ } ++ mtk_hw_dump_reg(eth, "PPE0", reg_map->ppe_base + 0x200, 0x200); ++ if (!mtk_is_netsys_v1(eth)) ++ mtk_hw_dump_reg(eth, "PPE1", reg_map->ppe_base + 0x600, 0x200); ++ if (mtk_is_netsys_v3_or_greater(eth)) ++ mtk_hw_dump_reg(eth, "PPE2", reg_map->ppe_base + 0xE00, 0x200); ++ mtk_hw_dump_reg(eth, "GMAC", 0x10000, 0x300); ++ if (mtk_is_netsys_v3_or_greater(eth)) ++ mtk_hw_dump_reg(eth, "GMAC", 0x10300, 0x100); ++ if (mtk_is_netsys_v3_or_greater(eth)) { ++ mtk_hw_dump_reg(eth, "XGMAC0", 0x12000, 0x300); ++ mtk_hw_dump_reg(eth, "XGMAC1", 0x13000, 0x300); ++ } ++} ++ + static void mtk_hw_reset(struct mtk_eth *eth) + { + u32 val; +@@ -4539,6 +4592,8 @@ static void mtk_pending_work(struct work + rtnl_lock(); + set_bit(MTK_RESETTING, ð->state); + ++ mtk_hw_dump(eth); ++ + mtk_prepare_for_reset(eth); + mtk_wed_fe_reset(); + /* Run again reset preliminary configuration in order to avoid any +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -1185,6 +1185,7 @@ struct mtk_reg_map { + u32 rx_ptr; /* rx base pointer */ + u32 rx_cnt_cfg; /* rx max count configuration */ + u32 qcrx_ptr; /* rx cpu pointer */ ++ u32 page; /* page configuration */ + u32 glo_cfg; /* global configuration */ + u32 rst_idx; /* reset index */ + u32 delay_irq; /* delay interrupt */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/735-net-phy-realtek-rtl8261n.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/735-net-phy-realtek-rtl8261n.patch new file mode 100755 index 0000000..c9dc250 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/735-net-phy-realtek-rtl8261n.patch @@ -0,0 +1,21 @@ +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -431,6 +431,8 @@ config QSEMI_PHY + + source "drivers/net/phy/realtek/Kconfig" + ++source "drivers/net/phy/rtl8261n/Kconfig" ++ + config RENESAS_PHY + tristate "Renesas PHYs" + help +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -110,6 +110,7 @@ obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja + obj-y += qcom/ + obj-$(CONFIG_QSEMI_PHY) += qsemi.o + obj-$(CONFIG_REALTEK_PHY) += realtek/ ++obj-y += rtl8261n/ + obj-$(CONFIG_RENESAS_PHY) += uPD60620.o + obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o + obj-$(CONFIG_SMSC_PHY) += smsc.o diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch new file mode 100755 index 0000000..bf26a2f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch @@ -0,0 +1,64 @@ +From 880d1311335120f64447ca9d11933872d734e19a Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 27 Mar 2023 18:41:54 +0100 +Subject: [PATCH] generic: pcs-mtk-lynxi: add hack to use 2500Base-X without AN + +Using 2500Base-T SFP modules e.g. on the BananaPi R3 requires manually +disabling auto-negotiation, e.g. using ethtool. While a proper fix +using SFP quirks is being discussed upstream, bring a work-around to +restore user experience to what it was before the switch to the +dedicated SGMII PCS driver. + +Signed-off-by: Daniel Golle + +--- a/drivers/net/pcs/pcs-mtk-lynxi.c ++++ b/drivers/net/pcs/pcs-mtk-lynxi.c +@@ -129,14 +129,23 @@ static void mtk_pcs_lynxi_get_state(stru + struct phylink_link_state *state) + { + struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); +- unsigned int bm, adv; ++ unsigned int bm, bmsr, adv; + + /* Read the BMSR and LPA */ + regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm); +- regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv); ++ bmsr = FIELD_GET(SGMII_BMSR, bm); ++ ++ if (state->interface == PHY_INTERFACE_MODE_2500BASEX) { ++ state->link = !!(bmsr & BMSR_LSTATUS); ++ state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE); ++ state->speed = SPEED_2500; ++ state->duplex = DUPLEX_FULL; ++ ++ return; ++ } + +- phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm), +- FIELD_GET(SGMII_LPA, adv)); ++ regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv); ++ phylink_mii_c22_pcs_decode_state(state, bmsr, FIELD_GET(SGMII_LPA, adv)); + } + + static void mtk_sgmii_reset(struct mtk_pcs_lynxi *mpcs) +@@ -157,7 +166,7 @@ static int mtk_pcs_lynxi_config(struct p + { + struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); + bool mode_changed = false, changed; +- unsigned int rgc3, sgm_mode, bmcr; ++ unsigned int rgc3, sgm_mode, bmcr = 0; + int advertise, link_timer; + + advertise = phylink_mii_c22_pcs_encode_advertisement(interface, +@@ -180,9 +189,8 @@ static int mtk_pcs_lynxi_config(struct p + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { + if (interface == PHY_INTERFACE_MODE_SGMII) + sgm_mode |= SGMII_SPEED_DUPLEX_AN; +- bmcr = BMCR_ANENABLE; +- } else { +- bmcr = 0; ++ if (interface != PHY_INTERFACE_MODE_2500BASEX) ++ bmcr = BMCR_ANENABLE; + } + + if (mpcs->interface != interface) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/760-net-usb-r8152-add-LED-configuration-from-OF.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/760-net-usb-r8152-add-LED-configuration-from-OF.patch new file mode 100755 index 0000000..3b61638 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/760-net-usb-r8152-add-LED-configuration-from-OF.patch @@ -0,0 +1,74 @@ +From 82985725e071f2a5735052f18e109a32aeac3a0b Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Sun, 26 Jul 2020 02:38:31 +0200 +Subject: [PATCH] net: usb: r8152: add LED configuration from OF + +This adds the ability to configure the LED configuration register using +OF. This way, the correct value for board specific LED configuration can +be determined. + +Signed-off-by: David Bauer +--- + drivers/net/usb/r8152.c | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +--- a/drivers/net/usb/r8152.c ++++ b/drivers/net/usb/r8152.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -7047,6 +7048,22 @@ static void rtl_tally_reset(struct r8152 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data); + } + ++static int r8152_led_configuration(struct r8152 *tp) ++{ ++ u32 led_data; ++ int ret; ++ ++ ret = of_property_read_u32(tp->udev->dev.of_node, "realtek,led-data", ++ &led_data); ++ ++ if (ret) ++ return ret; ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, led_data); ++ ++ return 0; ++} ++ + static void r8152b_init(struct r8152 *tp) + { + u32 ocp_data; +@@ -7088,6 +7105,8 @@ static void r8152b_init(struct r8152 *tp + ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL); + ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN); + ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data); ++ ++ r8152_led_configuration(tp); + } + + static void r8153_init(struct r8152 *tp) +@@ -7228,6 +7247,8 @@ static void r8153_init(struct r8152 *tp) + tp->coalesce = COALESCE_SLOW; + break; + } ++ ++ r8152_led_configuration(tp); + } + + static void r8153b_init(struct r8152 *tp) +@@ -7310,6 +7331,8 @@ static void r8153b_init(struct r8152 *tp + rtl_tally_reset(tp); + + tp->coalesce = 15000; /* 15 us */ ++ ++ r8152_led_configuration(tp); + } + + static void r8153c_init(struct r8152 *tp) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/761-dt-bindings-net-add-RTL8152-binding-documentation.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/761-dt-bindings-net-add-RTL8152-binding-documentation.patch new file mode 100755 index 0000000..be262b9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/761-dt-bindings-net-add-RTL8152-binding-documentation.patch @@ -0,0 +1,54 @@ +From 3ee05f4aa64fc86af3be5bc176ba5808de9260a7 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Sun, 26 Jul 2020 15:30:33 +0200 +Subject: [PATCH] dt-bindings: net: add RTL8152 binding documentation + +Add binding documentation for the Realtek RTL8152 / RTL8153 USB ethernet +adapters. + +Signed-off-by: David Bauer +--- + .../bindings/net/realtek,rtl8152.yaml | 36 +++++++++++++++++++ + 1 file changed, 36 insertions(+) + create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8152.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/net/realtek,rtl8152.yaml +@@ -0,0 +1,36 @@ ++# SPDX-License-Identifier: GPL-2.0 ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/net/realtek,rtl8152.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: Realtek RTL8152/RTL8153 series USB ethernet ++ ++maintainers: ++ - David Bauer ++ ++properties: ++ compatible: ++ oneOf: ++ - items: ++ - enum: ++ - realtek,rtl8152 ++ - realtek,rtl8153 ++ ++ reg: ++ description: The device number on the USB bus ++ ++ realtek,led-data: ++ description: Value to be written to the LED configuration register. ++ ++required: ++ - compatible ++ - reg ++ ++examples: ++ - | ++ usb-eth@2 { ++ compatible = "realtek,rtl8153"; ++ reg = <2>; ++ realtek,led-data = <0x87>; ++ }; +\ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch new file mode 100755 index 0000000..2eeca8f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/766-net-phy-mediatek-ge-add-LED-configuration-interface.patch @@ -0,0 +1,72 @@ +From cc225d163b5a4f7a0d1968298bf7927306646a47 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Fri, 28 Apr 2023 01:53:01 +0200 +Subject: [PATCH] net: phy: mediatek-ge: add LED configuration interface + +This adds a small hack similar to the one used for ar8xxx switches to +read a reg:value map for configuring the LED configuration registers. + +This allows OpenWrt to write device-specific LED action as well as blink +configurations. It is unlikely to be accepted upstream, as upstream +plans on integrating their own framework for handling these LEDs. + +Signed-off-by: David Bauer +--- + drivers/net/phy/mediatek/mtk-ge.c | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +--- a/drivers/net/phy/mediatek/mtk-ge.c ++++ b/drivers/net/phy/mediatek/mtk-ge.c +@@ -1,4 +1,5 @@ + // SPDX-License-Identifier: GPL-2.0+ ++#include + #include + #include + #include +@@ -73,6 +74,36 @@ static int mt7530_phy_config_init(struct + return 0; + } + ++static int mt7530_led_config_of(struct phy_device *phydev) ++{ ++ struct device_node *np = phydev->mdio.dev.of_node; ++ const __be32 *paddr; ++ int len; ++ int i; ++ ++ paddr = of_get_property(np, "mediatek,led-config", &len); ++ if (!paddr) ++ return 0; ++ ++ if (len < (2 * sizeof(*paddr))) ++ return -EINVAL; ++ ++ len /= sizeof(*paddr); ++ ++ phydev_warn(phydev, "Configure LED registers (num=%d)\n", len); ++ for (i = 0; i < len - 1; i += 2) { ++ u32 reg; ++ u32 val; ++ ++ reg = be32_to_cpup(paddr + i); ++ val = be32_to_cpup(paddr + i + 1); ++ ++ phy_write_mmd(phydev, MDIO_MMD_VEND2, reg, val); ++ } ++ ++ return 0; ++} ++ + static int mt7531_phy_config_init(struct phy_device *phydev) + { + mtk_gephy_config_init(phydev); +@@ -93,6 +124,9 @@ static int mt7531_phy_config_init(struct + FIELD_PREP(MTK_TX_DELAY_PAIR_B_MASK, 0x4) | + FIELD_PREP(MTK_TX_DELAY_PAIR_D_MASK, 0x4)); + ++ /* LED Config*/ ++ mt7530_led_config_of(phydev); ++ + return 0; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/770-r8169-LED-uses-original-network-port-name.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/770-r8169-LED-uses-original-network-port-name.patch new file mode 100755 index 0000000..55d4b48 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/770-r8169-LED-uses-original-network-port-name.patch @@ -0,0 +1,89 @@ +From 5f8e52f3991c794be69af13170e5c54e5afe0674 Mon Sep 17 00:00:00 2001 +From: Chukun Pan +Date: Sun, 5 Jan 2025 18:08:29 +0800 +Subject: [PATCH] r8169: LED uses original network port name + +Most Linux distributions use Predictable Network Interface Names +to name PCIe network interfaces (systemd-udevd renames them). +Since OpenWrt doesn't use this, let's use the original network +port name in the driver to match the LED. + +Signed-off-by: Chukun Pan +--- + +--- a/drivers/net/ethernet/realtek/r8169.h ++++ b/drivers/net/ethernet/realtek/r8169.h +@@ -84,8 +84,6 @@ u8 rtl8168d_efuse_read(struct rtl8169_pr + void r8169_hw_phy_config(struct rtl8169_private *tp, struct phy_device *phydev, + enum mac_version ver); + +-void r8169_get_led_name(struct rtl8169_private *tp, int idx, +- char *buf, int buf_len); + int rtl8168_get_led_mode(struct rtl8169_private *tp); + int rtl8168_led_mod_ctrl(struct rtl8169_private *tp, u16 mask, u16 val); + struct r8169_led_classdev *rtl8168_init_leds(struct net_device *ndev); +--- a/drivers/net/ethernet/realtek/r8169_leds.c ++++ b/drivers/net/ethernet/realtek/r8169_leds.c +@@ -129,14 +129,13 @@ static struct device * + static void rtl8168_setup_ldev(struct r8169_led_classdev *ldev, + struct net_device *ndev, int index) + { +- struct rtl8169_private *tp = netdev_priv(ndev); + struct led_classdev *led_cdev = &ldev->led; + char led_name[LED_MAX_NAME_SIZE]; + + ldev->ndev = ndev; + ldev->index = index; + +- r8169_get_led_name(tp, index, led_name, LED_MAX_NAME_SIZE); ++ snprintf(led_name, sizeof(led_name), "%s-%d::lan", ndev->name, index); + led_cdev->name = led_name; + led_cdev->hw_control_trigger = "netdev"; + led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; +@@ -228,14 +227,13 @@ static int rtl8125_led_hw_control_get(st + static void rtl8125_setup_led_ldev(struct r8169_led_classdev *ldev, + struct net_device *ndev, int index) + { +- struct rtl8169_private *tp = netdev_priv(ndev); + struct led_classdev *led_cdev = &ldev->led; + char led_name[LED_MAX_NAME_SIZE]; + + ldev->ndev = ndev; + ldev->index = index; + +- r8169_get_led_name(tp, index, led_name, LED_MAX_NAME_SIZE); ++ snprintf(led_name, sizeof(led_name), "%s-%d::lan", ndev->name, index); + led_cdev->name = led_name; + led_cdev->hw_control_trigger = "netdev"; + led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; +--- a/drivers/net/ethernet/realtek/r8169_main.c ++++ b/drivers/net/ethernet/realtek/r8169_main.c +@@ -980,28 +980,6 @@ int rtl8125_get_led_mode(struct rtl8169_ + return ret; + } + +-void r8169_get_led_name(struct rtl8169_private *tp, int idx, +- char *buf, int buf_len) +-{ +- struct pci_dev *pdev = tp->pci_dev; +- char pdom[8], pfun[8]; +- int domain; +- +- domain = pci_domain_nr(pdev->bus); +- if (domain) +- snprintf(pdom, sizeof(pdom), "P%d", domain); +- else +- pdom[0] = '\0'; +- +- if (pdev->multifunction) +- snprintf(pfun, sizeof(pfun), "f%d", PCI_FUNC(pdev->devfn)); +- else +- pfun[0] = '\0'; +- +- snprintf(buf, buf_len, "en%sp%ds%d%s-%d::lan", pdom, pdev->bus->number, +- PCI_SLOT(pdev->devfn), pfun, idx); +-} +- + static void r8168fp_adjust_ocp_cmd(struct rtl8169_private *tp, u32 *cmd, int type) + { + /* based on RTL8168FP_OOBMAC_BASE in vendor driver */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/773-bgmac-add-srab-switch.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/773-bgmac-add-srab-switch.patch new file mode 100755 index 0000000..40634f9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/773-bgmac-add-srab-switch.patch @@ -0,0 +1,98 @@ +From 3cb240533ab787899dc7f17aa7d6c5b4810e2e58 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Fri, 7 Jul 2017 17:26:01 +0200 +Subject: bcm53xx: bgmac: use srab switch driver + +use the srab switch driver on these SoCs. + +Signed-off-by: Hauke Mehrtens +--- + drivers/net/ethernet/broadcom/bgmac-bcma.c | 1 + + drivers/net/ethernet/broadcom/bgmac.c | 24 ++++++++++++++++++++++++ + drivers/net/ethernet/broadcom/bgmac.h | 4 ++++ + 3 files changed, 29 insertions(+) + +--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c ++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c +@@ -280,6 +280,7 @@ static int bgmac_probe(struct bcma_devic + bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; + bgmac->feature_flags |= BGMAC_FEAT_NO_RESET; + bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500; ++ bgmac->feature_flags |= BGMAC_FEAT_SRAB; + break; + default: + bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; +--- a/drivers/net/ethernet/broadcom/bgmac.c ++++ b/drivers/net/ethernet/broadcom/bgmac.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1408,6 +1409,17 @@ static const struct ethtool_ops bgmac_et + .set_link_ksettings = phy_ethtool_set_link_ksettings, + }; + ++static struct b53_platform_data bgmac_b53_pdata = { ++}; ++ ++static struct platform_device bgmac_b53_dev = { ++ .name = "b53-srab-switch", ++ .id = -1, ++ .dev = { ++ .platform_data = &bgmac_b53_pdata, ++ }, ++}; ++ + /************************************************** + * MII + **************************************************/ +@@ -1546,6 +1558,14 @@ int bgmac_enet_probe(struct bgmac *bgmac + + bgmac->in_init = false; + ++ if ((bgmac->feature_flags & BGMAC_FEAT_SRAB) && !bgmac_b53_pdata.regs) { ++ bgmac_b53_pdata.regs = ioremap(0x18007000, 0x1000); ++ ++ err = platform_device_register(&bgmac_b53_dev); ++ if (!err) ++ bgmac->b53_device = &bgmac_b53_dev; ++ } ++ + err = register_netdev(bgmac->net_dev); + if (err) { + dev_err(bgmac->dev, "Cannot register net device\n"); +@@ -1568,6 +1588,10 @@ EXPORT_SYMBOL_GPL(bgmac_enet_probe); + + void bgmac_enet_remove(struct bgmac *bgmac) + { ++ if (bgmac->b53_device) ++ platform_device_unregister(&bgmac_b53_dev); ++ bgmac->b53_device = NULL; ++ + unregister_netdev(bgmac->net_dev); + phy_disconnect(bgmac->net_dev->phydev); + netif_napi_del(&bgmac->napi); +--- a/drivers/net/ethernet/broadcom/bgmac.h ++++ b/drivers/net/ethernet/broadcom/bgmac.h +@@ -387,6 +387,7 @@ + #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18) + #define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19) + #define BGMAC_FEAT_IDM_MASK BIT(20) ++#define BGMAC_FEAT_SRAB BIT(21) + + struct bgmac_slot_info { + union { +@@ -494,6 +495,9 @@ struct bgmac { + void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask, + u32 set); + int (*phy_connect)(struct bgmac *bgmac); ++ ++ /* platform device for associated switch */ ++ struct platform_device *b53_device; + }; + + struct bgmac *bgmac_alloc(struct device *dev); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/780-usb-net-MeigLink_modem_support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/780-usb-net-MeigLink_modem_support.patch new file mode 100755 index 0000000..eff038f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/780-usb-net-MeigLink_modem_support.patch @@ -0,0 +1,70 @@ +From f81700b6bb2eda3756247bce472d8eaf6f466f61 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 13:49:26 +0200 +Subject: [PATCH] net/usb/qmi_wwan: add MeigLink modem support + +--- + drivers/net/usb/qmi_wwan.c | 1 + + drivers/usb/serial/option.c | 7 +++++++ + 2 files changed, 8 insertions(+) + +--- a/drivers/net/usb/qmi_wwan.c ++++ b/drivers/net/usb/qmi_wwan.c +@@ -1082,6 +1082,11 @@ static const struct usb_device_id produc + USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7), + .driver_info = (unsigned long)&qmi_wwan_info, + }, ++ { /* Meiglink SGM828 */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d49, USB_CLASS_VENDOR_SPEC, 0x10, 0x05), ++ .driver_info = (unsigned long)&qmi_wwan_info, ++ }, ++ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0122)}, /* Quectel RG650V */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ +@@ -1089,6 +1094,7 @@ static const struct usb_device_id produc + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)}, /* Quectel EM160R-GL */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0801)}, /* Quectel RM520N */ ++ {QMI_MATCH_FF_FF_FF(0x05c6, 0xf601)}, /* MeigLink SLM750 */ + + /* 3. Combined interface devices matching on interface number */ + {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */ +--- a/drivers/usb/serial/option.c ++++ b/drivers/usb/serial/option.c +@@ -247,6 +247,11 @@ static void option_instat_callback(struc + #define UBLOX_PRODUCT_R410M 0x90b2 + /* These Yuga products use Qualcomm's vendor ID */ + #define YUGA_PRODUCT_CLM920_NC5 0x9625 ++/* These MeigLink products use Qualcomm's vendor ID */ ++#define MEIGLINK_PRODUCT_SLM750 0xf601 ++ ++#define MEIGLINK_VENDOR_ID 0x2dee ++#define MEIGLINK_PRODUCT_SLM828 0x4d49 + + #define QUECTEL_VENDOR_ID 0x2c7c + /* These Quectel products use Quectel's vendor ID */ +@@ -1156,6 +1161,11 @@ static const struct usb_device_id option + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ + { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000), /* SIMCom SIM5218 */ + .driver_info = NCTRL(0) | NCTRL(1) | NCTRL(2) | NCTRL(3) | RSVD(4) }, ++ /* MeiG */ ++ { USB_DEVICE_AND_INTERFACE_INFO(MEIGLINK_VENDOR_ID, MEIGLINK_PRODUCT_SLM828, USB_CLASS_VENDOR_SPEC, 0x10, 0x01) }, ++ { USB_DEVICE_AND_INTERFACE_INFO(MEIGLINK_VENDOR_ID, MEIGLINK_PRODUCT_SLM828, USB_CLASS_VENDOR_SPEC, 0x10, 0x02) }, ++ { USB_DEVICE_AND_INTERFACE_INFO(MEIGLINK_VENDOR_ID, MEIGLINK_PRODUCT_SLM828, USB_CLASS_VENDOR_SPEC, 0x10, 0x03) }, ++ { USB_DEVICE_AND_INTERFACE_INFO(MEIGLINK_VENDOR_ID, MEIGLINK_PRODUCT_SLM828, USB_CLASS_VENDOR_SPEC, 0x10, 0x04) }, + /* Quectel products using Qualcomm vendor ID */ + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC15)}, + { USB_DEVICE(QUALCOMM_VENDOR_ID, QUECTEL_PRODUCT_UC20), +@@ -1197,6 +1207,11 @@ static const struct usb_device_id option + .driver_info = ZLP }, + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), + .driver_info = RSVD(4) }, ++ /* Meiglink products using Qualcomm vendor ID */ ++ // Works OK. In case of some issues check macros that are used by Quectel Products ++ { USB_DEVICE_AND_INTERFACE_INFO(QUALCOMM_VENDOR_ID, MEIGLINK_PRODUCT_SLM750, 0xff, 0xff, 0xff), ++ .driver_info = NUMEP2 }, ++ { USB_DEVICE_AND_INTERFACE_INFO(QUALCOMM_VENDOR_ID, MEIGLINK_PRODUCT_SLM750, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff), + .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) }, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/781-usb-net-rndis-support-asr.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/781-usb-net-rndis-support-asr.patch new file mode 100755 index 0000000..47339b6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/781-usb-net-rndis-support-asr.patch @@ -0,0 +1,69 @@ +From 9fabf60187f1fa19e6f6bb5441587d485bd534b0 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 9 Apr 2024 17:06:38 +0100 +Subject: [PATCH] rndis_host: add a bunch of USB IDs + +Add a bunch of USB IDs found in various places online to the +RNDIS USB network driver. + +Signed-off-by: Daniel Golle +--- + drivers/net/usb/rndis_host.c | 40 ++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +--- a/drivers/net/usb/rndis_host.c ++++ b/drivers/net/usb/rndis_host.c +@@ -630,6 +630,16 @@ static const struct driver_info zte_rndi + .tx_fixup = rndis_tx_fixup, + }; + ++static const struct driver_info asr_rndis_info = { ++ .description = "Asr RNDIS device", ++ .flags = FLAG_WWAN | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT | FLAG_NOARP, ++ .bind = rndis_bind, ++ .unbind = rndis_unbind, ++ .status = rndis_status, ++ .rx_fixup = rndis_rx_fixup, ++ .tx_fixup = rndis_tx_fixup, ++}; ++ + /*-------------------------------------------------------------------------*/ + + static const struct usb_device_id products [] = { +@@ -666,6 +676,36 @@ static const struct usb_device_id produc + USB_INTERFACE_INFO(USB_CLASS_WIRELESS_CONTROLLER, 1, 3), + .driver_info = (unsigned long) &rndis_info, + }, { ++ /* Quectel EG060V rndis device */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x6004, ++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3), ++ .driver_info = (unsigned long) &asr_rndis_info, ++}, { ++ /* Quectel EC200A rndis device */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x6005, ++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3), ++ .driver_info = (unsigned long) &asr_rndis_info, ++}, { ++ /* Quectel EC200T rndis device */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x6026, ++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3), ++ .driver_info = (unsigned long) &asr_rndis_info, ++}, { ++ /* Simcom A7906E rndis device */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x1e0e, 0x9011, ++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3), ++ .driver_info = (unsigned long) &asr_rndis_info, ++}, { ++ /* Meig SLM770A */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d57, ++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3), ++ .driver_info = (unsigned long) &asr_rndis_info, ++}, { ++ /* Meig SLM828 */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d49, ++ USB_CLASS_WIRELESS_CONTROLLER, 1, 3), ++ .driver_info = (unsigned long) &asr_rndis_info, ++}, { + /* Novatel Verizon USB730L */ + USB_INTERFACE_INFO(USB_CLASS_MISC, 4, 1), + .driver_info = (unsigned long) &rndis_info, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/800-GPIO-add-named-gpio-exports.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/800-GPIO-add-named-gpio-exports.patch new file mode 100755 index 0000000..f9b540f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/800-GPIO-add-named-gpio-exports.patch @@ -0,0 +1,172 @@ +From cc809a441d8f2924f785eb863dfa6aef47a25b0b Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Tue, 12 Aug 2014 20:49:27 +0200 +Subject: [PATCH 30/36] GPIO: add named gpio exports + +Signed-off-by: John Crispin +--- a/drivers/gpio/gpiolib-of.c ++++ b/drivers/gpio/gpiolib-of.c +@@ -21,6 +21,8 @@ + + #include + #include ++#include ++#include + + #include "gpiolib.h" + #include "gpiolib-of.h" +@@ -1198,3 +1200,73 @@ void of_gpiochip_remove(struct gpio_chip + { + of_node_put(dev_of_node(&chip->gpiodev->dev)); + } ++ ++#ifdef CONFIG_GPIO_SYSFS ++ ++static const struct of_device_id gpio_export_ids[] = { ++ { .compatible = "gpio-export" }, ++ { /* sentinel */ } ++}; ++ ++static int of_gpio_export_probe(struct platform_device *pdev) ++{ ++ struct device_node *np = pdev->dev.of_node; ++ struct device_node *cnp; ++ u32 val; ++ int nb = 0; ++ ++ for_each_child_of_node(np, cnp) { ++ const char *name = NULL; ++ int gpio; ++ bool dmc; ++ int max_gpio = 1; ++ int i; ++ ++ of_property_read_string(cnp, "gpio-export,name", &name); ++ ++ if (!name) ++ max_gpio = of_gpio_named_count(cnp, "gpios"); ++ ++ for (i = 0; i < max_gpio; i++) { ++ struct gpio_desc *desc; ++ unsigned flags = 0; ++ enum of_gpio_flags of_flags; ++ ++ desc = of_get_named_gpiod_flags(cnp, "gpios", i, &of_flags); ++ if (IS_ERR(desc)) ++ return PTR_ERR(desc); ++ gpio = desc_to_gpio(desc); ++ ++ if (of_flags & OF_GPIO_ACTIVE_LOW) ++ flags |= GPIOF_ACTIVE_LOW; ++ ++ if (!of_property_read_u32(cnp, "gpio-export,output", &val)) ++ flags |= val ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; ++ else ++ flags |= GPIOF_IN; ++ ++ if (devm_gpio_request_one(&pdev->dev, gpio, flags, name ? name : of_node_full_name(np))) ++ continue; ++ ++ dmc = of_property_read_bool(cnp, "gpio-export,direction_may_change"); ++ gpio_export_with_name(gpio_to_desc(gpio), dmc, name); ++ nb++; ++ } ++ } ++ ++ dev_info(&pdev->dev, "%d gpio(s) exported\n", nb); ++ ++ return 0; ++} ++ ++static struct platform_driver gpio_export_driver = { ++ .driver = { ++ .name = "gpio-export", ++ .of_match_table = of_match_ptr(gpio_export_ids), ++ }, ++ .probe = of_gpio_export_probe, ++}; ++ ++module_platform_driver(gpio_export_driver); ++ ++#endif +--- a/include/linux/gpio/consumer.h ++++ b/include/linux/gpio/consumer.h +@@ -628,7 +628,10 @@ static inline int devm_acpi_dev_add_driv + + #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) + ++int __gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name); + int gpiod_export(struct gpio_desc *desc, bool direction_may_change); ++int gpio_export_with_name(struct gpio_desc *desc, bool direction_may_change, ++ const char *name); + int gpiod_export_link(struct device *dev, const char *name, + struct gpio_desc *desc); + void gpiod_unexport(struct gpio_desc *desc); +@@ -637,11 +640,25 @@ void gpiod_unexport(struct gpio_desc *de + + #include + ++static inline int __gpiod_export(struct gpio_desc *desc, ++ bool direction_may_change, ++ const char *name) ++{ ++ return -ENOSYS; ++} ++ + static inline int gpiod_export(struct gpio_desc *desc, + bool direction_may_change) + { + return -ENOSYS; + } ++ ++static inline int gpio_export_with_name(struct gpio_desc *desc, ++ bool direction_may_change, ++ const char *name) ++{ ++ return -ENOSYS; ++} + + static inline int gpiod_export_link(struct device *dev, const char *name, + struct gpio_desc *desc) +--- a/drivers/gpio/gpiolib-sysfs.c ++++ b/drivers/gpio/gpiolib-sysfs.c +@@ -571,7 +571,7 @@ static struct class gpio_class = { + * Returns: + * 0 on success, or negative errno on failure. + */ +-int gpiod_export(struct gpio_desc *desc, bool direction_may_change) ++int __gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name) + { + const char *ioname = NULL; + struct gpio_device *gdev; +@@ -629,6 +629,8 @@ int gpiod_export(struct gpio_desc *desc, + offset = gpio_chip_hwgpio(desc); + if (guard.gc->names && guard.gc->names[offset]) + ioname = guard.gc->names[offset]; ++ if (name) ++ ioname = name; + + dev = device_create_with_groups(&gpio_class, &gdev->dev, + MKDEV(0, 0), data, gpio_groups, +@@ -650,8 +652,21 @@ err_unlock: + gpiod_dbg(desc, "%s: status %d\n", __func__, status); + return status; + } ++EXPORT_SYMBOL_GPL(__gpiod_export); ++ ++int gpiod_export(struct gpio_desc *desc, bool direction_may_change) ++{ ++ return __gpiod_export(desc, direction_may_change, NULL); ++} + EXPORT_SYMBOL_GPL(gpiod_export); + ++int gpio_export_with_name(struct gpio_desc *desc, bool direction_may_change, ++ const char *name) ++{ ++ return __gpiod_export(desc, direction_may_change, name); ++} ++EXPORT_SYMBOL_GPL(gpio_export_with_name); ++ + static int match_export(struct device *dev, const void *desc) + { + struct gpiod_data *data = dev_get_drvdata(dev); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/810-bcma-ssb-fallback-sprom.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/810-bcma-ssb-fallback-sprom.patch new file mode 100755 index 0000000..392c873 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/810-bcma-ssb-fallback-sprom.patch @@ -0,0 +1,182 @@ +From e4d708702e6c98f2111e33201a264d6788564cb2 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Fri, 12 May 2023 11:08:43 +0200 +Subject: [PATCH] ssb_sprom: add generic kernel support for Broadcom Fallback SPROMs + +--- + drivers/bcma/Kconfig | 4 ++++ + drivers/bcma/Makefile | 1 + + drivers/bcma/bcma_private.h | 1 + + drivers/bcma/main.c | 8 ++++++++ + drivers/bcma/sprom.c | 23 ++++++++++++++--------- + drivers/ssb/Kconfig | 5 +++++ + drivers/ssb/Makefile | 1 + + drivers/ssb/main.c | 8 ++++++++ + drivers/ssb/sprom.c | 12 +++++++++++- + drivers/ssb/ssb_private.h | 2 +- + 10 files changed, 54 insertions(+), 11 deletions(-) + +--- a/drivers/bcma/Kconfig ++++ b/drivers/bcma/Kconfig +@@ -18,6 +18,10 @@ config BCMA_BLOCKIO + bool + default y + ++config BCMA_FALLBACK_SPROM ++ bool ++ default y ++ + config BCMA_HOST_PCI_POSSIBLE + bool + depends on PCI = y +--- a/drivers/bcma/Makefile ++++ b/drivers/bcma/Makefile +@@ -11,6 +11,7 @@ bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) + bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o + bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o + bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o ++bcma-$(CONFIG_BCMA_FALLBACK_SPROM) += fallback-sprom.o + bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o + bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o + obj-$(CONFIG_BCMA) += bcma.o +--- a/drivers/bcma/bcma_private.h ++++ b/drivers/bcma/bcma_private.h +@@ -8,6 +8,7 @@ + + #include + #include ++#include "fallback-sprom.h" + + #define bcma_err(bus, fmt, ...) \ + dev_err((bus)->dev, "bus%d: " fmt, (bus)->num, ##__VA_ARGS__) +--- a/drivers/bcma/main.c ++++ b/drivers/bcma/main.c +@@ -677,6 +677,14 @@ static int __init bcma_modinit(void) + { + int err; + ++#ifdef CONFIG_BCMA_FALLBACK_SPROM ++ err = bcma_fbs_register(); ++ if (err) { ++ pr_err("Fallback SPROM initialization failed\n"); ++ err = 0; ++ } ++#endif /* CONFIG_BCMA_FALLBACK_SPROM */ ++ + err = bcma_init_bus_register(); + if (err) + return err; +--- a/drivers/bcma/sprom.c ++++ b/drivers/bcma/sprom.c +@@ -51,21 +51,26 @@ static int bcma_fill_sprom_with_fallback + { + int err; + +- if (!get_fallback_sprom) { ++ if (get_fallback_sprom) ++ err = get_fallback_sprom(bus, out); ++ ++#ifdef CONFIG_BCMA_FALLBACK_SPROM ++ if (!get_fallback_sprom || err) ++ err = bcma_get_fallback_sprom(bus, out); ++#else ++ if (!get_fallback_sprom) + err = -ENOENT; +- goto fail; +- } ++#endif /* CONFIG_BCMA_FALLBACK_SPROM */ + +- err = get_fallback_sprom(bus, out); +- if (err) +- goto fail; ++ if (err) { ++ bcma_warn(bus, "Using fallback SPROM failed (err %d)\n", err); ++ return err; ++ } + + bcma_debug(bus, "Using SPROM revision %d provided by platform.\n", + bus->sprom.revision); ++ + return 0; +-fail: +- bcma_warn(bus, "Using fallback SPROM failed (err %d)\n", err); +- return err; + } + + /************************************************** +--- a/drivers/ssb/Kconfig ++++ b/drivers/ssb/Kconfig +@@ -25,6 +25,11 @@ if SSB + config SSB_SPROM + bool + ++config SSB_FALLBACK_SPROM ++ bool ++ depends on SSB_PCIHOST ++ default y ++ + # Support for Block-I/O. SELECT this from the driver that needs it. + config SSB_BLOCKIO + bool +--- a/drivers/ssb/Makefile ++++ b/drivers/ssb/Makefile +@@ -2,6 +2,7 @@ + # core + ssb-y += main.o scan.o + ssb-$(CONFIG_SSB_EMBEDDED) += embedded.o ++ssb-$(CONFIG_SSB_FALLBACK_SPROM) += fallback-sprom.o + ssb-$(CONFIG_SSB_SPROM) += sprom.o + + # host support +--- a/drivers/ssb/main.c ++++ b/drivers/ssb/main.c +@@ -1289,6 +1289,14 @@ static int __init ssb_modinit(void) + { + int err; + ++#ifdef CONFIG_SSB_FALLBACK_SPROM ++ err = ssb_fbs_register(); ++ if (err) { ++ pr_err("Fallback SPROM initialization failed\n"); ++ err = 0; ++ } ++#endif /* CONFIG_SSB_FALLBACK_SPROM */ ++ + /* See the comment at the ssb_is_early_boot definition */ + ssb_is_early_boot = 0; + err = bus_register(&ssb_bustype); +--- a/drivers/ssb/sprom.c ++++ b/drivers/ssb/sprom.c +@@ -180,10 +180,20 @@ int ssb_arch_register_fallback_sprom(int + + int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out) + { ++ int err; ++ ++ if (get_fallback_sprom) ++ err = get_fallback_sprom(bus, out); ++ ++#ifdef CONFIG_SSB_FALLBACK_SPROM ++ if (!get_fallback_sprom || err) ++ err = ssb_get_fallback_sprom(bus, out); ++#else + if (!get_fallback_sprom) + return -ENOENT; ++#endif /* CONFIG_SSB_FALLBACK_SPROM */ + +- return get_fallback_sprom(bus, out); ++ return err; + } + + /* https://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */ +--- a/drivers/ssb/ssb_private.h ++++ b/drivers/ssb/ssb_private.h +@@ -8,7 +8,7 @@ + #include + #include + #include +- ++#include "fallback-sprom.h" + + /* pci.c */ + #ifdef CONFIG_SSB_PCIHOST diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/901-debloat_sock_diag.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/901-debloat_sock_diag.patch new file mode 100755 index 0000000..17a22d0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/901-debloat_sock_diag.patch @@ -0,0 +1,181 @@ +From 3b6115d6b57a263bdc8c9b1df273bd4a7955eead Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sat, 8 Jul 2017 08:16:31 +0200 +Subject: debloat: add some debloat patches, strip down procfs and make O_DIRECT support optional, saves ~15K after lzma on MIPS + +Signed-off-by: Felix Fietkau +--- + net/Kconfig | 3 +++ + net/core/Makefile | 3 ++- + net/core/sock.c | 2 ++ + net/ipv4/Kconfig | 1 + + net/netlink/Kconfig | 1 + + net/packet/Kconfig | 1 + + net/unix/Kconfig | 1 + + 7 files changed, 11 insertions(+), 1 deletion(-) + +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -138,6 +138,9 @@ source "net/mptcp/Kconfig" + + endif # if INET + ++config SOCK_DIAG ++ bool ++ + config NETWORK_SECMARK + bool "Security Marking" + help +--- a/net/core/Makefile ++++ b/net/core/Makefile +@@ -11,12 +11,13 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core. + + obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ + neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ +- sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \ ++ dev_ioctl.o tso.o sock_reuseport.o \ + fib_notifier.o xdp.o flow_offload.o gro.o \ + netdev-genl.o netdev-genl-gen.o gso.o + + obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o + ++obj-$(CONFIG_SOCK_DIAG) += sock_diag.o + obj-y += net-sysfs.o + obj-y += hotdata.o + obj-y += netdev_rx_queue.o +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -118,6 +118,7 @@ + #include + #include + #include ++#include + + #include + +@@ -152,6 +153,7 @@ + + static DEFINE_MUTEX(proto_list_mutex); + static LIST_HEAD(proto_list); ++DEFINE_COOKIE(sock_cookie); + + static void sock_def_write_space_wfree(struct sock *sk); + static void sock_def_write_space(struct sock *sk); +@@ -587,6 +589,21 @@ discard_and_relse: + } + EXPORT_SYMBOL(__sk_receive_skb); + ++u64 __sock_gen_cookie(struct sock *sk) ++{ ++ u64 res = atomic64_read(&sk->sk_cookie); ++ ++ if (!res) { ++ u64 new = gen_cookie_next(&sock_cookie); ++ ++ atomic64_cmpxchg(&sk->sk_cookie, res, new); ++ ++ /* Another thread might have changed sk_cookie before us. */ ++ res = atomic64_read(&sk->sk_cookie); ++ } ++ return res; ++} ++ + INDIRECT_CALLABLE_DECLARE(struct dst_entry *ip6_dst_check(struct dst_entry *, + u32)); + INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, +@@ -2342,9 +2359,11 @@ static void __sk_free(struct sock *sk) + if (likely(sk->sk_net_refcnt)) + sock_inuse_add(sock_net(sk), -1); + ++#ifdef CONFIG_SOCK_DIAG + if (unlikely(sk->sk_net_refcnt && sock_diag_has_destroy_listeners(sk))) + sock_diag_broadcast_destroy(sk); + else ++#endif + sk_destruct(sk); + } + +--- a/net/core/sock_diag.c ++++ b/net/core/sock_diag.c +@@ -12,7 +12,6 @@ + #include + #include + #include +-#include + #include + #include + +@@ -22,23 +21,6 @@ static const struct sock_diag_inet_compa + + static struct workqueue_struct *broadcast_wq; + +-DEFINE_COOKIE(sock_cookie); +- +-u64 __sock_gen_cookie(struct sock *sk) +-{ +- u64 res = atomic64_read(&sk->sk_cookie); +- +- if (!res) { +- u64 new = gen_cookie_next(&sock_cookie); +- +- atomic64_cmpxchg(&sk->sk_cookie, res, new); +- +- /* Another thread might have changed sk_cookie before us. */ +- res = atomic64_read(&sk->sk_cookie); +- } +- return res; +-} +- + int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie) + { + u64 res; +--- a/net/ipv4/Kconfig ++++ b/net/ipv4/Kconfig +@@ -423,6 +423,7 @@ config INET_TUNNEL + + config INET_DIAG + tristate "INET: socket monitoring interface" ++ select SOCK_DIAG + default y + help + Support for INET (TCP, DCCP, etc) socket monitoring interface used by +--- a/net/netlink/Kconfig ++++ b/net/netlink/Kconfig +@@ -5,6 +5,7 @@ + + config NETLINK_DIAG + tristate "NETLINK: socket monitoring interface" ++ select SOCK_DIAG + default n + help + Support for NETLINK socket monitoring interface used by the ss tool. +--- a/net/packet/Kconfig ++++ b/net/packet/Kconfig +@@ -19,6 +19,7 @@ config PACKET + config PACKET_DIAG + tristate "Packet: sockets monitoring interface" + depends on PACKET ++ select SOCK_DIAG + default n + help + Support for PF_PACKET sockets monitoring interface used by the ss tool. +--- a/net/unix/Kconfig ++++ b/net/unix/Kconfig +@@ -24,6 +24,7 @@ config AF_UNIX_OOB + config UNIX_DIAG + tristate "UNIX: socket monitoring interface" + depends on UNIX ++ select SOCK_DIAG + default n + help + Support for UNIX socket monitoring interface used by the ss tool. +--- a/net/xdp/Kconfig ++++ b/net/xdp/Kconfig +@@ -10,6 +10,7 @@ config XDP_SOCKETS + config XDP_SOCKETS_DIAG + tristate "XDP sockets: monitoring interface" + depends on XDP_SOCKETS ++ select SOCK_DIAG + default n + help + Support for PF_XDP sockets monitoring interface used by the ss tool. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/902-debloat_proc.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/902-debloat_proc.patch new file mode 100755 index 0000000..465a0ae --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/902-debloat_proc.patch @@ -0,0 +1,420 @@ +From 9e3f1d0805b2d919904dd9a4ff0d956314cc3cba Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sat, 8 Jul 2017 08:20:09 +0200 +Subject: debloat: procfs + +Signed-off-by: Felix Fietkau +--- + fs/locks.c | 2 ++ + fs/proc/Kconfig | 5 +++++ + fs/proc/consoles.c | 3 +++ + fs/proc/proc_tty.c | 11 ++++++++++- + include/net/snmp.h | 18 +++++++++++++++++- + ipc/msg.c | 3 +++ + ipc/sem.c | 2 ++ + ipc/shm.c | 2 ++ + ipc/util.c | 3 +++ + kernel/exec_domain.c | 2 ++ + kernel/irq/proc.c | 9 +++++++++ + kernel/time/timer_list.c | 2 ++ + mm/vmalloc.c | 2 ++ + mm/vmstat.c | 8 +++++--- + net/8021q/vlanproc.c | 6 ++++++ + net/core/net-procfs.c | 18 ++++++++++++------ + net/core/sock.c | 2 ++ + net/ipv4/fib_trie.c | 18 ++++++++++++------ + net/ipv4/proc.c | 3 +++ + net/ipv4/route.c | 3 +++ + 20 files changed, 105 insertions(+), 17 deletions(-) + +--- a/fs/locks.c ++++ b/fs/locks.c +@@ -2979,6 +2979,8 @@ static const struct seq_operations locks + + static int __init proc_locks_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create_seq_private("locks", 0, NULL, &locks_seq_operations, + sizeof(struct locks_iterator), NULL); + return 0; +--- a/fs/proc/Kconfig ++++ b/fs/proc/Kconfig +@@ -101,6 +101,11 @@ config PROC_CHILDREN + Say Y if you are running any user-space software which takes benefit from + this interface. For example, rkt is such a piece of software. + ++config PROC_STRIPPED ++ default n ++ depends on EXPERT ++ bool "Strip non-essential /proc functionality to reduce code size" ++ + config PROC_PID_ARCH_STATUS + def_bool n + depends on PROC_FS +--- a/fs/proc/consoles.c ++++ b/fs/proc/consoles.c +@@ -110,6 +110,9 @@ static const struct seq_operations conso + + static int __init proc_consoles_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + proc_create_seq("consoles", 0, NULL, &consoles_op); + return 0; + } +--- a/fs/proc/proc_tty.c ++++ b/fs/proc/proc_tty.c +@@ -131,7 +131,10 @@ static const struct seq_operations tty_d + void proc_tty_register_driver(struct tty_driver *driver) + { + struct proc_dir_entry *ent; +- ++ ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!driver->driver_name || driver->proc_entry || + !driver->ops->proc_show) + return; +@@ -148,6 +151,9 @@ void proc_tty_unregister_driver(struct t + { + struct proc_dir_entry *ent; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + ent = driver->proc_entry; + if (!ent) + return; +@@ -162,6 +168,9 @@ void proc_tty_unregister_driver(struct t + */ + void __init proc_tty_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (!proc_mkdir("tty", NULL)) + return; + proc_mkdir("tty/ldisc", NULL); /* Preserved: it's userspace visible */ +--- a/include/net/snmp.h ++++ b/include/net/snmp.h +@@ -124,6 +124,21 @@ struct linux_tls_mib { + #define DECLARE_SNMP_STAT(type, name) \ + extern __typeof__(type) __percpu *name + ++#ifdef CONFIG_PROC_STRIPPED ++#define __SNMP_STATS_DUMMY(mib) \ ++ do { (void) mib->mibs[0]; } while(0) ++ ++#define __SNMP_INC_STATS(mib, field) __SNMP_STATS_DUMMY(mib) ++#define SNMP_INC_STATS_ATOMIC_LONG(mib, field) __SNMP_STATS_DUMMY(mib) ++#define SNMP_INC_STATS(mib, field) __SNMP_STATS_DUMMY(mib) ++#define SNMP_DEC_STATS(mib, field) __SNMP_STATS_DUMMY(mib) ++#define __SNMP_ADD_STATS(mib, field, addend) __SNMP_STATS_DUMMY(mib) ++#define SNMP_ADD_STATS(mib, field, addend) __SNMP_STATS_DUMMY(mib) ++#define SNMP_UPD_PO_STATS(mib, basefield, addend) __SNMP_STATS_DUMMY(mib) ++#define __SNMP_UPD_PO_STATS(mib, basefield, addend) __SNMP_STATS_DUMMY(mib) ++ ++#else ++ + #define __SNMP_INC_STATS(mib, field) \ + __this_cpu_inc(mib->mibs[field]) + +@@ -154,8 +169,9 @@ struct linux_tls_mib { + __this_cpu_add(ptr[basefield##OCTETS], addend); \ + } while (0) + ++#endif + +-#if BITS_PER_LONG==32 ++#if (BITS_PER_LONG==32) && !defined(CONFIG_PROC_STRIPPED) + + #define __SNMP_ADD_STATS64(mib, field, addend) \ + do { \ +--- a/ipc/msg.c ++++ b/ipc/msg.c +@@ -1370,6 +1370,9 @@ void __init msg_init(void) + { + msg_init_ns(&init_ipc_ns); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + ipc_init_proc_interface("sysvipc/msg", + " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", + IPC_MSG_IDS, sysvipc_msg_proc_show); +--- a/ipc/sem.c ++++ b/ipc/sem.c +@@ -268,6 +268,8 @@ void sem_exit_ns(struct ipc_namespace *n + void __init sem_init(void) + { + sem_init_ns(&init_ipc_ns); ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; + ipc_init_proc_interface("sysvipc/sem", + " key semid perms nsems uid gid cuid cgid otime ctime\n", + IPC_SEM_IDS, sysvipc_sem_proc_show); +--- a/ipc/shm.c ++++ b/ipc/shm.c +@@ -155,6 +155,8 @@ pure_initcall(ipc_ns_init); + + void __init shm_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; + ipc_init_proc_interface("sysvipc/shm", + #if BITS_PER_LONG <= 32 + " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime rss swap\n", +--- a/ipc/util.c ++++ b/ipc/util.c +@@ -141,6 +141,9 @@ void __init ipc_init_proc_interface(cons + struct proc_dir_entry *pde; + struct ipc_proc_iface *iface; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + iface = kmalloc(sizeof(*iface), GFP_KERNEL); + if (!iface) + return; +--- a/kernel/exec_domain.c ++++ b/kernel/exec_domain.c +@@ -29,6 +29,8 @@ static int execdomains_proc_show(struct + + static int __init proc_execdomains_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + proc_create_single("execdomains", 0, NULL, execdomains_proc_show); + return 0; + } +--- a/kernel/irq/proc.c ++++ b/kernel/irq/proc.c +@@ -339,6 +339,9 @@ void register_irq_proc(unsigned int irq, + void __maybe_unused *irqp = (void *)(unsigned long) irq; + char name [MAX_NAMELEN]; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP)) ++ return; ++ + if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip)) + return; + +@@ -397,6 +400,9 @@ void unregister_irq_proc(unsigned int ir + { + char name [MAX_NAMELEN]; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP)) ++ return; ++ + if (!root_irq_dir || !desc->dir) + return; + #ifdef CONFIG_SMP +@@ -435,6 +441,9 @@ void init_irq_proc(void) + unsigned int irq; + struct irq_desc *desc; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED) && !IS_ENABLED(CONFIG_SMP)) ++ return; ++ + /* create /proc/irq */ + root_irq_dir = proc_mkdir("irq", NULL); + if (!root_irq_dir) +--- a/kernel/time/timer_list.c ++++ b/kernel/time/timer_list.c +@@ -354,6 +354,8 @@ static int __init init_timer_list_procfs + { + struct proc_dir_entry *pe; + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + pe = proc_create_seq_private("timer_list", 0400, NULL, &timer_list_sops, + sizeof(struct timer_list_iter), NULL); + if (!pe) +--- a/mm/vmalloc.c ++++ b/mm/vmalloc.c +@@ -5071,6 +5071,9 @@ static int vmalloc_info_show(struct seq_ + + static int __init proc_vmalloc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + proc_create_single("vmallocinfo", 0400, NULL, vmalloc_info_show); + return 0; + } +--- a/mm/vmstat.c ++++ b/mm/vmstat.c +@@ -2197,10 +2197,12 @@ void __init init_mm_internals(void) + start_shepherd_timer(); + #endif + #ifdef CONFIG_PROC_FS +- proc_create_seq("buddyinfo", 0444, NULL, &fragmentation_op); +- proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ proc_create_seq("buddyinfo", 0444, NULL, &fragmentation_op); ++ proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); ++ proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); ++ } + proc_create_seq("vmstat", 0444, NULL, &vmstat_op); +- proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); + #endif + } + +--- a/net/8021q/vlanproc.c ++++ b/net/8021q/vlanproc.c +@@ -93,6 +93,9 @@ void vlan_proc_cleanup(struct net *net) + { + struct vlan_net *vn = net_generic(net, vlan_net_id); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return; ++ + if (vn->proc_vlan_conf) + remove_proc_entry(name_conf, vn->proc_vlan_dir); + +@@ -112,6 +115,9 @@ int __net_init vlan_proc_init(struct net + { + struct vlan_net *vn = net_generic(net, vlan_net_id); + ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + vn->proc_vlan_dir = proc_net_mkdir(net, name_root, net->proc_net); + if (!vn->proc_vlan_dir) + goto err; +--- a/net/core/net-procfs.c ++++ b/net/core/net-procfs.c +@@ -295,10 +295,12 @@ static int __net_init dev_proc_net_init( + if (!proc_create_net("dev", 0444, net->proc_net, &dev_seq_ops, + sizeof(struct seq_net_private))) + goto out; +- if (!proc_create_seq("softnet_stat", 0444, net->proc_net, ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_create_seq("softnet_stat", 0444, net->proc_net, + &softnet_seq_ops)) + goto out_dev; +- if (!proc_create_net("ptype", 0444, net->proc_net, &ptype_seq_ops, ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_create_net("ptype", 0444, net->proc_net, &ptype_seq_ops, + sizeof(struct seq_net_private))) + goto out_softnet; + +@@ -308,9 +310,11 @@ static int __net_init dev_proc_net_init( + out: + return rc; + out_ptype: +- remove_proc_entry("ptype", net->proc_net); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ remove_proc_entry("ptype", net->proc_net); + out_softnet: +- remove_proc_entry("softnet_stat", net->proc_net); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ remove_proc_entry("softnet_stat", net->proc_net); + out_dev: + remove_proc_entry("dev", net->proc_net); + goto out; +@@ -320,8 +324,10 @@ static void __net_exit dev_proc_net_exit + { + wext_proc_exit(net); + +- remove_proc_entry("ptype", net->proc_net); +- remove_proc_entry("softnet_stat", net->proc_net); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ remove_proc_entry("ptype", net->proc_net); ++ remove_proc_entry("softnet_stat", net->proc_net); ++ } + remove_proc_entry("dev", net->proc_net); + } + +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -4285,6 +4285,8 @@ static __net_initdata struct pernet_oper + + static int __init proto_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; + return register_pernet_subsys(&proto_net_ops); + } + +--- a/net/ipv4/fib_trie.c ++++ b/net/ipv4/fib_trie.c +@@ -3016,11 +3016,13 @@ static const struct seq_operations fib_r + + int __net_init fib_proc_init(struct net *net) + { +- if (!proc_create_net("fib_trie", 0444, net->proc_net, &fib_trie_seq_ops, ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_create_net("fib_trie", 0444, net->proc_net, &fib_trie_seq_ops, + sizeof(struct fib_trie_iter))) + goto out1; + +- if (!proc_create_net_single("fib_triestat", 0444, net->proc_net, ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED) && ++ !proc_create_net_single("fib_triestat", 0444, net->proc_net, + fib_triestat_seq_show, NULL)) + goto out2; + +@@ -3031,17 +3033,21 @@ int __net_init fib_proc_init(struct net + return 0; + + out3: +- remove_proc_entry("fib_triestat", net->proc_net); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ remove_proc_entry("fib_triestat", net->proc_net); + out2: +- remove_proc_entry("fib_trie", net->proc_net); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ remove_proc_entry("fib_trie", net->proc_net); + out1: + return -ENOMEM; + } + + void __net_exit fib_proc_exit(struct net *net) + { +- remove_proc_entry("fib_trie", net->proc_net); +- remove_proc_entry("fib_triestat", net->proc_net); ++ if (!IS_ENABLED(CONFIG_PROC_STRIPPED)) { ++ remove_proc_entry("fib_trie", net->proc_net); ++ remove_proc_entry("fib_triestat", net->proc_net); ++ } + remove_proc_entry("route", net->proc_net); + } + +--- a/net/ipv4/proc.c ++++ b/net/ipv4/proc.c +@@ -563,5 +563,8 @@ static __net_initdata struct pernet_oper + + int __init ip_misc_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + return register_pernet_subsys(&ip_proc_ops); + } +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -382,6 +382,9 @@ static struct pernet_operations ip_rt_pr + + static int __init ip_rt_proc_init(void) + { ++ if (IS_ENABLED(CONFIG_PROC_STRIPPED)) ++ return 0; ++ + return register_pernet_subsys(&ip_rt_proc_ops); + } + +--- a/net/ipv4/inet_timewait_sock.c ++++ b/net/ipv4/inet_timewait_sock.c +@@ -285,7 +285,7 @@ void __inet_twsk_schedule(struct inet_ti + */ + + if (!rearm) { +- bool kill = timeo <= 4*HZ; ++ bool __maybe_unused kill = timeo <= 4*HZ; + + __NET_INC_STATS(twsk_net(tw), kill ? LINUX_MIB_TIMEWAITKILLED : + LINUX_MIB_TIMEWAITED); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/904-debloat_dma_buf.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/904-debloat_dma_buf.patch new file mode 100755 index 0000000..af566ec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/904-debloat_dma_buf.patch @@ -0,0 +1,105 @@ +From e3692cb2fcd5ba1244512a0f43b8118f65f1c375 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sat, 8 Jul 2017 08:20:43 +0200 +Subject: debloat: dmabuf + +Signed-off-by: Felix Fietkau +--- + drivers/base/Kconfig | 2 +- + drivers/dma-buf/Makefile | 10 +++++++--- + drivers/dma-buf/dma-buf.c | 4 +++- + kernel/sched/core.c | 1 + + net/Kconfig | 2 +- + 5 files changed, 13 insertions(+), 6 deletions(-) + +--- a/drivers/base/Kconfig ++++ b/drivers/base/Kconfig +@@ -198,7 +198,7 @@ config SOC_BUS + source "drivers/base/regmap/Kconfig" + + config DMA_SHARED_BUFFER +- bool ++ tristate + default n + select IRQ_WORK + help +--- a/drivers/dma-buf/heaps/Makefile ++++ b/drivers/dma-buf/heaps/Makefile +@@ -1,3 +1,3 @@ + # SPDX-License-Identifier: GPL-2.0 +-obj-$(CONFIG_DMABUF_HEAPS_SYSTEM) += system_heap.o +-obj-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o ++dma-buf-objs-$(CONFIG_DMABUF_HEAPS_SYSTEM) += system_heap.o ++dma-buf-objs-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o +--- a/drivers/dma-buf/Makefile ++++ b/drivers/dma-buf/Makefile +@@ -1,12 +1,14 @@ + # SPDX-License-Identifier: GPL-2.0-only +-obj-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \ ++obj-$(CONFIG_DMA_SHARED_BUFFER) := dma-shared-buffer.o ++ ++dma-buf-objs-y := dma-buf.o dma-fence.o dma-fence-array.o dma-fence-chain.o \ + dma-fence-unwrap.o dma-resv.o +-obj-$(CONFIG_DMABUF_HEAPS) += dma-heap.o +-obj-$(CONFIG_DMABUF_HEAPS) += heaps/ +-obj-$(CONFIG_SYNC_FILE) += sync_file.o +-obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o +-obj-$(CONFIG_UDMABUF) += udmabuf.o +-obj-$(CONFIG_DMABUF_SYSFS_STATS) += dma-buf-sysfs-stats.o ++dma-buf-objs-$(CONFIG_DMABUF_HEAPS) += dma-heap.o ++obj-$(CONFIG_DMABUF_HEAPS) += heaps/ ++dma-buf-objs-$(CONFIG_SYNC_FILE) += sync_file.o ++dma-buf-objs-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o ++dma-buf-objs-$(CONFIG_UDMABUF) += udmabuf.o ++dma-buf-objs-$(CONFIG_DMABUF_SYSFS_STATS) += dma-buf-sysfs-stats.o + + dmabuf_selftests-y := \ + selftest.o \ +@@ -15,4 +17,6 @@ dmabuf_selftests-y := \ + st-dma-fence-unwrap.o \ + st-dma-resv.o + +-obj-$(CONFIG_DMABUF_SELFTESTS) += dmabuf_selftests.o ++dma-buf-objs-$(CONFIG_DMABUF_SELFTESTS) += dmabuf_selftests.o ++ ++dma-shared-buffer-objs := $(dma-buf-objs-y) +--- a/drivers/dma-buf/dma-buf.c ++++ b/drivers/dma-buf/dma-buf.c +@@ -1743,4 +1743,5 @@ static void __exit dma_buf_deinit(void) + kern_unmount(dma_buf_mnt); + dma_buf_uninit_sysfs_statistics(); + } +-__exitcall(dma_buf_deinit); ++module_exit(dma_buf_deinit); ++MODULE_LICENSE("GPL"); +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -4434,6 +4434,7 @@ int wake_up_state(struct task_struct *p, + { + return try_to_wake_up(p, state, 0); + } ++EXPORT_SYMBOL_GPL(wake_up_state); + + /* + * Perform scheduler related setup for a newly forked process p. +--- a/fs/d_path.c ++++ b/fs/d_path.c +@@ -314,6 +314,7 @@ char *dynamic_dname(char *buffer, int bu + buffer += buflen - sz; + return memcpy(buffer, temp, sz); + } ++EXPORT_SYMBOL_GPL(dynamic_dname); + + char *simple_dname(struct dentry *dentry, char *buffer, int buflen) + { +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -74,7 +74,7 @@ config SKB_EXTENSIONS + + config NET_DEVMEM + def_bool y +- depends on DMA_SHARED_BUFFER ++ depends on DMA_SHARED_BUFFER=y + depends on GENERIC_ALLOCATOR + depends on PAGE_POOL + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/910-kobject_uevent.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/910-kobject_uevent.patch new file mode 100755 index 0000000..99dd5a7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/910-kobject_uevent.patch @@ -0,0 +1,35 @@ +From 0d37e6edc09c99e683dd91ca0e83bbc0df8477b3 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sun, 16 Jul 2017 16:56:10 +0200 +Subject: lib: add uevent_next_seqnum() + +Signed-off-by: Felix Fietkau +--- + include/linux/kobject.h | 2 ++ + lib/kobject_uevent.c | 6 ++++++ + 2 files changed, 8 insertions(+) + +--- a/include/linux/kobject.h ++++ b/include/linux/kobject.h +@@ -219,4 +219,6 @@ int kobject_synth_uevent(struct kobject + __printf(2, 3) + int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...); + ++u64 uevent_next_seqnum(void); ++ + #endif /* _KOBJECT_H_ */ +--- a/lib/kobject_uevent.c ++++ b/lib/kobject_uevent.c +@@ -178,6 +178,12 @@ out: + return r; + } + ++u64 uevent_next_seqnum(void) ++{ ++ return atomic64_inc_return(&uevent_seqnum); ++} ++EXPORT_SYMBOL_GPL(uevent_next_seqnum); ++ + /** + * kobject_synth_uevent - send synthetic uevent with arguments + * diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/911-kobject_add_broadcast_uevent.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/911-kobject_add_broadcast_uevent.patch new file mode 100755 index 0000000..df160ba --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/911-kobject_add_broadcast_uevent.patch @@ -0,0 +1,76 @@ +From 0d37e6edc09c99e683dd91ca0e83bbc0df8477b3 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sun, 16 Jul 2017 16:56:10 +0200 +Subject: lib: add broadcast_uevent() + +Signed-off-by: Felix Fietkau +--- + include/linux/kobject.h | 5 +++++ + lib/kobject_uevent.c | 37 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 42 insertions(+) + +--- a/include/linux/kobject.h ++++ b/include/linux/kobject.h +@@ -32,6 +32,8 @@ + #define UEVENT_NUM_ENVP 64 /* number of env pointers */ + #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */ + ++struct sk_buff; ++ + #ifdef CONFIG_UEVENT_HELPER + /* path to the userspace helper executed on an event */ + extern char uevent_helper[]; +@@ -221,4 +223,7 @@ int add_uevent_var(struct kobj_uevent_en + + u64 uevent_next_seqnum(void); + ++int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group, ++ gfp_t allocation); ++ + #endif /* _KOBJECT_H_ */ +--- a/lib/kobject_uevent.c ++++ b/lib/kobject_uevent.c +@@ -699,6 +699,43 @@ int add_uevent_var(struct kobj_uevent_en + EXPORT_SYMBOL_GPL(add_uevent_var); + + #if defined(CONFIG_NET) ++int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group, ++ gfp_t allocation) ++{ ++ struct uevent_sock *ue_sk; ++ int err = 0; ++ ++ /* send netlink message */ ++ mutex_lock(&uevent_sock_mutex); ++ list_for_each_entry(ue_sk, &uevent_sock_list, list) { ++ struct sock *uevent_sock = ue_sk->sk; ++ struct sk_buff *skb2; ++ ++ skb2 = skb_clone(skb, allocation); ++ if (!skb2) ++ break; ++ ++ err = netlink_broadcast(uevent_sock, skb2, pid, group, ++ allocation); ++ if (err) ++ break; ++ } ++ mutex_unlock(&uevent_sock_mutex); ++ ++ kfree_skb(skb); ++ return err; ++} ++#else ++int broadcast_uevent(struct sk_buff *skb, __u32 pid, __u32 group, ++ gfp_t allocation) ++{ ++ kfree_skb(skb); ++ return 0; ++} ++#endif ++EXPORT_SYMBOL_GPL(broadcast_uevent); ++ ++#if defined(CONFIG_NET) + static int uevent_net_broadcast(struct sock *usk, struct sk_buff *skb, + struct netlink_ext_ack *extack) + { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch new file mode 100755 index 0000000..4763e82 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch @@ -0,0 +1,21 @@ +From e08bcbbaa52fcc41f02743fd2e62a33255ce52da Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 13:52:28 +0200 +Subject: [PATCH] of/ftd: add device tree cmdline + +--- + drivers/of/fdt.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/of/fdt.c ++++ b/drivers/of/fdt.c +@@ -1049,6 +1049,9 @@ int __init early_init_dt_scan_chosen(cha + p = of_get_flat_dt_prop(node, "bootargs", &l); + if (p != NULL && l > 0) + strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE)); ++ p = of_get_flat_dt_prop(node, "bootargs-append", &l); ++ if (p != NULL && l > 0) ++ strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE)); + + handle_cmdline: + /* diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch new file mode 100755 index 0000000..a7c8a8e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/hack-6.12/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch @@ -0,0 +1,30 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Tue, 19 Jul 2022 06:17:48 +0200 +Subject: [PATCH] Revert "Revert "Revert "driver core: Set fw_devlink=on by + default""" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit ea718c699055c8566eb64432388a04974c43b2ea. + +With of_platform_populate() called for MTD partitions that commit breaks +probing devices which reference MTD in device tree. + +Link: https://lore.kernel.org/all/696cb2da-20b9-b3dd-46d9-de4bf91a1506@gmail.com/T/#u +Signed-off-by: RafaΕ‚ MiΕ‚ecki +--- + drivers/base/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/base/core.c ++++ b/drivers/base/core.c +@@ -1653,7 +1653,7 @@ static void device_links_purge(struct de + #define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \ + DL_FLAG_PM_RUNTIME) + +-static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_RPM; ++static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE; + static int __init fw_devlink_setup(char *arg) + { + if (!arg) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/Makefile b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/Makefile new file mode 100755 index 0000000..56ea9f6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/Makefile @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2006-2010 OpenWrt.org + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/image.mk + +# use default targets for everything + +$(eval $(call BuildImage)) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/initramfs-base-files.txt b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/initramfs-base-files.txt new file mode 100755 index 0000000..eda5d0d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/initramfs-base-files.txt @@ -0,0 +1,9 @@ +nod /dev/console 600 0 0 c 5 1 +nod /dev/null 666 0 0 c 1 3 +nod /dev/zero 666 0 0 c 1 5 +nod /dev/tty 666 0 0 c 5 0 +nod /dev/tty0 660 0 0 c 4 0 +nod /dev/tty1 660 0 0 c 4 1 +nod /dev/random 666 0 0 c 1 8 +nod /dev/urandom 666 0 0 c 1 9 +dir /dev/pts 755 0 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/Makefile b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/Makefile new file mode 100755 index 0000000..d75a446 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/Makefile @@ -0,0 +1,46 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME := loader +PKG_VERSION := 0.05 + +PKG_BUILD_DIR := $(KDIR)/$(PKG_NAME)-$(PKG_VERSION)$(LOADER_TYPE) + +$(PKG_BUILD_DIR)/.prepared: + mkdir $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ + touch $@ + +$(PKG_BUILD_DIR)/lzma.elf: $(PKG_BUILD_DIR)/.prepared $(PKG_BUILD_DIR)/vmlinux.lzma + PATH="$(TARGET_PATH)" $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" CROSS_COMPILE="$(TARGET_CROSS)" \ + RAMSIZE=$(RAMSIZE) \ + LOADADDR=$(LOADADDR) \ + KERNEL_ENTRY=$(KERNEL_ENTRY) \ + IMAGE_COPY=$(IMAGE_COPY) + + +$(PKG_BUILD_DIR)/vmlinux.lzma: $(KDIR)/vmlinux.lzma + $(CP) $< $@ + +$(KDIR)/loader$(LOADER_TYPE).elf: $(PKG_BUILD_DIR)/lzma.elf + $(CP) $< $@ + +$(KDIR)/loader$(LOADER_TYPE).bin: $(PKG_BUILD_DIR)/lzma.bin + $(CP) $< $@ + +download: +prepare: $(PKG_BUILD_DIR)/.prepared +compile: $(KDIR)/loader$(LOADER_TYPE).elf $(KDIR)/loader$(LOADER_TYPE).bin +install: + +clean: + rm -rf $(PKG_BUILD_DIR) + rm -f $(KDIR)/loader.elf + rm -f $(KDIR)/loader.bin diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/LzmaDecode.c b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/LzmaDecode.c new file mode 100755 index 0000000..8c863ef --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/LzmaDecode.c @@ -0,0 +1,590 @@ +/* + LzmaDecode.c + LZMA Decoder (optimized for Speed version) + + LZMA SDK 4.22 Copyright (c) 1999-2005 Igor Pavlov (2005-06-10) + http://www.7-zip.org/ + + LZMA SDK is licensed under two licenses: + 1) GNU Lesser General Public License (GNU LGPL) + 2) Common Public License (CPL) + It means that you can select one of these two licenses and + follow rules of that license. + + SPECIAL EXCEPTION: + Igor Pavlov, as the author of this Code, expressly permits you to + statically or dynamically link your Code (or bind by name) to the + interfaces of this file without subjecting your linked Code to the + terms of the CPL or GNU LGPL. Any modifications or additions + to this file, however, are subject to the LGPL or CPL terms. +*/ + +#include "LzmaDecode.h" + +#ifndef Byte +#define Byte unsigned char +#endif + +#define kNumTopBits 24 +#define kTopValue ((UInt32)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 + +#define RC_READ_BYTE (*Buffer++) + +#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \ + { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }} + +#ifdef _LZMA_IN_CB + +#define RC_TEST { if (Buffer == BufferLim) \ + { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \ + BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }} + +#define RC_INIT Buffer = BufferLim = 0; RC_INIT2 + +#else + +#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; } + +#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2 + +#endif + +#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; } + +#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound) +#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits; +#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits; + +#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \ + { UpdateBit0(p); mi <<= 1; A0; } else \ + { UpdateBit1(p); mi = (mi + mi) + 1; A1; } + +#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;) + +#define RangeDecoderBitTreeDecode(probs, numLevels, res) \ + { int i = numLevels; res = 1; \ + do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \ + res -= (1 << numLevels); } + + +#define kNumPosBitsMax 4 +#define kNumPosStatesMax (1 << kNumPosBitsMax) + +#define kLenNumLowBits 3 +#define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumMidBits 3 +#define kLenNumMidSymbols (1 << kLenNumMidBits) +#define kLenNumHighBits 8 +#define kLenNumHighSymbols (1 << kLenNumHighBits) + +#define LenChoice 0 +#define LenChoice2 (LenChoice + 1) +#define LenLow (LenChoice2 + 1) +#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) +#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) +#define kNumLenProbs (LenHigh + kLenNumHighSymbols) + + +#define kNumStates 12 +#define kNumLitStates 7 + +#define kStartPosModelIndex 4 +#define kEndPosModelIndex 14 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + +#define kNumPosSlotBits 6 +#define kNumLenToPosStates 4 + +#define kNumAlignBits 4 +#define kAlignTableSize (1 << kNumAlignBits) + +#define kMatchMinLen 2 + +#define IsMatch 0 +#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) +#define IsRepG0 (IsRep + kNumStates) +#define IsRepG1 (IsRepG0 + kNumStates) +#define IsRepG2 (IsRepG1 + kNumStates) +#define IsRep0Long (IsRepG2 + kNumStates) +#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) +#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) +#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) +#define LenCoder (Align + kAlignTableSize) +#define RepLenCoder (LenCoder + kNumLenProbs) +#define Literal (RepLenCoder + kNumLenProbs) + +#if Literal != LZMA_BASE_SIZE +StopCompilingDueBUG +#endif + +#if 0 +int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size) +{ + unsigned char prop0; + if (size < LZMA_PROPERTIES_SIZE) + return LZMA_RESULT_DATA_ERROR; + prop0 = propsData[0]; + if (prop0 >= (9 * 5 * 5)) + return LZMA_RESULT_DATA_ERROR; + { + for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5)); + for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9); + propsRes->lc = prop0; + /* + unsigned char remainder = (unsigned char)(prop0 / 9); + propsRes->lc = prop0 % 9; + propsRes->pb = remainder / 5; + propsRes->lp = remainder % 5; + */ + } + + #ifdef _LZMA_OUT_READ + { + int i; + propsRes->DictionarySize = 0; + for (i = 0; i < 4; i++) + propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8); + if (propsRes->DictionarySize == 0) + propsRes->DictionarySize = 1; + } + #endif + return LZMA_RESULT_OK; +} +#endif + +#define kLzmaStreamWasFinishedId (-1) + +int LzmaDecode(CLzmaDecoderState *vs, + #ifdef _LZMA_IN_CB + ILzmaInCallback *InCallback, + #else + const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, + #endif + unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed) +{ + CProb *p = vs->Probs; + SizeT nowPos = 0; + Byte previousByte = 0; + UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1; + UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1; + int lc = vs->Properties.lc; + + #ifdef _LZMA_OUT_READ + + UInt32 Range = vs->Range; + UInt32 Code = vs->Code; + #ifdef _LZMA_IN_CB + const Byte *Buffer = vs->Buffer; + const Byte *BufferLim = vs->BufferLim; + #else + const Byte *Buffer = inStream; + const Byte *BufferLim = inStream + inSize; + #endif + int state = vs->State; + UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3]; + int len = vs->RemainLen; + UInt32 globalPos = vs->GlobalPos; + UInt32 distanceLimit = vs->DistanceLimit; + + Byte *dictionary = vs->Dictionary; + UInt32 dictionarySize = vs->Properties.DictionarySize; + UInt32 dictionaryPos = vs->DictionaryPos; + + Byte tempDictionary[4]; + + #ifndef _LZMA_IN_CB + *inSizeProcessed = 0; + #endif + *outSizeProcessed = 0; + if (len == kLzmaStreamWasFinishedId) + return LZMA_RESULT_OK; + + if (dictionarySize == 0) + { + dictionary = tempDictionary; + dictionarySize = 1; + tempDictionary[0] = vs->TempDictionary[0]; + } + + if (len == kLzmaNeedInitId) + { + { + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); + UInt32 i; + for (i = 0; i < numProbs; i++) + p[i] = kBitModelTotal >> 1; + rep0 = rep1 = rep2 = rep3 = 1; + state = 0; + globalPos = 0; + distanceLimit = 0; + dictionaryPos = 0; + dictionary[dictionarySize - 1] = 0; + #ifdef _LZMA_IN_CB + RC_INIT; + #else + RC_INIT(inStream, inSize); + #endif + } + len = 0; + } + while(len != 0 && nowPos < outSize) + { + UInt32 pos = dictionaryPos - rep0; + if (pos >= dictionarySize) + pos += dictionarySize; + outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos]; + if (++dictionaryPos == dictionarySize) + dictionaryPos = 0; + len--; + } + if (dictionaryPos == 0) + previousByte = dictionary[dictionarySize - 1]; + else + previousByte = dictionary[dictionaryPos - 1]; + + #else /* if !_LZMA_OUT_READ */ + + int state = 0; + UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; + int len = 0; + const Byte *Buffer; + const Byte *BufferLim; + UInt32 Range; + UInt32 Code; + + #ifndef _LZMA_IN_CB + *inSizeProcessed = 0; + #endif + *outSizeProcessed = 0; + + { + UInt32 i; + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); + for (i = 0; i < numProbs; i++) + p[i] = kBitModelTotal >> 1; + } + + #ifdef _LZMA_IN_CB + RC_INIT; + #else + RC_INIT(inStream, inSize); + #endif + + #endif /* _LZMA_OUT_READ */ + + while(nowPos < outSize) + { + CProb *prob; + UInt32 bound; + int posState = (int)( + (nowPos + #ifdef _LZMA_OUT_READ + + globalPos + #endif + ) + & posStateMask); + + prob = p + IsMatch + (state << kNumPosBitsMax) + posState; + IfBit0(prob) + { + int symbol = 1; + UpdateBit0(prob) + prob = p + Literal + (LZMA_LIT_SIZE * + ((( + (nowPos + #ifdef _LZMA_OUT_READ + + globalPos + #endif + ) + & literalPosMask) << lc) + (previousByte >> (8 - lc)))); + + if (state >= kNumLitStates) + { + int matchByte; + #ifdef _LZMA_OUT_READ + UInt32 pos = dictionaryPos - rep0; + if (pos >= dictionarySize) + pos += dictionarySize; + matchByte = dictionary[pos]; + #else + matchByte = outStream[nowPos - rep0]; + #endif + do + { + int bit; + CProb *probLit; + matchByte <<= 1; + bit = (matchByte & 0x100); + probLit = prob + 0x100 + bit + symbol; + RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break) + } + while (symbol < 0x100); + } + while (symbol < 0x100) + { + CProb *probLit = prob + symbol; + RC_GET_BIT(probLit, symbol) + } + previousByte = (Byte)symbol; + + outStream[nowPos++] = previousByte; + #ifdef _LZMA_OUT_READ + if (distanceLimit < dictionarySize) + distanceLimit++; + + dictionary[dictionaryPos] = previousByte; + if (++dictionaryPos == dictionarySize) + dictionaryPos = 0; + #endif + if (state < 4) state = 0; + else if (state < 10) state -= 3; + else state -= 6; + } + else + { + UpdateBit1(prob); + prob = p + IsRep + state; + IfBit0(prob) + { + UpdateBit0(prob); + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + state = state < kNumLitStates ? 0 : 3; + prob = p + LenCoder; + } + else + { + UpdateBit1(prob); + prob = p + IsRepG0 + state; + IfBit0(prob) + { + UpdateBit0(prob); + prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState; + IfBit0(prob) + { + #ifdef _LZMA_OUT_READ + UInt32 pos; + #endif + UpdateBit0(prob); + + #ifdef _LZMA_OUT_READ + if (distanceLimit == 0) + #else + if (nowPos == 0) + #endif + return LZMA_RESULT_DATA_ERROR; + + state = state < kNumLitStates ? 9 : 11; + #ifdef _LZMA_OUT_READ + pos = dictionaryPos - rep0; + if (pos >= dictionarySize) + pos += dictionarySize; + previousByte = dictionary[pos]; + dictionary[dictionaryPos] = previousByte; + if (++dictionaryPos == dictionarySize) + dictionaryPos = 0; + #else + previousByte = outStream[nowPos - rep0]; + #endif + outStream[nowPos++] = previousByte; + #ifdef _LZMA_OUT_READ + if (distanceLimit < dictionarySize) + distanceLimit++; + #endif + + continue; + } + else + { + UpdateBit1(prob); + } + } + else + { + UInt32 distance; + UpdateBit1(prob); + prob = p + IsRepG1 + state; + IfBit0(prob) + { + UpdateBit0(prob); + distance = rep1; + } + else + { + UpdateBit1(prob); + prob = p + IsRepG2 + state; + IfBit0(prob) + { + UpdateBit0(prob); + distance = rep2; + } + else + { + UpdateBit1(prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < kNumLitStates ? 8 : 11; + prob = p + RepLenCoder; + } + { + int numBits, offset; + CProb *probLen = prob + LenChoice; + IfBit0(probLen) + { + UpdateBit0(probLen); + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + numBits = kLenNumLowBits; + } + else + { + UpdateBit1(probLen); + probLen = prob + LenChoice2; + IfBit0(probLen) + { + UpdateBit0(probLen); + probLen = prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + numBits = kLenNumMidBits; + } + else + { + UpdateBit1(probLen); + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + numBits = kLenNumHighBits; + } + } + RangeDecoderBitTreeDecode(probLen, numBits, len); + len += offset; + } + + if (state < 4) + { + int posSlot; + state += kNumLitStates; + prob = p + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << + kNumPosSlotBits); + RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot); + if (posSlot >= kStartPosModelIndex) + { + int numDirectBits = ((posSlot >> 1) - 1); + rep0 = (2 | ((UInt32)posSlot & 1)); + if (posSlot < kEndPosModelIndex) + { + rep0 <<= numDirectBits; + prob = p + SpecPos + rep0 - posSlot - 1; + } + else + { + numDirectBits -= kNumAlignBits; + do + { + RC_NORMALIZE + Range >>= 1; + rep0 <<= 1; + if (Code >= Range) + { + Code -= Range; + rep0 |= 1; + } + } + while (--numDirectBits != 0); + prob = p + Align; + rep0 <<= kNumAlignBits; + numDirectBits = kNumAlignBits; + } + { + int i = 1; + int mi = 1; + do + { + CProb *prob3 = prob + mi; + RC_GET_BIT2(prob3, mi, ; , rep0 |= i); + i <<= 1; + } + while(--numDirectBits != 0); + } + } + else + rep0 = posSlot; + if (++rep0 == (UInt32)(0)) + { + /* it's for stream version */ + len = kLzmaStreamWasFinishedId; + break; + } + } + + len += kMatchMinLen; + #ifdef _LZMA_OUT_READ + if (rep0 > distanceLimit) + #else + if (rep0 > nowPos) + #endif + return LZMA_RESULT_DATA_ERROR; + + #ifdef _LZMA_OUT_READ + if (dictionarySize - distanceLimit > (UInt32)len) + distanceLimit += len; + else + distanceLimit = dictionarySize; + #endif + + do + { + #ifdef _LZMA_OUT_READ + UInt32 pos = dictionaryPos - rep0; + if (pos >= dictionarySize) + pos += dictionarySize; + previousByte = dictionary[pos]; + dictionary[dictionaryPos] = previousByte; + if (++dictionaryPos == dictionarySize) + dictionaryPos = 0; + #else + previousByte = outStream[nowPos - rep0]; + #endif + len--; + outStream[nowPos++] = previousByte; + } + while(len != 0 && nowPos < outSize); + } + } + RC_NORMALIZE; + + #ifdef _LZMA_OUT_READ + vs->Range = Range; + vs->Code = Code; + vs->DictionaryPos = dictionaryPos; + vs->GlobalPos = globalPos + (UInt32)nowPos; + vs->DistanceLimit = distanceLimit; + vs->Reps[0] = rep0; + vs->Reps[1] = rep1; + vs->Reps[2] = rep2; + vs->Reps[3] = rep3; + vs->State = state; + vs->RemainLen = len; + vs->TempDictionary[0] = tempDictionary[0]; + #endif + + #ifdef _LZMA_IN_CB + vs->Buffer = Buffer; + vs->BufferLim = BufferLim; + #else + *inSizeProcessed = (SizeT)(Buffer - inStream); + #endif + *outSizeProcessed = nowPos; + return LZMA_RESULT_OK; +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/LzmaDecode.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/LzmaDecode.h new file mode 100755 index 0000000..abc02d7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/LzmaDecode.h @@ -0,0 +1,131 @@ +/* + LzmaDecode.h + LZMA Decoder interface + + LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08) + http://www.7-zip.org/ + + LZMA SDK is licensed under two licenses: + 1) GNU Lesser General Public License (GNU LGPL) + 2) Common Public License (CPL) + It means that you can select one of these two licenses and + follow rules of that license. + + SPECIAL EXCEPTION: + Igor Pavlov, as the author of this code, expressly permits you to + statically or dynamically link your code (or bind by name) to the + interfaces of this file without subjecting your linked code to the + terms of the CPL or GNU LGPL. Any modifications or additions + to this file, however, are subject to the LGPL or CPL terms. +*/ + +#ifndef __LZMADECODE_H +#define __LZMADECODE_H + +/* #define _LZMA_IN_CB */ +/* Use callback for input data */ + +/* #define _LZMA_OUT_READ */ +/* Use read function for output data */ + +/* #define _LZMA_PROB32 */ +/* It can increase speed on some 32-bit CPUs, + but memory usage will be doubled in that case */ + +/* #define _LZMA_LOC_OPT */ +/* Enable local speed optimizations inside code */ + +/* #define _LZMA_SYSTEM_SIZE_T */ +/* Use system's size_t. You can use it to enable 64-bit sizes supporting*/ + +#ifndef UInt32 +#ifdef _LZMA_UINT32_IS_ULONG +#define UInt32 unsigned long +#else +#define UInt32 unsigned int +#endif +#endif + +#ifndef SizeT +#ifdef _LZMA_SYSTEM_SIZE_T +#include +#define SizeT size_t +#else +#define SizeT UInt32 +#endif +#endif + +#ifdef _LZMA_PROB32 +#define CProb UInt32 +#else +#define CProb unsigned short +#endif + +#define LZMA_RESULT_OK 0 +#define LZMA_RESULT_DATA_ERROR 1 + +#ifdef _LZMA_IN_CB +typedef struct _ILzmaInCallback +{ + int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize); +} ILzmaInCallback; +#endif + +#define LZMA_BASE_SIZE 1846 +#define LZMA_LIT_SIZE 768 + +#define LZMA_PROPERTIES_SIZE 5 + +typedef struct _CLzmaProperties +{ + int lc; + int lp; + int pb; + #ifdef _LZMA_OUT_READ + UInt32 DictionarySize; + #endif +}CLzmaProperties; + +int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); + +#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp))) + +#define kLzmaNeedInitId (-2) + +typedef struct _CLzmaDecoderState +{ + CLzmaProperties Properties; + CProb *Probs; + + #ifdef _LZMA_IN_CB + const unsigned char *Buffer; + const unsigned char *BufferLim; + #endif + + #ifdef _LZMA_OUT_READ + unsigned char *Dictionary; + UInt32 Range; + UInt32 Code; + UInt32 DictionaryPos; + UInt32 GlobalPos; + UInt32 DistanceLimit; + UInt32 Reps[4]; + int State; + int RemainLen; + unsigned char TempDictionary[4]; + #endif +} CLzmaDecoderState; + +#ifdef _LZMA_OUT_READ +#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; } +#endif + +int LzmaDecode(CLzmaDecoderState *vs, + #ifdef _LZMA_IN_CB + ILzmaInCallback *inCallback, + #else + const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, + #endif + unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/Makefile b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/Makefile new file mode 100755 index 0000000..910172c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/Makefile @@ -0,0 +1,68 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +RAMSTART = 0x80000000 +RAMSIZE = 0x00100000 # 1MB +LOADADDR = 0x80400000 # RAM start + 4M +KERNEL_ENTRY = 0x80001000 +IMAGE_COPY:=0 + +CROSS_COMPILE = mips-linux- + +OBJCOPY:= $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S +CFLAGS := -fno-builtin -Os -G 0 -ffunction-sections -mno-abicalls -fno-pic -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap -Wall -DRAMSTART=${RAMSTART} -DRAMSIZE=${RAMSIZE} -DKERNEL_ENTRY=${KERNEL_ENTRY} -D_LZMA_IN_CB +ifeq ($(IMAGE_COPY),1) +CFLAGS += -DLOADADDR=${LOADADDR} -DIMAGE_COPY=1 +endif + +.S.s: + $(CPP) $(CFLAGS) $< -o $*.s +.S.o: + $(CC) $(CFLAGS) -c $< -o $*.o +.c.o: + $(CC) $(CFLAGS) -c $< -o $*.o + +CC = $(CROSS_COMPILE)gcc +LD = $(CROSS_COMPILE)ld +OBJDUMP = $(CROSS_COMPILE)objdump + +O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32) + +# Drop some uninteresting sections in the kernel. +# This is only relevant for ELF kernels but doesn't hurt a.out +drop-sections = .reginfo .mdebug .comment +strip-flags = $(addprefix --remove-section=,$(drop-sections)) + +all : lzma.elf lzma.bin + +lzma.lds: lzma.lds.in + sed -e 's,@LOADADDR@,$(LOADADDR),g' -e 's,@ENTRY@,_start,g' $< >$@ + +kernel.o: vmlinux.lzma lzma.lds + $(LD) -r -b binary --oformat $(O_FORMAT) -o $@ $< + +lzma.bin: lzma.elf + $(OBJCOPY) $< $@ + +ifeq ($(IMAGE_COPY),1) +LOADER_ENTRY ?= $(KERNEL_ENTRY) +lzma.o: decompress.o LzmaDecode.o kernel.o + sed -e 's,@LOADADDR@,$(LOADADDR),g' -e 's,@ENTRY@,entry,g' lzma.lds.in >lzma-stage2.lds + $(LD) -static --no-warn-mismatch -e entry -Tlzma-stage2.lds -o temp-$@ $^ + $(OBJCOPY) temp-$@ lzma.tmp + @echo "SECTIONS { .data : { code_start = .; *(.data) code_stop = .; }}" > lzma-data.lds + $(LD) -no-warn-mismatch -T lzma-data.lds -r -o $@ -b binary lzma.tmp --oformat $(O_FORMAT) + +lzma.elf: start.o lzma.o + sed -e 's,@LOADADDR@,$(LOADER_ENTRY),g' lzma-copy.lds.in >lzma-copy.lds + $(LD) -s -Tlzma-copy.lds -o $@ $^ +else +lzma.elf: start.o decompress.o LzmaDecode.o kernel.o + $(LD) -s -Tlzma.lds -o $@ $^ +endif + +clean: + rm -f *.o lzma.elf lzma.bin *.tmp *.lds diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/decompress.c b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/decompress.c new file mode 100755 index 0000000..45d77c7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/decompress.c @@ -0,0 +1,157 @@ +/* + * LZMA compressed kernel decompressor for bcm947xx boards + * + * Copyright (C) 2005 by Oleg I. Vdovikin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * Please note, this was code based on the bunzip2 decompressor code + * by Manuel Novoa III (mjn3@codepoet.org), although the only thing left + * is an idea and part of original vendor code + * + * + * 12-Mar-2005 Mineharu Takahara + * pass actual output size to decoder (stream mode + * compressed input is not a requirement anymore) + * + * 24-Apr-2005 Oleg I. Vdovikin + * reordered functions using lds script, removed forward decl + * + * ??-Nov-2005 Mike Baker + * reorder the script as an lzma wrapper; do not depend on flash access + */ + +#include "LzmaDecode.h" + +#define KSEG0 0x80000000 +#define KSEG1 0xa0000000 + +#define KSEG1ADDR(a) ((((unsigned)(a)) & 0x1fffffffU) | KSEG1) + +#define Index_Invalidate_I 0x00 +#define Index_Writeback_Inv_D 0x01 + +#define cache_unroll(base,op) \ + __asm__ __volatile__( \ + ".set noreorder;\n" \ + ".set mips3;\n" \ + "cache %1, (%0);\n" \ + ".set mips0;\n" \ + ".set reorder\n" \ + : \ + : "r" (base), \ + "i" (op)); + + +static __inline__ void blast_icache(unsigned long size, unsigned long lsize) +{ + unsigned long start = KSEG0; + unsigned long end = (start + size); + + while(start < end) { + cache_unroll(start,Index_Invalidate_I); + start += lsize; + } +} + +static __inline__ void blast_dcache(unsigned long size, unsigned long lsize) +{ + unsigned long start = KSEG0; + unsigned long end = (start + size); + + while(start < end) { + cache_unroll(start,Index_Writeback_Inv_D); + start += lsize; + } +} + +unsigned char *data; + +static int read_byte(void *object, unsigned char **buffer, UInt32 *bufferSize) +{ + *bufferSize = 1; + *buffer = data; + ++data; + return LZMA_RESULT_OK; +} + +static __inline__ unsigned char get_byte(void) +{ + unsigned char *buffer; + UInt32 fake; + + return read_byte(0, &buffer, &fake), *buffer; +} + +/* This puts lzma workspace 128k below RAM end. + * That should be enough for both lzma and stack + */ +static char *buffer = (char *)(RAMSTART + RAMSIZE - 0x00020000); +extern char lzma_start[]; +extern char lzma_end[]; + +/* should be the first function */ +void entry(unsigned long icache_size, unsigned long icache_lsize, + unsigned long dcache_size, unsigned long dcache_lsize) +{ + unsigned int i; /* temp value */ + unsigned int osize; /* uncompressed size */ + volatile unsigned int arg0, arg1, arg2, arg3; + + /* restore argument registers */ + __asm__ __volatile__ ("ori %0, $12, 0":"=r"(arg0)); + __asm__ __volatile__ ("ori %0, $13, 0":"=r"(arg1)); + __asm__ __volatile__ ("ori %0, $14, 0":"=r"(arg2)); + __asm__ __volatile__ ("ori %0, $15, 0":"=r"(arg3)); + + ILzmaInCallback callback; + CLzmaDecoderState vs; + callback.Read = read_byte; + + data = lzma_start; + + /* lzma args */ + i = get_byte(); + vs.Properties.lc = i % 9, i = i / 9; + vs.Properties.lp = i % 5, vs.Properties.pb = i / 5; + + vs.Probs = (CProb *)buffer; + + /* skip rest of the LZMA coder property */ + for (i = 0; i < 4; i++) + get_byte(); + + /* read the lower half of uncompressed size in the header */ + osize = ((unsigned int)get_byte()) + + ((unsigned int)get_byte() << 8) + + ((unsigned int)get_byte() << 16) + + ((unsigned int)get_byte() << 24); + + /* skip rest of the header (upper half of uncompressed size) */ + for (i = 0; i < 4; i++) + get_byte(); + + /* decompress kernel */ + if ((i = LzmaDecode(&vs, &callback, + (unsigned char*)KERNEL_ENTRY, osize, &osize)) == LZMA_RESULT_OK) + { + blast_dcache(dcache_size, dcache_lsize); + blast_icache(icache_size, icache_lsize); + + /* Jump to load address */ + ((void (*)(int a0, int a1, int a2, int a3)) KERNEL_ENTRY)(arg0, arg1, arg2, arg3); + } +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/lzma-copy.lds.in b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/lzma-copy.lds.in new file mode 100755 index 0000000..fbc87ab --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/lzma-copy.lds.in @@ -0,0 +1,20 @@ +OUTPUT_ARCH(mips) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = @LOADADDR@; + .text : + { + _ftext = . ; + *(.text) + *(.rodata) + } =0 + + .reginfo : { *(.reginfo) } + + .bss : + { + *(.bss) + } +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/lzma.lds.in b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/lzma.lds.in new file mode 100755 index 0000000..6021cec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/lzma.lds.in @@ -0,0 +1,24 @@ +OUTPUT_ARCH(mips) +ENTRY(@ENTRY@) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = @LOADADDR@; + .text : + { + _ftext = . ; + *(.text.entry) + *(.text) + *(.rodata) + lzma_start = .; + kernel.o + lzma_end = .; + } =0 + + .reginfo : { *(.reginfo) } + + .bss : + { + *(.bss) + } +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/print.c b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/print.c new file mode 100755 index 0000000..66c1778 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/print.c @@ -0,0 +1,324 @@ +/* + * Copyright (C) 2001 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include "print.h" + +/* macros */ +#define IsDigit(x) ( ((x) >= '0') && ((x) <= '9') ) +#define Ctod(x) ( (x) - '0') + +/* forward declaration */ +extern int PrintChar(char *, char, int, int); +extern int PrintString(char *, char *, int, int); +extern int PrintNum(char *, unsigned long, int, int, int, int, char, int); + +/* private variable */ +static const char theFatalMsg[] = "fatal error in lp_Print!"; + +/* -*- + * A low level printf() function. + */ +void +lp_Print(void (*output)(void *, char *, int), + void * arg, + char *fmt, + va_list ap) +{ + +#define OUTPUT(arg, s, l) \ + { if (((l) < 0) || ((l) > LP_MAX_BUF)) { \ + (*output)(arg, (char*)theFatalMsg, sizeof(theFatalMsg)-1); for(;;); \ + } else { \ + (*output)(arg, s, l); \ + } \ + } + + char buf[LP_MAX_BUF]; + + char c; + char *s; + long int num; + + int longFlag; + int negFlag; + int width; + int prec; + int ladjust; + char padc; + + int length; + + for(;;) { + { + /* scan for the next '%' */ + char *fmtStart = fmt; + while ( (*fmt != '\0') && (*fmt != '%')) { + fmt ++; + } + + /* flush the string found so far */ + OUTPUT(arg, fmtStart, fmt-fmtStart); + + /* are we hitting the end? */ + if (*fmt == '\0') break; + } + + /* we found a '%' */ + fmt ++; + + /* check for long */ + if (*fmt == 'l') { + longFlag = 1; + fmt ++; + } else { + longFlag = 0; + } + + /* check for other prefixes */ + width = 0; + prec = -1; + ladjust = 0; + padc = ' '; + + if (*fmt == '-') { + ladjust = 1; + fmt ++; + } + + if (*fmt == '0') { + padc = '0'; + fmt++; + } + + if (IsDigit(*fmt)) { + while (IsDigit(*fmt)) { + width = 10 * width + Ctod(*fmt++); + } + } + + if (*fmt == '.') { + fmt ++; + if (IsDigit(*fmt)) { + prec = 0; + while (IsDigit(*fmt)) { + prec = prec*10 + Ctod(*fmt++); + } + } + } + + + /* check format flag */ + negFlag = 0; + switch (*fmt) { + case 'b': + if (longFlag) { + num = va_arg(ap, long int); + } else { + num = va_arg(ap, int); + } + length = PrintNum(buf, num, 2, 0, width, ladjust, padc, 0); + OUTPUT(arg, buf, length); + break; + + case 'd': + case 'D': + if (longFlag) { + num = va_arg(ap, long int); + } else { + num = va_arg(ap, int); + } + if (num < 0) { + num = - num; + negFlag = 1; + } + length = PrintNum(buf, num, 10, negFlag, width, ladjust, padc, 0); + OUTPUT(arg, buf, length); + break; + + case 'o': + case 'O': + if (longFlag) { + num = va_arg(ap, long int); + } else { + num = va_arg(ap, int); + } + length = PrintNum(buf, num, 8, 0, width, ladjust, padc, 0); + OUTPUT(arg, buf, length); + break; + + case 'u': + case 'U': + if (longFlag) { + num = va_arg(ap, long int); + } else { + num = va_arg(ap, int); + } + length = PrintNum(buf, num, 10, 0, width, ladjust, padc, 0); + OUTPUT(arg, buf, length); + break; + + case 'x': + if (longFlag) { + num = va_arg(ap, long int); + } else { + num = va_arg(ap, int); + } + length = PrintNum(buf, num, 16, 0, width, ladjust, padc, 0); + OUTPUT(arg, buf, length); + break; + + case 'X': + if (longFlag) { + num = va_arg(ap, long int); + } else { + num = va_arg(ap, int); + } + length = PrintNum(buf, num, 16, 0, width, ladjust, padc, 1); + OUTPUT(arg, buf, length); + break; + + case 'c': + c = (char)va_arg(ap, int); + length = PrintChar(buf, c, width, ladjust); + OUTPUT(arg, buf, length); + break; + + case 's': + s = (char*)va_arg(ap, char *); + length = PrintString(buf, s, width, ladjust); + OUTPUT(arg, buf, length); + break; + + case '\0': + fmt --; + break; + + default: + /* output this char as it is */ + OUTPUT(arg, fmt, 1); + } /* switch (*fmt) */ + + fmt ++; + } /* for(;;) */ + + /* special termination call */ + OUTPUT(arg, "\0", 1); +} + + +/* --------------- local help functions --------------------- */ +int +PrintChar(char * buf, char c, int length, int ladjust) +{ + int i; + + if (length < 1) length = 1; + if (ladjust) { + *buf = c; + for (i=1; i< length; i++) buf[i] = ' '; + } else { + for (i=0; i< length-1; i++) buf[i] = ' '; + buf[length - 1] = c; + } + return length; +} + +int +PrintString(char * buf, char* s, int length, int ladjust) +{ + int i; + int len=0; + char* s1 = s; + while (*s1++) len++; + if (length < len) length = len; + + if (ladjust) { + for (i=0; i< len; i++) buf[i] = s[i]; + for (i=len; i< length; i++) buf[i] = ' '; + } else { + for (i=0; i< length-len; i++) buf[i] = ' '; + for (i=length-len; i < length; i++) buf[i] = s[i-length+len]; + } + return length; +} + +int +PrintNum(char * buf, unsigned long u, int base, int negFlag, + int length, int ladjust, char padc, int upcase) +{ + /* algorithm : + * 1. prints the number from left to right in reverse form. + * 2. fill the remaining spaces with padc if length is longer than + * the actual length + * TRICKY : if left adjusted, no "0" padding. + * if negtive, insert "0" padding between "0" and number. + * 3. if (!ladjust) we reverse the whole string including paddings + * 4. otherwise we only reverse the actual string representing the num. + */ + + int actualLength =0; + char *p = buf; + int i; + + do { + int tmp = u %base; + if (tmp <= 9) { + *p++ = '0' + tmp; + } else if (upcase) { + *p++ = 'A' + tmp - 10; + } else { + *p++ = 'a' + tmp - 10; + } + u /= base; + } while (u != 0); + + if (negFlag) { + *p++ = '-'; + } + + /* figure out actual length and adjust the maximum length */ + actualLength = p - buf; + if (length < actualLength) length = actualLength; + + /* add padding */ + if (ladjust) { + padc = ' '; + } + if (negFlag && !ladjust && (padc == '0')) { + for (i = actualLength-1; i< length-1; i++) buf[i] = padc; + buf[length -1] = '-'; + } else { + for (i = actualLength; i< length; i++) buf[i] = padc; + } + + + /* prepare to reverse the string */ + { + int begin = 0; + int end; + if (ladjust) { + end = actualLength - 1; + } else { + end = length -1; + } + + while (end > begin) { + char tmp = buf[begin]; + buf[begin] = buf[end]; + buf[end] = tmp; + begin ++; + end --; + } + } + + /* adjust the string pointer */ + return length; +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/print.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/print.h new file mode 100755 index 0000000..9fea609 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/print.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2001 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef _print_h_ +#define _print_h_ + +#include + +/* this is the maximum width for a variable */ +#define LP_MAX_BUF 80 + +/* -*- + * output function takes an void pointer which is passed in as the + * second argument in lp_Print(). This black-box argument gives output + * function a way to track state. + * + * The second argument in output function is a pointer to char buffer. + * The third argument specifies the number of chars to outputed. + * + * output function cannot assume the buffer is null-terminated after + * l number of chars. + */ +void lp_Print(void (*output)(void *, char *, int), + void * arg, + char *fmt, + va_list ap); + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/printf.c b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/printf.c new file mode 100755 index 0000000..e3d5332 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/printf.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2001 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include "printf.h" +#include "print.h" +#include "uart16550.h" + +static void myoutput(void *arg, char *s, int l) +{ + int i; + + // special termination call + if ((l==1) && (s[0] == '\0')) return; + + for (i=0; i< l; i++) { + Uart16550Put(s[i]); + if (s[i] == '\n') Uart16550Put('\r'); + } +} + +void printf(char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + lp_Print(myoutput, 0, fmt, ap); + va_end(ap); +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/printf.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/printf.h new file mode 100755 index 0000000..9b1c1df --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/printf.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2001 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef _printf_h_ +#define _printf_h_ + +#include +void printf(char *fmt, ...); + +#endif /* _printf_h_ */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/start.S b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/start.S new file mode 100755 index 0000000..f025dab --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/start.S @@ -0,0 +1,160 @@ +#include +#include + +#define KSEG0 0x80000000 + +#define C0_CONFIG $16 +#define C0_TAGLO $28 +#define C0_TAGHI $29 + +#define CONF1_DA_SHIFT 7 /* D$ associativity */ +#define CONF1_DA_MASK 0x00000380 +#define CONF1_DA_BASE 1 +#define CONF1_DL_SHIFT 10 /* D$ line size */ +#define CONF1_DL_MASK 0x00001c00 +#define CONF1_DL_BASE 2 +#define CONF1_DS_SHIFT 13 /* D$ sets/way */ +#define CONF1_DS_MASK 0x0000e000 +#define CONF1_DS_BASE 64 +#define CONF1_IA_SHIFT 16 /* I$ associativity */ +#define CONF1_IA_MASK 0x00070000 +#define CONF1_IA_BASE 1 +#define CONF1_IL_SHIFT 19 /* I$ line size */ +#define CONF1_IL_MASK 0x00380000 +#define CONF1_IL_BASE 2 +#define CONF1_IS_SHIFT 22 /* Instruction cache sets/way */ +#define CONF1_IS_MASK 0x01c00000 +#define CONF1_IS_BASE 64 + +#define Index_Invalidate_I 0x00 +#define Index_Writeback_Inv_D 0x01 + +LEAF(_start) + + .set mips32 + .set noreorder + + /* save argument registers */ + move t4, a0 + move t5, a1 + move t6, a2 + move t7, a3 + + /* set up stack */ + li sp, RAMSTART + RAMSIZE - 16 + +#ifdef IMAGE_COPY + /* Copy decompressor code to the right place */ + li t2, LOADADDR + add a0, t2, 0 + la a1, code_start + la a2, code_stop +$L1: + lw t0, 0(a1) + sw t0, 0(a0) + add a1, 4 + add a0, 4 + blt a1, a2, $L1 + nop +#endif + + /* At this point we need to invalidate dcache and */ + /* icache before jumping to new code */ + +1: /* Get cache sizes */ + mfc0 s0,C0_CONFIG,1 + + li s1,CONF1_DL_MASK + and s1,s0 + beq s1,zero,nodc + nop + + srl s1,CONF1_DL_SHIFT + li t0,CONF1_DL_BASE + sll s1,t0,s1 /* s1 has D$ cache line size */ + + li s2,CONF1_DA_MASK + and s2,s0 + srl s2,CONF1_DA_SHIFT + addiu s2,CONF1_DA_BASE /* s2 now has D$ associativity */ + + li t0,CONF1_DS_MASK + and t0,s0 + srl t0,CONF1_DS_SHIFT + li s3,CONF1_DS_BASE + sll s3,s3,t0 /* s3 has D$ sets per way */ + + multu s2,s3 /* sets/way * associativity */ + mflo t0 /* total cache lines */ + + multu s1,t0 /* D$ linesize * lines */ + mflo s2 /* s2 is now D$ size in bytes */ + + /* Initilize the D$: */ + mtc0 zero,C0_TAGLO + mtc0 zero,C0_TAGHI + + li t0,KSEG0 /* Just an address for the first $ line */ + addu t1,t0,s2 /* + size of cache == end */ + +1: cache Index_Writeback_Inv_D,0(t0) + bne t0,t1,1b + addu t0,s1 + +nodc: + /* Now we get to do it all again for the I$ */ + + move s3,zero /* just in case there is no icache */ + move s4,zero + + li t0,CONF1_IL_MASK + and t0,s0 + beq t0,zero,noic + nop + + srl t0,CONF1_IL_SHIFT + li s3,CONF1_IL_BASE + sll s3,t0 /* s3 has I$ cache line size */ + + li t0,CONF1_IA_MASK + and t0,s0 + srl t0,CONF1_IA_SHIFT + addiu s4,t0,CONF1_IA_BASE /* s4 now has I$ associativity */ + + li t0,CONF1_IS_MASK + and t0,s0 + srl t0,CONF1_IS_SHIFT + li s5,CONF1_IS_BASE + sll s5,t0 /* s5 has I$ sets per way */ + + multu s4,s5 /* sets/way * associativity */ + mflo t0 /* s4 is now total cache lines */ + + multu s3,t0 /* I$ linesize * lines */ + mflo s4 /* s4 is cache size in bytes */ + + /* Initilize the I$: */ + mtc0 zero,C0_TAGLO + mtc0 zero,C0_TAGHI + + li t0,KSEG0 /* Just an address for the first $ line */ + addu t1,t0,s4 /* + size of cache == end */ + +1: cache Index_Invalidate_I,0(t0) + bne t0,t1,1b + addu t0,s3 +noic: + /* jump to main */ + move a0,s4 /* icache size */ + move a1,s3 /* icache line size */ + move a2,s2 /* dcache size */ +#ifdef IMAGE_COPY + jal t2 +#else + jal entry +#endif + move a3,s1 /* dcache line size */ + + .set reorder +END(_start) + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/uart16550.c b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/uart16550.c new file mode 100755 index 0000000..125670f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/uart16550.c @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2001 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + + +#include "uart16550.h" + +/* === CONFIG === */ + +#define BASE 0xb8058000 +#define MAX_BAUD 1152000 +#define REG_OFFSET 4 + +/* === END OF CONFIG === */ + +/* register offset */ +#define OFS_RCV_BUFFER (0*REG_OFFSET) +#define OFS_TRANS_HOLD (0*REG_OFFSET) +#define OFS_SEND_BUFFER (0*REG_OFFSET) +#define OFS_INTR_ENABLE (1*REG_OFFSET) +#define OFS_INTR_ID (2*REG_OFFSET) +#define OFS_DATA_FORMAT (3*REG_OFFSET) +#define OFS_LINE_CONTROL (3*REG_OFFSET) +#define OFS_MODEM_CONTROL (4*REG_OFFSET) +#define OFS_RS232_OUTPUT (4*REG_OFFSET) +#define OFS_LINE_STATUS (5*REG_OFFSET) +#define OFS_MODEM_STATUS (6*REG_OFFSET) +#define OFS_RS232_INPUT (6*REG_OFFSET) +#define OFS_SCRATCH_PAD (7*REG_OFFSET) + +#define OFS_DIVISOR_LSB (0*REG_OFFSET) +#define OFS_DIVISOR_MSB (1*REG_OFFSET) + + +/* memory-mapped read/write of the port */ +#define UART16550_READ(y) (*((volatile uint32*)(BASE + y))) +#define UART16550_WRITE(y, z) ((*((volatile uint32*)(BASE + y))) = z) + +#define DEBUG_LED (*(unsigned short*)0xb7ffffc0) +#define OutputLED(x) (DEBUG_LED = x) + +void Uart16550Init(uint32 baud, uint8 data, uint8 parity, uint8 stop) +{ + /* disable interrupts */ + UART16550_WRITE(OFS_INTR_ENABLE, 0); + + /* set up buad rate */ + { + uint32 divisor; + + /* set DIAB bit */ + UART16550_WRITE(OFS_LINE_CONTROL, 0x80); + + /* set divisor */ + divisor = MAX_BAUD / baud; + UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff); + UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00)>>8); + + /* clear DIAB bit */ + UART16550_WRITE(OFS_LINE_CONTROL, 0x0); + } + + /* set data format */ + UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop); +} + +uint8 Uart16550GetPoll() +{ + while((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0); + return UART16550_READ(OFS_RCV_BUFFER); +} + + +void Uart16550Put(uint8 byte) +{ + while ((UART16550_READ(OFS_LINE_STATUS) &0x20) == 0); + UART16550_WRITE(OFS_SEND_BUFFER, byte); +} + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/uart16550.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/uart16550.h new file mode 100755 index 0000000..b3fd6fd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/lzma-loader/src/uart16550.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2001 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef _uart16550_h_ +#define _uart16550_h_ + +typedef unsigned char uint8; +typedef unsigned int uint32; + +#define UART16550_BAUD_2400 2400 +#define UART16550_BAUD_4800 4800 +#define UART16550_BAUD_9600 9600 +#define UART16550_BAUD_19200 19200 +#define UART16550_BAUD_38400 38400 +#define UART16550_BAUD_57600 57600 +#define UART16550_BAUD_115200 115200 + +#define UART16550_PARITY_NONE 0 +#define UART16550_PARITY_ODD 0x08 +#define UART16550_PARITY_EVEN 0x18 +#define UART16550_PARITY_MARK 0x28 +#define UART16550_PARITY_SPACE 0x38 + +#define UART16550_DATA_5BIT 0x0 +#define UART16550_DATA_6BIT 0x1 +#define UART16550_DATA_7BIT 0x2 +#define UART16550_DATA_8BIT 0x3 + +#define UART16550_STOP_1BIT 0x0 +#define UART16550_STOP_2BIT 0x4 + +void Uart16550Init(uint32 baud, uint8 data, uint8 parity, uint8 stop); + +/* blocking call */ +uint8 Uart16550GetPoll(); + +void Uart16550Put(uint8 byte); + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/Makefile b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/Makefile new file mode 100755 index 0000000..62e3b32 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/Makefile @@ -0,0 +1,75 @@ +# +# Makefile for the kernel relocation stub for MIPS devices +# +# Copyright (C) 2011 Gabor Juhos +# Copyright (C) 2015 Felix Fietkau +# +# Some parts of this file was based on the OpenWrt specific lzma-loader +# for the BCM47xx and ADM5120 based boards: +# Copyright (C) 2004 Manuel Novoa III (mjn3@codepoet.org) +# Copyright (C) 2005 Mineharu Takahara +# Copyright (C) 2005 by Oleg I. Vdovikin +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation. +# + +LOADADDR := +LZMA_TEXT_START := 0x81000000 +LOADER_DATA := +BOARD := +FLASH_OFFS := +FLASH_MAX := +PLATFORM := +CACHELINE_SIZE := 32 + +CC := $(CROSS_COMPILE)gcc +LD := $(CROSS_COMPILE)ld +OBJCOPY := $(CROSS_COMPILE)objcopy +OBJDUMP := $(CROSS_COMPILE)objdump + +BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \ + -R .MIPS.abiflags -S + +CFLAGS = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ + -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 \ + -mno-abicalls -fno-pic -ffunction-sections -pipe -mlong-calls \ + -fno-common -ffreestanding -fhonour-copts \ + -mabi=32 -march=mips32r2 \ + -Wa,-32 -Wa,-march=mips32r2 -Wa,-mips32r2 -Wa,--trap \ + -DCONFIG_CACHELINE_SIZE=$(CACHELINE_SIZE) \ + -DKERNEL_ADDR=$(KERNEL_ADDR) + +ASFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +LDFLAGS = -static --gc-sections -no-warn-mismatch +LDFLAGS += -e startup -T loader.lds -Ttext $(LZMA_TEXT_START) + +O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32) + +OBJECTS := head.o + +all: head.o loader.bin + +# Don't build dependencies, this may die if $(CC) isn't gcc +dep: + +install: + +%.o : %.c + $(CC) $(CFLAGS) -c -o $@ $< + +%.o : %.S + $(CC) $(ASFLAGS) -c -o $@ $< + +loader: $(OBJECTS) + $(LD) $(LDFLAGS) -o $@ $(OBJECTS) + +loader.bin: loader + $(OBJCOPY) $(BIN_FLAGS) $< $@ + +mrproper: clean + +clean: + rm -f loader *.elf *.bin *.o diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/cacheops.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/cacheops.h new file mode 100755 index 0000000..70bcad7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/cacheops.h @@ -0,0 +1,85 @@ +/* + * Cache operations for the cache instruction. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * (C) Copyright 1996, 97, 99, 2002, 03 Ralf Baechle + * (C) Copyright 1999 Silicon Graphics, Inc. + */ +#ifndef __ASM_CACHEOPS_H +#define __ASM_CACHEOPS_H + +/* + * Cache Operations available on all MIPS processors with R4000-style caches + */ +#define Index_Invalidate_I 0x00 +#define Index_Writeback_Inv_D 0x01 +#define Index_Load_Tag_I 0x04 +#define Index_Load_Tag_D 0x05 +#define Index_Store_Tag_I 0x08 +#define Index_Store_Tag_D 0x09 +#if defined(CONFIG_CPU_LOONGSON2) +#define Hit_Invalidate_I 0x00 +#else +#define Hit_Invalidate_I 0x10 +#endif +#define Hit_Invalidate_D 0x11 +#define Hit_Writeback_Inv_D 0x15 + +/* + * R4000-specific cacheops + */ +#define Create_Dirty_Excl_D 0x0d +#define Fill 0x14 +#define Hit_Writeback_I 0x18 +#define Hit_Writeback_D 0x19 + +/* + * R4000SC and R4400SC-specific cacheops + */ +#define Index_Invalidate_SI 0x02 +#define Index_Writeback_Inv_SD 0x03 +#define Index_Load_Tag_SI 0x06 +#define Index_Load_Tag_SD 0x07 +#define Index_Store_Tag_SI 0x0A +#define Index_Store_Tag_SD 0x0B +#define Create_Dirty_Excl_SD 0x0f +#define Hit_Invalidate_SI 0x12 +#define Hit_Invalidate_SD 0x13 +#define Hit_Writeback_Inv_SD 0x17 +#define Hit_Writeback_SD 0x1b +#define Hit_Set_Virtual_SI 0x1e +#define Hit_Set_Virtual_SD 0x1f + +/* + * R5000-specific cacheops + */ +#define R5K_Page_Invalidate_S 0x17 + +/* + * RM7000-specific cacheops + */ +#define Page_Invalidate_T 0x16 + +/* + * R10000-specific cacheops + * + * Cacheops 0x02, 0x06, 0x0a, 0x0c-0x0e, 0x16, 0x1a and 0x1e are unused. + * Most of the _S cacheops are identical to the R4000SC _SD cacheops. + */ +#define Index_Writeback_Inv_S 0x03 +#define Index_Load_Tag_S 0x07 +#define Index_Store_Tag_S 0x0B +#define Hit_Invalidate_S 0x13 +#define Cache_Barrier 0x14 +#define Hit_Writeback_Inv_S 0x17 +#define Index_Load_Data_I 0x18 +#define Index_Load_Data_D 0x19 +#define Index_Load_Data_S 0x1b +#define Index_Store_Data_I 0x1c +#define Index_Store_Data_D 0x1d +#define Index_Store_Data_S 0x1f + +#endif /* __ASM_CACHEOPS_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/cp0regdef.h b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/cp0regdef.h new file mode 100755 index 0000000..c1188ad --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/cp0regdef.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001 by Ralf Baechle + * + * Copyright (C) 2001, Monta Vista Software + * Author: jsun@mvista.com or jsun@junsun.net + */ +#ifndef _cp0regdef_h_ +#define _cp0regdef_h_ + +#define CP0_INDEX $0 +#define CP0_RANDOM $1 +#define CP0_ENTRYLO0 $2 +#define CP0_ENTRYLO1 $3 +#define CP0_CONTEXT $4 +#define CP0_PAGEMASK $5 +#define CP0_WIRED $6 +#define CP0_BADVADDR $8 +#define CP0_COUNT $9 +#define CP0_ENTRYHI $10 +#define CP0_COMPARE $11 +#define CP0_STATUS $12 +#define CP0_CAUSE $13 +#define CP0_EPC $14 +#define CP0_PRID $15 +#define CP0_CONFIG $16 +#define CP0_LLADDR $17 +#define CP0_WATCHLO $18 +#define CP0_WATCHHI $19 +#define CP0_XCONTEXT $20 +#define CP0_FRAMEMASK $21 +#define CP0_DIAGNOSTIC $22 +#define CP0_PERFORMANCE $25 +#define CP0_ECC $26 +#define CP0_CACHEERR $27 +#define CP0_TAGLO $28 +#define CP0_TAGHI $29 +#define CP0_ERROREPC $30 + +#endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/head.S b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/head.S new file mode 100755 index 0000000..58c336d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/head.S @@ -0,0 +1,159 @@ +/* + * Kernel relocation stub for MIPS devices + * + * Copyright (C) 2015 Felix Fietkau + * + * Based on: + * + * LZMA compressed kernel loader for Atheros AR7XXX/AR9XXX based boards + * + * Copyright (C) 2011 Gabor Juhos + * + * Some parts of this code was based on the OpenWrt specific lzma-loader + * for the BCM47xx and ADM5120 based boards: + * Copyright (C) 2004 Manuel Novoa III (mjn3@codepoet.org) + * Copyright (C) 2005 by Oleg I. Vdovikin + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include +#include +#include "cp0regdef.h" +#include "cacheops.h" + +#define KSEG0 0x80000000 + + .macro ehb + sll zero, 3 + .endm + + .macro reset + li t0, 0xbe000034 + lw t1, 0(t0) + ori t1, 1 + sw t1, 0(t0) + .endm + + .text + +LEAF(startup) + .set noreorder + .set mips32 + + .fill 0x10000 + + mtc0 zero, CP0_WATCHLO # clear watch registers + mtc0 zero, CP0_WATCHHI + mtc0 zero, CP0_CAUSE # clear before writing status register + + mfc0 t0, CP0_STATUS + li t1, 0x1000001f + or t0, t1 + xori t0, 0x1f + mtc0 t0, CP0_STATUS + ehb + + mtc0 zero, CP0_COUNT + mtc0 zero, CP0_COMPARE + ehb + + la t0, __reloc_label # get linked address of label + bal __reloc_label # branch and link to label to + nop # get actual address +__reloc_label: + subu t0, ra, t0 # get reloc_delta + + /* Copy our code to the right place */ + la t1, _code_start # get linked address of _code_start + la t2, _code_end # get linked address of _code_end + + addu t4, t2, t0 # calculate actual address of _code_end + lw t5, 0(t4) # get extra data size + + add t2, t5 + add t2, 4 + + add t0, t1 # calculate actual address of _code_start + +__reloc_copy: + lw t3, 0(t0) + sw t3, 0(t1) + add t1, 4 + blt t1, t2, __reloc_copy + add t0, 4 + + /* flush cache */ + la t0, _code_start + la t1, _code_end + + li t2, ~(CONFIG_CACHELINE_SIZE - 1) + and t0, t2 + and t1, t2 + li t2, CONFIG_CACHELINE_SIZE + + b __flush_check + nop + +__flush_line: + cache Hit_Writeback_Inv_D, 0(t0) + cache Hit_Invalidate_I, 0(t0) + add t0, t2 + +__flush_check: + bne t0, t1, __flush_line + nop + + sync + + la t0, __reloc_back + j t0 + nop + +__reloc_back: + la t0, _code_end + add t0, 4 + + addu t1, t0, t5 + + li t2, KERNEL_ADDR + +__kernel_copy: + lw t3, 0(t0) + sw t3, 0(t2) + add t0, 4 + blt t0, t1, __kernel_copy + add t2, 4 + + /* flush cache */ + li t0, KERNEL_ADDR + addu t1, t0, t5 + + add t1, CONFIG_CACHELINE_SIZE - 1 + li t2, ~(CONFIG_CACHELINE_SIZE - 1) + and t0, t2 + and t1, t2 + li t2, CONFIG_CACHELINE_SIZE + + b __kernel_flush_check + nop + +__kernel_flush_line: + cache Hit_Writeback_Inv_D, 0(t0) + cache Hit_Invalidate_I, 0(t0) + add t0, t2 + +__kernel_flush_check: + bne t0, t1, __kernel_flush_line + nop + + sync + + li t0, KERNEL_ADDR + jr t0 + nop + + .set reorder +END(startup) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/loader.lds b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/loader.lds new file mode 100755 index 0000000..98ca209 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/image/relocate/loader.lds @@ -0,0 +1,16 @@ +OUTPUT_ARCH(mips) +SECTIONS { + .text : { + _code_start = .; + *(.text) + *(.text.*) + *(.rodata) + *(.rodata.*) + *(.data) + *(.data.*) + } + + . = ALIGN(32); + + _code_end = .; +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/kernel-6.12 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/kernel-6.12 new file mode 100755 index 0000000..3b9c474 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/kernel-6.12 @@ -0,0 +1,2 @@ +LINUX_VERSION-6.12 = .74 +LINUX_KERNEL_HASH-6.12.74 = 3b56eeb1dc9a437f189ca56b823be3769994f59a4ea0895b08ec0d20acaca13e diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/other-files/init b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/other-files/init new file mode 100755 index 0000000..521655b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/other-files/init @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +export INITRAMFS=1 + +# switch to tmpfs to allow run daemons in jail on initramfs boot +DIRS=$(echo *) +NEW_ROOT=/new_root + +mkdir -p $NEW_ROOT +mount -t tmpfs tmpfs $NEW_ROOT + +cp -pr $DIRS $NEW_ROOT + +exec switch_root $NEW_ROOT /sbin/init diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/100-compiler.h-only-include-asm-rwonce.h-for-kernel-code.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/100-compiler.h-only-include-asm-rwonce.h-for-kernel-code.patch new file mode 100755 index 0000000..725e223 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/100-compiler.h-only-include-asm-rwonce.h-for-kernel-code.patch @@ -0,0 +1,29 @@ +From: Felix Fietkau +Date: Thu, 22 Oct 2020 22:00:03 +0200 +Subject: [PATCH] compiler.h: only include asm/rwonce.h for kernel code + +This header file is not in uapi, which makes any user space code that includes +linux/compiler.h to fail with the error 'asm/rwonce.h: No such file or directory' + +Fixes: e506ea451254 ("compiler.h: Split {READ,WRITE}_ONCE definitions out into rwonce.h") +Signed-off-by: Felix Fietkau +--- + +--- a/include/linux/compiler.h ++++ b/include/linux/compiler.h +@@ -191,6 +191,8 @@ void ftrace_likely_update(struct ftrace_ + __v; \ + }) + ++#include ++ + #endif /* __KERNEL__ */ + + /** +@@ -298,6 +300,4 @@ static inline void *offset_to_ptr(const + */ + #define prevent_tail_call_optimization() mb() + +-#include +- + #endif /* __LINUX_COMPILER_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/102-MIPS-only-process-negative-stack-offsets-on-stack-tr.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/102-MIPS-only-process-negative-stack-offsets-on-stack-tr.patch new file mode 100755 index 0000000..d79d03d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/102-MIPS-only-process-negative-stack-offsets-on-stack-tr.patch @@ -0,0 +1,57 @@ +From: Felix Fietkau +Date: Wed, 18 Apr 2018 10:50:05 +0200 +Subject: [PATCH] MIPS: only process negative stack offsets on stack traces + +Fixes endless back traces in cases where the compiler emits a stack +pointer increase in a branch delay slot (probably for some form of +function return). + +[ 3.475442] BUG: MAX_STACK_TRACE_ENTRIES too low! +[ 3.480070] turning off the locking correctness validator. +[ 3.485521] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.34 #0 +[ 3.491475] Stack : 00000000 00000000 00000000 00000000 80e0fce2 00000034 00000000 00000000 +[ 3.499764] 87c3838c 80696377 8061047c 00000000 00000001 00000001 87c2d850 6534689f +[ 3.508059] 00000000 00000000 80e10000 00000000 00000000 000000cf 0000000f 00000000 +[ 3.516353] 00000000 806a0000 00076891 00000000 00000000 00000000 ffffffff 00000000 +[ 3.524648] 806c0000 00000004 80e10000 806a0000 00000003 80690000 00000000 80700000 +[ 3.532942] ... +[ 3.535362] Call Trace: +[ 3.537818] [<80010a48>] show_stack+0x58/0x100 +[ 3.542207] [<804c2f78>] dump_stack+0xe8/0x170 +[ 3.546613] [<80079f90>] save_trace+0xf0/0x110 +[ 3.551010] [<8007b1ec>] mark_lock+0x33c/0x78c +[ 3.555413] [<8007bf48>] __lock_acquire+0x2ac/0x1a08 +[ 3.560337] [<8007de60>] lock_acquire+0x64/0x8c +[ 3.564846] [<804e1570>] _raw_spin_lock_irqsave+0x54/0x78 +[ 3.570186] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.574770] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.579257] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.583839] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.588329] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.592911] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.597401] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.601983] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.606473] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.611055] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.615545] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.620125] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.624619] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.629197] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.633691] [<801b618c>] kernfs_notify+0x94/0xac +[ 3.638269] [<801b7b10>] sysfs_notify+0x74/0xa0 +[ 3.642763] [<801b618c>] kernfs_notify+0x94/0xac + +Signed-off-by: Felix Fietkau +--- + +--- a/arch/mips/kernel/process.c ++++ b/arch/mips/kernel/process.c +@@ -395,6 +395,8 @@ static inline int is_sp_move_ins(union m + + if (ip->i_format.opcode == addiu_op || + ip->i_format.opcode == daddiu_op) { ++ if (ip->i_format.simmediate > 0) ++ return 0; + *frame_size = -ip->i_format.simmediate; + return 1; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/103-kbuild-export-SUBARCH.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/103-kbuild-export-SUBARCH.patch new file mode 100755 index 0000000..0cedbec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/103-kbuild-export-SUBARCH.patch @@ -0,0 +1,21 @@ +From 173019b66dcc9d68ad9333aa744dad1e369b5aa8 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Sun, 9 Jul 2017 00:26:53 +0200 +Subject: [PATCH 34/34] kernel: add compile fix for linux 4.9 on x86 + +Signed-off-by: Felix Fietkau +--- + Makefile | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -589,7 +589,7 @@ export RUSTC_BOOTSTRAP := 1 + # Allows finding `.clippy.toml` in out-of-srctree builds. + export CLIPPY_CONF_DIR := $(srctree) + +-export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC HOSTPKG_CONFIG ++export ARCH SRCARCH SUBARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC HOSTPKG_CONFIG + export RUSTC RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN + export HOSTRUSTC KBUILD_HOSTRUSTFLAGS + export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/111-watchdog-max63xx_wdt-Add-support-for-specifying-WDI-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/111-watchdog-max63xx_wdt-Add-support-for-specifying-WDI-.patch new file mode 100755 index 0000000..9dd90ee --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/111-watchdog-max63xx_wdt-Add-support-for-specifying-WDI-.patch @@ -0,0 +1,75 @@ +From bd1b9f66d5134e518419f4c4dacf1884c1616983 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pali=20Roh=C3=A1r?= +Date: Thu, 28 Apr 2022 11:13:23 +0200 +Subject: [PATCH] watchdog: max63xx_wdt: Add support for specifying WDI logic + via GPIO +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On some boards is WDI logic of max6370 chip connected via GPIO. +So extend max63xx_wdt driver to allow specifying WDI logic via GPIO. + +Signed-off-by: Pali RohΓ‘r +--- + drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +--- a/drivers/watchdog/max63xx_wdt.c ++++ b/drivers/watchdog/max63xx_wdt.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #define DEFAULT_HEARTBEAT 60 + #define MAX_HEARTBEAT 60 +@@ -50,6 +51,9 @@ struct max63xx_wdt { + void __iomem *base; + spinlock_t lock; + ++ /* GPIOs */ ++ struct gpio_desc *gpio_wdi; ++ + /* WDI and WSET bits write access routines */ + void (*ping)(struct max63xx_wdt *wdt); + void (*set)(struct max63xx_wdt *wdt, u8 set); +@@ -155,6 +159,17 @@ static const struct watchdog_info max63x + .identity = "max63xx Watchdog", + }; + ++static void max63xx_gpio_ping(struct max63xx_wdt *wdt) ++{ ++ spin_lock(&wdt->lock); ++ ++ gpiod_set_value(wdt->gpio_wdi, 1); ++ udelay(1); ++ gpiod_set_value(wdt->gpio_wdi, 0); ++ ++ spin_unlock(&wdt->lock); ++} ++ + static void max63xx_mmap_ping(struct max63xx_wdt *wdt) + { + u8 val; +@@ -222,10 +237,19 @@ static int max63xx_wdt_probe(struct plat + return -EINVAL; + } + ++ wdt->gpio_wdi = devm_gpiod_get(dev, NULL, GPIOD_FLAGS_BIT_DIR_OUT); ++ if (IS_ERR(wdt->gpio_wdi) && PTR_ERR(wdt->gpio_wdi) != -ENOENT) ++ return dev_err_probe(dev, PTR_ERR(wdt->gpio_wdi), ++ "unable to request gpio: %ld\n", ++ PTR_ERR(wdt->gpio_wdi)); ++ + err = max63xx_mmap_init(pdev, wdt); + if (err) + return err; + ++ if (!IS_ERR(wdt->gpio_wdi)) ++ wdt->ping = max63xx_gpio_ping; ++ + platform_set_drvdata(pdev, &wdt->wdd); + watchdog_set_drvdata(&wdt->wdd, wdt); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/140-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/140-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch new file mode 100755 index 0000000..b5cc52d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/140-jffs2-use-.rename2-and-add-RENAME_WHITEOUT-support.patch @@ -0,0 +1,81 @@ +From: Felix Fietkau +Subject: jffs2: use .rename2 and add RENAME_WHITEOUT support + +It is required for renames on overlayfs + +Signed-off-by: Felix Fietkau +--- + +--- a/fs/jffs2/dir.c ++++ b/fs/jffs2/dir.c +@@ -620,8 +620,8 @@ static int jffs2_rmdir (struct inode *di + return ret; + } + +-static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i, +- struct dentry *dentry, umode_t mode, dev_t rdev) ++static int __jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i, ++ struct dentry *dentry, umode_t mode, dev_t rdev, bool whiteout) + { + struct jffs2_inode_info *f, *dir_f; + struct jffs2_sb_info *c; +@@ -761,7 +761,11 @@ static int jffs2_mknod (struct mnt_idmap + mutex_unlock(&dir_f->sem); + jffs2_complete_reservation(c); + +- d_instantiate_new(dentry, inode); ++ if (!whiteout) ++ d_instantiate_new(dentry, inode); ++ else ++ unlock_new_inode(inode); ++ + return 0; + + fail: +@@ -769,6 +773,19 @@ static int jffs2_mknod (struct mnt_idmap + return ret; + } + ++static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i, ++ struct dentry *dentry, umode_t mode, dev_t rdev) ++{ ++ return __jffs2_mknod(idmap, dir_i, dentry, mode, rdev, false); ++} ++ ++static int jffs2_whiteout (struct mnt_idmap *idmap, struct inode *old_dir, ++ struct dentry *old_dentry) ++{ ++ return __jffs2_mknod(idmap, old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, ++ WHITEOUT_DEV, true); ++} ++ + static int jffs2_rename (struct mnt_idmap *idmap, + struct inode *old_dir_i, struct dentry *old_dentry, + struct inode *new_dir_i, struct dentry *new_dentry, +@@ -780,7 +797,7 @@ static int jffs2_rename (struct mnt_idma + uint8_t type; + uint32_t now; + +- if (flags & ~RENAME_NOREPLACE) ++ if (flags & ~(RENAME_NOREPLACE|RENAME_WHITEOUT)) + return -EINVAL; + + /* The VFS will check for us and prevent trying to rename a +@@ -846,9 +863,14 @@ static int jffs2_rename (struct mnt_idma + if (d_is_dir(old_dentry) && !victim_f) + inc_nlink(new_dir_i); + +- /* Unlink the original */ +- ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), +- old_dentry->d_name.name, old_dentry->d_name.len, NULL, now); ++ if (flags & RENAME_WHITEOUT) ++ /* Replace with whiteout */ ++ ret = jffs2_whiteout(idmap, old_dir_i, old_dentry); ++ else ++ /* Unlink the original */ ++ ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), ++ old_dentry->d_name.name, ++ old_dentry->d_name.len, NULL, now); + + /* We don't touch inode->i_nlink */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/141-jffs2-add-RENAME_EXCHANGE-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/141-jffs2-add-RENAME_EXCHANGE-support.patch new file mode 100755 index 0000000..44ba3bd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/141-jffs2-add-RENAME_EXCHANGE-support.patch @@ -0,0 +1,73 @@ +From: Felix Fietkau +Subject: jffs2: add RENAME_EXCHANGE support + +Signed-off-by: Felix Fietkau +--- + +--- a/fs/jffs2/dir.c ++++ b/fs/jffs2/dir.c +@@ -794,18 +794,31 @@ static int jffs2_rename (struct mnt_idma + int ret; + struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb); + struct jffs2_inode_info *victim_f = NULL; ++ struct inode *fst_inode = d_inode(old_dentry); ++ struct inode *snd_inode = d_inode(new_dentry); + uint8_t type; + uint32_t now; + +- if (flags & ~(RENAME_NOREPLACE|RENAME_WHITEOUT)) ++ if (flags & ~(RENAME_NOREPLACE|RENAME_WHITEOUT|RENAME_EXCHANGE)) + return -EINVAL; + ++ if ((flags & RENAME_EXCHANGE) && (old_dir_i != new_dir_i)) { ++ if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) { ++ inc_nlink(new_dir_i); ++ drop_nlink(old_dir_i); ++ } ++ else if (!S_ISDIR(fst_inode->i_mode) && S_ISDIR(snd_inode->i_mode)) { ++ drop_nlink(new_dir_i); ++ inc_nlink(old_dir_i); ++ } ++ } ++ + /* The VFS will check for us and prevent trying to rename a + * file over a directory and vice versa, but if it's a directory, + * the VFS can't check whether the victim is empty. The filesystem + * needs to do that for itself. + */ +- if (d_really_is_positive(new_dentry)) { ++ if (d_really_is_positive(new_dentry) && !(flags & RENAME_EXCHANGE)) { + victim_f = JFFS2_INODE_INFO(d_inode(new_dentry)); + if (d_is_dir(new_dentry)) { + struct jffs2_full_dirent *fd; +@@ -840,7 +853,7 @@ static int jffs2_rename (struct mnt_idma + if (ret) + return ret; + +- if (victim_f) { ++ if (victim_f && !(flags & RENAME_EXCHANGE)) { + /* There was a victim. Kill it off nicely */ + if (d_is_dir(new_dentry)) + clear_nlink(d_inode(new_dentry)); +@@ -866,6 +879,12 @@ static int jffs2_rename (struct mnt_idma + if (flags & RENAME_WHITEOUT) + /* Replace with whiteout */ + ret = jffs2_whiteout(idmap, old_dir_i, old_dentry); ++ else if (flags & RENAME_EXCHANGE) ++ /* Replace the original */ ++ ret = jffs2_do_link(c, JFFS2_INODE_INFO(old_dir_i), ++ d_inode(new_dentry)->i_ino, type, ++ old_dentry->d_name.name, old_dentry->d_name.len, ++ now); + else + /* Unlink the original */ + ret = jffs2_do_unlink(c, JFFS2_INODE_INFO(old_dir_i), +@@ -898,7 +917,7 @@ static int jffs2_rename (struct mnt_idma + return ret; + } + +- if (d_is_dir(old_dentry)) ++ if (d_is_dir(old_dentry) && !(flags & RENAME_EXCHANGE)) + drop_nlink(old_dir_i); + + inode_set_mtime_to_ts(old_dir_i, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/142-jffs2-add-splice-ops.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/142-jffs2-add-splice-ops.patch new file mode 100755 index 0000000..ea57158 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/142-jffs2-add-splice-ops.patch @@ -0,0 +1,20 @@ +From: Felix Fietkau +Subject: jffs2: add splice ops + +Add splice_read using generic_file_splice_read. +Add splice_write using iter_file_splice_write + +Signed-off-by: Felix Fietkau +--- + +--- a/fs/jffs2/file.c ++++ b/fs/jffs2/file.c +@@ -53,6 +53,8 @@ const struct file_operations jffs2_file_ + .open = generic_file_open, + .read_iter = generic_file_read_iter, + .write_iter = generic_file_write_iter, ++ .splice_read = filemap_splice_read, ++ .splice_write = iter_file_splice_write, + .unlocked_ioctl=jffs2_ioctl, + .mmap = generic_file_readonly_mmap, + .fsync = jffs2_fsync, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/150-bridge_allow_receiption_on_disabled_port.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/150-bridge_allow_receiption_on_disabled_port.patch new file mode 100755 index 0000000..530f2c3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/150-bridge_allow_receiption_on_disabled_port.patch @@ -0,0 +1,45 @@ +From: Stephen Hemminger +Subject: bridge: allow receiption on disabled port + +When an ethernet device is enslaved to a bridge, and the bridge STP +detects loss of carrier (or operational state down), then normally +packet receiption is blocked. + +This breaks control applications like WPA which maybe expecting to +receive packets to negotiate to bring link up. The bridge needs to +block forwarding packets from these disabled ports, but there is no +hard requirement to not allow local packet delivery. + +Signed-off-by: Stephen Hemminger +Signed-off-by: Felix Fietkau + +--- a/net/bridge/br_input.c ++++ b/net/bridge/br_input.c +@@ -245,6 +245,9 @@ static void __br_handle_local_finish(str + /* note: already called with rcu_read_lock */ + static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb) + { ++ struct net_bridge_port *p = br_port_get_rcu(skb->dev); ++ ++ if (p->state != BR_STATE_DISABLED) + __br_handle_local_finish(skb); + + /* return 1 to signal the okfn() was called so it's ok to use the skb */ +@@ -416,6 +419,17 @@ forward: + goto defer_stp_filtering; + + switch (p->state) { ++ case BR_STATE_DISABLED: ++ if (ether_addr_equal(p->br->dev->dev_addr, dest)) ++ skb->pkt_type = PACKET_HOST; ++ ++ if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, ++ dev_net(skb->dev), NULL, skb, skb->dev, NULL, ++ br_handle_local_finish) == 1) { ++ return RX_HANDLER_PASS; ++ } ++ break; ++ + case BR_STATE_FORWARDING: + case BR_STATE_LEARNING: + defer_stp_filtering: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/151-net-bridge-do-not-send-arp-replies-if-src-and-target.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/151-net-bridge-do-not-send-arp-replies-if-src-and-target.patch new file mode 100755 index 0000000..3abeaca --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/151-net-bridge-do-not-send-arp-replies-if-src-and-target.patch @@ -0,0 +1,37 @@ +From: Felix Fietkau +Date: Thu, 4 Jan 2024 15:21:21 +0100 +Subject: [PATCH] net: bridge: do not send arp replies if src and target hw + addr is the same + +There are broken devices in the wild that handle duplicate IP address +detection by sending out ARP requests for the IP that they received from a +DHCP server and refuse the address if they get a reply. +When proxyarp is enabled, they would go into a loop of requesting an address +and then NAKing it again. + +Link: https://github.com/openwrt/openwrt/issues/14309 +Signed-off-by: Felix Fietkau +--- + +--- a/net/bridge/br_arp_nd_proxy.c ++++ b/net/bridge/br_arp_nd_proxy.c +@@ -204,7 +204,10 @@ void br_do_proxy_suppress_arp(struct sk_ + if ((p && (p->flags & BR_PROXYARP)) || + (f->dst && (f->dst->flags & BR_PROXYARP_WIFI)) || + br_is_neigh_suppress_enabled(f->dst, vid)) { +- if (!vid) ++ replied = true; ++ if (!memcmp(n->ha, sha, dev->addr_len)) ++ replied = false; ++ else if (!vid) + br_arp_send(br, p, skb->dev, sip, tip, + sha, n->ha, sha, 0, 0); + else +@@ -212,7 +215,6 @@ void br_do_proxy_suppress_arp(struct sk_ + sha, n->ha, sha, + skb->vlan_proto, + skb_vlan_tag_get(skb)); +- replied = true; + } + + /* If we have replied or as long as we know the diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/190-rtc-rs5c372-support_alarms_up_to_1_week.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/190-rtc-rs5c372-support_alarms_up_to_1_week.patch new file mode 100755 index 0000000..2f5c222 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/190-rtc-rs5c372-support_alarms_up_to_1_week.patch @@ -0,0 +1,94 @@ +From: Daniel GonzΓ‘lez Cabanelas +Subject: [PATCH 1/2] rtc: rs5c372: support alarms up to 1 week + +The Ricoh R2221x, R2223x, RS5C372, RV5C387A chips can handle 1 week +alarms. + +Read the "wday" alarm register and convert it to a date to support up 1 +week in our driver. + +Signed-off-by: Daniel GonzΓ‘lez Cabanelas +--- + drivers/rtc/rtc-rs5c372.c | 48 ++++++++++++++++++++++++++++++++++----- + 1 file changed, 42 insertions(+), 6 deletions(-) + +--- a/drivers/rtc/rtc-rs5c372.c ++++ b/drivers/rtc/rtc-rs5c372.c +@@ -399,7 +399,9 @@ static int rs5c_read_alarm(struct device + { + struct i2c_client *client = to_i2c_client(dev); + struct rs5c372 *rs5c = i2c_get_clientdata(client); +- int status; ++ int status, wday_offs; ++ struct rtc_time rtc; ++ unsigned long alarm_secs; + + status = rs5c_get_regs(rs5c); + if (status < 0) +@@ -409,6 +411,30 @@ static int rs5c_read_alarm(struct device + t->time.tm_sec = 0; + t->time.tm_min = bcd2bin(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f); + t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]); ++ t->time.tm_wday = ffs(rs5c->regs[RS5C_REG_ALARM_A_WDAY] & 0x7f) - 1; ++ ++ /* determine the day, month and year based on alarm wday, taking as a ++ * reference the current time from the rtc ++ */ ++ status = rs5c372_rtc_read_time(dev, &rtc); ++ if (status < 0) ++ return status; ++ ++ wday_offs = t->time.tm_wday - rtc.tm_wday; ++ alarm_secs = mktime64(rtc.tm_year + 1900, ++ rtc.tm_mon + 1, ++ rtc.tm_mday + wday_offs, ++ t->time.tm_hour, ++ t->time.tm_min, ++ t->time.tm_sec); ++ ++ if (wday_offs < 0 || (wday_offs == 0 && ++ (t->time.tm_hour < rtc.tm_hour || ++ (t->time.tm_hour == rtc.tm_hour && ++ t->time.tm_min <= rtc.tm_min)))) ++ alarm_secs += 7 * 86400; ++ ++ rtc_time64_to_tm(alarm_secs, &t->time); + + /* ... and status */ + t->enabled = !!(rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE); +@@ -423,12 +449,20 @@ static int rs5c_set_alarm(struct device + struct rs5c372 *rs5c = i2c_get_clientdata(client); + int status, addr, i; + unsigned char buf[3]; ++ struct rtc_time rtc_tm; ++ unsigned long rtc_secs, alarm_secs; + +- /* only handle up to 24 hours in the future, like RTC_ALM_SET */ +- if (t->time.tm_mday != -1 +- || t->time.tm_mon != -1 +- || t->time.tm_year != -1) ++ /* chip only can handle alarms up to one week in the future*/ ++ status = rs5c372_rtc_read_time(dev, &rtc_tm); ++ if (status) ++ return status; ++ rtc_secs = rtc_tm_to_time64(&rtc_tm); ++ alarm_secs = rtc_tm_to_time64(&t->time); ++ if (alarm_secs >= rtc_secs + 7 * 86400) { ++ dev_err(dev, "%s: alarm maximum is one week in the future (%d)\n", ++ __func__, status); + return -EINVAL; ++ } + + /* REVISIT: round up tm_sec */ + +@@ -449,7 +483,9 @@ static int rs5c_set_alarm(struct device + /* set alarm */ + buf[0] = bin2bcd(t->time.tm_min); + buf[1] = rs5c_hr2reg(rs5c, t->time.tm_hour); +- buf[2] = 0x7f; /* any/all days */ ++ /* each bit is the day of the week, 0x7f means all days */ ++ buf[2] = (t->time.tm_wday >= 0 && t->time.tm_wday < 7) ? ++ BIT(t->time.tm_wday) : 0x7f; + + for (i = 0; i < sizeof(buf); i++) { + addr = RS5C_ADDR(RS5C_REG_ALARM_A_MIN + i); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/191-rtc-rs5c372-let_the_alarm_to_be_used_as_wakeup_source.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/191-rtc-rs5c372-let_the_alarm_to_be_used_as_wakeup_source.patch new file mode 100755 index 0000000..a29c548 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/191-rtc-rs5c372-let_the_alarm_to_be_used_as_wakeup_source.patch @@ -0,0 +1,71 @@ +From: Daniel GonzΓ‘lez Cabanelas +Subject: [PATCH 2/2] rtc: rs5c372: let the alarm to be used as wakeup source + +Currently there is no use for the interrupts on the rs5c372 RTC and the +wakealarm isn't enabled. There are some devices like NASes which use this +RTC to wake up from the power off state when the INTR pin is activated by +the alarm clock. + +Enable the alarm and let to be used as a wakeup source. + +Tested on a Buffalo LS421DE NAS. + +Signed-off-by: Daniel GonzΓ‘lez Cabanelas +--- + drivers/rtc/rtc-rs5c372.c | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +--- a/drivers/rtc/rtc-rs5c372.c ++++ b/drivers/rtc/rtc-rs5c372.c +@@ -832,6 +832,7 @@ static int rs5c372_probe(struct i2c_clie + int err = 0; + int smbus_mode = 0; + struct rs5c372 *rs5c372; ++ bool rs5c372_can_wakeup_device = false; + + dev_dbg(&client->dev, "%s\n", __func__); + +@@ -868,6 +869,12 @@ static int rs5c372_probe(struct i2c_clie + rs5c372->type = id->driver_data; + } + ++#ifdef CONFIG_OF ++ if(of_property_read_bool(client->dev.of_node, ++ "wakeup-source")) ++ rs5c372_can_wakeup_device = true; ++#endif ++ + /* we read registers 0x0f then 0x00-0x0f; skip the first one */ + rs5c372->regs = &rs5c372->buf[1]; + rs5c372->smbus = smbus_mode; +@@ -901,6 +908,8 @@ static int rs5c372_probe(struct i2c_clie + goto exit; + } + ++ rs5c372->has_irq = 1; ++ + /* if the oscillator lost power and no other software (like + * the bootloader) set it up, do it here. + * +@@ -927,6 +936,10 @@ static int rs5c372_probe(struct i2c_clie + ); + + /* REVISIT use client->irq to register alarm irq ... */ ++ if (rs5c372_can_wakeup_device) { ++ device_init_wakeup(&client->dev, true); ++ } ++ + rs5c372->rtc = devm_rtc_device_register(&client->dev, + rs5c372_driver.driver.name, + &rs5c372_rtc_ops, THIS_MODULE); +@@ -940,6 +953,10 @@ static int rs5c372_probe(struct i2c_clie + if (err) + goto exit; + ++ /* the rs5c372 alarm only supports a minute accuracy */ ++ set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rs5c372->rtc->features); ++ clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rs5c372->rtc->features); ++ + return 0; + + exit: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/200-ARM-9404-1-arm32-fix-boot-hang-with-HAVE_LD_DEAD_COD.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/200-ARM-9404-1-arm32-fix-boot-hang-with-HAVE_LD_DEAD_COD.patch new file mode 100755 index 0000000..f36b118 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/200-ARM-9404-1-arm32-fix-boot-hang-with-HAVE_LD_DEAD_COD.patch @@ -0,0 +1,79 @@ +From cf3d39cfd29ab7bcbd6aa79d4a2f132817969e3d Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 15 Apr 2025 23:16:40 +0200 +Subject: [PATCH] ARM: 9404/1: arm32: fix boot hang with + HAVE_LD_DEAD_CODE_DATA_ELIMINATION + +It was reported that some SoC (mvebu based for example) hang on kernel +loading. A variant of the feature was present in OpenWrt from long ago +and adding the additional entry with KEEP, fix the problem. + +Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION") +Signed-off-by: Christian Marangi +--- + arch/arm/include/asm/vmlinux.lds.h | 10 +++++----- + arch/arm/kernel/vmlinux.lds.S | 4 ++-- + 2 files changed, 7 insertions(+), 7 deletions(-) + +--- a/arch/arm/include/asm/vmlinux.lds.h ++++ b/arch/arm/include/asm/vmlinux.lds.h +@@ -54,7 +54,7 @@ + #define IDMAP_TEXT \ + ALIGN_FUNCTION(); \ + __idmap_text_start = .; \ +- *(.idmap.text) \ ++ KEEP(*(.idmap.text)) \ + __idmap_text_end = .; \ + + #define ARM_DISCARD \ +@@ -114,12 +114,12 @@ + . = ALIGN(8); \ + .ARM.unwind_idx : { \ + __start_unwind_idx = .; \ +- *(.ARM.exidx*) \ ++ KEEP(*(.ARM.exidx*)) \ + __stop_unwind_idx = .; \ + } \ + .ARM.unwind_tab : { \ + __start_unwind_tab = .; \ +- *(.ARM.extab*) \ ++ KEEP(*(.ARM.extab*)) \ + __stop_unwind_tab = .; \ + } + +@@ -131,7 +131,7 @@ + __vectors_lma = .; \ + OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) { \ + .vectors { \ +- OVERLAY_KEEP(*(.vectors)) \ ++ KEEP(*(.vectors)) \ + } \ + .vectors.bhb.loop8 { \ + OVERLAY_KEEP(*(.vectors.bhb.loop8)) \ +@@ -149,7 +149,7 @@ + \ + __stubs_lma = .; \ + .stubs ADDR(.vectors) + 0x1000 : AT(__stubs_lma) { \ +- *(.stubs) \ ++ KEEP(*(.stubs)) \ + } \ + ARM_LMA(__stubs, .stubs); \ + . = __stubs_lma + SIZEOF(.stubs); \ +--- a/arch/arm/kernel/vmlinux.lds.S ++++ b/arch/arm/kernel/vmlinux.lds.S +@@ -104,13 +104,13 @@ SECTIONS + } + .init.tagtable : { + __tagtable_begin = .; +- *(.taglist.init) ++ KEEP(*(.taglist.init)) + __tagtable_end = .; + } + #ifdef CONFIG_SMP_ON_UP + .init.smpalt : { + __smpalt_begin = .; +- *(.alt.smp.init) ++ KEEP(*(.alt.smp.init)) + __smpalt_end = .; + } + #endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/203-kallsyms_uncompressed.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/203-kallsyms_uncompressed.patch new file mode 100755 index 0000000..40de8f6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/203-kallsyms_uncompressed.patch @@ -0,0 +1,183 @@ +From: Felix Fietkau +Subject: kernel: add a config option for keeping the kallsyms table uncompressed, saving ~9kb kernel size after lzma on ar71xx + +[john@phrozen.org: added to my upstream queue 30.12.2016] +lede-commit: e0e3509b5ce2ccf93d4d67ea907613f5f7ec2eed +Signed-off-by: Felix Fietkau +--- + init/Kconfig | 11 +++++++++++ + kernel/kallsyms.c | 8 ++++++++ + kernel/vmcore_info.c | 2 ++ + scripts/kallsyms.c | 12 ++++++++++++ + scripts/link-vmlinux.sh | 4 ++++ + 5 files changed, 37 insertions(+) + +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -1534,6 +1534,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW + the unaligned access emulation. + see arch/parisc/kernel/unaligned.c for reference + ++config KALLSYMS_UNCOMPRESSED ++ bool "Keep kallsyms uncompressed" ++ depends on KALLSYMS ++ help ++ Normally kallsyms contains compressed symbols (using a token table), ++ reducing the uncompressed kernel image size. Keeping the symbol table ++ uncompressed significantly improves the size of this part in compressed ++ kernel images. ++ ++ Say N unless you need compressed kernel images to be small. ++ + config HAVE_PCSPKR_PLATFORM + bool + +--- a/kernel/kallsyms.c ++++ b/kernel/kallsyms.c +@@ -69,6 +69,11 @@ static unsigned int kallsyms_expand_symb + * For every byte on the compressed symbol data, copy the table + * entry for that byte. + */ ++#ifdef CONFIG_KALLSYMS_UNCOMPRESSED ++ memcpy(result, data + 1, len - 1); ++ result += len - 1; ++ len = 0; ++#endif + while (len) { + tptr = &kallsyms_token_table[kallsyms_token_index[*data]]; + data++; +@@ -101,6 +106,9 @@ tail: + */ + static char kallsyms_get_symbol_type(unsigned int off) + { ++#ifdef CONFIG_KALLSYMS_UNCOMPRESSED ++ return kallsyms_names[off + 1]; ++#endif + /* + * Get just the first code, look it up in the token table, + * and return the first char from this token. If MSB of length +--- a/kernel/vmcore_info.c ++++ b/kernel/vmcore_info.c +@@ -214,8 +214,10 @@ static int __init crash_save_vmcoreinfo_ + #ifdef CONFIG_KALLSYMS + VMCOREINFO_SYMBOL(kallsyms_names); + VMCOREINFO_SYMBOL(kallsyms_num_syms); ++#ifndef CONFIG_KALLSYMS_UNCOMPRESSED + VMCOREINFO_SYMBOL(kallsyms_token_table); + VMCOREINFO_SYMBOL(kallsyms_token_index); ++#endif + VMCOREINFO_SYMBOL(kallsyms_offsets); + VMCOREINFO_SYMBOL(kallsyms_relative_base); + #endif /* CONFIG_KALLSYMS */ +--- a/scripts/kallsyms.c ++++ b/scripts/kallsyms.c +@@ -62,6 +62,7 @@ static struct addr_range percpu_range = + static struct sym_entry **table; + static unsigned int table_size, table_cnt; + static int all_symbols; ++static int uncompressed; + static int absolute_percpu; + + static int token_profit[0x10000]; +@@ -412,13 +413,17 @@ static void write_src(void) + for (k = 0; k < table[i]->len; k++) + printf(", 0x%02x", table[i]->sym[k]); + +- /* +- * Now that we wrote out the compressed symbol name, restore the +- * original name and print it in the comment. +- */ +- expand_symbol(table[i]->sym, table[i]->len, buf); +- strcpy((char *)table[i]->sym, buf); +- printf("\t/* %s */\n", table[i]->sym); ++ if (!uncompressed) { ++ /* ++ * Now that we wrote out the compressed symbol name, restore the ++ * original name and print it in the comment. ++ */ ++ expand_symbol(table[i]->sym, table[i]->len, buf); ++ strcpy((char *)table[i]->sym, buf); ++ printf("\t/* %s */\n", table[i]->sym); ++ } else { ++ printf("\n"); ++ } + } + printf("\n"); + +@@ -429,20 +434,22 @@ static void write_src(void) + + free(markers); + +- output_label("kallsyms_token_table"); +- off = 0; +- for (i = 0; i < 256; i++) { +- best_idx[i] = off; +- expand_symbol(best_table[i], best_table_len[i], buf); +- printf("\t.asciz\t\"%s\"\n", buf); +- off += strlen(buf) + 1; ++ if (!uncompressed) { ++ output_label("kallsyms_token_table"); ++ off = 0; ++ for (i = 0; i < 256; i++) { ++ best_idx[i] = off; ++ expand_symbol(best_table[i], best_table_len[i], buf); ++ printf("\t.asciz\t\"%s\"\n", buf); ++ off += strlen(buf) + 1; ++ } ++ printf("\n"); ++ ++ output_label("kallsyms_token_index"); ++ for (i = 0; i < 256; i++) ++ printf("\t.short\t%d\n", best_idx[i]); ++ printf("\n"); + } +- printf("\n"); +- +- output_label("kallsyms_token_index"); +- for (i = 0; i < 256; i++) +- printf("\t.short\t%d\n", best_idx[i]); +- printf("\n"); + + output_label("kallsyms_offsets"); + +@@ -532,6 +539,9 @@ static unsigned char *find_token(unsigne + { + int i; + ++ if (uncompressed) ++ return NULL; ++ + for (i = 0; i < len - 1; i++) { + if (str[i] == token[0] && str[i+1] == token[1]) + return &str[i]; +@@ -604,6 +614,9 @@ static void optimize_result(void) + { + int i, best; + ++ if (uncompressed) ++ return; ++ + /* using the '\0' symbol last allows compress_symbols to use standard + * fast string functions */ + for (i = 255; i >= 0; i--) { +@@ -763,6 +776,7 @@ int main(int argc, char **argv) + static const struct option long_options[] = { + {"all-symbols", no_argument, &all_symbols, 1}, + {"absolute-percpu", no_argument, &absolute_percpu, 1}, ++ {"uncompressed", no_argument, &uncompressed, 1}, + {}, + }; + +--- a/scripts/link-vmlinux.sh ++++ b/scripts/link-vmlinux.sh +@@ -144,6 +144,10 @@ kallsyms() + kallsymopt="${kallsymopt} --absolute-percpu" + fi + ++ if is_enabled CONFIG_KALLSYMS_UNCOMPRESSED; then ++ kallsymopt="${kallsymopt} --uncompressed" ++ fi ++ + info KSYMS "${2}.S" + scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S" + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/205-backtrace_module_info.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/205-backtrace_module_info.patch new file mode 100755 index 0000000..de9f860 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/205-backtrace_module_info.patch @@ -0,0 +1,48 @@ +From: Felix Fietkau +Subject: kernel: when KALLSYMS is disabled, print module address + size for matching backtrace entries + +[john@phrozen.org: felix will add this to his upstream queue] + +dmitrmax@gmail.com: fixed FTB when CONFIG_MODULES=n + +lede-commit 53827cdc824556cda910b23ce5030c363b8f1461 +Signed-off-by: Felix Fietkau +Signed-off-by: Maksim Dmitrichenko +--- + lib/vsprintf.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +--- a/lib/vsprintf.c ++++ b/lib/vsprintf.c +@@ -983,8 +983,12 @@ char *symbol_string(char *buf, char *end + struct printf_spec spec, const char *fmt) + { + unsigned long value; +-#ifdef CONFIG_KALLSYMS + char sym[KSYM_SYMBOL_LEN]; ++#ifndef CONFIG_KALLSYMS ++#ifdef CONFIG_MODULES ++ struct module *mod; ++#endif ++ int len; + #endif + + if (fmt[1] == 'R') +@@ -1005,8 +1009,16 @@ char *symbol_string(char *buf, char *end + + return string_nocheck(buf, end, sym, spec); + #else +- return special_hex_number(buf, end, value, sizeof(void *)); ++ len = snprintf(sym, sizeof(sym), "0x%lx", value); ++#ifdef CONFIG_MODULES ++ mod = __module_address(value); ++ if (mod) ++ snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]", ++ mod->name, mod->mem[MOD_TEXT].base, ++ mod->mem[MOD_TEXT].size); ++#endif + #endif ++ return string(buf, end, sym, spec); + } + + static const struct printf_spec default_str_spec = { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/240-remove-unsane-filenames-from-deps_initramfs-list.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/240-remove-unsane-filenames-from-deps_initramfs-list.patch new file mode 100755 index 0000000..9e78284 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/240-remove-unsane-filenames-from-deps_initramfs-list.patch @@ -0,0 +1,30 @@ +From: Gabor Juhos +Subject: usr: sanitize deps_initramfs list + +If any filename in the intramfs dependency +list contains a colon, that causes a kernel +build error like this: + +/devel/openwrt/build_dir/linux-ar71xx_generic/linux-3.6.6/usr/Makefile:58: *** multiple target patterns. Stop. +make[5]: *** [usr] Error 2 + +Fix it by removing such filenames from the +deps_initramfs list. + +Signed-off-by: Gabor Juhos +Signed-off-by: Felix Fietkau +--- + usr/Makefile | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/usr/Makefile ++++ b/usr/Makefile +@@ -56,6 +56,8 @@ hostprogs := gen_init_cpio + # The dependency list is generated by gen_initramfs.sh -l + -include $(obj)/.initramfs_data.cpio.d + ++deps_initramfs := $(foreach v,$(deps_initramfs),$(if $(findstring :,$(v)),,$(v))) ++ + # do not try to update files included in initramfs + $(deps_initramfs): ; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/250-kernel-fork-Increase-minimum-number-of-allowed-threa.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/250-kernel-fork-Increase-minimum-number-of-allowed-threa.patch new file mode 100755 index 0000000..5255a9c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/250-kernel-fork-Increase-minimum-number-of-allowed-threa.patch @@ -0,0 +1,37 @@ +From a22c4c7bbfad3e93e717e16f6faf343259add27a Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Fri, 27 Jun 2025 11:09:04 +0100 +Subject: [PATCH v2] kernel/fork: Increase minimum number of allowed threads + +A modern Linux system creates much more than 20 threads at bootup. +When I booted up OpenWrt in qemu the system sometimes failed to boot up +when it wanted to create the 419th thread. The VM had 128MB RAM and the +calculation in set_max_threads() calculated that max_threads should be +set to 419. When the system booted up it tried to notify the user space +about every device it created because CONFIG_UEVENT_HELPER was set and +used. I counted 1299 calls to call_usermodehelper_setup(), all of +them try to create a new thread and call the userspace hotplug script in +it. + +This fixes bootup of Linux on systems with low memory. + +I saw the problem with qemu 10.0.2 using these commands: +qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic + +Cc: stable@vger.kernel.org +Signed-off-by: Hauke Mehrtens +--- + kernel/fork.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/kernel/fork.c ++++ b/kernel/fork.c +@@ -123,7 +123,7 @@ + /* + * Minimum number of threads to boot the kernel + */ +-#define MIN_THREADS 20 ++#define MIN_THREADS 600 + + /* + * Maximum number of threads diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/270-platform-mikrotik-build-bits.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/270-platform-mikrotik-build-bits.patch new file mode 100755 index 0000000..772d9fe --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/270-platform-mikrotik-build-bits.patch @@ -0,0 +1,31 @@ +From c2deb5ef01a0ef09088832744cbace9e239a6ee0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= +Date: Sat, 28 Mar 2020 12:11:50 +0100 +Subject: [PATCH] generic: platform/mikrotik build bits (5.4) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch adds platform/mikrotik kernel build bits + +Signed-off-by: Thibaut VARÈNE +--- + drivers/platform/Kconfig | 2 ++ + drivers/platform/Makefile | 1 + + 2 files changed, 3 insertions(+) + +--- a/drivers/platform/Kconfig ++++ b/drivers/platform/Kconfig +@@ -18,3 +18,5 @@ source "drivers/platform/surface/Kconfig + source "drivers/platform/x86/Kconfig" + + source "drivers/platform/arm64/Kconfig" ++ ++source "drivers/platform/mikrotik/Kconfig" +--- a/drivers/platform/Makefile ++++ b/drivers/platform/Makefile +@@ -13,3 +13,4 @@ obj-$(CONFIG_CHROME_PLATFORMS) += chrome + obj-$(CONFIG_CZNIC_PLATFORMS) += cznic/ + obj-$(CONFIG_SURFACE_PLATFORMS) += surface/ + obj-$(CONFIG_ARM64_PLATFORM_DEVICES) += arm64/ ++obj-$(CONFIG_MIKROTIK) += mikrotik/ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/300-mips_expose_boot_raw.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/300-mips_expose_boot_raw.patch new file mode 100755 index 0000000..ca8d010 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/300-mips_expose_boot_raw.patch @@ -0,0 +1,40 @@ +From: Mark Miller +Subject: mips: expose CONFIG_BOOT_RAW + +This exposes the CONFIG_BOOT_RAW symbol in Kconfig. This is needed on +certain Broadcom chipsets running CFE in order to load the kernel. + +Signed-off-by: Mark Miller +Acked-by: Rob Landley +--- +--- a/arch/mips/Kconfig ++++ b/arch/mips/Kconfig +@@ -1055,9 +1055,6 @@ config FW_ARC + config ARCH_MAY_HAVE_PC_FDC + bool + +-config BOOT_RAW +- bool +- + config CEVT_BCM1480 + bool + +@@ -2990,6 +2987,18 @@ choice + bool "Extend builtin kernel arguments with bootloader arguments" + endchoice + ++config BOOT_RAW ++ bool "Enable the kernel to be executed from the load address" ++ default n ++ help ++ Allow the kernel to be executed from the load address for ++ bootloaders which cannot read the ELF format. This places ++ a jump to start_kernel at the load address. ++ ++ If unsure, say N. ++ ++ ++ + endmenu + + config LOCKDEP_SUPPORT diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/301-MIPS-Add-barriers-between-dcache-icache-flushes.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/301-MIPS-Add-barriers-between-dcache-icache-flushes.patch new file mode 100755 index 0000000..b3cb5f0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/301-MIPS-Add-barriers-between-dcache-icache-flushes.patch @@ -0,0 +1,71 @@ +From e6e6ef4275978823ec3a84133fc91f4ffbef5c84 Mon Sep 17 00:00:00 2001 +From: Paul Burton +Date: Mon, 22 Feb 2016 18:09:44 +0000 +Subject: [PATCH] MIPS: Add barriers between dcache & icache flushes + +Index-based cache operations may be arbitrarily reordered by out of +order CPUs. Thus code which writes back the dcache & then invalidates +the icache using indexed cache ops must include a barrier between +operating on the 2 caches in order to prevent the scenario in which: + + - icache invalidation occurs. + + - icache fetch occurs, due to speculation. + + - dcache writeback occurs. + +If the above were allowed to happen then the icache would contain stale +data. Forcing the dcache writeback to complete before the icache +invalidation avoids this. + +Signed-off-by: Paul Burton +Cc: James Hogan +--- + arch/mips/mm/c-r4k.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +--- a/arch/mips/mm/c-r4k.c ++++ b/arch/mips/mm/c-r4k.c +@@ -403,6 +403,7 @@ static inline void local_r4k___flush_cac + + default: + r4k_blast_dcache(); ++ mb(); /* cache instructions may be reordered */ + r4k_blast_icache(); + break; + } +@@ -483,8 +484,10 @@ static inline void local_r4k_flush_cache + if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) + r4k_blast_dcache(); + /* If executable, blast stale lines from icache */ +- if (exec) ++ if (exec) { ++ mb(); /* cache instructions may be reordered */ + r4k_blast_icache(); ++ } + } + + static void r4k_flush_cache_range(struct vm_area_struct *vma, +@@ -586,8 +589,13 @@ static inline void local_r4k_flush_cache + if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) { + vaddr ? r4k_blast_dcache_page(addr) : + r4k_blast_dcache_user_page(addr); +- if (exec && !cpu_icache_snoops_remote_store) ++ if (exec) ++ mb(); /* cache instructions may be reordered */ ++ ++ if (exec && !cpu_icache_snoops_remote_store) { + r4k_blast_scache_page(addr); ++ mb(); /* cache instructions may be reordered */ ++ } + } + if (exec) { + if (vaddr && cpu_has_vtag_icache && mm == current->active_mm) { +@@ -654,6 +662,7 @@ static inline void __local_r4k_flush_ica + else + blast_dcache_range(start, end); + } ++ mb(); /* cache instructions may be reordered */ + } + + if (type == R4K_INDEX || diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/302-mips_no_branch_likely.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/302-mips_no_branch_likely.patch new file mode 100755 index 0000000..669aa81 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/302-mips_no_branch_likely.patch @@ -0,0 +1,22 @@ +From: Felix Fietkau +Subject: mips: use -mno-branch-likely for kernel and userspace + +saves ~11k kernel size after lzma and ~12k squashfs size in the + +lede-commit: 41a039f46450ffae9483d6216422098669da2900 +Signed-off-by: Felix Fietkau +--- + arch/mips/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/mips/Makefile ++++ b/arch/mips/Makefile +@@ -94,7 +94,7 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlin + # machines may also. Since BFD is incredibly buggy with respect to + # crossformat linking we rely on the elf2ecoff tool for format conversion. + # +-cflags-y += -G 0 -mno-abicalls -fno-pic -pipe ++cflags-y += -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely + cflags-y += -msoft-float -Wa,-msoft-float + LDFLAGS_vmlinux += -G 0 -static -n -nostdlib + KBUILD_AFLAGS_MODULE += -mlong-calls diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/303-Revert-powerpc-dts-mpc85xx-remove-simple-bus-compatible-from-ifc-node.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/303-Revert-powerpc-dts-mpc85xx-remove-simple-bus-compatible-from-ifc-node.patch new file mode 100755 index 0000000..31f15a5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/303-Revert-powerpc-dts-mpc85xx-remove-simple-bus-compatible-from-ifc-node.patch @@ -0,0 +1,125 @@ +From patchwork Wed Nov 5 20:55:24 2025 +From: Rosen Penev +Subject: [PATCH] Revert "powerpc: dts: mpc85xx: remove "simple-bus" compatible + from ifc node" +Date: Wed, 5 Nov 2025 12:55:24 -0800 + +This reverts commit 0bf51cc9e9e57a751b4c5dacbfa499ba5cd8bd72. + +simple-bus is needed for legacy platforms such as P1010 so that nodes +are populated properly. + +Fixes fsl,ifc-nand probing under at least P1010. + +Signed-off-by: Rosen Penev +--- + arch/powerpc/boot/dts/fsl/b4si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/c293si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/p1010si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/t1023si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/t1040si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/t2081si-post.dtsi | 2 +- + arch/powerpc/boot/dts/fsl/t4240si-post.dtsi | 2 +- + 9 files changed, 9 insertions(+), 9 deletions(-) + +--- a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi +@@ -50,7 +50,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <25 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi +@@ -35,7 +35,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <16 2 0 0 20 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/bsc9132si-post.dtsi +@@ -35,7 +35,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + /* FIXME: Test whether interrupts are split */ + interrupts = <16 2 0 0 20 2 0 0>; + }; +--- a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi +@@ -35,7 +35,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <19 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi +@@ -35,7 +35,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <16 2 0 0 19 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi +@@ -52,7 +52,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <25 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/t1040si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/t1040si-post.dtsi +@@ -52,7 +52,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <25 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/t2081si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/t2081si-post.dtsi +@@ -50,7 +50,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <25 2 0 0>; + }; + +--- a/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi +@@ -50,7 +50,7 @@ + &ifc { + #address-cells = <2>; + #size-cells = <1>; +- compatible = "fsl,ifc"; ++ compatible = "fsl,ifc", "simple-bus"; + interrupts = <25 2 0 0>; + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/308-mips32r2_tune.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/308-mips32r2_tune.patch new file mode 100755 index 0000000..b9bd610 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/308-mips32r2_tune.patch @@ -0,0 +1,22 @@ +From: Felix Fietkau +Subject: kernel: add -mtune=34kc to MIPS CFLAGS when building for mips32r2 + +This provides a good tradeoff across at least 24Kc-74Kc, while also +producing smaller code. + +Signed-off-by: Felix Fietkau +--- + arch/mips/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/mips/Makefile ++++ b/arch/mips/Makefile +@@ -153,7 +153,7 @@ cflags-$(CONFIG_CPU_R4300) += $(call cc- + cflags-$(CONFIG_CPU_R4X00) += $(call cc-option,-march=r4600,-march=mips3) -Wa,--trap + cflags-$(CONFIG_CPU_TX49XX) += $(call cc-option,-march=r4600,-march=mips3) -Wa,--trap + cflags-$(CONFIG_CPU_MIPS32_R1) += -march=mips32 -Wa,--trap +-cflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -Wa,--trap ++cflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -mtune=34kc -Wa,--trap + cflags-$(CONFIG_CPU_MIPS32_R5) += -march=mips32r5 -Wa,--trap -modd-spreg + cflags-$(CONFIG_CPU_MIPS32_R6) += -march=mips32r6 -Wa,--trap -modd-spreg + cflags-$(CONFIG_CPU_MIPS64_R1) += -march=mips64 -Wa,--trap diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/310-arm_module_unresolved_weak_sym.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/310-arm_module_unresolved_weak_sym.patch new file mode 100755 index 0000000..c654f6b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/310-arm_module_unresolved_weak_sym.patch @@ -0,0 +1,22 @@ +From: Felix Fietkau +Subject: fix errors in unresolved weak symbols on arm + +lede-commit: 570699d4838a907c3ef9f2819bf19eb72997b32f +Signed-off-by: Felix Fietkau +--- + arch/arm/kernel/module.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/arch/arm/kernel/module.c ++++ b/arch/arm/kernel/module.c +@@ -112,6 +112,10 @@ apply_relocate(Elf32_Shdr *sechdrs, cons + return -ENOEXEC; + } + ++ if ((IS_ERR_VALUE(sym->st_value) || !sym->st_value) && ++ ELF_ST_BIND(sym->st_info) == STB_WEAK) ++ continue; ++ + loc = dstsec->sh_addr + rel->r_offset; + + switch (ELF32_R_TYPE(rel->r_info)) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch new file mode 100755 index 0000000..a8c6b7a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch @@ -0,0 +1,282 @@ +From: Yousong Zhou +Subject: MIPS: kexec: Accept command line parameters from userspace. + +Signed-off-by: Yousong Zhou +--- + arch/mips/kernel/machine_kexec.c | 153 +++++++++++++++++++++++++++++++----- + arch/mips/kernel/machine_kexec.h | 20 +++++ + arch/mips/kernel/relocate_kernel.S | 21 +++-- + 3 files changed, 167 insertions(+), 27 deletions(-) + create mode 100644 arch/mips/kernel/machine_kexec.h + +--- a/arch/mips/kernel/machine_kexec.c ++++ b/arch/mips/kernel/machine_kexec.c +@@ -10,14 +10,11 @@ + #include + #include + ++#include + #include + #include +- +-extern const unsigned char relocate_new_kernel[]; +-extern const size_t relocate_new_kernel_size; +- +-extern unsigned long kexec_start_address; +-extern unsigned long kexec_indirection_page; ++#include ++#include "machine_kexec.h" + + static unsigned long reboot_code_buffer; + +@@ -31,6 +28,101 @@ void (*_crash_smp_send_stop)(void) = NUL + void (*_machine_kexec_shutdown)(void) = NULL; + void (*_machine_crash_shutdown)(struct pt_regs *regs) = NULL; + ++static void machine_kexec_print_args(void) ++{ ++ unsigned long argc = (int)kexec_args[0]; ++ int i; ++ ++ pr_info("kexec_args[0] (argc): %lu\n", argc); ++ pr_info("kexec_args[1] (argv): %p\n", (void *)kexec_args[1]); ++ pr_info("kexec_args[2] (env ): %p\n", (void *)kexec_args[2]); ++ pr_info("kexec_args[3] (desc): %p\n", (void *)kexec_args[3]); ++ ++ for (i = 0; i < argc; i++) { ++ pr_info("kexec_argv[%d] = %p, %s\n", ++ i, kexec_argv[i], kexec_argv[i]); ++ } ++} ++ ++static void machine_kexec_init_argv(struct kimage *image) ++{ ++ void __user *buf = NULL; ++ size_t bufsz; ++ size_t size; ++ int i; ++ ++ bufsz = 0; ++ for (i = 0; i < image->nr_segments; i++) { ++ struct kexec_segment *seg; ++ ++ seg = &image->segment[i]; ++ if (seg->bufsz < 6) ++ continue; ++ ++ if (strncmp((char *) seg->buf, "kexec ", 6)) ++ continue; ++ ++ buf = seg->buf; ++ bufsz = seg->bufsz; ++ break; ++ } ++ ++ if (!buf) ++ return; ++ ++ size = KEXEC_COMMAND_LINE_SIZE; ++ size = min(size, bufsz); ++ if (size < bufsz) ++ pr_warn("kexec command line truncated to %zd bytes\n", size); ++ ++ /* Copy to kernel space */ ++ if (copy_from_user(kexec_argv_buf, buf, size)) ++ pr_warn("kexec command line copy to kernel space failed\n"); ++ ++ kexec_argv_buf[size - 1] = 0; ++} ++ ++static void machine_kexec_parse_argv(struct kimage *image) ++{ ++ char *reboot_code_buffer; ++ int reloc_delta; ++ char *ptr; ++ int argc; ++ int i; ++ ++ ptr = kexec_argv_buf; ++ argc = 0; ++ ++ /* ++ * convert command line string to array of parameters ++ * (as bootloader does). ++ */ ++ while (ptr && *ptr && (KEXEC_MAX_ARGC > argc)) { ++ if (*ptr == ' ') { ++ *ptr++ = '\0'; ++ continue; ++ } ++ ++ kexec_argv[argc++] = ptr; ++ ptr = strchr(ptr, ' '); ++ } ++ ++ if (!argc) ++ return; ++ ++ kexec_args[0] = argc; ++ kexec_args[1] = (unsigned long)kexec_argv; ++ kexec_args[2] = 0; ++ kexec_args[3] = 0; ++ ++ reboot_code_buffer = page_address(image->control_code_page); ++ reloc_delta = reboot_code_buffer - (char *)kexec_relocate_new_kernel; ++ ++ kexec_args[1] += reloc_delta; ++ for (i = 0; i < argc; i++) ++ kexec_argv[i] += reloc_delta; ++} ++ + static void kexec_image_info(const struct kimage *kimage) + { + unsigned long i; +@@ -100,6 +192,18 @@ machine_kexec_prepare(struct kimage *kim + #endif + + kexec_image_info(kimage); ++ /* ++ * Whenever arguments passed from kexec-tools, Init the arguments as ++ * the original ones to try avoiding booting failure. ++ */ ++ ++ kexec_args[0] = fw_arg0; ++ kexec_args[1] = fw_arg1; ++ kexec_args[2] = fw_arg2; ++ kexec_args[3] = fw_arg3; ++ ++ machine_kexec_init_argv(kimage); ++ machine_kexec_parse_argv(kimage); + + if (_machine_kexec_prepare) + return _machine_kexec_prepare(kimage); +@@ -162,7 +266,7 @@ machine_crash_shutdown(struct pt_regs *r + void kexec_nonboot_cpu_jump(void) + { + local_flush_icache_range((unsigned long)relocated_kexec_smp_wait, +- reboot_code_buffer + relocate_new_kernel_size); ++ reboot_code_buffer + KEXEC_RELOCATE_NEW_KERNEL_SIZE); + + relocated_kexec_smp_wait(NULL); + } +@@ -200,7 +304,7 @@ void kexec_reboot(void) + * machine_kexec() CPU. + */ + local_flush_icache_range(reboot_code_buffer, +- reboot_code_buffer + relocate_new_kernel_size); ++ reboot_code_buffer + KEXEC_RELOCATE_NEW_KERNEL_SIZE); + + do_kexec = (void *)reboot_code_buffer; + do_kexec(); +@@ -213,10 +317,12 @@ machine_kexec(struct kimage *image) + unsigned long *ptr; + + reboot_code_buffer = +- (unsigned long)page_address(image->control_code_page); ++ (unsigned long)page_address(image->control_code_page); ++ pr_info("reboot_code_buffer = %p\n", (void *)reboot_code_buffer); + + kexec_start_address = + (unsigned long) phys_to_virt(image->start); ++ pr_info("kexec_start_address = %p\n", (void *)kexec_start_address); + + if (image->type == KEXEC_TYPE_DEFAULT) { + kexec_indirection_page = +@@ -224,9 +330,19 @@ machine_kexec(struct kimage *image) + } else { + kexec_indirection_page = (unsigned long)&image->head; + } ++ pr_info("kexec_indirection_page = %p\n", (void *)kexec_indirection_page); + +- memcpy((void*)reboot_code_buffer, relocate_new_kernel, +- relocate_new_kernel_size); ++ pr_info("Where is memcpy: %p\n", memcpy); ++ pr_info("kexec_relocate_new_kernel = %p, kexec_relocate_new_kernel_end = %p\n", ++ (void *)kexec_relocate_new_kernel, &kexec_relocate_new_kernel_end); ++ pr_info("Copy %lu bytes from %p to %p\n", KEXEC_RELOCATE_NEW_KERNEL_SIZE, ++ (void *)kexec_relocate_new_kernel, (void *)reboot_code_buffer); ++ memcpy((void*)reboot_code_buffer, kexec_relocate_new_kernel, ++ KEXEC_RELOCATE_NEW_KERNEL_SIZE); ++ ++ pr_info("Before _print_args().\n"); ++ machine_kexec_print_args(); ++ pr_info("Before eval loop.\n"); + + /* + * The generic kexec code builds a page list with physical +@@ -257,7 +373,7 @@ machine_kexec(struct kimage *image) + #ifdef CONFIG_SMP + /* All secondary cpus now may jump to kexec_wait cycle */ + relocated_kexec_smp_wait = reboot_code_buffer + +- (void *)(kexec_smp_wait - relocate_new_kernel); ++ (void *)(kexec_smp_wait - kexec_relocate_new_kernel); + smp_wmb(); + atomic_set(&kexec_ready_to_reboot, 1); + #endif +--- /dev/null ++++ b/arch/mips/kernel/machine_kexec.h +@@ -0,0 +1,20 @@ ++#ifndef _MACHINE_KEXEC_H ++#define _MACHINE_KEXEC_H ++ ++#ifndef __ASSEMBLY__ ++extern const unsigned char kexec_relocate_new_kernel[]; ++extern unsigned long kexec_relocate_new_kernel_end; ++extern unsigned long kexec_start_address; ++extern unsigned long kexec_indirection_page; ++ ++extern char kexec_argv_buf[]; ++extern char *kexec_argv[]; ++ ++#define KEXEC_RELOCATE_NEW_KERNEL_SIZE ((unsigned long)&kexec_relocate_new_kernel_end - (unsigned long)kexec_relocate_new_kernel) ++#endif /* !__ASSEMBLY__ */ ++ ++#define KEXEC_COMMAND_LINE_SIZE 256 ++#define KEXEC_ARGV_SIZE (KEXEC_COMMAND_LINE_SIZE / 16) ++#define KEXEC_MAX_ARGC (KEXEC_ARGV_SIZE / sizeof(long)) ++ ++#endif +--- a/arch/mips/kernel/relocate_kernel.S ++++ b/arch/mips/kernel/relocate_kernel.S +@@ -10,10 +10,11 @@ + #include + #include + #include ++#include "machine_kexec.h" + + #include + +-LEAF(relocate_new_kernel) ++LEAF(kexec_relocate_new_kernel) + PTR_L a0, arg0 + PTR_L a1, arg1 + PTR_L a2, arg2 +@@ -97,7 +98,7 @@ done: + #endif + /* jump to kexec_start_address */ + j s1 +- END(relocate_new_kernel) ++ END(kexec_relocate_new_kernel) + + #ifdef CONFIG_SMP + /* +@@ -176,8 +177,15 @@ EXPORT(kexec_indirection_page) + PTR_WD 0 + .size kexec_indirection_page, PTRSIZE + +-relocate_new_kernel_end: ++kexec_argv_buf: ++ EXPORT(kexec_argv_buf) ++ .skip KEXEC_COMMAND_LINE_SIZE ++ .size kexec_argv_buf, KEXEC_COMMAND_LINE_SIZE ++ ++kexec_argv: ++ EXPORT(kexec_argv) ++ .skip KEXEC_ARGV_SIZE ++ .size kexec_argv, KEXEC_ARGV_SIZE + +-EXPORT(relocate_new_kernel_size) +- PTR_WD relocate_new_kernel_end - relocate_new_kernel +- .size relocate_new_kernel_size, PTRSIZE ++kexec_relocate_new_kernel_end: ++ EXPORT(kexec_relocate_new_kernel_end) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/332-arc-add-OWRTDTB-section.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/332-arc-add-OWRTDTB-section.patch new file mode 100755 index 0000000..5b943f3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/332-arc-add-OWRTDTB-section.patch @@ -0,0 +1,84 @@ +From bb0c3b0175240bf152fd7c644821a0cf9f77c37c Mon Sep 17 00:00:00 2001 +From: Evgeniy Didin +Date: Fri, 15 Mar 2019 18:53:38 +0300 +Subject: [PATCH] arc add OWRTDTB section + +This change allows OpenWRT to patch resulting kernel binary with +external .dtb. + +That allows us to re-use exactky the same vmlinux on different boards +given its ARC core configurations match (at least cache line sizes etc). + +""patch-dtb" searches for ASCII "OWRTDTB:" strign and copies external +.dtb right after it, keeping the string in place. + +Signed-off-by: Eugeniy Paltsev +Signed-off-by: Alexey Brodkin +Signed-off-by: Evgeniy Didin +--- + arch/arc/kernel/head.S | 10 ++++++++++ + arch/arc/kernel/setup.c | 4 +++- + arch/arc/kernel/vmlinux.lds.S | 13 +++++++++++++ + 3 files changed, 26 insertions(+), 1 deletion(-) + +--- a/arch/arc/kernel/head.S ++++ b/arch/arc/kernel/head.S +@@ -88,6 +88,16 @@ + DSP_EARLY_INIT + .endm + ++ ; Here "patch-dtb" will embed external .dtb ++ ; Note "patch-dtb" searches for ASCII "OWRTDTB:" string ++ ; and pastes .dtb right after it, hense the string precedes ++ ; __image_dtb symbol. ++ .section .owrt, "aw",@progbits ++ .ascii "OWRTDTB:" ++ENTRY(__image_dtb) ++ .fill 0x4000 ++END(__image_dtb) ++ + .section .init.text, "ax",@progbits + + ;---------------------------------------------------------------- +--- a/arch/arc/kernel/setup.c ++++ b/arch/arc/kernel/setup.c +@@ -450,6 +450,8 @@ static inline bool uboot_arg_invalid(uns + /* We always pass 0 as magic from U-boot */ + #define UBOOT_MAGIC_VALUE 0 + ++extern struct boot_param_header __image_dtb; ++ + void __init handle_uboot_args(void) + { + bool use_embedded_dtb = true; +@@ -488,7 +490,7 @@ void __init handle_uboot_args(void) + ignore_uboot_args: + + if (use_embedded_dtb) { +- machine_desc = setup_machine_fdt(__dtb_start); ++ machine_desc = setup_machine_fdt(&__image_dtb); + if (!machine_desc) + panic("Embedded DT invalid\n"); + } +--- a/arch/arc/kernel/vmlinux.lds.S ++++ b/arch/arc/kernel/vmlinux.lds.S +@@ -27,6 +27,19 @@ SECTIONS + + . = CONFIG_LINUX_LINK_BASE; + ++ /* ++ * In OpenWRT we want to patch built binary embedding .dtb of choice. ++ * This is implemented with "patch-dtb" utility which searches for ++ * "OWRTDTB:" string in first 16k of image and if it is found ++ * copies .dtb right after mentioned string. ++ * ++ * Note: "OWRTDTB:" won't be overwritten with .dtb, .dtb will follow it. ++ */ ++ .owrt : { ++ *(.owrt) ++ . = ALIGN(PAGE_SIZE); ++ } ++ + _int_vec_base_lds = .; + .vector : { + *(.vector) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/333-arc-enable-unaligned-access-in-kernel-mode.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/333-arc-enable-unaligned-access-in-kernel-mode.patch new file mode 100755 index 0000000..2c9808d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/333-arc-enable-unaligned-access-in-kernel-mode.patch @@ -0,0 +1,24 @@ +From: Alexey Brodkin +Subject: arc: enable unaligned access in kernel mode + +This enables misaligned access handling even in kernel mode. +Some wireless drivers (ath9k-htc and mt7601u) use misaligned accesses +here and there and to cope with that without fixing stuff in the drivers +we're just gracefully handling it on ARC. + +Signed-off-by: Alexey Brodkin +--- + arch/arc/kernel/unaligned.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/arc/kernel/unaligned.c ++++ b/arch/arc/kernel/unaligned.c +@@ -203,7 +203,7 @@ int misaligned_fixup(unsigned long addre + char buf[TASK_COMM_LEN]; + + /* handle user mode only and only if enabled by sysadmin */ +- if (!user_mode(regs) || !unaligned_enabled) ++ if (!unaligned_enabled) + return 1; + + if (no_unaligned_warning) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/342-powerpc-Enable-kernel-XZ-compression-option-on-PPC_8.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/342-powerpc-Enable-kernel-XZ-compression-option-on-PPC_8.patch new file mode 100755 index 0000000..c812a08 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/342-powerpc-Enable-kernel-XZ-compression-option-on-PPC_8.patch @@ -0,0 +1,25 @@ +From 66770a004afe10df11d3902e16eaa0c2c39436bb Mon Sep 17 00:00:00 2001 +From: Pawel Dembicki +Date: Fri, 24 May 2019 17:56:19 +0200 +Subject: [PATCH] powerpc: Enable kernel XZ compression option on PPC_85xx + +Enable kernel XZ compression option on PPC_85xx. Tested with +simpleImage on TP-Link TL-WDR4900 (Freescale P1014 processor). + +Suggested-by: Christian Lamparter +Signed-off-by: Pawel Dembicki +--- + arch/powerpc/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/powerpc/Kconfig ++++ b/arch/powerpc/Kconfig +@@ -254,7 +254,7 @@ config PPC + select HAVE_KERNEL_GZIP + select HAVE_KERNEL_LZMA if DEFAULT_UIMAGE + select HAVE_KERNEL_LZO if DEFAULT_UIMAGE +- select HAVE_KERNEL_XZ if PPC_BOOK3S || 44x ++ select HAVE_KERNEL_XZ if PPC_BOOK3S || 44x || PPC_85xx + select HAVE_KPROBES + select HAVE_KPROBES_ON_FTRACE + select HAVE_KRETPROBES diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/350-mips-kernel-fix-detect_memory_region-function.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/350-mips-kernel-fix-detect_memory_region-function.patch new file mode 100755 index 0000000..a99eed4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/350-mips-kernel-fix-detect_memory_region-function.patch @@ -0,0 +1,74 @@ +From: Shiji Yang +Date: Wed, 13 Mar 2024 20:28:37 +0800 +Subject: [PATCH] mips: kernel: fix detect_memory_region() function + +1. Do not use memcmp() on unallocated memory, as the new introduced + fortify dynamic object size check[1] will report unexpected result. +2. Use a fixed pattern instead of a random function pointer as the + magic value. +3. Flip magic value and double check it. +4. Enable this feature only for 32-bit CPUs. Currently, only ath79 and + ralink CPUs are using it. + +[1] 439a1bcac648 ("fortify: Use __builtin_dynamic_object_size() when available") +Signed-off-by: Shiji Yang +--- + arch/mips/include/asm/bootinfo.h | 2 ++ + arch/mips/kernel/setup.c | 17 ++++++++++++----- + 2 files changed, 14 insertions(+), 5 deletions(-) + +--- a/arch/mips/include/asm/bootinfo.h ++++ b/arch/mips/include/asm/bootinfo.h +@@ -93,7 +93,9 @@ const char *get_system_type(void); + + extern unsigned long mips_machtype; + ++#ifndef CONFIG_64BIT + extern void detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_addr_t sz_max); ++#endif + + extern void prom_init(void); + extern void prom_free_prom_memory(void); +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -86,21 +86,27 @@ static struct resource bss_resource = { + unsigned long __kaslr_offset __ro_after_init; + EXPORT_SYMBOL(__kaslr_offset); + +-static void *detect_magic __initdata = detect_memory_region; +- + #ifdef CONFIG_MIPS_AUTO_PFN_OFFSET + unsigned long ARCH_PFN_OFFSET; + EXPORT_SYMBOL(ARCH_PFN_OFFSET); + #endif + ++#ifndef CONFIG_64BIT ++static u32 detect_magic __initdata; ++#define MIPS_MEM_TEST_PATTERN 0xaa5555aa ++ + void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_addr_t sz_max) + { +- void *dm = &detect_magic; ++ void *dm = (void *)KSEG1ADDR(&detect_magic); + phys_addr_t size; + + for (size = sz_min; size < sz_max; size <<= 1) { +- if (!memcmp(dm, dm + size, sizeof(detect_magic))) +- break; ++ __raw_writel(MIPS_MEM_TEST_PATTERN, dm); ++ if (__raw_readl(dm) == __raw_readl(dm + size)) { ++ __raw_writel(~MIPS_MEM_TEST_PATTERN, dm); ++ if (__raw_readl(dm) == __raw_readl(dm + size)) ++ break; ++ } + } + + pr_debug("Memory: %lluMB of RAM detected at 0x%llx (min: %lluMB, max: %lluMB)\n", +@@ -111,6 +117,7 @@ void __init detect_memory_region(phys_ad + + memblock_add(start, size); + } ++#endif /* CONFIG_64BIT */ + + /* + * Manage initrd diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/360-Revert-MIPS-mm-kmalloc-tlb_vpn-array-to-avoid-stack-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/360-Revert-MIPS-mm-kmalloc-tlb_vpn-array-to-avoid-stack-.patch new file mode 100755 index 0000000..522fccd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/360-Revert-MIPS-mm-kmalloc-tlb_vpn-array-to-avoid-stack-.patch @@ -0,0 +1,60 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Mon, 15 Dec 2025 01:45:07 +0100 +Subject: Revert "MIPS: mm: kmalloc tlb_vpn array to avoid stack overflow" + +This reverts commit 63a93d1cd6077d79735f804f5a4957bfb240280c. +--- + arch/mips/mm/tlb-r4k.c | 18 ++---------------- + 1 file changed, 2 insertions(+), 16 deletions(-) + +--- a/arch/mips/mm/tlb-r4k.c ++++ b/arch/mips/mm/tlb-r4k.c +@@ -12,7 +12,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -523,26 +522,17 @@ static int r4k_vpn_cmp(const void *a, co + * Initialise all TLB entries with unique values that do not clash with + * what we have been handed over and what we'll be using ourselves. + */ +-static void __ref r4k_tlb_uniquify(void) ++static void r4k_tlb_uniquify(void) + { ++ unsigned long tlb_vpns[1 << MIPS_CONF1_TLBS_SIZE]; + int tlbsize = current_cpu_data.tlbsize; +- bool use_slab = slab_is_available(); + int start = num_wired_entries(); +- phys_addr_t tlb_vpn_size; +- unsigned long *tlb_vpns; + unsigned long vpn_mask; + int cnt, ent, idx, i; + + vpn_mask = GENMASK(cpu_vmbits - 1, 13); + vpn_mask |= IS_ENABLED(CONFIG_64BIT) ? 3ULL << 62 : 1 << 31; + +- tlb_vpn_size = tlbsize * sizeof(*tlb_vpns); +- tlb_vpns = (use_slab ? +- kmalloc(tlb_vpn_size, GFP_KERNEL) : +- memblock_alloc_raw(tlb_vpn_size, sizeof(*tlb_vpns))); +- if (WARN_ON(!tlb_vpns)) +- return; /* Pray local_flush_tlb_all() is good enough. */ +- + htw_stop(); + + for (i = start, cnt = 0; i < tlbsize; i++, cnt++) { +@@ -595,10 +585,6 @@ static void __ref r4k_tlb_uniquify(void) + tlbw_use_hazard(); + htw_start(); + flush_micro_tlb(); +- if (use_slab) +- kfree(tlb_vpns); +- else +- memblock_free(tlb_vpns, tlb_vpn_size); + } + + /* diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/361-Revert-MIPS-mm-Prevent-a-TLB-shutdown-on-initial-uni.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/361-Revert-MIPS-mm-Prevent-a-TLB-shutdown-on-initial-uni.patch new file mode 100755 index 0000000..826ed8e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/361-Revert-MIPS-mm-Prevent-a-TLB-shutdown-on-initial-uni.patch @@ -0,0 +1,146 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Mon, 15 Dec 2025 01:45:20 +0100 +Subject: Revert "MIPS: mm: Prevent a TLB shutdown on initial uniquification" + +This reverts commit 135178e90aa43ad949534e1d6e376c4034942caa. +--- + arch/mips/mm/tlb-r4k.c | 100 +++++++++++++++-------------------------- + 1 file changed, 37 insertions(+), 63 deletions(-) + +--- a/arch/mips/mm/tlb-r4k.c ++++ b/arch/mips/mm/tlb-r4k.c +@@ -15,7 +15,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -509,79 +508,55 @@ static int __init set_ntlb(char *str) + + __setup("ntlb=", set_ntlb); + +- +-/* Comparison function for EntryHi VPN fields. */ +-static int r4k_vpn_cmp(const void *a, const void *b) +-{ +- long v = *(unsigned long *)a - *(unsigned long *)b; +- int s = sizeof(long) > sizeof(int) ? sizeof(long) * 8 - 1: 0; +- return s ? (v != 0) | v >> s : v; +-} +- +-/* +- * Initialise all TLB entries with unique values that do not clash with +- * what we have been handed over and what we'll be using ourselves. +- */ ++/* Initialise all TLB entries with unique values */ + static void r4k_tlb_uniquify(void) + { +- unsigned long tlb_vpns[1 << MIPS_CONF1_TLBS_SIZE]; +- int tlbsize = current_cpu_data.tlbsize; +- int start = num_wired_entries(); +- unsigned long vpn_mask; +- int cnt, ent, idx, i; +- +- vpn_mask = GENMASK(cpu_vmbits - 1, 13); +- vpn_mask |= IS_ENABLED(CONFIG_64BIT) ? 3ULL << 62 : 1 << 31; ++ int entry = num_wired_entries(); + + htw_stop(); ++ write_c0_entrylo0(0); ++ write_c0_entrylo1(0); + +- for (i = start, cnt = 0; i < tlbsize; i++, cnt++) { +- unsigned long vpn; ++ while (entry < current_cpu_data.tlbsize) { ++ unsigned long asid_mask = cpu_asid_mask(¤t_cpu_data); ++ unsigned long asid = 0; ++ int idx; + +- write_c0_index(i); +- mtc0_tlbr_hazard(); +- tlb_read(); +- tlb_read_hazard(); +- vpn = read_c0_entryhi(); +- vpn &= vpn_mask & PAGE_MASK; +- tlb_vpns[cnt] = vpn; ++ /* Skip wired MMID to make ginvt_mmid work */ ++ if (cpu_has_mmid) ++ asid = MMID_KERNEL_WIRED + 1; + +- /* Prevent any large pages from overlapping regular ones. */ +- write_c0_pagemask(read_c0_pagemask() & PM_DEFAULT_MASK); ++ /* Check for match before using UNIQUE_ENTRYHI */ ++ do { ++ if (cpu_has_mmid) { ++ write_c0_memorymapid(asid); ++ write_c0_entryhi(UNIQUE_ENTRYHI(entry)); ++ } else { ++ write_c0_entryhi(UNIQUE_ENTRYHI(entry) | asid); ++ } ++ mtc0_tlbw_hazard(); ++ tlb_probe(); ++ tlb_probe_hazard(); ++ idx = read_c0_index(); ++ /* No match or match is on current entry */ ++ if (idx < 0 || idx == entry) ++ break; ++ /* ++ * If we hit a match, we need to try again with ++ * a different ASID. ++ */ ++ asid++; ++ } while (asid < asid_mask); ++ ++ if (idx >= 0 && idx != entry) ++ panic("Unable to uniquify TLB entry %d", idx); ++ ++ write_c0_index(entry); + mtc0_tlbw_hazard(); + tlb_write_indexed(); +- tlbw_use_hazard(); ++ entry++; + } + +- sort(tlb_vpns, cnt, sizeof(tlb_vpns[0]), r4k_vpn_cmp, NULL); +- +- write_c0_pagemask(PM_DEFAULT_MASK); +- write_c0_entrylo0(0); +- write_c0_entrylo1(0); +- +- idx = 0; +- ent = tlbsize; +- for (i = start; i < tlbsize; i++) +- while (1) { +- unsigned long entryhi, vpn; +- +- entryhi = UNIQUE_ENTRYHI(ent); +- vpn = entryhi & vpn_mask & PAGE_MASK; +- +- if (idx >= cnt || vpn < tlb_vpns[idx]) { +- write_c0_entryhi(entryhi); +- write_c0_index(i); +- mtc0_tlbw_hazard(); +- tlb_write_indexed(); +- ent++; +- break; +- } else if (vpn == tlb_vpns[idx]) { +- ent++; +- } else { +- idx++; +- } +- } +- + tlbw_use_hazard(); + htw_start(); + flush_micro_tlb(); +@@ -627,7 +602,6 @@ static void r4k_tlb_configure(void) + + /* From this point on the ARC firmware is dead. */ + r4k_tlb_uniquify(); +- local_flush_tlb_all(); + + /* Did I tell you that ARC SUCKS? */ + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/400-mtd-mtdsplit-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/400-mtd-mtdsplit-support.patch new file mode 100755 index 0000000..2a3a285 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/400-mtd-mtdsplit-support.patch @@ -0,0 +1,328 @@ +From 39717277d5c87bdb183cf2f258957b44ba99b4df Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 11:47:35 +0200 +Subject: [PATCH] mtd: mtdsplit support + +--- + drivers/mtd/Kconfig | 19 ++++ + drivers/mtd/Makefile | 2 + + drivers/mtd/mtdpart.c | 169 ++++++++++++++++++++++++++++----- + include/linux/mtd/mtd.h | 25 +++++ + include/linux/mtd/partitions.h | 7 ++ + 5 files changed, 197 insertions(+), 25 deletions(-) + +--- a/drivers/mtd/Kconfig ++++ b/drivers/mtd/Kconfig +@@ -12,6 +12,25 @@ menuconfig MTD + + if MTD + ++menu "OpenWrt specific MTD options" ++ ++config MTD_ROOTFS_ROOT_DEV ++ bool "Automatically set 'rootfs' partition to be root filesystem" ++ default y ++ ++config MTD_SPLIT_FIRMWARE ++ bool "Automatically split firmware partition for kernel+rootfs" ++ default y ++ ++config MTD_SPLIT_FIRMWARE_NAME ++ string "Firmware partition name" ++ depends on MTD_SPLIT_FIRMWARE ++ default "firmware" ++ ++source "drivers/mtd/mtdsplit/Kconfig" ++ ++endmenu ++ + config MTD_TESTS + tristate "MTD tests support (DANGEROUS)" + depends on m +--- a/drivers/mtd/Makefile ++++ b/drivers/mtd/Makefile +@@ -9,6 +9,8 @@ mtd-y := mtdcore.o mtdsuper.o mtdconc + + obj-y += parsers/ + ++obj-$(CONFIG_MTD_SPLIT) += mtdsplit/ ++ + # 'Users' - code which presents functionality to userspace. + obj-$(CONFIG_MTD_BLKDEVS) += mtd_blkdevs.o + obj-$(CONFIG_MTD_BLOCK) += mtdblock.o +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -15,11 +15,13 @@ + #include + #include + #include ++#include + #include + #include + #include + + #include "mtdcore.h" ++#include "mtdsplit/mtdsplit.h" + + /* + * MTD methods which simply translate the effective address and pass through +@@ -242,6 +244,147 @@ static int mtd_add_partition_attrs(struc + return ret; + } + ++static DEFINE_SPINLOCK(part_parser_lock); ++static LIST_HEAD(part_parsers); ++ ++static struct mtd_part_parser *mtd_part_parser_get(const char *name) ++{ ++ struct mtd_part_parser *p, *ret = NULL; ++ ++ spin_lock(&part_parser_lock); ++ ++ list_for_each_entry(p, &part_parsers, list) ++ if (!strcmp(p->name, name) && try_module_get(p->owner)) { ++ ret = p; ++ break; ++ } ++ ++ spin_unlock(&part_parser_lock); ++ ++ return ret; ++} ++ ++static inline void mtd_part_parser_put(const struct mtd_part_parser *p) ++{ ++ module_put(p->owner); ++} ++ ++static struct mtd_part_parser * ++get_partition_parser_by_type(enum mtd_parser_type type, ++ struct mtd_part_parser *start) ++{ ++ struct mtd_part_parser *p, *ret = NULL; ++ ++ spin_lock(&part_parser_lock); ++ ++ p = list_prepare_entry(start, &part_parsers, list); ++ if (start) ++ mtd_part_parser_put(start); ++ ++ list_for_each_entry_continue(p, &part_parsers, list) { ++ if (p->type == type && try_module_get(p->owner)) { ++ ret = p; ++ break; ++ } ++ } ++ ++ spin_unlock(&part_parser_lock); ++ ++ return ret; ++} ++ ++static int parse_mtd_partitions_by_type(struct mtd_info *master, ++ enum mtd_parser_type type, ++ const struct mtd_partition **pparts, ++ struct mtd_part_parser_data *data) ++{ ++ struct mtd_part_parser *prev = NULL; ++ int ret = 0; ++ ++ while (1) { ++ struct mtd_part_parser *parser; ++ ++ parser = get_partition_parser_by_type(type, prev); ++ if (!parser) ++ break; ++ ++ ret = (*parser->parse_fn)(master, pparts, data); ++ ++ if (ret > 0) { ++ mtd_part_parser_put(parser); ++ printk(KERN_NOTICE ++ "%d %s partitions found on MTD device %s\n", ++ ret, parser->name, master->name); ++ break; ++ } ++ ++ prev = parser; ++ } ++ ++ return ret; ++} ++ ++static int ++run_parsers_by_type(struct mtd_info *child, enum mtd_parser_type type) ++{ ++ struct mtd_partition *parts; ++ int nr_parts; ++ int i; ++ ++ nr_parts = parse_mtd_partitions_by_type(child, type, (const struct mtd_partition **)&parts, ++ NULL); ++ if (nr_parts <= 0) ++ return nr_parts; ++ ++ if (WARN_ON(!parts)) ++ return 0; ++ ++ for (i = 0; i < nr_parts; i++) { ++ /* adjust partition offsets */ ++ parts[i].offset += child->part.offset; ++ ++ mtd_add_partition(child->parent, ++ parts[i].name, ++ parts[i].offset, ++ parts[i].size); ++ } ++ ++ kfree(parts); ++ ++ return nr_parts; ++} ++ ++#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME ++#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME ++#else ++#define SPLIT_FIRMWARE_NAME "unused" ++#endif ++ ++static void split_firmware(struct mtd_info *master, struct mtd_info *part) ++{ ++ run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE); ++} ++ ++static void mtd_partition_split(struct mtd_info *master, struct mtd_info *part) ++{ ++ static int rootfs_found = 0; ++ ++ if (rootfs_found) ++ return; ++ ++ if (of_property_present(mtd_get_of_node(part), "linux,rootfs") || ++ !strcmp(part->name, "rootfs")) { ++ run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS); ++ ++ rootfs_found = 1; ++ } ++ ++ if (IS_ENABLED(CONFIG_MTD_SPLIT_FIRMWARE) && ++ !strcmp(part->name, SPLIT_FIRMWARE_NAME) && ++ !of_property_present(mtd_get_of_node(part), "compatible")) ++ split_firmware(master, part); ++} ++ + int mtd_add_partition(struct mtd_info *parent, const char *name, + long long offset, long long length) + { +@@ -280,6 +423,7 @@ int mtd_add_partition(struct mtd_info *p + if (ret) + goto err_remove_part; + ++ mtd_partition_split(parent, child); + mtd_add_partition_attrs(child); + + return 0; +@@ -423,6 +567,7 @@ int add_mtd_partitions(struct mtd_info * + goto err_del_partitions; + } + ++ mtd_partition_split(master, child); + mtd_add_partition_attrs(child); + + /* Look for subpartitions (skip if no maching parser found) */ +@@ -446,31 +591,6 @@ err_del_partitions: + return ret; + } + +-static DEFINE_SPINLOCK(part_parser_lock); +-static LIST_HEAD(part_parsers); +- +-static struct mtd_part_parser *mtd_part_parser_get(const char *name) +-{ +- struct mtd_part_parser *p, *ret = NULL; +- +- spin_lock(&part_parser_lock); +- +- list_for_each_entry(p, &part_parsers, list) +- if (!strcmp(p->name, name) && try_module_get(p->owner)) { +- ret = p; +- break; +- } +- +- spin_unlock(&part_parser_lock); +- +- return ret; +-} +- +-static inline void mtd_part_parser_put(const struct mtd_part_parser *p) +-{ +- module_put(p->owner); +-} +- + /* + * Many partition parsers just expected the core to kfree() all their data in + * one chunk. Do that by default. +--- a/include/linux/mtd/mtd.h ++++ b/include/linux/mtd/mtd.h +@@ -615,6 +615,24 @@ static inline void mtd_align_erase_req(s + req->len += mtd->erasesize - mod; + } + ++static inline uint64_t mtd_roundup_to_eb(uint64_t sz, struct mtd_info *mtd) ++{ ++ if (mtd_mod_by_eb(sz, mtd) == 0) ++ return sz; ++ ++ /* Round up to next erase block */ ++ return (mtd_div_by_eb(sz, mtd) + 1) * mtd->erasesize; ++} ++ ++static inline uint64_t mtd_rounddown_to_eb(uint64_t sz, struct mtd_info *mtd) ++{ ++ if (mtd_mod_by_eb(sz, mtd) == 0) ++ return sz; ++ ++ /* Round down to the start of the current erase block */ ++ return (mtd_div_by_eb(sz, mtd)) * mtd->erasesize; ++} ++ + static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd) + { + if (mtd->writesize_shift) +@@ -688,6 +706,13 @@ extern struct mtd_info *of_get_mtd_devic + extern struct mtd_info *get_mtd_device_nm(const char *name); + extern void put_mtd_device(struct mtd_info *mtd); + ++static inline uint64_t mtdpart_get_offset(const struct mtd_info *mtd) ++{ ++ if (!mtd_is_partition(mtd)) ++ return 0; ++ ++ return mtd->part.offset; ++} + + struct mtd_notifier { + void (*add)(struct mtd_info *mtd); +--- a/include/linux/mtd/partitions.h ++++ b/include/linux/mtd/partitions.h +@@ -75,6 +75,12 @@ struct mtd_part_parser_data { + * Functions dealing with the various ways of partitioning the space + */ + ++enum mtd_parser_type { ++ MTD_PARSER_TYPE_DEVICE = 0, ++ MTD_PARSER_TYPE_ROOTFS, ++ MTD_PARSER_TYPE_FIRMWARE, ++}; ++ + struct mtd_part_parser { + struct list_head list; + struct module *owner; +@@ -83,6 +89,7 @@ struct mtd_part_parser { + int (*parse_fn)(struct mtd_info *, const struct mtd_partition **, + struct mtd_part_parser_data *); + void (*cleanup)(const struct mtd_partition *pparts, int nr_parts); ++ enum mtd_parser_type type; + }; + + /* Container for passing around a set of parsed partitions */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/402-mtd-spi-nor-write-support-for-minor-aligned-partitions.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/402-mtd-spi-nor-write-support-for-minor-aligned-partitions.patch new file mode 100755 index 0000000..e8ad204 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/402-mtd-spi-nor-write-support-for-minor-aligned-partitions.patch @@ -0,0 +1,245 @@ +From acacdac272927ae1d96e0bca51eb82899671eaea Mon Sep 17 00:00:00 2001 +From: John Thomson +Date: Fri, 25 Dec 2020 18:50:08 +1000 +Subject: [PATCH] mtd: spi-nor: write support for minor aligned partitions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Do not prevent writing to mtd partitions where a partition boundary sits +on a minor erasesize boundary. +This addresses a FIXME that has been present since the start of the +linux git history: +/* Doesn't start on a boundary of major erase size */ +/* FIXME: Let it be writable if it is on a boundary of + * _minor_ erase size though */ + +Allow a uniform erase region spi-nor device to be configured +to use the non-uniform erase regions code path for an erase with: +CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE=y + +On supporting hardware (SECT_4K: majority of current SPI-NOR device) +provide the facility for an erase to use the least number +of SPI-NOR operations, as well as access to 4K erase without +requiring CONFIG_MTD_SPI_NOR_USE_4K_SECTORS + +Introduce erasesize_minor to the mtd struct, +the smallest erasesize supported by the device + +On existing devices, this is useful where write support is wanted +for data on a 4K partition, such as some u-boot-env partitions, +or RouterBoot soft_config, while still netting the performance +benefits of using 64K sectors + +Performance: +time mtd erase firmware +OpenWrt 5.10 ramips MT7621 w25q128jv 0xfc0000 partition length + +Without this patch +MTD_SPI_NOR_USE_4K_SECTORS=y |n +real 2m 11.66s |0m 50.86s +user 0m 0.00s |0m 0.00s +sys 1m 56.20s |0m 50.80s + +With this patch +MTD_SPI_NOR_USE_VARIABLE_ERASE=n|y |4K_SECTORS=y +real 0m 51.68s |0m 50.85s |2m 12.89s +user 0m 0.00s |0m 0.00s |0m 0.01s +sys 0m 46.94s |0m 50.38s |2m 12.46s + +Signed-off-by: John Thomson +Signed-off-by: Thibaut VARÈNE + +--- + +checkpatch does not like the printk(KERN_WARNING +these should be changed separately beforehand? + +Changes v1 -> v2: +Added mtdcore sysfs for erasesize_minor +Removed finding minor erasesize for variable erase regions device, +as untested and no responses regarding it. +Moved IF_ENABLED for SPINOR variable erase to guard setting +erasesize_minor in spi-nor/core.c +Removed setting erasesize to minor where partition boundaries require +minor erase to be writable +Simplified minor boundary check by relying on minor being a factor of +major + +Changes RFC -> v1: +Fix uninitialized variable smatch warning +Reported-by: kernel test robot +Reported-by: Dan Carpenter +--- + drivers/mtd/mtdcore.c | 10 ++++++++++ + drivers/mtd/mtdpart.c | 35 +++++++++++++++++++++++++---------- + drivers/mtd/spi-nor/Kconfig | 10 ++++++++++ + drivers/mtd/spi-nor/core.c | 11 +++++++++-- + include/linux/mtd/mtd.h | 2 ++ + 5 files changed, 56 insertions(+), 12 deletions(-) + +--- a/drivers/mtd/mtdcore.c ++++ b/drivers/mtd/mtdcore.c +@@ -199,6 +199,15 @@ static ssize_t mtd_erasesize_show(struct + } + MTD_DEVICE_ATTR_RO(erasesize); + ++static ssize_t mtd_erasesize_minor_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct mtd_info *mtd = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%lu\n", (unsigned long)mtd->erasesize_minor); ++} ++MTD_DEVICE_ATTR_RO(erasesize_minor); ++ + static ssize_t mtd_writesize_show(struct device *dev, + struct device_attribute *attr, char *buf) + { +@@ -344,6 +353,7 @@ static struct attribute *mtd_attrs[] = { + &dev_attr_flags.attr, + &dev_attr_size.attr, + &dev_attr_erasesize.attr, ++ &dev_attr_erasesize_minor.attr, + &dev_attr_writesize.attr, + &dev_attr_subpagesize.attr, + &dev_attr_oobsize.attr, +--- a/drivers/mtd/mtdpart.c ++++ b/drivers/mtd/mtdpart.c +@@ -47,6 +47,7 @@ static struct mtd_info *allocate_partiti + struct mtd_info *master = mtd_get_master(parent); + int wr_alignment = (parent->flags & MTD_NO_ERASE) ? + master->writesize : master->erasesize; ++ int wr_alignment_minor = 0; + u64 parent_size = mtd_is_partition(parent) ? + parent->part.size : parent->size; + struct mtd_info *child; +@@ -171,6 +172,7 @@ static struct mtd_info *allocate_partiti + } else { + /* Single erase size */ + child->erasesize = master->erasesize; ++ child->erasesize_minor = master->erasesize_minor; + } + + /* +@@ -178,26 +180,39 @@ static struct mtd_info *allocate_partiti + * exposes several regions with different erasesize. Adjust + * wr_alignment accordingly. + */ +- if (!(child->flags & MTD_NO_ERASE)) ++ if (!(child->flags & MTD_NO_ERASE)) { + wr_alignment = child->erasesize; ++ wr_alignment_minor = child->erasesize_minor; ++ } + + tmp = mtd_get_master_ofs(child, 0); + remainder = do_div(tmp, wr_alignment); + if ((child->flags & MTD_WRITEABLE) && remainder) { +- /* Doesn't start on a boundary of major erase size */ +- /* FIXME: Let it be writable if it is on a boundary of +- * _minor_ erase size though */ +- child->flags &= ~MTD_WRITEABLE; +- printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase/write block boundary -- force read-only\n", +- part->name); ++ if (wr_alignment_minor) { ++ /* rely on minor being a factor of major erasesize */ ++ tmp = remainder; ++ remainder = do_div(tmp, wr_alignment_minor); ++ } ++ if (remainder) { ++ child->flags &= ~MTD_WRITEABLE; ++ printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase/write block boundary -- force read-only\n", ++ part->name); ++ } + } + + tmp = mtd_get_master_ofs(child, 0) + child->part.size; + remainder = do_div(tmp, wr_alignment); + if ((child->flags & MTD_WRITEABLE) && remainder) { +- child->flags &= ~MTD_WRITEABLE; +- printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase/write block -- force read-only\n", +- part->name); ++ if (wr_alignment_minor) { ++ tmp = remainder; ++ remainder = do_div(tmp, wr_alignment_minor); ++ } ++ ++ if (remainder) { ++ child->flags &= ~MTD_WRITEABLE; ++ printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase/write block -- force read-only\n", ++ part->name); ++ } + } + + child->size = child->part.size; +--- a/drivers/mtd/spi-nor/Kconfig ++++ b/drivers/mtd/spi-nor/Kconfig +@@ -10,6 +10,16 @@ menuconfig MTD_SPI_NOR + + if MTD_SPI_NOR + ++config MTD_SPI_NOR_USE_VARIABLE_ERASE ++ bool "Disable uniform_erase to allow use of all hardware supported erasesizes" ++ depends on !MTD_SPI_NOR_USE_4K_SECTORS ++ default n ++ help ++ Allow mixed use of all hardware supported erasesizes, ++ by forcing spi_nor to use the multiple eraseregions code path. ++ For example: A 68K erase will use one 64K erase, and one 4K erase ++ on supporting hardware. ++ + config MTD_SPI_NOR_USE_4K_SECTORS + bool "Use small 4096 B erase sectors" + default y +--- a/drivers/mtd/spi-nor/core.c ++++ b/drivers/mtd/spi-nor/core.c +@@ -1158,6 +1158,8 @@ static u8 spi_nor_convert_3to4_erase(u8 + + static bool spi_nor_has_uniform_erase(const struct spi_nor *nor) + { ++ if (IS_ENABLED(CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE)) ++ return false; + return !!nor->params->erase_map.uniform_region.erase_mask; + } + +@@ -2516,6 +2518,7 @@ static int spi_nor_select_erase(struct s + { + struct spi_nor_erase_map *map = &nor->params->erase_map; + const struct spi_nor_erase_type *erase = NULL; ++ const struct spi_nor_erase_type *erase_minor = NULL; + struct mtd_info *mtd = &nor->mtd; + int i; + +@@ -2542,8 +2545,9 @@ static int spi_nor_select_erase(struct s + */ + for (i = SNOR_ERASE_TYPE_MAX - 1; i >= 0; i--) { + if (map->erase_type[i].size) { +- erase = &map->erase_type[i]; +- break; ++ if (!erase) ++ erase = &map->erase_type[i]; ++ erase_minor = &map->erase_type[i]; + } + } + +@@ -2551,6 +2555,9 @@ static int spi_nor_select_erase(struct s + return -EINVAL; + + mtd->erasesize = erase->size; ++ if (IS_ENABLED(CONFIG_MTD_SPI_NOR_USE_VARIABLE_ERASE) && ++ erase_minor && erase_minor->size < erase->size) ++ mtd->erasesize_minor = erase_minor->size; + return 0; + } + +--- a/include/linux/mtd/mtd.h ++++ b/include/linux/mtd/mtd.h +@@ -245,6 +245,8 @@ struct mtd_info { + * information below if they desire + */ + uint32_t erasesize; ++ /* "Minor" (smallest) erase size supported by the whole device */ ++ uint32_t erasesize_minor; + /* Minimal writable flash unit size. In case of NOR flash it is 1 (even + * though individual bits can be cleared), in case of NAND flash it is + * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/417-mtd-spi-nand-macronix-disable-continuous-read-for-MX.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/417-mtd-spi-nand-macronix-disable-continuous-read-for-MX.patch new file mode 100755 index 0000000..65531e0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/417-mtd-spi-nand-macronix-disable-continuous-read-for-MX.patch @@ -0,0 +1,39 @@ +From 435afd182e8f5997033da1d69e56094ecb112cad Mon Sep 17 00:00:00 2001 +From: Chukun Pan +Date: Thu, 10 Jun 2025 23:10:16 +0800 +Subject: [PATCH] mtd: spi-nand: macronix: disable continuous read for + MX35LFxGE4AD + +In on-die ECC mode, enabling continuous read will cause ubi_io_read error. +[ 7.852000] ubi0 warning: ubi_io_read: error -5 while reading ... + +So disable it first. Tested on GL.iNet GL-MT3000 with MX35LF2GE4AD flash. + +Fixes: 11813857864f ("mtd: spi-nand: macronix: Continuous read support") +Signed-off-by: Chukun Pan +--- + drivers/mtd/nand/spi/macronix.c | 2 -- + 1 file changed, 2 deletions(-) + +--- a/drivers/mtd/nand/spi/macronix.c ++++ b/drivers/mtd/nand/spi/macronix.c +@@ -167,8 +167,7 @@ static const struct spinand_info macroni + &update_cache_variants), + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, +- macronix_ecc_get_status), +- SPINAND_CONT_READ(macronix_set_cont_read)), ++ macronix_ecc_get_status)), + SPINAND_INFO("MX35LF4GE4AD", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x37, 0x03), + NAND_MEMORG(1, 4096, 128, 64, 2048, 40, 1, 1, 1), +@@ -178,8 +177,7 @@ static const struct spinand_info macroni + &update_cache_variants), + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, +- macronix_ecc_get_status), +- SPINAND_CONT_READ(macronix_set_cont_read)), ++ macronix_ecc_get_status)), + SPINAND_INFO("MX35LF1G24AD", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14, 0x03), + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1), diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/420-mtd-redboot_space.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/420-mtd-redboot_space.patch new file mode 100755 index 0000000..5518ea7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/420-mtd-redboot_space.patch @@ -0,0 +1,41 @@ +From: Felix Fietkau +Subject: add patch for including unpartitioned space in the rootfs partition for redboot devices (if applicable) + +[john@phrozen.org: used by ixp and others] + +lede-commit: 394918851f84e4d00fa16eb900e7700e95091f00 +Signed-off-by: Felix Fietkau +--- + drivers/mtd/redboot.c | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +--- a/drivers/mtd/parsers/redboot.c ++++ b/drivers/mtd/parsers/redboot.c +@@ -278,14 +278,21 @@ nogood: + #endif + names += strlen(names) + 1; + +-#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED + if (fl->next && fl->img->flash_base + fl->img->size + master->erasesize <= fl->next->img->flash_base) { +- i++; +- parts[i].offset = parts[i - 1].size + parts[i - 1].offset; +- parts[i].size = fl->next->img->flash_base - parts[i].offset; +- parts[i].name = nullname; +- } ++ if (!strcmp(parts[i].name, "rootfs")) { ++ parts[i].size = fl->next->img->flash_base; ++ parts[i].size &= ~(master->erasesize - 1); ++ parts[i].size -= parts[i].offset; ++#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED ++ nrparts--; ++ } else { ++ i++; ++ parts[i].offset = parts[i-1].size + parts[i-1].offset; ++ parts[i].size = fl->next->img->flash_base - parts[i].offset; ++ parts[i].name = nullname; + #endif ++ } ++ } + tmp_fl = fl; + fl = fl->next; + kfree(tmp_fl); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/430-mtd-add-myloader-partition-parser.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/430-mtd-add-myloader-partition-parser.patch new file mode 100755 index 0000000..8ce1123 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/430-mtd-add-myloader-partition-parser.patch @@ -0,0 +1,229 @@ +From: Florian Fainelli +Subject: Add myloader partition table parser + +[john@phozen.org: shoud be upstreamable] + +lede-commit: d8bf22859b51faa09d22c056fe221a45d2f7a3b8 +Signed-off-by: Florian Fainelli +[adjust for kernel 5.4, add myloader.c to patch] +Signed-off-by: Adrian Schmutzler + +--- a/drivers/mtd/parsers/Kconfig ++++ b/drivers/mtd/parsers/Kconfig +@@ -62,6 +62,22 @@ config MTD_CMDLINE_PARTS + + If unsure, say 'N'. + ++config MTD_MYLOADER_PARTS ++ tristate "MyLoader partition parsing" ++ depends on ADM5120 || ATH79 ++ help ++ MyLoader is a bootloader which allows the user to define partitions ++ in flash devices, by putting a table in the second erase block ++ on the device, similar to a partition table. This table gives the ++ offsets and lengths of the user defined partitions. ++ ++ If you need code which can detect and parse these tables, and ++ register MTD 'partitions' corresponding to each image detected, ++ enable this option. ++ ++ You will still need the parsing functions to be called by the driver ++ for your particular device. It won't happen automatically. ++ + config MTD_OF_PARTS + tristate "OpenFirmware (device tree) partitioning parser" + default y +--- a/drivers/mtd/parsers/Makefile ++++ b/drivers/mtd/parsers/Makefile +@@ -3,6 +3,7 @@ obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm4 + obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o + obj-$(CONFIG_MTD_BRCM_U_BOOT) += brcm_u-boot.o + obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o ++obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o + obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o + ofpart-y += ofpart_core.o + ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908) += ofpart_bcm4908.o +--- /dev/null ++++ b/drivers/mtd/parsers/myloader.c +@@ -0,0 +1,181 @@ ++/* ++ * Parse MyLoader-style flash partition tables and produce a Linux partition ++ * array to match. ++ * ++ * Copyright (C) 2007-2009 Gabor Juhos ++ * ++ * This file was based on drivers/mtd/redboot.c ++ * Author: Red Hat, Inc. - David Woodhouse ++ * ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 as published ++ * by the Free Software Foundation. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define BLOCK_LEN_MIN 0x10000 ++#define PART_NAME_LEN 32 ++ ++struct part_data { ++ struct mylo_partition_table tab; ++ char names[MYLO_MAX_PARTITIONS][PART_NAME_LEN]; ++}; ++ ++static int myloader_parse_partitions(struct mtd_info *master, ++ const struct mtd_partition **pparts, ++ struct mtd_part_parser_data *data) ++{ ++ struct part_data *buf; ++ struct mylo_partition_table *tab; ++ struct mylo_partition *part; ++ struct mtd_partition *mtd_parts; ++ struct mtd_partition *mtd_part; ++ int num_parts; ++ int ret, i; ++ size_t retlen; ++ char *names; ++ unsigned long offset; ++ unsigned long blocklen; ++ ++ buf = vmalloc(sizeof(*buf)); ++ if (!buf) { ++ return -ENOMEM; ++ goto out; ++ } ++ tab = &buf->tab; ++ ++ blocklen = master->erasesize; ++ if (blocklen < BLOCK_LEN_MIN) ++ blocklen = BLOCK_LEN_MIN; ++ ++ offset = blocklen; ++ ++ /* Find the partition table */ ++ for (i = 0; i < 4; i++, offset += blocklen) { ++ printk(KERN_DEBUG "%s: searching for MyLoader partition table" ++ " at offset 0x%lx\n", master->name, offset); ++ ++ ret = mtd_read(master, offset, sizeof(*buf), &retlen, ++ (void *)buf); ++ if (ret) ++ goto out_free_buf; ++ ++ if (retlen != sizeof(*buf)) { ++ ret = -EIO; ++ goto out_free_buf; ++ } ++ ++ /* Check for Partition Table magic number */ ++ if (tab->magic == le32_to_cpu(MYLO_MAGIC_PARTITIONS)) ++ break; ++ ++ } ++ ++ if (tab->magic != le32_to_cpu(MYLO_MAGIC_PARTITIONS)) { ++ printk(KERN_DEBUG "%s: no MyLoader partition table found\n", ++ master->name); ++ ret = 0; ++ goto out_free_buf; ++ } ++ ++ /* The MyLoader and the Partition Table is always present */ ++ num_parts = 2; ++ ++ /* Detect number of used partitions */ ++ for (i = 0; i < MYLO_MAX_PARTITIONS; i++) { ++ part = &tab->partitions[i]; ++ ++ if (le16_to_cpu(part->type) == PARTITION_TYPE_FREE) ++ continue; ++ ++ num_parts++; ++ } ++ ++ mtd_parts = kzalloc((num_parts * sizeof(*mtd_part) + ++ num_parts * PART_NAME_LEN), GFP_KERNEL); ++ ++ if (!mtd_parts) { ++ ret = -ENOMEM; ++ goto out_free_buf; ++ } ++ ++ mtd_part = mtd_parts; ++ names = (char *)&mtd_parts[num_parts]; ++ ++ strncpy(names, "myloader", PART_NAME_LEN); ++ mtd_part->name = names; ++ mtd_part->offset = 0; ++ mtd_part->size = offset; ++ mtd_part->mask_flags = MTD_WRITEABLE; ++ mtd_part++; ++ names += PART_NAME_LEN; ++ ++ strncpy(names, "partition_table", PART_NAME_LEN); ++ mtd_part->name = names; ++ mtd_part->offset = offset; ++ mtd_part->size = blocklen; ++ mtd_part->mask_flags = MTD_WRITEABLE; ++ mtd_part++; ++ names += PART_NAME_LEN; ++ ++ for (i = 0; i < MYLO_MAX_PARTITIONS; i++) { ++ part = &tab->partitions[i]; ++ ++ if (le16_to_cpu(part->type) == PARTITION_TYPE_FREE) ++ continue; ++ ++ if ((buf->names[i][0]) && (buf->names[i][0] != '\xff')) ++ strncpy(names, buf->names[i], PART_NAME_LEN); ++ else ++ snprintf(names, PART_NAME_LEN, "partition%d", i); ++ ++ mtd_part->offset = le32_to_cpu(part->addr); ++ mtd_part->size = le32_to_cpu(part->size); ++ mtd_part->name = names; ++ mtd_part++; ++ names += PART_NAME_LEN; ++ } ++ ++ *pparts = mtd_parts; ++ ret = num_parts; ++ ++ out_free_buf: ++ vfree(buf); ++ out: ++ return ret; ++} ++ ++static struct mtd_part_parser myloader_mtd_parser = { ++ .owner = THIS_MODULE, ++ .parse_fn = myloader_parse_partitions, ++ .name = "MyLoader", ++}; ++ ++static int __init myloader_mtd_parser_init(void) ++{ ++ register_mtd_parser(&myloader_mtd_parser); ++ ++ return 0; ++} ++ ++static void __exit myloader_mtd_parser_exit(void) ++{ ++ deregister_mtd_parser(&myloader_mtd_parser); ++} ++ ++module_init(myloader_mtd_parser_init); ++module_exit(myloader_mtd_parser_exit); ++ ++MODULE_AUTHOR("Gabor Juhos "); ++MODULE_DESCRIPTION("Parsing code for MyLoader partition tables"); ++MODULE_LICENSE("GPL v2"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch new file mode 100755 index 0000000..bcea45d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch @@ -0,0 +1,68 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Subject: [PATCH] mtd: bcm47xxpart: check for bad blocks when calculating offsets + +Signed-off-by: RafaΕ‚ MiΕ‚ecki +--- + +--- a/drivers/mtd/parsers/parser_trx.c ++++ b/drivers/mtd/parsers/parser_trx.c +@@ -25,6 +25,33 @@ struct trx_header { + uint32_t offset[3]; + } __packed; + ++/* ++ * Calculate real end offset (address) for a given amount of data. It checks ++ * all blocks skipping bad ones. ++ */ ++static size_t parser_trx_real_offset(struct mtd_info *mtd, size_t bytes) ++{ ++ size_t real_offset = 0; ++ ++ if (mtd_block_isbad(mtd, real_offset)) ++ pr_warn("Base offset shouldn't be at bad block"); ++ ++ while (bytes >= mtd->erasesize) { ++ bytes -= mtd->erasesize; ++ real_offset += mtd->erasesize; ++ while (mtd_block_isbad(mtd, real_offset)) { ++ real_offset += mtd->erasesize; ++ ++ if (real_offset >= mtd->size) ++ return real_offset - mtd->erasesize; ++ } ++ } ++ ++ real_offset += bytes; ++ ++ return real_offset; ++} ++ + static const char *parser_trx_data_part_name(struct mtd_info *master, + size_t offset) + { +@@ -86,21 +113,21 @@ static int parser_trx_parse(struct mtd_i + if (trx.offset[2]) { + part = &parts[curr_part++]; + part->name = "loader"; +- part->offset = trx.offset[i]; ++ part->offset = parser_trx_real_offset(mtd, trx.offset[i]); + i++; + } + + if (trx.offset[i]) { + part = &parts[curr_part++]; + part->name = "linux"; +- part->offset = trx.offset[i]; ++ part->offset = parser_trx_real_offset(mtd, trx.offset[i]); + i++; + } + + if (trx.offset[i]) { + part = &parts[curr_part++]; +- part->name = parser_trx_data_part_name(mtd, trx.offset[i]); +- part->offset = trx.offset[i]; ++ part->offset = parser_trx_real_offset(mtd, trx.offset[i]); ++ part->name = parser_trx_data_part_name(mtd, part->offset); + i++; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch new file mode 100755 index 0000000..852654d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/432-mtd-bcm47xxpart-detect-T_Meter-partition.patch @@ -0,0 +1,37 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Subject: mtd: bcm47xxpart: detect T_Meter partition + +It can be found on many Netgear devices. It consists of many 0x30 blocks +starting with 4D 54. + +Signed-off-by: RafaΕ‚ MiΕ‚ecki +--- + drivers/mtd/bcm47xxpart.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/mtd/parsers/bcm47xxpart.c ++++ b/drivers/mtd/parsers/bcm47xxpart.c +@@ -35,6 +35,7 @@ + #define NVRAM_HEADER 0x48534C46 /* FLSH */ + #define POT_MAGIC1 0x54544f50 /* POTT */ + #define POT_MAGIC2 0x504f /* OP */ ++#define T_METER_MAGIC 0x4D540000 /* MT */ + #define ML_MAGIC1 0x39685a42 + #define ML_MAGIC2 0x26594131 + #define TRX_MAGIC 0x30524448 +@@ -178,6 +179,15 @@ static int bcm47xxpart_parse(struct mtd_ + MTD_WRITEABLE); + continue; + } ++ ++ /* T_Meter */ ++ if ((le32_to_cpu(buf[0x000 / 4]) & 0xFFFF0000) == T_METER_MAGIC && ++ (le32_to_cpu(buf[0x030 / 4]) & 0xFFFF0000) == T_METER_MAGIC && ++ (le32_to_cpu(buf[0x060 / 4]) & 0xFFFF0000) == T_METER_MAGIC) { ++ bcm47xxpart_add_part(&parts[curr_part++], "T_Meter", offset, ++ MTD_WRITEABLE); ++ continue; ++ } + + /* TRX */ + if (buf[0x000 / 4] == TRX_MAGIC) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/435-mtd-add-routerbootpart-parser-config.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/435-mtd-add-routerbootpart-parser-config.patch new file mode 100755 index 0000000..d516e1d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/435-mtd-add-routerbootpart-parser-config.patch @@ -0,0 +1,38 @@ +From 4437e01fb6bca63fccdba5d6c44888b0935885c2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= +Date: Tue, 24 Mar 2020 11:45:07 +0100 +Subject: [PATCH] generic: routerboot partition build bits (5.4) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch adds routerbootpart kernel build bits + +Signed-off-by: Thibaut VARÈNE +--- + drivers/mtd/parsers/Kconfig | 9 +++++++++ + drivers/mtd/parsers/Makefile | 1 + + 2 files changed, 10 insertions(+) + +--- a/drivers/mtd/parsers/Kconfig ++++ b/drivers/mtd/parsers/Kconfig +@@ -231,3 +231,12 @@ config MTD_SERCOMM_PARTS + partition map. This partition table contains real partition + offsets, which may differ from device to device depending on the + number and location of bad blocks on NAND. ++ ++config MTD_ROUTERBOOT_PARTS ++ tristate "RouterBoot flash partition parser" ++ depends on MTD && OF ++ help ++ MikroTik RouterBoot is implemented as a multi segment system on the ++ flash, some of which are fixed and some of which are located at ++ variable offsets. This parser handles both cases via properly ++ formatted DTS. +--- a/drivers/mtd/parsers/Makefile ++++ b/drivers/mtd/parsers/Makefile +@@ -16,3 +16,4 @@ obj-$(CONFIG_MTD_SERCOMM_PARTS) += scpa + obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o + obj-$(CONFIG_MTD_QCOMSMEM_PARTS) += qcomsmempart.o ++obj-$(CONFIG_MTD_ROUTERBOOT_PARTS) += routerbootpart.o diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/450-block-allow-setting-partition-of_node.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/450-block-allow-setting-partition-of_node.patch new file mode 100755 index 0000000..a3c8abc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/450-block-allow-setting-partition-of_node.patch @@ -0,0 +1,123 @@ +From decc6959a423c8617e87244fd269129fc4e7d0e6 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 7 Oct 2024 23:36:14 +0100 +Subject: [PATCH 1/8] block: allow setting partition of_node + +Allow partition parsers to set the Device Tree node for a partition by +introducing of_put_partition() and extending struct parsed_partitions +accordingly. + +As the partition information is preallocated independently of the actual +number of partitions the additional pointer takes about 2 kiB of allocated +memory which is worth avoiding in case CONFIG_OF is not set. This is +achieved by only adding the corresponding field to the struct in case +CONFIG_OF is set using #ifdef'ery. + +Signed-off-by: Daniel Golle +--- + block/partitions/check.h | 16 +++++++++++++++- + block/partitions/core.c | 14 +++++++++++--- + 2 files changed, 26 insertions(+), 4 deletions(-) + +--- a/block/partitions/check.h ++++ b/block/partitions/check.h +@@ -1,6 +1,7 @@ + /* SPDX-License-Identifier: GPL-2.0 */ + #include + #include ++#include + #include "../blk.h" + + /* +@@ -16,6 +17,9 @@ struct parsed_partitions { + int flags; + bool has_info; + struct partition_meta_info info; ++#ifdef CONFIG_OF ++ struct device_node *np; ++#endif + } *parts; + int next; + int limit; +@@ -34,18 +38,28 @@ static inline void put_dev_sector(Sector + } + + static inline void +-put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size) ++of_put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size, ++ struct device_node *np) + { + if (n < p->limit) { + char tmp[1 + BDEVNAME_SIZE + 10 + 1]; + + p->parts[n].from = from; + p->parts[n].size = size; ++#ifdef CONFIG_OF ++ p->parts[n].np = np; ++#endif + snprintf(tmp, sizeof(tmp), " %s%d", p->name, n); + strlcat(p->pp_buf, tmp, PAGE_SIZE); + } + } + ++static inline void ++put_partition(struct parsed_partitions *p, int n, sector_t from, sector_t size) ++{ ++ of_put_partition(p, n, from, size, NULL); ++} ++ + /* detection routines go here in alphabetical order: */ + int adfspart_check_ADFS(struct parsed_partitions *state); + int adfspart_check_CUMANA(struct parsed_partitions *state); +--- a/block/partitions/core.c ++++ b/block/partitions/core.c +@@ -9,6 +9,7 @@ + #include + #include + #include ++#include + #include + #include "check.h" + +@@ -290,7 +291,8 @@ static const DEVICE_ATTR(whole_disk, 044 + */ + static struct block_device *add_partition(struct gendisk *disk, int partno, + sector_t start, sector_t len, int flags, +- struct partition_meta_info *info) ++ struct partition_meta_info *info, ++ struct device_node *np) + { + dev_t devt = MKDEV(0, 0); + struct device *ddev = disk_to_dev(disk); +@@ -339,6 +341,7 @@ static struct block_device *add_partitio + pdev->class = &block_class; + pdev->type = &part_type; + pdev->parent = ddev; ++ device_set_node(pdev, of_fwnode_handle(np)); + + /* in consecutive minor range? */ + if (bdev_partno(bdev) < disk->minors) { +@@ -445,7 +448,7 @@ int bdev_add_partition(struct gendisk *d + } + + part = add_partition(disk, partno, start, length, +- ADDPART_FLAG_NONE, NULL); ++ ADDPART_FLAG_NONE, NULL, NULL); + ret = PTR_ERR_OR_ZERO(part); + out: + mutex_unlock(&disk->open_mutex); +@@ -559,8 +562,13 @@ static bool blk_add_partition(struct gen + size = get_capacity(disk) - from; + } + ++#ifdef CONFIG_OF + part = add_partition(disk, p, from, size, state->parts[p].flags, +- &state->parts[p].info); ++ &state->parts[p].info, state->parts[p].np); ++#else ++ part = add_partition(disk, p, from, size, state->parts[p].flags, ++ &state->parts[p].info, NULL); ++#endif + if (IS_ERR(part)) { + if (PTR_ERR(part) != -ENXIO) { + printk(KERN_ERR " %s: p%d could not be added: %pe\n", diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/451-block-partitions-of-assign-Device-Tree-node-to-parti.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/451-block-partitions-of-assign-Device-Tree-node-to-parti.patch new file mode 100755 index 0000000..f9e41d0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/451-block-partitions-of-assign-Device-Tree-node-to-parti.patch @@ -0,0 +1,25 @@ +From 5d265996597a6b0d654bbeda1bc3bae197061de7 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 7 Oct 2024 23:43:32 +0100 +Subject: [PATCH 2/8] block: partitions: of: assign Device Tree node to + partition + +Assign partition of_node so other drivers are able to identify a +partition by its Device Tree node. + +Signed-off-by: Daniel Golle +--- + block/partitions/of.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/block/partitions/of.c ++++ b/block/partitions/of.c +@@ -48,7 +48,7 @@ static void add_of_partition(struct pars + u64 offset = of_read_number(reg, a_cells) / SECTOR_SIZE; + u64 size = of_read_number(reg + a_cells, s_cells) / SECTOR_SIZE; + +- put_partition(state, slot, offset, size); ++ of_put_partition(state, slot, offset, size, np); + + if (of_property_read_bool(np, "read-only")) + state->parts[slot].flags |= ADDPART_FLAG_READONLY; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/452-partitions-efi-apply-Linux-code-style.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/452-partitions-efi-apply-Linux-code-style.patch new file mode 100755 index 0000000..6e996ca --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/452-partitions-efi-apply-Linux-code-style.patch @@ -0,0 +1,498 @@ +From d4e82837c8b86ff2c21fa923271908988bc72faa Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 7 Oct 2024 23:22:53 +0100 +Subject: [PATCH 3/8] partitions/efi: apply Linux code style + +Fix (mostly white space related) coding style issues in +block/partitions/efi.c by use of clang-format. + +Signed-off-by: Daniel Golle +--- + block/partitions/efi.c | 235 +++++++++++++++++++++-------------------- + 1 file changed, 121 insertions(+), 114 deletions(-) + +--- a/block/partitions/efi.c ++++ b/block/partitions/efi.c +@@ -95,15 +95,13 @@ + * the partition tables happens after init too. + */ + static int force_gpt; +-static int __init +-force_gpt_fn(char *str) ++static int __init force_gpt_fn(char *str) + { + force_gpt = 1; + return 1; + } + __setup("gpt", force_gpt_fn); + +- + /** + * efi_crc32() - EFI version of crc32 function + * @buf: buffer to calculate crc32 of +@@ -116,8 +114,7 @@ __setup("gpt", force_gpt_fn); + * Note, the EFI Specification, v1.02, has a reference to + * Dr. Dobbs Journal, May 1994 (actually it's in May 1992). + */ +-static inline u32 +-efi_crc32(const void *buf, unsigned long len) ++static inline u32 efi_crc32(const void *buf, unsigned long len) + { + return (crc32(~0L, buf, len) ^ ~0L); + } +@@ -134,7 +131,8 @@ efi_crc32(const void *buf, unsigned long + static u64 last_lba(struct gendisk *disk) + { + return div_u64(bdev_nr_bytes(disk->part0), +- queue_logical_block_size(disk->queue)) - 1ULL; ++ queue_logical_block_size(disk->queue)) - ++ 1ULL; + } + + static inline int pmbr_part_valid(gpt_mbr_record *part) +@@ -195,7 +193,7 @@ static int is_pmbr_valid(legacy_mbr *mbr + check_hybrid: + for (i = 0; i < 4; i++) + if ((mbr->partition_record[i].os_type != +- EFI_PMBR_OSTYPE_EFI_GPT) && ++ EFI_PMBR_OSTYPE_EFI_GPT) && + (mbr->partition_record[i].os_type != 0x00)) + ret = GPT_MBR_HYBRID; + +@@ -213,10 +211,11 @@ check_hybrid: + */ + if (ret == GPT_MBR_PROTECTIVE) { + sz = le32_to_cpu(mbr->partition_record[part].size_in_lba); +- if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF) +- pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n", +- sz, min_t(uint32_t, +- total_sectors - 1, 0xFFFFFFFF)); ++ if (sz != (uint32_t)total_sectors - 1 && sz != 0xFFFFFFFF) ++ pr_debug( ++ "GPT: mbr size in lba (%u) different than whole disk (%u).\n", ++ sz, ++ min_t(uint32_t, total_sectors - 1, 0xFFFFFFFF)); + } + done: + return ret; +@@ -232,15 +231,14 @@ done: + * Description: Reads @count bytes from @state->disk into @buffer. + * Returns number of bytes read on success, 0 on error. + */ +-static size_t read_lba(struct parsed_partitions *state, +- u64 lba, u8 *buffer, size_t count) ++static size_t read_lba(struct parsed_partitions *state, u64 lba, u8 *buffer, ++ size_t count) + { + size_t totalreadcount = 0; +- sector_t n = lba * +- (queue_logical_block_size(state->disk->queue) / 512); ++ sector_t n = lba * (queue_logical_block_size(state->disk->queue) / 512); + + if (!buffer || lba > last_lba(state->disk)) +- return 0; ++ return 0; + + while (count) { + int copied = 512; +@@ -253,7 +251,7 @@ static size_t read_lba(struct parsed_par + memcpy(buffer, data, copied); + put_dev_sector(sect); + buffer += copied; +- totalreadcount +=copied; ++ totalreadcount += copied; + count -= copied; + } + return totalreadcount; +@@ -278,17 +276,17 @@ static gpt_entry *alloc_read_gpt_entries + return NULL; + + count = (size_t)le32_to_cpu(gpt->num_partition_entries) * +- le32_to_cpu(gpt->sizeof_partition_entry); ++ le32_to_cpu(gpt->sizeof_partition_entry); + if (!count) + return NULL; + pte = kmalloc(count, GFP_KERNEL); + if (!pte) + return NULL; + +- if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba), +- (u8 *) pte, count) < count) { ++ if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba), (u8 *)pte, ++ count) < count) { + kfree(pte); +- pte=NULL; ++ pte = NULL; + return NULL; + } + return pte; +@@ -313,9 +311,9 @@ static gpt_header *alloc_read_gpt_header + if (!gpt) + return NULL; + +- if (read_lba(state, lba, (u8 *) gpt, ssz) < ssz) { ++ if (read_lba(state, lba, (u8 *)gpt, ssz) < ssz) { + kfree(gpt); +- gpt=NULL; ++ gpt = NULL; + return NULL; + } + +@@ -354,8 +352,9 @@ static int is_gpt_valid(struct parsed_pa + + /* Check the GUID Partition Table header size is too big */ + if (le32_to_cpu((*gpt)->header_size) > +- queue_logical_block_size(state->disk->queue)) { +- pr_debug("GUID Partition Table Header size is too large: %u > %u\n", ++ queue_logical_block_size(state->disk->queue)) { ++ pr_debug( ++ "GUID Partition Table Header size is too large: %u > %u\n", + le32_to_cpu((*gpt)->header_size), + queue_logical_block_size(state->disk->queue)); + goto fail; +@@ -363,16 +362,17 @@ static int is_gpt_valid(struct parsed_pa + + /* Check the GUID Partition Table header size is too small */ + if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) { +- pr_debug("GUID Partition Table Header size is too small: %u < %zu\n", +- le32_to_cpu((*gpt)->header_size), +- sizeof(gpt_header)); ++ pr_debug( ++ "GUID Partition Table Header size is too small: %u < %zu\n", ++ le32_to_cpu((*gpt)->header_size), sizeof(gpt_header)); + goto fail; + } + + /* Check the GUID Partition Table CRC */ + origcrc = le32_to_cpu((*gpt)->header_crc32); + (*gpt)->header_crc32 = 0; +- crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size)); ++ crc = efi_crc32((const unsigned char *)(*gpt), ++ le32_to_cpu((*gpt)->header_size)); + + if (crc != origcrc) { + pr_debug("GUID Partition Table Header CRC is wrong: %x != %x\n", +@@ -396,20 +396,25 @@ static int is_gpt_valid(struct parsed_pa + lastlba = last_lba(state->disk); + if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) { + pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n", +- (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba), ++ (unsigned long long)le64_to_cpu( ++ (*gpt)->first_usable_lba), + (unsigned long long)lastlba); + goto fail; + } + if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) { + pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", +- (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), ++ (unsigned long long)le64_to_cpu( ++ (*gpt)->last_usable_lba), + (unsigned long long)lastlba); + goto fail; + } +- if (le64_to_cpu((*gpt)->last_usable_lba) < le64_to_cpu((*gpt)->first_usable_lba)) { ++ if (le64_to_cpu((*gpt)->last_usable_lba) < ++ le64_to_cpu((*gpt)->first_usable_lba)) { + pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", +- (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), +- (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba)); ++ (unsigned long long)le64_to_cpu( ++ (*gpt)->last_usable_lba), ++ (unsigned long long)le64_to_cpu( ++ (*gpt)->first_usable_lba)); + goto fail; + } + /* Check that sizeof_partition_entry has the correct value */ +@@ -420,10 +425,11 @@ static int is_gpt_valid(struct parsed_pa + + /* Sanity check partition table size */ + pt_size = (u64)le32_to_cpu((*gpt)->num_partition_entries) * +- le32_to_cpu((*gpt)->sizeof_partition_entry); ++ le32_to_cpu((*gpt)->sizeof_partition_entry); + if (pt_size > KMALLOC_MAX_SIZE) { +- pr_debug("GUID Partition Table is too large: %llu > %lu bytes\n", +- (unsigned long long)pt_size, KMALLOC_MAX_SIZE); ++ pr_debug( ++ "GUID Partition Table is too large: %llu > %lu bytes\n", ++ (unsigned long long)pt_size, KMALLOC_MAX_SIZE); + goto fail; + } + +@@ -431,7 +437,7 @@ static int is_gpt_valid(struct parsed_pa + goto fail; + + /* Check the GUID Partition Entry Array CRC */ +- crc = efi_crc32((const unsigned char *) (*ptes), pt_size); ++ crc = efi_crc32((const unsigned char *)(*ptes), pt_size); + + if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) { + pr_debug("GUID Partition Entry Array CRC check failed.\n"); +@@ -441,10 +447,10 @@ static int is_gpt_valid(struct parsed_pa + /* We're done, all's well */ + return 1; + +- fail_ptes: ++fail_ptes: + kfree(*ptes); + *ptes = NULL; +- fail: ++fail: + kfree(*gpt); + *gpt = NULL; + return 0; +@@ -457,12 +463,11 @@ static int is_gpt_valid(struct parsed_pa + * + * Description: returns 1 if valid, 0 on error. + */ +-static inline int +-is_pte_valid(const gpt_entry *pte, const u64 lastlba) ++static inline int is_pte_valid(const gpt_entry *pte, const u64 lastlba) + { + if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) || +- le64_to_cpu(pte->starting_lba) > lastlba || +- le64_to_cpu(pte->ending_lba) > lastlba) ++ le64_to_cpu(pte->starting_lba) > lastlba || ++ le64_to_cpu(pte->ending_lba) > lastlba) + return 0; + return 1; + } +@@ -477,8 +482,7 @@ is_pte_valid(const gpt_entry *pte, const + * and prints warnings on discrepancies. + * + */ +-static void +-compare_gpts(gpt_header *pgpt, gpt_header *agpt, u64 lastlba) ++static void compare_gpts(gpt_header *pgpt, gpt_header *agpt, u64 lastlba) + { + int error_found = 0; + if (!pgpt || !agpt) +@@ -486,31 +490,32 @@ compare_gpts(gpt_header *pgpt, gpt_heade + if (le64_to_cpu(pgpt->my_lba) != le64_to_cpu(agpt->alternate_lba)) { + pr_warn("GPT:Primary header LBA != Alt. header alternate_lba\n"); + pr_warn("GPT:%lld != %lld\n", +- (unsigned long long)le64_to_cpu(pgpt->my_lba), +- (unsigned long long)le64_to_cpu(agpt->alternate_lba)); ++ (unsigned long long)le64_to_cpu(pgpt->my_lba), ++ (unsigned long long)le64_to_cpu(agpt->alternate_lba)); + error_found++; + } + if (le64_to_cpu(pgpt->alternate_lba) != le64_to_cpu(agpt->my_lba)) { + pr_warn("GPT:Primary header alternate_lba != Alt. header my_lba\n"); + pr_warn("GPT:%lld != %lld\n", +- (unsigned long long)le64_to_cpu(pgpt->alternate_lba), +- (unsigned long long)le64_to_cpu(agpt->my_lba)); ++ (unsigned long long)le64_to_cpu(pgpt->alternate_lba), ++ (unsigned long long)le64_to_cpu(agpt->my_lba)); + error_found++; + } + if (le64_to_cpu(pgpt->first_usable_lba) != +- le64_to_cpu(agpt->first_usable_lba)) { ++ le64_to_cpu(agpt->first_usable_lba)) { + pr_warn("GPT:first_usable_lbas don't match.\n"); + pr_warn("GPT:%lld != %lld\n", +- (unsigned long long)le64_to_cpu(pgpt->first_usable_lba), +- (unsigned long long)le64_to_cpu(agpt->first_usable_lba)); ++ (unsigned long long)le64_to_cpu(pgpt->first_usable_lba), ++ (unsigned long long)le64_to_cpu( ++ agpt->first_usable_lba)); + error_found++; + } + if (le64_to_cpu(pgpt->last_usable_lba) != +- le64_to_cpu(agpt->last_usable_lba)) { ++ le64_to_cpu(agpt->last_usable_lba)) { + pr_warn("GPT:last_usable_lbas don't match.\n"); + pr_warn("GPT:%lld != %lld\n", +- (unsigned long long)le64_to_cpu(pgpt->last_usable_lba), +- (unsigned long long)le64_to_cpu(agpt->last_usable_lba)); ++ (unsigned long long)le64_to_cpu(pgpt->last_usable_lba), ++ (unsigned long long)le64_to_cpu(agpt->last_usable_lba)); + error_found++; + } + if (efi_guidcmp(pgpt->disk_guid, agpt->disk_guid)) { +@@ -518,27 +523,27 @@ compare_gpts(gpt_header *pgpt, gpt_heade + error_found++; + } + if (le32_to_cpu(pgpt->num_partition_entries) != +- le32_to_cpu(agpt->num_partition_entries)) { ++ le32_to_cpu(agpt->num_partition_entries)) { + pr_warn("GPT:num_partition_entries don't match: " +- "0x%x != 0x%x\n", +- le32_to_cpu(pgpt->num_partition_entries), +- le32_to_cpu(agpt->num_partition_entries)); ++ "0x%x != 0x%x\n", ++ le32_to_cpu(pgpt->num_partition_entries), ++ le32_to_cpu(agpt->num_partition_entries)); + error_found++; + } + if (le32_to_cpu(pgpt->sizeof_partition_entry) != +- le32_to_cpu(agpt->sizeof_partition_entry)) { ++ le32_to_cpu(agpt->sizeof_partition_entry)) { + pr_warn("GPT:sizeof_partition_entry values don't match: " +- "0x%x != 0x%x\n", +- le32_to_cpu(pgpt->sizeof_partition_entry), +- le32_to_cpu(agpt->sizeof_partition_entry)); ++ "0x%x != 0x%x\n", ++ le32_to_cpu(pgpt->sizeof_partition_entry), ++ le32_to_cpu(agpt->sizeof_partition_entry)); + error_found++; + } + if (le32_to_cpu(pgpt->partition_entry_array_crc32) != +- le32_to_cpu(agpt->partition_entry_array_crc32)) { ++ le32_to_cpu(agpt->partition_entry_array_crc32)) { + pr_warn("GPT:partition_entry_array_crc32 values don't match: " +- "0x%x != 0x%x\n", +- le32_to_cpu(pgpt->partition_entry_array_crc32), +- le32_to_cpu(agpt->partition_entry_array_crc32)); ++ "0x%x != 0x%x\n", ++ le32_to_cpu(pgpt->partition_entry_array_crc32), ++ le32_to_cpu(agpt->partition_entry_array_crc32)); + error_found++; + } + if (le64_to_cpu(pgpt->alternate_lba) != lastlba) { +@@ -594,7 +599,7 @@ static int find_valid_gpt(struct parsed_ + return 0; + + lastlba = last_lba(state->disk); +- if (!force_gpt) { ++ if (!force_gpt) { + /* This will be added to the EFI Spec. per Intel after v1.02. */ + legacymbr = kzalloc(sizeof(*legacymbr), GFP_KERNEL); + if (!legacymbr) +@@ -608,18 +613,17 @@ static int find_valid_gpt(struct parsed_ + goto fail; + + pr_debug("Device has a %s MBR\n", +- good_pmbr == GPT_MBR_PROTECTIVE ? +- "protective" : "hybrid"); ++ good_pmbr == GPT_MBR_PROTECTIVE ? "protective" : ++ "hybrid"); + } + +- good_pgpt = is_gpt_valid(state, GPT_PRIMARY_PARTITION_TABLE_LBA, +- &pgpt, &pptes); +- if (good_pgpt) +- good_agpt = is_gpt_valid(state, +- le64_to_cpu(pgpt->alternate_lba), +- &agpt, &aptes); +- if (!good_agpt && force_gpt) +- good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes); ++ good_pgpt = is_gpt_valid(state, GPT_PRIMARY_PARTITION_TABLE_LBA, &pgpt, ++ &pptes); ++ if (good_pgpt) ++ good_agpt = is_gpt_valid( ++ state, le64_to_cpu(pgpt->alternate_lba), &agpt, &aptes); ++ if (!good_agpt && force_gpt) ++ good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes); + + if (!good_agpt && force_gpt && fops->alternative_gpt_sector) { + sector_t agpt_sector; +@@ -627,43 +631,42 @@ static int find_valid_gpt(struct parsed_ + + err = fops->alternative_gpt_sector(disk, &agpt_sector); + if (!err) +- good_agpt = is_gpt_valid(state, agpt_sector, +- &agpt, &aptes); ++ good_agpt = ++ is_gpt_valid(state, agpt_sector, &agpt, &aptes); + } + +- /* The obviously unsuccessful case */ +- if (!good_pgpt && !good_agpt) +- goto fail; +- +- compare_gpts(pgpt, agpt, lastlba); +- +- /* The good cases */ +- if (good_pgpt) { +- *gpt = pgpt; +- *ptes = pptes; +- kfree(agpt); +- kfree(aptes); ++ /* The obviously unsuccessful case */ ++ if (!good_pgpt && !good_agpt) ++ goto fail; ++ ++ compare_gpts(pgpt, agpt, lastlba); ++ ++ /* The good cases */ ++ if (good_pgpt) { ++ *gpt = pgpt; ++ *ptes = pptes; ++ kfree(agpt); ++ kfree(aptes); + if (!good_agpt) +- pr_warn("Alternate GPT is invalid, using primary GPT.\n"); +- return 1; +- } +- else if (good_agpt) { +- *gpt = agpt; +- *ptes = aptes; +- kfree(pgpt); +- kfree(pptes); ++ pr_warn("Alternate GPT is invalid, using primary GPT.\n"); ++ return 1; ++ } else if (good_agpt) { ++ *gpt = agpt; ++ *ptes = aptes; ++ kfree(pgpt); ++ kfree(pptes); + pr_warn("Primary GPT is invalid, using alternate GPT.\n"); +- return 1; +- } ++ return 1; ++ } + +- fail: +- kfree(pgpt); +- kfree(agpt); +- kfree(pptes); +- kfree(aptes); +- *gpt = NULL; +- *ptes = NULL; +- return 0; ++fail: ++ kfree(pgpt); ++ kfree(agpt); ++ kfree(pptes); ++ kfree(aptes); ++ *gpt = NULL; ++ *ptes = NULL; ++ return 0; + } + + /** +@@ -725,7 +728,9 @@ int efi_partition(struct parsed_partitio + + pr_debug("GUID Partition Table is valid! Yea!\n"); + +- for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { ++ for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && ++ i < state->limit - 1; ++ i++) { + struct partition_meta_info *info; + unsigned label_max; + u64 start = le64_to_cpu(ptes[i].starting_lba); +@@ -735,10 +740,11 @@ int efi_partition(struct parsed_partitio + if (!is_pte_valid(&ptes[i], last_lba(state->disk))) + continue; + +- put_partition(state, i+1, start * ssz, size * ssz); ++ put_partition(state, i + 1, start * ssz, size * ssz); + + /* If this is a RAID volume, tell md */ +- if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID)) ++ if (!efi_guidcmp(ptes[i].partition_type_guid, ++ PARTITION_LINUX_RAID_GUID)) + state->parts[i + 1].flags = ADDPART_FLAG_RAID; + + info = &state->parts[i + 1].info; +@@ -747,7 +753,8 @@ int efi_partition(struct parsed_partitio + /* Naively convert UTF16-LE to 7 bits. */ + label_max = min(ARRAY_SIZE(info->volname) - 1, + ARRAY_SIZE(ptes[i].partition_name)); +- utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname); ++ utf16_le_to_7bit(ptes[i].partition_name, label_max, ++ info->volname); + state->parts[i + 1].has_info = true; + } + kfree(ptes); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/453-partitions-efi-allow-assigning-partition-Device-Tree.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/453-partitions-efi-allow-assigning-partition-Device-Tree.patch new file mode 100755 index 0000000..cc2c203 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/453-partitions-efi-allow-assigning-partition-Device-Tree.patch @@ -0,0 +1,75 @@ +From f28e36c19b927671d93ccd2b5de3d518fccf721e Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 8 Oct 2024 00:25:12 +0100 +Subject: [PATCH 4/8] partitions/efi: allow assigning partition Device Tree + node + +Signed-off-by: Daniel Golle +--- + block/partitions/efi.c | 34 +++++++++++++++++++++++++++++++++- + 1 file changed, 33 insertions(+), 1 deletion(-) + +--- a/block/partitions/efi.c ++++ b/block/partitions/efi.c +@@ -86,6 +86,7 @@ + #include + #include + #include ++#include + #include + #include "check.h" + #include "efi.h" +@@ -694,6 +695,34 @@ static void utf16_le_to_7bit(const __le1 + } + } + ++static struct device_node *find_partition_of_node(struct device_node *partitions_np, ++ gpt_entry *ptes) ++{ ++ char volname[64], partuuid[UUID_STRING_LEN + 1]; ++ const char *uuid, *name; ++ ++ if (!partitions_np || ++ !of_device_is_compatible(partitions_np, "gpt-partitions")) ++ return NULL; ++ ++ efi_guid_to_str(&ptes->unique_partition_guid, partuuid); ++ utf16_le_to_7bit(ptes->partition_name, ARRAY_SIZE(volname) - 1, volname); ++ ++ for_each_available_child_of_node_scoped(partitions_np, np) { ++ if (!of_property_read_string(np, "uuid", &uuid) && ++ strncmp(uuid, partuuid, ARRAY_SIZE(partuuid))) ++ continue; ++ ++ if (!of_property_read_string(np, "partname", &name) && ++ strncmp(name, volname, ARRAY_SIZE(volname))) ++ continue; ++ ++ return np; ++ } ++ ++ return NULL; ++} ++ + /** + * efi_partition - scan for GPT partitions + * @state: disk parsed partitions +@@ -719,6 +748,8 @@ int efi_partition(struct parsed_partitio + gpt_entry *ptes = NULL; + u32 i; + unsigned ssz = queue_logical_block_size(state->disk->queue) / 512; ++ struct device *ddev = disk_to_dev(state->disk); ++ struct device_node *partitions_np = of_node_get(ddev->of_node); + + if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { + kfree(gpt); +@@ -740,7 +771,8 @@ int efi_partition(struct parsed_partitio + if (!is_pte_valid(&ptes[i], last_lba(state->disk))) + continue; + +- put_partition(state, i + 1, start * ssz, size * ssz); ++ of_put_partition(state, i + 1, start * ssz, size * ssz, ++ find_partition_of_node(partitions_np, &ptes[i])); + + /* If this is a RAID volume, tell md */ + if (!efi_guidcmp(ptes[i].partition_type_guid, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/454-block-add-support-for-notifications.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/454-block-add-support-for-notifications.patch new file mode 100755 index 0000000..6a5abef --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/454-block-add-support-for-notifications.patch @@ -0,0 +1,164 @@ +From 858df9db80c1568db255659baca7602504f823af Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 15 May 2024 08:19:51 +0100 +Subject: [PATCH 5/8] block: add support for notifications + +Add notifier block to notify other subsystems about the addition or +removal of block devices. + +Signed-off-by: Daniel Golle +--- + block/Kconfig | 6 +++ + block/Makefile | 1 + + block/blk-notify.c | 107 +++++++++++++++++++++++++++++++++++++++++ + include/linux/blkdev.h | 8 +++ + 4 files changed, 122 insertions(+) + create mode 100644 block/blk-notify.c + +--- a/block/Kconfig ++++ b/block/Kconfig +@@ -209,6 +209,12 @@ config BLK_INLINE_ENCRYPTION_FALLBACK + by falling back to the kernel crypto API when inline + encryption hardware is not present. + ++config BLOCK_NOTIFIERS ++ bool "Enable support for notifications in block layer" ++ help ++ Enable this option to provide notifiers for other subsystems ++ upon addition or removal of block devices. ++ + source "block/partitions/Kconfig" + + config BLK_MQ_PCI +--- a/block/Makefile ++++ b/block/Makefile +@@ -38,3 +38,4 @@ obj-$(CONFIG_BLK_INLINE_ENCRYPTION) += b + blk-crypto-sysfs.o + obj-$(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) += blk-crypto-fallback.o + obj-$(CONFIG_BLOCK_HOLDER_DEPRECATED) += holder.o ++obj-$(CONFIG_BLOCK_NOTIFIERS) += blk-notify.o +--- /dev/null ++++ b/block/blk-notify.c +@@ -0,0 +1,107 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* ++ * Notifiers for addition and removal of block devices ++ * ++ * Copyright (c) 2024 Daniel Golle ++ */ ++ ++#include ++#include ++#include ++#include ++ ++#include "blk.h" ++ ++struct blk_device_list { ++ struct device *dev; ++ struct list_head list; ++}; ++ ++static RAW_NOTIFIER_HEAD(blk_notifier_list); ++static DEFINE_MUTEX(blk_notifier_lock); ++static LIST_HEAD(blk_devices); ++ ++struct blk_notify_event { ++ struct delayed_work work; ++ struct device *dev; ++}; ++ ++void blk_register_notify(struct notifier_block *nb) ++{ ++ struct blk_device_list *existing_blkdev; ++ ++ mutex_lock(&blk_notifier_lock); ++ raw_notifier_chain_register(&blk_notifier_list, nb); ++ ++ list_for_each_entry(existing_blkdev, &blk_devices, list) ++ nb->notifier_call(nb, BLK_DEVICE_ADD, existing_blkdev->dev); ++ ++ mutex_unlock(&blk_notifier_lock); ++} ++EXPORT_SYMBOL_GPL(blk_register_notify); ++ ++void blk_unregister_notify(struct notifier_block *nb) ++{ ++ mutex_lock(&blk_notifier_lock); ++ raw_notifier_chain_unregister(&blk_notifier_list, nb); ++ mutex_unlock(&blk_notifier_lock); ++} ++EXPORT_SYMBOL_GPL(blk_unregister_notify); ++ ++static void blk_notify_work(struct work_struct *work) ++{ ++ struct blk_notify_event *ev = ++ container_of(work, struct blk_notify_event, work.work); ++ ++ raw_notifier_call_chain(&blk_notifier_list, BLK_DEVICE_ADD, ev->dev); ++ kfree(ev); ++} ++ ++static int blk_call_notifier_add(struct device *dev) ++{ ++ struct blk_device_list *new_blkdev; ++ struct blk_notify_event *ev; ++ ++ new_blkdev = kmalloc(sizeof (*new_blkdev), GFP_KERNEL); ++ if (!new_blkdev) ++ return -ENOMEM; ++ ++ ev = kmalloc(sizeof(*ev), GFP_KERNEL); ++ INIT_DEFERRABLE_WORK(&ev->work, blk_notify_work); ++ ev->dev = dev; ++ new_blkdev->dev = dev; ++ mutex_lock(&blk_notifier_lock); ++ list_add_tail(&new_blkdev->list, &blk_devices); ++ schedule_delayed_work(&ev->work, msecs_to_jiffies(500)); ++ mutex_unlock(&blk_notifier_lock); ++ ++ return 0; ++} ++ ++static void blk_call_notifier_remove(struct device *dev) ++{ ++ struct blk_device_list *old_blkdev, *tmp; ++ ++ mutex_lock(&blk_notifier_lock); ++ list_for_each_entry_safe(old_blkdev, tmp, &blk_devices, list) { ++ if (old_blkdev->dev != dev) ++ continue; ++ ++ list_del(&old_blkdev->list); ++ kfree(old_blkdev); ++ } ++ raw_notifier_call_chain(&blk_notifier_list, BLK_DEVICE_REMOVE, dev); ++ mutex_unlock(&blk_notifier_lock); ++} ++ ++static struct class_interface blk_notifications_bus_interface __refdata = { ++ .class = &block_class, ++ .add_dev = &blk_call_notifier_add, ++ .remove_dev = &blk_call_notifier_remove, ++}; ++ ++static int __init blk_notifications_init(void) ++{ ++ return class_interface_register(&blk_notifications_bus_interface); ++} ++device_initcall(blk_notifications_init); +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -1753,4 +1753,12 @@ static inline bool bdev_can_atomic_write + + #define DEFINE_IO_COMP_BATCH(name) struct io_comp_batch name = { } + ++ ++#ifdef CONFIG_BLOCK_NOTIFIERS ++#define BLK_DEVICE_ADD 1 ++#define BLK_DEVICE_REMOVE 2 ++extern void blk_register_notify(struct notifier_block *nb); ++extern void blk_unregister_notify(struct notifier_block *nb); ++#endif ++ + #endif /* _LINUX_BLKDEV_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/455-block-add-new-genhd-flag-GENHD_FL_NVMEM.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/455-block-add-new-genhd-flag-GENHD_FL_NVMEM.patch new file mode 100755 index 0000000..4f9a26f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/455-block-add-new-genhd-flag-GENHD_FL_NVMEM.patch @@ -0,0 +1,29 @@ +From 2b28bf485b283991eea9f00c5831c1c39c73991f Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 21 Mar 2024 19:33:49 +0000 +Subject: [PATCH 6/8] block: add new genhd flag GENHD_FL_NVMEM + +Add new flag to destinguish block devices which may act as an NVMEM +provider. + +Signed-off-by: Daniel Golle +--- + include/linux/blkdev.h | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -82,11 +82,13 @@ struct partition_meta_info { + * ``GENHD_FL_NO_PART``: partition support is disabled. The kernel will not + * scan for partitions from add_disk, and users can't add partitions manually. + * ++ * ``GENHD_FL_NVMEM``: the block device should be considered as NVMEM provider. + */ + enum { + GENHD_FL_REMOVABLE = 1 << 0, + GENHD_FL_HIDDEN = 1 << 1, + GENHD_FL_NO_PART = 1 << 2, ++ GENHD_FL_NVMEM = 1 << 3, + }; + + enum { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/456-nvmem-implement-block-NVMEM-provider.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/456-nvmem-implement-block-NVMEM-provider.patch new file mode 100755 index 0000000..563b9f1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/456-nvmem-implement-block-NVMEM-provider.patch @@ -0,0 +1,250 @@ +From 26ae98bf77fdbd60536fe5c2175e528469b9ac9a Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 15 May 2024 18:18:37 +0300 +Subject: [PATCH 7/8] nvmem: implement block NVMEM provider + +On embedded devices using an eMMC it is common that one or more partitions +on the eMMC are used to store MAC addresses and Wi-Fi calibration EEPROM +data. Allow referencing any block device or partition in Device Tree to +allow e.g. Ethernet and Wi-Fi drivers accessing them via the NVMEM layer. + +Signed-off-by: Daniel Golle +--- + drivers/nvmem/Kconfig | 11 +++ + drivers/nvmem/Makefile | 2 + + drivers/nvmem/block.c | 198 +++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 211 insertions(+) + create mode 100644 drivers/nvmem/block.c + +--- a/drivers/nvmem/Kconfig ++++ b/drivers/nvmem/Kconfig +@@ -40,6 +40,17 @@ config NVMEM_APPLE_EFUSES + This driver can also be built as a module. If so, the module will + be called nvmem-apple-efuses. + ++config NVMEM_BLOCK ++ tristate "Block device NVMEM provider" ++ depends on BLOCK ++ depends on OF ++ depends on NVMEM ++ select BLOCK_NOTIFIERS ++ help ++ Allow block devices (or partitions) to act as NVMEM prodivers, ++ typically used with eMMC to store MAC addresses or Wi-Fi ++ calibration data on embedded devices. ++ + config NVMEM_BCM_OCOTP + tristate "Broadcom On-Chip OTP Controller support" + depends on ARCH_BCM_IPROC || COMPILE_TEST +--- a/drivers/nvmem/Makefile ++++ b/drivers/nvmem/Makefile +@@ -14,6 +14,8 @@ obj-$(CONFIG_NVMEM_APPLE_EFUSES) += nvme + nvmem-apple-efuses-y := apple-efuses.o + obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o + nvmem-bcm-ocotp-y := bcm-ocotp.o ++obj-$(CONFIG_NVMEM_BLOCK) += nvmem-block.o ++nvmem-block-y := block.o + obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o + nvmem_brcm_nvram-y := brcm_nvram.o + obj-$(CONFIG_NVMEM_IMX_IIM) += nvmem-imx-iim.o +--- /dev/null ++++ b/drivers/nvmem/block.c +@@ -0,0 +1,198 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++/* ++ * block device NVMEM provider ++ * ++ * Copyright (c) 2024 Daniel Golle ++ * ++ * Useful on devices using a partition on an eMMC for MAC addresses or ++ * Wi-Fi calibration EEPROM data. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++/* List of all NVMEM devices */ ++static LIST_HEAD(nvmem_devices); ++static DEFINE_MUTEX(devices_mutex); ++ ++struct blk_nvmem { ++ struct nvmem_device *nvmem; ++ struct device *dev; ++ struct list_head list; ++}; ++ ++static int blk_nvmem_reg_read(void *priv, unsigned int from, ++ void *val, size_t bytes) ++{ ++ blk_mode_t mode = BLK_OPEN_READ | BLK_OPEN_RESTRICT_WRITES; ++ unsigned long offs = from & ~PAGE_MASK, to_read; ++ pgoff_t f_index = from >> PAGE_SHIFT; ++ struct blk_nvmem *bnv = priv; ++ size_t bytes_left = bytes; ++ struct file *bdev_file; ++ struct folio *folio; ++ void *p; ++ int ret = 0; ++ ++ bdev_file = bdev_file_open_by_dev(bnv->dev->devt, mode, priv, NULL); ++ if (!bdev_file) ++ return -ENODEV; ++ ++ if (IS_ERR(bdev_file)) ++ return PTR_ERR(bdev_file); ++ ++ while (bytes_left) { ++ folio = read_mapping_folio(bdev_file->f_mapping, f_index++, NULL); ++ if (IS_ERR(folio)) { ++ ret = PTR_ERR(folio); ++ goto err_release_bdev; ++ } ++ to_read = min_t(unsigned long, bytes_left, PAGE_SIZE - offs); ++ p = folio_address(folio) + offset_in_folio(folio, offs); ++ memcpy(val, p, to_read); ++ offs = 0; ++ bytes_left -= to_read; ++ val += to_read; ++ folio_put(folio); ++ } ++ ++err_release_bdev: ++ fput(bdev_file); ++ ++ return ret; ++} ++ ++static int blk_nvmem_register(struct device *dev) ++{ ++ struct block_device *bdev = dev_to_bdev(dev); ++ struct device_node *np = dev_of_node(dev); ++ struct nvmem_config config = {}; ++ struct blk_nvmem *bnv; ++ ++ /* skip devices which do not have a device tree node */ ++ if (!np) ++ return 0; ++ ++ /* skip devices without an nvmem layout defined */ ++ if (!of_get_child_by_name(np, "nvmem-layout")) ++ return 0; ++ ++ /* ++ * skip devices which don't have GENHD_FL_NVMEM set ++ * ++ * This flag is used for mtdblock and ubiblock devices because ++ * both, MTD and UBI already implement their own NVMEM provider. ++ * To avoid registering multiple NVMEM providers for the same ++ * device node, don't register the block NVMEM provider for them. ++ */ ++ if (!(bdev->bd_disk->flags & GENHD_FL_NVMEM)) ++ return 0; ++ ++ /* ++ * skip block device too large to be represented as NVMEM devices ++ * which are using an 'int' as address ++ */ ++ if (bdev_nr_bytes(bdev) > INT_MAX) ++ return -EFBIG; ++ ++ bnv = kzalloc(sizeof(struct blk_nvmem), GFP_KERNEL); ++ if (!bnv) ++ return -ENOMEM; ++ ++ config.id = NVMEM_DEVID_NONE; ++ config.dev = &bdev->bd_device; ++ config.name = dev_name(&bdev->bd_device); ++ config.owner = THIS_MODULE; ++ config.priv = bnv; ++ config.reg_read = blk_nvmem_reg_read; ++ config.size = bdev_nr_bytes(bdev); ++ config.word_size = 1; ++ config.stride = 1; ++ config.read_only = true; ++ config.root_only = true; ++ config.ignore_wp = true; ++ config.of_node = to_of_node(dev->fwnode); ++ ++ bnv->dev = &bdev->bd_device; ++ bnv->nvmem = nvmem_register(&config); ++ if (IS_ERR(bnv->nvmem)) { ++ dev_err_probe(&bdev->bd_device, PTR_ERR(bnv->nvmem), ++ "Failed to register NVMEM device\n"); ++ ++ kfree(bnv); ++ return PTR_ERR(bnv->nvmem); ++ } ++ ++ mutex_lock(&devices_mutex); ++ list_add_tail(&bnv->list, &nvmem_devices); ++ mutex_unlock(&devices_mutex); ++ ++ return 0; ++} ++ ++static void blk_nvmem_unregister(struct device *dev) ++{ ++ struct blk_nvmem *bnv_c, *bnv = NULL; ++ ++ mutex_lock(&devices_mutex); ++ list_for_each_entry(bnv_c, &nvmem_devices, list) { ++ if (bnv_c->dev == dev) { ++ bnv = bnv_c; ++ break; ++ } ++ } ++ ++ if (!bnv) { ++ mutex_unlock(&devices_mutex); ++ return; ++ } ++ ++ list_del(&bnv->list); ++ mutex_unlock(&devices_mutex); ++ nvmem_unregister(bnv->nvmem); ++ kfree(bnv); ++} ++ ++static int blk_nvmem_handler(struct notifier_block *this, unsigned long code, void *obj) ++{ ++ struct device *dev = (struct device *)obj; ++ ++ switch (code) { ++ case BLK_DEVICE_ADD: ++ return blk_nvmem_register(dev); ++ break; ++ case BLK_DEVICE_REMOVE: ++ blk_nvmem_unregister(dev); ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static struct notifier_block blk_nvmem_notifier = { ++ .notifier_call = blk_nvmem_handler, ++}; ++ ++static int __init blk_nvmem_init(void) ++{ ++ blk_register_notify(&blk_nvmem_notifier); ++ ++ return 0; ++} ++ ++static void __exit blk_nvmem_exit(void) ++{ ++ blk_unregister_notify(&blk_nvmem_notifier); ++} ++ ++module_init(blk_nvmem_init); ++module_exit(blk_nvmem_exit); ++ ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("Daniel Golle "); ++MODULE_DESCRIPTION("block device NVMEM provider"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/457-mmc-block-set-GENHD_FL_NVMEM.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/457-mmc-block-set-GENHD_FL_NVMEM.patch new file mode 100755 index 0000000..955fa66 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/457-mmc-block-set-GENHD_FL_NVMEM.patch @@ -0,0 +1,22 @@ +From caac69565748349a3e532130a891e18dd5c36c5e Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 20 Jul 2023 17:36:44 +0100 +Subject: [PATCH 8/8] mmc: block: set GENHD_FL_NVMEM + +Set flag to consider MMC block devices as NVMEM providers. + +Signed-off-by: Daniel Golle +--- + drivers/mmc/core/block.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/mmc/core/block.c ++++ b/drivers/mmc/core/block.c +@@ -2644,6 +2644,7 @@ static struct mmc_blk_data *mmc_blk_allo + md->disk->major = MMC_BLOCK_MAJOR; + md->disk->minors = perdev_minors; + md->disk->first_minor = devidx * perdev_minors; ++ md->disk->flags = GENHD_FL_NVMEM; + md->disk->fops = &mmc_bdops; + md->disk->private_data = md; + md->parent = parent; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch new file mode 100755 index 0000000..2435133 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/460-mtd-cfi_cmdset_0002-no-erase_suspend.patch @@ -0,0 +1,25 @@ +From: Felix Fietkau +Subject: kernel: disable cfi cmdset 0002 erase suspend + +on some platforms, erase suspend leads to data corruption and lockups when write +ops collide with erase ops. this has been observed on the buffalo wzr-hp-g300nh. +rather than play whack-a-mole with a hard to reproduce issue on a variety of devices, +simply disable erase suspend, as it will usually not produce any useful gain on +the small filesystems used on embedded hardware. + +Signed-off-by: Felix Fietkau +--- + drivers/mtd/chips/cfi_cmdset_0002.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -906,7 +906,7 @@ static int get_chip(struct map_info *map + return 0; + + case FL_ERASING: +- if (!cfip || !(cfip->EraseSuspend & (0x1|0x2)) || ++ if (1 /* no suspend */ || !cfip || !(cfip->EraseSuspend & (0x1|0x2)) || + !(mode == FL_READY || mode == FL_POINT || + (mode == FL_WRITING && (cfip->EraseSuspend & 0x2)))) + goto sleep; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch new file mode 100755 index 0000000..059d967 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/461-mtd-cfi_cmdset_0002-add-buffer-write-cmd-timeout.patch @@ -0,0 +1,17 @@ +From: George Kashperko +Subject: Issue map read after Write Buffer Load command to ensure chip is ready to receive data. + +Signed-off-by: George Kashperko +--- + drivers/mtd/chips/cfi_cmdset_0002.c | 1 + + 1 file changed, 1 insertion(+) +--- a/drivers/mtd/chips/cfi_cmdset_0002.c ++++ b/drivers/mtd/chips/cfi_cmdset_0002.c +@@ -2050,6 +2050,7 @@ static int __xipram do_write_buffer(stru + + /* Write Buffer Load */ + map_write(map, CMD(0x25), cmd_adr); ++ (void) map_read(map, cmd_adr); + + chip->state = FL_WRITING_TO_BUFFER; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/476-mtd-spi-nor-add-eon-en25q128.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/476-mtd-spi-nor-add-eon-en25q128.patch new file mode 100755 index 0000000..afc5e48 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/476-mtd-spi-nor-add-eon-en25q128.patch @@ -0,0 +1,22 @@ +From: Piotr Dymacz +Subject: kernel/mtd: add support for EON EN25Q128 + +Signed-off-by: Piotr Dymacz +--- + drivers/mtd/spi-nor/spi-nor.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/mtd/spi-nor/eon.c ++++ b/drivers/mtd/spi-nor/eon.c +@@ -18,6 +18,11 @@ static const struct flash_info eon_nor_p + .name = "en25p64", + .size = SZ_8M, + }, { ++ .id = SNOR_ID(0x1c, 0x30, 0x18), ++ .name = "en25q128", ++ .size = SZ_16M, ++ .no_sfdp_flags = SECT_4K, ++ }, { + .id = SNOR_ID(0x1c, 0x30, 0x14), + .name = "en25q80a", + .size = SZ_1M, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/477-mtd-spi-nor-add-eon-en25qx128a.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/477-mtd-spi-nor-add-eon-en25qx128a.patch new file mode 100755 index 0000000..4dd229b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/477-mtd-spi-nor-add-eon-en25qx128a.patch @@ -0,0 +1,24 @@ +From: Christian Marangi +Subject: kernel/mtd: add support for EON EN25QX128A + +Add support for EON EN25QX128A with no flags as it does +support SFDP parsing. + +Signed-off-by: Christian Marangi +--- + drivers/mtd/spi-nor/spi-nor.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/mtd/spi-nor/eon.c ++++ b/drivers/mtd/spi-nor/eon.c +@@ -23,6 +23,10 @@ static const struct flash_info eon_nor_p + .size = SZ_16M, + .no_sfdp_flags = SECT_4K, + }, { ++ .id = SNOR_ID(0x1c, 0x71, 0x18), ++ .name = "en25qx128a", ++ .size = SZ_16M, ++ }, { + .id = SNOR_ID(0x1c, 0x30, 0x14), + .name = "en25q80a", + .size = SZ_1M, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/479-mtd-spi-nor-add-xtx-xt25f128b.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/479-mtd-spi-nor-add-xtx-xt25f128b.patch new file mode 100755 index 0000000..be8bafa --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/479-mtd-spi-nor-add-xtx-xt25f128b.patch @@ -0,0 +1,84 @@ +From patchwork Thu Feb 6 17:19:41 2020 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 1234465 +Date: Thu, 6 Feb 2020 19:19:41 +0200 +From: Daniel Golle +To: linux-mtd@lists.infradead.org +Subject: [PATCH v2] mtd: spi-nor: Add support for xt25f128b chip +Message-ID: <20200206171941.GA2398@makrotopia.org> +MIME-Version: 1.0 +Content-Disposition: inline +List-Subscribe: , + +Cc: Eitan Cohen , Piotr Dymacz , + Tudor Ambarus +Sender: "linux-mtd" +Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org + +Add XT25F128B made by XTX Technology (Shenzhen) Limited. +This chip supports dual and quad read and uniform 4K-byte erase. +Verified on Teltonika RUT955 which comes with XT25F128B in recent +versions of the device. + +Signed-off-by: Daniel Golle +Signed-off-by: Felix Fietkau +--- + drivers/mtd/spi-nor/spi-nor.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/drivers/mtd/spi-nor/Makefile ++++ b/drivers/mtd/spi-nor/Makefile +@@ -14,6 +14,7 @@ spi-nor-objs += spansion.o + spi-nor-objs += sst.o + spi-nor-objs += winbond.o + spi-nor-objs += xmc.o ++spi-nor-objs += xtx.o + spi-nor-$(CONFIG_DEBUG_FS) += debugfs.o + obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o + +--- /dev/null ++++ b/drivers/mtd/spi-nor/xtx.c +@@ -0,0 +1,20 @@ ++// SPDX-License-Identifier: GPL-2.0 ++#include ++ ++#include "core.h" ++ ++static const struct flash_info xtx_parts[] = { ++ /* XTX Technology (Shenzhen) Limited */ ++ { ++ .id = SNOR_ID(0x0B, 0x40, 0x18), ++ .name = "xt25f128b", ++ .size = SZ_16M, ++ .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, ++ }, ++}; ++ ++const struct spi_nor_manufacturer spi_nor_xtx = { ++ .name = "xtx", ++ .parts = xtx_parts, ++ .nparts = ARRAY_SIZE(xtx_parts), ++}; +--- a/drivers/mtd/spi-nor/core.c ++++ b/drivers/mtd/spi-nor/core.c +@@ -1979,6 +1979,7 @@ static const struct spi_nor_manufacturer + &spi_nor_sst, + &spi_nor_winbond, + &spi_nor_xmc, ++ &spi_nor_xtx, + }; + + static const struct flash_info spi_nor_generic_flash = { +--- a/drivers/mtd/spi-nor/core.h ++++ b/drivers/mtd/spi-nor/core.h +@@ -593,6 +593,7 @@ extern const struct spi_nor_manufacturer + extern const struct spi_nor_manufacturer spi_nor_sst; + extern const struct spi_nor_manufacturer spi_nor_winbond; + extern const struct spi_nor_manufacturer spi_nor_xmc; ++extern const struct spi_nor_manufacturer spi_nor_xtx; + + extern const struct attribute_group *spi_nor_sysfs_groups[]; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/481-mtd-spi-nor-add-support-for-Gigadevice-GD25D05.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/481-mtd-spi-nor-add-support-for-Gigadevice-GD25D05.patch new file mode 100755 index 0000000..c4caf73 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/481-mtd-spi-nor-add-support-for-Gigadevice-GD25D05.patch @@ -0,0 +1,25 @@ +From d68b4aa22e8c625685bfad642dd7337948dc0ad1 Mon Sep 17 00:00:00 2001 +From: Koen Vandeputte +Date: Mon, 6 Jan 2020 13:07:56 +0100 +Subject: [PATCH] mtd: spi-nor: add support for Gigadevice GD25D05 + +Signed-off-by: Koen Vandeputte +--- + drivers/mtd/spi-nor/spi-nor.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/mtd/spi-nor/gigadevice.c ++++ b/drivers/mtd/spi-nor/gigadevice.c +@@ -35,6 +35,12 @@ static const struct spi_nor_fixups gd25q + + static const struct flash_info gigadevice_nor_parts[] = { + { ++ .id = SNOR_ID(0xc8, 0x40, 0x10), ++ .name = "gd25q05", ++ .size = SZ_64K, ++ .flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB, ++ .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, ++ }, { + .id = SNOR_ID(0xc8, 0x40, 0x15), + .name = "gd25q16", + .size = SZ_2M, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/482-mtd-spi-nor-add-gd25q512.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/482-mtd-spi-nor-add-gd25q512.patch new file mode 100755 index 0000000..2b34d14 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/482-mtd-spi-nor-add-gd25q512.patch @@ -0,0 +1,25 @@ +From f8943df3beb0d3f9754bb35320c3a378727175a8 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Thu, 14 Jul 2022 08:38:07 +0200 +Subject: [PATCH] spi-nor/gigadevic: add gd25q512 + +--- + drivers/mtd/spi-nor/gigadevice.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/mtd/spi-nor/gigadevice.c ++++ b/drivers/mtd/spi-nor/gigadevice.c +@@ -71,6 +71,13 @@ static const struct flash_info gigadevic + .fixups = &gd25q256_fixups, + .fixup_flags = SPI_NOR_4B_OPCODES, + }, { ++ .id = SNOR_ID(0xc8, 0x40, 0x20), ++ .name = "gd25q512", ++ .size = SZ_64M, ++ .flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB, ++ .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, ++ .fixup_flags = SPI_NOR_4B_OPCODES, ++ }, { + .id = SNOR_ID(0xc8, 0x60, 0x16), + .name = "gd25lq32", + .size = SZ_4M, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/484-mtd-spi-nor-add-esmt-f25l16pa.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/484-mtd-spi-nor-add-esmt-f25l16pa.patch new file mode 100755 index 0000000..1e296ee --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/484-mtd-spi-nor-add-esmt-f25l16pa.patch @@ -0,0 +1,27 @@ +From 87363cc0e522de3294ea6ae10fb468d2a8d6fb2f Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 12:17:21 +0200 +Subject: [PATCH] spi-nor/esmt.c: add esmt f25l16pa + +This fixes support for Dongwon T&I DW02-412H which uses F25L16PA(2S) +flash. + +--- + drivers/mtd/spi-nor/esmt.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/mtd/spi-nor/esmt.c ++++ b/drivers/mtd/spi-nor/esmt.c +@@ -10,6 +10,12 @@ + + static const struct flash_info esmt_nor_parts[] = { + { ++ .id = SNOR_ID(0x8c, 0x21, 0x15), ++ .name = "f25l16pa-2s", ++ .size = SZ_2M, ++ .flags = SPI_NOR_HAS_LOCK, ++ .no_sfdp_flags = SECT_4K, ++ }, { + .id = SNOR_ID(0x8c, 0x20, 0x16), + .name = "f25l32pa", + .size = SZ_4M, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/485-mtd-spi-nor-add-xmc-xm25qh128c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/485-mtd-spi-nor-add-xmc-xm25qh128c.patch new file mode 100755 index 0000000..886d755 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/485-mtd-spi-nor-add-xmc-xm25qh128c.patch @@ -0,0 +1,27 @@ +From f6b33d850f7f12555df2fa0e3349b33427bf5890 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 12:19:01 +0200 +Subject: [PATCH] spi-nor/xmc.c: add xm25qh128c + +The XMC XM25QH128C is a 16MB SPI NOR chip. The patch is verified on +Ruijie RG-EW3200GX PRO. +Datasheet available at https://www.xmcwh.com/uploads/435/XM25QH128C.pdf + +--- + drivers/mtd/spi-nor/xmc.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/mtd/spi-nor/xmc.c ++++ b/drivers/mtd/spi-nor/xmc.c +@@ -19,6 +19,11 @@ static const struct flash_info xmc_nor_p + .name = "XM25QH128A", + .size = SZ_16M, + .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, ++ }, { ++ .id = SNOR_ID(0x20, 0x40, 0x18), ++ .name = "XM25QH128C", ++ .size = SZ_16M, ++ .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, + }, + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/487-mtd-spinand-Add-support-for-Etron-EM73D044VCx.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/487-mtd-spinand-Add-support-for-Etron-EM73D044VCx.patch new file mode 100755 index 0000000..f6b7264 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/487-mtd-spinand-Add-support-for-Etron-EM73D044VCx.patch @@ -0,0 +1,170 @@ +From f32085fc0b87049491b07e198d924d738a1a2834 Mon Sep 17 00:00:00 2001 +From: Daniel Danzberger +Date: Wed, 3 Aug 2022 17:31:03 +0200 +Subject: [PATCH] mtd: spinand: Add support for Etron EM73D044VCx + +Airoha is a new ARM platform based on Cortex-A53 which has recently been +merged into linux-next. + +Due to BootROM limitations on this platform, the Cortex-A53 can't run in +Aarch64 mode and code must be compiled for 32-Bit ARM. + +This support is based mostly on those linux-next commits backported +for kernel 5.15. + +Patches: +1 - platform support = linux-next +2 - clock driver = linux-next +3 - gpio driver = linux-next +4 - linux,usable-memory-range dts support = linux-next +5 - mtd spinand driver +6 - spi driver +7 - pci driver (kconfig only, uses mediatek PCI) = linux-next + +Still missing: +- Ethernet driver +- Sysupgrade support + +A.t.m there exists one subtarget EN7523 with only one evaluation +board. + +The initramfs can be run with the following commands from u-boot: +- +u-boot> setenv bootfile \ + openwrt-airoha-airoha_en7523-evb-initramfs-kernel.bin +u-boot> tftpboot +u-boot> bootm 0x81800000 +- + +Submitted-by: Daniel Danzberger + +--- a/drivers/mtd/nand/spi/Makefile ++++ b/drivers/mtd/nand/spi/Makefile +@@ -1,4 +1,4 @@ + # SPDX-License-Identifier: GPL-2.0 +-spinand-objs := core.o alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o +-spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o ++spinand-objs := core.o alliancememory.o ato.o esmt.o etron.o fmsh.o foresee.o gigadevice.o ++spinand-objs += macronix.o micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o + obj-$(CONFIG_MTD_SPI_NAND) += spinand.o +--- a/drivers/mtd/nand/spi/core.c ++++ b/drivers/mtd/nand/spi/core.c +@@ -1178,6 +1178,7 @@ static const struct spinand_manufacturer + &ato_spinand_manufacturer, + &esmt_8c_spinand_manufacturer, + &esmt_c8_spinand_manufacturer, ++ &etron_spinand_manufacturer, + &fmsh_spinand_manufacturer, + &foresee_spinand_manufacturer, + &gigadevice_spinand_manufacturer, +--- /dev/null ++++ b/drivers/mtd/nand/spi/etron.c +@@ -0,0 +1,98 @@ ++// SPDX-License-Identifier: GPL-2.0 ++ ++#include ++#include ++#include ++ ++#define SPINAND_MFR_ETRON 0xd5 ++ ++ ++static SPINAND_OP_VARIANTS(read_cache_variants, ++ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0), ++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(write_cache_variants, ++ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0), ++ SPINAND_PROG_LOAD(true, 0, NULL, 0)); ++ ++static SPINAND_OP_VARIANTS(update_cache_variants, ++ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0), ++ SPINAND_PROG_LOAD(false, 0, NULL, 0)); ++ ++static int etron_ooblayout_ecc(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *oobregion) ++{ ++ if (section) ++ return -ERANGE; ++ ++ oobregion->offset = 72; ++ oobregion->length = 56; ++ ++ return 0; ++} ++ ++static int etron_ooblayout_free(struct mtd_info *mtd, int section, ++ struct mtd_oob_region *oobregion) ++{ ++ if (section) ++ return -ERANGE; ++ ++ oobregion->offset = 1; ++ oobregion->length = 71; ++ ++ return 0; ++} ++ ++static int etron_ecc_get_status(struct spinand_device *spinand, u8 status) ++{ ++ switch (status & STATUS_ECC_MASK) { ++ case STATUS_ECC_NO_BITFLIPS: ++ return 0; ++ ++ case STATUS_ECC_HAS_BITFLIPS: ++ /* Between 1-7 bitflips were corrected */ ++ return 7; ++ ++ case STATUS_ECC_MASK: ++ /* Maximum bitflips were corrected */ ++ return 8; ++ ++ case STATUS_ECC_UNCOR_ERROR: ++ return -EBADMSG; ++ } ++ ++ return -EINVAL; ++} ++ ++static const struct mtd_ooblayout_ops etron_ooblayout = { ++ .ecc = etron_ooblayout_ecc, ++ .free = etron_ooblayout_free, ++}; ++ ++static const struct spinand_info etron_spinand_table[] = { ++ SPINAND_INFO("EM73D044VCx", ++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x1f), ++ // bpc, pagesize, oobsize, pagesperblock, bperlun, maxbadplun, ppl, lpt, #t ++ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1), ++ NAND_ECCREQ(8, 512), ++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants, ++ &write_cache_variants, ++ &update_cache_variants), ++ SPINAND_HAS_QE_BIT, ++ SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)), ++}; ++ ++static const struct spinand_manufacturer_ops etron_spinand_manuf_ops = { ++}; ++ ++const struct spinand_manufacturer etron_spinand_manufacturer = { ++ .id = SPINAND_MFR_ETRON, ++ .name = "Etron", ++ .chips = etron_spinand_table, ++ .nchips = ARRAY_SIZE(etron_spinand_table), ++ .ops = &etron_spinand_manuf_ops, ++}; +--- a/include/linux/mtd/spinand.h ++++ b/include/linux/mtd/spinand.h +@@ -264,6 +264,7 @@ extern const struct spinand_manufacturer + extern const struct spinand_manufacturer ato_spinand_manufacturer; + extern const struct spinand_manufacturer esmt_8c_spinand_manufacturer; + extern const struct spinand_manufacturer esmt_c8_spinand_manufacturer; ++extern const struct spinand_manufacturer etron_spinand_manufacturer; + extern const struct spinand_manufacturer fmsh_spinand_manufacturer; + extern const struct spinand_manufacturer foresee_spinand_manufacturer; + extern const struct spinand_manufacturer gigadevice_spinand_manufacturer; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/488-mtd-spi-nor-add-xmc-xm25qh64c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/488-mtd-spi-nor-add-xmc-xm25qh64c.patch new file mode 100755 index 0000000..6e65c55 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/488-mtd-spi-nor-add-xmc-xm25qh64c.patch @@ -0,0 +1,25 @@ +From: Joe Mullally +Subject: mtd/spi-nor/xmc: add support for XMC XM25QH64C + +The XMC XM25QH64C is a 8MB SPI NOR chip. The patch is verified on TL-WPA8631P v3. +Datasheet available at https://www.xmcwh.com/uploads/442/XM25QH64C.pdf + +Signed-off-by: Joe Mullally +--- + drivers/mtd/spi-nor/xmc.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/mtd/spi-nor/xmc.c ++++ b/drivers/mtd/spi-nor/xmc.c +@@ -15,6 +15,11 @@ static const struct flash_info xmc_nor_p + .size = SZ_8M, + .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, + }, { ++ .id = SNOR_ID(0x20, 0x40, 0x17), ++ .name = "XM25QH64C", ++ .size = SZ_8M, ++ .no_sfdp_flags = SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ, ++ }, { + .id = SNOR_ID(0x20, 0x70, 0x18), + .name = "XM25QH128A", + .size = SZ_16M, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch new file mode 100755 index 0000000..27b8611 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch @@ -0,0 +1,104 @@ +From: Daniel Golle +Subject: ubi: auto-attach mtd device named "ubi" or "data" on boot + +Signed-off-by: Daniel Golle +--- + drivers/mtd/ubi/build.c | 36 ++++++++++++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) + +--- a/drivers/mtd/ubi/build.c ++++ b/drivers/mtd/ubi/build.c +@@ -1263,6 +1263,80 @@ static struct mtd_notifier ubi_mtd_notif + .remove = ubi_notify_remove, + }; + ++ ++/* ++ * This function tries attaching mtd partitions named either "ubi" or "data" ++ * during boot. ++ */ ++static void __init ubi_auto_attach(void) ++{ ++ int err; ++ struct mtd_info *mtd; ++ struct device_node *np; ++ loff_t offset = 0; ++ size_t len; ++ char magic[4]; ++ ++ /* try attaching mtd device named "ubi" or "data" */ ++ mtd = open_mtd_device("ubi"); ++ if (IS_ERR(mtd)) ++ mtd = open_mtd_device("data"); ++ ++ if (IS_ERR(mtd)) ++ return; ++ ++ /* skip "linux,ubi" mtd as it has already been attached */ ++ np = mtd_get_of_node(mtd); ++ if (of_device_is_compatible(np, "linux,ubi")) ++ goto cleanup; ++ ++ /* get the first not bad block */ ++ if (mtd_can_have_bb(mtd)) ++ while (mtd_block_isbad(mtd, offset)) { ++ offset += mtd->erasesize; ++ ++ if (offset > mtd->size) { ++ pr_err("UBI error: Failed to find a non-bad " ++ "block on mtd%d\n", mtd->index); ++ goto cleanup; ++ } ++ } ++ ++ /* check if the read from flash was successful */ ++ err = mtd_read(mtd, offset, 4, &len, (void *) magic); ++ if ((err && !mtd_is_bitflip(err)) || len != 4) { ++ pr_err("UBI error: unable to read from mtd%d\n", mtd->index); ++ goto cleanup; ++ } ++ ++ /* check for a valid ubi magic */ ++ if (strncmp(magic, "UBI#", 4)) { ++ pr_err("UBI error: no valid UBI magic found inside mtd%d\n", mtd->index); ++ goto cleanup; ++ } ++ ++ /* don't auto-add media types where UBI doesn't makes sense */ ++ if (mtd->type != MTD_NANDFLASH && ++ mtd->type != MTD_NORFLASH && ++ mtd->type != MTD_DATAFLASH && ++ mtd->type != MTD_MLCNANDFLASH) ++ goto cleanup; ++ ++ mutex_lock(&ubi_devices_mutex); ++ pr_notice("UBI: auto-attach mtd%d\n", mtd->index); ++ err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0, false, false); ++ mutex_unlock(&ubi_devices_mutex); ++ if (err < 0) { ++ pr_err("UBI error: cannot attach mtd%d\n", mtd->index); ++ goto cleanup; ++ } ++ ++ return; ++ ++cleanup: ++ put_mtd_device(mtd); ++} ++ + static int __init ubi_init_attach(void) + { + int err, i, k; +@@ -1314,6 +1388,12 @@ static int __init ubi_init_attach(void) + } + } + ++ /* auto-attach mtd devices only if built-in to the kernel and no ubi.mtd ++ * parameter was given */ ++ if (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && ++ !ubi_is_module() && !mtd_devs) ++ ubi_auto_attach(); ++ + return 0; + + out_detach: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/491-ubi-auto-create-ubiblock-device-for-rootfs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/491-ubi-auto-create-ubiblock-device-for-rootfs.patch new file mode 100755 index 0000000..44c3bf3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/491-ubi-auto-create-ubiblock-device-for-rootfs.patch @@ -0,0 +1,77 @@ +From: Daniel Golle +Subject: ubi: auto-create ubiblock device for rootfs + +Signed-off-by: Daniel Golle +--- + drivers/mtd/ubi/block.c | 42 ++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 42 insertions(+) + +--- a/drivers/mtd/ubi/block.c ++++ b/drivers/mtd/ubi/block.c +@@ -575,10 +575,47 @@ match_volume_desc(struct ubi_volume_info + return true; + } + ++#define UBIFS_NODE_MAGIC 0x06101831 ++static inline int ubi_vol_is_ubifs(struct ubi_volume_desc *desc) ++{ ++ int ret; ++ uint32_t magic_of, magic; ++ ret = ubi_read(desc, 0, (char *)&magic_of, 0, 4); ++ if (ret) ++ return 0; ++ magic = le32_to_cpu(magic_of); ++ return magic == UBIFS_NODE_MAGIC; ++} ++ ++static void ubiblock_create_auto_rootfs(struct ubi_volume_info *vi) ++{ ++ int ret, is_ubifs; ++ struct ubi_volume_desc *desc; ++ ++ if (strcmp(vi->name, "rootfs") && ++ strcmp(vi->name, "fit")) ++ return; ++ ++ desc = ubi_open_volume(vi->ubi_num, vi->vol_id, UBI_READONLY); ++ if (IS_ERR(desc)) ++ return; ++ ++ is_ubifs = ubi_vol_is_ubifs(desc); ++ ubi_close_volume(desc); ++ if (is_ubifs) ++ return; ++ ++ ret = ubiblock_create(vi); ++ if (ret) ++ pr_err("UBI error: block: can't add '%s' volume, err=%d\n", ++ vi->name, ret); ++} ++ + static void + ubiblock_create_from_param(struct ubi_volume_info *vi) + { + int i, ret = 0; ++ bool got_param = false; + struct ubiblock_param *p; + + /* +@@ -591,6 +628,7 @@ ubiblock_create_from_param(struct ubi_vo + if (!match_volume_desc(vi, p->name, p->ubi_num, p->vol_id)) + continue; + ++ got_param = true; + ret = ubiblock_create(vi); + if (ret) { + pr_err( +@@ -599,6 +637,10 @@ ubiblock_create_from_param(struct ubi_vo + } + break; + } ++ ++ /* auto-attach "rootfs" volume if existing and non-ubifs */ ++ if (!got_param && IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV)) ++ ubiblock_create_auto_rootfs(vi); + } + + static int ubiblock_notify(struct notifier_block *nb, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch new file mode 100755 index 0000000..7a4c633 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch @@ -0,0 +1,54 @@ +From: Daniel Golle +Subject: try auto-mounting ubi0:rootfs in init/do_mounts.c + +Signed-off-by: Daniel Golle +--- + init/do_mounts.c | 26 +++++++++++++++++++++++++- + 1 file changed, 25 insertions(+), 1 deletion(-) + +--- a/init/do_mounts.c ++++ b/init/do_mounts.c +@@ -250,7 +250,30 @@ retry: + out: + put_page(page); + } +- ++ ++#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV ++static int __init mount_ubi_rootfs(void) ++{ ++ int flags = MS_SILENT; ++ int err, tried = 0; ++ ++ while (tried < 2) { ++ err = do_mount_root("ubi0:rootfs", "ubifs", flags, \ ++ root_mount_data); ++ switch (err) { ++ case -EACCES: ++ flags |= MS_RDONLY; ++ tried++; ++ break; ++ default: ++ return err; ++ } ++ } ++ ++ return -EINVAL; ++} ++#endif ++ + #ifdef CONFIG_ROOT_NFS + + #define NFSROOT_TIMEOUT_MIN 5 +@@ -387,6 +410,11 @@ static inline void mount_block_root(char + + void __init mount_root(char *root_device_name) + { ++#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV ++ if (!mount_ubi_rootfs()) ++ return; ++#endif ++ + switch (ROOT_DEV) { + case Root_NFS: + mount_nfs_root(); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch new file mode 100755 index 0000000..4007c8a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/493-ubi-set-ROOT_DEV-to-ubiblock-rootfs-if-unset.patch @@ -0,0 +1,34 @@ +From: Daniel Golle +Subject: ubi: set ROOT_DEV to ubiblock "rootfs" if unset + +Signed-off-by: Daniel Golle +--- + drivers/mtd/ubi/block.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/mtd/ubi/block.c ++++ b/drivers/mtd/ubi/block.c +@@ -41,6 +41,7 @@ + #include + #include + #include ++#include + + #include "ubi-media.h" + #include "ubi.h" +@@ -431,6 +432,15 @@ int ubiblock_create(struct ubi_volume_in + dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)", + dev->ubi_num, dev->vol_id, vi->name); + mutex_unlock(&devices_mutex); ++ ++ if (!strcmp(vi->name, "rootfs") && ++ IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) && ++ ROOT_DEV == 0) { ++ pr_notice("ubiblock: device ubiblock%d_%d (%s) set to be root filesystem\n", ++ dev->ubi_num, dev->vol_id, vi->name); ++ ROOT_DEV = MKDEV(gd->major, gd->first_minor); ++ } ++ + return 0; + + out_remove_minor: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/494-mtd-ubi-add-EOF-marker-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/494-mtd-ubi-add-EOF-marker-support.patch new file mode 100755 index 0000000..4134317 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/494-mtd-ubi-add-EOF-marker-support.patch @@ -0,0 +1,60 @@ +From: Gabor Juhos +Subject: mtd: add EOF marker support to the UBI layer + +Signed-off-by: Gabor Juhos +--- + drivers/mtd/ubi/attach.c | 25 ++++++++++++++++++++++--- + drivers/mtd/ubi/ubi.h | 1 + + 2 files changed, 23 insertions(+), 3 deletions(-) + +--- a/drivers/mtd/ubi/attach.c ++++ b/drivers/mtd/ubi/attach.c +@@ -926,6 +926,13 @@ static bool vol_ignored(int vol_id) + #endif + } + ++static bool ec_hdr_has_eof(struct ubi_ec_hdr *ech) ++{ ++ return ech->padding1[0] == 'E' && ++ ech->padding1[1] == 'O' && ++ ech->padding1[2] == 'F'; ++} ++ + /** + * scan_peb - scan and process UBI headers of a PEB. + * @ubi: UBI device description object +@@ -958,9 +965,21 @@ static int scan_peb(struct ubi_device *u + return 0; + } + +- err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0); +- if (err < 0) +- return err; ++ if (!ai->eof_found) { ++ err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0); ++ if (err < 0) ++ return err; ++ ++ if (ec_hdr_has_eof(ech)) { ++ pr_notice("UBI: EOF marker found, PEBs from %d will be erased\n", ++ pnum); ++ ai->eof_found = true; ++ } ++ } ++ ++ if (ai->eof_found) ++ err = UBI_IO_FF_BITFLIPS; ++ + switch (err) { + case 0: + break; +--- a/drivers/mtd/ubi/ubi.h ++++ b/drivers/mtd/ubi/ubi.h +@@ -778,6 +778,7 @@ struct ubi_attach_info { + int mean_ec; + uint64_t ec_sum; + int ec_count; ++ bool eof_found; + struct kmem_cache *aeb_slab_cache; + struct ubi_ec_hdr *ech; + struct ubi_vid_io_buf *vidb; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/496-dt-bindings-add-bindings-for-mtd-concat-devices.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/496-dt-bindings-add-bindings-for-mtd-concat-devices.patch new file mode 100755 index 0000000..01f3b9e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/496-dt-bindings-add-bindings-for-mtd-concat-devices.patch @@ -0,0 +1,52 @@ +From 5734c6669fba7ddb5ef491ccff7159d15dba0b59 Mon Sep 17 00:00:00 2001 +From: Bernhard Frauendienst +Date: Wed, 5 Sep 2018 01:32:51 +0200 +Subject: [PATCH 496/497] dt-bindings: add bindings for mtd-concat devices + +Document virtual mtd-concat device bindings. + +Signed-off-by: Bernhard Frauendienst +--- + .../devicetree/bindings/mtd/mtd-concat.txt | 36 +++++++++++++++++++ + 1 file changed, 36 insertions(+) + create mode 100644 Documentation/devicetree/bindings/mtd/mtd-concat.txt + +--- /dev/null ++++ b/Documentation/devicetree/bindings/mtd/mtd-concat.txt +@@ -0,0 +1,36 @@ ++Virtual MTD concat device ++ ++Requires properties: ++- devices: list of phandles to mtd nodes that should be concatenated ++ ++Example: ++ ++&spi { ++ flash0: flash@0 { ++ ... ++ }; ++ flash1: flash@1 { ++ ... ++ }; ++}; ++ ++flash { ++ compatible = "mtd-concat"; ++ ++ devices = <&flash0 &flash1>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ ++ partition@0 { ++ label = "boot"; ++ reg = <0x0000000 0x0040000>; ++ read-only; ++ }; ++ ++ partition@40000 { ++ label = "firmware"; ++ reg = <0x0040000 0x1fc0000>; ++ }; ++ } ++} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/497-mtd-mtdconcat-add-dt-driver-for-concat-devices.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/497-mtd-mtdconcat-add-dt-driver-for-concat-devices.patch new file mode 100755 index 0000000..cda5e10 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/497-mtd-mtdconcat-add-dt-driver-for-concat-devices.patch @@ -0,0 +1,215 @@ +From e53f712d8eac71f54399b61038ccf87d2cee99d7 Mon Sep 17 00:00:00 2001 +From: Bernhard Frauendienst +Date: Sat, 25 Aug 2018 12:35:22 +0200 +Subject: [PATCH 497/497] mtd: mtdconcat: add dt driver for concat devices + +Some mtd drivers like physmap variants have support for concatenating +multiple mtd devices, but there is no generic way to define such a +concat device from within the device tree. + +This is useful for some SoC boards that use multiple flash chips as +memory banks of a single mtd device, with partitions spanning chip +borders. + +This commit adds a driver for creating virtual mtd-concat devices. They +must have a compatible = "mtd-concat" line, and define a list of devices +to concat in the 'devices' property, for example: + +flash { + compatible = "mtd-concat"; + + devices = <&flash0 &flash1>; + + partitions { + ... + }; +}; + +The driver is added to the very end of the mtd Makefile to increase the +likelyhood of all child devices already being loaded at the time of +probing, preventing unnecessary deferred probes. + +Signed-off-by: Bernhard Frauendienst +--- + drivers/mtd/Kconfig | 2 + + drivers/mtd/Makefile | 3 + + drivers/mtd/composite/Kconfig | 12 +++ + drivers/mtd/composite/Makefile | 6 ++ + drivers/mtd/composite/virt_concat.c | 128 ++++++++++++++++++++++++++++ + 5 files changed, 151 insertions(+) + create mode 100644 drivers/mtd/composite/Kconfig + create mode 100644 drivers/mtd/composite/Makefile + create mode 100644 drivers/mtd/composite/virt_concat.c + +--- a/drivers/mtd/Kconfig ++++ b/drivers/mtd/Kconfig +@@ -241,4 +241,6 @@ source "drivers/mtd/ubi/Kconfig" + + source "drivers/mtd/hyperbus/Kconfig" + ++source "drivers/mtd/composite/Kconfig" ++ + endif # MTD +--- a/drivers/mtd/Makefile ++++ b/drivers/mtd/Makefile +@@ -33,3 +33,6 @@ obj-y += chips/ lpddr/ maps/ devices/ n + obj-$(CONFIG_MTD_SPI_NOR) += spi-nor/ + obj-$(CONFIG_MTD_UBI) += ubi/ + obj-$(CONFIG_MTD_HYPERBUS) += hyperbus/ ++ ++# Composite drivers must be loaded last ++obj-y += composite/ +--- /dev/null ++++ b/drivers/mtd/composite/Kconfig +@@ -0,0 +1,12 @@ ++menu "Composite MTD device drivers" ++ depends on MTD!=n ++ ++config MTD_VIRT_CONCAT ++ tristate "Virtual concat MTD device" ++ help ++ This driver allows creation of a virtual MTD concat device, which ++ concatenates multiple underlying MTD devices to a single device. ++ This is required by some SoC boards where multiple memory banks are ++ used as one device with partitions spanning across device boundaries. ++ ++endmenu +--- /dev/null ++++ b/drivers/mtd/composite/Makefile +@@ -0,0 +1,6 @@ ++# SPDX-License-Identifier: GPL-2.0 ++# ++# linux/drivers/mtd/composite/Makefile ++# ++ ++obj-$(CONFIG_MTD_VIRT_CONCAT) += virt_concat.o +--- /dev/null ++++ b/drivers/mtd/composite/virt_concat.c +@@ -0,0 +1,127 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Virtual concat MTD device driver ++ * ++ * Copyright (C) 2018 Bernhard Frauendienst ++ * Author: Bernhard Frauendienst, kernel@nospam.obeliks.de ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* ++ * struct of_virt_concat - platform device driver data. ++ * @cmtd the final mtd_concat device ++ * @num_devices the number of devices in @devices ++ * @devices points to an array of devices already loaded ++ */ ++struct of_virt_concat { ++ struct mtd_info *cmtd; ++ int num_devices; ++ struct mtd_info **devices; ++}; ++ ++static void virt_concat_remove(struct platform_device *pdev) ++{ ++ struct of_virt_concat *info; ++ int i; ++ ++ info = platform_get_drvdata(pdev); ++ if (!info) ++ return; ++ ++ // unset data for when this is called after a probe error ++ platform_set_drvdata(pdev, NULL); ++ ++ if (info->cmtd) { ++ mtd_device_unregister(info->cmtd); ++ mtd_concat_destroy(info->cmtd); ++ } ++ ++ if (info->devices) { ++ for (i = 0; i < info->num_devices; i++) ++ put_mtd_device(info->devices[i]); ++ } ++} ++ ++static int virt_concat_probe(struct platform_device *pdev) ++{ ++ struct device_node *node = pdev->dev.of_node; ++ struct of_phandle_iterator it; ++ struct of_virt_concat *info; ++ struct mtd_info *mtd; ++ int err = 0, count; ++ ++ count = of_count_phandle_with_args(node, "devices", NULL); ++ if (count <= 0) ++ return -EINVAL; ++ ++ info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); ++ if (!info) ++ return -ENOMEM; ++ info->devices = devm_kcalloc(&pdev->dev, count, ++ sizeof(*(info->devices)), GFP_KERNEL); ++ if (!info->devices) { ++ err = -ENOMEM; ++ goto err_remove; ++ } ++ ++ platform_set_drvdata(pdev, info); ++ ++ of_for_each_phandle(&it, err, node, "devices", NULL, 0) { ++ mtd = of_get_mtd_device_by_node(it.node); ++ if (IS_ERR(mtd)) { ++ of_node_put(it.node); ++ err = -EPROBE_DEFER; ++ goto err_remove; ++ } ++ ++ info->devices[info->num_devices++] = mtd; ++ } ++ ++ info->cmtd = mtd_concat_create(info->devices, info->num_devices, ++ dev_name(&pdev->dev)); ++ if (!info->cmtd) { ++ err = -ENXIO; ++ goto err_remove; ++ } ++ ++ info->cmtd->dev.parent = &pdev->dev; ++ mtd_set_of_node(info->cmtd, node); ++ mtd_device_register(info->cmtd, NULL, 0); ++ ++ return 0; ++ ++err_remove: ++ virt_concat_remove(pdev); ++ ++ return err; ++} ++ ++static const struct of_device_id virt_concat_of_match[] = { ++ { .compatible = "mtd-concat", }, ++ { /* sentinel */ } ++}; ++MODULE_DEVICE_TABLE(of, virt_concat_of_match); ++ ++static struct platform_driver virt_concat_driver = { ++ .probe = virt_concat_probe, ++ .remove = virt_concat_remove, ++ .driver = { ++ .name = "virt-mtdconcat", ++ .of_match_table = virt_concat_of_match, ++ }, ++}; ++ ++module_platform_driver(virt_concat_driver); ++ ++MODULE_LICENSE("GPL v2"); ++MODULE_AUTHOR("Bernhard Frauendienst "); ++MODULE_DESCRIPTION("Virtual concat MTD device driver"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/500-fs_cdrom_dependencies.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/500-fs_cdrom_dependencies.patch new file mode 100755 index 0000000..7c14358 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/500-fs_cdrom_dependencies.patch @@ -0,0 +1,52 @@ +From af7b91bcecce0eae24e90acd35d96ecee73e1407 Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 12:21:15 +0200 +Subject: [PATCH] fs: add cdrom dependency + +--- + fs/hfs/Kconfig | 1 + + fs/hfsplus/Kconfig | 1 + + fs/isofs/Kconfig | 1 + + fs/udf/Kconfig | 1 + + 4 files changed, 4 insertions(+) + +--- a/fs/hfs/Kconfig ++++ b/fs/hfs/Kconfig +@@ -2,6 +2,7 @@ + config HFS_FS + tristate "Apple Macintosh file system support" + depends on BLOCK ++ select CDROM + select BUFFER_HEAD + select NLS + select LEGACY_DIRECT_IO +--- a/fs/hfsplus/Kconfig ++++ b/fs/hfsplus/Kconfig +@@ -2,6 +2,7 @@ + config HFSPLUS_FS + tristate "Apple Extended HFS file system support" + depends on BLOCK ++ select CDROM + select BUFFER_HEAD + select NLS + select NLS_UTF8 +--- a/fs/isofs/Kconfig ++++ b/fs/isofs/Kconfig +@@ -1,6 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0-only + config ISO9660_FS + tristate "ISO 9660 CDROM file system support" ++ select CDROM + select BUFFER_HEAD + help + This is the standard file system used on CD-ROMs. It was previously +--- a/fs/udf/Kconfig ++++ b/fs/udf/Kconfig +@@ -1,6 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0-only + config UDF_FS + tristate "UDF file system support" ++ select CDROM + select BUFFER_HEAD + select CRC_ITU_T + select NLS diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/510-block-add-uImage.FIT-subimage-block-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/510-block-add-uImage.FIT-subimage-block-driver.patch new file mode 100755 index 0000000..74b079a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/510-block-add-uImage.FIT-subimage-block-driver.patch @@ -0,0 +1,757 @@ +From 3a200922ac4cbf4bfffdf86c0957b1401474e839 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Wed, 16 Nov 2022 12:49:52 +0000 +Subject: [PATCH 1/2] block: add uImage.FIT subimage block driver + +Add a small block driver which exposes filesystem sub-images contained +in U-Boot uImage.FIT images as block devices. + +The uImage.FIT image has to be stored directly on a block device or +partition, MTD device or partition, or UBI volume. + +The driver is intended for systems using the U-Boot bootloader and +uses the root device hint left by the bootloader (or the user) in +the 'chosen' section of the device-tree. + +Example: +/dts-v1/; +/ { + chosen { + rootdisk = <&mmc0_part3>; + }; +}; + +Signed-off-by: Daniel Golle +--- + MAINTAINERS | 6 + + drivers/block/Kconfig | 12 + + drivers/block/Makefile | 2 + + drivers/block/fitblk.c | 660 ++++++++++++++++++++++++++++++++++++ + drivers/block/open | 4 + + include/uapi/linux/fitblk.h | 10 + + 6 files changed, 694 insertions(+) + create mode 100644 drivers/block/fitblk.c + create mode 100644 drivers/block/open + create mode 100644 include/uapi/linux/fitblk.h + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -23677,6 +23677,12 @@ F: Documentation/filesystems/ubifs-authe + F: Documentation/filesystems/ubifs.rst + F: fs/ubifs/ + ++U-BOOT UIMAGE.FIT PARSER ++M: Daniel Golle ++L: linux-block@vger.kernel.org ++S: Maintained ++F: drivers/block/fitblk.c ++ + UBLK USERSPACE BLOCK DRIVER + M: Ming Lei + L: linux-block@vger.kernel.org +--- a/drivers/block/Kconfig ++++ b/drivers/block/Kconfig +@@ -363,6 +363,18 @@ config BLK_DEV_RUST_NULL + + If unsure, say N. + ++config UIMAGE_FIT_BLK ++ bool "uImage.FIT block driver" ++ help ++ This driver allows using filesystems contained in uImage.FIT images ++ by mapping them as block devices. ++ ++ It can currently not be built as a module due to libfdt symbols not ++ being exported. ++ ++ Say Y if you want to mount filesystems sub-images of a uImage.FIT ++ stored in a block device partition, mtdblock or ubiblock device. ++ + config BLK_DEV_RBD + tristate "Rados block device (RBD)" + depends on INET && BLOCK +--- a/drivers/block/Makefile ++++ b/drivers/block/Makefile +@@ -42,4 +42,6 @@ obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_b + + obj-$(CONFIG_BLK_DEV_UBLK) += ublk_drv.o + ++obj-$(CONFIG_UIMAGE_FIT_BLK) += fitblk.o ++ + swim_mod-y := swim.o swim_asm.o +--- /dev/null ++++ b/drivers/block/fitblk.c +@@ -0,0 +1,660 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * uImage.FIT virtual block device driver. ++ * ++ * Copyright (C) 2023 Daniel Golle ++ * Copyright (C) 2007 Nick Piggin ++ * Copyright (C) 2007 Novell Inc. ++ * ++ * Initially derived from drivers/block/brd.c which is in parts derived from ++ * drivers/block/rd.c, and drivers/block/loop.c, copyright of their respective ++ * owners. ++ * ++ * uImage.FIT headers extracted from Das U-Boot ++ * (C) Copyright 2008 Semihalf ++ * (C) Copyright 2000-2005 ++ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define FIT_DEVICE_PREFIX "fit" ++ ++/* maximum number of pages used for the uImage.FIT index structure */ ++#define FIT_MAX_PAGES 1024 ++ ++/* minimum free sectors to map as read-write "remainder" volume */ ++#define MIN_FREE_SECT 16 ++ ++/* maximum number of mapped loadables */ ++#define MAX_FIT_LOADABLES 16 ++ ++/* constants for uImage.FIT structrure traversal */ ++#define FIT_IMAGES_PATH "/images" ++#define FIT_CONFS_PATH "/configurations" ++ ++/* hash/signature/key node */ ++#define FIT_HASH_NODENAME "hash" ++#define FIT_ALGO_PROP "algo" ++#define FIT_VALUE_PROP "value" ++#define FIT_IGNORE_PROP "uboot-ignore" ++#define FIT_SIG_NODENAME "signature" ++#define FIT_KEY_REQUIRED "required" ++#define FIT_KEY_HINT "key-name-hint" ++ ++/* cipher node */ ++#define FIT_CIPHER_NODENAME "cipher" ++#define FIT_ALGO_PROP "algo" ++ ++/* image node */ ++#define FIT_DATA_PROP "data" ++#define FIT_DATA_POSITION_PROP "data-position" ++#define FIT_DATA_OFFSET_PROP "data-offset" ++#define FIT_DATA_SIZE_PROP "data-size" ++#define FIT_TIMESTAMP_PROP "timestamp" ++#define FIT_DESC_PROP "description" ++#define FIT_ARCH_PROP "arch" ++#define FIT_TYPE_PROP "type" ++#define FIT_OS_PROP "os" ++#define FIT_COMP_PROP "compression" ++#define FIT_ENTRY_PROP "entry" ++#define FIT_LOAD_PROP "load" ++ ++/* configuration node */ ++#define FIT_KERNEL_PROP "kernel" ++#define FIT_FILESYSTEM_PROP "filesystem" ++#define FIT_RAMDISK_PROP "ramdisk" ++#define FIT_FDT_PROP "fdt" ++#define FIT_LOADABLE_PROP "loadables" ++#define FIT_DEFAULT_PROP "default" ++#define FIT_SETUP_PROP "setup" ++#define FIT_FPGA_PROP "fpga" ++#define FIT_FIRMWARE_PROP "firmware" ++#define FIT_STANDALONE_PROP "standalone" ++ ++/* fitblk driver data */ ++static const char *_fitblk_claim_ptr = "I belong to fitblk"; ++static const char *ubootver; ++struct device_node *rootdisk; ++static struct platform_device *pdev; ++static LIST_HEAD(fitblk_devices); ++static DEFINE_MUTEX(devices_mutex); ++refcount_t num_devs; ++ ++struct fitblk { ++ struct platform_device *pdev; ++ struct file *bdev_file; ++ sector_t start_sect; ++ struct gendisk *disk; ++ struct work_struct remove_work; ++ struct list_head list; ++ bool dead; ++}; ++ ++static int fitblk_open(struct gendisk *disk, fmode_t mode) ++{ ++ struct fitblk *fitblk = disk->private_data; ++ ++ if (fitblk->dead) ++ return -ENOENT; ++ ++ return 0; ++} ++ ++static void fitblk_release(struct gendisk *disk) ++{ ++ return; ++} ++ ++static void fitblk_submit_bio(struct bio *orig_bio) ++{ ++ struct bio *bio = orig_bio; ++ struct fitblk *fitblk = bio->bi_bdev->bd_disk->private_data; ++ ++ if (fitblk->dead) ++ return; ++ ++ /* mangle bio and re-submit */ ++ while (bio) { ++ bio->bi_iter.bi_sector += fitblk->start_sect; ++ bio->bi_bdev = file_bdev(fitblk->bdev_file); ++ bio = bio->bi_next; ++ } ++ submit_bio(orig_bio); ++} ++ ++static void fitblk_remove(struct fitblk *fitblk) ++{ ++ blk_mark_disk_dead(fitblk->disk); ++ mutex_lock(&devices_mutex); ++ fitblk->dead = true; ++ list_del(&fitblk->list); ++ mutex_unlock(&devices_mutex); ++ ++ schedule_work(&fitblk->remove_work); ++} ++ ++static int fitblk_ioctl(struct block_device *bdev, fmode_t mode, ++ unsigned int cmd, unsigned long arg) ++{ ++ struct fitblk *fitblk = bdev->bd_disk->private_data; ++ ++ if (!capable(CAP_SYS_ADMIN)) ++ return -EACCES; ++ ++ if (fitblk->dead) ++ return -ENOENT; ++ ++ switch (cmd) { ++ case FITBLK_RELEASE: ++ fitblk_remove(fitblk); ++ break; ++ default: ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static const struct block_device_operations fitblk_fops = { ++ .owner = THIS_MODULE, ++ .ioctl = fitblk_ioctl, ++ .open = fitblk_open, ++ .release = fitblk_release, ++ .submit_bio = fitblk_submit_bio, ++}; ++ ++static void fitblk_purge(struct work_struct *work) ++{ ++ struct fitblk *fitblk = container_of(work, struct fitblk, remove_work); ++ ++ del_gendisk(fitblk->disk); ++ refcount_dec(&num_devs); ++ platform_device_del(fitblk->pdev); ++ platform_device_put(fitblk->pdev); ++ ++ if (refcount_dec_if_one(&num_devs)) { ++ sysfs_remove_link(&pdev->dev.kobj, "lower_dev"); ++ fput(fitblk->bdev_file); ++ } ++ ++ kfree(fitblk); ++} ++ ++static int add_fit_subimage_device(struct file *bdev_file, ++ unsigned int slot, sector_t start_sect, ++ sector_t nr_sect, bool readonly) ++{ ++ struct block_device *bdev = file_bdev(bdev_file); ++ struct fitblk *fitblk; ++ struct gendisk *disk; ++ int err; ++ ++ mutex_lock(&devices_mutex); ++ if (!refcount_inc_not_zero(&num_devs)) ++ return -EBADF; ++ ++ fitblk = kzalloc(sizeof(struct fitblk), GFP_KERNEL); ++ if (!fitblk) { ++ err = -ENOMEM; ++ goto out_unlock; ++ } ++ ++ fitblk->bdev_file = bdev_file; ++ fitblk->start_sect = start_sect; ++ INIT_WORK(&fitblk->remove_work, fitblk_purge); ++ ++ disk = blk_alloc_disk(&bdev->bd_disk->queue->limits, NUMA_NO_NODE); ++ if (!disk) { ++ err = -ENOMEM; ++ goto out_free_fitblk; ++ } ++ ++ disk->first_minor = 0; ++ disk->flags = bdev->bd_disk->flags | GENHD_FL_NO_PART; ++ disk->fops = &fitblk_fops; ++ disk->private_data = fitblk; ++ if (readonly) { ++ set_disk_ro(disk, 1); ++ snprintf(disk->disk_name, sizeof(disk->disk_name), FIT_DEVICE_PREFIX "%u", slot); ++ } else { ++ strcpy(disk->disk_name, FIT_DEVICE_PREFIX "rw"); ++ } ++ ++ set_capacity(disk, nr_sect); ++ disk->queue->queue_flags = bdev->bd_disk->queue->queue_flags; ++ ++ fitblk->disk = disk; ++ fitblk->pdev = platform_device_alloc(disk->disk_name, PLATFORM_DEVID_NONE); ++ if (!fitblk->pdev) { ++ err = -ENOMEM; ++ goto out_cleanup_disk; ++ } ++ ++ fitblk->pdev->dev.parent = &pdev->dev; ++ err = platform_device_add(fitblk->pdev); ++ if (err) ++ goto out_put_pdev; ++ ++ err = device_add_disk(&fitblk->pdev->dev, disk, NULL); ++ if (err) ++ goto out_del_pdev; ++ ++ if (!ROOT_DEV) ++ ROOT_DEV = disk->part0->bd_dev; ++ ++ list_add_tail(&fitblk->list, &fitblk_devices); ++ ++ mutex_unlock(&devices_mutex); ++ ++ return 0; ++ ++out_del_pdev: ++ platform_device_del(fitblk->pdev); ++out_put_pdev: ++ platform_device_put(fitblk->pdev); ++out_cleanup_disk: ++ put_disk(disk); ++out_free_fitblk: ++ kfree(fitblk); ++out_unlock: ++ refcount_dec(&num_devs); ++ mutex_unlock(&devices_mutex); ++ return err; ++} ++ ++static void fitblk_mark_dead(struct block_device *bdev, bool surprise) ++{ ++ struct list_head *n, *tmp; ++ struct fitblk *fitblk; ++ ++ mutex_lock(&devices_mutex); ++ list_for_each_safe(n, tmp, &fitblk_devices) { ++ fitblk = list_entry(n, struct fitblk, list); ++ if (file_bdev(fitblk->bdev_file) != bdev) ++ continue; ++ ++ fitblk->dead = true; ++ list_del(&fitblk->list); ++ /* removal needs to be deferred to avoid deadlock */ ++ schedule_work(&fitblk->remove_work); ++ } ++ mutex_unlock(&devices_mutex); ++} ++ ++static const struct blk_holder_ops fitblk_hops = { ++ .mark_dead = fitblk_mark_dead, ++}; ++ ++static int parse_fit_on_dev(struct device *dev) ++{ ++ struct file *bdev_file; ++ struct block_device *bdev; ++ struct address_space *mapping; ++ struct folio *folio; ++ pgoff_t f_index = 0; ++ size_t bytes_left, bytes_to_copy; ++ void *pre_fit, *fit, *fit_c; ++ u64 dsize, dsectors, imgmaxsect = 0; ++ u32 size, image_pos, image_len; ++ const __be32 *image_offset_be, *image_len_be, *image_pos_be; ++ int ret = 0, node, images, config; ++ const char *image_name, *image_type, *image_description, ++ *config_default, *config_description, *config_loadables; ++ u32 image_name_len, image_type_len, image_description_len, ++ bootconf_len, config_default_len, config_description_len, ++ config_loadables_len; ++ sector_t start_sect, nr_sects; ++ struct device_node *np = NULL; ++ const char *bootconf_c; ++ const char *loadable; ++ char *bootconf = NULL, *bootconf_term; ++ bool found; ++ int loadables_rem_len, loadable_len; ++ u16 loadcnt; ++ unsigned int slot = 0; ++ ++ /* Exclusive open the block device to receive holder notifications */ ++ bdev_file = bdev_file_open_by_dev(dev->devt, ++ BLK_OPEN_READ | BLK_OPEN_RESTRICT_WRITES, ++ &_fitblk_claim_ptr, &fitblk_hops); ++ if (!bdev_file) ++ return -ENODEV; ++ ++ if (IS_ERR(bdev_file)) ++ return PTR_ERR(bdev_file); ++ ++ bdev = file_bdev(bdev_file); ++ mapping = bdev_file->f_mapping; ++ ++ /* map first page */ ++ folio = read_mapping_folio(mapping, f_index++, NULL); ++ if (IS_ERR(folio)) { ++ ret = PTR_ERR(folio); ++ goto out_blkdev; ++ } ++ pre_fit = folio_address(folio) + offset_in_folio(folio, 0); ++ ++ /* uImage.FIT is based on flattened device tree structure */ ++ if (fdt_check_header(pre_fit)) { ++ ret = -EINVAL; ++ folio_put(folio); ++ goto out_blkdev; ++ } ++ ++ size = fdt_totalsize(pre_fit); ++ ++ if (size > PAGE_SIZE * FIT_MAX_PAGES) { ++ ret = -EOPNOTSUPP; ++ folio_put(folio); ++ goto out_blkdev; ++ } ++ ++ /* acquire disk size */ ++ dsectors = bdev_nr_sectors(bdev); ++ dsize = dsectors << SECTOR_SHIFT; ++ ++ /* abort if FIT structure is larger than disk or partition size */ ++ if (size >= dsize) { ++ ret = -EFBIG; ++ folio_put(folio); ++ goto out_blkdev; ++ } ++ ++ fit = kmalloc(size, GFP_KERNEL); ++ if (!fit) { ++ ret = -ENOMEM; ++ folio_put(folio); ++ goto out_blkdev; ++ } ++ ++ bytes_left = size; ++ fit_c = fit; ++ while (bytes_left > 0) { ++ bytes_to_copy = min_t(size_t, bytes_left, ++ folio_size(folio) - offset_in_folio(folio, 0)); ++ memcpy(fit_c, pre_fit, bytes_to_copy); ++ fit_c += bytes_to_copy; ++ bytes_left -= bytes_to_copy; ++ if (bytes_left) { ++ folio_put(folio); ++ folio = read_mapping_folio(mapping, f_index++, NULL); ++ if (IS_ERR(folio)) { ++ ret = PTR_ERR(folio); ++ goto out_blkdev; ++ }; ++ pre_fit = folio_address(folio) + offset_in_folio(folio, 0); ++ } ++ } ++ folio_put(folio); ++ ++ /* set boot config node name U-Boot may have added to the device tree */ ++ np = of_find_node_by_path("/chosen"); ++ if (np) { ++ bootconf_c = of_get_property(np, "u-boot,bootconf", &bootconf_len); ++ if (bootconf_c && bootconf_len) ++ bootconf = kmemdup_nul(bootconf_c, bootconf_len, GFP_KERNEL); ++ } ++ ++ if (bootconf) { ++ bootconf_term = strchr(bootconf, '#'); ++ if (bootconf_term) ++ *bootconf_term = '\0'; ++ } ++ ++ /* find configuration path in uImage.FIT */ ++ config = fdt_path_offset(fit, FIT_CONFS_PATH); ++ if (config < 0) { ++ pr_err("FIT: Cannot find %s node: %d\n", ++ FIT_CONFS_PATH, config); ++ ret = -ENOENT; ++ goto out_bootconf; ++ } ++ ++ /* get default configuration node name */ ++ config_default = ++ fdt_getprop(fit, config, FIT_DEFAULT_PROP, &config_default_len); ++ ++ /* make sure we got either default or selected boot config node name */ ++ if (!config_default && !bootconf) { ++ pr_err("FIT: Cannot find default configuration\n"); ++ ret = -ENOENT; ++ goto out_bootconf; ++ } ++ ++ /* find selected boot config node, fallback on default config node */ ++ node = fdt_subnode_offset(fit, config, bootconf ?: config_default); ++ if (node < 0) { ++ pr_err("FIT: Cannot find %s node: %d\n", ++ bootconf ?: config_default, node); ++ ret = -ENOENT; ++ goto out_bootconf; ++ } ++ ++ pr_info("FIT: Detected U-Boot %s\n", ubootver); ++ ++ /* get selected configuration data */ ++ config_description = ++ fdt_getprop(fit, node, FIT_DESC_PROP, &config_description_len); ++ config_loadables = fdt_getprop(fit, node, FIT_LOADABLE_PROP, ++ &config_loadables_len); ++ ++ pr_info("FIT: %s configuration: \"%.*s\"%s%.*s%s\n", ++ bootconf ? "Selected" : "Default", ++ bootconf ? bootconf_len : config_default_len, ++ bootconf ?: config_default, ++ config_description ? " (" : "", ++ config_description ? config_description_len : 0, ++ config_description ?: "", ++ config_description ? ")" : ""); ++ ++ if (!config_loadables || !config_loadables_len) { ++ pr_err("FIT: No loadables configured in \"%s\"\n", ++ bootconf ?: config_default); ++ ret = -ENOENT; ++ goto out_bootconf; ++ } ++ ++ /* get images path in uImage.FIT */ ++ images = fdt_path_offset(fit, FIT_IMAGES_PATH); ++ if (images < 0) { ++ pr_err("FIT: Cannot find %s node: %d\n", FIT_IMAGES_PATH, images); ++ ret = -EINVAL; ++ goto out_bootconf; ++ } ++ ++ /* iterate over images in uImage.FIT */ ++ fdt_for_each_subnode(node, fit, images) { ++ image_name = fdt_get_name(fit, node, &image_name_len); ++ image_type = fdt_getprop(fit, node, FIT_TYPE_PROP, &image_type_len); ++ image_offset_be = fdt_getprop(fit, node, FIT_DATA_OFFSET_PROP, NULL); ++ image_pos_be = fdt_getprop(fit, node, FIT_DATA_POSITION_PROP, NULL); ++ image_len_be = fdt_getprop(fit, node, FIT_DATA_SIZE_PROP, NULL); ++ ++ if (!image_name || !image_type || !image_len_be || ++ !image_name_len || !image_type_len) ++ continue; ++ ++ image_len = be32_to_cpu(*image_len_be); ++ if (!image_len) ++ continue; ++ ++ if (image_offset_be) ++ image_pos = be32_to_cpu(*image_offset_be) + size; ++ else if (image_pos_be) ++ image_pos = be32_to_cpu(*image_pos_be); ++ else ++ continue; ++ ++ image_description = fdt_getprop(fit, node, FIT_DESC_PROP, ++ &image_description_len); ++ ++ pr_info("FIT: %16s sub-image 0x%08x..0x%08x \"%.*s\"%s%.*s%s\n", ++ image_type, image_pos, image_pos + image_len - 1, ++ image_name_len, image_name, image_description ? " (" : "", ++ image_description ? image_description_len : 0, ++ image_description ?: "", image_description ? ") " : ""); ++ ++ /* only 'filesystem' images should be mapped as partitions */ ++ if (strncmp(image_type, FIT_FILESYSTEM_PROP, image_type_len)) ++ continue; ++ ++ /* check if sub-image is part of configured loadables */ ++ found = false; ++ loadable = config_loadables; ++ loadables_rem_len = config_loadables_len; ++ for (loadcnt = 0; loadables_rem_len > 1 && ++ loadcnt < MAX_FIT_LOADABLES; ++loadcnt) { ++ loadable_len = ++ strnlen(loadable, loadables_rem_len - 1) + 1; ++ loadables_rem_len -= loadable_len; ++ if (!strncmp(image_name, loadable, loadable_len)) { ++ found = true; ++ break; ++ } ++ loadable += loadable_len; ++ } ++ if (!found) ++ continue; ++ ++ if (image_pos % (1 << PAGE_SHIFT)) { ++ dev_err(dev, "FIT: image %.*s start not aligned to page boundaries, skipping\n", ++ image_name_len, image_name); ++ continue; ++ } ++ ++ if (image_len % (1 << PAGE_SHIFT)) { ++ dev_err(dev, "FIT: sub-image %.*s end not aligned to page boundaries, skipping\n", ++ image_name_len, image_name); ++ continue; ++ } ++ ++ start_sect = image_pos >> SECTOR_SHIFT; ++ nr_sects = image_len >> SECTOR_SHIFT; ++ imgmaxsect = max_t(sector_t, imgmaxsect, start_sect + nr_sects); ++ ++ if (start_sect + nr_sects > dsectors) { ++ dev_err(dev, "FIT: sub-image %.*s disk access beyond EOD\n", ++ image_name_len, image_name); ++ continue; ++ } ++ ++ if (!slot) { ++ ret = sysfs_create_link_nowarn(&pdev->dev.kobj, bdev_kobj(bdev), "lower_dev"); ++ if (ret && ret != -EEXIST) ++ goto out_bootconf; ++ ++ ret = 0; ++ } ++ ++ add_fit_subimage_device(bdev_file, slot++, start_sect, nr_sects, true); ++ } ++ ++ if (!slot) ++ goto out_bootconf; ++ ++ dev_info(dev, "mapped %u uImage.FIT filesystem sub-image%s as /dev/fit%s%u%s\n", ++ slot, (slot > 1)?"s":"", (slot > 1)?"[0...":"", slot - 1, ++ (slot > 1)?"]":""); ++ ++ /* in case uImage.FIT is stored in a partition, map the remaining space */ ++ if (!bdev_read_only(bdev) && bdev_is_partition(bdev) && ++ (imgmaxsect + MIN_FREE_SECT) < dsectors) { ++ add_fit_subimage_device(bdev_file, slot++, imgmaxsect, ++ dsectors - imgmaxsect, false); ++ dev_info(dev, "mapped remaining space as /dev/fitrw\n"); ++ } ++ ++out_bootconf: ++ kfree(bootconf); ++ kfree(fit); ++out_blkdev: ++ if (!slot) ++ fput(bdev_file); ++ ++ return ret; ++} ++ ++static int fitblk_match_of_node(struct device *dev, const void *np) ++{ ++ int ret; ++ ++ ret = device_match_of_node(dev, np); ++ if (ret) ++ return ret; ++ ++ /* ++ * To match ubiblock and mtdblock devices by their parent ubi ++ * or mtd device, also consider block device parent ++ */ ++ if (!dev->parent) ++ return 0; ++ ++ return device_match_of_node(dev->parent, np); ++} ++ ++static int fitblk_probe(struct platform_device *pdev) ++{ ++ struct device *dev; ++ ++ dev = class_find_device(&block_class, NULL, rootdisk, fitblk_match_of_node); ++ if (!dev) ++ return -EPROBE_DEFER; ++ ++ return parse_fit_on_dev(dev); ++} ++ ++static struct platform_driver fitblk_driver = { ++ .probe = fitblk_probe, ++ .driver = { ++ .name = "fitblk", ++ }, ++}; ++ ++static int __init fitblk_init(void) ++{ ++ /* detect U-Boot firmware */ ++ ubootver = of_get_property(of_chosen, "u-boot,version", NULL); ++ if (!ubootver) ++ return 0; ++ ++ /* parse 'rootdisk' property phandle */ ++ rootdisk = of_parse_phandle(of_chosen, "rootdisk", 0); ++ if (!rootdisk) ++ return 0; ++ ++ if (platform_driver_register(&fitblk_driver)) ++ return -ENODEV; ++ ++ refcount_set(&num_devs, 1); ++ pdev = platform_device_register_simple("fitblk", -1, NULL, 0); ++ if (IS_ERR(pdev)) ++ return PTR_ERR(pdev); ++ ++ return 0; ++} ++device_initcall(fitblk_init); +--- /dev/null ++++ b/include/uapi/linux/fitblk.h +@@ -0,0 +1,10 @@ ++/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ ++#ifndef _UAPI_LINUX_FITBLK_H ++#define _UAPI_LINUX_FITBLK_H ++ ++/* ++ * IOCTL commands --- we will commandeer 0x46 ('F') ++ */ ++#define FITBLK_RELEASE 0x4600 ++ ++#endif /* _UAPI_LINUX_FITBLK_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/511-init-bypass-device-lookup-for-dev-fit-rootfs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/511-init-bypass-device-lookup-for-dev-fit-rootfs.patch new file mode 100755 index 0000000..b3d8d7d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/511-init-bypass-device-lookup-for-dev-fit-rootfs.patch @@ -0,0 +1,25 @@ +From 5ede3f8aed9a1a579bf7304142600d1f3500add9 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 12 Jun 2023 03:58:42 +0100 +Subject: [PATCH 2/2] init: bypass device lookup for /dev/fit* rootfs + +Allow 'rootwait' as /dev/fit* can show up late if the underlaying +device is probed late. + +Signed-off-by: Daniel Golle +--- + init/do_mounts.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/init/do_mounts.c ++++ b/init/do_mounts.c +@@ -465,7 +465,8 @@ static dev_t __init parse_root_device(ch + int error; + dev_t dev; + +- if (!strncmp(root_device_name, "mtd", 3) || ++ if (!strncmp(root_device_name, "fit", 3) || ++ !strncmp(root_device_name, "mtd", 3) || + !strncmp(root_device_name, "ubi", 3)) + return Root_Generic; + if (strcmp(root_device_name, "/dev/nfs") == 0) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/530-jffs2_make_lzma_available.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/530-jffs2_make_lzma_available.patch new file mode 100755 index 0000000..213e6f1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/530-jffs2_make_lzma_available.patch @@ -0,0 +1,5190 @@ +From: Alexandros C. Couloumbis +Subject: fs: add jffs2/lzma support (not activated by default yet) + +lede-commit: c2c88d315fa0e881f8b19da07b62859b915b11b2 +Signed-off-by: Alexandros C. Couloumbis +--- + fs/jffs2/Kconfig | 9 + + fs/jffs2/Makefile | 3 + + fs/jffs2/compr.c | 6 + + fs/jffs2/compr.h | 10 +- + fs/jffs2/compr_lzma.c | 128 +++ + fs/jffs2/super.c | 33 +- + include/linux/lzma.h | 62 ++ + include/linux/lzma/LzFind.h | 115 +++ + include/linux/lzma/LzHash.h | 54 + + include/linux/lzma/LzmaDec.h | 231 +++++ + include/linux/lzma/LzmaEnc.h | 80 ++ + include/linux/lzma/Types.h | 226 +++++ + include/uapi/linux/jffs2.h | 1 + + lib/Kconfig | 6 + + lib/Makefile | 12 + + lib/lzma/LzFind.c | 761 ++++++++++++++ + lib/lzma/LzmaDec.c | 999 +++++++++++++++++++ + lib/lzma/LzmaEnc.c | 2271 ++++++++++++++++++++++++++++++++++++++++++ + lib/lzma/Makefile | 7 + + 19 files changed, 5008 insertions(+), 6 deletions(-) + create mode 100644 fs/jffs2/compr_lzma.c + create mode 100644 include/linux/lzma.h + create mode 100644 include/linux/lzma/LzFind.h + create mode 100644 include/linux/lzma/LzHash.h + create mode 100644 include/linux/lzma/LzmaDec.h + create mode 100644 include/linux/lzma/LzmaEnc.h + create mode 100644 include/linux/lzma/Types.h + create mode 100644 lib/lzma/LzFind.c + create mode 100644 lib/lzma/LzmaDec.c + create mode 100644 lib/lzma/LzmaEnc.c + create mode 100644 lib/lzma/Makefile + +--- a/fs/jffs2/Kconfig ++++ b/fs/jffs2/Kconfig +@@ -136,6 +136,15 @@ config JFFS2_LZO + This feature was added in July, 2007. Say 'N' if you need + compatibility with older bootloaders or kernels. + ++config JFFS2_LZMA ++ bool "JFFS2 LZMA compression support" if JFFS2_COMPRESSION_OPTIONS ++ select LZMA_COMPRESS ++ select LZMA_DECOMPRESS ++ depends on JFFS2_FS ++ default n ++ help ++ JFFS2 wrapper to the LZMA C SDK ++ + config JFFS2_RTIME + bool "JFFS2 RTIME compression support" if JFFS2_COMPRESSION_OPTIONS + depends on JFFS2_FS +--- a/fs/jffs2/Makefile ++++ b/fs/jffs2/Makefile +@@ -19,4 +19,7 @@ jffs2-$(CONFIG_JFFS2_RUBIN) += compr_rub + jffs2-$(CONFIG_JFFS2_RTIME) += compr_rtime.o + jffs2-$(CONFIG_JFFS2_ZLIB) += compr_zlib.o + jffs2-$(CONFIG_JFFS2_LZO) += compr_lzo.o ++jffs2-$(CONFIG_JFFS2_LZMA) += compr_lzma.o + jffs2-$(CONFIG_JFFS2_SUMMARY) += summary.o ++ ++CFLAGS_compr_lzma.o += -Iinclude/linux -Ilib/lzma +--- a/fs/jffs2/compr.c ++++ b/fs/jffs2/compr.c +@@ -381,6 +381,9 @@ int __init jffs2_compressors_init(void) + ret = jffs2_lzo_init(); + if (ret) + goto exit_dynrubin; ++ ret = jffs2_lzma_init(); ++ if (ret) ++ goto exit_lzo; + + + /* Setting default compression mode */ +@@ -402,6 +405,8 @@ int __init jffs2_compressors_init(void) + #endif + return 0; + ++exit_lzo: ++ jffs2_lzo_exit(); + exit_dynrubin: + jffs2_dynrubin_exit(); + exit_runinmips: +@@ -417,6 +422,7 @@ exit: + int jffs2_compressors_exit(void) + { + /* Unregistering compressors */ ++ jffs2_lzma_exit(); + jffs2_lzo_exit(); + jffs2_dynrubin_exit(); + jffs2_rubinmips_exit(); +--- a/fs/jffs2/compr.h ++++ b/fs/jffs2/compr.h +@@ -29,9 +29,9 @@ + #define JFFS2_DYNRUBIN_PRIORITY 20 + #define JFFS2_LZARI_PRIORITY 30 + #define JFFS2_RTIME_PRIORITY 50 +-#define JFFS2_ZLIB_PRIORITY 60 +-#define JFFS2_LZO_PRIORITY 80 +- ++#define JFFS2_LZMA_PRIORITY 70 ++#define JFFS2_ZLIB_PRIORITY 80 ++#define JFFS2_LZO_PRIORITY 90 + + #define JFFS2_RUBINMIPS_DISABLED /* RUBINs will be used only */ + #define JFFS2_DYNRUBIN_DISABLED /* for decompression */ +@@ -115,5 +115,12 @@ extern void jffs2_lzo_exit(void); + static inline int jffs2_lzo_init(void) { return 0; } + static inline void jffs2_lzo_exit(void) {} + #endif ++#ifdef CONFIG_JFFS2_LZMA ++extern int jffs2_lzma_init(void); ++extern void jffs2_lzma_exit(void); ++#else ++static inline int jffs2_lzma_init(void) { return 0; } ++static inline void jffs2_lzma_exit(void) {} ++#endif + + #endif /* __JFFS2_COMPR_H__ */ +--- /dev/null ++++ b/fs/jffs2/compr_lzma.c +@@ -0,0 +1,128 @@ ++/* ++ * JFFS2 -- Journalling Flash File System, Version 2. ++ * ++ * For licensing information, see the file 'LICENCE' in this directory. ++ * ++ * JFFS2 wrapper to the LZMA C SDK ++ * ++ */ ++ ++#include ++#include "compr.h" ++ ++#ifdef __KERNEL__ ++ static DEFINE_MUTEX(deflate_mutex); ++#endif ++ ++CLzmaEncHandle *p; ++Byte propsEncoded[LZMA_PROPS_SIZE]; ++SizeT propsSize = sizeof(propsEncoded); ++ ++STATIC void lzma_free_workspace(void) ++{ ++ LzmaEnc_Destroy(p, &lzma_alloc, &lzma_alloc); ++} ++ ++STATIC int INIT lzma_alloc_workspace(CLzmaEncProps *props) ++{ ++ if ((p = (CLzmaEncHandle *)LzmaEnc_Create(&lzma_alloc)) == NULL) ++ { ++ PRINT_ERROR("Failed to allocate lzma deflate workspace\n"); ++ return -ENOMEM; ++ } ++ ++ if (LzmaEnc_SetProps(p, props) != SZ_OK) ++ { ++ lzma_free_workspace(); ++ return -1; ++ } ++ ++ if (LzmaEnc_WriteProperties(p, propsEncoded, &propsSize) != SZ_OK) ++ { ++ lzma_free_workspace(); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out, ++ uint32_t *sourcelen, uint32_t *dstlen) ++{ ++ SizeT compress_size = (SizeT)(*dstlen); ++ int ret; ++ ++ #ifdef __KERNEL__ ++ mutex_lock(&deflate_mutex); ++ #endif ++ ++ ret = LzmaEnc_MemEncode(p, cpage_out, &compress_size, data_in, *sourcelen, ++ 0, NULL, &lzma_alloc, &lzma_alloc); ++ ++ #ifdef __KERNEL__ ++ mutex_unlock(&deflate_mutex); ++ #endif ++ ++ if (ret != SZ_OK) ++ return -1; ++ ++ *dstlen = (uint32_t)compress_size; ++ ++ return 0; ++} ++ ++STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out, ++ uint32_t srclen, uint32_t destlen) ++{ ++ int ret; ++ SizeT dl = (SizeT)destlen; ++ SizeT sl = (SizeT)srclen; ++ ELzmaStatus status; ++ ++ ret = LzmaDecode(cpage_out, &dl, data_in, &sl, propsEncoded, ++ propsSize, LZMA_FINISH_ANY, &status, &lzma_alloc); ++ ++ if (ret != SZ_OK || status == LZMA_STATUS_NOT_FINISHED || dl != (SizeT)destlen) ++ return -1; ++ ++ return 0; ++} ++ ++static struct jffs2_compressor jffs2_lzma_comp = { ++ .priority = JFFS2_LZMA_PRIORITY, ++ .name = "lzma", ++ .compr = JFFS2_COMPR_LZMA, ++ .compress = &jffs2_lzma_compress, ++ .decompress = &jffs2_lzma_decompress, ++ .disabled = 0, ++}; ++ ++int INIT jffs2_lzma_init(void) ++{ ++ int ret; ++ CLzmaEncProps props; ++ LzmaEncProps_Init(&props); ++ ++ props.dictSize = LZMA_BEST_DICT(0x2000); ++ props.level = LZMA_BEST_LEVEL; ++ props.lc = LZMA_BEST_LC; ++ props.lp = LZMA_BEST_LP; ++ props.pb = LZMA_BEST_PB; ++ props.fb = LZMA_BEST_FB; ++ ++ ret = lzma_alloc_workspace(&props); ++ if (ret < 0) ++ return ret; ++ ++ ret = jffs2_register_compressor(&jffs2_lzma_comp); ++ if (ret) ++ lzma_free_workspace(); ++ ++ return ret; ++} ++ ++void jffs2_lzma_exit(void) ++{ ++ jffs2_unregister_compressor(&jffs2_lzma_comp); ++ lzma_free_workspace(); ++} +--- a/fs/jffs2/super.c ++++ b/fs/jffs2/super.c +@@ -376,14 +376,41 @@ static int __init init_jffs2_fs(void) + BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68); + BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32); + +- pr_info("version 2.2." ++ pr_info("version 2.2" + #ifdef CONFIG_JFFS2_FS_WRITEBUFFER + " (NAND)" + #endif + #ifdef CONFIG_JFFS2_SUMMARY +- " (SUMMARY) " ++ " (SUMMARY)" + #endif +- " Β© 2001-2006 Red Hat, Inc.\n"); ++#ifdef CONFIG_JFFS2_ZLIB ++ " (ZLIB)" ++#endif ++#ifdef CONFIG_JFFS2_LZO ++ " (LZO)" ++#endif ++#ifdef CONFIG_JFFS2_LZMA ++ " (LZMA)" ++#endif ++#ifdef CONFIG_JFFS2_RTIME ++ " (RTIME)" ++#endif ++#ifdef CONFIG_JFFS2_RUBIN ++ " (RUBIN)" ++#endif ++#ifdef CONFIG_JFFS2_CMODE_NONE ++ " (CMODE_NONE)" ++#endif ++#ifdef CONFIG_JFFS2_CMODE_PRIORITY ++ " (CMODE_PRIORITY)" ++#endif ++#ifdef CONFIG_JFFS2_CMODE_SIZE ++ " (CMODE_SIZE)" ++#endif ++#ifdef CONFIG_JFFS2_CMODE_FAVOURLZO ++ " (CMODE_FAVOURLZO)" ++#endif ++ " (c) 2001-2006 Red Hat, Inc.\n"); + + jffs2_inode_cachep = kmem_cache_create("jffs2_i", + sizeof(struct jffs2_inode_info), +--- /dev/null ++++ b/include/linux/lzma.h +@@ -0,0 +1,62 @@ ++#ifndef __LZMA_H__ ++#define __LZMA_H__ ++ ++#ifdef __KERNEL__ ++ #include ++ #include ++ #include ++ #include ++ #include ++ #define LZMA_MALLOC vmalloc ++ #define LZMA_FREE vfree ++ #define PRINT_ERROR(msg) printk(KERN_WARNING #msg) ++ #define INIT __init ++ #define STATIC static ++#else ++ #include ++ #include ++ #include ++ #include ++ #include ++ #include ++ #include ++ #include ++ #ifndef PAGE_SIZE ++ extern int page_size; ++ #define PAGE_SIZE page_size ++ #endif ++ #define LZMA_MALLOC malloc ++ #define LZMA_FREE free ++ #define PRINT_ERROR(msg) fprintf(stderr, msg) ++ #define INIT ++ #define STATIC ++#endif ++ ++#include "lzma/LzmaDec.h" ++#include "lzma/LzmaEnc.h" ++ ++#define LZMA_BEST_LEVEL (9) ++#define LZMA_BEST_LC (0) ++#define LZMA_BEST_LP (0) ++#define LZMA_BEST_PB (0) ++#define LZMA_BEST_FB (273) ++ ++#define LZMA_BEST_DICT(n) (((int)((n) / 2)) * 2) ++ ++static void *p_lzma_malloc(void *p, size_t size) ++{ ++ if (size == 0) ++ return NULL; ++ ++ return LZMA_MALLOC(size); ++} ++ ++static void p_lzma_free(void *p, void *address) ++{ ++ if (address != NULL) ++ LZMA_FREE(address); ++} ++ ++static ISzAlloc lzma_alloc = { .Alloc = p_lzma_malloc, .Free = p_lzma_free }; ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzFind.h +@@ -0,0 +1,115 @@ ++/* LzFind.h -- Match finder for LZ algorithms ++2009-04-22 : Igor Pavlov : Public domain */ ++ ++#ifndef __LZ_FIND_H ++#define __LZ_FIND_H ++ ++#include "Types.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++typedef UInt32 CLzRef; ++ ++typedef struct _CMatchFinder ++{ ++ Byte *buffer; ++ UInt32 pos; ++ UInt32 posLimit; ++ UInt32 streamPos; ++ UInt32 lenLimit; ++ ++ UInt32 cyclicBufferPos; ++ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ ++ ++ UInt32 matchMaxLen; ++ CLzRef *hash; ++ CLzRef *son; ++ UInt32 hashMask; ++ UInt32 cutValue; ++ ++ Byte *bufferBase; ++ ISeqInStream *stream; ++ int streamEndWasReached; ++ ++ UInt32 blockSize; ++ UInt32 keepSizeBefore; ++ UInt32 keepSizeAfter; ++ ++ UInt32 numHashBytes; ++ int directInput; ++ size_t directInputRem; ++ int btMode; ++ int bigHash; ++ UInt32 historySize; ++ UInt32 fixedHashSize; ++ UInt32 hashSizeSum; ++ UInt32 numSons; ++ SRes result; ++ UInt32 crc[256]; ++} CMatchFinder; ++ ++#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) ++#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)]) ++ ++#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) ++ ++int MatchFinder_NeedMove(CMatchFinder *p); ++Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); ++void MatchFinder_MoveBlock(CMatchFinder *p); ++void MatchFinder_ReadIfRequired(CMatchFinder *p); ++ ++void MatchFinder_Construct(CMatchFinder *p); ++ ++/* Conditions: ++ historySize <= 3 GB ++ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB ++*/ ++int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, ++ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ++ ISzAlloc *alloc); ++void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); ++void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems); ++void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); ++ ++UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, ++ UInt32 *distances, UInt32 maxLen); ++ ++/* ++Conditions: ++ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. ++ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function ++*/ ++ ++typedef void (*Mf_Init_Func)(void *object); ++typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index); ++typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); ++typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); ++typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); ++typedef void (*Mf_Skip_Func)(void *object, UInt32); ++ ++typedef struct _IMatchFinder ++{ ++ Mf_Init_Func Init; ++ Mf_GetIndexByte_Func GetIndexByte; ++ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; ++ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; ++ Mf_GetMatches_Func GetMatches; ++ Mf_Skip_Func Skip; ++} IMatchFinder; ++ ++void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); ++ ++void MatchFinder_Init(CMatchFinder *p); ++UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); ++UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); ++void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); ++void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzHash.h +@@ -0,0 +1,54 @@ ++/* LzHash.h -- HASH functions for LZ algorithms ++2009-02-07 : Igor Pavlov : Public domain */ ++ ++#ifndef __LZ_HASH_H ++#define __LZ_HASH_H ++ ++#define kHash2Size (1 << 10) ++#define kHash3Size (1 << 16) ++#define kHash4Size (1 << 20) ++ ++#define kFix3HashSize (kHash2Size) ++#define kFix4HashSize (kHash2Size + kHash3Size) ++#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) ++ ++#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); ++ ++#define HASH3_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } ++ ++#define HASH4_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ ++ hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } ++ ++#define HASH5_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ ++ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ ++ hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ ++ hash4Value &= (kHash4Size - 1); } ++ ++/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ ++#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; ++ ++ ++#define MT_HASH2_CALC \ ++ hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); ++ ++#define MT_HASH3_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } ++ ++#define MT_HASH4_CALC { \ ++ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ ++ hash2Value = temp & (kHash2Size - 1); \ ++ hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ ++ hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzmaDec.h +@@ -0,0 +1,231 @@ ++/* LzmaDec.h -- LZMA Decoder ++2009-02-07 : Igor Pavlov : Public domain */ ++ ++#ifndef __LZMA_DEC_H ++#define __LZMA_DEC_H ++ ++#include "Types.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* #define _LZMA_PROB32 */ ++/* _LZMA_PROB32 can increase the speed on some CPUs, ++ but memory usage for CLzmaDec::probs will be doubled in that case */ ++ ++#ifdef _LZMA_PROB32 ++#define CLzmaProb UInt32 ++#else ++#define CLzmaProb UInt16 ++#endif ++ ++ ++/* ---------- LZMA Properties ---------- */ ++ ++#define LZMA_PROPS_SIZE 5 ++ ++typedef struct _CLzmaProps ++{ ++ unsigned lc, lp, pb; ++ UInt32 dicSize; ++} CLzmaProps; ++ ++/* LzmaProps_Decode - decodes properties ++Returns: ++ SZ_OK ++ SZ_ERROR_UNSUPPORTED - Unsupported properties ++*/ ++ ++SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); ++ ++ ++/* ---------- LZMA Decoder state ---------- */ ++ ++/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. ++ Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ ++ ++#define LZMA_REQUIRED_INPUT_MAX 20 ++ ++typedef struct ++{ ++ CLzmaProps prop; ++ CLzmaProb *probs; ++ Byte *dic; ++ const Byte *buf; ++ UInt32 range, code; ++ SizeT dicPos; ++ SizeT dicBufSize; ++ UInt32 processedPos; ++ UInt32 checkDicSize; ++ unsigned state; ++ UInt32 reps[4]; ++ unsigned remainLen; ++ int needFlush; ++ int needInitState; ++ UInt32 numProbs; ++ unsigned tempBufSize; ++ Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; ++} CLzmaDec; ++ ++#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } ++ ++void LzmaDec_Init(CLzmaDec *p); ++ ++/* There are two types of LZMA streams: ++ 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. ++ 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ ++ ++typedef enum ++{ ++ LZMA_FINISH_ANY, /* finish at any point */ ++ LZMA_FINISH_END /* block must be finished at the end */ ++} ELzmaFinishMode; ++ ++/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! ++ ++ You must use LZMA_FINISH_END, when you know that current output buffer ++ covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. ++ ++ If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, ++ and output value of destLen will be less than output buffer size limit. ++ You can check status result also. ++ ++ You can use multiple checks to test data integrity after full decompression: ++ 1) Check Result and "status" variable. ++ 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. ++ 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. ++ You must use correct finish mode in that case. */ ++ ++typedef enum ++{ ++ LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ ++ LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ ++ LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ ++ LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ ++} ELzmaStatus; ++ ++/* ELzmaStatus is used only as output value for function call */ ++ ++ ++/* ---------- Interfaces ---------- */ ++ ++/* There are 3 levels of interfaces: ++ 1) Dictionary Interface ++ 2) Buffer Interface ++ 3) One Call Interface ++ You can select any of these interfaces, but don't mix functions from different ++ groups for same object. */ ++ ++ ++/* There are two variants to allocate state for Dictionary Interface: ++ 1) LzmaDec_Allocate / LzmaDec_Free ++ 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs ++ You can use variant 2, if you set dictionary buffer manually. ++ For Buffer Interface you must always use variant 1. ++ ++LzmaDec_Allocate* can return: ++ SZ_OK ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_UNSUPPORTED - Unsupported properties ++*/ ++ ++SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); ++void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); ++ ++SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); ++void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); ++ ++/* ---------- Dictionary Interface ---------- */ ++ ++/* You can use it, if you want to eliminate the overhead for data copying from ++ dictionary to some other external buffer. ++ You must work with CLzmaDec variables directly in this interface. ++ ++ STEPS: ++ LzmaDec_Constr() ++ LzmaDec_Allocate() ++ for (each new stream) ++ { ++ LzmaDec_Init() ++ while (it needs more decompression) ++ { ++ LzmaDec_DecodeToDic() ++ use data from CLzmaDec::dic and update CLzmaDec::dicPos ++ } ++ } ++ LzmaDec_Free() ++*/ ++ ++/* LzmaDec_DecodeToDic ++ ++ The decoding to internal dictionary buffer (CLzmaDec::dic). ++ You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! ++ ++finishMode: ++ It has meaning only if the decoding reaches output limit (dicLimit). ++ LZMA_FINISH_ANY - Decode just dicLimit bytes. ++ LZMA_FINISH_END - Stream must be finished after dicLimit. ++ ++Returns: ++ SZ_OK ++ status: ++ LZMA_STATUS_FINISHED_WITH_MARK ++ LZMA_STATUS_NOT_FINISHED ++ LZMA_STATUS_NEEDS_MORE_INPUT ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK ++ SZ_ERROR_DATA - Data error ++*/ ++ ++SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, ++ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); ++ ++ ++/* ---------- Buffer Interface ---------- */ ++ ++/* It's zlib-like interface. ++ See LzmaDec_DecodeToDic description for information about STEPS and return results, ++ but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need ++ to work with CLzmaDec variables manually. ++ ++finishMode: ++ It has meaning only if the decoding reaches output limit (*destLen). ++ LZMA_FINISH_ANY - Decode just destLen bytes. ++ LZMA_FINISH_END - Stream must be finished after (*destLen). ++*/ ++ ++SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, ++ const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); ++ ++ ++/* ---------- One Call Interface ---------- */ ++ ++/* LzmaDecode ++ ++finishMode: ++ It has meaning only if the decoding reaches output limit (*destLen). ++ LZMA_FINISH_ANY - Decode just destLen bytes. ++ LZMA_FINISH_END - Stream must be finished after (*destLen). ++ ++Returns: ++ SZ_OK ++ status: ++ LZMA_STATUS_FINISHED_WITH_MARK ++ LZMA_STATUS_NOT_FINISHED ++ LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK ++ SZ_ERROR_DATA - Data error ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_UNSUPPORTED - Unsupported properties ++ SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). ++*/ ++ ++SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ++ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ++ ELzmaStatus *status, ISzAlloc *alloc); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/LzmaEnc.h +@@ -0,0 +1,80 @@ ++/* LzmaEnc.h -- LZMA Encoder ++2009-02-07 : Igor Pavlov : Public domain */ ++ ++#ifndef __LZMA_ENC_H ++#define __LZMA_ENC_H ++ ++#include "Types.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#define LZMA_PROPS_SIZE 5 ++ ++typedef struct _CLzmaEncProps ++{ ++ int level; /* 0 <= level <= 9 */ ++ UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version ++ (1 << 12) <= dictSize <= (1 << 30) for 64-bit version ++ default = (1 << 24) */ ++ int lc; /* 0 <= lc <= 8, default = 3 */ ++ int lp; /* 0 <= lp <= 4, default = 0 */ ++ int pb; /* 0 <= pb <= 4, default = 2 */ ++ int algo; /* 0 - fast, 1 - normal, default = 1 */ ++ int fb; /* 5 <= fb <= 273, default = 32 */ ++ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ ++ int numHashBytes; /* 2, 3 or 4, default = 4 */ ++ UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ ++ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ ++ int numThreads; /* 1 or 2, default = 2 */ ++} CLzmaEncProps; ++ ++void LzmaEncProps_Init(CLzmaEncProps *p); ++void LzmaEncProps_Normalize(CLzmaEncProps *p); ++UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); ++ ++ ++/* ---------- CLzmaEncHandle Interface ---------- */ ++ ++/* LzmaEnc_* functions can return the following exit codes: ++Returns: ++ SZ_OK - OK ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_PARAM - Incorrect paramater in props ++ SZ_ERROR_WRITE - Write callback error. ++ SZ_ERROR_PROGRESS - some break from progress callback ++ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) ++*/ ++ ++typedef void * CLzmaEncHandle; ++ ++CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); ++void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); ++SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); ++SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); ++SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); ++SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); ++ ++/* ---------- One Call Interface ---------- */ ++ ++/* LzmaEncode ++Return code: ++ SZ_OK - OK ++ SZ_ERROR_MEM - Memory allocation error ++ SZ_ERROR_PARAM - Incorrect paramater ++ SZ_ERROR_OUTPUT_EOF - output buffer overflow ++ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) ++*/ ++ ++SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +--- /dev/null ++++ b/include/linux/lzma/Types.h +@@ -0,0 +1,226 @@ ++/* Types.h -- Basic types ++2009-11-23 : Igor Pavlov : Public domain */ ++ ++#ifndef __7Z_TYPES_H ++#define __7Z_TYPES_H ++ ++#include ++ ++#ifdef _WIN32 ++#include ++#endif ++ ++#ifndef EXTERN_C_BEGIN ++#ifdef __cplusplus ++#define EXTERN_C_BEGIN extern "C" { ++#define EXTERN_C_END } ++#else ++#define EXTERN_C_BEGIN ++#define EXTERN_C_END ++#endif ++#endif ++ ++EXTERN_C_BEGIN ++ ++#define SZ_OK 0 ++ ++#define SZ_ERROR_DATA 1 ++#define SZ_ERROR_MEM 2 ++#define SZ_ERROR_CRC 3 ++#define SZ_ERROR_UNSUPPORTED 4 ++#define SZ_ERROR_PARAM 5 ++#define SZ_ERROR_INPUT_EOF 6 ++#define SZ_ERROR_OUTPUT_EOF 7 ++#define SZ_ERROR_READ 8 ++#define SZ_ERROR_WRITE 9 ++#define SZ_ERROR_PROGRESS 10 ++#define SZ_ERROR_FAIL 11 ++#define SZ_ERROR_THREAD 12 ++ ++#define SZ_ERROR_ARCHIVE 16 ++#define SZ_ERROR_NO_ARCHIVE 17 ++ ++typedef int SRes; ++ ++#ifdef _WIN32 ++typedef DWORD WRes; ++#else ++typedef int WRes; ++#endif ++ ++#ifndef RINOK ++#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } ++#endif ++ ++typedef unsigned char Byte; ++typedef short Int16; ++typedef unsigned short UInt16; ++ ++#ifdef _LZMA_UINT32_IS_ULONG ++typedef long Int32; ++typedef unsigned long UInt32; ++#else ++typedef int Int32; ++typedef unsigned int UInt32; ++#endif ++ ++#ifdef _SZ_NO_INT_64 ++ ++/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. ++ NOTES: Some code will work incorrectly in that case! */ ++ ++typedef long Int64; ++typedef unsigned long UInt64; ++ ++#else ++ ++#if defined(_MSC_VER) || defined(__BORLANDC__) ++typedef __int64 Int64; ++typedef unsigned __int64 UInt64; ++#else ++typedef long long int Int64; ++typedef unsigned long long int UInt64; ++#endif ++ ++#endif ++ ++#ifdef _LZMA_NO_SYSTEM_SIZE_T ++typedef UInt32 SizeT; ++#else ++typedef size_t SizeT; ++#endif ++ ++typedef int Bool; ++#define True 1 ++#define False 0 ++ ++ ++#ifdef _WIN32 ++#define MY_STD_CALL __stdcall ++#else ++#define MY_STD_CALL ++#endif ++ ++#ifdef _MSC_VER ++ ++#if _MSC_VER >= 1300 ++#define MY_NO_INLINE __declspec(noinline) ++#else ++#define MY_NO_INLINE ++#endif ++ ++#define MY_CDECL __cdecl ++#define MY_FAST_CALL __fastcall ++ ++#else ++ ++#define MY_CDECL ++#define MY_FAST_CALL ++ ++#endif ++ ++ ++/* The following interfaces use first parameter as pointer to structure */ ++ ++typedef struct ++{ ++ SRes (*Read)(void *p, void *buf, size_t *size); ++ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. ++ (output(*size) < input(*size)) is allowed */ ++} ISeqInStream; ++ ++/* it can return SZ_ERROR_INPUT_EOF */ ++SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); ++SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); ++SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); ++ ++typedef struct ++{ ++ size_t (*Write)(void *p, const void *buf, size_t size); ++ /* Returns: result - the number of actually written bytes. ++ (result < size) means error */ ++} ISeqOutStream; ++ ++typedef enum ++{ ++ SZ_SEEK_SET = 0, ++ SZ_SEEK_CUR = 1, ++ SZ_SEEK_END = 2 ++} ESzSeek; ++ ++typedef struct ++{ ++ SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ ++ SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); ++} ISeekInStream; ++ ++typedef struct ++{ ++ SRes (*Look)(void *p, void **buf, size_t *size); ++ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. ++ (output(*size) > input(*size)) is not allowed ++ (output(*size) < input(*size)) is allowed */ ++ SRes (*Skip)(void *p, size_t offset); ++ /* offset must be <= output(*size) of Look */ ++ ++ SRes (*Read)(void *p, void *buf, size_t *size); ++ /* reads directly (without buffer). It's same as ISeqInStream::Read */ ++ SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); ++} ILookInStream; ++ ++SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); ++SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); ++ ++/* reads via ILookInStream::Read */ ++SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); ++SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); ++ ++#define LookToRead_BUF_SIZE (1 << 14) ++ ++typedef struct ++{ ++ ILookInStream s; ++ ISeekInStream *realStream; ++ size_t pos; ++ size_t size; ++ Byte buf[LookToRead_BUF_SIZE]; ++} CLookToRead; ++ ++void LookToRead_CreateVTable(CLookToRead *p, int lookahead); ++void LookToRead_Init(CLookToRead *p); ++ ++typedef struct ++{ ++ ISeqInStream s; ++ ILookInStream *realStream; ++} CSecToLook; ++ ++void SecToLook_CreateVTable(CSecToLook *p); ++ ++typedef struct ++{ ++ ISeqInStream s; ++ ILookInStream *realStream; ++} CSecToRead; ++ ++void SecToRead_CreateVTable(CSecToRead *p); ++ ++typedef struct ++{ ++ SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); ++ /* Returns: result. (result != SZ_OK) means break. ++ Value (UInt64)(Int64)-1 for size means unknown value. */ ++} ICompressProgress; ++ ++typedef struct ++{ ++ void *(*Alloc)(void *p, size_t size); ++ void (*Free)(void *p, void *address); /* address can be 0 */ ++} ISzAlloc; ++ ++#define IAlloc_Alloc(p, size) (p)->Alloc((p), size) ++#define IAlloc_Free(p, a) (p)->Free((p), a) ++ ++EXTERN_C_END ++ ++#endif +--- a/include/uapi/linux/jffs2.h ++++ b/include/uapi/linux/jffs2.h +@@ -46,6 +46,7 @@ + #define JFFS2_COMPR_DYNRUBIN 0x05 + #define JFFS2_COMPR_ZLIB 0x06 + #define JFFS2_COMPR_LZO 0x07 ++#define JFFS2_COMPR_LZMA 0x08 + /* Compatibility flags. */ + #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */ + #define JFFS2_NODE_ACCURATE 0x2000 +--- a/lib/Kconfig ++++ b/lib/Kconfig +@@ -353,6 +353,12 @@ config ZSTD_DECOMPRESS + + source "lib/xz/Kconfig" + ++config LZMA_COMPRESS ++ tristate ++ ++config LZMA_DECOMPRESS ++ tristate ++ + # + # These all provide a common interface (hence the apparent duplication with + # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.) +--- a/lib/Makefile ++++ b/lib/Makefile +@@ -126,6 +126,16 @@ CFLAGS_kobject.o += -DDEBUG + CFLAGS_kobject_uevent.o += -DDEBUG + endif + ++ifdef CONFIG_JFFS2_ZLIB ++ CONFIG_ZLIB_INFLATE:=y ++ CONFIG_ZLIB_DEFLATE:=y ++endif ++ ++ifdef CONFIG_JFFS2_LZMA ++ CONFIG_LZMA_DECOMPRESS:=y ++ CONFIG_LZMA_COMPRESS:=y ++endif ++ + obj-$(CONFIG_DEBUG_INFO_REDUCED) += debug_info.o + CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any) + +@@ -185,6 +195,8 @@ obj-$(CONFIG_ZSTD_COMPRESS) += zstd/ + obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd/ + obj-$(CONFIG_XZ_DEC) += xz/ + obj-$(CONFIG_RAID6_PQ) += raid6/ ++obj-$(CONFIG_LZMA_COMPRESS) += lzma/ ++obj-$(CONFIG_LZMA_DECOMPRESS) += lzma/ + + lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o + lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o +--- /dev/null ++++ b/lib/lzma/LzFind.c +@@ -0,0 +1,761 @@ ++/* LzFind.c -- Match finder for LZ algorithms ++2009-04-22 : Igor Pavlov : Public domain */ ++ ++#include ++ ++#include "LzFind.h" ++#include "LzHash.h" ++ ++#define kEmptyHashValue 0 ++#define kMaxValForNormalize ((UInt32)0xFFFFFFFF) ++#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */ ++#define kNormalizeMask (~(kNormalizeStepMin - 1)) ++#define kMaxHistorySize ((UInt32)3 << 30) ++ ++#define kStartMaxLen 3 ++ ++static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) ++{ ++ if (!p->directInput) ++ { ++ alloc->Free(alloc, p->bufferBase); ++ p->bufferBase = 0; ++ } ++} ++ ++/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ ++ ++static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) ++{ ++ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; ++ if (p->directInput) ++ { ++ p->blockSize = blockSize; ++ return 1; ++ } ++ if (p->bufferBase == 0 || p->blockSize != blockSize) ++ { ++ LzInWindow_Free(p, alloc); ++ p->blockSize = blockSize; ++ p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize); ++ } ++ return (p->bufferBase != 0); ++} ++ ++Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } ++static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; } ++ ++static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } ++ ++void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) ++{ ++ p->posLimit -= subValue; ++ p->pos -= subValue; ++ p->streamPos -= subValue; ++} ++ ++static void MatchFinder_ReadBlock(CMatchFinder *p) ++{ ++ if (p->streamEndWasReached || p->result != SZ_OK) ++ return; ++ if (p->directInput) ++ { ++ UInt32 curSize = 0xFFFFFFFF - p->streamPos; ++ if (curSize > p->directInputRem) ++ curSize = (UInt32)p->directInputRem; ++ p->directInputRem -= curSize; ++ p->streamPos += curSize; ++ if (p->directInputRem == 0) ++ p->streamEndWasReached = 1; ++ return; ++ } ++ for (;;) ++ { ++ Byte *dest = p->buffer + (p->streamPos - p->pos); ++ size_t size = (p->bufferBase + p->blockSize - dest); ++ if (size == 0) ++ return; ++ p->result = p->stream->Read(p->stream, dest, &size); ++ if (p->result != SZ_OK) ++ return; ++ if (size == 0) ++ { ++ p->streamEndWasReached = 1; ++ return; ++ } ++ p->streamPos += (UInt32)size; ++ if (p->streamPos - p->pos > p->keepSizeAfter) ++ return; ++ } ++} ++ ++void MatchFinder_MoveBlock(CMatchFinder *p) ++{ ++ memmove(p->bufferBase, ++ p->buffer - p->keepSizeBefore, ++ (size_t)(p->streamPos - p->pos + p->keepSizeBefore)); ++ p->buffer = p->bufferBase + p->keepSizeBefore; ++} ++ ++int MatchFinder_NeedMove(CMatchFinder *p) ++{ ++ if (p->directInput) ++ return 0; ++ /* if (p->streamEndWasReached) return 0; */ ++ return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); ++} ++ ++void MatchFinder_ReadIfRequired(CMatchFinder *p) ++{ ++ if (p->streamEndWasReached) ++ return; ++ if (p->keepSizeAfter >= p->streamPos - p->pos) ++ MatchFinder_ReadBlock(p); ++} ++ ++static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) ++{ ++ if (MatchFinder_NeedMove(p)) ++ MatchFinder_MoveBlock(p); ++ MatchFinder_ReadBlock(p); ++} ++ ++static void MatchFinder_SetDefaultSettings(CMatchFinder *p) ++{ ++ p->cutValue = 32; ++ p->btMode = 1; ++ p->numHashBytes = 4; ++ p->bigHash = 0; ++} ++ ++#define kCrcPoly 0xEDB88320 ++ ++void MatchFinder_Construct(CMatchFinder *p) ++{ ++ UInt32 i; ++ p->bufferBase = 0; ++ p->directInput = 0; ++ p->hash = 0; ++ MatchFinder_SetDefaultSettings(p); ++ ++ for (i = 0; i < 256; i++) ++ { ++ UInt32 r = i; ++ int j; ++ for (j = 0; j < 8; j++) ++ r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); ++ p->crc[i] = r; ++ } ++} ++ ++static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->hash); ++ p->hash = 0; ++} ++ ++void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc) ++{ ++ MatchFinder_FreeThisClassMemory(p, alloc); ++ LzInWindow_Free(p, alloc); ++} ++ ++static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc) ++{ ++ size_t sizeInBytes = (size_t)num * sizeof(CLzRef); ++ if (sizeInBytes / sizeof(CLzRef) != num) ++ return 0; ++ return (CLzRef *)alloc->Alloc(alloc, sizeInBytes); ++} ++ ++int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, ++ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ++ ISzAlloc *alloc) ++{ ++ UInt32 sizeReserv; ++ if (historySize > kMaxHistorySize) ++ { ++ MatchFinder_Free(p, alloc); ++ return 0; ++ } ++ sizeReserv = historySize >> 1; ++ if (historySize > ((UInt32)2 << 30)) ++ sizeReserv = historySize >> 2; ++ sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); ++ ++ p->keepSizeBefore = historySize + keepAddBufferBefore + 1; ++ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; ++ /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ ++ if (LzInWindow_Create(p, sizeReserv, alloc)) ++ { ++ UInt32 newCyclicBufferSize = historySize + 1; ++ UInt32 hs; ++ p->matchMaxLen = matchMaxLen; ++ { ++ p->fixedHashSize = 0; ++ if (p->numHashBytes == 2) ++ hs = (1 << 16) - 1; ++ else ++ { ++ hs = historySize - 1; ++ hs |= (hs >> 1); ++ hs |= (hs >> 2); ++ hs |= (hs >> 4); ++ hs |= (hs >> 8); ++ hs >>= 1; ++ hs |= 0xFFFF; /* don't change it! It's required for Deflate */ ++ if (hs > (1 << 24)) ++ { ++ if (p->numHashBytes == 3) ++ hs = (1 << 24) - 1; ++ else ++ hs >>= 1; ++ } ++ } ++ p->hashMask = hs; ++ hs++; ++ if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; ++ if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; ++ if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size; ++ hs += p->fixedHashSize; ++ } ++ ++ { ++ UInt32 prevSize = p->hashSizeSum + p->numSons; ++ UInt32 newSize; ++ p->historySize = historySize; ++ p->hashSizeSum = hs; ++ p->cyclicBufferSize = newCyclicBufferSize; ++ p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize); ++ newSize = p->hashSizeSum + p->numSons; ++ if (p->hash != 0 && prevSize == newSize) ++ return 1; ++ MatchFinder_FreeThisClassMemory(p, alloc); ++ p->hash = AllocRefs(newSize, alloc); ++ if (p->hash != 0) ++ { ++ p->son = p->hash + p->hashSizeSum; ++ return 1; ++ } ++ } ++ } ++ MatchFinder_Free(p, alloc); ++ return 0; ++} ++ ++static void MatchFinder_SetLimits(CMatchFinder *p) ++{ ++ UInt32 limit = kMaxValForNormalize - p->pos; ++ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; ++ if (limit2 < limit) ++ limit = limit2; ++ limit2 = p->streamPos - p->pos; ++ if (limit2 <= p->keepSizeAfter) ++ { ++ if (limit2 > 0) ++ limit2 = 1; ++ } ++ else ++ limit2 -= p->keepSizeAfter; ++ if (limit2 < limit) ++ limit = limit2; ++ { ++ UInt32 lenLimit = p->streamPos - p->pos; ++ if (lenLimit > p->matchMaxLen) ++ lenLimit = p->matchMaxLen; ++ p->lenLimit = lenLimit; ++ } ++ p->posLimit = p->pos + limit; ++} ++ ++void MatchFinder_Init(CMatchFinder *p) ++{ ++ UInt32 i; ++ for (i = 0; i < p->hashSizeSum; i++) ++ p->hash[i] = kEmptyHashValue; ++ p->cyclicBufferPos = 0; ++ p->buffer = p->bufferBase; ++ p->pos = p->streamPos = p->cyclicBufferSize; ++ p->result = SZ_OK; ++ p->streamEndWasReached = 0; ++ MatchFinder_ReadBlock(p); ++ MatchFinder_SetLimits(p); ++} ++ ++static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) ++{ ++ return (p->pos - p->historySize - 1) & kNormalizeMask; ++} ++ ++void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems) ++{ ++ UInt32 i; ++ for (i = 0; i < numItems; i++) ++ { ++ UInt32 value = items[i]; ++ if (value <= subValue) ++ value = kEmptyHashValue; ++ else ++ value -= subValue; ++ items[i] = value; ++ } ++} ++ ++static void MatchFinder_Normalize(CMatchFinder *p) ++{ ++ UInt32 subValue = MatchFinder_GetSubValue(p); ++ MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons); ++ MatchFinder_ReduceOffsets(p, subValue); ++} ++ ++static void MatchFinder_CheckLimits(CMatchFinder *p) ++{ ++ if (p->pos == kMaxValForNormalize) ++ MatchFinder_Normalize(p); ++ if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) ++ MatchFinder_CheckAndMoveAndRead(p); ++ if (p->cyclicBufferPos == p->cyclicBufferSize) ++ p->cyclicBufferPos = 0; ++ MatchFinder_SetLimits(p); ++} ++ ++static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, ++ UInt32 *distances, UInt32 maxLen) ++{ ++ son[_cyclicBufferPos] = curMatch; ++ for (;;) ++ { ++ UInt32 delta = pos - curMatch; ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize) ++ return distances; ++ { ++ const Byte *pb = cur - delta; ++ curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; ++ if (pb[maxLen] == cur[maxLen] && *pb == *cur) ++ { ++ UInt32 len = 0; ++ while (++len != lenLimit) ++ if (pb[len] != cur[len]) ++ break; ++ if (maxLen < len) ++ { ++ *distances++ = maxLen = len; ++ *distances++ = delta - 1; ++ if (len == lenLimit) ++ return distances; ++ } ++ } ++ } ++ } ++} ++ ++UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, ++ UInt32 *distances, UInt32 maxLen) ++{ ++ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; ++ CLzRef *ptr1 = son + (_cyclicBufferPos << 1); ++ UInt32 len0 = 0, len1 = 0; ++ for (;;) ++ { ++ UInt32 delta = pos - curMatch; ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize) ++ { ++ *ptr0 = *ptr1 = kEmptyHashValue; ++ return distances; ++ } ++ { ++ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); ++ const Byte *pb = cur - delta; ++ UInt32 len = (len0 < len1 ? len0 : len1); ++ if (pb[len] == cur[len]) ++ { ++ if (++len != lenLimit && pb[len] == cur[len]) ++ while (++len != lenLimit) ++ if (pb[len] != cur[len]) ++ break; ++ if (maxLen < len) ++ { ++ *distances++ = maxLen = len; ++ *distances++ = delta - 1; ++ if (len == lenLimit) ++ { ++ *ptr1 = pair[0]; ++ *ptr0 = pair[1]; ++ return distances; ++ } ++ } ++ } ++ if (pb[len] < cur[len]) ++ { ++ *ptr1 = curMatch; ++ ptr1 = pair + 1; ++ curMatch = *ptr1; ++ len1 = len; ++ } ++ else ++ { ++ *ptr0 = curMatch; ++ ptr0 = pair; ++ curMatch = *ptr0; ++ len0 = len; ++ } ++ } ++ } ++} ++ ++static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, ++ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) ++{ ++ CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; ++ CLzRef *ptr1 = son + (_cyclicBufferPos << 1); ++ UInt32 len0 = 0, len1 = 0; ++ for (;;) ++ { ++ UInt32 delta = pos - curMatch; ++ if (cutValue-- == 0 || delta >= _cyclicBufferSize) ++ { ++ *ptr0 = *ptr1 = kEmptyHashValue; ++ return; ++ } ++ { ++ CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); ++ const Byte *pb = cur - delta; ++ UInt32 len = (len0 < len1 ? len0 : len1); ++ if (pb[len] == cur[len]) ++ { ++ while (++len != lenLimit) ++ if (pb[len] != cur[len]) ++ break; ++ { ++ if (len == lenLimit) ++ { ++ *ptr1 = pair[0]; ++ *ptr0 = pair[1]; ++ return; ++ } ++ } ++ } ++ if (pb[len] < cur[len]) ++ { ++ *ptr1 = curMatch; ++ ptr1 = pair + 1; ++ curMatch = *ptr1; ++ len1 = len; ++ } ++ else ++ { ++ *ptr0 = curMatch; ++ ptr0 = pair; ++ curMatch = *ptr0; ++ len0 = len; ++ } ++ } ++ } ++} ++ ++#define MOVE_POS \ ++ ++p->cyclicBufferPos; \ ++ p->buffer++; \ ++ if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); ++ ++#define MOVE_POS_RET MOVE_POS return offset; ++ ++static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } ++ ++#define GET_MATCHES_HEADER2(minLen, ret_op) \ ++ UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ ++ lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ ++ cur = p->buffer; ++ ++#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0) ++#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue) ++ ++#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue ++ ++#define GET_MATCHES_FOOTER(offset, maxLen) \ ++ offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \ ++ distances + offset, maxLen) - distances); MOVE_POS_RET; ++ ++#define SKIP_FOOTER \ ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; ++ ++static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 offset; ++ GET_MATCHES_HEADER(2) ++ HASH2_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ offset = 0; ++ GET_MATCHES_FOOTER(offset, 1) ++} ++ ++UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 offset; ++ GET_MATCHES_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ offset = 0; ++ GET_MATCHES_FOOTER(offset, 2) ++} ++ ++static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 hash2Value, delta2, maxLen, offset; ++ GET_MATCHES_HEADER(3) ++ ++ HASH3_CALC; ++ ++ delta2 = p->pos - p->hash[hash2Value]; ++ curMatch = p->hash[kFix3HashSize + hashValue]; ++ ++ p->hash[hash2Value] = ++ p->hash[kFix3HashSize + hashValue] = p->pos; ++ ++ ++ maxLen = 2; ++ offset = 0; ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) ++ { ++ for (; maxLen != lenLimit; maxLen++) ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) ++ break; ++ distances[0] = maxLen; ++ distances[1] = delta2 - 1; ++ offset = 2; ++ if (maxLen == lenLimit) ++ { ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); ++ MOVE_POS_RET; ++ } ++ } ++ GET_MATCHES_FOOTER(offset, maxLen) ++} ++ ++static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; ++ GET_MATCHES_HEADER(4) ++ ++ HASH4_CALC; ++ ++ delta2 = p->pos - p->hash[ hash2Value]; ++ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ ++ maxLen = 1; ++ offset = 0; ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) ++ { ++ distances[0] = maxLen = 2; ++ distances[1] = delta2 - 1; ++ offset = 2; ++ } ++ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) ++ { ++ maxLen = 3; ++ distances[offset + 1] = delta3 - 1; ++ offset += 2; ++ delta2 = delta3; ++ } ++ if (offset != 0) ++ { ++ for (; maxLen != lenLimit; maxLen++) ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) ++ break; ++ distances[offset - 2] = maxLen; ++ if (maxLen == lenLimit) ++ { ++ SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); ++ MOVE_POS_RET; ++ } ++ } ++ if (maxLen < 3) ++ maxLen = 3; ++ GET_MATCHES_FOOTER(offset, maxLen) ++} ++ ++static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; ++ GET_MATCHES_HEADER(4) ++ ++ HASH4_CALC; ++ ++ delta2 = p->pos - p->hash[ hash2Value]; ++ delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ ++ maxLen = 1; ++ offset = 0; ++ if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) ++ { ++ distances[0] = maxLen = 2; ++ distances[1] = delta2 - 1; ++ offset = 2; ++ } ++ if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) ++ { ++ maxLen = 3; ++ distances[offset + 1] = delta3 - 1; ++ offset += 2; ++ delta2 = delta3; ++ } ++ if (offset != 0) ++ { ++ for (; maxLen != lenLimit; maxLen++) ++ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) ++ break; ++ distances[offset - 2] = maxLen; ++ if (maxLen == lenLimit) ++ { ++ p->son[p->cyclicBufferPos] = curMatch; ++ MOVE_POS_RET; ++ } ++ } ++ if (maxLen < 3) ++ maxLen = 3; ++ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), ++ distances + offset, maxLen) - (distances)); ++ MOVE_POS_RET ++} ++ ++UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) ++{ ++ UInt32 offset; ++ GET_MATCHES_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), ++ distances, 2) - (distances)); ++ MOVE_POS_RET ++} ++ ++static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ SKIP_HEADER(2) ++ HASH2_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ SKIP_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ UInt32 hash2Value; ++ SKIP_HEADER(3) ++ HASH3_CALC; ++ curMatch = p->hash[kFix3HashSize + hashValue]; ++ p->hash[hash2Value] = ++ p->hash[kFix3HashSize + hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ UInt32 hash2Value, hash3Value; ++ SKIP_HEADER(4) ++ HASH4_CALC; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = p->pos; ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ SKIP_FOOTER ++ } ++ while (--num != 0); ++} ++ ++static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ UInt32 hash2Value, hash3Value; ++ SKIP_HEADER(4) ++ HASH4_CALC; ++ curMatch = p->hash[kFix4HashSize + hashValue]; ++ p->hash[ hash2Value] = ++ p->hash[kFix3HashSize + hash3Value] = ++ p->hash[kFix4HashSize + hashValue] = p->pos; ++ p->son[p->cyclicBufferPos] = curMatch; ++ MOVE_POS ++ } ++ while (--num != 0); ++} ++ ++void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) ++{ ++ do ++ { ++ SKIP_HEADER(3) ++ HASH_ZIP_CALC; ++ curMatch = p->hash[hashValue]; ++ p->hash[hashValue] = p->pos; ++ p->son[p->cyclicBufferPos] = curMatch; ++ MOVE_POS ++ } ++ while (--num != 0); ++} ++ ++void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) ++{ ++ vTable->Init = (Mf_Init_Func)MatchFinder_Init; ++ vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; ++ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; ++ vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; ++ if (!p->btMode) ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; ++ } ++ else if (p->numHashBytes == 2) ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; ++ } ++ else if (p->numHashBytes == 3) ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; ++ } ++ else ++ { ++ vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; ++ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; ++ } ++} +--- /dev/null ++++ b/lib/lzma/LzmaDec.c +@@ -0,0 +1,999 @@ ++/* LzmaDec.c -- LZMA Decoder ++2009-09-20 : Igor Pavlov : Public domain */ ++ ++#include "LzmaDec.h" ++ ++#include ++ ++#define kNumTopBits 24 ++#define kTopValue ((UInt32)1 << kNumTopBits) ++ ++#define kNumBitModelTotalBits 11 ++#define kBitModelTotal (1 << kNumBitModelTotalBits) ++#define kNumMoveBits 5 ++ ++#define RC_INIT_SIZE 5 ++ ++#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } ++ ++#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) ++#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); ++#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); ++#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ ++ { UPDATE_0(p); i = (i + i); A0; } else \ ++ { UPDATE_1(p); i = (i + i) + 1; A1; } ++#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) ++ ++#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } ++#define TREE_DECODE(probs, limit, i) \ ++ { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } ++ ++/* #define _LZMA_SIZE_OPT */ ++ ++#ifdef _LZMA_SIZE_OPT ++#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) ++#else ++#define TREE_6_DECODE(probs, i) \ ++ { i = 1; \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ TREE_GET_BIT(probs, i); \ ++ i -= 0x40; } ++#endif ++ ++#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } ++ ++#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) ++#define UPDATE_0_CHECK range = bound; ++#define UPDATE_1_CHECK range -= bound; code -= bound; ++#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ ++ { UPDATE_0_CHECK; i = (i + i); A0; } else \ ++ { UPDATE_1_CHECK; i = (i + i) + 1; A1; } ++#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) ++#define TREE_DECODE_CHECK(probs, limit, i) \ ++ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } ++ ++ ++#define kNumPosBitsMax 4 ++#define kNumPosStatesMax (1 << kNumPosBitsMax) ++ ++#define kLenNumLowBits 3 ++#define kLenNumLowSymbols (1 << kLenNumLowBits) ++#define kLenNumMidBits 3 ++#define kLenNumMidSymbols (1 << kLenNumMidBits) ++#define kLenNumHighBits 8 ++#define kLenNumHighSymbols (1 << kLenNumHighBits) ++ ++#define LenChoice 0 ++#define LenChoice2 (LenChoice + 1) ++#define LenLow (LenChoice2 + 1) ++#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) ++#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) ++#define kNumLenProbs (LenHigh + kLenNumHighSymbols) ++ ++ ++#define kNumStates 12 ++#define kNumLitStates 7 ++ ++#define kStartPosModelIndex 4 ++#define kEndPosModelIndex 14 ++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) ++ ++#define kNumPosSlotBits 6 ++#define kNumLenToPosStates 4 ++ ++#define kNumAlignBits 4 ++#define kAlignTableSize (1 << kNumAlignBits) ++ ++#define kMatchMinLen 2 ++#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) ++ ++#define IsMatch 0 ++#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) ++#define IsRepG0 (IsRep + kNumStates) ++#define IsRepG1 (IsRepG0 + kNumStates) ++#define IsRepG2 (IsRepG1 + kNumStates) ++#define IsRep0Long (IsRepG2 + kNumStates) ++#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) ++#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) ++#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) ++#define LenCoder (Align + kAlignTableSize) ++#define RepLenCoder (LenCoder + kNumLenProbs) ++#define Literal (RepLenCoder + kNumLenProbs) ++ ++#define LZMA_BASE_SIZE 1846 ++#define LZMA_LIT_SIZE 768 ++ ++#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) ++ ++#if Literal != LZMA_BASE_SIZE ++StopCompilingDueBUG ++#endif ++ ++#define LZMA_DIC_MIN (1 << 12) ++ ++/* First LZMA-symbol is always decoded. ++And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization ++Out: ++ Result: ++ SZ_OK - OK ++ SZ_ERROR_DATA - Error ++ p->remainLen: ++ < kMatchSpecLenStart : normal remain ++ = kMatchSpecLenStart : finished ++ = kMatchSpecLenStart + 1 : Flush marker ++ = kMatchSpecLenStart + 2 : State Init Marker ++*/ ++ ++static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) ++{ ++ CLzmaProb *probs = p->probs; ++ ++ unsigned state = p->state; ++ UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; ++ unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; ++ unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; ++ unsigned lc = p->prop.lc; ++ ++ Byte *dic = p->dic; ++ SizeT dicBufSize = p->dicBufSize; ++ SizeT dicPos = p->dicPos; ++ ++ UInt32 processedPos = p->processedPos; ++ UInt32 checkDicSize = p->checkDicSize; ++ unsigned len = 0; ++ ++ const Byte *buf = p->buf; ++ UInt32 range = p->range; ++ UInt32 code = p->code; ++ ++ do ++ { ++ CLzmaProb *prob; ++ UInt32 bound; ++ unsigned ttt; ++ unsigned posState = processedPos & pbMask; ++ ++ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0(prob) ++ { ++ unsigned symbol; ++ UPDATE_0(prob); ++ prob = probs + Literal; ++ if (checkDicSize != 0 || processedPos != 0) ++ prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + ++ (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); ++ ++ if (state < kNumLitStates) ++ { ++ state -= (state < 4) ? state : 3; ++ symbol = 1; ++ do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); ++ } ++ else ++ { ++ unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; ++ unsigned offs = 0x100; ++ state -= (state < 10) ? 3 : 6; ++ symbol = 1; ++ do ++ { ++ unsigned bit; ++ CLzmaProb *probLit; ++ matchByte <<= 1; ++ bit = (matchByte & offs); ++ probLit = prob + offs + bit + symbol; ++ GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) ++ } ++ while (symbol < 0x100); ++ } ++ dic[dicPos++] = (Byte)symbol; ++ processedPos++; ++ continue; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ prob = probs + IsRep + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ state += kNumStates; ++ prob = probs + LenCoder; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ if (checkDicSize == 0 && processedPos == 0) ++ return SZ_ERROR_DATA; ++ prob = probs + IsRepG0 + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; ++ dicPos++; ++ processedPos++; ++ state = state < kNumLitStates ? 9 : 11; ++ continue; ++ } ++ UPDATE_1(prob); ++ } ++ else ++ { ++ UInt32 distance; ++ UPDATE_1(prob); ++ prob = probs + IsRepG1 + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ distance = rep1; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ prob = probs + IsRepG2 + state; ++ IF_BIT_0(prob) ++ { ++ UPDATE_0(prob); ++ distance = rep2; ++ } ++ else ++ { ++ UPDATE_1(prob); ++ distance = rep3; ++ rep3 = rep2; ++ } ++ rep2 = rep1; ++ } ++ rep1 = rep0; ++ rep0 = distance; ++ } ++ state = state < kNumLitStates ? 8 : 11; ++ prob = probs + RepLenCoder; ++ } ++ { ++ unsigned limit, offset; ++ CLzmaProb *probLen = prob + LenChoice; ++ IF_BIT_0(probLen) ++ { ++ UPDATE_0(probLen); ++ probLen = prob + LenLow + (posState << kLenNumLowBits); ++ offset = 0; ++ limit = (1 << kLenNumLowBits); ++ } ++ else ++ { ++ UPDATE_1(probLen); ++ probLen = prob + LenChoice2; ++ IF_BIT_0(probLen) ++ { ++ UPDATE_0(probLen); ++ probLen = prob + LenMid + (posState << kLenNumMidBits); ++ offset = kLenNumLowSymbols; ++ limit = (1 << kLenNumMidBits); ++ } ++ else ++ { ++ UPDATE_1(probLen); ++ probLen = prob + LenHigh; ++ offset = kLenNumLowSymbols + kLenNumMidSymbols; ++ limit = (1 << kLenNumHighBits); ++ } ++ } ++ TREE_DECODE(probLen, limit, len); ++ len += offset; ++ } ++ ++ if (state >= kNumStates) ++ { ++ UInt32 distance; ++ prob = probs + PosSlot + ++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); ++ TREE_6_DECODE(prob, distance); ++ if (distance >= kStartPosModelIndex) ++ { ++ unsigned posSlot = (unsigned)distance; ++ int numDirectBits = (int)(((distance >> 1) - 1)); ++ distance = (2 | (distance & 1)); ++ if (posSlot < kEndPosModelIndex) ++ { ++ distance <<= numDirectBits; ++ prob = probs + SpecPos + distance - posSlot - 1; ++ { ++ UInt32 mask = 1; ++ unsigned i = 1; ++ do ++ { ++ GET_BIT2(prob + i, i, ; , distance |= mask); ++ mask <<= 1; ++ } ++ while (--numDirectBits != 0); ++ } ++ } ++ else ++ { ++ numDirectBits -= kNumAlignBits; ++ do ++ { ++ NORMALIZE ++ range >>= 1; ++ ++ { ++ UInt32 t; ++ code -= range; ++ t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ ++ distance = (distance << 1) + (t + 1); ++ code += range & t; ++ } ++ /* ++ distance <<= 1; ++ if (code >= range) ++ { ++ code -= range; ++ distance |= 1; ++ } ++ */ ++ } ++ while (--numDirectBits != 0); ++ prob = probs + Align; ++ distance <<= kNumAlignBits; ++ { ++ unsigned i = 1; ++ GET_BIT2(prob + i, i, ; , distance |= 1); ++ GET_BIT2(prob + i, i, ; , distance |= 2); ++ GET_BIT2(prob + i, i, ; , distance |= 4); ++ GET_BIT2(prob + i, i, ; , distance |= 8); ++ } ++ if (distance == (UInt32)0xFFFFFFFF) ++ { ++ len += kMatchSpecLenStart; ++ state -= kNumStates; ++ break; ++ } ++ } ++ } ++ rep3 = rep2; ++ rep2 = rep1; ++ rep1 = rep0; ++ rep0 = distance + 1; ++ if (checkDicSize == 0) ++ { ++ if (distance >= processedPos) ++ return SZ_ERROR_DATA; ++ } ++ else if (distance >= checkDicSize) ++ return SZ_ERROR_DATA; ++ state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; ++ } ++ ++ len += kMatchMinLen; ++ ++ if (limit == dicPos) ++ return SZ_ERROR_DATA; ++ { ++ SizeT rem = limit - dicPos; ++ unsigned curLen = ((rem < len) ? (unsigned)rem : len); ++ SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); ++ ++ processedPos += curLen; ++ ++ len -= curLen; ++ if (pos + curLen <= dicBufSize) ++ { ++ Byte *dest = dic + dicPos; ++ ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; ++ const Byte *lim = dest + curLen; ++ dicPos += curLen; ++ do ++ *(dest) = (Byte)*(dest + src); ++ while (++dest != lim); ++ } ++ else ++ { ++ do ++ { ++ dic[dicPos++] = dic[pos]; ++ if (++pos == dicBufSize) ++ pos = 0; ++ } ++ while (--curLen != 0); ++ } ++ } ++ } ++ } ++ while (dicPos < limit && buf < bufLimit); ++ NORMALIZE; ++ p->buf = buf; ++ p->range = range; ++ p->code = code; ++ p->remainLen = len; ++ p->dicPos = dicPos; ++ p->processedPos = processedPos; ++ p->reps[0] = rep0; ++ p->reps[1] = rep1; ++ p->reps[2] = rep2; ++ p->reps[3] = rep3; ++ p->state = state; ++ ++ return SZ_OK; ++} ++ ++static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) ++{ ++ if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) ++ { ++ Byte *dic = p->dic; ++ SizeT dicPos = p->dicPos; ++ SizeT dicBufSize = p->dicBufSize; ++ unsigned len = p->remainLen; ++ UInt32 rep0 = p->reps[0]; ++ if (limit - dicPos < len) ++ len = (unsigned)(limit - dicPos); ++ ++ if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) ++ p->checkDicSize = p->prop.dicSize; ++ ++ p->processedPos += len; ++ p->remainLen -= len; ++ while (len-- != 0) ++ { ++ dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; ++ dicPos++; ++ } ++ p->dicPos = dicPos; ++ } ++} ++ ++static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) ++{ ++ do ++ { ++ SizeT limit2 = limit; ++ if (p->checkDicSize == 0) ++ { ++ UInt32 rem = p->prop.dicSize - p->processedPos; ++ if (limit - p->dicPos > rem) ++ limit2 = p->dicPos + rem; ++ } ++ RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); ++ if (p->processedPos >= p->prop.dicSize) ++ p->checkDicSize = p->prop.dicSize; ++ LzmaDec_WriteRem(p, limit); ++ } ++ while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); ++ ++ if (p->remainLen > kMatchSpecLenStart) ++ { ++ p->remainLen = kMatchSpecLenStart; ++ } ++ return 0; ++} ++ ++typedef enum ++{ ++ DUMMY_ERROR, /* unexpected end of input stream */ ++ DUMMY_LIT, ++ DUMMY_MATCH, ++ DUMMY_REP ++} ELzmaDummy; ++ ++static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) ++{ ++ UInt32 range = p->range; ++ UInt32 code = p->code; ++ const Byte *bufLimit = buf + inSize; ++ CLzmaProb *probs = p->probs; ++ unsigned state = p->state; ++ ELzmaDummy res; ++ ++ { ++ CLzmaProb *prob; ++ UInt32 bound; ++ unsigned ttt; ++ unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); ++ ++ prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK ++ ++ /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ ++ ++ prob = probs + Literal; ++ if (p->checkDicSize != 0 || p->processedPos != 0) ++ prob += (LZMA_LIT_SIZE * ++ ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + ++ (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); ++ ++ if (state < kNumLitStates) ++ { ++ unsigned symbol = 1; ++ do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); ++ } ++ else ++ { ++ unsigned matchByte = p->dic[p->dicPos - p->reps[0] + ++ ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; ++ unsigned offs = 0x100; ++ unsigned symbol = 1; ++ do ++ { ++ unsigned bit; ++ CLzmaProb *probLit; ++ matchByte <<= 1; ++ bit = (matchByte & offs); ++ probLit = prob + offs + bit + symbol; ++ GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) ++ } ++ while (symbol < 0x100); ++ } ++ res = DUMMY_LIT; ++ } ++ else ++ { ++ unsigned len; ++ UPDATE_1_CHECK; ++ ++ prob = probs + IsRep + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ state = 0; ++ prob = probs + LenCoder; ++ res = DUMMY_MATCH; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ res = DUMMY_REP; ++ prob = probs + IsRepG0 + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ NORMALIZE_CHECK; ++ return DUMMY_REP; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ } ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ prob = probs + IsRepG1 + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ prob = probs + IsRepG2 + state; ++ IF_BIT_0_CHECK(prob) ++ { ++ UPDATE_0_CHECK; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ } ++ } ++ } ++ state = kNumStates; ++ prob = probs + RepLenCoder; ++ } ++ { ++ unsigned limit, offset; ++ CLzmaProb *probLen = prob + LenChoice; ++ IF_BIT_0_CHECK(probLen) ++ { ++ UPDATE_0_CHECK; ++ probLen = prob + LenLow + (posState << kLenNumLowBits); ++ offset = 0; ++ limit = 1 << kLenNumLowBits; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ probLen = prob + LenChoice2; ++ IF_BIT_0_CHECK(probLen) ++ { ++ UPDATE_0_CHECK; ++ probLen = prob + LenMid + (posState << kLenNumMidBits); ++ offset = kLenNumLowSymbols; ++ limit = 1 << kLenNumMidBits; ++ } ++ else ++ { ++ UPDATE_1_CHECK; ++ probLen = prob + LenHigh; ++ offset = kLenNumLowSymbols + kLenNumMidSymbols; ++ limit = 1 << kLenNumHighBits; ++ } ++ } ++ TREE_DECODE_CHECK(probLen, limit, len); ++ len += offset; ++ } ++ ++ if (state < 4) ++ { ++ unsigned posSlot; ++ prob = probs + PosSlot + ++ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << ++ kNumPosSlotBits); ++ TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); ++ if (posSlot >= kStartPosModelIndex) ++ { ++ int numDirectBits = ((posSlot >> 1) - 1); ++ ++ /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ ++ ++ if (posSlot < kEndPosModelIndex) ++ { ++ prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; ++ } ++ else ++ { ++ numDirectBits -= kNumAlignBits; ++ do ++ { ++ NORMALIZE_CHECK ++ range >>= 1; ++ code -= range & (((code - range) >> 31) - 1); ++ /* if (code >= range) code -= range; */ ++ } ++ while (--numDirectBits != 0); ++ prob = probs + Align; ++ numDirectBits = kNumAlignBits; ++ } ++ { ++ unsigned i = 1; ++ do ++ { ++ GET_BIT_CHECK(prob + i, i); ++ } ++ while (--numDirectBits != 0); ++ } ++ } ++ } ++ } ++ } ++ NORMALIZE_CHECK; ++ return res; ++} ++ ++ ++static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) ++{ ++ p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); ++ p->range = 0xFFFFFFFF; ++ p->needFlush = 0; ++} ++ ++static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) ++{ ++ p->needFlush = 1; ++ p->remainLen = 0; ++ p->tempBufSize = 0; ++ ++ if (initDic) ++ { ++ p->processedPos = 0; ++ p->checkDicSize = 0; ++ p->needInitState = 1; ++ } ++ if (initState) ++ p->needInitState = 1; ++} ++ ++void LzmaDec_Init(CLzmaDec *p) ++{ ++ p->dicPos = 0; ++ LzmaDec_InitDicAndState(p, True, True); ++} ++ ++static void LzmaDec_InitStateReal(CLzmaDec *p) ++{ ++ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); ++ UInt32 i; ++ CLzmaProb *probs = p->probs; ++ for (i = 0; i < numProbs; i++) ++ probs[i] = kBitModelTotal >> 1; ++ p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; ++ p->state = 0; ++ p->needInitState = 0; ++} ++ ++SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, ++ ELzmaFinishMode finishMode, ELzmaStatus *status) ++{ ++ SizeT inSize = *srcLen; ++ (*srcLen) = 0; ++ LzmaDec_WriteRem(p, dicLimit); ++ ++ *status = LZMA_STATUS_NOT_SPECIFIED; ++ ++ while (p->remainLen != kMatchSpecLenStart) ++ { ++ int checkEndMarkNow; ++ ++ if (p->needFlush != 0) ++ { ++ for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) ++ p->tempBuf[p->tempBufSize++] = *src++; ++ if (p->tempBufSize < RC_INIT_SIZE) ++ { ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT; ++ return SZ_OK; ++ } ++ if (p->tempBuf[0] != 0) ++ return SZ_ERROR_DATA; ++ ++ LzmaDec_InitRc(p, p->tempBuf); ++ p->tempBufSize = 0; ++ } ++ ++ checkEndMarkNow = 0; ++ if (p->dicPos >= dicLimit) ++ { ++ if (p->remainLen == 0 && p->code == 0) ++ { ++ *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; ++ return SZ_OK; ++ } ++ if (finishMode == LZMA_FINISH_ANY) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_OK; ++ } ++ if (p->remainLen != 0) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_ERROR_DATA; ++ } ++ checkEndMarkNow = 1; ++ } ++ ++ if (p->needInitState) ++ LzmaDec_InitStateReal(p); ++ ++ if (p->tempBufSize == 0) ++ { ++ SizeT processed; ++ const Byte *bufLimit; ++ if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) ++ { ++ int dummyRes = LzmaDec_TryDummy(p, src, inSize); ++ if (dummyRes == DUMMY_ERROR) ++ { ++ memcpy(p->tempBuf, src, inSize); ++ p->tempBufSize = (unsigned)inSize; ++ (*srcLen) += inSize; ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT; ++ return SZ_OK; ++ } ++ if (checkEndMarkNow && dummyRes != DUMMY_MATCH) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_ERROR_DATA; ++ } ++ bufLimit = src; ++ } ++ else ++ bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; ++ p->buf = src; ++ if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) ++ return SZ_ERROR_DATA; ++ processed = (SizeT)(p->buf - src); ++ (*srcLen) += processed; ++ src += processed; ++ inSize -= processed; ++ } ++ else ++ { ++ unsigned rem = p->tempBufSize, lookAhead = 0; ++ while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) ++ p->tempBuf[rem++] = src[lookAhead++]; ++ p->tempBufSize = rem; ++ if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) ++ { ++ int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); ++ if (dummyRes == DUMMY_ERROR) ++ { ++ (*srcLen) += lookAhead; ++ *status = LZMA_STATUS_NEEDS_MORE_INPUT; ++ return SZ_OK; ++ } ++ if (checkEndMarkNow && dummyRes != DUMMY_MATCH) ++ { ++ *status = LZMA_STATUS_NOT_FINISHED; ++ return SZ_ERROR_DATA; ++ } ++ } ++ p->buf = p->tempBuf; ++ if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) ++ return SZ_ERROR_DATA; ++ lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); ++ (*srcLen) += lookAhead; ++ src += lookAhead; ++ inSize -= lookAhead; ++ p->tempBufSize = 0; ++ } ++ } ++ if (p->code == 0) ++ *status = LZMA_STATUS_FINISHED_WITH_MARK; ++ return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; ++} ++ ++SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) ++{ ++ SizeT outSize = *destLen; ++ SizeT inSize = *srcLen; ++ *srcLen = *destLen = 0; ++ for (;;) ++ { ++ SizeT inSizeCur = inSize, outSizeCur, dicPos; ++ ELzmaFinishMode curFinishMode; ++ SRes res; ++ if (p->dicPos == p->dicBufSize) ++ p->dicPos = 0; ++ dicPos = p->dicPos; ++ if (outSize > p->dicBufSize - dicPos) ++ { ++ outSizeCur = p->dicBufSize; ++ curFinishMode = LZMA_FINISH_ANY; ++ } ++ else ++ { ++ outSizeCur = dicPos + outSize; ++ curFinishMode = finishMode; ++ } ++ ++ res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); ++ src += inSizeCur; ++ inSize -= inSizeCur; ++ *srcLen += inSizeCur; ++ outSizeCur = p->dicPos - dicPos; ++ memcpy(dest, p->dic + dicPos, outSizeCur); ++ dest += outSizeCur; ++ outSize -= outSizeCur; ++ *destLen += outSizeCur; ++ if (res != 0) ++ return res; ++ if (outSizeCur == 0 || outSize == 0) ++ return SZ_OK; ++ } ++} ++ ++void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->probs); ++ p->probs = 0; ++} ++ ++static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->dic); ++ p->dic = 0; ++} ++ ++void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) ++{ ++ LzmaDec_FreeProbs(p, alloc); ++ LzmaDec_FreeDict(p, alloc); ++} ++ ++SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) ++{ ++ UInt32 dicSize; ++ Byte d; ++ ++ if (size < LZMA_PROPS_SIZE) ++ return SZ_ERROR_UNSUPPORTED; ++ else ++ dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); ++ ++ if (dicSize < LZMA_DIC_MIN) ++ dicSize = LZMA_DIC_MIN; ++ p->dicSize = dicSize; ++ ++ d = data[0]; ++ if (d >= (9 * 5 * 5)) ++ return SZ_ERROR_UNSUPPORTED; ++ ++ p->lc = d % 9; ++ d /= 9; ++ p->pb = d / 5; ++ p->lp = d % 5; ++ ++ return SZ_OK; ++} ++ ++static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) ++{ ++ UInt32 numProbs = LzmaProps_GetNumProbs(propNew); ++ if (p->probs == 0 || numProbs != p->numProbs) ++ { ++ LzmaDec_FreeProbs(p, alloc); ++ p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); ++ p->numProbs = numProbs; ++ if (p->probs == 0) ++ return SZ_ERROR_MEM; ++ } ++ return SZ_OK; ++} ++ ++SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) ++{ ++ CLzmaProps propNew; ++ RINOK(LzmaProps_Decode(&propNew, props, propsSize)); ++ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); ++ p->prop = propNew; ++ return SZ_OK; ++} ++ ++SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) ++{ ++ CLzmaProps propNew; ++ SizeT dicBufSize; ++ RINOK(LzmaProps_Decode(&propNew, props, propsSize)); ++ RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); ++ dicBufSize = propNew.dicSize; ++ if (p->dic == 0 || dicBufSize != p->dicBufSize) ++ { ++ LzmaDec_FreeDict(p, alloc); ++ p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); ++ if (p->dic == 0) ++ { ++ LzmaDec_FreeProbs(p, alloc); ++ return SZ_ERROR_MEM; ++ } ++ } ++ p->dicBufSize = dicBufSize; ++ p->prop = propNew; ++ return SZ_OK; ++} ++ ++SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ++ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ++ ELzmaStatus *status, ISzAlloc *alloc) ++{ ++ CLzmaDec p; ++ SRes res; ++ SizeT inSize = *srcLen; ++ SizeT outSize = *destLen; ++ *srcLen = *destLen = 0; ++ if (inSize < RC_INIT_SIZE) ++ return SZ_ERROR_INPUT_EOF; ++ ++ LzmaDec_Construct(&p); ++ res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); ++ if (res != 0) ++ return res; ++ p.dic = dest; ++ p.dicBufSize = outSize; ++ ++ LzmaDec_Init(&p); ++ ++ *srcLen = inSize; ++ res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); ++ ++ if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) ++ res = SZ_ERROR_INPUT_EOF; ++ ++ (*destLen) = p.dicPos; ++ LzmaDec_FreeProbs(&p, alloc); ++ return res; ++} +--- /dev/null ++++ b/lib/lzma/LzmaEnc.c +@@ -0,0 +1,2271 @@ ++/* LzmaEnc.c -- LZMA Encoder ++2009-11-24 : Igor Pavlov : Public domain */ ++ ++#include ++ ++/* #define SHOW_STAT */ ++/* #define SHOW_STAT2 */ ++ ++#if defined(SHOW_STAT) || defined(SHOW_STAT2) ++#include ++#endif ++ ++#include "LzmaEnc.h" ++ ++/* disable MT */ ++#define _7ZIP_ST ++ ++#include "LzFind.h" ++#ifndef _7ZIP_ST ++#include "LzFindMt.h" ++#endif ++ ++#ifdef SHOW_STAT ++static int ttt = 0; ++#endif ++ ++#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1) ++ ++#define kBlockSize (9 << 10) ++#define kUnpackBlockSize (1 << 18) ++#define kMatchArraySize (1 << 21) ++#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX) ++ ++#define kNumMaxDirectBits (31) ++ ++#define kNumTopBits 24 ++#define kTopValue ((UInt32)1 << kNumTopBits) ++ ++#define kNumBitModelTotalBits 11 ++#define kBitModelTotal (1 << kNumBitModelTotalBits) ++#define kNumMoveBits 5 ++#define kProbInitValue (kBitModelTotal >> 1) ++ ++#define kNumMoveReducingBits 4 ++#define kNumBitPriceShiftBits 4 ++#define kBitPrice (1 << kNumBitPriceShiftBits) ++ ++void LzmaEncProps_Init(CLzmaEncProps *p) ++{ ++ p->level = 5; ++ p->dictSize = p->mc = 0; ++ p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; ++ p->writeEndMark = 0; ++} ++ ++void LzmaEncProps_Normalize(CLzmaEncProps *p) ++{ ++ int level = p->level; ++ if (level < 0) level = 5; ++ p->level = level; ++ if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); ++ if (p->lc < 0) p->lc = 3; ++ if (p->lp < 0) p->lp = 0; ++ if (p->pb < 0) p->pb = 2; ++ if (p->algo < 0) p->algo = (level < 5 ? 0 : 1); ++ if (p->fb < 0) p->fb = (level < 7 ? 32 : 64); ++ if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); ++ if (p->numHashBytes < 0) p->numHashBytes = 4; ++ if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); ++ if (p->numThreads < 0) ++ p->numThreads = ++ #ifndef _7ZIP_ST ++ ((p->btMode && p->algo) ? 2 : 1); ++ #else ++ 1; ++ #endif ++} ++ ++UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) ++{ ++ CLzmaEncProps props = *props2; ++ LzmaEncProps_Normalize(&props); ++ return props.dictSize; ++} ++ ++/* #define LZMA_LOG_BSR */ ++/* Define it for Intel's CPU */ ++ ++ ++#ifdef LZMA_LOG_BSR ++ ++#define kDicLogSizeMaxCompress 30 ++ ++#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); } ++ ++UInt32 GetPosSlot1(UInt32 pos) ++{ ++ UInt32 res; ++ BSR2_RET(pos, res); ++ return res; ++} ++#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } ++#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } ++ ++#else ++ ++#define kNumLogBits (9 + (int)sizeof(size_t) / 2) ++#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) ++ ++static void LzmaEnc_FastPosInit(Byte *g_FastPos) ++{ ++ int c = 2, slotFast; ++ g_FastPos[0] = 0; ++ g_FastPos[1] = 1; ++ ++ for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++) ++ { ++ UInt32 k = (1 << ((slotFast >> 1) - 1)); ++ UInt32 j; ++ for (j = 0; j < k; j++, c++) ++ g_FastPos[c] = (Byte)slotFast; ++ } ++} ++ ++#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \ ++ (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ ++ res = p->g_FastPos[pos >> i] + (i * 2); } ++/* ++#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \ ++ p->g_FastPos[pos >> 6] + 12 : \ ++ p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; } ++*/ ++ ++#define GetPosSlot1(pos) p->g_FastPos[pos] ++#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } ++#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); } ++ ++#endif ++ ++ ++#define LZMA_NUM_REPS 4 ++ ++typedef unsigned CState; ++ ++typedef struct ++{ ++ UInt32 price; ++ ++ CState state; ++ int prev1IsChar; ++ int prev2; ++ ++ UInt32 posPrev2; ++ UInt32 backPrev2; ++ ++ UInt32 posPrev; ++ UInt32 backPrev; ++ UInt32 backs[LZMA_NUM_REPS]; ++} COptimal; ++ ++#define kNumOpts (1 << 12) ++ ++#define kNumLenToPosStates 4 ++#define kNumPosSlotBits 6 ++#define kDicLogSizeMin 0 ++#define kDicLogSizeMax 32 ++#define kDistTableSizeMax (kDicLogSizeMax * 2) ++ ++ ++#define kNumAlignBits 4 ++#define kAlignTableSize (1 << kNumAlignBits) ++#define kAlignMask (kAlignTableSize - 1) ++ ++#define kStartPosModelIndex 4 ++#define kEndPosModelIndex 14 ++#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex) ++ ++#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) ++ ++#ifdef _LZMA_PROB32 ++#define CLzmaProb UInt32 ++#else ++#define CLzmaProb UInt16 ++#endif ++ ++#define LZMA_PB_MAX 4 ++#define LZMA_LC_MAX 8 ++#define LZMA_LP_MAX 4 ++ ++#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) ++ ++ ++#define kLenNumLowBits 3 ++#define kLenNumLowSymbols (1 << kLenNumLowBits) ++#define kLenNumMidBits 3 ++#define kLenNumMidSymbols (1 << kLenNumMidBits) ++#define kLenNumHighBits 8 ++#define kLenNumHighSymbols (1 << kLenNumHighBits) ++ ++#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) ++ ++#define LZMA_MATCH_LEN_MIN 2 ++#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1) ++ ++#define kNumStates 12 ++ ++typedef struct ++{ ++ CLzmaProb choice; ++ CLzmaProb choice2; ++ CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits]; ++ CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits]; ++ CLzmaProb high[kLenNumHighSymbols]; ++} CLenEnc; ++ ++typedef struct ++{ ++ CLenEnc p; ++ UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; ++ UInt32 tableSize; ++ UInt32 counters[LZMA_NUM_PB_STATES_MAX]; ++} CLenPriceEnc; ++ ++typedef struct ++{ ++ UInt32 range; ++ Byte cache; ++ UInt64 low; ++ UInt64 cacheSize; ++ Byte *buf; ++ Byte *bufLim; ++ Byte *bufBase; ++ ISeqOutStream *outStream; ++ UInt64 processed; ++ SRes res; ++} CRangeEnc; ++ ++typedef struct ++{ ++ CLzmaProb *litProbs; ++ ++ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ CLzmaProb isRep[kNumStates]; ++ CLzmaProb isRepG0[kNumStates]; ++ CLzmaProb isRepG1[kNumStates]; ++ CLzmaProb isRepG2[kNumStates]; ++ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ ++ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; ++ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; ++ CLzmaProb posAlignEncoder[1 << kNumAlignBits]; ++ ++ CLenPriceEnc lenEnc; ++ CLenPriceEnc repLenEnc; ++ ++ UInt32 reps[LZMA_NUM_REPS]; ++ UInt32 state; ++} CSaveState; ++ ++typedef struct ++{ ++ IMatchFinder matchFinder; ++ void *matchFinderObj; ++ ++ #ifndef _7ZIP_ST ++ Bool mtMode; ++ CMatchFinderMt matchFinderMt; ++ #endif ++ ++ CMatchFinder matchFinderBase; ++ ++ #ifndef _7ZIP_ST ++ Byte pad[128]; ++ #endif ++ ++ UInt32 optimumEndIndex; ++ UInt32 optimumCurrentIndex; ++ ++ UInt32 longestMatchLength; ++ UInt32 numPairs; ++ UInt32 numAvail; ++ COptimal opt[kNumOpts]; ++ ++ #ifndef LZMA_LOG_BSR ++ Byte g_FastPos[1 << kNumLogBits]; ++ #endif ++ ++ UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; ++ UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; ++ UInt32 numFastBytes; ++ UInt32 additionalOffset; ++ UInt32 reps[LZMA_NUM_REPS]; ++ UInt32 state; ++ ++ UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; ++ UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; ++ UInt32 alignPrices[kAlignTableSize]; ++ UInt32 alignPriceCount; ++ ++ UInt32 distTableSize; ++ ++ unsigned lc, lp, pb; ++ unsigned lpMask, pbMask; ++ ++ CLzmaProb *litProbs; ++ ++ CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ CLzmaProb isRep[kNumStates]; ++ CLzmaProb isRepG0[kNumStates]; ++ CLzmaProb isRepG1[kNumStates]; ++ CLzmaProb isRepG2[kNumStates]; ++ CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; ++ ++ CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; ++ CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; ++ CLzmaProb posAlignEncoder[1 << kNumAlignBits]; ++ ++ CLenPriceEnc lenEnc; ++ CLenPriceEnc repLenEnc; ++ ++ unsigned lclp; ++ ++ Bool fastMode; ++ ++ CRangeEnc rc; ++ ++ Bool writeEndMark; ++ UInt64 nowPos64; ++ UInt32 matchPriceCount; ++ Bool finished; ++ Bool multiThread; ++ ++ SRes result; ++ UInt32 dictSize; ++ UInt32 matchFinderCycles; ++ ++ int needInit; ++ ++ CSaveState saveState; ++} CLzmaEnc; ++ ++/*void LzmaEnc_SaveState(CLzmaEncHandle pp) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ CSaveState *dest = &p->saveState; ++ int i; ++ dest->lenEnc = p->lenEnc; ++ dest->repLenEnc = p->repLenEnc; ++ dest->state = p->state; ++ ++ for (i = 0; i < kNumStates; i++) ++ { ++ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); ++ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); ++ } ++ for (i = 0; i < kNumLenToPosStates; i++) ++ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); ++ memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); ++ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); ++ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); ++ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); ++ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); ++ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); ++ memcpy(dest->reps, p->reps, sizeof(p->reps)); ++ memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); ++}*/ ++ ++/*void LzmaEnc_RestoreState(CLzmaEncHandle pp) ++{ ++ CLzmaEnc *dest = (CLzmaEnc *)pp; ++ const CSaveState *p = &dest->saveState; ++ int i; ++ dest->lenEnc = p->lenEnc; ++ dest->repLenEnc = p->repLenEnc; ++ dest->state = p->state; ++ ++ for (i = 0; i < kNumStates; i++) ++ { ++ memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); ++ memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); ++ } ++ for (i = 0; i < kNumLenToPosStates; i++) ++ memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); ++ memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); ++ memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); ++ memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); ++ memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); ++ memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); ++ memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); ++ memcpy(dest->reps, p->reps, sizeof(p->reps)); ++ memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); ++}*/ ++ ++SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ CLzmaEncProps props = *props2; ++ LzmaEncProps_Normalize(&props); ++ ++ if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX || ++ props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30)) ++ return SZ_ERROR_PARAM; ++ p->dictSize = props.dictSize; ++ p->matchFinderCycles = props.mc; ++ { ++ unsigned fb = props.fb; ++ if (fb < 5) ++ fb = 5; ++ if (fb > LZMA_MATCH_LEN_MAX) ++ fb = LZMA_MATCH_LEN_MAX; ++ p->numFastBytes = fb; ++ } ++ p->lc = props.lc; ++ p->lp = props.lp; ++ p->pb = props.pb; ++ p->fastMode = (props.algo == 0); ++ p->matchFinderBase.btMode = props.btMode; ++ { ++ UInt32 numHashBytes = 4; ++ if (props.btMode) ++ { ++ if (props.numHashBytes < 2) ++ numHashBytes = 2; ++ else if (props.numHashBytes < 4) ++ numHashBytes = props.numHashBytes; ++ } ++ p->matchFinderBase.numHashBytes = numHashBytes; ++ } ++ ++ p->matchFinderBase.cutValue = props.mc; ++ ++ p->writeEndMark = props.writeEndMark; ++ ++ #ifndef _7ZIP_ST ++ /* ++ if (newMultiThread != _multiThread) ++ { ++ ReleaseMatchFinder(); ++ _multiThread = newMultiThread; ++ } ++ */ ++ p->multiThread = (props.numThreads > 1); ++ #endif ++ ++ return SZ_OK; ++} ++ ++static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; ++static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; ++static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; ++static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; ++ ++#define IsCharState(s) ((s) < 7) ++ ++#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1) ++ ++#define kInfinityPrice (1 << 30) ++ ++static void RangeEnc_Construct(CRangeEnc *p) ++{ ++ p->outStream = 0; ++ p->bufBase = 0; ++} ++ ++#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize) ++ ++#define RC_BUF_SIZE (1 << 16) ++static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc) ++{ ++ if (p->bufBase == 0) ++ { ++ p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE); ++ if (p->bufBase == 0) ++ return 0; ++ p->bufLim = p->bufBase + RC_BUF_SIZE; ++ } ++ return 1; ++} ++ ++static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->bufBase); ++ p->bufBase = 0; ++} ++ ++static void RangeEnc_Init(CRangeEnc *p) ++{ ++ /* Stream.Init(); */ ++ p->low = 0; ++ p->range = 0xFFFFFFFF; ++ p->cacheSize = 1; ++ p->cache = 0; ++ ++ p->buf = p->bufBase; ++ ++ p->processed = 0; ++ p->res = SZ_OK; ++} ++ ++static void RangeEnc_FlushStream(CRangeEnc *p) ++{ ++ size_t num; ++ if (p->res != SZ_OK) ++ return; ++ num = p->buf - p->bufBase; ++ if (num != p->outStream->Write(p->outStream, p->bufBase, num)) ++ p->res = SZ_ERROR_WRITE; ++ p->processed += num; ++ p->buf = p->bufBase; ++} ++ ++static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) ++{ ++ if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0) ++ { ++ Byte temp = p->cache; ++ do ++ { ++ Byte *buf = p->buf; ++ *buf++ = (Byte)(temp + (Byte)(p->low >> 32)); ++ p->buf = buf; ++ if (buf == p->bufLim) ++ RangeEnc_FlushStream(p); ++ temp = 0xFF; ++ } ++ while (--p->cacheSize != 0); ++ p->cache = (Byte)((UInt32)p->low >> 24); ++ } ++ p->cacheSize++; ++ p->low = (UInt32)p->low << 8; ++} ++ ++static void RangeEnc_FlushData(CRangeEnc *p) ++{ ++ int i; ++ for (i = 0; i < 5; i++) ++ RangeEnc_ShiftLow(p); ++} ++ ++static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits) ++{ ++ do ++ { ++ p->range >>= 1; ++ p->low += p->range & (0 - ((value >> --numBits) & 1)); ++ if (p->range < kTopValue) ++ { ++ p->range <<= 8; ++ RangeEnc_ShiftLow(p); ++ } ++ } ++ while (numBits != 0); ++} ++ ++static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol) ++{ ++ UInt32 ttt = *prob; ++ UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt; ++ if (symbol == 0) ++ { ++ p->range = newBound; ++ ttt += (kBitModelTotal - ttt) >> kNumMoveBits; ++ } ++ else ++ { ++ p->low += newBound; ++ p->range -= newBound; ++ ttt -= ttt >> kNumMoveBits; ++ } ++ *prob = (CLzmaProb)ttt; ++ if (p->range < kTopValue) ++ { ++ p->range <<= 8; ++ RangeEnc_ShiftLow(p); ++ } ++} ++ ++static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol) ++{ ++ symbol |= 0x100; ++ do ++ { ++ RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1); ++ symbol <<= 1; ++ } ++ while (symbol < 0x10000); ++} ++ ++static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte) ++{ ++ UInt32 offs = 0x100; ++ symbol |= 0x100; ++ do ++ { ++ matchByte <<= 1; ++ RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1); ++ symbol <<= 1; ++ offs &= ~(matchByte ^ symbol); ++ } ++ while (symbol < 0x10000); ++} ++ ++static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices) ++{ ++ UInt32 i; ++ for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) ++ { ++ const int kCyclesBits = kNumBitPriceShiftBits; ++ UInt32 w = i; ++ UInt32 bitCount = 0; ++ int j; ++ for (j = 0; j < kCyclesBits; j++) ++ { ++ w = w * w; ++ bitCount <<= 1; ++ while (w >= ((UInt32)1 << 16)) ++ { ++ w >>= 1; ++ bitCount++; ++ } ++ } ++ ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); ++ } ++} ++ ++ ++#define GET_PRICE(prob, symbol) \ ++ p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; ++ ++#define GET_PRICEa(prob, symbol) \ ++ ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; ++ ++#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits] ++#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] ++ ++#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits] ++#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] ++ ++static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ symbol |= 0x100; ++ do ++ { ++ price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1); ++ symbol <<= 1; ++ } ++ while (symbol < 0x10000); ++ return price; ++} ++ ++static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ UInt32 offs = 0x100; ++ symbol |= 0x100; ++ do ++ { ++ matchByte <<= 1; ++ price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1); ++ symbol <<= 1; ++ offs &= ~(matchByte ^ symbol); ++ } ++ while (symbol < 0x10000); ++ return price; ++} ++ ++ ++static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) ++{ ++ UInt32 m = 1; ++ int i; ++ for (i = numBitLevels; i != 0;) ++ { ++ UInt32 bit; ++ i--; ++ bit = (symbol >> i) & 1; ++ RangeEnc_EncodeBit(rc, probs + m, bit); ++ m = (m << 1) | bit; ++ } ++} ++ ++static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) ++{ ++ UInt32 m = 1; ++ int i; ++ for (i = 0; i < numBitLevels; i++) ++ { ++ UInt32 bit = symbol & 1; ++ RangeEnc_EncodeBit(rc, probs + m, bit); ++ m = (m << 1) | bit; ++ symbol >>= 1; ++ } ++} ++ ++static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ symbol |= (1 << numBitLevels); ++ while (symbol != 1) ++ { ++ price += GET_PRICEa(probs[symbol >> 1], symbol & 1); ++ symbol >>= 1; ++ } ++ return price; ++} ++ ++static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) ++{ ++ UInt32 price = 0; ++ UInt32 m = 1; ++ int i; ++ for (i = numBitLevels; i != 0; i--) ++ { ++ UInt32 bit = symbol & 1; ++ symbol >>= 1; ++ price += GET_PRICEa(probs[m], bit); ++ m = (m << 1) | bit; ++ } ++ return price; ++} ++ ++ ++static void LenEnc_Init(CLenEnc *p) ++{ ++ unsigned i; ++ p->choice = p->choice2 = kProbInitValue; ++ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++) ++ p->low[i] = kProbInitValue; ++ for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++) ++ p->mid[i] = kProbInitValue; ++ for (i = 0; i < kLenNumHighSymbols; i++) ++ p->high[i] = kProbInitValue; ++} ++ ++static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState) ++{ ++ if (symbol < kLenNumLowSymbols) ++ { ++ RangeEnc_EncodeBit(rc, &p->choice, 0); ++ RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol); ++ } ++ else ++ { ++ RangeEnc_EncodeBit(rc, &p->choice, 1); ++ if (symbol < kLenNumLowSymbols + kLenNumMidSymbols) ++ { ++ RangeEnc_EncodeBit(rc, &p->choice2, 0); ++ RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols); ++ } ++ else ++ { ++ RangeEnc_EncodeBit(rc, &p->choice2, 1); ++ RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols); ++ } ++ } ++} ++ ++static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices) ++{ ++ UInt32 a0 = GET_PRICE_0a(p->choice); ++ UInt32 a1 = GET_PRICE_1a(p->choice); ++ UInt32 b0 = a1 + GET_PRICE_0a(p->choice2); ++ UInt32 b1 = a1 + GET_PRICE_1a(p->choice2); ++ UInt32 i = 0; ++ for (i = 0; i < kLenNumLowSymbols; i++) ++ { ++ if (i >= numSymbols) ++ return; ++ prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices); ++ } ++ for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++) ++ { ++ if (i >= numSymbols) ++ return; ++ prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices); ++ } ++ for (; i < numSymbols; i++) ++ prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices); ++} ++ ++static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices) ++{ ++ LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices); ++ p->counters[posState] = p->tableSize; ++} ++ ++static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices) ++{ ++ UInt32 posState; ++ for (posState = 0; posState < numPosStates; posState++) ++ LenPriceEnc_UpdateTable(p, posState, ProbPrices); ++} ++ ++static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices) ++{ ++ LenEnc_Encode(&p->p, rc, symbol, posState); ++ if (updatePrice) ++ if (--p->counters[posState] == 0) ++ LenPriceEnc_UpdateTable(p, posState, ProbPrices); ++} ++ ++ ++ ++ ++static void MovePos(CLzmaEnc *p, UInt32 num) ++{ ++ #ifdef SHOW_STAT ++ ttt += num; ++ printf("\n MovePos %d", num); ++ #endif ++ if (num != 0) ++ { ++ p->additionalOffset += num; ++ p->matchFinder.Skip(p->matchFinderObj, num); ++ } ++} ++ ++static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes) ++{ ++ UInt32 lenRes = 0, numPairs; ++ p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++ numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); ++ #ifdef SHOW_STAT ++ printf("\n i = %d numPairs = %d ", ttt, numPairs / 2); ++ ttt++; ++ { ++ UInt32 i; ++ for (i = 0; i < numPairs; i += 2) ++ printf("%2d %6d | ", p->matches[i], p->matches[i + 1]); ++ } ++ #endif ++ if (numPairs > 0) ++ { ++ lenRes = p->matches[numPairs - 2]; ++ if (lenRes == p->numFastBytes) ++ { ++ const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ UInt32 distance = p->matches[numPairs - 1] + 1; ++ UInt32 numAvail = p->numAvail; ++ if (numAvail > LZMA_MATCH_LEN_MAX) ++ numAvail = LZMA_MATCH_LEN_MAX; ++ { ++ const Byte *pby2 = pby - distance; ++ for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++); ++ } ++ } ++ } ++ p->additionalOffset++; ++ *numDistancePairsRes = numPairs; ++ return lenRes; ++} ++ ++ ++#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False; ++#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False; ++#define IsShortRep(p) ((p)->backPrev == 0) ++ ++static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState) ++{ ++ return ++ GET_PRICE_0(p->isRepG0[state]) + ++ GET_PRICE_0(p->isRep0Long[state][posState]); ++} ++ ++static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState) ++{ ++ UInt32 price; ++ if (repIndex == 0) ++ { ++ price = GET_PRICE_0(p->isRepG0[state]); ++ price += GET_PRICE_1(p->isRep0Long[state][posState]); ++ } ++ else ++ { ++ price = GET_PRICE_1(p->isRepG0[state]); ++ if (repIndex == 1) ++ price += GET_PRICE_0(p->isRepG1[state]); ++ else ++ { ++ price += GET_PRICE_1(p->isRepG1[state]); ++ price += GET_PRICE(p->isRepG2[state], repIndex - 2); ++ } ++ } ++ return price; ++} ++ ++static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState) ++{ ++ return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] + ++ GetPureRepPrice(p, repIndex, state, posState); ++} ++ ++static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) ++{ ++ UInt32 posMem = p->opt[cur].posPrev; ++ UInt32 backMem = p->opt[cur].backPrev; ++ p->optimumEndIndex = cur; ++ do ++ { ++ if (p->opt[cur].prev1IsChar) ++ { ++ MakeAsChar(&p->opt[posMem]) ++ p->opt[posMem].posPrev = posMem - 1; ++ if (p->opt[cur].prev2) ++ { ++ p->opt[posMem - 1].prev1IsChar = False; ++ p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2; ++ p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2; ++ } ++ } ++ { ++ UInt32 posPrev = posMem; ++ UInt32 backCur = backMem; ++ ++ backMem = p->opt[posPrev].backPrev; ++ posMem = p->opt[posPrev].posPrev; ++ ++ p->opt[posPrev].backPrev = backCur; ++ p->opt[posPrev].posPrev = cur; ++ cur = posPrev; ++ } ++ } ++ while (cur != 0); ++ *backRes = p->opt[0].backPrev; ++ p->optimumCurrentIndex = p->opt[0].posPrev; ++ return p->optimumCurrentIndex; ++} ++ ++#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300) ++ ++static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) ++{ ++ UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur; ++ UInt32 matchPrice, repMatchPrice, normalMatchPrice; ++ UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS]; ++ UInt32 *matches; ++ const Byte *data; ++ Byte curByte, matchByte; ++ if (p->optimumEndIndex != p->optimumCurrentIndex) ++ { ++ const COptimal *opt = &p->opt[p->optimumCurrentIndex]; ++ UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex; ++ *backRes = opt->backPrev; ++ p->optimumCurrentIndex = opt->posPrev; ++ return lenRes; ++ } ++ p->optimumCurrentIndex = p->optimumEndIndex = 0; ++ ++ if (p->additionalOffset == 0) ++ mainLen = ReadMatchDistances(p, &numPairs); ++ else ++ { ++ mainLen = p->longestMatchLength; ++ numPairs = p->numPairs; ++ } ++ ++ numAvail = p->numAvail; ++ if (numAvail < 2) ++ { ++ *backRes = (UInt32)(-1); ++ return 1; ++ } ++ if (numAvail > LZMA_MATCH_LEN_MAX) ++ numAvail = LZMA_MATCH_LEN_MAX; ++ ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ repMaxIndex = 0; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 lenTest; ++ const Byte *data2; ++ reps[i] = p->reps[i]; ++ data2 = data - (reps[i] + 1); ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ { ++ repLens[i] = 0; ++ continue; ++ } ++ for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++); ++ repLens[i] = lenTest; ++ if (lenTest > repLens[repMaxIndex]) ++ repMaxIndex = i; ++ } ++ if (repLens[repMaxIndex] >= p->numFastBytes) ++ { ++ UInt32 lenRes; ++ *backRes = repMaxIndex; ++ lenRes = repLens[repMaxIndex]; ++ MovePos(p, lenRes - 1); ++ return lenRes; ++ } ++ ++ matches = p->matches; ++ if (mainLen >= p->numFastBytes) ++ { ++ *backRes = matches[numPairs - 1] + LZMA_NUM_REPS; ++ MovePos(p, mainLen - 1); ++ return mainLen; ++ } ++ curByte = *data; ++ matchByte = *(data - (reps[0] + 1)); ++ ++ if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2) ++ { ++ *backRes = (UInt32)-1; ++ return 1; ++ } ++ ++ p->opt[0].state = (CState)p->state; ++ ++ posState = (position & p->pbMask); ++ ++ { ++ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); ++ p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + ++ (!IsCharState(p->state) ? ++ LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) : ++ LitEnc_GetPrice(probs, curByte, p->ProbPrices)); ++ } ++ ++ MakeAsChar(&p->opt[1]); ++ ++ matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); ++ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); ++ ++ if (matchByte == curByte) ++ { ++ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState); ++ if (shortRepPrice < p->opt[1].price) ++ { ++ p->opt[1].price = shortRepPrice; ++ MakeAsShortRep(&p->opt[1]); ++ } ++ } ++ lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]); ++ ++ if (lenEnd < 2) ++ { ++ *backRes = p->opt[1].backPrev; ++ return 1; ++ } ++ ++ p->opt[1].posPrev = 0; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ p->opt[0].backs[i] = reps[i]; ++ ++ len = lenEnd; ++ do ++ p->opt[len--].price = kInfinityPrice; ++ while (len >= 2); ++ ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 repLen = repLens[i]; ++ UInt32 price; ++ if (repLen < 2) ++ continue; ++ price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState); ++ do ++ { ++ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2]; ++ COptimal *opt = &p->opt[repLen]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = 0; ++ opt->backPrev = i; ++ opt->prev1IsChar = False; ++ } ++ } ++ while (--repLen >= 2); ++ } ++ ++ normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); ++ ++ len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2); ++ if (len <= mainLen) ++ { ++ UInt32 offs = 0; ++ while (len > matches[offs]) ++ offs += 2; ++ for (; ; len++) ++ { ++ COptimal *opt; ++ UInt32 distance = matches[offs + 1]; ++ ++ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN]; ++ UInt32 lenToPosState = GetLenToPosState(len); ++ if (distance < kNumFullDistances) ++ curAndLenPrice += p->distancesPrices[lenToPosState][distance]; ++ else ++ { ++ UInt32 slot; ++ GetPosSlot2(distance, slot); ++ curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot]; ++ } ++ opt = &p->opt[len]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = 0; ++ opt->backPrev = distance + LZMA_NUM_REPS; ++ opt->prev1IsChar = False; ++ } ++ if (len == matches[offs]) ++ { ++ offs += 2; ++ if (offs == numPairs) ++ break; ++ } ++ } ++ } ++ ++ cur = 0; ++ ++ #ifdef SHOW_STAT2 ++ if (position >= 0) ++ { ++ unsigned i; ++ printf("\n pos = %4X", position); ++ for (i = cur; i <= lenEnd; i++) ++ printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price); ++ } ++ #endif ++ ++ for (;;) ++ { ++ UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen; ++ UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice; ++ Bool nextIsChar; ++ Byte curByte, matchByte; ++ const Byte *data; ++ COptimal *curOpt; ++ COptimal *nextOpt; ++ ++ cur++; ++ if (cur == lenEnd) ++ return Backward(p, backRes, cur); ++ ++ newLen = ReadMatchDistances(p, &numPairs); ++ if (newLen >= p->numFastBytes) ++ { ++ p->numPairs = numPairs; ++ p->longestMatchLength = newLen; ++ return Backward(p, backRes, cur); ++ } ++ position++; ++ curOpt = &p->opt[cur]; ++ posPrev = curOpt->posPrev; ++ if (curOpt->prev1IsChar) ++ { ++ posPrev--; ++ if (curOpt->prev2) ++ { ++ state = p->opt[curOpt->posPrev2].state; ++ if (curOpt->backPrev2 < LZMA_NUM_REPS) ++ state = kRepNextStates[state]; ++ else ++ state = kMatchNextStates[state]; ++ } ++ else ++ state = p->opt[posPrev].state; ++ state = kLiteralNextStates[state]; ++ } ++ else ++ state = p->opt[posPrev].state; ++ if (posPrev == cur - 1) ++ { ++ if (IsShortRep(curOpt)) ++ state = kShortRepNextStates[state]; ++ else ++ state = kLiteralNextStates[state]; ++ } ++ else ++ { ++ UInt32 pos; ++ const COptimal *prevOpt; ++ if (curOpt->prev1IsChar && curOpt->prev2) ++ { ++ posPrev = curOpt->posPrev2; ++ pos = curOpt->backPrev2; ++ state = kRepNextStates[state]; ++ } ++ else ++ { ++ pos = curOpt->backPrev; ++ if (pos < LZMA_NUM_REPS) ++ state = kRepNextStates[state]; ++ else ++ state = kMatchNextStates[state]; ++ } ++ prevOpt = &p->opt[posPrev]; ++ if (pos < LZMA_NUM_REPS) ++ { ++ UInt32 i; ++ reps[0] = prevOpt->backs[pos]; ++ for (i = 1; i <= pos; i++) ++ reps[i] = prevOpt->backs[i - 1]; ++ for (; i < LZMA_NUM_REPS; i++) ++ reps[i] = prevOpt->backs[i]; ++ } ++ else ++ { ++ UInt32 i; ++ reps[0] = (pos - LZMA_NUM_REPS); ++ for (i = 1; i < LZMA_NUM_REPS; i++) ++ reps[i] = prevOpt->backs[i - 1]; ++ } ++ } ++ curOpt->state = (CState)state; ++ ++ curOpt->backs[0] = reps[0]; ++ curOpt->backs[1] = reps[1]; ++ curOpt->backs[2] = reps[2]; ++ curOpt->backs[3] = reps[3]; ++ ++ curPrice = curOpt->price; ++ nextIsChar = False; ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ curByte = *data; ++ matchByte = *(data - (reps[0] + 1)); ++ ++ posState = (position & p->pbMask); ++ ++ curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]); ++ { ++ const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); ++ curAnd1Price += ++ (!IsCharState(state) ? ++ LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) : ++ LitEnc_GetPrice(probs, curByte, p->ProbPrices)); ++ } ++ ++ nextOpt = &p->opt[cur + 1]; ++ ++ if (curAnd1Price < nextOpt->price) ++ { ++ nextOpt->price = curAnd1Price; ++ nextOpt->posPrev = cur; ++ MakeAsChar(nextOpt); ++ nextIsChar = True; ++ } ++ ++ matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); ++ repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); ++ ++ if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) ++ { ++ UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); ++ if (shortRepPrice <= nextOpt->price) ++ { ++ nextOpt->price = shortRepPrice; ++ nextOpt->posPrev = cur; ++ MakeAsShortRep(nextOpt); ++ nextIsChar = True; ++ } ++ } ++ numAvailFull = p->numAvail; ++ { ++ UInt32 temp = kNumOpts - 1 - cur; ++ if (temp < numAvailFull) ++ numAvailFull = temp; ++ } ++ ++ if (numAvailFull < 2) ++ continue; ++ numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes); ++ ++ if (!nextIsChar && matchByte != curByte) /* speed optimization */ ++ { ++ /* try Literal + rep0 */ ++ UInt32 temp; ++ UInt32 lenTest2; ++ const Byte *data2 = data - (reps[0] + 1); ++ UInt32 limit = p->numFastBytes + 1; ++ if (limit > numAvailFull) ++ limit = numAvailFull; ++ ++ for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++); ++ lenTest2 = temp - 1; ++ if (lenTest2 >= 2) ++ { ++ UInt32 state2 = kLiteralNextStates[state]; ++ UInt32 posStateNext = (position + 1) & p->pbMask; ++ UInt32 nextRepMatchPrice = curAnd1Price + ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) + ++ GET_PRICE_1(p->isRep[state2]); ++ /* for (; lenTest2 >= 2; lenTest2--) */ ++ { ++ UInt32 curAndLenPrice; ++ COptimal *opt; ++ UInt32 offset = cur + 1 + lenTest2; ++ while (lenEnd < offset) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); ++ opt = &p->opt[offset]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur + 1; ++ opt->backPrev = 0; ++ opt->prev1IsChar = True; ++ opt->prev2 = False; ++ } ++ } ++ } ++ } ++ ++ startLen = 2; /* speed optimization */ ++ { ++ UInt32 repIndex; ++ for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++) ++ { ++ UInt32 lenTest; ++ UInt32 lenTestTemp; ++ UInt32 price; ++ const Byte *data2 = data - (reps[repIndex] + 1); ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ continue; ++ for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++); ++ while (lenEnd < cur + lenTest) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ lenTestTemp = lenTest; ++ price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState); ++ do ++ { ++ UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2]; ++ COptimal *opt = &p->opt[cur + lenTest]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur; ++ opt->backPrev = repIndex; ++ opt->prev1IsChar = False; ++ } ++ } ++ while (--lenTest >= 2); ++ lenTest = lenTestTemp; ++ ++ if (repIndex == 0) ++ startLen = lenTest + 1; ++ ++ /* if (_maxMode) */ ++ { ++ UInt32 lenTest2 = lenTest + 1; ++ UInt32 limit = lenTest2 + p->numFastBytes; ++ UInt32 nextRepMatchPrice; ++ if (limit > numAvailFull) ++ limit = numAvailFull; ++ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); ++ lenTest2 -= lenTest + 1; ++ if (lenTest2 >= 2) ++ { ++ UInt32 state2 = kRepNextStates[state]; ++ UInt32 posStateNext = (position + lenTest) & p->pbMask; ++ UInt32 curAndLenCharPrice = ++ price + p->repLenEnc.prices[posState][lenTest - 2] + ++ GET_PRICE_0(p->isMatch[state2][posStateNext]) + ++ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), ++ data[lenTest], data2[lenTest], p->ProbPrices); ++ state2 = kLiteralNextStates[state2]; ++ posStateNext = (position + lenTest + 1) & p->pbMask; ++ nextRepMatchPrice = curAndLenCharPrice + ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) + ++ GET_PRICE_1(p->isRep[state2]); ++ ++ /* for (; lenTest2 >= 2; lenTest2--) */ ++ { ++ UInt32 curAndLenPrice; ++ COptimal *opt; ++ UInt32 offset = cur + lenTest + 1 + lenTest2; ++ while (lenEnd < offset) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); ++ opt = &p->opt[offset]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur + lenTest + 1; ++ opt->backPrev = 0; ++ opt->prev1IsChar = True; ++ opt->prev2 = True; ++ opt->posPrev2 = cur; ++ opt->backPrev2 = repIndex; ++ } ++ } ++ } ++ } ++ } ++ } ++ /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */ ++ if (newLen > numAvail) ++ { ++ newLen = numAvail; ++ for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2); ++ matches[numPairs] = newLen; ++ numPairs += 2; ++ } ++ if (newLen >= startLen) ++ { ++ UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); ++ UInt32 offs, curBack, posSlot; ++ UInt32 lenTest; ++ while (lenEnd < cur + newLen) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ ++ offs = 0; ++ while (startLen > matches[offs]) ++ offs += 2; ++ curBack = matches[offs + 1]; ++ GetPosSlot2(curBack, posSlot); ++ for (lenTest = /*2*/ startLen; ; lenTest++) ++ { ++ UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN]; ++ UInt32 lenToPosState = GetLenToPosState(lenTest); ++ COptimal *opt; ++ if (curBack < kNumFullDistances) ++ curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; ++ else ++ curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; ++ ++ opt = &p->opt[cur + lenTest]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur; ++ opt->backPrev = curBack + LZMA_NUM_REPS; ++ opt->prev1IsChar = False; ++ } ++ ++ if (/*_maxMode && */lenTest == matches[offs]) ++ { ++ /* Try Match + Literal + Rep0 */ ++ const Byte *data2 = data - (curBack + 1); ++ UInt32 lenTest2 = lenTest + 1; ++ UInt32 limit = lenTest2 + p->numFastBytes; ++ UInt32 nextRepMatchPrice; ++ if (limit > numAvailFull) ++ limit = numAvailFull; ++ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); ++ lenTest2 -= lenTest + 1; ++ if (lenTest2 >= 2) ++ { ++ UInt32 state2 = kMatchNextStates[state]; ++ UInt32 posStateNext = (position + lenTest) & p->pbMask; ++ UInt32 curAndLenCharPrice = curAndLenPrice + ++ GET_PRICE_0(p->isMatch[state2][posStateNext]) + ++ LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), ++ data[lenTest], data2[lenTest], p->ProbPrices); ++ state2 = kLiteralNextStates[state2]; ++ posStateNext = (posStateNext + 1) & p->pbMask; ++ nextRepMatchPrice = curAndLenCharPrice + ++ GET_PRICE_1(p->isMatch[state2][posStateNext]) + ++ GET_PRICE_1(p->isRep[state2]); ++ ++ /* for (; lenTest2 >= 2; lenTest2--) */ ++ { ++ UInt32 offset = cur + lenTest + 1 + lenTest2; ++ UInt32 curAndLenPrice; ++ COptimal *opt; ++ while (lenEnd < offset) ++ p->opt[++lenEnd].price = kInfinityPrice; ++ curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); ++ opt = &p->opt[offset]; ++ if (curAndLenPrice < opt->price) ++ { ++ opt->price = curAndLenPrice; ++ opt->posPrev = cur + lenTest + 1; ++ opt->backPrev = 0; ++ opt->prev1IsChar = True; ++ opt->prev2 = True; ++ opt->posPrev2 = cur; ++ opt->backPrev2 = curBack + LZMA_NUM_REPS; ++ } ++ } ++ } ++ offs += 2; ++ if (offs == numPairs) ++ break; ++ curBack = matches[offs + 1]; ++ if (curBack >= kNumFullDistances) ++ GetPosSlot2(curBack, posSlot); ++ } ++ } ++ } ++ } ++} ++ ++#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist)) ++ ++static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) ++{ ++ UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i; ++ const Byte *data; ++ const UInt32 *matches; ++ ++ if (p->additionalOffset == 0) ++ mainLen = ReadMatchDistances(p, &numPairs); ++ else ++ { ++ mainLen = p->longestMatchLength; ++ numPairs = p->numPairs; ++ } ++ ++ numAvail = p->numAvail; ++ *backRes = (UInt32)-1; ++ if (numAvail < 2) ++ return 1; ++ if (numAvail > LZMA_MATCH_LEN_MAX) ++ numAvail = LZMA_MATCH_LEN_MAX; ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ ++ repLen = repIndex = 0; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 len; ++ const Byte *data2 = data - (p->reps[i] + 1); ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ continue; ++ for (len = 2; len < numAvail && data[len] == data2[len]; len++); ++ if (len >= p->numFastBytes) ++ { ++ *backRes = i; ++ MovePos(p, len - 1); ++ return len; ++ } ++ if (len > repLen) ++ { ++ repIndex = i; ++ repLen = len; ++ } ++ } ++ ++ matches = p->matches; ++ if (mainLen >= p->numFastBytes) ++ { ++ *backRes = matches[numPairs - 1] + LZMA_NUM_REPS; ++ MovePos(p, mainLen - 1); ++ return mainLen; ++ } ++ ++ mainDist = 0; /* for GCC */ ++ if (mainLen >= 2) ++ { ++ mainDist = matches[numPairs - 1]; ++ while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1) ++ { ++ if (!ChangePair(matches[numPairs - 3], mainDist)) ++ break; ++ numPairs -= 2; ++ mainLen = matches[numPairs - 2]; ++ mainDist = matches[numPairs - 1]; ++ } ++ if (mainLen == 2 && mainDist >= 0x80) ++ mainLen = 1; ++ } ++ ++ if (repLen >= 2 && ( ++ (repLen + 1 >= mainLen) || ++ (repLen + 2 >= mainLen && mainDist >= (1 << 9)) || ++ (repLen + 3 >= mainLen && mainDist >= (1 << 15)))) ++ { ++ *backRes = repIndex; ++ MovePos(p, repLen - 1); ++ return repLen; ++ } ++ ++ if (mainLen < 2 || numAvail <= 2) ++ return 1; ++ ++ p->longestMatchLength = ReadMatchDistances(p, &p->numPairs); ++ if (p->longestMatchLength >= 2) ++ { ++ UInt32 newDistance = matches[p->numPairs - 1]; ++ if ((p->longestMatchLength >= mainLen && newDistance < mainDist) || ++ (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) || ++ (p->longestMatchLength > mainLen + 1) || ++ (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) ++ return 1; ++ } ++ ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; ++ for (i = 0; i < LZMA_NUM_REPS; i++) ++ { ++ UInt32 len, limit; ++ const Byte *data2 = data - (p->reps[i] + 1); ++ if (data[0] != data2[0] || data[1] != data2[1]) ++ continue; ++ limit = mainLen - 1; ++ for (len = 2; len < limit && data[len] == data2[len]; len++); ++ if (len >= limit) ++ return 1; ++ } ++ *backRes = mainDist + LZMA_NUM_REPS; ++ MovePos(p, mainLen - 2); ++ return mainLen; ++} ++ ++static void WriteEndMarker(CLzmaEnc *p, UInt32 posState) ++{ ++ UInt32 len; ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); ++ p->state = kMatchNextStates[p->state]; ++ len = LZMA_MATCH_LEN_MIN; ++ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); ++ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1); ++ RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits); ++ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); ++} ++ ++static SRes CheckErrors(CLzmaEnc *p) ++{ ++ if (p->result != SZ_OK) ++ return p->result; ++ if (p->rc.res != SZ_OK) ++ p->result = SZ_ERROR_WRITE; ++ if (p->matchFinderBase.result != SZ_OK) ++ p->result = SZ_ERROR_READ; ++ if (p->result != SZ_OK) ++ p->finished = True; ++ return p->result; ++} ++ ++static SRes Flush(CLzmaEnc *p, UInt32 nowPos) ++{ ++ /* ReleaseMFStream(); */ ++ p->finished = True; ++ if (p->writeEndMark) ++ WriteEndMarker(p, nowPos & p->pbMask); ++ RangeEnc_FlushData(&p->rc); ++ RangeEnc_FlushStream(&p->rc); ++ return CheckErrors(p); ++} ++ ++static void FillAlignPrices(CLzmaEnc *p) ++{ ++ UInt32 i; ++ for (i = 0; i < kAlignTableSize; i++) ++ p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); ++ p->alignPriceCount = 0; ++} ++ ++static void FillDistancesPrices(CLzmaEnc *p) ++{ ++ UInt32 tempPrices[kNumFullDistances]; ++ UInt32 i, lenToPosState; ++ for (i = kStartPosModelIndex; i < kNumFullDistances; i++) ++ { ++ UInt32 posSlot = GetPosSlot1(i); ++ UInt32 footerBits = ((posSlot >> 1) - 1); ++ UInt32 base = ((2 | (posSlot & 1)) << footerBits); ++ tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices); ++ } ++ ++ for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++) ++ { ++ UInt32 posSlot; ++ const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState]; ++ UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState]; ++ for (posSlot = 0; posSlot < p->distTableSize; posSlot++) ++ posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices); ++ for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++) ++ posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits); ++ ++ { ++ UInt32 *distancesPrices = p->distancesPrices[lenToPosState]; ++ UInt32 i; ++ for (i = 0; i < kStartPosModelIndex; i++) ++ distancesPrices[i] = posSlotPrices[i]; ++ for (; i < kNumFullDistances; i++) ++ distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i]; ++ } ++ } ++ p->matchPriceCount = 0; ++} ++ ++static void LzmaEnc_Construct(CLzmaEnc *p) ++{ ++ RangeEnc_Construct(&p->rc); ++ MatchFinder_Construct(&p->matchFinderBase); ++ #ifndef _7ZIP_ST ++ MatchFinderMt_Construct(&p->matchFinderMt); ++ p->matchFinderMt.MatchFinder = &p->matchFinderBase; ++ #endif ++ ++ { ++ CLzmaEncProps props; ++ LzmaEncProps_Init(&props); ++ LzmaEnc_SetProps(p, &props); ++ } ++ ++ #ifndef LZMA_LOG_BSR ++ LzmaEnc_FastPosInit(p->g_FastPos); ++ #endif ++ ++ LzmaEnc_InitPriceTables(p->ProbPrices); ++ p->litProbs = 0; ++ p->saveState.litProbs = 0; ++} ++ ++CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc) ++{ ++ void *p; ++ p = alloc->Alloc(alloc, sizeof(CLzmaEnc)); ++ if (p != 0) ++ LzmaEnc_Construct((CLzmaEnc *)p); ++ return p; ++} ++ ++static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc) ++{ ++ alloc->Free(alloc, p->litProbs); ++ alloc->Free(alloc, p->saveState.litProbs); ++ p->litProbs = 0; ++ p->saveState.litProbs = 0; ++} ++ ++static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ #ifndef _7ZIP_ST ++ MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); ++ #endif ++ MatchFinder_Free(&p->matchFinderBase, allocBig); ++ LzmaEnc_FreeLits(p, alloc); ++ RangeEnc_Free(&p->rc, alloc); ++} ++ ++void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig); ++ alloc->Free(alloc, p); ++} ++ ++static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize) ++{ ++ UInt32 nowPos32, startPos32; ++ if (p->needInit) ++ { ++ p->matchFinder.Init(p->matchFinderObj); ++ p->needInit = 0; ++ } ++ ++ if (p->finished) ++ return p->result; ++ RINOK(CheckErrors(p)); ++ ++ nowPos32 = (UInt32)p->nowPos64; ++ startPos32 = nowPos32; ++ ++ if (p->nowPos64 == 0) ++ { ++ UInt32 numPairs; ++ Byte curByte; ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) ++ return Flush(p, nowPos32); ++ ReadMatchDistances(p, &numPairs); ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0); ++ p->state = kLiteralNextStates[p->state]; ++ curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset); ++ LitEnc_Encode(&p->rc, p->litProbs, curByte); ++ p->additionalOffset--; ++ nowPos32++; ++ } ++ ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0) ++ for (;;) ++ { ++ UInt32 pos, len, posState; ++ ++ if (p->fastMode) ++ len = GetOptimumFast(p, &pos); ++ else ++ len = GetOptimum(p, nowPos32, &pos); ++ ++ #ifdef SHOW_STAT2 ++ printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos); ++ #endif ++ ++ posState = nowPos32 & p->pbMask; ++ if (len == 1 && pos == (UInt32)-1) ++ { ++ Byte curByte; ++ CLzmaProb *probs; ++ const Byte *data; ++ ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0); ++ data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; ++ curByte = *data; ++ probs = LIT_PROBS(nowPos32, *(data - 1)); ++ if (IsCharState(p->state)) ++ LitEnc_Encode(&p->rc, probs, curByte); ++ else ++ LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1)); ++ p->state = kLiteralNextStates[p->state]; ++ } ++ else ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); ++ if (pos < LZMA_NUM_REPS) ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1); ++ if (pos == 0) ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0); ++ RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1)); ++ } ++ else ++ { ++ UInt32 distance = p->reps[pos]; ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1); ++ if (pos == 1) ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0); ++ else ++ { ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1); ++ RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2); ++ if (pos == 3) ++ p->reps[3] = p->reps[2]; ++ p->reps[2] = p->reps[1]; ++ } ++ p->reps[1] = p->reps[0]; ++ p->reps[0] = distance; ++ } ++ if (len == 1) ++ p->state = kShortRepNextStates[p->state]; ++ else ++ { ++ LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); ++ p->state = kRepNextStates[p->state]; ++ } ++ } ++ else ++ { ++ UInt32 posSlot; ++ RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); ++ p->state = kMatchNextStates[p->state]; ++ LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); ++ pos -= LZMA_NUM_REPS; ++ GetPosSlot(pos, posSlot); ++ RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); ++ ++ if (posSlot >= kStartPosModelIndex) ++ { ++ UInt32 footerBits = ((posSlot >> 1) - 1); ++ UInt32 base = ((2 | (posSlot & 1)) << footerBits); ++ UInt32 posReduced = pos - base; ++ ++ if (posSlot < kEndPosModelIndex) ++ RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced); ++ else ++ { ++ RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); ++ RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); ++ p->alignPriceCount++; ++ } ++ } ++ p->reps[3] = p->reps[2]; ++ p->reps[2] = p->reps[1]; ++ p->reps[1] = p->reps[0]; ++ p->reps[0] = pos; ++ p->matchPriceCount++; ++ } ++ } ++ p->additionalOffset -= len; ++ nowPos32 += len; ++ if (p->additionalOffset == 0) ++ { ++ UInt32 processed; ++ if (!p->fastMode) ++ { ++ if (p->matchPriceCount >= (1 << 7)) ++ FillDistancesPrices(p); ++ if (p->alignPriceCount >= kAlignTableSize) ++ FillAlignPrices(p); ++ } ++ if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) ++ break; ++ processed = nowPos32 - startPos32; ++ if (useLimits) ++ { ++ if (processed + kNumOpts + 300 >= maxUnpackSize || ++ RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize) ++ break; ++ } ++ else if (processed >= (1 << 15)) ++ { ++ p->nowPos64 += nowPos32 - startPos32; ++ return CheckErrors(p); ++ } ++ } ++ } ++ p->nowPos64 += nowPos32 - startPos32; ++ return Flush(p, nowPos32); ++} ++ ++#define kBigHashDicLimit ((UInt32)1 << 24) ++ ++static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ UInt32 beforeSize = kNumOpts; ++ Bool btMode; ++ if (!RangeEnc_Alloc(&p->rc, alloc)) ++ return SZ_ERROR_MEM; ++ btMode = (p->matchFinderBase.btMode != 0); ++ #ifndef _7ZIP_ST ++ p->mtMode = (p->multiThread && !p->fastMode && btMode); ++ #endif ++ ++ { ++ unsigned lclp = p->lc + p->lp; ++ if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp) ++ { ++ LzmaEnc_FreeLits(p, alloc); ++ p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); ++ p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); ++ if (p->litProbs == 0 || p->saveState.litProbs == 0) ++ { ++ LzmaEnc_FreeLits(p, alloc); ++ return SZ_ERROR_MEM; ++ } ++ p->lclp = lclp; ++ } ++ } ++ ++ p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit); ++ ++ if (beforeSize + p->dictSize < keepWindowSize) ++ beforeSize = keepWindowSize - p->dictSize; ++ ++ #ifndef _7ZIP_ST ++ if (p->mtMode) ++ { ++ RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)); ++ p->matchFinderObj = &p->matchFinderMt; ++ MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); ++ } ++ else ++ #endif ++ { ++ if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) ++ return SZ_ERROR_MEM; ++ p->matchFinderObj = &p->matchFinderBase; ++ MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); ++ } ++ return SZ_OK; ++} ++ ++static void LzmaEnc_Init(CLzmaEnc *p) ++{ ++ UInt32 i; ++ p->state = 0; ++ for (i = 0 ; i < LZMA_NUM_REPS; i++) ++ p->reps[i] = 0; ++ ++ RangeEnc_Init(&p->rc); ++ ++ ++ for (i = 0; i < kNumStates; i++) ++ { ++ UInt32 j; ++ for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++) ++ { ++ p->isMatch[i][j] = kProbInitValue; ++ p->isRep0Long[i][j] = kProbInitValue; ++ } ++ p->isRep[i] = kProbInitValue; ++ p->isRepG0[i] = kProbInitValue; ++ p->isRepG1[i] = kProbInitValue; ++ p->isRepG2[i] = kProbInitValue; ++ } ++ ++ { ++ UInt32 num = 0x300 << (p->lp + p->lc); ++ for (i = 0; i < num; i++) ++ p->litProbs[i] = kProbInitValue; ++ } ++ ++ { ++ for (i = 0; i < kNumLenToPosStates; i++) ++ { ++ CLzmaProb *probs = p->posSlotEncoder[i]; ++ UInt32 j; ++ for (j = 0; j < (1 << kNumPosSlotBits); j++) ++ probs[j] = kProbInitValue; ++ } ++ } ++ { ++ for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++) ++ p->posEncoders[i] = kProbInitValue; ++ } ++ ++ LenEnc_Init(&p->lenEnc.p); ++ LenEnc_Init(&p->repLenEnc.p); ++ ++ for (i = 0; i < (1 << kNumAlignBits); i++) ++ p->posAlignEncoder[i] = kProbInitValue; ++ ++ p->optimumEndIndex = 0; ++ p->optimumCurrentIndex = 0; ++ p->additionalOffset = 0; ++ ++ p->pbMask = (1 << p->pb) - 1; ++ p->lpMask = (1 << p->lp) - 1; ++} ++ ++static void LzmaEnc_InitPrices(CLzmaEnc *p) ++{ ++ if (!p->fastMode) ++ { ++ FillDistancesPrices(p); ++ FillAlignPrices(p); ++ } ++ ++ p->lenEnc.tableSize = ++ p->repLenEnc.tableSize = ++ p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; ++ LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices); ++ LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices); ++} ++ ++static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ UInt32 i; ++ for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++) ++ if (p->dictSize <= ((UInt32)1 << i)) ++ break; ++ p->distTableSize = i * 2; ++ ++ p->finished = False; ++ p->result = SZ_OK; ++ RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)); ++ LzmaEnc_Init(p); ++ LzmaEnc_InitPrices(p); ++ p->nowPos64 = 0; ++ return SZ_OK; ++} ++ ++static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ++ ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ p->matchFinderBase.stream = inStream; ++ p->needInit = 1; ++ p->rc.outStream = outStream; ++ return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); ++} ++ ++/*SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ++ ISeqInStream *inStream, UInt32 keepWindowSize, ++ ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ p->matchFinderBase.stream = inStream; ++ p->needInit = 1; ++ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); ++}*/ ++ ++static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) ++{ ++ p->matchFinderBase.directInput = 1; ++ p->matchFinderBase.bufferBase = (Byte *)src; ++ p->matchFinderBase.directInputRem = srcLen; ++} ++ ++static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, ++ UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ LzmaEnc_SetInputBuf(p, src, srcLen); ++ p->needInit = 1; ++ ++ return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); ++} ++ ++static void LzmaEnc_Finish(CLzmaEncHandle pp) ++{ ++ #ifndef _7ZIP_ST ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ if (p->mtMode) ++ MatchFinderMt_ReleaseStream(&p->matchFinderMt); ++ #else ++ pp = pp; ++ #endif ++} ++ ++typedef struct ++{ ++ ISeqOutStream funcTable; ++ Byte *data; ++ SizeT rem; ++ Bool overflow; ++} CSeqOutStreamBuf; ++ ++static size_t MyWrite(void *pp, const void *data, size_t size) ++{ ++ CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp; ++ if (p->rem < size) ++ { ++ size = p->rem; ++ p->overflow = True; ++ } ++ memcpy(p->data, data, size); ++ p->rem -= size; ++ p->data += size; ++ return size; ++} ++ ++ ++/*UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) ++{ ++ const CLzmaEnc *p = (CLzmaEnc *)pp; ++ return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); ++}*/ ++ ++/*const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) ++{ ++ const CLzmaEnc *p = (CLzmaEnc *)pp; ++ return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; ++}*/ ++ ++/* SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, ++ Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ UInt64 nowPos64; ++ SRes res; ++ CSeqOutStreamBuf outStream; ++ ++ outStream.funcTable.Write = MyWrite; ++ outStream.data = dest; ++ outStream.rem = *destLen; ++ outStream.overflow = False; ++ ++ p->writeEndMark = False; ++ p->finished = False; ++ p->result = SZ_OK; ++ ++ if (reInit) ++ LzmaEnc_Init(p); ++ LzmaEnc_InitPrices(p); ++ nowPos64 = p->nowPos64; ++ RangeEnc_Init(&p->rc); ++ p->rc.outStream = &outStream.funcTable; ++ ++ res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); ++ ++ *unpackSize = (UInt32)(p->nowPos64 - nowPos64); ++ *destLen -= outStream.rem; ++ if (outStream.overflow) ++ return SZ_ERROR_OUTPUT_EOF; ++ ++ return res; ++}*/ ++ ++static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) ++{ ++ SRes res = SZ_OK; ++ ++ #ifndef _7ZIP_ST ++ Byte allocaDummy[0x300]; ++ int i = 0; ++ for (i = 0; i < 16; i++) ++ allocaDummy[i] = (Byte)i; ++ #endif ++ ++ for (;;) ++ { ++ res = LzmaEnc_CodeOneBlock(p, False, 0, 0); ++ if (res != SZ_OK || p->finished != 0) ++ break; ++ if (progress != 0) ++ { ++ res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); ++ if (res != SZ_OK) ++ { ++ res = SZ_ERROR_PROGRESS; ++ break; ++ } ++ } ++ } ++ LzmaEnc_Finish(p); ++ return res; ++} ++ ++SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, ++ ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); ++ return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); ++} ++ ++SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ int i; ++ UInt32 dictSize = p->dictSize; ++ if (*size < LZMA_PROPS_SIZE) ++ return SZ_ERROR_PARAM; ++ *size = LZMA_PROPS_SIZE; ++ props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); ++ ++ for (i = 11; i <= 30; i++) ++ { ++ if (dictSize <= ((UInt32)2 << i)) ++ { ++ dictSize = (2 << i); ++ break; ++ } ++ if (dictSize <= ((UInt32)3 << i)) ++ { ++ dictSize = (3 << i); ++ break; ++ } ++ } ++ ++ for (i = 0; i < 4; i++) ++ props[1 + i] = (Byte)(dictSize >> (8 * i)); ++ return SZ_OK; ++} ++ ++SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ SRes res; ++ CLzmaEnc *p = (CLzmaEnc *)pp; ++ ++ CSeqOutStreamBuf outStream; ++ ++ LzmaEnc_SetInputBuf(p, src, srcLen); ++ ++ outStream.funcTable.Write = MyWrite; ++ outStream.data = dest; ++ outStream.rem = *destLen; ++ outStream.overflow = False; ++ ++ p->writeEndMark = writeEndMark; ++ ++ p->rc.outStream = &outStream.funcTable; ++ res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); ++ if (res == SZ_OK) ++ res = LzmaEnc_Encode2(p, progress); ++ ++ *destLen -= outStream.rem; ++ if (outStream.overflow) ++ return SZ_ERROR_OUTPUT_EOF; ++ return res; ++} ++ ++SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, ++ const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, ++ ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) ++{ ++ CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); ++ SRes res; ++ if (p == 0) ++ return SZ_ERROR_MEM; ++ ++ res = LzmaEnc_SetProps(p, props); ++ if (res == SZ_OK) ++ { ++ res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); ++ if (res == SZ_OK) ++ res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, ++ writeEndMark, progress, alloc, allocBig); ++ } ++ ++ LzmaEnc_Destroy(p, alloc, allocBig); ++ return res; ++} +--- /dev/null ++++ b/lib/lzma/Makefile +@@ -0,0 +1,7 @@ ++lzma_compress-objs := LzFind.o LzmaEnc.o ++lzma_decompress-objs := LzmaDec.o ++ ++obj-$(CONFIG_LZMA_COMPRESS) += lzma_compress.o ++obj-$(CONFIG_LZMA_DECOMPRESS) += lzma_decompress.o ++ ++EXTRA_CFLAGS += -Iinclude/linux -Iinclude/linux/lzma -include types.h diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/532-jffs2_eofdetect.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/532-jffs2_eofdetect.patch new file mode 100755 index 0000000..88bb14a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/532-jffs2_eofdetect.patch @@ -0,0 +1,65 @@ +From: Felix Fietkau +Subject: fs: jffs2: EOF marker + +Signed-off-by: Felix Fietkau +--- + fs/jffs2/build.c | 10 ++++++++++ + fs/jffs2/scan.c | 21 +++++++++++++++++++-- + 2 files changed, 29 insertions(+), 2 deletions(-) + +--- a/fs/jffs2/build.c ++++ b/fs/jffs2/build.c +@@ -117,6 +117,16 @@ static int jffs2_build_filesystem(struct + dbg_fsbuild("scanned flash completely\n"); + jffs2_dbg_dump_block_lists_nolock(c); + ++ if (c->flags & (1 << 7)) { ++ printk("%s(): unlocking the mtd device... ", __func__); ++ mtd_unlock(c->mtd, 0, c->mtd->size); ++ printk("done.\n"); ++ ++ printk("%s(): erasing all blocks after the end marker... ", __func__); ++ jffs2_erase_pending_blocks(c, -1); ++ printk("done.\n"); ++ } ++ + dbg_fsbuild("pass 1 starting\n"); + c->flags |= JFFS2_SB_FLAG_BUILDING; + /* Now scan the directory tree, increasing nlink according to every dirent found. */ +--- a/fs/jffs2/scan.c ++++ b/fs/jffs2/scan.c +@@ -148,8 +148,14 @@ int jffs2_scan_medium(struct jffs2_sb_in + /* reset summary info for next eraseblock scan */ + jffs2_sum_reset_collected(s); + +- ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), +- buf_size, s); ++ if (c->flags & (1 << 7)) { ++ if (mtd_block_isbad(c->mtd, jeb->offset)) ++ ret = BLK_STATE_BADBLOCK; ++ else ++ ret = BLK_STATE_ALLFF; ++ } else ++ ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset), ++ buf_size, s); + + if (ret < 0) + goto out; +@@ -569,6 +575,17 @@ full_scan: + return err; + } + ++ if ((buf[0] == 0xde) && ++ (buf[1] == 0xad) && ++ (buf[2] == 0xc0) && ++ (buf[3] == 0xde)) { ++ /* end of filesystem. erase everything after this point */ ++ printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset); ++ c->flags |= (1 << 7); ++ ++ return BLK_STATE_ALLFF; ++ } ++ + /* We temporarily use 'ofs' as a pointer into the buffer/jeb */ + ofs = 0; + max_ofs = EMPTY_SCAN_SIZE(c->sector_size); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/600-netfilter_conntrack_flush.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/600-netfilter_conntrack_flush.patch new file mode 100755 index 0000000..52e97e4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/600-netfilter_conntrack_flush.patch @@ -0,0 +1,90 @@ +From: Felix Fietkau +Subject: netfilter: add support for flushing conntrack via /proc + +lede-commit 8193bbe59a74d34d6a26d4a8cb857b1952905314 +Signed-off-by: Felix Fietkau +--- + net/netfilter/nf_conntrack_standalone.c | 59 ++++++++++++++++++++++++++++++++- + 1 file changed, 58 insertions(+), 1 deletion(-) + +--- a/net/netfilter/nf_conntrack_standalone.c ++++ b/net/netfilter/nf_conntrack_standalone.c +@@ -9,6 +9,7 @@ + #include + #include + #include ++#include + #include + #ifdef CONFIG_SYSCTL + #include +@@ -458,6 +459,58 @@ static int ct_cpu_seq_show(struct seq_fi + return 0; + } + ++struct kill_request { ++ u16 family; ++ union nf_inet_addr addr; ++}; ++ ++static int kill_matching(struct nf_conn *i, void *data) ++{ ++ struct kill_request *kr = data; ++ struct nf_conntrack_tuple *t1 = &i->tuplehash[IP_CT_DIR_ORIGINAL].tuple; ++ struct nf_conntrack_tuple *t2 = &i->tuplehash[IP_CT_DIR_REPLY].tuple; ++ ++ if (!kr->family) ++ return 1; ++ ++ if (t1->src.l3num != kr->family) ++ return 0; ++ ++ return (nf_inet_addr_cmp(&kr->addr, &t1->src.u3) || ++ nf_inet_addr_cmp(&kr->addr, &t1->dst.u3) || ++ nf_inet_addr_cmp(&kr->addr, &t2->src.u3) || ++ nf_inet_addr_cmp(&kr->addr, &t2->dst.u3)); ++} ++ ++static int ct_file_write(struct file *file, char *buf, size_t count) ++{ ++ struct seq_file *seq = file->private_data; ++ struct nf_ct_iter_data iter_data; ++ struct kill_request kr = { }; ++ ++ if (count == 0) ++ return 0; ++ ++ if (count >= INET6_ADDRSTRLEN) ++ count = INET6_ADDRSTRLEN - 1; ++ ++ if (strnchr(buf, count, ':')) { ++ kr.family = AF_INET6; ++ if (!in6_pton(buf, count, (void *)&kr.addr, '\n', NULL)) ++ return -EINVAL; ++ } else if (strnchr(buf, count, '.')) { ++ kr.family = AF_INET; ++ if (!in4_pton(buf, count, (void *)&kr.addr, '\n', NULL)) ++ return -EINVAL; ++ } ++ ++ iter_data.net = seq_file_net(seq); ++ iter_data.data = &kr; ++ nf_ct_iterate_cleanup_net(kill_matching, &iter_data); ++ ++ return 0; ++} ++ + static const struct seq_operations ct_cpu_seq_ops = { + .start = ct_cpu_seq_start, + .next = ct_cpu_seq_next, +@@ -471,8 +524,9 @@ static int nf_conntrack_standalone_init_ + kuid_t root_uid; + kgid_t root_gid; + +- pde = proc_create_net("nf_conntrack", 0440, net->proc_net, &ct_seq_ops, +- sizeof(struct ct_iter_state)); ++ pde = proc_create_net_data_write("nf_conntrack", 0440, net->proc_net, ++ &ct_seq_ops, &ct_file_write, ++ sizeof(struct ct_iter_state), NULL); + if (!pde) + goto out_nf_conntrack; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/610-netfilter_match_bypass_default_checks.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/610-netfilter_match_bypass_default_checks.patch new file mode 100755 index 0000000..fd22200 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/610-netfilter_match_bypass_default_checks.patch @@ -0,0 +1,110 @@ +From: Felix Fietkau +Subject: kernel: add a new version of my netfilter speedup patches for linux 2.6.39 and 3.0 + +Signed-off-by: Felix Fietkau +--- + include/uapi/linux/netfilter_ipv4/ip_tables.h | 1 + + net/ipv4/netfilter/ip_tables.c | 37 +++++++++++++++++++++++++++ + 2 files changed, 38 insertions(+) + +--- a/include/uapi/linux/netfilter_ipv4/ip_tables.h ++++ b/include/uapi/linux/netfilter_ipv4/ip_tables.h +@@ -89,6 +89,7 @@ struct ipt_ip { + #define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */ + #define IPT_F_GOTO 0x02 /* Set if jump is a goto */ + #define IPT_F_MASK 0x03 /* All possible flag bits mask. */ ++#define IPT_F_NO_DEF_MATCH 0x80 /* Internal: no default match rules present */ + + /* Values for "inv" field in struct ipt_ip. */ + #define IPT_INV_VIA_IN 0x01 /* Invert the sense of IN IFACE. */ +--- a/net/ipv4/netfilter/ip_tables.c ++++ b/net/ipv4/netfilter/ip_tables.c +@@ -48,6 +48,9 @@ ip_packet_match(const struct iphdr *ip, + { + unsigned long ret; + ++ if (ipinfo->flags & IPT_F_NO_DEF_MATCH) ++ return true; ++ + if (NF_INVF(ipinfo, IPT_INV_SRCIP, + (ip->saddr & ipinfo->smsk.s_addr) != ipinfo->src.s_addr) || + NF_INVF(ipinfo, IPT_INV_DSTIP, +@@ -78,6 +81,29 @@ ip_packet_match(const struct iphdr *ip, + return true; + } + ++static void ++ip_checkdefault(struct ipt_ip *ip) ++{ ++ static const char iface_mask[IFNAMSIZ] = {}; ++ ++ if (ip->invflags || ip->flags & IPT_F_FRAG) ++ return; ++ ++ if (memcmp(ip->iniface_mask, iface_mask, IFNAMSIZ) != 0) ++ return; ++ ++ if (memcmp(ip->outiface_mask, iface_mask, IFNAMSIZ) != 0) ++ return; ++ ++ if (ip->smsk.s_addr || ip->dmsk.s_addr) ++ return; ++ ++ if (ip->proto) ++ return; ++ ++ ip->flags |= IPT_F_NO_DEF_MATCH; ++} ++ + static bool + ip_checkentry(const struct ipt_ip *ip) + { +@@ -523,6 +549,8 @@ find_check_entry(struct ipt_entry *e, st + struct xt_mtchk_param mtpar; + struct xt_entry_match *ematch; + ++ ip_checkdefault(&e->ip); ++ + if (!xt_percpu_counter_alloc(alloc_state, &e->counters)) + return -ENOMEM; + +@@ -817,6 +845,7 @@ copy_entries_to_user(unsigned int total_ + const struct xt_table_info *private = table->private; + int ret = 0; + const void *loc_cpu_entry; ++ u8 flags; + + counters = alloc_counters(table); + if (IS_ERR(counters)) +@@ -844,6 +873,14 @@ copy_entries_to_user(unsigned int total_ + goto free_counters; + } + ++ flags = e->ip.flags & IPT_F_MASK; ++ if (copy_to_user(userptr + off ++ + offsetof(struct ipt_entry, ip.flags), ++ &flags, sizeof(flags)) != 0) { ++ ret = -EFAULT; ++ goto free_counters; ++ } ++ + for (i = sizeof(struct ipt_entry); + i < e->target_offset; + i += m->u.match_size) { +@@ -1225,12 +1262,15 @@ compat_copy_entry_to_user(struct ipt_ent + compat_uint_t origsize; + const struct xt_entry_match *ematch; + int ret = 0; ++ u8 flags = e->ip.flags & IPT_F_MASK; + + origsize = *size; + ce = *dstptr; + if (copy_to_user(ce, e, sizeof(struct ipt_entry)) != 0 || + copy_to_user(&ce->counters, &counters[i], +- sizeof(counters[i])) != 0) ++ sizeof(counters[i])) != 0 || ++ copy_to_user(&ce->ip.flags, &flags, ++ sizeof(flags)) != 0) + return -EFAULT; + + *dstptr += sizeof(struct compat_ipt_entry); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/611-netfilter_match_bypass_default_table.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/611-netfilter_match_bypass_default_table.patch new file mode 100755 index 0000000..9f0efe4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/611-netfilter_match_bypass_default_table.patch @@ -0,0 +1,106 @@ +From: Felix Fietkau +Subject: netfilter: match bypass default table + +Signed-off-by: Felix Fietkau +--- + net/ipv4/netfilter/ip_tables.c | 79 +++++++++++++++++++++++++++++++----------- + 1 file changed, 58 insertions(+), 21 deletions(-) + +--- a/net/ipv4/netfilter/ip_tables.c ++++ b/net/ipv4/netfilter/ip_tables.c +@@ -244,6 +244,33 @@ struct ipt_entry *ipt_next_entry(const s + return (void *)entry + entry->next_offset; + } + ++static bool ++ipt_handle_default_rule(struct ipt_entry *e, unsigned int *verdict) ++{ ++ struct xt_entry_target *t; ++ struct xt_standard_target *st; ++ ++ if (e->target_offset != sizeof(struct ipt_entry)) ++ return false; ++ ++ if (!(e->ip.flags & IPT_F_NO_DEF_MATCH)) ++ return false; ++ ++ t = ipt_get_target(e); ++ if (t->u.kernel.target->target) ++ return false; ++ ++ st = (struct xt_standard_target *) t; ++ if (st->verdict == XT_RETURN) ++ return false; ++ ++ if (st->verdict >= 0) ++ return false; ++ ++ *verdict = (unsigned)(-st->verdict) - 1; ++ return true; ++} ++ + /* Returns one of the generic firewall policies, like NF_ACCEPT. */ + unsigned int + ipt_do_table(void *priv, +@@ -265,27 +292,28 @@ ipt_do_table(void *priv, + unsigned int addend; + + /* Initialization */ ++ WARN_ON(!(table->valid_hooks & (1 << hook))); ++ local_bh_disable(); ++ private = READ_ONCE(table->private); /* Address dependency. */ ++ cpu = smp_processor_id(); ++ table_base = private->entries; ++ ++ e = get_entry(table_base, private->hook_entry[hook]); ++ if (ipt_handle_default_rule(e, &verdict)) { ++ struct xt_counters *counter; ++ ++ counter = xt_get_this_cpu_counter(&e->counters); ++ ADD_COUNTER(*counter, skb->len, 1); ++ local_bh_enable(); ++ return verdict; ++ } ++ + stackidx = 0; + ip = ip_hdr(skb); + indev = state->in ? state->in->name : nulldevname; + outdev = state->out ? state->out->name : nulldevname; +- /* We handle fragments by dealing with the first fragment as +- * if it was a normal packet. All other fragments are treated +- * normally, except that they will NEVER match rules that ask +- * things we don't know, ie. tcp syn flag or ports). If the +- * rule is also a fragment-specific rule, non-fragments won't +- * match it. */ +- acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET; +- acpar.thoff = ip_hdrlen(skb); +- acpar.hotdrop = false; +- acpar.state = state; + +- WARN_ON(!(table->valid_hooks & (1 << hook))); +- local_bh_disable(); + addend = xt_write_recseq_begin(); +- private = READ_ONCE(table->private); /* Address dependency. */ +- cpu = smp_processor_id(); +- table_base = private->entries; + jumpstack = (struct ipt_entry **)private->jumpstack[cpu]; + + /* Switch to alternate jumpstack if we're being invoked via TEE. +@@ -298,7 +326,16 @@ ipt_do_table(void *priv, + if (static_key_false(&xt_tee_enabled)) + jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated); + +- e = get_entry(table_base, private->hook_entry[hook]); ++ /* We handle fragments by dealing with the first fragment as ++ * if it was a normal packet. All other fragments are treated ++ * normally, except that they will NEVER match rules that ask ++ * things we don't know, ie. tcp syn flag or ports). If the ++ * rule is also a fragment-specific rule, non-fragments won't ++ * match it. */ ++ acpar.fragoff = ntohs(ip->frag_off) & IP_OFFSET; ++ acpar.thoff = ip_hdrlen(skb); ++ acpar.hotdrop = false; ++ acpar.state = state; + + do { + const struct xt_entry_target *t; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/612-netfilter_match_reduce_memory_access.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/612-netfilter_match_reduce_memory_access.patch new file mode 100755 index 0000000..7f291fc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/612-netfilter_match_reduce_memory_access.patch @@ -0,0 +1,22 @@ +From: Felix Fietkau +Subject: netfilter: reduce match memory access + +Signed-off-by: Felix Fietkau +--- + net/ipv4/netfilter/ip_tables.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/net/ipv4/netfilter/ip_tables.c ++++ b/net/ipv4/netfilter/ip_tables.c +@@ -51,9 +51,9 @@ ip_packet_match(const struct iphdr *ip, + if (ipinfo->flags & IPT_F_NO_DEF_MATCH) + return true; + +- if (NF_INVF(ipinfo, IPT_INV_SRCIP, ++ if (NF_INVF(ipinfo, IPT_INV_SRCIP, ipinfo->smsk.s_addr && + (ip->saddr & ipinfo->smsk.s_addr) != ipinfo->src.s_addr) || +- NF_INVF(ipinfo, IPT_INV_DSTIP, ++ NF_INVF(ipinfo, IPT_INV_DSTIP, ipinfo->dmsk.s_addr && + (ip->daddr & ipinfo->dmsk.s_addr) != ipinfo->dst.s_addr)) + return false; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/620-net-sfp-improve-Huawei-MA5671a-fixup.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/620-net-sfp-improve-Huawei-MA5671a-fixup.patch new file mode 100755 index 0000000..4a5abc4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/620-net-sfp-improve-Huawei-MA5671a-fixup.patch @@ -0,0 +1,149 @@ +From patchwork Fri Mar 6 12:29:55 2026 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= + +X-Patchwork-Id: 14457090 +X-Patchwork-Delegate: kuba@kernel.org +Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com + [209.85.221.48]) + (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) + (No client certificate requested) + by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF3F4386459 + for ; Fri, 6 Mar 2026 12:52:18 +0000 (UTC) +Authentication-Results: smtp.subspace.kernel.org; + arc=none smtp.client-ip=209.85.221.48 +ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; + t=1772801540; cv=none; + b=LVeywxv8ajenPZ8Kr1arieKosbrf60O9l+ouIPKPFNt5btxWDZ59pIU9BfZjv5n9ifEOyUA/UD0phxnG77+oB/k6UCd7DdGQQASZB3NHq5cvmErbgXm0XG3C8BBxVXU5pF7atPS23kBqM9ptxsv3IaeH/fDFcj6k6SH61rGEpuQ= +ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; + s=arc-20240116; t=1772801540; c=relaxed/simple; + bh=HAy43ssDo0xlUcBDIU7vQZtNnpxG03JPCL6Ldi51ASI=; + h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; + b=OBk8kI0I91psFRaIxb6nCnAzQlsc7jrXkOPW8lL7cYCosY08yfQDwAlWBFfdFs/VDuVJjD5VEdeQeMt2K4kWGgjLNXhTrRqgs6JNe7PxALDJKvt+kcJ833TRz3hKl2eb2Ft6WnKPf/6hp5Q3qm8+/Q703ixD4sF/0aDNw1BrDY4= +ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; + dmarc=pass (p=none dis=none) header.from=gmail.com; + spf=pass smtp.mailfrom=gmail.com; + dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com + header.b=RCEse1HL; arc=none smtp.client-ip=209.85.221.48 +Authentication-Results: smtp.subspace.kernel.org; + dmarc=pass (p=none dis=none) header.from=gmail.com +Authentication-Results: smtp.subspace.kernel.org; + spf=pass smtp.mailfrom=gmail.com +Authentication-Results: smtp.subspace.kernel.org; + dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com + header.b="RCEse1HL" +Received: by mail-wr1-f48.google.com with SMTP id + ffacd0b85a97d-439b7c2788dso4008389f8f.1 + for ; Fri, 06 Mar 2026 04:52:18 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=gmail.com; s=20230601; t=1772801537; x=1773406337; + darn=vger.kernel.org; + h=content-transfer-encoding:mime-version:message-id:date:subject:cc + :to:from:from:to:cc:subject:date:message-id:reply-to; + bh=y8B8kg8ACcCsMXy3SgsyRYngVEpIsqkcoCsLOS/nNqQ=; + b=RCEse1HLoUtQApOdbPXFvYItGrEKWhMZ5FH1L4npAxteGeWOhAEAekijg3Ur83ovNu + D7j0Aio5nwazNQz3y4rO88a+svlEbLx5fyxypjkMFUV4PDnOpv7HYjT9Aw1NVdIwO6l+ + sTgZ1jssfWdVnLQwQe6naotyBRoBV2AugdTmASE0Okxrsi3juIOafyTCxnp4K0weRpaH + XodiSWNrkHzZSWM6/wl3D42yExGGPiuDybF+9otR/5TaBWNzrcLkSb73hvP6va35kQWK + mnp6OV+L7iHTbxYpTfTm4axD+IZ/Q/dtFxxA6XolA28oMQbRPK0SIHepheSZx4bgl64w + FM4w== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20230601; t=1772801537; x=1773406337; + h=content-transfer-encoding:mime-version:message-id:date:subject:cc + :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date + :message-id:reply-to; + bh=y8B8kg8ACcCsMXy3SgsyRYngVEpIsqkcoCsLOS/nNqQ=; + b=KomubXrbvHQI4WbFxBztyfrvNNRRWm7V46yQSwx0bP8PXKIJP38kAYzK+ZKWhmcd7e + LpS7422VcYyLywLRxlevD2YaXsF0CK6e00YpTtixakHxYs/4KxGaU21vfwYV8mRhfu7g + HVmxKvNQ6DTdC7wAIGT6TrcZCK4VCvgCx3z9yC62hQc8C6w+9mDnnGPvXNR74ofvvXdC + eVZjm56layRoEr4PTpR2F33OVSt8+HRikH7eBzIKtQ5n/lEKtmJKDHRaodAaCyFGWMWa + qDVoOR8VI4NIJABfsOT6OqisXLPLf+jkKpGkCY2ioRPRKK9GzW4PgIuNcKvPQilQQkgD + Xlnw== +X-Forwarded-Encrypted: i=1; + AJvYcCVcziiSg1n0cDakmiQXH3869FECP24dcIqrZzs8zKakP+vHT958hnq9Bp0alDnLeVtXgo0B8T4=@vger.kernel.org +X-Gm-Message-State: AOJu0Yx2OF1e3PiuR4Zqpe9qXA6kz6T2CCtro6kv8eL2j4Zh2HCjWywo + /rZTavazOZRoq7zTvc4fGZ/yupjkTT9xRPZCKRkM9pc0UuK/KDSP4pan +X-Gm-Gg: ATEYQzx75s3OlYg8XKMgu042++2+ZPa/CZDw09DYtnwEHHBsuylQF0+eXzcFM166JtP + EMuM6Nq/sGQx2WNTPNEyu1BRGci/SV005CzkExhd1KK52D/nC1c76MBxvAtioaI/+5tgNoyCg8v + ZFRyiqDReKfJ6JHa3YRI213dTzMluN1sZTYNSqlWI1MwW66gaDCf0myU81ehAfiAff34wmxnm8C + PUF0YrLYtgZl1I/ZcYM1npoL3PBOnrhaulSqhbn7S5NaZMkHLrNQm6ns1lof+7Ciju05dQpEcBe + pumVg15Dy+PcSXQSSQt4CULH7bbuJvZ0PHJ7dS+74i/OqFSgxD4E7LCqM5ufHYdbESx0/ERaR/z + CAyT3oTz6S1oMQCUTPevHjHjTbDOWhu74SqyTZETzwGnjZnfrPMa56ebQVRfYgOYW0bbx6j3O2M + v3CSEBiXpdFTdaLuRcqIb56JeDryaHx87SOThqnYP6gMiu7EljKYIhr572Rpgz+UIRkrYyNjL9c + BLmrcmhsXX4hU4X5KocoApkO04w +X-Received: by 2002:a05:600c:8b8b:b0:483:103c:b1ee with SMTP id + 5b1f17b1804b1-48526922599mr34173745e9.8.1772801536778; + Fri, 06 Mar 2026 04:52:16 -0800 (PST) +Received: from skynet.lan + (2a02-9142-4581-3c00-0000-0000-0000-0008.red-2a02-914.customerbaf.ipv6.rima-tde.net. + [2a02:9142:4581:3c00::8]) + by smtp.gmail.com with ESMTPSA id + 5b1f17b1804b1-48527681a3esm76085715e9.4.2026.03.06.04.52.14 + (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); + Fri, 06 Mar 2026 04:52:15 -0800 (PST) +From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= +To: linux@armlinux.org.uk, + andrew@lunn.ch, + hkallweit1@gmail.com, + davem@davemloft.net, + edumazet@google.com, + kuba@kernel.org, + pabeni@redhat.com, + mnhagan88@gmail.com, + netdev@vger.kernel.org, + linux-kernel@vger.kernel.org +Cc: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= +Subject: [PATCH net v3] net: sfp: improve Huawei MA5671a fixup +Date: Fri, 6 Mar 2026 13:29:55 +0100 +Message-ID: <20260306125139.213637-1-noltari@gmail.com> +X-Mailer: git-send-email 2.47.3 +Precedence: bulk +X-Mailing-List: netdev@vger.kernel.org +List-Id: +List-Subscribe: +List-Unsubscribe: +MIME-Version: 1.0 +X-Patchwork-Delegate: kuba@kernel.org + +With the current sfp_fixup_ignore_tx_fault() fixup we ignore the TX_FAULT +signal, but we also need to apply sfp_fixup_ignore_los() in order to be +able to communicate with the module even if the fiber isn't connected for +configuration purposes. +This is needed for all the MA5671a firmwares, excluding the FS modded +firmware. + +Fixes: 2069624dac19 ("net: sfp: Add tx-fault workaround for Huawei MA5671A SFP ONT") +Signed-off-by: Álvaro FernΓ‘ndez Rojas +--- + v3: avoid using a vendor name in the function + v2: rebase on top of net/main instead of linux/master + + drivers/net/phy/sfp.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -360,6 +360,12 @@ static void sfp_fixup_ignore_tx_fault(st + sfp->state_ignore_mask |= SFP_F_TX_FAULT; + } + ++static void sfp_fixup_ignore_tx_fault_and_los(struct sfp *sfp) ++{ ++ sfp_fixup_ignore_tx_fault(sfp); ++ sfp_fixup_ignore_los(sfp); ++} ++ + static void sfp_fixup_ignore_hw(struct sfp *sfp, unsigned int mask) + { + sfp->state_hw_mask &= ~mask; +@@ -523,7 +529,7 @@ static const struct sfp_quirk sfp_quirks + // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in + // their EEPROM + SFP_QUIRK("HUAWEI", "MA5671A", sfp_quirk_2500basex, +- sfp_fixup_ignore_tx_fault), ++ sfp_fixup_ignore_tx_fault_and_los), + + // Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report + // 2500MBd NRZ in their EEPROM diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/630-packet_socket_type.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/630-packet_socket_type.patch new file mode 100755 index 0000000..769696e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/630-packet_socket_type.patch @@ -0,0 +1,138 @@ +From: Felix Fietkau +Subject: net: add an optimization for dealing with raw sockets + +lede-commit: 4898039703d7315f0f3431c860123338ec3be0f6 +Signed-off-by: Felix Fietkau +--- + include/uapi/linux/if_packet.h | 3 +++ + net/packet/af_packet.c | 34 +++++++++++++++++++++++++++------- + net/packet/internal.h | 1 + + 3 files changed, 31 insertions(+), 7 deletions(-) + +--- a/include/uapi/linux/if_packet.h ++++ b/include/uapi/linux/if_packet.h +@@ -33,6 +33,8 @@ struct sockaddr_ll { + #define PACKET_KERNEL 7 /* To kernel space */ + /* Unused, PACKET_FASTROUTE and PACKET_LOOPBACK are invisible to user space */ + #define PACKET_FASTROUTE 6 /* Fastrouted frame */ ++#define PACKET_MASK_ANY 0xffffffff /* mask for packet type bits */ ++ + + /* Packet socket options */ + +@@ -60,6 +62,7 @@ struct sockaddr_ll { + #define PACKET_FANOUT_DATA 22 + #define PACKET_IGNORE_OUTGOING 23 + #define PACKET_VNET_HDR_SZ 24 ++#define PACKET_RECV_TYPE 25 + + #define PACKET_FANOUT_HASH 0 + #define PACKET_FANOUT_LB 1 +--- a/net/packet/af_packet.c ++++ b/net/packet/af_packet.c +@@ -1911,6 +1911,7 @@ static int packet_rcv_spkt(struct sk_buf + { + struct sock *sk; + struct sockaddr_pkt *spkt; ++ struct packet_sock *po; + + /* + * When we registered the protocol we saved the socket in the data +@@ -1918,6 +1919,7 @@ static int packet_rcv_spkt(struct sk_buf + */ + + sk = pt->af_packet_priv; ++ po = pkt_sk(sk); + + /* + * Yank back the headers [hope the device set this +@@ -1930,7 +1932,7 @@ static int packet_rcv_spkt(struct sk_buf + * so that this procedure is noop. + */ + +- if (skb->pkt_type == PACKET_LOOPBACK) ++ if (!(po->pkt_type & (1 << skb->pkt_type))) + goto out; + + if (!net_eq(dev_net(dev), sock_net(sk))) +@@ -2175,12 +2177,12 @@ static int packet_rcv(struct sk_buff *sk + int skb_len = skb->len; + unsigned int snaplen, res; + +- if (skb->pkt_type == PACKET_LOOPBACK) +- goto drop; +- + sk = pt->af_packet_priv; + po = pkt_sk(sk); + ++ if (!(po->pkt_type & (1 << skb->pkt_type))) ++ goto drop; ++ + if (!net_eq(dev_net(dev), sock_net(sk))) + goto drop; + +@@ -2304,12 +2306,12 @@ static int tpacket_rcv(struct sk_buff *s + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32); + BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48); + +- if (skb->pkt_type == PACKET_LOOPBACK) +- goto drop; +- + sk = pt->af_packet_priv; + po = pkt_sk(sk); + ++ if (!(po->pkt_type & (1 << skb->pkt_type))) ++ goto drop; ++ + if (!net_eq(dev_net(dev), sock_net(sk))) + goto drop; + +@@ -3429,6 +3431,7 @@ static int packet_create(struct net *net + mutex_init(&po->pg_vec_lock); + po->rollover = NULL; + po->prot_hook.func = packet_rcv; ++ po->pkt_type = PACKET_MASK_ANY & ~(1 << PACKET_LOOPBACK); + + if (sock->type == SOCK_PACKET) + po->prot_hook.func = packet_rcv_spkt; +@@ -4096,6 +4099,16 @@ packet_setsockopt(struct socket *sock, i + packet_sock_flag_set(po, PACKET_SOCK_QDISC_BYPASS, val); + return 0; + } ++ case PACKET_RECV_TYPE: ++ { ++ unsigned int val; ++ if (optlen != sizeof(val)) ++ return -EINVAL; ++ if (copy_from_sockptr(&val, optval, sizeof(val))) ++ return -EFAULT; ++ po->pkt_type = val & ~BIT(PACKET_LOOPBACK); ++ return 0; ++ } + default: + return -ENOPROTOOPT; + } +@@ -4158,6 +4171,13 @@ static int packet_getsockopt(struct sock + case PACKET_COPY_THRESH: + val = READ_ONCE(pkt_sk(sk)->copy_thresh); + break; ++ case PACKET_RECV_TYPE: ++ if (len > sizeof(unsigned int)) ++ len = sizeof(unsigned int); ++ val = po->pkt_type; ++ ++ data = &val; ++ break; + case PACKET_VERSION: + val = po->tp_version; + break; +--- a/net/packet/internal.h ++++ b/net/packet/internal.h +@@ -131,6 +131,7 @@ struct packet_sock { + struct net_device __rcu *cached_dev; + struct packet_type prot_hook ____cacheline_aligned_in_smp; + atomic_t tp_drops ____cacheline_aligned_in_smp; ++ unsigned int pkt_type; + }; + + #define pkt_sk(ptr) container_of_const(ptr, struct packet_sock, sk) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/640-net-bridge-fix-switchdev-host-mdb-entry-updates.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/640-net-bridge-fix-switchdev-host-mdb-entry-updates.patch new file mode 100755 index 0000000..8271e06 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/640-net-bridge-fix-switchdev-host-mdb-entry-updates.patch @@ -0,0 +1,42 @@ +From: Felix Fietkau +Date: Thu, 22 Aug 2024 18:02:17 +0200 +Subject: [PATCH] net: bridge: fix switchdev host mdb entry updates + +When a mdb entry is removed, the bridge switchdev code can issue a +switchdev_port_obj_del call for a port that was not offloaded. + +This leads to an imbalance in switchdev_port_obj_add/del calls, since +br_switchdev_mdb_replay has not been called for the port before. + +This can lead to potential multicast forwarding issues and messages such as: +mt7915e 0000:01:00.0 wl1-ap0: Failed to del Host Multicast Database entry + (object id=3) with error: -ENOENT (-2). + +Fix this issue by checking the port offload status when iterating over +lower devs. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/bridge/br_switchdev.c ++++ b/net/bridge/br_switchdev.c +@@ -571,10 +571,18 @@ static void br_switchdev_host_mdb(struct + struct net_bridge_mdb_entry *mp, int type) + { + struct net_device *lower_dev; ++ struct net_bridge_port *port; + struct list_head *iter; + +- netdev_for_each_lower_dev(dev, lower_dev, iter) ++ rcu_read_lock(); ++ netdev_for_each_lower_dev(dev, lower_dev, iter) { ++ port = br_port_get_rcu(lower_dev); ++ if (!port || !port->offload_count) ++ continue; ++ + br_switchdev_host_mdb_one(dev, lower_dev, mp, type); ++ } ++ rcu_read_unlock(); + } + + static int diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/641-net-bridge-switchdev-Don-t-drop-packets-between-port.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/641-net-bridge-switchdev-Don-t-drop-packets-between-port.patch new file mode 100755 index 0000000..531e1c9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/641-net-bridge-switchdev-Don-t-drop-packets-between-port.patch @@ -0,0 +1,38 @@ +From: "Leon M. Busch-George" +Date: Sun, 20 Oct 2024 18:20:14 +0200 +Subject: [PATCH] net: bridge: switchdev: Don't drop packets between ports with + no hwdom + +nbp_switchdev_allowed_egress uses hwdom to determine whether or not a +packet has already been forwarded to a hardware domain. For +net_bridge_ports that aren't set up to use forward offloading, hwdom is +set to 0. When both ingress and egress port have no hwdom, +'cb->src_hwdom != p->hwdom' indicates that the packet is already known in +the target domain - which it isn't - and the packet is wrongly dropped. + +The error was found on a bridge containing a wifi device and a VLAN +tagging device (e.g. eth0.12). With VLAN filtering, this shouldn't happen. + +This patch adds a check for p->hwdom != 0 before comparing hardware +domains to restore forwarding between ports with hwdom = 0. + +fwd_hwdoms are only set for ports with offloading enabled, which also +implies a valid hwdom, so the check '!test_bit(p->hwdom, &cb->fwd_hwdoms)' +doesn't fail in this way (yet - fingers crossed..) and it is left in place. + +Co-developed-by: Felix Fietkau +Signed-off-by: Felix Fietkau +Signed-off-by: Leon M. Busch-George +--- + +--- a/net/bridge/br_switchdev.c ++++ b/net/bridge/br_switchdev.c +@@ -70,7 +70,7 @@ bool nbp_switchdev_allowed_egress(const + struct br_input_skb_cb *cb = BR_INPUT_SKB_CB(skb); + + return !test_bit(p->hwdom, &cb->fwd_hwdoms) && +- (!skb->offload_fwd_mark || cb->src_hwdom != p->hwdom); ++ (!skb->offload_fwd_mark || !p->hwdom || cb->src_hwdom != p->hwdom); + } + + /* Flags that can be offloaded to hardware */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/650-net-pppoe-implement-GRO-support.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/650-net-pppoe-implement-GRO-support.patch new file mode 100755 index 0000000..2aa55f8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/650-net-pppoe-implement-GRO-support.patch @@ -0,0 +1,248 @@ +From: Felix Fietkau +Date: Tue, 15 Jul 2025 12:37:45 +0200 +Subject: [PATCH] net: pppoe: implement GRO support + +Only handles packets where the pppoe header length field matches the exact +packet length. Significantly improves rx throughput. + +When running NAT traffic through a MediaTek MT7621 devices from a host +behind PPPoE to a host directly connected via ethernet, the TCP throughput +that the device is able to handle improves from ~130 Mbit/s to ~630 Mbit/s, +using fraglist GRO. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ppp/pppoe.c ++++ b/drivers/net/ppp/pppoe.c +@@ -77,6 +77,7 @@ + #include + #include + #include ++#include + + #include + +@@ -434,7 +435,7 @@ static int pppoe_rcv(struct sk_buff *skb + if (skb->len < len) + goto drop; + +- if (pskb_trim_rcsum(skb, len)) ++ if (!skb_is_gso(skb) && pskb_trim_rcsum(skb, len)) + goto drop; + + ph = pppoe_hdr(skb); +@@ -1176,6 +1177,161 @@ static struct pernet_operations pppoe_ne + .size = sizeof(struct pppoe_net), + }; + ++static u16 ++compare_pppoe_header(struct pppoe_hdr *phdr, struct pppoe_hdr *phdr2) ++{ ++ return (__force __u16)((phdr->sid ^ phdr2->sid) | ++ (phdr->tag[0].tag_type ^ phdr2->tag[0].tag_type)); ++} ++ ++static __be16 pppoe_hdr_proto(struct pppoe_hdr *phdr) ++{ ++ switch (phdr->tag[0].tag_type) { ++ case cpu_to_be16(PPP_IP): ++ return cpu_to_be16(ETH_P_IP); ++ case cpu_to_be16(PPP_IPV6): ++ return cpu_to_be16(ETH_P_IPV6); ++ default: ++ return 0; ++ } ++ ++} ++ ++static struct sk_buff *pppoe_gro_receive(struct list_head *head, ++ struct sk_buff *skb) ++{ ++ const struct packet_offload *ptype; ++ unsigned int hlen, off_pppoe; ++ struct sk_buff *pp = NULL; ++ struct pppoe_hdr *phdr; ++ struct sk_buff *p; ++ int flush = 1; ++ __be16 type; ++ ++ off_pppoe = skb_gro_offset(skb); ++ hlen = off_pppoe + sizeof(*phdr); ++ phdr = skb_gro_header(skb, hlen + 2, off_pppoe); ++ if (unlikely(!phdr)) ++ goto out; ++ ++ /* ignore packets with padding or invalid length */ ++ if (skb_gro_len(skb) != be16_to_cpu(phdr->length) + hlen) ++ goto out; ++ ++ type = pppoe_hdr_proto(phdr); ++ if (!type) ++ goto out; ++ ++ ptype = gro_find_receive_by_type(type); ++ if (!ptype) ++ goto out; ++ ++ flush = 0; ++ ++ list_for_each_entry(p, head, list) { ++ struct pppoe_hdr *phdr2; ++ ++ if (!NAPI_GRO_CB(p)->same_flow) ++ continue; ++ ++ phdr2 = (struct pppoe_hdr *)(p->data + off_pppoe); ++ if (compare_pppoe_header(phdr, phdr2)) ++ NAPI_GRO_CB(p)->same_flow = 0; ++ } ++ ++ skb_gro_pull(skb, sizeof(*phdr) + 2); ++ skb_gro_postpull_rcsum(skb, phdr, sizeof(*phdr) + 2); ++ ++ pp = indirect_call_gro_receive_inet(ptype->callbacks.gro_receive, ++ ipv6_gro_receive, inet_gro_receive, ++ head, skb); ++ ++out: ++ skb_gro_flush_final(skb, pp, flush); ++ ++ return pp; ++} ++ ++static int pppoe_gro_complete(struct sk_buff *skb, int nhoff) ++{ ++ struct pppoe_hdr *phdr = (struct pppoe_hdr *)(skb->data + nhoff); ++ __be16 type = pppoe_hdr_proto(phdr); ++ struct packet_offload *ptype; ++ int len, err; ++ ++ ptype = gro_find_complete_by_type(type); ++ if (!ptype) ++ return -ENOENT; ++ ++ err = INDIRECT_CALL_INET(ptype->callbacks.gro_complete, ++ ipv6_gro_complete, inet_gro_complete, ++ skb, nhoff + sizeof(*phdr) + 2); ++ if (err) ++ return err; ++ ++ len = skb->len - (nhoff + sizeof(*phdr)); ++ phdr->length = cpu_to_be16(len); ++ ++ return 0; ++} ++ ++static struct sk_buff *pppoe_gso_segment(struct sk_buff *skb, ++ netdev_features_t features) ++{ ++ unsigned int pppoe_hlen = sizeof(struct pppoe_hdr) + 2; ++ struct sk_buff *segs = ERR_PTR(-EINVAL); ++ u16 mac_offset = skb->mac_header; ++ struct packet_offload *ptype; ++ u16 mac_len = skb->mac_len; ++ struct pppoe_hdr *phdr; ++ __be16 orig_type, type; ++ int len, nhoff; ++ ++ skb_reset_network_header(skb); ++ nhoff = skb_network_header(skb) - skb_mac_header(skb); ++ ++ if (unlikely(!pskb_may_pull(skb, pppoe_hlen))) ++ goto out; ++ ++ phdr = (struct pppoe_hdr *)skb_network_header(skb); ++ type = pppoe_hdr_proto(phdr); ++ ptype = gro_find_complete_by_type(type); ++ if (!ptype) ++ goto out; ++ ++ orig_type = skb->protocol; ++ __skb_pull(skb, pppoe_hlen); ++ segs = ptype->callbacks.gso_segment(skb, features); ++ if (IS_ERR_OR_NULL(segs)) { ++ skb_gso_error_unwind(skb, orig_type, pppoe_hlen, mac_offset, ++ mac_len); ++ goto out; ++ } ++ ++ skb = segs; ++ do { ++ phdr = (struct pppoe_hdr *)(skb_mac_header(skb) + nhoff); ++ len = skb->len - (nhoff + sizeof(*phdr)); ++ phdr->length = cpu_to_be16(len); ++ skb->network_header = (u8 *)phdr - skb->head; ++ skb->protocol = orig_type; ++ skb_reset_mac_len(skb); ++ } while ((skb = skb->next)); ++ ++out: ++ return segs; ++} ++ ++static struct packet_offload pppoe_packet_offload __read_mostly = { ++ .type = cpu_to_be16(ETH_P_PPP_SES), ++ .priority = 20, ++ .callbacks = { ++ .gro_receive = pppoe_gro_receive, ++ .gro_complete = pppoe_gro_complete, ++ .gso_segment = pppoe_gso_segment, ++ }, ++}; ++ + static int __init pppoe_init(void) + { + int err; +@@ -1192,6 +1348,7 @@ static int __init pppoe_init(void) + if (err) + goto out_unregister_pppoe_proto; + ++ dev_add_offload(&pppoe_packet_offload); + dev_add_pack(&pppoes_ptype); + dev_add_pack(&pppoed_ptype); + register_netdevice_notifier(&pppoe_notifier); +@@ -1211,6 +1368,7 @@ static void __exit pppoe_exit(void) + unregister_netdevice_notifier(&pppoe_notifier); + dev_remove_pack(&pppoed_ptype); + dev_remove_pack(&pppoes_ptype); ++ dev_remove_offload(&pppoe_packet_offload); + unregister_pppox_proto(PX_PROTO_OE); + proto_unregister(&pppoe_sk_proto); + unregister_pernet_device(&pppoe_net_ops); +--- a/net/ipv4/af_inet.c ++++ b/net/ipv4/af_inet.c +@@ -1546,6 +1546,7 @@ out: + + return pp; + } ++EXPORT_INDIRECT_CALLABLE(inet_gro_receive); + + static struct sk_buff *ipip_gro_receive(struct list_head *head, + struct sk_buff *skb) +@@ -1631,6 +1632,7 @@ int inet_gro_complete(struct sk_buff *sk + out: + return err; + } ++EXPORT_INDIRECT_CALLABLE(inet_gro_complete); + + static int ipip_gro_complete(struct sk_buff *skb, int nhoff) + { +--- a/net/ipv6/ip6_offload.c ++++ b/net/ipv6/ip6_offload.c +@@ -306,6 +306,7 @@ out: + + return pp; + } ++EXPORT_INDIRECT_CALLABLE(ipv6_gro_receive); + + static struct sk_buff *sit_ip6ip6_gro_receive(struct list_head *head, + struct sk_buff *skb) +@@ -388,6 +389,7 @@ INDIRECT_CALLABLE_SCOPE int ipv6_gro_com + out: + return err; + } ++EXPORT_INDIRECT_CALLABLE(ipv6_gro_complete); + + static int sit_gro_complete(struct sk_buff *skb, int nhoff) + { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/655-increase_skb_pad.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/655-increase_skb_pad.patch new file mode 100755 index 0000000..895e0a8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/655-increase_skb_pad.patch @@ -0,0 +1,20 @@ +From: Felix Fietkau +Subject: kernel: add a few patches for avoiding unnecessary skb reallocations - significantly improves ethernet<->wireless performance + +lede-commit: 6f89cffc9add6939d44a6b54cf9a5e77849aa7fd +Signed-off-by: Felix Fietkau +--- + include/linux/skbuff.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/linux/skbuff.h ++++ b/include/linux/skbuff.h +@@ -3209,7 +3209,7 @@ static inline int pskb_network_may_pull( + * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) + */ + #ifndef NET_SKB_PAD +-#define NET_SKB_PAD max(32, L1_CACHE_BYTES) ++#define NET_SKB_PAD max(64, L1_CACHE_BYTES) + #endif + + int ___pskb_trim(struct sk_buff *skb, unsigned int len); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch new file mode 100755 index 0000000..951e7f7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/666-Add-support-for-MAP-E-FMRs-mesh-mode.patch @@ -0,0 +1,511 @@ +From: Steven Barth +Subject: Add support for MAP-E FMRs (mesh mode) + +MAP-E FMRs (draft-ietf-softwire-map-10) are rules for IPv4-communication +between MAP CEs (mesh mode) without the need to forward such data to a +border relay. This is similar to how 6rd works but for IPv4 over IPv6. + +Signed-off-by: Steven Barth +--- + include/net/ip6_tunnel.h | 13 ++ + include/uapi/linux/if_tunnel.h | 13 ++ + net/ipv6/ip6_tunnel.c | 276 +++++++++++++++++++++++++++++++++++++++-- + 3 files changed, 291 insertions(+), 11 deletions(-) + +--- a/include/net/ip6_tunnel.h ++++ b/include/net/ip6_tunnel.h +@@ -18,6 +18,18 @@ + /* determine capability on a per-packet basis */ + #define IP6_TNL_F_CAP_PER_PACKET 0x40000 + ++/* IPv6 tunnel FMR */ ++struct __ip6_tnl_fmr { ++ struct __ip6_tnl_fmr *next; /* next fmr in list */ ++ struct in6_addr ip6_prefix; ++ struct in_addr ip4_prefix; ++ ++ __u8 ip6_prefix_len; ++ __u8 ip4_prefix_len; ++ __u8 ea_len; ++ __u8 offset; ++}; ++ + struct __ip6_tnl_parm { + char name[IFNAMSIZ]; /* name of tunnel device */ + int link; /* ifindex of underlying L2 interface */ +@@ -29,6 +41,7 @@ struct __ip6_tnl_parm { + __u32 flags; /* tunnel flags */ + struct in6_addr laddr; /* local tunnel end-point address */ + struct in6_addr raddr; /* remote tunnel end-point address */ ++ struct __ip6_tnl_fmr *fmrs; /* FMRs */ + + IP_TUNNEL_DECLARE_FLAGS(i_flags); + IP_TUNNEL_DECLARE_FLAGS(o_flags); +--- a/include/uapi/linux/if_tunnel.h ++++ b/include/uapi/linux/if_tunnel.h +@@ -77,10 +77,23 @@ enum { + IFLA_IPTUN_ENCAP_DPORT, + IFLA_IPTUN_COLLECT_METADATA, + IFLA_IPTUN_FWMARK, ++ IFLA_IPTUN_FMRS, + __IFLA_IPTUN_MAX, + }; + #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1) + ++enum { ++ IFLA_IPTUN_FMR_UNSPEC, ++ IFLA_IPTUN_FMR_IP6_PREFIX, ++ IFLA_IPTUN_FMR_IP4_PREFIX, ++ IFLA_IPTUN_FMR_IP6_PREFIX_LEN, ++ IFLA_IPTUN_FMR_IP4_PREFIX_LEN, ++ IFLA_IPTUN_FMR_EA_LEN, ++ IFLA_IPTUN_FMR_OFFSET, ++ __IFLA_IPTUN_FMR_MAX, ++}; ++#define IFLA_IPTUN_FMR_MAX (__IFLA_IPTUN_FMR_MAX - 1) ++ + enum tunnel_encap_types { + TUNNEL_ENCAP_NONE, + TUNNEL_ENCAP_FOU, +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -11,6 +11,9 @@ + * linux/net/ipv6/sit.c and linux/net/ipv4/ipip.c + * + * RFC 2473 ++ * ++ * Changes: ++ * Steven Barth : MAP-E FMR support + */ + + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +@@ -68,9 +71,9 @@ static bool log_ecn_error = true; + module_param(log_ecn_error, bool, 0644); + MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN"); + +-static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2) ++static u32 HASH(const struct in6_addr *addr) + { +- u32 hash = ipv6_addr_hash(addr1) ^ ipv6_addr_hash(addr2); ++ u32 hash = ipv6_addr_hash(addr); + + return hash_32(hash, IP6_TUNNEL_HASH_SIZE_SHIFT); + } +@@ -115,17 +118,33 @@ static struct ip6_tnl * + ip6_tnl_lookup(struct net *net, int link, + const struct in6_addr *remote, const struct in6_addr *local) + { +- unsigned int hash = HASH(remote, local); ++ unsigned int hash = HASH(local); + struct ip6_tnl *t, *cand = NULL; + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); + struct in6_addr any; + + for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { + if (!ipv6_addr_equal(local, &t->parms.laddr) || +- !ipv6_addr_equal(remote, &t->parms.raddr) || + !(t->dev->flags & IFF_UP)) + continue; + ++ if (!ipv6_addr_equal(remote, &t->parms.raddr)) { ++ struct __ip6_tnl_fmr *fmr; ++ bool found = false; ++ ++ for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) { ++ if (!ipv6_prefix_equal(remote, &fmr->ip6_prefix, ++ fmr->ip6_prefix_len)) ++ continue; ++ ++ found = true; ++ break; ++ } ++ ++ if (!found) ++ continue; ++ } ++ + if (link == t->parms.link) + return t; + else +@@ -133,7 +152,7 @@ ip6_tnl_lookup(struct net *net, int link + } + + memset(&any, 0, sizeof(any)); +- hash = HASH(&any, local); ++ hash = HASH(local); + for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { + if (!ipv6_addr_equal(local, &t->parms.laddr) || + !ipv6_addr_any(&t->parms.raddr) || +@@ -146,7 +165,7 @@ ip6_tnl_lookup(struct net *net, int link + cand = t; + } + +- hash = HASH(remote, &any); ++ hash = HASH(&any); + for_each_ip6_tunnel_rcu(ip6n->tnls_r_l[hash]) { + if (!ipv6_addr_equal(remote, &t->parms.raddr) || + !ipv6_addr_any(&t->parms.laddr) || +@@ -195,7 +214,7 @@ ip6_tnl_bucket(struct ip6_tnl_net *ip6n, + + if (!ipv6_addr_any(remote) || !ipv6_addr_any(local)) { + prio = 1; +- h = HASH(remote, local); ++ h = HASH(local); + } + return &ip6n->tnls[prio][h]; + } +@@ -376,6 +395,12 @@ ip6_tnl_dev_uninit(struct net_device *de + struct net *net = t->net; + struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); + ++ while (t->parms.fmrs) { ++ struct __ip6_tnl_fmr *next = t->parms.fmrs->next; ++ kfree(t->parms.fmrs); ++ t->parms.fmrs = next; ++ } ++ + if (dev == ip6n->fb_tnl_dev) + RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL); + else +@@ -790,6 +815,107 @@ int ip6_tnl_rcv_ctl(struct ip6_tnl *t, + } + EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl); + ++/** ++ * ip4ip6_fmr_calc - calculate target / source IPv6-address based on FMR ++ * @dest: destination IPv6 address buffer ++ * @skb: received socket buffer ++ * @fmr: MAP FMR ++ * @xmit: Calculate for xmit or rcv ++ **/ ++static void ip4ip6_fmr_calc(struct in6_addr *dest, ++ const struct iphdr *iph, const uint8_t *end, ++ const struct __ip6_tnl_fmr *fmr, bool xmit) ++{ ++ int psidlen = fmr->ea_len - (32 - fmr->ip4_prefix_len); ++ u8 *portp = NULL; ++ bool use_dest_addr; ++ const struct iphdr *dsth = iph; ++ ++ if ((u8*)dsth >= end) ++ return; ++ ++ /* find significant IP header */ ++ if (iph->protocol == IPPROTO_ICMP) { ++ struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4); ++ if (ih && ((u8*)&ih[1]) <= end && ( ++ ih->type == ICMP_DEST_UNREACH || ++ ih->type == ICMP_SOURCE_QUENCH || ++ ih->type == ICMP_TIME_EXCEEDED || ++ ih->type == ICMP_PARAMETERPROB || ++ ih->type == ICMP_REDIRECT)) ++ dsth = (const struct iphdr*)&ih[1]; ++ } ++ ++ /* in xmit-path use dest port by default and source port only if ++ this is an ICMP reply to something else; vice versa in rcv-path */ ++ use_dest_addr = (xmit && dsth == iph) || (!xmit && dsth != iph); ++ ++ /* get dst port */ ++ if (((u8*)&dsth[1]) <= end && ( ++ dsth->protocol == IPPROTO_UDP || ++ dsth->protocol == IPPROTO_TCP || ++ dsth->protocol == IPPROTO_SCTP || ++ dsth->protocol == IPPROTO_DCCP)) { ++ /* for UDP, TCP, SCTP and DCCP source and dest port ++ follow IPv4 header directly */ ++ portp = ((u8*)dsth) + dsth->ihl * 4; ++ ++ if (use_dest_addr) ++ portp += sizeof(u16); ++ } else if (iph->protocol == IPPROTO_ICMP) { ++ struct icmphdr *ih = (struct icmphdr*)(((u8*)dsth) + dsth->ihl * 4); ++ ++ /* use icmp identifier as port */ ++ if (((u8*)&ih) <= end && ( ++ (use_dest_addr && ( ++ ih->type == ICMP_ECHOREPLY || ++ ih->type == ICMP_TIMESTAMPREPLY || ++ ih->type == ICMP_INFO_REPLY || ++ ih->type == ICMP_ADDRESSREPLY)) || ++ (!use_dest_addr && ( ++ ih->type == ICMP_ECHO || ++ ih->type == ICMP_TIMESTAMP || ++ ih->type == ICMP_INFO_REQUEST || ++ ih->type == ICMP_ADDRESS) ++ ))) ++ portp = (u8*)&ih->un.echo.id; ++ } ++ ++ if ((portp && &portp[2] <= end) || psidlen == 0) { ++ int frombyte = fmr->ip6_prefix_len / 8; ++ int fromrem = fmr->ip6_prefix_len % 8; ++ int bytes = sizeof(struct in6_addr) - frombyte; ++ const u32 *addr = (use_dest_addr) ? &iph->daddr : &iph->saddr; ++ u64 eabits = ((u64)ntohl(*addr)) << (32 + fmr->ip4_prefix_len); ++ u64 t = 0; ++ ++ /* extract PSID from port and add it to eabits */ ++ u16 psidbits = 0; ++ if (psidlen > 0) { ++ psidbits = ((u16)portp[0]) << 8 | ((u16)portp[1]); ++ psidbits >>= 16 - psidlen - fmr->offset; ++ psidbits = (u16)(psidbits << (16 - psidlen)); ++ eabits |= ((u64)psidbits) << (48 - (fmr->ea_len - psidlen)); ++ } ++ ++ /* rewrite destination address */ ++ *dest = fmr->ip6_prefix; ++ memcpy(&dest->s6_addr[10], addr, sizeof(*addr)); ++ dest->s6_addr16[7] = htons(psidbits >> (16 - psidlen)); ++ ++ if (bytes > sizeof(u64)) ++ bytes = sizeof(u64); ++ ++ /* insert eabits */ ++ memcpy(&t, &dest->s6_addr[frombyte], bytes); ++ t = be64_to_cpu(t) & ~(((((u64)1) << fmr->ea_len) - 1) ++ << (64 - fmr->ea_len - fromrem)); ++ t = cpu_to_be64(t | (eabits >> fromrem)); ++ memcpy(&dest->s6_addr[frombyte], &t, bytes); ++ } ++} ++ ++ + static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb, + const struct tnl_ptk_info *tpi, + struct metadata_dst *tun_dst, +@@ -855,6 +981,27 @@ static int __ip6_tnl_rcv(struct ip6_tnl + + memset(skb->cb, 0, sizeof(struct inet6_skb_parm)); + ++ if (tpi->proto == htons(ETH_P_IP) && tunnel->parms.fmrs && ++ !ipv6_addr_equal(&ipv6h->saddr, &tunnel->parms.raddr)) { ++ /* Packet didn't come from BR, so lookup FMR */ ++ struct __ip6_tnl_fmr *fmr; ++ struct in6_addr expected = tunnel->parms.raddr; ++ for (fmr = tunnel->parms.fmrs; fmr; fmr = fmr->next) ++ if (ipv6_prefix_equal(&ipv6h->saddr, ++ &fmr->ip6_prefix, fmr->ip6_prefix_len)) ++ break; ++ ++ /* Check that IPv6 matches IPv4 source to prevent spoofing */ ++ if (fmr) ++ ip4ip6_fmr_calc(&expected, ip_hdr(skb), ++ skb_tail_pointer(skb), fmr, false); ++ ++ if (!ipv6_addr_equal(&ipv6h->saddr, &expected)) { ++ rcu_read_unlock(); ++ goto drop; ++ } ++ } ++ + __skb_tunnel_rx(skb, tunnel->dev, tunnel->net); + + err = dscp_ecn_decapsulate(tunnel, ipv6h, skb); +@@ -1004,6 +1151,7 @@ static void init_tel_txopt(struct ipv6_t + opt->ops.opt_nflen = 8; + } + ++ + /** + * ip6_tnl_addr_conflict - compare packet addresses to tunnel's own + * @t: the outgoing tunnel device +@@ -1293,6 +1441,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, str + u8 protocol) + { + struct ip6_tnl *t = netdev_priv(dev); ++ struct __ip6_tnl_fmr *fmr; + struct ipv6hdr *ipv6h; + const struct iphdr *iph; + int encap_limit = -1; +@@ -1392,6 +1541,18 @@ ipxip6_tnl_xmit(struct sk_buff *skb, str + fl6.flowi6_uid = sock_net_uid(dev_net(dev), NULL); + dsfield = INET_ECN_encapsulate(dsfield, orig_dsfield); + ++ /* try to find matching FMR */ ++ for (fmr = t->parms.fmrs; fmr; fmr = fmr->next) { ++ unsigned mshift = 32 - fmr->ip4_prefix_len; ++ if (ntohl(fmr->ip4_prefix.s_addr) >> mshift == ++ ntohl(ip_hdr(skb)->daddr) >> mshift) ++ break; ++ } ++ ++ /* change dstaddr according to FMR */ ++ if (fmr) ++ ip4ip6_fmr_calc(&fl6.daddr, ip_hdr(skb), skb_tail_pointer(skb), fmr, true); ++ + if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6)) + return -1; + +@@ -1545,6 +1706,14 @@ ip6_tnl_change(struct ip6_tnl *t, const + t->parms.link = p->link; + t->parms.proto = p->proto; + t->parms.fwmark = p->fwmark; ++ ++ while (t->parms.fmrs) { ++ struct __ip6_tnl_fmr *next = t->parms.fmrs->next; ++ kfree(t->parms.fmrs); ++ t->parms.fmrs = next; ++ } ++ t->parms.fmrs = p->fmrs; ++ + dst_cache_reset(&t->dst_cache); + ip6_tnl_link_config(t); + } +@@ -1579,6 +1748,7 @@ ip6_tnl_parm_from_user(struct __ip6_tnl_ + p->flowinfo = u->flowinfo; + p->link = u->link; + p->proto = u->proto; ++ p->fmrs = NULL; + memcpy(p->name, u->name, sizeof(u->name)); + } + +@@ -1962,6 +2132,15 @@ static int ip6_tnl_validate(struct nlatt + return 0; + } + ++static const struct nla_policy ip6_tnl_fmr_policy[IFLA_IPTUN_FMR_MAX + 1] = { ++ [IFLA_IPTUN_FMR_IP6_PREFIX] = { .len = sizeof(struct in6_addr) }, ++ [IFLA_IPTUN_FMR_IP4_PREFIX] = { .len = sizeof(struct in_addr) }, ++ [IFLA_IPTUN_FMR_IP6_PREFIX_LEN] = { .type = NLA_U8 }, ++ [IFLA_IPTUN_FMR_IP4_PREFIX_LEN] = { .type = NLA_U8 }, ++ [IFLA_IPTUN_FMR_EA_LEN] = { .type = NLA_U8 }, ++ [IFLA_IPTUN_FMR_OFFSET] = { .type = NLA_U8 } ++}; ++ + static void ip6_tnl_netlink_parms(struct nlattr *data[], + struct __ip6_tnl_parm *parms) + { +@@ -1999,6 +2178,46 @@ static void ip6_tnl_netlink_parms(struct + + if (data[IFLA_IPTUN_FWMARK]) + parms->fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]); ++ ++ if (data[IFLA_IPTUN_FMRS]) { ++ unsigned rem; ++ struct nlattr *fmr; ++ nla_for_each_nested(fmr, data[IFLA_IPTUN_FMRS], rem) { ++ struct nlattr *fmrd[IFLA_IPTUN_FMR_MAX + 1], *c; ++ struct __ip6_tnl_fmr *nfmr; ++ ++ nla_parse_nested(fmrd, IFLA_IPTUN_FMR_MAX, ++ fmr, ip6_tnl_fmr_policy, NULL); ++ ++ if (!(nfmr = kzalloc(sizeof(*nfmr), GFP_KERNEL))) ++ continue; ++ ++ nfmr->offset = 6; ++ ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX])) ++ nla_memcpy(&nfmr->ip6_prefix, fmrd[IFLA_IPTUN_FMR_IP6_PREFIX], ++ sizeof(nfmr->ip6_prefix)); ++ ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX])) ++ nla_memcpy(&nfmr->ip4_prefix, fmrd[IFLA_IPTUN_FMR_IP4_PREFIX], ++ sizeof(nfmr->ip4_prefix)); ++ ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP6_PREFIX_LEN])) ++ nfmr->ip6_prefix_len = nla_get_u8(c); ++ ++ if ((c = fmrd[IFLA_IPTUN_FMR_IP4_PREFIX_LEN])) ++ nfmr->ip4_prefix_len = nla_get_u8(c); ++ ++ if ((c = fmrd[IFLA_IPTUN_FMR_EA_LEN])) ++ nfmr->ea_len = nla_get_u8(c); ++ ++ if ((c = fmrd[IFLA_IPTUN_FMR_OFFSET])) ++ nfmr->offset = nla_get_u8(c); ++ ++ nfmr->next = parms->fmrs; ++ parms->fmrs = nfmr; ++ } ++ } + } + + static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev, +@@ -2083,6 +2302,12 @@ static void ip6_tnl_dellink(struct net_d + + static size_t ip6_tnl_get_size(const struct net_device *dev) + { ++ const struct ip6_tnl *t = netdev_priv(dev); ++ struct __ip6_tnl_fmr *c; ++ int fmrs = 0; ++ for (c = t->parms.fmrs; c; c = c->next) ++ ++fmrs; ++ + return + /* IFLA_IPTUN_LINK */ + nla_total_size(4) + +@@ -2112,6 +2337,24 @@ static size_t ip6_tnl_get_size(const str + nla_total_size(0) + + /* IFLA_IPTUN_FWMARK */ + nla_total_size(4) + ++ /* IFLA_IPTUN_FMRS */ ++ nla_total_size(0) + ++ ( ++ /* nest */ ++ nla_total_size(0) + ++ /* IFLA_IPTUN_FMR_IP6_PREFIX */ ++ nla_total_size(sizeof(struct in6_addr)) + ++ /* IFLA_IPTUN_FMR_IP4_PREFIX */ ++ nla_total_size(sizeof(struct in_addr)) + ++ /* IFLA_IPTUN_FMR_EA_LEN */ ++ nla_total_size(1) + ++ /* IFLA_IPTUN_FMR_IP6_PREFIX_LEN */ ++ nla_total_size(1) + ++ /* IFLA_IPTUN_FMR_IP4_PREFIX_LEN */ ++ nla_total_size(1) + ++ /* IFLA_IPTUN_FMR_OFFSET */ ++ nla_total_size(1) ++ ) * fmrs + + 0; + } + +@@ -2119,6 +2362,9 @@ static int ip6_tnl_fill_info(struct sk_b + { + struct ip6_tnl *tunnel = netdev_priv(dev); + struct __ip6_tnl_parm *parm = &tunnel->parms; ++ struct __ip6_tnl_fmr *c; ++ int fmrcnt = 0; ++ struct nlattr *fmrs; + + if (nla_put_u32(skb, IFLA_IPTUN_LINK, parm->link) || + nla_put_in6_addr(skb, IFLA_IPTUN_LOCAL, &parm->laddr) || +@@ -2128,9 +2374,27 @@ static int ip6_tnl_fill_info(struct sk_b + nla_put_be32(skb, IFLA_IPTUN_FLOWINFO, parm->flowinfo) || + nla_put_u32(skb, IFLA_IPTUN_FLAGS, parm->flags) || + nla_put_u8(skb, IFLA_IPTUN_PROTO, parm->proto) || +- nla_put_u32(skb, IFLA_IPTUN_FWMARK, parm->fwmark)) ++ nla_put_u32(skb, IFLA_IPTUN_FWMARK, parm->fwmark) || ++ !(fmrs = nla_nest_start(skb, IFLA_IPTUN_FMRS))) + goto nla_put_failure; + ++ for (c = parm->fmrs; c; c = c->next) { ++ struct nlattr *fmr = nla_nest_start(skb, ++fmrcnt); ++ if (!fmr || ++ nla_put(skb, IFLA_IPTUN_FMR_IP6_PREFIX, ++ sizeof(c->ip6_prefix), &c->ip6_prefix) || ++ nla_put(skb, IFLA_IPTUN_FMR_IP4_PREFIX, ++ sizeof(c->ip4_prefix), &c->ip4_prefix) || ++ nla_put_u8(skb, IFLA_IPTUN_FMR_IP6_PREFIX_LEN, c->ip6_prefix_len) || ++ nla_put_u8(skb, IFLA_IPTUN_FMR_IP4_PREFIX_LEN, c->ip4_prefix_len) || ++ nla_put_u8(skb, IFLA_IPTUN_FMR_EA_LEN, c->ea_len) || ++ nla_put_u8(skb, IFLA_IPTUN_FMR_OFFSET, c->offset)) ++ goto nla_put_failure; ++ ++ nla_nest_end(skb, fmr); ++ } ++ nla_nest_end(skb, fmrs); ++ + if (nla_put_u16(skb, IFLA_IPTUN_ENCAP_TYPE, tunnel->encap.type) || + nla_put_be16(skb, IFLA_IPTUN_ENCAP_SPORT, tunnel->encap.sport) || + nla_put_be16(skb, IFLA_IPTUN_ENCAP_DPORT, tunnel->encap.dport) || +@@ -2170,6 +2434,7 @@ static const struct nla_policy ip6_tnl_p + [IFLA_IPTUN_ENCAP_DPORT] = { .type = NLA_U16 }, + [IFLA_IPTUN_COLLECT_METADATA] = { .type = NLA_FLAG }, + [IFLA_IPTUN_FWMARK] = { .type = NLA_U32 }, ++ [IFLA_IPTUN_FMRS] = { .type = NLA_NESTED }, + }; + + static struct rtnl_link_ops ip6_link_ops __read_mostly = { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch new file mode 100755 index 0000000..c8693af --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/670-ipv6-allow-rejecting-with-source-address-failed-policy.patch @@ -0,0 +1,263 @@ +From: Jonas Gorski +Subject: ipv6: allow rejecting with "source address failed policy" + +RFC6204 L-14 requires rejecting traffic from invalid addresses with +ICMPv6 Destination Unreachable, Code 5 (Source address failed ingress/ +egress policy) on the LAN side, so add an appropriate rule for that. + +Signed-off-by: Jonas Gorski +--- + include/net/netns/ipv6.h | 1 + + include/uapi/linux/fib_rules.h | 4 +++ + include/uapi/linux/rtnetlink.h | 1 + + net/ipv4/fib_semantics.c | 4 +++ + net/ipv4/fib_trie.c | 1 + + net/ipv4/ipmr.c | 1 + + net/ipv6/fib6_rules.c | 4 +++ + net/ipv6/ip6mr.c | 2 ++ + net/ipv6/route.c | 58 +++++++++++++++++++++++++++++++++++++++++- + 9 files changed, 75 insertions(+), 1 deletion(-) + +--- a/include/net/netns/ipv6.h ++++ b/include/net/netns/ipv6.h +@@ -86,6 +86,7 @@ struct netns_ipv6 { + unsigned int fib6_routes_require_src; + #endif + struct rt6_info *ip6_prohibit_entry; ++ struct rt6_info *ip6_policy_failed_entry; + struct rt6_info *ip6_blk_hole_entry; + struct fib6_table *fib6_local_tbl; + struct fib_rules_ops *fib6_rules_ops; +--- a/include/uapi/linux/fib_rules.h ++++ b/include/uapi/linux/fib_rules.h +@@ -83,6 +83,10 @@ enum { + FR_ACT_BLACKHOLE, /* Drop without notification */ + FR_ACT_UNREACHABLE, /* Drop with ENETUNREACH */ + FR_ACT_PROHIBIT, /* Drop with EACCES */ ++ FR_ACT_RES9, ++ FR_ACT_RES10, ++ FR_ACT_RES11, ++ FR_ACT_POLICY_FAILED, /* Drop with EACCES */ + __FR_ACT_MAX, + }; + +--- a/include/uapi/linux/rtnetlink.h ++++ b/include/uapi/linux/rtnetlink.h +@@ -265,6 +265,7 @@ enum { + RTN_THROW, /* Not in this table */ + RTN_NAT, /* Translate this address */ + RTN_XRESOLVE, /* Use external resolver */ ++ RTN_POLICY_FAILED, /* Failed ingress/egress policy */ + __RTN_MAX + }; + +--- a/net/ipv4/fib_semantics.c ++++ b/net/ipv4/fib_semantics.c +@@ -145,6 +145,10 @@ const struct fib_prop fib_props[RTN_MAX + .error = -EINVAL, + .scope = RT_SCOPE_NOWHERE, + }, ++ [RTN_POLICY_FAILED] = { ++ .error = -EACCES, ++ .scope = RT_SCOPE_UNIVERSE, ++ }, + }; + + static void rt_fibinfo_free(struct rtable __rcu **rtp) +--- a/net/ipv4/fib_trie.c ++++ b/net/ipv4/fib_trie.c +@@ -2763,6 +2763,7 @@ static const char *const rtn_type_names[ + [RTN_THROW] = "THROW", + [RTN_NAT] = "NAT", + [RTN_XRESOLVE] = "XRESOLVE", ++ [RTN_POLICY_FAILED] = "POLICY_FAILED", + }; + + static inline const char *rtn_type(char *buf, size_t len, unsigned int t) +--- a/net/ipv4/ipmr.c ++++ b/net/ipv4/ipmr.c +@@ -191,6 +191,7 @@ static int ipmr_rule_action(struct fib_r + case FR_ACT_UNREACHABLE: + return -ENETUNREACH; + case FR_ACT_PROHIBIT: ++ case FR_ACT_POLICY_FAILED: + return -EACCES; + case FR_ACT_BLACKHOLE: + default: +--- a/net/ipv6/fib6_rules.c ++++ b/net/ipv6/fib6_rules.c +@@ -222,6 +222,10 @@ static int __fib6_rule_action(struct fib + err = -EACCES; + rt = net->ipv6.ip6_prohibit_entry; + goto discard_pkt; ++ case FR_ACT_POLICY_FAILED: ++ err = -EACCES; ++ rt = net->ipv6.ip6_policy_failed_entry; ++ goto discard_pkt; + } + + tb_id = fib_rule_get_table(rule, arg); +--- a/net/ipv6/ip6mr.c ++++ b/net/ipv6/ip6mr.c +@@ -180,6 +180,8 @@ static int ip6mr_rule_action(struct fib_ + return -ENETUNREACH; + case FR_ACT_PROHIBIT: + return -EACCES; ++ case FR_ACT_POLICY_FAILED: ++ return -EACCES; + case FR_ACT_BLACKHOLE: + default: + return -EINVAL; +--- a/net/ipv6/route.c ++++ b/net/ipv6/route.c +@@ -98,6 +98,8 @@ static int ip6_pkt_discard(struct sk_bu + static int ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb); + static int ip6_pkt_prohibit(struct sk_buff *skb); + static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb); ++static int ip6_pkt_policy_failed(struct sk_buff *skb); ++static int ip6_pkt_policy_failed_out(struct net *net, struct sock *sk, struct sk_buff *skb); + static void ip6_link_failure(struct sk_buff *skb); + static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, + struct sk_buff *skb, u32 mtu, +@@ -316,6 +318,18 @@ static const struct rt6_info ip6_prohibi + .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), + }; + ++static const struct rt6_info ip6_policy_failed_entry_template = { ++ .dst = { ++ .__rcuref = RCUREF_INIT(1), ++ .__use = 1, ++ .obsolete = DST_OBSOLETE_FORCE_CHK, ++ .error = -EACCES, ++ .input = ip6_pkt_policy_failed, ++ .output = ip6_pkt_policy_failed_out, ++ }, ++ .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), ++}; ++ + static const struct rt6_info ip6_blk_hole_entry_template = { + .dst = { + .__rcuref = RCUREF_INIT(1), +@@ -1085,6 +1099,7 @@ static const int fib6_prop[RTN_MAX + 1] + [RTN_BLACKHOLE] = -EINVAL, + [RTN_UNREACHABLE] = -EHOSTUNREACH, + [RTN_PROHIBIT] = -EACCES, ++ [RTN_POLICY_FAILED] = -EACCES, + [RTN_THROW] = -EAGAIN, + [RTN_NAT] = -EINVAL, + [RTN_XRESOLVE] = -EINVAL, +@@ -1120,6 +1135,10 @@ static void ip6_rt_init_dst_reject(struc + rt->dst.output = ip6_pkt_prohibit_out; + rt->dst.input = ip6_pkt_prohibit; + break; ++ case RTN_POLICY_FAILED: ++ rt->dst.output = ip6_pkt_policy_failed_out; ++ rt->dst.input = ip6_pkt_policy_failed; ++ break; + case RTN_THROW: + case RTN_UNREACHABLE: + default: +@@ -4610,6 +4629,17 @@ static int ip6_pkt_prohibit_out(struct n + return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES); + } + ++static int ip6_pkt_policy_failed(struct sk_buff *skb) ++{ ++ return ip6_pkt_drop(skb, ICMPV6_POLICY_FAIL, IPSTATS_MIB_INNOROUTES); ++} ++ ++static int ip6_pkt_policy_failed_out(struct net *net, struct sock *sk, struct sk_buff *skb) ++{ ++ skb->dev = skb_dst(skb)->dev; ++ return ip6_pkt_drop(skb, ICMPV6_POLICY_FAIL, IPSTATS_MIB_OUTNOROUTES); ++} ++ + /* + * Allocate a dst for local (unicast / anycast) address. + */ +@@ -5101,7 +5131,8 @@ static int rtm_to_fib6_config(struct sk_ + if (rtm->rtm_type == RTN_UNREACHABLE || + rtm->rtm_type == RTN_BLACKHOLE || + rtm->rtm_type == RTN_PROHIBIT || +- rtm->rtm_type == RTN_THROW) ++ rtm->rtm_type == RTN_THROW || ++ rtm->rtm_type == RTN_POLICY_FAILED) + cfg->fc_flags |= RTF_REJECT; + + if (rtm->rtm_type == RTN_LOCAL) +@@ -6372,6 +6403,8 @@ static int ip6_route_dev_notify(struct n + #ifdef CONFIG_IPV6_MULTIPLE_TABLES + net->ipv6.ip6_prohibit_entry->dst.dev = dev; + net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev); ++ net->ipv6.ip6_policy_failed_entry->dst.dev = dev; ++ net->ipv6.ip6_policy_failed_entry->rt6i_idev = in6_dev_get(dev); + net->ipv6.ip6_blk_hole_entry->dst.dev = dev; + net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev); + #endif +@@ -6383,6 +6416,7 @@ static int ip6_route_dev_notify(struct n + in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev); + #ifdef CONFIG_IPV6_MULTIPLE_TABLES + in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev); ++ in6_dev_put_clear(&net->ipv6.ip6_policy_failed_entry->rt6i_idev); + in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev); + #endif + } +@@ -6578,6 +6612,8 @@ static int __net_init ip6_route_net_init + + #ifdef CONFIG_IPV6_MULTIPLE_TABLES + net->ipv6.fib6_has_custom_rules = false; ++ ++ + net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, + sizeof(*net->ipv6.ip6_prohibit_entry), + GFP_KERNEL); +@@ -6588,11 +6624,21 @@ static int __net_init ip6_route_net_init + ip6_template_metrics, true); + INIT_LIST_HEAD(&net->ipv6.ip6_prohibit_entry->dst.rt_uncached); + ++ net->ipv6.ip6_policy_failed_entry = ++ kmemdup(&ip6_policy_failed_entry_template, ++ sizeof(*net->ipv6.ip6_policy_failed_entry), GFP_KERNEL); ++ if (!net->ipv6.ip6_policy_failed_entry) ++ goto out_ip6_prohibit_entry; ++ net->ipv6.ip6_policy_failed_entry->dst.ops = &net->ipv6.ip6_dst_ops; ++ dst_init_metrics(&net->ipv6.ip6_policy_failed_entry->dst, ++ ip6_template_metrics, true); ++ INIT_LIST_HEAD(&net->ipv6.ip6_policy_failed_entry->dst.rt_uncached); ++ + net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, + sizeof(*net->ipv6.ip6_blk_hole_entry), + GFP_KERNEL); + if (!net->ipv6.ip6_blk_hole_entry) +- goto out_ip6_prohibit_entry; ++ goto out_ip6_policy_failed_entry; + net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; + dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst, + ip6_template_metrics, true); +@@ -6619,6 +6665,8 @@ out: + return ret; + + #ifdef CONFIG_IPV6_MULTIPLE_TABLES ++out_ip6_policy_failed_entry: ++ kfree(net->ipv6.ip6_policy_failed_entry); + out_ip6_prohibit_entry: + kfree(net->ipv6.ip6_prohibit_entry); + out_ip6_null_entry: +@@ -6638,6 +6686,7 @@ static void __net_exit ip6_route_net_exi + kfree(net->ipv6.ip6_null_entry); + #ifdef CONFIG_IPV6_MULTIPLE_TABLES + kfree(net->ipv6.ip6_prohibit_entry); ++ kfree(net->ipv6.ip6_policy_failed_entry); + kfree(net->ipv6.ip6_blk_hole_entry); + #endif + dst_entries_destroy(&net->ipv6.ip6_dst_ops); +@@ -6721,6 +6770,9 @@ void __init ip6_route_init_special_entri + init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); + init_net.ipv6.ip6_blk_hole_entry->dst.dev = init_net.loopback_dev; + init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); ++ init_net.ipv6.ip6_policy_failed_entry->dst.dev = init_net.loopback_dev; ++ init_net.ipv6.ip6_policy_failed_entry->rt6i_idev = ++ in6_dev_get(init_net.loopback_dev); + #endif + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch new file mode 100755 index 0000000..7057d36 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/671-net-provide-defines-for-_POLICY_FAILED-until-all-cod.patch @@ -0,0 +1,50 @@ +From: Jonas Gorski +Subject: net: provide defines for _POLICY_FAILED until all code is updated + +Upstream introduced ICMPV6_POLICY_FAIL for code 5 of destination +unreachable, conflicting with our name. + +Add appropriate defines to allow our code to build with the new +name until we have updated our local patches for older kernels +and userspace packages. + +Signed-off-by: Jonas Gorski +--- + include/uapi/linux/fib_rules.h | 2 ++ + include/uapi/linux/icmpv6.h | 2 ++ + include/uapi/linux/rtnetlink.h | 2 ++ + 3 files changed, 6 insertions(+) + +--- a/include/uapi/linux/fib_rules.h ++++ b/include/uapi/linux/fib_rules.h +@@ -90,6 +90,8 @@ enum { + __FR_ACT_MAX, + }; + ++#define FR_ACT_FAILED_POLICY FR_ACT_POLICY_FAILED ++ + #define FR_ACT_MAX (__FR_ACT_MAX - 1) + + #endif +--- a/include/uapi/linux/icmpv6.h ++++ b/include/uapi/linux/icmpv6.h +@@ -127,6 +127,8 @@ struct icmp6hdr { + #define ICMPV6_POLICY_FAIL 5 + #define ICMPV6_REJECT_ROUTE 6 + ++#define ICMPV6_FAILED_POLICY ICMPV6_POLICY_FAIL ++ + /* + * Codes for Time Exceeded + */ +--- a/include/uapi/linux/rtnetlink.h ++++ b/include/uapi/linux/rtnetlink.h +@@ -269,6 +269,8 @@ enum { + __RTN_MAX + }; + ++#define RTN_FAILED_POLICY RTN_POLICY_FAILED ++ + #define RTN_MAX (__RTN_MAX - 1) + + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/681-net-remove-NETIF_F_GSO_FRAGLIST-from-NETIF_F_GSO_SOF.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/681-net-remove-NETIF_F_GSO_FRAGLIST-from-NETIF_F_GSO_SOF.patch new file mode 100755 index 0000000..fdfacd8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/681-net-remove-NETIF_F_GSO_FRAGLIST-from-NETIF_F_GSO_SOF.patch @@ -0,0 +1,129 @@ +From: Felix Fietkau +Date: Thu, 15 Aug 2024 21:15:13 +0200 +Subject: [PATCH] net: remove NETIF_F_GSO_FRAGLIST from NETIF_F_GSO_SOFTWARE + +Several drivers set NETIF_F_GSO_SOFTWARE, but mangle fraglist GRO packets +in a way that they can't be properly segmented anymore. +In order to properly deal with this, remove fraglist GSO from +NETIF_F_GSO_SOFTWARE and switch to NETIF_F_GSO_SOFTWARE_ALL (which includes +fraglist GSO) in places where it's safe to add. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/dummy.c ++++ b/drivers/net/dummy.c +@@ -111,7 +111,7 @@ static void dummy_setup(struct net_devic + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE; + dev->lltx = true; + dev->features |= NETIF_F_SG | NETIF_F_FRAGLIST; +- dev->features |= NETIF_F_GSO_SOFTWARE; ++ dev->features |= NETIF_F_GSO_SOFTWARE_ALL; + dev->features |= NETIF_F_HW_CSUM | NETIF_F_HIGHDMA; + dev->features |= NETIF_F_GSO_ENCAP_ALL; + dev->hw_features |= dev->features; +--- a/drivers/net/loopback.c ++++ b/drivers/net/loopback.c +@@ -174,7 +174,7 @@ static void gen_lo_setup(struct net_devi + dev->lltx = true; + dev->netns_local = true; + netif_keep_dst(dev); +- dev->hw_features = NETIF_F_GSO_SOFTWARE; ++ dev->hw_features = NETIF_F_GSO_SOFTWARE_ALL; + dev->features = NETIF_F_SG | NETIF_F_FRAGLIST + | NETIF_F_GSO_SOFTWARE + | NETIF_F_HW_CSUM +--- a/drivers/net/macvlan.c ++++ b/drivers/net/macvlan.c +@@ -903,7 +903,7 @@ static int macvlan_hwtstamp_set(struct n + static struct lock_class_key macvlan_netdev_addr_lock_key; + + #define ALWAYS_ON_OFFLOADS \ +- (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | \ ++ (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE_ALL | \ + NETIF_F_GSO_ROBUST | NETIF_F_GSO_ENCAP_ALL) + + #define ALWAYS_ON_FEATURES ALWAYS_ON_OFFLOADS +--- a/include/linux/netdev_features.h ++++ b/include/linux/netdev_features.h +@@ -211,13 +211,14 @@ static inline int find_next_netdev_featu + + /* List of features with software fallbacks. */ + #define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | NETIF_F_GSO_SCTP | \ +- NETIF_F_GSO_UDP_L4 | NETIF_F_GSO_FRAGLIST) ++ NETIF_F_GSO_UDP_L4) ++#define NETIF_F_GSO_SOFTWARE_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_FRAGLIST) + + /* + * If one device supports one of these features, then enable them + * for all in netdev_increment_features. + */ +-#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ ++#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE_ALL | NETIF_F_GSO_ROBUST | \ + NETIF_F_SG | NETIF_F_HIGHDMA | \ + NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED) + +--- a/net/8021q/vlan.h ++++ b/net/8021q/vlan.h +@@ -109,7 +109,7 @@ static inline netdev_features_t vlan_tnl + netdev_features_t ret; + + ret = real_dev->hw_enc_features & +- (NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE | ++ (NETIF_F_CSUM_MASK | NETIF_F_GSO_SOFTWARE_ALL | + NETIF_F_GSO_ENCAP_ALL); + + if ((ret & NETIF_F_GSO_ENCAP_ALL) && (ret & NETIF_F_CSUM_MASK)) +--- a/net/8021q/vlan_dev.c ++++ b/net/8021q/vlan_dev.c +@@ -538,7 +538,7 @@ static int vlan_dev_init(struct net_devi + dev->state |= (1 << __LINK_STATE_NOCARRIER); + + dev->hw_features = NETIF_F_HW_CSUM | NETIF_F_SG | +- NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE | ++ NETIF_F_FRAGLIST | NETIF_F_GSO_SOFTWARE_ALL | + NETIF_F_GSO_ENCAP_ALL | + NETIF_F_HIGHDMA | NETIF_F_SCTP_CRC | + NETIF_F_FCOE_CRC | NETIF_F_FSO; +@@ -634,7 +634,7 @@ static netdev_features_t vlan_dev_fix_fe + if (lower_features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)) + lower_features |= NETIF_F_HW_CSUM; + features = netdev_intersect_features(features, lower_features); +- features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE); ++ features |= old_features & (NETIF_F_SOFT_FEATURES | NETIF_F_GSO_SOFTWARE_ALL); + + return features; + } +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2557,7 +2557,7 @@ void sk_setup_caps(struct sock *sk, stru + icsk->icsk_ack.dst_quick_ack = dst_metric(dst, RTAX_QUICKACK); + } + if (sk->sk_route_caps & NETIF_F_GSO) +- sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE; ++ sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE_ALL; + if (unlikely(sk->sk_gso_disabled)) + sk->sk_route_caps &= ~NETIF_F_GSO_MASK; + if (sk_can_gso(sk)) { +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -2023,7 +2023,7 @@ void ieee80211_color_collision_detection + /* interface handling */ + #define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ + NETIF_F_HW_CSUM | NETIF_F_SG | \ +- NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE | \ ++ NETIF_F_HIGHDMA | NETIF_F_GSO_SOFTWARE_ALL | \ + NETIF_F_HW_TC) + #define MAC80211_SUPPORTED_FEATURES_RX (NETIF_F_RXCSUM) + #define MAC80211_SUPPORTED_FEATURES (MAC80211_SUPPORTED_FEATURES_TX | \ +--- a/net/openvswitch/vport-internal_dev.c ++++ b/net/openvswitch/vport-internal_dev.c +@@ -109,7 +109,7 @@ static void do_setup(struct net_device * + netdev->rtnl_link_ops = &internal_dev_link_ops; + + netdev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | +- NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE | ++ NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE_ALL | + NETIF_F_GSO_ENCAP_ALL; + + netdev->vlan_features = netdev->features; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/683-of_net-add-mac-address-to-of-tree.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/683-of_net-add-mac-address-to-of-tree.patch new file mode 100755 index 0000000..0fb02db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/683-of_net-add-mac-address-to-of-tree.patch @@ -0,0 +1,75 @@ +From 8585756342caa6d27008d1ad0c18023e4211a40a Mon Sep 17 00:00:00 2001 +From: OpenWrt community +Date: Wed, 13 Jul 2022 12:22:48 +0200 +Subject: [PATCH] of/of_net: write back netdev MAC-address to device-tree + +The label-mac logic relies on the mac-address property of a netdev +devices of-node. However, the mac address can also be stored as a +different property or read from e.g. an mtd device. + +Create this node when reading a mac-address from OF if it does not +already exist and copy the mac-address used for the device to this +property. This way, the MAC address can be accessed using procfs. + +--- + net/core/of_net.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +--- a/net/core/of_net.c ++++ b/net/core/of_net.c +@@ -97,6 +97,27 @@ int of_get_mac_address_nvmem(struct devi + } + EXPORT_SYMBOL(of_get_mac_address_nvmem); + ++static int of_add_mac_address(struct device_node *np, u8* addr) ++{ ++ struct property *prop; ++ ++ prop = kzalloc(sizeof(*prop), GFP_KERNEL); ++ if (!prop) ++ return -ENOMEM; ++ ++ prop->name = "mac-address"; ++ prop->length = ETH_ALEN; ++ prop->value = kmemdup(addr, ETH_ALEN, GFP_KERNEL); ++ if (!prop->value || of_update_property(np, prop)) ++ goto free; ++ ++ return 0; ++free: ++ kfree(prop->value); ++ kfree(prop); ++ return -ENOMEM; ++} ++ + /** + * of_get_mac_address() + * @np: Caller's Device Node +@@ -132,17 +153,23 @@ int of_get_mac_address(struct device_nod + + ret = of_get_mac_addr(np, "mac-address", addr); + if (!ret) +- return 0; ++ goto found; + + ret = of_get_mac_addr(np, "local-mac-address", addr); + if (!ret) +- return 0; ++ goto found; + + ret = of_get_mac_addr(np, "address", addr); + if (!ret) +- return 0; ++ goto found; + +- return of_get_mac_address_nvmem(np, addr); ++ ret = of_get_mac_address_nvmem(np, addr); ++ if (ret) ++ return ret; ++ ++found: ++ ret = of_add_mac_address(np, addr); ++ return ret; + } + EXPORT_SYMBOL(of_get_mac_address); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/690-net-add-missing-check-for-TCP-fraglist-GRO.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/690-net-add-missing-check-for-TCP-fraglist-GRO.patch new file mode 100755 index 0000000..4684e04 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/690-net-add-missing-check-for-TCP-fraglist-GRO.patch @@ -0,0 +1,26 @@ +From 4498f0aa561092bc656bfabe7c4bdae41bc4a5b4 Mon Sep 17 00:00:00 2001 +From: Felix Fietkau +Date: Tue, 7 May 2024 11:24:50 +0200 +Subject: [PATCH] net: add missing check for TCP fraglist GRO + +It turns out that the existing checks do not guarantee that the skb can be +pulled up to the GRO offset. When using the usb r8152 network driver with +GRO fraglist, the BUG() in __skb_pull is often triggered. +Fix the crash by adding the missing check. + +Fixes: 8d95dc474f85 ("net: add code for TCP fraglist GRO") +Signed-off-by: Felix Fietkau +--- + net/ipv4/tcp_offload.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/net/ipv4/tcp_offload.c ++++ b/net/ipv4/tcp_offload.c +@@ -355,6 +355,7 @@ struct sk_buff *tcp_gro_receive(struct l + flush |= (__force int)(flags ^ tcp_flag_word(th2)); + flush |= skb->ip_summed != p->ip_summed; + flush |= skb->csum_level != p->csum_level; ++ flush |= !pskb_may_pull(skb, skb_gro_offset(skb)); + flush |= NAPI_GRO_CB(p)->count >= 64; + skb_set_network_header(skb, skb_gro_receive_network_offset(skb)); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch new file mode 100755 index 0000000..59868b2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/700-netfilter-nft_flow_offload-handle-netdevice-events-f.patch @@ -0,0 +1,106 @@ +From: Pablo Neira Ayuso +Date: Thu, 25 Jan 2018 12:58:55 +0100 +Subject: [PATCH] netfilter: nft_flow_offload: handle netdevice events from + nf_flow_table + +Move the code that deals with device events to the core. + +Signed-off-by: Pablo Neira Ayuso +--- + +--- a/net/netfilter/nf_flow_table_core.c ++++ b/net/netfilter/nf_flow_table_core.c +@@ -658,6 +658,23 @@ static struct pernet_operations nf_flow_ + .exit_batch = nf_flow_table_pernet_exit, + }; + ++static int nf_flow_table_netdev_event(struct notifier_block *this, ++ unsigned long event, void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (event != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ ++ nf_flow_table_cleanup(dev); ++ ++ return NOTIFY_DONE; ++} ++ ++static struct notifier_block flow_offload_netdev_notifier = { ++ .notifier_call = nf_flow_table_netdev_event, ++}; ++ + static int __init nf_flow_table_module_init(void) + { + int ret; +@@ -674,6 +691,10 @@ static int __init nf_flow_table_module_i + if (ret) + goto out_bpf; + ++ ret = register_netdevice_notifier(&flow_offload_netdev_notifier); ++ if (ret) ++ goto out_bpf; ++ + return 0; + + out_bpf: +@@ -685,6 +706,7 @@ out_offload: + + static void __exit nf_flow_table_module_exit(void) + { ++ unregister_netdevice_notifier(&flow_offload_netdev_notifier); + nf_flow_table_offload_exit(); + unregister_pernet_subsys(&nf_flow_table_net_ops); + } +--- a/net/netfilter/nft_flow_offload.c ++++ b/net/netfilter/nft_flow_offload.c +@@ -494,47 +494,14 @@ static struct nft_expr_type nft_flow_off + .owner = THIS_MODULE, + }; + +-static int flow_offload_netdev_event(struct notifier_block *this, +- unsigned long event, void *ptr) +-{ +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- +- if (event != NETDEV_DOWN) +- return NOTIFY_DONE; +- +- nf_flow_table_cleanup(dev); +- +- return NOTIFY_DONE; +-} +- +-static struct notifier_block flow_offload_netdev_notifier = { +- .notifier_call = flow_offload_netdev_event, +-}; +- + static int __init nft_flow_offload_module_init(void) + { +- int err; +- +- err = register_netdevice_notifier(&flow_offload_netdev_notifier); +- if (err) +- goto err; +- +- err = nft_register_expr(&nft_flow_offload_type); +- if (err < 0) +- goto register_expr; +- +- return 0; +- +-register_expr: +- unregister_netdevice_notifier(&flow_offload_netdev_notifier); +-err: +- return err; ++ return nft_register_expr(&nft_flow_offload_type); + } + + static void __exit nft_flow_offload_module_exit(void) + { + nft_unregister_expr(&nft_flow_offload_type); +- unregister_netdevice_notifier(&flow_offload_netdev_notifier); + } + + module_init(nft_flow_offload_module_init); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch new file mode 100755 index 0000000..360168a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch @@ -0,0 +1,29 @@ +From: Felix Fietkau +Date: Thu, 31 Aug 2023 21:48:38 +0200 +Subject: [PATCH] netfilter: nf_tables: ignore -EOPNOTSUPP on flowtable device + offload setup + +On many embedded devices, it is common to configure flowtable offloading for +a mix of different devices, some of which have hardware offload support and +some of which don't. +The current code limits the ability of user space to properly set up such a +configuration by only allowing adding devices with hardware offload support to +a offload-enabled flowtable. +Given that offload-enabled flowtables also imply fallback to pure software +offloading, this limitation makes little sense. +Fix it by not bailing out when the offload setup returns -EOPNOTSUPP + +Signed-off-by: Felix Fietkau +--- + +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -8718,7 +8718,7 @@ static int nft_register_flowtable_net_ho + err = flowtable->data.type->setup(&flowtable->data, + hook->ops.dev, + FLOW_BLOCK_BIND); +- if (err < 0) ++ if (err < 0 && err != -EOPNOTSUPP) + goto err_unregister_net_hooks; + + err = nf_register_net_hook(net, &hook->ops); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch new file mode 100755 index 0000000..d476465 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -0,0 +1,21 @@ +From: Felix Fietkau +Date: Mon, 21 Mar 2022 20:39:59 +0100 +Subject: [PATCH] net: ethernet: mtk_eth_soc: enable threaded NAPI + +This can improve performance under load by ensuring that NAPI processing is +not pinned on CPU 0. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -5148,6 +5148,8 @@ static int mtk_probe(struct platform_dev + dev_err(eth->dev, "failed to allocated dummy device\n"); + goto err_unreg_netdev; + } ++ eth->dummy_dev->threaded = 1; ++ strcpy(eth->dummy_dev->name, "mtk_eth"); + netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); + netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/703-phy-add-detach-callback-to-struct-phy_driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/703-phy-add-detach-callback-to-struct-phy_driver.patch new file mode 100755 index 0000000..4e00118 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/703-phy-add-detach-callback-to-struct-phy_driver.patch @@ -0,0 +1,38 @@ +From: Gabor Juhos +Subject: generic: add detach callback to struct phy_driver + +lede-commit: fe61fc2d7d0b3fb348b502f68f98243b3ddf5867 + +Signed-off-by: Gabor Juhos +--- + drivers/net/phy/phy_device.c | 3 +++ + include/linux/phy.h | 6 ++++++ + 2 files changed, 9 insertions(+) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -2037,6 +2037,9 @@ void phy_detach(struct phy_device *phyde + phydev->devlink = NULL; + } + ++ if (phydev->drv && phydev->drv->detach) ++ phydev->drv->detach(phydev); ++ + if (phydev->sysfs_links) { + if (dev) + sysfs_remove_link(&dev->dev.kobj, "phydev"); +--- a/include/linux/phy.h ++++ b/include/linux/phy.h +@@ -1037,6 +1037,12 @@ struct phy_driver { + /** @handle_interrupt: Override default interrupt handling */ + irqreturn_t (*handle_interrupt)(struct phy_device *phydev); + ++ /* ++ * Called before an ethernet device is detached ++ * from the PHY. ++ */ ++ void (*detach)(struct phy_device *phydev); ++ + /** @remove: Clears up any memory if needed */ + void (*remove)(struct phy_device *phydev); + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/704-net-phy-register-phy-led_triggers-during-probe-to-av.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/704-net-phy-register-phy-led_triggers-during-probe-to-av.patch new file mode 100755 index 0000000..126275c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/704-net-phy-register-phy-led_triggers-during-probe-to-av.patch @@ -0,0 +1,116 @@ +From 5225349f1e750dfd107a4c5dc97d91fa212dc1ed Mon Sep 17 00:00:00 2001 +From: Andrew Lunn +Date: Sat, 21 Feb 2026 14:51:54 -0600 +Subject: [PATCH] net: phy: register phy led_triggers during probe to avoid + AB-BA deadlock + +There is an AB-BA deadlock when both LEDS_TRIGGER_NETDEV and +LED_TRIGGER_PHY are enabled: + +[ 1362.049207] [<8054e4b8>] led_trigger_register+0x5c/0x1fc <-- Trying to get lock "triggers_list_lock" via down_write(&triggers_list_lock); +[ 1362.054536] [<80662830>] phy_led_triggers_register+0xd0/0x234 +[ 1362.060329] [<8065e200>] phy_attach_direct+0x33c/0x40c +[ 1362.065489] [<80651fc4>] phylink_fwnode_phy_connect+0x15c/0x23c +[ 1362.071480] [<8066ee18>] mtk_open+0x7c/0xba0 +[ 1362.075849] [<806d714c>] __dev_open+0x280/0x2b0 +[ 1362.080384] [<806d7668>] __dev_change_flags+0x244/0x24c +[ 1362.085598] [<806d7698>] dev_change_flags+0x28/0x78 +[ 1362.090528] [<807150e4>] dev_ioctl+0x4c0/0x654 <-- Hold lock "rtnl_mutex" by calling rtnl_lock(); +[ 1362.094985] [<80694360>] sock_ioctl+0x2f4/0x4e0 +[ 1362.099567] [<802e9c4c>] sys_ioctl+0x32c/0xd8c +[ 1362.104022] [<80014504>] syscall_common+0x34/0x58 + +Here LED_TRIGGER_PHY is registering LED triggers during phy_attach +while holding RTNL and then taking triggers_list_lock. + +[ 1362.191101] [<806c2640>] register_netdevice_notifier+0x60/0x168 <-- Trying to get lock "rtnl_mutex" via rtnl_lock(); +[ 1362.197073] [<805504ac>] netdev_trig_activate+0x194/0x1e4 +[ 1362.202490] [<8054e28c>] led_trigger_set+0x1d4/0x360 <-- Hold lock "triggers_list_lock" by down_read(&triggers_list_lock); +[ 1362.207511] [<8054eb38>] led_trigger_write+0xd8/0x14c +[ 1362.212566] [<80381d98>] sysfs_kf_bin_write+0x80/0xbc +[ 1362.217688] [<8037fcd8>] kernfs_fop_write_iter+0x17c/0x28c +[ 1362.223174] [<802cbd70>] vfs_write+0x21c/0x3c4 +[ 1362.227712] [<802cc0c4>] ksys_write+0x78/0x12c +[ 1362.232164] [<80014504>] syscall_common+0x34/0x58 + +Here LEDS_TRIGGER_NETDEV is being enabled on an LED. It first takes +triggers_list_lock and then RTNL. A classical AB-BA deadlock. + +phy_led_triggers_registers() does not require the RTNL, it does not +make any calls into the network stack which require protection. There +is also no requirement the PHY has been attached to a MAC, the +triggers only make use of phydev state. This allows the call to +phy_led_triggers_registers() to be placed elsewhere. PHY probe() and +release() don't hold RTNL, so solving the AB-BA deadlock. + +Reported-by: Shiji Yang +Closes: https://lore.kernel.org/all/OS7PR01MB13602B128BA1AD3FA38B6D1FFBC69A@OS7PR01MB13602.jpnprd01.prod.outlook.com/ +Fixes: 06f502f57d0d ("leds: trigger: Introduce a NETDEV trigger") +Signed-off-by: Andrew Lunn +--- + drivers/net/phy/phy_device.c | 25 +++++++++++++++++-------- + 1 file changed, 17 insertions(+), 8 deletions(-) + +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -1684,8 +1684,6 @@ int phy_attach_direct(struct net_device + goto error; + + phy_resume(phydev); +- if (!phydev->is_on_sfp_module) +- phy_led_triggers_register(phydev); + + /** + * If the external phy used by current mac interface is managed by +@@ -2058,9 +2056,6 @@ void phy_detach(struct phy_device *phyde + } + phydev->phylink = NULL; + +- if (!phydev->is_on_sfp_module) +- phy_led_triggers_unregister(phydev); +- + if (phydev->mdio.dev.driver) + module_put(phydev->mdio.dev.driver->owner); + +@@ -3691,17 +3686,28 @@ static int phy_probe(struct device *dev) + /* Set the state to READY by default */ + phydev->state = PHY_READY; + ++ /* Register the PHY LED triggers */ ++ if (!phydev->is_on_sfp_module) ++ phy_led_triggers_register(phydev); ++ + /* Get the LEDs from the device tree, and instantiate standard + * LEDs for them. + */ + if (IS_ENABLED(CONFIG_PHYLIB_LEDS) && !phy_driver_is_genphy(phydev) && +- !phy_driver_is_genphy_10g(phydev)) ++ !phy_driver_is_genphy_10g(phydev)) { + err = of_phy_leds(phydev); ++ if (err) ++ goto out; ++ } ++ ++ return 0; + + out: ++ if (!phydev->is_on_sfp_module) ++ phy_led_triggers_unregister(phydev); ++ + /* Re-assert the reset signal on error */ +- if (err) +- phy_device_reset(phydev, 1); ++ phy_device_reset(phydev, 1); + + return err; + } +@@ -3716,6 +3722,9 @@ static int phy_remove(struct device *dev + !phy_driver_is_genphy_10g(phydev)) + phy_leds_unregister(phydev); + ++ if (!phydev->is_on_sfp_module) ++ phy_led_triggers_unregister(phydev); ++ + phydev->state = PHY_DOWN; + + sfp_bus_del_upstream(phydev->sfp_bus); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/705-net-dsa-tag_mtk-add-padding-for-tx-packets.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/705-net-dsa-tag_mtk-add-padding-for-tx-packets.patch new file mode 100755 index 0000000..f7e4e77 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/705-net-dsa-tag_mtk-add-padding-for-tx-packets.patch @@ -0,0 +1,28 @@ +From: Felix Fietkau +Date: Fri, 6 May 2022 21:38:42 +0200 +Subject: [PATCH] net: dsa: tag_mtk: add padding for tx packets + +Padding for transmitted packets needs to account for the special tag. +With not enough padding, garbage bytes are inserted by the switch at the +end of small packets. + +Fixes: 5cd8985a1909 ("net-next: dsa: add Mediatek tag RX/TX handler") +Signed-off-by: Felix Fietkau +--- + +--- a/net/dsa/tag_mtk.c ++++ b/net/dsa/tag_mtk.c +@@ -29,6 +29,13 @@ static struct sk_buff *mtk_tag_xmit(stru + + skb_set_queue_mapping(skb, dp->index); + ++ /* The Ethernet switch we are interfaced with needs packets to be at ++ * least 64 bytes (including FCS) otherwise their padding might be ++ * corrupted. With tags enabled, we need to make sure that packets are ++ * at least 68 bytes (including FCS and tag). ++ */ ++ eth_skb_pad(skb); ++ + /* Build the special tag after the MAC Source Address. If VLAN header + * is present, it's required that VLAN header and special tag is + * being combined. Only in this way we can allow the switch can parse diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch new file mode 100755 index 0000000..dea84c7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/706-net-phy-populate-host_interfaces-when-attaching-PHY.patch @@ -0,0 +1,57 @@ +From 4e432e530db0056450fbc4a3cee793f16adc39a7 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 8 Oct 2024 23:58:41 +0100 +Subject: [PATCH] net: phy: populate host_interfaces when attaching PHY + +Use bitmask of interfaces supported by the MAC for the PHY to choose +from if the declared interface mode is among those using a single pair +of SerDes lanes. +This will allow 2500Base-T PHYs to switch to SGMII on most hosts, which +results in half-duplex being supported in case the MAC supports them. +Without this change, 2500Base-T PHYs will always operate in 2500Base-X +mode with rate-matching, which is not only wasteful in terms of energy +consumption, but also limits the supported interface modes to +full-duplex only. + +Signed-off-by: Daniel Golle +--- + drivers/net/phy/phylink.c | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -2273,7 +2273,7 @@ int phylink_fwnode_phy_connect(struct ph + { + struct fwnode_handle *phy_fwnode; + struct phy_device *phy_dev; +- int ret; ++ int i, ret; + + /* Fixed links and 802.3z are handled without needing a PHY */ + if (pl->cfg_link_an_mode == MLO_AN_FIXED || +@@ -2303,6 +2303,25 @@ int phylink_fwnode_phy_connect(struct ph + if (pl->config->mac_requires_rxc) + flags |= PHY_F_RXC_ALWAYS_ON; + ++ /* Assume single-lane SerDes interface modes share the same ++ * lanes and allow the PHY to switch to slower also supported modes ++ */ ++ for (i = ARRAY_SIZE(phylink_sfp_interface_preference) - 1; i >= 0; i--) { ++ /* skip unsupported modes */ ++ if (!test_bit(phylink_sfp_interface_preference[i], pl->config->supported_interfaces)) ++ continue; ++ ++ __set_bit(phylink_sfp_interface_preference[i], phy_dev->host_interfaces); ++ ++ /* skip all faster modes */ ++ if (phylink_sfp_interface_preference[i] == pl->link_interface) ++ break; ++ } ++ ++ if (test_bit(pl->link_interface, phylink_sfp_interfaces)) ++ phy_interface_and(phy_dev->host_interfaces, phylink_sfp_interfaces, ++ pl->config->supported_interfaces); ++ + ret = phy_attach_direct(pl->netdev, phy_dev, flags, + pl->link_interface); + phy_device_free(phy_dev); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch new file mode 100755 index 0000000..2f90df6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/710-bridge-add-knob-for-filtering-rx-tx-BPDU-pack.patch @@ -0,0 +1,174 @@ +From: Felix Fietkau +Date: Fri, 27 Aug 2021 12:22:32 +0200 +Subject: [PATCH] bridge: add knob for filtering rx/tx BPDU packets on a port + +Some devices (e.g. wireless APs) can't have devices behind them be part of +a bridge topology with redundant links, due to address limitations. +Additionally, broadcast traffic on these devices is somewhat expensive, due to +the low data rate and wakeups of clients in powersave mode. +This knob can be used to ensure that BPDU packets are never sent or forwarded +to/from these devices + +Signed-off-by: Felix Fietkau +--- + +--- a/include/linux/if_bridge.h ++++ b/include/linux/if_bridge.h +@@ -61,6 +61,7 @@ struct br_ip_list { + #define BR_PORT_LOCKED BIT(21) + #define BR_PORT_MAB BIT(22) + #define BR_NEIGH_VLAN_SUPPRESS BIT(23) ++#define BR_BPDU_FILTER BIT(24) + + #define BR_DEFAULT_AGEING_TIME (300 * HZ) + +--- a/net/bridge/br_forward.c ++++ b/net/bridge/br_forward.c +@@ -202,6 +202,7 @@ void br_flood(struct net_bridge *br, str + enum br_pkt_type pkt_type, bool local_rcv, bool local_orig, + u16 vid) + { ++ const unsigned char *dest = eth_hdr(skb)->h_dest; + struct net_bridge_port *prev = NULL; + struct net_bridge_port *p; + +@@ -219,6 +220,10 @@ void br_flood(struct net_bridge *br, str + case BR_PKT_MULTICAST: + if (!(p->flags & BR_MCAST_FLOOD) && skb->dev != br->dev) + continue; ++ if ((p->flags & BR_BPDU_FILTER) && ++ unlikely(is_link_local_ether_addr(dest) && ++ dest[5] == 0)) ++ continue; + break; + case BR_PKT_BROADCAST: + if (!(p->flags & BR_BCAST_FLOOD) && skb->dev != br->dev) +--- a/net/bridge/br_input.c ++++ b/net/bridge/br_input.c +@@ -368,6 +368,8 @@ static rx_handler_result_t br_handle_fra + fwd_mask |= p->group_fwd_mask; + switch (dest[5]) { + case 0x00: /* Bridge Group Address */ ++ if (p->flags & BR_BPDU_FILTER) ++ goto drop; + /* If STP is turned off, + then must forward to keep loop detection */ + if (p->br->stp_enabled == BR_NO_STP || +--- a/net/bridge/br_sysfs_if.c ++++ b/net/bridge/br_sysfs_if.c +@@ -240,6 +240,7 @@ BRPORT_ATTR_FLAG(multicast_flood, BR_MCA + BRPORT_ATTR_FLAG(broadcast_flood, BR_BCAST_FLOOD); + BRPORT_ATTR_FLAG(neigh_suppress, BR_NEIGH_SUPPRESS); + BRPORT_ATTR_FLAG(isolated, BR_ISOLATED); ++BRPORT_ATTR_FLAG(bpdu_filter, BR_BPDU_FILTER); + + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING + static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf) +@@ -292,6 +293,7 @@ static const struct brport_attribute *br + &brport_attr_group_fwd_mask, + &brport_attr_neigh_suppress, + &brport_attr_isolated, ++ &brport_attr_bpdu_filter, + &brport_attr_backup_port, + NULL + }; +--- a/net/bridge/br_stp_bpdu.c ++++ b/net/bridge/br_stp_bpdu.c +@@ -80,7 +80,8 @@ void br_send_config_bpdu(struct net_brid + { + unsigned char buf[35]; + +- if (p->br->stp_enabled != BR_KERNEL_STP) ++ if (p->br->stp_enabled != BR_KERNEL_STP || ++ (p->flags & BR_BPDU_FILTER)) + return; + + buf[0] = 0; +@@ -127,7 +128,8 @@ void br_send_tcn_bpdu(struct net_bridge_ + { + unsigned char buf[4]; + +- if (p->br->stp_enabled != BR_KERNEL_STP) ++ if (p->br->stp_enabled != BR_KERNEL_STP || ++ (p->flags & BR_BPDU_FILTER)) + return; + + buf[0] = 0; +@@ -172,6 +174,9 @@ void br_stp_rcv(const struct stp_proto * + if (!(br->dev->flags & IFF_UP)) + goto out; + ++ if (p->flags & BR_BPDU_FILTER) ++ goto out; ++ + if (p->state == BR_STATE_DISABLED) + goto out; + +--- a/include/uapi/linux/if_link.h ++++ b/include/uapi/linux/if_link.h +@@ -1094,6 +1094,7 @@ enum { + IFLA_BRPORT_MCAST_MAX_GROUPS, + IFLA_BRPORT_NEIGH_VLAN_SUPPRESS, + IFLA_BRPORT_BACKUP_NHID, ++ IFLA_BRPORT_BPDU_FILTER, + __IFLA_BRPORT_MAX + }; + #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1) +--- a/net/bridge/br_netlink.c ++++ b/net/bridge/br_netlink.c +@@ -190,6 +190,7 @@ static inline size_t br_port_info_size(v + + nla_total_size(1) /* IFLA_BRPORT_LOCKED */ + + nla_total_size(1) /* IFLA_BRPORT_MAB */ + + nla_total_size(1) /* IFLA_BRPORT_NEIGH_VLAN_SUPPRESS */ ++ + nla_total_size(1) /* IFLA_BRPORT_BPDU_FILTER */ + + nla_total_size(sizeof(struct ifla_bridge_id)) /* IFLA_BRPORT_ROOT_ID */ + + nla_total_size(sizeof(struct ifla_bridge_id)) /* IFLA_BRPORT_BRIDGE_ID */ + + nla_total_size(sizeof(u16)) /* IFLA_BRPORT_DESIGNATED_PORT */ +@@ -282,7 +283,8 @@ static int br_port_fill_attrs(struct sk_ + nla_put_u8(skb, IFLA_BRPORT_LOCKED, !!(p->flags & BR_PORT_LOCKED)) || + nla_put_u8(skb, IFLA_BRPORT_MAB, !!(p->flags & BR_PORT_MAB)) || + nla_put_u8(skb, IFLA_BRPORT_NEIGH_VLAN_SUPPRESS, +- !!(p->flags & BR_NEIGH_VLAN_SUPPRESS))) ++ !!(p->flags & BR_NEIGH_VLAN_SUPPRESS)) || ++ nla_put_u8(skb, IFLA_BRPORT_BPDU_FILTER, !!(p->flags & BR_BPDU_FILTER))) + return -EMSGSIZE; + + timerval = br_timer_value(&p->message_age_timer); +@@ -902,6 +904,7 @@ static const struct nla_policy br_port_p + [IFLA_BRPORT_MCAST_MAX_GROUPS] = { .type = NLA_U32 }, + [IFLA_BRPORT_NEIGH_VLAN_SUPPRESS] = NLA_POLICY_MAX(NLA_U8, 1), + [IFLA_BRPORT_BACKUP_NHID] = { .type = NLA_U32 }, ++ [IFLA_BRPORT_BPDU_FILTER] = { .type = NLA_U8 }, + }; + + /* Change the state of the port and notify spanning tree */ +@@ -970,6 +973,7 @@ static int br_setport(struct net_bridge_ + br_set_port_flag(p, tb, IFLA_BRPORT_MAB, BR_PORT_MAB); + br_set_port_flag(p, tb, IFLA_BRPORT_NEIGH_VLAN_SUPPRESS, + BR_NEIGH_VLAN_SUPPRESS); ++ br_set_port_flag(p, tb, IFLA_BRPORT_BPDU_FILTER, BR_BPDU_FILTER); + + if ((p->flags & BR_PORT_MAB) && + (!(p->flags & BR_PORT_LOCKED) || !(p->flags & BR_LEARNING))) { +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -62,7 +62,7 @@ + #include "dev.h" + + #define RTNL_MAX_TYPE 50 +-#define RTNL_SLAVE_MAX_TYPE 44 ++#define RTNL_SLAVE_MAX_TYPE 45 + + struct rtnl_link { + rtnl_doit_func doit; +@@ -5009,7 +5009,9 @@ int ndo_dflt_bridge_getlink(struct sk_bu + brport_nla_put_flag(skb, flags, mask, + IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD) || + brport_nla_put_flag(skb, flags, mask, +- IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD)) { ++ IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD) || ++ brport_nla_put_flag(skb, flags, mask, ++ IFLA_BRPORT_BPDU_FILTER, BR_BPDU_FILTER)) { + nla_nest_cancel(skb, protinfo); + goto nla_put_failure; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-01-net-dsa-qca8k-implement-lag_fdb_add-del-ops.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-01-net-dsa-qca8k-implement-lag_fdb_add-del-ops.patch new file mode 100755 index 0000000..0e89159 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-01-net-dsa-qca8k-implement-lag_fdb_add-del-ops.patch @@ -0,0 +1,86 @@ +From 3b4329230db8750bea7a56ef07f07cbbf5fc6c5a Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 4 Jul 2023 22:50:12 +0200 +Subject: [PATCH 19/20] net: dsa: qca8k: implement lag_fdb_add/del ops + +Implement lag_fdb_add/del ops to correctly support using LAG interface. +Qca8k switch supports declaring fdb entry for link aggregation by simply +setting the DES_PORT bits to all the LAG member. + +Signed-off-by: Christian Marangi +--- + drivers/net/dsa/qca/qca8k-8xxx.c | 2 ++ + drivers/net/dsa/qca/qca8k-common.c | 48 ++++++++++++++++++++++++++++++ + drivers/net/dsa/qca/qca8k.h | 6 ++++ + 3 files changed, 56 insertions(+) + +--- a/drivers/net/dsa/qca/qca8k-8xxx.c ++++ b/drivers/net/dsa/qca/qca8k-8xxx.c +@@ -2031,6 +2031,8 @@ static const struct dsa_switch_ops qca8k + .port_fdb_add = qca8k_port_fdb_add, + .port_fdb_del = qca8k_port_fdb_del, + .port_fdb_dump = qca8k_port_fdb_dump, ++ .lag_fdb_add = qca8k_lag_fdb_add, ++ .lag_fdb_del = qca8k_lag_fdb_del, + .port_mdb_add = qca8k_port_mdb_add, + .port_mdb_del = qca8k_port_mdb_del, + .port_mirror_add = qca8k_port_mirror_add, +--- a/drivers/net/dsa/qca/qca8k-common.c ++++ b/drivers/net/dsa/qca/qca8k-common.c +@@ -1234,6 +1234,42 @@ int qca8k_port_lag_leave(struct dsa_swit + return qca8k_lag_refresh_portmap(ds, port, lag, true); + } + ++int qca8k_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag lag, ++ const unsigned char *addr, u16 vid, ++ struct dsa_db db) ++{ ++ struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; ++ struct dsa_port *dp; ++ u16 port_mask = 0; ++ ++ /* Set the vid to the port vlan id if no vid is set */ ++ if (!vid) ++ vid = QCA8K_PORT_VID_DEF; ++ ++ dsa_lag_foreach_port(dp, ds->dst, &lag) ++ port_mask |= BIT(dp->index); ++ ++ return qca8k_port_fdb_insert(priv, addr, port_mask, vid); ++} ++ ++int qca8k_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag lag, ++ const unsigned char *addr, u16 vid, ++ struct dsa_db db) ++{ ++ struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; ++ struct dsa_port *dp; ++ u16 port_mask = 0; ++ ++ /* Set the vid to the port vlan id if no vid is set */ ++ if (!vid) ++ vid = QCA8K_PORT_VID_DEF; ++ ++ dsa_lag_foreach_port(dp, ds->dst, &lag) ++ port_mask |= BIT(dp->index); ++ ++ return qca8k_fdb_del(priv, addr, port_mask, vid); ++} ++ + int qca8k_read_switch_id(struct qca8k_priv *priv) + { + u32 val; +--- a/drivers/net/dsa/qca/qca8k.h ++++ b/drivers/net/dsa/qca/qca8k.h +@@ -592,5 +592,11 @@ int qca8k_port_lag_join(struct dsa_switc + struct netlink_ext_ack *extack); + int qca8k_port_lag_leave(struct dsa_switch *ds, int port, + struct dsa_lag lag); ++int qca8k_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag lag, ++ const unsigned char *addr, u16 vid, ++ struct dsa_db db); ++int qca8k_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag lag, ++ const unsigned char *addr, u16 vid, ++ struct dsa_db db); + + #endif /* __QCA8K_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-02-net-dsa-qca8k-enable-flooding-to-both-CPU-port.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-02-net-dsa-qca8k-enable-flooding-to-both-CPU-port.patch new file mode 100755 index 0000000..d10bbcf --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-02-net-dsa-qca8k-enable-flooding-to-both-CPU-port.patch @@ -0,0 +1,37 @@ +From b954d61d9ecfa64450fc178586719dc2a95b92a7 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 20 Jun 2023 21:48:24 +0200 +Subject: [PATCH 3/4] net: dsa: qca8k: enable flooding to both CPU port + +To permit a multi-CPU setup, flood all unknown frames to all CPU ports. +Each CPU port should have correct LOOKUP MEMBER configuration to +prevent receiving duplicate packets from user ports. + +Signed-off-by: Christian Marangi +--- + drivers/net/dsa/qca/qca8k-8xxx.c | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +--- a/drivers/net/dsa/qca/qca8k-8xxx.c ++++ b/drivers/net/dsa/qca/qca8k-8xxx.c +@@ -1913,15 +1913,12 @@ qca8k_setup(struct dsa_switch *ds) + } + } + +- /* Forward all unknown frames to CPU port for Linux processing +- * Notice that in multi-cpu config only one port should be set +- * for igmp, unknown, multicast and broadcast packet +- */ ++ /* Forward all unknown frames to CPU port for Linux processing */ + ret = qca8k_write(priv, QCA8K_REG_GLOBAL_FW_CTRL1, +- FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_IGMP_DP_MASK, BIT(cpu_port)) | +- FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_BC_DP_MASK, BIT(cpu_port)) | +- FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_MC_DP_MASK, BIT(cpu_port)) | +- FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_UC_DP_MASK, BIT(cpu_port))); ++ FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_IGMP_DP_MASK, dsa_cpu_ports(ds)) | ++ FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_BC_DP_MASK, dsa_cpu_ports(ds)) | ++ FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_MC_DP_MASK, dsa_cpu_ports(ds)) | ++ FIELD_PREP(QCA8K_GLOBAL_FW_CTRL1_UC_DP_MASK, dsa_cpu_ports(ds))); + if (ret) + return ret; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-03-net-dsa-qca8k-add-support-for-port_change_master.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-03-net-dsa-qca8k-add-support-for-port_change_master.patch new file mode 100755 index 0000000..25c6ae3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/711-03-net-dsa-qca8k-add-support-for-port_change_master.patch @@ -0,0 +1,158 @@ +From b2d6ebf2f92f8695c83fa6979f4ab579c588df76 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Tue, 20 Jun 2023 07:57:38 +0200 +Subject: [PATCH 4/4] net: dsa: qca8k: add support for port_change_master + +Add support for port_change_master to permit assigning an alternative +CPU port if the switch have both CPU port connected or create a LAG on +both CPU port and assign the LAG as DSA master. + +On port change master request, we check if the master is a LAG. +With LAG we compose the cpu_port_mask with the CPU port in the LAG, if +master is a simple dsa_port, we derive the index. + +Finally we apply the new cpu_port_mask to the LOOKUP MEMBER to permit +the port to receive packet by the new CPU port setup for the port and we +refresh the CPU ports LOOKUP MEMBER configuration to reflect the new +user port state. + +port_lag_join/leave is updated to refresh the user ports if we detect +that the LAG is a DSA master and we have user port using it as a master. + +Signed-off-by: Christian Marangi +--- + drivers/net/dsa/qca/qca8k-8xxx.c | 116 ++++++++++++++++++++++++++++++- + 1 file changed, 114 insertions(+), 2 deletions(-) + +--- a/drivers/net/dsa/qca/qca8k-8xxx.c ++++ b/drivers/net/dsa/qca/qca8k-8xxx.c +@@ -1750,6 +1750,117 @@ qca8k_get_tag_protocol(struct dsa_switch + return DSA_TAG_PROTO_QCA; + } + ++static int qca8k_port_change_master(struct dsa_switch *ds, int port, ++ struct net_device *master, ++ struct netlink_ext_ack *extack) ++{ ++ struct dsa_switch_tree *dst = ds->dst; ++ struct qca8k_priv *priv = ds->priv; ++ u8 cpu_port_mask = 0; ++ struct dsa_port *dp; ++ u32 val; ++ int ret; ++ ++ /* With LAG of CPU port, compose the mask for port LOOKUP MEMBER */ ++ if (netif_is_lag_master(master)) { ++ struct dsa_lag *lag; ++ int id; ++ ++ id = dsa_lag_id(dst, master); ++ lag = dsa_lag_by_id(dst, id); ++ ++ dsa_lag_foreach_port(dp, dst, lag) ++ if (dsa_port_is_cpu(dp)) ++ cpu_port_mask |= BIT(dp->index); ++ } else { ++ dp = master->dsa_ptr; ++ cpu_port_mask |= BIT(dp->index); ++ } ++ ++ /* Connect port to new cpu port */ ++ ret = regmap_read(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port), &val); ++ if (ret) ++ return ret; ++ ++ /* Reset connected CPU port in port LOOKUP MEMBER */ ++ val &= ~dsa_cpu_ports(ds); ++ /* Assign the new CPU port in port LOOKUP MEMBER */ ++ val |= cpu_port_mask; ++ ++ ret = regmap_update_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port), ++ QCA8K_PORT_LOOKUP_MEMBER, ++ val); ++ if (ret) ++ return ret; ++ ++ /* Refresh CPU port LOOKUP MEMBER with new port */ ++ dsa_tree_for_each_cpu_port(dp, ds->dst) { ++ u32 reg = QCA8K_PORT_LOOKUP_CTRL(dp->index); ++ ++ /* If CPU port in mask assign port, else remove port */ ++ if (BIT(dp->index) & cpu_port_mask) ++ ret = regmap_set_bits(priv->regmap, reg, BIT(port)); ++ else ++ ret = regmap_clear_bits(priv->regmap, reg, BIT(port)); ++ ++ if (ret) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int qca8k_port_lag_refresh_user_ports(struct dsa_switch *ds, ++ struct dsa_lag lag) ++{ ++ struct net_device *lag_dev = lag.dev; ++ struct dsa_port *dp; ++ int ret; ++ ++ /* Ignore if LAG is not a DSA master */ ++ if (!netif_is_lag_master(lag_dev)) ++ return 0; ++ ++ dsa_switch_for_each_user_port(dp, ds) { ++ /* Skip if assigned master is not the LAG */ ++ if (dsa_port_to_conduit(dp) != lag_dev) ++ continue; ++ ++ ret = qca8k_port_change_master(ds, dp->index, ++ lag_dev, NULL); ++ if (ret) ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int qca8xxx_port_lag_join(struct dsa_switch *ds, int port, ++ struct dsa_lag lag, ++ struct netdev_lag_upper_info *info, ++ struct netlink_ext_ack *extack) ++{ ++ int ret; ++ ++ ret = qca8k_port_lag_join(ds, port, lag, info, extack); ++ if (ret) ++ return ret; ++ ++ return qca8k_port_lag_refresh_user_ports(ds, lag); ++} ++ ++static int qca8xxx_port_lag_leave(struct dsa_switch *ds, int port, ++ struct dsa_lag lag) ++{ ++ int ret; ++ ++ ret = qca8k_port_lag_leave(ds, port, lag); ++ if (ret) ++ return ret; ++ ++ return qca8k_port_lag_refresh_user_ports(ds, lag); ++} ++ + static void + qca8k_conduit_change(struct dsa_switch *ds, const struct net_device *conduit, + bool operational) +@@ -2039,8 +2150,9 @@ static const struct dsa_switch_ops qca8k + .port_vlan_del = qca8k_port_vlan_del, + .phylink_get_caps = qca8k_phylink_get_caps, + .get_phy_flags = qca8k_get_phy_flags, +- .port_lag_join = qca8k_port_lag_join, +- .port_lag_leave = qca8k_port_lag_leave, ++ .port_lag_join = qca8xxx_port_lag_join, ++ .port_lag_leave = qca8xxx_port_lag_leave, ++ .port_change_conduit = qca8k_port_change_master, + .conduit_state_change = qca8k_conduit_change, + .connect_tag_protocol = qca8k_connect_tag_protocol, + }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/712-net-dsa-qca8k-enable-assisted-learning-on-CPU-port.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/712-net-dsa-qca8k-enable-assisted-learning-on-CPU-port.patch new file mode 100755 index 0000000..03cf2db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/712-net-dsa-qca8k-enable-assisted-learning-on-CPU-port.patch @@ -0,0 +1,57 @@ +From 0f6599167c126ce32c85d4f8a1f3d1775a268572 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Fri, 6 Oct 2023 12:44:00 +0200 +Subject: [PATCH] net: dsa: qca8k: enable assisted learning on CPU port + +Enable assisted learning on CPU port. + +It has been verified that there is a problem in packet roaming +from one BSS to another in the same security settings from one +physical R7800 to another physical R7800 where they are in the +same L2 broadcast domain backhauled/linked together via one +of the ethernet ports. +DHCP will fail to complete and traffic cannot flow for around 300 +seconds. + +Signed-off-by: Christian Marangi +--- + drivers/net/dsa/qca/qca8k-8xxx.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +--- a/drivers/net/dsa/qca/qca8k-8xxx.c ++++ b/drivers/net/dsa/qca/qca8k-8xxx.c +@@ -2022,6 +2022,12 @@ qca8k_setup(struct dsa_switch *ds) + dev_err(priv->dev, "failed enabling QCA header mode on port %d", dp->index); + return ret; + } ++ ++ /* Disable learning by default on all ports */ ++ ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(dp->index), ++ QCA8K_PORT_LOOKUP_LEARN); ++ if (ret) ++ return ret; + } + + /* Forward all unknown frames to CPU port for Linux processing */ +@@ -2051,11 +2057,6 @@ qca8k_setup(struct dsa_switch *ds) + if (ret) + return ret; + +- ret = regmap_clear_bits(priv->regmap, QCA8K_PORT_LOOKUP_CTRL(port), +- QCA8K_PORT_LOOKUP_LEARN); +- if (ret) +- return ret; +- + /* For port based vlans to work we need to set the + * default egress vid + */ +@@ -2107,6 +2108,9 @@ qca8k_setup(struct dsa_switch *ds) + /* Set max number of LAGs supported */ + ds->num_lag_ids = QCA8K_NUM_LAGS; + ++ /* HW learn on CPU port is limited and require manual setting */ ++ ds->assisted_learning_on_cpu_port = true; ++ + return 0; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/713-net-phy-c45-check-validity-of-10GbE-link-partner.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/713-net-phy-c45-check-validity-of-10GbE-link-partner.patch new file mode 100755 index 0000000..5870dfb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/713-net-phy-c45-check-validity-of-10GbE-link-partner.patch @@ -0,0 +1,29 @@ +From 7d719484930bc10c8472c0d43b94b68087541b24 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sat, 22 Apr 2023 01:25:39 +0100 +Subject: [PATCH] net: phy: c45: check validity of 10GbE link-partner + advertisement + +Only use link-partner advertisement bits for 10GbE modes if they are +actually valid. Check LOCALOK and REMOTEOK bits and clear 10GbE modes +unless both of them are set. + +Signed-off-by: Daniel Golle +--- a/include/linux/mdio.h ++++ b/include/linux/mdio.h +@@ -323,8 +323,14 @@ static inline u32 linkmode_adv_to_mii_10 + * to linkmode advertisement settings. Other bits in advertising aren't changed. + */ + static inline void mii_10gbt_stat_mod_linkmode_lpa_t(unsigned long *advertising, +- u32 lpa) ++ u32 lpa_in) + { ++ u32 lpa = lpa_in; ++ ++ if (!(lpa & MDIO_AN_10GBT_STAT_REMOK) || ++ !(lpa & MDIO_AN_10GBT_STAT_LOCOK)) ++ lpa = 0; ++ + linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + advertising, lpa & MDIO_AN_10GBT_STAT_LP2_5G); + linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-01-net-phy-realtek-use-genphy_soft_reset-for-2.5G-PHYs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-01-net-phy-realtek-use-genphy_soft_reset-for-2.5G-PHYs.patch new file mode 100755 index 0000000..2a0a0e9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-01-net-phy-realtek-use-genphy_soft_reset-for-2.5G-PHYs.patch @@ -0,0 +1,57 @@ +From 85cd45580f5e3b26068cccb7d6173f200e754dc0 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sun, 2 Apr 2023 23:56:16 +0100 +Subject: [PATCH 1/2] net: phy: realtek: use genphy_soft_reset for 2.5G PHYs + +Some vendor bootloaders do weird things with those PHYs which result in +link modes being reported wrongly. Start from a clean sheet by resetting +the PHY. + +Reported-by: Yevhen Kolomeiko +Signed-off-by: Daniel Golle +--- + drivers/net/phy/realtek/realtek_main.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -2255,6 +2255,7 @@ static struct phy_driver realtek_drvs[] + }, { + .name = "RTL8226 2.5Gbps PHY", + .match_phy_device = rtl8226_match_phy_device, ++ .soft_reset = genphy_soft_reset, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .read_status = rtl822x_read_status, +@@ -2267,6 +2268,7 @@ static struct phy_driver realtek_drvs[] + }, { + .match_phy_device = rtl8221b_match_phy_device, + .name = "RTL8226B_RTL8221B 2.5Gbps PHY", ++ .soft_reset = genphy_soft_reset, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, +@@ -2297,6 +2299,7 @@ static struct phy_driver realtek_drvs[] + }, { + PHY_ID_MATCH_EXACT(0x001cc848), + .name = "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY", ++ .soft_reset = genphy_soft_reset, + .get_features = rtl822x_get_features, + .config_aneg = rtl822x_config_aneg, + .config_init = rtl822xb_config_init, +@@ -2315,6 +2318,7 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8221B-VB-CG 2.5Gbps PHY", + .config_intr = rtl8221b_config_intr, + .handle_interrupt = rtl8221b_handle_interrupt, ++ .soft_reset = rtl822x_c45_soft_reset, + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .inband_caps = rtl822x_inband_caps, +@@ -2334,6 +2338,7 @@ static struct phy_driver realtek_drvs[] + .name = "RTL8221B-VM-CG 2.5Gbps PHY", + .config_intr = rtl8221b_config_intr, + .handle_interrupt = rtl8221b_handle_interrupt, ++ .soft_reset = rtl822x_c45_soft_reset, + .probe = rtl822x_probe, + .config_init = rtl822xb_config_init, + .inband_caps = rtl822x_inband_caps, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-03-net-phy-realtek-make-sure-paged-read-is-protected-by.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-03-net-phy-realtek-make-sure-paged-read-is-protected-by.patch new file mode 100755 index 0000000..8a0db2c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-03-net-phy-realtek-make-sure-paged-read-is-protected-by.patch @@ -0,0 +1,35 @@ +From 4dd2cc9b91ecb25f278a2c55e07e6455e9000e6b Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sat, 22 Apr 2023 01:21:14 +0100 +Subject: [PATCH] net: phy: realtek: make sure paged read is protected by mutex + +As we cannot rely on phy_read_paged function before the PHY is +identified, the paged read in rtlgen_supports_2_5gbps needs to be open +coded as it is being called by the match_phy_device function, ie. before +.read_page and .write_page have been populated. + +Make sure it is also protected by the MDIO bus mutex and use +rtl821x_write_page instead of 3 individually locked MDIO bus operations. + +Signed-off-by: Daniel Golle +--- + drivers/net/phy/realtek/realtek_main.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1823,9 +1823,11 @@ static bool rtlgen_supports_2_5gbps(stru + { + int val; + +- phy_write(phydev, RTL821x_PAGE_SELECT, 0xa61); +- val = phy_read(phydev, 0x13); +- phy_write(phydev, RTL821x_PAGE_SELECT, 0); ++ mutex_lock(&phydev->mdio.bus->mdio_lock); ++ rtl821x_write_page(phydev, 0xa61); ++ val = __phy_read(phydev, 0x13); ++ rtl821x_write_page(phydev, 0); ++ mutex_unlock(&phydev->mdio.bus->mdio_lock); + + return val >= 0 && val & MDIO_PMA_SPEED_2_5G; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-04-net-phy-realtek-setup-aldps.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-04-net-phy-realtek-setup-aldps.patch new file mode 100755 index 0000000..1a33ea5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-04-net-phy-realtek-setup-aldps.patch @@ -0,0 +1,93 @@ +From 9155098547fb1172d4fa536f3f6bc9d42f59d08c Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sat, 22 Apr 2023 03:26:01 +0100 +Subject: [PATCH] net: phy: realtek: setup ALDPS on RTL822x + +Setup Link Down Power Saving Mode according the DTS property +just like for RTL821x 1GE PHYs. + +Signed-off-by: Daniel Golle +--- + drivers/net/phy/realtek/realtek_main.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -170,6 +170,10 @@ + + #define RTL8224_SRAM_RTCT_LEN(pair) (0x8028 + (pair) * 4) + ++#define RTL8221B_PHYCR1 0xa430 ++#define RTL8221B_PHYCR1_ALDPS_EN BIT(2) ++#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12) ++ + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) + +@@ -216,6 +220,10 @@ struct rtl821x_priv { + u16 iner; + }; + ++struct rtl822x_priv { ++ bool enable_aldps; ++}; ++ + static int rtl821x_read_page(struct phy_device *phydev) + { + return __phy_read(phydev, RTL821x_PAGE_SELECT); +@@ -1238,6 +1246,18 @@ static int rtl822x_write_mmd(struct phy_ + + static int rtl822x_probe(struct phy_device *phydev) + { ++ struct device *dev = &phydev->mdio.dev; ++ struct rtl822x_priv *priv; ++ ++ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ priv->enable_aldps = of_property_read_bool(dev->of_node, ++ "realtek,aldps-enable"); ++ ++ phydev->priv = priv; ++ + if (IS_ENABLED(CONFIG_REALTEK_PHY_HWMON) && + phydev->phy_id != RTL_GENERIC_PHYID) + return rtl822x_hwmon_init(phydev); +@@ -1328,6 +1348,19 @@ static int rtl822xb_write_mmd(struct phy + return write_ret; + } + ++static int rtl822x_init_phycr1(struct phy_device *phydev, bool no_aldps) ++{ ++ struct rtl822x_priv *priv = phydev->priv; ++ u16 val = 0; ++ ++ if (priv->enable_aldps && !no_aldps) ++ val = RTL8221B_PHYCR1_ALDPS_EN | RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN; ++ ++ return phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL8221B_PHYCR1, ++ RTL8221B_PHYCR1_ALDPS_EN | ++ RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN, val); ++} ++ + static int rtl822x_set_serdes_option_mode(struct phy_device *phydev, bool gen1) + { + bool has_2500, has_sgmii; +@@ -1385,7 +1418,15 @@ static int rtl822x_set_serdes_option_mod + if (ret < 0) + return ret; + +- return phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); ++ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x6f11, 0x8020); ++ if (ret < 0) ++ return ret; ++ ++ ret = rtl822x_init_phycr1(phydev, false); ++ if (ret < 0) ++ return ret; ++ ++ return 0; + } + + static int rtl822x_config_init(struct phy_device *phydev) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-05-net-phy-realtek-detect-early-version-of-RTL8221B.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-05-net-phy-realtek-detect-early-version-of-RTL8221B.patch new file mode 100755 index 0000000..829f4b9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-05-net-phy-realtek-detect-early-version-of-RTL8221B.patch @@ -0,0 +1,52 @@ +From 0de82310d2b32e78ff79d42c08b1122a6ede3778 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sun, 30 Apr 2023 00:15:41 +0100 +Subject: [PATCH] net: phy: realtek: detect early version of RTL8221B + +Early versions (?) of the RTL8221B PHY cannot be identified in a regular +Clause-45 bus scan as the PHY doesn't report the implemented MMDs +correctly but returns 0 instead. +Implement custom identify function using the PKGID instead of iterating +over the implemented MMDs. + +Signed-off-by: Daniel Golle +[forward-port by @namiltd] +Signed-off-by: Mieczyslaw Nalewaj +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1908,10 +1908,32 @@ static int rtl8226_match_phy_device(stru + static int rtlgen_is_c45_match(struct phy_device *phydev, unsigned int id, + bool is_c45) + { +- if (phydev->is_c45) +- return is_c45 && (id == phydev->c45_ids.device_ids[1]); +- else ++ if (phydev->is_c45) { ++ u32 rid; ++ ++ if (!is_c45) ++ return 0; ++ ++ rid = phydev->c45_ids.device_ids[1]; ++ if ((rid == 0xffffffff) && phydev->mdio.bus->read_c45) { ++ int val; ++ ++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1); ++ if (val < 0) ++ return 0; ++ ++ rid = val << 16; ++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID2); ++ if (val < 0) ++ return 0; ++ ++ rid |= val; ++ } ++ ++ return (id == rid); ++ } else { + return !is_c45 && (id == phydev->phy_id); ++ } + } + + static int rtl8221b_match_phy_device(struct phy_device *phydev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-06-net-phy-realtek-mark-existing-MMDs-as-present.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-06-net-phy-realtek-mark-existing-MMDs-as-present.patch new file mode 100755 index 0000000..922d3f4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-06-net-phy-realtek-mark-existing-MMDs-as-present.patch @@ -0,0 +1,27 @@ +From 1addfb042a9d27788a0fb2c2935045b56fd8560e Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 23 Jan 2025 03:25:29 +0000 +Subject: [PATCH] net: phy: realtek: mark existing MMDs as present + +When using Clause-45 mode to access RealTek RTL8221B 2.5G PHYs some +versions of the PHY fail to report the MMDs present on the PHY. +Mark MMDs PMAPMD, PCS and AN which are always existing according to +the datasheet as present to fix that. + +Signed-off-by: Daniel Golle +--- + drivers/net/phy/realtek/realtek_main.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1604,6 +1604,9 @@ static int rtl822x_c45_get_features(stru + linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, + phydev->supported); + ++ phydev->c45_ids.mmds_present |= MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | ++ MDIO_DEVS_AN; ++ + return genphy_c45_pma_read_abilities(phydev); + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-07-net-phy-realtek-disable-MDIO-broadcast.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-07-net-phy-realtek-disable-MDIO-broadcast.patch new file mode 100755 index 0000000..e37faac --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-07-net-phy-realtek-disable-MDIO-broadcast.patch @@ -0,0 +1,33 @@ +From: Daniel Golle +Date: Thu, 30 Jan 2025 05:38:31 +0000 +Subject: [PATCH] net: phy: realtek: disable MDIO broadcast + +RealTek's PHYs by default also listen on MDIO address 0 which is defined +as broadcast address. This can lead to problems if there is an actual PHY +(such as MT7981 built-in PHY) present at this address, as accessing that +PHY may then confuse the RealTek PHY. + +Disabled listening on the MDIO broadcast address to avoid such problems. + +Signed-off-by: Daniel Golle +--- +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -173,6 +173,7 @@ + #define RTL8221B_PHYCR1 0xa430 + #define RTL8221B_PHYCR1_ALDPS_EN BIT(2) + #define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12) ++#define RTL8221B_PHYCR1_PHYAD_0_EN BIT(13) + + #define RTL8366RB_POWER_SAVE 0x15 + #define RTL8366RB_POWER_SAVE_ON BIT(12) +@@ -1358,7 +1359,8 @@ static int rtl822x_init_phycr1(struct ph + + return phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, RTL8221B_PHYCR1, + RTL8221B_PHYCR1_ALDPS_EN | +- RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN, val); ++ RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN | ++ RTL8221B_PHYCR1_PHYAD_0_EN, val); + } + + static int rtl822x_set_serdes_option_mode(struct phy_device *phydev, bool gen1) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-08-net-phy-realtek-rate-adapter-in-C22-mode.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-08-net-phy-realtek-rate-adapter-in-C22-mode.patch new file mode 100755 index 0000000..f8a28d5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/720-08-net-phy-realtek-rate-adapter-in-C22-mode.patch @@ -0,0 +1,22 @@ +From: Daniel Golle +Date: Mon, 5 Jan 2026 17:55:02 +0000 +Subject: [PATCH] net: phy: realtek: rate-adapter in C22 mode + +Use rate-adapter mode in case the PHY is connected to the host using +Clause-22 MDIO. + +This is necessary because phylink only handles dynamically switching the +interface mode if the PHY is connected using Clause-45 MDIO. + +Signed-off-by: Daniel Golle +--- a/drivers/net/phy/realtek/realtek_main.c ++++ b/drivers/net/phy/realtek/realtek_main.c +@@ -1387,7 +1387,7 @@ static int rtl822x_set_serdes_option_mod + return 0; + + /* determine SerDes option mode */ +- if (has_2500 && !has_sgmii) { ++ if (has_2500 && (!has_sgmii || !phydev->is_c45)) { + mode = RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX; + phydev->rate_matching = RATE_MATCH_PAUSE; + } else { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/731-net-permit-ieee80211_ptr-even-with-no-CFG82111-suppo.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/731-net-permit-ieee80211_ptr-even-with-no-CFG82111-suppo.patch new file mode 100755 index 0000000..50d3403 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/731-net-permit-ieee80211_ptr-even-with-no-CFG82111-suppo.patch @@ -0,0 +1,59 @@ +From 686c603f67ae87bf21a61b5e4b1564443f41c3ee Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 20 Oct 2022 03:34:43 +0200 +Subject: [PATCH] net: permit ieee80211_ptr even with no CFG82111 support + +Introduce a new flag CONFIG_CFG80211_HEADERS to compile in ieee80211_ptr +even if CFG80211 support is not compiled in. This is needed for the +backports project and for any downstream wireless driver that loads in +the kernel dynamically. + +Signed-off-by: Christian Marangi +--- + include/linux/netdevice.h | 2 +- + net/batman-adv/hard-interface.c | 2 +- + net/wireless/Kconfig | 4 ++++ + 3 files changed, 6 insertions(+), 2 deletions(-) + +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -2224,7 +2224,7 @@ struct net_device { + #if IS_ENABLED(CONFIG_AX25) + struct ax25_dev __rcu *ax25_ptr; + #endif +-#if IS_ENABLED(CONFIG_CFG80211) ++#if IS_ENABLED(CONFIG_CFG80211_HEADERS) + struct wireless_dev *ieee80211_ptr; + #endif + #if IS_ENABLED(CONFIG_IEEE802154) || IS_ENABLED(CONFIG_6LOWPAN) +--- a/net/batman-adv/hard-interface.c ++++ b/net/batman-adv/hard-interface.c +@@ -309,7 +309,7 @@ static bool batadv_is_cfg80211_netdev(st + if (!net_device) + return false; + +-#if IS_ENABLED(CONFIG_CFG80211) ++#if IS_ENABLED(CONFIG_CFG80211_HEADERS) + /* cfg80211 drivers have to set ieee80211_ptr */ + if (net_device->ieee80211_ptr) + return true; +--- a/net/wireless/Kconfig ++++ b/net/wireless/Kconfig +@@ -26,6 +26,7 @@ config CFG80211 + # using a different algorithm, though right now they shouldn't + # (this is here rather than below to allow it to be a module) + select CRYPTO_SHA256 if CFG80211_USE_KERNEL_REGDB_KEYS ++ select CFG80211_HEADERS + help + cfg80211 is the Linux wireless LAN (802.11) configuration API. + Enable this if you have a wireless device. +@@ -36,6 +37,9 @@ config CFG80211 + + When built as a module it will be called cfg80211. + ++config CFG80211_HEADERS ++ bool "cfg80211 - headers support" ++ + if CFG80211 + + config NL80211_TESTMODE diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-00-net-ethernet-mtk_eth_soc-compile-out-netsys-v2-code-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-00-net-ethernet-mtk_eth_soc-compile-out-netsys-v2-code-.patch new file mode 100755 index 0000000..ec6ed6e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-00-net-ethernet-mtk_eth_soc-compile-out-netsys-v2-code-.patch @@ -0,0 +1,44 @@ +From: Felix Fietkau +Date: Thu, 27 Oct 2022 23:39:52 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: compile out netsys v2 code + on mt7621 + +Avoid some branches in the hot path on low-end devices with limited CPU power, +and reduce code size + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -1344,6 +1344,22 @@ struct mtk_mac { + /* the struct describing the SoC. these are declared in the soc_xyz.c files */ + extern const struct of_device_id of_mtk_match[]; + ++#ifdef CONFIG_SOC_MT7621 ++static inline bool mtk_is_netsys_v1(struct mtk_eth *eth) ++{ ++ return true; ++} ++ ++static inline bool mtk_is_netsys_v2_or_greater(struct mtk_eth *eth) ++{ ++ return false; ++} ++ ++static inline bool mtk_is_netsys_v3_or_greater(struct mtk_eth *eth) ++{ ++ return false; ++} ++#else + static inline bool mtk_is_netsys_v1(struct mtk_eth *eth) + { + return eth->soc->version == 1; +@@ -1358,6 +1374,7 @@ static inline bool mtk_is_netsys_v3_or_g + { + return eth->soc->version > 2; + } ++#endif + + static inline struct mtk_foe_entry * + mtk_foe_get_entry(struct mtk_ppe *ppe, u16 hash) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch new file mode 100755 index 0000000..71b20b9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch @@ -0,0 +1,102 @@ +From: Felix Fietkau +Date: Thu, 3 Nov 2022 12:38:49 +0100 +Subject: [PATCH] net: ethernet: mtk_eth_soc: work around issue with sending + small fragments + +When lots of frames are sent with a number of very small fragments, an +internal FIFO can overflow, causing the DMA engine to lock up lock up and +transmit attempts time out. + +Fix this on MT7986 by increasing the reserved FIFO space. +Fix this on older chips by detecting the presence of small fragments and use +skb_gso_segment + skb_linearize to deal with them. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + + #include "mtk_eth_soc.h" +@@ -1607,12 +1608,28 @@ static void mtk_wake_queue(struct mtk_et + } + } + ++static bool mtk_skb_has_small_frag(struct sk_buff *skb) ++{ ++ int min_size = 16; ++ int i; ++ ++ if (skb_headlen(skb) < min_size) ++ return true; ++ ++ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) ++ if (skb_frag_size(&skb_shinfo(skb)->frags[i]) < min_size) ++ return true; ++ ++ return false; ++} ++ + static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) + { + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; + struct mtk_tx_ring *ring = ð->tx_ring; + struct net_device_stats *stats = &dev->stats; ++ struct sk_buff *segs, *next; + bool gso = false; + int tx_num; + +@@ -1641,6 +1658,18 @@ static netdev_tx_t mtk_start_xmit(struct + return NETDEV_TX_BUSY; + } + ++ if (mtk_is_netsys_v1(eth) && ++ skb_is_gso(skb) && mtk_skb_has_small_frag(skb)) { ++ segs = skb_gso_segment(skb, dev->features & ~NETIF_F_ALL_TSO); ++ if (IS_ERR(segs)) ++ goto drop; ++ ++ if (segs) { ++ consume_skb(skb); ++ skb = segs; ++ } ++ } ++ + /* TSO: fill MSS info in tcp checksum field */ + if (skb_is_gso(skb)) { + if (skb_cow_head(skb, 0)) { +@@ -1656,8 +1685,14 @@ static netdev_tx_t mtk_start_xmit(struct + } + } + +- if (mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) +- goto drop; ++ skb_list_walk_safe(skb, skb, next) { ++ if ((mtk_is_netsys_v1(eth) && ++ mtk_skb_has_small_frag(skb) && skb_linearize(skb)) || ++ mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) { ++ stats->tx_dropped++; ++ dev_kfree_skb_any(skb); ++ } ++ } + + if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) + netif_tx_stop_all_queues(dev); +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -278,7 +278,7 @@ + #define MTK_CHK_DDONE_EN BIT(28) + #define MTK_DMAD_WR_WDONE BIT(26) + #define MTK_WCOMP_EN BIT(24) +-#define MTK_RESV_BUF (0x40 << 16) ++#define MTK_RESV_BUF (0x80 << 16) + #define MTK_MUTLI_CNT (0x4 << 12) + #define MTK_LEAKY_BUCKET_EN BIT(11) + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-03-net-ethernet-mtk_eth_soc-optimize-dma-ring-address-i.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-03-net-ethernet-mtk_eth_soc-optimize-dma-ring-address-i.patch new file mode 100755 index 0000000..ef46691 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-03-net-ethernet-mtk_eth_soc-optimize-dma-ring-address-i.patch @@ -0,0 +1,486 @@ +From: Felix Fietkau +Date: Tue, 15 Oct 2024 12:52:56 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: optimize dma ring address/index + calculation + +Since DMA descriptor sizes are all power of 2, we can avoid costly integer +division in favor or simple shifts. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -43,6 +43,11 @@ MODULE_PARM_DESC(msg_level, "Message lev + offsetof(struct mtk_hw_stats, xdp_stats.x) / \ + sizeof(u64) } + ++#define RX_DESC_OFS(eth, i) \ ++ ((i) << (eth)->soc->rx.desc_shift) ++#define TX_DESC_OFS(eth, i) \ ++ ((i) << (eth)->soc->tx.desc_shift) ++ + static const struct mtk_reg_map mtk_reg_map = { + .tx_irq_mask = 0x1a1c, + .tx_irq_status = 0x1a18, +@@ -1160,14 +1165,14 @@ static int mtk_init_fq_dma(struct mtk_et + eth->scratch_ring = eth->sram_base; + else + eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, +- cnt * soc->tx.desc_size, ++ TX_DESC_OFS(eth, cnt), + ð->phy_scratch_ring, + GFP_KERNEL); + + if (unlikely(!eth->scratch_ring)) + return -ENOMEM; + +- phy_ring_tail = eth->phy_scratch_ring + soc->tx.desc_size * (cnt - 1); ++ phy_ring_tail = eth->phy_scratch_ring + TX_DESC_OFS(eth, cnt - 1); + + for (j = 0; j < DIV_ROUND_UP(soc->tx.fq_dma_size, MTK_FQ_DMA_LENGTH); j++) { + len = min_t(int, cnt - j * MTK_FQ_DMA_LENGTH, MTK_FQ_DMA_LENGTH); +@@ -1186,11 +1191,11 @@ static int mtk_init_fq_dma(struct mtk_et + for (i = 0; i < len; i++) { + struct mtk_tx_dma_v2 *txd; + +- txd = eth->scratch_ring + (j * MTK_FQ_DMA_LENGTH + i) * soc->tx.desc_size; ++ txd = eth->scratch_ring + TX_DESC_OFS(eth, j * MTK_FQ_DMA_LENGTH + i); + txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; + if (j * MTK_FQ_DMA_LENGTH + i < cnt) + txd->txd2 = eth->phy_scratch_ring + +- (j * MTK_FQ_DMA_LENGTH + i + 1) * soc->tx.desc_size; ++ TX_DESC_OFS(eth, j * MTK_FQ_DMA_LENGTH + i + 1); + + txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE); + if (MTK_HAS_CAPS(soc->caps, MTK_36BIT_DMA)) +@@ -1220,9 +1225,9 @@ static void *mtk_qdma_phys_to_virt(struc + } + + static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, +- void *txd, u32 txd_size) ++ void *txd, u32 txd_shift) + { +- int idx = (txd - ring->dma) / txd_size; ++ int idx = (txd - ring->dma) >> txd_shift; + + return &ring->buf[idx]; + } +@@ -1233,9 +1238,9 @@ static struct mtk_tx_dma *qdma_to_pdma(s + return ring->dma_pdma - (struct mtk_tx_dma *)ring->dma + dma; + } + +-static int txd_to_idx(struct mtk_tx_ring *ring, void *dma, u32 txd_size) ++static int txd_to_idx(struct mtk_tx_ring *ring, void *dma, u32 txd_shift) + { +- return (dma - ring->dma) / txd_size; ++ return (dma - ring->dma) >> txd_shift; + } + + static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, +@@ -1443,7 +1448,7 @@ static int mtk_tx_map(struct sk_buff *sk + if (itxd == ring->last_free) + return -ENOMEM; + +- itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_size); ++ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_shift); + memset(itx_buf, 0, sizeof(*itx_buf)); + + txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size, +@@ -1497,7 +1502,7 @@ static int mtk_tx_map(struct sk_buff *sk + mtk_tx_set_dma_desc(dev, txd, &txd_info); + + tx_buf = mtk_desc_to_tx_buf(ring, txd, +- soc->tx.desc_size); ++ soc->tx.desc_shift); + if (new_desc) + memset(tx_buf, 0, sizeof(*tx_buf)); + tx_buf->data = (void *)MTK_DMA_DUMMY_DESC; +@@ -1540,7 +1545,7 @@ static int mtk_tx_map(struct sk_buff *sk + } else { + int next_idx; + +- next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->tx.desc_size), ++ next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->tx.desc_shift), + ring->dma_size); + mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0); + } +@@ -1549,7 +1554,7 @@ static int mtk_tx_map(struct sk_buff *sk + + err_dma: + do { +- tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_size); ++ tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_shift); + + /* unmap dma */ + mtk_tx_unmap(eth, tx_buf, NULL, false); +@@ -1723,7 +1728,7 @@ static struct mtk_rx_ring *mtk_get_rx_ri + + ring = ð->rx_ring[i]; + idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); +- rxd = ring->dma + idx * eth->soc->rx.desc_size; ++ rxd = ring->dma + RX_DESC_OFS(eth, idx); + if (rxd->rxd2 & RX_DMA_DONE) { + ring->calc_idx_update = true; + return ring; +@@ -1891,7 +1896,7 @@ static int mtk_xdp_submit_frame(struct m + } + htxd = txd; + +- tx_buf = mtk_desc_to_tx_buf(ring, txd, soc->tx.desc_size); ++ tx_buf = mtk_desc_to_tx_buf(ring, txd, soc->tx.desc_shift); + memset(tx_buf, 0, sizeof(*tx_buf)); + htx_buf = tx_buf; + +@@ -1910,7 +1915,7 @@ static int mtk_xdp_submit_frame(struct m + goto unmap; + + tx_buf = mtk_desc_to_tx_buf(ring, txd, +- soc->tx.desc_size); ++ soc->tx.desc_shift); + memset(tx_buf, 0, sizeof(*tx_buf)); + n_desc++; + } +@@ -1948,7 +1953,7 @@ static int mtk_xdp_submit_frame(struct m + } else { + int idx; + +- idx = txd_to_idx(ring, txd, soc->tx.desc_size); ++ idx = txd_to_idx(ring, txd, soc->tx.desc_shift); + mtk_w32(eth, NEXT_DESP_IDX(idx, ring->dma_size), + MT7628_TX_CTX_IDX0); + } +@@ -1959,7 +1964,7 @@ static int mtk_xdp_submit_frame(struct m + + unmap: + while (htxd != txd) { +- tx_buf = mtk_desc_to_tx_buf(ring, htxd, soc->tx.desc_size); ++ tx_buf = mtk_desc_to_tx_buf(ring, htxd, soc->tx.desc_shift); + mtk_tx_unmap(eth, tx_buf, NULL, false); + + htxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; +@@ -2091,7 +2096,7 @@ static int mtk_poll_rx(struct napi_struc + goto rx_done; + + idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); +- rxd = ring->dma + idx * eth->soc->rx.desc_size; ++ rxd = ring->dma + RX_DESC_OFS(eth, idx); + data = ring->data[idx]; + + if (!mtk_rx_get_desc(eth, &trxd, rxd)) +@@ -2355,7 +2360,7 @@ static int mtk_poll_tx_qdma(struct mtk_e + break; + + tx_buf = mtk_desc_to_tx_buf(ring, desc, +- eth->soc->tx.desc_size); ++ eth->soc->tx.desc_shift); + if (!tx_buf->data) + break; + +@@ -2406,7 +2411,7 @@ static int mtk_poll_tx_pdma(struct mtk_e + } + mtk_tx_unmap(eth, tx_buf, &bq, true); + +- desc = ring->dma + cpu * eth->soc->tx.desc_size; ++ desc = ring->dma + TX_DESC_OFS(eth, cpu); + ring->last_free = desc; + atomic_inc(&ring->free_count); + +@@ -2524,7 +2529,7 @@ static int mtk_tx_alloc(struct mtk_eth * + { + const struct mtk_soc_data *soc = eth->soc; + struct mtk_tx_ring *ring = ð->tx_ring; +- int i, sz = soc->tx.desc_size; ++ int i, sz = TX_DESC_OFS(eth, 1); + struct mtk_tx_dma_v2 *txd; + int ring_size; + u32 ofs, val; +@@ -2571,7 +2576,7 @@ static int mtk_tx_alloc(struct mtk_eth * + * descriptors in ring->dma_pdma. + */ + if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { +- ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, ring_size * sz, ++ ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, TX_DESC_OFS(eth, ring_size), + &ring->phys_pdma, GFP_KERNEL); + if (!ring->dma_pdma) + goto no_tx_mem; +@@ -2586,7 +2591,7 @@ static int mtk_tx_alloc(struct mtk_eth * + atomic_set(&ring->free_count, ring_size - 2); + ring->next_free = ring->dma; + ring->last_free = (void *)txd; +- ring->last_free_ptr = (u32)(ring->phys + ((ring_size - 1) * sz)); ++ ring->last_free_ptr = (u32)(ring->phys + TX_DESC_OFS(eth, ring_size - 1)); + ring->thresh = MAX_SKB_FRAGS; + + /* make sure that all changes to the dma ring are flushed before we +@@ -2598,7 +2603,7 @@ static int mtk_tx_alloc(struct mtk_eth * + mtk_w32(eth, ring->phys, soc->reg_map->qdma.ctx_ptr); + mtk_w32(eth, ring->phys, soc->reg_map->qdma.dtx_ptr); + mtk_w32(eth, +- ring->phys + ((ring_size - 1) * sz), ++ ring->phys + TX_DESC_OFS(eth, ring_size - 1), + soc->reg_map->qdma.crx_ptr); + mtk_w32(eth, ring->last_free_ptr, soc->reg_map->qdma.drx_ptr); + +@@ -2647,14 +2652,14 @@ static void mtk_tx_clean(struct mtk_eth + } + if (!MTK_HAS_CAPS(soc->caps, MTK_SRAM) && ring->dma) { + dma_free_coherent(eth->dma_dev, +- ring->dma_size * soc->tx.desc_size, ++ TX_DESC_OFS(eth, ring->dma_size), + ring->dma, ring->phys); + ring->dma = NULL; + } + + if (ring->dma_pdma) { + dma_free_coherent(eth->dma_dev, +- ring->dma_size * soc->tx.desc_size, ++ TX_DESC_OFS(eth, ring->dma_size), + ring->dma_pdma, ring->phys_pdma); + ring->dma_pdma = NULL; + } +@@ -2710,15 +2715,13 @@ static int mtk_rx_alloc(struct mtk_eth * + if (!MTK_HAS_CAPS(eth->soc->caps, MTK_SRAM) || + rx_flag != MTK_RX_FLAGS_NORMAL) { + ring->dma = dma_alloc_coherent(eth->dma_dev, +- rx_dma_size * eth->soc->rx.desc_size, ++ RX_DESC_OFS(eth, rx_dma_size), + &ring->phys, GFP_KERNEL); + } else { + struct mtk_tx_ring *tx_ring = ð->tx_ring; + +- ring->dma = tx_ring->dma + tx_ring_size * +- eth->soc->tx.desc_size * (ring_no + 1); +- ring->phys = tx_ring->phys + tx_ring_size * +- eth->soc->tx.desc_size * (ring_no + 1); ++ ring->dma = tx_ring->dma + TX_DESC_OFS(eth, tx_ring_size * (ring_no + 1)); ++ ring->phys = tx_ring->phys + TX_DESC_OFS(eth, tx_ring_size * (ring_no + 1)); + } + + if (!ring->dma) +@@ -2729,7 +2732,7 @@ static int mtk_rx_alloc(struct mtk_eth * + dma_addr_t dma_addr; + void *data; + +- rxd = ring->dma + i * eth->soc->rx.desc_size; ++ rxd = ring->dma + RX_DESC_OFS(eth, i); + if (ring->page_pool) { + data = mtk_page_pool_get_buff(ring->page_pool, + &dma_addr, GFP_KERNEL); +@@ -2820,7 +2823,7 @@ static void mtk_rx_clean(struct mtk_eth + if (!ring->data[i]) + continue; + +- rxd = ring->dma + i * eth->soc->rx.desc_size; ++ rxd = ring->dma + RX_DESC_OFS(eth, i); + if (!rxd->rxd1) + continue; + +@@ -2837,7 +2840,7 @@ static void mtk_rx_clean(struct mtk_eth + + if (!in_sram && ring->dma) { + dma_free_coherent(eth->dma_dev, +- ring->dma_size * eth->soc->rx.desc_size, ++ RX_DESC_OFS(eth, ring->dma_size), + ring->dma, ring->phys); + ring->dma = NULL; + } +@@ -3208,7 +3211,7 @@ static void mtk_dma_free(struct mtk_eth + + if (!MTK_HAS_CAPS(soc->caps, MTK_SRAM) && eth->scratch_ring) { + dma_free_coherent(eth->dma_dev, +- MTK_QDMA_RING_SIZE * soc->tx.desc_size, ++ TX_DESC_OFS(eth, MTK_QDMA_RING_SIZE), + eth->scratch_ring, eth->phy_scratch_ring); + eth->scratch_ring = NULL; + eth->phy_scratch_ring = 0; +@@ -5236,6 +5239,9 @@ static void mtk_remove(struct platform_d + mtk_mdio_cleanup(eth); + } + ++#define DESC_SIZE(struct_name) \ ++ .desc_shift = const_ilog2(sizeof(struct_name)) ++ + static const struct mtk_soc_data mt2701_data = { + .reg_map = &mtk_reg_map, + .caps = MT7623_CAPS | MTK_HWLRO, +@@ -5244,14 +5250,14 @@ static const struct mtk_soc_data mt2701_ + .required_pctl = true, + .version = 1, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma), ++ DESC_SIZE(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, + .dma_size = MTK_DMA_SIZE(2K), +@@ -5272,14 +5278,14 @@ static const struct mtk_soc_data mt7621_ + .hash_offset = 2, + .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma), ++ DESC_SIZE(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, + .dma_size = MTK_DMA_SIZE(2K), +@@ -5302,14 +5308,14 @@ static const struct mtk_soc_data mt7622_ + .has_accounting = true, + .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma), ++ DESC_SIZE(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, + .dma_size = MTK_DMA_SIZE(2K), +@@ -5331,14 +5337,14 @@ static const struct mtk_soc_data mt7623_ + .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, + .disable_pll_modes = true, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma), ++ DESC_SIZE(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, + .dma_size = MTK_DMA_SIZE(2K), +@@ -5357,14 +5363,14 @@ static const struct mtk_soc_data mt7629_ + .has_accounting = true, + .version = 1, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma), ++ DESC_SIZE(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, + .dma_size = MTK_DMA_SIZE(2K), +@@ -5387,14 +5393,14 @@ static const struct mtk_soc_data mt7981_ + .has_accounting = true, + .foe_entry_size = MTK_FOE_ENTRY_V2_SIZE, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma_v2), ++ DESC_SIZE(struct mtk_tx_dma_v2), + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID_V2, + .dma_max_len = MTK_TX_DMA_BUF_LEN, +@@ -5417,14 +5423,14 @@ static const struct mtk_soc_data mt7986_ + .has_accounting = true, + .foe_entry_size = MTK_FOE_ENTRY_V2_SIZE, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma_v2), ++ DESC_SIZE(struct mtk_tx_dma_v2), + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID_V2, + .dma_max_len = MTK_TX_DMA_BUF_LEN, +@@ -5447,14 +5453,14 @@ static const struct mtk_soc_data mt7988_ + .has_accounting = true, + .foe_entry_size = MTK_FOE_ENTRY_V3_SIZE, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma_v2), ++ DESC_SIZE(struct mtk_tx_dma_v2), + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, + .dma_len_offset = 8, + .dma_size = MTK_DMA_SIZE(2K), + .fq_dma_size = MTK_DMA_SIZE(4K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma_v2), ++ DESC_SIZE(struct mtk_rx_dma_v2), + .irq_done_mask = MTK_RX_DONE_INT_V2, + .dma_l4_valid = RX_DMA_L4_VALID_V2, + .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, +@@ -5471,13 +5477,13 @@ static const struct mtk_soc_data rt5350_ + .required_pctl = false, + .version = 1, + .tx = { +- .desc_size = sizeof(struct mtk_tx_dma), ++ DESC_SIZE(struct mtk_tx_dma), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + .dma_size = MTK_DMA_SIZE(2K), + }, + .rx = { +- .desc_size = sizeof(struct mtk_rx_dma), ++ DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID_PDMA, + .dma_max_len = MTK_TX_DMA_BUF_LEN, +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -1160,7 +1160,7 @@ struct mtk_reg_map { + * @foe_entry_size Foe table entry size. + * @has_accounting Bool indicating support for accounting of + * offloaded flows. +- * @desc_size Tx/Rx DMA descriptor size. ++ * @desc_shift Tx/Rx DMA descriptor size (in power-of-2). + * @irq_done_mask Rx irq done register mask. + * @dma_l4_valid Rx DMA valid register mask. + * @dma_max_len Max DMA tx/rx buffer length. +@@ -1181,14 +1181,14 @@ struct mtk_soc_data { + bool has_accounting; + bool disable_pll_modes; + struct { +- u32 desc_size; ++ u32 desc_shift; + u32 dma_max_len; + u32 dma_len_offset; + u32 dma_size; + u32 fq_dma_size; + } tx; + struct { +- u32 desc_size; ++ u32 desc_shift; + u32 irq_done_mask; + u32 dma_l4_valid; + u32 dma_max_len; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-04-net-ethernet-mtk_eth_soc-shrink-struct-mtk_tx_buf.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-04-net-ethernet-mtk_eth_soc-shrink-struct-mtk_tx_buf.patch new file mode 100755 index 0000000..a2dd04b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-04-net-ethernet-mtk_eth_soc-shrink-struct-mtk_tx_buf.patch @@ -0,0 +1,124 @@ +From: Felix Fietkau +Date: Mon, 14 Jul 2025 10:52:59 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: shrink struct mtk_tx_buf + +There is no need to track the difference between dma_map_page +and dma_map_single, since they're unmapped in exactly the same way. +Also reorder fields in order to avoid padding. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1246,32 +1246,19 @@ static int txd_to_idx(struct mtk_tx_ring + static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, + struct xdp_frame_bulk *bq, bool napi) + { +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { +- if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) { +- dma_unmap_single(eth->dma_dev, +- dma_unmap_addr(tx_buf, dma_addr0), +- dma_unmap_len(tx_buf, dma_len0), +- DMA_TO_DEVICE); +- } else if (tx_buf->flags & MTK_TX_FLAGS_PAGE0) { +- dma_unmap_page(eth->dma_dev, +- dma_unmap_addr(tx_buf, dma_addr0), +- dma_unmap_len(tx_buf, dma_len0), +- DMA_TO_DEVICE); +- } +- } else { +- if (dma_unmap_len(tx_buf, dma_len0)) { +- dma_unmap_page(eth->dma_dev, +- dma_unmap_addr(tx_buf, dma_addr0), +- dma_unmap_len(tx_buf, dma_len0), +- DMA_TO_DEVICE); +- } ++ if (dma_unmap_len(tx_buf, dma_len0)) { ++ dma_unmap_page(eth->dma_dev, ++ dma_unmap_addr(tx_buf, dma_addr0), ++ dma_unmap_len(tx_buf, dma_len0), ++ DMA_TO_DEVICE); ++ } + +- if (dma_unmap_len(tx_buf, dma_len1)) { +- dma_unmap_page(eth->dma_dev, +- dma_unmap_addr(tx_buf, dma_addr1), +- dma_unmap_len(tx_buf, dma_len1), +- DMA_TO_DEVICE); +- } ++ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA) && ++ dma_unmap_len(tx_buf, dma_len1)) { ++ dma_unmap_page(eth->dma_dev, ++ dma_unmap_addr(tx_buf, dma_addr1), ++ dma_unmap_len(tx_buf, dma_len1), ++ DMA_TO_DEVICE); + } + + if (tx_buf->data && tx_buf->data != (void *)MTK_DMA_DUMMY_DESC) { +@@ -1293,7 +1280,6 @@ static void mtk_tx_unmap(struct mtk_eth + xdp_return_frame(xdpf); + } + } +- tx_buf->flags = 0; + tx_buf->data = NULL; + } + +@@ -1458,7 +1444,6 @@ static int mtk_tx_map(struct sk_buff *sk + + mtk_tx_set_dma_desc(dev, itxd, &txd_info); + +- itx_buf->flags |= MTK_TX_FLAGS_SINGLE0; + itx_buf->mac_id = mac->id; + setup_tx_buf(eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size, + k++); +@@ -1506,7 +1491,6 @@ static int mtk_tx_map(struct sk_buff *sk + if (new_desc) + memset(tx_buf, 0, sizeof(*tx_buf)); + tx_buf->data = (void *)MTK_DMA_DUMMY_DESC; +- tx_buf->flags |= MTK_TX_FLAGS_PAGE0; + tx_buf->mac_id = mac->id; + + setup_tx_buf(eth, tx_buf, txd_pdma, txd_info.addr, +@@ -1839,8 +1823,6 @@ static int mtk_xdp_frame_map(struct mtk_ + txd_info->size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(eth->dma_dev, txd_info->addr))) + return -ENOMEM; +- +- tx_buf->flags |= MTK_TX_FLAGS_SINGLE0; + } else { + struct page *page = virt_to_head_page(data); + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -701,14 +701,6 @@ struct mtk_hw_stats { + struct u64_stats_sync syncp; + }; + +-enum mtk_tx_flags { +- /* PDMA descriptor can point at 1-2 segments. This enum allows us to +- * track how memory was allocated so that it can be freed properly. +- */ +- MTK_TX_FLAGS_SINGLE0 = 0x01, +- MTK_TX_FLAGS_PAGE0 = 0x02, +-}; +- + /* This enum allows us to identify how the clock is defined on the array of the + * clock in the order + */ +@@ -881,13 +873,12 @@ enum mtk_tx_buf_type { + */ + struct mtk_tx_buf { + enum mtk_tx_buf_type type; ++ u16 mac_id; + void *data; + +- u16 mac_id; +- u16 flags; + DEFINE_DMA_UNMAP_ADDR(dma_addr0); +- DEFINE_DMA_UNMAP_LEN(dma_len0); + DEFINE_DMA_UNMAP_ADDR(dma_addr1); ++ DEFINE_DMA_UNMAP_LEN(dma_len0); + DEFINE_DMA_UNMAP_LEN(dma_len1); + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-05-net-ethernet-mtk_eth_soc-add-support-for-sending-fra.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-05-net-ethernet-mtk_eth_soc-add-support-for-sending-fra.patch new file mode 100755 index 0000000..8dad080 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/732-05-net-ethernet-mtk_eth_soc-add-support-for-sending-fra.patch @@ -0,0 +1,519 @@ +From: Felix Fietkau +Date: Mon, 14 Jul 2025 10:41:27 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add support for sending + fraglist GSO packets + +When primarily forwarding traffic, TCP fraglist GRO can be noticeably more +efficient than regular TCP GRO. In order to avoid the overhead of +unnecessary segmentation on ethernet tx, add support for sending fraglist +GRO packets. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -18,6 +18,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -27,6 +29,7 @@ + #include + #include + #include ++#include + #include + + #include "mtk_eth_soc.h" +@@ -1404,119 +1407,251 @@ static void mtk_tx_set_dma_desc(struct n + mtk_tx_set_dma_desc_v1(dev, txd, info); + } + ++struct mtk_tx_map_state { ++ struct mtk_tx_dma *txd, *txd_pdma; ++ struct mtk_tx_buf *tx_buf; ++ int nbuf; ++ int ndesc; ++}; ++ ++static void ++mtk_tx_map_set_txd(struct mtk_tx_map_state *state, struct mtk_tx_ring *ring, ++ const struct mtk_soc_data *soc, struct mtk_tx_dma *txd) ++{ ++ state->txd = txd; ++ state->txd_pdma = qdma_to_pdma(ring, txd); ++ state->tx_buf = mtk_desc_to_tx_buf(ring, txd, soc->tx.desc_shift); ++ memset(state->tx_buf, 0, sizeof(*state->tx_buf)); ++} ++ ++static int ++mtk_tx_map_info(struct mtk_eth *eth, struct mtk_tx_ring *ring, ++ struct net_device *dev, struct mtk_tx_map_state *state, ++ struct mtk_tx_dma_desc_info *txd_info) ++{ ++ const struct mtk_soc_data *soc = eth->soc; ++ struct mtk_tx_buf *tx_buf = state->tx_buf; ++ struct mtk_tx_dma *txd = state->txd; ++ struct mtk_mac *mac = netdev_priv(dev); ++ ++ if (state->nbuf && ++ (MTK_HAS_CAPS(soc->caps, MTK_QDMA) || (state->nbuf & 1) == 0)) { ++ txd = mtk_qdma_phys_to_virt(ring, txd->txd2); ++ if (txd == ring->last_free) ++ return -1; ++ ++ mtk_tx_map_set_txd(state, ring, soc, txd); ++ state->ndesc++; ++ } ++ ++ mtk_tx_set_dma_desc(dev, txd, txd_info); ++ tx_buf = state->tx_buf; ++ tx_buf->data = (void *)MTK_DMA_DUMMY_DESC; ++ tx_buf->mac_id = mac->id; ++ ++ setup_tx_buf(eth, tx_buf, state->txd_pdma, txd_info->addr, ++ txd_info->size, state->nbuf++); ++ return 0; ++} ++ ++static void ++mtk_tx_update_ipaddr(struct sk_buff *skb, ++ struct iphdr *iph, struct tcphdr *th, ++ __be32 *old_ip, __be32 new_ip) ++{ ++ if (*old_ip == new_ip) ++ return; ++ ++ inet_proto_csum_replace4(&th->check, skb, *old_ip, new_ip, true); ++ csum_replace4(&iph->check, *old_ip, new_ip); ++ *old_ip = new_ip; ++} ++ ++static void ++mtk_tx_update_ip6addr(struct sk_buff *skb, struct ipv6hdr *iph, ++ struct tcphdr *th, struct in6_addr *old_ip, ++ const struct in6_addr *new_ip) ++{ ++ if (ipv6_addr_equal(old_ip, new_ip)) ++ return; ++ ++ inet_proto_csum_replace16(&th->check, skb, old_ip->s6_addr32, ++ new_ip->s6_addr32, true); ++ *old_ip = *new_ip; ++} ++ ++static void ++mtk_tx_update_port(struct sk_buff *skb, struct tcphdr *th, ++ __be16 *old_port, __be16 new_port) ++{ ++ if (*old_port == new_port) ++ return; ++ ++ inet_proto_csum_replace2(&th->check, skb, *old_port, new_port, false); ++ *old_port = new_port; ++} ++ + static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, +- int tx_num, struct mtk_tx_ring *ring, bool gso) ++ int tx_num, struct mtk_tx_ring *ring, bool gso, ++ unsigned int header_len) + { +- struct mtk_tx_dma_desc_info txd_info = { +- .size = skb_headlen(skb), +- .gso = gso, +- .csum = skb->ip_summed == CHECKSUM_PARTIAL, +- .vlan = skb_vlan_tag_present(skb), +- .qid = skb_get_queue_mapping(skb), +- .vlan_tci = skb_vlan_tag_get(skb), +- .first = true, +- .last = !skb_is_nonlinear(skb), ++ struct mtk_tx_dma_desc_info txd_info; ++ struct mtk_tx_map_state state = { ++ .ndesc = 1, + }; + struct netdev_queue *txq; + struct mtk_mac *mac = netdev_priv(dev); + struct mtk_eth *eth = mac->hw; + const struct mtk_soc_data *soc = eth->soc; +- struct mtk_tx_dma *itxd, *txd; +- struct mtk_tx_dma *itxd_pdma, *txd_pdma; +- struct mtk_tx_buf *itx_buf, *tx_buf; +- int i, n_desc = 1; ++ struct mtk_tx_dma *itxd; ++ struct sk_buff *cur_skb, *next_skb; + int queue = skb_get_queue_mapping(skb); +- int k = 0; ++ int i, frag_size = skb_headlen(skb); ++ bool gso_v4, gso_fraglist; ++ int offset = 0; + + txq = netdev_get_tx_queue(dev, queue); + itxd = ring->next_free; +- itxd_pdma = qdma_to_pdma(ring, itxd); + if (itxd == ring->last_free) + return -ENOMEM; + +- itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_shift); +- memset(itx_buf, 0, sizeof(*itx_buf)); ++ cur_skb = skb; ++ next_skb = skb_shinfo(skb)->frag_list; ++ mtk_tx_map_set_txd(&state, ring, soc, itxd); ++ gso_v4 = skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4; ++ gso_fraglist = skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST; + +- txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size, +- DMA_TO_DEVICE); +- if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) +- return -ENOMEM; ++next: ++ txd_info = (struct mtk_tx_dma_desc_info){ ++ .gso = gso, ++ .qid = queue, ++ .csum = cur_skb->ip_summed == CHECKSUM_PARTIAL || gso, ++ .vlan = skb_vlan_tag_present(skb), ++ .vlan_tci = skb_vlan_tag_get(skb), ++ .first = true, ++ }; + +- mtk_tx_set_dma_desc(dev, itxd, &txd_info); ++ if (cur_skb != skb) { ++ struct tcphdr *th, *th2; + +- itx_buf->mac_id = mac->id; +- setup_tx_buf(eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size, +- k++); +- +- /* TX SG offload */ +- txd = itxd; +- txd_pdma = qdma_to_pdma(ring, txd); +- +- for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { +- skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; +- unsigned int offset = 0; +- int frag_size = skb_frag_size(frag); ++ if (skb_cow_head(cur_skb, header_len)) ++ goto err_dma; + +- while (frag_size) { +- bool new_desc = true; ++ memcpy(cur_skb->data - header_len, skb->data, ++ skb_network_offset(skb)); + +- if (MTK_HAS_CAPS(soc->caps, MTK_QDMA) || +- (i & 0x1)) { +- txd = mtk_qdma_phys_to_virt(ring, txd->txd2); +- txd_pdma = qdma_to_pdma(ring, txd); +- if (txd == ring->last_free) +- goto err_dma; ++ th = tcp_hdr(cur_skb); ++ th2 = tcp_hdr(skb); ++ if (gso_v4) { ++ struct iphdr *iph = ip_hdr(cur_skb); ++ struct iphdr *iph2 = ip_hdr(skb); ++ ++ mtk_tx_update_ipaddr(skb, iph, th, &iph->saddr, ++ iph2->saddr); ++ mtk_tx_update_ipaddr(skb, iph, th, &iph->daddr, ++ iph2->daddr); ++ } else { ++ struct ipv6hdr *iph = ipv6_hdr(cur_skb); ++ struct ipv6hdr *iph2 = ipv6_hdr(skb); + +- n_desc++; +- } else { +- new_desc = false; +- } ++ mtk_tx_update_ip6addr(skb, iph, th, &iph->saddr, ++ &iph2->saddr); ++ mtk_tx_update_ip6addr(skb, iph, th, &iph->daddr, ++ &iph2->daddr); ++ } ++ ++ mtk_tx_update_port(skb, th, &th->source, th2->source); ++ mtk_tx_update_port(skb, th, &th->dest, th2->dest); ++ ++ offset = -header_len; ++ frag_size += header_len; ++ } else if (next_skb && gso_fraglist) { ++ unsigned int ip_len = skb_pagelen(skb) - skb_network_offset(skb); ++ if (gso_v4) { ++ struct iphdr *iph = ip_hdr(cur_skb); ++ __be16 ip_len_val = cpu_to_be16(ip_len); + +- memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); ++ csum_replace2(&iph->check, iph->tot_len, ip_len_val); ++ iph->tot_len = ip_len_val; ++ } else { ++ struct ipv6hdr *iph = ipv6_hdr(cur_skb); ++ __be16 ip_len_val = cpu_to_be16(ip_len - sizeof(*iph)); ++ ++ iph->payload_len = ip_len_val; ++ } ++ } ++ ++next_frag: ++ while (frag_size) { ++ txd_info.size = min_t(unsigned int, frag_size, ++ soc->tx.dma_max_len); ++ txd_info.addr = dma_map_single(eth->dma_dev, cur_skb->data + offset, ++ txd_info.size, DMA_TO_DEVICE); ++ if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) ++ goto err_dma; ++ ++ frag_size -= txd_info.size; ++ offset += txd_info.size; ++ txd_info.last = !frag_size && !skb_shinfo(cur_skb)->nr_frags && ++ (gso_fraglist || !next_skb); ++ if (mtk_tx_map_info(eth, ring, dev, &state, &txd_info) < 0) ++ goto err_dma; ++ } ++ ++ for (i = 0; i < skb_shinfo(cur_skb)->nr_frags; i++) { ++ skb_frag_t *frag = &skb_shinfo(cur_skb)->frags[i]; ++ ++ frag_size = skb_frag_size(frag); ++ memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); ++ txd_info.qid = queue; ++ offset = 0; ++ while (frag_size) { + txd_info.size = min_t(unsigned int, frag_size, + soc->tx.dma_max_len); +- txd_info.qid = queue; +- txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 && +- !(frag_size - txd_info.size); +- txd_info.addr = skb_frag_dma_map(eth->dma_dev, frag, +- offset, txd_info.size, +- DMA_TO_DEVICE); ++ txd_info.addr = skb_frag_dma_map(eth->dma_dev, frag, offset, ++ txd_info.size, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) + goto err_dma; + +- mtk_tx_set_dma_desc(dev, txd, &txd_info); +- +- tx_buf = mtk_desc_to_tx_buf(ring, txd, +- soc->tx.desc_shift); +- if (new_desc) +- memset(tx_buf, 0, sizeof(*tx_buf)); +- tx_buf->data = (void *)MTK_DMA_DUMMY_DESC; +- tx_buf->mac_id = mac->id; +- +- setup_tx_buf(eth, tx_buf, txd_pdma, txd_info.addr, +- txd_info.size, k++); +- + frag_size -= txd_info.size; + offset += txd_info.size; ++ txd_info.last = i == skb_shinfo(cur_skb)->nr_frags - 1 && ++ !frag_size && (gso_fraglist || !next_skb); ++ if (mtk_tx_map_info(eth, ring, dev, &state, &txd_info) < 0) ++ goto err_dma; + } + } + +- /* store skb to cleanup */ +- itx_buf->type = MTK_TYPE_SKB; +- itx_buf->data = skb; ++ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA) && ++ (gso_fraglist || !next_skb)) { ++ if (state.nbuf & 0x1) { ++ state.txd_pdma->txd2 |= TX_DMA_LS0; ++ state.nbuf++; ++ } else { ++ state.txd_pdma->txd2 |= TX_DMA_LS1; ++ } ++ } ++ ++ if (next_skb) { ++ cur_skb = next_skb; ++ next_skb = cur_skb->next; ++ offset = 0; ++ frag_size = skb_headlen(cur_skb); ++ if (!gso_fraglist) ++ goto next_frag; + +- if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { +- if (k & 0x1) +- txd_pdma->txd2 |= TX_DMA_LS0; +- else +- txd_pdma->txd2 |= TX_DMA_LS1; ++ goto next; + } + ++ /* store skb to cleanup */ ++ state.tx_buf->type = MTK_TYPE_SKB; ++ state.tx_buf->data = skb; ++ + netdev_tx_sent_queue(txq, skb->len); + skb_tx_timestamp(skb); + +- ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2); +- atomic_sub(n_desc, &ring->free_count); ++ ring->next_free = mtk_qdma_phys_to_virt(ring, state.txd->txd2); ++ atomic_sub(state.ndesc, &ring->free_count); + + /* make sure that all changes to the dma ring are flushed before we + * continue +@@ -1525,11 +1660,11 @@ static int mtk_tx_map(struct sk_buff *sk + + if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { + if (netif_xmit_stopped(txq) || !netdev_xmit_more()) +- mtk_w32(eth, txd->txd2, soc->reg_map->qdma.ctx_ptr); ++ mtk_w32(eth, state.txd->txd2, soc->reg_map->qdma.ctx_ptr); + } else { + int next_idx; + +- next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->tx.desc_shift), ++ next_idx = NEXT_DESP_IDX(txd_to_idx(ring, state.txd, soc->tx.desc_shift), + ring->dma_size); + mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0); + } +@@ -1538,18 +1673,20 @@ static int mtk_tx_map(struct sk_buff *sk + + err_dma: + do { +- tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_shift); ++ struct mtk_tx_dma *itxd_pdma = qdma_to_pdma(ring, itxd); ++ struct mtk_tx_buf *itx_buf; ++ ++ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->tx.desc_shift); + + /* unmap dma */ +- mtk_tx_unmap(eth, tx_buf, NULL, false); ++ mtk_tx_unmap(eth, itx_buf, NULL, false); + + itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; + if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) + itxd_pdma->txd2 = TX_DMA_DESP2_DEF; + + itxd = mtk_qdma_phys_to_virt(ring, itxd->txd2); +- itxd_pdma = qdma_to_pdma(ring, itxd); +- } while (itxd != txd); ++ } while (itxd != state.txd); + + return -ENOMEM; + } +@@ -1569,6 +1706,9 @@ static int mtk_cal_txd_req(struct mtk_et + nfrags += skb_shinfo(skb)->nr_frags; + } + ++ for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) ++ nfrags += mtk_cal_txd_req(eth, skb) + 1; ++ + return nfrags; + } + +@@ -1609,9 +1749,29 @@ static bool mtk_skb_has_small_frag(struc + if (skb_frag_size(&skb_shinfo(skb)->frags[i]) < min_size) + return true; + ++ for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) ++ if (mtk_skb_has_small_frag(skb)) ++ return true; ++ + return false; + } + ++static bool mtk_skb_valid_gso(struct mtk_eth *eth, struct sk_buff *skb, ++ unsigned int header_len) ++{ ++ if (mtk_is_netsys_v1(eth) && mtk_skb_has_small_frag(skb)) ++ return false; ++ ++ if (!(skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST)) ++ return true; ++ ++ if (skb->encapsulation) ++ return false; ++ ++ return skb_pagelen(skb) - header_len == skb_shinfo(skb)->gso_size && ++ skb_headlen(skb) > header_len; ++} ++ + static netdev_tx_t mtk_start_xmit(struct sk_buff *skb, struct net_device *dev) + { + struct mtk_mac *mac = netdev_priv(dev); +@@ -1619,6 +1779,7 @@ static netdev_tx_t mtk_start_xmit(struct + struct mtk_tx_ring *ring = ð->tx_ring; + struct net_device_stats *stats = &dev->stats; + struct sk_buff *segs, *next; ++ unsigned int header_len = 0; + bool gso = false; + int tx_num; + +@@ -1647,37 +1808,42 @@ static netdev_tx_t mtk_start_xmit(struct + return NETDEV_TX_BUSY; + } + +- if (mtk_is_netsys_v1(eth) && +- skb_is_gso(skb) && mtk_skb_has_small_frag(skb)) { +- segs = skb_gso_segment(skb, dev->features & ~NETIF_F_ALL_TSO); +- if (IS_ERR(segs)) +- goto drop; +- +- if (segs) { +- consume_skb(skb); +- skb = segs; +- } +- } +- +- /* TSO: fill MSS info in tcp checksum field */ + if (skb_is_gso(skb)) { +- if (skb_cow_head(skb, 0)) { +- netif_warn(eth, tx_err, dev, +- "GSO expand head fail.\n"); +- goto drop; ++ header_len = skb_tcp_all_headers(skb); ++ if (!mtk_skb_valid_gso(eth, skb, header_len)) { ++ segs = skb_gso_segment(skb, dev->features & ~NETIF_F_ALL_TSO); ++ if (IS_ERR(segs)) ++ goto drop; ++ ++ if (segs) { ++ consume_skb(skb); ++ skb = segs; ++ } ++ goto send; + } + ++ if ((skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST)) ++ goto send; ++ + if (skb_shinfo(skb)->gso_type & + (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { ++ /* TSO: fill MSS info in tcp checksum field */ + gso = true; ++ if (skb_cow_head(skb, 0)) { ++ netif_warn(eth, tx_err, dev, ++ "GSO expand head fail.\n"); ++ goto drop; ++ } ++ + tcp_hdr(skb)->check = htons(skb_shinfo(skb)->gso_size); + } + } + ++send: + skb_list_walk_safe(skb, skb, next) { + if ((mtk_is_netsys_v1(eth) && + mtk_skb_has_small_frag(skb) && skb_linearize(skb)) || +- mtk_tx_map(skb, dev, tx_num, ring, gso) < 0) { ++ mtk_tx_map(skb, dev, tx_num, ring, gso, header_len) < 0) { + stats->tx_dropped++; + dev_kfree_skb_any(skb); + } +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -51,6 +51,8 @@ + NETIF_F_HW_VLAN_CTAG_TX | \ + NETIF_F_SG | NETIF_F_TSO | \ + NETIF_F_TSO6 | \ ++ NETIF_F_FRAGLIST | \ ++ NETIF_F_GSO_FRAGLIST | \ + NETIF_F_IPV6_CSUM |\ + NETIF_F_HW_TC) + #define MTK_HW_FEATURES_MT7628 (NETIF_F_SG | NETIF_F_RXCSUM) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/733-01-net-ethernet-mtk_eth_soc-use-napi_build_skb.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/733-01-net-ethernet-mtk_eth_soc-use-napi_build_skb.patch new file mode 100755 index 0000000..f87315a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/733-01-net-ethernet-mtk_eth_soc-use-napi_build_skb.patch @@ -0,0 +1,30 @@ +From: Felix Fietkau +Date: Mon, 20 May 2024 14:29:58 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: use napi_build_skb() + +The napi_build_skb() can reuse the skb in skb cache per CPU or +can allocate skbs in bulk, which helps improve the performance. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -2312,7 +2312,7 @@ static int mtk_poll_rx(struct napi_struc + if (ret != XDP_PASS) + goto skip_rx; + +- skb = build_skb(data, PAGE_SIZE); ++ skb = napi_build_skb(data, PAGE_SIZE); + if (unlikely(!skb)) { + page_pool_put_full_page(ring->page_pool, + page, true); +@@ -2350,7 +2350,7 @@ static int mtk_poll_rx(struct napi_struc + dma_unmap_single(eth->dma_dev, ((u64)trxd.rxd1 | addr64), + ring->buf_size, DMA_FROM_DEVICE); + +- skb = build_skb(data, ring->frag_size); ++ skb = napi_build_skb(data, ring->frag_size); + if (unlikely(!skb)) { + netdev->stats.rx_dropped++; + skb_free_frag(data); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/734-net-ethernet-mediatek-enlarge-DMA-reserve-buffer.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/734-net-ethernet-mediatek-enlarge-DMA-reserve-buffer.patch new file mode 100755 index 0000000..8d0f0b9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/734-net-ethernet-mediatek-enlarge-DMA-reserve-buffer.patch @@ -0,0 +1,44 @@ +From: Chad Monroe +Date: Mon, 16 Sep 2024 19:29:03 -0700 +Subject: [PATCH] net: ethernet: mediatek: increase QDMA RESV_BUF size + +Increase QDMA RESV_BUF from 2K to 3K for netsys v2 to match Mediatek SDK[1]. +This helps reduce the possibility of Ethernet transmit timeouts. + +[1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/19d8456c3051e5f6dabf42fa770916a2126ea4bf + +Signed-off-by: Chad Monroe +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++-- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + + 2 files changed, 5 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -282,6 +282,7 @@ + #define MTK_WCOMP_EN BIT(24) + #define MTK_RESV_BUF (0x80 << 16) + #define MTK_MUTLI_CNT (0x4 << 12) ++#define MTK_RESV_BUF_MASK (0xff << 16) + #define MTK_LEAKY_BUCKET_EN BIT(11) + + /* QDMA Flow Control Register */ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -3483,12 +3483,14 @@ static int mtk_start_dma(struct mtk_eth + MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO | + MTK_RX_2B_OFFSET | MTK_TX_WB_DDONE; + +- if (mtk_is_netsys_v2_or_greater(eth)) ++ if (mtk_is_netsys_v2_or_greater(eth)) { ++ val &= ~MTK_RESV_BUF_MASK; + val |= MTK_MUTLI_CNT | MTK_RESV_BUF | + MTK_WCOMP_EN | MTK_DMAD_WR_WDONE | + MTK_CHK_DDONE_EN; +- else ++ } else { + val |= MTK_RX_BT_32DWORDS; ++ } + mtk_w32(eth, val, reg_map->qdma.glo_cfg); + + mtk_w32(eth, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-03-net-ethernet-mtk_eth_soc-improve-keeping-track-of-of.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-03-net-ethernet-mtk_eth_soc-improve-keeping-track-of-of.patch new file mode 100755 index 0000000..c503483 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-03-net-ethernet-mtk_eth_soc-improve-keeping-track-of-of.patch @@ -0,0 +1,334 @@ +From: Felix Fietkau +Date: Thu, 23 Mar 2023 10:24:11 +0100 +Subject: [PATCH] net: ethernet: mtk_eth_soc: improve keeping track of + offloaded flows + +Unify tracking of L2 and L3 flows. Use the generic list field in struct +mtk_foe_entry for tracking L2 subflows. Preparation for improving +flow accounting support. + +Signed-off-by: Felix Fietkau +--- + drivers/net/ethernet/mediatek/mtk_ppe.c | 162 ++++++++++++------------ + drivers/net/ethernet/mediatek/mtk_ppe.h | 15 +-- + 2 files changed, 86 insertions(+), 91 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_ppe.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.c +@@ -479,42 +479,43 @@ int mtk_foe_entry_set_queue(struct mtk_e + return 0; + } + ++static int ++mtk_flow_entry_match_len(struct mtk_eth *eth, struct mtk_foe_entry *entry) ++{ ++ int type = mtk_get_ib1_pkt_type(eth, entry->ib1); ++ ++ if (type > MTK_PPE_PKT_TYPE_IPV4_DSLITE) ++ return offsetof(struct mtk_foe_entry, ipv6._rsv); ++ else ++ return offsetof(struct mtk_foe_entry, ipv4.ib2); ++} ++ + static bool + mtk_flow_entry_match(struct mtk_eth *eth, struct mtk_flow_entry *entry, +- struct mtk_foe_entry *data) ++ struct mtk_foe_entry *data, int len) + { +- int type, len; +- + if ((data->ib1 ^ entry->data.ib1) & MTK_FOE_IB1_UDP) + return false; + +- type = mtk_get_ib1_pkt_type(eth, entry->data.ib1); +- if (type > MTK_PPE_PKT_TYPE_IPV4_DSLITE) +- len = offsetof(struct mtk_foe_entry, ipv6._rsv); +- else +- len = offsetof(struct mtk_foe_entry, ipv4.ib2); +- + return !memcmp(&entry->data.data, &data->data, len - 4); + } + + static void +-__mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) ++__mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry, ++ bool set_state) + { +- struct hlist_head *head; + struct hlist_node *tmp; + + if (entry->type == MTK_FLOW_TYPE_L2) { + rhashtable_remove_fast(&ppe->l2_flows, &entry->l2_node, + mtk_flow_l2_ht_params); + +- head = &entry->l2_flows; +- hlist_for_each_entry_safe(entry, tmp, head, l2_data.list) +- __mtk_foe_entry_clear(ppe, entry); ++ hlist_for_each_entry_safe(entry, tmp, &entry->l2_flows, l2_list) ++ __mtk_foe_entry_clear(ppe, entry, set_state); + return; + } + +- hlist_del_init(&entry->list); +- if (entry->hash != 0xffff) { ++ if (entry->hash != 0xffff && set_state) { + struct mtk_foe_entry *hwe = mtk_foe_get_entry(ppe, entry->hash); + + hwe->ib1 &= ~MTK_FOE_IB1_STATE; +@@ -535,7 +536,8 @@ __mtk_foe_entry_clear(struct mtk_ppe *pp + if (entry->type != MTK_FLOW_TYPE_L2_SUBFLOW) + return; + +- hlist_del_init(&entry->l2_data.list); ++ hlist_del_init(&entry->l2_list); ++ hlist_del_init(&entry->list); + kfree(entry); + } + +@@ -551,66 +553,55 @@ static int __mtk_foe_entry_idle_time(str + return now - timestamp; + } + ++static bool ++mtk_flow_entry_update(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) ++{ ++ struct mtk_foe_entry foe = {}; ++ struct mtk_foe_entry *hwe; ++ u16 hash = entry->hash; ++ int len; ++ ++ if (hash == 0xffff) ++ return false; ++ ++ hwe = mtk_foe_get_entry(ppe, hash); ++ len = mtk_flow_entry_match_len(ppe->eth, &entry->data); ++ memcpy(&foe, hwe, len); ++ ++ if (!mtk_flow_entry_match(ppe->eth, entry, &foe, len) || ++ FIELD_GET(MTK_FOE_IB1_STATE, foe.ib1) != MTK_FOE_STATE_BIND) ++ return false; ++ ++ entry->data.ib1 = foe.ib1; ++ ++ return true; ++} ++ + static void + mtk_flow_entry_update_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) + { + u32 ib1_ts_mask = mtk_get_ib1_ts_mask(ppe->eth); + struct mtk_flow_entry *cur; +- struct mtk_foe_entry *hwe; + struct hlist_node *tmp; + int idle; + + idle = __mtk_foe_entry_idle_time(ppe, entry->data.ib1); +- hlist_for_each_entry_safe(cur, tmp, &entry->l2_flows, l2_data.list) { ++ hlist_for_each_entry_safe(cur, tmp, &entry->l2_flows, l2_list) { + int cur_idle; +- u32 ib1; +- +- hwe = mtk_foe_get_entry(ppe, cur->hash); +- ib1 = READ_ONCE(hwe->ib1); + +- if (FIELD_GET(MTK_FOE_IB1_STATE, ib1) != MTK_FOE_STATE_BIND) { +- cur->hash = 0xffff; +- __mtk_foe_entry_clear(ppe, cur); ++ if (!mtk_flow_entry_update(ppe, cur)) { ++ __mtk_foe_entry_clear(ppe, entry, false); + continue; + } + +- cur_idle = __mtk_foe_entry_idle_time(ppe, ib1); ++ cur_idle = __mtk_foe_entry_idle_time(ppe, cur->data.ib1); + if (cur_idle >= idle) + continue; + + idle = cur_idle; + entry->data.ib1 &= ~ib1_ts_mask; +- entry->data.ib1 |= ib1 & ib1_ts_mask; +- } +-} +- +-static void +-mtk_flow_entry_update(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) +-{ +- struct mtk_foe_entry foe = {}; +- struct mtk_foe_entry *hwe; +- +- spin_lock_bh(&ppe_lock); +- +- if (entry->type == MTK_FLOW_TYPE_L2) { +- mtk_flow_entry_update_l2(ppe, entry); +- goto out; ++ entry->data.ib1 |= cur->data.ib1 & ib1_ts_mask; + } +- +- if (entry->hash == 0xffff) +- goto out; +- +- hwe = mtk_foe_get_entry(ppe, entry->hash); +- memcpy(&foe, hwe, ppe->eth->soc->foe_entry_size); +- if (!mtk_flow_entry_match(ppe->eth, entry, &foe)) { +- entry->hash = 0xffff; +- goto out; +- } +- +- entry->data.ib1 = foe.ib1; +- +-out: +- spin_unlock_bh(&ppe_lock); + } + + static void +@@ -653,7 +644,8 @@ __mtk_foe_entry_commit(struct mtk_ppe *p + void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) + { + spin_lock_bh(&ppe_lock); +- __mtk_foe_entry_clear(ppe, entry); ++ __mtk_foe_entry_clear(ppe, entry, true); ++ hlist_del_init(&entry->list); + spin_unlock_bh(&ppe_lock); + } + +@@ -700,8 +692,8 @@ mtk_foe_entry_commit_subflow(struct mtk_ + { + const struct mtk_soc_data *soc = ppe->eth->soc; + struct mtk_flow_entry *flow_info; +- struct mtk_foe_entry foe = {}, *hwe; + struct mtk_foe_mac_info *l2; ++ struct mtk_foe_entry *hwe; + u32 ib1_mask = mtk_get_ib1_pkt_type_mask(ppe->eth) | MTK_FOE_IB1_UDP; + int type; + +@@ -709,30 +701,30 @@ mtk_foe_entry_commit_subflow(struct mtk_ + if (!flow_info) + return; + +- flow_info->l2_data.base_flow = entry; + flow_info->type = MTK_FLOW_TYPE_L2_SUBFLOW; + flow_info->hash = hash; + hlist_add_head(&flow_info->list, + &ppe->foe_flow[hash / soc->hash_offset]); +- hlist_add_head(&flow_info->l2_data.list, &entry->l2_flows); ++ hlist_add_head(&flow_info->l2_list, &entry->l2_flows); + + hwe = mtk_foe_get_entry(ppe, hash); +- memcpy(&foe, hwe, soc->foe_entry_size); +- foe.ib1 &= ib1_mask; +- foe.ib1 |= entry->data.ib1 & ~ib1_mask; ++ memcpy(&flow_info->data, hwe, soc->foe_entry_size); ++ flow_info->data.ib1 &= ib1_mask; ++ flow_info->data.ib1 |= entry->data.ib1 & ~ib1_mask; + +- l2 = mtk_foe_entry_l2(ppe->eth, &foe); ++ l2 = mtk_foe_entry_l2(ppe->eth, &flow_info->data); + memcpy(l2, &entry->data.bridge.l2, sizeof(*l2)); + +- type = mtk_get_ib1_pkt_type(ppe->eth, foe.ib1); ++ type = mtk_get_ib1_pkt_type(ppe->eth, flow_info->data.ib1); + if (type == MTK_PPE_PKT_TYPE_IPV4_HNAPT) +- memcpy(&foe.ipv4.new, &foe.ipv4.orig, sizeof(foe.ipv4.new)); ++ memcpy(&flow_info->data.ipv4.new, &flow_info->data.ipv4.orig, ++ sizeof(flow_info->data.ipv4.new)); + else if (type >= MTK_PPE_PKT_TYPE_IPV6_ROUTE_3T && l2->etype == ETH_P_IP) + l2->etype = ETH_P_IPV6; + +- *mtk_foe_entry_ib2(ppe->eth, &foe) = entry->data.bridge.ib2; ++ *mtk_foe_entry_ib2(ppe->eth, &flow_info->data) = entry->data.bridge.ib2; + +- __mtk_foe_entry_commit(ppe, &foe, hash); ++ __mtk_foe_entry_commit(ppe, &flow_info->data, hash); + } + + void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash) +@@ -742,9 +734,11 @@ void __mtk_ppe_check_skb(struct mtk_ppe + struct mtk_foe_entry *hwe = mtk_foe_get_entry(ppe, hash); + struct mtk_flow_entry *entry; + struct mtk_foe_bridge key = {}; ++ struct mtk_foe_entry foe = {}; + struct hlist_node *n; + struct ethhdr *eh; + bool found = false; ++ int entry_len; + u8 *tag; + + spin_lock_bh(&ppe_lock); +@@ -752,20 +746,14 @@ void __mtk_ppe_check_skb(struct mtk_ppe + if (FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == MTK_FOE_STATE_BIND) + goto out; + +- hlist_for_each_entry_safe(entry, n, head, list) { +- if (entry->type == MTK_FLOW_TYPE_L2_SUBFLOW) { +- if (unlikely(FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == +- MTK_FOE_STATE_BIND)) +- continue; +- +- entry->hash = 0xffff; +- __mtk_foe_entry_clear(ppe, entry); +- continue; +- } ++ entry_len = mtk_flow_entry_match_len(ppe->eth, hwe); ++ memcpy(&foe, hwe, entry_len); + +- if (found || !mtk_flow_entry_match(ppe->eth, entry, hwe)) { ++ hlist_for_each_entry_safe(entry, n, head, list) { ++ if (found || ++ !mtk_flow_entry_match(ppe->eth, entry, &foe, entry_len)) { + if (entry->hash != 0xffff) +- entry->hash = 0xffff; ++ __mtk_foe_entry_clear(ppe, entry, false); + continue; + } + +@@ -816,9 +804,17 @@ out: + + int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) + { +- mtk_flow_entry_update(ppe, entry); ++ int idle; ++ ++ spin_lock_bh(&ppe_lock); ++ if (entry->type == MTK_FLOW_TYPE_L2) ++ mtk_flow_entry_update_l2(ppe, entry); ++ else ++ mtk_flow_entry_update(ppe, entry); ++ idle = __mtk_foe_entry_idle_time(ppe, entry->data.ib1); ++ spin_unlock_bh(&ppe_lock); + +- return __mtk_foe_entry_idle_time(ppe, entry->data.ib1); ++ return idle; + } + + int mtk_ppe_prepare_reset(struct mtk_ppe *ppe) +--- a/drivers/net/ethernet/mediatek/mtk_ppe.h ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.h +@@ -286,7 +286,12 @@ enum { + + struct mtk_flow_entry { + union { +- struct hlist_node list; ++ /* regular flows + L2 subflows */ ++ struct { ++ struct hlist_node list; ++ struct hlist_node l2_list; ++ }; ++ /* L2 flows */ + struct { + struct rhash_head l2_node; + struct hlist_head l2_flows; +@@ -296,13 +301,7 @@ struct mtk_flow_entry { + s8 wed_index; + u8 ppe_index; + u16 hash; +- union { +- struct mtk_foe_entry data; +- struct { +- struct mtk_flow_entry *base_flow; +- struct hlist_node list; +- } l2_data; +- }; ++ struct mtk_foe_entry data; + struct rhash_head node; + unsigned long cookie; + }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-04-net-ethernet-mediatek-fix-ppe-flow-accounting-for-L2.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-04-net-ethernet-mediatek-fix-ppe-flow-accounting-for-L2.patch new file mode 100755 index 0000000..9141fa6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-04-net-ethernet-mediatek-fix-ppe-flow-accounting-for-L2.patch @@ -0,0 +1,343 @@ +From: Felix Fietkau +Date: Thu, 23 Mar 2023 11:05:22 +0100 +Subject: [PATCH] net: ethernet: mediatek: fix ppe flow accounting for L2 + flows + +For L2 flows, the packet/byte counters should report the sum of the +counters of their subflows, both current and expired. +In order to make this work, change the way that accounting data is tracked. +Reset counters when a flow enters bind. Once it expires (or enters unbind), +store the last counter value in struct mtk_flow_entry. + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_ppe.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.c +@@ -83,9 +83,9 @@ static int mtk_ppe_mib_wait_busy(struct + int ret; + u32 val; + +- ret = readl_poll_timeout(ppe->base + MTK_PPE_MIB_SER_CR, val, +- !(val & MTK_PPE_MIB_SER_CR_ST), +- 20, MTK_PPE_WAIT_TIMEOUT_US); ++ ret = readl_poll_timeout_atomic(ppe->base + MTK_PPE_MIB_SER_CR, val, ++ !(val & MTK_PPE_MIB_SER_CR_ST), ++ 20, MTK_PPE_WAIT_TIMEOUT_US); + + if (ret) + dev_err(ppe->dev, "MIB table busy"); +@@ -93,17 +93,31 @@ static int mtk_ppe_mib_wait_busy(struct + return ret; + } + +-static int mtk_mib_entry_read(struct mtk_ppe *ppe, u16 index, u64 *bytes, u64 *packets) ++static inline struct mtk_foe_accounting * ++mtk_ppe_acct_data(struct mtk_ppe *ppe, u16 index) ++{ ++ if (!ppe->acct_table) ++ return NULL; ++ ++ return ppe->acct_table + index * sizeof(struct mtk_foe_accounting); ++} ++ ++struct mtk_foe_accounting *mtk_ppe_mib_entry_read(struct mtk_ppe *ppe, u16 index) + { + u32 val, cnt_r0, cnt_r1, cnt_r2; ++ struct mtk_foe_accounting *acct; + int ret; + + val = FIELD_PREP(MTK_PPE_MIB_SER_CR_ADDR, index) | MTK_PPE_MIB_SER_CR_ST; + ppe_w32(ppe, MTK_PPE_MIB_SER_CR, val); + ++ acct = mtk_ppe_acct_data(ppe, index); ++ if (!acct) ++ return NULL; ++ + ret = mtk_ppe_mib_wait_busy(ppe); + if (ret) +- return ret; ++ return acct; + + cnt_r0 = readl(ppe->base + MTK_PPE_MIB_SER_R0); + cnt_r1 = readl(ppe->base + MTK_PPE_MIB_SER_R1); +@@ -112,19 +126,19 @@ static int mtk_mib_entry_read(struct mtk + if (mtk_is_netsys_v3_or_greater(ppe->eth)) { + /* 64 bit for each counter */ + u32 cnt_r3 = readl(ppe->base + MTK_PPE_MIB_SER_R3); +- *bytes = ((u64)cnt_r1 << 32) | cnt_r0; +- *packets = ((u64)cnt_r3 << 32) | cnt_r2; ++ acct->bytes += ((u64)cnt_r1 << 32) | cnt_r0; ++ acct->packets += ((u64)cnt_r3 << 32) | cnt_r2; + } else { + /* 48 bit byte counter, 40 bit packet counter */ + u32 byte_cnt_low = FIELD_GET(MTK_PPE_MIB_SER_R0_BYTE_CNT_LOW, cnt_r0); + u32 byte_cnt_high = FIELD_GET(MTK_PPE_MIB_SER_R1_BYTE_CNT_HIGH, cnt_r1); + u32 pkt_cnt_low = FIELD_GET(MTK_PPE_MIB_SER_R1_PKT_CNT_LOW, cnt_r1); + u32 pkt_cnt_high = FIELD_GET(MTK_PPE_MIB_SER_R2_PKT_CNT_HIGH, cnt_r2); +- *bytes = ((u64)byte_cnt_high << 32) | byte_cnt_low; +- *packets = ((u64)pkt_cnt_high << 16) | pkt_cnt_low; ++ acct->bytes += ((u64)byte_cnt_high << 32) | byte_cnt_low; ++ acct->packets += ((u64)pkt_cnt_high << 16) | pkt_cnt_low; + } + +- return 0; ++ return acct; + } + + static void mtk_ppe_cache_clear(struct mtk_ppe *ppe) +@@ -522,14 +536,6 @@ __mtk_foe_entry_clear(struct mtk_ppe *pp + hwe->ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE, MTK_FOE_STATE_INVALID); + dma_wmb(); + mtk_ppe_cache_clear(ppe); +- +- if (ppe->accounting) { +- struct mtk_foe_accounting *acct; +- +- acct = ppe->acct_table + entry->hash * sizeof(*acct); +- acct->packets = 0; +- acct->bytes = 0; +- } + } + entry->hash = 0xffff; + +@@ -554,11 +560,14 @@ static int __mtk_foe_entry_idle_time(str + } + + static bool +-mtk_flow_entry_update(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) ++mtk_flow_entry_update(struct mtk_ppe *ppe, struct mtk_flow_entry *entry, ++ u64 *packets, u64 *bytes) + { ++ struct mtk_foe_accounting *acct; + struct mtk_foe_entry foe = {}; + struct mtk_foe_entry *hwe; + u16 hash = entry->hash; ++ bool ret = false; + int len; + + if (hash == 0xffff) +@@ -569,18 +578,35 @@ mtk_flow_entry_update(struct mtk_ppe *pp + memcpy(&foe, hwe, len); + + if (!mtk_flow_entry_match(ppe->eth, entry, &foe, len) || +- FIELD_GET(MTK_FOE_IB1_STATE, foe.ib1) != MTK_FOE_STATE_BIND) +- return false; ++ FIELD_GET(MTK_FOE_IB1_STATE, foe.ib1) != MTK_FOE_STATE_BIND) { ++ acct = mtk_ppe_acct_data(ppe, hash); ++ if (acct) { ++ entry->prev_packets += acct->packets; ++ entry->prev_bytes += acct->bytes; ++ } ++ ++ goto out; ++ } + + entry->data.ib1 = foe.ib1; ++ acct = mtk_ppe_mib_entry_read(ppe, hash); ++ ret = true; ++ ++out: ++ if (acct) { ++ *packets += acct->packets; ++ *bytes += acct->bytes; ++ } + +- return true; ++ return ret; + } + + static void + mtk_flow_entry_update_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) + { + u32 ib1_ts_mask = mtk_get_ib1_ts_mask(ppe->eth); ++ u64 *packets = &entry->packets; ++ u64 *bytes = &entry->bytes; + struct mtk_flow_entry *cur; + struct hlist_node *tmp; + int idle; +@@ -589,7 +615,9 @@ mtk_flow_entry_update_l2(struct mtk_ppe + hlist_for_each_entry_safe(cur, tmp, &entry->l2_flows, l2_list) { + int cur_idle; + +- if (!mtk_flow_entry_update(ppe, cur)) { ++ if (!mtk_flow_entry_update(ppe, cur, packets, bytes)) { ++ entry->prev_packets += cur->prev_packets; ++ entry->prev_bytes += cur->prev_bytes; + __mtk_foe_entry_clear(ppe, entry, false); + continue; + } +@@ -604,10 +632,29 @@ mtk_flow_entry_update_l2(struct mtk_ppe + } + } + ++void mtk_foe_entry_get_stats(struct mtk_ppe *ppe, struct mtk_flow_entry *entry, ++ int *idle) ++{ ++ entry->packets = entry->prev_packets; ++ entry->bytes = entry->prev_bytes; ++ ++ spin_lock_bh(&ppe_lock); ++ ++ if (entry->type == MTK_FLOW_TYPE_L2) ++ mtk_flow_entry_update_l2(ppe, entry); ++ else ++ mtk_flow_entry_update(ppe, entry, &entry->packets, &entry->bytes); ++ ++ *idle = __mtk_foe_entry_idle_time(ppe, entry->data.ib1); ++ ++ spin_unlock_bh(&ppe_lock); ++} ++ + static void + __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, + u16 hash) + { ++ struct mtk_foe_accounting *acct; + struct mtk_eth *eth = ppe->eth; + u16 timestamp = mtk_eth_timestamp(eth); + struct mtk_foe_entry *hwe; +@@ -638,6 +685,12 @@ __mtk_foe_entry_commit(struct mtk_ppe *p + + dma_wmb(); + ++ acct = mtk_ppe_mib_entry_read(ppe, hash); ++ if (acct) { ++ acct->packets = 0; ++ acct->bytes = 0; ++ } ++ + mtk_ppe_cache_clear(ppe); + } + +@@ -802,21 +855,6 @@ out: + spin_unlock_bh(&ppe_lock); + } + +-int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) +-{ +- int idle; +- +- spin_lock_bh(&ppe_lock); +- if (entry->type == MTK_FLOW_TYPE_L2) +- mtk_flow_entry_update_l2(ppe, entry); +- else +- mtk_flow_entry_update(ppe, entry); +- idle = __mtk_foe_entry_idle_time(ppe, entry->data.ib1); +- spin_unlock_bh(&ppe_lock); +- +- return idle; +-} +- + int mtk_ppe_prepare_reset(struct mtk_ppe *ppe) + { + if (!ppe) +@@ -844,32 +882,6 @@ int mtk_ppe_prepare_reset(struct mtk_ppe + return mtk_ppe_wait_busy(ppe); + } + +-struct mtk_foe_accounting *mtk_foe_entry_get_mib(struct mtk_ppe *ppe, u32 index, +- struct mtk_foe_accounting *diff) +-{ +- struct mtk_foe_accounting *acct; +- int size = sizeof(struct mtk_foe_accounting); +- u64 bytes, packets; +- +- if (!ppe->accounting) +- return NULL; +- +- if (mtk_mib_entry_read(ppe, index, &bytes, &packets)) +- return NULL; +- +- acct = ppe->acct_table + index * size; +- +- acct->bytes += bytes; +- acct->packets += packets; +- +- if (diff) { +- diff->bytes = bytes; +- diff->packets = packets; +- } +- +- return acct; +-} +- + struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base, int index) + { + bool accounting = eth->soc->has_accounting; +--- a/drivers/net/ethernet/mediatek/mtk_ppe.h ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.h +@@ -304,6 +304,8 @@ struct mtk_flow_entry { + struct mtk_foe_entry data; + struct rhash_head node; + unsigned long cookie; ++ u64 prev_packets, prev_bytes; ++ u64 packets, bytes; + }; + + struct mtk_mib_entry { +@@ -348,6 +350,7 @@ void mtk_ppe_deinit(struct mtk_eth *eth) + void mtk_ppe_start(struct mtk_ppe *ppe); + int mtk_ppe_stop(struct mtk_ppe *ppe); + int mtk_ppe_prepare_reset(struct mtk_ppe *ppe); ++struct mtk_foe_accounting *mtk_ppe_mib_entry_read(struct mtk_ppe *ppe, u16 index); + + void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash); + +@@ -397,9 +400,8 @@ int mtk_foe_entry_set_queue(struct mtk_e + unsigned int queue); + int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); + void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); +-int mtk_foe_entry_idle_time(struct mtk_ppe *ppe, struct mtk_flow_entry *entry); + int mtk_ppe_debugfs_init(struct mtk_ppe *ppe, int index); +-struct mtk_foe_accounting *mtk_foe_entry_get_mib(struct mtk_ppe *ppe, u32 index, +- struct mtk_foe_accounting *diff); ++void mtk_foe_entry_get_stats(struct mtk_ppe *ppe, struct mtk_flow_entry *entry, ++ int *idle); + + #endif +--- a/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c +@@ -97,7 +97,7 @@ mtk_ppe_debugfs_foe_show(struct seq_file + if (bind && state != MTK_FOE_STATE_BIND) + continue; + +- acct = mtk_foe_entry_get_mib(ppe, i, NULL); ++ acct = mtk_ppe_mib_entry_read(ppe, i); + + type = mtk_get_ib1_pkt_type(ppe->eth, entry->ib1); + seq_printf(m, "%05x %s %7s", i, +--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c +@@ -522,24 +522,21 @@ static int + mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f) + { + struct mtk_flow_entry *entry; +- struct mtk_foe_accounting diff; +- u32 idle; ++ u64 packets, bytes; ++ int idle; + + entry = rhashtable_lookup(ð->flow_table, &f->cookie, + mtk_flow_ht_params); + if (!entry) + return -ENOENT; + +- idle = mtk_foe_entry_idle_time(eth->ppe[entry->ppe_index], entry); ++ packets = entry->packets; ++ bytes = entry->bytes; ++ mtk_foe_entry_get_stats(eth->ppe[entry->ppe_index], entry, &idle); ++ f->stats.pkts += entry->packets - packets; ++ f->stats.bytes += entry->bytes - bytes; + f->stats.lastused = jiffies - idle * HZ; + +- if (entry->hash != 0xFFFF && +- mtk_foe_entry_get_mib(eth->ppe[entry->ppe_index], entry->hash, +- &diff)) { +- f->stats.pkts += diff.packets; +- f->stats.bytes += diff.bytes; +- } +- + return 0; + } + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-05-net-ethernet-mtk_eth_soc-zero-initialize-PPE-flow-ta.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-05-net-ethernet-mtk_eth_soc-zero-initialize-PPE-flow-ta.patch new file mode 100755 index 0000000..2ca5ace --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/736-05-net-ethernet-mtk_eth_soc-zero-initialize-PPE-flow-ta.patch @@ -0,0 +1,27 @@ +From: Felix Fietkau +Date: Fri, 12 Sep 2025 14:18:14 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: zero initialize PPE flow table + +Avoid picking up flows from last boot or other invalid data + +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_ppe.c ++++ b/drivers/net/ethernet/mediatek/mtk_ppe.c +@@ -914,6 +914,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_ + if (!foe) + goto err_free_l2_flows; + ++ memset(foe, 0, MTK_PPE_ENTRIES * soc->foe_entry_size); + ppe->foe_table = foe; + + foe_flow_size = (MTK_PPE_ENTRIES / soc->hash_offset) * +@@ -928,6 +929,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_ + if (!mib) + return NULL; + ++ memset(mib, 0, MTK_PPE_ENTRIES * sizeof(*mib)); + ppe->mib_table = mib; + + acct = devm_kzalloc(dev, MTK_PPE_ENTRIES * sizeof(*acct), diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch new file mode 100755 index 0000000..93ceb98 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch @@ -0,0 +1,893 @@ +From d5e337e7aecc2e1cc9e96768062610adb95f8f72 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 12 Dec 2023 03:51:14 +0000 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add paths and SerDes modes for + MT7988 + +MT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to +connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R, +2500Base-X, 1000Base-X and Cisco SGMII interface modes. + +Implement support for configuring for the new paths to SerDes interfaces +and the internal 2.5G PHY. + +Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and +setup the new PHYA on MT7988 to access the also still existing old +LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII PCS interface +modes. + +Signed-off-by: Daniel Golle +--- + drivers/net/ethernet/mediatek/mtk_eth_path.c | 122 +++++++- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 292 +++++++++++++++++-- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 107 ++++++- + 3 files changed, 470 insertions(+), 51 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_path.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_path.c +@@ -31,10 +31,20 @@ static const char *mtk_eth_path_name(u64 + return "gmac2_rgmii"; + case MTK_ETH_PATH_GMAC2_SGMII: + return "gmac2_sgmii"; ++ case MTK_ETH_PATH_GMAC2_2P5GPHY: ++ return "gmac2_2p5gphy"; + case MTK_ETH_PATH_GMAC2_GEPHY: + return "gmac2_gephy"; ++ case MTK_ETH_PATH_GMAC3_SGMII: ++ return "gmac3_sgmii"; + case MTK_ETH_PATH_GDM1_ESW: + return "gdm1_esw"; ++ case MTK_ETH_PATH_GMAC1_USXGMII: ++ return "gmac1_usxgmii"; ++ case MTK_ETH_PATH_GMAC2_USXGMII: ++ return "gmac2_usxgmii"; ++ case MTK_ETH_PATH_GMAC3_USXGMII: ++ return "gmac3_usxgmii"; + default: + return "unknown path"; + } +@@ -127,6 +137,27 @@ static int set_mux_u3_gmac2_to_qphy(stru + return 0; + } + ++static int set_mux_gmac2_to_2p5gphy(struct mtk_eth *eth, u64 path) ++{ ++ int ret; ++ ++ if (path == MTK_ETH_PATH_GMAC2_2P5GPHY) { ++ ret = regmap_clear_bits(eth->ethsys, ETHSYS_SYSCFG0, SYSCFG0_SGMII_GMAC2_V2); ++ if (ret) ++ return ret; ++ ++ /* Setup mux to 2p5g PHY */ ++ ret = regmap_clear_bits(eth->infra, TOP_MISC_NETSYS_PCS_MUX, MUX_G2_USXGMII_SEL); ++ if (ret) ++ return ret; ++ ++ dev_dbg(eth->dev, "path %s in %s updated\n", ++ mtk_eth_path_name(path), __func__); ++ } ++ ++ return 0; ++} ++ + static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path) + { + unsigned int val = 0; +@@ -165,7 +196,48 @@ static int set_mux_gmac1_gmac2_to_sgmii_ + return 0; + } + +-static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path) ++static int set_mux_gmac123_to_usxgmii(struct mtk_eth *eth, u64 path) ++{ ++ unsigned int val = 0; ++ bool updated = true; ++ int mac_id = 0; ++ ++ /* Disable SYSCFG1 SGMII */ ++ regmap_read(eth->ethsys, ETHSYS_SYSCFG0, &val); ++ ++ switch (path) { ++ case MTK_ETH_PATH_GMAC1_USXGMII: ++ val &= ~(u32)SYSCFG0_SGMII_GMAC1_V2; ++ mac_id = MTK_GMAC1_ID; ++ break; ++ case MTK_ETH_PATH_GMAC2_USXGMII: ++ val &= ~(u32)SYSCFG0_SGMII_GMAC2_V2; ++ mac_id = MTK_GMAC2_ID; ++ break; ++ case MTK_ETH_PATH_GMAC3_USXGMII: ++ val &= ~(u32)SYSCFG0_SGMII_GMAC3_V2; ++ mac_id = MTK_GMAC3_ID; ++ break; ++ default: ++ updated = false; ++ }; ++ ++ if (updated) { ++ regmap_update_bits(eth->ethsys, ETHSYS_SYSCFG0, ++ SYSCFG0_SGMII_MASK, val); ++ ++ if (mac_id == MTK_GMAC2_ID) ++ regmap_set_bits(eth->infra, TOP_MISC_NETSYS_PCS_MUX, ++ MUX_G2_USXGMII_SEL); ++ } ++ ++ dev_dbg(eth->dev, "path %s in %s updated = %d\n", ++ mtk_eth_path_name(path), __func__, updated); ++ ++ return 0; ++} ++ ++static int set_mux_gmac123_to_gephy_sgmii(struct mtk_eth *eth, u64 path) + { + unsigned int val = 0; + bool updated = true; +@@ -182,6 +254,9 @@ static int set_mux_gmac12_to_gephy_sgmii + case MTK_ETH_PATH_GMAC2_SGMII: + val |= SYSCFG0_SGMII_GMAC2_V2; + break; ++ case MTK_ETH_PATH_GMAC3_SGMII: ++ val |= SYSCFG0_SGMII_GMAC3_V2; ++ break; + default: + updated = false; + } +@@ -210,13 +285,25 @@ static const struct mtk_eth_muxc mtk_eth + .cap_bit = MTK_ETH_MUX_U3_GMAC2_TO_QPHY, + .set_path = set_mux_u3_gmac2_to_qphy, + }, { ++ .name = "mux_gmac2_to_2p5gphy", ++ .cap_bit = MTK_ETH_MUX_GMAC2_TO_2P5GPHY, ++ .set_path = set_mux_gmac2_to_2p5gphy, ++ }, { + .name = "mux_gmac1_gmac2_to_sgmii_rgmii", + .cap_bit = MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII, + .set_path = set_mux_gmac1_gmac2_to_sgmii_rgmii, + }, { + .name = "mux_gmac12_to_gephy_sgmii", + .cap_bit = MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII, +- .set_path = set_mux_gmac12_to_gephy_sgmii, ++ .set_path = set_mux_gmac123_to_gephy_sgmii, ++ }, { ++ .name = "mux_gmac123_to_gephy_sgmii", ++ .cap_bit = MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII, ++ .set_path = set_mux_gmac123_to_gephy_sgmii, ++ }, { ++ .name = "mux_gmac123_to_usxgmii", ++ .cap_bit = MTK_ETH_MUX_GMAC123_TO_USXGMII, ++ .set_path = set_mux_gmac123_to_usxgmii, + }, + }; + +@@ -249,12 +336,39 @@ out: + return err; + } + ++int mtk_gmac_usxgmii_path_setup(struct mtk_eth *eth, int mac_id) ++{ ++ u64 path; ++ ++ path = (mac_id == MTK_GMAC1_ID) ? MTK_ETH_PATH_GMAC1_USXGMII : ++ (mac_id == MTK_GMAC2_ID) ? MTK_ETH_PATH_GMAC2_USXGMII : ++ MTK_ETH_PATH_GMAC3_USXGMII; ++ ++ /* Setup proper MUXes along the path */ ++ return mtk_eth_mux_setup(eth, path); ++} ++ + int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id) + { + u64 path; + +- path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_SGMII : +- MTK_ETH_PATH_GMAC2_SGMII; ++ path = (mac_id == MTK_GMAC1_ID) ? MTK_ETH_PATH_GMAC1_SGMII : ++ (mac_id == MTK_GMAC2_ID) ? MTK_ETH_PATH_GMAC2_SGMII : ++ MTK_ETH_PATH_GMAC3_SGMII; ++ ++ /* Setup proper MUXes along the path */ ++ return mtk_eth_mux_setup(eth, path); ++} ++ ++int mtk_gmac_2p5gphy_path_setup(struct mtk_eth *eth, int mac_id) ++{ ++ u64 path = 0; ++ ++ if (mac_id == MTK_GMAC2_ID) ++ path = MTK_ETH_PATH_GMAC2_2P5GPHY; ++ ++ if (!path) ++ return -EINVAL; + + /* Setup proper MUXes along the path */ + return mtk_eth_mux_setup(eth, path); +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -24,6 +24,8 @@ + #include + #include + #include ++#include ++#include + #include + #include + #include +@@ -522,6 +524,30 @@ static void mtk_setup_bridge_switch(stru + MTK_GSW_CFG); + } + ++static bool mtk_check_gmac23_idle(struct mtk_mac *mac) ++{ ++ u32 mac_fsm, gdm_fsm; ++ ++ mac_fsm = mtk_r32(mac->hw, MTK_MAC_FSM(mac->id)); ++ ++ switch (mac->id) { ++ case MTK_GMAC2_ID: ++ gdm_fsm = mtk_r32(mac->hw, MTK_FE_GDM2_FSM); ++ break; ++ case MTK_GMAC3_ID: ++ gdm_fsm = mtk_r32(mac->hw, MTK_FE_GDM3_FSM); ++ break; ++ default: ++ return true; ++ }; ++ ++ if ((mac_fsm & 0xFFFF0000) == 0x01010000 && ++ (gdm_fsm & 0xFFFF0000) == 0x00000000) ++ return true; ++ ++ return false; ++} ++ + static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config, + phy_interface_t interface) + { +@@ -530,6 +556,21 @@ static struct phylink_pcs *mtk_mac_selec + struct mtk_eth *eth = mac->hw; + unsigned int sid; + ++ if (mtk_is_netsys_v3_or_greater(eth)) { ++ switch (interface) { ++ case PHY_INTERFACE_MODE_1000BASEX: ++ case PHY_INTERFACE_MODE_2500BASEX: ++ case PHY_INTERFACE_MODE_SGMII: ++ return mac->sgmii_pcs; ++ case PHY_INTERFACE_MODE_5GBASER: ++ case PHY_INTERFACE_MODE_10GBASER: ++ case PHY_INTERFACE_MODE_USXGMII: ++ return mac->usxgmii_pcs; ++ default: ++ return NULL; ++ } ++ } ++ + if (interface == PHY_INTERFACE_MODE_SGMII || + phy_interface_mode_is_8023z(interface)) { + sid = (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_SGMII)) ? +@@ -581,7 +622,22 @@ static void mtk_mac_config(struct phylin + goto init_err; + } + break; ++ case PHY_INTERFACE_MODE_USXGMII: ++ case PHY_INTERFACE_MODE_10GBASER: ++ case PHY_INTERFACE_MODE_5GBASER: ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_USXGMII)) { ++ err = mtk_gmac_usxgmii_path_setup(eth, mac->id); ++ if (err) ++ goto init_err; ++ } ++ break; + case PHY_INTERFACE_MODE_INTERNAL: ++ if (mac->id == MTK_GMAC2_ID && ++ MTK_HAS_CAPS(eth->soc->caps, MTK_2P5GPHY)) { ++ err = mtk_gmac_2p5gphy_path_setup(eth, mac->id); ++ if (err) ++ goto init_err; ++ } + break; + default: + goto err_phy; +@@ -628,8 +684,6 @@ static void mtk_mac_config(struct phylin + val &= ~SYSCFG0_GE_MODE(SYSCFG0_GE_MASK, mac->id); + val |= SYSCFG0_GE_MODE(ge_mode, mac->id); + regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val); +- +- mac->interface = state->interface; + } + + /* SGMII */ +@@ -646,21 +700,40 @@ static void mtk_mac_config(struct phylin + + /* Save the syscfg0 value for mac_finish */ + mac->syscfg0 = val; +- } else if (phylink_autoneg_inband(mode)) { ++ } else if (state->interface != PHY_INTERFACE_MODE_USXGMII && ++ state->interface != PHY_INTERFACE_MODE_10GBASER && ++ state->interface != PHY_INTERFACE_MODE_5GBASER && ++ phylink_autoneg_inband(mode)) { + dev_err(eth->dev, +- "In-band mode not supported in non SGMII mode!\n"); ++ "In-band mode not supported in non-SerDes modes!\n"); + return; + } + + /* Setup gmac */ +- if (mtk_is_netsys_v3_or_greater(eth) && +- mac->interface == PHY_INTERFACE_MODE_INTERNAL) { +- mtk_w32(mac->hw, MTK_GDMA_XGDM_SEL, MTK_GDMA_EG_CTRL(mac->id)); +- mtk_w32(mac->hw, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(mac->id)); ++ if (mtk_is_netsys_v3_or_greater(eth)) { ++ if (mtk_interface_mode_is_xgmii(state->interface)) { ++ mtk_w32(mac->hw, MTK_GDMA_XGDM_SEL, MTK_GDMA_EG_CTRL(mac->id)); ++ mtk_w32(mac->hw, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(mac->id)); ++ ++ if (mac->id == MTK_GMAC1_ID) ++ mtk_setup_bridge_switch(eth); ++ } else { ++ mtk_w32(eth, 0, MTK_GDMA_EG_CTRL(mac->id)); + +- mtk_setup_bridge_switch(eth); ++ /* FIXME: In current hardware design, we have to reset FE ++ * when swtiching XGDM to GDM. Therefore, here trigger an SER ++ * to let GDM go back to the initial state. ++ */ ++ if ((mtk_interface_mode_is_xgmii(mac->interface) || ++ mac->interface == PHY_INTERFACE_MODE_NA) && ++ !mtk_check_gmac23_idle(mac) && ++ !test_bit(MTK_RESETTING, ð->state)) ++ schedule_work(ð->pending_work); ++ } + } + ++ mac->interface = state->interface; ++ + return; + + err_phy: +@@ -673,6 +746,18 @@ init_err: + mac->id, phy_modes(state->interface), err); + } + ++static int mtk_mac_prepare(struct phylink_config *config, unsigned int mode, ++ phy_interface_t interface) ++{ ++ struct mtk_mac *mac = container_of(config, struct mtk_mac, ++ phylink_config); ++ ++ if (mac->pextp && mac->interface != interface) ++ phy_reset(mac->pextp); ++ ++ return 0; ++} ++ + static int mtk_mac_finish(struct phylink_config *config, unsigned int mode, + phy_interface_t interface) + { +@@ -681,6 +766,10 @@ static int mtk_mac_finish(struct phylink + struct mtk_eth *eth = mac->hw; + u32 mcr_cur, mcr_new; + ++ /* Setup PMA/PMD */ ++ if (mac->pextp) ++ phy_set_mode_ext(mac->pextp, PHY_MODE_ETHERNET, interface); ++ + /* Enable SGMII */ + if (interface == PHY_INTERFACE_MODE_SGMII || + phy_interface_mode_is_8023z(interface)) +@@ -705,10 +794,14 @@ static void mtk_mac_link_down(struct phy + { + struct mtk_mac *mac = container_of(config, struct mtk_mac, + phylink_config); +- u32 mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); + +- mcr &= ~(MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK); +- mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); ++ if (!mtk_interface_mode_is_xgmii(interface)) { ++ mtk_m32(mac->hw, MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK, 0, MTK_MAC_MCR(mac->id)); ++ if (mtk_is_netsys_v3_or_greater(mac->hw)) ++ mtk_m32(mac->hw, MTK_XGMAC_FORCE_LINK(mac->id), 0, MTK_XGMAC_STS(mac->id)); ++ } else if (mtk_is_netsys_v3_or_greater(mac->hw) && mac->id != MTK_GMAC1_ID) { ++ mtk_m32(mac->hw, XMAC_MCR_TRX_DISABLE, XMAC_MCR_TRX_DISABLE, MTK_XMAC_MCR(mac->id)); ++ } + } + + static void mtk_set_queue_speed(struct mtk_eth *eth, unsigned int idx, +@@ -780,13 +873,11 @@ static void mtk_set_queue_speed(struct m + mtk_w32(eth, val, soc->reg_map->qdma.qtx_sch + ofs); + } + +-static void mtk_mac_link_up(struct phylink_config *config, +- struct phy_device *phy, +- unsigned int mode, phy_interface_t interface, +- int speed, int duplex, bool tx_pause, bool rx_pause) ++static void mtk_gdm_mac_link_up(struct mtk_mac *mac, ++ struct phy_device *phy, ++ unsigned int mode, phy_interface_t interface, ++ int speed, int duplex, bool tx_pause, bool rx_pause) + { +- struct mtk_mac *mac = container_of(config, struct mtk_mac, +- phylink_config); + u32 mcr; + + mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id)); +@@ -830,9 +921,63 @@ static void mtk_mac_link_up(struct phyli + mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); + } + ++static void mtk_xgdm_mac_link_up(struct mtk_mac *mac, ++ struct phy_device *phy, ++ unsigned int mode, phy_interface_t interface, ++ int speed, int duplex, bool tx_pause, bool rx_pause) ++{ ++ u32 mcr, force_link = 0; ++ ++ if (mac->id == MTK_GMAC1_ID) ++ return; ++ ++ /* Eliminate the interference(before link-up) caused by PHY noise */ ++ mtk_m32(mac->hw, XMAC_LOGIC_RST, 0, MTK_XMAC_LOGIC_RST(mac->id)); ++ mdelay(20); ++ mtk_m32(mac->hw, XMAC_GLB_CNTCLR, XMAC_GLB_CNTCLR, MTK_XMAC_CNT_CTRL(mac->id)); ++ ++ if (mac->interface == PHY_INTERFACE_MODE_INTERNAL || mac->id == MTK_GMAC3_ID) ++ force_link = MTK_XGMAC_FORCE_LINK(mac->id); ++ ++ mtk_m32(mac->hw, MTK_XGMAC_FORCE_LINK(mac->id), force_link, MTK_XGMAC_STS(mac->id)); ++ ++ mcr = mtk_r32(mac->hw, MTK_XMAC_MCR(mac->id)); ++ mcr &= ~(XMAC_MCR_FORCE_TX_FC | XMAC_MCR_FORCE_RX_FC | XMAC_MCR_TRX_DISABLE); ++ /* Configure pause modes - ++ * phylink will avoid these for half duplex ++ */ ++ if (tx_pause) ++ mcr |= XMAC_MCR_FORCE_TX_FC; ++ if (rx_pause) ++ mcr |= XMAC_MCR_FORCE_RX_FC; ++ ++ mtk_w32(mac->hw, mcr, MTK_XMAC_MCR(mac->id)); ++} ++ ++static void mtk_mac_link_up(struct phylink_config *config, ++ struct phy_device *phy, ++ unsigned int mode, phy_interface_t interface, ++ int speed, int duplex, bool tx_pause, bool rx_pause) ++{ ++ struct mtk_mac *mac = container_of(config, struct mtk_mac, ++ phylink_config); ++ ++ if (mtk_is_netsys_v3_or_greater(mac->hw) && mtk_interface_mode_is_xgmii(interface)) ++ mtk_xgdm_mac_link_up(mac, phy, mode, interface, speed, duplex, ++ tx_pause, rx_pause); ++ else ++ mtk_gdm_mac_link_up(mac, phy, mode, interface, speed, duplex, ++ tx_pause, rx_pause); ++ ++ /* Repeat pextp setup to tune link */ ++ if (mac->pextp) ++ phy_set_mode_ext(mac->pextp, PHY_MODE_ETHERNET, interface); ++} ++ + static const struct phylink_mac_ops mtk_phylink_ops = { + .mac_select_pcs = mtk_mac_select_pcs, + .mac_config = mtk_mac_config, ++ .mac_prepare = mtk_mac_prepare, + .mac_finish = mtk_mac_finish, + .mac_link_down = mtk_mac_link_down, + .mac_link_up = mtk_mac_link_up, +@@ -3591,6 +3736,9 @@ static int mtk_open(struct net_device *d + + ppe_num = eth->soc->ppe_num; + ++ if (mac->pextp) ++ phy_power_on(mac->pextp); ++ + err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); + if (err) { + netdev_err(dev, "%s: could not attach PHY: %d\n", __func__, +@@ -3738,6 +3886,9 @@ static int mtk_stop(struct net_device *d + for (i = 0; i < ARRAY_SIZE(eth->ppe); i++) + mtk_ppe_stop(eth->ppe[i]); + ++ if (mac->pextp) ++ phy_power_off(mac->pextp); ++ + return 0; + } + +@@ -4828,6 +4979,7 @@ static const struct net_device_ops mtk_n + static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) + { + const __be32 *_id = of_get_property(np, "reg", NULL); ++ struct device_node *pcs_np; + phy_interface_t phy_mode; + struct phylink *phylink; + struct mtk_mac *mac; +@@ -4866,16 +5018,44 @@ static int mtk_add_mac(struct mtk_eth *e + mac->id = id; + mac->hw = eth; + mac->of_node = np; ++ pcs_np = of_parse_phandle(mac->of_node, "pcs-handle", 0); ++ if (pcs_np) { ++ mac->sgmii_pcs = mtk_pcs_lynxi_get(eth->dev, pcs_np); ++ if (IS_ERR(mac->sgmii_pcs)) { ++ if (PTR_ERR(mac->sgmii_pcs) != -EPROBE_DEFER) ++ dev_err(eth->dev, ++ "cannot select SGMII PCS, error %ld\n", ++ PTR_ERR(mac->sgmii_pcs)); ++ ++ err = PTR_ERR(mac->sgmii_pcs); ++ goto free_netdev; ++ } ++ } + +- err = of_get_ethdev_address(mac->of_node, eth->netdev[id]); +- if (err == -EPROBE_DEFER) +- return err; ++ pcs_np = of_parse_phandle(mac->of_node, "pcs-handle", 1); ++ if (pcs_np) { ++ mac->usxgmii_pcs = mtk_usxgmii_pcs_get(eth->dev, pcs_np); ++ if (IS_ERR(mac->usxgmii_pcs)) { ++ if (PTR_ERR(mac->usxgmii_pcs) != -EPROBE_DEFER) ++ dev_err(eth->dev, ++ "cannot select USXGMII PCS, error %ld\n", ++ PTR_ERR(mac->usxgmii_pcs)); ++ ++ err = PTR_ERR(mac->usxgmii_pcs); ++ goto free_netdev; ++ } ++ } + +- if (err) { +- /* If the mac address is invalid, use random mac address */ +- eth_hw_addr_random(eth->netdev[id]); +- dev_err(eth->dev, "generated random MAC address %pM\n", +- eth->netdev[id]->dev_addr); ++ if (mtk_is_netsys_v3_or_greater(eth) && (mac->sgmii_pcs || mac->usxgmii_pcs)) { ++ mac->pextp = devm_of_phy_optional_get(eth->dev, mac->of_node, NULL); ++ if (IS_ERR(mac->pextp)) { ++ if (PTR_ERR(mac->pextp) != -EPROBE_DEFER) ++ dev_err(eth->dev, "cannot get PHY, error %ld\n", ++ PTR_ERR(mac->pextp)); ++ ++ err = PTR_ERR(mac->pextp); ++ goto free_netdev; ++ } + } + + memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip)); +@@ -4958,8 +5138,21 @@ static int mtk_add_mac(struct mtk_eth *e + phy_interface_zero(mac->phylink_config.supported_interfaces); + __set_bit(PHY_INTERFACE_MODE_INTERNAL, + mac->phylink_config.supported_interfaces); ++ } else if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_USXGMII)) { ++ mac->phylink_config.mac_capabilities |= MAC_5000FD | MAC_10000FD; ++ __set_bit(PHY_INTERFACE_MODE_5GBASER, ++ mac->phylink_config.supported_interfaces); ++ __set_bit(PHY_INTERFACE_MODE_10GBASER, ++ mac->phylink_config.supported_interfaces); ++ __set_bit(PHY_INTERFACE_MODE_USXGMII, ++ mac->phylink_config.supported_interfaces); + } + ++ if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_2P5GPHY) && ++ id == MTK_GMAC2_ID) ++ __set_bit(PHY_INTERFACE_MODE_INTERNAL, ++ mac->phylink_config.supported_interfaces); ++ + phylink = phylink_create(&mac->phylink_config, + of_fwnode_handle(mac->of_node), + phy_mode, &mtk_phylink_ops); +@@ -5010,6 +5203,26 @@ free_netdev: + return err; + } + ++static int mtk_mac_assign_address(struct mtk_eth *eth, int i, bool test_defer_only) ++{ ++ int err = of_get_ethdev_address(eth->mac[i]->of_node, eth->netdev[i]); ++ ++ if (err == -EPROBE_DEFER) ++ return err; ++ ++ if (test_defer_only) ++ return 0; ++ ++ if (err) { ++ /* If the mac address is invalid, use random mac address */ ++ eth_hw_addr_random(eth->netdev[i]); ++ dev_err(eth->dev, "generated random MAC address %pM\n", ++ eth->netdev[i]); ++ } ++ ++ return 0; ++} ++ + void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev) + { + struct net_device *dev, *tmp; +@@ -5156,7 +5369,8 @@ static int mtk_probe(struct platform_dev + regmap_write(cci, 0, 3); + } + +- if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) { ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII) && ++ !mtk_is_netsys_v3_or_greater(eth)) { + err = mtk_sgmii_init(eth); + + if (err) +@@ -5267,6 +5481,24 @@ static int mtk_probe(struct platform_dev + } + } + ++ for (i = 0; i < MTK_MAX_DEVS; i++) { ++ if (!eth->netdev[i]) ++ continue; ++ ++ err = mtk_mac_assign_address(eth, i, true); ++ if (err) ++ goto err_deinit_hw; ++ } ++ ++ for (i = 0; i < MTK_MAX_DEVS; i++) { ++ if (!eth->netdev[i]) ++ continue; ++ ++ err = mtk_mac_assign_address(eth, i, false); ++ if (err) ++ goto err_deinit_hw; ++ } ++ + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { + err = devm_request_irq(eth->dev, eth->irq[0], + mtk_handle_irq, 0, +@@ -5377,6 +5609,11 @@ static void mtk_remove(struct platform_d + mtk_stop(eth->netdev[i]); + mac = netdev_priv(eth->netdev[i]); + phylink_disconnect_phy(mac->phylink); ++ if (mac->sgmii_pcs) ++ mtk_pcs_lynxi_put(mac->sgmii_pcs); ++ ++ if (mac->usxgmii_pcs) ++ mtk_usxgmii_pcs_put(mac->usxgmii_pcs); + } + + mtk_wed_exit(); +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -527,6 +528,21 @@ + #define INTF_MODE_RGMII_1000 (TRGMII_MODE | TRGMII_CENTRAL_ALIGNED) + #define INTF_MODE_RGMII_10_100 0 + ++/* XFI Mac control registers */ ++#define MTK_XMAC_BASE(x) (0x12000 + (((x) - 1) * 0x1000)) ++#define MTK_XMAC_MCR(x) (MTK_XMAC_BASE(x)) ++#define XMAC_MCR_TRX_DISABLE 0xf ++#define XMAC_MCR_FORCE_TX_FC BIT(5) ++#define XMAC_MCR_FORCE_RX_FC BIT(4) ++ ++/* XFI Mac logic reset registers */ ++#define MTK_XMAC_LOGIC_RST(x) (MTK_XMAC_BASE(x) + 0x10) ++#define XMAC_LOGIC_RST BIT(0) ++ ++/* XFI Mac count global control */ ++#define MTK_XMAC_CNT_CTRL(x) (MTK_XMAC_BASE(x) + 0x100) ++#define XMAC_GLB_CNTCLR BIT(0) ++ + /* GPIO port control registers for GMAC 2*/ + #define GPIO_OD33_CTRL8 0x4c0 + #define GPIO_BIAS_CTRL 0xed0 +@@ -552,6 +568,7 @@ + #define SYSCFG0_SGMII_GMAC2 ((3 << 8) & SYSCFG0_SGMII_MASK) + #define SYSCFG0_SGMII_GMAC1_V2 BIT(9) + #define SYSCFG0_SGMII_GMAC2_V2 BIT(8) ++#define SYSCFG0_SGMII_GMAC3_V2 BIT(7) + + + /* ethernet subsystem clock register */ +@@ -590,6 +607,11 @@ + #define GEPHY_MAC_SEL BIT(1) + + /* Top misc registers */ ++#define TOP_MISC_NETSYS_PCS_MUX 0x0 ++#define NETSYS_PCS_MUX_MASK GENMASK(1, 0) ++#define MUX_G2_USXGMII_SEL BIT(1) ++#define MUX_HSGMII1_G1_SEL BIT(0) ++ + #define USB_PHY_SWITCH_REG 0x218 + #define QPHY_SEL_MASK GENMASK(1, 0) + #define SGMII_QPHY_SEL 0x2 +@@ -614,6 +636,8 @@ + #define MT7628_SDM_RBCNT (MT7628_SDM_OFFSET + 0x10c) + #define MT7628_SDM_CS_ERR (MT7628_SDM_OFFSET + 0x110) + ++/* Debug Purpose Register */ ++#define MTK_PSE_FQFC_CFG 0x100 + #define MTK_FE_CDM1_FSM 0x220 + #define MTK_FE_CDM2_FSM 0x224 + #define MTK_FE_CDM3_FSM 0x238 +@@ -622,6 +646,11 @@ + #define MTK_FE_CDM6_FSM 0x328 + #define MTK_FE_GDM1_FSM 0x228 + #define MTK_FE_GDM2_FSM 0x22C ++#define MTK_FE_GDM3_FSM 0x23C ++#define MTK_FE_PSE_FREE 0x240 ++#define MTK_FE_DROP_FQ 0x244 ++#define MTK_FE_DROP_FC 0x248 ++#define MTK_FE_DROP_PPE 0x24C + + #define MTK_MAC_FSM(x) (0x1010C + ((x) * 0x100)) + +@@ -945,6 +974,8 @@ enum mkt_eth_capabilities { + MTK_RGMII_BIT = 0, + MTK_TRGMII_BIT, + MTK_SGMII_BIT, ++ MTK_USXGMII_BIT, ++ MTK_2P5GPHY_BIT, + MTK_ESW_BIT, + MTK_GEPHY_BIT, + MTK_MUX_BIT, +@@ -965,8 +996,11 @@ enum mkt_eth_capabilities { + MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT, + MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY_BIT, + MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT, ++ MTK_ETH_MUX_GMAC2_TO_2P5GPHY_BIT, + MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT, + MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT, ++ MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII_BIT, ++ MTK_ETH_MUX_GMAC123_TO_USXGMII_BIT, + + /* PATH BITS */ + MTK_ETH_PATH_GMAC1_RGMII_BIT, +@@ -974,14 +1008,21 @@ enum mkt_eth_capabilities { + MTK_ETH_PATH_GMAC1_SGMII_BIT, + MTK_ETH_PATH_GMAC2_RGMII_BIT, + MTK_ETH_PATH_GMAC2_SGMII_BIT, ++ MTK_ETH_PATH_GMAC2_2P5GPHY_BIT, + MTK_ETH_PATH_GMAC2_GEPHY_BIT, ++ MTK_ETH_PATH_GMAC3_SGMII_BIT, + MTK_ETH_PATH_GDM1_ESW_BIT, ++ MTK_ETH_PATH_GMAC1_USXGMII_BIT, ++ MTK_ETH_PATH_GMAC2_USXGMII_BIT, ++ MTK_ETH_PATH_GMAC3_USXGMII_BIT, + }; + + /* Supported hardware group on SoCs */ + #define MTK_RGMII BIT_ULL(MTK_RGMII_BIT) + #define MTK_TRGMII BIT_ULL(MTK_TRGMII_BIT) + #define MTK_SGMII BIT_ULL(MTK_SGMII_BIT) ++#define MTK_USXGMII BIT_ULL(MTK_USXGMII_BIT) ++#define MTK_2P5GPHY BIT_ULL(MTK_2P5GPHY_BIT) + #define MTK_ESW BIT_ULL(MTK_ESW_BIT) + #define MTK_GEPHY BIT_ULL(MTK_GEPHY_BIT) + #define MTK_MUX BIT_ULL(MTK_MUX_BIT) +@@ -1004,10 +1045,16 @@ enum mkt_eth_capabilities { + BIT_ULL(MTK_ETH_MUX_GMAC2_GMAC0_TO_GEPHY_BIT) + #define MTK_ETH_MUX_U3_GMAC2_TO_QPHY \ + BIT_ULL(MTK_ETH_MUX_U3_GMAC2_TO_QPHY_BIT) ++#define MTK_ETH_MUX_GMAC2_TO_2P5GPHY \ ++ BIT_ULL(MTK_ETH_MUX_GMAC2_TO_2P5GPHY_BIT) + #define MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII \ + BIT_ULL(MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII_BIT) + #define MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII \ + BIT_ULL(MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII_BIT) ++#define MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII \ ++ BIT_ULL(MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII_BIT) ++#define MTK_ETH_MUX_GMAC123_TO_USXGMII \ ++ BIT_ULL(MTK_ETH_MUX_GMAC123_TO_USXGMII_BIT) + + /* Supported path present on SoCs */ + #define MTK_ETH_PATH_GMAC1_RGMII BIT_ULL(MTK_ETH_PATH_GMAC1_RGMII_BIT) +@@ -1015,8 +1062,13 @@ enum mkt_eth_capabilities { + #define MTK_ETH_PATH_GMAC1_SGMII BIT_ULL(MTK_ETH_PATH_GMAC1_SGMII_BIT) + #define MTK_ETH_PATH_GMAC2_RGMII BIT_ULL(MTK_ETH_PATH_GMAC2_RGMII_BIT) + #define MTK_ETH_PATH_GMAC2_SGMII BIT_ULL(MTK_ETH_PATH_GMAC2_SGMII_BIT) ++#define MTK_ETH_PATH_GMAC2_2P5GPHY BIT_ULL(MTK_ETH_PATH_GMAC2_2P5GPHY_BIT) + #define MTK_ETH_PATH_GMAC2_GEPHY BIT_ULL(MTK_ETH_PATH_GMAC2_GEPHY_BIT) ++#define MTK_ETH_PATH_GMAC3_SGMII BIT_ULL(MTK_ETH_PATH_GMAC3_SGMII_BIT) + #define MTK_ETH_PATH_GDM1_ESW BIT_ULL(MTK_ETH_PATH_GDM1_ESW_BIT) ++#define MTK_ETH_PATH_GMAC1_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC1_USXGMII_BIT) ++#define MTK_ETH_PATH_GMAC2_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC2_USXGMII_BIT) ++#define MTK_ETH_PATH_GMAC3_USXGMII BIT_ULL(MTK_ETH_PATH_GMAC3_USXGMII_BIT) + + #define MTK_GMAC1_RGMII (MTK_ETH_PATH_GMAC1_RGMII | MTK_RGMII) + #define MTK_GMAC1_TRGMII (MTK_ETH_PATH_GMAC1_TRGMII | MTK_TRGMII) +@@ -1024,7 +1076,12 @@ enum mkt_eth_capabilities { + #define MTK_GMAC2_RGMII (MTK_ETH_PATH_GMAC2_RGMII | MTK_RGMII) + #define MTK_GMAC2_SGMII (MTK_ETH_PATH_GMAC2_SGMII | MTK_SGMII) + #define MTK_GMAC2_GEPHY (MTK_ETH_PATH_GMAC2_GEPHY | MTK_GEPHY) ++#define MTK_GMAC2_2P5GPHY (MTK_ETH_PATH_GMAC2_2P5GPHY | MTK_2P5GPHY) ++#define MTK_GMAC3_SGMII (MTK_ETH_PATH_GMAC3_SGMII | MTK_SGMII) + #define MTK_GDM1_ESW (MTK_ETH_PATH_GDM1_ESW | MTK_ESW) ++#define MTK_GMAC1_USXGMII (MTK_ETH_PATH_GMAC1_USXGMII | MTK_USXGMII) ++#define MTK_GMAC2_USXGMII (MTK_ETH_PATH_GMAC2_USXGMII | MTK_USXGMII) ++#define MTK_GMAC3_USXGMII (MTK_ETH_PATH_GMAC3_USXGMII | MTK_USXGMII) + + /* MUXes present on SoCs */ + /* 0: GDM1 -> GMAC1, 1: GDM1 -> ESW */ +@@ -1043,10 +1100,20 @@ enum mkt_eth_capabilities { + (MTK_ETH_MUX_GMAC1_GMAC2_TO_SGMII_RGMII | MTK_MUX | \ + MTK_SHARED_SGMII) + ++/* 2: GMAC2 -> XGMII */ ++#define MTK_MUX_GMAC2_TO_2P5GPHY \ ++ (MTK_ETH_MUX_GMAC2_TO_2P5GPHY | MTK_MUX | MTK_INFRA) ++ + /* 0: GMACx -> GEPHY, 1: GMACx -> SGMII where x is 1 or 2 */ + #define MTK_MUX_GMAC12_TO_GEPHY_SGMII \ + (MTK_ETH_MUX_GMAC12_TO_GEPHY_SGMII | MTK_MUX) + ++#define MTK_MUX_GMAC123_TO_GEPHY_SGMII \ ++ (MTK_ETH_MUX_GMAC123_TO_GEPHY_SGMII | MTK_MUX) ++ ++#define MTK_MUX_GMAC123_TO_USXGMII \ ++ (MTK_ETH_MUX_GMAC123_TO_USXGMII | MTK_MUX | MTK_INFRA) ++ + #define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x)) + + #define MT7621_CAPS (MTK_GMAC1_RGMII | MTK_GMAC1_TRGMII | \ +@@ -1078,8 +1145,12 @@ enum mkt_eth_capabilities { + MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \ + MTK_RSTCTRL_PPE1 | MTK_SRAM) + +-#define MT7988_CAPS (MTK_36BIT_DMA | MTK_GDM1_ESW | MTK_QDMA | \ +- MTK_RSTCTRL_PPE1 | MTK_RSTCTRL_PPE2 | MTK_SRAM) ++#define MT7988_CAPS (MTK_36BIT_DMA | MTK_GDM1_ESW | MTK_GMAC1_SGMII | \ ++ MTK_GMAC2_2P5GPHY | MTK_GMAC2_SGMII | MTK_GMAC2_USXGMII | \ ++ MTK_GMAC3_SGMII | MTK_GMAC3_USXGMII | \ ++ MTK_MUX_GMAC123_TO_GEPHY_SGMII | \ ++ MTK_MUX_GMAC123_TO_USXGMII | MTK_MUX_GMAC2_TO_2P5GPHY | \ ++ MTK_QDMA | MTK_RSTCTRL_PPE1 | MTK_RSTCTRL_PPE2 | MTK_SRAM) + + struct mtk_tx_dma_desc_info { + dma_addr_t addr; +@@ -1327,6 +1398,9 @@ struct mtk_mac { + struct device_node *of_node; + struct phylink *phylink; + struct phylink_config phylink_config; ++ struct phylink_pcs *sgmii_pcs; ++ struct phylink_pcs *usxgmii_pcs; ++ struct phy *pextp; + struct mtk_eth *hw; + struct mtk_hw_stats *hw_stats; + __be32 hwlro_ip[MTK_MAX_LRO_IP_CNT]; +@@ -1450,6 +1524,19 @@ static inline u32 mtk_get_ib2_multicast_ + return MTK_FOE_IB2_MULTICAST; + } + ++static inline bool mtk_interface_mode_is_xgmii(phy_interface_t interface) ++{ ++ switch (interface) { ++ case PHY_INTERFACE_MODE_INTERNAL: ++ case PHY_INTERFACE_MODE_USXGMII: ++ case PHY_INTERFACE_MODE_10GBASER: ++ case PHY_INTERFACE_MODE_5GBASER: ++ return true; ++ default: ++ return false; ++ } ++} ++ + /* read the hardware status register */ + void mtk_stats_update_mac(struct mtk_mac *mac); + +@@ -1458,8 +1545,10 @@ u32 mtk_r32(struct mtk_eth *eth, unsigne + u32 mtk_m32(struct mtk_eth *eth, u32 mask, u32 set, unsigned int reg); + + int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id); ++int mtk_gmac_2p5gphy_path_setup(struct mtk_eth *eth, int mac_id); + int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id); + int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id); ++int mtk_gmac_usxgmii_path_setup(struct mtk_eth *eth, int mac_id); + + int mtk_eth_offload_init(struct mtk_eth *eth, u8 id); + int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/738-01-net-ethernet-mtk_eth_soc-reduce-rx-ring-size-for-older.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/738-01-net-ethernet-mtk_eth_soc-reduce-rx-ring-size-for-older.patch new file mode 100755 index 0000000..1ba5433 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/738-01-net-ethernet-mtk_eth_soc-reduce-rx-ring-size-for-older.patch @@ -0,0 +1,104 @@ +From: Felix Fietkau +Subject: [PATCH net-next 3/4] net: ethernet: mtk_eth_soc: reduce rx ring size for older chipsets +Date: Tue, 15 Oct 2024 13:09:37 +0200 + +Commit c57e55819443 ("net: ethernet: mtk_eth_soc: handle dma buffer +size soc specific") resolved some tx timeout issues by bumping FQ and +tx ring sizes from 512 to 2048 entries (the value used in the MediaTek +SDK), however it also changed the rx ring size for all chipsets in the +same way. + +Based on a few tests, it seems that a symmetric rx/tx ring size of 2048 +really only makes sense on MT7988, which is capable of 10G ethernet links. + +Older chipsets are typically deployed in systems that are more memory +constrained and don't actually need the larger rings to handle received +packets. + +In order to reduce wasted memory set the ring size based on the SoC to +the following values: +- 2048 on MT7988 +- 1024 on MT7986 +- 512 (previous value) on everything else, except: +- 256 on RT5350 (the oldest supported chipset) + +Fixes: c57e55819443 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific") +Signed-off-by: Felix Fietkau +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -5647,7 +5647,7 @@ static const struct mtk_soc_data mt2701_ + DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(512), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, +@@ -5675,7 +5675,7 @@ static const struct mtk_soc_data mt7621_ + DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(512), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, +@@ -5705,7 +5705,7 @@ static const struct mtk_soc_data mt7622_ + DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(512), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, +@@ -5734,7 +5734,7 @@ static const struct mtk_soc_data mt7623_ + DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(512), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, +@@ -5760,7 +5760,7 @@ static const struct mtk_soc_data mt7629_ + DESC_SIZE(struct mtk_rx_dma), + .irq_done_mask = MTK_RX_DONE_INT, + .dma_l4_valid = RX_DMA_L4_VALID, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(512), + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, + }, +@@ -5792,7 +5792,7 @@ static const struct mtk_soc_data mt7981_ + .dma_l4_valid = RX_DMA_L4_VALID_V2, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(512), + }, + }; + +@@ -5822,7 +5822,7 @@ static const struct mtk_soc_data mt7986_ + .dma_l4_valid = RX_DMA_L4_VALID_V2, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(1K), + }, + }; + +@@ -5875,7 +5875,7 @@ static const struct mtk_soc_data rt5350_ + .dma_l4_valid = RX_DMA_L4_VALID_PDMA, + .dma_max_len = MTK_TX_DMA_BUF_LEN, + .dma_len_offset = 16, +- .dma_size = MTK_DMA_SIZE(2K), ++ .dma_size = MTK_DMA_SIZE(256), + }, + }; + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/738-02-net-ethernet-mtk_eth_soc-do-not-enable-page-pool-sta.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/738-02-net-ethernet-mtk_eth_soc-do-not-enable-page-pool-sta.patch new file mode 100755 index 0000000..10712eb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/738-02-net-ethernet-mtk_eth_soc-do-not-enable-page-pool-sta.patch @@ -0,0 +1,43 @@ +From: Danila Romanov +Date: Wed, 22 Jan 2025 06:48:45 +0100 +Subject: [PATCH] net: ethernet: mtk_eth_soc: do not enable page pool stats by + default + +There is no reason for it to be enabled by default. +Align mtk_eth_soc driver to mt76 driver. + +This option incurs additional CPU cost in allocation and recycle paths +and additional memory cost to store the statistics. + +Signed-off-by: Danila Romanov +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/Kconfig ++++ b/drivers/net/ethernet/mediatek/Kconfig +@@ -26,7 +26,6 @@ config NET_MEDIATEK_SOC + select PHYLINK + select DIMLIB + select PAGE_POOL +- select PAGE_POOL_STATS + select PCS_MTK_LYNXI + select REGMAP_MMIO + help +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -4747,6 +4747,7 @@ static int mtk_get_sset_count(struct net + + static void mtk_ethtool_pp_stats(struct mtk_eth *eth, u64 *data) + { ++#ifdef CONFIG_PAGE_POOL_STATS + struct page_pool_stats stats = {}; + int i; + +@@ -4759,6 +4760,7 @@ static void mtk_ethtool_pp_stats(struct + page_pool_get_stats(ring->page_pool, &stats); + } + page_pool_ethtool_stats_get(data, &stats); ++#endif + } + + static void mtk_get_ethtool_stats(struct net_device *dev, diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-01-dt-bindings-phy-mediatek-xfi-tphy-add-new-bindings.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-01-dt-bindings-phy-mediatek-xfi-tphy-add-new-bindings.patch new file mode 100755 index 0000000..1f1c40b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-01-dt-bindings-phy-mediatek-xfi-tphy-add-new-bindings.patch @@ -0,0 +1,136 @@ +From patchwork Thu Feb 1 21:52:20 2024 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 13541842 +Date: Thu, 1 Feb 2024 21:52:20 +0000 +From: Daniel Golle +To: Bc-bocun Chen , + Steven Liu , + John Crispin , + Chunfeng Yun , + Vinod Koul , + Kishon Vijay Abraham I , + Rob Herring , + Krzysztof Kozlowski , + Conor Dooley , + Daniel Golle , + Qingfang Deng , + SkyLake Huang , + Matthias Brugger , + AngeloGioacchino Del Regno , + Philipp Zabel , + linux-arm-kernel@lists.infradead.org, + linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, + devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, + netdev@vger.kernel.org +Subject: [PATCH 1/2] dt-bindings: phy: mediatek,xfi-tphy: add new bindings +Message-ID: + <702afb0c1246d95c90b22e57105304028bdd3083.1706823233.git.daniel@makrotopia.org> +MIME-Version: 1.0 +Content-Disposition: inline +List-Id: Linux Phy Mailing list + +Add bindings for the MediaTek XFI T-PHY Ethernet SerDes PHY found in the +MediaTek MT7988 SoC which can operate at various interfaces modes: + +via USXGMII PCS: + * USXGMII + * 10GBase-R + * 5GBase-R + +via LynxI SGMII PCS: + * 2500Base-X + * 1000Base-X + * Cisco SGMII (MAC side) + +Signed-off-by: Daniel Golle +--- + .../bindings/phy/mediatek,xfi-tphy.yaml | 80 +++++++++++++++++++ + 1 file changed, 80 insertions(+) + create mode 100644 Documentation/devicetree/bindings/phy/mediatek,xfi-tphy.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/phy/mediatek,xfi-tphy.yaml +@@ -0,0 +1,80 @@ ++# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/phy/mediatek,xfi-tphy.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MediaTek XFI T-PHY ++ ++maintainers: ++ - Daniel Golle ++ ++description: ++ The MediaTek XFI SerDes T-PHY provides the physical SerDes lanes ++ used by the (10G/5G) USXGMII PCS and (1G/2.5G) LynxI PCS found in ++ MediaTek's 10G-capabale SoCs. ++ ++properties: ++ $nodename: ++ pattern: "^phy@[0-9a-f]+$" ++ ++ compatible: ++ const: mediatek,mt7988-xfi-tphy ++ ++ reg: ++ maxItems: 1 ++ ++ clocks: ++ items: ++ - description: XFI PHY clock ++ - description: XFI register clock ++ ++ clock-names: ++ items: ++ - const: xfipll ++ - const: topxtal ++ ++ resets: ++ items: ++ - description: PEXTP reset ++ ++ mediatek,usxgmii-performance-errata: ++ $ref: /schemas/types.yaml#/definitions/flag ++ description: ++ One instance of the T-PHY on MT7988 suffers from a performance ++ problem in 10GBase-R mode which needs a work-around in the driver. ++ The work-around is enabled using this flag. ++ ++ "#phy-cells": ++ const: 0 ++ ++required: ++ - compatible ++ - reg ++ - clocks ++ - clock-names ++ - resets ++ - "#phy-cells" ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ soc { ++ #address-cells = <2>; ++ #size-cells = <2>; ++ ++ phy@11f20000 { ++ compatible = "mediatek,mt7988-xfi-tphy"; ++ reg = <0 0x11f20000 0 0x10000>; ++ clocks = <&xfi_pll CLK_XFIPLL_PLL_EN>, ++ <&topckgen CLK_TOP_XFI_PHY_0_XTAL_SEL>; ++ clock-names = "xfipll", "topxtal"; ++ resets = <&watchdog 14>; ++ mediatek,usxgmii-performance-errata; ++ #phy-cells = <0>; ++ }; ++ }; ++ ++... diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-03-net-pcs-pcs-mtk-lynxi-add-platform-driver-for-MT7988.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-03-net-pcs-pcs-mtk-lynxi-add-platform-driver-for-MT7988.patch new file mode 100755 index 0000000..0e4a63e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-03-net-pcs-pcs-mtk-lynxi-add-platform-driver-for-MT7988.patch @@ -0,0 +1,369 @@ +From 4b1a2716299c0e96a698044aebf3f80513509ae7 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 12 Dec 2023 03:47:18 +0000 +Subject: [PATCH 3/5] net: pcs: pcs-mtk-lynxi: add platform driver for MT7988 + +Introduce a proper platform MFD driver for the LynxI (H)SGMII PCS which +is going to initially be used for the MT7988 SoC. + +Signed-off-by: Daniel Golle +--- + drivers/net/pcs/pcs-mtk-lynxi.c | 227 ++++++++++++++++++++++++++++-- + include/linux/pcs/pcs-mtk-lynxi.h | 11 ++ + 2 files changed, 227 insertions(+), 11 deletions(-) + +--- a/drivers/net/pcs/pcs-mtk-lynxi.c ++++ b/drivers/net/pcs/pcs-mtk-lynxi.c +@@ -1,6 +1,6 @@ + // SPDX-License-Identifier: GPL-2.0 + // Copyright (c) 2018-2019 MediaTek Inc. +-/* A library for MediaTek SGMII circuit ++/* A library and platform driver for the MediaTek LynxI SGMII circuit + * + * Author: Sean Wang + * Author: Alexander Couzens +@@ -8,11 +8,17 @@ + * + */ + ++#include + #include ++#include ++#include + #include ++#include + #include + #include ++#include + #include ++#include + + /* SGMII subsystem config registers */ + /* BMCR (low 16) BMSR (high 16) */ +@@ -65,6 +71,8 @@ + #define SGMII_PN_SWAP_MASK GENMASK(1, 0) + #define SGMII_PN_SWAP_TX_RX (BIT(0) | BIT(1)) + ++#define MTK_NETSYS_V3_AMA_RGC3 0x128 ++ + /* struct mtk_pcs_lynxi - This structure holds each sgmii regmap andassociated + * data + * @regmap: The register map pointing at the range used to setup +@@ -74,15 +82,29 @@ + * @interface: Currently configured interface mode + * @pcs: Phylink PCS structure + * @flags: Flags indicating hardware properties ++ * @rstc: Reset controller ++ * @sgmii_sel: SGMII Register Clock ++ * @sgmii_rx: SGMII RX Clock ++ * @sgmii_tx: SGMII TX Clock ++ * @node: List node + */ + struct mtk_pcs_lynxi { + struct regmap *regmap; ++ struct device *dev; + u32 ana_rgc3; + phy_interface_t interface; + struct phylink_pcs pcs; + u32 flags; ++ struct reset_control *rstc; ++ struct clk *sgmii_sel; ++ struct clk *sgmii_rx; ++ struct clk *sgmii_tx; ++ struct list_head node; + }; + ++static LIST_HEAD(mtk_pcs_lynxi_instances); ++static DEFINE_MUTEX(instance_mutex); ++ + static struct mtk_pcs_lynxi *pcs_to_mtk_pcs_lynxi(struct phylink_pcs *pcs) + { + return container_of(pcs, struct mtk_pcs_lynxi, pcs); +@@ -117,6 +139,17 @@ static void mtk_pcs_lynxi_get_state(stru + FIELD_GET(SGMII_LPA, adv)); + } + ++static void mtk_sgmii_reset(struct mtk_pcs_lynxi *mpcs) ++{ ++ if (!mpcs->rstc) ++ return; ++ ++ reset_control_assert(mpcs->rstc); ++ udelay(100); ++ reset_control_deassert(mpcs->rstc); ++ mdelay(1); ++} ++ + static int mtk_pcs_lynxi_config(struct phylink_pcs *pcs, unsigned int neg_mode, + phy_interface_t interface, + const unsigned long *advertising, +@@ -162,6 +195,7 @@ static int mtk_pcs_lynxi_config(struct p + SGMII_PHYA_PWD); + + /* Reset SGMII PCS state */ ++ mtk_sgmii_reset(mpcs); + regmap_set_bits(mpcs->regmap, SGMSYS_RESERVED_0, + SGMII_SW_RESET); + +@@ -248,10 +282,29 @@ static void mtk_pcs_lynxi_link_up(struct + } + } + ++static int mtk_pcs_lynxi_enable(struct phylink_pcs *pcs) ++{ ++ struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); ++ ++ if (mpcs->sgmii_tx && mpcs->sgmii_rx) { ++ clk_prepare_enable(mpcs->sgmii_rx); ++ clk_prepare_enable(mpcs->sgmii_tx); ++ } ++ ++ return 0; ++} ++ + static void mtk_pcs_lynxi_disable(struct phylink_pcs *pcs) + { + struct mtk_pcs_lynxi *mpcs = pcs_to_mtk_pcs_lynxi(pcs); + ++ regmap_set_bits(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); ++ ++ if (mpcs->sgmii_tx && mpcs->sgmii_rx) { ++ clk_disable_unprepare(mpcs->sgmii_tx); ++ clk_disable_unprepare(mpcs->sgmii_rx); ++ } ++ + mpcs->interface = PHY_INTERFACE_MODE_NA; + } + +@@ -262,11 +315,12 @@ static const struct phylink_pcs_ops mtk_ + .pcs_an_restart = mtk_pcs_lynxi_restart_an, + .pcs_link_up = mtk_pcs_lynxi_link_up, + .pcs_disable = mtk_pcs_lynxi_disable, ++ .pcs_enable = mtk_pcs_lynxi_enable, + }; + +-struct phylink_pcs *mtk_pcs_lynxi_create(struct device *dev, +- struct regmap *regmap, u32 ana_rgc3, +- u32 flags) ++static struct phylink_pcs *mtk_pcs_lynxi_init(struct device *dev, struct regmap *regmap, ++ u32 ana_rgc3, u32 flags, ++ struct mtk_pcs_lynxi *prealloc) + { + struct mtk_pcs_lynxi *mpcs; + u32 id, ver; +@@ -274,29 +328,33 @@ struct phylink_pcs *mtk_pcs_lynxi_create + + ret = regmap_read(regmap, SGMSYS_PCS_DEVICE_ID, &id); + if (ret < 0) +- return NULL; ++ return ERR_PTR(ret); + + if (id != SGMII_LYNXI_DEV_ID) { + dev_err(dev, "unknown PCS device id %08x\n", id); +- return NULL; ++ return ERR_PTR(-ENODEV); + } + + ret = regmap_read(regmap, SGMSYS_PCS_SCRATCH, &ver); + if (ret < 0) +- return NULL; ++ return ERR_PTR(ret); + + ver = FIELD_GET(SGMII_DEV_VERSION, ver); + if (ver != 0x1) { + dev_err(dev, "unknown PCS device version %04x\n", ver); +- return NULL; ++ return ERR_PTR(-ENODEV); + } + + dev_dbg(dev, "MediaTek LynxI SGMII PCS (id 0x%08x, ver 0x%04x)\n", id, + ver); + +- mpcs = kzalloc(sizeof(*mpcs), GFP_KERNEL); +- if (!mpcs) +- return NULL; ++ if (prealloc) { ++ mpcs = prealloc; ++ } else { ++ mpcs = kzalloc(sizeof(*mpcs), GFP_KERNEL); ++ if (!mpcs) ++ return ERR_PTR(-ENOMEM); ++ }; + + mpcs->ana_rgc3 = ana_rgc3; + mpcs->regmap = regmap; +@@ -307,6 +365,13 @@ struct phylink_pcs *mtk_pcs_lynxi_create + mpcs->interface = PHY_INTERFACE_MODE_NA; + + return &mpcs->pcs; ++}; ++ ++struct phylink_pcs *mtk_pcs_lynxi_create(struct device *dev, ++ struct regmap *regmap, u32 ana_rgc3, ++ u32 flags) ++{ ++ return mtk_pcs_lynxi_init(dev, regmap, ana_rgc3, flags, NULL); + } + EXPORT_SYMBOL(mtk_pcs_lynxi_create); + +@@ -319,5 +384,142 @@ void mtk_pcs_lynxi_destroy(struct phylin + } + EXPORT_SYMBOL(mtk_pcs_lynxi_destroy); + ++static int mtk_pcs_lynxi_probe(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct device_node *np = dev->of_node; ++ struct mtk_pcs_lynxi *mpcs; ++ struct phylink_pcs *pcs; ++ struct regmap *regmap; ++ u32 flags = 0; ++ ++ mpcs = devm_kzalloc(dev, sizeof(*mpcs), GFP_KERNEL); ++ if (!mpcs) ++ return -ENOMEM; ++ ++ mpcs->dev = dev; ++ regmap = syscon_node_to_regmap(np->parent); ++ if (IS_ERR(regmap)) ++ return PTR_ERR(regmap); ++ ++ if (of_property_read_bool(np->parent, "mediatek,pnswap")) ++ flags |= MTK_SGMII_FLAG_PN_SWAP; ++ ++ mpcs->rstc = of_reset_control_get_shared(np->parent, NULL); ++ if (IS_ERR(mpcs->rstc)) ++ return PTR_ERR(mpcs->rstc); ++ ++ reset_control_deassert(mpcs->rstc); ++ mpcs->sgmii_sel = devm_clk_get_enabled(dev, "sgmii_sel"); ++ if (IS_ERR(mpcs->sgmii_sel)) ++ return PTR_ERR(mpcs->sgmii_sel); ++ ++ mpcs->sgmii_rx = devm_clk_get(dev, "sgmii_rx"); ++ if (IS_ERR(mpcs->sgmii_rx)) ++ return PTR_ERR(mpcs->sgmii_rx); ++ ++ mpcs->sgmii_tx = devm_clk_get(dev, "sgmii_tx"); ++ if (IS_ERR(mpcs->sgmii_tx)) ++ return PTR_ERR(mpcs->sgmii_tx); ++ ++ pcs = mtk_pcs_lynxi_init(dev, regmap, (uintptr_t)of_device_get_match_data(dev), ++ flags, mpcs); ++ if (IS_ERR(pcs)) ++ return PTR_ERR(pcs); ++ ++ regmap_set_bits(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); ++ ++ platform_set_drvdata(pdev, mpcs); ++ ++ mutex_lock(&instance_mutex); ++ list_add_tail(&mpcs->node, &mtk_pcs_lynxi_instances); ++ mutex_unlock(&instance_mutex); ++ ++ return 0; ++} ++ ++static void mtk_pcs_lynxi_remove(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct mtk_pcs_lynxi *cur, *tmp; ++ ++ mutex_lock(&instance_mutex); ++ list_for_each_entry_safe(cur, tmp, &mtk_pcs_lynxi_instances, node) ++ if (cur->dev == dev) { ++ list_del(&cur->node); ++ kfree(cur); ++ break; ++ } ++ mutex_unlock(&instance_mutex); ++} ++ ++static const struct of_device_id mtk_pcs_lynxi_of_match[] = { ++ { .compatible = "mediatek,mt7988-sgmii", .data = (void *)MTK_NETSYS_V3_AMA_RGC3 }, ++ { /* sentinel */ }, ++}; ++MODULE_DEVICE_TABLE(of, mtk_pcs_lynxi_of_match); ++ ++struct phylink_pcs *mtk_pcs_lynxi_get(struct device *dev, struct device_node *np) ++{ ++ struct platform_device *pdev; ++ struct mtk_pcs_lynxi *mpcs; ++ ++ if (!np) ++ return NULL; ++ ++ if (!of_device_is_available(np)) ++ return ERR_PTR(-ENODEV); ++ ++ if (!of_match_node(mtk_pcs_lynxi_of_match, np)) ++ return ERR_PTR(-EINVAL); ++ ++ pdev = of_find_device_by_node(np); ++ if (!pdev || !platform_get_drvdata(pdev)) { ++ if (pdev) ++ put_device(&pdev->dev); ++ return ERR_PTR(-EPROBE_DEFER); ++ } ++ ++ mpcs = platform_get_drvdata(pdev); ++ device_link_add(dev, mpcs->dev, DL_FLAG_AUTOREMOVE_CONSUMER); ++ ++ return &mpcs->pcs; ++} ++EXPORT_SYMBOL(mtk_pcs_lynxi_get); ++ ++void mtk_pcs_lynxi_put(struct phylink_pcs *pcs) ++{ ++ struct mtk_pcs_lynxi *cur, *mpcs = NULL; ++ ++ if (!pcs) ++ return; ++ ++ mutex_lock(&instance_mutex); ++ list_for_each_entry(cur, &mtk_pcs_lynxi_instances, node) ++ if (pcs == &cur->pcs) { ++ mpcs = cur; ++ break; ++ } ++ mutex_unlock(&instance_mutex); ++ ++ if (WARN_ON(!mpcs)) ++ return; ++ ++ put_device(mpcs->dev); ++} ++EXPORT_SYMBOL(mtk_pcs_lynxi_put); ++ ++static struct platform_driver mtk_pcs_lynxi_driver = { ++ .driver = { ++ .name = "mtk-pcs-lynxi", ++ .suppress_bind_attrs = true, ++ .of_match_table = mtk_pcs_lynxi_of_match, ++ }, ++ .probe = mtk_pcs_lynxi_probe, ++ .remove_new = mtk_pcs_lynxi_remove, ++}; ++module_platform_driver(mtk_pcs_lynxi_driver); ++ ++MODULE_AUTHOR("Daniel Golle "); + MODULE_DESCRIPTION("MediaTek SGMII library for LynxI"); + MODULE_LICENSE("GPL"); +--- a/include/linux/pcs/pcs-mtk-lynxi.h ++++ b/include/linux/pcs/pcs-mtk-lynxi.h +@@ -10,4 +10,15 @@ struct phylink_pcs *mtk_pcs_lynxi_create + struct regmap *regmap, + u32 ana_rgc3, u32 flags); + void mtk_pcs_lynxi_destroy(struct phylink_pcs *pcs); ++ ++#if IS_ENABLED(CONFIG_PCS_MTK_LYNXI) ++struct phylink_pcs *mtk_pcs_lynxi_get(struct device *dev, struct device_node *np); ++void mtk_pcs_lynxi_put(struct phylink_pcs *pcs); ++#else ++static inline struct phylink_pcs *mtk_pcs_lynxi_get(struct device *dev, struct device_node *np) ++{ ++ return NULL; ++} ++static inline void mtk_pcs_lynxi_put(struct phylink_pcs *pcs) { } ++#endif /* IS_ENABLED(CONFIG_PCS_MTK_LYNXI) */ + #endif diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-04-dt-bindings-net-pcs-add-bindings-for-MediaTek-USXGMI.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-04-dt-bindings-net-pcs-add-bindings-for-MediaTek-USXGMI.patch new file mode 100755 index 0000000..215bd2c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-04-dt-bindings-net-pcs-add-bindings-for-MediaTek-USXGMI.patch @@ -0,0 +1,81 @@ +From 7d88d79c0f65b27a92754d7547f7af098b3de67b Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 12 Dec 2023 03:47:31 +0000 +Subject: [PATCH 4/5] dt-bindings: net: pcs: add bindings for MediaTek USXGMII + PCS + +MediaTek's USXGMII can be found in the MT7988 SoC. We need to access +it in order to configure and monitor the Ethernet SerDes link in +USXGMII, 10GBase-R and 5GBase-R mode. By including a wrapped +legacy 1000Base-X/2500Base-X/Cisco SGMII LynxI PCS as well, those +interface modes are also available. + +Signed-off-by: Daniel Golle +--- + .../bindings/net/pcs/mediatek,usxgmii.yaml | 60 +++++++++++++++++++ + 1 file changed, 60 insertions(+) + create mode 100644 Documentation/devicetree/bindings/net/pcs/mediatek,usxgmii.yaml + +--- /dev/null ++++ b/Documentation/devicetree/bindings/net/pcs/mediatek,usxgmii.yaml +@@ -0,0 +1,60 @@ ++# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/net/pcs/mediatek,usxgmii.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: MediaTek USXGMII PCS ++ ++maintainers: ++ - Daniel Golle ++ ++description: ++ The MediaTek USXGMII PCS provides physical link control and status ++ for USXGMII, 10GBase-R and 5GBase-R links on the SerDes interfaces ++ provided by the PEXTP PHY. ++ In order to also support legacy 2500Base-X, 1000Base-X and Cisco ++ SGMII an existing mediatek,*-sgmiisys LynxI PCS is wrapped to ++ provide those interfaces modes on the same SerDes interfaces shared ++ with the USXGMII PCS. ++ ++properties: ++ $nodename: ++ pattern: "^pcs@[0-9a-f]+$" ++ ++ compatible: ++ const: mediatek,mt7988-usxgmiisys ++ ++ reg: ++ maxItems: 1 ++ ++ clocks: ++ items: ++ - description: USXGMII top-level clock ++ ++ resets: ++ items: ++ - description: XFI reset ++ ++required: ++ - compatible ++ - reg ++ - clocks ++ - resets ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ #define MT7988_TOPRGU_XFI0_GRST 12 ++ soc { ++ #address-cells = <2>; ++ #size-cells = <2>; ++ usxgmiisys0: pcs@10080000 { ++ compatible = "mediatek,mt7988-usxgmiisys"; ++ reg = <0 0x10080000 0 0x1000>; ++ clocks = <&topckgen CLK_TOP_USXGMII_SBUS_0_SEL>; ++ resets = <&watchdog MT7988_TOPRGU_XFI0_GRST>; ++ }; ++ }; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-05-net-pcs-add-driver-for-MediaTek-USXGMII-PCS.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-05-net-pcs-add-driver-for-MediaTek-USXGMII-PCS.patch new file mode 100755 index 0000000..04790ce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/739-05-net-pcs-add-driver-for-MediaTek-USXGMII-PCS.patch @@ -0,0 +1,545 @@ +From dde0e95fff92e9f5009f3bea75278e0e34a48822 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Tue, 12 Dec 2023 03:47:47 +0000 +Subject: [PATCH 5/5] net: pcs: add driver for MediaTek USXGMII PCS + +Add driver for USXGMII PCS found in the MediaTek MT7988 SoC and supporting +USXGMII, 10GBase-R and 5GBase-R interface modes. + +Signed-off-by: Daniel Golle +--- + MAINTAINERS | 2 + + drivers/net/pcs/Kconfig | 11 + + drivers/net/pcs/Makefile | 1 + + drivers/net/pcs/pcs-mtk-usxgmii.c | 456 ++++++++++++++++++++++++++++ + include/linux/pcs/pcs-mtk-usxgmii.h | 27 ++ + 5 files changed, 497 insertions(+) + create mode 100644 drivers/net/pcs/pcs-mtk-usxgmii.c + create mode 100644 include/linux/pcs/pcs-mtk-usxgmii.h + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -14432,7 +14432,9 @@ M: Daniel Golle + L: netdev@vger.kernel.org + S: Maintained + F: drivers/net/pcs/pcs-mtk-lynxi.c ++F: drivers/net/pcs/pcs-mtk-usxgmii.c + F: include/linux/pcs/pcs-mtk-lynxi.h ++F: include/linux/pcs/pcs-mtk-usxgmii.h + + MEDIATEK ETHERNET PHY DRIVERS + M: Daniel Golle +--- a/drivers/net/pcs/Kconfig ++++ b/drivers/net/pcs/Kconfig +@@ -25,6 +25,17 @@ config PCS_MTK_LYNXI + This module provides helpers to phylink for managing the LynxI PCS + which is part of MediaTek's SoC and Ethernet switch ICs. + ++config PCS_MTK_USXGMII ++ tristate "MediaTek USXGMII PCS" ++ select PCS_MTK_LYNXI ++ select PHY_MTK_PEXTP ++ select PHYLINK ++ help ++ This module provides a driver for MediaTek's USXGMII PCS supporting ++ 10GBase-R, 5GBase-R and USXGMII interface modes. ++ 1000Base-X, 2500Base-X and Cisco SGMII are supported on the same ++ differential pairs via an embedded LynxI PHY. ++ + config PCS_RZN1_MIIC + tristate "Renesas RZ/N1 MII converter" + depends on OF && (ARCH_RZN1 || COMPILE_TEST) +--- a/drivers/net/pcs/Makefile ++++ b/drivers/net/pcs/Makefile +@@ -8,3 +8,4 @@ obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o + obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o + obj-$(CONFIG_PCS_MTK_LYNXI) += pcs-mtk-lynxi.o + obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o ++obj-$(CONFIG_PCS_MTK_USXGMII) += pcs-mtk-usxgmii.o +--- /dev/null ++++ b/drivers/net/pcs/pcs-mtk-usxgmii.c +@@ -0,0 +1,454 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2023 MediaTek Inc. ++ * Author: Henry Yen ++ * Daniel Golle ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* USXGMII subsystem config registers */ ++/* Register to control speed */ ++#define RG_PHY_TOP_SPEED_CTRL1 0x80c ++#define USXGMII_RATE_UPDATE_MODE BIT(31) ++#define USXGMII_MAC_CK_GATED BIT(29) ++#define USXGMII_IF_FORCE_EN BIT(28) ++#define USXGMII_RATE_ADAPT_MODE GENMASK(10, 8) ++#define USXGMII_RATE_ADAPT_MODE_X1 0 ++#define USXGMII_RATE_ADAPT_MODE_X2 1 ++#define USXGMII_RATE_ADAPT_MODE_X4 2 ++#define USXGMII_RATE_ADAPT_MODE_X10 3 ++#define USXGMII_RATE_ADAPT_MODE_X100 4 ++#define USXGMII_RATE_ADAPT_MODE_X5 5 ++#define USXGMII_RATE_ADAPT_MODE_X50 6 ++#define USXGMII_XFI_RX_MODE GENMASK(6, 4) ++#define USXGMII_XFI_TX_MODE GENMASK(2, 0) ++#define USXGMII_XFI_MODE_10G 0 ++#define USXGMII_XFI_MODE_5G 1 ++#define USXGMII_XFI_MODE_2P5G 3 ++ ++/* Register to control PCS AN */ ++#define RG_PCS_AN_CTRL0 0x810 ++#define USXGMII_AN_RESTART BIT(31) ++#define USXGMII_AN_SYNC_CNT GENMASK(30, 11) ++#define USXGMII_AN_ENABLE BIT(0) ++ ++#define RG_PCS_AN_CTRL2 0x818 ++#define USXGMII_LINK_TIMER_IDLE_DETECT GENMASK(29, 20) ++#define USXGMII_LINK_TIMER_COMP_ACK_DETECT GENMASK(19, 10) ++#define USXGMII_LINK_TIMER_AN_RESTART GENMASK(9, 0) ++ ++/* Register to read PCS AN status */ ++#define RG_PCS_AN_STS0 0x81c ++#define USXGMII_LPA GENMASK(15, 0) ++#define USXGMII_LPA_LATCH BIT(31) ++ ++/* Register to read PCS link status */ ++#define RG_PCS_RX_STATUS0 0x904 ++#define RG_PCS_RX_STATUS_UPDATE BIT(16) ++#define RG_PCS_RX_LINK_STATUS BIT(2) ++ ++/* struct mtk_usxgmii_pcs - This structure holds each usxgmii PCS ++ * @pcs: Phylink PCS structure ++ * @dev: Pointer to device structure ++ * @base: IO memory to access PCS hardware ++ * @clk: Pointer to USXGMII clk ++ * @reset: Pointer to USXGMII reset control ++ * @interface: Currently selected interface mode ++ * @neg_mode: Currently used phylink neg_mode ++ * @node: List node ++ */ ++struct mtk_usxgmii_pcs { ++ struct phylink_pcs pcs; ++ struct device *dev; ++ void __iomem *base; ++ struct clk *clk; ++ struct reset_control *reset; ++ phy_interface_t interface; ++ unsigned int neg_mode; ++ struct list_head node; ++}; ++ ++static LIST_HEAD(mtk_usxgmii_pcs_instances); ++static DEFINE_MUTEX(instance_mutex); ++ ++static u32 mtk_r32(struct mtk_usxgmii_pcs *mpcs, unsigned int reg) ++{ ++ return ioread32(mpcs->base + reg); ++} ++ ++static void mtk_m32(struct mtk_usxgmii_pcs *mpcs, unsigned int reg, u32 mask, u32 set) ++{ ++ u32 val; ++ ++ val = ioread32(mpcs->base + reg); ++ val &= ~mask; ++ val |= set; ++ iowrite32(val, mpcs->base + reg); ++} ++ ++static struct mtk_usxgmii_pcs *pcs_to_mtk_usxgmii_pcs(struct phylink_pcs *pcs) ++{ ++ return container_of(pcs, struct mtk_usxgmii_pcs, pcs); ++} ++ ++static void mtk_usxgmii_reset(struct mtk_usxgmii_pcs *mpcs) ++{ ++ reset_control_assert(mpcs->reset); ++ udelay(100); ++ reset_control_deassert(mpcs->reset); ++ ++ mdelay(10); ++} ++ ++static int mtk_usxgmii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, ++ phy_interface_t interface, ++ const unsigned long *advertising, ++ bool permit_pause_to_mac) ++{ ++ struct mtk_usxgmii_pcs *mpcs = pcs_to_mtk_usxgmii_pcs(pcs); ++ unsigned int an_ctrl = 0, link_timer = 0, xfi_mode = 0, adapt_mode = 0; ++ bool mode_changed = false; ++ ++ if (interface == PHY_INTERFACE_MODE_USXGMII) { ++ an_ctrl = FIELD_PREP(USXGMII_AN_SYNC_CNT, 0x1FF) | USXGMII_AN_ENABLE; ++ link_timer = FIELD_PREP(USXGMII_LINK_TIMER_IDLE_DETECT, 0x7B) | ++ FIELD_PREP(USXGMII_LINK_TIMER_COMP_ACK_DETECT, 0x7B) | ++ FIELD_PREP(USXGMII_LINK_TIMER_AN_RESTART, 0x7B); ++ xfi_mode = FIELD_PREP(USXGMII_XFI_RX_MODE, USXGMII_XFI_MODE_10G) | ++ FIELD_PREP(USXGMII_XFI_TX_MODE, USXGMII_XFI_MODE_10G); ++ } else if (interface == PHY_INTERFACE_MODE_10GBASER) { ++ an_ctrl = FIELD_PREP(USXGMII_AN_SYNC_CNT, 0x1FF); ++ link_timer = FIELD_PREP(USXGMII_LINK_TIMER_IDLE_DETECT, 0x7B) | ++ FIELD_PREP(USXGMII_LINK_TIMER_COMP_ACK_DETECT, 0x7B) | ++ FIELD_PREP(USXGMII_LINK_TIMER_AN_RESTART, 0x7B); ++ xfi_mode = FIELD_PREP(USXGMII_XFI_RX_MODE, USXGMII_XFI_MODE_10G) | ++ FIELD_PREP(USXGMII_XFI_TX_MODE, USXGMII_XFI_MODE_10G); ++ adapt_mode = USXGMII_RATE_UPDATE_MODE; ++ } else if (interface == PHY_INTERFACE_MODE_5GBASER) { ++ an_ctrl = FIELD_PREP(USXGMII_AN_SYNC_CNT, 0xFF); ++ link_timer = FIELD_PREP(USXGMII_LINK_TIMER_IDLE_DETECT, 0x3D) | ++ FIELD_PREP(USXGMII_LINK_TIMER_COMP_ACK_DETECT, 0x3D) | ++ FIELD_PREP(USXGMII_LINK_TIMER_AN_RESTART, 0x3D); ++ xfi_mode = FIELD_PREP(USXGMII_XFI_RX_MODE, USXGMII_XFI_MODE_5G) | ++ FIELD_PREP(USXGMII_XFI_TX_MODE, USXGMII_XFI_MODE_5G); ++ adapt_mode = USXGMII_RATE_UPDATE_MODE; ++ } else { ++ return -EINVAL; ++ } ++ ++ adapt_mode |= FIELD_PREP(USXGMII_RATE_ADAPT_MODE, USXGMII_RATE_ADAPT_MODE_X1); ++ ++ if (mpcs->interface != interface) { ++ mpcs->interface = interface; ++ mode_changed = true; ++ } ++ ++ mtk_usxgmii_reset(mpcs); ++ ++ /* Setup USXGMII AN ctrl */ ++ mtk_m32(mpcs, RG_PCS_AN_CTRL0, ++ USXGMII_AN_SYNC_CNT | USXGMII_AN_ENABLE, ++ an_ctrl); ++ ++ mtk_m32(mpcs, RG_PCS_AN_CTRL2, ++ USXGMII_LINK_TIMER_IDLE_DETECT | ++ USXGMII_LINK_TIMER_COMP_ACK_DETECT | ++ USXGMII_LINK_TIMER_AN_RESTART, ++ link_timer); ++ ++ mpcs->neg_mode = neg_mode; ++ ++ /* Gated MAC CK */ ++ mtk_m32(mpcs, RG_PHY_TOP_SPEED_CTRL1, ++ USXGMII_MAC_CK_GATED, USXGMII_MAC_CK_GATED); ++ ++ /* Enable interface force mode */ ++ mtk_m32(mpcs, RG_PHY_TOP_SPEED_CTRL1, ++ USXGMII_IF_FORCE_EN, USXGMII_IF_FORCE_EN); ++ ++ /* Setup USXGMII adapt mode */ ++ mtk_m32(mpcs, RG_PHY_TOP_SPEED_CTRL1, ++ USXGMII_RATE_UPDATE_MODE | USXGMII_RATE_ADAPT_MODE, ++ adapt_mode); ++ ++ /* Setup USXGMII speed */ ++ mtk_m32(mpcs, RG_PHY_TOP_SPEED_CTRL1, ++ USXGMII_XFI_RX_MODE | USXGMII_XFI_TX_MODE, ++ xfi_mode); ++ ++ usleep_range(1, 10); ++ ++ /* Un-gated MAC CK */ ++ mtk_m32(mpcs, RG_PHY_TOP_SPEED_CTRL1, USXGMII_MAC_CK_GATED, 0); ++ ++ usleep_range(1, 10); ++ ++ /* Disable interface force mode for the AN mode */ ++ if (an_ctrl & USXGMII_AN_ENABLE) ++ mtk_m32(mpcs, RG_PHY_TOP_SPEED_CTRL1, USXGMII_IF_FORCE_EN, 0); ++ ++ return mode_changed; ++} ++ ++static void mtk_usxgmii_pcs_get_fixed_speed(struct mtk_usxgmii_pcs *mpcs, ++ struct phylink_link_state *state) ++{ ++ u32 val = mtk_r32(mpcs, RG_PHY_TOP_SPEED_CTRL1); ++ int speed; ++ ++ /* Calculate speed from interface speed and rate adapt mode */ ++ switch (FIELD_GET(USXGMII_XFI_RX_MODE, val)) { ++ case USXGMII_XFI_MODE_10G: ++ speed = 10000; ++ break; ++ case USXGMII_XFI_MODE_5G: ++ speed = 5000; ++ break; ++ case USXGMII_XFI_MODE_2P5G: ++ speed = 2500; ++ break; ++ default: ++ state->speed = SPEED_UNKNOWN; ++ return; ++ } ++ ++ switch (FIELD_GET(USXGMII_RATE_ADAPT_MODE, val)) { ++ case USXGMII_RATE_ADAPT_MODE_X100: ++ speed /= 100; ++ break; ++ case USXGMII_RATE_ADAPT_MODE_X50: ++ speed /= 50; ++ break; ++ case USXGMII_RATE_ADAPT_MODE_X10: ++ speed /= 10; ++ break; ++ case USXGMII_RATE_ADAPT_MODE_X5: ++ speed /= 5; ++ break; ++ case USXGMII_RATE_ADAPT_MODE_X4: ++ speed /= 4; ++ break; ++ case USXGMII_RATE_ADAPT_MODE_X2: ++ speed /= 2; ++ break; ++ case USXGMII_RATE_ADAPT_MODE_X1: ++ break; ++ default: ++ state->speed = SPEED_UNKNOWN; ++ return; ++ } ++ ++ state->speed = speed; ++ state->duplex = DUPLEX_FULL; ++} ++ ++static void mtk_usxgmii_pcs_get_an_state(struct mtk_usxgmii_pcs *mpcs, ++ struct phylink_link_state *state) ++{ ++ u16 lpa; ++ ++ /* Refresh LPA by toggling LPA_LATCH */ ++ mtk_m32(mpcs, RG_PCS_AN_STS0, USXGMII_LPA_LATCH, USXGMII_LPA_LATCH); ++ ndelay(1020); ++ mtk_m32(mpcs, RG_PCS_AN_STS0, USXGMII_LPA_LATCH, 0); ++ ndelay(1020); ++ lpa = FIELD_GET(USXGMII_LPA, mtk_r32(mpcs, RG_PCS_AN_STS0)); ++ ++ phylink_decode_usxgmii_word(state, lpa); ++} ++ ++static void mtk_usxgmii_pcs_get_state(struct phylink_pcs *pcs, ++ struct phylink_link_state *state) ++{ ++ struct mtk_usxgmii_pcs *mpcs = pcs_to_mtk_usxgmii_pcs(pcs); ++ ++ /* Refresh USXGMII link status by toggling RG_PCS_AN_STATUS_UPDATE */ ++ mtk_m32(mpcs, RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE, ++ RG_PCS_RX_STATUS_UPDATE); ++ ndelay(1020); ++ mtk_m32(mpcs, RG_PCS_RX_STATUS0, RG_PCS_RX_STATUS_UPDATE, 0); ++ ndelay(1020); ++ ++ /* Read USXGMII link status */ ++ state->link = FIELD_GET(RG_PCS_RX_LINK_STATUS, ++ mtk_r32(mpcs, RG_PCS_RX_STATUS0)); ++ ++ /* Continuously repeat re-configuration sequence until link comes up */ ++ if (!state->link) { ++ mtk_usxgmii_pcs_config(pcs, mpcs->neg_mode, ++ state->interface, NULL, false); ++ return; ++ } ++ ++ if (FIELD_GET(USXGMII_AN_ENABLE, mtk_r32(mpcs, RG_PCS_AN_CTRL0))) ++ mtk_usxgmii_pcs_get_an_state(mpcs, state); ++ else ++ mtk_usxgmii_pcs_get_fixed_speed(mpcs, state); ++} ++ ++static void mtk_usxgmii_pcs_restart_an(struct phylink_pcs *pcs) ++{ ++ struct mtk_usxgmii_pcs *mpcs = pcs_to_mtk_usxgmii_pcs(pcs); ++ ++ mtk_m32(mpcs, RG_PCS_AN_CTRL0, USXGMII_AN_RESTART, USXGMII_AN_RESTART); ++} ++ ++static void mtk_usxgmii_pcs_link_up(struct phylink_pcs *pcs, unsigned int neg_mode, ++ phy_interface_t interface, ++ int speed, int duplex) ++{ ++ /* Reconfiguring USXGMII to ensure the quality of the RX signal ++ * after the line side link up. ++ */ ++ mtk_usxgmii_pcs_config(pcs, neg_mode, interface, NULL, false); ++} ++ ++static void mtk_usxgmii_pcs_disable(struct phylink_pcs *pcs) ++{ ++ struct mtk_usxgmii_pcs *mpcs = pcs_to_mtk_usxgmii_pcs(pcs); ++ ++ mpcs->interface = PHY_INTERFACE_MODE_NA; ++ mpcs->neg_mode = -1; ++} ++ ++static const struct phylink_pcs_ops mtk_usxgmii_pcs_ops = { ++ .pcs_config = mtk_usxgmii_pcs_config, ++ .pcs_get_state = mtk_usxgmii_pcs_get_state, ++ .pcs_an_restart = mtk_usxgmii_pcs_restart_an, ++ .pcs_link_up = mtk_usxgmii_pcs_link_up, ++ .pcs_disable = mtk_usxgmii_pcs_disable, ++}; ++ ++static int mtk_usxgmii_probe(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct mtk_usxgmii_pcs *mpcs; ++ ++ mpcs = devm_kzalloc(dev, sizeof(*mpcs), GFP_KERNEL); ++ if (!mpcs) ++ return -ENOMEM; ++ ++ mpcs->base = devm_platform_ioremap_resource(pdev, 0); ++ if (IS_ERR(mpcs->base)) ++ return PTR_ERR(mpcs->base); ++ ++ mpcs->dev = dev; ++ mpcs->pcs.ops = &mtk_usxgmii_pcs_ops; ++ mpcs->pcs.poll = true; ++ mpcs->pcs.neg_mode = true; ++ mpcs->interface = PHY_INTERFACE_MODE_NA; ++ mpcs->neg_mode = -1; ++ ++ mpcs->clk = devm_clk_get_enabled(mpcs->dev, NULL); ++ if (IS_ERR(mpcs->clk)) ++ return PTR_ERR(mpcs->clk); ++ ++ mpcs->reset = devm_reset_control_get_shared(dev, NULL); ++ if (IS_ERR(mpcs->reset)) ++ return PTR_ERR(mpcs->reset); ++ ++ reset_control_deassert(mpcs->reset); ++ ++ platform_set_drvdata(pdev, mpcs); ++ ++ mutex_lock(&instance_mutex); ++ list_add_tail(&mpcs->node, &mtk_usxgmii_pcs_instances); ++ mutex_unlock(&instance_mutex); ++ ++ return 0; ++} ++ ++static void mtk_usxgmii_remove(struct platform_device *pdev) ++{ ++ struct device *dev = &pdev->dev; ++ struct mtk_usxgmii_pcs *cur, *tmp; ++ ++ mutex_lock(&instance_mutex); ++ list_for_each_entry_safe(cur, tmp, &mtk_usxgmii_pcs_instances, node) ++ if (cur->dev == dev) { ++ list_del(&cur->node); ++ break; ++ } ++ mutex_unlock(&instance_mutex); ++} ++ ++static const struct of_device_id mtk_usxgmii_of_mtable[] = { ++ { .compatible = "mediatek,mt7988-usxgmiisys" }, ++ { /* sentinel */ }, ++}; ++MODULE_DEVICE_TABLE(of, mtk_usxgmii_of_mtable); ++ ++struct phylink_pcs *mtk_usxgmii_pcs_get(struct device *dev, struct device_node *np) ++{ ++ struct platform_device *pdev; ++ struct mtk_usxgmii_pcs *mpcs; ++ ++ if (!np) ++ return NULL; ++ ++ if (!of_device_is_available(np)) ++ return ERR_PTR(-ENODEV); ++ ++ if (!of_match_node(mtk_usxgmii_of_mtable, np)) ++ return ERR_PTR(-EINVAL); ++ ++ pdev = of_find_device_by_node(np); ++ if (!pdev || !platform_get_drvdata(pdev)) { ++ if (pdev) ++ put_device(&pdev->dev); ++ return ERR_PTR(-EPROBE_DEFER); ++ } ++ ++ mpcs = platform_get_drvdata(pdev); ++ device_link_add(dev, mpcs->dev, DL_FLAG_AUTOREMOVE_CONSUMER); ++ ++ return &mpcs->pcs; ++} ++EXPORT_SYMBOL(mtk_usxgmii_pcs_get); ++ ++void mtk_usxgmii_pcs_put(struct phylink_pcs *pcs) ++{ ++ struct mtk_usxgmii_pcs *cur, *mpcs = NULL; ++ ++ if (!pcs) ++ return; ++ ++ mutex_lock(&instance_mutex); ++ list_for_each_entry(cur, &mtk_usxgmii_pcs_instances, node) ++ if (pcs == &cur->pcs) { ++ mpcs = cur; ++ break; ++ } ++ mutex_unlock(&instance_mutex); ++ ++ if (WARN_ON(!mpcs)) ++ return; ++ ++ put_device(mpcs->dev); ++} ++EXPORT_SYMBOL(mtk_usxgmii_pcs_put); ++ ++static struct platform_driver mtk_usxgmii_driver = { ++ .driver = { ++ .name = "mtk_usxgmii", ++ .suppress_bind_attrs = true, ++ .of_match_table = mtk_usxgmii_of_mtable, ++ }, ++ .probe = mtk_usxgmii_probe, ++ .remove_new = mtk_usxgmii_remove, ++}; ++module_platform_driver(mtk_usxgmii_driver); ++ ++MODULE_LICENSE("GPL"); ++MODULE_DESCRIPTION("MediaTek USXGMII PCS driver"); ++MODULE_AUTHOR("Daniel Golle "); +--- /dev/null ++++ b/include/linux/pcs/pcs-mtk-usxgmii.h +@@ -0,0 +1,27 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef __LINUX_PCS_MTK_USXGMII_H ++#define __LINUX_PCS_MTK_USXGMII_H ++ ++#include ++ ++/** ++ * mtk_usxgmii_select_pcs() - Get MediaTek PCS instance ++ * @np: Pointer to device node indentifying a MediaTek USXGMII PCS ++ * @mode: Ethernet PHY interface mode ++ * ++ * Return PCS identified by a device node and the PHY interface mode in use ++ * ++ * Return: Pointer to phylink PCS instance of NULL ++ */ ++#if IS_ENABLED(CONFIG_PCS_MTK_USXGMII) ++struct phylink_pcs *mtk_usxgmii_pcs_get(struct device *dev, struct device_node *np); ++void mtk_usxgmii_pcs_put(struct phylink_pcs *pcs); ++#else ++static inline struct phylink_pcs *mtk_usxgmii_pcs_get(struct device *dev, struct device_node *np) ++{ ++ return NULL; ++} ++static inline void mtk_usxgmii_pcs_put(struct phylink_pcs *pcs) { } ++#endif /* IS_ENABLED(CONFIG_PCS_MTK_USXGMII) */ ++ ++#endif /* __LINUX_PCS_MTK_USXGMII_H */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/740-net-phy-motorcomm-Add-missing-include.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/740-net-phy-motorcomm-Add-missing-include.patch new file mode 100755 index 0000000..2a1f908 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/740-net-phy-motorcomm-Add-missing-include.patch @@ -0,0 +1,22 @@ +From 6f291aa7da199c6486cc229b055dcbcd5cee7a21 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 21 May 2023 22:24:56 +0200 +Subject: [PATCH] net: phy: motorcomm: Add missing include + +Directly include linux/bitfield.h which provides FIELD_PREP. + +Signed-off-by: Hauke Mehrtens +--- + drivers/net/phy/motorcomm.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/net/phy/motorcomm.c ++++ b/drivers/net/phy/motorcomm.c +@@ -6,6 +6,7 @@ + * Author: Frank + */ + ++#include + #include + #include + #include diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/741-net-phy-broadcom-update-dependency-condition.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/741-net-phy-broadcom-update-dependency-condition.patch new file mode 100755 index 0000000..7a52bd5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/741-net-phy-broadcom-update-dependency-condition.patch @@ -0,0 +1,35 @@ +From 1be3688b3eaa7ea2d9e19bd29ae6a6a51c121a0b Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Sat, 16 Nov 2024 22:36:15 +0100 +Subject: [PATCH] net: phy: broadcom: update dependency condition + +The broadcom PHY driver only has to depend upon PTP_1588_CLOCK_OPTIONAL +if NETWORK_PHY_TIMESTAMPING is enabled. The PTP functionality is stubbed +in this case. + +Reflect this circumstance in the dependence condition. This allows to +build the driver as a built-in module even if PTP is built as a module. + +This is required to include the broadcom PHY module regardless of the +built-setting of the PTP subsystem. On ath79 (and probably more) +targets with Broadcom PHY, Gigabit operation is currently broken as the +PHY driver is only built as a module in case all kernel-packages are +built. Due to this circumstance, affected devices fall back to using the +generic PHY driver. + +Signed-off-by: David Bauer +--- + drivers/net/phy/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -151,7 +151,7 @@ config BROADCOM_PHY + tristate "Broadcom 54XX PHYs" + select BCM_NET_PHYLIB + select BCM_NET_PHYPTP if NETWORK_PHY_TIMESTAMPING +- depends on PTP_1588_CLOCK_OPTIONAL ++ depends on NETWORK_PHY_TIMESTAMPING=n || PTP_1588_CLOCK_OPTIONAL + help + Currently supports the BCM5411, BCM5421, BCM5461, BCM54616S, BCM5464, + BCM5481, BCM54810 and BCM5482 PHYs. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/780-ARM-kirkwood-add-missing-linux-if_ether.h-for-ETH_AL.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/780-ARM-kirkwood-add-missing-linux-if_ether.h-for-ETH_AL.patch new file mode 100755 index 0000000..39ba716 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/780-ARM-kirkwood-add-missing-linux-if_ether.h-for-ETH_AL.patch @@ -0,0 +1,61 @@ +From patchwork Thu Aug 5 22:23:30 2021 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12422209 +Date: Thu, 5 Aug 2021 23:23:30 +0100 +From: Daniel Golle +To: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, + linux-kernel@vger.kernel.org +Cc: "David S. Miller" , Andrew Lunn , + Michael Walle +Subject: [PATCH] ARM: kirkwood: add missing for ETH_ALEN +Message-ID: +MIME-Version: 1.0 +Content-Disposition: inline +X-BeenThere: linux-arm-kernel@lists.infradead.org +X-Mailman-Version: 2.1.34 +Precedence: list +List-Id: +List-Archive: +Sender: "linux-arm-kernel" + +After commit 83216e3988cd1 ("of: net: pass the dst buffer to +of_get_mac_address()") build fails for kirkwood as ETH_ALEN is not +defined. + +arch/arm/mach-mvebu/kirkwood.c: In function 'kirkwood_dt_eth_fixup': +arch/arm/mach-mvebu/kirkwood.c:87:13: error: 'ETH_ALEN' undeclared (first use in this function); did you mean 'ESTALE'? + u8 tmpmac[ETH_ALEN]; + ^~~~~~~~ + ESTALE +arch/arm/mach-mvebu/kirkwood.c:87:13: note: each undeclared identifier is reported only once for each function it appears in +arch/arm/mach-mvebu/kirkwood.c:87:6: warning: unused variable 'tmpmac' [-Wunused-variable] + u8 tmpmac[ETH_ALEN]; + ^~~~~~ +make[5]: *** [scripts/Makefile.build:262: arch/arm/mach-mvebu/kirkwood.o] Error 1 +make[5]: *** Waiting for unfinished jobs.... + +Add missing #include to fix this. + +Cc: David S. Miller +Cc: Andrew Lunn +Cc: Michael Walle +Reported-by: https://buildbot.openwrt.org/master/images/#/builders/56/builds/220/steps/44/logs/stdio +Fixes: 83216e3988cd1 ("of: net: pass the dst buffer to of_get_mac_address()") +Signed-off-by: Daniel Golle +--- + arch/arm/mach-mvebu/kirkwood.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/arm/mach-mvebu/kirkwood.c ++++ b/arch/arm/mach-mvebu/kirkwood.c +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/790-bus-mhi-core-add-SBL-state-callback.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/790-bus-mhi-core-add-SBL-state-callback.patch new file mode 100755 index 0000000..80d1306 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/790-bus-mhi-core-add-SBL-state-callback.patch @@ -0,0 +1,48 @@ +From 5f7c5e1c0d7a79be144e5efc1f24728ddd7fc25c Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Sat, 5 Nov 2022 20:02:56 +0100 +Subject: [PATCH 1/2] bus: mhi: core: add SBL state callback + +Add support for SBL state callback in MHI core. + +It is required for ath11k MHI devices in order to be able to set QRTR +instance ID in the SBL state so that QRTR instance ID-s dont conflict in +case of multiple PCI/MHI cards or AHB + PCI/MHI card. +Setting QRTR instance ID is only possible in SBL state and there is +currently no way to ensure that we are in that state, so provide a +callback that the controller can trigger off. + +Signed-off-by: Robert Marko +--- + drivers/bus/mhi/host/main.c | 1 + + include/linux/mhi.h | 2 ++ + 2 files changed, 3 insertions(+) + +--- a/drivers/bus/mhi/host/main.c ++++ b/drivers/bus/mhi/host/main.c +@@ -916,6 +916,7 @@ int mhi_process_ctrl_ev_ring(struct mhi_ + switch (event) { + case MHI_EE_SBL: + st = DEV_ST_TRANSITION_SBL; ++ mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_SBL_MODE); + break; + case MHI_EE_WFW: + case MHI_EE_AMSS: +--- a/include/linux/mhi.h ++++ b/include/linux/mhi.h +@@ -34,6 +34,7 @@ struct mhi_buf_info; + * @MHI_CB_SYS_ERROR: MHI device entered error state (may recover) + * @MHI_CB_FATAL_ERROR: MHI device entered fatal error state + * @MHI_CB_BW_REQ: Received a bandwidth switch request from device ++ * @MHI_CB_EE_SBL_MODE: MHI device entered SBL mode + */ + enum mhi_callback { + MHI_CB_IDLE, +@@ -45,6 +46,7 @@ enum mhi_callback { + MHI_CB_SYS_ERROR, + MHI_CB_FATAL_ERROR, + MHI_CB_BW_REQ, ++ MHI_CB_EE_SBL_MODE, + }; + + /** diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/791-tg3-Fix-DMA-allocations-on-57766-devices.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/791-tg3-Fix-DMA-allocations-on-57766-devices.patch new file mode 100755 index 0000000..5181041 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/791-tg3-Fix-DMA-allocations-on-57766-devices.patch @@ -0,0 +1,31 @@ +From f992b15965177e2f280fb6f41f292214f9a6f8d5 Mon Sep 17 00:00:00 2001 +From: Pavan Chebbi +Date: Tue, 10 Dec 2024 03:28:31 -0800 +Subject: [PATCH] tg3: Fix DMA allocations on 57766 devices + +The coherent DMA mask of 31b may not be accepted if +the DMA mask is configured to use higher memories of +64b. Set the DMA mask also to lower 32b for 57766 +devices. + +Fixes: 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets") +Reported-By: Rui Salvaterra +Signed-off-by: Pavan Chebbi +--- + drivers/net/ethernet/broadcom/tg3.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/broadcom/tg3.c ++++ b/drivers/net/ethernet/broadcom/tg3.c +@@ -17799,8 +17799,10 @@ static int tg3_init_one(struct pci_dev * + } else + persist_dma_mask = dma_mask = DMA_BIT_MASK(64); + +- if (tg3_asic_rev(tp) == ASIC_REV_57766) ++ if (tg3_asic_rev(tp) == ASIC_REV_57766) { ++ dma_mask = DMA_BIT_MASK(32); + persist_dma_mask = DMA_BIT_MASK(31); ++ } + + /* Configure DMA attributes. */ + if (dma_mask > DMA_BIT_MASK(32)) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/800-bcma-get-SoC-device-struct-copy-its-DMA-params-to-th.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/800-bcma-get-SoC-device-struct-copy-its-DMA-params-to-th.patch new file mode 100755 index 0000000..4a9c188 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/800-bcma-get-SoC-device-struct-copy-its-DMA-params-to-th.patch @@ -0,0 +1,73 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Subject: [PATCH] bcma: get SoC device struct & copy its DMA params to the + subdevices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For bus devices to be fully usable it's required to set their DMA +parameters. + +For years it has been missing and remained unnoticed because of +mips_dma_alloc_coherent() silently handling the empty coherent_dma_mask. +Kernel 4.19 came with a lot of DMA changes and caused a regression on +the bcm47xx. Starting with the commit f8c55dc6e828 ("MIPS: use generic +dma noncoherent ops for simple noncoherent platforms") DMA coherent +allocations just fail. Example: +[ 1.114914] bgmac_bcma bcma0:2: Allocation of TX ring 0x200 failed +[ 1.121215] bgmac_bcma bcma0:2: Unable to alloc memory for DMA +[ 1.127626] bgmac_bcma: probe of bcma0:2 failed with error -12 +[ 1.133838] bgmac_bcma: Broadcom 47xx GBit MAC driver loaded + +This change fixes above regression in addition to the MIPS bcm47xx +commit 321c46b91550 ("MIPS: BCM47XX: Setup struct device for the SoC"). + +It also fixes another *old* GPIO regression caused by a parent pointing +to the NULL: +[ 0.157054] missing gpiochip .dev parent pointer +[ 0.157287] bcma: bus0: Error registering GPIO driver: -22 +introduced by the commit 74f4e0cc6108 ("bcma: switch GPIO portions to +use GPIOLIB_IRQCHIP"). + +Fixes: f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms") +Fixes: 74f4e0cc6108 ("bcma: switch GPIO portions to use GPIOLIB_IRQCHIP") +Cc: linux-mips@linux-mips.org +Cc: Christoph Hellwig +Cc: Linus Walleij +Signed-off-by: RafaΕ‚ MiΕ‚ecki +--- + +--- a/drivers/bcma/host_soc.c ++++ b/drivers/bcma/host_soc.c +@@ -191,6 +191,8 @@ int __init bcma_host_soc_init(struct bcm + struct bcma_bus *bus = &soc->bus; + int err; + ++ bus->dev = soc->dev; ++ + /* Scan bus and initialize it */ + err = bcma_bus_early_register(bus); + if (err) +--- a/drivers/bcma/main.c ++++ b/drivers/bcma/main.c +@@ -237,13 +237,17 @@ EXPORT_SYMBOL(bcma_core_irq); + + void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core) + { +- device_initialize(&core->dev); ++ struct device *dev = &core->dev; ++ ++ device_initialize(dev); + core->dev.release = bcma_release_core_dev; + core->dev.bus = &bcma_bus_type; +- dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index); ++ dev_set_name(dev, "bcma%d:%d", bus->num, core->core_index); + core->dev.parent = bus->dev; +- if (bus->dev) ++ if (bus->dev) { + bcma_of_fill_device(bus->dev, core); ++ dma_coerce_mask_and_coherent(dev, bus->dev->coherent_dma_mask); ++ } + + switch (bus->hosttype) { + case BCMA_HOSTTYPE_PCI: diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/802-OPP-Provide-old-opp-to-config_clks-on-_set_opp.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/802-OPP-Provide-old-opp-to-config_clks-on-_set_opp.patch new file mode 100755 index 0000000..042afdc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/802-OPP-Provide-old-opp-to-config_clks-on-_set_opp.patch @@ -0,0 +1,134 @@ +From fd59b838dd90452f61a17dc9e5ff175205003068 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Thu, 15 Sep 2022 18:49:43 +0200 +Subject: [PATCH] OPP: Provide old opp to config_clks on _set_opp + +With the target opp, also pass the old opp to config_clks function. +This can be useful when a driver needs to take decision on what fequency +to set based on what is the current frequency without using a +clk_get_freq call. +Update the only user of custom config_clks (tegra30 devfreq driver) to +this new implementation. + +Signed-off-by: Christian Marangi +--- + drivers/devfreq/tegra30-devfreq.c | 5 +++-- + drivers/opp/core.c | 11 ++++++----- + include/linux/pm_opp.h | 11 ++++++----- + 3 files changed, 15 insertions(+), 12 deletions(-) + +--- a/drivers/devfreq/tegra30-devfreq.c ++++ b/drivers/devfreq/tegra30-devfreq.c +@@ -823,8 +823,9 @@ static int devm_tegra_devfreq_init_hw(st + + static int tegra_devfreq_config_clks_nop(struct device *dev, + struct opp_table *opp_table, +- struct dev_pm_opp *opp, void *data, +- bool scaling_down) ++ struct dev_pm_opp *old_opp, ++ struct dev_pm_opp *opp, ++ void *data, bool scaling_down) + { + /* We want to skip clk configuration via dev_pm_opp_set_opp() */ + return 0; +--- a/drivers/opp/core.c ++++ b/drivers/opp/core.c +@@ -965,7 +965,8 @@ static int _set_opp_voltage(struct devic + + static int + _opp_config_clk_single(struct device *dev, struct opp_table *opp_table, +- struct dev_pm_opp *opp, void *data, bool scaling_down) ++ struct dev_pm_opp *old_opp, struct dev_pm_opp *opp, ++ void *data, bool scaling_down) + { + unsigned long *target = data; + unsigned long freq; +@@ -997,8 +998,8 @@ _opp_config_clk_single(struct device *de + * the order in which they are present in the array while scaling up. + */ + int dev_pm_opp_config_clks_simple(struct device *dev, +- struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, +- bool scaling_down) ++ struct opp_table *opp_table, struct dev_pm_opp *old_opp, ++ struct dev_pm_opp *opp, void *data, bool scaling_down) + { + int ret, i; + +@@ -1265,7 +1266,7 @@ static int _set_opp(struct device *dev, + } + + if (opp_table->config_clks) { +- ret = opp_table->config_clks(dev, opp_table, opp, clk_data, scaling_down); ++ ret = opp_table->config_clks(dev, opp_table, old_opp, opp, clk_data, scaling_down); + if (ret) + return ret; + } +@@ -1344,7 +1345,7 @@ int dev_pm_opp_set_rate(struct device *d + * equivalent to a clk_set_rate() + */ + if (!_get_opp_count(opp_table)) { +- ret = opp_table->config_clks(dev, opp_table, NULL, ++ ret = opp_table->config_clks(dev, opp_table, NULL, NULL, + &target_freq, false); + goto put_opp_table; + } +--- a/drivers/ufs/core/ufshcd.c ++++ b/drivers/ufs/core/ufshcd.c +@@ -1122,8 +1122,8 @@ out: + } + + int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table, +- struct dev_pm_opp *opp, void *data, +- bool scaling_down) ++ struct dev_pm_opp *old_opp, struct dev_pm_opp *opp, ++ void *data, bool scaling_down) + { + struct ufs_hba *hba = dev_get_drvdata(dev); + struct list_head *head = &hba->clk_list_head; +--- a/include/linux/pm_opp.h ++++ b/include/linux/pm_opp.h +@@ -50,7 +50,8 @@ typedef int (*config_regulators_t)(struc + struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, + struct regulator **regulators, unsigned int count); + +-typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_table, ++typedef int (*config_clks_t)(struct device *dev, ++ struct opp_table *opp_table, struct dev_pm_opp *old_opp, + struct dev_pm_opp *opp, void *data, bool scaling_down); + + /** +@@ -184,8 +185,8 @@ int dev_pm_opp_set_config(struct device + int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *config); + void dev_pm_opp_clear_config(int token); + int dev_pm_opp_config_clks_simple(struct device *dev, +- struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, +- bool scaling_down); ++ struct opp_table *opp_table, struct dev_pm_opp *old_opp, ++ struct dev_pm_opp *opp, void *data, bool scaling_down); + + struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp); + int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); +@@ -395,8 +396,8 @@ static inline int devm_pm_opp_set_config + static inline void dev_pm_opp_clear_config(int token) {} + + static inline int dev_pm_opp_config_clks_simple(struct device *dev, +- struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, +- bool scaling_down) ++ struct opp_table *opp_table, struct dev_pm_opp *old_opp, ++ struct dev_pm_opp *opp, void *data, bool scaling_down) + { + return -EOPNOTSUPP; + } +--- a/include/ufs/ufshcd.h ++++ b/include/ufs/ufshcd.h +@@ -1333,8 +1333,8 @@ void ufshcd_mcq_enable(struct ufs_hba *h + void ufshcd_mcq_config_esi(struct ufs_hba *hba, struct msi_msg *msg); + + int ufshcd_opp_config_clks(struct device *dev, struct opp_table *opp_table, +- struct dev_pm_opp *opp, void *data, +- bool scaling_down); ++ struct dev_pm_opp *old_opp, struct dev_pm_opp *opp, ++ void *data, bool scaling_down); + /** + * ufshcd_set_variant - set variant specific data to the hba + * @hba: per adapter instance diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/804-nvmem-core-support-mac-base-fixed-layout-cells.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/804-nvmem-core-support-mac-base-fixed-layout-cells.patch new file mode 100755 index 0000000..8f2706e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/804-nvmem-core-support-mac-base-fixed-layout-cells.patch @@ -0,0 +1,124 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Thu, 13 Jul 2023 18:29:19 +0200 +Subject: [PATCH] nvmem: core: support "mac-base" fixed layout cells + +Fixed layout binding allows specifying "mac-base" NVMEM cells. It's used +for base MAC address (that can be used for calculating relative +addresses). It can be stored in a raw binary format or as an ASCII +string. +--- + +--- a/drivers/nvmem/Kconfig ++++ b/drivers/nvmem/Kconfig +@@ -2,6 +2,7 @@ + menuconfig NVMEM + bool "NVMEM Support" + imply NVMEM_LAYOUTS ++ select GENERIC_NET_UTILS + help + Support for NVMEM(Non Volatile Memory) devices like EEPROM, EFUSES... + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -7,9 +7,12 @@ + */ + + #include ++#include ++#include + #include + #include + #include ++#include + #include + #include + #include +@@ -811,6 +814,62 @@ static int nvmem_validate_keepouts(struc + return 0; + } + ++static int nvmem_mac_base_raw_read(void *context, const char *id, int index, unsigned int offset, ++ void *buf, size_t bytes) ++{ ++ if (WARN_ON(bytes != ETH_ALEN)) ++ return -EINVAL; ++ ++ if (index) ++ eth_addr_add(buf, index); ++ ++ return 0; ++} ++ ++static int nvmem_mac_base_ascii_read(void *context, const char *id, int index, unsigned int offset, ++ void *buf, size_t bytes) ++{ ++ u8 mac[ETH_ALEN]; ++ ++ if (WARN_ON(bytes != 3 * ETH_ALEN - 1)) ++ return -EINVAL; ++ ++ if (!mac_pton(buf, mac)) ++ return -EINVAL; ++ ++ if (index) ++ eth_addr_add(mac, index); ++ ++ ether_addr_copy(buf, mac); ++ ++ return 0; ++} ++ ++static int nvmem_mac_base_hex_read(void *context, const char *id, int index, unsigned int offset, ++ void *buf, size_t bytes) ++{ ++ u8 mac[ETH_ALEN], *hexstr; ++ int i; ++ ++ if (WARN_ON(bytes != 2 * ETH_ALEN)) ++ return -EINVAL; ++ ++ hexstr = (u8 *)buf; ++ for (i = 0; i < ETH_ALEN; i++) { ++ if (!isxdigit(hexstr[i * 2]) || !isxdigit(hexstr[i * 2 + 1])) ++ return -EINVAL; ++ ++ mac[i] = (hex_to_bin(hexstr[i * 2]) << 4) | hex_to_bin(hexstr[i * 2 + 1]); ++ } ++ ++ if (index) ++ eth_addr_add(mac, index); ++ ++ ether_addr_copy(buf, mac); ++ ++ return 0; ++} ++ + static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) + { + struct device *dev = &nvmem->dev; +@@ -852,6 +911,25 @@ static int nvmem_add_cells_from_dt(struc + if (nvmem->fixup_dt_cell_info) + nvmem->fixup_dt_cell_info(nvmem, &info); + ++ if (of_device_is_compatible(np, "fixed-layout")) { ++ if (of_device_is_compatible(child, "mac-base")) { ++ if (info.bytes == ETH_ALEN) { ++ info.raw_len = info.bytes; ++ info.bytes = ETH_ALEN; ++ info.read_post_process = nvmem_mac_base_raw_read; ++ } else if (info.bytes == 2 * ETH_ALEN) { ++ info.raw_len = info.bytes; ++ info.bytes = ETH_ALEN; ++ info.read_post_process = nvmem_mac_base_hex_read; ++ } else if (info.bytes == 3 * ETH_ALEN - 1) { ++ info.raw_len = info.bytes; ++ info.bytes = ETH_ALEN; ++ info.read_post_process = nvmem_mac_base_ascii_read; ++ } ++ ++ } ++ } ++ + ret = nvmem_add_one_cell(nvmem, &info); + kfree(info.name); + if (ret) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-01-nvmem-core-generalize-mac-base-cells-handling.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-01-nvmem-core-generalize-mac-base-cells-handling.patch new file mode 100755 index 0000000..94d43e0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-01-nvmem-core-generalize-mac-base-cells-handling.patch @@ -0,0 +1,248 @@ +From fd0e523037439520813db7c57df5bd37cdf40f7e Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Mon, 3 Feb 2025 00:10:18 +0100 +Subject: [PATCH 1/2] nvmem: core: generalize "mac-base" cells handling + +Generalize support of "mac-base" nvmem cells and provide a GPL symbol to +permit also other NVMEM layout driver to parse mac-base cells. + +It's VERY COMMON for some specially formatted NVMEM to expose a mac +address in ASCII format or HEX format hence prevent code duplication by +exposing a common helper. + +Such helper will change the nvmem_info_cell and apply the correct post +process function to correctly parse the mac address. + +Since the API requires OF and is only related to layout, move the +function in layouts.c to correctly handle non-OF NVMEM. + +Signed-off-by: Christian Marangi +--- + drivers/nvmem/core.c | 79 +-------------------------------- + drivers/nvmem/layouts.c | 80 ++++++++++++++++++++++++++++++++++ + include/linux/nvmem-provider.h | 4 ++ + 3 files changed, 86 insertions(+), 77 deletions(-) + +--- a/drivers/nvmem/core.c ++++ b/drivers/nvmem/core.c +@@ -7,12 +7,9 @@ + */ + + #include +-#include +-#include + #include + #include + #include +-#include + #include + #include + #include +@@ -814,62 +811,6 @@ static int nvmem_validate_keepouts(struc + return 0; + } + +-static int nvmem_mac_base_raw_read(void *context, const char *id, int index, unsigned int offset, +- void *buf, size_t bytes) +-{ +- if (WARN_ON(bytes != ETH_ALEN)) +- return -EINVAL; +- +- if (index) +- eth_addr_add(buf, index); +- +- return 0; +-} +- +-static int nvmem_mac_base_ascii_read(void *context, const char *id, int index, unsigned int offset, +- void *buf, size_t bytes) +-{ +- u8 mac[ETH_ALEN]; +- +- if (WARN_ON(bytes != 3 * ETH_ALEN - 1)) +- return -EINVAL; +- +- if (!mac_pton(buf, mac)) +- return -EINVAL; +- +- if (index) +- eth_addr_add(mac, index); +- +- ether_addr_copy(buf, mac); +- +- return 0; +-} +- +-static int nvmem_mac_base_hex_read(void *context, const char *id, int index, unsigned int offset, +- void *buf, size_t bytes) +-{ +- u8 mac[ETH_ALEN], *hexstr; +- int i; +- +- if (WARN_ON(bytes != 2 * ETH_ALEN)) +- return -EINVAL; +- +- hexstr = (u8 *)buf; +- for (i = 0; i < ETH_ALEN; i++) { +- if (!isxdigit(hexstr[i * 2]) || !isxdigit(hexstr[i * 2 + 1])) +- return -EINVAL; +- +- mac[i] = (hex_to_bin(hexstr[i * 2]) << 4) | hex_to_bin(hexstr[i * 2 + 1]); +- } +- +- if (index) +- eth_addr_add(mac, index); +- +- ether_addr_copy(buf, mac); +- +- return 0; +-} +- + static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) + { + struct device *dev = &nvmem->dev; +@@ -911,24 +852,8 @@ static int nvmem_add_cells_from_dt(struc + if (nvmem->fixup_dt_cell_info) + nvmem->fixup_dt_cell_info(nvmem, &info); + +- if (of_device_is_compatible(np, "fixed-layout")) { +- if (of_device_is_compatible(child, "mac-base")) { +- if (info.bytes == ETH_ALEN) { +- info.raw_len = info.bytes; +- info.bytes = ETH_ALEN; +- info.read_post_process = nvmem_mac_base_raw_read; +- } else if (info.bytes == 2 * ETH_ALEN) { +- info.raw_len = info.bytes; +- info.bytes = ETH_ALEN; +- info.read_post_process = nvmem_mac_base_hex_read; +- } else if (info.bytes == 3 * ETH_ALEN - 1) { +- info.raw_len = info.bytes; +- info.bytes = ETH_ALEN; +- info.read_post_process = nvmem_mac_base_ascii_read; +- } +- +- } +- } ++ if (of_device_is_compatible(np, "fixed-layout")) ++ nvmem_layout_parse_mac_base(&info); + + ret = nvmem_add_one_cell(nvmem, &info); + kfree(info.name); +--- a/drivers/nvmem/layouts.c ++++ b/drivers/nvmem/layouts.c +@@ -6,8 +6,11 @@ + * Author: Miquel Raynal + #include + #include ++#include ++#include + #include + #include + #include +@@ -21,6 +24,83 @@ + #define to_nvmem_layout_device(_dev) \ + container_of((_dev), struct nvmem_layout, dev) + ++static int nvmem_mac_base_raw_read(void *context, const char *id, int index, unsigned int offset, ++ void *buf, size_t bytes) ++{ ++ if (WARN_ON(bytes != ETH_ALEN)) ++ return -EINVAL; ++ ++ if (index) ++ eth_addr_add(buf, index); ++ ++ return 0; ++} ++ ++static int nvmem_mac_base_ascii_read(void *context, const char *id, int index, unsigned int offset, ++ void *buf, size_t bytes) ++{ ++ u8 mac[ETH_ALEN]; ++ ++ if (WARN_ON(bytes != 3 * ETH_ALEN - 1)) ++ return -EINVAL; ++ ++ if (!mac_pton(buf, mac)) ++ return -EINVAL; ++ ++ if (index) ++ eth_addr_add(mac, index); ++ ++ ether_addr_copy(buf, mac); ++ ++ return 0; ++} ++ ++static int nvmem_mac_base_hex_read(void *context, const char *id, int index, unsigned int offset, ++ void *buf, size_t bytes) ++{ ++ u8 mac[ETH_ALEN], *hexstr; ++ int i; ++ ++ if (WARN_ON(bytes != 2 * ETH_ALEN)) ++ return -EINVAL; ++ ++ hexstr = (u8 *)buf; ++ for (i = 0; i < ETH_ALEN; i++) { ++ if (!isxdigit(hexstr[i * 2]) || !isxdigit(hexstr[i * 2 + 1])) ++ return -EINVAL; ++ ++ mac[i] = (hex_to_bin(hexstr[i * 2]) << 4) | hex_to_bin(hexstr[i * 2 + 1]); ++ } ++ ++ if (index) ++ eth_addr_add(mac, index); ++ ++ ether_addr_copy(buf, mac); ++ ++ return 0; ++} ++ ++void nvmem_layout_parse_mac_base(struct nvmem_cell_info *info) ++{ ++ if (!of_device_is_compatible(info->np, "mac-base")) ++ return; ++ ++ if (info->bytes == ETH_ALEN) { ++ info->raw_len = info->bytes; ++ info->bytes = ETH_ALEN; ++ info->read_post_process = nvmem_mac_base_raw_read; ++ } else if (info->bytes == 2 * ETH_ALEN) { ++ info->raw_len = info->bytes; ++ info->bytes = ETH_ALEN; ++ info->read_post_process = nvmem_mac_base_hex_read; ++ } else if (info->bytes == 3 * ETH_ALEN - 1) { ++ info->raw_len = info->bytes; ++ info->bytes = ETH_ALEN; ++ info->read_post_process = nvmem_mac_base_ascii_read; ++ } ++} ++EXPORT_SYMBOL_GPL(nvmem_layout_parse_mac_base); ++ + static int nvmem_layout_bus_match(struct device *dev, const struct device_driver *drv) + { + return of_driver_match_device(dev, drv); +--- a/include/linux/nvmem-provider.h ++++ b/include/linux/nvmem-provider.h +@@ -242,6 +242,8 @@ static inline void nvmem_layout_unregist + + #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) + ++void nvmem_layout_parse_mac_base(struct nvmem_cell_info *info); ++ + /** + * of_nvmem_layout_get_container() - Get OF node of layout container + * +@@ -254,6 +256,8 @@ struct device_node *of_nvmem_layout_get_ + + #else /* CONFIG_NVMEM && CONFIG_OF */ + ++static inline void nvmem_layout_parse_mac_base(struct nvmem_cell_info *info) {} ++ + static inline struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvmem) + { + return NULL; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-02-nvmem-layouts-add-support-for-ascii-env-driver.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-02-nvmem-layouts-add-support-for-ascii-env-driver.patch new file mode 100755 index 0000000..0906e0f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-02-nvmem-layouts-add-support-for-ascii-env-driver.patch @@ -0,0 +1,204 @@ +From 38287e8ec5c0281377fc70f11f20bcd9986a05f5 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Mon, 3 Feb 2025 00:36:12 +0100 +Subject: [PATCH 2/2] nvmem: layouts: add support for ascii-env driver + +Add support for simple ASCII envirorment driver for NVMEM layouts. + +It's very common for devices to store simple text file format in +partition for environment varibles. The most common pattern is variable +name, a delimiter and variable value all separated by a new line +character (\n). + +This driver adds support for exporting such data and expose NVMEM cells +so they can be referenced by other drivers. This driver also supports +parsing mac-base NVMEM cells to parse ASCII or HEX mac address. + +Signed-off-by: Christian Marangi +--- + drivers/nvmem/layouts/Kconfig | 13 +++ + drivers/nvmem/layouts/Makefile | 1 + + drivers/nvmem/layouts/ascii-env.c | 140 ++++++++++++++++++++++++++++++ + 3 files changed, 154 insertions(+) + create mode 100644 drivers/nvmem/layouts/ascii-env.c + +--- a/drivers/nvmem/layouts/Kconfig ++++ b/drivers/nvmem/layouts/Kconfig +@@ -37,6 +37,19 @@ config NVMEM_LAYOUT_U_BOOT_ENV + + If unsure, say N. + ++config NVMEM_LAYOUT_ASCII_ENV ++ tristate "ASCII environment variables layout" ++ help ++ It's very common for devices to store simple text file format in ++ partition for environment varibles. The most common pattern is variable ++ name, a delimiter and variable value all separated by a new line ++ character (\n). ++ This driver adds support for exporting such data and expose NVMEM cells ++ so they can be referenced by other drivers. This driver also supports ++ parsing mac-base NVMEM cells to parse ASCII or HEX mac address. ++ ++ If unsure, say N. ++ + endmenu + + endif +--- a/drivers/nvmem/layouts/Makefile ++++ b/drivers/nvmem/layouts/Makefile +@@ -6,3 +6,4 @@ + obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o + obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o + obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o ++obj-$(CONFIG_NVMEM_LAYOUT_ASCII_ENV) += ascii-env.o +--- /dev/null ++++ b/drivers/nvmem/layouts/ascii-env.c +@@ -0,0 +1,148 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Copyright (C) 2024 Christian Marangi ++ * ++ * This borrow some parse logic from u-boot-env. ++ */ ++#include ++#include ++#include ++#include ++ ++struct ascii_env_match_data { ++ const char delim; ++}; ++ ++/* ++ * Parse a buffer as an ASCII text with name delimiter value and each pattern separated ++ * with a new line char '\n' ++ * Example: (delimiter '=') ++ * name=value\nname2=value2\n ++ * 2 Cell: ++ * - name: value ++ * - name2: value2 ++ */ ++static int ascii_env_parse_cells(struct device *dev, struct nvmem_device *nvmem, uint8_t *buf, ++ size_t data_len, const char delim) ++{ ++ char *var, *value, *eq, *lf; ++ char *data = buf; ++ ++ /* ++ * Warning the inner loop take care of replacing '\n' ++ * with '\0', hence we can use strlen on value. ++ */ ++ for (var = data; var < data + data_len && *var; ++ var = value + strlen(value) + 1) { ++ struct nvmem_cell_info info = {}; ++ struct device_node *child; ++ const char *label; ++ ++ eq = strchr(var, delim); ++ if (!eq) ++ break; ++ *eq = '\0'; ++ value = eq + 1; ++ ++ /* Replace '\n' with '\0' to use strlen for value */ ++ lf = strchr(value, '\n'); ++ if (!lf) ++ break; ++ *lf = '\0'; ++ ++ info.name = devm_kstrdup(dev, var, GFP_KERNEL); ++ if (!info.name) ++ return -ENOMEM; ++ info.offset = value - data; ++ info.bytes = strlen(value); ++ info.np = of_get_child_by_name(dev->of_node, info.name); ++ for_each_child_of_node(dev->of_node, child) { ++ if (!of_property_read_string(child, "label", &label) && ++ !strncmp(info.name, label, info.bytes)) ++ info.np = child; ++ else if (of_node_name_eq(child, info.name)) ++ info.np = child; ++ } ++ ++ nvmem_layout_parse_mac_base(&info); ++ ++ nvmem_add_one_cell(nvmem, &info); ++ } ++ ++ return 0; ++} ++ ++static int ascii_env_add_cells(struct nvmem_layout *layout) ++{ ++ struct nvmem_device *nvmem = layout->nvmem; ++ const struct ascii_env_match_data *data; ++ struct device *dev = &layout->dev; ++ size_t dev_size; ++ uint8_t *buf; ++ int bytes; ++ int ret; ++ ++ /* Get the delimiter for name value pattern */ ++ data = device_get_match_data(dev); ++ ++ dev_size = nvmem_dev_size(nvmem); ++ ++ buf = kzalloc(dev_size, GFP_KERNEL); ++ if (!buf) { ++ ret = -ENOMEM; ++ goto err_out; ++ } ++ ++ bytes = nvmem_device_read(nvmem, 0, dev_size, buf); ++ if (bytes < 0) { ++ ret = bytes; ++ goto err_kfree; ++ } else if (bytes != dev_size) { ++ ret = -EIO; ++ goto err_kfree; ++ } ++ ++ buf[dev_size - 1] = '\0'; ++ ret = ascii_env_parse_cells(dev, nvmem, buf, dev_size, data->delim); ++ ++err_kfree: ++ kfree(buf); ++err_out: ++ return ret; ++} ++ ++static int ascii_env_probe(struct nvmem_layout *layout) ++{ ++ layout->add_cells = ascii_env_add_cells; ++ ++ return nvmem_layout_register(layout); ++} ++ ++static void ascii_env_remove(struct nvmem_layout *layout) ++{ ++ nvmem_layout_unregister(layout); ++} ++ ++static const struct ascii_env_match_data ascii_env_eq = { ++ .delim = '=', ++}; ++ ++static const struct of_device_id ascii_env_of_match_table[] = { ++ { .compatible = "ascii-eq-delim-env", .data = &ascii_env_eq, }, ++ {}, ++}; ++ ++static struct nvmem_layout_driver ascii_env_layout = { ++ .driver = { ++ .name = "ascii-env-layout", ++ .of_match_table = ascii_env_of_match_table, ++ }, ++ .probe = ascii_env_probe, ++ .remove = ascii_env_remove, ++}; ++module_nvmem_layout_driver(ascii_env_layout); ++ ++MODULE_AUTHOR("Christian Marangi "); ++MODULE_LICENSE("GPL"); ++MODULE_DEVICE_TABLE(of, ascii_env_of_match_table); ++MODULE_DESCRIPTION("NVMEM layout driver for ASCII environment variables"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-03-nvmem-layouts-ascii-env-handle-CRLF-while-parsing.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-03-nvmem-layouts-ascii-env-handle-CRLF-while-parsing.patch new file mode 100755 index 0000000..ab5fc58 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/809-03-nvmem-layouts-ascii-env-handle-CRLF-while-parsing.patch @@ -0,0 +1,58 @@ +From: George Moussalem +Date: Thu, 06 Feb 2025 21:55:28 +0400 +Subject: [PATCH] nvmem: layouts: ascii-env handle CRLF while parsing + +The current driver supports LF line endings only. + +For CRLF-based line endings in the ASCII env, the length of the value of +the variable passed to nvmem_layout_parse_mac_base is 18 bytes instead +of an expected length of 17 causing the parsing to fail. +So, let's add the ability to handle CRLF line endings by adding a +condition to check if the value ends with a '\r' character and replace it +with '\0' to properly parse the mac address. + +Tested on Linksys MX2000, MX5500, and SPNMX56. + +Signed-off-by: George Moussalem +--- +--- a/drivers/nvmem/layouts/ascii-env.c ++++ b/drivers/nvmem/layouts/ascii-env.c +@@ -25,18 +25,20 @@ struct ascii_env_match_data { + static int ascii_env_parse_cells(struct device *dev, struct nvmem_device *nvmem, uint8_t *buf, + size_t data_len, const char delim) + { +- char *var, *value, *eq, *lf; ++ char *var, *value, *eq, *lf, *cr; + char *data = buf; ++ uint incr = 0; + + /* + * Warning the inner loop take care of replacing '\n' + * with '\0', hence we can use strlen on value. + */ + for (var = data; var < data + data_len && *var; +- var = value + strlen(value) + 1) { ++ var = value + strlen(value) + incr) { + struct nvmem_cell_info info = {}; + struct device_node *child; + const char *label; ++ incr = 0; + + eq = strchr(var, delim); + if (!eq) +@@ -49,6 +51,15 @@ static int ascii_env_parse_cells(struct + if (!lf) + break; + *lf = '\0'; ++ incr++; ++ ++ /* For CRLF based env, replace '\r' with '\0' too to use strlen ++ * for value, and increment var by one in loop for next variable */ ++ cr = strchr(value, '\r'); ++ if (cr) { ++ *cr = '\0'; ++ incr++; ++ } + + info.name = devm_kstrdup(dev, var, GFP_KERNEL); + if (!info.name) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/810-pci_disable_common_quirks.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/810-pci_disable_common_quirks.patch new file mode 100755 index 0000000..89dcbc2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/810-pci_disable_common_quirks.patch @@ -0,0 +1,62 @@ +From: Gabor Juhos +Subject: debloat: add kernel config option to disabling common PCI quirks + +Signed-off-by: Gabor Juhos +--- + drivers/pci/Kconfig | 6 ++++++ + drivers/pci/quirks.c | 6 ++++++ + 2 files changed, 12 insertions(+) + +--- a/drivers/pci/Kconfig ++++ b/drivers/pci/Kconfig +@@ -118,6 +118,13 @@ config XEN_PCIDEV_FRONTEND + The PCI device frontend driver allows the kernel to import arbitrary + PCI devices from a PCI backend to support PCI driver domains. + ++config PCI_DISABLE_COMMON_QUIRKS ++ bool "PCI disable common quirks" ++ depends on PCI ++ help ++ If you don't know what to do here, say N. ++ ++ + config PCI_ATS + bool + +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -313,6 +313,7 @@ static void quirk_mmio_always_on(struct + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_BRIDGE_HOST, 8, quirk_mmio_always_on); + ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS + /* + * The Mellanox Tavor device gives false positive parity errors. Disable + * parity error reporting. +@@ -3509,6 +3510,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_I + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata); + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata); + ++#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */ ++ + /* + * Ivytown NTB BAR sizes are misreported by the hardware due to an erratum. + * To work around this, query the size it should be configured to by the +@@ -3534,6 +3537,8 @@ static void quirk_intel_ntb(struct pci_d + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0e08, quirk_intel_ntb); + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0e0d, quirk_intel_ntb); + ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS ++ + /* + * Some BIOS implementations leave the Intel GPU interrupts enabled, even + * though no one is handling them (e.g., if the i915 driver is never +@@ -3572,6 +3577,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IN + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq); + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq); + ++#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */ ++ + /* + * PCI devices which are on Intel chips can skip the 10ms delay + * before entering D3 mode. diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/811-pci_disable_usb_common_quirks.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/811-pci_disable_usb_common_quirks.patch new file mode 100755 index 0000000..4e0360d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/811-pci_disable_usb_common_quirks.patch @@ -0,0 +1,63 @@ +From: Felix Fietkau +Date: Sat, 26 Apr 2025 21:10:40 +0200 +Subject: [PATCH] debloat: disable common USB quirks + +Signed-off-by: Felix Fietkau +--- + drivers/usb/host/pci-quirks.c | 7 +++++++ + drivers/usb/host/pci-quirks.h | 4 ++++ + 2 files changed, 11 insertions(+) + +--- a/drivers/usb/host/pci-quirks.c ++++ b/drivers/usb/host/pci-quirks.c +@@ -590,6 +590,7 @@ bool usb_amd_pt_check_port(struct device + EXPORT_SYMBOL_GPL(usb_amd_pt_check_port); + #endif /* CONFIG_USB_PCI_AMD */ + ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS + static int usb_asmedia_wait_write(struct pci_dev *pdev) + { + unsigned long retry_count; +@@ -642,6 +643,7 @@ static inline int io_type_enabled(struct + } + + #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) ++#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */ + + #if defined(CONFIG_HAS_IOPORT) && IS_ENABLED(CONFIG_USB_UHCI_HCD) + /* +@@ -724,6 +726,10 @@ reset_needed: + return 1; + } + EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc); ++#endif ++ ++#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS ++#if defined(CONFIG_HAS_IOPORT) && IS_ENABLED(CONFIG_USB_UHCI_HCD) + + #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) + +@@ -1304,3 +1310,4 @@ static void quirk_usb_early_handoff(stru + } + DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff); ++#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */ +--- a/drivers/usb/host/pci-quirks.h ++++ b/drivers/usb/host/pci-quirks.h +@@ -38,12 +38,16 @@ static inline bool usb_amd_pt_check_port + #ifdef CONFIG_USB_PCI + void uhci_reset_hc(struct pci_dev *pdev, unsigned long base); + int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base); ++#endif ++ ++#if defined(CONFIG_USB_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS) + void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev); + void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev); + void usb_disable_xhci_ports(struct pci_dev *xhci_pdev); + #else + struct pci_dev; + static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {} ++static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {} + static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {} + #endif /* CONFIG_USB_PCI */ + diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/812-PCI-sysfs-enforce-single-creation-of-sysfs-entry-for.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/812-PCI-sysfs-enforce-single-creation-of-sysfs-entry-for.patch new file mode 100755 index 0000000..e5f54d7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/812-PCI-sysfs-enforce-single-creation-of-sysfs-entry-for.patch @@ -0,0 +1,142 @@ +From d33941523a8379e30070374b133b28a2077dcef8 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Mon, 13 Oct 2025 20:45:25 +0200 +Subject: [PATCH] PCI/sysfs: enforce single creation of sysfs entry for pdev +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In some specific scenario it's possible that the +pci_create_resource_files() gets called multiple times and the created +entry actually gets wrongly deleted with extreme case of having a NULL +pointer dereference when the PCI is removed. + +This mainly happen due to bad timing where the PCI bus is adding PCI +devices and at the same time the sysfs code is adding the entry causing +double execution of the pci_create_resource_files function and kernel +WARNING. + +To be more precise there is a race between the late_initcall of +pci-sysfs with pci_sysfs_init and PCI bus.c pci_bus_add_device that also +call pci_create_sysfs_dev_files. + +With correct amount of ""luck"" (or better say bad luck) +pci_create_sysfs_dev_files in bus.c might be called with pci_sysfs_init +is executing the loop. + +This has been reported multiple times and on multiple system, like imx6 +system, ipq806x systems... + +To address this, imlement multiple improvement to the implementation: +1. Add a bool to pci_dev to flag when sysfs entry are created + (sysfs_init) +2. Implement a simple completion to wait pci_sysfs_init execution. +3. Permit additional call of pci_create_sysfs_dev_files only after + pci_sysfs_init has finished. + +With such logic in place, we address al kind of timing problem with +minimal change to any driver. + +A notice worth to mention is that the remove function are not affected +by this as the pci_remove_resource_files have enough check in place to +always work and it's always called by pci_stop_dev. + +Cc: stable@vger.kernel.org +Reported-by: Krzysztof HaΕ‚asa +Closes: https://bugzilla.kernel.org/show_bug.cgi?id=215515 +Signed-off-by: Christian Marangi +--- + drivers/pci/pci-sysfs.c | 34 +++++++++++++++++++++++++++++----- + include/linux/pci.h | 1 + + 2 files changed, 30 insertions(+), 5 deletions(-) + +--- a/drivers/pci/pci-sysfs.c ++++ b/drivers/pci/pci-sysfs.c +@@ -13,6 +13,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -36,6 +37,7 @@ + #endif + + static int sysfs_initialized; /* = 0 */ ++static DECLARE_COMPLETION(sysfs_init_completion); + + /* show configuration fields */ + #define pci_config_attr(field, format_string) \ +@@ -1551,12 +1553,32 @@ static const struct attribute_group pci_ + .is_visible = resource_resize_is_visible, + }; + ++static int __pci_create_sysfs_dev_files(struct pci_dev *pdev) ++{ ++ int ret; ++ ++ ret = pci_create_resource_files(pdev); ++ if (ret) ++ return ret; ++ ++ /* on success set sysfs correctly created */ ++ pdev->sysfs_init = true; ++ return 0; ++} ++ + int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) + { + if (!sysfs_initialized) + return -EACCES; + +- return pci_create_resource_files(pdev); ++ /* sysfs entry already created */ ++ if (pdev->sysfs_init) ++ return 0; ++ ++ /* wait for pci_sysfs_init */ ++ wait_for_completion(&sysfs_init_completion); ++ ++ return __pci_create_sysfs_dev_files(pdev); + } + + /** +@@ -1577,21 +1599,23 @@ static int __init pci_sysfs_init(void) + { + struct pci_dev *pdev = NULL; + struct pci_bus *pbus = NULL; +- int retval; ++ int retval = 0; + + sysfs_initialized = 1; + for_each_pci_dev(pdev) { +- retval = pci_create_sysfs_dev_files(pdev); ++ retval = __pci_create_sysfs_dev_files(pdev); + if (retval) { + pci_dev_put(pdev); +- return retval; ++ goto exit; + } + } + + while ((pbus = pci_find_next_bus(pbus))) + pci_create_legacy_files(pbus); + +- return 0; ++exit: ++ complete_all(&sysfs_init_completion); ++ return retval; + } + late_initcall(pci_sysfs_init); + +--- a/include/linux/pci.h ++++ b/include/linux/pci.h +@@ -484,6 +484,7 @@ struct pci_dev { + unsigned int rom_attr_enabled:1; /* Display of ROM attribute enabled? */ + pci_dev_flags_t dev_flags; + atomic_t enable_cnt; /* pci_enable_device has been called */ ++ bool sysfs_init; /* sysfs entry has been created */ + + spinlock_t pcie_cap_lock; /* Protects RMW ops in capability accessors */ + u32 saved_config_space[16]; /* Config space saved at suspend time */ diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/834-ledtrig-libata.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/834-ledtrig-libata.patch new file mode 100755 index 0000000..373e2ec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/834-ledtrig-libata.patch @@ -0,0 +1,145 @@ +From: Daniel Golle +Subject: libata: add ledtrig support + +This adds a LED trigger for each ATA port indicating disk activity. + +As this is needed only on specific platforms (NAS SoCs and such), +these platforms should define ARCH_WANTS_LIBATA_LEDS if there +are boards with LED(s) intended to indicate ATA disk activity and +need the OS to take care of that. +In that way, if not selected, LED trigger support not will be +included in libata-core and both, codepaths and structures remain +untouched. + +Signed-off-by: Daniel Golle +--- + drivers/ata/Kconfig | 16 ++++++++++++++++ + drivers/ata/libata-core.c | 41 +++++++++++++++++++++++++++++++++++++++++ + include/linux/libata.h | 9 +++++++++ + 3 files changed, 66 insertions(+) + +--- a/drivers/ata/Kconfig ++++ b/drivers/ata/Kconfig +@@ -67,6 +67,22 @@ config ATA_FORCE + + If unsure, say Y. + ++config ARCH_WANT_LIBATA_LEDS ++ bool ++ ++config ATA_LEDS ++ bool "support ATA port LED triggers" ++ depends on ARCH_WANT_LIBATA_LEDS ++ select NEW_LEDS ++ select LEDS_CLASS ++ select LEDS_TRIGGERS ++ default y ++ help ++ This option adds a LED trigger for each registered ATA port. ++ It is used to drive disk activity leds connected via GPIO. ++ ++ If unsure, say N. ++ + config ATA_ACPI + bool "ATA ACPI Support" + depends on ACPI +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -703,6 +703,17 @@ static inline void ata_set_tf_cdl(struct + qc->flags |= ATA_QCFLAG_HAS_CDL | ATA_QCFLAG_RESULT_TF; + } + ++#ifdef CONFIG_ATA_LEDS ++#define LIBATA_BLINK_DELAY 20 /* ms */ ++static inline void ata_led_act(struct ata_port *ap) ++{ ++ if (unlikely(!ap->ledtrig)) ++ return; ++ ++ led_trigger_blink_oneshot(ap->ledtrig, LIBATA_BLINK_DELAY, LIBATA_BLINK_DELAY, 0); ++} ++#endif ++ + /** + * ata_build_rw_tf - Build ATA taskfile for given read/write request + * @qc: Metadata associated with the taskfile to build +@@ -4800,6 +4811,9 @@ void __ata_qc_complete(struct ata_queued + link->active_tag = ATA_TAG_POISON; + ap->nr_active_links--; + } ++#ifdef CONFIG_ATA_LEDS ++ ata_led_act(ap); ++#endif + + /* clear exclusive status */ + if (unlikely(qc->flags & ATA_QCFLAG_CLEAR_EXCL && +@@ -5522,6 +5536,9 @@ struct ata_port *ata_port_alloc(struct a + ap->stats.unhandled_irq = 1; + ap->stats.idle_irq = 1; + #endif ++#ifdef CONFIG_ATA_LEDS ++ ap->ledtrig = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); ++#endif + ata_sff_port_init(ap); + + ata_force_pflags(ap); +@@ -5538,6 +5555,12 @@ void ata_port_free(struct ata_port *ap) + kfree(ap->pmp_link); + kfree(ap->slave_link); + ida_free(&ata_ida, ap->print_id); ++#ifdef CONFIG_ATA_LEDS ++ if (ap->ledtrig) { ++ led_trigger_unregister(ap->ledtrig); ++ kfree(ap->ledtrig); ++ }; ++#endif + kfree(ap); + } + EXPORT_SYMBOL_GPL(ata_port_free); +@@ -5942,7 +5965,23 @@ int ata_host_register(struct ata_host *h + WARN_ON(1); + return -EINVAL; + } ++#ifdef CONFIG_ATA_LEDS ++ for (i = 0; i < host->n_ports; i++) { ++ if (unlikely(!host->ports[i]->ledtrig)) ++ continue; + ++ snprintf(host->ports[i]->ledtrig_name, ++ sizeof(host->ports[i]->ledtrig_name), "ata%u", ++ host->ports[i]->print_id); ++ ++ host->ports[i]->ledtrig->name = host->ports[i]->ledtrig_name; ++ ++ if (led_trigger_register(host->ports[i]->ledtrig)) { ++ kfree(host->ports[i]->ledtrig); ++ host->ports[i]->ledtrig = NULL; ++ } ++ } ++#endif + /* Create associated sysfs transport objects */ + for (i = 0; i < host->n_ports; i++) { + rc = ata_tport_add(host->dev,host->ports[i]); +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -23,6 +23,9 @@ + #include + #include + #include ++#ifdef CONFIG_ATA_LEDS ++#include ++#endif + + /* + * Define if arch has non-standard setup. This is a _PCI_ standard +@@ -935,6 +938,10 @@ struct ata_port { + #ifdef CONFIG_ATA_ACPI + struct ata_acpi_gtm __acpi_init_gtm; /* use ata_acpi_init_gtm() */ + #endif ++#ifdef CONFIG_ATA_LEDS ++ struct led_trigger *ledtrig; ++ char ledtrig_name[8]; ++#endif + }; + + /* The following initializer overrides a method to NULL whether one of diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/840-hwrng-bcm2835-set-quality-to-1000.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/840-hwrng-bcm2835-set-quality-to-1000.patch new file mode 100755 index 0000000..3172ad5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/840-hwrng-bcm2835-set-quality-to-1000.patch @@ -0,0 +1,26 @@ +From d6988cf1d16faac56899918bb2b1be8d85155e3f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= +Date: Sat, 20 Feb 2021 18:36:38 +0100 +Subject: [PATCH] hwrng: bcm2835: set quality to 1000 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This allows devices without a high precission timer to reduce boot from >100s +to <30s. + +Signed-off-by: Álvaro FernΓ‘ndez Rojas +--- + drivers/char/hw_random/bcm2835-rng.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/char/hw_random/bcm2835-rng.c ++++ b/drivers/char/hw_random/bcm2835-rng.c +@@ -169,6 +169,7 @@ static int bcm2835_rng_probe(struct plat + priv->rng.init = bcm2835_rng_init; + priv->rng.read = bcm2835_rng_read; + priv->rng.cleanup = bcm2835_rng_cleanup; ++ priv->rng.quality = 1000; + + if (dev_of_node(dev)) { + rng_id = of_match_node(bcm2835_rng_of_match, dev->of_node); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/850-0023-PCI-aardvark-Make-main-irq_chip-structure-a-static-d.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/850-0023-PCI-aardvark-Make-main-irq_chip-structure-a-static-d.patch new file mode 100755 index 0000000..6a90959 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/850-0023-PCI-aardvark-Make-main-irq_chip-structure-a-static-d.patch @@ -0,0 +1,102 @@ +From 663b9f99bb35dbc0c7b685f71ee3668a60d31320 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Beh=C3=BAn?= +Date: Mon, 10 Jan 2022 02:02:00 +0100 +Subject: [PATCH] PCI: aardvark: Make main irq_chip structure a static driver + structure +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Marc Zyngier says [1] that we should use struct irq_chip as a global +static struct in the driver. Even though the structure currently +contains a dynamic member (parent_device), Marc says [2] that he plans +to kill it and make the structure completely static. + +We have already converted others irq_chip structures in this driver in +this way, but we omitted this one because the .name member is +dynamically created from device's name, and the name is displayed in +sysfs, so changing it would break sysfs ABI. + +The rationale for changing the name (to "advk-INT") in spite of sysfs +ABI, and thus allowing to convert to a static structure, is that after +the other changes we made in this series, the IRQ chip is basically +something different: it no logner generates ERR and PME interrupts (they +are generated by emulated bridge's rp_irq_chip). + +[1] https://lore.kernel.org/linux-pci/877dbcvngf.wl-maz@kernel.org/ +[2] https://lore.kernel.org/linux-pci/874k6gvkhz.wl-maz@kernel.org/ + +Signed-off-by: Marek BehΓΊn +--- + drivers/pci/controller/pci-aardvark.c | 25 +++++++------------------ + 1 file changed, 7 insertions(+), 18 deletions(-) + +--- a/drivers/pci/controller/pci-aardvark.c ++++ b/drivers/pci/controller/pci-aardvark.c +@@ -276,7 +276,6 @@ struct advk_pcie { + u8 wins_count; + struct irq_domain *rp_irq_domain; + struct irq_domain *irq_domain; +- struct irq_chip irq_chip; + raw_spinlock_t irq_lock; + struct irq_domain *msi_domain; + struct irq_domain *msi_inner_domain; +@@ -1418,14 +1417,19 @@ static void advk_pcie_irq_unmask(struct + raw_spin_unlock_irqrestore(&pcie->irq_lock, flags); + } + ++static struct irq_chip advk_irq_chip = { ++ .name = "advk-INT", ++ .irq_mask = advk_pcie_irq_mask, ++ .irq_unmask = advk_pcie_irq_unmask, ++}; ++ + static int advk_pcie_irq_map(struct irq_domain *h, + unsigned int virq, irq_hw_number_t hwirq) + { + struct advk_pcie *pcie = h->host_data; + + irq_set_status_flags(virq, IRQ_LEVEL); +- irq_set_chip_and_handler(virq, &pcie->irq_chip, +- handle_level_irq); ++ irq_set_chip_and_handler(virq, &advk_irq_chip, handle_level_irq); + irq_set_chip_data(virq, pcie); + + return 0; +@@ -1485,7 +1489,6 @@ static int advk_pcie_init_irq_domain(str + struct device *dev = &pcie->pdev->dev; + struct device_node *node = dev->of_node; + struct device_node *pcie_intc_node; +- struct irq_chip *irq_chip; + int ret = 0; + + raw_spin_lock_init(&pcie->irq_lock); +@@ -1496,28 +1499,14 @@ static int advk_pcie_init_irq_domain(str + return -ENODEV; + } + +- irq_chip = &pcie->irq_chip; +- +- irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq", +- dev_name(dev)); +- if (!irq_chip->name) { +- ret = -ENOMEM; +- goto out_put_node; +- } +- +- irq_chip->irq_mask = advk_pcie_irq_mask; +- irq_chip->irq_unmask = advk_pcie_irq_unmask; +- + pcie->irq_domain = + irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, + &advk_pcie_irq_domain_ops, pcie); + if (!pcie->irq_domain) { + dev_err(dev, "Failed to get a INTx IRQ domain\n"); + ret = -ENOMEM; +- goto out_put_node; + } + +-out_put_node: + of_node_put(pcie_intc_node); + return ret; + } diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/890-usb-serial-add-support-for-CH348.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/890-usb-serial-add-support-for-CH348.patch new file mode 100755 index 0000000..028ecf4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/890-usb-serial-add-support-for-CH348.patch @@ -0,0 +1,783 @@ +From df1357358eec062241bddd2995e7ef0ce86cf45a Mon Sep 17 00:00:00 2001 +X-Patchwork-Submitter: Corentin Labbe +X-Patchwork-Id: 13656881 +Message-Id: <20240507131522.3546113-2-clabbe@baylibre.com> +X-Mailer: git-send-email 2.25.1 +In-Reply-To: <20240507131522.3546113-1-clabbe@baylibre.com> +References: <20240507131522.3546113-1-clabbe@baylibre.com> +Precedence: bulk +X-Mailing-List: linux-usb@vger.kernel.org +List-Id: +From: Corentin Labbe +Date: Tue, 7 May 2024 13:15:22 +0000 +Subject: [PATCH v7] usb: serial: add support for CH348 + +The CH348 is an USB octo port serial adapter. +The device multiplexes all 8 ports in the same pair of Bulk endpoints. +Since there is no public datasheet, unfortunately it remains some magic values + +Signed-off-by: Corentin Labbe +Tested-by: Martin Blumenstingl +--- + drivers/usb/serial/Kconfig | 9 + + drivers/usb/serial/Makefile | 1 + + drivers/usb/serial/ch348.c | 725 ++++++++++++++++++++++++++++++++++++ + 3 files changed, 735 insertions(+) + create mode 100644 drivers/usb/serial/ch348.c + +--- a/drivers/usb/serial/Kconfig ++++ b/drivers/usb/serial/Kconfig +@@ -112,6 +112,15 @@ config USB_SERIAL_CH341 + To compile this driver as a module, choose M here: the + module will be called ch341. + ++config USB_SERIAL_CH348 ++ tristate "USB Winchiphead CH348 Octo Port Serial Driver" ++ help ++ Say Y here if you want to use a Winchiphead CH348 octo port ++ USB to serial adapter. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called ch348. ++ + config USB_SERIAL_WHITEHEAT + tristate "USB ConnectTech WhiteHEAT Serial Driver" + select USB_EZUSB_FX2 +--- a/drivers/usb/serial/Makefile ++++ b/drivers/usb/serial/Makefile +@@ -15,6 +15,7 @@ obj-$(CONFIG_USB_SERIAL_AIRCABLE) += ai + obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o + obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o + obj-$(CONFIG_USB_SERIAL_CH341) += ch341.o ++obj-$(CONFIG_USB_SERIAL_CH348) += ch348.o + obj-$(CONFIG_USB_SERIAL_CP210X) += cp210x.o + obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o + obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o +--- /dev/null ++++ b/drivers/usb/serial/ch348.c +@@ -0,0 +1,725 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * USB serial driver for USB to Octal UARTs chip ch348. ++ * ++ * Copyright (C) 2022 Corentin Labbe ++ * With the help of Neil Armstrong ++ * and the help of Martin Blumenstingl ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define CH348_CMD_TIMEOUT 2000 ++ ++#define CH348_CTO_D 0x01 ++#define CH348_CTO_R 0x02 ++ ++#define CH348_CTI_C 0x10 ++#define CH348_CTI_DSR 0x20 ++#define CH348_CTI_R 0x40 ++#define CH348_CTI_DCD 0x80 ++ ++#define CH348_LO 0x02 ++#define CH348_LP 0x04 ++#define CH348_LF 0x08 ++#define CH348_LB 0x10 ++ ++#define CMD_W_R 0xC0 ++#define CMD_W_BR 0x80 ++ ++#define CMD_WB_E 0x90 ++#define CMD_RB_E 0xC0 ++ ++#define M_NOR 0x00 ++#define M_HF 0x03 ++ ++#define R_MOD 0x97 ++#define R_IO_D 0x98 ++#define R_IO_O 0x99 ++#define R_IO_I 0x9b ++#define R_TM_O 0x9c ++#define R_INIT 0xa1 ++ ++#define R_C1 0x01 ++#define R_C2 0x02 ++#define R_C4 0x04 ++#define R_C5 0x06 ++ ++#define R_II_B1 0x06 ++#define R_II_B2 0x02 ++#define R_II_B3 0x00 ++ ++#define CMD_VER 0x96 ++ ++#define CH348_RX_PORT_CHUNK_LENGTH 32 ++#define CH348_RX_PORT_MAX_LENGTH 30 ++ ++struct ch348_rxbuf { ++ u8 port; ++ u8 length; ++ u8 data[CH348_RX_PORT_MAX_LENGTH]; ++} __packed; ++ ++struct ch348_txbuf { ++ u8 port; ++ __le16 length; ++ u8 data[]; ++} __packed; ++ ++#define CH348_TX_HDRSIZE offsetof(struct ch348_txbuf, data) ++ ++struct ch348_initbuf { ++ u8 cmd; ++ u8 reg; ++ u8 port; ++ __be32 baudrate; ++ u8 format; ++ u8 paritytype; ++ u8 databits; ++ u8 rate; ++ u8 unknown; ++} __packed; ++ ++#define CH348_MAXPORT 8 ++ ++/* ++ * The CH348 multiplexes rx & tx into a pair of Bulk USB endpoints for ++ * the 8 serial ports, and another pair of Bulk USB endpoints to ++ * set port settings and receive port status events. ++ * ++ * The USB serial cores ties every Bulk endpoints pairs to each ports, ++ * but in our case it will set port 0 with the rx/tx endpoints ++ * and port 1 with the setup/status endpoints. ++ * ++ * To still take advantage of the generic code, we (re-)initialize ++ * the USB serial port structure with the correct USB endpoint ++ * for read and write, and write proper process_read_urb() ++ * and prepare_write_buffer() to correctly (de-)multiplex data. ++ * Also we use a custom write() implementation to wait until the buffer ++ * has been fully transmitted to prevent TX buffer overruns. ++ */ ++ ++/* ++ * struct ch348_port - per-port information ++ * @uartmode: UART port current mode ++ * @write_completion: completion event when the TX buffer has been written out ++ */ ++struct ch348_port { ++ u8 uartmode; ++ struct completion write_completion; ++}; ++ ++/* ++ * struct ch348 - main container for all this driver information ++ * @udev: pointer to the CH348 USB device ++ * @ports: List of per-port information ++ * @serial: pointer to the serial structure ++ * @write_lock: protect against concurrent writes so we don't lose data ++ * @cmd_ep: endpoint number for configure operations ++ * @status_urb: URB for status ++ * @status_buffer: buffer used by status_urb ++ */ ++struct ch348 { ++ struct usb_device *udev; ++ struct ch348_port ports[CH348_MAXPORT]; ++ struct usb_serial *serial; ++ ++ struct mutex write_lock; ++ ++ int cmd_ep; ++ ++ struct urb *status_urb; ++ u8 status_buffer[]; ++}; ++ ++struct ch348_magic { ++ u8 action; ++ u8 reg; ++ u8 control; ++} __packed; ++ ++struct ch348_status_entry { ++ u8 portnum:4; ++ u8 unused:4; ++ u8 reg_iir; ++ union { ++ u8 lsr_signal; ++ u8 modem_signal; ++ u8 init_data[10]; ++ }; ++} __packed; ++ ++static void ch348_process_status_urb(struct urb *urb) ++{ ++ struct ch348_status_entry *status_entry; ++ struct ch348 *ch348 = urb->context; ++ int ret, status = urb->status; ++ struct usb_serial_port *port; ++ unsigned int i, status_len; ++ ++ switch (status) { ++ case 0: ++ /* success */ ++ break; ++ case -ECONNRESET: ++ case -ENOENT: ++ case -ESHUTDOWN: ++ /* this urb is terminated, clean up */ ++ dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", ++ __func__, status); ++ return; ++ default: ++ dev_err(&urb->dev->dev, "%s - nonzero urb status received: %d\n", ++ __func__, status); ++ goto exit; ++ } ++ ++ if (urb->actual_length < 3) { ++ dev_warn(&ch348->udev->dev, ++ "Received too short status buffer with %u bytes\n", ++ urb->actual_length); ++ goto exit; ++ } ++ ++ for (i = 0; i < urb->actual_length;) { ++ status_entry = urb->transfer_buffer + i; ++ ++ if (status_entry->portnum >= CH348_MAXPORT) { ++ dev_warn(&ch348->udev->dev, ++ "Invalid port %d in status entry\n", ++ status_entry->portnum); ++ break; ++ } ++ ++ port = ch348->serial->port[status_entry->portnum]; ++ status_len = 3; ++ ++ if (!status_entry->reg_iir) { ++ dev_dbg(&port->dev, "Ignoring status with zero reg_iir\n"); ++ } else if (status_entry->reg_iir == R_INIT) { ++ status_len = 12; ++ } else if ((status_entry->reg_iir & 0x0f) == R_II_B1) { ++ if (status_entry->lsr_signal & CH348_LO) ++ port->icount.overrun++; ++ if (status_entry->lsr_signal & CH348_LP) ++ port->icount.parity++; ++ if (status_entry->lsr_signal & CH348_LF) ++ port->icount.frame++; ++ if (status_entry->lsr_signal & CH348_LF) ++ port->icount.brk++; ++ } else if ((status_entry->reg_iir & 0x0f) == R_II_B2) { ++ complete_all(&ch348->ports[status_entry->portnum].write_completion); ++ } else { ++ dev_warn(&port->dev, ++ "Unsupported status with reg_iir 0x%02x\n", ++ status_entry->reg_iir); ++ } ++ ++ usb_serial_debug_data(&port->dev, __func__, status_len, ++ urb->transfer_buffer + i); ++ ++ i += status_len; ++ } ++ ++exit: ++ ret = usb_submit_urb(urb, GFP_ATOMIC); ++ if (ret) ++ dev_err(&urb->dev->dev, "%s - usb_submit_urb failed; %d\n", ++ __func__, ret); ++} ++ ++/* ++ * Some values came from vendor tree, and we have no meaning for them, this ++ * function simply use them. ++ */ ++static int ch348_do_magic(struct ch348 *ch348, int portnum, u8 action, u8 reg, u8 control) ++{ ++ struct ch348_magic *buffer; ++ int ret, len; ++ ++ buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); ++ if (!buffer) ++ return -ENOMEM; ++ ++ if (portnum < 4) ++ reg += 0x10 * portnum; ++ else ++ reg += 0x10 * (portnum - 4) + 0x08; ++ ++ buffer->action = action; ++ buffer->reg = reg; ++ buffer->control = control; ++ ++ ret = usb_bulk_msg(ch348->udev, ch348->cmd_ep, buffer, 3, &len, ++ CH348_CMD_TIMEOUT); ++ if (ret) ++ dev_err(&ch348->udev->dev, "Failed to write magic err=%d\n", ret); ++ ++ kfree(buffer); ++ ++ return ret; ++} ++ ++static int ch348_configure(struct ch348 *ch348, int portnum) ++{ ++ int ret; ++ ++ ret = ch348_do_magic(ch348, portnum, CMD_W_R, R_C2, 0x87); ++ if (ret) ++ return ret; ++ ++ return ch348_do_magic(ch348, portnum, CMD_W_R, R_C4, 0x08); ++} ++ ++static void ch348_process_read_urb(struct urb *urb) ++{ ++ struct usb_serial_port *port = urb->context; ++ struct ch348 *ch348 = usb_get_serial_data(port->serial); ++ unsigned int portnum, usblen, i; ++ struct ch348_rxbuf *rxb; ++ ++ if (urb->actual_length < 2) { ++ dev_dbg(&ch348->udev->dev, "Empty rx buffer\n"); ++ return; ++ } ++ ++ for (i = 0; i < urb->actual_length; i += CH348_RX_PORT_CHUNK_LENGTH) { ++ rxb = urb->transfer_buffer + i; ++ portnum = rxb->port; ++ if (portnum >= CH348_MAXPORT) { ++ dev_dbg(&ch348->udev->dev, "Invalid port %d\n", portnum); ++ break; ++ } ++ ++ port = ch348->serial->port[portnum]; ++ ++ usblen = rxb->length; ++ if (usblen > CH348_RX_PORT_MAX_LENGTH) { ++ dev_dbg(&port->dev, "Invalid length %d for port %d\n", ++ usblen, portnum); ++ break; ++ } ++ ++ tty_insert_flip_string(&port->port, rxb->data, usblen); ++ tty_flip_buffer_push(&port->port); ++ port->icount.rx += usblen; ++ usb_serial_debug_data(&port->dev, __func__, usblen, rxb->data); ++ } ++} ++ ++static int ch348_prepare_write_buffer(struct usb_serial_port *port, void *dest, size_t size) ++{ ++ struct ch348_txbuf *rxt = dest; ++ int count; ++ ++ count = kfifo_out_locked(&port->write_fifo, rxt->data, ++ size - CH348_TX_HDRSIZE, &port->lock); ++ ++ rxt->port = port->port_number; ++ rxt->length = cpu_to_le16(count); ++ ++ return count + CH348_TX_HDRSIZE; ++} ++ ++static int ch348_write(struct tty_struct *tty, struct usb_serial_port *port, ++ const unsigned char *buf, int count) ++{ ++ struct ch348 *ch348 = usb_get_serial_data(port->serial); ++ struct ch348_port *ch348_port = &ch348->ports[port->port_number]; ++ int ret, max_tx_size; ++ ++ if (tty_get_baud_rate(tty) < 9600 && count >= 128) ++ /* ++ * Writing larger buffers can take longer than the hardware ++ * allows before discarding the write buffer. Limit the ++ * transfer size in such cases. ++ * These values have been found by empirical testing. ++ */ ++ max_tx_size = 128; ++ else ++ /* ++ * Only ingest as many bytes as we can transfer with one URB at ++ * a time. Once an URB has been written we need to wait for the ++ * R_II_B2 status event before we are allowed to send more data. ++ * If we ingest more data then usb_serial_generic_write() will ++ * internally try to process as much data as possible with any ++ * number of URBs without giving us the chance to wait in ++ * between transfers. ++ */ ++ max_tx_size = port->bulk_out_size - CH348_TX_HDRSIZE; ++ ++ reinit_completion(&ch348_port->write_completion); ++ ++ mutex_lock(&ch348->write_lock); ++ ++ /* ++ * For any (remaining) bytes that we did not transfer TTY core will ++ * call us again, with the buffer and count adjusted to the remaining ++ * data. ++ */ ++ ret = usb_serial_generic_write(tty, port, buf, min(count, max_tx_size)); ++ ++ mutex_unlock(&ch348->write_lock); ++ ++ if (ret <= 0) ++ return ret; ++ ++ if (!wait_for_completion_interruptible_timeout(&ch348_port->write_completion, ++ msecs_to_jiffies(CH348_CMD_TIMEOUT))) { ++ dev_err_console(port, "Failed to wait for TX buffer flush\n"); ++ return -ETIMEDOUT; ++ } ++ ++ return ret; ++} ++ ++static int ch348_set_uartmode(struct ch348 *ch348, int portnum, u8 mode) ++{ ++ int ret; ++ ++ if (ch348->ports[portnum].uartmode == M_NOR && mode == M_HF) { ++ ret = ch348_do_magic(ch348, portnum, CMD_W_BR, R_C4, 0x51); ++ if (ret) ++ return ret; ++ ch348->ports[portnum].uartmode = M_HF; ++ } ++ ++ if (ch348->ports[portnum].uartmode == M_HF && mode == M_NOR) { ++ ret = ch348_do_magic(ch348, portnum, CMD_W_BR, R_C4, 0x50); ++ if (ret) ++ return ret; ++ ch348->ports[portnum].uartmode = M_NOR; ++ } ++ return 0; ++} ++ ++static void ch348_set_termios(struct tty_struct *tty, struct usb_serial_port *port, ++ const struct ktermios *termios_old) ++{ ++ struct ch348 *ch348 = usb_get_serial_data(port->serial); ++ struct ktermios *termios = &tty->termios; ++ int ret, portnum = port->port_number; ++ struct ch348_initbuf *buffer; ++ speed_t baudrate; ++ u8 format; ++ ++ if (termios_old && !tty_termios_hw_change(&tty->termios, termios_old)) ++ return; ++ ++ buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); ++ if (!buffer) { ++ if (termios_old) ++ tty->termios = *termios_old; ++ return; ++ } ++ ++ /* ++ * The datasheet states that only baud rates in range of 1200..6000000 ++ * are supported. Tests however show that even baud rates as low as 50 ++ * and as high as 12000000 are working in practice. ++ */ ++ baudrate = clamp(tty_get_baud_rate(tty), 50, 12000000); ++ ++ format = termios->c_cflag & CSTOPB ? 2 : 1; ++ ++ buffer->paritytype = 0; ++ if (termios->c_cflag & PARENB) { ++ if (termios->c_cflag & PARODD) ++ buffer->paritytype += 1; ++ else ++ buffer->paritytype += 2; ++ if (termios->c_cflag & CMSPAR) ++ buffer->paritytype += 2; ++ } ++ ++ switch (C_CSIZE(tty)) { ++ case CS5: ++ buffer->databits = 5; ++ break; ++ case CS6: ++ buffer->databits = 6; ++ break; ++ case CS7: ++ buffer->databits = 7; ++ break; ++ case CS8: ++ default: ++ buffer->databits = 8; ++ break; ++ } ++ buffer->cmd = CMD_WB_E | (portnum & 0x0F); ++ buffer->reg = R_INIT; ++ buffer->port = portnum; ++ buffer->baudrate = cpu_to_be32(baudrate); ++ ++ if (format == 2) ++ buffer->format = 0x02; ++ else if (format == 1) ++ buffer->format = 0x00; ++ ++ buffer->rate = max_t(speed_t, 5, (10000 * 15 / baudrate) + 1); ++ ++ ret = usb_bulk_msg(ch348->udev, ch348->cmd_ep, buffer, ++ sizeof(*buffer), NULL, CH348_CMD_TIMEOUT); ++ if (ret < 0) { ++ dev_err(&ch348->udev->dev, "Failed to change line settings: err=%d\n", ++ ret); ++ goto out; ++ } ++ ++ ret = ch348_do_magic(ch348, portnum, CMD_W_R, R_C1, 0x0F); ++ if (ret < 0) ++ goto out; ++ ++ if (C_CRTSCTS(tty)) ++ ret = ch348_set_uartmode(ch348, portnum, M_HF); ++ else ++ ret = ch348_set_uartmode(ch348, portnum, M_NOR); ++ ++out: ++ kfree(buffer); ++} ++ ++static int ch348_open(struct tty_struct *tty, struct usb_serial_port *port) ++{ ++ struct ch348 *ch348 = usb_get_serial_data(port->serial); ++ int ret; ++ ++ if (tty) ++ ch348_set_termios(tty, port, NULL); ++ ++ ret = ch348_configure(ch348, port->port_number); ++ if (ret) { ++ dev_err(&ch348->udev->dev, "Fail to configure err=%d\n", ret); ++ return ret; ++ } ++ ++ return usb_serial_generic_open(tty, port); ++} ++ ++static int ch348_attach(struct usb_serial *serial) ++{ ++ struct usb_endpoint_descriptor *epcmd, *epstatus; ++ struct usb_serial_port *port0 = serial->port[1]; ++ struct usb_device *usb_dev = serial->dev; ++ int status_buffer_size, i, ret; ++ struct usb_interface *intf; ++ struct ch348 *ch348; ++ ++ intf = usb_ifnum_to_if(usb_dev, 0); ++ epstatus = &intf->cur_altsetting->endpoint[2].desc; ++ epcmd = &intf->cur_altsetting->endpoint[3].desc; ++ ++ status_buffer_size = usb_endpoint_maxp(epstatus); ++ ++ ch348 = kzalloc(struct_size(ch348, status_buffer, status_buffer_size), ++ GFP_KERNEL); ++ if (!ch348) ++ return -ENOMEM; ++ ++ usb_set_serial_data(serial, ch348); ++ ++ ch348->udev = serial->dev; ++ ch348->serial = serial; ++ mutex_init(&ch348->write_lock); ++ ++ for (i = 0; i < CH348_MAXPORT; i++) ++ init_completion(&ch348->ports[i].write_completion); ++ ++ ch348->status_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!ch348->status_urb) { ++ ret = -ENOMEM; ++ goto err_free_ch348; ++ } ++ ++ usb_fill_bulk_urb(ch348->status_urb, ch348->udev, ++ usb_rcvbulkpipe(ch348->udev, epstatus->bEndpointAddress), ++ ch348->status_buffer, status_buffer_size, ++ ch348_process_status_urb, ch348); ++ ++ ret = usb_submit_urb(ch348->status_urb, GFP_KERNEL); ++ if (ret) { ++ dev_err(&ch348->udev->dev, ++ "%s - failed to submit status/interrupt urb %i\n", ++ __func__, ret); ++ goto err_free_status_urb; ++ } ++ ++ ret = usb_serial_generic_submit_read_urbs(port0, GFP_KERNEL); ++ if (ret) ++ goto err_kill_status_urb; ++ ++ ch348->cmd_ep = usb_sndbulkpipe(usb_dev, epcmd->bEndpointAddress); ++ ++ return 0; ++ ++err_kill_status_urb: ++ usb_kill_urb(ch348->status_urb); ++err_free_status_urb: ++ usb_free_urb(ch348->status_urb); ++err_free_ch348: ++ kfree(ch348); ++ return ret; ++} ++ ++static void ch348_release(struct usb_serial *serial) ++{ ++ struct ch348 *ch348 = usb_get_serial_data(serial); ++ ++ usb_kill_urb(ch348->status_urb); ++ usb_free_urb(ch348->status_urb); ++ ++ kfree(ch348); ++} ++ ++static void ch348_print_version(struct usb_serial *serial) ++{ ++ u8 *version_buf; ++ int ret; ++ ++ version_buf = kzalloc(4, GFP_KERNEL); ++ if (!version_buf) ++ return; ++ ++ ret = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), ++ CMD_VER, ++ USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, ++ 0, 0, version_buf, 4, CH348_CMD_TIMEOUT); ++ if (ret < 0) ++ dev_dbg(&serial->dev->dev, "Failed to read CMD_VER: %d\n", ret); ++ else ++ dev_info(&serial->dev->dev, "Found WCH CH348%s\n", ++ (version_buf[1] & 0x80) ? "Q" : "L"); ++ ++ kfree(version_buf); ++} ++ ++static int ch348_probe(struct usb_serial *serial, const struct usb_device_id *id) ++{ ++ struct usb_endpoint_descriptor *epread, *epwrite, *epstatus, *epcmd; ++ struct usb_device *usb_dev = serial->dev; ++ struct usb_interface *intf; ++ int ret; ++ ++ intf = usb_ifnum_to_if(usb_dev, 0); ++ ++ ret = usb_find_common_endpoints(intf->cur_altsetting, &epread, &epwrite, ++ NULL, NULL); ++ if (ret) { ++ dev_err(&serial->dev->dev, "Failed to find basic endpoints ret=%d\n", ret); ++ return ret; ++ } ++ ++ epstatus = &intf->cur_altsetting->endpoint[2].desc; ++ if (!usb_endpoint_is_bulk_in(epstatus)) { ++ dev_err(&serial->dev->dev, "Missing second bulk in (STATUS/INT)\n"); ++ return -ENODEV; ++ } ++ ++ epcmd = &intf->cur_altsetting->endpoint[3].desc; ++ if (!usb_endpoint_is_bulk_out(epcmd)) { ++ dev_err(&serial->dev->dev, "Missing second bulk out (CMD)\n"); ++ return -ENODEV; ++ } ++ ++ ch348_print_version(serial); ++ ++ return 0; ++} ++ ++static int ch348_calc_num_ports(struct usb_serial *serial, ++ struct usb_serial_endpoints *epds) ++{ ++ int i; ++ ++ for (i = 1; i < CH348_MAXPORT; ++i) { ++ epds->bulk_out[i] = epds->bulk_out[0]; ++ epds->bulk_in[i] = epds->bulk_in[0]; ++ } ++ ++ epds->num_bulk_out = CH348_MAXPORT; ++ epds->num_bulk_in = CH348_MAXPORT; ++ ++ return CH348_MAXPORT; ++} ++ ++static int ch348_suspend(struct usb_serial *serial, pm_message_t message) ++{ ++ struct ch348 *ch348 = usb_get_serial_data(serial); ++ ++ usb_kill_urb(ch348->status_urb); ++ ++ return 0; ++} ++ ++static int ch348_resume(struct usb_serial *serial) ++{ ++ struct ch348 *ch348 = usb_get_serial_data(serial); ++ int ret; ++ ++ ret = usb_submit_urb(ch348->status_urb, GFP_KERNEL); ++ if (ret) { ++ dev_err(&ch348->udev->dev, ++ "%s - failed to submit status/interrupt urb %i\n", ++ __func__, ret); ++ return ret; ++ } ++ ++ ret = usb_serial_generic_resume(serial); ++ if (ret) ++ usb_kill_urb(ch348->status_urb); ++ ++ return ret; ++} ++ ++static const struct usb_device_id ch348_ids[] = { ++ { USB_DEVICE(0x1a86, 0x55d9), }, ++ { /* sentinel */ } ++}; ++ ++MODULE_DEVICE_TABLE(usb, ch348_ids); ++ ++static struct usb_serial_driver ch348_device = { ++ .driver = { ++ .owner = THIS_MODULE, ++ .name = "ch348", ++ }, ++ .id_table = ch348_ids, ++ .num_ports = CH348_MAXPORT, ++ .num_bulk_in = 1, ++ .num_bulk_out = 1, ++ .open = ch348_open, ++ .set_termios = ch348_set_termios, ++ .process_read_urb = ch348_process_read_urb, ++ .prepare_write_buffer = ch348_prepare_write_buffer, ++ .write = ch348_write, ++ .probe = ch348_probe, ++ .calc_num_ports = ch348_calc_num_ports, ++ .attach = ch348_attach, ++ .release = ch348_release, ++ .suspend = ch348_suspend, ++ .resume = ch348_resume, ++}; ++ ++static struct usb_serial_driver * const serial_drivers[] = { ++ &ch348_device, NULL ++}; ++ ++module_usb_serial_driver(serial_drivers, ch348_ids); ++ ++MODULE_AUTHOR("Corentin Labbe "); ++MODULE_DESCRIPTION("USB CH348 Octo port serial converter driver"); ++MODULE_LICENSE("GPL"); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/900-net-ag71xx-fix-qca9530-and-qca9550-mdio-probe.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/900-net-ag71xx-fix-qca9530-and-qca9550-mdio-probe.patch new file mode 100755 index 0000000..c0e318e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/900-net-ag71xx-fix-qca9530-and-qca9550-mdio-probe.patch @@ -0,0 +1,25 @@ +From 440415703692af4548e836832ef0434e87fbc357 Mon Sep 17 00:00:00 2001 +From: Oskari Lemmela +Date: Sat, 13 Jul 2024 18:56:59 +0300 +Subject: [PATCH] net: ag71xx: fix qca9530 and qca9550 mdio probe + +Newer QCA9530 and QCA9550 devices should use same div table as AR933X. + +Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver") +Signed-off-by: Oskari Lemmela +--- + drivers/net/ethernet/atheros/ag71xx.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/atheros/ag71xx.c ++++ b/drivers/net/ethernet/atheros/ag71xx.c +@@ -641,7 +641,8 @@ static int ag71xx_mdio_get_divider(struc + if (!ref_clock) + return -EINVAL; + +- if (ag71xx_is(ag, AR9330) || ag71xx_is(ag, AR9340)) { ++ if (ag71xx_is(ag, AR9330) || ag71xx_is(ag, AR9340) || ++ ag71xx_is(ag, QCA9530) || ag71xx_is(ag, QCA9550)) { + table = ar933x_mdio_div_table; + ndivs = ARRAY_SIZE(ar933x_mdio_div_table); + } else if (ag71xx_is(ag, AR7240)) { diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/920-mangle_bootargs.patch b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/920-mangle_bootargs.patch new file mode 100755 index 0000000..3bf2fce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/generic/pending-6.12/920-mangle_bootargs.patch @@ -0,0 +1,71 @@ +From: Imre Kaloz +Subject: init: add CONFIG_MANGLE_BOOTARGS and disable it by default + +Enabling this option renames the bootloader supplied root= +and rootfstype= variables, which might have to be know but +would break the automatisms OpenWrt uses. + +Signed-off-by: Imre Kaloz +--- + init/Kconfig | 9 +++++++++ + init/main.c | 24 ++++++++++++++++++++++++ + 2 files changed, 33 insertions(+) + +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -1888,6 +1888,15 @@ config ARCH_HAS_MEMBARRIER_CALLBACKS + config ARCH_HAS_MEMBARRIER_SYNC_CORE + bool + ++config MANGLE_BOOTARGS ++ bool "Rename offending bootargs" ++ depends on EXPERT ++ help ++ Sometimes the bootloader passed bogus root= and rootfstype= ++ parameters to the kernel, and while you want to ignore them, ++ you need to know the values f.e. to support dual firmware ++ layouts on the flash. ++ + config HAVE_PERF_EVENTS + bool + help +--- a/init/main.c ++++ b/init/main.c +@@ -633,6 +633,29 @@ static inline void setup_nr_cpu_ids(void + static inline void smp_prepare_cpus(unsigned int maxcpus) { } + #endif + ++#ifdef CONFIG_MANGLE_BOOTARGS ++static void __init mangle_bootargs(char *command_line) ++{ ++ char *rootdev; ++ char *rootfs; ++ ++ rootdev = strstr(command_line, "root=/dev/mtdblock"); ++ ++ if (rootdev) ++ strncpy(rootdev, "mangled_rootblock=", 18); ++ ++ rootfs = strstr(command_line, "rootfstype"); ++ ++ if (rootfs) ++ strncpy(rootfs, "mangled_fs", 10); ++ ++} ++#else ++static void __init mangle_bootargs(char *command_line) ++{ ++} ++#endif ++ + /* + * We need to store the untouched command line for future reference. + * We also need to store the touched command line since the parameter +@@ -939,6 +962,7 @@ void start_kernel(void) + jump_label_init(); + static_call_init(); + early_security_init(); ++ mangle_bootargs(command_line); + setup_boot_config(); + setup_command_line(command_line); + setup_nr_cpu_ids(); diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/Makefile b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/Makefile new file mode 100755 index 0000000..f08a9c8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/Makefile @@ -0,0 +1,21 @@ +include $(TOPDIR)/rules.mk + +ARCH:=aarch64 +BOARD:=qualcommax +BOARDNAME:=Qualcomm Atheros 802.11ax WiSoC-s +FEATURES:=squashfs ramdisk fpu nand rtc emmc +KERNELNAME:=Image +CPU_TYPE:=cortex-a53 +SUBTARGETS:=ipq807x ipq60xx ipq50xx + +KERNEL_PATCHVER:=6.12 + +include $(INCLUDE_DIR)/target.mk +DEFAULT_PACKAGES += \ + kmod-usb3 kmod-usb-dwc3 kmod-usb-dwc3-qcom \ + kmod-leds-gpio kmod-gpio-button-hotplug \ + kmod-qca-nss-dp kmod-ath11k-ahb \ + wpad-basic-mbedtls uboot-envtools \ + e2fsprogs kmod-fs-ext4 losetup + +$(eval $(call BuildTarget)) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/config-6.12 b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/config-6.12 new file mode 100755 index 0000000..65944ce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/config-6.12 @@ -0,0 +1,629 @@ +CONFIG_64BIT=y +CONFIG_ARCH_BINFMT_ELF_EXTRA_PHDRS=y +CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE=y +CONFIG_ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG=y +CONFIG_ARCH_DMA_ADDR_T_64BIT=y +CONFIG_ARCH_FORCE_MAX_ORDER=10 +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_KEEP_MEMBLOCK=y +CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE=y +CONFIG_ARCH_MMAP_RND_BITS=18 +CONFIG_ARCH_MMAP_RND_BITS_MAX=24 +CONFIG_ARCH_MMAP_RND_BITS_MIN=18 +CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11 +CONFIG_ARCH_PKEY_BITS=3 +CONFIG_ARCH_PROC_KCORE_TEXT=y +CONFIG_ARCH_QCOM=y +CONFIG_ARCH_SPARSEMEM_ENABLE=y +CONFIG_ARCH_STACKWALK=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_ARCH_WANTS_EXECMEM_LATE=y +CONFIG_ARCH_WANTS_NO_INSTR=y +CONFIG_ARCH_WANTS_THP_SWAP=y +CONFIG_ARM64=y +CONFIG_ARM64_4K_PAGES=y +CONFIG_ARM64_ERRATUM_1165522=y +CONFIG_ARM64_ERRATUM_1286807=y +CONFIG_ARM64_ERRATUM_2051678=y +CONFIG_ARM64_ERRATUM_2054223=y +CONFIG_ARM64_ERRATUM_2067961=y +CONFIG_ARM64_ERRATUM_2077057=y +CONFIG_ARM64_ERRATUM_2658417=y +CONFIG_ARM64_LD_HAS_FIX_ERRATUM_843419=y +CONFIG_ARM64_PA_BITS=48 +CONFIG_ARM64_PA_BITS_48=y +CONFIG_ARM64_PLATFORM_DEVICES=y +CONFIG_ARM64_PTR_AUTH=y +CONFIG_ARM64_PTR_AUTH_KERNEL=y +CONFIG_ARM64_SVE=y +CONFIG_ARM64_TAGGED_ADDR_ABI=y +CONFIG_ARM64_VA_BITS=39 +CONFIG_ARM64_VA_BITS_39=y +# CONFIG_ARM64_VA_BITS_52 is not set +CONFIG_ARM64_WORKAROUND_REPEAT_TLBI=y +CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT=y +CONFIG_ARM64_WORKAROUND_TSB_FLUSH_FAILURE=y +CONFIG_ARM_AMBA=y +CONFIG_ARM_ARCH_TIMER=y +CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y +CONFIG_ARM_GIC=y +CONFIG_ARM_GIC_V2M=y +CONFIG_ARM_GIC_V3=y +CONFIG_ARM_GIC_V3_ITS=y +# CONFIG_ARM_MHU_V2 is not set +# CONFIG_ARM_MHU_V3 is not set +CONFIG_ARM_PSCI_CPUIDLE=y +CONFIG_ARM_PSCI_FW=y +# CONFIG_ARM_QCOM_CPUFREQ_HW is not set +CONFIG_ARM_QCOM_CPUFREQ_NVMEM=y +CONFIG_AT803X_PHY=y +CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y +CONFIG_AUXILIARY_BUS=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_SD=y +CONFIG_BLK_MQ_PCI=y +CONFIG_BLK_MQ_VIRTIO=y +CONFIG_BLK_PM=y +CONFIG_BUILTIN_RETURN_ADDRESS_STRIPS_PAC=y +CONFIG_CC_HAVE_SHADOW_CALL_STACK=y +CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y +# CONFIG_CLK_QCM2290_GPUCC is not set +# CONFIG_CLK_X1E80100_CAMCC is not set +# CONFIG_CLK_X1E80100_DISPCC is not set +# CONFIG_CLK_X1E80100_GCC is not set +# CONFIG_CLK_X1E80100_GPUCC is not set +# CONFIG_CLK_X1E80100_TCSRCC is not set +CONFIG_CLONE_BACKWARDS=y +CONFIG_COMMON_CLK=y +CONFIG_COMMON_CLK_QCOM=y +CONFIG_COMPACT_UNEVICTABLE_DEFAULT=1 +# CONFIG_COMPAT_32BIT_TIME is not set +CONFIG_CONTEXT_TRACKING=y +CONFIG_CONTEXT_TRACKING_IDLE=y +CONFIG_COREDUMP=y +CONFIG_CPUFREQ_DT=y +CONFIG_CPUFREQ_DT_PLATDEV=y +CONFIG_CPU_FREQ=y +# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set +CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y +CONFIG_CPU_FREQ_GOV_ATTR_SET=y +# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set +# CONFIG_CPU_FREQ_GOV_ONDEMAND is not set +CONFIG_CPU_FREQ_GOV_PERFORMANCE=y +# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y +# CONFIG_CPU_FREQ_GOV_USERSPACE is not set +CONFIG_CPU_FREQ_STAT=y +CONFIG_CPU_FREQ_THERMAL=y +CONFIG_CPU_IDLE=y +CONFIG_CPU_IDLE_GOV_MENU=y +CONFIG_CPU_IDLE_MULTIPLE_DRIVERS=y +CONFIG_CPU_LITTLE_ENDIAN=y +CONFIG_CPU_MITIGATIONS=y +CONFIG_CPU_PM=y +CONFIG_CPU_RMAP=y +CONFIG_CPU_THERMAL=y +CONFIG_CRC16=y +CONFIG_CRC8=y +CONFIG_CRYPTO_AUTHENC=y +CONFIG_CRYPTO_CBC=y +CONFIG_CRYPTO_DEFLATE=y +CONFIG_CRYPTO_DEV_QCE=y +CONFIG_CRYPTO_DEV_QCE_AEAD=y +# CONFIG_CRYPTO_DEV_QCE_ENABLE_AEAD is not set +CONFIG_CRYPTO_DEV_QCE_ENABLE_ALL=y +# CONFIG_CRYPTO_DEV_QCE_ENABLE_SHA is not set +# CONFIG_CRYPTO_DEV_QCE_ENABLE_SKCIPHER is not set +CONFIG_CRYPTO_DEV_QCE_SHA=y +CONFIG_CRYPTO_DEV_QCE_SKCIPHER=y +CONFIG_CRYPTO_DEV_QCE_SW_MAX_LEN=512 +CONFIG_CRYPTO_DEV_QCOM_RNG=y +CONFIG_CRYPTO_ECB=y +CONFIG_CRYPTO_HASH_INFO=y +CONFIG_CRYPTO_HW=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y +CONFIG_CRYPTO_LIB_DES=y +CONFIG_CRYPTO_LIB_GF128MUL=y +CONFIG_CRYPTO_LIB_SHA1=y +CONFIG_CRYPTO_LIB_SHA256=y +CONFIG_CRYPTO_LIB_UTILS=y +CONFIG_CRYPTO_LZO=y +CONFIG_CRYPTO_RNG=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_SHA1=y +CONFIG_CRYPTO_SHA256=y +CONFIG_CRYPTO_XTS=y +CONFIG_CRYPTO_ZSTD=y +CONFIG_DCACHE_WORD_ACCESS=y +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_INFO=y +CONFIG_DEV_COREDUMP=y +CONFIG_DMADEVICES=y +CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC=y +CONFIG_DMA_DIRECT_REMAP=y +CONFIG_DMA_ENGINE=y +CONFIG_DMA_NEED_SYNC=y +CONFIG_DMA_OF=y +CONFIG_DMA_VIRTUAL_CHANNELS=y +CONFIG_DTC=y +CONFIG_DT_IDLE_STATES=y +CONFIG_EDAC_SUPPORT=y +CONFIG_EXCLUSIVE_SYSTEM_RAM=y +CONFIG_FIXED_PHY=y +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_FRAME_POINTER=y +CONFIG_FS_IOMAP=y +CONFIG_FUNCTION_ALIGNMENT=4 +CONFIG_FUNCTION_ALIGNMENT_4B=y +CONFIG_FWNODE_MDIO=y +CONFIG_FW_LOADER_PAGED_BUF=y +CONFIG_FW_LOADER_SYSFS=y +CONFIG_GCC_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS=y +CONFIG_GENERIC_ALLOCATOR=y +CONFIG_GENERIC_ARCH_TOPOLOGY=y +CONFIG_GENERIC_BUG=y +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y +CONFIG_GENERIC_CPU_AUTOPROBE=y +CONFIG_GENERIC_CPU_DEVICES=y +CONFIG_GENERIC_CPU_VULNERABILITIES=y +CONFIG_GENERIC_CSUM=y +CONFIG_GENERIC_EARLY_IOREMAP=y +CONFIG_GENERIC_GETTIMEOFDAY=y +CONFIG_GENERIC_IDLE_POLL_SETUP=y +CONFIG_GENERIC_IOREMAP=y +CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_IRQ_SHOW_LEVEL=y +CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED=y +CONFIG_GENERIC_MSI_IRQ=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_PHY=y +CONFIG_GENERIC_PINCONF=y +CONFIG_GENERIC_PINCTRL_GROUPS=y +CONFIG_GENERIC_PINMUX_FUNCTIONS=y +CONFIG_GENERIC_SCHED_CLOCK=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GENERIC_TIME_VSYSCALL=y +CONFIG_GLOB=y +CONFIG_GPIOLIB_IRQCHIP=y +CONFIG_GPIO_CDEV=y +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HWMON=y +CONFIG_HWSPINLOCK=y +CONFIG_HWSPINLOCK_QCOM=y +CONFIG_HW_RANDOM=y +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_HELPER_AUTO=y +# CONFIG_I2C_QCOM_CCI is not set +CONFIG_I2C_QUP=y +CONFIG_IIO=y +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 +CONFIG_INITRAMFS_SOURCE="" +CONFIG_INTERCONNECT=y +CONFIG_INTERCONNECT_CLK=y +# CONFIG_INTERCONNECT_QCOM is not set +# CONFIG_IPQ5018_PHY is not set +CONFIG_IPQ_APSS_6018=y +CONFIG_IPQ_APSS_PLL=y +# CONFIG_IPQ_CMN_PLL is not set +# CONFIG_IPQ_GCC_4019 is not set +# CONFIG_IPQ_GCC_5018 is not set +# CONFIG_IPQ_GCC_5332 is not set +# CONFIG_IPQ_GCC_6018 is not set +# CONFIG_IPQ_GCC_8074 is not set +# CONFIG_IPQ_GCC_9574 is not set +# CONFIG_IPQ_NSSCC_QCA8K is not set +CONFIG_IRQCHIP=y +CONFIG_IRQ_DOMAIN=y +CONFIG_IRQ_DOMAIN_HIERARCHY=y +CONFIG_IRQ_FASTEOI_HIERARCHY_HANDLERS=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_IRQ_MSI_LIB=y +CONFIG_IRQ_WORK=y +# CONFIG_KPSS_XCC is not set +CONFIG_LEDS_TLC591XX=y +CONFIG_LIBFDT=y +CONFIG_LOCK_DEBUGGING_SUPPORT=y +CONFIG_LOCK_SPIN_ON_OWNER=y +CONFIG_LRU_GEN_WALKS_MMU=y +CONFIG_LZO_COMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_MAILBOX=y +# CONFIG_MAILBOX_TEST is not set +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MDIO_IPQ4019=y +# CONFIG_MFD_QCOM_RPM is not set +CONFIG_MFD_SYSCON=y +CONFIG_MIGRATION=y +# CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY is not set +CONFIG_MMC=y +CONFIG_MMC_BLOCK=y +CONFIG_MMC_BLOCK_MINORS=32 +CONFIG_MMC_CQHCI=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_IO_ACCESSORS=y +CONFIG_MMC_SDHCI_MSM=y +CONFIG_MMC_SDHCI_PLTFM=y +CONFIG_MMU_LAZY_TLB_REFCOUNT=y +CONFIG_MODULES_USE_ELF_RELA=y +# CONFIG_MSM_GCC_8916 is not set +# CONFIG_MSM_GCC_8917 is not set +# CONFIG_MSM_GCC_8939 is not set +# CONFIG_MSM_GCC_8976 is not set +# CONFIG_MSM_GCC_8994 is not set +# CONFIG_MSM_GCC_8996 is not set +# CONFIG_MSM_GCC_8998 is not set +# CONFIG_MSM_GPUCC_8998 is not set +# CONFIG_MSM_MMCC_8996 is not set +# CONFIG_MSM_MMCC_8998 is not set +CONFIG_MTD_NAND_CORE=y +CONFIG_MTD_NAND_ECC=y +CONFIG_MTD_NAND_ECC_SW_HAMMING=y +CONFIG_MTD_NAND_QCOM=y +CONFIG_MTD_QCOMSMEM_PARTS=y +CONFIG_MTD_RAW_NAND=y +CONFIG_MTD_SPI_NOR=y +CONFIG_MTD_UBI=y +CONFIG_MTD_UBI_BEB_LIMIT=20 +CONFIG_MTD_UBI_BLOCK=y +CONFIG_MTD_UBI_WL_THRESHOLD=4096 +CONFIG_MUTEX_SPIN_ON_OWNER=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_NET_EGRESS=y +CONFIG_NET_FLOW_LIMIT=y +CONFIG_NET_INGRESS=y +CONFIG_NET_SELFTESTS=y +CONFIG_NET_XGRESS=y +CONFIG_NLS=y +CONFIG_NO_HZ_COMMON=y +CONFIG_NO_HZ_IDLE=y +CONFIG_NR_CPUS=4 +# CONFIG_NSM is not set +CONFIG_NVMEM=y +CONFIG_NVMEM_LAYOUTS=y +CONFIG_NVMEM_LAYOUT_ASCII_ENV=y +CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y +CONFIG_NVMEM_QCOM_QFPROM=y +# CONFIG_NVMEM_QCOM_SEC_QFPROM is not set +CONFIG_NVMEM_SYSFS=y +CONFIG_OF=y +CONFIG_OF_ADDRESS=y +CONFIG_OF_EARLY_FLATTREE=y +CONFIG_OF_FLATTREE=y +CONFIG_OF_GPIO=y +CONFIG_OF_IRQ=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_PADATA=y +CONFIG_PAGE_POOL=y +CONFIG_PAGE_SIZE_LESS_THAN_256KB=y +CONFIG_PAGE_SIZE_LESS_THAN_64KB=y +CONFIG_PARTITION_PERCPU=y +CONFIG_PCI=y +CONFIG_PCIEAER=y +CONFIG_PCIEASPM=y +CONFIG_PCIEASPM_DEFAULT=y +# CONFIG_PCIEASPM_PERFORMANCE is not set +# CONFIG_PCIEASPM_POWERSAVE is not set +# CONFIG_PCIEASPM_POWER_SUPERSAVE is not set +CONFIG_PCIEPORTBUS=y +CONFIG_PCIE_DW=y +CONFIG_PCIE_DW_HOST=y +CONFIG_PCIE_PME=y +CONFIG_PCIE_QCOM=y +CONFIG_PCIE_QCOM_COMMON=y +CONFIG_PCI_DOMAINS=y +CONFIG_PCI_DOMAINS_GENERIC=y +CONFIG_PCI_MSI=y +CONFIG_PER_VMA_LOCK=y +CONFIG_PGTABLE_LEVELS=3 +CONFIG_PHYLIB=y +CONFIG_PHYLIB_LEDS=y +CONFIG_PHYS_ADDR_T_64BIT=y +# CONFIG_PHY_QCOM_APQ8064_SATA is not set +# CONFIG_PHY_QCOM_EDP is not set +# CONFIG_PHY_QCOM_EUSB2_REPEATER is not set +# CONFIG_PHY_QCOM_IPQ4019_USB is not set +# CONFIG_PHY_QCOM_IPQ806X_SATA is not set +# CONFIG_PHY_QCOM_IPQ806X_USB is not set +# CONFIG_PHY_QCOM_M31_USB is not set +# CONFIG_PHY_QCOM_PCIE2 is not set +CONFIG_PHY_QCOM_QMP=y +CONFIG_PHY_QCOM_QMP_COMBO=y +CONFIG_PHY_QCOM_QMP_PCIE=y +CONFIG_PHY_QCOM_QMP_PCIE_8996=y +CONFIG_PHY_QCOM_QMP_UFS=y +CONFIG_PHY_QCOM_QMP_USB=y +# CONFIG_PHY_QCOM_QMP_USB_LEGACY is not set +CONFIG_PHY_QCOM_QUSB2=y +# CONFIG_PHY_QCOM_SGMII_ETH is not set +# CONFIG_PHY_QCOM_SNPS_EUSB2 is not set +# CONFIG_PHY_QCOM_UNIPHY_PCIE_28LP is not set +# CONFIG_PHY_QCOM_USB_HS_28NM is not set +# CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2 is not set +# CONFIG_PHY_QCOM_USB_SS is not set +CONFIG_PINCTRL=y +CONFIG_PINCTRL_AW9523=y +# CONFIG_PINCTRL_IPQ5018 is not set +# CONFIG_PINCTRL_IPQ5332 is not set +# CONFIG_PINCTRL_IPQ6018 is not set +# CONFIG_PINCTRL_IPQ8074 is not set +# CONFIG_PINCTRL_IPQ9574 is not set +CONFIG_PINCTRL_MSM=y +# CONFIG_PINCTRL_MSM8916 is not set +# CONFIG_PINCTRL_MSM8976 is not set +# CONFIG_PINCTRL_MSM8994 is not set +# CONFIG_PINCTRL_MSM8996 is not set +# CONFIG_PINCTRL_MSM8998 is not set +# CONFIG_PINCTRL_QCM2290 is not set +# CONFIG_PINCTRL_QCOM_SSBI_PMIC is not set +# CONFIG_PINCTRL_QCS404 is not set +# CONFIG_PINCTRL_QDU1000 is not set +# CONFIG_PINCTRL_SA8775P is not set +# CONFIG_PINCTRL_SC7180 is not set +# CONFIG_PINCTRL_SC8280XP is not set +# CONFIG_PINCTRL_SDM660 is not set +# CONFIG_PINCTRL_SDM670 is not set +# CONFIG_PINCTRL_SDM845 is not set +# CONFIG_PINCTRL_SDX75 is not set +# CONFIG_PINCTRL_SM4450 is not set +# CONFIG_PINCTRL_SM6350 is not set +# CONFIG_PINCTRL_SM6375 is not set +# CONFIG_PINCTRL_SM7150 is not set +# CONFIG_PINCTRL_SM8150 is not set +# CONFIG_PINCTRL_SM8250 is not set +# CONFIG_PINCTRL_SM8450 is not set +# CONFIG_PINCTRL_SM8550 is not set +# CONFIG_PINCTRL_SM8650 is not set +# CONFIG_PINCTRL_X1E80100 is not set +CONFIG_PM=y +CONFIG_PM_CLK=y +CONFIG_PM_OPP=y +CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y +CONFIG_POWER_RESET=y +CONFIG_POWER_RESET_GPIO=y +# CONFIG_POWER_RESET_MSM is not set +CONFIG_POWER_SUPPLY=y +CONFIG_PRINTK_TIME=y +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_QCA807X_PHY=y +CONFIG_QCA808X_PHY=y +# CONFIG_QCM_DISPCC_2290 is not set +# CONFIG_QCM_GCC_2290 is not set +# CONFIG_QCOM_A53PLL is not set +# CONFIG_QCOM_AOSS_QMP is not set +CONFIG_QCOM_APCS_IPC=y +# CONFIG_QCOM_APM is not set +# CONFIG_QCOM_APR is not set +CONFIG_QCOM_BAM_DMA=y +# CONFIG_QCOM_CLK_APCC_MSM8996 is not set +# CONFIG_QCOM_CLK_APCS_MSM8916 is not set +# CONFIG_QCOM_COMMAND_DB is not set +# CONFIG_QCOM_CPR is not set +# CONFIG_QCOM_CPUCP_MBOX is not set +# CONFIG_QCOM_EBI2 is not set +# CONFIG_QCOM_FASTRPC is not set +# CONFIG_QCOM_GENI_SE is not set +# CONFIG_QCOM_GSBI is not set +# CONFIG_QCOM_HFPLL is not set +# CONFIG_QCOM_ICC_BWMON is not set +# CONFIG_QCOM_IPA is not set +# CONFIG_QCOM_IPCC is not set +# CONFIG_QCOM_LLCC is not set +CONFIG_QCOM_MDT_LOADER=y +# CONFIG_QCOM_MPM is not set +CONFIG_QCOM_NET_PHYLIB=y +# CONFIG_QCOM_OCMEM is not set +# CONFIG_QCOM_PDC is not set +CONFIG_QCOM_PIL_INFO=y +# CONFIG_QCOM_Q6V5_ADSP is not set +CONFIG_QCOM_Q6V5_COMMON=y +# CONFIG_QCOM_Q6V5_MPD is not set +# CONFIG_QCOM_Q6V5_MSS is not set +# CONFIG_QCOM_Q6V5_PAS is not set +CONFIG_QCOM_Q6V5_WCSS=y +# CONFIG_QCOM_Q6V5_WCSS_SEC is not set +# CONFIG_QCOM_QSEECOM is not set +# CONFIG_QCOM_RAMP_CTRL is not set +# CONFIG_QCOM_RMTFS_MEM is not set +# CONFIG_QCOM_RPMH is not set +# CONFIG_QCOM_RPM_MASTER_STATS is not set +CONFIG_QCOM_RPROC_COMMON=y +CONFIG_QCOM_SCM=y +# CONFIG_QCOM_SMD_RPM is not set +CONFIG_QCOM_SMEM=y +CONFIG_QCOM_SMEM_STATE=y +CONFIG_QCOM_SMP2P=y +# CONFIG_QCOM_SMSM is not set +CONFIG_QCOM_SOCINFO=y +# CONFIG_QCOM_SPM is not set +# CONFIG_QCOM_STATS is not set +# CONFIG_QCOM_SYSMON is not set +# CONFIG_QCOM_TMEL_QMP_MAILBOX is not set +CONFIG_QCOM_TSENS=y +CONFIG_QCOM_TZMEM=y +CONFIG_QCOM_TZMEM_MODE_GENERIC=y +# CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE is not set +# CONFIG_QCOM_WCNSS_CTRL is not set +# CONFIG_QCOM_WCNSS_PIL is not set +CONFIG_QCOM_WDT=y +# CONFIG_QCS_GCC_404 is not set +# CONFIG_QCS_Q6SSTOP_404 is not set +# CONFIG_QCS_TURING_404 is not set +# CONFIG_QDU_ECPRICC_1000 is not set +# CONFIG_QDU_GCC_1000 is not set +CONFIG_QUEUED_RWLOCKS=y +CONFIG_QUEUED_SPINLOCKS=y +CONFIG_RANDSTRUCT_NONE=y +CONFIG_RAS=y +CONFIG_RATIONAL=y +CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y +CONFIG_REGMAP_MMIO=y +CONFIG_REGULATOR=y +# CONFIG_REGULATOR_CPR3 is not set +CONFIG_REGULATOR_FIXED_VOLTAGE=y +# CONFIG_REGULATOR_VQMMC_IPQ4019 is not set +CONFIG_RELOCATABLE=y +CONFIG_REMOTEPROC=y +CONFIG_REMOTEPROC_CDEV=y +CONFIG_RESET_CONTROLLER=y +# CONFIG_RESET_QCOM_AOSS is not set +# CONFIG_RESET_QCOM_PDC is not set +CONFIG_RFS_ACCEL=y +CONFIG_RODATA_FULL_DEFAULT_ENABLED=y +CONFIG_RPMSG=y +CONFIG_RPMSG_CHAR=y +# CONFIG_RPMSG_CTRL is not set +# CONFIG_RPMSG_NS is not set +CONFIG_RPMSG_QCOM_GLINK=y +CONFIG_RPMSG_QCOM_GLINK_RPM=y +CONFIG_RPMSG_QCOM_GLINK_SMEM=y +CONFIG_RPMSG_QCOM_SMD=y +# CONFIG_RPMSG_TTY is not set +CONFIG_RPS=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_I2C_AND_SPI=y +CONFIG_RWSEM_SPIN_ON_OWNER=y +# CONFIG_SA_GCC_8775P is not set +# CONFIG_SA_GPUCC_8775P is not set +# CONFIG_SCHED_CORE is not set +CONFIG_SCHED_HW_PRESSURE=y +CONFIG_SCHED_MC=y +CONFIG_SCHED_SMT=y +CONFIG_SCSI=y +CONFIG_SCSI_COMMON=y +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_PROC_FS is not set +# CONFIG_SC_CAMCC_7280 is not set +# CONFIG_SC_CAMCC_8280XP is not set +# CONFIG_SC_DISPCC_7180 is not set +# CONFIG_SC_DISPCC_8280XP is not set +# CONFIG_SC_GCC_7180 is not set +# CONFIG_SC_GCC_8280XP is not set +# CONFIG_SC_GPUCC_7180 is not set +# CONFIG_SC_LPASSCC_7280 is not set +# CONFIG_SC_LPASSCC_8280XP is not set +# CONFIG_SC_LPASS_CORECC_7180 is not set +# CONFIG_SC_LPASS_CORECC_7280 is not set +# CONFIG_SC_VIDEOCC_7180 is not set +# CONFIG_SDM_CAMCC_845 is not set +# CONFIG_SDM_DISPCC_845 is not set +# CONFIG_SDM_GCC_660 is not set +# CONFIG_SDM_GCC_845 is not set +# CONFIG_SDM_GPUCC_845 is not set +# CONFIG_SDM_LPASSCC_845 is not set +# CONFIG_SDM_VIDEOCC_845 is not set +# CONFIG_SDX_GCC_75 is not set +CONFIG_SERIAL_8250_FSL=y +CONFIG_SERIAL_MCTRL_GPIO=y +CONFIG_SERIAL_MSM=y +CONFIG_SERIAL_MSM_CONSOLE=y +CONFIG_SGL_ALLOC=y +CONFIG_SG_POOL=y +CONFIG_SMP=y +# CONFIG_SM_CAMCC_4450 is not set +# CONFIG_SM_CAMCC_6350 is not set +# CONFIG_SM_CAMCC_7150 is not set +# CONFIG_SM_CAMCC_8150 is not set +# CONFIG_SM_CAMCC_8450 is not set +# CONFIG_SM_CAMCC_8550 is not set +# CONFIG_SM_CAMCC_8650 is not set +# CONFIG_SM_GCC_4450 is not set +# CONFIG_SM_GCC_7150 is not set +# CONFIG_SM_GCC_8150 is not set +# CONFIG_SM_GCC_8250 is not set +# CONFIG_SM_GCC_8450 is not set +# CONFIG_SM_GCC_8550 is not set +# CONFIG_SM_GCC_8650 is not set +# CONFIG_SM_GPUCC_4450 is not set +# CONFIG_SM_GPUCC_6115 is not set +# CONFIG_SM_GPUCC_6125 is not set +# CONFIG_SM_GPUCC_6350 is not set +# CONFIG_SM_GPUCC_6375 is not set +# CONFIG_SM_GPUCC_8150 is not set +# CONFIG_SM_GPUCC_8250 is not set +# CONFIG_SM_GPUCC_8350 is not set +# CONFIG_SM_GPUCC_8450 is not set +# CONFIG_SM_GPUCC_8550 is not set +# CONFIG_SM_GPUCC_8650 is not set +# CONFIG_SM_TCSRCC_8550 is not set +# CONFIG_SM_TCSRCC_8650 is not set +# CONFIG_SM_VIDEOCC_7150 is not set +# CONFIG_SM_VIDEOCC_8150 is not set +# CONFIG_SM_VIDEOCC_8250 is not set +# CONFIG_SM_VIDEOCC_8350 is not set +# CONFIG_SM_VIDEOCC_8450 is not set +CONFIG_SOCK_RX_QUEUE_MAPPING=y +CONFIG_SOC_BUS=y +CONFIG_SOFTIRQ_ON_OWN_STACK=y +CONFIG_SPARSEMEM=y +CONFIG_SPARSEMEM_EXTREME=y +CONFIG_SPARSEMEM_VMEMMAP=y +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y +CONFIG_SPARSE_IRQ=y +CONFIG_SPI=y +CONFIG_SPI_MASTER=y +CONFIG_SPI_MEM=y +# CONFIG_SPI_QPIC_SNAND is not set +CONFIG_SPI_QUP=y +CONFIG_SPLIT_PMD_PTLOCKS=y +CONFIG_SPLIT_PTE_PTLOCKS=y +CONFIG_SWIOTLB=y +CONFIG_SWPHY=y +CONFIG_SYSCTL_EXCEPTION_TRACE=y +# CONFIG_TEST_FPU is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=y +CONFIG_THREAD_INFO_IN_TASK=y +CONFIG_TICK_CPU_ACCOUNTING=y +CONFIG_TIMER_OF=y +CONFIG_TIMER_PROBE=y +CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y +CONFIG_TREE_RCU=y +CONFIG_TREE_SRCU=y +CONFIG_UBIFS_FS=y +CONFIG_UBIFS_FS_ADVANCED_COMPR=y +# CONFIG_UCLAMP_TASK is not set +CONFIG_UNMAP_KERNEL_AT_EL0=y +CONFIG_USB=y +CONFIG_USB_COMMON=y +CONFIG_USB_SUPPORT=y +CONFIG_USER_STACKTRACE_SUPPORT=y +CONFIG_VDSO_GETRANDOM=y +CONFIG_VIRTIO=y +CONFIG_VIRTIO_ANCHOR=y +# CONFIG_VIRTIO_BLK is not set +# CONFIG_VIRTIO_DEBUG is not set +# CONFIG_VIRTIO_NET is not set +CONFIG_VMAP_STACK=y +CONFIG_WANT_DEV_COREDUMP=y +CONFIG_WATCHDOG_CORE=y +CONFIG_WATCHDOG_SYSFS=y +CONFIG_XPS=y +CONFIG_XXHASH=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_ZLIB_INFLATE=y +CONFIG_ZONE_DMA32=y +CONFIG_ZSTD_COMMON=y +CONFIG_ZSTD_COMPRESS=y +CONFIG_ZSTD_DECOMPRESS=y diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax6000.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax6000.dts new file mode 100755 index 0000000..67b00f2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax6000.dts @@ -0,0 +1,585 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" + +#include +#include +#include + +/ { + model = "Xiaomi AX6000"; + compatible = "xiaomi,ax6000", "qcom,ipq5018"; + + aliases { + label-mac-device = &dp1; + led-boot = &led_system_blue; + led-failsafe = &led_system_yellow; + led-running = &led_system_blue; + led-upgrade = &led_system_yellow; + serial0 = &blsp1_uart1; + }; + + chosen { + /* Xiaomi's U-boot sets bootargs to: + * ubi.mtd=rootfs_1 root=mtd:ubi_rootfs rootfstype=squashfs rootwait uart_en=1 + * so we need to override and set ubi.mtd=rootfs + */ + bootargs-append = " ubi.mtd=rootfs root=/dev/ubiblock0_0 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset-button { + label = "reset"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_wlan_green: wlan-green { + color = ; + function = LED_FUNCTION_WLAN; + gpios = <&tlmm 23 GPIO_ACTIVE_HIGH>; + }; + + led_system_blue: system-blue { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + }; + + led_system_yellow: system-yellow { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + led_net_blue: net-blue { + color = ; + function = LED_FUNCTION_WAN_ONLINE; + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + }; + + led_net_yellow: net-yellow { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&tlmm 27 GPIO_ACTIVE_HIGH>; + }; + + led_phy_green: phy-green { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x00000000 0x80000>; + read-only; + }; + + partition@80000 { + label = "0:mibib"; + reg = <0x00080000 0x80000>; + read-only; + }; + + partition@100000 { + label = "0:bootconfig"; + reg = <0x00100000 0x40000>; + read-only; + }; + + partition@140000 { + label = "0:bootconfig1"; + reg = <0x00140000 0x40000>; + read-only; + }; + + partition@180000 { + label = "0:qsee"; + reg = <0x00180000 0x100000>; + read-only; + }; + + partition@280000 { + label = "0:qsee_1"; + reg = <0x00280000 0x100000>; + read-only; + }; + + partition@380000 { + label = "0:devcfg"; + reg = <0x00380000 0x40000>; + read-only; + }; + + partition@3c0000 { + label = "0:devcfg_1"; + reg = <0x003c0000 0x40000>; + read-only; + }; + + partition@400000 { + label = "0:cdt"; + reg = <0x00400000 0x40000>; + read-only; + }; + + partition@440000 { + label = "0:cdt_1`"; + reg = <0x00440000 0x40000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x00480000 0x80000>; + }; + + partition@500000 { + label = "0:appsbl"; + reg = <0x00500000 0x140000>; + read-only; + }; + + partition@640000 { + label = "0:appsbl_1"; + reg = <0x00640000 0x140000>; + read-only; + }; + + partition@780000 { + label = "0:art"; + reg = <0x00780000 0x100000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + mac_addr_dp1: macaddr@0 { + reg = <0x0 0x6>; + }; + + mac_addr_dp2: macaddr@6 { + reg = <0x6 0x6>; + }; + + caldata_qca9889: caldata@4d000 { + reg = <0x4d000 0x844>; + }; + }; + }; + + partition@880000 { + label = "0:training"; + reg = <0x00880000 0x80000>; + read-only; + }; + + partition@900000 { + label = "bdata"; + reg = <0x00900000 0x80000>; + }; + + partition@980000 { + label = "crash"; + reg = <0x00980000 0x80000>; + }; + + partition@a00000 { + label = "crash_syslog"; + reg = <0x00a00000 0x80000>; + }; + + partition@a80000 { + label = "ubi_kernel"; + reg = <0x00a80000 0x2400000>; + }; + + partition@2e80000 { + label = "rootfs"; + reg = <0x02e80000 0x5180000>; + }; + }; + }; +}; + +/* +* ================================================================= +* _______________________ _______________________ +* | IPQ5018 | | QCA8337 | +* | +------+ +--------+ | | +--------+ +------+ | +* | | MAC0 |---| GE Phy |-+--- MDI ---+ | Phy3 |---| MAC4 | | +* | +------+ +--------+ | | +--------+ +------+ | +* | | |_______________________| +* | | _______________________ +* | | | QCA8081 | +* | +------+ +--------+ | | +-------------------+ | +* | | MAC1 |---| Uniphy |-+-- SGMII+--+ | Phy | | +* | +------+ +--------+ | | +-------------------+ | +* |_______________________| |_______________________| +* +* ================================================================= +*/ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy --- MDI --- QCA8337 Switch + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + phy_dac = <0x10 0x10>; + }; + + // MAC1 -> Uniphy --- SGMII --- QCA8081 + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + phy_address = <8>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; + + nvmem-cells = <&mac_addr_dp1 0>; + nvmem-cell-names = "mac-address"; +}; + +// MAC1 ---SGMII---> QCA8081 +&dp2 { + status = "okay"; + + label = "wan"; + phy-handle = <&qca8081>; + nvmem-cells = <&mac_addr_dp2 0>; + nvmem-cell-names = "mac-address"; +}; + +&mdio0 { + status = "okay"; +}; + +// IPQ5018 GE Phy -> QCA8337 PHY0 +&ge_phy { + qcom,dac-preset-short-cable; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 -> LAN1 + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN2 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN3 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> IPQ5018 GE Phy + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8081 Phy -> WAN + qca8081: ethernet-phy@8 { + compatible = "ethernet-phy-id004d.d101"; + reg = <8>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + + // QCA8337 switch + ethernet-switch@11 { + compatible = "qca,qca8337"; + reg = <17>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@4 { + reg = <4>; + phy-handle = <&qca8337_3>; + phy-mode = "gmii"; + ethernet = <&dp1>; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + leds_pins: leds-state { + pins = "gpio23", "gpio24", "gpio25", + "gpio26", "gpio27", "gpio28"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + bias-disable; + }; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Xiaomi-AX6000"; + }; + }; +}; + +&pcie1_phy { + status = "okay"; +}; + +&pcie1 { + /* + * although the pcie1 phy probes successfully, the controller is unable + * to bring it up. So let's disable it until a solution is found. + */ + status = "disabled"; + + perst-gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + compatible = "qcom,ath10k"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath10k-calibration-variant = "Xiaomi-AX6000"; + nvmem-cell-names = "calibration"; + nvmem-cells = <&caldata_qca9889>; + }; + }; +}; + +&q6v5_wcss { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6v5_wcss>; + qcom,ath11k-calibration-variant = "Xiaomi-AX6000"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax830.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax830.dts new file mode 100755 index 0000000..310548a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax830.dts @@ -0,0 +1,392 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2025, Shubham Vishwakarma + */ + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "Yuncore AX830"; + compatible = "yuncore,ax830", "qcom,ipq5018"; + + aliases { + serial0 = &blsp1_uart1; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + }; + + wlan2g { + function = LED_FUNCTION_WLAN_2GHZ; + color = ; + gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + function = LED_FUNCTION_WLAN_5GHZ; + color = ; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + }; + + gpio-watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + hw_algo = "toggle"; + hw_margin_ms = <5000>; + always-running; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 -> Uniphy --- SGMII --- QCA8081 + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; + + label = "lan"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + phy-mode = "sgmii"; +}; + +// MAC1 ---SGMII---> QCA8081 +&dp2 { + status = "okay"; + + label = "wan"; + phy-handle = <&qca8081>; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x00 0x30000>; + read-only; + }; + + partition@30000 { + label = "0:MIBIB"; + reg = <0x30000 0x10000>; + read-only; + }; + + partition@40000 { + label = "0:BOOTCONFIG"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "0:BOOTCONFIG1"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:QSEE"; + reg = <0x60000 0xa0000>; + read-only; + }; + + partition@100000 { + label = "0:QSEE_1"; + reg = <0x100000 0xa0000>; + read-only; + }; + + partition@1a0000 { + label = "0:DEVCFG"; + reg = <0x1a0000 0x10000>; + read-only; + }; + + partition@1b0000 { + label = "0:DEVCFG_1"; + reg = <0x1b0000 0x10000>; + read-only; + }; + + partition@1c0000 { + label = "0:CDT"; + reg = <0x1c0000 0x10000>; + read-only; + }; + + partition@1d0000 { + label = "0:CDT_1"; + reg = <0x1d0000 0x10000>; + read-only; + }; + + partition@1e0000 { + label = "0:APPSBLENV"; + reg = <0x1e0000 0x10000>; + }; + + partition@1f0000 { + label = "0:APPSBL"; + reg = <0x1f0000 0xa0000>; + read-only; + }; + + partition@290000 { + label = "0:APPSBL_1"; + reg = <0x290000 0xa0000>; + read-only; + }; + + partition@330000 { + label = "0:ART"; + reg = <0x330000 0x70000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + hw_mac_addr: hw_mac_addr { + #nvmem-cell-cells = <1>; + compatible = "mac-base"; + reg = <0x0 0x6>; + }; + }; + }; + }; + }; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:TRAINING"; + reg = <0x00 0x80000>; + }; + + partition@80000 { + label = "rootfs_1"; + reg = <0x80000 0x3e00000>; + }; + + partition@3e80000 { + label = "rootfs"; + reg = <0x3e80000 0x3e00000>; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + drive-strength = <8>; + bias-disable; + }; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "Yuncore-AX830"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; +}; + +&wifi1 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd3>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd3"; + qcom,ath11k-calibration-variant = "Yuncore-AX830"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax850.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax850.dts new file mode 100755 index 0000000..30b5bc2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-ax850.dts @@ -0,0 +1,412 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2025, Shubham Vishwakarma + */ + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" + +#include +#include +#include + +/ { + model = "Yuncore AX850"; + compatible = "yuncore,ax850", "qcom,ipq5018"; + + aliases { + serial0 = &blsp1_uart1; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + }; + + wlan2g { + function = LED_FUNCTION_WLAN_2GHZ; + color = ; + gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + function = LED_FUNCTION_WLAN_5GHZ; + color = ; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + }; + + gpio-watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + hw_algo = "toggle"; + hw_margin_ms = <5000>; + always-running; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 -> Uniphy --- SGMII --- QCA8081 + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; + + label = "lan"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + phy-mode = "sgmii"; +}; + +// MAC1 ---SGMII---> QCA8081 +&dp2 { + status = "okay"; + + label = "wan"; + phy-handle = <&qca8081>; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x00 0x30000>; + read-only; + }; + + partition@30000 { + label = "0:MIBIB"; + reg = <0x30000 0x10000>; + read-only; + }; + + partition@40000 { + label = "0:BOOTCONFIG"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "0:BOOTCONFIG1"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:QSEE"; + reg = <0x60000 0xa0000>; + read-only; + }; + + partition@100000 { + label = "0:QSEE_1"; + reg = <0x100000 0xa0000>; + read-only; + }; + + partition@1a0000 { + label = "0:DEVCFG"; + reg = <0x1a0000 0x10000>; + read-only; + }; + + partition@1b0000 { + label = "0:DEVCFG_1"; + reg = <0x1b0000 0x10000>; + read-only; + }; + + partition@1c0000 { + label = "0:CDT"; + reg = <0x1c0000 0x10000>; + read-only; + }; + + partition@1d0000 { + label = "0:CDT_1"; + reg = <0x1d0000 0x10000>; + read-only; + }; + + partition@1e0000 { + label = "0:APPSBLENV"; + reg = <0x1e0000 0x10000>; + }; + + partition@1f0000 { + label = "0:APPSBL"; + reg = <0x1f0000 0xa0000>; + read-only; + }; + + partition@290000 { + label = "0:APPSBL_1"; + reg = <0x290000 0xa0000>; + read-only; + }; + + partition@330000 { + label = "0:ART"; + reg = <0x330000 0x70000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + hw_mac_addr: hw_mac_addr { + #nvmem-cell-cells = <1>; + compatible = "mac-base"; + reg = <0x0 0x6>; + }; + }; + }; + }; + }; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:TRAINING"; + reg = <0x00 0x80000>; + }; + + partition@80000 { + label = "rootfs_1"; + reg = <0x80000 0x3e00000>; + }; + + partition@3e80000 { + label = "rootfs"; + reg = <0x3e80000 0x3e00000>; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + bias-disable; + }; +}; + +&tsens { + status = "okay"; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + bridge@0,0 { + reg = <0x00000000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + wifi@1,0 { + status = "okay"; + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + qcom,ath11k-calibration-variant = "Yuncore-AX850"; + }; + }; +}; + +&q6v5_wcss { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6v5_wcss>; + qcom,ath11k-calibration-variant = "Yuncore-AX850"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-gl-b3000.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-gl-b3000.dts new file mode 100755 index 0000000..d0cd077 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-gl-b3000.dts @@ -0,0 +1,333 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "GL.iNet GL-B3000"; + compatible = "glinet,gl-b3000", "qcom,ipq5018"; + + aliases { + ethernet1 = &dp2; + label-mac-device = &dp2; + led-boot = &led_system_blue; + led-failsafe = &led_status_white; + led-running = &led_status_white; + led-upgrade = &led_system_blue; + serial0 = &blsp1_uart1; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + button-reset { + label = "reset"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_system_blue: system-blue { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + }; + + led_status_white: status-white { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 23 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&switch { + status = "okay"; + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> QCA8337 Phy2 + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC1 ---SGMII---> QCA8337 SerDes +&dp2 { + status = "okay"; + nvmem-cells = <&macaddr_dp2 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 -> WAN + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN1 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy3 -> LAN2 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 switch + switch0: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + switch0cpu: port@0 { + reg = <0>; + label = "cpu"; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + // QCA8337 Phy0 -> WAN + port@1 { + reg = <1>; + label = "wan"; + phy-handle = <&qca8337_0>; + }; + + // QCA8337 Phy1 -> LAN1 + port@2 { + reg = <2>; + label = "lan1"; + phy-handle = <&qca8337_1>; + + nvmem-cells = <&macaddr_dp2 2>; + nvmem-cell-names = "mac-address"; + }; + + // QCA8337 Phy3 -> LAN2 + port@3 { + reg = <3>; + label = "lan2"; + phy-handle = <&qca8337_2>; + + nvmem-cells = <&macaddr_dp2 2>; + nvmem-cell-names = "mac-address"; + }; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-art { + label = "0:art"; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_dp2: macaddr@0 { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + reg = <0x6 0x6>; + }; + }; + }; + }; + }; +}; + +&tlmm { + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + leds_pins: leds-pins { + pins = "gpio23", "gpio24"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + button_pins: button-pins { + pins = "gpio27"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + drive-strength = <8>; + bias-disable; + }; +}; + +&q6v5_wcss { + /* B3000 currently doesn't support passing bootargs */ + /*boot-args = < */ + /* type: 0x1 PCIE0 */ + /* length: 4 */ + /* PD id: 3 */ + /* reset GPIO: 15 */ + /* reserved: 0 0>; */ +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; + qcom,ath11k-calibration-variant = "GL-iNet-GL-B3000"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; +}; + +&wifi1 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd3>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd3"; + qcom,ath11k-calibration-variant = "GL-iNet-GL-B3000"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mr3000d-ci.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mr3000d-ci.dts new file mode 100755 index 0000000..a03f9de --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mr3000d-ci.dts @@ -0,0 +1,424 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "CMCC MR3000D-CI"; + compatible = "cmcc,mr3000d-ci", "qcom,ipq5018"; + + aliases { + label-mac-device = <&dp1>; + + led-boot = &led_status_red; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_green; + + serial0 = &blsp1_uart1; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + button-0 { + label = "reset"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + button-1 { + label = "wps"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led_status_red: led-0 { + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_status_green: led-1 { + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + // GigaDevice GD5F1GQ5REYIG + nand@0 { + compatible = "spi-nand"; + reg = <0>; + + nand-ecc-engine = <&qpic_nand>; + nand-ecc-step-size = <512>; + nand-ecc-strength = <8>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-art { + label = "0:art"; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + // WAN MAC address + macaddr_art_0: mac-address@0 { + compatible = "mac-base"; + reg = <0x0 0x6>; + #nvmem-cell-cells = <1>; + }; + + // LAN MAC address + macaddr_art_6: mac-address@6 { + compatible = "mac-base"; + reg = <0x6 0x6>; + #nvmem-cell-cells = <1>; + }; + + // WLAN 2.4 GHz MAC address + macaddr_art_c: mac-address@c { + compatible = "mac-base"; + reg = <0xc 0x6>; + #nvmem-cell-cells = <1>; + }; + + // WLAN 5 GHz MAC address + macaddr_art_12: mac-address@12 { + compatible = "mac-base"; + reg = <0x12 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; +}; + +/* + * =============================================================== + * _______________________ _______________________ + * | IPQ5018 | | QCA8337 | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC0 |---| GE Phy | | | | Phy0 |---| MAC1 | | + * | +------+ +--------+ | | +--------+ +------+ | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC1 |---| Uniphy |-+-SGMII-+-| SerDes |---| MAC6 | | + * | +------+ +--------+ | | +--------+ +------+ | + * |_______________________| |_______________________| + * + * =============================================================== + */ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> QCA8337 Phy4 + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; + + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_art_0 (0)>; +}; + +// MAC1 -> SGMII +&dp2 { + status = "okay"; + + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_art_6 (0)>; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +// MAC0 -> GE Phy -> QCA8337 Phy4 +&ge_phy { + qcom,dac-preset-short-cable; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 -> LAN3 + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN2 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN1 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> WAN + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> IPQ5018 GE Phy + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + + // QCA8337 switch + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan3"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan1"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "wan"; + phy-handle = <&qca8337_3>; + + nvmem-cells = <&macaddr_art_0 (0)>; + nvmem-cell-names = "mac-address"; + }; + + port@6 { + reg = <6>; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + button-pins { + pins = "gpio27", "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + }; + + led_pins: led-state { + pins = "gpio30", "gpio46"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio28", "gpio29"; + function = "blsp0_uart1"; + drive-strength = <8>; + bias-disable; + }; + + switch_reset_pins: switch-reset-state { + pins = "gpio39"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +&q6v5_wcss { + status = "okay"; + + /* The QCN6102 radio should map to UPD ID 2. Without */ + /* bootargs, the firmware will expect it to be on UPD ID 3 */ + boot-args = < + /* type: */ 0x1 /* PCIE0 */ + /* length: */ 4 + /* UPD ID: */ 2 + /* reset GPIO: */ 15 + /* reserved: */ 0 0>; +}; + +&wifi { + // IPQ5018 + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "CMCC-MR3000D-CI"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; +}; + +&wifi1 { + // QCN6102 5G + status = "okay"; + + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "CMCC-MR3000D-CI"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mr5500.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mr5500.dts new file mode 100755 index 0000000..f9ee89d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mr5500.dts @@ -0,0 +1,339 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" + +/ { + model = "Linksys MR5500"; + compatible = "linksys,mr5500", "qcom,ipq5018"; + + chosen { + bootargs-append = " root=/dev/ubiblock0_0 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + gpio-leds { + compatible = "gpio-leds"; + + usb { + color = ; + function = LED_FUNCTION_USB; + gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + trigger-sources = <&usb_port1>; + linux,default-trigger = "usbport"; + }; + }; + + regulator_fixed_5p0: regulator-s0500 { + compatible = "regulator-fixed"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <500000>; + regulator-name = "fixed_5p0"; + gpios = <&tlmm 17 GPIO_ACTIVE_LOW>; + }; +}; + +/* + * =============================================================== + * _______________________ _______________________ + * | IPQ5018 | | QCA8337 | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC0 |---| GE Phy | | | | Phy0 |---| MAC1 | | + * | +------+ +--------+ | | +--------+ +------+ | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC1 |---| Uniphy |-+-SGMII-+-| SerDes |---| MAC6 | | + * | +------+ +--------+ | | +--------+ +------+ | + * |_______________________| |_______________________| + * + * =============================================================== + */ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC1 ---SGMII---> QCA8337 SerDes +&dp2 { + status = "okay"; + + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + port@5 { + reg = <5>; + label = "wan"; + phy-handle = <&qca8337_4>; + phy-mode = "internal"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + + port@6 { + reg = <6>; + label = "cpu"; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + // QCA8337 Phy0 -> LAN1 + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN2 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN3 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> LAN4 + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> WAN + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + }; + }; +}; + +&usbphy0 { + status = "okay"; + + vdd-supply = <®ulator_fixed_5p0>; +}; + +&usb { + status = "okay"; + + vbus-supply = <®ulator_fixed_5p0>; +}; + +&usb_dwc { + #address-cells = <1>; + #size-cells = <0>; + dr_mode = "host"; + + usb_port1: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Linksys-MR5500"; + }; + }; +}; + +&q6v5_wcss { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6v5_wcss>; + qcom,ath11k-calibration-variant = "Linksys-MR5500"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx-base.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx-base.dtsi new file mode 100755 index 0000000..629f523 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx-base.dtsi @@ -0,0 +1,211 @@ +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" + +#include +#include +#include + +/ { + + aliases { + led-boot = &led_system_blue; + led-failsafe = &led_system_red; + led-running = &led_system_blue; + led-upgrade = &led_system_red; + serial0 = &blsp1_uart1; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wps-button { + label = "wps"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset-button { + label = "reset"; + gpios = <&tlmm 28 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "pwm-leds"; + + led_system_red: red { + color = ; + function = LED_FUNCTION_POWER; + pwms = <&pwm 3 1250000>; + max-brightness = <255>; + }; + + green { + color = ; + function = LED_FUNCTION_POWER; + pwms = <&pwm 0 1250000>; + max-brightness = <255>; + }; + + led_system_blue: blue { + color = ; + function = LED_FUNCTION_POWER; + pwms = <&pwm 1 1250000>; + max-brightness = <255>; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&pwm { + status = "okay"; + + #pwm-cells = <2>; + pinctrl-0 = <&pwm_pins>; + pinctrl-names = "default"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-devinfo { + label = "devinfo"; + read-only; + + nvmem-layout { + compatible = "ascii-eq-delim-env"; + #address-cells = <1>; + #size-cells = <1>; + + hw_mac_addr: hw_mac_addr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio27", "gpio28"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + pwm_pins: pwm-state { + mux_1 { + pins = "gpio1"; + function = "pwm1"; + drive-strength = <8>; + }; + + mux_2 { + pins = "gpio30"; + function = "pwm3"; + drive-strength = <8>; + }; + + mux_3 { + pins = "gpio46"; + function = "pwm0"; + drive-strength = <8>; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + bias-disable; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx2000.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx2000.dts new file mode 100755 index 0000000..9d5fae4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx2000.dts @@ -0,0 +1,183 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" +#include "ipq5018-qcn6122.dtsi" + +/ { + model = "Linksys MX2000"; + compatible = "linksys,mx2000", "qcom,ipq5018"; + + chosen { + bootargs-append = " root=/dev/ubiblock0_0 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; +}; + +/* + * =============================================================== + * _______________________ _______________________ + * | IPQ5018 | | QCA8337 | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC0 |---| GE Phy | | | | Phy0 |---| MAC1 | | + * | +------+ +--------+ | | +--------+ +------+ | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC1 |---| Uniphy |-+-SGMII-+-| SerDes |---| MAC6 | | + * | +------+ +--------+ | | +--------+ +------+ | + * |_______________________| |_______________________| + * + * =============================================================== + */ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> QCA8337 Phy4 + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC1 ---SGMII---> QCA8337 SerDes +&dp2 { + status = "okay"; + + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 not connected + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> WAN + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN1 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> LAN2 + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> LAN3 + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + + // QCA8337 switch + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@2 { + reg = <2>; + label = "wan"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan2"; + phy-handle = <&qca8337_3>; + }; + + port@5 { + reg = <5>; + label = "lan1"; + phy-handle = <&qca8337_4>; + }; + + port@6 { + reg = <6>; + label = "cpu"; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&q6v5_wcss { + /* The QCN6102 radio should map to UPD ID 2. Without */ + /* bootargs, the firmware will expect it to be on UPD ID 3 */ + boot-args = < + /* type: */ 0x1 /* PCIE0 */ + /* length: */ 4 + /* UPD ID: */ 2 + /* reset GPIO: */ 15 + /* reserved: */ 0 0>; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "Linksys-MX2000"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; +}; + +&wifi1 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "Linksys-MX2000"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx5500.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx5500.dts new file mode 100755 index 0000000..fd7fa70 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx5500.dts @@ -0,0 +1,186 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" + +/ { + model = "Linksys MX5500"; + compatible = "linksys,mx5500", "qcom,ipq5018"; + + chosen { + bootargs-append = " root=/dev/ubiblock0_0 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; +}; + +/* + * =============================================================== + * _______________________ _______________________ + * | IPQ5018 | | QCA8337 | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC0 |---| GE Phy | | | | Phy0 |---| MAC1 | | + * | +------+ +--------+ | | +--------+ +------+ | + * | +------+ +--------+ | | +--------+ +------+ | + * | | MAC1 |---| Uniphy |-+-SGMII-+-| SerDes |---| MAC6 | | + * | +------+ +--------+ | | +--------+ +------+ | + * |_______________________| |_______________________| + * + * =============================================================== + */ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> QCA8337 Phy4 + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> QCA8337 SerDes + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC1 ---SGMII---> QCA8337 SerDes +&dp2 { + status = "okay"; + + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 not connected + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> WAN + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN1 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> LAN2 + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> LAN3 + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + + // QCA8337 switch + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@2 { + reg = <2>; + label = "wan"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan2"; + phy-handle = <&qca8337_3>; + }; + + port@5 { + reg = <5>; + label = "lan1"; + phy-handle = <&qca8337_4>; + }; + + port@6 { + reg = <6>; + label = "cpu"; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Linksys-MX5500"; + }; + }; +}; + +&q6v5_wcss { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; +}; + +&wifi { + qcom,rproc = <&q6v5_wcss>; + qcom,ath11k-calibration-variant = "Linksys-MX5500"; + qcom,ath11k-fw-memory-mode = <1>; + + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx6200.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx6200.dts new file mode 100755 index 0000000..8bd1281 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-mx6200.dts @@ -0,0 +1,128 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" +#include "ipq5018-qcn6122.dtsi" + +/ { + model = "Linksys MX6200"; + compatible = "linksys,mx6200", "qcom,ipq5018"; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; +}; + +/* +* ================================================================= +* _______________________ ____________ +* | IPQ5018 | | | +* | +------+ +--------+ | | +--------+ | +* | | MAC0 |---| GE Phy |-+--- MDI ---+ | RJ45 | + +* | +------+ +--------+ | | +--------+ | +* | | |____________| +* | | _______________________ +* | | | MXL GPY115C Phy | +* | +------+ +--------+ | | +--------+ +------+ | +* | | MAC1 |---| Uniphy |-+-- SGMII---+ | Phy |---| RJ45 | | +* | +------+ +--------+ | | +--------+ +------+ | +* |_______________________| |_______________________| +* +* ================================================================= + */ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy -> MDI --> RJ45 + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 ---SGMII---> MaxLinear PHY -> RJ45 + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + phy_address = <15>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +// MAC0 ---MDI---> IPQ5018 GE PHY +&dp1 { + status = "okay"; + + label = "lan"; + phy-handle = <&ge_phy>; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +// MAC1 ---SGMII---> MXL Phy +&dp2 { + status = "okay"; + + label = "wan"; + phy-handle = <&gpy115c>; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; + + // Maxlinear Ethernet GPY115C + gpy115c: ethernet-phy@f { + compatible = "ethernet-phy-id67c9.df10"; + reg = <15>; + }; +}; + +&q6_region { + reg = <0x0 0x4b000000 0x0 0x4d00000>; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "Linksys-MX6200"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; +}; + +&wifi1 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "Linksys-MX6200-5G"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,m3-dump-addr = <0x4df00000>; +}; + +&wifi2 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd3>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd3"; + qcom,ath11k-calibration-variant = "Linksys-MX6200-6G"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4e500000>; + qcom,m3-dump-addr = <0x4f200000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-pz-l8.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-pz-l8.dts new file mode 100755 index 0000000..f090075 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-pz-l8.dts @@ -0,0 +1,389 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "CMCC PZ-L8"; + compatible = "cmcc,pz-l8", "qcom,ipq5018"; + + aliases { + serial0 = &blsp1_uart1; + led-boot = &led_wan; + led-failsafe = &led_lan; + led-running = &led_wan; + led-upgrade = &led_lan; + label-mac-device = <&dp1>; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset-button { + label = "reset"; + gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led_wan: led-0 { + gpios = <&tlmm 35 GPIO_ACTIVE_LOW>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "off"; + }; + + led_lan: led-1 { + gpios = <&tlmm 30 GPIO_ACTIVE_LOW>; + color = ; + function = LED_FUNCTION_LAN; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-art { + label = "0:art"; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + hw_mac_addr: mac-address@0 { + compatible = "mac-base"; + reg = <0x0 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy --- MDI --- QCA8337 Phy4(Port5) + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + // MAC1 -> Uniphy --- SGMII --- QCA8337 SerDes(Port6) + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; + + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +// MAC1 -> SGMII +&dp2 { + status = "okay"; + + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +// MAC0 -> GE Phy -> QCA8337 Phy4 +&ge_phy { + qcom,dac-preset-short-cable; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + + // QCA8337 Phy0 -> LAN3 + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN2 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN1 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> WAN + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> IPQ5018 GE Phy + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + + // QCA8337 switch + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan3"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan1"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "wan"; + phy-handle = <&qca8337_3>; + }; + + /* + * WAN cannot work if added + * port@5 { + * reg = <5>; + * phy-handle = <&qca8337_4>; + * phy-mode = "gmii"; + * ethernet = <&dp1>; + * }; + */ + + port@6 { + reg = <6>; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + button-pins { + pins = "gpio34", "gpio33"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + }; + + led_pins: led-state { + pins = "gpio35", "gpio30"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio28", "gpio29"; + function = "blsp0_uart1"; + drive-strength = <8>; + bias-disable; + }; + + switch_reset_pins: switch-reset-state { + pins = "gpio26"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +/* + * ath11k Wi-Fi consumes too large memory spaces and too few spaces are + * available for users. To prevent OOM when using LuCI or other softwares, + * disable Wi-Fi related peripherals at the moment. + */ +&q6v5_wcss { + status = "disabled"; +}; + +&wifi { + // IPQ5018 + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "CMCC-PZ-L8"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; + + ieee80211-freq-limit = <2400000 2483000>; + + status = "disabled"; +}; + +&wifi1 { + // QCN6102 5G + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "CMCC-PZ-L8"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; + + ieee80211-freq-limit = <5150000 5730000>; + + status = "disabled"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-qcn6122.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-qcn6122.dtsi new file mode 100755 index 0000000..a59c6ce --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-qcn6122.dtsi @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/* + * IPQ5018 SoC device tree source extension for QCN6122 wifi + * + * Copyright (c) 2023-2025 The Linux Foundation. All rights reserved. + */ + +&q6_region { + reg = <0x0 0x4b000000 0x0 0x3000000>; +}; + +&q6v5_wcss { + compatible = "qcom,ipq5018-q6-mpd"; + + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt", + "ath11k/QCN6122/hw1.0/m3_fw.mdt"; + + // IPQ5018 + q6_wcss_pd1: pd-1 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + interrupts-extended = + <&wcss_smp2p_in 8 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 9 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 12 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 11 IRQ_TYPE_NONE>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 8>, + <&wcss_smp2p_out 9>, + <&wcss_smp2p_out 10>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + }; + + // QCN6122 + q6_wcss_pd2: pd-2 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + interrupts-extended = + <&wcss_smp2p_in 16 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 17 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 20 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 19 IRQ_TYPE_NONE>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 16>, + <&wcss_smp2p_out 17>, + <&wcss_smp2p_out 18>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + }; + + // QCN6122 + q6_wcss_pd3: pd-3 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + interrupts-extended = + <&wcss_smp2p_in 24 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 25 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 28 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 27 IRQ_TYPE_NONE>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 24>, + <&wcss_smp2p_out 25>, + <&wcss_smp2p_out 26>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + }; +}; + +&soc { + //QCN6122: 1st instance + wifi1: wifi@b00a040 { + reg = <0x0b00a040 0x0>; + compatible = "qcom,qcn6122-wifi"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + ; + status = "disabled"; + }; + + //QCN6122: 2nd instance + wifi2: wifi@b00b040 { + reg = <0x0b00b040 0x0>; + compatible = "qcom,qcn6122-wifi"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + ; + status = "disabled"; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-scr50axe.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-scr50axe.dts new file mode 100755 index 0000000..29faf99 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-scr50axe.dts @@ -0,0 +1,426 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "Zyxel SCR50AXE"; + compatible ="zyxel,scr50axe", "qcom,ipq5018"; + + aliases { + label-mac-device = &dp2; + led-boot = &led_power_blue; + led-failsafe = &led_power_red; + led-upgrade = &led_power_green; + led-running = &led_power_green; + serial0 = &blsp1_uart1; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 swiotlb=1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_power_red: R1 { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 40 GPIO_ACTIVE_HIGH>; + }; + + led_power_green: G1 { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 11 GPIO_ACTIVE_HIGH>; + }; + + led_power_blue: B1 { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 10 GPIO_ACTIVE_HIGH>; + }; + + R2 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + }; + + G2 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + + B2 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&tlmm 32 GPIO_ACTIVE_HIGH>; + }; + + R3 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + G3 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 34 GPIO_ACTIVE_HIGH>; + }; + + B3 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + }; + + R4 { + color = ; + function = LED_FUNCTION_WLAN_6GHZ; + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy2radio"; + }; + + G4 { + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&tlmm 33 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + B4 { + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + + G5 { + color = ; + function = LED_FUNCTION_WPS; + gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&switch { + status = "okay"; + switch_mac_mode = ; + + qcom,port_phyinfo { + + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +&dp1 { + status = "okay"; + + label = "wan"; + nvmem-cells = <&macaddr_appsblenv_ethaddr 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + nvmem-cells = <&macaddr_appsblenv_ethaddr (-4)>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <0x17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + }; + + port@6 { + reg = <6>; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + nand-bus-width = <8>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-appsblenv { + compatible = "fixed-partitions"; + label = "0:appsblenv"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "env-data"; + reg = <0x0 0x40000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_appsblenv_ethaddr: ethaddr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; +}; + +&tlmm { + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + leds_pins: leds-pins { + pins = "gpio26", "gpio35", "gpio32", "gpio25", "gpio34", + "gpio24", "gpio31", "gpio33", "gpio30", "gpio10", + "gpio11", "gpio12", "gpio40"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + button_pins: button-pins { + pins = "gpio22", "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = + "gpio20", // RX + "gpio21"; // TX + function = "blsp0_uart0"; + drive-strength = <8>; + bias-disable; + }; +}; + +&q6_region { + reg = <0x0 0x4b000000 0x0 0x4d00000>; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; + qcom,ath11k-calibration-variant = "Zyxel-SCR50AXE"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4c400000>; +}; + +&wifi1 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "Zyxel-SCR50AXE-5G"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; +}; + +&wifi2 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd3>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd3"; + qcom,ath11k-calibration-variant = "Zyxel-SCR50AXE-6G"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,bdf-addr = <0x4e500000>; + qcom,m3-dump-addr = <0x4f200000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-spnmx56.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-spnmx56.dts new file mode 100755 index 0000000..2cc71e4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-spnmx56.dts @@ -0,0 +1,197 @@ +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-mx-base.dtsi" + +/ { + model = "Linksys SPNMX56"; + compatible = "linksys,spnmx56", "qcom,ipq5018"; + + chosen { + bootargs-append = " root=/dev/ubiblock0_0 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; +}; + +/* +* ================================================================= +* _______________________ _______________________ +* | IPQ5018 | | QCA8337 | +* | +------+ +--------+ | | +--------+ +------+ | +* | | MAC0 |---| GE Phy |-+--- MDI ---+ | Phy4 |---| MAC5 | | +* | +------+ +--------+ | | +--------+ +------+ | +* | | |_______________________| +* | | _______________________ +* | | | QCA8081 | +* | +------+ +--------+ | | +--------+ +------+ | +* | | MAC1 |---| Uniphy |-+-- SGMII+--+ | Phy |---| MAC | | +* | +------+ +--------+ | | +--------+ +------+ | +* |_______________________| |_______________________| +* +* ================================================================= +*/ + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + // MAC0 -> GE Phy --- MDI --- QCA8337 Switch + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + phy_dac = <0x10 0x10>; + }; + + // MAC1 -> Uniphy --- SGMII --- QCA8081 + port@2 { + port_id = <2>; + mdiobus = <&mdio1>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +// MAC0 -> GE Phy +&dp1 { + status = "okay"; + + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +// MAC1 ---SGMII---> QCA8081 +&dp2 { + status = "okay"; + + label = "wan"; + phy-handle = <&qca8081>; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&mdio0 { + status = "okay"; +}; + +// IPQ5018 GE Phy -> QCA8337 PHY4 +&ge_phy { + qcom,dac-preset-short-cable; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + // Not connected + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + // QCA8337 Phy1 -> LAN1 + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + // QCA8337 Phy2 -> LAN2 + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + // QCA8337 Phy3 -> LAN3 + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + // QCA8337 Phy4 -> MDI -> IPQ5018 GE PHY + qca8337_4: ethernet-phy@4 { + reg = <4>; + }; + + // QCA8081 Phy -> WAN + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; + }; + + // QCA8337 switch + switch1: ethernet-switch@17 { + compatible = "qca,qca8337"; + reg = <17>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@2 { + reg = <2>; + label = "lan3"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan2"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan1"; + phy-handle = <&qca8337_3>; + }; + + port@5 { + reg = <5>; + phy-handle = <&qca8337_4>; + phy-mode = "gmii"; + ethernet = <&dp1>; + }; + }; + }; +}; + +&pcie0_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 15 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* QCN9074: ath11k lacks DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Linksys-SPNMX56"; + }; + }; +}; + +&q6v5_wcss { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt"; +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6v5_wcss>; + qcom,ath11k-calibration-variant = "Linksys-SPNMX56"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-wn-dax3000gr.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-wn-dax3000gr.dts new file mode 100755 index 0000000..770cd95 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-wn-dax3000gr.dts @@ -0,0 +1,417 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "I-O DATA WN-DAX3000GR"; + compatible = "iodata,wn-dax3000gr", "qcom,ipq5018"; + + aliases { + serial0 = &blsp1_uart1; + led-boot = &led_status_green; + led-failsafe = &led_status_red; + led-upgrade = &led_status_green; + label-mac-device = <&dp1>; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + button-reset { + label = "reset"; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + switch-led-on { + label = "led-on"; + gpios = <&tlmm 23 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + switch-repeater { + label = "repeater"; + gpios = <&tlmm 31 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + switch-ap { + label = "ap"; + gpios = <&tlmm 32 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + button-wps { + label = "wps"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led-0 { + gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WPS; + }; + + led_status_green: led-1 { + gpios = <&tlmm 13 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_status_red: led-2 { + gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led-3 { + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WAN_ONLINE; + }; + + led-4 { + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + color = ; + function = "router"; + }; + + led-5 { + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + default-state = "on"; + }; + + led-6 { + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WAN; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + + /* strength=8 breaks NAND I/O, use 4 instead */ + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-appsblenv { + compatible = "fixed-partitions"; + label = "0:appsblenv"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "env-data"; + reg = <0x0 0x40000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_appsblenv_ethaddr: ethaddr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +&dp1 { + status = "okay"; + + label = "wan"; + nvmem-cells = <&macaddr_appsblenv_ethaddr 2>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + + nvmem-cells = <&macaddr_appsblenv_ethaddr 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>, <&switch_reset_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + ethernet-switch@18 { + compatible = "qca,qca8337"; + reg = <0x18>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + }; + + port@6 { + reg = <6>; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + key-pullup-pins { + pins = "gpio22", "gpio23", "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + key-pulldown-pins { + pins = "gpio31", "gpio32"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + led_pins: led-state { + pins = "gpio12", "gpio13", "gpio16", "gpio24", + "gpio25", "gpio26", "gpio28"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + bias-disable; + }; + + switch_reset_pins: switch-reset-state { + pins = "gpio39"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +&q6v5_wcss { + boot-args = <0x2 4 2 18 0 0>; /* pcie:1, len:4, updid:2, reset:gpio18 */ +}; + +&wifi { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,ath11k-calibration-variant = "IODATA-WN-DAX3000GR"; + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4c400000>; + + ieee80211-freq-limit = <2400000 2483000>; +}; + +&wifi1 { + status = "okay"; + + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "IODATA-WN-DAX3000GR"; + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; + + ieee80211-freq-limit = <5150000 5730000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-wrc-x3000gs2.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-wrc-x3000gs2.dts new file mode 100755 index 0000000..03a3bbe --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq5018-wrc-x3000gs2.dts @@ -0,0 +1,419 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" +#include "ipq5018-qcn6122.dtsi" + +#include +#include +#include + +/ { + model = "ELECOM WRC-X3000GS2"; + compatible = "elecom,wrc-x3000gs2", "qcom,ipq5018"; + + aliases { + serial0 = &blsp1_uart1; + led-boot = &led_power_green; + led-failsafe = &led_power_red; + led-running = &led_power_green; + led-upgrade = &led_power_green; + label-mac-device = <&dp1>; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + switch-router { + label = "router"; + gpios = <&tlmm 14 GPIO_ACTIVE_HIGH>; + linux,code = ; + linux,input-type = ; + }; + + reset-button { + label = "reset"; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led-0 { + gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WPS; + }; + + led_power_green: led-1 { + gpios = <&tlmm 13 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led_power_red: led-2 { + gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led-3 { + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + linux,default-trigger = "phy1radio"; + }; + + led-4 { + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + }; + + led-5 { + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + linux,default-trigger = "phy0radio"; + }; + + led-6 { + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + }; + + led-7 { + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WAN; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-div = <4>; + clock-mult = <1>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + compatible = "spi-nand"; + reg = <0>; + nand-ecc-engine = <&qpic_nand>; + + /* strength=8 breaks NAND I/O, use 4 instead */ + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-appsblenv { + compatible = "fixed-partitions"; + label = "0:appsblenv"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "env-data"; + reg = <0x0 0x40000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_appsblenv_ethaddr: ethaddr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + port@2 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +&dp1 { + status = "okay"; + + label = "wan"; + nvmem-cells = <&macaddr_appsblenv_ethaddr 3>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + + nvmem-cells = <&macaddr_appsblenv_ethaddr 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>, <&switch_reset_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + ethernet-switch@18 { + compatible = "qca,qca8337"; + reg = <0x18>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + }; + + port@6 { + reg = <6>; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + button-pins { + pins = "gpio22", "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + switch-pins { + pins = "gpio14"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + led_pins: led-state { + pins = "gpio12", "gpio13", "gpio16", "gpio24", + "gpio25", "gpio26", "gpio28", "gpio46"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + bias-disable; + }; + + switch_reset_pins: switch-reset-state { + pins = "gpio39"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +/* + * ath11k Wi-Fi consumes too large memory spaces and too few spaces are + * available for users. To prevent OOM when using LuCI or other softwares, + * disable Wi-Fi related peripherals at the moment. + */ +&q6v5_wcss { + status = "disabled"; + + boot-args = <0x2 4 2 18 0 0>; /* pcie:1, len:4, updid:2, reset:gpio18 */ +}; + +&wifi { + status = "disabled"; + + qcom,rproc = <&q6_wcss_pd1>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; + qcom,ath11k-calibration-variant = "ELECOM-WRC-X3000GS2"; + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4c400000>; + + ieee80211-freq-limit = <2400000 2483000>; +}; + +&wifi1 { + status = "disabled"; + + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "ELECOM-WRC-X3000GS2"; + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; + + ieee80211-freq-limit = <5150000 5730000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-360v6.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-360v6.dts new file mode 100755 index 0000000..07aabe0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-360v6.dts @@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018-512m.dtsi" +#include "ipq6018-ess.dtsi" +#include "ipq6018-cp-cpu.dtsi" + +#include +#include +#include + +/ { + model = "Qihoo 360V6"; + compatible = "qihoo,360v6", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + led-boot = &led_status_red; + led-failsafe = &led_status_red; + led-running = &led_status_green; + led-upgrade = &led_status_orange; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 19 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 68 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: red { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 71 GPIO_ACTIVE_HIGH>; + }; + + led_status_orange: orange { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 72 GPIO_ACTIVE_HIGH>; + }; + + led_status_green: green { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 73 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-fw-memory-mode = <1>; + qcom,ath11k-calibration-variant = "Qihoo-360V6"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-ap120c-ax.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-ap120c-ax.dts new file mode 100755 index 0000000..3cc14d7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-ap120c-ax.dts @@ -0,0 +1,400 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018-512m.dtsi" +#include "ipq6018-ess.dtsi" +#include "ipq6018-cp-cpu.dtsi" + +#include +#include +#include + +/ { + model = "ALFA Network AP120C-AX"; + compatible = "alfa-network,ap120c-ax", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + serial1 = &blsp1_uart2; + led-boot = &led_status_green; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_green; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led_status_green: status { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 55 GPIO_ACTIVE_LOW>; + }; + + wlan2g { + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1radio"; + }; + + wlan5g { + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&tlmm 35 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + }; +}; + +&tlmm { + btcoex_pins: btcoex_pinmux { + mux_0 { + pins = "gpio51"; + function = "pta1_1"; + drive-strength = <6>; + bias-pull-down; + }; + + mux_1 { + pins = "gpio52"; + function = "pta1_2"; + drive-strength = <6>; + bias-pull-down; + }; + + mux_2 { + pins = "gpio53"; + function = "pta1_0"; + drive-strength = <6>; + bias-pull-down; + }; + }; + + btrstint_pins: btrstint_pinmux { + pins = "gpio78", "gpio79"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + }; + + button_pins: button_pinmux { + pins = "gpio9"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + }; + + hsuart_pins: hsuart_pinmux { + pins = "gpio71", "gpio72", "gpio69", "gpio70"; + function = "blsp1_uart"; + drive-strength = <8>; + bias-disable; + }; + + led_pins: led_pinmux { + pins = "gpio35", "gpio37", "gpio55"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio_pins: mdio_pinmux { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + spi_pins: spi_pinmux { + pins = "gpio38", "gpio39", "gpio40", "gpio41"; + function = "blsp0_spi"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +&blsp1_uart3 { + status = "okay"; + + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; +}; + +&blsp1_uart2 { + status = "okay"; + + pinctrl-0 = <&hsuart_pins &btcoex_pins &btrstint_pins>; + pinctrl-names = "default"; + + dmas = <&blsp_dma 2>, <&blsp_dma 3>; + dma-names = "tx", "rx"; +}; + +&blsp1_spi1 { + status = "okay"; + + pinctrl-0 = <&spi_pins>; + pinctrl-names = "default"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x00000000 0x000c0000>; + read-only; + }; + + partition@c0000 { + label = "0:MIBIB"; + reg = <0x000c0000 0x00010000>; + read-only; + }; + + partition@d0000 { + label = "0:BOOTCONFIG"; + reg = <0x000d0000 0x00020000>; + }; + + partition@f0000 { + label = "0:BOOTCONFIG1"; + reg = <0x000f0000 0x00020000>; + }; + + partition@110000 { + label = "0:QSEE"; + reg = <0x00110000 0x001a0000>; + read-only; + }; + + partition@2b0000 { + label = "0:QSEE_1"; + reg = <0x002b0000 0x001a0000>; + read-only; + }; + + partition@450000 { + label = "0:DEVCFG"; + reg = <0x00450000 0x00010000>; + read-only; + }; + + partition@460000 { + label = "0:DEVCFG_1"; + reg = <0x00460000 0x00010000>; + read-only; + }; + + partition@470000 { + label = "0:RPM"; + reg = <0x00470000 0x00040000>; + read-only; + }; + + partition@4b0000 { + label = "0:RPM_1"; + reg = <0x004b0000 0x00040000>; + read-only; + }; + + partition@4f0000 { + label = "0:CDT"; + reg = <0x004f0000 0x00010000>; + read-only; + }; + + partition@500000 { + label = "0:CDT_1"; + reg = <0x00500000 0x00010000>; + read-only; + }; + + partition@510000 { + label = "0:APPSBLENV"; + reg = <0x00510000 0x00010000>; + }; + + partition@520000 { + label = "0:APPSBL"; + reg = <0x00520000 0x000a0000>; + read-only; + }; + + partition@5c0000 { + label = "0:APPSBL_1"; + reg = <0x005c0000 0x000a0000>; + read-only; + }; + + partition@660000 { + label = "0:ART"; + reg = <0x00660000 0x00040000>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_lan: macaddr@6 { + reg = <0x6 0x6>; + }; + + macaddr_wan: macaddr@0 { + reg = <0x0 0x6>; + }; + }; + }; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * This board uses NOR+NAND configuration which is currently not + * supported by 'qcomsmem' MTD parser. Let U-Boot find the NAND + * dt node and populate MTD partitions from SMEM partition table. + * + * This makes it possible to use QCA 'runtime failsafe' and rotate + * 'rootfs'/'rootfs_1' partitions between subsequent updates. + */ + compatible = "qcom,ipq6018-nand", "qcom,ebi2-nandc-bam-v1.5.0"; + + nand@0 { + reg = <0>; + nand-bus-width = <8>; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qcom,package-mode = "psgmii"; + + qca8072_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8072_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_wan_bmp = ; + + switch_mac_mode = ; + + qcom,port_phyinfo { + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp4 { + status = "okay"; + + phy-handle = <&qca8072_3>; + label = "lan"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + + phy-handle = <&qca8072_4>; + label = "wan"; + nvmem-cells = <&macaddr_wan>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-fw-memory-mode = <1>; + qcom,ath11k-calibration-variant = "ALFA-Network-AP120C-AX"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-gl-ax1800.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-gl-ax1800.dts new file mode 100755 index 0000000..cd6e749 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-gl-ax1800.dts @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6000-glinet.dtsi" + +/ { + model = "GL.iNet GL-AX1800"; + compatible = "glinet,gl-ax1800", "qcom,ipq6018"; + + aliases { + label-mac-device = &dp1; + }; +}; + +&partitions { + partition@a00000 { + label = "rootfs"; + reg = <0x0a00000 0x7300000>; + }; +}; + +&switch { + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; + switch_wan_bmp = ; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "wan"; + nvmem-cells = <&macaddr_wan>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan1"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan3"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "lan4"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + qcom,ath11k-calibration-variant = "GL-iNet-GL-AX1800"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-gl-axt1800.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-gl-axt1800.dts new file mode 100755 index 0000000..ca9ef8c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-gl-axt1800.dts @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6000-glinet.dtsi" + +/ { + model = "GL.iNet GL-AXT1800"; + compatible = "glinet,gl-axt1800", "qcom,ipq6018"; + + aliases { + label-mac-device = &dp1; + }; + + vcc_sd: regulator-vcc-sd { + compatible = "regulator-fixed"; + regulator-name = "vcc_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + gpios = <&tlmm 66 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-always-on; + }; + + vcc_fan: regulator-vcc-fan { + compatible = "regulator-fixed"; + regulator-name = "vcc_fan"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-boot-on; + }; + + fan: pwm-fan { + compatible = "pwm-fan"; + pwms = <&pwm 1 40000 0>; + fan-supply = <&vcc_fan>; + interrupt-parent = <&tlmm>; + interrupts = <31 IRQ_TYPE_EDGE_RISING>; + cooling-levels = <36 128 192 255>; + #cooling-cells = <2>; + }; + + thermal-zones { + cpu-thermal { + trips { + cpu_trip_high: active-high { + temperature = <100000>; + hysteresis = <2000>; + type = "active"; + }; + + cpu_trip_med: active-med { + temperature = <75000>; + hysteresis = <2000>; + type = "active"; + }; + + cpu_trip_low: active-low { + temperature = <50000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + cpu-active-high { + cooling-device = <&fan 3 3>; + trip = <&cpu_trip_high>; + }; + + cpu-active-med { + cooling-device = <&fan 2 2>; + trip = <&cpu_trip_med>; + }; + + cpu-active-low { + cooling-device = <&fan 1 1>; + trip = <&cpu_trip_low>; + }; + }; + }; + }; +}; + +&tlmm { + pwm_pins: pwm-pins { + pwm { + pins = "gpio30"; + function = "pwm13"; + drive-strength = <8>; + }; + }; + + sd_pins: sd-pins { + sd { + pins = "gpio62"; + function = "sd_card"; + bias-pull-up; + }; + ldo { + pins = "gpio66"; + function = "gpio"; + bias-pull-up; + }; + }; +}; + +&partitions { + partition@a00000 { + label = "rootfs"; + reg = <0x0a00000 0x7280000>; + }; + + partition@7c80000 { + label = "log"; + reg = <0x7c80000 0x0080000>; + }; +}; + +&pwm { + pinctrl-0 = <&pwm_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&sdhc { + mmc-ddr-1_8v; + bus-width = <4>; + cd-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&sd_pins>; + pinctrl-names = "default"; + vqmmc-supply = <&vcc_sd>; + status = "okay"; +}; + +&switch { + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3)>; + switch_wan_bmp = ; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "wan"; + nvmem-cells = <&macaddr_wan>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan1"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + qcom,ath11k-calibration-variant = "GL-iNet-GL-AXT1800"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-glinet.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-glinet.dtsi new file mode 100755 index 0000000..5c862f3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-glinet.dtsi @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ipq6018-512m.dtsi" +#include "ipq6018-ess.dtsi" + +#include +#include +#include + +/ { + aliases { + led-boot = &led_run; + led-failsafe = &led_run; + led-running = &led_run; + led-upgrade = &led_run; + serial0 = &blsp1_uart3; + serial1 = &blsp1_uart4; + serial2 = &blsp1_uart5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + switch { + label = "switch"; + linux,code = ; + linux,input-type = ; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_run: run { + label = "blue:run"; + color = ; + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + + system { + label = "white:system"; + color = ; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + }; + + reg_usb_vbus: regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 0 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-boot-on; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + tluart_pins: tluart-pins { + mux { + pins = "gpio75", "gpio76"; + function = "blsp3_uart"; + drive-strength = <8>; + bias-disable; + }; + }; + + hsuart_pins: hsuart-pins { + mux { + pins = "gpio57", "gpio58"; + function = "blsp4_uart"; + drive-strength = <8>; + bias-disable; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_uart4 { + pinctrl-0 = <&tluart_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_uart5 { + pinctrl-0 = <&hsuart_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + #address-cells = <1>; + #size-cells = <1>; + + partitions: partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0000000 0x0180000>; + read-only; + }; + + partition@180000 { + label = "0:mibib"; + reg = <0x0180000 0x0100000>; + read-only; + }; + + partition@280000 { + label = "0:qsee"; + reg = <0x0280000 0x0380000>; + read-only; + }; + + partition@600000 { + label = "0:devcfg"; + reg = <0x0600000 0x0080000>; + read-only; + }; + + partition@680000 { + label = "0:rpm"; + reg = <0x0680000 0x0080000>; + read-only; + }; + + partition@700000 { + label = "0:cdt"; + reg = <0x0700000 0x0080000>; + read-only; + }; + + partition@780000 { + label = "0:appsblenv"; + reg = <0x0780000 0x0080000>; + }; + + partition@800000 { + label = "0:appsbl"; + reg = <0x0800000 0x0180000>; + read-only; + }; + + partition@980000 { + label = "0:art"; + reg = <0x0980000 0x0080000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_wan: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_lan: macaddr@6 { + reg = <0x6 0x6>; + }; + }; + }; + + /* rootfs defined in variant dts */ + + partition@7d00000 { + label = "0:ethphyfw"; + reg = <0x7d00000 0x0080000>; + read-only; + }; + }; + }; +}; + +&qusb_phy_0 { + vdd-supply = <®_usb_vbus>; + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&rpm { + status = "disabled"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 74 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-mr7350.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-mr7350.dts new file mode 100755 index 0000000..8406ed2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-mr7350.dts @@ -0,0 +1,432 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + model = "Linksys MR7350"; + compatible = "linksys,mr7350", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + serial1 = &blsp1_uart2; + led-boot = &led_system_blue; + led-running = &led_system_blue; + led-failsafe = &led_system_red; + led-upgrade = &led_system_green; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + + wps-button { + label = "wps"; + linux,code = ; + gpios = <&tlmm 56 GPIO_ACTIVE_LOW>; + }; + + reset-button { + label = "reset"; + linux,code = ; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + usb { + color = ; + function = LED_FUNCTION_USB; + gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>; + trigger-sources = <&usb3_port1>, <&usb3_port2>; + linux,default-trigger = "usbport"; + }; + }; + + reg_usb_vbus: regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 61 GPIO_ACTIVE_LOW>; + regulator-boot-on; + }; +}; + +&tlmm { + hsuart_pins: hsuart-pins { + mux { + pins = "gpio69", "gpio70", + "gpio71", "gpio72"; + function = "blsp1_uart"; + drive-strength = <8>; + bias-disable; + }; + }; + + i2c_pins: i2c-pins { + mux { + pins = "gpio42", "gpio43"; + function = "blsp2_i2c"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + mdio_pins: mdio-state { + mdc-pins { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_i2c3 { + pinctrl-0 = <&i2c_pins>; + pinctrl-names = "default"; + status = "okay"; + + led-controller@62 { + compatible = "nxp,pca9633"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x62>; + + led_system_red: led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_green: led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_blue: led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; +}; + +&blsp1_uart2 { + pinctrl-0 = <&hsuart_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&dwc_0 { + #address-cells = <1>; + #size-cells = <0>; + + usb3_port1: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; + + usb3_port2: port@2 { + reg = <2>; + #trigger-source-cells = <0>; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + #address-cells = <1>; + #size-cells = <1>; + + partition-0-devinfo { + label = "devinfo"; + read-only; + #address-cells = <1>; + #size-cells = <1>; + + nvmem-layout { + compatible = "ascii-eq-delim-env"; + #address-cells = <1>; + #size-cells = <1>; + + hw_mac_addr: hw_mac_addr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; + + vdd-supply = <®_usb_vbus>; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + vbus-supply = <®_usb_vbus>; + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-MR7350"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-re-ss-01.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-re-ss-01.dts new file mode 100755 index 0000000..a71574c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6000-re-ss-01.dts @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018-512m.dtsi" +#include "ipq6018-ess.dtsi" + +#include +#include +#include + +/ { + model = "JDCloud RE-SS-01"; + compatible = "jdcloud,re-ss-01", "qcom,ipq6018"; + + aliases { + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + serial0 = &blsp1_uart3; + + label-mac-device = &dp2; + led-boot = &led_status_red; + led-failsafe = &led_status_red; + led-running = &led_status_green; + led-upgrade = &led_status_blue; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 8 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: red { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + + led_status_blue: blue { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + + led_status_green: green { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + gpio-reserved-ranges = <20 1>; + + button_pins: button-pins { + mux { + pins = "gpio8", "gpio9"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&rpm { + status = "disabled"; +}; + +&sdhc { + bus-width = <8>; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + non-removable; + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan1"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan3"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "JDC-RE-SS-01"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-mango-dvk.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-mango-dvk.dts new file mode 100755 index 0000000..6076945 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-mango-dvk.dts @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + model = "8devices Mango-DVK"; + compatible = "8devices,mango-dvk", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&tlmm 79 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + wlan5g { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <0>; + gpios = <&tlmm 66 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + wlan2g { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <1>; + gpios = <&tlmm 67 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + spi_0_pins: spi-0-pins { + pins = "gpio38", "gpio39", "gpio40", "gpio41"; + function = "blsp0_spi"; + drive-strength = <8>; + bias-pull-down; + }; + + led_pins: led_pins { + leds { + pins = "gpio66", "gpio67"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + sd_pins: sd_pins { + sd_cd { + pins = "gpio62"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x00000000 0x000c0000>; + }; + + partition@c0000 { + label = "0:MIBIB"; + reg = <0x000c0000 0x00010000>; + }; + + partition@d0000 { + label = "0:QSEE"; + reg = <0x000d0000 0x001a0000>; + }; + + partition@270000 { + label = "0:DEVCFG"; + reg = <0x00270000 0x00010000>; + }; + + partition@280000 { + label = "0:RPM"; + reg = <0x00280000 0x00020000>; + }; + + partition@2a0000 { + label = "0:CDT"; + reg = <0x002a0000 0x00010000>; + }; + + partition@2b0000 { + label = "0:APPSBLENV"; + reg = <0x002b0000 0x00010000>; + }; + + partition@2c0000 { + label = "0:APPSBL"; + reg = <0x002c0000 0x000a0000>; + }; + + partition@360000 { + label = "0:ART"; + reg = <0x00360000 0x00040000>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_eth0: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_eth1: macaddr@6 { + reg = <0x6 0x6>; + }; + + macaddr_eth2: macaddr@c { + reg = <0xc 0x6>; + }; + }; + }; + + partition@3a0000 { + label = "config"; + reg = <0x003a0000 0x00040000>; + }; + + partition@3e0000 { + label = "data"; + reg = <0x003e0000 0x00100000>; + }; + + partition@4e0000 { + label = "firmware"; + compatible = "denx,fit"; + reg = <0x004e0000 0x1b20000>; + }; + }; + }; +}; + +&dp3 { + status = "okay"; + + phy-handle = <&qca8072_1>; + nvmem-cells = <&macaddr_eth1>; + nvmem-cell-names = "mac-address"; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + + phy-handle = <&qca8072_0>; + nvmem-cells = <&macaddr_eth0>; + nvmem-cell-names = "mac-address"; + label = "lan1"; +}; + +&dp5 { + status = "okay"; + + phy-mode = "sgmii"; + phy-handle = <&qca8081>; + nvmem-cells = <&macaddr_eth2>; + nvmem-cell-names = "mac-address"; + label = "wan"; +}; + +&edma { + status = "okay"; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "psgmii"; + + qca8072_0: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8072_1: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; + + qca8081: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + reset-assert-us = <10000>; + reset-deassert-us = <50000>; + }; +}; + +&sdhc { + pinctrl-0 = <&sd_pins>; + pinctrl-names = "default"; + status = "okay"; + + bus-width = <4>; + cd-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT3 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + switch_mac_mode1 = ; + port3_pcs_channel = <4>; + + qcom,port_phyinfo { + port@3 { + port_id = <3>; + phy_address = <4>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "nand_data"; + reg = <0x0000000 0x10000000>; + }; + }; + }; +}; + +&pcie_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + perst-gpios = <&tlmm 60 GPIO_ACTIVE_LOW>; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "8devices-Mango"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs-02.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs-02.dts new file mode 100755 index 0000000..6a7e3ef --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs-02.dts @@ -0,0 +1,172 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6010-re-cs.dtsi" + +/ { + model = "JDCloud RE-CS-02"; + compatible = "jdcloud,re-cs-02", "qcom,ipq6018"; + + aliases { + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + + label-mac-device = &dp1; + serial0 = &blsp1_uart3; + serial1 = &blsp1_uart6; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 56 GPIO_ACTIVE_LOW>; + }; + + screen { + label = "screen"; + linux,code = ; + gpios = <&tlmm 71 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 72 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&tlmm { + button_pins: button-pins { + mux { + pins = "gpio56", "gpio71", "gpio72"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + btuart_pins: btuart-pins { + mux { + pins = "gpio48", "gpio49"; + function = "blsp5_uart"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart6 { + pinctrl-0 = <&btuart_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pcie_phy { + status = "okay"; +}; + +&pcie0 { + perst-gpio = <&tlmm 53 GPIO_ACTIVE_LOW>; + status = "okay"; + + pcie@0 { + wifi@0,0 { + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + qcom,ath11k-calibration-variant = "JDC-RE-CS-02"; + }; + }; +}; + +&mdio { + qca8081: ethernet-phy@12 { + compatible = "ethernet-phy-id004d.d101"; + reg = <12>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + switch_mac_mode1 = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <24>; + }; + port@2 { + port_id = <2>; + phy_address = <25>; + }; + port@3 { + port_id = <3>; + phy_address = <26>; + }; + port@4 { + port_id = <4>; + phy_address = <27>; + }; + port@5 { + port_id = <5>; + phy_address = <12>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; +}; + +&dp5 { + status = "okay"; + phy-mode = "sgmii"; + phy-handle = <&qca8081>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "JDC-RE-CS-02"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs-07.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs-07.dts new file mode 100755 index 0000000..650e2c5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs-07.dts @@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6010-re-cs.dtsi" + +/ { + model = "JDCloud RE-CS-07"; + compatible = "jdcloud,re-cs-07", "qcom,ipq6018"; + + aliases { + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + + label-mac-device = &dp2; + serial0 = &blsp1_uart3; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 56 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&tlmm { + button_pins: button-pins { + mux { + pins = "gpio56"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <24>; + }; + port@2 { + port_id = <2>; + phy_address = <25>; + }; + port@3 { + port_id = <3>; + phy_address = <26>; + }; + port@4 { + port_id = <4>; + phy_address = <27>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "wan"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan1"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan3"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs.dtsi new file mode 100755 index 0000000..7ff4326 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-re-cs.dtsi @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ipq6018.dtsi" +#include "ipq6018-ess.dtsi" + +#include +#include +#include + +/ { + aliases { + led-boot = &led_status_red; + led-failsafe = &led_status_red; + led-running = &led_status_green; + led-upgrade = &led_status_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: red { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 57 GPIO_ACTIVE_HIGH>; + }; + + led_status_green: green { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 58 GPIO_ACTIVE_HIGH>; + }; + + led_status_blue: blue { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 79 GPIO_ACTIVE_HIGH>; + }; + }; + + usb_vbus: regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-boot-on; + }; +}; + +&tlmm { + gpio-reserved-ranges = <20 1>; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&qusb_phy_0 { + vdd-supply = <&usb_vbus>; + status = "okay"; +}; + +&rpm { + status = "disabled"; +}; + +&sdhc { + bus-width = <8>; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + non-removable; + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@24 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <24>; + + qca8075_0: ethernet-phy@24 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <24>; + }; + + qca8075_1: ethernet-phy@25 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <25>; + }; + + qca8075_2: ethernet-phy@26 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <26>; + }; + + qca8075_3: ethernet-phy@27 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <27>; + }; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax214.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax214.dts new file mode 100755 index 0000000..90a4828 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax214.dts @@ -0,0 +1,172 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + model = "Netgear WAX214"; + compatible = "netgear,wax214", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + ethernet0 = &dp3; + label-mac-device = &dp3; + led-boot = &pwr; + led-failsafe = &pwr; + led-running = &pwr; + led-upgrade = &pwr; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + pwr: pwr { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + }; + + lan { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <0>; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + wlan5g { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <1>; + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&dp3 { + status = "okay"; + + phy-handle = <&qca8072_4>; + label = "lan"; +}; + +&edma { + status = "okay"; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "psgmii"; + + qca8072_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_mac_mode = ; + port3_pcs_channel = <4>; + + qcom,port_phyinfo { + port@3 { + port_id = <3>; + phy_address = <4>; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + + +&wifi { + status = "okay"; + qcom,ath11k-fw-memory-mode = <1>; + qcom,ath11k-calibration-variant = "Netgear-WAX214"; +}; \ No newline at end of file diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610-base.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610-base.dtsi new file mode 100755 index 0000000..e51ed90 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610-base.dtsi @@ -0,0 +1,206 @@ +#include "ipq6018.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + aliases { + serial0 = &blsp1_uart3; + ethernet0 = &dp5; + label-mac-device = &dp5; + + led-boot = &led_system_blue; + led-failsafe = &led_system_orange; + led-running = &led_system_green; + led-upgrade = &led_system_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + /* + * Netgear's U-Boot adds "ubi.mtd=rootfs root=mtd:ubi_rootfs" + * That fails to create a UBI block device, so add it here. + */ + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_orange: system-orange { + color = ; + function = LED_FUNCTION_POWER; + function-enumerator = <0>; + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + led_system_green: system-green { + color = ; + function = LED_FUNCTION_POWER; + function-enumerator = <1>; + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + }; + + led_system_blue: system-blue { + color = ; + function = LED_FUNCTION_POWER; + function-enumerator = <2>; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; + }; + + led_lan_g { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <0>; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + }; + + led_lan_o { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + }; + + led_2g_b { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <0>; + gpios = <&tlmm 32 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + + led_2g_g { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <1>; + gpios = <&tlmm 33 GPIO_ACTIVE_HIGH>; + }; + + led_5g_b { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <2>; + gpios = <&tlmm 36 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + led_5g_g { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <3>; + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_mac_mode1 = ; + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + + qca8081_24: ethernet-phy@24 { + reg = <24>; + }; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8081_24>; + label = "lan"; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&wifi { + status = "okay"; + + qcom,m3-dump-addr = <0x50100000>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610.dts new file mode 100755 index 0000000..f8530b3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6010-wax610-base.dtsi" + +/ { + model = "Netgear WAX610"; + compatible = "netgear,wax610", "qcom,ipq6018"; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Netgear-WAX610"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610y.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610y.dts new file mode 100755 index 0000000..79d1ae4 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-wax610y.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6010-wax610-base.dtsi" + +/ { + model = "Netgear WAX610Y"; + compatible = "netgear,wax610y", "qcom,ipq6018"; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Netgear-WAX610Y"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-xe3-4.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-xe3-4.dts new file mode 100755 index 0000000..014d788 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6010-xe3-4.dts @@ -0,0 +1,452 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + /* Qualcomm Technologies, Inc. IPQ6018/AP-CP01-C3 */ + model = "Cambium Networks XE3-4"; + compatible = "cambiumnetworks,xe3-4", "qcom,ipq6018-cp01", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + ethernet0 = &dp5; + ethernet1 = &dp4; + label-mac-device = &dp5; + + led-boot = &led_status_amber; + led-failsafe = &led_status_amber; + led-running = &led_status_white; + led-upgrade = &led_status_amber; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 19 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led_status_white: status-white { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 56 GPIO_ACTIVE_LOW>; + }; + + led_status_amber: status-amber { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 35 GPIO_ACTIVE_LOW>; + }; + }; + + reg_sd_vmmc: regulator-sdcard-vmmc { + compatible = "regulator-fixed"; + regulator-name = "sdcard-vmmc"; + regulator-min-microvolt = <2950000>; + regulator-max-microvolt = <2950000>; + + startup-delay-us = <200>; + + gpios = <&tlmm 66 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-names = "default"; + pinctrl-0 = <&sd_vmmc_en_default>; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_i2c3 { + pinctrl-0 = <&i2c_1_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&rpm { + status = "disabled"; +}; + +&tlmm { + /* TZ has exclusive control over GPIO20 */ + gpio-reserved-ranges = <20 1>; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + i2c_1_pins: i2c-1-state { + pins = "gpio42", "gpio43"; + function = "blsp2_i2c"; + drive-strength = <8>; + }; + + spi_0_pins: spi-0-state { + pins = "gpio38", "gpio39", "gpio40", "gpio41"; + function = "blsp0_spi"; + drive-strength = <8>; + bias-pull-down; + }; + + led_pins: led_pins { + leds { + pins = "gpio35", "gpio37", "gpio50"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + sd_vmmc_en_default: sd-vmmc-en-default-state { + pins = "gpio66"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + sd_pins: sd-state { + pins = "gpio62"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; +}; + +&pcie_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + perst-gpios = <&tlmm 60 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* ath11k has no DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-fw-memory-mode = <0>; + qcom,ath11k-calibration-variant = "CambiumNetworks-XE34"; + }; + }; +}; + +&sdhc { + pinctrl-0 = <&sd_pins>; + pinctrl-names = "default"; + status = "okay"; + + cd-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>; + vqmmc-supply = <®_sd_vmmc>; + bus-width = <4>; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT4 | ESS_PORT5)>; + switch_mac_mode = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "psgmii"; + + qca8072: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + reset-assert-us = <10000>; + reset-deassert-us = <50000>; + }; +}; + +&dp4 { + status = "okay"; + + phy-handle = <&qca8072>; + nvmem-cell-names = "mac-address"; + nvmem-cells = <ð1addr 0>; + label = "lan2"; +}; + +&dp5 { + status = "okay"; + + phy-mode = "sgmii"; + phy-handle = <&qca8081>; + nvmem-cell-names = "mac-address"; + nvmem-cells = <ðaddr 0>; + label = "lan1"; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + reg = <0>; + /* + * U-boot looks for "n25q128a11" node, + * if we don't have it, it will spit out the following warning: + * "ipq: fdt fixup unable to find compatible node". + */ + linux,modalias = "m25p80", "mx30uf2g18ac", "n25q128a11"; + compatible = "micron,n25q128a11", "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x0 0xc0000>; + read-only; + }; + + partition@c0000 { + label = "0:MIBIB"; + reg = <0xc0000 0x10000>; + read-only; + }; + + partition@d0000 { + label = "0:BOOTCONFIG"; + reg = <0xd0000 0x20000>; + read-only; + }; + + partition@f0000 { + label = "0:BOOTCONFIG1"; + reg = <0xf0000 0x20000>; + read-only; + }; + + partition@110000 { + label = "0:QSEE"; + reg = <0x110000 0x1a0000>; + read-only; + }; + + partition@2b0000 { + label = "0:QSEE_1"; + reg = <0x2b0000 0x1a0000>; + read-only; + }; + + partition@450000 { + label = "0:DEVCFG"; + reg = <0x450000 0x10000>; + read-only; + }; + + partition@460000 { + label = "mfginfo"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:RPM"; + reg = <0x470000 0x40000>; + read-only; + }; + + partition@4b0000 { + label = "0:RPM_1"; + reg = <0x4b0000 0x40000>; + read-only; + }; + + partition@4f0000 { + label = "0:CDT"; + reg = <0x4f0000 0x10000>; + read-only; + }; + + partition@500000 { + label = "0:CDT_1"; + reg = <0x500000 0x10000>; + read-only; + }; + + partition@510000 { + label = "0:APPSBLENV"; + reg = <0x510000 0x10000>; + + nvmem-layout { + compatible = "u-boot,env"; + + ethaddr: ethaddr { + #nvmem-cell-cells = <0>; + }; + + eth1addr: eth1addr { + #nvmem-cell-cells = <0>; + }; + + eth2addr: eth2addr { + #nvmem-cell-cells = <0>; + }; + + eth5addr: eth5addr { + #nvmem-cell-cells = <0>; + }; + }; + }; + + partition@520000 { + label = "0:APPSBL"; + reg = <0x520000 0xa0000>; + read-only; + }; + + partition@5c0000 { + label = "0:APPSBL_1"; + reg = <0x5c0000 0xa0000>; + read-only; + }; + + partition@660000 { + label = "0:ART"; + reg = <0x660000 0x80000>; + read-only; + }; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs"; + reg = <0x0 0x6000000>; + }; + + partition@6000000 { + label = "rootfs_1"; + reg = <0x6000000 0x6000000>; + }; + + partition@c000000 { + label = "NVRAM"; + reg = <0xc000000 0x3000000>; + }; + + partition@f000000 { + label = "crashLog"; + reg = <0xf000000 0x1000000>; + }; + }; + }; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "CambiumNetworks-XE34"; + + nvmem-cell-names = "mac-address"; + nvmem-cells = <ð2addr>; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap610-outdoor.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap610-outdoor.dts new file mode 100755 index 0000000..33444f3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap610-outdoor.dts @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018-tplink-eap6xx-outdoor.dtsi" + +/ { + model = "TP-Link EAP610-Outdoor"; + compatible = "tplink,eap610-outdoor", "qcom,ipq6018"; +}; + +&wifi { + ieee80211-freq-limit = <2402000 5835000>; + qcom,ath11k-calibration-variant = "TP-Link-EAP610-Outdoor"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap620-hd-v3.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap620-hd-v3.dts new file mode 100755 index 0000000..fd7b9c5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap620-hd-v3.dts @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018-tplink-eap6xx-outdoor.dtsi" + +/ { + model = "TP-Link EAP620HD v3"; + compatible = "tplink,eap620-hd-v3", "qcom,ipq6018"; + + /* Delete EAP6xx outdoor leds node to redefine it. */ + /delete-node/ leds; + + aliases { + led-boot = &led_status_blue; + led-failsafe = &led_status_blue; + led-running = &led_status_blue; + led-upgrade = &led_status_blue; + }; + + leds { + compatible = "gpio-leds"; + + led_status_blue: status-blue { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&mdio { + rtl8211f_4: ethernet-phy@4 { + reg = <4>; + compatible = "ethernet-phy-ieee802.3-c22"; + }; +}; + +&tlmm { + gpio-reserved-ranges = <20 1>; +}; + +&switch { + switch_mac_mode1 = ; +}; + +&wifi { + qcom,ath11k-calibration-variant = "TP-Link-EAP620-HD-v3"; + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap623od-hd-v1.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap623od-hd-v1.dts new file mode 100755 index 0000000..f54593a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap623od-hd-v1.dts @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: MIT, GPL-2.0 or later +/* Copyright (c) 2025, Yang Xiwen */ + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + model = "TP-Link EAP623-Outdoor HD V1.0"; + compatible = "tplink,eap623od-hd-v1", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + led-boot = &led_sys_green; + led-failsafe = &led_sys_yellow; + led-running = &led_sys_green; + led-upgrade = &led_sys_yellow; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_sys_green: led-0 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + + led_sys_yellow: led-1 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 32 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + phy_pins: phy-reset-pin { + pins = "gpio77"; + function = "gpio"; + bias-pull-up; + }; +}; + +&mdio { + status = "okay"; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + pinctrl-0 = <&mdio_pins>, <&phy_pins>; + pinctrl-names = "default"; + + rtl8211f: ethernet-phy@4 { + reg = <4>; + + realtek,clkout-disable; + realtek,aldps-enable; + }; +}; + +&switch { + status = "okay"; + switch_lan_bmp = ; /* lan port bitmap */ + switch_mac_mode1 = ; /* mac mode for uniphy instance0*/ + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <4>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&rtl8211f>; + phy-mode = "sgmii"; + label = "lan"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&wifi { + qcom,ath11k-calibration-variant = "TPLink-EAP623-Outdoor-HD-v1"; + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap625-outdoor-hd-v1.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap625-outdoor-hd-v1.dts new file mode 100755 index 0000000..bb39aae --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-eap625-outdoor-hd-v1.dts @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018-tplink-eap6xx-outdoor.dtsi" + +/ { + model = "TP-Link EAP625-Outdoor HD v1"; + compatible = "tplink,eap625-outdoor-hd-v1", "qcom,ipq6018"; +}; + +&wifi { + qcom,ath11k-calibration-variant = "TP-Link-EAP625-Outdoor-HD-v1"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-fap650.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-fap650.dts new file mode 100755 index 0000000..414b6e7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-fap650.dts @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: MIT, GPL-2.0 or later +/* Copyright (c) 2023, Ruslan Isaev */ + +/dts-v1/; + +#include "ipq6018-512m.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + model = "Yuncore FAP650"; + compatible = "yuncore,fap650", "qcom,ipq6018"; + + aliases { + ethernet0 = &dp5; + ethernet1 = &dp4; + ethernet2 = &dp3; + ethernet3 = &dp2; + ethernet4 = &dp1; + label-mac-device = &dp5; + serial0 = &blsp1_uart3; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 19 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 32 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + + wlan5g { + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "psgmii"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + switch_lan_bmp = <(ESS_PORT1|ESS_PORT2|ESS_PORT3|ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@3 { + port_id = <3>; + phy_address = <2>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&usb2 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + phy-mode = "psgmii"; + label = "wan"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + #address-cells = <1>; + #size-cells = <1>; + compatible = "fixed-partitions"; + + partition@0 { + reg = <0x00000000 0x000c0000>; + label = "0:sbl1"; + }; + + partition@c0000 { + reg = <0x000c0000 0x00010000>; + label = "0:mibib"; + }; + + partition@d0000 { + reg = <0x000d0000 0x00020000>; + label = "0:bootconfig"; + }; + + partition@f0000 { + reg = <0x000f0000 0x00020000>; + label = "0:bootconfig1"; + }; + + partition@110000 { + reg = <0x00110000 0x001a0000>; + label = "0:qsee"; + }; + + partition@2b0000 { + reg = <0x002b0000 0x001a0000>; + label = "0:qsee_1"; + }; + + partition@450000 { + reg = <0x00450000 0x00010000>; + label = "0:devcfg"; + }; + + partition@460000 { + reg = <0x00460000 0x00010000>; + label = "0:devcfg_1"; + }; + + partition@470000 { + reg = <0x00470000 0x00040000>; + label = "0:rpm"; + }; + + partition@4b0000 { + reg = <0x004b0000 0x00040000>; + label = "0:rpm_1"; + }; + + partition@4f0000 { + reg = <0x004f0000 0x00010000>; + label = "0:cdt"; + }; + + partition@500000 { + reg = <0x00500000 0x00010000>; + label = "0:cdt_1"; + }; + + partition@510000 { + reg = <0x00510000 0x00010000>; + label = "0:appsblenv"; + }; + + partition@520000 { + reg = <0x00520000 0x000a0000>; + label = "0:appsbl"; + }; + + partition@5c0000 { + reg = <0x005c0000 0x000a0000>; + label = "0:appsbl_1"; + }; + + partition@660000 { + reg = <0x00660000 0x00040000>; + label = "0:art"; + }; + }; + }; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs"; + reg = <0x00000000 0x03c00000>; + }; + + partition@3c00000 { + label = "rootfs_1"; + reg = <0x03c00000 0x03c00000>; + }; + }; + }; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Yuncore-FAP650"; + qcom,ath11k-fw-memory-mode = <1>; + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-mr7500.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-mr7500.dts new file mode 100755 index 0000000..c2a8ab2 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-mr7500.dts @@ -0,0 +1,540 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// Copyright 2024 Weikai Kong (priv at pppig236.com) + +/dts-v1/; + +#include "ipq6018-512m.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + model = "Linksys MR7500"; + compatible = "linksys,mr7500", "qcom,ipq6018"; + + aliases { + serial0 = &blsp1_uart3; + serial1 = &blsp1_uart2; + + led-boot = &led_system_blue; + led-running = &led_system_blue; + led-failsafe = &led_system_red; + led-upgrade = &led_system_green; + + label-mac-device = &dp5_syn; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0"; + }; + + extcon_usb { + pinctrl-0 = <&extcon_usb_pins>; + pinctrl-names = "default"; + id-gpio = <&tlmm 26 GPIO_ACTIVE_LOW>; + status = "okay"; + }; + + gpio_keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 56 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "pwm-leds"; + + usb { + color = ; + function = LED_FUNCTION_USB; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + pwms = <&pwm 1 650000>; + max-brightness = <255>; + trigger-sources = <&usb3_port1>, <&usb3_port2>; + linux,default-trigger = "usbport"; + }; + + led_system_red: red { + color = ; + function = LED_FUNCTION_INDICATOR; + pwms = <&pwm 2 1250000>; + max-brightness = <255>; + panic-indicator; + }; + + led_system_green: green { + color = ; + function = LED_FUNCTION_INDICATOR; + pwms = <&pwm 3 1250000>; + max-brightness = <255>; + }; + + led_system_blue: blue { + color = ; + function = LED_FUNCTION_POWER; + pwms = <&pwm 0 1250000>; + max-brightness = <255>; + }; + }; + + reg_usb_vbus: regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + }; +}; + +&tlmm { + pwm_pins: pwm_pinmux { + /*LED_B*/ + mux_0 { + pins = "gpio29"; + function = "pwm03"; + drive-strength = <8>; + bias-pull-up; + }; + + /*LED_USB*/ + mux_1 { + pins = "gpio30"; + function = "pwm13"; + drive-strength = <8>; + bias-pull-down; + }; + + /*LED_R*/ + mux_2 { + pins = "gpio31"; + function = "pwm23"; + drive-strength = <8>; + bias-pull-down; + }; + + /*LED_G*/ + mux_3 { + pins = "gpio32"; + function = "pwm33"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + extcon_usb_pins: extcon_usb_pins { + pins = "gpio26"; + function = "gpio"; + drive-strength = <2>; + bias-pull-down; + }; + + button_pins: button_pins { + wps_button { + pins = "gpio37"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + reset_button { + pins = "gpio56"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + mdio_pins: mdio_pinmux { + mux_0 { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + mux_1 { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + hsuart_pins: hsuart_pins { + pins = "gpio71", "gpio72", "gpio69", "gpio70"; + function = "blsp1_uart"; + drive-strength = <8>; + bias-disable; + }; + + btcoex_pins: btcoex_pins { + mux_0 { + pins = "gpio51"; + function = "pta1_1"; + drive-strength = <6>; + bias-pull-down; + }; + mux_1 { + pins = "gpio53"; + function = "pta1_0"; + drive-strength = <6>; + bias-pull-down; + }; + mux_2 { + pins = "gpio52"; + function = "pta1_2"; + drive-strength = <6>; + bias-pull-down; + }; + }; +}; + +&pwm { + pinctrl-0 = <&pwm_pins>; + pinctrl-names = "default"; + #pwm-cells = <2>; + status = "okay"; +}; + +&mdio { + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + status = "okay"; + + ethernet-phy-package { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + }; + + aqr114c: ethernet-phy@8 { + reg = <8>; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_HIGH>; + compatible = "ethernet-phy-ieee802.3-c45"; + firmware-name = "marvell/AQR114C.cld"; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; +}; + +&dp1 { + status = "okay"; + label = "lan1"; + phy-handle = <&qca8075_0>; + phy-mode = "qsgmii"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + label = "lan2"; + phy-handle = <&qca8075_1>; + phy-mode = "qsgmii"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + label = "lan3"; + phy-handle = <&qca8075_2>; + phy-mode = "qsgmii"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + label = "lan4"; + phy-handle = <&qca8075_3>; + phy-mode = "qsgmii"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp5_syn { + status = "okay"; + label = "wan"; + phy-handle = <&aqr114c>; + phy-mode = "usxgmii"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + switch_lan_bmp = <( ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4 )>; + switch_wan_bmp = ; + switch_mac_mode = ; + switch_mac_mode1 = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <8>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_uart2 { + pinctrl-0 = <&hsuart_pins &btcoex_pins>; + pinctrl-names = "default"; + dmas = <&blsp_dma 2>, <&blsp_dma 3>; + dma-names = "tx", "rx"; + status = "okay"; + bluetooth { // doesn't work + compatible = "csr,8811"; + enable-gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + #address-cells = <1>; + #size-cells = <1>; + + partition-0-devinfo { + label = "devinfo"; + read-only; + #address-cells = <1>; + #size-cells = <1>; + + nvmem-layout { + compatible = "ascii-eq-delim-env"; + #address-cells = <1>; + #size-cells = <1>; + + hw_mac_addr: hw_mac_addr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; +}; + +&ssphy_0 { + status = "okay"; +}; + +&dwc_0 { + #address-cells = <1>; + #size-cells = <0>; + + usb3_port1: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; + + usb3_port2: port@2 { + reg = <2>; + #trigger-source-cells = <0>; + }; +}; + +&qusb_phy_0 { + status = "okay"; + vdd-supply = <®_usb_vbus>; +}; + +&usb3 { + status = "okay"; + vbus-supply = <®_usb_vbus>; +}; + +&pcie_phy { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + pcie@0 { + wifi@0,0 { + status = "okay"; + /* ath11k has no DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + qcom,ath11k-calibration-variant = "Linksys-MR7500"; + }; + }; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "Linksys-MR7500"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbr350.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbr350.dts new file mode 100755 index 0000000..ee671d9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbr350.dts @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018-rbx350.dtsi" + +/ { + model = "Netgear RBR350"; + compatible = "netgear,rbr350", "qcom,ipq6018"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbs350.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbs350.dts new file mode 100755 index 0000000..3b3090c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbs350.dts @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: (GPL-2.0+) + +/dts-v1/; + +#include "ipq6018-rbx350.dtsi" + +/ { + model = "Netgear RBS350"; + compatible = "netgear,rbs350", "qcom,ipq6018"; +}; + +&dp2 { + status = "disabled"; +}; + +&dp3 { + status = "disabled"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbx350.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbx350.dtsi new file mode 100755 index 0000000..2b11173 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-rbx350.dtsi @@ -0,0 +1,281 @@ +#include "ipq6018-512m.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" +#include +#include +#include + +/ { + aliases { + led-boot = &led_status_white; + led-failsafe = &led_status_red; + led-upgrade = &led_status_blue; + serial0 = &blsp1_uart3; + label-mac-device = &dp5; + }; + + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.mtd=rootfs root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 19 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + + wps { + label = "wps"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + + power_green { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + + power_red { + function = LED_FUNCTION_FAULT; + color = ; + gpios = <&tlmm 35 GPIO_ACTIVE_LOW>; + }; + + led_status_white: status_white { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + }; + + status_green { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&tlmm 76 GPIO_ACTIVE_LOW>; + }; + + led_status_red: status_red { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + }; + + led_status_blue: status_blue { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&tlmm 78 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@3 { + port_id = <3>; + phy_address = <2>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 75 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + + ethernet-phy-package { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "psgmii"; + + phy0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + phy1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + phy2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + phy3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + phy4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&dp2 { + status = "okay"; + phy-handle = <&phy1>; + label = "wan"; + nvmem-cells = <&macaddr_boarddata 3>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&phy2>; + label = "lan3"; + nvmem-cells = <&macaddr_boarddata 2>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&phy3>; + label = "lan2"; + nvmem-cells = <&macaddr_boarddata 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&phy4>; + label = "lan1"; + nvmem-cells = <&macaddr_boarddata 0>; + nvmem-cell-names = "mac-address"; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-boarddata { + label = "boarddata"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_boarddata: macaddr@8 { + compatible = "mac-base"; + reg = <0x8 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition-0-appsblenv { + label = "0:appsblenv"; + + nvmem-layout { + compatible = "u-boot,env"; + env-size = <0x40000>; + }; + }; + }; + }; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "Netgear-RBK350"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-tplink-eap6xx-outdoor.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-tplink-eap6xx-outdoor.dtsi new file mode 100755 index 0000000..0a551e7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq6018-tplink-eap6xx-outdoor.dtsi @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq6018.dtsi" +#include "ipq6018-cp-cpu.dtsi" +#include "ipq6018-ess.dtsi" + +#include +#include +#include + +/ { + aliases { + serial0 = &blsp1_uart3; + led-boot = &led_sys_green; + led-failsafe = &led_sys_amber; + led-running = &led_sys_green; + led-upgrade = &led_sys_amber; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.block=0,rootfs root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_sys_amber: led-0 { + function = "system"; + color = ; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + }; + + led_sys_green: led-1 { + function = "system"; + color = ; + gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>; + }; + }; + + gpio-restart { + compatible = "gpio-restart"; + gpios = <&tlmm 61 GPIO_ACTIVE_LOW>; + open-source; + }; +}; + +&blsp1_uart3 { + pinctrl-0 = <&serial_3_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio64"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio65"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + phy_reset_pin: phy-reset-pin { + pins = "gpio77"; + function = "gpio"; + bias-pull-up; + }; + + led_enable { + gpio-hog; + output-high; + gpios = <36 GPIO_ACTIVE_HIGH>; + line-name = "enable-leds"; + }; +}; + +&dp5 { + phy-handle = <&rtl8211f_4>; + phy-mode = "sgmii"; + label = "lan"; + status = "okay"; +}; + +&edma { + status = "okay"; +}; + +&mdio { + pinctrl-0 = <&mdio_pins>, <&phy_reset_pin>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + reset-post-delay-us = <50000>; + status = "okay"; + + rtl8211f_4: ethernet-phy@4 { + reg = <4>; + }; +}; + +&switch { + switch_lan_bmp = ; + switch_mac_mode1 = ; + status = "okay"; + + qcom,port_phyinfo { + port@4 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + }; +}; + +&wifi { + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-cax1800.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-cax1800.dts new file mode 100755 index 0000000..8eb534f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-cax1800.dts @@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Dirk Buchwalder */ + +/dts-v1/; + +#include "ipq8074-512m.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include + +/ { + model = "Edimax CAX1800"; + compatible = "edimax,cax1800", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_system_red; + led-failsafe = &led_system_red; + led-running = &led_system_green; + led-upgrade = &led_system_red; + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp5; + label-mac-device = &dp5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 32 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_red: system-red { + label = "red:system"; + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + led_system_green: system-green { + label = "green:system"; + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + }; + + led_system_blue: system-blue { + label = "blue:system"; + gpios = <&tlmm 27 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs"; + reg = <0x0000000 0x3400000>; + }; + }; + }; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + cs-select = <0>; + status = "okay"; + + m25p80@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + use-default-sizes; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + }; + + partition@490000 { + label = "0:appsbl"; + reg = <0x490000 0xa0000>; + read-only; + }; + + partition@530000 { + label = "0:appsbl_1"; + reg = <0x530000 0xa0000>; + read-only; + }; + + partition@5d0000 { + label = "0:art"; + reg = <0x5d0000 0x40000>; + read-only; + }; + + partition@610000 { + label = "0:ethphyfw"; + reg = <0x610000 0x80000>; + read-only; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; /* lan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "lan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Edimax-CAX1800"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-nwa110ax.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-nwa110ax.dts new file mode 100755 index 0000000..c9358a0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-nwa110ax.dts @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2026 Michael Lotz + */ + +/dts-v1/; + +#include "ipq807x-nwax10ax.dtsi" + +/ { + model = "Zyxel NWA110AX"; + compatible = "zyxel,nwa110ax", "qcom,ipq8074"; + + aliases { + ethernet0 = &dp1; + label-mac-device = &dp1; + }; +}; + +&switch { + switch_lan_bmp = ; + switch_mac_mode = ; +}; + +&dp1 { + label = "uplink"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&label_mac 0>; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Zyxel-NWA110AX"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-rm2-6.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-rm2-6.dts new file mode 100755 index 0000000..5d3123f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8070-rm2-6.dts @@ -0,0 +1,310 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074-512m.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "CMCC RM2-6"; + compatible = "cmcc,rm2-6", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + led-boot = &led_status_red; + led-failsafe = &led_status_red; + led-running = &led_status_blue; + led-upgrade = &led_status_amber; + /* + * Aliases as required by u-boot + * to patch MAC addresses + */ + ethernet0 = &dp4; + ethernet1 = &dp2; + ethernet2 = &dp5; + label-mac-device = &dp4; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 30 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_amber: status-amber { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + led_status_blue: status-blue { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + }; + + led_status_red: status-red { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + }; + }; + + fan: gpio-fan { + #cooling-cells = <2>; + compatible = "gpio-fan"; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; + gpio-fan,speed-map = <0 0>, <1 1>; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + status = "okay"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <8>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&cpu0_thermal { + trips { + cpu0_trip_active: cpu-active { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + cpu-active { + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + trip = <&cpu0_trip_active>; + }; + }; +}; + +&cpu1_thermal { + trips { + cpu1_trip_active: cpu-active { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + cpu-active { + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + trip = <&cpu1_trip_active>; + }; + }; +}; + +&cpu2_thermal { + trips { + cpu2_trip_active: cpu-active { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + cpu-active { + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + trip = <&cpu2_trip_active>; + }; + }; +}; + +&cpu3_thermal { + trips { + cpu3_trip_active: cpu-active { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + cpu-active { + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + trip = <&cpu3_trip_active>; + }; + }; +}; + +&cluster_thermal { + trips { + cluster_active: cluster-active { + temperature = <60000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + cluster-active { + cooling-device = <&fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + trip = <&cluster_active>; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +/* + * Directly connect to the Hi5630 + * PLC (Power Line Communication) + */ +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "plc"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "CMCC-RM2-6"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ap8220.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ap8220.dts new file mode 100755 index 0000000..7e70cfc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ap8220.dts @@ -0,0 +1,335 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Aliyun AP8220"; + compatible = "aliyun,ap8220", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 66 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&tlmm 47 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + + wlan5g { + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&tlmm 48 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + bluetooth { + color = ; + function = LED_FUNCTION_BLUETOOTH; + gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; + }; + }; + + gpio-export { + compatible = "gpio-export"; + + ble-power { + gpio-export,name = "ble_power"; + gpio-export,output = <1>; + gpios = <&tlmm 54 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button-pins { + mux { + pins = "gpio66"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:qsee"; + reg = <0x60000 0x180000>; + read-only; + }; + + partition@1e0000 { + label = "0:devcfg"; + reg = <0x1e0000 0x10000>; + read-only; + }; + + partition@1f0000 { + label = "0:apdp"; + reg = <0x1f0000 0x10000>; + read-only; + }; + + partition@200000 { + label = "0:rpm"; + reg = <0x200000 0x40000>; + read-only; + }; + + partition@240000 { + label = "0:cdt"; + reg = <0x240000 0x10000>; + read-only; + }; + + partition@250000 { + label = "0:appsblenv"; + reg = <0x250000 0x10000>; + }; + + partition@260000 { + label = "0:appsbl"; + reg = <0x260000 0xa0000>; + read-only; + }; + + partition@300000 { + label = "0:art"; + reg = <0x300000 0x40000>; + read-only; + }; + + partition@340000 { + label = "0:ethphyfw"; + reg = <0x340000 0x80000>; + read-only; + }; + + partition@3c0000 { + label = "product_info"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "mtdoops"; + reg = <0x3d0000 0x20000>; + }; + + partition@3f0000 { + label = "priv_data1"; + reg = <0x3f0000 0x10000>; + read-only; + }; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs1"; + reg = <0x0000000 0x3000000>; + }; + + partition@3000000 { + label = "rootfs2"; + reg = <0x3000000 0x3000000>; + }; + + partition@6000000 { + label = "usrdata"; + reg = <0x6000000 0x2000000>; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + + qca8081_24: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + }; + + qca8081_28: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_wan_bmp = ; + switch_mac_mode1 = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5 { + status = "okay"; + phy-mode = "sgmii"; + phy-handle = <&qca8081_24>; + label = "wan"; +}; + +&dp6 { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "lan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Aliyun-AP8220"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax3600.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax3600.dts new file mode 100755 index 0000000..4df2adb --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax3600.dts @@ -0,0 +1,125 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Robert Marko */ + +/dts-v1/; + +#include "ipq8071-ax3600.dtsi" +#include + +/ { + model = "Xiaomi AX3600"; + compatible = "xiaomi,ax3600", "qcom,ipq8074"; + + leds { + compatible = "gpio-leds"; + + led_system_blue: system-blue { + label = "blue:system"; + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + }; + + led_system_yellow: system-yellow { + label = "yellow:system"; + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + }; + + network-yellow { + label = "yellow:network"; + gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>; + }; + + network-blue { + label = "blue:network"; + gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + }; + + aiot { + label = "blue:aiot"; + gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0tpt"; + }; + }; +}; + +&pcie_qmp0 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 52 GPIO_ACTIVE_HIGH>; + + pcie@0 { + wifi0: wifi@0,0 { + status = "okay"; + + compatible = "qcom,ath10k"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath10k-calibration-variant = "Xiaomi-AX3600"; + nvmem-cell-names = "calibration"; + nvmem-cells = <&caldata_qca9889>; + }; + }; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Xiaomi-AX3600"; +}; + +&qca8075_1 { + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; +}; + +&qca8075_2 { + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; +}; + +&qca8075_3 { + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; +}; + +&qca8075_4 { + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax3600.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax3600.dtsi new file mode 100755 index 0000000..6afafb3 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax3600.dtsi @@ -0,0 +1,311 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Robert Marko */ + +#include "ipq8074-512m.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include + +/ { + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_system_yellow; + led-failsafe = &led_system_yellow; + led-running = &led_system_blue; + led-upgrade = &led_system_yellow; + label-mac-device = &dp2; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:qsee"; + reg = <0x200000 0x300000>; + read-only; + }; + + partition@500000 { + label = "0:devcfg"; + reg = <0x500000 0x80000>; + read-only; + }; + + partition@580000 { + label = "0:rpm"; + reg = <0x580000 0x80000>; + read-only; + }; + + partition@600000 { + label = "0:cdt"; + reg = <0x600000 0x80000>; + read-only; + }; + + partition@680000 { + label = "0:appsblenv"; + reg = <0x680000 0x80000>; + }; + + partition@700000 { + label = "0:appsbl"; + reg = <0x700000 0x100000>; + read-only; + }; + + partition@800000 { + label = "0:art"; + reg = <0x800000 0x80000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_dp2: macaddr@6 { + reg = <0x6 0x6>; + }; + + macaddr_dp3: macaddr@c { + reg = <0xc 0x6>; + }; + + macaddr_dp4: macaddr@12 { + reg = <0x12 0x6>; + }; + + macaddr_dp5: macaddr@18 { + reg = <0x18 0x6>; + }; + + caldata_qca9889: caldata@4d000 { + reg = <0x33000 0x844>; + }; + }; + }; + + partition@880000 { + label = "bdata"; + reg = <0x880000 0x80000>; + }; + + partition@900000 { + /* This is crash + crash_syslog parts combined */ + label = "pstore"; + reg = <0x900000 0x100000>; + }; + + /* Make the first rootfs a dedicated ubi partition for kernel */ + partition@a00000 { + label = "ubi_kernel"; + reg = <0xa00000 0x23c0000>; + }; + + /* Place the real rootfs in the original second rootfs and + * expand it to the end of the nand + */ + rootfs: partition@2dc0000 { + label = "rootfs"; + reg = <0x2dc0000 0xd240000>; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "wan"; + nvmem-cells = <&macaddr_dp2>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan1"; + nvmem-cells = <&macaddr_dp3>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan2"; + nvmem-cells = <&macaddr_dp4>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "lan3"; + nvmem-cells = <&macaddr_dp5>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax6.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax6.dts new file mode 100755 index 0000000..6611a8f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-ax6.dts @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Zhijun You */ + +/dts-v1/; + +#include "ipq8071-ax3600.dtsi" + +/ { + model = "Redmi AX6"; + compatible = "redmi,ax6", "qcom,ipq8074"; + + leds { + compatible = "gpio-leds"; + + led_system_blue: system-blue { + label = "blue:system"; + gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + }; + + led_system_yellow: system-yellow { + label = "yellow:system"; + gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>; + }; + + network-blue { + label = "blue:network"; + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + }; + + network-yellow { + label = "yellow:network"; + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +/* AX6 can both have NAND of 256MiB or 128MiB. + * To be on the safe side, assume 128MiB of NAND. + */ +&rootfs { + reg = <0x2dc0000 0x5220000>; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Redmi-AX6"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-eap102.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-eap102.dts new file mode 100755 index 0000000..41b6dd0 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-eap102.dts @@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2022, Matthew Hagan */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Edgecore EAP102"; + compatible = "edgecore,eap102", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + led-boot = &led_system_green; + led-failsafe = &led_system_green; + led-running = &led_system_green; + led-upgrade = &led_system_green; + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp6; + ethernet1 = &dp5; + label-mac-device = &dp5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + gpios = <&tlmm 66 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_wanpoe { + label = "green:wanpoe"; + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + }; + + led_wlan2g { + label = "green:wlan2g"; + gpios = <&tlmm 47 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + + led_wlan5g { + label = "green:wlan5g"; + gpios = <&tlmm 48 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + + led_system_green: led_system { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button_pins { + reset_button { + pins = "gpio66"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + }; + + partition@490000 { + label = "0:appsbl"; + reg = <0x490000 0xc0000>; + read-only; + }; + + partition@550000 { + label = "0:appsbl_1"; + reg = <0x530000 0xc0000>; + read-only; + }; + + partition@610000 { + label = "0:art"; + reg = <0x610000 0x40000>; + read-only; + }; + + partition@650000 { + label = "0:ethphyfw"; + reg = <0x650000 0x80000>; + read-only; + }; + + partition@6d0000 { + label = "0:product_info"; + reg = <0x6d0000 0x80000>; + read-only; + }; + + partition@750000 { + label = "priv_data1"; + reg = <0x750000 0x10000>; + read-only; + }; + + partition@760000 { + label = "priv_data2"; + reg = <0x760000 0x10000>; + read-only; + }; + }; + }; +}; + +&blsp1_uart3 { + status = "okay"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <8>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs1"; + reg = <0x0000000 0x3400000>; + }; + + partition@3400000 { + label = "0:wififw"; + reg = <0x3400000 0x800000>; + read-only; + }; + + partition@3c00000 { + label = "rootfs2"; + reg = <0x3c00000 0x3400000>; + }; + + partition@7000000 { + label = "0:wififw_1"; + reg = <0x7000000 0x800000>; + read-only; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + + qca8081_24: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + }; + + qca8081_28: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5 { + status = "okay"; + phy-mode = "sgmii"; + phy-handle = <&qca8081_24>; + label = "lan"; +}; + +&dp6 { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Edgecore-EAP102"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-mf269.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-mf269.dts new file mode 100755 index 0000000..a45c28b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-mf269.dts @@ -0,0 +1,450 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074-512m.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "ZTE MF269"; + compatible = "zte,mf269", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + label-mac-device = &dp6_syn; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 46 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&tlmm 56 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + button_pins: button_pins { + mux { + pins = "gpio37", "gpio46"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + i2c_pins: i2c-pins { + pins = "gpio21", "gpio22"; + function = "blsp4_i2c1"; + drive-strength = <8>; + bias-disable; + }; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + usb_pwr_pins: usb_pwr_pins { + mux { + pins = "gpio29"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + output-high; + }; + }; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + cs-select = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + }; + + partition@490000 { + label = "0:appsbl"; + reg = <0x490000 0xc0000>; + read-only; + }; + + partition@550000 { + label = "0:appsbl_1"; + reg = <0x550000 0xc0000>; + read-only; + }; + + partition@610000 { + label = "0:art"; + reg = <0x610000 0x40000>; + read-only; + }; + + partition@650000 { + label = "0:ethphyfw"; + reg = <0x650000 0x80000>; + read-only; + }; + }; + }; +}; + +&blsp1_i2c5 { + pinctrl-0 = <&i2c_pins>; + pinctrl-names = "default"; + status = "okay"; + + /* No driver exists */ + aw9106: gpio-expander@5b { + reg = <0x5b>; + reset-gpios = <&tlmm 54 GPIO_ACTIVE_HIGH>; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "fota-flag"; + reg = <0x0000000 0x00a0000>; + read-only; + }; + + partition@a0000 { + label = "mac"; + reg = <0x00a0000 0x0080000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_mac_0: macaddr@0 { + compatible = "mac-base"; + reg = <0x0 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@120000 { + label = "cfg-param"; + reg = <0x0120000 0x1400000>; + read-only; + }; + + partition@1520000 { + label = "log"; + reg = <0x1520000 0x0600000>; + read-only; + }; + + partition@1b20000 { + label = "oops"; + reg = <0x1b20000 0x00a0000>; + read-only; + }; + + partition@1bc0000 { + label = "web"; + reg = <0x1bc0000 0x0800000>; + read-only; + }; + + partition@23c0000 { + label = "ubi_kernel"; + reg = <0x23c0000 0x3400000>; + }; + + partition@57c0000 { + label = "0:wififw"; + reg = <0x57c0000 0x0800000>; + read-only; + }; + + /* rootfs partition is the result of squashing + * consecutive stock partitions: + * - openwrt_data (25 MiB) + * - data (30 MiB) + * - fota (99 MiB) + */ + partition@5fc0000 { + label = "rootfs"; + reg = <0x5fc0000 0x9a00000>; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + pinctrl-0 = <&usb_pwr_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + + qca8081_24: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + }; + + qca8081_28: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5_syn { + status = "okay"; + phy-handle = <&qca8081_24>; + label = "lan"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_mac_0 1>; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "wan"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_mac_0 0>; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "ZTE-MF269"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-nwa210ax.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-nwa210ax.dts new file mode 100755 index 0000000..91a4027 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8071-nwa210ax.dts @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2025 Pascal Beleiu + * Copyright (c) 2025 Eric SchΓ€fer + */ + +/dts-v1/; + +#include "ipq807x-nwax10ax.dtsi" + +/ { + model = "Zyxel NWA210AX"; + compatible = "zyxel,nwa210ax", "qcom,ipq8074"; + + aliases { + ethernet0 = &dp5; + ethernet1 = &dp1; + label-mac-device = &dp5; + }; + + leds { + compatible = "gpio-leds"; + + gpio_green { + gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; + default-state = "off"; + color = ; + function = LED_FUNCTION_STATUS; + }; + + gpio_red { + gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>; + default-state = "off"; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; +}; + +&tlmm { + button_pins: button-pins { + pins = "gpio30"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; +}; + +&switch { + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT5)>; + switch_mac_mode = ; + switch_mac_mode1 = ; +}; + +&phyinfo { + port@5 { + port_id = <5>; + phy_address = <16>; + port_mac_sel = "QGMAC_PORT"; + }; +}; + +&mdio { + qca8081: ethernet-phy@16 { + compatible = "ethernet-phy-id004d.d101"; + reg = <16>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + +&dp1 { + label = "lan1"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&label_mac 1>; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8081>; + phy-mode = "sgmii"; + label = "uplink"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&label_mac 0>; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Zyxel-NWA210AX"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-301w.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-301w.dts new file mode 100755 index 0000000..5edb4e1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-301w.dts @@ -0,0 +1,533 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Dirk Buchwalder */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "QNAP 301w"; + compatible = "qnap,301w", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + /* + * Aliases as required by u-boot + * to patch MAC addresses + */ + led-boot = &led_system_red; + led-failsafe = &led_system_red; + led-running = &led_pwr_green; + led-upgrade = &led_system_red; + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + ethernet5 = &dp6_syn; + label-mac-device = &dp1; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wps-button { + label = "wps"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset-button { + label = "reset"; + gpios = <&tlmm 67 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&leds_pins>; + pinctrl-names = "default"; + + led_system_green: led-system-green { + gpios = <&tlmm 1 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_red: led-system-red { + gpios = <&tlmm 3 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_pwr_green: led-pwr-green { + gpios = <&tlmm 4 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led-wifi-green { + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN; + }; + + led-lan4-green { + gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <4>; + }; + + led-lan4-amber { + gpios = <&tlmm 7 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <4>; + }; + + led-lan3-green { + gpios = <&tlmm 8 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <3>; + }; + + led-lan3-amber { + gpios = <&tlmm 11 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <3>; + }; + + led-lan2-green { + gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <2>; + }; + + led-lan2-amber { + gpios = <&tlmm 13 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <2>; + }; + + led-lan1-green { + gpios = <&tlmm 14 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + }; + + led-lan1-amber { + gpios = <&tlmm 15 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + }; + + led-10g-1-green { + gpios = <&tlmm 54 GPIO_ACTIVE_HIGH>; + color = ; + function = "10g"; + function-enumerator = <1>; + }; + + led-10g-1-amber { + gpios = <&tlmm 56 GPIO_ACTIVE_HIGH>; + color = ; + function = "10g"; + function-enumerator = <1>; + }; + + led-10g-2-green { + gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>; + color = ; + function = "10g"; + function-enumerator = <2>; + }; + + led-10g-2-amber { + gpios = <&tlmm 52 GPIO_ACTIVE_HIGH>; + color = ; + function = "10g"; + function-enumerator = <2>; + }; + }; +}; + +&tlmm { + + mdio_pins: mdio-state { + mdc-pins { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button-state { + wps-pins { + pins = "gpio57"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + rst-pins { + pins = "gpio67"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + leds_pins: leds-state { + pins = "gpio1", "gpio3", "gpio4", "gpio6", "gpio7", "gpio8", + "gpio11", "gpio12", "gpio13", "gpio14", "gpio15", "gpio42", + "gpio51", "gpio52", "gpio54", "gpio56"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_spi1 { /* BLSP1 QUP1 */ + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:qsee"; + reg = <0x60000 0x180000>; + read-only; + }; + + partition@1e0000 { + label = "0:devcfg"; + reg = <0x1e0000 0x10000>; + read-only; + }; + + partition@1f0000 { + label = "0:apdp"; + reg = <0x1f0000 0x10000>; + read-only; + }; + + partition@200000 { + label = "0:rpm"; + reg = <0x200000 0x40000>; + read-only; + }; + + partition@240000 { + label = "0:cdt"; + reg = <0x240000 0x10000>; + read-only; + }; + + partition@250000 { + label = "0:appsblenv"; + reg = <0x250000 0x20000>; + }; + + partition@270000 { + label = "0:appsbl"; + reg = <0x250000 0x100000>; + read-only; + }; + + partition@370000 { + label = "0:art"; + reg = <0x370000 0x40000>; + read-only; + }; + + partition@3b0000 { + label = "0:ethphyfw1"; + reg = <0x3b0000 0x80000>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + aqr0_fw: firmware@0 { + reg = <0x0 0x5fc02>; + }; + }; + }; + + partition@430000 { + label = "0:ethphyfw2"; + reg = <0x430000 0x80000>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + aqr1_fw: firmware@0 { + reg = <0x0 0x5fc02>; + }; + }; + }; + + partition@4b0000 { + label = "reserved"; + reg = <0x4b0000 0x350000>; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + aqr113c_0: ethernet-phy@0 { + compatible ="ethernet-phy-ieee802.3-c45"; + reg = <0>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + firmware-name = "marvell/AQR-G4_v5.4.C-AQR_CIG_WF-1945_0x0_ID44778_VER1630.cld"; + nvmem-cell-names = "firmware"; + nvmem-cells = <&aqr0_fw>; + }; + + aqr113c_8: ethernet-phy@8 { + compatible ="ethernet-phy-ieee802.3-c45"; + reg = <8>; + reset-gpios = <&tlmm 59 GPIO_ACTIVE_LOW>; + firmware-name = "marvell/AQR-G4_v5.4.C-AQR_CIG_WF-1945_0x8_ID44776_VER1630.cld"; + nvmem-cell-names = "firmware"; + nvmem-cells = <&aqr1_fw>; + }; + + ethernet-phy-package@16 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <16>; + + qcom,package-mode = "qsgmii"; + + qca8075_16: ethernet-phy@16 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <16>; + }; + + qca8075_17: ethernet-phy@17 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <17>; + }; + + qca8075_18: ethernet-phy@18 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <18>; + }; + + qca8075_19: ethernet-phy@19 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <19>; + }; + }; +}; + +&sdhc_1 { + status = "okay"; + + /* According to the stock dts from the QNAP gpl drop + * the emmc has a problem with the hs400 > hs200 speed switch. + * Therefore remove the mmc-hs400-1_8v property + */ + /delete-property/ mmc-hs400-1_8v; + mmc-hs200-1_8v; + mmc-ddr-1_8v; + vqmmc-supply = <&l11>; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT6)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@0 { + port_id = <1>; + phy_address = <16>; + }; + port@1 { + port_id = <2>; + phy_address = <17>; + }; + port@2 { + port_id = <3>; + phy_address = <18>; + }; + port@3 { + port_id = <4>; + phy_address = <19>; + }; + port@4 { + port_id = <5>; + phy_address = <8>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + port@5 { + port_id = <6>; + phy_address = <0>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_16>; + label = "lan4"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_17>; + label = "lan3"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_18>; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_19>; + label = "lan1"; +}; + +&dp5 { + status = "okay"; + qcom,mactype = <1>; + phy-mode = "usxgmii"; + phy-handle = <&aqr113c_8>; + label = "10g-1"; +}; + +&dp6_syn { + status = "okay"; + phy-mode = "usxgmii"; + phy-handle = <&aqr113c_0>; + label = "10g-2"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "QNAP-301w"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-aw1000.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-aw1000.dts new file mode 100755 index 0000000..09adde5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-aw1000.dts @@ -0,0 +1,379 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2023, Chukun Pan */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Arcadyan AW1000"; + compatible = "arcadyan,aw1000", "qcom,ipq8074"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + serial0 = &blsp1_uart5; + /* + * Aliases as required by u-boot + * to patch MAC addresses + */ + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp6_syn; + label-mac-device = &dp1; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + gpio-export { + compatible = "gpio-export"; + + lte-pwrkey { + gpio-export,name = "lte_pwrkey"; + gpio-export,output = <1>; + gpios = <&tlmm 54 GPIO_ACTIVE_HIGH>; + }; + + lte-power { + gpio-export,name = "lte_power"; + gpio-export,output = <1>; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + }; + + lte-reset { + gpio-export,name = "lte_reset"; + gpio-export,output = <1>; + gpios = <&tlmm 63 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wlan { + label = "wlan"; + linux,code = ; + gpios = <&tlmm 2 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 62 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 67 GPIO_ACTIVE_LOW>; + }; + }; + + led-spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + + led_gpio: led-gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <2>; + spi-max-frequency = <1000000>; + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&led_gpio 0 GPIO_ACTIVE_HIGH>; + }; + + wifi { + label = "green:wifi"; + gpios = <&led_gpio 1 GPIO_ACTIVE_HIGH>; + }; + + internet { + label = "green:internet"; + gpios = <&led_gpio 2 GPIO_ACTIVE_HIGH>; + }; + + 5g-red { + label = "red:5g"; + gpios = <&led_gpio 3 GPIO_ACTIVE_LOW>; + }; + + 5g-green { + label = "green:5g"; + gpios = <&led_gpio 4 GPIO_ACTIVE_LOW>; + }; + + 5g-blue { + label = "blue:5g"; + gpios = <&led_gpio 5 GPIO_ACTIVE_LOW>; + }; + + signal-red { + label = "red:signal"; + gpios = <&led_gpio 6 GPIO_ACTIVE_LOW>; + }; + + signal-green { + label = "green:signal"; + gpios = <&led_gpio 8 GPIO_ACTIVE_LOW>; + }; + + signal-blue { + label = "blue:signal"; + gpios = <&led_gpio 9 GPIO_ACTIVE_LOW>; + }; + + phone { + label = "green:phone"; + gpios = <&led_gpio 11 GPIO_ACTIVE_HIGH>; + }; + }; + + usb_vbus: regulator-usb-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + regulator-boot-on; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <8>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; + + vdd-supply = <&usb_vbus>; +}; + +&ssphy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 64 GPIO_ACTIVE_LOW>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@2 { + reg = <2>; + active-low; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_0>; + label = "lan1"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_1>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_3>; + label = "lan4"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Arcadyan-AW1000"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-ax880.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-ax880.dts new file mode 100755 index 0000000..96aff3d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-ax880.dts @@ -0,0 +1,392 @@ +// SPDX-License-Identifier: MIT, GPL-2.0 or later +/* Copyright (c) 2023, Ruslan Isaev */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Yuncore AX880"; + compatible = "yuncore,ax880", "qcom,ipq8074", "qcom,ipq8074-hk09"; + + aliases { + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp5_syn; + ethernet1 = &dp6_syn; + label-mac-device = &dp5_syn; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + color = "red"; + gpios = <&tlmm 0 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + color = "green"; + linux,default-trigger = "phy0tpt"; + gpios = <&tlmm 2 GPIO_ACTIVE_HIGH>; + }; + + wlan5g { + color = "blue"; + linux,default-trigger = "phy1tpt"; + gpios = <&tlmm 9 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button_pins { + reset_button { + pins = "gpio57"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee_1"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm_1"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt_1"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + + nvmem-layout { + compatible = "u-boot,env"; + }; + }; + + partition@490000 { + label = "0:appsbl_1"; + reg = <0x490000 0xa0000>; + read-only; + }; + + partition@550000 { + label = "0:appsbl"; + reg = <0x530000 0xa0000>; + read-only; + }; + + partition@610000 { + label = "0:art"; + reg = <0x5d0000 0x40000>; + read-only; + }; + + partition@650000 { + label = "0:ethphyfw"; + reg = <0x610000 0x80000>; + read-only; + }; + + }; + }; +}; + +//serial interface +&blsp1_uart3 { + status = "okay"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs_1"; + reg = <0x0000000 0x3400000>; + }; + + partition@3400000 { + label = "0:wififw"; + reg = <0x3400000 0x800000>; + read-only; + }; + + rootfs: partition@3c00000 { + label = "rootfs"; + reg = <0x3c00000 0x3400000>; + }; + + partition@7000000 { + label = "0:wififw_1"; + reg = <0x7000000 0x800000>; + read-only; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + + qca8081_24: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + + qca8081_28: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5_syn { + status = "okay"; + phy-handle = <&qca8081_24>; + label = "wan"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "lan"; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "Yuncore-AX880"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-ax9000.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-ax9000.dts new file mode 100755 index 0000000..54c1388 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-ax9000.dts @@ -0,0 +1,578 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Robert Marko */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Xiaomi AX9000"; + compatible = "xiaomi,ax9000", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_system_yellow; + led-failsafe = &led_system_yellow; + led-running = &led_system_blue; + led-upgrade = &led_system_yellow; + label-mac-device = &dp5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; /* Labeled Mesh on the device */ + gpios = <&tlmm 46 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_blue: system-blue { + gpios = <&tlmm 48 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led_system_yellow: system-yellow { + gpios = <&tlmm 52 GPIO_ACTIVE_HIGH>; + color = ; + }; + + network-yellow { + gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; + color = ; + }; + + network-blue { + gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>; + color = ; + }; + + top-red { + gpios = <&tlmm 63 GPIO_ACTIVE_HIGH>; + color = ; + default-state = "keep"; + }; + + top-green { + gpios = <&tlmm 64 GPIO_ACTIVE_HIGH>; + color = ; + default-state = "keep"; + }; + + top-blue { + gpios = <&tlmm 66 GPIO_ACTIVE_HIGH>; + color = ; + default-state = "keep"; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + i2c_pins: i2c-pins { + pins = "gpio0", "gpio2"; + function = "blsp5_i2c"; + drive-strength = <8>; + bias-disable; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&blsp1_i2c6 { + status = "okay"; + + pinctrl-0 = <&i2c_pins>; + pinctrl-names = "default"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_dp1: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_dp2: macaddr@6 { + reg = <0x6 0x6>; + }; + + macaddr_dp3: macaddr@c { + reg = <0xc 0x6>; + }; + + macaddr_dp4: macaddr@12 { + reg = <0x12 0x6>; + }; + + macaddr_dp5: macaddr@18 { + reg = <0x18 0x6>; + }; + + caldata_qca9889: caldata@4d000 { + reg = <0x4d000 0x844>; + }; + }; + }; + + partition@1000000 { + label = "bdata"; + reg = <0x1000000 0x80000>; + }; + + partition@1080000 { + /* This is crash + crash_syslog parts combined */ + label = "pstore"; + reg = <0x1080000 0x100000>; + }; + + partition@1180000 { + label = "ubi_kernel"; + reg = <0x1180000 0x3800000>; + }; + + partition@4980000 { + label = "rootfs"; + reg = <0x4980000 0xb680000>; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + }; + + qca8081: ethernet-phy@24 { + compatible = "ethernet-phy-id004d.d101"; + reg = <24>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <24>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_0>; + label = "lan4"; + nvmem-cells = <&macaddr_dp1>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_1>; + label = "lan3"; + nvmem-cells = <&macaddr_dp2>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_2>; + label = "lan2"; + nvmem-cells = <&macaddr_dp3>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_3>; + label = "lan1"; + nvmem-cells = <&macaddr_dp4>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-mode = "sgmii"; + phy-handle = <&qca8081>; + label = "wan"; + nvmem-cells = <&macaddr_dp5>; + nvmem-cell-names = "mac-address"; +}; + +&pcie_qmp0 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 58 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* ath11k has no DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Xiaomi-AX9000"; + }; + }; +}; + +&pcie_qmp1 { + status = "okay"; +}; + +&pcie1 { + status = "okay"; + + perst-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + compatible = "qcom,ath10k"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath10k-calibration-variant = "Xiaomi-AX9000"; + nvmem-cell-names = "calibration"; + nvmem-cells = <&caldata_qca9889>; + }; + }; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Xiaomi-AX9000"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-dl-wrx36.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-dl-wrx36.dts new file mode 100755 index 0000000..d25bc90 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-dl-wrx36.dts @@ -0,0 +1,271 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2022, Robert Marko */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Dynalink DL-WRX36"; + compatible = "dynalink,dl-wrx36", "qcom,ipq8074"; + + aliases { + led-boot = &led_system_red; + led-failsafe = &led_system_red; + led-running = &led_system_blue; + led-upgrade = &led_system_red; + serial0 = &blsp1_uart5; + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp6_syn; + ethernet1 = &dp4; + ethernet2 = &dp3; + ethernet3 = &dp2; + ethernet4 = &dp1; + label-mac-device = &dp6_syn; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 63 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_blue: system-blue { + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led_system_red: system-red { + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <8>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + active-low; + }; + + led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_0>; + label = "lan4"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_1>; + label = "lan3"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_2>; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_3>; + label = "lan1"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081>; + label = "wan"; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "Dynalink-DL-WRX36"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-eap620hd-v1.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-eap620hd-v1.dts new file mode 100755 index 0000000..18a3759 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-eap620hd-v1.dts @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "TP-Link EAP620 HD v1"; + compatible = "tplink,eap620hd-v1", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_status_blue; + led-failsafe = &led_status_blue; + led-running = &led_status_blue; + led-upgrade = &led_status_blue; + }; + + chosen { + stdout-path = "serial0,115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 50 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_blue: status-blue { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ar8031: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; +}; + +&dp6 { + status = "okay"; + phy-handle = <&ar8031>; + label = "lan"; +}; + +&switch { + status = "okay"; + switch_lan_bmp = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@6 { + phy_address = <4>; + port_id = <6>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "TP-Link-EAP620-HD-v1"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-eap660hd-v1.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-eap660hd-v1.dts new file mode 100755 index 0000000..62d40d7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-eap660hd-v1.dts @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "TP-Link EAP660 HD v1"; + compatible = "tplink,eap660hd-v1", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_status_blue; + led-failsafe = &led_status_blue; + led-running = &led_status_blue; + led-upgrade = &led_status_blue; + }; + + chosen { + stdout-path = "serial0,115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 50 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_blue: status-blue { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + + qca8081_28: ethernet-phy@28 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <28>; + }; +}; + +&dp5 { + status = "okay"; + phy-mode = "sgmii"; + phy-handle = <&qca8081_28>; + label = "lan"; +}; + +&switch { + status = "okay"; + switch_lan_bmp = ; + switch_mac_mode1 = ; + + qcom,port_phyinfo { + port@5 { + phy_address = <28>; + port_id = <5>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "TP-Link-EAP660-HD-v1"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-haze.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-haze.dts new file mode 100755 index 0000000..0b390e9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-haze.dts @@ -0,0 +1,347 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "prpl Foundation Haze"; + compatible = "prpl,haze", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + /* Aliases are required by U-Boot to patch MAC addresses */ + ethernet0 = &dp6_syn; + ethernet1 = &dp4; + ethernet2 = &dp3; + ethernet3 = &dp2; + label-mac-device = &dp6_syn; + led-boot = &led_system_blue; + led-failsafe = &led_system_red; + led-running = &led_system_green; + led-upgrade = &led_system_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wps-button { + label = "wps"; + gpios = <&tlmm 42 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset-button { + label = "reset"; + gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-state { + mdc-pins { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button-state { + wps-pins { + pins = "gpio42"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + rst-pins { + pins = "gpio44"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + i2c_3_pins: i2c-3-state { + pins = "gpio46", "gpio47"; + function = "blsp2_i2c"; + drive-strength = <8>; + bias-disable; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_spi1 { /* BLSP1 QUP1 */ + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + aqr113c: ethernet-phy@5 { + compatible ="ethernet-phy-ieee802.3-c45"; + reg = <8>; + reset-gpios = <&tlmm 43 GPIO_ACTIVE_LOW>; + }; +}; + +&sdhc_1 { + status = "okay"; + + vqmmc-supply = <&l11>; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@6 { + port_id = <6>; + phy_address = <8>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + }; +}; + +&edma { + status = "okay"; +}; + +/* Dummy LAN port */ +&dp1 { + status = "disabled"; + phy-handle = <&qca8075_0>; + label = "lan4"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan3"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan1"; +}; + +&dp6_syn { + status = "okay"; + qcom,mactype = <1>; + phy-mode = "usxgmii"; + phy-handle = <&aqr113c>; + label = "wan"; +}; + +&pcie_qmp0 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 58 GPIO_ACTIVE_LOW>; +}; + +&pcie_qmp1 { + status = "okay"; +}; + +&pcie1 { + status = "okay"; + + perst-gpios = <&tlmm 61 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* ath11k has no DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "prpl-Haze"; + }; + }; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "prpl-Haze"; +}; + +&blsp1_i2c3{ + pinctrl-0 = <&i2c_3_pins>; + pinctrl-names = "default"; + status = "okay"; + + led-controller@30 { + compatible = "ti,lp5562"; + reg = <0x30>; + clock-mode = /bits/ 8 <2>; + #address-cells = <1>; + #size-cells = <0>; + + led_system_red: chan@0 { + chan-name = "red"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + color = ; + reg = <0>; + }; + + led_system_green: chan@1 { + chan-name = "green"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + color = ; + reg = <1>; + }; + + led_system_blue: chan@2 { + chan-name = "blue"; + led-cur = /bits/ 8 <0x20>; + max-cur = /bits/ 8 <0x60>; + color = ; + reg = <2>; + }; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-linkhub-hh500v.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-linkhub-hh500v.dts new file mode 100755 index 0000000..2a91807 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-linkhub-hh500v.dts @@ -0,0 +1,400 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "TCL LINKHUB HH500V"; + compatible = "tcl,linkhub-hh500v", "qcom,ipq8074"; + + aliases { + led-boot = &led_power_blue; + led-failsafe = &led_power_red; + led-running = &led_power_blue; + led-upgrade = &led_power_red; + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + modem { + compatible = "gpio-export"; + pinctrl-names = "default"; + pinctrl-0 = <&modem_pins>; + + /* output low = download mode */ + modem-edl { + gpio-export,name = "modem_edl"; + gpio-export,output = <1>; + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + }; + + /* output high = power on, output low = no power on after reset */ + modem-power { + gpio-export,name = "modem_power"; + gpio-export,output = <1>; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + }; + + /* output low 5s pulse = reset */ + modem-reset { + gpio-export,name = "modem_reset"; + gpio-export,output = <1>; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; + }; + }; + + gpio-poweroff { + compatible = "gpio-poweroff"; + gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 64 GPIO_ACTIVE_LOW>; + }; + + power { + label = "power"; + gpios = <&tlmm 62 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&led_pins>; + + 4g_green { + color = ; + function = "4g"; + gpios = <&aw9523 0 GPIO_ACTIVE_LOW>; + }; + + 4g_blue { + color = ; + function = "4g"; + gpios = <&aw9523 1 GPIO_ACTIVE_LOW>; + }; + + wifi_blue { + color = ; + function = LED_FUNCTION_WLAN; + gpios = <&aw9523 3 GPIO_ACTIVE_LOW>; + }; + + led_power_blue: power_blue { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&aw9523 5 GPIO_ACTIVE_LOW>; + }; + + led_power_red: power_red { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&aw9523 6 GPIO_ACTIVE_LOW>; + }; + + 5g_red { + color = ; + function = "5g"; + gpios = <&aw9523 8 GPIO_ACTIVE_LOW>; + }; + + 5g_green { + color = ; + function = "5g"; + gpios = <&aw9523 9 GPIO_ACTIVE_LOW>; + }; + + 5g_blue { + color = ; + function = "5g"; + gpios = <&aw9523 10 GPIO_ACTIVE_LOW>; + }; + + 4g_red { + color = ; + function = "4g"; + gpios = <&aw9523 11 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button-pins { + bias-pull-up; + drive-strength = <8>; + function = "gpio"; + pins = "gpio47", "gpio62", "gpio64"; + }; + + hsuart_pins: hsuart-state { + pins = "gpio48", "gpio49"; + }; + + modem_pins: modem-pins { + modem_power_on { + bias-pull-up; + drive-strength = <8>; + output-high; + pins = "gpio30"; + }; + + modem_reset { + drive-strength = <8>; + output-high; + pins = "gpio29"; + }; + + modem_edl { + output-high; + pins = "gpio46"; + }; + }; + + pcie0_default_state: pcie0_wake_gpio { + bias-pull-up; + drive-strength = <8>; + function = "pcie0_wake"; + pins = "gpio59"; + }; +}; + +&blsp1_i2c2 { + status = "okay"; + + aw9523: gpio-expander@5b { + compatible = "awinic,aw9523-pinctrl"; + reg = <0x5b>; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&aw9523 0 0 16>; + reset-gpios = <&tlmm 2 GPIO_ACTIVE_HIGH>; + + led_pins: led-pins { + pins = + "gpio0", "gpio1", "gpio3", "gpio5", "gpio6", + "gpio8", "gpio9", "gpio10", "gpio11"; + function = "gpio"; + input-disable; + output-low; + }; + }; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x00>; + /* "n25q128a11" required for u-boot patching, see nand node */ + compatible = "n25q128a11", "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + }; + }; +}; + +&blsp1_uart3 { + status = "okay"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + /* + * Some variants of this board use NOR+NAND configuration which is + * currently not supported by 'qcomsmem' MTD parser while other versions + * have NAND alone. Let U-Boot find the NAND and SPI flash dt nodes and + * populate partitions from SMEM partition table. + * + * This makes it possible to support both flash configurations with a + * single image, and also to use QCA 'runtime failsafe' and rotate + * 'rootfs'/'rootfs_1' partitions between subsequent updates. + */ + compatible = "qcom,ebi2-nandc-bam-v1.5.0", "qcom,ipq8074-nand"; + + nand@0 { + #address-cells = <0x01>; + #size-cells = <0x01>; + nand-bus-width = <8>; + nand-ecc-step-size = <512>; + nand-ecc-strength = <8>; + reg = <0>; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@16 { + compatible = "ethernet-phy-id004d.d101"; + reg = <16>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_wan_bmp = ; + switch_mac_mode = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@4 { + phy_address = <3>; + port_id = <4>; + }; + + port@6 { + phy_address = <16>; + port_id = <6>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081>; + label = "wan"; +}; + +&pcie_qmp0 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + pinctrl-0 = <&pcie0_default_state>; + pinctrl-names = "default"; + perst-gpio = <&tlmm 58 GPIO_ACTIVE_LOW>; + + pcie@0 { + modem@0,0 { + reg = <0x00 0x00 0x00 0x00 0x00>; + }; + }; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "TCL-LINKHUB-HH500V"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-mx5300.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-mx5300.dts new file mode 100755 index 0000000..5c8ab8b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-mx5300.dts @@ -0,0 +1,543 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Linksys MX5300"; + compatible = "linksys,mx5300", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + /* + * Aliases as required by u-boot + * to patch MAC addresses + */ + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + led-boot = &led_system_blue; + led-running = &led_system_blue; + led-failsafe = &led_system_red; + led-upgrade = &led_system_green; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0 rootfstype=squashfs ro"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset-button { + label = "reset"; + gpios = <&tlmm 67 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio54", "gpio67"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio_pins: mdio-state { + mdc-pins { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + /* + * QCA4024 is not currently supported, keep for documentation purposes + *spi_3_pins: spi-3-state { + * spi-pins { + * pins = "gpio50", "gpio52", "gpio53"; + * function = "blsp3_spi"; + * drive-strength = <8>; + * bias-disable; + * }; + * + * cs-pins { + * pins = "gpio22"; + * function = "blsp3_spi2"; + * drive-strength = <8>; + * bias-disable; + * }; + *}; + * + *quartz_pins: quartz-state { + * interrupt-pins { + * pins = "gpio48"; + * function = "gpio"; + * bias-disable; + * input; + * }; + * + * reset-pins { + * pins = "gpio21"; + * function = "gpio"; + * bias-disable; + * output-high; + * }; + *}; + */ +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + #address-cells = <1>; + #size-cells = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + caldata_qca9984: caldata@33000 { + reg = <0x33000 0x2f20>; + }; + }; + }; + + partition@1000000 { + label = "u_env"; + reg = <0x1000000 0x40000>; + }; + + partition@1040000 { + label = "s_env"; + reg = <0x1040000 0x20000>; + }; + + partition@1060000 { + label = "devinfo"; + reg = <0x1060000 0x20000>; + read-only; + }; + + partition@1080000 { + label = "kernel"; + reg = <0x1080000 0x9600000>; + }; + + partition@1680000 { + label = "rootfs"; + reg = <0x1680000 0x9000000>; + }; + + partition@a680000 { + label = "alt_kernel"; + reg = <0xa680000 0x9600000>; + }; + + partition@ac80000 { + label = "alt_rootfs"; + reg = <0xac80000 0x9000000>; + }; + + partition@13c80000 { + label = "sysdiag"; + reg = <0x13c80000 0x200000>; + read-only; + }; + + partition@13e80000 { + label = "0:ethphyfw"; + reg = <0x13e80000 0x80000>; + read-only; + }; + + partition@13f00000 { + label = "syscfg"; + reg = <0x13f00000 0xb800000>; + read-only; + }; + + partition@1f700000 { + label = "0:wififw"; + reg = <0x1f700000 0x900000>; + read-only; + }; + }; + }; +}; + +&blsp1_i2c2 { + status = "okay"; + + led-controller@62 { + compatible = "nxp,pca9633"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x62>; + nxp,hw-blink; + + led_system_red: led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_green: led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_blue: led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; + + rtc@68 { + compatible = "dallas,ds1307"; + reg = <0x68>; + }; +}; + +/* + * QCA4024 is not currently supported, keep for documentation purposes + *&blsp1_spi4 { + * status = "okay"; + * + * pinctrl-0 = <&spi_3_pins &quartz_pins>; + * pinctrl-names = "default"; + * + * iot@3 { + * compatible = "qca,qca4024"; + * reg = <0>; + * spi-max-frequency = <24000000>; + * }; + *}; + */ + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&pcie_qmp1 { + status = "okay"; +}; + +&pcie1 { + status = "okay"; + + perst-gpios = <&tlmm 58 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi0: wifi@0,0 { + status = "okay"; + + compatible = "qcom,ath10k"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath10k-calibration-variant = "Linksys-MX5300"; + nvmem-cell-names = "pre-calibration"; + nvmem-cells = <&caldata_qca9984>; + }; + }; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-MX5300"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-mx8500.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-mx8500.dts new file mode 100755 index 0000000..749aec9 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-mx8500.dts @@ -0,0 +1,536 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Linksys MX8500"; + compatible = "linksys,mx8500", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + led-boot = &led_system_blue; + led-running = &led_system_blue; + led-failsafe = &led_system_red; + led-upgrade = &led_system_green; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_0 rootfstype=squashfs ro"; + }; + + gpio_export { + compatible = "gpio-export"; + + bt_pwr { + gpio-export,name = "bt_pwr"; + gpio-export,output = <1>; + gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset-button { + label = "reset"; + gpios = <&tlmm 67 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 64 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio64", "gpio67"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio_pins: mdio-state { + mdc-pins { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + status = "okay"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + #address-cells = <1>; + #size-cells = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + }; + + partition@1000000 { + label = "u_env"; + reg = <0x1000000 0x40000>; + }; + + partition@1040000 { + label = "s_env"; + reg = <0x1040000 0x20000>; + }; + + partition@1060000 { + label = "devinfo"; + reg = <0x1060000 0x20000>; + read-only; + + nvmem-layout { + compatible = "ascii-eq-delim-env"; + + hw_mac_addr: hw_mac_addr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@1080000 { + label = "kernel"; + reg = <0x1080000 0x9600000>; + }; + + partition@1680000 { + label = "rootfs"; + reg = <0x1680000 0x9000000>; + }; + + partition@a680000 { + label = "alt_kernel"; + reg = <0xa680000 0x9600000>; + }; + + partition@ac80000 { + label = "alt_rootfs"; + reg = <0xac80000 0x9000000>; + }; + + partition@13c80000 { + label = "sysdiag"; + reg = <0x13c80000 0x200000>; + read-only; + }; + + partition@13e80000 { + label = "0:ethphyfw"; + reg = <0x13e80000 0x100000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + aqr_fw: firmware@0 { + /* Skip the QCOM MBN Header of 40 bytes */ + reg = <0x28 0x60002>; + }; + }; + }; + + partition@13f80000 { + label = "syscfg"; + reg = <0x13f80000 0xb180000>; + read-only; + }; + + partition@1f100000 { + label = "app_data"; + reg = <0x1f100000 0x500000>; + read-only; + }; + + partition@1f600000 { + label = "0:wififw"; + reg = <0x1f600000 0xa00000>; + read-only; + }; + }; + }; +}; + +&blsp1_i2c2 { + status = "okay"; + + led-controller@62 { + compatible = "nxp,pca9633"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x62>; + nxp,hw-blink; + + led_system_red: led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_green: led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_blue: led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + aqr114c: ethernet-phy@8 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <8>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + firmware-name = "marvell/AQR-G4_v5.6.5-AQR_WNC_SAQA-L2_GT_ID45287_VER24005.cld"; + nvmem-cells = <&aqr_fw>; + nvmem-cell-names = "firmware"; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@3 { + port_id = <3>; + phy_address = <2>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@6 { + port_id = <6>; + phy_address = <8>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_0>; + label = "lan1"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_1>; + label = "lan2"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_2>; + label = "lan3"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_3>; + label = "lan4"; + nvmem-cells = <&hw_mac_addr 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp6_syn { + status = "okay"; + phy-mode = "usxgmii"; + phy-handle = <&aqr114c>; + label = "wan"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&pcie_qmp0 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 61 GPIO_ACTIVE_LOW>; + + pcie@0 { + wifi@0,0 { + status = "okay"; + + /* ath11k has no DT compatible for PCI cards */ + compatible = "pci17cb,1104"; + reg = <0x00010000 0 0 0 0>; + + qcom,ath11k-calibration-variant = "Linksys-MX8500"; + }; + }; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-MX8500"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-sax1v1k.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-sax1v1k.dts new file mode 100755 index 0000000..91804b8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-sax1v1k.dts @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Spectrum SAX1V1K"; + compatible = "spectrum,sax1v1k", "qcom,ipq8074"; + + aliases { + led-boot = &led_system_red; + led-failsafe = &led_system_red; + led-running = &led_system_blue; + led-upgrade = &led_system_red; + serial0 = &blsp1_uart5; + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp6_syn; + ethernet1 = &dp4; + ethernet2 = &dp3; + ethernet3 = &dp2; + label-mac-device = &dp6_syn; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 63 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_blue: system-blue { + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_red: system-red { + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&mdio { + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + status = "okay"; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + reset-deassert-us = <10000>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + active-low; + }; + + led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + active-low; + }; + }; + }; +}; + +&sdhc_1 { + /* Following same rule as QNAP 301W + * the emmc has a problem with the hs400 > hs200 speed switch. + * Therefore remove the mmc-hs400-1_8v property + */ + /delete-property/ mmc-hs400-1_8v; + mmc-hs200-1_8v; + mmc-ddr-1_8v; + vqmmc-supply = <&l11>; + status = "okay"; +}; + +&switch { + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + status = "okay"; + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@3 { + port_id = <3>; + phy_address = <2>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp2 { + phy-mode = "qsgmii"; + phy-handle = <&qca8075_1>; + label = "lan3"; + status = "okay"; +}; + +&dp3 { + phy-mode = "qsgmii"; + phy-handle = <&qca8075_2>; + label = "lan2"; + status = "okay"; +}; + +&dp4 { + phy-mode = "qsgmii"; + phy-handle = <&qca8075_3>; + label = "lan1"; + status = "okay"; +}; + +&dp6_syn { + phy-handle = <&qca8081>; + label = "wan"; + status = "okay"; +}; + +&wifi { + qcom,ath11k-calibration-variant = "Spectrum-SAX1V1K"; + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wax218.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wax218.dts new file mode 100755 index 0000000..8ced631 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wax218.dts @@ -0,0 +1,193 @@ +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" + +#include +#include +#include + +/ { + model = "Netgear WAX218"; + compatible = "netgear,wax218", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_power_amber; + led-failsafe = &led_power_amber; + led-running = &led_power_amber; + led-upgrade = &led_power_amber; + }; + + chosen { + stdout-path = "serial0:115200n8"; + /* + * Netgear's U-Boot adds "ubi.mtd=rootfs root=mtd:ubi_rootfs" + * That fails to create a UBI block device, so add it here. + */ + bootargs-append = " ubi.block=0,rootfs root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 52 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + + led_gpio: led_gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <1>; + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + spi-max-frequency = <1000000>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power_amber: led_power { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&led_gpio 1 GPIO_ACTIVE_HIGH>; + }; + + led_lan { + function = LED_FUNCTION_LAN; + color = ; + gpios = <&led_gpio 2 GPIO_ACTIVE_HIGH>; + }; + + led_wlan_2g { + label = "blue:wlan2g"; + gpios = <&led_gpio 3 GPIO_ACTIVE_HIGH>; + }; + + led_wlan_5g { + label = "blue:wlan5g"; + gpios = <&led_gpio 4 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_mac_mode = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + + qca8081_28: ethernet-phy@28 { + reg = <28>; + }; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "lan"; + nvmem-cells = <&macaddr_ubootenv_ethaddr>; + nvmem-cell-names = "mac-address"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-appsblenv { + compatible = "fixed-partitions"; + label = "0:appsblenv"; + read-only; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "env-data"; + reg = <0x0 0x40000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_ubootenv_ethaddr: ethaddr { + }; + }; + }; + }; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Netgear-WAX218"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wax620.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wax620.dts new file mode 100755 index 0000000..f410f79 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wax620.dts @@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include + +/ { + model = "Netgear WAX620"; + compatible = "netgear,wax620", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + ethernet0 = &dp6; + label-mac-device = &dp6; + + led-boot = &led_system_blue; + led-failsafe = &led_system_red; + led-running = &led_system_green; + led-upgrade = &led_system_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + /* + * Netgear's U-Boot adds "ubi.mtd=rootfs root=mtd:ubi_rootfs" + * That fails to create a UBI block device, so add it here. + */ + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 52 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + + led_gpio: led_gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <1>; + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + spi-max-frequency = <1000000>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_red: system-red { + label = "system:red"; + gpios = <&tlmm 54 GPIO_ACTIVE_HIGH>; + }; + + led_system_green: system-green { + label = "system:green"; + gpios = <&tlmm 55 GPIO_ACTIVE_HIGH>; + }; + + led_system_blue: system-blue { + label = "system:blue"; + gpios = <&tlmm 56 GPIO_ACTIVE_HIGH>; + }; + + led_lan_g { + label = "lan:green"; + gpios = <&led_gpio 0 GPIO_ACTIVE_HIGH>; + }; + + led_lan_o { + label = "lan:orange"; + gpios = <&led_gpio 1 GPIO_ACTIVE_HIGH>; + }; + + led_2g_b { + label = "wlan2g:blue"; + gpios = <&led_gpio 2 GPIO_ACTIVE_HIGH>; + }; + + led_2g_g { + label = "wlan2g:green"; + gpios = <&led_gpio 3 GPIO_ACTIVE_HIGH>; + }; + + led_5g_b { + label = "wlan5g:blue"; + gpios = <&led_gpio 4 GPIO_ACTIVE_HIGH>; + }; + + led_5g_g { + label = "wlan5g:green"; + gpios = <&led_gpio 5 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = ; + switch_mac_mode = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + + qca8081_28: ethernet-phy@28 { + reg = <28>; + }; +}; + +&dp6 { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "lan"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Netgear-WAX620"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wpq873.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wpq873.dts new file mode 100755 index 0000000..d678bea --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-wpq873.dts @@ -0,0 +1,468 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright 2023 Nokia */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Compex WPQ873"; + compatible = "compex,wpq873", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_power_blue; + led-failsafe = &led_power_red; + led-running = &led_system_green; + led-upgrade = &led_system_blue; + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet0 = &dp6; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + label-mac-device = &dp6; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 21 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power_red: power-red { + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led_power_blue: power-blue { + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led_system_red: system-red { + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led_system_green: system-green { + gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led_system_blue: system-blue { + gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + i2c_pins: i2c-pins { + pins = "gpio0", "gpio2"; + function = "blsp5_i2c"; + drive-strength = <8>; + bias-disable; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&blsp1_i2c6 { + status = "okay"; + + pinctrl-0 = <&i2c_pins>; + pinctrl-names = "default"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_spi1 { + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + button_pins: button_pins { + reset_button { + pins = "gpio66"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_spi1 { + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + }; + + partition@490000 { + label = "0:appsbl"; + reg = <0x490000 0xa0000>; + read-only; + }; + + partition@550000 { + label = "0:appsbl_1"; + reg = <0x530000 0xa0000>; + read-only; + }; + + partition@610000 { + label = "0:art"; + reg = <0x5d0000 0x40000>; + read-only; + }; + + partition@650000 { + label = "0:ethphyfw"; + reg = <0x610000 0x80000>; + read-only; + }; + }; + }; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <8>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs"; + reg = <0x0000000 0x3400000>; + }; + + partition@3400000 { + label = "0:wififw"; + reg = <0x3400000 0x800000>; + read-only; + }; + + partition@3c00000 { + label = "rootfs_1"; + reg = <0x3c00000 0x3400000>; + }; + + partition@7000000 { + label = "0:wififw_1"; + reg = <0x7000000 0x800000>; + read-only; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <28>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan1"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan3"; +}; + +&dp6 { + status = "okay"; + phy-handle = <&qca8081>; + label = "wan"; +}; + +&pcie_qmp0 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + perst-gpios = <&tlmm 58 GPIO_ACTIVE_LOW>; +}; + +&pcie_qmp1 { + status = "okay"; +}; + +&pcie1 { + status = "okay"; + + perst-gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Compex-WPQ873"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-zbt-z800ax.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-zbt-z800ax.dts new file mode 100755 index 0000000..2e29da5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8072-zbt-z800ax.dts @@ -0,0 +1,450 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Zbtlink ZBT-Z800AX"; + compatible = "zbtlink,zbt-z800ax", "qcom,ipq8074"; + + aliases { + led-boot = &led_net; + led-failsafe = &led_net; + led-upgrade = &led_net; + serial0 = &blsp1_uart5; + /* + * Aliases as required by u-boot + * to patch MAC addresses + */ + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + label-mac-device = &dp1; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + gpio-export { + compatible = "gpio-export"; + + lte-power { + gpio-export,name = "lte_power"; + gpio-export,output = <1>; + gpios = <&tlmm 55 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&tlmm 46 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_net: net { + color = ; + function = LED_FUNCTION_WAN_ONLINE; + gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>; + }; + + module { + color = ; + function = LED_FUNCTION_MOBILE; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + }; + + wlan2g { + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1radio"; + }; + + wlan5g { + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0radio"; + }; + }; +}; + +&tlmm { + button_pins: button-pins { + mux { + pins = "gpio34", "gpio46"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + cs-select = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + }; + + partition@490000 { + label = "0:appsbl"; + reg = <0x490000 0xa0000>; + read-only; + }; + + partition@530000 { + label = "0:appsbl_1"; + reg = <0x530000 0xa0000>; + read-only; + }; + + partition@5d0000 { + label = "0:art"; + reg = <0x5d0000 0x40000>; + read-only; + }; + + partition@610000 { + label = "0:ethphyfw"; + reg = <0x610000 0x80000>; + read-only; + }; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <8>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "rootfs"; + reg = <0x0000000 0x3400000>; + }; + + partition@3400000 { + label = "0:wififw"; + reg = <0x3400000 0x0800000>; + read-only; + }; + + partition@3c00000 { + label = "rootfs_1"; + reg = <0x3c00000 0x3400000>; + }; + + partition@7000000 { + label = "0:wififw_1"; + reg = <0x7000000 0x0800000>; + read-only; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + compatible = "qcom,qca8075-package"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "ZBT-Z800AX"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-deco-x80-5g.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-deco-x80-5g.dts new file mode 100755 index 0000000..09f8be6 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-deco-x80-5g.dts @@ -0,0 +1,458 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2022, Robert Marko +altered by Jonathan Brophy +to suit the TP-Link Deco X80-5G target */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "TP-Link Deco X80-5G"; + compatible = "tplink,deco-x80-5g", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + modem { + compatible = "gpio-export"; + pinctrl-names = "default"; + pinctrl-0 = <&modem_pins>; + pinctrl-1 = <&antenna_pins>; + + w_disable { + gpio-export,name = "w_disable"; + gpio-export,output = <1>; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; /* wwan disable output */ + }; + + modem-reset { + gpio-export,name = "modem_reset"; + gpio-export,output = <0>; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; /* reset modem output */ + }; + + ext_antenna_en { + gpio-export,name = "ext_antenna_en"; + gpio-export,output = <0>; + gpios = <&tlmm 56 GPIO_ACTIVE_HIGH>; /* select external sma antennas for wwan output */ + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset_button { + label = "reset"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; /*reset button output*/ + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + /*note the LED's defined here are not individual they are a single combined RGB element used for status functions. + To mimic the OEM default behaviour green and red are switched on from boot to indicate yellow (power on).*/ + + led_system_green: green { + gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + default-state = "on"; + }; + + led_system_red: red { + gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + default-state = "on"; + }; + + led_system_blue: blue { + gpios = <&tlmm 52 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; + + gpio_fan: gpio-fan { + compatible = "gpio-fan"; + pinctrl-0 = <&fan_pins>; + pinctrl-names = "default"; + gpios = <&tlmm 42 GPIO_ACTIVE_LOW>, /* fan gpio MSB */ + <&tlmm 41 GPIO_ACTIVE_LOW>, + <&tlmm 40 GPIO_ACTIVE_LOW>; /* fan gpio LSB */ + + /* stock fan is a Sunnon EF40201BX-Q18C-F99 + 6800 rpm + gpio68 seemed to be the feedback rpm of the fan. + no support for fan speed in kernel saved for future use.*/ + + /*rpm-gpios = <&tlmm 68 GPIO_ACTIVE_HIGH>; */ + gpio-fan,speed-map = <0 0>, /* speed 0 binary drive bits 0,0,0 (idle state) */ + <971 1>, /* speed 1 binary drive bits 0,0,1 β–Ό */ + <1942 2>, /* speed 3 binary drive bits 0,1,0 (active state) */ + <2913 3>, /* speed 4 binary drive bits 0,1,1 β–Ό */ + <3884 4>, /* speed 5 binary drive bits 1,0,0 β–Ό */ + <4855 5>, /* speed 6 binary drive bits 1,0,1 (high state) */ + <5826 6>, /* speed 7 binary drive bits 1,1,0 β–Ό */ + <6800 7>; /* speed 8 binary drive bits 1,1,1 β–Ό */ + #cooling-cells = <2>; /* min followed by max */ + }; +}; + +&cpu0_thermal { + trips { + cpu0_high: cpu-high { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + cpu0_active: cpu-active { + temperature = <50000>; + hysteresis = <2000>; + type = "active"; + }; + cpu0_idle: cpu-idle { + temperature = <25000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu0_high>; + cooling-device = <&gpio_fan 5 THERMAL_NO_LIMIT>; + }; + map3 { + trip = <&cpu0_active>; + cooling-device = <&gpio_fan 2 4>; + }; + map4 { + trip = <&cpu0_idle>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>; + }; + }; +}; + +&cpu1_thermal { + trips { + cpu1_high: cpu-high { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + cpu1_active: cpu-active { + temperature = <50000>; + hysteresis = <2000>; + type = "active"; + }; + cpu1_idle: cpu-idle { + temperature = <25000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu1_high>; + cooling-device = <&gpio_fan 5 THERMAL_NO_LIMIT>; + }; + map3 { + trip = <&cpu1_active>; + cooling-device = <&gpio_fan 2 4>; + }; + map4 { + trip = <&cpu1_idle>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>; + }; + }; +}; + +&cpu2_thermal { + trips { + cpu2_high: cpu-high { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + cpu2_active: cpu-active { + temperature = <50000>; + hysteresis = <2000>; + type = "active"; + }; + cpu2_idle: cpu-idle { + temperature = <25000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu2_high>; + cooling-device = <&gpio_fan 5 THERMAL_NO_LIMIT>; + }; + map3 { + trip = <&cpu2_active>; + cooling-device = <&gpio_fan 2 4>; + }; + map4 { + trip = <&cpu2_idle>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>; + }; + }; +}; + +&cpu3_thermal { + trips { + cpu3_high: cpu-high { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + cpu3_active: cpu-active { + temperature = <50000>; + hysteresis = <2000>; + type = "active"; + }; + cpu3_idle: cpu-idle { + temperature = <25000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu3_high>; + cooling-device = <&gpio_fan 5 THERMAL_NO_LIMIT>; + }; + map3 { + trip = <&cpu3_active>; + cooling-device = <&gpio_fan 2 4>; + }; + map4 { + trip = <&cpu3_idle>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>; + }; + }; +}; + + +&cluster_thermal { + trips { + cluster_high: cluster-high { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + cluster_active: cluster-active { + temperature = <50000>; + hysteresis = <2000>; + type = "active"; + }; + cluster_idle: cluster-idle { + temperature = <25000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cluster_high>; + cooling-device = <&gpio_fan 5 THERMAL_NO_LIMIT>; + }; + map3 { + trip = <&cluster_active>; + cooling-device = <&gpio_fan 2 4>; + }; + map4 { + trip = <&cluster_idle>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT 1>; + }; + }; +}; + + +&tlmm { + button_pins: button-state { + pins = "gpio27"; + function = "gpio"; + drive-strength = <2>; + bias-pull-up; + }; + + fan_pins: fan-state { + pins = "gpio40", "gpio41", "gpio42"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + antenna_pins: antenna-state { + pins = "gpio56"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + modem_pins: modem-state { + pins = "gpio29", "gpio55"; + function = "gpio"; + drive-strength = <2>; + bias-disable; + }; + + led_pins: led-state { + pins = "gpio50", "gpio51", "gpio52"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + }; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; /* define SMEM partition table */ + + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + qca8033: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; /* lan phy */ + reg = <4>; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; /* wan phy */ + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>; + }; +}; + + +&switch { + status = "okay"; + + switch_wan_bmp = ; /* wan port bitmap */ + switch_lan_bmp = ; /* lan port bitmap */ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@5 { + port_id = <5>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + port@6 { + port_id = <6>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8081>; + label = "wan"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8033>; + label = "lan"; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "tplink_deco-x80-5g"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-nbg7815.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-nbg7815.dts new file mode 100755 index 0000000..35dd019 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-nbg7815.dts @@ -0,0 +1,449 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2022, Karol Przybylski + * Copyright (c) 2023, Andre Valentin + */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Zyxel NBG7815"; + compatible = "zyxel,nbg7815", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + /* Alias as required by u-boot to patch MAC addresses */ + ethernet0 = &dp1; + label-mac-device = &dp1; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + status = "okay"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + reg = <0>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + read-only; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsbl"; + reg = <0x480000 0xc0000>; + read-only; + }; + + partition@540000 { + label = "0:appsbl_1"; + reg = <0x540000 0xc0000>; + read-only; + }; + + partition@600000 { + label = "0:appsblenv"; + reg = <0x600000 0x10000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_lan: ethaddr { + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@610000 { + label = "0:art"; + reg = <0x610000 0x40000>; + read-only; + }; + + partition@650000 { + label = "0:ethphyfw"; + reg = <0x650000 0x80000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + aqr_fw: aqr-fw@0 { + /* Skip the QCOM MBN Header of 40 bytes */ + reg = <0x28 0x5f402>; + }; + }; + }; + + partition@6d0000 { + label = "0:crt"; + reg = <0x6d0000 0x10000>; + read-only; + }; + + partition@6e0000 { + label = "dual_flag"; + reg = <0x6e0000 0x10000>; + }; + + partition@6f0000 { + label = "reserved"; + reg = <0x6f0000 0x110000>; + read-only; + }; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 31 GPIO_ACTIVE_LOW>; + }; + + aqr113c: ethernet-phy@5 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <8>; + reset-gpios = <&tlmm 63 GPIO_ACTIVE_LOW>; + + nvmem-cells = <&aqr_fw>; + nvmem-cell-names = "firmware"; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT6)>; + switch_wan_bmp = ; + switch_mac_mode = ; + switch_mac_mode1 = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@3 { + port_id = <3>; + phy_address = <2>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + + port@6 { + port_id = <6>; + ethernet-phy-ieee802.3-c45; + phy_address = <8>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan1"; + nvmem-cells = <&macaddr_lan 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; + nvmem-cells = <&macaddr_lan 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; + nvmem-cells = <&macaddr_lan 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; + nvmem-cells = <&macaddr_lan 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-mode = "sgmii"; + phy-handle = <&qca8081>; + label = "wan"; + nvmem-cells = <&macaddr_lan 1>; + nvmem-cell-names = "mac-address"; +}; + +&dp6_syn { + status = "okay"; + phy-mode = "usxgmii"; + phy-handle = <&aqr113c>; + label = "10g"; + nvmem-cells = <&macaddr_lan 0>; + nvmem-cell-names = "mac-address"; +}; + +&blsp1_i2c2 { + pinctrl-0 = <&i2c_0_pins>; + pinctrl-names = "default"; + status = "okay"; + + tmp103@70 { + compatible = "ti,tmp103"; + reg = <0x70>; + }; +}; + +&sdhc_1 { + status = "okay"; + /* unstable, problem with the hs400 > h200 speed switch */ + /delete-property/ mmc-hs400-1_8v; + mmc-hs200-1_8v; + mmc-ddr-1_8v; + vqmmc-supply = <&l11>; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Zyxel-NBG7815"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rax120v2.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rax120v2.dts new file mode 100755 index 0000000..36e315c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rax120v2.dts @@ -0,0 +1,537 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-ess.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include +#include +#include + +/ { + model = "Netgear RAX120v2"; + compatible = "netgear,rax120v2", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + + led-running = &led_system_white; + led-upgrade = &led_system_white; + led-internet = &led_wan_white; + label-mac-device = &dp5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.mtd=rootfs root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + + rfkill { + label = "rfkill"; + gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + led_spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + + led_gpio: led_gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <2>; + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + spi-max-frequency = <1000000>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_white: system-white { + gpios = <&led_gpio 0 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_24g_white { + gpios = <&led_gpio 1 GPIO_ACTIVE_LOW>; + color = ; + linux,default-trigger = "phy1radio"; + }; + + led_5g_white { + gpios = <&led_gpio 2 GPIO_ACTIVE_LOW>; + color = ; + linux,default-trigger = "phy0radio"; + }; + + led_usb1_white { + gpios = <&led_gpio 3 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_usb2_white { + gpios = <&led_gpio 4 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_wan_white: wan-white { + gpios = <&led_gpio 5 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_aqr_green { + gpios = <&led_gpio 6 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_aqr_red { + gpios = <&led_gpio 10 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_aqr_white { + gpios = <&led_gpio 11 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_wps_white { + gpios = <&tlmm 40 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + compatible = "qcom,qca8075-package"; + + qca8075_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; + + aqr111b0: ethernet-phy@7 { + compatible ="ethernet-phy-ieee802.3-c45"; + reg = <7>; + reset-gpios = <&tlmm 59 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT6)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + port@6 { + port_id = <6>; + phy_address = <7>; + compatible = "ethernet-phy-ieee802.3-c45"; + ethernet-phy-ieee802.3-c45; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-handle = <&qca8075_0>; + label = "lan4"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan3"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan2"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan1"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "wan"; + nvmem-cells = <&macaddr_wan>; + nvmem-cell-names = "mac-address"; +}; + +&dp6_syn { + status = "okay"; + phy-mode = "usxgmii"; + phy-handle = <&aqr111b0>; + label = "lan5"; + nvmem-cells = <&macaddr_lan>; + nvmem-cell-names = "mac-address"; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&blsp1_i2c2 { + status = "okay"; + + g761@3e { + compatible = "gmt,g761"; + reg = <0x3e>; + fan_gear_mode = <0>; + fan_start = <1>; + pwm_polarity = <0>; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x00 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig_1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + }; + + partition@1000000 { + label = "0:art.bak"; + reg = <0x1000000 0x0080000>; + read-only; + }; + + partition@1080000 { + label = "config"; + reg = <0x1080000 0x0100000>; + read-only; + }; + + partition@1180000 { + label = "boarddata1"; + reg = <0x1180000 0x0100000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_lan: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_wan: macaddr@1 { + reg = <0x6 0x6>; + }; + + macaddr_wlan5g: macaddr@2 { + reg = <0xc 0x6>; + }; + }; + }; + + partition@1280000 { + label = "boarddata2"; + reg = <0x1280000 0x0100000>; + read-only; + }; + + partition@1380000 { + label = "pot"; + reg = <0x1380000 0x0100000>; + read-only; + }; + + partition@1480000 { + label = "dnidata"; + reg = <0x1480000 0x0500000>; + read-only; + }; + + partition@1980000 { + label = "kernel"; + reg = <0x1980000 0x1d00000>; + }; + + partition@7e00000 { + label = "ethphyfw"; + reg = <0x7e00000 0x80000>; + }; + + partition@e8800000 { + label = "rootfs"; + reg = <0xe880000 0x11780000>; + }; + }; + }; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&ssphy_1 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&wifi{ + status = "okay"; + + qcom,ath11k-calibration-variant = "Netgear-RAX120v2"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&prng { + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbr750.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbr750.dts new file mode 100755 index 0000000..2bfa897 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbr750.dts @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2026 Michael Lotz + */ + +/dts-v1/; + +#include "ipq8074-rbx750.dtsi" + +/ { + model = "Netgear RBR750"; + compatible = "netgear,rbr750", "qcom,ipq8074"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbs750.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbs750.dts new file mode 100755 index 0000000..9982abd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbs750.dts @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2026 Michael Lotz + */ + +/dts-v1/; + +#include "ipq8074-rbx750.dtsi" + +/ { + model = "Netgear RBS750"; + compatible = "netgear,rbs750", "qcom,ipq8074"; +}; + +&dp1 { + status = "disabled"; +}; + +&dp2 { + status = "disabled"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbx750.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbx750.dtsi new file mode 100755 index 0000000..55474c8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rbx750.dtsi @@ -0,0 +1,292 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2026 Michael Lotz + */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + aliases { + led-boot = &lp5562_white; + led-failsafe = &lp5562_red; + led-upgrade = &lp5562_blue; + serial0 = &blsp1_uart5; + label-mac-device = &dp5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.mtd=rootfs root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 34 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + power_green { + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + color = ; + function = LED_FUNCTION_POWER; + linux,default-trigger = "default-on"; + }; + + power_red { + gpios = <&tlmm 56 GPIO_ACTIVE_LOW>; + color = ; + function = LED_FUNCTION_POWER; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&edma { + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT4 | ESS_PORT5)>; + switch_wan_bmp = ; + switch_mac_mode = ; + + qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <0>; + }; + + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + phy0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; + + phy1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + phy3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + phy4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&dp1 { + status = "okay"; + phy-handle = <&phy0>; + label = "wan"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_boarddata 1>; +}; + +&dp2 { + status = "okay"; + phy-handle = <&phy1>; + label = "lan3"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_boarddata 2>; +}; + +&dp4 { + status = "okay"; + phy-handle = <&phy3>; + label = "lan2"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_boarddata 1>; +}; + +&dp5 { + status = "okay"; + phy-handle = <&phy4>; + label = "lan1"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_boarddata 0>; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-board_data { + label = "board_data"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_boarddata: macaddr@40 { + compatible = "mac-base"; + reg = <0x40 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition-0-appsblenv { + label = "0:appsblenv"; + + nvmem-layout { + compatible = "u-boot,env"; + env-size = <0x40000>; + }; + }; + }; + }; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "Netgear-RBK750"; +}; + +&blsp1_i2c2 { + status = "okay"; + + lp5562@31 { + compatible = "ti,lp5562"; + reg = <0x31>; + clock-mode = [02]; + #address-cells = <1>; + #size-cells = <0>; + + lp5562_red: led@0 { + chan-name = "lp5562_red"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <0>; + }; + + lp5562_green: led@1 { + chan-name = "lp5562_green"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <1>; + }; + + lp5562_blue: led@2 { + chan-name = "lp5562_blue"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <2>; + }; + + lp5562_white: led@3 { + chan-name = "lp5562_white"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <3>; + }; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rt-ax89x.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rt-ax89x.dts new file mode 100755 index 0000000..1fdf394 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-rt-ax89x.dts @@ -0,0 +1,738 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2024, Robert Marko */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Asus RT-AX89X"; + compatible = "asus,rt-ax89x", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + mdio-gpio0 = &mdio1; + ethernet0 = &dp1; + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5_syn; + ethernet5 = &dp6_syn; + led-boot = &led_pwr; + led-failsafe = &led_pwr; + led-running = &led_pwr; + led-upgrade = &led_pwr; + }; + + chosen { + stdout-path = "serial0:115200n8"; + /* We have to override root and ubi device passed by bootloader */ + bootargs-append = " ubi.block=0,jffs2 root=/dev/ubiblock0_4"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + wifi-button { + label = "wifi"; + gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset-button { + label = "reset"; + gpios = <&tlmm 61 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + led-button { + label = "led"; + gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led_pwr: led-pwr { + function = LED_FUNCTION_POWER; + gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led-2g { + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + color = ; + linux,default-trigger = "phy0radio"; + }; + + led-5g { + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + color = ; + linux,default-trigger = "phy1radio"; + }; + + led-10g-copper { + function = "aqr10g"; + gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led-lan { + function = LED_FUNCTION_LAN; + gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led-sfp { + function = "sfp"; + gpios = <&tlmm 36 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led-wan-red { + function = LED_FUNCTION_WAN; + gpios = <&tlmm 44 GPIO_ACTIVE_HIGH>; + color = ; + }; + + led-wan-white { + function = LED_FUNCTION_WAN; + gpios = <&tlmm 47 GPIO_ACTIVE_HIGH>; + color = ; + }; + }; + + gpio_fan: gpio-fan { + compatible = "gpio-fan"; + pinctrl-0 = <&fan_pins>; + pinctrl-names = "default"; + gpios = <&tlmm 64 GPIO_ACTIVE_HIGH + &tlmm 66 GPIO_ACTIVE_HIGH>; + /* + * Not supported upstream, but good to document for + * future uses. + * It seems that Delta AFB0712VHB fan has its tacho + * output connected to GPIO 65. + */ + //rpm-gpios = <&tlmm 65 GPIO_ACTIVE_HIGH>; + gpio-fan,speed-map = < 0 0 + 1600 1 + 1850 2 + 2100 3 >; + #cooling-cells = <2>; + }; + + usb0_vbus: regulator-usb0-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb0_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-boot-on; + }; + + usb1_vbus: regulator-usb1-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb1_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-boot-on; + }; +}; + +&cpu0_thermal { + trips { + cpu0_active: cpu-active { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu0_active>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&cpu1_thermal { + trips { + cpu1_active: cpu-active { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu1_active>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&cpu2_thermal { + trips { + cpu2_active: cpu-active { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu2_active>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&cpu3_thermal { + trips { + cpu3_active: cpu-active { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cpu3_active>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&cluster_thermal { + trips { + cluster_active: cluster-active { + temperature = <70000>; + hysteresis = <2000>; + type = "active"; + }; + }; + + cooling-maps { + map2 { + trip = <&cluster_active>; + cooling-device = <&gpio_fan THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio25", "gpio26", "gpio34", "gpio61"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + i2c_pins: i2c-pins { + pins = "gpio42", "gpio43"; + function = "blsp1_i2c"; + drive-strength = <8>; + bias-disable; + }; + + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <16>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <16>; + bias-pull-up; + }; + }; + + mdio_gpio_pins: mdio-gpio-pins { + pins = "gpio54", "gpio56"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + uniphy_pins: uniphy_pinmux { + mux { + pins = "gpio60"; + function = "rx2"; + bias-disable; + }; + + sfp_tx_disable { + pins = "gpio48"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + output-low; + }; + + sfp_tx_fault { + pins = "gpio62"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + output-high; + }; + + sfp_mod_def0 { + pins = "gpio46"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + led_pins: led-state { + power { + pins = "gpio21"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + default_off { + pins = "gpio18", "gpio19", "gpio20", "gpio47", + "gpio44", "gpio35", "gpio36"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + fan_pins: fan-state { + pins = "gpio64", "gpio66"; + function = "gpio"; + drive-strength = <8>; + bias-disable; + output-high; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; + + vdd-supply = <&usb0_vbus>; +}; + +&ssphy_1 { + status = "okay"; +}; + +&qusb_phy_1 { + status = "okay"; + + vdd-supply = <&usb1_vbus>; +}; + +&usb_0 { + status = "okay"; +}; + +&usb_1 { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x60000>; + read-only; + }; + + partition@60000 { + label = "0:mibib"; + reg = <0x00060000 0x40000>; + read-only; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0x000a0000 0x1e0000>; + read-only; + }; + + partition@280000 { + label = "0:devcfg"; + reg = <0x00280000 0x20000>; + read-only; + }; + + partition@2a0000 { + label = "0:apdp"; + reg = <0x002a0000 0x20000>; + read-only; + }; + + partition@2c0000 { + label = "0:rpm"; + reg = <0x002c0000 0x40000>; + read-only; + }; + + partition@300000 { + label = "0:cdt"; + reg = <0x00300000 0x20000>; + read-only; + }; + + partition@320000 { + label = "0:appsbl"; + reg = <0x00320000 0xc0000>; + read-only; + }; + + partition@3e0000 { + label = "0:appsblenv"; + reg = <0x003e0000 0x20000>; + }; + + partition@400000 { + compatible = "linux,ubi"; + label = "UBI_DEV"; + reg = <0x00400000 0xfc00000>; + }; + }; + }; +}; + +&blsp1_i2c2 { + status = "okay"; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + qca8337_0: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x0>; + }; + + qca8337_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x1>; + }; + + qca8337_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x2>; + }; + + qca8337_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x3>; + }; + + qca8337_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x4>; + }; + + /* + * Vendor bootloader has path for ethernet-phy@5 hardcoded + * and if its there it will delete the node, but since we + * need the QCA8035 for DSA lets fool the bootloader by using + * ethernet-phy@05 even though it causes DTC to print a warning. + */ + qca8035: ethernet-phy@05 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x5>; + }; + + qca8033: ethernet-phy@6 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x6>; + }; + + ethernet-phy-package@8 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <8>; + + qcom,package-mode = "qsgmii"; + + qca8075_8: ethernet-phy@8 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x8>; + }; + + qca8075_9: ethernet-phy@9 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x9>; + }; + + qca8075_a: ethernet-phy@a { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0xa>; + }; + + qca8075_b: ethernet-phy@b { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0xb>; + }; + }; + + qca8337: switch@10 { + compatible = "qca,qca8337"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x10>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "cpu"; + ethernet = <&dp1>; + phy-mode = "rgmii-rxid"; + phy-handle = <&qca8035>; + }; + + port@1 { + reg = <1>; + label = "lan7"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan6"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan5"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + }; + + port@5 { + reg = <5>; + label = "lan3"; + phy-handle = <&qca8337_4>; + }; + + port@6 { + reg = <6>; + label = "lan8"; + phy-mode = "sgmii"; + phy-handle = <&qca8033>; + managed = "in-band-status"; + qca,sgmii-enable-pll; + }; + }; + }; +}; + +&soc { + /* + * This is techically incorrect and will cause a DTC warning as + * all nodes under a bus are supposed to have addresses as well + * but its required as bootloader has this path hardcoded in + * order to enable AQR113C on newer revisions. + */ + mdio1: mdio1 { + compatible = "virtual,mdio-gpio"; + pinctrl-0 = <&mdio_gpio_pins>; + pinctrl-names = "default"; + gpios = <&tlmm 56 GPIO_ACTIVE_HIGH>, + <&tlmm 54 GPIO_ACTIVE_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + + /* + * PCB R5.00, AQR113C + * No idea why the bitbanged this one. + * @5 is wrong, but their bootloader has it hardcoded in + * order to dynamically enable the PHY for newer HW. + */ + aqr113c: ethernet-phy@5 { + status = "disabled"; + compatible ="ethernet-phy-ieee802.3-c45"; + reg = <8>; + }; + }; +}; + +&switch { + status = "okay"; + + pinctrl-0 = <&uniphy_pins>; + pinctrl-names = "default"; + + switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT5 | ESS_PORT6)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode1 = ; /* mac mode for uniphy instance1*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@0 { + port_id = <1>; + phy_address = <0x8>; + }; + port@1 { + port_id = <2>; + phy_address = <0x9>; + }; + port@2 { + port_id = <3>; + phy_address = <0xa>; + }; + port@3 { + port_id = <4>; + phy_address = <0xb>; + }; + + sfp: port@4 { + port_id = <5>; + phy_address = <30>; + phy_i2c_address = <30>; + phy-i2c-mode; /*i2c access phy */ + media-type = "sfp"; /* fiber mode */ + sfp_tx_dis_pin = <&tlmm 48 GPIO_ACTIVE_HIGH>; + sfp_mod_present_pin = <&tlmm 46 GPIO_ACTIVE_LOW>; + }; + + /* PCB R5.00, AQR113C */ + port@5_113c { + status = "disabled"; + port_id = <6>; + phy_address = <8>; + ethernet-phy-ieee802.3-c45; + mdiobus = <&mdio1>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp1 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_8>; + label = "switch"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_9>; + label = "lan2"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_a>; + label = "lan1"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_b>; + label = "wan"; +}; + +&dp5_syn { + status = "okay"; + phy-handle = <&sfp>; + label = "10g-sfp"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&aqr113c>; + label = "10g-copper"; +}; + +&wifi { + status = "okay"; + qcom,ath11k-calibration-variant = "Asus-RT-AX89X"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxk80.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxk80.dtsi new file mode 100755 index 0000000..221de78 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxk80.dtsi @@ -0,0 +1,541 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2021, Flole + * Copyright (c) 2023, Andrew Smith + */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-ess.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include +#include +#include + +/ { + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_front_blue; + led-failsafe = &led_front_red; + led-running = &led_front_green; + led-upgrade = &led_front_white; + label-mac-device = &dp2; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.mtd=rootfs root=/dev/ubiblock0_0"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_front_blue: front-blue { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_front_green: front-green { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 29 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_front_red: front-red { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 31 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_front_white: front-white { + function = LED_FUNCTION_STATUS; + gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + color = ; + }; + + led_power_green: power-green { + function = LED_FUNCTION_POWER; + gpios = <&tlmm 21 GPIO_ACTIVE_LOW>; + color = ; + default-state = "on"; + }; + + led_power_red: power-red { + function = LED_FUNCTION_POWER; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + color = ; + panic-indicator; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + leds_pins: leds_pinmux { + led_power_green { + pins = "gpio21"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_power_red { + pins = "gpio22"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_white { + pins = "gpio26"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_green { + pins = "gpio29"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_red { + pins = "gpio31"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + led_blue { + pins = "gpio33"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&blsp1_i2c2 { + pinctrl-0 = <&i2c_0_pins>; + pinctrl-names = "default"; + + status = "okay"; + + tlc59208f@27 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "ti,tlc59108"; + reg = <0x27>; + + led@0 { + label = "rgb:led0"; + reg = <0>; + linux,default-trigger = "default-off"; + }; + + led@1 { + label = "rgb:led1"; + reg = <1>; + linux,default-trigger = "default-off"; + }; + + led@2 { + label = "rgb:led2"; + reg = <2>; + linux,default-trigger = "default-off"; + }; + + led@3 { + label = "rgb:led3"; + reg = <3>; + linux,default-trigger = "default-off"; + }; + }; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x00 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig_1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + }; + + partition@1000000 { + label = "0:art.bak"; + reg = <0x1000000 0x80000>; + read-only; + }; + + partition@1080000 { + label = "config"; + reg = <0x1080000 0x100000>; + }; + + partition@1180000 { + label = "boarddata1"; + reg = <0x1180000 0x100000>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_boarddata1_0: macaddr@0 { + reg = <0x0 0x6>; + }; + + macaddr_boarddata1_6: macaddr@6 { + reg = <0x6 0x6>; + }; + }; + }; + + partition@1280000 { + label = "boarddata2"; + reg = <0x1280000 0x100000>; + }; + + partition@1380000 { + label = "pot"; + reg = <0x1380000 0x100000>; + read-only; + }; + + partition@1480000 { + label = "dnidata"; + reg = <0x1480000 0x500000>; + read-only; + }; + + partition@1980000 { + label = "kernel"; + reg = <0x1980000 0x620000>; + }; + + partition@1fa0000 { + label = "rootfs"; + reg = <0x1fa0000 0x66e0000>; + }; + + partition@8680000 { + label = "kernel2"; + reg = <0x8680000 0x620000>; + read-only; + }; + + partition@8ca0000 { + label = "rootfs2"; + reg = <0x8ca0000 0x66e0000>; + read-only; + }; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + compatible = "qcom,qca8075-package"; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; + + qca8081_28: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + switch_mac_mode2 = ; /* mac mode for uniphy instance2*/ + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + port@3 { + port_id = <3>; + phy_address = <2>; + }; + port@4 { + port_id = <4>; + phy_address = <3>; + }; + port@5 { + port_id = <5>; + phy_address = <4>; + }; + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "lan2"; + nvmem-cells = <&macaddr_boarddata1_0>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; + nvmem-cells = <&macaddr_boarddata1_0>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan4"; + nvmem-cells = <&macaddr_boarddata1_0>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "lan5"; + nvmem-cells = <&macaddr_boarddata1_0>; + nvmem-cell-names = "mac-address"; +}; + +&dp6 { + status = "okay"; + phy-handle = <&qca8081_28>; + label = "wan"; + nvmem-cells = <&macaddr_boarddata1_6>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Netgear-SXK80"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxr80.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxr80.dts new file mode 100755 index 0000000..d90e75d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxr80.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Flole */ + +/dts-v1/; + +#include "ipq8074-sxk80.dtsi" + +/ { + model = "Netgear SXR80"; + compatible = "netgear,sxr80", "qcom,ipq8074"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxs80.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxs80.dts new file mode 100755 index 0000000..0d7240c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-sxs80.dts @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2021, Flole */ + +/dts-v1/; + +#include "ipq8074-sxk80.dtsi" + +/ { + model = "Netgear SXS80"; + compatible = "netgear,sxs80", "qcom,ipq8074"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-wax630.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-wax630.dts new file mode 100755 index 0000000..3393efd --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-wax630.dts @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Netgear WAX630"; + compatible = "netgear,wax630", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + + ethernet0 = &dp6_syn; + ethernet1 = &dp4; + label-mac-device = &dp6_syn; + + led-boot = &led_system_blue; + led-failsafe = &led_system_red; + led-running = &led_system_green; + led-upgrade = &led_system_blue; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + led-spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>; + + led_gpio: led-gpio@0 { + compatible = "fairchild,74hc595"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + registers-number = <1>; + enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + spi-max-frequency = <1000000>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system_red: system-red { + label = "system:red"; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + led_system_green: system-green { + label = "system:green"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + led_system_blue: system-blue { + label = "system:blue"; + gpios = <&tlmm 21 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + lan1-green { + label = "lan1:green"; + gpios = <&tlmm 26 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + lan1-orange { + label = "lan1:orange"; + gpios = <&tlmm 27 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + lan2-green { + label = "lan2:green"; + gpios = <&tlmm 57 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + lan2-orange { + label = "lan2:orange"; + gpios = <&tlmm 60 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + 2g-blue { + label = "wlan2g:blue"; + gpios = <&tlmm 29 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + 2g-green { + label = "wlan2g:green"; + gpios = <&tlmm 30 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + 5g-low-blue { + label = "wlan5g_low:blue"; + gpios = <&tlmm 33 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + 5g-low-green { + label = "wlan5g_low:green"; + gpios = <&tlmm 34 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + 5g-high-blue { + label = "wlan5g_high:blue"; + gpios = <&tlmm 31 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + 5g-high-green { + label = "wlan5g_high:green"; + gpios = <&tlmm 32 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + }; +}; + +&edma { + status = "okay"; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT4 | ESS_PORT6)>; + switch_mac_mode = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@6 { + port_id = <6>; + phy_address = <28>; + port_mac_sel = "QGMAC_PORT"; + }; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + }; + + qca8081: ethernet-phy@28 { + compatible = "ethernet-phy-id004d.d101"; + reg = <28>; + reset-deassert-us = <10000>; + reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; + }; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan2"; +}; + +&dp6_syn { + status = "okay"; + phy-handle = <&qca8081>; + label = "lan1"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Netgear-WAX630"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-wxr-5950ax12.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-wxr-5950ax12.dts new file mode 100755 index 0000000..f5574c1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8074-wxr-5950ax12.dts @@ -0,0 +1,371 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-hk-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + model = "Buffalo WXR-5950AX12"; + compatible = "buffalo,wxr-5950ax12", "qcom,ipq8074"; + + aliases { + serial0 = &blsp1_uart5; + led-boot = &led_power_white; + led-failsafe = &led_power_red; + led-running = &led_power_white; + led-upgrade = &led_power_white; + label-mac-device = &dp5_syn; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " ubi.mtd=user_property root=/dev/ubiblock1_0"; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + color = ; + function = "router"; + }; + + led-1 { + gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>; + color = ; + function = "router"; + }; + + led_power_red: led-2 { + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led_power_white: led-3 { + gpios = <&tlmm 34 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led-4 { + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + color = ; + function = "internet"; + }; + + led-5 { + gpios = <&tlmm 44 GPIO_ACTIVE_HIGH>; + color = ; + function = "internet"; + }; + + led-6 { + gpios = <&tlmm 55 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN; + }; + + led-7 { + gpios = <&tlmm 56 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN; + }; + }; + + keys { + compatible = "gpio-keys"; + + /* + * mode: 3x position switch + * + * - ROUTER + * - AP + * - WB (Wireless Bridge) + */ + ap { + label = "mode-ap"; + gpios = <&tlmm 29 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + bridge { + label = "mode-wb"; + gpios = <&tlmm 30 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + /* + * op: 2x position switch + * + * - AUTO + * - MANUAL (select Router/AP/WB manually) + */ + manual { + label = "op-manual"; + gpios = <&tlmm 52 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 51 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&tlmm 54 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + reg_usb_vbus: regulator-5v-vbus { + compatible = "regulator-fixed"; + regulator-name = "vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpios = <&tlmm 64 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-always-on; + }; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-appsblenv { + compatible = "fixed-partitions"; + label = "0:appsblenv"; + read-only; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "env-data"; + reg = <0x0 0x40000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_appsblenv_ethaddr: ethaddr { + }; + }; + }; + }; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + /* + * RESET pins of phy chips + * + * WXR-5950AX12 has 2x RESET pins for QCA8075 and AQR113C. + * The pin of QCA8075 is for the chip and not phys in the chip, the + * pin of AQR113C is for 2x chips. So both pins are not appropriate + * to declare them as reset-gpios in phy nodes. + * Multiple entries in reset-gpios of mdio may not be supported, but + * leave the following as-is to show that the those reset pin exists. + */ + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>, /* QCA8075 RESET */ + <&tlmm 63 GPIO_ACTIVE_LOW>; /* AQR113C RESET (2x) */ + + aqr113c_1: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <0x0>; + }; + + aqr113c_2: ethernet-phy@8 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <0x8>; + }; + + ethernet-phy-package@17 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0x18>; + + qcom,package-mode = "qsgmii"; + + qca8075_1: ethernet-phy@19 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x19>; + }; + + qca8075_2: ethernet-phy@1a { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x1a>; + }; + + qca8075_3: ethernet-phy@1b { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0x1b>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3 | ESS_PORT4 | ESS_PORT6)>; + switch_wan_bmp = ; + switch_mac_mode = ; + switch_mac_mode1 = ; + switch_mac_mode2 = ; + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <0x19>; + }; + + port@3 { + port_id = <3>; + phy_address = <0x1a>; + }; + + port@4 { + port_id = <4>; + phy_address = <0x1b>; + }; + + port@5 { + port_id = <5>; + ethernet-phy-ieee802.3-c45; + phy_address = <0x0>; + }; + + port@6 { + port_id = <6>; + ethernet-phy-ieee802.3-c45; + phy_address = <0x8>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&dp2 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_1>; + label = "lan4"; + nvmem-cells = <&macaddr_appsblenv_ethaddr>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_2>; + label = "lan3"; + nvmem-cells = <&macaddr_appsblenv_ethaddr>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-mode = "qsgmii"; + phy-handle = <&qca8075_3>; + label = "lan2"; + nvmem-cells = <&macaddr_appsblenv_ethaddr>; + nvmem-cell-names = "mac-address"; +}; + +&dp5_syn { + status = "okay"; + phy-mode = "usxgmii"; + phy-handle = <&aqr113c_1>; + label = "wan"; + nvmem-cells = <&macaddr_appsblenv_ethaddr>; + nvmem-cell-names = "mac-address"; +}; + +&dp6_syn { + status = "okay"; + phy-mode = "usxgmii"; + phy-handle = <&aqr113c_2>; + label = "lan1"; + nvmem-cells = <&macaddr_appsblenv_ethaddr>; + nvmem-cell-names = "mac-address"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; + + vbus-supply = <®_usb_vbus>; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Buffalo-WXR-5950AX12"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq807x-nwax10ax.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq807x-nwax10ax.dtsi new file mode 100755 index 0000000..f92d901 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq807x-nwax10ax.dtsi @@ -0,0 +1,375 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Copyright (c) 2025 Pascal Beleiu + * Copyright (c) 2025 Eric SchΓ€fer + */ + +/dts-v1/; + +#include "ipq8074.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + aliases { + led-boot = &lp5562_blue; + led-failsafe = &lp5562_white; + led-running = &lp5562_green; + led-upgrade = &lp5562_red; + serial0 = &blsp1_uart5; + }; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/ubiblock0_1 loglevel=7"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 31 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + hw_algo = "toggle"; + hw_margin_ms = <10000>; + always-running; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&edma { + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pins { + mdc { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + mdio_gpio_pins: mdio-gpio-pins { + pins = "gpio37", "gpio44"; + function = "gpio"; + bias-pull-up; + }; + + i2c_6_pins: i2c-6-state { + pins = "gpio0", "gpio2"; + drive-strength = <8>; + function = "blsp5_i2c"; + bias-disable; + }; +}; + +&switch { + status = "okay"; + + phyinfo: qcom,port_phyinfo { + port@1 { + port_id = <1>; + phy_address = <1>; + }; + }; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ar8033: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; +}; + +&dp1 { + status = "okay"; + phy-handle = <&ar8033>; + phy-mode = "sgmii"; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + cs-select = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x50000>; + read-only; + }; + + partition@50000 { + label = "0:mibib"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "0:bootconfig"; + reg = <0x60000 0x20000>; + }; + + partition@80000 { + label = "0:bootconfig1"; + reg = <0x80000 0x20000>; + }; + + partition@a0000 { + label = "0:qsee"; + reg = <0xa0000 0x180000>; + read-only; + }; + + partition@220000 { + label = "0:qsee_1"; + reg = <0x220000 0x180000>; + read-only; + }; + + partition@3a0000 { + label = "0:devcfg"; + reg = <0x3a0000 0x10000>; + read-only; + }; + + partition@3b0000 { + label = "0:devcfg_1"; + reg = <0x3b0000 0x10000>; + read-only; + }; + + partition@3c0000 { + label = "0:apdp"; + reg = <0x3c0000 0x10000>; + read-only; + }; + + partition@3d0000 { + label = "0:apdp_1"; + reg = <0x3d0000 0x10000>; + read-only; + }; + + partition@3e0000 { + label = "0:rpm"; + reg = <0x3e0000 0x40000>; + read-only; + }; + + partition@420000 { + label = "0:rpm_1"; + reg = <0x420000 0x40000>; + read-only; + }; + + partition@460000 { + label = "0:cdt"; + reg = <0x460000 0x10000>; + read-only; + }; + + partition@470000 { + label = "0:cdt_1"; + reg = <0x470000 0x10000>; + read-only; + }; + + partition@480000 { + label = "0:appsblenv"; + reg = <0x480000 0x10000>; + read-only; + }; + + partition@490000 { + label = "0:appsbl"; + reg = <0x490000 0xa0000>; + read-only; + }; + + partition@530000 { + label = "0:appsbl_1"; + reg = <0x530000 0xa0000>; + read-only; + }; + + partition@5d0000 { + label = "0:art"; + reg = <0x5d0000 0x40000>; + read-only; + }; + + partition@610000 { + label = "mrd"; + reg = <0x610000 0x10000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + label_mac: macaddr@fff8 { + compatible = "mac-base"; + reg = <0xfff8 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@620000 { + label = "mrd_1"; + reg = <0x620000 0x10000>; + read-only; + }; + + partition@630000 { + label = "conf"; + reg = <0x630000 0x1d0000>; + read-only; + }; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + nand-ecc-strength = <4>; + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = <0x00 0x3c00000>; + label = "rootfs"; + }; + + partition@3c00000 { + reg = <0x3c00000 0x800000>; + label = "0:wififw"; + read-only; + }; + + partition@4400000 { + reg = <0x4400000 0x3c00000>; + label = "rootfs_1"; + }; + + partition@8000000 { + reg = <0x8000000 0x800000>; + label = "0:wififw_1"; + read-only; + }; + + partition@8800000 { + reg = <0x8800000 0x7800000>; + label = "logs"; + }; + }; +}; + +&wifi { + status = "okay"; +}; + +&blsp1_i2c6 { + pinctrl-0 = <&i2c_6_pins>; + pinctrl-names = "default"; + status = "okay"; + + lp5562@30 { + compatible = "ti,lp5562"; + reg = <0x30>; + clock-mode = [02]; + #address-cells = <1>; + #size-cells = <0>; + + lp5562_red: led@0 { + chan-name = "lp5562_red"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <0>; + }; + + lp5562_green: led@1 { + chan-name = "lp5562_green"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <1>; + }; + + lp5562_blue: led@2 { + chan-name = "lp5562_blue"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <2>; + }; + + lp5562_white: led@3 { + chan-name = "lp5562_white"; + led-cur = [20]; + max-cur = [60]; + color = ; + function = LED_FUNCTION_STATUS; + reg = <3>; + }; + }; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-homewrk.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-homewrk.dts new file mode 100755 index 0000000..e623036 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-homewrk.dts @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8174-mx4x00.dtsi" + +/ { + model = "Linksys HomeWRK"; + compatible = "linksys,homewrk", "qcom,ipq8074"; + + aliases { + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1"; + }; +}; + +&qpic_nand { + status = "okay"; + + nand@0 { + reg = <0>; + /* + * Some devices use Micron NAND with with 8 bit ECC + * other AMD/Spansion NAND with 4 bit ECC + *nand-ecc-strength = <4>; + *nand-ecc-step-size = <512>; + */ + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "wan"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan2"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "lan1"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-HomeWRK"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200.dtsi new file mode 100755 index 0000000..16fd4b5 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200.dtsi @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2023, Mohammad Sayful Islam */ + +#include "ipq8174-mx4x00.dtsi" + +/ { + aliases { + label-mac-device = &dp2; + }; +}; + +&tlmm { + iot_pins: iot-state { + recovery-pins { + pins = "gpio22"; + function = "gpio"; + input; + }; + + reset-pins { + pins = "gpio21"; + function = "gpio"; + bias-pull-up; + }; + }; +}; + +&blsp1_uart3 { + status = "okay"; + + pinctrl-0 = <&hsuart_pins &iot_pins>; + pinctrl-names = "default"; + + /* Silicon Labs EFR32MG21 IoT */ +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + }; + + partition@1000000 { + label = "u_env"; + reg = <0x1000000 0x40000>; + }; + + partition@1040000 { + label = "s_env"; + reg = <0x1040000 0x20000>; + }; + + partition@1060000 { + label = "devinfo"; + reg = <0x1060000 0x20000>; + read-only; + + nvmem-layout { + compatible = "ascii-eq-delim-env"; + + hw_mac_addr: hw_mac_addr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@1080000 { + label = "kernel"; + reg = <0x1080000 0x9600000>; + }; + + partition@1680000 { + label = "rootfs"; + reg = <0x1680000 0x9000000>; + }; + + partition@a680000 { + label = "alt_kernel"; + reg = <0xa680000 0x9600000>; + }; + + partition@ac80000 { + label = "alt_rootfs"; + reg = <0xac80000 0x9000000>; + }; + + partition@13c80000 { + label = "sysdiag"; + reg = <0x13c80000 0x200000>; + read-only; + }; + + partition@13e80000 { + label = "0:ethphyfw"; + reg = <0x13e80000 0x80000>; + read-only; + }; + + partition@13f00000 { + label = "syscfg"; + reg = <0x13f00000 0xb800000>; + read-only; + }; + + partition@1f700000 { + label = "0:wififw"; + reg = <0x1f700000 0x900000>; + read-only; + }; + }; + }; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + label = "wan"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + label = "lan1"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + label = "lan2"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; + label = "lan3"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200v1.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200v1.dts new file mode 100755 index 0000000..7946e5c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200v1.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2023, Mohammad Sayful Islam */ + +/dts-v1/; + +#include "ipq8074-512m.dtsi" +#include "ipq8174-mx4200.dtsi" + +/ { + model = "Linksys MX4200v1"; + compatible = "linksys,mx4200v1", "qcom,ipq8074"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-MX4200v1"; + qcom,ath11k-fw-memory-mode = <1>; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200v2.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200v2.dts new file mode 100755 index 0000000..44e1b72 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4200v2.dts @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2023, Mohammad Sayful Islam */ + +/dts-v1/; + +#include "ipq8174-mx4200.dtsi" + +/ { + model = "Linksys MX4200v2"; + compatible = "linksys,mx4200v2", "qcom,ipq8074"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-MX4200v2"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4300.dts b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4300.dts new file mode 100755 index 0000000..7e72195 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4300.dts @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq8174-mx4x00.dtsi" + +/ { + model = "Linksys MX4300"; + compatible = "linksys,mx4300", "qcom,ipq8074"; + + chosen { + /* + In the kernel command line, replace the first occurence of bootargs-find-X with bootargs-replace-X. + If bootargs-exact-match-X is set to "y", then replacement happens only if the kernel command line + is identical to bootargs-find-X. + */ + bootargs-find-1 = "ubi.mtd=22,2048"; + bootargs-replace-1 = "ubi.mtd=22,4096"; + + bootargs-find-2 = "ubi.mtd=24,2048"; + bootargs-replace-2 = "ubi.mtd=24,4096"; + }; + + aliases { + label-mac-device = &dp2; + }; +}; + +&qpic_nand { + status = "okay"; + + /* + * Bootloader will find the NAND DT node by the compatible and + * then "fixup" it by adding the partitions from the SMEM table + * using the legacy bindings thus making it impossible for us + * to change the partition table or utilize NVMEM for calibration. + * So add a dummy partitions node that bootloader will populate + * and set it as disabled so the kernel ignores it instead of + * printing warnings due to the broken way bootloader adds the + * partitions. + */ + partitions { + status = "disabled"; + }; + + nand@0 { + reg = <0>; + /* + * Some devices use Micron NAND with with 8 bit ECC + * other AMD/Spansion NAND with 4 bit ECC + *nand-ecc-strength = <4>; + *nand-ecc-step-size = <512>; + */ + nand-bus-width = <8>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:sbl1"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "0:mibib"; + reg = <0x100000 0x100000>; + read-only; + }; + + partition@200000 { + label = "0:bootconfig"; + reg = <0x200000 0x80000>; + read-only; + }; + + partition@280000 { + label = "0:bootconfig1"; + reg = <0x280000 0x80000>; + read-only; + }; + + partition@300000 { + label = "0:qsee"; + reg = <0x300000 0x300000>; + read-only; + }; + + partition@600000 { + label = "0:qsee_1"; + reg = <0x600000 0x300000>; + read-only; + }; + + partition@900000 { + label = "0:devcfg"; + reg = <0x900000 0x80000>; + read-only; + }; + + partition@980000 { + label = "0:devcfg_1"; + reg = <0x980000 0x80000>; + read-only; + }; + + partition@a00000 { + label = "0:apdp"; + reg = <0xa00000 0x80000>; + read-only; + }; + + partition@a80000 { + label = "0:apdp_1"; + reg = <0xa80000 0x80000>; + read-only; + }; + + partition@b00000 { + label = "0:rpm"; + reg = <0xb00000 0x80000>; + read-only; + }; + + partition@b80000 { + label = "0:rpm_1"; + reg = <0xb80000 0x80000>; + read-only; + }; + + partition@c00000 { + label = "0:cdt"; + reg = <0xc00000 0x80000>; + read-only; + }; + + partition@c80000 { + label = "0:cdt_1"; + reg = <0xc80000 0x80000>; + read-only; + }; + + partition@d00000 { + label = "0:appsblenv"; + reg = <0xd00000 0x80000>; + }; + + partition@d80000 { + label = "0:appsbl"; + reg = <0xd80000 0x100000>; + read-only; + }; + + partition@e80000 { + label = "0:appsbl_1"; + reg = <0xe80000 0x100000>; + read-only; + }; + + partition@f80000 { + label = "0:art"; + reg = <0xf80000 0x80000>; + read-only; + }; + + partition@1000000 { + label = "u_env"; + reg = <0x1000000 0x100000>; + }; + + partition@1100000 { + label = "s_env"; + reg = <0x1100000 0x100000>; + }; + + partition@1200000 { + label = "devinfo"; + reg = <0x1200000 0x40000>; + read-only; + + nvmem-layout { + compatible = "ascii-eq-delim-env"; + + hw_mac_addr: hw_mac_addr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@1240000 { + label = "kernel"; + reg = <0x1240000 0xaf40000>; + }; + + partition@1a40000 { + label = "rootfs"; + reg = <0x1a40000 0xa740000>; + }; + + partition@c180000 { + label = "alt_kernel"; + reg = <0xc180000 0xaf40000>; + }; + + partition@c980000 { + label = "alt_rootfs"; + reg = <0xc980000 0xa740000>; + }; + + partition@170c0000 { + label = "sysdiag"; + reg = <0x170c0000 0x400000>; + read-only; + }; + + partition@174c0000 { + label = "0:ethphyfw"; + reg = <0x174c0000 0x80000>; + read-only; + }; + + partition@17540000 { + label = "syscfg"; + reg = <0x17540000 0x79c0000>; + read-only; + }; + + partition@1ef00000 { + label = "secured_store"; + reg = <0x1ef00000 0x400000>; + read-only; + }; + + partition@1f300000 { + label = "0:wififw"; + reg = <0x1f300000 0x1900000>; + read-only; + }; + + partition@20c00000 { + label = "app2_data"; + reg = <0x20c00000 0x16180000>; + read-only; + }; + + partition@36d80000 { + label = "app2"; + reg = <0x36d80000 0x9280000>; + read-only; + }; + }; + }; +}; + +&dp2 { + status = "okay"; + phy-handle = <&qca8075_1>; + label = "wan"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp3 { + status = "okay"; + phy-handle = <&qca8075_2>; + label = "lan3"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp4 { + status = "okay"; + phy-handle = <&qca8075_3>; + label = "lan2"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&dp5 { + status = "okay"; + phy-handle = <&qca8075_4>; + label = "lan1"; + nvmem-cells = <&hw_mac_addr 0>; + nvmem-cell-names = "mac-address"; +}; + +&wifi { + status = "okay"; + + qcom,ath11k-calibration-variant = "Linksys-MX4200v1"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4x00.dtsi b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4x00.dtsi new file mode 100755 index 0000000..1bd150c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/dts/ipq8174-mx4x00.dtsi @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* Copyright (c) 2023, Mohammad Sayful Islam */ + +#include "ipq8074.dtsi" +#include "ipq8074-ac-cpu.dtsi" +#include "ipq8074-ess.dtsi" +#include +#include +#include + +/ { + aliases { + serial0 = &blsp1_uart5; + serial1 = &blsp1_uart3; + led-boot = &led_system_blue; + led-running = &led_system_blue; + led-failsafe = &led_system_red; + led-upgrade = &led_system_green; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset-button { + label = "reset"; + gpios = <&tlmm 52 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 67 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&tlmm { + button_pins: button-state { + pins = "gpio52", "gpio67"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio_pins: mdio-state { + mdc-pins { + pins = "gpio68"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio69"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; +}; + +&blsp1_uart5 { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&crypto { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&blsp1_i2c2 { + status = "okay"; + + led-controller@62 { + compatible = "nxp,pca9633"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x62>; + nxp,hw-blink; + + led_system_red: led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_green: led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_STATUS; + }; + + led_system_blue: led@2 { + reg = <2>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; +}; + +&mdio { + status = "okay"; + + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qca8075_1: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; + + qca8075_2: ethernet-phy@2 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + }; + + qca8075_3: ethernet-phy@3 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <3>; + }; + + qca8075_4: ethernet-phy@4 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <4>; + }; + }; +}; + +&switch { + status = "okay"; + + switch_lan_bmp = <(ESS_PORT3 | ESS_PORT4 | ESS_PORT5)>; /* lan port bitmap */ + switch_wan_bmp = ; /* wan port bitmap */ + switch_mac_mode = ; /* mac mode for uniphy instance0*/ + + qcom,port_phyinfo { + port@2 { + port_id = <2>; + phy_address = <1>; + }; + + port@3 { + port_id = <3>; + phy_address = <2>; + }; + + port@4 { + port_id = <4>; + phy_address = <3>; + }; + + port@5 { + port_id = <5>; + phy_address = <4>; + }; + }; +}; + +&edma { + status = "okay"; +}; + +&ssphy_0 { + status = "okay"; +}; + +&qusb_phy_0 { + status = "okay"; +}; + +&usb_0 { + status = "okay"; +}; diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/Makefile b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/Makefile new file mode 100755 index 0000000..245dc76 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/Makefile @@ -0,0 +1,41 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/image.mk + +define Device/Default + PROFILES := Default + KERNEL_LOADADDR := 0x41000000 + DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1))) + DEVICE_DTS_CONFIG := config@1 + DEVICE_DTS_DIR := ../dts + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin = sysupgrade-tar | append-metadata + IMAGE/sysupgrade.bin/squashfs := +endef + +define Device/FitImage + KERNEL_SUFFIX := -uImage.itb + KERNEL = kernel-bin | libdeflate-gzip | fit gzip $$(KDIR)/image-$$(DEVICE_DTS).dtb + KERNEL_NAME := Image +endef + +define Device/FitImageLzma + KERNEL_SUFFIX := -uImage.itb + KERNEL = kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(DEVICE_DTS).dtb + KERNEL_NAME := Image +endef + +define Device/EmmcImage + IMAGES += factory.bin + IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k + IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to 64k | sysupgrade-tar rootfs=$$$$@ | append-metadata +endef + +define Device/UbiFit + KERNEL_IN_UBI := 1 + IMAGES += factory.ubi + IMAGE/factory.ubi := append-ubi +endef + +include $(SUBTARGET).mk + +$(eval $(call BuildImage)) diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/glinet_gl-b3000.bootscript b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/glinet_gl-b3000.bootscript new file mode 100755 index 0000000..0962937 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/glinet_gl-b3000.bootscript @@ -0,0 +1,47 @@ +if test "x$verbose" = "x"; then + failedmsg=\'[failed]\' +else + failedmsg='######################################## Failed' +fi + +if test -n $soc_hw_version; then + if test "$soc_hw_version" = "20180100" || test "$soc_hw_version" = "20180101" ; then + echo 'soc_hw_version : Validation success' + else + echo 'soc_hw_version : did not match, aborting upgrade' + exit 1 + fi +else + echo 'soc_hw_version : unknown, skipping validation' +fi + +if test "$machid" = "8040004" ; then + echo 'machid : Validation success' +else + echo 'machid : unknown, aborting upgrade' + exit 1 +fi + +if test "x$verbose" = "x"; then + echo \\c'Flashing ubi: ' + setenv stdout nulldev +else + echo '######################################## Flashing ubi: Started' +fi + +failreason='error: failed on image extraction' +imxtract $imgaddr ubi || setenv stdout serial && echo "$failedmsg" && echo "$failreason" && exit 1 +failreason='error: failed on partition erase' +nand device 0 && nand erase 0x00800000 0x07800000 || setenv stdout serial && echo "$failedmsg" && echo "$failreason" && exit 1 +failreason='error: failed on partition write' +nand write $fileaddr 0x00800000 rootfs_size || setenv stdout serial && echo "$failedmsg" && echo "$failreason" && exit 1 +if test "x$verbose" = "x"; then + setenv stdout serial + echo '[ done ]' + setenv stdout nulldev + setenv stdout serial +else + echo '######################################## Flashing ubi: Done' +fi + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq50xx.mk b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq50xx.mk new file mode 100755 index 0000000..a636fea --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq50xx.mk @@ -0,0 +1,252 @@ +DTS_DIR := $(DTS_DIR)/qcom +DEVICE_VARS += BOOT_SCRIPT + +define Build/mstc-header + $(eval version=$(word 1,$(1))) + $(eval hdrlen=$(if $(word 2,$(1)),$(word 2,$(1)),0x400)) + gzip -c $@ | tail -c8 > $@.crclen + ( \ + printf "CMOC"; \ + tail -c+5 $@.crclen; head -c4 $@.crclen; \ + printf '$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' | \ + dd bs=64 count=1 conv=sync 2>/dev/null; \ + printf "$(version)" | \ + dd bs=64 count=1 conv=sync 2>/dev/null; \ + dd if=/dev/zero bs=$$(($(hdrlen) - 0x8c)) count=1 2>/dev/null; \ + cat $@; \ + ) > $@.new + mv $@.new $@ + rm -f $@.crclen +endef + +define Device/cmcc_mr3000d-ci + $(call Device/FitImageLzma) + $(call Device/UbiFit) + DEVICE_VENDOR := CMCC + DEVICE_MODEL := MR3000D-CI + DEVICE_DTS_CONFIG := config@mp03.3-m1 + SOC := ipq5018 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 59392k + NAND_SIZE := 128m + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-cmcc_mr3000d-ci +endef +TARGET_DEVICES += cmcc_mr3000d-ci + +define Device/cmcc_pz-l8 + $(call Device/FitImageLzma) + $(call Device/UbiFit) + DEVICE_VENDOR := CMCC + DEVICE_MODEL := PZ-L8 + DEVICE_DTS_CONFIG := config@mp02.1 + SOC := ipq5018 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 59392k + NAND_SIZE := 128m +endef +TARGET_DEVICES += cmcc_pz-l8 + +define Device/elecom_wrc-x3000gs2 + $(call Device/FitImageLzma) + DEVICE_VENDOR := ELECOM + DEVICE_MODEL := WRC-X3000GS2 + DEVICE_DTS_CONFIG := config@mp03.3 + SOC := ipq5018 + KERNEL_IN_UBI := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 52480k + NAND_SIZE := 128m + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand | \ + mstc-header 4.04(XZF.0)b90 | elecom-product-header WRC-X3000GS2 + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-elecom_wrc-x3000gs2 +endef +TARGET_DEVICES += elecom_wrc-x3000gs2 + +define Device/glinet_gl-b3000 + $(call Device/FitImage) + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-B3000 + SOC := ipq5018 + KERNEL_IN_UBI := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + NAND_SIZE := 128m + DEVICE_DTS_CONFIG := config@mp03.5-c1 + SUPPORTED_DEVICES += b3000 + BOOT_SCRIPT:= glinet_gl-b3000.bootscript + IMAGES := factory.img sysupgrade.bin + IMAGE/factory.img := append-ubi | gl-qsdk-factory | append-metadata + DEVICE_PACKAGES := \ + ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-glinet_gl-b3000 \ + dumpimage +endef +TARGET_DEVICES += glinet_gl-b3000 + +define Device/iodata_wn-dax3000gr + $(call Device/FitImageLzma) + DEVICE_VENDOR := I-O DATA + DEVICE_MODEL := WN-DAX3000GR + DEVICE_DTS_CONFIG := config@mp03.3 + SOC := ipq5018 + KERNEL_IN_UBI := 1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 52480k + NAND_SIZE := 128m + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand | \ + mstc-header 4.04(XZH.1)b90 0x480 + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-iodata_wn-dax3000gr +endef +TARGET_DEVICES += iodata_wn-dax3000gr + +define Device/linksys_ipq50xx_mx_base + $(call Device/FitImageLzma) + DEVICE_VENDOR := Linksys + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 8192k + IMAGE_SIZE := 83968k + NAND_SIZE := 256m + SOC := ipq5018 + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | linksys-image type=$$$$(DEVICE_MODEL) +endef + +define Device/linksys_mr5500 + $(call Device/linksys_ipq50xx_mx_base) + DEVICE_MODEL := MR5500 + DEVICE_DTS_CONFIG := config@mp03.1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018 \ + kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + ipq-wifi-linksys_mr5500 \ + kmod-usb-ledtrig-usbport +endef +TARGET_DEVICES += linksys_mr5500 + +define Device/linksys_mx2000 + $(call Device/linksys_ipq50xx_mx_base) + DEVICE_MODEL := MX2000 + DEVICE_DTS_CONFIG := config@mp03.5-c1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-linksys_mx2000 +endef +TARGET_DEVICES += linksys_mx2000 + +define Device/linksys_mx5500 + $(call Device/linksys_ipq50xx_mx_base) + DEVICE_MODEL := MX5500 + DEVICE_DTS_CONFIG := config@mp03.1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018 \ + kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + ipq-wifi-linksys_mx5500 +endef +TARGET_DEVICES += linksys_mx5500 + +define Device/linksys_mx6200 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Linksys + DEVICE_MODEL := MX6200 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@mp03.5-c1 + KERNEL_SIZE := 8192k + IMAGE_SIZE := 51200k + NAND_SIZE := 256m + SOC := ipq5018 + IMAGE/factory.ubi := append-ubi | linksys-image type=$$$$(DEVICE_MODEL) + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-linksys_mx6200 +endef +TARGET_DEVICES += linksys_mx6200 + +define Device/linksys_spnmx56 + $(call Device/linksys_ipq50xx_mx_base) + DEVICE_MODEL := SPNMX56 + DEVICE_DTS_CONFIG := config@mp03.1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018 \ + kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + ipq-wifi-linksys_spnmx56 +endef +TARGET_DEVICES += linksys_spnmx56 + +define Device/xiaomi_ax6000 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Xiaomi + DEVICE_MODEL := AX6000 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@mp03.1 + SOC := ipq5018 + KERNEL_SIZE := 36864k + NAND_SIZE := 128m + DEVICE_PACKAGES := ath11k-firmware-ipq5018 \ + kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + kmod-ath10k-ct-smallbuffers \ + ath10k-firmware-qca9887-ct \ + ipq-wifi-xiaomi_ax6000 +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + ARTIFACTS := initramfs-factory.ubi + ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-uImage.itb | ubinize-kernel +endif +endef +TARGET_DEVICES += xiaomi_ax6000 + +define Device/yuncore_ax830 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Yuncore + DEVICE_MODEL := AX830 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq5018 + DEVICE_DTS_CONFIG := config@mp03.5-c1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-yuncore_ax830 +endef +TARGET_DEVICES += yuncore_ax830 + +define Device/yuncore_ax850 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Yuncore + DEVICE_MODEL := AX850 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq5018 + DEVICE_DTS_CONFIG := config@mp03.1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018 \ + kmod-ath11k-pci \ + ath11k-firmware-qcn9074 \ + ipq-wifi-yuncore_ax850 +endef +TARGET_DEVICES += yuncore_ax850 + +define Device/zyxel_scr50axe + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Zyxel + DEVICE_MODEL := SCR50AXE + SOC := ipq5018 + BLOCKSIZE := 128k + PAGESIZE := 2048 + NAND_SIZE := 256m + DEVICE_DTS_CONFIG := config@mp03.5-c1 + DEVICE_PACKAGES := ath11k-firmware-ipq5018-qcn6122 \ + ipq-wifi-zyxel_scr50axe +endef +TARGET_DEVICES += zyxel_scr50axe diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq60xx.mk b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq60xx.mk new file mode 100755 index 0000000..bef95ec --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq60xx.mk @@ -0,0 +1,324 @@ +DTS_DIR := $(DTS_DIR)/qcom +DEVICE_VARS += TPLINK_SUPPORT_STRING + +define Build/wax610-netgear-tar + mkdir $@.tmp + mv $@ $@.tmp/nand-ipq6018-apps.img + md5sum $@.tmp/nand-ipq6018-apps.img | cut -c 1-32 > $@.tmp/nand-ipq6018-apps.md5sum + echo "WAX610" > $@.tmp/metadata.txt + echo "WAX610-610Y_V99.9.9.9" > $@.tmp/version + tar -C $@.tmp/ -cf $@ . + rm -rf $@.tmp +endef + +define Build/netgear-rbx350-qsdk-ipq-factory + $(CP) $(FLASH_SCRIPT) $(KDIR_TMP)/ + + echo "VERSION : V5.0.0.0_$(LINUX_VERSION)" > $@.metadata + echo "MODEL_ID : $(DEVICE_MODEL)" >> $@.metadata + + $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh $@.its $(FLASH_SCRIPT) txt $@.metadata ubi $@ + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new + @mv $@.new $@ +endef + +define Device/8devices_mango-dvk + $(call Device/FitImageLzma) + DEVICE_VENDOR := 8devices + DEVICE_MODEL := Mango-DVK + IMAGE_SIZE := 27776k + BLOCKSIZE := 64k + SOC := ipq6010 + SUPPORTED_DEVICES += 8devices,mango + IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-rootfs | pad-rootfs | check-size | append-metadata + DEVICE_PACKAGES := ipq-wifi-8devices_mango +endef +TARGET_DEVICES += 8devices_mango-dvk + +define Device/alfa-network_ap120c-ax + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := ALFA Network + DEVICE_MODEL := AP120C-AX + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq6000 + DEVICE_PACKAGES := ipq-wifi-alfa-network_ap120c-ax +endef +TARGET_DEVICES += alfa-network_ap120c-ax + +define Device/cambiumnetworks_xe3-4 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Cambium Networks + DEVICE_MODEL := XE3-4 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp01-c3-xv3-4 + SOC := ipq6010 + DEVICE_PACKAGES := ipq-wifi-cambiumnetworks_xe34 ath11k-firmware-qcn9074 kmod-ath11k-pci +endef +TARGET_DEVICES += cambiumnetworks_xe3-4 + +define Device/glinet_gl-common + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := GL.iNet + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp03-c1 + SOC := ipq6000 + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | append-gl-metadata +endef + +define Device/glinet_gl-ax1800 + $(call Device/glinet_gl-common) + DEVICE_MODEL := GL-AX1800 + DEVICE_PACKAGES := ipq-wifi-glinet_gl-ax1800 + SUPPORTED_DEVICES += glinet,ax1800 +endef +TARGET_DEVICES += glinet_gl-ax1800 + +define Device/glinet_gl-axt1800 + $(call Device/glinet_gl-common) + DEVICE_MODEL := GL-AXT1800 + DEVICE_PACKAGES := ipq-wifi-glinet_gl-axt1800 kmod-hwmon-pwmfan + SUPPORTED_DEVICES += glinet,axt1800 +endef +TARGET_DEVICES += glinet_gl-axt1800 + +define Device/jdcloud_re-cs-02 + $(call Device/FitImage) + DEVICE_VENDOR := JDCloud + DEVICE_MODEL := RE-CS-02 + SOC := ipq6010 + BLOCKSIZE := 64k + KERNEL_SIZE := 6144k + DEVICE_DTS_CONFIG := config@cp03-c3 + DEVICE_PACKAGES := ath11k-firmware-qcn9074 ipq-wifi-jdcloud_re-cs-02 kmod-ath11k-pci +endef +TARGET_DEVICES += jdcloud_re-cs-02 + +define Device/jdcloud_re-cs-07 + $(call Device/FitImage) + DEVICE_VENDOR := JDCloud + DEVICE_MODEL := RE-CS-07 + SOC := ipq6010 + BLOCKSIZE := 64k + KERNEL_SIZE := 6144k + DEVICE_DTS_CONFIG := config@cp03-c4 + DEVICE_PACKAGES := -ath11k-firmware-ipq6018 -kmod-ath11k-ahb -wpad-basic-mbedtls +endef +TARGET_DEVICES += jdcloud_re-cs-07 + +define Device/jdcloud_re-ss-01 + $(call Device/FitImage) + DEVICE_VENDOR := JDCloud + DEVICE_MODEL := RE-SS-01 + SOC := ipq6000 + BLOCKSIZE := 64k + KERNEL_SIZE := 6144k + DEVICE_DTS_CONFIG := config@cp03-c2 + DEVICE_PACKAGES := ipq-wifi-jdcloud_re-ss-01 +endef +TARGET_DEVICES += jdcloud_re-ss-01 + +define Device/linksys_mr + $(call Device/FitImage) + DEVICE_VENDOR := Linksys + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 8192k + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | linksys-image type=$$$$(DEVICE_MODEL) + DEVICE_PACKAGE := kmod-usb-ledtrig-usbport +endef + +define Device/linksys_mr7350 + $(call Device/linksys_mr) + DEVICE_MODEL := MR7350 + NAND_SIZE := 256m + IMAGE_SIZE := 75776k + SOC := ipq6000 + DEVICE_PACKAGES += ipq-wifi-linksys_mr7350 kmod-leds-pca963x +endef +TARGET_DEVICES += linksys_mr7350 + +define Device/linksys_mr7500 + $(call Device/linksys_mr) + DEVICE_MODEL := MR7500 + SOC := ipq6018 + NAND_SIZE := 512m + IMAGE_SIZE := 147456k + DEVICE_PACKAGES += ipq-wifi-linksys_mr7500 \ + ath11k-firmware-qcn9074 kmod-ath11k-pci \ + kmod-leds-pwm kmod-phy-aquantia +endef +TARGET_DEVICES += linksys_mr7500 + +define Device/netgear_rbx350 + $(call Device/FitImage) + $(call Device/UbiFit) + SOC := ipq6018 + DEVICE_VENDOR := Netgear + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_PACKAGES := ipq-wifi-netgear_rbk350 + FLASH_SCRIPT := netgear_rbx350.bootscript + IMAGES += factory.img + IMAGE/factory.img := append-ubi | netgear-rbx350-qsdk-ipq-factory +endef + +define Device/netgear_rbr350 + $(call Device/netgear_rbx350) + DEVICE_MODEL := RBR350 +endef +TARGET_DEVICES += netgear_rbr350 + +define Device/netgear_rbs350 + $(call Device/netgear_rbx350) + DEVICE_MODEL := RBS350 +endef +TARGET_DEVICES += netgear_rbs350 + +define Device/netgear_wax214 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Netgear + DEVICE_MODEL := WAX214 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp03-c1 + SOC := ipq6010 + DEVICE_PACKAGES := ipq-wifi-netgear_wax214 +endef +TARGET_DEVICES += netgear_wax214 + +define Device/netgear_wax610-common + $(call Device/FitImage) + DEVICE_VENDOR := Netgear + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp03-c1 + SOC := ipq6010 + KERNEL_IN_UBI := 1 + IMAGES += ui-factory.tar + IMAGE/ui-factory.tar := append-ubi | qsdk-ipq-factory-nand | pad-to 4096 | wax610-netgear-tar +endef + +define Device/netgear_wax610 + $(Device/netgear_wax610-common) + DEVICE_MODEL := WAX610 + DEVICE_PACKAGES := ipq-wifi-netgear_wax610 +endef +TARGET_DEVICES += netgear_wax610 + +define Device/netgear_wax610y + $(Device/netgear_wax610-common) + DEVICE_MODEL := WAX610Y + DEVICE_PACKAGES := ipq-wifi-netgear_wax610y +endef +TARGET_DEVICES += netgear_wax610y + +define Device/qihoo_360v6 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Qihoo + DEVICE_MODEL := 360V6 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq6000 + DEVICE_DTS_CONFIG := config@cp03-c1 + DEVICE_PACKAGES := ipq-wifi-qihoo_360v6 +endef +TARGET_DEVICES += qihoo_360v6 + +define Device/tplink_eap610-outdoor + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := EAP610-Outdoor + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq6018 + DEVICE_PACKAGES := ipq-wifi-tplink_eap610-outdoor + IMAGES += web-ui-factory.bin + IMAGE/web-ui-factory.bin := append-ubi | tplink-image-2022 + TPLINK_SUPPORT_STRING := SupportList:\r\n \ + EAP610-Outdoor(TP-Link|UN|AX1800-D):1.0\r\n \ + EAP610-Outdoor(TP-Link|JP|AX1800-D):1.0\r\n \ + EAP610-Outdoor(TP-Link|CA|AX1800-D):1.0 +endef +TARGET_DEVICES += tplink_eap610-outdoor + +define Device/tplink_eap623od-hd-v1 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := EAP623-Outdoor HD + DEVICE_VARIANT := v1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq6018 + DEVICE_PACKAGES := ipq-wifi-tplink_eap623-outdoor-hd-v1 kmod-phy-realtek + IMAGES += web-ui-factory.bin + IMAGE/web-ui-factory.bin := append-ubi | tplink-image-2022 + TPLINK_SUPPORT_STRING := SupportList:\r\nEAP623-Outdoor HD(TP-Link|UN|AX1800-D):1.0\r\n +endef +TARGET_DEVICES += tplink_eap623od-hd-v1 + +define Device/tplink_eap625-outdoor-hd-v1 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := EAP625-Outdoor HD v1 and v1.6 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq6018 + DEVICE_PACKAGES := ipq-wifi-tplink_eap625-outdoor-hd-v1 + IMAGES += web-ui-factory.bin + IMAGE/web-ui-factory.bin := append-ubi | tplink-image-2022 + TPLINK_SUPPORT_STRING := SupportList:\r\n \ + EAP625-Outdoor HD(TP-Link|UN|AX1800-D):1.0\r\n \ + EAP625-Outdoor HD(TP-Link|CA|AX1800-D):1.0\r\n \ + EAP625-Outdoor HD(TP-Link|AU|AX1800-D):1.0\r\n \ + EAP625-Outdoor HD(TP-Link|KR|AX1800-D):1.0 + +endef +TARGET_DEVICES += tplink_eap625-outdoor-hd-v1 + +define Device/tplink_eap620-hd-v3 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := EAP620 HD v3 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq6018 + DEVICE_PACKAGES := ipq-wifi-tplink_eap620-hd-v3 + IMAGES += web-ui-factory.bin + IMAGE/web-ui-factory.bin := append-ubi | tplink-image-2022 + TPLINK_SUPPORT_STRING := SupportList:\r\n \ + EAP620 HD(TP-Link|UN|AX1800-D):3.0\r\n \ + EAP620 HD(TP-Link|CA|AX1800-D):3.0\r\n \ + EAP620 HD(TP-Link|JP|AX1800-D):3.0\r\n \ + EAP620 HD(TP-Link|EG|AX1800-D):3.0\r\n + +endef +TARGET_DEVICES += tplink_eap620-hd-v3 + +define Device/yuncore_fap650 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Yuncore + DEVICE_MODEL := FAP650 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@cp03-c1 + SOC := ipq6018 + DEVICE_PACKAGES := ipq-wifi-yuncore_fap650 + IMAGES := factory.ubi factory.ubin sysupgrade.bin + IMAGE/factory.ubin := append-ubi | qsdk-ipq-factory-nand +endef +TARGET_DEVICES += yuncore_fap650 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq807x.mk b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq807x.mk new file mode 100755 index 0000000..747123f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/ipq807x.mk @@ -0,0 +1,637 @@ +DTS_DIR := $(DTS_DIR)/qcom +DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID TPLINK_SUPPORT_STRING ZYXEL_MODEL_ID + +define Build/asus-fake-ramdisk + rm -rf $(KDIR)/tmp/fakerd + dd if=/dev/zero bs=32 count=1 > $(KDIR)/tmp/fakerd + $(info KERNEL_INITRAMFS is $(KERNEL_INITRAMFS)) +endef + +define Build/asus-fake-rootfs + $(eval comp=$(word 1,$(1))) + $(eval filepath=$(word 2,$(1))) + $(eval filecont=$(word 3,$(1))) + rm -rf $(KDIR)/tmp/fakefs $(KDIR)/tmp/fakehsqs + mkdir -p $(KDIR)/tmp/fakefs/$$(dirname $(filepath)) + echo '$(filecont)' > $(KDIR)/tmp/fakefs/$(filepath) + $(STAGING_DIR_HOST)/bin/mksquashfs4 $(KDIR)/tmp/fakefs $(KDIR)/tmp/fakehsqs -comp $(comp) \ + -b 4096 -no-exports -no-sparse -no-xattrs -all-root -noappend \ + $(wordlist 4,$(words $(1)),$(1)) +endef + +define Build/asus-trx + $(STAGING_DIR_HOST)/bin/asusuimage $(wordlist 1,$(words $(1)),$(1)) -i $@ -o $@.new + mv $@.new $@ +endef + +define Build/netgear-rbx750-qsdk-ipq-factory + $(CP) $(FLASH_SCRIPT) $(KDIR_TMP)/ + + echo "VERSION : V8.0.0.0_$(LINUX_VERSION)" > $@.metadata + echo "MODEL_ID : $(DEVICE_MODEL)" >> $@.metadata + + $(TOPDIR)/scripts/mkits-qsdk-ipq-image.sh $@.its $(FLASH_SCRIPT) txt $@.metadata ubi $@ + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new + @mv $@.new $@ +endef + +define Build/wax6xx-netgear-tar + mkdir $@.tmp + mv $@ $@.tmp/nand-ipq807x-apps.img + md5sum $@.tmp/nand-ipq807x-apps.img | cut -c 1-32 > $@.tmp/nand-ipq807x-apps.md5sum + echo $(DEVICE_MODEL) > $@.tmp/metadata.txt + echo $(DEVICE_MODEL)"_V99.9.9.9" > $@.tmp/version + tar -C $@.tmp/ -cf $@ . + rm -rf $@.tmp +endef + +define Build/zyxel-nwax10ax-fit + $(TOPDIR)/scripts/mkits-zyxel-fit-filogic.sh \ + $@.its $@ "$(ZYXEL_MODEL_ID) ff ff ff ff ff ff ff ff" + PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new + @mv $@.new $@ +endef + +define Device/aliyun_ap8220 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Aliyun + DEVICE_MODEL := AP8220 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@ac02 + SOC := ipq8071 + DEVICE_PACKAGES := ipq-wifi-aliyun_ap8220 +endef +TARGET_DEVICES += aliyun_ap8220 + +define Device/arcadyan_aw1000 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Arcadyan + DEVICE_MODEL := AW1000 + BLOCKSIZE := 256k + PAGESIZE := 4096 + DEVICE_DTS_CONFIG := config@hk09 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-arcadyan_aw1000 kmod-spi-gpio \ + kmod-gpio-nxp-74hc164 kmod-usb-serial-option uqmi +endef +TARGET_DEVICES += arcadyan_aw1000 + +define Device/asus_rt-ax89x + DEVICE_VENDOR := Asus + DEVICE_MODEL := RT-AX89X + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk01 + SOC := ipq8074 + DEVICE_PACKAGES := kmod-hwmon-gpiofan ipq-wifi-asus_rt-ax89x + KERNEL_NAME := vmlinux + KERNEL := kernel-bin | libdeflate-gzip + KERNEL_IN_UBI := 1 + IMAGE/sysupgrade.bin/squashfs := \ + append-kernel | asus-fake-ramdisk |\ + multiImage gzip $$(KDIR)/tmp/fakerd $$(KDIR)/image-$$(DEVICE_DTS).dtb |\ + sysupgrade-tar kernel=$$$$@ | append-metadata +ifeq ($(IB),) +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + ARTIFACTS := initramfs-factory.trx initramfs-uImage.itb + ARTIFACT/initramfs-uImage.itb := \ + append-image-stage initramfs-kernel.bin | fit gzip $$(KDIR)/image-$$(DEVICE_DTS).dtb + ARTIFACT/initramfs-factory.trx := \ + append-image-stage initramfs-kernel.bin |\ + asus-fake-rootfs xz /lib/firmware/IPQ8074A/fw_version.txt "fake" -no-compression |\ + multiImage gzip $$(KDIR)/tmp/fakehsqs $$(KDIR)/image-$$(DEVICE_DTS).dtb |\ + asus-trx -v 2 -n RT-AX89U -b 388 -e 49000 +endif +endif +endef +TARGET_DEVICES += asus_rt-ax89x + +define Device/buffalo_wxr-5950ax12 + $(call Device/FitImage) + DEVICE_VENDOR := Buffalo + DEVICE_MODEL := WXR-5950AX12 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk01 + SOC := ipq8074 + DEVICE_PACKAGES := ipq-wifi-buffalo_wxr-5950ax12 +endef +TARGET_DEVICES += buffalo_wxr-5950ax12 + +define Device/cmcc_rm2-6 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := CMCC + DEVICE_MODEL := RM2-6 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@ac02 + SOC := ipq8070 + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand + DEVICE_PACKAGES := ipq-wifi-cmcc_rm2-6 kmod-hwmon-gpiofan +endef +TARGET_DEVICES += cmcc_rm2-6 + +define Device/compex_wpq873 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Compex + DEVICE_MODEL := WPQ873 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk09.wpq873 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-compex_wpq873 + IMAGE/factory.ubi := append-ubi | qsdk-ipq-factory-nand +endef +TARGET_DEVICES += compex_wpq873 + +define Device/dynalink_dl-wrx36 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Dynalink + DEVICE_MODEL := DL-WRX36 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@rt5010w-d350-rev0 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-dynalink_dl-wrx36 +endef +TARGET_DEVICES += dynalink_dl-wrx36 + +define Device/edgecore_eap102 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Edgecore + DEVICE_MODEL := EAP102 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@ac02 + SOC := ipq8071 + DEVICE_PACKAGES := ipq-wifi-edgecore_eap102 + IMAGE/factory.ubi := append-ubi | qsdk-ipq-factory-nand +endef +TARGET_DEVICES += edgecore_eap102 + +define Device/edimax_cax1800 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Edimax + DEVICE_MODEL := CAX1800 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@ac03 + SOC := ipq8070 + DEVICE_PACKAGES := ipq-wifi-edimax_cax1800 +endef +TARGET_DEVICES += edimax_cax1800 + +define Device/linksys_homewrk + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Linksys + DEVICE_MODEL := HomeWRK + DEVICE_DTS_CONFIG := config@oak03 + BLOCKSIZE := 256k + PAGESIZE := 4096 + IMAGE_SIZE := 475m + NAND_SIZE := 1024m + SOC := ipq8174 + DEVICE_PACKAGES += kmod-leds-pca963x ipq-wifi-linksys_homewrk +endef +TARGET_DEVICES += linksys_homewrk + +define Device/linksys_mx + $(call Device/FitImage) + DEVICE_VENDOR := Linksys + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 6144k + IMAGE_SIZE := 147456k + NAND_SIZE := 512m + SOC := ipq8072 + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | linksys-image type=$$$$(DEVICE_MODEL) + DEVICE_PACKAGES := kmod-leds-pca963x +endef + +define Device/linksys_mx4x00 + $(call Device/linksys_mx) + SOC := ipq8174 + DEVICE_PACKAGES += ipq-wifi-linksys_mx4200 +endef + +define Device/linksys_mx4200v1 + $(call Device/linksys_mx4x00) + DEVICE_MODEL := MX4200 + DEVICE_VARIANT := v1 + DEVICE_PACKAGES += kmod-hci-uart +endef +TARGET_DEVICES += linksys_mx4200v1 + +define Device/linksys_mx4200v2 + $(call Device/linksys_mx4200v1) + DEVICE_VARIANT := v2 +endef +TARGET_DEVICES += linksys_mx4200v2 + +define Device/linksys_mx4300 + $(call Device/linksys_mx4x00) + DEVICE_MODEL := MX4300 + BLOCKSIZE := 256k + PAGESIZE := 4096 + KERNEL_SIZE := 8192k + IMAGE_SIZE := 171264k + NAND_SIZE := 1024m +endef +TARGET_DEVICES += linksys_mx4300 + +define Device/linksys_mx5300 + $(call Device/linksys_mx) + DEVICE_MODEL := MX5300 + DEVICE_PACKAGES += kmod-rtc-ds1307 ipq-wifi-linksys_mx5300 \ + kmod-ath10k-ct ath10k-firmware-qca9984-ct +endef +TARGET_DEVICES += linksys_mx5300 + +define Device/linksys_mx8500 + $(call Device/linksys_mx) + DEVICE_MODEL := MX8500 + DEVICE_PACKAGES += ipq-wifi-linksys_mx8500 kmod-ath11k-pci \ + ath11k-firmware-qcn9074 kmod-hci-uart +endef +TARGET_DEVICES += linksys_mx8500 + +define Device/netgear_rax120v2 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Netgear + DEVICE_MODEL := RAX120v2 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk01 + SOC := ipq8074 + KERNEL_SIZE := 29696k + NETGEAR_BOARD_ID := RAX120 + NETGEAR_HW_ID := 29765589+0+512+1024+4x4+8x8 + DEVICE_PACKAGES := ipq-wifi-netgear_rax120v2 kmod-spi-gpio \ + kmod-spi-bitbang kmod-gpio-nxp-74hc164 kmod-hwmon-g762 +ifeq ($(IB),) +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + IMAGES += web-ui-factory.img + IMAGE/web-ui-factory.img := append-image initramfs-uImage.itb | \ + pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | \ + netgear-dni +endif +endif + IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ + append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \ + append-metadata +endef +TARGET_DEVICES += netgear_rax120v2 + +define Device/netgear_rbx750 + $(call Device/FitImage) + $(call Device/UbiFit) + SOC := ipq8074 + DEVICE_VENDOR := Netgear + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_PACKAGES := ipq-wifi-netgear_rbk750 kmod-leds-lp5562 + DEVICE_DTS_CONFIG := config@oak03 + FLASH_SCRIPT := netgear_rbx750.bootscript + IMAGES += factory.chk + IMAGE/factory.chk := append-ubi | netgear-rbx750-qsdk-ipq-factory | \ + netgear-chk +endef + +define Device/netgear_rbr750 + $(call Device/netgear_rbx750) + DEVICE_MODEL := RBR750 + NETGEAR_BOARD_ID := U12H415T00_NETGEAR +endef +TARGET_DEVICES += netgear_rbr750 + +define Device/netgear_rbs750 + $(call Device/netgear_rbx750) + DEVICE_MODEL := RBS750 + NETGEAR_BOARD_ID := U12H416T00_NETGEAR +endef +TARGET_DEVICES += netgear_rbs750 + +define Device/netgear_sxk80 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_PACKAGES += ipq-wifi-netgear_sxk80 + DEVICE_VENDOR := Netgear + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk01 + SOC := ipq8074 + KERNEL_SIZE := 6272k + NETGEAR_HW_ID := 29766265+0+512+1024+4x4+4x4+4x4 +endef + +define Device/netgear_sxr80 + $(call Device/netgear_sxk80) + DEVICE_MODEL := SXR80 + NETGEAR_BOARD_ID := SXR80 +endef +TARGET_DEVICES += netgear_sxr80 + +define Device/netgear_sxs80 + $(call Device/netgear_sxk80) + DEVICE_MODEL := SXS80 + NETGEAR_BOARD_ID := SXS80 +endef +TARGET_DEVICES += netgear_sxs80 + +define Device/netgear_wax218 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Netgear + DEVICE_MODEL := WAX218 + DEVICE_DTS_CONFIG := config@hk07 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq8072 +ifeq ($(IB),) +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + ARTIFACTS := web-ui-factory.fit + ARTIFACT/web-ui-factory.fit := append-image initramfs-uImage.itb | \ + ubinize-kernel | qsdk-ipq-factory-nand +endif +endif + DEVICE_PACKAGES := kmod-spi-gpio kmod-spi-bitbang kmod-gpio-nxp-74hc164 \ + ipq-wifi-netgear_wax218 +endef +TARGET_DEVICES += netgear_wax218 + +define Device/netgear_wax620 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Netgear + DEVICE_MODEL := WAX620 + DEVICE_DTS_CONFIG := config@hk07 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq8072 + IMAGES += ui-factory.tar + IMAGE/ui-factory.tar := append-ubi | qsdk-ipq-factory-nand | pad-to 4096 | wax6xx-netgear-tar + DEVICE_PACKAGES := kmod-spi-gpio kmod-gpio-nxp-74hc164 \ + ipq-wifi-netgear_wax620 +endef +TARGET_DEVICES += netgear_wax620 + +define Device/netgear_wax630 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Netgear + DEVICE_MODEL := WAX630 + DEVICE_DTS_CONFIG := config@hk01 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq8074 + IMAGES += ui-factory.tar + IMAGE/ui-factory.tar := append-ubi | qsdk-ipq-factory-nand | pad-to 4096 | wax6xx-netgear-tar + DEVICE_PACKAGES := kmod-spi-gpio ipq-wifi-netgear_wax630 +endef +TARGET_DEVICES += netgear_wax630 + +define Device/prpl_haze + $(call Device/FitImage) + $(call Device/EmmcImage) + DEVICE_VENDOR := prpl Foundation + DEVICE_MODEL := Haze + DEVICE_DTS_CONFIG := config@hk09 + SOC := ipq8072 + DEVICE_PACKAGES := ath11k-firmware-qcn9074 ipq-wifi-prpl_haze kmod-ath11k-pci \ + kmod-fs-f2fs f2fs-tools kmod-leds-lp5562 +endef +TARGET_DEVICES += prpl_haze + +define Device/qnap_301w + $(call Device/FitImage) + $(call Device/EmmcImage) + DEVICE_VENDOR := QNAP + DEVICE_MODEL := 301w + DEVICE_DTS_CONFIG := config@hk01 + KERNEL_SIZE := 16384k + SOC := ipq8072 + DEVICE_PACKAGES := kmod-fs-f2fs f2fs-tools ipq-wifi-qnap_301w +endef +TARGET_DEVICES += qnap_301w + +define Device/redmi_ax6 + $(call Device/xiaomi_ax3600) + DEVICE_VENDOR := Redmi + DEVICE_MODEL := AX6 + DEVICE_PACKAGES := ipq-wifi-redmi_ax6 +endef +TARGET_DEVICES += redmi_ax6 + +define Device/spectrum_sax1v1k + $(call Device/FitImage) + $(call Device/EmmcImage) + DEVICE_VENDOR := Spectrum + DEVICE_MODEL := SAX1V1K + DEVICE_DTS_CONFIG := config@rt5010w-d187-rev6 + SOC := ipq8072 + IMAGES := sysupgrade.bin + DEVICE_PACKAGES := kmod-fs-f2fs f2fs-tools ipq-wifi-spectrum_sax1v1k +endef +TARGET_DEVICES += spectrum_sax1v1k + +define Device/tcl_linkhub-hh500v + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TCL + DEVICE_MODEL := LINKHUB HH500V + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk09 + SOC := ipq8072 + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand + DEVICE_PACKAGES := ipq-wifi-tcl_linkhub-hh500v kmod-mhi-pci-generic \ + kmod-mhi-wwan-ctrl kmod-mhi-wwan-mbim +endef +TARGET_DEVICES += tcl_linkhub-hh500v + +define Device/tplink_deco-x80-5g + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := Deco X80-5G + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk01.c5 + SOC := ipq8074 + DEVICE_PACKAGES := kmod-hwmon-gpiofan ipq-wifi-tplink_deco-x80-5g \ + kmod-usb-serial-option kmod-usb-net-qmi-wwan +endef +TARGET_DEVICES += tplink_deco-x80-5g + +define Device/tplink_eap620hd-v1 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := EAP620 HD + DEVICE_VARIANT := v1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-tplink_eap620hd-v1 + IMAGES += web-ui-factory.bin + IMAGE/web-ui-factory.bin := append-ubi | tplink-image-2022 + TPLINK_SUPPORT_STRING := SupportList:\r\nEAP620 HD(TP-Link|UN|AX1800-D):1.0\r\n +endef +TARGET_DEVICES += tplink_eap620hd-v1 + +define Device/tplink_eap660hd-v1 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := TP-Link + DEVICE_MODEL := EAP660 HD + DEVICE_VARIANT := v1 + BLOCKSIZE := 128k + PAGESIZE := 2048 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-tplink_eap660hd-v1 + IMAGES += web-ui-factory.bin + IMAGE/web-ui-factory.bin := append-ubi | tplink-image-2022 + TPLINK_SUPPORT_STRING := SupportList:\r\nEAP660 HD(TP-Link|UN|AX3600-D):1.0\r\n +endef +TARGET_DEVICES += tplink_eap660hd-v1 + +define Device/xiaomi_ax3600 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Xiaomi + DEVICE_MODEL := AX3600 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@ac04 + SOC := ipq8071 + KERNEL_SIZE := 36608k + DEVICE_PACKAGES := ipq-wifi-xiaomi_ax3600 kmod-ath10k-ct-smallbuffers ath10k-firmware-qca9887-ct +ifeq ($(IB),) +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + ARTIFACTS := initramfs-factory.ubi + ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-uImage.itb | ubinize-kernel +endif +endif +endef +TARGET_DEVICES += xiaomi_ax3600 + +define Device/xiaomi_ax9000 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Xiaomi + DEVICE_MODEL := AX9000 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk14 + SOC := ipq8072 + KERNEL_SIZE := 57344k + DEVICE_PACKAGES := ipq-wifi-xiaomi_ax9000 kmod-ath11k-pci ath11k-firmware-qcn9074 \ + kmod-ath10k-ct ath10k-firmware-qca9887-ct +ifeq ($(IB),) +ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + ARTIFACTS := initramfs-factory.ubi + ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-uImage.itb | ubinize-kernel +endif +endif +endef +TARGET_DEVICES += xiaomi_ax9000 + +define Device/yuncore_ax880 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Yuncore + DEVICE_MODEL := AX880 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk09 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-yuncore_ax880 + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand +endef +TARGET_DEVICES += yuncore_ax880 + +define Device/zbtlink_zbt-z800ax + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Zbtlink + DEVICE_MODEL := ZBT-Z800AX + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@hk09 + SOC := ipq8072 + DEVICE_PACKAGES := ipq-wifi-zbtlink_zbt-z800ax + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand +endef +TARGET_DEVICES += zbtlink_zbt-z800ax + +define Device/zte_mf269 + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := ZTE + DEVICE_MODEL := MF269 + BLOCKSIZE := 128k + PAGESIZE := 2048 + DEVICE_DTS_CONFIG := config@ac04 + SOC := ipq8071 + KERNEL_SIZE := 53248k + DEVICE_PACKAGES := ipq-wifi-zte_mf269 +endef +TARGET_DEVICES += zte_mf269 + +define Device/zyxel_nbg7815 + $(call Device/FitImage) + $(call Device/EmmcImage) + DEVICE_VENDOR := ZYXEL + DEVICE_MODEL := NBG7815 + DEVICE_DTS_CONFIG := config@nbg7815 + SOC := ipq8074 + DEVICE_PACKAGES := kmod-fs-f2fs f2fs-tools ipq-wifi-zyxel_nbg7815 kmod-ath11k-pci \ + kmod-hci-uart kmod-hwmon-tmp103 +endef +TARGET_DEVICES += zyxel_nbg7815 + +define Device/zyxel_nwax10ax_common + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Zyxel + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 61440k + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) | zyxel-nwax10ax-fit +endef + +define Device/zyxel_nwa110ax + $(call Device/zyxel_nwax10ax_common) + DEVICE_MODEL := NWA110AX + DEVICE_DTS_CONFIG := config@ac01 + SOC := ipq8070 + DEVICE_PACKAGES := ipq-wifi-zyxel_nwa110ax zyxel-bootconfig-ipq807x kmod-leds-lp5562 + ZYXEL_MODEL_ID := 59 e1 +endef +TARGET_DEVICES += zyxel_nwa110ax + +define Device/zyxel_nwa210ax + $(call Device/zyxel_nwax10ax_common) + DEVICE_MODEL := NWA210AX + DEVICE_DTS_CONFIG := config@ac02 + SOC := ipq8071 + DEVICE_PACKAGES := ipq-wifi-zyxel_nwa210ax zyxel-bootconfig-ipq807x kmod-leds-lp5562 + ZYXEL_MODEL_ID := 5c e1 +endef +TARGET_DEVICES += zyxel_nwa210ax diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/netgear_rbx350.bootscript b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/netgear_rbx350.bootscript new file mode 100755 index 0000000..9eda83d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/netgear_rbx350.bootscript @@ -0,0 +1,7 @@ +imxtract $imgaddr ubi +switch_rootfs 0 +smeminfo +nand erase.part fs +nand write $fileaddr fs $filesize +setenv bootcmd "ubi part fs && ubi read 0x44000000 kernel && bootm" +saveenv diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/netgear_rbx750.bootscript b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/netgear_rbx750.bootscript new file mode 100755 index 0000000..9c89c88 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/image/netgear_rbx750.bootscript @@ -0,0 +1,10 @@ +imxtract $imgaddr ubi +nand device 0 +setenv firmware_partition 0 +setenv mtdids nand0=nand0 +setenv mtdparts mtdparts=nand0:0x6d00000@0x11c00000(fs) # RBR750 +mtdparts || setenv mtdparts mtdparts=nand0:0x4280000@0x3e80000(fs) # RBS750 +nand erase.part fs +nand write $fileaddr fs $filesize +setenv bootcmd "ubi part fs && ubi read 0x44000000 kernel && bootm" +saveenv diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds new file mode 100755 index 0000000..874e96d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds @@ -0,0 +1,41 @@ +# +# Copyright (C) 2015 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh + +board_config_update + +board=$(board_name) + +case "$board" in +cmcc,pz-l8|\ +elecom,wrc-x3000gs2|\ +iodata,wn-dax3000gr) + ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" "tx rx link_10 link_100 link_1000" + ;; +linksys,mr5500) + ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "qca8k-0.0:00:green:lan" "lan1" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan1-port-activity" "LAN1-PORT-ACTIVITY" "qca8k-0.0:00:amber:lan" "lan1" "tx rx" + ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "qca8k-0.0:01:green:lan" "lan2" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-activity" "LAN2-PORT-ACTIVITY" "qca8k-0.0:01:amber:lan" "lan2" "tx rx" + ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "qca8k-0.0:02:green:lan" "lan3" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-activity" "LAN3-PORT-ACTIVITY" "qca8k-0.0:02:amber:lan" "lan3" "tx rx" + ucidef_set_led_netdev "lan4-port-link" "LAN4-PORT-LINK" "qca8k-0.0:03:green:lan" "lan4" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan4-port-activity" "LAN4-PORT-ACTIVITY" "qca8k-0.0:03:amber:lan" "lan4" "tx rx" + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "qca8k-0.0:04:green:wan" "wan" "link_10 link_100 link_1000" + ucidef_set_led_netdev "wan-port-activity" "WAN-PORT-ACTIVITY" "qca8k-0.0:04:amber:wan" "wan" "tx rx" + ;; +xiaomi,ax6000) + ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:00:green:lan" "lan1" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:01:green:lan" "lan2" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:02:green:lan" "lan3" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:08:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500" + ucidef_set_led_netdev "wan-port-link-top-blue" "WAN-PORT-LINK-TOP-BLUE" "blue:wan" "wan" "link_1000 link_2500" + ucidef_set_led_netdev "wan-port-link-top-yellow" "WAN-PORT-LINK-TOP-YELLOW" "yellow:wan" "wan" "link_10 link_100" + ;; +esac + +board_config_flush + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network new file mode 100755 index 0000000..16aa187 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network @@ -0,0 +1,40 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +ipq50xx_setup_interfaces() +{ + local board="$1" + case $board in + elecom,wrc-x3000gs2|\ + iodata,wn-dax3000gr|\ + linksys,mr5500|\ + zyxel,scr50axe) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" + ;; + glinet,gl-b3000) + ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" + ;; + cmcc,mr3000d-ci|\ + cmcc,pz-l8|\ + linksys,mx2000|\ + linksys,mx5500|\ + linksys,spnmx56|\ + xiaomi,ax6000) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" + ;; + linksys,mx6200|\ + yuncore,ax830|\ + yuncore,ax850) + ucidef_set_interfaces_lan_wan "lan" "wan" + ;; + esac +} + +board_config_update +board=$(board_name) +ipq50xx_setup_interfaces $board +board_config_flush + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/03_set_oem_name b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/03_set_oem_name new file mode 100755 index 0000000..350ff1b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/03_set_oem_name @@ -0,0 +1,21 @@ +#!/bin/sh + +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +ipq50xx_set_oem_name() +{ + local board="$1" + case $board in + glinet,gl-b3000) + oem_name=${board#*-} + echo "$oem_name" > "$oem_file" + ;; + esac +} + +oem_file=/tmp/sysinfo/oem_name +board=$(board_name) +ipq50xx_set_oem_name $board + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata new file mode 100755 index 0000000..92fd10a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -0,0 +1,149 @@ +#!/bin/sh + +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/functions/caldata.sh + +board=$(board_name) + +case "$FIRMWARE" in +"ath11k/IPQ5018/hw1.0/cal-ahb-c000000.wifi.bin") + case "$board" in + cmcc,mr3000d-ci) + caldata_extract "0:art" 0x1000 0x20000 + wlan_mac=$(mtd_get_mac_binary 0:art 12) + ath11k_patch_mac $wlan_mac 0 + ath11k_set_macflag + ath11k_remove_regdomain + ;; + elecom,wrc-x3000gs2|\ + iodata,wn-dax3000gr|\ + zyxel,scr50axe) + caldata_extract "0:art" 0x1000 0x20000 + wlan_mac=$(mtd_get_mac_ascii 0:appsblenv wifi0) + ath11k_patch_mac $wlan_mac 0 + ath11k_set_macflag + ;; + glinet,gl-b3000) + caldata_extract "0:art" 0x1000 0x20000 + ath11k_patch_mac $(macaddr_add $(get_mac_label_dt) 3) 0 + ath11k_set_macflag + ;; + linksys,mr5500|\ + linksys,mx2000|\ + linksys,mx5500|\ + linksys,spnmx56) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + linksys,mx6200) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + xiaomi,ax6000) + caldata_extract "0:art" 0x1000 0x20000 + ;; + yuncore,ax830|\ + yuncore,ax850) + caldata_extract "0:ART" 0x1000 0x20000 + label_mac=$(mtd_get_mac_binary 0:ART 0) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + esac + ;; +"ath11k/QCN6122/hw1.0/cal-ahb-b00a040.wifi.bin") + case "$board" in + cmcc,mr3000d-ci) + caldata_extract "0:art" 0x26800 0x20000 + wlan_mac=$(mtd_get_mac_binary 0:art 18) + ath11k_patch_mac $wlan_mac 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + elecom,wrc-x3000gs2|\ + iodata,wn-dax3000gr|\ + zyxel,scr50axe) + caldata_extract "0:art" 0x26800 0x20000 + wlan_mac=$(mtd_get_mac_ascii 0:appsblenv wifi1) + ath11k_patch_mac $wlan_mac 0 + ath11k_set_macflag + ;; + glinet,gl-b3000) + caldata_extract "0:art" 0x26800 0x20000 + ath11k_patch_mac $(macaddr_add $(get_mac_label_dt) 4) 0 + ath11k_set_macflag + ;; + linksys,mx2000) + caldata_extract "0:art" 0x26800 0x20000 + label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + linksys,mx6200) + caldata_extract "0:art" 0x26800 0x20000 + label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + yuncore,ax830) + caldata_extract "0:ART" 0x4c000 0x20000 + label_mac=$(mtd_get_mac_binary 0:ART 0) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + esac + ;; +"ath11k/QCN6122/hw1.0/cal-ahb-b00b040.wifi.bin") + case "$board" in + linksys,mx6200) + caldata_extract "0:art" 0x4c000 0x20000 + label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $label_mac 4) 0 + ath11k_remove_regdomain + ;; + zyxel,scr50axe) + caldata_extract "0:art" 0x4C000 0x20000 + wlan_mac=$(mtd_get_mac_ascii 0:appsblenv wifi2) + ath11k_patch_mac $wlan_mac 0 + ath11k_set_macflag + ;; + esac + ;; +"ath11k/QCN9074/hw1.0/cal-pci-0000:01:00.0.bin") + case "$board" in + linksys,mr5500|\ + linksys,mx5500|\ + linksys,spnmx56) + caldata_extract "0:art" 0x26800 0x20000 + label_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + xiaomi,ax6000) + caldata_extract "0:art" 0x26800 0x20000 + ;; + yuncore,ax850) + caldata_extract "0:ART" 0x26800 0x20000 + label_mac=$(mtd_get_mac_binary 0:ART 0) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + esac + ;; +*) + exit 1 + ;; +esac diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate new file mode 100755 index 0000000..d3460db --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate @@ -0,0 +1,67 @@ +#!/bin/sh + +# This must run before 10-wifi-detect + +[ "${ACTION}" = "add" ] || return + +. /lib/functions.sh + +check_radio() +{ + local cfg="$1" to="$2" + + config_get path "$cfg" path + + [ "$path" = "$to" ] && PATH_EXISTS=true +} + +do_migrate_radio() +{ + local cfg="$1" from="$2" to="$3" + + config_get path "$cfg" path + + [ "$path" = "$from" ] || return + + uci set "wireless.${cfg}.path=${to}" + WIRELESS_CHANGED=true + + logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'" +} + +migrate_radio() +{ + local from="$1" to="$2" + + config_load wireless + + # Check if there is already a section with the target path: In this case, the system + # was already upgraded to a version without this migration script before; better bail out, + # as we can't be sure we don't break more than we fix. + PATH_EXISTS=false + config_foreach check_radio wifi-device "$to" + $PATH_EXISTS && return + + config_foreach do_migrate_radio wifi-device "$from" "$to" +} + +WIRELESS_CHANGED=false + +case "$(board_name)" in +elecom,wrc-x3000gs2|\ +glinet,gl-b3000|\ +iodata,wn-dax3000gr|\ +linksys,mx2000|\ +yuncore,ax830) + migrate_radio 'platform/soc@0/b00a040.wifi1' 'platform/soc@0/b00a040.wifi' + ;; +linksys,mr5500|\ +linksys,mx5500|\ +linksys,spnmx56) + migrate_radio 'soc@0/a0000000.pcie/pci0001:00/0001:00:00.0/0001:01:00.0' 'soc@0/a0000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0' + ;; +esac + +$WIRELESS_CHANGED && uci commit wireless + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount new file mode 100755 index 0000000..efde13d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/etc/init.d/bootcount @@ -0,0 +1,15 @@ +#!/bin/sh /etc/rc.common + +START=99 + +boot() { + case $(board_name) in + linksys,mr5500|\ + linksys,mx2000|\ + linksys,mx5500|\ + linksys,mx6200|\ + linksys,spnmx56) + mtd resetbc s_env || true + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/functions/bootconfig.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/functions/bootconfig.sh new file mode 100755 index 0000000..3632c6a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/functions/bootconfig.sh @@ -0,0 +1,177 @@ +. /lib/functions.sh + +PART_SIZE=20 +NAME_SIZE=16 +MAX_NUM_PARTS=16 + +MAGIC_START_HEX="a0 a1 a2 a3" +MAGIC_START_TRY_HEX="a1 a1 a2 a3" +MAGIC_END_HEX="b0 b1 b2 b3" + +validate_bootconfig_magic() { + local file=$1 + magic_start=$(hexdump -v -n 4 -e '4/1 "%02x "' "$file") + magic_end=$(hexdump -v -s 332 -n 4 -e '4/1 "%02x "' "$file") + + if [ "$magic_start" != "$MAGIC_START_HEX" ] && \ + [ "$magic_start" != "$MAGIC_START_TRY_HEX" ]; then + echo "Not a valid bootconfig file, start magic does not match" >&2 + return 1 + fi + + if [ "$magic_end" != "$MAGIC_END_HEX" ]; then + echo "Not a valid bootconfig file, end magic does not match" >&2 + return 1 + fi + return 0 +} + +get_bootconfig_numparts() { + local file=$1 + numpartshex=$(hexdump -v -s 8 -n 4 -e '4/1 "%02x "' "$file") + numparts=$(( 0x$(echo $numpartshex | awk '{print $4$3$2$1}') )) + echo ${numparts} +} + +get_bootconfig_partidx() { + local file=$1 + local partname=$2 + local numparts=$(get_bootconfig_numparts "$file") + + if [ -z "$numparts" ]; then + echo "Could not get number of partitions" >&2 + return + fi + + if [ $numparts -gt $MAX_NUM_PARTS ]; then + numparts=$MAX_NUM_PARTS + fi + + for i in $(seq 0 $((numparts -1))); do + nameoffset=$((12 + i * $PART_SIZE)) + nameraw=$(dd if="$file" bs=1 skip="$nameoffset" count=12 2>/dev/null) + name=${nameraw//S'\x00'/} + if [ "$partname" = "$name" ]; then + echo $i + fi + done +} + +get_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + + local partidx=$(get_bootconfig_partidx "$file" "$partname") + if ! echo "$partidx" | grep -Eq '^[0-9]+$'; then + echo "Could not get partition index for $partname in $file" >&2 + return + fi + + if [ "$partidx" -ge 0 ] && [ "$partidx" -lt $MAX_NUM_PARTS ]; then + offset=$((12 + $partidx * $PART_SIZE + $NAME_SIZE)) + primaryboothex=$(hexdump -v -s "$offset" -n 4 -e '4/1 "%02x "' $file) + primaryboot=$(( 0x$(echo $primaryboothex | awk '{print $4$3$2$1}') )) + echo $primaryboot + fi +} + +_set_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot=$3 + local primaryboothex + local partidx + local primarybootoffset + + partidx=$(get_bootconfig_partidx "$file" "$partname") + if ! echo "$partidx" | grep -Eq '^[0-9]+$'; then + echo "Could not get partition index for $2" >&2 + return 1 + fi + primarybootoffset=$((12 + $partidx * $PART_SIZE + $NAME_SIZE)) + + case "$primaryboot" in + 0) + printf "\x00\x00\x00\x00" | dd of="$file" seek="$primarybootoffset" bs=1 count=4 conv=notrunc 2>/dev/null + ;; + 1) + printf "\x01\x00\x00\x00" | dd of="$file" seek="$primarybootoffset" bs=1 count=4 conv=notrunc 2>/dev/null + ;; + *) + echo "invalid argument: primaryboot must be 0 or 1" >&2 + return 1 + ;; + esac +} + +set_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot=$3 + + [ -z "$file" ] || [ -z "$partname" ] || [ -z "$primaryboot" ] && { + echo "usage: $0 <0|1>" + return 1 + } + + [ ! -e "$file" ] && { + echo "file $file not found" >&2 + return 1 + } + + [ ! -w $file ] && { + echo "file $file not writable" >&2 + return 1 + } + + validate_bootconfig_magic "$file" + [ $? -ne 0 ] && return 1 + + _set_bootconfig_primaryboot $file $partname $primaryboot + [ $? -ne 0 ] && return 1 + + return 0 +} + +toggle_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot + + [ -z "$file" ] || [ -z "$partname" ] && { + echo "usage: $0 " + return 1 + } + + [ ! -e "$file" ] && { + echo "file $file not found" >&2 + return 1 + } + + [ ! -w $file ] && { + echo "file $file not writable" >&2 + return 1 + } + + validate_bootconfig_magic "$file" + [ $? -ne 0 ] && return 1 + + primaryboot=$(get_bootconfig_primaryboot "$1" "$2") + + case "$primaryboot" in + 0) + _set_bootconfig_primaryboot "$1" "$2" 1 + ;; + 1) + _set_bootconfig_primaryboot "$1" "$2" 0 + ;; + *) + echo "invalid value: primaryboot must be 0 or 1" >&2 + return 1 + ;; + esac + + [ $? -ne 0 ] && return 1 + + return 0 +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh new file mode 100755 index 0000000..14f8992 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh @@ -0,0 +1,119 @@ +. /lib/functions.sh + +bootconfig_find_entry() { + local cfgbin="$1" + local partname="$2" + local i part parts offset + + parts=$(hexdump -n 4 -s 8 -e '1/4 "%d"' "$cfgbin") + # partition count: <= 10 + [ -z "$parts" ] || [ "$parts" = "0" ] || [ "$parts" -gt "10" ] && \ + return 1 + + for i in $(seq 1 $parts); do + offset=$((0xc + 0x14 * (i - 1))) + part=$(dd if="$cfgbin" iflag=skip_bytes \ + skip=$offset bs=16 count=1 2>/dev/null) + if [ "$part" = "$partname" ]; then + printf "0x%08x" $offset + return + fi + done + + return 1 +} + +# Read or update an entry in Qualcomm bootconfig partition +# +# parameters: +# $1: partition name of bootconfig (ex.: "0:bootconfig", "0:bootconfig1", etc) +# $2: entry name in bootconfig (ex.: "0:hlos", "rootfs", etc) +# $3: index to set for the entry (0/1) +# +# operations: +# read : bootconfig_rw_index +# write: bootconfig_rw_index +bootconfig_rw_index() { + local bootcfg="$1" + local partname="$2" + local index="$3" + local mtddev + local offset + local current + + if [ -z "$bootcfg" ] || [ -z "$partname" ]; then + echo "no value specified for bootconfig or partition entry" + return 1 + fi + + case "$index" in + 0|1|"") ;; + *) echo "invalid bootconfig index specified \"$index\""; return 1 ;; + esac + + mtddev="$(find_mtd_part $bootcfg)" + [ -z "$mtddev" ] && \ + return 1 + + dd if=$mtddev of=/tmp/${mtddev##*/} bs=1k + + offset=$(bootconfig_find_entry "/tmp/${mtddev##*/}" $partname) || return 1 + current=$(hexdump -n 4 -s $((offset + 0x10)) -e '1/4 "%d"' /tmp/${mtddev##*/}) + + [ -z "$index" ] && \ + echo "$current" && return 0 + + if [ "$current" != "$index" ]; then + printf "\x$index" | \ + dd of=$mtddev conv=notrunc bs=1 seek=$((offset + 0x10)) + fi +} + +# Qcom U-Boot always sets a name of current active partition to "rootfs" and +# inactive partition is named as "rootfs_1", in the smem partition table. +# When the second partition is active, "rootfs" and "rootfs_1" are swapped. +smempart_next_root() { + local index="$1" + local root_idx="$(find_mtd_index rootfs)" + local root1_idx="$(find_mtd_index rootfs_1)" + local root_offset root1_offset + + [ -z "$root_idx" ] || [ -z "$root1_idx" ] && \ + return 1 + + root_offset=$(cat /sys/block/mtdblock$root_idx/device/offset) + root1_offset=$(cat /sys/block/mtdblock$root1_idx/device/offset) + + case "$index" in + 0) + [ "$root_offset" -lt "$root1_offset" ] && \ + echo "rootfs" || \ + echo "rootfs_1" + ;; + 1) + [ "$root_offset" -lt "$root1_offset" ] && \ + echo "rootfs_1" || \ + echo "rootfs" + ;; + *) + echo "invalid index specified..." + return 1 + ;; + esac +} + +elecom_upgrade_prepare() { + local index + + if ! index=$(bootconfig_rw_index "0:bootconfig" rootfs); then + v "failed to read bootconfig index..." + nand_do_upgrade_failed + fi + + if ! CI_UBIPART=$(smempart_next_root $index); then + v "failed to get next root..." + nand_do_upgrade_failed + fi + + v "next rootfs: $index (current: $CI_UBIPART)" +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/glinet-upgrade.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/glinet-upgrade.sh new file mode 100755 index 0000000..931202e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/glinet-upgrade.sh @@ -0,0 +1,53 @@ +. /lib/upgrade/common.sh + +glinet_do_fit_upgrade() { + echo -n "fit: Extract [ FIT IMAGE ] -x-x-> [ ubi.bin ] ... " + local ubi=/tmp/ubi.bin + local part=$(dumpimage -l "$1" | grep -o "Image [0-9] (ubi)" | cut -f2 -d" ") + + local ubibin=$( dumpimage -T flat_dt -p ${part} -o "$ubi" "$1" ) + if [ -s "$ubi" ]; then + echo "[ OK ]" + local ubiMd5=$(md5sum "$ubi" | cut -f1 -d" ") + echo -n "fit-copy: [ ubi.bin ] -c-c-> [ firmware.bin ] ... " + mv "$ubi" "$1" + echo "[ OK ]" + local firmMd5=$(md5sum "$1" | cut -f1 -d" ") + echo -n "fit-copy: MD5 CHECK: " + if [ "$ubiMd5" = "$firmMd5" ]; then + echo "[ OK ]" + echo "$ubiMd5 <=> $firmMd5" + echo "fit: Successfully Extracted UBI from FIT IMAGE" + echo "fit: Proceeding with sysupgrade .." + nand_do_upgrade "$1" + return + fi + echo "[ FAILED ] !!" + echo "ERROR: Failed to Copy UBI into firmware.bin !!" + echo "fit: Terminating sysupgrade .." + exit 1 + fi + echo "[ FAILED ] !!" + echo "ERROR: Failed to Extract UBI from FIT IMAGE !!" + echo "fit: Terminating sysupgrade .." + exit 1 +} + +glinet_do_upgrade() { + CI_UBIPART="rootfs" + echo -n "Validating GL.iNet Image ... " + case "$(identify_magic_long $(get_magic_long "$1"))" in + fit) + echo "[ OK ]" + echo "fit-main: Firmware is Valid: fit" + echo "fit-main: Upgrading Firmware via [ FIT IMAGE ]" + glinet_do_fit_upgrade "$1" + ;; + *) + echo "[ FAILED ] !!" + echo "main: GL.iNet Image Validation Failed !!" + echo "main: Attempting default sysupgrade" + nand_do_upgrade "$1" + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh new file mode 100755 index 0000000..9be1d82 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh @@ -0,0 +1,245 @@ +. /lib/functions/bootconfig.sh + +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +RAMFS_COPY_BIN='dumpimage fw_printenv fw_setenv head seq' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + +xiaomi_initramfs_prepare() { + # Wipe UBI if running initramfs + [ "$(rootfs_type)" = "tmpfs" ] || return 0 + + local rootfs_mtdnum="$( find_mtd_index rootfs )" + if [ ! "$rootfs_mtdnum" ]; then + echo "unable to find mtd partition rootfs" + return 1 + fi + + local kern_mtdnum="$( find_mtd_index ubi_kernel )" + if [ ! "$kern_mtdnum" ]; then + echo "unable to find mtd partition ubi_kernel" + return 1 + fi + + ubidetach -m "$rootfs_mtdnum" + ubiformat /dev/mtd$rootfs_mtdnum -y + + ubidetach -m "$kern_mtdnum" + ubiformat /dev/mtd$kern_mtdnum -y +} + +remove_oem_ubi_volume() { + local oem_volume_name="$1" + local oem_ubivol + local mtdnum + local ubidev + + mtdnum=$(find_mtd_index "$CI_UBIPART") + if [ ! "$mtdnum" ]; then + return + fi + + ubidev=$(nand_find_ubi "$CI_UBIPART") + if [ ! "$ubidev" ]; then + ubiattach --mtdn="$mtdnum" + ubidev=$(nand_find_ubi "$CI_UBIPART") + fi + + if [ "$ubidev" ]; then + oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name") + [ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name" + fi +} + +linksys_bootconfig_set_primaryboot() { + local partname=$1 + local tempfile + local mtdidx + + mtdidx=$(find_mtd_index "$partname") + [ ! "$mtdidx" ] && { + echo "cannot find mtd index for $partname" + return 1 + } + + # No need to cleanup as files in /tmp will be removed upon reboot + tempfile=/tmp/mtd"$mtdidx".bin + dd if=/dev/mtd"$mtdidx" of="$tempfile" bs=1 count=336 2>/dev/null + [ $? -ne 0 ] || [ ! -f "$tempfile" ]&& { + echo "failed to create a temp copy of /dev/mtd$mtdidx" + return 1 + } + + set_bootconfig_primaryboot "$tempfile" "0:HLOS" $2 + [ $? -ne 0 ] && { + echo "failed to toggle primaryboot on 0:HLOS part" + return 1 + } + + set_bootconfig_primaryboot "$tempfile" "rootfs" $2 + [ $? -ne 0 ] && { + echo "failed to toggle primaryboot for rootfs part" + return 1 + } + + mtd write "$tempfile" /dev/mtd"$mtdidx" 2>/dev/null + [ $? -ne 0 ] && { + echo "failed to write temp copy back to /dev/mtd$mtdidx" + return 1 + } +} + +linksys_bootconfig_pre_upgrade() { + local setenv_script="/tmp/fw_env_upgrade" + + CI_UBIPART="rootfs_1" + boot_part="$(fw_printenv -n boot_part)" + if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then + CI_UBIPART="rootfs" + else + if [ "$boot_part" -eq "1" ]; then + echo "boot_part 2" >> $setenv_script + linksys_bootconfig_set_primaryboot "0:bootconfig" 1 + linksys_bootconfig_set_primaryboot "0:bootconfig1" 1 + else + echo "boot_part 1" >> $setenv_script + linksys_bootconfig_set_primaryboot "0:bootconfig" 0 + linksys_bootconfig_set_primaryboot "0:bootconfig1" 0 + fi + fi + + boot_part_ready="$(fw_printenv -n boot_part_ready)" + if [ "$boot_part_ready" -ne "3" ]; then + echo "boot_part_ready 3" >> $setenv_script + fi + + auto_recovery="$(fw_printenv -n auto_recovery)" + if [ "$auto_recovery" != "yes" ]; then + echo "auto_recovery yes" >> $setenv_script + fi + + if [ -f "$setenv_script" ]; then + fw_setenv -s $setenv_script || { + echo "failed to update U-Boot environment" + return 1 + } + fi +} + +linksys_mx_pre_upgrade() { + local setenv_script="/tmp/fw_env_upgrade" + + CI_UBIPART="rootfs" + boot_part="$(fw_printenv -n boot_part)" + if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then + if [ "$boot_part" -eq "2" ]; then + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + fi + else + if [ "$boot_part" -eq "1" ]; then + echo "boot_part 2" >> $setenv_script + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + else + echo "boot_part 1" >> $setenv_script + fi + fi + + boot_part_ready="$(fw_printenv -n boot_part_ready)" + if [ "$boot_part_ready" -ne "3" ]; then + echo "boot_part_ready 3" >> $setenv_script + fi + + auto_recovery="$(fw_printenv -n auto_recovery)" + if [ "$auto_recovery" != "yes" ]; then + echo "auto_recovery yes" >> $setenv_script + fi + + if [ -f "$setenv_script" ]; then + fw_setenv -s $setenv_script || { + echo "failed to update U-Boot environment" + return 1 + } + fi +} + +platform_check_image() { + return 0; +} + +platform_pre_upgrade() { + case "$(board_name)" in + xiaomi,ax6000) + xiaomi_initramfs_prepare + ;; + esac +} + +platform_do_upgrade() { + case "$(board_name)" in + cmcc,mr3000d-ci|\ + cmcc,pz-l8|\ + elecom,wrc-x3000gs2|\ + iodata,wn-dax3000gr) + local delay + + delay=$(fw_printenv bootdelay) + [ -z "$delay" ] || [ "$delay" -eq "0" ] && \ + fw_setenv bootdelay 3 + + elecom_upgrade_prepare + + remove_oem_ubi_volume bt_fw + remove_oem_ubi_volume ubi_rootfs + remove_oem_ubi_volume wifi_fw + nand_do_upgrade "$1" + ;; + glinet,gl-b3000) + glinet_do_upgrade "$1" + ;; + linksys,mr5500|\ + linksys,mx2000|\ + linksys,mx5500|\ + linksys,spnmx56) + linksys_mx_pre_upgrade "$1" + remove_oem_ubi_volume squashfs + nand_do_upgrade "$1" + ;; + linksys,mx6200) + linksys_bootconfig_pre_upgrade "$1" + remove_oem_ubi_volume ubi_rootfs + nand_do_upgrade "$1" + ;; + xiaomi,ax6000) + # Make sure that UART is enabled + fw_setenv boot_wait on + fw_setenv uart_en 1 + + # Enforce single partition. + fw_setenv flag_boot_rootfs 0 + fw_setenv flag_last_success 0 + fw_setenv flag_boot_success 1 + fw_setenv flag_try_sys1_failed 8 + fw_setenv flag_try_sys2_failed 8 + + # Kernel and rootfs are placed in 2 different UBI + CI_KERN_UBIPART="ubi_kernel" + CI_ROOT_UBIPART="rootfs" + nand_do_upgrade "$1" + ;; + yuncore,ax830|\ + yuncore,ax850|\ + zyxel,scr50axe) + CI_UBIPART="rootfs" + remove_oem_ubi_volume ubi_rootfs + remove_oem_ubi_volume bt_fw + remove_oem_ubi_volume wifi_fw + nand_do_upgrade "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/config-default b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/config-default new file mode 100755 index 0000000..33e5611 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/config-default @@ -0,0 +1,26 @@ +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set +CONFIG_GRO_CELLS=y +CONFIG_IPQ_CMN_PLL=y +CONFIG_IPQ_GCC_5018=y +CONFIG_LEDS_PWM=y +CONFIG_MAXLINEAR_GPHY=y +CONFIG_MTD_SPI_NAND=y +CONFIG_NET_DEVLINK=y +CONFIG_NET_DSA=y +CONFIG_NET_DSA_QCA8K=y +CONFIG_NET_DSA_QCA8K_LEDS_SUPPORT=y +CONFIG_NET_DSA_TAG_QCA=y +CONFIG_PHYLINK=y +CONFIG_PHY_QCOM_M31_USB=y +CONFIG_PHY_QCOM_UNIPHY_PCIE_28LP=y +CONFIG_PINCTRL_IPQ5018=y +CONFIG_PWM=y +CONFIG_PWM_IPQ=y +CONFIG_PWM_SYSFS=y +CONFIG_QCA83XX_PHY=y +CONFIG_QCOM_APM=y +CONFIG_QCOM_Q6V5_MPD=y +CONFIG_QCOM_Q6V5_WCSS_SEC=y +CONFIG_QCOM_TMEL_QMP_MAILBOX=y +CONFIG_SPI_QPIC_SNAND=y diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/target.mk b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/target.mk new file mode 100755 index 0000000..62b05a7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq50xx/target.mk @@ -0,0 +1,6 @@ +SUBTARGET:=ipq50xx +BOARDNAME:=Qualcomm Atheros IPQ50xx + +define Target/Description + Build firmware images for Qualcomm Atheros IPQ50xx based boards. +endef diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/board.d/01_leds b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/board.d/01_leds new file mode 100755 index 0000000..2f39503 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/board.d/01_leds @@ -0,0 +1,47 @@ + +. /lib/functions/leds.sh +. /lib/functions/uci-defaults.sh + +board_config_update + +board=$(board_name) + +case "$board" in +linksys,mr7350) + ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:00:green:lan" "lan1" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan1-port-traffic" "LAN1-PORT-TRAFFIC" "90000.mdio-1:00:orange:lan" "lan1" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:01:green:lan" "lan2" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-traffic" "LAN2-PORT-TRAFFIC" "90000.mdio-1:01:orange:lan" "lan2" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:02:green:lan" "lan3" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-traffic" "LAN3-PORT-TRAFFIC" "90000.mdio-1:02:orange:lan" "lan3" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan4-port-link" "LAN4-PORT-LINK" "90000.mdio-1:03:green:lan" "lan4" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan4-port-traffic" "LAN4-PORT-TRAFFIC" "90000.mdio-1:03:orange:lan" "lan4" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:04:green:wan" "wan" "link_10 link_100 link_1000" + ucidef_set_led_netdev "wan-port-traffic" "WAN-PORT-TRAFFIC" "90000.mdio-1:04:orange:wan" "wan" "tx rx link_10 link_100 link_1000" + ;; +linksys,mr7500) + ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:00:green:lan" "lan1" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan1-port-traffic" "LAN1-PORT-TRAFFIC" "90000.mdio-1:00:orange:lan" "lan1" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:01:green:lan" "lan2" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-traffic" "LAN2-PORT-TRAFFIC" "90000.mdio-1:01:orange:lan" "lan2" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:02:green:lan" "lan3" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-traffic" "LAN3-PORT-TRAFFIC" "90000.mdio-1:02:orange:lan" "lan3" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan4-port-link" "LAN4-PORT-LINK" "90000.mdio-1:03:green:lan" "lan4" "link_10 link_100 link_1000" + ucidef_set_led_netdev "lan4-port-traffic" "LAN4-PORT-TRAFFIC" "90000.mdio-1:03:orange:lan" "lan4" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:08:green:lan" "wan" "link_10 link_100 link_1000 link_2500 link_5000" + ucidef_set_led_netdev "wan-port-traffic" "WAN-PORT-TRAFFIC" "90000.mdio-1:08:orange:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500 link_5000" + ;; +yuncore,fap650) + ucidef_set_led_netdev "wlan5ghz" "WLAN 5GHz LED" "blue:wlan-5ghz" "wlan0" "tx rx" + ucidef_set_led_netdev "wlan2ghz" "WLAN 2.4GHz LED" "green:wlan-2ghz" "wlan1" "tx rx" + ;; +netgear,wax610|\ +netgear,wax610y) + ucidef_set_led_netdev "lan-port-link" "LAN-PORT-LINK" "green:lan-0" "lan" "link_10 link_100 link_1000 link_2500" + ucidef_set_led_netdev "lan-port-traffic" "LAN-PORT-TRAFFIC" "orange:lan-1" "lan" "tx rx link_10 link_100 link_1000 link_2500" + ;; +esac + +board_config_flush + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/board.d/02_network b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/board.d/02_network new file mode 100755 index 0000000..67ac532 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/board.d/02_network @@ -0,0 +1,91 @@ +# +# Copyright (c) 2015 The Linux Foundation. All rights reserved. +# Copyright (c) 2011-2015 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +ipq60xx_setup_interfaces() +{ + local board="$1" + + case "$board" in + 8devices,mango-dvk|\ + glinet,gl-axt1800) + ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" + ;; + alfa-network,ap120c-ax) + ucidef_set_interfaces_lan_wan "lan" "wan" + ;; + cambiumnetworks,xe3-4|\ + netgear,rbs350) + ucidef_set_interface_lan "lan1 lan2" "dhcp" + ;; + glinet,gl-ax1800|\ + jdcloud,re-cs-02|\ + linksys,mr7350|\ + linksys,mr7500|\ + yuncore,fap650) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" + ;; + jdcloud,re-cs-07|\ + jdcloud,re-ss-01|\ + netgear,rbr350|\ + qihoo,360v6) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" + ;; + netgear,wax214) + ucidef_set_interfaces_lan_wan "lan" + ;; + netgear,wax610|\ + netgear,wax610y|\ + tplink,eap610-outdoor|\ + tplink,eap623od-hd-v1|\ + tplink,eap620-hd-v3|\ + tplink,eap625-outdoor-hd-v1) + ucidef_set_interface_lan "lan" "dhcp" + ;; + *) + echo "Unsupported hardware. Network interfaces not initialized" + ;; + esac +} + +ipq60xx_setup_macs() +{ + local board="$1" + local lan_mac="" + local wan_mac="" + local label_mac="" + + case $board in + alfa-network,ap120c-ax) + label_mac=$(mtd_get_mac_binary 0:ART 12) + ;; + qihoo,360v6) + lan_mac=$(mtd_get_mac_ascii factory lanMac) + wan_mac=$(macaddr_add "$lan_mac" 1) + label_mac=$lan_mac + ;; + tplink,eap610-outdoor|\ + tplink,eap620-hd-v3|\ + tplink,eap623od-hd-v1|\ + tplink,eap625-outdoor-hd-v1) + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + lan_mac=$label_mac + ;; + esac + + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac + [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac +} + +board_config_update +board=$(board_name) +ipq60xx_setup_interfaces $board +ipq60xx_setup_macs $board +board_config_flush + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata new file mode 100755 index 0000000..77587ae --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -0,0 +1,113 @@ +#!/bin/sh + +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/functions/caldata.sh + +board=$(board_name) + +case "$FIRMWARE" in +"ath11k/IPQ6018/hw1.0/cal-ahb-c000000.wifi.bin") + case "$board" in + 8devices,mango-dvk) + caldata_extract "0:ART" 0x1000 0x20000 + ;; + alfa-network,ap120c-ax) + caldata_extract "0:ART" 0x1000 0x20000 + label_mac=$(mtd_get_mac_binary 0:ART 12) + ath11k_patch_mac $label_mac 1 + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_set_macflag + ;; + cambiumnetworks,xe3-4) + caldata_extract "0:ART" 0x1000 0x10000 + ;; + glinet,gl-ax1800|\ + glinet,gl-axt1800) + caldata_extract "0:art" 0x1000 0x10000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_patch_mac $(macaddr_add $label_mac 2) 1 + ath11k_set_macflag + ;; + jdcloud,re-cs-02|\ + jdcloud,re-ss-01) + caldata_extract_mmc "0:ART" 0x1000 0x10000 + ;; + linksys,mr7350|\ + linksys,mr7500) + caldata_extract "0:art" 0x1000 0x10000 + addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $addr 2) 0 + ath11k_patch_mac $(macaddr_add $addr 1) 1 + ath11k_set_macflag + ath11k_remove_regdomain + ;; + netgear,rbr350|\ + netgear,rbs350) + caldata_extract "0:art" 0x1000 0x10000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 1) 1 + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_set_macflag + ;; + netgear,wax214) + caldata_extract "0:art" 0x1000 0x10000 + ;; + netgear,wax610|\ + netgear,wax610y) + caldata_extract "0:art" 0x1000 0x10000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac -30) 1 + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_set_macflag + ;; + qihoo,360v6) + caldata_extract "0:art" 0x1000 0x10000 + label_mac=$(mtd_get_mac_ascii factory lanMac) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_patch_mac $(macaddr_add $label_mac 2) 1 + ath11k_set_macflag + ;; + tplink,eap610-outdoor|\ + tplink,eap623od-hd-v1|\ + tplink,eap625-outdoor-hd-v1) + caldata_from_file "/tmp/factory_data/radio" 0 0x10000 + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + ath11k_patch_mac $label_mac 1 + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_set_macflag + ;; + tplink,eap620-hd-v3) + caldata_from_file "/tmp/factory_data/radio" 0 0x20000 + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + ath11k_patch_mac $label_mac 1 + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_set_macflag + ;; + yuncore,fap650) + caldata_extract "0:art" 0x1000 0x20000 + ;; + esac + ;; +"ath11k/QCN9074/hw1.0/cal-pci-0000:01:00.0.bin") + case "$board" in + cambiumnetworks,xe3-4) + caldata_extract "0:ART" 0x26800 0x20000 + ;; + jdcloud,re-cs-02) + caldata_extract_mmc "0:ART" 0x26800 0x20000 + ;; + linksys,mr7500) + caldata_extract "0:art" 0x26800 0x20000 + addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ath11k_patch_mac $(macaddr_add $addr 3) 0 + ath11k_set_macflag + ath11k_remove_regdomain + ;; + esac + ;; +*) + exit 1 + ;; +esac diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/init.d/bootcount b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/init.d/bootcount new file mode 100755 index 0000000..5490e65 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/etc/init.d/bootcount @@ -0,0 +1,19 @@ +#!/bin/sh /etc/rc.common + +START=99 + +boot() { + case $(board_name) in + linksys,mr7350|\ + linksys,mr7500) + mtd resetbc s_env || true + ;; + yuncore,fap650) + fw_setenv owrt_bootcount 0 + ;; + netgear,wax610|\ + netgear,wax610y) + fw_setenv boot_count 0 + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/functions/bootconfig.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/functions/bootconfig.sh new file mode 100755 index 0000000..3632c6a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/functions/bootconfig.sh @@ -0,0 +1,177 @@ +. /lib/functions.sh + +PART_SIZE=20 +NAME_SIZE=16 +MAX_NUM_PARTS=16 + +MAGIC_START_HEX="a0 a1 a2 a3" +MAGIC_START_TRY_HEX="a1 a1 a2 a3" +MAGIC_END_HEX="b0 b1 b2 b3" + +validate_bootconfig_magic() { + local file=$1 + magic_start=$(hexdump -v -n 4 -e '4/1 "%02x "' "$file") + magic_end=$(hexdump -v -s 332 -n 4 -e '4/1 "%02x "' "$file") + + if [ "$magic_start" != "$MAGIC_START_HEX" ] && \ + [ "$magic_start" != "$MAGIC_START_TRY_HEX" ]; then + echo "Not a valid bootconfig file, start magic does not match" >&2 + return 1 + fi + + if [ "$magic_end" != "$MAGIC_END_HEX" ]; then + echo "Not a valid bootconfig file, end magic does not match" >&2 + return 1 + fi + return 0 +} + +get_bootconfig_numparts() { + local file=$1 + numpartshex=$(hexdump -v -s 8 -n 4 -e '4/1 "%02x "' "$file") + numparts=$(( 0x$(echo $numpartshex | awk '{print $4$3$2$1}') )) + echo ${numparts} +} + +get_bootconfig_partidx() { + local file=$1 + local partname=$2 + local numparts=$(get_bootconfig_numparts "$file") + + if [ -z "$numparts" ]; then + echo "Could not get number of partitions" >&2 + return + fi + + if [ $numparts -gt $MAX_NUM_PARTS ]; then + numparts=$MAX_NUM_PARTS + fi + + for i in $(seq 0 $((numparts -1))); do + nameoffset=$((12 + i * $PART_SIZE)) + nameraw=$(dd if="$file" bs=1 skip="$nameoffset" count=12 2>/dev/null) + name=${nameraw//S'\x00'/} + if [ "$partname" = "$name" ]; then + echo $i + fi + done +} + +get_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + + local partidx=$(get_bootconfig_partidx "$file" "$partname") + if ! echo "$partidx" | grep -Eq '^[0-9]+$'; then + echo "Could not get partition index for $partname in $file" >&2 + return + fi + + if [ "$partidx" -ge 0 ] && [ "$partidx" -lt $MAX_NUM_PARTS ]; then + offset=$((12 + $partidx * $PART_SIZE + $NAME_SIZE)) + primaryboothex=$(hexdump -v -s "$offset" -n 4 -e '4/1 "%02x "' $file) + primaryboot=$(( 0x$(echo $primaryboothex | awk '{print $4$3$2$1}') )) + echo $primaryboot + fi +} + +_set_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot=$3 + local primaryboothex + local partidx + local primarybootoffset + + partidx=$(get_bootconfig_partidx "$file" "$partname") + if ! echo "$partidx" | grep -Eq '^[0-9]+$'; then + echo "Could not get partition index for $2" >&2 + return 1 + fi + primarybootoffset=$((12 + $partidx * $PART_SIZE + $NAME_SIZE)) + + case "$primaryboot" in + 0) + printf "\x00\x00\x00\x00" | dd of="$file" seek="$primarybootoffset" bs=1 count=4 conv=notrunc 2>/dev/null + ;; + 1) + printf "\x01\x00\x00\x00" | dd of="$file" seek="$primarybootoffset" bs=1 count=4 conv=notrunc 2>/dev/null + ;; + *) + echo "invalid argument: primaryboot must be 0 or 1" >&2 + return 1 + ;; + esac +} + +set_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot=$3 + + [ -z "$file" ] || [ -z "$partname" ] || [ -z "$primaryboot" ] && { + echo "usage: $0 <0|1>" + return 1 + } + + [ ! -e "$file" ] && { + echo "file $file not found" >&2 + return 1 + } + + [ ! -w $file ] && { + echo "file $file not writable" >&2 + return 1 + } + + validate_bootconfig_magic "$file" + [ $? -ne 0 ] && return 1 + + _set_bootconfig_primaryboot $file $partname $primaryboot + [ $? -ne 0 ] && return 1 + + return 0 +} + +toggle_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot + + [ -z "$file" ] || [ -z "$partname" ] && { + echo "usage: $0 " + return 1 + } + + [ ! -e "$file" ] && { + echo "file $file not found" >&2 + return 1 + } + + [ ! -w $file ] && { + echo "file $file not writable" >&2 + return 1 + } + + validate_bootconfig_magic "$file" + [ $? -ne 0 ] && return 1 + + primaryboot=$(get_bootconfig_primaryboot "$1" "$2") + + case "$primaryboot" in + 0) + _set_bootconfig_primaryboot "$1" "$2" 1 + ;; + 1) + _set_bootconfig_primaryboot "$1" "$2" 0 + ;; + *) + echo "invalid value: primaryboot must be 0 or 1" >&2 + return 1 + ;; + esac + + [ $? -ne 0 ] && return 1 + + return 0 +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/preinit/09_mount_factory_data b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/preinit/09_mount_factory_data new file mode 100755 index 0000000..09ca32f --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/preinit/09_mount_factory_data @@ -0,0 +1,22 @@ +#!/bin/sh + +preinit_mount_factory_data() { + local mtd_path + + . /lib/functions.sh + . /lib/functions/system.sh + + case $(board_name) in + tplink,eap610-outdoor|\ + tplink,eap620-hd-v3|\ + tplink,eap623od-hd-v1|\ + tplink,eap625-outdoor-hd-v1) + mtd_path=$(find_mtd_chardev "factory_data") + ubiattach --dev-path="$mtd_path" --devn=1 + mkdir /tmp/factory_data + mount -o ro,noatime -t ubifs ubi1:ubi_factory_data /tmp/factory_data + ;; + esac +} + +boot_hook_add preinit_main preinit_mount_factory_data diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/alfa.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/alfa.sh new file mode 100755 index 0000000..5d30af8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/alfa.sh @@ -0,0 +1,34 @@ +. /lib/functions.sh + +# Flip active 'rootfs' partition in selected 'bootconfig' mtd partition +# $1 target 'bootconfig' mtd partition name +# $2 'offset' of the active rootfs flag byte +alfa_bootconfig_rootfs_rotate() { + local part="$1" + local offs="$2" + + local mtdnum=$(find_mtd_index "$part") + [ -c "/dev/mtd${mtdnum}" ] || return 1 + + dd if=/dev/mtd${mtdnum} of=/tmp/mtd${mtdnum} bs=1k > /dev/null 2>&1 + + local active="$(dd if=/tmp/mtd${mtdnum} bs=1 skip=${offs} count=1 2>/dev/null)" + active=$(printf "%d\n" "\"$active") + + if [ "$active" = "1" ]; then + printf '\x00' | dd of=/tmp/mtd${mtdnum} \ + conv=notrunc bs=1 seek=${offs} > /dev/null 2>&1 + else + printf '\x01' | dd of=/tmp/mtd${mtdnum} \ + conv=notrunc bs=1 seek=${offs} > /dev/null 2>&1 + fi + + mtd -qq write /tmp/mtd${mtdnum} /dev/mtd${mtdnum} 2>/dev/null + + local mtdnum_sec=$(find_mtd_index "${part}1") + [ -c "/dev/mtd${mtdnum_sec}" ] && \ + mtd -qq write \ + /tmp/mtd${mtdnum} /dev/mtd${mtdnum_sec} 2>/dev/null + + return 0 +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh new file mode 100755 index 0000000..789f88c --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/base-files/lib/upgrade/platform.sh @@ -0,0 +1,228 @@ +. /lib/functions/bootconfig.sh + +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +RAMFS_COPY_BIN='fw_printenv fw_setenv head seq' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + +remove_oem_ubi_volume() { + local oem_volume_name="$1" + local oem_ubivol + local mtdnum + local ubidev + + mtdnum=$(find_mtd_index "$CI_UBIPART") + if [ ! "$mtdnum" ]; then + return + fi + + ubidev=$(nand_find_ubi "$CI_UBIPART") + if [ ! "$ubidev" ]; then + ubiattach --mtdn="$mtdnum" + ubidev=$(nand_find_ubi "$CI_UBIPART") + fi + + if [ "$ubidev" ]; then + oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name") + [ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name" + fi +} + +qihoo_bootconfig_toggle_rootfs() { + local partname=$1 + local tempfile + local mtdidx + + mtdidx=$(find_mtd_index "$partname") + [ ! "$mtdidx" ] && { + echo "cannot find mtd index for $partname" + return 1 + } + + tempfile=/tmp/mtd"$mtdidx".bin + dd if=/dev/mtd"$mtdidx" of="$tempfile" bs=1 count=336 2>/dev/null + [ $? -ne 0 ] || [ ! -f "$tempfile" ] && { + echo "failed to create a temp copy of /dev/mtd$mtdidx" + return 1 + } + + toggle_bootconfig_primaryboot "$tempfile" "rootfs" + [ $? -ne 0 ] && { + echo "failed to toggle primaryboot for rootfs partition" + return 1 + } + + mtd write "$tempfile" /dev/mtd"$mtdidx" 2>/dev/null + [ $? -ne 0 ] && { + echo "failed to write temp copy back to /dev/mtd$mtdidx" + return 1 + } + + # Update bootconfig1 if exists + local mtdidx1=$(find_mtd_index "${partname}1") + [ -n "$mtdidx1" ] && mtd write "$tempfile" /dev/mtd"$mtdidx1" 2>/dev/null + + return 0 +} + +tplink_get_boot_part() { + local cur_boot_part + local args + + # Try to find rootfs from kernel arguments + read -r args < /proc/cmdline + for arg in $args; do + local ubi_mtd_arg=${arg#ubi.mtd=} + case "$ubi_mtd_arg" in + rootfs|rootfs_1) + echo "$ubi_mtd_arg" + return + ;; + esac + done + + # Fallback to u-boot env (e.g. when running initramfs) + cur_boot_part="$(/usr/sbin/fw_printenv -n tp_boot_idx)" + case $cur_boot_part in + 1) + echo rootfs_1 + ;; + 0|*) + echo rootfs + ;; + esac +} + +tplink_do_upgrade() { + local new_boot_part + + case $(tplink_get_boot_part) in + rootfs) + CI_UBIPART="rootfs_1" + new_boot_part=1 + ;; + rootfs_1) + CI_UBIPART="rootfs" + new_boot_part=0 + ;; + esac + + fw_setenv -s - <<-EOF + tp_boot_idx $new_boot_part + EOF + + remove_oem_ubi_volume ubi_rootfs + nand_do_upgrade "$1" +} + +platform_check_image() { + return 0; +} + + +yuncore_fap650_env_setup() { + local ubifile=$(board_name) + local active=$(fw_printenv -n owrt_slotactive) + [ -z "$active" ] && active=$(hexdump -s 0x94 -n 4 -e '4 "%d"' /dev/mtd$(find_mtd_index 0:bootconfig)) + cat > /tmp/env_tmp << EOF +owrt_slotactive=${active} +owrt_bootcount=0 +bootfile=${ubifile}.ubi +owrt_bootcountcheck=if test \$owrt_bootcount > 4; then run owrt_tftprecover; fi; if test \$owrt_bootcount = 3; then run owrt_slotswap; else echo bootcountcheck successfull; fi +owrt_bootinc=if test \$owrt_bootcount < 5; then echo save env part; setexpr owrt_bootcount \${owrt_bootcount} + 1 && saveenv; else echo save env skipped; fi; echo current bootcount: \$owrt_bootcount +bootcmd=run owrt_bootinc && run owrt_bootcountcheck && run owrt_slotselect && run owrt_bootlinux +owrt_bootlinux=echo booting linux... && ubi part fs && ubi read 0x44000000 kernel && bootm; reset +owrt_setslot0=setenv bootargs console=ttyMSM0,115200n8 ubi.mtd=rootfs root=mtd:rootfs rootfstype=squashfs rootwait swiotlb=1 && setenv mtdparts mtdparts=nand0:0x3c00000@0(fs) +owrt_setslot1=setenv bootargs console=ttyMSM0,115200n8 ubi.mtd=rootfs_1 root=mtd:rootfs rootfstype=squashfs rootwait swiotlb=1 && setenv mtdparts mtdparts=nand0:0x3c00000@0x3c00000(fs) +owrt_slotswap=setexpr owrt_slotactive 1 - \${owrt_slotactive} && saveenv && echo slot swapped. new active slot: \$owrt_slotactive +owrt_slotselect=setenv mtdids nand0=nand0,nand1=spi0.0; if test \$owrt_slotactive = 0; then run owrt_setslot0; else run owrt_setslot1; fi +owrt_tftprecover=echo trying to recover firmware with tftp... && sleep 10 && dhcp && flash rootfs && flash rootfs_1 && setenv owrt_bootcount 0 && setenv owrt_slotactive 0 && saveenv && reset +owrt_env_ver=7 +EOF + fw_setenv --script /tmp/env_tmp +} + +platform_do_upgrade() { + case "$(board_name)" in + alfa-network,ap120c-ax) + CI_UBIPART="rootfs_1" + alfa_bootconfig_rootfs_rotate "0:BOOTCONFIG" "148" + nand_do_upgrade "$1" + ;; + cambiumnetworks,xe3-4) + fw_setenv bootcount 0 + nand_do_upgrade "$1" + ;; + glinet,gl-ax1800|\ + glinet,gl-axt1800|\ + netgear,rbr350|\ + netgear,rbs350|\ + netgear,wax214) + nand_do_upgrade "$1" + ;; + qihoo,360v6) + CI_UBIPART="rootfs_1" + qihoo_bootconfig_toggle_rootfs "0:bootconfig" + remove_oem_ubi_volume wifi_fw + remove_oem_ubi_volume ubi_rootfs + nand_do_upgrade "$1" + ;; + jdcloud,re-cs-02|\ + jdcloud,re-cs-07|\ + jdcloud,re-ss-01) + local cfgpart=$(find_mmc_part "0:BOOTCONFIG") + part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 148 -C $cfgpart | cut -f 1 -d "|" | head -n1)" + if [ "$part_num" -eq "1" ]; then + CI_KERNPART="0:HLOS_1" + CI_ROOTPART="rootfs_1" + else + CI_KERNPART="0:HLOS" + CI_ROOTPART="rootfs" + fi + emmc_do_upgrade "$1" + ;; + netgear,wax610|\ + netgear,wax610y) + remove_oem_ubi_volume wifi_fw + remove_oem_ubi_volume ubi_rootfs + nand_do_upgrade "$1" + ;; + linksys,mr7350|\ + linksys,mr7500) + boot_part="$(fw_printenv -n boot_part)" + if [ "$boot_part" -eq "1" ]; then + fw_setenv boot_part 2 + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + else + fw_setenv boot_part 1 + CI_UBIPART="rootfs" + fi + fw_setenv boot_part_ready 3 + fw_setenv auto_recovery yes + nand_do_upgrade "$1" + ;; + tplink,eap610-outdoor|\ + tplink,eap620-hd-v3|\ + tplink,eap623od-hd-v1|\ + tplink,eap625-outdoor-hd-v1) + tplink_do_upgrade "$1" + ;; + yuncore,fap650) + [ "$(fw_printenv -n owrt_env_ver 2>/dev/null)" != "7" ] && yuncore_fap650_env_setup + local active="$(fw_printenv -n owrt_slotactive 2>/dev/null)" + if [ "$active" = "1" ]; then + CI_UBIPART="rootfs" + else + CI_UBIPART="rootfs_1" + fi + fw_setenv owrt_bootcount 0 + fw_setenv owrt_slotactive $((1 - active)) + nand_do_upgrade "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/config-default b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/config-default new file mode 100755 index 0000000..ac9743e --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/config-default @@ -0,0 +1,14 @@ +CONFIG_IPQ_GCC_6018=y +CONFIG_MTD_SPLIT_FIT_FW=y +CONFIG_PINCTRL_IPQ6018=y +CONFIG_PWM=y +CONFIG_PWM_IPQ=y +CONFIG_PWM_SYSFS=y +CONFIG_QCOM_APM=y +# CONFIG_QCOM_CLK_SMD_RPM is not set +# CONFIG_QCOM_RPMPD is not set +CONFIG_QCOM_SMD_RPM=y +CONFIG_REGULATOR_CPR3=y +# CONFIG_REGULATOR_CPR3_NPU is not set +CONFIG_REGULATOR_CPR4_APSS=y +CONFIG_REGULATOR_QCOM_SMD_RPM=y diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/target.mk b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/target.mk new file mode 100755 index 0000000..06a85ab --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq60xx/target.mk @@ -0,0 +1,7 @@ +SUBTARGET:=ipq60xx +BOARDNAME:=Qualcomm Atheros IPQ60xx +DEFAULT_PACKAGES += ath11k-firmware-ipq6018 + +define Target/Description + Build firmware images for Qualcomm Atheros IPQ60xx based boards. +endef diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds new file mode 100755 index 0000000..665b83d --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/board.d/01_leds @@ -0,0 +1,81 @@ + +. /lib/functions/uci-defaults.sh + +board_config_update + +board=$(board_name) + +case "$board" in +arcadyan,aw1000) + ucidef_set_led_netdev "5g" "5G" "green:5g" "wwan0" + ucidef_set_led_netdev "wan" "WAN" "green:internet" "wan" + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:1c:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500" + ;; +asus,rt-ax89x) + ucidef_set_led_netdev "aqr" "AQR" "white:aqr10g" "10g-copper" + ucidef_set_led_netdev "sfp" "SFP" "white:sfp" "10g-sfp" + ucidef_set_led_netdev "wan" "WAN" "white:wan" "wan" + ;; +dynalink,dl-wrx36|\ +spectrum,sax1v1k) + ucidef_set_led_netdev "wan-port-link-green" "WAN-PORT-LINK-GREEN" "90000.mdio-1:1c:green:wan" "wan" "link_2500" + ucidef_set_led_netdev "wan-port-link-yellow" "WAN-PORT-LINK-YELLOW" "90000.mdio-1:1c:yellow:wan" "wan" "tx rx link_10 link_100 link_1000" + ;; +edgecore,eap102) + ucidef_set_led_netdev "wan" "WAN" "green:wanpoe" "wan" + ;; +netgear,rax120v2) + ucidef_set_led_netdev "aqr" "AQR" "white:aqr" "lan5" + ;; +netgear,wax218) + ucidef_set_led_netdev "lan" "LAN" "blue:lan" "lan" + ucidef_set_led_wlan "wlan5g" "WIFI 5GHz" "blue:wlan5g" "phy0radio" + ucidef_set_led_wlan "wlan2g" "WIFI 2.4GHz" "blue:wlan2g" "phy1radio" + ;; +netgear,wax620) + ucidef_set_led_netdev "lan" "LAN" "lan:green" "lan" + ;; +netgear,wax630) + ucidef_set_led_netdev "lan1" "LAN1" "lan1:green" "lan1" + ucidef_set_led_netdev "lan2" "LAN2" "lan2:green" "lan2" + ;; +redmi,ax6) + ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan" + ;; +tcl,linkhub-hh500v) + ucidef_set_led_wlan "wlan5g" "WiFi 5GHz" "blue:wlan" "phy0radio" + ;; +xiaomi,ax3600) + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:01:green:wan" "wan" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:02:green:lan" "lan1" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:03:green:lan" "lan2" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:04:green:lan" "lan3" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan" + ;; +xiaomi,ax9000) + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:18:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500" + ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "90000.mdio-1:03:green:lan" "lan1" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan2-port-link" "LAN2-PORT-LINK" "90000.mdio-1:02:green:lan" "lan2" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan3-port-link" "LAN3-PORT-LINK" "90000.mdio-1:01:green:lan" "lan3" "tx rx link_10 link_100 link_1000" + ucidef_set_led_netdev "lan4-port-link" "LAN4-PORT-LINK" "90000.mdio-1:00:green:lan" "lan4" "tx rx link_10 link_100 link_1000" + ;; +qnap,301w) + ucidef_set_led_netdev "lan1" "LAN1" "green:lan-1" "lan1" + ucidef_set_led_netdev "lan2" "LAN2" "green:lan-2" "lan2" + ucidef_set_led_netdev "lan3" "LAN3" "green:lan-3" "lan3" + ucidef_set_led_netdev "lan4" "LAN4" "green:lan-4" "lan4" + ucidef_set_led_netdev "10G_1" "10G_1" "green:10g-1" "10g-1" + ucidef_set_led_netdev "10G_2" "10G_2" "green:10g-2" "10g-2" + ;; +yuncore,ax880) + ucidef_set_led_netdev "wan-port-link" "WAN-PORT-LINK" "90000.mdio-1:18:green:wan" "wan" "tx rx link_10 link_100 link_1000 link_2500" + ucidef_set_led_netdev "lan-port-link" "LAN-PORT-LINK" "90000.mdio-1:1c:green:lan" "lan" "tx rx link_10 link_100 link_1000 link_2500" + ;; +zbtlink,zbt-z800ax) + ucidef_set_led_netdev "internet" "Internet" "green:wan-online" "wan" + ;; +esac + +board_config_flush + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network new file mode 100755 index 0000000..392afed --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/board.d/02_network @@ -0,0 +1,134 @@ +# +# Copyright (c) 2015 The Linux Foundation. All rights reserved. +# Copyright (c) 2011-2015 OpenWrt.org +# + +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +ipq807x_setup_interfaces() +{ + local board="$1" + + case "$board" in + aliyun,ap8220|\ + edgecore,eap102|\ + tcl,linkhub-hh500v|\ + tplink,deco-x80-5g|\ + yuncore,ax880|\ + zte,mf269) + ucidef_set_interfaces_lan_wan "lan" "wan" + ;; + asus,rt-ax89x) + ucidef_set_interfaces_lan_wan "10g-sfp 10g-copper lan1 lan2 lan3 lan4 lan5 lan6 lan7 lan8" "wan" + ;; + arcadyan,aw1000|\ + buffalo,wxr-5950ax12|\ + dynalink,dl-wrx36|\ + linksys,mx5300|\ + linksys,mx8500|\ + xiaomi,ax9000|\ + zbtlink,zbt-z800ax) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" + ;; + cmcc,rm2-6) + ucidef_set_interfaces_lan_wan "lan plc" "wan" + ;; + compex,wpq873|\ + linksys,homewrk|\ + linksys,mx4200v1|\ + linksys,mx4200v2|\ + linksys,mx4300|\ + netgear,rbr750|\ + prpl,haze|\ + redmi,ax6|\ + spectrum,sax1v1k|\ + xiaomi,ax3600) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" + ;; + edimax,cax1800) + ucidef_set_interfaces_lan_wan "lan" + ;; + netgear,rax120v2) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan5" "wan" + ;; + netgear,sxr80|\ + netgear,sxs80) + ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan" + ;; + netgear,wax218|\ + netgear,wax620) + ucidef_set_interface_lan "lan" "dhcp" + ;; + netgear,rbs750|\ + netgear,wax630) + ucidef_set_interface_lan "lan1 lan2" "dhcp" + ;; + qnap,301w) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g-2" "10g-1" + ;; + tplink,eap620hd-v1|\ + tplink,eap660hd-v1) + ucidef_set_interface_lan "lan" "dhcp" + ;; + zyxel,nbg7815) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g" "wan" + ;; + zyxel,nwa110ax) + ucidef_set_interface_lan "uplink" "dhcp" + ;; + zyxel,nwa210ax) + ucidef_set_interface_lan "uplink lan1" "dhcp" + ;; + *) + echo "Unsupported hardware. Network interfaces not initialized" + ;; + esac +} + +ipq807x_setup_macs() +{ + local board="$1" + local lan_mac="" + local wan_mac="" + local label_mac="" + + case "$board" in + aliyun,ap8220) + wan_mac=$(mtd_get_mac_text product_info 0x4b) + lan_mac=$(macaddr_add "$wan_mac" 1) + label_mac="$wan_mac" + ;; + tcl,linkhub-hh500v) + wan_mac=$(mtd_get_mac_binary "0:ART" 0x5e290) + lan_mac=$(mtd_get_mac_binary "0:ART" 0x5e296) + ;; + tplink,deco-x80-5g) + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + lan_mac=$(macaddr_add $label_mac 1) + wan_mac=$label_mac + ;; + tplink,eap620hd-v1|\ + tplink,eap660hd-v1) + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + lan_mac=$label_mac + ;; + zyxel,nwa110ax|\ + zyxel,nwa210ax) + label_mac=$(get_mac_label_dt) + lan_mac=$label_mac + ;; + esac + + [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac + [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac + [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac +} + +board_config_update +board=$(board_name) +ipq807x_setup_interfaces $board +ipq807x_setup_macs $board +board_config_flush + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata new file mode 100755 index 0000000..a93f1fc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -0,0 +1,178 @@ +#!/bin/sh + +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/functions/caldata.sh + +board=$(board_name) + +case "$FIRMWARE" in +"ath11k/IPQ8074/hw2.0/cal-ahb-c000000.wifi.bin") + case "$board" in + aliyun,ap8220) + caldata_extract "0:art" 0x1000 0x20000 + addr=$(mtd_get_mac_text product_info 0x4b) + ath11k_patch_mac $addr 0 + ath11k_patch_mac $(macaddr_add $addr 8) 1 + ath11k_set_macflag + ;; + asus,rt-ax89x) + CI_UBIPART="UBI_DEV" + caldata_extract_ubi "Factory" 0x1000 0x20000 + ;; + arcadyan,aw1000|\ + buffalo,wxr-5950ax12|\ + cmcc,rm2-6|\ + compex,wpq873|\ + dynalink,dl-wrx36|\ + edgecore,eap102|\ + edimax,cax1800|\ + linksys,mx5300|\ + netgear,wax218|\ + qnap,301w|\ + redmi,ax6|\ + xiaomi,ax3600|\ + xiaomi,ax9000|\ + yuncore,ax880|\ + zte,mf269) + caldata_extract "0:art" 0x1000 0x20000 + ;; + linksys,homewrk|\ + linksys,mx4200v1|\ + linksys,mx8500) + caldata_extract "0:art" 0x1000 0x20000 + ath11k_remove_regdomain + ;; + linksys,mx4200v2) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_patch_mac $(macaddr_add $label_mac 1) 1 + ath11k_patch_mac $(macaddr_add $label_mac 3) 2 + ath11k_remove_regdomain + ath11k_set_macflag + ;; + linksys,mx4300) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_patch_mac $(macaddr_add $label_mac 1) 1 + ath11k_patch_mac $(macaddr_add $label_mac 3) 2 + ath11k_remove_regdomain + ;; + netgear,rax120v2) + caldata_extract "0:art" 0x1000 0x20000 + ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0xc) 0 + ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x0) 1 + ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x6) 2 + ath11k_set_macflag + ;; + netgear,rbr750|\ + netgear,rbs750) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label_dt) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_patch_mac $(macaddr_add $label_mac 2) 1 + ath11k_patch_mac $(macaddr_add $label_mac 4) 2 + ath11k_set_macflag + ;; + netgear,sxr80|\ + netgear,sxs80) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x0c) 0 + #boarddata1 doesn't have a MAC for the 2G interface + ath11k_patch_mac $(macaddr_setbit_la $label_mac) 1 + ath11k_patch_mac $(mtd_get_mac_binary boarddata1 0x12) 2 + ath11k_set_macflag + ;; + netgear,wax620) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac -31) 1 + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_set_macflag + ;; + netgear,wax630) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac -31) 1 + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_patch_mac $(macaddr_add $label_mac 33) 2 + ath11k_set_macflag + ;; + prpl,haze|\ + spectrum,sax1v1k) + caldata_extract_mmc "0:ART" 0x1000 0x20000 + ;; + tcl,linkhub-hh500v) + caldata_extract "0:ART" 0x1000 0x20000 + ath11k_patch_mac $(mtd_get_mac_binary "0:ART" 0x5e29c) 0 + ath11k_patch_mac $(mtd_get_mac_binary "0:ART" 0x5e2a2) 1 + ath11k_set_macflag + ;; + tplink,deco-x80-5g) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + ath11k_patch_mac $(macaddr_add $label_mac -1) 0 + ath11k_patch_mac $(macaddr_add $label_mac -2) 1 + ath11k_set_macflag + ;; + tplink,eap620hd-v1|\ + tplink,eap660hd-v1) + caldata_from_file "/tmp/factory_data/radio" 0 0x20000 + label_mac=$(get_mac_binary /tmp/factory_data/default-mac 0) + ath11k_patch_mac $label_mac 1 + ath11k_patch_mac $(macaddr_add $label_mac 1) 0 + ath11k_set_macflag + ;; + zbtlink,zbt-z800ax) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac -1) 0 + ath11k_patch_mac $(macaddr_add $label_mac -2) 1 + ath11k_set_macflag + ;; + zyxel,nbg7815) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_patch_mac $(macaddr_add $label_mac 2) 1 + ath11k_patch_mac $(macaddr_add $label_mac 4) 2 + ath11k_set_macflag + ;; + zyxel,nwa110ax) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 2) 0 + ath11k_patch_mac $(macaddr_add $label_mac 1) 1 + ath11k_set_macflag + ;; + zyxel,nwa210ax) + caldata_extract "0:art" 0x1000 0x20000 + label_mac=$(get_mac_label) + ath11k_patch_mac $(macaddr_add $label_mac 3) 0 + ath11k_patch_mac $(macaddr_add $label_mac 2) 1 + ath11k_set_macflag + ;; + esac + ;; +"ath11k/QCN9074/hw1.0/cal-pci-0000:01:00.0.bin"|\ +"ath11k/QCN9074/hw1.0/cal-pci-0001:01:00.0.bin") + case "$board" in + linksys,mx8500) + caldata_extract "0:art" 0x26800 0x20000 + ath11k_remove_regdomain + ;; + prpl,haze) + caldata_extract_mmc "0:ART" 0x26800 0x20000 + ;; + xiaomi,ax9000) + caldata_extract "0:art" 0x26800 0x20000 + ;; + esac + ;; +*) + exit 1 + ;; +esac diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate new file mode 100755 index 0000000..c08e10b --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/05-wifi-migrate @@ -0,0 +1,64 @@ +#!/bin/sh + +# This must run before 10-wifi-detect + +[ "${ACTION}" = "add" ] || return + +. /lib/functions.sh +. /lib/functions/system.sh + +do_migrate_radio() +{ + local cfg="$1" from="$2" to="$3" + + config_get path "$cfg" path + + [ "$path" = "$from" ] || return + + uci set "wireless.${cfg}.path=${to}" + WIRELESS_CHANGED=true + + logger -t wifi-migrate "Updated path of wireless.${cfg} from '${from}' to '${to}'" +} + +check_path() +{ + local config + config="$1" + + config_get path "$config" path + + to=${path/soc\//soc@0\/} + to=${to/pci\//pcie\/} + + # Checks if kernel version is less than 6.6.0, if it is and the path is using the new format, + # then path should be migrated to the old format. This would allow users on platforms with two partitions, + # to test 6.1 and 6.6. + [ "$(get_linux_version)" -lt "606000" ] && to=${to/soc@0\//soc\/} + + [ "$(get_linux_version)" -lt "612000" ] && to=${to/pcie\//pci\/} + + [ "$path" = "$to" ] || do_migrate_radio "$config" "$path" "$to" +} + +migrate_radio() +{ + config_load wireless + + # Check if there is already a section with the target path: In this case, the system + # was already upgraded to a version without this migration script before; better bail out, + # as we can't be sure we don't break more than we fix. + config_foreach check_path wifi-device +} + +WIRELESS_CHANGED=false + +case "$(board_name)" in +*) + migrate_radio + ;; +esac + +$WIRELESS_CHANGED && uci commit wireless + +exit 0 diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac new file mode 100755 index 0000000..80c07b8 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac @@ -0,0 +1,26 @@ +[ "$ACTION" == "add" ] || exit 0 + +PHYNBR=${DEVPATH##*/phy} + +[ -n $PHYNBR ] || exit 0 + +. /lib/functions.sh +. /lib/functions/system.sh + +board=$(board_name) + +case "$board" in + arcadyan,aw1000) + [ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 1 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 2 > /sys${DEVPATH}/macaddress + ;; + buffalo,wxr-5950ax12) + [ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 8 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 16 > /sys${DEVPATH}/macaddress + ;; + cmcc,rm2-6|\ + zte,mf269) + [ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 2 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $(get_mac_label) 3 > /sys${DEVPATH}/macaddress + ;; +esac diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/bootcount b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/bootcount new file mode 100755 index 0000000..e7c2049 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/bootcount @@ -0,0 +1,25 @@ +#!/bin/sh /etc/rc.common + +START=99 + +boot() { + case $(board_name) in + edgecore,eap102|\ + yuncore,ax880) + fw_setenv upgrade_available 0 + # Unset changed flag after sysupgrade complete + fw_setenv changed + ;; + linksys,mx4200v1|\ + linksys,mx4200v2|\ + linksys,mx4300|\ + linksys,mx5300|\ + linksys,mx8500) + mtd resetbc s_env || true + ;; + netgear,wax620|\ + netgear,wax630) + fw_setenv boot_count 0 + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/modem b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/modem new file mode 100755 index 0000000..a23d8c1 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/modem @@ -0,0 +1,22 @@ +#!/bin/sh /etc/rc.common + +START=15 + +boot() { + case $(board_name) in + tcl,linkhub-hh500v) + PCIPATH="/sys/bus/pci/devices/0000:01:00.0" + + for i in $(seq 0 10); do + [ -d "${PCIPATH}" ] && break + echo 1 > /sys/bus/pci/rescan + sleep 2 + done + + if [ ! -d "${PCIPATH}" ]; then + echo "No modem PCIe device found" + exit 1 + fi + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/smp_affinity b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/smp_affinity new file mode 100755 index 0000000..ecf88ae --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/init.d/smp_affinity @@ -0,0 +1,122 @@ +#!/bin/sh /etc/rc.common +###################################################################### +# vim: set ft=bash +# shellcheck disable=2155,3019,3043,3057,3060 +###################################################################### + +START=93 + +PROG=smp_affinity + +log_msg() { + + local irq_name="$1" affinity="$2" irq="$3" + + msg="$(printf "Pinning IRQ($irq) %-24s to CPU ${affinity}\n" "$irq_name")" + + logger -t "$PROG" "$msg" +} + +###################################################################### +### Takes a comma, space separated, or range list of CPU numbers and +## returns a bitmask of CPUs. +## cpus_to_bitmask "0,1,2,3" -> f +## cpus_to_bitmask "0 1 2 3" -> f +## cpus_to_bitmask "0-3" -> f +## cpus_to_bitmask "3" -> 8 +####################################################################### + +cpus_to_bitmask() { + + local bitmask=0 + # shellcheck disable=2048 + for range in ${*//,/ }; do + start="${range%-*}" + end="${range#*-}" + if [ -z "$end" ]; then + bitmask="$((bitmask | 1 << start))" + else + bitmask="$((bitmask | (2 ** (end - start + 1) - 1) << start))" + fi + done + printf '%x' $bitmask +} + +###################################################################### +### Takes a bitmask of CPUs and returns a space separated list of +## CPU numbers. +## bitmask_to_cpus f -> 0 1 2 3 +###################################################################### + +bitmask_to_cpus() { + + [ "${1:0:2}" != "0x" ] && set -- "0x$1" + local bitmask="$(printf '%d' "$1")" + + local cpus="" + for i in $(seq 0 63); do + if [ $((bitmask & 1)) -ne 0 ]; then + cpus="$cpus $i" + fi + bitmask=$((bitmask >> 1)) + done + echo "${cpus# }" +} + +###################################################################### +### Sets the affinity of the IRQs with the given name to the given CPU. +## 1st argument: IRQ name ("reo2host-destination-ring1") (req) +## 2nd argument: CPU number (req) +###################################################################### + +set_affinity() { + + local irq_name="$1" affinity="$2" bitmask irq + awk -v irq_name="$1" '$0 ~ irq_name { print substr($1, 1, length($1)-1); exit }' /proc/interrupts \ + | while read -r irq; do + $enable_log && { + log_msg "$irq_name" "$affinity" "$irq" + } + bitmask=$(cpus_to_bitmask "$affinity") && echo "$bitmask" > "/proc/irq/$irq/smp_affinity" + done +} + +enable_affinity_ipq807x() { + + # assign 4 rx interrupts to each core + set_affinity 'reo2host-destination-ring1' 0 + set_affinity 'reo2host-destination-ring2' 1 + set_affinity 'reo2host-destination-ring3' 2 + set_affinity 'reo2host-destination-ring4' 3 + + # assign 3 tcl completions to last 3 CPUs + set_affinity 'wbm2host-tx-completions-ring1' 1 + set_affinity 'wbm2host-tx-completions-ring2' 2 + set_affinity 'wbm2host-tx-completions-ring3' 3 + + # assign 3 ppdu mac interrupts to last 3 cores + set_affinity 'ppdu-end-interrupts-mac1' 1 + set_affinity 'ppdu-end-interrupts-mac2' 2 + set_affinity 'ppdu-end-interrupts-mac3' 3 + + # assign 4 lan/wan to core 4 + set_affinity 'edma_txcmpl' 3 + set_affinity 'edma_rxfill' 3 + set_affinity 'edma_rxdesc' 3 + set_affinity 'edma_misc' 3 +} + +boot() { + + local enable + + config_load smp_affinity + + config_get_bool enable "general" enable 1 + config_get_bool enable_log "general" enable_log 1 + + [ "$enable" -eq 1 ] && enable=true || enable=false + [ "$enable_log" -eq 1 ] && enable_log=true || enable_log=false + + $enable && enable_affinity_ipq807x +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/uci-defaults/15_smp_affinity b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/uci-defaults/15_smp_affinity new file mode 100755 index 0000000..3ec0adc --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/etc/uci-defaults/15_smp_affinity @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q get smp_affinity && exit 0 +touch /etc/config/smp_affinity + +uci -q batch << EOF + set smp_affinity.general=smp_affinity + set smp_affinity.general.enable='1' + set smp_affinity.general.enable_log='1' + commit smp_affinity +EOF diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/functions/bootconfig.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/functions/bootconfig.sh new file mode 100755 index 0000000..3632c6a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/functions/bootconfig.sh @@ -0,0 +1,177 @@ +. /lib/functions.sh + +PART_SIZE=20 +NAME_SIZE=16 +MAX_NUM_PARTS=16 + +MAGIC_START_HEX="a0 a1 a2 a3" +MAGIC_START_TRY_HEX="a1 a1 a2 a3" +MAGIC_END_HEX="b0 b1 b2 b3" + +validate_bootconfig_magic() { + local file=$1 + magic_start=$(hexdump -v -n 4 -e '4/1 "%02x "' "$file") + magic_end=$(hexdump -v -s 332 -n 4 -e '4/1 "%02x "' "$file") + + if [ "$magic_start" != "$MAGIC_START_HEX" ] && \ + [ "$magic_start" != "$MAGIC_START_TRY_HEX" ]; then + echo "Not a valid bootconfig file, start magic does not match" >&2 + return 1 + fi + + if [ "$magic_end" != "$MAGIC_END_HEX" ]; then + echo "Not a valid bootconfig file, end magic does not match" >&2 + return 1 + fi + return 0 +} + +get_bootconfig_numparts() { + local file=$1 + numpartshex=$(hexdump -v -s 8 -n 4 -e '4/1 "%02x "' "$file") + numparts=$(( 0x$(echo $numpartshex | awk '{print $4$3$2$1}') )) + echo ${numparts} +} + +get_bootconfig_partidx() { + local file=$1 + local partname=$2 + local numparts=$(get_bootconfig_numparts "$file") + + if [ -z "$numparts" ]; then + echo "Could not get number of partitions" >&2 + return + fi + + if [ $numparts -gt $MAX_NUM_PARTS ]; then + numparts=$MAX_NUM_PARTS + fi + + for i in $(seq 0 $((numparts -1))); do + nameoffset=$((12 + i * $PART_SIZE)) + nameraw=$(dd if="$file" bs=1 skip="$nameoffset" count=12 2>/dev/null) + name=${nameraw//S'\x00'/} + if [ "$partname" = "$name" ]; then + echo $i + fi + done +} + +get_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + + local partidx=$(get_bootconfig_partidx "$file" "$partname") + if ! echo "$partidx" | grep -Eq '^[0-9]+$'; then + echo "Could not get partition index for $partname in $file" >&2 + return + fi + + if [ "$partidx" -ge 0 ] && [ "$partidx" -lt $MAX_NUM_PARTS ]; then + offset=$((12 + $partidx * $PART_SIZE + $NAME_SIZE)) + primaryboothex=$(hexdump -v -s "$offset" -n 4 -e '4/1 "%02x "' $file) + primaryboot=$(( 0x$(echo $primaryboothex | awk '{print $4$3$2$1}') )) + echo $primaryboot + fi +} + +_set_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot=$3 + local primaryboothex + local partidx + local primarybootoffset + + partidx=$(get_bootconfig_partidx "$file" "$partname") + if ! echo "$partidx" | grep -Eq '^[0-9]+$'; then + echo "Could not get partition index for $2" >&2 + return 1 + fi + primarybootoffset=$((12 + $partidx * $PART_SIZE + $NAME_SIZE)) + + case "$primaryboot" in + 0) + printf "\x00\x00\x00\x00" | dd of="$file" seek="$primarybootoffset" bs=1 count=4 conv=notrunc 2>/dev/null + ;; + 1) + printf "\x01\x00\x00\x00" | dd of="$file" seek="$primarybootoffset" bs=1 count=4 conv=notrunc 2>/dev/null + ;; + *) + echo "invalid argument: primaryboot must be 0 or 1" >&2 + return 1 + ;; + esac +} + +set_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot=$3 + + [ -z "$file" ] || [ -z "$partname" ] || [ -z "$primaryboot" ] && { + echo "usage: $0 <0|1>" + return 1 + } + + [ ! -e "$file" ] && { + echo "file $file not found" >&2 + return 1 + } + + [ ! -w $file ] && { + echo "file $file not writable" >&2 + return 1 + } + + validate_bootconfig_magic "$file" + [ $? -ne 0 ] && return 1 + + _set_bootconfig_primaryboot $file $partname $primaryboot + [ $? -ne 0 ] && return 1 + + return 0 +} + +toggle_bootconfig_primaryboot() { + local file=$1 + local partname=$2 + local primaryboot + + [ -z "$file" ] || [ -z "$partname" ] && { + echo "usage: $0 " + return 1 + } + + [ ! -e "$file" ] && { + echo "file $file not found" >&2 + return 1 + } + + [ ! -w $file ] && { + echo "file $file not writable" >&2 + return 1 + } + + validate_bootconfig_magic "$file" + [ $? -ne 0 ] && return 1 + + primaryboot=$(get_bootconfig_primaryboot "$1" "$2") + + case "$primaryboot" in + 0) + _set_bootconfig_primaryboot "$1" "$2" 1 + ;; + 1) + _set_bootconfig_primaryboot "$1" "$2" 0 + ;; + *) + echo "invalid value: primaryboot must be 0 or 1" >&2 + return 1 + ;; + esac + + [ $? -ne 0 ] && return 1 + + return 0 +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/preinit/09_mount_factory_data b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/preinit/09_mount_factory_data new file mode 100755 index 0000000..fb4710a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/preinit/09_mount_factory_data @@ -0,0 +1,32 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/system.sh + +preinit_mount_factory_data() { + local part_name="$1" + local mtd_path + local ubi_num + + mtd_path=$(find_mtd_chardev "$part_name") + ubi_num=$(grep $part_name /proc/mtd | cut -c 1-5 | grep -o '[0-9]*') + ubiattach --dev-path="$mtd_path" --devn=$ubi_num + mkdir /tmp/$part_name + mount -o ro,noatime -t ubifs ubi$ubi_num:ubi_$part_name /tmp/$part_name +} + +preinit_mount_factory_partitions() { + + case $(board_name) in + tplink,deco-x80-5g) + preinit_mount_factory_data "factory_data" + preinit_mount_factory_data "runtime_data" + ;; + tplink,eap620hd-v1|\ + tplink,eap660hd-v1) + preinit_mount_factory_data "factory_data" + ;; + esac +} + +boot_hook_add preinit_main preinit_mount_factory_partitions diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/buffalo.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/buffalo.sh new file mode 100755 index 0000000..d0ed258 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/buffalo.sh @@ -0,0 +1,55 @@ +. /lib/functions.sh + +# Prepare UBI devices for OpenWrt installation +# - rootfs (mtd22) +# - remove "ubi_rootfs" volume (rootfs on stock) +# - remove "fw_hash" volume (firmware hash) +# - user_property (mtd24) +# - remove "user_property_ubi" volume (user configuration) +# - remove "extra_property" volume (gzipped syslog) +buffalo_upgrade_prepare() { + local ubi_rootdev ubi_propdev + + if ! ubi_rootdev="$(nand_attach_ubi rootfs)" || \ + ! ubi_propdev="$(nand_attach_ubi user_property)"; then + echo "failed to attach UBI volume \"rootfs\" or \"user_property\", rebooting..." + reboot -f + fi + + ubirmvol /dev/$ubi_rootdev -N ubi_rootfs &> /dev/null || true + ubirmvol /dev/$ubi_rootdev -N fw_hash &> /dev/null || true + + ubirmvol /dev/$ubi_propdev -N user_property_ubi &> /dev/null || true + ubirmvol /dev/$ubi_propdev -N extra_property &> /dev/null || true +} + +# Re-create small dummy ubi_rootfs volume and update +# fw_hash volume to pass the checking by U-Boot +# - rootfs (mtd22) +# - re-create "ubi_rootfs" volume +# - re-create and update "fw_hash" volume +# - rootfs_recover (mtd23) +# - update "fw_hash" volume +buffalo_upgrade_optvol() { + local ubi_rootdev ubi_rcvrdev + local hashvol_root hashvol_rcvr + + if ! ubi_rootdev="$(nand_attach_ubi rootfs)" || \ + ! ubi_rcvrdev="$(nand_attach_ubi rootfs_recover)"; then + echo "failed to attach UBI volume \"rootfs\" or \"rootfs_recover\", rebooting..." + reboot -f + fi + + ubimkvol /dev/$ubi_rootdev -N ubi_rootfs -S 1 + ubimkvol /dev/$ubi_rootdev -N fw_hash -S 1 -t static + + if ! hashvol_root="$(nand_find_volume $ubi_rootdev fw_hash)" || \ + ! hashvol_rcvr="$(nand_find_volume $ubi_rcvrdev fw_hash)"; then + echo "\"fw_hash\" volume in \"rootfs\" or \"rootfs_recover\" not found, rebooting..." + reboot -f + fi + + echo -n "00000000000000000000000000000000" > /tmp/dummyhash.txt + ubiupdatevol /dev/$hashvol_root /tmp/dummyhash.txt + ubiupdatevol /dev/$hashvol_rcvr /tmp/dummyhash.txt +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh new file mode 100755 index 0000000..9bece63 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh @@ -0,0 +1,335 @@ +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +RAMFS_COPY_BIN='fw_printenv fw_setenv head seq' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + +xiaomi_initramfs_prepare() { + # Wipe UBI if running initramfs + [ "$(rootfs_type)" = "tmpfs" ] || return 0 + + local rootfs_mtdnum="$( find_mtd_index rootfs )" + if [ ! "$rootfs_mtdnum" ]; then + echo "unable to find mtd partition rootfs" + return 1 + fi + + local kern_mtdnum="$( find_mtd_index ubi_kernel )" + if [ ! "$kern_mtdnum" ]; then + echo "unable to find mtd partition ubi_kernel" + return 1 + fi + + ubidetach -m "$rootfs_mtdnum" + ubiformat /dev/mtd$rootfs_mtdnum -y + + ubidetach -m "$kern_mtdnum" + ubiformat /dev/mtd$kern_mtdnum -y +} + +asus_initial_setup() { + # Remove existing linux and jffs2 volumes + [ "$(rootfs_type)" = "tmpfs" ] || return 0 + + ubirmvol /dev/ubi0 -N linux + ubirmvol /dev/ubi0 -N jffs2 +} + +remove_oem_ubi_volume() { + local oem_volume_name="$1" + local oem_ubivol + local mtdnum + local ubidev + + mtdnum=$(find_mtd_index "$CI_UBIPART") + if [ ! "$mtdnum" ]; then + return + fi + + ubidev=$(nand_find_ubi "$CI_UBIPART") + if [ ! "$ubidev" ]; then + ubiattach --mtdn="$mtdnum" + ubidev=$(nand_find_ubi "$CI_UBIPART") + fi + + if [ "$ubidev" ]; then + oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name") + [ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name" + fi +} + +tplink_get_boot_part() { + local cur_boot_part + local args + + # Try to find rootfs from kernel arguments + read -r args < /proc/cmdline + for arg in $args; do + local ubi_mtd_arg=${arg#ubi.mtd=} + case "$ubi_mtd_arg" in + rootfs|rootfs_1) + echo "$ubi_mtd_arg" + return + ;; + esac + done + + # Fallback to u-boot env (e.g. when running initramfs) + cur_boot_part="$(/usr/sbin/fw_printenv -n tp_boot_idx)" + case $cur_boot_part in + 1) + echo rootfs_1 + ;; + 0|*) + echo rootfs + ;; + esac +} + +tplink_do_upgrade() { + local new_boot_part + + case $(tplink_get_boot_part) in + rootfs) + CI_UBIPART="rootfs_1" + new_boot_part=1 + ;; + rootfs_1) + CI_UBIPART="rootfs" + new_boot_part=0 + ;; + esac + + fw_setenv -s - <<-EOF + tp_boot_idx $new_boot_part + EOF + + remove_oem_ubi_volume ubi_rootfs + nand_do_upgrade "$1" +} + +linksys_mx_pre_upgrade() { + local setenv_script="/tmp/fw_env_upgrade" + + CI_UBIPART="rootfs" + boot_part="$(fw_printenv -n boot_part)" + if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then + if [ "$boot_part" -eq "2" ]; then + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + fi + else + if [ "$boot_part" -eq "1" ]; then + echo "boot_part 2" >> $setenv_script + CI_KERNPART="alt_kernel" + CI_UBIPART="alt_rootfs" + else + echo "boot_part 1" >> $setenv_script + fi + fi + + boot_part_ready="$(fw_printenv -n boot_part_ready)" + if [ "$boot_part_ready" -ne "3" ]; then + echo "boot_part_ready 3" >> $setenv_script + fi + + auto_recovery="$(fw_printenv -n auto_recovery)" + if [ "$auto_recovery" != "yes" ]; then + echo "auto_recovery yes" >> $setenv_script + fi + + if [ -f "$setenv_script" ]; then + fw_setenv -s $setenv_script || { + echo "failed to update U-Boot environment" + return 1 + } + fi +} + +platform_check_image() { + return 0; +} + +platform_pre_upgrade() { + case "$(board_name)" in + asus,rt-ax89x) + asus_initial_setup + ;; + redmi,ax6|\ + xiaomi,ax3600|\ + xiaomi,ax9000) + xiaomi_initramfs_prepare + ;; + esac +} + +platform_do_upgrade() { + case "$(board_name)" in + aliyun,ap8220) + active="$(fw_printenv -n active)" + if [ "$active" -eq "1" ]; then + CI_UBIPART="rootfs1" + else + CI_UBIPART="rootfs2" + fi + nand_do_upgrade "$1" + ;; + arcadyan,aw1000|\ + cmcc,rm2-6|\ + compex,wpq873|\ + dynalink,dl-wrx36|\ + edimax,cax1800|\ + netgear,rax120v2|\ + netgear,rbr750|\ + netgear,rbs750|\ + netgear,sxr80|\ + netgear,sxs80|\ + netgear,wax218|\ + netgear,wax620|\ + netgear,wax630|\ + zyxel,nwa110ax|\ + zyxel,nwa210ax) + nand_do_upgrade "$1" + ;; + asus,rt-ax89x) + CI_UBIPART="UBI_DEV" + CI_KERNPART="linux" + CI_ROOTPART="jffs2" + nand_do_upgrade "$1" + ;; + buffalo,wxr-5950ax12) + CI_KERN_UBIPART="rootfs" + CI_ROOT_UBIPART="user_property" + buffalo_upgrade_prepare + nand_do_flash_file "$1" || nand_do_upgrade_failed + nand_do_restore_config || nand_do_upgrade_failed + buffalo_upgrade_optvol + ;; + edgecore,eap102) + active="$(fw_printenv -n active)" + if [ "$active" -eq "1" ]; then + CI_UBIPART="rootfs2" + else + CI_UBIPART="rootfs1" + fi + # force altbootcmd which handles partition change in u-boot + fw_setenv bootcount 3 + fw_setenv upgrade_available 1 + nand_do_upgrade "$1" + ;; + linksys,homewrk) + CI_UBIPART="rootfs" + remove_oem_ubi_volume ubi_rootfs + nand_do_upgrade "$1" + ;; + linksys,mx4200v1|\ + linksys,mx4200v2|\ + linksys,mx4300) + linksys_mx_pre_upgrade "$1" + remove_oem_ubi_volume squashfs + nand_do_upgrade "$1" + ;; + linksys,mx5300|\ + linksys,mx8500) + linksys_mx_pre_upgrade "$1" + remove_oem_ubi_volume ubifs + nand_do_upgrade "$1" + ;; + prpl,haze|\ + qnap,301w) + CI_KERNPART="0:HLOS" + CI_ROOTPART="rootfs" + emmc_do_upgrade "$1" + ;; + redmi,ax6|\ + xiaomi,ax3600|\ + xiaomi,ax9000) + # Make sure that UART is enabled + fw_setenv boot_wait on + fw_setenv uart_en 1 + + # Enforce single partition. + fw_setenv flag_boot_rootfs 0 + fw_setenv flag_last_success 0 + fw_setenv flag_boot_success 1 + fw_setenv flag_try_sys1_failed 8 + fw_setenv flag_try_sys2_failed 8 + + # Kernel and rootfs are placed in 2 different UBI + CI_KERN_UBIPART="ubi_kernel" + CI_ROOT_UBIPART="rootfs" + nand_do_upgrade "$1" + ;; + spectrum,sax1v1k) + CI_KERNPART="0:HLOS" + CI_ROOTPART="rootfs" + CI_DATAPART="rootfs_data" + emmc_do_upgrade "$1" + ;; + tcl,linkhub-hh500v) + tcl_upgrade_prepare + nand_do_upgrade "$1" + ;; + tplink,deco-x80-5g|\ + tplink,eap620hd-v1|\ + tplink,eap660hd-v1) + tplink_do_upgrade "$1" + ;; + yuncore,ax880) + active="$(fw_printenv -n active)" + if [ "$active" -eq "1" ]; then + CI_UBIPART="rootfs_1" + else + CI_UBIPART="rootfs" + fi + # force altbootcmd which handles partition change in u-boot + fw_setenv bootcount 3 + fw_setenv upgrade_available 1 + nand_do_upgrade "$1" + ;; + zbtlink,zbt-z800ax) + local mtdnum="$(find_mtd_index 0:bootconfig)" + local alt_mtdnum="$(find_mtd_index 0:bootconfig1)" + part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$mtdnum | cut -f 1 -d "|" | head -n1)" + # vendor firmware may swap the rootfs partition location, u-boot append: ubi.mtd=rootfs + # since we use fixed-partitions, need to force boot from the first rootfs partition + if [ "$part_num" -eq "1" ]; then + mtd erase /dev/mtd$mtdnum + mtd erase /dev/mtd$alt_mtdnum + fi + nand_do_upgrade "$1" + ;; + zte,mf269) + CI_KERN_UBIPART="ubi_kernel" + CI_ROOT_UBIPART="rootfs" + nand_do_upgrade "$1" + ;; + zyxel,nbg7815) + local config_mtdnum="$(find_mtd_index 0:bootconfig)" + [ -z "$config_mtdnum" ] && reboot + part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|" | head -n1)" + if [ "$part_num" -eq "0" ]; then + CI_KERNPART="0:HLOS" + CI_ROOTPART="rootfs" + else + CI_KERNPART="0:HLOS_1" + CI_ROOTPART="rootfs_1" + fi + emmc_do_upgrade "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} + +platform_copy_config() { + case "$(board_name)" in + prpl,haze|\ + qnap,301w|\ + spectrum,sax1v1k|\ + zyxel,nbg7815) + emmc_copy_config + ;; + esac +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/tcl.sh b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/tcl.sh new file mode 100755 index 0000000..9442fa7 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/tcl.sh @@ -0,0 +1,92 @@ +# based on target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh + +. /lib/functions.sh +. /lib/functions/bootconfig.sh + +# Read or update an entry in Qualcomm bootconfig partition +# +# parameters: +# $1: partition name of bootconfig (ex.: "0:bootconfig", "0:bootconfig1", etc) +# $2: entry name in bootconfig (ex.: "0:hlos", "rootfs", etc) +# $3: index to set for the entry (0/1) +# +# operations: +# read : bootconfig_rw_index +# write: bootconfig_rw_index +bootconfig_rw_index() { + local bootcfg="$1" + local partname="$2" + local index="$3" + local mtdidx + local tempfile + local current + + if [ -z "$bootcfg" ] || [ -z "$partname" ]; then + echo "no value specified for bootconfig or partition entry" + return 1 + fi + + case "$index" in + 0|1|"") ;; + *) echo "invalid bootconfig index specified \"$index\""; return 1 ;; + esac + + mtdidx=$(find_mtd_index "$bootcfg") + [ ! "$mtdidx" ] && { + echo "cannot find mtd index for $partname" + return 1 + } + + tempfile=/tmp/mtd"$mtdidx".bin + dd if=/dev/mtd"$mtdidx" of="$tempfile" bs=1 count=336 + [ $? -ne 0 ] || [ ! -f "$tempfile" ] && { + echo "failed to create a temp copy of /dev/mtd$mtdidx" + return 1 + } + + current=$(get_bootconfig_primaryboot "$tempfile" "$partname") + + if [ -z "$index" ]; then + echo "$current" + elif [ "$current" != "$index" ]; then + set_bootconfig_primaryboot "$tempfile" "$partname" "$index" + mtd write "$tempfile" /dev/mtd"$mtdidx" 2>/dev/null + [ $? -ne 0 ] && { + echo "failed to write temp copy back to /dev/mtd$mtdidx" + return 1 + } + fi + + rm "$tempfile" +} + +tcl_swap_active_root() { + local index + + index=$(bootconfig_rw_index "0:BOOTCONFIG" rootfs) + if [ -z "$index" ]; then + v "failed to read bootconfig index..." + nand_do_upgrade_failed + fi + + if [ "$index" = "1" ]; then + bootconfig_rw_index "0:BOOTCONFIG" rootfs 0 + bootconfig_rw_index "0:BOOTCONFIG1" rootfs 0 + else + bootconfig_rw_index "0:BOOTCONFIG" rootfs 1 + bootconfig_rw_index "0:BOOTCONFIG1" rootfs 1 + fi +} + +tcl_upgrade_prepare() { + local delay + + delay=$(fw_printenv -n bootdelay) + [ -z "$delay" ] || [ "$delay" -eq "0" ] && \ + fw_setenv bootdelay 3 + + if [ -z "$UPGRADE_OPT_USE_CURR_PART" ]; then + tcl_swap_active_root + CI_UBIPART="rootfs_1" + fi +} diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/config-default b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/config-default new file mode 100755 index 0000000..a55b17a --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/config-default @@ -0,0 +1,37 @@ +CONFIG_ARM_PSCI_CPUIDLE_DOMAIN=y +CONFIG_DT_IDLE_GENPD=y +CONFIG_GRO_CELLS=y +CONFIG_IPQ_GCC_8074=y +CONFIG_MDIO_BITBANG=y +CONFIG_MDIO_GPIO=y +# CONFIG_MFD_HI6421_SPMI is not set +CONFIG_MFD_SPMI_PMIC=y +CONFIG_NET_DEVLINK=y +CONFIG_NET_DSA=y +CONFIG_NET_DSA_QCA8K=y +CONFIG_NET_DSA_TAG_QCA=y +# CONFIG_NVMEM_SPMI_SDAM is not set +CONFIG_PHYLINK=y +CONFIG_PINCTRL_IPQ8074=y +CONFIG_PINCTRL_QCOM_SPMI_PMIC=y +# CONFIG_PM8916_WATCHDOG is not set +CONFIG_PM_GENERIC_DOMAINS=y +CONFIG_PM_GENERIC_DOMAINS_OF=y +# CONFIG_POWER_RESET_QCOM_PON is not set +CONFIG_QCA83XX_PHY=y +CONFIG_QCOM_APM=y +# CONFIG_QCOM_COINCELL is not set +CONFIG_QCOM_GDSC=y +CONFIG_QCOM_SPMI_ADC5=y +# CONFIG_QCOM_SPMI_RRADC is not set +CONFIG_QCOM_VADC_COMMON=y +CONFIG_REGMAP_SPMI=y +CONFIG_REGULATOR_CPR3=y +# CONFIG_REGULATOR_CPR3_NPU is not set +CONFIG_REGULATOR_CPR4_APSS=y +CONFIG_REGULATOR_QCOM_SPMI=y +CONFIG_RTC_DRV_PM8XXX=y +CONFIG_SPMI=y +# CONFIG_SPMI_HISI3670 is not set +CONFIG_SPMI_MSM_PMIC_ARB=y +# CONFIG_SPMI_PMIC_CLKDIV is not set diff --git a/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/target.mk b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/target.mk new file mode 100755 index 0000000..22a9b78 --- /dev/null +++ b/flint1-armv7/sdk/openwrt-sdk-qualcommax-ipq60xx_gcc-14.3.0_musl.Linux-x86_64/target/linux/qualcommax/ipq807x/target.mk @@ -0,0 +1,7 @@ +SUBTARGET:=ipq807x +BOARDNAME:=Qualcomm Atheros IPQ807x +DEFAULT_PACKAGES += kmod-phy-aquantia ath11k-firmware-ipq8074 + +define Target/Description + Build firmware images for Qualcomm Atheros IPQ807x based boards. +endef diff --git a/flint1-armv7/sdk/openwrt-sdk.tar.zst b/flint1-armv7/sdk/openwrt-sdk.tar.zst new file mode 100755 index 0000000..7225082 Binary files /dev/null and b/flint1-armv7/sdk/openwrt-sdk.tar.zst differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ar b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ar new file mode 100755 index 0000000..4588378 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ar differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/as b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/as new file mode 100755 index 0000000..5e14ca0 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/as differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld new file mode 100755 index 0000000..7dd280d Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld.bfd b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld.bfd new file mode 100755 index 0000000..7dd280d Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld.bfd differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld.gold b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld.gold new file mode 100755 index 0000000..b3a4641 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ld.gold differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/nm b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/nm new file mode 100755 index 0000000..ea87466 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/nm differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/objcopy b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/objcopy new file mode 100755 index 0000000..79784b2 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/objcopy differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/objdump b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/objdump new file mode 100755 index 0000000..86170ad Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/objdump differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ranlib b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ranlib new file mode 100755 index 0000000..8903899 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/ranlib differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/readelf b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/readelf new file mode 100755 index 0000000..b6acb9d Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/readelf differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/strip b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/strip new file mode 100755 index 0000000..4931250 Binary files /dev/null and b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/bin/strip differ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/aio.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/aio.h new file mode 100755 index 0000000..453c41b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/aio.h @@ -0,0 +1,73 @@ +#ifndef _AIO_H +#define _AIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define __NEED_ssize_t +#define __NEED_off_t + +#include + +struct aiocb { + int aio_fildes, aio_lio_opcode, aio_reqprio; + volatile void *aio_buf; + size_t aio_nbytes; + struct sigevent aio_sigevent; + void *__td; + int __lock[2]; + volatile int __err; + ssize_t __ret; + off_t aio_offset; + void *__next, *__prev; + char __dummy4[32-2*sizeof(void *)]; +}; + +#define AIO_CANCELED 0 +#define AIO_NOTCANCELED 1 +#define AIO_ALLDONE 2 + +#define LIO_READ 0 +#define LIO_WRITE 1 +#define LIO_NOP 2 + +#define LIO_WAIT 0 +#define LIO_NOWAIT 1 + +int aio_read(struct aiocb *); +int aio_write(struct aiocb *); +int aio_error(const struct aiocb *); +ssize_t aio_return(struct aiocb *); +int aio_cancel(int, struct aiocb *); +int aio_suspend(const struct aiocb *const [], int, const struct timespec *); +int aio_fsync(int, struct aiocb *); + +int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict); + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define aiocb64 aiocb +#define aio_read64 aio_read +#define aio_write64 aio_write +#define aio_error64 aio_error +#define aio_return64 aio_return +#define aio_cancel64 aio_cancel +#define aio_suspend64 aio_suspend +#define aio_fsync64 aio_fsync +#define lio_listio64 lio_listio +#define off64_t off_t +#endif + +#if _REDIR_TIME64 +__REDIR(aio_suspend, __aio_suspend_time64); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/alloca.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/alloca.h new file mode 100755 index 0000000..b8d183d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/alloca.h @@ -0,0 +1,19 @@ +#ifndef _ALLOCA_H +#define _ALLOCA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __NEED_size_t +#include + +void *alloca(size_t); + +#define alloca __builtin_alloca + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/ar.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/ar.h new file mode 100755 index 0000000..eafd51d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/ar.h @@ -0,0 +1,25 @@ +#ifndef _AR_H +#define _AR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define ARMAG "!\n" +#define SARMAG 8 +#define ARFMAG "`\n" + +struct ar_hdr { + char ar_name[16]; + char ar_date[12]; + char ar_uid[6], ar_gid[6]; + char ar_mode[8]; + char ar_size[10]; + char ar_fmag[2]; +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/ftp.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/ftp.h new file mode 100755 index 0000000..fb0a46f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/ftp.h @@ -0,0 +1,35 @@ +#ifndef _ARPA_FTP_H +#define _ARPA_FTP_H +#define PRELIM 1 +#define COMPLETE 2 +#define CONTINUE 3 +#define TRANSIENT 4 +#define ERROR 5 +#define TYPE_A 1 +#define TYPE_E 2 +#define TYPE_I 3 +#define TYPE_L 4 +#define FORM_N 1 +#define FORM_T 2 +#define FORM_C 3 +#define STRU_F 1 +#define STRU_R 2 +#define STRU_P 3 +#define MODE_S 1 +#define MODE_B 2 +#define MODE_C 3 +#define REC_ESC '\377' +#define REC_EOR '\001' +#define REC_EOF '\002' +#define BLK_EOR 0x80 +#define BLK_EOF 0x40 +#define BLK_ERRORS 0x20 +#define BLK_RESTART 0x10 +#define BLK_BYTECOUNT 2 +#ifdef FTP_NAMES +char *modenames[] = {"0", "Stream", "Block", "Compressed" }; +char *strunames[] = {"0", "File", "Record", "Page" }; +char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; +char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; +#endif +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/inet.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/inet.h new file mode 100755 index 0000000..9d20a15 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/inet.h @@ -0,0 +1,31 @@ +#ifndef _ARPA_INET_H +#define _ARPA_INET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +uint32_t htonl(uint32_t); +uint16_t htons(uint16_t); +uint32_t ntohl(uint32_t); +uint16_t ntohs(uint16_t); + +in_addr_t inet_addr (const char *); +in_addr_t inet_network (const char *); +char *inet_ntoa (struct in_addr); +int inet_pton (int, const char *__restrict, void *__restrict); +const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t); + +int inet_aton (const char *, struct in_addr *); +struct in_addr inet_makeaddr(in_addr_t, in_addr_t); +in_addr_t inet_lnaof(struct in_addr); +in_addr_t inet_netof(struct in_addr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/nameser.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/nameser.h new file mode 100755 index 0000000..581925a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/nameser.h @@ -0,0 +1,455 @@ +#ifndef _ARPA_NAMESER_H +#define _ARPA_NAMESER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define __NAMESER 19991006 +#define NS_PACKETSZ 512 +#define NS_MAXDNAME 1025 +#define NS_MAXMSG 65535 +#define NS_MAXCDNAME 255 +#define NS_MAXLABEL 63 +#define NS_HFIXEDSZ 12 +#define NS_QFIXEDSZ 4 +#define NS_RRFIXEDSZ 10 +#define NS_INT32SZ 4 +#define NS_INT16SZ 2 +#define NS_INT8SZ 1 +#define NS_INADDRSZ 4 +#define NS_IN6ADDRSZ 16 +#define NS_CMPRSFLGS 0xc0 +#define NS_DEFAULTPORT 53 + +typedef enum __ns_sect { + ns_s_qd = 0, + ns_s_zn = 0, + ns_s_an = 1, + ns_s_pr = 1, + ns_s_ns = 2, + ns_s_ud = 2, + ns_s_ar = 3, + ns_s_max = 4 +} ns_sect; + +typedef struct __ns_msg { + const unsigned char *_msg, *_eom; + uint16_t _id, _flags, _counts[ns_s_max]; + const unsigned char *_sections[ns_s_max]; + ns_sect _sect; + int _rrnum; + const unsigned char *_msg_ptr; +} ns_msg; + +struct _ns_flagdata { int mask, shift; }; +extern const struct _ns_flagdata _ns_flagdata[]; + +#define ns_msg_id(handle) ((handle)._id + 0) +#define ns_msg_base(handle) ((handle)._msg + 0) +#define ns_msg_end(handle) ((handle)._eom + 0) +#define ns_msg_size(handle) ((handle)._eom - (handle)._msg) +#define ns_msg_count(handle, section) ((handle)._counts[section] + 0) +#define ns_msg_getflag(handle, flag) \ + (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift) + +typedef struct __ns_rr { + char name[NS_MAXDNAME]; + uint16_t type; + uint16_t rr_class; + uint32_t ttl; + uint16_t rdlength; + const unsigned char *rdata; +} ns_rr; + +#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") +#define ns_rr_type(rr) ((ns_type)((rr).type + 0)) +#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) +#define ns_rr_ttl(rr) ((rr).ttl + 0) +#define ns_rr_rdlen(rr) ((rr).rdlength + 0) +#define ns_rr_rdata(rr) ((rr).rdata + 0) + +typedef enum __ns_flag { + ns_f_qr, + ns_f_opcode, + ns_f_aa, + ns_f_tc, + ns_f_rd, + ns_f_ra, + ns_f_z, + ns_f_ad, + ns_f_cd, + ns_f_rcode, + ns_f_max +} ns_flag; + +typedef enum __ns_opcode { + ns_o_query = 0, + ns_o_iquery = 1, + ns_o_status = 2, + ns_o_notify = 4, + ns_o_update = 5, + ns_o_max = 6 +} ns_opcode; + +typedef enum __ns_rcode { + ns_r_noerror = 0, + ns_r_formerr = 1, + ns_r_servfail = 2, + ns_r_nxdomain = 3, + ns_r_notimpl = 4, + ns_r_refused = 5, + ns_r_yxdomain = 6, + ns_r_yxrrset = 7, + ns_r_nxrrset = 8, + ns_r_notauth = 9, + ns_r_notzone = 10, + ns_r_max = 11, + ns_r_badvers = 16, + ns_r_badsig = 16, + ns_r_badkey = 17, + ns_r_badtime = 18 +} ns_rcode; + +typedef enum __ns_update_operation { + ns_uop_delete = 0, + ns_uop_add = 1, + ns_uop_max = 2 +} ns_update_operation; + +struct ns_tsig_key { + char name[NS_MAXDNAME], alg[NS_MAXDNAME]; + unsigned char *data; + int len; +}; +typedef struct ns_tsig_key ns_tsig_key; + +struct ns_tcp_tsig_state { + int counter; + struct dst_key *key; + void *ctx; + unsigned char sig[NS_PACKETSZ]; + int siglen; +}; +typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; + +#define NS_TSIG_FUDGE 300 +#define NS_TSIG_TCP_COUNT 100 +#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" + +#define NS_TSIG_ERROR_NO_TSIG -10 +#define NS_TSIG_ERROR_NO_SPACE -11 +#define NS_TSIG_ERROR_FORMERR -12 + +typedef enum __ns_type { + ns_t_invalid = 0, + ns_t_a = 1, + ns_t_ns = 2, + ns_t_md = 3, + ns_t_mf = 4, + ns_t_cname = 5, + ns_t_soa = 6, + ns_t_mb = 7, + ns_t_mg = 8, + ns_t_mr = 9, + ns_t_null = 10, + ns_t_wks = 11, + ns_t_ptr = 12, + ns_t_hinfo = 13, + ns_t_minfo = 14, + ns_t_mx = 15, + ns_t_txt = 16, + ns_t_rp = 17, + ns_t_afsdb = 18, + ns_t_x25 = 19, + ns_t_isdn = 20, + ns_t_rt = 21, + ns_t_nsap = 22, + ns_t_nsap_ptr = 23, + ns_t_sig = 24, + ns_t_key = 25, + ns_t_px = 26, + ns_t_gpos = 27, + ns_t_aaaa = 28, + ns_t_loc = 29, + ns_t_nxt = 30, + ns_t_eid = 31, + ns_t_nimloc = 32, + ns_t_srv = 33, + ns_t_atma = 34, + ns_t_naptr = 35, + ns_t_kx = 36, + ns_t_cert = 37, + ns_t_a6 = 38, + ns_t_dname = 39, + ns_t_sink = 40, + ns_t_opt = 41, + ns_t_apl = 42, + ns_t_tkey = 249, + ns_t_tsig = 250, + ns_t_ixfr = 251, + ns_t_axfr = 252, + ns_t_mailb = 253, + ns_t_maila = 254, + ns_t_any = 255, + ns_t_zxfr = 256, + ns_t_max = 65536 +} ns_type; + +#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ + (t) == ns_t_mailb || (t) == ns_t_maila) +#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) +#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) +#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) +#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ + (t) == ns_t_zxfr) + +typedef enum __ns_class { + ns_c_invalid = 0, + ns_c_in = 1, + ns_c_2 = 2, + ns_c_chaos = 3, + ns_c_hs = 4, + ns_c_none = 254, + ns_c_any = 255, + ns_c_max = 65536 +} ns_class; + +typedef enum __ns_key_types { + ns_kt_rsa = 1, + ns_kt_dh = 2, + ns_kt_dsa = 3, + ns_kt_private = 254 +} ns_key_types; + +typedef enum __ns_cert_types { + cert_t_pkix = 1, + cert_t_spki = 2, + cert_t_pgp = 3, + cert_t_url = 253, + cert_t_oid = 254 +} ns_cert_types; + +#define NS_KEY_TYPEMASK 0xC000 +#define NS_KEY_TYPE_AUTH_CONF 0x0000 +#define NS_KEY_TYPE_CONF_ONLY 0x8000 +#define NS_KEY_TYPE_AUTH_ONLY 0x4000 +#define NS_KEY_TYPE_NO_KEY 0xC000 +#define NS_KEY_NO_AUTH 0x8000 +#define NS_KEY_NO_CONF 0x4000 +#define NS_KEY_RESERVED2 0x2000 +#define NS_KEY_EXTENDED_FLAGS 0x1000 +#define NS_KEY_RESERVED4 0x0800 +#define NS_KEY_RESERVED5 0x0400 +#define NS_KEY_NAME_TYPE 0x0300 +#define NS_KEY_NAME_USER 0x0000 +#define NS_KEY_NAME_ENTITY 0x0200 +#define NS_KEY_NAME_ZONE 0x0100 +#define NS_KEY_NAME_RESERVED 0x0300 +#define NS_KEY_RESERVED8 0x0080 +#define NS_KEY_RESERVED9 0x0040 +#define NS_KEY_RESERVED10 0x0020 +#define NS_KEY_RESERVED11 0x0010 +#define NS_KEY_SIGNATORYMASK 0x000F +#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \ + NS_KEY_RESERVED4 | \ + NS_KEY_RESERVED5 | \ + NS_KEY_RESERVED8 | \ + NS_KEY_RESERVED9 | \ + NS_KEY_RESERVED10 | \ + NS_KEY_RESERVED11 ) +#define NS_KEY_RESERVED_BITMASK2 0xFFFF +#define NS_ALG_MD5RSA 1 +#define NS_ALG_DH 2 +#define NS_ALG_DSA 3 +#define NS_ALG_DSS NS_ALG_DSA +#define NS_ALG_EXPIRE_ONLY 253 +#define NS_ALG_PRIVATE_OID 254 + +#define NS_KEY_PROT_TLS 1 +#define NS_KEY_PROT_EMAIL 2 +#define NS_KEY_PROT_DNSSEC 3 +#define NS_KEY_PROT_IPSEC 4 +#define NS_KEY_PROT_ANY 255 + +#define NS_MD5RSA_MIN_BITS 512 +#define NS_MD5RSA_MAX_BITS 4096 +#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) +#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) +#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) +#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) + +#define NS_DSA_SIG_SIZE 41 +#define NS_DSA_MIN_SIZE 213 +#define NS_DSA_MAX_BYTES 405 + +#define NS_SIG_TYPE 0 +#define NS_SIG_ALG 2 +#define NS_SIG_LABELS 3 +#define NS_SIG_OTTL 4 +#define NS_SIG_EXPIR 8 +#define NS_SIG_SIGNED 12 +#define NS_SIG_FOOT 16 +#define NS_SIG_SIGNER 18 +#define NS_NXT_BITS 8 +#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_MAX 127 + +#define NS_OPT_DNSSEC_OK 0x8000U +#define NS_OPT_NSID 3 + +#define NS_GET16(s, cp) (void)((s) = ns_get16(((cp)+=2)-2)) +#define NS_GET32(l, cp) (void)((l) = ns_get32(((cp)+=4)-4)) +#define NS_PUT16(s, cp) ns_put16((s), ((cp)+=2)-2) +#define NS_PUT32(l, cp) ns_put32((l), ((cp)+=4)-4) + +unsigned ns_get16(const unsigned char *); +unsigned long ns_get32(const unsigned char *); +void ns_put16(unsigned, unsigned char *); +void ns_put32(unsigned long, unsigned char *); + +int ns_initparse(const unsigned char *, int, ns_msg *); +int ns_parserr(ns_msg *, ns_sect, int, ns_rr *); +int ns_skiprr(const unsigned char *, const unsigned char *, ns_sect, int); +int ns_name_uncompress(const unsigned char *, const unsigned char *, const unsigned char *, char *, size_t); + + +#define __BIND 19950621 + +typedef struct { + unsigned id :16; +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned qr: 1; + unsigned opcode: 4; + unsigned aa: 1; + unsigned tc: 1; + unsigned rd: 1; + unsigned ra: 1; + unsigned unused :1; + unsigned ad: 1; + unsigned cd: 1; + unsigned rcode :4; +#else + unsigned rd :1; + unsigned tc :1; + unsigned aa :1; + unsigned opcode :4; + unsigned qr :1; + unsigned rcode :4; + unsigned cd: 1; + unsigned ad: 1; + unsigned unused :1; + unsigned ra :1; +#endif + unsigned qdcount :16; + unsigned ancount :16; + unsigned nscount :16; + unsigned arcount :16; +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INT8SZ NS_INT8SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_A6 ns_t_a6 +#define T_DNAME ns_t_dname +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#define GETSHORT NS_GET16 +#define GETLONG NS_GET32 +#define PUTSHORT NS_PUT16 +#define PUTLONG NS_PUT32 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/nameser_compat.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/nameser_compat.h new file mode 100755 index 0000000..3aac25c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/nameser_compat.h @@ -0,0 +1,2 @@ +#include + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/telnet.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/telnet.h new file mode 100755 index 0000000..e2ad974 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/telnet.h @@ -0,0 +1,251 @@ +#ifndef _ARPA_TELNET_H +#define _ARPA_TELNET_H + +#define IAC 255 +#define DONT 254 +#define DO 253 +#define WONT 252 +#define WILL 251 +#define SB 250 +#define GA 249 +#define EL 248 +#define EC 247 +#define AYT 246 +#define AO 245 +#define IP 244 +#define BREAK 243 +#define DM 242 +#define NOP 241 +#define SE 240 +#define EOR 239 +#define ABORT 238 +#define SUSP 237 +#define xEOF 236 + +#define SYNCH 242 + +#define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 }) + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +#define TELOPT_BINARY 0 +#define TELOPT_ECHO 1 +#define TELOPT_RCP 2 +#define TELOPT_SGA 3 +#define TELOPT_NAMS 4 +#define TELOPT_STATUS 5 +#define TELOPT_TM 6 +#define TELOPT_RCTE 7 +#define TELOPT_NAOL 8 +#define TELOPT_NAOP 9 +#define TELOPT_NAOCRD 10 +#define TELOPT_NAOHTS 11 +#define TELOPT_NAOHTD 12 +#define TELOPT_NAOFFD 13 +#define TELOPT_NAOVTS 14 +#define TELOPT_NAOVTD 15 +#define TELOPT_NAOLFD 16 +#define TELOPT_XASCII 17 +#define TELOPT_LOGOUT 18 +#define TELOPT_BM 19 +#define TELOPT_DET 20 +#define TELOPT_SUPDUP 21 +#define TELOPT_SUPDUPOUTPUT 22 +#define TELOPT_SNDLOC 23 +#define TELOPT_TTYPE 24 +#define TELOPT_EOR 25 +#define TELOPT_TUID 26 +#define TELOPT_OUTMRK 27 +#define TELOPT_TTYLOC 28 +#define TELOPT_3270REGIME 29 +#define TELOPT_X3PAD 30 +#define TELOPT_NAWS 31 +#define TELOPT_TSPEED 32 +#define TELOPT_LFLOW 33 +#define TELOPT_LINEMODE 34 +#define TELOPT_XDISPLOC 35 +#define TELOPT_OLD_ENVIRON 36 +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 +#define TELOPT_NEW_ENVIRON 39 +#define TELOPT_EXOPL 255 + + +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +#ifdef TELOPTS +char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +#define TELQUAL_IS 0 +#define TELQUAL_SEND 1 +#define TELQUAL_INFO 2 +#define TELQUAL_REPLY 2 +#define TELQUAL_NAME 3 + +#define LFLOW_OFF 0 +#define LFLOW_ON 1 +#define LFLOW_RESTART_ANY 2 +#define LFLOW_RESTART_XON 3 + + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +#define AUTH_WHO_CLIENT 0 +#define AUTH_WHO_SERVER 1 +#define AUTH_WHO_MASK 1 + +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_CNT 5 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, +}; +#else +extern char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +#define ENCRYPT_IS 0 +#define ENCRYPT_SUPPORT 1 +#define ENCRYPT_REPLY 2 +#define ENCRYPT_START 3 +#define ENCRYPT_END 4 +#define ENCRYPT_REQSTART 5 +#define ENCRYPT_REQEND 6 +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; +char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/tftp.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/tftp.h new file mode 100755 index 0000000..799c54f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/arpa/tftp.h @@ -0,0 +1,31 @@ +#ifndef _ARPA_TFTP_H +#define _ARPA_TFTP_H +#define SEGSIZE 512 +#define RRQ 01 +#define WRQ 02 +#define DATA 03 +#define ACK 04 +#define ERROR 05 +struct tftphdr { + short th_opcode; + union { + unsigned short tu_block; + short tu_code; + char tu_stuff[1]; + } th_u; + char th_data[1]; +}; +#define th_block th_u.tu_block +#define th_code th_u.tu_code +#define th_stuff th_u.tu_stuff +#define th_msg th_data +#define EUNDEF 0 +#define ENOTFOUND 1 +#define EACCESS 2 +#define ENOSPACE 3 +#define EBADOP 4 +#define EBADID 5 +#define EEXISTS 6 +#define ENOUSER 7 +#endif + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/auxvec.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/auxvec.h new file mode 100755 index 0000000..b99573b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/auxvec.h @@ -0,0 +1,8 @@ +#ifndef __ASM_GENERIC_AUXVEC_H +#define __ASM_GENERIC_AUXVEC_H +/* + * Not all architectures need their own auxvec.h, the most + * common definitions are already in linux/auxvec.h. + */ + +#endif /* __ASM_GENERIC_AUXVEC_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/bitsperlong.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/bitsperlong.h new file mode 100755 index 0000000..0aac245 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/bitsperlong.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_BITS_PER_LONG +#define __ASM_GENERIC_BITS_PER_LONG + +/* + * There seems to be no way of detecting this automatically from user + * space, so 64 bit architectures should override this in their + * bitsperlong.h. In particular, an architecture that supports + * both 32 and 64 bit user space must not rely on CONFIG_64BIT + * to decide it, but rather check a compiler provided macro. + */ +#ifndef __BITS_PER_LONG +#define __BITS_PER_LONG 32 +#endif + +#endif /* __ASM_GENERIC_BITS_PER_LONG */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/bpf_perf_event.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/bpf_perf_event.h new file mode 100755 index 0000000..29fbc11 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/bpf_perf_event.h @@ -0,0 +1,9 @@ +#ifndef __ASM_GENERIC_BPF_PERF_EVENT_H__ +#define __ASM_GENERIC_BPF_PERF_EVENT_H__ + +#include + +/* Export kernel pt_regs structure */ +typedef struct pt_regs bpf_user_pt_regs_t; + +#endif /* __ASM_GENERIC_BPF_PERF_EVENT_H__ */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/errno-base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/errno-base.h new file mode 100755 index 0000000..9653140 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/errno-base.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/errno.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/errno.h new file mode 100755 index 0000000..cf9c51a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/errno.h @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ + +/* + * This error code is special: arch syscall entry code will return + * -ENOSYS if users try to call a syscall that doesn't exist. To keep + * failures of syscalls that really do exist distinguishable from + * failures due to attempts to use a nonexistent syscall, syscall + * implementations should refrain from returning -ENOSYS. + */ +#define ENOSYS 38 /* Invalid system call number */ + +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#define ERFKILL 132 /* Operation not possible due to RF-kill */ + +#define EHWPOISON 133 /* Memory page has hardware error */ + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/fcntl.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/fcntl.h new file mode 100755 index 0000000..9dc0bf0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/fcntl.h @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_FCNTL_H +#define _ASM_GENERIC_FCNTL_H + +#include + +/* + * FMODE_EXEC is 0x20 + * FMODE_NONOTIFY is 0x4000000 + * These cannot be used by userspace O_* until internal and external open + * flags are split. + * -Eric Paris + */ + +/* + * When introducing new O_* bits, please check its uniqueness in fcntl_init(). + */ + +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#ifndef O_CREAT +#define O_CREAT 00000100 /* not fcntl */ +#endif +#ifndef O_EXCL +#define O_EXCL 00000200 /* not fcntl */ +#endif +#ifndef O_NOCTTY +#define O_NOCTTY 00000400 /* not fcntl */ +#endif +#ifndef O_TRUNC +#define O_TRUNC 00001000 /* not fcntl */ +#endif +#ifndef O_APPEND +#define O_APPEND 00002000 +#endif +#ifndef O_NONBLOCK +#define O_NONBLOCK 00004000 +#endif +#ifndef O_DSYNC +#define O_DSYNC 00010000 /* used to be O_SYNC, see below */ +#endif +#ifndef FASYNC +#define FASYNC 00020000 /* fcntl, for BSD compatibility */ +#endif +#ifndef O_DIRECT +#define O_DIRECT 00040000 /* direct disk access hint */ +#endif +#ifndef O_LARGEFILE +#define O_LARGEFILE 00100000 +#endif +#ifndef O_DIRECTORY +#define O_DIRECTORY 00200000 /* must be a directory */ +#endif +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 00400000 /* don't follow links */ +#endif +#ifndef O_NOATIME +#define O_NOATIME 01000000 +#endif +#ifndef O_CLOEXEC +#define O_CLOEXEC 02000000 /* set close_on_exec */ +#endif + +/* + * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using + * the O_SYNC flag. We continue to use the existing numerical value + * for O_DSYNC semantics now, but using the correct symbolic name for it. + * This new value is used to request true Posix O_SYNC semantics. It is + * defined in this strange way to make sure applications compiled against + * new headers get at least O_DSYNC semantics on older kernels. + * + * This has the nice side-effect that we can simply test for O_DSYNC + * wherever we do not care if O_DSYNC or O_SYNC is used. + * + * Note: __O_SYNC must never be used directly. + */ +#ifndef O_SYNC +#define __O_SYNC 04000000 +#define O_SYNC (__O_SYNC|O_DSYNC) +#endif + +#ifndef O_PATH +#define O_PATH 010000000 +#endif + +#ifndef __O_TMPFILE +#define __O_TMPFILE 020000000 +#endif + +/* a horrid kludge trying to make sure that this will fail on old kernels */ +#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) +#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT) + +#ifndef O_NDELAY +#define O_NDELAY O_NONBLOCK +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get close_on_exec */ +#define F_SETFD 2 /* set/clear close_on_exec */ +#define F_GETFL 3 /* get file->f_flags */ +#define F_SETFL 4 /* set file->f_flags */ +#ifndef F_GETLK +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif +#ifndef F_SETOWN +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ +#endif +#ifndef F_SETSIG +#define F_SETSIG 10 /* for sockets. */ +#define F_GETSIG 11 /* for sockets. */ +#endif + +#ifndef CONFIG_64BIT +#ifndef F_GETLK64 +#define F_GETLK64 12 /* using 'struct flock64' */ +#define F_SETLK64 13 +#define F_SETLKW64 14 +#endif +#endif + +#ifndef F_SETOWN_EX +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 +#endif + +#ifndef F_GETOWNER_UIDS +#define F_GETOWNER_UIDS 17 +#endif + +/* + * Open File Description Locks + * + * Usually record locks held by a process are released on *any* close and are + * not inherited across a fork(). + * + * These cmd values will set locks that conflict with process-associated + * record locks, but are "owned" by the open file description, not the + * process. This means that they are inherited across fork() like BSD (flock) + * locks, and they are only released automatically when the last reference to + * the the open file against which they were acquired is put. + */ +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 + +#define F_OWNER_TID 0 +#define F_OWNER_PID 1 +#define F_OWNER_PGRP 2 + +struct f_owner_ex { + int type; + __kernel_pid_t pid; +}; + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#ifndef F_RDLCK +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#endif + +/* for old implementation of bsd flock () */ +#ifndef F_EXLCK +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ +#endif + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#define LOCK_MAND 32 /* This is a mandatory flock ... */ +#define LOCK_READ 64 /* which allows concurrent read operations */ +#define LOCK_WRITE 128 /* which allows concurrent write operations */ +#define LOCK_RW 192 /* which allows concurrent read & write ops */ + +#define F_LINUX_SPECIFIC_BASE 1024 + +#ifndef HAVE_ARCH_STRUCT_FLOCK +#ifndef __ARCH_FLOCK_PAD +#define __ARCH_FLOCK_PAD +#endif + +struct flock { + short l_type; + short l_whence; + __kernel_off_t l_start; + __kernel_off_t l_len; + __kernel_pid_t l_pid; + __ARCH_FLOCK_PAD +}; +#endif + +#ifndef HAVE_ARCH_STRUCT_FLOCK64 +#ifndef __ARCH_FLOCK64_PAD +#define __ARCH_FLOCK64_PAD +#endif + +struct flock64 { + short l_type; + short l_whence; + __kernel_loff_t l_start; + __kernel_loff_t l_len; + __kernel_pid_t l_pid; + __ARCH_FLOCK64_PAD +}; +#endif + +#endif /* _ASM_GENERIC_FCNTL_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/hugetlb_encode.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/hugetlb_encode.h new file mode 100755 index 0000000..4f3d5aa --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/hugetlb_encode.h @@ -0,0 +1,37 @@ +#ifndef _ASM_GENERIC_HUGETLB_ENCODE_H_ +#define _ASM_GENERIC_HUGETLB_ENCODE_H_ + +/* + * Several system calls take a flag to request "hugetlb" huge pages. + * Without further specification, these system calls will use the + * system's default huge page size. If a system supports multiple + * huge page sizes, the desired huge page size can be specified in + * bits [26:31] of the flag arguments. The value in these 6 bits + * will encode the log2 of the huge page size. + * + * The following definitions are associated with this huge page size + * encoding in flag arguments. System call specific header files + * that use this encoding should include this file. They can then + * provide definitions based on these with their own specific prefix. + * for example: + * #define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT + */ + +#define HUGETLB_FLAG_ENCODE_SHIFT 26 +#define HUGETLB_FLAG_ENCODE_MASK 0x3f + +#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT) + +#endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/int-l64.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/int-l64.h new file mode 100755 index 0000000..845e2de --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/int-l64.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * asm-generic/int-l64.h + * + * Integer declarations for architectures which use "long" + * for 64-bit types. + */ + +#ifndef _ASM_GENERIC_INT_L64_H +#define _ASM_GENERIC_INT_L64_H + +#include + +#ifndef __ASSEMBLY__ +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +typedef __signed__ long __s64; +typedef unsigned long __u64; + +#endif /* __ASSEMBLY__ */ + + +#endif /* _ASM_GENERIC_INT_L64_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/int-ll64.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/int-ll64.h new file mode 100755 index 0000000..db61e81 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/int-ll64.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * asm-generic/int-ll64.h + * + * Integer declarations for architectures which use "long long" + * for 64-bit types. + */ + +#ifndef _ASM_GENERIC_INT_LL64_H +#define _ASM_GENERIC_INT_LL64_H + +#include + +#ifndef __ASSEMBLY__ +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#ifdef __GNUC__ +__extension__ typedef __signed__ long long __s64; +__extension__ typedef unsigned long long __u64; +#else +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +#endif /* __ASSEMBLY__ */ + + +#endif /* _ASM_GENERIC_INT_LL64_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ioctl.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ioctl.h new file mode 100755 index 0000000..8cbb364 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ioctl.h @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_IOCTL_H +#define _ASM_GENERIC_IOCTL_H + +/* ioctl command encoding: 32 bits total, command in lower 16 bits, + * size of the parameter structure in the lower 14 bits of the + * upper 16 bits. + * Encoding the size of the parameter structure in the ioctl request + * is useful for catching programs compiled with old versions + * and to avoid overwriting user space outside the user buffer area. + * The highest 2 bits are reserved for indicating the ``access mode''. + * NOTE: This limits the max parameter size to 16kB -1 ! + */ + +/* + * The following is for compatibility across the various Linux + * platforms. The generic ioctl numbering scheme doesn't really enforce + * a type field. De facto, however, the top 8 bits of the lower 16 + * bits are indeed used as a type field, so we might just as well make + * this explicit here. Please be sure to use the decoding macros + * below from now on. + */ +#define _IOC_NRBITS 8 +#define _IOC_TYPEBITS 8 + +/* + * Let any architecture override either of the following before + * including this file. + */ + +#ifndef _IOC_SIZEBITS +# define _IOC_SIZEBITS 14 +#endif + +#ifndef _IOC_DIRBITS +# define _IOC_DIRBITS 2 +#endif + +#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) +#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) +#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) +#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) + +#define _IOC_NRSHIFT 0 +#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) +#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) +#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) + +/* + * Direction bits, which any architecture can choose to override + * before including this file. + * + * NOTE: _IOC_WRITE means userland is writing and kernel is + * reading. _IOC_READ means userland is reading and kernel is writing. + */ + +#ifndef _IOC_NONE +# define _IOC_NONE 0U +#endif + +#ifndef _IOC_WRITE +# define _IOC_WRITE 1U +#endif + +#ifndef _IOC_READ +# define _IOC_READ 2U +#endif + +#define _IOC(dir,type,nr,size) \ + (((dir) << _IOC_DIRSHIFT) | \ + ((type) << _IOC_TYPESHIFT) | \ + ((nr) << _IOC_NRSHIFT) | \ + ((size) << _IOC_SIZESHIFT)) + +#define _IOC_TYPECHECK(t) (sizeof(t)) + +/* + * Used to create numbers. + * + * NOTE: _IOW means userland is writing and kernel is reading. _IOR + * means userland is reading and kernel is writing. + */ +#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) +#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) +#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) +#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) +#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) + +/* used to decode ioctl numbers.. */ +#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) +#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) +#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) +#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) + +/* ...and for the drivers/sound files... */ + +#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) +#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) +#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) +#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) +#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) + +#endif /* _ASM_GENERIC_IOCTL_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ioctls.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ioctls.h new file mode 100755 index 0000000..ab5479a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ioctls.h @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_IOCTLS_H +#define __ASM_GENERIC_IOCTLS_H + +#include + +/* + * These are the most common definitions for tty ioctl numbers. + * Most of them do not use the recommended _IOC(), but there is + * probably some source code out there hardcoding the number, + * so we might as well use them for all new platforms. + * + * The architectures that use different values here typically + * try to be compatible with some Unix variants for the same + * architecture. + */ + +/* 0x54 is just a magic number to make these relatively unique ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCSBRK 0x5427 /* BSD compatibility */ +#define TIOCCBRK 0x5428 /* BSD compatibility */ +#define TIOCGSID 0x5429 /* Return the session ID of FD */ +#define TCGETS2 _IOR('T', 0x2A, struct termios2) +#define TCSETS2 _IOW('T', 0x2B, struct termios2) +#define TCSETSW2 _IOW('T', 0x2C, struct termios2) +#define TCSETSF2 _IOW('T', 0x2D, struct termios2) +#define TIOCGRS485 0x542E +#ifndef TIOCSRS485 +#define TIOCSRS485 0x542F +#endif +#define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */ +#define TIOCGDEV _IOR('T', 0x32, unsigned int) /* Get primary device node of /dev/console */ +#define TCGETX 0x5432 /* SYS5 TCGETX compatibility */ +#define TCSETX 0x5433 +#define TCSETXF 0x5434 +#define TCSETXW 0x5435 +#define TIOCSIG _IOW('T', 0x36, int) /* pty: generate signal */ +#define TIOCVHANGUP 0x5437 +#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ +#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ +#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ +#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ +#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816) +#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816) + +#define FIONCLEX 0x5450 +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port __inline__ interrupt counts */ + +/* + * Some arches already define FIOQSIZE due to a historical + * conflict with a Hayes modem-specific ioctl value. + */ +#ifndef FIOQSIZE +# define FIOQSIZE 0x5460 +#endif + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 +#define TIOCPKT_IOCTL 64 + +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +#endif /* __ASM_GENERIC_IOCTLS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ipcbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ipcbuf.h new file mode 100755 index 0000000..41a01b4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ipcbuf.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_IPCBUF_H +#define __ASM_GENERIC_IPCBUF_H + +#include + +/* + * The generic ipc64_perm structure: + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * ipc64_perm was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * Pad space is left for: + * - 32-bit mode_t on architectures that only had 16 bit + * - 32-bit seq + * - 2 miscellaneous 32-bit values + */ + +struct ipc64_perm { + __kernel_key_t key; + __kernel_uid32_t uid; + __kernel_gid32_t gid; + __kernel_uid32_t cuid; + __kernel_gid32_t cgid; + __kernel_mode_t mode; + /* pad if mode_t is u16: */ + unsigned char __pad1[4 - sizeof(__kernel_mode_t)]; + unsigned short seq; + unsigned short __pad2; + __kernel_ulong_t __unused1; + __kernel_ulong_t __unused2; +}; + +#endif /* __ASM_GENERIC_IPCBUF_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/kvm_para.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/kvm_para.h new file mode 100755 index 0000000..486f0af --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/kvm_para.h @@ -0,0 +1,4 @@ +/* + * There isn't anything here, but the file must not be empty or patch + * will delete it. + */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/mman-common.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/mman-common.h new file mode 100755 index 0000000..1567a32 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/mman-common.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_MMAN_COMMON_H +#define __ASM_GENERIC_MMAN_COMMON_H + +/* + Author: Michael S. Tsirkin , Mellanox Technologies Ltd. + Based on: asm-xxx/mman.h +*/ + +#define PROT_READ 0x1 /* page can be read */ +#define PROT_WRITE 0x2 /* page can be written */ +#define PROT_EXEC 0x4 /* page can be executed */ +#define PROT_SEM 0x8 /* page may be used for atomic ops */ +/* 0x10 reserved for arch-specific use */ +/* 0x20 reserved for arch-specific use */ +#define PROT_NONE 0x0 /* page can not be accessed */ +#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ +#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ + +/* 0x01 - 0x03 are defined in linux/mman.h */ +#define MAP_TYPE 0x0f /* Mask for type of mapping */ +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ + +/* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */ +#define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */ +#define MAP_NONBLOCK 0x010000 /* do not block on IO */ +#define MAP_STACK 0x020000 /* give out an address that is best suited for process/thread stacks */ +#define MAP_HUGETLB 0x040000 /* create a huge page mapping */ +#define MAP_SYNC 0x080000 /* perform synchronous page faults for the mapping */ +#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ + +#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be + * uninitialized */ + +/* + * Flags for mlock + */ +#define MLOCK_ONFAULT 0x01 /* Lock pages in range after they are faulted in, do not prefault */ + +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ + +#define MADV_NORMAL 0 /* no further special treatment */ +#define MADV_RANDOM 1 /* expect random page references */ +#define MADV_SEQUENTIAL 2 /* expect sequential page references */ +#define MADV_WILLNEED 3 /* will need these pages */ +#define MADV_DONTNEED 4 /* don't need these pages */ + +/* common parameters: try to keep these consistent across architectures */ +#define MADV_FREE 8 /* free pages only if memory pressure */ +#define MADV_REMOVE 9 /* remove these pages & resources */ +#define MADV_DONTFORK 10 /* don't inherit across fork */ +#define MADV_DOFORK 11 /* do inherit across fork */ +#define MADV_HWPOISON 100 /* poison a page for testing */ +#define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */ + +#define MADV_MERGEABLE 12 /* KSM may merge identical pages */ +#define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ + +#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ +#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ + +#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, + overrides the coredump filter bits */ +#define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag */ + +#define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ +#define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ + +#define MADV_COLD 20 /* deactivate these pages */ +#define MADV_PAGEOUT 21 /* reclaim these pages */ + +#define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */ +#define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */ + +/* compatibility flags */ +#define MAP_FILE 0 + +#define PKEY_DISABLE_ACCESS 0x1 +#define PKEY_DISABLE_WRITE 0x2 +#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ + PKEY_DISABLE_WRITE) + +#endif /* __ASM_GENERIC_MMAN_COMMON_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/mman.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/mman.h new file mode 100755 index 0000000..57e8195 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/mman.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_MMAN_H +#define __ASM_GENERIC_MMAN_H + +#include + +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ +#define MAP_NORESERVE 0x4000 /* don't check for reservations */ + +/* + * Bits [26:31] are reserved, see asm-generic/hugetlb_encode.h + * for MAP_HUGETLB usage + */ + +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ +#define MCL_ONFAULT 4 /* lock all pages that are faulted in */ + +#endif /* __ASM_GENERIC_MMAN_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/msgbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/msgbuf.h new file mode 100755 index 0000000..6504d7b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/msgbuf.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_MSGBUF_H +#define __ASM_GENERIC_MSGBUF_H + +#include +#include + +/* + * generic msqid64_ds structure. + * + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * msqid64_ds was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * 64 bit architectures use a 64-bit long time field here, while + * 32 bit architectures have a pair of unsigned long values. + * On big-endian systems, the lower half is in the wrong place. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; +#if __BITS_PER_LONG == 64 + long msg_stime; /* last msgsnd time */ + long msg_rtime; /* last msgrcv time */ + long msg_ctime; /* last change time */ +#else + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_stime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_rtime_high; + unsigned long msg_ctime; /* last change time */ + unsigned long msg_ctime_high; +#endif + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* __ASM_GENERIC_MSGBUF_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/param.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/param.h new file mode 100755 index 0000000..1ced72d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/param.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_PARAM_H +#define __ASM_GENERIC_PARAM_H + +#ifndef HZ +#define HZ 100 +#endif + +#ifndef EXEC_PAGESIZE +#define EXEC_PAGESIZE 4096 +#endif + +#ifndef NOGROUP +#define NOGROUP (-1) +#endif + +#define MAXHOSTNAMELEN 64 /* max length of hostname */ + + +#endif /* __ASM_GENERIC_PARAM_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/poll.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/poll.h new file mode 100755 index 0000000..0322a39 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/poll.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_POLL_H +#define __ASM_GENERIC_POLL_H + +/* These are specified by iBCS2 */ +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +/* The rest seem to be more-or-less nonstandard. Check them! */ +#define POLLRDNORM 0x0040 +#define POLLRDBAND 0x0080 +#ifndef POLLWRNORM +#define POLLWRNORM 0x0100 +#endif +#ifndef POLLWRBAND +#define POLLWRBAND 0x0200 +#endif +#ifndef POLLMSG +#define POLLMSG 0x0400 +#endif +#ifndef POLLREMOVE +#define POLLREMOVE 0x1000 +#endif +#ifndef POLLRDHUP +#define POLLRDHUP 0x2000 +#endif + +#define POLLFREE (__poll_t)0x4000 /* currently only for epoll */ + +#define POLL_BUSY_LOOP (__poll_t)0x8000 + +struct pollfd { + int fd; + short events; + short revents; +}; + +#endif /* __ASM_GENERIC_POLL_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/posix_types.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/posix_types.h new file mode 100755 index 0000000..2f9c805 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/posix_types.h @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_POSIX_TYPES_H +#define __ASM_GENERIC_POSIX_TYPES_H + +#include +/* + * This file is generally used by user-level software, so you need to + * be a little careful about namespace pollution etc. + * + * First the types that are often defined in different ways across + * architectures, so that you can override them. + */ + +#ifndef __kernel_long_t +typedef long __kernel_long_t; +typedef unsigned long __kernel_ulong_t; +#endif + +#ifndef __kernel_ino_t +typedef __kernel_ulong_t __kernel_ino_t; +#endif + +#ifndef __kernel_mode_t +typedef unsigned int __kernel_mode_t; +#endif + +#ifndef __kernel_pid_t +typedef int __kernel_pid_t; +#endif + +#ifndef __kernel_ipc_pid_t +typedef int __kernel_ipc_pid_t; +#endif + +#ifndef __kernel_uid_t +typedef unsigned int __kernel_uid_t; +typedef unsigned int __kernel_gid_t; +#endif + +#ifndef __kernel_suseconds_t +typedef __kernel_long_t __kernel_suseconds_t; +#endif + +#ifndef __kernel_daddr_t +typedef int __kernel_daddr_t; +#endif + +#ifndef __kernel_uid32_t +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; +#endif + +#ifndef __kernel_old_uid_t +typedef __kernel_uid_t __kernel_old_uid_t; +typedef __kernel_gid_t __kernel_old_gid_t; +#endif + +#ifndef __kernel_old_dev_t +typedef unsigned int __kernel_old_dev_t; +#endif + +/* + * Most 32 bit architectures use "unsigned int" size_t, + * and all 64 bit architectures use "unsigned long" size_t. + */ +#ifndef __kernel_size_t +#if __BITS_PER_LONG != 64 +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +#else +typedef __kernel_ulong_t __kernel_size_t; +typedef __kernel_long_t __kernel_ssize_t; +typedef __kernel_long_t __kernel_ptrdiff_t; +#endif +#endif + +#ifndef __kernel_fsid_t +typedef struct { + int val[2]; +} __kernel_fsid_t; +#endif + +/* + * anything below here should be completely generic + */ +typedef __kernel_long_t __kernel_off_t; +typedef long long __kernel_loff_t; +typedef __kernel_long_t __kernel_old_time_t; +typedef __kernel_long_t __kernel_time_t; +typedef long long __kernel_time64_t; +typedef __kernel_long_t __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; + +#endif /* __ASM_GENERIC_POSIX_TYPES_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/resource.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/resource.h new file mode 100755 index 0000000..2b8f2c2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/resource.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_RESOURCE_H +#define _ASM_GENERIC_RESOURCE_H + +/* + * Resource limit IDs + * + * ( Compatibility detail: there are architectures that have + * a different rlimit ID order in the 5-9 range and want + * to keep that order for binary compatibility. The reasons + * are historic and all new rlimits are identical across all + * arches. If an arch has such special order for some rlimits + * then it defines them prior including asm-generic/resource.h. ) + */ + +#define RLIMIT_CPU 0 /* CPU time in sec */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ + +#ifndef RLIMIT_RSS +# define RLIMIT_RSS 5 /* max resident set size */ +#endif + +#ifndef RLIMIT_NPROC +# define RLIMIT_NPROC 6 /* max number of processes */ +#endif + +#ifndef RLIMIT_NOFILE +# define RLIMIT_NOFILE 7 /* max number of open files */ +#endif + +#ifndef RLIMIT_MEMLOCK +# define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ +#endif + +#ifndef RLIMIT_AS +# define RLIMIT_AS 9 /* address space limit */ +#endif + +#define RLIMIT_LOCKS 10 /* maximum file locks held */ +#define RLIMIT_SIGPENDING 11 /* max number of pending signals */ +#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */ +#define RLIMIT_NICE 13 /* max nice prio allowed to raise to + 0-39 for nice level 19 .. -20 */ +#define RLIMIT_RTPRIO 14 /* maximum realtime priority */ +#define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */ +#define RLIM_NLIMITS 16 + +/* + * SuS says limits have to be unsigned. + * Which makes a ton more sense anyway. + * + * Some architectures override this (for compatibility reasons): + */ +#ifndef RLIM_INFINITY +# define RLIM_INFINITY (~0UL) +#endif + + +#endif /* _ASM_GENERIC_RESOURCE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/sembuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/sembuf.h new file mode 100755 index 0000000..f54e48f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/sembuf.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SEMBUF_H +#define __ASM_GENERIC_SEMBUF_H + +#include +#include + +/* + * The semid64_ds structure for most architectures (though it came from x86_32 + * originally). Note extra padding because this structure is passed back and + * forth between kernel and user space. + * + * semid64_ds was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * 64 bit architectures use a 64-bit long time field here, while + * 32 bit architectures have a pair of unsigned long values. + * + * On big-endian systems, the padding is in the wrong place for + * historic reasons, so user space has to reconstruct a time_t + * value using + * + * user_semid_ds.sem_otime = kernel_semid64_ds.sem_otime + + * ((long long)kernel_semid64_ds.sem_otime_high << 32) + * + * Pad space is left for 2 miscellaneous 32-bit values + */ +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#if __BITS_PER_LONG == 64 + long sem_otime; /* last semop time */ + long sem_ctime; /* last change time */ +#else + unsigned long sem_otime; /* last semop time */ + unsigned long sem_otime_high; + unsigned long sem_ctime; /* last change time */ + unsigned long sem_ctime_high; +#endif + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif /* __ASM_GENERIC_SEMBUF_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/setup.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/setup.h new file mode 100755 index 0000000..88ac510 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/setup.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SETUP_H +#define __ASM_GENERIC_SETUP_H + +#define COMMAND_LINE_SIZE 512 + +#endif /* __ASM_GENERIC_SETUP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/shmbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/shmbuf.h new file mode 100755 index 0000000..2bab955 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/shmbuf.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SHMBUF_H +#define __ASM_GENERIC_SHMBUF_H + +#include + +/* + * The shmid64_ds structure for x86 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * shmid64_ds was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * 64 bit architectures use a 64-bit long time field here, while + * 32 bit architectures have a pair of unsigned long values. + * On big-endian systems, the lower half is in the wrong place. + * + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ +#if __BITS_PER_LONG == 64 + long shm_atime; /* last attach time */ + long shm_dtime; /* last detach time */ + long shm_ctime; /* last change time */ +#else + unsigned long shm_atime; /* last attach time */ + unsigned long shm_atime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_dtime_high; + unsigned long shm_ctime; /* last change time */ + unsigned long shm_ctime_high; +#endif + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused4; + unsigned long __unused5; +}; + +struct shminfo64 { + unsigned long shmmax; + unsigned long shmmin; + unsigned long shmmni; + unsigned long shmseg; + unsigned long shmall; + unsigned long __unused1; + unsigned long __unused2; + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif /* __ASM_GENERIC_SHMBUF_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/siginfo.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/siginfo.h new file mode 100755 index 0000000..0d245e3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/siginfo.h @@ -0,0 +1,353 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_SIGINFO_H +#define _ASM_GENERIC_SIGINFO_H + + +#include + +typedef union sigval { + int sival_int; + void *sival_ptr; +} sigval_t; + +#define SI_MAX_SIZE 128 + +/* + * The default "si_band" type is "long", as specified by POSIX. + * However, some architectures want to override this to "int" + * for historical compatibility reasons, so we allow that. + */ +#ifndef __ARCH_SI_BAND_T +#define __ARCH_SI_BAND_T long +#endif + +#ifndef __ARCH_SI_CLOCK_T +#define __ARCH_SI_CLOCK_T __kernel_clock_t +#endif + +#ifndef __ARCH_SI_ATTRIBUTES +#define __ARCH_SI_ATTRIBUTES +#endif + +/* + * Be careful when extending this union. On 32bit siginfo_t is 32bit + * aligned. Which means that a 64bit field or any other field that + * would increase the alignment of siginfo_t will break the ABI. + */ +union __sifields { + /* kill() */ + struct { + __kernel_pid_t _pid; /* sender's pid */ + __kernel_uid32_t _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + __kernel_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + __kernel_pid_t _pid; /* sender's pid */ + __kernel_uid32_t _uid; /* sender's uid */ + sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + __kernel_pid_t _pid; /* which child */ + __kernel_uid32_t _uid; /* sender's uid */ + int _status; /* exit code */ + __ARCH_SI_CLOCK_T _utime; + __ARCH_SI_CLOCK_T _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */ + struct { + void *_addr; /* faulting insn/memory ref. */ +#ifdef __ia64__ + int _imm; /* immediate value for "break" */ + unsigned int _flags; /* see ia64 si_flags */ + unsigned long _isr; /* isr */ +#endif + +#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \ + sizeof(short) : __alignof__(void *)) + union { + /* used on alpha and sparc */ + int _trapno; /* TRAP # which caused the signal */ + /* + * used when si_code=BUS_MCEERR_AR or + * used when si_code=BUS_MCEERR_AO + */ + short _addr_lsb; /* LSB of the reported address */ + /* used when si_code=SEGV_BNDERR */ + struct { + char _dummy_bnd[__ADDR_BND_PKEY_PAD]; + void *_lower; + void *_upper; + } _addr_bnd; + /* used when si_code=SEGV_PKUERR */ + struct { + char _dummy_pkey[__ADDR_BND_PKEY_PAD]; + __u32 _pkey; + } _addr_pkey; + /* used when si_code=TRAP_PERF */ + struct { + unsigned long _data; + __u32 _type; + } _perf; + }; + } _sigfault; + + /* SIGPOLL */ + struct { + __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + + /* SIGSYS */ + struct { + void *_call_addr; /* calling user insn */ + int _syscall; /* triggering system call number */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall */ + } _sigsys; +}; + +#ifndef __ARCH_HAS_SWAPPED_SIGINFO +#define __SIGINFO \ +struct { \ + int si_signo; \ + int si_errno; \ + int si_code; \ + union __sifields _sifields; \ +} +#else +#define __SIGINFO \ +struct { \ + int si_signo; \ + int si_code; \ + int si_errno; \ + union __sifields _sifields; \ +} +#endif /* __ARCH_HAS_SWAPPED_SIGINFO */ + +typedef struct siginfo { + union { + __SIGINFO; + int _si_pad[SI_MAX_SIZE/sizeof(int)]; + }; +} __ARCH_SI_ATTRIBUTES siginfo_t; + +/* + * How these fields are to be accessed. + */ +#define si_pid _sifields._kill._pid +#define si_uid _sifields._kill._uid +#define si_tid _sifields._timer._tid +#define si_overrun _sifields._timer._overrun +#define si_sys_private _sifields._timer._sys_private +#define si_status _sifields._sigchld._status +#define si_utime _sifields._sigchld._utime +#define si_stime _sifields._sigchld._stime +#define si_value _sifields._rt._sigval +#define si_int _sifields._rt._sigval.sival_int +#define si_ptr _sifields._rt._sigval.sival_ptr +#define si_addr _sifields._sigfault._addr +#define si_trapno _sifields._sigfault._trapno +#define si_addr_lsb _sifields._sigfault._addr_lsb +#define si_lower _sifields._sigfault._addr_bnd._lower +#define si_upper _sifields._sigfault._addr_bnd._upper +#define si_pkey _sifields._sigfault._addr_pkey._pkey +#define si_perf_data _sifields._sigfault._perf._data +#define si_perf_type _sifields._sigfault._perf._type +#define si_band _sifields._sigpoll._band +#define si_fd _sifields._sigpoll._fd +#define si_call_addr _sifields._sigsys._call_addr +#define si_syscall _sifields._sigsys._syscall +#define si_arch _sifields._sigsys._arch + +/* + * si_code values + * Digital reserves positive values for kernel-generated signals. + */ +#define SI_USER 0 /* sent by kill, sigsend, raise */ +#define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ +#define SI_QUEUE -1 /* sent by sigqueue */ +#define SI_TIMER -2 /* sent by timer expiration */ +#define SI_MESGQ -3 /* sent by real time mesq state change */ +#define SI_ASYNCIO -4 /* sent by AIO completion */ +#define SI_SIGIO -5 /* sent by queued SIGIO */ +#define SI_TKILL -6 /* sent by tkill system call */ +#define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */ +#define SI_ASYNCNL -60 /* sent by glibc async name lookup completion */ + +#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) +#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) + +/* + * SIGILL si_codes + */ +#define ILL_ILLOPC 1 /* illegal opcode */ +#define ILL_ILLOPN 2 /* illegal operand */ +#define ILL_ILLADR 3 /* illegal addressing mode */ +#define ILL_ILLTRP 4 /* illegal trap */ +#define ILL_PRVOPC 5 /* privileged opcode */ +#define ILL_PRVREG 6 /* privileged register */ +#define ILL_COPROC 7 /* coprocessor error */ +#define ILL_BADSTK 8 /* internal stack error */ +#define ILL_BADIADDR 9 /* unimplemented instruction address */ +#define __ILL_BREAK 10 /* illegal break */ +#define __ILL_BNDMOD 11 /* bundle-update (modification) in progress */ +#define NSIGILL 11 + +/* + * SIGFPE si_codes + */ +#define FPE_INTDIV 1 /* integer divide by zero */ +#define FPE_INTOVF 2 /* integer overflow */ +#define FPE_FLTDIV 3 /* floating point divide by zero */ +#define FPE_FLTOVF 4 /* floating point overflow */ +#define FPE_FLTUND 5 /* floating point underflow */ +#define FPE_FLTRES 6 /* floating point inexact result */ +#define FPE_FLTINV 7 /* floating point invalid operation */ +#define FPE_FLTSUB 8 /* subscript out of range */ +#define __FPE_DECOVF 9 /* decimal overflow */ +#define __FPE_DECDIV 10 /* decimal division by zero */ +#define __FPE_DECERR 11 /* packed decimal error */ +#define __FPE_INVASC 12 /* invalid ASCII digit */ +#define __FPE_INVDEC 13 /* invalid decimal digit */ +#define FPE_FLTUNK 14 /* undiagnosed floating-point exception */ +#define FPE_CONDTRAP 15 /* trap on condition */ +#define NSIGFPE 15 + +/* + * SIGSEGV si_codes + */ +#define SEGV_MAPERR 1 /* address not mapped to object */ +#define SEGV_ACCERR 2 /* invalid permissions for mapped object */ +#define SEGV_BNDERR 3 /* failed address bound checks */ +#ifdef __ia64__ +# define __SEGV_PSTKOVF 4 /* paragraph stack overflow */ +#else +# define SEGV_PKUERR 4 /* failed protection key checks */ +#endif +#define SEGV_ACCADI 5 /* ADI not enabled for mapped object */ +#define SEGV_ADIDERR 6 /* Disrupting MCD error */ +#define SEGV_ADIPERR 7 /* Precise MCD exception */ +#define SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */ +#define SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ +#define NSIGSEGV 9 + +/* + * SIGBUS si_codes + */ +#define BUS_ADRALN 1 /* invalid address alignment */ +#define BUS_ADRERR 2 /* non-existent physical address */ +#define BUS_OBJERR 3 /* object specific hardware error */ +/* hardware memory error consumed on a machine check: action required */ +#define BUS_MCEERR_AR 4 +/* hardware memory error detected in process but not consumed: action optional*/ +#define BUS_MCEERR_AO 5 +#define NSIGBUS 5 + +/* + * SIGTRAP si_codes + */ +#define TRAP_BRKPT 1 /* process breakpoint */ +#define TRAP_TRACE 2 /* process trace trap */ +#define TRAP_BRANCH 3 /* process taken branch trap */ +#define TRAP_HWBKPT 4 /* hardware breakpoint/watchpoint */ +#define TRAP_UNK 5 /* undiagnosed trap */ +#define TRAP_PERF 6 /* perf event with sigtrap=1 */ +#define NSIGTRAP 6 + +/* + * There is an additional set of SIGTRAP si_codes used by ptrace + * that are of the form: ((PTRACE_EVENT_XXX << 8) | SIGTRAP) + */ + +/* + * SIGCHLD si_codes + */ +#define CLD_EXITED 1 /* child has exited */ +#define CLD_KILLED 2 /* child was killed */ +#define CLD_DUMPED 3 /* child terminated abnormally */ +#define CLD_TRAPPED 4 /* traced child has trapped */ +#define CLD_STOPPED 5 /* child has stopped */ +#define CLD_CONTINUED 6 /* stopped child has continued */ +#define NSIGCHLD 6 + +/* + * SIGPOLL (or any other signal without signal specific si_codes) si_codes + */ +#define POLL_IN 1 /* data input available */ +#define POLL_OUT 2 /* output buffers available */ +#define POLL_MSG 3 /* input message available */ +#define POLL_ERR 4 /* i/o error */ +#define POLL_PRI 5 /* high priority input available */ +#define POLL_HUP 6 /* device disconnected */ +#define NSIGPOLL 6 + +/* + * SIGSYS si_codes + */ +#define SYS_SECCOMP 1 /* seccomp triggered */ +#define SYS_USER_DISPATCH 2 /* syscall user dispatch triggered */ +#define NSIGSYS 2 + +/* + * SIGEMT si_codes + */ +#define EMT_TAGOVF 1 /* tag overflow */ +#define NSIGEMT 1 + +/* + * sigevent definitions + * + * It seems likely that SIGEV_THREAD will have to be handled from + * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the + * thread manager then catches and does the appropriate nonsense. + * However, everything is written out here so as to not get lost. + */ +#define SIGEV_SIGNAL 0 /* notify via signal */ +#define SIGEV_NONE 1 /* other notification: meaningless */ +#define SIGEV_THREAD 2 /* deliver via thread creation */ +#define SIGEV_THREAD_ID 4 /* deliver to thread */ + +/* + * This works because the alignment is ok on all current architectures + * but we leave open this being overridden in the future + */ +#ifndef __ARCH_SIGEV_PREAMBLE_SIZE +#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t)) +#endif + +#define SIGEV_MAX_SIZE 64 +#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \ + / sizeof(int)) + +typedef struct sigevent { + sigval_t sigev_value; + int sigev_signo; + int sigev_notify; + union { + int _pad[SIGEV_PAD_SIZE]; + int _tid; + + struct { + void (*_function)(sigval_t); + void *_attribute; /* really pthread_attr_t */ + } _sigev_thread; + } _sigev_un; +} sigevent_t; + +#define sigev_notify_function _sigev_un._sigev_thread._function +#define sigev_notify_attributes _sigev_un._sigev_thread._attribute +#define sigev_notify_thread_id _sigev_un._tid + + +#endif /* _ASM_GENERIC_SIGINFO_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/signal-defs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/signal-defs.h new file mode 100755 index 0000000..57d529d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/signal-defs.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SIGNAL_DEFS_H +#define __ASM_GENERIC_SIGNAL_DEFS_H + + + +/* + * SA_FLAGS values: + * + * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. + * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. + * SA_SIGINFO delivers the signal with SIGINFO structs. + * SA_ONSTACK indicates that a registered stack_t will be used. + * SA_RESTART flag to get restarting signals (which were the default long ago) + * SA_NODEFER prevents the current signal from being masked in the handler. + * SA_RESETHAND clears the handler when the signal is delivered. + * SA_UNSUPPORTED is a flag bit that will never be supported. Kernels from + * before the introduction of SA_UNSUPPORTED did not clear unknown bits from + * sa_flags when read using the oldact argument to sigaction and rt_sigaction, + * so this bit allows flag bit support to be detected from userspace while + * allowing an old kernel to be distinguished from a kernel that supports every + * flag bit. + * SA_EXPOSE_TAGBITS exposes an architecture-defined set of tag bits in + * siginfo.si_addr. + * + * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single + * Unix names RESETHAND and NODEFER respectively. + */ +#ifndef SA_NOCLDSTOP +#define SA_NOCLDSTOP 0x00000001 +#endif +#ifndef SA_NOCLDWAIT +#define SA_NOCLDWAIT 0x00000002 +#endif +#ifndef SA_SIGINFO +#define SA_SIGINFO 0x00000004 +#endif +/* 0x00000008 used on alpha, mips, parisc */ +/* 0x00000010 used on alpha, parisc */ +/* 0x00000020 used on alpha, parisc, sparc */ +/* 0x00000040 used on alpha, parisc */ +/* 0x00000080 used on parisc */ +/* 0x00000100 used on sparc */ +/* 0x00000200 used on sparc */ +#define SA_UNSUPPORTED 0x00000400 +#define SA_EXPOSE_TAGBITS 0x00000800 +/* 0x00010000 used on mips */ +/* 0x01000000 used on x86 */ +/* 0x02000000 used on x86 */ +/* + * New architectures should not define the obsolete + * SA_RESTORER 0x04000000 + */ +#ifndef SA_ONSTACK +#define SA_ONSTACK 0x08000000 +#endif +#ifndef SA_RESTART +#define SA_RESTART 0x10000000 +#endif +#ifndef SA_NODEFER +#define SA_NODEFER 0x40000000 +#endif +#ifndef SA_RESETHAND +#define SA_RESETHAND 0x80000000 +#endif + +#define SA_NOMASK SA_NODEFER +#define SA_ONESHOT SA_RESETHAND + +#ifndef SIG_BLOCK +#define SIG_BLOCK 0 /* for blocking signals */ +#endif +#ifndef SIG_UNBLOCK +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#endif +#ifndef SIG_SETMASK +#define SIG_SETMASK 2 /* for setting the signal mask */ +#endif + +#ifndef __ASSEMBLY__ +typedef void __signalfn_t(int); +typedef __signalfn_t *__sighandler_t; + +typedef void __restorefn_t(void); +typedef __restorefn_t *__sigrestore_t; + +#define SIG_DFL ((__sighandler_t)0) /* default signal handling */ +#define SIG_IGN ((__sighandler_t)1) /* ignore signal */ +#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */ +#endif + +#endif /* __ASM_GENERIC_SIGNAL_DEFS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/signal.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/signal.h new file mode 100755 index 0000000..d97df1e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/signal.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SIGNAL_H +#define __ASM_GENERIC_SIGNAL_H + +#include + +#define _NSIG 64 +#define _NSIG_BPW __BITS_PER_LONG +#define _NSIG_WORDS (_NSIG / _NSIG_BPW) + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#ifndef SIGRTMAX +#define SIGRTMAX _NSIG +#endif + +#if !defined MINSIGSTKSZ || !defined SIGSTKSZ +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 +#endif + +#ifndef __ASSEMBLY__ +typedef struct { + unsigned long sig[_NSIG_WORDS]; +} sigset_t; + +/* not actually used, but required for linux/syscalls.h */ +typedef unsigned long old_sigset_t; + +#include + +#ifdef SA_RESTORER +#define __ARCH_HAS_SA_RESTORER +#endif + +struct sigaction { + __sighandler_t sa_handler; + unsigned long sa_flags; +#ifdef SA_RESTORER + __sigrestore_t sa_restorer; +#endif + sigset_t sa_mask; /* mask last for extensibility */ +}; + +typedef struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_GENERIC_SIGNAL_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/socket.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/socket.h new file mode 100755 index 0000000..496b045 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/socket.h @@ -0,0 +1,152 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SOCKET_H +#define __ASM_GENERIC_SOCKET_H + +#include +#include + +/* For setsockopt(2) */ +#define SOL_SOCKET 1 + +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_SNDBUFFORCE 32 +#define SO_RCVBUFFORCE 33 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +#define SO_REUSEPORT 15 +#ifndef SO_PASSCRED /* powerpc only differs in these */ +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO_OLD 20 +#define SO_SNDTIMEO_OLD 21 +#endif + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 + +#define SO_BINDTODEVICE 25 + +/* Socket filtering */ +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 +#define SO_GET_FILTER SO_ATTACH_FILTER + +#define SO_PEERNAME 28 + +#define SO_ACCEPTCONN 30 + +#define SO_PEERSEC 31 +#define SO_PASSSEC 34 + +#define SO_MARK 36 + +#define SO_PROTOCOL 38 +#define SO_DOMAIN 39 + +#define SO_RXQ_OVFL 40 + +#define SO_WIFI_STATUS 41 +#define SCM_WIFI_STATUS SO_WIFI_STATUS +#define SO_PEEK_OFF 42 + +/* Instruct lower device to use last 4-bytes of skb data as FCS */ +#define SO_NOFCS 43 + +#define SO_LOCK_FILTER 44 + +#define SO_SELECT_ERR_QUEUE 45 + +#define SO_BUSY_POLL 46 + +#define SO_MAX_PACING_RATE 47 + +#define SO_BPF_EXTENSIONS 48 + +#define SO_INCOMING_CPU 49 + +#define SO_ATTACH_BPF 50 +#define SO_DETACH_BPF SO_DETACH_FILTER + +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + +#define SO_CNX_ADVICE 53 + +#define SCM_TIMESTAMPING_OPT_STATS 54 + +#define SO_MEMINFO 55 + +#define SO_INCOMING_NAPI_ID 56 + +#define SO_COOKIE 57 + +#define SCM_TIMESTAMPING_PKTINFO 58 + +#define SO_PEERGROUPS 59 + +#define SO_ZEROCOPY 60 + +#define SO_TXTIME 61 +#define SCM_TXTIME SO_TXTIME + +#define SO_BINDTOIFINDEX 62 + +#define SO_TIMESTAMP_OLD 29 +#define SO_TIMESTAMPNS_OLD 35 +#define SO_TIMESTAMPING_OLD 37 + +#define SO_TIMESTAMP_NEW 63 +#define SO_TIMESTAMPNS_NEW 64 +#define SO_TIMESTAMPING_NEW 65 + +#define SO_RCVTIMEO_NEW 66 +#define SO_SNDTIMEO_NEW 67 + +#define SO_DETACH_REUSEPORT_BPF 68 + +#define SO_PREFER_BUSY_POLL 69 +#define SO_BUSY_POLL_BUDGET 70 + +#define SO_NETNS_COOKIE 71 + +#define SO_BUF_LOCK 72 + + +#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__)) +/* on 64-bit and x32, avoid the ?: operator */ +#define SO_TIMESTAMP SO_TIMESTAMP_OLD +#define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD +#define SO_TIMESTAMPING SO_TIMESTAMPING_OLD + +#define SO_RCVTIMEO SO_RCVTIMEO_OLD +#define SO_SNDTIMEO SO_SNDTIMEO_OLD +#else +#define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW) +#define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW) +#define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW) + +#define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW) +#define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW) +#endif + +#define SCM_TIMESTAMP SO_TIMESTAMP +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS +#define SCM_TIMESTAMPING SO_TIMESTAMPING + + +#endif /* __ASM_GENERIC_SOCKET_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/sockios.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/sockios.h new file mode 100755 index 0000000..44fa3ed --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/sockios.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_SOCKIOS_H +#define __ASM_GENERIC_SOCKIOS_H + +/* Socket-level I/O control calls. */ +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */ +#define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */ + +#endif /* __ASM_GENERIC_SOCKIOS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/stat.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/stat.h new file mode 100755 index 0000000..0d962ec --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/stat.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_STAT_H +#define __ASM_GENERIC_STAT_H + +/* + * Everybody gets this wrong and has to stick with it for all + * eternity. Hopefully, this version gets used by new architectures + * so they don't fall into the same traps. + * + * stat64 is copied from powerpc64, with explicit padding added. + * stat is the same structure layout on 64-bit, without the 'long long' + * types. + * + * By convention, 64 bit architectures use the stat interface, while + * 32 bit architectures use the stat64 interface. Note that we don't + * provide an __old_kernel_stat here, which new architecture should + * not have to start with. + */ + +#include + +#define STAT_HAVE_NSEC 1 + +struct stat { + unsigned long st_dev; /* Device. */ + unsigned long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ + unsigned long st_rdev; /* Device number, if device. */ + unsigned long __pad1; + long st_size; /* Size of file, in bytes. */ + int st_blksize; /* Optimal block size for I/O. */ + int __pad2; + long st_blocks; /* Number 512-byte blocks allocated. */ + long st_atime; /* Time of last access. */ + unsigned long st_atime_nsec; + long st_mtime; /* Time of last modification. */ + unsigned long st_mtime_nsec; + long st_ctime; /* Time of last status change. */ + unsigned long st_ctime_nsec; + unsigned int __unused4; + unsigned int __unused5; +}; + +/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */ +#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) +struct stat64 { + unsigned long long st_dev; /* Device. */ + unsigned long long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ + unsigned long long st_rdev; /* Device number, if device. */ + unsigned long long __pad1; + long long st_size; /* Size of file, in bytes. */ + int st_blksize; /* Optimal block size for I/O. */ + int __pad2; + long long st_blocks; /* Number 512-byte blocks allocated. */ + int st_atime; /* Time of last access. */ + unsigned int st_atime_nsec; + int st_mtime; /* Time of last modification. */ + unsigned int st_mtime_nsec; + int st_ctime; /* Time of last status change. */ + unsigned int st_ctime_nsec; + unsigned int __unused4; + unsigned int __unused5; +}; +#endif + +#endif /* __ASM_GENERIC_STAT_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/statfs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/statfs.h new file mode 100755 index 0000000..9749431 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/statfs.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _GENERIC_STATFS_H +#define _GENERIC_STATFS_H + +#include + + +/* + * Most 64-bit platforms use 'long', while most 32-bit platforms use '__u32'. + * Yes, they differ in signedness as well as size. + * Special cases can override it for themselves -- except for S390x, which + * is just a little too special for us. And MIPS, which I'm not touching + * with a 10' pole. + */ +#ifndef __statfs_word +#if __BITS_PER_LONG == 64 +#define __statfs_word __kernel_long_t +#else +#define __statfs_word __u32 +#endif +#endif + +struct statfs { + __statfs_word f_type; + __statfs_word f_bsize; + __statfs_word f_blocks; + __statfs_word f_bfree; + __statfs_word f_bavail; + __statfs_word f_files; + __statfs_word f_ffree; + __kernel_fsid_t f_fsid; + __statfs_word f_namelen; + __statfs_word f_frsize; + __statfs_word f_flags; + __statfs_word f_spare[4]; +}; + +/* + * ARM needs to avoid the 32-bit padding at the end, for consistency + * between EABI and OABI + */ +#ifndef ARCH_PACK_STATFS64 +#define ARCH_PACK_STATFS64 +#endif + +struct statfs64 { + __statfs_word f_type; + __statfs_word f_bsize; + __u64 f_blocks; + __u64 f_bfree; + __u64 f_bavail; + __u64 f_files; + __u64 f_ffree; + __kernel_fsid_t f_fsid; + __statfs_word f_namelen; + __statfs_word f_frsize; + __statfs_word f_flags; + __statfs_word f_spare[4]; +} ARCH_PACK_STATFS64; + +/* + * IA64 and x86_64 need to avoid the 32-bit padding at the end, + * to be compatible with the i386 ABI + */ +#ifndef ARCH_PACK_COMPAT_STATFS64 +#define ARCH_PACK_COMPAT_STATFS64 +#endif + +struct compat_statfs64 { + __u32 f_type; + __u32 f_bsize; + __u64 f_blocks; + __u64 f_bfree; + __u64 f_bavail; + __u64 f_files; + __u64 f_ffree; + __kernel_fsid_t f_fsid; + __u32 f_namelen; + __u32 f_frsize; + __u32 f_flags; + __u32 f_spare[4]; +} ARCH_PACK_COMPAT_STATFS64; + +#endif /* _GENERIC_STATFS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/swab.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/swab.h new file mode 100755 index 0000000..f2da4e4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/swab.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_SWAB_H +#define _ASM_GENERIC_SWAB_H + +#include + +/* + * 32 bit architectures typically (but not always) want to + * set __SWAB_64_THRU_32__. In user space, this is only + * valid if the compiler supports 64 bit data types. + */ + +#if __BITS_PER_LONG == 32 +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) +#define __SWAB_64_THRU_32__ +#endif +#endif + +#endif /* _ASM_GENERIC_SWAB_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/termbits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/termbits.h new file mode 100755 index 0000000..2fbaf9a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/termbits.h @@ -0,0 +1,200 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_TERMBITS_H +#define __ASM_GENERIC_TERMBITS_H + +#include + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +struct termios2 { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + +struct ktermios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 + +/* c_cflag bit meaning */ +#define CBAUD 0010017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CBAUDEX 0010000 +#define BOTHER 0010000 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 +#define CIBAUD 002003600000 /* input baud rate */ +#define CMSPAR 010000000000 /* mark or space (stick) parity */ +#define CRTSCTS 020000000000 /* flow control */ + +#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 +#define EXTPROC 0200000 + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +#endif /* __ASM_GENERIC_TERMBITS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/termios.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/termios.h new file mode 100755 index 0000000..8b538b9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/termios.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_TERMIOS_H +#define _ASM_GENERIC_TERMIOS_H +/* + * Most architectures have straight copies of the x86 code, with + * varying levels of bug fixes on top. Usually it's a good idea + * to use this generic version instead, but be careful to avoid + * ABI changes. + * New architectures should not provide their own version. + */ + +#include +#include + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + + +#endif /* _ASM_GENERIC_TERMIOS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/types.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/types.h new file mode 100755 index 0000000..dfaa50d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/types.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_TYPES_H +#define _ASM_GENERIC_TYPES_H +/* + * int-ll64 is used everywhere now. + */ +#include + +#endif /* _ASM_GENERIC_TYPES_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ucontext.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ucontext.h new file mode 100755 index 0000000..351868a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/ucontext.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_UCONTEXT_H +#define __ASM_GENERIC_UCONTEXT_H + +struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +}; + +#endif /* __ASM_GENERIC_UCONTEXT_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/unistd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/unistd.h new file mode 100755 index 0000000..1c5fb86 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm-generic/unistd.h @@ -0,0 +1,932 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include + +/* + * This file contains the system call numbers, based on the + * layout of the x86-64 architecture, which embeds the + * pointer to the syscall in the table. + * + * As a basic principle, no duplication of functionality + * should be added, e.g. we don't use lseek when llseek + * is present. New architectures should use this file + * and implement the less feature-full calls in user space. + */ + +#ifndef __SYSCALL +#define __SYSCALL(x, y) +#endif + +#if __BITS_PER_LONG == 32 || defined(__SYSCALL_COMPAT) +#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32) +#else +#define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64) +#endif + +#ifdef __SYSCALL_COMPAT +#define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _comp) +#define __SC_COMP_3264(_nr, _32, _64, _comp) __SYSCALL(_nr, _comp) +#else +#define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys) +#define __SC_COMP_3264(_nr, _32, _64, _comp) __SC_3264(_nr, _32, _64) +#endif + +#define __NR_io_setup 0 +__SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup) +#define __NR_io_destroy 1 +__SYSCALL(__NR_io_destroy, sys_io_destroy) +#define __NR_io_submit 2 +__SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit) +#define __NR_io_cancel 3 +__SYSCALL(__NR_io_cancel, sys_io_cancel) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_io_getevents 4 +__SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents) +#endif + +/* fs/xattr.c */ +#define __NR_setxattr 5 +__SYSCALL(__NR_setxattr, sys_setxattr) +#define __NR_lsetxattr 6 +__SYSCALL(__NR_lsetxattr, sys_lsetxattr) +#define __NR_fsetxattr 7 +__SYSCALL(__NR_fsetxattr, sys_fsetxattr) +#define __NR_getxattr 8 +__SYSCALL(__NR_getxattr, sys_getxattr) +#define __NR_lgetxattr 9 +__SYSCALL(__NR_lgetxattr, sys_lgetxattr) +#define __NR_fgetxattr 10 +__SYSCALL(__NR_fgetxattr, sys_fgetxattr) +#define __NR_listxattr 11 +__SYSCALL(__NR_listxattr, sys_listxattr) +#define __NR_llistxattr 12 +__SYSCALL(__NR_llistxattr, sys_llistxattr) +#define __NR_flistxattr 13 +__SYSCALL(__NR_flistxattr, sys_flistxattr) +#define __NR_removexattr 14 +__SYSCALL(__NR_removexattr, sys_removexattr) +#define __NR_lremovexattr 15 +__SYSCALL(__NR_lremovexattr, sys_lremovexattr) +#define __NR_fremovexattr 16 +__SYSCALL(__NR_fremovexattr, sys_fremovexattr) + +/* fs/dcache.c */ +#define __NR_getcwd 17 +__SYSCALL(__NR_getcwd, sys_getcwd) + +/* fs/cookies.c */ +#define __NR_lookup_dcookie 18 +__SC_COMP(__NR_lookup_dcookie, sys_lookup_dcookie, compat_sys_lookup_dcookie) + +/* fs/eventfd.c */ +#define __NR_eventfd2 19 +__SYSCALL(__NR_eventfd2, sys_eventfd2) + +/* fs/eventpoll.c */ +#define __NR_epoll_create1 20 +__SYSCALL(__NR_epoll_create1, sys_epoll_create1) +#define __NR_epoll_ctl 21 +__SYSCALL(__NR_epoll_ctl, sys_epoll_ctl) +#define __NR_epoll_pwait 22 +__SC_COMP(__NR_epoll_pwait, sys_epoll_pwait, compat_sys_epoll_pwait) + +/* fs/fcntl.c */ +#define __NR_dup 23 +__SYSCALL(__NR_dup, sys_dup) +#define __NR_dup3 24 +__SYSCALL(__NR_dup3, sys_dup3) +#define __NR3264_fcntl 25 +__SC_COMP_3264(__NR3264_fcntl, sys_fcntl64, sys_fcntl, compat_sys_fcntl64) + +/* fs/inotify_user.c */ +#define __NR_inotify_init1 26 +__SYSCALL(__NR_inotify_init1, sys_inotify_init1) +#define __NR_inotify_add_watch 27 +__SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch) +#define __NR_inotify_rm_watch 28 +__SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch) + +/* fs/ioctl.c */ +#define __NR_ioctl 29 +__SC_COMP(__NR_ioctl, sys_ioctl, compat_sys_ioctl) + +/* fs/ioprio.c */ +#define __NR_ioprio_set 30 +__SYSCALL(__NR_ioprio_set, sys_ioprio_set) +#define __NR_ioprio_get 31 +__SYSCALL(__NR_ioprio_get, sys_ioprio_get) + +/* fs/locks.c */ +#define __NR_flock 32 +__SYSCALL(__NR_flock, sys_flock) + +/* fs/namei.c */ +#define __NR_mknodat 33 +__SYSCALL(__NR_mknodat, sys_mknodat) +#define __NR_mkdirat 34 +__SYSCALL(__NR_mkdirat, sys_mkdirat) +#define __NR_unlinkat 35 +__SYSCALL(__NR_unlinkat, sys_unlinkat) +#define __NR_symlinkat 36 +__SYSCALL(__NR_symlinkat, sys_symlinkat) +#define __NR_linkat 37 +__SYSCALL(__NR_linkat, sys_linkat) +#ifdef __ARCH_WANT_RENAMEAT +/* renameat is superseded with flags by renameat2 */ +#define __NR_renameat 38 +__SYSCALL(__NR_renameat, sys_renameat) +#endif /* __ARCH_WANT_RENAMEAT */ + +/* fs/namespace.c */ +#define __NR_umount2 39 +__SYSCALL(__NR_umount2, sys_umount) +#define __NR_mount 40 +__SYSCALL(__NR_mount, sys_mount) +#define __NR_pivot_root 41 +__SYSCALL(__NR_pivot_root, sys_pivot_root) + +/* fs/nfsctl.c */ +#define __NR_nfsservctl 42 +__SYSCALL(__NR_nfsservctl, sys_ni_syscall) + +/* fs/open.c */ +#define __NR3264_statfs 43 +__SC_COMP_3264(__NR3264_statfs, sys_statfs64, sys_statfs, \ + compat_sys_statfs64) +#define __NR3264_fstatfs 44 +__SC_COMP_3264(__NR3264_fstatfs, sys_fstatfs64, sys_fstatfs, \ + compat_sys_fstatfs64) +#define __NR3264_truncate 45 +__SC_COMP_3264(__NR3264_truncate, sys_truncate64, sys_truncate, \ + compat_sys_truncate64) +#define __NR3264_ftruncate 46 +__SC_COMP_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate, \ + compat_sys_ftruncate64) + +#define __NR_fallocate 47 +__SC_COMP(__NR_fallocate, sys_fallocate, compat_sys_fallocate) +#define __NR_faccessat 48 +__SYSCALL(__NR_faccessat, sys_faccessat) +#define __NR_chdir 49 +__SYSCALL(__NR_chdir, sys_chdir) +#define __NR_fchdir 50 +__SYSCALL(__NR_fchdir, sys_fchdir) +#define __NR_chroot 51 +__SYSCALL(__NR_chroot, sys_chroot) +#define __NR_fchmod 52 +__SYSCALL(__NR_fchmod, sys_fchmod) +#define __NR_fchmodat 53 +__SYSCALL(__NR_fchmodat, sys_fchmodat) +#define __NR_fchownat 54 +__SYSCALL(__NR_fchownat, sys_fchownat) +#define __NR_fchown 55 +__SYSCALL(__NR_fchown, sys_fchown) +#define __NR_openat 56 +__SYSCALL(__NR_openat, sys_openat) +#define __NR_close 57 +__SYSCALL(__NR_close, sys_close) +#define __NR_vhangup 58 +__SYSCALL(__NR_vhangup, sys_vhangup) + +/* fs/pipe.c */ +#define __NR_pipe2 59 +__SYSCALL(__NR_pipe2, sys_pipe2) + +/* fs/quota.c */ +#define __NR_quotactl 60 +__SYSCALL(__NR_quotactl, sys_quotactl) + +/* fs/readdir.c */ +#define __NR_getdents64 61 +__SYSCALL(__NR_getdents64, sys_getdents64) + +/* fs/read_write.c */ +#define __NR3264_lseek 62 +__SC_3264(__NR3264_lseek, sys_llseek, sys_lseek) +#define __NR_read 63 +__SYSCALL(__NR_read, sys_read) +#define __NR_write 64 +__SYSCALL(__NR_write, sys_write) +#define __NR_readv 65 +__SC_COMP(__NR_readv, sys_readv, sys_readv) +#define __NR_writev 66 +__SC_COMP(__NR_writev, sys_writev, sys_writev) +#define __NR_pread64 67 +__SC_COMP(__NR_pread64, sys_pread64, compat_sys_pread64) +#define __NR_pwrite64 68 +__SC_COMP(__NR_pwrite64, sys_pwrite64, compat_sys_pwrite64) +#define __NR_preadv 69 +__SC_COMP(__NR_preadv, sys_preadv, compat_sys_preadv) +#define __NR_pwritev 70 +__SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev) + +/* fs/sendfile.c */ +#define __NR3264_sendfile 71 +__SYSCALL(__NR3264_sendfile, sys_sendfile64) + +/* fs/select.c */ +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_pselect6 72 +__SC_COMP_3264(__NR_pselect6, sys_pselect6_time32, sys_pselect6, compat_sys_pselect6_time32) +#define __NR_ppoll 73 +__SC_COMP_3264(__NR_ppoll, sys_ppoll_time32, sys_ppoll, compat_sys_ppoll_time32) +#endif + +/* fs/signalfd.c */ +#define __NR_signalfd4 74 +__SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4) + +/* fs/splice.c */ +#define __NR_vmsplice 75 +__SYSCALL(__NR_vmsplice, sys_vmsplice) +#define __NR_splice 76 +__SYSCALL(__NR_splice, sys_splice) +#define __NR_tee 77 +__SYSCALL(__NR_tee, sys_tee) + +/* fs/stat.c */ +#define __NR_readlinkat 78 +__SYSCALL(__NR_readlinkat, sys_readlinkat) +#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) +#define __NR3264_fstatat 79 +__SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat) +#define __NR3264_fstat 80 +__SC_3264(__NR3264_fstat, sys_fstat64, sys_newfstat) +#endif + +/* fs/sync.c */ +#define __NR_sync 81 +__SYSCALL(__NR_sync, sys_sync) +#define __NR_fsync 82 +__SYSCALL(__NR_fsync, sys_fsync) +#define __NR_fdatasync 83 +__SYSCALL(__NR_fdatasync, sys_fdatasync) +#ifdef __ARCH_WANT_SYNC_FILE_RANGE2 +#define __NR_sync_file_range2 84 +__SC_COMP(__NR_sync_file_range2, sys_sync_file_range2, \ + compat_sys_sync_file_range2) +#else +#define __NR_sync_file_range 84 +__SC_COMP(__NR_sync_file_range, sys_sync_file_range, \ + compat_sys_sync_file_range) +#endif + +/* fs/timerfd.c */ +#define __NR_timerfd_create 85 +__SYSCALL(__NR_timerfd_create, sys_timerfd_create) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_timerfd_settime 86 +__SC_3264(__NR_timerfd_settime, sys_timerfd_settime32, \ + sys_timerfd_settime) +#define __NR_timerfd_gettime 87 +__SC_3264(__NR_timerfd_gettime, sys_timerfd_gettime32, \ + sys_timerfd_gettime) +#endif + +/* fs/utimes.c */ +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_utimensat 88 +__SC_3264(__NR_utimensat, sys_utimensat_time32, sys_utimensat) +#endif + +/* kernel/acct.c */ +#define __NR_acct 89 +__SYSCALL(__NR_acct, sys_acct) + +/* kernel/capability.c */ +#define __NR_capget 90 +__SYSCALL(__NR_capget, sys_capget) +#define __NR_capset 91 +__SYSCALL(__NR_capset, sys_capset) + +/* kernel/exec_domain.c */ +#define __NR_personality 92 +__SYSCALL(__NR_personality, sys_personality) + +/* kernel/exit.c */ +#define __NR_exit 93 +__SYSCALL(__NR_exit, sys_exit) +#define __NR_exit_group 94 +__SYSCALL(__NR_exit_group, sys_exit_group) +#define __NR_waitid 95 +__SC_COMP(__NR_waitid, sys_waitid, compat_sys_waitid) + +/* kernel/fork.c */ +#define __NR_set_tid_address 96 +__SYSCALL(__NR_set_tid_address, sys_set_tid_address) +#define __NR_unshare 97 +__SYSCALL(__NR_unshare, sys_unshare) + +/* kernel/futex.c */ +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_futex 98 +__SC_3264(__NR_futex, sys_futex_time32, sys_futex) +#endif +#define __NR_set_robust_list 99 +__SC_COMP(__NR_set_robust_list, sys_set_robust_list, \ + compat_sys_set_robust_list) +#define __NR_get_robust_list 100 +__SC_COMP(__NR_get_robust_list, sys_get_robust_list, \ + compat_sys_get_robust_list) + +/* kernel/hrtimer.c */ +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_nanosleep 101 +__SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) +#endif + +/* kernel/itimer.c */ +#define __NR_getitimer 102 +__SC_COMP(__NR_getitimer, sys_getitimer, compat_sys_getitimer) +#define __NR_setitimer 103 +__SC_COMP(__NR_setitimer, sys_setitimer, compat_sys_setitimer) + +/* kernel/kexec.c */ +#define __NR_kexec_load 104 +__SC_COMP(__NR_kexec_load, sys_kexec_load, compat_sys_kexec_load) + +/* kernel/module.c */ +#define __NR_init_module 105 +__SYSCALL(__NR_init_module, sys_init_module) +#define __NR_delete_module 106 +__SYSCALL(__NR_delete_module, sys_delete_module) + +/* kernel/posix-timers.c */ +#define __NR_timer_create 107 +__SC_COMP(__NR_timer_create, sys_timer_create, compat_sys_timer_create) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_timer_gettime 108 +__SC_3264(__NR_timer_gettime, sys_timer_gettime32, sys_timer_gettime) +#endif +#define __NR_timer_getoverrun 109 +__SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_timer_settime 110 +__SC_3264(__NR_timer_settime, sys_timer_settime32, sys_timer_settime) +#endif +#define __NR_timer_delete 111 +__SYSCALL(__NR_timer_delete, sys_timer_delete) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_clock_settime 112 +__SC_3264(__NR_clock_settime, sys_clock_settime32, sys_clock_settime) +#define __NR_clock_gettime 113 +__SC_3264(__NR_clock_gettime, sys_clock_gettime32, sys_clock_gettime) +#define __NR_clock_getres 114 +__SC_3264(__NR_clock_getres, sys_clock_getres_time32, sys_clock_getres) +#define __NR_clock_nanosleep 115 +__SC_3264(__NR_clock_nanosleep, sys_clock_nanosleep_time32, \ + sys_clock_nanosleep) +#endif + +/* kernel/printk.c */ +#define __NR_syslog 116 +__SYSCALL(__NR_syslog, sys_syslog) + +/* kernel/ptrace.c */ +#define __NR_ptrace 117 +__SYSCALL(__NR_ptrace, sys_ptrace) + +/* kernel/sched/core.c */ +#define __NR_sched_setparam 118 +__SYSCALL(__NR_sched_setparam, sys_sched_setparam) +#define __NR_sched_setscheduler 119 +__SYSCALL(__NR_sched_setscheduler, sys_sched_setscheduler) +#define __NR_sched_getscheduler 120 +__SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler) +#define __NR_sched_getparam 121 +__SYSCALL(__NR_sched_getparam, sys_sched_getparam) +#define __NR_sched_setaffinity 122 +__SC_COMP(__NR_sched_setaffinity, sys_sched_setaffinity, \ + compat_sys_sched_setaffinity) +#define __NR_sched_getaffinity 123 +__SC_COMP(__NR_sched_getaffinity, sys_sched_getaffinity, \ + compat_sys_sched_getaffinity) +#define __NR_sched_yield 124 +__SYSCALL(__NR_sched_yield, sys_sched_yield) +#define __NR_sched_get_priority_max 125 +__SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max) +#define __NR_sched_get_priority_min 126 +__SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_sched_rr_get_interval 127 +__SC_3264(__NR_sched_rr_get_interval, sys_sched_rr_get_interval_time32, \ + sys_sched_rr_get_interval) +#endif + +/* kernel/signal.c */ +#define __NR_restart_syscall 128 +__SYSCALL(__NR_restart_syscall, sys_restart_syscall) +#define __NR_kill 129 +__SYSCALL(__NR_kill, sys_kill) +#define __NR_tkill 130 +__SYSCALL(__NR_tkill, sys_tkill) +#define __NR_tgkill 131 +__SYSCALL(__NR_tgkill, sys_tgkill) +#define __NR_sigaltstack 132 +__SC_COMP(__NR_sigaltstack, sys_sigaltstack, compat_sys_sigaltstack) +#define __NR_rt_sigsuspend 133 +__SC_COMP(__NR_rt_sigsuspend, sys_rt_sigsuspend, compat_sys_rt_sigsuspend) +#define __NR_rt_sigaction 134 +__SC_COMP(__NR_rt_sigaction, sys_rt_sigaction, compat_sys_rt_sigaction) +#define __NR_rt_sigprocmask 135 +__SC_COMP(__NR_rt_sigprocmask, sys_rt_sigprocmask, compat_sys_rt_sigprocmask) +#define __NR_rt_sigpending 136 +__SC_COMP(__NR_rt_sigpending, sys_rt_sigpending, compat_sys_rt_sigpending) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_rt_sigtimedwait 137 +__SC_COMP_3264(__NR_rt_sigtimedwait, sys_rt_sigtimedwait_time32, \ + sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time32) +#endif +#define __NR_rt_sigqueueinfo 138 +__SC_COMP(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo, \ + compat_sys_rt_sigqueueinfo) +#define __NR_rt_sigreturn 139 +__SC_COMP(__NR_rt_sigreturn, sys_rt_sigreturn, compat_sys_rt_sigreturn) + +/* kernel/sys.c */ +#define __NR_setpriority 140 +__SYSCALL(__NR_setpriority, sys_setpriority) +#define __NR_getpriority 141 +__SYSCALL(__NR_getpriority, sys_getpriority) +#define __NR_reboot 142 +__SYSCALL(__NR_reboot, sys_reboot) +#define __NR_setregid 143 +__SYSCALL(__NR_setregid, sys_setregid) +#define __NR_setgid 144 +__SYSCALL(__NR_setgid, sys_setgid) +#define __NR_setreuid 145 +__SYSCALL(__NR_setreuid, sys_setreuid) +#define __NR_setuid 146 +__SYSCALL(__NR_setuid, sys_setuid) +#define __NR_setresuid 147 +__SYSCALL(__NR_setresuid, sys_setresuid) +#define __NR_getresuid 148 +__SYSCALL(__NR_getresuid, sys_getresuid) +#define __NR_setresgid 149 +__SYSCALL(__NR_setresgid, sys_setresgid) +#define __NR_getresgid 150 +__SYSCALL(__NR_getresgid, sys_getresgid) +#define __NR_setfsuid 151 +__SYSCALL(__NR_setfsuid, sys_setfsuid) +#define __NR_setfsgid 152 +__SYSCALL(__NR_setfsgid, sys_setfsgid) +#define __NR_times 153 +__SC_COMP(__NR_times, sys_times, compat_sys_times) +#define __NR_setpgid 154 +__SYSCALL(__NR_setpgid, sys_setpgid) +#define __NR_getpgid 155 +__SYSCALL(__NR_getpgid, sys_getpgid) +#define __NR_getsid 156 +__SYSCALL(__NR_getsid, sys_getsid) +#define __NR_setsid 157 +__SYSCALL(__NR_setsid, sys_setsid) +#define __NR_getgroups 158 +__SYSCALL(__NR_getgroups, sys_getgroups) +#define __NR_setgroups 159 +__SYSCALL(__NR_setgroups, sys_setgroups) +#define __NR_uname 160 +__SYSCALL(__NR_uname, sys_newuname) +#define __NR_sethostname 161 +__SYSCALL(__NR_sethostname, sys_sethostname) +#define __NR_setdomainname 162 +__SYSCALL(__NR_setdomainname, sys_setdomainname) + +#ifdef __ARCH_WANT_SET_GET_RLIMIT +/* getrlimit and setrlimit are superseded with prlimit64 */ +#define __NR_getrlimit 163 +__SC_COMP(__NR_getrlimit, sys_getrlimit, compat_sys_getrlimit) +#define __NR_setrlimit 164 +__SC_COMP(__NR_setrlimit, sys_setrlimit, compat_sys_setrlimit) +#endif + +#define __NR_getrusage 165 +__SC_COMP(__NR_getrusage, sys_getrusage, compat_sys_getrusage) +#define __NR_umask 166 +__SYSCALL(__NR_umask, sys_umask) +#define __NR_prctl 167 +__SYSCALL(__NR_prctl, sys_prctl) +#define __NR_getcpu 168 +__SYSCALL(__NR_getcpu, sys_getcpu) + +/* kernel/time.c */ +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_gettimeofday 169 +__SC_COMP(__NR_gettimeofday, sys_gettimeofday, compat_sys_gettimeofday) +#define __NR_settimeofday 170 +__SC_COMP(__NR_settimeofday, sys_settimeofday, compat_sys_settimeofday) +#define __NR_adjtimex 171 +__SC_3264(__NR_adjtimex, sys_adjtimex_time32, sys_adjtimex) +#endif + +/* kernel/sys.c */ +#define __NR_getpid 172 +__SYSCALL(__NR_getpid, sys_getpid) +#define __NR_getppid 173 +__SYSCALL(__NR_getppid, sys_getppid) +#define __NR_getuid 174 +__SYSCALL(__NR_getuid, sys_getuid) +#define __NR_geteuid 175 +__SYSCALL(__NR_geteuid, sys_geteuid) +#define __NR_getgid 176 +__SYSCALL(__NR_getgid, sys_getgid) +#define __NR_getegid 177 +__SYSCALL(__NR_getegid, sys_getegid) +#define __NR_gettid 178 +__SYSCALL(__NR_gettid, sys_gettid) +#define __NR_sysinfo 179 +__SC_COMP(__NR_sysinfo, sys_sysinfo, compat_sys_sysinfo) + +/* ipc/mqueue.c */ +#define __NR_mq_open 180 +__SC_COMP(__NR_mq_open, sys_mq_open, compat_sys_mq_open) +#define __NR_mq_unlink 181 +__SYSCALL(__NR_mq_unlink, sys_mq_unlink) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_mq_timedsend 182 +__SC_3264(__NR_mq_timedsend, sys_mq_timedsend_time32, sys_mq_timedsend) +#define __NR_mq_timedreceive 183 +__SC_3264(__NR_mq_timedreceive, sys_mq_timedreceive_time32, \ + sys_mq_timedreceive) +#endif +#define __NR_mq_notify 184 +__SC_COMP(__NR_mq_notify, sys_mq_notify, compat_sys_mq_notify) +#define __NR_mq_getsetattr 185 +__SC_COMP(__NR_mq_getsetattr, sys_mq_getsetattr, compat_sys_mq_getsetattr) + +/* ipc/msg.c */ +#define __NR_msgget 186 +__SYSCALL(__NR_msgget, sys_msgget) +#define __NR_msgctl 187 +__SC_COMP(__NR_msgctl, sys_msgctl, compat_sys_msgctl) +#define __NR_msgrcv 188 +__SC_COMP(__NR_msgrcv, sys_msgrcv, compat_sys_msgrcv) +#define __NR_msgsnd 189 +__SC_COMP(__NR_msgsnd, sys_msgsnd, compat_sys_msgsnd) + +/* ipc/sem.c */ +#define __NR_semget 190 +__SYSCALL(__NR_semget, sys_semget) +#define __NR_semctl 191 +__SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_semtimedop 192 +__SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop) +#endif +#define __NR_semop 193 +__SYSCALL(__NR_semop, sys_semop) + +/* ipc/shm.c */ +#define __NR_shmget 194 +__SYSCALL(__NR_shmget, sys_shmget) +#define __NR_shmctl 195 +__SC_COMP(__NR_shmctl, sys_shmctl, compat_sys_shmctl) +#define __NR_shmat 196 +__SC_COMP(__NR_shmat, sys_shmat, compat_sys_shmat) +#define __NR_shmdt 197 +__SYSCALL(__NR_shmdt, sys_shmdt) + +/* net/socket.c */ +#define __NR_socket 198 +__SYSCALL(__NR_socket, sys_socket) +#define __NR_socketpair 199 +__SYSCALL(__NR_socketpair, sys_socketpair) +#define __NR_bind 200 +__SYSCALL(__NR_bind, sys_bind) +#define __NR_listen 201 +__SYSCALL(__NR_listen, sys_listen) +#define __NR_accept 202 +__SYSCALL(__NR_accept, sys_accept) +#define __NR_connect 203 +__SYSCALL(__NR_connect, sys_connect) +#define __NR_getsockname 204 +__SYSCALL(__NR_getsockname, sys_getsockname) +#define __NR_getpeername 205 +__SYSCALL(__NR_getpeername, sys_getpeername) +#define __NR_sendto 206 +__SYSCALL(__NR_sendto, sys_sendto) +#define __NR_recvfrom 207 +__SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom) +#define __NR_setsockopt 208 +__SC_COMP(__NR_setsockopt, sys_setsockopt, sys_setsockopt) +#define __NR_getsockopt 209 +__SC_COMP(__NR_getsockopt, sys_getsockopt, sys_getsockopt) +#define __NR_shutdown 210 +__SYSCALL(__NR_shutdown, sys_shutdown) +#define __NR_sendmsg 211 +__SC_COMP(__NR_sendmsg, sys_sendmsg, compat_sys_sendmsg) +#define __NR_recvmsg 212 +__SC_COMP(__NR_recvmsg, sys_recvmsg, compat_sys_recvmsg) + +/* mm/filemap.c */ +#define __NR_readahead 213 +__SC_COMP(__NR_readahead, sys_readahead, compat_sys_readahead) + +/* mm/nommu.c, also with MMU */ +#define __NR_brk 214 +__SYSCALL(__NR_brk, sys_brk) +#define __NR_munmap 215 +__SYSCALL(__NR_munmap, sys_munmap) +#define __NR_mremap 216 +__SYSCALL(__NR_mremap, sys_mremap) + +/* security/keys/keyctl.c */ +#define __NR_add_key 217 +__SYSCALL(__NR_add_key, sys_add_key) +#define __NR_request_key 218 +__SYSCALL(__NR_request_key, sys_request_key) +#define __NR_keyctl 219 +__SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl) + +/* arch/example/kernel/sys_example.c */ +#define __NR_clone 220 +__SYSCALL(__NR_clone, sys_clone) +#define __NR_execve 221 +__SC_COMP(__NR_execve, sys_execve, compat_sys_execve) + +#define __NR3264_mmap 222 +__SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap) +/* mm/fadvise.c */ +#define __NR3264_fadvise64 223 +__SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64) + +/* mm/, CONFIG_MMU only */ +#ifndef __ARCH_NOMMU +#define __NR_swapon 224 +__SYSCALL(__NR_swapon, sys_swapon) +#define __NR_swapoff 225 +__SYSCALL(__NR_swapoff, sys_swapoff) +#define __NR_mprotect 226 +__SYSCALL(__NR_mprotect, sys_mprotect) +#define __NR_msync 227 +__SYSCALL(__NR_msync, sys_msync) +#define __NR_mlock 228 +__SYSCALL(__NR_mlock, sys_mlock) +#define __NR_munlock 229 +__SYSCALL(__NR_munlock, sys_munlock) +#define __NR_mlockall 230 +__SYSCALL(__NR_mlockall, sys_mlockall) +#define __NR_munlockall 231 +__SYSCALL(__NR_munlockall, sys_munlockall) +#define __NR_mincore 232 +__SYSCALL(__NR_mincore, sys_mincore) +#define __NR_madvise 233 +__SYSCALL(__NR_madvise, sys_madvise) +#define __NR_remap_file_pages 234 +__SYSCALL(__NR_remap_file_pages, sys_remap_file_pages) +#define __NR_mbind 235 +__SYSCALL(__NR_mbind, sys_mbind) +#define __NR_get_mempolicy 236 +__SYSCALL(__NR_get_mempolicy, sys_get_mempolicy) +#define __NR_set_mempolicy 237 +__SYSCALL(__NR_set_mempolicy, sys_set_mempolicy) +#define __NR_migrate_pages 238 +__SYSCALL(__NR_migrate_pages, sys_migrate_pages) +#define __NR_move_pages 239 +__SYSCALL(__NR_move_pages, sys_move_pages) +#endif + +#define __NR_rt_tgsigqueueinfo 240 +__SC_COMP(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, \ + compat_sys_rt_tgsigqueueinfo) +#define __NR_perf_event_open 241 +__SYSCALL(__NR_perf_event_open, sys_perf_event_open) +#define __NR_accept4 242 +__SYSCALL(__NR_accept4, sys_accept4) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_recvmmsg 243 +__SC_COMP_3264(__NR_recvmmsg, sys_recvmmsg_time32, sys_recvmmsg, compat_sys_recvmmsg_time32) +#endif + +/* + * Architectures may provide up to 16 syscalls of their own + * starting with this value. + */ +#define __NR_arch_specific_syscall 244 + +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_wait4 260 +__SC_COMP(__NR_wait4, sys_wait4, compat_sys_wait4) +#endif +#define __NR_prlimit64 261 +__SYSCALL(__NR_prlimit64, sys_prlimit64) +#define __NR_fanotify_init 262 +__SYSCALL(__NR_fanotify_init, sys_fanotify_init) +#define __NR_fanotify_mark 263 +__SYSCALL(__NR_fanotify_mark, sys_fanotify_mark) +#define __NR_name_to_handle_at 264 +__SYSCALL(__NR_name_to_handle_at, sys_name_to_handle_at) +#define __NR_open_by_handle_at 265 +__SYSCALL(__NR_open_by_handle_at, sys_open_by_handle_at) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_clock_adjtime 266 +__SC_3264(__NR_clock_adjtime, sys_clock_adjtime32, sys_clock_adjtime) +#endif +#define __NR_syncfs 267 +__SYSCALL(__NR_syncfs, sys_syncfs) +#define __NR_setns 268 +__SYSCALL(__NR_setns, sys_setns) +#define __NR_sendmmsg 269 +__SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg) +#define __NR_process_vm_readv 270 +__SYSCALL(__NR_process_vm_readv, sys_process_vm_readv) +#define __NR_process_vm_writev 271 +__SYSCALL(__NR_process_vm_writev, sys_process_vm_writev) +#define __NR_kcmp 272 +__SYSCALL(__NR_kcmp, sys_kcmp) +#define __NR_finit_module 273 +__SYSCALL(__NR_finit_module, sys_finit_module) +#define __NR_sched_setattr 274 +__SYSCALL(__NR_sched_setattr, sys_sched_setattr) +#define __NR_sched_getattr 275 +__SYSCALL(__NR_sched_getattr, sys_sched_getattr) +#define __NR_renameat2 276 +__SYSCALL(__NR_renameat2, sys_renameat2) +#define __NR_seccomp 277 +__SYSCALL(__NR_seccomp, sys_seccomp) +#define __NR_getrandom 278 +__SYSCALL(__NR_getrandom, sys_getrandom) +#define __NR_memfd_create 279 +__SYSCALL(__NR_memfd_create, sys_memfd_create) +#define __NR_bpf 280 +__SYSCALL(__NR_bpf, sys_bpf) +#define __NR_execveat 281 +__SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat) +#define __NR_userfaultfd 282 +__SYSCALL(__NR_userfaultfd, sys_userfaultfd) +#define __NR_membarrier 283 +__SYSCALL(__NR_membarrier, sys_membarrier) +#define __NR_mlock2 284 +__SYSCALL(__NR_mlock2, sys_mlock2) +#define __NR_copy_file_range 285 +__SYSCALL(__NR_copy_file_range, sys_copy_file_range) +#define __NR_preadv2 286 +__SC_COMP(__NR_preadv2, sys_preadv2, compat_sys_preadv2) +#define __NR_pwritev2 287 +__SC_COMP(__NR_pwritev2, sys_pwritev2, compat_sys_pwritev2) +#define __NR_pkey_mprotect 288 +__SYSCALL(__NR_pkey_mprotect, sys_pkey_mprotect) +#define __NR_pkey_alloc 289 +__SYSCALL(__NR_pkey_alloc, sys_pkey_alloc) +#define __NR_pkey_free 290 +__SYSCALL(__NR_pkey_free, sys_pkey_free) +#define __NR_statx 291 +__SYSCALL(__NR_statx, sys_statx) +#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 +#define __NR_io_pgetevents 292 +__SC_COMP_3264(__NR_io_pgetevents, sys_io_pgetevents_time32, sys_io_pgetevents, compat_sys_io_pgetevents) +#endif +#define __NR_rseq 293 +__SYSCALL(__NR_rseq, sys_rseq) +#define __NR_kexec_file_load 294 +__SYSCALL(__NR_kexec_file_load, sys_kexec_file_load) +/* 295 through 402 are unassigned to sync up with generic numbers, don't use */ +#if __BITS_PER_LONG == 32 +#define __NR_clock_gettime64 403 +__SYSCALL(__NR_clock_gettime64, sys_clock_gettime) +#define __NR_clock_settime64 404 +__SYSCALL(__NR_clock_settime64, sys_clock_settime) +#define __NR_clock_adjtime64 405 +__SYSCALL(__NR_clock_adjtime64, sys_clock_adjtime) +#define __NR_clock_getres_time64 406 +__SYSCALL(__NR_clock_getres_time64, sys_clock_getres) +#define __NR_clock_nanosleep_time64 407 +__SYSCALL(__NR_clock_nanosleep_time64, sys_clock_nanosleep) +#define __NR_timer_gettime64 408 +__SYSCALL(__NR_timer_gettime64, sys_timer_gettime) +#define __NR_timer_settime64 409 +__SYSCALL(__NR_timer_settime64, sys_timer_settime) +#define __NR_timerfd_gettime64 410 +__SYSCALL(__NR_timerfd_gettime64, sys_timerfd_gettime) +#define __NR_timerfd_settime64 411 +__SYSCALL(__NR_timerfd_settime64, sys_timerfd_settime) +#define __NR_utimensat_time64 412 +__SYSCALL(__NR_utimensat_time64, sys_utimensat) +#define __NR_pselect6_time64 413 +__SC_COMP(__NR_pselect6_time64, sys_pselect6, compat_sys_pselect6_time64) +#define __NR_ppoll_time64 414 +__SC_COMP(__NR_ppoll_time64, sys_ppoll, compat_sys_ppoll_time64) +#define __NR_io_pgetevents_time64 416 +__SYSCALL(__NR_io_pgetevents_time64, sys_io_pgetevents) +#define __NR_recvmmsg_time64 417 +__SC_COMP(__NR_recvmmsg_time64, sys_recvmmsg, compat_sys_recvmmsg_time64) +#define __NR_mq_timedsend_time64 418 +__SYSCALL(__NR_mq_timedsend_time64, sys_mq_timedsend) +#define __NR_mq_timedreceive_time64 419 +__SYSCALL(__NR_mq_timedreceive_time64, sys_mq_timedreceive) +#define __NR_semtimedop_time64 420 +__SYSCALL(__NR_semtimedop_time64, sys_semtimedop) +#define __NR_rt_sigtimedwait_time64 421 +__SC_COMP(__NR_rt_sigtimedwait_time64, sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time64) +#define __NR_futex_time64 422 +__SYSCALL(__NR_futex_time64, sys_futex) +#define __NR_sched_rr_get_interval_time64 423 +__SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) +#endif + +#define __NR_pidfd_send_signal 424 +__SYSCALL(__NR_pidfd_send_signal, sys_pidfd_send_signal) +#define __NR_io_uring_setup 425 +__SYSCALL(__NR_io_uring_setup, sys_io_uring_setup) +#define __NR_io_uring_enter 426 +__SYSCALL(__NR_io_uring_enter, sys_io_uring_enter) +#define __NR_io_uring_register 427 +__SYSCALL(__NR_io_uring_register, sys_io_uring_register) +#define __NR_open_tree 428 +__SYSCALL(__NR_open_tree, sys_open_tree) +#define __NR_move_mount 429 +__SYSCALL(__NR_move_mount, sys_move_mount) +#define __NR_fsopen 430 +__SYSCALL(__NR_fsopen, sys_fsopen) +#define __NR_fsconfig 431 +__SYSCALL(__NR_fsconfig, sys_fsconfig) +#define __NR_fsmount 432 +__SYSCALL(__NR_fsmount, sys_fsmount) +#define __NR_fspick 433 +__SYSCALL(__NR_fspick, sys_fspick) +#define __NR_pidfd_open 434 +__SYSCALL(__NR_pidfd_open, sys_pidfd_open) +#ifdef __ARCH_WANT_SYS_CLONE3 +#define __NR_clone3 435 +__SYSCALL(__NR_clone3, sys_clone3) +#endif +#define __NR_close_range 436 +__SYSCALL(__NR_close_range, sys_close_range) + +#define __NR_openat2 437 +__SYSCALL(__NR_openat2, sys_openat2) +#define __NR_pidfd_getfd 438 +__SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) +#define __NR_faccessat2 439 +__SYSCALL(__NR_faccessat2, sys_faccessat2) +#define __NR_process_madvise 440 +__SYSCALL(__NR_process_madvise, sys_process_madvise) +#define __NR_epoll_pwait2 441 +__SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2) +#define __NR_mount_setattr 442 +__SYSCALL(__NR_mount_setattr, sys_mount_setattr) +#define __NR_quotactl_fd 443 +__SYSCALL(__NR_quotactl_fd, sys_quotactl_fd) + +#define __NR_landlock_create_ruleset 444 +__SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset) +#define __NR_landlock_add_rule 445 +__SYSCALL(__NR_landlock_add_rule, sys_landlock_add_rule) +#define __NR_landlock_restrict_self 446 +__SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self) + +#ifdef __ARCH_WANT_MEMFD_SECRET +#define __NR_memfd_secret 447 +__SYSCALL(__NR_memfd_secret, sys_memfd_secret) +#endif +#define __NR_process_mrelease 448 +__SYSCALL(__NR_process_mrelease, sys_process_mrelease) + +#undef __NR_syscalls +#define __NR_syscalls 449 + +/* + * 32 bit systems traditionally used different + * syscalls for off_t and loff_t arguments, while + * 64 bit systems only need the off_t version. + * For new 32 bit platforms, there is no need to + * implement the old 32 bit off_t syscalls, so + * they take different names. + * Here we map the numbers so that both versions + * use the same syscall table layout. + */ +#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT) +#define __NR_fcntl __NR3264_fcntl +#define __NR_statfs __NR3264_statfs +#define __NR_fstatfs __NR3264_fstatfs +#define __NR_truncate __NR3264_truncate +#define __NR_ftruncate __NR3264_ftruncate +#define __NR_lseek __NR3264_lseek +#define __NR_sendfile __NR3264_sendfile +#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) +#define __NR_newfstatat __NR3264_fstatat +#define __NR_fstat __NR3264_fstat +#endif +#define __NR_mmap __NR3264_mmap +#define __NR_fadvise64 __NR3264_fadvise64 +#ifdef __NR3264_stat +#define __NR_stat __NR3264_stat +#define __NR_lstat __NR3264_lstat +#endif +#else +#define __NR_fcntl64 __NR3264_fcntl +#define __NR_statfs64 __NR3264_statfs +#define __NR_fstatfs64 __NR3264_fstatfs +#define __NR_truncate64 __NR3264_truncate +#define __NR_ftruncate64 __NR3264_ftruncate +#define __NR_llseek __NR3264_lseek +#define __NR_sendfile64 __NR3264_sendfile +#if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) +#define __NR_fstatat64 __NR3264_fstatat +#define __NR_fstat64 __NR3264_fstat +#endif +#define __NR_mmap2 __NR3264_mmap +#define __NR_fadvise64_64 __NR3264_fadvise64 +#ifdef __NR3264_stat +#define __NR_stat64 __NR3264_stat +#define __NR_lstat64 __NR3264_lstat +#endif +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/auxvec.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/auxvec.h new file mode 100755 index 0000000..5c09da5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/auxvec.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_AUXVEC_H +#define __ASM_AUXVEC_H + +/* VDSO location */ +#define AT_SYSINFO_EHDR 33 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/bitsperlong.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/bitsperlong.h new file mode 100755 index 0000000..6dc0bb0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/bitsperlong.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/bpf_perf_event.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/bpf_perf_event.h new file mode 100755 index 0000000..3097758 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/bpf_perf_event.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/byteorder.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/byteorder.h new file mode 100755 index 0000000..cb8406a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/byteorder.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * arch/arm/include/asm/byteorder.h + * + * ARM Endian-ness. In little endian mode, the data bus is connected such + * that byte accesses appear as: + * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 + * and word accesses (data or instruction) appear as: + * d0...d31 + * + * When in big endian mode, byte accesses appear as: + * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 + * and word accesses (data or instruction) appear as: + * d0...d31 + */ +#ifndef __ASM_ARM_BYTEORDER_H +#define __ASM_ARM_BYTEORDER_H + +#ifdef __ARMEB__ +#include +#else +#include +#endif + +#endif + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/errno.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/errno.h new file mode 100755 index 0000000..4c82b50 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/errno.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/fcntl.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/fcntl.h new file mode 100755 index 0000000..e6b5d71 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/fcntl.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ARM_FCNTL_H +#define _ARM_FCNTL_H + +#define O_DIRECTORY 040000 /* must be a directory */ +#define O_NOFOLLOW 0100000 /* don't follow links */ +#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */ +#define O_LARGEFILE 0400000 + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/hwcap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/hwcap.h new file mode 100755 index 0000000..65c2a7c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/hwcap.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASMARM_HWCAP_H +#define __ASMARM_HWCAP_H + +/* + * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP + */ +#define HWCAP_SWP (1 << 0) +#define HWCAP_HALF (1 << 1) +#define HWCAP_THUMB (1 << 2) +#define HWCAP_26BIT (1 << 3) /* Play it safe */ +#define HWCAP_FAST_MULT (1 << 4) +#define HWCAP_FPA (1 << 5) +#define HWCAP_VFP (1 << 6) +#define HWCAP_EDSP (1 << 7) +#define HWCAP_JAVA (1 << 8) +#define HWCAP_IWMMXT (1 << 9) +#define HWCAP_CRUNCH (1 << 10) /* Obsolete */ +#define HWCAP_THUMBEE (1 << 11) +#define HWCAP_NEON (1 << 12) +#define HWCAP_VFPv3 (1 << 13) +#define HWCAP_VFPv3D16 (1 << 14) /* also set for VFPv4-D16 */ +#define HWCAP_TLS (1 << 15) +#define HWCAP_VFPv4 (1 << 16) +#define HWCAP_IDIVA (1 << 17) +#define HWCAP_IDIVT (1 << 18) +#define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */ +#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) +#define HWCAP_LPAE (1 << 20) +#define HWCAP_EVTSTRM (1 << 21) + +/* + * HWCAP2 flags - for elf_hwcap2 (in kernel) and AT_HWCAP2 + */ +#define HWCAP2_AES (1 << 0) +#define HWCAP2_PMULL (1 << 1) +#define HWCAP2_SHA1 (1 << 2) +#define HWCAP2_SHA2 (1 << 3) +#define HWCAP2_CRC32 (1 << 4) + +#endif /* __ASMARM_HWCAP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ioctl.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ioctl.h new file mode 100755 index 0000000..b279fe0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ioctl.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ioctls.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ioctls.h new file mode 100755 index 0000000..1bfe285 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ioctls.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_ARM_IOCTLS_H +#define __ASM_ARM_IOCTLS_H + +#define FIOQSIZE 0x545E + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ipcbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ipcbuf.h new file mode 100755 index 0000000..84c7e51 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ipcbuf.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/kvm_para.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/kvm_para.h new file mode 100755 index 0000000..14fab8f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/kvm_para.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/mman.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/mman.h new file mode 100755 index 0000000..41f99c5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/mman.h @@ -0,0 +1,4 @@ +#include + +#define arch_mmap_check(addr, len, flags) \ + (((flags) & MAP_FIXED && (addr) < FIRST_USER_ADDRESS) ? -EINVAL : 0) diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/msgbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/msgbuf.h new file mode 100755 index 0000000..809134c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/msgbuf.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/param.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/param.h new file mode 100755 index 0000000..965d454 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/param.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/perf_regs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/perf_regs.h new file mode 100755 index 0000000..a3c0461 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/perf_regs.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_ARM_PERF_REGS_H +#define _ASM_ARM_PERF_REGS_H + +enum perf_event_arm_regs { + PERF_REG_ARM_R0, + PERF_REG_ARM_R1, + PERF_REG_ARM_R2, + PERF_REG_ARM_R3, + PERF_REG_ARM_R4, + PERF_REG_ARM_R5, + PERF_REG_ARM_R6, + PERF_REG_ARM_R7, + PERF_REG_ARM_R8, + PERF_REG_ARM_R9, + PERF_REG_ARM_R10, + PERF_REG_ARM_FP, + PERF_REG_ARM_IP, + PERF_REG_ARM_SP, + PERF_REG_ARM_LR, + PERF_REG_ARM_PC, + PERF_REG_ARM_MAX, +}; +#endif /* _ASM_ARM_PERF_REGS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/poll.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/poll.h new file mode 100755 index 0000000..c98509d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/poll.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/posix_types.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/posix_types.h new file mode 100755 index 0000000..6bf11ad --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/posix_types.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * arch/arm/include/asm/posix_types.h + * + * Copyright (C) 1996-1998 Russell King. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Changelog: + * 27-06-1996 RMK Created + */ +#ifndef __ARCH_ARM_POSIX_TYPES_H +#define __ARCH_ARM_POSIX_TYPES_H + +/* + * This file is generally used by user-level software, so you need to + * be a little careful about namespace pollution etc. Also, we cannot + * assume GCC is being used. + */ + +typedef unsigned short __kernel_mode_t; +#define __kernel_mode_t __kernel_mode_t + +typedef unsigned short __kernel_ipc_pid_t; +#define __kernel_ipc_pid_t __kernel_ipc_pid_t + +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +#define __kernel_uid_t __kernel_uid_t + +typedef unsigned short __kernel_old_dev_t; +#define __kernel_old_dev_t __kernel_old_dev_t + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ptrace.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ptrace.h new file mode 100755 index 0000000..97ae3fd --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/ptrace.h @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * arch/arm/include/asm/ptrace.h + * + * Copyright (C) 1996-2003 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_ARM_PTRACE_H +#define __ASM_ARM_PTRACE_H + +#include + +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 +#define PTRACE_GETFPREGS 14 +#define PTRACE_SETFPREGS 15 +/* PTRACE_ATTACH is 16 */ +/* PTRACE_DETACH is 17 */ +#define PTRACE_GETWMMXREGS 18 +#define PTRACE_SETWMMXREGS 19 +/* 20 is unused */ +#define PTRACE_OLDSETOPTIONS 21 +#define PTRACE_GET_THREAD_AREA 22 +#define PTRACE_SET_SYSCALL 23 +/* PTRACE_SYSCALL is 24 */ +#define PTRACE_GETCRUNCHREGS 25 /* obsolete */ +#define PTRACE_SETCRUNCHREGS 26 /* obsolete */ +#define PTRACE_GETVFPREGS 27 +#define PTRACE_SETVFPREGS 28 +#define PTRACE_GETHBPREGS 29 +#define PTRACE_SETHBPREGS 30 +#define PTRACE_GETFDPIC 31 + +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 + +/* + * PSR bits + * Note on V7M there is no mode contained in the PSR + */ +#define USR26_MODE 0x00000000 +#define FIQ26_MODE 0x00000001 +#define IRQ26_MODE 0x00000002 +#define SVC26_MODE 0x00000003 +#define USR_MODE 0x00000010 +#define SVC_MODE 0x00000013 +#define FIQ_MODE 0x00000011 +#define IRQ_MODE 0x00000012 +#define MON_MODE 0x00000016 +#define ABT_MODE 0x00000017 +#define HYP_MODE 0x0000001a +#define UND_MODE 0x0000001b +#define SYSTEM_MODE 0x0000001f +#define MODE32_BIT 0x00000010 +#define MODE_MASK 0x0000001f + +#define V4_PSR_T_BIT 0x00000020 /* >= V4T, but not V7M */ +#define V7M_PSR_T_BIT 0x01000000 +/* for compatibility */ +#define PSR_T_BIT V4_PSR_T_BIT + +#define PSR_F_BIT 0x00000040 /* >= V4, but not V7M */ +#define PSR_I_BIT 0x00000080 /* >= V4, but not V7M */ +#define PSR_A_BIT 0x00000100 /* >= V6, but not V7M */ +#define PSR_E_BIT 0x00000200 /* >= V6, but not V7M */ +#define PSR_J_BIT 0x01000000 /* >= V5J, but not V7M */ +#define PSR_Q_BIT 0x08000000 /* >= V5E, including V7M */ +#define PSR_V_BIT 0x10000000 +#define PSR_C_BIT 0x20000000 +#define PSR_Z_BIT 0x40000000 +#define PSR_N_BIT 0x80000000 + +/* + * Groups of PSR bits + */ +#define PSR_f 0xff000000 /* Flags */ +#define PSR_s 0x00ff0000 /* Status */ +#define PSR_x 0x0000ff00 /* Extension */ +#define PSR_c 0x000000ff /* Control */ + +/* + * ARMv7 groups of PSR bits + */ +#define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */ +#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */ +#define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */ +#define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */ + +/* + * Default endianness state + */ +#ifdef CONFIG_CPU_ENDIAN_BE8 +#define PSR_ENDSTATE PSR_E_BIT +#else +#define PSR_ENDSTATE 0 +#endif + +/* + * These are 'magic' values for PTRACE_PEEKUSR that return info about where a + * process is located in memory. + */ +#define PT_TEXT_ADDR 0x10000 +#define PT_DATA_ADDR 0x10004 +#define PT_TEXT_END_ADDR 0x10008 + +#ifndef __ASSEMBLY__ + +/* + * This struct defines the way the registers are stored on the + * stack during a system call. Note that sizeof(struct pt_regs) + * has to be a multiple of 8. + */ +struct pt_regs { + long uregs[18]; +}; + +#define ARM_cpsr uregs[16] +#define ARM_pc uregs[15] +#define ARM_lr uregs[14] +#define ARM_sp uregs[13] +#define ARM_ip uregs[12] +#define ARM_fp uregs[11] +#define ARM_r10 uregs[10] +#define ARM_r9 uregs[9] +#define ARM_r8 uregs[8] +#define ARM_r7 uregs[7] +#define ARM_r6 uregs[6] +#define ARM_r5 uregs[5] +#define ARM_r4 uregs[4] +#define ARM_r3 uregs[3] +#define ARM_r2 uregs[2] +#define ARM_r1 uregs[1] +#define ARM_r0 uregs[0] +#define ARM_ORIG_r0 uregs[17] + +/* + * The size of the user-visible VFP state as seen by PTRACE_GET/SETVFPREGS + * and core dumps. + */ +#define ARM_VFPREGS_SIZE ( 32 * 8 /*fpregs*/ + 4 /*fpscr*/ ) + + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_ARM_PTRACE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/resource.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/resource.h new file mode 100755 index 0000000..04bc4db --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/resource.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sembuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sembuf.h new file mode 100755 index 0000000..7673b83 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sembuf.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/setup.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/setup.h new file mode 100755 index 0000000..4a0fab0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/setup.h @@ -0,0 +1,188 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * linux/include/asm/setup.h + * + * Copyright (C) 1997-1999 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Structure passed to kernel to tell it about the + * hardware it's running on. See Documentation/arm/setup.rst + * for more info. + */ +#ifndef __ASMARM_SETUP_H +#define __ASMARM_SETUP_H + +#include + +#define COMMAND_LINE_SIZE 1024 + +/* The list ends with an ATAG_NONE node. */ +#define ATAG_NONE 0x00000000 + +struct tag_header { + __u32 size; + __u32 tag; +}; + +/* The list must start with an ATAG_CORE node */ +#define ATAG_CORE 0x54410001 + +struct tag_core { + __u32 flags; /* bit 0 = read-only */ + __u32 pagesize; + __u32 rootdev; +}; + +/* it is allowed to have multiple ATAG_MEM nodes */ +#define ATAG_MEM 0x54410002 + +struct tag_mem32 { + __u32 size; + __u32 start; /* physical start address */ +}; + +/* VGA text type displays */ +#define ATAG_VIDEOTEXT 0x54410003 + +struct tag_videotext { + __u8 x; + __u8 y; + __u16 video_page; + __u8 video_mode; + __u8 video_cols; + __u16 video_ega_bx; + __u8 video_lines; + __u8 video_isvga; + __u16 video_points; +}; + +/* describes how the ramdisk will be used in kernel */ +#define ATAG_RAMDISK 0x54410004 + +struct tag_ramdisk { + __u32 flags; /* bit 0 = load, bit 1 = prompt */ + __u32 size; /* decompressed ramdisk size in _kilo_ bytes */ + __u32 start; /* starting block of floppy-based RAM disk image */ +}; + +/* describes where the compressed ramdisk image lives (virtual address) */ +/* + * this one accidentally used virtual addresses - as such, + * it's deprecated. + */ +#define ATAG_INITRD 0x54410005 + +/* describes where the compressed ramdisk image lives (physical address) */ +#define ATAG_INITRD2 0x54420005 + +struct tag_initrd { + __u32 start; /* physical start address */ + __u32 size; /* size of compressed ramdisk image in bytes */ +}; + +/* board serial number. "64 bits should be enough for everybody" */ +#define ATAG_SERIAL 0x54410006 + +struct tag_serialnr { + __u32 low; + __u32 high; +}; + +/* board revision */ +#define ATAG_REVISION 0x54410007 + +struct tag_revision { + __u32 rev; +}; + +/* initial values for vesafb-type framebuffers. see struct screen_info + * in include/linux/tty.h + */ +#define ATAG_VIDEOLFB 0x54410008 + +struct tag_videolfb { + __u16 lfb_width; + __u16 lfb_height; + __u16 lfb_depth; + __u16 lfb_linelength; + __u32 lfb_base; + __u32 lfb_size; + __u8 red_size; + __u8 red_pos; + __u8 green_size; + __u8 green_pos; + __u8 blue_size; + __u8 blue_pos; + __u8 rsvd_size; + __u8 rsvd_pos; +}; + +/* command line: \0 terminated string */ +#define ATAG_CMDLINE 0x54410009 + +struct tag_cmdline { + char cmdline[1]; /* this is the minimum size */ +}; + +/* acorn RiscPC specific information */ +#define ATAG_ACORN 0x41000101 + +struct tag_acorn { + __u32 memc_control_reg; + __u32 vram_pages; + __u8 sounddefault; + __u8 adfsdrives; +}; + +/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ +#define ATAG_MEMCLK 0x41000402 + +struct tag_memclk { + __u32 fmemclk; +}; + +struct tag { + struct tag_header hdr; + union { + struct tag_core core; + struct tag_mem32 mem; + struct tag_videotext videotext; + struct tag_ramdisk ramdisk; + struct tag_initrd initrd; + struct tag_serialnr serialnr; + struct tag_revision revision; + struct tag_videolfb videolfb; + struct tag_cmdline cmdline; + + /* + * Acorn specific + */ + struct tag_acorn acorn; + + /* + * DC21285 specific + */ + struct tag_memclk memclk; + } u; +}; + +struct tagtable { + __u32 tag; + int (*parse)(const struct tag *); +}; + +#define tag_member_present(tag,member) \ + ((unsigned long)(&((struct tag *)0L)->member + 1) \ + <= (tag)->hdr.size * 4) + +#define tag_next(t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size)) +#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) + +#define for_each_tag(t,base) \ + for (t = base; t->hdr.size; t = tag_next(t)) + + +#endif /* __ASMARM_SETUP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/shmbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/shmbuf.h new file mode 100755 index 0000000..83c05fc --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/shmbuf.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sigcontext.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sigcontext.h new file mode 100755 index 0000000..e223c65 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sigcontext.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASMARM_SIGCONTEXT_H +#define _ASMARM_SIGCONTEXT_H + +/* + * Signal context structure - contains all info to do with the state + * before the signal handler was invoked. Note: only add new entries + * to the end of the structure. + */ +struct sigcontext { + unsigned long trap_no; + unsigned long error_code; + unsigned long oldmask; + unsigned long arm_r0; + unsigned long arm_r1; + unsigned long arm_r2; + unsigned long arm_r3; + unsigned long arm_r4; + unsigned long arm_r5; + unsigned long arm_r6; + unsigned long arm_r7; + unsigned long arm_r8; + unsigned long arm_r9; + unsigned long arm_r10; + unsigned long arm_fp; + unsigned long arm_ip; + unsigned long arm_sp; + unsigned long arm_lr; + unsigned long arm_pc; + unsigned long arm_cpsr; + unsigned long fault_address; +}; + + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/siginfo.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/siginfo.h new file mode 100755 index 0000000..0815d29 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/siginfo.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/signal.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/signal.h new file mode 100755 index 0000000..1254f11 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/signal.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASMARM_SIGNAL_H +#define _ASMARM_SIGNAL_H + +#include + +/* Avoid too many header ordering problems. */ +struct siginfo; + +/* Here we must cater to libcs that poke about in kernel headers. */ + +#define NSIG 32 +typedef unsigned long sigset_t; + + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL SIGIO +/* +#define SIGLOST 29 +*/ +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED 31 + +/* These should not be considered constants from userland. */ +#define SIGRTMIN 32 +#define SIGRTMAX _NSIG + +#define SIGSWI 32 + +/* + * SA_THIRTYTWO historically meant deliver the signal in 32-bit mode, even if + * the task is running in 26-bit. But since the kernel no longer supports + * 26-bit mode, the flag has no effect. + */ +#define SA_THIRTYTWO 0x02000000 +#define SA_RESTORER 0x04000000 + +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 + +#include + +/* Here we must cater to libcs that poke about in kernel headers. */ + +struct sigaction { + union { + __sighandler_t _sa_handler; + void (*_sa_sigaction)(int, struct siginfo *, void *); + } _u; + sigset_t sa_mask; + unsigned long sa_flags; + void (*sa_restorer)(void); +}; + +#define sa_handler _u._sa_handler +#define sa_sigaction _u._sa_sigaction + + +typedef struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; + + +#endif /* _ASMARM_SIGNAL_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/socket.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/socket.h new file mode 100755 index 0000000..6b71384 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/socket.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sockios.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sockios.h new file mode 100755 index 0000000..def6d47 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/sockios.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/stat.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/stat.h new file mode 100755 index 0000000..9c6580b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/stat.h @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASMARM_STAT_H +#define _ASMARM_STAT_H + +struct __old_kernel_stat { + unsigned short st_dev; + unsigned short st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned long st_size; + unsigned long st_atime; + unsigned long st_mtime; + unsigned long st_ctime; +}; + +#define STAT_HAVE_NSEC + +struct stat { +#if defined(__ARMEB__) + unsigned short st_dev; + unsigned short __pad1; +#else + unsigned long st_dev; +#endif + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; +#if defined(__ARMEB__) + unsigned short st_rdev; + unsigned short __pad2; +#else + unsigned long st_rdev; +#endif + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long __unused4; + unsigned long __unused5; +}; + +/* This matches struct stat64 in glibc2.1, hence the absolutely + * insane amounts of padding around dev_t's. + * Note: The kernel zero's the padded region because glibc might read them + * in the hope that the kernel has stretched to using larger sizes. + */ +struct stat64 { + unsigned long long st_dev; + unsigned char __pad0[4]; + +#define STAT64_HAS_BROKEN_ST_INO 1 + unsigned long __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + + unsigned long st_uid; + unsigned long st_gid; + + unsigned long long st_rdev; + unsigned char __pad3[4]; + + long long st_size; + unsigned long st_blksize; + unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long st_atime_nsec; + + unsigned long st_mtime; + unsigned long st_mtime_nsec; + + unsigned long st_ctime; + unsigned long st_ctime_nsec; + + unsigned long long st_ino; +}; + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/statfs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/statfs.h new file mode 100755 index 0000000..177f085 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/statfs.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASMARM_STATFS_H +#define _ASMARM_STATFS_H + +/* + * With EABI there is 4 bytes of padding added to this structure. + * Let's pack it so the padding goes away to simplify dual ABI support. + * Note that user space does NOT have to pack this structure. + */ +#define ARCH_PACK_STATFS64 __attribute__((packed,aligned(4))) + +#include +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/swab.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/swab.h new file mode 100755 index 0000000..8aabe5f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/swab.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * arch/arm/include/asm/byteorder.h + * + * ARM Endian-ness. In little endian mode, the data bus is connected such + * that byte accesses appear as: + * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 + * and word accesses (data or instruction) appear as: + * d0...d31 + * + * When in big endian mode, byte accesses appear as: + * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 + * and word accesses (data or instruction) appear as: + * d0...d31 + */ +#ifndef __ASM_ARM_SWAB_H +#define __ASM_ARM_SWAB_H + + +#include + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __SWAB_64_THRU_32__ +#endif + + +static __inline__ __u32 __arch_swab32(__u32 x) +{ + __u32 t; + +#ifndef __thumb__ + if (!__builtin_constant_p(x)) { + /* + * The compiler needs a bit of a hint here to always do the + * right thing and not screw it up to different degrees + * depending on the gcc version. + */ + __asm__ ("eor\t%0, %1, %1, ror #16" : "=r" (t) : "r" (x)); + } else +#endif + t = x ^ ((x << 16) | (x >> 16)); /* eor r1,r0,r0,ror #16 */ + + x = (x << 24) | (x >> 8); /* mov r0,r0,ror #8 */ + t &= ~0x00FF0000; /* bic r1,r1,#0x00FF0000 */ + x ^= (t >> 8); /* eor r0,r0,r1,lsr #8 */ + + return x; +} +#define __arch_swab32 __arch_swab32 + + +#endif /* __ASM_ARM_SWAB_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/termbits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/termbits.h new file mode 100755 index 0000000..3935b10 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/termbits.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/termios.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/termios.h new file mode 100755 index 0000000..280d78a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/termios.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/types.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/types.h new file mode 100755 index 0000000..5ad3e4d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/types.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_TYPES_H +#define _ASM_TYPES_H + +#include + +/* + * The C99 types uintXX_t that are usually defined in 'stdint.h' are not as + * unambiguous on ARM as you would expect. For the types below, there is a + * difference on ARM between GCC built for bare metal ARM, GCC built for glibc + * and the kernel itself, which results in build errors if you try to build with + * -ffreestanding and include 'stdint.h' (such as when you include 'arm_neon.h' + * in order to use NEON intrinsics) + * + * As the typedefs for these types in 'stdint.h' are based on builtin defines + * supplied by GCC, we can tweak these to align with the kernel's idea of those + * types, so 'linux/types.h' and 'stdint.h' can be safely included from the same + * source file (provided that -ffreestanding is used). + * + * int32_t uint32_t uintptr_t + * bare metal GCC long unsigned long unsigned int + * glibc GCC int unsigned int unsigned int + * kernel int unsigned int unsigned long + */ + +#ifdef __INT32_TYPE__ +#undef __INT32_TYPE__ +#define __INT32_TYPE__ int +#endif + +#ifdef __UINT32_TYPE__ +#undef __UINT32_TYPE__ +#define __UINT32_TYPE__ unsigned int +#endif + +#ifdef __UINTPTR_TYPE__ +#undef __UINTPTR_TYPE__ +#define __UINTPTR_TYPE__ unsigned long +#endif + +#endif /* _ASM_TYPES_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd-eabi.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd-eabi.h new file mode 100755 index 0000000..1aa5ef4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd-eabi.h @@ -0,0 +1,406 @@ +#ifndef _ASM_UNISTD_EABI_H +#define _ASM_UNISTD_EABI_H + +#define __NR_restart_syscall (__NR_SYSCALL_BASE + 0) +#define __NR_exit (__NR_SYSCALL_BASE + 1) +#define __NR_fork (__NR_SYSCALL_BASE + 2) +#define __NR_read (__NR_SYSCALL_BASE + 3) +#define __NR_write (__NR_SYSCALL_BASE + 4) +#define __NR_open (__NR_SYSCALL_BASE + 5) +#define __NR_close (__NR_SYSCALL_BASE + 6) +#define __NR_creat (__NR_SYSCALL_BASE + 8) +#define __NR_link (__NR_SYSCALL_BASE + 9) +#define __NR_unlink (__NR_SYSCALL_BASE + 10) +#define __NR_execve (__NR_SYSCALL_BASE + 11) +#define __NR_chdir (__NR_SYSCALL_BASE + 12) +#define __NR_mknod (__NR_SYSCALL_BASE + 14) +#define __NR_chmod (__NR_SYSCALL_BASE + 15) +#define __NR_lchown (__NR_SYSCALL_BASE + 16) +#define __NR_lseek (__NR_SYSCALL_BASE + 19) +#define __NR_getpid (__NR_SYSCALL_BASE + 20) +#define __NR_mount (__NR_SYSCALL_BASE + 21) +#define __NR_setuid (__NR_SYSCALL_BASE + 23) +#define __NR_getuid (__NR_SYSCALL_BASE + 24) +#define __NR_ptrace (__NR_SYSCALL_BASE + 26) +#define __NR_pause (__NR_SYSCALL_BASE + 29) +#define __NR_access (__NR_SYSCALL_BASE + 33) +#define __NR_nice (__NR_SYSCALL_BASE + 34) +#define __NR_sync (__NR_SYSCALL_BASE + 36) +#define __NR_kill (__NR_SYSCALL_BASE + 37) +#define __NR_rename (__NR_SYSCALL_BASE + 38) +#define __NR_mkdir (__NR_SYSCALL_BASE + 39) +#define __NR_rmdir (__NR_SYSCALL_BASE + 40) +#define __NR_dup (__NR_SYSCALL_BASE + 41) +#define __NR_pipe (__NR_SYSCALL_BASE + 42) +#define __NR_times (__NR_SYSCALL_BASE + 43) +#define __NR_brk (__NR_SYSCALL_BASE + 45) +#define __NR_setgid (__NR_SYSCALL_BASE + 46) +#define __NR_getgid (__NR_SYSCALL_BASE + 47) +#define __NR_geteuid (__NR_SYSCALL_BASE + 49) +#define __NR_getegid (__NR_SYSCALL_BASE + 50) +#define __NR_acct (__NR_SYSCALL_BASE + 51) +#define __NR_umount2 (__NR_SYSCALL_BASE + 52) +#define __NR_ioctl (__NR_SYSCALL_BASE + 54) +#define __NR_fcntl (__NR_SYSCALL_BASE + 55) +#define __NR_setpgid (__NR_SYSCALL_BASE + 57) +#define __NR_umask (__NR_SYSCALL_BASE + 60) +#define __NR_chroot (__NR_SYSCALL_BASE + 61) +#define __NR_ustat (__NR_SYSCALL_BASE + 62) +#define __NR_dup2 (__NR_SYSCALL_BASE + 63) +#define __NR_getppid (__NR_SYSCALL_BASE + 64) +#define __NR_getpgrp (__NR_SYSCALL_BASE + 65) +#define __NR_setsid (__NR_SYSCALL_BASE + 66) +#define __NR_sigaction (__NR_SYSCALL_BASE + 67) +#define __NR_setreuid (__NR_SYSCALL_BASE + 70) +#define __NR_setregid (__NR_SYSCALL_BASE + 71) +#define __NR_sigsuspend (__NR_SYSCALL_BASE + 72) +#define __NR_sigpending (__NR_SYSCALL_BASE + 73) +#define __NR_sethostname (__NR_SYSCALL_BASE + 74) +#define __NR_setrlimit (__NR_SYSCALL_BASE + 75) +#define __NR_getrusage (__NR_SYSCALL_BASE + 77) +#define __NR_gettimeofday (__NR_SYSCALL_BASE + 78) +#define __NR_settimeofday (__NR_SYSCALL_BASE + 79) +#define __NR_getgroups (__NR_SYSCALL_BASE + 80) +#define __NR_setgroups (__NR_SYSCALL_BASE + 81) +#define __NR_symlink (__NR_SYSCALL_BASE + 83) +#define __NR_readlink (__NR_SYSCALL_BASE + 85) +#define __NR_uselib (__NR_SYSCALL_BASE + 86) +#define __NR_swapon (__NR_SYSCALL_BASE + 87) +#define __NR_reboot (__NR_SYSCALL_BASE + 88) +#define __NR_munmap (__NR_SYSCALL_BASE + 91) +#define __NR_truncate (__NR_SYSCALL_BASE + 92) +#define __NR_ftruncate (__NR_SYSCALL_BASE + 93) +#define __NR_fchmod (__NR_SYSCALL_BASE + 94) +#define __NR_fchown (__NR_SYSCALL_BASE + 95) +#define __NR_getpriority (__NR_SYSCALL_BASE + 96) +#define __NR_setpriority (__NR_SYSCALL_BASE + 97) +#define __NR_statfs (__NR_SYSCALL_BASE + 99) +#define __NR_fstatfs (__NR_SYSCALL_BASE + 100) +#define __NR_syslog (__NR_SYSCALL_BASE + 103) +#define __NR_setitimer (__NR_SYSCALL_BASE + 104) +#define __NR_getitimer (__NR_SYSCALL_BASE + 105) +#define __NR_stat (__NR_SYSCALL_BASE + 106) +#define __NR_lstat (__NR_SYSCALL_BASE + 107) +#define __NR_fstat (__NR_SYSCALL_BASE + 108) +#define __NR_vhangup (__NR_SYSCALL_BASE + 111) +#define __NR_wait4 (__NR_SYSCALL_BASE + 114) +#define __NR_swapoff (__NR_SYSCALL_BASE + 115) +#define __NR_sysinfo (__NR_SYSCALL_BASE + 116) +#define __NR_fsync (__NR_SYSCALL_BASE + 118) +#define __NR_sigreturn (__NR_SYSCALL_BASE + 119) +#define __NR_clone (__NR_SYSCALL_BASE + 120) +#define __NR_setdomainname (__NR_SYSCALL_BASE + 121) +#define __NR_uname (__NR_SYSCALL_BASE + 122) +#define __NR_adjtimex (__NR_SYSCALL_BASE + 124) +#define __NR_mprotect (__NR_SYSCALL_BASE + 125) +#define __NR_sigprocmask (__NR_SYSCALL_BASE + 126) +#define __NR_init_module (__NR_SYSCALL_BASE + 128) +#define __NR_delete_module (__NR_SYSCALL_BASE + 129) +#define __NR_quotactl (__NR_SYSCALL_BASE + 131) +#define __NR_getpgid (__NR_SYSCALL_BASE + 132) +#define __NR_fchdir (__NR_SYSCALL_BASE + 133) +#define __NR_bdflush (__NR_SYSCALL_BASE + 134) +#define __NR_sysfs (__NR_SYSCALL_BASE + 135) +#define __NR_personality (__NR_SYSCALL_BASE + 136) +#define __NR_setfsuid (__NR_SYSCALL_BASE + 138) +#define __NR_setfsgid (__NR_SYSCALL_BASE + 139) +#define __NR__llseek (__NR_SYSCALL_BASE + 140) +#define __NR_getdents (__NR_SYSCALL_BASE + 141) +#define __NR__newselect (__NR_SYSCALL_BASE + 142) +#define __NR_flock (__NR_SYSCALL_BASE + 143) +#define __NR_msync (__NR_SYSCALL_BASE + 144) +#define __NR_readv (__NR_SYSCALL_BASE + 145) +#define __NR_writev (__NR_SYSCALL_BASE + 146) +#define __NR_getsid (__NR_SYSCALL_BASE + 147) +#define __NR_fdatasync (__NR_SYSCALL_BASE + 148) +#define __NR__sysctl (__NR_SYSCALL_BASE + 149) +#define __NR_mlock (__NR_SYSCALL_BASE + 150) +#define __NR_munlock (__NR_SYSCALL_BASE + 151) +#define __NR_mlockall (__NR_SYSCALL_BASE + 152) +#define __NR_munlockall (__NR_SYSCALL_BASE + 153) +#define __NR_sched_setparam (__NR_SYSCALL_BASE + 154) +#define __NR_sched_getparam (__NR_SYSCALL_BASE + 155) +#define __NR_sched_setscheduler (__NR_SYSCALL_BASE + 156) +#define __NR_sched_getscheduler (__NR_SYSCALL_BASE + 157) +#define __NR_sched_yield (__NR_SYSCALL_BASE + 158) +#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE + 159) +#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE + 160) +#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE + 161) +#define __NR_nanosleep (__NR_SYSCALL_BASE + 162) +#define __NR_mremap (__NR_SYSCALL_BASE + 163) +#define __NR_setresuid (__NR_SYSCALL_BASE + 164) +#define __NR_getresuid (__NR_SYSCALL_BASE + 165) +#define __NR_poll (__NR_SYSCALL_BASE + 168) +#define __NR_nfsservctl (__NR_SYSCALL_BASE + 169) +#define __NR_setresgid (__NR_SYSCALL_BASE + 170) +#define __NR_getresgid (__NR_SYSCALL_BASE + 171) +#define __NR_prctl (__NR_SYSCALL_BASE + 172) +#define __NR_rt_sigreturn (__NR_SYSCALL_BASE + 173) +#define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174) +#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE + 175) +#define __NR_rt_sigpending (__NR_SYSCALL_BASE + 176) +#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE + 177) +#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE + 178) +#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE + 179) +#define __NR_pread64 (__NR_SYSCALL_BASE + 180) +#define __NR_pwrite64 (__NR_SYSCALL_BASE + 181) +#define __NR_chown (__NR_SYSCALL_BASE + 182) +#define __NR_getcwd (__NR_SYSCALL_BASE + 183) +#define __NR_capget (__NR_SYSCALL_BASE + 184) +#define __NR_capset (__NR_SYSCALL_BASE + 185) +#define __NR_sigaltstack (__NR_SYSCALL_BASE + 186) +#define __NR_sendfile (__NR_SYSCALL_BASE + 187) +#define __NR_vfork (__NR_SYSCALL_BASE + 190) +#define __NR_ugetrlimit (__NR_SYSCALL_BASE + 191) +#define __NR_mmap2 (__NR_SYSCALL_BASE + 192) +#define __NR_truncate64 (__NR_SYSCALL_BASE + 193) +#define __NR_ftruncate64 (__NR_SYSCALL_BASE + 194) +#define __NR_stat64 (__NR_SYSCALL_BASE + 195) +#define __NR_lstat64 (__NR_SYSCALL_BASE + 196) +#define __NR_fstat64 (__NR_SYSCALL_BASE + 197) +#define __NR_lchown32 (__NR_SYSCALL_BASE + 198) +#define __NR_getuid32 (__NR_SYSCALL_BASE + 199) +#define __NR_getgid32 (__NR_SYSCALL_BASE + 200) +#define __NR_geteuid32 (__NR_SYSCALL_BASE + 201) +#define __NR_getegid32 (__NR_SYSCALL_BASE + 202) +#define __NR_setreuid32 (__NR_SYSCALL_BASE + 203) +#define __NR_setregid32 (__NR_SYSCALL_BASE + 204) +#define __NR_getgroups32 (__NR_SYSCALL_BASE + 205) +#define __NR_setgroups32 (__NR_SYSCALL_BASE + 206) +#define __NR_fchown32 (__NR_SYSCALL_BASE + 207) +#define __NR_setresuid32 (__NR_SYSCALL_BASE + 208) +#define __NR_getresuid32 (__NR_SYSCALL_BASE + 209) +#define __NR_setresgid32 (__NR_SYSCALL_BASE + 210) +#define __NR_getresgid32 (__NR_SYSCALL_BASE + 211) +#define __NR_chown32 (__NR_SYSCALL_BASE + 212) +#define __NR_setuid32 (__NR_SYSCALL_BASE + 213) +#define __NR_setgid32 (__NR_SYSCALL_BASE + 214) +#define __NR_setfsuid32 (__NR_SYSCALL_BASE + 215) +#define __NR_setfsgid32 (__NR_SYSCALL_BASE + 216) +#define __NR_getdents64 (__NR_SYSCALL_BASE + 217) +#define __NR_pivot_root (__NR_SYSCALL_BASE + 218) +#define __NR_mincore (__NR_SYSCALL_BASE + 219) +#define __NR_madvise (__NR_SYSCALL_BASE + 220) +#define __NR_fcntl64 (__NR_SYSCALL_BASE + 221) +#define __NR_gettid (__NR_SYSCALL_BASE + 224) +#define __NR_readahead (__NR_SYSCALL_BASE + 225) +#define __NR_setxattr (__NR_SYSCALL_BASE + 226) +#define __NR_lsetxattr (__NR_SYSCALL_BASE + 227) +#define __NR_fsetxattr (__NR_SYSCALL_BASE + 228) +#define __NR_getxattr (__NR_SYSCALL_BASE + 229) +#define __NR_lgetxattr (__NR_SYSCALL_BASE + 230) +#define __NR_fgetxattr (__NR_SYSCALL_BASE + 231) +#define __NR_listxattr (__NR_SYSCALL_BASE + 232) +#define __NR_llistxattr (__NR_SYSCALL_BASE + 233) +#define __NR_flistxattr (__NR_SYSCALL_BASE + 234) +#define __NR_removexattr (__NR_SYSCALL_BASE + 235) +#define __NR_lremovexattr (__NR_SYSCALL_BASE + 236) +#define __NR_fremovexattr (__NR_SYSCALL_BASE + 237) +#define __NR_tkill (__NR_SYSCALL_BASE + 238) +#define __NR_sendfile64 (__NR_SYSCALL_BASE + 239) +#define __NR_futex (__NR_SYSCALL_BASE + 240) +#define __NR_sched_setaffinity (__NR_SYSCALL_BASE + 241) +#define __NR_sched_getaffinity (__NR_SYSCALL_BASE + 242) +#define __NR_io_setup (__NR_SYSCALL_BASE + 243) +#define __NR_io_destroy (__NR_SYSCALL_BASE + 244) +#define __NR_io_getevents (__NR_SYSCALL_BASE + 245) +#define __NR_io_submit (__NR_SYSCALL_BASE + 246) +#define __NR_io_cancel (__NR_SYSCALL_BASE + 247) +#define __NR_exit_group (__NR_SYSCALL_BASE + 248) +#define __NR_lookup_dcookie (__NR_SYSCALL_BASE + 249) +#define __NR_epoll_create (__NR_SYSCALL_BASE + 250) +#define __NR_epoll_ctl (__NR_SYSCALL_BASE + 251) +#define __NR_epoll_wait (__NR_SYSCALL_BASE + 252) +#define __NR_remap_file_pages (__NR_SYSCALL_BASE + 253) +#define __NR_set_tid_address (__NR_SYSCALL_BASE + 256) +#define __NR_timer_create (__NR_SYSCALL_BASE + 257) +#define __NR_timer_settime (__NR_SYSCALL_BASE + 258) +#define __NR_timer_gettime (__NR_SYSCALL_BASE + 259) +#define __NR_timer_getoverrun (__NR_SYSCALL_BASE + 260) +#define __NR_timer_delete (__NR_SYSCALL_BASE + 261) +#define __NR_clock_settime (__NR_SYSCALL_BASE + 262) +#define __NR_clock_gettime (__NR_SYSCALL_BASE + 263) +#define __NR_clock_getres (__NR_SYSCALL_BASE + 264) +#define __NR_clock_nanosleep (__NR_SYSCALL_BASE + 265) +#define __NR_statfs64 (__NR_SYSCALL_BASE + 266) +#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267) +#define __NR_tgkill (__NR_SYSCALL_BASE + 268) +#define __NR_utimes (__NR_SYSCALL_BASE + 269) +#define __NR_arm_fadvise64_64 (__NR_SYSCALL_BASE + 270) +#define __NR_pciconfig_iobase (__NR_SYSCALL_BASE + 271) +#define __NR_pciconfig_read (__NR_SYSCALL_BASE + 272) +#define __NR_pciconfig_write (__NR_SYSCALL_BASE + 273) +#define __NR_mq_open (__NR_SYSCALL_BASE + 274) +#define __NR_mq_unlink (__NR_SYSCALL_BASE + 275) +#define __NR_mq_timedsend (__NR_SYSCALL_BASE + 276) +#define __NR_mq_timedreceive (__NR_SYSCALL_BASE + 277) +#define __NR_mq_notify (__NR_SYSCALL_BASE + 278) +#define __NR_mq_getsetattr (__NR_SYSCALL_BASE + 279) +#define __NR_waitid (__NR_SYSCALL_BASE + 280) +#define __NR_socket (__NR_SYSCALL_BASE + 281) +#define __NR_bind (__NR_SYSCALL_BASE + 282) +#define __NR_connect (__NR_SYSCALL_BASE + 283) +#define __NR_listen (__NR_SYSCALL_BASE + 284) +#define __NR_accept (__NR_SYSCALL_BASE + 285) +#define __NR_getsockname (__NR_SYSCALL_BASE + 286) +#define __NR_getpeername (__NR_SYSCALL_BASE + 287) +#define __NR_socketpair (__NR_SYSCALL_BASE + 288) +#define __NR_send (__NR_SYSCALL_BASE + 289) +#define __NR_sendto (__NR_SYSCALL_BASE + 290) +#define __NR_recv (__NR_SYSCALL_BASE + 291) +#define __NR_recvfrom (__NR_SYSCALL_BASE + 292) +#define __NR_shutdown (__NR_SYSCALL_BASE + 293) +#define __NR_setsockopt (__NR_SYSCALL_BASE + 294) +#define __NR_getsockopt (__NR_SYSCALL_BASE + 295) +#define __NR_sendmsg (__NR_SYSCALL_BASE + 296) +#define __NR_recvmsg (__NR_SYSCALL_BASE + 297) +#define __NR_semop (__NR_SYSCALL_BASE + 298) +#define __NR_semget (__NR_SYSCALL_BASE + 299) +#define __NR_semctl (__NR_SYSCALL_BASE + 300) +#define __NR_msgsnd (__NR_SYSCALL_BASE + 301) +#define __NR_msgrcv (__NR_SYSCALL_BASE + 302) +#define __NR_msgget (__NR_SYSCALL_BASE + 303) +#define __NR_msgctl (__NR_SYSCALL_BASE + 304) +#define __NR_shmat (__NR_SYSCALL_BASE + 305) +#define __NR_shmdt (__NR_SYSCALL_BASE + 306) +#define __NR_shmget (__NR_SYSCALL_BASE + 307) +#define __NR_shmctl (__NR_SYSCALL_BASE + 308) +#define __NR_add_key (__NR_SYSCALL_BASE + 309) +#define __NR_request_key (__NR_SYSCALL_BASE + 310) +#define __NR_keyctl (__NR_SYSCALL_BASE + 311) +#define __NR_semtimedop (__NR_SYSCALL_BASE + 312) +#define __NR_vserver (__NR_SYSCALL_BASE + 313) +#define __NR_ioprio_set (__NR_SYSCALL_BASE + 314) +#define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) +#define __NR_inotify_init (__NR_SYSCALL_BASE + 316) +#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 317) +#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 318) +#define __NR_mbind (__NR_SYSCALL_BASE + 319) +#define __NR_get_mempolicy (__NR_SYSCALL_BASE + 320) +#define __NR_set_mempolicy (__NR_SYSCALL_BASE + 321) +#define __NR_openat (__NR_SYSCALL_BASE + 322) +#define __NR_mkdirat (__NR_SYSCALL_BASE + 323) +#define __NR_mknodat (__NR_SYSCALL_BASE + 324) +#define __NR_fchownat (__NR_SYSCALL_BASE + 325) +#define __NR_futimesat (__NR_SYSCALL_BASE + 326) +#define __NR_fstatat64 (__NR_SYSCALL_BASE + 327) +#define __NR_unlinkat (__NR_SYSCALL_BASE + 328) +#define __NR_renameat (__NR_SYSCALL_BASE + 329) +#define __NR_linkat (__NR_SYSCALL_BASE + 330) +#define __NR_symlinkat (__NR_SYSCALL_BASE + 331) +#define __NR_readlinkat (__NR_SYSCALL_BASE + 332) +#define __NR_fchmodat (__NR_SYSCALL_BASE + 333) +#define __NR_faccessat (__NR_SYSCALL_BASE + 334) +#define __NR_pselect6 (__NR_SYSCALL_BASE + 335) +#define __NR_ppoll (__NR_SYSCALL_BASE + 336) +#define __NR_unshare (__NR_SYSCALL_BASE + 337) +#define __NR_set_robust_list (__NR_SYSCALL_BASE + 338) +#define __NR_get_robust_list (__NR_SYSCALL_BASE + 339) +#define __NR_splice (__NR_SYSCALL_BASE + 340) +#define __NR_arm_sync_file_range (__NR_SYSCALL_BASE + 341) +#define __NR_tee (__NR_SYSCALL_BASE + 342) +#define __NR_vmsplice (__NR_SYSCALL_BASE + 343) +#define __NR_move_pages (__NR_SYSCALL_BASE + 344) +#define __NR_getcpu (__NR_SYSCALL_BASE + 345) +#define __NR_epoll_pwait (__NR_SYSCALL_BASE + 346) +#define __NR_kexec_load (__NR_SYSCALL_BASE + 347) +#define __NR_utimensat (__NR_SYSCALL_BASE + 348) +#define __NR_signalfd (__NR_SYSCALL_BASE + 349) +#define __NR_timerfd_create (__NR_SYSCALL_BASE + 350) +#define __NR_eventfd (__NR_SYSCALL_BASE + 351) +#define __NR_fallocate (__NR_SYSCALL_BASE + 352) +#define __NR_timerfd_settime (__NR_SYSCALL_BASE + 353) +#define __NR_timerfd_gettime (__NR_SYSCALL_BASE + 354) +#define __NR_signalfd4 (__NR_SYSCALL_BASE + 355) +#define __NR_eventfd2 (__NR_SYSCALL_BASE + 356) +#define __NR_epoll_create1 (__NR_SYSCALL_BASE + 357) +#define __NR_dup3 (__NR_SYSCALL_BASE + 358) +#define __NR_pipe2 (__NR_SYSCALL_BASE + 359) +#define __NR_inotify_init1 (__NR_SYSCALL_BASE + 360) +#define __NR_preadv (__NR_SYSCALL_BASE + 361) +#define __NR_pwritev (__NR_SYSCALL_BASE + 362) +#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE + 363) +#define __NR_perf_event_open (__NR_SYSCALL_BASE + 364) +#define __NR_recvmmsg (__NR_SYSCALL_BASE + 365) +#define __NR_accept4 (__NR_SYSCALL_BASE + 366) +#define __NR_fanotify_init (__NR_SYSCALL_BASE + 367) +#define __NR_fanotify_mark (__NR_SYSCALL_BASE + 368) +#define __NR_prlimit64 (__NR_SYSCALL_BASE + 369) +#define __NR_name_to_handle_at (__NR_SYSCALL_BASE + 370) +#define __NR_open_by_handle_at (__NR_SYSCALL_BASE + 371) +#define __NR_clock_adjtime (__NR_SYSCALL_BASE + 372) +#define __NR_syncfs (__NR_SYSCALL_BASE + 373) +#define __NR_sendmmsg (__NR_SYSCALL_BASE + 374) +#define __NR_setns (__NR_SYSCALL_BASE + 375) +#define __NR_process_vm_readv (__NR_SYSCALL_BASE + 376) +#define __NR_process_vm_writev (__NR_SYSCALL_BASE + 377) +#define __NR_kcmp (__NR_SYSCALL_BASE + 378) +#define __NR_finit_module (__NR_SYSCALL_BASE + 379) +#define __NR_sched_setattr (__NR_SYSCALL_BASE + 380) +#define __NR_sched_getattr (__NR_SYSCALL_BASE + 381) +#define __NR_renameat2 (__NR_SYSCALL_BASE + 382) +#define __NR_seccomp (__NR_SYSCALL_BASE + 383) +#define __NR_getrandom (__NR_SYSCALL_BASE + 384) +#define __NR_memfd_create (__NR_SYSCALL_BASE + 385) +#define __NR_bpf (__NR_SYSCALL_BASE + 386) +#define __NR_execveat (__NR_SYSCALL_BASE + 387) +#define __NR_userfaultfd (__NR_SYSCALL_BASE + 388) +#define __NR_membarrier (__NR_SYSCALL_BASE + 389) +#define __NR_mlock2 (__NR_SYSCALL_BASE + 390) +#define __NR_copy_file_range (__NR_SYSCALL_BASE + 391) +#define __NR_preadv2 (__NR_SYSCALL_BASE + 392) +#define __NR_pwritev2 (__NR_SYSCALL_BASE + 393) +#define __NR_pkey_mprotect (__NR_SYSCALL_BASE + 394) +#define __NR_pkey_alloc (__NR_SYSCALL_BASE + 395) +#define __NR_pkey_free (__NR_SYSCALL_BASE + 396) +#define __NR_statx (__NR_SYSCALL_BASE + 397) +#define __NR_rseq (__NR_SYSCALL_BASE + 398) +#define __NR_io_pgetevents (__NR_SYSCALL_BASE + 399) +#define __NR_migrate_pages (__NR_SYSCALL_BASE + 400) +#define __NR_kexec_file_load (__NR_SYSCALL_BASE + 401) +#define __NR_clock_gettime64 (__NR_SYSCALL_BASE + 403) +#define __NR_clock_settime64 (__NR_SYSCALL_BASE + 404) +#define __NR_clock_adjtime64 (__NR_SYSCALL_BASE + 405) +#define __NR_clock_getres_time64 (__NR_SYSCALL_BASE + 406) +#define __NR_clock_nanosleep_time64 (__NR_SYSCALL_BASE + 407) +#define __NR_timer_gettime64 (__NR_SYSCALL_BASE + 408) +#define __NR_timer_settime64 (__NR_SYSCALL_BASE + 409) +#define __NR_timerfd_gettime64 (__NR_SYSCALL_BASE + 410) +#define __NR_timerfd_settime64 (__NR_SYSCALL_BASE + 411) +#define __NR_utimensat_time64 (__NR_SYSCALL_BASE + 412) +#define __NR_pselect6_time64 (__NR_SYSCALL_BASE + 413) +#define __NR_ppoll_time64 (__NR_SYSCALL_BASE + 414) +#define __NR_io_pgetevents_time64 (__NR_SYSCALL_BASE + 416) +#define __NR_recvmmsg_time64 (__NR_SYSCALL_BASE + 417) +#define __NR_mq_timedsend_time64 (__NR_SYSCALL_BASE + 418) +#define __NR_mq_timedreceive_time64 (__NR_SYSCALL_BASE + 419) +#define __NR_semtimedop_time64 (__NR_SYSCALL_BASE + 420) +#define __NR_rt_sigtimedwait_time64 (__NR_SYSCALL_BASE + 421) +#define __NR_futex_time64 (__NR_SYSCALL_BASE + 422) +#define __NR_sched_rr_get_interval_time64 (__NR_SYSCALL_BASE + 423) +#define __NR_pidfd_send_signal (__NR_SYSCALL_BASE + 424) +#define __NR_io_uring_setup (__NR_SYSCALL_BASE + 425) +#define __NR_io_uring_enter (__NR_SYSCALL_BASE + 426) +#define __NR_io_uring_register (__NR_SYSCALL_BASE + 427) +#define __NR_open_tree (__NR_SYSCALL_BASE + 428) +#define __NR_move_mount (__NR_SYSCALL_BASE + 429) +#define __NR_fsopen (__NR_SYSCALL_BASE + 430) +#define __NR_fsconfig (__NR_SYSCALL_BASE + 431) +#define __NR_fsmount (__NR_SYSCALL_BASE + 432) +#define __NR_fspick (__NR_SYSCALL_BASE + 433) +#define __NR_pidfd_open (__NR_SYSCALL_BASE + 434) +#define __NR_clone3 (__NR_SYSCALL_BASE + 435) +#define __NR_close_range (__NR_SYSCALL_BASE + 436) +#define __NR_openat2 (__NR_SYSCALL_BASE + 437) +#define __NR_pidfd_getfd (__NR_SYSCALL_BASE + 438) +#define __NR_faccessat2 (__NR_SYSCALL_BASE + 439) +#define __NR_process_madvise (__NR_SYSCALL_BASE + 440) +#define __NR_epoll_pwait2 (__NR_SYSCALL_BASE + 441) +#define __NR_mount_setattr (__NR_SYSCALL_BASE + 442) +#define __NR_quotactl_fd (__NR_SYSCALL_BASE + 443) +#define __NR_landlock_create_ruleset (__NR_SYSCALL_BASE + 444) +#define __NR_landlock_add_rule (__NR_SYSCALL_BASE + 445) +#define __NR_landlock_restrict_self (__NR_SYSCALL_BASE + 446) +#define __NR_process_mrelease (__NR_SYSCALL_BASE + 448) + +#endif /* _ASM_UNISTD_EABI_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd-oabi.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd-oabi.h new file mode 100755 index 0000000..b84c8d6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd-oabi.h @@ -0,0 +1,418 @@ +#ifndef _ASM_UNISTD_OABI_H +#define _ASM_UNISTD_OABI_H + +#define __NR_restart_syscall (__NR_SYSCALL_BASE + 0) +#define __NR_exit (__NR_SYSCALL_BASE + 1) +#define __NR_fork (__NR_SYSCALL_BASE + 2) +#define __NR_read (__NR_SYSCALL_BASE + 3) +#define __NR_write (__NR_SYSCALL_BASE + 4) +#define __NR_open (__NR_SYSCALL_BASE + 5) +#define __NR_close (__NR_SYSCALL_BASE + 6) +#define __NR_creat (__NR_SYSCALL_BASE + 8) +#define __NR_link (__NR_SYSCALL_BASE + 9) +#define __NR_unlink (__NR_SYSCALL_BASE + 10) +#define __NR_execve (__NR_SYSCALL_BASE + 11) +#define __NR_chdir (__NR_SYSCALL_BASE + 12) +#define __NR_time (__NR_SYSCALL_BASE + 13) +#define __NR_mknod (__NR_SYSCALL_BASE + 14) +#define __NR_chmod (__NR_SYSCALL_BASE + 15) +#define __NR_lchown (__NR_SYSCALL_BASE + 16) +#define __NR_lseek (__NR_SYSCALL_BASE + 19) +#define __NR_getpid (__NR_SYSCALL_BASE + 20) +#define __NR_mount (__NR_SYSCALL_BASE + 21) +#define __NR_umount (__NR_SYSCALL_BASE + 22) +#define __NR_setuid (__NR_SYSCALL_BASE + 23) +#define __NR_getuid (__NR_SYSCALL_BASE + 24) +#define __NR_stime (__NR_SYSCALL_BASE + 25) +#define __NR_ptrace (__NR_SYSCALL_BASE + 26) +#define __NR_alarm (__NR_SYSCALL_BASE + 27) +#define __NR_pause (__NR_SYSCALL_BASE + 29) +#define __NR_utime (__NR_SYSCALL_BASE + 30) +#define __NR_access (__NR_SYSCALL_BASE + 33) +#define __NR_nice (__NR_SYSCALL_BASE + 34) +#define __NR_sync (__NR_SYSCALL_BASE + 36) +#define __NR_kill (__NR_SYSCALL_BASE + 37) +#define __NR_rename (__NR_SYSCALL_BASE + 38) +#define __NR_mkdir (__NR_SYSCALL_BASE + 39) +#define __NR_rmdir (__NR_SYSCALL_BASE + 40) +#define __NR_dup (__NR_SYSCALL_BASE + 41) +#define __NR_pipe (__NR_SYSCALL_BASE + 42) +#define __NR_times (__NR_SYSCALL_BASE + 43) +#define __NR_brk (__NR_SYSCALL_BASE + 45) +#define __NR_setgid (__NR_SYSCALL_BASE + 46) +#define __NR_getgid (__NR_SYSCALL_BASE + 47) +#define __NR_geteuid (__NR_SYSCALL_BASE + 49) +#define __NR_getegid (__NR_SYSCALL_BASE + 50) +#define __NR_acct (__NR_SYSCALL_BASE + 51) +#define __NR_umount2 (__NR_SYSCALL_BASE + 52) +#define __NR_ioctl (__NR_SYSCALL_BASE + 54) +#define __NR_fcntl (__NR_SYSCALL_BASE + 55) +#define __NR_setpgid (__NR_SYSCALL_BASE + 57) +#define __NR_umask (__NR_SYSCALL_BASE + 60) +#define __NR_chroot (__NR_SYSCALL_BASE + 61) +#define __NR_ustat (__NR_SYSCALL_BASE + 62) +#define __NR_dup2 (__NR_SYSCALL_BASE + 63) +#define __NR_getppid (__NR_SYSCALL_BASE + 64) +#define __NR_getpgrp (__NR_SYSCALL_BASE + 65) +#define __NR_setsid (__NR_SYSCALL_BASE + 66) +#define __NR_sigaction (__NR_SYSCALL_BASE + 67) +#define __NR_setreuid (__NR_SYSCALL_BASE + 70) +#define __NR_setregid (__NR_SYSCALL_BASE + 71) +#define __NR_sigsuspend (__NR_SYSCALL_BASE + 72) +#define __NR_sigpending (__NR_SYSCALL_BASE + 73) +#define __NR_sethostname (__NR_SYSCALL_BASE + 74) +#define __NR_setrlimit (__NR_SYSCALL_BASE + 75) +#define __NR_getrlimit (__NR_SYSCALL_BASE + 76) +#define __NR_getrusage (__NR_SYSCALL_BASE + 77) +#define __NR_gettimeofday (__NR_SYSCALL_BASE + 78) +#define __NR_settimeofday (__NR_SYSCALL_BASE + 79) +#define __NR_getgroups (__NR_SYSCALL_BASE + 80) +#define __NR_setgroups (__NR_SYSCALL_BASE + 81) +#define __NR_select (__NR_SYSCALL_BASE + 82) +#define __NR_symlink (__NR_SYSCALL_BASE + 83) +#define __NR_readlink (__NR_SYSCALL_BASE + 85) +#define __NR_uselib (__NR_SYSCALL_BASE + 86) +#define __NR_swapon (__NR_SYSCALL_BASE + 87) +#define __NR_reboot (__NR_SYSCALL_BASE + 88) +#define __NR_readdir (__NR_SYSCALL_BASE + 89) +#define __NR_mmap (__NR_SYSCALL_BASE + 90) +#define __NR_munmap (__NR_SYSCALL_BASE + 91) +#define __NR_truncate (__NR_SYSCALL_BASE + 92) +#define __NR_ftruncate (__NR_SYSCALL_BASE + 93) +#define __NR_fchmod (__NR_SYSCALL_BASE + 94) +#define __NR_fchown (__NR_SYSCALL_BASE + 95) +#define __NR_getpriority (__NR_SYSCALL_BASE + 96) +#define __NR_setpriority (__NR_SYSCALL_BASE + 97) +#define __NR_statfs (__NR_SYSCALL_BASE + 99) +#define __NR_fstatfs (__NR_SYSCALL_BASE + 100) +#define __NR_socketcall (__NR_SYSCALL_BASE + 102) +#define __NR_syslog (__NR_SYSCALL_BASE + 103) +#define __NR_setitimer (__NR_SYSCALL_BASE + 104) +#define __NR_getitimer (__NR_SYSCALL_BASE + 105) +#define __NR_stat (__NR_SYSCALL_BASE + 106) +#define __NR_lstat (__NR_SYSCALL_BASE + 107) +#define __NR_fstat (__NR_SYSCALL_BASE + 108) +#define __NR_vhangup (__NR_SYSCALL_BASE + 111) +#define __NR_syscall (__NR_SYSCALL_BASE + 113) +#define __NR_wait4 (__NR_SYSCALL_BASE + 114) +#define __NR_swapoff (__NR_SYSCALL_BASE + 115) +#define __NR_sysinfo (__NR_SYSCALL_BASE + 116) +#define __NR_ipc (__NR_SYSCALL_BASE + 117) +#define __NR_fsync (__NR_SYSCALL_BASE + 118) +#define __NR_sigreturn (__NR_SYSCALL_BASE + 119) +#define __NR_clone (__NR_SYSCALL_BASE + 120) +#define __NR_setdomainname (__NR_SYSCALL_BASE + 121) +#define __NR_uname (__NR_SYSCALL_BASE + 122) +#define __NR_adjtimex (__NR_SYSCALL_BASE + 124) +#define __NR_mprotect (__NR_SYSCALL_BASE + 125) +#define __NR_sigprocmask (__NR_SYSCALL_BASE + 126) +#define __NR_init_module (__NR_SYSCALL_BASE + 128) +#define __NR_delete_module (__NR_SYSCALL_BASE + 129) +#define __NR_quotactl (__NR_SYSCALL_BASE + 131) +#define __NR_getpgid (__NR_SYSCALL_BASE + 132) +#define __NR_fchdir (__NR_SYSCALL_BASE + 133) +#define __NR_bdflush (__NR_SYSCALL_BASE + 134) +#define __NR_sysfs (__NR_SYSCALL_BASE + 135) +#define __NR_personality (__NR_SYSCALL_BASE + 136) +#define __NR_setfsuid (__NR_SYSCALL_BASE + 138) +#define __NR_setfsgid (__NR_SYSCALL_BASE + 139) +#define __NR__llseek (__NR_SYSCALL_BASE + 140) +#define __NR_getdents (__NR_SYSCALL_BASE + 141) +#define __NR__newselect (__NR_SYSCALL_BASE + 142) +#define __NR_flock (__NR_SYSCALL_BASE + 143) +#define __NR_msync (__NR_SYSCALL_BASE + 144) +#define __NR_readv (__NR_SYSCALL_BASE + 145) +#define __NR_writev (__NR_SYSCALL_BASE + 146) +#define __NR_getsid (__NR_SYSCALL_BASE + 147) +#define __NR_fdatasync (__NR_SYSCALL_BASE + 148) +#define __NR__sysctl (__NR_SYSCALL_BASE + 149) +#define __NR_mlock (__NR_SYSCALL_BASE + 150) +#define __NR_munlock (__NR_SYSCALL_BASE + 151) +#define __NR_mlockall (__NR_SYSCALL_BASE + 152) +#define __NR_munlockall (__NR_SYSCALL_BASE + 153) +#define __NR_sched_setparam (__NR_SYSCALL_BASE + 154) +#define __NR_sched_getparam (__NR_SYSCALL_BASE + 155) +#define __NR_sched_setscheduler (__NR_SYSCALL_BASE + 156) +#define __NR_sched_getscheduler (__NR_SYSCALL_BASE + 157) +#define __NR_sched_yield (__NR_SYSCALL_BASE + 158) +#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE + 159) +#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE + 160) +#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE + 161) +#define __NR_nanosleep (__NR_SYSCALL_BASE + 162) +#define __NR_mremap (__NR_SYSCALL_BASE + 163) +#define __NR_setresuid (__NR_SYSCALL_BASE + 164) +#define __NR_getresuid (__NR_SYSCALL_BASE + 165) +#define __NR_poll (__NR_SYSCALL_BASE + 168) +#define __NR_nfsservctl (__NR_SYSCALL_BASE + 169) +#define __NR_setresgid (__NR_SYSCALL_BASE + 170) +#define __NR_getresgid (__NR_SYSCALL_BASE + 171) +#define __NR_prctl (__NR_SYSCALL_BASE + 172) +#define __NR_rt_sigreturn (__NR_SYSCALL_BASE + 173) +#define __NR_rt_sigaction (__NR_SYSCALL_BASE + 174) +#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE + 175) +#define __NR_rt_sigpending (__NR_SYSCALL_BASE + 176) +#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE + 177) +#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE + 178) +#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE + 179) +#define __NR_pread64 (__NR_SYSCALL_BASE + 180) +#define __NR_pwrite64 (__NR_SYSCALL_BASE + 181) +#define __NR_chown (__NR_SYSCALL_BASE + 182) +#define __NR_getcwd (__NR_SYSCALL_BASE + 183) +#define __NR_capget (__NR_SYSCALL_BASE + 184) +#define __NR_capset (__NR_SYSCALL_BASE + 185) +#define __NR_sigaltstack (__NR_SYSCALL_BASE + 186) +#define __NR_sendfile (__NR_SYSCALL_BASE + 187) +#define __NR_vfork (__NR_SYSCALL_BASE + 190) +#define __NR_ugetrlimit (__NR_SYSCALL_BASE + 191) +#define __NR_mmap2 (__NR_SYSCALL_BASE + 192) +#define __NR_truncate64 (__NR_SYSCALL_BASE + 193) +#define __NR_ftruncate64 (__NR_SYSCALL_BASE + 194) +#define __NR_stat64 (__NR_SYSCALL_BASE + 195) +#define __NR_lstat64 (__NR_SYSCALL_BASE + 196) +#define __NR_fstat64 (__NR_SYSCALL_BASE + 197) +#define __NR_lchown32 (__NR_SYSCALL_BASE + 198) +#define __NR_getuid32 (__NR_SYSCALL_BASE + 199) +#define __NR_getgid32 (__NR_SYSCALL_BASE + 200) +#define __NR_geteuid32 (__NR_SYSCALL_BASE + 201) +#define __NR_getegid32 (__NR_SYSCALL_BASE + 202) +#define __NR_setreuid32 (__NR_SYSCALL_BASE + 203) +#define __NR_setregid32 (__NR_SYSCALL_BASE + 204) +#define __NR_getgroups32 (__NR_SYSCALL_BASE + 205) +#define __NR_setgroups32 (__NR_SYSCALL_BASE + 206) +#define __NR_fchown32 (__NR_SYSCALL_BASE + 207) +#define __NR_setresuid32 (__NR_SYSCALL_BASE + 208) +#define __NR_getresuid32 (__NR_SYSCALL_BASE + 209) +#define __NR_setresgid32 (__NR_SYSCALL_BASE + 210) +#define __NR_getresgid32 (__NR_SYSCALL_BASE + 211) +#define __NR_chown32 (__NR_SYSCALL_BASE + 212) +#define __NR_setuid32 (__NR_SYSCALL_BASE + 213) +#define __NR_setgid32 (__NR_SYSCALL_BASE + 214) +#define __NR_setfsuid32 (__NR_SYSCALL_BASE + 215) +#define __NR_setfsgid32 (__NR_SYSCALL_BASE + 216) +#define __NR_getdents64 (__NR_SYSCALL_BASE + 217) +#define __NR_pivot_root (__NR_SYSCALL_BASE + 218) +#define __NR_mincore (__NR_SYSCALL_BASE + 219) +#define __NR_madvise (__NR_SYSCALL_BASE + 220) +#define __NR_fcntl64 (__NR_SYSCALL_BASE + 221) +#define __NR_gettid (__NR_SYSCALL_BASE + 224) +#define __NR_readahead (__NR_SYSCALL_BASE + 225) +#define __NR_setxattr (__NR_SYSCALL_BASE + 226) +#define __NR_lsetxattr (__NR_SYSCALL_BASE + 227) +#define __NR_fsetxattr (__NR_SYSCALL_BASE + 228) +#define __NR_getxattr (__NR_SYSCALL_BASE + 229) +#define __NR_lgetxattr (__NR_SYSCALL_BASE + 230) +#define __NR_fgetxattr (__NR_SYSCALL_BASE + 231) +#define __NR_listxattr (__NR_SYSCALL_BASE + 232) +#define __NR_llistxattr (__NR_SYSCALL_BASE + 233) +#define __NR_flistxattr (__NR_SYSCALL_BASE + 234) +#define __NR_removexattr (__NR_SYSCALL_BASE + 235) +#define __NR_lremovexattr (__NR_SYSCALL_BASE + 236) +#define __NR_fremovexattr (__NR_SYSCALL_BASE + 237) +#define __NR_tkill (__NR_SYSCALL_BASE + 238) +#define __NR_sendfile64 (__NR_SYSCALL_BASE + 239) +#define __NR_futex (__NR_SYSCALL_BASE + 240) +#define __NR_sched_setaffinity (__NR_SYSCALL_BASE + 241) +#define __NR_sched_getaffinity (__NR_SYSCALL_BASE + 242) +#define __NR_io_setup (__NR_SYSCALL_BASE + 243) +#define __NR_io_destroy (__NR_SYSCALL_BASE + 244) +#define __NR_io_getevents (__NR_SYSCALL_BASE + 245) +#define __NR_io_submit (__NR_SYSCALL_BASE + 246) +#define __NR_io_cancel (__NR_SYSCALL_BASE + 247) +#define __NR_exit_group (__NR_SYSCALL_BASE + 248) +#define __NR_lookup_dcookie (__NR_SYSCALL_BASE + 249) +#define __NR_epoll_create (__NR_SYSCALL_BASE + 250) +#define __NR_epoll_ctl (__NR_SYSCALL_BASE + 251) +#define __NR_epoll_wait (__NR_SYSCALL_BASE + 252) +#define __NR_remap_file_pages (__NR_SYSCALL_BASE + 253) +#define __NR_set_tid_address (__NR_SYSCALL_BASE + 256) +#define __NR_timer_create (__NR_SYSCALL_BASE + 257) +#define __NR_timer_settime (__NR_SYSCALL_BASE + 258) +#define __NR_timer_gettime (__NR_SYSCALL_BASE + 259) +#define __NR_timer_getoverrun (__NR_SYSCALL_BASE + 260) +#define __NR_timer_delete (__NR_SYSCALL_BASE + 261) +#define __NR_clock_settime (__NR_SYSCALL_BASE + 262) +#define __NR_clock_gettime (__NR_SYSCALL_BASE + 263) +#define __NR_clock_getres (__NR_SYSCALL_BASE + 264) +#define __NR_clock_nanosleep (__NR_SYSCALL_BASE + 265) +#define __NR_statfs64 (__NR_SYSCALL_BASE + 266) +#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267) +#define __NR_tgkill (__NR_SYSCALL_BASE + 268) +#define __NR_utimes (__NR_SYSCALL_BASE + 269) +#define __NR_arm_fadvise64_64 (__NR_SYSCALL_BASE + 270) +#define __NR_pciconfig_iobase (__NR_SYSCALL_BASE + 271) +#define __NR_pciconfig_read (__NR_SYSCALL_BASE + 272) +#define __NR_pciconfig_write (__NR_SYSCALL_BASE + 273) +#define __NR_mq_open (__NR_SYSCALL_BASE + 274) +#define __NR_mq_unlink (__NR_SYSCALL_BASE + 275) +#define __NR_mq_timedsend (__NR_SYSCALL_BASE + 276) +#define __NR_mq_timedreceive (__NR_SYSCALL_BASE + 277) +#define __NR_mq_notify (__NR_SYSCALL_BASE + 278) +#define __NR_mq_getsetattr (__NR_SYSCALL_BASE + 279) +#define __NR_waitid (__NR_SYSCALL_BASE + 280) +#define __NR_socket (__NR_SYSCALL_BASE + 281) +#define __NR_bind (__NR_SYSCALL_BASE + 282) +#define __NR_connect (__NR_SYSCALL_BASE + 283) +#define __NR_listen (__NR_SYSCALL_BASE + 284) +#define __NR_accept (__NR_SYSCALL_BASE + 285) +#define __NR_getsockname (__NR_SYSCALL_BASE + 286) +#define __NR_getpeername (__NR_SYSCALL_BASE + 287) +#define __NR_socketpair (__NR_SYSCALL_BASE + 288) +#define __NR_send (__NR_SYSCALL_BASE + 289) +#define __NR_sendto (__NR_SYSCALL_BASE + 290) +#define __NR_recv (__NR_SYSCALL_BASE + 291) +#define __NR_recvfrom (__NR_SYSCALL_BASE + 292) +#define __NR_shutdown (__NR_SYSCALL_BASE + 293) +#define __NR_setsockopt (__NR_SYSCALL_BASE + 294) +#define __NR_getsockopt (__NR_SYSCALL_BASE + 295) +#define __NR_sendmsg (__NR_SYSCALL_BASE + 296) +#define __NR_recvmsg (__NR_SYSCALL_BASE + 297) +#define __NR_semop (__NR_SYSCALL_BASE + 298) +#define __NR_semget (__NR_SYSCALL_BASE + 299) +#define __NR_semctl (__NR_SYSCALL_BASE + 300) +#define __NR_msgsnd (__NR_SYSCALL_BASE + 301) +#define __NR_msgrcv (__NR_SYSCALL_BASE + 302) +#define __NR_msgget (__NR_SYSCALL_BASE + 303) +#define __NR_msgctl (__NR_SYSCALL_BASE + 304) +#define __NR_shmat (__NR_SYSCALL_BASE + 305) +#define __NR_shmdt (__NR_SYSCALL_BASE + 306) +#define __NR_shmget (__NR_SYSCALL_BASE + 307) +#define __NR_shmctl (__NR_SYSCALL_BASE + 308) +#define __NR_add_key (__NR_SYSCALL_BASE + 309) +#define __NR_request_key (__NR_SYSCALL_BASE + 310) +#define __NR_keyctl (__NR_SYSCALL_BASE + 311) +#define __NR_semtimedop (__NR_SYSCALL_BASE + 312) +#define __NR_vserver (__NR_SYSCALL_BASE + 313) +#define __NR_ioprio_set (__NR_SYSCALL_BASE + 314) +#define __NR_ioprio_get (__NR_SYSCALL_BASE + 315) +#define __NR_inotify_init (__NR_SYSCALL_BASE + 316) +#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 317) +#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 318) +#define __NR_mbind (__NR_SYSCALL_BASE + 319) +#define __NR_get_mempolicy (__NR_SYSCALL_BASE + 320) +#define __NR_set_mempolicy (__NR_SYSCALL_BASE + 321) +#define __NR_openat (__NR_SYSCALL_BASE + 322) +#define __NR_mkdirat (__NR_SYSCALL_BASE + 323) +#define __NR_mknodat (__NR_SYSCALL_BASE + 324) +#define __NR_fchownat (__NR_SYSCALL_BASE + 325) +#define __NR_futimesat (__NR_SYSCALL_BASE + 326) +#define __NR_fstatat64 (__NR_SYSCALL_BASE + 327) +#define __NR_unlinkat (__NR_SYSCALL_BASE + 328) +#define __NR_renameat (__NR_SYSCALL_BASE + 329) +#define __NR_linkat (__NR_SYSCALL_BASE + 330) +#define __NR_symlinkat (__NR_SYSCALL_BASE + 331) +#define __NR_readlinkat (__NR_SYSCALL_BASE + 332) +#define __NR_fchmodat (__NR_SYSCALL_BASE + 333) +#define __NR_faccessat (__NR_SYSCALL_BASE + 334) +#define __NR_pselect6 (__NR_SYSCALL_BASE + 335) +#define __NR_ppoll (__NR_SYSCALL_BASE + 336) +#define __NR_unshare (__NR_SYSCALL_BASE + 337) +#define __NR_set_robust_list (__NR_SYSCALL_BASE + 338) +#define __NR_get_robust_list (__NR_SYSCALL_BASE + 339) +#define __NR_splice (__NR_SYSCALL_BASE + 340) +#define __NR_arm_sync_file_range (__NR_SYSCALL_BASE + 341) +#define __NR_tee (__NR_SYSCALL_BASE + 342) +#define __NR_vmsplice (__NR_SYSCALL_BASE + 343) +#define __NR_move_pages (__NR_SYSCALL_BASE + 344) +#define __NR_getcpu (__NR_SYSCALL_BASE + 345) +#define __NR_epoll_pwait (__NR_SYSCALL_BASE + 346) +#define __NR_kexec_load (__NR_SYSCALL_BASE + 347) +#define __NR_utimensat (__NR_SYSCALL_BASE + 348) +#define __NR_signalfd (__NR_SYSCALL_BASE + 349) +#define __NR_timerfd_create (__NR_SYSCALL_BASE + 350) +#define __NR_eventfd (__NR_SYSCALL_BASE + 351) +#define __NR_fallocate (__NR_SYSCALL_BASE + 352) +#define __NR_timerfd_settime (__NR_SYSCALL_BASE + 353) +#define __NR_timerfd_gettime (__NR_SYSCALL_BASE + 354) +#define __NR_signalfd4 (__NR_SYSCALL_BASE + 355) +#define __NR_eventfd2 (__NR_SYSCALL_BASE + 356) +#define __NR_epoll_create1 (__NR_SYSCALL_BASE + 357) +#define __NR_dup3 (__NR_SYSCALL_BASE + 358) +#define __NR_pipe2 (__NR_SYSCALL_BASE + 359) +#define __NR_inotify_init1 (__NR_SYSCALL_BASE + 360) +#define __NR_preadv (__NR_SYSCALL_BASE + 361) +#define __NR_pwritev (__NR_SYSCALL_BASE + 362) +#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE + 363) +#define __NR_perf_event_open (__NR_SYSCALL_BASE + 364) +#define __NR_recvmmsg (__NR_SYSCALL_BASE + 365) +#define __NR_accept4 (__NR_SYSCALL_BASE + 366) +#define __NR_fanotify_init (__NR_SYSCALL_BASE + 367) +#define __NR_fanotify_mark (__NR_SYSCALL_BASE + 368) +#define __NR_prlimit64 (__NR_SYSCALL_BASE + 369) +#define __NR_name_to_handle_at (__NR_SYSCALL_BASE + 370) +#define __NR_open_by_handle_at (__NR_SYSCALL_BASE + 371) +#define __NR_clock_adjtime (__NR_SYSCALL_BASE + 372) +#define __NR_syncfs (__NR_SYSCALL_BASE + 373) +#define __NR_sendmmsg (__NR_SYSCALL_BASE + 374) +#define __NR_setns (__NR_SYSCALL_BASE + 375) +#define __NR_process_vm_readv (__NR_SYSCALL_BASE + 376) +#define __NR_process_vm_writev (__NR_SYSCALL_BASE + 377) +#define __NR_kcmp (__NR_SYSCALL_BASE + 378) +#define __NR_finit_module (__NR_SYSCALL_BASE + 379) +#define __NR_sched_setattr (__NR_SYSCALL_BASE + 380) +#define __NR_sched_getattr (__NR_SYSCALL_BASE + 381) +#define __NR_renameat2 (__NR_SYSCALL_BASE + 382) +#define __NR_seccomp (__NR_SYSCALL_BASE + 383) +#define __NR_getrandom (__NR_SYSCALL_BASE + 384) +#define __NR_memfd_create (__NR_SYSCALL_BASE + 385) +#define __NR_bpf (__NR_SYSCALL_BASE + 386) +#define __NR_execveat (__NR_SYSCALL_BASE + 387) +#define __NR_userfaultfd (__NR_SYSCALL_BASE + 388) +#define __NR_membarrier (__NR_SYSCALL_BASE + 389) +#define __NR_mlock2 (__NR_SYSCALL_BASE + 390) +#define __NR_copy_file_range (__NR_SYSCALL_BASE + 391) +#define __NR_preadv2 (__NR_SYSCALL_BASE + 392) +#define __NR_pwritev2 (__NR_SYSCALL_BASE + 393) +#define __NR_pkey_mprotect (__NR_SYSCALL_BASE + 394) +#define __NR_pkey_alloc (__NR_SYSCALL_BASE + 395) +#define __NR_pkey_free (__NR_SYSCALL_BASE + 396) +#define __NR_statx (__NR_SYSCALL_BASE + 397) +#define __NR_rseq (__NR_SYSCALL_BASE + 398) +#define __NR_io_pgetevents (__NR_SYSCALL_BASE + 399) +#define __NR_migrate_pages (__NR_SYSCALL_BASE + 400) +#define __NR_kexec_file_load (__NR_SYSCALL_BASE + 401) +#define __NR_clock_gettime64 (__NR_SYSCALL_BASE + 403) +#define __NR_clock_settime64 (__NR_SYSCALL_BASE + 404) +#define __NR_clock_adjtime64 (__NR_SYSCALL_BASE + 405) +#define __NR_clock_getres_time64 (__NR_SYSCALL_BASE + 406) +#define __NR_clock_nanosleep_time64 (__NR_SYSCALL_BASE + 407) +#define __NR_timer_gettime64 (__NR_SYSCALL_BASE + 408) +#define __NR_timer_settime64 (__NR_SYSCALL_BASE + 409) +#define __NR_timerfd_gettime64 (__NR_SYSCALL_BASE + 410) +#define __NR_timerfd_settime64 (__NR_SYSCALL_BASE + 411) +#define __NR_utimensat_time64 (__NR_SYSCALL_BASE + 412) +#define __NR_pselect6_time64 (__NR_SYSCALL_BASE + 413) +#define __NR_ppoll_time64 (__NR_SYSCALL_BASE + 414) +#define __NR_io_pgetevents_time64 (__NR_SYSCALL_BASE + 416) +#define __NR_recvmmsg_time64 (__NR_SYSCALL_BASE + 417) +#define __NR_mq_timedsend_time64 (__NR_SYSCALL_BASE + 418) +#define __NR_mq_timedreceive_time64 (__NR_SYSCALL_BASE + 419) +#define __NR_semtimedop_time64 (__NR_SYSCALL_BASE + 420) +#define __NR_rt_sigtimedwait_time64 (__NR_SYSCALL_BASE + 421) +#define __NR_futex_time64 (__NR_SYSCALL_BASE + 422) +#define __NR_sched_rr_get_interval_time64 (__NR_SYSCALL_BASE + 423) +#define __NR_pidfd_send_signal (__NR_SYSCALL_BASE + 424) +#define __NR_io_uring_setup (__NR_SYSCALL_BASE + 425) +#define __NR_io_uring_enter (__NR_SYSCALL_BASE + 426) +#define __NR_io_uring_register (__NR_SYSCALL_BASE + 427) +#define __NR_open_tree (__NR_SYSCALL_BASE + 428) +#define __NR_move_mount (__NR_SYSCALL_BASE + 429) +#define __NR_fsopen (__NR_SYSCALL_BASE + 430) +#define __NR_fsconfig (__NR_SYSCALL_BASE + 431) +#define __NR_fsmount (__NR_SYSCALL_BASE + 432) +#define __NR_fspick (__NR_SYSCALL_BASE + 433) +#define __NR_pidfd_open (__NR_SYSCALL_BASE + 434) +#define __NR_clone3 (__NR_SYSCALL_BASE + 435) +#define __NR_close_range (__NR_SYSCALL_BASE + 436) +#define __NR_openat2 (__NR_SYSCALL_BASE + 437) +#define __NR_pidfd_getfd (__NR_SYSCALL_BASE + 438) +#define __NR_faccessat2 (__NR_SYSCALL_BASE + 439) +#define __NR_process_madvise (__NR_SYSCALL_BASE + 440) +#define __NR_epoll_pwait2 (__NR_SYSCALL_BASE + 441) +#define __NR_mount_setattr (__NR_SYSCALL_BASE + 442) +#define __NR_quotactl_fd (__NR_SYSCALL_BASE + 443) +#define __NR_landlock_create_ruleset (__NR_SYSCALL_BASE + 444) +#define __NR_landlock_add_rule (__NR_SYSCALL_BASE + 445) +#define __NR_landlock_restrict_self (__NR_SYSCALL_BASE + 446) +#define __NR_process_mrelease (__NR_SYSCALL_BASE + 448) + +#endif /* _ASM_UNISTD_OABI_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd.h new file mode 100755 index 0000000..1b346d1 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/asm/unistd.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * arch/arm/include/asm/unistd.h + * + * Copyright (C) 2001-2005 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Please forward _all_ changes to this file to rmk@arm.linux.org.uk, + * no matter what the change is. Thanks! + */ +#ifndef __ASM_ARM_UNISTD_H +#define __ASM_ARM_UNISTD_H + +#define __NR_OABI_SYSCALL_BASE 0x900000 +#define __NR_SYSCALL_MASK 0x0fffff + +#if defined(__thumb__) || defined(__ARM_EABI__) +#define __NR_SYSCALL_BASE 0 +#include +#else +#define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE +#include +#endif + +#define __NR_sync_file_range2 __NR_arm_sync_file_range + +/* + * The following SWIs are ARM private. + */ +#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000) +#define __ARM_NR_breakpoint (__ARM_NR_BASE+1) +#define __ARM_NR_cacheflush (__ARM_NR_BASE+2) +#define __ARM_NR_usr26 (__ARM_NR_BASE+3) +#define __ARM_NR_usr32 (__ARM_NR_BASE+4) +#define __ARM_NR_set_tls (__ARM_NR_BASE+5) +#define __ARM_NR_get_tls (__ARM_NR_BASE+6) + +#endif /* __ASM_ARM_UNISTD_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/assert.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/assert.h new file mode 100755 index 0000000..d14ec94 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/assert.h @@ -0,0 +1,23 @@ +#include + +#undef assert + +#ifdef NDEBUG +#define assert(x) (void)0 +#else +#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) +#endif + +#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus) +#define static_assert _Static_assert +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_Noreturn void __assert_fail (const char *, const char *, int, const char *); + +#ifdef __cplusplus +} +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/alltypes.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/alltypes.h new file mode 100755 index 0000000..2bc88cd --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/alltypes.h @@ -0,0 +1,408 @@ +#define _REDIR_TIME64 1 +#define _Addr int +#define _Int64 long long +#define _Reg int + +#if __ARMEB__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif + +#define __LONG_MAX 0x7fffffffL + +#ifndef __cplusplus +#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) +typedef unsigned wchar_t; +#define __DEFINED_wchar_t +#endif + +#endif + +#if defined(__NEED_float_t) && !defined(__DEFINED_float_t) +typedef float float_t; +#define __DEFINED_float_t +#endif + +#if defined(__NEED_double_t) && !defined(__DEFINED_double_t) +typedef double double_t; +#define __DEFINED_double_t +#endif + + +#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t) +typedef struct { long long __ll; long double __ld; } max_align_t; +#define __DEFINED_max_align_t +#endif + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __USE_TIME_BITS64 1 + +#if defined(__NEED_size_t) && !defined(__DEFINED_size_t) +typedef unsigned _Addr size_t; +#define __DEFINED_size_t +#endif + +#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t) +typedef unsigned _Addr uintptr_t; +#define __DEFINED_uintptr_t +#endif + +#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t) +typedef _Addr ptrdiff_t; +#define __DEFINED_ptrdiff_t +#endif + +#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t) +typedef _Addr ssize_t; +#define __DEFINED_ssize_t +#endif + +#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t) +typedef _Addr intptr_t; +#define __DEFINED_intptr_t +#endif + +#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t) +typedef _Addr regoff_t; +#define __DEFINED_regoff_t +#endif + +#if defined(__NEED_register_t) && !defined(__DEFINED_register_t) +typedef _Reg register_t; +#define __DEFINED_register_t +#endif + +#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) +typedef _Int64 time_t; +#define __DEFINED_time_t +#endif + +#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) +typedef _Int64 suseconds_t; +#define __DEFINED_suseconds_t +#endif + + +#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t) +typedef signed char int8_t; +#define __DEFINED_int8_t +#endif + +#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t) +typedef signed short int16_t; +#define __DEFINED_int16_t +#endif + +#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t) +typedef signed int int32_t; +#define __DEFINED_int32_t +#endif + +#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t) +typedef signed _Int64 int64_t; +#define __DEFINED_int64_t +#endif + +#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t) +typedef signed _Int64 intmax_t; +#define __DEFINED_intmax_t +#endif + +#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t) +typedef unsigned char uint8_t; +#define __DEFINED_uint8_t +#endif + +#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t) +typedef unsigned short uint16_t; +#define __DEFINED_uint16_t +#endif + +#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t) +typedef unsigned int uint32_t; +#define __DEFINED_uint32_t +#endif + +#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t) +typedef unsigned _Int64 uint64_t; +#define __DEFINED_uint64_t +#endif + +#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t) +typedef unsigned _Int64 u_int64_t; +#define __DEFINED_u_int64_t +#endif + +#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t) +typedef unsigned _Int64 uintmax_t; +#define __DEFINED_uintmax_t +#endif + + +#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t) +typedef unsigned mode_t; +#define __DEFINED_mode_t +#endif + +#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t) +typedef unsigned _Reg nlink_t; +#define __DEFINED_nlink_t +#endif + +#if defined(__NEED_off_t) && !defined(__DEFINED_off_t) +typedef _Int64 off_t; +#define __DEFINED_off_t +#endif + +#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t) +typedef unsigned _Int64 ino_t; +#define __DEFINED_ino_t +#endif + +#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t) +typedef unsigned _Int64 dev_t; +#define __DEFINED_dev_t +#endif + +#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) +typedef long blksize_t; +#define __DEFINED_blksize_t +#endif + +#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t) +typedef _Int64 blkcnt_t; +#define __DEFINED_blkcnt_t +#endif + +#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t) +typedef unsigned _Int64 fsblkcnt_t; +#define __DEFINED_fsblkcnt_t +#endif + +#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t) +typedef unsigned _Int64 fsfilcnt_t; +#define __DEFINED_fsfilcnt_t +#endif + + +#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t) +typedef unsigned wint_t; +#define __DEFINED_wint_t +#endif + +#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t) +typedef unsigned long wctype_t; +#define __DEFINED_wctype_t +#endif + + +#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t) +typedef void * timer_t; +#define __DEFINED_timer_t +#endif + +#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t) +typedef int clockid_t; +#define __DEFINED_clockid_t +#endif + +#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t) +typedef long clock_t; +#define __DEFINED_clock_t +#endif + +#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval) +struct timeval { time_t tv_sec; suseconds_t tv_usec; }; +#define __DEFINED_struct_timeval +#endif + +#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec) +struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); }; +#define __DEFINED_struct_timespec +#endif + + +#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t) +typedef int pid_t; +#define __DEFINED_pid_t +#endif + +#if defined(__NEED_id_t) && !defined(__DEFINED_id_t) +typedef unsigned id_t; +#define __DEFINED_id_t +#endif + +#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t) +typedef unsigned uid_t; +#define __DEFINED_uid_t +#endif + +#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t) +typedef unsigned gid_t; +#define __DEFINED_gid_t +#endif + +#if defined(__NEED_key_t) && !defined(__DEFINED_key_t) +typedef int key_t; +#define __DEFINED_key_t +#endif + +#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t) +typedef unsigned useconds_t; +#define __DEFINED_useconds_t +#endif + + +#ifdef __cplusplus +#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) +typedef unsigned long pthread_t; +#define __DEFINED_pthread_t +#endif + +#else +#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) +typedef struct __pthread * pthread_t; +#define __DEFINED_pthread_t +#endif + +#endif +#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t) +typedef int pthread_once_t; +#define __DEFINED_pthread_once_t +#endif + +#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t) +typedef unsigned pthread_key_t; +#define __DEFINED_pthread_key_t +#endif + +#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t) +typedef int pthread_spinlock_t; +#define __DEFINED_pthread_spinlock_t +#endif + +#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t) +typedef struct { unsigned __attr; } pthread_mutexattr_t; +#define __DEFINED_pthread_mutexattr_t +#endif + +#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t) +typedef struct { unsigned __attr; } pthread_condattr_t; +#define __DEFINED_pthread_condattr_t +#endif + +#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t) +typedef struct { unsigned __attr; } pthread_barrierattr_t; +#define __DEFINED_pthread_barrierattr_t +#endif + +#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t) +typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t; +#define __DEFINED_pthread_rwlockattr_t +#endif + + +#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE) +struct _IO_FILE { char __x; }; +#define __DEFINED_struct__IO_FILE +#endif + +#if defined(__NEED_FILE) && !defined(__DEFINED_FILE) +typedef struct _IO_FILE FILE; +#define __DEFINED_FILE +#endif + + +#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) +typedef __builtin_va_list va_list; +#define __DEFINED_va_list +#endif + +#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) +typedef __builtin_va_list __isoc_va_list; +#define __DEFINED___isoc_va_list +#endif + + +#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t) +typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; +#define __DEFINED_mbstate_t +#endif + + +#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t) +typedef struct __locale_struct * locale_t; +#define __DEFINED_locale_t +#endif + + +#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t) +typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; +#define __DEFINED_sigset_t +#endif + + +#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec) +struct iovec { void *iov_base; size_t iov_len; }; +#define __DEFINED_struct_iovec +#endif + + +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + +#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) +typedef unsigned socklen_t; +#define __DEFINED_socklen_t +#endif + +#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t) +typedef unsigned short sa_family_t; +#define __DEFINED_sa_family_t +#endif + + +#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) +typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t; +#define __DEFINED_pthread_attr_t +#endif + +#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) +typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t; +#define __DEFINED_pthread_mutex_t +#endif + +#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) +typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t; +#define __DEFINED_mtx_t +#endif + +#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) +typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t; +#define __DEFINED_pthread_cond_t +#endif + +#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) +typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t; +#define __DEFINED_cnd_t +#endif + +#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) +typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t; +#define __DEFINED_pthread_rwlock_t +#endif + +#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) +typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t; +#define __DEFINED_pthread_barrier_t +#endif + + +#undef _Addr +#undef _Int64 +#undef _Reg diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/dirent.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/dirent.h new file mode 100755 index 0000000..c845fe8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/dirent.h @@ -0,0 +1,11 @@ +#define _DIRENT_HAVE_D_RECLEN +#define _DIRENT_HAVE_D_OFF +#define _DIRENT_HAVE_D_TYPE + +struct dirent { + ino_t d_ino; + off_t d_off; + unsigned short d_reclen; + unsigned char d_type; + char d_name[256]; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/errno.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/errno.h new file mode 100755 index 0000000..d2e1eee --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/errno.h @@ -0,0 +1,134 @@ +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 +#define ELOOP 40 +#define EWOULDBLOCK EAGAIN +#define ENOMSG 42 +#define EIDRM 43 +#define ECHRNG 44 +#define EL2NSYNC 45 +#define EL3HLT 46 +#define EL3RST 47 +#define ELNRNG 48 +#define EUNATCH 49 +#define ENOCSI 50 +#define EL2HLT 51 +#define EBADE 52 +#define EBADR 53 +#define EXFULL 54 +#define ENOANO 55 +#define EBADRQC 56 +#define EBADSLT 57 +#define EDEADLOCK EDEADLK +#define EBFONT 59 +#define ENOSTR 60 +#define ENODATA 61 +#define ETIME 62 +#define ENOSR 63 +#define ENONET 64 +#define ENOPKG 65 +#define EREMOTE 66 +#define ENOLINK 67 +#define EADV 68 +#define ESRMNT 69 +#define ECOMM 70 +#define EPROTO 71 +#define EMULTIHOP 72 +#define EDOTDOT 73 +#define EBADMSG 74 +#define EOVERFLOW 75 +#define ENOTUNIQ 76 +#define EBADFD 77 +#define EREMCHG 78 +#define ELIBACC 79 +#define ELIBBAD 80 +#define ELIBSCN 81 +#define ELIBMAX 82 +#define ELIBEXEC 83 +#define EILSEQ 84 +#define ERESTART 85 +#define ESTRPIPE 86 +#define EUSERS 87 +#define ENOTSOCK 88 +#define EDESTADDRREQ 89 +#define EMSGSIZE 90 +#define EPROTOTYPE 91 +#define ENOPROTOOPT 92 +#define EPROTONOSUPPORT 93 +#define ESOCKTNOSUPPORT 94 +#define EOPNOTSUPP 95 +#define ENOTSUP EOPNOTSUPP +#define EPFNOSUPPORT 96 +#define EAFNOSUPPORT 97 +#define EADDRINUSE 98 +#define EADDRNOTAVAIL 99 +#define ENETDOWN 100 +#define ENETUNREACH 101 +#define ENETRESET 102 +#define ECONNABORTED 103 +#define ECONNRESET 104 +#define ENOBUFS 105 +#define EISCONN 106 +#define ENOTCONN 107 +#define ESHUTDOWN 108 +#define ETOOMANYREFS 109 +#define ETIMEDOUT 110 +#define ECONNREFUSED 111 +#define EHOSTDOWN 112 +#define EHOSTUNREACH 113 +#define EALREADY 114 +#define EINPROGRESS 115 +#define ESTALE 116 +#define EUCLEAN 117 +#define ENOTNAM 118 +#define ENAVAIL 119 +#define EISNAM 120 +#define EREMOTEIO 121 +#define EDQUOT 122 +#define ENOMEDIUM 123 +#define EMEDIUMTYPE 124 +#define ECANCELED 125 +#define ENOKEY 126 +#define EKEYEXPIRED 127 +#define EKEYREVOKED 128 +#define EKEYREJECTED 129 +#define EOWNERDEAD 130 +#define ENOTRECOVERABLE 131 +#define ERFKILL 132 +#define EHWPOISON 133 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/fcntl.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/fcntl.h new file mode 100755 index 0000000..4cb1753 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/fcntl.h @@ -0,0 +1,40 @@ +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_NOCTTY 0400 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_DSYNC 010000 +#define O_SYNC 04010000 +#define O_RSYNC 04010000 +#define O_DIRECTORY 040000 +#define O_NOFOLLOW 0100000 +#define O_CLOEXEC 02000000 + +#define O_ASYNC 020000 +#define O_DIRECT 0200000 +#define O_LARGEFILE 0400000 +#define O_NOATIME 01000000 +#define O_PATH 010000000 +#define O_TMPFILE 020040000 +#define O_NDELAY O_NONBLOCK + +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 + +#define F_SETOWN 8 +#define F_GETOWN 9 +#define F_SETSIG 10 +#define F_GETSIG 11 + +#define F_GETLK 12 +#define F_SETLK 13 +#define F_SETLKW 14 + +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 + +#define F_GETOWNER_UIDS 17 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/fenv.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/fenv.h new file mode 100755 index 0000000..d85fc86 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/fenv.h @@ -0,0 +1,23 @@ +#ifndef __ARM_PCS_VFP +#define FE_ALL_EXCEPT 0 +#define FE_TONEAREST 0 +#else +#define FE_INVALID 1 +#define FE_DIVBYZERO 2 +#define FE_OVERFLOW 4 +#define FE_UNDERFLOW 8 +#define FE_INEXACT 16 +#define FE_ALL_EXCEPT 31 +#define FE_TONEAREST 0 +#define FE_DOWNWARD 0x800000 +#define FE_UPWARD 0x400000 +#define FE_TOWARDZERO 0xc00000 +#endif + +typedef unsigned long fexcept_t; + +typedef struct { + unsigned long __cw; +} fenv_t; + +#define FE_DFL_ENV ((const fenv_t *) -1) diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/float.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/float.h new file mode 100755 index 0000000..c4a655e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/float.h @@ -0,0 +1,16 @@ +#define FLT_EVAL_METHOD 0 + +#define LDBL_TRUE_MIN 4.94065645841246544177e-324L +#define LDBL_MIN 2.22507385850720138309e-308L +#define LDBL_MAX 1.79769313486231570815e+308L +#define LDBL_EPSILON 2.22044604925031308085e-16L + +#define LDBL_MANT_DIG 53 +#define LDBL_MIN_EXP (-1021) +#define LDBL_MAX_EXP 1024 + +#define LDBL_DIG 15 +#define LDBL_MIN_10_EXP (-307) +#define LDBL_MAX_10_EXP 308 + +#define DECIMAL_DIG 17 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/hwcap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/hwcap.h new file mode 100755 index 0000000..a3d8731 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/hwcap.h @@ -0,0 +1,53 @@ +#define HWCAP_SWP (1 << 0) +#define HWCAP_HALF (1 << 1) +#define HWCAP_THUMB (1 << 2) +#define HWCAP_26BIT (1 << 3) +#define HWCAP_FAST_MULT (1 << 4) +#define HWCAP_FPA (1 << 5) +#define HWCAP_VFP (1 << 6) +#define HWCAP_EDSP (1 << 7) +#define HWCAP_JAVA (1 << 8) +#define HWCAP_IWMMXT (1 << 9) +#define HWCAP_CRUNCH (1 << 10) +#define HWCAP_THUMBEE (1 << 11) +#define HWCAP_NEON (1 << 12) +#define HWCAP_VFPv3 (1 << 13) +#define HWCAP_VFPv3D16 (1 << 14) +#define HWCAP_TLS (1 << 15) +#define HWCAP_VFPv4 (1 << 16) +#define HWCAP_IDIVA (1 << 17) +#define HWCAP_IDIVT (1 << 18) +#define HWCAP_VFPD32 (1 << 19) +#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) +#define HWCAP_LPAE (1 << 20) +#define HWCAP_EVTSTRM (1 << 21) + +#define HWCAP2_AES (1 << 0) +#define HWCAP2_PMULL (1 << 1) +#define HWCAP2_SHA1 (1 << 2) +#define HWCAP2_SHA2 (1 << 3) +#define HWCAP2_CRC32 (1 << 4) + +#define HWCAP_ARM_SWP (1 << 0) +#define HWCAP_ARM_HALF (1 << 1) +#define HWCAP_ARM_THUMB (1 << 2) +#define HWCAP_ARM_26BIT (1 << 3) +#define HWCAP_ARM_FAST_MULT (1 << 4) +#define HWCAP_ARM_FPA (1 << 5) +#define HWCAP_ARM_VFP (1 << 6) +#define HWCAP_ARM_EDSP (1 << 7) +#define HWCAP_ARM_JAVA (1 << 8) +#define HWCAP_ARM_IWMMXT (1 << 9) +#define HWCAP_ARM_CRUNCH (1 << 10) +#define HWCAP_ARM_THUMBEE (1 << 11) +#define HWCAP_ARM_NEON (1 << 12) +#define HWCAP_ARM_VFPv3 (1 << 13) +#define HWCAP_ARM_VFPv3D16 (1 << 14) +#define HWCAP_ARM_TLS (1 << 15) +#define HWCAP_ARM_VFPv4 (1 << 16) +#define HWCAP_ARM_IDIVA (1 << 17) +#define HWCAP_ARM_IDIVT (1 << 18) +#define HWCAP_ARM_VFPD32 (1 << 19) +#define HWCAP_ARM_IDIV (HWCAP_ARM_IDIVA | HWCAP_ARM_IDIVT) +#define HWCAP_ARM_LPAE (1 << 20) +#define HWCAP_ARM_EVTSTRM (1 << 21) diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/io.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/io.h new file mode 100755 index 0000000..e69de29 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ioctl.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ioctl.h new file mode 100755 index 0000000..60ae8b8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ioctl.h @@ -0,0 +1,115 @@ +#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) ) +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U + +#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0) +#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c)) +#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c)) +#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c)) + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define FIONREAD 0x541B +#define TIOCINQ FIONREAD +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 +#define FIONBIO 0x5421 +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 +#define TIOCSBRK 0x5427 +#define TIOCCBRK 0x5428 +#define TIOCGSID 0x5429 +#define TIOCGRS485 0x542E +#define TIOCSRS485 0x542F +#define TIOCGPTN 0x80045430 +#define TIOCSPTLCK 0x40045431 +#define TIOCGDEV 0x80045432 +#define TCGETX 0x5432 +#define TCSETX 0x5433 +#define TCSETXF 0x5434 +#define TCSETXW 0x5435 +#define TIOCSIG 0x40045436 +#define TIOCVHANGUP 0x5437 +#define TIOCGPKT 0x80045438 +#define TIOCGPTLCK 0x80045439 +#define TIOCGEXCL 0x80045440 +#define TIOCGPTPEER 0x5441 +#define TIOCGISO7816 0x80285442 +#define TIOCSISO7816 0xc0285443 + +#define FIONCLEX 0x5450 +#define FIOCLEX 0x5451 +#define FIOASYNC 0x5452 +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 +#define TIOCSERGETLSR 0x5459 +#define TIOCSERGETMULTI 0x545A +#define TIOCSERSETMULTI 0x545B + +#define TIOCMIWAIT 0x545C +#define TIOCGICOUNT 0x545D +#define FIOQSIZE 0x5460 + +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG +#define TIOCM_OUT1 0x2000 +#define TIOCM_OUT2 0x4000 +#define TIOCM_LOOP 0x8000 + +#define FIOSETOWN 0x8901 +#define SIOCSPGRP 0x8902 +#define FIOGETOWN 0x8903 +#define SIOCGPGRP 0x8904 +#define SIOCATMARK 0x8905 +#if __LONG_MAX == 0x7fffffff +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) +#else +#define SIOCGSTAMP 0x8906 +#define SIOCGSTAMPNS 0x8907 +#endif + +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ioctl_fix.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ioctl_fix.h new file mode 100755 index 0000000..ebb383d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ioctl_fix.h @@ -0,0 +1,2 @@ +#undef FIOQSIZE +#define FIOQSIZE 0x545e diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ipc.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ipc.h new file mode 100755 index 0000000..40d6f3a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ipc.h @@ -0,0 +1,11 @@ +struct ipc_perm { + key_t __ipc_perm_key; + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + int __ipc_perm_seq; + long __pad1; + long __pad2; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ipcstat.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ipcstat.h new file mode 100755 index 0000000..4f4fcb0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 0x102 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/kd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/kd.h new file mode 100755 index 0000000..33b873f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/kd.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/limits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/limits.h new file mode 100755 index 0000000..e69de29 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/link.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/link.h new file mode 100755 index 0000000..4a94d8f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/link.h @@ -0,0 +1 @@ +typedef uint32_t Elf_Symndx; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/mman.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/mman.h new file mode 100755 index 0000000..e69de29 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/msg.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/msg.h new file mode 100755 index 0000000..7bbbb2b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/msg.h @@ -0,0 +1,18 @@ +struct msqid_ds { + struct ipc_perm msg_perm; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; + unsigned long msg_cbytes; + msgqnum_t msg_qnum; + msglen_t msg_qbytes; + pid_t msg_lspid; + pid_t msg_lrpid; + unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/poll.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/poll.h new file mode 100755 index 0000000..e69de29 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/posix.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/posix.h new file mode 100755 index 0000000..30a3871 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/posix.h @@ -0,0 +1,2 @@ +#define _POSIX_V6_ILP32_OFFBIG 1 +#define _POSIX_V7_ILP32_OFFBIG 1 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ptrace.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ptrace.h new file mode 100755 index 0000000..9556ef4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/ptrace.h @@ -0,0 +1,25 @@ +#define PTRACE_GETWMMXREGS 18 +#define PTRACE_SETWMMXREGS 19 +#define PTRACE_GET_THREAD_AREA 22 +#define PTRACE_SET_SYSCALL 23 +#define PTRACE_GETCRUNCHREGS 25 +#define PTRACE_SETCRUNCHREGS 26 +#define PTRACE_GETVFPREGS 27 +#define PTRACE_SETVFPREGS 28 +#define PTRACE_GETHBPREGS 29 +#define PTRACE_SETHBPREGS 30 +#define PTRACE_GETFDPIC 31 +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 + +#define PT_GETWMMXREGS PTRACE_GETWMMXREGS +#define PT_SETWMMXREGS PTRACE_SETWMMXREGS +#define PT_GET_THREAD_AREA PTRACE_GET_THREAD_AREA +#define PT_SET_SYSCALL PTRACE_SET_SYSCALL +#define PT_GETCRUNCHREGS PTRACE_GETCRUNCHREGS +#define PT_SETCRUNCHREGS PTRACE_SETCRUNCHREGS +#define PT_GETVFPREGS PTRACE_GETVFPREGS +#define PT_SETVFPREGS PTRACE_SETVFPREGS +#define PT_GETHBPREGS PTRACE_GETHBPREGS +#define PT_SETHBPREGS PTRACE_SETHBPREGS +#define PT_GETFDPIC PTRACE_GETFDPIC diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/reg.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/reg.h new file mode 100755 index 0000000..0c7bffc --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/reg.h @@ -0,0 +1,3 @@ +#undef __WORDSIZE +#define __WORDSIZE 32 +/* FIXME */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/resource.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/resource.h new file mode 100755 index 0000000..e69de29 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/sem.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/sem.h new file mode 100755 index 0000000..544e3d2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/sem.h @@ -0,0 +1,18 @@ +struct semid_ds { + struct ipc_perm sem_perm; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned short sem_nsems; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; +#else + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + unsigned short sem_nsems; +#endif + long __unused3; + long __unused4; + time_t sem_otime; + time_t sem_ctime; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/setjmp.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/setjmp.h new file mode 100755 index 0000000..55e3a95 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/setjmp.h @@ -0,0 +1 @@ +typedef unsigned long long __jmp_buf[32]; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/shm.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/shm.h new file mode 100755 index 0000000..725fb46 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/shm.h @@ -0,0 +1,31 @@ +#define SHMLBA 4096 + +struct shmid_ds { + struct ipc_perm shm_perm; + size_t shm_segsz; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; + pid_t shm_cpid; + pid_t shm_lpid; + unsigned long shm_nattch; + unsigned long __pad1; + unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; +}; + +struct shminfo { + unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4]; +}; + +struct shm_info { + int __used_ids; + unsigned long shm_tot, shm_rss, shm_swp; + unsigned long __swap_attempts, __swap_successes; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/signal.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/signal.h new file mode 100755 index 0000000..3c78985 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/signal.h @@ -0,0 +1,86 @@ +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +typedef int greg_t, gregset_t[18]; +typedef struct sigcontext { + unsigned long trap_no, error_code, oldmask; + unsigned long arm_r0, arm_r1, arm_r2, arm_r3; + unsigned long arm_r4, arm_r5, arm_r6, arm_r7; + unsigned long arm_r8, arm_r9, arm_r10, arm_fp; + unsigned long arm_ip, arm_sp, arm_lr, arm_pc; + unsigned long arm_cpsr, fault_address; +} mcontext_t; +#else +typedef struct { + unsigned long __regs[21]; +} mcontext_t; +#endif + +struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +}; + +typedef struct __ucontext { + unsigned long uc_flags; + struct __ucontext *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + sigset_t uc_sigmask; + unsigned long long uc_regspace[64]; +} ucontext_t; + +#define SA_NOCLDSTOP 1 +#define SA_NOCLDWAIT 2 +#define SA_SIGINFO 4 +#define SA_ONSTACK 0x08000000 +#define SA_RESTART 0x10000000 +#define SA_NODEFER 0x40000000 +#define SA_RESETHAND 0x80000000 +#define SA_RESTORER 0x04000000 + +#endif + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT SIGABRT +#define SIGBUS 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 +#define SIGURG 23 +#define SIGXCPU 24 +#define SIGXFSZ 25 +#define SIGVTALRM 26 +#define SIGPROF 27 +#define SIGWINCH 28 +#define SIGIO 29 +#define SIGPOLL 29 +#define SIGPWR 30 +#define SIGSYS 31 +#define SIGUNUSED SIGSYS + +#define _NSIG 65 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/socket.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/socket.h new file mode 100755 index 0000000..e69de29 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/soundcard.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/soundcard.h new file mode 100755 index 0000000..fade986 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/soundcard.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/stat.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/stat.h new file mode 100755 index 0000000..5d7828c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/stat.h @@ -0,0 +1,25 @@ +/* copied from kernel definition, but with padding replaced + * by the corresponding correctly-sized userspace types. */ + +struct stat { + dev_t st_dev; + int __st_dev_padding; + long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + int __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + ino_t st_ino; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/statfs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/statfs.h new file mode 100755 index 0000000..f103f4e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/statfs.h @@ -0,0 +1,7 @@ +struct statfs { + unsigned long f_type, f_bsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree; + fsid_t f_fsid; + unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/stdint.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/stdint.h new file mode 100755 index 0000000..d1b2712 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/stdint.h @@ -0,0 +1,20 @@ +typedef int32_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef uint32_t uint_fast16_t; +typedef uint32_t uint_fast32_t; + +#define INT_FAST16_MIN INT32_MIN +#define INT_FAST32_MIN INT32_MIN + +#define INT_FAST16_MAX INT32_MAX +#define INT_FAST32_MAX INT32_MAX + +#define UINT_FAST16_MAX UINT32_MAX +#define UINT_FAST32_MAX UINT32_MAX + +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX +#define PTRDIFF_MIN INT32_MIN +#define PTRDIFF_MAX INT32_MAX +#define SIZE_MAX UINT32_MAX diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/syscall.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/syscall.h new file mode 100755 index 0000000..a9afaed --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/syscall.h @@ -0,0 +1,800 @@ +#define __NR_restart_syscall 0 +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_ptrace 26 +#define __NR_pause 29 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_setpgid 57 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrusage 77 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_symlink 83 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_vhangup 111 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread64 180 +#define __NR_pwrite64 181 +#define __NR_chown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_vfork 190 +#define __NR_ugetrlimit 191 +#define __NR_mmap2 192 +#define __NR_truncate64 193 +#define __NR_ftruncate64 194 +#define __NR_stat64 195 +#define __NR_lstat64 196 +#define __NR_fstat64 197 +#define __NR_lchown32 198 +#define __NR_getuid32 199 +#define __NR_getgid32 200 +#define __NR_geteuid32 201 +#define __NR_getegid32 202 +#define __NR_setreuid32 203 +#define __NR_setregid32 204 +#define __NR_getgroups32 205 +#define __NR_setgroups32 206 +#define __NR_fchown32 207 +#define __NR_setresuid32 208 +#define __NR_getresuid32 209 +#define __NR_setresgid32 210 +#define __NR_getresgid32 211 +#define __NR_chown32 212 +#define __NR_setuid32 213 +#define __NR_setgid32 214 +#define __NR_setfsuid32 215 +#define __NR_setfsgid32 216 +#define __NR_getdents64 217 +#define __NR_pivot_root 218 +#define __NR_mincore 219 +#define __NR_madvise 220 +#define __NR_fcntl64 221 +#define __NR_gettid 224 +#define __NR_readahead 225 +#define __NR_setxattr 226 +#define __NR_lsetxattr 227 +#define __NR_fsetxattr 228 +#define __NR_getxattr 229 +#define __NR_lgetxattr 230 +#define __NR_fgetxattr 231 +#define __NR_listxattr 232 +#define __NR_llistxattr 233 +#define __NR_flistxattr 234 +#define __NR_removexattr 235 +#define __NR_lremovexattr 236 +#define __NR_fremovexattr 237 +#define __NR_tkill 238 +#define __NR_sendfile64 239 +#define __NR_futex 240 +#define __NR_sched_setaffinity 241 +#define __NR_sched_getaffinity 242 +#define __NR_io_setup 243 +#define __NR_io_destroy 244 +#define __NR_io_getevents 245 +#define __NR_io_submit 246 +#define __NR_io_cancel 247 +#define __NR_exit_group 248 +#define __NR_lookup_dcookie 249 +#define __NR_epoll_create 250 +#define __NR_epoll_ctl 251 +#define __NR_epoll_wait 252 +#define __NR_remap_file_pages 253 +#define __NR_set_tid_address 256 +#define __NR_timer_create 257 +#define __NR_timer_settime32 258 +#define __NR_timer_gettime32 259 +#define __NR_timer_getoverrun 260 +#define __NR_timer_delete 261 +#define __NR_clock_settime32 262 +#define __NR_clock_gettime32 263 +#define __NR_clock_getres_time32 264 +#define __NR_clock_nanosleep_time32 265 +#define __NR_statfs64 266 +#define __NR_fstatfs64 267 +#define __NR_tgkill 268 +#define __NR_utimes 269 +#define __NR_fadvise64_64 270 +#define __NR_arm_fadvise64_64 270 +#define __NR_pciconfig_iobase 271 +#define __NR_pciconfig_read 272 +#define __NR_pciconfig_write 273 +#define __NR_mq_open 274 +#define __NR_mq_unlink 275 +#define __NR_mq_timedsend 276 +#define __NR_mq_timedreceive 277 +#define __NR_mq_notify 278 +#define __NR_mq_getsetattr 279 +#define __NR_waitid 280 +#define __NR_socket 281 +#define __NR_bind 282 +#define __NR_connect 283 +#define __NR_listen 284 +#define __NR_accept 285 +#define __NR_getsockname 286 +#define __NR_getpeername 287 +#define __NR_socketpair 288 +#define __NR_send 289 +#define __NR_sendto 290 +#define __NR_recv 291 +#define __NR_recvfrom 292 +#define __NR_shutdown 293 +#define __NR_setsockopt 294 +#define __NR_getsockopt 295 +#define __NR_sendmsg 296 +#define __NR_recvmsg 297 +#define __NR_semop 298 +#define __NR_semget 299 +#define __NR_semctl 300 +#define __NR_msgsnd 301 +#define __NR_msgrcv 302 +#define __NR_msgget 303 +#define __NR_msgctl 304 +#define __NR_shmat 305 +#define __NR_shmdt 306 +#define __NR_shmget 307 +#define __NR_shmctl 308 +#define __NR_add_key 309 +#define __NR_request_key 310 +#define __NR_keyctl 311 +#define __NR_semtimedop 312 +#define __NR_vserver 313 +#define __NR_ioprio_set 314 +#define __NR_ioprio_get 315 +#define __NR_inotify_init 316 +#define __NR_inotify_add_watch 317 +#define __NR_inotify_rm_watch 318 +#define __NR_mbind 319 +#define __NR_get_mempolicy 320 +#define __NR_set_mempolicy 321 +#define __NR_openat 322 +#define __NR_mkdirat 323 +#define __NR_mknodat 324 +#define __NR_fchownat 325 +#define __NR_futimesat 326 +#define __NR_fstatat64 327 +#define __NR_unlinkat 328 +#define __NR_renameat 329 +#define __NR_linkat 330 +#define __NR_symlinkat 331 +#define __NR_readlinkat 332 +#define __NR_fchmodat 333 +#define __NR_faccessat 334 +#define __NR_pselect6 335 +#define __NR_ppoll 336 +#define __NR_unshare 337 +#define __NR_set_robust_list 338 +#define __NR_get_robust_list 339 +#define __NR_splice 340 +#define __NR_sync_file_range2 341 +#define __NR_arm_sync_file_range 341 +#define __NR_tee 342 +#define __NR_vmsplice 343 +#define __NR_move_pages 344 +#define __NR_getcpu 345 +#define __NR_epoll_pwait 346 +#define __NR_kexec_load 347 +#define __NR_utimensat 348 +#define __NR_signalfd 349 +#define __NR_timerfd_create 350 +#define __NR_eventfd 351 +#define __NR_fallocate 352 +#define __NR_timerfd_settime32 353 +#define __NR_timerfd_gettime32 354 +#define __NR_signalfd4 355 +#define __NR_eventfd2 356 +#define __NR_epoll_create1 357 +#define __NR_dup3 358 +#define __NR_pipe2 359 +#define __NR_inotify_init1 360 +#define __NR_preadv 361 +#define __NR_pwritev 362 +#define __NR_rt_tgsigqueueinfo 363 +#define __NR_perf_event_open 364 +#define __NR_recvmmsg 365 +#define __NR_accept4 366 +#define __NR_fanotify_init 367 +#define __NR_fanotify_mark 368 +#define __NR_prlimit64 369 +#define __NR_name_to_handle_at 370 +#define __NR_open_by_handle_at 371 +#define __NR_clock_adjtime 372 +#define __NR_syncfs 373 +#define __NR_sendmmsg 374 +#define __NR_setns 375 +#define __NR_process_vm_readv 376 +#define __NR_process_vm_writev 377 +#define __NR_kcmp 378 +#define __NR_finit_module 379 +#define __NR_sched_setattr 380 +#define __NR_sched_getattr 381 +#define __NR_renameat2 382 +#define __NR_seccomp 383 +#define __NR_getrandom 384 +#define __NR_memfd_create 385 +#define __NR_bpf 386 +#define __NR_execveat 387 +#define __NR_userfaultfd 388 +#define __NR_membarrier 389 +#define __NR_mlock2 390 +#define __NR_copy_file_range 391 +#define __NR_preadv2 392 +#define __NR_pwritev2 393 +#define __NR_pkey_mprotect 394 +#define __NR_pkey_alloc 395 +#define __NR_pkey_free 396 +#define __NR_statx 397 +#define __NR_rseq 398 +#define __NR_io_pgetevents 399 +#define __NR_migrate_pages 400 +#define __NR_kexec_file_load 401 +#define __NR_clock_gettime64 403 +#define __NR_clock_settime64 404 +#define __NR_clock_adjtime64 405 +#define __NR_clock_getres_time64 406 +#define __NR_clock_nanosleep_time64 407 +#define __NR_timer_gettime64 408 +#define __NR_timer_settime64 409 +#define __NR_timerfd_gettime64 410 +#define __NR_timerfd_settime64 411 +#define __NR_utimensat_time64 412 +#define __NR_pselect6_time64 413 +#define __NR_ppoll_time64 414 +#define __NR_io_pgetevents_time64 416 +#define __NR_recvmmsg_time64 417 +#define __NR_mq_timedsend_time64 418 +#define __NR_mq_timedreceive_time64 419 +#define __NR_semtimedop_time64 420 +#define __NR_rt_sigtimedwait_time64 421 +#define __NR_futex_time64 422 +#define __NR_sched_rr_get_interval_time64 423 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 +#define __NR_process_madvise 440 + +#define __ARM_NR_breakpoint 0x0f0001 +#define __ARM_NR_cacheflush 0x0f0002 +#define __ARM_NR_usr26 0x0f0003 +#define __ARM_NR_usr32 0x0f0004 +#define __ARM_NR_set_tls 0x0f0005 +#define __ARM_NR_get_tls 0x0f0006 + +#define SYS_restart_syscall 0 +#define SYS_exit 1 +#define SYS_fork 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execve 11 +#define SYS_chdir 12 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_lchown 16 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_mount 21 +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_ptrace 26 +#define SYS_pause 29 +#define SYS_access 33 +#define SYS_nice 34 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_rename 38 +#define SYS_mkdir 39 +#define SYS_rmdir 40 +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_times 43 +#define SYS_brk 45 +#define SYS_setgid 46 +#define SYS_getgid 47 +#define SYS_geteuid 49 +#define SYS_getegid 50 +#define SYS_acct 51 +#define SYS_umount2 52 +#define SYS_ioctl 54 +#define SYS_fcntl 55 +#define SYS_setpgid 57 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_ustat 62 +#define SYS_dup2 63 +#define SYS_getppid 64 +#define SYS_getpgrp 65 +#define SYS_setsid 66 +#define SYS_sigaction 67 +#define SYS_setreuid 70 +#define SYS_setregid 71 +#define SYS_sigsuspend 72 +#define SYS_sigpending 73 +#define SYS_sethostname 74 +#define SYS_setrlimit 75 +#define SYS_getrusage 77 +#define SYS_gettimeofday_time32 78 +#define SYS_settimeofday_time32 79 +#define SYS_getgroups 80 +#define SYS_setgroups 81 +#define SYS_symlink 83 +#define SYS_readlink 85 +#define SYS_uselib 86 +#define SYS_swapon 87 +#define SYS_reboot 88 +#define SYS_munmap 91 +#define SYS_truncate 92 +#define SYS_ftruncate 93 +#define SYS_fchmod 94 +#define SYS_fchown 95 +#define SYS_getpriority 96 +#define SYS_setpriority 97 +#define SYS_statfs 99 +#define SYS_fstatfs 100 +#define SYS_syslog 103 +#define SYS_setitimer 104 +#define SYS_getitimer 105 +#define SYS_stat 106 +#define SYS_lstat 107 +#define SYS_fstat 108 +#define SYS_vhangup 111 +#define SYS_wait4 114 +#define SYS_swapoff 115 +#define SYS_sysinfo 116 +#define SYS_fsync 118 +#define SYS_sigreturn 119 +#define SYS_clone 120 +#define SYS_setdomainname 121 +#define SYS_uname 122 +#define SYS_adjtimex 124 +#define SYS_mprotect 125 +#define SYS_sigprocmask 126 +#define SYS_init_module 128 +#define SYS_delete_module 129 +#define SYS_quotactl 131 +#define SYS_getpgid 132 +#define SYS_fchdir 133 +#define SYS_bdflush 134 +#define SYS_sysfs 135 +#define SYS_personality 136 +#define SYS_setfsuid 138 +#define SYS_setfsgid 139 +#define SYS__llseek 140 +#define SYS_getdents 141 +#define SYS__newselect 142 +#define SYS_flock 143 +#define SYS_msync 144 +#define SYS_readv 145 +#define SYS_writev 146 +#define SYS_getsid 147 +#define SYS_fdatasync 148 +#define SYS__sysctl 149 +#define SYS_mlock 150 +#define SYS_munlock 151 +#define SYS_mlockall 152 +#define SYS_munlockall 153 +#define SYS_sched_setparam 154 +#define SYS_sched_getparam 155 +#define SYS_sched_setscheduler 156 +#define SYS_sched_getscheduler 157 +#define SYS_sched_yield 158 +#define SYS_sched_get_priority_max 159 +#define SYS_sched_get_priority_min 160 +#define SYS_sched_rr_get_interval 161 +#define SYS_nanosleep 162 +#define SYS_mremap 163 +#define SYS_setresuid 164 +#define SYS_getresuid 165 +#define SYS_poll 168 +#define SYS_nfsservctl 169 +#define SYS_setresgid 170 +#define SYS_getresgid 171 +#define SYS_prctl 172 +#define SYS_rt_sigreturn 173 +#define SYS_rt_sigaction 174 +#define SYS_rt_sigprocmask 175 +#define SYS_rt_sigpending 176 +#define SYS_rt_sigtimedwait 177 +#define SYS_rt_sigqueueinfo 178 +#define SYS_rt_sigsuspend 179 +#define SYS_pread64 180 +#define SYS_pwrite64 181 +#define SYS_chown 182 +#define SYS_getcwd 183 +#define SYS_capget 184 +#define SYS_capset 185 +#define SYS_sigaltstack 186 +#define SYS_sendfile 187 +#define SYS_vfork 190 +#define SYS_ugetrlimit 191 +#define SYS_mmap2 192 +#define SYS_truncate64 193 +#define SYS_ftruncate64 194 +#define SYS_stat64 195 +#define SYS_lstat64 196 +#define SYS_fstat64 197 +#define SYS_lchown32 198 +#define SYS_getuid32 199 +#define SYS_getgid32 200 +#define SYS_geteuid32 201 +#define SYS_getegid32 202 +#define SYS_setreuid32 203 +#define SYS_setregid32 204 +#define SYS_getgroups32 205 +#define SYS_setgroups32 206 +#define SYS_fchown32 207 +#define SYS_setresuid32 208 +#define SYS_getresuid32 209 +#define SYS_setresgid32 210 +#define SYS_getresgid32 211 +#define SYS_chown32 212 +#define SYS_setuid32 213 +#define SYS_setgid32 214 +#define SYS_setfsuid32 215 +#define SYS_setfsgid32 216 +#define SYS_getdents64 217 +#define SYS_pivot_root 218 +#define SYS_mincore 219 +#define SYS_madvise 220 +#define SYS_fcntl64 221 +#define SYS_gettid 224 +#define SYS_readahead 225 +#define SYS_setxattr 226 +#define SYS_lsetxattr 227 +#define SYS_fsetxattr 228 +#define SYS_getxattr 229 +#define SYS_lgetxattr 230 +#define SYS_fgetxattr 231 +#define SYS_listxattr 232 +#define SYS_llistxattr 233 +#define SYS_flistxattr 234 +#define SYS_removexattr 235 +#define SYS_lremovexattr 236 +#define SYS_fremovexattr 237 +#define SYS_tkill 238 +#define SYS_sendfile64 239 +#define SYS_futex 240 +#define SYS_sched_setaffinity 241 +#define SYS_sched_getaffinity 242 +#define SYS_io_setup 243 +#define SYS_io_destroy 244 +#define SYS_io_getevents 245 +#define SYS_io_submit 246 +#define SYS_io_cancel 247 +#define SYS_exit_group 248 +#define SYS_lookup_dcookie 249 +#define SYS_epoll_create 250 +#define SYS_epoll_ctl 251 +#define SYS_epoll_wait 252 +#define SYS_remap_file_pages 253 +#define SYS_set_tid_address 256 +#define SYS_timer_create 257 +#define SYS_timer_settime32 258 +#define SYS_timer_gettime32 259 +#define SYS_timer_getoverrun 260 +#define SYS_timer_delete 261 +#define SYS_clock_settime32 262 +#define SYS_clock_gettime32 263 +#define SYS_clock_getres_time32 264 +#define SYS_clock_nanosleep_time32 265 +#define SYS_statfs64 266 +#define SYS_fstatfs64 267 +#define SYS_tgkill 268 +#define SYS_utimes 269 +#define SYS_fadvise64_64 270 +#define SYS_arm_fadvise64_64 270 +#define SYS_pciconfig_iobase 271 +#define SYS_pciconfig_read 272 +#define SYS_pciconfig_write 273 +#define SYS_mq_open 274 +#define SYS_mq_unlink 275 +#define SYS_mq_timedsend 276 +#define SYS_mq_timedreceive 277 +#define SYS_mq_notify 278 +#define SYS_mq_getsetattr 279 +#define SYS_waitid 280 +#define SYS_socket 281 +#define SYS_bind 282 +#define SYS_connect 283 +#define SYS_listen 284 +#define SYS_accept 285 +#define SYS_getsockname 286 +#define SYS_getpeername 287 +#define SYS_socketpair 288 +#define SYS_send 289 +#define SYS_sendto 290 +#define SYS_recv 291 +#define SYS_recvfrom 292 +#define SYS_shutdown 293 +#define SYS_setsockopt 294 +#define SYS_getsockopt 295 +#define SYS_sendmsg 296 +#define SYS_recvmsg 297 +#define SYS_semop 298 +#define SYS_semget 299 +#define SYS_semctl 300 +#define SYS_msgsnd 301 +#define SYS_msgrcv 302 +#define SYS_msgget 303 +#define SYS_msgctl 304 +#define SYS_shmat 305 +#define SYS_shmdt 306 +#define SYS_shmget 307 +#define SYS_shmctl 308 +#define SYS_add_key 309 +#define SYS_request_key 310 +#define SYS_keyctl 311 +#define SYS_semtimedop 312 +#define SYS_vserver 313 +#define SYS_ioprio_set 314 +#define SYS_ioprio_get 315 +#define SYS_inotify_init 316 +#define SYS_inotify_add_watch 317 +#define SYS_inotify_rm_watch 318 +#define SYS_mbind 319 +#define SYS_get_mempolicy 320 +#define SYS_set_mempolicy 321 +#define SYS_openat 322 +#define SYS_mkdirat 323 +#define SYS_mknodat 324 +#define SYS_fchownat 325 +#define SYS_futimesat 326 +#define SYS_fstatat64 327 +#define SYS_unlinkat 328 +#define SYS_renameat 329 +#define SYS_linkat 330 +#define SYS_symlinkat 331 +#define SYS_readlinkat 332 +#define SYS_fchmodat 333 +#define SYS_faccessat 334 +#define SYS_pselect6 335 +#define SYS_ppoll 336 +#define SYS_unshare 337 +#define SYS_set_robust_list 338 +#define SYS_get_robust_list 339 +#define SYS_splice 340 +#define SYS_sync_file_range2 341 +#define SYS_arm_sync_file_range 341 +#define SYS_tee 342 +#define SYS_vmsplice 343 +#define SYS_move_pages 344 +#define SYS_getcpu 345 +#define SYS_epoll_pwait 346 +#define SYS_kexec_load 347 +#define SYS_utimensat 348 +#define SYS_signalfd 349 +#define SYS_timerfd_create 350 +#define SYS_eventfd 351 +#define SYS_fallocate 352 +#define SYS_timerfd_settime32 353 +#define SYS_timerfd_gettime32 354 +#define SYS_signalfd4 355 +#define SYS_eventfd2 356 +#define SYS_epoll_create1 357 +#define SYS_dup3 358 +#define SYS_pipe2 359 +#define SYS_inotify_init1 360 +#define SYS_preadv 361 +#define SYS_pwritev 362 +#define SYS_rt_tgsigqueueinfo 363 +#define SYS_perf_event_open 364 +#define SYS_recvmmsg 365 +#define SYS_accept4 366 +#define SYS_fanotify_init 367 +#define SYS_fanotify_mark 368 +#define SYS_prlimit64 369 +#define SYS_name_to_handle_at 370 +#define SYS_open_by_handle_at 371 +#define SYS_clock_adjtime 372 +#define SYS_syncfs 373 +#define SYS_sendmmsg 374 +#define SYS_setns 375 +#define SYS_process_vm_readv 376 +#define SYS_process_vm_writev 377 +#define SYS_kcmp 378 +#define SYS_finit_module 379 +#define SYS_sched_setattr 380 +#define SYS_sched_getattr 381 +#define SYS_renameat2 382 +#define SYS_seccomp 383 +#define SYS_getrandom 384 +#define SYS_memfd_create 385 +#define SYS_bpf 386 +#define SYS_execveat 387 +#define SYS_userfaultfd 388 +#define SYS_membarrier 389 +#define SYS_mlock2 390 +#define SYS_copy_file_range 391 +#define SYS_preadv2 392 +#define SYS_pwritev2 393 +#define SYS_pkey_mprotect 394 +#define SYS_pkey_alloc 395 +#define SYS_pkey_free 396 +#define SYS_statx 397 +#define SYS_rseq 398 +#define SYS_io_pgetevents 399 +#define SYS_migrate_pages 400 +#define SYS_kexec_file_load 401 +#define SYS_clock_gettime64 403 +#define SYS_clock_settime64 404 +#define SYS_clock_adjtime64 405 +#define SYS_clock_getres_time64 406 +#define SYS_clock_nanosleep_time64 407 +#define SYS_timer_gettime64 408 +#define SYS_timer_settime64 409 +#define SYS_timerfd_gettime64 410 +#define SYS_timerfd_settime64 411 +#define SYS_utimensat_time64 412 +#define SYS_pselect6_time64 413 +#define SYS_ppoll_time64 414 +#define SYS_io_pgetevents_time64 416 +#define SYS_recvmmsg_time64 417 +#define SYS_mq_timedsend_time64 418 +#define SYS_mq_timedreceive_time64 419 +#define SYS_semtimedop_time64 420 +#define SYS_rt_sigtimedwait_time64 421 +#define SYS_futex_time64 422 +#define SYS_sched_rr_get_interval_time64 423 +#define SYS_pidfd_send_signal 424 +#define SYS_io_uring_setup 425 +#define SYS_io_uring_enter 426 +#define SYS_io_uring_register 427 +#define SYS_open_tree 428 +#define SYS_move_mount 429 +#define SYS_fsopen 430 +#define SYS_fsconfig 431 +#define SYS_fsmount 432 +#define SYS_fspick 433 +#define SYS_pidfd_open 434 +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 +#define SYS_process_madvise 440 diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/termios.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/termios.h new file mode 100755 index 0000000..124f71d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/termios.h @@ -0,0 +1,166 @@ +struct termios { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[NCCS]; + speed_t __c_ispeed; + speed_t __c_ospeed; +}; + +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 + +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 +#endif + +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 + +#define B0 0000000 +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 + +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 + +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 + +#define ISIG 0000001 +#define ICANON 0000002 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define IEXTEN 0100000 + +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define EXTA 0000016 +#define EXTB 0000017 +#define CBAUD 0010017 +#define CBAUDEX 0010000 +#define CIBAUD 002003600000 +#define CMSPAR 010000000000 +#define CRTSCTS 020000000000 + +#define XCASE 0000004 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define EXTPROC 0200000 + +#define XTABS 0014000 +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/user.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/user.h new file mode 100755 index 0000000..3e5a4d2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/user.h @@ -0,0 +1,36 @@ +typedef struct user_fpregs { + struct fp_reg { + unsigned sign1:1; + unsigned unused:15; + unsigned sign2:1; + unsigned exponent:14; + unsigned j:1; + unsigned mantissa1:31; + unsigned mantissa0:32; + } fpregs[8]; + unsigned fpsr:32; + unsigned fpcr:32; + unsigned char ftype[8]; + unsigned int init_flag; +} elf_fpregset_t; + +struct user_regs { + unsigned long uregs[18]; +}; +#define ELF_NGREG 18 +typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG]; + +struct user { + struct user_regs regs; + int u_fpvalid; + unsigned long u_tsize, u_dsize, u_ssize; + unsigned long start_code, start_stack; + long signal; + int reserved; + struct user_regs *u_ar0; + unsigned long magic; + char u_comm[32]; + int u_debugreg[8]; + struct user_fpregs u_fp; + struct user_fpregs *u_fp0; +}; diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/vt.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/vt.h new file mode 100755 index 0000000..834abfb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/bits/vt.h @@ -0,0 +1 @@ +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/byteswap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/byteswap.h new file mode 100755 index 0000000..00b9df3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/byteswap.h @@ -0,0 +1,26 @@ +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +#include +#include + +static __inline uint16_t __bswap_16(uint16_t __x) +{ + return __x<<8 | __x>>8; +} + +static __inline uint32_t __bswap_32(uint32_t __x) +{ + return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24; +} + +static __inline uint64_t __bswap_64(uint64_t __x) +{ + return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32); +} + +#define bswap_16(x) __bswap_16(x) +#define bswap_32(x) __bswap_32(x) +#define bswap_64(x) __bswap_64(x) + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/algorithm b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/algorithm new file mode 100755 index 0000000..9ce4aa8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/algorithm @@ -0,0 +1,86 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/algorithm + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ALGORITHM +#define _GLIBCXX_ALGORITHM 1 + +#pragma GCC system_header + +#include // UK-300. +#include +#include +#if __cplusplus > 201703L +# include +#endif + +#if __cplusplus > 201402L +// Parallel STL algorithms +# if _PSTL_EXECUTION_POLICIES_DEFINED +// If has already been included, pull in implementations +# include +# else +// Otherwise just pull in forward declarations +# include +# define _PSTL_ALGORITHM_FORWARD_DECLARED 1 +# endif + +// Feature test macro for parallel algorithms +# define __cpp_lib_parallel_algorithm 201603L +#endif // C++17 + +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#endif /* _GLIBCXX_ALGORITHM */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/any b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/any new file mode 100755 index 0000000..ccc27c5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/any @@ -0,0 +1,636 @@ +// -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/any + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ANY +#define _GLIBCXX_ANY 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + + /** + * @brief Exception class thrown by a failed @c any_cast + * @ingroup exceptions + */ + class bad_any_cast : public bad_cast + { + public: + virtual const char* what() const noexcept { return "bad any_cast"; } + }; + + [[gnu::noreturn]] inline void __throw_bad_any_cast() + { +#if __cpp_exceptions + throw bad_any_cast{}; +#else + __builtin_abort(); +#endif + } + +#define __cpp_lib_any 201606L + + /** + * @brief A type-safe container of any type. + * + * An @c any object's state is either empty or it stores a contained object + * of CopyConstructible type. + */ + class any + { + // Holds either pointer to a heap object or the contained object itself. + union _Storage + { + constexpr _Storage() : _M_ptr{nullptr} {} + + // Prevent trivial copies of this type, buffer might hold a non-POD. + _Storage(const _Storage&) = delete; + _Storage& operator=(const _Storage&) = delete; + + void* _M_ptr; + aligned_storage::type _M_buffer; + }; + + template, + bool _Fits = (sizeof(_Tp) <= sizeof(_Storage)) + && (alignof(_Tp) <= alignof(_Storage))> + using _Internal = std::integral_constant; + + template + struct _Manager_internal; // uses small-object optimization + + template + struct _Manager_external; // creates contained object on the heap + + template + using _Manager = conditional_t<_Internal<_Tp>::value, + _Manager_internal<_Tp>, + _Manager_external<_Tp>>; + + template> + using _Decay_if_not_any = enable_if_t, _VTp>; + + /// Emplace with an object created from @p __args as the contained object. + template > + void __do_emplace(_Args&&... __args) + { + reset(); + _Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...); + _M_manager = &_Mgr::_S_manage; + } + + /// Emplace with an object created from @p __il and @p __args as + /// the contained object. + template > + void __do_emplace(initializer_list<_Up> __il, _Args&&... __args) + { + reset(); + _Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...); + _M_manager = &_Mgr::_S_manage; + } + + template + using __any_constructible + = enable_if<__and_, + is_constructible<_Tp, _Args...>>::value, + _Res>; + + template + using __any_constructible_t + = typename __any_constructible::type; + + template + using __emplace_t + = typename __any_constructible<_VTp&, _VTp, _Args...>::type; + + public: + // construct/destruct + + /// Default constructor, creates an empty object. + constexpr any() noexcept : _M_manager(nullptr) { } + + /// Copy constructor, copies the state of @p __other + any(const any& __other) + { + if (!__other.has_value()) + _M_manager = nullptr; + else + { + _Arg __arg; + __arg._M_any = this; + __other._M_manager(_Op_clone, &__other, &__arg); + } + } + + /** + * @brief Move constructor, transfer the state from @p __other + * + * @post @c !__other.has_value() (this postcondition is a GNU extension) + */ + any(any&& __other) noexcept + { + if (!__other.has_value()) + _M_manager = nullptr; + else + { + _Arg __arg; + __arg._M_any = this; + __other._M_manager(_Op_xfer, &__other, &__arg); + } + } + + /// Construct with a copy of @p __value as the contained object. + template , + typename _Mgr = _Manager<_VTp>, + enable_if_t::value + && !__is_in_place_type<_VTp>::value, bool> = true> + any(_Tp&& __value) + : _M_manager(&_Mgr::_S_manage) + { + _Mgr::_S_create(_M_storage, std::forward<_Tp>(__value)); + } + + /// Construct with an object created from @p __args as the contained object. + template , + typename _Mgr = _Manager<_VTp>, + __any_constructible_t<_VTp, _Args&&...> = false> + explicit + any(in_place_type_t<_Tp>, _Args&&... __args) + : _M_manager(&_Mgr::_S_manage) + { + _Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...); + } + + /// Construct with an object created from @p __il and @p __args as + /// the contained object. + template , typename _Mgr = _Manager<_VTp>, + __any_constructible_t<_VTp, initializer_list<_Up>&, + _Args&&...> = false> + explicit + any(in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args) + : _M_manager(&_Mgr::_S_manage) + { + _Mgr::_S_create(_M_storage, __il, std::forward<_Args>(__args)...); + } + + /// Destructor, calls @c reset() + ~any() { reset(); } + + // assignments + + /// Copy the state of another object. + any& + operator=(const any& __rhs) + { + *this = any(__rhs); + return *this; + } + + /** + * @brief Move assignment operator + * + * @post @c !__rhs.has_value() (not guaranteed for other implementations) + */ + any& + operator=(any&& __rhs) noexcept + { + if (!__rhs.has_value()) + reset(); + else if (this != &__rhs) + { + reset(); + _Arg __arg; + __arg._M_any = this; + __rhs._M_manager(_Op_xfer, &__rhs, &__arg); + } + return *this; + } + + /// Store a copy of @p __rhs as the contained object. + template + enable_if_t>::value, any&> + operator=(_Tp&& __rhs) + { + *this = any(std::forward<_Tp>(__rhs)); + return *this; + } + + /// Emplace with an object created from @p __args as the contained object. + template + __emplace_t, _Args...> + emplace(_Args&&... __args) + { + using _VTp = decay_t<_Tp>; + __do_emplace<_VTp>(std::forward<_Args>(__args)...); + any::_Arg __arg; + this->_M_manager(any::_Op_access, this, &__arg); + return *static_cast<_VTp*>(__arg._M_obj); + } + + /// Emplace with an object created from @p __il and @p __args as + /// the contained object. + template + __emplace_t, initializer_list<_Up>&, _Args&&...> + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + using _VTp = decay_t<_Tp>; + __do_emplace<_VTp, _Up>(__il, std::forward<_Args>(__args)...); + any::_Arg __arg; + this->_M_manager(any::_Op_access, this, &__arg); + return *static_cast<_VTp*>(__arg._M_obj); + } + + // modifiers + + /// If not empty, destroy the contained object. + void reset() noexcept + { + if (has_value()) + { + _M_manager(_Op_destroy, this, nullptr); + _M_manager = nullptr; + } + } + + /// Exchange state with another object. + void swap(any& __rhs) noexcept + { + if (!has_value() && !__rhs.has_value()) + return; + + if (has_value() && __rhs.has_value()) + { + if (this == &__rhs) + return; + + any __tmp; + _Arg __arg; + __arg._M_any = &__tmp; + __rhs._M_manager(_Op_xfer, &__rhs, &__arg); + __arg._M_any = &__rhs; + _M_manager(_Op_xfer, this, &__arg); + __arg._M_any = this; + __tmp._M_manager(_Op_xfer, &__tmp, &__arg); + } + else + { + any* __empty = !has_value() ? this : &__rhs; + any* __full = !has_value() ? &__rhs : this; + _Arg __arg; + __arg._M_any = __empty; + __full->_M_manager(_Op_xfer, __full, &__arg); + } + } + + // observers + + /// Reports whether there is a contained object or not. + bool has_value() const noexcept { return _M_manager != nullptr; } + +#if __cpp_rtti + /// The @c typeid of the contained object, or @c typeid(void) if empty. + const type_info& type() const noexcept + { + if (!has_value()) + return typeid(void); + _Arg __arg; + _M_manager(_Op_get_type_info, this, &__arg); + return *__arg._M_typeinfo; + } +#endif + + template + static constexpr bool __is_valid_cast() + { return __or_, is_copy_constructible<_Tp>>::value; } + + private: + enum _Op { + _Op_access, _Op_get_type_info, _Op_clone, _Op_destroy, _Op_xfer + }; + + union _Arg + { + void* _M_obj; + const std::type_info* _M_typeinfo; + any* _M_any; + }; + + void (*_M_manager)(_Op, const any*, _Arg*); + _Storage _M_storage; + + template + friend void* __any_caster(const any* __any); + + // Manage in-place contained object. + template + struct _Manager_internal + { + static void + _S_manage(_Op __which, const any* __anyp, _Arg* __arg); + + template + static void + _S_create(_Storage& __storage, _Up&& __value) + { + void* __addr = &__storage._M_buffer; + ::new (__addr) _Tp(std::forward<_Up>(__value)); + } + + template + static void + _S_create(_Storage& __storage, _Args&&... __args) + { + void* __addr = &__storage._M_buffer; + ::new (__addr) _Tp(std::forward<_Args>(__args)...); + } + }; + + // Manage external contained object. + template + struct _Manager_external + { + static void + _S_manage(_Op __which, const any* __anyp, _Arg* __arg); + + template + static void + _S_create(_Storage& __storage, _Up&& __value) + { + __storage._M_ptr = new _Tp(std::forward<_Up>(__value)); + } + template + static void + _S_create(_Storage& __storage, _Args&&... __args) + { + __storage._M_ptr = new _Tp(std::forward<_Args>(__args)...); + } + }; + }; + + /// Exchange the states of two @c any objects. + inline void swap(any& __x, any& __y) noexcept { __x.swap(__y); } + + /// Create an any holding a @c _Tp constructed from @c __args. + template + any make_any(_Args&&... __args) + { + return any(in_place_type<_Tp>, std::forward<_Args>(__args)...); + } + + /// Create an any holding a @c _Tp constructed from @c __il and @c __args. + template + any make_any(initializer_list<_Up> __il, _Args&&... __args) + { + return any(in_place_type<_Tp>, __il, std::forward<_Args>(__args)...); + } + + /** + * @brief Access the contained object. + * + * @tparam _ValueType A const-reference or CopyConstructible type. + * @param __any The object to access. + * @return The contained object. + * @throw bad_any_cast If + * __any.type() != typeid(remove_reference_t<_ValueType>) + * + */ + template + inline _ValueType any_cast(const any& __any) + { + using _Up = __remove_cvref_t<_ValueType>; + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + static_assert(is_constructible_v<_ValueType, const _Up&>, + "Template argument must be constructible from a const value."); + auto __p = any_cast<_Up>(&__any); + if (__p) + return static_cast<_ValueType>(*__p); + __throw_bad_any_cast(); + } + + /** + * @brief Access the contained object. + * + * @tparam _ValueType A reference or CopyConstructible type. + * @param __any The object to access. + * @return The contained object. + * @throw bad_any_cast If + * __any.type() != typeid(remove_reference_t<_ValueType>) + * + * + * @{ + */ + template + inline _ValueType any_cast(any& __any) + { + using _Up = __remove_cvref_t<_ValueType>; + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + static_assert(is_constructible_v<_ValueType, _Up&>, + "Template argument must be constructible from an lvalue."); + auto __p = any_cast<_Up>(&__any); + if (__p) + return static_cast<_ValueType>(*__p); + __throw_bad_any_cast(); + } + + template + inline _ValueType any_cast(any&& __any) + { + using _Up = __remove_cvref_t<_ValueType>; + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + static_assert(is_constructible_v<_ValueType, _Up>, + "Template argument must be constructible from an rvalue."); + auto __p = any_cast<_Up>(&__any); + if (__p) + return static_cast<_ValueType>(std::move(*__p)); + __throw_bad_any_cast(); + } + /// @} + + /// @cond undocumented + template + void* __any_caster(const any* __any) + { + // any_cast returns non-null if __any->type() == typeid(T) and + // typeid(T) ignores cv-qualifiers so remove them: + using _Up = remove_cv_t<_Tp>; + // The contained value has a decayed type, so if decay_t is not U, + // then it's not possible to have a contained value of type U: + if constexpr (!is_same_v, _Up>) + return nullptr; + // Only copy constructible types can be used for contained values: + else if constexpr (!is_copy_constructible_v<_Up>) + return nullptr; + // First try comparing function addresses, which works without RTTI + else if (__any->_M_manager == &any::_Manager<_Up>::_S_manage +#if __cpp_rtti + || __any->type() == typeid(_Tp) +#endif + ) + { + any::_Arg __arg; + __any->_M_manager(any::_Op_access, __any, &__arg); + return __arg._M_obj; + } + return nullptr; + } + /// @endcond + + /** + * @brief Access the contained object. + * + * @tparam _ValueType The type of the contained object. + * @param __any A pointer to the object to access. + * @return The address of the contained object if + * __any != nullptr && __any.type() == typeid(_ValueType) + * , otherwise a null pointer. + * + * @{ + */ + template + inline const _ValueType* any_cast(const any* __any) noexcept + { + if constexpr (is_object_v<_ValueType>) + if (__any) + return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); + return nullptr; + } + + template + inline _ValueType* any_cast(any* __any) noexcept + { + if constexpr (is_object_v<_ValueType>) + if (__any) + return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); + return nullptr; + } + /// @} + + template + void + any::_Manager_internal<_Tp>:: + _S_manage(_Op __which, const any* __any, _Arg* __arg) + { + // The contained object is in _M_storage._M_buffer + auto __ptr = reinterpret_cast(&__any->_M_storage._M_buffer); + switch (__which) + { + case _Op_access: + __arg->_M_obj = const_cast<_Tp*>(__ptr); + break; + case _Op_get_type_info: +#if __cpp_rtti + __arg->_M_typeinfo = &typeid(_Tp); +#endif + break; + case _Op_clone: + ::new(&__arg->_M_any->_M_storage._M_buffer) _Tp(*__ptr); + __arg->_M_any->_M_manager = __any->_M_manager; + break; + case _Op_destroy: + __ptr->~_Tp(); + break; + case _Op_xfer: + ::new(&__arg->_M_any->_M_storage._M_buffer) _Tp + (std::move(*const_cast<_Tp*>(__ptr))); + __ptr->~_Tp(); + __arg->_M_any->_M_manager = __any->_M_manager; + const_cast(__any)->_M_manager = nullptr; + break; + } + } + + template + void + any::_Manager_external<_Tp>:: + _S_manage(_Op __which, const any* __any, _Arg* __arg) + { + // The contained object is *_M_storage._M_ptr + auto __ptr = static_cast(__any->_M_storage._M_ptr); + switch (__which) + { + case _Op_access: + __arg->_M_obj = const_cast<_Tp*>(__ptr); + break; + case _Op_get_type_info: +#if __cpp_rtti + __arg->_M_typeinfo = &typeid(_Tp); +#endif + break; + case _Op_clone: + __arg->_M_any->_M_storage._M_ptr = new _Tp(*__ptr); + __arg->_M_any->_M_manager = __any->_M_manager; + break; + case _Op_destroy: + delete __ptr; + break; + case _Op_xfer: + __arg->_M_any->_M_storage._M_ptr = __any->_M_storage._M_ptr; + __arg->_M_any->_M_manager = __any->_M_manager; + const_cast(__any)->_M_manager = nullptr; + break; + } + } + + /// @} + + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing an + // any into a variant. + template<> + struct _Never_valueless_alt + : std::true_type + { }; + } // namespace __detail::__variant + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 +#endif // _GLIBCXX_ANY diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/atomic_word.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/atomic_word.h new file mode 100755 index 0000000..dbabb57 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/atomic_word.h @@ -0,0 +1,40 @@ +// Low-level type for atomic operations -*- C++ -*- + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file atomic_word.h + * This file is a GNU extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_ATOMIC_WORD_H +#define _GLIBCXX_ATOMIC_WORD_H 1 + +typedef int _Atomic_word; + + +// This is a memory order acquire fence. +#define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE) +// This is a memory order release fence. +#define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE) + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/basic_file.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/basic_file.h new file mode 100755 index 0000000..5a372b4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/basic_file.h @@ -0,0 +1,135 @@ +// Wrapper of C-language FILE struct -*- C++ -*- + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 27.8 File-based streams +// + +/** @file bits/basic_file.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +#ifndef _GLIBCXX_BASIC_FILE_STDIO_H +#define _GLIBCXX_BASIC_FILE_STDIO_H 1 + +#pragma GCC system_header + +#include +#include // for __c_lock and __c_file +#include // for swap +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Generic declaration. + template + class __basic_file; + + // Specialization. + template<> + class __basic_file + { + // Underlying data source/sink. + __c_file* _M_cfile; + + // True iff we opened _M_cfile, and thus must close it ourselves. + bool _M_cfile_created; + + public: + __basic_file(__c_lock* __lock = 0) throw (); + +#if __cplusplus >= 201103L + __basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept + : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created) + { + __rv._M_cfile = nullptr; + __rv._M_cfile_created = false; + } + + __basic_file& operator=(const __basic_file&) = delete; + __basic_file& operator=(__basic_file&&) = delete; + + void + swap(__basic_file& __f) noexcept + { + std::swap(_M_cfile, __f._M_cfile); + std::swap(_M_cfile_created, __f._M_cfile_created); + } +#endif + + __basic_file* + open(const char* __name, ios_base::openmode __mode, int __prot = 0664); + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + __basic_file* + open(const wchar_t* __name, ios_base::openmode __mode); +#endif + + __basic_file* + sys_open(__c_file* __file, ios_base::openmode); + + __basic_file* + sys_open(int __fd, ios_base::openmode __mode) throw (); + + __basic_file* + close(); + + _GLIBCXX_PURE bool + is_open() const throw (); + + _GLIBCXX_PURE int + fd() throw (); + + _GLIBCXX_PURE __c_file* + file() throw (); + + ~__basic_file(); + + streamsize + xsputn(const char* __s, streamsize __n); + + streamsize + xsputn_2(const char* __s1, streamsize __n1, + const char* __s2, streamsize __n2); + + streamsize + xsgetn(char* __s, streamsize __n); + + streamoff + seekoff(streamoff __off, ios_base::seekdir __way) throw (); + + int + sync(); + + streamsize + showmanyc(); + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++allocator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++allocator.h new file mode 100755 index 0000000..77ee8b7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++allocator.h @@ -0,0 +1,59 @@ +// Base to std::allocator -*- C++ -*- + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++allocator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _GLIBCXX_CXX_ALLOCATOR_H +#define _GLIBCXX_CXX_ALLOCATOR_H 1 + +#include + +#if __cplusplus >= 201103L +namespace std +{ + /** + * @brief An alias to the base class for std::allocator. + * + * Used to set the std::allocator base class to + * __gnu_cxx::new_allocator. + * + * @ingroup allocators + * @tparam _Tp Type of allocated object. + */ + template + using __allocator_base = __gnu_cxx::new_allocator<_Tp>; +} +#else +// Define new_allocator as the base class to std::allocator. +# define __allocator_base __gnu_cxx::new_allocator +#endif + +#if defined(__SANITIZE_ADDRESS__) && !defined(_GLIBCXX_SANITIZE_STD_ALLOCATOR) +# define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++config.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++config.h new file mode 100755 index 0000000..b1c9405 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++config.h @@ -0,0 +1,2141 @@ +// Predefined symbols and macros -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++config.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{version} + */ + +#ifndef _GLIBCXX_CXX_CONFIG_H +#define _GLIBCXX_CXX_CONFIG_H 1 + +// The major release number for the GCC release the C++ library belongs to. +#define _GLIBCXX_RELEASE 11 + +// The datestamp of the C++ library in compressed ISO date format. +#define __GLIBCXX__ 20211120 + +// Macros for various attributes. +// _GLIBCXX_PURE +// _GLIBCXX_CONST +// _GLIBCXX_NORETURN +// _GLIBCXX_NOTHROW +// _GLIBCXX_VISIBILITY +#ifndef _GLIBCXX_PURE +# define _GLIBCXX_PURE __attribute__ ((__pure__)) +#endif + +#ifndef _GLIBCXX_CONST +# define _GLIBCXX_CONST __attribute__ ((__const__)) +#endif + +#ifndef _GLIBCXX_NORETURN +# define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) +#endif + +// See below for C++ +#ifndef _GLIBCXX_NOTHROW +# ifndef __cplusplus +# define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) +# endif +#endif + +// Macros for visibility attributes. +// _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY +// _GLIBCXX_VISIBILITY +# define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 + +#if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY +# define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) +#else +// If this is not supplied by the OS-specific or CPU-specific +// headers included below, it will be defined to an empty default. +# define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) +#endif + +// Macros for deprecated attributes. +// _GLIBCXX_USE_DEPRECATED +// _GLIBCXX_DEPRECATED +// _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX11_DEPRECATED +// _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX17_DEPRECATED +// _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX20_DEPRECATED( string-literal ) +// _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) +#ifndef _GLIBCXX_USE_DEPRECATED +# define _GLIBCXX_USE_DEPRECATED 1 +#endif + +#if defined(__DEPRECATED) +# define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) +# define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \ + __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) +#else +# define _GLIBCXX_DEPRECATED +# define _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 201103L) +# define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED +# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX11_DEPRECATED +# define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus >= 201703L) +# define _GLIBCXX17_DEPRECATED [[__deprecated__]] +# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX17_DEPRECATED +# define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) +#endif + +#if defined(__DEPRECATED) && (__cplusplus > 201703L) +# define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] +# define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX20_DEPRECATED(MSG) +# define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) +#endif + +// Macros for ABI tag attributes. +#ifndef _GLIBCXX_ABI_TAG_CXX11 +# define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) +#endif + +// Macro to warn about unused results. +#if __cplusplus >= 201703L +# define _GLIBCXX_NODISCARD [[__nodiscard__]] +#else +# define _GLIBCXX_NODISCARD +#endif + + + +#if __cplusplus + +// Macro for constexpr, to support in mixed 03/0x mode. +#ifndef _GLIBCXX_CONSTEXPR +# if __cplusplus >= 201103L +# define _GLIBCXX_CONSTEXPR constexpr +# define _GLIBCXX_USE_CONSTEXPR constexpr +# else +# define _GLIBCXX_CONSTEXPR +# define _GLIBCXX_USE_CONSTEXPR const +# endif +#endif + +#ifndef _GLIBCXX14_CONSTEXPR +# if __cplusplus >= 201402L +# define _GLIBCXX14_CONSTEXPR constexpr +# else +# define _GLIBCXX14_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX17_CONSTEXPR +# if __cplusplus >= 201703L +# define _GLIBCXX17_CONSTEXPR constexpr +# else +# define _GLIBCXX17_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX20_CONSTEXPR +# if __cplusplus > 201703L +# define _GLIBCXX20_CONSTEXPR constexpr +# else +# define _GLIBCXX20_CONSTEXPR +# endif +#endif + +#ifndef _GLIBCXX17_INLINE +# if __cplusplus >= 201703L +# define _GLIBCXX17_INLINE inline +# else +# define _GLIBCXX17_INLINE +# endif +#endif + +// Macro for noexcept, to support in mixed 03/0x mode. +#ifndef _GLIBCXX_NOEXCEPT +# if __cplusplus >= 201103L +# define _GLIBCXX_NOEXCEPT noexcept +# define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) +# define _GLIBCXX_USE_NOEXCEPT noexcept +# define _GLIBCXX_THROW(_EXC) +# else +# define _GLIBCXX_NOEXCEPT +# define _GLIBCXX_NOEXCEPT_IF(...) +# define _GLIBCXX_USE_NOEXCEPT throw() +# define _GLIBCXX_THROW(_EXC) throw(_EXC) +# endif +#endif + +#ifndef _GLIBCXX_NOTHROW +# define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT +#endif + +#ifndef _GLIBCXX_THROW_OR_ABORT +# if __cpp_exceptions +# define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) +# else +# define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) +# endif +#endif + +#if __cpp_noexcept_function_type +#define _GLIBCXX_NOEXCEPT_PARM , bool _NE +#define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE) +#else +#define _GLIBCXX_NOEXCEPT_PARM +#define _GLIBCXX_NOEXCEPT_QUAL +#endif + +// Macro for extern template, ie controlling template linkage via use +// of extern keyword on template declaration. As documented in the g++ +// manual, it inhibits all implicit instantiations and is used +// throughout the library to avoid multiple weak definitions for +// required types that are already explicitly instantiated in the +// library binary. This substantially reduces the binary size of +// resulting executables. +// Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern +// templates only in basic_string, thus activating its debug-mode +// checks even at -O0. +# define _GLIBCXX_EXTERN_TEMPLATE 1 + +/* + Outline of libstdc++ namespaces. + + namespace std + { + namespace __debug { } + namespace __parallel { } + namespace __cxx1998 { } + + namespace __detail { + namespace __variant { } // C++17 + } + + namespace rel_ops { } + + namespace tr1 + { + namespace placeholders { } + namespace regex_constants { } + namespace __detail { } + } + + namespace tr2 { } + + namespace decimal { } + + namespace chrono { } // C++11 + namespace placeholders { } // C++11 + namespace regex_constants { } // C++11 + namespace this_thread { } // C++11 + inline namespace literals { // C++14 + inline namespace chrono_literals { } // C++14 + inline namespace complex_literals { } // C++14 + inline namespace string_literals { } // C++14 + inline namespace string_view_literals { } // C++17 + } + } + + namespace abi { } + + namespace __gnu_cxx + { + namespace __detail { } + } + + For full details see: + http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html +*/ +namespace std +{ + typedef __SIZE_TYPE__ size_t; + typedef __PTRDIFF_TYPE__ ptrdiff_t; + +#if __cplusplus >= 201103L + typedef decltype(nullptr) nullptr_t; +#endif +} + +# define _GLIBCXX_USE_DUAL_ABI 1 + +#if ! _GLIBCXX_USE_DUAL_ABI +// Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI +# undef _GLIBCXX_USE_CXX11_ABI +#endif + +#ifndef _GLIBCXX_USE_CXX11_ABI +# define _GLIBCXX_USE_CXX11_ABI 1 +#endif + +#if _GLIBCXX_USE_CXX11_ABI +namespace std +{ + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +} +namespace __gnu_cxx +{ + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +} +# define _GLIBCXX_NAMESPACE_CXX11 __cxx11:: +# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 { +# define _GLIBCXX_END_NAMESPACE_CXX11 } +# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11 +#else +# define _GLIBCXX_NAMESPACE_CXX11 +# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 +# define _GLIBCXX_END_NAMESPACE_CXX11 +# define _GLIBCXX_DEFAULT_ABI_TAG +#endif + +// Defined if inline namespaces are used for versioning. +# define _GLIBCXX_INLINE_VERSION 0 + +// Inline namespace for symbol versioning. +#if _GLIBCXX_INLINE_VERSION +# define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { +# define _GLIBCXX_END_NAMESPACE_VERSION } + +namespace std +{ +inline _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if __cplusplus >= 201402L + inline namespace literals { + inline namespace chrono_literals { } + inline namespace complex_literals { } + inline namespace string_literals { } +#if __cplusplus > 201402L + inline namespace string_view_literals { } +#endif // C++17 + } +#endif // C++14 +_GLIBCXX_END_NAMESPACE_VERSION +} + +namespace __gnu_cxx +{ +inline _GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_END_NAMESPACE_VERSION +} + +#else +# define _GLIBCXX_BEGIN_NAMESPACE_VERSION +# define _GLIBCXX_END_NAMESPACE_VERSION +#endif + +// Inline namespaces for special modes: debug, parallel. +#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Non-inline namespace for components replaced by alternates in active mode. + namespace __cxx1998 + { +# if _GLIBCXX_USE_CXX11_ABI + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +# endif + } + +_GLIBCXX_END_NAMESPACE_VERSION + + // Inline namespace for debug mode. +# ifdef _GLIBCXX_DEBUG + inline namespace __debug { } +# endif + + // Inline namespaces for parallel mode. +# ifdef _GLIBCXX_PARALLEL + inline namespace __parallel { } +# endif +} + +// Check for invalid usage and unsupported mixed-mode use. +# if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) +# error illegal use of multiple inlined namespaces +# endif + +// Check for invalid use due to lack for weak symbols. +# if __NO_INLINE__ && !__GXX_WEAK__ +# warning currently using inlined namespace mode which may fail \ + without inlining due to lack of weak symbols +# endif +#endif + +// Macros for namespace scope. Either namespace std:: or the name +// of some nested namespace within it corresponding to the active mode. +// _GLIBCXX_STD_A +// _GLIBCXX_STD_C +// +// Macros for opening/closing conditional namespaces. +// _GLIBCXX_BEGIN_NAMESPACE_ALGO +// _GLIBCXX_END_NAMESPACE_ALGO +// _GLIBCXX_BEGIN_NAMESPACE_CONTAINER +// _GLIBCXX_END_NAMESPACE_CONTAINER +#if defined(_GLIBCXX_DEBUG) +# define _GLIBCXX_STD_C __cxx1998 +# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ + namespace _GLIBCXX_STD_C { +# define _GLIBCXX_END_NAMESPACE_CONTAINER } +#else +# define _GLIBCXX_STD_C std +# define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER +# define _GLIBCXX_END_NAMESPACE_CONTAINER +#endif + +#ifdef _GLIBCXX_PARALLEL +# define _GLIBCXX_STD_A __cxx1998 +# define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ + namespace _GLIBCXX_STD_A { +# define _GLIBCXX_END_NAMESPACE_ALGO } +#else +# define _GLIBCXX_STD_A std +# define _GLIBCXX_BEGIN_NAMESPACE_ALGO +# define _GLIBCXX_END_NAMESPACE_ALGO +#endif + +// GLIBCXX_ABI Deprecated +// Define if compatibility should be provided for -mlong-double-64. +#undef _GLIBCXX_LONG_DOUBLE_COMPAT + +// Define if compatibility should be provided for alternative 128-bit long +// double formats. Not possible for Clang until __ibm128 is supported. +#ifndef __clang__ +#undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT +#endif + +// Inline namespaces for long double 128 modes. +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ +namespace std +{ + // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE. + inline namespace __gnu_cxx_ieee128 { } + inline namespace __gnu_cxx11_ieee128 { } +} +# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128:: +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 { +# define _GLIBCXX_END_NAMESPACE_LDBL } +# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128:: +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 { +# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 } + +#else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ +namespace std +{ + inline namespace __gnu_cxx_ldbl128 { } +} +# define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { +# define _GLIBCXX_END_NAMESPACE_LDBL } +#else +# define _GLIBCXX_NAMESPACE_LDBL +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL +# define _GLIBCXX_END_NAMESPACE_LDBL +#endif + +#if _GLIBCXX_USE_CXX11_ABI +# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11 +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11 +# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 +#else +# define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL +# define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL +# define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL +#endif + +#endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 + +// Debug Mode implies checking assertions. +#if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS) +# define _GLIBCXX_ASSERTIONS 1 +#endif + +// Disable std::string explicit instantiation declarations in order to assert. +#ifdef _GLIBCXX_ASSERTIONS +# undef _GLIBCXX_EXTERN_TEMPLATE +# define _GLIBCXX_EXTERN_TEMPLATE -1 +#endif + + +#if __has_builtin(__builtin_is_constant_evaluated) +# define __glibcxx_constexpr_assert(cond) \ + if (__builtin_is_constant_evaluated() && !bool(cond)) \ + __builtin_unreachable() /* precondition violation detected! */ +#else +# define __glibcxx_constexpr_assert(unevaluated) +#endif + + +// Assert. +#if defined(_GLIBCXX_ASSERTIONS) \ + || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) +namespace std +{ + // Avoid the use of assert, because we're trying to keep the + // include out of the mix. + extern "C++" _GLIBCXX_NORETURN + inline void + __replacement_assert(const char* __file, int __line, + const char* __function, const char* __condition) + { + __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, + __function, __condition); + __builtin_abort(); + } +} +#define __glibcxx_assert_impl(_Condition) \ + if (__builtin_expect(!bool(_Condition), false)) \ + { \ + __glibcxx_constexpr_assert(_Condition); \ + std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + #_Condition); \ + } +#endif + +#if defined(_GLIBCXX_ASSERTIONS) +# define __glibcxx_assert(cond) \ + do { __glibcxx_assert_impl(cond); } while (false) +#else +# define __glibcxx_assert(cond) \ + do { __glibcxx_constexpr_assert(cond); } while (false) +#endif + +// Macros for race detectors. +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain +// atomic (lock-free) synchronization to race detectors: +// the race detector will infer a happens-before arc from the former to the +// latter when they share the same argument pointer. +// +// The most frequent use case for these macros (and the only case in the +// current implementation of the library) is atomic reference counting: +// void _M_remove_reference() +// { +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); +// if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) +// { +// _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); +// _M_destroy(__a); +// } +// } +// The annotations in this example tell the race detector that all memory +// accesses occurred when the refcount was positive do not race with +// memory accesses which occurred after the refcount became zero. +#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE +# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) +#endif +#ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER +# define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) +#endif + +// Macros for C linkage: define extern "C" linkage only when using C++. +# define _GLIBCXX_BEGIN_EXTERN_C extern "C" { +# define _GLIBCXX_END_EXTERN_C } + +# define _GLIBCXX_USE_ALLOCATOR_NEW 1 + +#ifdef __SIZEOF_INT128__ +#if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ +// If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined +// unless the compiler is in strict mode. If it's not defined and the strict +// macro is not defined, something is wrong. +#warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" +#endif +#endif + +#else // !__cplusplus +# define _GLIBCXX_BEGIN_EXTERN_C +# define _GLIBCXX_END_EXTERN_C +#endif + + +// First includes. + +// Pick up any OS-specific definitions. +#include + +// Pick up any CPU-specific definitions. +#include + +// If platform uses neither visibility nor psuedo-visibility, +// specify empty default for namespace annotation macros. +#ifndef _GLIBCXX_PSEUDO_VISIBILITY +# define _GLIBCXX_PSEUDO_VISIBILITY(V) +#endif + +// Certain function definitions that are meant to be overridable from +// user code are decorated with this macro. For some targets, this +// macro causes these definitions to be weak. +#ifndef _GLIBCXX_WEAK_DEFINITION +# define _GLIBCXX_WEAK_DEFINITION +#endif + +// By default, we assume that __GXX_WEAK__ also means that there is support +// for declaring functions as weak while not defining such functions. This +// allows for referring to functions provided by other libraries (e.g., +// libitm) without depending on them if the respective features are not used. +#ifndef _GLIBCXX_USE_WEAK_REF +# define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__ +#endif + +// Conditionally enable annotations for the Transactional Memory TS on C++11. +// Most of the following conditions are due to limitations in the current +// implementation. +#if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \ + && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \ + && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \ + && _GLIBCXX_USE_ALLOCATOR_NEW +#define _GLIBCXX_TXN_SAFE transaction_safe +#define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic +#else +#define _GLIBCXX_TXN_SAFE +#define _GLIBCXX_TXN_SAFE_DYN +#endif + +#if __cplusplus > 201402L +// In C++17 mathematical special functions are in namespace std. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 +// For C++11 and C++14 they are in namespace std when requested. +# define _GLIBCXX_USE_STD_SPEC_FUNCS 1 +#endif + +// The remainder of the prewritten config is automatic; all the +// user hooks are listed above. + +// Create a boolean flag to be used to determine if --fast-math is set. +#ifdef __FAST_MATH__ +# define _GLIBCXX_FAST_MATH 1 +#else +# define _GLIBCXX_FAST_MATH 0 +#endif + +// This marks string literals in header files to be extracted for eventual +// translation. It is primarily used for messages in thrown exceptions; see +// src/functexcept.cc. We use __N because the more traditional _N is used +// for something else under certain OSes (see BADNAMES). +#define __N(msgid) (msgid) + +// For example, is known to #define min and max as macros... +#undef min +#undef max + +// N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally +// so they should be tested with #if not with #ifdef. +#if __cplusplus >= 201103L +# ifndef _GLIBCXX_USE_C99_MATH +# define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH +# endif +# ifndef _GLIBCXX_USE_C99_COMPLEX +# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX +# endif +# ifndef _GLIBCXX_USE_C99_STDIO +# define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO +# endif +# ifndef _GLIBCXX_USE_C99_STDLIB +# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB +# endif +# ifndef _GLIBCXX_USE_C99_WCHAR +# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR +# endif +#else +# ifndef _GLIBCXX_USE_C99_MATH +# define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH +# endif +# ifndef _GLIBCXX_USE_C99_COMPLEX +# define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX +# endif +# ifndef _GLIBCXX_USE_C99_STDIO +# define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO +# endif +# ifndef _GLIBCXX_USE_C99_STDLIB +# define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB +# endif +# ifndef _GLIBCXX_USE_C99_WCHAR +# define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR +# endif +#endif + +// Unless explicitly specified, enable char8_t extensions only if the core +// language char8_t feature macro is defined. +#ifndef _GLIBCXX_USE_CHAR8_T +# ifdef __cpp_char8_t +# define _GLIBCXX_USE_CHAR8_T 1 +# endif +#endif +#ifdef _GLIBCXX_USE_CHAR8_T +# define __cpp_lib_char8_t 201907L +#endif + +/* Define if __float128 is supported on this host. */ +#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) +/* For powerpc64 don't use __float128 when it's the same type as long double. */ +# if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__)) +# undef _GLIBCXX_USE_FLOAT128 +# endif +#endif + +// Define if float has the IEEE binary32 format. +#if __FLT_MANT_DIG__ == 24 \ + && __FLT_MIN_EXP__ == -125 \ + && __FLT_MAX_EXP__ == 128 +# define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 +#endif + +// Define if double has the IEEE binary64 format. +#if __DBL_MANT_DIG__ == 53 \ + && __DBL_MIN_EXP__ == -1021 \ + && __DBL_MAX_EXP__ == 1024 +# define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 +#endif + +#ifdef __has_builtin +# ifdef __is_identifier +// Intel and older Clang require !__is_identifier for some built-ins: +# define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B) +# else +# define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) +# endif +#endif + +#if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) +# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__is_aggregate) +# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__builtin_is_constant_evaluated) +# define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__is_same) +# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 +#endif + +#if _GLIBCXX_HAS_BUILTIN(__builtin_launder) +# define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 +#endif + +#undef _GLIBCXX_HAS_BUILTIN + + +// PSTL configuration + +#if __cplusplus >= 201703L +// This header is not installed for freestanding: +#if __has_include() +// Preserved here so we have some idea which version of upstream we've pulled in +// #define PSTL_VERSION 9000 + +// For now this defaults to being based on the presence of Thread Building Blocks +# ifndef _GLIBCXX_USE_TBB_PAR_BACKEND +# define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include() +# endif +// This section will need some rework when a new (default) backend type is added +# if _GLIBCXX_USE_TBB_PAR_BACKEND +# define _PSTL_PAR_BACKEND_TBB +# else +# define _PSTL_PAR_BACKEND_SERIAL +# endif + +# define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) +# define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition) + +#include +#endif // __has_include +#endif // C++17 + +// End of prewritten config; the settings discovered at configure time follow. +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `acosf' function. */ +#define _GLIBCXX_HAVE_ACOSF 1 + +/* Define to 1 if you have the `acosl' function. */ +#define _GLIBCXX_HAVE_ACOSL 1 + +/* Define to 1 if you have the `aligned_alloc' function. */ +#define _GLIBCXX_HAVE_ALIGNED_ALLOC 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the `asinf' function. */ +#define _GLIBCXX_HAVE_ASINF 1 + +/* Define to 1 if you have the `asinl' function. */ +#define _GLIBCXX_HAVE_ASINL 1 + +/* Define to 1 if the target assembler supports .symver directive. */ +#define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 + +/* Define to 1 if you have the `atan2f' function. */ +#define _GLIBCXX_HAVE_ATAN2F 1 + +/* Define to 1 if you have the `atan2l' function. */ +#define _GLIBCXX_HAVE_ATAN2L 1 + +/* Define to 1 if you have the `atanf' function. */ +#define _GLIBCXX_HAVE_ATANF 1 + +/* Define to 1 if you have the `atanl' function. */ +#define _GLIBCXX_HAVE_ATANL 1 + +/* Defined if shared_ptr reference counting should use atomic operations. */ +/* #undef _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY */ + +/* Define to 1 if you have the `at_quick_exit' function. */ +#define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 + +/* Define to 1 if the target assembler supports thread-local storage. */ +/* #undef _GLIBCXX_HAVE_CC_TLS */ + +/* Define to 1 if you have the `ceilf' function. */ +#define _GLIBCXX_HAVE_CEILF 1 + +/* Define to 1 if you have the `ceill' function. */ +#define _GLIBCXX_HAVE_CEILL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_COMPLEX_H 1 + +/* Define to 1 if you have the `cosf' function. */ +#define _GLIBCXX_HAVE_COSF 1 + +/* Define to 1 if you have the `coshf' function. */ +#define _GLIBCXX_HAVE_COSHF 1 + +/* Define to 1 if you have the `coshl' function. */ +#define _GLIBCXX_HAVE_COSHL 1 + +/* Define to 1 if you have the `cosl' function. */ +#define _GLIBCXX_HAVE_COSL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_ENDIAN_H 1 + +/* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */ +/* #undef _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_EXECINFO_H */ + +/* Define to 1 if you have the `expf' function. */ +#define _GLIBCXX_HAVE_EXPF 1 + +/* Define to 1 if you have the `expl' function. */ +#define _GLIBCXX_HAVE_EXPL 1 + +/* Define to 1 if you have the `fabsf' function. */ +#define _GLIBCXX_HAVE_FABSF 1 + +/* Define to 1 if you have the `fabsl' function. */ +#define _GLIBCXX_HAVE_FABSL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_FCNTL_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_FENV_H 1 + +/* Define to 1 if you have the `finite' function. */ +#define _GLIBCXX_HAVE_FINITE 1 + +/* Define to 1 if you have the `finitef' function. */ +#define _GLIBCXX_HAVE_FINITEF 1 + +/* Define to 1 if you have the `finitel' function. */ +/* #undef _GLIBCXX_HAVE_FINITEL */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_FLOAT_H 1 + +/* Define to 1 if you have the `floorf' function. */ +#define _GLIBCXX_HAVE_FLOORF 1 + +/* Define to 1 if you have the `floorl' function. */ +#define _GLIBCXX_HAVE_FLOORL 1 + +/* Define to 1 if you have the `fmodf' function. */ +#define _GLIBCXX_HAVE_FMODF 1 + +/* Define to 1 if you have the `fmodl' function. */ +#define _GLIBCXX_HAVE_FMODL 1 + +/* Define to 1 if you have the `fpclass' function. */ +/* #undef _GLIBCXX_HAVE_FPCLASS */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_FP_H */ + +/* Define to 1 if you have the `frexpf' function. */ +#define _GLIBCXX_HAVE_FREXPF 1 + +/* Define to 1 if you have the `frexpl' function. */ +#define _GLIBCXX_HAVE_FREXPL 1 + +/* Define if _Unwind_GetIPInfo is available. */ +#define _GLIBCXX_HAVE_GETIPINFO 1 + +/* Define if gets is available in before C++14. */ +#define _GLIBCXX_HAVE_GETS 1 + +/* Define to 1 if you have the `hypot' function. */ +#define _GLIBCXX_HAVE_HYPOT 1 + +/* Define to 1 if you have the `hypotf' function. */ +#define _GLIBCXX_HAVE_HYPOTF 1 + +/* Define to 1 if you have the `hypotl' function. */ +#define _GLIBCXX_HAVE_HYPOTL 1 + +/* Define if you have the iconv() function. */ +#define _GLIBCXX_HAVE_ICONV 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_IEEEFP_H */ + +/* Define if int64_t is available in . */ +#define _GLIBCXX_HAVE_INT64_T 1 + +/* Define if int64_t is a long. */ +/* #undef _GLIBCXX_HAVE_INT64_T_LONG */ + +/* Define if int64_t is a long long. */ +#define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `isinf' function. */ +/* #undef _GLIBCXX_HAVE_ISINF */ + +/* Define to 1 if you have the `isinff' function. */ +/* #undef _GLIBCXX_HAVE_ISINFF */ + +/* Define to 1 if you have the `isinfl' function. */ +/* #undef _GLIBCXX_HAVE_ISINFL */ + +/* Define to 1 if you have the `isnan' function. */ +/* #undef _GLIBCXX_HAVE_ISNAN */ + +/* Define to 1 if you have the `isnanf' function. */ +/* #undef _GLIBCXX_HAVE_ISNANF */ + +/* Define to 1 if you have the `isnanl' function. */ +/* #undef _GLIBCXX_HAVE_ISNANL */ + +/* Defined if iswblank exists. */ +#define _GLIBCXX_HAVE_ISWBLANK 1 + +/* Define if LC_MESSAGES is available in . */ +#define _GLIBCXX_HAVE_LC_MESSAGES 1 + +/* Define to 1 if you have the `ldexpf' function. */ +#define _GLIBCXX_HAVE_LDEXPF 1 + +/* Define to 1 if you have the `ldexpl' function. */ +#define _GLIBCXX_HAVE_LDEXPL 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_LIBINTL_H */ + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_AS 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_DATA 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_FSIZE 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_RSS 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define _GLIBCXX_HAVE_LIMIT_VMEM 0 + +/* Define if link is available in . */ +#define _GLIBCXX_HAVE_LINK 1 + +/* Define if futex syscall is available. */ +#define _GLIBCXX_HAVE_LINUX_FUTEX 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_LINUX_RANDOM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_LINUX_TYPES_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `log10f' function. */ +#define _GLIBCXX_HAVE_LOG10F 1 + +/* Define to 1 if you have the `log10l' function. */ +#define _GLIBCXX_HAVE_LOG10L 1 + +/* Define to 1 if you have the `logf' function. */ +#define _GLIBCXX_HAVE_LOGF 1 + +/* Define to 1 if you have the `logl' function. */ +#define _GLIBCXX_HAVE_LOGL 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ + +/* Define if mbstate_t exists in wchar.h. */ +#define _GLIBCXX_HAVE_MBSTATE_T 1 + +/* Define to 1 if you have the `memalign' function. */ +#define _GLIBCXX_HAVE_MEMALIGN 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `modf' function. */ +#define _GLIBCXX_HAVE_MODF 1 + +/* Define to 1 if you have the `modff' function. */ +#define _GLIBCXX_HAVE_MODFF 1 + +/* Define to 1 if you have the `modfl' function. */ +#define _GLIBCXX_HAVE_MODFL 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_NAN_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_NETDB_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_NETINET_TCP_H 1 + +/* Define if defines obsolete isinf function. */ +/* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */ + +/* Define if defines obsolete isnan function. */ +/* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */ + +/* Define if poll is available in . */ +#define _GLIBCXX_HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_memalign' function. */ +#define _GLIBCXX_HAVE_POSIX_MEMALIGN 1 + +/* Define to 1 if POSIX Semaphores with sem_timedwait are available in + . */ +/* #undef _GLIBCXX_HAVE_POSIX_SEMAPHORE */ + +/* Define to 1 if you have the `powf' function. */ +#define _GLIBCXX_HAVE_POWF 1 + +/* Define to 1 if you have the `powl' function. */ +#define _GLIBCXX_HAVE_POWL 1 + +/* Define to 1 if you have the `qfpclass' function. */ +/* #undef _GLIBCXX_HAVE_QFPCLASS */ + +/* Define to 1 if you have the `quick_exit' function. */ +#define _GLIBCXX_HAVE_QUICK_EXIT 1 + +/* Define if readlink is available in . */ +#define _GLIBCXX_HAVE_READLINK 1 + +/* Define to 1 if you have the `setenv' function. */ +/* #undef _GLIBCXX_HAVE_SETENV */ + +/* Define to 1 if you have the `sincos' function. */ +#define _GLIBCXX_HAVE_SINCOS 1 + +/* Define to 1 if you have the `sincosf' function. */ +#define _GLIBCXX_HAVE_SINCOSF 1 + +/* Define to 1 if you have the `sincosl' function. */ +#define _GLIBCXX_HAVE_SINCOSL 1 + +/* Define to 1 if you have the `sinf' function. */ +#define _GLIBCXX_HAVE_SINF 1 + +/* Define to 1 if you have the `sinhf' function. */ +#define _GLIBCXX_HAVE_SINHF 1 + +/* Define to 1 if you have the `sinhl' function. */ +#define _GLIBCXX_HAVE_SINHL 1 + +/* Define to 1 if you have the `sinl' function. */ +#define _GLIBCXX_HAVE_SINL 1 + +/* Defined if sleep exists. */ +/* #undef _GLIBCXX_HAVE_SLEEP */ + +/* Define to 1 if you have the `sockatmark' function. */ +#define _GLIBCXX_HAVE_SOCKATMARK 1 + +/* Define to 1 if you have the `sqrtf' function. */ +#define _GLIBCXX_HAVE_SQRTF 1 + +/* Define to 1 if you have the `sqrtl' function. */ +#define _GLIBCXX_HAVE_SQRTL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDALIGN_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STDLIB_H 1 + +/* Define if strerror_l is available in . */ +/* #undef _GLIBCXX_HAVE_STRERROR_L */ + +/* Define if strerror_r is available in . */ +#define _GLIBCXX_HAVE_STRERROR_R 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtof' function. */ +#define _GLIBCXX_HAVE_STRTOF 1 + +/* Define to 1 if you have the `strtold' function. */ +#define _GLIBCXX_HAVE_STRTOLD 1 + +/* Define to 1 if `d_type' is a member of `struct dirent'. */ +#define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1 + +/* Define if strxfrm_l is available in . */ +/* #undef _GLIBCXX_HAVE_STRXFRM_L */ + +/* Define if symlink is available in . */ +#define _GLIBCXX_HAVE_SYMLINK 1 + +/* Define to 1 if the target runtime linker supports binding the same symbol + to different versions. */ +#define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_IPC_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have a suitable header file */ +/* #undef _GLIBCXX_HAVE_SYS_SDT_H */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_SEM_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_SYS_UIO_H 1 + +/* Define if S_IFREG is available in . */ +/* #undef _GLIBCXX_HAVE_S_IFREG */ + +/* Define if S_ISREG is available in . */ +#define _GLIBCXX_HAVE_S_ISREG 1 + +/* Define to 1 if you have the `tanf' function. */ +#define _GLIBCXX_HAVE_TANF 1 + +/* Define to 1 if you have the `tanhf' function. */ +#define _GLIBCXX_HAVE_TANHF 1 + +/* Define to 1 if you have the `tanhl' function. */ +#define _GLIBCXX_HAVE_TANHL 1 + +/* Define to 1 if you have the `tanl' function. */ +#define _GLIBCXX_HAVE_TANL 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_TGMATH_H 1 + +/* Define to 1 if you have the `timespec_get' function. */ +#define _GLIBCXX_HAVE_TIMESPEC_GET 1 + +/* Define to 1 if the target supports thread-local storage. */ +#define _GLIBCXX_HAVE_TLS 1 + +/* Define if truncate is available in . */ +#define _GLIBCXX_HAVE_TRUNCATE 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_UCHAR_H 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `uselocale' function. */ +#define _GLIBCXX_HAVE_USELOCALE 1 + +/* Defined if usleep exists. */ +/* #undef _GLIBCXX_HAVE_USLEEP */ + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_UTIME_H 1 + +/* Defined if vfwscanf exists. */ +#define _GLIBCXX_HAVE_VFWSCANF 1 + +/* Defined if vswscanf exists. */ +#define _GLIBCXX_HAVE_VSWSCANF 1 + +/* Defined if vwscanf exists. */ +#define _GLIBCXX_HAVE_VWSCANF 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_WCHAR_H 1 + +/* Defined if wcstof exists. */ +#define _GLIBCXX_HAVE_WCSTOF 1 + +/* Define to 1 if you have the header file. */ +#define _GLIBCXX_HAVE_WCTYPE_H 1 + +/* Defined if Sleep exists. */ +/* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ + +/* Define if writev is available in . */ +#define _GLIBCXX_HAVE_WRITEV 1 + +/* Define to 1 if you have the header file. */ +/* #undef _GLIBCXX_HAVE_XLOCALE_H */ + +/* Define to 1 if you have the `_acosf' function. */ +/* #undef _GLIBCXX_HAVE__ACOSF */ + +/* Define to 1 if you have the `_acosl' function. */ +/* #undef _GLIBCXX_HAVE__ACOSL */ + +/* Define to 1 if you have the `_aligned_malloc' function. */ +/* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ + +/* Define to 1 if you have the `_asinf' function. */ +/* #undef _GLIBCXX_HAVE__ASINF */ + +/* Define to 1 if you have the `_asinl' function. */ +/* #undef _GLIBCXX_HAVE__ASINL */ + +/* Define to 1 if you have the `_atan2f' function. */ +/* #undef _GLIBCXX_HAVE__ATAN2F */ + +/* Define to 1 if you have the `_atan2l' function. */ +/* #undef _GLIBCXX_HAVE__ATAN2L */ + +/* Define to 1 if you have the `_atanf' function. */ +/* #undef _GLIBCXX_HAVE__ATANF */ + +/* Define to 1 if you have the `_atanl' function. */ +/* #undef _GLIBCXX_HAVE__ATANL */ + +/* Define to 1 if you have the `_ceilf' function. */ +/* #undef _GLIBCXX_HAVE__CEILF */ + +/* Define to 1 if you have the `_ceill' function. */ +/* #undef _GLIBCXX_HAVE__CEILL */ + +/* Define to 1 if you have the `_cosf' function. */ +/* #undef _GLIBCXX_HAVE__COSF */ + +/* Define to 1 if you have the `_coshf' function. */ +/* #undef _GLIBCXX_HAVE__COSHF */ + +/* Define to 1 if you have the `_coshl' function. */ +/* #undef _GLIBCXX_HAVE__COSHL */ + +/* Define to 1 if you have the `_cosl' function. */ +/* #undef _GLIBCXX_HAVE__COSL */ + +/* Define to 1 if you have the `_expf' function. */ +/* #undef _GLIBCXX_HAVE__EXPF */ + +/* Define to 1 if you have the `_expl' function. */ +/* #undef _GLIBCXX_HAVE__EXPL */ + +/* Define to 1 if you have the `_fabsf' function. */ +/* #undef _GLIBCXX_HAVE__FABSF */ + +/* Define to 1 if you have the `_fabsl' function. */ +/* #undef _GLIBCXX_HAVE__FABSL */ + +/* Define to 1 if you have the `_finite' function. */ +/* #undef _GLIBCXX_HAVE__FINITE */ + +/* Define to 1 if you have the `_finitef' function. */ +/* #undef _GLIBCXX_HAVE__FINITEF */ + +/* Define to 1 if you have the `_finitel' function. */ +/* #undef _GLIBCXX_HAVE__FINITEL */ + +/* Define to 1 if you have the `_floorf' function. */ +/* #undef _GLIBCXX_HAVE__FLOORF */ + +/* Define to 1 if you have the `_floorl' function. */ +/* #undef _GLIBCXX_HAVE__FLOORL */ + +/* Define to 1 if you have the `_fmodf' function. */ +/* #undef _GLIBCXX_HAVE__FMODF */ + +/* Define to 1 if you have the `_fmodl' function. */ +/* #undef _GLIBCXX_HAVE__FMODL */ + +/* Define to 1 if you have the `_fpclass' function. */ +/* #undef _GLIBCXX_HAVE__FPCLASS */ + +/* Define to 1 if you have the `_frexpf' function. */ +/* #undef _GLIBCXX_HAVE__FREXPF */ + +/* Define to 1 if you have the `_frexpl' function. */ +/* #undef _GLIBCXX_HAVE__FREXPL */ + +/* Define to 1 if you have the `_hypot' function. */ +/* #undef _GLIBCXX_HAVE__HYPOT */ + +/* Define to 1 if you have the `_hypotf' function. */ +/* #undef _GLIBCXX_HAVE__HYPOTF */ + +/* Define to 1 if you have the `_hypotl' function. */ +/* #undef _GLIBCXX_HAVE__HYPOTL */ + +/* Define to 1 if you have the `_isinf' function. */ +/* #undef _GLIBCXX_HAVE__ISINF */ + +/* Define to 1 if you have the `_isinff' function. */ +/* #undef _GLIBCXX_HAVE__ISINFF */ + +/* Define to 1 if you have the `_isinfl' function. */ +/* #undef _GLIBCXX_HAVE__ISINFL */ + +/* Define to 1 if you have the `_isnan' function. */ +/* #undef _GLIBCXX_HAVE__ISNAN */ + +/* Define to 1 if you have the `_isnanf' function. */ +/* #undef _GLIBCXX_HAVE__ISNANF */ + +/* Define to 1 if you have the `_isnanl' function. */ +/* #undef _GLIBCXX_HAVE__ISNANL */ + +/* Define to 1 if you have the `_ldexpf' function. */ +/* #undef _GLIBCXX_HAVE__LDEXPF */ + +/* Define to 1 if you have the `_ldexpl' function. */ +/* #undef _GLIBCXX_HAVE__LDEXPL */ + +/* Define to 1 if you have the `_log10f' function. */ +/* #undef _GLIBCXX_HAVE__LOG10F */ + +/* Define to 1 if you have the `_log10l' function. */ +/* #undef _GLIBCXX_HAVE__LOG10L */ + +/* Define to 1 if you have the `_logf' function. */ +/* #undef _GLIBCXX_HAVE__LOGF */ + +/* Define to 1 if you have the `_logl' function. */ +/* #undef _GLIBCXX_HAVE__LOGL */ + +/* Define to 1 if you have the `_modf' function. */ +/* #undef _GLIBCXX_HAVE__MODF */ + +/* Define to 1 if you have the `_modff' function. */ +/* #undef _GLIBCXX_HAVE__MODFF */ + +/* Define to 1 if you have the `_modfl' function. */ +/* #undef _GLIBCXX_HAVE__MODFL */ + +/* Define to 1 if you have the `_powf' function. */ +/* #undef _GLIBCXX_HAVE__POWF */ + +/* Define to 1 if you have the `_powl' function. */ +/* #undef _GLIBCXX_HAVE__POWL */ + +/* Define to 1 if you have the `_qfpclass' function. */ +/* #undef _GLIBCXX_HAVE__QFPCLASS */ + +/* Define to 1 if you have the `_sincos' function. */ +/* #undef _GLIBCXX_HAVE__SINCOS */ + +/* Define to 1 if you have the `_sincosf' function. */ +/* #undef _GLIBCXX_HAVE__SINCOSF */ + +/* Define to 1 if you have the `_sincosl' function. */ +/* #undef _GLIBCXX_HAVE__SINCOSL */ + +/* Define to 1 if you have the `_sinf' function. */ +/* #undef _GLIBCXX_HAVE__SINF */ + +/* Define to 1 if you have the `_sinhf' function. */ +/* #undef _GLIBCXX_HAVE__SINHF */ + +/* Define to 1 if you have the `_sinhl' function. */ +/* #undef _GLIBCXX_HAVE__SINHL */ + +/* Define to 1 if you have the `_sinl' function. */ +/* #undef _GLIBCXX_HAVE__SINL */ + +/* Define to 1 if you have the `_sqrtf' function. */ +/* #undef _GLIBCXX_HAVE__SQRTF */ + +/* Define to 1 if you have the `_sqrtl' function. */ +/* #undef _GLIBCXX_HAVE__SQRTL */ + +/* Define to 1 if you have the `_tanf' function. */ +/* #undef _GLIBCXX_HAVE__TANF */ + +/* Define to 1 if you have the `_tanhf' function. */ +/* #undef _GLIBCXX_HAVE__TANHF */ + +/* Define to 1 if you have the `_tanhl' function. */ +/* #undef _GLIBCXX_HAVE__TANHL */ + +/* Define to 1 if you have the `_tanl' function. */ +/* #undef _GLIBCXX_HAVE__TANL */ + +/* Define to 1 if you have the `_wfopen' function. */ +/* #undef _GLIBCXX_HAVE__WFOPEN */ + +/* Define to 1 if you have the `__cxa_thread_atexit' function. */ +/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */ + +/* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ +/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */ + +/* Define as const if the declaration of iconv() needs const. */ +#define _GLIBCXX_ICONV_CONST + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Defined if no way to sleep is available. */ +/* #undef NO_SLEEP */ + +/* Name of package */ +/* #undef _GLIBCXX_PACKAGE */ + +/* Define to the address where bug reports for this package should be sent. */ +#define _GLIBCXX_PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define _GLIBCXX_PACKAGE_NAME "package-unused" + +/* Define to the full name and version of this package. */ +#define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" + +/* Define to the one symbol short name of this package. */ +#define _GLIBCXX_PACKAGE_TARNAME "libstdc++" + +/* Define to the home page for this package. */ +#define _GLIBCXX_PACKAGE_URL "" + +/* Define to the version of this package. */ +#define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" + +/* The size of `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of `int', as computed by sizeof. */ +/* #undef SIZEOF_INT */ + +/* The size of `long', as computed by sizeof. */ +/* #undef SIZEOF_LONG */ + +/* The size of `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of `void *', as computed by sizeof. */ +/* #undef SIZEOF_VOID_P */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +/* #undef _GLIBCXX_VERSION */ + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _GLIBCXX_DARWIN_USE_64_BIT_INODE +# define _GLIBCXX_DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _GLIBCXX_FILE_OFFSET_BITS */ + +/* Define if C99 functions in should be used in for + C++11. Using compiler builtins for these functions requires corresponding + C99 library functions to be present. */ +#define _GLIBCXX11_USE_C99_COMPLEX 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_MATH 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_STDIO 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_STDLIB 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++11. */ +#define _GLIBCXX11_USE_C99_WCHAR 1 + +/* Define if C99 functions in should be used in for + C++98. Using compiler builtins for these functions requires corresponding + C99 library functions to be present. */ +#define _GLIBCXX98_USE_C99_COMPLEX 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_MATH 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_STDIO 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_STDLIB 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std for C++98. */ +#define _GLIBCXX98_USE_C99_WCHAR 1 + +/* Define if the compiler supports C++11 atomics. */ +#define _GLIBCXX_ATOMIC_BUILTINS 1 + +/* Define to use concept checking code from the boost libraries. */ +/* #undef _GLIBCXX_CONCEPT_CHECKS */ + +/* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, + undefined for platform defaults */ +#define _GLIBCXX_FULLY_DYNAMIC_STRING 0 + +/* Define if gthreads library is available. */ +#define _GLIBCXX_HAS_GTHREADS 1 + +/* Define to 1 if a full hosted library is built, or 0 if freestanding. */ +#define _GLIBCXX_HOSTED 1 + +/* Define if compatibility should be provided for alternative 128-bit long + double formats. */ + +/* Define if compatibility should be provided for -mlong-double-64. */ + +/* Define to the letter to which size_t is mangled. */ +#define _GLIBCXX_MANGLE_SIZE_T j + +/* Define if C99 llrint and llround functions are missing from . */ +/* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */ + +/* Define if ptrdiff_t is int. */ +#define _GLIBCXX_PTRDIFF_T_IS_INT 1 + +/* Define if using setrlimit to set resource limits during "make check" */ +#define _GLIBCXX_RES_LIMITS 1 + +/* Define if size_t is unsigned int. */ +#define _GLIBCXX_SIZE_T_IS_UINT 1 + +/* Define to the value of the EOF integer constant. */ +#define _GLIBCXX_STDIO_EOF -1 + +/* Define to the value of the SEEK_CUR integer constant. */ +#define _GLIBCXX_STDIO_SEEK_CUR 1 + +/* Define to the value of the SEEK_END integer constant. */ +#define _GLIBCXX_STDIO_SEEK_END 2 + +/* Define to use symbol versioning in the shared library. */ +#define _GLIBCXX_SYMVER 1 + +/* Define to use darwin versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_DARWIN */ + +/* Define to use GNU versioning in the shared library. */ +#define _GLIBCXX_SYMVER_GNU 1 + +/* Define to use GNU namespace versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ + +/* Define to use Sun versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_SUN */ + +/* Define if C11 functions in should be imported into namespace std + in . */ +#define _GLIBCXX_USE_C11_UCHAR_CXX11 1 + +/* Define if C99 functions or macros from , , , + , and can be used or exposed. */ +#define _GLIBCXX_USE_C99 1 + +/* Define if C99 functions in should be used in . + Using compiler builtins for these functions requires corresponding C99 + library functions to be present. */ +#define _GLIBCXX_USE_C99_COMPLEX_TR1 1 + +/* Define if C99 functions in should be imported in in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_CTYPE_TR1 1 + +/* Define if C99 functions in should be imported in in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_FENV_TR1 1 + +/* Define if C99 functions in should be imported in + in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_INTTYPES_TR1 1 + +/* Define if wchar_t C99 functions in should be imported in + in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 + +/* Define if C99 functions or macros in should be imported in + in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_MATH_TR1 1 + +/* Define if C99 types in should be imported in in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_STDINT_TR1 1 + +/* Defined if clock_gettime syscall has monotonic and realtime clock support. + */ +/* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */ + +/* Defined if clock_gettime has monotonic clock support. */ +#define _GLIBCXX_USE_CLOCK_MONOTONIC 1 + +/* Defined if clock_gettime has realtime clock support. */ +#define _GLIBCXX_USE_CLOCK_REALTIME 1 + +/* Define if ISO/IEC TR 24733 decimal floating point types are supported on + this host. */ +/* #undef _GLIBCXX_USE_DECIMAL_FLOAT */ + +/* Define if /dev/random and /dev/urandom are available for + std::random_device. */ +#define _GLIBCXX_USE_DEV_RANDOM 1 + +/* Define if fchmod is available in . */ +#define _GLIBCXX_USE_FCHMOD 1 + +/* Define if fchmodat is available in . */ +#define _GLIBCXX_USE_FCHMODAT 1 + +/* Defined if gettimeofday is available. */ +#define _GLIBCXX_USE_GETTIMEOFDAY 1 + +/* Define if get_nprocs is available in . */ +#define _GLIBCXX_USE_GET_NPROCS 1 + +/* Define if __int128 is supported on this host. */ +/* #undef _GLIBCXX_USE_INT128 */ + +/* Define if LFS support is available. */ +#define _GLIBCXX_USE_LFS 1 + +/* Define if code specialized for long long should be used. */ +#define _GLIBCXX_USE_LONG_LONG 1 + +/* Define if lstat is available in . */ +#define _GLIBCXX_USE_LSTAT 1 + +/* Defined if nanosleep is available. */ +#define _GLIBCXX_USE_NANOSLEEP 1 + +/* Define if NLS translations are to be used. */ +/* #undef _GLIBCXX_USE_NLS */ + +/* Define if pthreads_num_processors_np is available in . */ +/* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ + +/* Define if pthread_cond_clockwait is available in . */ +/* #undef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT */ + +/* Define if pthread_mutex_clocklock is available in . */ +/* #undef _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK */ + +/* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are + available in . */ +/* #undef _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK */ + +/* Define if POSIX read/write locks are available in . */ +#define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1 + +/* Define if /dev/random and /dev/urandom are available for the random_device + of TR1 (Chapter 5.1). */ +#define _GLIBCXX_USE_RANDOM_TR1 1 + +/* Define if usable realpath is available in . */ +#define _GLIBCXX_USE_REALPATH 1 + +/* Defined if sched_yield is available. */ +#define _GLIBCXX_USE_SCHED_YIELD 1 + +/* Define if _SC_NPROCESSORS_ONLN is available in . */ +#define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 + +/* Define if _SC_NPROC_ONLN is available in . */ +/* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ + +/* Define if sendfile is available in . */ +#define _GLIBCXX_USE_SENDFILE 1 + +/* Define to restrict std::__basic_file<> to stdio APIs. */ +/* #undef _GLIBCXX_USE_STDIO_PURE */ + +/* Define if struct stat has timespec members. */ +#define _GLIBCXX_USE_ST_MTIM 1 + +/* Define if sysctl(), CTL_HW and HW_NCPU are available in . */ +/* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ + +/* Define if obsolescent tmpnam is available in . */ +#define _GLIBCXX_USE_TMPNAM 1 + +/* Define if utime is available in . */ +#define _GLIBCXX_USE_UTIME 1 + +/* Define if utimensat and UTIME_OMIT are available in and + AT_FDCWD in . */ +#define _GLIBCXX_USE_UTIMENSAT 1 + +/* Define if code specialized for wchar_t should be used. */ +#define _GLIBCXX_USE_WCHAR_T 1 + +/* Define to 1 if a verbose library is built, or 0 otherwise. */ +#define _GLIBCXX_VERBOSE 1 + +/* Defined if as can handle rdrand. */ +/* #undef _GLIBCXX_X86_RDRAND */ + +/* Defined if as can handle rdseed. */ +/* #undef _GLIBCXX_X86_RDSEED */ + +/* Define to 1 if mutex_timedlock is available. */ +#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 + +/* Define for large files, on AIX-style hosts. */ +/* #undef _GLIBCXX_LARGE_FILES */ + +/* Define if all C++11 floating point overloads are available in . */ +#if __cplusplus >= 201103L +/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */ +#endif + +/* Define if all C++11 integral type overloads are available in . */ +#if __cplusplus >= 201103L +/* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */ +#endif + +#if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) +# define _GLIBCXX_HAVE_ACOSF 1 +# define acosf _acosf +#endif + +#if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) +# define _GLIBCXX_HAVE_ACOSL 1 +# define acosl _acosl +#endif + +#if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) +# define _GLIBCXX_HAVE_ASINF 1 +# define asinf _asinf +#endif + +#if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) +# define _GLIBCXX_HAVE_ASINL 1 +# define asinl _asinl +#endif + +#if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) +# define _GLIBCXX_HAVE_ATAN2F 1 +# define atan2f _atan2f +#endif + +#if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) +# define _GLIBCXX_HAVE_ATAN2L 1 +# define atan2l _atan2l +#endif + +#if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) +# define _GLIBCXX_HAVE_ATANF 1 +# define atanf _atanf +#endif + +#if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) +# define _GLIBCXX_HAVE_ATANL 1 +# define atanl _atanl +#endif + +#if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) +# define _GLIBCXX_HAVE_CEILF 1 +# define ceilf _ceilf +#endif + +#if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) +# define _GLIBCXX_HAVE_CEILL 1 +# define ceill _ceill +#endif + +#if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) +# define _GLIBCXX_HAVE_COSF 1 +# define cosf _cosf +#endif + +#if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) +# define _GLIBCXX_HAVE_COSHF 1 +# define coshf _coshf +#endif + +#if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) +# define _GLIBCXX_HAVE_COSHL 1 +# define coshl _coshl +#endif + +#if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) +# define _GLIBCXX_HAVE_COSL 1 +# define cosl _cosl +#endif + +#if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) +# define _GLIBCXX_HAVE_EXPF 1 +# define expf _expf +#endif + +#if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) +# define _GLIBCXX_HAVE_EXPL 1 +# define expl _expl +#endif + +#if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) +# define _GLIBCXX_HAVE_FABSF 1 +# define fabsf _fabsf +#endif + +#if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) +# define _GLIBCXX_HAVE_FABSL 1 +# define fabsl _fabsl +#endif + +#if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) +# define _GLIBCXX_HAVE_FINITE 1 +# define finite _finite +#endif + +#if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) +# define _GLIBCXX_HAVE_FINITEF 1 +# define finitef _finitef +#endif + +#if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) +# define _GLIBCXX_HAVE_FINITEL 1 +# define finitel _finitel +#endif + +#if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) +# define _GLIBCXX_HAVE_FLOORF 1 +# define floorf _floorf +#endif + +#if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) +# define _GLIBCXX_HAVE_FLOORL 1 +# define floorl _floorl +#endif + +#if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) +# define _GLIBCXX_HAVE_FMODF 1 +# define fmodf _fmodf +#endif + +#if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) +# define _GLIBCXX_HAVE_FMODL 1 +# define fmodl _fmodl +#endif + +#if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) +# define _GLIBCXX_HAVE_FPCLASS 1 +# define fpclass _fpclass +#endif + +#if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) +# define _GLIBCXX_HAVE_FREXPF 1 +# define frexpf _frexpf +#endif + +#if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) +# define _GLIBCXX_HAVE_FREXPL 1 +# define frexpl _frexpl +#endif + +#if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) +# define _GLIBCXX_HAVE_HYPOT 1 +# define hypot _hypot +#endif + +#if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) +# define _GLIBCXX_HAVE_HYPOTF 1 +# define hypotf _hypotf +#endif + +#if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) +# define _GLIBCXX_HAVE_HYPOTL 1 +# define hypotl _hypotl +#endif + +#if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) +# define _GLIBCXX_HAVE_ISINF 1 +# define isinf _isinf +#endif + +#if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) +# define _GLIBCXX_HAVE_ISINFF 1 +# define isinff _isinff +#endif + +#if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) +# define _GLIBCXX_HAVE_ISINFL 1 +# define isinfl _isinfl +#endif + +#if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) +# define _GLIBCXX_HAVE_ISNAN 1 +# define isnan _isnan +#endif + +#if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) +# define _GLIBCXX_HAVE_ISNANF 1 +# define isnanf _isnanf +#endif + +#if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) +# define _GLIBCXX_HAVE_ISNANL 1 +# define isnanl _isnanl +#endif + +#if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) +# define _GLIBCXX_HAVE_LDEXPF 1 +# define ldexpf _ldexpf +#endif + +#if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) +# define _GLIBCXX_HAVE_LDEXPL 1 +# define ldexpl _ldexpl +#endif + +#if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) +# define _GLIBCXX_HAVE_LOG10F 1 +# define log10f _log10f +#endif + +#if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) +# define _GLIBCXX_HAVE_LOG10L 1 +# define log10l _log10l +#endif + +#if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) +# define _GLIBCXX_HAVE_LOGF 1 +# define logf _logf +#endif + +#if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) +# define _GLIBCXX_HAVE_LOGL 1 +# define logl _logl +#endif + +#if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) +# define _GLIBCXX_HAVE_MODF 1 +# define modf _modf +#endif + +#if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) +# define _GLIBCXX_HAVE_MODFF 1 +# define modff _modff +#endif + +#if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) +# define _GLIBCXX_HAVE_MODFL 1 +# define modfl _modfl +#endif + +#if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) +# define _GLIBCXX_HAVE_POWF 1 +# define powf _powf +#endif + +#if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) +# define _GLIBCXX_HAVE_POWL 1 +# define powl _powl +#endif + +#if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) +# define _GLIBCXX_HAVE_QFPCLASS 1 +# define qfpclass _qfpclass +#endif + +#if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) +# define _GLIBCXX_HAVE_SINCOS 1 +# define sincos _sincos +#endif + +#if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) +# define _GLIBCXX_HAVE_SINCOSF 1 +# define sincosf _sincosf +#endif + +#if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) +# define _GLIBCXX_HAVE_SINCOSL 1 +# define sincosl _sincosl +#endif + +#if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) +# define _GLIBCXX_HAVE_SINF 1 +# define sinf _sinf +#endif + +#if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) +# define _GLIBCXX_HAVE_SINHF 1 +# define sinhf _sinhf +#endif + +#if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) +# define _GLIBCXX_HAVE_SINHL 1 +# define sinhl _sinhl +#endif + +#if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) +# define _GLIBCXX_HAVE_SINL 1 +# define sinl _sinl +#endif + +#if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) +# define _GLIBCXX_HAVE_SQRTF 1 +# define sqrtf _sqrtf +#endif + +#if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) +# define _GLIBCXX_HAVE_SQRTL 1 +# define sqrtl _sqrtl +#endif + +#if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) +# define _GLIBCXX_HAVE_STRTOF 1 +# define strtof _strtof +#endif + +#if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) +# define _GLIBCXX_HAVE_STRTOLD 1 +# define strtold _strtold +#endif + +#if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) +# define _GLIBCXX_HAVE_TANF 1 +# define tanf _tanf +#endif + +#if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) +# define _GLIBCXX_HAVE_TANHF 1 +# define tanhf _tanhf +#endif + +#if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) +# define _GLIBCXX_HAVE_TANHL 1 +# define tanhl _tanhl +#endif + +#if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) +# define _GLIBCXX_HAVE_TANL 1 +# define tanl _tanl +#endif + +#endif // _GLIBCXX_CXX_CONFIG_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++io.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++io.h new file mode 100755 index 0000000..650566e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++io.h @@ -0,0 +1,50 @@ +// Underlying io library details -*- C++ -*- + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++io.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +// c_io_stdio.h - Defines for using "C" stdio.h + +#ifndef _GLIBCXX_CXX_IO_H +#define _GLIBCXX_CXX_IO_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef __gthread_mutex_t __c_lock; + + // for basic_file.h + typedef FILE __c_file; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++locale.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++locale.h new file mode 100755 index 0000000..fbad3bb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/c++locale.h @@ -0,0 +1,92 @@ +// Wrapper for underlying C-language localization -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++locale.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.8 Standard locale categories. +// + +// Written by Benjamin Kosnik + +#ifndef _GLIBCXX_CXX_LOCALE_H +#define _GLIBCXX_CXX_LOCALE_H 1 + +#pragma GCC system_header + +#include + +#define _GLIBCXX_NUM_CATEGORIES 0 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + typedef int* __c_locale; + + // Convert numeric value of type double and long double to string and + // return length of string. If vsnprintf is available use it, otherwise + // fall back to the unsafe vsprintf which, in general, can be dangerous + // and should be avoided. + inline int + __convert_from_v(const __c_locale&, char* __out, + const int __size __attribute__((__unused__)), + const char* __fmt, ...) + { + char* __old = std::setlocale(LC_NUMERIC, 0); + char* __sav = 0; + if (__builtin_strcmp(__old, "C")) + { + const size_t __len = __builtin_strlen(__old) + 1; + __sav = new char[__len]; + __builtin_memcpy(__sav, __old, __len); + std::setlocale(LC_NUMERIC, "C"); + } + + __builtin_va_list __args; + __builtin_va_start(__args, __fmt); + +#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF + const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); +#else + const int __ret = __builtin_vsprintf(__out, __fmt, __args); +#endif + + __builtin_va_end(__args); + + if (__sav) + { + std::setlocale(LC_NUMERIC, __sav); + delete [] __sav; + } + return __ret; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/cpu_defines.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/cpu_defines.h new file mode 100755 index 0000000..57c102f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/cpu_defines.h @@ -0,0 +1,40 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cpu_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_CPU_DEFINES +#define _GLIBCXX_CPU_DEFINES 1 + +// Integer divide instructions don't trap on ARM. +#ifdef __ARM_ARCH_EXT_IDIV__ +#define __glibcxx_integral_traps false +#else +#define __glibcxx_integral_traps true +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/ctype_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/ctype_base.h new file mode 100755 index 0000000..62fce60 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/ctype_base.h @@ -0,0 +1,59 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// +// ISO C++ 14882: 22.1 Locales +// + +// Default information, may not be appropriate for specific host. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @brief Base class for ctype. + struct ctype_base + { + // Non-standard typedefs. + typedef const int* __to_type; + + // NB: Offsets into ctype::_M_table force a particular size + // on the mask type. Because of this, we don't use an enum. + typedef unsigned int mask; + static const mask upper = 1 << 0; + static const mask lower = 1 << 1; + static const mask alpha = 1 << 2; + static const mask digit = 1 << 3; + static const mask xdigit = 1 << 4; + static const mask space = 1 << 5; + static const mask print = 1 << 6; + static const mask graph = (1 << 2) | (1 << 3) | (1 << 9); // alnum|punct + static const mask cntrl = 1 << 8; + static const mask punct = 1 << 9; + static const mask alnum = (1 << 2) | (1 << 3); // alpha|digit + static const mask blank = 1 << 10; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/ctype_inline.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/ctype_inline.h new file mode 100755 index 0000000..b6ad988 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/ctype_inline.h @@ -0,0 +1,173 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ctype_inline.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) +// functions go in ctype.cc + +// The following definitions are portable, but insanely slow. If one +// cares at all about performance, then specialized ctype +// functionality should be added for the native os in question: see +// the config/os/bits/ctype_*.h files. + +// Constructing a synthetic "C" table should be seriously considered... + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + bool + ctype:: + is(mask __m, char __c) const + { + if (_M_table) + return _M_table[static_cast(__c)] & __m; + else + { + bool __ret = false; + const size_t __bitmasksize = 15; + size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0 + for (; __bitcur <= __bitmasksize; ++__bitcur) + { + const mask __bit = static_cast(1 << __bitcur); + if (__m & __bit) + { + bool __testis; + switch (__bit) + { + case space: + __testis = isspace(__c); + break; + case print: + __testis = isprint(__c); + break; + case cntrl: + __testis = iscntrl(__c); + break; + case upper: + __testis = isupper(__c); + break; + case lower: + __testis = islower(__c); + break; + case alpha: + __testis = isalpha(__c); + break; + case digit: + __testis = isdigit(__c); + break; + case punct: + __testis = ispunct(__c); + break; + case xdigit: + __testis = isxdigit(__c); + break; + case alnum: + __testis = isalnum(__c); + break; + case graph: + __testis = isgraph(__c); + break; +#ifdef _GLIBCXX_USE_C99_CTYPE_TR1 + case blank: + __testis = isblank(__c); + break; +#endif + default: + __testis = false; + break; + } + __ret |= __testis; + } + } + return __ret; + } + } + + const char* + ctype:: + is(const char* __low, const char* __high, mask* __vec) const + { + if (_M_table) + while (__low < __high) + *__vec++ = _M_table[static_cast(*__low++)]; + else + { + // Highest bitmask in ctype_base == 11. + const size_t __bitmasksize = 15; + for (;__low < __high; ++__vec, ++__low) + { + mask __m = 0; + // Lowest bitmask in ctype_base == 0 + size_t __i = 0; + for (;__i <= __bitmasksize; ++__i) + { + const mask __bit = static_cast(1 << __i); + if (this->is(__bit, *__low)) + __m |= __bit; + } + *__vec = __m; + } + } + return __high; + } + + const char* + ctype:: + scan_is(mask __m, const char* __low, const char* __high) const + { + if (_M_table) + while (__low < __high + && !(_M_table[static_cast(*__low)] & __m)) + ++__low; + else + while (__low < __high && !this->is(__m, *__low)) + ++__low; + return __low; + } + + const char* + ctype:: + scan_not(mask __m, const char* __low, const char* __high) const + { + if (_M_table) + while (__low < __high + && (_M_table[static_cast(*__low)] & __m) != 0) + ++__low; + else + while (__low < __high && this->is(__m, *__low) != 0) + ++__low; + return __low; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/cxxabi_tweaks.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/cxxabi_tweaks.h new file mode 100755 index 0000000..2fb1611 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/cxxabi_tweaks.h @@ -0,0 +1,87 @@ +// Control various target specific ABI tweaks. ARM version. + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cxxabi_tweaks.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cxxabi.h} + */ + +#ifndef _CXXABI_TWEAKS_H +#define _CXXABI_TWEAKS_H 1 + +#ifdef __cplusplus +namespace __cxxabiv1 +{ + extern "C" + { +#endif + +#ifdef __ARM_EABI__ + // The ARM EABI uses the least significant bit of a 32-bit + // guard variable. +#define _GLIBCXX_GUARD_TEST(x) ((*(x) & 1) != 0) +#define _GLIBCXX_GUARD_SET(x) *(x) = 1 +#define _GLIBCXX_GUARD_BIT 1 +#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) +#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) + typedef int __guard; + +#define _GLIBCXX_GUARD_TEST_AND_ACQUIRE(x) \ + ((__atomic_load_n(x, __ATOMIC_ACQUIRE) & 1) != 0) +#define _GLIBCXX_GUARD_SET_AND_RELEASE(x) \ + __atomic_store_n(x, 1, __ATOMIC_RELEASE) + + // We also want the element size in array cookies. +#define _GLIBCXX_ELTSIZE_IN_COOKIE 1 + + // __cxa_vec_ctor should return a pointer to the array. + typedef void * __cxa_vec_ctor_return_type; +#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x + // Constructors and destructors return the "this" pointer. + typedef void * __cxa_cdtor_return_type; + +#else // __ARM_EABI__ + + // The generic ABI uses the first byte of a 64-bit guard variable. +#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) +#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 +#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) +#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) +#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) + __extension__ typedef int __guard __attribute__((mode (__DI__))); + + // __cxa_vec_ctor has void return type. + typedef void __cxa_vec_ctor_return_type; +#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return + // Constructors and destructors do not return a value. + typedef void __cxa_cdtor_return_type; + +#endif //!__ARM_EABI__ + +#ifdef __cplusplus + } +} // namespace __cxxabiv1 +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/error_constants.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/error_constants.h new file mode 100755 index 0000000..9d01c16 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/error_constants.h @@ -0,0 +1,178 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/error_constants.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{system_error} + */ + +#ifndef _GLIBCXX_ERROR_CONSTANTS +#define _GLIBCXX_ERROR_CONSTANTS 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum class errc + { + address_family_not_supported = EAFNOSUPPORT, + address_in_use = EADDRINUSE, + address_not_available = EADDRNOTAVAIL, + already_connected = EISCONN, + argument_list_too_long = E2BIG, + argument_out_of_domain = EDOM, + bad_address = EFAULT, + bad_file_descriptor = EBADF, + +#ifdef EBADMSG + bad_message = EBADMSG, +#endif + + broken_pipe = EPIPE, + connection_aborted = ECONNABORTED, + connection_already_in_progress = EALREADY, + connection_refused = ECONNREFUSED, + connection_reset = ECONNRESET, + cross_device_link = EXDEV, + destination_address_required = EDESTADDRREQ, + device_or_resource_busy = EBUSY, + directory_not_empty = ENOTEMPTY, + executable_format_error = ENOEXEC, + file_exists = EEXIST, + file_too_large = EFBIG, + filename_too_long = ENAMETOOLONG, + function_not_supported = ENOSYS, + host_unreachable = EHOSTUNREACH, + +#ifdef EIDRM + identifier_removed = EIDRM, +#endif + + illegal_byte_sequence = EILSEQ, + inappropriate_io_control_operation = ENOTTY, + interrupted = EINTR, + invalid_argument = EINVAL, + invalid_seek = ESPIPE, + io_error = EIO, + is_a_directory = EISDIR, + message_size = EMSGSIZE, + network_down = ENETDOWN, + network_reset = ENETRESET, + network_unreachable = ENETUNREACH, + no_buffer_space = ENOBUFS, + no_child_process = ECHILD, + +#ifdef ENOLINK + no_link = ENOLINK, +#endif + + no_lock_available = ENOLCK, + +#ifdef ENODATA + no_message_available = ENODATA, +#endif + + no_message = ENOMSG, + no_protocol_option = ENOPROTOOPT, + no_space_on_device = ENOSPC, + +#ifdef ENOSR + no_stream_resources = ENOSR, +#endif + + no_such_device_or_address = ENXIO, + no_such_device = ENODEV, + no_such_file_or_directory = ENOENT, + no_such_process = ESRCH, + not_a_directory = ENOTDIR, + not_a_socket = ENOTSOCK, + +#ifdef ENOSTR + not_a_stream = ENOSTR, +#endif + + not_connected = ENOTCONN, + not_enough_memory = ENOMEM, + +#ifdef ENOTSUP + not_supported = ENOTSUP, +#endif + +#ifdef ECANCELED + operation_canceled = ECANCELED, +#endif + + operation_in_progress = EINPROGRESS, + operation_not_permitted = EPERM, + operation_not_supported = EOPNOTSUPP, + operation_would_block = EWOULDBLOCK, + +#ifdef EOWNERDEAD + owner_dead = EOWNERDEAD, +#endif + + permission_denied = EACCES, + +#ifdef EPROTO + protocol_error = EPROTO, +#endif + + protocol_not_supported = EPROTONOSUPPORT, + read_only_file_system = EROFS, + resource_deadlock_would_occur = EDEADLK, + resource_unavailable_try_again = EAGAIN, + result_out_of_range = ERANGE, + +#ifdef ENOTRECOVERABLE + state_not_recoverable = ENOTRECOVERABLE, +#endif + +#ifdef ETIME + stream_timeout = ETIME, +#endif + +#ifdef ETXTBSY + text_file_busy = ETXTBSY, +#endif + + timed_out = ETIMEDOUT, + too_many_files_open_in_system = ENFILE, + too_many_files_open = EMFILE, + too_many_links = EMLINK, + too_many_symbolic_link_levels = ELOOP, + +#ifdef EOVERFLOW + value_too_large = EOVERFLOW, +#endif + + wrong_protocol_type = EPROTOTYPE + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/extc++.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/extc++.h new file mode 100755 index 0000000..fed2083 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/extc++.h @@ -0,0 +1,83 @@ +// C++ includes used for precompiling extensions -*- C++ -*- + +// Copyright (C) 2006-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file extc++.h + * This is an implementation file for a precompiled header. + */ + +#if __cplusplus < 201103L +#include +#else +#include +#endif + +#include +#if __cplusplus >= 201103L +# include +#endif +#include +#include +#include +#include +#if __cplusplus >= 201103L +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if __cplusplus >= 201103L +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_HAVE_ICONV + #include + #include +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-default.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-default.h new file mode 100755 index 0000000..2ec1c36 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-default.h @@ -0,0 +1,890 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2021 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _GLIBCXX_GCC_GTHR_POSIX_H +#define _GLIBCXX_GCC_GTHR_POSIX_H + +/* POSIX threads specific definitions. + Easy, since the interface is just one-to-one mapping. */ + +#define __GTHREADS 1 +#define __GTHREADS_CXX0X 1 + +#include + +#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ + || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) +# include +# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 +# else +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 +# endif +#endif + +typedef pthread_t __gthread_t; +typedef pthread_key_t __gthread_key_t; +typedef pthread_once_t __gthread_once_t; +typedef pthread_mutex_t __gthread_mutex_t; +typedef pthread_mutex_t __gthread_recursive_mutex_t; +typedef pthread_cond_t __gthread_cond_t; +typedef struct timespec __gthread_time_t; + +/* POSIX like conditional variables are supported. Please look at comments + in gthr.h for details. */ +#define __GTHREAD_HAS_COND 1 + +#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function +#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT +#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +#else +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER +#define __GTHREAD_TIME_INIT {0,0} + +#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC +# undef __GTHREAD_MUTEX_INIT +#endif +#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC +# undef __GTHREAD_RECURSIVE_MUTEX_INIT +# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION +# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#ifdef _GTHREAD_USE_COND_INIT_FUNC +# undef __GTHREAD_COND_INIT +# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function +#endif + +#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK +# ifndef __gthrw_pragma +# define __gthrw_pragma(pragma) +# endif +# define __gthrw2(name,name2,type) \ + static __typeof(type) name \ + __attribute__ ((__weakref__(#name2), __copy__ (type))); \ + __gthrw_pragma(weak type) +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw2(name,name2,type) +# define __gthrw_(name) name +#endif + +/* Typically, __gthrw_foo is a weak reference to symbol foo. */ +#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) + +__gthrw(pthread_once) +__gthrw(pthread_getspecific) +__gthrw(pthread_setspecific) + +__gthrw(pthread_create) +__gthrw(pthread_join) +__gthrw(pthread_equal) +__gthrw(pthread_self) +__gthrw(pthread_detach) +#ifndef __BIONIC__ +__gthrw(pthread_cancel) +#endif +__gthrw(sched_yield) + +__gthrw(pthread_mutex_lock) +__gthrw(pthread_mutex_trylock) +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +__gthrw(pthread_mutex_timedlock) +#endif +__gthrw(pthread_mutex_unlock) +__gthrw(pthread_mutex_init) +__gthrw(pthread_mutex_destroy) + +__gthrw(pthread_cond_init) +__gthrw(pthread_cond_broadcast) +__gthrw(pthread_cond_signal) +__gthrw(pthread_cond_wait) +__gthrw(pthread_cond_timedwait) +__gthrw(pthread_cond_destroy) + +__gthrw(pthread_key_create) +__gthrw(pthread_key_delete) +__gthrw(pthread_mutexattr_init) +__gthrw(pthread_mutexattr_settype) +__gthrw(pthread_mutexattr_destroy) + + +#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) +/* Objective-C. */ +__gthrw(pthread_exit) +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(sched_get_priority_max) +__gthrw(sched_get_priority_min) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ +__gthrw(pthread_attr_destroy) +__gthrw(pthread_attr_init) +__gthrw(pthread_attr_setdetachstate) +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(pthread_getschedparam) +__gthrw(pthread_setschedparam) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _LIBOBJC || _LIBOBJC_WEAK */ + +#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK + +/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if + -pthreads is not specified. The functions are dummies and most return an + error value. However pthread_once returns 0 without invoking the routine + it is passed so we cannot pretend that the interface is active if -pthreads + is not specified. On Solaris 2.5.1, the interface is not exposed at all so + we need to play the usual game with weak symbols. On Solaris 10 and up, a + working interface is always exposed. On FreeBSD 6 and later, libc also + exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up + to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, + which means the alternate __gthread_active_p below cannot be used there. */ + +#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) + +static volatile int __gthread_active = -1; + +static void +__gthread_trigger (void) +{ + __gthread_active = 1; +} + +static inline int +__gthread_active_p (void) +{ + static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; + static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; + + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + + /* This test is not protected to avoid taking a lock on the main code + path so every update of __gthread_active in a threaded program must + be atomic with regard to the result of the test. */ + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + if (__gthrw_(pthread_once)) + { + /* If this really is a threaded program, then we must ensure that + __gthread_active has been set to 1 before exiting this block. */ + __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); + __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); + __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); + } + + /* Make sure we'll never enter this block again. */ + if (__gthread_active < 0) + __gthread_active = 0; + + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* neither FreeBSD nor Solaris */ + +/* For a program to be multi-threaded the only thing that it certainly must + be using is pthread_create. However, there may be other libraries that + intercept pthread_create with their own definitions to wrap pthreads + functionality for some purpose. In those cases, pthread_create being + defined might not necessarily mean that libpthread is actually linked + in. + + For the GNU C library, we can use a known internal name. This is always + available in the ABI, but no other library would define it. That is + ideal, since any public pthread function might be intercepted just as + pthread_create might be. __pthread_key_create is an "internal" + implementation symbol, but it is part of the public exported ABI. Also, + it's among the symbols that the static libpthread.a always links in + whenever pthread_create is used, so there is no danger of a false + negative result in any statically-linked, multi-threaded program. + + For others, we choose pthread_cancel as a function that seems unlikely + to be redefined by an interceptor library. The bionic (Android) C + library does not provide pthread_cancel, so we do use pthread_create + there (and interceptor libraries lose). */ + +#ifdef __GLIBC__ +__gthrw2(__gthrw_(__pthread_key_create), + __pthread_key_create, + pthread_key_create) +# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) +#elif defined (__BIONIC__) +# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) +#else +# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) +#endif + +static inline int +__gthread_active_p (void) +{ + static void *const __gthread_active_ptr + = __extension__ (void *) >HR_ACTIVE_PROXY; + return __gthread_active_ptr != 0; +} + +#endif /* FreeBSD or Solaris */ + +#else /* not __GXX_WEAK__ */ + +/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread + calls in shared flavors of the HP-UX C library. Most of the stubs + have no functionality. The details are described in the "libc cumulative + patch" for each subversion of HP-UX 11. There are two special interfaces + provided for checking whether an application is linked to a shared pthread + library or not. However, these interfaces aren't available in early + libpthread libraries. We also need a test that works for archive + libraries. We can't use pthread_once as some libc versions call the + init function. We also can't use pthread_create or pthread_attr_init + as these create a thread and thereby prevent changing the default stack + size. The function pthread_default_stacksize_np is available in both + the archive and shared versions of libpthread. It can be used to + determine the default pthread stack size. There is a stub in some + shared libc versions which returns a zero size if pthreads are not + active. We provide an equivalent stub to handle cases where libc + doesn't provide one. */ + +#if defined(__hppa__) && defined(__hpux__) + +static volatile int __gthread_active = -1; + +static inline int +__gthread_active_p (void) +{ + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + size_t __s; + + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + pthread_default_stacksize_np (0, &__s); + __gthread_active = __s ? 1 : 0; + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* not hppa-hpux */ + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +#endif /* hppa-hpux */ + +#endif /* __GXX_WEAK__ */ + +#ifdef _LIBOBJC + +/* This is the config.h file in libobjc/ */ +#include + +#ifdef HAVE_SCHED_H +# include +#endif + +/* Key structure for maintaining thread specific storage */ +static pthread_key_t _objc_thread_storage; +static pthread_attr_t _objc_thread_attribs; + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + if (__gthread_active_p ()) + { + /* Initialize the thread storage key. */ + if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) + { + /* The normal default detach state for threads is + * PTHREAD_CREATE_JOINABLE which causes threads to not die + * when you think they should. */ + if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 + && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, + PTHREAD_CREATE_DETACHED) == 0) + return 0; + } + } + + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + if (__gthread_active_p () + && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 + && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) + return 0; + + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (*func)(void *), void *arg) +{ + objc_thread_t thread_id; + pthread_t new_thread_handle; + + if (!__gthread_active_p ()) + return NULL; + + if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, + (void *) func, arg))) + thread_id = (objc_thread_t) new_thread_handle; + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority) +{ + if (!__gthread_active_p ()) + return -1; + else + { +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + pthread_t thread_id = __gthrw_(pthread_self) (); + int policy; + struct sched_param params; + int priority_min, priority_max; + + if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) + { + if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) + return -1; + + if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) + return -1; + + if (priority > priority_max) + priority = priority_max; + else if (priority < priority_min) + priority = priority_min; + params.sched_priority = priority; + + /* + * The solaris 7 and several other man pages incorrectly state that + * this should be a pointer to policy but pthread.h is universally + * at odds with this. + */ + if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) + return 0; + } +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return -1; + } +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + if (__gthread_active_p ()) + { + int policy; + struct sched_param params; + + if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) + return params.sched_priority; + else + return -1; + } + else +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + if (__gthread_active_p ()) + __gthrw_(sched_yield) (); +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + if (__gthread_active_p ()) + /* exit the thread */ + __gthrw_(pthread_exit) (&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + if (__gthread_active_p ()) + return (objc_thread_t) __gthrw_(pthread_self) (); + else + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); + else + { + thread_local_storage = value; + return 0; + } +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_getspecific) (_objc_thread_storage); + else + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); + + if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) + { + objc_free (mutex->backend); + mutex->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + int count; + + /* + * Posix Threads specifically require that the thread be unlocked + * for __gthrw_(pthread_mutex_destroy) to work. + */ + + do + { + count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); + if (count < 0) + return -1; + } + while (count); + + if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) + return -1; + + objc_free (mutex->backend); + mutex->backend = NULL; + } + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + condition->backend = objc_malloc (sizeof (pthread_cond_t)); + + if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) + { + objc_free (condition->backend); + condition->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) + return -1; + + objc_free (condition->backend); + condition->backend = NULL; + } + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, + (pthread_mutex_t *) mutex->backend); + else + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_create (__gthread_t *__threadid, void *(*__func) (void*), + void *__args) +{ + return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); +} + +static inline int +__gthread_join (__gthread_t __threadid, void **__value_ptr) +{ + return __gthrw_(pthread_join) (__threadid, __value_ptr); +} + +static inline int +__gthread_detach (__gthread_t __threadid) +{ + return __gthrw_(pthread_detach) (__threadid); +} + +static inline int +__gthread_equal (__gthread_t __t1, __gthread_t __t2) +{ + return __gthrw_(pthread_equal) (__t1, __t2); +} + +static inline __gthread_t +__gthread_self (void) +{ + return __gthrw_(pthread_self) (); +} + +static inline int +__gthread_yield (void) +{ + return __gthrw_(sched_yield) (); +} + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(pthread_key_create) (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return __gthrw_(pthread_key_delete) (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return __gthrw_(pthread_getspecific) (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthrw_(pthread_setspecific) (__key, __ptr); +} + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_mutex_init) (__mutex, NULL); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_destroy) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_trylock) (__mutex); + else + return 0; +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_mutex_timedlock (__gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); + else + return 0; +} +#endif + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_unlock) (__mutex); + else + return 0; +} + +#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ + || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + pthread_mutexattr_t __attr; + int __r; + + __r = __gthrw_(pthread_mutexattr_init) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_settype) (&__attr, + PTHREAD_MUTEX_RECURSIVE); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); + return __r; + } + return 0; +} +#endif + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_mutex_timedlock (__mutex, __abs_timeout); +} +#endif + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +static inline int +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_destroy (__mutex); +} + +#ifdef _GTHREAD_USE_COND_INIT_FUNC +static inline void +__gthread_cond_init_function (__gthread_cond_t *__cond) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_cond_init) (__cond, NULL); +} +#endif + +static inline int +__gthread_cond_broadcast (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_broadcast) (__cond); +} + +static inline int +__gthread_cond_signal (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_signal) (__cond); +} + +static inline int +__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) +{ + return __gthrw_(pthread_cond_wait) (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_wait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex) +{ + return __gthread_cond_wait (__cond, __mutex); +} + +static inline int +__gthread_cond_destroy (__gthread_cond_t* __cond) +{ + return __gthrw_(pthread_cond_destroy) (__cond); +} + +#endif /* _LIBOBJC */ + +#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-posix.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-posix.h new file mode 100755 index 0000000..2ec1c36 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-posix.h @@ -0,0 +1,890 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2021 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _GLIBCXX_GCC_GTHR_POSIX_H +#define _GLIBCXX_GCC_GTHR_POSIX_H + +/* POSIX threads specific definitions. + Easy, since the interface is just one-to-one mapping. */ + +#define __GTHREADS 1 +#define __GTHREADS_CXX0X 1 + +#include + +#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ + || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) +# include +# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 +# else +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 +# endif +#endif + +typedef pthread_t __gthread_t; +typedef pthread_key_t __gthread_key_t; +typedef pthread_once_t __gthread_once_t; +typedef pthread_mutex_t __gthread_mutex_t; +typedef pthread_mutex_t __gthread_recursive_mutex_t; +typedef pthread_cond_t __gthread_cond_t; +typedef struct timespec __gthread_time_t; + +/* POSIX like conditional variables are supported. Please look at comments + in gthr.h for details. */ +#define __GTHREAD_HAS_COND 1 + +#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function +#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT +#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +#else +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER +#define __GTHREAD_TIME_INIT {0,0} + +#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC +# undef __GTHREAD_MUTEX_INIT +#endif +#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC +# undef __GTHREAD_RECURSIVE_MUTEX_INIT +# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION +# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#ifdef _GTHREAD_USE_COND_INIT_FUNC +# undef __GTHREAD_COND_INIT +# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function +#endif + +#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK +# ifndef __gthrw_pragma +# define __gthrw_pragma(pragma) +# endif +# define __gthrw2(name,name2,type) \ + static __typeof(type) name \ + __attribute__ ((__weakref__(#name2), __copy__ (type))); \ + __gthrw_pragma(weak type) +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw2(name,name2,type) +# define __gthrw_(name) name +#endif + +/* Typically, __gthrw_foo is a weak reference to symbol foo. */ +#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) + +__gthrw(pthread_once) +__gthrw(pthread_getspecific) +__gthrw(pthread_setspecific) + +__gthrw(pthread_create) +__gthrw(pthread_join) +__gthrw(pthread_equal) +__gthrw(pthread_self) +__gthrw(pthread_detach) +#ifndef __BIONIC__ +__gthrw(pthread_cancel) +#endif +__gthrw(sched_yield) + +__gthrw(pthread_mutex_lock) +__gthrw(pthread_mutex_trylock) +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +__gthrw(pthread_mutex_timedlock) +#endif +__gthrw(pthread_mutex_unlock) +__gthrw(pthread_mutex_init) +__gthrw(pthread_mutex_destroy) + +__gthrw(pthread_cond_init) +__gthrw(pthread_cond_broadcast) +__gthrw(pthread_cond_signal) +__gthrw(pthread_cond_wait) +__gthrw(pthread_cond_timedwait) +__gthrw(pthread_cond_destroy) + +__gthrw(pthread_key_create) +__gthrw(pthread_key_delete) +__gthrw(pthread_mutexattr_init) +__gthrw(pthread_mutexattr_settype) +__gthrw(pthread_mutexattr_destroy) + + +#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) +/* Objective-C. */ +__gthrw(pthread_exit) +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(sched_get_priority_max) +__gthrw(sched_get_priority_min) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ +__gthrw(pthread_attr_destroy) +__gthrw(pthread_attr_init) +__gthrw(pthread_attr_setdetachstate) +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(pthread_getschedparam) +__gthrw(pthread_setschedparam) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _LIBOBJC || _LIBOBJC_WEAK */ + +#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK + +/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if + -pthreads is not specified. The functions are dummies and most return an + error value. However pthread_once returns 0 without invoking the routine + it is passed so we cannot pretend that the interface is active if -pthreads + is not specified. On Solaris 2.5.1, the interface is not exposed at all so + we need to play the usual game with weak symbols. On Solaris 10 and up, a + working interface is always exposed. On FreeBSD 6 and later, libc also + exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up + to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, + which means the alternate __gthread_active_p below cannot be used there. */ + +#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) + +static volatile int __gthread_active = -1; + +static void +__gthread_trigger (void) +{ + __gthread_active = 1; +} + +static inline int +__gthread_active_p (void) +{ + static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; + static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; + + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + + /* This test is not protected to avoid taking a lock on the main code + path so every update of __gthread_active in a threaded program must + be atomic with regard to the result of the test. */ + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + if (__gthrw_(pthread_once)) + { + /* If this really is a threaded program, then we must ensure that + __gthread_active has been set to 1 before exiting this block. */ + __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); + __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); + __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); + } + + /* Make sure we'll never enter this block again. */ + if (__gthread_active < 0) + __gthread_active = 0; + + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* neither FreeBSD nor Solaris */ + +/* For a program to be multi-threaded the only thing that it certainly must + be using is pthread_create. However, there may be other libraries that + intercept pthread_create with their own definitions to wrap pthreads + functionality for some purpose. In those cases, pthread_create being + defined might not necessarily mean that libpthread is actually linked + in. + + For the GNU C library, we can use a known internal name. This is always + available in the ABI, but no other library would define it. That is + ideal, since any public pthread function might be intercepted just as + pthread_create might be. __pthread_key_create is an "internal" + implementation symbol, but it is part of the public exported ABI. Also, + it's among the symbols that the static libpthread.a always links in + whenever pthread_create is used, so there is no danger of a false + negative result in any statically-linked, multi-threaded program. + + For others, we choose pthread_cancel as a function that seems unlikely + to be redefined by an interceptor library. The bionic (Android) C + library does not provide pthread_cancel, so we do use pthread_create + there (and interceptor libraries lose). */ + +#ifdef __GLIBC__ +__gthrw2(__gthrw_(__pthread_key_create), + __pthread_key_create, + pthread_key_create) +# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) +#elif defined (__BIONIC__) +# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) +#else +# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) +#endif + +static inline int +__gthread_active_p (void) +{ + static void *const __gthread_active_ptr + = __extension__ (void *) >HR_ACTIVE_PROXY; + return __gthread_active_ptr != 0; +} + +#endif /* FreeBSD or Solaris */ + +#else /* not __GXX_WEAK__ */ + +/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread + calls in shared flavors of the HP-UX C library. Most of the stubs + have no functionality. The details are described in the "libc cumulative + patch" for each subversion of HP-UX 11. There are two special interfaces + provided for checking whether an application is linked to a shared pthread + library or not. However, these interfaces aren't available in early + libpthread libraries. We also need a test that works for archive + libraries. We can't use pthread_once as some libc versions call the + init function. We also can't use pthread_create or pthread_attr_init + as these create a thread and thereby prevent changing the default stack + size. The function pthread_default_stacksize_np is available in both + the archive and shared versions of libpthread. It can be used to + determine the default pthread stack size. There is a stub in some + shared libc versions which returns a zero size if pthreads are not + active. We provide an equivalent stub to handle cases where libc + doesn't provide one. */ + +#if defined(__hppa__) && defined(__hpux__) + +static volatile int __gthread_active = -1; + +static inline int +__gthread_active_p (void) +{ + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + size_t __s; + + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + pthread_default_stacksize_np (0, &__s); + __gthread_active = __s ? 1 : 0; + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* not hppa-hpux */ + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +#endif /* hppa-hpux */ + +#endif /* __GXX_WEAK__ */ + +#ifdef _LIBOBJC + +/* This is the config.h file in libobjc/ */ +#include + +#ifdef HAVE_SCHED_H +# include +#endif + +/* Key structure for maintaining thread specific storage */ +static pthread_key_t _objc_thread_storage; +static pthread_attr_t _objc_thread_attribs; + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + if (__gthread_active_p ()) + { + /* Initialize the thread storage key. */ + if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) + { + /* The normal default detach state for threads is + * PTHREAD_CREATE_JOINABLE which causes threads to not die + * when you think they should. */ + if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 + && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, + PTHREAD_CREATE_DETACHED) == 0) + return 0; + } + } + + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + if (__gthread_active_p () + && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 + && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) + return 0; + + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (*func)(void *), void *arg) +{ + objc_thread_t thread_id; + pthread_t new_thread_handle; + + if (!__gthread_active_p ()) + return NULL; + + if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, + (void *) func, arg))) + thread_id = (objc_thread_t) new_thread_handle; + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority) +{ + if (!__gthread_active_p ()) + return -1; + else + { +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + pthread_t thread_id = __gthrw_(pthread_self) (); + int policy; + struct sched_param params; + int priority_min, priority_max; + + if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) + { + if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) + return -1; + + if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) + return -1; + + if (priority > priority_max) + priority = priority_max; + else if (priority < priority_min) + priority = priority_min; + params.sched_priority = priority; + + /* + * The solaris 7 and several other man pages incorrectly state that + * this should be a pointer to policy but pthread.h is universally + * at odds with this. + */ + if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) + return 0; + } +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return -1; + } +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + if (__gthread_active_p ()) + { + int policy; + struct sched_param params; + + if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) + return params.sched_priority; + else + return -1; + } + else +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + if (__gthread_active_p ()) + __gthrw_(sched_yield) (); +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + if (__gthread_active_p ()) + /* exit the thread */ + __gthrw_(pthread_exit) (&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + if (__gthread_active_p ()) + return (objc_thread_t) __gthrw_(pthread_self) (); + else + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); + else + { + thread_local_storage = value; + return 0; + } +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_getspecific) (_objc_thread_storage); + else + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); + + if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) + { + objc_free (mutex->backend); + mutex->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + int count; + + /* + * Posix Threads specifically require that the thread be unlocked + * for __gthrw_(pthread_mutex_destroy) to work. + */ + + do + { + count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); + if (count < 0) + return -1; + } + while (count); + + if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) + return -1; + + objc_free (mutex->backend); + mutex->backend = NULL; + } + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + condition->backend = objc_malloc (sizeof (pthread_cond_t)); + + if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) + { + objc_free (condition->backend); + condition->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) + return -1; + + objc_free (condition->backend); + condition->backend = NULL; + } + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, + (pthread_mutex_t *) mutex->backend); + else + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_create (__gthread_t *__threadid, void *(*__func) (void*), + void *__args) +{ + return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); +} + +static inline int +__gthread_join (__gthread_t __threadid, void **__value_ptr) +{ + return __gthrw_(pthread_join) (__threadid, __value_ptr); +} + +static inline int +__gthread_detach (__gthread_t __threadid) +{ + return __gthrw_(pthread_detach) (__threadid); +} + +static inline int +__gthread_equal (__gthread_t __t1, __gthread_t __t2) +{ + return __gthrw_(pthread_equal) (__t1, __t2); +} + +static inline __gthread_t +__gthread_self (void) +{ + return __gthrw_(pthread_self) (); +} + +static inline int +__gthread_yield (void) +{ + return __gthrw_(sched_yield) (); +} + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(pthread_key_create) (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return __gthrw_(pthread_key_delete) (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return __gthrw_(pthread_getspecific) (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthrw_(pthread_setspecific) (__key, __ptr); +} + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_mutex_init) (__mutex, NULL); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_destroy) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_trylock) (__mutex); + else + return 0; +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_mutex_timedlock (__gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); + else + return 0; +} +#endif + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_unlock) (__mutex); + else + return 0; +} + +#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ + || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + pthread_mutexattr_t __attr; + int __r; + + __r = __gthrw_(pthread_mutexattr_init) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_settype) (&__attr, + PTHREAD_MUTEX_RECURSIVE); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); + return __r; + } + return 0; +} +#endif + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_mutex_timedlock (__mutex, __abs_timeout); +} +#endif + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +static inline int +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_destroy (__mutex); +} + +#ifdef _GTHREAD_USE_COND_INIT_FUNC +static inline void +__gthread_cond_init_function (__gthread_cond_t *__cond) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_cond_init) (__cond, NULL); +} +#endif + +static inline int +__gthread_cond_broadcast (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_broadcast) (__cond); +} + +static inline int +__gthread_cond_signal (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_signal) (__cond); +} + +static inline int +__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) +{ + return __gthrw_(pthread_cond_wait) (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_wait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex) +{ + return __gthread_cond_wait (__cond, __mutex); +} + +static inline int +__gthread_cond_destroy (__gthread_cond_t* __cond) +{ + return __gthrw_(pthread_cond_destroy) (__cond); +} + +#endif /* _LIBOBJC */ + +#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-single.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-single.h new file mode 100755 index 0000000..710e6c6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr-single.h @@ -0,0 +1,298 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2021 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H +#define _GLIBCXX_GCC_GTHR_SINGLE_H + +/* Just provide compatibility for mutex handling. */ + +typedef int __gthread_key_t; +typedef int __gthread_once_t; +typedef int __gthread_mutex_t; +typedef int __gthread_recursive_mutex_t; + +#define __GTHREAD_ONCE_INIT 0 +#define __GTHREAD_MUTEX_INIT 0 +#define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0) +#define __GTHREAD_RECURSIVE_MUTEX_INIT 0 + +#define _GLIBCXX_UNUSED __attribute__((__unused__)) + +#ifdef _LIBOBJC + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + /* No thread support available */ + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + /* No thread support available */ + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED) +{ + /* No thread support available */ + return NULL; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED) +{ + /* No thread support available */ + return -1; +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + return; +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + /* No thread support available */ + /* Should we really exit the program */ + /* exit (&__objc_thread_exit_status); */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + /* No thread support, use 1. */ + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + thread_local_storage = value; + return 0; +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED) +{ + /* There can only be one thread, so we always get the lock */ + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED) +{ + /* There can only be one thread, so we always get the lock */ + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED, + objc_mutex_t mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED) +{ + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED) +{ + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_active_p (void) +{ + return 0; +} + +static inline int +__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int _GLIBCXX_UNUSED +__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED) +{ + return 0; +} + +static int _GLIBCXX_UNUSED +__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int +__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) +{ + return 0; +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +static inline int +__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_destroy (__mutex); +} + +#endif /* _LIBOBJC */ + +#undef _GLIBCXX_UNUSED + +#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr.h new file mode 100755 index 0000000..c9e2224 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/gthr.h @@ -0,0 +1,154 @@ +/* Threads compatibility routines for libgcc2. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997-2021 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +#ifndef _GLIBCXX_GCC_GTHR_H +#define _GLIBCXX_GCC_GTHR_H + +#ifndef _GLIBCXX_HIDE_EXPORTS +#pragma GCC visibility push(default) +#endif + +/* If this file is compiled with threads support, it must + #define __GTHREADS 1 + to indicate that threads support is present. Also it has define + function + int __gthread_active_p () + that returns 1 if thread system is active, 0 if not. + + The threads interface must define the following types: + __gthread_key_t + __gthread_once_t + __gthread_mutex_t + __gthread_recursive_mutex_t + + The threads interface must define the following macros: + + __GTHREAD_ONCE_INIT + to initialize __gthread_once_t + __GTHREAD_MUTEX_INIT + to initialize __gthread_mutex_t to get a fast + non-recursive mutex. + __GTHREAD_MUTEX_INIT_FUNCTION + to initialize __gthread_mutex_t to get a fast + non-recursive mutex. + Define this to a function which looks like this: + void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) + Some systems can't initialize a mutex without a + function call. Don't define __GTHREAD_MUTEX_INIT in this case. + __GTHREAD_RECURSIVE_MUTEX_INIT + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION + as above, but for a recursive mutex. + + The threads interface must define the following static functions: + + int __gthread_once (__gthread_once_t *once, void (*func) ()) + + int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) + int __gthread_key_delete (__gthread_key_t key) + + void *__gthread_getspecific (__gthread_key_t key) + int __gthread_setspecific (__gthread_key_t key, const void *ptr) + + int __gthread_mutex_destroy (__gthread_mutex_t *mutex); + int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex); + + int __gthread_mutex_lock (__gthread_mutex_t *mutex); + int __gthread_mutex_trylock (__gthread_mutex_t *mutex); + int __gthread_mutex_unlock (__gthread_mutex_t *mutex); + + int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); + int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); + int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); + + The following are supported in POSIX threads only. They are required to + fix a deadlock in static initialization inside libsupc++. The header file + gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra + features are supported. + + Types: + __gthread_cond_t + + Macros: + __GTHREAD_COND_INIT + __GTHREAD_COND_INIT_FUNCTION + + Interface: + int __gthread_cond_broadcast (__gthread_cond_t *cond); + int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); + int __gthread_cond_wait_recursive (__gthread_cond_t *cond, + __gthread_recursive_mutex_t *mutex); + + All functions returning int should return zero on success or the error + number. If the operation is not supported, -1 is returned. + + If the following are also defined, you should + #define __GTHREADS_CXX0X 1 + to enable the c++0x thread library. + + Types: + __gthread_t + __gthread_time_t + + Interface: + int __gthread_create (__gthread_t *thread, void *(*func) (void*), + void *args); + int __gthread_join (__gthread_t thread, void **value_ptr); + int __gthread_detach (__gthread_t thread); + int __gthread_equal (__gthread_t t1, __gthread_t t2); + __gthread_t __gthread_self (void); + int __gthread_yield (void); + + int __gthread_mutex_timedlock (__gthread_mutex_t *m, + const __gthread_time_t *abs_timeout); + int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, + const __gthread_time_t *abs_time); + + int __gthread_cond_signal (__gthread_cond_t *cond); + int __gthread_cond_timedwait (__gthread_cond_t *cond, + __gthread_mutex_t *mutex, + const __gthread_time_t *abs_timeout); + +*/ + +#if __GXX_WEAK__ +/* The pe-coff weak support isn't fully compatible to ELF's weak. + For static libraries it might would work, but as we need to deal + with shared versions too, we disable it for mingw-targets. */ +#ifdef __MINGW32__ +#undef _GLIBCXX_GTHREAD_USE_WEAK +#define _GLIBCXX_GTHREAD_USE_WEAK 0 +#endif + +#ifndef _GLIBCXX_GTHREAD_USE_WEAK +#define _GLIBCXX_GTHREAD_USE_WEAK 1 +#endif +#endif +#include + +#ifndef _GLIBCXX_HIDE_EXPORTS +#pragma GCC visibility pop +#endif + +#endif /* ! _GLIBCXX_GCC_GTHR_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/messages_members.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/messages_members.h new file mode 100755 index 0000000..78c10e6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/messages_members.h @@ -0,0 +1,92 @@ +// std::messages implementation details, generic version -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/messages_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.7.1.2 messages virtual functions +// + +// Written by Benjamin Kosnik + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Non-virtual member functions. + template + messages<_CharT>::messages(size_t __refs) + : facet(__refs) + { _M_c_locale_messages = _S_get_c_locale(); } + + template + messages<_CharT>::messages(__c_locale, const char*, size_t __refs) + : facet(__refs) + { _M_c_locale_messages = _S_get_c_locale(); } + + template + typename messages<_CharT>::catalog + messages<_CharT>::open(const basic_string& __s, const locale& __loc, + const char*) const + { return this->do_open(__s, __loc); } + + // Virtual member functions. + template + messages<_CharT>::~messages() + { _S_destroy_c_locale(_M_c_locale_messages); } + + template + typename messages<_CharT>::catalog + messages<_CharT>::do_open(const basic_string&, const locale&) const + { return 0; } + + template + typename messages<_CharT>::string_type + messages<_CharT>::do_get(catalog, int, int, + const string_type& __dfault) const + { return __dfault; } + + template + void + messages<_CharT>::do_close(catalog) const + { } + + // messages_byname + template + messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) + : messages<_CharT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_messages); + this->_S_create_c_locale(this->_M_c_locale_messages, __s); + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/opt_random.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/opt_random.h new file mode 100755 index 0000000..7431cc6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/opt_random.h @@ -0,0 +1,38 @@ +// Optimizations for random number handling, generic version -*- C++ -*- + +// Copyright (C) 2012-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/opt_random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _BITS_OPT_RANDOM_H +#define _BITS_OPT_RANDOM_H 1 + +#pragma GCC system_header + + + + +#endif // _BITS_OPT_RANDOM_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/os_defines.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/os_defines.h new file mode 100755 index 0000000..d269c58 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/os_defines.h @@ -0,0 +1,41 @@ +// Specific definitions for generic platforms -*- C++ -*- + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/os_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _GLIBCXX_OS_DEFINES +#define _GLIBCXX_OS_DEFINES 1 + +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. + +// Disable the weak reference logic in gthr.h for os/generic because it +// is broken on every platform unless there is implementation specific +// workaround in gthr-posix.h and at link-time for static linking. +#define _GLIBCXX_GTHREAD_USE_WEAK 0 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/stdc++.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/stdc++.h new file mode 100755 index 0000000..d2601d7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/stdc++.h @@ -0,0 +1,153 @@ +// C++ includes used for precompiling -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file stdc++.h + * This is an implementation file for a precompiled header. + */ + +// 17.4.1.2 Headers + +// C +#ifndef _GLIBCXX_NO_ASSERT +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +// C++ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if __cplusplus >= 201402L +#include +#endif + +#if __cplusplus >= 201703L +#include +#include +// #include +#include +#include +#include +#include +#include +#endif + +#if __cplusplus > 201703L +#include +#include +#include +#include +#if __cpp_impl_coroutine +# include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/stdtr1c++.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/stdtr1c++.h new file mode 100755 index 0000000..1904620 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/stdtr1c++.h @@ -0,0 +1,53 @@ +// C++ includes used for precompiling TR1 -*- C++ -*- + +// Copyright (C) 2006-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file stdtr1c++.h + * This is an implementation file for a precompiled header. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/time_members.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/time_members.h new file mode 100755 index 0000000..39f7e23 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/bits/time_members.h @@ -0,0 +1,92 @@ +// std::time_get, std::time_put implementation, generic version -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/time_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.5.1.2 - time_get functions +// ISO C++ 14882: 22.2.5.3.2 - time_put functions +// + +// Written by Benjamin Kosnik + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + __timepunct<_CharT>::__timepunct(size_t __refs) + : facet(__refs), _M_data(0) + { + _M_name_timepunct = _S_get_c_name(); + _M_initialize_timepunct(); + } + + template + __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) + : facet(__refs), _M_data(__cache) + { + _M_name_timepunct = _S_get_c_name(); + _M_initialize_timepunct(); + } + + template + __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, + size_t __refs) + : facet(__refs), _M_data(0) + { + if (__builtin_strcmp(__s, _S_get_c_name()) != 0) + { + const size_t __len = __builtin_strlen(__s) + 1; + char* __tmp = new char[__len]; + __builtin_memcpy(__tmp, __s, __len); + _M_name_timepunct = __tmp; + } + else + _M_name_timepunct = _S_get_c_name(); + + __try + { _M_initialize_timepunct(__cloc); } + __catch(...) + { + if (_M_name_timepunct != _S_get_c_name()) + delete [] _M_name_timepunct; + __throw_exception_again; + } + } + + template + __timepunct<_CharT>::~__timepunct() + { + if (_M_name_timepunct != _S_get_c_name()) + delete [] _M_name_timepunct; + delete _M_data; + _S_destroy_c_locale(_M_c_locale_timepunct); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/ext/opt_random.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/ext/opt_random.h new file mode 100755 index 0000000..b381d57 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/armv7l-linux-musleabihf/ext/opt_random.h @@ -0,0 +1,38 @@ +// Optimizations for random number extensions, generic version -*- C++ -*- + +// Copyright (C) 2012-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ext/opt_random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ext/random} + */ + +#ifndef _EXT_OPT_RANDOM_H +#define _EXT_OPT_RANDOM_H 1 + +#pragma GCC system_header + + + + +#endif // _EXT_OPT_RANDOM_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/array b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/array new file mode 100755 index 0000000..0c6f33e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/array @@ -0,0 +1,461 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/array + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_ARRAY +#define _GLIBCXX_ARRAY 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + struct __array_traits + { + typedef _Tp _Type[_Nm]; + typedef __is_swappable<_Tp> _Is_swappable; + typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable; + + static constexpr _Tp& + _S_ref(const _Type& __t, std::size_t __n) noexcept + { return const_cast<_Tp&>(__t[__n]); } + + static constexpr _Tp* + _S_ptr(const _Type& __t) noexcept + { return const_cast<_Tp*>(__t); } + }; + + template + struct __array_traits<_Tp, 0> + { + struct _Type { }; + typedef true_type _Is_swappable; + typedef true_type _Is_nothrow_swappable; + + static constexpr _Tp& + _S_ref(const _Type&, std::size_t) noexcept + { return *static_cast<_Tp*>(nullptr); } + + static constexpr _Tp* + _S_ptr(const _Type&) noexcept + { return nullptr; } + }; + + /** + * @brief A standard container for storing a fixed size sequence of elements. + * + * @ingroup sequences + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence. + * + * Sets support random access iterators. + * + * @tparam Tp Type of element. Required to be a complete type. + * @tparam Nm Number of elements. + */ + template + struct array + { + typedef _Tp value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // Support for zero-sized arrays mandatory. + typedef __array_traits<_Tp, _Nm> _AT_Type; + typename _AT_Type::_Type _M_elems; + + // No explicit construct/copy/destroy for aggregate type. + + // DR 776. + _GLIBCXX20_CONSTEXPR void + fill(const value_type& __u) + { std::fill_n(begin(), size(), __u); } + + _GLIBCXX20_CONSTEXPR void + swap(array& __other) + noexcept(_AT_Type::_Is_nothrow_swappable::value) + { std::swap_ranges(begin(), end(), __other.begin()); } + + // Iterators. + _GLIBCXX17_CONSTEXPR iterator + begin() noexcept + { return iterator(data()); } + + _GLIBCXX17_CONSTEXPR const_iterator + begin() const noexcept + { return const_iterator(data()); } + + _GLIBCXX17_CONSTEXPR iterator + end() noexcept + { return iterator(data() + _Nm); } + + _GLIBCXX17_CONSTEXPR const_iterator + end() const noexcept + { return const_iterator(data() + _Nm); } + + _GLIBCXX17_CONSTEXPR reverse_iterator + rbegin() noexcept + { return reverse_iterator(end()); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + rbegin() const noexcept + { return const_reverse_iterator(end()); } + + _GLIBCXX17_CONSTEXPR reverse_iterator + rend() noexcept + { return reverse_iterator(begin()); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + rend() const noexcept + { return const_reverse_iterator(begin()); } + + _GLIBCXX17_CONSTEXPR const_iterator + cbegin() const noexcept + { return const_iterator(data()); } + + _GLIBCXX17_CONSTEXPR const_iterator + cend() const noexcept + { return const_iterator(data() + _Nm); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + _GLIBCXX17_CONSTEXPR const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } + + // Capacity. + constexpr size_type + size() const noexcept { return _Nm; } + + constexpr size_type + max_size() const noexcept { return _Nm; } + + _GLIBCXX_NODISCARD constexpr bool + empty() const noexcept { return size() == 0; } + + // Element access. + _GLIBCXX17_CONSTEXPR reference + operator[](size_type __n) noexcept + { + __glibcxx_requires_subscript(__n); + return _AT_Type::_S_ref(_M_elems, __n); + } + + constexpr const_reference + operator[](size_type __n) const noexcept + { +#if __cplusplus >= 201402L + __glibcxx_requires_subscript(__n); +#endif + return _AT_Type::_S_ref(_M_elems, __n); + } + + _GLIBCXX17_CONSTEXPR reference + at(size_type __n) + { + if (__n >= _Nm) + std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " + ">= _Nm (which is %zu)"), + __n, _Nm); + return _AT_Type::_S_ref(_M_elems, __n); + } + + constexpr const_reference + at(size_type __n) const + { + // Result of conditional expression must be an lvalue so use + // boolean ? lvalue : (throw-expr, lvalue) + return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n) + : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " + ">= _Nm (which is %zu)"), + __n, _Nm), + _AT_Type::_S_ref(_M_elems, 0)); + } + + _GLIBCXX17_CONSTEXPR reference + front() noexcept + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + constexpr const_reference + front() const noexcept + { +#if __cplusplus >= 201402L + __glibcxx_requires_nonempty(); +#endif + return _AT_Type::_S_ref(_M_elems, 0); + } + + _GLIBCXX17_CONSTEXPR reference + back() noexcept + { + __glibcxx_requires_nonempty(); + return _Nm ? *(end() - 1) : *end(); + } + + constexpr const_reference + back() const noexcept + { +#if __cplusplus >= 201402L + __glibcxx_requires_nonempty(); +#endif + return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) + : _AT_Type::_S_ref(_M_elems, 0); + } + + _GLIBCXX17_CONSTEXPR pointer + data() noexcept + { return _AT_Type::_S_ptr(_M_elems); } + + _GLIBCXX17_CONSTEXPR const_pointer + data() const noexcept + { return _AT_Type::_S_ptr(_M_elems); } + }; + +#if __cpp_deduction_guides >= 201606 + template + array(_Tp, _Up...) + -> array && ...), _Tp>, + 1 + sizeof...(_Up)>; +#endif + + // Array comparisons. + template + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return std::equal(__one.begin(), __one.end(), __two.begin()); } + +#if __cpp_lib_three_way_comparison && __cpp_lib_concepts + template + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { +#ifdef __cpp_lib_is_constant_evaluated + if constexpr (_Nm && __is_memcmp_ordered<_Tp>::__value) + if (!std::is_constant_evaluated()) + { + constexpr size_t __n = _Nm * sizeof(_Tp); + return __builtin_memcmp(__a.data(), __b.data(), __n) <=> 0; + } +#endif + + for (size_t __i = 0; __i < _Nm; ++__i) + { + auto __c = __detail::__synth3way(__a[__i], __b[__i]); + if (__c != 0) + return __c; + } + return strong_ordering::equal; + } +#else + template + _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one == __two); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) + { + return std::lexicographical_compare(__a.begin(), __a.end(), + __b.begin(), __b.end()); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return __two < __one; } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one > __two); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) + { return !(__one < __two); } +#endif // three_way_comparison && concepts + + // Specialized algorithms. + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if< + __array_traits<_Tp, _Nm>::_Is_swappable::value + >::type +#else + void +#endif + swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) + noexcept(noexcept(__one.swap(__two))) + { __one.swap(__two); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if< + !__array_traits<_Tp, _Nm>::_Is_swappable::value>::type + swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; +#endif + + template + constexpr _Tp& + get(array<_Tp, _Nm>& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return __array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int); + } + + template + constexpr _Tp&& + get(array<_Tp, _Nm>&& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return std::move(std::get<_Int>(__arr)); + } + + template + constexpr const _Tp& + get(const array<_Tp, _Nm>& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return __array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int); + } + + template + constexpr const _Tp&& + get(const array<_Tp, _Nm>&& __arr) noexcept + { + static_assert(_Int < _Nm, "array index is within bounds"); + return std::move(std::get<_Int>(__arr)); + } + +#if __cplusplus > 201703L +#define __cpp_lib_to_array 201907L + + template + constexpr array, sizeof...(_Idx)> + __to_array(_Tp (&__a)[sizeof...(_Idx)], index_sequence<_Idx...>) + { + if constexpr (_Move) + return {{std::move(__a[_Idx])...}}; + else + return {{__a[_Idx]...}}; + } + + template + constexpr array, _Nm> + to_array(_Tp (&__a)[_Nm]) + noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) + { + static_assert(!is_array_v<_Tp>); + static_assert(is_constructible_v<_Tp, _Tp&>); + if constexpr (is_constructible_v<_Tp, _Tp&>) + return __to_array(__a, make_index_sequence<_Nm>{}); + __builtin_unreachable(); // FIXME: see PR c++/91388 + } + + template + constexpr array, _Nm> + to_array(_Tp (&&__a)[_Nm]) + noexcept(is_nothrow_move_constructible_v<_Tp>) + { + static_assert(!is_array_v<_Tp>); + static_assert(is_move_constructible_v<_Tp>); + if constexpr (is_move_constructible_v<_Tp>) + return __to_array<1>(__a, make_index_sequence<_Nm>{}); + __builtin_unreachable(); // FIXME: see PR c++/91388 + } +#endif // C++20 + + // Tuple interface to class template array. + + /// tuple_size + template + struct tuple_size; + + /// Partial specialization for std::array + template + struct tuple_size> + : public integral_constant { }; + + /// tuple_element + template + struct tuple_element; + + /// Partial specialization for std::array + template + struct tuple_element<_Int, array<_Tp, _Nm>> + { + static_assert(_Int < _Nm, "index is out of bounds"); + typedef _Tp type; + }; + + template + struct __is_tuple_like_impl> : true_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_ARRAY diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/atomic b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/atomic new file mode 100755 index 0000000..9b1fb15 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/atomic @@ -0,0 +1,1640 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/atomic + * This is a Standard C++ Library header. + */ + +// Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl. +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html + +#ifndef _GLIBCXX_ATOMIC +#define _GLIBCXX_ATOMIC 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup atomics + * @{ + */ + +#if __cplusplus >= 201703L +# define __cpp_lib_atomic_is_always_lock_free 201603 +#endif + + template + struct atomic; + + /// atomic + // NB: No operators or fetch-operations for this type. + template<> + struct atomic + { + using value_type = bool; + + private: + __atomic_base _M_base; + + public: + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(bool __i) noexcept : _M_base(__i) { } + + bool + operator=(bool __i) noexcept + { return _M_base.operator=(__i); } + + bool + operator=(bool __i) volatile noexcept + { return _M_base.operator=(__i); } + + operator bool() const noexcept + { return _M_base.load(); } + + operator bool() const volatile noexcept + { return _M_base.load(); } + + bool + is_lock_free() const noexcept { return _M_base.is_lock_free(); } + + bool + is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); } + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_BOOL_LOCK_FREE == 2; +#endif + + void + store(bool __i, memory_order __m = memory_order_seq_cst) noexcept + { _M_base.store(__i, __m); } + + void + store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept + { _M_base.store(__i, __m); } + + bool + load(memory_order __m = memory_order_seq_cst) const noexcept + { return _M_base.load(__m); } + + bool + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { return _M_base.load(__m); } + + bool + exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept + { return _M_base.exchange(__i, __m); } + + bool + exchange(bool __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_base.exchange(__i, __m); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m); } + + bool + compare_exchange_weak(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_base.compare_exchange_weak(__i1, __i2, __m); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m); } + + bool + compare_exchange_strong(bool& __i1, bool __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_base.compare_exchange_strong(__i1, __i2, __m); } + +#if __cpp_lib_atomic_wait + void + wait(bool __old, memory_order __m = memory_order_seq_cst) const noexcept + { _M_base.wait(__old, __m); } + + // TODO add const volatile overload + + void + notify_one() const noexcept + { _M_base.notify_one(); } + + void + notify_all() const noexcept + { _M_base.notify_all(); } +#endif // __cpp_lib_atomic_wait + }; + +#if __cplusplus <= 201703L +# define _GLIBCXX20_INIT(I) +#else +# define _GLIBCXX20_INIT(I) = I +#endif + + /** + * @brief Generic atomic type, primary class template. + * + * @tparam _Tp Type to be made atomic, must be trivially copyable. + */ + template + struct atomic + { + using value_type = _Tp; + + private: + // Align 1/2/4/8/16-byte types to at least their size. + static constexpr int _S_min_alignment + = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || sizeof(_Tp) > 16 + ? 0 : sizeof(_Tp); + + static constexpr int _S_alignment + = _S_min_alignment > alignof(_Tp) ? _S_min_alignment : alignof(_Tp); + + alignas(_S_alignment) _Tp _M_i _GLIBCXX20_INIT(_Tp()); + + static_assert(__is_trivially_copyable(_Tp), + "std::atomic requires a trivially copyable type"); + + static_assert(sizeof(_Tp) > 0, + "Incomplete or zero-sized types are not supported"); + +#if __cplusplus > 201703L + static_assert(is_copy_constructible_v<_Tp>); + static_assert(is_move_constructible_v<_Tp>); + static_assert(is_copy_assignable_v<_Tp>); + static_assert(is_move_assignable_v<_Tp>); +#endif + + public: + atomic() = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(_Tp __i) noexcept : _M_i(__i) { } + + operator _Tp() const noexcept + { return load(); } + + operator _Tp() const volatile noexcept + { return load(); } + + _Tp + operator=(_Tp __i) noexcept + { store(__i); return __i; } + + _Tp + operator=(_Tp __i) volatile noexcept + { store(__i); return __i; } + + bool + is_lock_free() const noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + + bool + is_lock_free() const volatile noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_M_i), 0); +#endif + + void + store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept + { + __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); + } + + void + store(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept + { + __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); + } + + _Tp + load(memory_order __m = memory_order_seq_cst) const noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_load(std::__addressof(_M_i), __ptr, int(__m)); + return *__ptr; + } + + _Tp + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_load(std::__addressof(_M_i), __ptr, int(__m)); + return *__ptr; + } + + _Tp + exchange(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), + __ptr, int(__m)); + return *__ptr; + } + + _Tp + exchange(_Tp __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); + __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), + __ptr, int(__m)); + return *__ptr; + } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) noexcept + { + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + true, int(__s), int(__f)); + } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) volatile noexcept + { + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + true, int(__s), int(__f)); + } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) noexcept + { return compare_exchange_weak(__e, __i, __m, + __cmpexch_failure_order(__m)); } + + bool + compare_exchange_weak(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return compare_exchange_weak(__e, __i, __m, + __cmpexch_failure_order(__m)); } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) noexcept + { + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + false, int(__s), int(__f)); + } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, + memory_order __f) volatile noexcept + { + return __atomic_compare_exchange(std::__addressof(_M_i), + std::__addressof(__e), + std::__addressof(__i), + false, int(__s), int(__f)); + } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) noexcept + { return compare_exchange_strong(__e, __i, __m, + __cmpexch_failure_order(__m)); } + + bool + compare_exchange_strong(_Tp& __e, _Tp __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return compare_exchange_strong(__e, __i, __m, + __cmpexch_failure_order(__m)); } + +#if __cpp_lib_atomic_wait + void + wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept + { + std::__atomic_wait_address_v(&_M_i, __old, + [__m, this] { return this->load(__m); }); + } + + // TODO add const volatile overload + + void + notify_one() const noexcept + { std::__atomic_notify_address(&_M_i, false); } + + void + notify_all() const noexcept + { std::__atomic_notify_address(&_M_i, true); } +#endif // __cpp_lib_atomic_wait + + }; +#undef _GLIBCXX20_INIT + + /// Partial specialization for pointer types. + template + struct atomic<_Tp*> + { + using value_type = _Tp*; + using difference_type = ptrdiff_t; + + typedef _Tp* __pointer_type; + typedef __atomic_base<_Tp*> __base_type; + __base_type _M_b; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { } + + operator __pointer_type() const noexcept + { return __pointer_type(_M_b); } + + operator __pointer_type() const volatile noexcept + { return __pointer_type(_M_b); } + + __pointer_type + operator=(__pointer_type __p) noexcept + { return _M_b.operator=(__p); } + + __pointer_type + operator=(__pointer_type __p) volatile noexcept + { return _M_b.operator=(__p); } + + __pointer_type + operator++(int) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b++; + } + + __pointer_type + operator++(int) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b++; + } + + __pointer_type + operator--(int) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b--; + } + + __pointer_type + operator--(int) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b--; + } + + __pointer_type + operator++() noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return ++_M_b; + } + + __pointer_type + operator++() volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return ++_M_b; + } + + __pointer_type + operator--() noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return --_M_b; + } + + __pointer_type + operator--() volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return --_M_b; + } + + __pointer_type + operator+=(ptrdiff_t __d) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator+=(__d); + } + + __pointer_type + operator+=(ptrdiff_t __d) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator+=(__d); + } + + __pointer_type + operator-=(ptrdiff_t __d) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator-=(__d); + } + + __pointer_type + operator-=(ptrdiff_t __d) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.operator-=(__d); + } + + bool + is_lock_free() const noexcept + { return _M_b.is_lock_free(); } + + bool + is_lock_free() const volatile noexcept + { return _M_b.is_lock_free(); } + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_POINTER_LOCK_FREE == 2; +#endif + + void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_b.store(__p, __m); } + + void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_b.store(__p, __m); } + + __pointer_type + load(memory_order __m = memory_order_seq_cst) const noexcept + { return _M_b.load(__m); } + + __pointer_type + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { return _M_b.load(__m); } + + __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { return _M_b.exchange(__p, __m); } + + __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return _M_b.exchange(__p, __m); } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, memory_order __m2) noexcept + { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) noexcept + { + return compare_exchange_weak(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + + bool + compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return compare_exchange_weak(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, memory_order __m2) noexcept + { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) noexcept + { + return _M_b.compare_exchange_strong(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + + bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return _M_b.compare_exchange_strong(__p1, __p2, __m, + __cmpexch_failure_order(__m)); + } + +#if __cpp_lib_atomic_wait + void + wait(__pointer_type __old, memory_order __m = memory_order_seq_cst) noexcept + { _M_b.wait(__old, __m); } + + // TODO add const volatile overload + + void + notify_one() const noexcept + { _M_b.notify_one(); } + + void + notify_all() const noexcept + { _M_b.notify_all(); } +#endif // __cpp_lib_atomic_wait + __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_add(__d, __m); + } + + __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_add(__d, __m); + } + + __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_sub(__d, __m); + } + + __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { +#if __cplusplus >= 201703L + static_assert( is_object<_Tp>::value, "pointer to object type" ); +#endif + return _M_b.fetch_sub(__d, __m); + } + }; + + + /// Explicit specialization for char. + template<> + struct atomic : __atomic_base + { + typedef char __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for signed char. + template<> + struct atomic : __atomic_base + { + typedef signed char __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept= default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned char. + template<> + struct atomic : __atomic_base + { + typedef unsigned char __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept= default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for short. + template<> + struct atomic : __atomic_base + { + typedef short __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned short. + template<> + struct atomic : __atomic_base + { + typedef unsigned short __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for int. + template<> + struct atomic : __atomic_base + { + typedef int __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned int. + template<> + struct atomic : __atomic_base + { + typedef unsigned int __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for long. + template<> + struct atomic : __atomic_base + { + typedef long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned long. + template<> + struct atomic : __atomic_base + { + typedef unsigned long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for long long. + template<> + struct atomic : __atomic_base + { + typedef long long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for unsigned long long. + template<> + struct atomic : __atomic_base + { + typedef unsigned long long __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for wchar_t. + template<> + struct atomic : __atomic_base + { + typedef wchar_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2; +#endif + }; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// Explicit specialization for char8_t. + template<> + struct atomic : __atomic_base + { + typedef char8_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus > 201402L + static constexpr bool is_always_lock_free = ATOMIC_CHAR8_T_LOCK_FREE == 2; +#endif + }; +#endif + + /// Explicit specialization for char16_t. + template<> + struct atomic : __atomic_base + { + typedef char16_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR16_T_LOCK_FREE == 2; +#endif + }; + + /// Explicit specialization for char32_t. + template<> + struct atomic : __atomic_base + { + typedef char32_t __integral_type; + typedef __atomic_base __base_type; + + atomic() noexcept = default; + ~atomic() noexcept = default; + atomic(const atomic&) = delete; + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; + + constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { } + + using __base_type::operator __integral_type; + using __base_type::operator=; + +#if __cplusplus >= 201703L + static constexpr bool is_always_lock_free = ATOMIC_CHAR32_T_LOCK_FREE == 2; +#endif + }; + + + /// atomic_bool + typedef atomic atomic_bool; + + /// atomic_char + typedef atomic atomic_char; + + /// atomic_schar + typedef atomic atomic_schar; + + /// atomic_uchar + typedef atomic atomic_uchar; + + /// atomic_short + typedef atomic atomic_short; + + /// atomic_ushort + typedef atomic atomic_ushort; + + /// atomic_int + typedef atomic atomic_int; + + /// atomic_uint + typedef atomic atomic_uint; + + /// atomic_long + typedef atomic atomic_long; + + /// atomic_ulong + typedef atomic atomic_ulong; + + /// atomic_llong + typedef atomic atomic_llong; + + /// atomic_ullong + typedef atomic atomic_ullong; + + /// atomic_wchar_t + typedef atomic atomic_wchar_t; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// atomic_char8_t + typedef atomic atomic_char8_t; +#endif + + /// atomic_char16_t + typedef atomic atomic_char16_t; + + /// atomic_char32_t + typedef atomic atomic_char32_t; + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2441. Exact-width atomic typedefs should be provided + + /// atomic_int8_t + typedef atomic atomic_int8_t; + + /// atomic_uint8_t + typedef atomic atomic_uint8_t; + + /// atomic_int16_t + typedef atomic atomic_int16_t; + + /// atomic_uint16_t + typedef atomic atomic_uint16_t; + + /// atomic_int32_t + typedef atomic atomic_int32_t; + + /// atomic_uint32_t + typedef atomic atomic_uint32_t; + + /// atomic_int64_t + typedef atomic atomic_int64_t; + + /// atomic_uint64_t + typedef atomic atomic_uint64_t; + + + /// atomic_int_least8_t + typedef atomic atomic_int_least8_t; + + /// atomic_uint_least8_t + typedef atomic atomic_uint_least8_t; + + /// atomic_int_least16_t + typedef atomic atomic_int_least16_t; + + /// atomic_uint_least16_t + typedef atomic atomic_uint_least16_t; + + /// atomic_int_least32_t + typedef atomic atomic_int_least32_t; + + /// atomic_uint_least32_t + typedef atomic atomic_uint_least32_t; + + /// atomic_int_least64_t + typedef atomic atomic_int_least64_t; + + /// atomic_uint_least64_t + typedef atomic atomic_uint_least64_t; + + + /// atomic_int_fast8_t + typedef atomic atomic_int_fast8_t; + + /// atomic_uint_fast8_t + typedef atomic atomic_uint_fast8_t; + + /// atomic_int_fast16_t + typedef atomic atomic_int_fast16_t; + + /// atomic_uint_fast16_t + typedef atomic atomic_uint_fast16_t; + + /// atomic_int_fast32_t + typedef atomic atomic_int_fast32_t; + + /// atomic_uint_fast32_t + typedef atomic atomic_uint_fast32_t; + + /// atomic_int_fast64_t + typedef atomic atomic_int_fast64_t; + + /// atomic_uint_fast64_t + typedef atomic atomic_uint_fast64_t; +#endif + + + /// atomic_intptr_t + typedef atomic atomic_intptr_t; + + /// atomic_uintptr_t + typedef atomic atomic_uintptr_t; + + /// atomic_size_t + typedef atomic atomic_size_t; + + /// atomic_ptrdiff_t + typedef atomic atomic_ptrdiff_t; + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + /// atomic_intmax_t + typedef atomic atomic_intmax_t; + + /// atomic_uintmax_t + typedef atomic atomic_uintmax_t; +#endif + + // Function definitions, atomic_flag operations. + inline bool + atomic_flag_test_and_set_explicit(atomic_flag* __a, + memory_order __m) noexcept + { return __a->test_and_set(__m); } + + inline bool + atomic_flag_test_and_set_explicit(volatile atomic_flag* __a, + memory_order __m) noexcept + { return __a->test_and_set(__m); } + + inline void + atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept + { __a->clear(__m); } + + inline void + atomic_flag_clear_explicit(volatile atomic_flag* __a, + memory_order __m) noexcept + { __a->clear(__m); } + + inline bool + atomic_flag_test_and_set(atomic_flag* __a) noexcept + { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } + + inline bool + atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept + { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); } + + inline void + atomic_flag_clear(atomic_flag* __a) noexcept + { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } + + inline void + atomic_flag_clear(volatile atomic_flag* __a) noexcept + { atomic_flag_clear_explicit(__a, memory_order_seq_cst); } + + + template + using __atomic_val_t = typename atomic<_Tp>::value_type; + template + using __atomic_diff_t = typename atomic<_Tp>::difference_type; + + // [atomics.nonmembers] Non-member functions. + // Function templates generally applicable to atomic types. + template + inline bool + atomic_is_lock_free(const atomic<_ITp>* __a) noexcept + { return __a->is_lock_free(); } + + template + inline bool + atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept + { return __a->is_lock_free(); } + + template + inline void + atomic_init(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { __a->store(__i, memory_order_relaxed); } + + template + inline void + atomic_init(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { __a->store(__i, memory_order_relaxed); } + + template + inline void + atomic_store_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { __a->store(__i, __m); } + + template + inline void + atomic_store_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { __a->store(__i, __m); } + + template + inline _ITp + atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept + { return __a->load(__m); } + + template + inline _ITp + atomic_load_explicit(const volatile atomic<_ITp>* __a, + memory_order __m) noexcept + { return __a->load(__m); } + + template + inline _ITp + atomic_exchange_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->exchange(__i, __m); } + + template + inline _ITp + atomic_exchange_explicit(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->exchange(__i, __m); } + + template + inline bool + atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } + + template + inline bool + atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); } + + template + inline bool + atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } + + template + inline bool + atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2, + memory_order __m1, + memory_order __m2) noexcept + { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); } + + + template + inline void + atomic_store(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { atomic_store_explicit(__a, __i, memory_order_seq_cst); } + + template + inline void + atomic_store(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { atomic_store_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_load(const atomic<_ITp>* __a) noexcept + { return atomic_load_explicit(__a, memory_order_seq_cst); } + + template + inline _ITp + atomic_load(const volatile atomic<_ITp>* __a) noexcept + { return atomic_load_explicit(__a, memory_order_seq_cst); } + + template + inline _ITp + atomic_exchange(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept + { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_exchange(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); } + + template + inline bool + atomic_compare_exchange_weak(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_weak(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_weak_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_strong(atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_strong(volatile atomic<_ITp>* __a, + __atomic_val_t<_ITp>* __i1, + __atomic_val_t<_ITp> __i2) noexcept + { + return atomic_compare_exchange_strong_explicit(__a, __i1, __i2, + memory_order_seq_cst, + memory_order_seq_cst); + } + + +#if __cpp_lib_atomic_wait + template + inline void + atomic_wait(const atomic<_Tp>* __a, + typename std::atomic<_Tp>::value_type __old) noexcept + { __a->wait(__old); } + + template + inline void + atomic_wait_explicit(const atomic<_Tp>* __a, + typename std::atomic<_Tp>::value_type __old, + std::memory_order __m) noexcept + { __a->wait(__old, __m); } + + template + inline void + atomic_notify_one(atomic<_Tp>* __a) noexcept + { __a->notify_one(); } + + template + inline void + atomic_notify_all(atomic<_Tp>* __a) noexcept + { __a->notify_all(); } +#endif // __cpp_lib_atomic_wait + + // Function templates for atomic_integral and atomic_pointer operations only. + // Some operations (and, or, xor) are only available for atomic integrals, + // which is implemented by taking a parameter of type __atomic_base<_ITp>*. + + template + inline _ITp + atomic_fetch_add_explicit(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_add(__i, __m); } + + template + inline _ITp + atomic_fetch_add_explicit(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_add(__i, __m); } + + template + inline _ITp + atomic_fetch_sub_explicit(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_sub(__i, __m); } + + template + inline _ITp + atomic_fetch_sub_explicit(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_sub(__i, __m); } + + template + inline _ITp + atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_and(__i, __m); } + + template + inline _ITp + atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_and(__i, __m); } + + template + inline _ITp + atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_or(__i, __m); } + + template + inline _ITp + atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_or(__i, __m); } + + template + inline _ITp + atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_xor(__i, __m); } + + template + inline _ITp + atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i, + memory_order __m) noexcept + { return __a->fetch_xor(__i, __m); } + + template + inline _ITp + atomic_fetch_add(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_add(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_sub(atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_sub(volatile atomic<_ITp>* __a, + __atomic_diff_t<_ITp> __i) noexcept + { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_and(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_and(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_or(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_or(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_xor(__atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } + + template + inline _ITp + atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, + __atomic_val_t<_ITp> __i) noexcept + { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); } + +#if __cplusplus > 201703L +#define __cpp_lib_atomic_float 201711L + template<> + struct atomic : __atomic_float + { + atomic() noexcept = default; + + constexpr + atomic(float __fp) noexcept : __atomic_float(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float::operator=; + }; + + template<> + struct atomic : __atomic_float + { + atomic() noexcept = default; + + constexpr + atomic(double __fp) noexcept : __atomic_float(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float::operator=; + }; + + template<> + struct atomic : __atomic_float + { + atomic() noexcept = default; + + constexpr + atomic(long double __fp) noexcept : __atomic_float(__fp) + { } + + atomic& operator=(const atomic&) volatile = delete; + atomic& operator=(const atomic&) = delete; + + using __atomic_float::operator=; + }; + +#define __cpp_lib_atomic_ref 201806L + + /// Class template to provide atomic operations on a non-atomic variable. + template + struct atomic_ref : __atomic_ref<_Tp> + { + explicit + atomic_ref(_Tp& __t) noexcept : __atomic_ref<_Tp>(__t) + { } + + atomic_ref& operator=(const atomic_ref&) = delete; + + atomic_ref(const atomic_ref&) = default; + + using __atomic_ref<_Tp>::operator=; + }; + +#endif // C++2a + + /// @} group atomics + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _GLIBCXX_ATOMIC diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/auto_ptr.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/auto_ptr.h new file mode 100755 index 0000000..abd065a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/auto_ptr.h @@ -0,0 +1,337 @@ +// auto_ptr implementation -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file backward/auto_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _BACKWARD_AUTO_PTR_H +#define _BACKWARD_AUTO_PTR_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * A wrapper class to provide auto_ptr with reference semantics. + * For example, an auto_ptr can be assigned (or constructed from) + * the result of a function which returns an auto_ptr by value. + * + * All the auto_ptr_ref stuff should happen behind the scenes. + */ + template + struct auto_ptr_ref + { + _Tp1* _M_ptr; + + explicit + auto_ptr_ref(_Tp1* __p): _M_ptr(__p) { } + } _GLIBCXX11_DEPRECATED; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + + /** + * @brief A simple smart pointer providing strict ownership semantics. + * + * The Standard says: + *
+   *  An @c auto_ptr owns the object it holds a pointer to.  Copying
+   *  an @c auto_ptr copies the pointer and transfers ownership to the
+   *  destination.  If more than one @c auto_ptr owns the same object
+   *  at the same time the behavior of the program is undefined.
+   *
+   *  The uses of @c auto_ptr include providing temporary
+   *  exception-safety for dynamically allocated memory, passing
+   *  ownership of dynamically allocated memory to a function, and
+   *  returning dynamically allocated memory from a function.  @c
+   *  auto_ptr does not meet the CopyConstructible and Assignable
+   *  requirements for Standard Library container elements and thus
+   *  instantiating a Standard Library container with an @c auto_ptr
+   *  results in undefined behavior.
+   *  
+ * Quoted from [20.4.5]/3. + * + * Good examples of what can and cannot be done with auto_ptr can + * be found in the libstdc++ testsuite. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * 127. auto_ptr<> conversion issues + * These resolutions have all been incorporated. + */ + template + class auto_ptr + { + private: + _Tp* _M_ptr; + + public: + /// The pointed-to type. + typedef _Tp element_type; + + /** + * @brief An %auto_ptr is usually constructed from a raw pointer. + * @param __p A pointer (defaults to NULL). + * + * This object now @e owns the object pointed to by @a __p. + */ + explicit + auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { } + + /** + * @brief An %auto_ptr can be constructed from another %auto_ptr. + * @param __a Another %auto_ptr of the same type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. + */ + auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { } + + /** + * @brief An %auto_ptr can be constructed from another %auto_ptr. + * @param __a Another %auto_ptr of a different but related type. + * + * A pointer-to-Tp1 must be convertible to a + * pointer-to-Tp/element_type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. + */ + template + auto_ptr(auto_ptr<_Tp1>& __a) throw() : _M_ptr(__a.release()) { } + + /** + * @brief %auto_ptr assignment operator. + * @param __a Another %auto_ptr of the same type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. The object that this one @e + * used to own and track has been deleted. + */ + auto_ptr& + operator=(auto_ptr& __a) throw() + { + reset(__a.release()); + return *this; + } + + /** + * @brief %auto_ptr assignment operator. + * @param __a Another %auto_ptr of a different but related type. + * + * A pointer-to-Tp1 must be convertible to a pointer-to-Tp/element_type. + * + * This object now @e owns the object previously owned by @a __a, + * which has given up ownership. The object that this one @e + * used to own and track has been deleted. + */ + template + auto_ptr& + operator=(auto_ptr<_Tp1>& __a) throw() + { + reset(__a.release()); + return *this; + } + + /** + * When the %auto_ptr goes out of scope, the object it owns is + * deleted. If it no longer owns anything (i.e., @c get() is + * @c NULL), then this has no effect. + * + * The C++ standard says there is supposed to be an empty throw + * specification here, but omitting it is standard conforming. Its + * presence can be detected only if _Tp::~_Tp() throws, but this is + * prohibited. [17.4.3.6]/2 + */ + ~auto_ptr() { delete _M_ptr; } + + /** + * @brief Smart pointer dereferencing. + * + * If this %auto_ptr no longer owns anything, then this + * operation will crash. (For a smart pointer, no longer owns + * anything is the same as being a null pointer, and you know + * what happens when you dereference one of those...) + */ + element_type& + operator*() const throw() + { + __glibcxx_assert(_M_ptr != 0); + return *_M_ptr; + } + + /** + * @brief Smart pointer dereferencing. + * + * This returns the pointer itself, which the language then will + * automatically cause to be dereferenced. + */ + element_type* + operator->() const throw() + { + __glibcxx_assert(_M_ptr != 0); + return _M_ptr; + } + + /** + * @brief Bypassing the smart pointer. + * @return The raw pointer being managed. + * + * You can get a copy of the pointer that this object owns, for + * situations such as passing to a function which only accepts + * a raw pointer. + * + * @note This %auto_ptr still owns the memory. + */ + element_type* + get() const throw() { return _M_ptr; } + + /** + * @brief Bypassing the smart pointer. + * @return The raw pointer being managed. + * + * You can get a copy of the pointer that this object owns, for + * situations such as passing to a function which only accepts + * a raw pointer. + * + * @note This %auto_ptr no longer owns the memory. When this object + * goes out of scope, nothing will happen. + */ + element_type* + release() throw() + { + element_type* __tmp = _M_ptr; + _M_ptr = 0; + return __tmp; + } + + /** + * @brief Forcibly deletes the managed object. + * @param __p A pointer (defaults to NULL). + * + * This object now @e owns the object pointed to by @a __p. The + * previous object has been deleted. + */ + void + reset(element_type* __p = 0) throw() + { + if (__p != _M_ptr) + { + delete _M_ptr; + _M_ptr = __p; + } + } + + /** + * @brief Automatic conversions + * + * These operations are supposed to convert an %auto_ptr into and from + * an auto_ptr_ref automatically as needed. This would allow + * constructs such as + * @code + * auto_ptr func_returning_auto_ptr(.....); + * ... + * auto_ptr ptr = func_returning_auto_ptr(.....); + * @endcode + * + * But it doesn't work, and won't be fixed. For further details see + * http://cplusplus.github.io/LWG/lwg-closed.html#463 + */ + auto_ptr(auto_ptr_ref __ref) throw() + : _M_ptr(__ref._M_ptr) { } + + auto_ptr& + operator=(auto_ptr_ref __ref) throw() + { + if (__ref._M_ptr != this->get()) + { + delete _M_ptr; + _M_ptr = __ref._M_ptr; + } + return *this; + } + + template + operator auto_ptr_ref<_Tp1>() throw() + { return auto_ptr_ref<_Tp1>(this->release()); } + + template + operator auto_ptr<_Tp1>() throw() + { return auto_ptr<_Tp1>(this->release()); } + } _GLIBCXX11_DEPRECATED_SUGGEST("std::unique_ptr"); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 541. shared_ptr template assignment and void + template<> + class auto_ptr + { + public: + typedef void element_type; + } _GLIBCXX11_DEPRECATED; + +#if __cplusplus >= 201103L + template<_Lock_policy _Lp> + template + inline + __shared_count<_Lp>::__shared_count(std::auto_ptr<_Tp>&& __r) + : _M_pi(new _Sp_counted_ptr<_Tp*, _Lp>(__r.get())) + { __r.release(); } + + template + template + inline + __shared_ptr<_Tp, _Lp>::__shared_ptr(std::auto_ptr<_Tp1>&& __r) + : _M_ptr(__r.get()), _M_refcount() + { + __glibcxx_function_requires(_ConvertibleConcept<_Tp1*, _Tp*>) + static_assert( sizeof(_Tp1) > 0, "incomplete type" ); + _Tp1* __tmp = __r.get(); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + _M_enable_shared_from_this_with(__tmp); + } + + template + template + inline + shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r) + : __shared_ptr<_Tp>(std::move(__r)) { } + + template + template + inline + unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept + : _M_t(__u.release(), deleter_type()) { } +#endif + +#pragma GCC diagnostic pop + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _BACKWARD_AUTO_PTR_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/backward_warning.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/backward_warning.h new file mode 100755 index 0000000..eec07f1 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/backward_warning.h @@ -0,0 +1,60 @@ +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file backward/backward_warning.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _BACKWARD_BACKWARD_WARNING_H +#define _BACKWARD_BACKWARD_WARNING_H 1 + +#ifdef __DEPRECATED +#warning \ + This file includes at least one deprecated or antiquated header which \ + may be removed without further notice at a future date. Please use a \ + non-deprecated interface with equivalent functionality instead. For a \ + listing of replacement headers and interfaces, consult the file \ + backward_warning.h. To disable this warning use -Wno-deprecated. + +/* + A list of valid replacements is as follows: + + Use: Instead of: + , basic_stringbuf , strstreambuf + , basic_istringstream , istrstream + , basic_ostringstream , ostrstream + , basic_stringstream , strstream + , unordered_set , hash_set + , unordered_multiset , hash_multiset + , unordered_map , hash_map + , unordered_multimap , hash_multimap + , bind , binder1st + , bind , binder2nd + , bind , bind1st + , bind , bind2nd + , unique_ptr , auto_ptr +*/ + +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/binders.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/binders.h new file mode 100755 index 0000000..c586600 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/binders.h @@ -0,0 +1,182 @@ +// Functor implementations -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file backward/binders.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _BACKWARD_BINDERS_H +#define _BACKWARD_BINDERS_H 1 + +// Suppress deprecated warning for this file. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 20.3.6 binders + /** @defgroup binders Binder Classes + * @ingroup functors + * + * Binders turn functions/functors with two arguments into functors + * with a single argument, storing an argument to be applied later. + * For example, a variable @c B of type @c binder1st is constructed + * from a functor @c f and an argument @c x. Later, B's @c + * operator() is called with a single argument @c y. The return + * value is the value of @c f(x,y). @c B can be @a called with + * various arguments (y1, y2, ...) and will in turn call @c + * f(x,y1), @c f(x,y2), ... + * + * The function @c bind1st is provided to save some typing. It takes the + * function and an argument as parameters, and returns an instance of + * @c binder1st. + * + * The type @c binder2nd and its creator function @c bind2nd do the same + * thing, but the stored argument is passed as the second parameter instead + * of the first, e.g., @c bind2nd(std::minus(),1.3) will create a + * functor whose @c operator() accepts a floating-point number, subtracts + * 1.3 from it, and returns the result. (If @c bind1st had been used, + * the functor would perform 1.3 - x instead. + * + * Creator-wrapper functions like @c bind1st are intended to be used in + * calling algorithms. Their return values will be temporary objects. + * (The goal is to not require you to type names like + * @c std::binder1st> for declaring a variable to hold the + * return value from @c bind1st(std::plus(),5). + * + * These become more useful when combined with the composition functions. + * + * These functions are deprecated in C++11 and can be replaced by + * @c std::bind (or @c std::tr1::bind) which is more powerful and flexible, + * supporting functions with any number of arguments. Uses of @c bind1st + * can be replaced by @c std::bind(f, x, std::placeholders::_1) and + * @c bind2nd by @c std::bind(f, std::placeholders::_1, x). + * @{ + */ + /// One of the @link binders binder functors@endlink. + template + class binder1st + : public unary_function + { + protected: + _Operation op; + typename _Operation::first_argument_type value; + + public: + binder1st(const _Operation& __x, + const typename _Operation::first_argument_type& __y) + : op(__x), value(__y) { } + + typename _Operation::result_type + operator()(const typename _Operation::second_argument_type& __x) const + { return op(value, __x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 109. Missing binders for non-const sequence elements + typename _Operation::result_type + operator()(typename _Operation::second_argument_type& __x) const + { return op(value, __x); } + } _GLIBCXX11_DEPRECATED_SUGGEST("std::bind"); + + /// One of the @link binders binder functors@endlink. + template + inline binder1st<_Operation> + bind1st(const _Operation& __fn, const _Tp& __x) + { + typedef typename _Operation::first_argument_type _Arg1_type; + return binder1st<_Operation>(__fn, _Arg1_type(__x)); + } + + /// One of the @link binders binder functors@endlink. + template + class binder2nd + : public unary_function + { + protected: + _Operation op; + typename _Operation::second_argument_type value; + + public: + binder2nd(const _Operation& __x, + const typename _Operation::second_argument_type& __y) + : op(__x), value(__y) { } + + typename _Operation::result_type + operator()(const typename _Operation::first_argument_type& __x) const + { return op(__x, value); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 109. Missing binders for non-const sequence elements + typename _Operation::result_type + operator()(typename _Operation::first_argument_type& __x) const + { return op(__x, value); } + } _GLIBCXX11_DEPRECATED_SUGGEST("std::bind"); + + /// One of the @link binders binder functors@endlink. + template + inline binder2nd<_Operation> + bind2nd(const _Operation& __fn, const _Tp& __x) + { + typedef typename _Operation::second_argument_type _Arg2_type; + return binder2nd<_Operation>(__fn, _Arg2_type(__x)); + } + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#pragma GCC diagnostic pop + +#endif /* _BACKWARD_BINDERS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_fun.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_fun.h new file mode 100755 index 0000000..0fe44c9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_fun.h @@ -0,0 +1,170 @@ +// 'struct hash' from SGI -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file backward/hash_fun.h + * This file is a GNU extension to the Standard C++ Library (possibly + * containing extensions from the HP/SGI STL subset). + */ + +#ifndef _BACKWARD_HASH_FUN_H +#define _BACKWARD_HASH_FUN_H 1 + +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using std::size_t; + + template + struct hash { }; + + inline size_t + __stl_hash_string(const char* __s) + { + unsigned long __h = 0; + for ( ; *__s; ++__s) + __h = 5 * __h + *__s; + return size_t(__h); + } + + template<> + struct hash + { + size_t + operator()(const char* __s) const + { return __stl_hash_string(__s); } + }; + + template<> + struct hash + { + size_t + operator()(const char* __s) const + { return __stl_hash_string(__s); } + }; + + template<> + struct hash + { + size_t + operator()(char __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned char __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned char __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(short __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned short __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(int __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned int __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(long __x) const + { return __x; } + }; + + template<> + struct hash + { + size_t + operator()(unsigned long __x) const + { return __x; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_map b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_map new file mode 100755 index 0000000..38df991 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_map @@ -0,0 +1,599 @@ +// Hashing map implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file backward/hash_map + * This file is a GNU extension to the Standard C++ Library (possibly + * containing extensions from the HP/SGI STL subset). + */ + +#ifndef _BACKWARD_HASH_MAP +#define _BACKWARD_HASH_MAP 1 + +#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH +#include +#endif + +#include +#include +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using std::equal_to; + using std::allocator; + using std::pair; + using std::_Select1st; + + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> > + class hash_map + { + private: + typedef hashtable,_Key, _HashFn, + _Select1st >, + _EqualKey, _Alloc> _Ht; + + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + hash_map() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_map(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_map(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_map(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_map(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + _GLIBCXX_NODISCARD bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_map& __hs) + { _M_ht.swap(__hs._M_ht); } + + template + friend bool + operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&, + const hash_map<_K1, _T1, _HF, _EqK, _Al>&); + + iterator + begin() + { return _M_ht.begin(); } + + iterator + end() + { return _M_ht.end(); } + + const_iterator + begin() const + { return _M_ht.begin(); } + + const_iterator + end() const + { return _M_ht.end(); } + + pair + insert(const value_type& __obj) + { return _M_ht.insert_unique(__obj); } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f, __l); } + + pair + insert_noresize(const value_type& __obj) + { return _M_ht.insert_unique_noresize(__obj); } + + iterator + find(const key_type& __key) + { return _M_ht.find(__key); } + + const_iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + _Tp& + operator[](const key_type& __key) + { return _M_ht.find_or_insert(value_type(__key, _Tp())).second; } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) + { return _M_ht.equal_range(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + {return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { return __hm1._M_ht == __hm2._M_ht; } + + template + inline bool + operator!=(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { return !(__hm1 == __hm2); } + + template + inline void + swap(hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { __hm1.swap(__hm2); } + + + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Key>, + class _Alloc = allocator<_Tp> > + class hash_multimap + { + // concept requirements + __glibcxx_class_requires(_Key, _SGIAssignableConcept) + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) + __glibcxx_class_requires3(_HashFn, size_t, _Key, _UnaryFunctionConcept) + __glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept) + + private: + typedef hashtable, _Key, _HashFn, + _Select1st >, _EqualKey, _Alloc> + _Ht; + + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef _Tp data_type; + typedef _Tp mapped_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Ht::pointer pointer; + typedef typename _Ht::const_pointer const_pointer; + typedef typename _Ht::reference reference; + typedef typename _Ht::const_reference const_reference; + + typedef typename _Ht::iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + hash_multimap() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_multimap(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_multimap(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_multimap(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + _GLIBCXX_NODISCARD bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_multimap& __hs) + { _M_ht.swap(__hs._M_ht); } + + template + friend bool + operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, + const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); + + iterator + begin() + { return _M_ht.begin(); } + + iterator + end() + { return _M_ht.end(); } + + const_iterator + begin() const + { return _M_ht.begin(); } + + const_iterator + end() const + { return _M_ht.end(); } + + iterator + insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } + + iterator + insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + iterator + find(const key_type& __key) + { return _M_ht.find(__key); } + + const_iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) + { return _M_ht.equal_range(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + { return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, + const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) + { return __hm1._M_ht == __hm2._M_ht; } + + template + inline bool + operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, + const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) + { return !(__hm1 == __hm2); } + + template + inline void + swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + { __hm1.swap(__hm2); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Specialization of insert_iterator so that it will work for hash_map + // and hash_multimap. + template + class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn, + _EqKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> + _Container; + _Container* container; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() { return *this; } + + insert_iterator<_Container>& + operator++(int) + { return *this; } + }; + + template + class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, + _EqKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> + _Container; + _Container* container; + typename _Container::iterator iter; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() + { return *this; } + + insert_iterator<_Container>& + operator++(int) + { return *this; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_set b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_set new file mode 100755 index 0000000..3138a35 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hash_set @@ -0,0 +1,569 @@ +// Hashing set implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file backward/hash_set + * This file is a GNU extension to the Standard C++ Library (possibly + * containing extensions from the HP/SGI STL subset). + */ + +#ifndef _BACKWARD_HASH_SET +#define _BACKWARD_HASH_SET 1 + +#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH +#include +#endif + +#include +#include +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using std::equal_to; + using std::allocator; + using std::pair; + using std::_Identity; + + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Value>, + class _Alloc = allocator<_Value> > + class hash_set + { + // concept requirements + __glibcxx_class_requires(_Value, _SGIAssignableConcept) + __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) + __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) + + typedef __alloc_traits<_Alloc> _Alloc_traits; + + private: + typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, + _EqualKey, _Alloc> _Ht; + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + + typedef typename _Ht::const_iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + hash_set() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_set(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_set(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_set(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_set(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_unique(__f, __l); } + + template + hash_set(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_unique(__f, __l); } + + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + _GLIBCXX_NODISCARD bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_set& __hs) + { _M_ht.swap(__hs._M_ht); } + + template + friend bool + operator==(const hash_set<_Val, _HF, _EqK, _Al>&, + const hash_set<_Val, _HF, _EqK, _Al>&); + + iterator + begin() const + { return _M_ht.begin(); } + + iterator + end() const + { return _M_ht.end(); } + + pair + insert(const value_type& __obj) + { + pair __p = _M_ht.insert_unique(__obj); + return pair(__p.first, __p.second); + } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_unique(__f, __l); } + + pair + insert_noresize(const value_type& __obj) + { + pair __p + = _M_ht.insert_unique_noresize(__obj); + return pair(__p.first, __p.second); + } + + iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + {return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return __hs1._M_ht == __hs2._M_ht; } + + template + inline bool + operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return !(__hs1 == __hs2); } + + template + inline void + swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { __hs1.swap(__hs2); } + + + /** + * This is an SGI extension. + * @ingroup SGIextensions + * @doctodo + */ + template, + class _EqualKey = equal_to<_Value>, + class _Alloc = allocator<_Value> > + class hash_multiset + { + // concept requirements + __glibcxx_class_requires(_Value, _SGIAssignableConcept) + __glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept) + __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept) + + private: + typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>, + _EqualKey, _Alloc> _Ht; + _Ht _M_ht; + + public: + typedef typename _Ht::key_type key_type; + typedef typename _Ht::value_type value_type; + typedef typename _Ht::hasher hasher; + typedef typename _Ht::key_equal key_equal; + + typedef typename _Ht::size_type size_type; + typedef typename _Ht::difference_type difference_type; + typedef typename _Alloc::pointer pointer; + typedef typename _Alloc::const_pointer const_pointer; + typedef typename _Alloc::reference reference; + typedef typename _Alloc::const_reference const_reference; + + typedef typename _Ht::const_iterator iterator; + typedef typename _Ht::const_iterator const_iterator; + + typedef typename _Ht::allocator_type allocator_type; + + hasher + hash_funct() const + { return _M_ht.hash_funct(); } + + key_equal + key_eq() const + { return _M_ht.key_eq(); } + + allocator_type + get_allocator() const + { return _M_ht.get_allocator(); } + + hash_multiset() + : _M_ht(100, hasher(), key_equal(), allocator_type()) {} + + explicit + hash_multiset(size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + + hash_multiset(size_type __n, const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + + hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) {} + + template + hash_multiset(_InputIterator __f, _InputIterator __l) + : _M_ht(100, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n) + : _M_ht(__n, hasher(), key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf) + : _M_ht(__n, __hf, key_equal(), allocator_type()) + { _M_ht.insert_equal(__f, __l); } + + template + hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _M_ht(__n, __hf, __eql, __a) + { _M_ht.insert_equal(__f, __l); } + + size_type + size() const + { return _M_ht.size(); } + + size_type + max_size() const + { return _M_ht.max_size(); } + + _GLIBCXX_NODISCARD bool + empty() const + { return _M_ht.empty(); } + + void + swap(hash_multiset& hs) + { _M_ht.swap(hs._M_ht); } + + template + friend bool + operator==(const hash_multiset<_Val, _HF, _EqK, _Al>&, + const hash_multiset<_Val, _HF, _EqK, _Al>&); + + iterator + begin() const + { return _M_ht.begin(); } + + iterator + end() const + { return _M_ht.end(); } + + iterator + insert(const value_type& __obj) + { return _M_ht.insert_equal(__obj); } + + template + void + insert(_InputIterator __f, _InputIterator __l) + { _M_ht.insert_equal(__f,__l); } + + iterator + insert_noresize(const value_type& __obj) + { return _M_ht.insert_equal_noresize(__obj); } + + iterator + find(const key_type& __key) const + { return _M_ht.find(__key); } + + size_type + count(const key_type& __key) const + { return _M_ht.count(__key); } + + pair + equal_range(const key_type& __key) const + { return _M_ht.equal_range(__key); } + + size_type + erase(const key_type& __key) + { return _M_ht.erase(__key); } + + void + erase(iterator __it) + { _M_ht.erase(__it); } + + void + erase(iterator __f, iterator __l) + { _M_ht.erase(__f, __l); } + + void + clear() + { _M_ht.clear(); } + + void + resize(size_type __hint) + { _M_ht.resize(__hint); } + + size_type + bucket_count() const + { return _M_ht.bucket_count(); } + + size_type + max_bucket_count() const + { return _M_ht.max_bucket_count(); } + + size_type + elems_in_bucket(size_type __n) const + { return _M_ht.elems_in_bucket(__n); } + }; + + template + inline bool + operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return __hs1._M_ht == __hs2._M_ht; } + + template + inline bool + operator!=(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { return !(__hs1 == __hs2); } + + template + inline void + swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1, + hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2) + { __hs1.swap(__hs2); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Specialization of insert_iterator so that it will work for hash_set + // and hash_multiset. + template + class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn, + _EqualKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc> + _Container; + _Container* container; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() + { return *this; } + + insert_iterator<_Container>& + operator++(int) + { return *this; } + }; + + template + class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn, + _EqualKey, _Alloc> > + { + protected: + typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc> + _Container; + _Container* container; + typename _Container::iterator iter; + + public: + typedef _Container container_type; + typedef output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + + insert_iterator(_Container& __x) + : container(&__x) {} + + insert_iterator(_Container& __x, typename _Container::iterator) + : container(&__x) {} + + insert_iterator<_Container>& + operator=(const typename _Container::value_type& __value) + { + container->insert(__value); + return *this; + } + + insert_iterator<_Container>& + operator*() + { return *this; } + + insert_iterator<_Container>& + operator++() + { return *this; } + + insert_iterator<_Container>& + operator++(int) { return *this; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hashtable.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hashtable.h new file mode 100755 index 0000000..7af9e59 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/hashtable.h @@ -0,0 +1,1166 @@ +// Hashtable implementation used by containers -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file backward/hashtable.h + * This file is a GNU extension to the Standard C++ Library (possibly + * containing extensions from the HP/SGI STL subset). + */ + +#ifndef _BACKWARD_HASHTABLE_H +#define _BACKWARD_HASHTABLE_H 1 + +// Hashtable class, used to implement the hashed associative containers +// hash_set, hash_map, hash_multiset, and hash_multimap. + +#include +#include +#include +#include +#include +#include + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + struct _Hashtable_node + { + _Hashtable_node* _M_next; + _Val _M_val; + }; + + template > + class hashtable; + + template + struct _Hashtable_iterator; + + template + struct _Hashtable_const_iterator; + + template + struct _Hashtable_iterator + { + typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + typedef std::forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef _Val& reference; + typedef _Val* pointer; + + _Node* _M_cur; + _Hashtable* _M_ht; + + _Hashtable_iterator(_Node* __n, _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) { } + + _Hashtable_iterator() { } + + reference + operator*() const + { return _M_cur->_M_val; } + + pointer + operator->() const + { return &(operator*()); } + + iterator& + operator++(); + + iterator + operator++(int); + + bool + operator==(const iterator& __it) const + { return _M_cur == __it._M_cur; } + + bool + operator!=(const iterator& __it) const + { return _M_cur != __it._M_cur; } + }; + + template + struct _Hashtable_const_iterator + { + typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> + _Hashtable; + typedef _Hashtable_iterator<_Val,_Key,_HashFcn, + _ExtractKey,_EqualKey,_Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, + _ExtractKey, _EqualKey, _Alloc> + const_iterator; + typedef _Hashtable_node<_Val> _Node; + + typedef std::forward_iterator_tag iterator_category; + typedef _Val value_type; + typedef std::ptrdiff_t difference_type; + typedef std::size_t size_type; + typedef const _Val& reference; + typedef const _Val* pointer; + + const _Node* _M_cur; + const _Hashtable* _M_ht; + + _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) + : _M_cur(__n), _M_ht(__tab) { } + + _Hashtable_const_iterator() { } + + _Hashtable_const_iterator(const iterator& __it) + : _M_cur(__it._M_cur), _M_ht(__it._M_ht) { } + + reference + operator*() const + { return _M_cur->_M_val; } + + pointer + operator->() const + { return &(operator*()); } + + const_iterator& + operator++(); + + const_iterator + operator++(int); + + bool + operator==(const const_iterator& __it) const + { return _M_cur == __it._M_cur; } + + bool + operator!=(const const_iterator& __it) const + { return _M_cur != __it._M_cur; } + }; + + // Note: assumes long is at least 32 bits. + enum { _S_num_primes = 29 }; + + template + struct _Hashtable_prime_list + { + static const _PrimeType __stl_prime_list[_S_num_primes]; + + static const _PrimeType* + _S_get_prime_list(); + }; + + template const _PrimeType + _Hashtable_prime_list<_PrimeType>::__stl_prime_list[_S_num_primes] = + { + 5ul, 53ul, 97ul, 193ul, 389ul, + 769ul, 1543ul, 3079ul, 6151ul, 12289ul, + 24593ul, 49157ul, 98317ul, 196613ul, 393241ul, + 786433ul, 1572869ul, 3145739ul, 6291469ul, 12582917ul, + 25165843ul, 50331653ul, 100663319ul, 201326611ul, 402653189ul, + 805306457ul, 1610612741ul, 3221225473ul, 4294967291ul + }; + + template inline const _PrimeType* + _Hashtable_prime_list<_PrimeType>::_S_get_prime_list() + { + return __stl_prime_list; + } + + inline unsigned long + __stl_next_prime(unsigned long __n) + { + const unsigned long* __first = _Hashtable_prime_list::_S_get_prime_list(); + const unsigned long* __last = __first + (int)_S_num_primes; + const unsigned long* pos = std::lower_bound(__first, __last, __n); + return pos == __last ? *(__last - 1) : *pos; + } + + // Forward declaration of operator==. + template + class hashtable; + + template + bool + operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2); + + // Hashtables handle allocators a bit differently than other + // containers do. If we're using standard-conforming allocators, then + // a hashtable unconditionally has a member variable to hold its + // allocator, even if it so happens that all instances of the + // allocator type are identical. This is because, for hashtables, + // this extra storage is negligible. Additionally, a base class + // wouldn't serve any other purposes; it wouldn't, for example, + // simplify the exception-handling code. + template + class hashtable + { + public: + typedef _Key key_type; + typedef _Val value_type; + typedef _HashFcn hasher; + typedef _EqualKey key_equal; + + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + hasher + hash_funct() const + { return _M_hash; } + + key_equal + key_eq() const + { return _M_equals; } + + private: + typedef _Hashtable_node<_Val> _Node; + + public: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other allocator_type; + + allocator_type + get_allocator() const + { return _M_node_allocator; } + + private: + typedef __gnu_cxx::__alloc_traits _Alloc_traits; + typedef typename _Alloc_traits::template rebind<_Node>::other + _Node_Alloc; + typedef typename _Alloc_traits::template rebind<_Node*>::other + _Nodeptr_Alloc; + typedef std::vector<_Node*, _Nodeptr_Alloc> _Vector_type; + + _Node_Alloc _M_node_allocator; + + _Node* + _M_get_node() + { return _M_node_allocator.allocate(1); } + + void + _M_put_node(_Node* __p) + { _M_node_allocator.deallocate(__p, 1); } + + private: + hasher _M_hash; + key_equal _M_equals; + _ExtractKey _M_get_key; + _Vector_type _M_buckets; + size_type _M_num_elements; + + public: + typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc> + iterator; + typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc> + const_iterator; + + friend struct + _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + + friend struct + _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, + _EqualKey, _Alloc>; + + public: + hashtable(size_type __n, const _HashFcn& __hf, + const _EqualKey& __eql, const _ExtractKey& __ext, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), + _M_get_key(__ext), _M_buckets(__a), _M_num_elements(0) + { _M_initialize_buckets(__n); } + + hashtable(size_type __n, const _HashFcn& __hf, + const _EqualKey& __eql, + const allocator_type& __a = allocator_type()) + : _M_node_allocator(__a), _M_hash(__hf), _M_equals(__eql), + _M_get_key(_ExtractKey()), _M_buckets(__a), _M_num_elements(0) + { _M_initialize_buckets(__n); } + + hashtable(const hashtable& __ht) + : _M_node_allocator(__ht.get_allocator()), _M_hash(__ht._M_hash), + _M_equals(__ht._M_equals), _M_get_key(__ht._M_get_key), + _M_buckets(__ht.get_allocator()), _M_num_elements(0) + { _M_copy_from(__ht); } + + hashtable& + operator= (const hashtable& __ht) + { + if (&__ht != this) + { + clear(); + _M_hash = __ht._M_hash; + _M_equals = __ht._M_equals; + _M_get_key = __ht._M_get_key; + _M_copy_from(__ht); + } + return *this; + } + + ~hashtable() + { clear(); } + + size_type + size() const + { return _M_num_elements; } + + size_type + max_size() const + { return size_type(-1); } + + _GLIBCXX_NODISCARD bool + empty() const + { return size() == 0; } + + void + swap(hashtable& __ht) + { + std::swap(_M_hash, __ht._M_hash); + std::swap(_M_equals, __ht._M_equals); + std::swap(_M_get_key, __ht._M_get_key); + _M_buckets.swap(__ht._M_buckets); + std::swap(_M_num_elements, __ht._M_num_elements); + } + + iterator + begin() + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return iterator(_M_buckets[__n], this); + return end(); + } + + iterator + end() + { return iterator(0, this); } + + const_iterator + begin() const + { + for (size_type __n = 0; __n < _M_buckets.size(); ++__n) + if (_M_buckets[__n]) + return const_iterator(_M_buckets[__n], this); + return end(); + } + + const_iterator + end() const + { return const_iterator(0, this); } + + template + friend bool + operator==(const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&, + const hashtable<_Vl, _Ky, _HF, _Ex, _Eq, _Al>&); + + public: + size_type + bucket_count() const + { return _M_buckets.size(); } + + size_type + max_bucket_count() const + { return _Hashtable_prime_list:: + _S_get_prime_list()[(int)_S_num_primes - 1]; + } + + size_type + elems_in_bucket(size_type __bucket) const + { + size_type __result = 0; + for (_Node* __n = _M_buckets[__bucket]; __n; __n = __n->_M_next) + __result += 1; + return __result; + } + + std::pair + insert_unique(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_unique_noresize(__obj); + } + + iterator + insert_equal(const value_type& __obj) + { + resize(_M_num_elements + 1); + return insert_equal_noresize(__obj); + } + + std::pair + insert_unique_noresize(const value_type& __obj); + + iterator + insert_equal_noresize(const value_type& __obj); + + template + void + insert_unique(_InputIterator __f, _InputIterator __l) + { insert_unique(__f, __l, std::__iterator_category(__f)); } + + template + void + insert_equal(_InputIterator __f, _InputIterator __l) + { insert_equal(__f, __l, std::__iterator_category(__f)); } + + template + void + insert_unique(_InputIterator __f, _InputIterator __l, + std::input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_unique(*__f); + } + + template + void + insert_equal(_InputIterator __f, _InputIterator __l, + std::input_iterator_tag) + { + for ( ; __f != __l; ++__f) + insert_equal(*__f); + } + + template + void + insert_unique(_ForwardIterator __f, _ForwardIterator __l, + std::forward_iterator_tag) + { + size_type __n = std::distance(__f, __l); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_unique_noresize(*__f); + } + + template + void + insert_equal(_ForwardIterator __f, _ForwardIterator __l, + std::forward_iterator_tag) + { + size_type __n = std::distance(__f, __l); + resize(_M_num_elements + __n); + for ( ; __n > 0; --__n, ++__f) + insert_equal_noresize(*__f); + } + + reference + find_or_insert(const value_type& __obj); + + iterator + find(const key_type& __key) + { + size_type __n = _M_bkt_num_key(__key); + _Node* __first; + for (__first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + { } + return iterator(__first, this); + } + + const_iterator + find(const key_type& __key) const + { + size_type __n = _M_bkt_num_key(__key); + const _Node* __first; + for (__first = _M_buckets[__n]; + __first && !_M_equals(_M_get_key(__first->_M_val), __key); + __first = __first->_M_next) + { } + return const_iterator(__first, this); + } + + size_type + count(const key_type& __key) const + { + const size_type __n = _M_bkt_num_key(__key); + size_type __result = 0; + + for (const _Node* __cur = _M_buckets[__n]; __cur; + __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), __key)) + ++__result; + return __result; + } + + std::pair + equal_range(const key_type& __key); + + std::pair + equal_range(const key_type& __key) const; + + size_type + erase(const key_type& __key); + + void + erase(const iterator& __it); + + void + erase(iterator __first, iterator __last); + + void + erase(const const_iterator& __it); + + void + erase(const_iterator __first, const_iterator __last); + + void + resize(size_type __num_elements_hint); + + void + clear(); + + private: + size_type + _M_next_size(size_type __n) const + { return __stl_next_prime(__n); } + + void + _M_initialize_buckets(size_type __n) + { + const size_type __n_buckets = _M_next_size(__n); + _M_buckets.reserve(__n_buckets); + _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); + _M_num_elements = 0; + } + + size_type + _M_bkt_num_key(const key_type& __key) const + { return _M_bkt_num_key(__key, _M_buckets.size()); } + + size_type + _M_bkt_num(const value_type& __obj) const + { return _M_bkt_num_key(_M_get_key(__obj)); } + + size_type + _M_bkt_num_key(const key_type& __key, std::size_t __n) const + { return _M_hash(__key) % __n; } + + size_type + _M_bkt_num(const value_type& __obj, std::size_t __n) const + { return _M_bkt_num_key(_M_get_key(__obj), __n); } + + _Node* + _M_new_node(const value_type& __obj) + { + _Node* __n = _M_get_node(); + __n->_M_next = 0; + __try + { + allocator_type __a = this->get_allocator(); + _Alloc_traits::construct(__a, &__n->_M_val, __obj); + return __n; + } + __catch(...) + { + _M_put_node(__n); + __throw_exception_again; + } + } + + void + _M_delete_node(_Node* __n) + { + allocator_type __a = this->get_allocator(); + _Alloc_traits::destroy(__a, &__n->_M_val); + _M_put_node(__n); + } + + void + _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last); + + void + _M_erase_bucket(const size_type __n, _Node* __last); + + void + _M_copy_from(const hashtable& __ht); + }; + + template + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++() + { + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) + { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; + } + + template + inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> + _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++(int) + { + iterator __tmp = *this; + ++*this; + return __tmp; + } + + template + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>& + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++() + { + const _Node* __old = _M_cur; + _M_cur = _M_cur->_M_next; + if (!_M_cur) + { + size_type __bucket = _M_ht->_M_bkt_num(__old->_M_val); + while (!_M_cur && ++__bucket < _M_ht->_M_buckets.size()) + _M_cur = _M_ht->_M_buckets[__bucket]; + } + return *this; + } + + template + inline _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All> + _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>:: + operator++(int) + { + const_iterator __tmp = *this; + ++*this; + return __tmp; + } + + template + bool + operator==(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) + { + typedef typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_Node _Node; + + if (__ht1._M_buckets.size() != __ht2._M_buckets.size()) + return false; + + for (std::size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n) + { + _Node* __cur1 = __ht1._M_buckets[__n]; + _Node* __cur2 = __ht2._M_buckets[__n]; + // Check same length of lists + for (; __cur1 && __cur2; + __cur1 = __cur1->_M_next, __cur2 = __cur2->_M_next) + { } + if (__cur1 || __cur2) + return false; + // Now check one's elements are in the other + for (__cur1 = __ht1._M_buckets[__n] ; __cur1; + __cur1 = __cur1->_M_next) + { + bool _found__cur1 = false; + for (__cur2 = __ht2._M_buckets[__n]; + __cur2; __cur2 = __cur2->_M_next) + { + if (__cur1->_M_val == __cur2->_M_val) + { + _found__cur1 = true; + break; + } + } + if (!_found__cur1) + return false; + } + } + return true; + } + + template + inline bool + operator!=(const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht1, + const hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>& __ht2) + { return !(__ht1 == __ht2); } + + template + inline void + swap(hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht1, + hashtable<_Val, _Key, _HF, _Extract, _EqKey, _All>& __ht2) + { __ht1.swap(__ht2); } + + template + std::pair::iterator, + bool> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + insert_unique_noresize(const value_type& __obj) + { + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return std::pair(iterator(__cur, this), false); + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return std::pair(iterator(__tmp, this), true); + } + + template + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + insert_equal_noresize(const value_type& __obj) + { + const size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + { + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __cur->_M_next; + __cur->_M_next = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); + } + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return iterator(__tmp, this); + } + + template + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + find_or_insert(const value_type& __obj) + { + resize(_M_num_elements + 1); + + size_type __n = _M_bkt_num(__obj); + _Node* __first = _M_buckets[__n]; + + for (_Node* __cur = __first; __cur; __cur = __cur->_M_next) + if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj))) + return __cur->_M_val; + + _Node* __tmp = _M_new_node(__obj); + __tmp->_M_next = __first; + _M_buckets[__n] = __tmp; + ++_M_num_elements; + return __tmp->_M_val; + } + + template + std::pair::iterator, + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + equal_range(const key_type& __key) + { + typedef std::pair _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (_Node* __first = _M_buckets[__n]; __first; + __first = __first->_M_next) + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + for (_Node* __cur = __first->_M_next; __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(iterator(__first, this), iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(iterator(__first, this), + iterator(_M_buckets[__m], this)); + return _Pii(iterator(__first, this), end()); + } + return _Pii(end(), end()); + } + + template + std::pair< + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator, + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator> + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + equal_range(const key_type& __key) const + { + typedef std::pair _Pii; + const size_type __n = _M_bkt_num_key(__key); + + for (const _Node* __first = _M_buckets[__n]; __first; + __first = __first->_M_next) + { + if (_M_equals(_M_get_key(__first->_M_val), __key)) + { + for (const _Node* __cur = __first->_M_next; __cur; + __cur = __cur->_M_next) + if (!_M_equals(_M_get_key(__cur->_M_val), __key)) + return _Pii(const_iterator(__first, this), + const_iterator(__cur, this)); + for (size_type __m = __n + 1; __m < _M_buckets.size(); ++__m) + if (_M_buckets[__m]) + return _Pii(const_iterator(__first, this), + const_iterator(_M_buckets[__m], this)); + return _Pii(const_iterator(__first, this), end()); + } + } + return _Pii(end(), end()); + } + + template + typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::size_type + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const key_type& __key) + { + const size_type __n = _M_bkt_num_key(__key); + _Node* __first = _M_buckets[__n]; + _Node* __saved_slot = 0; + size_type __erased = 0; + + if (__first) + { + _Node* __cur = __first; + _Node* __next = __cur->_M_next; + while (__next) + { + if (_M_equals(_M_get_key(__next->_M_val), __key)) + { + if (&_M_get_key(__next->_M_val) != &__key) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + ++__erased; + --_M_num_elements; + } + else + { + __saved_slot = __cur; + __cur = __next; + __next = __cur->_M_next; + } + } + else + { + __cur = __next; + __next = __cur->_M_next; + } + } + bool __delete_first = _M_equals(_M_get_key(__first->_M_val), __key); + if (__saved_slot) + { + __next = __saved_slot->_M_next; + __saved_slot->_M_next = __next->_M_next; + _M_delete_node(__next); + ++__erased; + --_M_num_elements; + } + if (__delete_first) + { + _M_buckets[__n] = __first->_M_next; + _M_delete_node(__first); + ++__erased; + --_M_num_elements; + } + } + return __erased; + } + + template + void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const iterator& __it) + { + _Node* __p = __it._M_cur; + if (__p) + { + const size_type __n = _M_bkt_num(__p->_M_val); + _Node* __cur = _M_buckets[__n]; + + if (__cur == __p) + { + _M_buckets[__n] = __cur->_M_next; + _M_delete_node(__cur); + --_M_num_elements; + } + else + { + _Node* __next = __cur->_M_next; + while (__next) + { + if (__next == __p) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + --_M_num_elements; + break; + } + else + { + __cur = __next; + __next = __cur->_M_next; + } + } + } + } + } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(iterator __first, iterator __last) + { + size_type __f_bucket = __first._M_cur ? _M_bkt_num(__first._M_cur->_M_val) + : _M_buckets.size(); + + size_type __l_bucket = __last._M_cur ? _M_bkt_num(__last._M_cur->_M_val) + : _M_buckets.size(); + + if (__first._M_cur == __last._M_cur) + return; + else if (__f_bucket == __l_bucket) + _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); + else + { + _M_erase_bucket(__f_bucket, __first._M_cur, 0); + for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) + _M_erase_bucket(__n, 0); + if (__l_bucket != _M_buckets.size()) + _M_erase_bucket(__l_bucket, __last._M_cur); + } + } + + template + inline void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const_iterator __first, const_iterator __last) + { + erase(iterator(const_cast<_Node*>(__first._M_cur), + const_cast(__first._M_ht)), + iterator(const_cast<_Node*>(__last._M_cur), + const_cast(__last._M_ht))); + } + + template + inline void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + erase(const const_iterator& __it) + { erase(iterator(const_cast<_Node*>(__it._M_cur), + const_cast(__it._M_ht))); } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + resize(size_type __num_elements_hint) + { + const size_type __old_n = _M_buckets.size(); + if (__num_elements_hint > __old_n) + { + const size_type __n = _M_next_size(__num_elements_hint); + if (__n > __old_n) + { + _Vector_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator()); + __try + { + for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) + { + _Node* __first = _M_buckets[__bucket]; + while (__first) + { + size_type __new_bucket = _M_bkt_num(__first->_M_val, + __n); + _M_buckets[__bucket] = __first->_M_next; + __first->_M_next = __tmp[__new_bucket]; + __tmp[__new_bucket] = __first; + __first = _M_buckets[__bucket]; + } + } + _M_buckets.swap(__tmp); + } + __catch(...) + { + for (size_type __bucket = 0; __bucket < __tmp.size(); + ++__bucket) + { + while (__tmp[__bucket]) + { + _Node* __next = __tmp[__bucket]->_M_next; + _M_delete_node(__tmp[__bucket]); + __tmp[__bucket] = __next; + } + } + __throw_exception_again; + } + } + } + } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_erase_bucket(const size_type __n, _Node* __first, _Node* __last) + { + _Node* __cur = _M_buckets[__n]; + if (__cur == __first) + _M_erase_bucket(__n, __last); + else + { + _Node* __next; + for (__next = __cur->_M_next; + __next != __first; + __cur = __next, __next = __cur->_M_next) + ; + while (__next != __last) + { + __cur->_M_next = __next->_M_next; + _M_delete_node(__next); + __next = __cur->_M_next; + --_M_num_elements; + } + } + } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_erase_bucket(const size_type __n, _Node* __last) + { + _Node* __cur = _M_buckets[__n]; + while (__cur != __last) + { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + _M_buckets[__n] = __cur; + --_M_num_elements; + } + } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + clear() + { + if (_M_num_elements == 0) + return; + + for (size_type __i = 0; __i < _M_buckets.size(); ++__i) + { + _Node* __cur = _M_buckets[__i]; + while (__cur != 0) + { + _Node* __next = __cur->_M_next; + _M_delete_node(__cur); + __cur = __next; + } + _M_buckets[__i] = 0; + } + _M_num_elements = 0; + } + + template + void + hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: + _M_copy_from(const hashtable& __ht) + { + _M_buckets.clear(); + _M_buckets.reserve(__ht._M_buckets.size()); + _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0); + __try + { + for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { + const _Node* __cur = __ht._M_buckets[__i]; + if (__cur) + { + _Node* __local_copy = _M_new_node(__cur->_M_val); + _M_buckets[__i] = __local_copy; + + for (_Node* __next = __cur->_M_next; + __next; + __cur = __next, __next = __cur->_M_next) + { + __local_copy->_M_next = _M_new_node(__next->_M_val); + __local_copy = __local_copy->_M_next; + } + } + } + _M_num_elements = __ht._M_num_elements; + } + __catch(...) + { + clear(); + __throw_exception_again; + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/strstream b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/strstream new file mode 100755 index 0000000..4c216ac --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/backward/strstream @@ -0,0 +1,239 @@ +// Backward-compat support -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +// WARNING: The classes defined in this header are DEPRECATED. This +// header is defined in section D.7.1 of the C++ standard, and it +// MAY BE REMOVED in a future standard revision. One should use the +// header instead. + +/** @file strstream + * This is a Standard C++ Library header. + */ + +#ifndef _BACKWARD_STRSTREAM +#define _BACKWARD_STRSTREAM + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Class strstreambuf, a streambuf class that manages an array of char. + // Note that this class is not a template. + class strstreambuf : public basic_streambuf > + { + public: + // Types. + typedef char_traits _Traits; + typedef basic_streambuf _Base; + + public: + // Constructor, destructor +#if __cplusplus >= 201103L + strstreambuf() : strstreambuf(0) { } + explicit strstreambuf(streamsize __initial_capacity); +#else + explicit strstreambuf(streamsize __initial_capacity = 0); +#endif + strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*)); + + strstreambuf(char* __get, streamsize __n, char* __put = 0) throw (); + strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0) throw (); + strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0) throw (); + + strstreambuf(const char* __get, streamsize __n) throw (); + strstreambuf(const signed char* __get, streamsize __n) throw (); + strstreambuf(const unsigned char* __get, streamsize __n) throw (); + + virtual ~strstreambuf(); + +#if __cplusplus >= 201103L + strstreambuf(strstreambuf&& __rhs) noexcept + : _Base(__rhs), _M_alloc_fun(__rhs._M_alloc_fun), + _M_free_fun(__rhs._M_free_fun), _M_dynamic(__rhs._M_dynamic), + _M_frozen(__rhs._M_frozen), _M_constant(__rhs._M_constant) + { + __rhs.setg(nullptr, nullptr, nullptr); + __rhs.setp(nullptr, nullptr); + } + + strstreambuf& + operator=(strstreambuf&& __rhs) noexcept + { + if (_M_dynamic && !_M_frozen) + _M_free(eback()); + _Base::operator=(static_cast(__rhs)); + _M_alloc_fun = __rhs._M_alloc_fun; + _M_free_fun = __rhs._M_free_fun; + _M_dynamic = __rhs._M_dynamic; + _M_frozen = __rhs._M_frozen; + _M_constant = __rhs._M_constant; + __rhs.setg(nullptr, nullptr, nullptr); + __rhs.setp(nullptr, nullptr); + return *this; + } +#endif + + public: + void freeze(bool = true) throw (); + char* str() throw (); + _GLIBCXX_PURE int pcount() const throw (); + + protected: + virtual int_type overflow(int_type __c = _Traits::eof()); + virtual int_type pbackfail(int_type __c = _Traits::eof()); + virtual int_type underflow(); + virtual _Base* setbuf(char* __buf, streamsize __n); + virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, + ios_base::openmode __mode + = ios_base::in | ios_base::out); + virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode + = ios_base::in | ios_base::out); + + private: +#if __cplusplus < 201103L + strstreambuf& + operator=(const strstreambuf&); + + strstreambuf(const strstreambuf&); +#endif + + // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. + char* _M_alloc(size_t); + void _M_free(char*); + + // Helper function used in constructors. + void _M_setup(char* __get, char* __put, streamsize __n) throw (); + + // Data members. + void* (*_M_alloc_fun)(size_t); + void (*_M_free_fun)(void*); + + bool _M_dynamic : 1; + bool _M_frozen : 1; + bool _M_constant : 1; + }; + + // Class istrstream, an istream that manages a strstreambuf. + class istrstream : public basic_istream + { + public: + explicit istrstream(char*); + explicit istrstream(const char*); + istrstream(char* , streamsize); + istrstream(const char*, streamsize); + virtual ~istrstream(); + +#if __cplusplus >= 201103L + istrstream(istrstream&& __rhs) + : istream(std::move(__rhs)), _M_buf(std::move(__rhs._M_buf)) + { set_rdbuf(&_M_buf); } + + istrstream& operator=(istrstream&&) = default; +#endif + + _GLIBCXX_CONST strstreambuf* rdbuf() const throw (); + char* str() throw (); + + private: + strstreambuf _M_buf; + }; + + // Class ostrstream + class ostrstream : public basic_ostream + { + public: + ostrstream(); + ostrstream(char*, int, ios_base::openmode = ios_base::out); + virtual ~ostrstream(); + +#if __cplusplus >= 201103L + ostrstream(ostrstream&& __rhs) + : ostream(std::move(__rhs)), _M_buf(std::move(__rhs._M_buf)) + { set_rdbuf(&_M_buf); } + + ostrstream& operator=(ostrstream&&) = default; +#endif + + _GLIBCXX_CONST strstreambuf* rdbuf() const throw (); + void freeze(bool = true) throw(); + char* str() throw (); + _GLIBCXX_PURE int pcount() const throw (); + + private: + strstreambuf _M_buf; + }; + + // Class strstream + class strstream : public basic_iostream + { + public: + typedef char char_type; + typedef char_traits::int_type int_type; + typedef char_traits::pos_type pos_type; + typedef char_traits::off_type off_type; + + strstream(); + strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); + virtual ~strstream(); + +#if __cplusplus >= 201103L + strstream(strstream&& __rhs) + : iostream(std::move(__rhs)), _M_buf(std::move(__rhs._M_buf)) + { set_rdbuf(&_M_buf); } + + strstream& operator=(strstream&&) = default; +#endif + + _GLIBCXX_CONST strstreambuf* rdbuf() const throw (); + void freeze(bool = true) throw (); + _GLIBCXX_PURE int pcount() const throw (); + char* str() throw (); + + private: + strstreambuf _M_buf; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/barrier b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/barrier new file mode 100755 index 0000000..4210e30 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/barrier @@ -0,0 +1,259 @@ +// -*- C++ -*- + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// This implementation is based on libcxx/include/barrier +//===-- barrier.h --------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===---------------------------------------------------------------===// + +/** @file include/barrier + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_BARRIER +#define _GLIBCXX_BARRIER 1 + +#pragma GCC system_header + +#if __cplusplus > 201703L +#include +#if __cpp_lib_atomic_wait && __cpp_aligned_new +#include +#include + +#include + +#define __cpp_lib_barrier 201907L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct __empty_completion + { + _GLIBCXX_ALWAYS_INLINE void + operator()() noexcept + { } + }; + +/* + +The default implementation of __tree_barrier is a classic tree barrier. + +It looks different from literature pseudocode for two main reasons: + 1. Threads that call into std::barrier functions do not provide indices, + so a numbering step is added before the actual barrier algorithm, + appearing as an N+1 round to the N rounds of the tree barrier. + 2. A great deal of attention has been paid to avoid cache line thrashing + by flattening the tree structure into cache-line sized arrays, that + are indexed in an efficient way. + +*/ + + enum class __barrier_phase_t : unsigned char { }; + + template + class __tree_barrier + { + using __atomic_phase_ref_t = std::__atomic_ref<__barrier_phase_t>; + using __atomic_phase_const_ref_t = std::__atomic_ref; + static constexpr auto __phase_alignment = + __atomic_phase_ref_t::required_alignment; + + using __tickets_t = std::array<__barrier_phase_t, 64>; + struct alignas(64) /* naturally-align the heap state */ __state_t + { + alignas(__phase_alignment) __tickets_t __tickets; + }; + + ptrdiff_t _M_expected; + unique_ptr<__state_t[]> _M_state; + __atomic_base _M_expected_adjustment; + _CompletionF _M_completion; + + alignas(__phase_alignment) __barrier_phase_t _M_phase; + + bool + _M_arrive(__barrier_phase_t __old_phase, size_t __current) + { + const auto __old_phase_val = static_cast(__old_phase); + const auto __half_step = + static_cast<__barrier_phase_t>(__old_phase_val + 1); + const auto __full_step = + static_cast<__barrier_phase_t>(__old_phase_val + 2); + + size_t __current_expected = _M_expected; + __current %= ((_M_expected + 1) >> 1); + + for (int __round = 0; ; ++__round) + { + if (__current_expected <= 1) + return true; + size_t const __end_node = ((__current_expected + 1) >> 1), + __last_node = __end_node - 1; + for ( ; ; ++__current) + { + if (__current == __end_node) + __current = 0; + auto __expect = __old_phase; + __atomic_phase_ref_t __phase(_M_state[__current] + .__tickets[__round]); + if (__current == __last_node && (__current_expected & 1)) + { + if (__phase.compare_exchange_strong(__expect, __full_step, + memory_order_acq_rel)) + break; // I'm 1 in 1, go to next __round + } + else if (__phase.compare_exchange_strong(__expect, __half_step, + memory_order_acq_rel)) + { + return false; // I'm 1 in 2, done with arrival + } + else if (__expect == __half_step) + { + if (__phase.compare_exchange_strong(__expect, __full_step, + memory_order_acq_rel)) + break; // I'm 2 in 2, go to next __round + } + } + __current_expected = __last_node + 1; + __current >>= 1; + } + } + + public: + using arrival_token = __barrier_phase_t; + + static constexpr ptrdiff_t + max() noexcept + { return __PTRDIFF_MAX__; } + + __tree_barrier(ptrdiff_t __expected, _CompletionF __completion) + : _M_expected(__expected), _M_expected_adjustment(0), + _M_completion(move(__completion)), + _M_phase(static_cast<__barrier_phase_t>(0)) + { + size_t const __count = (_M_expected + 1) >> 1; + + _M_state = std::make_unique<__state_t[]>(__count); + } + + [[nodiscard]] arrival_token + arrive(ptrdiff_t __update) + { + std::hash __hasher; + size_t __current = __hasher(std::this_thread::get_id()); + __atomic_phase_ref_t __phase(_M_phase); + const auto __old_phase = __phase.load(memory_order_relaxed); + const auto __cur = static_cast(__old_phase); + for(; __update; --__update) + { + if(_M_arrive(__old_phase, __current)) + { + _M_completion(); + _M_expected += _M_expected_adjustment.load(memory_order_relaxed); + _M_expected_adjustment.store(0, memory_order_relaxed); + auto __new_phase = static_cast<__barrier_phase_t>(__cur + 2); + __phase.store(__new_phase, memory_order_release); + __phase.notify_all(); + } + } + return __old_phase; + } + + void + wait(arrival_token&& __old_phase) const + { + __atomic_phase_const_ref_t __phase(_M_phase); + auto const __test_fn = [=] + { + return __phase.load(memory_order_acquire) != __old_phase; + }; + std::__atomic_wait_address(&_M_phase, __test_fn); + } + + void + arrive_and_drop() + { + _M_expected_adjustment.fetch_sub(1, memory_order_relaxed); + (void)arrive(1); + } + }; + + template + class barrier + { + // Note, we may introduce a "central" barrier algorithm at some point + // for more space constrained targets + using __algorithm_t = __tree_barrier<_CompletionF>; + __algorithm_t _M_b; + + public: + class arrival_token final + { + public: + arrival_token(arrival_token&&) = default; + arrival_token& operator=(arrival_token&&) = default; + ~arrival_token() = default; + + private: + friend class barrier; + using __token = typename __algorithm_t::arrival_token; + explicit arrival_token(__token __tok) noexcept : _M_tok(__tok) { } + __token _M_tok; + }; + + static constexpr ptrdiff_t + max() noexcept + { return __algorithm_t::max(); } + + explicit + barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF()) + : _M_b(__count, std::move(__completion)) + { } + + barrier(barrier const&) = delete; + barrier& operator=(barrier const&) = delete; + + [[nodiscard]] arrival_token + arrive(ptrdiff_t __update = 1) + { return arrival_token{_M_b.arrive(__update)}; } + + void + wait(arrival_token&& __phase) const + { _M_b.wait(std::move(__phase._M_tok)); } + + void + arrive_and_wait() + { wait(arrive()); } + + void + arrive_and_drop() + { _M_b.arrive_and_drop(); } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // __cpp_lib_atomic_wait && __cpp_aligned_new +#endif // __cplusplus > 201703L +#endif // _GLIBCXX_BARRIER diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bit b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bit new file mode 100755 index 0000000..c5aae8b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bit @@ -0,0 +1,409 @@ +// -*- C++ -*- + +// Copyright (C) 2018-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bit + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_BIT +#define _GLIBCXX_BIT 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include + +#if _GLIBCXX_HOSTED +# include +#else +# include +/// @cond undocumented +namespace __gnu_cxx +{ + template + struct __int_traits + { + static constexpr int __digits = std::numeric_limits<_Tp>::digits; + static constexpr _Tp __max = std::numeric_limits<_Tp>::max(); + }; +} +/// @endcond +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup bit_manip Bit manipulation + * @ingroup numerics + * + * Utilities for examining and manipulating individual bits. + * + * @{ + */ + +#if __cplusplus > 201703l && __has_builtin(__builtin_bit_cast) +#define __cpp_lib_bit_cast 201806L + + /// Create a value of type `To` from the bits of `from`. + template + [[nodiscard]] + constexpr _To + bit_cast(const _From& __from) noexcept + { + return __builtin_bit_cast(_To, __from); + } +#endif + + /// @cond undoc + + template + constexpr _Tp + __rotl(_Tp __x, int __s) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + if _GLIBCXX17_CONSTEXPR ((_Nd & (_Nd - 1)) == 0) + { + // Variant for power of two _Nd which the compiler can + // easily pattern match. + constexpr unsigned __uNd = _Nd; + const unsigned __r = __s; + return (__x << (__r % __uNd)) | (__x >> ((-__r) % __uNd)); + } + const int __r = __s % _Nd; + if (__r == 0) + return __x; + else if (__r > 0) + return (__x << __r) | (__x >> ((_Nd - __r) % _Nd)); + else + return (__x >> -__r) | (__x << ((_Nd + __r) % _Nd)); // rotr(x, -r) + } + + template + constexpr _Tp + __rotr(_Tp __x, int __s) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + if _GLIBCXX17_CONSTEXPR ((_Nd & (_Nd - 1)) == 0) + { + // Variant for power of two _Nd which the compiler can + // easily pattern match. + constexpr unsigned __uNd = _Nd; + const unsigned __r = __s; + return (__x >> (__r % __uNd)) | (__x << ((-__r) % __uNd)); + } + const int __r = __s % _Nd; + if (__r == 0) + return __x; + else if (__r > 0) + return (__x >> __r) | (__x << ((_Nd - __r) % _Nd)); + else + return (__x << -__r) | (__x >> ((_Nd + __r) % _Nd)); // rotl(x, -r) + } + + template + constexpr int + __countl_zero(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + + if (__x == 0) + return _Nd; + + constexpr auto _Nd_ull = __int_traits::__digits; + constexpr auto _Nd_ul = __int_traits::__digits; + constexpr auto _Nd_u = __int_traits::__digits; + + if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u) + { + constexpr int __diff = _Nd_u - _Nd; + return __builtin_clz(__x) - __diff; + } + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul) + { + constexpr int __diff = _Nd_ul - _Nd; + return __builtin_clzl(__x) - __diff; + } + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull) + { + constexpr int __diff = _Nd_ull - _Nd; + return __builtin_clzll(__x) - __diff; + } + else // (_Nd > _Nd_ull) + { + static_assert(_Nd <= (2 * _Nd_ull), + "Maximum supported integer size is 128-bit"); + + unsigned long long __high = __x >> _Nd_ull; + if (__high != 0) + { + constexpr int __diff = (2 * _Nd_ull) - _Nd; + return __builtin_clzll(__high) - __diff; + } + constexpr auto __max_ull = __int_traits::__max; + unsigned long long __low = __x & __max_ull; + return (_Nd - _Nd_ull) + __builtin_clzll(__low); + } + } + + template + constexpr int + __countl_one(_Tp __x) noexcept + { + return std::__countl_zero<_Tp>((_Tp)~__x); + } + + template + constexpr int + __countr_zero(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + + if (__x == 0) + return _Nd; + + constexpr auto _Nd_ull = __int_traits::__digits; + constexpr auto _Nd_ul = __int_traits::__digits; + constexpr auto _Nd_u = __int_traits::__digits; + + if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u) + return __builtin_ctz(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul) + return __builtin_ctzl(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull) + return __builtin_ctzll(__x); + else // (_Nd > _Nd_ull) + { + static_assert(_Nd <= (2 * _Nd_ull), + "Maximum supported integer size is 128-bit"); + + constexpr auto __max_ull = __int_traits::__max; + unsigned long long __low = __x & __max_ull; + if (__low != 0) + return __builtin_ctzll(__low); + unsigned long long __high = __x >> _Nd_ull; + return __builtin_ctzll(__high) + _Nd_ull; + } + } + + template + constexpr int + __countr_one(_Tp __x) noexcept + { + return std::__countr_zero((_Tp)~__x); + } + + template + constexpr int + __popcount(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + + constexpr auto _Nd_ull = __int_traits::__digits; + constexpr auto _Nd_ul = __int_traits::__digits; + constexpr auto _Nd_u = __int_traits::__digits; + + if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_u) + return __builtin_popcount(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ul) + return __builtin_popcountl(__x); + else if _GLIBCXX17_CONSTEXPR (_Nd <= _Nd_ull) + return __builtin_popcountll(__x); + else // (_Nd > _Nd_ull) + { + static_assert(_Nd <= (2 * _Nd_ull), + "Maximum supported integer size is 128-bit"); + + constexpr auto __max_ull = __int_traits::__max; + unsigned long long __low = __x & __max_ull; + unsigned long long __high = __x >> _Nd_ull; + return __builtin_popcountll(__low) + __builtin_popcountll(__high); + } + } + + template + constexpr bool + __has_single_bit(_Tp __x) noexcept + { return std::__popcount(__x) == 1; } + + template + constexpr _Tp + __bit_ceil(_Tp __x) noexcept + { + using __gnu_cxx::__int_traits; + constexpr auto _Nd = __int_traits<_Tp>::__digits; + if (__x == 0 || __x == 1) + return 1; + auto __shift_exponent = _Nd - std::__countl_zero((_Tp)(__x - 1u)); + // If the shift exponent equals _Nd then the correct result is not + // representable as a value of _Tp, and so the result is undefined. + // Want that undefined behaviour to be detected in constant expressions, + // by UBSan, and by debug assertions. +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (!__builtin_is_constant_evaluated()) + { + __glibcxx_assert( __shift_exponent != __int_traits<_Tp>::__digits ); + } +#endif + using __promoted_type = decltype(__x << 1); + if _GLIBCXX17_CONSTEXPR (!is_same<__promoted_type, _Tp>::value) + { + // If __x undergoes integral promotion then shifting by _Nd is + // not undefined. In order to make the shift undefined, so that + // it is diagnosed in constant expressions and by UBsan, we also + // need to "promote" the shift exponent to be too large for the + // promoted type. + const int __extra_exp = sizeof(__promoted_type) / sizeof(_Tp) / 2; + __shift_exponent |= (__shift_exponent & _Nd) << __extra_exp; + } + return (_Tp)1u << __shift_exponent; + } + + template + constexpr _Tp + __bit_floor(_Tp __x) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + if (__x == 0) + return 0; + return (_Tp)1u << (_Nd - std::__countl_zero((_Tp)(__x >> 1))); + } + + template + constexpr _Tp + __bit_width(_Tp __x) noexcept + { + constexpr auto _Nd = __gnu_cxx::__int_traits<_Tp>::__digits; + return _Nd - std::__countl_zero(__x); + } + + /// @endcond + +#if __cplusplus > 201703L + +#define __cpp_lib_bitops 201907L + + /// @cond undoc + template + using _If_is_unsigned_integer + = enable_if_t<__is_unsigned_integer<_Tp>::value, _Up>; + /// @endcond + + // [bit.rot], rotating + + /// Rotate `x` to the left by `s` bits. + template + [[nodiscard]] constexpr _If_is_unsigned_integer<_Tp> + rotl(_Tp __x, int __s) noexcept + { return std::__rotl(__x, __s); } + + /// Rotate `x` to the right by `s` bits. + template + [[nodiscard]] constexpr _If_is_unsigned_integer<_Tp> + rotr(_Tp __x, int __s) noexcept + { return std::__rotr(__x, __s); } + + // [bit.count], counting + + /// The number of contiguous zero bits, starting from the highest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countl_zero(_Tp __x) noexcept + { return std::__countl_zero(__x); } + + /// The number of contiguous one bits, starting from the highest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countl_one(_Tp __x) noexcept + { return std::__countl_one(__x); } + + /// The number of contiguous zero bits, starting from the lowest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countr_zero(_Tp __x) noexcept + { return std::__countr_zero(__x); } + + /// The number of contiguous one bits, starting from the lowest bit. + template + constexpr _If_is_unsigned_integer<_Tp, int> + countr_one(_Tp __x) noexcept + { return std::__countr_one(__x); } + + /// The number of bits set in `x`. + template + constexpr _If_is_unsigned_integer<_Tp, int> + popcount(_Tp __x) noexcept + { return std::__popcount(__x); } + + // [bit.pow.two], integral powers of 2 + +#define __cpp_lib_int_pow2 202002L + + /// True if `x` is a power of two, false otherwise. + template + constexpr _If_is_unsigned_integer<_Tp, bool> + has_single_bit(_Tp __x) noexcept + { return std::__has_single_bit(__x); } + + /// The smallest power-of-two not less than `x`. + template + constexpr _If_is_unsigned_integer<_Tp> + bit_ceil(_Tp __x) noexcept + { return std::__bit_ceil(__x); } + + /// The largest power-of-two not greater than `x`. + template + constexpr _If_is_unsigned_integer<_Tp> + bit_floor(_Tp __x) noexcept + { return std::__bit_floor(__x); } + + /// The smallest integer greater than the base-2 logarithm of `x`. + template + constexpr _If_is_unsigned_integer<_Tp> + bit_width(_Tp __x) noexcept + { return std::__bit_width(__x); } + +#define __cpp_lib_endian 201907L + + /// Byte order + enum class endian + { + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ + }; +#endif // C++2a + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 +#endif // _GLIBCXX_BIT diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/algorithmfwd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/algorithmfwd.h new file mode 100755 index 0000000..48920b0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/algorithmfwd.h @@ -0,0 +1,967 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/algorithmfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _GLIBCXX_ALGORITHMFWD_H +#define _GLIBCXX_ALGORITHMFWD_H 1 + +#pragma GCC system_header + +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /* + adjacent_find + all_of (C++11) + any_of (C++11) + binary_search + clamp (C++17) + copy + copy_backward + copy_if (C++11) + copy_n (C++11) + count + count_if + equal + equal_range + fill + fill_n + find + find_end + find_first_of + find_if + find_if_not (C++11) + for_each + generate + generate_n + includes + inplace_merge + is_heap (C++11) + is_heap_until (C++11) + is_partitioned (C++11) + is_sorted (C++11) + is_sorted_until (C++11) + iter_swap + lexicographical_compare + lower_bound + make_heap + max + max_element + merge + min + min_element + minmax (C++11) + minmax_element (C++11) + mismatch + next_permutation + none_of (C++11) + nth_element + partial_sort + partial_sort_copy + partition + partition_copy (C++11) + partition_point (C++11) + pop_heap + prev_permutation + push_heap + random_shuffle + remove + remove_copy + remove_copy_if + remove_if + replace + replace_copy + replace_copy_if + replace_if + reverse + reverse_copy + rotate + rotate_copy + search + search_n + set_difference + set_intersection + set_symmetric_difference + set_union + shuffle (C++11) + sort + sort_heap + stable_partition + stable_sort + swap + swap_ranges + transform + unique + unique_copy + upper_bound + */ + + /** + * @defgroup algorithms Algorithms + * + * Components for performing algorithmic operations. Includes + * non-modifying sequence, modifying (mutating) sequence, sorting, + * searching, merge, partition, heap, set, minima, maxima, and + * permutation operations. + */ + + /** + * @defgroup mutating_algorithms Mutating + * @ingroup algorithms + */ + + /** + * @defgroup non_mutating_algorithms Non-Mutating + * @ingroup algorithms + */ + + /** + * @defgroup sorting_algorithms Sorting + * @ingroup algorithms + */ + + /** + * @defgroup set_algorithms Set Operations + * @ingroup sorting_algorithms + * + * These algorithms are common set operations performed on sequences + * that are already sorted. The number of comparisons will be + * linear. + */ + + /** + * @defgroup binary_search_algorithms Binary Search + * @ingroup sorting_algorithms + * + * These algorithms are variations of a classic binary search, and + * all assume that the sequence being searched is already sorted. + * + * The number of comparisons will be logarithmic (and as few as + * possible). The number of steps through the sequence will be + * logarithmic for random-access iterators (e.g., pointers), and + * linear otherwise. + * + * The LWG has passed Defect Report 270, which notes: The + * proposed resolution reinterprets binary search. Instead of + * thinking about searching for a value in a sorted range, we view + * that as an important special case of a more general algorithm: + * searching for the partition point in a partitioned range. We + * also add a guarantee that the old wording did not: we ensure that + * the upper bound is no earlier than the lower bound, that the pair + * returned by equal_range is a valid range, and that the first part + * of that pair is the lower bound. + * + * The actual effect of the first sentence is that a comparison + * functor passed by the user doesn't necessarily need to induce a + * strict weak ordering relation. Rather, it partitions the range. + */ + + // adjacent_find + +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_algorithms 201806L +#endif + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + all_of(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + bool + any_of(_IIter, _IIter, _Predicate); +#endif + + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_FIter, _FIter, const _Tp&, _Compare); + +#if __cplusplus > 201402L + template + _GLIBCXX14_CONSTEXPR + const _Tp& + clamp(const _Tp&, const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + clamp(const _Tp&, const _Tp&, const _Tp&, _Compare); +#endif + + template + _GLIBCXX20_CONSTEXPR + _OIter + copy(_IIter, _IIter, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _BIter2 + copy_backward(_BIter1, _BIter1, _BIter2); + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + _OIter + copy_if(_IIter, _IIter, _OIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _OIter + copy_n(_IIter, _Size, _OIter); +#endif + + // count + // count_if + + template + _GLIBCXX20_CONSTEXPR + pair<_FIter, _FIter> + equal_range(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + pair<_FIter, _FIter> + equal_range(_FIter, _FIter, const _Tp&, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + fill(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _OIter + fill_n(_OIter, _Size, const _Tp&); + + // find + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_end(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + // find_first_of + // find_if + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + _IIter + find_if_not(_IIter, _IIter, _Predicate); +#endif + + // for_each + // generate + // generate_n + + template + _GLIBCXX20_CONSTEXPR + bool + includes(_IIter1, _IIter1, _IIter2, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); + + template + void + inplace_merge(_BIter, _BIter, _BIter); + + template + void + inplace_merge(_BIter, _BIter, _BIter, _Compare); + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + is_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + bool + is_heap(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _RAIter + is_heap_until(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + _RAIter + is_heap_until(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + bool + is_partitioned(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + bool + is_permutation(_FIter1, _FIter1, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + is_permutation(_FIter1, _FIter1, _FIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + bool + is_sorted(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + bool + is_sorted(_FIter, _FIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _FIter + is_sorted_until(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + _FIter + is_sorted_until(_FIter, _FIter, _Compare); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + iter_swap(_FIter1, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter + lower_bound(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + lower_bound(_FIter, _FIter, const _Tp&, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + make_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + make_heap(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + max(const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + max(const _Tp&, const _Tp&, _Compare); + + // max_element + // merge + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + min(const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + const _Tp& + min(const _Tp&, const _Tp&, _Compare); + + // min_element + +#if __cplusplus >= 201103L + template + _GLIBCXX14_CONSTEXPR + pair + minmax(const _Tp&, const _Tp&); + + template + _GLIBCXX14_CONSTEXPR + pair + minmax(const _Tp&, const _Tp&, _Compare); + + template + _GLIBCXX14_CONSTEXPR + pair<_FIter, _FIter> + minmax_element(_FIter, _FIter); + + template + _GLIBCXX14_CONSTEXPR + pair<_FIter, _FIter> + minmax_element(_FIter, _FIter, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _Tp + min(initializer_list<_Tp>); + + template + _GLIBCXX14_CONSTEXPR + _Tp + min(initializer_list<_Tp>, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _Tp + max(initializer_list<_Tp>); + + template + _GLIBCXX14_CONSTEXPR + _Tp + max(initializer_list<_Tp>, _Compare); + + template + _GLIBCXX14_CONSTEXPR + pair<_Tp, _Tp> + minmax(initializer_list<_Tp>); + + template + _GLIBCXX14_CONSTEXPR + pair<_Tp, _Tp> + minmax(initializer_list<_Tp>, _Compare); +#endif + + // mismatch + + template + _GLIBCXX20_CONSTEXPR + bool + next_permutation(_BIter, _BIter); + + template + _GLIBCXX20_CONSTEXPR + bool + next_permutation(_BIter, _BIter, _Compare); + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + none_of(_IIter, _IIter, _Predicate); +#endif + + // nth_element + // partial_sort + + template + _GLIBCXX20_CONSTEXPR + _RAIter + partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + _RAIter + partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare); + + // partition + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + pair<_OIter1, _OIter2> + partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _FIter + partition_point(_FIter, _FIter, _Predicate); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + pop_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + pop_heap(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + bool + prev_permutation(_BIter, _BIter); + + template + _GLIBCXX20_CONSTEXPR + bool + prev_permutation(_BIter, _BIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + push_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + push_heap(_RAIter, _RAIter, _Compare); + + // random_shuffle + + template + _GLIBCXX20_CONSTEXPR + _FIter + remove(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + remove_if(_FIter, _FIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _OIter + remove_copy(_IIter, _IIter, _OIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _OIter + remove_copy_if(_IIter, _IIter, _OIter, _Predicate); + + // replace + + template + _GLIBCXX20_CONSTEXPR + _OIter + replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _OIter + replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); + + // replace_if + + template + _GLIBCXX20_CONSTEXPR + void + reverse(_BIter, _BIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + reverse_copy(_BIter, _BIter, _OIter); + + inline namespace _V2 + { + template + _GLIBCXX20_CONSTEXPR + _FIter + rotate(_FIter, _FIter, _FIter); + } + + template + _GLIBCXX20_CONSTEXPR + _OIter + rotate_copy(_FIter, _FIter, _FIter, _OIter); + + // search + // search_n + // set_difference + // set_intersection + // set_symmetric_difference + // set_union + +#if (__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99_STDINT_TR1) + template + void + shuffle(_RAIter, _RAIter, _UGenerator&&); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + sort_heap(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + sort_heap(_RAIter, _RAIter, _Compare); + + template + _BIter + stable_partition(_BIter, _BIter, _Predicate); + +#if __cplusplus < 201103L + // For C++11 swap() is declared in . + + template + _GLIBCXX20_CONSTEXPR + inline void + swap(_Tp& __a, _Tp& __b); + + template + _GLIBCXX20_CONSTEXPR + inline void + swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]); +#endif + + template + _GLIBCXX20_CONSTEXPR + _FIter2 + swap_ranges(_FIter1, _FIter1, _FIter2); + + // transform + + template + _GLIBCXX20_CONSTEXPR + _FIter + unique(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + _FIter + unique(_FIter, _FIter, _BinaryPredicate); + + // unique_copy + + template + _GLIBCXX20_CONSTEXPR + _FIter + upper_bound(_FIter, _FIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + upper_bound(_FIter, _FIter, const _Tp&, _Compare); + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + + template + _GLIBCXX20_CONSTEXPR + _FIter + adjacent_find(_FIter, _FIter); + + template + _GLIBCXX20_CONSTEXPR + _FIter + adjacent_find(_FIter, _FIter, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + typename iterator_traits<_IIter>::difference_type + count(_IIter, _IIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + typename iterator_traits<_IIter>::difference_type + count_if(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + bool + equal(_IIter1, _IIter1, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _IIter + find(_IIter, _IIter, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _IIter + find_if(_IIter, _IIter, _Predicate); + + template + _GLIBCXX20_CONSTEXPR + _Funct + for_each(_IIter, _IIter, _Funct); + + template + _GLIBCXX20_CONSTEXPR + void + generate(_FIter, _FIter, _Generator); + + template + _GLIBCXX20_CONSTEXPR + _OIter + generate_n(_OIter, _Size, _Generator); + + template + _GLIBCXX20_CONSTEXPR + bool + lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + bool + lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _FIter + max_element(_FIter, _FIter); + + template + _GLIBCXX14_CONSTEXPR + _FIter + max_element(_FIter, _FIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX14_CONSTEXPR + _FIter + min_element(_FIter, _FIter); + + template + _GLIBCXX14_CONSTEXPR + _FIter + min_element(_FIter, _FIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + pair<_IIter1, _IIter2> + mismatch(_IIter1, _IIter1, _IIter2); + + template + _GLIBCXX20_CONSTEXPR + pair<_IIter1, _IIter2> + mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + void + nth_element(_RAIter, _RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + nth_element(_RAIter, _RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + partial_sort(_RAIter, _RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + partial_sort(_RAIter, _RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _BIter + partition(_BIter, _BIter, _Predicate); + + template + void + random_shuffle(_RAIter, _RAIter); + + template + void + random_shuffle(_RAIter, _RAIter, +#if __cplusplus >= 201103L + _Generator&&); +#else + _Generator&); +#endif + + template + _GLIBCXX20_CONSTEXPR + void + replace(_FIter, _FIter, const _Tp&, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + void + replace_if(_FIter, _FIter, _Predicate, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + search(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _GLIBCXX20_CONSTEXPR + _FIter1 + search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _FIter + search_n(_FIter, _FIter, _Size, const _Tp&); + + template + _GLIBCXX20_CONSTEXPR + _FIter + search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, + _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + void + sort(_RAIter, _RAIter); + + template + _GLIBCXX20_CONSTEXPR + void + sort(_RAIter, _RAIter, _Compare); + + template + void + stable_sort(_RAIter, _RAIter); + + template + void + stable_sort(_RAIter, _RAIter, _Compare); + + template + _GLIBCXX20_CONSTEXPR + _OIter + transform(_IIter, _IIter, _OIter, _UnaryOperation); + + template + _GLIBCXX20_CONSTEXPR + _OIter + transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); + + template + _GLIBCXX20_CONSTEXPR + _OIter + unique_copy(_IIter, _IIter, _OIter); + + template + _GLIBCXX20_CONSTEXPR + _OIter + unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); + +_GLIBCXX_END_NAMESPACE_ALGO +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#endif + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/align.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/align.h new file mode 100755 index 0000000..eabdaa6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/align.h @@ -0,0 +1,111 @@ +// align implementation -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/align.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _GLIBCXX_ALIGN_H +#define _GLIBCXX_ALIGN_H 1 + +#include + +#include // std::has_single_bit +#include // uintptr_t +#include // _GLIBCXX_DEBUG_ASSERT + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @brief Fit aligned storage in buffer. + * + * This function tries to fit @a __size bytes of storage with alignment + * @a __align into the buffer @a __ptr of size @a __space bytes. If such + * a buffer fits then @a __ptr is changed to point to the first byte of the + * aligned storage and @a __space is reduced by the bytes used for alignment. + * + * C++11 20.6.5 [ptr.align] + * + * @param __align A fundamental or extended alignment value. + * @param __size Size of the aligned storage required. + * @param __ptr Pointer to a buffer of @a __space bytes. + * @param __space Size of the buffer pointed to by @a __ptr. + * @return the updated pointer if the aligned storage fits, otherwise nullptr. + * + * @ingroup memory + */ +inline void* +align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept +{ + if (__space < __size) + return nullptr; + const auto __intptr = reinterpret_cast(__ptr); + const auto __aligned = (__intptr - 1u + __align) & -__align; + const auto __diff = __aligned - __intptr; + if (__diff > (__space - __size)) + return nullptr; + else + { + __space -= __diff; + return __ptr = reinterpret_cast(__aligned); + } +} + +#if __cplusplus > 201703L +#define __cpp_lib_assume_aligned 201811L + /** @brief Inform the compiler that a pointer is aligned. + * + * @tparam _Align An alignment value (i.e. a power of two) + * @tparam _Tp An object type + * @param __ptr A pointer that is aligned to _Align + * + * C++20 20.10.6 [ptr.align] + * + * @ingroup memory + */ + template + [[nodiscard,__gnu__::__always_inline__]] + constexpr _Tp* + assume_aligned(_Tp* __ptr) noexcept + { + static_assert(std::has_single_bit(_Align)); + if (std::is_constant_evaluated()) + return __ptr; + else + { + // This function is expected to be used in hot code, where + // __glibcxx_assert would add unwanted overhead. + _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0); + return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); + } + } +#endif // C++2a + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GLIBCXX_ALIGN_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/alloc_traits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/alloc_traits.h new file mode 100755 index 0000000..3441258 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/alloc_traits.h @@ -0,0 +1,751 @@ +// Allocator traits -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/alloc_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _ALLOC_TRAITS_H +#define _ALLOC_TRAITS_H 1 + +#include +#include +#if __cplusplus >= 201103L +# include +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201103L +#define __cpp_lib_allocator_traits_is_always_equal 201411 + + struct __allocator_traits_base + { + template + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + + template + struct __rebind<_Tp, _Up, + __void_t::other>> + { using type = typename _Tp::template rebind<_Up>::other; }; + + protected: + template + using __pointer = typename _Tp::pointer; + template + using __c_pointer = typename _Tp::const_pointer; + template + using __v_pointer = typename _Tp::void_pointer; + template + using __cv_pointer = typename _Tp::const_void_pointer; + template + using __pocca = typename _Tp::propagate_on_container_copy_assignment; + template + using __pocma = typename _Tp::propagate_on_container_move_assignment; + template + using __pocs = typename _Tp::propagate_on_container_swap; + template + using __equal = typename _Tp::is_always_equal; + }; + + template + using __alloc_rebind + = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type; + + /** + * @brief Uniform interface to all allocator types. + * @ingroup allocators + */ + template + struct allocator_traits : __allocator_traits_base + { + /// The allocator type + typedef _Alloc allocator_type; + /// The allocated type + typedef typename _Alloc::value_type value_type; + + /** + * @brief The allocator's pointer type. + * + * @c Alloc::pointer if that type exists, otherwise @c value_type* + */ + using pointer = __detected_or_t; + + private: + // Select _Func<_Alloc> or pointer_traits::rebind<_Tp> + template class _Func, typename _Tp, typename = void> + struct _Ptr + { + using type = typename pointer_traits::template rebind<_Tp>; + }; + + template class _Func, typename _Tp> + struct _Ptr<_Func, _Tp, __void_t<_Func<_Alloc>>> + { + using type = _Func<_Alloc>; + }; + + // Select _A2::difference_type or pointer_traits<_Ptr>::difference_type + template + struct _Diff + { using type = typename pointer_traits<_PtrT>::difference_type; }; + + template + struct _Diff<_A2, _PtrT, __void_t> + { using type = typename _A2::difference_type; }; + + // Select _A2::size_type or make_unsigned<_DiffT>::type + template + struct _Size : make_unsigned<_DiffT> { }; + + template + struct _Size<_A2, _DiffT, __void_t> + { using type = typename _A2::size_type; }; + + public: + /** + * @brief The allocator's const pointer type. + * + * @c Alloc::const_pointer if that type exists, otherwise + * pointer_traits::rebind + */ + using const_pointer = typename _Ptr<__c_pointer, const value_type>::type; + + /** + * @brief The allocator's void pointer type. + * + * @c Alloc::void_pointer if that type exists, otherwise + * pointer_traits::rebind + */ + using void_pointer = typename _Ptr<__v_pointer, void>::type; + + /** + * @brief The allocator's const void pointer type. + * + * @c Alloc::const_void_pointer if that type exists, otherwise + * pointer_traits::rebind + */ + using const_void_pointer = typename _Ptr<__cv_pointer, const void>::type; + + /** + * @brief The allocator's difference type + * + * @c Alloc::difference_type if that type exists, otherwise + * pointer_traits::difference_type + */ + using difference_type = typename _Diff<_Alloc, pointer>::type; + + /** + * @brief The allocator's size type + * + * @c Alloc::size_type if that type exists, otherwise + * make_unsigned::type + */ + using size_type = typename _Size<_Alloc, difference_type>::type; + + /** + * @brief How the allocator is propagated on copy assignment + * + * @c Alloc::propagate_on_container_copy_assignment if that type exists, + * otherwise @c false_type + */ + using propagate_on_container_copy_assignment + = __detected_or_t; + + /** + * @brief How the allocator is propagated on move assignment + * + * @c Alloc::propagate_on_container_move_assignment if that type exists, + * otherwise @c false_type + */ + using propagate_on_container_move_assignment + = __detected_or_t; + + /** + * @brief How the allocator is propagated on swap + * + * @c Alloc::propagate_on_container_swap if that type exists, + * otherwise @c false_type + */ + using propagate_on_container_swap + = __detected_or_t; + + /** + * @brief Whether all instances of the allocator type compare equal. + * + * @c Alloc::is_always_equal if that type exists, + * otherwise @c is_empty::type + */ + using is_always_equal + = __detected_or_t::type, __equal, _Alloc>; + + template + using rebind_alloc = __alloc_rebind<_Alloc, _Tp>; + template + using rebind_traits = allocator_traits>; + + private: + template + static constexpr auto + _S_allocate(_Alloc2& __a, size_type __n, const_void_pointer __hint, int) + -> decltype(__a.allocate(__n, __hint)) + { return __a.allocate(__n, __hint); } + + template + static constexpr pointer + _S_allocate(_Alloc2& __a, size_type __n, const_void_pointer, ...) + { return __a.allocate(__n); } + + template + struct __construct_helper + { + template()->construct( + std::declval<_Tp*>(), std::declval<_Args>()...))> + static true_type __test(int); + + template + static false_type __test(...); + + using type = decltype(__test<_Alloc>(0)); + }; + + template + using __has_construct + = typename __construct_helper<_Tp, _Args...>::type; + + template + static _GLIBCXX14_CONSTEXPR _Require<__has_construct<_Tp, _Args...>> + _S_construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + noexcept(noexcept(__a.construct(__p, std::forward<_Args>(__args)...))) + { __a.construct(__p, std::forward<_Args>(__args)...); } + + template + static _GLIBCXX14_CONSTEXPR + _Require<__and_<__not_<__has_construct<_Tp, _Args...>>, + is_constructible<_Tp, _Args...>>> + _S_construct(_Alloc&, _Tp* __p, _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Tp, _Args...>::value) + { +#if __cplusplus <= 201703L + ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); +#else + std::construct_at(__p, std::forward<_Args>(__args)...); +#endif + } + + template + static _GLIBCXX14_CONSTEXPR auto + _S_destroy(_Alloc2& __a, _Tp* __p, int) + noexcept(noexcept(__a.destroy(__p))) + -> decltype(__a.destroy(__p)) + { __a.destroy(__p); } + + template + static _GLIBCXX14_CONSTEXPR void + _S_destroy(_Alloc2&, _Tp* __p, ...) + noexcept(std::is_nothrow_destructible<_Tp>::value) + { std::_Destroy(__p); } + + template + static constexpr auto + _S_max_size(_Alloc2& __a, int) + -> decltype(__a.max_size()) + { return __a.max_size(); } + + template + static constexpr size_type + _S_max_size(_Alloc2&, ...) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2466. allocator_traits::max_size() default behavior is incorrect + return __gnu_cxx::__numeric_traits::__max + / sizeof(value_type); + } + + template + static constexpr auto + _S_select(_Alloc2& __a, int) + -> decltype(__a.select_on_container_copy_construction()) + { return __a.select_on_container_copy_construction(); } + + template + static constexpr _Alloc2 + _S_select(_Alloc2& __a, ...) + { return __a; } + + public: + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * + * Calls @c a.allocate(n) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(_Alloc& __a, size_type __n) + { return __a.allocate(__n); } + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * @param __hint Aid to locality. + * @return Memory of suitable size and alignment for @a n objects + * of type @c value_type + * + * Returns a.allocate(n, hint) if that expression is + * well-formed, otherwise returns @c a.allocate(n) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(_Alloc& __a, size_type __n, const_void_pointer __hint) + { return _S_allocate(__a, __n, __hint, 0); } + + /** + * @brief Deallocate memory. + * @param __a An allocator. + * @param __p Pointer to the memory to deallocate. + * @param __n The number of objects space was allocated for. + * + * Calls a.deallocate(p, n) + */ + static _GLIBCXX20_CONSTEXPR void + deallocate(_Alloc& __a, pointer __p, size_type __n) + { __a.deallocate(__p, __n); } + + /** + * @brief Construct an object of type `_Tp` + * @param __a An allocator. + * @param __p Pointer to memory of suitable size and alignment for Tp + * @param __args Constructor arguments. + * + * Calls __a.construct(__p, std::forward(__args)...) + * if that expression is well-formed, otherwise uses placement-new + * to construct an object of type @a _Tp at location @a __p from the + * arguments @a __args... + */ + template + static _GLIBCXX20_CONSTEXPR auto + construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + noexcept(noexcept(_S_construct(__a, __p, + std::forward<_Args>(__args)...))) + -> decltype(_S_construct(__a, __p, std::forward<_Args>(__args)...)) + { _S_construct(__a, __p, std::forward<_Args>(__args)...); } + + /** + * @brief Destroy an object of type @a _Tp + * @param __a An allocator. + * @param __p Pointer to the object to destroy + * + * Calls @c __a.destroy(__p) if that expression is well-formed, + * otherwise calls @c __p->~_Tp() + */ + template + static _GLIBCXX20_CONSTEXPR void + destroy(_Alloc& __a, _Tp* __p) + noexcept(noexcept(_S_destroy(__a, __p, 0))) + { _S_destroy(__a, __p, 0); } + + /** + * @brief The maximum supported allocation size + * @param __a An allocator. + * @return @c __a.max_size() or @c numeric_limits::max() + * + * Returns @c __a.max_size() if that expression is well-formed, + * otherwise returns @c numeric_limits::max() + */ + static _GLIBCXX20_CONSTEXPR size_type + max_size(const _Alloc& __a) noexcept + { return _S_max_size(__a, 0); } + + /** + * @brief Obtain an allocator to use when copying a container. + * @param __rhs An allocator. + * @return @c __rhs.select_on_container_copy_construction() or @a __rhs + * + * Returns @c __rhs.select_on_container_copy_construction() if that + * expression is well-formed, otherwise returns @a __rhs + */ + static _GLIBCXX20_CONSTEXPR _Alloc + select_on_container_copy_construction(const _Alloc& __rhs) + { return _S_select(__rhs, 0); } + }; + +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_dynamic_alloc 201907L +#endif + + /// Partial specialization for std::allocator. + template + struct allocator_traits> + { + /// The allocator type + using allocator_type = allocator<_Tp>; + + /// The allocated type + using value_type = _Tp; + + /// The allocator's pointer type. + using pointer = _Tp*; + + /// The allocator's const pointer type. + using const_pointer = const _Tp*; + + /// The allocator's void pointer type. + using void_pointer = void*; + + /// The allocator's const void pointer type. + using const_void_pointer = const void*; + + /// The allocator's difference type + using difference_type = std::ptrdiff_t; + + /// The allocator's size type + using size_type = std::size_t; + + /// How the allocator is propagated on copy assignment + using propagate_on_container_copy_assignment = false_type; + + /// How the allocator is propagated on move assignment + using propagate_on_container_move_assignment = true_type; + + /// How the allocator is propagated on swap + using propagate_on_container_swap = false_type; + + /// Whether all instances of the allocator type compare equal. + using is_always_equal = true_type; + + template + using rebind_alloc = allocator<_Up>; + + template + using rebind_traits = allocator_traits>; + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * + * Calls @c a.allocate(n) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(allocator_type& __a, size_type __n) + { return __a.allocate(__n); } + + /** + * @brief Allocate memory. + * @param __a An allocator. + * @param __n The number of objects to allocate space for. + * @param __hint Aid to locality. + * @return Memory of suitable size and alignment for @a n objects + * of type @c value_type + * + * Returns a.allocate(n, hint) + */ + _GLIBCXX_NODISCARD static _GLIBCXX20_CONSTEXPR pointer + allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) + { +#if __cplusplus <= 201703L + return __a.allocate(__n, __hint); +#else + return __a.allocate(__n); +#endif + } + + /** + * @brief Deallocate memory. + * @param __a An allocator. + * @param __p Pointer to the memory to deallocate. + * @param __n The number of objects space was allocated for. + * + * Calls a.deallocate(p, n) + */ + static _GLIBCXX20_CONSTEXPR void + deallocate(allocator_type& __a, pointer __p, size_type __n) + { __a.deallocate(__p, __n); } + + /** + * @brief Construct an object of type `_Up` + * @param __a An allocator. + * @param __p Pointer to memory of suitable size and alignment for + * an object of type `_Up`. + * @param __args Constructor arguments. + * + * Calls `__a.construct(__p, std::forward<_Args>(__args)...)` + * in C++11, C++14 and C++17. Changed in C++20 to call + * `std::construct_at(__p, std::forward<_Args>(__args)...)` instead. + */ + template + static _GLIBCXX20_CONSTEXPR void + construct(allocator_type& __a __attribute__((__unused__)), _Up* __p, + _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Up, _Args...>::value) + { +#if __cplusplus <= 201703L + __a.construct(__p, std::forward<_Args>(__args)...); +#else + std::construct_at(__p, std::forward<_Args>(__args)...); +#endif + } + + /** + * @brief Destroy an object of type @a _Up + * @param __a An allocator. + * @param __p Pointer to the object to destroy + * + * Calls @c __a.destroy(__p). + */ + template + static _GLIBCXX20_CONSTEXPR void + destroy(allocator_type& __a __attribute__((__unused__)), _Up* __p) + noexcept(is_nothrow_destructible<_Up>::value) + { +#if __cplusplus <= 201703L + __a.destroy(__p); +#else + std::destroy_at(__p); +#endif + } + + /** + * @brief The maximum supported allocation size + * @param __a An allocator. + * @return @c __a.max_size() + */ + static _GLIBCXX20_CONSTEXPR size_type + max_size(const allocator_type& __a __attribute__((__unused__))) noexcept + { +#if __cplusplus <= 201703L + return __a.max_size(); +#else + return size_t(-1) / sizeof(value_type); +#endif + } + + /** + * @brief Obtain an allocator to use when copying a container. + * @param __rhs An allocator. + * @return @c __rhs + */ + static _GLIBCXX20_CONSTEXPR allocator_type + select_on_container_copy_construction(const allocator_type& __rhs) + { return __rhs; } + }; + +#if __cplusplus < 201703L + template + inline void + __do_alloc_on_copy(_Alloc& __one, const _Alloc& __two, true_type) + { __one = __two; } + + template + inline void + __do_alloc_on_copy(_Alloc&, const _Alloc&, false_type) + { } +#endif + + template + _GLIBCXX14_CONSTEXPR inline void + __alloc_on_copy(_Alloc& __one, const _Alloc& __two) + { + typedef allocator_traits<_Alloc> __traits; + typedef typename __traits::propagate_on_container_copy_assignment __pocca; +#if __cplusplus >= 201703L + if constexpr (__pocca::value) + __one = __two; +#else + __do_alloc_on_copy(__one, __two, __pocca()); +#endif + } + + template + constexpr _Alloc + __alloc_on_copy(const _Alloc& __a) + { + typedef allocator_traits<_Alloc> __traits; + return __traits::select_on_container_copy_construction(__a); + } + +#if __cplusplus < 201703L + template + inline void __do_alloc_on_move(_Alloc& __one, _Alloc& __two, true_type) + { __one = std::move(__two); } + + template + inline void __do_alloc_on_move(_Alloc&, _Alloc&, false_type) + { } +#endif + + template + _GLIBCXX14_CONSTEXPR inline void + __alloc_on_move(_Alloc& __one, _Alloc& __two) + { + typedef allocator_traits<_Alloc> __traits; + typedef typename __traits::propagate_on_container_move_assignment __pocma; +#if __cplusplus >= 201703L + if constexpr (__pocma::value) + __one = std::move(__two); +#else + __do_alloc_on_move(__one, __two, __pocma()); +#endif + } + +#if __cplusplus < 201703L + template + inline void __do_alloc_on_swap(_Alloc& __one, _Alloc& __two, true_type) + { + using std::swap; + swap(__one, __two); + } + + template + inline void __do_alloc_on_swap(_Alloc&, _Alloc&, false_type) + { } +#endif + + template + _GLIBCXX14_CONSTEXPR inline void + __alloc_on_swap(_Alloc& __one, _Alloc& __two) + { + typedef allocator_traits<_Alloc> __traits; + typedef typename __traits::propagate_on_container_swap __pocs; +#if __cplusplus >= 201703L + if constexpr (__pocs::value) + { + using std::swap; + swap(__one, __two); + } +#else + __do_alloc_on_swap(__one, __two, __pocs()); +#endif + } + + template, + typename = void> + struct __is_alloc_insertable_impl + : false_type + { }; + + template + struct __is_alloc_insertable_impl<_Alloc, _Tp, _ValueT, + __void_t::construct( + std::declval<_Alloc&>(), std::declval<_ValueT*>(), + std::declval<_Tp>()))>> + : true_type + { }; + + // true if _Alloc::value_type is CopyInsertable into containers using _Alloc + // (might be wrong if _Alloc::construct exists but is not constrained, + // i.e. actually trying to use it would still be invalid. Use with caution.) + template + struct __is_copy_insertable + : __is_alloc_insertable_impl<_Alloc, + typename _Alloc::value_type const&>::type + { }; + + // std::allocator<_Tp> just requires CopyConstructible + template + struct __is_copy_insertable> + : is_copy_constructible<_Tp> + { }; + + // true if _Alloc::value_type is MoveInsertable into containers using _Alloc + // (might be wrong if _Alloc::construct exists but is not constrained, + // i.e. actually trying to use it would still be invalid. Use with caution.) + template + struct __is_move_insertable + : __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type + { }; + + // std::allocator<_Tp> just requires MoveConstructible + template + struct __is_move_insertable> + : is_move_constructible<_Tp> + { }; + + // Trait to detect Allocator-like types. + template + struct __is_allocator : false_type { }; + + template + struct __is_allocator<_Alloc, + __void_t().allocate(size_t{}))>> + : true_type { }; + + template + using _RequireAllocator + = typename enable_if<__is_allocator<_Alloc>::value, _Alloc>::type; + + template + using _RequireNotAllocator + = typename enable_if::value, _Alloc>::type; + +#if __cpp_concepts >= 201907L + template + concept __allocator_like = requires (_Alloc& __a) { + typename _Alloc::value_type; + __a.deallocate(__a.allocate(1u), 1u); + }; +#endif +#endif // C++11 + + /** + * Destroy a range of objects using the supplied allocator. For + * non-default allocators we do not optimize away invocation of + * destroy() even if _Tp has a trivial destructor. + */ + + template + void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + _Allocator& __alloc) + { + for (; __first != __last; ++__first) +#if __cplusplus < 201103L + __alloc.destroy(std::__addressof(*__first)); +#else + allocator_traits<_Allocator>::destroy(__alloc, + std::__addressof(*__first)); +#endif + } + + template + inline void + _Destroy(_ForwardIterator __first, _ForwardIterator __last, + allocator<_Tp>&) + { + _Destroy(__first, __last); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // _ALLOC_TRAITS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/allocated_ptr.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/allocated_ptr.h new file mode 100755 index 0000000..340964e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/allocated_ptr.h @@ -0,0 +1,104 @@ +// Guarded Allocation -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/allocated_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _ALLOCATED_PTR_H +#define _ALLOCATED_PTR_H 1 + +#if __cplusplus < 201103L +# include +#else +# include +# include +# include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Non-standard RAII type for managing pointers obtained from allocators. + template + struct __allocated_ptr + { + using pointer = typename allocator_traits<_Alloc>::pointer; + using value_type = typename allocator_traits<_Alloc>::value_type; + + /// Take ownership of __ptr + __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept + : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr) + { } + + /// Convert __ptr to allocator's pointer type and take ownership of it + template>> + __allocated_ptr(_Alloc& __a, _Ptr __ptr) + : _M_alloc(std::__addressof(__a)), + _M_ptr(pointer_traits::pointer_to(*__ptr)) + { } + + /// Transfer ownership of the owned pointer + __allocated_ptr(__allocated_ptr&& __gd) noexcept + : _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr) + { __gd._M_ptr = nullptr; } + + /// Deallocate the owned pointer + ~__allocated_ptr() + { + if (_M_ptr != nullptr) + std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1); + } + + /// Release ownership of the owned pointer + __allocated_ptr& + operator=(std::nullptr_t) noexcept + { + _M_ptr = nullptr; + return *this; + } + + /// Get the address that the owned pointer refers to. + value_type* get() { return std::__to_address(_M_ptr); } + + private: + _Alloc* _M_alloc; + pointer _M_ptr; + }; + + /// Allocate space for a single object using __a + template + __allocated_ptr<_Alloc> + __allocate_guarded(_Alloc& __a) + { + return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) }; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/allocator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/allocator.h new file mode 100755 index 0000000..396872f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/allocator.h @@ -0,0 +1,351 @@ +// Allocators -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996-1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/allocator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _ALLOCATOR_H +#define _ALLOCATOR_H 1 + +#include // Define the base class to std::allocator. +#include +#if __cplusplus >= 201103L +#include +#endif + +#define __cpp_lib_incomplete_container_elements 201505 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup allocators + * @{ + */ + + // Since C++20 the primary template should be used for allocator, + // but then it would have a non-trivial default ctor and dtor, which + // would be an ABI change. So C++20 still uses the allocator explicit + // specialization, with the historical ABI properties, but with the same + // members that are present in the primary template. + +#if ! _GLIBCXX_INLINE_VERSION + /// allocator specialization. + template<> + class allocator + { + public: + typedef void value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +#if __cplusplus <= 201703L + // These were removed for C++20. + typedef void* pointer; + typedef const void* const_pointer; + + template + struct rebind + { typedef allocator<_Tp1> other; }; +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2103. std::allocator propagate_on_container_move_assignment + using propagate_on_container_move_assignment = true_type; + + using is_always_equal + _GLIBCXX20_DEPRECATED_SUGGEST("allocator_traits::is_always_equal") + = true_type; + +#if __cplusplus >= 202002L + allocator() = default; + + template + constexpr + allocator(const allocator<_Up>&) noexcept { } + + // No allocate member because it's ill-formed by LWG 3307. + // No deallocate member because it would be undefined to call it + // with any pointer which wasn't obtained from allocate. + +#else // ! C++20 + private: + // This uses construct and destroy in C++11/14/17 modes. + friend allocator_traits>; + + template + void + construct(_Up* __p, _Args&&... __args) + noexcept(std::is_nothrow_constructible<_Up, _Args...>::value) + { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } + + template + void + destroy(_Up* __p) + noexcept(std::is_nothrow_destructible<_Up>::value) + { __p->~_Up(); } +#endif // C++17 +#endif // C++11 + + }; +#endif // ! _GLIBCXX_INLINE_VERSION + + /** + * @brief The @a standard allocator, as per C++03 [20.4.1]. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator + * for further details. + * + * @tparam _Tp Type of allocated object. + */ + template + class allocator : public __allocator_base<_Tp> + { + public: + typedef _Tp value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +#if __cplusplus <= 201703L + // These were removed for C++20. + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + + template + struct rebind + { typedef allocator<_Tp1> other; }; +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2103. std::allocator propagate_on_container_move_assignment + using propagate_on_container_move_assignment = true_type; + + using is_always_equal + _GLIBCXX20_DEPRECATED_SUGGEST("allocator_traits::is_always_equal") + = true_type; +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3035. std::allocator's constructors should be constexpr + _GLIBCXX20_CONSTEXPR + allocator() _GLIBCXX_NOTHROW { } + + _GLIBCXX20_CONSTEXPR + allocator(const allocator& __a) _GLIBCXX_NOTHROW + : __allocator_base<_Tp>(__a) { } + +#if __cplusplus >= 201103L + // Avoid implicit deprecation. + allocator& operator=(const allocator&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR + allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { } + +#if __cpp_constexpr_dynamic_alloc + constexpr +#endif + ~allocator() _GLIBCXX_NOTHROW { } + +#if __cplusplus > 201703L + [[nodiscard,__gnu__::__always_inline__]] + constexpr _Tp* + allocate(size_t __n) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); +#endif + return __allocator_base<_Tp>::allocate(__n, 0); + } + + [[__gnu__::__always_inline__]] + constexpr void + deallocate(_Tp* __p, size_t __n) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + ::operator delete(__p); + return; + } +#endif + __allocator_base<_Tp>::deallocate(__p, __n); + } +#endif // C++20 + + friend _GLIBCXX20_CONSTEXPR bool + operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW + { return true; } + +#if __cpp_impl_three_way_comparison < 201907L + friend _GLIBCXX20_CONSTEXPR bool + operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW + { return false; } +#endif + + // Inherit everything else. + }; + + template + inline _GLIBCXX20_CONSTEXPR bool + operator==(const allocator<_T1>&, const allocator<_T2>&) + _GLIBCXX_NOTHROW + { return true; } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline _GLIBCXX20_CONSTEXPR bool + operator!=(const allocator<_T1>&, const allocator<_T2>&) + _GLIBCXX_NOTHROW + { return false; } +#endif + + // Invalid allocator partial specializations. + // allocator_traits::rebind_alloc can be used to form a valid allocator type. + template + class allocator + { + public: + typedef _Tp value_type; + template allocator(const allocator<_Up>&) { } + }; + + template + class allocator + { + public: + typedef _Tp value_type; + template allocator(const allocator<_Up>&) { } + }; + + template + class allocator + { + public: + typedef _Tp value_type; + template allocator(const allocator<_Up>&) { } + }; + + /// @} group allocator + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class allocator; + extern template class allocator; +#endif + + // Undefine. +#undef __allocator_base + + // To implement Option 3 of DR 431. + template + struct __alloc_swap + { static void _S_do_it(_Alloc&, _Alloc&) _GLIBCXX_NOEXCEPT { } }; + + template + struct __alloc_swap<_Alloc, false> + { + static void + _S_do_it(_Alloc& __one, _Alloc& __two) _GLIBCXX_NOEXCEPT + { + // Precondition: swappable allocators. + if (__one != __two) + swap(__one, __two); + } + }; + + // Optimize for stateless allocators. + template + struct __alloc_neq + { + static bool + _S_do_it(const _Alloc&, const _Alloc&) + { return false; } + }; + + template + struct __alloc_neq<_Alloc, false> + { + static bool + _S_do_it(const _Alloc& __one, const _Alloc& __two) + { return __one != __two; } + }; + +#if __cplusplus >= 201103L + template, + is_nothrow_move_constructible>::value> + struct __shrink_to_fit_aux + { static bool _S_do_it(_Tp&) noexcept { return false; } }; + + template + struct __shrink_to_fit_aux<_Tp, true> + { + static bool + _S_do_it(_Tp& __c) noexcept + { +#if __cpp_exceptions + try + { + _Tp(__make_move_if_noexcept_iterator(__c.begin()), + __make_move_if_noexcept_iterator(__c.end()), + __c.get_allocator()).swap(__c); + return true; + } + catch(...) + { return false; } +#else + return false; +#endif + } + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_base.h new file mode 100755 index 0000000..20cf134 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_base.h @@ -0,0 +1,1951 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_BASE_H +#define _GLIBCXX_ATOMIC_BASE_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include + +#if __cplusplus > 201703L +#include +#endif + +#ifndef _GLIBCXX_ALWAYS_INLINE +#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup atomics Atomics + * + * Components for performing atomic operations. + * @{ + */ + + /// Enumeration for memory_order +#if __cplusplus > 201703L + enum class memory_order : int + { + relaxed, + consume, + acquire, + release, + acq_rel, + seq_cst + }; + + inline constexpr memory_order memory_order_relaxed = memory_order::relaxed; + inline constexpr memory_order memory_order_consume = memory_order::consume; + inline constexpr memory_order memory_order_acquire = memory_order::acquire; + inline constexpr memory_order memory_order_release = memory_order::release; + inline constexpr memory_order memory_order_acq_rel = memory_order::acq_rel; + inline constexpr memory_order memory_order_seq_cst = memory_order::seq_cst; +#else + typedef enum memory_order + { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst + } memory_order; +#endif + + enum __memory_order_modifier + { + __memory_order_mask = 0x0ffff, + __memory_order_modifier_mask = 0xffff0000, + __memory_order_hle_acquire = 0x10000, + __memory_order_hle_release = 0x20000 + }; + + constexpr memory_order + operator|(memory_order __m, __memory_order_modifier __mod) + { + return memory_order(int(__m) | int(__mod)); + } + + constexpr memory_order + operator&(memory_order __m, __memory_order_modifier __mod) + { + return memory_order(int(__m) & int(__mod)); + } + + // Drop release ordering as per [atomics.types.operations.req]/21 + constexpr memory_order + __cmpexch_failure_order2(memory_order __m) noexcept + { + return __m == memory_order_acq_rel ? memory_order_acquire + : __m == memory_order_release ? memory_order_relaxed : __m; + } + + constexpr memory_order + __cmpexch_failure_order(memory_order __m) noexcept + { + return memory_order(__cmpexch_failure_order2(__m & __memory_order_mask) + | __memory_order_modifier(__m & __memory_order_modifier_mask)); + } + + _GLIBCXX_ALWAYS_INLINE void + atomic_thread_fence(memory_order __m) noexcept + { __atomic_thread_fence(int(__m)); } + + _GLIBCXX_ALWAYS_INLINE void + atomic_signal_fence(memory_order __m) noexcept + { __atomic_signal_fence(int(__m)); } + + /// kill_dependency + template + inline _Tp + kill_dependency(_Tp __y) noexcept + { + _Tp __ret(__y); + return __ret; + } + + // Base types for atomics. + template + struct __atomic_base; + +#if __cplusplus <= 201703L +# define _GLIBCXX20_INIT(I) +#else +# define __cpp_lib_atomic_value_initialization 201911L +# define _GLIBCXX20_INIT(I) = I +#endif + +#define ATOMIC_VAR_INIT(_VI) { _VI } + + template + struct atomic; + + template + struct atomic<_Tp*>; + + /* The target's "set" value for test-and-set may not be exactly 1. */ +#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1 + typedef bool __atomic_flag_data_type; +#else + typedef unsigned char __atomic_flag_data_type; +#endif + + /** + * @brief Base type for atomic_flag. + * + * Base type is POD with data, allowing atomic_flag to derive from + * it and meet the standard layout type requirement. In addition to + * compatibility with a C interface, this allows different + * implementations of atomic_flag to use the same atomic operation + * functions, via a standard conversion to the __atomic_flag_base + * argument. + */ + _GLIBCXX_BEGIN_EXTERN_C + + struct __atomic_flag_base + { + __atomic_flag_data_type _M_i _GLIBCXX20_INIT({}); + }; + + _GLIBCXX_END_EXTERN_C + +#define ATOMIC_FLAG_INIT { 0 } + + /// atomic_flag + struct atomic_flag : public __atomic_flag_base + { + atomic_flag() noexcept = default; + ~atomic_flag() noexcept = default; + atomic_flag(const atomic_flag&) = delete; + atomic_flag& operator=(const atomic_flag&) = delete; + atomic_flag& operator=(const atomic_flag&) volatile = delete; + + // Conversion to ATOMIC_FLAG_INIT. + constexpr atomic_flag(bool __i) noexcept + : __atomic_flag_base{ _S_init(__i) } + { } + + _GLIBCXX_ALWAYS_INLINE bool + test_and_set(memory_order __m = memory_order_seq_cst) noexcept + { + return __atomic_test_and_set (&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + test_and_set(memory_order __m = memory_order_seq_cst) volatile noexcept + { + return __atomic_test_and_set (&_M_i, int(__m)); + } + +#if __cplusplus > 201703L +#define __cpp_lib_atomic_flag_test 201907L + + _GLIBCXX_ALWAYS_INLINE bool + test(memory_order __m = memory_order_seq_cst) const noexcept + { + __atomic_flag_data_type __v; + __atomic_load(&_M_i, &__v, int(__m)); + return __v == __GCC_ATOMIC_TEST_AND_SET_TRUEVAL; + } + + _GLIBCXX_ALWAYS_INLINE bool + test(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + __atomic_flag_data_type __v; + __atomic_load(&_M_i, &__v, int(__m)); + return __v == __GCC_ATOMIC_TEST_AND_SET_TRUEVAL; + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(bool __old, + memory_order __m = memory_order_seq_cst) const noexcept + { + const __atomic_flag_data_type __v + = __old ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; + + std::__atomic_wait_address_v(&_M_i, __v, + [__m, this] { return __atomic_load_n(&_M_i, int(__m)); }); + } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { std::__atomic_notify_address(&_M_i, false); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { std::__atomic_notify_address(&_M_i, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait +#endif // C++20 + + _GLIBCXX_ALWAYS_INLINE void + clear(memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_consume); + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + + __atomic_clear (&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE void + clear(memory_order __m = memory_order_seq_cst) volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_consume); + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + + __atomic_clear (&_M_i, int(__m)); + } + + private: + static constexpr __atomic_flag_data_type + _S_init(bool __i) + { return __i ? __GCC_ATOMIC_TEST_AND_SET_TRUEVAL : 0; } + }; + + + /// Base class for atomic integrals. + // + // For each of the integral types, define atomic_[integral type] struct + // + // atomic_bool bool + // atomic_char char + // atomic_schar signed char + // atomic_uchar unsigned char + // atomic_short short + // atomic_ushort unsigned short + // atomic_int int + // atomic_uint unsigned int + // atomic_long long + // atomic_ulong unsigned long + // atomic_llong long long + // atomic_ullong unsigned long long + // atomic_char8_t char8_t + // atomic_char16_t char16_t + // atomic_char32_t char32_t + // atomic_wchar_t wchar_t + // + // NB: Assuming _ITp is an integral scalar type that is 1, 2, 4, or + // 8 bytes, since that is what GCC built-in functions for atomic + // memory access expect. + template + struct __atomic_base + { + using value_type = _ITp; + using difference_type = value_type; + + private: + typedef _ITp __int_type; + + static constexpr int _S_alignment = + sizeof(_ITp) > alignof(_ITp) ? sizeof(_ITp) : alignof(_ITp); + + alignas(_S_alignment) __int_type _M_i _GLIBCXX20_INIT(0); + + public: + __atomic_base() noexcept = default; + ~__atomic_base() noexcept = default; + __atomic_base(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) volatile = delete; + + // Requires __int_type convertible to _M_i. + constexpr __atomic_base(__int_type __i) noexcept : _M_i (__i) { } + + operator __int_type() const noexcept + { return load(); } + + operator __int_type() const volatile noexcept + { return load(); } + + __int_type + operator=(__int_type __i) noexcept + { + store(__i); + return __i; + } + + __int_type + operator=(__int_type __i) volatile noexcept + { + store(__i); + return __i; + } + + __int_type + operator++(int) noexcept + { return fetch_add(1); } + + __int_type + operator++(int) volatile noexcept + { return fetch_add(1); } + + __int_type + operator--(int) noexcept + { return fetch_sub(1); } + + __int_type + operator--(int) volatile noexcept + { return fetch_sub(1); } + + __int_type + operator++() noexcept + { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator++() volatile noexcept + { return __atomic_add_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator--() noexcept + { return __atomic_sub_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator--() volatile noexcept + { return __atomic_sub_fetch(&_M_i, 1, int(memory_order_seq_cst)); } + + __int_type + operator+=(__int_type __i) noexcept + { return __atomic_add_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator+=(__int_type __i) volatile noexcept + { return __atomic_add_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator-=(__int_type __i) noexcept + { return __atomic_sub_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator-=(__int_type __i) volatile noexcept + { return __atomic_sub_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator&=(__int_type __i) noexcept + { return __atomic_and_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator&=(__int_type __i) volatile noexcept + { return __atomic_and_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator|=(__int_type __i) noexcept + { return __atomic_or_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator|=(__int_type __i) volatile noexcept + { return __atomic_or_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator^=(__int_type __i) noexcept + { return __atomic_xor_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + __int_type + operator^=(__int_type __i) volatile noexcept + { return __atomic_xor_fetch(&_M_i, __i, int(memory_order_seq_cst)); } + + bool + is_lock_free() const noexcept + { + // Use a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + + bool + is_lock_free() const volatile noexcept + { + // Use a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_i), + reinterpret_cast(-_S_alignment)); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_i, __i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_i, __i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __int_type + load(memory_order __m = memory_order_seq_cst) const noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __int_type + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __int_type + exchange(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { + return __atomic_exchange_n(&_M_i, __i, int(__m)); + } + + + _GLIBCXX_ALWAYS_INLINE __int_type + exchange(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return __atomic_exchange_n(&_M_i, __i, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m1, memory_order __m2) noexcept + { + memory_order __b2 __attribute__ ((__unused__)) + = __m2 & __memory_order_mask; + memory_order __b1 __attribute__ ((__unused__)) + = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + memory_order __b2 __attribute__ ((__unused__)) + = __m2 & __memory_order_mask; + memory_order __b1 __attribute__ ((__unused__)) + = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 1, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) noexcept + { + return compare_exchange_weak(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return compare_exchange_weak(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m1, memory_order __m2) noexcept + { + memory_order __b2 __attribute__ ((__unused__)) + = __m2 & __memory_order_mask; + memory_order __b1 __attribute__ ((__unused__)) + = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + memory_order __b2 __attribute__ ((__unused__)) + = __m2 & __memory_order_mask; + memory_order __b1 __attribute__ ((__unused__)) + = __m1 & __memory_order_mask; + + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_i, &__i1, __i2, 0, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) noexcept + { + return compare_exchange_strong(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__int_type& __i1, __int_type __i2, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return compare_exchange_strong(__i1, __i2, __m, + __cmpexch_failure_order(__m)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(__int_type __old, + memory_order __m = memory_order_seq_cst) const noexcept + { + std::__atomic_wait_address_v(&_M_i, __old, + [__m, this] { return this->load(__m); }); + } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { std::__atomic_notify_address(&_M_i, false); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { std::__atomic_notify_address(&_M_i, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_add(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_add(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_add(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_add(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_sub(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_sub(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_sub(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_sub(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_and(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_and(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_and(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_and(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_or(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_or(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_or(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_or(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_xor(__int_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_xor(&_M_i, __i, int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __int_type + fetch_xor(__int_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_xor(&_M_i, __i, int(__m)); } + }; + + + /// Partial specialization for pointer types. + template + struct __atomic_base<_PTp*> + { + private: + typedef _PTp* __pointer_type; + + __pointer_type _M_p _GLIBCXX20_INIT(nullptr); + + // Factored out to facilitate explicit specialization. + constexpr ptrdiff_t + _M_type_size(ptrdiff_t __d) const { return __d * sizeof(_PTp); } + + constexpr ptrdiff_t + _M_type_size(ptrdiff_t __d) const volatile { return __d * sizeof(_PTp); } + + public: + __atomic_base() noexcept = default; + ~__atomic_base() noexcept = default; + __atomic_base(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) = delete; + __atomic_base& operator=(const __atomic_base&) volatile = delete; + + // Requires __pointer_type convertible to _M_p. + constexpr __atomic_base(__pointer_type __p) noexcept : _M_p (__p) { } + + operator __pointer_type() const noexcept + { return load(); } + + operator __pointer_type() const volatile noexcept + { return load(); } + + __pointer_type + operator=(__pointer_type __p) noexcept + { + store(__p); + return __p; + } + + __pointer_type + operator=(__pointer_type __p) volatile noexcept + { + store(__p); + return __p; + } + + __pointer_type + operator++(int) noexcept + { return fetch_add(1); } + + __pointer_type + operator++(int) volatile noexcept + { return fetch_add(1); } + + __pointer_type + operator--(int) noexcept + { return fetch_sub(1); } + + __pointer_type + operator--(int) volatile noexcept + { return fetch_sub(1); } + + __pointer_type + operator++() noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator++() volatile noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator--() noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator--() volatile noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + int(memory_order_seq_cst)); } + + __pointer_type + operator+=(ptrdiff_t __d) noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + __pointer_type + operator+=(ptrdiff_t __d) volatile noexcept + { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + __pointer_type + operator-=(ptrdiff_t __d) noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + __pointer_type + operator-=(ptrdiff_t __d) volatile noexcept + { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + int(memory_order_seq_cst)); } + + bool + is_lock_free() const noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_p), + reinterpret_cast(-__alignof(_M_p))); + } + + bool + is_lock_free() const volatile noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(sizeof(_M_p), + reinterpret_cast(-__alignof(_M_p))); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_p, __p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE void + store(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_acquire); + __glibcxx_assert(__b != memory_order_acq_rel); + __glibcxx_assert(__b != memory_order_consume); + + __atomic_store_n(&_M_p, __p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + load(memory_order __m = memory_order_seq_cst) const noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { + memory_order __b __attribute__ ((__unused__)) + = __m & __memory_order_mask; + __glibcxx_assert(__b != memory_order_release); + __glibcxx_assert(__b != memory_order_acq_rel); + + return __atomic_load_n(&_M_p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) noexcept + { + return __atomic_exchange_n(&_M_p, __p, int(__m)); + } + + + _GLIBCXX_ALWAYS_INLINE __pointer_type + exchange(__pointer_type __p, + memory_order __m = memory_order_seq_cst) volatile noexcept + { + return __atomic_exchange_n(&_M_p, __p, int(__m)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) noexcept + { + memory_order __b2 __attribute__ ((__unused__)) + = __m2 & __memory_order_mask; + memory_order __b1 __attribute__ ((__unused__)) + = __m1 & __memory_order_mask; + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, + int(__m1), int(__m2)); + } + + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2, + memory_order __m1, + memory_order __m2) volatile noexcept + { + memory_order __b2 __attribute__ ((__unused__)) + = __m2 & __memory_order_mask; + memory_order __b1 __attribute__ ((__unused__)) + = __m1 & __memory_order_mask; + + __glibcxx_assert(__b2 != memory_order_release); + __glibcxx_assert(__b2 != memory_order_acq_rel); + __glibcxx_assert(__b2 <= __b1); + + return __atomic_compare_exchange_n(&_M_p, &__p1, __p2, 0, + int(__m1), int(__m2)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(__pointer_type __old, + memory_order __m = memory_order_seq_cst) noexcept + { + std::__atomic_wait_address_v(&_M_p, __old, + [__m, this] + { return this->load(__m); }); + } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { std::__atomic_notify_address(&_M_p, false); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { std::__atomic_notify_address(&_M_p, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_add(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } + + _GLIBCXX_ALWAYS_INLINE __pointer_type + fetch_sub(ptrdiff_t __d, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } + }; + +#if __cplusplus > 201703L + // Implementation details of atomic_ref and atomic. + namespace __atomic_impl + { + // Remove volatile and create a non-deduced context for value arguments. + template + using _Val = remove_volatile_t<_Tp>; + + // As above, but for difference_type arguments. + template + using _Diff = conditional_t, ptrdiff_t, _Val<_Tp>>; + + template + _GLIBCXX_ALWAYS_INLINE bool + is_lock_free() noexcept + { + // Produce a fake, minimally aligned pointer. + return __atomic_is_lock_free(_Size, reinterpret_cast(-_Align)); + } + + template + _GLIBCXX_ALWAYS_INLINE void + store(_Tp* __ptr, _Val<_Tp> __t, memory_order __m) noexcept + { __atomic_store(__ptr, std::__addressof(__t), int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Val<_Tp> + load(const _Tp* __ptr, memory_order __m) noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); + __atomic_load(__ptr, __dest, int(__m)); + return *__dest; + } + + template + _GLIBCXX_ALWAYS_INLINE _Val<_Tp> + exchange(_Tp* __ptr, _Val<_Tp> __desired, memory_order __m) noexcept + { + alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; + auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); + __atomic_exchange(__ptr, std::__addressof(__desired), __dest, int(__m)); + return *__dest; + } + + template + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_weak(_Tp* __ptr, _Val<_Tp>& __expected, + _Val<_Tp> __desired, memory_order __success, + memory_order __failure) noexcept + { + return __atomic_compare_exchange(__ptr, std::__addressof(__expected), + std::__addressof(__desired), true, + int(__success), int(__failure)); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + compare_exchange_strong(_Tp* __ptr, _Val<_Tp>& __expected, + _Val<_Tp> __desired, memory_order __success, + memory_order __failure) noexcept + { + return __atomic_compare_exchange(__ptr, std::__addressof(__expected), + std::__addressof(__desired), false, + int(__success), int(__failure)); + } + +#if __cpp_lib_atomic_wait + template + _GLIBCXX_ALWAYS_INLINE void + wait(const _Tp* __ptr, _Val<_Tp> __old, + memory_order __m = memory_order_seq_cst) noexcept + { + std::__atomic_wait_address_v(__ptr, __old, + [__ptr, __m]() { return __atomic_impl::load(__ptr, __m); }); + } + + // TODO add const volatile overload + + template + _GLIBCXX_ALWAYS_INLINE void + notify_one(const _Tp* __ptr) noexcept + { std::__atomic_notify_address(__ptr, false); } + + // TODO add const volatile overload + + template + _GLIBCXX_ALWAYS_INLINE void + notify_all(const _Tp* __ptr) noexcept + { std::__atomic_notify_address(__ptr, true); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_add(_Tp* __ptr, _Diff<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_add(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_sub(_Tp* __ptr, _Diff<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_sub(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_and(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_and(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_or(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_or(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + fetch_xor(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { return __atomic_fetch_xor(__ptr, __i, int(__m)); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __add_fetch(_Tp* __ptr, _Diff<_Tp> __i) noexcept + { return __atomic_add_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __sub_fetch(_Tp* __ptr, _Diff<_Tp> __i) noexcept + { return __atomic_sub_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __and_fetch(_Tp* __ptr, _Val<_Tp> __i) noexcept + { return __atomic_and_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __or_fetch(_Tp* __ptr, _Val<_Tp> __i) noexcept + { return __atomic_or_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _GLIBCXX_ALWAYS_INLINE _Tp + __xor_fetch(_Tp* __ptr, _Val<_Tp> __i) noexcept + { return __atomic_xor_fetch(__ptr, __i, __ATOMIC_SEQ_CST); } + + template + _Tp + __fetch_add_flt(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval + __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, __m, + memory_order_relaxed)) + __newval = __oldval + __i; + return __oldval; + } + + template + _Tp + __fetch_sub_flt(_Tp* __ptr, _Val<_Tp> __i, memory_order __m) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval - __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, __m, + memory_order_relaxed)) + __newval = __oldval - __i; + return __oldval; + } + + template + _Tp + __add_fetch_flt(_Tp* __ptr, _Val<_Tp> __i) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval + __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, + memory_order_seq_cst, + memory_order_relaxed)) + __newval = __oldval + __i; + return __newval; + } + + template + _Tp + __sub_fetch_flt(_Tp* __ptr, _Val<_Tp> __i) noexcept + { + _Val<_Tp> __oldval = load(__ptr, memory_order_relaxed); + _Val<_Tp> __newval = __oldval - __i; + while (!compare_exchange_weak(__ptr, __oldval, __newval, + memory_order_seq_cst, + memory_order_relaxed)) + __newval = __oldval - __i; + return __newval; + } + } // namespace __atomic_impl + + // base class for atomic + template + struct __atomic_float + { + static_assert(is_floating_point_v<_Fp>); + + static constexpr size_t _S_alignment = __alignof__(_Fp); + + public: + using value_type = _Fp; + using difference_type = value_type; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Fp), 0); + + __atomic_float() = default; + + constexpr + __atomic_float(_Fp __t) : _M_fp(__t) + { } + + __atomic_float(const __atomic_float&) = delete; + __atomic_float& operator=(const __atomic_float&) = delete; + __atomic_float& operator=(const __atomic_float&) volatile = delete; + + _Fp + operator=(_Fp __t) volatile noexcept + { + this->store(__t); + return __t; + } + + _Fp + operator=(_Fp __t) noexcept + { + this->store(__t); + return __t; + } + + bool + is_lock_free() const volatile noexcept + { return __atomic_impl::is_lock_free(); } + + bool + is_lock_free() const noexcept + { return __atomic_impl::is_lock_free(); } + + void + store(_Fp __t, memory_order __m = memory_order_seq_cst) volatile noexcept + { __atomic_impl::store(&_M_fp, __t, __m); } + + void + store(_Fp __t, memory_order __m = memory_order_seq_cst) noexcept + { __atomic_impl::store(&_M_fp, __t, __m); } + + _Fp + load(memory_order __m = memory_order_seq_cst) const volatile noexcept + { return __atomic_impl::load(&_M_fp, __m); } + + _Fp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(&_M_fp, __m); } + + operator _Fp() const volatile noexcept { return this->load(); } + operator _Fp() const noexcept { return this->load(); } + + _Fp + exchange(_Fp __desired, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_impl::exchange(&_M_fp, __desired, __m); } + + _Fp + exchange(_Fp __desired, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_impl::exchange(&_M_fp, __desired, __m); } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) noexcept + { + return __atomic_impl::compare_exchange_weak(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) volatile noexcept + { + return __atomic_impl::compare_exchange_weak(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) noexcept + { + return __atomic_impl::compare_exchange_strong(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) volatile noexcept + { + return __atomic_impl::compare_exchange_strong(&_M_fp, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + volatile noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + volatile noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Fp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(&_M_fp, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(&_M_fp); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(&_M_fp); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_impl::__fetch_add_flt(&_M_fp, __i, __m); } + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_impl::__fetch_add_flt(&_M_fp, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) noexcept + { return __atomic_impl::__fetch_sub_flt(&_M_fp, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) volatile noexcept + { return __atomic_impl::__fetch_sub_flt(&_M_fp, __i, __m); } + + value_type + operator+=(value_type __i) noexcept + { return __atomic_impl::__add_fetch_flt(&_M_fp, __i); } + + value_type + operator+=(value_type __i) volatile noexcept + { return __atomic_impl::__add_fetch_flt(&_M_fp, __i); } + + value_type + operator-=(value_type __i) noexcept + { return __atomic_impl::__sub_fetch_flt(&_M_fp, __i); } + + value_type + operator-=(value_type __i) volatile noexcept + { return __atomic_impl::__sub_fetch_flt(&_M_fp, __i); } + + private: + alignas(_S_alignment) _Fp _M_fp _GLIBCXX20_INIT(0); + }; +#undef _GLIBCXX20_INIT + + template, bool = is_floating_point_v<_Tp>> + struct __atomic_ref; + + // base class for non-integral, non-floating-point, non-pointer types + template + struct __atomic_ref<_Tp, false, false> + { + static_assert(is_trivially_copyable_v<_Tp>); + + // 1/2/4/8/16-byte types must be aligned to at least their size. + static constexpr int _S_min_alignment + = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || sizeof(_Tp) > 16 + ? 0 : sizeof(_Tp); + + public: + using value_type = _Tp; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Tp), 0); + + static constexpr size_t required_alignment + = _S_min_alignment > alignof(_Tp) ? _S_min_alignment : alignof(_Tp); + + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Tp& __t) : _M_ptr(std::__addressof(__t)) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Tp + operator=(_Tp __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Tp() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { return __atomic_impl::is_lock_free(); } + + void + store(_Tp __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Tp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Tp + exchange(_Tp __desired, memory_order __m = memory_order_seq_cst) + const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + private: + _Tp* _M_ptr; + }; + + // base class for atomic_ref + template + struct __atomic_ref<_Tp, true, false> + { + static_assert(is_integral_v<_Tp>); + + public: + using value_type = _Tp; + using difference_type = value_type; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Tp), 0); + + static constexpr size_t required_alignment + = sizeof(_Tp) > alignof(_Tp) ? sizeof(_Tp) : alignof(_Tp); + + __atomic_ref() = delete; + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Tp& __t) : _M_ptr(&__t) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Tp + operator=(_Tp __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Tp() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { + return __atomic_impl::is_lock_free(); + } + + void + store(_Tp __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Tp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Tp + exchange(_Tp __desired, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Tp& __expected, _Tp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_add(_M_ptr, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_sub(_M_ptr, __i, __m); } + + value_type + fetch_and(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_and(_M_ptr, __i, __m); } + + value_type + fetch_or(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_or(_M_ptr, __i, __m); } + + value_type + fetch_xor(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_xor(_M_ptr, __i, __m); } + + _GLIBCXX_ALWAYS_INLINE value_type + operator++(int) const noexcept + { return fetch_add(1); } + + _GLIBCXX_ALWAYS_INLINE value_type + operator--(int) const noexcept + { return fetch_sub(1); } + + value_type + operator++() const noexcept + { return __atomic_impl::__add_fetch(_M_ptr, value_type(1)); } + + value_type + operator--() const noexcept + { return __atomic_impl::__sub_fetch(_M_ptr, value_type(1)); } + + value_type + operator+=(value_type __i) const noexcept + { return __atomic_impl::__add_fetch(_M_ptr, __i); } + + value_type + operator-=(value_type __i) const noexcept + { return __atomic_impl::__sub_fetch(_M_ptr, __i); } + + value_type + operator&=(value_type __i) const noexcept + { return __atomic_impl::__and_fetch(_M_ptr, __i); } + + value_type + operator|=(value_type __i) const noexcept + { return __atomic_impl::__or_fetch(_M_ptr, __i); } + + value_type + operator^=(value_type __i) const noexcept + { return __atomic_impl::__xor_fetch(_M_ptr, __i); } + + private: + _Tp* _M_ptr; + }; + + // base class for atomic_ref + template + struct __atomic_ref<_Fp, false, true> + { + static_assert(is_floating_point_v<_Fp>); + + public: + using value_type = _Fp; + using difference_type = value_type; + + static constexpr bool is_always_lock_free + = __atomic_always_lock_free(sizeof(_Fp), 0); + + static constexpr size_t required_alignment = __alignof__(_Fp); + + __atomic_ref() = delete; + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Fp& __t) : _M_ptr(&__t) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Fp + operator=(_Fp __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Fp() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { + return __atomic_impl::is_lock_free(); + } + + void + store(_Fp __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Fp + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Fp + exchange(_Fp __desired, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Fp& __expected, _Fp __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Fp __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + value_type + fetch_add(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::__fetch_add_flt(_M_ptr, __i, __m); } + + value_type + fetch_sub(value_type __i, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::__fetch_sub_flt(_M_ptr, __i, __m); } + + value_type + operator+=(value_type __i) const noexcept + { return __atomic_impl::__add_fetch_flt(_M_ptr, __i); } + + value_type + operator-=(value_type __i) const noexcept + { return __atomic_impl::__sub_fetch_flt(_M_ptr, __i); } + + private: + _Fp* _M_ptr; + }; + + // base class for atomic_ref + template + struct __atomic_ref<_Tp*, false, false> + { + public: + using value_type = _Tp*; + using difference_type = ptrdiff_t; + + static constexpr bool is_always_lock_free = ATOMIC_POINTER_LOCK_FREE == 2; + + static constexpr size_t required_alignment = __alignof__(_Tp*); + + __atomic_ref() = delete; + __atomic_ref& operator=(const __atomic_ref&) = delete; + + explicit + __atomic_ref(_Tp*& __t) : _M_ptr(std::__addressof(__t)) + { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + + __atomic_ref(const __atomic_ref&) noexcept = default; + + _Tp* + operator=(_Tp* __t) const noexcept + { + this->store(__t); + return __t; + } + + operator _Tp*() const noexcept { return this->load(); } + + bool + is_lock_free() const noexcept + { + return __atomic_impl::is_lock_free(); + } + + void + store(_Tp* __t, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::store(_M_ptr, __t, __m); } + + _Tp* + load(memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::load(_M_ptr, __m); } + + _Tp* + exchange(_Tp* __desired, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::exchange(_M_ptr, __desired, __m); } + + bool + compare_exchange_weak(_Tp*& __expected, _Tp* __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_weak(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_strong(_Tp*& __expected, _Tp* __desired, + memory_order __success, + memory_order __failure) const noexcept + { + return __atomic_impl::compare_exchange_strong(_M_ptr, + __expected, __desired, + __success, __failure); + } + + bool + compare_exchange_weak(_Tp*& __expected, _Tp* __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_weak(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + + bool + compare_exchange_strong(_Tp*& __expected, _Tp* __desired, + memory_order __order = memory_order_seq_cst) + const noexcept + { + return compare_exchange_strong(__expected, __desired, __order, + __cmpexch_failure_order(__order)); + } + +#if __cpp_lib_atomic_wait + _GLIBCXX_ALWAYS_INLINE void + wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const noexcept + { __atomic_impl::wait(_M_ptr, __old, __m); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_one() const noexcept + { __atomic_impl::notify_one(_M_ptr); } + + // TODO add const volatile overload + + _GLIBCXX_ALWAYS_INLINE void + notify_all() const noexcept + { __atomic_impl::notify_all(_M_ptr); } + + // TODO add const volatile overload +#endif // __cpp_lib_atomic_wait + + _GLIBCXX_ALWAYS_INLINE value_type + fetch_add(difference_type __d, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_add(_M_ptr, _S_type_size(__d), __m); } + + _GLIBCXX_ALWAYS_INLINE value_type + fetch_sub(difference_type __d, + memory_order __m = memory_order_seq_cst) const noexcept + { return __atomic_impl::fetch_sub(_M_ptr, _S_type_size(__d), __m); } + + value_type + operator++(int) const noexcept + { return fetch_add(1); } + + value_type + operator--(int) const noexcept + { return fetch_sub(1); } + + value_type + operator++() const noexcept + { + return __atomic_impl::__add_fetch(_M_ptr, _S_type_size(1)); + } + + value_type + operator--() const noexcept + { + return __atomic_impl::__sub_fetch(_M_ptr, _S_type_size(1)); + } + + value_type + operator+=(difference_type __d) const noexcept + { + return __atomic_impl::__add_fetch(_M_ptr, _S_type_size(__d)); + } + + value_type + operator-=(difference_type __d) const noexcept + { + return __atomic_impl::__sub_fetch(_M_ptr, _S_type_size(__d)); + } + + private: + static constexpr ptrdiff_t + _S_type_size(ptrdiff_t __d) noexcept + { + static_assert(is_object_v<_Tp>); + return __d * sizeof(_Tp); + } + + _Tp** _M_ptr; + }; + +#endif // C++2a + + /// @} group atomics + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_futex.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_futex.h new file mode 100755 index 0000000..d4bb32c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_futex.h @@ -0,0 +1,361 @@ +// -*- C++ -*- header. + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_futex.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _GLIBCXX_ATOMIC_FUTEX_H +#define _GLIBCXX_ATOMIC_FUTEX_H 1 + +#pragma GCC system_header + +#include +#include +#include +#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1) +#include +#include +#endif + +#ifndef _GLIBCXX_ALWAYS_INLINE +#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef _GLIBCXX_HAS_GTHREADS +#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1 + struct __atomic_futex_unsigned_base + { + // __s and __ns are measured against CLOCK_REALTIME. Returns false + // iff a timeout occurred. + bool + _M_futex_wait_until(unsigned *__addr, unsigned __val, bool __has_timeout, + chrono::seconds __s, chrono::nanoseconds __ns); + + // __s and __ns are measured against CLOCK_MONOTONIC. Returns + // false iff a timeout occurred. + bool + _M_futex_wait_until_steady(unsigned *__addr, unsigned __val, + bool __has_timeout, chrono::seconds __s, chrono::nanoseconds __ns); + + // This can be executed after the object has been destroyed. + static void _M_futex_notify_all(unsigned* __addr); + }; + + template + class __atomic_futex_unsigned : __atomic_futex_unsigned_base + { + typedef chrono::steady_clock __clock_t; + + // This must be lock-free and at offset 0. + atomic _M_data; + + public: + explicit + __atomic_futex_unsigned(unsigned __data) : _M_data(__data) + { } + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load(memory_order __mo) + { + return _M_data.load(__mo) & ~_Waiter_bit; + } + + private: + // If a timeout occurs, returns a current value after the timeout; + // otherwise, returns the operand's value if equal is true or a different + // value if equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + // __s and __ns are measured against CLOCK_REALTIME. + unsigned + _M_load_and_test_until(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, bool __has_timeout, + chrono::seconds __s, chrono::nanoseconds __ns) + { + for (;;) + { + // Don't bother checking the value again because we expect the caller + // to have done it recently. + // memory_order_relaxed is sufficient because we can rely on just the + // modification order (store_notify uses an atomic RMW operation too), + // and the futex syscalls synchronize between themselves. + _M_data.fetch_or(_Waiter_bit, memory_order_relaxed); + bool __ret = _M_futex_wait_until((unsigned*)(void*)&_M_data, + __assumed | _Waiter_bit, + __has_timeout, __s, __ns); + // Fetch the current value after waiting (clears _Waiter_bit). + __assumed = _M_load(__mo); + if (!__ret || ((__operand == __assumed) == __equal)) + return __assumed; + // TODO adapt wait time + } + } + + // If a timeout occurs, returns a current value after the timeout; + // otherwise, returns the operand's value if equal is true or a different + // value if equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + // __s and __ns are measured against CLOCK_MONOTONIC. + unsigned + _M_load_and_test_until_steady(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, bool __has_timeout, + chrono::seconds __s, chrono::nanoseconds __ns) + { + for (;;) + { + // Don't bother checking the value again because we expect the caller + // to have done it recently. + // memory_order_relaxed is sufficient because we can rely on just the + // modification order (store_notify uses an atomic RMW operation too), + // and the futex syscalls synchronize between themselves. + _M_data.fetch_or(_Waiter_bit, memory_order_relaxed); + bool __ret = _M_futex_wait_until_steady((unsigned*)(void*)&_M_data, + __assumed | _Waiter_bit, + __has_timeout, __s, __ns); + // Fetch the current value after waiting (clears _Waiter_bit). + __assumed = _M_load(__mo); + if (!__ret || ((__operand == __assumed) == __equal)) + return __assumed; + // TODO adapt wait time + } + } + + // Returns the operand's value if equal is true or a different value if + // equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + unsigned + _M_load_and_test(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo) + { + return _M_load_and_test_until(__assumed, __operand, __equal, __mo, + false, {}, {}); + } + + // If a timeout occurs, returns a current value after the timeout; + // otherwise, returns the operand's value if equal is true or a different + // value if equal is false. + // The assumed value is the caller's assumption about the current value + // when making the call. + template + unsigned + _M_load_and_test_until_impl(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + // XXX correct? + return _M_load_and_test_until(__assumed, __operand, __equal, __mo, + true, __s.time_since_epoch(), __ns); + } + + template + unsigned + _M_load_and_test_until_impl(unsigned __assumed, unsigned __operand, + bool __equal, memory_order __mo, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + // XXX correct? + return _M_load_and_test_until_steady(__assumed, __operand, __equal, __mo, + true, __s.time_since_epoch(), __ns); + } + + public: + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load_when_not_equal(unsigned __val, memory_order __mo) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) != __val) + return (__i & ~_Waiter_bit); + // TODO Spin-wait first. + return _M_load_and_test(__i, __val, false, __mo); + } + + _GLIBCXX_ALWAYS_INLINE void + _M_load_when_equal(unsigned __val, memory_order __mo) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) == __val) + return; + // TODO Spin-wait first. + _M_load_and_test(__i, __val, true, __mo); + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_for(unsigned __val, memory_order __mo, + const chrono::duration<_Rep, _Period>& __rtime) + { + using __dur = typename __clock_t::duration; + return _M_load_when_equal_until(__val, __mo, + __clock_t::now() + chrono::__detail::ceil<__dur>(__rtime)); + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point<_Clock, _Duration>& __atime) + { + typename _Clock::time_point __c_entry = _Clock::now(); + do { + const __clock_t::time_point __s_entry = __clock_t::now(); + const auto __delta = __atime - __c_entry; + const auto __s_atime = __s_entry + + chrono::__detail::ceil<__clock_t::duration>(__delta); + if (_M_load_when_equal_until(__val, __mo, __s_atime)) + return true; + __c_entry = _Clock::now(); + } while (__c_entry < __atime); + return false; + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point& __atime) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) == __val) + return true; + // TODO Spin-wait first. Ignore effect on timeout. + __i = _M_load_and_test_until_impl(__i, __val, true, __mo, __atime); + return (__i & ~_Waiter_bit) == __val; + } + + // Returns false iff a timeout occurred. + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point& __atime) + { + unsigned __i = _M_load(__mo); + if ((__i & ~_Waiter_bit) == __val) + return true; + // TODO Spin-wait first. Ignore effect on timeout. + __i = _M_load_and_test_until_impl(__i, __val, true, __mo, __atime); + return (__i & ~_Waiter_bit) == __val; + } + + _GLIBCXX_ALWAYS_INLINE void + _M_store_notify_all(unsigned __val, memory_order __mo) + { + unsigned* __futex = (unsigned *)(void *)&_M_data; + if (_M_data.exchange(__val, __mo) & _Waiter_bit) + _M_futex_notify_all(__futex); + } + }; + +#else // ! (_GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1) + + // If futexes are not available, use a mutex and a condvar to wait. + // Because we access the data only within critical sections, all accesses + // are sequentially consistent; thus, we satisfy any provided memory_order. + template + class __atomic_futex_unsigned + { + typedef chrono::system_clock __clock_t; + + unsigned _M_data; + mutex _M_mutex; + condition_variable _M_condvar; + + public: + explicit + __atomic_futex_unsigned(unsigned __data) : _M_data(__data) + { } + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load(memory_order __mo) + { + unique_lock __lock(_M_mutex); + return _M_data; + } + + _GLIBCXX_ALWAYS_INLINE unsigned + _M_load_when_not_equal(unsigned __val, memory_order __mo) + { + unique_lock __lock(_M_mutex); + while (_M_data == __val) + _M_condvar.wait(__lock); + return _M_data; + } + + _GLIBCXX_ALWAYS_INLINE void + _M_load_when_equal(unsigned __val, memory_order __mo) + { + unique_lock __lock(_M_mutex); + while (_M_data != __val) + _M_condvar.wait(__lock); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_for(unsigned __val, memory_order __mo, + const chrono::duration<_Rep, _Period>& __rtime) + { + unique_lock __lock(_M_mutex); + return _M_condvar.wait_for(__lock, __rtime, + [&] { return _M_data == __val;}); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_load_when_equal_until(unsigned __val, memory_order __mo, + const chrono::time_point<_Clock, _Duration>& __atime) + { + unique_lock __lock(_M_mutex); + return _M_condvar.wait_until(__lock, __atime, + [&] { return _M_data == __val;}); + } + + _GLIBCXX_ALWAYS_INLINE void + _M_store_notify_all(unsigned __val, memory_order __mo) + { + unique_lock __lock(_M_mutex); + _M_data = __val; + _M_condvar.notify_all(); + } + }; + +#endif // _GLIBCXX_HAVE_LINUX_FUTEX && ATOMIC_INT_LOCK_FREE > 1 +#endif // _GLIBCXX_HAS_GTHREADS + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_lockfree_defines.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_lockfree_defines.h new file mode 100755 index 0000000..e91da6a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_lockfree_defines.h @@ -0,0 +1,66 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_lockfree_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_LOCK_FREE_H +#define _GLIBCXX_ATOMIC_LOCK_FREE_H 1 + +#pragma GCC system_header + +/** + * @addtogroup atomics + * @{ + */ + +/** + * Lock-free property. + * + * 0 indicates that the types are never lock-free. + * 1 indicates that the types are sometimes lock-free. + * 2 indicates that the types are always lock-free. + */ + +#if __cplusplus >= 201103L +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#ifdef _GLIBCXX_USE_CHAR8_T +#define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE +#endif +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/// @} group atomics + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_timed_wait.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_timed_wait.h new file mode 100755 index 0000000..3db08f8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_timed_wait.h @@ -0,0 +1,450 @@ +// -*- C++ -*- header. + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_timed_wait.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_TIMED_WAIT_H +#define _GLIBCXX_ATOMIC_TIMED_WAIT_H 1 + +#pragma GCC system_header + +#include + +#if __cpp_lib_atomic_wait +#include +#include + +#include + +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX +#include // std::terminate +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail + { + using __wait_clock_t = chrono::steady_clock; + + template + __wait_clock_t::time_point + __to_wait_clock(const chrono::time_point<_Clock, _Dur>& __atime) noexcept + { + const typename _Clock::time_point __c_entry = _Clock::now(); + const __wait_clock_t::time_point __w_entry = __wait_clock_t::now(); + const auto __delta = __atime - __c_entry; + using __w_dur = typename __wait_clock_t::duration; + return __w_entry + chrono::ceil<__w_dur>(__delta); + } + + template + __wait_clock_t::time_point + __to_wait_clock(const chrono::time_point<__wait_clock_t, + _Dur>& __atime) noexcept + { + using __w_dur = typename __wait_clock_t::duration; + return chrono::ceil<__w_dur>(__atime); + } + +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX +#define _GLIBCXX_HAVE_PLATFORM_TIMED_WAIT + // returns true if wait ended before timeout + template + bool + __platform_wait_until_impl(const __platform_wait_t* __addr, + __platform_wait_t __old, + const chrono::time_point<__wait_clock_t, _Dur>& + __atime) noexcept + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + struct timespec __rt = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + auto __e = syscall (SYS_futex, __addr, + static_cast(__futex_wait_flags:: + __wait_bitset_private), + __old, &__rt, nullptr, + static_cast(__futex_wait_flags:: + __bitset_match_any)); + + if (__e) + { + if ((errno != ETIMEDOUT) && (errno != EINTR) + && (errno != EAGAIN)) + __throw_system_error(errno); + return true; + } + return false; + } + + // returns true if wait ended before timeout + template + bool + __platform_wait_until(const __platform_wait_t* __addr, __platform_wait_t __old, + const chrono::time_point<_Clock, _Dur>& __atime) + { + if constexpr (is_same_v<__wait_clock_t, _Clock>) + { + return __platform_wait_until_impl(__addr, __old, __atime); + } + else + { + if (!__platform_wait_until_impl(__addr, __old, + __to_wait_clock(__atime))) + { + // We got a timeout when measured against __clock_t but + // we need to check against the caller-supplied clock + // to tell whether we should return a timeout. + if (_Clock::now() < __atime) + return true; + } + return false; + } + } +#else +// define _GLIBCXX_HAVE_PLATFORM_TIMED_WAIT and implement __platform_wait_until() +// if there is a more efficient primitive supported by the platform +// (e.g. __ulock_wait())which is better than pthread_cond_clockwait +#endif // ! PLATFORM_TIMED_WAIT + + // Returns true if wait ended before timeout. + // _Clock must be either steady_clock or system_clock. + template + bool + __cond_wait_until_impl(__condvar& __cv, mutex& __mx, + const chrono::time_point<_Clock, _Dur>& __atime) + { + static_assert(std::__is_one_of<_Clock, chrono::steady_clock, + chrono::system_clock>::value); + + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + if constexpr (is_same_v) + __cv.wait_until(__mx, CLOCK_MONOTONIC, __ts); + else +#endif + __cv.wait_until(__mx, __ts); + return _Clock::now() < __atime; + } + + // returns true if wait ended before timeout + template + bool + __cond_wait_until(__condvar& __cv, mutex& __mx, + const chrono::time_point<_Clock, _Dur>& __atime) + { +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + if constexpr (is_same_v<_Clock, chrono::steady_clock>) + return __detail::__cond_wait_until_impl(__cv, __mx, __atime); + else +#endif + if constexpr (is_same_v<_Clock, chrono::system_clock>) + return __detail::__cond_wait_until_impl(__cv, __mx, __atime); + else + { + if (__cond_wait_until_impl(__cv, __mx, + __to_wait_clock(__atime))) + { + // We got a timeout when measured against __clock_t but + // we need to check against the caller-supplied clock + // to tell whether we should return a timeout. + if (_Clock::now() < __atime) + return true; + } + return false; + } + } + + struct __timed_waiter_pool : __waiter_pool_base + { + // returns true if wait ended before timeout + template + bool + _M_do_wait_until(__platform_wait_t* __addr, __platform_wait_t __old, + const chrono::time_point<_Clock, _Dur>& __atime) + { +#ifdef _GLIBCXX_HAVE_PLATFORM_TIMED_WAIT + return __platform_wait_until(__addr, __old, __atime); +#else + __platform_wait_t __val; + __atomic_load(__addr, &__val, __ATOMIC_RELAXED); + if (__val == __old) + { + lock_guard __l(_M_mtx); + return __cond_wait_until(_M_cv, _M_mtx, __atime); + } + else + return true; +#endif // _GLIBCXX_HAVE_PLATFORM_TIMED_WAIT + } + }; + + struct __timed_backoff_spin_policy + { + __wait_clock_t::time_point _M_deadline; + __wait_clock_t::time_point _M_t0; + + template + __timed_backoff_spin_policy(chrono::time_point<_Clock, _Dur> + __deadline = _Clock::time_point::max(), + chrono::time_point<_Clock, _Dur> + __t0 = _Clock::now()) noexcept + : _M_deadline(__to_wait_clock(__deadline)) + , _M_t0(__to_wait_clock(__t0)) + { } + + bool + operator()() const noexcept + { + using namespace literals::chrono_literals; + auto __now = __wait_clock_t::now(); + if (_M_deadline <= __now) + return false; + + auto __elapsed = __now - _M_t0; + if (__elapsed > 128ms) + { + this_thread::sleep_for(64ms); + } + else if (__elapsed > 64us) + { + this_thread::sleep_for(__elapsed / 2); + } + else if (__elapsed > 4us) + { + __thread_yield(); + } + else + return false; + return true; + } + }; + + template + struct __timed_waiter : __waiter_base<__timed_waiter_pool> + { + using __base_type = __waiter_base<__timed_waiter_pool>; + + template + __timed_waiter(const _Tp* __addr) noexcept + : __base_type(__addr) + { + if constexpr (_EntersWait::value) + _M_w._M_enter_wait(); + } + + ~__timed_waiter() + { + if constexpr (_EntersWait::value) + _M_w._M_leave_wait(); + } + + // returns true if wait ended before timeout + template + bool + _M_do_wait_until_v(_Tp __old, _ValFn __vfn, + const chrono::time_point<_Clock, _Dur>& + __atime) noexcept + { + __platform_wait_t __val; + if (_M_do_spin(__old, std::move(__vfn), __val, + __timed_backoff_spin_policy(__atime))) + return true; + return __base_type::_M_w._M_do_wait_until(__base_type::_M_addr, __val, __atime); + } + + // returns true if wait ended before timeout + template + bool + _M_do_wait_until(_Pred __pred, __platform_wait_t __val, + const chrono::time_point<_Clock, _Dur>& + __atime) noexcept + { + for (auto __now = _Clock::now(); __now < __atime; + __now = _Clock::now()) + { + if (__base_type::_M_w._M_do_wait_until( + __base_type::_M_addr, __val, __atime) + && __pred()) + return true; + + if (__base_type::_M_do_spin(__pred, __val, + __timed_backoff_spin_policy(__atime, __now))) + return true; + } + return false; + } + + // returns true if wait ended before timeout + template + bool + _M_do_wait_until(_Pred __pred, + const chrono::time_point<_Clock, _Dur>& + __atime) noexcept + { + __platform_wait_t __val; + if (__base_type::_M_do_spin(__pred, __val, + __timed_backoff_spin_policy(__atime))) + return true; + return _M_do_wait_until(__pred, __val, __atime); + } + + template + bool + _M_do_wait_for_v(_Tp __old, _ValFn __vfn, + const chrono::duration<_Rep, _Period>& + __rtime) noexcept + { + __platform_wait_t __val; + if (_M_do_spin_v(__old, std::move(__vfn), __val)) + return true; + + if (!__rtime.count()) + return false; // no rtime supplied, and spin did not acquire + + auto __reltime = chrono::ceil<__wait_clock_t::duration>(__rtime); + + return __base_type::_M_w._M_do_wait_until( + __base_type::_M_addr, + __val, + chrono::steady_clock::now() + __reltime); + } + + template + bool + _M_do_wait_for(_Pred __pred, + const chrono::duration<_Rep, _Period>& __rtime) noexcept + { + __platform_wait_t __val; + if (__base_type::_M_do_spin(__pred, __val)) + return true; + + if (!__rtime.count()) + return false; // no rtime supplied, and spin did not acquire + + auto __reltime = chrono::ceil<__wait_clock_t::duration>(__rtime); + + return _M_do_wait_until(__pred, __val, + chrono::steady_clock::now() + __reltime); + } + }; + + using __enters_timed_wait = __timed_waiter; + using __bare_timed_wait = __timed_waiter; + } // namespace __detail + + // returns true if wait ended before timeout + template + bool + __atomic_wait_address_until_v(const _Tp* __addr, _Tp&& __old, _ValFn&& __vfn, + const chrono::time_point<_Clock, _Dur>& + __atime) noexcept + { + __detail::__enters_timed_wait __w{__addr}; + return __w._M_do_wait_until_v(__old, __vfn, __atime); + } + + template + bool + __atomic_wait_address_until(const _Tp* __addr, _Pred __pred, + const chrono::time_point<_Clock, _Dur>& + __atime) noexcept + { + __detail::__enters_timed_wait __w{__addr}; + return __w._M_do_wait_until(__pred, __atime); + } + + template + bool + __atomic_wait_address_until_bare(const __detail::__platform_wait_t* __addr, + _Pred __pred, + const chrono::time_point<_Clock, _Dur>& + __atime) noexcept + { + __detail::__bare_timed_wait __w{__addr}; + return __w._M_do_wait_until(__pred, __atime); + } + + template + bool + __atomic_wait_address_for_v(const _Tp* __addr, _Tp&& __old, _ValFn&& __vfn, + const chrono::duration<_Rep, _Period>& __rtime) noexcept + { + __detail::__enters_timed_wait __w{__addr}; + return __w._M_do_wait_for_v(__old, __vfn, __rtime); + } + + template + bool + __atomic_wait_address_for(const _Tp* __addr, _Pred __pred, + const chrono::duration<_Rep, _Period>& __rtime) noexcept + { + + __detail::__enters_timed_wait __w{__addr}; + return __w._M_do_wait_for(__pred, __rtime); + } + + template + bool + __atomic_wait_address_for_bare(const __detail::__platform_wait_t* __addr, + _Pred __pred, + const chrono::duration<_Rep, _Period>& __rtime) noexcept + { + __detail::__bare_timed_wait __w{__addr}; + return __w._M_do_wait_for(__pred, __rtime); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // __cpp_lib_atomic_wait +#endif // _GLIBCXX_ATOMIC_TIMED_WAIT_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_wait.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_wait.h new file mode 100755 index 0000000..07bb744 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/atomic_wait.h @@ -0,0 +1,485 @@ +// -*- C++ -*- header. + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_wait.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_WAIT_H +#define _GLIBCXX_ATOMIC_WAIT_H 1 + +#pragma GCC system_header + +#include +#if defined _GLIBCXX_HAS_GTHREADS || defined _GLIBCXX_HAVE_LINUX_FUTEX +#include +#include +#include + +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX +# include +# include +# include +# include +# include +#endif + +# include // std::mutex, std::__condvar + +#define __cpp_lib_atomic_wait 201907L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace __detail + { +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX + using __platform_wait_t = int; + static constexpr size_t __platform_wait_alignment = 4; +#else + using __platform_wait_t = uint64_t; + static constexpr size_t __platform_wait_alignment + = __alignof__(__platform_wait_t); +#endif + } // namespace __detail + + template + inline constexpr bool __platform_wait_uses_type +#ifdef _GLIBCXX_HAVE_PLATFORM_WAIT + = is_scalar_v<_Tp> + && ((sizeof(_Tp) == sizeof(__detail::__platform_wait_t)) + && (alignof(_Tp*) >= __platform_wait_alignment)); +#else + = false; +#endif + + namespace __detail + { +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX +#define _GLIBCXX_HAVE_PLATFORM_WAIT 1 + enum class __futex_wait_flags : int + { +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX_PRIVATE + __private_flag = 128, +#else + __private_flag = 0, +#endif + __wait = 0, + __wake = 1, + __wait_bitset = 9, + __wake_bitset = 10, + __wait_private = __wait | __private_flag, + __wake_private = __wake | __private_flag, + __wait_bitset_private = __wait_bitset | __private_flag, + __wake_bitset_private = __wake_bitset | __private_flag, + __bitset_match_any = -1 + }; + + template + void + __platform_wait(const _Tp* __addr, __platform_wait_t __val) noexcept + { + auto __e = syscall (SYS_futex, static_cast(__addr), + static_cast(__futex_wait_flags::__wait_private), + __val, nullptr); + if (!__e || errno == EAGAIN) + return; + if (errno != EINTR) + __throw_system_error(errno); + } + + template + void + __platform_notify(const _Tp* __addr, bool __all) noexcept + { + syscall (SYS_futex, static_cast(__addr), + static_cast(__futex_wait_flags::__wake_private), + __all ? INT_MAX : 1); + } +#else +// define _GLIBCX_HAVE_PLATFORM_WAIT and implement __platform_wait() +// and __platform_notify() if there is a more efficient primitive supported +// by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than +// a mutex/condvar based wait +#endif + + inline void + __thread_yield() noexcept + { +#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD + __gthread_yield(); +#endif + } + + inline void + __thread_relax() noexcept + { +#if defined __i386__ || defined __x86_64__ + __builtin_ia32_pause(); +#else + __thread_yield(); +#endif + } + + constexpr auto __atomic_spin_count_1 = 12; + constexpr auto __atomic_spin_count_2 = 4; + + struct __default_spin_policy + { + bool + operator()() const noexcept + { return false; } + }; + + template + bool + __atomic_spin(_Pred& __pred, _Spin __spin = _Spin{ }) noexcept + { + for (auto __i = 0; __i < __atomic_spin_count_1; ++__i) + { + if (__pred()) + return true; + __detail::__thread_relax(); + } + + for (auto __i = 0; __i < __atomic_spin_count_2; ++__i) + { + if (__pred()) + return true; + __detail::__thread_yield(); + } + + while (__spin()) + { + if (__pred()) + return true; + } + + return false; + } + + // return true if equal + template + bool __atomic_compare(const _Tp& __a, const _Tp& __b) + { + // TODO make this do the correct padding bit ignoring comparison + return __builtin_memcmp(&__a, &__b, sizeof(_Tp)) == 0; + } + + struct __waiter_pool_base + { +#ifdef __cpp_lib_hardware_interference_size + static constexpr auto _S_align = hardware_destructive_interference_size; +#else + static constexpr auto _S_align = 64; +#endif + + alignas(_S_align) __platform_wait_t _M_wait = 0; + +#ifndef _GLIBCXX_HAVE_PLATFORM_WAIT + mutex _M_mtx; +#endif + + alignas(_S_align) __platform_wait_t _M_ver = 0; + +#ifndef _GLIBCXX_HAVE_PLATFORM_WAIT + __condvar _M_cv; +#endif + __waiter_pool_base() = default; + + void + _M_enter_wait() noexcept + { __atomic_fetch_add(&_M_wait, 1, __ATOMIC_ACQ_REL); } + + void + _M_leave_wait() noexcept + { __atomic_fetch_sub(&_M_wait, 1, __ATOMIC_ACQ_REL); } + + bool + _M_waiting() const noexcept + { + __platform_wait_t __res; + __atomic_load(&_M_wait, &__res, __ATOMIC_ACQUIRE); + return __res > 0; + } + + void + _M_notify(const __platform_wait_t* __addr, bool __all, bool __bare) noexcept + { + if (!(__bare || _M_waiting())) + return; + +#ifdef _GLIBCXX_HAVE_PLATFORM_WAIT + __platform_notify(__addr, __all); +#else + if (__all) + _M_cv.notify_all(); + else + _M_cv.notify_one(); +#endif + } + + static __waiter_pool_base& + _S_for(const void* __addr) noexcept + { + constexpr uintptr_t __ct = 16; + static __waiter_pool_base __w[__ct]; + auto __key = (uintptr_t(__addr) >> 2) % __ct; + return __w[__key]; + } + }; + + struct __waiter_pool : __waiter_pool_base + { + void + _M_do_wait(const __platform_wait_t* __addr, __platform_wait_t __old) noexcept + { +#ifdef _GLIBCXX_HAVE_PLATFORM_WAIT + __platform_wait(__addr, __old); +#else + __platform_wait_t __val; + __atomic_load(__addr, &__val, __ATOMIC_RELAXED); + if (__val == __old) + { + lock_guard __l(_M_mtx); + _M_cv.wait(_M_mtx); + } +#endif // __GLIBCXX_HAVE_PLATFORM_WAIT + } + }; + + template + struct __waiter_base + { + using __waiter_type = _Tp; + + __waiter_type& _M_w; + __platform_wait_t* _M_addr; + + template + static __platform_wait_t* + _S_wait_addr(const _Up* __a, __platform_wait_t* __b) + { + if constexpr (__platform_wait_uses_type<_Up>) + return reinterpret_cast<__platform_wait_t*>(const_cast<_Up*>(__a)); + else + return __b; + } + + static __waiter_type& + _S_for(const void* __addr) noexcept + { + static_assert(sizeof(__waiter_type) == sizeof(__waiter_pool_base)); + auto& res = __waiter_pool_base::_S_for(__addr); + return reinterpret_cast<__waiter_type&>(res); + } + + template + explicit __waiter_base(const _Up* __addr) noexcept + : _M_w(_S_for(__addr)) + , _M_addr(_S_wait_addr(__addr, &_M_w._M_ver)) + { } + + bool + _M_laundered() const + { return _M_addr == &_M_w._M_ver; } + + void + _M_notify(bool __all, bool __bare = false) + { + if (_M_laundered()) + { + __atomic_fetch_add(_M_addr, 1, __ATOMIC_ACQ_REL); + __all = true; + } + _M_w._M_notify(_M_addr, __all, __bare); + } + + template + static bool + _S_do_spin_v(__platform_wait_t* __addr, + const _Up& __old, _ValFn __vfn, + __platform_wait_t& __val, + _Spin __spin = _Spin{ }) + { + auto const __pred = [=] + { return !__detail::__atomic_compare(__old, __vfn()); }; + + if constexpr (__platform_wait_uses_type<_Up>) + { + __val == __old; + } + else + { + __atomic_load(__addr, &__val, __ATOMIC_RELAXED); + } + return __atomic_spin(__pred, __spin); + } + + template + bool + _M_do_spin_v(const _Up& __old, _ValFn __vfn, + __platform_wait_t& __val, + _Spin __spin = _Spin{ }) + { return _S_do_spin_v(_M_addr, __old, __vfn, __val, __spin); } + + template + static bool + _S_do_spin(const __platform_wait_t* __addr, + _Pred __pred, + __platform_wait_t& __val, + _Spin __spin = _Spin{ }) + { + __atomic_load(__addr, &__val, __ATOMIC_RELAXED); + return __atomic_spin(__pred, __spin); + } + + template + bool + _M_do_spin(_Pred __pred, __platform_wait_t& __val, + _Spin __spin = _Spin{ }) + { return _S_do_spin(_M_addr, __pred, __val, __spin); } + }; + + template + struct __waiter : __waiter_base<__waiter_pool> + { + using __base_type = __waiter_base<__waiter_pool>; + + template + explicit __waiter(const _Tp* __addr) noexcept + : __base_type(__addr) + { + if constexpr (_EntersWait::value) + _M_w._M_enter_wait(); + } + + ~__waiter() + { + if constexpr (_EntersWait::value) + _M_w._M_leave_wait(); + } + + template + void + _M_do_wait_v(_Tp __old, _ValFn __vfn) + { + __platform_wait_t __val; + if (__base_type::_M_do_spin_v(__old, __vfn, __val)) + return; + + do + { + __base_type::_M_w._M_do_wait(__base_type::_M_addr, __val); + } + while (__detail::__atomic_compare(__old, __vfn())); + } + + template + void + _M_do_wait(_Pred __pred) noexcept + { + do + { + __platform_wait_t __val; + if (__base_type::_M_do_spin(__pred, __val)) + return; + __base_type::_M_w._M_do_wait(__base_type::_M_addr, __val); + } + while (!__pred()); + } + }; + + using __enters_wait = __waiter; + using __bare_wait = __waiter; + } // namespace __detail + + template + void + __atomic_wait_address_v(const _Tp* __addr, _Tp __old, + _ValFn __vfn) noexcept + { + __detail::__enters_wait __w(__addr); + __w._M_do_wait_v(__old, __vfn); + } + + template + void + __atomic_wait_address(const _Tp* __addr, _Pred __pred) noexcept + { + __detail::__enters_wait __w(__addr); + __w._M_do_wait(__pred); + } + + // This call is to be used by atomic types which track contention externally + template + void + __atomic_wait_address_bare(const __detail::__platform_wait_t* __addr, + _Pred __pred) noexcept + { +#ifdef _GLIBCXX_HAVE_PLATFORM_WAIT + do + { + __detail::__platform_wait_t __val; + if (__detail::__bare_wait::_S_do_spin(__addr, __pred, __val)) + return; + __detail::__platform_wait(__addr, __val); + } + while (!__pred()); +#else // !_GLIBCXX_HAVE_PLATFORM_WAIT + __detail::__bare_wait __w(__addr); + __w._M_do_wait(__pred); +#endif + } + + template + void + __atomic_notify_address(const _Tp* __addr, bool __all) noexcept + { + __detail::__bare_wait __w(__addr); + __w._M_notify(__all); + } + + // This call is to be used by atomic types which track contention externally + inline void + __atomic_notify_address_bare(const __detail::__platform_wait_t* __addr, + bool __all) noexcept + { +#ifdef _GLIBCXX_HAVE_PLATFORM_WAIT + __detail::__platform_notify(__addr, __all); +#else + __detail::__bare_wait __w(__addr); + __w._M_notify(__all, true); +#endif + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // GTHREADS || LINUX_FUTEX +#endif // _GLIBCXX_ATOMIC_WAIT_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_ios.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_ios.h new file mode 100755 index 0000000..aac59ac --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_ios.h @@ -0,0 +1,518 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_ios.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +#ifndef _BASIC_IOS_H +#define _BASIC_IOS_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + inline const _Facet& + __check_facet(const _Facet* __f) + { + if (!__f) + __throw_bad_cast(); + return *__f; + } + + /** + * @brief Template class basic_ios, virtual base class for all + * stream classes. + * @ingroup io + * + * @tparam _CharT Type of character stream. + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * + * Most of the member functions called dispatched on stream objects + * (e.g., @c std::cout.foo(bar);) are consolidated in this class. + */ + template + class basic_ios : public ios_base + { + public: + ///@{ + /** + * These are standard types. They permit a standardized way of + * referring to names of (or names dependent on) the template + * parameters, which are specific to the implementation. + */ + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + ///@} + + ///@{ + /** + * These are non-standard types. + */ + typedef ctype<_CharT> __ctype_type; + typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> > + __num_put_type; + typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > + __num_get_type; + ///@} + + // Data members: + protected: + basic_ostream<_CharT, _Traits>* _M_tie; + mutable char_type _M_fill; + mutable bool _M_fill_init; + basic_streambuf<_CharT, _Traits>* _M_streambuf; + + // Cached use_facet, which is based on the current locale info. + const __ctype_type* _M_ctype; + // For ostream. + const __num_put_type* _M_num_put; + // For istream. + const __num_get_type* _M_num_get; + + public: + ///@{ + /** + * @brief The quick-and-easy status check. + * + * This allows you to write constructs such as + * if (!a_stream) ... and while (a_stream) ... + */ +#if __cplusplus >= 201103L + explicit operator bool() const + { return !this->fail(); } +#else + operator void*() const + { return this->fail() ? 0 : const_cast(this); } +#endif + + bool + operator!() const + { return this->fail(); } + ///@} + + /** + * @brief Returns the error state of the stream buffer. + * @return A bit pattern (well, isn't everything?) + * + * See std::ios_base::iostate for the possible bit values. Most + * users will call one of the interpreting wrappers, e.g., good(). + */ + iostate + rdstate() const + { return _M_streambuf_state; } + + /** + * @brief [Re]sets the error state. + * @param __state The new state flag(s) to set. + * + * See std::ios_base::iostate for the possible bit values. Most + * users will not need to pass an argument. + */ + void + clear(iostate __state = goodbit); + + /** + * @brief Sets additional flags in the error state. + * @param __state The additional state flag(s) to set. + * + * See std::ios_base::iostate for the possible bit values. + */ + void + setstate(iostate __state) + { this->clear(this->rdstate() | __state); } + + // Flip the internal state on for the proper state bits, then + // rethrows the propagated exception if bit also set in + // exceptions(). + void + _M_setstate(iostate __state) + { + // 27.6.1.2.1 Common requirements. + // Turn this on without causing an ios::failure to be thrown. + _M_streambuf_state |= __state; + if (this->exceptions() & __state) + __throw_exception_again; + } + + /** + * @brief Fast error checking. + * @return True if no error flags are set. + * + * A wrapper around rdstate. + */ + bool + good() const + { return this->rdstate() == 0; } + + /** + * @brief Fast error checking. + * @return True if the eofbit is set. + * + * Note that other iostate flags may also be set. + */ + bool + eof() const + { return (this->rdstate() & eofbit) != 0; } + + /** + * @brief Fast error checking. + * @return True if either the badbit or the failbit is set. + * + * Checking the badbit in fail() is historical practice. + * Note that other iostate flags may also be set. + */ + bool + fail() const + { return (this->rdstate() & (badbit | failbit)) != 0; } + + /** + * @brief Fast error checking. + * @return True if the badbit is set. + * + * Note that other iostate flags may also be set. + */ + bool + bad() const + { return (this->rdstate() & badbit) != 0; } + + /** + * @brief Throwing exceptions on errors. + * @return The current exceptions mask. + * + * This changes nothing in the stream. See the one-argument version + * of exceptions(iostate) for the meaning of the return value. + */ + iostate + exceptions() const + { return _M_exception; } + + /** + * @brief Throwing exceptions on errors. + * @param __except The new exceptions mask. + * + * By default, error flags are set silently. You can set an + * exceptions mask for each stream; if a bit in the mask becomes set + * in the error flags, then an exception of type + * std::ios_base::failure is thrown. + * + * If the error flag is already set when the exceptions mask is + * added, the exception is immediately thrown. Try running the + * following under GCC 3.1 or later: + * @code + * #include + * #include + * #include + * + * int main() + * { + * std::set_terminate (__gnu_cxx::__verbose_terminate_handler); + * + * std::ifstream f ("/etc/motd"); + * + * std::cerr << "Setting badbit\n"; + * f.setstate (std::ios_base::badbit); + * + * std::cerr << "Setting exception mask\n"; + * f.exceptions (std::ios_base::badbit); + * } + * @endcode + */ + void + exceptions(iostate __except) + { + _M_exception = __except; + this->clear(_M_streambuf_state); + } + + // Constructor/destructor: + /** + * @brief Constructor performs initialization. + * + * The parameter is passed by derived streams. + */ + explicit + basic_ios(basic_streambuf<_CharT, _Traits>* __sb) + : ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0), + _M_ctype(0), _M_num_put(0), _M_num_get(0) + { this->init(__sb); } + + /** + * @brief Empty. + * + * The destructor does nothing. More specifically, it does not + * destroy the streambuf held by rdbuf(). + */ + virtual + ~basic_ios() { } + + // Members: + /** + * @brief Fetches the current @e tied stream. + * @return A pointer to the tied stream, or NULL if the stream is + * not tied. + * + * A stream may be @e tied (or synchronized) to a second output + * stream. When this stream performs any I/O, the tied stream is + * first flushed. For example, @c std::cin is tied to @c std::cout. + */ + basic_ostream<_CharT, _Traits>* + tie() const + { return _M_tie; } + + /** + * @brief Ties this stream to an output stream. + * @param __tiestr The output stream. + * @return The previously tied output stream, or NULL if the stream + * was not tied. + * + * This sets up a new tie; see tie() for more. + */ + basic_ostream<_CharT, _Traits>* + tie(basic_ostream<_CharT, _Traits>* __tiestr) + { + basic_ostream<_CharT, _Traits>* __old = _M_tie; + _M_tie = __tiestr; + return __old; + } + + /** + * @brief Accessing the underlying buffer. + * @return The current stream buffer. + * + * This does not change the state of the stream. + */ + basic_streambuf<_CharT, _Traits>* + rdbuf() const + { return _M_streambuf; } + + /** + * @brief Changing the underlying buffer. + * @param __sb The new stream buffer. + * @return The previous stream buffer. + * + * Associates a new buffer with the current stream, and clears the + * error state. + * + * Due to historical accidents which the LWG refuses to correct, the + * I/O library suffers from a design error: this function is hidden + * in derived classes by overrides of the zero-argument @c rdbuf(), + * which is non-virtual for hysterical raisins. As a result, you + * must use explicit qualifications to access this function via any + * derived class. For example: + * + * @code + * std::fstream foo; // or some other derived type + * std::streambuf* p = .....; + * + * foo.ios::rdbuf(p); // ios == basic_ios + * @endcode + */ + basic_streambuf<_CharT, _Traits>* + rdbuf(basic_streambuf<_CharT, _Traits>* __sb); + + /** + * @brief Copies fields of __rhs into this. + * @param __rhs The source values for the copies. + * @return Reference to this object. + * + * All fields of __rhs are copied into this object except that rdbuf() + * and rdstate() remain unchanged. All values in the pword and iword + * arrays are copied. Before copying, each callback is invoked with + * erase_event. After copying, each (new) callback is invoked with + * copyfmt_event. The final step is to copy exceptions(). + */ + basic_ios& + copyfmt(const basic_ios& __rhs); + + /** + * @brief Retrieves the @a empty character. + * @return The current fill character. + * + * It defaults to a space (' ') in the current locale. + */ + char_type + fill() const + { + if (!_M_fill_init) + { + _M_fill = this->widen(' '); + _M_fill_init = true; + } + return _M_fill; + } + + /** + * @brief Sets a new @a empty character. + * @param __ch The new character. + * @return The previous fill character. + * + * The fill character is used to fill out space when P+ characters + * have been requested (e.g., via setw), Q characters are actually + * used, and Qfill(); + _M_fill = __ch; + return __old; + } + + // Locales: + /** + * @brief Moves to a new locale. + * @param __loc The new locale. + * @return The previous locale. + * + * Calls @c ios_base::imbue(loc), and if a stream buffer is associated + * with this stream, calls that buffer's @c pubimbue(loc). + * + * Additional l10n notes are at + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html + */ + locale + imbue(const locale& __loc); + + /** + * @brief Squeezes characters. + * @param __c The character to narrow. + * @param __dfault The character to narrow. + * @return The narrowed character. + * + * Maps a character of @c char_type to a character of @c char, + * if possible. + * + * Returns the result of + * @code + * std::use_facet >(getloc()).narrow(c,dfault) + * @endcode + * + * Additional l10n notes are at + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html + */ + char + narrow(char_type __c, char __dfault) const + { return __check_facet(_M_ctype).narrow(__c, __dfault); } + + /** + * @brief Widens characters. + * @param __c The character to widen. + * @return The widened character. + * + * Maps a character of @c char to a character of @c char_type. + * + * Returns the result of + * @code + * std::use_facet >(getloc()).widen(c) + * @endcode + * + * Additional l10n notes are at + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/localization.html + */ + char_type + widen(char __c) const + { return __check_facet(_M_ctype).widen(__c); } + + protected: + // 27.4.5.1 basic_ios constructors + /** + * @brief Empty. + * + * The default constructor does nothing and is not normally + * accessible to users. + */ + basic_ios() + : ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false), + _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0) + { } + + /** + * @brief All setup is performed here. + * + * This is called from the public constructor. It is not virtual and + * cannot be redefined. + */ + void + init(basic_streambuf<_CharT, _Traits>* __sb); + +#if __cplusplus >= 201103L + basic_ios(const basic_ios&) = delete; + basic_ios& operator=(const basic_ios&) = delete; + + void + move(basic_ios& __rhs) + { + ios_base::_M_move(__rhs); + _M_cache_locale(_M_ios_locale); + this->tie(__rhs.tie(nullptr)); + _M_fill = __rhs._M_fill; + _M_fill_init = __rhs._M_fill_init; + _M_streambuf = nullptr; + } + + void + move(basic_ios&& __rhs) + { this->move(__rhs); } + + void + swap(basic_ios& __rhs) noexcept + { + ios_base::_M_swap(__rhs); + _M_cache_locale(_M_ios_locale); + __rhs._M_cache_locale(__rhs._M_ios_locale); + std::swap(_M_tie, __rhs._M_tie); + std::swap(_M_fill, __rhs._M_fill); + std::swap(_M_fill_init, __rhs._M_fill_init); + } + + void + set_rdbuf(basic_streambuf<_CharT, _Traits>* __sb) + { _M_streambuf = __sb; } +#endif + + void + _M_cache_locale(const locale& __loc); + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include + +#endif /* _BASIC_IOS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_ios.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_ios.tcc new file mode 100755 index 0000000..f79aad9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_ios.tcc @@ -0,0 +1,188 @@ +// basic_ios member functions -*- C++ -*- + +// Copyright (C) 1999-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_ios.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +#ifndef _BASIC_IOS_TCC +#define _BASIC_IOS_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + basic_ios<_CharT, _Traits>::clear(iostate __state) + { + if (this->rdbuf()) + _M_streambuf_state = __state; + else + _M_streambuf_state = __state | badbit; + if (this->exceptions() & this->rdstate()) + __throw_ios_failure(__N("basic_ios::clear")); + } + + template + basic_streambuf<_CharT, _Traits>* + basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<_CharT, _Traits>* __sb) + { + basic_streambuf<_CharT, _Traits>* __old = _M_streambuf; + _M_streambuf = __sb; + this->clear(); + return __old; + } + + template + basic_ios<_CharT, _Traits>& + basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 292. effects of a.copyfmt (a) + if (this != &__rhs) + { + // Per 27.1.1, do not call imbue, yet must trash all caches + // associated with imbue() + + // Alloc any new word array first, so if it fails we have "rollback". + _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? + _M_local_word : new _Words[__rhs._M_word_size]; + + // Bump refs before doing callbacks, for safety. + _Callback_list* __cb = __rhs._M_callbacks; + if (__cb) + __cb->_M_add_reference(); + _M_call_callbacks(erase_event); + if (_M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } + _M_dispose_callbacks(); + + // NB: Don't want any added during above. + _M_callbacks = __cb; + for (int __i = 0; __i < __rhs._M_word_size; ++__i) + __words[__i] = __rhs._M_word[__i]; + _M_word = __words; + _M_word_size = __rhs._M_word_size; + + this->flags(__rhs.flags()); + this->width(__rhs.width()); + this->precision(__rhs.precision()); + this->tie(__rhs.tie()); + this->fill(__rhs.fill()); + _M_ios_locale = __rhs.getloc(); + _M_cache_locale(_M_ios_locale); + + _M_call_callbacks(copyfmt_event); + + // The next is required to be the last assignment. + this->exceptions(__rhs.exceptions()); + } + return *this; + } + + // Locales: + template + locale + basic_ios<_CharT, _Traits>::imbue(const locale& __loc) + { + locale __old(this->getloc()); + ios_base::imbue(__loc); + _M_cache_locale(__loc); + if (this->rdbuf() != 0) + this->rdbuf()->pubimbue(__loc); + return __old; + } + + template + void + basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb) + { + // NB: This may be called more than once on the same object. + ios_base::_M_init(); + + // Cache locale data and specific facets used by iostreams. + _M_cache_locale(_M_ios_locale); + + // NB: The 27.4.4.1 Postconditions Table specifies requirements + // after basic_ios::init() has been called. As part of this, + // fill() must return widen(' ') any time after init() has been + // called, which needs an imbued ctype facet of char_type to + // return without throwing an exception. Unfortunately, + // ctype is not necessarily a required facet, so + // streams with char_type != [char, wchar_t] will not have it by + // default. Because of this, the correct value for _M_fill is + // constructed on the first call of fill(). That way, + // unformatted input and output with non-required basic_ios + // instantiations is possible even without imbuing the expected + // ctype facet. + _M_fill = _CharT(); + _M_fill_init = false; + + _M_tie = 0; + _M_exception = goodbit; + _M_streambuf = __sb; + _M_streambuf_state = __sb ? goodbit : badbit; + } + + template + void + basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc) + { + if (__builtin_expect(has_facet<__ctype_type>(__loc), true)) + _M_ctype = std::__addressof(use_facet<__ctype_type>(__loc)); + else + _M_ctype = 0; + + if (__builtin_expect(has_facet<__num_put_type>(__loc), true)) + _M_num_put = std::__addressof(use_facet<__num_put_type>(__loc)); + else + _M_num_put = 0; + + if (__builtin_expect(has_facet<__num_get_type>(__loc), true)) + _M_num_get = std::__addressof(use_facet<__num_get_type>(__loc)); + else + _M_num_get = 0; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_ios; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_ios; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_string.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_string.h new file mode 100755 index 0000000..5d09f77 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_string.h @@ -0,0 +1,7012 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_string.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _BASIC_STRING_H +#define _BASIC_STRING_H 1 + +#pragma GCC system_header + +#include +#include +#include + +#if __cplusplus >= 201103L +#include +#endif + +#if __cplusplus >= 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __cpp_lib_is_constant_evaluated +// Support P1032R1 in C++20 (but not P0980R1 yet). +# define __cpp_lib_constexpr_string 201811L +#elif __cplusplus >= 201703L +// Support P0426R1 changes to char_traits in C++17. +# define __cpp_lib_constexpr_string 201611L +#elif __cplusplus > 201703L +#endif + +#if _GLIBCXX_USE_CXX11_ABI +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + /** + * @class basic_string basic_string.h + * @brief Managing sequences of characters and character-like objects. + * + * @ingroup strings + * @ingroup sequences + * + * @tparam _CharT Type of character + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence. Of the + * optional sequence requirements, only + * @c push_back, @c at, and @c %array access are supported. + */ + template + class basic_string + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + + // Types: + public: + typedef _Traits traits_type; + typedef typename _Traits::char_type value_type; + typedef _Char_alloc_type allocator_type; + typedef typename _Alloc_traits::size_type size_type; + typedef typename _Alloc_traits::difference_type difference_type; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef __gnu_cxx::__normal_iterator iterator; + typedef __gnu_cxx::__normal_iterator + const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + + /// Value returned by various member functions when they fail. + static const size_type npos = static_cast(-1); + + protected: + // type used for positions in insert, erase etc. +#if __cplusplus < 201103L + typedef iterator __const_iterator; +#else + typedef const_iterator __const_iterator; +#endif + + private: +#if __cplusplus >= 201703L + // A helper type for avoiding boiler-plate. + typedef basic_string_view<_CharT, _Traits> __sv_type; + + template + using _If_sv = enable_if_t< + __and_, + __not_>, + __not_>>::value, + _Res>; + + // Allows an implicit conversion to __sv_type. + static __sv_type + _S_to_string_view(__sv_type __svt) noexcept + { return __svt; } + + // Wraps a string_view by explicit conversion and thus + // allows to add an internal constructor that does not + // participate in overload resolution when a string_view + // is provided. + struct __sv_wrapper + { + explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { } + __sv_type _M_sv; + }; + + /** + * @brief Only internally used: Construct string from a string view + * wrapper. + * @param __svw string view wrapper. + * @param __a Allocator to use. + */ + explicit + basic_string(__sv_wrapper __svw, const _Alloc& __a) + : basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { } +#endif + + // Use empty-base optimization: http://www.cantrip.org/emptyopt.html + struct _Alloc_hider : allocator_type // TODO check __is_final + { +#if __cplusplus < 201103L + _Alloc_hider(pointer __dat, const _Alloc& __a = _Alloc()) + : allocator_type(__a), _M_p(__dat) { } +#else + _Alloc_hider(pointer __dat, const _Alloc& __a) + : allocator_type(__a), _M_p(__dat) { } + + _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc()) + : allocator_type(std::move(__a)), _M_p(__dat) { } +#endif + + pointer _M_p; // The actual data. + }; + + _Alloc_hider _M_dataplus; + size_type _M_string_length; + + enum { _S_local_capacity = 15 / sizeof(_CharT) }; + + union + { + _CharT _M_local_buf[_S_local_capacity + 1]; + size_type _M_allocated_capacity; + }; + + void + _M_data(pointer __p) + { _M_dataplus._M_p = __p; } + + void + _M_length(size_type __length) + { _M_string_length = __length; } + + pointer + _M_data() const + { return _M_dataplus._M_p; } + + pointer + _M_local_data() + { +#if __cplusplus >= 201103L + return std::pointer_traits::pointer_to(*_M_local_buf); +#else + return pointer(_M_local_buf); +#endif + } + + const_pointer + _M_local_data() const + { +#if __cplusplus >= 201103L + return std::pointer_traits::pointer_to(*_M_local_buf); +#else + return const_pointer(_M_local_buf); +#endif + } + + void + _M_capacity(size_type __capacity) + { _M_allocated_capacity = __capacity; } + + void + _M_set_length(size_type __n) + { + _M_length(__n); + traits_type::assign(_M_data()[__n], _CharT()); + } + + bool + _M_is_local() const + { return _M_data() == _M_local_data(); } + + // Create & Destroy + pointer + _M_create(size_type&, size_type); + + void + _M_dispose() + { + if (!_M_is_local()) + _M_destroy(_M_allocated_capacity); + } + + void + _M_destroy(size_type __size) throw() + { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); } + + // _M_construct_aux is used to implement the 21.3.1 para 15 which + // requires special behaviour if _InIterator is an integral type + template + void + _M_construct_aux(_InIterator __beg, _InIterator __end, + std::__false_type) + { + typedef typename iterator_traits<_InIterator>::iterator_category _Tag; + _M_construct(__beg, __end, _Tag()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type) + { _M_construct_aux_2(static_cast(__beg), __end); } + + void + _M_construct_aux_2(size_type __req, _CharT __c) + { _M_construct(__req, __c); } + + template + void + _M_construct(_InIterator __beg, _InIterator __end) + { + typedef typename std::__is_integer<_InIterator>::__type _Integral; + _M_construct_aux(__beg, __end, _Integral()); + } + + // For Input Iterators, used in istreambuf_iterators, etc. + template + void + _M_construct(_InIterator __beg, _InIterator __end, + std::input_iterator_tag); + + // For forward_iterators up to random_access_iterators, used for + // string::iterator, _CharT*, etc. + template + void + _M_construct(_FwdIterator __beg, _FwdIterator __end, + std::forward_iterator_tag); + + void + _M_construct(size_type __req, _CharT __c); + + allocator_type& + _M_get_allocator() + { return _M_dataplus; } + + const allocator_type& + _M_get_allocator() const + { return _M_dataplus; } + + private: + +#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST + // The explicit instantiations in misc-inst.cc require this due to + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64063 + template::__value + && !__are_same<_Tp, const _CharT*>::__value + && !__are_same<_Tp, iterator>::__value + && !__are_same<_Tp, const_iterator>::__value> + struct __enable_if_not_native_iterator + { typedef basic_string& __type; }; + template + struct __enable_if_not_native_iterator<_Tp, false> { }; +#endif + + size_type + _M_check(size_type __pos, const char* __s) const + { + if (__pos > this->size()) + __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > " + "this->size() (which is %zu)"), + __s, __pos, this->size()); + return __pos; + } + + void + _M_check_length(size_type __n1, size_type __n2, const char* __s) const + { + if (this->max_size() - (this->size() - __n1) < __n2) + __throw_length_error(__N(__s)); + } + + + // NB: _M_limit doesn't check for a bad __pos value. + size_type + _M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT + { + const bool __testoff = __off < this->size() - __pos; + return __testoff ? __off : this->size() - __pos; + } + + // True if _Rep and source do not overlap. + bool + _M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT + { + return (less()(__s, _M_data()) + || less()(_M_data() + this->size(), __s)); + } + + // When __n = 1 way faster than the general multichar + // traits_type::copy/move/assign. + static void + _S_copy(_CharT* __d, const _CharT* __s, size_type __n) + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::copy(__d, __s, __n); + } + + static void + _S_move(_CharT* __d, const _CharT* __s, size_type __n) + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::move(__d, __s, __n); + } + + static void + _S_assign(_CharT* __d, size_type __n, _CharT __c) + { + if (__n == 1) + traits_type::assign(*__d, __c); + else + traits_type::assign(__d, __n, __c); + } + + // _S_copy_chars is a separate template to permit specialization + // to optimize for the common case of pointers as iterators. + template + static void + _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) + { + for (; __k1 != __k2; ++__k1, (void)++__p) + traits_type::assign(*__p, *__k1); // These types are off. + } + + static void + _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2) + _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT + { _S_copy(__p, __k1, __k2 - __k1); } + + static void + _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) + _GLIBCXX_NOEXCEPT + { _S_copy(__p, __k1, __k2 - __k1); } + + static int + _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT + { + const difference_type __d = difference_type(__n1 - __n2); + + if (__d > __gnu_cxx::__numeric_traits::__max) + return __gnu_cxx::__numeric_traits::__max; + else if (__d < __gnu_cxx::__numeric_traits::__min) + return __gnu_cxx::__numeric_traits::__min; + else + return int(__d); + } + + void + _M_assign(const basic_string&); + + void + _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, + size_type __len2); + + void + _M_erase(size_type __pos, size_type __n); + + public: + // Construct/copy/destroy: + // NB: We overload ctors in some cases instead of using default + // arguments, per 17.4.4.4 para. 2 item 2. + + /** + * @brief Default constructor creates an empty string. + */ + basic_string() + _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value) + : _M_dataplus(_M_local_data()) + { _M_set_length(0); } + + /** + * @brief Construct an empty string using allocator @a a. + */ + explicit + basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT + : _M_dataplus(_M_local_data(), __a) + { _M_set_length(0); } + + /** + * @brief Construct string with copy of value of @a __str. + * @param __str Source string. + */ + basic_string(const basic_string& __str) + : _M_dataplus(_M_local_data(), + _Alloc_traits::_S_select_on_copy(__str._M_get_allocator())) + { _M_construct(__str._M_data(), __str._M_data() + __str.length()); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2583. no way to supply an allocator for basic_string(str, pos) + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __a Allocator to use. + */ + basic_string(const basic_string& __str, size_type __pos, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { + const _CharT* __start = __str._M_data() + + __str._M_check(__pos, "basic_string::basic_string"); + _M_construct(__start, __start + __str._M_limit(__pos, npos)); + } + + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __n Number of characters to copy. + */ + basic_string(const basic_string& __str, size_type __pos, + size_type __n) + : _M_dataplus(_M_local_data()) + { + const _CharT* __start = __str._M_data() + + __str._M_check(__pos, "basic_string::basic_string"); + _M_construct(__start, __start + __str._M_limit(__pos, __n)); + } + + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __n Number of characters to copy. + * @param __a Allocator to use. + */ + basic_string(const basic_string& __str, size_type __pos, + size_type __n, const _Alloc& __a) + : _M_dataplus(_M_local_data(), __a) + { + const _CharT* __start + = __str._M_data() + __str._M_check(__pos, "string::string"); + _M_construct(__start, __start + __str._M_limit(__pos, __n)); + } + + /** + * @brief Construct string initialized by a character %array. + * @param __s Source character %array. + * @param __n Number of characters to copy. + * @param __a Allocator to use (default is default allocator). + * + * NB: @a __s must have at least @a __n characters, '\\0' + * has no special meaning. + */ + basic_string(const _CharT* __s, size_type __n, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__s, __s + __n); } + + /** + * @brief Construct string as copy of a C string. + * @param __s Source C string. + * @param __a Allocator to use (default is default allocator). + */ +#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3076. basic_string CTAD ambiguity + template> +#endif + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { + const _CharT* __end = __s ? __s + traits_type::length(__s) + // We just need a non-null pointer here to get an exception: + : reinterpret_cast(__alignof__(_CharT)); + _M_construct(__s, __end, random_access_iterator_tag()); + } + + /** + * @brief Construct string as multiple characters. + * @param __n Number of characters. + * @param __c Character to use. + * @param __a Allocator to use (default is default allocator). + */ +#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3076. basic_string CTAD ambiguity + template> +#endif + basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__n, __c); } + +#if __cplusplus >= 201103L + /** + * @brief Move construct string. + * @param __str Source string. + * + * The newly-created string contains the exact contents of @a __str. + * @a __str is a valid, but unspecified string. + */ + basic_string(basic_string&& __str) noexcept + : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator())) + { + if (__str._M_is_local()) + { + traits_type::copy(_M_local_buf, __str._M_local_buf, + _S_local_capacity + 1); + } + else + { + _M_data(__str._M_data()); + _M_capacity(__str._M_allocated_capacity); + } + + // Must use _M_length() here not _M_set_length() because + // basic_stringbuf relies on writing into unallocated capacity so + // we mess up the contents if we put a '\0' in the string. + _M_length(__str.length()); + __str._M_data(__str._M_local_data()); + __str._M_set_length(0); + } + + /** + * @brief Construct string from an initializer %list. + * @param __l std::initializer_list of characters. + * @param __a Allocator to use (default is default allocator). + */ + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__l.begin(), __l.end()); } + + basic_string(const basic_string& __str, const _Alloc& __a) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__str.begin(), __str.end()); } + + basic_string(basic_string&& __str, const _Alloc& __a) + noexcept(_Alloc_traits::_S_always_equal()) + : _M_dataplus(_M_local_data(), __a) + { + if (__str._M_is_local()) + { + traits_type::copy(_M_local_buf, __str._M_local_buf, + _S_local_capacity + 1); + _M_length(__str.length()); + __str._M_set_length(0); + } + else if (_Alloc_traits::_S_always_equal() + || __str.get_allocator() == __a) + { + _M_data(__str._M_data()); + _M_length(__str.length()); + _M_capacity(__str._M_allocated_capacity); + __str._M_data(__str._M_local_buf); + __str._M_set_length(0); + } + else + _M_construct(__str.begin(), __str.end()); + } + +#endif // C++11 + + /** + * @brief Construct string as copy of a range. + * @param __beg Start of range. + * @param __end End of range. + * @param __a Allocator to use (default is default allocator). + */ +#if __cplusplus >= 201103L + template> +#else + template +#endif + basic_string(_InputIterator __beg, _InputIterator __end, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_M_local_data(), __a) + { _M_construct(__beg, __end); } + +#if __cplusplus >= 201703L + /** + * @brief Construct string from a substring of a string_view. + * @param __t Source object convertible to string view. + * @param __pos The index of the first character to copy from __t. + * @param __n The number of characters to copy from __t. + * @param __a Allocator to use. + */ + template> + basic_string(const _Tp& __t, size_type __pos, size_type __n, + const _Alloc& __a = _Alloc()) + : basic_string(_S_to_string_view(__t).substr(__pos, __n), __a) { } + + /** + * @brief Construct string from a string_view. + * @param __t Source object convertible to string view. + * @param __a Allocator to use (default is default allocator). + */ + template> + explicit + basic_string(const _Tp& __t, const _Alloc& __a = _Alloc()) + : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { } +#endif // C++17 + + /** + * @brief Destroy the string instance. + */ + ~basic_string() + { _M_dispose(); } + + /** + * @brief Assign the value of @a str to this string. + * @param __str Source string. + */ + basic_string& + operator=(const basic_string& __str) + { + return this->assign(__str); + } + + /** + * @brief Copy contents of @a s into this string. + * @param __s Source null-terminated string. + */ + basic_string& + operator=(const _CharT* __s) + { return this->assign(__s); } + + /** + * @brief Set value to string of length 1. + * @param __c Source character. + * + * Assigning to a character makes this string length 1 and + * (*this)[0] == @a c. + */ + basic_string& + operator=(_CharT __c) + { + this->assign(1, __c); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Move assign the value of @a str to this string. + * @param __str Source string. + * + * The contents of @a str are moved into this string (without copying). + * @a str is a valid, but unspecified string. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2063. Contradictory requirements for string move assignment + basic_string& + operator=(basic_string&& __str) + noexcept(_Alloc_traits::_S_nothrow_move()) + { + if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign() + && !_Alloc_traits::_S_always_equal() + && _M_get_allocator() != __str._M_get_allocator()) + { + // Destroy existing storage before replacing allocator. + _M_destroy(_M_allocated_capacity); + _M_data(_M_local_data()); + _M_set_length(0); + } + // Replace allocator if POCMA is true. + std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator()); + + if (__str._M_is_local()) + { + // We've always got room for a short string, just copy it + // (unless this is a self-move, because that would violate the + // char_traits::copy precondition that the ranges don't overlap). + if (__builtin_expect(std::__addressof(__str) != this, true)) + { + if (__str.size()) + this->_S_copy(_M_data(), __str._M_data(), __str.size()); + _M_set_length(__str.size()); + } + } + else if (_Alloc_traits::_S_propagate_on_move_assign() + || _Alloc_traits::_S_always_equal() + || _M_get_allocator() == __str._M_get_allocator()) + { + // Just move the allocated pointer, our allocator can free it. + pointer __data = nullptr; + size_type __capacity; + if (!_M_is_local()) + { + if (_Alloc_traits::_S_always_equal()) + { + // __str can reuse our existing storage. + __data = _M_data(); + __capacity = _M_allocated_capacity; + } + else // __str can't use it, so free it. + _M_destroy(_M_allocated_capacity); + } + + _M_data(__str._M_data()); + _M_length(__str.length()); + _M_capacity(__str._M_allocated_capacity); + if (__data) + { + __str._M_data(__data); + __str._M_capacity(__capacity); + } + else + __str._M_data(__str._M_local_buf); + } + else // Need to do a deep copy + assign(__str); + __str.clear(); + return *this; + } + + /** + * @brief Set value to string constructed from initializer %list. + * @param __l std::initializer_list. + */ + basic_string& + operator=(initializer_list<_CharT> __l) + { + this->assign(__l.begin(), __l.size()); + return *this; + } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Set value to string constructed from a string_view. + * @param __svt An object convertible to string_view. + */ + template + _If_sv<_Tp, basic_string&> + operator=(const _Tp& __svt) + { return this->assign(__svt); } + + /** + * @brief Convert to a string_view. + * @return A string_view. + */ + operator __sv_type() const noexcept + { return __sv_type(data(), size()); } +#endif // C++17 + + // Iterators: + /** + * Returns a read/write iterator that points to the first character in + * the %string. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_M_data()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_M_data()); } + + /** + * Returns a read/write iterator that points one past the last + * character in the %string. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_M_data() + this->size()); } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_M_data() + this->size()); } + + /** + * Returns a read/write reverse iterator that points to the last + * character in the %string. Iteration is done in reverse element + * order. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last character in the %string. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->end()); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first character in the %string. Iteration is done in reverse + * element order. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first character in the %string. Iteration + * is done in reverse element order. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_data()); } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + const_iterator + cend() const noexcept + { return const_iterator(this->_M_data() + this->size()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last character in the %string. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(this->end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first character in the %string. Iteration + * is done in reverse element order. + */ + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(this->begin()); } +#endif + + public: + // Capacity: + /// Returns the number of characters in the string, not including any + /// null-termination. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_string_length; } + + /// Returns the number of characters in the string, not including any + /// null-termination. + size_type + length() const _GLIBCXX_NOEXCEPT + { return _M_string_length; } + + /// Returns the size() of the largest possible %string. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; } + + /** + * @brief Resizes the %string to the specified number of characters. + * @param __n Number of characters the %string should contain. + * @param __c Character to fill any new elements. + * + * This function will %resize the %string to the specified + * number of characters. If the number is smaller than the + * %string's current size the %string is truncated, otherwise + * the %string is extended and new elements are %set to @a __c. + */ + void + resize(size_type __n, _CharT __c); + + /** + * @brief Resizes the %string to the specified number of characters. + * @param __n Number of characters the %string should contain. + * + * This function will resize the %string to the specified length. If + * the new size is smaller than the %string's current size the %string + * is truncated, otherwise the %string is extended and new characters + * are default-constructed. For basic types such as char, this means + * setting them to 0. + */ + void + resize(size_type __n) + { this->resize(__n, _CharT()); } + +#if __cplusplus >= 201103L +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /// A non-binding request to reduce capacity() to size(). + void + shrink_to_fit() noexcept + { reserve(); } +#pragma GCC diagnostic pop +#endif + + /** + * Returns the total number of characters that the %string can hold + * before needing to allocate more memory. + */ + size_type + capacity() const _GLIBCXX_NOEXCEPT + { + return _M_is_local() ? size_type(_S_local_capacity) + : _M_allocated_capacity; + } + + /** + * @brief Attempt to preallocate enough memory for specified number of + * characters. + * @param __res_arg Number of characters required. + * @throw std::length_error If @a __res_arg exceeds @c max_size(). + * + * This function attempts to reserve enough memory for the + * %string to hold the specified number of characters. If the + * number requested is more than max_size(), length_error is + * thrown. + * + * The advantage of this function is that if optimal code is a + * necessity and the user can determine the string length that will be + * required, the user can reserve the memory in %advance, and thus + * prevent a possible reallocation of memory and copying of %string + * data. + */ + void + reserve(size_type __res_arg); + + /** + * Equivalent to shrink_to_fit(). + */ +#if __cplusplus > 201703L + [[deprecated("use shrink_to_fit() instead")]] +#endif + void + reserve(); + + /** + * Erases the string, making it empty. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_set_length(0); } + + /** + * Returns true if the %string is empty. Equivalent to + * *this == "". + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return this->size() == 0; } + + // Element access: + /** + * @brief Subscript access to the data contained in the %string. + * @param __pos The index of the character to access. + * @return Read-only (constant) reference to the character. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + const_reference + operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT + { + __glibcxx_assert(__pos <= size()); + return _M_data()[__pos]; + } + + /** + * @brief Subscript access to the data contained in the %string. + * @param __pos The index of the character to access. + * @return Read/write reference to the character. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + reference + operator[](size_type __pos) + { + // Allow pos == size() both in C++98 mode, as v3 extension, + // and in C++11 mode. + __glibcxx_assert(__pos <= size()); + // In pedantic mode be strict in C++98 mode. + _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos < size()); + return _M_data()[__pos]; + } + + /** + * @brief Provides access to the data contained in the %string. + * @param __n The index of the character to access. + * @return Read-only (const) reference to the character. + * @throw std::out_of_range If @a n is an invalid index. + * + * This function provides for safer data access. The parameter is + * first checked that it is in the range of the string. The function + * throws out_of_range if the check fails. + */ + const_reference + at(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("basic_string::at: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + return _M_data()[__n]; + } + + /** + * @brief Provides access to the data contained in the %string. + * @param __n The index of the character to access. + * @return Read/write reference to the character. + * @throw std::out_of_range If @a n is an invalid index. + * + * This function provides for safer data access. The parameter is + * first checked that it is in the range of the string. The function + * throws out_of_range if the check fails. + */ + reference + at(size_type __n) + { + if (__n >= size()) + __throw_out_of_range_fmt(__N("basic_string::at: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + return _M_data()[__n]; + } + +#if __cplusplus >= 201103L + /** + * Returns a read/write reference to the data at the first + * element of the %string. + */ + reference + front() noexcept + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %string. + */ + const_reference + front() const noexcept + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %string. + */ + reference + back() noexcept + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } + + /** + * Returns a read-only (constant) reference to the data at the + * last element of the %string. + */ + const_reference + back() const noexcept + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } +#endif + + // Modifiers: + /** + * @brief Append a string to this string. + * @param __str The string to append. + * @return Reference to this string. + */ + basic_string& + operator+=(const basic_string& __str) + { return this->append(__str); } + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + basic_string& + operator+=(const _CharT* __s) + { return this->append(__s); } + + /** + * @brief Append a character. + * @param __c The character to append. + * @return Reference to this string. + */ + basic_string& + operator+=(_CharT __c) + { + this->push_back(__c); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Append an initializer_list of characters. + * @param __l The initializer_list of characters to be appended. + * @return Reference to this string. + */ + basic_string& + operator+=(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt An object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + operator+=(const _Tp& __svt) + { return this->append(__svt); } +#endif // C++17 + + /** + * @brief Append a string to this string. + * @param __str The string to append. + * @return Reference to this string. + */ + basic_string& + append(const basic_string& __str) + { return _M_append(__str._M_data(), __str.size()); } + + /** + * @brief Append a substring. + * @param __str The string to append. + * @param __pos Index of the first character of str to append. + * @param __n The number of characters to append. + * @return Reference to this string. + * @throw std::out_of_range if @a __pos is not a valid index. + * + * This function appends @a __n characters from @a __str + * starting at @a __pos to this string. If @a __n is is larger + * than the number of available characters in @a __str, the + * remainder of @a __str is appended. + */ + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n = npos) + { return _M_append(__str._M_data() + + __str._M_check(__pos, "basic_string::append"), + __str._M_limit(__pos, __n)); } + + /** + * @brief Append a C substring. + * @param __s The C string to append. + * @param __n The number of characters to append. + * @return Reference to this string. + */ + basic_string& + append(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check_length(size_type(0), __n, "basic_string::append"); + return _M_append(__s, __n); + } + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + basic_string& + append(const _CharT* __s) + { + __glibcxx_requires_string(__s); + const size_type __n = traits_type::length(__s); + _M_check_length(size_type(0), __n, "basic_string::append"); + return _M_append(__s, __n); + } + + /** + * @brief Append multiple characters. + * @param __n The number of characters to append. + * @param __c The character to use. + * @return Reference to this string. + * + * Appends __n copies of __c to this string. + */ + basic_string& + append(size_type __n, _CharT __c) + { return _M_replace_aux(this->size(), size_type(0), __n, __c); } + +#if __cplusplus >= 201103L + /** + * @brief Append an initializer_list of characters. + * @param __l The initializer_list of characters to append. + * @return Reference to this string. + */ + basic_string& + append(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.size()); } +#endif // C++11 + + /** + * @brief Append a range of characters. + * @param __first Iterator referencing the first character to append. + * @param __last Iterator marking the end of the range. + * @return Reference to this string. + * + * Appends characters in the range [__first,__last) to this string. + */ +#if __cplusplus >= 201103L + template> +#else + template +#endif + basic_string& + append(_InputIterator __first, _InputIterator __last) + { return this->replace(end(), end(), __first, __last); } + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt An object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->append(__sv.data(), __sv.size()); + } + + /** + * @brief Append a range of characters from a string_view. + * @param __svt An object convertible to string_view to be appended from. + * @param __pos The position in the string_view to append from. + * @param __n The number of characters to append from the string_view. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return _M_append(__sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::append"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + + /** + * @brief Append a single character. + * @param __c Character to append. + */ + void + push_back(_CharT __c) + { + const size_type __size = this->size(); + if (__size + 1 > this->capacity()) + this->_M_mutate(__size, size_type(0), 0, size_type(1)); + traits_type::assign(this->_M_data()[__size], __c); + this->_M_set_length(__size + 1); + } + + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + */ + basic_string& + assign(const basic_string& __str) + { +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + if (!_Alloc_traits::_S_always_equal() && !_M_is_local() + && _M_get_allocator() != __str._M_get_allocator()) + { + // Propagating allocator cannot free existing storage so must + // deallocate it before replacing current allocator. + if (__str.size() <= _S_local_capacity) + { + _M_destroy(_M_allocated_capacity); + _M_data(_M_local_data()); + _M_set_length(0); + } + else + { + const auto __len = __str.size(); + auto __alloc = __str._M_get_allocator(); + // If this allocation throws there are no effects: + auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1); + _M_destroy(_M_allocated_capacity); + _M_data(__ptr); + _M_capacity(__len); + _M_set_length(__len); + } + } + std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator()); + } +#endif + this->_M_assign(__str); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + * + * This function sets this string to the exact contents of @a __str. + * @a __str is a valid, but unspecified string. + */ + basic_string& + assign(basic_string&& __str) + noexcept(_Alloc_traits::_S_nothrow_move()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2063. Contradictory requirements for string move assignment + return *this = std::move(__str); + } +#endif // C++11 + + /** + * @brief Set value to a substring of a string. + * @param __str The string to use. + * @param __pos Index of the first character of str. + * @param __n Number of characters to use. + * @return Reference to this string. + * @throw std::out_of_range if @a pos is not a valid index. + * + * This function sets this string to the substring of @a __str + * consisting of @a __n characters at @a __pos. If @a __n is + * is larger than the number of available characters in @a + * __str, the remainder of @a __str is used. + */ + basic_string& + assign(const basic_string& __str, size_type __pos, size_type __n = npos) + { return _M_replace(size_type(0), this->size(), __str._M_data() + + __str._M_check(__pos, "basic_string::assign"), + __str._M_limit(__pos, __n)); } + + /** + * @brief Set value to a C substring. + * @param __s The C string to use. + * @param __n Number of characters to use. + * @return Reference to this string. + * + * This function sets the value of this string to the first @a __n + * characters of @a __s. If @a __n is is larger than the number of + * available characters in @a __s, the remainder of @a __s is used. + */ + basic_string& + assign(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + return _M_replace(size_type(0), this->size(), __s, __n); + } + + /** + * @brief Set value to contents of a C string. + * @param __s The C string to use. + * @return Reference to this string. + * + * This function sets the value of this string to the value of @a __s. + * The data is copied, so there is no dependence on @a __s once the + * function returns. + */ + basic_string& + assign(const _CharT* __s) + { + __glibcxx_requires_string(__s); + return _M_replace(size_type(0), this->size(), __s, + traits_type::length(__s)); + } + + /** + * @brief Set value to multiple characters. + * @param __n Length of the resulting string. + * @param __c The character to use. + * @return Reference to this string. + * + * This function sets the value of this string to @a __n copies of + * character @a __c. + */ + basic_string& + assign(size_type __n, _CharT __c) + { return _M_replace_aux(size_type(0), this->size(), __n, __c); } + + /** + * @brief Set value to a range of characters. + * @param __first Iterator referencing the first character to append. + * @param __last Iterator marking the end of the range. + * @return Reference to this string. + * + * Sets value of string to characters in the range [__first,__last). + */ +#if __cplusplus >= 201103L + template> +#else + template +#endif + basic_string& + assign(_InputIterator __first, _InputIterator __last) + { return this->replace(begin(), end(), __first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Set value to an initializer_list of characters. + * @param __l The initializer_list of characters to assign. + * @return Reference to this string. + */ + basic_string& + assign(initializer_list<_CharT> __l) + { return this->assign(__l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Set value from a string_view. + * @param __svt The source object convertible to string_view. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->assign(__sv.data(), __sv.size()); + } + + /** + * @brief Set value from a range of characters in a string_view. + * @param __svt The source object convertible to string_view. + * @param __pos The position in the string_view to assign from. + * @param __n The number of characters to assign. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return _M_replace(size_type(0), this->size(), + __sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::assign"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + +#if __cplusplus >= 201103L + /** + * @brief Insert multiple characters. + * @param __p Const_iterator referencing location in string to + * insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @return Iterator referencing the first inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts @a __n copies of character @a __c starting at the + * position referenced by iterator @a __p. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + iterator + insert(const_iterator __p, size_type __n, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + const size_type __pos = __p - begin(); + this->replace(__p, __p, __n, __c); + return iterator(this->_M_data() + __pos); + } +#else + /** + * @brief Insert multiple characters. + * @param __p Iterator referencing location in string to insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts @a __n copies of character @a __c starting at the + * position referenced by iterator @a __p. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + void + insert(iterator __p, size_type __n, _CharT __c) + { this->replace(__p, __p, __n, __c); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert a range of characters. + * @param __p Const_iterator referencing location in string to + * insert at. + * @param __beg Start of range. + * @param __end End of range. + * @return Iterator referencing the first inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts characters in range [beg,end). If adding characters + * causes the length to exceed max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + template> + iterator + insert(const_iterator __p, _InputIterator __beg, _InputIterator __end) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + const size_type __pos = __p - begin(); + this->replace(__p, __p, __beg, __end); + return iterator(this->_M_data() + __pos); + } +#else + /** + * @brief Insert a range of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __beg Start of range. + * @param __end End of range. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts characters in range [__beg,__end). If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + template + void + insert(iterator __p, _InputIterator __beg, _InputIterator __end) + { this->replace(__p, __p, __beg, __end); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert an initializer_list of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __l The initializer_list of characters to insert. + * @throw std::length_error If new length exceeds @c max_size(). + */ + iterator + insert(const_iterator __p, initializer_list<_CharT> __l) + { return this->insert(__p, __l.begin(), __l.end()); } + +#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // See PR libstdc++/83328 + void + insert(iterator __p, initializer_list<_CharT> __l) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + this->insert(__p - begin(), __l.begin(), __l.size()); + } +#endif +#endif // C++11 + + /** + * @brief Insert value of a string. + * @param __pos1 Position in string to insert at. + * @param __str The string to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts value of @a __str starting at @a __pos1. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + insert(size_type __pos1, const basic_string& __str) + { return this->replace(__pos1, size_type(0), + __str._M_data(), __str.size()); } + + /** + * @brief Insert a substring. + * @param __pos1 Position in string to insert at. + * @param __str The string to insert. + * @param __pos2 Start of characters in str to insert. + * @param __n Number of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a pos1 > size() or + * @a __pos2 > @a str.size(). + * + * Starting at @a pos1, insert @a __n character of @a __str + * beginning with @a __pos2. If adding characters causes the + * length to exceed max_size(), length_error is thrown. If @a + * __pos1 is beyond the end of this string or @a __pos2 is + * beyond the end of @a __str, out_of_range is thrown. The + * value of the string doesn't change if an error is thrown. + */ + basic_string& + insert(size_type __pos1, const basic_string& __str, + size_type __pos2, size_type __n = npos) + { return this->replace(__pos1, size_type(0), __str._M_data() + + __str._M_check(__pos2, "basic_string::insert"), + __str._M_limit(__pos2, __n)); } + + /** + * @brief Insert a C substring. + * @param __pos Position in string to insert at. + * @param __s The C string to insert. + * @param __n The number of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a __pos is beyond the end of this + * string. + * + * Inserts the first @a __n characters of @a __s starting at @a + * __pos. If adding characters causes the length to exceed + * max_size(), length_error is thrown. If @a __pos is beyond + * end(), out_of_range is thrown. The value of the string + * doesn't change if an error is thrown. + */ + basic_string& + insert(size_type __pos, const _CharT* __s, size_type __n) + { return this->replace(__pos, size_type(0), __s, __n); } + + /** + * @brief Insert a C string. + * @param __pos Position in string to insert at. + * @param __s The C string to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * + * Inserts the first @a n characters of @a __s starting at @a __pos. If + * adding characters causes the length to exceed max_size(), + * length_error is thrown. If @a __pos is beyond end(), out_of_range is + * thrown. The value of the string doesn't change if an error is + * thrown. + */ + basic_string& + insert(size_type __pos, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__pos, size_type(0), __s, + traits_type::length(__s)); + } + + /** + * @brief Insert multiple characters. + * @param __pos Index in string to insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a __pos is beyond the end of this + * string. + * + * Inserts @a __n copies of character @a __c starting at index + * @a __pos. If adding characters causes the length to exceed + * max_size(), length_error is thrown. If @a __pos > length(), + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + insert(size_type __pos, size_type __n, _CharT __c) + { return _M_replace_aux(_M_check(__pos, "basic_string::insert"), + size_type(0), __n, __c); } + + /** + * @brief Insert one character. + * @param __p Iterator referencing position in string to insert at. + * @param __c The character to insert. + * @return Iterator referencing newly inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts character @a __c at position referenced by @a __p. + * If adding character causes the length to exceed max_size(), + * length_error is thrown. If @a __p is beyond end of string, + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + iterator + insert(__const_iterator __p, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end()); + const size_type __pos = __p - begin(); + _M_replace_aux(__pos, size_type(0), size_type(1), __c); + return iterator(_M_data() + __pos); + } + +#if __cplusplus >= 201703L + /** + * @brief Insert a string_view. + * @param __pos Position in string to insert at. + * @param __svt The object convertible to string_view to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + insert(size_type __pos, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->insert(__pos, __sv.data(), __sv.size()); + } + + /** + * @brief Insert a string_view. + * @param __pos1 Position in string to insert at. + * @param __svt The object convertible to string_view to insert from. + * @param __pos2 Start of characters in str to insert. + * @param __n The number of characters to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + insert(size_type __pos1, const _Tp& __svt, + size_type __pos2, size_type __n = npos) + { + __sv_type __sv = __svt; + return this->replace(__pos1, size_type(0), + __sv.data() + + std::__sv_check(__sv.size(), __pos2, "basic_string::insert"), + std::__sv_limit(__sv.size(), __pos2, __n)); + } +#endif // C++17 + + /** + * @brief Remove characters. + * @param __pos Index of first character to remove (default 0). + * @param __n Number of characters to remove (default remainder). + * @return Reference to this string. + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * + * Removes @a __n characters from this string starting at @a + * __pos. The length of the string is reduced by @a __n. If + * there are < @a __n characters to remove, the remainder of + * the string is truncated. If @a __p is beyond end of string, + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + erase(size_type __pos = 0, size_type __n = npos) + { + _M_check(__pos, "basic_string::erase"); + if (__n == npos) + this->_M_set_length(__pos); + else if (__n != 0) + this->_M_erase(__pos, _M_limit(__pos, __n)); + return *this; + } + + /** + * @brief Remove one character. + * @param __position Iterator referencing the character to remove. + * @return iterator referencing same location after removal. + * + * Removes the character at @a __position from this string. The value + * of the string doesn't change if an error is thrown. + */ + iterator + erase(__const_iterator __position) + { + _GLIBCXX_DEBUG_PEDASSERT(__position >= begin() + && __position < end()); + const size_type __pos = __position - begin(); + this->_M_erase(__pos, size_type(1)); + return iterator(_M_data() + __pos); + } + + /** + * @brief Remove a range of characters. + * @param __first Iterator referencing the first character to remove. + * @param __last Iterator referencing the end of the range. + * @return Iterator referencing location of first after removal. + * + * Removes the characters in the range [first,last) from this string. + * The value of the string doesn't change if an error is thrown. + */ + iterator + erase(__const_iterator __first, __const_iterator __last) + { + _GLIBCXX_DEBUG_PEDASSERT(__first >= begin() && __first <= __last + && __last <= end()); + const size_type __pos = __first - begin(); + if (__last == end()) + this->_M_set_length(__pos); + else + this->_M_erase(__pos, __last - __first); + return iterator(this->_M_data() + __pos); + } + +#if __cplusplus >= 201103L + /** + * @brief Remove the last character. + * + * The string must be non-empty. + */ + void + pop_back() noexcept + { + __glibcxx_assert(!empty()); + _M_erase(size() - 1, 1); + } +#endif // C++11 + + /** + * @brief Replace characters with value from another string. + * @param __pos Index of first character to replace. + * @param __n Number of characters to be replaced. + * @param __str String to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos+__n) from + * this string. In place, the value of @a __str is inserted. + * If @a __pos is beyond end of string, out_of_range is thrown. + * If the length of the result exceeds max_size(), length_error + * is thrown. The value of the string doesn't change if an + * error is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n, const basic_string& __str) + { return this->replace(__pos, __n, __str._M_data(), __str.size()); } + + /** + * @brief Replace characters with value from another string. + * @param __pos1 Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __str String to insert. + * @param __pos2 Index of first character of str to use. + * @param __n2 Number of characters from str to use. + * @return Reference to this string. + * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 > + * __str.size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos1,__pos1 + n) from this + * string. In place, the value of @a __str is inserted. If @a __pos is + * beyond end of string, out_of_range is thrown. If the length of the + * result exceeds max_size(), length_error is thrown. The value of the + * string doesn't change if an error is thrown. + */ + basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2 = npos) + { return this->replace(__pos1, __n1, __str._M_data() + + __str._M_check(__pos2, "basic_string::replace"), + __str._M_limit(__pos2, __n2)); } + + /** + * @brief Replace characters with value of a C substring. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __s C string to insert. + * @param __n2 Number of characters from @a s to use. + * @return Reference to this string. + * @throw std::out_of_range If @a pos1 > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos + __n1) + * from this string. In place, the first @a __n2 characters of + * @a __s are inserted, or all of @a __s if @a __n2 is too large. If + * @a __pos is beyond end of string, out_of_range is thrown. If + * the length of result exceeds max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) + { + __glibcxx_requires_string_len(__s, __n2); + return _M_replace(_M_check(__pos, "basic_string::replace"), + _M_limit(__pos, __n1), __s, __n2); + } + + /** + * @brief Replace characters with value of a C string. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __s C string to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a pos > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos + __n1) + * from this string. In place, the characters of @a __s are + * inserted. If @a __pos is beyond end of string, out_of_range + * is thrown. If the length of result exceeds max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__pos, __n1, __s, traits_type::length(__s)); + } + + /** + * @brief Replace characters with multiple characters. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __n2 Number of characters to insert. + * @param __c Character to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a __pos > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [pos,pos + n1) from this + * string. In place, @a __n2 copies of @a __c are inserted. + * If @a __pos is beyond end of string, out_of_range is thrown. + * If the length of result exceeds max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) + { return _M_replace_aux(_M_check(__pos, "basic_string::replace"), + _M_limit(__pos, __n1), __n2, __c); } + + /** + * @brief Replace range of characters with string. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __str String value to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the value of @a __str is inserted. If the length of result + * exceeds max_size(), length_error is thrown. The value of + * the string doesn't change if an error is thrown. + */ + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const basic_string& __str) + { return this->replace(__i1, __i2, __str._M_data(), __str.size()); } + + /** + * @brief Replace range of characters with C substring. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __s C string value to insert. + * @param __n Number of characters from s to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the first @a __n characters of @a __s are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const _CharT* __s, size_type __n) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + return this->replace(__i1 - begin(), __i2 - __i1, __s, __n); + } + + /** + * @brief Replace range of characters with C string. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __s C string value to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the characters of @a __s are inserted. If the length of + * result exceeds max_size(), length_error is thrown. The + * value of the string doesn't change if an error is thrown. + */ + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__i1, __i2, __s, traits_type::length(__s)); + } + + /** + * @brief Replace range of characters with multiple characters + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __n Number of characters to insert. + * @param __c Character to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * @a __n copies of @a __c are inserted. If the length of + * result exceeds max_size(), length_error is thrown. The + * value of the string doesn't change if an error is thrown. + */ + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, size_type __n, + _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __c); + } + + /** + * @brief Replace range of characters with range. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __k1 Iterator referencing start of range to insert. + * @param __k2 Iterator referencing end of range to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * characters in the range [__k1,__k2) are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ +#if __cplusplus >= 201103L + template> + basic_string& + replace(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->_M_replace_dispatch(__i1, __i2, __k1, __k2, + std::__false_type()); + } +#else + template +#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST + typename __enable_if_not_native_iterator<_InputIterator>::__type +#else + basic_string& +#endif + replace(iterator __i1, iterator __i2, + _InputIterator __k1, _InputIterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral()); + } +#endif + + // Specializations for the common case of pointer and iterator: + // useful to avoid the overhead of temporary buffering in _M_replace. + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + _CharT* __k1, _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const _CharT* __k1, const _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + iterator __k1, iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const_iterator __k1, const_iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2 + && __i2 <= end()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - begin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + +#if __cplusplus >= 201103L + /** + * @brief Replace range of characters with initializer_list. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __l The initializer_list of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * characters in the range [__k1,__k2) are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + basic_string& replace(const_iterator __i1, const_iterator __i2, + initializer_list<_CharT> __l) + { return this->replace(__i1, __i2, __l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Replace range of characters with string_view. + * @param __pos The position to replace at. + * @param __n The number of characters to replace. + * @param __svt The object convertible to string_view to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + replace(size_type __pos, size_type __n, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->replace(__pos, __n, __sv.data(), __sv.size()); + } + + /** + * @brief Replace range of characters with string_view. + * @param __pos1 The position to replace at. + * @param __n1 The number of characters to replace. + * @param __svt The object convertible to string_view to insert from. + * @param __pos2 The position in the string_view to insert from. + * @param __n2 The number of characters to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + replace(size_type __pos1, size_type __n1, const _Tp& __svt, + size_type __pos2, size_type __n2 = npos) + { + __sv_type __sv = __svt; + return this->replace(__pos1, __n1, + __sv.data() + + std::__sv_check(__sv.size(), __pos2, "basic_string::replace"), + std::__sv_limit(__sv.size(), __pos2, __n2)); + } + + /** + * @brief Replace range of characters with string_view. + * @param __i1 An iterator referencing the start position + to replace at. + * @param __i2 An iterator referencing the end position + for the replace. + * @param __svt The object convertible to string_view to insert from. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->replace(__i1 - begin(), __i2 - __i1, __sv); + } +#endif // C++17 + + private: + template + basic_string& + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _Integer __n, _Integer __val, __true_type) + { return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __val); } + + template + basic_string& + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + __false_type); + + basic_string& + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c); + + basic_string& + _M_replace(size_type __pos, size_type __len1, const _CharT* __s, + const size_type __len2); + + basic_string& + _M_append(const _CharT* __s, size_type __n); + + public: + + /** + * @brief Copy substring into C string. + * @param __s C string to copy value into. + * @param __n Number of characters to copy. + * @param __pos Index of first character to copy. + * @return Number of characters actually copied + * @throw std::out_of_range If __pos > size(). + * + * Copies up to @a __n characters starting at @a __pos into the + * C string @a __s. If @a __pos is %greater than size(), + * out_of_range is thrown. + */ + size_type + copy(_CharT* __s, size_type __n, size_type __pos = 0) const; + + /** + * @brief Swap contents with another string. + * @param __s String to swap with. + * + * Exchanges the contents of this string with that of @a __s in constant + * time. + */ + void + swap(basic_string& __s) _GLIBCXX_NOEXCEPT; + + // String operations: + /** + * @brief Return const pointer to null-terminated contents. + * + * This is a handle to internal data. Do not modify or dire things may + * happen. + */ + const _CharT* + c_str() const _GLIBCXX_NOEXCEPT + { return _M_data(); } + + /** + * @brief Return const pointer to contents. + * + * This is a pointer to internal data. It is undefined to modify + * the contents through the returned pointer. To get a pointer that + * allows modifying the contents use @c &str[0] instead, + * (or in C++17 the non-const @c str.data() overload). + */ + const _CharT* + data() const _GLIBCXX_NOEXCEPT + { return _M_data(); } + +#if __cplusplus >= 201703L + /** + * @brief Return non-const pointer to contents. + * + * This is a pointer to the character sequence held by the string. + * Modifying the characters in the sequence is allowed. + */ + _CharT* + data() noexcept + { return _M_data(); } +#endif + + /** + * @brief Return copy of allocator used to construct this string. + */ + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return _M_get_allocator(); } + + /** + * @brief Find position of a C substring. + * @param __s C string to locate. + * @param __pos Index of character to search from. + * @param __n Number of characters from @a s to search for. + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for the first @a + * __n characters in @a __s within this string. If found, + * returns the index where it begins. If not found, returns + * npos. + */ + size_type + find(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a string. + * @param __str String to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for value of @a __str within + * this string. If found, returns the index where it begins. If not + * found, returns npos. + */ + size_type + find(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a string_view. + * @param __svt The object convertible to string_view to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + */ + template + _If_sv<_Tp, size_type> + find(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a C string. + * @param __s C string to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for the value of @a + * __s within this string. If found, returns the index where + * it begins. If not found, returns npos. + */ + size_type + find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a string. + * @param __str String to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for value of @a + * __str within this string. If found, returns the index where + * it begins. If not found, returns npos. + */ + size_type + rfind(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->rfind(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a string_view. + * @param __svt The object convertible to string_view to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of start of last occurrence. + */ + template + _If_sv<_Tp, size_type> + rfind(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->rfind(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a C substring. + * @param __s C string to locate. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to search for. + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for the first @a + * __n characters in @a __s within this string. If found, + * returns the index where it begins. If not found, returns + * npos. + */ + size_type + rfind(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a C string. + * @param __s C string to locate. + * @param __pos Index of character to start search at (default end). + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for the value of + * @a __s within this string. If found, returns the index + * where it begins. If not found, returns npos. + */ + size_type + rfind(const _CharT* __s, size_type __pos = npos) const + { + __glibcxx_requires_string(__s); + return this->rfind(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character of string. + * @param __str String containing characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * characters of @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_first_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find_first_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a character of a string_view. + * @param __svt An object convertible to string_view containing + * characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + */ + template + _If_sv<_Tp, size_type> + find_first_of(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_first_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a character of C substring. + * @param __s String containing characters to locate. + * @param __pos Index of character to search from. + * @param __n Number of characters from s to search for. + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * first @a __n characters of @a __s within this string. If + * found, returns the index where it was found. If not found, + * returns npos. + */ + size_type + find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character of C string. + * @param __s String containing characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * characters of @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + size_type + find_first_of(const _CharT* __s, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_first_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for the character + * @a __c within this string. If found, returns the index + * where it was found. If not found, returns npos. + * + * Note: equivalent to find(__c, __pos). + */ + size_type + find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return this->find(__c, __pos); } + + /** + * @brief Find last position of a character of string. + * @param __str String containing characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * characters of @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_last_of(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->find_last_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a character of string. + * @param __svt An object convertible to string_view containing + * characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + */ + template + _If_sv<_Tp, size_type> + find_last_of(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_last_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a character of C substring. + * @param __s C string containing characters to locate. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to search for. + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * first @a __n characters of @a __s within this string. If + * found, returns the index where it was found. If not found, + * returns npos. + */ + size_type + find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a character of C string. + * @param __s C string containing characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * characters of @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + size_type + find_last_of(const _CharT* __s, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_last_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + * + * Note: equivalent to rfind(__c, __pos). + */ + size_type + find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT + { return this->rfind(__c, __pos); } + + /** + * @brief Find position of a character not in string. + * @param __str String containing characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not contained + * in @a __str within this string. If found, returns the index where it + * was found. If not found, returns npos. + */ + size_type + find_first_not_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find_first_not_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a character not in a string_view. + * @param __svt A object convertible to string_view containing + * characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + */ + template + _If_sv<_Tp, size_type> + find_first_not_of(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_first_not_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a character not in C substring. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search from. + * @param __n Number of characters from __s to consider. + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not + * contained in the first @a __n characters of @a __s within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + find_first_not_of(const _CharT* __s, size_type __pos, + size_type __n) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character not in C string. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not + * contained in @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + size_type + find_first_not_of(const _CharT* __s, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_first_not_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a different character. + * @param __c Character to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character + * other than @a __c within this string. If found, returns the + * index where it was found. If not found, returns npos. + */ + size_type + find_first_not_of(_CharT __c, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a character not in string. + * @param __str String containing characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character + * not contained in @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_last_not_of(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->find_last_not_of(__str.data(), __pos, __str.size()); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a character not in a string_view. + * @param __svt An object convertible to string_view containing + * characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + */ + template + _If_sv<_Tp, size_type> + find_last_not_of(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_last_not_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a character not in C substring. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to consider. + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character not + * contained in the first @a __n characters of @a __s within this string. + * If found, returns the index where it was found. If not found, + * returns npos. + */ + size_type + find_last_not_of(const _CharT* __s, size_type __pos, + size_type __n) const _GLIBCXX_NOEXCEPT; + /** + * @brief Find last position of a character not in C string. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character + * not contained in @a __s within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_last_not_of(const _CharT* __s, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_last_not_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a different character. + * @param __c Character to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character other than + * @a __c within this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + find_last_not_of(_CharT __c, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Get a substring. + * @param __pos Index of first character (default 0). + * @param __n Number of characters in substring (default remainder). + * @return The new string. + * @throw std::out_of_range If __pos > size(). + * + * Construct and return a new string using the @a __n + * characters starting at @a __pos. If the string is too + * short, use the remainder of the characters. If @a __pos is + * beyond the end of the string, out_of_range is thrown. + */ + basic_string + substr(size_type __pos = 0, size_type __n = npos) const + { return basic_string(*this, + _M_check(__pos, "basic_string::substr"), __n); } + + /** + * @brief Compare to a string. + * @param __str String to compare against. + * @return Integer < 0, 0, or > 0. + * + * Returns an integer < 0 if this string is ordered before @a + * __str, 0 if their values are equivalent, or > 0 if this + * string is ordered after @a __str. Determines the effective + * length rlen of the strings to compare as the smallest of + * size() and str.size(). The function then compares the two + * strings by calling traits::compare(data(), str.data(),rlen). + * If the result of the comparison is nonzero returns it, + * otherwise the shorter one is ordered first. + */ + int + compare(const basic_string& __str) const + { + const size_type __size = this->size(); + const size_type __osize = __str.size(); + const size_type __len = std::min(__size, __osize); + + int __r = traits_type::compare(_M_data(), __str.data(), __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + +#if __cplusplus >= 201703L + /** + * @brief Compare to a string_view. + * @param __svt An object convertible to string_view to compare against. + * @return Integer < 0, 0, or > 0. + */ + template + _If_sv<_Tp, int> + compare(const _Tp& __svt) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + const size_type __size = this->size(); + const size_type __osize = __sv.size(); + const size_type __len = std::min(__size, __osize); + + int __r = traits_type::compare(_M_data(), __sv.data(), __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + + /** + * @brief Compare to a string_view. + * @param __pos A position in the string to start comparing from. + * @param __n The number of characters to compare. + * @param __svt An object convertible to string_view to compare + * against. + * @return Integer < 0, 0, or > 0. + */ + template + _If_sv<_Tp, int> + compare(size_type __pos, size_type __n, const _Tp& __svt) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return __sv_type(*this).substr(__pos, __n).compare(__sv); + } + + /** + * @brief Compare to a string_view. + * @param __pos1 A position in the string to start comparing from. + * @param __n1 The number of characters to compare. + * @param __svt An object convertible to string_view to compare + * against. + * @param __pos2 A position in the string_view to start comparing from. + * @param __n2 The number of characters to compare. + * @return Integer < 0, 0, or > 0. + */ + template + _If_sv<_Tp, int> + compare(size_type __pos1, size_type __n1, const _Tp& __svt, + size_type __pos2, size_type __n2 = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return __sv_type(*this) + .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); + } +#endif // C++17 + + /** + * @brief Compare substring to a string. + * @param __pos Index of first character of substring. + * @param __n Number of characters in substring. + * @param __str String to compare against. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n characters + * starting at @a __pos. Returns an integer < 0 if the + * substring is ordered before @a __str, 0 if their values are + * equivalent, or > 0 if the substring is ordered after @a + * __str. Determines the effective length rlen of the strings + * to compare as the smallest of the length of the substring + * and @a __str.size(). The function then compares the two + * strings by calling + * traits::compare(substring.data(),str.data(),rlen). If the + * result of the comparison is nonzero returns it, otherwise + * the shorter one is ordered first. + */ + int + compare(size_type __pos, size_type __n, const basic_string& __str) const; + + /** + * @brief Compare substring to a substring. + * @param __pos1 Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __str String to compare against. + * @param __pos2 Index of first character of substring of str. + * @param __n2 Number of characters in substring of str. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a __pos1. Form the substring of @a + * __str from the @a __n2 characters starting at @a __pos2. + * Returns an integer < 0 if this substring is ordered before + * the substring of @a __str, 0 if their values are equivalent, + * or > 0 if this substring is ordered after the substring of + * @a __str. Determines the effective length rlen of the + * strings to compare as the smallest of the lengths of the + * substrings. The function then compares the two strings by + * calling + * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). + * If the result of the comparison is nonzero returns it, + * otherwise the shorter one is ordered first. + */ + int + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2 = npos) const; + + /** + * @brief Compare to a C string. + * @param __s C string to compare against. + * @return Integer < 0, 0, or > 0. + * + * Returns an integer < 0 if this string is ordered before @a __s, 0 if + * their values are equivalent, or > 0 if this string is ordered after + * @a __s. Determines the effective length rlen of the strings to + * compare as the smallest of size() and the length of a string + * constructed from @a __s. The function then compares the two strings + * by calling traits::compare(data(),s,rlen). If the result of the + * comparison is nonzero returns it, otherwise the shorter one is + * ordered first. + */ + int + compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 5 String::compare specification questionable + /** + * @brief Compare substring to a C string. + * @param __pos Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __s C string to compare against. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a pos. Returns an integer < 0 if + * the substring is ordered before @a __s, 0 if their values + * are equivalent, or > 0 if the substring is ordered after @a + * __s. Determines the effective length rlen of the strings to + * compare as the smallest of the length of the substring and + * the length of a string constructed from @a __s. The + * function then compares the two string by calling + * traits::compare(substring.data(),__s,rlen). If the result of + * the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. + */ + int + compare(size_type __pos, size_type __n1, const _CharT* __s) const; + + /** + * @brief Compare substring against a character %array. + * @param __pos Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __s character %array to compare against. + * @param __n2 Number of characters of s. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a __pos. Form a string from the + * first @a __n2 characters of @a __s. Returns an integer < 0 + * if this substring is ordered before the string from @a __s, + * 0 if their values are equivalent, or > 0 if this substring + * is ordered after the string from @a __s. Determines the + * effective length rlen of the strings to compare as the + * smallest of the length of the substring and @a __n2. The + * function then compares the two strings by calling + * traits::compare(substring.data(),s,rlen). If the result of + * the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. + * + * NB: s must have at least n2 characters, '\\0' has + * no special meaning. + */ + int + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const; + +#if __cplusplus > 201703L + bool + starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } +#endif // C++20 + +#if __cplusplus > 202002L + bool + contains(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } + + bool + contains(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } + + bool + contains(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } +#endif // C++23 + + // Allow basic_stringbuf::__xfer_bufptrs to call _M_length: + template friend class basic_stringbuf; + }; +_GLIBCXX_END_NAMESPACE_CXX11 +#else // !_GLIBCXX_USE_CXX11_ABI + // Reference-counted COW string implentation + + /** + * @class basic_string basic_string.h + * @brief Managing sequences of characters and character-like objects. + * + * @ingroup strings + * @ingroup sequences + * + * @tparam _CharT Type of character + * @tparam _Traits Traits for character type, defaults to + * char_traits<_CharT>. + * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence. Of the + * optional sequence requirements, only + * @c push_back, @c at, and @c %array access are supported. + * + * @doctodo + * + * + * Documentation? What's that? + * Nathan Myers . + * + * A string looks like this: + * + * @code + * [_Rep] + * _M_length + * [basic_string] _M_capacity + * _M_dataplus _M_refcount + * _M_p ----------------> unnamed array of char_type + * @endcode + * + * Where the _M_p points to the first character in the string, and + * you cast it to a pointer-to-_Rep and subtract 1 to get a + * pointer to the header. + * + * This approach has the enormous advantage that a string object + * requires only one allocation. All the ugliness is confined + * within a single %pair of inline functions, which each compile to + * a single @a add instruction: _Rep::_M_data(), and + * string::_M_rep(); and the allocation function which gets a + * block of raw bytes and with room enough and constructs a _Rep + * object at the front. + * + * The reason you want _M_data pointing to the character %array and + * not the _Rep is so that the debugger can see the string + * contents. (Probably we should add a non-inline member to get + * the _Rep for the debugger to use, so users can check the actual + * string length.) + * + * Note that the _Rep object is a POD so that you can have a + * static empty string _Rep object already @a constructed before + * static constructors have run. The reference-count encoding is + * chosen so that a 0 indicates one reference, so you never try to + * destroy the empty-string _Rep object. + * + * All but the last paragraph is considered pretty conventional + * for a C++ string implementation. + */ + // 21.3 Template class basic_string + template + class basic_string + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _CharT_alloc_type; + typedef __gnu_cxx::__alloc_traits<_CharT_alloc_type> _CharT_alloc_traits; + + // Types: + public: + typedef _Traits traits_type; + typedef typename _Traits::char_type value_type; + typedef _Alloc allocator_type; + typedef typename _CharT_alloc_traits::size_type size_type; + typedef typename _CharT_alloc_traits::difference_type difference_type; +#if __cplusplus < 201103L + typedef typename _CharT_alloc_type::reference reference; + typedef typename _CharT_alloc_type::const_reference const_reference; +#else + typedef value_type& reference; + typedef const value_type& const_reference; +#endif + typedef typename _CharT_alloc_traits::pointer pointer; + typedef typename _CharT_alloc_traits::const_pointer const_pointer; + typedef __gnu_cxx::__normal_iterator iterator; + typedef __gnu_cxx::__normal_iterator + const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + + protected: + // type used for positions in insert, erase etc. + typedef iterator __const_iterator; + + private: + // _Rep: string representation + // Invariants: + // 1. String really contains _M_length + 1 characters: due to 21.3.4 + // must be kept null-terminated. + // 2. _M_capacity >= _M_length + // Allocated memory is always (_M_capacity + 1) * sizeof(_CharT). + // 3. _M_refcount has three states: + // -1: leaked, one reference, no ref-copies allowed, non-const. + // 0: one reference, non-const. + // n>0: n + 1 references, operations require a lock, const. + // 4. All fields==0 is an empty string, given the extra storage + // beyond-the-end for a null terminator; thus, the shared + // empty string representation needs no constructor. + + struct _Rep_base + { + size_type _M_length; + size_type _M_capacity; + _Atomic_word _M_refcount; + }; + + struct _Rep : _Rep_base + { + // Types: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other _Raw_bytes_alloc; + + // (Public) Data members: + + // The maximum number of individual char_type elements of an + // individual string is determined by _S_max_size. This is the + // value that will be returned by max_size(). (Whereas npos + // is the maximum number of bytes the allocator can allocate.) + // If one was to divvy up the theoretical largest size string, + // with a terminating character and m _CharT elements, it'd + // look like this: + // npos = sizeof(_Rep) + (m * sizeof(_CharT)) + sizeof(_CharT) + // Solving for m: + // m = ((npos - sizeof(_Rep))/sizeof(CharT)) - 1 + // In addition, this implementation quarters this amount. + static const size_type _S_max_size; + static const _CharT _S_terminal; + + // The following storage is init'd to 0 by the linker, resulting + // (carefully) in an empty string with one reference. + static size_type _S_empty_rep_storage[]; + + static _Rep& + _S_empty_rep() _GLIBCXX_NOEXCEPT + { + // NB: Mild hack to avoid strict-aliasing warnings. Note that + // _S_empty_rep_storage is never modified and the punning should + // be reasonably safe in this case. + void* __p = reinterpret_cast(&_S_empty_rep_storage); + return *reinterpret_cast<_Rep*>(__p); + } + + bool + _M_is_leaked() const _GLIBCXX_NOEXCEPT + { +#if defined(__GTHREADS) + // _M_refcount is mutated concurrently by _M_refcopy/_M_dispose, + // so we need to use an atomic load. However, _M_is_leaked + // predicate does not change concurrently (i.e. the string is either + // leaked or not), so a relaxed load is enough. + return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0; +#else + return this->_M_refcount < 0; +#endif + } + + bool + _M_is_shared() const _GLIBCXX_NOEXCEPT + { +#if defined(__GTHREADS) + // _M_refcount is mutated concurrently by _M_refcopy/_M_dispose, + // so we need to use an atomic load. Another thread can drop last + // but one reference concurrently with this check, so we need this + // load to be acquire to synchronize with release fetch_and_add in + // _M_dispose. + return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0; +#else + return this->_M_refcount > 0; +#endif + } + + void + _M_set_leaked() _GLIBCXX_NOEXCEPT + { this->_M_refcount = -1; } + + void + _M_set_sharable() _GLIBCXX_NOEXCEPT + { this->_M_refcount = 0; } + + void + _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif + { + this->_M_set_sharable(); // One reference. + this->_M_length = __n; + traits_type::assign(this->_M_refdata()[__n], _S_terminal); + // grrr. (per 21.3.4) + // You cannot leave those LWG people alone for a second. + } + } + + _CharT* + _M_refdata() throw() + { return reinterpret_cast<_CharT*>(this + 1); } + + _CharT* + _M_grab(const _Alloc& __alloc1, const _Alloc& __alloc2) + { + return (!_M_is_leaked() && __alloc1 == __alloc2) + ? _M_refcopy() : _M_clone(__alloc1); + } + + // Create & Destroy + static _Rep* + _S_create(size_type, size_type, const _Alloc&); + + void + _M_dispose(const _Alloc& __a) _GLIBCXX_NOEXCEPT + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); + // Decrement of _M_refcount is acq_rel, because: + // - all but last decrements need to release to synchronize with + // the last decrement that will delete the object. + // - the last decrement needs to acquire to synchronize with + // all the previous decrements. + // - last but one decrement needs to release to synchronize with + // the acquire load in _M_is_shared that will conclude that + // the object is not shared anymore. + if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, + -1) <= 0) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); + _M_destroy(__a); + } + } + } // XXX MT + + void + _M_destroy(const _Alloc&) throw(); + + _CharT* + _M_refcopy() throw() + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__builtin_expect(this != &_S_empty_rep(), false)) +#endif + __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1); + return _M_refdata(); + } // XXX MT + + _CharT* + _M_clone(const _Alloc&, size_type __res = 0); + }; + + // Use empty-base optimization: http://www.cantrip.org/emptyopt.html + struct _Alloc_hider : _Alloc + { + _Alloc_hider(_CharT* __dat, const _Alloc& __a) _GLIBCXX_NOEXCEPT + : _Alloc(__a), _M_p(__dat) { } + + _CharT* _M_p; // The actual data. + }; + + public: + // Data Members (public): + // NB: This is an unsigned type, and thus represents the maximum + // size that the allocator can hold. + /// Value returned by various member functions when they fail. + static const size_type npos = static_cast(-1); + + private: + // Data Members (private): + mutable _Alloc_hider _M_dataplus; + + _CharT* + _M_data() const _GLIBCXX_NOEXCEPT + { return _M_dataplus._M_p; } + + _CharT* + _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT + { return (_M_dataplus._M_p = __p); } + + _Rep* + _M_rep() const _GLIBCXX_NOEXCEPT + { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); } + + // For the internal use we have functions similar to `begin'/`end' + // but they do not call _M_leak. + iterator + _M_ibegin() const _GLIBCXX_NOEXCEPT + { return iterator(_M_data()); } + + iterator + _M_iend() const _GLIBCXX_NOEXCEPT + { return iterator(_M_data() + this->size()); } + + void + _M_leak() // for use in begin() & non-const op[] + { + if (!_M_rep()->_M_is_leaked()) + _M_leak_hard(); + } + + size_type + _M_check(size_type __pos, const char* __s) const + { + if (__pos > this->size()) + __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > " + "this->size() (which is %zu)"), + __s, __pos, this->size()); + return __pos; + } + + void + _M_check_length(size_type __n1, size_type __n2, const char* __s) const + { + if (this->max_size() - (this->size() - __n1) < __n2) + __throw_length_error(__N(__s)); + } + + // NB: _M_limit doesn't check for a bad __pos value. + size_type + _M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT + { + const bool __testoff = __off < this->size() - __pos; + return __testoff ? __off : this->size() - __pos; + } + + // True if _Rep and source do not overlap. + bool + _M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT + { + return (less()(__s, _M_data()) + || less()(_M_data() + this->size(), __s)); + } + + // When __n = 1 way faster than the general multichar + // traits_type::copy/move/assign. + static void + _M_copy(_CharT* __d, const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::copy(__d, __s, __n); + } + + static void + _M_move(_CharT* __d, const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT + { + if (__n == 1) + traits_type::assign(*__d, *__s); + else + traits_type::move(__d, __s, __n); + } + + static void + _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT + { + if (__n == 1) + traits_type::assign(*__d, __c); + else + traits_type::assign(__d, __n, __c); + } + + // _S_copy_chars is a separate template to permit specialization + // to optimize for the common case of pointers as iterators. + template + static void + _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) + { + for (; __k1 != __k2; ++__k1, (void)++__p) + traits_type::assign(*__p, *__k1); // These types are off. + } + + static void + _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2) + _GLIBCXX_NOEXCEPT + { _S_copy_chars(__p, __k1.base(), __k2.base()); } + + static void + _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT + { _M_copy(__p, __k1, __k2 - __k1); } + + static void + _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2) + _GLIBCXX_NOEXCEPT + { _M_copy(__p, __k1, __k2 - __k1); } + + static int + _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT + { + const difference_type __d = difference_type(__n1 - __n2); + + if (__d > __gnu_cxx::__numeric_traits::__max) + return __gnu_cxx::__numeric_traits::__max; + else if (__d < __gnu_cxx::__numeric_traits::__min) + return __gnu_cxx::__numeric_traits::__min; + else + return int(__d); + } + + void + _M_mutate(size_type __pos, size_type __len1, size_type __len2); + + void + _M_leak_hard(); + + static _Rep& + _S_empty_rep() _GLIBCXX_NOEXCEPT + { return _Rep::_S_empty_rep(); } + +#if __cplusplus >= 201703L + // A helper type for avoiding boiler-plate. + typedef basic_string_view<_CharT, _Traits> __sv_type; + + template + using _If_sv = enable_if_t< + __and_, + __not_>, + __not_>>::value, + _Res>; + + // Allows an implicit conversion to __sv_type. + static __sv_type + _S_to_string_view(__sv_type __svt) noexcept + { return __svt; } + + // Wraps a string_view by explicit conversion and thus + // allows to add an internal constructor that does not + // participate in overload resolution when a string_view + // is provided. + struct __sv_wrapper + { + explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { } + __sv_type _M_sv; + }; + + /** + * @brief Only internally used: Construct string from a string view + * wrapper. + * @param __svw string view wrapper. + * @param __a Allocator to use. + */ + explicit + basic_string(__sv_wrapper __svw, const _Alloc& __a) + : basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { } +#endif + + public: + // Construct/copy/destroy: + // NB: We overload ctors in some cases instead of using default + // arguments, per 17.4.4.4 para. 2 item 2. + + /** + * @brief Default constructor creates an empty string. + */ + basic_string() +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + _GLIBCXX_NOEXCEPT + : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) +#else + : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) +#endif + { } + + /** + * @brief Construct an empty string using allocator @a a. + */ + explicit + basic_string(const _Alloc& __a) + : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a) + { } + + // NB: per LWG issue 42, semantics different from IS: + /** + * @brief Construct string with copy of value of @a str. + * @param __str Source string. + */ + basic_string(const basic_string& __str) + : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()), + __str.get_allocator()), + __str.get_allocator()) + { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2583. no way to supply an allocator for basic_string(str, pos) + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __a Allocator to use. + */ + basic_string(const basic_string& __str, size_type __pos, + const _Alloc& __a = _Alloc()); + + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __n Number of characters to copy. + */ + basic_string(const basic_string& __str, size_type __pos, + size_type __n); + /** + * @brief Construct string as copy of a substring. + * @param __str Source string. + * @param __pos Index of first character to copy from. + * @param __n Number of characters to copy. + * @param __a Allocator to use. + */ + basic_string(const basic_string& __str, size_type __pos, + size_type __n, const _Alloc& __a); + + /** + * @brief Construct string initialized by a character %array. + * @param __s Source character %array. + * @param __n Number of characters to copy. + * @param __a Allocator to use (default is default allocator). + * + * NB: @a __s must have at least @a __n characters, '\\0' + * has no special meaning. + */ + basic_string(const _CharT* __s, size_type __n, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__s, __s + __n, __a), __a) + { } + + /** + * @brief Construct string as copy of a C string. + * @param __s Source C string. + * @param __a Allocator to use (default is default allocator). + */ +#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3076. basic_string CTAD ambiguity + template> +#endif + basic_string(const _CharT* __s, const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) : + __s + npos, __a), __a) + { } + + /** + * @brief Construct string as multiple characters. + * @param __n Number of characters. + * @param __c Character to use. + * @param __a Allocator to use (default is default allocator). + */ + basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__n, __c, __a), __a) + { } + +#if __cplusplus >= 201103L + /** + * @brief Move construct string. + * @param __str Source string. + * + * The newly-created string contains the exact contents of @a __str. + * @a __str is a valid, but unspecified string. + */ + basic_string(basic_string&& __str) +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + noexcept // FIXME C++11: should always be noexcept. +#endif + : _M_dataplus(std::move(__str._M_dataplus)) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + __str._M_data(_S_empty_rep()._M_refdata()); +#else + __str._M_data(_S_construct(size_type(), _CharT(), get_allocator())); +#endif + } + + /** + * @brief Construct string from an initializer %list. + * @param __l std::initializer_list of characters. + * @param __a Allocator to use (default is default allocator). + */ + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a) + { } + + basic_string(const basic_string& __str, const _Alloc& __a) + : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.get_allocator()), __a) + { } + + basic_string(basic_string&& __str, const _Alloc& __a) + : _M_dataplus(__str._M_data(), __a) + { + if (__a == __str.get_allocator()) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + __str._M_data(_S_empty_rep()._M_refdata()); +#else + __str._M_data(_S_construct(size_type(), _CharT(), __a)); +#endif + } + else + _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a); + } +#endif // C++11 + + /** + * @brief Construct string as copy of a range. + * @param __beg Start of range. + * @param __end End of range. + * @param __a Allocator to use (default is default allocator). + */ + template + basic_string(_InputIterator __beg, _InputIterator __end, + const _Alloc& __a = _Alloc()) + : _M_dataplus(_S_construct(__beg, __end, __a), __a) + { } + +#if __cplusplus >= 201703L + /** + * @brief Construct string from a substring of a string_view. + * @param __t Source object convertible to string view. + * @param __pos The index of the first character to copy from __t. + * @param __n The number of characters to copy from __t. + * @param __a Allocator to use. + */ + template> + basic_string(const _Tp& __t, size_type __pos, size_type __n, + const _Alloc& __a = _Alloc()) + : basic_string(_S_to_string_view(__t).substr(__pos, __n), __a) { } + + /** + * @brief Construct string from a string_view. + * @param __t Source object convertible to string view. + * @param __a Allocator to use (default is default allocator). + */ + template> + explicit + basic_string(const _Tp& __t, const _Alloc& __a = _Alloc()) + : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { } +#endif // C++17 + + /** + * @brief Destroy the string instance. + */ + ~basic_string() _GLIBCXX_NOEXCEPT + { _M_rep()->_M_dispose(this->get_allocator()); } + + /** + * @brief Assign the value of @a str to this string. + * @param __str Source string. + */ + basic_string& + operator=(const basic_string& __str) + { return this->assign(__str); } + + /** + * @brief Copy contents of @a s into this string. + * @param __s Source null-terminated string. + */ + basic_string& + operator=(const _CharT* __s) + { return this->assign(__s); } + + /** + * @brief Set value to string of length 1. + * @param __c Source character. + * + * Assigning to a character makes this string length 1 and + * (*this)[0] == @a c. + */ + basic_string& + operator=(_CharT __c) + { + this->assign(1, __c); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Move assign the value of @a str to this string. + * @param __str Source string. + * + * The contents of @a str are moved into this string (without copying). + * @a str is a valid, but unspecified string. + */ + basic_string& + operator=(basic_string&& __str) + _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value) + { + // NB: DR 1204. + this->swap(__str); + return *this; + } + + /** + * @brief Set value to string constructed from initializer %list. + * @param __l std::initializer_list. + */ + basic_string& + operator=(initializer_list<_CharT> __l) + { + this->assign(__l.begin(), __l.size()); + return *this; + } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Set value to string constructed from a string_view. + * @param __svt An object convertible to string_view. + */ + template + _If_sv<_Tp, basic_string&> + operator=(const _Tp& __svt) + { return this->assign(__svt); } + + /** + * @brief Convert to a string_view. + * @return A string_view. + */ + operator __sv_type() const noexcept + { return __sv_type(data(), size()); } +#endif // C++17 + + // Iterators: + /** + * Returns a read/write iterator that points to the first character in + * the %string. Unshares the string. + */ + iterator + begin() // FIXME C++11: should be noexcept. + { + _M_leak(); + return iterator(_M_data()); + } + + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_M_data()); } + + /** + * Returns a read/write iterator that points one past the last + * character in the %string. Unshares the string. + */ + iterator + end() // FIXME C++11: should be noexcept. + { + _M_leak(); + return iterator(_M_data() + this->size()); + } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_M_data() + this->size()); } + + /** + * Returns a read/write reverse iterator that points to the last + * character in the %string. Iteration is done in reverse element + * order. Unshares the string. + */ + reverse_iterator + rbegin() // FIXME C++11: should be noexcept. + { return reverse_iterator(this->end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last character in the %string. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->end()); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first character in the %string. Iteration is done in reverse + * element order. Unshares the string. + */ + reverse_iterator + rend() // FIXME C++11: should be noexcept. + { return reverse_iterator(this->begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first character in the %string. Iteration + * is done in reverse element order. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * character in the %string. + */ + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_data()); } + + /** + * Returns a read-only (constant) iterator that points one past the + * last character in the %string. + */ + const_iterator + cend() const noexcept + { return const_iterator(this->_M_data() + this->size()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last character in the %string. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(this->end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first character in the %string. Iteration + * is done in reverse element order. + */ + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(this->begin()); } +#endif + + public: + // Capacity: + /// Returns the number of characters in the string, not including any + /// null-termination. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_rep()->_M_length; } + + /// Returns the number of characters in the string, not including any + /// null-termination. + size_type + length() const _GLIBCXX_NOEXCEPT + { return _M_rep()->_M_length; } + + /// Returns the size() of the largest possible %string. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _Rep::_S_max_size; } + + /** + * @brief Resizes the %string to the specified number of characters. + * @param __n Number of characters the %string should contain. + * @param __c Character to fill any new elements. + * + * This function will %resize the %string to the specified + * number of characters. If the number is smaller than the + * %string's current size the %string is truncated, otherwise + * the %string is extended and new elements are %set to @a __c. + */ + void + resize(size_type __n, _CharT __c); + + /** + * @brief Resizes the %string to the specified number of characters. + * @param __n Number of characters the %string should contain. + * + * This function will resize the %string to the specified length. If + * the new size is smaller than the %string's current size the %string + * is truncated, otherwise the %string is extended and new characters + * are default-constructed. For basic types such as char, this means + * setting them to 0. + */ + void + resize(size_type __n) + { this->resize(__n, _CharT()); } + +#if __cplusplus >= 201103L +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /// A non-binding request to reduce capacity() to size(). + void + shrink_to_fit() noexcept + { reserve(); } +#pragma GCC diagnostic pop +#endif + + /** + * Returns the total number of characters that the %string can hold + * before needing to allocate more memory. + */ + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return _M_rep()->_M_capacity; } + + /** + * @brief Attempt to preallocate enough memory for specified number of + * characters. + * @param __res_arg Number of characters required. + * @throw std::length_error If @a __res_arg exceeds @c max_size(). + * + * This function attempts to reserve enough memory for the + * %string to hold the specified number of characters. If the + * number requested is more than max_size(), length_error is + * thrown. + * + * The advantage of this function is that if optimal code is a + * necessity and the user can determine the string length that will be + * required, the user can reserve the memory in %advance, and thus + * prevent a possible reallocation of memory and copying of %string + * data. + */ + void + reserve(size_type __res_arg); + + /// Equivalent to shrink_to_fit(). +#if __cplusplus > 201703L + [[deprecated("use shrink_to_fit() instead")]] +#endif + void + reserve(); + + /** + * Erases the string, making it empty. + */ +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + void + clear() _GLIBCXX_NOEXCEPT + { + if (_M_rep()->_M_is_shared()) + { + _M_rep()->_M_dispose(this->get_allocator()); + _M_data(_S_empty_rep()._M_refdata()); + } + else + _M_rep()->_M_set_length_and_sharable(0); + } +#else + // PR 56166: this should not throw. + void + clear() + { _M_mutate(0, this->size(), 0); } +#endif + + /** + * Returns true if the %string is empty. Equivalent to + * *this == "". + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return this->size() == 0; } + + // Element access: + /** + * @brief Subscript access to the data contained in the %string. + * @param __pos The index of the character to access. + * @return Read-only (constant) reference to the character. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + const_reference + operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT + { + __glibcxx_assert(__pos <= size()); + return _M_data()[__pos]; + } + + /** + * @brief Subscript access to the data contained in the %string. + * @param __pos The index of the character to access. + * @return Read/write reference to the character. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) Unshares the string. + */ + reference + operator[](size_type __pos) + { + // Allow pos == size() both in C++98 mode, as v3 extension, + // and in C++11 mode. + __glibcxx_assert(__pos <= size()); + // In pedantic mode be strict in C++98 mode. + _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos < size()); + _M_leak(); + return _M_data()[__pos]; + } + + /** + * @brief Provides access to the data contained in the %string. + * @param __n The index of the character to access. + * @return Read-only (const) reference to the character. + * @throw std::out_of_range If @a n is an invalid index. + * + * This function provides for safer data access. The parameter is + * first checked that it is in the range of the string. The function + * throws out_of_range if the check fails. + */ + const_reference + at(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("basic_string::at: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + return _M_data()[__n]; + } + + /** + * @brief Provides access to the data contained in the %string. + * @param __n The index of the character to access. + * @return Read/write reference to the character. + * @throw std::out_of_range If @a n is an invalid index. + * + * This function provides for safer data access. The parameter is + * first checked that it is in the range of the string. The function + * throws out_of_range if the check fails. Success results in + * unsharing the string. + */ + reference + at(size_type __n) + { + if (__n >= size()) + __throw_out_of_range_fmt(__N("basic_string::at: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + _M_leak(); + return _M_data()[__n]; + } + +#if __cplusplus >= 201103L + /** + * Returns a read/write reference to the data at the first + * element of the %string. + */ + reference + front() + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %string. + */ + const_reference + front() const noexcept + { + __glibcxx_assert(!empty()); + return operator[](0); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %string. + */ + reference + back() + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } + + /** + * Returns a read-only (constant) reference to the data at the + * last element of the %string. + */ + const_reference + back() const noexcept + { + __glibcxx_assert(!empty()); + return operator[](this->size() - 1); + } +#endif + + // Modifiers: + /** + * @brief Append a string to this string. + * @param __str The string to append. + * @return Reference to this string. + */ + basic_string& + operator+=(const basic_string& __str) + { return this->append(__str); } + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + basic_string& + operator+=(const _CharT* __s) + { return this->append(__s); } + + /** + * @brief Append a character. + * @param __c The character to append. + * @return Reference to this string. + */ + basic_string& + operator+=(_CharT __c) + { + this->push_back(__c); + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Append an initializer_list of characters. + * @param __l The initializer_list of characters to be appended. + * @return Reference to this string. + */ + basic_string& + operator+=(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt The object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + operator+=(const _Tp& __svt) + { return this->append(__svt); } +#endif // C++17 + + /** + * @brief Append a string to this string. + * @param __str The string to append. + * @return Reference to this string. + */ + basic_string& + append(const basic_string& __str); + + /** + * @brief Append a substring. + * @param __str The string to append. + * @param __pos Index of the first character of str to append. + * @param __n The number of characters to append. + * @return Reference to this string. + * @throw std::out_of_range if @a __pos is not a valid index. + * + * This function appends @a __n characters from @a __str + * starting at @a __pos to this string. If @a __n is is larger + * than the number of available characters in @a __str, the + * remainder of @a __str is appended. + */ + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n = npos); + + /** + * @brief Append a C substring. + * @param __s The C string to append. + * @param __n The number of characters to append. + * @return Reference to this string. + */ + basic_string& + append(const _CharT* __s, size_type __n); + + /** + * @brief Append a C string. + * @param __s The C string to append. + * @return Reference to this string. + */ + basic_string& + append(const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->append(__s, traits_type::length(__s)); + } + + /** + * @brief Append multiple characters. + * @param __n The number of characters to append. + * @param __c The character to use. + * @return Reference to this string. + * + * Appends __n copies of __c to this string. + */ + basic_string& + append(size_type __n, _CharT __c); + +#if __cplusplus >= 201103L + /** + * @brief Append an initializer_list of characters. + * @param __l The initializer_list of characters to append. + * @return Reference to this string. + */ + basic_string& + append(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.size()); } +#endif // C++11 + + /** + * @brief Append a range of characters. + * @param __first Iterator referencing the first character to append. + * @param __last Iterator marking the end of the range. + * @return Reference to this string. + * + * Appends characters in the range [__first,__last) to this string. + */ + template + basic_string& + append(_InputIterator __first, _InputIterator __last) + { return this->replace(_M_iend(), _M_iend(), __first, __last); } + +#if __cplusplus >= 201703L + /** + * @brief Append a string_view. + * @param __svt The object convertible to string_view to be appended. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->append(__sv.data(), __sv.size()); + } + + /** + * @brief Append a range of characters from a string_view. + * @param __svt The object convertible to string_view to be appended + * from. + * @param __pos The position in the string_view to append from. + * @param __n The number of characters to append from the string_view. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + append(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return append(__sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::append"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + + /** + * @brief Append a single character. + * @param __c Character to append. + */ + void + push_back(_CharT __c) + { + const size_type __len = 1 + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + traits_type::assign(_M_data()[this->size()], __c); + _M_rep()->_M_set_length_and_sharable(__len); + } + + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + */ + basic_string& + assign(const basic_string& __str); + +#if __cplusplus >= 201103L + /** + * @brief Set value to contents of another string. + * @param __str Source string to use. + * @return Reference to this string. + * + * This function sets this string to the exact contents of @a __str. + * @a __str is a valid, but unspecified string. + */ + basic_string& + assign(basic_string&& __str) + noexcept(allocator_traits<_Alloc>::is_always_equal::value) + { + this->swap(__str); + return *this; + } +#endif // C++11 + + /** + * @brief Set value to a substring of a string. + * @param __str The string to use. + * @param __pos Index of the first character of str. + * @param __n Number of characters to use. + * @return Reference to this string. + * @throw std::out_of_range if @a pos is not a valid index. + * + * This function sets this string to the substring of @a __str + * consisting of @a __n characters at @a __pos. If @a __n is + * is larger than the number of available characters in @a + * __str, the remainder of @a __str is used. + */ + basic_string& + assign(const basic_string& __str, size_type __pos, size_type __n = npos) + { return this->assign(__str._M_data() + + __str._M_check(__pos, "basic_string::assign"), + __str._M_limit(__pos, __n)); } + + /** + * @brief Set value to a C substring. + * @param __s The C string to use. + * @param __n Number of characters to use. + * @return Reference to this string. + * + * This function sets the value of this string to the first @a __n + * characters of @a __s. If @a __n is is larger than the number of + * available characters in @a __s, the remainder of @a __s is used. + */ + basic_string& + assign(const _CharT* __s, size_type __n); + + /** + * @brief Set value to contents of a C string. + * @param __s The C string to use. + * @return Reference to this string. + * + * This function sets the value of this string to the value of @a __s. + * The data is copied, so there is no dependence on @a __s once the + * function returns. + */ + basic_string& + assign(const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->assign(__s, traits_type::length(__s)); + } + + /** + * @brief Set value to multiple characters. + * @param __n Length of the resulting string. + * @param __c The character to use. + * @return Reference to this string. + * + * This function sets the value of this string to @a __n copies of + * character @a __c. + */ + basic_string& + assign(size_type __n, _CharT __c) + { return _M_replace_aux(size_type(0), this->size(), __n, __c); } + + /** + * @brief Set value to a range of characters. + * @param __first Iterator referencing the first character to append. + * @param __last Iterator marking the end of the range. + * @return Reference to this string. + * + * Sets value of string to characters in the range [__first,__last). + */ + template + basic_string& + assign(_InputIterator __first, _InputIterator __last) + { return this->replace(_M_ibegin(), _M_iend(), __first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Set value to an initializer_list of characters. + * @param __l The initializer_list of characters to assign. + * @return Reference to this string. + */ + basic_string& + assign(initializer_list<_CharT> __l) + { return this->assign(__l.begin(), __l.size()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Set value from a string_view. + * @param __svt The source object convertible to string_view. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->assign(__sv.data(), __sv.size()); + } + + /** + * @brief Set value from a range of characters in a string_view. + * @param __svt The source object convertible to string_view. + * @param __pos The position in the string_view to assign from. + * @param __n The number of characters to assign. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + assign(const _Tp& __svt, size_type __pos, size_type __n = npos) + { + __sv_type __sv = __svt; + return assign(__sv.data() + + std::__sv_check(__sv.size(), __pos, "basic_string::assign"), + std::__sv_limit(__sv.size(), __pos, __n)); + } +#endif // C++17 + + /** + * @brief Insert multiple characters. + * @param __p Iterator referencing location in string to insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts @a __n copies of character @a __c starting at the + * position referenced by iterator @a __p. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + void + insert(iterator __p, size_type __n, _CharT __c) + { this->replace(__p, __p, __n, __c); } + + /** + * @brief Insert a range of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __beg Start of range. + * @param __end End of range. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts characters in range [__beg,__end). If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + template + void + insert(iterator __p, _InputIterator __beg, _InputIterator __end) + { this->replace(__p, __p, __beg, __end); } + +#if __cplusplus >= 201103L + /** + * @brief Insert an initializer_list of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __l The initializer_list of characters to insert. + * @throw std::length_error If new length exceeds @c max_size(). + */ + void + insert(iterator __p, initializer_list<_CharT> __l) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + this->insert(__p - _M_ibegin(), __l.begin(), __l.size()); + } +#endif // C++11 + + /** + * @brief Insert value of a string. + * @param __pos1 Position in string to insert at. + * @param __str The string to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts value of @a __str starting at @a __pos1. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + insert(size_type __pos1, const basic_string& __str) + { return this->insert(__pos1, __str, size_type(0), __str.size()); } + + /** + * @brief Insert a substring. + * @param __pos1 Position in string to insert at. + * @param __str The string to insert. + * @param __pos2 Start of characters in str to insert. + * @param __n Number of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a pos1 > size() or + * @a __pos2 > @a str.size(). + * + * Starting at @a pos1, insert @a __n character of @a __str + * beginning with @a __pos2. If adding characters causes the + * length to exceed max_size(), length_error is thrown. If @a + * __pos1 is beyond the end of this string or @a __pos2 is + * beyond the end of @a __str, out_of_range is thrown. The + * value of the string doesn't change if an error is thrown. + */ + basic_string& + insert(size_type __pos1, const basic_string& __str, + size_type __pos2, size_type __n = npos) + { return this->insert(__pos1, __str._M_data() + + __str._M_check(__pos2, "basic_string::insert"), + __str._M_limit(__pos2, __n)); } + + /** + * @brief Insert a C substring. + * @param __pos Position in string to insert at. + * @param __s The C string to insert. + * @param __n The number of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a __pos is beyond the end of this + * string. + * + * Inserts the first @a __n characters of @a __s starting at @a + * __pos. If adding characters causes the length to exceed + * max_size(), length_error is thrown. If @a __pos is beyond + * end(), out_of_range is thrown. The value of the string + * doesn't change if an error is thrown. + */ + basic_string& + insert(size_type __pos, const _CharT* __s, size_type __n); + + /** + * @brief Insert a C string. + * @param __pos Position in string to insert at. + * @param __s The C string to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * + * Inserts the first @a n characters of @a __s starting at @a __pos. If + * adding characters causes the length to exceed max_size(), + * length_error is thrown. If @a __pos is beyond end(), out_of_range is + * thrown. The value of the string doesn't change if an error is + * thrown. + */ + basic_string& + insert(size_type __pos, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->insert(__pos, __s, traits_type::length(__s)); + } + + /** + * @brief Insert multiple characters. + * @param __pos Index in string to insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * @throw std::out_of_range If @a __pos is beyond the end of this + * string. + * + * Inserts @a __n copies of character @a __c starting at index + * @a __pos. If adding characters causes the length to exceed + * max_size(), length_error is thrown. If @a __pos > length(), + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + insert(size_type __pos, size_type __n, _CharT __c) + { return _M_replace_aux(_M_check(__pos, "basic_string::insert"), + size_type(0), __n, __c); } + + /** + * @brief Insert one character. + * @param __p Iterator referencing position in string to insert at. + * @param __c The character to insert. + * @return Iterator referencing newly inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts character @a __c at position referenced by @a __p. + * If adding character causes the length to exceed max_size(), + * length_error is thrown. If @a __p is beyond end of string, + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + iterator + insert(iterator __p, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + const size_type __pos = __p - _M_ibegin(); + _M_replace_aux(__pos, size_type(0), size_type(1), __c); + _M_rep()->_M_set_leaked(); + return iterator(_M_data() + __pos); + } + +#if __cplusplus >= 201703L + /** + * @brief Insert a string_view. + * @param __pos Position in string to insert at. + * @param __svt The object convertible to string_view to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + insert(size_type __pos, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->insert(__pos, __sv.data(), __sv.size()); + } + + /** + * @brief Insert a string_view. + * @param __pos1 Position in string to insert at. + * @param __svt The object convertible to string_view to insert from. + * @param __pos2 Position in string_view to insert from. + * @param __n The number of characters to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + insert(size_type __pos1, const _Tp& __svt, + size_type __pos2, size_type __n = npos) + { + __sv_type __sv = __svt; + return this->replace(__pos1, size_type(0), __sv.data() + + std::__sv_check(__sv.size(), __pos2, "basic_string::insert"), + std::__sv_limit(__sv.size(), __pos2, __n)); + } +#endif // C++17 + + /** + * @brief Remove characters. + * @param __pos Index of first character to remove (default 0). + * @param __n Number of characters to remove (default remainder). + * @return Reference to this string. + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * + * Removes @a __n characters from this string starting at @a + * __pos. The length of the string is reduced by @a __n. If + * there are < @a __n characters to remove, the remainder of + * the string is truncated. If @a __p is beyond end of string, + * out_of_range is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + erase(size_type __pos = 0, size_type __n = npos) + { + _M_mutate(_M_check(__pos, "basic_string::erase"), + _M_limit(__pos, __n), size_type(0)); + return *this; + } + + /** + * @brief Remove one character. + * @param __position Iterator referencing the character to remove. + * @return iterator referencing same location after removal. + * + * Removes the character at @a __position from this string. The value + * of the string doesn't change if an error is thrown. + */ + iterator + erase(iterator __position) + { + _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin() + && __position < _M_iend()); + const size_type __pos = __position - _M_ibegin(); + _M_mutate(__pos, size_type(1), size_type(0)); + _M_rep()->_M_set_leaked(); + return iterator(_M_data() + __pos); + } + + /** + * @brief Remove a range of characters. + * @param __first Iterator referencing the first character to remove. + * @param __last Iterator referencing the end of the range. + * @return Iterator referencing location of first after removal. + * + * Removes the characters in the range [first,last) from this string. + * The value of the string doesn't change if an error is thrown. + */ + iterator + erase(iterator __first, iterator __last); + +#if __cplusplus >= 201103L + /** + * @brief Remove the last character. + * + * The string must be non-empty. + */ + void + pop_back() // FIXME C++11: should be noexcept. + { + __glibcxx_assert(!empty()); + erase(size() - 1, 1); + } +#endif // C++11 + + /** + * @brief Replace characters with value from another string. + * @param __pos Index of first character to replace. + * @param __n Number of characters to be replaced. + * @param __str String to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a pos is beyond the end of this + * string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos+__n) from + * this string. In place, the value of @a __str is inserted. + * If @a __pos is beyond end of string, out_of_range is thrown. + * If the length of the result exceeds max_size(), length_error + * is thrown. The value of the string doesn't change if an + * error is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n, const basic_string& __str) + { return this->replace(__pos, __n, __str._M_data(), __str.size()); } + + /** + * @brief Replace characters with value from another string. + * @param __pos1 Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __str String to insert. + * @param __pos2 Index of first character of str to use. + * @param __n2 Number of characters from str to use. + * @return Reference to this string. + * @throw std::out_of_range If @a __pos1 > size() or @a __pos2 > + * __str.size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos1,__pos1 + n) from this + * string. In place, the value of @a __str is inserted. If @a __pos is + * beyond end of string, out_of_range is thrown. If the length of the + * result exceeds max_size(), length_error is thrown. The value of the + * string doesn't change if an error is thrown. + */ + basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2 = npos) + { return this->replace(__pos1, __n1, __str._M_data() + + __str._M_check(__pos2, "basic_string::replace"), + __str._M_limit(__pos2, __n2)); } + + /** + * @brief Replace characters with value of a C substring. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __s C string to insert. + * @param __n2 Number of characters from @a s to use. + * @return Reference to this string. + * @throw std::out_of_range If @a pos1 > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos + __n1) + * from this string. In place, the first @a __n2 characters of + * @a __s are inserted, or all of @a __s if @a __n2 is too large. If + * @a __pos is beyond end of string, out_of_range is thrown. If + * the length of result exceeds max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2); + + /** + * @brief Replace characters with value of a C string. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __s C string to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a pos > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__pos,__pos + __n1) + * from this string. In place, the characters of @a __s are + * inserted. If @a __pos is beyond end of string, out_of_range + * is thrown. If the length of result exceeds max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__pos, __n1, __s, traits_type::length(__s)); + } + + /** + * @brief Replace characters with multiple characters. + * @param __pos Index of first character to replace. + * @param __n1 Number of characters to be replaced. + * @param __n2 Number of characters to insert. + * @param __c Character to insert. + * @return Reference to this string. + * @throw std::out_of_range If @a __pos > size(). + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [pos,pos + n1) from this + * string. In place, @a __n2 copies of @a __c are inserted. + * If @a __pos is beyond end of string, out_of_range is thrown. + * If the length of result exceeds max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ + basic_string& + replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) + { return _M_replace_aux(_M_check(__pos, "basic_string::replace"), + _M_limit(__pos, __n1), __n2, __c); } + + /** + * @brief Replace range of characters with string. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __str String value to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the value of @a __str is inserted. If the length of result + * exceeds max_size(), length_error is thrown. The value of + * the string doesn't change if an error is thrown. + */ + basic_string& + replace(iterator __i1, iterator __i2, const basic_string& __str) + { return this->replace(__i1, __i2, __str._M_data(), __str.size()); } + + /** + * @brief Replace range of characters with C substring. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __s C string value to insert. + * @param __n Number of characters from s to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the first @a __n characters of @a __s are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + basic_string& + replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n); + } + + /** + * @brief Replace range of characters with C string. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __s C string value to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * the characters of @a __s are inserted. If the length of + * result exceeds max_size(), length_error is thrown. The + * value of the string doesn't change if an error is thrown. + */ + basic_string& + replace(iterator __i1, iterator __i2, const _CharT* __s) + { + __glibcxx_requires_string(__s); + return this->replace(__i1, __i2, __s, traits_type::length(__s)); + } + + /** + * @brief Replace range of characters with multiple characters + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __n Number of characters to insert. + * @param __c Character to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * @a __n copies of @a __c are inserted. If the length of + * result exceeds max_size(), length_error is thrown. The + * value of the string doesn't change if an error is thrown. + */ + basic_string& + replace(iterator __i1, iterator __i2, size_type __n, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c); + } + + /** + * @brief Replace range of characters with range. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __k1 Iterator referencing start of range to insert. + * @param __k2 Iterator referencing end of range to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * characters in the range [__k1,__k2) are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + template + basic_string& + replace(iterator __i1, iterator __i2, + _InputIterator __k1, _InputIterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral()); + } + + // Specializations for the common case of pointer and iterator: + // useful to avoid the overhead of temporary buffering in _M_replace. + basic_string& + replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + basic_string& + replace(iterator __i1, iterator __i2, + const _CharT* __k1, const _CharT* __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1, __k2 - __k1); + } + + basic_string& + replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + + basic_string& + replace(iterator __i1, iterator __i2, + const_iterator __k1, const_iterator __k2) + { + _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 + && __i2 <= _M_iend()); + __glibcxx_requires_valid_range(__k1, __k2); + return this->replace(__i1 - _M_ibegin(), __i2 - __i1, + __k1.base(), __k2 - __k1); + } + +#if __cplusplus >= 201103L + /** + * @brief Replace range of characters with initializer_list. + * @param __i1 Iterator referencing start of range to replace. + * @param __i2 Iterator referencing end of range to replace. + * @param __l The initializer_list of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [__i1,__i2). In place, + * characters in the range [__k1,__k2) are inserted. If the + * length of result exceeds max_size(), length_error is thrown. + * The value of the string doesn't change if an error is + * thrown. + */ + basic_string& replace(iterator __i1, iterator __i2, + initializer_list<_CharT> __l) + { return this->replace(__i1, __i2, __l.begin(), __l.end()); } +#endif // C++11 + +#if __cplusplus >= 201703L + /** + * @brief Replace range of characters with string_view. + * @param __pos The position to replace at. + * @param __n The number of characters to replace. + * @param __svt The object convertible to string_view to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + replace(size_type __pos, size_type __n, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->replace(__pos, __n, __sv.data(), __sv.size()); + } + + /** + * @brief Replace range of characters with string_view. + * @param __pos1 The position to replace at. + * @param __n1 The number of characters to replace. + * @param __svt The object convertible to string_view to insert from. + * @param __pos2 The position in the string_view to insert from. + * @param __n2 The number of characters to insert. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + replace(size_type __pos1, size_type __n1, const _Tp& __svt, + size_type __pos2, size_type __n2 = npos) + { + __sv_type __sv = __svt; + return this->replace(__pos1, __n1, + __sv.data() + + std::__sv_check(__sv.size(), __pos2, "basic_string::replace"), + std::__sv_limit(__sv.size(), __pos2, __n2)); + } + + /** + * @brief Replace range of characters with string_view. + * @param __i1 An iterator referencing the start position + to replace at. + * @param __i2 An iterator referencing the end position + for the replace. + * @param __svt The object convertible to string_view to insert from. + * @return Reference to this string. + */ + template + _If_sv<_Tp, basic_string&> + replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt) + { + __sv_type __sv = __svt; + return this->replace(__i1 - begin(), __i2 - __i1, __sv); + } +#endif // C++17 + + private: + template + basic_string& + _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n, + _Integer __val, __true_type) + { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); } + + template + basic_string& + _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, + _InputIterator __k2, __false_type); + + basic_string& + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c); + + basic_string& + _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s, + size_type __n2); + + // _S_construct_aux is used to implement the 21.3.1 para 15 which + // requires special behaviour if _InIter is an integral type + template + static _CharT* + _S_construct_aux(_InIterator __beg, _InIterator __end, + const _Alloc& __a, __false_type) + { + typedef typename iterator_traits<_InIterator>::iterator_category _Tag; + return _S_construct(__beg, __end, __a, _Tag()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + static _CharT* + _S_construct_aux(_Integer __beg, _Integer __end, + const _Alloc& __a, __true_type) + { return _S_construct_aux_2(static_cast(__beg), + __end, __a); } + + static _CharT* + _S_construct_aux_2(size_type __req, _CharT __c, const _Alloc& __a) + { return _S_construct(__req, __c, __a); } + + template + static _CharT* + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a) + { + typedef typename std::__is_integer<_InIterator>::__type _Integral; + return _S_construct_aux(__beg, __end, __a, _Integral()); + } + + // For Input Iterators, used in istreambuf_iterators, etc. + template + static _CharT* + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, + input_iterator_tag); + + // For forward_iterators up to random_access_iterators, used for + // string::iterator, _CharT*, etc. + template + static _CharT* + _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, + forward_iterator_tag); + + static _CharT* + _S_construct(size_type __req, _CharT __c, const _Alloc& __a); + + public: + + /** + * @brief Copy substring into C string. + * @param __s C string to copy value into. + * @param __n Number of characters to copy. + * @param __pos Index of first character to copy. + * @return Number of characters actually copied + * @throw std::out_of_range If __pos > size(). + * + * Copies up to @a __n characters starting at @a __pos into the + * C string @a __s. If @a __pos is %greater than size(), + * out_of_range is thrown. + */ + size_type + copy(_CharT* __s, size_type __n, size_type __pos = 0) const; + + /** + * @brief Swap contents with another string. + * @param __s String to swap with. + * + * Exchanges the contents of this string with that of @a __s in constant + * time. + */ + void + swap(basic_string& __s) + _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value); + + // String operations: + /** + * @brief Return const pointer to null-terminated contents. + * + * This is a handle to internal data. Do not modify or dire things may + * happen. + */ + const _CharT* + c_str() const _GLIBCXX_NOEXCEPT + { return _M_data(); } + + /** + * @brief Return const pointer to contents. + * + * This is a pointer to internal data. It is undefined to modify + * the contents through the returned pointer. To get a pointer that + * allows modifying the contents use @c &str[0] instead, + * (or in C++17 the non-const @c str.data() overload). + */ + const _CharT* + data() const _GLIBCXX_NOEXCEPT + { return _M_data(); } + +#if __cplusplus >= 201703L + /** + * @brief Return non-const pointer to contents. + * + * This is a pointer to the character sequence held by the string. + * Modifying the characters in the sequence is allowed. + */ + _CharT* + data() noexcept + { + _M_leak(); + return _M_data(); + } +#endif + + /** + * @brief Return copy of allocator used to construct this string. + */ + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return _M_dataplus; } + + /** + * @brief Find position of a C substring. + * @param __s C string to locate. + * @param __pos Index of character to search from. + * @param __n Number of characters from @a s to search for. + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for the first @a + * __n characters in @a __s within this string. If found, + * returns the index where it begins. If not found, returns + * npos. + */ + size_type + find(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a string. + * @param __str String to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for value of @a __str within + * this string. If found, returns the index where it begins. If not + * found, returns npos. + */ + size_type + find(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find(__str.data(), __pos, __str.size()); } + + /** + * @brief Find position of a C string. + * @param __s C string to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + * + * Starting from @a __pos, searches forward for the value of @a + * __s within this string. If found, returns the index where + * it begins. If not found, returns npos. + */ + size_type + find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT; + +#if __cplusplus >= 201703L + /** + * @brief Find position of a string_view. + * @param __svt The object convertible to string_view to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of start of first occurrence. + */ + template + _If_sv<_Tp, size_type> + find(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a string. + * @param __str String to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for value of @a + * __str within this string. If found, returns the index where + * it begins. If not found, returns npos. + */ + size_type + rfind(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->rfind(__str.data(), __pos, __str.size()); } + + /** + * @brief Find last position of a C substring. + * @param __s C string to locate. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to search for. + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for the first @a + * __n characters in @a __s within this string. If found, + * returns the index where it begins. If not found, returns + * npos. + */ + size_type + rfind(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a C string. + * @param __s C string to locate. + * @param __pos Index of character to start search at (default end). + * @return Index of start of last occurrence. + * + * Starting from @a __pos, searches backward for the value of + * @a __s within this string. If found, returns the index + * where it begins. If not found, returns npos. + */ + size_type + rfind(const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->rfind(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT; + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a string_view. + * @param __svt The object convertible to string_view to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of start of last occurrence. + */ + template + _If_sv<_Tp, size_type> + rfind(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->rfind(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a character of string. + * @param __str String containing characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * characters of @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_first_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find_first_of(__str.data(), __pos, __str.size()); } + + /** + * @brief Find position of a character of C substring. + * @param __s String containing characters to locate. + * @param __pos Index of character to search from. + * @param __n Number of characters from s to search for. + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * first @a __n characters of @a __s within this string. If + * found, returns the index where it was found. If not found, + * returns npos. + */ + size_type + find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character of C string. + * @param __s String containing characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for one of the + * characters of @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + size_type + find_first_of(const _CharT* __s, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_first_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for the character + * @a __c within this string. If found, returns the index + * where it was found. If not found, returns npos. + * + * Note: equivalent to find(__c, __pos). + */ + size_type + find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return this->find(__c, __pos); } + +#if __cplusplus >= 201703L + /** + * @brief Find position of a character of a string_view. + * @param __svt An object convertible to string_view containing + * characters to locate. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + */ + template + _If_sv<_Tp, size_type> + find_first_of(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_first_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a character of string. + * @param __str String containing characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * characters of @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_last_of(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->find_last_of(__str.data(), __pos, __str.size()); } + + /** + * @brief Find last position of a character of C substring. + * @param __s C string containing characters to locate. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to search for. + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * first @a __n characters of @a __s within this string. If + * found, returns the index where it was found. If not found, + * returns npos. + */ + size_type + find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT; + + /** + * @brief Find last position of a character of C string. + * @param __s C string containing characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for one of the + * characters of @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + size_type + find_last_of(const _CharT* __s, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_last_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a character. + * @param __c Character to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for @a __c within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + * + * Note: equivalent to rfind(__c, __pos). + */ + size_type + find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT + { return this->rfind(__c, __pos); } + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a character of string. + * @param __svt An object convertible to string_view containing + * characters to locate. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + */ + template + _If_sv<_Tp, size_type> + find_last_of(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_last_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find position of a character not in string. + * @param __str String containing characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not contained + * in @a __str within this string. If found, returns the index where it + * was found. If not found, returns npos. + */ + size_type + find_first_not_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return this->find_first_not_of(__str.data(), __pos, __str.size()); } + + /** + * @brief Find position of a character not in C substring. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search from. + * @param __n Number of characters from __s to consider. + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not + * contained in the first @a __n characters of @a __s within + * this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + find_first_not_of(const _CharT* __s, size_type __pos, + size_type __n) const _GLIBCXX_NOEXCEPT; + + /** + * @brief Find position of a character not in C string. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character not + * contained in @a __s within this string. If found, returns + * the index where it was found. If not found, returns npos. + */ + size_type + find_first_not_of(const _CharT* __s, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_first_not_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find position of a different character. + * @param __c Character to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + * + * Starting from @a __pos, searches forward for a character + * other than @a __c within this string. If found, returns the + * index where it was found. If not found, returns npos. + */ + size_type + find_first_not_of(_CharT __c, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT; + +#if __cplusplus >= 201703L + /** + * @brief Find position of a character not in a string_view. + * @param __svt An object convertible to string_view containing + * characters to avoid. + * @param __pos Index of character to search from (default 0). + * @return Index of first occurrence. + */ + template + _If_sv<_Tp, size_type> + find_first_not_of(const _Tp& __svt, size_type __pos = 0) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_first_not_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Find last position of a character not in string. + * @param __str String containing characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character + * not contained in @a __str within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_last_not_of(const basic_string& __str, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { return this->find_last_not_of(__str.data(), __pos, __str.size()); } + + /** + * @brief Find last position of a character not in C substring. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search back from. + * @param __n Number of characters from s to consider. + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character not + * contained in the first @a __n characters of @a __s within this string. + * If found, returns the index where it was found. If not found, + * returns npos. + */ + size_type + find_last_not_of(const _CharT* __s, size_type __pos, + size_type __n) const _GLIBCXX_NOEXCEPT; + /** + * @brief Find last position of a character not in C string. + * @param __s C string containing characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character + * not contained in @a __s within this string. If found, + * returns the index where it was found. If not found, returns + * npos. + */ + size_type + find_last_not_of(const _CharT* __s, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + return this->find_last_not_of(__s, __pos, traits_type::length(__s)); + } + + /** + * @brief Find last position of a different character. + * @param __c Character to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + * + * Starting from @a __pos, searches backward for a character other than + * @a __c within this string. If found, returns the index where it was + * found. If not found, returns npos. + */ + size_type + find_last_not_of(_CharT __c, size_type __pos = npos) const + _GLIBCXX_NOEXCEPT; + +#if __cplusplus >= 201703L + /** + * @brief Find last position of a character not in a string_view. + * @param __svt An object convertible to string_view containing + * characters to avoid. + * @param __pos Index of character to search back from (default end). + * @return Index of last occurrence. + */ + template + _If_sv<_Tp, size_type> + find_last_not_of(const _Tp& __svt, size_type __pos = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return this->find_last_not_of(__sv.data(), __pos, __sv.size()); + } +#endif // C++17 + + /** + * @brief Get a substring. + * @param __pos Index of first character (default 0). + * @param __n Number of characters in substring (default remainder). + * @return The new string. + * @throw std::out_of_range If __pos > size(). + * + * Construct and return a new string using the @a __n + * characters starting at @a __pos. If the string is too + * short, use the remainder of the characters. If @a __pos is + * beyond the end of the string, out_of_range is thrown. + */ + basic_string + substr(size_type __pos = 0, size_type __n = npos) const + { return basic_string(*this, + _M_check(__pos, "basic_string::substr"), __n); } + + /** + * @brief Compare to a string. + * @param __str String to compare against. + * @return Integer < 0, 0, or > 0. + * + * Returns an integer < 0 if this string is ordered before @a + * __str, 0 if their values are equivalent, or > 0 if this + * string is ordered after @a __str. Determines the effective + * length rlen of the strings to compare as the smallest of + * size() and str.size(). The function then compares the two + * strings by calling traits::compare(data(), str.data(),rlen). + * If the result of the comparison is nonzero returns it, + * otherwise the shorter one is ordered first. + */ + int + compare(const basic_string& __str) const + { + const size_type __size = this->size(); + const size_type __osize = __str.size(); + const size_type __len = std::min(__size, __osize); + + int __r = traits_type::compare(_M_data(), __str.data(), __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + +#if __cplusplus >= 201703L + /** + * @brief Compare to a string_view. + * @param __svt An object convertible to string_view to compare against. + * @return Integer < 0, 0, or > 0. + */ + template + _If_sv<_Tp, int> + compare(const _Tp& __svt) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + const size_type __size = this->size(); + const size_type __osize = __sv.size(); + const size_type __len = std::min(__size, __osize); + + int __r = traits_type::compare(_M_data(), __sv.data(), __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + + /** + * @brief Compare to a string_view. + * @param __pos A position in the string to start comparing from. + * @param __n The number of characters to compare. + * @param __svt An object convertible to string_view to compare + * against. + * @return Integer < 0, 0, or > 0. + */ + template + _If_sv<_Tp, int> + compare(size_type __pos, size_type __n, const _Tp& __svt) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return __sv_type(*this).substr(__pos, __n).compare(__sv); + } + + /** + * @brief Compare to a string_view. + * @param __pos1 A position in the string to start comparing from. + * @param __n1 The number of characters to compare. + * @param __svt An object convertible to string_view to compare + * against. + * @param __pos2 A position in the string_view to start comparing from. + * @param __n2 The number of characters to compare. + * @return Integer < 0, 0, or > 0. + */ + template + _If_sv<_Tp, int> + compare(size_type __pos1, size_type __n1, const _Tp& __svt, + size_type __pos2, size_type __n2 = npos) const + noexcept(is_same<_Tp, __sv_type>::value) + { + __sv_type __sv = __svt; + return __sv_type(*this) + .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); + } +#endif // C++17 + + /** + * @brief Compare substring to a string. + * @param __pos Index of first character of substring. + * @param __n Number of characters in substring. + * @param __str String to compare against. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n characters + * starting at @a __pos. Returns an integer < 0 if the + * substring is ordered before @a __str, 0 if their values are + * equivalent, or > 0 if the substring is ordered after @a + * __str. Determines the effective length rlen of the strings + * to compare as the smallest of the length of the substring + * and @a __str.size(). The function then compares the two + * strings by calling + * traits::compare(substring.data(),str.data(),rlen). If the + * result of the comparison is nonzero returns it, otherwise + * the shorter one is ordered first. + */ + int + compare(size_type __pos, size_type __n, const basic_string& __str) const; + + /** + * @brief Compare substring to a substring. + * @param __pos1 Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __str String to compare against. + * @param __pos2 Index of first character of substring of str. + * @param __n2 Number of characters in substring of str. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a __pos1. Form the substring of @a + * __str from the @a __n2 characters starting at @a __pos2. + * Returns an integer < 0 if this substring is ordered before + * the substring of @a __str, 0 if their values are equivalent, + * or > 0 if this substring is ordered after the substring of + * @a __str. Determines the effective length rlen of the + * strings to compare as the smallest of the lengths of the + * substrings. The function then compares the two strings by + * calling + * traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen). + * If the result of the comparison is nonzero returns it, + * otherwise the shorter one is ordered first. + */ + int + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2 = npos) const; + + /** + * @brief Compare to a C string. + * @param __s C string to compare against. + * @return Integer < 0, 0, or > 0. + * + * Returns an integer < 0 if this string is ordered before @a __s, 0 if + * their values are equivalent, or > 0 if this string is ordered after + * @a __s. Determines the effective length rlen of the strings to + * compare as the smallest of size() and the length of a string + * constructed from @a __s. The function then compares the two strings + * by calling traits::compare(data(),s,rlen). If the result of the + * comparison is nonzero returns it, otherwise the shorter one is + * ordered first. + */ + int + compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 5 String::compare specification questionable + /** + * @brief Compare substring to a C string. + * @param __pos Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __s C string to compare against. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a pos. Returns an integer < 0 if + * the substring is ordered before @a __s, 0 if their values + * are equivalent, or > 0 if the substring is ordered after @a + * __s. Determines the effective length rlen of the strings to + * compare as the smallest of the length of the substring and + * the length of a string constructed from @a __s. The + * function then compares the two string by calling + * traits::compare(substring.data(),__s,rlen). If the result of + * the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. + */ + int + compare(size_type __pos, size_type __n1, const _CharT* __s) const; + + /** + * @brief Compare substring against a character %array. + * @param __pos Index of first character of substring. + * @param __n1 Number of characters in substring. + * @param __s character %array to compare against. + * @param __n2 Number of characters of s. + * @return Integer < 0, 0, or > 0. + * + * Form the substring of this string from the @a __n1 + * characters starting at @a __pos. Form a string from the + * first @a __n2 characters of @a __s. Returns an integer < 0 + * if this substring is ordered before the string from @a __s, + * 0 if their values are equivalent, or > 0 if this substring + * is ordered after the string from @a __s. Determines the + * effective length rlen of the strings to compare as the + * smallest of the length of the substring and @a __n2. The + * function then compares the two strings by calling + * traits::compare(substring.data(),s,rlen). If the result of + * the comparison is nonzero returns it, otherwise the shorter + * one is ordered first. + * + * NB: s must have at least n2 characters, '\\0' has + * no special meaning. + */ + int + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const; + +#if __cplusplus > 201703L + bool + starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + starts_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).starts_with(__x); } + + bool + ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } + + bool + ends_with(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).ends_with(__x); } +#endif // C++20 + +#if __cplusplus > 202011L + bool + contains(basic_string_view<_CharT, _Traits> __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } + + bool + contains(_CharT __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } + + bool + contains(const _CharT* __x) const noexcept + { return __sv_type(this->data(), this->size()).contains(__x); } +#endif // C++23 + +# ifdef _GLIBCXX_TM_TS_INTERNAL + friend void + ::_txnal_cow_string_C1_for_exceptions(void* that, const char* s, + void* exc); + friend const char* + ::_txnal_cow_string_c_str(const void *that); + friend void + ::_txnal_cow_string_D1(void *that); + friend void + ::_txnal_cow_string_D1_commit(void *that); +# endif + }; +#endif // !_GLIBCXX_USE_CXX11_ABI + +#if __cpp_deduction_guides >= 201606 +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template::value_type, + typename _Allocator = allocator<_CharT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3075. basic_string needs deduction guides from basic_string_view + template, + typename = _RequireAllocator<_Allocator>> + basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) + -> basic_string<_CharT, _Traits, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + basic_string(basic_string_view<_CharT, _Traits>, + typename basic_string<_CharT, _Traits, _Allocator>::size_type, + typename basic_string<_CharT, _Traits, _Allocator>::size_type, + const _Allocator& = _Allocator()) + -> basic_string<_CharT, _Traits, _Allocator>; +_GLIBCXX_END_NAMESPACE_CXX11 +#endif + + // operator+ + /** + * @brief Concatenate two strings. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with value of @a __lhs followed by @a __rhs. + */ + template + basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { + basic_string<_CharT, _Traits, _Alloc> __str(__lhs); + __str.append(__rhs); + return __str; + } + + /** + * @brief Concatenate C string and string. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with value of @a __lhs followed by @a __rhs. + */ + template + basic_string<_CharT,_Traits,_Alloc> + operator+(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Alloc>& __rhs); + + /** + * @brief Concatenate character and string. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with @a __lhs followed by @a __rhs. + */ + template + basic_string<_CharT,_Traits,_Alloc> + operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs); + + /** + * @brief Concatenate string and C string. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with @a __lhs followed by @a __rhs. + */ + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { + basic_string<_CharT, _Traits, _Alloc> __str(__lhs); + __str.append(__rhs); + return __str; + } + + /** + * @brief Concatenate string and character. + * @param __lhs First string. + * @param __rhs Last string. + * @return New string with @a __lhs followed by @a __rhs. + */ + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) + { + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __string_type::size_type __size_type; + __string_type __str(__lhs); + __str.append(__size_type(1), __rhs); + return __str; + } + +#if __cplusplus >= 201103L + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return std::move(__lhs.append(__rhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, __lhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { +#if _GLIBCXX_USE_CXX11_ABI + using _Alloc_traits = allocator_traits<_Alloc>; + bool __use_rhs = false; + if _GLIBCXX17_CONSTEXPR (typename _Alloc_traits::is_always_equal{}) + __use_rhs = true; + else if (__lhs.get_allocator() == __rhs.get_allocator()) + __use_rhs = true; + if (__use_rhs) +#endif + { + const auto __size = __lhs.size() + __rhs.size(); + if (__size > __lhs.capacity() && __size <= __rhs.capacity()) + return std::move(__rhs.insert(0, __lhs)); + } + return std::move(__lhs.append(__rhs)); + } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(const _CharT* __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, __lhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(_CharT __lhs, + basic_string<_CharT, _Traits, _Alloc>&& __rhs) + { return std::move(__rhs.insert(0, 1, __lhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + const _CharT* __rhs) + { return std::move(__lhs.append(__rhs)); } + + template + inline basic_string<_CharT, _Traits, _Alloc> + operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, + _CharT __rhs) + { return std::move(__lhs.append(1, __rhs)); } +#endif + + // operator == + /** + * @brief Test equivalence of two strings. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. + */ + template + inline bool + operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) == 0; } + + template + inline + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, bool>::__type + operator==(const basic_string<_CharT>& __lhs, + const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT + { return (__lhs.size() == __rhs.size() + && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(), + __lhs.size())); } + + /** + * @brief Test equivalence of string and C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs.compare(@a __rhs) == 0. False otherwise. + */ + template + inline bool + operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a string and a C string. + * @param __lhs A string. + * @param __rhs A null-terminated string. + * @return A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept + -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0)) + { return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); } + + /** + * @brief Three-way comparison of a string and a C string. + * @param __lhs A string. + * @param __rhs A null-terminated string. + * @return A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) noexcept + -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0)) + { return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); } +#else + /** + * @brief Test equivalence of C string and string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __rhs.compare(@a __lhs) == 0. False otherwise. + */ + template + inline bool + operator==(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) == 0; } + + // operator != + /** + * @brief Test difference of two strings. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. + */ + template + inline bool + operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return !(__lhs == __rhs); } + + /** + * @brief Test difference of C string and string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __rhs.compare(@a __lhs) != 0. False otherwise. + */ + template + inline bool + operator!=(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Test difference of string and C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs.compare(@a __rhs) != 0. False otherwise. + */ + template + inline bool + operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return !(__lhs == __rhs); } + + // operator < + /** + * @brief Test if string precedes string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs precedes @a __rhs. False otherwise. + */ + template + inline bool + operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Test if string precedes C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs precedes @a __rhs. False otherwise. + */ + template + inline bool + operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Test if C string precedes string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs precedes @a __rhs. False otherwise. + */ + template + inline bool + operator<(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) > 0; } + + // operator > + /** + * @brief Test if string follows string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs follows @a __rhs. False otherwise. + */ + template + inline bool + operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) > 0; } + + /** + * @brief Test if string follows C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs follows @a __rhs. False otherwise. + */ + template + inline bool + operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) > 0; } + + /** + * @brief Test if C string follows string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs follows @a __rhs. False otherwise. + */ + template + inline bool + operator>(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) < 0; } + + // operator <= + /** + * @brief Test if string doesn't follow string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. + */ + template + inline bool + operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Test if string doesn't follow C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. + */ + template + inline bool + operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Test if C string doesn't follow string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs doesn't follow @a __rhs. False otherwise. + */ + template + inline bool + operator<=(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) >= 0; } + + // operator >= + /** + * @brief Test if string doesn't precede string. + * @param __lhs First string. + * @param __rhs Second string. + * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. + */ + template + inline bool + operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Test if string doesn't precede C string. + * @param __lhs String. + * @param __rhs C string. + * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. + */ + template + inline bool + operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, + const _CharT* __rhs) + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Test if C string doesn't precede string. + * @param __lhs C string. + * @param __rhs String. + * @return True if @a __lhs doesn't precede @a __rhs. False otherwise. + */ + template + inline bool + operator>=(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { return __rhs.compare(__lhs) <= 0; } +#endif // three-way comparison + + /** + * @brief Swap contents of two strings. + * @param __lhs First string. + * @param __rhs Second string. + * + * Exchanges the contents of @a __lhs and @a __rhs in constant time. + */ + template + inline void + swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, + basic_string<_CharT, _Traits, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + + + /** + * @brief Read stream into a string. + * @param __is Input stream. + * @param __str Buffer to store into. + * @return Reference to the input stream. + * + * Stores characters from @a __is into @a __str until whitespace is + * found, the end of the stream is encountered, or str.max_size() + * is reached. If is.width() is non-zero, that is the limit on the + * number of characters stored into @a __str. Any previous + * contents of @a __str are erased. + */ + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT, _Traits, _Alloc>& __str); + + template<> + basic_istream& + operator>>(basic_istream& __is, basic_string& __str); + + /** + * @brief Write string to a stream. + * @param __os Output stream. + * @param __str String to write out. + * @return Reference to the output stream. + * + * Output characters of @a __str into os following the same rules as for + * writing a C string. + */ + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, + const basic_string<_CharT, _Traits, _Alloc>& __str) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 586. string inserter not a formatted function + return __ostream_insert(__os, __str.data(), __str.size()); + } + + /** + * @brief Read a line from stream into a string. + * @param __is Input stream. + * @param __str Buffer to store into. + * @param __delim Character marking end of line. + * @return Reference to the input stream. + * + * Stores characters from @a __is into @a __str until @a __delim is + * found, the end of the stream is encountered, or str.max_size() + * is reached. Any previous contents of @a __str are erased. If + * @a __delim is encountered, it is extracted but not stored into + * @a __str. + */ + template + basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim); + + /** + * @brief Read a line from stream into a string. + * @param __is Input stream. + * @param __str Buffer to store into. + * @return Reference to the input stream. + * + * Stores characters from is into @a __str until '\n' is + * found, the end of the stream is encountered, or str.max_size() + * is reached. Any previous contents of @a __str are erased. If + * end of line is encountered, it is extracted but not stored into + * @a __str. + */ + template + inline basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>& __is, + basic_string<_CharT, _Traits, _Alloc>& __str) + { return std::getline(__is, __str, __is.widen('\n')); } + +#if __cplusplus >= 201103L + /// Read a line from an rvalue stream into a string. + template + inline basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>&& __is, + basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim) + { return std::getline(__is, __str, __delim); } + + /// Read a line from an rvalue stream into a string. + template + inline basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>&& __is, + basic_string<_CharT, _Traits, _Alloc>& __str) + { return std::getline(__is, __str); } +#endif + + template<> + basic_istream& + getline(basic_istream& __in, basic_string& __str, + char __delim); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + basic_istream& + getline(basic_istream& __in, basic_string& __str, + wchar_t __delim); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if __cplusplus >= 201103L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + +#if _GLIBCXX_USE_C99_STDLIB + // 21.4 Numeric Conversions [string.conversions]. + inline int + stoi(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtol, "stoi", __str.c_str(), + __idx, __base); } + + inline long + stol(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(), + __idx, __base); } + + inline unsigned long + stoul(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(), + __idx, __base); } + + inline long long + stoll(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(), + __idx, __base); } + + inline unsigned long long + stoull(const string& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(), + __idx, __base); } + + // NB: strtof vs strtod. + inline float + stof(const string& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); } + + inline double + stod(const string& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); } + + inline long double + stold(const string& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); } +#endif // _GLIBCXX_USE_C99_STDLIB + + // DR 1261. Insufficent overloads for to_string / to_wstring + + inline string + to_string(int __val) + { + const bool __neg = __val < 0; + const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val; + const auto __len = __detail::__to_chars_len(__uval); + string __str(__neg + __len, '-'); + __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); + return __str; + } + + inline string + to_string(unsigned __val) + { + string __str(__detail::__to_chars_len(__val), '\0'); + __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); + return __str; + } + + inline string + to_string(long __val) + { + const bool __neg = __val < 0; + const unsigned long __uval = __neg ? (unsigned long)~__val + 1ul : __val; + const auto __len = __detail::__to_chars_len(__uval); + string __str(__neg + __len, '-'); + __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); + return __str; + } + + inline string + to_string(unsigned long __val) + { + string __str(__detail::__to_chars_len(__val), '\0'); + __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); + return __str; + } + + inline string + to_string(long long __val) + { + const bool __neg = __val < 0; + const unsigned long long __uval + = __neg ? (unsigned long long)~__val + 1ull : __val; + const auto __len = __detail::__to_chars_len(__uval); + string __str(__neg + __len, '-'); + __detail::__to_chars_10_impl(&__str[__neg], __len, __uval); + return __str; + } + + inline string + to_string(unsigned long long __val) + { + string __str(__detail::__to_chars_len(__val), '\0'); + __detail::__to_chars_10_impl(&__str[0], __str.size(), __val); + return __str; + } + +#if _GLIBCXX_USE_C99_STDIO + // NB: (v)snprintf vs sprintf. + + inline string + to_string(float __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vsnprintf, __n, + "%f", __val); + } + + inline string + to_string(double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vsnprintf, __n, + "%f", __val); + } + + inline string + to_string(long double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vsnprintf, __n, + "%Lf", __val); + } +#endif // _GLIBCXX_USE_C99_STDIO + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR + inline int + stoi(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstol, "stoi", __str.c_str(), + __idx, __base); } + + inline long + stol(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(), + __idx, __base); } + + inline unsigned long + stoul(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(), + __idx, __base); } + + inline long long + stoll(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(), + __idx, __base); } + + inline unsigned long long + stoull(const wstring& __str, size_t* __idx = 0, int __base = 10) + { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(), + __idx, __base); } + + // NB: wcstof vs wcstod. + inline float + stof(const wstring& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); } + + inline double + stod(const wstring& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); } + + inline long double + stold(const wstring& __str, size_t* __idx = 0) + { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); } + +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF + // DR 1261. + inline wstring + to_wstring(int __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(int), + L"%d", __val); } + + inline wstring + to_wstring(unsigned __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(unsigned), + L"%u", __val); } + + inline wstring + to_wstring(long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, 4 * sizeof(long), + L"%ld", __val); } + + inline wstring + to_wstring(unsigned long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(unsigned long), + L"%lu", __val); } + + inline wstring + to_wstring(long long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(long long), + L"%lld", __val); } + + inline wstring + to_wstring(unsigned long long __val) + { return __gnu_cxx::__to_xstring(&std::vswprintf, + 4 * sizeof(unsigned long long), + L"%llu", __val); } + + inline wstring + to_wstring(float __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vswprintf, __n, + L"%f", __val); + } + + inline wstring + to_wstring(double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vswprintf, __n, + L"%f", __val); + } + + inline wstring + to_wstring(long double __val) + { + const int __n = + __gnu_cxx::__numeric_traits::__max_exponent10 + 20; + return __gnu_cxx::__to_xstring(&std::vswprintf, __n, + L"%Lf", __val); + } +#endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF +#endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR + +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* C++11 */ + +#if __cplusplus >= 201103L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // DR 1182. + +#ifndef _GLIBCXX_COMPATIBILITY_CXX0X + /// std::hash specialization for string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), __s.length()); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; + +#ifdef _GLIBCXX_USE_WCHAR_T + /// std::hash specialization for wstring. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const wstring& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(wchar_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; +#endif +#endif /* _GLIBCXX_COMPATIBILITY_CXX0X */ + +#ifdef _GLIBCXX_USE_CHAR8_T + /// std::hash specialization for u8string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const u8string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(char8_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; +#endif + + /// std::hash specialization for u16string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const u16string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(char16_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; + + /// std::hash specialization for u32string. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const u32string& __s) const noexcept + { return std::_Hash_impl::hash(__s.data(), + __s.length() * sizeof(char32_t)); } + }; + + template<> + struct __is_fast_hash> : std::false_type + { }; + +#if __cplusplus >= 201402L + +#define __cpp_lib_string_udls 201304 + + inline namespace literals + { + inline namespace string_literals + { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char* __str, size_t __len) + { return basic_string{__str, __len}; } + +#ifdef _GLIBCXX_USE_WCHAR_T + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const wchar_t* __str, size_t __len) + { return basic_string{__str, __len}; } +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char8_t* __str, size_t __len) + { return basic_string{__str, __len}; } +#endif + + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char16_t* __str, size_t __len) + { return basic_string{__str, __len}; } + + _GLIBCXX_DEFAULT_ABI_TAG + inline basic_string + operator""s(const char32_t* __str, size_t __len) + { return basic_string{__str, __len}; } + +#pragma GCC diagnostic pop + } // inline namespace string_literals + } // inline namespace literals + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // basic_string into a variant, but only if moving the string cannot throw. + template + struct _Never_valueless_alt> + : __and_< + is_nothrow_move_constructible>, + is_nothrow_move_assignable> + >::type + { }; + } // namespace __detail::__variant +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif /* _BASIC_STRING_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_string.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_string.tcc new file mode 100755 index 0000000..35b6086 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/basic_string.tcc @@ -0,0 +1,1674 @@ +// Components for manipulating sequences of characters -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/basic_string.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +// Written by Jason Merrill based upon the specification by Takanori Adachi +// in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers to ISO-14882. +// Non-reference-counted implementation written by Paolo Carlini and +// updated by Jonathan Wakely for ISO-14882-2011. + +#ifndef _BASIC_STRING_TCC +#define _BASIC_STRING_TCC 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if _GLIBCXX_USE_CXX11_ABI + + template + const typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>::npos; + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + swap(basic_string& __s) _GLIBCXX_NOEXCEPT + { + if (this == &__s) + return; + + _Alloc_traits::_S_on_swap(_M_get_allocator(), __s._M_get_allocator()); + + if (_M_is_local()) + if (__s._M_is_local()) + { + if (length() && __s.length()) + { + _CharT __tmp_data[_S_local_capacity + 1]; + traits_type::copy(__tmp_data, __s._M_local_buf, + _S_local_capacity + 1); + traits_type::copy(__s._M_local_buf, _M_local_buf, + _S_local_capacity + 1); + traits_type::copy(_M_local_buf, __tmp_data, + _S_local_capacity + 1); + } + else if (__s.length()) + { + traits_type::copy(_M_local_buf, __s._M_local_buf, + _S_local_capacity + 1); + _M_length(__s.length()); + __s._M_set_length(0); + return; + } + else if (length()) + { + traits_type::copy(__s._M_local_buf, _M_local_buf, + _S_local_capacity + 1); + __s._M_length(length()); + _M_set_length(0); + return; + } + } + else + { + const size_type __tmp_capacity = __s._M_allocated_capacity; + traits_type::copy(__s._M_local_buf, _M_local_buf, + _S_local_capacity + 1); + _M_data(__s._M_data()); + __s._M_data(__s._M_local_buf); + _M_capacity(__tmp_capacity); + } + else + { + const size_type __tmp_capacity = _M_allocated_capacity; + if (__s._M_is_local()) + { + traits_type::copy(_M_local_buf, __s._M_local_buf, + _S_local_capacity + 1); + __s._M_data(_M_data()); + _M_data(_M_local_buf); + } + else + { + pointer __tmp_ptr = _M_data(); + _M_data(__s._M_data()); + __s._M_data(__tmp_ptr); + _M_capacity(__s._M_allocated_capacity); + } + __s._M_capacity(__tmp_capacity); + } + + const size_type __tmp_length = length(); + _M_length(__s.length()); + __s._M_length(__tmp_length); + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::pointer + basic_string<_CharT, _Traits, _Alloc>:: + _M_create(size_type& __capacity, size_type __old_capacity) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 83. String::npos vs. string::max_size() + if (__capacity > max_size()) + std::__throw_length_error(__N("basic_string::_M_create")); + + // The below implements an exponential growth policy, necessary to + // meet amortized linear time requirements of the library: see + // http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html. + if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) + { + __capacity = 2 * __old_capacity; + // Never allocate a string bigger than max_size. + if (__capacity > max_size()) + __capacity = max_size(); + } + + // NB: Need an array of char_type[__capacity], plus a terminating + // null char_type() element. + return _Alloc_traits::allocate(_M_get_allocator(), __capacity + 1); + } + + // NB: This is the special case for Input Iterators, used in + // istreambuf_iterators, etc. + // Input Iterators have a cost structure very different from + // pointers, calling for a different coding style. + template + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(_InIterator __beg, _InIterator __end, + std::input_iterator_tag) + { + size_type __len = 0; + size_type __capacity = size_type(_S_local_capacity); + + while (__beg != __end && __len < __capacity) + { + _M_data()[__len++] = *__beg; + ++__beg; + } + + __try + { + while (__beg != __end) + { + if (__len == __capacity) + { + // Allocate more space. + __capacity = __len + 1; + pointer __another = _M_create(__capacity, __len); + this->_S_copy(__another, _M_data(), __len); + _M_dispose(); + _M_data(__another); + _M_capacity(__capacity); + } + _M_data()[__len++] = *__beg; + ++__beg; + } + } + __catch(...) + { + _M_dispose(); + __throw_exception_again; + } + + _M_set_length(__len); + } + + template + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(_InIterator __beg, _InIterator __end, + std::forward_iterator_tag) + { + // NB: Not required, but considered best practice. + if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end) + std::__throw_logic_error(__N("basic_string::" + "_M_construct null not valid")); + + size_type __dnew = static_cast(std::distance(__beg, __end)); + + if (__dnew > size_type(_S_local_capacity)) + { + _M_data(_M_create(__dnew, size_type(0))); + _M_capacity(__dnew); + } + + // Check for out_of_range and length_error exceptions. + __try + { this->_S_copy_chars(_M_data(), __beg, __end); } + __catch(...) + { + _M_dispose(); + __throw_exception_again; + } + + _M_set_length(__dnew); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_construct(size_type __n, _CharT __c) + { + if (__n > size_type(_S_local_capacity)) + { + _M_data(_M_create(__n, size_type(0))); + _M_capacity(__n); + } + + if (__n) + this->_S_assign(_M_data(), __n, __c); + + _M_set_length(__n); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_assign(const basic_string& __str) + { + if (this != &__str) + { + const size_type __rsize = __str.length(); + const size_type __capacity = capacity(); + + if (__rsize > __capacity) + { + size_type __new_capacity = __rsize; + pointer __tmp = _M_create(__new_capacity, __capacity); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__new_capacity); + } + + if (__rsize) + this->_S_copy(_M_data(), __str._M_data(), __rsize); + + _M_set_length(__rsize); + } + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve(size_type __res) + { + const size_type __capacity = capacity(); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2968. Inconsistencies between basic_string reserve and + // vector/unordered_map/unordered_set reserve functions + // P0966 reserve should not shrink + if (__res <= __capacity) + return; + + pointer __tmp = _M_create(__res, __capacity); + this->_S_copy(__tmp, _M_data(), length() + 1); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__res); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_mutate(size_type __pos, size_type __len1, const _CharT* __s, + size_type __len2) + { + const size_type __how_much = length() - __pos - __len1; + + size_type __new_capacity = length() + __len2 - __len1; + pointer __r = _M_create(__new_capacity, capacity()); + + if (__pos) + this->_S_copy(__r, _M_data(), __pos); + if (__s && __len2) + this->_S_copy(__r + __pos, __s, __len2); + if (__how_much) + this->_S_copy(__r + __pos + __len2, + _M_data() + __pos + __len1, __how_much); + + _M_dispose(); + _M_data(__r); + _M_capacity(__new_capacity); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_erase(size_type __pos, size_type __n) + { + const size_type __how_much = length() - __pos - __n; + + if (__how_much && __n) + this->_S_move(_M_data() + __pos, _M_data() + __pos + __n, __how_much); + + _M_set_length(length() - __n); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve() + { + if (_M_is_local()) + return; + + const size_type __length = length(); + const size_type __capacity = _M_allocated_capacity; + + if (__length <= size_type(_S_local_capacity)) + { + this->_S_copy(_M_local_data(), _M_data(), __length + 1); + _M_destroy(__capacity); + _M_data(_M_local_data()); + } +#if __cpp_exceptions + else if (__length < __capacity) + try + { + pointer __tmp + = _Alloc_traits::allocate(_M_get_allocator(), __length + 1); + this->_S_copy(__tmp, _M_data(), __length + 1); + _M_dispose(); + _M_data(__tmp); + _M_capacity(__length); + } + catch (const __cxxabiv1::__forced_unwind&) + { throw; } + catch (...) + { /* swallow the exception */ } +#endif + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + resize(size_type __n, _CharT __c) + { + const size_type __size = this->size(); + if (__size < __n) + this->append(__n - __size, __c); + else if (__n < __size) + this->_M_set_length(__n); + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_append(const _CharT* __s, size_type __n) + { + const size_type __len = __n + this->size(); + + if (__len <= this->capacity()) + { + if (__n) + this->_S_copy(this->_M_data() + this->size(), __s, __n); + } + else + this->_M_mutate(this->size(), size_type(0), __s, __n); + + this->_M_set_length(__len); + return *this; + } + + template + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + std::__false_type) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2788. unintentionally require a default constructible allocator + const basic_string __s(__k1, __k2, this->get_allocator()); + const size_type __n1 = __i2 - __i1; + return _M_replace(__i1 - begin(), __n1, __s._M_data(), + __s.size()); + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c) + { + _M_check_length(__n1, __n2, "basic_string::_M_replace_aux"); + + const size_type __old_size = this->size(); + const size_type __new_size = __old_size + __n2 - __n1; + + if (__new_size <= this->capacity()) + { + pointer __p = this->_M_data() + __pos1; + + const size_type __how_much = __old_size - __pos1 - __n1; + if (__how_much && __n1 != __n2) + this->_S_move(__p + __n2, __p + __n1, __how_much); + } + else + this->_M_mutate(__pos1, __n1, 0, __n2); + + if (__n2) + this->_S_assign(this->_M_data() + __pos1, __n2, __c); + + this->_M_set_length(__new_size); + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace(size_type __pos, size_type __len1, const _CharT* __s, + const size_type __len2) + { + _M_check_length(__len1, __len2, "basic_string::_M_replace"); + + const size_type __old_size = this->size(); + const size_type __new_size = __old_size + __len2 - __len1; + + if (__new_size <= this->capacity()) + { + pointer __p = this->_M_data() + __pos; + + const size_type __how_much = __old_size - __pos - __len1; + if (_M_disjunct(__s)) + { + if (__how_much && __len1 != __len2) + this->_S_move(__p + __len2, __p + __len1, __how_much); + if (__len2) + this->_S_copy(__p, __s, __len2); + } + else + { + // Work in-place. + if (__len2 && __len2 <= __len1) + this->_S_move(__p, __s, __len2); + if (__how_much && __len1 != __len2) + this->_S_move(__p + __len2, __p + __len1, __how_much); + if (__len2 > __len1) + { + if (__s + __len2 <= __p + __len1) + this->_S_move(__p, __s, __len2); + else if (__s >= __p + __len1) + { + // Hint to middle end that __p and __s overlap + // (PR 98465). + const size_type __poff = (__s - __p) + (__len2 - __len1); + this->_S_copy(__p, __p + __poff, __len2); + } + else + { + const size_type __nleft = (__p + __len1) - __s; + this->_S_move(__p, __s, __nleft); + this->_S_copy(__p + __nleft, __p + __len2, + __len2 - __nleft); + } + } + } + } + else + this->_M_mutate(__pos, __len1, __s, __len2); + + this->_M_set_length(__new_size); + return *this; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + copy(_CharT* __s, size_type __n, size_type __pos) const + { + _M_check(__pos, "basic_string::copy"); + __n = _M_limit(__pos, __n); + __glibcxx_requires_string_len(__s, __n); + if (__n) + _S_copy(__s, _M_data() + __pos, __n); + // 21.3.5.7 par 3: do not append null. (good.) + return __n; + } + +#else // !_GLIBCXX_USE_CXX11_ABI + + template + const typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + _Rep::_S_max_size = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4; + + template + const _CharT + basic_string<_CharT, _Traits, _Alloc>:: + _Rep::_S_terminal = _CharT(); + + template + const typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>::npos; + + // Linker sets _S_empty_rep_storage to all 0s (one reference, empty string) + // at static init time (before static ctors are run). + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_empty_rep_storage[ + (sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) / + sizeof(size_type)]; + + // NB: This is the special case for Input Iterators, used in + // istreambuf_iterators, etc. + // Input Iterators have a cost structure very different from + // pointers, calling for a different coding style. + template + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>:: + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, + input_iterator_tag) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__beg == __end && __a == _Alloc()) + return _S_empty_rep()._M_refdata(); +#endif + // Avoid reallocation for common case. + _CharT __buf[128]; + size_type __len = 0; + while (__beg != __end && __len < sizeof(__buf) / sizeof(_CharT)) + { + __buf[__len++] = *__beg; + ++__beg; + } + _Rep* __r = _Rep::_S_create(__len, size_type(0), __a); + _M_copy(__r->_M_refdata(), __buf, __len); + __try + { + while (__beg != __end) + { + if (__len == __r->_M_capacity) + { + // Allocate more space. + _Rep* __another = _Rep::_S_create(__len + 1, __len, __a); + _M_copy(__another->_M_refdata(), __r->_M_refdata(), __len); + __r->_M_destroy(__a); + __r = __another; + } + __r->_M_refdata()[__len++] = *__beg; + ++__beg; + } + } + __catch(...) + { + __r->_M_destroy(__a); + __throw_exception_again; + } + __r->_M_set_length_and_sharable(__len); + return __r->_M_refdata(); + } + + template + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>:: + _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, + forward_iterator_tag) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__beg == __end && __a == _Alloc()) + return _S_empty_rep()._M_refdata(); +#endif + // NB: Not required, but considered best practice. + if (__gnu_cxx::__is_null_pointer(__beg) && __beg != __end) + __throw_logic_error(__N("basic_string::_S_construct null not valid")); + + const size_type __dnew = static_cast(std::distance(__beg, + __end)); + // Check for out_of_range and length_error exceptions. + _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a); + __try + { _S_copy_chars(__r->_M_refdata(), __beg, __end); } + __catch(...) + { + __r->_M_destroy(__a); + __throw_exception_again; + } + __r->_M_set_length_and_sharable(__dnew); + return __r->_M_refdata(); + } + + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>:: + _S_construct(size_type __n, _CharT __c, const _Alloc& __a) + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (__n == 0 && __a == _Alloc()) + return _S_empty_rep()._M_refdata(); +#endif + // Check for out_of_range and length_error exceptions. + _Rep* __r = _Rep::_S_create(__n, size_type(0), __a); + if (__n) + _M_assign(__r->_M_refdata(), __n, __c); + + __r->_M_set_length_and_sharable(__n); + return __r->_M_refdata(); + } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str, size_type __pos, const _Alloc& __a) + : _M_dataplus(_S_construct(__str._M_data() + + __str._M_check(__pos, + "basic_string::basic_string"), + __str._M_data() + __str._M_limit(__pos, npos) + + __pos, __a), __a) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str, size_type __pos, size_type __n) + : _M_dataplus(_S_construct(__str._M_data() + + __str._M_check(__pos, + "basic_string::basic_string"), + __str._M_data() + __str._M_limit(__pos, __n) + + __pos, _Alloc()), _Alloc()) + { } + + template + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(const basic_string& __str, size_type __pos, + size_type __n, const _Alloc& __a) + : _M_dataplus(_S_construct(__str._M_data() + + __str._M_check(__pos, + "basic_string::basic_string"), + __str._M_data() + __str._M_limit(__pos, __n) + + __pos, __a), __a) + { } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + assign(const basic_string& __str) + { + if (_M_rep() != __str._M_rep()) + { + // XXX MT + const allocator_type __a = this->get_allocator(); + _CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator()); + _M_rep()->_M_dispose(__a); + _M_data(__tmp); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + assign(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check_length(this->size(), __n, "basic_string::assign"); + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(size_type(0), this->size(), __s, __n); + else + { + // Work in-place. + const size_type __pos = __s - _M_data(); + if (__pos >= __n) + _M_copy(_M_data(), __s, __n); + else if (__pos) + _M_move(_M_data(), __s, __n); + _M_rep()->_M_set_length_and_sharable(__n); + return *this; + } + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(size_type __n, _CharT __c) + { + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_assign(_M_data() + this->size(), __n, __c); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + if (__n) + { + _M_check_length(size_type(0), __n, "basic_string::append"); + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + { + if (_M_disjunct(__s)) + this->reserve(__len); + else + { + const size_type __off = __s - _M_data(); + this->reserve(__len); + __s = _M_data() + __off; + } + } + _M_copy(_M_data() + this->size(), __s, __n); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str) + { + const size_type __size = __str.size(); + if (__size) + { + const size_type __len = __size + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data(), __size); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + append(const basic_string& __str, size_type __pos, size_type __n) + { + __str._M_check(__pos, "basic_string::append"); + __n = __str._M_limit(__pos, __n); + if (__n) + { + const size_type __len = __n + this->size(); + if (__len > this->capacity() || _M_rep()->_M_is_shared()) + this->reserve(__len); + _M_copy(_M_data() + this->size(), __str._M_data() + __pos, __n); + _M_rep()->_M_set_length_and_sharable(__len); + } + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + insert(size_type __pos, const _CharT* __s, size_type __n) + { + __glibcxx_requires_string_len(__s, __n); + _M_check(__pos, "basic_string::insert"); + _M_check_length(size_type(0), __n, "basic_string::insert"); + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(__pos, size_type(0), __s, __n); + else + { + // Work in-place. + const size_type __off = __s - _M_data(); + _M_mutate(__pos, 0, __n); + __s = _M_data() + __off; + _CharT* __p = _M_data() + __pos; + if (__s + __n <= __p) + _M_copy(__p, __s, __n); + else if (__s >= __p) + _M_copy(__p, __s + __n, __n); + else + { + const size_type __nleft = __p - __s; + _M_copy(__p, __s, __nleft); + _M_copy(__p + __nleft, __p + __n, __n - __nleft); + } + return *this; + } + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::iterator + basic_string<_CharT, _Traits, _Alloc>:: + erase(iterator __first, iterator __last) + { + _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last + && __last <= _M_iend()); + + // NB: This isn't just an optimization (bail out early when + // there is nothing to do, really), it's also a correctness + // issue vs MT, see libstdc++/40518. + const size_type __size = __last - __first; + if (__size) + { + const size_type __pos = __first - _M_ibegin(); + _M_mutate(__pos, __size, size_type(0)); + _M_rep()->_M_set_leaked(); + return iterator(_M_data() + __pos); + } + else + return __first; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) + { + __glibcxx_requires_string_len(__s, __n2); + _M_check(__pos, "basic_string::replace"); + __n1 = _M_limit(__pos, __n1); + _M_check_length(__n1, __n2, "basic_string::replace"); + bool __left; + if (_M_disjunct(__s) || _M_rep()->_M_is_shared()) + return _M_replace_safe(__pos, __n1, __s, __n2); + else if ((__left = __s + __n2 <= _M_data() + __pos) + || _M_data() + __pos + __n1 <= __s) + { + // Work in-place: non-overlapping case. + size_type __off = __s - _M_data(); + __left ? __off : (__off += __n2 - __n1); + _M_mutate(__pos, __n1, __n2); + _M_copy(_M_data() + __pos, _M_data() + __off, __n2); + return *this; + } + else + { + // Todo: overlapping case. + const basic_string __tmp(__s, __n2); + return _M_replace_safe(__pos, __n1, __tmp._M_data(), __n2); + } + } + + template + void + basic_string<_CharT, _Traits, _Alloc>::_Rep:: + _M_destroy(const _Alloc& __a) throw () + { + const size_type __size = sizeof(_Rep_base) + + (this->_M_capacity + 1) * sizeof(_CharT); + _Raw_bytes_alloc(__a).deallocate(reinterpret_cast(this), __size); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_leak_hard() + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + if (_M_rep() == &_S_empty_rep()) + return; +#endif + if (_M_rep()->_M_is_shared()) + _M_mutate(0, 0, 0); + _M_rep()->_M_set_leaked(); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + _M_mutate(size_type __pos, size_type __len1, size_type __len2) + { + const size_type __old_size = this->size(); + const size_type __new_size = __old_size + __len2 - __len1; + const size_type __how_much = __old_size - __pos - __len1; + + if (__new_size > this->capacity() || _M_rep()->_M_is_shared()) + { + // Must reallocate. + const allocator_type __a = get_allocator(); + _Rep* __r = _Rep::_S_create(__new_size, this->capacity(), __a); + + if (__pos) + _M_copy(__r->_M_refdata(), _M_data(), __pos); + if (__how_much) + _M_copy(__r->_M_refdata() + __pos + __len2, + _M_data() + __pos + __len1, __how_much); + + _M_rep()->_M_dispose(__a); + _M_data(__r->_M_refdata()); + } + else if (__how_much && __len1 != __len2) + { + // Work in-place. + _M_move(_M_data() + __pos + __len2, + _M_data() + __pos + __len1, __how_much); + } + _M_rep()->_M_set_length_and_sharable(__new_size); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve(size_type __res) + { + const size_type __capacity = capacity(); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2968. Inconsistencies between basic_string reserve and + // vector/unordered_map/unordered_set reserve functions + // P0966 reserve should not shrink + if (__res <= __capacity) + { + if (!_M_rep()->_M_is_shared()) + return; + + // unshare, but keep same capacity + __res = __capacity; + } + + const allocator_type __a = get_allocator(); + _CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size()); + _M_rep()->_M_dispose(__a); + _M_data(__tmp); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + swap(basic_string& __s) + _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value) + { + if (_M_rep()->_M_is_leaked()) + _M_rep()->_M_set_sharable(); + if (__s._M_rep()->_M_is_leaked()) + __s._M_rep()->_M_set_sharable(); + if (this->get_allocator() == __s.get_allocator()) + { + _CharT* __tmp = _M_data(); + _M_data(__s._M_data()); + __s._M_data(__tmp); + } + // The code below can usually be optimized away. + else + { + const basic_string __tmp1(_M_ibegin(), _M_iend(), + __s.get_allocator()); + const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(), + this->get_allocator()); + *this = __tmp2; + __s = __tmp1; + } + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::_Rep* + basic_string<_CharT, _Traits, _Alloc>::_Rep:: + _S_create(size_type __capacity, size_type __old_capacity, + const _Alloc& __alloc) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 83. String::npos vs. string::max_size() + if (__capacity > _S_max_size) + __throw_length_error(__N("basic_string::_S_create")); + + // The standard places no restriction on allocating more memory + // than is strictly needed within this layer at the moment or as + // requested by an explicit application call to reserve(n). + + // Many malloc implementations perform quite poorly when an + // application attempts to allocate memory in a stepwise fashion + // growing each allocation size by only 1 char. Additionally, + // it makes little sense to allocate less linear memory than the + // natural blocking size of the malloc implementation. + // Unfortunately, we would need a somewhat low-level calculation + // with tuned parameters to get this perfect for any particular + // malloc implementation. Fortunately, generalizations about + // common features seen among implementations seems to suffice. + + // __pagesize need not match the actual VM page size for good + // results in practice, thus we pick a common value on the low + // side. __malloc_header_size is an estimate of the amount of + // overhead per memory allocation (in practice seen N * sizeof + // (void*) where N is 0, 2 or 4). According to folklore, + // picking this value on the high side is better than + // low-balling it (especially when this algorithm is used with + // malloc implementations that allocate memory blocks rounded up + // to a size which is a power of 2). + const size_type __pagesize = 4096; + const size_type __malloc_header_size = 4 * sizeof(void*); + + // The below implements an exponential growth policy, necessary to + // meet amortized linear time requirements of the library: see + // http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html. + // It's active for allocations requiring an amount of memory above + // system pagesize. This is consistent with the requirements of the + // standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html + if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) + __capacity = 2 * __old_capacity; + + // NB: Need an array of char_type[__capacity], plus a terminating + // null char_type() element, plus enough for the _Rep data structure. + // Whew. Seemingly so needy, yet so elemental. + size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); + + const size_type __adj_size = __size + __malloc_header_size; + if (__adj_size > __pagesize && __capacity > __old_capacity) + { + const size_type __extra = __pagesize - __adj_size % __pagesize; + __capacity += __extra / sizeof(_CharT); + // Never allocate a string bigger than _S_max_size. + if (__capacity > _S_max_size) + __capacity = _S_max_size; + __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); + } + + // NB: Might throw, but no worries about a leak, mate: _Rep() + // does not throw. + void* __place = _Raw_bytes_alloc(__alloc).allocate(__size); + _Rep *__p = new (__place) _Rep; + __p->_M_capacity = __capacity; + // ABI compatibility - 3.4.x set in _S_create both + // _M_refcount and _M_length. All callers of _S_create + // in basic_string.tcc then set just _M_length. + // In 4.0.x and later both _M_refcount and _M_length + // are initialized in the callers, unfortunately we can + // have 3.4.x compiled code with _S_create callers inlined + // calling 4.0.x+ _S_create. + __p->_M_set_sharable(); + return __p; + } + + template + _CharT* + basic_string<_CharT, _Traits, _Alloc>::_Rep:: + _M_clone(const _Alloc& __alloc, size_type __res) + { + // Requested capacity of the clone. + const size_type __requested_cap = this->_M_length + __res; + _Rep* __r = _Rep::_S_create(__requested_cap, this->_M_capacity, + __alloc); + if (this->_M_length) + _M_copy(__r->_M_refdata(), _M_refdata(), this->_M_length); + + __r->_M_set_length_and_sharable(this->_M_length); + return __r->_M_refdata(); + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + resize(size_type __n, _CharT __c) + { + const size_type __size = this->size(); + _M_check_length(__size, __n, "basic_string::resize"); + if (__size < __n) + this->append(__n - __size, __c); + else if (__n < __size) + this->erase(__n); + // else nothing (in particular, avoid calling _M_mutate() unnecessarily.) + } + + template + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, + _InputIterator __k2, __false_type) + { + const basic_string __s(__k1, __k2); + const size_type __n1 = __i2 - __i1; + _M_check_length(__n1, __s.size(), "basic_string::_M_replace_dispatch"); + return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(), + __s.size()); + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, + _CharT __c) + { + _M_check_length(__n1, __n2, "basic_string::_M_replace_aux"); + _M_mutate(__pos1, __n1, __n2); + if (__n2) + _M_assign(_M_data() + __pos1, __n2, __c); + return *this; + } + + template + basic_string<_CharT, _Traits, _Alloc>& + basic_string<_CharT, _Traits, _Alloc>:: + _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s, + size_type __n2) + { + _M_mutate(__pos1, __n1, __n2); + if (__n2) + _M_copy(_M_data() + __pos1, __s, __n2); + return *this; + } + + template + void + basic_string<_CharT, _Traits, _Alloc>:: + reserve() + { +#if __cpp_exceptions + if (length() < capacity() || _M_rep()->_M_is_shared()) + try + { + const allocator_type __a = get_allocator(); + _CharT* __tmp = _M_rep()->_M_clone(__a); + _M_rep()->_M_dispose(__a); + _M_data(__tmp); + } + catch (const __cxxabiv1::__forced_unwind&) + { throw; } + catch (...) + { /* swallow the exception */ } +#endif + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + copy(_CharT* __s, size_type __n, size_type __pos) const + { + _M_check(__pos, "basic_string::copy"); + __n = _M_limit(__pos, __n); + __glibcxx_requires_string_len(__s, __n); + if (__n) + _M_copy(__s, _M_data() + __pos, __n); + // 21.3.5.7 par 3: do not append null. (good.) + return __n; + } +#endif // !_GLIBCXX_USE_CXX11_ABI + + template + basic_string<_CharT, _Traits, _Alloc> + operator+(const _CharT* __lhs, + const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { + __glibcxx_requires_string(__lhs); + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __string_type::size_type __size_type; + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + const __size_type __len = _Traits::length(__lhs); + __string_type __str(_Alloc_traits::_S_select_on_copy( + __rhs.get_allocator())); + __str.reserve(__len + __rhs.size()); + __str.append(__lhs, __len); + __str.append(__rhs); + return __str; + } + + template + basic_string<_CharT, _Traits, _Alloc> + operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) + { + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __string_type::size_type __size_type; + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + __string_type __str(_Alloc_traits::_S_select_on_copy( + __rhs.get_allocator())); + const __size_type __len = __rhs.size(); + __str.reserve(__len + 1); + __str.append(__size_type(1), __lhs); + __str.append(__rhs); + return __str; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + const size_type __size = this->size(); + + if (__n == 0) + return __pos <= __size ? __pos : npos; + if (__pos >= __size) + return npos; + + const _CharT __elem0 = __s[0]; + const _CharT* const __data = data(); + const _CharT* __first = __data + __pos; + const _CharT* const __last = __data + __size; + size_type __len = __size - __pos; + + while (__len >= __n) + { + // Find the first occurrence of __elem0: + __first = traits_type::find(__first, __len - __n + 1, __elem0); + if (!__first) + return npos; + // Compare the full strings from the first occurrence of __elem0. + // We already know that __first[0] == __s[0] but compare them again + // anyway because __s is probably aligned, which helps memcmp. + if (traits_type::compare(__first, __s, __n) == 0) + return __first - __data; + __len = __last - ++__first; + } + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + size_type __ret = npos; + const size_type __size = this->size(); + if (__pos < __size) + { + const _CharT* __data = _M_data(); + const size_type __n = __size - __pos; + const _CharT* __p = traits_type::find(__data + __pos, __n, __c); + if (__p) + __ret = __p - __data; + } + return __ret; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + rfind(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + const size_type __size = this->size(); + if (__n <= __size) + { + __pos = std::min(size_type(__size - __n), __pos); + const _CharT* __data = _M_data(); + do + { + if (traits_type::compare(__data + __pos, __s, __n) == 0) + return __pos; + } + while (__pos-- > 0); + } + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + rfind(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + size_type __size = this->size(); + if (__size) + { + if (--__size > __pos) + __size = __pos; + for (++__size; __size-- > 0; ) + if (traits_type::eq(_M_data()[__size], __c)) + return __size; + } + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + for (; __n && __pos < this->size(); ++__pos) + { + const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]); + if (__p) + return __pos; + } + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + size_type __size = this->size(); + if (__size && __n) + { + if (--__size > __pos) + __size = __pos; + do + { + if (traits_type::find(__s, __n, _M_data()[__size])) + return __size; + } + while (__size-- != 0); + } + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + for (; __pos < this->size(); ++__pos) + if (!traits_type::find(__s, __n, _M_data()[__pos])) + return __pos; + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_first_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + for (; __pos < this->size(); ++__pos) + if (!traits_type::eq(_M_data()[__pos], __c)) + return __pos; + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const + _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string_len(__s, __n); + size_type __size = this->size(); + if (__size) + { + if (--__size > __pos) + __size = __pos; + do + { + if (!traits_type::find(__s, __n, _M_data()[__size])) + return __size; + } + while (__size--); + } + return npos; + } + + template + typename basic_string<_CharT, _Traits, _Alloc>::size_type + basic_string<_CharT, _Traits, _Alloc>:: + find_last_not_of(_CharT __c, size_type __pos) const _GLIBCXX_NOEXCEPT + { + size_type __size = this->size(); + if (__size) + { + if (--__size > __pos) + __size = __pos; + do + { + if (!traits_type::eq(_M_data()[__size], __c)) + return __size; + } + while (__size--); + } + return npos; + } + + template + int + basic_string<_CharT, _Traits, _Alloc>:: + compare(size_type __pos, size_type __n, const basic_string& __str) const + { + _M_check(__pos, "basic_string::compare"); + __n = _M_limit(__pos, __n); + const size_type __osize = __str.size(); + const size_type __len = std::min(__n, __osize); + int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len); + if (!__r) + __r = _S_compare(__n, __osize); + return __r; + } + + template + int + basic_string<_CharT, _Traits, _Alloc>:: + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2) const + { + _M_check(__pos1, "basic_string::compare"); + __str._M_check(__pos2, "basic_string::compare"); + __n1 = _M_limit(__pos1, __n1); + __n2 = __str._M_limit(__pos2, __n2); + const size_type __len = std::min(__n1, __n2); + int __r = traits_type::compare(_M_data() + __pos1, + __str.data() + __pos2, __len); + if (!__r) + __r = _S_compare(__n1, __n2); + return __r; + } + + template + int + basic_string<_CharT, _Traits, _Alloc>:: + compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_string(__s); + const size_type __size = this->size(); + const size_type __osize = traits_type::length(__s); + const size_type __len = std::min(__size, __osize); + int __r = traits_type::compare(_M_data(), __s, __len); + if (!__r) + __r = _S_compare(__size, __osize); + return __r; + } + + template + int + basic_string <_CharT, _Traits, _Alloc>:: + compare(size_type __pos, size_type __n1, const _CharT* __s) const + { + __glibcxx_requires_string(__s); + _M_check(__pos, "basic_string::compare"); + __n1 = _M_limit(__pos, __n1); + const size_type __osize = traits_type::length(__s); + const size_type __len = std::min(__n1, __osize); + int __r = traits_type::compare(_M_data() + __pos, __s, __len); + if (!__r) + __r = _S_compare(__n1, __osize); + return __r; + } + + template + int + basic_string <_CharT, _Traits, _Alloc>:: + compare(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) const + { + __glibcxx_requires_string_len(__s, __n2); + _M_check(__pos, "basic_string::compare"); + __n1 = _M_limit(__pos, __n1); + const size_type __len = std::min(__n1, __n2); + int __r = traits_type::compare(_M_data() + __pos, __s, __len); + if (!__r) + __r = _S_compare(__n1, __n2); + return __r; + } + + // 21.3.7.9 basic_string::getline and operators + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, + basic_string<_CharT, _Traits, _Alloc>& __str) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __istream_type::ios_base __ios_base; + typedef typename __istream_type::int_type __int_type; + typedef typename __string_type::size_type __size_type; + typedef ctype<_CharT> __ctype_type; + typedef typename __ctype_type::ctype_base __ctype_base; + + __size_type __extracted = 0; + typename __ios_base::iostate __err = __ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + __try + { + // Avoid reallocation for common case. + __str.erase(); + _CharT __buf[128]; + __size_type __len = 0; + const streamsize __w = __in.width(); + const __size_type __n = __w > 0 ? static_cast<__size_type>(__w) + : __str.max_size(); + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + const __int_type __eof = _Traits::eof(); + __int_type __c = __in.rdbuf()->sgetc(); + + while (__extracted < __n + && !_Traits::eq_int_type(__c, __eof) + && !__ct.is(__ctype_base::space, + _Traits::to_char_type(__c))) + { + if (__len == sizeof(__buf) / sizeof(_CharT)) + { + __str.append(__buf, sizeof(__buf) / sizeof(_CharT)); + __len = 0; + } + __buf[__len++] = _Traits::to_char_type(__c); + ++__extracted; + __c = __in.rdbuf()->snextc(); + } + __str.append(__buf, __len); + + if (__extracted < __n && _Traits::eq_int_type(__c, __eof)) + __err |= __ios_base::eofbit; + __in.width(0); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 91. Description of operator>> and getline() for string<> + // might cause endless loop + __in._M_setstate(__ios_base::badbit); + } + } + // 211. operator>>(istream&, string&) doesn't set failbit + if (!__extracted) + __err |= __ios_base::failbit; + if (__err) + __in.setstate(__err); + return __in; + } + + template + basic_istream<_CharT, _Traits>& + getline(basic_istream<_CharT, _Traits>& __in, + basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; + typedef typename __istream_type::ios_base __ios_base; + typedef typename __istream_type::int_type __int_type; + typedef typename __string_type::size_type __size_type; + + __size_type __extracted = 0; + const __size_type __n = __str.max_size(); + typename __ios_base::iostate __err = __ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, true); + if (__cerb) + { + __try + { + __str.erase(); + const __int_type __idelim = _Traits::to_int_type(__delim); + const __int_type __eof = _Traits::eof(); + __int_type __c = __in.rdbuf()->sgetc(); + + while (__extracted < __n + && !_Traits::eq_int_type(__c, __eof) + && !_Traits::eq_int_type(__c, __idelim)) + { + __str += _Traits::to_char_type(__c); + ++__extracted; + __c = __in.rdbuf()->snextc(); + } + + if (_Traits::eq_int_type(__c, __eof)) + __err |= __ios_base::eofbit; + else if (_Traits::eq_int_type(__c, __idelim)) + { + ++__extracted; + __in.rdbuf()->sbumpc(); + } + else + __err |= __ios_base::failbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 91. Description of operator>> and getline() for string<> + // might cause endless loop + __in._M_setstate(__ios_base::badbit); + } + } + if (!__extracted) + __err |= __ios_base::failbit; + if (__err) + __in.setstate(__err); + return __in; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + // The explicit instantiation definitions in src/c++11/string-inst.cc and + // src/c++17/string-inst.cc only instantiate the members required for C++17 + // and earlier standards (so not C++20's starts_with and ends_with). + // Suppress the explicit instantiation declarations for C++20, so C++20 + // code will implicitly instantiate std::string and std::wstring as needed. +# if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0 + extern template class basic_string; +# elif ! _GLIBCXX_USE_CXX11_ABI + // Still need to prevent implicit instantiation of the COW empty rep, + // to ensure the definition in libstdc++.so is unique (PR 86138). + extern template basic_string::size_type + basic_string::_Rep::_S_empty_rep_storage[]; +# endif + + extern template + basic_istream& + operator>>(basic_istream&, string&); + extern template + basic_ostream& + operator<<(basic_ostream&, const string&); + extern template + basic_istream& + getline(basic_istream&, string&, char); + extern template + basic_istream& + getline(basic_istream&, string&); + +#ifdef _GLIBCXX_USE_WCHAR_T +# if __cplusplus <= 201703L && _GLIBCXX_EXTERN_TEMPLATE > 0 + extern template class basic_string; +# elif ! _GLIBCXX_USE_CXX11_ABI + extern template basic_string::size_type + basic_string::_Rep::_S_empty_rep_storage[]; +# endif + + extern template + basic_istream& + operator>>(basic_istream&, wstring&); + extern template + basic_ostream& + operator<<(basic_ostream&, const wstring&); + extern template + basic_istream& + getline(basic_istream&, wstring&, wchar_t); + extern template + basic_istream& + getline(basic_istream&, wstring&); +#endif // _GLIBCXX_USE_WCHAR_T +#endif // _GLIBCXX_EXTERN_TEMPLATE + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/boost_concept_check.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/boost_concept_check.h new file mode 100755 index 0000000..5c87e32 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/boost_concept_check.h @@ -0,0 +1,794 @@ +// -*- C++ -*- + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +// + +/** @file bits/boost_concept_check.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +// GCC Note: based on version 1.12.0 of the Boost library. + +#ifndef _BOOST_CONCEPT_CHECK_H +#define _BOOST_CONCEPT_CHECK_H 1 + +#pragma GCC system_header + +#include +#include // for traits and tags + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-local-typedefs" + +#define _IsUnused __attribute__ ((__unused__)) + +// When the C-C code is in use, we would like this function to do as little +// as possible at runtime, use as few resources as possible, and hopefully +// be elided out of existence... hmmm. +template +_GLIBCXX14_CONSTEXPR inline void __function_requires() +{ + void (_Concept::*__x)() _IsUnused = &_Concept::__constraints; +} + +// No definition: if this is referenced, there's a problem with +// the instantiating type not being one of the required integer types. +// Unfortunately, this results in a link-time error, not a compile-time error. +void __error_type_must_be_an_integer_type(); +void __error_type_must_be_an_unsigned_integer_type(); +void __error_type_must_be_a_signed_integer_type(); + +// ??? Should the "concept_checking*" structs begin with more than _ ? +#define _GLIBCXX_CLASS_REQUIRES(_type_var, _ns, _concept) \ + typedef void (_ns::_concept <_type_var>::* _func##_type_var##_concept)(); \ + template <_func##_type_var##_concept _Tp1> \ + struct _concept_checking##_type_var##_concept { }; \ + typedef _concept_checking##_type_var##_concept< \ + &_ns::_concept <_type_var>::__constraints> \ + _concept_checking_typedef##_type_var##_concept + +#define _GLIBCXX_CLASS_REQUIRES2(_type_var1, _type_var2, _ns, _concept) \ + typedef void (_ns::_concept <_type_var1,_type_var2>::* _func##_type_var1##_type_var2##_concept)(); \ + template <_func##_type_var1##_type_var2##_concept _Tp1> \ + struct _concept_checking##_type_var1##_type_var2##_concept { }; \ + typedef _concept_checking##_type_var1##_type_var2##_concept< \ + &_ns::_concept <_type_var1,_type_var2>::__constraints> \ + _concept_checking_typedef##_type_var1##_type_var2##_concept + +#define _GLIBCXX_CLASS_REQUIRES3(_type_var1, _type_var2, _type_var3, _ns, _concept) \ + typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3>::* _func##_type_var1##_type_var2##_type_var3##_concept)(); \ + template <_func##_type_var1##_type_var2##_type_var3##_concept _Tp1> \ + struct _concept_checking##_type_var1##_type_var2##_type_var3##_concept { }; \ + typedef _concept_checking##_type_var1##_type_var2##_type_var3##_concept< \ + &_ns::_concept <_type_var1,_type_var2,_type_var3>::__constraints> \ + _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_concept + +#define _GLIBCXX_CLASS_REQUIRES4(_type_var1, _type_var2, _type_var3, _type_var4, _ns, _concept) \ + typedef void (_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::* _func##_type_var1##_type_var2##_type_var3##_type_var4##_concept)(); \ + template <_func##_type_var1##_type_var2##_type_var3##_type_var4##_concept _Tp1> \ + struct _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept { }; \ + typedef _concept_checking##_type_var1##_type_var2##_type_var3##_type_var4##_concept< \ + &_ns::_concept <_type_var1,_type_var2,_type_var3,_type_var4>::__constraints> \ + _concept_checking_typedef##_type_var1##_type_var2##_type_var3##_type_var4##_concept + + +template +struct _Aux_require_same { }; + +template +struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; }; + + template + struct _SameTypeConcept + { + void __constraints() { + typedef typename _Aux_require_same<_Tp1, _Tp2>::_Type _Required; + } + }; + + template + struct _IntegerConcept { + void __constraints() { + __error_type_must_be_an_integer_type(); + } + }; + template <> struct _IntegerConcept { void __constraints() {} }; + template <> struct _IntegerConcept { void __constraints(){} }; + template <> struct _IntegerConcept { void __constraints() {} }; + template <> struct _IntegerConcept { void __constraints() {} }; + template <> struct _IntegerConcept { void __constraints() {} }; + template <> struct _IntegerConcept { void __constraints() {} }; + template <> struct _IntegerConcept { void __constraints() {} }; + template <> struct _IntegerConcept + { void __constraints() {} }; + + template + struct _SignedIntegerConcept { + void __constraints() { + __error_type_must_be_a_signed_integer_type(); + } + }; + template <> struct _SignedIntegerConcept { void __constraints() {} }; + template <> struct _SignedIntegerConcept { void __constraints() {} }; + template <> struct _SignedIntegerConcept { void __constraints() {} }; + template <> struct _SignedIntegerConcept { void __constraints(){}}; + + template + struct _UnsignedIntegerConcept { + void __constraints() { + __error_type_must_be_an_unsigned_integer_type(); + } + }; + template <> struct _UnsignedIntegerConcept + { void __constraints() {} }; + template <> struct _UnsignedIntegerConcept + { void __constraints() {} }; + template <> struct _UnsignedIntegerConcept + { void __constraints() {} }; + template <> struct _UnsignedIntegerConcept + { void __constraints() {} }; + + //=========================================================================== + // Basic Concepts + + template + struct _DefaultConstructibleConcept + { + void __constraints() { + _Tp __a _IsUnused; // require default constructor + } + }; + + template + struct _AssignableConcept + { + void __constraints() { + __a = __a; // require assignment operator + __const_constraints(__a); + } + void __const_constraints(const _Tp& __b) { + __a = __b; // const required for argument to assignment + } + _Tp __a; + // possibly should be "Tp* a;" and then dereference "a" in constraint + // functions? present way would require a default ctor, i think... + }; + + template + struct _CopyConstructibleConcept + { + void __constraints() { + _Tp __a(__b); // require copy constructor + _Tp* __ptr _IsUnused = &__a; // require address of operator + __const_constraints(__a); + } + void __const_constraints(const _Tp& __a) { + _Tp __c _IsUnused(__a); // require const copy constructor + const _Tp* __ptr _IsUnused = &__a; // require const address of operator + } + _Tp __b; + }; + + // The SGI STL version of Assignable requires copy constructor and operator= + template + struct _SGIAssignableConcept + { + void __constraints() { + _Tp __b _IsUnused(__a); + __a = __a; // require assignment operator + __const_constraints(__a); + } + void __const_constraints(const _Tp& __b) { + _Tp __c _IsUnused(__b); + __a = __b; // const required for argument to assignment + } + _Tp __a; + }; + + template + struct _ConvertibleConcept + { + void __constraints() { + _To __y _IsUnused = __x; + } + _From __x; + }; + + // The C++ standard requirements for many concepts talk about return + // types that must be "convertible to bool". The problem with this + // requirement is that it leaves the door open for evil proxies that + // define things like operator|| with strange return types. Two + // possible solutions are: + // 1) require the return type to be exactly bool + // 2) stay with convertible to bool, and also + // specify stuff about all the logical operators. + // For now we just test for convertible to bool. + template + void __aux_require_boolean_expr(const _Tp& __t) { + bool __x _IsUnused = __t; + } + +// FIXME + template + struct _EqualityComparableConcept + { + void __constraints() { + __aux_require_boolean_expr(__a == __b); + } + _Tp __a, __b; + }; + + template + struct _LessThanComparableConcept + { + void __constraints() { + __aux_require_boolean_expr(__a < __b); + } + _Tp __a, __b; + }; + + // This is equivalent to SGI STL's LessThanComparable. + template + struct _ComparableConcept + { + void __constraints() { + __aux_require_boolean_expr(__a < __b); + __aux_require_boolean_expr(__a > __b); + __aux_require_boolean_expr(__a <= __b); + __aux_require_boolean_expr(__a >= __b); + } + _Tp __a, __b; + }; + +#define _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(_OP,_NAME) \ + template \ + struct _NAME { \ + void __constraints() { (void)__constraints_(); } \ + bool __constraints_() { \ + return __a _OP __b; \ + } \ + _First __a; \ + _Second __b; \ + } + +#define _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(_OP,_NAME) \ + template \ + struct _NAME { \ + void __constraints() { (void)__constraints_(); } \ + _Ret __constraints_() { \ + return __a _OP __b; \ + } \ + _First __a; \ + _Second __b; \ + } + + _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(==, _EqualOpConcept); + _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(!=, _NotEqualOpConcept); + _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<, _LessThanOpConcept); + _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(<=, _LessEqualOpConcept); + _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>, _GreaterThanOpConcept); + _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT(>=, _GreaterEqualOpConcept); + + _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(+, _PlusOpConcept); + _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(*, _TimesOpConcept); + _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(/, _DivideOpConcept); + _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(-, _SubtractOpConcept); + _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT(%, _ModOpConcept); + +#undef _GLIBCXX_DEFINE_BINARY_PREDICATE_OP_CONSTRAINT +#undef _GLIBCXX_DEFINE_BINARY_OPERATOR_CONSTRAINT + + //=========================================================================== + // Function Object Concepts + + template + struct _GeneratorConcept + { + void __constraints() { + const _Return& __r _IsUnused = __f();// require operator() member function + } + _Func __f; + }; + + + template + struct _GeneratorConcept<_Func,void> + { + void __constraints() { + __f(); // require operator() member function + } + _Func __f; + }; + + template + struct _UnaryFunctionConcept + { + void __constraints() { + __r = __f(__arg); // require operator() + } + _Func __f; + _Arg __arg; + _Return __r; + }; + + template + struct _UnaryFunctionConcept<_Func, void, _Arg> { + void __constraints() { + __f(__arg); // require operator() + } + _Func __f; + _Arg __arg; + }; + + template + struct _BinaryFunctionConcept + { + void __constraints() { + __r = __f(__first, __second); // require operator() + } + _Func __f; + _First __first; + _Second __second; + _Return __r; + }; + + template + struct _BinaryFunctionConcept<_Func, void, _First, _Second> + { + void __constraints() { + __f(__first, __second); // require operator() + } + _Func __f; + _First __first; + _Second __second; + }; + + template + struct _UnaryPredicateConcept + { + void __constraints() { + __aux_require_boolean_expr(__f(__arg)); // require op() returning bool + } + _Func __f; + _Arg __arg; + }; + + template + struct _BinaryPredicateConcept + { + void __constraints() { + __aux_require_boolean_expr(__f(__a, __b)); // require op() returning bool + } + _Func __f; + _First __a; + _Second __b; + }; + + // use this when functor is used inside a container class like std::set + template + struct _Const_BinaryPredicateConcept { + void __constraints() { + __const_constraints(__f); + } + void __const_constraints(const _Func& __fun) { + __function_requires<_BinaryPredicateConcept<_Func, _First, _Second> >(); + // operator() must be a const member function + __aux_require_boolean_expr(__fun(__a, __b)); + } + _Func __f; + _First __a; + _Second __b; + }; + + //=========================================================================== + // Iterator Concepts + + template + struct _TrivialIteratorConcept + { + void __constraints() { +// __function_requires< _DefaultConstructibleConcept<_Tp> >(); + __function_requires< _AssignableConcept<_Tp> >(); + __function_requires< _EqualityComparableConcept<_Tp> >(); +// typedef typename std::iterator_traits<_Tp>::value_type _V; + (void)*__i; // require dereference operator + } + _Tp __i; + }; + + template + struct _Mutable_TrivialIteratorConcept + { + void __constraints() { + __function_requires< _TrivialIteratorConcept<_Tp> >(); + *__i = *__j; // require dereference and assignment + } + _Tp __i, __j; + }; + + template + struct _InputIteratorConcept + { + void __constraints() { + __function_requires< _TrivialIteratorConcept<_Tp> >(); + // require iterator_traits typedef's + typedef typename std::iterator_traits<_Tp>::difference_type _Diff; +// __function_requires< _SignedIntegerConcept<_Diff> >(); + typedef typename std::iterator_traits<_Tp>::reference _Ref; + typedef typename std::iterator_traits<_Tp>::pointer _Pt; + typedef typename std::iterator_traits<_Tp>::iterator_category _Cat; + __function_requires< _ConvertibleConcept< + typename std::iterator_traits<_Tp>::iterator_category, + std::input_iterator_tag> >(); + ++__i; // require preincrement operator + __i++; // require postincrement operator + } + _Tp __i; + }; + + template + struct _OutputIteratorConcept + { + void __constraints() { + __function_requires< _AssignableConcept<_Tp> >(); + ++__i; // require preincrement operator + __i++; // require postincrement operator + *__i++ = __t; // require postincrement and assignment + } + _Tp __i; + _ValueT __t; + }; + + template + struct _ForwardIteratorConcept + { + void __constraints() { + __function_requires< _InputIteratorConcept<_Tp> >(); + __function_requires< _DefaultConstructibleConcept<_Tp> >(); + __function_requires< _ConvertibleConcept< + typename std::iterator_traits<_Tp>::iterator_category, + std::forward_iterator_tag> >(); + typedef typename std::iterator_traits<_Tp>::reference _Ref; + _Ref __r _IsUnused = *__i; + } + _Tp __i; + }; + + template + struct _Mutable_ForwardIteratorConcept + { + void __constraints() { + __function_requires< _ForwardIteratorConcept<_Tp> >(); + *__i++ = *__i; // require postincrement and assignment + } + _Tp __i; + }; + + template + struct _BidirectionalIteratorConcept + { + void __constraints() { + __function_requires< _ForwardIteratorConcept<_Tp> >(); + __function_requires< _ConvertibleConcept< + typename std::iterator_traits<_Tp>::iterator_category, + std::bidirectional_iterator_tag> >(); + --__i; // require predecrement operator + __i--; // require postdecrement operator + } + _Tp __i; + }; + + template + struct _Mutable_BidirectionalIteratorConcept + { + void __constraints() { + __function_requires< _BidirectionalIteratorConcept<_Tp> >(); + __function_requires< _Mutable_ForwardIteratorConcept<_Tp> >(); + *__i-- = *__i; // require postdecrement and assignment + } + _Tp __i; + }; + + + template + struct _RandomAccessIteratorConcept + { + void __constraints() { + __function_requires< _BidirectionalIteratorConcept<_Tp> >(); + __function_requires< _ComparableConcept<_Tp> >(); + __function_requires< _ConvertibleConcept< + typename std::iterator_traits<_Tp>::iterator_category, + std::random_access_iterator_tag> >(); + // ??? We don't use _Ref, are we just checking for "referenceability"? + typedef typename std::iterator_traits<_Tp>::reference _Ref; + + __i += __n; // require assignment addition operator + __i = __i + __n; __i = __n + __i; // require addition with difference type + __i -= __n; // require assignment subtraction op + __i = __i - __n; // require subtraction with + // difference type + __n = __i - __j; // require difference operator + (void)__i[__n]; // require element access operator + } + _Tp __a, __b; + _Tp __i, __j; + typename std::iterator_traits<_Tp>::difference_type __n; + }; + + template + struct _Mutable_RandomAccessIteratorConcept + { + void __constraints() { + __function_requires< _RandomAccessIteratorConcept<_Tp> >(); + __function_requires< _Mutable_BidirectionalIteratorConcept<_Tp> >(); + __i[__n] = *__i; // require element access and assignment + } + _Tp __i; + typename std::iterator_traits<_Tp>::difference_type __n; + }; + + //=========================================================================== + // Container Concepts + + template + struct _ContainerConcept + { + typedef typename _Container::value_type _Value_type; + typedef typename _Container::difference_type _Difference_type; + typedef typename _Container::size_type _Size_type; + typedef typename _Container::const_reference _Const_reference; + typedef typename _Container::const_pointer _Const_pointer; + typedef typename _Container::const_iterator _Const_iterator; + + void __constraints() { + __function_requires< _InputIteratorConcept<_Const_iterator> >(); + __function_requires< _AssignableConcept<_Container> >(); + const _Container __c; + __i = __c.begin(); + __i = __c.end(); + __n = __c.size(); + __n = __c.max_size(); + __b = __c.empty(); + } + bool __b; + _Const_iterator __i; + _Size_type __n; + }; + + template + struct _Mutable_ContainerConcept + { + typedef typename _Container::value_type _Value_type; + typedef typename _Container::reference _Reference; + typedef typename _Container::iterator _Iterator; + typedef typename _Container::pointer _Pointer; + + void __constraints() { + __function_requires< _ContainerConcept<_Container> >(); + __function_requires< _AssignableConcept<_Value_type> >(); + __function_requires< _InputIteratorConcept<_Iterator> >(); + + __i = __c.begin(); + __i = __c.end(); + __c.swap(__c2); + } + _Iterator __i; + _Container __c, __c2; + }; + + template + struct _ForwardContainerConcept + { + void __constraints() { + __function_requires< _ContainerConcept<_ForwardContainer> >(); + typedef typename _ForwardContainer::const_iterator _Const_iterator; + __function_requires< _ForwardIteratorConcept<_Const_iterator> >(); + } + }; + + template + struct _Mutable_ForwardContainerConcept + { + void __constraints() { + __function_requires< _ForwardContainerConcept<_ForwardContainer> >(); + __function_requires< _Mutable_ContainerConcept<_ForwardContainer> >(); + typedef typename _ForwardContainer::iterator _Iterator; + __function_requires< _Mutable_ForwardIteratorConcept<_Iterator> >(); + } + }; + + template + struct _ReversibleContainerConcept + { + typedef typename _ReversibleContainer::const_iterator _Const_iterator; + typedef typename _ReversibleContainer::const_reverse_iterator + _Const_reverse_iterator; + + void __constraints() { + __function_requires< _ForwardContainerConcept<_ReversibleContainer> >(); + __function_requires< _BidirectionalIteratorConcept<_Const_iterator> >(); + __function_requires< + _BidirectionalIteratorConcept<_Const_reverse_iterator> >(); + + const _ReversibleContainer __c; + _Const_reverse_iterator __i = __c.rbegin(); + __i = __c.rend(); + } + }; + + template + struct _Mutable_ReversibleContainerConcept + { + typedef typename _ReversibleContainer::iterator _Iterator; + typedef typename _ReversibleContainer::reverse_iterator _Reverse_iterator; + + void __constraints() { + __function_requires<_ReversibleContainerConcept<_ReversibleContainer> >(); + __function_requires< + _Mutable_ForwardContainerConcept<_ReversibleContainer> >(); + __function_requires<_Mutable_BidirectionalIteratorConcept<_Iterator> >(); + __function_requires< + _Mutable_BidirectionalIteratorConcept<_Reverse_iterator> >(); + + _Reverse_iterator __i = __c.rbegin(); + __i = __c.rend(); + } + _ReversibleContainer __c; + }; + + template + struct _RandomAccessContainerConcept + { + typedef typename _RandomAccessContainer::size_type _Size_type; + typedef typename _RandomAccessContainer::const_reference _Const_reference; + typedef typename _RandomAccessContainer::const_iterator _Const_iterator; + typedef typename _RandomAccessContainer::const_reverse_iterator + _Const_reverse_iterator; + + void __constraints() { + __function_requires< + _ReversibleContainerConcept<_RandomAccessContainer> >(); + __function_requires< _RandomAccessIteratorConcept<_Const_iterator> >(); + __function_requires< + _RandomAccessIteratorConcept<_Const_reverse_iterator> >(); + + const _RandomAccessContainer __c; + _Const_reference __r _IsUnused = __c[__n]; + } + _Size_type __n; + }; + + template + struct _Mutable_RandomAccessContainerConcept + { + typedef typename _RandomAccessContainer::size_type _Size_type; + typedef typename _RandomAccessContainer::reference _Reference; + typedef typename _RandomAccessContainer::iterator _Iterator; + typedef typename _RandomAccessContainer::reverse_iterator _Reverse_iterator; + + void __constraints() { + __function_requires< + _RandomAccessContainerConcept<_RandomAccessContainer> >(); + __function_requires< + _Mutable_ReversibleContainerConcept<_RandomAccessContainer> >(); + __function_requires< _Mutable_RandomAccessIteratorConcept<_Iterator> >(); + __function_requires< + _Mutable_RandomAccessIteratorConcept<_Reverse_iterator> >(); + + _Reference __r _IsUnused = __c[__i]; + } + _Size_type __i; + _RandomAccessContainer __c; + }; + + // A Sequence is inherently mutable + template + struct _SequenceConcept + { + typedef typename _Sequence::reference _Reference; + typedef typename _Sequence::const_reference _Const_reference; + + void __constraints() { + // Matt Austern's book puts DefaultConstructible here, the C++ + // standard places it in Container + // function_requires< DefaultConstructible >(); + __function_requires< _Mutable_ForwardContainerConcept<_Sequence> >(); + __function_requires< _DefaultConstructibleConcept<_Sequence> >(); + + _Sequence + __c _IsUnused(__n, __t), + __c2 _IsUnused(__first, __last); + + __c.insert(__p, __t); + __c.insert(__p, __n, __t); + __c.insert(__p, __first, __last); + + __c.erase(__p); + __c.erase(__p, __q); + + _Reference __r _IsUnused = __c.front(); + + __const_constraints(__c); + } + void __const_constraints(const _Sequence& __c) { + _Const_reference __r _IsUnused = __c.front(); + } + typename _Sequence::value_type __t; + typename _Sequence::size_type __n; + typename _Sequence::value_type *__first, *__last; + typename _Sequence::iterator __p, __q; + }; + + template + struct _FrontInsertionSequenceConcept + { + void __constraints() { + __function_requires< _SequenceConcept<_FrontInsertionSequence> >(); + + __c.push_front(__t); + __c.pop_front(); + } + _FrontInsertionSequence __c; + typename _FrontInsertionSequence::value_type __t; + }; + + template + struct _BackInsertionSequenceConcept + { + typedef typename _BackInsertionSequence::reference _Reference; + typedef typename _BackInsertionSequence::const_reference _Const_reference; + + void __constraints() { + __function_requires< _SequenceConcept<_BackInsertionSequence> >(); + + __c.push_back(__t); + __c.pop_back(); + _Reference __r _IsUnused = __c.back(); + } + void __const_constraints(const _BackInsertionSequence& __c) { + _Const_reference __r _IsUnused = __c.back(); + }; + _BackInsertionSequence __c; + typename _BackInsertionSequence::value_type __t; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#pragma GCC diagnostic pop +#undef _IsUnused + +#endif // _GLIBCXX_BOOST_CONCEPT_CHECK + + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/c++0x_warning.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/c++0x_warning.h new file mode 100755 index 0000000..22eeea1 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/c++0x_warning.h @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/c++0x_warning.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +#ifndef _CXX0X_WARNING_H +#define _CXX0X_WARNING_H 1 + +#if __cplusplus < 201103L +#error This file requires compiler and library support \ +for the ISO C++ 2011 standard. This support must be enabled \ +with the -std=c++11 or -std=gnu++11 compiler options. +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/char_traits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/char_traits.h new file mode 100755 index 0000000..c143d74 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/char_traits.h @@ -0,0 +1,957 @@ +// Character Traits for use by standard string and iostream -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/char_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _CHAR_TRAITS_H +#define _CHAR_TRAITS_H 1 + +#pragma GCC system_header + +#include // std::copy, std::fill_n +#include // For streampos +#include // For WEOF, wmemmove, wmemset, etc. +#if __cplusplus > 201703L +# include +#endif + +#ifndef _GLIBCXX_ALWAYS_INLINE +# define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +#endif + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Mapping from character type to associated types. + * + * @note This is an implementation class for the generic version + * of char_traits. It defines int_type, off_type, pos_type, and + * state_type. By default these are unsigned long, streamoff, + * streampos, and mbstate_t. Users who need a different set of + * types, but who don't need to change the definitions of any function + * defined in char_traits, can specialize __gnu_cxx::_Char_types + * while leaving __gnu_cxx::char_traits alone. */ + template + struct _Char_types + { + typedef unsigned long int_type; + typedef std::streampos pos_type; + typedef std::streamoff off_type; + typedef std::mbstate_t state_type; + }; + + + /** + * @brief Base class used to implement std::char_traits. + * + * @note For any given actual character type, this definition is + * probably wrong. (Most of the member functions are likely to be + * right, but the int_type and state_type typedefs, and the eof() + * member function, are likely to be wrong.) The reason this class + * exists is so users can specialize it. Classes in namespace std + * may not be specialized for fundamental types, but classes in + * namespace __gnu_cxx may be. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types + * for advice on how to make use of this class for @a unusual character + * types. Also, check out include/ext/pod_char_traits.h. + */ + template + struct char_traits + { + typedef _CharT char_type; + typedef typename _Char_types<_CharT>::int_type int_type; + typedef typename _Char_types<_CharT>::pos_type pos_type; + typedef typename _Char_types<_CharT>::off_type off_type; + typedef typename _Char_types<_CharT>::state_type state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = std::strong_ordering; +#endif + + static _GLIBCXX14_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static _GLIBCXX14_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, std::size_t __n); + + static _GLIBCXX14_CONSTEXPR std::size_t + length(const char_type* __s); + + static _GLIBCXX14_CONSTEXPR const char_type* + find(const char_type* __s, std::size_t __n, const char_type& __a); + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, std::size_t __n); + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, std::size_t __n); + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, std::size_t __n, char_type __a); + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) + { return static_cast(__c); } + + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) + { return static_cast(__c); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() + { return static_cast(_GLIBCXX_STDIO_EOF); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) + { return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); } + }; + + template + _GLIBCXX14_CONSTEXPR int + char_traits<_CharT>:: + compare(const char_type* __s1, const char_type* __s2, std::size_t __n) + { + for (std::size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } + + template + _GLIBCXX14_CONSTEXPR std::size_t + char_traits<_CharT>:: + length(const char_type* __p) + { + std::size_t __i = 0; + while (!eq(__p[__i], char_type())) + ++__i; + return __i; + } + + template + _GLIBCXX14_CONSTEXPR const typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + find(const char_type* __s, std::size_t __n, const char_type& __a) + { + for (std::size_t __i = 0; __i < __n; ++__i) + if (eq(__s[__i], __a)) + return __s + __i; + return 0; + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + move(char_type* __s1, const char_type* __s2, std::size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + if (__s1 > __s2 && __s1 < __s2 + __n) + std::copy_backward(__s2, __s2 + __n, __s1 + __n); + else + std::copy(__s2, __s2 + __n, __s1); + return __s1; + } +#endif + return static_cast<_CharT*>(__builtin_memmove(__s1, __s2, + __n * sizeof(char_type))); + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + copy(char_type* __s1, const char_type* __s2, std::size_t __n) + { + // NB: Inline std::copy so no recursive dependencies. + std::copy(__s2, __s2 + __n, __s1); + return __s1; + } + + template + _GLIBCXX20_CONSTEXPR + typename char_traits<_CharT>::char_type* + char_traits<_CharT>:: + assign(char_type* __s, std::size_t __n, char_type __a) + { + // NB: Inline std::fill_n so no recursive dependencies. + std::fill_n(__s, __n, __a); + return __s; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + +#ifdef __cpp_lib_is_constant_evaluated +// Unofficial macro indicating P1032R1 support in C++20 +# define __cpp_lib_constexpr_char_traits 201811L +#else +// Unofficial macro indicating P0426R1 support in C++17 +# define __cpp_lib_constexpr_char_traits 201611L +#endif + + /** + * @brief Determine whether the characters of a NULL-terminated + * string are known at compile time. + * @param __s The string. + * + * Assumes that _CharT is a built-in character type. + */ + template + _GLIBCXX_ALWAYS_INLINE constexpr bool + __constant_string_p(const _CharT* __s) + { +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + (void) __s; + // In constexpr contexts all strings should be constant. + return __builtin_is_constant_evaluated(); +#else + while (__builtin_constant_p(*__s) && *__s) + __s++; + return __builtin_constant_p(*__s); +#endif + } + + /** + * @brief Determine whether the characters of a character array are + * known at compile time. + * @param __a The character array. + * @param __n Number of characters. + * + * Assumes that _CharT is a built-in character type. + */ + template + _GLIBCXX_ALWAYS_INLINE constexpr bool + __constant_char_array_p(const _CharT* __a, size_t __n) + { +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + (void) __a; + (void) __n; + // In constexpr contexts all character arrays should be constant. + return __builtin_is_constant_evaluated(); +#else + size_t __i = 0; + while (__i < __n && __builtin_constant_p(__a[__i])) + __i++; + return __i == __n; +#endif + } +#endif + + // 21.1 + /** + * @brief Basis for explicit traits specializations. + * + * @note For any given actual character type, this definition is + * probably wrong. Since this is just a thin wrapper around + * __gnu_cxx::char_traits, it is possible to achieve a more + * appropriate definition by specializing __gnu_cxx::char_traits. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types + * for advice on how to make use of this class for @a unusual character + * types. Also, check out include/ext/pod_char_traits.h. + */ + template + struct char_traits : public __gnu_cxx::char_traits<_CharT> + { }; + + + /// 21.1.3.1 char_traits specializations + template<> + struct char_traits + { + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { __c1 = __c2; } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { + // LWG 467. + return (static_cast(__c1) + < static_cast(__c2)); + } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (__builtin_constant_p(__n) + && __constant_char_array_p(__s1, __n) + && __constant_char_array_p(__s2, __n)) + { + for (size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } +#endif + return __builtin_memcmp(__s1, __s2, __n); + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { +#if __cplusplus >= 201703L + if (__constant_string_p(__s)) + return __gnu_cxx::char_traits::length(__s); +#endif + return __builtin_strlen(__s); + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (__builtin_constant_p(__n) + && __builtin_constant_p(__a) + && __constant_char_array_p(__s, __n)) + return __gnu_cxx::char_traits::find(__s, __n, __a); +#endif + return static_cast(__builtin_memchr(__s, __a, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return static_cast(__builtin_memmove(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return static_cast(__builtin_memcpy(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + if (__n == 0) + return __s; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::assign(__s, __n, __a); +#endif + return static_cast(__builtin_memset(__s, __a, __n)); + } + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT + { return static_cast(__c); } + + // To keep both the byte 0xff and the eof symbol 0xffffffff + // from ending up as 0xffffffff. + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT + { return static_cast(static_cast(__c)); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() _GLIBCXX_NOEXCEPT + { return static_cast(_GLIBCXX_STDIO_EOF); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT + { return (__c == eof()) ? 0 : __c; } + }; + + +#ifdef _GLIBCXX_USE_WCHAR_T + /// 21.1.3.2 char_traits specializations + template<> + struct char_traits + { + typedef wchar_t char_type; + typedef wint_t int_type; + typedef streamoff off_type; + typedef wstreampos pos_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { __c1 = __c2; } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (__builtin_constant_p(__n) + && __constant_char_array_p(__s1, __n) + && __constant_char_array_p(__s2, __n)) + return __gnu_cxx::char_traits::compare(__s1, __s2, __n); +#endif + return wmemcmp(__s1, __s2, __n); + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { +#if __cplusplus >= 201703L + if (__constant_string_p(__s)) + return __gnu_cxx::char_traits::length(__s); +#endif + return wcslen(__s); + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + if (__n == 0) + return 0; +#if __cplusplus >= 201703L + if (__builtin_constant_p(__n) + && __builtin_constant_p(__a) + && __constant_char_array_p(__s, __n)) + return __gnu_cxx::char_traits::find(__s, __n, __a); +#endif + return wmemchr(__s, __a, __n); + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return wmemmove(__s1, __s2, __n); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return wmemcpy(__s1, __s2, __n); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + if (__n == 0) + return __s; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::assign(__s, __n, __a); +#endif + return wmemset(__s, __a, __n); + } + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT + { return char_type(__c); } + + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT + { return int_type(__c); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() _GLIBCXX_NOEXCEPT + { return static_cast(WEOF); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; +#endif //_GLIBCXX_USE_WCHAR_T + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct char_traits + { + typedef char8_t char_type; + typedef unsigned int int_type; + typedef u8streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { __c1 = __c2; } + + static _GLIBCXX_CONSTEXPR bool + eq(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR bool + lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return 0; +#if __cplusplus > 201402 + if (__builtin_constant_p(__n) + && __constant_char_array_p(__s1, __n) + && __constant_char_array_p(__s2, __n)) + return __gnu_cxx::char_traits::compare(__s1, __s2, __n); +#endif + return __builtin_memcmp(__s1, __s2, __n); + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { +#if __cplusplus > 201402 + if (__constant_string_p(__s)) + return __gnu_cxx::char_traits::length(__s); +#endif + size_t __i = 0; + while (!eq(__s[__i], char_type())) + ++__i; + return __i; + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + if (__n == 0) + return 0; +#if __cplusplus > 201402 + if (__builtin_constant_p(__n) + && __builtin_constant_p(__a) + && __constant_char_array_p(__s, __n)) + return __gnu_cxx::char_traits::find(__s, __n, __a); +#endif + return static_cast(__builtin_memchr(__s, __a, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return static_cast(__builtin_memmove(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return static_cast(__builtin_memcpy(__s1, __s2, __n)); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + if (__n == 0) + return __s; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::assign(__s, __n, __a); +#endif + return static_cast(__builtin_memset(__s, __a, __n)); + } + + static _GLIBCXX_CONSTEXPR char_type + to_char_type(const int_type& __c) _GLIBCXX_NOEXCEPT + { return char_type(__c); } + + static _GLIBCXX_CONSTEXPR int_type + to_int_type(const char_type& __c) _GLIBCXX_NOEXCEPT + { return int_type(__c); } + + static _GLIBCXX_CONSTEXPR bool + eq_int_type(const int_type& __c1, const int_type& __c2) _GLIBCXX_NOEXCEPT + { return __c1 == __c2; } + + static _GLIBCXX_CONSTEXPR int_type + eof() _GLIBCXX_NOEXCEPT + { return static_cast(-1); } + + static _GLIBCXX_CONSTEXPR int_type + not_eof(const int_type& __c) _GLIBCXX_NOEXCEPT + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; +#endif //_GLIBCXX_USE_CHAR8_T + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if __cplusplus >= 201103L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template<> + struct char_traits + { + typedef char16_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + typedef uint_least16_t int_type; +#elif defined __UINT_LEAST16_TYPE__ + typedef __UINT_LEAST16_TYPE__ int_type; +#else + typedef make_unsigned::type int_type; +#endif + typedef streamoff off_type; + typedef u16streampos pos_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) noexcept + { __c1 = __c2; } + + static constexpr bool + eq(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr bool + lt(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { + size_t __i = 0; + while (!eq(__s[__i], char_type())) + ++__i; + return __i; + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (size_t __i = 0; __i < __n; ++__i) + if (eq(__s[__i], __a)) + return __s + __i; + return 0; + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (size_t __i = 0; __i < __n; ++__i) + assign(__s[__i], __a); + return __s; + } + + static constexpr char_type + to_char_type(const int_type& __c) noexcept + { return char_type(__c); } + + static constexpr int_type + to_int_type(const char_type& __c) noexcept + { return __c == eof() ? int_type(0xfffd) : int_type(__c); } + + static constexpr bool + eq_int_type(const int_type& __c1, const int_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr int_type + eof() noexcept + { return static_cast(-1); } + + static constexpr int_type + not_eof(const int_type& __c) noexcept + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; + + template<> + struct char_traits + { + typedef char32_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + typedef uint_least32_t int_type; +#elif defined __UINT_LEAST32_TYPE__ + typedef __UINT_LEAST32_TYPE__ int_type; +#else + typedef make_unsigned::type int_type; +#endif + typedef streamoff off_type; + typedef u32streampos pos_type; + typedef mbstate_t state_type; +#if __cpp_lib_three_way_comparison + using comparison_category = strong_ordering; +#endif + + static _GLIBCXX17_CONSTEXPR void + assign(char_type& __c1, const char_type& __c2) noexcept + { __c1 = __c2; } + + static constexpr bool + eq(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr bool + lt(const char_type& __c1, const char_type& __c2) noexcept + { return __c1 < __c2; } + + static _GLIBCXX17_CONSTEXPR int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (lt(__s1[__i], __s2[__i])) + return -1; + else if (lt(__s2[__i], __s1[__i])) + return 1; + return 0; + } + + static _GLIBCXX17_CONSTEXPR size_t + length(const char_type* __s) + { + size_t __i = 0; + while (!eq(__s[__i], char_type())) + ++__i; + return __i; + } + + static _GLIBCXX17_CONSTEXPR const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (size_t __i = 0; __i < __n; ++__i) + if (eq(__s[__i], __a)) + return __s + __i; + return 0; + } + + static _GLIBCXX20_CONSTEXPR char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::move(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memmove(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { + if (__n == 0) + return __s1; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __gnu_cxx::char_traits::copy(__s1, __s2, __n); +#endif + return (static_cast + (__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)))); + } + + static _GLIBCXX20_CONSTEXPR char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (size_t __i = 0; __i < __n; ++__i) + assign(__s[__i], __a); + return __s; + } + + static constexpr char_type + to_char_type(const int_type& __c) noexcept + { return char_type(__c); } + + static constexpr int_type + to_int_type(const char_type& __c) noexcept + { return int_type(__c); } + + static constexpr bool + eq_int_type(const int_type& __c1, const int_type& __c2) noexcept + { return __c1 == __c2; } + + static constexpr int_type + eof() noexcept + { return static_cast(-1); } + + static constexpr int_type + not_eof(const int_type& __c) noexcept + { return eq_int_type(__c, eof()) ? 0 : __c; } + }; + +#if __cpp_lib_three_way_comparison + namespace __detail + { + template + constexpr auto + __char_traits_cmp_cat(int __cmp) noexcept + { + if constexpr (requires { typename _ChTraits::comparison_category; }) + { + using _Cat = typename _ChTraits::comparison_category; + static_assert( !is_void_v> ); + return static_cast<_Cat>(__cmp <=> 0); + } + else + return static_cast(__cmp <=> 0); + } + } // namespace __detail +#endif // C++20 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif // _CHAR_TRAITS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/charconv.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/charconv.h new file mode 100755 index 0000000..0d2e320 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/charconv.h @@ -0,0 +1,106 @@ +// Numeric conversions (to_string, to_chars) -*- C++ -*- + +// Copyright (C) 2017-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/charconv.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{charconv} + */ + +#ifndef _GLIBCXX_CHARCONV_H +#define _GLIBCXX_CHARCONV_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace __detail +{ + // Generic implementation for arbitrary bases. + template + _GLIBCXX14_CONSTEXPR unsigned + __to_chars_len(_Tp __value, int __base = 10) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + unsigned __n = 1; + const unsigned __b2 = __base * __base; + const unsigned __b3 = __b2 * __base; + const unsigned long __b4 = __b3 * __base; + for (;;) + { + if (__value < (unsigned)__base) return __n; + if (__value < __b2) return __n + 1; + if (__value < __b3) return __n + 2; + if (__value < __b4) return __n + 3; + __value /= __b4; + __n += 4; + } + } + + // Write an unsigned integer value to the range [first,first+len). + // The caller is required to provide a buffer of exactly the right size + // (which can be determined by the __to_chars_len function). + template + void + __to_chars_10_impl(char* __first, unsigned __len, _Tp __val) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + static constexpr char __digits[201] = + "0001020304050607080910111213141516171819" + "2021222324252627282930313233343536373839" + "4041424344454647484950515253545556575859" + "6061626364656667686970717273747576777879" + "8081828384858687888990919293949596979899"; + unsigned __pos = __len - 1; + while (__val >= 100) + { + auto const __num = (__val % 100) * 2; + __val /= 100; + __first[__pos] = __digits[__num + 1]; + __first[__pos - 1] = __digits[__num]; + __pos -= 2; + } + if (__val >= 10) + { + auto const __num = __val * 2; + __first[1] = __digits[__num + 1]; + __first[0] = __digits[__num]; + } + else + __first[0] = '0' + __val; + } + +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++11 +#endif // _GLIBCXX_CHARCONV_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/codecvt.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/codecvt.h new file mode 100755 index 0000000..85f92b1 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/codecvt.h @@ -0,0 +1,843 @@ +// Locale support (codecvt) -*- C++ -*- + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/codecvt.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.2.1.5 Template class codecvt +// + +// Written by Benjamin Kosnik + +#ifndef _CODECVT_H +#define _CODECVT_H 1 + +#pragma GCC system_header + +#include +#include // locale::facet + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Empty base class for codecvt facet [22.2.1.5]. + class codecvt_base + { + public: + enum result + { + ok, + partial, + error, + noconv + }; + }; + + /** + * @brief Common base for codecvt functions. + * + * This template class provides implementations of the public functions + * that forward to the protected virtual functions. + * + * This template also provides abstract stubs for the protected virtual + * functions. + */ + template + class __codecvt_abstract_base + : public locale::facet, public codecvt_base + { + public: + // Types: + typedef codecvt_base::result result; + typedef _InternT intern_type; + typedef _ExternT extern_type; + typedef _StateT state_type; + + // 22.2.1.5.1 codecvt members + /** + * @brief Convert from internal to external character set. + * + * Converts input string of intern_type to output string of + * extern_type. This is analogous to wcsrtombs. It does this by + * calling codecvt::do_out. + * + * The source and destination character sets are determined by the + * facet's locale, internal and external types. + * + * The characters in [from,from_end) are converted and written to + * [to,to_end). from_next and to_next are set to point to the + * character following the last successfully converted character, + * respectively. If the result needed no conversion, from_next and + * to_next are not affected. + * + * The @a state argument should be initialized if the input is at the + * beginning and carried from a previous call if continuing + * conversion. There are no guarantees about how @a state is used. + * + * The result returned is a member of codecvt_base::result. If + * all the input is converted, returns codecvt_base::ok. If no + * conversion is necessary, returns codecvt_base::noconv. If + * the input ends early or there is insufficient space in the + * output, returns codecvt_base::partial. Otherwise the + * conversion failed and codecvt_base::error is returned. + * + * @param __state Persistent conversion state data. + * @param __from Start of input. + * @param __from_end End of input. + * @param __from_next Returns start of unconverted data. + * @param __to Start of output buffer. + * @param __to_end End of output buffer. + * @param __to_next Returns start of unused output area. + * @return codecvt_base::result. + */ + result + out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const + { + return this->do_out(__state, __from, __from_end, __from_next, + __to, __to_end, __to_next); + } + + /** + * @brief Reset conversion state. + * + * Writes characters to output that would restore @a state to initial + * conditions. The idea is that if a partial conversion occurs, then + * the converting the characters written by this function would leave + * the state in initial conditions, rather than partial conversion + * state. It does this by calling codecvt::do_unshift(). + * + * For example, if 4 external characters always converted to 1 internal + * character, and input to in() had 6 external characters with state + * saved, this function would write two characters to the output and + * set the state to initialized conditions. + * + * The source and destination character sets are determined by the + * facet's locale, internal and external types. + * + * The result returned is a member of codecvt_base::result. If the + * state could be reset and data written, returns codecvt_base::ok. If + * no conversion is necessary, returns codecvt_base::noconv. If the + * output has insufficient space, returns codecvt_base::partial. + * Otherwise the reset failed and codecvt_base::error is returned. + * + * @param __state Persistent conversion state data. + * @param __to Start of output buffer. + * @param __to_end End of output buffer. + * @param __to_next Returns start of unused output area. + * @return codecvt_base::result. + */ + result + unshift(state_type& __state, extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const + { return this->do_unshift(__state, __to,__to_end,__to_next); } + + /** + * @brief Convert from external to internal character set. + * + * Converts input string of extern_type to output string of + * intern_type. This is analogous to mbsrtowcs. It does this by + * calling codecvt::do_in. + * + * The source and destination character sets are determined by the + * facet's locale, internal and external types. + * + * The characters in [from,from_end) are converted and written to + * [to,to_end). from_next and to_next are set to point to the + * character following the last successfully converted character, + * respectively. If the result needed no conversion, from_next and + * to_next are not affected. + * + * The @a state argument should be initialized if the input is at the + * beginning and carried from a previous call if continuing + * conversion. There are no guarantees about how @a state is used. + * + * The result returned is a member of codecvt_base::result. If + * all the input is converted, returns codecvt_base::ok. If no + * conversion is necessary, returns codecvt_base::noconv. If + * the input ends early or there is insufficient space in the + * output, returns codecvt_base::partial. Otherwise the + * conversion failed and codecvt_base::error is returned. + * + * @param __state Persistent conversion state data. + * @param __from Start of input. + * @param __from_end End of input. + * @param __from_next Returns start of unconverted data. + * @param __to Start of output buffer. + * @param __to_end End of output buffer. + * @param __to_next Returns start of unused output area. + * @return codecvt_base::result. + */ + result + in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const + { + return this->do_in(__state, __from, __from_end, __from_next, + __to, __to_end, __to_next); + } + + int + encoding() const throw() + { return this->do_encoding(); } + + bool + always_noconv() const throw() + { return this->do_always_noconv(); } + + int + length(state_type& __state, const extern_type* __from, + const extern_type* __end, size_t __max) const + { return this->do_length(__state, __from, __end, __max); } + + int + max_length() const throw() + { return this->do_max_length(); } + + protected: + explicit + __codecvt_abstract_base(size_t __refs = 0) : locale::facet(__refs) { } + + virtual + ~__codecvt_abstract_base() { } + + /** + * @brief Convert from internal to external character set. + * + * Converts input string of intern_type to output string of + * extern_type. This function is a hook for derived classes to change + * the value returned. @see out for more information. + */ + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const = 0; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const = 0; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const = 0; + + virtual int + do_encoding() const throw() = 0; + + virtual bool + do_always_noconv() const throw() = 0; + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const = 0; + + virtual int + do_max_length() const throw() = 0; + }; + + /** + * @brief Primary class template codecvt. + * @ingroup locales + * + * NB: Generic, mostly useless implementation. + * + */ + template + class codecvt + : public __codecvt_abstract_base<_InternT, _ExternT, _StateT> + { + public: + // Types: + typedef codecvt_base::result result; + typedef _InternT intern_type; + typedef _ExternT extern_type; + typedef _StateT state_type; + + protected: + __c_locale _M_c_locale_codecvt; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs), + _M_c_locale_codecvt(0) + { } + + explicit + codecvt(__c_locale __cloc, size_t __refs = 0); + + protected: + virtual + ~codecvt() { } + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual int + do_encoding() const throw(); + + virtual bool + do_always_noconv() const throw(); + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + template + locale::id codecvt<_InternT, _ExternT, _StateT>::id; + + /// class codecvt specialization. + template<> + class codecvt + : public __codecvt_abstract_base + { + friend class messages; + + public: + // Types: + typedef char intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + protected: + __c_locale _M_c_locale_codecvt; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0); + + explicit + codecvt(__c_locale __cloc, size_t __refs = 0); + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, extern_type* __to, + extern_type* __to_end, extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, const extern_type* __from, + const extern_type* __from_end, const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual int + do_encoding() const throw(); + + virtual bool + do_always_noconv() const throw(); + + virtual int + do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Class codecvt specialization. + * + * Converts between narrow and wide characters in the native character set + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + friend class messages; + + public: + // Types: + typedef wchar_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + protected: + __c_locale _M_c_locale_codecvt; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0); + + explicit + codecvt(__c_locale __cloc, size_t __refs = 0); + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; +#endif //_GLIBCXX_USE_WCHAR_T + +#if __cplusplus >= 201103L + /** @brief Class codecvt specialization. + * + * Converts between UTF-16 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char16_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + /** @brief Class codecvt specialization. + * + * Converts between UTF-32 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char32_t intern_type; + typedef char extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + +#ifdef _GLIBCXX_USE_CHAR8_T + /** @brief Class codecvt specialization. + * + * Converts between UTF-16 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char16_t intern_type; + typedef char8_t extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; + + /** @brief Class codecvt specialization. + * + * Converts between UTF-32 and UTF-8. + */ + template<> + class codecvt + : public __codecvt_abstract_base + { + public: + // Types: + typedef char32_t intern_type; + typedef char8_t extern_type; + typedef mbstate_t state_type; + + public: + static locale::id id; + + explicit + codecvt(size_t __refs = 0) + : __codecvt_abstract_base(__refs) { } + + protected: + virtual + ~codecvt(); + + virtual result + do_out(state_type& __state, const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_unshift(state_type& __state, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const; + + virtual result + do_in(state_type& __state, + const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const; + + virtual + int do_encoding() const throw(); + + virtual + bool do_always_noconv() const throw(); + + virtual + int do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const; + + virtual int + do_max_length() const throw(); + }; +#endif // _GLIBCXX_USE_CHAR8_T + +#endif // C++11 + + /// class codecvt_byname [22.2.1.6]. + template + class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> + { + public: + explicit + codecvt_byname(const char* __s, size_t __refs = 0) + : codecvt<_InternT, _ExternT, _StateT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_codecvt); + this->_S_create_c_locale(this->_M_c_locale_codecvt, __s); + } + } + +#if __cplusplus >= 201103L + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~codecvt_byname() { } + }; + +#if __cplusplus >= 201103L + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; + + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; + +#if defined(_GLIBCXX_USE_CHAR8_T) + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; + + template<> + class codecvt_byname + : public codecvt + { + public: + explicit + codecvt_byname(const char*, size_t __refs = 0) + : codecvt(__refs) { } + + explicit + codecvt_byname(const string& __s, size_t __refs = 0) + : codecvt_byname(__s.c_str(), __refs) { } + + protected: + virtual + ~codecvt_byname() { } + }; +#endif + +#endif // C++11 + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class codecvt_byname; + + extern template + const codecvt& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class codecvt_byname; + + extern template + const codecvt& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif + +#if __cplusplus >= 201103L + extern template class codecvt_byname; + extern template class codecvt_byname; + +#if defined(_GLIBCXX_USE_CHAR8_T) + extern template class codecvt_byname; + extern template class codecvt_byname; +#endif + +#endif + +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _CODECVT_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/concept_check.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/concept_check.h new file mode 100755 index 0000000..d0a443c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/concept_check.h @@ -0,0 +1,81 @@ +// Concept-checking control -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/concept_check.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _CONCEPT_CHECK_H +#define _CONCEPT_CHECK_H 1 + +#pragma GCC system_header + +#include + +// All places in libstdc++-v3 where these are used, or /might/ be used, or +// don't need to be used, or perhaps /should/ be used, are commented with +// "concept requirements" (and maybe some more text). So grep like crazy +// if you're looking for additional places to use these. + +// Concept-checking code is off by default unless users turn it on via +// configure options or editing c++config.h. +// It is not supported for freestanding implementations. + +#if !defined(_GLIBCXX_CONCEPT_CHECKS) || !_GLIBCXX_HOSTED + +#define __glibcxx_function_requires(...) +#define __glibcxx_class_requires(_a,_b) +#define __glibcxx_class_requires2(_a,_b,_c) +#define __glibcxx_class_requires3(_a,_b,_c,_d) +#define __glibcxx_class_requires4(_a,_b,_c,_d,_e) + +#else // the checks are on + +#include + +// Note that the obvious and elegant approach of +// +//#define glibcxx_function_requires(C) debug::function_requires< debug::C >() +// +// won't work due to concept templates with more than one parameter, e.g., +// BinaryPredicateConcept. The preprocessor tries to split things up on +// the commas in the template argument list. We can't use an inner pair of +// parenthesis to hide the commas, because "debug::(Temp)" isn't +// a valid instantiation pattern. Thus, we steal a feature from C99. + +#define __glibcxx_function_requires(...) \ + __gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >(); +#define __glibcxx_class_requires(_a,_C) \ + _GLIBCXX_CLASS_REQUIRES(_a, __gnu_cxx, _C); +#define __glibcxx_class_requires2(_a,_b,_C) \ + _GLIBCXX_CLASS_REQUIRES2(_a, _b, __gnu_cxx, _C); +#define __glibcxx_class_requires3(_a,_b,_c,_C) \ + _GLIBCXX_CLASS_REQUIRES3(_a, _b, _c, __gnu_cxx, _C); +#define __glibcxx_class_requires4(_a,_b,_c,_d,_C) \ + _GLIBCXX_CLASS_REQUIRES4(_a, _b, _c, _d, __gnu_cxx, _C); + +#endif // enable/disable + +#endif // _GLIBCXX_CONCEPT_CHECK diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cpp_type_traits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cpp_type_traits.h new file mode 100755 index 0000000..ca0d68c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cpp_type_traits.h @@ -0,0 +1,567 @@ +// The -*- C++ -*- type traits classes for internal use in libstdc++ + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cpp_type_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ext/type_traits} + */ + +// Written by Gabriel Dos Reis + +#ifndef _CPP_TYPE_TRAITS_H +#define _CPP_TYPE_TRAITS_H 1 + +#pragma GCC system_header + +#include + +// +// This file provides some compile-time information about various types. +// These representations were designed, on purpose, to be constant-expressions +// and not types as found in . In particular, they +// can be used in control structures and the optimizer hopefully will do +// the obvious thing. +// +// Why integral expressions, and not functions nor types? +// Firstly, these compile-time entities are used as template-arguments +// so function return values won't work: We need compile-time entities. +// We're left with types and constant integral expressions. +// Secondly, from the point of view of ease of use, type-based compile-time +// information is -not- *that* convenient. One has to write lots of +// overloaded functions and to hope that the compiler will select the right +// one. As a net effect, the overall structure isn't very clear at first +// glance. +// Thirdly, partial ordering and overload resolution (of function templates) +// is highly costly in terms of compiler-resource. It is a Good Thing to +// keep these resource consumption as least as possible. +// +// See valarray_array.h for a case use. +// +// -- Gaby (dosreis@cmla.ens-cachan.fr) 2000-03-06. +// +// Update 2005: types are also provided and has been +// removed. +// + +extern "C++" { + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct __true_type { }; + struct __false_type { }; + + template + struct __truth_type + { typedef __false_type __type; }; + + template<> + struct __truth_type + { typedef __true_type __type; }; + + // N.B. The conversions to bool are needed due to the issue + // explained in c++/19404. + template + struct __traitor + { + enum { __value = bool(_Sp::__value) || bool(_Tp::__value) }; + typedef typename __truth_type<__value>::__type __type; + }; + + // Compare for equality of types. + template + struct __are_same + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template + struct __are_same<_Tp, _Tp> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // Holds if the template-argument is a void type. + template + struct __is_void + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_void + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // Integer types + // + template + struct __is_integer + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + // Thirteen specializations (yes there are eleven standard integer + // types; long long and unsigned long long are + // supported as extensions). Up to four target-specific __int + // types are supported as well. + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +# ifdef __WCHAR_TYPE__ + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; +# endif + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + +#if __cplusplus >= 201103L + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_integer + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#define __INT_N(TYPE) \ + template<> \ + struct __is_integer \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; \ + template<> \ + struct __is_integer \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; + +#ifdef __GLIBCXX_TYPE_INT_N_0 +__INT_N(__GLIBCXX_TYPE_INT_N_0) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 +__INT_N(__GLIBCXX_TYPE_INT_N_1) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 +__INT_N(__GLIBCXX_TYPE_INT_N_2) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 +__INT_N(__GLIBCXX_TYPE_INT_N_3) +#endif + +#undef __INT_N + + // + // Floating point types + // + template + struct __is_floating + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + // three specializations (float, double and 'long double') + template<> + struct __is_floating + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_floating + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_floating + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // Pointer types + // + template + struct __is_pointer + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template + struct __is_pointer<_Tp*> + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + // + // An arithmetic type is an integer type or a floating point type + // + template + struct __is_arithmetic + : public __traitor<__is_integer<_Tp>, __is_floating<_Tp> > + { }; + + // + // A scalar type is an arithmetic type or a pointer type + // + template + struct __is_scalar + : public __traitor<__is_arithmetic<_Tp>, __is_pointer<_Tp> > + { }; + + // + // For use in std::copy and std::find overloads for streambuf iterators. + // + template + struct __is_char + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_char + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#ifdef __WCHAR_TYPE__ + template<> + struct __is_char + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template + struct __is_byte + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; + +#if __cplusplus >= 201703L + enum class byte : unsigned char; + + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif // C++17 + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + struct __is_byte + { + enum { __value = 1 }; + typedef __true_type __type; + }; +#endif + + template struct iterator_traits; + + // A type that is safe for use with memcpy, memmove, memcmp etc. + template + struct __is_nonvolatile_trivially_copyable + { + enum { __value = __is_trivially_copyable(_Tp) }; + }; + + // Cannot use memcpy/memmove/memcmp on volatile types even if they are + // trivially copyable, so ensure __memcpyable + // and similar will be false. + template + struct __is_nonvolatile_trivially_copyable + { + enum { __value = 0 }; + }; + + // Whether two iterator types can be used with memcpy/memmove. + template + struct __memcpyable + { + enum { __value = 0 }; + }; + + template + struct __memcpyable<_Tp*, _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + template + struct __memcpyable<_Tp*, const _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + // Whether two iterator types can be used with memcmp. + // This trait only says it's well-formed to use memcmp, not that it + // gives the right answer for a given algorithm. So for example, std::equal + // needs to add additional checks that the types are integers or pointers, + // because other trivially copyable types can overload operator==. + template + struct __memcmpable + { + enum { __value = 0 }; + }; + + // OK to use memcmp with pointers to trivially copyable types. + template + struct __memcmpable<_Tp*, _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + template + struct __memcmpable + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + template + struct __memcmpable<_Tp*, const _Tp*> + : __is_nonvolatile_trivially_copyable<_Tp> + { }; + + // Whether memcmp can be used to determine ordering for a type + // e.g. in std::lexicographical_compare or three-way comparisons. + // True for unsigned integer-like types where comparing each byte in turn + // as an unsigned char yields the right result. This is true for all + // unsigned integers on big endian targets, but only unsigned narrow + // character types (and std::byte) on little endian targets. + template::__value +#else + __is_byte<_Tp>::__value +#endif + > + struct __is_memcmp_ordered + { + static const bool __value = _Tp(-1) > _Tp(1); // is unsigned + }; + + template + struct __is_memcmp_ordered<_Tp, false> + { + static const bool __value = false; + }; + + // Whether two types can be compared using memcmp. + template + struct __is_memcmp_ordered_with + { + static const bool __value = __is_memcmp_ordered<_Tp>::__value + && __is_memcmp_ordered<_Up>::__value; + }; + + template + struct __is_memcmp_ordered_with<_Tp, _Up, false> + { + static const bool __value = false; + }; + +#if __cplusplus >= 201703L +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + // std::byte is not an integer, but it can be compared using memcmp. + template<> + struct __is_memcmp_ordered + { static constexpr bool __value = true; }; +#endif + + // std::byte can only be compared to itself, not to other types. + template<> + struct __is_memcmp_ordered_with + { static constexpr bool __value = true; }; + + template + struct __is_memcmp_ordered_with<_Tp, std::byte, _SameSize> + { static constexpr bool __value = false; }; + + template + struct __is_memcmp_ordered_with + { static constexpr bool __value = false; }; +#endif + + // + // Move iterator type + // + template + struct __is_move_iterator + { + enum { __value = 0 }; + typedef __false_type __type; + }; + + // Fallback implementation of the function in bits/stl_iterator.h used to + // remove the move_iterator wrapper. + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __miter_base(_Iterator __it) + { return __it; } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#endif //_CPP_TYPE_TRAITS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cxxabi_forced.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cxxabi_forced.h new file mode 100755 index 0000000..43996d5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cxxabi_forced.h @@ -0,0 +1,60 @@ +// cxxabi.h subset for cancellation -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cxxabi_forced.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cxxabi.h} + */ + +#ifndef _CXXABI_FORCED_H +#define _CXXABI_FORCED_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#ifdef __cplusplus +namespace __cxxabiv1 +{ + /** + * @brief Thrown as part of forced unwinding. + * @ingroup exceptions + * + * A magic placeholder class that can be caught by reference to + * recognize forced unwinding. + */ + class __forced_unwind + { + virtual ~__forced_unwind() throw(); + + // Prevent catch by value. + virtual void __pure_dummy() = 0; + }; +} +#endif // __cplusplus + +#pragma GCC visibility pop + +#endif // __CXXABI_FORCED_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cxxabi_init_exception.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cxxabi_init_exception.h new file mode 100755 index 0000000..b197849 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/cxxabi_init_exception.h @@ -0,0 +1,80 @@ +// ABI Support -*- C++ -*- + +// Copyright (C) 2016-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/cxxabi_init_exception.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _CXXABI_INIT_EXCEPTION_H +#define _CXXABI_INIT_EXCEPTION_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include +#include + +#ifndef _GLIBCXX_CDTOR_CALLABI +#define _GLIBCXX_CDTOR_CALLABI +#define _GLIBCXX_HAVE_CDTOR_CALLABI 0 +#else +#define _GLIBCXX_HAVE_CDTOR_CALLABI 1 +#endif + +#ifdef __cplusplus + +namespace std +{ + class type_info; +} + +namespace __cxxabiv1 +{ + struct __cxa_refcounted_exception; + + extern "C" + { + // Allocate memory for the primary exception plus the thrown object. + void* + __cxa_allocate_exception(size_t) _GLIBCXX_NOTHROW; + + void + __cxa_free_exception(void*) _GLIBCXX_NOTHROW; + + // Initialize exception (this is a GNU extension) + __cxa_refcounted_exception* + __cxa_init_primary_exception(void *object, std::type_info *tinfo, + void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) _GLIBCXX_NOTHROW; + + } +} // namespace __cxxabiv1 + +#endif + +#pragma GCC visibility pop + +#endif // _CXXABI_INIT_EXCEPTION_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/deque.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/deque.tcc new file mode 100755 index 0000000..db532e3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/deque.tcc @@ -0,0 +1,1366 @@ +// Deque implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/deque.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{deque} + */ + +#ifndef _DEQUE_TCC +#define _DEQUE_TCC 1 + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_default_initialize() + { + _Map_pointer __cur; + __try + { + for (__cur = this->_M_impl._M_start._M_node; + __cur < this->_M_impl._M_finish._M_node; + ++__cur) + std::__uninitialized_default_a(*__cur, *__cur + _S_buffer_size(), + _M_get_Tp_allocator()); + std::__uninitialized_default_a(this->_M_impl._M_finish._M_first, + this->_M_impl._M_finish._M_cur, + _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), + _M_get_Tp_allocator()); + __throw_exception_again; + } + } +#endif + + template + deque<_Tp, _Alloc>& + deque<_Tp, _Alloc>:: + operator=(const deque& __x) + { + if (&__x != this) + { +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + if (!_Alloc_traits::_S_always_equal() + && _M_get_Tp_allocator() != __x._M_get_Tp_allocator()) + { + // Replacement allocator cannot free existing storage, + // so deallocate everything and take copy of __x's data. + _M_replace_map(__x, __x.get_allocator()); + std::__alloc_on_copy(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + return *this; + } + std::__alloc_on_copy(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } +#endif + const size_type __len = size(); + if (__len >= __x.size()) + _M_erase_at_end(std::copy(__x.begin(), __x.end(), + this->_M_impl._M_start)); + else + { + const_iterator __mid = __x.begin() + difference_type(__len); + std::copy(__x.begin(), __mid, this->_M_impl._M_start); + _M_range_insert_aux(this->_M_impl._M_finish, __mid, __x.end(), + std::random_access_iterator_tag()); + } + } + return *this; + } + +#if __cplusplus >= 201103L + template + template +#if __cplusplus > 201402L + typename deque<_Tp, _Alloc>::reference +#else + void +#endif + deque<_Tp, _Alloc>:: + emplace_front(_Args&&... __args) + { + if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_start._M_cur - 1, + std::forward<_Args>(__args)...); + --this->_M_impl._M_start._M_cur; + } + else + _M_push_front_aux(std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return front(); +#endif + } + + template + template +#if __cplusplus > 201402L + typename deque<_Tp, _Alloc>::reference +#else + void +#endif + deque<_Tp, _Alloc>:: + emplace_back(_Args&&... __args) + { + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_last - 1) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_finish._M_cur, + std::forward<_Args>(__args)...); + ++this->_M_impl._M_finish._M_cur; + } + else + _M_push_back_aux(std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + +#if __cplusplus >= 201103L + template + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + emplace(const_iterator __position, _Args&&... __args) + { + if (__position._M_cur == this->_M_impl._M_start._M_cur) + { + emplace_front(std::forward<_Args>(__args)...); + return this->_M_impl._M_start; + } + else if (__position._M_cur == this->_M_impl._M_finish._M_cur) + { + emplace_back(std::forward<_Args>(__args)...); + iterator __tmp = this->_M_impl._M_finish; + --__tmp; + return __tmp; + } + else + return _M_insert_aux(__position._M_const_cast(), + std::forward<_Args>(__args)...); + } +#endif + + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + if (__position._M_cur == this->_M_impl._M_start._M_cur) + { + push_front(__x); + return this->_M_impl._M_start; + } + else if (__position._M_cur == this->_M_impl._M_finish._M_cur) + { + push_back(__x); + iterator __tmp = this->_M_impl._M_finish; + --__tmp; + return __tmp; + } + else + return _M_insert_aux(__position._M_const_cast(), __x); + } + + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_erase(iterator __position) + { + iterator __next = __position; + ++__next; + const difference_type __index = __position - begin(); + if (static_cast(__index) < (size() >> 1)) + { + if (__position != begin()) + _GLIBCXX_MOVE_BACKWARD3(begin(), __position, __next); + pop_front(); + } + else + { + if (__next != end()) + _GLIBCXX_MOVE3(__next, end(), __position); + pop_back(); + } + return begin() + __index; + } + + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_erase(iterator __first, iterator __last) + { + if (__first == __last) + return __first; + else if (__first == begin() && __last == end()) + { + clear(); + return end(); + } + else + { + const difference_type __n = __last - __first; + const difference_type __elems_before = __first - begin(); + if (static_cast(__elems_before) <= (size() - __n) / 2) + { + if (__first != begin()) + _GLIBCXX_MOVE_BACKWARD3(begin(), __first, __last); + _M_erase_at_begin(begin() + __n); + } + else + { + if (__last != end()) + _GLIBCXX_MOVE3(__last, end(), __first); + _M_erase_at_end(end() - __n); + } + return begin() + __elems_before; + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + iterator __cur = begin(); + for (; __first != __last && __cur != end(); ++__cur, (void)++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + _M_range_insert_aux(end(), __first, __last, + std::__iterator_category(__first)); + } + + template + void + deque<_Tp, _Alloc>:: + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) + { + if (__pos._M_cur == this->_M_impl._M_start._M_cur) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + __try + { + std::__uninitialized_fill_a(__new_start, this->_M_impl._M_start, + __x, _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else if (__pos._M_cur == this->_M_impl._M_finish._M_cur) + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + __try + { + std::__uninitialized_fill_a(this->_M_impl._M_finish, + __new_finish, __x, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + else + _M_insert_aux(__pos, __n, __x); + } + +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_default_append(size_type __n) + { + if (__n) + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + __try + { + std::__uninitialized_default_a(this->_M_impl._M_finish, + __new_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + } + + template + bool + deque<_Tp, _Alloc>:: + _M_shrink_to_fit() + { + const difference_type __front_capacity + = (this->_M_impl._M_start._M_cur - this->_M_impl._M_start._M_first); + if (__front_capacity == 0) + return false; + + const difference_type __back_capacity + = (this->_M_impl._M_finish._M_last - this->_M_impl._M_finish._M_cur); + if (__front_capacity + __back_capacity < _S_buffer_size()) + return false; + + return std::__shrink_to_fit_aux::_S_do_it(*this); + } +#endif + + template + void + deque<_Tp, _Alloc>:: + _M_fill_initialize(const value_type& __value) + { + _Map_pointer __cur; + __try + { + for (__cur = this->_M_impl._M_start._M_node; + __cur < this->_M_impl._M_finish._M_node; + ++__cur) + std::__uninitialized_fill_a(*__cur, *__cur + _S_buffer_size(), + __value, _M_get_Tp_allocator()); + std::__uninitialized_fill_a(this->_M_impl._M_finish._M_first, + this->_M_impl._M_finish._M_cur, + __value, _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur), + _M_get_Tp_allocator()); + __throw_exception_again; + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_initialize(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + this->_M_initialize_map(0); + __try + { + for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else + push_back(*__first); +#endif + } + __catch(...) + { + clear(); + __throw_exception_again; + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + this->_M_initialize_map(_S_check_init_len(__n, _M_get_Tp_allocator())); + + _Map_pointer __cur_node; + __try + { + for (__cur_node = this->_M_impl._M_start._M_node; + __cur_node < this->_M_impl._M_finish._M_node; + ++__cur_node) + { + _ForwardIterator __mid = __first; + std::advance(__mid, _S_buffer_size()); + std::__uninitialized_copy_a(__first, __mid, *__cur_node, + _M_get_Tp_allocator()); + __first = __mid; + } + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_finish._M_first, + _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(this->_M_impl._M_start, + iterator(*__cur_node, __cur_node), + _M_get_Tp_allocator()); + __throw_exception_again; + } + } + + // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_last - 1. + template +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_push_back_aux(_Args&&... __args) +#else + void + deque<_Tp, _Alloc>:: + _M_push_back_aux(const value_type& __t) +#endif + { + if (size() == max_size()) + __throw_length_error( + __N("cannot create std::deque larger than max_size()")); + + _M_reserve_map_at_back(); + *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node(); + __try + { +#if __cplusplus >= 201103L + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_finish._M_cur, + std::forward<_Args>(__args)...); +#else + this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __t); +#endif + this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node + + 1); + this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first; + } + __catch(...) + { + _M_deallocate_node(*(this->_M_impl._M_finish._M_node + 1)); + __throw_exception_again; + } + } + + // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first. + template +#if __cplusplus >= 201103L + template + void + deque<_Tp, _Alloc>:: + _M_push_front_aux(_Args&&... __args) +#else + void + deque<_Tp, _Alloc>:: + _M_push_front_aux(const value_type& __t) +#endif + { + if (size() == max_size()) + __throw_length_error( + __N("cannot create std::deque larger than max_size()")); + + _M_reserve_map_at_front(); + *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node(); + __try + { + this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + - 1); + this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1; +#if __cplusplus >= 201103L + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_start._M_cur, + std::forward<_Args>(__args)...); +#else + this->_M_impl.construct(this->_M_impl._M_start._M_cur, __t); +#endif + } + __catch(...) + { + ++this->_M_impl._M_start; + _M_deallocate_node(*(this->_M_impl._M_start._M_node - 1)); + __throw_exception_again; + } + } + + // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first. + template + void deque<_Tp, _Alloc>:: + _M_pop_back_aux() + { + _M_deallocate_node(this->_M_impl._M_finish._M_first); + this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1); + this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1; + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_finish._M_cur); + } + + // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_last - 1. + // Note that if the deque has at least one element (a precondition for this + // member function), and if + // _M_impl._M_start._M_cur == _M_impl._M_start._M_last, + // then the deque must have at least two nodes. + template + void deque<_Tp, _Alloc>:: + _M_pop_front_aux() + { + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_start._M_cur); + _M_deallocate_node(this->_M_impl._M_start._M_first); + this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1); + this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first; + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_insert_aux(iterator __pos, + _InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { std::copy(__first, __last, std::inserter(*this, __pos)); } + + template + template + void + deque<_Tp, _Alloc>:: + _M_range_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + if (__pos._M_cur == this->_M_impl._M_start._M_cur) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + __try + { + std::__uninitialized_copy_a(__first, __last, __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else if (__pos._M_cur == this->_M_impl._M_finish._M_cur) + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + __try + { + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + else + _M_insert_aux(__pos, __first, __last, __n); + } + + template +#if __cplusplus >= 201103L + template + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, _Args&&... __args) + { + value_type __x_copy(std::forward<_Args>(__args)...); // XXX copy +#else + typename deque<_Tp, _Alloc>::iterator + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, const value_type& __x) + { + value_type __x_copy = __x; // XXX copy +#endif + difference_type __index = __pos - this->_M_impl._M_start; + if (static_cast(__index) < size() / 2) + { + push_front(_GLIBCXX_MOVE(front())); + iterator __front1 = this->_M_impl._M_start; + ++__front1; + iterator __front2 = __front1; + ++__front2; + __pos = this->_M_impl._M_start + __index; + iterator __pos1 = __pos; + ++__pos1; + _GLIBCXX_MOVE3(__front2, __pos1, __front1); + } + else + { + push_back(_GLIBCXX_MOVE(back())); + iterator __back1 = this->_M_impl._M_finish; + --__back1; + iterator __back2 = __back1; + --__back2; + __pos = this->_M_impl._M_start + __index; + _GLIBCXX_MOVE_BACKWARD3(__pos, __back2, __back1); + } + *__pos = _GLIBCXX_MOVE(__x_copy); + return __pos; + } + + template + void + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, size_type __n, const value_type& __x) + { + const difference_type __elems_before = __pos - this->_M_impl._M_start; + const size_type __length = this->size(); + value_type __x_copy = __x; + if (__elems_before < difference_type(__length / 2)) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_impl._M_start; + __pos = this->_M_impl._M_start + __elems_before; + __try + { + if (__elems_before >= difference_type(__n)) + { + iterator __start_n = (this->_M_impl._M_start + + difference_type(__n)); + std::__uninitialized_move_a(this->_M_impl._M_start, + __start_n, __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + _GLIBCXX_MOVE3(__start_n, __pos, __old_start); + std::fill(__pos - difference_type(__n), __pos, __x_copy); + } + else + { + std::__uninitialized_move_fill(this->_M_impl._M_start, + __pos, __new_start, + this->_M_impl._M_start, + __x_copy, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + std::fill(__old_start, __pos, __x_copy); + } + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_impl._M_finish; + const difference_type __elems_after = + difference_type(__length) - __elems_before; + __pos = this->_M_impl._M_finish - __elems_after; + __try + { + if (__elems_after > difference_type(__n)) + { + iterator __finish_n = (this->_M_impl._M_finish + - difference_type(__n)); + std::__uninitialized_move_a(__finish_n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish); + std::fill(__pos, __pos + difference_type(__n), __x_copy); + } + else + { + std::__uninitialized_fill_move(this->_M_impl._M_finish, + __pos + difference_type(__n), + __x_copy, __pos, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + std::fill(__pos, __old_finish, __x_copy); + } + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + } + + template + template + void + deque<_Tp, _Alloc>:: + _M_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + size_type __n) + { + const difference_type __elemsbefore = __pos - this->_M_impl._M_start; + const size_type __length = size(); + if (static_cast(__elemsbefore) < __length / 2) + { + iterator __new_start = _M_reserve_elements_at_front(__n); + iterator __old_start = this->_M_impl._M_start; + __pos = this->_M_impl._M_start + __elemsbefore; + __try + { + if (__elemsbefore >= difference_type(__n)) + { + iterator __start_n = (this->_M_impl._M_start + + difference_type(__n)); + std::__uninitialized_move_a(this->_M_impl._M_start, + __start_n, __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + _GLIBCXX_MOVE3(__start_n, __pos, __old_start); + std::copy(__first, __last, __pos - difference_type(__n)); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, difference_type(__n) - __elemsbefore); + std::__uninitialized_move_copy(this->_M_impl._M_start, + __pos, __first, __mid, + __new_start, + _M_get_Tp_allocator()); + this->_M_impl._M_start = __new_start; + std::copy(__mid, __last, __old_start); + } + } + __catch(...) + { + _M_destroy_nodes(__new_start._M_node, + this->_M_impl._M_start._M_node); + __throw_exception_again; + } + } + else + { + iterator __new_finish = _M_reserve_elements_at_back(__n); + iterator __old_finish = this->_M_impl._M_finish; + const difference_type __elemsafter = + difference_type(__length) - __elemsbefore; + __pos = this->_M_impl._M_finish - __elemsafter; + __try + { + if (__elemsafter > difference_type(__n)) + { + iterator __finish_n = (this->_M_impl._M_finish + - difference_type(__n)); + std::__uninitialized_move_a(__finish_n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + _GLIBCXX_MOVE_BACKWARD3(__pos, __finish_n, __old_finish); + std::copy(__first, __last, __pos); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, __elemsafter); + std::__uninitialized_copy_move(__mid, __last, __pos, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __new_finish; + std::copy(__first, __mid, __pos); + } + } + __catch(...) + { + _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1, + __new_finish._M_node + 1); + __throw_exception_again; + } + } + } + + template + void + deque<_Tp, _Alloc>:: + _M_destroy_data_aux(iterator __first, iterator __last) + { + for (_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::_Destroy(*__node, *__node + _S_buffer_size(), + _M_get_Tp_allocator()); + + if (__first._M_node != __last._M_node) + { + std::_Destroy(__first._M_cur, __first._M_last, + _M_get_Tp_allocator()); + std::_Destroy(__last._M_first, __last._M_cur, + _M_get_Tp_allocator()); + } + else + std::_Destroy(__first._M_cur, __last._M_cur, + _M_get_Tp_allocator()); + } + + template + void + deque<_Tp, _Alloc>:: + _M_new_elements_at_front(size_type __new_elems) + { + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_front")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); + _M_reserve_map_at_front(__new_nodes); + size_type __i; + __try + { + for (__i = 1; __i <= __new_nodes; ++__i) + *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node(); + } + __catch(...) + { + for (size_type __j = 1; __j < __i; ++__j) + _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j)); + __throw_exception_again; + } + } + + template + void + deque<_Tp, _Alloc>:: + _M_new_elements_at_back(size_type __new_elems) + { + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_back")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); + _M_reserve_map_at_back(__new_nodes); + size_type __i; + __try + { + for (__i = 1; __i <= __new_nodes; ++__i) + *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node(); + } + __catch(...) + { + for (size_type __j = 1; __j < __i; ++__j) + _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j)); + __throw_exception_again; + } + } + + template + void + deque<_Tp, _Alloc>:: + _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front) + { + const size_type __old_num_nodes + = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1; + const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; + + _Map_pointer __new_nstart; + if (this->_M_impl._M_map_size > 2 * __new_num_nodes) + { + __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size + - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + if (__new_nstart < this->_M_impl._M_start._M_node) + std::copy(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1, + __new_nstart); + else + std::copy_backward(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1, + __new_nstart + __old_num_nodes); + } + else + { + size_type __new_map_size = this->_M_impl._M_map_size + + std::max(this->_M_impl._M_map_size, + __nodes_to_add) + 2; + + _Map_pointer __new_map = this->_M_allocate_map(__new_map_size); + __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + std::copy(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1, + __new_nstart); + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + + this->_M_impl._M_map = __new_map; + this->_M_impl._M_map_size = __new_map_size; + } + + this->_M_impl._M_start._M_set_node(__new_nstart); + this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); + } + +_GLIBCXX_END_NAMESPACE_CONTAINER + + // Overload for deque::iterators, exploiting the "segmented-iterator + // optimization". + template + void + __fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last, + const _VTp& __value) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + if (__first._M_node != __last._M_node) + { + std::__fill_a1(__first._M_cur, __first._M_last, __value); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node < __last._M_node; ++__node) + std::__fill_a1(*__node, *__node + _Iter::_S_buffer_size(), __value); + + std::__fill_a1(__last._M_first, __last._M_cur, __value); + } + else + std::__fill_a1(__first._M_cur, __last._M_cur, __value); + } + + template + _OI + __copy_move_dit(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + if (__first._M_node != __last._M_node) + { + __result + = std::__copy_move_a1<_IsMove>(__first._M_cur, __first._M_last, + __result); + + for (typename _Iter::_Map_pointer __node = __first._M_node + 1; + __node != __last._M_node; ++__node) + __result + = std::__copy_move_a1<_IsMove>(*__node, + *__node + _Iter::_S_buffer_size(), + __result); + + return std::__copy_move_a1<_IsMove>(__last._M_first, __last._M_cur, + __result); + } + + return std::__copy_move_a1<_IsMove>(__first._M_cur, __last._M_cur, + __result); + } + + template + _OI + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { return __copy_move_dit<_IsMove>(__first, __last, __result); } + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result) + { return __copy_move_dit<_IsMove>(__first, __last, __result); } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_a1(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __result._M_last - __result._M_cur); + std::__copy_move_a1<_IsMove>(__first, __first + __clen, + __result._M_cur); + + __first += __clen; + __result += __clen; + __len -= __clen; + } + + return __result; + } + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_move_a2( + istreambuf_iterator<_CharT, char_traits<_CharT> > __first, + istreambuf_iterator<_CharT, char_traits<_CharT> > __last, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result) + { + if (__first == __last) + return __result; + + for (;;) + { + const std::ptrdiff_t __len = __result._M_last - __result._M_cur; + const std::ptrdiff_t __nb + = std::__copy_n_a(__first, __len, __result._M_cur, false) + - __result._M_cur; + __result += __nb; + + if (__nb != __len) + break; + } + + return __result; + } + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_n_a( + istreambuf_iterator<_CharT, char_traits<_CharT> > __it, _Size __size, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> __result, + bool __strict) + { + if (__size == 0) + return __result; + + do + { + const _Size __len + = std::min<_Size>(__result._M_last - __result._M_cur, __size); + std::__copy_n_a(__it, __len, __result._M_cur, __strict); + __result += __len; + __size -= __len; + } + while (__size != 0); + return __result; + } + + template + _OI + __copy_move_backward_dit( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + if (__first._M_node != __last._M_node) + { + __result = std::__copy_move_backward_a1<_IsMove>( + __last._M_first, __last._M_cur, __result); + + for (typename _Iter::_Map_pointer __node = __last._M_node - 1; + __node != __first._M_node; --__node) + __result = std::__copy_move_backward_a1<_IsMove>( + *__node, *__node + _Iter::_S_buffer_size(), __result); + + return std::__copy_move_backward_a1<_IsMove>( + __first._M_cur, __first._M_last, __result); + } + + return std::__copy_move_backward_a1<_IsMove>( + __first._M_cur, __last._M_cur, __result); + } + + template + _OI + __copy_move_backward_a1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last, + _OI __result) + { return __copy_move_backward_dit<_IsMove>(__first, __last, __result); } + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_backward_a1( + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> __result) + { return __copy_move_backward_dit<_IsMove>(__first, __last, __result); } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_backward_a1(_II __first, _II __last, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> __result) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last - __first; + while (__len > 0) + { + difference_type __rlen = __result._M_cur - __result._M_first; + _Tp* __rend = __result._M_cur; + if (!__rlen) + { + __rlen = _Iter::_S_buffer_size(); + __rend = *(__result._M_node - 1) + __rlen; + } + + const difference_type __clen = std::min(__len, __rlen); + std::__copy_move_backward_a1<_IsMove>(__last - __clen, __last, __rend); + + __last -= __clen; + __result -= __clen; + __len -= __clen; + } + + return __result; + } + + template + bool + __equal_dit( + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __last1, + _II __first2) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + if (__first1._M_node != __last1._M_node) + { + if (!std::__equal_aux1(__first1._M_cur, __first1._M_last, __first2)) + return false; + + __first2 += __first1._M_last - __first1._M_cur; + for (typename _Iter::_Map_pointer __node = __first1._M_node + 1; + __node != __last1._M_node; + __first2 += _Iter::_S_buffer_size(), ++__node) + if (!std::__equal_aux1(*__node, *__node + _Iter::_S_buffer_size(), + __first2)) + return false; + + return std::__equal_aux1(__last1._M_first, __last1._M_cur, __first2); + } + + return std::__equal_aux1(__first1._M_cur, __last1._M_cur, __first2); + } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last1, + _II __first2) + { return std::__equal_dit(__first1, __last1, __first2); } + + template + bool + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2) + { return std::__equal_dit(__first1, __last1, __first2); } + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_II __first1, _II __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first2) + { + typedef _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> _Iter; + typedef typename _Iter::difference_type difference_type; + + difference_type __len = __last1 - __first1; + while (__len > 0) + { + const difference_type __clen + = std::min(__len, __first2._M_last - __first2._M_cur); + if (!std::__equal_aux1(__first1, __first1 + __clen, __first2._M_cur)) + return false; + + __first1 += __clen; + __len -= __clen; + __first2 += __clen; + } + + return true; + } + + template + int + __lex_cmp_dit( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __last1, + const _Tp2* __first2, const _Tp2* __last2) + { + const bool __simple = + (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value + && __is_pointer<_Ptr>::__value +#if __cplusplus > 201703L && __cpp_lib_concepts + // For C++20 iterator_traits::value_type is non-volatile + // so __is_byte could be true, but we can't use memcmp with + // volatile data. + && !is_volatile_v<_Tp1> + && !is_volatile_v<_Tp2> +#endif + ); + typedef std::__lexicographical_compare<__simple> _Lc; + + while (__first1._M_node != __last1._M_node) + { + const ptrdiff_t __len1 = __first1._M_last - __first1._M_cur; + const ptrdiff_t __len2 = __last2 - __first2; + const ptrdiff_t __len = std::min(__len1, __len2); + // if __len1 > __len2 this will return a positive value: + if (int __ret = _Lc::__3way(__first1._M_cur, __first1._M_last, + __first2, __first2 + __len)) + return __ret; + + __first1 += __len; + __first2 += __len; + } + return _Lc::__3way(__first1._M_cur, __last1._M_cur, + __first2, __last2); + } + + template + inline bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, + _Tp2* __first2, _Tp2* __last2) + { return std::__lex_cmp_dit(__first1, __last1, __first2, __last2) < 0; } + + template + inline bool + __lexicographical_compare_aux1(_Tp1* __first1, _Tp1* __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2) + { return std::__lex_cmp_dit(__first2, __last2, __first1, __last1) > 0; } + + template + inline bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2) + { + const bool __simple = + (__is_memcmp_ordered_with<_Tp1, _Tp2>::__value + && __is_pointer<_Ptr1>::__value + && __is_pointer<_Ptr2>::__value +#if __cplusplus > 201703L && __cpp_lib_concepts + // For C++20 iterator_traits::value_type is non-volatile + // so __is_byte could be true, but we can't use memcmp with + // volatile data. + && !is_volatile_v<_Tp1> + && !is_volatile_v<_Tp2> +#endif + ); + typedef std::__lexicographical_compare<__simple> _Lc; + + while (__first1 != __last1) + { + const ptrdiff_t __len2 = __first2._M_node == __last2._M_node + ? __last2._M_cur - __first2._M_cur + : __first2._M_last - __first2._M_cur; + if (__len2 == 0) + return false; + const ptrdiff_t __len1 = __first1._M_node == __last1._M_node + ? __last1._M_cur - __first1._M_cur + : __first1._M_last - __first1._M_cur; + const ptrdiff_t __len = std::min(__len1, __len2); + if (int __ret = _Lc::__3way(__first1._M_cur, __first1._M_cur + __len, + __first2._M_cur, __first2._M_cur + __len)) + return __ret < 0; + + __first1 += __len; + __first2 += __len; + } + + return __last2 != __first2; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/enable_special_members.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/enable_special_members.h new file mode 100755 index 0000000..8361a06 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/enable_special_members.h @@ -0,0 +1,314 @@ +// -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/enable_special_members.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _ENABLE_SPECIAL_MEMBERS_H +#define _ENABLE_SPECIAL_MEMBERS_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct _Enable_default_constructor_tag + { + explicit constexpr _Enable_default_constructor_tag() = default; + }; + +/** + * @brief A mixin helper to conditionally enable or disable the default + * constructor. + * @sa _Enable_special_members + */ +template + struct _Enable_default_constructor + { + constexpr _Enable_default_constructor() noexcept = default; + constexpr _Enable_default_constructor(_Enable_default_constructor const&) + noexcept = default; + constexpr _Enable_default_constructor(_Enable_default_constructor&&) + noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor const&) noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor&&) noexcept = default; + + // Can be used in other ctors. + constexpr explicit + _Enable_default_constructor(_Enable_default_constructor_tag) { } + }; + + +/** + * @brief A mixin helper to conditionally enable or disable the default + * destructor. + * @sa _Enable_special_members + */ +template + struct _Enable_destructor { }; + +/** + * @brief A mixin helper to conditionally enable or disable the copy/move + * special members. + * @sa _Enable_special_members + */ +template + struct _Enable_copy_move { }; + +/** + * @brief A mixin helper to conditionally enable or disable the special + * members. + * + * The @c _Tag type parameter is to make mixin bases unique and thus avoid + * ambiguities. + */ +template + struct _Enable_special_members + : private _Enable_default_constructor<_Default, _Tag>, + private _Enable_destructor<_Destructor, _Tag>, + private _Enable_copy_move<_Copy, _CopyAssignment, + _Move, _MoveAssignment, + _Tag> + { }; + +// Boilerplate follows. + +template + struct _Enable_default_constructor + { + constexpr _Enable_default_constructor() noexcept = delete; + constexpr _Enable_default_constructor(_Enable_default_constructor const&) + noexcept = default; + constexpr _Enable_default_constructor(_Enable_default_constructor&&) + noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor const&) noexcept = default; + _Enable_default_constructor& + operator=(_Enable_default_constructor&&) noexcept = default; + + // Can be used in other ctors. + constexpr explicit + _Enable_default_constructor(_Enable_default_constructor_tag) { } + }; + +template + struct _Enable_destructor + { ~_Enable_destructor() noexcept = delete; }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = default; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = default; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +template + struct _Enable_copy_move + { + constexpr _Enable_copy_move() noexcept = default; + constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept = delete; + constexpr _Enable_copy_move(_Enable_copy_move&&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move const&) noexcept = delete; + _Enable_copy_move& + operator=(_Enable_copy_move&&) noexcept = delete; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _ENABLE_SPECIAL_MEMBERS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/erase_if.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/erase_if.h new file mode 100755 index 0000000..8d1d231 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/erase_if.h @@ -0,0 +1,74 @@ +// -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/erase_if.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef _GLIBCXX_ERASE_IF_H +#define _GLIBCXX_ERASE_IF_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus > 201703L +# define __cpp_lib_erase_if 202002L +#endif + + namespace __detail + { + template + typename _Container::size_type + __erase_nodes_if(_Container& __cont, _Predicate __pred) + { + typename _Container::size_type __num = 0; + for (auto __iter = __cont.begin(), __last = __cont.end(); + __iter != __last;) + { + if (__pred(*__iter)) + { + __iter = __cont.erase(__iter); + ++__num; + } + else + ++__iter; + } + return __num; + } + } // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_ERASE_IF_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception.h new file mode 100755 index 0000000..60faa88 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception.h @@ -0,0 +1,87 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 2016-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/exception.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#ifndef __EXCEPTION_H +#define __EXCEPTION_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include + +extern "C++" { + +namespace std +{ + /** + * @defgroup exceptions Exceptions + * @ingroup diagnostics + * @since C++98 + * + * Classes and functions for reporting errors via exceptions. + * @{ + */ + + /** + * @brief Base class for all library exceptions. + * + * This is the base class for all exceptions thrown by the standard + * library, and by certain language expressions. You are free to derive + * your own %exception classes, or use a different hierarchy, or to + * throw non-class data (e.g., fundamental types). + */ + class exception + { + public: + exception() _GLIBCXX_NOTHROW { } + virtual ~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; +#if __cplusplus >= 201103L + exception(const exception&) = default; + exception& operator=(const exception&) = default; + exception(exception&&) = default; + exception& operator=(exception&&) = default; +#endif + + /** Returns a C-style character string describing the general cause + * of the current error. */ + virtual const char* + what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW; + }; + + /// @} + +} // namespace std + +} + +#pragma GCC visibility pop + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception_defines.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception_defines.h new file mode 100755 index 0000000..58ee17b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception_defines.h @@ -0,0 +1,45 @@ +// -fno-exceptions Support -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/exception_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + */ + +#ifndef _EXCEPTION_DEFINES_H +#define _EXCEPTION_DEFINES_H 1 + +#if ! __cpp_exceptions +// Iff -fno-exceptions, transform error handling code to work without it. +# define __try if (true) +# define __catch(X) if (false) +# define __throw_exception_again +#else +// Else proceed normally. +# define __try try +# define __catch(X) catch(X) +# define __throw_exception_again throw +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception_ptr.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception_ptr.h new file mode 100755 index 0000000..f9dffd5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/exception_ptr.h @@ -0,0 +1,273 @@ +// Exception Handling support header (exception_ptr class) for -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/exception_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + */ + +#ifndef _EXCEPTION_PTR_H +#define _EXCEPTION_PTR_H + +#pragma GCC visibility push(default) + +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_EH_PTR_RELOPS_COMPAT +# define _GLIBCXX_EH_PTR_USED __attribute__((__used__)) +#else +# define _GLIBCXX_EH_PTR_USED +#endif + +extern "C++" { + +namespace std +{ + class type_info; + + /** + * @addtogroup exceptions + * @{ + */ + + namespace __exception_ptr + { + class exception_ptr; + } + + using __exception_ptr::exception_ptr; + + /** Obtain an exception_ptr to the currently handled exception. If there + * is none, or the currently handled exception is foreign, return the null + * value. + */ + exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT; + + template + exception_ptr make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT; + + /// Throw the object pointed to by the exception_ptr. + void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); + + namespace __exception_ptr + { + using std::rethrow_exception; + + /** + * @brief An opaque pointer to an arbitrary exception. + * @ingroup exceptions + */ + class exception_ptr + { + void* _M_exception_object; + + explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT; + + void _M_addref() _GLIBCXX_USE_NOEXCEPT; + void _M_release() _GLIBCXX_USE_NOEXCEPT; + + void *_M_get() const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__)); + + friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT; + friend void std::rethrow_exception(exception_ptr); + template + friend exception_ptr std::make_exception_ptr(_Ex) _GLIBCXX_USE_NOEXCEPT; + + public: + exception_ptr() _GLIBCXX_USE_NOEXCEPT; + + exception_ptr(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + exception_ptr(nullptr_t) noexcept + : _M_exception_object(nullptr) + { } + + exception_ptr(exception_ptr&& __o) noexcept + : _M_exception_object(__o._M_exception_object) + { __o._M_exception_object = nullptr; } +#endif + +#if (__cplusplus < 201103L) || defined (_GLIBCXX_EH_PTR_COMPAT) + typedef void (exception_ptr::*__safe_bool)(); + + // For construction from nullptr or 0. + exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT; +#endif + + exception_ptr& + operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + exception_ptr& + operator=(exception_ptr&& __o) noexcept + { + exception_ptr(static_cast(__o)).swap(*this); + return *this; + } +#endif + + ~exception_ptr() _GLIBCXX_USE_NOEXCEPT; + + void + swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT; + +#ifdef _GLIBCXX_EH_PTR_COMPAT + // Retained for compatibility with CXXABI_1.3. + void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__const__)); + bool operator!() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); + operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT; +#endif + +#if __cplusplus >= 201103L + explicit operator bool() const noexcept + { return _M_exception_object; } +#endif + +#if __cpp_impl_three_way_comparison >= 201907L \ + && ! defined _GLIBCXX_EH_PTR_RELOPS_COMPAT + friend bool + operator==(const exception_ptr&, const exception_ptr&) noexcept = default; +#else + friend _GLIBCXX_EH_PTR_USED bool + operator==(const exception_ptr& __x, const exception_ptr& __y) + _GLIBCXX_USE_NOEXCEPT + { return __x._M_exception_object == __y._M_exception_object; } + + friend _GLIBCXX_EH_PTR_USED bool + operator!=(const exception_ptr& __x, const exception_ptr& __y) + _GLIBCXX_USE_NOEXCEPT + { return __x._M_exception_object != __y._M_exception_object; } +#endif + + const class std::type_info* + __cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); + }; + + _GLIBCXX_EH_PTR_USED + inline + exception_ptr::exception_ptr() _GLIBCXX_NOEXCEPT + : _M_exception_object(0) + { } + + _GLIBCXX_EH_PTR_USED + inline + exception_ptr::exception_ptr(const exception_ptr& __other) _GLIBCXX_NOEXCEPT + : _M_exception_object(__other._M_exception_object) + { + if (_M_exception_object) + _M_addref(); + } + + _GLIBCXX_EH_PTR_USED + inline + exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT + { + if (_M_exception_object) + _M_release(); + } + + _GLIBCXX_EH_PTR_USED + inline exception_ptr& + exception_ptr::operator=(const exception_ptr& __other) _GLIBCXX_USE_NOEXCEPT + { + exception_ptr(__other).swap(*this); + return *this; + } + + _GLIBCXX_EH_PTR_USED + inline void + exception_ptr::swap(exception_ptr &__other) _GLIBCXX_USE_NOEXCEPT + { + void *__tmp = _M_exception_object; + _M_exception_object = __other._M_exception_object; + __other._M_exception_object = __tmp; + } + + /// @relates exception_ptr + inline void + swap(exception_ptr& __lhs, exception_ptr& __rhs) + { __lhs.swap(__rhs); } + + /// @cond undocumented + template + inline void + __dest_thunk(void* __x) + { static_cast<_Ex*>(__x)->~_Ex(); } + /// @endcond + + } // namespace __exception_ptr + + /// Obtain an exception_ptr pointing to a copy of the supplied object. + template + exception_ptr + make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT + { +#if __cpp_exceptions && __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI + void* __e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex)); + (void) __cxxabiv1::__cxa_init_primary_exception( + __e, const_cast(&typeid(__ex)), + __exception_ptr::__dest_thunk<_Ex>); + try + { + ::new (__e) _Ex(__ex); + return exception_ptr(__e); + } + catch(...) + { + __cxxabiv1::__cxa_free_exception(__e); + return current_exception(); + } +#elif __cpp_exceptions + try + { + throw __ex; + } + catch(...) + { + return current_exception(); + } +#else // no RTTI and no exceptions + return exception_ptr(); +#endif + } + +#undef _GLIBCXX_EH_PTR_USED + + /// @} group exceptions +} // namespace std + +} // extern "C++" + +#pragma GCC visibility pop + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/forward_list.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/forward_list.h new file mode 100755 index 0000000..e617468 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/forward_list.h @@ -0,0 +1,1514 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/forward_list.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{forward_list} + */ + +#ifndef _FORWARD_LIST_H +#define _FORWARD_LIST_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * @brief A helper basic node class for %forward_list. + * This is just a linked list with nothing inside it. + * There are purely list shuffling utility methods here. + */ + struct _Fwd_list_node_base + { + _Fwd_list_node_base() = default; + _Fwd_list_node_base(_Fwd_list_node_base&& __x) noexcept + : _M_next(__x._M_next) + { __x._M_next = nullptr; } + + _Fwd_list_node_base(const _Fwd_list_node_base&) = delete; + _Fwd_list_node_base& operator=(const _Fwd_list_node_base&) = delete; + + _Fwd_list_node_base& + operator=(_Fwd_list_node_base&& __x) noexcept + { + _M_next = __x._M_next; + __x._M_next = nullptr; + return *this; + } + + _Fwd_list_node_base* _M_next = nullptr; + + _Fwd_list_node_base* + _M_transfer_after(_Fwd_list_node_base* __begin, + _Fwd_list_node_base* __end) noexcept + { + _Fwd_list_node_base* __keep = __begin->_M_next; + if (__end) + { + __begin->_M_next = __end->_M_next; + __end->_M_next = _M_next; + } + else + __begin->_M_next = nullptr; + _M_next = __keep; + return __end; + } + + void + _M_reverse_after() noexcept + { + _Fwd_list_node_base* __tail = _M_next; + if (!__tail) + return; + while (_Fwd_list_node_base* __temp = __tail->_M_next) + { + _Fwd_list_node_base* __keep = _M_next; + _M_next = __temp; + __tail->_M_next = __temp->_M_next; + _M_next->_M_next = __keep; + } + } + }; + + /** + * @brief A helper node class for %forward_list. + * This is just a linked list with uninitialized storage for a + * data value in each node. + * There is a sorting utility method. + */ + template + struct _Fwd_list_node + : public _Fwd_list_node_base + { + _Fwd_list_node() = default; + + __gnu_cxx::__aligned_buffer<_Tp> _M_storage; + + _Tp* + _M_valptr() noexcept + { return _M_storage._M_ptr(); } + + const _Tp* + _M_valptr() const noexcept + { return _M_storage._M_ptr(); } + }; + + /** + * @brief A forward_list::iterator. + * + * All the functions are op overloads. + */ + template + struct _Fwd_list_iterator + { + typedef _Fwd_list_iterator<_Tp> _Self; + typedef _Fwd_list_node<_Tp> _Node; + + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Fwd_list_iterator() noexcept + : _M_node() { } + + explicit + _Fwd_list_iterator(_Fwd_list_node_base* __n) noexcept + : _M_node(__n) { } + + reference + operator*() const noexcept + { return *static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + pointer + operator->() const noexcept + { return static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + _Self& + operator++() noexcept + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) noexcept + { + _Self __tmp(*this); + _M_node = _M_node->_M_next; + return __tmp; + } + + /** + * @brief Forward list iterator equality comparison. + */ + friend bool + operator==(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + /** + * @brief Forward list iterator inequality comparison. + */ + friend bool + operator!=(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node != __y._M_node; } +#endif + + _Self + _M_next() const noexcept + { + if (_M_node) + return _Fwd_list_iterator(_M_node->_M_next); + else + return _Fwd_list_iterator(nullptr); + } + + _Fwd_list_node_base* _M_node; + }; + + /** + * @brief A forward_list::const_iterator. + * + * All the functions are op overloads. + */ + template + struct _Fwd_list_const_iterator + { + typedef _Fwd_list_const_iterator<_Tp> _Self; + typedef const _Fwd_list_node<_Tp> _Node; + typedef _Fwd_list_iterator<_Tp> iterator; + + typedef _Tp value_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + typedef ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Fwd_list_const_iterator() noexcept + : _M_node() { } + + explicit + _Fwd_list_const_iterator(const _Fwd_list_node_base* __n) noexcept + : _M_node(__n) { } + + _Fwd_list_const_iterator(const iterator& __iter) noexcept + : _M_node(__iter._M_node) { } + + reference + operator*() const noexcept + { return *static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + pointer + operator->() const noexcept + { return static_cast<_Node*>(this->_M_node)->_M_valptr(); } + + _Self& + operator++() noexcept + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) noexcept + { + _Self __tmp(*this); + _M_node = _M_node->_M_next; + return __tmp; + } + + /** + * @brief Forward list const_iterator equality comparison. + */ + friend bool + operator==(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + /** + * @brief Forward list const_iterator inequality comparison. + */ + friend bool + operator!=(const _Self& __x, const _Self& __y) noexcept + { return __x._M_node != __y._M_node; } +#endif + + _Self + _M_next() const noexcept + { + if (this->_M_node) + return _Fwd_list_const_iterator(_M_node->_M_next); + else + return _Fwd_list_const_iterator(nullptr); + } + + const _Fwd_list_node_base* _M_node; + }; + + /** + * @brief Base class for %forward_list. + */ + template + struct _Fwd_list_base + { + protected: + typedef __alloc_rebind<_Alloc, _Fwd_list_node<_Tp>> _Node_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits; + + struct _Fwd_list_impl + : public _Node_alloc_type + { + _Fwd_list_node_base _M_head; + + _Fwd_list_impl() + noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value) + : _Node_alloc_type(), _M_head() + { } + + _Fwd_list_impl(_Fwd_list_impl&&) = default; + + _Fwd_list_impl(_Fwd_list_impl&& __fl, _Node_alloc_type&& __a) + : _Node_alloc_type(std::move(__a)), _M_head(std::move(__fl._M_head)) + { } + + _Fwd_list_impl(_Node_alloc_type&& __a) + : _Node_alloc_type(std::move(__a)), _M_head() + { } + }; + + _Fwd_list_impl _M_impl; + + public: + typedef _Fwd_list_iterator<_Tp> iterator; + typedef _Fwd_list_const_iterator<_Tp> const_iterator; + typedef _Fwd_list_node<_Tp> _Node; + + _Node_alloc_type& + _M_get_Node_allocator() noexcept + { return this->_M_impl; } + + const _Node_alloc_type& + _M_get_Node_allocator() const noexcept + { return this->_M_impl; } + + _Fwd_list_base() = default; + + _Fwd_list_base(_Node_alloc_type&& __a) + : _M_impl(std::move(__a)) { } + + // When allocators are always equal. + _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a, + std::true_type) + : _M_impl(std::move(__lst._M_impl), std::move(__a)) + { } + + // When allocators are not always equal. + _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a); + + _Fwd_list_base(_Fwd_list_base&&) = default; + + ~_Fwd_list_base() + { _M_erase_after(&_M_impl._M_head, nullptr); } + + protected: + _Node* + _M_get_node() + { + auto __ptr = _Node_alloc_traits::allocate(_M_get_Node_allocator(), 1); + return std::__to_address(__ptr); + } + + template + _Node* + _M_create_node(_Args&&... __args) + { + _Node* __node = this->_M_get_node(); + __try + { + ::new ((void*)__node) _Node; + _Node_alloc_traits::construct(_M_get_Node_allocator(), + __node->_M_valptr(), + std::forward<_Args>(__args)...); + } + __catch(...) + { + this->_M_put_node(__node); + __throw_exception_again; + } + return __node; + } + + template + _Fwd_list_node_base* + _M_insert_after(const_iterator __pos, _Args&&... __args); + + void + _M_put_node(_Node* __p) + { + typedef typename _Node_alloc_traits::pointer _Ptr; + auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__p); + _Node_alloc_traits::deallocate(_M_get_Node_allocator(), __ptr, 1); + } + + _Fwd_list_node_base* + _M_erase_after(_Fwd_list_node_base* __pos); + + _Fwd_list_node_base* + _M_erase_after(_Fwd_list_node_base* __pos, + _Fwd_list_node_base* __last); + }; + + /** + * @brief A standard container with linear time access to elements, + * and fixed time insertion/deletion at any point in the sequence. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * sequence, including the + * optional sequence requirements with the + * %exception of @c at and @c operator[]. + * + * This is a @e singly @e linked %list. Traversal up the + * %list requires linear time, but adding and removing elements (or + * @e nodes) is done in constant time, regardless of where the + * change takes place. Unlike std::vector and std::deque, + * random-access iterators are not provided, so subscripting ( @c + * [] ) access is not allowed. For algorithms which only need + * sequential access, this lack makes no difference. + * + * Also unlike the other standard containers, std::forward_list provides + * specialized algorithms %unique to linked lists, such as + * splicing, sorting, and in-place reversal. + */ + template> + class forward_list : private _Fwd_list_base<_Tp, _Alloc> + { + static_assert(is_same::type, _Tp>::value, + "std::forward_list must have a non-const, non-volatile value_type"); +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::forward_list must have the same value_type as its allocator"); +#endif + + private: + typedef _Fwd_list_base<_Tp, _Alloc> _Base; + typedef _Fwd_list_node_base _Node_base; + typedef typename _Base::_Node _Node; + typedef typename _Base::_Node_alloc_type _Node_alloc_type; + typedef typename _Base::_Node_alloc_traits _Node_alloc_traits; + typedef allocator_traits<__alloc_rebind<_Alloc, _Tp>> _Alloc_traits; + + public: + // types: + typedef _Tp value_type; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + // 23.3.4.2 construct/copy/destroy: + + /** + * @brief Creates a %forward_list with no elements. + */ + forward_list() = default; + + /** + * @brief Creates a %forward_list with no elements. + * @param __al An allocator object. + */ + explicit + forward_list(const _Alloc& __al) noexcept + : _Base(_Node_alloc_type(__al)) + { } + + /** + * @brief Copy constructor with allocator argument. + * @param __list Input list to copy. + * @param __al An allocator object. + */ + forward_list(const forward_list& __list, const _Alloc& __al) + : _Base(_Node_alloc_type(__al)) + { _M_range_initialize(__list.begin(), __list.end()); } + + private: + forward_list(forward_list&& __list, _Node_alloc_type&& __al, + false_type) + : _Base(std::move(__list), std::move(__al)) + { + // If __list is not empty it means its allocator is not equal to __a, + // so we need to move from each element individually. + insert_after(cbefore_begin(), + std::__make_move_if_noexcept_iterator(__list.begin()), + std::__make_move_if_noexcept_iterator(__list.end())); + } + + forward_list(forward_list&& __list, _Node_alloc_type&& __al, + true_type) + noexcept + : _Base(std::move(__list), _Node_alloc_type(__al), true_type{}) + { } + + public: + /** + * @brief Move constructor with allocator argument. + * @param __list Input list to move. + * @param __al An allocator object. + */ + forward_list(forward_list&& __list, const _Alloc& __al) + noexcept(_Node_alloc_traits::_S_always_equal()) + : forward_list(std::move(__list), _Node_alloc_type(__al), + typename _Node_alloc_traits::is_always_equal{}) + { } + + /** + * @brief Creates a %forward_list with default constructed elements. + * @param __n The number of elements to initially create. + * @param __al An allocator object. + * + * This constructor creates the %forward_list with @a __n default + * constructed elements. + */ + explicit + forward_list(size_type __n, const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_default_initialize(__n); } + + /** + * @brief Creates a %forward_list with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __al An allocator object. + * + * This constructor fills the %forward_list with @a __n copies of + * @a __value. + */ + forward_list(size_type __n, const _Tp& __value, + const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_fill_initialize(__n, __value); } + + /** + * @brief Builds a %forward_list from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __al An allocator object. + * + * Create a %forward_list consisting of copies of the elements from + * [@a __first,@a __last). This is linear in N (where N is + * distance(@a __first,@a __last)). + */ + template> + forward_list(_InputIterator __first, _InputIterator __last, + const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_range_initialize(__first, __last); } + + /** + * @brief The %forward_list copy constructor. + * @param __list A %forward_list of identical element and allocator + * types. + */ + forward_list(const forward_list& __list) + : _Base(_Node_alloc_traits::_S_select_on_copy( + __list._M_get_Node_allocator())) + { _M_range_initialize(__list.begin(), __list.end()); } + + /** + * @brief The %forward_list move constructor. + * @param __list A %forward_list of identical element and allocator + * types. + * + * The newly-created %forward_list contains the exact contents of the + * moved instance. The contents of the moved instance are a valid, but + * unspecified %forward_list. + */ + forward_list(forward_list&&) = default; + + /** + * @brief Builds a %forward_list from an initializer_list + * @param __il An initializer_list of value_type. + * @param __al An allocator object. + * + * Create a %forward_list consisting of copies of the elements + * in the initializer_list @a __il. This is linear in __il.size(). + */ + forward_list(std::initializer_list<_Tp> __il, + const _Alloc& __al = _Alloc()) + : _Base(_Node_alloc_type(__al)) + { _M_range_initialize(__il.begin(), __il.end()); } + + /** + * @brief The forward_list dtor. + */ + ~forward_list() noexcept + { } + + /** + * @brief The %forward_list assignment operator. + * @param __list A %forward_list of identical element and allocator + * types. + * + * All the elements of @a __list are copied. + * + * Whether the allocator is copied depends on the allocator traits. + */ + forward_list& + operator=(const forward_list& __list); + + /** + * @brief The %forward_list move assignment operator. + * @param __list A %forward_list of identical element and allocator + * types. + * + * The contents of @a __list are moved into this %forward_list + * (without copying, if the allocators permit it). + * + * Afterwards @a __list is a valid, but unspecified %forward_list + * + * Whether the allocator is moved depends on the allocator traits. + */ + forward_list& + operator=(forward_list&& __list) + noexcept(_Node_alloc_traits::_S_nothrow_move()) + { + constexpr bool __move_storage = + _Node_alloc_traits::_S_propagate_on_move_assign() + || _Node_alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__list), __bool_constant<__move_storage>()); + return *this; + } + + /** + * @brief The %forward_list initializer list assignment operator. + * @param __il An initializer_list of value_type. + * + * Replace the contents of the %forward_list with copies of the + * elements in the initializer_list @a __il. This is linear in + * __il.size(). + */ + forward_list& + operator=(std::initializer_list<_Tp> __il) + { + assign(__il); + return *this; + } + + /** + * @brief Assigns a range to a %forward_list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %forward_list with copies of the elements + * in the range [@a __first,@a __last). + * + * Note that the assignment completely changes the %forward_list and + * that the number of elements of the resulting %forward_list is the + * same as the number of elements assigned. + */ + template> + void + assign(_InputIterator __first, _InputIterator __last) + { + typedef is_assignable<_Tp, decltype(*__first)> __assignable; + _M_assign(__first, __last, __assignable()); + } + + /** + * @brief Assigns a given value to a %forward_list. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %forward_list with @a __n copies of the + * given value. Note that the assignment completely changes the + * %forward_list, and that the resulting %forward_list has __n + * elements. + */ + void + assign(size_type __n, const _Tp& __val) + { _M_assign_n(__n, __val, is_copy_assignable<_Tp>()); } + + /** + * @brief Assigns an initializer_list to a %forward_list. + * @param __il An initializer_list of value_type. + * + * Replace the contents of the %forward_list with copies of the + * elements in the initializer_list @a __il. This is linear in + * il.size(). + */ + void + assign(std::initializer_list<_Tp> __il) + { assign(__il.begin(), __il.end()); } + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const noexcept + { return allocator_type(this->_M_get_Node_allocator()); } + + // 23.3.4.3 iterators: + + /** + * Returns a read/write iterator that points before the first element + * in the %forward_list. Iteration is done in ordinary element order. + */ + iterator + before_begin() noexcept + { return iterator(&this->_M_impl._M_head); } + + /** + * Returns a read-only (constant) iterator that points before the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + before_begin() const noexcept + { return const_iterator(&this->_M_impl._M_head); } + + /** + * Returns a read/write iterator that points to the first element + * in the %forward_list. Iteration is done in ordinary element order. + */ + iterator + begin() noexcept + { return iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + begin() const noexcept + { return const_iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + iterator + end() noexcept + { return iterator(nullptr); } + + /** + * Returns a read-only iterator that points one past the last + * element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + end() const noexcept + { return const_iterator(nullptr); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_head._M_next); } + + /** + * Returns a read-only (constant) iterator that points before the + * first element in the %forward_list. Iteration is done in ordinary + * element order. + */ + const_iterator + cbefore_begin() const noexcept + { return const_iterator(&this->_M_impl._M_head); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %forward_list. Iteration is done in + * ordinary element order. + */ + const_iterator + cend() const noexcept + { return const_iterator(nullptr); } + + /** + * Returns true if the %forward_list is empty. (Thus begin() would + * equal end().) + */ + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return this->_M_impl._M_head._M_next == nullptr; } + + /** + * Returns the largest possible number of elements of %forward_list. + */ + size_type + max_size() const noexcept + { return _Node_alloc_traits::max_size(this->_M_get_Node_allocator()); } + + // 23.3.4.4 element access: + + /** + * Returns a read/write reference to the data at the first + * element of the %forward_list. + */ + reference + front() + { + _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next); + return *__front->_M_valptr(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %forward_list. + */ + const_reference + front() const + { + _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next); + return *__front->_M_valptr(); + } + + // 23.3.4.5 modifiers: + + /** + * @brief Constructs object in %forward_list at the front of the + * list. + * @param __args Arguments. + * + * This function will insert an object of type Tp constructed + * with Tp(std::forward(args)...) at the front of the list + * Due to the nature of a %forward_list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args) + { + this->_M_insert_after(cbefore_begin(), + std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return front(); +#endif + } + + /** + * @brief Add data to the front of the %forward_list. + * @param __val Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %forward_list and assigns the given + * data to it. Due to the nature of a %forward_list this operation + * can be done in constant time, and does not invalidate iterators + * and references. + */ + void + push_front(const _Tp& __val) + { this->_M_insert_after(cbefore_begin(), __val); } + + /** + * + */ + void + push_front(_Tp&& __val) + { this->_M_insert_after(cbefore_begin(), std::move(__val)); } + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %forward_list + * by one. Due to the nature of a %forward_list this operation can + * be done in constant time, and only invalidates iterators/references + * to the element being removed. + * + * Note that no data is returned, and if the first element's data + * is needed, it should be retrieved before pop_front() is + * called. + */ + void + pop_front() + { this->_M_erase_after(&this->_M_impl._M_head); } + + /** + * @brief Constructs object in %forward_list after the specified + * iterator. + * @param __pos A const_iterator into the %forward_list. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) after the specified + * location. Due to the nature of a %forward_list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template + iterator + emplace_after(const_iterator __pos, _Args&&... __args) + { return iterator(this->_M_insert_after(__pos, + std::forward<_Args>(__args)...)); } + + /** + * @brief Inserts given value into %forward_list after specified + * iterator. + * @param __pos An iterator into the %forward_list. + * @param __val Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value after + * the specified location. Due to the nature of a %forward_list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, const _Tp& __val) + { return iterator(this->_M_insert_after(__pos, __val)); } + + /** + * + */ + iterator + insert_after(const_iterator __pos, _Tp&& __val) + { return iterator(this->_M_insert_after(__pos, std::move(__val))); } + + /** + * @brief Inserts a number of copies of given data into the + * %forward_list. + * @param __pos An iterator into the %forward_list. + * @param __n Number of elements to be inserted. + * @param __val Data to be inserted. + * @return An iterator pointing to the last inserted copy of + * @a val or @a pos if @a n == 0. + * + * This function will insert a specified number of copies of the + * given data after the location specified by @a pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, size_type __n, const _Tp& __val); + + /** + * @brief Inserts a range into the %forward_list. + * @param __pos An iterator into the %forward_list. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator pointing to the last inserted element or + * @a __pos if @a __first == @a __last. + * + * This function will insert copies of the data in the range + * [@a __first,@a __last) into the %forward_list after the + * location specified by @a __pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template> + iterator + insert_after(const_iterator __pos, + _InputIterator __first, _InputIterator __last); + + /** + * @brief Inserts the contents of an initializer_list into + * %forward_list after the specified iterator. + * @param __pos An iterator into the %forward_list. + * @param __il An initializer_list of value_type. + * @return An iterator pointing to the last inserted element + * or @a __pos if @a __il is empty. + * + * This function will insert copies of the data in the + * initializer_list @a __il into the %forward_list before the location + * specified by @a __pos. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) + { return insert_after(__pos, __il.begin(), __il.end()); } + + /** + * @brief Removes the element pointed to by the iterator following + * @c pos. + * @param __pos Iterator pointing before element to be erased. + * @return An iterator pointing to the element following the one + * that was erased, or end() if no such element exists. + * + * This function will erase the element at the given position and + * thus shorten the %forward_list by one. + * + * Due to the nature of a %forward_list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. The user is also cautioned that + * this function only erases the element, and that if the element + * is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase_after(const_iterator __pos) + { return iterator(this->_M_erase_after(const_cast<_Node_base*> + (__pos._M_node))); } + + /** + * @brief Remove a range of elements. + * @param __pos Iterator pointing before the first element to be + * erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return @ __last. + * + * This function will erase the elements in the range + * @a (__pos,__last) and shorten the %forward_list accordingly. + * + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + iterator + erase_after(const_iterator __pos, const_iterator __last) + { return iterator(this->_M_erase_after(const_cast<_Node_base*> + (__pos._M_node), + const_cast<_Node_base*> + (__last._M_node))); } + + /** + * @brief Swaps data with another %forward_list. + * @param __list A %forward_list of the same element and allocator + * types. + * + * This exchanges the elements between two lists in constant + * time. Note that the global std::swap() function is + * specialized such that std::swap(l1,l2) will feed to this + * function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(forward_list& __list) noexcept + { + std::swap(this->_M_impl._M_head._M_next, + __list._M_impl._M_head._M_next); + _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(), + __list._M_get_Node_allocator()); + } + + /** + * @brief Resizes the %forward_list to the specified number of + * elements. + * @param __sz Number of elements the %forward_list should contain. + * + * This function will %resize the %forward_list to the specified + * number of elements. If the number is smaller than the + * %forward_list's current number of elements the %forward_list + * is truncated, otherwise the %forward_list is extended and the + * new elements are default constructed. + */ + void + resize(size_type __sz); + + /** + * @brief Resizes the %forward_list to the specified number of + * elements. + * @param __sz Number of elements the %forward_list should contain. + * @param __val Data with which new elements should be populated. + * + * This function will %resize the %forward_list to the specified + * number of elements. If the number is smaller than the + * %forward_list's current number of elements the %forward_list + * is truncated, otherwise the %forward_list is extended and new + * elements are populated with given data. + */ + void + resize(size_type __sz, const value_type& __val); + + /** + * @brief Erases all the elements. + * + * Note that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { this->_M_erase_after(&this->_M_impl._M_head, nullptr); } + + // 23.3.4.6 forward_list operations: + + /** + * @brief Insert contents of another %forward_list. + * @param __pos Iterator referencing the element to insert after. + * @param __list Source list. + * + * The elements of @a list are inserted in constant time after + * the element referenced by @a pos. @a list becomes an empty + * list. + * + * Requires this != @a x. + */ + void + splice_after(const_iterator __pos, forward_list&& __list) noexcept + { + if (!__list.empty()) + _M_splice_after(__pos, __list.before_begin(), __list.end()); + } + + void + splice_after(const_iterator __pos, forward_list& __list) noexcept + { splice_after(__pos, std::move(__list)); } + + /** + * @brief Insert element from another %forward_list. + * @param __pos Iterator referencing the element to insert after. + * @param __list Source list. + * @param __i Iterator referencing the element before the element + * to move. + * + * Removes the element in list @a list referenced by @a i and + * inserts it into the current list after @a pos. + */ + void + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __i) noexcept; + + void + splice_after(const_iterator __pos, forward_list& __list, + const_iterator __i) noexcept + { splice_after(__pos, std::move(__list), __i); } + + /** + * @brief Insert range from another %forward_list. + * @param __pos Iterator referencing the element to insert after. + * @param __list Source list. + * @param __before Iterator referencing before the start of range + * in list. + * @param __last Iterator referencing the end of range in list. + * + * Removes elements in the range (__before,__last) and inserts them + * after @a __pos in constant time. + * + * Undefined if @a __pos is in (__before,__last). + * @{ + */ + void + splice_after(const_iterator __pos, forward_list&&, + const_iterator __before, const_iterator __last) noexcept + { _M_splice_after(__pos, __before, __last); } + + void + splice_after(const_iterator __pos, forward_list&, + const_iterator __before, const_iterator __last) noexcept + { _M_splice_after(__pos, __before, __last); } + /// @} + + private: +#if __cplusplus > 201703L +# define __cpp_lib_list_remove_return_type 201806L + using __remove_return_type = size_type; +# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG \ + __attribute__((__abi_tag__("__cxx20"))) +#else + using __remove_return_type = void; +# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG +#endif + public: + + /** + * @brief Remove all elements equal to value. + * @param __val The value to remove. + * + * Removes every element in the list equal to @a __val. + * Remaining elements stay in list order. Note that this + * function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + remove(const _Tp& __val); + + /** + * @brief Remove all elements satisfying a predicate. + * @param __pred Unary predicate function or object. + * + * Removes every element in the list for which the predicate + * returns true. Remaining elements stay in list order. Note + * that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + template + __remove_return_type + remove_if(_Pred __pred); + + /** + * @brief Remove consecutive duplicate elements. + * + * For each consecutive set of elements with the same value, + * remove all but the first one. Remaining elements stay in + * list order. Note that this function only erases the + * elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + unique() + { return unique(std::equal_to<_Tp>()); } + +#undef _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + + /** + * @brief Remove consecutive elements satisfying a predicate. + * @param __binary_pred Binary predicate function or object. + * + * For each consecutive set of elements [first,last) that + * satisfy predicate(first,i) where i is an iterator in + * [first,last), remove all but the first one. Remaining + * elements stay in list order. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + template + __remove_return_type + unique(_BinPred __binary_pred); + + /** + * @brief Merge sorted lists. + * @param __list Sorted list to merge. + * + * Assumes that both @a list and this list are sorted according to + * operator<(). Merges elements of @a __list into this list in + * sorted order, leaving @a __list empty when complete. Elements in + * this list precede elements in @a __list that are equal. + */ + void + merge(forward_list&& __list) + { merge(std::move(__list), std::less<_Tp>()); } + + void + merge(forward_list& __list) + { merge(std::move(__list)); } + + /** + * @brief Merge sorted lists according to comparison function. + * @param __list Sorted list to merge. + * @param __comp Comparison function defining sort order. + * + * Assumes that both @a __list and this list are sorted according to + * comp. Merges elements of @a __list into this list + * in sorted order, leaving @a __list empty when complete. Elements + * in this list precede elements in @a __list that are equivalent + * according to comp(). + */ + template + void + merge(forward_list&& __list, _Comp __comp); + + template + void + merge(forward_list& __list, _Comp __comp) + { merge(std::move(__list), __comp); } + + /** + * @brief Sort the elements of the list. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + void + sort() + { sort(std::less<_Tp>()); } + + /** + * @brief Sort the forward_list using a comparison function. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + template + void + sort(_Comp __comp); + + /** + * @brief Reverse the elements in list. + * + * Reverse the order of elements in the list in linear time. + */ + void + reverse() noexcept + { this->_M_impl._M_head._M_reverse_after(); } + + private: + // Called by the range constructor to implement [23.3.4.2]/9 + template + void + _M_range_initialize(_InputIterator __first, _InputIterator __last); + + // Called by forward_list(n,v,a), and the range constructor when it + // turns out to be the same thing. + void + _M_fill_initialize(size_type __n, const value_type& __value); + + // Called by splice_after and insert_after. + iterator + _M_splice_after(const_iterator __pos, const_iterator __before, + const_iterator __last); + + // Called by forward_list(n). + void + _M_default_initialize(size_type __n); + + // Called by resize(sz). + void + _M_default_insert_after(const_iterator __pos, size_type __n); + + // Called by operator=(forward_list&&) + void + _M_move_assign(forward_list&& __list, true_type) noexcept + { + clear(); + this->_M_impl._M_head._M_next = __list._M_impl._M_head._M_next; + __list._M_impl._M_head._M_next = nullptr; + std::__alloc_on_move(this->_M_get_Node_allocator(), + __list._M_get_Node_allocator()); + } + + // Called by operator=(forward_list&&) + void + _M_move_assign(forward_list&& __list, false_type) + { + if (__list._M_get_Node_allocator() == this->_M_get_Node_allocator()) + _M_move_assign(std::move(__list), true_type()); + else + // The rvalue's allocator cannot be moved, or is not equal, + // so we need to individually move each element. + this->assign(std::make_move_iterator(__list.begin()), + std::make_move_iterator(__list.end())); + } + + // Called by assign(_InputIterator, _InputIterator) if _Tp is + // CopyAssignable. + template + void + _M_assign(_InputIterator __first, _InputIterator __last, true_type) + { + auto __prev = before_begin(); + auto __curr = begin(); + auto __end = end(); + while (__curr != __end && __first != __last) + { + *__curr = *__first; + ++__prev; + ++__curr; + ++__first; + } + if (__first != __last) + insert_after(__prev, __first, __last); + else if (__curr != __end) + erase_after(__prev, __end); + } + + // Called by assign(_InputIterator, _InputIterator) if _Tp is not + // CopyAssignable. + template + void + _M_assign(_InputIterator __first, _InputIterator __last, false_type) + { + clear(); + insert_after(cbefore_begin(), __first, __last); + } + + // Called by assign(size_type, const _Tp&) if Tp is CopyAssignable + void + _M_assign_n(size_type __n, const _Tp& __val, true_type) + { + auto __prev = before_begin(); + auto __curr = begin(); + auto __end = end(); + while (__curr != __end && __n > 0) + { + *__curr = __val; + ++__prev; + ++__curr; + --__n; + } + if (__n > 0) + insert_after(__prev, __n, __val); + else if (__curr != __end) + erase_after(__prev, __end); + } + + // Called by assign(size_type, const _Tp&) if Tp is non-CopyAssignable + void + _M_assign_n(size_type __n, const _Tp& __val, false_type) + { + clear(); + insert_after(cbefore_begin(), __n, __val); + } + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> forward_list<_ValT, _Allocator>; +#endif + + /** + * @brief Forward list equality comparison. + * @param __lx A %forward_list + * @param __ly A %forward_list of the same type as @a __lx. + * @return True iff the elements of the forward lists are equal. + * + * This is an equivalence relation. It is linear in the number of + * elements of the forward lists. Deques are considered equivalent + * if corresponding elements compare equal. + */ + template + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly); + +#if __cpp_lib_three_way_comparison + /** + * @brief Forward list ordering relation. + * @param __x A `forward_list`. + * @param __y A `forward_list` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Tp> + operator<=>(const forward_list<_Tp, _Alloc>& __x, + const forward_list<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief Forward list ordering relation. + * @param __lx A %forward_list. + * @param __ly A %forward_list of the same type as @a __lx. + * @return True iff @a __lx is lexicographically less than @a __ly. + * + * This is a total ordering relation. It is linear in the number of + * elements of the forward lists. The elements must be comparable + * with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return std::lexicographical_compare(__lx.cbegin(), __lx.cend(), + __ly.cbegin(), __ly.cend()); } + + /// Based on operator== + template + inline bool + operator!=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx == __ly); } + + /// Based on operator< + template + inline bool + operator>(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return (__ly < __lx); } + + /// Based on operator< + template + inline bool + operator>=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx < __ly); } + + /// Based on operator< + template + inline bool + operator<=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__ly < __lx); } +#endif // three-way comparison + + /// See std::forward_list::swap(). + template + inline void + swap(forward_list<_Tp, _Alloc>& __lx, + forward_list<_Tp, _Alloc>& __ly) + noexcept(noexcept(__lx.swap(__ly))) + { __lx.swap(__ly); } + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _FORWARD_LIST_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/forward_list.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/forward_list.tcc new file mode 100755 index 0000000..bd7a859 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/forward_list.tcc @@ -0,0 +1,512 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/forward_list.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{forward_list} + */ + +#ifndef _FORWARD_LIST_TCC +#define _FORWARD_LIST_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + _Fwd_list_base<_Tp, _Alloc>:: + _Fwd_list_base(_Fwd_list_base&& __lst, _Node_alloc_type&& __a) + : _M_impl(std::move(__a)) + { + if (__lst._M_get_Node_allocator() == _M_get_Node_allocator()) + this->_M_impl._M_head = std::move(__lst._M_impl._M_head); + } + + template + template + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_insert_after(const_iterator __pos, _Args&&... __args) + { + _Fwd_list_node_base* __to + = const_cast<_Fwd_list_node_base*>(__pos._M_node); + _Node* __thing = _M_create_node(std::forward<_Args>(__args)...); + __thing->_M_next = __to->_M_next; + __to->_M_next = __thing; + return __to->_M_next; + } + + template + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_erase_after(_Fwd_list_node_base* __pos) + { + _Node* __curr = static_cast<_Node*>(__pos->_M_next); + __pos->_M_next = __curr->_M_next; + _Node_alloc_traits::destroy(_M_get_Node_allocator(), + __curr->_M_valptr()); + __curr->~_Node(); + _M_put_node(__curr); + return __pos->_M_next; + } + + template + _Fwd_list_node_base* + _Fwd_list_base<_Tp, _Alloc>:: + _M_erase_after(_Fwd_list_node_base* __pos, + _Fwd_list_node_base* __last) + { + _Node* __curr = static_cast<_Node*>(__pos->_M_next); + while (__curr != __last) + { + _Node* __temp = __curr; + __curr = static_cast<_Node*>(__curr->_M_next); + _Node_alloc_traits::destroy(_M_get_Node_allocator(), + __temp->_M_valptr()); + __temp->~_Node(); + _M_put_node(__temp); + } + __pos->_M_next = __last; + return __last; + } + + // Called by the range constructor to implement [23.3.4.2]/9 + template + template + void + forward_list<_Tp, _Alloc>:: + _M_range_initialize(_InputIterator __first, _InputIterator __last) + { + _Node_base* __to = &this->_M_impl._M_head; + for (; __first != __last; ++__first) + { + __to->_M_next = this->_M_create_node(*__first); + __to = __to->_M_next; + } + } + + // Called by forward_list(n,v,a). + template + void + forward_list<_Tp, _Alloc>:: + _M_fill_initialize(size_type __n, const value_type& __value) + { + _Node_base* __to = &this->_M_impl._M_head; + for (; __n; --__n) + { + __to->_M_next = this->_M_create_node(__value); + __to = __to->_M_next; + } + } + + template + void + forward_list<_Tp, _Alloc>:: + _M_default_initialize(size_type __n) + { + _Node_base* __to = &this->_M_impl._M_head; + for (; __n; --__n) + { + __to->_M_next = this->_M_create_node(); + __to = __to->_M_next; + } + } + + template + forward_list<_Tp, _Alloc>& + forward_list<_Tp, _Alloc>:: + operator=(const forward_list& __list) + { + if (std::__addressof(__list) != this) + { + if (_Node_alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_get_Node_allocator(); + auto& __that_alloc = __list._M_get_Node_allocator(); + if (!_Node_alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // replacement allocator cannot free existing storage + clear(); + } + std::__alloc_on_copy(__this_alloc, __that_alloc); + } + assign(__list.cbegin(), __list.cend()); + } + return *this; + } + + template + void + forward_list<_Tp, _Alloc>:: + _M_default_insert_after(const_iterator __pos, size_type __n) + { + const_iterator __saved_pos = __pos; + __try + { + for (; __n; --__n) + __pos = emplace_after(__pos); + } + __catch(...) + { + erase_after(__saved_pos, ++__pos); + __throw_exception_again; + } + } + + template + void + forward_list<_Tp, _Alloc>:: + resize(size_type __sz) + { + iterator __k = before_begin(); + + size_type __len = 0; + while (__k._M_next() != end() && __len < __sz) + { + ++__k; + ++__len; + } + if (__len == __sz) + erase_after(__k, end()); + else + _M_default_insert_after(__k, __sz - __len); + } + + template + void + forward_list<_Tp, _Alloc>:: + resize(size_type __sz, const value_type& __val) + { + iterator __k = before_begin(); + + size_type __len = 0; + while (__k._M_next() != end() && __len < __sz) + { + ++__k; + ++__len; + } + if (__len == __sz) + erase_after(__k, end()); + else + insert_after(__k, __sz - __len, __val); + } + + template + typename forward_list<_Tp, _Alloc>::iterator + forward_list<_Tp, _Alloc>:: + _M_splice_after(const_iterator __pos, + const_iterator __before, const_iterator __last) + { + _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node); + _Node_base* __b = const_cast<_Node_base*>(__before._M_node); + _Node_base* __end = __b; + + while (__end && __end->_M_next != __last._M_node) + __end = __end->_M_next; + + if (__b != __end) + return iterator(__tmp->_M_transfer_after(__b, __end)); + else + return iterator(__tmp); + } + + template + void + forward_list<_Tp, _Alloc>:: + splice_after(const_iterator __pos, forward_list&&, + const_iterator __i) noexcept + { + const_iterator __j = __i; + ++__j; + + if (__pos == __i || __pos == __j) + return; + + _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node); + __tmp->_M_transfer_after(const_cast<_Node_base*>(__i._M_node), + const_cast<_Node_base*>(__j._M_node)); + } + + template + typename forward_list<_Tp, _Alloc>::iterator + forward_list<_Tp, _Alloc>:: + insert_after(const_iterator __pos, size_type __n, const _Tp& __val) + { + if (__n) + { + forward_list __tmp(__n, __val, get_allocator()); + return _M_splice_after(__pos, __tmp.before_begin(), __tmp.end()); + } + else + return iterator(const_cast<_Node_base*>(__pos._M_node)); + } + + template + template + typename forward_list<_Tp, _Alloc>::iterator + forward_list<_Tp, _Alloc>:: + insert_after(const_iterator __pos, + _InputIterator __first, _InputIterator __last) + { + forward_list __tmp(__first, __last, get_allocator()); + if (!__tmp.empty()) + return _M_splice_after(__pos, __tmp.before_begin(), __tmp.end()); + else + return iterator(const_cast<_Node_base*>(__pos._M_node)); + } + +#if __cplusplus > 201703L +# define _GLIBCXX20_ONLY(__expr) __expr +#else +# define _GLIBCXX20_ONLY(__expr) +#endif + + template + auto + forward_list<_Tp, _Alloc>:: + remove(const _Tp& __val) -> __remove_return_type + { + size_type __removed __attribute__((__unused__)) = 0; + forward_list __to_destroy(get_allocator()); + + auto __prev_it = cbefore_begin(); + while (_Node* __tmp = static_cast<_Node*>(__prev_it._M_node->_M_next)) + if (*__tmp->_M_valptr() == __val) + { + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + *this, __prev_it); + _GLIBCXX20_ONLY( __removed++ ); + } + else + ++__prev_it; + + return _GLIBCXX20_ONLY( __removed ); + } + + template + template + auto + forward_list<_Tp, _Alloc>:: + remove_if(_Pred __pred) -> __remove_return_type + { + size_type __removed __attribute__((__unused__)) = 0; + forward_list __to_destroy(get_allocator()); + + auto __prev_it = cbefore_begin(); + while (_Node* __tmp = static_cast<_Node*>(__prev_it._M_node->_M_next)) + if (__pred(*__tmp->_M_valptr())) + { + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + *this, __prev_it); + _GLIBCXX20_ONLY( __removed++ ); + } + else + ++__prev_it; + + return _GLIBCXX20_ONLY( __removed ); + } + + template + template + auto + forward_list<_Tp, _Alloc>:: + unique(_BinPred __binary_pred) -> __remove_return_type + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return _GLIBCXX20_ONLY(0); + + forward_list __to_destroy(get_allocator()); + size_type __removed __attribute__((__unused__)) = 0; + iterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(*__first, *__next)) + { + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + *this, __first); + _GLIBCXX20_ONLY( __removed++ ); + } + else + __first = __next; + __next = __first; + } + + return _GLIBCXX20_ONLY( __removed ); + } + +#undef _GLIBCXX20_ONLY + + template + template + void + forward_list<_Tp, _Alloc>:: + merge(forward_list&& __list, _Comp __comp) + { + _Node_base* __node = &this->_M_impl._M_head; + while (__node->_M_next && __list._M_impl._M_head._M_next) + { + if (__comp(*static_cast<_Node*> + (__list._M_impl._M_head._M_next)->_M_valptr(), + *static_cast<_Node*> + (__node->_M_next)->_M_valptr())) + __node->_M_transfer_after(&__list._M_impl._M_head, + __list._M_impl._M_head._M_next); + __node = __node->_M_next; + } + + if (__list._M_impl._M_head._M_next) + *__node = std::move(__list._M_impl._M_head); + } + + template + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { + // We don't have size() so we need to walk through both lists + // making sure both iterators are valid. + auto __ix = __lx.cbegin(); + auto __iy = __ly.cbegin(); + while (__ix != __lx.cend() && __iy != __ly.cend()) + { + if (!(*__ix == *__iy)) + return false; + ++__ix; + ++__iy; + } + if (__ix == __lx.cend() && __iy == __ly.cend()) + return true; + else + return false; + } + + template + template + void + forward_list<_Tp, _Alloc>:: + sort(_Comp __comp) + { + // If `next' is nullptr, return immediately. + _Node* __list = static_cast<_Node*>(this->_M_impl._M_head._M_next); + if (!__list) + return; + + unsigned long __insize = 1; + + while (1) + { + _Node* __p = __list; + __list = nullptr; + _Node* __tail = nullptr; + + // Count number of merges we do in this pass. + unsigned long __nmerges = 0; + + while (__p) + { + ++__nmerges; + // There exists a merge to be done. + // Step `insize' places along from p. + _Node* __q = __p; + unsigned long __psize = 0; + for (unsigned long __i = 0; __i < __insize; ++__i) + { + ++__psize; + __q = static_cast<_Node*>(__q->_M_next); + if (!__q) + break; + } + + // If q hasn't fallen off end, we have two lists to merge. + unsigned long __qsize = __insize; + + // Now we have two lists; merge them. + while (__psize > 0 || (__qsize > 0 && __q)) + { + // Decide whether next node of merge comes from p or q. + _Node* __e; + if (__psize == 0) + { + // p is empty; e must come from q. + __e = __q; + __q = static_cast<_Node*>(__q->_M_next); + --__qsize; + } + else if (__qsize == 0 || !__q) + { + // q is empty; e must come from p. + __e = __p; + __p = static_cast<_Node*>(__p->_M_next); + --__psize; + } + else if (!__comp(*__q->_M_valptr(), *__p->_M_valptr())) + { + // First node of q is not lower; e must come from p. + __e = __p; + __p = static_cast<_Node*>(__p->_M_next); + --__psize; + } + else + { + // First node of q is lower; e must come from q. + __e = __q; + __q = static_cast<_Node*>(__q->_M_next); + --__qsize; + } + + // Add the next node to the merged list. + if (__tail) + __tail->_M_next = __e; + else + __list = __e; + __tail = __e; + } + + // Now p has stepped `insize' places along, and q has too. + __p = __q; + } + __tail->_M_next = nullptr; + + // If we have done only one merge, we're finished. + // Allow for nmerges == 0, the empty list case. + if (__nmerges <= 1) + { + this->_M_impl._M_head._M_next = __list; + return; + } + + // Otherwise repeat, merging lists twice the size. + __insize *= 2; + } + } + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _FORWARD_LIST_TCC */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_dir.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_dir.h new file mode 100755 index 0000000..2674ca6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_dir.h @@ -0,0 +1,576 @@ +// Filesystem directory utilities -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/fs_dir.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{filesystem} + */ + +#ifndef _GLIBCXX_FS_DIR_H +#define _GLIBCXX_FS_DIR_H 1 + +#if __cplusplus >= 201703L +# include +# include +# include +# include + +#if __cplusplus > 201703L +# include // std::strong_ordering +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace filesystem +{ + /** @addtogroup filesystem + * @{ + */ + + /// Information about a file's type and permissions. + class file_status + { + public: + // constructors and destructor + file_status() noexcept : file_status(file_type::none) {} + + explicit + file_status(file_type __ft, perms __prms = perms::unknown) noexcept + : _M_type(__ft), _M_perms(__prms) { } + + file_status(const file_status&) noexcept = default; + file_status(file_status&&) noexcept = default; + ~file_status() = default; + + file_status& operator=(const file_status&) noexcept = default; + file_status& operator=(file_status&&) noexcept = default; + + // observers + file_type type() const noexcept { return _M_type; } + perms permissions() const noexcept { return _M_perms; } + + // modifiers + void type(file_type __ft) noexcept { _M_type = __ft; } + void permissions(perms __prms) noexcept { _M_perms = __prms; } + +#if __cpp_lib_three_way_comparison + friend bool + operator==(const file_status&, const file_status&) noexcept = default; +#endif + + private: + file_type _M_type; + perms _M_perms; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + struct _Dir; + class directory_iterator; + class recursive_directory_iterator; + + /// The value type used by directory iterators + class directory_entry + { + public: + // constructors and destructor + directory_entry() noexcept = default; + directory_entry(const directory_entry&) = default; + directory_entry(directory_entry&&) noexcept = default; + + explicit + directory_entry(const filesystem::path& __p) + : _M_path(__p) + { refresh(); } + + directory_entry(const filesystem::path& __p, error_code& __ec) + : _M_path(__p) + { + refresh(__ec); + if (__ec) + _M_path.clear(); + } + + ~directory_entry() = default; + + // modifiers + directory_entry& operator=(const directory_entry&) = default; + directory_entry& operator=(directory_entry&&) noexcept = default; + + void + assign(const filesystem::path& __p) + { + _M_path = __p; + refresh(); + } + + void + assign(const filesystem::path& __p, error_code& __ec) + { + _M_path = __p; + refresh(__ec); + } + + void + replace_filename(const filesystem::path& __p) + { + _M_path.replace_filename(__p); + refresh(); + } + + void + replace_filename(const filesystem::path& __p, error_code& __ec) + { + _M_path.replace_filename(__p); + refresh(__ec); + } + + void + refresh() + { _M_type = symlink_status().type(); } + + void + refresh(error_code& __ec) noexcept + { _M_type = symlink_status(__ec).type(); } + + // observers + const filesystem::path& path() const noexcept { return _M_path; } + operator const filesystem::path& () const noexcept { return _M_path; } + + bool + exists() const + { return filesystem::exists(file_status{_M_file_type()}); } + + bool + exists(error_code& __ec) const noexcept + { return filesystem::exists(file_status{_M_file_type(__ec)}); } + + bool + is_block_file() const + { return _M_file_type() == file_type::block; } + + bool + is_block_file(error_code& __ec) const noexcept + { return _M_file_type(__ec) == file_type::block; } + + bool + is_character_file() const + { return _M_file_type() == file_type::character; } + + bool + is_character_file(error_code& __ec) const noexcept + { return _M_file_type(__ec) == file_type::character; } + + bool + is_directory() const + { return _M_file_type() == file_type::directory; } + + bool + is_directory(error_code& __ec) const noexcept + { return _M_file_type(__ec) == file_type::directory; } + + bool + is_fifo() const + { return _M_file_type() == file_type::fifo; } + + bool + is_fifo(error_code& __ec) const noexcept + { return _M_file_type(__ec) == file_type::fifo; } + + bool + is_other() const + { return filesystem::is_other(file_status{_M_file_type()}); } + + bool + is_other(error_code& __ec) const noexcept + { return filesystem::is_other(file_status{_M_file_type(__ec)}); } + + bool + is_regular_file() const + { return _M_file_type() == file_type::regular; } + + bool + is_regular_file(error_code& __ec) const noexcept + { return _M_file_type(__ec) == file_type::regular; } + + bool + is_socket() const + { return _M_file_type() == file_type::socket; } + + bool + is_socket(error_code& __ec) const noexcept + { return _M_file_type(__ec) == file_type::socket; } + + bool + is_symlink() const + { + if (_M_type != file_type::none) + return _M_type == file_type::symlink; + return symlink_status().type() == file_type::symlink; + } + + bool + is_symlink(error_code& __ec) const noexcept + { + if (_M_type != file_type::none) + return _M_type == file_type::symlink; + return symlink_status(__ec).type() == file_type::symlink; + } + + uintmax_t + file_size() const + { return filesystem::file_size(_M_path); } + + uintmax_t + file_size(error_code& __ec) const noexcept + { return filesystem::file_size(_M_path, __ec); } + + uintmax_t + hard_link_count() const + { return filesystem::hard_link_count(_M_path); } + + uintmax_t + hard_link_count(error_code& __ec) const noexcept + { return filesystem::hard_link_count(_M_path, __ec); } + + file_time_type + last_write_time() const + { return filesystem::last_write_time(_M_path); } + + + file_time_type + last_write_time(error_code& __ec) const noexcept + { return filesystem::last_write_time(_M_path, __ec); } + + file_status + status() const + { return filesystem::status(_M_path); } + + file_status + status(error_code& __ec) const noexcept + { return filesystem::status(_M_path, __ec); } + + file_status + symlink_status() const + { return filesystem::symlink_status(_M_path); } + + file_status + symlink_status(error_code& __ec) const noexcept + { return filesystem::symlink_status(_M_path, __ec); } + + bool + operator==(const directory_entry& __rhs) const noexcept + { return _M_path == __rhs._M_path; } + +#if __cpp_lib_three_way_comparison + strong_ordering + operator<=>(const directory_entry& __rhs) const noexcept + { return _M_path <=> __rhs._M_path; } +#else + bool + operator!=(const directory_entry& __rhs) const noexcept + { return _M_path != __rhs._M_path; } + + bool + operator< (const directory_entry& __rhs) const noexcept + { return _M_path < __rhs._M_path; } + + bool + operator<=(const directory_entry& __rhs) const noexcept + { return _M_path <= __rhs._M_path; } + + bool + operator> (const directory_entry& __rhs) const noexcept + { return _M_path > __rhs._M_path; } + + bool + operator>=(const directory_entry& __rhs) const noexcept + { return _M_path >= __rhs._M_path; } +#endif + + private: + friend struct _Dir; + friend class directory_iterator; + friend class recursive_directory_iterator; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3171. LWG 2989 breaks directory_entry stream insertion + template + friend basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, + const directory_entry& __d) + { return __os << __d.path(); } + + directory_entry(const filesystem::path& __p, file_type __t) + : _M_path(__p), _M_type(__t) + { } + + // Equivalent to status().type() but uses cached value, if any. + file_type + _M_file_type() const + { + if (_M_type != file_type::none && _M_type != file_type::symlink) + return _M_type; + return status().type(); + } + + // Equivalent to status(__ec).type() but uses cached value, if any. + file_type + _M_file_type(error_code& __ec) const noexcept + { + if (_M_type != file_type::none && _M_type != file_type::symlink) + { + __ec.clear(); + return _M_type; + } + return status(__ec).type(); + } + + filesystem::path _M_path; + file_type _M_type = file_type::none; + }; + + /// Proxy returned by post-increment on directory iterators. + struct __directory_iterator_proxy + { + const directory_entry& operator*() const& noexcept { return _M_entry; } + + directory_entry operator*() && noexcept { return std::move(_M_entry); } + + private: + friend class directory_iterator; + friend class recursive_directory_iterator; + + explicit + __directory_iterator_proxy(const directory_entry& __e) : _M_entry(__e) { } + + directory_entry _M_entry; + }; + + /// Iterator type for traversing the entries in a single directory. + class directory_iterator + { + public: + typedef directory_entry value_type; + typedef ptrdiff_t difference_type; + typedef const directory_entry* pointer; + typedef const directory_entry& reference; + typedef input_iterator_tag iterator_category; + + directory_iterator() = default; + + explicit + directory_iterator(const path& __p) + : directory_iterator(__p, directory_options::none, nullptr) { } + + directory_iterator(const path& __p, directory_options __options) + : directory_iterator(__p, __options, nullptr) { } + + directory_iterator(const path& __p, error_code& __ec) + : directory_iterator(__p, directory_options::none, __ec) { } + + directory_iterator(const path& __p, directory_options __options, + error_code& __ec) + : directory_iterator(__p, __options, &__ec) { } + + directory_iterator(const directory_iterator& __rhs) = default; + + directory_iterator(directory_iterator&& __rhs) noexcept = default; + + ~directory_iterator() = default; + + directory_iterator& + operator=(const directory_iterator& __rhs) = default; + + directory_iterator& + operator=(directory_iterator&& __rhs) noexcept = default; + + const directory_entry& operator*() const noexcept; + const directory_entry* operator->() const noexcept { return &**this; } + directory_iterator& operator++(); + directory_iterator& increment(error_code& __ec); + + __directory_iterator_proxy operator++(int) + { + __directory_iterator_proxy __pr{**this}; + ++*this; + return __pr; + } + + private: + directory_iterator(const path&, directory_options, error_code*); + + friend bool + operator==(const directory_iterator& __lhs, + const directory_iterator& __rhs) noexcept + { + return !__rhs._M_dir.owner_before(__lhs._M_dir) + && !__lhs._M_dir.owner_before(__rhs._M_dir); + } + + friend bool + operator!=(const directory_iterator& __lhs, + const directory_iterator& __rhs) noexcept + { return !(__lhs == __rhs); } + + friend class recursive_directory_iterator; + + std::__shared_ptr<_Dir> _M_dir; + }; + + /// @relates std::filesystem::directory_iterator @{ + + /** @brief Enable range-based `for` using directory_iterator. + * + * e.g. `for (auto& entry : std::filesystem::directory_iterator(".")) ...` + */ + inline directory_iterator + begin(directory_iterator __iter) noexcept + { return __iter; } + + /// Return a past-the-end directory_iterator + inline directory_iterator + end(directory_iterator) noexcept + { return directory_iterator(); } + /// @} + + /// Iterator type for recursively traversing a directory hierarchy. + class recursive_directory_iterator + { + public: + typedef directory_entry value_type; + typedef ptrdiff_t difference_type; + typedef const directory_entry* pointer; + typedef const directory_entry& reference; + typedef input_iterator_tag iterator_category; + + recursive_directory_iterator() = default; + + explicit + recursive_directory_iterator(const path& __p) + : recursive_directory_iterator(__p, directory_options::none, nullptr) { } + + recursive_directory_iterator(const path& __p, directory_options __options) + : recursive_directory_iterator(__p, __options, nullptr) { } + + recursive_directory_iterator(const path& __p, directory_options __options, + error_code& __ec) + : recursive_directory_iterator(__p, __options, &__ec) { } + + recursive_directory_iterator(const path& __p, error_code& __ec) + : recursive_directory_iterator(__p, directory_options::none, &__ec) { } + + recursive_directory_iterator( + const recursive_directory_iterator&) = default; + + recursive_directory_iterator(recursive_directory_iterator&&) = default; + + ~recursive_directory_iterator(); + + // observers + directory_options options() const noexcept; + int depth() const noexcept; + bool recursion_pending() const noexcept; + + const directory_entry& operator*() const noexcept; + const directory_entry* operator->() const noexcept { return &**this; } + + // modifiers + recursive_directory_iterator& + operator=(const recursive_directory_iterator& __rhs) noexcept; + recursive_directory_iterator& + operator=(recursive_directory_iterator&& __rhs) noexcept; + + recursive_directory_iterator& operator++(); + recursive_directory_iterator& increment(error_code& __ec); + + __directory_iterator_proxy operator++(int) + { + __directory_iterator_proxy __pr{**this}; + ++*this; + return __pr; + } + + void pop(); + void pop(error_code&); + + void disable_recursion_pending() noexcept; + + private: + recursive_directory_iterator(const path&, directory_options, error_code*); + + friend bool + operator==(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) noexcept + { + return !__rhs._M_dirs.owner_before(__lhs._M_dirs) + && !__lhs._M_dirs.owner_before(__rhs._M_dirs); + } + + friend bool + operator!=(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) noexcept + { return !(__lhs == __rhs); } + + struct _Dir_stack; + std::__shared_ptr<_Dir_stack> _M_dirs; + }; + + /// @relates std::filesystem::recursive_directory_iterator @{ + + /** @brief Enable range-based `for` using recursive_directory_iterator. + * + * e.g. `for (auto& entry : recursive_directory_iterator(".")) ...` + */ + inline recursive_directory_iterator + begin(recursive_directory_iterator __iter) noexcept + { return __iter; } + + /// Return a past-the-end recursive_directory_iterator + inline recursive_directory_iterator + end(recursive_directory_iterator) noexcept + { return recursive_directory_iterator(); } + /// @} + +_GLIBCXX_END_NAMESPACE_CXX11 + + /// @} group filesystem +} // namespace filesystem + + // Use explicit instantiations of these types. Any inconsistency in the + // value of __default_lock_policy between code including this header and + // the library will cause a linker error. + extern template class + __shared_ptr; + extern template class + __shared_ptr; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 + +#endif // _GLIBCXX_FS_DIR_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_fwd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_fwd.h new file mode 100755 index 0000000..a7f5a37 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_fwd.h @@ -0,0 +1,362 @@ +// Filesystem declarations -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/fs_fwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{filesystem} + */ + +#ifndef _GLIBCXX_FS_FWD_H +#define _GLIBCXX_FS_FWD_H 1 + +#if __cplusplus >= 201703L + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/// ISO C++ 2017 namespace for File System library +namespace filesystem +{ +#if _GLIBCXX_USE_CXX11_ABI +/// @cond undocumented +inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +/// @endcond +#endif + +/** @addtogroup filesystem + * @{ + */ + + class file_status; +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + class path; + class filesystem_error; + class directory_entry; + class directory_iterator; + class recursive_directory_iterator; +_GLIBCXX_END_NAMESPACE_CXX11 + + /// Information about free space on a disk + struct space_info + { + uintmax_t capacity; + uintmax_t free; + uintmax_t available; + +#if __cpp_impl_three_way_comparison >= 201907L + friend bool operator==(const space_info&, const space_info&) = default; +#endif + }; + + /// Enumerated type representing the type of a file + enum class file_type : signed char { + none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3, + block = 4, character = 5, fifo = 6, socket = 7, unknown = 8 + }; + + /// Bitmask type controlling effects of `filesystem::copy` + enum class copy_options : unsigned short { + none = 0, + skip_existing = 1, overwrite_existing = 2, update_existing = 4, + recursive = 8, + copy_symlinks = 16, skip_symlinks = 32, + directories_only = 64, create_symlinks = 128, create_hard_links = 256 + }; + + /// @{ + /// @relates copy_options + constexpr copy_options + operator&(copy_options __x, copy_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr copy_options + operator|(copy_options __x, copy_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr copy_options + operator^(copy_options __x, copy_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr copy_options + operator~(copy_options __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline copy_options& + operator&=(copy_options& __x, copy_options __y) noexcept + { return __x = __x & __y; } + + inline copy_options& + operator|=(copy_options& __x, copy_options __y) noexcept + { return __x = __x | __y; } + + inline copy_options& + operator^=(copy_options& __x, copy_options __y) noexcept + { return __x = __x ^ __y; } + /// @} + + + /// Bitmask type representing file access permissions + enum class perms : unsigned { + none = 0, + owner_read = 0400, + owner_write = 0200, + owner_exec = 0100, + owner_all = 0700, + group_read = 040, + group_write = 020, + group_exec = 010, + group_all = 070, + others_read = 04, + others_write = 02, + others_exec = 01, + others_all = 07, + all = 0777, + set_uid = 04000, + set_gid = 02000, + sticky_bit = 01000, + mask = 07777, + unknown = 0xFFFF, + }; + + /// @{ + /// @relates perm_options + constexpr perms + operator&(perms __x, perms __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr perms + operator|(perms __x, perms __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr perms + operator^(perms __x, perms __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr perms + operator~(perms __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline perms& + operator&=(perms& __x, perms __y) noexcept + { return __x = __x & __y; } + + inline perms& + operator|=(perms& __x, perms __y) noexcept + { return __x = __x | __y; } + + inline perms& + operator^=(perms& __x, perms __y) noexcept + { return __x = __x ^ __y; } + /// @} + + /// Bitmask type controlling changes to permissions + enum class perm_options : unsigned { + replace = 0x1, + add = 0x2, + remove = 0x4, + nofollow = 0x8 + }; + + /// @{ + /// @relates perm_options + constexpr perm_options + operator&(perm_options __x, perm_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr perm_options + operator|(perm_options __x, perm_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr perm_options + operator^(perm_options __x, perm_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr perm_options + operator~(perm_options __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline perm_options& + operator&=(perm_options& __x, perm_options __y) noexcept + { return __x = __x & __y; } + + inline perm_options& + operator|=(perm_options& __x, perm_options __y) noexcept + { return __x = __x | __y; } + + inline perm_options& + operator^=(perm_options& __x, perm_options __y) noexcept + { return __x = __x ^ __y; } + /// @} + + /// Bitmask type controlling directory iteration + enum class directory_options : unsigned char { + none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 + }; + + /// @{ + /// @relates directory_options + constexpr directory_options + operator&(directory_options __x, directory_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr directory_options + operator|(directory_options __x, directory_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr directory_options + operator^(directory_options __x, directory_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr directory_options + operator~(directory_options __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline directory_options& + operator&=(directory_options& __x, directory_options __y) noexcept + { return __x = __x & __y; } + + inline directory_options& + operator|=(directory_options& __x, directory_options __y) noexcept + { return __x = __x | __y; } + + inline directory_options& + operator^=(directory_options& __x, directory_options __y) noexcept + { return __x = __x ^ __y; } + /// @} + + /// The type used for file timestamps + using file_time_type = __file_clock::time_point; + + // operational functions + + void copy(const path& __from, const path& __to, copy_options __options); + void copy(const path& __from, const path& __to, copy_options __options, + error_code&); + + bool copy_file(const path& __from, const path& __to, copy_options __option); + bool copy_file(const path& __from, const path& __to, copy_options __option, + error_code&); + + path current_path(); + + bool exists(file_status) noexcept; + + bool is_other(file_status) noexcept; + + uintmax_t file_size(const path&); + uintmax_t file_size(const path&, error_code&) noexcept; + uintmax_t hard_link_count(const path&); + uintmax_t hard_link_count(const path&, error_code&) noexcept; + file_time_type last_write_time(const path&); + file_time_type last_write_time(const path&, error_code&) noexcept; + + void permissions(const path&, perms, perm_options, error_code&) noexcept; + + path proximate(const path& __p, const path& __base, error_code& __ec); + path proximate(const path& __p, const path& __base, error_code& __ec); + + path relative(const path& __p, const path& __base, error_code& __ec); + + file_status status(const path&); + file_status status(const path&, error_code&) noexcept; + + bool status_known(file_status) noexcept; + + file_status symlink_status(const path&); + file_status symlink_status(const path&, error_code&) noexcept; + + bool is_regular_file(file_status) noexcept; + bool is_symlink(file_status) noexcept; + +/// @} +} // namespace filesystem +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 +#endif // _GLIBCXX_FS_FWD_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_ops.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_ops.h new file mode 100755 index 0000000..a385133 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_ops.h @@ -0,0 +1,313 @@ +// Filesystem operational functions -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your __option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/fs_fwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{filesystem} + */ + +#ifndef _GLIBCXX_FS_OPS_H +#define _GLIBCXX_FS_OPS_H 1 + +#if __cplusplus >= 201703L + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace filesystem +{ + /** @addtogroup filesystem + * @{ + */ + + path absolute(const path& __p); + path absolute(const path& __p, error_code& __ec); + + path canonical(const path& __p); + path canonical(const path& __p, error_code& __ec); + + inline void + copy(const path& __from, const path& __to) + { copy(__from, __to, copy_options::none); } + + inline void + copy(const path& __from, const path& __to, error_code& __ec) + { copy(__from, __to, copy_options::none, __ec); } + + void copy(const path& __from, const path& __to, copy_options __options); + void copy(const path& __from, const path& __to, copy_options __options, + error_code& __ec); + + inline bool + copy_file(const path& __from, const path& __to) + { return copy_file(__from, __to, copy_options::none); } + + inline bool + copy_file(const path& __from, const path& __to, error_code& __ec) + { return copy_file(__from, __to, copy_options::none, __ec); } + + bool copy_file(const path& __from, const path& __to, copy_options __option); + bool copy_file(const path& __from, const path& __to, copy_options __option, + error_code& __ec); + + void copy_symlink(const path& __existing_symlink, const path& __new_symlink); + void copy_symlink(const path& __existing_symlink, const path& __new_symlink, + error_code& __ec) noexcept; + + bool create_directories(const path& __p); + bool create_directories(const path& __p, error_code& __ec); + + bool create_directory(const path& __p); + bool create_directory(const path& __p, error_code& __ec) noexcept; + + bool create_directory(const path& __p, const path& attributes); + bool create_directory(const path& __p, const path& attributes, + error_code& __ec) noexcept; + + void create_directory_symlink(const path& __to, const path& __new_symlink); + void create_directory_symlink(const path& __to, const path& __new_symlink, + error_code& __ec) noexcept; + + void create_hard_link(const path& __to, const path& __new_hard_link); + void create_hard_link(const path& __to, const path& __new_hard_link, + error_code& __ec) noexcept; + + void create_symlink(const path& __to, const path& __new_symlink); + void create_symlink(const path& __to, const path& __new_symlink, + error_code& __ec) noexcept; + + path current_path(); + path current_path(error_code& __ec); + void current_path(const path& __p); + void current_path(const path& __p, error_code& __ec) noexcept; + + bool + equivalent(const path& __p1, const path& __p2); + + bool + equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept; + + inline bool + exists(file_status __s) noexcept + { return status_known(__s) && __s.type() != file_type::not_found; } + + inline bool + exists(const path& __p) + { return exists(status(__p)); } + + inline bool + exists(const path& __p, error_code& __ec) noexcept + { + auto __s = status(__p, __ec); + if (status_known(__s)) + { + __ec.clear(); + return __s.type() != file_type::not_found; + } + return false; + } + + uintmax_t file_size(const path& __p); + uintmax_t file_size(const path& __p, error_code& __ec) noexcept; + + uintmax_t hard_link_count(const path& __p); + uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept; + + inline bool + is_block_file(file_status __s) noexcept + { return __s.type() == file_type::block; } + + inline bool + is_block_file(const path& __p) + { return is_block_file(status(__p)); } + + inline bool + is_block_file(const path& __p, error_code& __ec) noexcept + { return is_block_file(status(__p, __ec)); } + + inline bool + is_character_file(file_status __s) noexcept + { return __s.type() == file_type::character; } + + inline bool + is_character_file(const path& __p) + { return is_character_file(status(__p)); } + + inline bool + is_character_file(const path& __p, error_code& __ec) noexcept + { return is_character_file(status(__p, __ec)); } + + inline bool + is_directory(file_status __s) noexcept + { return __s.type() == file_type::directory; } + + inline bool + is_directory(const path& __p) + { return is_directory(status(__p)); } + + inline bool + is_directory(const path& __p, error_code& __ec) noexcept + { return is_directory(status(__p, __ec)); } + + bool is_empty(const path& __p); + bool is_empty(const path& __p, error_code& __ec); + + inline bool + is_fifo(file_status __s) noexcept + { return __s.type() == file_type::fifo; } + + inline bool + is_fifo(const path& __p) + { return is_fifo(status(__p)); } + + inline bool + is_fifo(const path& __p, error_code& __ec) noexcept + { return is_fifo(status(__p, __ec)); } + + inline bool + is_other(file_status __s) noexcept + { + return exists(__s) && !is_regular_file(__s) && !is_directory(__s) + && !is_symlink(__s); + } + + inline bool + is_other(const path& __p) + { return is_other(status(__p)); } + + inline bool + is_other(const path& __p, error_code& __ec) noexcept + { return is_other(status(__p, __ec)); } + + inline bool + is_regular_file(file_status __s) noexcept + { return __s.type() == file_type::regular; } + + inline bool + is_regular_file(const path& __p) + { return is_regular_file(status(__p)); } + + inline bool + is_regular_file(const path& __p, error_code& __ec) noexcept + { return is_regular_file(status(__p, __ec)); } + + inline bool + is_socket(file_status __s) noexcept + { return __s.type() == file_type::socket; } + + inline bool + is_socket(const path& __p) + { return is_socket(status(__p)); } + + inline bool + is_socket(const path& __p, error_code& __ec) noexcept + { return is_socket(status(__p, __ec)); } + + inline bool + is_symlink(file_status __s) noexcept + { return __s.type() == file_type::symlink; } + + inline bool + is_symlink(const path& __p) + { return is_symlink(symlink_status(__p)); } + + inline bool + is_symlink(const path& __p, error_code& __ec) noexcept + { return is_symlink(symlink_status(__p, __ec)); } + + file_time_type last_write_time(const path& __p); + file_time_type last_write_time(const path& __p, error_code& __ec) noexcept; + void last_write_time(const path& __p, file_time_type __new_time); + void last_write_time(const path& __p, file_time_type __new_time, + error_code& __ec) noexcept; + + void + permissions(const path& __p, perms __prms, + perm_options __opts = perm_options::replace); + + inline void + permissions(const path& __p, perms __prms, error_code& __ec) noexcept + { permissions(__p, __prms, perm_options::replace, __ec); } + + void + permissions(const path& __p, perms __prms, perm_options __opts, + error_code& __ec) noexcept; + + inline path proximate(const path& __p, error_code& __ec) + { return proximate(__p, current_path(), __ec); } + + path proximate(const path& __p, const path& __base = current_path()); + path proximate(const path& __p, const path& __base, error_code& __ec); + + path read_symlink(const path& __p); + path read_symlink(const path& __p, error_code& __ec); + + inline path relative(const path& __p, error_code& __ec) + { return relative(__p, current_path(), __ec); } + + path relative(const path& __p, const path& __base = current_path()); + path relative(const path& __p, const path& __base, error_code& __ec); + + bool remove(const path& __p); + bool remove(const path& __p, error_code& __ec) noexcept; + + uintmax_t remove_all(const path& __p); + uintmax_t remove_all(const path& __p, error_code& __ec); + + void rename(const path& __from, const path& __to); + void rename(const path& __from, const path& __to, error_code& __ec) noexcept; + + void resize_file(const path& __p, uintmax_t __size); + void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept; + + space_info space(const path& __p); + space_info space(const path& __p, error_code& __ec) noexcept; + + file_status status(const path& __p); + file_status status(const path& __p, error_code& __ec) noexcept; + + inline bool status_known(file_status __s) noexcept + { return __s.type() != file_type::none; } + + file_status symlink_status(const path& __p); + file_status symlink_status(const path& __p, error_code& __ec) noexcept; + + path temp_directory_path(); + path temp_directory_path(error_code& __ec); + + path weakly_canonical(const path& __p); + path weakly_canonical(const path& __p, error_code& __ec); + + /// @} group filesystem +} // namespace filesystem + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 + +#endif // _GLIBCXX_FS_OPS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_path.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_path.h new file mode 100755 index 0000000..a1f780a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fs_path.h @@ -0,0 +1,1369 @@ +// Class filesystem::path -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/fs_path.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{filesystem} + */ + +#ifndef _GLIBCXX_FS_PATH_H +#define _GLIBCXX_FS_PATH_H 1 + +#if __cplusplus >= 201703L + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if __cplusplus > 201703L +# include +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) +# define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1 +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace filesystem +{ +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + class path; + + /// @cond undocumented +namespace __detail +{ + /// @addtogroup filesystem + /// @{ + template + inline constexpr bool __is_encoded_char = false; + template<> + inline constexpr bool __is_encoded_char = true; +#ifdef _GLIBCXX_USE_CHAR8_T + template<> + inline constexpr bool __is_encoded_char = true; +#endif +#if _GLIBCXX_USE_WCHAR_T + template<> + inline constexpr bool __is_encoded_char = true; +#endif + template<> + inline constexpr bool __is_encoded_char = true; + template<> + inline constexpr bool __is_encoded_char = true; + +#if __cpp_concepts >= 201907L + template + using __safe_iterator_traits = std::iterator_traits<_Iter>; +#else + template + struct __safe_iterator_traits : std::iterator_traits<_Iter> + { }; + + // Protect against ill-formed iterator_traits specializations in C++17 + template<> struct __safe_iterator_traits { }; + template<> struct __safe_iterator_traits { }; + template<> struct __safe_iterator_traits { }; + template<> struct __safe_iterator_traits { }; +#endif + + template + struct __is_path_iter_src + : false_type + { }; + + template + struct __is_path_iter_src<_Iter_traits, + void_t> + : bool_constant<__is_encoded_char> + { }; + + template + inline constexpr bool __is_path_src + = __is_path_iter_src>>::value; + + template<> + inline constexpr bool __is_path_src = false; + + template<> + inline constexpr bool __is_path_src = false; + + template<> + inline constexpr bool __is_path_src = false; + + template<> + inline constexpr bool __is_path_src = false; + + template<> + inline constexpr bool __is_path_src = false; + + template<> + inline constexpr bool __is_path_src = false; + + template + inline constexpr bool + __is_path_src> + = __is_encoded_char<_CharT>; + + template + inline constexpr bool + __is_path_src> + = __is_encoded_char<_CharT>; + + // SFINAE constraint for Source parameters as required by [fs.path.req]. + template + using _Path = enable_if_t<__is_path_src<_Tp>, path>; + + // SFINAE constraint for InputIterator parameters as required by [fs.req]. + template> + using _Path2 = enable_if_t<__is_path_iter_src<_Tr>::value, path>; + + // The __effective_range overloads convert a Source parameter into + // either a basic_string_view or basic_string containing the + // effective range of the Source, as defined in [fs.path.req]. + + template + inline basic_string_view<_CharT, _Traits> + __effective_range(const basic_string<_CharT, _Traits, _Alloc>& __source) + { return __source; } + + template + inline const basic_string_view<_CharT, _Traits>& + __effective_range(const basic_string_view<_CharT, _Traits>& __source) + { return __source; } + + template + inline auto + __effective_range(const _Source& __source) + { + if constexpr (is_pointer_v>) + return basic_string_view{&*__source}; + else + { + // _Source is an input iterator that iterates over an NTCTS. + // Create a basic_string by reading until the null character. + using value_type + = typename iterator_traits<_Source>::value_type; + basic_string __str; + _Source __it = __source; + for (value_type __ch = *__it; __ch != value_type(); __ch = *++__it) + __str.push_back(__ch); + return __str; + } + } + + // The value type of a Source parameter's effective range. + template + using __value_t = typename remove_reference_t< + decltype(__detail::__effective_range(std::declval<_Tp>()))>::value_type; + + // SFINAE helper to check that an effective range has value_type char, + // as required by path constructors taking a std::locale parameter. + // The type _Tp must have already been checked by _Path or _Path2<_Tp>. + template> + using __value_type_is_char + = std::enable_if_t, _Val>; + + // As above, but also allows char8_t, as required by u8path + // C++20 [depr.fs.path.factory] + template> + using __value_type_is_char_or_char8_t + = std::enable_if_t +#ifdef _GLIBCXX_USE_CHAR8_T + || std::is_same_v<_Val, char8_t> +#endif + , _Val>; + + // Create a string or string view from an iterator range. + template + inline auto + __string_from_range(_InputIterator __first, _InputIterator __last) + { + using _EcharT + = typename std::iterator_traits<_InputIterator>::value_type; + static_assert(__is_encoded_char<_EcharT>); + +#if __cpp_lib_concepts + constexpr bool __contiguous = std::contiguous_iterator<_InputIterator>; +#else + constexpr bool __contiguous + = is_pointer_v; +#endif + if constexpr (__contiguous) + { + // For contiguous iterators we can just return a string view. + const auto* __f = std::__to_address(std::__niter_base(__first)); + const auto* __l = std::__to_address(std::__niter_base(__last)); + return basic_string_view<_EcharT>(__f, __l - __f); + } + else + // Conversion requires contiguous characters, so create a string. + return basic_string<_EcharT>(__first, __last); + } + + /// @} group filesystem +} // namespace __detail + /// @endcond + + /// @addtogroup filesystem + /// @{ + + /// A filesystem path + /// @ingroup filesystem + class path + { + public: +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + using value_type = wchar_t; + static constexpr value_type preferred_separator = L'\\'; +#else +# ifdef _GLIBCXX_DOXYGEN + /// Windows uses wchar_t for path::value_type, POSIX uses char. + using value_type = __os_dependent__; +# else + using value_type = char; +# endif + static constexpr value_type preferred_separator = '/'; +#endif + using string_type = std::basic_string; + + /// path::format is ignored in this implementation + enum format : unsigned char { native_format, generic_format, auto_format }; + + // constructors and destructor + + path() noexcept { } + + path(const path& __p) = default; + + path(path&& __p) +#if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_FULLY_DYNAMIC_STRING == 0 + noexcept +#endif + : _M_pathname(std::move(__p._M_pathname)), + _M_cmpts(std::move(__p._M_cmpts)) + { __p.clear(); } + + path(string_type&& __source, format = auto_format) + : _M_pathname(std::move(__source)) + { _M_split_cmpts(); } + + template> + path(_Source const& __source, format = auto_format) + : _M_pathname(_S_convert(__detail::__effective_range(__source))) + { _M_split_cmpts(); } + + template> + path(_InputIterator __first, _InputIterator __last, format = auto_format) + : _M_pathname(_S_convert(__detail::__string_from_range(__first, __last))) + { _M_split_cmpts(); } + + template, + typename _Require2 = __detail::__value_type_is_char<_Source>> + path(_Source const& __src, const locale& __loc, format = auto_format) + : _M_pathname(_S_convert_loc(__detail::__effective_range(__src), __loc)) + { _M_split_cmpts(); } + + template, + typename _Req2 = __detail::__value_type_is_char<_InputIterator>> + path(_InputIterator __first, _InputIterator __last, const locale& __loc, + format = auto_format) + : _M_pathname(_S_convert_loc(__first, __last, __loc)) + { _M_split_cmpts(); } + + ~path() = default; + + // assignments + + path& operator=(const path&); + path& operator=(path&&) noexcept; + path& operator=(string_type&& __source); + path& assign(string_type&& __source); + + template + __detail::_Path<_Source>& + operator=(_Source const& __source) + { return *this = path(__source); } + + template + __detail::_Path<_Source>& + assign(_Source const& __source) + { return *this = path(__source); } + + template + __detail::_Path2<_InputIterator>& + assign(_InputIterator __first, _InputIterator __last) + { return *this = path(__first, __last); } + + // appends + + path& operator/=(const path& __p); + + template + __detail::_Path<_Source>& + operator/=(_Source const& __source) + { + _M_append(_S_convert(__detail::__effective_range(__source))); + return *this; + } + + template + __detail::_Path<_Source>& + append(_Source const& __source) + { + _M_append(_S_convert(__detail::__effective_range(__source))); + return *this; + } + + template + __detail::_Path2<_InputIterator>& + append(_InputIterator __first, _InputIterator __last) + { + _M_append(_S_convert(__detail::__string_from_range(__first, __last))); + return *this; + } + + // concatenation + + path& operator+=(const path& __x); + path& operator+=(const string_type& __x); + path& operator+=(const value_type* __x); + path& operator+=(value_type __x); + path& operator+=(basic_string_view __x); + + template + __detail::_Path<_Source>& + operator+=(_Source const& __x) { return concat(__x); } + + template + __detail::_Path2<_CharT*>& + operator+=(_CharT __x); + + template + __detail::_Path<_Source>& + concat(_Source const& __x) + { + _M_concat(_S_convert(__detail::__effective_range(__x))); + return *this; + } + + template + __detail::_Path2<_InputIterator>& + concat(_InputIterator __first, _InputIterator __last) + { + _M_concat(_S_convert(__detail::__string_from_range(__first, __last))); + return *this; + } + + // modifiers + + void clear() noexcept { _M_pathname.clear(); _M_split_cmpts(); } + + path& make_preferred(); + path& remove_filename(); + path& replace_filename(const path& __replacement); + path& replace_extension(const path& __replacement = path()); + + void swap(path& __rhs) noexcept; + + // native format observers + + const string_type& native() const noexcept { return _M_pathname; } + const value_type* c_str() const noexcept { return _M_pathname.c_str(); } + operator string_type() const { return _M_pathname; } + + template, + typename _Allocator = std::allocator<_CharT>> + std::basic_string<_CharT, _Traits, _Allocator> + string(const _Allocator& __a = _Allocator()) const; + + std::string string() const; +#if _GLIBCXX_USE_WCHAR_T + std::wstring wstring() const; +#endif +#ifdef _GLIBCXX_USE_CHAR8_T + __attribute__((__abi_tag__("__u8"))) + std::u8string u8string() const; +#else + std::string u8string() const; +#endif // _GLIBCXX_USE_CHAR8_T + std::u16string u16string() const; + std::u32string u32string() const; + + // generic format observers + template, + typename _Allocator = std::allocator<_CharT>> + std::basic_string<_CharT, _Traits, _Allocator> + generic_string(const _Allocator& __a = _Allocator()) const; + + std::string generic_string() const; +#if _GLIBCXX_USE_WCHAR_T + std::wstring generic_wstring() const; +#endif +#ifdef _GLIBCXX_USE_CHAR8_T + __attribute__((__abi_tag__("__u8"))) + std::u8string generic_u8string() const; +#else + std::string generic_u8string() const; +#endif // _GLIBCXX_USE_CHAR8_T + std::u16string generic_u16string() const; + std::u32string generic_u32string() const; + + // compare + + int compare(const path& __p) const noexcept; + int compare(const string_type& __s) const noexcept; + int compare(const value_type* __s) const noexcept; + int compare(basic_string_view __s) const noexcept; + + // decomposition + + path root_name() const; + path root_directory() const; + path root_path() const; + path relative_path() const; + path parent_path() const; + path filename() const; + path stem() const; + path extension() const; + + // query + + [[nodiscard]] bool empty() const noexcept { return _M_pathname.empty(); } + bool has_root_name() const noexcept; + bool has_root_directory() const noexcept; + bool has_root_path() const noexcept; + bool has_relative_path() const noexcept; + bool has_parent_path() const noexcept; + bool has_filename() const noexcept; + bool has_stem() const noexcept; + bool has_extension() const noexcept; + bool is_absolute() const noexcept; + bool is_relative() const noexcept { return !is_absolute(); } + + // generation + path lexically_normal() const; + path lexically_relative(const path& base) const; + path lexically_proximate(const path& base) const; + + // iterators + class iterator; + using const_iterator = iterator; + + iterator begin() const; + iterator end() const; + + /// Write a path to a stream + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, const path& __p) + { + __os << std::quoted(__p.string<_CharT, _Traits>()); + return __os; + } + + /// Read a path from a stream + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, path& __p) + { + std::basic_string<_CharT, _Traits> __tmp; + if (__is >> std::quoted(__tmp)) + __p = std::move(__tmp); + return __is; + } + + // non-member operators + + /// Compare paths + friend bool operator==(const path& __lhs, const path& __rhs) noexcept + { return path::_S_compare(__lhs, __rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /// Compare paths + friend strong_ordering + operator<=>(const path& __lhs, const path& __rhs) noexcept + { return path::_S_compare(__lhs, __rhs) <=> 0; } +#else + /// Compare paths + friend bool operator!=(const path& __lhs, const path& __rhs) noexcept + { return !(__lhs == __rhs); } + + /// Compare paths + friend bool operator<(const path& __lhs, const path& __rhs) noexcept + { return __lhs.compare(__rhs) < 0; } + + /// Compare paths + friend bool operator<=(const path& __lhs, const path& __rhs) noexcept + { return !(__rhs < __lhs); } + + /// Compare paths + friend bool operator>(const path& __lhs, const path& __rhs) noexcept + { return __rhs < __lhs; } + + /// Compare paths + friend bool operator>=(const path& __lhs, const path& __rhs) noexcept + { return !(__lhs < __rhs); } +#endif + + /// Append one path to another + friend path operator/(const path& __lhs, const path& __rhs) + { + path __result(__lhs); + __result /= __rhs; + return __result; + } + + private: + enum class _Type : unsigned char { + _Multi = 0, _Root_name, _Root_dir, _Filename + }; + + path(basic_string_view __str, _Type __type) + : _M_pathname(__str) + { + __glibcxx_assert(__type != _Type::_Multi); + _M_cmpts.type(__type); + } + + enum class _Split { _Stem, _Extension }; + + void _M_append(basic_string_view); + void _M_concat(basic_string_view); + + pair _M_find_extension() const noexcept; + + // path::_S_convert creates a basic_string or + // basic_string_view from a range (either the effective + // range of a Source parameter, or a pair of InputIterator parameters), + // performing the conversions required by [fs.path.type.cvt]. + // If the value_type of the range value type is path::value_type, + // no encoding conversion is performed. If the range is contiguous + // a string_view + + static string_type + _S_convert(string_type __str) + { return __str; } + + template + static auto + _S_convert(const _Tp& __str) + { + if constexpr (is_same_v<_Tp, string_type>) + return __str; + else if constexpr (is_same_v<_Tp, basic_string_view>) + return __str; + else if constexpr (is_same_v) + return basic_string_view(__str.data(), __str.size()); + else + return _S_convert(__str.data(), __str.data() + __str.size()); + } + + template + static auto + _S_convert(const _EcharT* __first, const _EcharT* __last); + + static string_type + _S_convert_loc(const char* __first, const char* __last, + const std::locale& __loc); + + template + static string_type + _S_convert_loc(_Iter __first, _Iter __last, const std::locale& __loc) + { + const auto __s = __detail::__string_from_range(__first, __last); + return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc); + } + + template + static string_type + _S_convert_loc(const _Tp& __s, const std::locale& __loc) + { + return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc); + } + + template + static basic_string<_CharT, _Traits, _Allocator> + _S_str_convert(basic_string_view, const _Allocator&); + + // Returns lhs.compare(rhs), but defined after path::iterator is complete. + __attribute__((__always_inline__)) + static int + _S_compare(const path& __lhs, const path& __rhs) noexcept; + + void _M_split_cmpts(); + + _Type _M_type() const noexcept { return _M_cmpts.type(); } + + string_type _M_pathname; + + struct _Cmpt; + + struct _List + { + using value_type = _Cmpt; + using iterator = value_type*; + using const_iterator = const value_type*; + + _List(); + _List(const _List&); + _List(_List&&) = default; + _List& operator=(const _List&); + _List& operator=(_List&&) = default; + ~_List() = default; + + _Type type() const noexcept + { return _Type(reinterpret_cast(_M_impl.get()) & 0x3); } + + void type(_Type) noexcept; + + int size() const noexcept; // zero unless type() == _Type::_Multi + bool empty() const noexcept; // true unless type() == _Type::_Multi + void clear(); + void swap(_List& __l) noexcept { _M_impl.swap(__l._M_impl); } + int capacity() const noexcept; + void reserve(int, bool); ///< @pre type() == _Type::_Multi + + // All the member functions below here have a precondition !empty() + // (and they should only be called from within the library). + + iterator begin() noexcept; + iterator end() noexcept; + const_iterator begin() const noexcept; + const_iterator end() const noexcept; + + value_type& front() noexcept; + value_type& back() noexcept; + const value_type& front() const noexcept; + const value_type& back() const noexcept; + + void pop_back(); + void _M_erase_from(const_iterator __pos); // erases [__pos,end()) + + struct _Impl; + struct _Impl_deleter + { + void operator()(_Impl*) const noexcept; + }; + unique_ptr<_Impl, _Impl_deleter> _M_impl; + }; + _List _M_cmpts; + + struct _Parser; + }; + + /// @{ + /// @relates std::filesystem::path + + inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } + + size_t hash_value(const path& __p) noexcept; + + /// @} + + /// Exception type thrown by the Filesystem library + class filesystem_error : public std::system_error + { + public: + filesystem_error(const string& __what_arg, error_code __ec); + + filesystem_error(const string& __what_arg, const path& __p1, + error_code __ec); + + filesystem_error(const string& __what_arg, const path& __p1, + const path& __p2, error_code __ec); + + filesystem_error(const filesystem_error&) = default; + filesystem_error& operator=(const filesystem_error&) = default; + + // No move constructor or assignment operator. + // Copy rvalues instead, so that _M_impl is not left empty. + + ~filesystem_error(); + + const path& path1() const noexcept; + const path& path2() const noexcept; + const char* what() const noexcept; + + private: + struct _Impl; + std::__shared_ptr _M_impl; + }; + + /// @cond undocumented +namespace __detail +{ + [[noreturn]] inline void + __throw_conversion_error() + { + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); + } + +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + template + inline std::wstring + __wstr_from_utf8(const _Tp& __str) + { + static_assert(std::is_same_v); + std::wstring __wstr; + // XXX This assumes native wide encoding is UTF-16. + std::codecvt_utf8_utf16 __wcvt; + const auto __p = __str.data(); + if (!__str_codecvt_in_all(__p, __p + __str.size(), __wstr, __wcvt)) + __detail::__throw_conversion_error(); + return __wstr; + } +#endif + +} // namespace __detail + /// @endcond + + + /** Create a path from a UTF-8-encoded sequence of char + * + * @relates std::filesystem::path + */ + template, + typename _CharT + = __detail::__value_type_is_char_or_char8_t<_InputIterator>> + inline path + u8path(_InputIterator __first, _InputIterator __last) + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + if constexpr (is_same_v<_CharT, char>) + return path{ __detail::__wstr_from_utf8( + __detail::__string_from_range(__first, __last)) }; + else + return path{ __first, __last }; // constructor handles char8_t +#else + // This assumes native normal encoding is UTF-8. + return path{ __first, __last }; +#endif + } + + /** Create a path from a UTF-8-encoded sequence of char + * + * @relates std::filesystem::path + */ + template, + typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>> + inline path + u8path(const _Source& __source) + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + if constexpr (is_same_v<_CharT, char>) + return path{ __detail::__wstr_from_utf8( + __detail::__effective_range(__source)) }; + else + return path{ __source }; // constructor handles char8_t +#else + // This assumes native normal encoding is UTF-8. + return path{ __source }; +#endif + } + + /// @cond undocumented + + struct path::_Cmpt : path + { + _Cmpt(basic_string_view __s, _Type __t, size_t __pos) + : path(__s, __t), _M_pos(__pos) { } + + _Cmpt() : _M_pos(-1) { } + + size_t _M_pos; + }; + + template + auto + path::_S_convert(const _EcharT* __f, const _EcharT* __l) + { + static_assert(__detail::__is_encoded_char<_EcharT>); + + if constexpr (is_same_v<_EcharT, value_type>) + return basic_string_view(__f, __l - __f); +#if !defined _GLIBCXX_FILESYSTEM_IS_WINDOWS && defined _GLIBCXX_USE_CHAR8_T + else if constexpr (is_same_v<_EcharT, char8_t>) + // For POSIX converting from char8_t to char is also 'noconv' + return string_view(reinterpret_cast(__f), __l - __f); +#endif + else + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::wstring __wstr; + if constexpr (is_same_v<_EcharT, char>) + { + struct _UCvt : std::codecvt + { } __cvt; + if (__str_codecvt_in_all(__f, __l, __wstr, __cvt)) + return __wstr; + } +#ifdef _GLIBCXX_USE_CHAR8_T + else if constexpr (is_same_v<_EcharT, char8_t>) + { + const auto __f2 = reinterpret_cast(__f); + return __detail::__wstr_from_utf8(string_view(__f2, __l - __f)); + } +#endif + else // char16_t or char32_t + { + struct _UCvt : std::codecvt<_EcharT, char, std::mbstate_t> + { } __cvt; + std::string __str; + if (__str_codecvt_out_all(__f, __l, __str, __cvt)) + return __detail::__wstr_from_utf8(__str); + } +#else // ! windows + struct _UCvt : std::codecvt<_EcharT, char, std::mbstate_t> + { } __cvt; + std::string __str; + if (__str_codecvt_out_all(__f, __l, __str, __cvt)) + return __str; +#endif + __detail::__throw_conversion_error(); + } + } + + /// @endcond + + /// An iterator for the components of a path + class path::iterator + { + public: + using difference_type = std::ptrdiff_t; + using value_type = path; + using reference = const path&; + using pointer = const path*; + using iterator_category = std::bidirectional_iterator_tag; + + iterator() : _M_path(nullptr), _M_cur(), _M_at_end() { } + + iterator(const iterator&) = default; + iterator& operator=(const iterator&) = default; + + reference operator*() const; + pointer operator->() const { return std::__addressof(**this); } + + iterator& operator++(); + iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; } + + iterator& operator--(); + iterator operator--(int) { auto __tmp = *this; --*this; return __tmp; } + + friend bool operator==(const iterator& __lhs, const iterator& __rhs) + { return __lhs._M_equals(__rhs); } + + friend bool operator!=(const iterator& __lhs, const iterator& __rhs) + { return !__lhs._M_equals(__rhs); } + + private: + friend class path; + + bool _M_is_multi() const { return _M_path->_M_type() == _Type::_Multi; } + + friend difference_type + __path_iter_distance(const iterator& __first, const iterator& __last) + { + __glibcxx_assert(__first._M_path != nullptr); + __glibcxx_assert(__first._M_path == __last._M_path); + if (__first._M_is_multi()) + return std::distance(__first._M_cur, __last._M_cur); + else if (__first._M_at_end == __last._M_at_end) + return 0; + else + return __first._M_at_end ? -1 : 1; + } + + friend void + __path_iter_advance(iterator& __i, difference_type __n) + { + if (__n == 1) + ++__i; + else if (__n == -1) + --__i; + else if (__n != 0) + { + __glibcxx_assert(__i._M_path != nullptr); + __glibcxx_assert(__i._M_is_multi()); + // __glibcxx_assert(__i._M_path->_M_cmpts.end() - __i._M_cur >= __n); + __i._M_cur += __n; + } + } + + iterator(const path* __path, path::_List::const_iterator __iter) + : _M_path(__path), _M_cur(__iter), _M_at_end() + { } + + iterator(const path* __path, bool __at_end) + : _M_path(__path), _M_cur(), _M_at_end(__at_end) + { } + + bool _M_equals(iterator) const; + + const path* _M_path; + path::_List::const_iterator _M_cur; + bool _M_at_end; // only used when type != _Multi + }; + + + inline path& + path::operator=(path&& __p) noexcept + { + if (&__p == this) [[__unlikely__]] + return *this; + + _M_pathname = std::move(__p._M_pathname); + _M_cmpts = std::move(__p._M_cmpts); + __p.clear(); + return *this; + } + + inline path& + path::operator=(string_type&& __source) + { return *this = path(std::move(__source)); } + + inline path& + path::assign(string_type&& __source) + { return *this = path(std::move(__source)); } + + inline path& + path::operator+=(const string_type& __x) + { + _M_concat(__x); + return *this; + } + + inline path& + path::operator+=(const value_type* __x) + { + _M_concat(__x); + return *this; + } + + inline path& + path::operator+=(value_type __x) + { + _M_concat(basic_string_view(&__x, 1)); + return *this; + } + + inline path& + path::operator+=(basic_string_view __x) + { + _M_concat(__x); + return *this; + } + + template + inline __detail::_Path2<_CharT*>& + path::operator+=(const _CharT __x) + { + _M_concat(_S_convert(&__x, &__x + 1)); + return *this; + } + + inline path& + path::make_preferred() + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::replace(_M_pathname.begin(), _M_pathname.end(), L'/', + preferred_separator); +#endif + return *this; + } + + inline void path::swap(path& __rhs) noexcept + { + _M_pathname.swap(__rhs._M_pathname); + _M_cmpts.swap(__rhs._M_cmpts); + } + + /// @cond undocumented + template + std::basic_string<_CharT, _Traits, _Allocator> + path::_S_str_convert(basic_string_view __str, + const _Allocator& __a) + { + static_assert(!is_same_v<_CharT, value_type>); + + using _WString = basic_string<_CharT, _Traits, _Allocator>; + + if (__str.size() == 0) + return _WString(__a); + +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + // First convert native string from UTF-16 to to UTF-8. + // XXX This assumes that the execution wide-character set is UTF-16. + std::codecvt_utf8_utf16 __cvt; + + using _CharAlloc = __alloc_rebind<_Allocator, char>; + using _String = basic_string, _CharAlloc>; + _String __u8str{_CharAlloc{__a}}; + const value_type* __wfirst = __str.data(); + const value_type* __wlast = __wfirst + __str.size(); + if (__str_codecvt_out_all(__wfirst, __wlast, __u8str, __cvt)) { + if constexpr (is_same_v<_CharT, char>) + return __u8str; // XXX assumes native ordinary encoding is UTF-8. + else { + + const char* __first = __u8str.data(); + const char* __last = __first + __u8str.size(); +#else + const value_type* __first = __str.data(); + const value_type* __last = __first + __str.size(); +#endif + + // Convert UTF-8 string to requested format. +#ifdef _GLIBCXX_USE_CHAR8_T + if constexpr (is_same_v<_CharT, char8_t>) + return _WString(__first, __last, __a); + else +#endif + { + // Convert UTF-8 to wide string. + _WString __wstr(__a); + struct _UCvt : std::codecvt<_CharT, char, std::mbstate_t> { } __cvt; + if (__str_codecvt_in_all(__first, __last, __wstr, __cvt)) + return __wstr; + } + +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + } } +#endif + __detail::__throw_conversion_error(); + } + /// @endcond + + template + inline basic_string<_CharT, _Traits, _Allocator> + path::string(const _Allocator& __a) const + { + if constexpr (is_same_v<_CharT, value_type>) + return { _M_pathname.c_str(), _M_pathname.length(), __a }; + else + return _S_str_convert<_CharT, _Traits>(_M_pathname, __a); + } + + inline std::string + path::string() const { return string(); } + +#if _GLIBCXX_USE_WCHAR_T + inline std::wstring + path::wstring() const { return string(); } +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + inline std::u8string + path::u8string() const { return string(); } +#else + inline std::string + path::u8string() const + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::string __str; + // convert from native wide encoding (assumed to be UTF-16) to UTF-8 + std::codecvt_utf8_utf16 __cvt; + const value_type* __first = _M_pathname.data(); + const value_type* __last = __first + _M_pathname.size(); + if (__str_codecvt_out_all(__first, __last, __str, __cvt)) + return __str; + __detail::__throw_conversion_error(); +#else + return _M_pathname; +#endif + } +#endif // _GLIBCXX_USE_CHAR8_T + + inline std::u16string + path::u16string() const { return string(); } + + inline std::u32string + path::u32string() const { return string(); } + + template + inline std::basic_string<_CharT, _Traits, _Allocator> + path::generic_string(const _Allocator& __a) const + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + const value_type __slash = L'/'; +#else + const value_type __slash = '/'; +#endif + using _Alloc2 = typename allocator_traits<_Allocator>::template + rebind_alloc; + basic_string, _Alloc2> __str(__a); + + if (_M_type() == _Type::_Root_dir) + __str.assign(1, __slash); + else + { + __str.reserve(_M_pathname.size()); + bool __add_slash = false; + for (auto& __elem : *this) + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + if (__elem._M_type() == _Type::_Root_dir) + { + __str += __slash; + continue; + } +#endif + if (__add_slash) + __str += __slash; + __str += basic_string_view(__elem._M_pathname); + __add_slash = __elem._M_type() == _Type::_Filename; + } + } + + if constexpr (is_same_v<_CharT, value_type>) + return __str; + else + return _S_str_convert<_CharT, _Traits>(__str, __a); + } + + inline std::string + path::generic_string() const + { return generic_string(); } + +#if _GLIBCXX_USE_WCHAR_T + inline std::wstring + path::generic_wstring() const + { return generic_string(); } +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + inline std::u8string + path::generic_u8string() const + { return generic_string(); } +#else + inline std::string + path::generic_u8string() const + { return generic_string(); } +#endif + + inline std::u16string + path::generic_u16string() const + { return generic_string(); } + + inline std::u32string + path::generic_u32string() const + { return generic_string(); } + + inline int + path::compare(const string_type& __s) const noexcept + { return compare(basic_string_view(__s)); } + + inline int + path::compare(const value_type* __s) const noexcept + { return compare(basic_string_view(__s)); } + + inline path + path::filename() const + { + if (empty()) + return {}; + else if (_M_type() == _Type::_Filename) + return *this; + else if (_M_type() == _Type::_Multi) + { + if (_M_pathname.back() == preferred_separator) + return {}; + auto& __last = *--end(); + if (__last._M_type() == _Type::_Filename) + return __last; + } + return {}; + } + + inline path + path::stem() const + { + auto ext = _M_find_extension(); + if (ext.first && ext.second != 0) + return path{ext.first->substr(0, ext.second)}; + return {}; + } + + inline path + path::extension() const + { + auto ext = _M_find_extension(); + if (ext.first && ext.second != string_type::npos) + return path{ext.first->substr(ext.second)}; + return {}; + } + + inline bool + path::has_stem() const noexcept + { + auto ext = _M_find_extension(); + return ext.first && ext.second != 0; + } + + inline bool + path::has_extension() const noexcept + { + auto ext = _M_find_extension(); + return ext.first && ext.second != string_type::npos; + } + + inline bool + path::is_absolute() const noexcept + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return has_root_name() && has_root_directory(); +#else + return has_root_directory(); +#endif + } + + inline path::iterator + path::begin() const + { + if (_M_type() == _Type::_Multi) + return iterator(this, _M_cmpts.begin()); + return iterator(this, empty()); + } + + inline path::iterator + path::end() const + { + if (_M_type() == _Type::_Multi) + return iterator(this, _M_cmpts.end()); + return iterator(this, true); + } + + inline path::iterator& + path::iterator::operator++() + { + __glibcxx_assert(_M_path != nullptr); + if (_M_path->_M_type() == _Type::_Multi) + { + __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end()); + ++_M_cur; + } + else + { + __glibcxx_assert(!_M_at_end); + _M_at_end = true; + } + return *this; + } + + inline path::iterator& + path::iterator::operator--() + { + __glibcxx_assert(_M_path != nullptr); + if (_M_path->_M_type() == _Type::_Multi) + { + __glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin()); + --_M_cur; + } + else + { + __glibcxx_assert(_M_at_end); + _M_at_end = false; + } + return *this; + } + + inline path::iterator::reference + path::iterator::operator*() const + { + __glibcxx_assert(_M_path != nullptr); + if (_M_path->_M_type() == _Type::_Multi) + { + __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end()); + return *_M_cur; + } + return *_M_path; + } + + inline bool + path::iterator::_M_equals(iterator __rhs) const + { + if (_M_path != __rhs._M_path) + return false; + if (_M_path == nullptr) + return true; + if (_M_path->_M_type() == path::_Type::_Multi) + return _M_cur == __rhs._M_cur; + return _M_at_end == __rhs._M_at_end; + } + + // Define this now that path and path::iterator are complete. + // It needs to consider the string_view(Range&&) constructor during + // overload resolution, which depends on whether range is satisfied, + // which depends on whether path::iterator is complete. + inline int + path::_S_compare(const path& __lhs, const path& __rhs) noexcept + { return __lhs.compare(__rhs); } + + /// @} group filesystem +_GLIBCXX_END_NAMESPACE_CXX11 +} // namespace filesystem + +/// @cond undocumented + +inline ptrdiff_t +distance(filesystem::path::iterator __first, filesystem::path::iterator __last) +{ return __path_iter_distance(__first, __last); } + +template + void + advance(filesystem::path::iterator& __i, _Distance __n) + { __path_iter_advance(__i, static_cast(__n)); } + +extern template class __shared_ptr; + +/// @endcond + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 + +#endif // _GLIBCXX_FS_PATH_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fstream.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fstream.tcc new file mode 100755 index 0000000..bc514b5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/fstream.tcc @@ -0,0 +1,1102 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/fstream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{fstream} + */ + +// +// ISO C++ 14882: 27.8 File-based streams +// + +#ifndef _FSTREAM_TCC +#define _FSTREAM_TCC 1 + +#pragma GCC system_header + +#include +#include // for swap +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + basic_filebuf<_CharT, _Traits>:: + _M_allocate_internal_buffer() + { + // Allocate internal buffer only if one doesn't already exist + // (either allocated or provided by the user via setbuf). + if (!_M_buf_allocated && !_M_buf) + { + _M_buf = new char_type[_M_buf_size]; + _M_buf_allocated = true; + } + } + + template + void + basic_filebuf<_CharT, _Traits>:: + _M_destroy_internal_buffer() throw() + { + if (_M_buf_allocated) + { + delete [] _M_buf; + _M_buf = 0; + _M_buf_allocated = false; + } + delete [] _M_ext_buf; + _M_ext_buf = 0; + _M_ext_buf_size = 0; + _M_ext_next = 0; + _M_ext_end = 0; + } + + template + basic_filebuf<_CharT, _Traits>:: + basic_filebuf() : __streambuf_type(), _M_lock(), _M_file(&_M_lock), + _M_mode(ios_base::openmode(0)), _M_state_beg(), _M_state_cur(), + _M_state_last(), _M_buf(0), _M_buf_size(_GLIBCXX_BUFSIZ), + _M_buf_allocated(false), _M_reading(false), _M_writing(false), _M_pback(), + _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false), + _M_codecvt(0), _M_ext_buf(0), _M_ext_buf_size(0), _M_ext_next(0), + _M_ext_end(0) + { + if (has_facet<__codecvt_type>(this->_M_buf_locale)) + _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale); + } + +#if __cplusplus >= 201103L + template + basic_filebuf<_CharT, _Traits>:: + basic_filebuf(basic_filebuf&& __rhs) + : __streambuf_type(__rhs), + _M_lock(), _M_file(std::move(__rhs._M_file), &_M_lock), + _M_mode(std::__exchange(__rhs._M_mode, ios_base::openmode(0))), + _M_state_beg(std::move(__rhs._M_state_beg)), + _M_state_cur(std::move(__rhs._M_state_cur)), + _M_state_last(std::move(__rhs._M_state_last)), + _M_buf(std::__exchange(__rhs._M_buf, nullptr)), + _M_buf_size(std::__exchange(__rhs._M_buf_size, 1)), + _M_buf_allocated(std::__exchange(__rhs._M_buf_allocated, false)), + _M_reading(std::__exchange(__rhs._M_reading, false)), + _M_writing(std::__exchange(__rhs._M_writing, false)), + _M_pback(__rhs._M_pback), + _M_pback_cur_save(std::__exchange(__rhs._M_pback_cur_save, nullptr)), + _M_pback_end_save(std::__exchange(__rhs._M_pback_end_save, nullptr)), + _M_pback_init(std::__exchange(__rhs._M_pback_init, false)), + _M_codecvt(__rhs._M_codecvt), + _M_ext_buf(std::__exchange(__rhs._M_ext_buf, nullptr)), + _M_ext_buf_size(std::__exchange(__rhs._M_ext_buf_size, 0)), + _M_ext_next(std::__exchange(__rhs._M_ext_next, nullptr)), + _M_ext_end(std::__exchange(__rhs._M_ext_end, nullptr)) + { + __rhs._M_set_buffer(-1); + __rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg; + } + + template + basic_filebuf<_CharT, _Traits>& + basic_filebuf<_CharT, _Traits>:: + operator=(basic_filebuf&& __rhs) + { + this->close(); + __streambuf_type::operator=(__rhs); + _M_file.swap(__rhs._M_file); + _M_mode = std::__exchange(__rhs._M_mode, ios_base::openmode(0)); + _M_state_beg = std::move(__rhs._M_state_beg); + _M_state_cur = std::move(__rhs._M_state_cur); + _M_state_last = std::move(__rhs._M_state_last); + _M_buf = std::__exchange(__rhs._M_buf, nullptr); + _M_buf_size = std::__exchange(__rhs._M_buf_size, 1); + _M_buf_allocated = std::__exchange(__rhs._M_buf_allocated, false); + _M_ext_buf = std::__exchange(__rhs._M_ext_buf, nullptr); + _M_ext_buf_size = std::__exchange(__rhs._M_ext_buf_size, 0); + _M_ext_next = std::__exchange(__rhs._M_ext_next, nullptr); + _M_ext_end = std::__exchange(__rhs._M_ext_end, nullptr); + _M_reading = std::__exchange(__rhs._M_reading, false); + _M_writing = std::__exchange(__rhs._M_writing, false); + _M_pback_cur_save = std::__exchange(__rhs._M_pback_cur_save, nullptr); + _M_pback_end_save = std::__exchange(__rhs._M_pback_end_save, nullptr); + _M_pback_init = std::__exchange(__rhs._M_pback_init, false); + __rhs._M_set_buffer(-1); + __rhs._M_state_last = __rhs._M_state_cur = __rhs._M_state_beg; + return *this; + } + + template + void + basic_filebuf<_CharT, _Traits>:: + swap(basic_filebuf& __rhs) + { + __streambuf_type::swap(__rhs); + _M_file.swap(__rhs._M_file); + std::swap(_M_mode, __rhs._M_mode); + std::swap(_M_state_beg, __rhs._M_state_beg); + std::swap(_M_state_cur, __rhs._M_state_cur); + std::swap(_M_state_last, __rhs._M_state_last); + std::swap(_M_buf, __rhs._M_buf); + std::swap(_M_buf_size, __rhs._M_buf_size); + std::swap(_M_buf_allocated, __rhs._M_buf_allocated); + std::swap(_M_ext_buf, __rhs._M_ext_buf); + std::swap(_M_ext_buf_size, __rhs._M_ext_buf_size); + std::swap(_M_ext_next, __rhs._M_ext_next); + std::swap(_M_ext_end, __rhs._M_ext_end); + std::swap(_M_reading, __rhs._M_reading); + std::swap(_M_writing, __rhs._M_writing); + std::swap(_M_pback_cur_save, __rhs._M_pback_cur_save); + std::swap(_M_pback_end_save, __rhs._M_pback_end_save); + std::swap(_M_pback_init, __rhs._M_pback_init); + } +#endif + + template + typename basic_filebuf<_CharT, _Traits>::__filebuf_type* + basic_filebuf<_CharT, _Traits>:: + open(const char* __s, ios_base::openmode __mode) + { + __filebuf_type *__ret = 0; + if (!this->is_open()) + { + _M_file.open(__s, __mode); + if (this->is_open()) + { + _M_allocate_internal_buffer(); + _M_mode = __mode; + + // Setup initial buffer to 'uncommitted' mode. + _M_reading = false; + _M_writing = false; + _M_set_buffer(-1); + + // Reset to initial state. + _M_state_last = _M_state_cur = _M_state_beg; + + // 27.8.1.3,4 + if ((__mode & ios_base::ate) + && this->seekoff(0, ios_base::end, __mode) + == pos_type(off_type(-1))) + this->close(); + else + __ret = this; + } + } + return __ret; + } + +#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T + template + basic_filebuf<_CharT, _Traits>* + basic_filebuf<_CharT, _Traits>:: + open(const wchar_t* __s, ios_base::openmode __mode) + { + __filebuf_type *__ret = 0; + if (!this->is_open()) + { + _M_file.open(__s, __mode); + if (this->is_open()) + { + _M_allocate_internal_buffer(); + _M_mode = __mode; + + // Setup initial buffer to 'uncommitted' mode. + _M_reading = false; + _M_writing = false; + _M_set_buffer(-1); + + // Reset to initial state. + _M_state_last = _M_state_cur = _M_state_beg; + + // 27.8.1.3,4 + if ((__mode & ios_base::ate) + && this->seekoff(0, ios_base::end, __mode) + == pos_type(off_type(-1))) + this->close(); + else + __ret = this; + } + } + return __ret; + } +#endif // HAVE__WFOPEN && USE_WCHAR_T + + template + typename basic_filebuf<_CharT, _Traits>::__filebuf_type* + basic_filebuf<_CharT, _Traits>:: + close() + { + if (!this->is_open()) + return 0; + + bool __testfail = false; + { + // NB: Do this here so that re-opened filebufs will be cool... + struct __close_sentry + { + basic_filebuf *__fb; + __close_sentry (basic_filebuf *__fbi): __fb(__fbi) { } + ~__close_sentry () + { + __fb->_M_mode = ios_base::openmode(0); + __fb->_M_pback_init = false; + __fb->_M_destroy_internal_buffer(); + __fb->_M_reading = false; + __fb->_M_writing = false; + __fb->_M_set_buffer(-1); + __fb->_M_state_last = __fb->_M_state_cur = __fb->_M_state_beg; + } + } __cs (this); + + __try + { + if (!_M_terminate_output()) + __testfail = true; + } + __catch(...) + { + _M_file.close(); + __throw_exception_again; + } + } + + if (!_M_file.close()) + __testfail = true; + + if (__testfail) + return 0; + else + return this; + } + + template + streamsize + basic_filebuf<_CharT, _Traits>:: + showmanyc() + { + streamsize __ret = -1; + const bool __testin = _M_mode & ios_base::in; + if (__testin && this->is_open()) + { + // For a stateful encoding (-1) the pending sequence might be just + // shift and unshift prefixes with no actual character. + __ret = this->egptr() - this->gptr(); + +#if _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM + // About this workaround, see libstdc++/20806. + const bool __testbinary = _M_mode & ios_base::binary; + if (__check_facet(_M_codecvt).encoding() >= 0 + && __testbinary) +#else + if (__check_facet(_M_codecvt).encoding() >= 0) +#endif + __ret += _M_file.showmanyc() / _M_codecvt->max_length(); + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::int_type + basic_filebuf<_CharT, _Traits>:: + underflow() + { + int_type __ret = traits_type::eof(); + const bool __testin = _M_mode & ios_base::in; + if (__testin) + { + if (_M_writing) + { + if (overflow() == traits_type::eof()) + return __ret; + _M_set_buffer(-1); + _M_writing = false; + } + // Check for pback madness, and if so switch back to the + // normal buffers and jet outta here before expensive + // fileops happen... + _M_destroy_pback(); + + if (this->gptr() < this->egptr()) + return traits_type::to_int_type(*this->gptr()); + + // Get and convert input sequence. + const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; + + // Will be set to true if ::read() returns 0 indicating EOF. + bool __got_eof = false; + // Number of internal characters produced. + streamsize __ilen = 0; + codecvt_base::result __r = codecvt_base::ok; + if (__check_facet(_M_codecvt).always_noconv()) + { + __ilen = _M_file.xsgetn(reinterpret_cast(this->eback()), + __buflen); + if (__ilen == 0) + __got_eof = true; + } + else + { + // Worst-case number of external bytes. + // XXX Not done encoding() == -1. + const int __enc = _M_codecvt->encoding(); + streamsize __blen; // Minimum buffer size. + streamsize __rlen; // Number of chars to read. + if (__enc > 0) + __blen = __rlen = __buflen * __enc; + else + { + __blen = __buflen + _M_codecvt->max_length() - 1; + __rlen = __buflen; + } + const streamsize __remainder = _M_ext_end - _M_ext_next; + __rlen = __rlen > __remainder ? __rlen - __remainder : 0; + + // An imbue in 'read' mode implies first converting the external + // chars already present. + if (_M_reading && this->egptr() == this->eback() && __remainder) + __rlen = 0; + + // Allocate buffer if necessary and move unconverted + // bytes to front. + if (_M_ext_buf_size < __blen) + { + char* __buf = new char[__blen]; + if (__remainder) + __builtin_memcpy(__buf, _M_ext_next, __remainder); + + delete [] _M_ext_buf; + _M_ext_buf = __buf; + _M_ext_buf_size = __blen; + } + else if (__remainder) + __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder); + + _M_ext_next = _M_ext_buf; + _M_ext_end = _M_ext_buf + __remainder; + _M_state_last = _M_state_cur; + + do + { + if (__rlen > 0) + { + // Sanity check! + // This may fail if the return value of + // codecvt::max_length() is bogus. + if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size) + { + __throw_ios_failure(__N("basic_filebuf::underflow " + "codecvt::max_length() " + "is not valid")); + } + streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen); + if (__elen == 0) + __got_eof = true; + else if (__elen == -1) + break; + _M_ext_end += __elen; + } + + char_type* __iend = this->eback(); + if (_M_ext_next < _M_ext_end) + __r = _M_codecvt->in(_M_state_cur, _M_ext_next, + _M_ext_end, _M_ext_next, + this->eback(), + this->eback() + __buflen, __iend); + if (__r == codecvt_base::noconv) + { + size_t __avail = _M_ext_end - _M_ext_buf; + __ilen = std::min(__avail, __buflen); + traits_type::copy(this->eback(), + reinterpret_cast + (_M_ext_buf), __ilen); + _M_ext_next = _M_ext_buf + __ilen; + } + else + __ilen = __iend - this->eback(); + + // _M_codecvt->in may return error while __ilen > 0: this is + // ok, and actually occurs in case of mixed encodings (e.g., + // XML files). + if (__r == codecvt_base::error) + break; + + __rlen = 1; + } + while (__ilen == 0 && !__got_eof); + } + + if (__ilen > 0) + { + _M_set_buffer(__ilen); + _M_reading = true; + __ret = traits_type::to_int_type(*this->gptr()); + } + else if (__got_eof) + { + // If the actual end of file is reached, set 'uncommitted' + // mode, thus allowing an immediate write without an + // intervening seek. + _M_set_buffer(-1); + _M_reading = false; + // However, reaching it while looping on partial means that + // the file has got an incomplete character. + if (__r == codecvt_base::partial) + __throw_ios_failure(__N("basic_filebuf::underflow " + "incomplete character in file")); + } + else if (__r == codecvt_base::error) + __throw_ios_failure(__N("basic_filebuf::underflow " + "invalid byte sequence in file")); + else + __throw_ios_failure(__N("basic_filebuf::underflow " + "error reading the file"), errno); + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::int_type + basic_filebuf<_CharT, _Traits>:: + pbackfail(int_type __i) + { + int_type __ret = traits_type::eof(); + const bool __testin = _M_mode & ios_base::in; + if (__testin) + { + if (_M_writing) + { + if (overflow() == traits_type::eof()) + return __ret; + _M_set_buffer(-1); + _M_writing = false; + } + // Remember whether the pback buffer is active, otherwise below + // we may try to store in it a second char (libstdc++/9761). + const bool __testpb = _M_pback_init; + const bool __testeof = traits_type::eq_int_type(__i, __ret); + int_type __tmp; + if (this->eback() < this->gptr()) + { + this->gbump(-1); + __tmp = traits_type::to_int_type(*this->gptr()); + } + else if (this->seekoff(-1, ios_base::cur) != pos_type(off_type(-1))) + { + __tmp = this->underflow(); + if (traits_type::eq_int_type(__tmp, __ret)) + return __ret; + } + else + { + // At the beginning of the buffer, need to make a + // putback position available. But the seek may fail + // (f.i., at the beginning of a file, see + // libstdc++/9439) and in that case we return + // traits_type::eof(). + return __ret; + } + + // Try to put back __i into input sequence in one of three ways. + // Order these tests done in is unspecified by the standard. + if (!__testeof && traits_type::eq_int_type(__i, __tmp)) + __ret = __i; + else if (__testeof) + __ret = traits_type::not_eof(__i); + else if (!__testpb) + { + _M_create_pback(); + _M_reading = true; + *this->gptr() = traits_type::to_char_type(__i); + __ret = __i; + } + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::int_type + basic_filebuf<_CharT, _Traits>:: + overflow(int_type __c) + { + int_type __ret = traits_type::eof(); + const bool __testeof = traits_type::eq_int_type(__c, __ret); + const bool __testout = (_M_mode & ios_base::out + || _M_mode & ios_base::app); + if (__testout) + { + if (_M_reading) + { + _M_destroy_pback(); + const int __gptr_off = _M_get_ext_pos(_M_state_last); + if (_M_seek(__gptr_off, ios_base::cur, _M_state_last) + == pos_type(off_type(-1))) + return __ret; + } + if (this->pbase() < this->pptr()) + { + // If appropriate, append the overflow char. + if (!__testeof) + { + *this->pptr() = traits_type::to_char_type(__c); + this->pbump(1); + } + + // Convert pending sequence to external representation, + // and output. + if (_M_convert_to_external(this->pbase(), + this->pptr() - this->pbase())) + { + _M_set_buffer(0); + __ret = traits_type::not_eof(__c); + } + } + else if (_M_buf_size > 1) + { + // Overflow in 'uncommitted' mode: set _M_writing, set + // the buffer to the initial 'write' mode, and put __c + // into the buffer. + _M_set_buffer(0); + _M_writing = true; + if (!__testeof) + { + *this->pptr() = traits_type::to_char_type(__c); + this->pbump(1); + } + __ret = traits_type::not_eof(__c); + } + else + { + // Unbuffered. + char_type __conv = traits_type::to_char_type(__c); + if (__testeof || _M_convert_to_external(&__conv, 1)) + { + _M_writing = true; + __ret = traits_type::not_eof(__c); + } + } + } + return __ret; + } + + template + bool + basic_filebuf<_CharT, _Traits>:: + _M_convert_to_external(_CharT* __ibuf, streamsize __ilen) + { + // Sizes of external and pending output. + streamsize __elen; + streamsize __plen; + if (__check_facet(_M_codecvt).always_noconv()) + { + __elen = _M_file.xsputn(reinterpret_cast(__ibuf), __ilen); + __plen = __ilen; + } + else + { + // Worst-case number of external bytes needed. + // XXX Not done encoding() == -1. + streamsize __blen = __ilen * _M_codecvt->max_length(); + char* __buf = static_cast(__builtin_alloca(__blen)); + + char* __bend; + const char_type* __iend; + codecvt_base::result __r; + __r = _M_codecvt->out(_M_state_cur, __ibuf, __ibuf + __ilen, + __iend, __buf, __buf + __blen, __bend); + + if (__r == codecvt_base::ok || __r == codecvt_base::partial) + __blen = __bend - __buf; + else if (__r == codecvt_base::noconv) + { + // Same as the always_noconv case above. + __buf = reinterpret_cast(__ibuf); + __blen = __ilen; + } + else + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " + "conversion error")); + + __elen = _M_file.xsputn(__buf, __blen); + __plen = __blen; + + // Try once more for partial conversions. + if (__r == codecvt_base::partial && __elen == __plen) + { + const char_type* __iresume = __iend; + streamsize __rlen = this->pptr() - __iend; + __r = _M_codecvt->out(_M_state_cur, __iresume, + __iresume + __rlen, __iend, __buf, + __buf + __blen, __bend); + if (__r != codecvt_base::error) + { + __rlen = __bend - __buf; + __elen = _M_file.xsputn(__buf, __rlen); + __plen = __rlen; + } + else + __throw_ios_failure(__N("basic_filebuf::_M_convert_to_external " + "conversion error")); + } + } + return __elen == __plen; + } + + template + streamsize + basic_filebuf<_CharT, _Traits>:: + xsgetn(_CharT* __s, streamsize __n) + { + // Clear out pback buffer before going on to the real deal... + streamsize __ret = 0; + if (_M_pback_init) + { + if (__n > 0 && this->gptr() == this->eback()) + { + *__s++ = *this->gptr(); // emulate non-underflowing sbumpc + this->gbump(1); + __ret = 1; + --__n; + } + _M_destroy_pback(); + } + else if (_M_writing) + { + if (overflow() == traits_type::eof()) + return __ret; + _M_set_buffer(-1); + _M_writing = false; + } + + // Optimization in the always_noconv() case, to be generalized in the + // future: when __n > __buflen we read directly instead of using the + // buffer repeatedly. + const bool __testin = _M_mode & ios_base::in; + const streamsize __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1; + + if (__n > __buflen && __check_facet(_M_codecvt).always_noconv() + && __testin) + { + // First, copy the chars already present in the buffer. + const streamsize __avail = this->egptr() - this->gptr(); + if (__avail != 0) + { + traits_type::copy(__s, this->gptr(), __avail); + __s += __avail; + this->setg(this->eback(), this->gptr() + __avail, this->egptr()); + __ret += __avail; + __n -= __avail; + } + + // Need to loop in case of short reads (relatively common + // with pipes). + streamsize __len; + for (;;) + { + __len = _M_file.xsgetn(reinterpret_cast(__s), __n); + if (__len == -1) + __throw_ios_failure(__N("basic_filebuf::xsgetn " + "error reading the file"), errno); + if (__len == 0) + break; + + __n -= __len; + __ret += __len; + if (__n == 0) + break; + + __s += __len; + } + + if (__n == 0) + { + // Set _M_reading. Buffer is already in initial 'read' mode. + _M_reading = true; + } + else if (__len == 0) + { + // If end of file is reached, set 'uncommitted' + // mode, thus allowing an immediate write without + // an intervening seek. + _M_set_buffer(-1); + _M_reading = false; + } + } + else + __ret += __streambuf_type::xsgetn(__s, __n); + + return __ret; + } + + template + streamsize + basic_filebuf<_CharT, _Traits>:: + xsputn(const _CharT* __s, streamsize __n) + { + streamsize __ret = 0; + // Optimization in the always_noconv() case, to be generalized in the + // future: when __n is sufficiently large we write directly instead of + // using the buffer. + const bool __testout = (_M_mode & ios_base::out + || _M_mode & ios_base::app); + if (__check_facet(_M_codecvt).always_noconv() + && __testout && !_M_reading) + { + // Measurement would reveal the best choice. + const streamsize __chunk = 1ul << 10; + streamsize __bufavail = this->epptr() - this->pptr(); + + // Don't mistake 'uncommitted' mode buffered with unbuffered. + if (!_M_writing && _M_buf_size > 1) + __bufavail = _M_buf_size - 1; + + const streamsize __limit = std::min(__chunk, __bufavail); + if (__n >= __limit) + { + const streamsize __buffill = this->pptr() - this->pbase(); + const char* __buf = reinterpret_cast(this->pbase()); + __ret = _M_file.xsputn_2(__buf, __buffill, + reinterpret_cast(__s), + __n); + if (__ret == __buffill + __n) + { + _M_set_buffer(0); + _M_writing = true; + } + if (__ret > __buffill) + __ret -= __buffill; + else + __ret = 0; + } + else + __ret = __streambuf_type::xsputn(__s, __n); + } + else + __ret = __streambuf_type::xsputn(__s, __n); + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::__streambuf_type* + basic_filebuf<_CharT, _Traits>:: + setbuf(char_type* __s, streamsize __n) + { + if (!this->is_open()) + { + if (__s == 0 && __n == 0) + _M_buf_size = 1; + else if (__s && __n > 0) + { + // This is implementation-defined behavior, and assumes that + // an external char_type array of length __n exists and has + // been pre-allocated. If this is not the case, things will + // quickly blow up. When __n > 1, __n - 1 positions will be + // used for the get area, __n - 1 for the put area and 1 + // position to host the overflow char of a full put area. + // When __n == 1, 1 position will be used for the get area + // and 0 for the put area, as in the unbuffered case above. + _M_buf = __s; + _M_buf_size = __n; + } + } + return this; + } + + + // According to 27.8.1.4 p11 - 13, seekoff should ignore the last + // argument (of type openmode). + template + typename basic_filebuf<_CharT, _Traits>::pos_type + basic_filebuf<_CharT, _Traits>:: + seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) + { + int __width = 0; + if (_M_codecvt) + __width = _M_codecvt->encoding(); + if (__width < 0) + __width = 0; + + pos_type __ret = pos_type(off_type(-1)); + const bool __testfail = __off != 0 && __width <= 0; + if (this->is_open() && !__testfail) + { + // tellg and tellp queries do not affect any state, unless + // ! always_noconv and the put sequence is not empty. + // In that case, determining the position requires converting the + // put sequence. That doesn't use ext_buf, so requires a flush. + bool __no_movement = __way == ios_base::cur && __off == 0 + && (!_M_writing || _M_codecvt->always_noconv()); + + // Ditch any pback buffers to avoid confusion. + if (!__no_movement) + _M_destroy_pback(); + + // Correct state at destination. Note that this is the correct + // state for the current position during output, because + // codecvt::unshift() returns the state to the initial state. + // This is also the correct state at the end of the file because + // an unshift sequence should have been written at the end. + __state_type __state = _M_state_beg; + off_type __computed_off = __off * __width; + if (_M_reading && __way == ios_base::cur) + { + __state = _M_state_last; + __computed_off += _M_get_ext_pos(__state); + } + if (!__no_movement) + __ret = _M_seek(__computed_off, __way, __state); + else + { + if (_M_writing) + __computed_off = this->pptr() - this->pbase(); + + off_type __file_off = _M_file.seekoff(0, ios_base::cur); + if (__file_off != off_type(-1)) + { + __ret = __file_off + __computed_off; + __ret.state(__state); + } + } + } + return __ret; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 171. Strange seekpos() semantics due to joint position + // According to the resolution of DR 171, seekpos should ignore the last + // argument (of type openmode). + template + typename basic_filebuf<_CharT, _Traits>::pos_type + basic_filebuf<_CharT, _Traits>:: + seekpos(pos_type __pos, ios_base::openmode) + { + pos_type __ret = pos_type(off_type(-1)); + if (this->is_open()) + { + // Ditch any pback buffers to avoid confusion. + _M_destroy_pback(); + __ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state()); + } + return __ret; + } + + template + typename basic_filebuf<_CharT, _Traits>::pos_type + basic_filebuf<_CharT, _Traits>:: + _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state) + { + pos_type __ret = pos_type(off_type(-1)); + if (_M_terminate_output()) + { + off_type __file_off = _M_file.seekoff(__off, __way); + if (__file_off != off_type(-1)) + { + _M_reading = false; + _M_writing = false; + _M_ext_next = _M_ext_end = _M_ext_buf; + _M_set_buffer(-1); + _M_state_cur = __state; + __ret = __file_off; + __ret.state(_M_state_cur); + } + } + return __ret; + } + + // Returns the distance from the end of the ext buffer to the point + // corresponding to gptr(). This is a negative value. Updates __state + // from eback() correspondence to gptr(). + template + int basic_filebuf<_CharT, _Traits>:: + _M_get_ext_pos(__state_type& __state) + { + if (_M_codecvt->always_noconv()) + return this->gptr() - this->egptr(); + else + { + // Calculate offset from _M_ext_buf that corresponds to + // gptr(). Precondition: __state == _M_state_last, which + // corresponds to eback(). + const int __gptr_off = + _M_codecvt->length(__state, _M_ext_buf, _M_ext_next, + this->gptr() - this->eback()); + return _M_ext_buf + __gptr_off - _M_ext_end; + } + } + + template + bool + basic_filebuf<_CharT, _Traits>:: + _M_terminate_output() + { + // Part one: update the output sequence. + bool __testvalid = true; + if (this->pbase() < this->pptr()) + { + const int_type __tmp = this->overflow(); + if (traits_type::eq_int_type(__tmp, traits_type::eof())) + __testvalid = false; + } + + // Part two: output unshift sequence. + if (_M_writing && !__check_facet(_M_codecvt).always_noconv() + && __testvalid) + { + // Note: this value is arbitrary, since there is no way to + // get the length of the unshift sequence from codecvt, + // without calling unshift. + const size_t __blen = 128; + char __buf[__blen]; + codecvt_base::result __r; + streamsize __ilen = 0; + + do + { + char* __next; + __r = _M_codecvt->unshift(_M_state_cur, __buf, + __buf + __blen, __next); + if (__r == codecvt_base::error) + __testvalid = false; + else if (__r == codecvt_base::ok || + __r == codecvt_base::partial) + { + __ilen = __next - __buf; + if (__ilen > 0) + { + const streamsize __elen = _M_file.xsputn(__buf, __ilen); + if (__elen != __ilen) + __testvalid = false; + } + } + } + while (__r == codecvt_base::partial && __ilen > 0 && __testvalid); + + if (__testvalid) + { + // This second call to overflow() is required by the standard, + // but it's not clear why it's needed, since the output buffer + // should be empty by this point (it should have been emptied + // in the first call to overflow()). + const int_type __tmp = this->overflow(); + if (traits_type::eq_int_type(__tmp, traits_type::eof())) + __testvalid = false; + } + } + return __testvalid; + } + + template + int + basic_filebuf<_CharT, _Traits>:: + sync() + { + // Make sure that the internal buffer resyncs its idea of + // the file position with the external file. + int __ret = 0; + if (this->pbase() < this->pptr()) + { + const int_type __tmp = this->overflow(); + if (traits_type::eq_int_type(__tmp, traits_type::eof())) + __ret = -1; + } + return __ret; + } + + template + void + basic_filebuf<_CharT, _Traits>:: + imbue(const locale& __loc) + { + bool __testvalid = true; + + const __codecvt_type* _M_codecvt_tmp = 0; + if (__builtin_expect(has_facet<__codecvt_type>(__loc), true)) + _M_codecvt_tmp = &use_facet<__codecvt_type>(__loc); + + if (this->is_open()) + { + // encoding() == -1 is ok only at the beginning. + if ((_M_reading || _M_writing) + && __check_facet(_M_codecvt).encoding() == -1) + __testvalid = false; + else + { + if (_M_reading) + { + if (__check_facet(_M_codecvt).always_noconv()) + { + if (_M_codecvt_tmp + && !__check_facet(_M_codecvt_tmp).always_noconv()) + __testvalid = this->seekoff(0, ios_base::cur, _M_mode) + != pos_type(off_type(-1)); + } + else + { + // External position corresponding to gptr(). + _M_ext_next = _M_ext_buf + + _M_codecvt->length(_M_state_last, _M_ext_buf, + _M_ext_next, + this->gptr() - this->eback()); + const streamsize __remainder = _M_ext_end - _M_ext_next; + if (__remainder) + __builtin_memmove(_M_ext_buf, _M_ext_next, __remainder); + + _M_ext_next = _M_ext_buf; + _M_ext_end = _M_ext_buf + __remainder; + _M_set_buffer(-1); + _M_state_last = _M_state_cur = _M_state_beg; + } + } + else if (_M_writing && (__testvalid = _M_terminate_output())) + _M_set_buffer(-1); + } + } + + if (__testvalid) + _M_codecvt = _M_codecvt_tmp; + else + _M_codecvt = 0; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_filebuf; + extern template class basic_ifstream; + extern template class basic_ofstream; + extern template class basic_fstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_filebuf; + extern template class basic_ifstream; + extern template class basic_ofstream; + extern template class basic_fstream; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/functexcept.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/functexcept.h new file mode 100755 index 0000000..56ef318 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/functexcept.h @@ -0,0 +1,118 @@ +// Function-Based Exception Support -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/functexcept.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + * + * This header provides support for -fno-exceptions. + */ + +// +// ISO C++ 14882: 19.1 Exception classes +// + +#ifndef _FUNCTEXCEPT_H +#define _FUNCTEXCEPT_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Helper for exception objects in + void + __throw_bad_exception(void) __attribute__((__noreturn__)); + + // Helper for exception objects in + void + __throw_bad_alloc(void) __attribute__((__noreturn__)); + + void + __throw_bad_array_new_length(void) __attribute__((__noreturn__)); + + // Helper for exception objects in + void + __throw_bad_cast(void) __attribute__((__noreturn__)); + + void + __throw_bad_typeid(void) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_logic_error(const char*) __attribute__((__noreturn__)); + + void + __throw_domain_error(const char*) __attribute__((__noreturn__)); + + void + __throw_invalid_argument(const char*) __attribute__((__noreturn__)); + + void + __throw_length_error(const char*) __attribute__((__noreturn__)); + + void + __throw_out_of_range(const char*) __attribute__((__noreturn__)); + + void + __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__)) + __attribute__((__format__(__gnu_printf__, 1, 2))); + + void + __throw_runtime_error(const char*) __attribute__((__noreturn__)); + + void + __throw_range_error(const char*) __attribute__((__noreturn__)); + + void + __throw_overflow_error(const char*) __attribute__((__noreturn__)); + + void + __throw_underflow_error(const char*) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_ios_failure(const char*) __attribute__((__noreturn__)); + + void + __throw_ios_failure(const char*, int) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_system_error(int) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_future_error(int) __attribute__((__noreturn__)); + + // Helpers for exception objects in + void + __throw_bad_function_call() __attribute__((__noreturn__)); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/functional_hash.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/functional_hash.h new file mode 100755 index 0000000..7be8ebf --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/functional_hash.h @@ -0,0 +1,290 @@ +// functional_hash.h header -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/functional_hash.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _FUNCTIONAL_HASH_H +#define _FUNCTIONAL_HASH_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @defgroup hashes Hashes + * @ingroup functors + * + * Hashing functors taking a variable type and returning a @c std::size_t. + * + * @{ + */ + + template + struct __hash_base + { + typedef _Result result_type _GLIBCXX17_DEPRECATED; + typedef _Arg argument_type _GLIBCXX17_DEPRECATED; + }; + + /// Primary class template hash. + template + struct hash; + + template + struct __poison_hash + { + static constexpr bool __enable_hash_call = false; + private: + // Private rather than deleted to be non-trivially-copyable. + __poison_hash(__poison_hash&&); + ~__poison_hash(); + }; + + template + struct __poison_hash<_Tp, __void_t()(declval<_Tp>()))>> + { + static constexpr bool __enable_hash_call = true; + }; + + // Helper struct for SFINAE-poisoning non-enum types. + template::value> + struct __hash_enum + { + private: + // Private rather than deleted to be non-trivially-copyable. + __hash_enum(__hash_enum&&); + ~__hash_enum(); + }; + + // Helper struct for hash with enum types. + template + struct __hash_enum<_Tp, true> : public __hash_base + { + size_t + operator()(_Tp __val) const noexcept + { + using __type = typename underlying_type<_Tp>::type; + return hash<__type>{}(static_cast<__type>(__val)); + } + }; + + /// Primary class template hash, usable for enum types only. + // Use with non-enum types still SFINAES. + template + struct hash : __hash_enum<_Tp> + { }; + + /// Partial specializations for pointer types. + template + struct hash<_Tp*> : public __hash_base + { + size_t + operator()(_Tp* __p) const noexcept + { return reinterpret_cast(__p); } + }; + + // Explicit specializations for integer types. +#define _Cxx_hashtable_define_trivial_hash(_Tp) \ + template<> \ + struct hash<_Tp> : public __hash_base \ + { \ + size_t \ + operator()(_Tp __val) const noexcept \ + { return static_cast(__val); } \ + }; + + /// Explicit specialization for bool. + _Cxx_hashtable_define_trivial_hash(bool) + + /// Explicit specialization for char. + _Cxx_hashtable_define_trivial_hash(char) + + /// Explicit specialization for signed char. + _Cxx_hashtable_define_trivial_hash(signed char) + + /// Explicit specialization for unsigned char. + _Cxx_hashtable_define_trivial_hash(unsigned char) + + /// Explicit specialization for wchar_t. + _Cxx_hashtable_define_trivial_hash(wchar_t) + +#ifdef _GLIBCXX_USE_CHAR8_T + /// Explicit specialization for char8_t. + _Cxx_hashtable_define_trivial_hash(char8_t) +#endif + + /// Explicit specialization for char16_t. + _Cxx_hashtable_define_trivial_hash(char16_t) + + /// Explicit specialization for char32_t. + _Cxx_hashtable_define_trivial_hash(char32_t) + + /// Explicit specialization for short. + _Cxx_hashtable_define_trivial_hash(short) + + /// Explicit specialization for int. + _Cxx_hashtable_define_trivial_hash(int) + + /// Explicit specialization for long. + _Cxx_hashtable_define_trivial_hash(long) + + /// Explicit specialization for long long. + _Cxx_hashtable_define_trivial_hash(long long) + + /// Explicit specialization for unsigned short. + _Cxx_hashtable_define_trivial_hash(unsigned short) + + /// Explicit specialization for unsigned int. + _Cxx_hashtable_define_trivial_hash(unsigned int) + + /// Explicit specialization for unsigned long. + _Cxx_hashtable_define_trivial_hash(unsigned long) + + /// Explicit specialization for unsigned long long. + _Cxx_hashtable_define_trivial_hash(unsigned long long) + +#ifdef __GLIBCXX_TYPE_INT_N_0 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_0 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_1 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_2 unsigned) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3) + _Cxx_hashtable_define_trivial_hash(__GLIBCXX_TYPE_INT_N_3 unsigned) +#endif + +#undef _Cxx_hashtable_define_trivial_hash + + struct _Hash_impl + { + static size_t + hash(const void* __ptr, size_t __clength, + size_t __seed = static_cast(0xc70f6907UL)) + { return _Hash_bytes(__ptr, __clength, __seed); } + + template + static size_t + hash(const _Tp& __val) + { return hash(&__val, sizeof(__val)); } + + template + static size_t + __hash_combine(const _Tp& __val, size_t __hash) + { return hash(&__val, sizeof(__val), __hash); } + }; + + // A hash function similar to FNV-1a (see PR59406 for how it differs). + struct _Fnv_hash_impl + { + static size_t + hash(const void* __ptr, size_t __clength, + size_t __seed = static_cast(2166136261UL)) + { return _Fnv_hash_bytes(__ptr, __clength, __seed); } + + template + static size_t + hash(const _Tp& __val) + { return hash(&__val, sizeof(__val)); } + + template + static size_t + __hash_combine(const _Tp& __val, size_t __hash) + { return hash(&__val, sizeof(__val), __hash); } + }; + + /// Specialization for float. + template<> + struct hash : public __hash_base + { + size_t + operator()(float __val) const noexcept + { + // 0 and -0 both hash to zero. + return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0; + } + }; + + /// Specialization for double. + template<> + struct hash : public __hash_base + { + size_t + operator()(double __val) const noexcept + { + // 0 and -0 both hash to zero. + return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0; + } + }; + + /// Specialization for long double. + template<> + struct hash + : public __hash_base + { + _GLIBCXX_PURE size_t + operator()(long double __val) const noexcept; + }; + +#if __cplusplus >= 201703L + template<> + struct hash : public __hash_base + { + size_t + operator()(nullptr_t) const noexcept + { return 0; } + }; +#endif + + /// @} group hashes + + // Hint about performance of hash functor. If not fast the hash-based + // containers will cache the hash code. + // Default behavior is to consider that hashers are fast unless specified + // otherwise. + template + struct __is_fast_hash : public std::true_type + { }; + + template<> + struct __is_fast_hash> : public std::false_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _FUNCTIONAL_HASH_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/gslice.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/gslice.h new file mode 100755 index 0000000..ae2052b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/gslice.h @@ -0,0 +1,185 @@ +// The template and inlines for the -*- C++ -*- gslice class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/gslice.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _GSLICE_H +#define _GSLICE_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Class defining multi-dimensional subset of an array. + * + * The slice class represents a multi-dimensional subset of an array, + * specified by three parameter sets: start offset, size array, and stride + * array. The start offset is the index of the first element of the array + * that is part of the subset. The size and stride array describe each + * dimension of the slice. Size is the number of elements in that + * dimension, and stride is the distance in the array between successive + * elements in that dimension. Each dimension's size and stride is taken + * to begin at an array element described by the previous dimension. The + * size array and stride array must be the same size. + * + * For example, if you have offset==3, stride[0]==11, size[1]==3, + * stride[1]==3, then slice[0,0]==array[3], slice[0,1]==array[6], + * slice[0,2]==array[9], slice[1,0]==array[14], slice[1,1]==array[17], + * slice[1,2]==array[20]. + */ + class gslice + { + public: + /// Construct an empty slice. + gslice(); + + /** + * @brief Construct a slice. + * + * Constructs a slice with as many dimensions as the length of the @a l + * and @a s arrays. + * + * @param __o Offset in array of first element. + * @param __l Array of dimension lengths. + * @param __s Array of dimension strides between array elements. + */ + gslice(size_t __o, const valarray& __l, + const valarray& __s); + + // XXX: the IS says the copy-ctor and copy-assignment operators are + // synthesized by the compiler but they are just unsuitable + // for a ref-counted semantic + /// Copy constructor. + gslice(const gslice&); + + /// Destructor. + ~gslice(); + + // XXX: See the note above. + /// Assignment operator. + gslice& operator=(const gslice&); + + /// Return array offset of first slice element. + size_t start() const; + + /// Return array of sizes of slice dimensions. + valarray size() const; + + /// Return array of array strides for each dimension. + valarray stride() const; + + private: + struct _Indexer + { + size_t _M_count; + size_t _M_start; + valarray _M_size; + valarray _M_stride; + valarray _M_index; // Linear array of referenced indices + + _Indexer() + : _M_count(1), _M_start(0), _M_size(), _M_stride(), _M_index() {} + + _Indexer(size_t, const valarray&, + const valarray&); + + void + _M_increment_use() + { ++_M_count; } + + size_t + _M_decrement_use() + { return --_M_count; } + }; + + _Indexer* _M_index; + + template friend class valarray; + }; + + inline size_t + gslice::start() const + { return _M_index ? _M_index->_M_start : 0; } + + inline valarray + gslice::size() const + { return _M_index ? _M_index->_M_size : valarray(); } + + inline valarray + gslice::stride() const + { return _M_index ? _M_index->_M_stride : valarray(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 543. valarray slice default constructor + inline + gslice::gslice() + : _M_index(new gslice::_Indexer()) {} + + inline + gslice::gslice(size_t __o, const valarray& __l, + const valarray& __s) + : _M_index(new gslice::_Indexer(__o, __l, __s)) {} + + inline + gslice::gslice(const gslice& __g) + : _M_index(__g._M_index) + { if (_M_index) _M_index->_M_increment_use(); } + + inline + gslice::~gslice() + { + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + } + + inline gslice& + gslice::operator=(const gslice& __g) + { + if (__g._M_index) + __g._M_index->_M_increment_use(); + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + _M_index = __g._M_index; + return *this; + } + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GSLICE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/gslice_array.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/gslice_array.h new file mode 100755 index 0000000..4f3309d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/gslice_array.h @@ -0,0 +1,223 @@ +// The template and inlines for the -*- C++ -*- gslice_array class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/gslice_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _GSLICE_ARRAY_H +#define _GSLICE_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Reference to multi-dimensional subset of an array. + * + * A gslice_array is a reference to the actual elements of an array + * specified by a gslice. The way to get a gslice_array is to call + * operator[](gslice) on a valarray. The returned gslice_array then + * permits carrying operations out on the referenced subset of elements in + * the original valarray. For example, operator+=(valarray) will add + * values to the subset of elements in the underlying valarray this + * gslice_array refers to. + * + * @param Tp Element type. + */ + template + class gslice_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + gslice_array(const gslice_array&); + + /// Assignment operator. Assigns slice elements to corresponding + /// elements of @a a. + gslice_array& operator=(const gslice_array&); + + /// Assign slice elements to corresponding elements of @a v. + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator=(const _Tp&) const; + + template + void operator=(const _Expr<_Dom, _Tp>&) const; + template + void operator*=(const _Expr<_Dom, _Tp>&) const; + template + void operator/=(const _Expr<_Dom, _Tp>&) const; + template + void operator%=(const _Expr<_Dom, _Tp>&) const; + template + void operator+=(const _Expr<_Dom, _Tp>&) const; + template + void operator-=(const _Expr<_Dom, _Tp>&) const; + template + void operator^=(const _Expr<_Dom, _Tp>&) const; + template + void operator&=(const _Expr<_Dom, _Tp>&) const; + template + void operator|=(const _Expr<_Dom, _Tp>&) const; + template + void operator<<=(const _Expr<_Dom, _Tp>&) const; + template + void operator>>=(const _Expr<_Dom, _Tp>&) const; + + private: + _Array<_Tp> _M_array; + const valarray& _M_index; + + friend class valarray<_Tp>; + + gslice_array(_Array<_Tp>, const valarray&); + +#if __cplusplus < 201103L + // not implemented + gslice_array(); +#else + public: + gslice_array() = delete; +#endif + }; + + template + inline + gslice_array<_Tp>::gslice_array(_Array<_Tp> __a, + const valarray& __i) + : _M_array(__a), _M_index(__i) {} + + template + inline + gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a) + : _M_array(__a._M_array), _M_index(__a._M_index) {} + + template + inline gslice_array<_Tp>& + gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a) + { + std::__valarray_copy(_Array<_Tp>(__a._M_array), + _Array(__a._M_index), _M_index.size(), + _M_array, _Array(_M_index)); + return *this; + } + + template + inline void + gslice_array<_Tp>::operator=(const _Tp& __t) const + { + std::__valarray_fill(_M_array, _Array(_M_index), + _M_index.size(), __t); + } + + template + inline void + gslice_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { + std::__valarray_copy(_Array<_Tp>(__v), __v.size(), + _M_array, _Array(_M_index)); + } + + template + template + inline void + gslice_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const + { + std::__valarray_copy (__e, _M_index.size(), _M_array, + _Array(_M_index)); + } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ + template \ + inline void \ + gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ + { \ + _Array_augmented_##_Name(_M_array, _Array(_M_index), \ + _Array<_Tp>(__v), __v.size()); \ + } \ + \ + template \ + template \ + inline void \ + gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _Array(_M_index), __e,\ + _M_index.size()); \ + } + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _GSLICE_ARRAY_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hash_bytes.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hash_bytes.h new file mode 100755 index 0000000..55ecbe8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hash_bytes.h @@ -0,0 +1,59 @@ +// Declarations for hash functions. -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/hash_bytes.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _HASH_BYTES_H +#define _HASH_BYTES_H 1 + +#pragma GCC system_header + +#include + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Hash function implementation for the nontrivial specialization. + // All of them are based on a primitive that hashes a pointer to a + // byte array. The actual hash algorithm is not guaranteed to stay + // the same from release to release -- it may be updated or tuned to + // improve hash quality or speed. + size_t + _Hash_bytes(const void* __ptr, size_t __len, size_t __seed); + + // A similar hash primitive, using the FNV hash algorithm. This + // algorithm is guaranteed to stay the same from release to release. + // (although it might not produce the same values on different + // machines.) + size_t + _Fnv_hash_bytes(const void* __ptr, size_t __len, size_t __seed); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hashtable.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hashtable.h new file mode 100755 index 0000000..d188d9a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hashtable.h @@ -0,0 +1,2518 @@ +// hashtable.h header -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/hashtable.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{unordered_map, unordered_set} + */ + +#ifndef _HASHTABLE_H +#define _HASHTABLE_H 1 + +#pragma GCC system_header + +#include +#include +#if __cplusplus > 201402L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + using __cache_default + = __not_<__and_, + // Mandatory to have erase not throwing. + __is_nothrow_invocable>>; + + // Helper to conditionally delete the default constructor. + // The _Hash_node_base type is used to distinguish this specialization + // from any other potentially-overlapping subobjects of the hashtable. + template + using _Hashtable_enable_default_ctor + = _Enable_default_constructor<__and_, + is_default_constructible<_Hash>, + is_default_constructible<_Allocator>>{}, + __detail::_Hash_node_base>; + + /** + * Primary class template _Hashtable. + * + * @ingroup hashtable-detail + * + * @tparam _Value CopyConstructible type. + * + * @tparam _Key CopyConstructible type. + * + * @tparam _Alloc An allocator type + * ([lib.allocator.requirements]) whose _Alloc::value_type is + * _Value. As a conforming extension, we allow for + * _Alloc::value_type != _Value. + * + * @tparam _ExtractKey Function object that takes an object of type + * _Value and returns a value of type _Key. + * + * @tparam _Equal Function object that takes two objects of type k + * and returns a bool-like value that is true if the two objects + * are considered equal. + * + * @tparam _Hash The hash function. A unary function object with + * argument type _Key and result type size_t. Return values should + * be distributed over the entire range [0, numeric_limits:::max()]. + * + * @tparam _RangeHash The range-hashing function (in the terminology of + * Tavori and Dreizin). A binary function object whose argument + * types and result type are all size_t. Given arguments r and N, + * the return value is in the range [0, N). + * + * @tparam _Unused Not used. + * + * @tparam _RehashPolicy Policy class with three members, all of + * which govern the bucket count. _M_next_bkt(n) returns a bucket + * count no smaller than n. _M_bkt_for_elements(n) returns a + * bucket count appropriate for an element count of n. + * _M_need_rehash(n_bkt, n_elt, n_ins) determines whether, if the + * current bucket count is n_bkt and the current element count is + * n_elt, we need to increase the bucket count for n_ins insertions. + * If so, returns make_pair(true, n), where n is the new bucket count. If + * not, returns make_pair(false, ) + * + * @tparam _Traits Compile-time class with three boolean + * std::integral_constant members: __cache_hash_code, __constant_iterators, + * __unique_keys. + * + * Each _Hashtable data structure has: + * + * - _Bucket[] _M_buckets + * - _Hash_node_base _M_before_begin + * - size_type _M_bucket_count + * - size_type _M_element_count + * + * with _Bucket being _Hash_node_base* and _Hash_node containing: + * + * - _Hash_node* _M_next + * - Tp _M_value + * - size_t _M_hash_code if cache_hash_code is true + * + * In terms of Standard containers the hashtable is like the aggregation of: + * + * - std::forward_list<_Node> containing the elements + * - std::vector::iterator> representing the buckets + * + * The non-empty buckets contain the node before the first node in the + * bucket. This design makes it possible to implement something like a + * std::forward_list::insert_after on container insertion and + * std::forward_list::erase_after on container erase + * calls. _M_before_begin is equivalent to + * std::forward_list::before_begin. Empty buckets contain + * nullptr. Note that one of the non-empty buckets contains + * &_M_before_begin which is not a dereferenceable node so the + * node pointer in a bucket shall never be dereferenced, only its + * next node can be. + * + * Walking through a bucket's nodes requires a check on the hash code to + * see if each node is still in the bucket. Such a design assumes a + * quite efficient hash functor and is one of the reasons it is + * highly advisable to set __cache_hash_code to true. + * + * The container iterators are simply built from nodes. This way + * incrementing the iterator is perfectly efficient independent of + * how many empty buckets there are in the container. + * + * On insert we compute the element's hash code and use it to find the + * bucket index. If the element must be inserted in an empty bucket + * we add it at the beginning of the singly linked list and make the + * bucket point to _M_before_begin. The bucket that used to point to + * _M_before_begin, if any, is updated to point to its new before + * begin node. + * + * On erase, the simple iterator design requires using the hash + * functor to get the index of the bucket to update. For this + * reason, when __cache_hash_code is set to false the hash functor must + * not throw and this is enforced by a static assertion. + * + * Functionality is implemented by decomposition into base classes, + * where the derived _Hashtable class is used in _Map_base, + * _Insert, _Rehash_base, and _Equality base classes to access the + * "this" pointer. _Hashtable_base is used in the base classes as a + * non-recursive, fully-completed-type so that detailed nested type + * information, such as iterator type and node type, can be + * used. This is similar to the "Curiously Recurring Template + * Pattern" (CRTP) technique, but uses a reconstructed, not + * explicitly passed, template pattern. + * + * Base class templates are: + * - __detail::_Hashtable_base + * - __detail::_Map_base + * - __detail::_Insert + * - __detail::_Rehash_base + * - __detail::_Equality + */ + template + class _Hashtable + : public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _Traits>, + public __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + public __detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + public __detail::_Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + public __detail::_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>, + private __detail::_Hashtable_alloc< + __alloc_rebind<_Alloc, + __detail::_Hash_node<_Value, + _Traits::__hash_cached::value>>>, + private _Hashtable_enable_default_ctor<_Equal, _Hash, _Alloc> + { + static_assert(is_same::type, _Value>::value, + "unordered container must have a non-const, non-volatile value_type"); +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same{}, + "unordered container must have the same value_type as its allocator"); +#endif + + using __traits_type = _Traits; + using __hash_cached = typename __traits_type::__hash_cached; + using __constant_iterators = typename __traits_type::__constant_iterators; + using __node_type = __detail::_Hash_node<_Value, __hash_cached::value>; + using __node_alloc_type = __alloc_rebind<_Alloc, __node_type>; + + using __hashtable_alloc = __detail::_Hashtable_alloc<__node_alloc_type>; + + using __node_value_type = + __detail::_Hash_node_value<_Value, __hash_cached::value>; + using __node_ptr = typename __hashtable_alloc::__node_ptr; + using __value_alloc_traits = + typename __hashtable_alloc::__value_alloc_traits; + using __node_alloc_traits = + typename __hashtable_alloc::__node_alloc_traits; + using __node_base = typename __hashtable_alloc::__node_base; + using __node_base_ptr = typename __hashtable_alloc::__node_base_ptr; + using __buckets_ptr = typename __hashtable_alloc::__buckets_ptr; + + using __insert_base = __detail::_Insert<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, + _RangeHash, _Unused, + _RehashPolicy, _Traits>; + using __enable_default_ctor + = _Hashtable_enable_default_ctor<_Equal, _Hash, _Alloc>; + + public: + typedef _Key key_type; + typedef _Value value_type; + typedef _Alloc allocator_type; + typedef _Equal key_equal; + + // mapped_type, if present, comes from _Map_base. + // hasher, if present, comes from _Hash_code_base/_Hashtable_base. + typedef typename __value_alloc_traits::pointer pointer; + typedef typename __value_alloc_traits::const_pointer const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + using iterator = typename __insert_base::iterator; + + using const_iterator = typename __insert_base::const_iterator; + + using local_iterator = __detail::_Local_iterator; + + using const_local_iterator = __detail::_Local_const_iterator< + key_type, _Value, + _ExtractKey, _Hash, _RangeHash, _Unused, + __constant_iterators::value, __hash_cached::value>; + + private: + using __rehash_type = _RehashPolicy; + using __rehash_state = typename __rehash_type::_State; + + using __unique_keys = typename __traits_type::__unique_keys; + + using __hashtable_base = __detail:: + _Hashtable_base<_Key, _Value, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, _Traits>; + + using __hash_code_base = typename __hashtable_base::__hash_code_base; + using __hash_code = typename __hashtable_base::__hash_code; + using __ireturn_type = typename __insert_base::__ireturn_type; + + using __map_base = __detail::_Map_base<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using __rehash_base = __detail::_Rehash_base<_Key, _Value, _Alloc, + _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using __eq_base = __detail::_Equality<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using __reuse_or_alloc_node_gen_t = + __detail::_ReuseOrAllocNode<__node_alloc_type>; + using __alloc_node_gen_t = + __detail::_AllocNode<__node_alloc_type>; + + // Simple RAII type for managing a node containing an element + struct _Scoped_node + { + // Take ownership of a node with a constructed element. + _Scoped_node(__node_ptr __n, __hashtable_alloc* __h) + : _M_h(__h), _M_node(__n) { } + + // Allocate a node and construct an element within it. + template + _Scoped_node(__hashtable_alloc* __h, _Args&&... __args) + : _M_h(__h), + _M_node(__h->_M_allocate_node(std::forward<_Args>(__args)...)) + { } + + // Destroy element and deallocate node. + ~_Scoped_node() { if (_M_node) _M_h->_M_deallocate_node(_M_node); }; + + _Scoped_node(const _Scoped_node&) = delete; + _Scoped_node& operator=(const _Scoped_node&) = delete; + + __hashtable_alloc* _M_h; + __node_ptr _M_node; + }; + + template + static constexpr + typename conditional::value, + const value_type&, value_type&&>::type + __fwd_value_for(value_type& __val) noexcept + { return std::move(__val); } + + // Compile-time diagnostics. + + // _Hash_code_base has everything protected, so use this derived type to + // access it. + struct __hash_code_base_access : __hash_code_base + { using __hash_code_base::_M_bucket_index; }; + + // Getting a bucket index from a node shall not throw because it is used + // in methods (erase, swap...) that shall not throw. + static_assert(noexcept(declval() + ._M_bucket_index(declval(), + (std::size_t)0)), + "Cache the hash code or qualify your functors involved" + " in hash code and bucket index computation with noexcept"); + + // To get bucket index we need _RangeHash not to throw. + static_assert(is_nothrow_default_constructible<_RangeHash>::value, + "Functor used to map hash code to bucket index" + " must be nothrow default constructible"); + static_assert(noexcept( + std::declval()((std::size_t)0, (std::size_t)0)), + "Functor used to map hash code to bucket index must be" + " noexcept"); + + // To compute bucket index we also need _ExtratKey not to throw. + static_assert(is_nothrow_default_constructible<_ExtractKey>::value, + "_ExtractKey must be nothrow default constructible"); + static_assert(noexcept( + std::declval()(std::declval<_Value>())), + "_ExtractKey functor must be noexcept invocable"); + + template + friend struct __detail::_Map_base; + + template + friend struct __detail::_Insert_base; + + template + friend struct __detail::_Insert; + + template + friend struct __detail::_Equality; + + public: + using size_type = typename __hashtable_base::size_type; + using difference_type = typename __hashtable_base::difference_type; + +#if __cplusplus > 201402L + using node_type = _Node_handle<_Key, _Value, __node_alloc_type>; + using insert_return_type = _Node_insert_return; +#endif + + private: + __buckets_ptr _M_buckets = &_M_single_bucket; + size_type _M_bucket_count = 1; + __node_base _M_before_begin; + size_type _M_element_count = 0; + _RehashPolicy _M_rehash_policy; + + // A single bucket used when only need for 1 bucket. Especially + // interesting in move semantic to leave hashtable with only 1 bucket + // which is not allocated so that we can have those operations noexcept + // qualified. + // Note that we can't leave hashtable with 0 bucket without adding + // numerous checks in the code to avoid 0 modulus. + __node_base_ptr _M_single_bucket = nullptr; + + void + _M_update_bbegin() + { + if (_M_begin()) + _M_buckets[_M_bucket_index(*_M_begin())] = &_M_before_begin; + } + + void + _M_update_bbegin(__node_ptr __n) + { + _M_before_begin._M_nxt = __n; + _M_update_bbegin(); + } + + bool + _M_uses_single_bucket(__buckets_ptr __bkts) const + { return __builtin_expect(__bkts == &_M_single_bucket, false); } + + bool + _M_uses_single_bucket() const + { return _M_uses_single_bucket(_M_buckets); } + + __hashtable_alloc& + _M_base_alloc() { return *this; } + + __buckets_ptr + _M_allocate_buckets(size_type __bkt_count) + { + if (__builtin_expect(__bkt_count == 1, false)) + { + _M_single_bucket = nullptr; + return &_M_single_bucket; + } + + return __hashtable_alloc::_M_allocate_buckets(__bkt_count); + } + + void + _M_deallocate_buckets(__buckets_ptr __bkts, size_type __bkt_count) + { + if (_M_uses_single_bucket(__bkts)) + return; + + __hashtable_alloc::_M_deallocate_buckets(__bkts, __bkt_count); + } + + void + _M_deallocate_buckets() + { _M_deallocate_buckets(_M_buckets, _M_bucket_count); } + + // Gets bucket begin, deals with the fact that non-empty buckets contain + // their before begin node. + __node_ptr + _M_bucket_begin(size_type __bkt) const; + + __node_ptr + _M_begin() const + { return static_cast<__node_ptr>(_M_before_begin._M_nxt); } + + // Assign *this using another _Hashtable instance. Whether elements + // are copied or moved depends on the _Ht reference. + template + void + _M_assign_elements(_Ht&&); + + template + void + _M_assign(_Ht&&, const _NodeGenerator&); + + void + _M_move_assign(_Hashtable&&, true_type); + + void + _M_move_assign(_Hashtable&&, false_type); + + void + _M_reset() noexcept; + + _Hashtable(const _Hash& __h, const _Equal& __eq, + const allocator_type& __a) + : __hashtable_base(__h, __eq), + __hashtable_alloc(__node_alloc_type(__a)), + __enable_default_ctor(_Enable_default_constructor_tag{}) + { } + + template + static constexpr bool + _S_nothrow_move() + { +#if __cplusplus <= 201402L + return __and_<__bool_constant<_No_realloc>, + is_nothrow_copy_constructible<_Hash>, + is_nothrow_copy_constructible<_Equal>>::value; +#else + if constexpr (_No_realloc) + if constexpr (is_nothrow_copy_constructible<_Hash>()) + return is_nothrow_copy_constructible<_Equal>(); + return false; +#endif + } + + _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, + true_type /* alloc always equal */) + noexcept(_S_nothrow_move()); + + _Hashtable(_Hashtable&&, __node_alloc_type&&, + false_type /* alloc always equal */); + + template + _Hashtable(_InputIterator __first, _InputIterator __last, + size_type __bkt_count_hint, + const _Hash&, const _Equal&, const allocator_type&, + true_type __uks); + + template + _Hashtable(_InputIterator __first, _InputIterator __last, + size_type __bkt_count_hint, + const _Hash&, const _Equal&, const allocator_type&, + false_type __uks); + + public: + // Constructor, destructor, assignment, swap + _Hashtable() = default; + + _Hashtable(const _Hashtable&); + + _Hashtable(const _Hashtable&, const allocator_type&); + + explicit + _Hashtable(size_type __bkt_count_hint, + const _Hash& __hf = _Hash(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()); + + // Use delegating constructors. + _Hashtable(_Hashtable&& __ht) + noexcept(_S_nothrow_move()) + : _Hashtable(std::move(__ht), std::move(__ht._M_node_allocator()), + true_type{}) + { } + + _Hashtable(_Hashtable&& __ht, const allocator_type& __a) + noexcept(_S_nothrow_move<__node_alloc_traits::_S_always_equal()>()) + : _Hashtable(std::move(__ht), __node_alloc_type(__a), + typename __node_alloc_traits::is_always_equal{}) + { } + + explicit + _Hashtable(const allocator_type& __a) + : __hashtable_alloc(__node_alloc_type(__a)), + __enable_default_ctor(_Enable_default_constructor_tag{}) + { } + + template + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bkt_count_hint = 0, + const _Hash& __hf = _Hash(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Hashtable(__f, __l, __bkt_count_hint, __hf, __eql, __a, + __unique_keys{}) + { } + + _Hashtable(initializer_list __l, + size_type __bkt_count_hint = 0, + const _Hash& __hf = _Hash(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Hashtable(__l.begin(), __l.end(), __bkt_count_hint, + __hf, __eql, __a, __unique_keys{}) + { } + + _Hashtable& + operator=(const _Hashtable& __ht); + + _Hashtable& + operator=(_Hashtable&& __ht) + noexcept(__node_alloc_traits::_S_nothrow_move() + && is_nothrow_move_assignable<_Hash>::value + && is_nothrow_move_assignable<_Equal>::value) + { + constexpr bool __move_storage = + __node_alloc_traits::_S_propagate_on_move_assign() + || __node_alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__ht), __bool_constant<__move_storage>()); + return *this; + } + + _Hashtable& + operator=(initializer_list __l) + { + __reuse_or_alloc_node_gen_t __roan(_M_begin(), *this); + _M_before_begin._M_nxt = nullptr; + clear(); + + // We consider that all elements of __l are going to be inserted. + auto __l_bkt_count = _M_rehash_policy._M_bkt_for_elements(__l.size()); + + // Do not shrink to keep potential user reservation. + if (_M_bucket_count < __l_bkt_count) + rehash(__l_bkt_count); + + this->_M_insert_range(__l.begin(), __l.end(), __roan, __unique_keys{}); + return *this; + } + + ~_Hashtable() noexcept; + + void + swap(_Hashtable&) + noexcept(__and_<__is_nothrow_swappable<_Hash>, + __is_nothrow_swappable<_Equal>>::value); + + // Basic container operations + iterator + begin() noexcept + { return iterator(_M_begin()); } + + const_iterator + begin() const noexcept + { return const_iterator(_M_begin()); } + + iterator + end() noexcept + { return iterator(nullptr); } + + const_iterator + end() const noexcept + { return const_iterator(nullptr); } + + const_iterator + cbegin() const noexcept + { return const_iterator(_M_begin()); } + + const_iterator + cend() const noexcept + { return const_iterator(nullptr); } + + size_type + size() const noexcept + { return _M_element_count; } + + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return size() == 0; } + + allocator_type + get_allocator() const noexcept + { return allocator_type(this->_M_node_allocator()); } + + size_type + max_size() const noexcept + { return __node_alloc_traits::max_size(this->_M_node_allocator()); } + + // Observers + key_equal + key_eq() const + { return this->_M_eq(); } + + // hash_function, if present, comes from _Hash_code_base. + + // Bucket operations + size_type + bucket_count() const noexcept + { return _M_bucket_count; } + + size_type + max_bucket_count() const noexcept + { return max_size(); } + + size_type + bucket_size(size_type __bkt) const + { return std::distance(begin(__bkt), end(__bkt)); } + + size_type + bucket(const key_type& __k) const + { return _M_bucket_index(this->_M_hash_code(__k)); } + + local_iterator + begin(size_type __bkt) + { + return local_iterator(*this, _M_bucket_begin(__bkt), + __bkt, _M_bucket_count); + } + + local_iterator + end(size_type __bkt) + { return local_iterator(*this, nullptr, __bkt, _M_bucket_count); } + + const_local_iterator + begin(size_type __bkt) const + { + return const_local_iterator(*this, _M_bucket_begin(__bkt), + __bkt, _M_bucket_count); + } + + const_local_iterator + end(size_type __bkt) const + { return const_local_iterator(*this, nullptr, __bkt, _M_bucket_count); } + + // DR 691. + const_local_iterator + cbegin(size_type __bkt) const + { + return const_local_iterator(*this, _M_bucket_begin(__bkt), + __bkt, _M_bucket_count); + } + + const_local_iterator + cend(size_type __bkt) const + { return const_local_iterator(*this, nullptr, __bkt, _M_bucket_count); } + + float + load_factor() const noexcept + { + return static_cast(size()) / static_cast(bucket_count()); + } + + // max_load_factor, if present, comes from _Rehash_base. + + // Generalization of max_load_factor. Extension, not found in + // TR1. Only useful if _RehashPolicy is something other than + // the default. + const _RehashPolicy& + __rehash_policy() const + { return _M_rehash_policy; } + + void + __rehash_policy(const _RehashPolicy& __pol) + { _M_rehash_policy = __pol; } + + // Lookup. + iterator + find(const key_type& __k); + + const_iterator + find(const key_type& __k) const; + + size_type + count(const key_type& __k) const; + + std::pair + equal_range(const key_type& __k); + + std::pair + equal_range(const key_type& __k) const; + +#if __cplusplus >= 202002L +#define __cpp_lib_generic_unordered_lookup 201811L + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + iterator + _M_find_tr(const _Kt& __k); + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + const_iterator + _M_find_tr(const _Kt& __k) const; + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + size_type + _M_count_tr(const _Kt& __k) const; + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + pair + _M_equal_range_tr(const _Kt& __k); + + template, + typename = __has_is_transparent_t<_Equal, _Kt>> + pair + _M_equal_range_tr(const _Kt& __k) const; +#endif // C++20 + + private: + // Bucket index computation helpers. + size_type + _M_bucket_index(const __node_value_type& __n) const noexcept + { return __hash_code_base::_M_bucket_index(__n, _M_bucket_count); } + + size_type + _M_bucket_index(__hash_code __c) const + { return __hash_code_base::_M_bucket_index(__c, _M_bucket_count); } + + // Find and insert helper functions and types + // Find the node before the one matching the criteria. + __node_base_ptr + _M_find_before_node(size_type, const key_type&, __hash_code) const; + + template + __node_base_ptr + _M_find_before_node_tr(size_type, const _Kt&, __hash_code) const; + + __node_ptr + _M_find_node(size_type __bkt, const key_type& __key, + __hash_code __c) const + { + __node_base_ptr __before_n = _M_find_before_node(__bkt, __key, __c); + if (__before_n) + return static_cast<__node_ptr>(__before_n->_M_nxt); + return nullptr; + } + + template + __node_ptr + _M_find_node_tr(size_type __bkt, const _Kt& __key, + __hash_code __c) const + { + auto __before_n = _M_find_before_node_tr(__bkt, __key, __c); + if (__before_n) + return static_cast<__node_ptr>(__before_n->_M_nxt); + return nullptr; + } + + // Insert a node at the beginning of a bucket. + void + _M_insert_bucket_begin(size_type, __node_ptr); + + // Remove the bucket first node + void + _M_remove_bucket_begin(size_type __bkt, __node_ptr __next_n, + size_type __next_bkt); + + // Get the node before __n in the bucket __bkt + __node_base_ptr + _M_get_previous_node(size_type __bkt, __node_ptr __n); + + // Insert node __n with hash code __code, in bucket __bkt if no + // rehash (assumes no element with same key already present). + // Takes ownership of __n if insertion succeeds, throws otherwise. + iterator + _M_insert_unique_node(size_type __bkt, __hash_code, + __node_ptr __n, size_type __n_elt = 1); + + // Insert node __n with key __k and hash code __code. + // Takes ownership of __n if insertion succeeds, throws otherwise. + iterator + _M_insert_multi_node(__node_ptr __hint, + __hash_code __code, __node_ptr __n); + + template + std::pair + _M_emplace(true_type __uks, _Args&&... __args); + + template + iterator + _M_emplace(false_type __uks, _Args&&... __args) + { return _M_emplace(cend(), __uks, std::forward<_Args>(__args)...); } + + // Emplace with hint, useless when keys are unique. + template + iterator + _M_emplace(const_iterator, true_type __uks, _Args&&... __args) + { return _M_emplace(__uks, std::forward<_Args>(__args)...).first; } + + template + iterator + _M_emplace(const_iterator, false_type __uks, _Args&&... __args); + + template + std::pair + _M_insert(_Arg&&, const _NodeGenerator&, true_type __uks); + + template + iterator + _M_insert(_Arg&& __arg, const _NodeGenerator& __node_gen, + false_type __uks) + { + return _M_insert(cend(), std::forward<_Arg>(__arg), __node_gen, + __uks); + } + + // Insert with hint, not used when keys are unique. + template + iterator + _M_insert(const_iterator, _Arg&& __arg, + const _NodeGenerator& __node_gen, true_type __uks) + { + return + _M_insert(std::forward<_Arg>(__arg), __node_gen, __uks).first; + } + + // Insert with hint when keys are not unique. + template + iterator + _M_insert(const_iterator, _Arg&&, + const _NodeGenerator&, false_type __uks); + + size_type + _M_erase(true_type __uks, const key_type&); + + size_type + _M_erase(false_type __uks, const key_type&); + + iterator + _M_erase(size_type __bkt, __node_base_ptr __prev_n, __node_ptr __n); + + public: + // Emplace + template + __ireturn_type + emplace(_Args&&... __args) + { return _M_emplace(__unique_keys{}, std::forward<_Args>(__args)...); } + + template + iterator + emplace_hint(const_iterator __hint, _Args&&... __args) + { + return _M_emplace(__hint, __unique_keys{}, + std::forward<_Args>(__args)...); + } + + // Insert member functions via inheritance. + + // Erase + iterator + erase(const_iterator); + + // LWG 2059. + iterator + erase(iterator __it) + { return erase(const_iterator(__it)); } + + size_type + erase(const key_type& __k) + { return _M_erase(__unique_keys{}, __k); } + + iterator + erase(const_iterator, const_iterator); + + void + clear() noexcept; + + // Set number of buckets keeping it appropriate for container's number + // of elements. + void rehash(size_type __bkt_count); + + // DR 1189. + // reserve, if present, comes from _Rehash_base. + +#if __cplusplus > 201402L + /// Re-insert an extracted node into a container with unique keys. + insert_return_type + _M_reinsert_node(node_type&& __nh) + { + insert_return_type __ret; + if (__nh.empty()) + __ret.position = end(); + else + { + __glibcxx_assert(get_allocator() == __nh.get_allocator()); + + const key_type& __k = __nh._M_key(); + __hash_code __code = this->_M_hash_code(__k); + size_type __bkt = _M_bucket_index(__code); + if (__node_ptr __n = _M_find_node(__bkt, __k, __code)) + { + __ret.node = std::move(__nh); + __ret.position = iterator(__n); + __ret.inserted = false; + } + else + { + __ret.position + = _M_insert_unique_node(__bkt, __code, __nh._M_ptr); + __nh._M_ptr = nullptr; + __ret.inserted = true; + } + } + return __ret; + } + + /// Re-insert an extracted node into a container with equivalent keys. + iterator + _M_reinsert_node_multi(const_iterator __hint, node_type&& __nh) + { + if (__nh.empty()) + return end(); + + __glibcxx_assert(get_allocator() == __nh.get_allocator()); + + const key_type& __k = __nh._M_key(); + auto __code = this->_M_hash_code(__k); + auto __ret + = _M_insert_multi_node(__hint._M_cur, __code, __nh._M_ptr); + __nh._M_ptr = nullptr; + return __ret; + } + + private: + node_type + _M_extract_node(size_t __bkt, __node_base_ptr __prev_n) + { + __node_ptr __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + if (__prev_n == _M_buckets[__bkt]) + _M_remove_bucket_begin(__bkt, __n->_M_next(), + __n->_M_nxt ? _M_bucket_index(*__n->_M_next()) : 0); + else if (__n->_M_nxt) + { + size_type __next_bkt = _M_bucket_index(*__n->_M_next()); + if (__next_bkt != __bkt) + _M_buckets[__next_bkt] = __prev_n; + } + + __prev_n->_M_nxt = __n->_M_nxt; + __n->_M_nxt = nullptr; + --_M_element_count; + return { __n, this->_M_node_allocator() }; + } + + public: + // Extract a node. + node_type + extract(const_iterator __pos) + { + size_t __bkt = _M_bucket_index(*__pos._M_cur); + return _M_extract_node(__bkt, + _M_get_previous_node(__bkt, __pos._M_cur)); + } + + /// Extract a node. + node_type + extract(const _Key& __k) + { + node_type __nh; + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + if (__node_base_ptr __prev_node = _M_find_before_node(__bkt, __k, __code)) + __nh = _M_extract_node(__bkt, __prev_node); + return __nh; + } + + /// Merge from a compatible container into one with unique keys. + template + void + _M_merge_unique(_Compatible_Hashtable& __src) noexcept + { + static_assert(is_same_v, "Node types are compatible"); + __glibcxx_assert(get_allocator() == __src.get_allocator()); + + auto __n_elt = __src.size(); + for (auto __i = __src.begin(), __end = __src.end(); __i != __end;) + { + auto __pos = __i++; + const key_type& __k = _ExtractKey{}(*__pos); + __hash_code __code = this->_M_hash_code(__k); + size_type __bkt = _M_bucket_index(__code); + if (_M_find_node(__bkt, __k, __code) == nullptr) + { + auto __nh = __src.extract(__pos); + _M_insert_unique_node(__bkt, __code, __nh._M_ptr, __n_elt); + __nh._M_ptr = nullptr; + __n_elt = 1; + } + else if (__n_elt != 1) + --__n_elt; + } + } + + /// Merge from a compatible container into one with equivalent keys. + template + void + _M_merge_multi(_Compatible_Hashtable& __src) noexcept + { + static_assert(is_same_v, "Node types are compatible"); + __glibcxx_assert(get_allocator() == __src.get_allocator()); + + this->reserve(size() + __src.size()); + for (auto __i = __src.begin(), __end = __src.end(); __i != __end;) + _M_reinsert_node_multi(cend(), __src.extract(__i++)); + } +#endif // C++17 + + private: + // Helper rehash method used when keys are unique. + void _M_rehash_aux(size_type __bkt_count, true_type __uks); + + // Helper rehash method used when keys can be non-unique. + void _M_rehash_aux(size_type __bkt_count, false_type __uks); + + // Unconditionally change size of bucket array to n, restore + // hash policy state to __state on exception. + void _M_rehash(size_type __bkt_count, const __rehash_state& __state); + }; + + + // Definitions of class template _Hashtable's out-of-line member functions. + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_bucket_begin(size_type __bkt) const + -> __node_ptr + { + __node_base_ptr __n = _M_buckets[__bkt]; + return __n ? static_cast<__node_ptr>(__n->_M_nxt) : nullptr; + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(size_type __bkt_count_hint, + const _Hash& __h, const _Equal& __eq, const allocator_type& __a) + : _Hashtable(__h, __eq, __a) + { + auto __bkt_count = _M_rehash_policy._M_next_bkt(__bkt_count_hint); + if (__bkt_count > _M_bucket_count) + { + _M_buckets = _M_allocate_buckets(__bkt_count); + _M_bucket_count = __bkt_count; + } + } + + template + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bkt_count_hint, + const _Hash& __h, const _Equal& __eq, + const allocator_type& __a, true_type /* __uks */) + : _Hashtable(__bkt_count_hint, __h, __eq, __a) + { + for (; __f != __l; ++__f) + this->insert(*__f); + } + + template + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_InputIterator __f, _InputIterator __l, + size_type __bkt_count_hint, + const _Hash& __h, const _Equal& __eq, + const allocator_type& __a, false_type /* __uks */) + : _Hashtable(__h, __eq, __a) + { + auto __nb_elems = __detail::__distance_fw(__f, __l); + auto __bkt_count = + _M_rehash_policy._M_next_bkt( + std::max(_M_rehash_policy._M_bkt_for_elements(__nb_elems), + __bkt_count_hint)); + + if (__bkt_count > _M_bucket_count) + { + _M_buckets = _M_allocate_buckets(__bkt_count); + _M_bucket_count = __bkt_count; + } + + for (; __f != __l; ++__f) + this->insert(*__f); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + operator=(const _Hashtable& __ht) + -> _Hashtable& + { + if (&__ht == this) + return *this; + + if (__node_alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_node_allocator(); + auto& __that_alloc = __ht._M_node_allocator(); + if (!__node_alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // Replacement allocator cannot free existing storage. + this->_M_deallocate_nodes(_M_begin()); + _M_before_begin._M_nxt = nullptr; + _M_deallocate_buckets(); + _M_buckets = nullptr; + std::__alloc_on_copy(__this_alloc, __that_alloc); + __hashtable_base::operator=(__ht); + _M_bucket_count = __ht._M_bucket_count; + _M_element_count = __ht._M_element_count; + _M_rehash_policy = __ht._M_rehash_policy; + __alloc_node_gen_t __alloc_node_gen(*this); + __try + { + _M_assign(__ht, __alloc_node_gen); + } + __catch(...) + { + // _M_assign took care of deallocating all memory. Now we + // must make sure this instance remains in a usable state. + _M_reset(); + __throw_exception_again; + } + return *this; + } + std::__alloc_on_copy(__this_alloc, __that_alloc); + } + + // Reuse allocated buckets and nodes. + _M_assign_elements(__ht); + return *this; + } + + template + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_assign_elements(_Ht&& __ht) + { + __buckets_ptr __former_buckets = nullptr; + std::size_t __former_bucket_count = _M_bucket_count; + const __rehash_state& __former_state = _M_rehash_policy._M_state(); + + if (_M_bucket_count != __ht._M_bucket_count) + { + __former_buckets = _M_buckets; + _M_buckets = _M_allocate_buckets(__ht._M_bucket_count); + _M_bucket_count = __ht._M_bucket_count; + } + else + __builtin_memset(_M_buckets, 0, + _M_bucket_count * sizeof(__node_base_ptr)); + + __try + { + __hashtable_base::operator=(std::forward<_Ht>(__ht)); + _M_element_count = __ht._M_element_count; + _M_rehash_policy = __ht._M_rehash_policy; + __reuse_or_alloc_node_gen_t __roan(_M_begin(), *this); + _M_before_begin._M_nxt = nullptr; + _M_assign(std::forward<_Ht>(__ht), __roan); + if (__former_buckets) + _M_deallocate_buckets(__former_buckets, __former_bucket_count); + } + __catch(...) + { + if (__former_buckets) + { + // Restore previous buckets. + _M_deallocate_buckets(); + _M_rehash_policy._M_reset(__former_state); + _M_buckets = __former_buckets; + _M_bucket_count = __former_bucket_count; + } + __builtin_memset(_M_buckets, 0, + _M_bucket_count * sizeof(__node_base_ptr)); + __throw_exception_again; + } + } + + template + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_assign(_Ht&& __ht, const _NodeGenerator& __node_gen) + { + __buckets_ptr __buckets = nullptr; + if (!_M_buckets) + _M_buckets = __buckets = _M_allocate_buckets(_M_bucket_count); + + __try + { + if (!__ht._M_before_begin._M_nxt) + return; + + // First deal with the special first node pointed to by + // _M_before_begin. + __node_ptr __ht_n = __ht._M_begin(); + __node_ptr __this_n + = __node_gen(__fwd_value_for<_Ht>(__ht_n->_M_v())); + this->_M_copy_code(*__this_n, *__ht_n); + _M_update_bbegin(__this_n); + + // Then deal with other nodes. + __node_ptr __prev_n = __this_n; + for (__ht_n = __ht_n->_M_next(); __ht_n; __ht_n = __ht_n->_M_next()) + { + __this_n = __node_gen(__fwd_value_for<_Ht>(__ht_n->_M_v())); + __prev_n->_M_nxt = __this_n; + this->_M_copy_code(*__this_n, *__ht_n); + size_type __bkt = _M_bucket_index(*__this_n); + if (!_M_buckets[__bkt]) + _M_buckets[__bkt] = __prev_n; + __prev_n = __this_n; + } + } + __catch(...) + { + clear(); + if (__buckets) + _M_deallocate_buckets(); + __throw_exception_again; + } + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_reset() noexcept + { + _M_rehash_policy._M_reset(); + _M_bucket_count = 1; + _M_single_bucket = nullptr; + _M_buckets = &_M_single_bucket; + _M_before_begin._M_nxt = nullptr; + _M_element_count = 0; + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_move_assign(_Hashtable&& __ht, true_type) + { + if (__builtin_expect(std::__addressof(__ht) == this, false)) + return; + + this->_M_deallocate_nodes(_M_begin()); + _M_deallocate_buckets(); + __hashtable_base::operator=(std::move(__ht)); + _M_rehash_policy = __ht._M_rehash_policy; + if (!__ht._M_uses_single_bucket()) + _M_buckets = __ht._M_buckets; + else + { + _M_buckets = &_M_single_bucket; + _M_single_bucket = __ht._M_single_bucket; + } + + _M_bucket_count = __ht._M_bucket_count; + _M_before_begin._M_nxt = __ht._M_before_begin._M_nxt; + _M_element_count = __ht._M_element_count; + std::__alloc_on_move(this->_M_node_allocator(), __ht._M_node_allocator()); + + // Fix bucket containing the _M_before_begin pointer that can't be moved. + _M_update_bbegin(); + __ht._M_reset(); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_move_assign(_Hashtable&& __ht, false_type) + { + if (__ht._M_node_allocator() == this->_M_node_allocator()) + _M_move_assign(std::move(__ht), true_type{}); + else + { + // Can't move memory, move elements then. + _M_assign_elements(std::move(__ht)); + __ht.clear(); + } + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(const _Hashtable& __ht) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc( + __node_alloc_traits::_S_select_on_copy(__ht._M_node_allocator())), + __enable_default_ctor(__ht), + _M_buckets(nullptr), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + __alloc_node_gen_t __alloc_node_gen(*this); + _M_assign(__ht, __alloc_node_gen); + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, + true_type /* alloc always equal */) + noexcept(_S_nothrow_move()) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc(std::move(__a)), + __enable_default_ctor(__ht), + _M_buckets(__ht._M_buckets), + _M_bucket_count(__ht._M_bucket_count), + _M_before_begin(__ht._M_before_begin._M_nxt), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + // Update buckets if __ht is using its single bucket. + if (__ht._M_uses_single_bucket()) + { + _M_buckets = &_M_single_bucket; + _M_single_bucket = __ht._M_single_bucket; + } + + // Fix bucket containing the _M_before_begin pointer that can't be moved. + _M_update_bbegin(); + + __ht._M_reset(); + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(const _Hashtable& __ht, const allocator_type& __a) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc(__node_alloc_type(__a)), + __enable_default_ctor(__ht), + _M_buckets(), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + __alloc_node_gen_t __alloc_node_gen(*this); + _M_assign(__ht, __alloc_node_gen); + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, + false_type /* alloc always equal */) + : __hashtable_base(__ht), + __map_base(__ht), + __rehash_base(__ht), + __hashtable_alloc(std::move(__a)), + __enable_default_ctor(__ht), + _M_buckets(nullptr), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy) + { + if (__ht._M_node_allocator() == this->_M_node_allocator()) + { + if (__ht._M_uses_single_bucket()) + { + _M_buckets = &_M_single_bucket; + _M_single_bucket = __ht._M_single_bucket; + } + else + _M_buckets = __ht._M_buckets; + + // Fix bucket containing the _M_before_begin pointer that can't be + // moved. + _M_update_bbegin(__ht._M_begin()); + + __ht._M_reset(); + } + else + { + __alloc_node_gen_t __alloc_gen(*this); + + using _Fwd_Ht = typename + conditional<__move_if_noexcept_cond::value, + const _Hashtable&, _Hashtable&&>::type; + _M_assign(std::forward<_Fwd_Ht>(__ht), __alloc_gen); + __ht.clear(); + } + } + + template + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + ~_Hashtable() noexcept + { + clear(); + _M_deallocate_buckets(); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + swap(_Hashtable& __x) + noexcept(__and_<__is_nothrow_swappable<_Hash>, + __is_nothrow_swappable<_Equal>>::value) + { + // The only base class with member variables is hash_code_base. + // We define _Hash_code_base::_M_swap because different + // specializations have different members. + this->_M_swap(__x); + + std::__alloc_on_swap(this->_M_node_allocator(), __x._M_node_allocator()); + std::swap(_M_rehash_policy, __x._M_rehash_policy); + + // Deal properly with potentially moved instances. + if (this->_M_uses_single_bucket()) + { + if (!__x._M_uses_single_bucket()) + { + _M_buckets = __x._M_buckets; + __x._M_buckets = &__x._M_single_bucket; + } + } + else if (__x._M_uses_single_bucket()) + { + __x._M_buckets = _M_buckets; + _M_buckets = &_M_single_bucket; + } + else + std::swap(_M_buckets, __x._M_buckets); + + std::swap(_M_bucket_count, __x._M_bucket_count); + std::swap(_M_before_begin._M_nxt, __x._M_before_begin._M_nxt); + std::swap(_M_element_count, __x._M_element_count); + std::swap(_M_single_bucket, __x._M_single_bucket); + + // Fix buckets containing the _M_before_begin pointers that can't be + // swapped. + _M_update_bbegin(); + __x._M_update_bbegin(); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + find(const key_type& __k) + -> iterator + { + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + return iterator(_M_find_node(__bkt, __k, __code)); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + find(const key_type& __k) const + -> const_iterator + { + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + return const_iterator(_M_find_node(__bkt, __k, __code)); + } + +#if __cplusplus > 201703L + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_tr(const _Kt& __k) + -> iterator + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + return iterator(_M_find_node_tr(__bkt, __k, __code)); + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_tr(const _Kt& __k) const + -> const_iterator + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + return const_iterator(_M_find_node_tr(__bkt, __k, __code)); + } +#endif + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + count(const key_type& __k) const + -> size_type + { + auto __it = find(__k); + if (!__it._M_cur) + return 0; + + if (__unique_keys::value) + return 1; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + size_type __result = 1; + for (auto __ref = __it++; + __it._M_cur && this->_M_node_equals(*__ref._M_cur, *__it._M_cur); + ++__it) + ++__result; + + return __result; + } + +#if __cplusplus > 201703L + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_count_tr(const _Kt& __k) const + -> size_type + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + auto __n = _M_find_node_tr(__bkt, __k, __code); + if (!__n) + return 0; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + iterator __it(__n); + size_type __result = 1; + for (++__it; + __it._M_cur && this->_M_equals_tr(__k, __code, *__it._M_cur); + ++__it) + ++__result; + + return __result; + } +#endif + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + equal_range(const key_type& __k) + -> pair + { + auto __ite = find(__k); + if (!__ite._M_cur) + return { __ite, __ite }; + + auto __beg = __ite++; + if (__unique_keys::value) + return { __beg, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + while (__ite._M_cur && this->_M_node_equals(*__beg._M_cur, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + equal_range(const key_type& __k) const + -> pair + { + auto __ite = find(__k); + if (!__ite._M_cur) + return { __ite, __ite }; + + auto __beg = __ite++; + if (__unique_keys::value) + return { __beg, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + while (__ite._M_cur && this->_M_node_equals(*__beg._M_cur, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } + +#if __cplusplus > 201703L + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_equal_range_tr(const _Kt& __k) + -> pair + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + auto __n = _M_find_node_tr(__bkt, __k, __code); + iterator __ite(__n); + if (!__n) + return { __ite, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + auto __beg = __ite++; + while (__ite._M_cur && this->_M_equals_tr(__k, __code, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_equal_range_tr(const _Kt& __k) const + -> pair + { + __hash_code __code = this->_M_hash_code_tr(__k); + std::size_t __bkt = _M_bucket_index(__code); + auto __n = _M_find_node_tr(__bkt, __k, __code); + const_iterator __ite(__n); + if (!__n) + return { __ite, __ite }; + + // All equivalent values are next to each other, if we find a + // non-equivalent value after an equivalent one it means that we won't + // find any new equivalent value. + auto __beg = __ite++; + while (__ite._M_cur && this->_M_equals_tr(__k, __code, *__ite._M_cur)) + ++__ite; + + return { __beg, __ite }; + } +#endif + + // Find the node before the one whose key compares equal to k in the bucket + // bkt. Return nullptr if no node is found. + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_before_node(size_type __bkt, const key_type& __k, + __hash_code __code) const + -> __node_base_ptr + { + __node_base_ptr __prev_p = _M_buckets[__bkt]; + if (!__prev_p) + return nullptr; + + for (__node_ptr __p = static_cast<__node_ptr>(__prev_p->_M_nxt);; + __p = __p->_M_next()) + { + if (this->_M_equals(__k, __code, *__p)) + return __prev_p; + + if (!__p->_M_nxt || _M_bucket_index(*__p->_M_next()) != __bkt) + break; + __prev_p = __p; + } + + return nullptr; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_find_before_node_tr(size_type __bkt, const _Kt& __k, + __hash_code __code) const + -> __node_base_ptr + { + __node_base_ptr __prev_p = _M_buckets[__bkt]; + if (!__prev_p) + return nullptr; + + for (__node_ptr __p = static_cast<__node_ptr>(__prev_p->_M_nxt);; + __p = __p->_M_next()) + { + if (this->_M_equals_tr(__k, __code, *__p)) + return __prev_p; + + if (!__p->_M_nxt || _M_bucket_index(*__p->_M_next()) != __bkt) + break; + __prev_p = __p; + } + + return nullptr; + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_bucket_begin(size_type __bkt, __node_ptr __node) + { + if (_M_buckets[__bkt]) + { + // Bucket is not empty, we just need to insert the new node + // after the bucket before begin. + __node->_M_nxt = _M_buckets[__bkt]->_M_nxt; + _M_buckets[__bkt]->_M_nxt = __node; + } + else + { + // The bucket is empty, the new node is inserted at the + // beginning of the singly-linked list and the bucket will + // contain _M_before_begin pointer. + __node->_M_nxt = _M_before_begin._M_nxt; + _M_before_begin._M_nxt = __node; + + if (__node->_M_nxt) + // We must update former begin bucket that is pointing to + // _M_before_begin. + _M_buckets[_M_bucket_index(*__node->_M_next())] = __node; + + _M_buckets[__bkt] = &_M_before_begin; + } + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_remove_bucket_begin(size_type __bkt, __node_ptr __next, + size_type __next_bkt) + { + if (!__next || __next_bkt != __bkt) + { + // Bucket is now empty + // First update next bucket if any + if (__next) + _M_buckets[__next_bkt] = _M_buckets[__bkt]; + + // Second update before begin node if necessary + if (&_M_before_begin == _M_buckets[__bkt]) + _M_before_begin._M_nxt = __next; + _M_buckets[__bkt] = nullptr; + } + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_get_previous_node(size_type __bkt, __node_ptr __n) + -> __node_base_ptr + { + __node_base_ptr __prev_n = _M_buckets[__bkt]; + while (__prev_n->_M_nxt != __n) + __prev_n = __prev_n->_M_nxt; + return __prev_n; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_emplace(true_type /* __uks */, _Args&&... __args) + -> pair + { + // First build the node to get access to the hash code + _Scoped_node __node { this, std::forward<_Args>(__args)... }; + const key_type& __k = _ExtractKey{}(__node._M_node->_M_v()); + __hash_code __code = this->_M_hash_code(__k); + size_type __bkt = _M_bucket_index(__code); + if (__node_ptr __p = _M_find_node(__bkt, __k, __code)) + // There is already an equivalent node, no insertion + return std::make_pair(iterator(__p), false); + + // Insert the node + auto __pos = _M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return { __pos, true }; + } + + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_emplace(const_iterator __hint, false_type /* __uks */, + _Args&&... __args) + -> iterator + { + // First build the node to get its hash code. + _Scoped_node __node { this, std::forward<_Args>(__args)... }; + const key_type& __k = _ExtractKey{}(__node._M_node->_M_v()); + + __hash_code __code = this->_M_hash_code(__k); + auto __pos + = _M_insert_multi_node(__hint._M_cur, __code, __node._M_node); + __node._M_node = nullptr; + return __pos; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_unique_node(size_type __bkt, __hash_code __code, + __node_ptr __node, size_type __n_elt) + -> iterator + { + const __rehash_state& __saved_state = _M_rehash_policy._M_state(); + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count, + __n_elt); + + if (__do_rehash.first) + { + _M_rehash(__do_rehash.second, __saved_state); + __bkt = _M_bucket_index(__code); + } + + this->_M_store_code(*__node, __code); + + // Always insert at the beginning of the bucket. + _M_insert_bucket_begin(__bkt, __node); + ++_M_element_count; + return iterator(__node); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert_multi_node(__node_ptr __hint, + __hash_code __code, __node_ptr __node) + -> iterator + { + const __rehash_state& __saved_state = _M_rehash_policy._M_state(); + std::pair __do_rehash + = _M_rehash_policy._M_need_rehash(_M_bucket_count, _M_element_count, 1); + + if (__do_rehash.first) + _M_rehash(__do_rehash.second, __saved_state); + + this->_M_store_code(*__node, __code); + const key_type& __k = _ExtractKey{}(__node->_M_v()); + size_type __bkt = _M_bucket_index(__code); + + // Find the node before an equivalent one or use hint if it exists and + // if it is equivalent. + __node_base_ptr __prev + = __builtin_expect(__hint != nullptr, false) + && this->_M_equals(__k, __code, *__hint) + ? __hint + : _M_find_before_node(__bkt, __k, __code); + + if (__prev) + { + // Insert after the node before the equivalent one. + __node->_M_nxt = __prev->_M_nxt; + __prev->_M_nxt = __node; + if (__builtin_expect(__prev == __hint, false)) + // hint might be the last bucket node, in this case we need to + // update next bucket. + if (__node->_M_nxt + && !this->_M_equals(__k, __code, *__node->_M_next())) + { + size_type __next_bkt = _M_bucket_index(*__node->_M_next()); + if (__next_bkt != __bkt) + _M_buckets[__next_bkt] = __node; + } + } + else + // The inserted node has no equivalent in the hashtable. We must + // insert the new node at the beginning of the bucket to preserve + // equivalent elements' relative positions. + _M_insert_bucket_begin(__bkt, __node); + ++_M_element_count; + return iterator(__node); + } + + // Insert v if no element with its key is already present. + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert(_Arg&& __v, const _NodeGenerator& __node_gen, + true_type /* __uks */) + -> pair + { + const key_type& __k = _ExtractKey{}(__v); + __hash_code __code = this->_M_hash_code(__k); + size_type __bkt = _M_bucket_index(__code); + + if (__node_ptr __node = _M_find_node(__bkt, __k, __code)) + return { iterator(__node), false }; + + _Scoped_node __node{ __node_gen(std::forward<_Arg>(__v)), this }; + auto __pos + = _M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return { __pos, true }; + } + + // Insert v unconditionally. + template + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_insert(const_iterator __hint, _Arg&& __v, + const _NodeGenerator& __node_gen, + false_type /* __uks */) + -> iterator + { + // First compute the hash code so that we don't do anything if it + // throws. + __hash_code __code = this->_M_hash_code(_ExtractKey{}(__v)); + + // Second allocate new node so that we don't rehash if it throws. + _Scoped_node __node{ __node_gen(std::forward<_Arg>(__v)), this }; + auto __pos + = _M_insert_multi_node(__hint._M_cur, __code, __node._M_node); + __node._M_node = nullptr; + return __pos; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + erase(const_iterator __it) + -> iterator + { + __node_ptr __n = __it._M_cur; + std::size_t __bkt = _M_bucket_index(*__n); + + // Look for previous node to unlink it from the erased one, this + // is why we need buckets to contain the before begin to make + // this search fast. + __node_base_ptr __prev_n = _M_get_previous_node(__bkt, __n); + return _M_erase(__bkt, __prev_n, __n); + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_erase(size_type __bkt, __node_base_ptr __prev_n, __node_ptr __n) + -> iterator + { + if (__prev_n == _M_buckets[__bkt]) + _M_remove_bucket_begin(__bkt, __n->_M_next(), + __n->_M_nxt ? _M_bucket_index(*__n->_M_next()) : 0); + else if (__n->_M_nxt) + { + size_type __next_bkt = _M_bucket_index(*__n->_M_next()); + if (__next_bkt != __bkt) + _M_buckets[__next_bkt] = __prev_n; + } + + __prev_n->_M_nxt = __n->_M_nxt; + iterator __result(__n->_M_next()); + this->_M_deallocate_node(__n); + --_M_element_count; + + return __result; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_erase(true_type /* __uks */, const key_type& __k) + -> size_type + { + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + + // Look for the node before the first matching node. + __node_base_ptr __prev_n = _M_find_before_node(__bkt, __k, __code); + if (!__prev_n) + return 0; + + // We found a matching node, erase it. + __node_ptr __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + _M_erase(__bkt, __prev_n, __n); + return 1; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_erase(false_type /* __uks */, const key_type& __k) + -> size_type + { + __hash_code __code = this->_M_hash_code(__k); + std::size_t __bkt = _M_bucket_index(__code); + + // Look for the node before the first matching node. + __node_base_ptr __prev_n = _M_find_before_node(__bkt, __k, __code); + if (!__prev_n) + return 0; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 526. Is it undefined if a function in the standard changes + // in parameters? + // We use one loop to find all matching nodes and another to deallocate + // them so that the key stays valid during the first loop. It might be + // invalidated indirectly when destroying nodes. + __node_ptr __n = static_cast<__node_ptr>(__prev_n->_M_nxt); + __node_ptr __n_last = __n->_M_next(); + while (__n_last && this->_M_node_equals(*__n, *__n_last)) + __n_last = __n_last->_M_next(); + + std::size_t __n_last_bkt = __n_last ? _M_bucket_index(*__n_last) : __bkt; + + // Deallocate nodes. + size_type __result = 0; + do + { + __node_ptr __p = __n->_M_next(); + this->_M_deallocate_node(__n); + __n = __p; + ++__result; + } + while (__n != __n_last); + + _M_element_count -= __result; + if (__prev_n == _M_buckets[__bkt]) + _M_remove_bucket_begin(__bkt, __n_last, __n_last_bkt); + else if (__n_last_bkt != __bkt) + _M_buckets[__n_last_bkt] = __prev_n; + __prev_n->_M_nxt = __n_last; + return __result; + } + + template + auto + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + erase(const_iterator __first, const_iterator __last) + -> iterator + { + __node_ptr __n = __first._M_cur; + __node_ptr __last_n = __last._M_cur; + if (__n == __last_n) + return iterator(__n); + + std::size_t __bkt = _M_bucket_index(*__n); + + __node_base_ptr __prev_n = _M_get_previous_node(__bkt, __n); + bool __is_bucket_begin = __n == _M_bucket_begin(__bkt); + std::size_t __n_bkt = __bkt; + for (;;) + { + do + { + __node_ptr __tmp = __n; + __n = __n->_M_next(); + this->_M_deallocate_node(__tmp); + --_M_element_count; + if (!__n) + break; + __n_bkt = _M_bucket_index(*__n); + } + while (__n != __last_n && __n_bkt == __bkt); + if (__is_bucket_begin) + _M_remove_bucket_begin(__bkt, __n, __n_bkt); + if (__n == __last_n) + break; + __is_bucket_begin = true; + __bkt = __n_bkt; + } + + if (__n && (__n_bkt != __bkt || __is_bucket_begin)) + _M_buckets[__n_bkt] = __prev_n; + __prev_n->_M_nxt = __n; + return iterator(__n); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + clear() noexcept + { + this->_M_deallocate_nodes(_M_begin()); + __builtin_memset(_M_buckets, 0, + _M_bucket_count * sizeof(__node_base_ptr)); + _M_element_count = 0; + _M_before_begin._M_nxt = nullptr; + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + rehash(size_type __bkt_count) + { + const __rehash_state& __saved_state = _M_rehash_policy._M_state(); + __bkt_count + = std::max(_M_rehash_policy._M_bkt_for_elements(_M_element_count + 1), + __bkt_count); + __bkt_count = _M_rehash_policy._M_next_bkt(__bkt_count); + + if (__bkt_count != _M_bucket_count) + _M_rehash(__bkt_count, __saved_state); + else + // No rehash, restore previous state to keep it consistent with + // container state. + _M_rehash_policy._M_reset(__saved_state); + } + + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_rehash(size_type __bkt_count, const __rehash_state& __state) + { + __try + { + _M_rehash_aux(__bkt_count, __unique_keys{}); + } + __catch(...) + { + // A failure here means that buckets allocation failed. We only + // have to restore hash policy previous state. + _M_rehash_policy._M_reset(__state); + __throw_exception_again; + } + } + + // Rehash when there is no equivalent elements. + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_rehash_aux(size_type __bkt_count, true_type /* __uks */) + { + __buckets_ptr __new_buckets = _M_allocate_buckets(__bkt_count); + __node_ptr __p = _M_begin(); + _M_before_begin._M_nxt = nullptr; + std::size_t __bbegin_bkt = 0; + while (__p) + { + __node_ptr __next = __p->_M_next(); + std::size_t __bkt + = __hash_code_base::_M_bucket_index(*__p, __bkt_count); + if (!__new_buckets[__bkt]) + { + __p->_M_nxt = _M_before_begin._M_nxt; + _M_before_begin._M_nxt = __p; + __new_buckets[__bkt] = &_M_before_begin; + if (__p->_M_nxt) + __new_buckets[__bbegin_bkt] = __p; + __bbegin_bkt = __bkt; + } + else + { + __p->_M_nxt = __new_buckets[__bkt]->_M_nxt; + __new_buckets[__bkt]->_M_nxt = __p; + } + + __p = __next; + } + + _M_deallocate_buckets(); + _M_bucket_count = __bkt_count; + _M_buckets = __new_buckets; + } + + // Rehash when there can be equivalent elements, preserve their relative + // order. + template + void + _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>:: + _M_rehash_aux(size_type __bkt_count, false_type /* __uks */) + { + __buckets_ptr __new_buckets = _M_allocate_buckets(__bkt_count); + __node_ptr __p = _M_begin(); + _M_before_begin._M_nxt = nullptr; + std::size_t __bbegin_bkt = 0; + std::size_t __prev_bkt = 0; + __node_ptr __prev_p = nullptr; + bool __check_bucket = false; + + while (__p) + { + __node_ptr __next = __p->_M_next(); + std::size_t __bkt + = __hash_code_base::_M_bucket_index(*__p, __bkt_count); + + if (__prev_p && __prev_bkt == __bkt) + { + // Previous insert was already in this bucket, we insert after + // the previously inserted one to preserve equivalent elements + // relative order. + __p->_M_nxt = __prev_p->_M_nxt; + __prev_p->_M_nxt = __p; + + // Inserting after a node in a bucket require to check that we + // haven't change the bucket last node, in this case next + // bucket containing its before begin node must be updated. We + // schedule a check as soon as we move out of the sequence of + // equivalent nodes to limit the number of checks. + __check_bucket = true; + } + else + { + if (__check_bucket) + { + // Check if we shall update the next bucket because of + // insertions into __prev_bkt bucket. + if (__prev_p->_M_nxt) + { + std::size_t __next_bkt + = __hash_code_base::_M_bucket_index( + *__prev_p->_M_next(), __bkt_count); + if (__next_bkt != __prev_bkt) + __new_buckets[__next_bkt] = __prev_p; + } + __check_bucket = false; + } + + if (!__new_buckets[__bkt]) + { + __p->_M_nxt = _M_before_begin._M_nxt; + _M_before_begin._M_nxt = __p; + __new_buckets[__bkt] = &_M_before_begin; + if (__p->_M_nxt) + __new_buckets[__bbegin_bkt] = __p; + __bbegin_bkt = __bkt; + } + else + { + __p->_M_nxt = __new_buckets[__bkt]->_M_nxt; + __new_buckets[__bkt]->_M_nxt = __p; + } + } + __prev_p = __p; + __prev_bkt = __bkt; + __p = __next; + } + + if (__check_bucket && __prev_p->_M_nxt) + { + std::size_t __next_bkt + = __hash_code_base::_M_bucket_index(*__prev_p->_M_next(), + __bkt_count); + if (__next_bkt != __prev_bkt) + __new_buckets[__next_bkt] = __prev_p; + } + + _M_deallocate_buckets(); + _M_bucket_count = __bkt_count; + _M_buckets = __new_buckets; + } + +#if __cplusplus > 201402L + template class _Hash_merge_helper { }; +#endif // C++17 + +#if __cpp_deduction_guides >= 201606 + // Used to constrain deduction guides + template + using _RequireNotAllocatorOrIntegral + = __enable_if_t, __is_allocator<_Hash>>::value>; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _HASHTABLE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hashtable_policy.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hashtable_policy.h new file mode 100755 index 0000000..9d7b7ad --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/hashtable_policy.h @@ -0,0 +1,1949 @@ +// Internal policy header for unordered_set and unordered_map -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/hashtable_policy.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + * @headername{unordered_map,unordered_set} + */ + +#ifndef _HASHTABLE_POLICY_H +#define _HASHTABLE_POLICY_H 1 + +#include // for std::tuple, std::forward_as_tuple +#include // for std::min, std::is_permutation. +#include // for __gnu_cxx::__int_traits + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + class _Hashtable; + +namespace __detail +{ + /** + * @defgroup hashtable-detail Base and Implementation Classes + * @ingroup unordered_associative_containers + * @{ + */ + template + struct _Hashtable_base; + + // Helper function: return distance(first, last) for forward + // iterators, or 0/1 for input iterators. + template + inline typename std::iterator_traits<_Iterator>::difference_type + __distance_fw(_Iterator __first, _Iterator __last, + std::input_iterator_tag) + { return __first != __last ? 1 : 0; } + + template + inline typename std::iterator_traits<_Iterator>::difference_type + __distance_fw(_Iterator __first, _Iterator __last, + std::forward_iterator_tag) + { return std::distance(__first, __last); } + + template + inline typename std::iterator_traits<_Iterator>::difference_type + __distance_fw(_Iterator __first, _Iterator __last) + { return __distance_fw(__first, __last, + std::__iterator_category(__first)); } + + struct _Identity + { + template + _Tp&& + operator()(_Tp&& __x) const noexcept + { return std::forward<_Tp>(__x); } + }; + + struct _Select1st + { + template + auto + operator()(_Tp&& __x) const noexcept + -> decltype(std::get<0>(std::forward<_Tp>(__x))) + { return std::get<0>(std::forward<_Tp>(__x)); } + }; + + template + struct _Hashtable_alloc; + + // Functor recycling a pool of nodes and using allocation once the pool is + // empty. + template + struct _ReuseOrAllocNode + { + private: + using __node_alloc_type = _NodeAlloc; + using __hashtable_alloc = _Hashtable_alloc<__node_alloc_type>; + using __node_alloc_traits = + typename __hashtable_alloc::__node_alloc_traits; + using __node_type = typename __hashtable_alloc::__node_type; + + public: + _ReuseOrAllocNode(__node_type* __nodes, __hashtable_alloc& __h) + : _M_nodes(__nodes), _M_h(__h) { } + _ReuseOrAllocNode(const _ReuseOrAllocNode&) = delete; + + ~_ReuseOrAllocNode() + { _M_h._M_deallocate_nodes(_M_nodes); } + + template + __node_type* + operator()(_Arg&& __arg) const + { + if (_M_nodes) + { + __node_type* __node = _M_nodes; + _M_nodes = _M_nodes->_M_next(); + __node->_M_nxt = nullptr; + auto& __a = _M_h._M_node_allocator(); + __node_alloc_traits::destroy(__a, __node->_M_valptr()); + __try + { + __node_alloc_traits::construct(__a, __node->_M_valptr(), + std::forward<_Arg>(__arg)); + } + __catch(...) + { + _M_h._M_deallocate_node_ptr(__node); + __throw_exception_again; + } + return __node; + } + return _M_h._M_allocate_node(std::forward<_Arg>(__arg)); + } + + private: + mutable __node_type* _M_nodes; + __hashtable_alloc& _M_h; + }; + + // Functor similar to the previous one but without any pool of nodes to + // recycle. + template + struct _AllocNode + { + private: + using __hashtable_alloc = _Hashtable_alloc<_NodeAlloc>; + using __node_type = typename __hashtable_alloc::__node_type; + + public: + _AllocNode(__hashtable_alloc& __h) + : _M_h(__h) { } + + template + __node_type* + operator()(_Arg&& __arg) const + { return _M_h._M_allocate_node(std::forward<_Arg>(__arg)); } + + private: + __hashtable_alloc& _M_h; + }; + + // Auxiliary types used for all instantiations of _Hashtable nodes + // and iterators. + + /** + * struct _Hashtable_traits + * + * Important traits for hash tables. + * + * @tparam _Cache_hash_code Boolean value. True if the value of + * the hash function is stored along with the value. This is a + * time-space tradeoff. Storing it may improve lookup speed by + * reducing the number of times we need to call the _Hash or _Equal + * functors. + * + * @tparam _Constant_iterators Boolean value. True if iterator and + * const_iterator are both constant iterator types. This is true + * for unordered_set and unordered_multiset, false for + * unordered_map and unordered_multimap. + * + * @tparam _Unique_keys Boolean value. True if the return value + * of _Hashtable::count(k) is always at most one, false if it may + * be an arbitrary number. This is true for unordered_set and + * unordered_map, false for unordered_multiset and + * unordered_multimap. + */ + template + struct _Hashtable_traits + { + using __hash_cached = __bool_constant<_Cache_hash_code>; + using __constant_iterators = __bool_constant<_Constant_iterators>; + using __unique_keys = __bool_constant<_Unique_keys>; + }; + + /** + * struct _Hash_node_base + * + * Nodes, used to wrap elements stored in the hash table. A policy + * template parameter of class template _Hashtable controls whether + * nodes also store a hash code. In some cases (e.g. strings) this + * may be a performance win. + */ + struct _Hash_node_base + { + _Hash_node_base* _M_nxt; + + _Hash_node_base() noexcept : _M_nxt() { } + + _Hash_node_base(_Hash_node_base* __next) noexcept : _M_nxt(__next) { } + }; + + /** + * struct _Hash_node_value_base + * + * Node type with the value to store. + */ + template + struct _Hash_node_value_base + { + typedef _Value value_type; + + __gnu_cxx::__aligned_buffer<_Value> _M_storage; + + _Value* + _M_valptr() noexcept + { return _M_storage._M_ptr(); } + + const _Value* + _M_valptr() const noexcept + { return _M_storage._M_ptr(); } + + _Value& + _M_v() noexcept + { return *_M_valptr(); } + + const _Value& + _M_v() const noexcept + { return *_M_valptr(); } + }; + + /** + * Primary template struct _Hash_node_code_cache. + */ + template + struct _Hash_node_code_cache + { }; + + /** + * Specialization for node with cache, struct _Hash_node_code_cache. + */ + template<> + struct _Hash_node_code_cache + { std::size_t _M_hash_code; }; + + template + struct _Hash_node_value + : _Hash_node_value_base<_Value> + , _Hash_node_code_cache<_Cache_hash_code> + { }; + + /** + * Primary template struct _Hash_node. + */ + template + struct _Hash_node + : _Hash_node_base + , _Hash_node_value<_Value, _Cache_hash_code> + { + _Hash_node* + _M_next() const noexcept + { return static_cast<_Hash_node*>(this->_M_nxt); } + }; + + /// Base class for node iterators. + template + struct _Node_iterator_base + { + using __node_type = _Hash_node<_Value, _Cache_hash_code>; + + __node_type* _M_cur; + + _Node_iterator_base() : _M_cur(nullptr) { } + _Node_iterator_base(__node_type* __p) noexcept + : _M_cur(__p) { } + + void + _M_incr() noexcept + { _M_cur = _M_cur->_M_next(); } + + friend bool + operator==(const _Node_iterator_base& __x, const _Node_iterator_base& __y) + noexcept + { return __x._M_cur == __y._M_cur; } + +#if __cpp_impl_three_way_comparison < 201907L + friend bool + operator!=(const _Node_iterator_base& __x, const _Node_iterator_base& __y) + noexcept + { return __x._M_cur != __y._M_cur; } +#endif + }; + + /// Node iterators, used to iterate through all the hashtable. + template + struct _Node_iterator + : public _Node_iterator_base<_Value, __cache> + { + private: + using __base_type = _Node_iterator_base<_Value, __cache>; + using __node_type = typename __base_type::__node_type; + + public: + typedef _Value value_type; + typedef std::ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + using pointer = typename std::conditional<__constant_iterators, + const value_type*, value_type*>::type; + + using reference = typename std::conditional<__constant_iterators, + const value_type&, value_type&>::type; + + _Node_iterator() = default; + + explicit + _Node_iterator(__node_type* __p) noexcept + : __base_type(__p) { } + + reference + operator*() const noexcept + { return this->_M_cur->_M_v(); } + + pointer + operator->() const noexcept + { return this->_M_cur->_M_valptr(); } + + _Node_iterator& + operator++() noexcept + { + this->_M_incr(); + return *this; + } + + _Node_iterator + operator++(int) noexcept + { + _Node_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + /// Node const_iterators, used to iterate through all the hashtable. + template + struct _Node_const_iterator + : public _Node_iterator_base<_Value, __cache> + { + private: + using __base_type = _Node_iterator_base<_Value, __cache>; + using __node_type = typename __base_type::__node_type; + + public: + typedef _Value value_type; + typedef std::ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + typedef const value_type* pointer; + typedef const value_type& reference; + + _Node_const_iterator() = default; + + explicit + _Node_const_iterator(__node_type* __p) noexcept + : __base_type(__p) { } + + _Node_const_iterator(const _Node_iterator<_Value, __constant_iterators, + __cache>& __x) noexcept + : __base_type(__x._M_cur) { } + + reference + operator*() const noexcept + { return this->_M_cur->_M_v(); } + + pointer + operator->() const noexcept + { return this->_M_cur->_M_valptr(); } + + _Node_const_iterator& + operator++() noexcept + { + this->_M_incr(); + return *this; + } + + _Node_const_iterator + operator++(int) noexcept + { + _Node_const_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + // Many of class template _Hashtable's template parameters are policy + // classes. These are defaults for the policies. + + /// Default range hashing function: use division to fold a large number + /// into the range [0, N). + struct _Mod_range_hashing + { + typedef std::size_t first_argument_type; + typedef std::size_t second_argument_type; + typedef std::size_t result_type; + + result_type + operator()(first_argument_type __num, + second_argument_type __den) const noexcept + { return __num % __den; } + }; + + /// Default ranged hash function H. In principle it should be a + /// function object composed from objects of type H1 and H2 such that + /// h(k, N) = h2(h1(k), N), but that would mean making extra copies of + /// h1 and h2. So instead we'll just use a tag to tell class template + /// hashtable to do that composition. + struct _Default_ranged_hash { }; + + /// Default value for rehash policy. Bucket size is (usually) the + /// smallest prime that keeps the load factor small enough. + struct _Prime_rehash_policy + { + using __has_load_factor = true_type; + + _Prime_rehash_policy(float __z = 1.0) noexcept + : _M_max_load_factor(__z), _M_next_resize(0) { } + + float + max_load_factor() const noexcept + { return _M_max_load_factor; } + + // Return a bucket size no smaller than n. + std::size_t + _M_next_bkt(std::size_t __n) const; + + // Return a bucket count appropriate for n elements + std::size_t + _M_bkt_for_elements(std::size_t __n) const + { return __builtin_ceil(__n / (double)_M_max_load_factor); } + + // __n_bkt is current bucket count, __n_elt is current element count, + // and __n_ins is number of elements to be inserted. Do we need to + // increase bucket count? If so, return make_pair(true, n), where n + // is the new bucket count. If not, return make_pair(false, 0). + std::pair + _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt, + std::size_t __n_ins) const; + + typedef std::size_t _State; + + _State + _M_state() const + { return _M_next_resize; } + + void + _M_reset() noexcept + { _M_next_resize = 0; } + + void + _M_reset(_State __state) + { _M_next_resize = __state; } + + static const std::size_t _S_growth_factor = 2; + + float _M_max_load_factor; + mutable std::size_t _M_next_resize; + }; + + /// Range hashing function assuming that second arg is a power of 2. + struct _Mask_range_hashing + { + typedef std::size_t first_argument_type; + typedef std::size_t second_argument_type; + typedef std::size_t result_type; + + result_type + operator()(first_argument_type __num, + second_argument_type __den) const noexcept + { return __num & (__den - 1); } + }; + + /// Compute closest power of 2 not less than __n + inline std::size_t + __clp2(std::size_t __n) noexcept + { + using __gnu_cxx::__int_traits; + // Equivalent to return __n ? std::bit_ceil(__n) : 0; + if (__n < 2) + return __n; + const unsigned __lz = sizeof(size_t) > sizeof(long) + ? __builtin_clzll(__n - 1ull) + : __builtin_clzl(__n - 1ul); + // Doing two shifts avoids undefined behaviour when __lz == 0. + return (size_t(1) << (__int_traits::__digits - __lz - 1)) << 1; + } + + /// Rehash policy providing power of 2 bucket numbers. Avoids modulo + /// operations. + struct _Power2_rehash_policy + { + using __has_load_factor = true_type; + + _Power2_rehash_policy(float __z = 1.0) noexcept + : _M_max_load_factor(__z), _M_next_resize(0) { } + + float + max_load_factor() const noexcept + { return _M_max_load_factor; } + + // Return a bucket size no smaller than n (as long as n is not above the + // highest power of 2). + std::size_t + _M_next_bkt(std::size_t __n) noexcept + { + if (__n == 0) + // Special case on container 1st initialization with 0 bucket count + // hint. We keep _M_next_resize to 0 to make sure that next time we + // want to add an element allocation will take place. + return 1; + + const auto __max_width = std::min(sizeof(size_t), 8); + const auto __max_bkt = size_t(1) << (__max_width * __CHAR_BIT__ - 1); + std::size_t __res = __clp2(__n); + + if (__res == 0) + __res = __max_bkt; + else if (__res == 1) + // If __res is 1 we force it to 2 to make sure there will be an + // allocation so that nothing need to be stored in the initial + // single bucket + __res = 2; + + if (__res == __max_bkt) + // Set next resize to the max value so that we never try to rehash again + // as we already reach the biggest possible bucket number. + // Note that it might result in max_load_factor not being respected. + _M_next_resize = size_t(-1); + else + _M_next_resize + = __builtin_floor(__res * (double)_M_max_load_factor); + + return __res; + } + + // Return a bucket count appropriate for n elements + std::size_t + _M_bkt_for_elements(std::size_t __n) const noexcept + { return __builtin_ceil(__n / (double)_M_max_load_factor); } + + // __n_bkt is current bucket count, __n_elt is current element count, + // and __n_ins is number of elements to be inserted. Do we need to + // increase bucket count? If so, return make_pair(true, n), where n + // is the new bucket count. If not, return make_pair(false, 0). + std::pair + _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt, + std::size_t __n_ins) noexcept + { + if (__n_elt + __n_ins > _M_next_resize) + { + // If _M_next_resize is 0 it means that we have nothing allocated so + // far and that we start inserting elements. In this case we start + // with an initial bucket size of 11. + double __min_bkts + = std::max(__n_elt + __n_ins, _M_next_resize ? 0 : 11) + / (double)_M_max_load_factor; + if (__min_bkts >= __n_bkt) + return { true, + _M_next_bkt(std::max(__builtin_floor(__min_bkts) + 1, + __n_bkt * _S_growth_factor)) }; + + _M_next_resize + = __builtin_floor(__n_bkt * (double)_M_max_load_factor); + return { false, 0 }; + } + else + return { false, 0 }; + } + + typedef std::size_t _State; + + _State + _M_state() const noexcept + { return _M_next_resize; } + + void + _M_reset() noexcept + { _M_next_resize = 0; } + + void + _M_reset(_State __state) noexcept + { _M_next_resize = __state; } + + static const std::size_t _S_growth_factor = 2; + + float _M_max_load_factor; + std::size_t _M_next_resize; + }; + + // Base classes for std::_Hashtable. We define these base classes + // because in some cases we want to do different things depending on + // the value of a policy class. In some cases the policy class + // affects which member functions and nested typedefs are defined; + // we handle that by specializing base class templates. Several of + // the base class templates need to access other members of class + // template _Hashtable, so we use a variant of the "Curiously + // Recurring Template Pattern" (CRTP) technique. + + /** + * Primary class template _Map_base. + * + * If the hashtable has a value type of the form pair and a + * key extraction policy (_ExtractKey) that returns the first part + * of the pair, the hashtable gets a mapped_type typedef. If it + * satisfies those criteria and also has unique keys, then it also + * gets an operator[]. + */ + template + struct _Map_base { }; + + /// Partial specialization, __unique_keys set to false. + template + struct _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false> + { + using mapped_type = typename std::tuple_element<1, _Pair>::type; + }; + + /// Partial specialization, __unique_keys set to true. + template + struct _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true> + { + private: + using __hashtable_base = _Hashtable_base<_Key, _Pair, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, + _Traits>; + + using __hashtable = _Hashtable<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, + _Unused, _RehashPolicy, _Traits>; + + using __hash_code = typename __hashtable_base::__hash_code; + + public: + using key_type = typename __hashtable_base::key_type; + using mapped_type = typename std::tuple_element<1, _Pair>::type; + + mapped_type& + operator[](const key_type& __k); + + mapped_type& + operator[](key_type&& __k); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 761. unordered_map needs an at() member function. + mapped_type& + at(const key_type& __k); + + const mapped_type& + at(const key_type& __k) const; + }; + + template + auto + _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + operator[](const key_type& __k) + -> mapped_type& + { + __hashtable* __h = static_cast<__hashtable*>(this); + __hash_code __code = __h->_M_hash_code(__k); + std::size_t __bkt = __h->_M_bucket_index(__code); + if (auto __node = __h->_M_find_node(__bkt, __k, __code)) + return __node->_M_v().second; + + typename __hashtable::_Scoped_node __node { + __h, + std::piecewise_construct, + std::tuple(__k), + std::tuple<>() + }; + auto __pos + = __h->_M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return __pos->second; + } + + template + auto + _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + operator[](key_type&& __k) + -> mapped_type& + { + __hashtable* __h = static_cast<__hashtable*>(this); + __hash_code __code = __h->_M_hash_code(__k); + std::size_t __bkt = __h->_M_bucket_index(__code); + if (auto __node = __h->_M_find_node(__bkt, __k, __code)) + return __node->_M_v().second; + + typename __hashtable::_Scoped_node __node { + __h, + std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::tuple<>() + }; + auto __pos + = __h->_M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return __pos->second; + } + + template + auto + _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + at(const key_type& __k) + -> mapped_type& + { + __hashtable* __h = static_cast<__hashtable*>(this); + auto __ite = __h->find(__k); + + if (!__ite._M_cur) + __throw_out_of_range(__N("_Map_base::at")); + return __ite->second; + } + + template + auto + _Map_base<_Key, _Pair, _Alloc, _Select1st, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + at(const key_type& __k) const + -> const mapped_type& + { + const __hashtable* __h = static_cast(this); + auto __ite = __h->find(__k); + + if (!__ite._M_cur) + __throw_out_of_range(__N("_Map_base::at")); + return __ite->second; + } + + /** + * Primary class template _Insert_base. + * + * Defines @c insert member functions appropriate to all _Hashtables. + */ + template + struct _Insert_base + { + protected: + using __hashtable_base = _Hashtable_base<_Key, _Value, _ExtractKey, + _Equal, _Hash, _RangeHash, + _Unused, _Traits>; + + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, + _Unused, _RehashPolicy, _Traits>; + + using __hash_cached = typename _Traits::__hash_cached; + using __constant_iterators = typename _Traits::__constant_iterators; + + using __hashtable_alloc = _Hashtable_alloc< + __alloc_rebind<_Alloc, _Hash_node<_Value, + __hash_cached::value>>>; + + using value_type = typename __hashtable_base::value_type; + using size_type = typename __hashtable_base::size_type; + + using __unique_keys = typename _Traits::__unique_keys; + using __node_alloc_type = typename __hashtable_alloc::__node_alloc_type; + using __node_gen_type = _AllocNode<__node_alloc_type>; + + __hashtable& + _M_conjure_hashtable() + { return *(static_cast<__hashtable*>(this)); } + + template + void + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter&, true_type __uks); + + template + void + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter&, false_type __uks); + + public: + using iterator = _Node_iterator<_Value, __constant_iterators::value, + __hash_cached::value>; + + using const_iterator = _Node_const_iterator<_Value, __constant_iterators::value, + __hash_cached::value>; + + using __ireturn_type = typename std::conditional<__unique_keys::value, + std::pair, + iterator>::type; + + __ireturn_type + insert(const value_type& __v) + { + __hashtable& __h = _M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(__v, __node_gen, __unique_keys{}); + } + + iterator + insert(const_iterator __hint, const value_type& __v) + { + __hashtable& __h = _M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(__hint, __v, __node_gen, __unique_keys{}); + } + + template + std::pair + try_emplace(const_iterator, _KType&& __k, _Args&&... __args) + { + __hashtable& __h = _M_conjure_hashtable(); + auto __code = __h._M_hash_code(__k); + std::size_t __bkt = __h._M_bucket_index(__code); + if (auto __node = __h._M_find_node(__bkt, __k, __code)) + return { iterator(__node), false }; + + typename __hashtable::_Scoped_node __node { + &__h, + std::piecewise_construct, + std::forward_as_tuple(std::forward<_KType>(__k)), + std::forward_as_tuple(std::forward<_Args>(__args)...) + }; + auto __it + = __h._M_insert_unique_node(__bkt, __code, __node._M_node); + __node._M_node = nullptr; + return { __it, true }; + } + + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + __hashtable& __h = _M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return _M_insert_range(__first, __last, __node_gen, __unique_keys{}); + } + }; + + template + template + void + _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>:: + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter& __node_gen, true_type __uks) + { + __hashtable& __h = _M_conjure_hashtable(); + for (; __first != __last; ++__first) + __h._M_insert(*__first, __node_gen, __uks); + } + + template + template + void + _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>:: + _M_insert_range(_InputIterator __first, _InputIterator __last, + const _NodeGetter& __node_gen, false_type __uks) + { + using __rehash_type = typename __hashtable::__rehash_type; + using __rehash_state = typename __hashtable::__rehash_state; + using pair_type = std::pair; + + size_type __n_elt = __detail::__distance_fw(__first, __last); + if (__n_elt == 0) + return; + + __hashtable& __h = _M_conjure_hashtable(); + __rehash_type& __rehash = __h._M_rehash_policy; + const __rehash_state& __saved_state = __rehash._M_state(); + pair_type __do_rehash = __rehash._M_need_rehash(__h._M_bucket_count, + __h._M_element_count, + __n_elt); + + if (__do_rehash.first) + __h._M_rehash(__do_rehash.second, __saved_state); + + for (; __first != __last; ++__first) + __h._M_insert(*__first, __node_gen, __uks); + } + + /** + * Primary class template _Insert. + * + * Defines @c insert member functions that depend on _Hashtable policies, + * via partial specializations. + */ + template + struct _Insert; + + /// Specialization. + template + struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits, true> + : public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits> + { + using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + using value_type = typename __base_type::value_type; + using iterator = typename __base_type::iterator; + using const_iterator = typename __base_type::const_iterator; + using __ireturn_type = typename __base_type::__ireturn_type; + + using __unique_keys = typename __base_type::__unique_keys; + using __hashtable = typename __base_type::__hashtable; + using __node_gen_type = typename __base_type::__node_gen_type; + + using __base_type::insert; + + __ireturn_type + insert(value_type&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(std::move(__v), __node_gen, __unique_keys{}); + } + + iterator + insert(const_iterator __hint, value_type&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + __node_gen_type __node_gen(__h); + return __h._M_insert(__hint, std::move(__v), __node_gen, + __unique_keys{}); + } + }; + + /// Specialization. + template + struct _Insert<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false> + : public _Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits> + { + using __base_type = _Insert_base<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + using value_type = typename __base_type::value_type; + using iterator = typename __base_type::iterator; + using const_iterator = typename __base_type::const_iterator; + + using __unique_keys = typename __base_type::__unique_keys; + using __hashtable = typename __base_type::__hashtable; + using __ireturn_type = typename __base_type::__ireturn_type; + + using __base_type::insert; + + template + using __is_cons = std::is_constructible; + + template + using _IFcons = std::enable_if<__is_cons<_Pair>::value>; + + template + using _IFconsp = typename _IFcons<_Pair>::type; + + template> + __ireturn_type + insert(_Pair&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + return __h._M_emplace(__unique_keys{}, std::forward<_Pair>(__v)); + } + + template> + iterator + insert(const_iterator __hint, _Pair&& __v) + { + __hashtable& __h = this->_M_conjure_hashtable(); + return __h._M_emplace(__hint, __unique_keys{}, + std::forward<_Pair>(__v)); + } + }; + + template + using __has_load_factor = typename _Policy::__has_load_factor; + + /** + * Primary class template _Rehash_base. + * + * Give hashtable the max_load_factor functions and reserve iff the + * rehash policy supports it. + */ + template> + struct _Rehash_base; + + /// Specialization when rehash policy doesn't provide load factor management. + template + struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, + false_type /* Has load factor */> + { + }; + + /// Specialization when rehash policy provide load factor management. + template + struct _Rehash_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, + true_type /* Has load factor */> + { + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, + _Equal, _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + float + max_load_factor() const noexcept + { + const __hashtable* __this = static_cast(this); + return __this->__rehash_policy().max_load_factor(); + } + + void + max_load_factor(float __z) + { + __hashtable* __this = static_cast<__hashtable*>(this); + __this->__rehash_policy(_RehashPolicy(__z)); + } + + void + reserve(std::size_t __n) + { + __hashtable* __this = static_cast<__hashtable*>(this); + __this->rehash(__this->__rehash_policy()._M_bkt_for_elements(__n)); + } + }; + + /** + * Primary class template _Hashtable_ebo_helper. + * + * Helper class using EBO when it is not forbidden (the type is not + * final) and when it is worth it (the type is empty.) + */ + template + struct _Hashtable_ebo_helper; + + /// Specialization using EBO. + template + struct _Hashtable_ebo_helper<_Nm, _Tp, true> + : private _Tp + { + _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } + + template + _Hashtable_ebo_helper(_OtherTp&& __tp) + : _Tp(std::forward<_OtherTp>(__tp)) + { } + + const _Tp& _M_cget() const { return static_cast(*this); } + _Tp& _M_get() { return static_cast<_Tp&>(*this); } + }; + + /// Specialization not using EBO. + template + struct _Hashtable_ebo_helper<_Nm, _Tp, false> + { + _Hashtable_ebo_helper() = default; + + template + _Hashtable_ebo_helper(_OtherTp&& __tp) + : _M_tp(std::forward<_OtherTp>(__tp)) + { } + + const _Tp& _M_cget() const { return _M_tp; } + _Tp& _M_get() { return _M_tp; } + + private: + _Tp _M_tp{}; + }; + + /** + * Primary class template _Local_iterator_base. + * + * Base class for local iterators, used to iterate within a bucket + * but not between buckets. + */ + template + struct _Local_iterator_base; + + /** + * Primary class template _Hash_code_base. + * + * Encapsulates two policy issues that aren't quite orthogonal. + * (1) the difference between using a ranged hash function and using + * the combination of a hash function and a range-hashing function. + * In the former case we don't have such things as hash codes, so + * we have a dummy type as placeholder. + * (2) Whether or not we cache hash codes. Caching hash codes is + * meaningless if we have a ranged hash function. + * + * We also put the key extraction objects here, for convenience. + * Each specialization derives from one or more of the template + * parameters to benefit from Ebo. This is important as this type + * is inherited in some cases by the _Local_iterator_base type used + * to implement local_iterator and const_local_iterator. As with + * any iterator type we prefer to make it as small as possible. + */ + template + struct _Hash_code_base + : private _Hashtable_ebo_helper<1, _Hash> + { + private: + using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>; + + // Gives the local iterator implementation access to _M_bucket_index(). + friend struct _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false>; + + public: + typedef _Hash hasher; + + hasher + hash_function() const + { return _M_hash(); } + + protected: + typedef std::size_t __hash_code; + + // We need the default constructor for the local iterators and _Hashtable + // default constructor. + _Hash_code_base() = default; + + _Hash_code_base(const _Hash& __hash) : __ebo_hash(__hash) { } + + __hash_code + _M_hash_code(const _Key& __k) const + { + static_assert(__is_invocable{}, + "hash function must be invocable with an argument of key type"); + return _M_hash()(__k); + } + + template + __hash_code + _M_hash_code_tr(const _Kt& __k) const + { + static_assert(__is_invocable{}, + "hash function must be invocable with an argument of key type"); + return _M_hash()(__k); + } + + std::size_t + _M_bucket_index(__hash_code __c, std::size_t __bkt_count) const + { return _RangeHash{}(__c, __bkt_count); } + + std::size_t + _M_bucket_index(const _Hash_node_value<_Value, false>& __n, + std::size_t __bkt_count) const + noexcept( noexcept(declval()(declval())) + && noexcept(declval()((__hash_code)0, + (std::size_t)0)) ) + { + return _RangeHash{}(_M_hash_code(_ExtractKey{}(__n._M_v())), + __bkt_count); + } + + std::size_t + _M_bucket_index(const _Hash_node_value<_Value, true>& __n, + std::size_t __bkt_count) const + noexcept( noexcept(declval()((__hash_code)0, + (std::size_t)0)) ) + { return _RangeHash{}(__n._M_hash_code, __bkt_count); } + + void + _M_store_code(_Hash_node_code_cache&, __hash_code) const + { } + + void + _M_copy_code(_Hash_node_code_cache&, + const _Hash_node_code_cache&) const + { } + + void + _M_store_code(_Hash_node_code_cache& __n, __hash_code __c) const + { __n._M_hash_code = __c; } + + void + _M_copy_code(_Hash_node_code_cache& __to, + const _Hash_node_code_cache& __from) const + { __to._M_hash_code = __from._M_hash_code; } + + void + _M_swap(_Hash_code_base& __x) + { std::swap(__ebo_hash::_M_get(), __x.__ebo_hash::_M_get()); } + + const _Hash& + _M_hash() const { return __ebo_hash::_M_cget(); } + }; + + /// Partial specialization used when nodes contain a cached hash code. + template + struct _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, true> + : public _Node_iterator_base<_Value, true> + { + protected: + using __base_node_iter = _Node_iterator_base<_Value, true>; + using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, true>; + + _Local_iterator_base() = default; + _Local_iterator_base(const __hash_code_base&, + _Hash_node<_Value, true>* __p, + std::size_t __bkt, std::size_t __bkt_count) + : __base_node_iter(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count) + { } + + void + _M_incr() + { + __base_node_iter::_M_incr(); + if (this->_M_cur) + { + std::size_t __bkt + = _RangeHash{}(this->_M_cur->_M_hash_code, _M_bucket_count); + if (__bkt != _M_bucket) + this->_M_cur = nullptr; + } + } + + std::size_t _M_bucket; + std::size_t _M_bucket_count; + + public: + std::size_t + _M_get_bucket() const { return _M_bucket; } // for debug mode + }; + + // Uninitialized storage for a _Hash_code_base. + // This type is DefaultConstructible and Assignable even if the + // _Hash_code_base type isn't, so that _Local_iterator_base<..., false> + // can be DefaultConstructible and Assignable. + template::value> + struct _Hash_code_storage + { + __gnu_cxx::__aligned_buffer<_Tp> _M_storage; + + _Tp* + _M_h() { return _M_storage._M_ptr(); } + + const _Tp* + _M_h() const { return _M_storage._M_ptr(); } + }; + + // Empty partial specialization for empty _Hash_code_base types. + template + struct _Hash_code_storage<_Tp, true> + { + static_assert( std::is_empty<_Tp>::value, "Type must be empty" ); + + // As _Tp is an empty type there will be no bytes written/read through + // the cast pointer, so no strict-aliasing violation. + _Tp* + _M_h() { return reinterpret_cast<_Tp*>(this); } + + const _Tp* + _M_h() const { return reinterpret_cast(this); } + }; + + template + using __hash_code_for_local_iter + = _Hash_code_storage<_Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false>>; + + // Partial specialization used when hash codes are not cached + template + struct _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false> + : __hash_code_for_local_iter<_Key, _Value, _ExtractKey, _Hash, _RangeHash, + _Unused> + , _Node_iterator_base<_Value, false> + { + protected: + using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, false>; + using __node_iter_base = _Node_iterator_base<_Value, false>; + + _Local_iterator_base() : _M_bucket_count(-1) { } + + _Local_iterator_base(const __hash_code_base& __base, + _Hash_node<_Value, false>* __p, + std::size_t __bkt, std::size_t __bkt_count) + : __node_iter_base(__p), _M_bucket(__bkt), _M_bucket_count(__bkt_count) + { _M_init(__base); } + + ~_Local_iterator_base() + { + if (_M_bucket_count != size_t(-1)) + _M_destroy(); + } + + _Local_iterator_base(const _Local_iterator_base& __iter) + : __node_iter_base(__iter._M_cur), _M_bucket(__iter._M_bucket) + , _M_bucket_count(__iter._M_bucket_count) + { + if (_M_bucket_count != size_t(-1)) + _M_init(*__iter._M_h()); + } + + _Local_iterator_base& + operator=(const _Local_iterator_base& __iter) + { + if (_M_bucket_count != -1) + _M_destroy(); + this->_M_cur = __iter._M_cur; + _M_bucket = __iter._M_bucket; + _M_bucket_count = __iter._M_bucket_count; + if (_M_bucket_count != -1) + _M_init(*__iter._M_h()); + return *this; + } + + void + _M_incr() + { + __node_iter_base::_M_incr(); + if (this->_M_cur) + { + std::size_t __bkt = this->_M_h()->_M_bucket_index(*this->_M_cur, + _M_bucket_count); + if (__bkt != _M_bucket) + this->_M_cur = nullptr; + } + } + + std::size_t _M_bucket; + std::size_t _M_bucket_count; + + void + _M_init(const __hash_code_base& __base) + { ::new(this->_M_h()) __hash_code_base(__base); } + + void + _M_destroy() { this->_M_h()->~__hash_code_base(); } + + public: + std::size_t + _M_get_bucket() const { return _M_bucket; } // for debug mode + }; + + /// local iterators + template + struct _Local_iterator + : public _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache> + { + private: + using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache>; + using __hash_code_base = typename __base_type::__hash_code_base; + + public: + typedef _Value value_type; + typedef typename std::conditional<__constant_iterators, + const value_type*, value_type*>::type + pointer; + typedef typename std::conditional<__constant_iterators, + const value_type&, value_type&>::type + reference; + typedef std::ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Local_iterator() = default; + + _Local_iterator(const __hash_code_base& __base, + _Hash_node<_Value, __cache>* __n, + std::size_t __bkt, std::size_t __bkt_count) + : __base_type(__base, __n, __bkt, __bkt_count) + { } + + reference + operator*() const + { return this->_M_cur->_M_v(); } + + pointer + operator->() const + { return this->_M_cur->_M_valptr(); } + + _Local_iterator& + operator++() + { + this->_M_incr(); + return *this; + } + + _Local_iterator + operator++(int) + { + _Local_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + /// local const_iterators + template + struct _Local_const_iterator + : public _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache> + { + private: + using __base_type = _Local_iterator_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, __cache>; + using __hash_code_base = typename __base_type::__hash_code_base; + + public: + typedef _Value value_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::ptrdiff_t difference_type; + typedef std::forward_iterator_tag iterator_category; + + _Local_const_iterator() = default; + + _Local_const_iterator(const __hash_code_base& __base, + _Hash_node<_Value, __cache>* __n, + std::size_t __bkt, std::size_t __bkt_count) + : __base_type(__base, __n, __bkt, __bkt_count) + { } + + _Local_const_iterator(const _Local_iterator<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, + __constant_iterators, + __cache>& __x) + : __base_type(__x) + { } + + reference + operator*() const + { return this->_M_cur->_M_v(); } + + pointer + operator->() const + { return this->_M_cur->_M_valptr(); } + + _Local_const_iterator& + operator++() + { + this->_M_incr(); + return *this; + } + + _Local_const_iterator + operator++(int) + { + _Local_const_iterator __tmp(*this); + this->_M_incr(); + return __tmp; + } + }; + + /** + * Primary class template _Hashtable_base. + * + * Helper class adding management of _Equal functor to + * _Hash_code_base type. + * + * Base class templates are: + * - __detail::_Hash_code_base + * - __detail::_Hashtable_ebo_helper + */ + template + struct _Hashtable_base + : public _Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, + _Unused, _Traits::__hash_cached::value>, + private _Hashtable_ebo_helper<0, _Equal> + { + public: + typedef _Key key_type; + typedef _Value value_type; + typedef _Equal key_equal; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + using __traits_type = _Traits; + using __hash_cached = typename __traits_type::__hash_cached; + + using __hash_code_base = _Hash_code_base<_Key, _Value, _ExtractKey, + _Hash, _RangeHash, _Unused, + __hash_cached::value>; + + using __hash_code = typename __hash_code_base::__hash_code; + + private: + using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>; + + static bool + _S_equals(__hash_code, const _Hash_node_code_cache&) + { return true; } + + static bool + _S_node_equals(const _Hash_node_code_cache&, + const _Hash_node_code_cache&) + { return true; } + + static bool + _S_equals(__hash_code __c, const _Hash_node_code_cache& __n) + { return __c == __n._M_hash_code; } + + static bool + _S_node_equals(const _Hash_node_code_cache& __lhn, + const _Hash_node_code_cache& __rhn) + { return __lhn._M_hash_code == __rhn._M_hash_code; } + + protected: + _Hashtable_base() = default; + + _Hashtable_base(const _Hash& __hash, const _Equal& __eq) + : __hash_code_base(__hash), _EqualEBO(__eq) + { } + + bool + _M_equals(const _Key& __k, __hash_code __c, + const _Hash_node_value<_Value, __hash_cached::value>& __n) const + { + static_assert(__is_invocable{}, + "key equality predicate must be invocable with two arguments of " + "key type"); + return _S_equals(__c, __n) && _M_eq()(__k, _ExtractKey{}(__n._M_v())); + } + + template + bool + _M_equals_tr(const _Kt& __k, __hash_code __c, + const _Hash_node_value<_Value, + __hash_cached::value>& __n) const + { + static_assert( + __is_invocable{}, + "key equality predicate must be invocable with two arguments of " + "key type"); + return _S_equals(__c, __n) && _M_eq()(__k, _ExtractKey{}(__n._M_v())); + } + + bool + _M_node_equals( + const _Hash_node_value<_Value, __hash_cached::value>& __lhn, + const _Hash_node_value<_Value, __hash_cached::value>& __rhn) const + { + return _S_node_equals(__lhn, __rhn) + && _M_eq()(_ExtractKey{}(__lhn._M_v()), _ExtractKey{}(__rhn._M_v())); + } + + void + _M_swap(_Hashtable_base& __x) + { + __hash_code_base::_M_swap(__x); + std::swap(_EqualEBO::_M_get(), __x._EqualEBO::_M_get()); + } + + const _Equal& + _M_eq() const { return _EqualEBO::_M_cget(); } + }; + + /** + * Primary class template _Equality. + * + * This is for implementing equality comparison for unordered + * containers, per N3068, by John Lakos and Pablo Halpern. + * Algorithmically, we follow closely the reference implementations + * therein. + */ + template + struct _Equality; + + /// unordered_map and unordered_set specializations. + template + struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true> + { + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + bool + _M_equal(const __hashtable&) const; + }; + + template + bool + _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, true>:: + _M_equal(const __hashtable& __other) const + { + using __node_type = typename __hashtable::__node_type; + const __hashtable* __this = static_cast(this); + if (__this->size() != __other.size()) + return false; + + for (auto __itx = __this->begin(); __itx != __this->end(); ++__itx) + { + std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur); + auto __prev_n = __other._M_buckets[__ybkt]; + if (!__prev_n) + return false; + + for (__node_type* __n = static_cast<__node_type*>(__prev_n->_M_nxt);; + __n = __n->_M_next()) + { + if (__n->_M_v() == *__itx) + break; + + if (!__n->_M_nxt + || __other._M_bucket_index(*__n->_M_next()) != __ybkt) + return false; + } + } + + return true; + } + + /// unordered_multiset and unordered_multimap specializations. + template + struct _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false> + { + using __hashtable = _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, + _RehashPolicy, _Traits>; + + bool + _M_equal(const __hashtable&) const; + }; + + template + bool + _Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, + _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits, false>:: + _M_equal(const __hashtable& __other) const + { + using __node_type = typename __hashtable::__node_type; + const __hashtable* __this = static_cast(this); + if (__this->size() != __other.size()) + return false; + + for (auto __itx = __this->begin(); __itx != __this->end();) + { + std::size_t __x_count = 1; + auto __itx_end = __itx; + for (++__itx_end; __itx_end != __this->end() + && __this->key_eq()(_ExtractKey{}(*__itx), + _ExtractKey{}(*__itx_end)); + ++__itx_end) + ++__x_count; + + std::size_t __ybkt = __other._M_bucket_index(*__itx._M_cur); + auto __y_prev_n = __other._M_buckets[__ybkt]; + if (!__y_prev_n) + return false; + + __node_type* __y_n = static_cast<__node_type*>(__y_prev_n->_M_nxt); + for (;;) + { + if (__this->key_eq()(_ExtractKey{}(__y_n->_M_v()), + _ExtractKey{}(*__itx))) + break; + + auto __y_ref_n = __y_n; + for (__y_n = __y_n->_M_next(); __y_n; __y_n = __y_n->_M_next()) + if (!__other._M_node_equals(*__y_ref_n, *__y_n)) + break; + + if (!__y_n || __other._M_bucket_index(*__y_n) != __ybkt) + return false; + } + + typename __hashtable::const_iterator __ity(__y_n); + for (auto __ity_end = __ity; __ity_end != __other.end(); ++__ity_end) + if (--__x_count == 0) + break; + + if (__x_count != 0) + return false; + + if (!std::is_permutation(__itx, __itx_end, __ity)) + return false; + + __itx = __itx_end; + } + return true; + } + + /** + * This type deals with all allocation and keeps an allocator instance + * through inheritance to benefit from EBO when possible. + */ + template + struct _Hashtable_alloc : private _Hashtable_ebo_helper<0, _NodeAlloc> + { + private: + using __ebo_node_alloc = _Hashtable_ebo_helper<0, _NodeAlloc>; + public: + using __node_type = typename _NodeAlloc::value_type; + using __node_alloc_type = _NodeAlloc; + // Use __gnu_cxx to benefit from _S_always_equal and al. + using __node_alloc_traits = __gnu_cxx::__alloc_traits<__node_alloc_type>; + + using __value_alloc_traits = typename __node_alloc_traits::template + rebind_traits; + + using __node_ptr = __node_type*; + using __node_base = _Hash_node_base; + using __node_base_ptr = __node_base*; + using __buckets_alloc_type = + __alloc_rebind<__node_alloc_type, __node_base_ptr>; + using __buckets_alloc_traits = std::allocator_traits<__buckets_alloc_type>; + using __buckets_ptr = __node_base_ptr*; + + _Hashtable_alloc() = default; + _Hashtable_alloc(const _Hashtable_alloc&) = default; + _Hashtable_alloc(_Hashtable_alloc&&) = default; + + template + _Hashtable_alloc(_Alloc&& __a) + : __ebo_node_alloc(std::forward<_Alloc>(__a)) + { } + + __node_alloc_type& + _M_node_allocator() + { return __ebo_node_alloc::_M_get(); } + + const __node_alloc_type& + _M_node_allocator() const + { return __ebo_node_alloc::_M_cget(); } + + // Allocate a node and construct an element within it. + template + __node_ptr + _M_allocate_node(_Args&&... __args); + + // Destroy the element within a node and deallocate the node. + void + _M_deallocate_node(__node_ptr __n); + + // Deallocate a node. + void + _M_deallocate_node_ptr(__node_ptr __n); + + // Deallocate the linked list of nodes pointed to by __n. + // The elements within the nodes are destroyed. + void + _M_deallocate_nodes(__node_ptr __n); + + __buckets_ptr + _M_allocate_buckets(std::size_t __bkt_count); + + void + _M_deallocate_buckets(__buckets_ptr, std::size_t __bkt_count); + }; + + // Definitions of class template _Hashtable_alloc's out-of-line member + // functions. + template + template + auto + _Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args) + -> __node_ptr + { + auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1); + __node_ptr __n = std::__to_address(__nptr); + __try + { + ::new ((void*)__n) __node_type; + __node_alloc_traits::construct(_M_node_allocator(), + __n->_M_valptr(), + std::forward<_Args>(__args)...); + return __n; + } + __catch(...) + { + __node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1); + __throw_exception_again; + } + } + + template + void + _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node(__node_ptr __n) + { + __node_alloc_traits::destroy(_M_node_allocator(), __n->_M_valptr()); + _M_deallocate_node_ptr(__n); + } + + template + void + _Hashtable_alloc<_NodeAlloc>::_M_deallocate_node_ptr(__node_ptr __n) + { + typedef typename __node_alloc_traits::pointer _Ptr; + auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__n); + __n->~__node_type(); + __node_alloc_traits::deallocate(_M_node_allocator(), __ptr, 1); + } + + template + void + _Hashtable_alloc<_NodeAlloc>::_M_deallocate_nodes(__node_ptr __n) + { + while (__n) + { + __node_ptr __tmp = __n; + __n = __n->_M_next(); + _M_deallocate_node(__tmp); + } + } + + template + auto + _Hashtable_alloc<_NodeAlloc>::_M_allocate_buckets(std::size_t __bkt_count) + -> __buckets_ptr + { + __buckets_alloc_type __alloc(_M_node_allocator()); + + auto __ptr = __buckets_alloc_traits::allocate(__alloc, __bkt_count); + __buckets_ptr __p = std::__to_address(__ptr); + __builtin_memset(__p, 0, __bkt_count * sizeof(__node_base_ptr)); + return __p; + } + + template + void + _Hashtable_alloc<_NodeAlloc>:: + _M_deallocate_buckets(__buckets_ptr __bkts, + std::size_t __bkt_count) + { + typedef typename __buckets_alloc_traits::pointer _Ptr; + auto __ptr = std::pointer_traits<_Ptr>::pointer_to(*__bkts); + __buckets_alloc_type __alloc(_M_node_allocator()); + __buckets_alloc_traits::deallocate(__alloc, __ptr, __bkt_count); + } + + ///@} hashtable-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _HASHTABLE_POLICY_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/indirect_array.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/indirect_array.h new file mode 100755 index 0000000..a3dc605 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/indirect_array.h @@ -0,0 +1,212 @@ +// The template and inlines for the -*- C++ -*- indirect_array class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/indirect_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _INDIRECT_ARRAY_H +#define _INDIRECT_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Reference to arbitrary subset of an array. + * + * An indirect_array is a reference to the actual elements of an array + * specified by an ordered array of indices. The way to get an + * indirect_array is to call operator[](valarray) on a valarray. + * The returned indirect_array then permits carrying operations out on the + * referenced subset of elements in the original valarray. + * + * For example, if an indirect_array is obtained using the array (4,2,0) as + * an argument, and then assigned to an array containing (1,2,3), then the + * underlying array will have array[0]==3, array[2]==2, and array[4]==1. + * + * @param Tp Element type. + */ + template + class indirect_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + indirect_array(const indirect_array&); + + /// Assignment operator. Assigns elements to corresponding elements + /// of @a a. + indirect_array& operator=(const indirect_array&); + + /// Assign slice elements to corresponding elements of @a v. + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator= (const _Tp&) const; + // ~indirect_array(); + + template + void operator=(const _Expr<_Dom, _Tp>&) const; + template + void operator*=(const _Expr<_Dom, _Tp>&) const; + template + void operator/=(const _Expr<_Dom, _Tp>&) const; + template + void operator%=(const _Expr<_Dom, _Tp>&) const; + template + void operator+=(const _Expr<_Dom, _Tp>&) const; + template + void operator-=(const _Expr<_Dom, _Tp>&) const; + template + void operator^=(const _Expr<_Dom, _Tp>&) const; + template + void operator&=(const _Expr<_Dom, _Tp>&) const; + template + void operator|=(const _Expr<_Dom, _Tp>&) const; + template + void operator<<=(const _Expr<_Dom, _Tp>&) const; + template + void operator>>=(const _Expr<_Dom, _Tp>&) const; + + private: + /// Copy constructor. Both slices refer to the same underlying array. + indirect_array(_Array<_Tp>, size_t, _Array); + + friend class valarray<_Tp>; + friend class gslice_array<_Tp>; + + const size_t _M_sz; + const _Array _M_index; + const _Array<_Tp> _M_array; + + // not implemented + indirect_array(); + }; + + template + inline + indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a) + : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {} + + template + inline + indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s, + _Array __i) + : _M_sz(__s), _M_index(__i), _M_array(__a) {} + + template + inline indirect_array<_Tp>& + indirect_array<_Tp>::operator=(const indirect_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array, + _M_index); + return *this; + } + + template + inline void + indirect_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_index, _M_sz, __t); } + + template + inline void + indirect_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); } + + template + template + inline void + indirect_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const + { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ + template \ + inline void \ + indirect_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_index, _Array<_Tp>(__v), _M_sz); \ + } \ + \ + template \ + template \ + inline void \ + indirect_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_index, __e, _M_sz); \ + } + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _INDIRECT_ARRAY_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/invoke.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/invoke.h new file mode 100755 index 0000000..3ffcabb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/invoke.h @@ -0,0 +1,164 @@ +// Implementation of INVOKE -*- C++ -*- + +// Copyright (C) 2016-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/invoke.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _GLIBCXX_INVOKE_H +#define _GLIBCXX_INVOKE_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include // forward + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + + // Used by __invoke_impl instead of std::forward<_Tp> so that a + // reference_wrapper is converted to an lvalue-reference. + template::type> + constexpr _Up&& + __invfwd(typename remove_reference<_Tp>::type& __t) noexcept + { return static_cast<_Up&&>(__t); } + + template + constexpr _Res + __invoke_impl(__invoke_other, _Fn&& __f, _Args&&... __args) + { return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); } + + template + constexpr _Res + __invoke_impl(__invoke_memfun_ref, _MemFun&& __f, _Tp&& __t, + _Args&&... __args) + { return (__invfwd<_Tp>(__t).*__f)(std::forward<_Args>(__args)...); } + + template + constexpr _Res + __invoke_impl(__invoke_memfun_deref, _MemFun&& __f, _Tp&& __t, + _Args&&... __args) + { + return ((*std::forward<_Tp>(__t)).*__f)(std::forward<_Args>(__args)...); + } + + template + constexpr _Res + __invoke_impl(__invoke_memobj_ref, _MemPtr&& __f, _Tp&& __t) + { return __invfwd<_Tp>(__t).*__f; } + + template + constexpr _Res + __invoke_impl(__invoke_memobj_deref, _MemPtr&& __f, _Tp&& __t) + { return (*std::forward<_Tp>(__t)).*__f; } + + /// Invoke a callable object. + template + constexpr typename __invoke_result<_Callable, _Args...>::type + __invoke(_Callable&& __fn, _Args&&... __args) + noexcept(__is_nothrow_invocable<_Callable, _Args...>::value) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } + +#if __cplusplus >= 201703L + // INVOKE: Invoke a callable object and convert the result to R. + template + constexpr enable_if_t, _Res> + __invoke_r(_Callable&& __fn, _Args&&... __args) + noexcept(is_nothrow_invocable_r_v<_Res, _Callable, _Args...>) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + if constexpr (is_void_v<_Res>) + std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + else + return std::__invoke_impl<__type>(__tag{}, + std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } +#else // C++11 + template + using __can_invoke_as_void = __enable_if_t< + __and_, __is_invocable<_Callable, _Args...>>::value, + _Res + >; + + template + using __can_invoke_as_nonvoid = __enable_if_t< + __and_<__not_>, + is_convertible::type, + _Res> + >::value, + _Res + >; + + // INVOKE: Invoke a callable object and convert the result to R. + template + constexpr __can_invoke_as_nonvoid<_Res, _Callable, _Args...> + __invoke_r(_Callable&& __fn, _Args&&... __args) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } + + // INVOKE when R is cv void + template + _GLIBCXX14_CONSTEXPR __can_invoke_as_void<_Res, _Callable, _Args...> + __invoke_r(_Callable&& __fn, _Args&&... __args) + { + using __result = __invoke_result<_Callable, _Args...>; + using __type = typename __result::type; + using __tag = typename __result::__invoke_type; + std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), + std::forward<_Args>(__args)...); + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_INVOKE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ios_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ios_base.h new file mode 100755 index 0000000..d6626d4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ios_base.h @@ -0,0 +1,1109 @@ +// Iostreams base classes -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ios_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ios} + */ + +// +// ISO C++ 14882: 27.4 Iostreams base classes +// + +#ifndef _IOS_BASE_H +#define _IOS_BASE_H 1 + +#pragma GCC system_header + +#include +#include +#include + +#if __cplusplus < 201103L +# include +#else +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The following definitions of bitmask types are enums, not ints, + // as permitted (but not required) in the standard, in order to provide + // better type safety in iostream calls. A side effect is that in C++98 + // expressions involving them are not compile-time constants. + enum _Ios_Fmtflags + { + _S_boolalpha = 1L << 0, + _S_dec = 1L << 1, + _S_fixed = 1L << 2, + _S_hex = 1L << 3, + _S_internal = 1L << 4, + _S_left = 1L << 5, + _S_oct = 1L << 6, + _S_right = 1L << 7, + _S_scientific = 1L << 8, + _S_showbase = 1L << 9, + _S_showpoint = 1L << 10, + _S_showpos = 1L << 11, + _S_skipws = 1L << 12, + _S_unitbuf = 1L << 13, + _S_uppercase = 1L << 14, + _S_adjustfield = _S_left | _S_right | _S_internal, + _S_basefield = _S_dec | _S_oct | _S_hex, + _S_floatfield = _S_scientific | _S_fixed, + _S_ios_fmtflags_end = 1L << 16, + _S_ios_fmtflags_max = __INT_MAX__, + _S_ios_fmtflags_min = ~__INT_MAX__ + }; + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) + { return _Ios_Fmtflags(static_cast(__a) & static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b) + { return _Ios_Fmtflags(static_cast(__a) | static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) + { return _Ios_Fmtflags(static_cast(__a) ^ static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags + operator~(_Ios_Fmtflags __a) + { return _Ios_Fmtflags(~static_cast(__a)); } + + inline const _Ios_Fmtflags& + operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) + { return __a = __a | __b; } + + inline const _Ios_Fmtflags& + operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) + { return __a = __a & __b; } + + inline const _Ios_Fmtflags& + operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) + { return __a = __a ^ __b; } + + + enum _Ios_Openmode + { + _S_app = 1L << 0, + _S_ate = 1L << 1, + _S_bin = 1L << 2, + _S_in = 1L << 3, + _S_out = 1L << 4, + _S_trunc = 1L << 5, + _S_ios_openmode_end = 1L << 16, + _S_ios_openmode_max = __INT_MAX__, + _S_ios_openmode_min = ~__INT_MAX__ + }; + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator&(_Ios_Openmode __a, _Ios_Openmode __b) + { return _Ios_Openmode(static_cast(__a) & static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator|(_Ios_Openmode __a, _Ios_Openmode __b) + { return _Ios_Openmode(static_cast(__a) | static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator^(_Ios_Openmode __a, _Ios_Openmode __b) + { return _Ios_Openmode(static_cast(__a) ^ static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Openmode + operator~(_Ios_Openmode __a) + { return _Ios_Openmode(~static_cast(__a)); } + + inline const _Ios_Openmode& + operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) + { return __a = __a | __b; } + + inline const _Ios_Openmode& + operator&=(_Ios_Openmode& __a, _Ios_Openmode __b) + { return __a = __a & __b; } + + inline const _Ios_Openmode& + operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) + { return __a = __a ^ __b; } + + + enum _Ios_Iostate + { + _S_goodbit = 0, + _S_badbit = 1L << 0, + _S_eofbit = 1L << 1, + _S_failbit = 1L << 2, + _S_ios_iostate_end = 1L << 16, + _S_ios_iostate_max = __INT_MAX__, + _S_ios_iostate_min = ~__INT_MAX__ + }; + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator&(_Ios_Iostate __a, _Ios_Iostate __b) + { return _Ios_Iostate(static_cast(__a) & static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator|(_Ios_Iostate __a, _Ios_Iostate __b) + { return _Ios_Iostate(static_cast(__a) | static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator^(_Ios_Iostate __a, _Ios_Iostate __b) + { return _Ios_Iostate(static_cast(__a) ^ static_cast(__b)); } + + inline _GLIBCXX_CONSTEXPR _Ios_Iostate + operator~(_Ios_Iostate __a) + { return _Ios_Iostate(~static_cast(__a)); } + + inline const _Ios_Iostate& + operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) + { return __a = __a | __b; } + + inline const _Ios_Iostate& + operator&=(_Ios_Iostate& __a, _Ios_Iostate __b) + { return __a = __a & __b; } + + inline const _Ios_Iostate& + operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) + { return __a = __a ^ __b; } + + + enum _Ios_Seekdir + { + _S_beg = 0, + _S_cur = _GLIBCXX_STDIO_SEEK_CUR, + _S_end = _GLIBCXX_STDIO_SEEK_END, + _S_ios_seekdir_end = 1L << 16 + }; + +#if __cplusplus >= 201103L + /// I/O error code + enum class io_errc { stream = 1 }; + + template <> struct is_error_code_enum : public true_type { }; + + const error_category& iostream_category() noexcept; + + inline error_code + make_error_code(io_errc __e) noexcept + { return error_code(static_cast(__e), iostream_category()); } + + inline error_condition + make_error_condition(io_errc __e) noexcept + { return error_condition(static_cast(__e), iostream_category()); } +#endif + + // 27.4.2 Class ios_base + /** + * @brief The base of the I/O class hierarchy. + * @ingroup io + * + * This class defines everything that can be defined about I/O that does + * not depend on the type of characters being input or output. Most + * people will only see @c ios_base when they need to specify the full + * name of the various I/O flags (e.g., the openmodes). + */ + class ios_base + { +#if _GLIBCXX_USE_CXX11_ABI +#if __cplusplus < 201103L + // Type that is layout-compatible with std::system_error + struct system_error : std::runtime_error + { + // Type that is layout-compatible with std::error_code + struct error_code + { + error_code() { } + private: + int _M_value; + const void* _M_cat; + } _M_code; + }; +#endif +#endif + public: + + /** + * @brief These are thrown to indicate problems with io. + * @ingroup exceptions + * + * 27.4.2.1.1 Class ios_base::failure + */ +#if _GLIBCXX_USE_CXX11_ABI + class _GLIBCXX_ABI_TAG_CXX11 failure : public system_error + { + public: + explicit + failure(const string& __str); + +#if __cplusplus >= 201103L + explicit + failure(const string&, const error_code&); + + explicit + failure(const char*, const error_code& = io_errc::stream); +#endif + + virtual + ~failure() throw(); + + virtual const char* + what() const throw(); + }; +#else + class failure : public exception + { + public: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 48. Use of non-existent exception constructor + explicit + failure(const string& __str) throw(); + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Vague-Linkage.html + virtual + ~failure() throw(); + + virtual const char* + what() const throw(); + +#if __cplusplus >= 201103L + // Define the new members required by C++11, + // even though the error_code cannot be stored. + + explicit + failure(const string& __s, const error_code&) noexcept + : failure(__s) + { } + + explicit + failure(const char* __s, const error_code& = error_code{}) + : failure(string(__s)) + { } + + // Stand-in for system_error::code() but returning by value. + error_code code() const noexcept { return error_code{}; } +#endif + + private: + string _M_msg; + }; +#endif + + // 27.4.2.1.2 Type ios_base::fmtflags + /** + * @brief This is a bitmask type. + * + * @c @a _Ios_Fmtflags is implementation-defined, but it is valid to + * perform bitwise operations on these values and expect the Right + * Thing to happen. Defined objects of type fmtflags are: + * - boolalpha + * - dec + * - fixed + * - hex + * - internal + * - left + * - oct + * - right + * - scientific + * - showbase + * - showpoint + * - showpos + * - skipws + * - unitbuf + * - uppercase + * - adjustfield + * - basefield + * - floatfield + */ + typedef _Ios_Fmtflags fmtflags; + + /// Insert/extract @c bool in alphabetic rather than numeric format. + static const fmtflags boolalpha = _S_boolalpha; + + /// Converts integer input or generates integer output in decimal base. + static const fmtflags dec = _S_dec; + + /// Generate floating-point output in fixed-point notation. + static const fmtflags fixed = _S_fixed; + + /// Converts integer input or generates integer output in hexadecimal base. + static const fmtflags hex = _S_hex; + + /// Adds fill characters at a designated internal point in certain + /// generated output, or identical to @c right if no such point is + /// designated. + static const fmtflags internal = _S_internal; + + /// Adds fill characters on the right (final positions) of certain + /// generated output. (I.e., the thing you print is flush left.) + static const fmtflags left = _S_left; + + /// Converts integer input or generates integer output in octal base. + static const fmtflags oct = _S_oct; + + /// Adds fill characters on the left (initial positions) of certain + /// generated output. (I.e., the thing you print is flush right.) + static const fmtflags right = _S_right; + + /// Generates floating-point output in scientific notation. + static const fmtflags scientific = _S_scientific; + + /// Generates a prefix indicating the numeric base of generated integer + /// output. + static const fmtflags showbase = _S_showbase; + + /// Generates a decimal-point character unconditionally in generated + /// floating-point output. + static const fmtflags showpoint = _S_showpoint; + + /// Generates a + sign in non-negative generated numeric output. + static const fmtflags showpos = _S_showpos; + + /// Skips leading white space before certain input operations. + static const fmtflags skipws = _S_skipws; + + /// Flushes output after each output operation. + static const fmtflags unitbuf = _S_unitbuf; + + /// Replaces certain lowercase letters with their uppercase equivalents + /// in generated output. + static const fmtflags uppercase = _S_uppercase; + + /// A mask of left|right|internal. Useful for the 2-arg form of @c setf. + static const fmtflags adjustfield = _S_adjustfield; + + /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. + static const fmtflags basefield = _S_basefield; + + /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf. + static const fmtflags floatfield = _S_floatfield; + + // 27.4.2.1.3 Type ios_base::iostate + /** + * @brief This is a bitmask type. + * + * @c @a _Ios_Iostate is implementation-defined, but it is valid to + * perform bitwise operations on these values and expect the Right + * Thing to happen. Defined objects of type iostate are: + * - badbit + * - eofbit + * - failbit + * - goodbit + */ + typedef _Ios_Iostate iostate; + + /// Indicates a loss of integrity in an input or output sequence (such + /// as an irrecoverable read error from a file). + static const iostate badbit = _S_badbit; + + /// Indicates that an input operation reached the end of an input sequence. + static const iostate eofbit = _S_eofbit; + + /// Indicates that an input operation failed to read the expected + /// characters, or that an output operation failed to generate the + /// desired characters. + static const iostate failbit = _S_failbit; + + /// Indicates all is well. + static const iostate goodbit = _S_goodbit; + + // 27.4.2.1.4 Type ios_base::openmode + /** + * @brief This is a bitmask type. + * + * @c @a _Ios_Openmode is implementation-defined, but it is valid to + * perform bitwise operations on these values and expect the Right + * Thing to happen. Defined objects of type openmode are: + * - app + * - ate + * - binary + * - in + * - out + * - trunc + */ + typedef _Ios_Openmode openmode; + + /// Seek to end before each write. + static const openmode app = _S_app; + + /// Open and seek to end immediately after opening. + static const openmode ate = _S_ate; + + /// Perform input and output in binary mode (as opposed to text mode). + /// This is probably not what you think it is; see + /// https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary + static const openmode binary = _S_bin; + + /// Open for input. Default for @c ifstream and fstream. + static const openmode in = _S_in; + + /// Open for output. Default for @c ofstream and fstream. + static const openmode out = _S_out; + + /// Truncate an existing stream when opening. Default for @c ofstream. + static const openmode trunc = _S_trunc; + + // 27.4.2.1.5 Type ios_base::seekdir + /** + * @brief This is an enumerated type. + * + * @c @a _Ios_Seekdir is implementation-defined. Defined values + * of type seekdir are: + * - beg + * - cur, equivalent to @c SEEK_CUR in the C standard library. + * - end, equivalent to @c SEEK_END in the C standard library. + */ + typedef _Ios_Seekdir seekdir; + + /// Request a seek relative to the beginning of the stream. + static const seekdir beg = _S_beg; + + /// Request a seek relative to the current position within the sequence. + static const seekdir cur = _S_cur; + + /// Request a seek relative to the current end of the sequence. + static const seekdir end = _S_end; + +#if __cplusplus <= 201402L + // Annex D.6 (removed in C++17) + typedef int io_state + _GLIBCXX_DEPRECATED_SUGGEST("std::iostate"); + typedef int open_mode + _GLIBCXX_DEPRECATED_SUGGEST("std::openmode"); + typedef int seek_dir + _GLIBCXX_DEPRECATED_SUGGEST("std::seekdir"); + + typedef std::streampos streampos + _GLIBCXX_DEPRECATED_SUGGEST("std::streampos"); + typedef std::streamoff streamoff + _GLIBCXX_DEPRECATED_SUGGEST("std::streamoff"); +#endif + + // Callbacks; + /** + * @brief The set of events that may be passed to an event callback. + * + * erase_event is used during ~ios() and copyfmt(). imbue_event is used + * during imbue(). copyfmt_event is used during copyfmt(). + */ + enum event + { + erase_event, + imbue_event, + copyfmt_event + }; + + /** + * @brief The type of an event callback function. + * @param __e One of the members of the event enum. + * @param __b Reference to the ios_base object. + * @param __i The integer provided when the callback was registered. + * + * Event callbacks are user defined functions that get called during + * several ios_base and basic_ios functions, specifically imbue(), + * copyfmt(), and ~ios(). + */ + typedef void (*event_callback) (event __e, ios_base& __b, int __i); + + /** + * @brief Add the callback __fn with parameter __index. + * @param __fn The function to add. + * @param __index The integer to pass to the function when invoked. + * + * Registers a function as an event callback with an integer parameter to + * be passed to the function when invoked. Multiple copies of the + * function are allowed. If there are multiple callbacks, they are + * invoked in the order they were registered. + */ + void + register_callback(event_callback __fn, int __index); + + protected: + streamsize _M_precision; + streamsize _M_width; + fmtflags _M_flags; + iostate _M_exception; + iostate _M_streambuf_state; + + // 27.4.2.6 Members for callbacks + // 27.4.2.6 ios_base callbacks + struct _Callback_list + { + // Data Members + _Callback_list* _M_next; + ios_base::event_callback _M_fn; + int _M_index; + _Atomic_word _M_refcount; // 0 means one reference. + + _Callback_list(ios_base::event_callback __fn, int __index, + _Callback_list* __cb) + : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } + + void + _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } + + // 0 => OK to delete. + int + _M_remove_reference() + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); + int __res = __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1); + if (__res == 0) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); + } + return __res; + } + }; + + _Callback_list* _M_callbacks; + + void + _M_call_callbacks(event __ev) throw(); + + void + _M_dispose_callbacks(void) throw(); + + // 27.4.2.5 Members for iword/pword storage + struct _Words + { + void* _M_pword; + long _M_iword; + _Words() : _M_pword(0), _M_iword(0) { } + }; + + // Only for failed iword/pword calls. + _Words _M_word_zero; + + // Guaranteed storage. + // The first 5 iword and pword slots are reserved for internal use. + enum { _S_local_word_size = 8 }; + _Words _M_local_word[_S_local_word_size]; + + // Allocated storage. + int _M_word_size; + _Words* _M_word; + + _Words& + _M_grow_words(int __index, bool __iword); + + // Members for locale and locale caching. + locale _M_ios_locale; + + void + _M_init() throw(); + + public: + + // 27.4.2.1.6 Class ios_base::Init + // Used to initialize standard streams. In theory, g++ could use + // -finit-priority to order this stuff correctly without going + // through these machinations. + class Init + { + friend class ios_base; + public: + Init(); + ~Init(); + +#if __cplusplus >= 201103L + Init(const Init&) = default; + Init& operator=(const Init&) = default; +#endif + + private: + static _Atomic_word _S_refcount; + static bool _S_synced_with_stdio; + }; + + // [27.4.2.2] fmtflags state functions + /** + * @brief Access to format flags. + * @return The format control flags for both input and output. + */ + fmtflags + flags() const + { return _M_flags; } + + /** + * @brief Setting new format flags all at once. + * @param __fmtfl The new flags to set. + * @return The previous format control flags. + * + * This function overwrites all the format flags with @a __fmtfl. + */ + fmtflags + flags(fmtflags __fmtfl) + { + fmtflags __old = _M_flags; + _M_flags = __fmtfl; + return __old; + } + + /** + * @brief Setting new format flags. + * @param __fmtfl Additional flags to set. + * @return The previous format control flags. + * + * This function sets additional flags in format control. Flags that + * were previously set remain set. + */ + fmtflags + setf(fmtflags __fmtfl) + { + fmtflags __old = _M_flags; + _M_flags |= __fmtfl; + return __old; + } + + /** + * @brief Setting new format flags. + * @param __fmtfl Additional flags to set. + * @param __mask The flags mask for @a fmtfl. + * @return The previous format control flags. + * + * This function clears @a mask in the format flags, then sets + * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield. + */ + fmtflags + setf(fmtflags __fmtfl, fmtflags __mask) + { + fmtflags __old = _M_flags; + _M_flags &= ~__mask; + _M_flags |= (__fmtfl & __mask); + return __old; + } + + /** + * @brief Clearing format flags. + * @param __mask The flags to unset. + * + * This function clears @a __mask in the format flags. + */ + void + unsetf(fmtflags __mask) + { _M_flags &= ~__mask; } + + /** + * @brief Flags access. + * @return The precision to generate on certain output operations. + * + * Be careful if you try to give a definition of @a precision here; see + * DR 189. + */ + streamsize + precision() const + { return _M_precision; } + + /** + * @brief Changing flags. + * @param __prec The new precision value. + * @return The previous value of precision(). + */ + streamsize + precision(streamsize __prec) + { + streamsize __old = _M_precision; + _M_precision = __prec; + return __old; + } + + /** + * @brief Flags access. + * @return The minimum field width to generate on output operations. + * + * Minimum field width refers to the number of characters. + */ + streamsize + width() const + { return _M_width; } + + /** + * @brief Changing flags. + * @param __wide The new width value. + * @return The previous value of width(). + */ + streamsize + width(streamsize __wide) + { + streamsize __old = _M_width; + _M_width = __wide; + return __old; + } + + // [27.4.2.4] ios_base static members + /** + * @brief Interaction with the standard C I/O objects. + * @param __sync Whether to synchronize or not. + * @return True if the standard streams were previously synchronized. + * + * The synchronization referred to is @e only that between the standard + * C facilities (e.g., stdout) and the standard C++ objects (e.g., + * cout). User-declared streams are unaffected. See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary + */ + static bool + sync_with_stdio(bool __sync = true); + + // [27.4.2.3] ios_base locale functions + /** + * @brief Setting a new locale. + * @param __loc The new locale. + * @return The previous locale. + * + * Sets the new locale for this stream, and then invokes each callback + * with imbue_event. + */ + locale + imbue(const locale& __loc) throw(); + + /** + * @brief Locale access + * @return A copy of the current locale. + * + * If @c imbue(loc) has previously been called, then this function + * returns @c loc. Otherwise, it returns a copy of @c std::locale(), + * the global C++ locale. + */ + locale + getloc() const + { return _M_ios_locale; } + + /** + * @brief Locale access + * @return A reference to the current locale. + * + * Like getloc above, but returns a reference instead of + * generating a copy. + */ + const locale& + _M_getloc() const + { return _M_ios_locale; } + + // [27.4.2.5] ios_base storage functions + /** + * @brief Access to unique indices. + * @return An integer different from all previous calls. + * + * This function returns a unique integer every time it is called. It + * can be used for any purpose, but is primarily intended to be a unique + * index for the iword and pword functions. The expectation is that an + * application calls xalloc in order to obtain an index in the iword and + * pword arrays that can be used without fear of conflict. + * + * The implementation maintains a static variable that is incremented and + * returned on each invocation. xalloc is guaranteed to return an index + * that is safe to use in the iword and pword arrays. + */ + static int + xalloc() throw(); + + /** + * @brief Access to integer array. + * @param __ix Index into the array. + * @return A reference to an integer associated with the index. + * + * The iword function provides access to an array of integers that can be + * used for any purpose. The array grows as required to hold the + * supplied index. All integers in the array are initialized to 0. + * + * The implementation reserves several indices. You should use xalloc to + * obtain an index that is safe to use. Also note that since the array + * can grow dynamically, it is not safe to hold onto the reference. + */ + long& + iword(int __ix) + { + _Words& __word = ((unsigned)__ix < (unsigned)_M_word_size) + ? _M_word[__ix] : _M_grow_words(__ix, true); + return __word._M_iword; + } + + /** + * @brief Access to void pointer array. + * @param __ix Index into the array. + * @return A reference to a void* associated with the index. + * + * The pword function provides access to an array of pointers that can be + * used for any purpose. The array grows as required to hold the + * supplied index. All pointers in the array are initialized to 0. + * + * The implementation reserves several indices. You should use xalloc to + * obtain an index that is safe to use. Also note that since the array + * can grow dynamically, it is not safe to hold onto the reference. + */ + void*& + pword(int __ix) + { + _Words& __word = ((unsigned)__ix < (unsigned)_M_word_size) + ? _M_word[__ix] : _M_grow_words(__ix, false); + return __word._M_pword; + } + + // Destructor + /** + * Invokes each callback with erase_event. Destroys local storage. + * + * Note that the ios_base object for the standard streams never gets + * destroyed. As a result, any callbacks registered with the standard + * streams will not get invoked with erase_event (unless copyfmt is + * used). + */ + virtual ~ios_base(); + + protected: + ios_base() throw (); + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 50. Copy constructor and assignment operator of ios_base + private: + ios_base(const ios_base&); + + ios_base& + operator=(const ios_base&); +#else + public: + ios_base(const ios_base&) = delete; + + ios_base& + operator=(const ios_base&) = delete; + + protected: + void + _M_move(ios_base&) noexcept; + + void + _M_swap(ios_base& __rhs) noexcept; +#endif + }; + + // [27.4.5.1] fmtflags manipulators + /// Calls base.setf(ios_base::boolalpha). + inline ios_base& + boolalpha(ios_base& __base) + { + __base.setf(ios_base::boolalpha); + return __base; + } + + /// Calls base.unsetf(ios_base::boolalpha). + inline ios_base& + noboolalpha(ios_base& __base) + { + __base.unsetf(ios_base::boolalpha); + return __base; + } + + /// Calls base.setf(ios_base::showbase). + inline ios_base& + showbase(ios_base& __base) + { + __base.setf(ios_base::showbase); + return __base; + } + + /// Calls base.unsetf(ios_base::showbase). + inline ios_base& + noshowbase(ios_base& __base) + { + __base.unsetf(ios_base::showbase); + return __base; + } + + /// Calls base.setf(ios_base::showpoint). + inline ios_base& + showpoint(ios_base& __base) + { + __base.setf(ios_base::showpoint); + return __base; + } + + /// Calls base.unsetf(ios_base::showpoint). + inline ios_base& + noshowpoint(ios_base& __base) + { + __base.unsetf(ios_base::showpoint); + return __base; + } + + /// Calls base.setf(ios_base::showpos). + inline ios_base& + showpos(ios_base& __base) + { + __base.setf(ios_base::showpos); + return __base; + } + + /// Calls base.unsetf(ios_base::showpos). + inline ios_base& + noshowpos(ios_base& __base) + { + __base.unsetf(ios_base::showpos); + return __base; + } + + /// Calls base.setf(ios_base::skipws). + inline ios_base& + skipws(ios_base& __base) + { + __base.setf(ios_base::skipws); + return __base; + } + + /// Calls base.unsetf(ios_base::skipws). + inline ios_base& + noskipws(ios_base& __base) + { + __base.unsetf(ios_base::skipws); + return __base; + } + + /// Calls base.setf(ios_base::uppercase). + inline ios_base& + uppercase(ios_base& __base) + { + __base.setf(ios_base::uppercase); + return __base; + } + + /// Calls base.unsetf(ios_base::uppercase). + inline ios_base& + nouppercase(ios_base& __base) + { + __base.unsetf(ios_base::uppercase); + return __base; + } + + /// Calls base.setf(ios_base::unitbuf). + inline ios_base& + unitbuf(ios_base& __base) + { + __base.setf(ios_base::unitbuf); + return __base; + } + + /// Calls base.unsetf(ios_base::unitbuf). + inline ios_base& + nounitbuf(ios_base& __base) + { + __base.unsetf(ios_base::unitbuf); + return __base; + } + + // [27.4.5.2] adjustfield manipulators + /// Calls base.setf(ios_base::internal, ios_base::adjustfield). + inline ios_base& + internal(ios_base& __base) + { + __base.setf(ios_base::internal, ios_base::adjustfield); + return __base; + } + + /// Calls base.setf(ios_base::left, ios_base::adjustfield). + inline ios_base& + left(ios_base& __base) + { + __base.setf(ios_base::left, ios_base::adjustfield); + return __base; + } + + /// Calls base.setf(ios_base::right, ios_base::adjustfield). + inline ios_base& + right(ios_base& __base) + { + __base.setf(ios_base::right, ios_base::adjustfield); + return __base; + } + + // [27.4.5.3] basefield manipulators + /// Calls base.setf(ios_base::dec, ios_base::basefield). + inline ios_base& + dec(ios_base& __base) + { + __base.setf(ios_base::dec, ios_base::basefield); + return __base; + } + + /// Calls base.setf(ios_base::hex, ios_base::basefield). + inline ios_base& + hex(ios_base& __base) + { + __base.setf(ios_base::hex, ios_base::basefield); + return __base; + } + + /// Calls base.setf(ios_base::oct, ios_base::basefield). + inline ios_base& + oct(ios_base& __base) + { + __base.setf(ios_base::oct, ios_base::basefield); + return __base; + } + + // [27.4.5.4] floatfield manipulators + /// Calls base.setf(ios_base::fixed, ios_base::floatfield). + inline ios_base& + fixed(ios_base& __base) + { + __base.setf(ios_base::fixed, ios_base::floatfield); + return __base; + } + + /// Calls base.setf(ios_base::scientific, ios_base::floatfield). + inline ios_base& + scientific(ios_base& __base) + { + __base.setf(ios_base::scientific, ios_base::floatfield); + return __base; + } + +#if __cplusplus >= 201103L + // New C++11 floatfield manipulators + + /// Calls + /// base.setf(ios_base::fixed|ios_base::scientific, ios_base::floatfield) + inline ios_base& + hexfloat(ios_base& __base) + { + __base.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); + return __base; + } + + /// Calls @c base.unsetf(ios_base::floatfield) + inline ios_base& + defaultfloat(ios_base& __base) + { + __base.unsetf(ios_base::floatfield); + return __base; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _IOS_BASE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/istream.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/istream.tcc new file mode 100755 index 0000000..1b046be --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/istream.tcc @@ -0,0 +1,1126 @@ +// istream classes -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/istream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{istream} + */ + +// +// ISO C++ 14882: 27.6.1 Input streams +// + +#ifndef _ISTREAM_TCC +#define _ISTREAM_TCC 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + basic_istream<_CharT, _Traits>::sentry:: + sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false) + { + ios_base::iostate __err = ios_base::goodbit; + if (__in.good()) + __try + { + if (__in.tie()) + __in.tie()->flush(); + if (!__noskip && bool(__in.flags() & ios_base::skipws)) + { + const __int_type __eof = traits_type::eof(); + __streambuf_type* __sb = __in.rdbuf(); + __int_type __c = __sb->sgetc(); + + const __ctype_type& __ct = __check_facet(__in._M_ctype); + while (!traits_type::eq_int_type(__c, __eof) + && __ct.is(ctype_base::space, + traits_type::to_char_type(__c))) + __c = __sb->snextc(); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 195. Should basic_istream::sentry's constructor ever + // set eofbit? + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __in._M_setstate(ios_base::badbit); } + + if (__in.good() && __err == ios_base::goodbit) + _M_ok = true; + else + { + __err |= ios_base::failbit; + __in.setstate(__err); + } + } + + template + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + _M_extract(_ValueT& __v) + { + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __v); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + operator>>(short& __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 118. basic_istream uses nonexistent num_get member functions. + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + long __l; + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __l); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 696. istream::operator>>(int&) broken. + if (__l < __gnu_cxx::__numeric_traits::__min) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__min; + } + else if (__l > __gnu_cxx::__numeric_traits::__max) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__max; + } + else + __n = short(__l); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + operator>>(int& __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 118. basic_istream uses nonexistent num_get member functions. + sentry __cerb(*this, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + long __l; + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __l); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 696. istream::operator>>(int&) broken. + if (__l < __gnu_cxx::__numeric_traits::__min) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__min; + } + else if (__l > __gnu_cxx::__numeric_traits::__max) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits::__max; + } + else + __n = int(__l); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + operator>>(__streambuf_type* __sbout) + { + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, false); + if (__cerb && __sbout) + { + __try + { + bool __ineof; + if (!__copy_streambufs_eof(this->rdbuf(), __sbout, __ineof)) + __err |= ios_base::failbit; + if (__ineof) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::failbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::failbit); } + } + else if (!__sbout) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + typename basic_istream<_CharT, _Traits>::int_type + basic_istream<_CharT, _Traits>:: + get(void) + { + const int_type __eof = traits_type::eof(); + int_type __c = __eof; + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + __c = this->rdbuf()->sbumpc(); + // 27.6.1.1 paragraph 3 + if (!traits_type::eq_int_type(__c, __eof)) + _M_gcount = 1; + else + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return __c; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + get(char_type& __c) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __cb = this->rdbuf()->sbumpc(); + // 27.6.1.1 paragraph 3 + if (!traits_type::eq_int_type(__cb, traits_type::eof())) + { + _M_gcount = 1; + __c = traits_type::to_char_type(__cb); + } + else + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + get(char_type* __s, streamsize __n, char_type __delim) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + while (_M_gcount + 1 < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim)) + { + *__s++ = traits_type::to_char_type(__c); + ++_M_gcount; + __c = __sb->snextc(); + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 243. get and getline when sentry reports failure. + if (__n > 0) + *__s = char_type(); + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + get(__streambuf_type& __sb, char_type __delim) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __this_sb = this->rdbuf(); + int_type __c = __this_sb->sgetc(); + char_type __c2 = traits_type::to_char_type(__c); + unsigned long long __gcount = 0; + + while (!traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim) + && !traits_type::eq_int_type(__sb.sputc(__c2), __eof)) + { + ++__gcount; + __c = __this_sb->snextc(); + __c2 = traits_type::to_char_type(__c); + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3464. istream::gcount() can overflow + if (__gcount <= __gnu_cxx::__numeric_traits::__max) + _M_gcount = __gcount; + else + _M_gcount = __gnu_cxx::__numeric_traits::__max; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + getline(char_type* __s, streamsize __n, char_type __delim) + { + _M_gcount = 0; + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + const int_type __idelim = traits_type::to_int_type(__delim); + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + while (_M_gcount + 1 < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __idelim)) + { + *__s++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); + ++_M_gcount; + } + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + if (traits_type::eq_int_type(__c, __idelim)) + { + __sb->sbumpc(); + ++_M_gcount; + } + else + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 243. get and getline when sentry reports failure. + if (__n > 0) + *__s = char_type(); + if (!_M_gcount) + __err |= ios_base::failbit; + if (__err) + this->setstate(__err); + return *this; + } + + // We provide three overloads, since the first two are much simpler + // than the general case. Also, the latter two can thus adopt the + // same "batchy" strategy used by getline above. + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(void) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + + if (traits_type::eq_int_type(__sb->sbumpc(), __eof)) + __err |= ios_base::eofbit; + else + _M_gcount = 1; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb && __n > 0) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + // N.B. On LFS-enabled platforms streamsize is still 32 bits + // wide: if we want to implement the standard mandated behavior + // for n == max() (see 27.6.1.3/24) we are at risk of signed + // integer overflow: thus these contortions. Also note that, + // by definition, when more than 2G chars are actually ignored, + // _M_gcount (the return value of gcount, that is) cannot be + // really correct, being unavoidably too small. + bool __large_ignore = false; + while (true) + { + while (_M_gcount < __n + && !traits_type::eq_int_type(__c, __eof)) + { + ++_M_gcount; + __c = __sb->snextc(); + } + if (__n == __gnu_cxx::__numeric_traits::__max + && !traits_type::eq_int_type(__c, __eof)) + { + _M_gcount = + __gnu_cxx::__numeric_traits::__min; + __large_ignore = true; + } + else + break; + } + + if (__n == __gnu_cxx::__numeric_traits::__max) + { + if (__large_ignore) + _M_gcount = __gnu_cxx::__numeric_traits::__max; + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + else if (_M_gcount < __n) + { + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + ignore(streamsize __n, int_type __delim) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb && __n > 0) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); + + // See comment above. + bool __large_ignore = false; + while (true) + { + while (_M_gcount < __n + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __delim)) + { + ++_M_gcount; + __c = __sb->snextc(); + } + if (__n == __gnu_cxx::__numeric_traits::__max + && !traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __delim)) + { + _M_gcount = + __gnu_cxx::__numeric_traits::__min; + __large_ignore = true; + } + else + break; + } + + if (__n == __gnu_cxx::__numeric_traits::__max) + { + if (__large_ignore) + _M_gcount = __gnu_cxx::__numeric_traits::__max; + + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + if (_M_gcount != __n) + ++_M_gcount; + __sb->sbumpc(); + } + } + else if (_M_gcount < __n) // implies __c == __delim or EOF + { + if (traits_type::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + else + { + ++_M_gcount; + __sb->sbumpc(); + } + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + typename basic_istream<_CharT, _Traits>::int_type + basic_istream<_CharT, _Traits>:: + peek(void) + { + int_type __c = traits_type::eof(); + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + __c = this->rdbuf()->sgetc(); + if (traits_type::eq_int_type(__c, traits_type::eof())) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return __c; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + read(char_type* __s, streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + _M_gcount = this->rdbuf()->sgetn(__s, __n); + if (_M_gcount != __n) + __err |= (ios_base::eofbit | ios_base::failbit); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + streamsize + basic_istream<_CharT, _Traits>:: + readsome(char_type* __s, streamsize __n) + { + _M_gcount = 0; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + // Cannot compare int_type with streamsize generically. + const streamsize __num = this->rdbuf()->in_avail(); + if (__num > 0) + _M_gcount = this->rdbuf()->sgetn(__s, std::min(__num, __n)); + else if (__num == -1) + __err |= ios_base::eofbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return _M_gcount; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + putback(char_type __c) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 60. What is a formatted input function? + _M_gcount = 0; + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + if (!__sb + || traits_type::eq_int_type(__sb->sputbackc(__c), __eof)) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + unget(void) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 60. What is a formatted input function? + _M_gcount = 0; + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __eof = traits_type::eof(); + __streambuf_type* __sb = this->rdbuf(); + if (!__sb + || traits_type::eq_int_type(__sb->sungetc(), __eof)) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + int + basic_istream<_CharT, _Traits>:: + sync(void) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + int __ret = -1; + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + __streambuf_type* __sb = this->rdbuf(); + if (__sb) + { + if (__sb->pubsync() == -1) + __err |= ios_base::badbit; + else + __ret = 0; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return __ret; + } + + template + typename basic_istream<_CharT, _Traits>::pos_type + basic_istream<_CharT, _Traits>:: + tellg(void) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + pos_type __ret = pos_type(-1); + sentry __cerb(*this, true); + if (__cerb) + { + __try + { + if (!this->fail()) + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, + ios_base::in); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + return __ret; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + seekg(pos_type __pos) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekpos(__pos, + ios_base::in); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_istream<_CharT, _Traits>& + basic_istream<_CharT, _Traits>:: + seekg(off_type __off, ios_base::seekdir __dir) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR60. Do not change _M_gcount. + // Clear eofbit per N3168. + this->clear(this->rdstate() & ~ios_base::eofbit); + sentry __cerb(*this, true); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir, + ios_base::in); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + // 27.6.1.2.3 Character extraction templates + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::int_type __int_type; + + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __int_type __cb = __in.rdbuf()->sbumpc(); + if (!_Traits::eq_int_type(__cb, _Traits::eof())) + __c = _Traits::to_char_type(__cb); + else + __err |= (ios_base::eofbit | ios_base::failbit); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __in._M_setstate(ios_base::badbit); } + if (__err) + __in.setstate(__err); + } + return __in; + } + + template + void + __istream_extract(basic_istream<_CharT, _Traits>& __in, _CharT* __s, + streamsize __num) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef typename _Traits::int_type int_type; + typedef _CharT char_type; + typedef ctype<_CharT> __ctype_type; + + streamsize __extracted = 0; + ios_base::iostate __err = ios_base::goodbit; + typename __istream_type::sentry __cerb(__in, false); + if (__cerb) + { + __try + { + // Figure out how many characters to extract. + streamsize __width = __in.width(); + if (0 < __width && __width < __num) + __num = __width; + + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + + const int_type __eof = _Traits::eof(); + __streambuf_type* __sb = __in.rdbuf(); + int_type __c = __sb->sgetc(); + + while (__extracted < __num - 1 + && !_Traits::eq_int_type(__c, __eof) + && !__ct.is(ctype_base::space, + _Traits::to_char_type(__c))) + { + *__s++ = _Traits::to_char_type(__c); + ++__extracted; + __c = __sb->snextc(); + } + + if (__extracted < __num - 1 + && _Traits::eq_int_type(__c, __eof)) + __err |= ios_base::eofbit; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 68. Extractors for char* should store null at end + *__s = char_type(); + __in.width(0); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __in._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __in._M_setstate(ios_base::badbit); } + } + if (!__extracted) + __err |= ios_base::failbit; + if (__err) + __in.setstate(__err); + } + + // 27.6.1.4 Standard basic_istream manipulators + template + basic_istream<_CharT, _Traits>& + ws(basic_istream<_CharT, _Traits>& __in) + { + typedef basic_istream<_CharT, _Traits> __istream_type; + typedef basic_streambuf<_CharT, _Traits> __streambuf_type; + typedef typename __istream_type::int_type __int_type; + typedef ctype<_CharT> __ctype_type; + + const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); + const __int_type __eof = _Traits::eof(); + __streambuf_type* __sb = __in.rdbuf(); + __int_type __c = __sb->sgetc(); + + while (!_Traits::eq_int_type(__c, __eof) + && __ct.is(ctype_base::space, _Traits::to_char_type(__c))) + __c = __sb->snextc(); + + if (_Traits::eq_int_type(__c, __eof)) + __in.setstate(ios_base::eofbit); + return __in; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_istream; + extern template istream& ws(istream&); + extern template istream& operator>>(istream&, char&); + extern template istream& operator>>(istream&, unsigned char&); + extern template istream& operator>>(istream&, signed char&); + + extern template istream& istream::_M_extract(unsigned short&); + extern template istream& istream::_M_extract(unsigned int&); + extern template istream& istream::_M_extract(long&); + extern template istream& istream::_M_extract(unsigned long&); + extern template istream& istream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template istream& istream::_M_extract(long long&); + extern template istream& istream::_M_extract(unsigned long long&); +#endif + extern template istream& istream::_M_extract(float&); + extern template istream& istream::_M_extract(double&); + extern template istream& istream::_M_extract(long double&); + extern template istream& istream::_M_extract(void*&); + + extern template class basic_iostream; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_istream; + extern template wistream& ws(wistream&); + extern template wistream& operator>>(wistream&, wchar_t&); + extern template void __istream_extract(wistream&, wchar_t*, streamsize); + + extern template wistream& wistream::_M_extract(unsigned short&); + extern template wistream& wistream::_M_extract(unsigned int&); + extern template wistream& wistream::_M_extract(long&); + extern template wistream& wistream::_M_extract(unsigned long&); + extern template wistream& wistream::_M_extract(bool&); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template wistream& wistream::_M_extract(long long&); + extern template wistream& wistream::_M_extract(unsigned long long&); +#endif + extern template wistream& wistream::_M_extract(float&); + extern template wistream& wistream::_M_extract(double&); + extern template wistream& wistream::_M_extract(long double&); + extern template wistream& wistream::_M_extract(void*&); + + extern template class basic_iostream; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/iterator_concepts.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/iterator_concepts.h new file mode 100755 index 0000000..11748e5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/iterator_concepts.h @@ -0,0 +1,987 @@ +// Concepts and traits for use with iterators -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/iterator_concepts.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _ITERATOR_CONCEPTS_H +#define _ITERATOR_CONCEPTS_H 1 + +#pragma GCC system_header + +#include +#include // to_address +#include // identity, ranges::less + +#if __cpp_lib_concepts +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct input_iterator_tag; + struct output_iterator_tag; + struct forward_iterator_tag; + struct bidirectional_iterator_tag; + struct random_access_iterator_tag; + struct contiguous_iterator_tag; + + template + struct iterator_traits; + + template requires is_object_v<_Tp> + struct iterator_traits<_Tp*>; + + template + struct __iterator_traits; + + namespace __detail + { + template + using __with_ref = _Tp&; + + template + concept __can_reference = requires { typename __with_ref<_Tp>; }; + + template + concept __dereferenceable = requires(_Tp& __t) + { + { *__t } -> __can_reference; + }; + } // namespace __detail + + template<__detail::__dereferenceable _Tp> + using iter_reference_t = decltype(*std::declval<_Tp&>()); + + namespace ranges + { + namespace __cust_imove + { + void iter_move(); + + template + concept __adl_imove + = (std::__detail::__class_or_enum>) + && requires(_Tp&& __t) { iter_move(static_cast<_Tp&&>(__t)); }; + + struct _IMove + { + private: + template + struct __result + { using type = iter_reference_t<_Tp>; }; + + template + requires __adl_imove<_Tp> + struct __result<_Tp> + { using type = decltype(iter_move(std::declval<_Tp>())); }; + + template + requires (!__adl_imove<_Tp>) + && is_lvalue_reference_v> + struct __result<_Tp> + { using type = remove_reference_t>&&; }; + + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_imove<_Tp>) + return noexcept(iter_move(std::declval<_Tp>())); + else + return noexcept(*std::declval<_Tp>()); + } + + public: + // The result type of iter_move(std::declval<_Tp>()) + template + using __type = typename __result<_Tp>::type; + + template + constexpr __type<_Tp> + operator()(_Tp&& __e) const + noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__adl_imove<_Tp>) + return iter_move(static_cast<_Tp&&>(__e)); + else if constexpr (is_lvalue_reference_v>) + return static_cast<__type<_Tp>>(*__e); + else + return *__e; + } + }; + } // namespace __cust_imove + + inline namespace __cust + { + inline constexpr __cust_imove::_IMove iter_move{}; + } // inline namespace __cust + } // namespace ranges + + template<__detail::__dereferenceable _Tp> + requires __detail:: + __can_reference> + using iter_rvalue_reference_t + = ranges::__cust_imove::_IMove::__type<_Tp&>; + + template struct incrementable_traits { }; + + template requires is_object_v<_Tp> + struct incrementable_traits<_Tp*> + { using difference_type = ptrdiff_t; }; + + template + struct incrementable_traits + : incrementable_traits<_Iter> { }; + + template requires requires { typename _Tp::difference_type; } + struct incrementable_traits<_Tp> + { using difference_type = typename _Tp::difference_type; }; + + template + requires (!requires { typename _Tp::difference_type; } + && requires(const _Tp& __a, const _Tp& __b) + { { __a - __b } -> integral; }) + struct incrementable_traits<_Tp> + { + using difference_type + = make_signed_t() - std::declval<_Tp>())>; + }; + +#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + // __int128 is incrementable even if !integral<__int128> + template<> + struct incrementable_traits<__int128> + { using difference_type = __int128; }; + + template<> + struct incrementable_traits + { using difference_type = __int128; }; +#endif + + namespace __detail + { + // An iterator such that iterator_traits<_Iter> names a specialization + // generated from the primary template. + template + concept __primary_traits_iter + = __is_base_of(__iterator_traits<_Iter, void>, iterator_traits<_Iter>); + + template + struct __iter_traits_impl + { using type = iterator_traits<_Iter>; }; + + template + requires __primary_traits_iter<_Iter> + struct __iter_traits_impl<_Iter, _Tp> + { using type = _Tp; }; + + // ITER_TRAITS + template + using __iter_traits = typename __iter_traits_impl<_Iter, _Tp>::type; + + template + using __iter_diff_t = typename + __iter_traits<_Tp, incrementable_traits<_Tp>>::difference_type; + } // namespace __detail + + template + using iter_difference_t = __detail::__iter_diff_t>; + + namespace __detail + { + template struct __cond_value_type { }; + + template requires is_object_v<_Tp> + struct __cond_value_type<_Tp> + { using value_type = remove_cv_t<_Tp>; }; + + template + concept __has_member_value_type + = requires { typename _Tp::value_type; }; + + template + concept __has_member_element_type + = requires { typename _Tp::element_type; }; + + } // namespace __detail + + template struct indirectly_readable_traits { }; + + template + struct indirectly_readable_traits<_Tp*> + : __detail::__cond_value_type<_Tp> + { }; + + template requires is_array_v<_Iter> + struct indirectly_readable_traits<_Iter> + { using value_type = remove_cv_t>; }; + + template + struct indirectly_readable_traits + : indirectly_readable_traits<_Iter> + { }; + + template<__detail::__has_member_value_type _Tp> + struct indirectly_readable_traits<_Tp> + : __detail::__cond_value_type + { }; + + template<__detail::__has_member_element_type _Tp> + struct indirectly_readable_traits<_Tp> + : __detail::__cond_value_type + { }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3446. indirectly_readable_traits ambiguity for types with both [...] + template<__detail::__has_member_value_type _Tp> + requires __detail::__has_member_element_type<_Tp> + && same_as, + remove_cv_t> + struct indirectly_readable_traits<_Tp> + : __detail::__cond_value_type + { }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3541. indirectly_readable_traits should be SFINAE-friendly for all types + template<__detail::__has_member_value_type _Tp> + requires __detail::__has_member_element_type<_Tp> + struct indirectly_readable_traits<_Tp> + { }; + + namespace __detail + { + template + using __iter_value_t = typename + __iter_traits<_Tp, indirectly_readable_traits<_Tp>>::value_type; + } // namespace __detail + + template + using iter_value_t = __detail::__iter_value_t>; + + namespace __detail + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3420. cpp17-iterator should check [type] looks like an iterator first + template + concept __cpp17_iterator = requires(_Iter __it) + { + { *__it } -> __can_reference; + { ++__it } -> same_as<_Iter&>; + { *__it++ } -> __can_reference; + } && copyable<_Iter>; + + template + concept __cpp17_input_iterator = __cpp17_iterator<_Iter> + && equality_comparable<_Iter> + && requires(_Iter __it) + { + typename incrementable_traits<_Iter>::difference_type; + typename indirectly_readable_traits<_Iter>::value_type; + typename common_reference_t&&, + typename indirectly_readable_traits<_Iter>::value_type&>; + typename common_reference_t::value_type&>; + requires signed_integral< + typename incrementable_traits<_Iter>::difference_type>; + }; + + template + concept __cpp17_fwd_iterator = __cpp17_input_iterator<_Iter> + && constructible_from<_Iter> + && is_lvalue_reference_v> + && same_as>, + typename indirectly_readable_traits<_Iter>::value_type> + && requires(_Iter __it) + { + { __it++ } -> convertible_to; + { *__it++ } -> same_as>; + }; + + template + concept __cpp17_bidi_iterator = __cpp17_fwd_iterator<_Iter> + && requires(_Iter __it) + { + { --__it } -> same_as<_Iter&>; + { __it-- } -> convertible_to; + { *__it-- } -> same_as>; + }; + + template + concept __cpp17_randacc_iterator = __cpp17_bidi_iterator<_Iter> + && totally_ordered<_Iter> + && requires(_Iter __it, + typename incrementable_traits<_Iter>::difference_type __n) + { + { __it += __n } -> same_as<_Iter&>; + { __it -= __n } -> same_as<_Iter&>; + { __it + __n } -> same_as<_Iter>; + { __n + __it } -> same_as<_Iter>; + { __it - __n } -> same_as<_Iter>; + { __it - __it } -> same_as; + { __it[__n] } -> convertible_to>; + }; + + template + concept __iter_with_nested_types = requires { + typename _Iter::iterator_category; + typename _Iter::value_type; + typename _Iter::difference_type; + typename _Iter::reference; + }; + + template + concept __iter_without_nested_types = !__iter_with_nested_types<_Iter>; + + template + concept __iter_without_category + = !requires { typename _Iter::iterator_category; }; + + } // namespace __detail + + template + requires __detail::__iter_with_nested_types<_Iterator> + struct __iterator_traits<_Iterator, void> + { + private: + template + struct __ptr + { using type = void; }; + + template requires requires { typename _Iter::pointer; } + struct __ptr<_Iter> + { using type = typename _Iter::pointer; }; + + public: + using iterator_category = typename _Iterator::iterator_category; + using value_type = typename _Iterator::value_type; + using difference_type = typename _Iterator::difference_type; + using pointer = typename __ptr<_Iterator>::type; + using reference = typename _Iterator::reference; + }; + + template + requires __detail::__iter_without_nested_types<_Iterator> + && __detail::__cpp17_input_iterator<_Iterator> + struct __iterator_traits<_Iterator, void> + { + private: + template + struct __cat + { using type = input_iterator_tag; }; + + template + requires requires { typename _Iter::iterator_category; } + struct __cat<_Iter> + { using type = typename _Iter::iterator_category; }; + + template + requires __detail::__iter_without_category<_Iter> + && __detail::__cpp17_randacc_iterator<_Iter> + struct __cat<_Iter> + { using type = random_access_iterator_tag; }; + + template + requires __detail::__iter_without_category<_Iter> + && __detail::__cpp17_bidi_iterator<_Iter> + struct __cat<_Iter> + { using type = bidirectional_iterator_tag; }; + + template + requires __detail::__iter_without_category<_Iter> + && __detail::__cpp17_fwd_iterator<_Iter> + struct __cat<_Iter> + { using type = forward_iterator_tag; }; + + template + struct __ptr + { using type = void; }; + + template requires requires { typename _Iter::pointer; } + struct __ptr<_Iter> + { using type = typename _Iter::pointer; }; + + template + requires (!requires { typename _Iter::pointer; } + && requires(_Iter& __it) { __it.operator->(); }) + struct __ptr<_Iter> + { using type = decltype(std::declval<_Iter&>().operator->()); }; + + template + struct __ref + { using type = iter_reference_t<_Iter>; }; + + template requires requires { typename _Iter::reference; } + struct __ref<_Iter> + { using type = typename _Iter::reference; }; + + public: + using iterator_category = typename __cat<_Iterator>::type; + using value_type + = typename indirectly_readable_traits<_Iterator>::value_type; + using difference_type + = typename incrementable_traits<_Iterator>::difference_type; + using pointer = typename __ptr<_Iterator>::type; + using reference = typename __ref<_Iterator>::type; + }; + + template + requires __detail::__iter_without_nested_types<_Iterator> + && __detail::__cpp17_iterator<_Iterator> + struct __iterator_traits<_Iterator, void> + { + private: + template + struct __diff + { using type = void; }; + + template + requires requires + { typename incrementable_traits<_Iter>::difference_type; } + struct __diff<_Iter> + { + using type = typename incrementable_traits<_Iter>::difference_type; + }; + + public: + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = typename __diff<_Iterator>::type; + using pointer = void; + using reference = void; + }; + + namespace __detail + { + template + struct __iter_concept_impl; + + // ITER_CONCEPT(I) is ITER_TRAITS(I)::iterator_concept if that is valid. + template + requires requires { typename __iter_traits<_Iter>::iterator_concept; } + struct __iter_concept_impl<_Iter> + { using type = typename __iter_traits<_Iter>::iterator_concept; }; + + // Otherwise, ITER_TRAITS(I)::iterator_category if that is valid. + template + requires (!requires { typename __iter_traits<_Iter>::iterator_concept; } + && requires { typename __iter_traits<_Iter>::iterator_category; }) + struct __iter_concept_impl<_Iter> + { using type = typename __iter_traits<_Iter>::iterator_category; }; + + // Otherwise, random_access_tag if iterator_traits is not specialized. + template + requires (!requires { typename __iter_traits<_Iter>::iterator_concept; } + && !requires { typename __iter_traits<_Iter>::iterator_category; } + && __primary_traits_iter<_Iter>) + struct __iter_concept_impl<_Iter> + { using type = random_access_iterator_tag; }; + + // Otherwise, there is no ITER_CONCEPT(I) type. + template + struct __iter_concept_impl + { }; + + // ITER_CONCEPT + template + using __iter_concept = typename __iter_concept_impl<_Iter>::type; + + template + concept __indirectly_readable_impl = requires + { + typename iter_value_t<_In>; + typename iter_reference_t<_In>; + typename iter_rvalue_reference_t<_In>; + requires same_as, + iter_reference_t<_In>>; + requires same_as, + iter_rvalue_reference_t<_In>>; + } + && common_reference_with&&, iter_value_t<_In>&> + && common_reference_with&&, + iter_rvalue_reference_t<_In>&&> + && common_reference_with&&, + const iter_value_t<_In>&>; + + } // namespace __detail + + /// Requirements for types that are readable by applying operator*. + template + concept indirectly_readable + = __detail::__indirectly_readable_impl>; + + template + using iter_common_reference_t + = common_reference_t, iter_value_t<_Tp>&>; + + /// Requirements for writing a value into an iterator's referenced object. + template + concept indirectly_writable = requires(_Out&& __o, _Tp&& __t) + { + *__o = std::forward<_Tp>(__t); + *std::forward<_Out>(__o) = std::forward<_Tp>(__t); + const_cast&&>(*__o) + = std::forward<_Tp>(__t); + const_cast&&>(*std::forward<_Out>(__o)) + = std::forward<_Tp>(__t); + }; + + namespace ranges::__detail + { + class __max_diff_type; + class __max_size_type; + + template + concept __is_signed_int128 +#if __SIZEOF_INT128__ + = same_as<_Tp, __int128>; +#else + = false; +#endif + + template + concept __is_unsigned_int128 +#if __SIZEOF_INT128__ + = same_as<_Tp, unsigned __int128>; +#else + = false; +#endif + + template + concept __cv_bool = same_as; + + template + concept __integral_nonbool = integral<_Tp> && !__cv_bool<_Tp>; + + template + concept __is_int128 = __is_signed_int128<_Tp> || __is_unsigned_int128<_Tp>; + + template + concept __is_integer_like = __integral_nonbool<_Tp> + || __is_int128<_Tp> + || same_as<_Tp, __max_diff_type> || same_as<_Tp, __max_size_type>; + + template + concept __is_signed_integer_like = signed_integral<_Tp> + || __is_signed_int128<_Tp> + || same_as<_Tp, __max_diff_type>; + + } // namespace ranges::__detail + + namespace __detail { using ranges::__detail::__is_signed_integer_like; } + + /// Requirements on types that can be incremented with ++. + template + concept weakly_incrementable = default_initializable<_Iter> + && movable<_Iter> + && requires(_Iter __i) + { + typename iter_difference_t<_Iter>; + requires __detail::__is_signed_integer_like>; + { ++__i } -> same_as<_Iter&>; + __i++; + }; + + template + concept incrementable = regular<_Iter> && weakly_incrementable<_Iter> + && requires(_Iter __i) { { __i++ } -> same_as<_Iter>; }; + + template + concept input_or_output_iterator + = requires(_Iter __i) { { *__i } -> __detail::__can_reference; } + && weakly_incrementable<_Iter>; + + template + concept sentinel_for = semiregular<_Sent> + && input_or_output_iterator<_Iter> + && __detail::__weakly_eq_cmp_with<_Sent, _Iter>; + + template + inline constexpr bool disable_sized_sentinel_for = false; + + template + concept sized_sentinel_for = sentinel_for<_Sent, _Iter> + && !disable_sized_sentinel_for, remove_cv_t<_Iter>> + && requires(const _Iter& __i, const _Sent& __s) + { + { __s - __i } -> same_as>; + { __i - __s } -> same_as>; + }; + + template + concept input_iterator = input_or_output_iterator<_Iter> + && indirectly_readable<_Iter> + && requires { typename __detail::__iter_concept<_Iter>; } + && derived_from<__detail::__iter_concept<_Iter>, input_iterator_tag>; + + template + concept output_iterator = input_or_output_iterator<_Iter> + && indirectly_writable<_Iter, _Tp> + && requires(_Iter __i, _Tp&& __t) { *__i++ = std::forward<_Tp>(__t); }; + + template + concept forward_iterator = input_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, forward_iterator_tag> + && incrementable<_Iter> && sentinel_for<_Iter, _Iter>; + + template + concept bidirectional_iterator = forward_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, + bidirectional_iterator_tag> + && requires(_Iter __i) + { + { --__i } -> same_as<_Iter&>; + { __i-- } -> same_as<_Iter>; + }; + + template + concept random_access_iterator = bidirectional_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, + random_access_iterator_tag> + && totally_ordered<_Iter> && sized_sentinel_for<_Iter, _Iter> + && requires(_Iter __i, const _Iter __j, + const iter_difference_t<_Iter> __n) + { + { __i += __n } -> same_as<_Iter&>; + { __j + __n } -> same_as<_Iter>; + { __n + __j } -> same_as<_Iter>; + { __i -= __n } -> same_as<_Iter&>; + { __j - __n } -> same_as<_Iter>; + { __j[__n] } -> same_as>; + }; + + template + concept contiguous_iterator = random_access_iterator<_Iter> + && derived_from<__detail::__iter_concept<_Iter>, contiguous_iterator_tag> + && is_lvalue_reference_v> + && same_as, remove_cvref_t>> + && requires(const _Iter& __i) + { + { std::to_address(__i) } + -> same_as>>; + }; + + // [indirectcallable], indirect callable requirements + + // [indirectcallable.indirectinvocable], indirect callables + + template + concept indirectly_unary_invocable = indirectly_readable<_Iter> + && copy_constructible<_Fn> && invocable<_Fn&, iter_value_t<_Iter>&> + && invocable<_Fn&, iter_reference_t<_Iter>> + && invocable<_Fn&, iter_common_reference_t<_Iter>> + && common_reference_with&>, + invoke_result_t<_Fn&, iter_reference_t<_Iter>>>; + + template + concept indirectly_regular_unary_invocable = indirectly_readable<_Iter> + && copy_constructible<_Fn> + && regular_invocable<_Fn&, iter_value_t<_Iter>&> + && regular_invocable<_Fn&, iter_reference_t<_Iter>> + && regular_invocable<_Fn&, iter_common_reference_t<_Iter>> + && common_reference_with&>, + invoke_result_t<_Fn&, iter_reference_t<_Iter>>>; + + template + concept indirect_unary_predicate = indirectly_readable<_Iter> + && copy_constructible<_Fn> && predicate<_Fn&, iter_value_t<_Iter>&> + && predicate<_Fn&, iter_reference_t<_Iter>> + && predicate<_Fn&, iter_common_reference_t<_Iter>>; + + template + concept indirect_binary_predicate + = indirectly_readable<_I1> && indirectly_readable<_I2> + && copy_constructible<_Fn> + && predicate<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&> + && predicate<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>> + && predicate<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&> + && predicate<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>> + && predicate<_Fn&, iter_common_reference_t<_I1>, + iter_common_reference_t<_I2>>; + + template + concept indirect_equivalence_relation + = indirectly_readable<_I1> && indirectly_readable<_I2> + && copy_constructible<_Fn> + && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&> + && equivalence_relation<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>> + && equivalence_relation<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&> + && equivalence_relation<_Fn&, iter_reference_t<_I1>, + iter_reference_t<_I2>> + && equivalence_relation<_Fn&, iter_common_reference_t<_I1>, + iter_common_reference_t<_I2>>; + + template + concept indirect_strict_weak_order + = indirectly_readable<_I1> && indirectly_readable<_I2> + && copy_constructible<_Fn> + && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_value_t<_I2>&> + && strict_weak_order<_Fn&, iter_value_t<_I1>&, iter_reference_t<_I2>> + && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_value_t<_I2>&> + && strict_weak_order<_Fn&, iter_reference_t<_I1>, iter_reference_t<_I2>> + && strict_weak_order<_Fn&, iter_common_reference_t<_I1>, + iter_common_reference_t<_I2>>; + + template + requires (indirectly_readable<_Is> && ...) + && invocable<_Fn, iter_reference_t<_Is>...> + using indirect_result_t = invoke_result_t<_Fn, iter_reference_t<_Is>...>; + + /// [projected], projected + template _Proj> + struct projected + { + using value_type = remove_cvref_t>; + + indirect_result_t<_Proj&, _Iter> operator*() const; // not defined + }; + + template + struct incrementable_traits> + { using difference_type = iter_difference_t<_Iter>; }; + + // [alg.req], common algorithm requirements + + /// [alg.req.ind.move], concept `indirectly_movable` + + template + concept indirectly_movable = indirectly_readable<_In> + && indirectly_writable<_Out, iter_rvalue_reference_t<_In>>; + + template + concept indirectly_movable_storable = indirectly_movable<_In, _Out> + && indirectly_writable<_Out, iter_value_t<_In>> + && movable> + && constructible_from, iter_rvalue_reference_t<_In>> + && assignable_from&, iter_rvalue_reference_t<_In>>; + + /// [alg.req.ind.copy], concept `indirectly_copyable` + template + concept indirectly_copyable = indirectly_readable<_In> + && indirectly_writable<_Out, iter_reference_t<_In>>; + + template + concept indirectly_copyable_storable = indirectly_copyable<_In, _Out> + && indirectly_writable<_Out, iter_value_t<_In>&> + && indirectly_writable<_Out, const iter_value_t<_In>&> + && indirectly_writable<_Out, iter_value_t<_In>&&> + && indirectly_writable<_Out, const iter_value_t<_In>&&> + && copyable> + && constructible_from, iter_reference_t<_In>> + && assignable_from&, iter_reference_t<_In>>; + +namespace ranges +{ + namespace __cust_iswap + { + template + void iter_swap(_It1, _It2) = delete; + + template + concept __adl_iswap + = (std::__detail::__class_or_enum> + || std::__detail::__class_or_enum>) + && requires(_Tp&& __t, _Up&& __u) { + iter_swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + }; + + template + constexpr iter_value_t<_Xp> + __iter_exchange_move(_Xp&& __x, _Yp&& __y) + noexcept(noexcept(iter_value_t<_Xp>(iter_move(__x))) + && noexcept(*__x = iter_move(__y))) + { + iter_value_t<_Xp> __old_value(iter_move(__x)); + *__x = iter_move(__y); + return __old_value; + } + + struct _IterSwap + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_iswap<_Tp, _Up>) + return noexcept(iter_swap(std::declval<_Tp>(), + std::declval<_Up>())); + else if constexpr (indirectly_readable<_Tp> + && indirectly_readable<_Up> + && swappable_with, iter_reference_t<_Up>>) + return noexcept(ranges::swap(*std::declval<_Tp>(), + *std::declval<_Up>())); + else + return noexcept(*std::declval<_Tp>() + = __iter_exchange_move(std::declval<_Up>(), + std::declval<_Tp>())); + } + + public: + template + requires __adl_iswap<_Tp, _Up> + || (indirectly_readable> + && indirectly_readable> + && swappable_with, iter_reference_t<_Up>>) + || (indirectly_movable_storable<_Tp, _Up> + && indirectly_movable_storable<_Up, _Tp>) + constexpr void + operator()(_Tp&& __e1, _Up&& __e2) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__adl_iswap<_Tp, _Up>) + iter_swap(static_cast<_Tp&&>(__e1), static_cast<_Up&&>(__e2)); + else if constexpr (indirectly_readable<_Tp> + && indirectly_readable<_Up> + && swappable_with, iter_reference_t<_Up>>) + ranges::swap(*__e1, *__e2); + else + *__e1 = __iter_exchange_move(__e2, __e1); + } + }; + } // namespace __cust_iswap + + inline namespace __cust + { + inline constexpr __cust_iswap::_IterSwap iter_swap{}; + } // inline namespace __cust + +} // namespace ranges + + /// [alg.req.ind.swap], concept `indirectly_swappable` + template + concept indirectly_swappable + = indirectly_readable<_I1> && indirectly_readable<_I2> + && requires(const _I1 __i1, const _I2 __i2) + { + ranges::iter_swap(__i1, __i1); + ranges::iter_swap(__i2, __i2); + ranges::iter_swap(__i1, __i2); + ranges::iter_swap(__i2, __i1); + }; + + /// [alg.req.ind.cmp], concept `indirectly_comparable` + template + concept indirectly_comparable + = indirect_binary_predicate<_Rel, projected<_I1, _P1>, + projected<_I2, _P2>>; + + /// [alg.req.permutable], concept `permutable` + template + concept permutable = forward_iterator<_Iter> + && indirectly_movable_storable<_Iter, _Iter> + && indirectly_swappable<_Iter, _Iter>; + + /// [alg.req.mergeable], concept `mergeable` + template + concept mergeable = input_iterator<_I1> && input_iterator<_I2> + && weakly_incrementable<_Out> && indirectly_copyable<_I1, _Out> + && indirectly_copyable<_I2, _Out> + && indirect_strict_weak_order<_Rel, projected<_I1, _P1>, + projected<_I2, _P2>>; + + /// [alg.req.sortable], concept `sortable` + template + concept sortable = permutable<_Iter> + && indirect_strict_weak_order<_Rel, projected<_Iter, _Proj>>; + + struct unreachable_sentinel_t + { + template + friend constexpr bool + operator==(unreachable_sentinel_t, const _It&) noexcept + { return false; } + }; + + inline constexpr unreachable_sentinel_t unreachable_sentinel{}; + + struct default_sentinel_t { }; + inline constexpr default_sentinel_t default_sentinel{}; + + // This is the namespace for [range.access] CPOs. + namespace ranges::__cust_access + { + using std::__detail::__class_or_enum; + + struct _Decay_copy final + { + template + constexpr decay_t<_Tp> + operator()(_Tp&& __t) const + noexcept(is_nothrow_convertible_v<_Tp, decay_t<_Tp>>) + { return std::forward<_Tp>(__t); } + } inline constexpr __decay_copy{}; + + template + concept __member_begin = requires(_Tp& __t) + { + { __decay_copy(__t.begin()) } -> input_or_output_iterator; + }; + + // Poison pills so that unqualified lookup doesn't find std::begin. + void begin(auto&) = delete; + void begin(const auto&) = delete; + + template + concept __adl_begin = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(begin(__t)) } -> input_or_output_iterator; + }; + + // Simplified version of std::ranges::begin that only supports lvalues, + // for use by __range_iter_t below. + template + requires is_array_v<_Tp> || __member_begin<_Tp&> || __adl_begin<_Tp&> + auto + __begin(_Tp& __t) + { + if constexpr (is_array_v<_Tp>) + return __t + 0; + else if constexpr (__member_begin<_Tp&>) + return __t.begin(); + else + return begin(__t); + } + } // namespace ranges::__cust_access + + namespace __detail + { + // Implementation of std::ranges::iterator_t, without using ranges::begin. + template + using __range_iter_t + = decltype(ranges::__cust_access::__begin(std::declval<_Tp&>())); + + } // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 library concepts +#endif // _ITERATOR_CONCEPTS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/list.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/list.tcc new file mode 100755 index 0000000..0ce4c47 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/list.tcc @@ -0,0 +1,663 @@ +// List implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/list.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{list} + */ + +#ifndef _LIST_TCC +#define _LIST_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + void + _List_base<_Tp, _Alloc>:: + _M_clear() _GLIBCXX_NOEXCEPT + { + typedef _List_node<_Tp> _Node; + __detail::_List_node_base* __cur = _M_impl._M_node._M_next; + while (__cur != &_M_impl._M_node) + { + _Node* __tmp = static_cast<_Node*>(__cur); + __cur = __tmp->_M_next; + _Tp* __val = __tmp->_M_valptr(); +#if __cplusplus >= 201103L + _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val); +#else + _Tp_alloc_type(_M_get_Node_allocator()).destroy(__val); +#endif + _M_put_node(__tmp); + } + } + +#if __cplusplus >= 201103L + template + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + emplace(const_iterator __position, _Args&&... __args) + { + _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...); + __tmp->_M_hook(__position._M_const_cast()._M_node); + this->_M_inc_size(1); + return iterator(__tmp); + } +#endif + + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + _Node* __tmp = _M_create_node(__x); + __tmp->_M_hook(__position._M_const_cast()._M_node); + this->_M_inc_size(1); + return iterator(__tmp); + } + +#if __cplusplus >= 201103L + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + insert(const_iterator __position, size_type __n, const value_type& __x) + { + if (__n) + { + list __tmp(__n, __x, get_allocator()); + iterator __it = __tmp.begin(); + splice(__position, __tmp); + return __it; + } + return __position._M_const_cast(); + } + + template + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + list __tmp(__first, __last, get_allocator()); + if (!__tmp.empty()) + { + iterator __it = __tmp.begin(); + splice(__position, __tmp); + return __it; + } + return __position._M_const_cast(); + } +#endif + + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + erase(const_iterator __position) noexcept +#else + erase(iterator __position) +#endif + { + iterator __ret = iterator(__position._M_node->_M_next); + _M_erase(__position._M_const_cast()); + return __ret; + } + + // Return a const_iterator indicating the position to start inserting or + // erasing elements (depending whether the list is growing or shrinking), + // and set __new_size to the number of new elements that must be appended. + // Equivalent to the following, but performed optimally: + // if (__new_size < size()) { + // __new_size = 0; + // return std::next(begin(), __new_size); + // } else { + // __newsize -= size(); + // return end(); + // } + template + typename list<_Tp, _Alloc>::const_iterator + list<_Tp, _Alloc>:: + _M_resize_pos(size_type& __new_size) const + { + const_iterator __i; +#if _GLIBCXX_USE_CXX11_ABI + const size_type __len = size(); + if (__new_size < __len) + { + if (__new_size <= __len / 2) + { + __i = begin(); + std::advance(__i, __new_size); + } + else + { + __i = end(); + ptrdiff_t __num_erase = __len - __new_size; + std::advance(__i, -__num_erase); + } + __new_size = 0; + return __i; + } + else + __i = end(); +#else + size_type __len = 0; + for (__i = begin(); __i != end() && __len < __new_size; ++__i, ++__len) + ; +#endif + __new_size -= __len; + return __i; + } + +#if __cplusplus >= 201103L + template + void + list<_Tp, _Alloc>:: + _M_default_append(size_type __n) + { + size_type __i = 0; + __try + { + for (; __i < __n; ++__i) + emplace_back(); + } + __catch(...) + { + for (; __i; --__i) + pop_back(); + __throw_exception_again; + } + } + + template + void + list<_Tp, _Alloc>:: + resize(size_type __new_size) + { + const_iterator __i = _M_resize_pos(__new_size); + if (__new_size) + _M_default_append(__new_size); + else + erase(__i, end()); + } + + template + void + list<_Tp, _Alloc>:: + resize(size_type __new_size, const value_type& __x) + { + const_iterator __i = _M_resize_pos(__new_size); + if (__new_size) + insert(end(), __new_size, __x); + else + erase(__i, end()); + } +#else + template + void + list<_Tp, _Alloc>:: + resize(size_type __new_size, value_type __x) + { + const_iterator __i = _M_resize_pos(__new_size); + if (__new_size) + insert(end(), __new_size, __x); + else + erase(__i._M_const_cast(), end()); + } +#endif + + template + list<_Tp, _Alloc>& + list<_Tp, _Alloc>:: + operator=(const list& __x) + { + if (this != std::__addressof(__x)) + { +#if __cplusplus >= 201103L + if (_Node_alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_get_Node_allocator(); + auto& __that_alloc = __x._M_get_Node_allocator(); + if (!_Node_alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // replacement allocator cannot free existing storage + clear(); + } + std::__alloc_on_copy(__this_alloc, __that_alloc); + } +#endif + _M_assign_dispatch(__x.begin(), __x.end(), __false_type()); + } + return *this; + } + + template + void + list<_Tp, _Alloc>:: + _M_fill_assign(size_type __n, const value_type& __val) + { + iterator __i = begin(); + for (; __i != end() && __n > 0; ++__i, --__n) + *__i = __val; + if (__n > 0) + insert(end(), __n, __val); + else + erase(__i, end()); + } + + template + template + void + list<_Tp, _Alloc>:: + _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2, + __false_type) + { + iterator __first1 = begin(); + iterator __last1 = end(); + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + *__first1 = *__first2; + if (__first2 == __last2) + erase(__first1, __last1); + else + insert(__last1, __first2, __last2); + } + +#if __cplusplus > 201703L +# define _GLIBCXX20_ONLY(__expr) __expr +#else +# define _GLIBCXX20_ONLY(__expr) +#endif + + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + remove(const value_type& __value) + { +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __first = begin(); + iterator __last = end(); + while (__first != __last) + { + iterator __next = __first; + ++__next; + if (*__first == __value) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 526. Is it undefined if a function in the standard changes + // in parameters? + __to_destroy.splice(__to_destroy.begin(), *this, __first); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + + __first = __next; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + unique() + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return _GLIBCXX20_ONLY( 0 ); +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __next = __first; + while (++__next != __last) + { + if (*__first == *__next) + { + __to_destroy.splice(__to_destroy.begin(), *this, __next); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + else + __first = __next; + __next = __first; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + void + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + merge(list&& __x) +#else + merge(list& __x) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != std::__addressof(__x)) + { + _M_check_equal_allocators(__x); + + iterator __first1 = begin(); + iterator __last1 = end(); + iterator __first2 = __x.begin(); + iterator __last2 = __x.end(); + const size_t __orig_size = __x.size(); + __try { + while (__first1 != __last1 && __first2 != __last2) + if (*__first2 < *__first1) + { + iterator __next = __first2; + _M_transfer(__first1, __first2, ++__next); + __first2 = __next; + } + else + ++__first1; + if (__first2 != __last2) + _M_transfer(__last1, __first2, __last2); + + this->_M_inc_size(__x._M_get_size()); + __x._M_set_size(0); + } + __catch(...) + { + const size_t __dist = std::distance(__first2, __last2); + this->_M_inc_size(__orig_size - __dist); + __x._M_set_size(__dist); + __throw_exception_again; + } + } + } + + template + template + void + list<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + merge(list&& __x, _StrictWeakOrdering __comp) +#else + merge(list& __x, _StrictWeakOrdering __comp) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != std::__addressof(__x)) + { + _M_check_equal_allocators(__x); + + iterator __first1 = begin(); + iterator __last1 = end(); + iterator __first2 = __x.begin(); + iterator __last2 = __x.end(); + const size_t __orig_size = __x.size(); + __try + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(*__first2, *__first1)) + { + iterator __next = __first2; + _M_transfer(__first1, __first2, ++__next); + __first2 = __next; + } + else + ++__first1; + if (__first2 != __last2) + _M_transfer(__last1, __first2, __last2); + + this->_M_inc_size(__x._M_get_size()); + __x._M_set_size(0); + } + __catch(...) + { + const size_t __dist = std::distance(__first2, __last2); + this->_M_inc_size(__orig_size - __dist); + __x._M_set_size(__dist); + __throw_exception_again; + } + } + } + + template + void + list<_Tp, _Alloc>:: + sort() + { + // Do nothing if the list has length 0 or 1. + if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node + && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node) + { + list __carry; + list __tmp[64]; + list * __fill = __tmp; + list * __counter; + __try + { + do + { + __carry.splice(__carry.begin(), *this, begin()); + + for(__counter = __tmp; + __counter != __fill && !__counter->empty(); + ++__counter) + { + __counter->merge(__carry); + __carry.swap(*__counter); + } + __carry.swap(*__counter); + if (__counter == __fill) + ++__fill; + } + while ( !empty() ); + + for (__counter = __tmp + 1; __counter != __fill; ++__counter) + __counter->merge(*(__counter - 1)); + swap( *(__fill - 1) ); + } + __catch(...) + { + this->splice(this->end(), __carry); + for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i) + this->splice(this->end(), __tmp[__i]); + __throw_exception_again; + } + } + } + + template + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + remove_if(_Predicate __pred) + { +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __first = begin(); + iterator __last = end(); + while (__first != __last) + { + iterator __next = __first; + ++__next; + if (__pred(*__first)) + { + __to_destroy.splice(__to_destroy.begin(), *this, __first); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + __first = __next; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + template + typename list<_Tp, _Alloc>::__remove_return_type + list<_Tp, _Alloc>:: + unique(_BinaryPredicate __binary_pred) + { + iterator __first = begin(); + iterator __last = end(); + if (__first == __last) + return _GLIBCXX20_ONLY(0); +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + list __to_destroy(get_allocator()); + iterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(*__first, *__next)) + { + __to_destroy.splice(__to_destroy.begin(), *this, __next); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + else + __first = __next; + __next = __first; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + +#undef _GLIBCXX20_ONLY + + template + template + void + list<_Tp, _Alloc>:: + sort(_StrictWeakOrdering __comp) + { + // Do nothing if the list has length 0 or 1. + if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node + && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node) + { + list __carry; + list __tmp[64]; + list * __fill = __tmp; + list * __counter; + __try + { + do + { + __carry.splice(__carry.begin(), *this, begin()); + + for(__counter = __tmp; + __counter != __fill && !__counter->empty(); + ++__counter) + { + __counter->merge(__carry, __comp); + __carry.swap(*__counter); + } + __carry.swap(*__counter); + if (__counter == __fill) + ++__fill; + } + while ( !empty() ); + + for (__counter = __tmp + 1; __counter != __fill; ++__counter) + __counter->merge(*(__counter - 1), __comp); + swap(*(__fill - 1)); + } + __catch(...) + { + this->splice(this->end(), __carry); + for (int __i = 0; __i < sizeof(__tmp)/sizeof(__tmp[0]); ++__i) + this->splice(this->end(), __tmp[__i]); + __throw_exception_again; + } + } + } + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _LIST_TCC */ + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_classes.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_classes.h new file mode 100755 index 0000000..f939fdd --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_classes.h @@ -0,0 +1,859 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_classes.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_CLASSES_H +#define _LOCALE_CLASSES_H 1 + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 22.1.1 Class locale + /** + * @brief Container class for localization functionality. + * @ingroup locales + * + * The locale class is first a class wrapper for C library locales. It is + * also an extensible container for user-defined localization. A locale is + * a collection of facets that implement various localization features such + * as money, time, and number printing. + * + * Constructing C++ locales does not change the C library locale. + * + * This library supports efficient construction and copying of locales + * through a reference counting implementation of the locale class. + */ + class locale + { + public: + // Types: + /// Definition of locale::category. + typedef int category; + + // Forward decls and friends: + class facet; + class id; + class _Impl; + + friend class facet; + friend class _Impl; + + template + friend bool + has_facet(const locale&) throw(); + + template + friend const _Facet& + use_facet(const locale&); + + template + friend struct __use_cache; + + ///@{ + /** + * @brief Category values. + * + * The standard category values are none, ctype, numeric, collate, time, + * monetary, and messages. They form a bitmask that supports union and + * intersection. The category all is the union of these values. + * + * NB: Order must match _S_facet_categories definition in locale.cc + */ + static const category none = 0; + static const category ctype = 1L << 0; + static const category numeric = 1L << 1; + static const category collate = 1L << 2; + static const category time = 1L << 3; + static const category monetary = 1L << 4; + static const category messages = 1L << 5; + static const category all = (ctype | numeric | collate | + time | monetary | messages); + ///@} + + // Construct/copy/destroy: + + /** + * @brief Default constructor. + * + * Constructs a copy of the global locale. If no locale has been + * explicitly set, this is the C locale. + */ + locale() throw(); + + /** + * @brief Copy constructor. + * + * Constructs a copy of @a other. + * + * @param __other The locale to copy. + */ + locale(const locale& __other) throw(); + + /** + * @brief Named locale constructor. + * + * Constructs a copy of the named C library locale. + * + * @param __s Name of the locale to construct. + * @throw std::runtime_error if __s is null or an undefined locale. + */ + explicit + locale(const char* __s); + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale named by @a s. If base is + * named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __s Name of the locale to use facets from. + * @param __cat Set of categories defining the facets to use from __s. + * @throw std::runtime_error if __s is null or an undefined locale. + */ + locale(const locale& __base, const char* __s, category __cat); + +#if __cplusplus >= 201103L + /** + * @brief Named locale constructor. + * + * Constructs a copy of the named C library locale. + * + * @param __s Name of the locale to construct. + * @throw std::runtime_error if __s is an undefined locale. + */ + explicit + locale(const std::string& __s) : locale(__s.c_str()) { } + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale named by @a s. If base is + * named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __s Name of the locale to use facets from. + * @param __cat Set of categories defining the facets to use from __s. + * @throw std::runtime_error if __s is an undefined locale. + */ + locale(const locale& __base, const std::string& __s, category __cat) + : locale(__base, __s.c_str(), __cat) { } +#endif + + /** + * @brief Construct locale with facets from another locale. + * + * Constructs a copy of the locale @a base. The facets specified by @a + * cat are replaced with those from the locale @a add. If @a base and @a + * add are named, this locale instance will also be named. + * + * @param __base The locale to copy. + * @param __add The locale to use facets from. + * @param __cat Set of categories defining the facets to use from add. + */ + locale(const locale& __base, const locale& __add, category __cat); + + /** + * @brief Construct locale with another facet. + * + * Constructs a copy of the locale @a __other. The facet @a __f + * is added to @a __other, replacing an existing facet of type + * Facet if there is one. If @a __f is null, this locale is a + * copy of @a __other. + * + * @param __other The locale to copy. + * @param __f The facet to add in. + */ + template + locale(const locale& __other, _Facet* __f); + + /// Locale destructor. + ~locale() throw(); + + /** + * @brief Assignment operator. + * + * Set this locale to be a copy of @a other. + * + * @param __other The locale to copy. + * @return A reference to this locale. + */ + const locale& + operator=(const locale& __other) throw(); + + /** + * @brief Construct locale with another facet. + * + * Constructs and returns a new copy of this locale. Adds or replaces an + * existing facet of type Facet from the locale @a other into the new + * locale. + * + * @tparam _Facet The facet type to copy from other + * @param __other The locale to copy from. + * @return Newly constructed locale. + * @throw std::runtime_error if __other has no facet of type _Facet. + */ + template + locale + combine(const locale& __other) const; + + // Locale operations: + /** + * @brief Return locale name. + * @return Locale name or "*" if unnamed. + */ + _GLIBCXX_DEFAULT_ABI_TAG + string + name() const; + + /** + * @brief Locale equality. + * + * @param __other The locale to compare against. + * @return True if other and this refer to the same locale instance, are + * copies, or have the same name. False otherwise. + */ + bool + operator==(const locale& __other) const throw(); + +#if __cpp_impl_three_way_comparison < 201907L + /** + * @brief Locale inequality. + * + * @param __other The locale to compare against. + * @return ! (*this == __other) + */ + bool + operator!=(const locale& __other) const throw() + { return !(this->operator==(__other)); } +#endif + + /** + * @brief Compare two strings according to collate. + * + * Template operator to compare two strings using the compare function of + * the collate facet in this locale. One use is to provide the locale to + * the sort function. For example, a vector v of strings could be sorted + * according to locale loc by doing: + * @code + * std::sort(v.begin(), v.end(), loc); + * @endcode + * + * @param __s1 First string to compare. + * @param __s2 Second string to compare. + * @return True if collate<_Char> facet compares __s1 < __s2, else false. + */ + template + bool + operator()(const basic_string<_Char, _Traits, _Alloc>& __s1, + const basic_string<_Char, _Traits, _Alloc>& __s2) const; + + // Global locale objects: + /** + * @brief Set global locale + * + * This function sets the global locale to the argument and returns a + * copy of the previous global locale. If the argument has a name, it + * will also call std::setlocale(LC_ALL, loc.name()). + * + * @param __loc The new locale to make global. + * @return Copy of the old global locale. + */ + static locale + global(const locale& __loc); + + /** + * @brief Return reference to the C locale. + */ + static const locale& + classic(); + + private: + // The (shared) implementation + _Impl* _M_impl; + + // The "C" reference locale + static _Impl* _S_classic; + + // Current global locale + static _Impl* _S_global; + + // Names of underlying locale categories. + // NB: locale::global() has to know how to modify all the + // underlying categories, not just the ones required by the C++ + // standard. + static const char* const* const _S_categories; + + // Number of standard categories. For C++, these categories are + // collate, ctype, monetary, numeric, time, and messages. These + // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE, + // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE + // 1003.1-2001) specifies LC_MESSAGES. + // In addition to the standard categories, the underlying + // operating system is allowed to define extra LC_* + // macros. For GNU systems, the following are also valid: + // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, + // and LC_IDENTIFICATION. + enum { _S_categories_size = 6 + _GLIBCXX_NUM_CATEGORIES }; + +#ifdef __GTHREADS + static __gthread_once_t _S_once; +#endif + + explicit + locale(_Impl*) throw(); + + static void + _S_initialize(); + + static void + _S_initialize_once() throw(); + + static category + _S_normalize_category(category); + + void + _M_coalesce(const locale& __base, const locale& __add, category __cat); + +#if _GLIBCXX_USE_CXX11_ABI + static const id* const _S_twinned_facets[]; +#endif + }; + + + // 22.1.1.1.2 Class locale::facet + /** + * @brief Localization functionality base class. + * @ingroup locales + * + * The facet class is the base class for a localization feature, such as + * money, time, and number printing. It provides common support for facets + * and reference management. + * + * Facets may not be copied or assigned. + */ + class locale::facet + { + private: + friend class locale; + friend class locale::_Impl; + + mutable _Atomic_word _M_refcount; + + // Contains data from the underlying "C" library for the classic locale. + static __c_locale _S_c_locale; + + // String literal for the name of the classic locale. + static const char _S_c_name[2]; + +#ifdef __GTHREADS + static __gthread_once_t _S_once; +#endif + + static void + _S_initialize_once(); + + protected: + /** + * @brief Facet constructor. + * + * This is the constructor provided by the standard. If refs is 0, the + * facet is destroyed when the last referencing locale is destroyed. + * Otherwise the facet will never be destroyed. + * + * @param __refs The initial value for reference count. + */ + explicit + facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0) + { } + + /// Facet destructor. + virtual + ~facet(); + + static void + _S_create_c_locale(__c_locale& __cloc, const char* __s, + __c_locale __old = 0); + + static __c_locale + _S_clone_c_locale(__c_locale& __cloc) throw(); + + static void + _S_destroy_c_locale(__c_locale& __cloc); + + static __c_locale + _S_lc_ctype_c_locale(__c_locale __cloc, const char* __s); + + // Returns data from the underlying "C" library data for the + // classic locale. + static __c_locale + _S_get_c_locale(); + + _GLIBCXX_CONST static const char* + _S_get_c_name() throw(); + +#if __cplusplus < 201103L + private: + facet(const facet&); // Not defined. + + facet& + operator=(const facet&); // Not defined. +#else + facet(const facet&) = delete; + + facet& + operator=(const facet&) = delete; +#endif + + private: + void + _M_add_reference() const throw() + { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } + + void + _M_remove_reference() const throw() + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); + __try + { delete this; } + __catch(...) + { } + } + } + + const facet* _M_sso_shim(const id*) const; + const facet* _M_cow_shim(const id*) const; + + protected: + class __shim; // For internal use only. + }; + + + // 22.1.1.1.3 Class locale::id + /** + * @brief Facet ID class. + * @ingroup locales + * + * The ID class provides facets with an index used to identify them. + * Every facet class must define a public static member locale::id, or be + * derived from a facet that provides this member, otherwise the facet + * cannot be used in a locale. The locale::id ensures that each class + * type gets a unique identifier. + */ + class locale::id + { + private: + friend class locale; + friend class locale::_Impl; + + template + friend const _Facet& + use_facet(const locale&); + + template + friend bool + has_facet(const locale&) throw(); + + // NB: There is no accessor for _M_index because it may be used + // before the constructor is run; the effect of calling a member + // function (even an inline) would be undefined. + mutable size_t _M_index; + + // Last id number assigned. + static _Atomic_word _S_refcount; + + void + operator=(const id&); // Not defined. + + id(const id&); // Not defined. + + public: + // NB: This class is always a static data member, and thus can be + // counted on to be zero-initialized. + /// Constructor. + id() { } + + size_t + _M_id() const throw(); + }; + + + // Implementation object for locale. + class locale::_Impl + { + public: + // Friends. + friend class locale; + friend class locale::facet; + + template + friend bool + has_facet(const locale&) throw(); + + template + friend const _Facet& + use_facet(const locale&); + + template + friend struct __use_cache; + + private: + // Data Members. + _Atomic_word _M_refcount; + const facet** _M_facets; + size_t _M_facets_size; + const facet** _M_caches; + char** _M_names; + static const locale::id* const _S_id_ctype[]; + static const locale::id* const _S_id_numeric[]; + static const locale::id* const _S_id_collate[]; + static const locale::id* const _S_id_time[]; + static const locale::id* const _S_id_monetary[]; + static const locale::id* const _S_id_messages[]; + static const locale::id* const* const _S_facet_categories[]; + + void + _M_add_reference() throw() + { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } + + void + _M_remove_reference() throw() + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); + __try + { delete this; } + __catch(...) + { } + } + } + + _Impl(const _Impl&, size_t); + _Impl(const char*, size_t); + _Impl(size_t) throw(); + + ~_Impl() throw(); + + _Impl(const _Impl&); // Not defined. + + void + operator=(const _Impl&); // Not defined. + + bool + _M_check_same_name() + { + bool __ret = true; + if (_M_names[1]) + // We must actually compare all the _M_names: can be all equal! + for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i) + __ret = __builtin_strcmp(_M_names[__i], _M_names[__i + 1]) == 0; + return __ret; + } + + void + _M_replace_categories(const _Impl*, category); + + void + _M_replace_category(const _Impl*, const locale::id* const*); + + void + _M_replace_facet(const _Impl*, const locale::id*); + + void + _M_install_facet(const locale::id*, const facet*); + + template + void + _M_init_facet(_Facet* __facet) + { _M_install_facet(&_Facet::id, __facet); } + + template + void + _M_init_facet_unchecked(_Facet* __facet) + { + __facet->_M_add_reference(); + _M_facets[_Facet::id._M_id()] = __facet; + } + + void + _M_install_cache(const facet*, size_t); + + void _M_init_extra(facet**); + void _M_init_extra(void*, void*, const char*, const char*); + +#ifdef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT + void _M_init_extra_ldbl128(bool); +#endif + }; + + + /** + * @brief Facet for localized string comparison. + * + * This facet encapsulates the code to compare strings in a localized + * manner. + * + * The collate template uses protected virtual functions to provide + * the actual results. The public accessors forward the call to + * the virtual functions. These virtual functions are hooks for + * developers to implement the behavior they require from the + * collate facet. + */ + template + class _GLIBCXX_NAMESPACE_CXX11 collate : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + + protected: + // Underlying "C" library locale information saved from + // initialization, needed by collate_byname as well. + __c_locale _M_c_locale_collate; + + public: + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + collate(size_t __refs = 0) + : facet(__refs), _M_c_locale_collate(_S_get_c_locale()) + { } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __refs Passed to the base facet class. + */ + explicit + collate(__c_locale __cloc, size_t __refs = 0) + : facet(__refs), _M_c_locale_collate(_S_clone_c_locale(__cloc)) + { } + + /** + * @brief Compare two strings. + * + * This function compares two strings and returns the result by calling + * collate::do_compare(). + * + * @param __lo1 Start of string 1. + * @param __hi1 End of string 1. + * @param __lo2 Start of string 2. + * @param __hi2 End of string 2. + * @return 1 if string1 > string2, -1 if string1 < string2, else 0. + */ + int + compare(const _CharT* __lo1, const _CharT* __hi1, + const _CharT* __lo2, const _CharT* __hi2) const + { return this->do_compare(__lo1, __hi1, __lo2, __hi2); } + + /** + * @brief Transform string to comparable form. + * + * This function is a wrapper for strxfrm functionality. It takes the + * input string and returns a modified string that can be directly + * compared to other transformed strings. In the C locale, this + * function just returns a copy of the input string. In some other + * locales, it may replace two chars with one, change a char for + * another, etc. It does so by returning collate::do_transform(). + * + * @param __lo Start of string. + * @param __hi End of string. + * @return Transformed string_type. + */ + string_type + transform(const _CharT* __lo, const _CharT* __hi) const + { return this->do_transform(__lo, __hi); } + + /** + * @brief Return hash of a string. + * + * This function computes and returns a hash on the input string. It + * does so by returning collate::do_hash(). + * + * @param __lo Start of string. + * @param __hi End of string. + * @return Hash value. + */ + long + hash(const _CharT* __lo, const _CharT* __hi) const + { return this->do_hash(__lo, __hi); } + + // Used to abstract out _CharT bits in virtual member functions, below. + int + _M_compare(const _CharT*, const _CharT*) const throw(); + + size_t + _M_transform(_CharT*, const _CharT*, size_t) const throw(); + + protected: + /// Destructor. + virtual + ~collate() + { _S_destroy_c_locale(_M_c_locale_collate); } + + /** + * @brief Compare two strings. + * + * This function is a hook for derived classes to change the value + * returned. @see compare(). + * + * @param __lo1 Start of string 1. + * @param __hi1 End of string 1. + * @param __lo2 Start of string 2. + * @param __hi2 End of string 2. + * @return 1 if string1 > string2, -1 if string1 < string2, else 0. + */ + virtual int + do_compare(const _CharT* __lo1, const _CharT* __hi1, + const _CharT* __lo2, const _CharT* __hi2) const; + + /** + * @brief Transform string to comparable form. + * + * This function is a hook for derived classes to change the value + * returned. + * + * @param __lo Start. + * @param __hi End. + * @return transformed string. + */ + virtual string_type + do_transform(const _CharT* __lo, const _CharT* __hi) const; + + /** + * @brief Return hash of a string. + * + * This function computes and returns a hash on the input string. This + * function is a hook for derived classes to change the value returned. + * + * @param __lo Start of string. + * @param __hi End of string. + * @return Hash value. + */ + virtual long + do_hash(const _CharT* __lo, const _CharT* __hi) const; + }; + + template + locale::id collate<_CharT>::id; + + // Specializations. + template<> + int + collate::_M_compare(const char*, const char*) const throw(); + + template<> + size_t + collate::_M_transform(char*, const char*, size_t) const throw(); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + int + collate::_M_compare(const wchar_t*, const wchar_t*) const throw(); + + template<> + size_t + collate::_M_transform(wchar_t*, const wchar_t*, size_t) const throw(); +#endif + + /// class collate_byname [22.2.4.2]. + template + class _GLIBCXX_NAMESPACE_CXX11 collate_byname : public collate<_CharT> + { + public: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + + explicit + collate_byname(const char* __s, size_t __refs = 0) + : collate<_CharT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_collate); + this->_S_create_c_locale(this->_M_c_locale_collate, __s); + } + } + +#if __cplusplus >= 201103L + explicit + collate_byname(const string& __s, size_t __refs = 0) + : collate_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~collate_byname() { } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +# include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_classes.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_classes.tcc new file mode 100755 index 0000000..b435b21 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_classes.tcc @@ -0,0 +1,298 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_classes.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_CLASSES_TCC +#define _LOCALE_CLASSES_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + locale:: + locale(const locale& __other, _Facet* __f) + { + _M_impl = new _Impl(*__other._M_impl, 1); + + __try + { _M_impl->_M_install_facet(&_Facet::id, __f); } + __catch(...) + { + _M_impl->_M_remove_reference(); + __throw_exception_again; + } + delete [] _M_impl->_M_names[0]; + _M_impl->_M_names[0] = 0; // Unnamed. + } + + template + locale + locale:: + combine(const locale& __other) const + { + _Impl* __tmp = new _Impl(*_M_impl, 1); + __try + { + __tmp->_M_replace_facet(__other._M_impl, &_Facet::id); + } + __catch(...) + { + __tmp->_M_remove_reference(); + __throw_exception_again; + } + return locale(__tmp); + } + + template + bool + locale:: + operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1, + const basic_string<_CharT, _Traits, _Alloc>& __s2) const + { + typedef std::collate<_CharT> __collate_type; + const __collate_type& __collate = use_facet<__collate_type>(*this); + return (__collate.compare(__s1.data(), __s1.data() + __s1.length(), + __s2.data(), __s2.data() + __s2.length()) < 0); + } + + /** + * @brief Test for the presence of a facet. + * @ingroup locales + * + * has_facet tests the locale argument for the presence of the facet type + * provided as the template parameter. Facets derived from the facet + * parameter will also return true. + * + * @tparam _Facet The facet type to test the presence of. + * @param __loc The locale to test. + * @return true if @p __loc contains a facet of type _Facet, else false. + */ + template + bool + has_facet(const locale& __loc) throw() + { + const size_t __i = _Facet::id._M_id(); + const locale::facet** __facets = __loc._M_impl->_M_facets; + return (__i < __loc._M_impl->_M_facets_size +#if __cpp_rtti + && dynamic_cast(__facets[__i])); +#else + && static_cast(__facets[__i])); +#endif + } + + /** + * @brief Return a facet. + * @ingroup locales + * + * use_facet looks for and returns a reference to a facet of type Facet + * where Facet is the template parameter. If has_facet(locale) is true, + * there is a suitable facet to return. It throws std::bad_cast if the + * locale doesn't contain a facet of type Facet. + * + * @tparam _Facet The facet type to access. + * @param __loc The locale to use. + * @return Reference to facet of type Facet. + * @throw std::bad_cast if @p __loc doesn't contain a facet of type _Facet. + */ + template + const _Facet& + use_facet(const locale& __loc) + { + const size_t __i = _Facet::id._M_id(); + const locale::facet** __facets = __loc._M_impl->_M_facets; + if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i]) + __throw_bad_cast(); +#if __cpp_rtti + return dynamic_cast(*__facets[__i]); +#else + return static_cast(*__facets[__i]); +#endif + } + + + // Generic version does nothing. + template + int + collate<_CharT>::_M_compare(const _CharT*, const _CharT*) const throw () + { return 0; } + + // Generic version does nothing. + template + size_t + collate<_CharT>::_M_transform(_CharT*, const _CharT*, size_t) const throw () + { return 0; } + + template + int + collate<_CharT>:: + do_compare(const _CharT* __lo1, const _CharT* __hi1, + const _CharT* __lo2, const _CharT* __hi2) const + { + // strcoll assumes zero-terminated strings so we make a copy + // and then put a zero at the end. + const string_type __one(__lo1, __hi1); + const string_type __two(__lo2, __hi2); + + const _CharT* __p = __one.c_str(); + const _CharT* __pend = __one.data() + __one.length(); + const _CharT* __q = __two.c_str(); + const _CharT* __qend = __two.data() + __two.length(); + + // strcoll stops when it sees a nul character so we break + // the strings into zero-terminated substrings and pass those + // to strcoll. + for (;;) + { + const int __res = _M_compare(__p, __q); + if (__res) + return __res; + + __p += char_traits<_CharT>::length(__p); + __q += char_traits<_CharT>::length(__q); + if (__p == __pend && __q == __qend) + return 0; + else if (__p == __pend) + return -1; + else if (__q == __qend) + return 1; + + __p++; + __q++; + } + } + + template + typename collate<_CharT>::string_type + collate<_CharT>:: + do_transform(const _CharT* __lo, const _CharT* __hi) const + { + string_type __ret; + + // strxfrm assumes zero-terminated strings so we make a copy + const string_type __str(__lo, __hi); + + const _CharT* __p = __str.c_str(); + const _CharT* __pend = __str.data() + __str.length(); + + size_t __len = (__hi - __lo) * 2; + + _CharT* __c = new _CharT[__len]; + + __try + { + // strxfrm stops when it sees a nul character so we break + // the string into zero-terminated substrings and pass those + // to strxfrm. + for (;;) + { + // First try a buffer perhaps big enough. + size_t __res = _M_transform(__c, __p, __len); + // If the buffer was not large enough, try again with the + // correct size. + if (__res >= __len) + { + __len = __res + 1; + delete [] __c, __c = 0; + __c = new _CharT[__len]; + __res = _M_transform(__c, __p, __len); + } + + __ret.append(__c, __res); + __p += char_traits<_CharT>::length(__p); + if (__p == __pend) + break; + + __p++; + __ret.push_back(_CharT()); + } + } + __catch(...) + { + delete [] __c; + __throw_exception_again; + } + + delete [] __c; + + return __ret; + } + + template + long + collate<_CharT>:: + do_hash(const _CharT* __lo, const _CharT* __hi) const + { + unsigned long __val = 0; + for (; __lo < __hi; ++__lo) + __val = + *__lo + ((__val << 7) + | (__val >> (__gnu_cxx::__numeric_traits:: + __digits - 7))); + return static_cast(__val); + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class collate; + extern template class collate_byname; + + extern template + const collate& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class collate; + extern template class collate_byname; + + extern template + const collate& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_conv.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_conv.h new file mode 100755 index 0000000..0e409da --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_conv.h @@ -0,0 +1,618 @@ +// wstring_convert implementation -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_conv.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +#ifndef _LOCALE_CONV_H +#define _LOCALE_CONV_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup locales + * @{ + */ + + template + bool + __do_str_codecvt(const _InChar* __first, const _InChar* __last, + _OutStr& __outstr, const _Codecvt& __cvt, _State& __state, + size_t& __count, _Fn __fn) + { + if (__first == __last) + { + __outstr.clear(); + __count = 0; + return true; + } + + size_t __outchars = 0; + auto __next = __first; + const auto __maxlen = __cvt.max_length() + 1; + + codecvt_base::result __result; + do + { + __outstr.resize(__outstr.size() + (__last - __next) * __maxlen); + auto __outnext = &__outstr.front() + __outchars; + auto const __outlast = &__outstr.back() + 1; + __result = (__cvt.*__fn)(__state, __next, __last, __next, + __outnext, __outlast, __outnext); + __outchars = __outnext - &__outstr.front(); + } + while (__result == codecvt_base::partial && __next != __last + && ptrdiff_t(__outstr.size() - __outchars) < __maxlen); + + if (__result == codecvt_base::error) + { + __count = __next - __first; + return false; + } + + // The codecvt facet will only return noconv when the types are + // the same, so avoid instantiating basic_string::assign otherwise + if _GLIBCXX17_CONSTEXPR (is_same()) + if (__result == codecvt_base::noconv) + { + __outstr.assign(__first, __last); + __count = __last - __first; + return true; + } + + __outstr.resize(__outchars); + __count = __next - __first; + return true; + } + + // Convert narrow character string to wide. + template + inline bool + __str_codecvt_in(const char* __first, const char* __last, + basic_string<_CharT, _Traits, _Alloc>& __outstr, + const codecvt<_CharT, char, _State>& __cvt, + _State& __state, size_t& __count) + { + using _Codecvt = codecvt<_CharT, char, _State>; + using _ConvFn + = codecvt_base::result + (_Codecvt::*)(_State&, const char*, const char*, const char*&, + _CharT*, _CharT*, _CharT*&) const; + _ConvFn __fn = &codecvt<_CharT, char, _State>::in; + return __do_str_codecvt(__first, __last, __outstr, __cvt, __state, + __count, __fn); + } + + // As above, but with no __count parameter + template + inline bool + __str_codecvt_in(const char* __first, const char* __last, + basic_string<_CharT, _Traits, _Alloc>& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n); + } + + // As above, but returns false for partial conversion + template + inline bool + __str_codecvt_in_all(const char* __first, const char* __last, + basic_string<_CharT, _Traits, _Alloc>& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_in(__first, __last, __outstr, __cvt, __state, __n) + && (__n == size_t(__last - __first)); + } + + // Convert wide character string to narrow. + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char, _State>& __cvt, + _State& __state, size_t& __count) + { + using _Codecvt = codecvt<_CharT, char, _State>; + using _ConvFn + = codecvt_base::result + (_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&, + char*, char*, char*&) const; + _ConvFn __fn = &codecvt<_CharT, char, _State>::out; + return __do_str_codecvt(__first, __last, __outstr, __cvt, __state, + __count, __fn); + } + + // As above, but with no __count parameter + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n); + } + + // As above, but returns false for partial conversions + template + inline bool + __str_codecvt_out_all(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n) + && (__n == size_t(__last - __first)); + } + +#ifdef _GLIBCXX_USE_CHAR8_T + + // Convert wide character string to narrow. + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char8_t, _State>& __cvt, + _State& __state, size_t& __count) + { + using _Codecvt = codecvt<_CharT, char8_t, _State>; + using _ConvFn + = codecvt_base::result + (_Codecvt::*)(_State&, const _CharT*, const _CharT*, const _CharT*&, + char8_t*, char8_t*, char8_t*&) const; + _ConvFn __fn = &codecvt<_CharT, char8_t, _State>::out; + return __do_str_codecvt(__first, __last, __outstr, __cvt, __state, + __count, __fn); + } + + template + inline bool + __str_codecvt_out(const _CharT* __first, const _CharT* __last, + basic_string& __outstr, + const codecvt<_CharT, char8_t, _State>& __cvt) + { + _State __state = {}; + size_t __n; + return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n); + } + +#endif // _GLIBCXX_USE_CHAR8_T + +#ifdef _GLIBCXX_USE_WCHAR_T + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /// String conversions + template, + typename _Byte_alloc = allocator> + class wstring_convert + { + public: + typedef basic_string, _Byte_alloc> byte_string; + typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string; + typedef typename _Codecvt::state_type state_type; + typedef typename wide_string::traits_type::int_type int_type; + + /// Default constructor. + wstring_convert() : _M_cvt(new _Codecvt()) { } + + /** Constructor. + * + * @param __pcvt The facet to use for conversions. + * + * Takes ownership of @p __pcvt and will delete it in the destructor. + */ + explicit + wstring_convert(_Codecvt* __pcvt) : _M_cvt(__pcvt) + { + if (!_M_cvt) + __throw_logic_error("wstring_convert"); + } + + /** Construct with an initial converstion state. + * + * @param __pcvt The facet to use for conversions. + * @param __state Initial conversion state. + * + * Takes ownership of @p __pcvt and will delete it in the destructor. + * The object's conversion state will persist between conversions. + */ + wstring_convert(_Codecvt* __pcvt, state_type __state) + : _M_cvt(__pcvt), _M_state(__state), _M_with_cvtstate(true) + { + if (!_M_cvt) + __throw_logic_error("wstring_convert"); + } + + /** Construct with error strings. + * + * @param __byte_err A string to return on failed conversions. + * @param __wide_err A wide string to return on failed conversions. + */ + explicit + wstring_convert(const byte_string& __byte_err, + const wide_string& __wide_err = wide_string()) + : _M_cvt(new _Codecvt), + _M_byte_err_string(__byte_err), _M_wide_err_string(__wide_err), + _M_with_strings(true) + { + if (!_M_cvt) + __throw_logic_error("wstring_convert"); + } + + ~wstring_convert() = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2176. Special members for wstring_convert and wbuffer_convert + wstring_convert(const wstring_convert&) = delete; + wstring_convert& operator=(const wstring_convert&) = delete; + + /// @{ Convert from bytes. + wide_string + from_bytes(char __byte) + { + char __bytes[2] = { __byte }; + return from_bytes(__bytes, __bytes+1); + } + + wide_string + from_bytes(const char* __ptr) + { return from_bytes(__ptr, __ptr+char_traits::length(__ptr)); } + + wide_string + from_bytes(const byte_string& __str) + { + auto __ptr = __str.data(); + return from_bytes(__ptr, __ptr + __str.size()); + } + + wide_string + from_bytes(const char* __first, const char* __last) + { + if (!_M_with_cvtstate) + _M_state = state_type(); + wide_string __out{ _M_wide_err_string.get_allocator() }; + if (__str_codecvt_in(__first, __last, __out, *_M_cvt, _M_state, + _M_count)) + return __out; + if (_M_with_strings) + return _M_wide_err_string; + __throw_range_error("wstring_convert::from_bytes"); + } + /// @} + + /// @{ Convert to bytes. + byte_string + to_bytes(_Elem __wchar) + { + _Elem __wchars[2] = { __wchar }; + return to_bytes(__wchars, __wchars+1); + } + + byte_string + to_bytes(const _Elem* __ptr) + { + return to_bytes(__ptr, __ptr+wide_string::traits_type::length(__ptr)); + } + + byte_string + to_bytes(const wide_string& __wstr) + { + auto __ptr = __wstr.data(); + return to_bytes(__ptr, __ptr + __wstr.size()); + } + + byte_string + to_bytes(const _Elem* __first, const _Elem* __last) + { + if (!_M_with_cvtstate) + _M_state = state_type(); + byte_string __out{ _M_byte_err_string.get_allocator() }; + if (__str_codecvt_out(__first, __last, __out, *_M_cvt, _M_state, + _M_count)) + return __out; + if (_M_with_strings) + return _M_byte_err_string; + __throw_range_error("wstring_convert::to_bytes"); + } + /// @} + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2174. wstring_convert::converted() should be noexcept + /// The number of elements successfully converted in the last conversion. + size_t converted() const noexcept { return _M_count; } + + /// The final conversion state of the last conversion. + state_type state() const { return _M_state; } + + private: + unique_ptr<_Codecvt> _M_cvt; + byte_string _M_byte_err_string; + wide_string _M_wide_err_string; + state_type _M_state = state_type(); + size_t _M_count = 0; + bool _M_with_cvtstate = false; + bool _M_with_strings = false; + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + + /// Buffer conversions + template> + class wbuffer_convert : public basic_streambuf<_Elem, _Tr> + { + typedef basic_streambuf<_Elem, _Tr> _Wide_streambuf; + + public: + typedef typename _Codecvt::state_type state_type; + + /// Default constructor. + wbuffer_convert() : wbuffer_convert(nullptr) { } + + /** Constructor. + * + * @param __bytebuf The underlying byte stream buffer. + * @param __pcvt The facet to use for conversions. + * @param __state Initial conversion state. + * + * Takes ownership of @p __pcvt and will delete it in the destructor. + */ + explicit + wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, + state_type __state = state_type()) + : _M_buf(__bytebuf), _M_cvt(__pcvt), _M_state(__state) + { + if (!_M_cvt) + __throw_logic_error("wbuffer_convert"); + + _M_always_noconv = _M_cvt->always_noconv(); + + if (_M_buf) + { + this->setp(_M_put_area, _M_put_area + _S_buffer_length); + this->setg(_M_get_area + _S_putback_length, + _M_get_area + _S_putback_length, + _M_get_area + _S_putback_length); + } + } + + ~wbuffer_convert() = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2176. Special members for wstring_convert and wbuffer_convert + wbuffer_convert(const wbuffer_convert&) = delete; + wbuffer_convert& operator=(const wbuffer_convert&) = delete; + + streambuf* rdbuf() const noexcept { return _M_buf; } + + streambuf* + rdbuf(streambuf *__bytebuf) noexcept + { + auto __prev = _M_buf; + _M_buf = __bytebuf; + return __prev; + } + + /// The conversion state following the last conversion. + state_type state() const noexcept { return _M_state; } + + protected: + int + sync() + { return _M_buf && _M_conv_put() && !_M_buf->pubsync() ? 0 : -1; } + + typename _Wide_streambuf::int_type + overflow(typename _Wide_streambuf::int_type __out) + { + if (!_M_buf || !_M_conv_put()) + return _Tr::eof(); + else if (!_Tr::eq_int_type(__out, _Tr::eof())) + return this->sputc(__out); + return _Tr::not_eof(__out); + } + + typename _Wide_streambuf::int_type + underflow() + { + if (!_M_buf) + return _Tr::eof(); + + if (this->gptr() < this->egptr() || (_M_buf && _M_conv_get())) + return _Tr::to_int_type(*this->gptr()); + else + return _Tr::eof(); + } + + streamsize + xsputn(const typename _Wide_streambuf::char_type* __s, streamsize __n) + { + if (!_M_buf || __n == 0) + return 0; + streamsize __done = 0; + do + { + auto __nn = std::min(this->epptr() - this->pptr(), + __n - __done); + _Tr::copy(this->pptr(), __s + __done, __nn); + this->pbump(__nn); + __done += __nn; + } while (__done < __n && _M_conv_put()); + return __done; + } + + private: + // fill the get area from converted contents of the byte stream buffer + bool + _M_conv_get() + { + const streamsize __pb1 = this->gptr() - this->eback(); + const streamsize __pb2 = _S_putback_length; + const streamsize __npb = std::min(__pb1, __pb2); + + _Tr::move(_M_get_area + _S_putback_length - __npb, + this->gptr() - __npb, __npb); + + streamsize __nbytes = sizeof(_M_get_buf) - _M_unconv; + __nbytes = std::min(__nbytes, _M_buf->in_avail()); + if (__nbytes < 1) + __nbytes = 1; + __nbytes = _M_buf->sgetn(_M_get_buf + _M_unconv, __nbytes); + if (__nbytes < 1) + return false; + __nbytes += _M_unconv; + + // convert _M_get_buf into _M_get_area + + _Elem* __outbuf = _M_get_area + _S_putback_length; + _Elem* __outnext = __outbuf; + const char* __bnext = _M_get_buf; + + codecvt_base::result __result; + if (_M_always_noconv) + __result = codecvt_base::noconv; + else + { + _Elem* __outend = _M_get_area + _S_buffer_length; + + __result = _M_cvt->in(_M_state, + __bnext, __bnext + __nbytes, __bnext, + __outbuf, __outend, __outnext); + } + + if (__result == codecvt_base::noconv) + { + // cast is safe because noconv means _Elem is same type as char + auto __get_buf = reinterpret_cast(_M_get_buf); + _Tr::copy(__outbuf, __get_buf, __nbytes); + _M_unconv = 0; + return true; + } + + if ((_M_unconv = _M_get_buf + __nbytes - __bnext)) + char_traits::move(_M_get_buf, __bnext, _M_unconv); + + this->setg(__outbuf, __outbuf, __outnext); + + return __result != codecvt_base::error; + } + + // unused + bool + _M_put(...) + { return false; } + + bool + _M_put(const char* __p, streamsize __n) + { + if (_M_buf->sputn(__p, __n) < __n) + return false; + return true; + } + + // convert the put area and write to the byte stream buffer + bool + _M_conv_put() + { + _Elem* const __first = this->pbase(); + const _Elem* const __last = this->pptr(); + const streamsize __pending = __last - __first; + + if (_M_always_noconv) + return _M_put(__first, __pending); + + char __outbuf[2 * _S_buffer_length]; + + const _Elem* __next = __first; + const _Elem* __start; + do + { + __start = __next; + char* __outnext = __outbuf; + char* const __outlast = __outbuf + sizeof(__outbuf); + auto __result = _M_cvt->out(_M_state, __next, __last, __next, + __outnext, __outlast, __outnext); + if (__result == codecvt_base::error) + return false; + else if (__result == codecvt_base::noconv) + return _M_put(__next, __pending); + + if (!_M_put(__outbuf, __outnext - __outbuf)) + return false; + } + while (__next != __last && __next != __start); + + if (__next != __last) + _Tr::move(__first, __next, __last - __next); + + this->pbump(__first - __next); + return __next != __first; + } + + streambuf* _M_buf; + unique_ptr<_Codecvt> _M_cvt; + state_type _M_state; + + static const streamsize _S_buffer_length = 32; + static const streamsize _S_putback_length = 3; + _Elem _M_put_area[_S_buffer_length]; + _Elem _M_get_area[_S_buffer_length]; + streamsize _M_unconv = 0; + char _M_get_buf[_S_buffer_length-_S_putback_length]; + bool _M_always_noconv; + }; + +#endif // _GLIBCXX_USE_WCHAR_T + + /// @} group locales + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // __cplusplus + +#endif /* _LOCALE_CONV_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets.h new file mode 100755 index 0000000..03724cf --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets.h @@ -0,0 +1,2684 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_FACETS_H +#define _LOCALE_FACETS_H 1 + +#pragma GCC system_header + +#include // For wctype_t +#include +#include +#include +#include // For ios_base, ios_base::iostate +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +// Number of standard facets (for narrow characters only) +#define _GLIBCXX_NUM_FACETS 14 + +// Number of duplicated facets for cxx11 ABI +#define _GLIBCXX_NUM_CXX11_FACETS (_GLIBCXX_USE_DUAL_ABI ? 8 : 0) + +// codecvt and codecvt +#ifdef _GLIBCXX_USE_CHAR8_T +# define _GLIBCXX_NUM_UNICODE_FACETS 4 +#else +# define _GLIBCXX_NUM_UNICODE_FACETS 2 +#endif + +// Facets duplicated for alt128 long double format +// num_get, num_put, money_get, money_put (+ cxx11 money_get, money_put) +#define _GLIBCXX_NUM_LBDL_ALT128_FACETS (4 + (_GLIBCXX_USE_DUAL_ABI ? 2 : 0)) + + // Convert string to numeric value of type _Tp and store results. + // NB: This is specialized for all required types, there is no + // generic definition. + template + void + __convert_to_v(const char*, _Tp&, ios_base::iostate&, + const __c_locale&) throw(); + + // Explicit specializations for required types. + template<> + void + __convert_to_v(const char*, float&, ios_base::iostate&, + const __c_locale&) throw(); + + template<> + void + __convert_to_v(const char*, double&, ios_base::iostate&, + const __c_locale&) throw(); + + template<> + void + __convert_to_v(const char*, long double&, ios_base::iostate&, + const __c_locale&) throw(); + + // NB: __pad is a struct, rather than a function, so it can be + // partially-specialized. + template + struct __pad + { + static void + _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, + const _CharT* __olds, streamsize __newlen, streamsize __oldlen); + }; + + // Used by both numeric and monetary facets. + // Inserts "group separator" characters into an array of characters. + // It's recursive, one iteration per group. It moves the characters + // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this + // only with __gsize != 0. + template + _CharT* + __add_grouping(_CharT* __s, _CharT __sep, + const char* __gbeg, size_t __gsize, + const _CharT* __first, const _CharT* __last); + + // This template permits specializing facet output code for + // ostreambuf_iterator. For ostreambuf_iterator, sputn is + // significantly more efficient than incrementing iterators. + template + inline + ostreambuf_iterator<_CharT> + __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len) + { + __s._M_put(__ws, __len); + return __s; + } + + // This is the unspecialized form of the template. + template + inline + _OutIter + __write(_OutIter __s, const _CharT* __ws, int __len) + { + for (int __j = 0; __j < __len; __j++, ++__s) + *__s = __ws[__j]; + return __s; + } + + + // 22.2.1.1 Template class ctype + // Include host and configuration specific ctype enums for ctype_base. + + /** + * @brief Common base for ctype facet + * + * This template class provides implementations of the public functions + * that forward to the protected virtual functions. + * + * This template also provides abstract stubs for the protected virtual + * functions. + */ + template + class __ctype_abstract_base : public locale::facet, public ctype_base + { + public: + // Types: + /// Typedef for the template parameter + typedef _CharT char_type; + + /** + * @brief Test char_type classification. + * + * This function finds a mask M for @a __c and compares it to + * mask @a __m. It does so by returning the value of + * ctype::do_is(). + * + * @param __c The char_type to compare the mask of. + * @param __m The mask to compare against. + * @return (M & __m) != 0. + */ + bool + is(mask __m, char_type __c) const + { return this->do_is(__m, __c); } + + /** + * @brief Return a mask array. + * + * This function finds the mask for each char_type in the range [lo,hi) + * and successively writes it to vec. vec must have as many elements + * as the char array. It does so by returning the value of + * ctype::do_is(). + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + const char_type* + is(const char_type *__lo, const char_type *__hi, mask *__vec) const + { return this->do_is(__lo, __hi, __vec); } + + /** + * @brief Find char_type matching a mask + * + * This function searches for and returns the first char_type c in + * [lo,hi) for which is(m,c) is true. It does so by returning + * ctype::do_scan_is(). + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to matching char_type if found, else @a __hi. + */ + const char_type* + scan_is(mask __m, const char_type* __lo, const char_type* __hi) const + { return this->do_scan_is(__m, __lo, __hi); } + + /** + * @brief Find char_type not matching a mask + * + * This function searches for and returns the first char_type c in + * [lo,hi) for which is(m,c) is false. It does so by returning + * ctype::do_scan_not(). + * + * @param __m The mask to compare against. + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return Pointer to non-matching char if found, else @a __hi. + */ + const char_type* + scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { return this->do_scan_not(__m, __lo, __hi); } + + /** + * @brief Convert to uppercase. + * + * This function converts the argument to uppercase if possible. + * If not possible (for example, '2'), returns the argument. It does + * so by returning ctype::do_toupper(). + * + * @param __c The char_type to convert. + * @return The uppercase char_type if convertible, else @a __c. + */ + char_type + toupper(char_type __c) const + { return this->do_toupper(__c); } + + /** + * @brief Convert array to uppercase. + * + * This function converts each char_type in the range [lo,hi) to + * uppercase if possible. Other elements remain untouched. It does so + * by returning ctype:: do_toupper(lo, hi). + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + toupper(char_type *__lo, const char_type* __hi) const + { return this->do_toupper(__lo, __hi); } + + /** + * @brief Convert to lowercase. + * + * This function converts the argument to lowercase if possible. If + * not possible (for example, '2'), returns the argument. It does so + * by returning ctype::do_tolower(c). + * + * @param __c The char_type to convert. + * @return The lowercase char_type if convertible, else @a __c. + */ + char_type + tolower(char_type __c) const + { return this->do_tolower(__c); } + + /** + * @brief Convert array to lowercase. + * + * This function converts each char_type in the range [__lo,__hi) to + * lowercase if possible. Other elements remain untouched. It does so + * by returning ctype:: do_tolower(__lo, __hi). + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + tolower(char_type* __lo, const char_type* __hi) const + { return this->do_tolower(__lo, __hi); } + + /** + * @brief Widen char to char_type + * + * This function converts the char argument to char_type using the + * simplest reasonable transformation. It does so by returning + * ctype::do_widen(c). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted char_type. + */ + char_type + widen(char __c) const + { return this->do_widen(__c); } + + /** + * @brief Widen array to char_type + * + * This function converts each char in the input to char_type using the + * simplest reasonable transformation. It does so by returning + * ctype::do_widen(c). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char* + widen(const char* __lo, const char* __hi, char_type* __to) const + { return this->do_widen(__lo, __hi, __to); } + + /** + * @brief Narrow char_type to char + * + * This function converts the char_type to char using the simplest + * reasonable transformation. If the conversion fails, dfault is + * returned instead. It does so by returning + * ctype::do_narrow(__c). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char_type to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + char + narrow(char_type __c, char __dfault) const + { return this->do_narrow(__c, __dfault); } + + /** + * @brief Narrow array to char array + * + * This function converts each char_type in the input to char using the + * simplest reasonable transformation and writes the results to the + * destination array. For any char_type in the input that cannot be + * converted, @a dfault is used instead. It does so by returning + * ctype::do_narrow(__lo, __hi, __dfault, __to). + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char_type* + narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const + { return this->do_narrow(__lo, __hi, __dfault, __to); } + + protected: + explicit + __ctype_abstract_base(size_t __refs = 0): facet(__refs) { } + + virtual + ~__ctype_abstract_base() { } + + /** + * @brief Test char_type classification. + * + * This function finds a mask M for @a c and compares it to mask @a m. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __c The char_type to find the mask of. + * @param __m The mask to compare against. + * @return (M & __m) != 0. + */ + virtual bool + do_is(mask __m, char_type __c) const = 0; + + /** + * @brief Return a mask array. + * + * This function finds the mask for each char_type in the range [lo,hi) + * and successively writes it to vec. vec must have as many elements + * as the input. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, + mask* __vec) const = 0; + + /** + * @brief Find char_type matching mask + * + * This function searches for and returns the first char_type c in + * [__lo,__hi) for which is(__m,c) is true. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a matching char_type if found, else @a __hi. + */ + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, + const char_type* __hi) const = 0; + + /** + * @brief Find char_type not matching mask + * + * This function searches for and returns a pointer to the first + * char_type c of [lo,hi) for which is(m,c) is false. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a non-matching char_type if found, else @a __hi. + */ + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const = 0; + + /** + * @brief Convert to uppercase. + * + * This virtual function converts the char_type argument to uppercase + * if possible. If not possible (for example, '2'), returns the + * argument. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __c The char_type to convert. + * @return The uppercase char_type if convertible, else @a __c. + */ + virtual char_type + do_toupper(char_type __c) const = 0; + + /** + * @brief Convert array to uppercase. + * + * This virtual function converts each char_type in the range [__lo,__hi) + * to uppercase if possible. Other elements remain untouched. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const = 0; + + /** + * @brief Convert to lowercase. + * + * This virtual function converts the argument to lowercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __c The char_type to convert. + * @return The lowercase char_type if convertible, else @a __c. + */ + virtual char_type + do_tolower(char_type __c) const = 0; + + /** + * @brief Convert array to lowercase. + * + * This virtual function converts each char_type in the range [__lo,__hi) + * to lowercase if possible. Other elements remain untouched. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const = 0; + + /** + * @brief Widen char + * + * This virtual function converts the char to char_type using the + * simplest reasonable transformation. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted char_type + */ + virtual char_type + do_widen(char __c) const = 0; + + /** + * @brief Widen char array + * + * This function converts each char in the input to char_type using the + * simplest reasonable transformation. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __to) const = 0; + + /** + * @brief Narrow char_type to char + * + * This virtual function converts the argument to char using the + * simplest reasonable transformation. If the conversion fails, dfault + * is returned instead. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char_type to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + virtual char + do_narrow(char_type __c, char __dfault) const = 0; + + /** + * @brief Narrow char_type array to char + * + * This virtual function converts each char_type in the range + * [__lo,__hi) to char using the simplest reasonable + * transformation and writes the results to the destination + * array. For any element in the input that cannot be + * converted, @a __dfault is used instead. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const = 0; + }; + + /** + * @brief Primary class template ctype facet. + * @ingroup locales + * + * This template class defines classification and conversion functions for + * character sets. It wraps cctype functionality. Ctype gets used by + * streams for many I/O operations. + * + * This template provides the protected virtual functions the developer + * will have to replace in a derived class or specialization to make a + * working facet. The public functions that access them are defined in + * __ctype_abstract_base, to allow for implementation flexibility. See + * ctype for an example. The functions are documented in + * __ctype_abstract_base. + * + * Note: implementations are provided for all the protected virtual + * functions, but will likely not be useful. + */ + template + class ctype : public __ctype_abstract_base<_CharT> + { + public: + // Types: + typedef _CharT char_type; + typedef typename __ctype_abstract_base<_CharT>::mask mask; + + /// The facet id for ctype + static locale::id id; + + explicit + ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { } + + protected: + virtual + ~ctype(); + + virtual bool + do_is(mask __m, char_type __c) const; + + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const; + + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const; + + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const; + + virtual char_type + do_toupper(char_type __c) const; + + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const; + + virtual char_type + do_tolower(char_type __c) const; + + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const; + + virtual char_type + do_widen(char __c) const; + + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __dest) const; + + virtual char + do_narrow(char_type, char __dfault) const; + + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const; + }; + + template + locale::id ctype<_CharT>::id; + + /** + * @brief The ctype specialization. + * @ingroup locales + * + * This class defines classification and conversion functions for + * the char type. It gets used by char streams for many I/O + * operations. The char specialization provides a number of + * optimizations as well. + */ + template<> + class ctype : public locale::facet, public ctype_base + { + public: + // Types: + /// Typedef for the template parameter char. + typedef char char_type; + + protected: + // Data Members: + __c_locale _M_c_locale_ctype; + bool _M_del; + __to_type _M_toupper; + __to_type _M_tolower; + const mask* _M_table; + mutable char _M_widen_ok; + mutable char _M_widen[1 + static_cast(-1)]; + mutable char _M_narrow[1 + static_cast(-1)]; + mutable char _M_narrow_ok; // 0 uninitialized, 1 init, + // 2 memcpy can't be used + + public: + /// The facet id for ctype + static locale::id id; + /// The size of the mask table. It is SCHAR_MAX + 1. + static const size_t table_size = 1 + static_cast(-1); + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __table If non-zero, table is used as the per-char mask. + * Else classic_table() is used. + * @param __del If true, passes ownership of table to this facet. + * @param __refs Passed to the base facet class. + */ + explicit + ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0); + + /** + * @brief Constructor performs static initialization. + * + * This constructor is used to construct the initial C locale facet. + * + * @param __cloc Handle to C locale data. + * @param __table If non-zero, table is used as the per-char mask. + * @param __del If true, passes ownership of table to this facet. + * @param __refs Passed to the base facet class. + */ + explicit + ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false, + size_t __refs = 0); + + /** + * @brief Test char classification. + * + * This function compares the mask table[c] to @a __m. + * + * @param __c The char to compare the mask of. + * @param __m The mask to compare against. + * @return True if __m & table[__c] is true, false otherwise. + */ + inline bool + is(mask __m, char __c) const; + + /** + * @brief Return a mask array. + * + * This function finds the mask for each char in the range [lo, hi) and + * successively writes it to vec. vec must have as many elements as + * the char array. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + inline const char* + is(const char* __lo, const char* __hi, mask* __vec) const; + + /** + * @brief Find char matching a mask + * + * This function searches for and returns the first char in [lo,hi) for + * which is(m,char) is true. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a matching char if found, else @a __hi. + */ + inline const char* + scan_is(mask __m, const char* __lo, const char* __hi) const; + + /** + * @brief Find char not matching a mask + * + * This function searches for and returns a pointer to the first char + * in [__lo,__hi) for which is(m,char) is false. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a non-matching char if found, else @a __hi. + */ + inline const char* + scan_not(mask __m, const char* __lo, const char* __hi) const; + + /** + * @brief Convert to uppercase. + * + * This function converts the char argument to uppercase if possible. + * If not possible (for example, '2'), returns the argument. + * + * toupper() acts as if it returns ctype::do_toupper(c). + * do_toupper() must always return the same result for the same input. + * + * @param __c The char to convert. + * @return The uppercase char if convertible, else @a __c. + */ + char_type + toupper(char_type __c) const + { return this->do_toupper(__c); } + + /** + * @brief Convert array to uppercase. + * + * This function converts each char in the range [__lo,__hi) to uppercase + * if possible. Other chars remain untouched. + * + * toupper() acts as if it returns ctype:: do_toupper(__lo, __hi). + * do_toupper() must always return the same result for the same input. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + toupper(char_type *__lo, const char_type* __hi) const + { return this->do_toupper(__lo, __hi); } + + /** + * @brief Convert to lowercase. + * + * This function converts the char argument to lowercase if possible. + * If not possible (for example, '2'), returns the argument. + * + * tolower() acts as if it returns ctype::do_tolower(__c). + * do_tolower() must always return the same result for the same input. + * + * @param __c The char to convert. + * @return The lowercase char if convertible, else @a __c. + */ + char_type + tolower(char_type __c) const + { return this->do_tolower(__c); } + + /** + * @brief Convert array to lowercase. + * + * This function converts each char in the range [lo,hi) to lowercase + * if possible. Other chars remain untouched. + * + * tolower() acts as if it returns ctype:: do_tolower(__lo, __hi). + * do_tolower() must always return the same result for the same input. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + const char_type* + tolower(char_type* __lo, const char_type* __hi) const + { return this->do_tolower(__lo, __hi); } + + /** + * @brief Widen char + * + * This function converts the char to char_type using the simplest + * reasonable transformation. For an underived ctype facet, the + * argument will be returned unchanged. + * + * This function works as if it returns ctype::do_widen(c). + * do_widen() must always return the same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted character. + */ + char_type + widen(char __c) const + { + if (_M_widen_ok) + return _M_widen[static_cast(__c)]; + this->_M_widen_init(); + return this->do_widen(__c); + } + + /** + * @brief Widen char array + * + * This function converts each char in the input to char using the + * simplest reasonable transformation. For an underived ctype + * facet, the argument will be copied unchanged. + * + * This function works as if it returns ctype::do_widen(c). + * do_widen() must always return the same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char* + widen(const char* __lo, const char* __hi, char_type* __to) const + { + if (_M_widen_ok == 1) + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + if (!_M_widen_ok) + _M_widen_init(); + return this->do_widen(__lo, __hi, __to); + } + + /** + * @brief Narrow char + * + * This function converts the char to char using the simplest + * reasonable transformation. If the conversion fails, dfault is + * returned instead. For an underived ctype facet, @a c + * will be returned unchanged. + * + * This function works as if it returns ctype::do_narrow(c). + * do_narrow() must always return the same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted character. + */ + char + narrow(char_type __c, char __dfault) const + { + if (_M_narrow[static_cast(__c)]) + return _M_narrow[static_cast(__c)]; + const char __t = do_narrow(__c, __dfault); + if (__t != __dfault) + _M_narrow[static_cast(__c)] = __t; + return __t; + } + + /** + * @brief Narrow char array + * + * This function converts each char in the input to char using the + * simplest reasonable transformation and writes the results to the + * destination array. For any char in the input that cannot be + * converted, @a dfault is used instead. For an underived ctype + * facet, the argument will be copied unchanged. + * + * This function works as if it returns ctype::do_narrow(lo, hi, + * dfault, to). do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + const char_type* + narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const + { + if (__builtin_expect(_M_narrow_ok == 1, true)) + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + if (!_M_narrow_ok) + _M_narrow_init(); + return this->do_narrow(__lo, __hi, __dfault, __to); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 695. ctype::classic_table() not accessible. + /// Returns a pointer to the mask table provided to the constructor, or + /// the default from classic_table() if none was provided. + const mask* + table() const throw() + { return _M_table; } + + /// Returns a pointer to the C locale mask table. + static const mask* + classic_table() throw(); + protected: + + /** + * @brief Destructor. + * + * This function deletes table() if @a del was true in the + * constructor. + */ + virtual + ~ctype(); + + /** + * @brief Convert to uppercase. + * + * This virtual function converts the char argument to uppercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __c The char to convert. + * @return The uppercase char if convertible, else @a __c. + */ + virtual char_type + do_toupper(char_type __c) const; + + /** + * @brief Convert array to uppercase. + * + * This virtual function converts each char in the range [lo,hi) to + * uppercase if possible. Other chars remain untouched. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Convert to lowercase. + * + * This virtual function converts the char argument to lowercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __c The char to convert. + * @return The lowercase char if convertible, else @a __c. + */ + virtual char_type + do_tolower(char_type __c) const; + + /** + * @brief Convert array to lowercase. + * + * This virtual function converts each char in the range [lo,hi) to + * lowercase if possible. Other chars remain untouched. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __lo Pointer to first char in range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Widen char + * + * This virtual function converts the char to char using the simplest + * reasonable transformation. For an underived ctype facet, the + * argument will be returned unchanged. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted character. + */ + virtual char_type + do_widen(char __c) const + { return __c; } + + /** + * @brief Widen char array + * + * This function converts each char in the range [lo,hi) to char using + * the simplest reasonable transformation. For an underived + * ctype facet, the argument will be copied unchanged. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __to) const + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + + /** + * @brief Narrow char + * + * This virtual function converts the char to char using the simplest + * reasonable transformation. If the conversion fails, dfault is + * returned instead. For an underived ctype facet, @a c will be + * returned unchanged. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + virtual char + do_narrow(char_type __c, char __dfault __attribute__((__unused__))) const + { return __c; } + + /** + * @brief Narrow char array to char array + * + * This virtual function converts each char in the range [lo,hi) to + * char using the simplest reasonable transformation and writes the + * results to the destination array. For any char in the input that + * cannot be converted, @a dfault is used instead. For an underived + * ctype facet, the argument will be copied unchanged. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault __attribute__((__unused__)), char* __to) const + { + if (__builtin_expect(__hi != __lo, true)) + __builtin_memcpy(__to, __lo, __hi - __lo); + return __hi; + } + + private: + void _M_narrow_init() const; + void _M_widen_init() const; + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** + * @brief The ctype specialization. + * @ingroup locales + * + * This class defines classification and conversion functions for the + * wchar_t type. It gets used by wchar_t streams for many I/O operations. + * The wchar_t specialization provides a number of optimizations as well. + * + * ctype inherits its public methods from + * __ctype_abstract_base. + */ + template<> + class ctype : public __ctype_abstract_base + { + public: + // Types: + /// Typedef for the template parameter wchar_t. + typedef wchar_t char_type; + typedef wctype_t __wmask_type; + + protected: + __c_locale _M_c_locale_ctype; + + // Pre-computed narrowed and widened chars. + bool _M_narrow_ok; + char _M_narrow[128]; + wint_t _M_widen[1 + static_cast(-1)]; + + // Pre-computed elements for do_is. + mask _M_bit[16]; + __wmask_type _M_wmask[16]; + + public: + // Data Members: + /// The facet id for ctype + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + ctype(size_t __refs = 0); + + /** + * @brief Constructor performs static initialization. + * + * This constructor is used to construct the initial C locale facet. + * + * @param __cloc Handle to C locale data. + * @param __refs Passed to the base facet class. + */ + explicit + ctype(__c_locale __cloc, size_t __refs = 0); + + protected: + __wmask_type + _M_convert_to_wmask(const mask __m) const throw(); + + /// Destructor + virtual + ~ctype(); + + /** + * @brief Test wchar_t classification. + * + * This function finds a mask M for @a c and compares it to mask @a m. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __c The wchar_t to find the mask of. + * @param __m The mask to compare against. + * @return (M & __m) != 0. + */ + virtual bool + do_is(mask __m, char_type __c) const; + + /** + * @brief Return a mask array. + * + * This function finds the mask for each wchar_t in the range [lo,hi) + * and successively writes it to vec. vec must have as many elements + * as the input. + * + * do_is() is a hook for a derived facet to change the behavior of + * classifying. do_is() must always return the same result for the + * same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __vec Pointer to an array of mask storage. + * @return @a __hi. + */ + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const; + + /** + * @brief Find wchar_t matching mask + * + * This function searches for and returns the first wchar_t c in + * [__lo,__hi) for which is(__m,c) is true. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a matching wchar_t if found, else @a __hi. + */ + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const; + + /** + * @brief Find wchar_t not matching mask + * + * This function searches for and returns a pointer to the first + * wchar_t c of [__lo,__hi) for which is(__m,c) is false. + * + * do_scan_is() is a hook for a derived facet to change the behavior of + * match searching. do_is() must always return the same result for the + * same input. + * + * @param __m The mask to compare against. + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return Pointer to a non-matching wchar_t if found, else @a __hi. + */ + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const; + + /** + * @brief Convert to uppercase. + * + * This virtual function converts the wchar_t argument to uppercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __c The wchar_t to convert. + * @return The uppercase wchar_t if convertible, else @a __c. + */ + virtual char_type + do_toupper(char_type __c) const; + + /** + * @brief Convert array to uppercase. + * + * This virtual function converts each wchar_t in the range [lo,hi) to + * uppercase if possible. Other elements remain untouched. + * + * do_toupper() is a hook for a derived facet to change the behavior of + * uppercasing. do_toupper() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_toupper(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Convert to lowercase. + * + * This virtual function converts the argument to lowercase if + * possible. If not possible (for example, '2'), returns the argument. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __c The wchar_t to convert. + * @return The lowercase wchar_t if convertible, else @a __c. + */ + virtual char_type + do_tolower(char_type __c) const; + + /** + * @brief Convert array to lowercase. + * + * This virtual function converts each wchar_t in the range [lo,hi) to + * lowercase if possible. Other elements remain untouched. + * + * do_tolower() is a hook for a derived facet to change the behavior of + * lowercasing. do_tolower() must always return the same result for + * the same input. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @return @a __hi. + */ + virtual const char_type* + do_tolower(char_type* __lo, const char_type* __hi) const; + + /** + * @brief Widen char to wchar_t + * + * This virtual function converts the char to wchar_t using the + * simplest reasonable transformation. For an underived ctype + * facet, the argument will be cast to wchar_t. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The char to convert. + * @return The converted wchar_t. + */ + virtual char_type + do_widen(char __c) const; + + /** + * @brief Widen char array to wchar_t array + * + * This function converts each char in the input to wchar_t using the + * simplest reasonable transformation. For an underived ctype + * facet, the argument will be copied, casting each element to wchar_t. + * + * do_widen() is a hook for a derived facet to change the behavior of + * widening. do_widen() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start range. + * @param __hi Pointer to end of range. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char* + do_widen(const char* __lo, const char* __hi, char_type* __to) const; + + /** + * @brief Narrow wchar_t to char + * + * This virtual function converts the argument to char using + * the simplest reasonable transformation. If the conversion + * fails, dfault is returned instead. For an underived + * ctype facet, @a c will be cast to char and + * returned. + * + * do_narrow() is a hook for a derived facet to change the + * behavior of narrowing. do_narrow() must always return the + * same result for the same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __c The wchar_t to convert. + * @param __dfault Char to return if conversion fails. + * @return The converted char. + */ + virtual char + do_narrow(char_type __c, char __dfault) const; + + /** + * @brief Narrow wchar_t array to char array + * + * This virtual function converts each wchar_t in the range [lo,hi) to + * char using the simplest reasonable transformation and writes the + * results to the destination array. For any wchar_t in the input that + * cannot be converted, @a dfault is used instead. For an underived + * ctype facet, the argument will be copied, casting each + * element to char. + * + * do_narrow() is a hook for a derived facet to change the behavior of + * narrowing. do_narrow() must always return the same result for the + * same input. + * + * Note: this is not what you want for codepage conversions. See + * codecvt for that. + * + * @param __lo Pointer to start of range. + * @param __hi Pointer to end of range. + * @param __dfault Char to use if conversion fails. + * @param __to Pointer to the destination array. + * @return @a __hi. + */ + virtual const char_type* + do_narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char* __to) const; + + // For use at construction time only. + void + _M_initialize_ctype() throw(); + }; +#endif //_GLIBCXX_USE_WCHAR_T + + /// class ctype_byname [22.2.1.2]. + template + class ctype_byname : public ctype<_CharT> + { + public: + typedef typename ctype<_CharT>::mask mask; + + explicit + ctype_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0) + : ctype_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~ctype_byname() { } + }; + + /// 22.2.1.4 Class ctype_byname specializations. + template<> + class ctype_byname : public ctype + { + public: + explicit + ctype_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0); +#endif + + protected: + virtual + ~ctype_byname(); + }; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + class ctype_byname : public ctype + { + public: + explicit + ctype_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + ctype_byname(const string& __s, size_t __refs = 0); +#endif + + protected: + virtual + ~ctype_byname(); + }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +// Include host and configuration specific ctype inlines. +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 22.2.2 The numeric category. + class __num_base + { + public: + // NB: Code depends on the order of _S_atoms_out elements. + // Below are the indices into _S_atoms_out. + enum + { + _S_ominus, + _S_oplus, + _S_ox, + _S_oX, + _S_odigits, + _S_odigits_end = _S_odigits + 16, + _S_oudigits = _S_odigits_end, + _S_oudigits_end = _S_oudigits + 16, + _S_oe = _S_odigits + 14, // For scientific notation, 'e' + _S_oE = _S_oudigits + 14, // For scientific notation, 'E' + _S_oend = _S_oudigits_end + }; + + // A list of valid numeric literals for output. This array + // contains chars that will be passed through the current locale's + // ctype<_CharT>.widen() and then used to render numbers. + // For the standard "C" locale, this is + // "-+xX0123456789abcdef0123456789ABCDEF". + static const char* _S_atoms_out; + + // String literal of acceptable (narrow) input, for num_get. + // "-+xX0123456789abcdefABCDEF" + static const char* _S_atoms_in; + + enum + { + _S_iminus, + _S_iplus, + _S_ix, + _S_iX, + _S_izero, + _S_ie = _S_izero + 14, + _S_iE = _S_izero + 20, + _S_iend = 26 + }; + + // num_put + // Construct and return valid scanf format for floating point types. + static void + _S_format_float(const ios_base& __io, char* __fptr, char __mod) throw(); + }; + + template + struct __numpunct_cache : public locale::facet + { + const char* _M_grouping; + size_t _M_grouping_size; + bool _M_use_grouping; + const _CharT* _M_truename; + size_t _M_truename_size; + const _CharT* _M_falsename; + size_t _M_falsename_size; + _CharT _M_decimal_point; + _CharT _M_thousands_sep; + + // A list of valid numeric literals for output: in the standard + // "C" locale, this is "-+xX0123456789abcdef0123456789ABCDEF". + // This array contains the chars after having been passed + // through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms_out[__num_base::_S_oend]; + + // A list of valid numeric literals for input: in the standard + // "C" locale, this is "-+xX0123456789abcdefABCDEF" + // This array contains the chars after having been passed + // through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms_in[__num_base::_S_iend]; + + bool _M_allocated; + + __numpunct_cache(size_t __refs = 0) + : facet(__refs), _M_grouping(0), _M_grouping_size(0), + _M_use_grouping(false), + _M_truename(0), _M_truename_size(0), _M_falsename(0), + _M_falsename_size(0), _M_decimal_point(_CharT()), + _M_thousands_sep(_CharT()), _M_allocated(false) + { } + + ~__numpunct_cache(); + + void + _M_cache(const locale& __loc); + + private: + __numpunct_cache& + operator=(const __numpunct_cache&); + + explicit + __numpunct_cache(const __numpunct_cache&); + }; + + template + __numpunct_cache<_CharT>::~__numpunct_cache() + { + if (_M_allocated) + { + delete [] _M_grouping; + delete [] _M_truename; + delete [] _M_falsename; + } + } + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template numpunct. + * @ingroup locales + * + * This facet stores several pieces of information related to printing and + * scanning numbers, such as the decimal point character. It takes a + * template parameter specifying the char type. The numpunct facet is + * used by streams for many I/O operations involving numbers. + * + * The numpunct template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from a numpunct facet. + */ + template + class numpunct : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + typedef __numpunct_cache<_CharT> __cache_type; + + protected: + __cache_type* _M_data; + + public: + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Numpunct constructor. + * + * @param __refs Refcount to pass to the base class. + */ + explicit + numpunct(size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_numpunct(); } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up the + * predefined locale facets. + * + * @param __cache __numpunct_cache object. + * @param __refs Refcount to pass to the base class. + */ + explicit + numpunct(__cache_type* __cache, size_t __refs = 0) + : facet(__refs), _M_data(__cache) + { _M_initialize_numpunct(); } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __refs Refcount to pass to the base class. + */ + explicit + numpunct(__c_locale __cloc, size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_numpunct(__cloc); } + + /** + * @brief Return decimal point character. + * + * This function returns a char_type to use as a decimal point. It + * does so by returning returning + * numpunct::do_decimal_point(). + * + * @return @a char_type representing a decimal point. + */ + char_type + decimal_point() const + { return this->do_decimal_point(); } + + /** + * @brief Return thousands separator character. + * + * This function returns a char_type to use as a thousands + * separator. It does so by returning returning + * numpunct::do_thousands_sep(). + * + * @return char_type representing a thousands separator. + */ + char_type + thousands_sep() const + { return this->do_thousands_sep(); } + + /** + * @brief Return grouping specification. + * + * This function returns a string representing groupings for the + * integer part of a number. Groupings indicate where thousands + * separators should be inserted in the integer part of a number. + * + * Each char in the return string is interpret as an integer + * rather than a character. These numbers represent the number + * of digits in a group. The first char in the string + * represents the number of digits in the least significant + * group. If a char is negative, it indicates an unlimited + * number of digits for the group. If more chars from the + * string are required to group a number, the last char is used + * repeatedly. + * + * For example, if the grouping() returns "\003\002" and is + * applied to the number 123456789, this corresponds to + * 12,34,56,789. Note that if the string was "32", this would + * put more than 50 digits into the least significant group if + * the character set is ASCII. + * + * The string is returned by calling + * numpunct::do_grouping(). + * + * @return string representing grouping specification. + */ + string + grouping() const + { return this->do_grouping(); } + + /** + * @brief Return string representation of bool true. + * + * This function returns a string_type containing the text + * representation for true bool variables. It does so by calling + * numpunct::do_truename(). + * + * @return string_type representing printed form of true. + */ + string_type + truename() const + { return this->do_truename(); } + + /** + * @brief Return string representation of bool false. + * + * This function returns a string_type containing the text + * representation for false bool variables. It does so by calling + * numpunct::do_falsename(). + * + * @return string_type representing printed form of false. + */ + string_type + falsename() const + { return this->do_falsename(); } + + protected: + /// Destructor. + virtual + ~numpunct(); + + /** + * @brief Return decimal point character. + * + * Returns a char_type to use as a decimal point. This function is a + * hook for derived classes to change the value returned. + * + * @return @a char_type representing a decimal point. + */ + virtual char_type + do_decimal_point() const + { return _M_data->_M_decimal_point; } + + /** + * @brief Return thousands separator character. + * + * Returns a char_type to use as a thousands separator. This function + * is a hook for derived classes to change the value returned. + * + * @return @a char_type representing a thousands separator. + */ + virtual char_type + do_thousands_sep() const + { return _M_data->_M_thousands_sep; } + + /** + * @brief Return grouping specification. + * + * Returns a string representing groupings for the integer part of a + * number. This function is a hook for derived classes to change the + * value returned. @see grouping() for details. + * + * @return String representing grouping specification. + */ + virtual string + do_grouping() const + { return _M_data->_M_grouping; } + + /** + * @brief Return string representation of bool true. + * + * Returns a string_type containing the text representation for true + * bool variables. This function is a hook for derived classes to + * change the value returned. + * + * @return string_type representing printed form of true. + */ + virtual string_type + do_truename() const + { return _M_data->_M_truename; } + + /** + * @brief Return string representation of bool false. + * + * Returns a string_type containing the text representation for false + * bool variables. This function is a hook for derived classes to + * change the value returned. + * + * @return string_type representing printed form of false. + */ + virtual string_type + do_falsename() const + { return _M_data->_M_falsename; } + + // For use at construction time only. + void + _M_initialize_numpunct(__c_locale __cloc = 0); + }; + + template + locale::id numpunct<_CharT>::id; + + template<> + numpunct::~numpunct(); + + template<> + void + numpunct::_M_initialize_numpunct(__c_locale __cloc); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + numpunct::~numpunct(); + + template<> + void + numpunct::_M_initialize_numpunct(__c_locale __cloc); +#endif + + /// class numpunct_byname [22.2.3.2]. + template + class numpunct_byname : public numpunct<_CharT> + { + public: + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + + explicit + numpunct_byname(const char* __s, size_t __refs = 0) + : numpunct<_CharT>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + __c_locale __tmp; + this->_S_create_c_locale(__tmp, __s); + this->_M_initialize_numpunct(__tmp); + this->_S_destroy_c_locale(__tmp); + } + } + +#if __cplusplus >= 201103L + explicit + numpunct_byname(const string& __s, size_t __refs = 0) + : numpunct_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~numpunct_byname() { } + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_BEGIN_NAMESPACE_LDBL + + /** + * @brief Primary class template num_get. + * @ingroup locales + * + * This facet encapsulates the code to parse and return a number + * from a string. It is used by the istream numeric extraction + * operators. + * + * The num_get template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the num_get facet. + */ + template + class num_get : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _InIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + num_get(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Numeric parsing. + * + * Parses the input stream into the bool @a v. It does so by calling + * num_get::do_get(). + * + * If ios_base::boolalpha is set, attempts to read + * ctype::truename() or ctype::falsename(). Sets + * @a v to true or false if successful. Sets err to + * ios_base::failbit if reading the string fails. Sets err to + * ios_base::eofbit if the stream is emptied. + * + * If ios_base::boolalpha is not set, proceeds as with reading a long, + * except if the value is 1, sets @a v to true, if the value is 0, sets + * @a v to false, and otherwise set err to ios_base::failbit. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, bool& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + ///@{ + /** + * @brief Numeric parsing. + * + * Parses the input stream into the integral variable @a v. It does so + * by calling num_get::do_get(). + * + * Parsing is affected by the flag settings in @a io. + * + * The basic parse is affected by the value of io.flags() & + * ios_base::basefield. If equal to ios_base::oct, parses like the + * scanf %o specifier. Else if equal to ios_base::hex, parses like %X + * specifier. Else if basefield equal to 0, parses like the %i + * specifier. Otherwise, parses like %d for signed and %u for unsigned + * types. The matching type length modifier is also used. + * + * Digit grouping is interpreted according to + * numpunct::grouping() and numpunct::thousands_sep(). If the + * pattern of digit groups isn't consistent, sets err to + * ios_base::failbit. + * + * If parsing the string yields a valid value for @a v, @a v is set. + * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered. + * Sets err to ios_base::eofbit if the stream is emptied. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned short& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned int& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long long& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } +#endif + ///@} + + ///@{ + /** + * @brief Numeric parsing. + * + * Parses the input stream into the integral variable @a v. It does so + * by calling num_get::do_get(). + * + * The input characters are parsed like the scanf %g specifier. The + * matching type length modifier is also used. + * + * The decimal point character used is numpunct::decimal_point(). + * Digit grouping is interpreted according to + * numpunct::grouping() and numpunct::thousands_sep(). If the + * pattern of digit groups isn't consistent, sets err to + * ios_base::failbit. + * + * If parsing the string yields a valid value for @a v, @a v is set. + * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered. + * Sets err to ios_base::eofbit if the stream is emptied. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, float& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long double& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + ///@} + + /** + * @brief Numeric parsing. + * + * Parses the input stream into the pointer variable @a v. It does so + * by calling num_get::do_get(). + * + * The input characters are parsed like the scanf %p specifier. + * + * Digit grouping is interpreted according to + * numpunct::grouping() and numpunct::thousands_sep(). If the + * pattern of digit groups isn't consistent, sets err to + * ios_base::failbit. + * + * Note that the digit grouping effect for pointers is a bit ambiguous + * in the standard and shouldn't be relied on. See DR 344. + * + * If parsing the string yields a valid value for @a v, @a v is set. + * Otherwise, sets err to ios_base::failbit and leaves @a v unaltered. + * Sets err to ios_base::eofbit if the stream is emptied. + * + * @param __in Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + iter_type + get(iter_type __in, iter_type __end, ios_base& __io, + ios_base::iostate& __err, void*& __v) const + { return this->do_get(__in, __end, __io, __err, __v); } + + protected: + /// Destructor. + virtual ~num_get() { } + + _GLIBCXX_DEFAULT_ABI_TAG + iter_type + _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, + string&) const; + + template + _GLIBCXX_DEFAULT_ABI_TAG + iter_type + _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, + _ValueT&) const; + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, int>::__type + _M_find(const _CharT2*, size_t __len, _CharT2 __c) const + { + int __ret = -1; + if (__len <= 10) + { + if (__c >= _CharT2('0') && __c < _CharT2(_CharT2('0') + __len)) + __ret = __c - _CharT2('0'); + } + else + { + if (__c >= _CharT2('0') && __c <= _CharT2('9')) + __ret = __c - _CharT2('0'); + else if (__c >= _CharT2('a') && __c <= _CharT2('f')) + __ret = 10 + (__c - _CharT2('a')); + else if (__c >= _CharT2('A') && __c <= _CharT2('F')) + __ret = 10 + (__c - _CharT2('A')); + } + return __ret; + } + + template + typename __gnu_cxx::__enable_if::__value, + int>::__type + _M_find(const _CharT2* __zero, size_t __len, _CharT2 __c) const + { + int __ret = -1; + const char_type* __q = char_traits<_CharT2>::find(__zero, __len, __c); + if (__q) + { + __ret = __q - __zero; + if (__ret > 15) + __ret -= 6; + } + return __ret; + } + + ///@{ + /** + * @brief Numeric parsing. + * + * Parses the input stream into the variable @a v. This function is a + * hook for derived classes to change the value returned. @see get() + * for more details. + * + * @param __beg Start of input stream. + * @param __end End of input stream. + * @param __io Source of locale and flags. + * @param __err Error flags to set. + * @param __v Value to format and insert. + * @return Iterator after reading. + */ + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const; + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned short& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned int& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } + + virtual iter_type + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, unsigned long long& __v) const + { return _M_extract_int(__beg, __end, __io, __err, __v); } +#endif + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, float&) const; + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + double&) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + // For __gnu_cxx_ldbl128::num_get and __gnu_cxx_ieee128::num_get + // this entry in the vtable is for a 64-bit "long double" with the + // same format as double. This keeps the vtable layout consistent + // with std::num_get (visible when -mlong-double-64 is used). + virtual iter_type + __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + double&) const; +#else + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + long double&) const; +#endif + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, void*&) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + // For __gnu_cxx_ieee128::num_get this entry in the vtable is for + // the non-IEEE 128-bit "long double" (aka "double double"). This + // is consistent with __gnu_cxx_ldbl128::num_get (-mabi=ibmlongdouble) + virtual iter_type + __do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + __ibm128&) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + // For __gnu_cxx_ldbl128::num_get and __gnu_cxx_ieee128::num_get + // this entry in the vtable is for the 128-bit "long double" type. + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, + long double&) const; +#endif + ///@} + }; + + template + locale::id num_get<_CharT, _InIter>::id; + + + /** + * @brief Primary class template num_put. + * @ingroup locales + * + * This facet encapsulates the code to convert a number to a string. It is + * used by the ostream numeric insertion operators. + * + * The num_put template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the num_put facet. + */ + template + class num_put : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _OutIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + num_put(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Numeric formatting. + * + * Formats the boolean @a v and inserts it into a stream. It does so + * by calling num_put::do_put(). + * + * If ios_base::boolalpha is set, writes ctype::truename() or + * ctype::falsename(). Otherwise formats @a v as an int. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const + { return this->do_put(__s, __io, __fill, __v); } + + ///@{ + /** + * @brief Numeric formatting. + * + * Formats the integral value @a v and inserts it into a + * stream. It does so by calling num_put::do_put(). + * + * Formatting is affected by the flag settings in @a io. + * + * The basic format is affected by the value of io.flags() & + * ios_base::basefield. If equal to ios_base::oct, formats like the + * printf %o specifier. Else if equal to ios_base::hex, formats like + * %x or %X with ios_base::uppercase unset or set respectively. + * Otherwise, formats like %d, %ld, %lld for signed and %u, %lu, %llu + * for unsigned values. Note that if both oct and hex are set, neither + * will take effect. + * + * If ios_base::showpos is set, '+' is output before positive values. + * If ios_base::showbase is set, '0' precedes octal values (except 0) + * and '0[xX]' precedes hex values. + * + * The decimal point character used is numpunct::decimal_point(). + * Thousands separators are inserted according to + * numpunct::grouping() and numpunct::thousands_sep(). + * + * If io.width() is non-zero, enough @a fill characters are inserted to + * make the result at least that wide. If + * (io.flags() & ios_base::adjustfield) == ios_base::left, result is + * padded at the end. If ios_base::internal, then padding occurs + * immediately after either a '+' or '-' or after '0x' or '0X'. + * Otherwise, padding occurs at the beginning. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, long __v) const + { return this->do_put(__s, __io, __fill, __v); } + + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long __v) const + { return this->do_put(__s, __io, __fill, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, long long __v) const + { return this->do_put(__s, __io, __fill, __v); } + + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long long __v) const + { return this->do_put(__s, __io, __fill, __v); } +#endif + ///@} + + ///@{ + /** + * @brief Numeric formatting. + * + * Formats the floating point value @a v and inserts it into a stream. + * It does so by calling num_put::do_put(). + * + * Formatting is affected by the flag settings in @a io. + * + * The basic format is affected by the value of io.flags() & + * ios_base::floatfield. If equal to ios_base::fixed, formats like the + * printf %f specifier. Else if equal to ios_base::scientific, formats + * like %e or %E with ios_base::uppercase unset or set respectively. + * Otherwise, formats like %g or %G depending on uppercase. Note that + * if both fixed and scientific are set, the effect will also be like + * %g or %G. + * + * The output precision is given by io.precision(). This precision is + * capped at numeric_limits::digits10 + 2 (different for double and + * long double). The default precision is 6. + * + * If ios_base::showpos is set, '+' is output before positive values. + * If ios_base::showpoint is set, a decimal point will always be + * output. + * + * The decimal point character used is numpunct::decimal_point(). + * Thousands separators are inserted according to + * numpunct::grouping() and numpunct::thousands_sep(). + * + * If io.width() is non-zero, enough @a fill characters are inserted to + * make the result at least that wide. If + * (io.flags() & ios_base::adjustfield) == ios_base::left, result is + * padded at the end. If ios_base::internal, then padding occurs + * immediately after either a '+' or '-' or after '0x' or '0X'. + * Otherwise, padding occurs at the beginning. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return this->do_put(__s, __io, __fill, __v); } + + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + long double __v) const + { return this->do_put(__s, __io, __fill, __v); } + ///@} + + /** + * @brief Numeric formatting. + * + * Formats the pointer value @a v and inserts it into a stream. It + * does so by calling num_put::do_put(). + * + * This function formats @a v as an unsigned long with ios_base::hex + * and ios_base::showbase set. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + const void* __v) const + { return this->do_put(__s, __io, __fill, __v); } + + protected: + template + iter_type + _M_insert_float(iter_type, ios_base& __io, char_type __fill, + char __mod, _ValueT __v) const; + + void + _M_group_float(const char* __grouping, size_t __grouping_size, + char_type __sep, const char_type* __p, char_type* __new, + char_type* __cs, int& __len) const; + + template + iter_type + _M_insert_int(iter_type, ios_base& __io, char_type __fill, + _ValueT __v) const; + + void + _M_group_int(const char* __grouping, size_t __grouping_size, + char_type __sep, ios_base& __io, char_type* __new, + char_type* __cs, int& __len) const; + + void + _M_pad(char_type __fill, streamsize __w, ios_base& __io, + char_type* __new, const char_type* __cs, int& __len) const; + + /// Destructor. + virtual + ~num_put() { } + + ///@{ + /** + * @brief Numeric formatting. + * + * These functions do the work of formatting numeric values and + * inserting them into a stream. This function is a hook for derived + * classes to change the value returned. + * + * @param __s Stream to write to. + * @param __io Source of locale and flags. + * @param __fill Char_type to use for filling. + * @param __v Value to format and insert. + * @return Iterator after writing. + */ + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const; + + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } + + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } + +#ifdef _GLIBCXX_USE_LONG_LONG + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, + long long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } + + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, + unsigned long long __v) const + { return _M_insert_int(__s, __io, __fill, __v); } +#endif + + virtual iter_type + do_put(iter_type, ios_base&, char_type, double) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + __do_put(iter_type, ios_base&, char_type, double) const; +#else + virtual iter_type + do_put(iter_type, ios_base&, char_type, long double) const; +#endif + + virtual iter_type + do_put(iter_type, ios_base&, char_type, const void*) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + virtual iter_type + __do_put(iter_type, ios_base&, char_type, __ibm128) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + virtual iter_type + do_put(iter_type, ios_base&, char_type, long double) const; +#endif + ///@} + }; + + template + locale::id num_put<_CharT, _OutIter>::id; + +_GLIBCXX_END_NAMESPACE_LDBL + + // Subclause convenience interfaces, inlines. + // NB: These are inline because, when used in a loop, some compilers + // can hoist the body out of the loop; then it's just as fast as the + // C is*() function. + + /// Convenience interface to ctype.is(ctype_base::space, __c). + template + inline bool + isspace(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::space, __c); } + + /// Convenience interface to ctype.is(ctype_base::print, __c). + template + inline bool + isprint(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::print, __c); } + + /// Convenience interface to ctype.is(ctype_base::cntrl, __c). + template + inline bool + iscntrl(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::cntrl, __c); } + + /// Convenience interface to ctype.is(ctype_base::upper, __c). + template + inline bool + isupper(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::upper, __c); } + + /// Convenience interface to ctype.is(ctype_base::lower, __c). + template + inline bool + islower(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::lower, __c); } + + /// Convenience interface to ctype.is(ctype_base::alpha, __c). + template + inline bool + isalpha(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::alpha, __c); } + + /// Convenience interface to ctype.is(ctype_base::digit, __c). + template + inline bool + isdigit(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::digit, __c); } + + /// Convenience interface to ctype.is(ctype_base::punct, __c). + template + inline bool + ispunct(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::punct, __c); } + + /// Convenience interface to ctype.is(ctype_base::xdigit, __c). + template + inline bool + isxdigit(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::xdigit, __c); } + + /// Convenience interface to ctype.is(ctype_base::alnum, __c). + template + inline bool + isalnum(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::alnum, __c); } + + /// Convenience interface to ctype.is(ctype_base::graph, __c). + template + inline bool + isgraph(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::graph, __c); } + +#if __cplusplus >= 201103L + /// Convenience interface to ctype.is(ctype_base::blank, __c). + template + inline bool + isblank(_CharT __c, const locale& __loc) + { return use_facet >(__loc).is(ctype_base::blank, __c); } +#endif + + /// Convenience interface to ctype.toupper(__c). + template + inline _CharT + toupper(_CharT __c, const locale& __loc) + { return use_facet >(__loc).toupper(__c); } + + /// Convenience interface to ctype.tolower(__c). + template + inline _CharT + tolower(_CharT __c, const locale& __loc) + { return use_facet >(__loc).tolower(__c); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +# include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets.tcc new file mode 100755 index 0000000..310bfed --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets.tcc @@ -0,0 +1,1404 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +#ifndef _LOCALE_FACETS_TCC +#define _LOCALE_FACETS_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Routine to access a cache for the facet. If the cache didn't + // exist before, it gets constructed on the fly. + template + struct __use_cache + { + const _Facet* + operator() (const locale& __loc) const; + }; + + // Specializations. + template + struct __use_cache<__numpunct_cache<_CharT> > + { + const __numpunct_cache<_CharT>* + operator() (const locale& __loc) const + { + const size_t __i = numpunct<_CharT>::id._M_id(); + const locale::facet** __caches = __loc._M_impl->_M_caches; + if (!__caches[__i]) + { + __numpunct_cache<_CharT>* __tmp = 0; + __try + { + __tmp = new __numpunct_cache<_CharT>; + __tmp->_M_cache(__loc); + } + __catch(...) + { + delete __tmp; + __throw_exception_again; + } + __loc._M_impl->_M_install_cache(__tmp, __i); + } + return static_cast*>(__caches[__i]); + } + }; + + template + void + __numpunct_cache<_CharT>::_M_cache(const locale& __loc) + { + const numpunct<_CharT>& __np = use_facet >(__loc); + + char* __grouping = 0; + _CharT* __truename = 0; + _CharT* __falsename = 0; + __try + { + const string& __g = __np.grouping(); + _M_grouping_size = __g.size(); + __grouping = new char[_M_grouping_size]; + __g.copy(__grouping, _M_grouping_size); + _M_use_grouping = (_M_grouping_size + && static_cast(__grouping[0]) > 0 + && (__grouping[0] + != __gnu_cxx::__numeric_traits::__max)); + + const basic_string<_CharT>& __tn = __np.truename(); + _M_truename_size = __tn.size(); + __truename = new _CharT[_M_truename_size]; + __tn.copy(__truename, _M_truename_size); + + const basic_string<_CharT>& __fn = __np.falsename(); + _M_falsename_size = __fn.size(); + __falsename = new _CharT[_M_falsename_size]; + __fn.copy(__falsename, _M_falsename_size); + + _M_decimal_point = __np.decimal_point(); + _M_thousands_sep = __np.thousands_sep(); + + const ctype<_CharT>& __ct = use_facet >(__loc); + __ct.widen(__num_base::_S_atoms_out, + __num_base::_S_atoms_out + + __num_base::_S_oend, _M_atoms_out); + __ct.widen(__num_base::_S_atoms_in, + __num_base::_S_atoms_in + + __num_base::_S_iend, _M_atoms_in); + + _M_grouping = __grouping; + _M_truename = __truename; + _M_falsename = __falsename; + _M_allocated = true; + } + __catch(...) + { + delete [] __grouping; + delete [] __truename; + delete [] __falsename; + __throw_exception_again; + } + } + + // Used by both numeric and monetary facets. + // Check to make sure that the __grouping_tmp string constructed in + // money_get or num_get matches the canonical grouping for a given + // locale. + // __grouping_tmp is parsed L to R + // 1,222,444 == __grouping_tmp of "\1\3\3" + // __grouping is parsed R to L + // 1,222,444 == __grouping of "\3" == "\3\3\3" + _GLIBCXX_PURE bool + __verify_grouping(const char* __grouping, size_t __grouping_size, + const string& __grouping_tmp) throw (); + +_GLIBCXX_BEGIN_NAMESPACE_LDBL + + template + _GLIBCXX_DEFAULT_ABI_TAG + _InIter + num_get<_CharT, _InIter>:: + _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io, + ios_base::iostate& __err, string& __xtrc) const + { + typedef char_traits<_CharT> __traits_type; + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + const _CharT* __lit = __lc->_M_atoms_in; + char_type __c = char_type(); + + // True if __beg becomes equal to __end. + bool __testeof = __beg == __end; + + // First check for sign. + if (!__testeof) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if ((__plus || __c == __lit[__num_base::_S_iminus]) + && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + { + __xtrc += __plus ? '+' : '-'; + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + } + + // Next, look for leading zeros. + bool __found_mantissa = false; + int __sep_pos = 0; + while (!__testeof) + { + if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + || __c == __lc->_M_decimal_point) + break; + else if (__c == __lit[__num_base::_S_izero]) + { + if (!__found_mantissa) + { + __xtrc += '0'; + __found_mantissa = true; + } + ++__sep_pos; + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + break; + } + + // Only need acceptable digits for floating point numbers. + bool __found_dec = false; + bool __found_sci = false; + string __found_grouping; + if (__lc->_M_use_grouping) + __found_grouping.reserve(32); + const char_type* __lit_zero = __lit + __num_base::_S_izero; + + if (!__lc->_M_allocated) + // "C" locale + while (!__testeof) + { + const int __digit = _M_find(__lit_zero, 10, __c); + if (__digit != -1) + { + __xtrc += '0' + __digit; + __found_mantissa = true; + } + else if (__c == __lc->_M_decimal_point + && !__found_dec && !__found_sci) + { + __xtrc += '.'; + __found_dec = true; + } + else if ((__c == __lit[__num_base::_S_ie] + || __c == __lit[__num_base::_S_iE]) + && !__found_sci && __found_mantissa) + { + // Scientific notation. + __xtrc += 'e'; + __found_sci = true; + + // Remove optional plus or minus sign, if they exist. + if (++__beg != __end) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if (__plus || __c == __lit[__num_base::_S_iminus]) + __xtrc += __plus ? '+' : '-'; + else + continue; + } + else + { + __testeof = true; + break; + } + } + else + break; + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + while (!__testeof) + { + // According to 22.2.2.1.2, p8-9, first look for thousands_sep + // and decimal_point. + if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + { + if (!__found_dec && !__found_sci) + { + // NB: Thousands separator at the beginning of a string + // is a no-no, as is two consecutive thousands separators. + if (__sep_pos) + { + __found_grouping += static_cast(__sep_pos); + __sep_pos = 0; + } + else + { + // NB: __convert_to_v will not assign __v and will + // set the failbit. + __xtrc.clear(); + break; + } + } + else + break; + } + else if (__c == __lc->_M_decimal_point) + { + if (!__found_dec && !__found_sci) + { + // If no grouping chars are seen, no grouping check + // is applied. Therefore __found_grouping is adjusted + // only if decimal_point comes after some thousands_sep. + if (__found_grouping.size()) + __found_grouping += static_cast(__sep_pos); + __xtrc += '.'; + __found_dec = true; + } + else + break; + } + else + { + const char_type* __q = + __traits_type::find(__lit_zero, 10, __c); + if (__q) + { + __xtrc += '0' + (__q - __lit_zero); + __found_mantissa = true; + ++__sep_pos; + } + else if ((__c == __lit[__num_base::_S_ie] + || __c == __lit[__num_base::_S_iE]) + && !__found_sci && __found_mantissa) + { + // Scientific notation. + if (__found_grouping.size() && !__found_dec) + __found_grouping += static_cast(__sep_pos); + __xtrc += 'e'; + __found_sci = true; + + // Remove optional plus or minus sign, if they exist. + if (++__beg != __end) + { + __c = *__beg; + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if ((__plus || __c == __lit[__num_base::_S_iminus]) + && !(__lc->_M_use_grouping + && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + __xtrc += __plus ? '+' : '-'; + else + continue; + } + else + { + __testeof = true; + break; + } + } + else + break; + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + + // Digit grouping is checked. If grouping and found_grouping don't + // match, then get very very upset, and set failbit. + if (__found_grouping.size()) + { + // Add the ending grouping if a decimal or 'e'/'E' wasn't found. + if (!__found_dec && !__found_sci) + __found_grouping += static_cast(__sep_pos); + + if (!std::__verify_grouping(__lc->_M_grouping, + __lc->_M_grouping_size, + __found_grouping)) + __err = ios_base::failbit; + } + + return __beg; + } + + template + template + _GLIBCXX_DEFAULT_ABI_TAG + _InIter + num_get<_CharT, _InIter>:: + _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io, + ios_base::iostate& __err, _ValueT& __v) const + { + typedef char_traits<_CharT> __traits_type; + using __gnu_cxx::__add_unsigned; + typedef typename __add_unsigned<_ValueT>::__type __unsigned_type; + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + const _CharT* __lit = __lc->_M_atoms_in; + char_type __c = char_type(); + + // NB: Iff __basefield == 0, __base can change based on contents. + const ios_base::fmtflags __basefield = __io.flags() + & ios_base::basefield; + const bool __oct = __basefield == ios_base::oct; + int __base = __oct ? 8 : (__basefield == ios_base::hex ? 16 : 10); + + // True if __beg becomes equal to __end. + bool __testeof = __beg == __end; + + // First check for sign. + bool __negative = false; + if (!__testeof) + { + __c = *__beg; + __negative = __c == __lit[__num_base::_S_iminus]; + if ((__negative || __c == __lit[__num_base::_S_iplus]) + && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + && !(__c == __lc->_M_decimal_point)) + { + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + } + + // Next, look for leading zeros and check required digits + // for base formats. + bool __found_zero = false; + int __sep_pos = 0; + while (!__testeof) + { + if ((__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + || __c == __lc->_M_decimal_point) + break; + else if (__c == __lit[__num_base::_S_izero] + && (!__found_zero || __base == 10)) + { + __found_zero = true; + ++__sep_pos; + if (__basefield == 0) + __base = 8; + if (__base == 8) + __sep_pos = 0; + } + else if (__found_zero + && (__c == __lit[__num_base::_S_ix] + || __c == __lit[__num_base::_S_iX])) + { + if (__basefield == 0) + __base = 16; + if (__base == 16) + { + __found_zero = false; + __sep_pos = 0; + } + else + break; + } + else + break; + + if (++__beg != __end) + { + __c = *__beg; + if (!__found_zero) + break; + } + else + __testeof = true; + } + + // At this point, base is determined. If not hex, only allow + // base digits as valid input. + const size_t __len = (__base == 16 ? __num_base::_S_iend + - __num_base::_S_izero : __base); + + // Extract. + typedef __gnu_cxx::__numeric_traits<_ValueT> __num_traits; + string __found_grouping; + if (__lc->_M_use_grouping) + __found_grouping.reserve(32); + bool __testfail = false; + bool __testoverflow = false; + const __unsigned_type __max = + (__negative && __num_traits::__is_signed) + ? -static_cast<__unsigned_type>(__num_traits::__min) + : __num_traits::__max; + const __unsigned_type __smax = __max / __base; + __unsigned_type __result = 0; + int __digit = 0; + const char_type* __lit_zero = __lit + __num_base::_S_izero; + + if (!__lc->_M_allocated) + // "C" locale + while (!__testeof) + { + __digit = _M_find(__lit_zero, __len, __c); + if (__digit == -1) + break; + + if (__result > __smax) + __testoverflow = true; + else + { + __result *= __base; + __testoverflow |= __result > __max - __digit; + __result += __digit; + ++__sep_pos; + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + else + while (!__testeof) + { + // According to 22.2.2.1.2, p8-9, first look for thousands_sep + // and decimal_point. + if (__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) + { + // NB: Thousands separator at the beginning of a string + // is a no-no, as is two consecutive thousands separators. + if (__sep_pos) + { + __found_grouping += static_cast(__sep_pos); + __sep_pos = 0; + } + else + { + __testfail = true; + break; + } + } + else if (__c == __lc->_M_decimal_point) + break; + else + { + const char_type* __q = + __traits_type::find(__lit_zero, __len, __c); + if (!__q) + break; + + __digit = __q - __lit_zero; + if (__digit > 15) + __digit -= 6; + if (__result > __smax) + __testoverflow = true; + else + { + __result *= __base; + __testoverflow |= __result > __max - __digit; + __result += __digit; + ++__sep_pos; + } + } + + if (++__beg != __end) + __c = *__beg; + else + __testeof = true; + } + + // Digit grouping is checked. If grouping and found_grouping don't + // match, then get very very upset, and set failbit. + if (__found_grouping.size()) + { + // Add the ending grouping. + __found_grouping += static_cast(__sep_pos); + + if (!std::__verify_grouping(__lc->_M_grouping, + __lc->_M_grouping_size, + __found_grouping)) + __err = ios_base::failbit; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + if ((!__sep_pos && !__found_zero && !__found_grouping.size()) + || __testfail) + { + __v = 0; + __err = ios_base::failbit; + } + else if (__testoverflow) + { + if (__negative && __num_traits::__is_signed) + __v = __num_traits::__min; + else + __v = __num_traits::__max; + __err = ios_base::failbit; + } + else + __v = __negative ? -__result : __result; + + if (__testeof) + __err |= ios_base::eofbit; + return __beg; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 17. Bad bool parsing + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, bool& __v) const + { + if (!(__io.flags() & ios_base::boolalpha)) + { + // Parse bool values as long. + // NB: We can't just call do_get(long) here, as it might + // refer to a derived class. + long __l = -1; + __beg = _M_extract_int(__beg, __end, __io, __err, __l); + if (__l == 0 || __l == 1) + __v = bool(__l); + else + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + __v = true; + __err = ios_base::failbit; + if (__beg == __end) + __err |= ios_base::eofbit; + } + } + else + { + // Parse bool values as alphanumeric. + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + + bool __testf = true; + bool __testt = true; + bool __donef = __lc->_M_falsename_size == 0; + bool __donet = __lc->_M_truename_size == 0; + bool __testeof = false; + size_t __n = 0; + while (!__donef || !__donet) + { + if (__beg == __end) + { + __testeof = true; + break; + } + + const char_type __c = *__beg; + + if (!__donef) + __testf = __c == __lc->_M_falsename[__n]; + + if (!__testf && __donet) + break; + + if (!__donet) + __testt = __c == __lc->_M_truename[__n]; + + if (!__testt && __donef) + break; + + if (!__testt && !__testf) + break; + + ++__n; + ++__beg; + + __donef = !__testf || __n >= __lc->_M_falsename_size; + __donet = !__testt || __n >= __lc->_M_truename_size; + } + if (__testf && __n == __lc->_M_falsename_size && __n) + { + __v = false; + if (__testt && __n == __lc->_M_truename_size) + __err = ios_base::failbit; + else + __err = __testeof ? ios_base::eofbit : ios_base::goodbit; + } + else if (__testt && __n == __lc->_M_truename_size && __n) + { + __v = true; + __err = __testeof ? ios_base::eofbit : ios_base::goodbit; + } + else + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 23. Num_get overflow result. + __v = false; + __err = ios_base::failbit; + if (__testeof) + __err |= ios_base::eofbit; + } + } + return __beg; + } + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, float& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _InIter + num_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } +#endif + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, long double& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + num_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, void*& __v) const + { + // Prepare for hex formatted input. + typedef ios_base::fmtflags fmtflags; + const fmtflags __fmt = __io.flags(); + __io.flags((__fmt & ~ios_base::basefield) | ios_base::hex); + + typedef __gnu_cxx::__conditional_type<(sizeof(void*) + <= sizeof(unsigned long)), + unsigned long, unsigned long long>::__type _UIntPtrType; + + _UIntPtrType __ul; + __beg = _M_extract_int(__beg, __end, __io, __err, __ul); + + // Reset from hex formatted input. + __io.flags(__fmt); + + __v = reinterpret_cast(__ul); + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _InIter + num_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, __ibm128& __v) const + { + string __xtrc; + __xtrc.reserve(32); + __beg = _M_extract_float(__beg, __end, __io, __err, __xtrc); + std::__convert_to_v(__xtrc.c_str(), __v, __err, _S_get_c_locale()); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } +#endif + + // For use by integer and floating-point types after they have been + // converted into a char_type string. + template + void + num_put<_CharT, _OutIter>:: + _M_pad(_CharT __fill, streamsize __w, ios_base& __io, + _CharT* __new, const _CharT* __cs, int& __len) const + { + // [22.2.2.2.2] Stage 3. + // If necessary, pad. + __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, + __cs, __w, __len); + __len = static_cast(__w); + } + +_GLIBCXX_END_NAMESPACE_LDBL + + template + int + __int_to_char(_CharT* __bufend, _ValueT __v, const _CharT* __lit, + ios_base::fmtflags __flags, bool __dec) + { + _CharT* __buf = __bufend; + if (__builtin_expect(__dec, true)) + { + // Decimal. + do + { + *--__buf = __lit[(__v % 10) + __num_base::_S_odigits]; + __v /= 10; + } + while (__v != 0); + } + else if ((__flags & ios_base::basefield) == ios_base::oct) + { + // Octal. + do + { + *--__buf = __lit[(__v & 0x7) + __num_base::_S_odigits]; + __v >>= 3; + } + while (__v != 0); + } + else + { + // Hex. + const bool __uppercase = __flags & ios_base::uppercase; + const int __case_offset = __uppercase ? __num_base::_S_oudigits + : __num_base::_S_odigits; + do + { + *--__buf = __lit[(__v & 0xf) + __case_offset]; + __v >>= 4; + } + while (__v != 0); + } + return __bufend - __buf; + } + +_GLIBCXX_BEGIN_NAMESPACE_LDBL + + template + void + num_put<_CharT, _OutIter>:: + _M_group_int(const char* __grouping, size_t __grouping_size, _CharT __sep, + ios_base&, _CharT* __new, _CharT* __cs, int& __len) const + { + _CharT* __p = std::__add_grouping(__new, __sep, __grouping, + __grouping_size, __cs, __cs + __len); + __len = __p - __new; + } + + template + template + _OutIter + num_put<_CharT, _OutIter>:: + _M_insert_int(_OutIter __s, ios_base& __io, _CharT __fill, + _ValueT __v) const + { + using __gnu_cxx::__add_unsigned; + typedef typename __add_unsigned<_ValueT>::__type __unsigned_type; + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + const _CharT* __lit = __lc->_M_atoms_out; + const ios_base::fmtflags __flags = __io.flags(); + + // Long enough to hold hex, dec, and octal representations. + const int __ilen = 5 * sizeof(_ValueT); + _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __ilen)); + + // [22.2.2.2.2] Stage 1, numeric conversion to character. + // Result is returned right-justified in the buffer. + const ios_base::fmtflags __basefield = __flags & ios_base::basefield; + const bool __dec = (__basefield != ios_base::oct + && __basefield != ios_base::hex); + const __unsigned_type __u = ((__v > 0 || !__dec) + ? __unsigned_type(__v) + : -__unsigned_type(__v)); + int __len = __int_to_char(__cs + __ilen, __u, __lit, __flags, __dec); + __cs += __ilen - __len; + + // Add grouping, if necessary. + if (__lc->_M_use_grouping) + { + // Grouping can add (almost) as many separators as the number + // of digits + space is reserved for numeric base or sign. + _CharT* __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * (__len + 1) + * 2)); + _M_group_int(__lc->_M_grouping, __lc->_M_grouping_size, + __lc->_M_thousands_sep, __io, __cs2 + 2, __cs, __len); + __cs = __cs2 + 2; + } + + // Complete Stage 1, prepend numeric base or sign. + if (__builtin_expect(__dec, true)) + { + // Decimal. + if (__v >= 0) + { + if (bool(__flags & ios_base::showpos) + && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed) + *--__cs = __lit[__num_base::_S_oplus], ++__len; + } + else + *--__cs = __lit[__num_base::_S_ominus], ++__len; + } + else if (bool(__flags & ios_base::showbase) && __v) + { + if (__basefield == ios_base::oct) + *--__cs = __lit[__num_base::_S_odigits], ++__len; + else + { + // 'x' or 'X' + const bool __uppercase = __flags & ios_base::uppercase; + *--__cs = __lit[__num_base::_S_ox + __uppercase]; + // '0' + *--__cs = __lit[__num_base::_S_odigits]; + __len += 2; + } + } + + // Pad. + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + _CharT* __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __w)); + _M_pad(__fill, __w, __io, __cs3, __cs, __len); + __cs = __cs3; + } + __io.width(0); + + // [22.2.2.2.2] Stage 4. + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __cs, __len); + } + + template + void + num_put<_CharT, _OutIter>:: + _M_group_float(const char* __grouping, size_t __grouping_size, + _CharT __sep, const _CharT* __p, _CharT* __new, + _CharT* __cs, int& __len) const + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 282. What types does numpunct grouping refer to? + // Add grouping, if necessary. + const int __declen = __p ? __p - __cs : __len; + _CharT* __p2 = std::__add_grouping(__new, __sep, __grouping, + __grouping_size, + __cs, __cs + __declen); + + // Tack on decimal part. + int __newlen = __p2 - __new; + if (__p) + { + char_traits<_CharT>::copy(__p2, __p, __len - __declen); + __newlen += __len - __declen; + } + __len = __newlen; + } + + // The following code uses vsnprintf (or vsprintf(), when + // _GLIBCXX_USE_C99_STDIO is not defined) to convert floating point + // values for insertion into a stream. An optimization would be to + // replace them with code that works directly on a wide buffer and + // then use __pad to do the padding. It would be good to replace + // them anyway to gain back the efficiency that C++ provides by + // knowing up front the type of the values to insert. Also, sprintf + // is dangerous since may lead to accidental buffer overruns. This + // implementation follows the C++ standard fairly directly as + // outlined in 22.2.2.2 [lib.locale.num.put] + template + template + _OutIter + num_put<_CharT, _OutIter>:: + _M_insert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod, + _ValueT __v) const + { + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + + // Use default precision if out of range. + const streamsize __prec = __io.precision() < 0 ? 6 : __io.precision(); + + const int __max_digits = + __gnu_cxx::__numeric_traits<_ValueT>::__digits10; + + // [22.2.2.2.2] Stage 1, numeric conversion to character. + int __len; + // Long enough for the max format spec. + char __fbuf[16]; + __num_base::_S_format_float(__io, __fbuf, __mod); + +#if _GLIBCXX_USE_C99_STDIO && !_GLIBCXX_HAVE_BROKEN_VSNPRINTF + // Precision is always used except for hexfloat format. + const bool __use_prec = + (__io.flags() & ios_base::floatfield) != ios_base::floatfield; + + // First try a buffer perhaps big enough (most probably sufficient + // for non-ios_base::fixed outputs) + int __cs_size = __max_digits * 3; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); + + // If the buffer was not large enough, try again with the correct size. + if (__len >= __cs_size) + { + __cs_size = __len + 1; + __cs = static_cast(__builtin_alloca(__cs_size)); + if (__use_prec) + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __prec, __v); + else + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + __fbuf, __v); + } +#else + // Consider the possibility of long ios_base::fixed outputs + const bool __fixed = __io.flags() & ios_base::fixed; + const int __max_exp = + __gnu_cxx::__numeric_traits<_ValueT>::__max_exponent10; + + // The size of the output string is computed as follows. + // ios_base::fixed outputs may need up to __max_exp + 1 chars + // for the integer part + __prec chars for the fractional part + // + 3 chars for sign, decimal point, '\0'. On the other hand, + // for non-fixed outputs __max_digits * 2 + __prec chars are + // largely sufficient. + const int __cs_size = __fixed ? __max_exp + __prec + 4 + : __max_digits * 2 + __prec; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf, + __prec, __v); +#endif + + // [22.2.2.2.2] Stage 2, convert to char_type, using correct + // numpunct.decimal_point() values for '.' and adding grouping. + const ctype<_CharT>& __ctype = use_facet >(__loc); + + _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __len)); + __ctype.widen(__cs, __cs + __len, __ws); + + // Replace decimal point. + _CharT* __wp = 0; + const char* __p = char_traits::find(__cs, __len, '.'); + if (__p) + { + __wp = __ws + (__p - __cs); + *__wp = __lc->_M_decimal_point; + } + + // Add grouping, if necessary. + // N.B. Make sure to not group things like 2e20, i.e., no decimal + // point, scientific notation. + if (__lc->_M_use_grouping + && (__wp || __len < 3 || (__cs[1] <= '9' && __cs[2] <= '9' + && __cs[1] >= '0' && __cs[2] >= '0'))) + { + // Grouping can add (almost) as many separators as the + // number of digits, but no more. + _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __len * 2)); + + streamsize __off = 0; + if (__cs[0] == '-' || __cs[0] == '+') + { + __off = 1; + __ws2[0] = __ws[0]; + __len -= 1; + } + + _M_group_float(__lc->_M_grouping, __lc->_M_grouping_size, + __lc->_M_thousands_sep, __wp, __ws2 + __off, + __ws + __off, __len); + __len += __off; + + __ws = __ws2; + } + + // Pad. + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + _CharT* __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __w)); + _M_pad(__fill, __w, __io, __ws3, __ws, __len); + __ws = __ws3; + } + __io.width(0); + + // [22.2.2.2.2] Stage 4. + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __ws, __len); + } + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, bool __v) const + { + const ios_base::fmtflags __flags = __io.flags(); + if ((__flags & ios_base::boolalpha) == 0) + { + const long __l = __v; + __s = _M_insert_int(__s, __io, __fill, __l); + } + else + { + typedef __numpunct_cache<_CharT> __cache_type; + __use_cache<__cache_type> __uc; + const locale& __loc = __io._M_getloc(); + const __cache_type* __lc = __uc(__loc); + + const _CharT* __name = __v ? __lc->_M_truename + : __lc->_M_falsename; + int __len = __v ? __lc->_M_truename_size + : __lc->_M_falsename_size; + + const streamsize __w = __io.width(); + if (__w > static_cast(__len)) + { + const streamsize __plen = __w - __len; + _CharT* __ps + = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) + * __plen)); + + char_traits<_CharT>::assign(__ps, __plen, __fill); + __io.width(0); + + if ((__flags & ios_base::adjustfield) == ios_base::left) + { + __s = std::__write(__s, __name, __len); + __s = std::__write(__s, __ps, __plen); + } + else + { + __s = std::__write(__s, __ps, __plen); + __s = std::__write(__s, __name, __len); + } + return __s; + } + __io.width(0); + __s = std::__write(__s, __name, __len); + } + return __s; + } + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return _M_insert_float(__s, __io, __fill, char(), __v); } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ + template + _OutIter + num_put<_CharT, _OutIter>:: + __do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const + { return _M_insert_float(__s, __io, __fill, char(), __v); } +#endif + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, + long double __v) const + { return _M_insert_float(__s, __io, __fill, 'L', __v); } + + template + _OutIter + num_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type __fill, + const void* __v) const + { + const ios_base::fmtflags __flags = __io.flags(); + const ios_base::fmtflags __fmt = ~(ios_base::basefield + | ios_base::uppercase); + __io.flags((__flags & __fmt) | (ios_base::hex | ios_base::showbase)); + + typedef __gnu_cxx::__conditional_type<(sizeof(const void*) + <= sizeof(unsigned long)), + unsigned long, unsigned long long>::__type _UIntPtrType; + + __s = _M_insert_int(__s, __io, __fill, + reinterpret_cast<_UIntPtrType>(__v)); + __io.flags(__flags); + return __s; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _OutIter + num_put<_CharT, _OutIter>:: + __do_put(iter_type __s, ios_base& __io, char_type __fill, + __ibm128 __v) const + { return _M_insert_float(__s, __io, __fill, 'L', __v); } +#endif +_GLIBCXX_END_NAMESPACE_LDBL + + // Construct correctly padded string, as per 22.2.2.2.2 + // Assumes + // __newlen > __oldlen + // __news is allocated for __newlen size + + // NB: Of the two parameters, _CharT can be deduced from the + // function arguments. The other (_Traits) has to be explicitly specified. + template + void + __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, + _CharT* __news, const _CharT* __olds, + streamsize __newlen, streamsize __oldlen) + { + const size_t __plen = static_cast(__newlen - __oldlen); + const ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield; + + // Padding last. + if (__adjust == ios_base::left) + { + _Traits::copy(__news, __olds, __oldlen); + _Traits::assign(__news + __oldlen, __plen, __fill); + return; + } + + size_t __mod = 0; + if (__adjust == ios_base::internal) + { + // Pad after the sign, if there is one. + // Pad after 0[xX], if there is one. + // Who came up with these rules, anyway? Jeeze. + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + if (__ctype.widen('-') == __olds[0] + || __ctype.widen('+') == __olds[0]) + { + __news[0] = __olds[0]; + __mod = 1; + ++__news; + } + else if (__ctype.widen('0') == __olds[0] + && __oldlen > 1 + && (__ctype.widen('x') == __olds[1] + || __ctype.widen('X') == __olds[1])) + { + __news[0] = __olds[0]; + __news[1] = __olds[1]; + __mod = 2; + __news += 2; + } + // else Padding first. + } + _Traits::assign(__news, __plen, __fill); + _Traits::copy(__news + __plen, __olds + __mod, __oldlen - __mod); + } + + template + _CharT* + __add_grouping(_CharT* __s, _CharT __sep, + const char* __gbeg, size_t __gsize, + const _CharT* __first, const _CharT* __last) + { + size_t __idx = 0; + size_t __ctr = 0; + + while (__last - __first > __gbeg[__idx] + && static_cast(__gbeg[__idx]) > 0 + && __gbeg[__idx] != __gnu_cxx::__numeric_traits::__max) + { + __last -= __gbeg[__idx]; + __idx < __gsize - 1 ? ++__idx : ++__ctr; + } + + while (__first != __last) + *__s++ = *__first++; + + while (__ctr--) + { + *__s++ = __sep; + for (char __i = __gbeg[__idx]; __i > 0; --__i) + *__s++ = *__first++; + } + + while (__idx--) + { + *__s++ = __sep; + for (char __i = __gbeg[__idx]; __i > 0; --__i) + *__s++ = *__first++; + } + + return __s; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct; + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL num_get; + extern template class _GLIBCXX_NAMESPACE_LDBL num_put; + extern template class ctype_byname; + + extern template + const ctype& + use_facet >(const locale&); + + extern template + const numpunct& + use_facet >(const locale&); + + extern template + const num_put& + use_facet >(const locale&); + + extern template + const num_get& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct; + extern template class _GLIBCXX_NAMESPACE_CXX11 numpunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL num_get; + extern template class _GLIBCXX_NAMESPACE_LDBL num_put; + extern template class ctype_byname; + + extern template + const ctype& + use_facet >(const locale&); + + extern template + const numpunct& + use_facet >(const locale&); + + extern template + const num_put& + use_facet >(const locale&); + + extern template + const num_get& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets_nonio.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets_nonio.h new file mode 100755 index 0000000..e518df9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets_nonio.h @@ -0,0 +1,2033 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets_nonio.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_FACETS_NONIO_H +#define _LOCALE_FACETS_NONIO_H 1 + +#pragma GCC system_header + +#include // For struct tm + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Time format ordering data. + * @ingroup locales + * + * This class provides an enum representing different orderings of + * time: day, month, and year. + */ + class time_base + { + public: + enum dateorder { no_order, dmy, mdy, ymd, ydm }; + }; + + template + struct __timepunct_cache : public locale::facet + { + // List of all known timezones, with GMT first. + static const _CharT* _S_timezones[14]; + + const _CharT* _M_date_format; + const _CharT* _M_date_era_format; + const _CharT* _M_time_format; + const _CharT* _M_time_era_format; + const _CharT* _M_date_time_format; + const _CharT* _M_date_time_era_format; + const _CharT* _M_am; + const _CharT* _M_pm; + const _CharT* _M_am_pm_format; + + // Day names, starting with "C"'s Sunday. + const _CharT* _M_day1; + const _CharT* _M_day2; + const _CharT* _M_day3; + const _CharT* _M_day4; + const _CharT* _M_day5; + const _CharT* _M_day6; + const _CharT* _M_day7; + + // Abbreviated day names, starting with "C"'s Sun. + const _CharT* _M_aday1; + const _CharT* _M_aday2; + const _CharT* _M_aday3; + const _CharT* _M_aday4; + const _CharT* _M_aday5; + const _CharT* _M_aday6; + const _CharT* _M_aday7; + + // Month names, starting with "C"'s January. + const _CharT* _M_month01; + const _CharT* _M_month02; + const _CharT* _M_month03; + const _CharT* _M_month04; + const _CharT* _M_month05; + const _CharT* _M_month06; + const _CharT* _M_month07; + const _CharT* _M_month08; + const _CharT* _M_month09; + const _CharT* _M_month10; + const _CharT* _M_month11; + const _CharT* _M_month12; + + // Abbreviated month names, starting with "C"'s Jan. + const _CharT* _M_amonth01; + const _CharT* _M_amonth02; + const _CharT* _M_amonth03; + const _CharT* _M_amonth04; + const _CharT* _M_amonth05; + const _CharT* _M_amonth06; + const _CharT* _M_amonth07; + const _CharT* _M_amonth08; + const _CharT* _M_amonth09; + const _CharT* _M_amonth10; + const _CharT* _M_amonth11; + const _CharT* _M_amonth12; + + bool _M_allocated; + + __timepunct_cache(size_t __refs = 0) : facet(__refs), + _M_date_format(0), _M_date_era_format(0), _M_time_format(0), + _M_time_era_format(0), _M_date_time_format(0), + _M_date_time_era_format(0), _M_am(0), _M_pm(0), + _M_am_pm_format(0), _M_day1(0), _M_day2(0), _M_day3(0), + _M_day4(0), _M_day5(0), _M_day6(0), _M_day7(0), + _M_aday1(0), _M_aday2(0), _M_aday3(0), _M_aday4(0), + _M_aday5(0), _M_aday6(0), _M_aday7(0), _M_month01(0), + _M_month02(0), _M_month03(0), _M_month04(0), _M_month05(0), + _M_month06(0), _M_month07(0), _M_month08(0), _M_month09(0), + _M_month10(0), _M_month11(0), _M_month12(0), _M_amonth01(0), + _M_amonth02(0), _M_amonth03(0), _M_amonth04(0), + _M_amonth05(0), _M_amonth06(0), _M_amonth07(0), + _M_amonth08(0), _M_amonth09(0), _M_amonth10(0), + _M_amonth11(0), _M_amonth12(0), _M_allocated(false) + { } + + ~__timepunct_cache(); + + private: + __timepunct_cache& + operator=(const __timepunct_cache&); + + explicit + __timepunct_cache(const __timepunct_cache&); + }; + + template + __timepunct_cache<_CharT>::~__timepunct_cache() + { + if (_M_allocated) + { + // Unused. + } + } + + // Specializations. + template<> + const char* + __timepunct_cache::_S_timezones[14]; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + const wchar_t* + __timepunct_cache::_S_timezones[14]; +#endif + + // Generic. + template + const _CharT* __timepunct_cache<_CharT>::_S_timezones[14]; + + template + class __timepunct : public locale::facet + { + public: + // Types: + typedef _CharT __char_type; + typedef __timepunct_cache<_CharT> __cache_type; + + protected: + __cache_type* _M_data; + __c_locale _M_c_locale_timepunct; + const char* _M_name_timepunct; + + public: + /// Numpunct facet id. + static locale::id id; + + explicit + __timepunct(size_t __refs = 0); + + explicit + __timepunct(__cache_type* __cache, size_t __refs = 0); + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __s The name of a locale. + * @param refs Passed to the base facet class. + */ + explicit + __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0); + + // FIXME: for error checking purposes _M_put should return the return + // value of strftime/wcsftime. + void + _M_put(_CharT* __s, size_t __maxlen, const _CharT* __format, + const tm* __tm) const throw (); + + void + _M_date_formats(const _CharT** __date) const + { + // Always have default first. + __date[0] = _M_data->_M_date_format; + __date[1] = _M_data->_M_date_era_format; + } + + void + _M_time_formats(const _CharT** __time) const + { + // Always have default first. + __time[0] = _M_data->_M_time_format; + __time[1] = _M_data->_M_time_era_format; + } + + void + _M_date_time_formats(const _CharT** __dt) const + { + // Always have default first. + __dt[0] = _M_data->_M_date_time_format; + __dt[1] = _M_data->_M_date_time_era_format; + } + +#if !_GLIBCXX_INLINE_VERSION + void + _M_am_pm_format(const _CharT*) const + { /* Kept for ABI compatibility, see PR65927 */ } +#endif + + void + _M_am_pm(const _CharT** __ampm) const + { + __ampm[0] = _M_data->_M_am; + __ampm[1] = _M_data->_M_pm; + } + + void + _M_days(const _CharT** __days) const + { + __days[0] = _M_data->_M_day1; + __days[1] = _M_data->_M_day2; + __days[2] = _M_data->_M_day3; + __days[3] = _M_data->_M_day4; + __days[4] = _M_data->_M_day5; + __days[5] = _M_data->_M_day6; + __days[6] = _M_data->_M_day7; + } + + void + _M_days_abbreviated(const _CharT** __days) const + { + __days[0] = _M_data->_M_aday1; + __days[1] = _M_data->_M_aday2; + __days[2] = _M_data->_M_aday3; + __days[3] = _M_data->_M_aday4; + __days[4] = _M_data->_M_aday5; + __days[5] = _M_data->_M_aday6; + __days[6] = _M_data->_M_aday7; + } + + void + _M_months(const _CharT** __months) const + { + __months[0] = _M_data->_M_month01; + __months[1] = _M_data->_M_month02; + __months[2] = _M_data->_M_month03; + __months[3] = _M_data->_M_month04; + __months[4] = _M_data->_M_month05; + __months[5] = _M_data->_M_month06; + __months[6] = _M_data->_M_month07; + __months[7] = _M_data->_M_month08; + __months[8] = _M_data->_M_month09; + __months[9] = _M_data->_M_month10; + __months[10] = _M_data->_M_month11; + __months[11] = _M_data->_M_month12; + } + + void + _M_months_abbreviated(const _CharT** __months) const + { + __months[0] = _M_data->_M_amonth01; + __months[1] = _M_data->_M_amonth02; + __months[2] = _M_data->_M_amonth03; + __months[3] = _M_data->_M_amonth04; + __months[4] = _M_data->_M_amonth05; + __months[5] = _M_data->_M_amonth06; + __months[6] = _M_data->_M_amonth07; + __months[7] = _M_data->_M_amonth08; + __months[8] = _M_data->_M_amonth09; + __months[9] = _M_data->_M_amonth10; + __months[10] = _M_data->_M_amonth11; + __months[11] = _M_data->_M_amonth12; + } + + protected: + virtual + ~__timepunct(); + + // For use at construction time only. + void + _M_initialize_timepunct(__c_locale __cloc = 0); + }; + + template + locale::id __timepunct<_CharT>::id; + + // Specializations. + template<> + void + __timepunct::_M_initialize_timepunct(__c_locale __cloc); + + template<> + void + __timepunct::_M_put(char*, size_t, const char*, const tm*) const throw (); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + void + __timepunct::_M_initialize_timepunct(__c_locale __cloc); + + template<> + void + __timepunct::_M_put(wchar_t*, size_t, const wchar_t*, + const tm*) const throw (); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + + // Include host and configuration specific timepunct functions. + #include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template time_get. + * @ingroup locales + * + * This facet encapsulates the code to parse and return a date or + * time from a string. It is used by the istream numeric + * extraction operators. + * + * The time_get template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the time_get facet. + */ + template + class time_get : public locale::facet, public time_base + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _InIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + time_get(size_t __refs = 0) + : facet (__refs) { } + + /** + * @brief Return preferred order of month, day, and year. + * + * This function returns an enum from time_base::dateorder giving the + * preferred ordering if the format @a x given to time_put::put() only + * uses month, day, and year. If the format @a x for the associated + * locale uses other fields, this function returns + * time_base::dateorder::noorder. + * + * NOTE: The library always returns noorder at the moment. + * + * @return A member of time_base::dateorder. + */ + dateorder + date_order() const + { return this->do_date_order(); } + + /** + * @brief Parse input time string. + * + * This function parses a time according to the format @a X and puts the + * results into a user-supplied struct tm. The result is returned by + * calling time_get::do_get_time(). + * + * If there is a valid time string according to format @a X, @a tm will + * be filled in accordingly and the returned iterator will point to the + * first character beyond the time string. If an error occurs before + * the end, err |= ios_base::failbit. If parsing reads all the + * characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond time string. + */ + iter_type + get_time(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_time(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input date string. + * + * This function parses a date according to the format @a x and puts the + * results into a user-supplied struct tm. The result is returned by + * calling time_get::do_get_date(). + * + * If there is a valid date string according to format @a x, @a tm will + * be filled in accordingly and the returned iterator will point to the + * first character beyond the date string. If an error occurs before + * the end, err |= ios_base::failbit. If parsing reads all the + * characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond date string. + */ + iter_type + get_date(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_date(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input weekday string. + * + * This function parses a weekday name and puts the results into a + * user-supplied struct tm. The result is returned by calling + * time_get::do_get_weekday(). + * + * Parsing starts by parsing an abbreviated weekday name. If a valid + * abbreviation is followed by a character that would lead to the full + * weekday name, parsing continues until the full name is found or an + * error occurs. Otherwise parsing finishes at the end of the + * abbreviated name. + * + * If an error occurs before the end, err |= ios_base::failbit. If + * parsing reads all the characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond weekday name. + */ + iter_type + get_weekday(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_weekday(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input month string. + * + * This function parses a month name and puts the results into a + * user-supplied struct tm. The result is returned by calling + * time_get::do_get_monthname(). + * + * Parsing starts by parsing an abbreviated month name. If a valid + * abbreviation is followed by a character that would lead to the full + * month name, parsing continues until the full name is found or an + * error occurs. Otherwise parsing finishes at the end of the + * abbreviated name. + * + * If an error occurs before the end, err |= ios_base::failbit. If + * parsing reads all the characters, err |= + * ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond month name. + */ + iter_type + get_monthname(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_monthname(__beg, __end, __io, __err, __tm); } + + /** + * @brief Parse input year string. + * + * This function reads up to 4 characters to parse a year string and + * puts the results into a user-supplied struct tm. The result is + * returned by calling time_get::do_get_year(). + * + * 4 consecutive digits are interpreted as a full year. If there are + * exactly 2 consecutive digits, the library interprets this as the + * number of years since 1900. + * + * If an error occurs before the end, err |= ios_base::failbit. If + * parsing reads all the characters, err |= ios_base::eofbit. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond year. + */ + iter_type + get_year(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { return this->do_get_year(__beg, __end, __io, __err, __tm); } + +#if __cplusplus >= 201103L + /** + * @brief Parse input string according to format. + * + * This function calls time_get::do_get with the provided + * parameters. @see do_get() and get(). + * + * @param __s Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @param __format Format specifier. + * @param __modifier Format modifier. + * @return Iterator to first char not parsed. + */ + inline + iter_type get(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, char __format, + char __modifier = 0) const + { + return this->do_get(__s, __end, __io, __err, __tm, __format, + __modifier); + } + + /** + * @brief Parse input string according to format. + * + * This function parses the input string according to a + * provided format string. It does the inverse of + * time_put::put. The format string follows the format + * specified for strftime(3)/strptime(3). The actual parsing + * is done by time_get::do_get. + * + * @param __s Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @param __fmt Start of the format string. + * @param __fmtend End of the format string. + * @return Iterator to first char not parsed. + */ + iter_type get(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, const char_type* __fmt, + const char_type* __fmtend) const; +#endif // __cplusplus >= 201103L + + protected: + /// Destructor. + virtual + ~time_get() { } + + /** + * @brief Return preferred order of month, day, and year. + * + * This function returns an enum from time_base::dateorder giving the + * preferred ordering if the format @a x given to time_put::put() only + * uses month, day, and year. This function is a hook for derived + * classes to change the value returned. + * + * @return A member of time_base::dateorder. + */ + virtual dateorder + do_date_order() const; + + /** + * @brief Parse input time string. + * + * This function parses a time according to the format @a x and puts the + * results into a user-supplied struct tm. This function is a hook for + * derived classes to change the value returned. @see get_time() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond time string. + */ + virtual iter_type + do_get_time(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input date string. + * + * This function parses a date according to the format @a X and puts the + * results into a user-supplied struct tm. This function is a hook for + * derived classes to change the value returned. @see get_date() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond date string. + */ + virtual iter_type + do_get_date(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input weekday string. + * + * This function parses a weekday name and puts the results into a + * user-supplied struct tm. This function is a hook for derived + * classes to change the value returned. @see get_weekday() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond weekday name. + */ + virtual iter_type + do_get_weekday(iter_type __beg, iter_type __end, ios_base&, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input month string. + * + * This function parses a month name and puts the results into a + * user-supplied struct tm. This function is a hook for derived + * classes to change the value returned. @see get_monthname() for + * details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond month name. + */ + virtual iter_type + do_get_monthname(iter_type __beg, iter_type __end, ios_base&, + ios_base::iostate& __err, tm* __tm) const; + + /** + * @brief Parse input year string. + * + * This function reads up to 4 characters to parse a year string and + * puts the results into a user-supplied struct tm. This function is a + * hook for derived classes to change the value returned. @see + * get_year() for details. + * + * @param __beg Start of string to parse. + * @param __end End of string to parse. + * @param __io Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @return Iterator to first char beyond year. + */ + virtual iter_type + do_get_year(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const; + +#if __cplusplus >= 201103L + /** + * @brief Parse input string according to format. + * + * This function parses the string according to the provided + * format and optional modifier. This function is a hook for + * derived classes to change the value returned. @see get() + * for more details. + * + * @param __s Start of string to parse. + * @param __end End of string to parse. + * @param __f Source of the locale. + * @param __err Error flags to set. + * @param __tm Pointer to struct tm to fill in. + * @param __format Format specifier. + * @param __modifier Format modifier. + * @return Iterator to first char not parsed. + */ +#if _GLIBCXX_USE_CXX11_ABI + virtual +#endif + iter_type + do_get(iter_type __s, iter_type __end, ios_base& __f, + ios_base::iostate& __err, tm* __tm, + char __format, char __modifier) const; +#endif // __cplusplus >= 201103L + + // Extract numeric component of length __len. + iter_type + _M_extract_num(iter_type __beg, iter_type __end, int& __member, + int __min, int __max, size_t __len, + ios_base& __io, ios_base::iostate& __err) const; + + // Extract any unique array of string literals in a const _CharT* array. + iter_type + _M_extract_name(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const; + + // Extract day or month name in a const _CharT* array. + iter_type + _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const; + + // Extract on a component-by-component basis, via __format argument. + iter_type + _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + const _CharT* __format) const; + }; + + template + locale::id time_get<_CharT, _InIter>::id; + + /// class time_get_byname [22.2.5.2]. + template + class time_get_byname : public time_get<_CharT, _InIter> + { + public: + // Types: + typedef _CharT char_type; + typedef _InIter iter_type; + + explicit + time_get_byname(const char*, size_t __refs = 0) + : time_get<_CharT, _InIter>(__refs) { } + +#if __cplusplus >= 201103L + explicit + time_get_byname(const string& __s, size_t __refs = 0) + : time_get_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~time_get_byname() { } + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + + /** + * @brief Primary class template time_put. + * @ingroup locales + * + * This facet encapsulates the code to format and output dates and times + * according to formats used by strftime(). + * + * The time_put template uses protected virtual functions to provide the + * actual results. The public accessors forward the call to the virtual + * functions. These virtual functions are hooks for developers to + * implement the behavior they require from the time_put facet. + */ + template + class time_put : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _OutIter iter_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + time_put(size_t __refs = 0) + : facet(__refs) { } + + /** + * @brief Format and output a time or date. + * + * This function formats the data in struct tm according to the + * provided format string. The format string is interpreted as by + * strftime(). + * + * @param __s The stream to write to. + * @param __io Source of locale. + * @param __fill char_type to use for padding. + * @param __tm Struct tm with date and time info to format. + * @param __beg Start of format string. + * @param __end End of format string. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, + const _CharT* __beg, const _CharT* __end) const; + + /** + * @brief Format and output a time or date. + * + * This function formats the data in struct tm according to the + * provided format char and optional modifier. The format and modifier + * are interpreted as by strftime(). It does so by returning + * time_put::do_put(). + * + * @param __s The stream to write to. + * @param __io Source of locale. + * @param __fill char_type to use for padding. + * @param __tm Struct tm with date and time info to format. + * @param __format Format char. + * @param __mod Optional modifier char. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, ios_base& __io, char_type __fill, + const tm* __tm, char __format, char __mod = 0) const + { return this->do_put(__s, __io, __fill, __tm, __format, __mod); } + + protected: + /// Destructor. + virtual + ~time_put() + { } + + /** + * @brief Format and output a time or date. + * + * This function formats the data in struct tm according to the + * provided format char and optional modifier. This function is a hook + * for derived classes to change the value returned. @see put() for + * more details. + * + * @param __s The stream to write to. + * @param __io Source of locale. + * @param __fill char_type to use for padding. + * @param __tm Struct tm with date and time info to format. + * @param __format Format char. + * @param __mod Optional modifier char. + * @return Iterator after writing. + */ + virtual iter_type + do_put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, + char __format, char __mod) const; + }; + + template + locale::id time_put<_CharT, _OutIter>::id; + + /// class time_put_byname [22.2.5.4]. + template + class time_put_byname : public time_put<_CharT, _OutIter> + { + public: + // Types: + typedef _CharT char_type; + typedef _OutIter iter_type; + + explicit + time_put_byname(const char*, size_t __refs = 0) + : time_put<_CharT, _OutIter>(__refs) + { } + +#if __cplusplus >= 201103L + explicit + time_put_byname(const string& __s, size_t __refs = 0) + : time_put_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~time_put_byname() { } + }; + + + /** + * @brief Money format ordering data. + * @ingroup locales + * + * This class contains an ordered array of 4 fields to represent the + * pattern for formatting a money amount. Each field may contain one entry + * from the part enum. symbol, sign, and value must be present and the + * remaining field must contain either none or space. @see + * moneypunct::pos_format() and moneypunct::neg_format() for details of how + * these fields are interpreted. + */ + class money_base + { + public: + enum part { none, space, symbol, sign, value }; + struct pattern { char field[4]; }; + + static const pattern _S_default_pattern; + + enum + { + _S_minus, + _S_zero, + _S_end = 11 + }; + + // String literal of acceptable (narrow) input/output, for + // money_get/money_put. "-0123456789" + static const char* _S_atoms; + + // Construct and return valid pattern consisting of some combination of: + // space none symbol sign value + _GLIBCXX_CONST static pattern + _S_construct_pattern(char __precedes, char __space, char __posn) throw (); + }; + + template + struct __moneypunct_cache : public locale::facet + { + const char* _M_grouping; + size_t _M_grouping_size; + bool _M_use_grouping; + _CharT _M_decimal_point; + _CharT _M_thousands_sep; + const _CharT* _M_curr_symbol; + size_t _M_curr_symbol_size; + const _CharT* _M_positive_sign; + size_t _M_positive_sign_size; + const _CharT* _M_negative_sign; + size_t _M_negative_sign_size; + int _M_frac_digits; + money_base::pattern _M_pos_format; + money_base::pattern _M_neg_format; + + // A list of valid numeric literals for input and output: in the standard + // "C" locale, this is "-0123456789". This array contains the chars after + // having been passed through the current locale's ctype<_CharT>.widen(). + _CharT _M_atoms[money_base::_S_end]; + + bool _M_allocated; + + __moneypunct_cache(size_t __refs = 0) : facet(__refs), + _M_grouping(0), _M_grouping_size(0), _M_use_grouping(false), + _M_decimal_point(_CharT()), _M_thousands_sep(_CharT()), + _M_curr_symbol(0), _M_curr_symbol_size(0), + _M_positive_sign(0), _M_positive_sign_size(0), + _M_negative_sign(0), _M_negative_sign_size(0), + _M_frac_digits(0), + _M_pos_format(money_base::pattern()), + _M_neg_format(money_base::pattern()), _M_allocated(false) + { } + + ~__moneypunct_cache(); + + void + _M_cache(const locale& __loc); + + private: + __moneypunct_cache& + operator=(const __moneypunct_cache&); + + explicit + __moneypunct_cache(const __moneypunct_cache&); + }; + + template + __moneypunct_cache<_CharT, _Intl>::~__moneypunct_cache() + { + if (_M_allocated) + { + delete [] _M_grouping; + delete [] _M_curr_symbol; + delete [] _M_positive_sign; + delete [] _M_negative_sign; + } + } + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template moneypunct. + * @ingroup locales + * + * This facet encapsulates the punctuation, grouping and other formatting + * features of money amount string representations. + */ + template + class moneypunct : public locale::facet, public money_base + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; + + private: + __cache_type* _M_data; + + public: + /// This value is provided by the standard, but no reason for its + /// existence. + static const bool intl = _Intl; + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + moneypunct(size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_moneypunct(); } + + /** + * @brief Constructor performs initialization. + * + * This is an internal constructor. + * + * @param __cache Cache for optimization. + * @param __refs Passed to the base facet class. + */ + explicit + moneypunct(__cache_type* __cache, size_t __refs = 0) + : facet(__refs), _M_data(__cache) + { _M_initialize_moneypunct(); } + + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __s The name of a locale. + * @param __refs Passed to the base facet class. + */ + explicit + moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) + : facet(__refs), _M_data(0) + { _M_initialize_moneypunct(__cloc, __s); } + + /** + * @brief Return decimal point character. + * + * This function returns a char_type to use as a decimal point. It + * does so by returning returning + * moneypunct::do_decimal_point(). + * + * @return @a char_type representing a decimal point. + */ + char_type + decimal_point() const + { return this->do_decimal_point(); } + + /** + * @brief Return thousands separator character. + * + * This function returns a char_type to use as a thousands + * separator. It does so by returning returning + * moneypunct::do_thousands_sep(). + * + * @return char_type representing a thousands separator. + */ + char_type + thousands_sep() const + { return this->do_thousands_sep(); } + + /** + * @brief Return grouping specification. + * + * This function returns a string representing groupings for the + * integer part of an amount. Groupings indicate where thousands + * separators should be inserted. + * + * Each char in the return string is interpret as an integer rather + * than a character. These numbers represent the number of digits in a + * group. The first char in the string represents the number of digits + * in the least significant group. If a char is negative, it indicates + * an unlimited number of digits for the group. If more chars from the + * string are required to group a number, the last char is used + * repeatedly. + * + * For example, if the grouping() returns \003\002 + * and is applied to the number 123456789, this corresponds to + * 12,34,56,789. Note that if the string was 32, this would + * put more than 50 digits into the least significant group if + * the character set is ASCII. + * + * The string is returned by calling + * moneypunct::do_grouping(). + * + * @return string representing grouping specification. + */ + string + grouping() const + { return this->do_grouping(); } + + /** + * @brief Return currency symbol string. + * + * This function returns a string_type to use as a currency symbol. It + * does so by returning returning + * moneypunct::do_curr_symbol(). + * + * @return @a string_type representing a currency symbol. + */ + string_type + curr_symbol() const + { return this->do_curr_symbol(); } + + /** + * @brief Return positive sign string. + * + * This function returns a string_type to use as a sign for positive + * amounts. It does so by returning returning + * moneypunct::do_positive_sign(). + * + * If the return value contains more than one character, the first + * character appears in the position indicated by pos_format() and the + * remainder appear at the end of the formatted string. + * + * @return @a string_type representing a positive sign. + */ + string_type + positive_sign() const + { return this->do_positive_sign(); } + + /** + * @brief Return negative sign string. + * + * This function returns a string_type to use as a sign for negative + * amounts. It does so by returning returning + * moneypunct::do_negative_sign(). + * + * If the return value contains more than one character, the first + * character appears in the position indicated by neg_format() and the + * remainder appear at the end of the formatted string. + * + * @return @a string_type representing a negative sign. + */ + string_type + negative_sign() const + { return this->do_negative_sign(); } + + /** + * @brief Return number of digits in fraction. + * + * This function returns the exact number of digits that make up the + * fractional part of a money amount. It does so by returning + * returning moneypunct::do_frac_digits(). + * + * The fractional part of a money amount is optional. But if it is + * present, there must be frac_digits() digits. + * + * @return Number of digits in amount fraction. + */ + int + frac_digits() const + { return this->do_frac_digits(); } + + ///@{ + /** + * @brief Return pattern for money values. + * + * This function returns a pattern describing the formatting of a + * positive or negative valued money amount. It does so by returning + * returning moneypunct::do_pos_format() or + * moneypunct::do_neg_format(). + * + * The pattern has 4 fields describing the ordering of symbol, sign, + * value, and none or space. There must be one of each in the pattern. + * The none and space enums may not appear in the first field and space + * may not appear in the final field. + * + * The parts of a money string must appear in the order indicated by + * the fields of the pattern. The symbol field indicates that the + * value of curr_symbol() may be present. The sign field indicates + * that the value of positive_sign() or negative_sign() must be + * present. The value field indicates that the absolute value of the + * money amount is present. none indicates 0 or more whitespace + * characters, except at the end, where it permits no whitespace. + * space indicates that 1 or more whitespace characters must be + * present. + * + * For example, for the US locale and pos_format() pattern + * {symbol,sign,value,none}, curr_symbol() == '$' + * positive_sign() == '+', and value 10.01, and + * options set to force the symbol, the corresponding string is + * $+10.01. + * + * @return Pattern for money values. + */ + pattern + pos_format() const + { return this->do_pos_format(); } + + pattern + neg_format() const + { return this->do_neg_format(); } + ///@} + + protected: + /// Destructor. + virtual + ~moneypunct(); + + /** + * @brief Return decimal point character. + * + * Returns a char_type to use as a decimal point. This function is a + * hook for derived classes to change the value returned. + * + * @return @a char_type representing a decimal point. + */ + virtual char_type + do_decimal_point() const + { return _M_data->_M_decimal_point; } + + /** + * @brief Return thousands separator character. + * + * Returns a char_type to use as a thousands separator. This function + * is a hook for derived classes to change the value returned. + * + * @return @a char_type representing a thousands separator. + */ + virtual char_type + do_thousands_sep() const + { return _M_data->_M_thousands_sep; } + + /** + * @brief Return grouping specification. + * + * Returns a string representing groupings for the integer part of a + * number. This function is a hook for derived classes to change the + * value returned. @see grouping() for details. + * + * @return String representing grouping specification. + */ + virtual string + do_grouping() const + { return _M_data->_M_grouping; } + + /** + * @brief Return currency symbol string. + * + * This function returns a string_type to use as a currency symbol. + * This function is a hook for derived classes to change the value + * returned. @see curr_symbol() for details. + * + * @return @a string_type representing a currency symbol. + */ + virtual string_type + do_curr_symbol() const + { return _M_data->_M_curr_symbol; } + + /** + * @brief Return positive sign string. + * + * This function returns a string_type to use as a sign for positive + * amounts. This function is a hook for derived classes to change the + * value returned. @see positive_sign() for details. + * + * @return @a string_type representing a positive sign. + */ + virtual string_type + do_positive_sign() const + { return _M_data->_M_positive_sign; } + + /** + * @brief Return negative sign string. + * + * This function returns a string_type to use as a sign for negative + * amounts. This function is a hook for derived classes to change the + * value returned. @see negative_sign() for details. + * + * @return @a string_type representing a negative sign. + */ + virtual string_type + do_negative_sign() const + { return _M_data->_M_negative_sign; } + + /** + * @brief Return number of digits in fraction. + * + * This function returns the exact number of digits that make up the + * fractional part of a money amount. This function is a hook for + * derived classes to change the value returned. @see frac_digits() + * for details. + * + * @return Number of digits in amount fraction. + */ + virtual int + do_frac_digits() const + { return _M_data->_M_frac_digits; } + + /** + * @brief Return pattern for money values. + * + * This function returns a pattern describing the formatting of a + * positive valued money amount. This function is a hook for derived + * classes to change the value returned. @see pos_format() for + * details. + * + * @return Pattern for money values. + */ + virtual pattern + do_pos_format() const + { return _M_data->_M_pos_format; } + + /** + * @brief Return pattern for money values. + * + * This function returns a pattern describing the formatting of a + * negative valued money amount. This function is a hook for derived + * classes to change the value returned. @see neg_format() for + * details. + * + * @return Pattern for money values. + */ + virtual pattern + do_neg_format() const + { return _M_data->_M_neg_format; } + + // For use at construction time only. + void + _M_initialize_moneypunct(__c_locale __cloc = 0, + const char* __name = 0); + }; + + template + locale::id moneypunct<_CharT, _Intl>::id; + + template + const bool moneypunct<_CharT, _Intl>::intl; + + template<> + moneypunct::~moneypunct(); + + template<> + moneypunct::~moneypunct(); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, const char*); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, const char*); + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + moneypunct::~moneypunct(); + + template<> + moneypunct::~moneypunct(); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, + const char*); + + template<> + void + moneypunct::_M_initialize_moneypunct(__c_locale, + const char*); +#endif + + /// class moneypunct_byname [22.2.6.4]. + template + class moneypunct_byname : public moneypunct<_CharT, _Intl> + { + public: + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + + static const bool intl = _Intl; + + explicit + moneypunct_byname(const char* __s, size_t __refs = 0) + : moneypunct<_CharT, _Intl>(__refs) + { + if (__builtin_strcmp(__s, "C") != 0 + && __builtin_strcmp(__s, "POSIX") != 0) + { + __c_locale __tmp; + this->_S_create_c_locale(__tmp, __s); + this->_M_initialize_moneypunct(__tmp); + this->_S_destroy_c_locale(__tmp); + } + } + +#if __cplusplus >= 201103L + explicit + moneypunct_byname(const string& __s, size_t __refs = 0) + : moneypunct_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~moneypunct_byname() { } + }; + + template + const bool moneypunct_byname<_CharT, _Intl>::intl; + +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 + + /** + * @brief Primary class template money_get. + * @ingroup locales + * + * This facet encapsulates the code to parse and return a monetary + * amount from a string. + * + * The money_get template uses protected virtual functions to + * provide the actual results. The public accessors forward the + * call to the virtual functions. These virtual functions are + * hooks for developers to implement the behavior they require from + * the money_get facet. + */ + template + class money_get : public locale::facet + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _InIter iter_type; + typedef basic_string<_CharT> string_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + money_get(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Read and parse a monetary value. + * + * This function reads characters from @a __s, interprets them as a + * monetary value according to moneypunct and ctype facets retrieved + * from io.getloc(), and returns the result in @a units as an integral + * value moneypunct::frac_digits() * the actual amount. For example, + * the string $10.01 in a US locale would store 1001 in @a units. + * + * Any characters not part of a valid money amount are not consumed. + * + * If a money value cannot be parsed from the input stream, sets + * err=(err|io.failbit). If the stream is consumed before finishing + * parsing, sets err=(err|io.failbit|io.eofbit). @a units is + * unchanged if parsing fails. + * + * This function works by returning the result of do_get(). + * + * @param __s Start of characters to parse. + * @param __end End of characters to parse. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __err Error field to set if parsing fails. + * @param __units Place to store result of parsing. + * @return Iterator referencing first character beyond valid money + * amount. + */ + iter_type + get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const + { return this->do_get(__s, __end, __intl, __io, __err, __units); } + + /** + * @brief Read and parse a monetary value. + * + * This function reads characters from @a __s, interprets them as + * a monetary value according to moneypunct and ctype facets + * retrieved from io.getloc(), and returns the result in @a + * digits. For example, the string $10.01 in a US locale would + * store 1001 in @a digits. + * + * Any characters not part of a valid money amount are not consumed. + * + * If a money value cannot be parsed from the input stream, sets + * err=(err|io.failbit). If the stream is consumed before finishing + * parsing, sets err=(err|io.failbit|io.eofbit). + * + * This function works by returning the result of do_get(). + * + * @param __s Start of characters to parse. + * @param __end End of characters to parse. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __err Error field to set if parsing fails. + * @param __digits Place to store result of parsing. + * @return Iterator referencing first character beyond valid money + * amount. + */ + iter_type + get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, string_type& __digits) const + { return this->do_get(__s, __end, __intl, __io, __err, __digits); } + + protected: + /// Destructor. + virtual + ~money_get() { } + + /** + * @brief Read and parse a monetary value. + * + * This function reads and parses characters representing a monetary + * value. This function is a hook for derived classes to change the + * value returned. @see get() for details. + */ + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, double& __units) const; +#else + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const; +#endif + + /** + * @brief Read and parse a monetary value. + * + * This function reads and parses characters representing a monetary + * value. This function is a hook for derived classes to change the + * value returned. @see get() for details. + */ + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, string_type& __digits) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + virtual iter_type + __do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, __ibm128& __units) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + do_get(iter_type __s, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const; +#endif + + template + iter_type + _M_extract(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, string& __digits) const; + }; + + template + locale::id money_get<_CharT, _InIter>::id; + + /** + * @brief Primary class template money_put. + * @ingroup locales + * + * This facet encapsulates the code to format and output a monetary + * amount. + * + * The money_put template uses protected virtual functions to + * provide the actual results. The public accessors forward the + * call to the virtual functions. These virtual functions are + * hooks for developers to implement the behavior they require from + * the money_put facet. + */ + template + class money_put : public locale::facet + { + public: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef _OutIter iter_type; + typedef basic_string<_CharT> string_type; + ///@} + + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + money_put(size_t __refs = 0) : facet(__refs) { } + + /** + * @brief Format and output a monetary value. + * + * This function formats @a units as a monetary value according to + * moneypunct and ctype facets retrieved from io.getloc(), and writes + * the resulting characters to @a __s. For example, the value 1001 in a + * US locale would write $10.01 to @a __s. + * + * This function works by returning the result of do_put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __units Place to store result of parsing. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, bool __intl, ios_base& __io, + char_type __fill, long double __units) const + { return this->do_put(__s, __intl, __io, __fill, __units); } + + /** + * @brief Format and output a monetary value. + * + * This function formats @a digits as a monetary value + * according to moneypunct and ctype facets retrieved from + * io.getloc(), and writes the resulting characters to @a __s. + * For example, the string 1001 in a US locale + * would write $10.01 to @a __s. + * + * This function works by returning the result of do_put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __digits Place to store result of parsing. + * @return Iterator after writing. + */ + iter_type + put(iter_type __s, bool __intl, ios_base& __io, + char_type __fill, const string_type& __digits) const + { return this->do_put(__s, __intl, __io, __fill, __digits); } + + protected: + /// Destructor. + virtual + ~money_put() { } + + /** + * @brief Format and output a monetary value. + * + * This function formats @a units as a monetary value according to + * moneypunct and ctype facets retrieved from io.getloc(), and writes + * the resulting characters to @a __s. For example, the value 1001 in a + * US locale would write $10.01 to @a __s. + * + * This function is a hook for derived classes to change the value + * returned. @see put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __units Place to store result of parsing. + * @return Iterator after writing. + */ + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + double __units) const; +#else + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const; +#endif + + /** + * @brief Format and output a monetary value. + * + * This function formats @a digits as a monetary value + * according to moneypunct and ctype facets retrieved from + * io.getloc(), and writes the resulting characters to @a __s. + * For example, the string 1001 in a US locale + * would write $10.01 to @a __s. + * + * This function is a hook for derived classes to change the value + * returned. @see put(). + * + * @param __s The stream to write to. + * @param __intl Parameter to use_facet >. + * @param __io Source of facets and io state. + * @param __fill char_type to use for padding. + * @param __digits Place to store result of parsing. + * @return Iterator after writing. + */ + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + const string_type& __digits) const; + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + virtual iter_type + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + __ibm128 __units) const; +#endif + + // XXX GLIBCXX_ABI Deprecated +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + virtual iter_type + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const; +#endif + + template + iter_type + _M_insert(iter_type __s, ios_base& __io, char_type __fill, + const string_type& __digits) const; + }; + + template + locale::id money_put<_CharT, _OutIter>::id; + +_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 + + /** + * @brief Messages facet base class providing catalog typedef. + * @ingroup locales + */ + struct messages_base + { + typedef int catalog; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @brief Primary class template messages. + * @ingroup locales + * + * This facet encapsulates the code to retrieve messages from + * message catalogs. The only thing defined by the standard for this facet + * is the interface. All underlying functionality is + * implementation-defined. + * + * This library currently implements 3 versions of the message facet. The + * first version (gnu) is a wrapper around gettext, provided by libintl. + * The second version (ieee) is a wrapper around catgets. The final + * version (default) does no actual translation. These implementations are + * only provided for char and wchar_t instantiations. + * + * The messages template uses protected virtual functions to + * provide the actual results. The public accessors forward the + * call to the virtual functions. These virtual functions are + * hooks for developers to implement the behavior they require from + * the messages facet. + */ + template + class messages : public locale::facet, public messages_base + { + public: + // Types: + ///@{ + /// Public typedefs + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + ///@} + + protected: + // Underlying "C" library locale information saved from + // initialization, needed by messages_byname as well. + __c_locale _M_c_locale_messages; + const char* _M_name_messages; + + public: + /// Numpunct facet id. + static locale::id id; + + /** + * @brief Constructor performs initialization. + * + * This is the constructor provided by the standard. + * + * @param __refs Passed to the base facet class. + */ + explicit + messages(size_t __refs = 0); + + // Non-standard. + /** + * @brief Internal constructor. Not for general use. + * + * This is a constructor for use by the library itself to set up new + * locales. + * + * @param __cloc The C locale. + * @param __s The name of a locale. + * @param __refs Refcount to pass to the base class. + */ + explicit + messages(__c_locale __cloc, const char* __s, size_t __refs = 0); + + /* + * @brief Open a message catalog. + * + * This function opens and returns a handle to a message catalog by + * returning do_open(__s, __loc). + * + * @param __s The catalog to open. + * @param __loc Locale to use for character set conversions. + * @return Handle to the catalog or value < 0 if open fails. + */ + catalog + open(const basic_string& __s, const locale& __loc) const + { return this->do_open(__s, __loc); } + + // Non-standard and unorthodox, yet effective. + /* + * @brief Open a message catalog. + * + * This non-standard function opens and returns a handle to a message + * catalog by returning do_open(s, loc). The third argument provides a + * message catalog root directory for gnu gettext and is ignored + * otherwise. + * + * @param __s The catalog to open. + * @param __loc Locale to use for character set conversions. + * @param __dir Message catalog root directory. + * @return Handle to the catalog or value < 0 if open fails. + */ + catalog + open(const basic_string&, const locale&, const char*) const; + + /* + * @brief Look up a string in a message catalog. + * + * This function retrieves and returns a message from a catalog by + * returning do_get(c, set, msgid, s). + * + * For gnu, @a __set and @a msgid are ignored. Returns gettext(s). + * For default, returns s. For ieee, returns catgets(c,set,msgid,s). + * + * @param __c The catalog to access. + * @param __set Implementation-defined. + * @param __msgid Implementation-defined. + * @param __s Default return value if retrieval fails. + * @return Retrieved message or @a __s if get fails. + */ + string_type + get(catalog __c, int __set, int __msgid, const string_type& __s) const + { return this->do_get(__c, __set, __msgid, __s); } + + /* + * @brief Close a message catalog. + * + * Closes catalog @a c by calling do_close(c). + * + * @param __c The catalog to close. + */ + void + close(catalog __c) const + { return this->do_close(__c); } + + protected: + /// Destructor. + virtual + ~messages(); + + /* + * @brief Open a message catalog. + * + * This function opens and returns a handle to a message catalog in an + * implementation-defined manner. This function is a hook for derived + * classes to change the value returned. + * + * @param __s The catalog to open. + * @param __loc Locale to use for character set conversions. + * @return Handle to the opened catalog, value < 0 if open failed. + */ + virtual catalog + do_open(const basic_string&, const locale&) const; + + /* + * @brief Look up a string in a message catalog. + * + * This function retrieves and returns a message from a catalog in an + * implementation-defined manner. This function is a hook for derived + * classes to change the value returned. + * + * For gnu, @a __set and @a __msgid are ignored. Returns gettext(s). + * For default, returns s. For ieee, returns catgets(c,set,msgid,s). + * + * @param __c The catalog to access. + * @param __set Implementation-defined. + * @param __msgid Implementation-defined. + * @param __s Default return value if retrieval fails. + * @return Retrieved message or @a __s if get fails. + */ + virtual string_type + do_get(catalog, int, int, const string_type& __dfault) const; + + /* + * @brief Close a message catalog. + * + * @param __c The catalog to close. + */ + virtual void + do_close(catalog) const; + + // Returns a locale and codeset-converted string, given a char* message. + char* + _M_convert_to_char(const string_type& __msg) const + { + // XXX + return reinterpret_cast(const_cast<_CharT*>(__msg.c_str())); + } + + // Returns a locale and codeset-converted string, given a char* message. + string_type + _M_convert_from_char(char*) const + { + // XXX + return string_type(); + } + }; + + template + locale::id messages<_CharT>::id; + + /// Specializations for required instantiations. + template<> + string + messages::do_get(catalog, int, int, const string&) const; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> + wstring + messages::do_get(catalog, int, int, const wstring&) const; +#endif + + /// class messages_byname [22.2.7.2]. + template + class messages_byname : public messages<_CharT> + { + public: + typedef _CharT char_type; + typedef basic_string<_CharT> string_type; + + explicit + messages_byname(const char* __s, size_t __refs = 0); + +#if __cplusplus >= 201103L + explicit + messages_byname(const string& __s, size_t __refs = 0) + : messages_byname(__s.c_str(), __refs) { } +#endif + + protected: + virtual + ~messages_byname() + { } + }; + +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +// Include host and configuration specific messages functions. +#include + +// 22.2.1.5 Template class codecvt +#include + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets_nonio.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets_nonio.tcc new file mode 100755 index 0000000..51c23d8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/locale_facets_nonio.tcc @@ -0,0 +1,1561 @@ +// Locale support -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/locale_facets_nonio.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +#ifndef _LOCALE_FACETS_NONIO_TCC +#define _LOCALE_FACETS_NONIO_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + struct __use_cache<__moneypunct_cache<_CharT, _Intl> > + { + const __moneypunct_cache<_CharT, _Intl>* + operator() (const locale& __loc) const + { + const size_t __i = moneypunct<_CharT, _Intl>::id._M_id(); + const locale::facet** __caches = __loc._M_impl->_M_caches; + if (!__caches[__i]) + { + __moneypunct_cache<_CharT, _Intl>* __tmp = 0; + __try + { + __tmp = new __moneypunct_cache<_CharT, _Intl>; + __tmp->_M_cache(__loc); + } + __catch(...) + { + delete __tmp; + __throw_exception_again; + } + __loc._M_impl->_M_install_cache(__tmp, __i); + } + return static_cast< + const __moneypunct_cache<_CharT, _Intl>*>(__caches[__i]); + } + }; + + template + void + __moneypunct_cache<_CharT, _Intl>::_M_cache(const locale& __loc) + { + const moneypunct<_CharT, _Intl>& __mp = + use_facet >(__loc); + + _M_decimal_point = __mp.decimal_point(); + _M_thousands_sep = __mp.thousands_sep(); + _M_frac_digits = __mp.frac_digits(); + + char* __grouping = 0; + _CharT* __curr_symbol = 0; + _CharT* __positive_sign = 0; + _CharT* __negative_sign = 0; + __try + { + const string& __g = __mp.grouping(); + _M_grouping_size = __g.size(); + __grouping = new char[_M_grouping_size]; + __g.copy(__grouping, _M_grouping_size); + _M_use_grouping = (_M_grouping_size + && static_cast(__grouping[0]) > 0 + && (__grouping[0] + != __gnu_cxx::__numeric_traits::__max)); + + const basic_string<_CharT>& __cs = __mp.curr_symbol(); + _M_curr_symbol_size = __cs.size(); + __curr_symbol = new _CharT[_M_curr_symbol_size]; + __cs.copy(__curr_symbol, _M_curr_symbol_size); + + const basic_string<_CharT>& __ps = __mp.positive_sign(); + _M_positive_sign_size = __ps.size(); + __positive_sign = new _CharT[_M_positive_sign_size]; + __ps.copy(__positive_sign, _M_positive_sign_size); + + const basic_string<_CharT>& __ns = __mp.negative_sign(); + _M_negative_sign_size = __ns.size(); + __negative_sign = new _CharT[_M_negative_sign_size]; + __ns.copy(__negative_sign, _M_negative_sign_size); + + _M_pos_format = __mp.pos_format(); + _M_neg_format = __mp.neg_format(); + + const ctype<_CharT>& __ct = use_facet >(__loc); + __ct.widen(money_base::_S_atoms, + money_base::_S_atoms + money_base::_S_end, _M_atoms); + + _M_grouping = __grouping; + _M_curr_symbol = __curr_symbol; + _M_positive_sign = __positive_sign; + _M_negative_sign = __negative_sign; + _M_allocated = true; + } + __catch(...) + { + delete [] __grouping; + delete [] __curr_symbol; + delete [] __positive_sign; + delete [] __negative_sign; + __throw_exception_again; + } + } + +_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 + + template + template + _InIter + money_get<_CharT, _InIter>:: + _M_extract(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, string& __units) const + { + typedef char_traits<_CharT> __traits_type; + typedef typename string_type::size_type size_type; + typedef money_base::part part; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; + + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + __use_cache<__cache_type> __uc; + const __cache_type* __lc = __uc(__loc); + const char_type* __lit = __lc->_M_atoms; + + // Deduced sign. + bool __negative = false; + // Sign size. + size_type __sign_size = 0; + // True if sign is mandatory. + const bool __mandatory_sign = (__lc->_M_positive_sign_size + && __lc->_M_negative_sign_size); + // String of grouping info from thousands_sep plucked from __units. + string __grouping_tmp; + if (__lc->_M_use_grouping) + __grouping_tmp.reserve(32); + // Last position before the decimal point. + int __last_pos = 0; + // Separator positions, then, possibly, fractional digits. + int __n = 0; + // If input iterator is in a valid state. + bool __testvalid = true; + // Flag marking when a decimal point is found. + bool __testdecfound = false; + + // The tentative returned string is stored here. + string __res; + __res.reserve(32); + + const char_type* __lit_zero = __lit + money_base::_S_zero; + const money_base::pattern __p = __lc->_M_neg_format; + for (int __i = 0; __i < 4 && __testvalid; ++__i) + { + const part __which = static_cast(__p.field[__i]); + switch (__which) + { + case money_base::symbol: + // According to 22.2.6.1.2, p2, symbol is required + // if (__io.flags() & ios_base::showbase), otherwise + // is optional and consumed only if other characters + // are needed to complete the format. + if (__io.flags() & ios_base::showbase || __sign_size > 1 + || __i == 0 + || (__i == 1 && (__mandatory_sign + || (static_cast(__p.field[0]) + == money_base::sign) + || (static_cast(__p.field[2]) + == money_base::space))) + || (__i == 2 && ((static_cast(__p.field[3]) + == money_base::value) + || (__mandatory_sign + && (static_cast(__p.field[3]) + == money_base::sign))))) + { + const size_type __len = __lc->_M_curr_symbol_size; + size_type __j = 0; + for (; __beg != __end && __j < __len + && *__beg == __lc->_M_curr_symbol[__j]; + ++__beg, (void)++__j); + if (__j != __len + && (__j || __io.flags() & ios_base::showbase)) + __testvalid = false; + } + break; + case money_base::sign: + // Sign might not exist, or be more than one character long. + if (__lc->_M_positive_sign_size && __beg != __end + && *__beg == __lc->_M_positive_sign[0]) + { + __sign_size = __lc->_M_positive_sign_size; + ++__beg; + } + else if (__lc->_M_negative_sign_size && __beg != __end + && *__beg == __lc->_M_negative_sign[0]) + { + __negative = true; + __sign_size = __lc->_M_negative_sign_size; + ++__beg; + } + else if (__lc->_M_positive_sign_size + && !__lc->_M_negative_sign_size) + // "... if no sign is detected, the result is given the sign + // that corresponds to the source of the empty string" + __negative = true; + else if (__mandatory_sign) + __testvalid = false; + break; + case money_base::value: + // Extract digits, remove and stash away the + // grouping of found thousands separators. + for (; __beg != __end; ++__beg) + { + const char_type __c = *__beg; + const char_type* __q = __traits_type::find(__lit_zero, + 10, __c); + if (__q != 0) + { + __res += money_base::_S_atoms[__q - __lit]; + ++__n; + } + else if (__c == __lc->_M_decimal_point + && !__testdecfound) + { + if (__lc->_M_frac_digits <= 0) + break; + + __last_pos = __n; + __n = 0; + __testdecfound = true; + } + else if (__lc->_M_use_grouping + && __c == __lc->_M_thousands_sep + && !__testdecfound) + { + if (__n) + { + // Mark position for later analysis. + __grouping_tmp += static_cast(__n); + __n = 0; + } + else + { + __testvalid = false; + break; + } + } + else + break; + } + if (__res.empty()) + __testvalid = false; + break; + case money_base::space: + // At least one space is required. + if (__beg != __end && __ctype.is(ctype_base::space, *__beg)) + ++__beg; + else + __testvalid = false; + // fallthrough + case money_base::none: + // Only if not at the end of the pattern. + if (__i != 3) + for (; __beg != __end + && __ctype.is(ctype_base::space, *__beg); ++__beg); + break; + } + } + + // Need to get the rest of the sign characters, if they exist. + if (__sign_size > 1 && __testvalid) + { + const char_type* __sign = __negative ? __lc->_M_negative_sign + : __lc->_M_positive_sign; + size_type __i = 1; + for (; __beg != __end && __i < __sign_size + && *__beg == __sign[__i]; ++__beg, (void)++__i); + + if (__i != __sign_size) + __testvalid = false; + } + + if (__testvalid) + { + // Strip leading zeros. + if (__res.size() > 1) + { + const size_type __first = __res.find_first_not_of('0'); + const bool __only_zeros = __first == string::npos; + if (__first) + __res.erase(0, __only_zeros ? __res.size() - 1 : __first); + } + + // 22.2.6.1.2, p4 + if (__negative && __res[0] != '0') + __res.insert(__res.begin(), '-'); + + // Test for grouping fidelity. + if (__grouping_tmp.size()) + { + // Add the ending grouping. + __grouping_tmp += static_cast(__testdecfound ? __last_pos + : __n); + if (!std::__verify_grouping(__lc->_M_grouping, + __lc->_M_grouping_size, + __grouping_tmp)) + __err |= ios_base::failbit; + } + + // Iff not enough digits were supplied after the decimal-point. + if (__testdecfound && __n != __lc->_M_frac_digits) + __testvalid = false; + } + + // Iff valid sequence is not recognized. + if (!__testvalid) + __err |= ios_base::failbit; + else + __units.swap(__res); + + // Iff no more characters are available. + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + template + _InIter + money_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, double& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } +#endif + + template + _InIter + money_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, long double& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } + + template + _InIter + money_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, string_type& __digits) const + { + typedef typename string::size_type size_type; + + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + const size_type __len = __str.size(); + if (__len) + { + __digits.resize(__len); + __ctype.widen(__str.data(), __str.data() + __len, &__digits[0]); + } + return __beg; + } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _InIter + money_get<_CharT, _InIter>:: + __do_get(iter_type __beg, iter_type __end, bool __intl, ios_base& __io, + ios_base::iostate& __err, __ibm128& __units) const + { + string __str; + __beg = __intl ? _M_extract(__beg, __end, __io, __err, __str) + : _M_extract(__beg, __end, __io, __err, __str); + std::__convert_to_v(__str.c_str(), __units, __err, _S_get_c_locale()); + return __beg; + } +#endif + + template + template + _OutIter + money_put<_CharT, _OutIter>:: + _M_insert(iter_type __s, ios_base& __io, char_type __fill, + const string_type& __digits) const + { + typedef typename string_type::size_type size_type; + typedef money_base::part part; + typedef __moneypunct_cache<_CharT, _Intl> __cache_type; + + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + __use_cache<__cache_type> __uc; + const __cache_type* __lc = __uc(__loc); + const char_type* __lit = __lc->_M_atoms; + + // Determine if negative or positive formats are to be used, and + // discard leading negative_sign if it is present. + const char_type* __beg = __digits.data(); + + money_base::pattern __p; + const char_type* __sign; + size_type __sign_size; + if (!(*__beg == __lit[money_base::_S_minus])) + { + __p = __lc->_M_pos_format; + __sign = __lc->_M_positive_sign; + __sign_size = __lc->_M_positive_sign_size; + } + else + { + __p = __lc->_M_neg_format; + __sign = __lc->_M_negative_sign; + __sign_size = __lc->_M_negative_sign_size; + if (__digits.size()) + ++__beg; + } + + // Look for valid numbers in the ctype facet within input digits. + size_type __len = __ctype.scan_not(ctype_base::digit, __beg, + __beg + __digits.size()) - __beg; + if (__len) + { + // Assume valid input, and attempt to format. + // Break down input numbers into base components, as follows: + // final_value = grouped units + (decimal point) + (digits) + string_type __value; + __value.reserve(2 * __len); + + // Add thousands separators to non-decimal digits, per + // grouping rules. + long __paddec = __len - __lc->_M_frac_digits; + if (__paddec > 0) + { + if (__lc->_M_frac_digits < 0) + __paddec = __len; + if (__lc->_M_grouping_size) + { + __value.assign(2 * __paddec, char_type()); + _CharT* __vend = + std::__add_grouping(&__value[0], __lc->_M_thousands_sep, + __lc->_M_grouping, + __lc->_M_grouping_size, + __beg, __beg + __paddec); + __value.erase(__vend - &__value[0]); + } + else + __value.assign(__beg, __paddec); + } + + // Deal with decimal point, decimal digits. + if (__lc->_M_frac_digits > 0) + { + __value += __lc->_M_decimal_point; + if (__paddec >= 0) + __value.append(__beg + __paddec, __lc->_M_frac_digits); + else + { + // Have to pad zeros in the decimal position. + __value.append(-__paddec, __lit[money_base::_S_zero]); + __value.append(__beg, __len); + } + } + + // Calculate length of resulting string. + const ios_base::fmtflags __f = __io.flags() + & ios_base::adjustfield; + __len = __value.size() + __sign_size; + __len += ((__io.flags() & ios_base::showbase) + ? __lc->_M_curr_symbol_size : 0); + + string_type __res; + __res.reserve(2 * __len); + + const size_type __width = static_cast(__io.width()); + const bool __testipad = (__f == ios_base::internal + && __len < __width); + // Fit formatted digits into the required pattern. + for (int __i = 0; __i < 4; ++__i) + { + const part __which = static_cast(__p.field[__i]); + switch (__which) + { + case money_base::symbol: + if (__io.flags() & ios_base::showbase) + __res.append(__lc->_M_curr_symbol, + __lc->_M_curr_symbol_size); + break; + case money_base::sign: + // Sign might not exist, or be more than one + // character long. In that case, add in the rest + // below. + if (__sign_size) + __res += __sign[0]; + break; + case money_base::value: + __res += __value; + break; + case money_base::space: + // At least one space is required, but if internal + // formatting is required, an arbitrary number of + // fill spaces will be necessary. + if (__testipad) + __res.append(__width - __len, __fill); + else + __res += __fill; + break; + case money_base::none: + if (__testipad) + __res.append(__width - __len, __fill); + break; + } + } + + // Special case of multi-part sign parts. + if (__sign_size > 1) + __res.append(__sign + 1, __sign_size - 1); + + // Pad, if still necessary. + __len = __res.size(); + if (__width > __len) + { + if (__f == ios_base::left) + // After. + __res.append(__width - __len, __fill); + else + // Before. + __res.insert(0, __width - __len, __fill); + __len = __width; + } + + // Write resulting, fully-formatted string to output iterator. + __s = std::__write(__s, __res.data(), __len); + } + __io.width(0); + return __s; + } + +#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ \ + && (_GLIBCXX_USE_CXX11_ABI == 0 || defined __LONG_DOUBLE_IEEE128__) + template + _OutIter + money_put<_CharT, _OutIter>:: + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + double __units) const + { return this->do_put(__s, __intl, __io, __fill, (long double) __units); } +#endif + + template + _OutIter + money_put<_CharT, _OutIter>:: + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + long double __units) const + { + const locale __loc = __io.getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); +#if _GLIBCXX_USE_C99_STDIO + // First try a buffer perhaps big enough. + int __cs_size = 64; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 328. Bad sprintf format modifier in money_put<>::do_put() + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); + // If the buffer was not large enough, try again with the correct size. + if (__len >= __cs_size) + { + __cs_size = __len + 1; + __cs = static_cast(__builtin_alloca(__cs_size)); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); + } +#else + // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'. + const int __cs_size = + __gnu_cxx::__numeric_traits::__max_exponent10 + 3; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", + 0, __units); +#endif + string_type __digits(__len, char_type()); + __ctype.widen(__cs, __cs + __len, &__digits[0]); + return __intl ? _M_insert(__s, __io, __fill, __digits) + : _M_insert(__s, __io, __fill, __digits); + } + + template + _OutIter + money_put<_CharT, _OutIter>:: + do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + const string_type& __digits) const + { return __intl ? _M_insert(__s, __io, __fill, __digits) + : _M_insert(__s, __io, __fill, __digits); } + +#if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ + && defined __LONG_DOUBLE_IEEE128__ + template + _OutIter + money_put<_CharT, _OutIter>:: + __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, + __ibm128 __units) const + { + const locale __loc = __io.getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); +#if _GLIBCXX_USE_C99_STDIO + // First try a buffer perhaps big enough. + int __cs_size = 64; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 328. Bad sprintf format modifier in money_put<>::do_put() + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); + // If the buffer was not large enough, try again with the correct size. + if (__len >= __cs_size) + { + __cs_size = __len + 1; + __cs = static_cast(__builtin_alloca(__cs_size)); + __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, + "%.*Lf", 0, __units); + } +#else + // max_exponent10 + 1 for the integer part, + 2 for sign and '\0'. + const int __cs_size = + __gnu_cxx::__numeric_traits::__max_exponent10 + 3; + char* __cs = static_cast(__builtin_alloca(__cs_size)); + int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", + 0, __units); +#endif + string_type __digits(__len, char_type()); + __ctype.widen(__cs, __cs + __len, &__digits[0]); + return __intl ? _M_insert(__s, __io, __fill, __digits) + : _M_insert(__s, __io, __fill, __digits); + } +#endif + +_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 + + // NB: Not especially useful. Without an ios_base object or some + // kind of locale reference, we are left clawing at the air where + // the side of the mountain used to be... + template + time_base::dateorder + time_get<_CharT, _InIter>::do_date_order() const + { return time_base::no_order; } + + // Expand a strftime format string and parse it. E.g., do_get_date() may + // pass %m/%d/%Y => extracted characters. + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_via_format(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + const _CharT* __format) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const ctype<_CharT>& __ctype = use_facet >(__loc); + const size_t __len = char_traits<_CharT>::length(__format); + + ios_base::iostate __tmperr = ios_base::goodbit; + size_t __i = 0; + for (; __beg != __end && __i < __len && !__tmperr; ++__i) + { + if (__ctype.narrow(__format[__i], 0) == '%') + { + // Verify valid formatting code, attempt to extract. + char __c = __ctype.narrow(__format[++__i], 0); + int __mem = 0; + if (__c == 'E' || __c == 'O') + __c = __ctype.narrow(__format[++__i], 0); + switch (__c) + { + const char* __cs; + _CharT __wcs[10]; + case 'a': + // Abbreviated weekday name [tm_wday] + const char_type* __days1[7]; + __tp._M_days_abbreviated(__days1); + __beg = _M_extract_name(__beg, __end, __mem, __days1, + 7, __io, __tmperr); + if (!__tmperr) + __tm->tm_wday = __mem; + break; + case 'A': + // Weekday name [tm_wday]. + const char_type* __days2[7]; + __tp._M_days(__days2); + __beg = _M_extract_name(__beg, __end, __mem, __days2, + 7, __io, __tmperr); + if (!__tmperr) + __tm->tm_wday = __mem; + break; + case 'h': + case 'b': + // Abbreviated month name [tm_mon] + const char_type* __months1[12]; + __tp._M_months_abbreviated(__months1); + __beg = _M_extract_name(__beg, __end, __mem, + __months1, 12, __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __mem; + break; + case 'B': + // Month name [tm_mon]. + const char_type* __months2[12]; + __tp._M_months(__months2); + __beg = _M_extract_name(__beg, __end, __mem, + __months2, 12, __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __mem; + break; + case 'c': + // Default time and date representation. + const char_type* __dt[2]; + __tp._M_date_time_formats(__dt); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __dt[0]); + break; + case 'd': + // Day [01, 31]. [tm_mday] + __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_mday = __mem; + break; + case 'e': + // Day [1, 31], with single digits preceded by + // space. [tm_mday] + if (__ctype.is(ctype_base::space, *__beg)) + __beg = _M_extract_num(++__beg, __end, __mem, 1, 9, + 1, __io, __tmperr); + else + __beg = _M_extract_num(__beg, __end, __mem, 10, 31, + 2, __io, __tmperr); + if (!__tmperr) + __tm->tm_mday = __mem; + break; + case 'D': + // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year] + __cs = "%m/%d/%y"; + __ctype.widen(__cs, __cs + 9, __wcs); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __wcs); + break; + case 'H': + // Hour [00, 23]. [tm_hour] + __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_hour = __mem; + break; + case 'I': + // Hour [01, 12]. [tm_hour] + __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_hour = __mem; + break; + case 'm': + // Month [01, 12]. [tm_mon] + __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __mem - 1; + break; + case 'M': + // Minute [00, 59]. [tm_min] + __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2, + __io, __tmperr); + if (!__tmperr) + __tm->tm_min = __mem; + break; + case 'n': + if (__ctype.narrow(*__beg, 0) == '\n') + ++__beg; + else + __tmperr |= ios_base::failbit; + break; + case 'R': + // Equivalent to (%H:%M). + __cs = "%H:%M"; + __ctype.widen(__cs, __cs + 6, __wcs); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __wcs); + break; + case 'S': + // Seconds. [tm_sec] + // [00, 60] in C99 (one leap-second), [00, 61] in C89. +#if _GLIBCXX_USE_C99 + __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2, +#else + __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2, +#endif + __io, __tmperr); + if (!__tmperr) + __tm->tm_sec = __mem; + break; + case 't': + if (__ctype.narrow(*__beg, 0) == '\t') + ++__beg; + else + __tmperr |= ios_base::failbit; + break; + case 'T': + // Equivalent to (%H:%M:%S). + __cs = "%H:%M:%S"; + __ctype.widen(__cs, __cs + 9, __wcs); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __wcs); + break; + case 'x': + // Locale's date. + const char_type* __dates[2]; + __tp._M_date_formats(__dates); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __dates[0]); + break; + case 'X': + // Locale's time. + const char_type* __times[2]; + __tp._M_time_formats(__times); + __beg = _M_extract_via_format(__beg, __end, __io, __tmperr, + __tm, __times[0]); + break; + case 'y': + case 'C': // C99 + // Two digit year. + case 'Y': + // Year [1900). + // NB: We parse either two digits, implicitly years since + // 1900, or 4 digits, full year. In both cases we can + // reconstruct [tm_year]. See also libstdc++/26701. + __beg = _M_extract_num(__beg, __end, __mem, 0, 9999, 4, + __io, __tmperr); + if (!__tmperr) + __tm->tm_year = __mem < 0 ? __mem + 100 : __mem - 1900; + break; + case 'Z': + // Timezone info. + if (__ctype.is(ctype_base::upper, *__beg)) + { + int __tmp; + __beg = _M_extract_name(__beg, __end, __tmp, + __timepunct_cache<_CharT>::_S_timezones, + 14, __io, __tmperr); + + // GMT requires special effort. + if (__beg != __end && !__tmperr && __tmp == 0 + && (*__beg == __ctype.widen('-') + || *__beg == __ctype.widen('+'))) + { + __beg = _M_extract_num(__beg, __end, __tmp, 0, 23, 2, + __io, __tmperr); + __beg = _M_extract_num(__beg, __end, __tmp, 0, 59, 2, + __io, __tmperr); + } + } + else + __tmperr |= ios_base::failbit; + break; + default: + // Not recognized. + __tmperr |= ios_base::failbit; + } + } + else + { + // Verify format and input match, extract and discard. + if (__format[__i] == *__beg) + ++__beg; + else + __tmperr |= ios_base::failbit; + } + } + + if (__tmperr || __i != __len) + __err |= ios_base::failbit; + + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_num(iter_type __beg, iter_type __end, int& __member, + int __min, int __max, size_t __len, + ios_base& __io, ios_base::iostate& __err) const + { + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + // As-is works for __len = 1, 2, 4, the values actually used. + int __mult = __len == 2 ? 10 : (__len == 4 ? 1000 : 1); + + ++__min; + size_t __i = 0; + int __value = 0; + for (; __beg != __end && __i < __len; ++__beg, (void)++__i) + { + const char __c = __ctype.narrow(*__beg, '*'); + if (__c >= '0' && __c <= '9') + { + __value = __value * 10 + (__c - '0'); + const int __valuec = __value * __mult; + if (__valuec > __max || __valuec + __mult < __min) + break; + __mult /= 10; + } + else + break; + } + if (__i == __len) + __member = __value; + // Special encoding for do_get_year, 'y', and 'Y' above. + else if (__len == 4 && __i == 2) + __member = __value - 100; + else + __err |= ios_base::failbit; + + return __beg; + } + + // Assumptions: + // All elements in __names are unique. + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_name(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const + { + typedef char_traits<_CharT> __traits_type; + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + int* __matches = static_cast(__builtin_alloca(sizeof(int) + * __indexlen)); + size_t __nmatches = 0; + size_t __pos = 0; + bool __testvalid = true; + const char_type* __name; + + // Look for initial matches. + // NB: Some of the locale data is in the form of all lowercase + // names, and some is in the form of initially-capitalized + // names. Look for both. + if (__beg != __end) + { + const char_type __c = *__beg; + for (size_t __i1 = 0; __i1 < __indexlen; ++__i1) + if (__c == __names[__i1][0] + || __c == __ctype.toupper(__names[__i1][0])) + __matches[__nmatches++] = __i1; + } + + while (__nmatches > 1) + { + // Find smallest matching string. + size_t __minlen = __traits_type::length(__names[__matches[0]]); + for (size_t __i2 = 1; __i2 < __nmatches; ++__i2) + __minlen = std::min(__minlen, + __traits_type::length(__names[__matches[__i2]])); + ++__beg; + ++__pos; + if (__pos < __minlen && __beg != __end) + for (size_t __i3 = 0; __i3 < __nmatches;) + { + __name = __names[__matches[__i3]]; + if (!(__name[__pos] == *__beg)) + __matches[__i3] = __matches[--__nmatches]; + else + ++__i3; + } + else + break; + } + + if (__nmatches == 1) + { + // Make sure found name is completely extracted. + ++__beg; + ++__pos; + __name = __names[__matches[0]]; + const size_t __len = __traits_type::length(__name); + while (__pos < __len && __beg != __end && __name[__pos] == *__beg) + ++__beg, (void)++__pos; + + if (__len == __pos) + __member = __matches[0]; + else + __testvalid = false; + } + else + __testvalid = false; + if (!__testvalid) + __err |= ios_base::failbit; + + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + _M_extract_wday_or_month(iter_type __beg, iter_type __end, int& __member, + const _CharT** __names, size_t __indexlen, + ios_base& __io, ios_base::iostate& __err) const + { + typedef char_traits<_CharT> __traits_type; + const locale& __loc = __io._M_getloc(); + const ctype<_CharT>& __ctype = use_facet >(__loc); + + int* __matches = static_cast(__builtin_alloca(2 * sizeof(int) + * __indexlen)); + size_t __nmatches = 0; + size_t* __matches_lengths = 0; + size_t __pos = 0; + + if (__beg != __end) + { + const char_type __c = *__beg; + for (size_t __i = 0; __i < 2 * __indexlen; ++__i) + if (__c == __names[__i][0] + || __c == __ctype.toupper(__names[__i][0])) + __matches[__nmatches++] = __i; + } + + if (__nmatches) + { + ++__beg; + ++__pos; + + __matches_lengths + = static_cast(__builtin_alloca(sizeof(size_t) + * __nmatches)); + for (size_t __i = 0; __i < __nmatches; ++__i) + __matches_lengths[__i] + = __traits_type::length(__names[__matches[__i]]); + } + + for (; __beg != __end; ++__beg, (void)++__pos) + { + size_t __nskipped = 0; + const char_type __c = *__beg; + for (size_t __i = 0; __i < __nmatches;) + { + const char_type* __name = __names[__matches[__i]]; + if (__pos >= __matches_lengths[__i]) + ++__nskipped, ++__i; + else if (!(__name[__pos] == __c)) + { + --__nmatches; + __matches[__i] = __matches[__nmatches]; + __matches_lengths[__i] = __matches_lengths[__nmatches]; + } + else + ++__i; + } + if (__nskipped == __nmatches) + break; + } + + if ((__nmatches == 1 && __matches_lengths[0] == __pos) + || (__nmatches == 2 && (__matches_lengths[0] == __pos + || __matches_lengths[1] == __pos))) + __member = (__matches[0] >= (int)__indexlen + ? __matches[0] - (int)__indexlen : __matches[0]); + else + __err |= ios_base::failbit; + + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_time(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __times[2]; + __tp._M_time_formats(__times); + __beg = _M_extract_via_format(__beg, __end, __io, __err, + __tm, __times[0]); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_date(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __dates[2]; + __tp._M_date_formats(__dates); + __beg = _M_extract_via_format(__beg, __end, __io, __err, + __tm, __dates[0]); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __days[14]; + __tp._M_days_abbreviated(__days); + __tp._M_days(__days + 7); + int __tmpwday; + ios_base::iostate __tmperr = ios_base::goodbit; + + __beg = _M_extract_wday_or_month(__beg, __end, __tmpwday, __days, 7, + __io, __tmperr); + if (!__tmperr) + __tm->tm_wday = __tmpwday; + else + __err |= ios_base::failbit; + + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_monthname(iter_type __beg, iter_type __end, + ios_base& __io, ios_base::iostate& __err, tm* __tm) const + { + const locale& __loc = __io._M_getloc(); + const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc); + const char_type* __months[24]; + __tp._M_months_abbreviated(__months); + __tp._M_months(__months + 12); + int __tmpmon; + ios_base::iostate __tmperr = ios_base::goodbit; + + __beg = _M_extract_wday_or_month(__beg, __end, __tmpmon, __months, 12, + __io, __tmperr); + if (!__tmperr) + __tm->tm_mon = __tmpmon; + else + __err |= ios_base::failbit; + + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + + template + _InIter + time_get<_CharT, _InIter>:: + do_get_year(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm) const + { + int __tmpyear; + ios_base::iostate __tmperr = ios_base::goodbit; + + __beg = _M_extract_num(__beg, __end, __tmpyear, 0, 9999, 4, + __io, __tmperr); + if (!__tmperr) + __tm->tm_year = __tmpyear < 0 ? __tmpyear + 100 : __tmpyear - 1900; + else + __err |= ios_base::failbit; + + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#if __cplusplus >= 201103L + template + inline + _InIter + time_get<_CharT, _InIter>:: + get(iter_type __s, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, const char_type* __fmt, + const char_type* __fmtend) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + __err = ios_base::goodbit; + while (__fmt != __fmtend && + __err == ios_base::goodbit) + { + if (__s == __end) + { + __err = ios_base::eofbit | ios_base::failbit; + break; + } + else if (__ctype.narrow(*__fmt, 0) == '%') + { + char __format; + char __mod = 0; + if (++__fmt == __fmtend) + { + __err = ios_base::failbit; + break; + } + const char __c = __ctype.narrow(*__fmt, 0); + if (__c != 'E' && __c != 'O') + __format = __c; + else if (++__fmt != __fmtend) + { + __mod = __c; + __format = __ctype.narrow(*__fmt, 0); + } + else + { + __err = ios_base::failbit; + break; + } + __s = this->do_get(__s, __end, __io, __err, __tm, __format, + __mod); + ++__fmt; + } + else if (__ctype.is(ctype_base::space, *__fmt)) + { + ++__fmt; + while (__fmt != __fmtend && + __ctype.is(ctype_base::space, *__fmt)) + ++__fmt; + + while (__s != __end && + __ctype.is(ctype_base::space, *__s)) + ++__s; + } + // TODO real case-insensitive comparison + else if (__ctype.tolower(*__s) == __ctype.tolower(*__fmt) || + __ctype.toupper(*__s) == __ctype.toupper(*__fmt)) + { + ++__s; + ++__fmt; + } + else + { + __err = ios_base::failbit; + break; + } + } + return __s; + } + + template + inline + _InIter + time_get<_CharT, _InIter>:: + do_get(iter_type __beg, iter_type __end, ios_base& __io, + ios_base::iostate& __err, tm* __tm, + char __format, char __mod) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + __err = ios_base::goodbit; + + char_type __fmt[4]; + __fmt[0] = __ctype.widen('%'); + if (!__mod) + { + __fmt[1] = __format; + __fmt[2] = char_type(); + } + else + { + __fmt[1] = __mod; + __fmt[2] = __format; + __fmt[3] = char_type(); + } + + __beg = _M_extract_via_format(__beg, __end, __io, __err, __tm, __fmt); + if (__beg == __end) + __err |= ios_base::eofbit; + return __beg; + } + +#endif // __cplusplus >= 201103L + + template + _OutIter + time_put<_CharT, _OutIter>:: + put(iter_type __s, ios_base& __io, char_type __fill, const tm* __tm, + const _CharT* __beg, const _CharT* __end) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + for (; __beg != __end; ++__beg) + if (__ctype.narrow(*__beg, 0) != '%') + { + *__s = *__beg; + ++__s; + } + else if (++__beg != __end) + { + char __format; + char __mod = 0; + const char __c = __ctype.narrow(*__beg, 0); + if (__c != 'E' && __c != 'O') + __format = __c; + else if (++__beg != __end) + { + __mod = __c; + __format = __ctype.narrow(*__beg, 0); + } + else + break; + __s = this->do_put(__s, __io, __fill, __tm, __format, __mod); + } + else + break; + return __s; + } + + template + _OutIter + time_put<_CharT, _OutIter>:: + do_put(iter_type __s, ios_base& __io, char_type, const tm* __tm, + char __format, char __mod) const + { + const locale& __loc = __io._M_getloc(); + ctype<_CharT> const& __ctype = use_facet >(__loc); + __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc); + + // NB: This size is arbitrary. Should this be a data member, + // initialized at construction? + const size_t __maxlen = 128; + char_type __res[__maxlen]; + + // NB: In IEE 1003.1-200x, and perhaps other locale models, it + // is possible that the format character will be longer than one + // character. Possibilities include 'E' or 'O' followed by a + // format character: if __mod is not the default argument, assume + // it's a valid modifier. + char_type __fmt[4]; + __fmt[0] = __ctype.widen('%'); + if (!__mod) + { + __fmt[1] = __format; + __fmt[2] = char_type(); + } + else + { + __fmt[1] = __mod; + __fmt[2] = __format; + __fmt[3] = char_type(); + } + + __tp._M_put(__res, __maxlen, __fmt, __tm); + + // Write resulting, fully-formatted string to output iterator. + return std::__write(__s, __res, char_traits::length(__res)); + } + + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class moneypunct; + extern template class moneypunct; + extern template class moneypunct_byname; + extern template class moneypunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put; + extern template class __timepunct; + extern template class time_put; + extern template class time_put_byname; + extern template class time_get; + extern template class time_get_byname; + extern template class messages; + extern template class messages_byname; + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const money_put& + use_facet >(const locale&); + + extern template + const money_get& + use_facet >(const locale&); + + extern template + const __timepunct& + use_facet<__timepunct >(const locale&); + + extern template + const time_put& + use_facet >(const locale&); + + extern template + const time_get& + use_facet >(const locale&); + + extern template + const messages& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet<__timepunct >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class moneypunct; + extern template class moneypunct; + extern template class moneypunct_byname; + extern template class moneypunct_byname; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_get; + extern template class _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 money_put; + extern template class __timepunct; + extern template class time_put; + extern template class time_put_byname; + extern template class time_get; + extern template class time_get_byname; + extern template class messages; + extern template class messages_byname; + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const moneypunct& + use_facet >(const locale&); + + extern template + const money_put& + use_facet >(const locale&); + + extern template + const money_get& + use_facet >(const locale&); + + extern template + const __timepunct& + use_facet<__timepunct >(const locale&); + + extern template + const time_put& + use_facet >(const locale&); + + extern template + const time_get& + use_facet >(const locale&); + + extern template + const messages& + use_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet<__timepunct >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); + + extern template + bool + has_facet >(const locale&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/localefwd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/localefwd.h new file mode 100755 index 0000000..9bc35e9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/localefwd.h @@ -0,0 +1,214 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/localefwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{locale} + */ + +// +// ISO C++ 14882: 22.1 Locales +// + +#ifndef _LOCALE_FWD_H +#define _LOCALE_FWD_H 1 + +#pragma GCC system_header + +#include +#include // Defines __c_locale, config-specific include +#include // For ostreambuf_iterator, istreambuf_iterator +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup locales Locales + * + * Classes and functions for internationalization and localization. + */ + + // 22.1.1 Locale + class locale; + + template + bool + has_facet(const locale&) throw(); + + template + const _Facet& + use_facet(const locale&); + + // 22.1.3 Convenience interfaces + template + bool + isspace(_CharT, const locale&); + + template + bool + isprint(_CharT, const locale&); + + template + bool + iscntrl(_CharT, const locale&); + + template + bool + isupper(_CharT, const locale&); + + template + bool + islower(_CharT, const locale&); + + template + bool + isalpha(_CharT, const locale&); + + template + bool + isdigit(_CharT, const locale&); + + template + bool + ispunct(_CharT, const locale&); + + template + bool + isxdigit(_CharT, const locale&); + + template + bool + isalnum(_CharT, const locale&); + + template + bool + isgraph(_CharT, const locale&); + +#if __cplusplus >= 201103L + template + bool + isblank(_CharT, const locale&); +#endif + + template + _CharT + toupper(_CharT, const locale&); + + template + _CharT + tolower(_CharT, const locale&); + + // 22.2.1 and 22.2.1.3 ctype + struct ctype_base; + template + class ctype; + template<> class ctype; +#ifdef _GLIBCXX_USE_WCHAR_T + template<> class ctype; +#endif + template + class ctype_byname; + // NB: Specialized for char and wchar_t in locale_facets.h. + + class codecvt_base; + template + class codecvt; + template<> class codecvt; +#ifdef _GLIBCXX_USE_WCHAR_T + template<> class codecvt; +#endif +#if __cplusplus >= 201103L + template<> class codecvt; + template<> class codecvt; +#ifdef _GLIBCXX_USE_CHAR8_T + template<> class codecvt; + template<> class codecvt; +#endif +#endif + template + class codecvt_byname; + + // 22.2.2 and 22.2.3 numeric +_GLIBCXX_BEGIN_NAMESPACE_LDBL + template > + class num_get; + template > + class num_put; +_GLIBCXX_END_NAMESPACE_LDBL +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template class numpunct; + template class numpunct_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + // 22.2.4 collation + template + class collate; + template + class collate_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + + // 22.2.5 date and time + class time_base; +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template > + class time_get; + template > + class time_get_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + template > + class time_put; + template > + class time_put_byname; + + // 22.2.6 money + class money_base; +_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 + template > + class money_get; + template > + class money_put; +_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template + class moneypunct; + template + class moneypunct_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + + // 22.2.7 message retrieval + struct messages_base; +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template + class messages; + template + class messages_byname; +_GLIBCXX_END_NAMESPACE_CXX11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/mask_array.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/mask_array.h new file mode 100755 index 0000000..3889bd1 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/mask_array.h @@ -0,0 +1,213 @@ +// The template and inlines for the -*- C++ -*- mask_array class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/mask_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _MASK_ARRAY_H +#define _MASK_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Reference to selected subset of an array. + * + * A mask_array is a reference to the actual elements of an array specified + * by a bitmask in the form of an array of bool. The way to get a + * mask_array is to call operator[](valarray) on a valarray. The + * returned mask_array then permits carrying operations out on the + * referenced subset of elements in the original valarray. + * + * For example, if a mask_array is obtained using the array (false, true, + * false, true) as an argument, the mask array has two elements referring + * to array[1] and array[3] in the underlying array. + * + * @param Tp Element type. + */ + template + class mask_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + mask_array (const mask_array&); + + /// Assignment operator. Assigns elements to corresponding elements + /// of @a a. + mask_array& operator=(const mask_array&); + + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator=(const _Tp&) const; + + // ~mask_array (); + + template + void operator=(const _Expr<_Dom,_Tp>&) const; + template + void operator*=(const _Expr<_Dom,_Tp>&) const; + template + void operator/=(const _Expr<_Dom,_Tp>&) const; + template + void operator%=(const _Expr<_Dom,_Tp>&) const; + template + void operator+=(const _Expr<_Dom,_Tp>&) const; + template + void operator-=(const _Expr<_Dom,_Tp>&) const; + template + void operator^=(const _Expr<_Dom,_Tp>&) const; + template + void operator&=(const _Expr<_Dom,_Tp>&) const; + template + void operator|=(const _Expr<_Dom,_Tp>&) const; + template + void operator<<=(const _Expr<_Dom,_Tp>&) const; + template + void operator>>=(const _Expr<_Dom,_Tp>&) const; + + private: + mask_array(_Array<_Tp>, size_t, _Array); + friend class valarray<_Tp>; + + const size_t _M_sz; + const _Array _M_mask; + const _Array<_Tp> _M_array; + +#if __cplusplus < 201103L + // not implemented + mask_array(); +#else + public: + mask_array() = delete; +#endif + }; + + template + inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& __a) + : _M_sz(__a._M_sz), _M_mask(__a._M_mask), _M_array(__a._M_array) {} + + template + inline + mask_array<_Tp>::mask_array(_Array<_Tp> __a, size_t __s, _Array __m) + : _M_sz(__s), _M_mask(__m), _M_array(__a) {} + + template + inline mask_array<_Tp>& + mask_array<_Tp>::operator=(const mask_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, __a._M_mask, + _M_sz, _M_array, _M_mask); + return *this; + } + + template + inline void + mask_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_sz, _M_mask, __t); } + + template + inline void + mask_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), __v.size(), _M_array, _M_mask); } + + template + template + inline void + mask_array<_Tp>::operator=(const _Expr<_Ex, _Tp>& __e) const + { std::__valarray_copy(__e, __e.size(), _M_array, _M_mask); } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ + template \ + inline void \ + mask_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ + { \ + _Array_augmented_##_Name(_M_array, _M_mask, \ + _Array<_Tp>(__v), __v.size()); \ + } \ + \ + template \ + template \ + inline void \ + mask_array<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_mask, __e, __e.size()); \ + } + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _MASK_ARRAY_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/max_size_type.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/max_size_type.h new file mode 100755 index 0000000..153b1bf --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/max_size_type.h @@ -0,0 +1,827 @@ +// -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/max_size_type.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _GLIBCXX_MAX_SIZE_TYPE_H +#define _GLIBCXX_MAX_SIZE_TYPE_H 1 + +#pragma GCC system_header + +#if __cplusplus > 201703L && __cpp_lib_concepts +#include +#include + +// This header implements unsigned and signed integer-class types (as per +// [iterator.concept.winc]) that are one bit wider than the widest supported +// integer type. +// +// The set of integer types we consider includes __int128 and unsigned __int128 +// (when they exist), even though they are really integer types only in GNU +// mode. This is to obtain a consistent ABI for these integer-class types +// across strict mode and GNU mode. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +template + struct numeric_limits; + +namespace ranges +{ + namespace __detail + { + class __max_size_type + { + public: + __max_size_type() = default; + + template requires integral<_Tp> || __is_int128<_Tp> + constexpr + __max_size_type(_Tp __i) noexcept + : _M_val(__i), _M_msb(__i < 0) + { } + + constexpr explicit + __max_size_type(const __max_diff_type& __d) noexcept; + + template requires integral<_Tp> || __is_int128<_Tp> + constexpr explicit + operator _Tp() const noexcept + { return _M_val; } + + constexpr explicit + operator bool() const noexcept + { return _M_val != 0 || _M_msb != 0; } + + constexpr __max_size_type + operator+() const noexcept + { return *this; } + + constexpr __max_size_type + operator~() const noexcept + { return __max_size_type{~_M_val, !_M_msb}; } + + constexpr __max_size_type + operator-() const noexcept + { return operator~() + 1; } + + constexpr __max_size_type& + operator++() noexcept + { return *this += 1; } + + constexpr __max_size_type + operator++(int) noexcept + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr __max_size_type& + operator--() noexcept + { return *this -= 1; } + + constexpr __max_size_type + operator--(int) noexcept + { + auto __tmp = *this; + --*this; + return __tmp; + } + + constexpr __max_size_type& + operator+=(const __max_size_type& __r) noexcept + { + const auto __sum = _M_val + __r._M_val; + const bool __overflow = (__sum < _M_val); + _M_msb = _M_msb ^ __r._M_msb ^ __overflow; + _M_val = __sum; + return *this; + } + + constexpr __max_size_type& + operator-=(const __max_size_type& __r) noexcept + { return *this += -__r; } + + constexpr __max_size_type& + operator*=(__max_size_type __r) noexcept + { + constexpr __max_size_type __threshold + = __rep(1) << (_S_rep_bits / 2 - 1); + if (_M_val < __threshold && __r < __threshold) + // When both operands are below this threshold then the + // multiplication can be safely computed in the base precision. + _M_val = _M_val * __r._M_val; + else + { + // Otherwise, perform the multiplication in four steps, by + // decomposing the LHS and the RHS into 2*x+a and 2*y+b, + // respectively, and computing 4*x*y + 2*x*b + 2*y*a + a*b. + const bool __lsb = _M_val & 1; + const bool __rlsb = __r._M_val & 1; + *this >>= 1; + __r >>= 1; + _M_val = (2 * _M_val * __r._M_val + + _M_val * __rlsb + __r._M_val * __lsb); + *this <<= 1; + *this += __rlsb * __lsb; + } + + return *this; + } + + constexpr __max_size_type& + operator/=(const __max_size_type& __r) noexcept + { + __glibcxx_assert(__r != 0); + + if (!_M_msb && !__r._M_msb) [[likely]] + _M_val /= __r._M_val; + else if (_M_msb && __r._M_msb) + { + _M_val = (_M_val >= __r._M_val); + _M_msb = 0; + } + else if (!_M_msb && __r._M_msb) + _M_val = 0; + else if (_M_msb && !__r._M_msb) + { + // The non-trivial case: the dividend has its MSB set and the + // divisor doesn't. In this case we compute ((LHS/2)/RHS)*2 + // in the base precision. This quantity is either the true + // quotient or one less than the true quotient. + const auto __orig = *this; + *this >>= 1; + _M_val /= __r._M_val; + *this <<= 1; + if (__orig - *this * __r >= __r) + ++_M_val; + } + return *this; + } + + constexpr __max_size_type& + operator%=(const __max_size_type& __r) noexcept + { + if (!_M_msb && !__r._M_msb) [[likely]] + _M_val %= __r._M_val; + else + *this -= (*this / __r) * __r; + return *this; + } + + constexpr __max_size_type& + operator<<=(const __max_size_type& __r) noexcept + { + __glibcxx_assert(__r <= _S_rep_bits); + if (__r != 0) + { + _M_msb = (_M_val >> (_S_rep_bits - __r._M_val)) & 1; + + if (__r._M_val == _S_rep_bits) [[unlikely]] + _M_val = 0; + else + _M_val <<= __r._M_val; + } + return *this; + } + + constexpr __max_size_type& + operator>>=(const __max_size_type& __r) noexcept + { + __glibcxx_assert(__r <= _S_rep_bits); + if (__r != 0) + { + if (__r._M_val == _S_rep_bits) [[unlikely]] + _M_val = 0; + else + _M_val >>= __r._M_val; + + if (_M_msb) [[unlikely]] + { + _M_val |= __rep(1) << (_S_rep_bits - __r._M_val); + _M_msb = 0; + } + } + return *this; + } + + constexpr __max_size_type& + operator&=(const __max_size_type& __r) noexcept + { + _M_val &= __r._M_val; + _M_msb &= __r._M_msb; + return *this; + } + + constexpr __max_size_type& + operator|=(const __max_size_type& __r) noexcept + { + _M_val |= __r._M_val; + _M_msb |= __r._M_msb; + return *this; + } + + constexpr __max_size_type& + operator^=(const __max_size_type& __r) noexcept + { + _M_val ^= __r._M_val; + _M_msb ^= __r._M_msb; + return *this; + } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator+=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a + __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator-=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a - __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator*=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a * __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator/=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a / __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator%=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a % __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator&=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a & __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator|=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a | __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator^=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a ^ __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator<<=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a << __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator>>=(_Tp& __a, const __max_size_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a >> __b)); } + + friend constexpr __max_size_type + operator+(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l += __r; + return __l; + } + + friend constexpr __max_size_type + operator-(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l -= __r; + return __l; + } + + friend constexpr __max_size_type + operator*(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l *= __r; + return __l; + } + + friend constexpr __max_size_type + operator/(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l /= __r; + return __l; + } + + friend constexpr __max_size_type + operator%(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l %= __r; + return __l; + } + + friend constexpr __max_size_type + operator<<(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l <<= __r; + return __l; + } + + friend constexpr __max_size_type + operator>>(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l >>= __r; + return __l; + } + + friend constexpr __max_size_type + operator&(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l &= __r; + return __l; + } + + friend constexpr __max_size_type + operator|(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l |= __r; + return __l; + } + + friend constexpr __max_size_type + operator^(__max_size_type __l, const __max_size_type& __r) noexcept + { + __l ^= __r; + return __l; + } + + friend constexpr bool + operator==(const __max_size_type& __l, const __max_size_type& __r) noexcept + { return __l._M_val == __r._M_val && __l._M_msb == __r._M_msb; } + +#if __cpp_lib_three_way_comparison + friend constexpr strong_ordering + operator<=>(const __max_size_type& __l, const __max_size_type& __r) noexcept + { + if (__l._M_msb ^ __r._M_msb) + return __l._M_msb ? strong_ordering::greater : strong_ordering::less; + else + return __l._M_val <=> __r._M_val; + } +#else + friend constexpr bool + operator!=(const __max_size_type& __l, const __max_size_type& __r) noexcept + { return !(__l == __r); } + + friend constexpr bool + operator<(const __max_size_type& __l, const __max_size_type& __r) noexcept + { + if (__l._M_msb == __r._M_msb) + return __l._M_val < __r._M_val; + else + return __r._M_msb; + } + + friend constexpr bool + operator>(const __max_size_type& __l, const __max_size_type& __r) noexcept + { return __r < __l; } + + friend constexpr bool + operator<=(const __max_size_type& __l, const __max_size_type& __r) noexcept + { return !(__l > __r); } + + friend constexpr bool + operator>=(const __max_size_type& __l, const __max_size_type& __r) noexcept + { return __r <= __l; } +#endif + +#if __SIZEOF_INT128__ + using __rep = unsigned __int128; +#else + using __rep = unsigned long long; +#endif + static constexpr size_t _S_rep_bits = sizeof(__rep) * __CHAR_BIT__; + private: + __rep _M_val = 0; + unsigned _M_msb:1 = 0; + + constexpr explicit + __max_size_type(__rep __val, int __msb) noexcept + : _M_val(__val), _M_msb(__msb) + { } + + friend __max_diff_type; + friend std::numeric_limits<__max_size_type>; + friend std::numeric_limits<__max_diff_type>; + }; + + class __max_diff_type + { + public: + __max_diff_type() = default; + + template requires integral<_Tp> || __is_int128<_Tp> + constexpr + __max_diff_type(_Tp __i) noexcept + : _M_rep(__i) + { } + + constexpr explicit + __max_diff_type(const __max_size_type& __d) noexcept + : _M_rep(__d) + { } + + template requires integral<_Tp> || __is_int128<_Tp> + constexpr explicit + operator _Tp() const noexcept + { return static_cast<_Tp>(_M_rep); } + + constexpr explicit + operator bool() const noexcept + { return _M_rep != 0; } + + constexpr __max_diff_type + operator+() const noexcept + { return *this; } + + constexpr __max_diff_type + operator-() const noexcept + { return __max_diff_type(-_M_rep); } + + constexpr __max_diff_type + operator~() const noexcept + { return __max_diff_type(~_M_rep); } + + constexpr __max_diff_type& + operator++() noexcept + { return *this += 1; } + + constexpr __max_diff_type + operator++(int) noexcept + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr __max_diff_type& + operator--() noexcept + { return *this -= 1; } + + constexpr __max_diff_type + operator--(int) noexcept + { + auto __tmp = *this; + --*this; + return __tmp; + } + + constexpr __max_diff_type& + operator+=(const __max_diff_type& __r) noexcept + { + _M_rep += __r._M_rep; + return *this; + } + + constexpr __max_diff_type& + operator-=(const __max_diff_type& __r) noexcept + { + _M_rep -= __r._M_rep; + return *this; + } + + constexpr __max_diff_type& + operator*=(const __max_diff_type& __r) noexcept + { + _M_rep *= __r._M_rep; + return *this; + } + + constexpr __max_diff_type& + operator/=(const __max_diff_type& __r) noexcept + { + __glibcxx_assert (__r != 0); + const bool __neg = *this < 0; + const bool __rneg = __r < 0; + if (!__neg && !__rneg) + _M_rep = _M_rep / __r._M_rep; + else if (__neg && __rneg) + _M_rep = -_M_rep / -__r._M_rep; + else if (__neg && !__rneg) + _M_rep = -(-_M_rep / __r._M_rep); + else + _M_rep = -(_M_rep / -__r._M_rep); + return *this ; + } + + constexpr __max_diff_type& + operator%=(const __max_diff_type& __r) noexcept + { + __glibcxx_assert (__r != 0); + if (*this >= 0 && __r > 0) + _M_rep %= __r._M_rep; + else + *this -= (*this / __r) * __r; + return *this; + } + + constexpr __max_diff_type& + operator<<=(const __max_diff_type& __r) noexcept + { + _M_rep.operator<<=(__r._M_rep); + return *this; + } + + constexpr __max_diff_type& + operator>>=(const __max_diff_type& __r) noexcept + { + // Arithmetic right shift. + const auto __msb = _M_rep._M_msb; + _M_rep >>= __r._M_rep; + _M_rep._M_msb |= __msb; + return *this; + } + + constexpr __max_diff_type& + operator&=(const __max_diff_type& __r) noexcept + { + _M_rep &= __r._M_rep; + return *this; + } + + constexpr __max_diff_type& + operator|=(const __max_diff_type& __r) noexcept + { + _M_rep |= __r._M_rep; + return *this; + } + + constexpr __max_diff_type& + operator^=(const __max_diff_type& __r) noexcept + { + _M_rep ^= __r._M_rep; + return *this; + } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator+=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a + __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator-=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a - __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator*=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a * __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator/=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a / __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator%=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a % __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator&=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a & __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator|=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a | __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator^=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a ^ __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator<<=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a << __b)); } + + template requires integral<_Tp> || __is_int128<_Tp> + friend constexpr _Tp& + operator>>=(_Tp& __a, const __max_diff_type& __b) noexcept + { return (__a = static_cast<_Tp>(__a >> __b)); } + + friend constexpr __max_diff_type + operator+(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l += __r; + return __l; + } + + friend constexpr __max_diff_type + operator-(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l -= __r; + return __l; + } + + friend constexpr __max_diff_type + operator*(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l *= __r; + return __l; + } + + friend constexpr __max_diff_type + operator/(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l /= __r; + return __l; + } + + friend constexpr __max_diff_type + operator%(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l %= __r; + return __l; + } + + friend constexpr __max_diff_type + operator<<(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l <<= __r; + return __l; + } + + friend constexpr __max_diff_type + operator>>(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l >>= __r; + return __l; + } + + friend constexpr __max_diff_type + operator&(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l &= __r; + return __l; + } + + friend constexpr __max_diff_type + operator|(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l |= __r; + return __l; + } + + friend constexpr __max_diff_type + operator^(__max_diff_type __l, const __max_diff_type& __r) noexcept + { + __l ^= __r; + return __l; + } + + friend constexpr bool + operator==(const __max_diff_type& __l, const __max_diff_type& __r) noexcept + { return __l._M_rep == __r._M_rep; } + +#if __cpp_lib_three_way_comparison + constexpr strong_ordering + operator<=>(const __max_diff_type& __r) const noexcept + { + const auto __lsign = _M_rep._M_msb; + const auto __rsign = __r._M_rep._M_msb; + if (__lsign ^ __rsign) + return __lsign ? strong_ordering::less : strong_ordering::greater; + else + return _M_rep <=> __r._M_rep; + } +#else + friend constexpr bool + operator!=(const __max_diff_type& __l, const __max_diff_type& __r) noexcept + { return !(__l == __r); } + + constexpr bool + operator<(const __max_diff_type& __r) const noexcept + { + const auto __lsign = _M_rep._M_msb; + const auto __rsign = __r._M_rep._M_msb; + if (__lsign ^ __rsign) + return __lsign; + else + return _M_rep < __r._M_rep; + } + + friend constexpr bool + operator>(const __max_diff_type& __l, const __max_diff_type& __r) noexcept + { return __r < __l; } + + friend constexpr bool + operator<=(const __max_diff_type& __l, const __max_diff_type& __r) noexcept + { return !(__r < __l); } + + friend constexpr bool + operator>=(const __max_diff_type& __l, const __max_diff_type& __r) noexcept + { return !(__l < __r); } +#endif + + private: + __max_size_type _M_rep = 0; + + friend class __max_size_type; + }; + + constexpr + __max_size_type::__max_size_type(const __max_diff_type& __d) noexcept + : __max_size_type(__d._M_rep) + { } + + } // namespace __detail +} // namespace ranges + + template<> + struct numeric_limits + { + using _Sp = ranges::__detail::__max_size_type; + static constexpr bool is_specialized = true; + static constexpr bool is_signed = false; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; +#if __SIZEOF_INT128__ + static_assert(same_as<_Sp::__rep, unsigned __int128>); + static constexpr int digits = 129; +#else + static_assert(same_as<_Sp::__rep, unsigned long long>); + static constexpr int digits + = __gnu_cxx::__int_traits::__digits + 1; +#endif + static constexpr int digits10 + = static_cast(digits * numbers::ln2 / numbers::ln10); + + static constexpr _Sp + min() noexcept + { return 0; } + + static constexpr _Sp + max() noexcept + { return _Sp(static_cast<_Sp::__rep>(-1), 1); } + + static constexpr _Sp + lowest() noexcept + { return min(); } + }; + + template<> + struct numeric_limits + { + using _Dp = ranges::__detail::__max_diff_type; + using _Sp = ranges::__detail::__max_size_type; + static constexpr bool is_specialized = true; + static constexpr bool is_signed = true; + static constexpr bool is_integer = true; + static constexpr bool is_exact = true; + static constexpr int digits = numeric_limits<_Sp>::digits - 1; + static constexpr int digits10 + = static_cast(digits * numbers::ln2 / numbers::ln10); + + static constexpr _Dp + min() noexcept + { return _Dp(_Sp(0, 1)); } + + static constexpr _Dp + max() noexcept + { return _Dp(_Sp(static_cast<_Sp::__rep>(-1), 0)); } + + static constexpr _Dp + lowest() noexcept + { return min(); } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++20 && library concepts +#endif // _GLIBCXX_MAX_SIZE_TYPE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/memoryfwd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/memoryfwd.h new file mode 100755 index 0000000..b0f0307 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/memoryfwd.h @@ -0,0 +1,83 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1996-1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/memoryfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _MEMORYFWD_H +#define _MEMORYFWD_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup allocators Allocators + * @ingroup memory + * + * Classes encapsulating memory operations. + * + * @{ + */ + + template + class allocator; + + template<> + class allocator; + +#if __cplusplus >= 201103L + /// Declare uses_allocator so it can be specialized in `` etc. + template + struct uses_allocator; + + template + struct allocator_traits; +#endif + + /// @} group memory + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/move.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/move.h new file mode 100755 index 0000000..3abbb37 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/move.h @@ -0,0 +1,231 @@ +// Move, forward and identity for C++11 + swap -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/move.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + */ + +#ifndef _MOVE_H +#define _MOVE_H 1 + +#include +#if __cplusplus < 201103L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Used, in C++03 mode too, by allocators, etc. + /** + * @brief Same as C++11 std::addressof + * @ingroup utilities + */ + template + inline _GLIBCXX_CONSTEXPR _Tp* + __addressof(_Tp& __r) _GLIBCXX_NOEXCEPT + { return __builtin_addressof(__r); } + +#if __cplusplus >= 201103L + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include // Brings in std::declval too. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + + /** + * @brief Forward an lvalue. + * @return The parameter cast to the specified type. + * + * This function is used to implement "perfect forwarding". + */ + template + _GLIBCXX_NODISCARD + constexpr _Tp&& + forward(typename std::remove_reference<_Tp>::type& __t) noexcept + { return static_cast<_Tp&&>(__t); } + + /** + * @brief Forward an rvalue. + * @return The parameter cast to the specified type. + * + * This function is used to implement "perfect forwarding". + */ + template + _GLIBCXX_NODISCARD + constexpr _Tp&& + forward(typename std::remove_reference<_Tp>::type&& __t) noexcept + { + static_assert(!std::is_lvalue_reference<_Tp>::value, "template argument" + " substituting _Tp must not be an lvalue reference type"); + return static_cast<_Tp&&>(__t); + } + + /** + * @brief Convert a value to an rvalue. + * @param __t A thing of arbitrary type. + * @return The parameter cast to an rvalue-reference to allow moving it. + */ + template + _GLIBCXX_NODISCARD + constexpr typename std::remove_reference<_Tp>::type&& + move(_Tp&& __t) noexcept + { return static_cast::type&&>(__t); } + + + template + struct __move_if_noexcept_cond + : public __and_<__not_>, + is_copy_constructible<_Tp>>::type { }; + + /** + * @brief Conditionally convert a value to an rvalue. + * @param __x A thing of arbitrary type. + * @return The parameter, possibly cast to an rvalue-reference. + * + * Same as std::move unless the type's move constructor could throw and the + * type is copyable, in which case an lvalue-reference is returned instead. + */ + template + _GLIBCXX_NODISCARD + constexpr typename + conditional<__move_if_noexcept_cond<_Tp>::value, const _Tp&, _Tp&&>::type + move_if_noexcept(_Tp& __x) noexcept + { return std::move(__x); } + + // declval, from type_traits. + +#if __cplusplus > 201402L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2296. std::addressof should be constexpr +# define __cpp_lib_addressof_constexpr 201603 +#endif + /** + * @brief Returns the actual address of the object or function + * referenced by r, even in the presence of an overloaded + * operator&. + * @param __r Reference to an object or function. + * @return The actual address. + */ + template + _GLIBCXX_NODISCARD + inline _GLIBCXX17_CONSTEXPR _Tp* + addressof(_Tp& __r) noexcept + { return std::__addressof(__r); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2598. addressof works on temporaries + template + const _Tp* addressof(const _Tp&&) = delete; + + // C++11 version of std::exchange for internal use. + template + _GLIBCXX20_CONSTEXPR + inline _Tp + __exchange(_Tp& __obj, _Up&& __new_val) + { + _Tp __old_val = std::move(__obj); + __obj = std::forward<_Up>(__new_val); + return __old_val; + } + + /// @} group utilities + +#define _GLIBCXX_FWDREF(_Tp) _Tp&& +#define _GLIBCXX_MOVE(__val) std::move(__val) +#define _GLIBCXX_FORWARD(_Tp, __val) std::forward<_Tp>(__val) +#else +#define _GLIBCXX_FWDREF(_Tp) const _Tp& +#define _GLIBCXX_MOVE(__val) (__val) +#define _GLIBCXX_FORWARD(_Tp, __val) (__val) +#endif + + /** + * @addtogroup utilities + * @{ + */ + + /** + * @brief Swaps two values. + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return Nothing. + */ + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus >= 201103L + typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>, + is_move_constructible<_Tp>, + is_move_assignable<_Tp>>::value>::type +#else + void +#endif + swap(_Tp& __a, _Tp& __b) + _GLIBCXX_NOEXCEPT_IF(__and_, + is_nothrow_move_assignable<_Tp>>::value) + { +#if __cplusplus < 201103L + // concept requirements + __glibcxx_function_requires(_SGIAssignableConcept<_Tp>) +#endif + _Tp __tmp = _GLIBCXX_MOVE(__a); + __a = _GLIBCXX_MOVE(__b); + __b = _GLIBCXX_MOVE(__tmp); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 809. std::swap should be overloaded for array types. + /// Swap the contents of two arrays. + template + _GLIBCXX20_CONSTEXPR + inline +#if __cplusplus >= 201103L + typename enable_if<__is_swappable<_Tp>::value>::type +#else + void +#endif + swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Tp>::value) + { + for (size_t __n = 0; __n < _Nm; ++__n) + swap(__a[__n], __b[__n]); + } + + /// @} group utilities +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _MOVE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/nested_exception.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/nested_exception.h new file mode 100755 index 0000000..cfcd3e7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/nested_exception.h @@ -0,0 +1,171 @@ +// Nested Exception support header (nested_exception class) for -*- C++ -*- + +// Copyright (C) 2009-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/nested_exception.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{exception} + */ + +#ifndef _GLIBCXX_NESTED_EXCEPTION_H +#define _GLIBCXX_NESTED_EXCEPTION_H 1 + +#pragma GCC visibility push(default) + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +extern "C++" { + +namespace std +{ + /** + * @addtogroup exceptions + * @{ + */ + + /// Exception class with exception_ptr data member. + class nested_exception + { + exception_ptr _M_ptr; + + public: + nested_exception() noexcept : _M_ptr(current_exception()) { } + + nested_exception(const nested_exception&) noexcept = default; + + nested_exception& operator=(const nested_exception&) noexcept = default; + + virtual ~nested_exception() noexcept; + + [[noreturn]] + void + rethrow_nested() const + { + if (_M_ptr) + rethrow_exception(_M_ptr); + std::terminate(); + } + + exception_ptr + nested_ptr() const noexcept + { return _M_ptr; } + }; + + /// @cond undocumented + + template + struct _Nested_exception : public _Except, public nested_exception + { + explicit _Nested_exception(const _Except& __ex) + : _Except(__ex) + { } + + explicit _Nested_exception(_Except&& __ex) + : _Except(static_cast<_Except&&>(__ex)) + { } + }; + + // [except.nested]/8 + // Throw an exception of unspecified type that is publicly derived from + // both remove_reference_t<_Tp> and nested_exception. + template + [[noreturn]] + inline void + __throw_with_nested_impl(_Tp&& __t, true_type) + { + using _Up = typename remove_reference<_Tp>::type; + throw _Nested_exception<_Up>{std::forward<_Tp>(__t)}; + } + + template + [[noreturn]] + inline void + __throw_with_nested_impl(_Tp&& __t, false_type) + { throw std::forward<_Tp>(__t); } + + /// @endcond + + /// If @p __t is derived from nested_exception, throws @p __t. + /// Else, throws an implementation-defined object derived from both. + template + [[noreturn]] + inline void + throw_with_nested(_Tp&& __t) + { + using _Up = typename decay<_Tp>::type; + using _CopyConstructible + = __and_, is_move_constructible<_Up>>; + static_assert(_CopyConstructible::value, + "throw_with_nested argument must be CopyConstructible"); + using __nest = __and_, __bool_constant, + __not_>>; + std::__throw_with_nested_impl(std::forward<_Tp>(__t), __nest{}); + } + + /// @cond undocumented + + // Determine if dynamic_cast would be well-formed. + template + using __rethrow_if_nested_cond = typename enable_if< + __and_, + __or_<__not_>, + is_convertible<_Tp*, nested_exception*>>>::value + >::type; + + // Attempt dynamic_cast to nested_exception and call rethrow_nested(). + template + inline __rethrow_if_nested_cond<_Ex> + __rethrow_if_nested_impl(const _Ex* __ptr) + { + if (auto __ne_ptr = dynamic_cast(__ptr)) + __ne_ptr->rethrow_nested(); + } + + // Otherwise, no effects. + inline void + __rethrow_if_nested_impl(const void*) + { } + + /// @endcond + + /// If @p __ex is derived from nested_exception, @p __ex.rethrow_nested(). + template + inline void + rethrow_if_nested(const _Ex& __ex) + { std::__rethrow_if_nested_impl(std::__addressof(__ex)); } + + /// @} group exceptions +} // namespace std + +} // extern "C++" + +#endif // C++11 + +#pragma GCC visibility pop + +#endif // _GLIBCXX_NESTED_EXCEPTION_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/node_handle.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/node_handle.h new file mode 100755 index 0000000..9a43caf --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/node_handle.h @@ -0,0 +1,374 @@ +// Node handles for containers -*- C++ -*- + +// Copyright (C) 2016-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/node_handle.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + * @headername{map,set,unordered_map,unordered_set} + */ + +#ifndef _NODE_HANDLE +#define _NODE_HANDLE 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L +# define __cpp_lib_node_extract 201606 + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Base class for node handle types of maps and sets. + template + class _Node_handle_common + { + using _AllocTraits = allocator_traits<_NodeAlloc>; + + public: + using allocator_type = __alloc_rebind<_NodeAlloc, _Val>; + + allocator_type + get_allocator() const noexcept + { + __glibcxx_assert(!this->empty()); + return allocator_type(_M_alloc._M_alloc); + } + + explicit operator bool() const noexcept { return _M_ptr != nullptr; } + + [[nodiscard]] bool empty() const noexcept { return _M_ptr == nullptr; } + + protected: + constexpr _Node_handle_common() noexcept : _M_ptr() { } + + ~_Node_handle_common() + { + if (!empty()) + _M_reset(); + } + + _Node_handle_common(_Node_handle_common&& __nh) noexcept + : _M_ptr(__nh._M_ptr) + { + if (_M_ptr) + _M_move(std::move(__nh)); + } + + _Node_handle_common& + operator=(_Node_handle_common&& __nh) noexcept + { + if (empty()) + { + if (!__nh.empty()) + _M_move(std::move(__nh)); + } + else if (__nh.empty()) + _M_reset(); + else + { + // Free the current node before replacing the allocator. + _AllocTraits::destroy(*_M_alloc, _M_ptr->_M_valptr()); + _AllocTraits::deallocate(*_M_alloc, _M_ptr, 1); + + _M_alloc = __nh._M_alloc.release(); // assigns if POCMA + _M_ptr = __nh._M_ptr; + __nh._M_ptr = nullptr; + } + return *this; + } + + _Node_handle_common(typename _AllocTraits::pointer __ptr, + const _NodeAlloc& __alloc) + : _M_ptr(__ptr), _M_alloc(__alloc) + { + __glibcxx_assert(__ptr != nullptr); + } + + void + _M_swap(_Node_handle_common& __nh) noexcept + { + if (empty()) + { + if (!__nh.empty()) + _M_move(std::move(__nh)); + } + else if (__nh.empty()) + __nh._M_move(std::move(*this)); + else + { + using std::swap; + swap(_M_ptr, __nh._M_ptr); + _M_alloc.swap(__nh._M_alloc); // swaps if POCS + } + } + + private: + // Moves the pointer and allocator from __nh to *this. + // Precondition: empty() && !__nh.empty() + // Postcondition: !empty() && __nh.empty() + void + _M_move(_Node_handle_common&& __nh) noexcept + { + ::new (std::__addressof(_M_alloc)) _NodeAlloc(__nh._M_alloc.release()); + _M_ptr = __nh._M_ptr; + __nh._M_ptr = nullptr; + } + + // Deallocates the node, destroys the allocator. + // Precondition: !empty() + // Postcondition: empty() + void + _M_reset() noexcept + { + _NodeAlloc __alloc = _M_alloc.release(); + _AllocTraits::destroy(__alloc, _M_ptr->_M_valptr()); + _AllocTraits::deallocate(__alloc, _M_ptr, 1); + _M_ptr = nullptr; + } + + protected: + typename _AllocTraits::pointer _M_ptr; + + private: + // A simplified, non-copyable std::optional<_NodeAlloc>. + // Call release() before destruction iff the allocator member is active. + union _Optional_alloc + { + _Optional_alloc() { } + ~_Optional_alloc() { } + + _Optional_alloc(_Optional_alloc&&) = delete; + _Optional_alloc& operator=(_Optional_alloc&&) = delete; + + _Optional_alloc(const _NodeAlloc& __alloc) noexcept + : _M_alloc(__alloc) + { } + + // Precondition: _M_alloc is the active member of the union. + void + operator=(_NodeAlloc&& __alloc) noexcept + { + using _ATr = _AllocTraits; + if constexpr (_ATr::propagate_on_container_move_assignment::value) + _M_alloc = std::move(__alloc); + else if constexpr (!_AllocTraits::is_always_equal::value) + __glibcxx_assert(_M_alloc == __alloc); + } + + // Precondition: _M_alloc is the active member of both unions. + void + swap(_Optional_alloc& __other) noexcept + { + using std::swap; + if constexpr (_AllocTraits::propagate_on_container_swap::value) + swap(_M_alloc, __other._M_alloc); + else if constexpr (!_AllocTraits::is_always_equal::value) + __glibcxx_assert(_M_alloc == __other._M_alloc); + } + + // Precondition: _M_alloc is the active member of the union. + _NodeAlloc& operator*() noexcept { return _M_alloc; } + + // Precondition: _M_alloc is the active member of the union. + _NodeAlloc release() noexcept + { + _NodeAlloc __tmp = std::move(_M_alloc); + _M_alloc.~_NodeAlloc(); + return __tmp; + } + + struct _Empty { }; + + [[__no_unique_address__]] _Empty _M_empty; + [[__no_unique_address__]] _NodeAlloc _M_alloc; + }; + + [[__no_unique_address__]] _Optional_alloc _M_alloc; + + template + friend class _Rb_tree; + }; + + /// Node handle type for maps. + template + class _Node_handle : public _Node_handle_common<_Value, _NodeAlloc> + { + public: + constexpr _Node_handle() noexcept = default; + ~_Node_handle() = default; + _Node_handle(_Node_handle&&) noexcept = default; + + _Node_handle& + operator=(_Node_handle&&) noexcept = default; + + using key_type = _Key; + using mapped_type = typename _Value::second_type; + + key_type& + key() const noexcept + { + __glibcxx_assert(!this->empty()); + return *_M_pkey; + } + + mapped_type& + mapped() const noexcept + { + __glibcxx_assert(!this->empty()); + return *_M_pmapped; + } + + void + swap(_Node_handle& __nh) noexcept + { + this->_M_swap(__nh); + using std::swap; + swap(_M_pkey, __nh._M_pkey); + swap(_M_pmapped, __nh._M_pmapped); + } + + friend void + swap(_Node_handle& __x, _Node_handle& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + private: + using _AllocTraits = allocator_traits<_NodeAlloc>; + + _Node_handle(typename _AllocTraits::pointer __ptr, + const _NodeAlloc& __alloc) + : _Node_handle_common<_Value, _NodeAlloc>(__ptr, __alloc) + { + if (__ptr) + { + auto& __key = const_cast<_Key&>(__ptr->_M_valptr()->first); + _M_pkey = _S_pointer_to(__key); + _M_pmapped = _S_pointer_to(__ptr->_M_valptr()->second); + } + else + { + _M_pkey = nullptr; + _M_pmapped = nullptr; + } + } + + template + using __pointer + = __ptr_rebind>; + + __pointer<_Key> _M_pkey = nullptr; + __pointer _M_pmapped = nullptr; + + template + __pointer<_Tp> + _S_pointer_to(_Tp& __obj) + { return pointer_traits<__pointer<_Tp>>::pointer_to(__obj); } + + const key_type& + _M_key() const noexcept { return key(); } + + template + friend class _Rb_tree; + + template + friend class _Hashtable; + }; + + /// Node handle type for sets. + template + class _Node_handle<_Value, _Value, _NodeAlloc> + : public _Node_handle_common<_Value, _NodeAlloc> + { + public: + constexpr _Node_handle() noexcept = default; + ~_Node_handle() = default; + _Node_handle(_Node_handle&&) noexcept = default; + + _Node_handle& + operator=(_Node_handle&&) noexcept = default; + + using value_type = _Value; + + value_type& + value() const noexcept + { + __glibcxx_assert(!this->empty()); + return *this->_M_ptr->_M_valptr(); + } + + void + swap(_Node_handle& __nh) noexcept + { this->_M_swap(__nh); } + + friend void + swap(_Node_handle& __x, _Node_handle& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + private: + using _AllocTraits = allocator_traits<_NodeAlloc>; + + _Node_handle(typename _AllocTraits::pointer __ptr, + const _NodeAlloc& __alloc) + : _Node_handle_common<_Value, _NodeAlloc>(__ptr, __alloc) { } + + const value_type& + _M_key() const noexcept { return value(); } + + template + friend class _Rb_tree; + + template + friend class _Hashtable; + }; + + /// Return type of insert(node_handle&&) on unique maps/sets. + template + struct _Node_insert_return + { + _Iterator position = _Iterator(); + bool inserted = false; + _NodeHandle node; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++17 +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ostream.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ostream.tcc new file mode 100755 index 0000000..76ca285 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ostream.tcc @@ -0,0 +1,407 @@ +// ostream classes -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ostream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ostream} + */ + +// +// ISO C++ 14882: 27.6.2 Output streams +// + +#ifndef _OSTREAM_TCC +#define _OSTREAM_TCC 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + basic_ostream<_CharT, _Traits>::sentry:: + sentry(basic_ostream<_CharT, _Traits>& __os) + : _M_ok(false), _M_os(__os) + { + // XXX MT + if (__os.tie() && __os.good()) + __os.tie()->flush(); + + if (__os.good()) + _M_ok = true; + else + __os.setstate(ios_base::failbit); + } + + template + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + _M_insert(_ValueT __v) + { + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const __num_put_type& __np = __check_facet(this->_M_num_put); + if (__np.put(*this, *this, this->fill(), __v).failed()) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(short __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; + if (__fmt == ios_base::oct || __fmt == ios_base::hex) + return _M_insert(static_cast(static_cast(__n))); + else + return _M_insert(static_cast(__n)); + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(int __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 117. basic_ostream uses nonexistent num_put member functions. + const ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; + if (__fmt == ios_base::oct || __fmt == ios_base::hex) + return _M_insert(static_cast(static_cast(__n))); + else + return _M_insert(static_cast(__n)); + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + operator<<(__streambuf_type* __sbin) + { + ios_base::iostate __err = ios_base::goodbit; + sentry __cerb(*this); + if (__cerb && __sbin) + { + __try + { + if (!__copy_streambufs(__sbin, this->rdbuf())) + __err |= ios_base::failbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::failbit); } + } + else if (!__sbin) + __err |= ios_base::badbit; + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + put(char_type __c) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::put(char_type) is an unformatted output function. + // DR 63. Exception-handling policy for unformatted output. + // Unformatted output functions should catch exceptions thrown + // from streambuf members. + sentry __cerb(*this); + if (__cerb) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + const int_type __put = this->rdbuf()->sputc(__c); + if (traits_type::eq_int_type(__put, traits_type::eof())) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + write(const _CharT* __s, streamsize __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::write(const char_type*, streamsize) is an + // unformatted output function. + // DR 63. Exception-handling policy for unformatted output. + // Unformatted output functions should catch exceptions thrown + // from streambuf members. + sentry __cerb(*this); + if (__cerb) + { + __try + { _M_write(__s, __n); } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + } + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + flush() + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 60. What is a formatted input function? + // basic_ostream::flush() is *not* an unformatted output function. + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (this->rdbuf() && this->rdbuf()->pubsync() == -1) + __err |= ios_base::badbit; + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + return *this; + } + + template + typename basic_ostream<_CharT, _Traits>::pos_type + basic_ostream<_CharT, _Traits>:: + tellp() + { + pos_type __ret = pos_type(-1); + __try + { + if (!this->fail()) + __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + return __ret; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + seekp(pos_type __pos) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekpos(__pos, + ios_base::out); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + basic_ostream<_CharT, _Traits>:: + seekp(off_type __off, ios_base::seekdir __dir) + { + ios_base::iostate __err = ios_base::goodbit; + __try + { + if (!this->fail()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 136. seekp, seekg setting wrong streams? + const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir, + ios_base::out); + + // 129. Need error indication from seekp() and seekg() + if (__p == pos_type(off_type(-1))) + __err |= ios_base::failbit; + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); + return *this; + } + + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) + { + if (!__s) + __out.setstate(ios_base::badbit); + else + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 167. Improper use of traits_type::length() + const size_t __clen = char_traits::length(__s); + __try + { + struct __ptr_guard + { + _CharT *__p; + __ptr_guard (_CharT *__ip): __p(__ip) { } + ~__ptr_guard() { delete[] __p; } + _CharT* __get() { return __p; } + } __pg (new _CharT[__clen]); + + _CharT *__ws = __pg.__get(); + for (size_t __i = 0; __i < __clen; ++__i) + __ws[__i] = __out.widen(__s[__i]); + __ostream_insert(__out, __ws, __clen); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __out._M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __out._M_setstate(ios_base::badbit); } + } + return __out; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_ostream; + extern template ostream& endl(ostream&); + extern template ostream& ends(ostream&); + extern template ostream& flush(ostream&); + extern template ostream& operator<<(ostream&, char); + extern template ostream& operator<<(ostream&, unsigned char); + extern template ostream& operator<<(ostream&, signed char); + extern template ostream& operator<<(ostream&, const char*); + extern template ostream& operator<<(ostream&, const unsigned char*); + extern template ostream& operator<<(ostream&, const signed char*); + + extern template ostream& ostream::_M_insert(long); + extern template ostream& ostream::_M_insert(unsigned long); + extern template ostream& ostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template ostream& ostream::_M_insert(long long); + extern template ostream& ostream::_M_insert(unsigned long long); +#endif + extern template ostream& ostream::_M_insert(double); + extern template ostream& ostream::_M_insert(long double); + extern template ostream& ostream::_M_insert(const void*); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_ostream; + extern template wostream& endl(wostream&); + extern template wostream& ends(wostream&); + extern template wostream& flush(wostream&); + extern template wostream& operator<<(wostream&, wchar_t); + extern template wostream& operator<<(wostream&, char); + extern template wostream& operator<<(wostream&, const wchar_t*); + extern template wostream& operator<<(wostream&, const char*); + + extern template wostream& wostream::_M_insert(long); + extern template wostream& wostream::_M_insert(unsigned long); + extern template wostream& wostream::_M_insert(bool); +#ifdef _GLIBCXX_USE_LONG_LONG + extern template wostream& wostream::_M_insert(long long); + extern template wostream& wostream::_M_insert(unsigned long long); +#endif + extern template wostream& wostream::_M_insert(double); + extern template wostream& wostream::_M_insert(long double); + extern template wostream& wostream::_M_insert(const void*); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ostream_insert.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ostream_insert.h new file mode 100755 index 0000000..72eea8b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ostream_insert.h @@ -0,0 +1,130 @@ +// Helpers for ostream inserters -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ostream_insert.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ostream} + */ + +#ifndef _OSTREAM_INSERT_H +#define _OSTREAM_INSERT_H 1 + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + inline void + __ostream_write(basic_ostream<_CharT, _Traits>& __out, + const _CharT* __s, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + const streamsize __put = __out.rdbuf()->sputn(__s, __n); + if (__put != __n) + __out.setstate(__ios_base::badbit); + } + + template + inline void + __ostream_fill(basic_ostream<_CharT, _Traits>& __out, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + const _CharT __c = __out.fill(); + for (; __n > 0; --__n) + { + const typename _Traits::int_type __put = __out.rdbuf()->sputc(__c); + if (_Traits::eq_int_type(__put, _Traits::eof())) + { + __out.setstate(__ios_base::badbit); + break; + } + } + } + + template + basic_ostream<_CharT, _Traits>& + __ostream_insert(basic_ostream<_CharT, _Traits>& __out, + const _CharT* __s, streamsize __n) + { + typedef basic_ostream<_CharT, _Traits> __ostream_type; + typedef typename __ostream_type::ios_base __ios_base; + + typename __ostream_type::sentry __cerb(__out); + if (__cerb) + { + __try + { + const streamsize __w = __out.width(); + if (__w > __n) + { + const bool __left = ((__out.flags() + & __ios_base::adjustfield) + == __ios_base::left); + if (!__left) + __ostream_fill(__out, __w - __n); + if (__out.good()) + __ostream_write(__out, __s, __n); + if (__left && __out.good()) + __ostream_fill(__out, __w - __n); + } + else + __ostream_write(__out, __s, __n); + __out.width(0); + } + __catch(__cxxabiv1::__forced_unwind&) + { + __out._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __out._M_setstate(__ios_base::badbit); } + } + return __out; + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template ostream& __ostream_insert(ostream&, const char*, streamsize); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wostream& __ostream_insert(wostream&, const wchar_t*, + streamsize); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _OSTREAM_INSERT_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/parse_numbers.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/parse_numbers.h new file mode 100755 index 0000000..5618661 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/parse_numbers.h @@ -0,0 +1,295 @@ +// Components for compile-time parsing of numbers -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/parse_numbers.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{chrono} + */ + +#ifndef _GLIBCXX_PARSE_NUMBERS_H +#define _GLIBCXX_PARSE_NUMBERS_H 1 + +#pragma GCC system_header + +// From n3642.pdf except I added binary literals and digit separator '\''. + +#if __cplusplus >= 201402L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __parse_int +{ + template + struct _Digit; + + template + struct _Digit<_Base, '0'> : integral_constant + { + using __valid = true_type; + }; + + template + struct _Digit<_Base, '1'> : integral_constant + { + using __valid = true_type; + }; + + template + struct _Digit_impl : integral_constant + { + static_assert(_Base > _Val, "invalid digit"); + using __valid = true_type; + }; + + template + struct _Digit<_Base, '2'> : _Digit_impl<_Base, 2> + { }; + + template + struct _Digit<_Base, '3'> : _Digit_impl<_Base, 3> + { }; + + template + struct _Digit<_Base, '4'> : _Digit_impl<_Base, 4> + { }; + + template + struct _Digit<_Base, '5'> : _Digit_impl<_Base, 5> + { }; + + template + struct _Digit<_Base, '6'> : _Digit_impl<_Base, 6> + { }; + + template + struct _Digit<_Base, '7'> : _Digit_impl<_Base, 7> + { }; + + template + struct _Digit<_Base, '8'> : _Digit_impl<_Base, 8> + { }; + + template + struct _Digit<_Base, '9'> : _Digit_impl<_Base, 9> + { }; + + template + struct _Digit<_Base, 'a'> : _Digit_impl<_Base, 0xa> + { }; + + template + struct _Digit<_Base, 'A'> : _Digit_impl<_Base, 0xa> + { }; + + template + struct _Digit<_Base, 'b'> : _Digit_impl<_Base, 0xb> + { }; + + template + struct _Digit<_Base, 'B'> : _Digit_impl<_Base, 0xb> + { }; + + template + struct _Digit<_Base, 'c'> : _Digit_impl<_Base, 0xc> + { }; + + template + struct _Digit<_Base, 'C'> : _Digit_impl<_Base, 0xc> + { }; + + template + struct _Digit<_Base, 'd'> : _Digit_impl<_Base, 0xd> + { }; + + template + struct _Digit<_Base, 'D'> : _Digit_impl<_Base, 0xd> + { }; + + template + struct _Digit<_Base, 'e'> : _Digit_impl<_Base, 0xe> + { }; + + template + struct _Digit<_Base, 'E'> : _Digit_impl<_Base, 0xe> + { }; + + template + struct _Digit<_Base, 'f'> : _Digit_impl<_Base, 0xf> + { }; + + template + struct _Digit<_Base, 'F'> : _Digit_impl<_Base, 0xf> + { }; + + // Digit separator + template + struct _Digit<_Base, '\''> : integral_constant + { + using __valid = false_type; + }; + +//------------------------------------------------------------------------------ + + template + using __ull_constant = integral_constant; + + template + struct _Power_help + { + using __next = typename _Power_help<_Base, _Digs...>::type; + using __valid_digit = typename _Digit<_Base, _Dig>::__valid; + using type + = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>; + }; + + template + struct _Power_help<_Base, _Dig> + { + using __valid_digit = typename _Digit<_Base, _Dig>::__valid; + using type = __ull_constant<__valid_digit::value>; + }; + + template + struct _Power : _Power_help<_Base, _Digs...>::type + { }; + + template + struct _Power<_Base> : __ull_constant<0> + { }; + +//------------------------------------------------------------------------------ + + template + struct _Number_help + { + using __digit = _Digit<_Base, _Dig>; + using __valid_digit = typename __digit::__valid; + using __next = _Number_help<_Base, + __valid_digit::value ? _Pow / _Base : _Pow, + _Digs...>; + using type = __ull_constant<_Pow * __digit::value + __next::type::value>; + static_assert((type::value / _Pow) == __digit::value, + "integer literal does not fit in unsigned long long"); + }; + + // Skip past digit separators: + template + struct _Number_help<_Base, _Pow, '\'', _Dig, _Digs...> + : _Number_help<_Base, _Pow, _Dig, _Digs...> + { }; + + // Terminating case for recursion: + template + struct _Number_help<_Base, 1ULL, _Dig> + { + using type = __ull_constant<_Digit<_Base, _Dig>::value>; + }; + + template + struct _Number + : _Number_help<_Base, _Power<_Base, _Digs...>::value, _Digs...>::type + { }; + + template + struct _Number<_Base> + : __ull_constant<0> + { }; + +//------------------------------------------------------------------------------ + + template + struct _Parse_int; + + template + struct _Parse_int<'0', 'b', _Digs...> + : _Number<2U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', 'B', _Digs...> + : _Number<2U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', 'x', _Digs...> + : _Number<16U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', 'X', _Digs...> + : _Number<16U, _Digs...>::type + { }; + + template + struct _Parse_int<'0', _Digs...> + : _Number<8U, _Digs...>::type + { }; + + template + struct _Parse_int + : _Number<10U, _Digs...>::type + { }; + +} // namespace __parse_int + + +namespace __select_int +{ + template + struct _Select_int_base; + + template + struct _Select_int_base<_Val, _IntType, _Ints...> + : conditional_t<(_Val <= __gnu_cxx::__int_traits<_IntType>::__max), + integral_constant<_IntType, (_IntType)_Val>, + _Select_int_base<_Val, _Ints...>> + { }; + + template + struct _Select_int_base<_Val> + { }; + + template + using _Select_int = typename _Select_int_base< + __parse_int::_Parse_int<_Digs...>::value, + unsigned char, + unsigned short, + unsigned int, + unsigned long, + unsigned long long + >::type; + +} // namespace __select_int + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_PARSE_NUMBERS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/postypes.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/postypes.h new file mode 100755 index 0000000..cb44cfe --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/postypes.h @@ -0,0 +1,253 @@ +// Position types -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/postypes.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iosfwd} + */ + +// +// ISO C++ 14882: 27.4.1 - Types +// ISO C++ 14882: 27.4.3 - Template class fpos +// + +#ifndef _GLIBCXX_POSTYPES_H +#define _GLIBCXX_POSTYPES_H 1 + +#pragma GCC system_header + +#include // For mbstate_t + +// XXX If is really needed, make sure to define the macros +// before including it, in order not to break (and +// in C++11). Reconsider all this as soon as possible... +#if (defined(_GLIBCXX_HAVE_INT64_T) && !defined(_GLIBCXX_HAVE_INT64_T_LONG) \ + && !defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)) + +#ifndef __STDC_LIMIT_MACROS +# define _UNDEF__STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS +#endif +#ifndef __STDC_CONSTANT_MACROS +# define _UNDEF__STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS +#endif +#include // For int64_t +#ifdef _UNDEF__STDC_LIMIT_MACROS +# undef __STDC_LIMIT_MACROS +# undef _UNDEF__STDC_LIMIT_MACROS +#endif +#ifdef _UNDEF__STDC_CONSTANT_MACROS +# undef __STDC_CONSTANT_MACROS +# undef _UNDEF__STDC_CONSTANT_MACROS +#endif + +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The types streamoff, streampos and wstreampos and the class + // template fpos<> are described in clauses 21.1.2, 21.1.3, 27.1.2, + // 27.2, 27.4.1, 27.4.3 and D.6. Despite all this verbiage, the + // behaviour of these types is mostly implementation defined or + // unspecified. The behaviour in this implementation is as noted + // below. + + /** + * @brief Type used by fpos, char_traits, and char_traits. + * + * In clauses 21.1.3.1 and 27.4.1 streamoff is described as an + * implementation defined type. + * Note: In versions of GCC up to and including GCC 3.3, streamoff + * was typedef long. + */ +#ifdef _GLIBCXX_HAVE_INT64_T_LONG + typedef long streamoff; +#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) + typedef long long streamoff; +#elif defined(_GLIBCXX_HAVE_INT64_T) + typedef int64_t streamoff; +#else + typedef long long streamoff; +#endif + + /// Integral type for I/O operation counts and buffer sizes. + typedef ptrdiff_t streamsize; // Signed integral type + + /** + * @brief Class representing stream positions. + * + * The standard places no requirements upon the template parameter StateT. + * In this implementation StateT must be DefaultConstructible, + * CopyConstructible and Assignable. The standard only requires that fpos + * should contain a member of type StateT. In this implementation it also + * contains an offset stored as a signed integer. + * + * @param StateT Type passed to and returned from state(). + */ + template + class fpos + { + private: + streamoff _M_off; + _StateT _M_state; + + public: + // The standard doesn't require that fpos objects can be default + // constructed. This implementation provides a default + // constructor that initializes the offset to 0 and default + // constructs the state. + fpos() + : _M_off(0), _M_state() { } + + // The standard requires that fpos objects can be constructed + // from streamoff objects using the constructor syntax, and + // fails to give any meaningful semantics. In this + // implementation implicit conversion is also allowed, and this + // constructor stores the streamoff as the offset and default + // constructs the state. + /// Construct position from offset. + fpos(streamoff __off) + : _M_off(__off), _M_state() { } + +#if __cplusplus >= 201103L + fpos(const fpos&) = default; + fpos& operator=(const fpos&) = default; + ~fpos() = default; +#endif + + /// Convert to streamoff. + operator streamoff() const { return _M_off; } + + /// Remember the value of @a st. + void + state(_StateT __st) + { _M_state = __st; } + + /// Return the last set value of @a st. + _StateT + state() const + { return _M_state; } + + // The standard requires that this operator must be defined, but + // gives no semantics. In this implementation it just adds its + // argument to the stored offset and returns *this. + /// Add offset to this position. + fpos& + operator+=(streamoff __off) + { + _M_off += __off; + return *this; + } + + // The standard requires that this operator must be defined, but + // gives no semantics. In this implementation it just subtracts + // its argument from the stored offset and returns *this. + /// Subtract offset from this position. + fpos& + operator-=(streamoff __off) + { + _M_off -= __off; + return *this; + } + + // The standard requires that this operator must be defined, but + // defines its semantics only in terms of operator-. In this + // implementation it constructs a copy of *this, adds the + // argument to that copy using operator+= and then returns the + // copy. + /// Add position and offset. + fpos + operator+(streamoff __off) const + { + fpos __pos(*this); + __pos += __off; + return __pos; + } + + // The standard requires that this operator must be defined, but + // defines its semantics only in terms of operator+. In this + // implementation it constructs a copy of *this, subtracts the + // argument from that copy using operator-= and then returns the + // copy. + /// Subtract offset from position. + fpos + operator-(streamoff __off) const + { + fpos __pos(*this); + __pos -= __off; + return __pos; + } + + // The standard requires that this operator must be defined, but + // defines its semantics only in terms of operator+. In this + // implementation it returns the difference between the offset + // stored in *this and in the argument. + /// Subtract position to return offset. + streamoff + operator-(const fpos& __other) const + { return _M_off - __other._M_off; } + }; + + // The standard only requires that operator== must be an + // equivalence relation. In this implementation two fpos + // objects belong to the same equivalence class if the contained + // offsets compare equal. + /// Test if equivalent to another position. + template + inline bool + operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) + { return streamoff(__lhs) == streamoff(__rhs); } + + template + inline bool + operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) + { return streamoff(__lhs) != streamoff(__rhs); } + + // Clauses 21.1.3.1 and 21.1.3.2 describe streampos and wstreampos + // as implementation defined types, but clause 27.2 requires that + // they must both be typedefs for fpos + /// File position for char streams. + typedef fpos streampos; + /// File position for wchar_t streams. + typedef fpos wstreampos; + +#ifdef _GLIBCXX_USE_CHAR8_T + /// File position for char8_t streams. + typedef fpos u8streampos; +#endif + +#if __cplusplus >= 201103L + /// File position for char16_t streams. + typedef fpos u16streampos; + /// File position for char32_t streams. + typedef fpos u32streampos; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/predefined_ops.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/predefined_ops.h new file mode 100755 index 0000000..97a8a6c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/predefined_ops.h @@ -0,0 +1,407 @@ +// Default predicates for internal use -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file predefined_ops.h + * This is an internal header file, included by other library headers. + * You should not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _GLIBCXX_PREDEFINED_OPS_H +#define _GLIBCXX_PREDEFINED_OPS_H 1 + +#include + +namespace __gnu_cxx +{ +namespace __ops +{ + struct _Iter_less_iter + { + template + _GLIBCXX14_CONSTEXPR + bool + operator()(_Iterator1 __it1, _Iterator2 __it2) const + { return *__it1 < *__it2; } + }; + + _GLIBCXX14_CONSTEXPR + inline _Iter_less_iter + __iter_less_iter() + { return _Iter_less_iter(); } + + struct _Iter_less_val + { +#if __cplusplus >= 201103L + constexpr _Iter_less_val() = default; +#else + _Iter_less_val() { } +#endif + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_less_val(_Iter_less_iter) { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it, _Value& __val) const + { return *__it < __val; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Iter_less_val + __iter_less_val() + { return _Iter_less_val(); } + + _GLIBCXX20_CONSTEXPR + inline _Iter_less_val + __iter_comp_val(_Iter_less_iter) + { return _Iter_less_val(); } + + struct _Val_less_iter + { +#if __cplusplus >= 201103L + constexpr _Val_less_iter() = default; +#else + _Val_less_iter() { } +#endif + + _GLIBCXX20_CONSTEXPR + explicit + _Val_less_iter(_Iter_less_iter) { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Value& __val, _Iterator __it) const + { return __val < *__it; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Val_less_iter + __val_less_iter() + { return _Val_less_iter(); } + + _GLIBCXX20_CONSTEXPR + inline _Val_less_iter + __val_comp_iter(_Iter_less_iter) + { return _Val_less_iter(); } + + struct _Iter_equal_to_iter + { + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator1 __it1, _Iterator2 __it2) const + { return *__it1 == *__it2; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Iter_equal_to_iter + __iter_equal_to_iter() + { return _Iter_equal_to_iter(); } + + struct _Iter_equal_to_val + { + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it, _Value& __val) const + { return *__it == __val; } + }; + + _GLIBCXX20_CONSTEXPR + inline _Iter_equal_to_val + __iter_equal_to_val() + { return _Iter_equal_to_val(); } + + _GLIBCXX20_CONSTEXPR + inline _Iter_equal_to_val + __iter_comp_val(_Iter_equal_to_iter) + { return _Iter_equal_to_val(); } + + template + struct _Iter_comp_iter + { + _Compare _M_comp; + + explicit _GLIBCXX14_CONSTEXPR + _Iter_comp_iter(_Compare __comp) + : _M_comp(_GLIBCXX_MOVE(__comp)) + { } + + template + _GLIBCXX14_CONSTEXPR + bool + operator()(_Iterator1 __it1, _Iterator2 __it2) + { return bool(_M_comp(*__it1, *__it2)); } + }; + + template + _GLIBCXX14_CONSTEXPR + inline _Iter_comp_iter<_Compare> + __iter_comp_iter(_Compare __comp) + { return _Iter_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + struct _Iter_comp_val + { + _Compare _M_comp; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_comp_val(_Compare __comp) + : _M_comp(_GLIBCXX_MOVE(__comp)) + { } + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_comp_val(const _Iter_comp_iter<_Compare>& __comp) + : _M_comp(__comp._M_comp) + { } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + explicit + _Iter_comp_val(_Iter_comp_iter<_Compare>&& __comp) + : _M_comp(std::move(__comp._M_comp)) + { } +#endif + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it, _Value& __val) + { return bool(_M_comp(*__it, __val)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_val<_Compare> + __iter_comp_val(_Compare __comp) + { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_val<_Compare> + __iter_comp_val(_Iter_comp_iter<_Compare> __comp) + { return _Iter_comp_val<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + struct _Val_comp_iter + { + _Compare _M_comp; + + _GLIBCXX20_CONSTEXPR + explicit + _Val_comp_iter(_Compare __comp) + : _M_comp(_GLIBCXX_MOVE(__comp)) + { } + + _GLIBCXX20_CONSTEXPR + explicit + _Val_comp_iter(const _Iter_comp_iter<_Compare>& __comp) + : _M_comp(__comp._M_comp) + { } + +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR + explicit + _Val_comp_iter(_Iter_comp_iter<_Compare>&& __comp) + : _M_comp(std::move(__comp._M_comp)) + { } +#endif + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Value& __val, _Iterator __it) + { return bool(_M_comp(__val, *__it)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Val_comp_iter<_Compare> + __val_comp_iter(_Compare __comp) + { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + _GLIBCXX20_CONSTEXPR + inline _Val_comp_iter<_Compare> + __val_comp_iter(_Iter_comp_iter<_Compare> __comp) + { return _Val_comp_iter<_Compare>(_GLIBCXX_MOVE(__comp)); } + + template + struct _Iter_equals_val + { + _Value& _M_value; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_equals_val(_Value& __value) + : _M_value(__value) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return *__it == _M_value; } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_equals_val<_Value> + __iter_equals_val(_Value& __val) + { return _Iter_equals_val<_Value>(__val); } + + template + struct _Iter_equals_iter + { + _Iterator1 _M_it1; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_equals_iter(_Iterator1 __it1) + : _M_it1(__it1) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator2 __it2) + { return *__it2 == *_M_it1; } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_equals_iter<_Iterator> + __iter_comp_iter(_Iter_equal_to_iter, _Iterator __it) + { return _Iter_equals_iter<_Iterator>(__it); } + + template + struct _Iter_pred + { + _Predicate _M_pred; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_pred(_Predicate __pred) + : _M_pred(_GLIBCXX_MOVE(__pred)) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return bool(_M_pred(*__it)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_pred<_Predicate> + __pred_iter(_Predicate __pred) + { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); } + + template + struct _Iter_comp_to_val + { + _Compare _M_comp; + _Value& _M_value; + + _GLIBCXX20_CONSTEXPR + _Iter_comp_to_val(_Compare __comp, _Value& __value) + : _M_comp(_GLIBCXX_MOVE(__comp)), _M_value(__value) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return bool(_M_comp(*__it, _M_value)); } + }; + + template + _Iter_comp_to_val<_Compare, _Value> + _GLIBCXX20_CONSTEXPR + __iter_comp_val(_Compare __comp, _Value &__val) + { + return _Iter_comp_to_val<_Compare, _Value>(_GLIBCXX_MOVE(__comp), __val); + } + + template + struct _Iter_comp_to_iter + { + _Compare _M_comp; + _Iterator1 _M_it1; + + _GLIBCXX20_CONSTEXPR + _Iter_comp_to_iter(_Compare __comp, _Iterator1 __it1) + : _M_comp(_GLIBCXX_MOVE(__comp)), _M_it1(__it1) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator2 __it2) + { return bool(_M_comp(*__it2, *_M_it1)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_comp_to_iter<_Compare, _Iterator> + __iter_comp_iter(_Iter_comp_iter<_Compare> __comp, _Iterator __it) + { + return _Iter_comp_to_iter<_Compare, _Iterator>( + _GLIBCXX_MOVE(__comp._M_comp), __it); + } + + template + struct _Iter_negate + { + _Predicate _M_pred; + + _GLIBCXX20_CONSTEXPR + explicit + _Iter_negate(_Predicate __pred) + : _M_pred(_GLIBCXX_MOVE(__pred)) + { } + + template + _GLIBCXX20_CONSTEXPR + bool + operator()(_Iterator __it) + { return !bool(_M_pred(*__it)); } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _Iter_negate<_Predicate> + __negate(_Iter_pred<_Predicate> __pred) + { return _Iter_negate<_Predicate>(_GLIBCXX_MOVE(__pred._M_pred)); } + +} // namespace __ops +} // namespace __gnu_cxx + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ptr_traits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ptr_traits.h new file mode 100755 index 0000000..653a358 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ptr_traits.h @@ -0,0 +1,215 @@ +// Pointer Traits -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ptr_traits.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _PTR_TRAITS_H +#define _PTR_TRAITS_H 1 + +#if __cplusplus >= 201103L + +#include + +#if __cplusplus > 201703L +#define __cpp_lib_constexpr_memory 201811L +namespace __gnu_debug { struct _Safe_iterator_base; } +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + class __undefined; + + // Given Template return T, otherwise invalid. + template + struct __get_first_arg + { using type = __undefined; }; + + template class _Template, typename _Tp, + typename... _Types> + struct __get_first_arg<_Template<_Tp, _Types...>> + { using type = _Tp; }; + + template + using __get_first_arg_t = typename __get_first_arg<_Tp>::type; + + // Given Template and U return Template, otherwise invalid. + template + struct __replace_first_arg + { }; + + template class _Template, typename _Up, + typename _Tp, typename... _Types> + struct __replace_first_arg<_Template<_Tp, _Types...>, _Up> + { using type = _Template<_Up, _Types...>; }; + + template + using __replace_first_arg_t = typename __replace_first_arg<_Tp, _Up>::type; + + template + using __make_not_void + = typename conditional::value, __undefined, _Tp>::type; + + /** + * @brief Uniform interface to all pointer-like types + * @ingroup pointer_abstractions + */ + template + struct pointer_traits + { + private: + template + using __element_type = typename _Tp::element_type; + + template + using __difference_type = typename _Tp::difference_type; + + template + struct __rebind : __replace_first_arg<_Tp, _Up> { }; + + template + struct __rebind<_Tp, _Up, __void_t>> + { using type = typename _Tp::template rebind<_Up>; }; + + public: + /// The pointer type. + using pointer = _Ptr; + + /// The type pointed to. + using element_type + = __detected_or_t<__get_first_arg_t<_Ptr>, __element_type, _Ptr>; + + /// The type used to represent the difference between two pointers. + using difference_type + = __detected_or_t; + + /// A pointer to a different type. + template + using rebind = typename __rebind<_Ptr, _Up>::type; + + static _Ptr + pointer_to(__make_not_void& __e) + { return _Ptr::pointer_to(__e); } + + static_assert(!is_same::value, + "pointer type defines element_type or is like SomePointer"); + }; + + /** + * @brief Partial specialization for built-in pointers. + * @ingroup pointer_abstractions + */ + template + struct pointer_traits<_Tp*> + { + /// The pointer type + typedef _Tp* pointer; + /// The type pointed to + typedef _Tp element_type; + /// Type used to represent the difference between two pointers + typedef ptrdiff_t difference_type; + + template + using rebind = _Up*; + + /** + * @brief Obtain a pointer to an object + * @param __r A reference to an object of type @c element_type + * @return @c addressof(__r) + */ + static _GLIBCXX20_CONSTEXPR pointer + pointer_to(__make_not_void& __r) noexcept + { return std::addressof(__r); } + }; + + /// Convenience alias for rebinding pointers. + template + using __ptr_rebind = typename pointer_traits<_Ptr>::template rebind<_Tp>; + + template + constexpr _Tp* + __to_address(_Tp* __ptr) noexcept + { + static_assert(!std::is_function<_Tp>::value, "not a function pointer"); + return __ptr; + } + +#if __cplusplus <= 201703L + template + constexpr typename std::pointer_traits<_Ptr>::element_type* + __to_address(const _Ptr& __ptr) + { return std::__to_address(__ptr.operator->()); } +#else + template + constexpr auto + __to_address(const _Ptr& __ptr) noexcept + -> decltype(std::pointer_traits<_Ptr>::to_address(__ptr)) + { return std::pointer_traits<_Ptr>::to_address(__ptr); } + + template + constexpr auto + __to_address(const _Ptr& __ptr, _None...) noexcept + { + if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>) + return std::__to_address(__ptr.base().operator->()); + else + return std::__to_address(__ptr.operator->()); + } + +#define __cpp_lib_to_address 201711L + + /** + * @brief Obtain address referenced by a pointer to an object + * @param __ptr A pointer to an object + * @return @c __ptr + * @ingroup pointer_abstractions + */ + template + constexpr _Tp* + to_address(_Tp* __ptr) noexcept + { return std::__to_address(__ptr); } + + /** + * @brief Obtain address referenced by a pointer to an object + * @param __ptr A pointer to an object + * @return @c pointer_traits<_Ptr>::to_address(__ptr) if that expression is + well-formed, otherwise @c to_address(__ptr.operator->()) + * @ingroup pointer_abstractions + */ + template + constexpr auto + to_address(const _Ptr& __ptr) noexcept + { return std::__to_address(__ptr); } +#endif // C++2a + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/quoted_string.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/quoted_string.h new file mode 100755 index 0000000..0db3332 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/quoted_string.h @@ -0,0 +1,182 @@ +// Helpers for quoted stream manipulators -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/quoted_string.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iomanip} + */ + +#ifndef _GLIBCXX_QUOTED_STRING_H +#define _GLIBCXX_QUOTED_STRING_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail { + /** + * @brief Struct for delimited strings. + */ + template + struct _Quoted_string + { + static_assert(is_reference<_String>::value + || is_pointer<_String>::value, + "String type must be pointer or reference"); + + _Quoted_string(_String __str, _CharT __del, _CharT __esc) + : _M_string(__str), _M_delim{__del}, _M_escape{__esc} + { } + + _Quoted_string& + operator=(_Quoted_string&) = delete; + + _String _M_string; + _CharT _M_delim; + _CharT _M_escape; + }; + +#if __cplusplus >= 201703L + template + struct _Quoted_string, _CharT> + { + _Quoted_string(basic_string_view<_CharT, _Traits> __str, + _CharT __del, _CharT __esc) + : _M_string(__str), _M_delim{__del}, _M_escape{__esc} + { } + + _Quoted_string& + operator=(_Quoted_string&) = delete; + + basic_string_view<_CharT, _Traits> _M_string; + _CharT _M_delim; + _CharT _M_escape; + }; +#endif // C++17 + + /** + * @brief Inserter for quoted strings. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 2344 quoted()'s interaction with padding is unclear + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const _Quoted_string& __str) + { + std::basic_ostringstream<_CharT, _Traits> __ostr; + __ostr << __str._M_delim; + for (const _CharT* __c = __str._M_string; *__c; ++__c) + { + if (*__c == __str._M_delim || *__c == __str._M_escape) + __ostr << __str._M_escape; + __ostr << *__c; + } + __ostr << __str._M_delim; + + return __os << __ostr.str(); + } + + /** + * @brief Inserter for quoted strings. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 2344 quoted()'s interaction with padding is unclear + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const _Quoted_string<_String, _CharT>& __str) + { + std::basic_ostringstream<_CharT, _Traits> __ostr; + __ostr << __str._M_delim; + for (auto __c : __str._M_string) + { + if (__c == __str._M_delim || __c == __str._M_escape) + __ostr << __str._M_escape; + __ostr << __c; + } + __ostr << __str._M_delim; + + return __os << __ostr.str(); + } + + /** + * @brief Extractor for delimited strings. + * The left and right delimiters can be different. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + const _Quoted_string&, + _CharT>& __str) + { + _CharT __c; + __is >> __c; + if (!__is.good()) + return __is; + if (__c != __str._M_delim) + { + __is.unget(); + __is >> __str._M_string; + return __is; + } + __str._M_string.clear(); + std::ios_base::fmtflags __flags + = __is.flags(__is.flags() & ~std::ios_base::skipws); + do + { + __is >> __c; + if (!__is.good()) + break; + if (__c == __str._M_escape) + { + __is >> __c; + if (!__is.good()) + break; + } + else if (__c == __str._M_delim) + break; + __str._M_string += __c; + } + while (true); + __is.setf(__flags); + + return __is; + } + } // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 +#endif /* _GLIBCXX_QUOTED_STRING_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/random.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/random.h new file mode 100755 index 0000000..8f6e6c4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/random.h @@ -0,0 +1,6111 @@ +// random number generation -*- C++ -*- + +// Copyright (C) 2009-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/random.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _RANDOM_H +#define _RANDOM_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // [26.4] Random number generation + + /** + * @defgroup random Random Number Generation + * @ingroup numerics + * + * A facility for generating random numbers on selected distributions. + * @{ + */ + + // std::uniform_random_bit_generator is defined in + + /** + * @brief A function template for converting the output of a (integral) + * uniform random number generator to a floatng point result in the range + * [0-1). + */ + template + _RealType + generate_canonical(_UniformRandomNumberGenerator& __g); + + /// @cond undocumented + // Implementation-space details. + namespace __detail + { + template + (std::numeric_limits<_UIntType>::digits)> + struct _Shift + { static const _UIntType __value = 0; }; + + template + struct _Shift<_UIntType, __w, true> + { static const _UIntType __value = _UIntType(1) << __w; }; + + template + struct _Select_uint_least_t + { + static_assert(__which < 0, /* needs to be dependent */ + "sorry, would be too much trouble for a slow result"); + }; + + template + struct _Select_uint_least_t<__s, 4> + { typedef unsigned int type; }; + + template + struct _Select_uint_least_t<__s, 3> + { typedef unsigned long type; }; + + template + struct _Select_uint_least_t<__s, 2> + { typedef unsigned long long type; }; + +#ifdef _GLIBCXX_USE_INT128 + template + struct _Select_uint_least_t<__s, 1> + { typedef unsigned __int128 type; }; +#endif + + // Assume a != 0, a < m, c < m, x < m. + template= __m - 1), + bool __schrage_ok = __m % __a < __m / __a> + struct _Mod + { + typedef typename _Select_uint_least_t::type _Tp2; + static _Tp + __calc(_Tp __x) + { return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m); } + }; + + // Schrage. + template + struct _Mod<_Tp, __m, __a, __c, false, true> + { + static _Tp + __calc(_Tp __x); + }; + + // Special cases: + // - for m == 2^n or m == 0, unsigned integer overflow is safe. + // - a * (m - 1) + c fits in _Tp, there is no overflow. + template + struct _Mod<_Tp, __m, __a, __c, true, __s> + { + static _Tp + __calc(_Tp __x) + { + _Tp __res = __a * __x + __c; + if (__m) + __res %= __m; + return __res; + } + }; + + template + inline _Tp + __mod(_Tp __x) + { + if _GLIBCXX17_CONSTEXPR (__a == 0) + return __c; + else + { + // _Mod must not be instantiated with a == 0 + constexpr _Tp __a1 = __a ? __a : 1; + return _Mod<_Tp, __m, __a1, __c>::__calc(__x); + } + } + + /* + * An adaptor class for converting the output of any Generator into + * the input for a specific Distribution. + */ + template + struct _Adaptor + { + static_assert(std::is_floating_point<_DInputType>::value, + "template argument must be a floating point type"); + + public: + _Adaptor(_Engine& __g) + : _M_g(__g) { } + + _DInputType + min() const + { return _DInputType(0); } + + _DInputType + max() const + { return _DInputType(1); } + + /* + * Converts a value generated by the adapted random number generator + * into a value in the input domain for the dependent random number + * distribution. + */ + _DInputType + operator()() + { + return std::generate_canonical<_DInputType, + std::numeric_limits<_DInputType>::digits, + _Engine>(_M_g); + } + + private: + _Engine& _M_g; + }; + + template + using __seed_seq_generate_t = decltype( + std::declval<_Sseq&>().generate(std::declval(), + std::declval())); + + // Detect whether _Sseq is a valid seed sequence for + // a random number engine _Engine with result type _Res. + template> + using __is_seed_seq = __and_< + __not_, _Engine>>, + is_unsigned, + __not_> + >; + + } // namespace __detail + /// @endcond + + /** + * @addtogroup random_generators Random Number Generators + * @ingroup random + * + * These classes define objects which provide random or pseudorandom + * numbers, either from a discrete or a continuous interval. The + * random number generator supplied as a part of this library are + * all uniform random number generators which provide a sequence of + * random number uniformly distributed over their range. + * + * A number generator is a function object with an operator() that + * takes zero arguments and returns a number. + * + * A compliant random number generator must satisfy the following + * requirements. + * + *
Random Number Generator Requirements
To be documented.
+ * + * @{ + */ + + /** + * @brief A model of a linear congruential random number generator. + * + * A random number generator that produces pseudorandom numbers via + * linear function: + * @f[ + * x_{i+1}\leftarrow(ax_{i} + c) \bmod m + * @f] + * + * The template parameter @p _UIntType must be an unsigned integral type + * large enough to store values up to (__m-1). If the template parameter + * @p __m is 0, the modulus @p __m used is + * std::numeric_limits<_UIntType>::max() plus 1. Otherwise, the template + * parameters @p __a and @p __c must be less than @p __m. + * + * The size of the state is @f$1@f$. + */ + template + class linear_congruential_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(__m == 0u || (__a < __m && __c < __m), + "template argument substituting __m out of bounds"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, linear_congruential_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + /** The multiplier. */ + static constexpr result_type multiplier = __a; + /** An increment. */ + static constexpr result_type increment = __c; + /** The modulus. */ + static constexpr result_type modulus = __m; + static constexpr result_type default_seed = 1u; + + /** + * @brief Constructs a %linear_congruential_engine random number + * generator engine with seed 1. + */ + linear_congruential_engine() : linear_congruential_engine(default_seed) + { } + + /** + * @brief Constructs a %linear_congruential_engine random number + * generator engine with seed @p __s. The default seed value + * is 1. + * + * @param __s The initial seed value. + */ + explicit + linear_congruential_engine(result_type __s) + { seed(__s); } + + /** + * @brief Constructs a %linear_congruential_engine random number + * generator engine seeded from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template> + explicit + linear_congruential_engine(_Sseq& __q) + { seed(__q); } + + /** + * @brief Reseeds the %linear_congruential_engine random number generator + * engine sequence to the seed @p __s. + * + * @param __s The new seed. + */ + void + seed(result_type __s = default_seed); + + /** + * @brief Reseeds the %linear_congruential_engine random number generator + * engine + * sequence using values from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q); + + /** + * @brief Gets the smallest possible value in the output range. + * + * The minimum depends on the @p __c parameter: if it is zero, the + * minimum generated must be > 0, otherwise 0 is allowed. + */ + static constexpr result_type + min() + { return __c == 0u ? 1u : 0u; } + + /** + * @brief Gets the largest possible value in the output range. + */ + static constexpr result_type + max() + { return __m - 1u; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next random number in the sequence. + */ + result_type + operator()() + { + _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x); + return _M_x; + } + + /** + * @brief Compares two linear congruential random number generator + * objects of the same type for equality. + * + * @param __lhs A linear congruential random number generator object. + * @param __rhs Another linear congruential random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const linear_congruential_engine& __lhs, + const linear_congruential_engine& __rhs) + { return __lhs._M_x == __rhs._M_x; } + + /** + * @brief Writes the textual representation of the state x(i) of x to + * @p __os. + * + * @param __os The output stream. + * @param __lcr A % linear_congruential_engine random number generator. + * @returns __os. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::linear_congruential_engine<_UIntType1, + __a1, __c1, __m1>& __lcr); + + /** + * @brief Sets the state of the engine by reading its textual + * representation from @p __is. + * + * The textual representation must have been previously written using + * an output stream whose imbued locale and whose type's template + * specialization arguments _CharT and _Traits were the same as those + * of @p __is. + * + * @param __is The input stream. + * @param __lcr A % linear_congruential_engine random number generator. + * @returns __is. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::linear_congruential_engine<_UIntType1, __a1, + __c1, __m1>& __lcr); + + private: + _UIntType _M_x; + }; + + /** + * @brief Compares two linear congruential random number generator + * objects of the same type for inequality. + * + * @param __lhs A linear congruential random number generator object. + * @param __rhs Another linear congruential random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::linear_congruential_engine<_UIntType, __a, + __c, __m>& __lhs, + const std::linear_congruential_engine<_UIntType, __a, + __c, __m>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * A generalized feedback shift register discrete random number generator. + * + * This algorithm avoids multiplication and division and is designed to be + * friendly to a pipelined architecture. If the parameters are chosen + * correctly, this generator will produce numbers with a very long period and + * fairly good apparent entropy, although still not cryptographically strong. + * + * The best way to use this generator is with the predefined mt19937 class. + * + * This algorithm was originally invented by Makoto Matsumoto and + * Takuji Nishimura. + * + * @tparam __w Word size, the number of bits in each element of + * the state vector. + * @tparam __n The degree of recursion. + * @tparam __m The period parameter. + * @tparam __r The separation point bit index. + * @tparam __a The last row of the twist matrix. + * @tparam __u The first right-shift tempering matrix parameter. + * @tparam __d The first right-shift tempering matrix mask. + * @tparam __s The first left-shift tempering matrix parameter. + * @tparam __b The first left-shift tempering matrix mask. + * @tparam __t The second left-shift tempering matrix parameter. + * @tparam __c The second left-shift tempering matrix mask. + * @tparam __l The second right-shift tempering matrix parameter. + * @tparam __f Initialization multiplier. + */ + template + class mersenne_twister_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(1u <= __m && __m <= __n, + "template argument substituting __m out of bounds"); + static_assert(__r <= __w, "template argument substituting " + "__r out of bound"); + static_assert(__u <= __w, "template argument substituting " + "__u out of bound"); + static_assert(__s <= __w, "template argument substituting " + "__s out of bound"); + static_assert(__t <= __w, "template argument substituting " + "__t out of bound"); + static_assert(__l <= __w, "template argument substituting " + "__l out of bound"); + static_assert(__w <= std::numeric_limits<_UIntType>::digits, + "template argument substituting __w out of bound"); + static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __a out of bound"); + static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __b out of bound"); + static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __c out of bound"); + static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __d out of bound"); + static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1), + "template argument substituting __f out of bound"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, mersenne_twister_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + // parameter values + static constexpr size_t word_size = __w; + static constexpr size_t state_size = __n; + static constexpr size_t shift_size = __m; + static constexpr size_t mask_bits = __r; + static constexpr result_type xor_mask = __a; + static constexpr size_t tempering_u = __u; + static constexpr result_type tempering_d = __d; + static constexpr size_t tempering_s = __s; + static constexpr result_type tempering_b = __b; + static constexpr size_t tempering_t = __t; + static constexpr result_type tempering_c = __c; + static constexpr size_t tempering_l = __l; + static constexpr result_type initialization_multiplier = __f; + static constexpr result_type default_seed = 5489u; + + // constructors and member functions + + mersenne_twister_engine() : mersenne_twister_engine(default_seed) { } + + explicit + mersenne_twister_engine(result_type __sd) + { seed(__sd); } + + /** + * @brief Constructs a %mersenne_twister_engine random number generator + * engine seeded from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template> + explicit + mersenne_twister_engine(_Sseq& __q) + { seed(__q); } + + void + seed(result_type __sd = default_seed); + + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q); + + /** + * @brief Gets the smallest possible value in the output range. + */ + static constexpr result_type + min() + { return 0; } + + /** + * @brief Gets the largest possible value in the output range. + */ + static constexpr result_type + max() + { return __detail::_Shift<_UIntType, __w>::__value - 1; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z); + + result_type + operator()(); + + /** + * @brief Compares two % mersenne_twister_engine random number generator + * objects of the same type for equality. + * + * @param __lhs A % mersenne_twister_engine random number generator + * object. + * @param __rhs Another % mersenne_twister_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const mersenne_twister_engine& __lhs, + const mersenne_twister_engine& __rhs) + { return (std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x) + && __lhs._M_p == __rhs._M_p); } + + /** + * @brief Inserts the current state of a % mersenne_twister_engine + * random number generator engine @p __x into the output stream + * @p __os. + * + * @param __os An output stream. + * @param __x A % mersenne_twister_engine random number generator + * engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::mersenne_twister_engine<_UIntType1, __w1, __n1, + __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, + __l1, __f1>& __x); + + /** + * @brief Extracts the current state of a % mersenne_twister_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A % mersenne_twister_engine random number generator + * engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::mersenne_twister_engine<_UIntType1, __w1, __n1, __m1, + __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, + __l1, __f1>& __x); + + private: + void _M_gen_rand(); + + _UIntType _M_x[state_size]; + size_t _M_p; + }; + + /** + * @brief Compares two % mersenne_twister_engine random number generator + * objects of the same type for inequality. + * + * @param __lhs A % mersenne_twister_engine random number generator + * object. + * @param __rhs Another % mersenne_twister_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __lhs, + const std::mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * @brief The Marsaglia-Zaman generator. + * + * This is a model of a Generalized Fibonacci discrete random number + * generator, sometimes referred to as the SWC generator. + * + * A discrete random number generator that produces pseudorandom + * numbers using: + * @f[ + * x_{i}\leftarrow(x_{i - s} - x_{i - r} - carry_{i-1}) \bmod m + * @f] + * + * The size of the state is @f$r@f$ + * and the maximum period of the generator is @f$(m^r - m^s - 1)@f$. + */ + template + class subtract_with_carry_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(0u < __s && __s < __r, + "0 < s < r"); + static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits, + "template argument substituting __w out of bounds"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, subtract_with_carry_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + // parameter values + static constexpr size_t word_size = __w; + static constexpr size_t short_lag = __s; + static constexpr size_t long_lag = __r; + static constexpr result_type default_seed = 19780503u; + + subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) + { } + + /** + * @brief Constructs an explicitly seeded %subtract_with_carry_engine + * random number generator. + */ + explicit + subtract_with_carry_engine(result_type __sd) + { seed(__sd); } + + /** + * @brief Constructs a %subtract_with_carry_engine random number engine + * seeded from the seed sequence @p __q. + * + * @param __q the seed sequence. + */ + template> + explicit + subtract_with_carry_engine(_Sseq& __q) + { seed(__q); } + + /** + * @brief Seeds the initial state @f$x_0@f$ of the random number + * generator. + * + * N1688[4.19] modifies this as follows. If @p __value == 0, + * sets value to 19780503. In any case, with a linear + * congruential generator lcg(i) having parameters @f$ m_{lcg} = + * 2147483563, a_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value + * @f$, sets @f$ x_{-r} \dots x_{-1} @f$ to @f$ lcg(1) \bmod m + * \dots lcg(r) \bmod m @f$ respectively. If @f$ x_{-1} = 0 @f$ + * set carry to 1, otherwise sets carry to 0. + */ + void + seed(result_type __sd = default_seed); + + /** + * @brief Seeds the initial state @f$x_0@f$ of the + * % subtract_with_carry_engine random number generator. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q); + + /** + * @brief Gets the inclusive minimum value of the range of random + * integers returned by this generator. + */ + static constexpr result_type + min() + { return 0; } + + /** + * @brief Gets the inclusive maximum value of the range of random + * integers returned by this generator. + */ + static constexpr result_type + max() + { return __detail::_Shift<_UIntType, __w>::__value - 1; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next random number in the sequence. + */ + result_type + operator()(); + + /** + * @brief Compares two % subtract_with_carry_engine random number + * generator objects of the same type for equality. + * + * @param __lhs A % subtract_with_carry_engine random number generator + * object. + * @param __rhs Another % subtract_with_carry_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const subtract_with_carry_engine& __lhs, + const subtract_with_carry_engine& __rhs) + { return (std::equal(__lhs._M_x, __lhs._M_x + long_lag, __rhs._M_x) + && __lhs._M_carry == __rhs._M_carry + && __lhs._M_p == __rhs._M_p); } + + /** + * @brief Inserts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x into the output stream + * @p __os. + * + * @param __os An output stream. + * @param __x A % subtract_with_carry_engine random number generator + * engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::subtract_with_carry_engine<_UIntType1, __w1, + __s1, __r1>& __x); + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A % subtract_with_carry_engine random number generator + * engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::subtract_with_carry_engine<_UIntType1, __w1, + __s1, __r1>& __x); + + private: + /// The state of the generator. This is a ring buffer. + _UIntType _M_x[long_lag]; + _UIntType _M_carry; ///< The carry + size_t _M_p; ///< Current index of x(i - r). + }; + + /** + * @brief Compares two % subtract_with_carry_engine random number + * generator objects of the same type for inequality. + * + * @param __lhs A % subtract_with_carry_engine random number generator + * object. + * @param __rhs Another % subtract_with_carry_engine random number + * generator object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::subtract_with_carry_engine<_UIntType, __w, + __s, __r>& __lhs, + const std::subtract_with_carry_engine<_UIntType, __w, + __s, __r>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * Produces random numbers from some base engine by discarding blocks of + * data. + * + * 0 <= @p __r <= @p __p + */ + template + class discard_block_engine + { + static_assert(1 <= __r && __r <= __p, + "template argument substituting __r out of bounds"); + + public: + /** The type of the generated random value. */ + typedef typename _RandomNumberEngine::result_type result_type; + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, discard_block_engine, result_type>::value>::type; + + // parameter values + static constexpr size_t block_size = __p; + static constexpr size_t used_block = __r; + + /** + * @brief Constructs a default %discard_block_engine engine. + * + * The underlying engine is default constructed as well. + */ + discard_block_engine() + : _M_b(), _M_n(0) { } + + /** + * @brief Copy constructs a %discard_block_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + discard_block_engine(const _RandomNumberEngine& __rng) + : _M_b(__rng), _M_n(0) { } + + /** + * @brief Move constructs a %discard_block_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + discard_block_engine(_RandomNumberEngine&& __rng) + : _M_b(std::move(__rng)), _M_n(0) { } + + /** + * @brief Seed constructs a %discard_block_engine engine. + * + * Constructs the underlying generator engine seeded with @p __s. + * @param __s A seed value for the base class engine. + */ + explicit + discard_block_engine(result_type __s) + : _M_b(__s), _M_n(0) { } + + /** + * @brief Generator construct a %discard_block_engine engine. + * + * @param __q A seed sequence. + */ + template> + explicit + discard_block_engine(_Sseq& __q) + : _M_b(__q), _M_n(0) + { } + + /** + * @brief Reseeds the %discard_block_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed() + { + _M_b.seed(); + _M_n = 0; + } + + /** + * @brief Reseeds the %discard_block_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed(result_type __s) + { + _M_b.seed(__s); + _M_n = 0; + } + + /** + * @brief Reseeds the %discard_block_engine object with the given seed + * sequence. + * @param __q A seed generator function. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q) + { + _M_b.seed(__q); + _M_n = 0; + } + + /** + * @brief Gets a const reference to the underlying generator engine + * object. + */ + const _RandomNumberEngine& + base() const noexcept + { return _M_b; } + + /** + * @brief Gets the minimum value in the generated random number range. + */ + static constexpr result_type + min() + { return _RandomNumberEngine::min(); } + + /** + * @brief Gets the maximum value in the generated random number range. + */ + static constexpr result_type + max() + { return _RandomNumberEngine::max(); } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next value in the generated random number sequence. + */ + result_type + operator()(); + + /** + * @brief Compares two %discard_block_engine random number generator + * objects of the same type for equality. + * + * @param __lhs A %discard_block_engine random number generator object. + * @param __rhs Another %discard_block_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const discard_block_engine& __lhs, + const discard_block_engine& __rhs) + { return __lhs._M_b == __rhs._M_b && __lhs._M_n == __rhs._M_n; } + + /** + * @brief Inserts the current state of a %discard_block_engine random + * number generator engine @p __x into the output stream + * @p __os. + * + * @param __os An output stream. + * @param __x A %discard_block_engine random number generator engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::discard_block_engine<_RandomNumberEngine1, + __p1, __r1>& __x); + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A %discard_block_engine random number generator engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::discard_block_engine<_RandomNumberEngine1, + __p1, __r1>& __x); + + private: + _RandomNumberEngine _M_b; + size_t _M_n; + }; + + /** + * @brief Compares two %discard_block_engine random number generator + * objects of the same type for inequality. + * + * @param __lhs A %discard_block_engine random number generator object. + * @param __rhs Another %discard_block_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::discard_block_engine<_RandomNumberEngine, __p, + __r>& __lhs, + const std::discard_block_engine<_RandomNumberEngine, __p, + __r>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * Produces random numbers by combining random numbers from some base + * engine to produce random numbers with a specified number of bits @p __w. + */ + template + class independent_bits_engine + { + static_assert(std::is_unsigned<_UIntType>::value, + "result_type must be an unsigned integral type"); + static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits, + "template argument substituting __w out of bounds"); + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, independent_bits_engine, _UIntType>::value>::type; + + public: + /** The type of the generated random value. */ + typedef _UIntType result_type; + + /** + * @brief Constructs a default %independent_bits_engine engine. + * + * The underlying engine is default constructed as well. + */ + independent_bits_engine() + : _M_b() { } + + /** + * @brief Copy constructs a %independent_bits_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + independent_bits_engine(const _RandomNumberEngine& __rng) + : _M_b(__rng) { } + + /** + * @brief Move constructs a %independent_bits_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + independent_bits_engine(_RandomNumberEngine&& __rng) + : _M_b(std::move(__rng)) { } + + /** + * @brief Seed constructs a %independent_bits_engine engine. + * + * Constructs the underlying generator engine seeded with @p __s. + * @param __s A seed value for the base class engine. + */ + explicit + independent_bits_engine(result_type __s) + : _M_b(__s) { } + + /** + * @brief Generator construct a %independent_bits_engine engine. + * + * @param __q A seed sequence. + */ + template> + explicit + independent_bits_engine(_Sseq& __q) + : _M_b(__q) + { } + + /** + * @brief Reseeds the %independent_bits_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed() + { _M_b.seed(); } + + /** + * @brief Reseeds the %independent_bits_engine object with the default + * seed for the underlying base class generator engine. + */ + void + seed(result_type __s) + { _M_b.seed(__s); } + + /** + * @brief Reseeds the %independent_bits_engine object with the given + * seed sequence. + * @param __q A seed generator function. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q) + { _M_b.seed(__q); } + + /** + * @brief Gets a const reference to the underlying generator engine + * object. + */ + const _RandomNumberEngine& + base() const noexcept + { return _M_b; } + + /** + * @brief Gets the minimum value in the generated random number range. + */ + static constexpr result_type + min() + { return 0U; } + + /** + * @brief Gets the maximum value in the generated random number range. + */ + static constexpr result_type + max() + { return __detail::_Shift<_UIntType, __w>::__value - 1; } + + /** + * @brief Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * @brief Gets the next value in the generated random number sequence. + */ + result_type + operator()(); + + /** + * @brief Compares two %independent_bits_engine random number generator + * objects of the same type for equality. + * + * @param __lhs A %independent_bits_engine random number generator + * object. + * @param __rhs Another %independent_bits_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const independent_bits_engine& __lhs, + const independent_bits_engine& __rhs) + { return __lhs._M_b == __rhs._M_b; } + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A %independent_bits_engine random number generator + * engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::independent_bits_engine<_RandomNumberEngine, + __w, _UIntType>& __x) + { + __is >> __x._M_b; + return __is; + } + + private: + _RandomNumberEngine _M_b; + }; + + /** + * @brief Compares two %independent_bits_engine random number generator + * objects of the same type for inequality. + * + * @param __lhs A %independent_bits_engine random number generator + * object. + * @param __rhs Another %independent_bits_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::independent_bits_engine<_RandomNumberEngine, __w, + _UIntType>& __lhs, + const std::independent_bits_engine<_RandomNumberEngine, __w, + _UIntType>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Inserts the current state of a %independent_bits_engine random + * number generator engine @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %independent_bits_engine random number generator engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::independent_bits_engine<_RandomNumberEngine, + __w, _UIntType>& __x) + { + __os << __x.base(); + return __os; + } + + + /** + * @brief Produces random numbers by reordering random numbers from some + * base engine. + * + * The values from the base engine are stored in a sequence of size @p __k + * and shuffled by an algorithm that depends on those values. + */ + template + class shuffle_order_engine + { + static_assert(1u <= __k, "template argument substituting " + "__k out of bound"); + + public: + /** The type of the generated random value. */ + typedef typename _RandomNumberEngine::result_type result_type; + + template + using _If_seed_seq = typename enable_if<__detail::__is_seed_seq< + _Sseq, shuffle_order_engine, result_type>::value>::type; + + static constexpr size_t table_size = __k; + + /** + * @brief Constructs a default %shuffle_order_engine engine. + * + * The underlying engine is default constructed as well. + */ + shuffle_order_engine() + : _M_b() + { _M_initialize(); } + + /** + * @brief Copy constructs a %shuffle_order_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + shuffle_order_engine(const _RandomNumberEngine& __rng) + : _M_b(__rng) + { _M_initialize(); } + + /** + * @brief Move constructs a %shuffle_order_engine engine. + * + * Copies an existing base class random number generator. + * @param __rng An existing (base class) engine object. + */ + explicit + shuffle_order_engine(_RandomNumberEngine&& __rng) + : _M_b(std::move(__rng)) + { _M_initialize(); } + + /** + * @brief Seed constructs a %shuffle_order_engine engine. + * + * Constructs the underlying generator engine seeded with @p __s. + * @param __s A seed value for the base class engine. + */ + explicit + shuffle_order_engine(result_type __s) + : _M_b(__s) + { _M_initialize(); } + + /** + * @brief Generator construct a %shuffle_order_engine engine. + * + * @param __q A seed sequence. + */ + template> + explicit + shuffle_order_engine(_Sseq& __q) + : _M_b(__q) + { _M_initialize(); } + + /** + * @brief Reseeds the %shuffle_order_engine object with the default seed + for the underlying base class generator engine. + */ + void + seed() + { + _M_b.seed(); + _M_initialize(); + } + + /** + * @brief Reseeds the %shuffle_order_engine object with the default seed + * for the underlying base class generator engine. + */ + void + seed(result_type __s) + { + _M_b.seed(__s); + _M_initialize(); + } + + /** + * @brief Reseeds the %shuffle_order_engine object with the given seed + * sequence. + * @param __q A seed generator function. + */ + template + _If_seed_seq<_Sseq> + seed(_Sseq& __q) + { + _M_b.seed(__q); + _M_initialize(); + } + + /** + * Gets a const reference to the underlying generator engine object. + */ + const _RandomNumberEngine& + base() const noexcept + { return _M_b; } + + /** + * Gets the minimum value in the generated random number range. + */ + static constexpr result_type + min() + { return _RandomNumberEngine::min(); } + + /** + * Gets the maximum value in the generated random number range. + */ + static constexpr result_type + max() + { return _RandomNumberEngine::max(); } + + /** + * Discard a sequence of random numbers. + */ + void + discard(unsigned long long __z) + { + for (; __z != 0ULL; --__z) + (*this)(); + } + + /** + * Gets the next value in the generated random number sequence. + */ + result_type + operator()(); + + /** + * Compares two %shuffle_order_engine random number generator objects + * of the same type for equality. + * + * @param __lhs A %shuffle_order_engine random number generator object. + * @param __rhs Another %shuffle_order_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be equal, false otherwise. + */ + friend bool + operator==(const shuffle_order_engine& __lhs, + const shuffle_order_engine& __rhs) + { return (__lhs._M_b == __rhs._M_b + && std::equal(__lhs._M_v, __lhs._M_v + __k, __rhs._M_v) + && __lhs._M_y == __rhs._M_y); } + + /** + * @brief Inserts the current state of a %shuffle_order_engine random + * number generator engine @p __x into the output stream + @p __os. + * + * @param __os An output stream. + * @param __x A %shuffle_order_engine random number generator engine. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::shuffle_order_engine<_RandomNumberEngine1, + __k1>& __x); + + /** + * @brief Extracts the current state of a % subtract_with_carry_engine + * random number generator engine @p __x from the input stream + * @p __is. + * + * @param __is An input stream. + * @param __x A %shuffle_order_engine random number generator engine. + * + * @returns The input stream with the state of @p __x extracted or in + * an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::shuffle_order_engine<_RandomNumberEngine1, __k1>& __x); + + private: + void _M_initialize() + { + for (size_t __i = 0; __i < __k; ++__i) + _M_v[__i] = _M_b(); + _M_y = _M_b(); + } + + _RandomNumberEngine _M_b; + result_type _M_v[__k]; + result_type _M_y; + }; + + /** + * Compares two %shuffle_order_engine random number generator objects + * of the same type for inequality. + * + * @param __lhs A %shuffle_order_engine random number generator object. + * @param __rhs Another %shuffle_order_engine random number generator + * object. + * + * @returns true if the infinite sequences of generated values + * would be different, false otherwise. + */ + template + inline bool + operator!=(const std::shuffle_order_engine<_RandomNumberEngine, + __k>& __lhs, + const std::shuffle_order_engine<_RandomNumberEngine, + __k>& __rhs) + { return !(__lhs == __rhs); } + + + /** + * The classic Minimum Standard rand0 of Lewis, Goodman, and Miller. + */ + typedef linear_congruential_engine + minstd_rand0; + + /** + * An alternative LCR (Lehmer Generator function). + */ + typedef linear_congruential_engine + minstd_rand; + + /** + * The classic Mersenne Twister. + * + * Reference: + * M. Matsumoto and T. Nishimura, Mersenne Twister: A 623-Dimensionally + * Equidistributed Uniform Pseudo-Random Number Generator, ACM Transactions + * on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. + */ + typedef mersenne_twister_engine< + uint_fast32_t, + 32, 624, 397, 31, + 0x9908b0dfUL, 11, + 0xffffffffUL, 7, + 0x9d2c5680UL, 15, + 0xefc60000UL, 18, 1812433253UL> mt19937; + + /** + * An alternative Mersenne Twister. + */ + typedef mersenne_twister_engine< + uint_fast64_t, + 64, 312, 156, 31, + 0xb5026f5aa96619e9ULL, 29, + 0x5555555555555555ULL, 17, + 0x71d67fffeda60000ULL, 37, + 0xfff7eee000000000ULL, 43, + 6364136223846793005ULL> mt19937_64; + + typedef subtract_with_carry_engine + ranlux24_base; + + typedef subtract_with_carry_engine + ranlux48_base; + + typedef discard_block_engine ranlux24; + + typedef discard_block_engine ranlux48; + + typedef shuffle_order_engine knuth_b; + + typedef minstd_rand0 default_random_engine; + + /** + * A standard interface to a platform-specific non-deterministic + * random number generator (if any are available). + */ + class random_device + { + public: + /** The type of the generated random value. */ + typedef unsigned int result_type; + + // constructors, destructors and member functions + + random_device() { _M_init("default"); } + + explicit + random_device(const std::string& __token) { _M_init(__token); } + +#if defined _GLIBCXX_USE_DEV_RANDOM + ~random_device() + { _M_fini(); } +#endif + + static constexpr result_type + min() + { return std::numeric_limits::min(); } + + static constexpr result_type + max() + { return std::numeric_limits::max(); } + + double + entropy() const noexcept + { +#ifdef _GLIBCXX_USE_DEV_RANDOM + return this->_M_getentropy(); +#else + return 0.0; +#endif + } + + result_type + operator()() + { return this->_M_getval(); } + + // No copy functions. + random_device(const random_device&) = delete; + void operator=(const random_device&) = delete; + + private: + + void _M_init(const std::string& __token); + void _M_init_pretr1(const std::string& __token); + void _M_fini(); + + result_type _M_getval(); + result_type _M_getval_pretr1(); + double _M_getentropy() const noexcept; + + void _M_init(const char*, size_t); // not exported from the shared library + + union + { + struct + { + void* _M_file; + result_type (*_M_func)(void*); + int _M_fd; + }; + mt19937 _M_mt; + }; + }; + + /// @} group random_generators + + /** + * @addtogroup random_distributions Random Number Distributions + * @ingroup random + * @{ + */ + + /** + * @addtogroup random_distributions_uniform Uniform Distributions + * @ingroup random_distributions + * @{ + */ + + // std::uniform_int_distribution is defined in + + /** + * @brief Return true if two uniform integer distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::uniform_int_distribution<_IntType>& __d1, + const std::uniform_int_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %uniform_int_distribution random number + * distribution @p __x into the output stream @p os. + * + * @param __os An output stream. + * @param __x A %uniform_int_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::uniform_int_distribution<_IntType>&); + + /** + * @brief Extracts a %uniform_int_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %uniform_int_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::uniform_int_distribution<_IntType>&); + + + /** + * @brief Uniform continuous distribution for random numbers. + * + * A continuous random distribution on the range [min, max) with equal + * probability throughout the range. The URNG should be real-valued and + * deliver number in the range [0, 1). + */ + template + class uniform_real_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef uniform_real_distribution<_RealType> distribution_type; + + param_type() : param_type(0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1)) + : _M_a(__a), _M_b(__b) + { + __glibcxx_assert(_M_a <= _M_b); + } + + result_type + a() const + { return _M_a; } + + result_type + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + public: + /** + * @brief Constructs a uniform_real_distribution object. + * + * The lower bound is set to 0.0 and the upper bound to 1.0 + */ + uniform_real_distribution() : uniform_real_distribution(0.0) { } + + /** + * @brief Constructs a uniform_real_distribution object. + * + * @param __a [IN] The lower bound of the distribution. + * @param __b [IN] The upper bound of the distribution. + */ + explicit + uniform_real_distribution(_RealType __a, _RealType __b = _RealType(1)) + : _M_param(__a, __b) + { } + + explicit + uniform_real_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for the uniform real distribution. + */ + void + reset() { } + + result_type + a() const + { return _M_param.a(); } + + result_type + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the inclusive lower bound of the distribution range. + */ + result_type + min() const + { return this->a(); } + + /** + * @brief Returns the inclusive upper bound of the distribution range. + */ + result_type + max() const + { return this->b(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return (__aurng() * (__p.b() - __p.a())) + __p.a(); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two uniform real distributions have + * the same parameters. + */ + friend bool + operator==(const uniform_real_distribution& __d1, + const uniform_real_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two uniform real distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::uniform_real_distribution<_IntType>& __d1, + const std::uniform_real_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %uniform_real_distribution random number + * distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %uniform_real_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::uniform_real_distribution<_RealType>&); + + /** + * @brief Extracts a %uniform_real_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %uniform_real_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::uniform_real_distribution<_RealType>&); + + /// @} group random_distributions_uniform + + /** + * @addtogroup random_distributions_normal Normal Distributions + * @ingroup random_distributions + * @{ + */ + + /** + * @brief A normal continuous distribution for random numbers. + * + * The formula for the normal probability density function is + * @f[ + * p(x|\mu,\sigma) = \frac{1}{\sigma \sqrt{2 \pi}} + * e^{- \frac{{x - \mu}^ {2}}{2 \sigma ^ {2}} } + * @f] + */ + template + class normal_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef normal_distribution<_RealType> distribution_type; + + param_type() : param_type(0.0) { } + + explicit + param_type(_RealType __mean, _RealType __stddev = _RealType(1)) + : _M_mean(__mean), _M_stddev(__stddev) + { + __glibcxx_assert(_M_stddev > _RealType(0)); + } + + _RealType + mean() const + { return _M_mean; } + + _RealType + stddev() const + { return _M_stddev; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return (__p1._M_mean == __p2._M_mean + && __p1._M_stddev == __p2._M_stddev); } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_mean; + _RealType _M_stddev; + }; + + public: + normal_distribution() : normal_distribution(0.0) { } + + /** + * Constructs a normal distribution with parameters @f$mean@f$ and + * standard deviation. + */ + explicit + normal_distribution(result_type __mean, + result_type __stddev = result_type(1)) + : _M_param(__mean, __stddev) + { } + + explicit + normal_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_saved_available = false; } + + /** + * @brief Returns the mean of the distribution. + */ + _RealType + mean() const + { return _M_param.mean(); } + + /** + * @brief Returns the standard deviation of the distribution. + */ + _RealType + stddev() const + { return _M_param.stddev(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two normal distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + template + friend bool + operator==(const std::normal_distribution<_RealType1>& __d1, + const std::normal_distribution<_RealType1>& __d2); + + /** + * @brief Inserts a %normal_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %normal_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::normal_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %normal_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %normal_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::normal_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + result_type _M_saved = 0; + bool _M_saved_available = false; + }; + + /** + * @brief Return true if two normal distributions are different. + */ + template + inline bool + operator!=(const std::normal_distribution<_RealType>& __d1, + const std::normal_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A lognormal_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f[ + * p(x|m,s) = \frac{1}{sx\sqrt{2\pi}} + * \exp{-\frac{(\ln{x} - m)^2}{2s^2}} + * @f] + */ + template + class lognormal_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef lognormal_distribution<_RealType> distribution_type; + + param_type() : param_type(0.0) { } + + explicit + param_type(_RealType __m, _RealType __s = _RealType(1)) + : _M_m(__m), _M_s(__s) + { } + + _RealType + m() const + { return _M_m; } + + _RealType + s() const + { return _M_s; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_m == __p2._M_m && __p1._M_s == __p2._M_s; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_m; + _RealType _M_s; + }; + + lognormal_distribution() : lognormal_distribution(0.0) { } + + explicit + lognormal_distribution(_RealType __m, _RealType __s = _RealType(1)) + : _M_param(__m, __s), _M_nd() + { } + + explicit + lognormal_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * + */ + _RealType + m() const + { return _M_param.m(); } + + _RealType + s() const + { return _M_param.s(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two lognormal distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const lognormal_distribution& __d1, + const lognormal_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_nd == __d2._M_nd); } + + /** + * @brief Inserts a %lognormal_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %lognormal_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::lognormal_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %lognormal_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %lognormal_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::lognormal_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two lognormal distributions are different. + */ + template + inline bool + operator!=(const std::lognormal_distribution<_RealType>& __d1, + const std::lognormal_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A gamma continuous distribution for random numbers. + * + * The formula for the gamma probability density function is: + * @f[ + * p(x|\alpha,\beta) = \frac{1}{\beta\Gamma(\alpha)} + * (x/\beta)^{\alpha - 1} e^{-x/\beta} + * @f] + */ + template + class gamma_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef gamma_distribution<_RealType> distribution_type; + friend class gamma_distribution<_RealType>; + + param_type() : param_type(1.0) { } + + explicit + param_type(_RealType __alpha_val, _RealType __beta_val = _RealType(1)) + : _M_alpha(__alpha_val), _M_beta(__beta_val) + { + __glibcxx_assert(_M_alpha > _RealType(0)); + _M_initialize(); + } + + _RealType + alpha() const + { return _M_alpha; } + + _RealType + beta() const + { return _M_beta; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return (__p1._M_alpha == __p2._M_alpha + && __p1._M_beta == __p2._M_beta); } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + _RealType _M_alpha; + _RealType _M_beta; + + _RealType _M_malpha, _M_a2; + }; + + public: + /** + * @brief Constructs a gamma distribution with parameters 1 and 1. + */ + gamma_distribution() : gamma_distribution(1.0) { } + + /** + * @brief Constructs a gamma distribution with parameters + * @f$\alpha@f$ and @f$\beta@f$. + */ + explicit + gamma_distribution(_RealType __alpha_val, + _RealType __beta_val = _RealType(1)) + : _M_param(__alpha_val, __beta_val), _M_nd() + { } + + explicit + gamma_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * @brief Returns the @f$\alpha@f$ of the distribution. + */ + _RealType + alpha() const + { return _M_param.alpha(); } + + /** + * @brief Returns the @f$\beta@f$ of the distribution. + */ + _RealType + beta() const + { return _M_param.beta(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two gamma distributions have the same + * parameters and the sequences that would be generated + * are equal. + */ + friend bool + operator==(const gamma_distribution& __d1, + const gamma_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_nd == __d2._M_nd); } + + /** + * @brief Inserts a %gamma_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %gamma_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::gamma_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %gamma_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %gamma_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::gamma_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two gamma distributions are different. + */ + template + inline bool + operator!=(const std::gamma_distribution<_RealType>& __d1, + const std::gamma_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A chi_squared_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f$p(x|n) = \frac{x^{(n/2) - 1}e^{-x/2}}{\Gamma(n/2) 2^{n/2}}@f$ + */ + template + class chi_squared_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef chi_squared_distribution<_RealType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_RealType __n) + : _M_n(__n) + { } + + _RealType + n() const + { return _M_n; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_n == __p2._M_n; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_n; + }; + + chi_squared_distribution() : chi_squared_distribution(1) { } + + explicit + chi_squared_distribution(_RealType __n) + : _M_param(__n), _M_gd(__n / 2) + { } + + explicit + chi_squared_distribution(const param_type& __p) + : _M_param(__p), _M_gd(__p.n() / 2) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_gd.reset(); } + + /** + * + */ + _RealType + n() const + { return _M_param.n(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { + _M_param = __param; + typedef typename std::gamma_distribution::param_type + param_type; + _M_gd.param(param_type{__param.n() / 2}); + } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return 2 * _M_gd(__urng); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + return 2 * _M_gd(__urng, param_type(__p.n() / 2)); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { typename std::gamma_distribution::param_type + __p2(__p.n() / 2); + this->__generate_impl(__f, __t, __urng, __p2); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { typename std::gamma_distribution::param_type + __p2(__p.n() / 2); + this->__generate_impl(__f, __t, __urng, __p2); } + + /** + * @brief Return true if two Chi-squared distributions have + * the same parameters and the sequences that would be + * generated are equal. + */ + friend bool + operator==(const chi_squared_distribution& __d1, + const chi_squared_distribution& __d2) + { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; } + + /** + * @brief Inserts a %chi_squared_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %chi_squared_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::chi_squared_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %chi_squared_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %chi_squared_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::chi_squared_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const typename + std::gamma_distribution::param_type& __p); + + param_type _M_param; + + std::gamma_distribution _M_gd; + }; + + /** + * @brief Return true if two Chi-squared distributions are different. + */ + template + inline bool + operator!=(const std::chi_squared_distribution<_RealType>& __d1, + const std::chi_squared_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A cauchy_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f$p(x|a,b) = (\pi b (1 + (\frac{x-a}{b})^2))^{-1}@f$ + */ + template + class cauchy_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef cauchy_distribution<_RealType> distribution_type; + + param_type() : param_type(0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1)) + : _M_a(__a), _M_b(__b) + { } + + _RealType + a() const + { return _M_a; } + + _RealType + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + cauchy_distribution() : cauchy_distribution(0.0) { } + + explicit + cauchy_distribution(_RealType __a, _RealType __b = 1.0) + : _M_param(__a, __b) + { } + + explicit + cauchy_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * + */ + _RealType + a() const + { return _M_param.a(); } + + _RealType + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Cauchy distributions have + * the same parameters. + */ + friend bool + operator==(const cauchy_distribution& __d1, + const cauchy_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two Cauchy distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::cauchy_distribution<_RealType>& __d1, + const std::cauchy_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %cauchy_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %cauchy_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::cauchy_distribution<_RealType>& __x); + + /** + * @brief Extracts a %cauchy_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %cauchy_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::cauchy_distribution<_RealType>& __x); + + + /** + * @brief A fisher_f_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f[ + * p(x|m,n) = \frac{\Gamma((m+n)/2)}{\Gamma(m/2)\Gamma(n/2)} + * (\frac{m}{n})^{m/2} x^{(m/2)-1} + * (1 + \frac{mx}{n})^{-(m+n)/2} + * @f] + */ + template + class fisher_f_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef fisher_f_distribution<_RealType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_RealType __m, _RealType __n = _RealType(1)) + : _M_m(__m), _M_n(__n) + { } + + _RealType + m() const + { return _M_m; } + + _RealType + n() const + { return _M_n; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_m == __p2._M_m && __p1._M_n == __p2._M_n; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_m; + _RealType _M_n; + }; + + fisher_f_distribution() : fisher_f_distribution(1.0) { } + + explicit + fisher_f_distribution(_RealType __m, + _RealType __n = _RealType(1)) + : _M_param(__m, __n), _M_gd_x(__m / 2), _M_gd_y(__n / 2) + { } + + explicit + fisher_f_distribution(const param_type& __p) + : _M_param(__p), _M_gd_x(__p.m() / 2), _M_gd_y(__p.n() / 2) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { + _M_gd_x.reset(); + _M_gd_y.reset(); + } + + /** + * + */ + _RealType + m() const + { return _M_param.m(); } + + _RealType + n() const + { return _M_param.n(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return (_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + return ((_M_gd_x(__urng, param_type(__p.m() / 2)) * n()) + / (_M_gd_y(__urng, param_type(__p.n() / 2)) * m())); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Fisher f distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const fisher_f_distribution& __d1, + const fisher_f_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_gd_x == __d2._M_gd_x + && __d1._M_gd_y == __d2._M_gd_y); } + + /** + * @brief Inserts a %fisher_f_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %fisher_f_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::fisher_f_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %fisher_f_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %fisher_f_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::fisher_f_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::gamma_distribution _M_gd_x, _M_gd_y; + }; + + /** + * @brief Return true if two Fisher f distributions are different. + */ + template + inline bool + operator!=(const std::fisher_f_distribution<_RealType>& __d1, + const std::fisher_f_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief A student_t_distribution random number distribution. + * + * The formula for the normal probability mass function is: + * @f[ + * p(x|n) = \frac{1}{\sqrt(n\pi)} \frac{\Gamma((n+1)/2)}{\Gamma(n/2)} + * (1 + \frac{x^2}{n}) ^{-(n+1)/2} + * @f] + */ + template + class student_t_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef student_t_distribution<_RealType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_RealType __n) + : _M_n(__n) + { } + + _RealType + n() const + { return _M_n; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_n == __p2._M_n; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_n; + }; + + student_t_distribution() : student_t_distribution(1.0) { } + + explicit + student_t_distribution(_RealType __n) + : _M_param(__n), _M_nd(), _M_gd(__n / 2, 2) + { } + + explicit + student_t_distribution(const param_type& __p) + : _M_param(__p), _M_nd(), _M_gd(__p.n() / 2, 2) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { + _M_nd.reset(); + _M_gd.reset(); + } + + /** + * + */ + _RealType + n() const + { return _M_param.n(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + + const result_type __g = _M_gd(__urng, param_type(__p.n() / 2, 2)); + return _M_nd(__urng) * std::sqrt(__p.n() / __g); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Student t distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const student_t_distribution& __d1, + const student_t_distribution& __d2) + { return (__d1._M_param == __d2._M_param + && __d1._M_nd == __d2._M_nd && __d1._M_gd == __d2._M_gd); } + + /** + * @brief Inserts a %student_t_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %student_t_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::student_t_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %student_t_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %student_t_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::student_t_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::normal_distribution _M_nd; + std::gamma_distribution _M_gd; + }; + + /** + * @brief Return true if two Student t distributions are different. + */ + template + inline bool + operator!=(const std::student_t_distribution<_RealType>& __d1, + const std::student_t_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /// @} group random_distributions_normal + + /** + * @addtogroup random_distributions_bernoulli Bernoulli Distributions + * @ingroup random_distributions + * @{ + */ + + /** + * @brief A Bernoulli random number distribution. + * + * Generates a sequence of true and false values with likelihood @f$p@f$ + * that true will come up and @f$(1 - p)@f$ that false will appear. + */ + class bernoulli_distribution + { + public: + /** The type of the range of the distribution. */ + typedef bool result_type; + + /** Parameter type. */ + struct param_type + { + typedef bernoulli_distribution distribution_type; + + param_type() : param_type(0.5) { } + + explicit + param_type(double __p) + : _M_p(__p) + { + __glibcxx_assert((_M_p >= 0.0) && (_M_p <= 1.0)); + } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + double _M_p; + }; + + public: + /** + * @brief Constructs a Bernoulli distribution with likelihood 0.5. + */ + bernoulli_distribution() : bernoulli_distribution(0.5) { } + + /** + * @brief Constructs a Bernoulli distribution with likelihood @p p. + * + * @param __p [IN] The likelihood of a true result being returned. + * Must be in the interval @f$[0, 1]@f$. + */ + explicit + bernoulli_distribution(double __p) + : _M_param(__p) + { } + + explicit + bernoulli_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for a Bernoulli distribution. + */ + void + reset() { } + + /** + * @brief Returns the @p p parameter of the distribution. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::min(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + if ((__aurng() - __aurng.min()) + < __p.p() * (__aurng.max() - __aurng.min())) + return true; + return false; + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Bernoulli distributions have + * the same parameters. + */ + friend bool + operator==(const bernoulli_distribution& __d1, + const bernoulli_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two Bernoulli distributions have + * different parameters. + */ + inline bool + operator!=(const std::bernoulli_distribution& __d1, + const std::bernoulli_distribution& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %bernoulli_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %bernoulli_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::bernoulli_distribution& __x); + + /** + * @brief Extracts a %bernoulli_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %bernoulli_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + inline std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::bernoulli_distribution& __x) + { + double __p; + if (__is >> __p) + __x.param(bernoulli_distribution::param_type(__p)); + return __is; + } + + + /** + * @brief A discrete binomial random number distribution. + * + * The formula for the binomial probability density function is + * @f$p(i|t,p) = \binom{t}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$ + * and @f$p@f$ are the parameters of the distribution. + */ + template + class binomial_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef binomial_distribution<_IntType> distribution_type; + friend class binomial_distribution<_IntType>; + + param_type() : param_type(1) { } + + explicit + param_type(_IntType __t, double __p = 0.5) + : _M_t(__t), _M_p(__p) + { + __glibcxx_assert((_M_t >= _IntType(0)) + && (_M_p >= 0.0) + && (_M_p <= 1.0)); + _M_initialize(); + } + + _IntType + t() const + { return _M_t; } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_t == __p2._M_t && __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + _IntType _M_t; + double _M_p; + + double _M_q; +#if _GLIBCXX_USE_C99_MATH_TR1 + double _M_d1, _M_d2, _M_s1, _M_s2, _M_c, + _M_a1, _M_a123, _M_s, _M_lf, _M_lp1p; +#endif + bool _M_easy; + }; + + // constructors and member functions + + binomial_distribution() : binomial_distribution(1) { } + + explicit + binomial_distribution(_IntType __t, double __p = 0.5) + : _M_param(__t, __p), _M_nd() + { } + + explicit + binomial_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * @brief Returns the distribution @p t parameter. + */ + _IntType + t() const + { return _M_param.t(); } + + /** + * @brief Returns the distribution @p p parameter. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return 0; } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return _M_param.t(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two binomial distributions have + * the same parameters and the sequences that would + * be generated are equal. + */ + friend bool + operator==(const binomial_distribution& __d1, + const binomial_distribution& __d2) +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; } +#else + { return __d1._M_param == __d2._M_param; } +#endif + + /** + * @brief Inserts a %binomial_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %binomial_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::binomial_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %binomial_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %binomial_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::binomial_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + result_type + _M_waiting(_UniformRandomNumberGenerator& __urng, + _IntType __t, double __q); + + param_type _M_param; + + // NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined. + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two binomial distributions are different. + */ + template + inline bool + operator!=(const std::binomial_distribution<_IntType>& __d1, + const std::binomial_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A discrete geometric random number distribution. + * + * The formula for the geometric probability density function is + * @f$p(i|p) = p(1 - p)^{i}@f$ where @f$p@f$ is the parameter of the + * distribution. + */ + template + class geometric_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef geometric_distribution<_IntType> distribution_type; + friend class geometric_distribution<_IntType>; + + param_type() : param_type(0.5) { } + + explicit + param_type(double __p) + : _M_p(__p) + { + __glibcxx_assert((_M_p > 0.0) && (_M_p < 1.0)); + _M_initialize(); + } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize() + { _M_log_1_p = std::log(1.0 - _M_p); } + + double _M_p; + + double _M_log_1_p; + }; + + // constructors and member functions + + geometric_distribution() : geometric_distribution(0.5) { } + + explicit + geometric_distribution(double __p) + : _M_param(__p) + { } + + explicit + geometric_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for the geometric distribution. + */ + void + reset() { } + + /** + * @brief Returns the distribution parameter @p p. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return 0; } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two geometric distributions have + * the same parameters. + */ + friend bool + operator==(const geometric_distribution& __d1, + const geometric_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two geometric distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::geometric_distribution<_IntType>& __d1, + const std::geometric_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %geometric_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %geometric_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::geometric_distribution<_IntType>& __x); + + /** + * @brief Extracts a %geometric_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %geometric_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::geometric_distribution<_IntType>& __x); + + + /** + * @brief A negative_binomial_distribution random number distribution. + * + * The formula for the negative binomial probability mass function is + * @f$p(i) = \binom{n}{i} p^i (1 - p)^{t - i}@f$ where @f$t@f$ + * and @f$p@f$ are the parameters of the distribution. + */ + template + class negative_binomial_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef negative_binomial_distribution<_IntType> distribution_type; + + param_type() : param_type(1) { } + + explicit + param_type(_IntType __k, double __p = 0.5) + : _M_k(__k), _M_p(__p) + { + __glibcxx_assert((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0)); + } + + _IntType + k() const + { return _M_k; } + + double + p() const + { return _M_p; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_k == __p2._M_k && __p1._M_p == __p2._M_p; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _IntType _M_k; + double _M_p; + }; + + negative_binomial_distribution() : negative_binomial_distribution(1) { } + + explicit + negative_binomial_distribution(_IntType __k, double __p = 0.5) + : _M_param(__k, __p), _M_gd(__k, (1.0 - __p) / __p) + { } + + explicit + negative_binomial_distribution(const param_type& __p) + : _M_param(__p), _M_gd(__p.k(), (1.0 - __p.p()) / __p.p()) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_gd.reset(); } + + /** + * @brief Return the @f$k@f$ parameter of the distribution. + */ + _IntType + k() const + { return _M_param.k(); } + + /** + * @brief Return the @f$p@f$ parameter of the distribution. + */ + double + p() const + { return _M_param.p(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng); + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate_impl(__f, __t, __urng); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two negative binomial distributions have + * the same parameters and the sequences that would be + * generated are equal. + */ + friend bool + operator==(const negative_binomial_distribution& __d1, + const negative_binomial_distribution& __d2) + { return __d1._M_param == __d2._M_param && __d1._M_gd == __d2._M_gd; } + + /** + * @brief Inserts a %negative_binomial_distribution random + * number distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %negative_binomial_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::negative_binomial_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %negative_binomial_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %negative_binomial_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::negative_binomial_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng); + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + std::gamma_distribution _M_gd; + }; + + /** + * @brief Return true if two negative binomial distributions are different. + */ + template + inline bool + operator!=(const std::negative_binomial_distribution<_IntType>& __d1, + const std::negative_binomial_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /// @} group random_distributions_bernoulli + + /** + * @addtogroup random_distributions_poisson Poisson Distributions + * @ingroup random_distributions + * @{ + */ + + /** + * @brief A discrete Poisson random number distribution. + * + * The formula for the Poisson probability density function is + * @f$p(i|\mu) = \frac{\mu^i}{i!} e^{-\mu}@f$ where @f$\mu@f$ is the + * parameter of the distribution. + */ + template + class poisson_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef poisson_distribution<_IntType> distribution_type; + friend class poisson_distribution<_IntType>; + + param_type() : param_type(1.0) { } + + explicit + param_type(double __mean) + : _M_mean(__mean) + { + __glibcxx_assert(_M_mean > 0.0); + _M_initialize(); + } + + double + mean() const + { return _M_mean; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_mean == __p2._M_mean; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + // Hosts either log(mean) or the threshold of the simple method. + void + _M_initialize(); + + double _M_mean; + + double _M_lm_thr; +#if _GLIBCXX_USE_C99_MATH_TR1 + double _M_lfm, _M_sm, _M_d, _M_scx, _M_1cx, _M_c2b, _M_cb; +#endif + }; + + // constructors and member functions + + poisson_distribution() : poisson_distribution(1.0) { } + + explicit + poisson_distribution(double __mean) + : _M_param(__mean), _M_nd() + { } + + explicit + poisson_distribution(const param_type& __p) + : _M_param(__p), _M_nd() + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { _M_nd.reset(); } + + /** + * @brief Returns the distribution parameter @p mean. + */ + double + mean() const + { return _M_param.mean(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return 0; } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Poisson distributions have the same + * parameters and the sequences that would be generated + * are equal. + */ + friend bool + operator==(const poisson_distribution& __d1, + const poisson_distribution& __d2) +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + { return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd; } +#else + { return __d1._M_param == __d2._M_param; } +#endif + + /** + * @brief Inserts a %poisson_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %poisson_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::poisson_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %poisson_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %poisson_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::poisson_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + // NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined. + std::normal_distribution _M_nd; + }; + + /** + * @brief Return true if two Poisson distributions are different. + */ + template + inline bool + operator!=(const std::poisson_distribution<_IntType>& __d1, + const std::poisson_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief An exponential continuous distribution for random numbers. + * + * The formula for the exponential probability density function is + * @f$p(x|\lambda) = \lambda e^{-\lambda x}@f$. + * + * + * + * + * + * + * + * + *
Distribution Statistics
Mean@f$\frac{1}{\lambda}@f$
Median@f$\frac{\ln 2}{\lambda}@f$
Mode@f$zero@f$
Range@f$[0, \infty]@f$
Standard Deviation@f$\frac{1}{\lambda}@f$
+ */ + template + class exponential_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef exponential_distribution<_RealType> distribution_type; + + param_type() : param_type(1.0) { } + + explicit + param_type(_RealType __lambda) + : _M_lambda(__lambda) + { + __glibcxx_assert(_M_lambda > _RealType(0)); + } + + _RealType + lambda() const + { return _M_lambda; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_lambda == __p2._M_lambda; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_lambda; + }; + + public: + /** + * @brief Constructs an exponential distribution with inverse scale + * parameter 1.0 + */ + exponential_distribution() : exponential_distribution(1.0) { } + + /** + * @brief Constructs an exponential distribution with inverse scale + * parameter @f$\lambda@f$. + */ + explicit + exponential_distribution(_RealType __lambda) + : _M_param(__lambda) + { } + + explicit + exponential_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Has no effect on exponential distributions. + */ + void + reset() { } + + /** + * @brief Returns the inverse scale parameter of the distribution. + */ + _RealType + lambda() const + { return _M_param.lambda(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return -std::log(result_type(1) - __aurng()) / __p.lambda(); + } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two exponential distributions have the same + * parameters. + */ + friend bool + operator==(const exponential_distribution& __d1, + const exponential_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two exponential distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::exponential_distribution<_RealType>& __d1, + const std::exponential_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %exponential_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %exponential_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::exponential_distribution<_RealType>& __x); + + /** + * @brief Extracts a %exponential_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %exponential_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::exponential_distribution<_RealType>& __x); + + + /** + * @brief A weibull_distribution random number distribution. + * + * The formula for the normal probability density function is: + * @f[ + * p(x|\alpha,\beta) = \frac{\alpha}{\beta} (\frac{x}{\beta})^{\alpha-1} + * \exp{(-(\frac{x}{\beta})^\alpha)} + * @f] + */ + template + class weibull_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef weibull_distribution<_RealType> distribution_type; + + param_type() : param_type(1.0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1.0)) + : _M_a(__a), _M_b(__b) + { } + + _RealType + a() const + { return _M_a; } + + _RealType + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + weibull_distribution() : weibull_distribution(1.0) { } + + explicit + weibull_distribution(_RealType __a, _RealType __b = _RealType(1)) + : _M_param(__a, __b) + { } + + explicit + weibull_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Return the @f$a@f$ parameter of the distribution. + */ + _RealType + a() const + { return _M_param.a(); } + + /** + * @brief Return the @f$b@f$ parameter of the distribution. + */ + _RealType + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two Weibull distributions have the same + * parameters. + */ + friend bool + operator==(const weibull_distribution& __d1, + const weibull_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two Weibull distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::weibull_distribution<_RealType>& __d1, + const std::weibull_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %weibull_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %weibull_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::weibull_distribution<_RealType>& __x); + + /** + * @brief Extracts a %weibull_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %weibull_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::weibull_distribution<_RealType>& __x); + + + /** + * @brief A extreme_value_distribution random number distribution. + * + * The formula for the normal probability mass function is + * @f[ + * p(x|a,b) = \frac{1}{b} + * \exp( \frac{a-x}{b} - \exp(\frac{a-x}{b})) + * @f] + */ + template + class extreme_value_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef extreme_value_distribution<_RealType> distribution_type; + + param_type() : param_type(0.0) { } + + explicit + param_type(_RealType __a, _RealType __b = _RealType(1.0)) + : _M_a(__a), _M_b(__b) + { } + + _RealType + a() const + { return _M_a; } + + _RealType + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _RealType _M_a; + _RealType _M_b; + }; + + extreme_value_distribution() : extreme_value_distribution(0.0) { } + + explicit + extreme_value_distribution(_RealType __a, _RealType __b = _RealType(1)) + : _M_param(__a, __b) + { } + + explicit + extreme_value_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Return the @f$a@f$ parameter of the distribution. + */ + _RealType + a() const + { return _M_param.a(); } + + /** + * @brief Return the @f$b@f$ parameter of the distribution. + */ + _RealType + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return std::numeric_limits::lowest(); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { return std::numeric_limits::max(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two extreme value distributions have the same + * parameters. + */ + friend bool + operator==(const extreme_value_distribution& __d1, + const extreme_value_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two extreme value distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::extreme_value_distribution<_RealType>& __d1, + const std::extreme_value_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + /** + * @brief Inserts a %extreme_value_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %extreme_value_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::extreme_value_distribution<_RealType>& __x); + + /** + * @brief Extracts a %extreme_value_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %extreme_value_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::extreme_value_distribution<_RealType>& __x); + + + /** + * @brief A discrete_distribution random number distribution. + * + * The formula for the discrete probability mass function is + * + */ + template + class discrete_distribution + { + static_assert(std::is_integral<_IntType>::value, + "result_type must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + + /** Parameter type. */ + struct param_type + { + typedef discrete_distribution<_IntType> distribution_type; + friend class discrete_distribution<_IntType>; + + param_type() + : _M_prob(), _M_cp() + { } + + template + param_type(_InputIterator __wbegin, + _InputIterator __wend) + : _M_prob(__wbegin, __wend), _M_cp() + { _M_initialize(); } + + param_type(initializer_list __wil) + : _M_prob(__wil.begin(), __wil.end()), _M_cp() + { _M_initialize(); } + + template + param_type(size_t __nw, double __xmin, double __xmax, + _Func __fw); + + // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/ + param_type(const param_type&) = default; + param_type& operator=(const param_type&) = default; + + std::vector + probabilities() const + { return _M_prob.empty() ? std::vector(1, 1.0) : _M_prob; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_prob == __p2._M_prob; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + std::vector _M_prob; + std::vector _M_cp; + }; + + discrete_distribution() + : _M_param() + { } + + template + discrete_distribution(_InputIterator __wbegin, + _InputIterator __wend) + : _M_param(__wbegin, __wend) + { } + + discrete_distribution(initializer_list __wl) + : _M_param(__wl) + { } + + template + discrete_distribution(size_t __nw, double __xmin, double __xmax, + _Func __fw) + : _M_param(__nw, __xmin, __xmax, __fw) + { } + + explicit + discrete_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Returns the probabilities of the distribution. + */ + std::vector + probabilities() const + { + return _M_param._M_prob.empty() + ? std::vector(1, 1.0) : _M_param._M_prob; + } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { return result_type(0); } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { + return _M_param._M_prob.empty() + ? result_type(0) : result_type(_M_param._M_prob.size() - 1); + } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two discrete distributions have the same + * parameters. + */ + friend bool + operator==(const discrete_distribution& __d1, + const discrete_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + /** + * @brief Inserts a %discrete_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %discrete_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::discrete_distribution<_IntType1>& __x); + + /** + * @brief Extracts a %discrete_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %discrete_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::discrete_distribution<_IntType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two discrete distributions have different + * parameters. + */ + template + inline bool + operator!=(const std::discrete_distribution<_IntType>& __d1, + const std::discrete_distribution<_IntType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A piecewise_constant_distribution random number distribution. + * + * The formula for the piecewise constant probability mass function is + * + */ + template + class piecewise_constant_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef piecewise_constant_distribution<_RealType> distribution_type; + friend class piecewise_constant_distribution<_RealType>; + + param_type() + : _M_int(), _M_den(), _M_cp() + { } + + template + param_type(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin); + + template + param_type(initializer_list<_RealType> __bi, _Func __fw); + + template + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, + _Func __fw); + + // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/ + param_type(const param_type&) = default; + param_type& operator=(const param_type&) = default; + + std::vector<_RealType> + intervals() const + { + if (_M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_int; + } + + std::vector + densities() const + { return _M_den.empty() ? std::vector(1, 1.0) : _M_den; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + std::vector<_RealType> _M_int; + std::vector _M_den; + std::vector _M_cp; + }; + + piecewise_constant_distribution() + : _M_param() + { } + + template + piecewise_constant_distribution(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_param(__bfirst, __bend, __wbegin) + { } + + template + piecewise_constant_distribution(initializer_list<_RealType> __bl, + _Func __fw) + : _M_param(__bl, __fw) + { } + + template + piecewise_constant_distribution(size_t __nw, + _RealType __xmin, _RealType __xmax, + _Func __fw) + : _M_param(__nw, __xmin, __xmax, __fw) + { } + + explicit + piecewise_constant_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Returns a vector of the intervals. + */ + std::vector<_RealType> + intervals() const + { + if (_M_param._M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_param._M_int; + } + + /** + * @brief Returns a vector of the probability densities. + */ + std::vector + densities() const + { + return _M_param._M_den.empty() + ? std::vector(1, 1.0) : _M_param._M_den; + } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { + return _M_param._M_int.empty() + ? result_type(0) : _M_param._M_int.front(); + } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { + return _M_param._M_int.empty() + ? result_type(1) : _M_param._M_int.back(); + } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two piecewise constant distributions have the + * same parameters. + */ + friend bool + operator==(const piecewise_constant_distribution& __d1, + const piecewise_constant_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + /** + * @brief Inserts a %piecewise_constant_distribution random + * number distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %piecewise_constant_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::piecewise_constant_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %piecewise_constant_distribution random + * number distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %piecewise_constant_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::piecewise_constant_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two piecewise constant distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::piecewise_constant_distribution<_RealType>& __d1, + const std::piecewise_constant_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /** + * @brief A piecewise_linear_distribution random number distribution. + * + * The formula for the piecewise linear probability mass function is + * + */ + template + class piecewise_linear_distribution + { + static_assert(std::is_floating_point<_RealType>::value, + "result_type must be a floating point type"); + + public: + /** The type of the range of the distribution. */ + typedef _RealType result_type; + + /** Parameter type. */ + struct param_type + { + typedef piecewise_linear_distribution<_RealType> distribution_type; + friend class piecewise_linear_distribution<_RealType>; + + param_type() + : _M_int(), _M_den(), _M_cp(), _M_m() + { } + + template + param_type(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin); + + template + param_type(initializer_list<_RealType> __bl, _Func __fw); + + template + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, + _Func __fw); + + // See: http://cpp-next.com/archive/2010/10/implicit-move-must-go/ + param_type(const param_type&) = default; + param_type& operator=(const param_type&) = default; + + std::vector<_RealType> + intervals() const + { + if (_M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_int; + } + + std::vector + densities() const + { return _M_den.empty() ? std::vector(2, 1.0) : _M_den; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_int == __p2._M_int && __p1._M_den == __p2._M_den; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + void + _M_initialize(); + + std::vector<_RealType> _M_int; + std::vector _M_den; + std::vector _M_cp; + std::vector _M_m; + }; + + piecewise_linear_distribution() + : _M_param() + { } + + template + piecewise_linear_distribution(_InputIteratorB __bfirst, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_param(__bfirst, __bend, __wbegin) + { } + + template + piecewise_linear_distribution(initializer_list<_RealType> __bl, + _Func __fw) + : _M_param(__bl, __fw) + { } + + template + piecewise_linear_distribution(size_t __nw, + _RealType __xmin, _RealType __xmax, + _Func __fw) + : _M_param(__nw, __xmin, __xmax, __fw) + { } + + explicit + piecewise_linear_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * Resets the distribution state. + */ + void + reset() + { } + + /** + * @brief Return the intervals of the distribution. + */ + std::vector<_RealType> + intervals() const + { + if (_M_param._M_int.empty()) + { + std::vector<_RealType> __tmp(2); + __tmp[1] = _RealType(1); + return __tmp; + } + else + return _M_param._M_int; + } + + /** + * @brief Return a vector of the probability densities of the + * distribution. + */ + std::vector + densities() const + { + return _M_param._M_den.empty() + ? std::vector(2, 1.0) : _M_param._M_den; + } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the greatest lower bound value of the distribution. + */ + result_type + min() const + { + return _M_param._M_int.empty() + ? result_type(0) : _M_param._M_int.front(); + } + + /** + * @brief Returns the least upper bound value of the distribution. + */ + result_type + max() const + { + return _M_param._M_int.empty() + ? result_type(1) : _M_param._M_int.back(); + } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomNumberGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two piecewise linear distributions have the + * same parameters. + */ + friend bool + operator==(const piecewise_linear_distribution& __d1, + const piecewise_linear_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + /** + * @brief Inserts a %piecewise_linear_distribution random number + * distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %piecewise_linear_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const std::piecewise_linear_distribution<_RealType1>& __x); + + /** + * @brief Extracts a %piecewise_linear_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %piecewise_linear_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error + * state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + std::piecewise_linear_distribution<_RealType1>& __x); + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p); + + param_type _M_param; + }; + + /** + * @brief Return true if two piecewise linear distributions have + * different parameters. + */ + template + inline bool + operator!=(const std::piecewise_linear_distribution<_RealType>& __d1, + const std::piecewise_linear_distribution<_RealType>& __d2) + { return !(__d1 == __d2); } + + + /// @} group random_distributions_poisson + + /// @} *group random_distributions + + /** + * @addtogroup random_utilities Random Number Utilities + * @ingroup random + * @{ + */ + + /** + * @brief The seed_seq class generates sequences of seeds for random + * number generators. + */ + class seed_seq + { + public: + /** The type of the seed vales. */ + typedef uint_least32_t result_type; + + /** Default constructor. */ + seed_seq() noexcept + : _M_v() + { } + + template>> + seed_seq(std::initializer_list<_IntType> __il); + + template + seed_seq(_InputIterator __begin, _InputIterator __end); + + // generating functions + template + void + generate(_RandomAccessIterator __begin, _RandomAccessIterator __end); + + // property functions + size_t size() const noexcept + { return _M_v.size(); } + + template + void + param(_OutputIterator __dest) const + { std::copy(_M_v.begin(), _M_v.end(), __dest); } + + // no copy functions + seed_seq(const seed_seq&) = delete; + seed_seq& operator=(const seed_seq&) = delete; + + private: + std::vector _M_v; + }; + + /// @} group random_utilities + + /// @} group random + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/random.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/random.tcc new file mode 100755 index 0000000..b33f8a8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/random.tcc @@ -0,0 +1,3381 @@ +// random number generation (out of line) -*- C++ -*- + +// Copyright (C) 2009-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/random.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _RANDOM_TCC +#define _RANDOM_TCC 1 + +#include // std::accumulate and std::partial_sum + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @cond undocumented + // (Further) implementation-space details. + namespace __detail + { + // General case for x = (ax + c) mod m -- use Schrage's algorithm + // to avoid integer overflow. + // + // Preconditions: a > 0, m > 0. + // + // Note: only works correctly for __m % __a < __m / __a. + template + _Tp + _Mod<_Tp, __m, __a, __c, false, true>:: + __calc(_Tp __x) + { + if (__a == 1) + __x %= __m; + else + { + static const _Tp __q = __m / __a; + static const _Tp __r = __m % __a; + + _Tp __t1 = __a * (__x % __q); + _Tp __t2 = __r * (__x / __q); + if (__t1 >= __t2) + __x = __t1 - __t2; + else + __x = __m - __t2 + __t1; + } + + if (__c != 0) + { + const _Tp __d = __m - __x; + if (__d > __c) + __x += __c; + else + __x = __c - __d; + } + return __x; + } + + template + _OutputIterator + __normalize(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, const _Tp& __factor) + { + for (; __first != __last; ++__first, ++__result) + *__result = *__first / __factor; + return __result; + } + + } // namespace __detail + /// @endcond + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::increment; + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; + + template + constexpr _UIntType + linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; + + /** + * Seeds the LCR with integral value @p __s, adjusted so that the + * ring identity is never a member of the convergence set. + */ + template + void + linear_congruential_engine<_UIntType, __a, __c, __m>:: + seed(result_type __s) + { + if ((__detail::__mod<_UIntType, __m>(__c) == 0) + && (__detail::__mod<_UIntType, __m>(__s) == 0)) + _M_x = 1; + else + _M_x = __detail::__mod<_UIntType, __m>(__s); + } + + /** + * Seeds the LCR engine with a value generated by @p __q. + */ + template + template + auto + linear_congruential_engine<_UIntType, __a, __c, __m>:: + seed(_Sseq& __q) + -> _If_seed_seq<_Sseq> + { + const _UIntType __k0 = __m == 0 ? std::numeric_limits<_UIntType>::digits + : std::__lg(__m); + const _UIntType __k = (__k0 + 31) / 32; + uint_least32_t __arr[__k + 3]; + __q.generate(__arr + 0, __arr + __k + 3); + _UIntType __factor = 1u; + _UIntType __sum = 0u; + for (size_t __j = 0; __j < __k; ++__j) + { + __sum += __arr[__j + 3] * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + seed(__sum); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const linear_congruential_engine<_UIntType, + __a, __c, __m>& __lcr) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__os.widen(' ')); + + __os << __lcr._M_x; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + linear_congruential_engine<_UIntType, __a, __c, __m>& __lcr) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec); + + __is >> __lcr._M_x; + + __is.flags(__flags); + return __is; + } + + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::word_size; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::state_size; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::shift_size; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::mask_bits; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::xor_mask; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_u; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_d; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_s; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_b; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_t; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_c; + + template + constexpr size_t + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::tempering_l; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + initialization_multiplier; + + template + constexpr _UIntType + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::default_seed; + + template + void + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + seed(result_type __sd) + { + _M_x[0] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sd); + + for (size_t __i = 1; __i < state_size; ++__i) + { + _UIntType __x = _M_x[__i - 1]; + __x ^= __x >> (__w - 2); + __x *= __f; + __x += __detail::__mod<_UIntType, __n>(__i); + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__x); + } + _M_p = state_size; + } + + template + template + auto + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + seed(_Sseq& __q) + -> _If_seed_seq<_Sseq> + { + const _UIntType __upper_mask = (~_UIntType()) << __r; + const size_t __k = (__w + 31) / 32; + uint_least32_t __arr[__n * __k]; + __q.generate(__arr + 0, __arr + __n * __k); + + bool __zero = true; + for (size_t __i = 0; __i < state_size; ++__i) + { + _UIntType __factor = 1u; + _UIntType __sum = 0u; + for (size_t __j = 0; __j < __k; ++__j) + { + __sum += __arr[__k * __i + __j] * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sum); + + if (__zero) + { + if (__i == 0) + { + if ((_M_x[0] & __upper_mask) != 0u) + __zero = false; + } + else if (_M_x[__i] != 0u) + __zero = false; + } + } + if (__zero) + _M_x[0] = __detail::_Shift<_UIntType, __w - 1>::__value; + _M_p = state_size; + } + + template + void + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + _M_gen_rand(void) + { + const _UIntType __upper_mask = (~_UIntType()) << __r; + const _UIntType __lower_mask = ~__upper_mask; + + for (size_t __k = 0; __k < (__n - __m); ++__k) + { + _UIntType __y = ((_M_x[__k] & __upper_mask) + | (_M_x[__k + 1] & __lower_mask)); + _M_x[__k] = (_M_x[__k + __m] ^ (__y >> 1) + ^ ((__y & 0x01) ? __a : 0)); + } + + for (size_t __k = (__n - __m); __k < (__n - 1); ++__k) + { + _UIntType __y = ((_M_x[__k] & __upper_mask) + | (_M_x[__k + 1] & __lower_mask)); + _M_x[__k] = (_M_x[__k + (__m - __n)] ^ (__y >> 1) + ^ ((__y & 0x01) ? __a : 0)); + } + + _UIntType __y = ((_M_x[__n - 1] & __upper_mask) + | (_M_x[0] & __lower_mask)); + _M_x[__n - 1] = (_M_x[__m - 1] ^ (__y >> 1) + ^ ((__y & 0x01) ? __a : 0)); + _M_p = 0; + } + + template + void + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + discard(unsigned long long __z) + { + while (__z > state_size - _M_p) + { + __z -= state_size - _M_p; + _M_gen_rand(); + } + _M_p += __z; + } + + template + typename + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>::result_type + mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, + __s, __b, __t, __c, __l, __f>:: + operator()() + { + // Reload the vector - cost is O(n) amortized over n calls. + if (_M_p >= state_size) + _M_gen_rand(); + + // Calculate o(x(i)). + result_type __z = _M_x[_M_p++]; + __z ^= (__z >> __u) & __d; + __z ^= (__z << __s) & __b; + __z ^= (__z << __t) & __c; + __z ^= (__z >> __l); + + return __z; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + for (size_t __i = 0; __i < __n; ++__i) + __os << __x._M_x[__i] << __space; + __os << __x._M_p; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + mersenne_twister_engine<_UIntType, __w, __n, __m, + __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + for (size_t __i = 0; __i < __n; ++__i) + __is >> __x._M_x[__i]; + __is >> __x._M_p; + + __is.flags(__flags); + return __is; + } + + + template + constexpr size_t + subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; + + template + constexpr size_t + subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; + + template + constexpr size_t + subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; + + template + constexpr _UIntType + subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; + + template + void + subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + seed(result_type __value) + { + std::linear_congruential_engine + __lcg(__value == 0u ? default_seed : __value); + + const size_t __n = (__w + 31) / 32; + + for (size_t __i = 0; __i < long_lag; ++__i) + { + _UIntType __sum = 0u; + _UIntType __factor = 1u; + for (size_t __j = 0; __j < __n; ++__j) + { + __sum += __detail::__mod::__value> + (__lcg()) * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sum); + } + _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0; + _M_p = 0; + } + + template + template + auto + subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + seed(_Sseq& __q) + -> _If_seed_seq<_Sseq> + { + const size_t __k = (__w + 31) / 32; + uint_least32_t __arr[__r * __k]; + __q.generate(__arr + 0, __arr + __r * __k); + + for (size_t __i = 0; __i < long_lag; ++__i) + { + _UIntType __sum = 0u; + _UIntType __factor = 1u; + for (size_t __j = 0; __j < __k; ++__j) + { + __sum += __arr[__k * __i + __j] * __factor; + __factor *= __detail::_Shift<_UIntType, 32>::__value; + } + _M_x[__i] = __detail::__mod<_UIntType, + __detail::_Shift<_UIntType, __w>::__value>(__sum); + } + _M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0; + _M_p = 0; + } + + template + typename subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + result_type + subtract_with_carry_engine<_UIntType, __w, __s, __r>:: + operator()() + { + // Derive short lag index from current index. + long __ps = _M_p - short_lag; + if (__ps < 0) + __ps += long_lag; + + // Calculate new x(i) without overflow or division. + // NB: Thanks to the requirements for _UIntType, _M_x[_M_p] + _M_carry + // cannot overflow. + _UIntType __xi; + if (_M_x[__ps] >= _M_x[_M_p] + _M_carry) + { + __xi = _M_x[__ps] - _M_x[_M_p] - _M_carry; + _M_carry = 0; + } + else + { + __xi = (__detail::_Shift<_UIntType, __w>::__value + - _M_x[_M_p] - _M_carry + _M_x[__ps]); + _M_carry = 1; + } + _M_x[_M_p] = __xi; + + // Adjust current index to loop around in ring buffer. + if (++_M_p >= long_lag) + _M_p = 0; + + return __xi; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const subtract_with_carry_engine<_UIntType, + __w, __s, __r>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + for (size_t __i = 0; __i < __r; ++__i) + __os << __x._M_x[__i] << __space; + __os << __x._M_carry << __space << __x._M_p; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + subtract_with_carry_engine<_UIntType, __w, __s, __r>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + for (size_t __i = 0; __i < __r; ++__i) + __is >> __x._M_x[__i]; + __is >> __x._M_carry; + __is >> __x._M_p; + + __is.flags(__flags); + return __is; + } + + + template + constexpr size_t + discard_block_engine<_RandomNumberEngine, __p, __r>::block_size; + + template + constexpr size_t + discard_block_engine<_RandomNumberEngine, __p, __r>::used_block; + + template + typename discard_block_engine<_RandomNumberEngine, + __p, __r>::result_type + discard_block_engine<_RandomNumberEngine, __p, __r>:: + operator()() + { + if (_M_n >= used_block) + { + _M_b.discard(block_size - _M_n); + _M_n = 0; + } + ++_M_n; + return _M_b(); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const discard_block_engine<_RandomNumberEngine, + __p, __r>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + __os << __x.base() << __space << __x._M_n; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + discard_block_engine<_RandomNumberEngine, __p, __r>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + __is >> __x._M_b >> __x._M_n; + + __is.flags(__flags); + return __is; + } + + + template + typename independent_bits_engine<_RandomNumberEngine, __w, _UIntType>:: + result_type + independent_bits_engine<_RandomNumberEngine, __w, _UIntType>:: + operator()() + { + typedef typename _RandomNumberEngine::result_type _Eresult_type; + const _Eresult_type __r + = (_M_b.max() - _M_b.min() < std::numeric_limits<_Eresult_type>::max() + ? _M_b.max() - _M_b.min() + 1 : 0); + const unsigned __edig = std::numeric_limits<_Eresult_type>::digits; + const unsigned __m = __r ? std::__lg(__r) : __edig; + + typedef typename std::common_type<_Eresult_type, result_type>::type + __ctype; + const unsigned __cdig = std::numeric_limits<__ctype>::digits; + + unsigned __n, __n0; + __ctype __s0, __s1, __y0, __y1; + + for (size_t __i = 0; __i < 2; ++__i) + { + __n = (__w + __m - 1) / __m + __i; + __n0 = __n - __w % __n; + const unsigned __w0 = __w / __n; // __w0 <= __m + + __s0 = 0; + __s1 = 0; + if (__w0 < __cdig) + { + __s0 = __ctype(1) << __w0; + __s1 = __s0 << 1; + } + + __y0 = 0; + __y1 = 0; + if (__r) + { + __y0 = __s0 * (__r / __s0); + if (__s1) + __y1 = __s1 * (__r / __s1); + + if (__r - __y0 <= __y0 / __n) + break; + } + else + break; + } + + result_type __sum = 0; + for (size_t __k = 0; __k < __n0; ++__k) + { + __ctype __u; + do + __u = _M_b() - _M_b.min(); + while (__y0 && __u >= __y0); + __sum = __s0 * __sum + (__s0 ? __u % __s0 : __u); + } + for (size_t __k = __n0; __k < __n; ++__k) + { + __ctype __u; + do + __u = _M_b() - _M_b.min(); + while (__y1 && __u >= __y1); + __sum = __s1 * __sum + (__s1 ? __u % __s1 : __u); + } + return __sum; + } + + + template + constexpr size_t + shuffle_order_engine<_RandomNumberEngine, __k>::table_size; + + namespace __detail + { + // Determine whether an integer is representable as double. + template + constexpr bool + __representable_as_double(_Tp __x) noexcept + { + static_assert(numeric_limits<_Tp>::is_integer, ""); + static_assert(!numeric_limits<_Tp>::is_signed, ""); + // All integers <= 2^53 are representable. + return (__x <= (1ull << __DBL_MANT_DIG__)) + // Between 2^53 and 2^54 only even numbers are representable. + || (!(__x & 1) && __detail::__representable_as_double(__x >> 1)); + } + + // Determine whether x+1 is representable as double. + template + constexpr bool + __p1_representable_as_double(_Tp __x) noexcept + { + static_assert(numeric_limits<_Tp>::is_integer, ""); + static_assert(!numeric_limits<_Tp>::is_signed, ""); + return numeric_limits<_Tp>::digits < __DBL_MANT_DIG__ + || (bool(__x + 1u) // return false if x+1 wraps around to zero + && __detail::__representable_as_double(__x + 1u)); + } + } + + template + typename shuffle_order_engine<_RandomNumberEngine, __k>::result_type + shuffle_order_engine<_RandomNumberEngine, __k>:: + operator()() + { + constexpr result_type __range = max() - min(); + size_t __j = __k; + const result_type __y = _M_y - min(); + // Avoid using slower long double arithmetic if possible. + if _GLIBCXX17_CONSTEXPR (__detail::__p1_representable_as_double(__range)) + __j *= __y / (__range + 1.0); + else + __j *= __y / (__range + 1.0L); + _M_y = _M_v[__j]; + _M_v[__j] = _M_b(); + + return _M_y; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const shuffle_order_engine<_RandomNumberEngine, __k>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left); + __os.fill(__space); + + __os << __x.base(); + for (size_t __i = 0; __i < __k; ++__i) + __os << __space << __x._M_v[__i]; + __os << __space << __x._M_y; + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + shuffle_order_engine<_RandomNumberEngine, __k>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + __is >> __x._M_b; + for (size_t __i = 0; __i < __k; ++__i) + __is >> __x._M_v[__i]; + __is >> __x._M_y; + + __is.flags(__flags); + return __is; + } + + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const uniform_int_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + uniform_int_distribution<_IntType>& __x) + { + using param_type + = typename uniform_int_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _IntType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + uniform_real_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + auto __range = __p.b() - __p.a(); + while (__f != __t) + *__f++ = __aurng() * __range + __p.a(); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const uniform_real_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + uniform_real_distribution<_RealType>& __x) + { + using param_type + = typename uniform_real_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + void + std::bernoulli_distribution:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + auto __limit = __p.p() * (__aurng.max() - __aurng.min()); + + while (__f != __t) + *__f++ = (__aurng() - __aurng.min()) < __limit; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bernoulli_distribution& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.p(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + + template + template + typename geometric_distribution<_IntType>::result_type + geometric_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + // About the epsilon thing see this thread: + // http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + // The largest _RealType convertible to _IntType. + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + double __cand; + do + __cand = std::floor(std::log(1.0 - __aurng()) / __param._M_log_1_p); + while (__cand >= __thr); + + return result_type(__cand + __naf); + } + + template + template + void + geometric_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // About the epsilon thing see this thread: + // http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00971.html + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + // The largest _RealType convertible to _IntType. + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + while (__f != __t) + { + double __cand; + do + __cand = std::floor(std::log(1.0 - __aurng()) + / __param._M_log_1_p); + while (__cand >= __thr); + + *__f++ = __cand + __naf; + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const geometric_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.p(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + geometric_distribution<_IntType>& __x) + { + using param_type = typename geometric_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + double __p; + if (__is >> __p) + __x.param(param_type(__p)); + + __is.flags(__flags); + return __is; + } + + // This is Leger's algorithm, also in Devroye, Ch. X, Example 1.5. + template + template + typename negative_binomial_distribution<_IntType>::result_type + negative_binomial_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng) + { + const double __y = _M_gd(__urng); + + // XXX Is the constructor too slow? + std::poisson_distribution __poisson(__y); + return __poisson(__urng); + } + + template + template + typename negative_binomial_distribution<_IntType>::result_type + negative_binomial_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + typedef typename std::gamma_distribution::param_type + param_type; + + const double __y = + _M_gd(__urng, param_type(__p.k(), (1.0 - __p.p()) / __p.p())); + + std::poisson_distribution __poisson(__y); + return __poisson(__urng); + } + + template + template + void + negative_binomial_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + { + const double __y = _M_gd(__urng); + + // XXX Is the constructor too slow? + std::poisson_distribution __poisson(__y); + *__f++ = __poisson(__urng); + } + } + + template + template + void + negative_binomial_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typename std::gamma_distribution::param_type + __p2(__p.k(), (1.0 - __p.p()) / __p.p()); + + while (__f != __t) + { + const double __y = _M_gd(__urng, __p2); + + std::poisson_distribution __poisson(__y); + *__f++ = __poisson(__urng); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const negative_binomial_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.k() << __space << __x.p() + << __space << __x._M_gd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + negative_binomial_distribution<_IntType>& __x) + { + using param_type + = typename negative_binomial_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + _IntType __k; + double __p; + if (__is >> __k >> __p >> __x._M_gd) + __x.param(param_type(__k, __p)); + + __is.flags(__flags); + return __is; + } + + + template + void + poisson_distribution<_IntType>::param_type:: + _M_initialize() + { +#if _GLIBCXX_USE_C99_MATH_TR1 + if (_M_mean >= 12) + { + const double __m = std::floor(_M_mean); + _M_lm_thr = std::log(_M_mean); + _M_lfm = std::lgamma(__m + 1); + _M_sm = std::sqrt(__m); + + const double __pi_4 = 0.7853981633974483096156608458198757L; + const double __dx = std::sqrt(2 * __m * std::log(32 * __m + / __pi_4)); + _M_d = std::round(std::max(6.0, std::min(__m, __dx))); + const double __cx = 2 * __m + _M_d; + _M_scx = std::sqrt(__cx / 2); + _M_1cx = 1 / __cx; + + _M_c2b = std::sqrt(__pi_4 * __cx) * std::exp(_M_1cx); + _M_cb = 2 * __cx * std::exp(-_M_d * _M_1cx * (1 + _M_d / 2)) + / _M_d; + } + else +#endif + _M_lm_thr = std::exp(-_M_mean); + } + + /** + * A rejection algorithm when mean >= 12 and a simple method based + * upon the multiplication of uniform random variates otherwise. + * NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1 + * is defined. + * + * Reference: + * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, + * New York, 1986, Ch. X, Sects. 3.3 & 3.4 (+ Errata!). + */ + template + template + typename poisson_distribution<_IntType>::result_type + poisson_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); +#if _GLIBCXX_USE_C99_MATH_TR1 + if (__param.mean() >= 12) + { + double __x; + + // See comments above... + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + + const double __m = std::floor(__param.mean()); + // sqrt(pi / 2) + const double __spi_2 = 1.2533141373155002512078826424055226L; + const double __c1 = __param._M_sm * __spi_2; + const double __c2 = __param._M_c2b + __c1; + const double __c3 = __c2 + 1; + const double __c4 = __c3 + 1; + // 1 / 78 + const double __178 = 0.0128205128205128205128205128205128L; + // e^(1 / 78) + const double __e178 = 1.0129030479320018583185514777512983L; + const double __c5 = __c4 + __e178; + const double __c = __param._M_cb + __c5; + const double __2cx = 2 * (2 * __m + __param._M_d); + + bool __reject = true; + do + { + const double __u = __c * __aurng(); + const double __e = -std::log(1.0 - __aurng()); + + double __w = 0.0; + + if (__u <= __c1) + { + const double __n = _M_nd(__urng); + const double __y = -std::abs(__n) * __param._M_sm - 1; + __x = std::floor(__y); + __w = -__n * __n / 2; + if (__x < -__m) + continue; + } + else if (__u <= __c2) + { + const double __n = _M_nd(__urng); + const double __y = 1 + std::abs(__n) * __param._M_scx; + __x = std::ceil(__y); + __w = __y * (2 - __y) * __param._M_1cx; + if (__x > __param._M_d) + continue; + } + else if (__u <= __c3) + // NB: This case not in the book, nor in the Errata, + // but should be ok... + __x = -1; + else if (__u <= __c4) + __x = 0; + else if (__u <= __c5) + { + __x = 1; + // Only in the Errata, see libstdc++/83237. + __w = __178; + } + else + { + const double __v = -std::log(1.0 - __aurng()); + const double __y = __param._M_d + + __v * __2cx / __param._M_d; + __x = std::ceil(__y); + __w = -__param._M_d * __param._M_1cx * (1 + __y / 2); + } + + __reject = (__w - __e - __x * __param._M_lm_thr + > __param._M_lfm - std::lgamma(__x + __m + 1)); + + __reject |= __x + __m >= __thr; + + } while (__reject); + + return result_type(__x + __m + __naf); + } + else +#endif + { + _IntType __x = 0; + double __prod = 1.0; + + do + { + __prod *= __aurng(); + __x += 1; + } + while (__prod > __param._M_lm_thr); + + return __x - 1; + } + } + + template + template + void + poisson_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // We could duplicate everything from operator()... + while (__f != __t) + *__f++ = this->operator()(__urng, __param); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const poisson_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.mean() << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + poisson_distribution<_IntType>& __x) + { + using param_type = typename poisson_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::skipws); + + double __mean; + if (__is >> __mean >> __x._M_nd) + __x.param(param_type(__mean)); + + __is.flags(__flags); + return __is; + } + + + template + void + binomial_distribution<_IntType>::param_type:: + _M_initialize() + { + const double __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p; + + _M_easy = true; + +#if _GLIBCXX_USE_C99_MATH_TR1 + if (_M_t * __p12 >= 8) + { + _M_easy = false; + const double __np = std::floor(_M_t * __p12); + const double __pa = __np / _M_t; + const double __1p = 1 - __pa; + + const double __pi_4 = 0.7853981633974483096156608458198757L; + const double __d1x = + std::sqrt(__np * __1p * std::log(32 * __np + / (81 * __pi_4 * __1p))); + _M_d1 = std::round(std::max(1.0, __d1x)); + const double __d2x = + std::sqrt(__np * __1p * std::log(32 * _M_t * __1p + / (__pi_4 * __pa))); + _M_d2 = std::round(std::max(1.0, __d2x)); + + // sqrt(pi / 2) + const double __spi_2 = 1.2533141373155002512078826424055226L; + _M_s1 = std::sqrt(__np * __1p) * (1 + _M_d1 / (4 * __np)); + _M_s2 = std::sqrt(__np * __1p) * (1 + _M_d2 / (4 * _M_t * __1p)); + _M_c = 2 * _M_d1 / __np; + _M_a1 = std::exp(_M_c) * _M_s1 * __spi_2; + const double __a12 = _M_a1 + _M_s2 * __spi_2; + const double __s1s = _M_s1 * _M_s1; + _M_a123 = __a12 + (std::exp(_M_d1 / (_M_t * __1p)) + * 2 * __s1s / _M_d1 + * std::exp(-_M_d1 * _M_d1 / (2 * __s1s))); + const double __s2s = _M_s2 * _M_s2; + _M_s = (_M_a123 + 2 * __s2s / _M_d2 + * std::exp(-_M_d2 * _M_d2 / (2 * __s2s))); + _M_lf = (std::lgamma(__np + 1) + + std::lgamma(_M_t - __np + 1)); + _M_lp1p = std::log(__pa / __1p); + + _M_q = -std::log(1 - (__p12 - __pa) / __1p); + } + else +#endif + _M_q = -std::log(1 - __p12); + } + + template + template + typename binomial_distribution<_IntType>::result_type + binomial_distribution<_IntType>:: + _M_waiting(_UniformRandomNumberGenerator& __urng, + _IntType __t, double __q) + { + _IntType __x = 0; + double __sum = 0.0; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + do + { + if (__t == __x) + return __x; + const double __e = -std::log(1.0 - __aurng()); + __sum += __e / (__t - __x); + __x += 1; + } + while (__sum <= __q); + + return __x - 1; + } + + /** + * A rejection algorithm when t * p >= 8 and a simple waiting time + * method - the second in the referenced book - otherwise. + * NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1 + * is defined. + * + * Reference: + * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, + * New York, 1986, Ch. X, Sect. 4 (+ Errata!). + */ + template + template + typename binomial_distribution<_IntType>::result_type + binomial_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + result_type __ret; + const _IntType __t = __param.t(); + const double __p = __param.p(); + const double __p12 = __p <= 0.5 ? __p : 1.0 - __p; + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + +#if _GLIBCXX_USE_C99_MATH_TR1 + if (!__param._M_easy) + { + double __x; + + // See comments above... + const double __naf = + (1 - std::numeric_limits::epsilon()) / 2; + const double __thr = + std::numeric_limits<_IntType>::max() + __naf; + + const double __np = std::floor(__t * __p12); + + // sqrt(pi / 2) + const double __spi_2 = 1.2533141373155002512078826424055226L; + const double __a1 = __param._M_a1; + const double __a12 = __a1 + __param._M_s2 * __spi_2; + const double __a123 = __param._M_a123; + const double __s1s = __param._M_s1 * __param._M_s1; + const double __s2s = __param._M_s2 * __param._M_s2; + + bool __reject; + do + { + const double __u = __param._M_s * __aurng(); + + double __v; + + if (__u <= __a1) + { + const double __n = _M_nd(__urng); + const double __y = __param._M_s1 * std::abs(__n); + __reject = __y >= __param._M_d1; + if (!__reject) + { + const double __e = -std::log(1.0 - __aurng()); + __x = std::floor(__y); + __v = -__e - __n * __n / 2 + __param._M_c; + } + } + else if (__u <= __a12) + { + const double __n = _M_nd(__urng); + const double __y = __param._M_s2 * std::abs(__n); + __reject = __y >= __param._M_d2; + if (!__reject) + { + const double __e = -std::log(1.0 - __aurng()); + __x = std::floor(-__y); + __v = -__e - __n * __n / 2; + } + } + else if (__u <= __a123) + { + const double __e1 = -std::log(1.0 - __aurng()); + const double __e2 = -std::log(1.0 - __aurng()); + + const double __y = __param._M_d1 + + 2 * __s1s * __e1 / __param._M_d1; + __x = std::floor(__y); + __v = (-__e2 + __param._M_d1 * (1 / (__t - __np) + -__y / (2 * __s1s))); + __reject = false; + } + else + { + const double __e1 = -std::log(1.0 - __aurng()); + const double __e2 = -std::log(1.0 - __aurng()); + + const double __y = __param._M_d2 + + 2 * __s2s * __e1 / __param._M_d2; + __x = std::floor(-__y); + __v = -__e2 - __param._M_d2 * __y / (2 * __s2s); + __reject = false; + } + + __reject = __reject || __x < -__np || __x > __t - __np; + if (!__reject) + { + const double __lfx = + std::lgamma(__np + __x + 1) + + std::lgamma(__t - (__np + __x) + 1); + __reject = __v > __param._M_lf - __lfx + + __x * __param._M_lp1p; + } + + __reject |= __x + __np >= __thr; + } + while (__reject); + + __x += __np + __naf; + + const _IntType __z = _M_waiting(__urng, __t - _IntType(__x), + __param._M_q); + __ret = _IntType(__x) + __z; + } + else +#endif + __ret = _M_waiting(__urng, __t, __param._M_q); + + if (__p12 != __p) + __ret = __t - __ret; + return __ret; + } + + template + template + void + binomial_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // We could duplicate everything from operator()... + while (__f != __t) + *__f++ = this->operator()(__urng, __param); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const binomial_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits::max_digits10); + + __os << __x.t() << __space << __x.p() + << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + binomial_distribution<_IntType>& __x) + { + using param_type = typename binomial_distribution<_IntType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _IntType __t; + double __p; + if (__is >> __t >> __p >> __x._M_nd) + __x.param(param_type(__t, __p)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + std::exponential_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + while (__f != __t) + *__f++ = -std::log(result_type(1) - __aurng()) / __p.lambda(); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const exponential_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__os.widen(' ')); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.lambda(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + exponential_distribution<_RealType>& __x) + { + using param_type + = typename exponential_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __lambda; + if (__is >> __lambda) + __x.param(param_type(__lambda)); + + __is.flags(__flags); + return __is; + } + + + /** + * Polar method due to Marsaglia. + * + * Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, + * New York, 1986, Ch. V, Sect. 4.4. + */ + template + template + typename normal_distribution<_RealType>::result_type + normal_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + result_type __ret; + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + if (_M_saved_available) + { + _M_saved_available = false; + __ret = _M_saved; + } + else + { + result_type __x, __y, __r2; + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + _M_saved = __x * __mult; + _M_saved_available = true; + __ret = __y * __mult; + } + + __ret = __ret * __param.stddev() + __param.mean(); + return __ret; + } + + template + template + void + normal_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + + if (__f == __t) + return; + + if (_M_saved_available) + { + _M_saved_available = false; + *__f++ = _M_saved * __param.stddev() + __param.mean(); + + if (__f == __t) + return; + } + + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + while (__f + 1 < __t) + { + result_type __x, __y, __r2; + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + *__f++ = __y * __mult * __param.stddev() + __param.mean(); + *__f++ = __x * __mult * __param.stddev() + __param.mean(); + } + + if (__f != __t) + { + result_type __x, __y, __r2; + do + { + __x = result_type(2.0) * __aurng() - 1.0; + __y = result_type(2.0) * __aurng() - 1.0; + __r2 = __x * __x + __y * __y; + } + while (__r2 > 1.0 || __r2 == 0.0); + + const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); + _M_saved = __x * __mult; + _M_saved_available = true; + *__f = __y * __mult * __param.stddev() + __param.mean(); + } + } + + template + bool + operator==(const std::normal_distribution<_RealType>& __d1, + const std::normal_distribution<_RealType>& __d2) + { + if (__d1._M_param == __d2._M_param + && __d1._M_saved_available == __d2._M_saved_available) + { + if (__d1._M_saved_available + && __d1._M_saved == __d2._M_saved) + return true; + else if(!__d1._M_saved_available) + return true; + else + return false; + } + else + return false; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const normal_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.mean() << __space << __x.stddev() + << __space << __x._M_saved_available; + if (__x._M_saved_available) + __os << __space << __x._M_saved; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + normal_distribution<_RealType>& __x) + { + using param_type = typename normal_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + double __mean, __stddev; + bool __saved_avail; + if (__is >> __mean >> __stddev >> __saved_avail) + { + if (__saved_avail && (__is >> __x._M_saved)) + { + __x._M_saved_available = __saved_avail; + __x.param(param_type(__mean, __stddev)); + } + } + + __is.flags(__flags); + return __is; + } + + + template + template + void + lognormal_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = std::exp(__p.s() * _M_nd(__urng) + __p.m()); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const lognormal_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.m() << __space << __x.s() + << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + lognormal_distribution<_RealType>& __x) + { + using param_type + = typename lognormal_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __m, __s; + if (__is >> __m >> __s >> __x._M_nd) + __x.param(param_type(__m, __s)); + + __is.flags(__flags); + return __is; + } + + template + template + void + std::chi_squared_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = 2 * _M_gd(__urng); + } + + template + template + void + std::chi_squared_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const typename + std::gamma_distribution::param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = 2 * _M_gd(__urng, __p); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const chi_squared_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.n() << __space << __x._M_gd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + chi_squared_distribution<_RealType>& __x) + { + using param_type + = typename chi_squared_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __n; + if (__is >> __n >> __x._M_gd) + __x.param(param_type(__n)); + + __is.flags(__flags); + return __is; + } + + + template + template + typename cauchy_distribution<_RealType>::result_type + cauchy_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + _RealType __u; + do + __u = __aurng(); + while (__u == 0.5); + + const _RealType __pi = 3.1415926535897932384626433832795029L; + return __p.a() + __p.b() * std::tan(__pi * __u); + } + + template + template + void + cauchy_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + const _RealType __pi = 3.1415926535897932384626433832795029L; + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + while (__f != __t) + { + _RealType __u; + do + __u = __aurng(); + while (__u == 0.5); + + *__f++ = __p.a() + __p.b() * std::tan(__pi * __u); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const cauchy_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + cauchy_distribution<_RealType>& __x) + { + using param_type = typename cauchy_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + std::fisher_f_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = ((_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m())); + } + + template + template + void + std::fisher_f_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typedef typename std::gamma_distribution::param_type + param_type; + param_type __p1(__p.m() / 2); + param_type __p2(__p.n() / 2); + while (__f != __t) + *__f++ = ((_M_gd_x(__urng, __p1) * n()) + / (_M_gd_y(__urng, __p2) * m())); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const fisher_f_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.m() << __space << __x.n() + << __space << __x._M_gd_x << __space << __x._M_gd_y; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + fisher_f_distribution<_RealType>& __x) + { + using param_type + = typename fisher_f_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __m, __n; + if (__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y) + __x.param(param_type(__m, __n)); + + __is.flags(__flags); + return __is; + } + + + template + template + void + std::student_t_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + while (__f != __t) + *__f++ = _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); + } + + template + template + void + std::student_t_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typename std::gamma_distribution::param_type + __p2(__p.n() / 2, 2); + while (__f != __t) + *__f++ = _M_nd(__urng) * std::sqrt(__p.n() / _M_gd(__urng, __p2)); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const student_t_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.n() << __space << __x._M_nd << __space << __x._M_gd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + student_t_distribution<_RealType>& __x) + { + using param_type + = typename student_t_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __n; + if (__is >> __n >> __x._M_nd >> __x._M_gd) + __x.param(param_type(__n)); + + __is.flags(__flags); + return __is; + } + + + template + void + gamma_distribution<_RealType>::param_type:: + _M_initialize() + { + _M_malpha = _M_alpha < 1.0 ? _M_alpha + _RealType(1.0) : _M_alpha; + + const _RealType __a1 = _M_malpha - _RealType(1.0) / _RealType(3.0); + _M_a2 = _RealType(1.0) / std::sqrt(_RealType(9.0) * __a1); + } + + /** + * Marsaglia, G. and Tsang, W. W. + * "A Simple Method for Generating Gamma Variables" + * ACM Transactions on Mathematical Software, 26, 3, 363-372, 2000. + */ + template + template + typename gamma_distribution<_RealType>::result_type + gamma_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + result_type __u, __v, __n; + const result_type __a1 = (__param._M_malpha + - _RealType(1.0) / _RealType(3.0)); + + do + { + do + { + __n = _M_nd(__urng); + __v = result_type(1.0) + __param._M_a2 * __n; + } + while (__v <= 0.0); + + __v = __v * __v * __v; + __u = __aurng(); + } + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n + && (std::log(__u) > (0.5 * __n * __n + __a1 + * (1.0 - __v + std::log(__v))))); + + if (__param.alpha() == __param._M_malpha) + return __a1 * __v * __param.beta(); + else + { + do + __u = __aurng(); + while (__u == 0.0); + + return (std::pow(__u, result_type(1.0) / __param.alpha()) + * __a1 * __v * __param.beta()); + } + } + + template + template + void + gamma_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + result_type __u, __v, __n; + const result_type __a1 = (__param._M_malpha + - _RealType(1.0) / _RealType(3.0)); + + if (__param.alpha() == __param._M_malpha) + while (__f != __t) + { + do + { + do + { + __n = _M_nd(__urng); + __v = result_type(1.0) + __param._M_a2 * __n; + } + while (__v <= 0.0); + + __v = __v * __v * __v; + __u = __aurng(); + } + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n + && (std::log(__u) > (0.5 * __n * __n + __a1 + * (1.0 - __v + std::log(__v))))); + + *__f++ = __a1 * __v * __param.beta(); + } + else + while (__f != __t) + { + do + { + do + { + __n = _M_nd(__urng); + __v = result_type(1.0) + __param._M_a2 * __n; + } + while (__v <= 0.0); + + __v = __v * __v * __v; + __u = __aurng(); + } + while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n + && (std::log(__u) > (0.5 * __n * __n + __a1 + * (1.0 - __v + std::log(__v))))); + + do + __u = __aurng(); + while (__u == 0.0); + + *__f++ = (std::pow(__u, result_type(1.0) / __param.alpha()) + * __a1 * __v * __param.beta()); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const gamma_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.alpha() << __space << __x.beta() + << __space << __x._M_nd; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + gamma_distribution<_RealType>& __x) + { + using param_type = typename gamma_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __alpha_val, __beta_val; + if (__is >> __alpha_val >> __beta_val >> __x._M_nd) + __x.param(param_type(__alpha_val, __beta_val)); + + __is.flags(__flags); + return __is; + } + + + template + template + typename weibull_distribution<_RealType>::result_type + weibull_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return __p.b() * std::pow(-std::log(result_type(1) - __aurng()), + result_type(1) / __p.a()); + } + + template + template + void + weibull_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + auto __inv_a = result_type(1) / __p.a(); + + while (__f != __t) + *__f++ = __p.b() * std::pow(-std::log(result_type(1) - __aurng()), + __inv_a); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const weibull_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + weibull_distribution<_RealType>& __x) + { + using param_type = typename weibull_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + template + typename extreme_value_distribution<_RealType>::result_type + extreme_value_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + return __p.a() - __p.b() * std::log(-std::log(result_type(1) + - __aurng())); + } + + template + template + void + extreme_value_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __p) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> + __aurng(__urng); + + while (__f != __t) + *__f++ = __p.a() - __p.b() * std::log(-std::log(result_type(1) + - __aurng())); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const extreme_value_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + __os << __x.a() << __space << __x.b(); + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + extreme_value_distribution<_RealType>& __x) + { + using param_type + = typename extreme_value_distribution<_RealType>::param_type; + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + _RealType __a, __b; + if (__is >> __a >> __b) + __x.param(param_type(__a, __b)); + + __is.flags(__flags); + return __is; + } + + + template + void + discrete_distribution<_IntType>::param_type:: + _M_initialize() + { + if (_M_prob.size() < 2) + { + _M_prob.clear(); + return; + } + + const double __sum = std::accumulate(_M_prob.begin(), + _M_prob.end(), 0.0); + __glibcxx_assert(__sum > 0); + // Now normalize the probabilites. + __detail::__normalize(_M_prob.begin(), _M_prob.end(), _M_prob.begin(), + __sum); + // Accumulate partial sums. + _M_cp.reserve(_M_prob.size()); + std::partial_sum(_M_prob.begin(), _M_prob.end(), + std::back_inserter(_M_cp)); + // Make sure the last cumulative probability is one. + _M_cp[_M_cp.size() - 1] = 1.0; + } + + template + template + discrete_distribution<_IntType>::param_type:: + param_type(size_t __nw, double __xmin, double __xmax, _Func __fw) + : _M_prob(), _M_cp() + { + const size_t __n = __nw == 0 ? 1 : __nw; + const double __delta = (__xmax - __xmin) / __n; + + _M_prob.reserve(__n); + for (size_t __k = 0; __k < __nw; ++__k) + _M_prob.push_back(__fw(__xmin + __k * __delta + 0.5 * __delta)); + + _M_initialize(); + } + + template + template + typename discrete_distribution<_IntType>::result_type + discrete_distribution<_IntType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + if (__param._M_cp.empty()) + return result_type(0); + + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + const double __p = __aurng(); + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + + return __pos - __param._M_cp.begin(); + } + + template + template + void + discrete_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + + if (__param._M_cp.empty()) + { + while (__f != __t) + *__f++ = result_type(0); + return; + } + + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + while (__f != __t) + { + const double __p = __aurng(); + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + + *__f++ = __pos - __param._M_cp.begin(); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const discrete_distribution<_IntType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits::max_digits10); + + std::vector __prob = __x.probabilities(); + __os << __prob.size(); + for (auto __dit = __prob.begin(); __dit != __prob.end(); ++__dit) + __os << __space << *__dit; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + +namespace __detail +{ + template + basic_istream<_CharT, _Traits>& + __extract_params(basic_istream<_CharT, _Traits>& __is, + vector<_ValT>& __vals, size_t __n) + { + __vals.reserve(__n); + while (__n--) + { + _ValT __val; + if (__is >> __val) + __vals.push_back(__val); + else + break; + } + return __is; + } +} // namespace __detail + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + discrete_distribution<_IntType>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + size_t __n; + if (__is >> __n) + { + std::vector __prob_vec; + if (__detail::__extract_params(__is, __prob_vec, __n)) + __x.param({__prob_vec.begin(), __prob_vec.end()}); + } + + __is.flags(__flags); + return __is; + } + + + template + void + piecewise_constant_distribution<_RealType>::param_type:: + _M_initialize() + { + if (_M_int.size() < 2 + || (_M_int.size() == 2 + && _M_int[0] == _RealType(0) + && _M_int[1] == _RealType(1))) + { + _M_int.clear(); + _M_den.clear(); + return; + } + + const double __sum = std::accumulate(_M_den.begin(), + _M_den.end(), 0.0); + __glibcxx_assert(__sum > 0); + + __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(), + __sum); + + _M_cp.reserve(_M_den.size()); + std::partial_sum(_M_den.begin(), _M_den.end(), + std::back_inserter(_M_cp)); + + // Make sure the last cumulative probability is one. + _M_cp[_M_cp.size() - 1] = 1.0; + + for (size_t __k = 0; __k < _M_den.size(); ++__k) + _M_den[__k] /= _M_int[__k + 1] - _M_int[__k]; + } + + template + template + piecewise_constant_distribution<_RealType>::param_type:: + param_type(_InputIteratorB __bbegin, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_int(), _M_den(), _M_cp() + { + if (__bbegin != __bend) + { + for (;;) + { + _M_int.push_back(*__bbegin); + ++__bbegin; + if (__bbegin == __bend) + break; + + _M_den.push_back(*__wbegin); + ++__wbegin; + } + } + + _M_initialize(); + } + + template + template + piecewise_constant_distribution<_RealType>::param_type:: + param_type(initializer_list<_RealType> __bl, _Func __fw) + : _M_int(), _M_den(), _M_cp() + { + _M_int.reserve(__bl.size()); + for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter) + _M_int.push_back(*__biter); + + _M_den.reserve(_M_int.size() - 1); + for (size_t __k = 0; __k < _M_int.size() - 1; ++__k) + _M_den.push_back(__fw(0.5 * (_M_int[__k + 1] + _M_int[__k]))); + + _M_initialize(); + } + + template + template + piecewise_constant_distribution<_RealType>::param_type:: + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw) + : _M_int(), _M_den(), _M_cp() + { + const size_t __n = __nw == 0 ? 1 : __nw; + const _RealType __delta = (__xmax - __xmin) / __n; + + _M_int.reserve(__n + 1); + for (size_t __k = 0; __k <= __nw; ++__k) + _M_int.push_back(__xmin + __k * __delta); + + _M_den.reserve(__n); + for (size_t __k = 0; __k < __nw; ++__k) + _M_den.push_back(__fw(_M_int[__k] + 0.5 * __delta)); + + _M_initialize(); + } + + template + template + typename piecewise_constant_distribution<_RealType>::result_type + piecewise_constant_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + const double __p = __aurng(); + if (__param._M_cp.empty()) + return __p; + + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + const size_t __i = __pos - __param._M_cp.begin(); + + const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0; + + return __param._M_int[__i] + (__p - __pref) / __param._M_den[__i]; + } + + template + template + void + piecewise_constant_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + if (__param._M_cp.empty()) + { + while (__f != __t) + *__f++ = __aurng(); + return; + } + + while (__f != __t) + { + const double __p = __aurng(); + + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + const size_t __i = __pos - __param._M_cp.begin(); + + const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0; + + *__f++ = (__param._M_int[__i] + + (__p - __pref) / __param._M_den[__i]); + } + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const piecewise_constant_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + std::vector<_RealType> __int = __x.intervals(); + __os << __int.size() - 1; + + for (auto __xit = __int.begin(); __xit != __int.end(); ++__xit) + __os << __space << *__xit; + + std::vector __den = __x.densities(); + for (auto __dit = __den.begin(); __dit != __den.end(); ++__dit) + __os << __space << *__dit; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + piecewise_constant_distribution<_RealType>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + size_t __n; + if (__is >> __n) + { + std::vector<_RealType> __int_vec; + if (__detail::__extract_params(__is, __int_vec, __n + 1)) + { + std::vector __den_vec; + if (__detail::__extract_params(__is, __den_vec, __n)) + { + __x.param({ __int_vec.begin(), __int_vec.end(), + __den_vec.begin() }); + } + } + } + + __is.flags(__flags); + return __is; + } + + + template + void + piecewise_linear_distribution<_RealType>::param_type:: + _M_initialize() + { + if (_M_int.size() < 2 + || (_M_int.size() == 2 + && _M_int[0] == _RealType(0) + && _M_int[1] == _RealType(1) + && _M_den[0] == _M_den[1])) + { + _M_int.clear(); + _M_den.clear(); + return; + } + + double __sum = 0.0; + _M_cp.reserve(_M_int.size() - 1); + _M_m.reserve(_M_int.size() - 1); + for (size_t __k = 0; __k < _M_int.size() - 1; ++__k) + { + const _RealType __delta = _M_int[__k + 1] - _M_int[__k]; + __sum += 0.5 * (_M_den[__k + 1] + _M_den[__k]) * __delta; + _M_cp.push_back(__sum); + _M_m.push_back((_M_den[__k + 1] - _M_den[__k]) / __delta); + } + __glibcxx_assert(__sum > 0); + + // Now normalize the densities... + __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(), + __sum); + // ... and partial sums... + __detail::__normalize(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __sum); + // ... and slopes. + __detail::__normalize(_M_m.begin(), _M_m.end(), _M_m.begin(), __sum); + + // Make sure the last cumulative probablility is one. + _M_cp[_M_cp.size() - 1] = 1.0; + } + + template + template + piecewise_linear_distribution<_RealType>::param_type:: + param_type(_InputIteratorB __bbegin, + _InputIteratorB __bend, + _InputIteratorW __wbegin) + : _M_int(), _M_den(), _M_cp(), _M_m() + { + for (; __bbegin != __bend; ++__bbegin, ++__wbegin) + { + _M_int.push_back(*__bbegin); + _M_den.push_back(*__wbegin); + } + + _M_initialize(); + } + + template + template + piecewise_linear_distribution<_RealType>::param_type:: + param_type(initializer_list<_RealType> __bl, _Func __fw) + : _M_int(), _M_den(), _M_cp(), _M_m() + { + _M_int.reserve(__bl.size()); + _M_den.reserve(__bl.size()); + for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter) + { + _M_int.push_back(*__biter); + _M_den.push_back(__fw(*__biter)); + } + + _M_initialize(); + } + + template + template + piecewise_linear_distribution<_RealType>::param_type:: + param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw) + : _M_int(), _M_den(), _M_cp(), _M_m() + { + const size_t __n = __nw == 0 ? 1 : __nw; + const _RealType __delta = (__xmax - __xmin) / __n; + + _M_int.reserve(__n + 1); + _M_den.reserve(__n + 1); + for (size_t __k = 0; __k <= __nw; ++__k) + { + _M_int.push_back(__xmin + __k * __delta); + _M_den.push_back(__fw(_M_int[__k] + __delta)); + } + + _M_initialize(); + } + + template + template + typename piecewise_linear_distribution<_RealType>::result_type + piecewise_linear_distribution<_RealType>:: + operator()(_UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __detail::_Adaptor<_UniformRandomNumberGenerator, double> + __aurng(__urng); + + const double __p = __aurng(); + if (__param._M_cp.empty()) + return __p; + + auto __pos = std::lower_bound(__param._M_cp.begin(), + __param._M_cp.end(), __p); + const size_t __i = __pos - __param._M_cp.begin(); + + const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0; + + const double __a = 0.5 * __param._M_m[__i]; + const double __b = __param._M_den[__i]; + const double __cm = __p - __pref; + + _RealType __x = __param._M_int[__i]; + if (__a == 0) + __x += __cm / __b; + else + { + const double __d = __b * __b + 4.0 * __a * __cm; + __x += 0.5 * (std::sqrt(__d) - __b) / __a; + } + + return __x; + } + + template + template + void + piecewise_linear_distribution<_RealType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomNumberGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + // We could duplicate everything from operator()... + while (__f != __t) + *__f++ = this->operator()(__urng, __param); + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const piecewise_linear_distribution<_RealType>& __x) + { + using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __os.flags(); + const _CharT __fill = __os.fill(); + const std::streamsize __precision = __os.precision(); + const _CharT __space = __os.widen(' '); + __os.flags(__ios_base::scientific | __ios_base::left); + __os.fill(__space); + __os.precision(std::numeric_limits<_RealType>::max_digits10); + + std::vector<_RealType> __int = __x.intervals(); + __os << __int.size() - 1; + + for (auto __xit = __int.begin(); __xit != __int.end(); ++__xit) + __os << __space << *__xit; + + std::vector __den = __x.densities(); + for (auto __dit = __den.begin(); __dit != __den.end(); ++__dit) + __os << __space << *__dit; + + __os.flags(__flags); + __os.fill(__fill); + __os.precision(__precision); + return __os; + } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, + piecewise_linear_distribution<_RealType>& __x) + { + using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base; + + const typename __ios_base::fmtflags __flags = __is.flags(); + __is.flags(__ios_base::dec | __ios_base::skipws); + + size_t __n; + if (__is >> __n) + { + vector<_RealType> __int_vec; + if (__detail::__extract_params(__is, __int_vec, __n + 1)) + { + vector __den_vec; + if (__detail::__extract_params(__is, __den_vec, __n + 1)) + { + __x.param({ __int_vec.begin(), __int_vec.end(), + __den_vec.begin() }); + } + } + } + __is.flags(__flags); + return __is; + } + + + template + seed_seq::seed_seq(std::initializer_list<_IntType> __il) + { + for (auto __iter = __il.begin(); __iter != __il.end(); ++__iter) + _M_v.push_back(__detail::__mod::__value>(*__iter)); + } + + template + seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end) + { + for (_InputIterator __iter = __begin; __iter != __end; ++__iter) + _M_v.push_back(__detail::__mod::__value>(*__iter)); + } + + template + void + seed_seq::generate(_RandomAccessIterator __begin, + _RandomAccessIterator __end) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _Type; + + if (__begin == __end) + return; + + std::fill(__begin, __end, _Type(0x8b8b8b8bu)); + + const size_t __n = __end - __begin; + const size_t __s = _M_v.size(); + const size_t __t = (__n >= 623) ? 11 + : (__n >= 68) ? 7 + : (__n >= 39) ? 5 + : (__n >= 7) ? 3 + : (__n - 1) / 2; + const size_t __p = (__n - __t) / 2; + const size_t __q = __p + __t; + const size_t __m = std::max(size_t(__s + 1), __n); + +#ifndef __UINT32_TYPE__ + struct _Up + { + _Up(uint_least32_t v) : _M_v(v & 0xffffffffu) { } + + operator uint_least32_t() const { return _M_v; } + + uint_least32_t _M_v; + }; + using uint32_t = _Up; +#endif + + // k == 0, every element in [begin,end) equals 0x8b8b8b8bu + { + uint32_t __r1 = 1371501266u; + uint32_t __r2 = __r1 + __s; + __begin[__p] += __r1; + __begin[__q] = (uint32_t)__begin[__q] + __r2; + __begin[0] = __r2; + } + + for (size_t __k = 1; __k <= __s; ++__k) + { + const size_t __kn = __k % __n; + const size_t __kpn = (__k + __p) % __n; + const size_t __kqn = (__k + __q) % __n; + uint32_t __arg = (__begin[__kn] + ^ __begin[__kpn] + ^ __begin[(__k - 1) % __n]); + uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27)); + uint32_t __r2 = __r1 + (uint32_t)__kn + _M_v[__k - 1]; + __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1; + __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2; + __begin[__kn] = __r2; + } + + for (size_t __k = __s + 1; __k < __m; ++__k) + { + const size_t __kn = __k % __n; + const size_t __kpn = (__k + __p) % __n; + const size_t __kqn = (__k + __q) % __n; + uint32_t __arg = (__begin[__kn] + ^ __begin[__kpn] + ^ __begin[(__k - 1) % __n]); + uint32_t __r1 = 1664525u * (__arg ^ (__arg >> 27)); + uint32_t __r2 = __r1 + (uint32_t)__kn; + __begin[__kpn] = (uint32_t)__begin[__kpn] + __r1; + __begin[__kqn] = (uint32_t)__begin[__kqn] + __r2; + __begin[__kn] = __r2; + } + + for (size_t __k = __m; __k < __m + __n; ++__k) + { + const size_t __kn = __k % __n; + const size_t __kpn = (__k + __p) % __n; + const size_t __kqn = (__k + __q) % __n; + uint32_t __arg = (__begin[__kn] + + __begin[__kpn] + + __begin[(__k - 1) % __n]); + uint32_t __r3 = 1566083941u * (__arg ^ (__arg >> 27)); + uint32_t __r4 = __r3 - __kn; + __begin[__kpn] ^= __r3; + __begin[__kqn] ^= __r4; + __begin[__kn] = __r4; + } + } + + template + _RealType + generate_canonical(_UniformRandomNumberGenerator& __urng) + { + static_assert(std::is_floating_point<_RealType>::value, + "template argument must be a floating point type"); + + const size_t __b + = std::min(static_cast(std::numeric_limits<_RealType>::digits), + __bits); + const long double __r = static_cast(__urng.max()) + - static_cast(__urng.min()) + 1.0L; + const size_t __log2r = std::log(__r) / std::log(2.0L); + const size_t __m = std::max(1UL, + (__b + __log2r - 1UL) / __log2r); + _RealType __ret; + _RealType __sum = _RealType(0); + _RealType __tmp = _RealType(1); + for (size_t __k = __m; __k != 0; --__k) + { + __sum += _RealType(__urng() - __urng.min()) * __tmp; + __tmp *= __r; + } + __ret = __sum / __tmp; + if (__builtin_expect(__ret >= _RealType(1), 0)) + { +#if _GLIBCXX_USE_C99_MATH_TR1 + __ret = std::nextafter(_RealType(1), _RealType(0)); +#else + __ret = _RealType(1) + - std::numeric_limits<_RealType>::epsilon() / _RealType(2); +#endif + } + return __ret; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/range_access.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/range_access.h new file mode 100755 index 0000000..71ad28c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/range_access.h @@ -0,0 +1,345 @@ +// Range access functions for containers -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/range_access.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _GLIBCXX_RANGE_ACCESS_H +#define _GLIBCXX_RANGE_ACCESS_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +#include +#include // common_type_t, make_signed_t +#include // reverse_iterator + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Return an iterator pointing to the first element of + * the container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + begin(_Container& __cont) -> decltype(__cont.begin()) + { return __cont.begin(); } + + /** + * @brief Return an iterator pointing to the first element of + * the const container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + begin(const _Container& __cont) -> decltype(__cont.begin()) + { return __cont.begin(); } + + /** + * @brief Return an iterator pointing to one past the last element of + * the container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + end(_Container& __cont) -> decltype(__cont.end()) + { return __cont.end(); } + + /** + * @brief Return an iterator pointing to one past the last element of + * the const container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + end(const _Container& __cont) -> decltype(__cont.end()) + { return __cont.end(); } + + /** + * @brief Return an iterator pointing to the first element of the array. + * @param __arr Array. + */ + template + inline _GLIBCXX14_CONSTEXPR _Tp* + begin(_Tp (&__arr)[_Nm]) noexcept + { return __arr; } + + /** + * @brief Return an iterator pointing to one past the last element + * of the array. + * @param __arr Array. + */ + template + inline _GLIBCXX14_CONSTEXPR _Tp* + end(_Tp (&__arr)[_Nm]) noexcept + { return __arr + _Nm; } + +#if __cplusplus >= 201402L + + template class valarray; + // These overloads must be declared for cbegin and cend to use them. + template _Tp* begin(valarray<_Tp>&); + template const _Tp* begin(const valarray<_Tp>&); + template _Tp* end(valarray<_Tp>&); + template const _Tp* end(const valarray<_Tp>&); + + /** + * @brief Return an iterator pointing to the first element of + * the const container. + * @param __cont Container. + */ + template + inline constexpr auto + cbegin(const _Container& __cont) noexcept(noexcept(std::begin(__cont))) + -> decltype(std::begin(__cont)) + { return std::begin(__cont); } + + /** + * @brief Return an iterator pointing to one past the last element of + * the const container. + * @param __cont Container. + */ + template + inline constexpr auto + cend(const _Container& __cont) noexcept(noexcept(std::end(__cont))) + -> decltype(std::end(__cont)) + { return std::end(__cont); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + rbegin(_Container& __cont) -> decltype(__cont.rbegin()) + { return __cont.rbegin(); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the const container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + rbegin(const _Container& __cont) -> decltype(__cont.rbegin()) + { return __cont.rbegin(); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + rend(_Container& __cont) -> decltype(__cont.rend()) + { return __cont.rend(); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the const container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + rend(const _Container& __cont) -> decltype(__cont.rend()) + { return __cont.rend(); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the array. + * @param __arr Array. + */ + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*> + rbegin(_Tp (&__arr)[_Nm]) noexcept + { return reverse_iterator<_Tp*>(__arr + _Nm); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the array. + * @param __arr Array. + */ + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Tp*> + rend(_Tp (&__arr)[_Nm]) noexcept + { return reverse_iterator<_Tp*>(__arr); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the initializer_list. + * @param __il initializer_list. + */ + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator + rbegin(initializer_list<_Tp> __il) noexcept + { return reverse_iterator(__il.end()); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the initializer_list. + * @param __il initializer_list. + */ + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator + rend(initializer_list<_Tp> __il) noexcept + { return reverse_iterator(__il.begin()); } + + /** + * @brief Return a reverse iterator pointing to the last element of + * the const container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + crbegin(const _Container& __cont) -> decltype(std::rbegin(__cont)) + { return std::rbegin(__cont); } + + /** + * @brief Return a reverse iterator pointing one past the first element of + * the const container. + * @param __cont Container. + */ + template + inline _GLIBCXX17_CONSTEXPR auto + crend(const _Container& __cont) -> decltype(std::rend(__cont)) + { return std::rend(__cont); } + +#endif // C++14 + +#if __cplusplus >= 201703L +#define __cpp_lib_nonmember_container_access 201411 + + /** + * @brief Return the size of a container. + * @param __cont Container. + */ + template + constexpr auto + size(const _Container& __cont) noexcept(noexcept(__cont.size())) + -> decltype(__cont.size()) + { return __cont.size(); } + + /** + * @brief Return the size of an array. + */ + template + constexpr size_t + size(const _Tp (&)[_Nm]) noexcept + { return _Nm; } + + /** + * @brief Return whether a container is empty. + * @param __cont Container. + */ + template + [[nodiscard]] constexpr auto + empty(const _Container& __cont) noexcept(noexcept(__cont.empty())) + -> decltype(__cont.empty()) + { return __cont.empty(); } + + /** + * @brief Return whether an array is empty (always false). + */ + template + [[nodiscard]] constexpr bool + empty(const _Tp (&)[_Nm]) noexcept + { return false; } + + /** + * @brief Return whether an initializer_list is empty. + * @param __il Initializer list. + */ + template + [[nodiscard]] constexpr bool + empty(initializer_list<_Tp> __il) noexcept + { return __il.size() == 0;} + + /** + * @brief Return the data pointer of a container. + * @param __cont Container. + */ + template + constexpr auto + data(_Container& __cont) noexcept(noexcept(__cont.data())) + -> decltype(__cont.data()) + { return __cont.data(); } + + /** + * @brief Return the data pointer of a const container. + * @param __cont Container. + */ + template + constexpr auto + data(const _Container& __cont) noexcept(noexcept(__cont.data())) + -> decltype(__cont.data()) + { return __cont.data(); } + + /** + * @brief Return the data pointer of an array. + * @param __array Array. + */ + template + constexpr _Tp* + data(_Tp (&__array)[_Nm]) noexcept + { return __array; } + + /** + * @brief Return the data pointer of an initializer list. + * @param __il Initializer list. + */ + template + constexpr const _Tp* + data(initializer_list<_Tp> __il) noexcept + { return __il.begin(); } + +#if __cplusplus > 201703L +#define __cpp_lib_ssize 201902L + template + constexpr auto + ssize(const _Container& __cont) + noexcept(noexcept(__cont.size())) + -> common_type_t> + { + using type = make_signed_t; + return static_cast>(__cont.size()); + } + + template + constexpr ptrdiff_t + ssize(const _Tp (&)[_Num]) noexcept + { return _Num; } +#endif // C++20 + +#endif // C++17 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 +#endif // _GLIBCXX_RANGE_ACCESS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_algo.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_algo.h new file mode 100755 index 0000000..8462521 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_algo.h @@ -0,0 +1,3651 @@ +// Core algorithmic facilities -*- C++ -*- + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ranges_algo.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _RANGES_ALGO_H +#define _RANGES_ALGO_H 1 + +#if __cplusplus > 201703L + +#include +#include +#include // concept uniform_random_bit_generator + +#if __cpp_lib_concepts +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace ranges +{ + namespace __detail + { + template + constexpr auto + __make_comp_proj(_Comp& __comp, _Proj& __proj) + { + return [&] (auto&& __lhs, auto&& __rhs) -> bool { + using _TL = decltype(__lhs); + using _TR = decltype(__rhs); + return std::__invoke(__comp, + std::__invoke(__proj, std::forward<_TL>(__lhs)), + std::__invoke(__proj, std::forward<_TR>(__rhs))); + }; + } + + template + constexpr auto + __make_pred_proj(_Pred& __pred, _Proj& __proj) + { + return [&] (_Tp&& __arg) -> bool { + return std::__invoke(__pred, + std::__invoke(__proj, std::forward<_Tp>(__arg))); + }; + } + } // namespace __detail + + struct __all_of_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr bool + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (!(bool)std::__invoke(__pred, std::__invoke(__proj, *__first))) + return false; + return true; + } + + template, _Proj>> + _Pred> + constexpr bool + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __all_of_fn all_of{}; + + struct __any_of_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr bool + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + return true; + return false; + } + + template, _Proj>> + _Pred> + constexpr bool + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __any_of_fn any_of{}; + + struct __none_of_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr bool + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + return false; + return true; + } + + template, _Proj>> + _Pred> + constexpr bool + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __none_of_fn none_of{}; + + template + struct in_fun_result + { + [[no_unique_address]] _Iter in; + [[no_unique_address]] _Fp fun; + + template + requires convertible_to + && convertible_to + constexpr + operator in_fun_result<_Iter2, _F2p>() const & + { return {in, fun}; } + + template + requires convertible_to<_Iter, _Iter2> && convertible_to<_Fp, _F2p> + constexpr + operator in_fun_result<_Iter2, _F2p>() && + { return {std::move(in), std::move(fun)}; } + }; + + template + using for_each_result = in_fun_result<_Iter, _Fp>; + + struct __for_each_fn + { + template _Sent, + typename _Proj = identity, + indirectly_unary_invocable> _Fun> + constexpr for_each_result<_Iter, _Fun> + operator()(_Iter __first, _Sent __last, _Fun __f, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + std::__invoke(__f, std::__invoke(__proj, *__first)); + return { std::move(__first), std::move(__f) }; + } + + template, _Proj>> + _Fun> + constexpr for_each_result, _Fun> + operator()(_Range&& __r, _Fun __f, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__f), std::move(__proj)); + } + }; + + inline constexpr __for_each_fn for_each{}; + + template + using for_each_n_result = in_fun_result<_Iter, _Fp>; + + struct __for_each_n_fn + { + template> _Fun> + constexpr for_each_n_result<_Iter, _Fun> + operator()(_Iter __first, iter_difference_t<_Iter> __n, + _Fun __f, _Proj __proj = {}) const + { + if constexpr (random_access_iterator<_Iter>) + { + if (__n <= 0) + return {std::move(__first), std::move(__f)}; + auto __last = __first + __n; + return ranges::for_each(std::move(__first), std::move(__last), + std::move(__f), std::move(__proj)); + } + else + { + while (__n-- > 0) + { + std::__invoke(__f, std::__invoke(__proj, *__first)); + ++__first; + } + return {std::move(__first), std::move(__f)}; + } + } + }; + + inline constexpr __for_each_n_fn for_each_n{}; + + // find, find_if and find_if_not are defined in . + + struct __find_first_of_fn + { + template _Sent1, + forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Pred = ranges::equal_to, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + constexpr _Iter1 + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + for (; __first1 != __last1; ++__first1) + for (auto __iter = __first2; __iter != __last2; ++__iter) + if (std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__iter))) + return __first1; + return __first1; + } + + template + requires indirectly_comparable, iterator_t<_Range2>, + _Pred, _Proj1, _Proj2> + constexpr borrowed_iterator_t<_Range1> + operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __find_first_of_fn find_first_of{}; + + struct __count_fn + { + template _Sent, + typename _Tp, typename _Proj = identity> + requires indirect_binary_predicate, + const _Tp*> + constexpr iter_difference_t<_Iter> + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Proj __proj = {}) const + { + iter_difference_t<_Iter> __n = 0; + for (; __first != __last; ++__first) + if (std::__invoke(__proj, *__first) == __value) + ++__n; + return __n; + } + + template + requires indirect_binary_predicate, _Proj>, + const _Tp*> + constexpr range_difference_t<_Range> + operator()(_Range&& __r, const _Tp& __value, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__proj)); + } + }; + + inline constexpr __count_fn count{}; + + struct __count_if_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr iter_difference_t<_Iter> + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + iter_difference_t<_Iter> __n = 0; + for (; __first != __last; ++__first) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + ++__n; + return __n; + } + + template, _Proj>> + _Pred> + constexpr range_difference_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __count_if_fn count_if{}; + + // in_in_result, mismatch and search are defined in . + + struct __search_n_fn + { + template _Sent, typename _Tp, + typename _Pred = ranges::equal_to, typename _Proj = identity> + requires indirectly_comparable<_Iter, const _Tp*, _Pred, _Proj> + constexpr subrange<_Iter> + operator()(_Iter __first, _Sent __last, iter_difference_t<_Iter> __count, + const _Tp& __value, _Pred __pred = {}, _Proj __proj = {}) const + { + if (__count <= 0) + return {__first, __first}; + + auto __value_comp = [&] (_Rp&& __arg) -> bool { + return std::__invoke(__pred, std::forward<_Rp>(__arg), __value); + }; + if (__count == 1) + { + __first = ranges::find_if(std::move(__first), __last, + std::move(__value_comp), + std::move(__proj)); + if (__first == __last) + return {__first, __first}; + else + { + auto __end = __first; + return {__first, ++__end}; + } + } + + if constexpr (sized_sentinel_for<_Sent, _Iter> + && random_access_iterator<_Iter>) + { + auto __tail_size = __last - __first; + auto __remainder = __count; + + while (__remainder <= __tail_size) + { + __first += __remainder; + __tail_size -= __remainder; + auto __backtrack = __first; + while (__value_comp(std::__invoke(__proj, *--__backtrack))) + { + if (--__remainder == 0) + return {__first - __count, __first}; + } + __remainder = __count + 1 - (__first - __backtrack); + } + auto __i = __first + __tail_size; + return {__i, __i}; + } + else + { + __first = ranges::find_if(__first, __last, __value_comp, __proj); + while (__first != __last) + { + auto __n = __count; + auto __i = __first; + ++__i; + while (__i != __last && __n != 1 + && __value_comp(std::__invoke(__proj, *__i))) + { + ++__i; + --__n; + } + if (__n == 1) + return {__first, __i}; + if (__i == __last) + return {__i, __i}; + __first = ranges::find_if(++__i, __last, __value_comp, __proj); + } + return {__first, __first}; + } + } + + template + requires indirectly_comparable, const _Tp*, + _Pred, _Proj> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, range_difference_t<_Range> __count, + const _Tp& __value, _Pred __pred = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__count), __value, + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __search_n_fn search_n{}; + + struct __find_end_fn + { + template _Sent1, + forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Pred = ranges::equal_to, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + constexpr subrange<_Iter1> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + if constexpr (bidirectional_iterator<_Iter1> + && bidirectional_iterator<_Iter2>) + { + auto __i1 = ranges::next(__first1, __last1); + auto __i2 = ranges::next(__first2, __last2); + auto __rresult + = ranges::search(reverse_iterator<_Iter1>{__i1}, + reverse_iterator<_Iter1>{__first1}, + reverse_iterator<_Iter2>{__i2}, + reverse_iterator<_Iter2>{__first2}, + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + auto __result_first = ranges::end(__rresult).base(); + auto __result_last = ranges::begin(__rresult).base(); + if (__result_last == __first1) + return {__i1, __i1}; + else + return {__result_first, __result_last}; + } + else + { + auto __i = ranges::next(__first1, __last1); + if (__first2 == __last2) + return {__i, __i}; + + auto __result_begin = __i; + auto __result_end = __i; + for (;;) + { + auto __new_range = ranges::search(__first1, __last1, + __first2, __last2, + __pred, __proj1, __proj2); + auto __new_result_begin = ranges::begin(__new_range); + auto __new_result_end = ranges::end(__new_range); + if (__new_result_begin == __last1) + return {__result_begin, __result_end}; + else + { + __result_begin = __new_result_begin; + __result_end = __new_result_end; + __first1 = __result_begin; + ++__first1; + } + } + } + } + + template + requires indirectly_comparable, iterator_t<_Range2>, + _Pred, _Proj1, _Proj2> + constexpr borrowed_subrange_t<_Range1> + operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __find_end_fn find_end{}; + + struct __adjacent_find_fn + { + template _Sent, + typename _Proj = identity, + indirect_binary_predicate, + projected<_Iter, _Proj>> _Pred + = ranges::equal_to> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Pred __pred = {}, _Proj __proj = {}) const + { + if (__first == __last) + return __first; + auto __next = __first; + for (; ++__next != __last; __first = __next) + { + if (std::__invoke(__pred, + std::__invoke(__proj, *__first), + std::__invoke(__proj, *__next))) + return __first; + } + return __next; + } + + template, _Proj>, + projected, _Proj>> _Pred = ranges::equal_to> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Pred __pred = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __adjacent_find_fn adjacent_find{}; + + struct __is_permutation_fn + { + template _Sent1, + forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Proj1 = identity, typename _Proj2 = identity, + indirect_equivalence_relation, + projected<_Iter2, _Proj2>> _Pred + = ranges::equal_to> + constexpr bool + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + constexpr bool __sized_iters + = (sized_sentinel_for<_Sent1, _Iter1> + && sized_sentinel_for<_Sent2, _Iter2>); + if constexpr (__sized_iters) + { + auto __d1 = ranges::distance(__first1, __last1); + auto __d2 = ranges::distance(__first2, __last2); + if (__d1 != __d2) + return false; + } + + // Efficiently compare identical prefixes: O(N) if sequences + // have the same elements in the same order. + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!(bool)std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + break; + + if constexpr (__sized_iters) + { + if (__first1 == __last1) + return true; + } + else + { + auto __d1 = ranges::distance(__first1, __last1); + auto __d2 = ranges::distance(__first2, __last2); + if (__d1 == 0 && __d2 == 0) + return true; + if (__d1 != __d2) + return false; + } + + for (auto __scan = __first1; __scan != __last1; ++__scan) + { + auto&& __proj_scan = std::__invoke(__proj1, *__scan); + auto __comp_scan = [&] (_Tp&& __arg) -> bool { + return std::__invoke(__pred, __proj_scan, + std::forward<_Tp>(__arg)); + }; + if (__scan != ranges::find_if(__first1, __scan, + __comp_scan, __proj1)) + continue; // We've seen this one before. + + auto __matches = ranges::count_if(__first2, __last2, + __comp_scan, __proj2); + if (__matches == 0 + || ranges::count_if(__scan, __last1, + __comp_scan, __proj1) != __matches) + return false; + } + return true; + } + + template, _Proj1>, + projected, _Proj2>> _Pred = ranges::equal_to> + constexpr bool + operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __is_permutation_fn is_permutation{}; + + template + using copy_if_result = in_out_result<_Iter, _Out>; + + struct __copy_if_fn + { + template _Sent, + weakly_incrementable _Out, typename _Proj = identity, + indirect_unary_predicate> _Pred> + requires indirectly_copyable<_Iter, _Out> + constexpr copy_if_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result, + _Pred __pred, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + { + *__result = *__first; + ++__result; + } + return {std::move(__first), std::move(__result)}; + } + + template, _Proj>> + _Pred> + requires indirectly_copyable, _Out> + constexpr copy_if_result, _Out> + operator()(_Range&& __r, _Out __result, + _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __copy_if_fn copy_if{}; + + template + using swap_ranges_result = in_in_result<_Iter1, _Iter2>; + + struct __swap_ranges_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2> + requires indirectly_swappable<_Iter1, _Iter2> + constexpr swap_ranges_result<_Iter1, _Iter2> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2) const + { + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + ranges::iter_swap(__first1, __first2); + return {std::move(__first1), std::move(__first2)}; + } + + template + requires indirectly_swappable, iterator_t<_Range2>> + constexpr swap_ranges_result, + borrowed_iterator_t<_Range2>> + operator()(_Range1&& __r1, _Range2&& __r2) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2)); + } + }; + + inline constexpr __swap_ranges_fn swap_ranges{}; + + template + using unary_transform_result = in_out_result<_Iter, _Out>; + + template + struct in_in_out_result + { + [[no_unique_address]] _Iter1 in1; + [[no_unique_address]] _Iter2 in2; + [[no_unique_address]] _Out out; + + template + requires convertible_to + && convertible_to + && convertible_to + constexpr + operator in_in_out_result<_IIter1, _IIter2, _OOut>() const & + { return {in1, in2, out}; } + + template + requires convertible_to<_Iter1, _IIter1> + && convertible_to<_Iter2, _IIter2> + && convertible_to<_Out, _OOut> + constexpr + operator in_in_out_result<_IIter1, _IIter2, _OOut>() && + { return {std::move(in1), std::move(in2), std::move(out)}; } + }; + + template + using binary_transform_result = in_in_out_result<_Iter1, _Iter2, _Out>; + + struct __transform_fn + { + template _Sent, + weakly_incrementable _Out, + copy_constructible _Fp, typename _Proj = identity> + requires indirectly_writable<_Out, + indirect_result_t<_Fp&, + projected<_Iter, _Proj>>> + constexpr unary_transform_result<_Iter, _Out> + operator()(_Iter __first1, _Sent __last1, _Out __result, + _Fp __op, _Proj __proj = {}) const + { + for (; __first1 != __last1; ++__first1, (void)++__result) + *__result = std::__invoke(__op, std::__invoke(__proj, *__first1)); + return {std::move(__first1), std::move(__result)}; + } + + template + requires indirectly_writable<_Out, + indirect_result_t<_Fp&, + projected, _Proj>>> + constexpr unary_transform_result, _Out> + operator()(_Range&& __r, _Out __result, _Fp __op, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), + std::move(__op), std::move(__proj)); + } + + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + weakly_incrementable _Out, copy_constructible _Fp, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_writable<_Out, + indirect_result_t<_Fp&, + projected<_Iter1, _Proj1>, + projected<_Iter2, _Proj2>>> + constexpr binary_transform_result<_Iter1, _Iter2, _Out> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, + _Out __result, _Fp __binary_op, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2, ++__result) + *__result = std::__invoke(__binary_op, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2)); + return {std::move(__first1), std::move(__first2), std::move(__result)}; + } + + template + requires indirectly_writable<_Out, + indirect_result_t<_Fp&, + projected, _Proj1>, + projected, _Proj2>>> + constexpr binary_transform_result, + borrowed_iterator_t<_Range2>, _Out> + operator()(_Range1&& __r1, _Range2&& __r2, _Out __result, _Fp __binary_op, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__result), std::move(__binary_op), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __transform_fn transform{}; + + struct __replace_fn + { + template _Sent, + typename _Tp1, typename _Tp2, typename _Proj = identity> + requires indirectly_writable<_Iter, const _Tp2&> + && indirect_binary_predicate, + const _Tp1*> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + const _Tp1& __old_value, const _Tp2& __new_value, + _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (std::__invoke(__proj, *__first) == __old_value) + *__first = __new_value; + return __first; + } + + template + requires indirectly_writable, const _Tp2&> + && indirect_binary_predicate, _Proj>, + const _Tp1*> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, + const _Tp1& __old_value, const _Tp2& __new_value, + _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __old_value, __new_value, std::move(__proj)); + } + }; + + inline constexpr __replace_fn replace{}; + + struct __replace_if_fn + { + template _Sent, + typename _Tp, typename _Proj = identity, + indirect_unary_predicate> _Pred> + requires indirectly_writable<_Iter, const _Tp&> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Pred __pred, const _Tp& __new_value, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + *__first = __new_value; + return std::move(__first); + } + + template, _Proj>> + _Pred> + requires indirectly_writable, const _Tp&> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, + _Pred __pred, const _Tp& __new_value, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), __new_value, std::move(__proj)); + } + }; + + inline constexpr __replace_if_fn replace_if{}; + + template + using replace_copy_result = in_out_result<_Iter, _Out>; + + struct __replace_copy_fn + { + template _Sent, + typename _Tp1, typename _Tp2, output_iterator _Out, + typename _Proj = identity> + requires indirectly_copyable<_Iter, _Out> + && indirect_binary_predicate, const _Tp1*> + constexpr replace_copy_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result, + const _Tp1& __old_value, const _Tp2& __new_value, + _Proj __proj = {}) const + { + for (; __first != __last; ++__first, (void)++__result) + if (std::__invoke(__proj, *__first) == __old_value) + *__result = __new_value; + else + *__result = *__first; + return {std::move(__first), std::move(__result)}; + } + + template _Out, typename _Proj = identity> + requires indirectly_copyable, _Out> + && indirect_binary_predicate, _Proj>, + const _Tp1*> + constexpr replace_copy_result, _Out> + operator()(_Range&& __r, _Out __result, + const _Tp1& __old_value, const _Tp2& __new_value, + _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), __old_value, + __new_value, std::move(__proj)); + } + }; + + inline constexpr __replace_copy_fn replace_copy{}; + + template + using replace_copy_if_result = in_out_result<_Iter, _Out>; + + struct __replace_copy_if_fn + { + template _Sent, + typename _Tp, output_iterator _Out, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + requires indirectly_copyable<_Iter, _Out> + constexpr replace_copy_if_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result, + _Pred __pred, const _Tp& __new_value, _Proj __proj = {}) const + { + for (; __first != __last; ++__first, (void)++__result) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + *__result = __new_value; + else + *__result = *__first; + return {std::move(__first), std::move(__result)}; + } + + template _Out, + typename _Proj = identity, + indirect_unary_predicate, _Proj>> + _Pred> + requires indirectly_copyable, _Out> + constexpr replace_copy_if_result, _Out> + operator()(_Range&& __r, _Out __result, + _Pred __pred, const _Tp& __new_value, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), std::move(__pred), + __new_value, std::move(__proj)); + } + }; + + inline constexpr __replace_copy_if_fn replace_copy_if{}; + + struct __generate_n_fn + { + template + requires invocable<_Fp&> + && indirectly_writable<_Out, invoke_result_t<_Fp&>> + constexpr _Out + operator()(_Out __first, iter_difference_t<_Out> __n, _Fp __gen) const + { + for (; __n > 0; --__n, (void)++__first) + *__first = std::__invoke(__gen); + return __first; + } + }; + + inline constexpr __generate_n_fn generate_n{}; + + struct __generate_fn + { + template _Sent, + copy_constructible _Fp> + requires invocable<_Fp&> + && indirectly_writable<_Out, invoke_result_t<_Fp&>> + constexpr _Out + operator()(_Out __first, _Sent __last, _Fp __gen) const + { + for (; __first != __last; ++__first) + *__first = std::__invoke(__gen); + return __first; + } + + template + requires invocable<_Fp&> && output_range<_Range, invoke_result_t<_Fp&>> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Fp __gen) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), std::move(__gen)); + } + }; + + inline constexpr __generate_fn generate{}; + + struct __remove_if_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr subrange<_Iter> + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + __first = ranges::find_if(__first, __last, __pred, __proj); + if (__first == __last) + return {__first, __first}; + + auto __result = __first; + ++__first; + for (; __first != __last; ++__first) + if (!std::__invoke(__pred, std::__invoke(__proj, *__first))) + { + *__result = std::move(*__first); + ++__result; + } + + return {__result, __first}; + } + + template, _Proj>> + _Pred> + requires permutable> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __remove_if_fn remove_if{}; + + struct __remove_fn + { + template _Sent, + typename _Tp, typename _Proj = identity> + requires indirect_binary_predicate, + const _Tp*> + constexpr subrange<_Iter> + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Proj __proj = {}) const + { + auto __pred = [&] (auto&& __arg) -> bool { + return std::forward(__arg) == __value; + }; + return ranges::remove_if(__first, __last, + std::move(__pred), std::move(__proj)); + } + + template + requires permutable> + && indirect_binary_predicate, _Proj>, + const _Tp*> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, const _Tp& __value, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__proj)); + } + }; + + inline constexpr __remove_fn remove{}; + + template + using remove_copy_if_result = in_out_result<_Iter, _Out>; + + struct __remove_copy_if_fn + { + template _Sent, + weakly_incrementable _Out, typename _Proj = identity, + indirect_unary_predicate> _Pred> + requires indirectly_copyable<_Iter, _Out> + constexpr remove_copy_if_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result, + _Pred __pred, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (!std::__invoke(__pred, std::__invoke(__proj, *__first))) + { + *__result = *__first; + ++__result; + } + return {std::move(__first), std::move(__result)}; + } + + template, _Proj>> + _Pred> + requires indirectly_copyable, _Out> + constexpr remove_copy_if_result, _Out> + operator()(_Range&& __r, _Out __result, + _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __remove_copy_if_fn remove_copy_if{}; + + template + using remove_copy_result = in_out_result<_Iter, _Out>; + + struct __remove_copy_fn + { + template _Sent, + weakly_incrementable _Out, typename _Tp, typename _Proj = identity> + requires indirectly_copyable<_Iter, _Out> + && indirect_binary_predicate, + const _Tp*> + constexpr remove_copy_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result, + const _Tp& __value, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (!(std::__invoke(__proj, *__first) == __value)) + { + *__result = *__first; + ++__result; + } + return {std::move(__first), std::move(__result)}; + } + + template + requires indirectly_copyable, _Out> + && indirect_binary_predicate, _Proj>, + const _Tp*> + constexpr remove_copy_result, _Out> + operator()(_Range&& __r, _Out __result, + const _Tp& __value, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), __value, std::move(__proj)); + } + }; + + inline constexpr __remove_copy_fn remove_copy{}; + + struct __unique_fn + { + template _Sent, + typename _Proj = identity, + indirect_equivalence_relation< + projected<_Iter, _Proj>> _Comp = ranges::equal_to> + constexpr subrange<_Iter> + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + __first = ranges::adjacent_find(__first, __last, __comp, __proj); + if (__first == __last) + return {__first, __first}; + + auto __dest = __first; + ++__first; + while (++__first != __last) + if (!std::__invoke(__comp, + std::__invoke(__proj, *__dest), + std::__invoke(__proj, *__first))) + *++__dest = std::move(*__first); + return {++__dest, __first}; + } + + template, _Proj>> _Comp = ranges::equal_to> + requires permutable> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __unique_fn unique{}; + + namespace __detail + { + template + concept __can_reread_output = input_iterator<_Out> + && same_as<_Tp, iter_value_t<_Out>>; + } + + template + using unique_copy_result = in_out_result<_Iter, _Out>; + + struct __unique_copy_fn + { + template _Sent, + weakly_incrementable _Out, typename _Proj = identity, + indirect_equivalence_relation< + projected<_Iter, _Proj>> _Comp = ranges::equal_to> + requires indirectly_copyable<_Iter, _Out> + && (forward_iterator<_Iter> + || __detail::__can_reread_output<_Out, iter_value_t<_Iter>> + || indirectly_copyable_storable<_Iter, _Out>) + constexpr unique_copy_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return {std::move(__first), std::move(__result)}; + + // TODO: perform a closer comparison with reference implementations + if constexpr (forward_iterator<_Iter>) + { + auto __next = __first; + *__result = *__next; + while (++__next != __last) + if (!std::__invoke(__comp, + std::__invoke(__proj, *__first), + std::__invoke(__proj, *__next))) + { + __first = __next; + *++__result = *__first; + } + return {__next, std::move(++__result)}; + } + else if constexpr (__detail::__can_reread_output<_Out, iter_value_t<_Iter>>) + { + *__result = *__first; + while (++__first != __last) + if (!std::__invoke(__comp, + std::__invoke(__proj, *__result), + std::__invoke(__proj, *__first))) + *++__result = *__first; + return {std::move(__first), std::move(++__result)}; + } + else // indirectly_copyable_storable<_Iter, _Out> + { + auto __value = *__first; + *__result = __value; + while (++__first != __last) + { + if (!(bool)std::__invoke(__comp, + std::__invoke(__proj, *__first), + std::__invoke(__proj, __value))) + { + __value = *__first; + *++__result = __value; + } + } + return {std::move(__first), std::move(++__result)}; + } + } + + template, _Proj>> _Comp = ranges::equal_to> + requires indirectly_copyable, _Out> + && (forward_iterator> + || __detail::__can_reread_output<_Out, range_value_t<_Range>> + || indirectly_copyable_storable, _Out>) + constexpr unique_copy_result, _Out> + operator()(_Range&& __r, _Out __result, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __unique_copy_fn unique_copy{}; + + struct __reverse_fn + { + template _Sent> + requires permutable<_Iter> + constexpr _Iter + operator()(_Iter __first, _Sent __last) const + { + auto __i = ranges::next(__first, __last); + auto __tail = __i; + + if constexpr (random_access_iterator<_Iter>) + { + if (__first != __last) + { + --__tail; + while (__first < __tail) + { + ranges::iter_swap(__first, __tail); + ++__first; + --__tail; + } + } + return __i; + } + else + { + for (;;) + if (__first == __tail || __first == --__tail) + break; + else + { + ranges::iter_swap(__first, __tail); + ++__first; + } + return __i; + } + } + + template + requires permutable> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r) const + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + }; + + inline constexpr __reverse_fn reverse{}; + + template + using reverse_copy_result = in_out_result<_Iter, _Out>; + + struct __reverse_copy_fn + { + template _Sent, + weakly_incrementable _Out> + requires indirectly_copyable<_Iter, _Out> + constexpr reverse_copy_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result) const + { + auto __i = ranges::next(__first, __last); + auto __tail = __i; + while (__first != __tail) + { + --__tail; + *__result = *__tail; + ++__result; + } + return {__i, std::move(__result)}; + } + + template + requires indirectly_copyable, _Out> + constexpr reverse_copy_result, _Out> + operator()(_Range&& __r, _Out __result) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result)); + } + }; + + inline constexpr __reverse_copy_fn reverse_copy{}; + + struct __rotate_fn + { + template _Sent> + constexpr subrange<_Iter> + operator()(_Iter __first, _Iter __middle, _Sent __last) const + { + auto __lasti = ranges::next(__first, __last); + if (__first == __middle) + return {__lasti, __lasti}; + if (__last == __middle) + return {std::move(__first), std::move(__lasti)}; + + if constexpr (random_access_iterator<_Iter>) + { + auto __n = __lasti - __first; + auto __k = __middle - __first; + + if (__k == __n - __k) + { + ranges::swap_ranges(__first, __middle, __middle, __middle + __k); + return {std::move(__middle), std::move(__lasti)}; + } + + auto __p = __first; + auto __ret = __first + (__lasti - __middle); + + for (;;) + { + if (__k < __n - __k) + { + // TODO: is_pod is deprecated, but this condition is + // consistent with the STL implementation. + if constexpr (__is_pod(iter_value_t<_Iter>)) + if (__k == 1) + { + auto __t = std::move(*__p); + ranges::move(__p + 1, __p + __n, __p); + *(__p + __n - 1) = std::move(__t); + return {std::move(__ret), std::move(__lasti)}; + } + auto __q = __p + __k; + for (decltype(__n) __i = 0; __i < __n - __k; ++ __i) + { + ranges::iter_swap(__p, __q); + ++__p; + ++__q; + } + __n %= __k; + if (__n == 0) + return {std::move(__ret), std::move(__lasti)}; + ranges::swap(__n, __k); + __k = __n - __k; + } + else + { + __k = __n - __k; + // TODO: is_pod is deprecated, but this condition is + // consistent with the STL implementation. + if constexpr (__is_pod(iter_value_t<_Iter>)) + if (__k == 1) + { + auto __t = std::move(*(__p + __n - 1)); + ranges::move_backward(__p, __p + __n - 1, __p + __n); + *__p = std::move(__t); + return {std::move(__ret), std::move(__lasti)}; + } + auto __q = __p + __n; + __p = __q - __k; + for (decltype(__n) __i = 0; __i < __n - __k; ++ __i) + { + --__p; + --__q; + ranges::iter_swap(__p, __q); + } + __n %= __k; + if (__n == 0) + return {std::move(__ret), std::move(__lasti)}; + std::swap(__n, __k); + } + } + } + else if constexpr (bidirectional_iterator<_Iter>) + { + auto __tail = __lasti; + + ranges::reverse(__first, __middle); + ranges::reverse(__middle, __tail); + + while (__first != __middle && __middle != __tail) + { + ranges::iter_swap(__first, --__tail); + ++__first; + } + + if (__first == __middle) + { + ranges::reverse(__middle, __tail); + return {std::move(__tail), std::move(__lasti)}; + } + else + { + ranges::reverse(__first, __middle); + return {std::move(__first), std::move(__lasti)}; + } + } + else + { + auto __first2 = __middle; + do + { + ranges::iter_swap(__first, __first2); + ++__first; + ++__first2; + if (__first == __middle) + __middle = __first2; + } while (__first2 != __last); + + auto __ret = __first; + + __first2 = __middle; + + while (__first2 != __last) + { + ranges::iter_swap(__first, __first2); + ++__first; + ++__first2; + if (__first == __middle) + __middle = __first2; + else if (__first2 == __last) + __first2 = __middle; + } + return {std::move(__ret), std::move(__lasti)}; + } + } + + template + requires permutable> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, iterator_t<_Range> __middle) const + { + return (*this)(ranges::begin(__r), std::move(__middle), + ranges::end(__r)); + } + }; + + inline constexpr __rotate_fn rotate{}; + + template + using rotate_copy_result = in_out_result<_Iter, _Out>; + + struct __rotate_copy_fn + { + template _Sent, + weakly_incrementable _Out> + requires indirectly_copyable<_Iter, _Out> + constexpr rotate_copy_result<_Iter, _Out> + operator()(_Iter __first, _Iter __middle, _Sent __last, + _Out __result) const + { + auto __copy1 = ranges::copy(__middle, + std::move(__last), + std::move(__result)); + auto __copy2 = ranges::copy(std::move(__first), + std::move(__middle), + std::move(__copy1.out)); + return { std::move(__copy1.in), std::move(__copy2.out) }; + } + + template + requires indirectly_copyable, _Out> + constexpr rotate_copy_result, _Out> + operator()(_Range&& __r, iterator_t<_Range> __middle, _Out __result) const + { + return (*this)(ranges::begin(__r), std::move(__middle), + ranges::end(__r), std::move(__result)); + } + }; + + inline constexpr __rotate_copy_fn rotate_copy{}; + + struct __sample_fn + { + template _Sent, + weakly_incrementable _Out, typename _Gen> + requires (forward_iterator<_Iter> || random_access_iterator<_Out>) + && indirectly_copyable<_Iter, _Out> + && uniform_random_bit_generator> + _Out + operator()(_Iter __first, _Sent __last, _Out __out, + iter_difference_t<_Iter> __n, _Gen&& __g) const + { + if constexpr (forward_iterator<_Iter>) + { + // FIXME: Forwarding to std::sample here requires computing __lasti + // which may take linear time. + auto __lasti = ranges::next(__first, __last); + return _GLIBCXX_STD_A:: + sample(std::move(__first), std::move(__lasti), std::move(__out), + __n, std::forward<_Gen>(__g)); + } + else + { + using __distrib_type + = uniform_int_distribution>; + using __param_type = typename __distrib_type::param_type; + __distrib_type __d{}; + iter_difference_t<_Iter> __sample_sz = 0; + while (__first != __last && __sample_sz != __n) + { + __out[__sample_sz++] = *__first; + ++__first; + } + for (auto __pop_sz = __sample_sz; __first != __last; + ++__first, (void) ++__pop_sz) + { + const auto __k = __d(__g, __param_type{0, __pop_sz}); + if (__k < __n) + __out[__k] = *__first; + } + return __out + __sample_sz; + } + } + + template + requires (forward_range<_Range> || random_access_iterator<_Out>) + && indirectly_copyable, _Out> + && uniform_random_bit_generator> + _Out + operator()(_Range&& __r, _Out __out, + range_difference_t<_Range> __n, _Gen&& __g) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__out), __n, + std::forward<_Gen>(__g)); + } + }; + + inline constexpr __sample_fn sample{}; + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + struct __shuffle_fn + { + template _Sent, + typename _Gen> + requires permutable<_Iter> + && uniform_random_bit_generator> + _Iter + operator()(_Iter __first, _Sent __last, _Gen&& __g) const + { + auto __lasti = ranges::next(__first, __last); + std::shuffle(std::move(__first), __lasti, std::forward<_Gen>(__g)); + return __lasti; + } + + template + requires permutable> + && uniform_random_bit_generator> + borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Gen&& __g) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::forward<_Gen>(__g)); + } + }; + + inline constexpr __shuffle_fn shuffle{}; +#endif + + struct __push_heap_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + std::push_heap(__first, __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __push_heap_fn push_heap{}; + + struct __pop_heap_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + std::pop_heap(__first, __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __pop_heap_fn pop_heap{}; + + struct __make_heap_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + std::make_heap(__first, __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __make_heap_fn make_heap{}; + + struct __sort_heap_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + std::sort_heap(__first, __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __sort_heap_fn sort_heap{}; + + struct __is_heap_until_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + iter_difference_t<_Iter> __n = ranges::distance(__first, __last); + iter_difference_t<_Iter> __parent = 0, __child = 1; + for (; __child < __n; ++__child) + if (std::__invoke(__comp, + std::__invoke(__proj, *(__first + __parent)), + std::__invoke(__proj, *(__first + __child)))) + return __first + __child; + else if ((__child & 1) == 0) + ++__parent; + + return __first + __n; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __is_heap_until_fn is_heap_until{}; + + struct __is_heap_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr bool + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (__last + == ranges::is_heap_until(__first, __last, + std::move(__comp), + std::move(__proj))); + } + + template, _Proj>> + _Comp = ranges::less> + constexpr bool + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __is_heap_fn is_heap{}; + + struct __sort_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + _GLIBCXX_STD_A::sort(std::move(__first), __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __sort_fn sort{}; + + struct __stable_sort_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + std::stable_sort(std::move(__first), __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __stable_sort_fn stable_sort{}; + + struct __partial_sort_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Iter __middle, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __middle) + return ranges::next(__first, __last); + + ranges::make_heap(__first, __middle, __comp, __proj); + auto __i = __middle; + for (; __i != __last; ++__i) + if (std::__invoke(__comp, + std::__invoke(__proj, *__i), + std::__invoke(__proj, *__first))) + { + ranges::pop_heap(__first, __middle, __comp, __proj); + ranges::iter_swap(__middle-1, __i); + ranges::push_heap(__first, __middle, __comp, __proj); + } + ranges::sort_heap(__first, __middle, __comp, __proj); + + return __i; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, iterator_t<_Range> __middle, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), std::move(__middle), + ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __partial_sort_fn partial_sort{}; + + template + using partial_sort_copy_result = in_out_result<_Iter, _Out>; + + struct __partial_sort_copy_fn + { + template _Sent1, + random_access_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Comp = ranges::less, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_copyable<_Iter1, _Iter2> + && sortable<_Iter2, _Comp, _Proj2> + && indirect_strict_weak_order<_Comp, + projected<_Iter1, _Proj1>, + projected<_Iter2, _Proj2>> + constexpr partial_sort_copy_result<_Iter1, _Iter2> + operator()(_Iter1 __first, _Sent1 __last, + _Iter2 __result_first, _Sent2 __result_last, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + if (__result_first == __result_last) + { + // TODO: Eliminating the variable __lasti triggers an ICE. + auto __lasti = ranges::next(std::move(__first), + std::move(__last)); + return {std::move(__lasti), std::move(__result_first)}; + } + + auto __result_real_last = __result_first; + while (__first != __last && __result_real_last != __result_last) + { + *__result_real_last = *__first; + ++__result_real_last; + ++__first; + } + + ranges::make_heap(__result_first, __result_real_last, __comp, __proj2); + for (; __first != __last; ++__first) + if (std::__invoke(__comp, + std::__invoke(__proj1, *__first), + std::__invoke(__proj2, *__result_first))) + { + ranges::pop_heap(__result_first, __result_real_last, + __comp, __proj2); + *(__result_real_last-1) = *__first; + ranges::push_heap(__result_first, __result_real_last, + __comp, __proj2); + } + ranges::sort_heap(__result_first, __result_real_last, __comp, __proj2); + + return {std::move(__first), std::move(__result_real_last)}; + } + + template + requires indirectly_copyable, iterator_t<_Range2>> + && sortable, _Comp, _Proj2> + && indirect_strict_weak_order<_Comp, + projected, _Proj1>, + projected, _Proj2>> + constexpr partial_sort_copy_result, + borrowed_iterator_t<_Range2>> + operator()(_Range1&& __r, _Range2&& __out, _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + ranges::begin(__out), ranges::end(__out), + std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __partial_sort_copy_fn partial_sort_copy{}; + + struct __is_sorted_until_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return __first; + + auto __next = __first; + for (++__next; __next != __last; __first = __next, (void)++__next) + if (std::__invoke(__comp, + std::__invoke(__proj, *__next), + std::__invoke(__proj, *__first))) + return __next; + return __next; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __is_sorted_until_fn is_sorted_until{}; + + struct __is_sorted_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr bool + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return true; + + auto __next = __first; + for (++__next; __next != __last; __first = __next, (void)++__next) + if (std::__invoke(__comp, + std::__invoke(__proj, *__next), + std::__invoke(__proj, *__first))) + return false; + return true; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr bool + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __is_sorted_fn is_sorted{}; + + struct __nth_element_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr _Iter + operator()(_Iter __first, _Iter __nth, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + _GLIBCXX_STD_A::nth_element(std::move(__first), std::move(__nth), + __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, iterator_t<_Range> __nth, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), std::move(__nth), + ranges::end(__r), std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __nth_element_fn nth_element{}; + + struct __lower_bound_fn + { + template _Sent, + typename _Tp, typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __len = ranges::distance(__first, __last); + + while (__len > 0) + { + auto __half = __len / 2; + auto __middle = __first; + ranges::advance(__middle, __half); + if (std::__invoke(__comp, std::__invoke(__proj, *__middle), __value)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, + const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __lower_bound_fn lower_bound{}; + + struct __upper_bound_fn + { + template _Sent, + typename _Tp, typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __len = ranges::distance(__first, __last); + + while (__len > 0) + { + auto __half = __len / 2; + auto __middle = __first; + ranges::advance(__middle, __half); + if (std::__invoke(__comp, __value, std::__invoke(__proj, *__middle))) + __len = __half; + else + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + } + return __first; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, + const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __upper_bound_fn upper_bound{}; + + struct __equal_range_fn + { + template _Sent, + typename _Tp, typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr subrange<_Iter> + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __len = ranges::distance(__first, __last); + + while (__len > 0) + { + auto __half = __len / 2; + auto __middle = __first; + ranges::advance(__middle, __half); + if (std::__invoke(__comp, + std::__invoke(__proj, *__middle), + __value)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else if (std::__invoke(__comp, + __value, + std::__invoke(__proj, *__middle))) + __len = __half; + else + { + auto __left + = ranges::lower_bound(__first, __middle, + __value, __comp, __proj); + ranges::advance(__first, __len); + auto __right + = ranges::upper_bound(++__middle, __first, + __value, __comp, __proj); + return {__left, __right}; + } + } + return {__first, __first}; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, const _Tp& __value, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __equal_range_fn equal_range{}; + + struct __binary_search_fn + { + template _Sent, + typename _Tp, typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr bool + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __i = ranges::lower_bound(__first, __last, __value, __comp, __proj); + if (__i == __last) + return false; + return !(bool)std::__invoke(__comp, __value, + std::__invoke(__proj, *__i)); + } + + template, _Proj>> + _Comp = ranges::less> + constexpr bool + operator()(_Range&& __r, const _Tp& __value, _Comp __comp = {}, + _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __binary_search_fn binary_search{}; + + struct __is_partitioned_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr bool + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + __first = ranges::find_if_not(std::move(__first), __last, + __pred, __proj); + if (__first == __last) + return true; + ++__first; + return ranges::none_of(std::move(__first), std::move(__last), + std::move(__pred), std::move(__proj)); + } + + template, _Proj>> + _Pred> + constexpr bool + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __is_partitioned_fn is_partitioned{}; + + struct __partition_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr subrange<_Iter> + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + if constexpr (bidirectional_iterator<_Iter>) + { + auto __lasti = ranges::next(__first, __last); + auto __tail = __lasti; + for (;;) + { + for (;;) + if (__first == __tail) + return {std::move(__first), std::move(__lasti)}; + else if (std::__invoke(__pred, + std::__invoke(__proj, *__first))) + ++__first; + else + break; + --__tail; + for (;;) + if (__first == __tail) + return {std::move(__first), std::move(__lasti)}; + else if (!(bool)std::__invoke(__pred, + std::__invoke(__proj, *__tail))) + --__tail; + else + break; + ranges::iter_swap(__first, __tail); + ++__first; + } + } + else + { + if (__first == __last) + return {__first, __first}; + + while (std::__invoke(__pred, std::__invoke(__proj, *__first))) + if (++__first == __last) + return {__first, __first}; + + auto __next = __first; + while (++__next != __last) + if (std::__invoke(__pred, std::__invoke(__proj, *__next))) + { + ranges::iter_swap(__first, __next); + ++__first; + } + + return {std::move(__first), std::move(__next)}; + } + } + + template, _Proj>> + _Pred> + requires permutable> + constexpr borrowed_subrange_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __partition_fn partition{}; + + struct __stable_partition_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + requires permutable<_Iter> + subrange<_Iter> + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + auto __middle + = std::stable_partition(std::move(__first), __lasti, + __detail::__make_pred_proj(__pred, __proj)); + return {std::move(__middle), std::move(__lasti)}; + } + + template, _Proj>> + _Pred> + requires permutable> + borrowed_subrange_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __stable_partition_fn stable_partition{}; + + template + struct in_out_out_result + { + [[no_unique_address]] _Iter in; + [[no_unique_address]] _Out1 out1; + [[no_unique_address]] _Out2 out2; + + template + requires convertible_to + && convertible_to + && convertible_to + constexpr + operator in_out_out_result<_IIter, _OOut1, _OOut2>() const & + { return {in, out1, out2}; } + + template + requires convertible_to<_Iter, _IIter> + && convertible_to<_Out1, _OOut1> + && convertible_to<_Out2, _OOut2> + constexpr + operator in_out_out_result<_IIter, _OOut1, _OOut2>() && + { return {std::move(in), std::move(out1), std::move(out2)}; } + }; + + template + using partition_copy_result = in_out_out_result<_Iter, _Out1, _Out2>; + + struct __partition_copy_fn + { + template _Sent, + weakly_incrementable _Out1, weakly_incrementable _Out2, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + requires indirectly_copyable<_Iter, _Out1> + && indirectly_copyable<_Iter, _Out2> + constexpr partition_copy_result<_Iter, _Out1, _Out2> + operator()(_Iter __first, _Sent __last, + _Out1 __out_true, _Out2 __out_false, + _Pred __pred, _Proj __proj = {}) const + { + for (; __first != __last; ++__first) + if (std::__invoke(__pred, std::__invoke(__proj, *__first))) + { + *__out_true = *__first; + ++__out_true; + } + else + { + *__out_false = *__first; + ++__out_false; + } + + return {std::move(__first), + std::move(__out_true), std::move(__out_false)}; + } + + template, _Proj>> + _Pred> + requires indirectly_copyable, _Out1> + && indirectly_copyable, _Out2> + constexpr partition_copy_result, _Out1, _Out2> + operator()(_Range&& __r, _Out1 __out_true, _Out2 __out_false, + _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__out_true), std::move(__out_false), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __partition_copy_fn partition_copy{}; + + struct __partition_point_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + auto __len = ranges::distance(__first, __last); + + while (__len > 0) + { + auto __half = __len / 2; + auto __middle = __first; + ranges::advance(__middle, __half); + if (std::__invoke(__pred, std::__invoke(__proj, *__middle))) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } + + template, _Proj>> + _Pred> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __partition_point_fn partition_point{}; + + template + using merge_result = in_in_out_result<_Iter1, _Iter2, _Out>; + + struct __merge_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + weakly_incrementable _Out, typename _Comp = ranges::less, + typename _Proj1 = identity, typename _Proj2 = identity> + requires mergeable<_Iter1, _Iter2, _Out, _Comp, _Proj1, _Proj2> + constexpr merge_result<_Iter1, _Iter2, _Out> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2) + { + if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + } + ++__result; + } + auto __copy1 = ranges::copy(std::move(__first1), std::move(__last1), + std::move(__result)); + auto __copy2 = ranges::copy(std::move(__first2), std::move(__last2), + std::move(__copy1.out)); + return { std::move(__copy1.in), std::move(__copy2.in), + std::move(__copy2.out) }; + } + + template + requires mergeable, iterator_t<_Range2>, _Out, + _Comp, _Proj1, _Proj2> + constexpr merge_result, + borrowed_iterator_t<_Range2>, + _Out> + operator()(_Range1&& __r1, _Range2&& __r2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__result), std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __merge_fn merge{}; + + struct __inplace_merge_fn + { + template _Sent, + typename _Comp = ranges::less, + typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + _Iter + operator()(_Iter __first, _Iter __middle, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __lasti = ranges::next(__first, __last); + std::inplace_merge(std::move(__first), std::move(__middle), __lasti, + __detail::__make_comp_proj(__comp, __proj)); + return __lasti; + } + + template + requires sortable, _Comp, _Proj> + borrowed_iterator_t<_Range> + operator()(_Range&& __r, iterator_t<_Range> __middle, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), std::move(__middle), + ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __inplace_merge_fn inplace_merge{}; + + struct __includes_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Proj1 = identity, typename _Proj2 = identity, + indirect_strict_weak_order, + projected<_Iter2, _Proj2>> + _Comp = ranges::less> + constexpr bool + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2) + if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + return false; + else if (std::__invoke(__comp, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + ++__first1; + else + { + ++__first1; + ++__first2; + } + + return __first2 == __last2; + } + + template, _Proj1>, + projected, _Proj2>> + _Comp = ranges::less> + constexpr bool + operator()(_Range1&& __r1, _Range2&& __r2, _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __includes_fn includes{}; + + template + using set_union_result = in_in_out_result<_Iter1, _Iter2, _Out>; + + struct __set_union_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + weakly_incrementable _Out, typename _Comp = ranges::less, + typename _Proj1 = identity, typename _Proj2 = identity> + requires mergeable<_Iter1, _Iter2, _Out, _Comp, _Proj1, _Proj2> + constexpr set_union_result<_Iter1, _Iter2, _Out> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, + _Out __result, _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2) + { + if (std::__invoke(__comp, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + { + *__result = *__first1; + ++__first1; + } + else if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + ++__first2; + } + ++__result; + } + auto __copy1 = ranges::copy(std::move(__first1), std::move(__last1), + std::move(__result)); + auto __copy2 = ranges::copy(std::move(__first2), std::move(__last2), + std::move(__copy1.out)); + return {std::move(__copy1.in), std::move(__copy2.in), + std::move(__copy2.out)}; + } + + template + requires mergeable, iterator_t<_Range2>, _Out, + _Comp, _Proj1, _Proj2> + constexpr set_union_result, + borrowed_iterator_t<_Range2>, _Out> + operator()(_Range1&& __r1, _Range2&& __r2, + _Out __result, _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__result), std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __set_union_fn set_union{}; + + template + using set_intersection_result = in_in_out_result<_Iter1, _Iter2, _Out>; + + struct __set_intersection_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + weakly_incrementable _Out, typename _Comp = ranges::less, + typename _Proj1 = identity, typename _Proj2 = identity> + requires mergeable<_Iter1, _Iter2, _Out, _Comp, _Proj1, _Proj2> + constexpr set_intersection_result<_Iter1, _Iter2, _Out> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2) + if (std::__invoke(__comp, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + ++__first1; + else if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + ++__first2; + else + { + *__result = *__first1; + ++__first1; + ++__first2; + ++__result; + } + // TODO: Eliminating these variables triggers an ICE. + auto __last1i = ranges::next(std::move(__first1), std::move(__last1)); + auto __last2i = ranges::next(std::move(__first2), std::move(__last2)); + return {std::move(__last1i), std::move(__last2i), std::move(__result)}; + } + + template + requires mergeable, iterator_t<_Range2>, _Out, + _Comp, _Proj1, _Proj2> + constexpr set_intersection_result, + borrowed_iterator_t<_Range2>, _Out> + operator()(_Range1&& __r1, _Range2&& __r2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__result), std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __set_intersection_fn set_intersection{}; + + template + using set_difference_result = in_out_result<_Iter, _Out>; + + struct __set_difference_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + weakly_incrementable _Out, typename _Comp = ranges::less, + typename _Proj1 = identity, typename _Proj2 = identity> + requires mergeable<_Iter1, _Iter2, _Out, _Comp, _Proj1, _Proj2> + constexpr set_difference_result<_Iter1, _Out> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2) + if (std::__invoke(__comp, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + { + *__result = *__first1; + ++__first1; + ++__result; + } + else if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + ++__first2; + else + { + ++__first1; + ++__first2; + } + return ranges::copy(std::move(__first1), std::move(__last1), + std::move(__result)); + } + + template + requires mergeable, iterator_t<_Range2>, _Out, + _Comp, _Proj1, _Proj2> + constexpr set_difference_result, _Out> + operator()(_Range1&& __r1, _Range2&& __r2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__result), std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __set_difference_fn set_difference{}; + + template + using set_symmetric_difference_result + = in_in_out_result<_Iter1, _Iter2, _Out>; + + struct __set_symmetric_difference_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + weakly_incrementable _Out, typename _Comp = ranges::less, + typename _Proj1 = identity, typename _Proj2 = identity> + requires mergeable<_Iter1, _Iter2, _Out, _Comp, _Proj1, _Proj2> + constexpr set_symmetric_difference_result<_Iter1, _Iter2, _Out> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, + _Out __result, _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2) + if (std::__invoke(__comp, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + { + *__result = *__first1; + ++__first1; + ++__result; + } + else if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + { + *__result = *__first2; + ++__first2; + ++__result; + } + else + { + ++__first1; + ++__first2; + } + auto __copy1 = ranges::copy(std::move(__first1), std::move(__last1), + std::move(__result)); + auto __copy2 = ranges::copy(std::move(__first2), std::move(__last2), + std::move(__copy1.out)); + return {std::move(__copy1.in), std::move(__copy2.in), + std::move(__copy2.out)}; + } + + template + requires mergeable, iterator_t<_Range2>, _Out, + _Comp, _Proj1, _Proj2> + constexpr set_symmetric_difference_result, + borrowed_iterator_t<_Range2>, + _Out> + operator()(_Range1&& __r1, _Range2&& __r2, _Out __result, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__result), std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __set_symmetric_difference_fn set_symmetric_difference{}; + + struct __min_fn + { + template> + _Comp = ranges::less> + constexpr const _Tp& + operator()(const _Tp& __a, const _Tp& __b, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (std::__invoke(__comp, + std::__invoke(__proj, __b), + std::__invoke(__proj, __a))) + return __b; + else + return __a; + } + + template, _Proj>> + _Comp = ranges::less> + requires indirectly_copyable_storable, + range_value_t<_Range>*> + constexpr range_value_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __first = ranges::begin(__r); + auto __last = ranges::end(__r); + __glibcxx_assert(__first != __last); + auto __result = *__first; + while (++__first != __last) + { + auto __tmp = *__first; + if (std::__invoke(__comp, + std::__invoke(__proj, __tmp), + std::__invoke(__proj, __result))) + __result = std::move(__tmp); + } + return __result; + } + + template> + _Comp = ranges::less> + constexpr _Tp + operator()(initializer_list<_Tp> __r, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::subrange(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __min_fn min{}; + + struct __max_fn + { + template> + _Comp = ranges::less> + constexpr const _Tp& + operator()(const _Tp& __a, const _Tp& __b, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (std::__invoke(__comp, + std::__invoke(__proj, __a), + std::__invoke(__proj, __b))) + return __b; + else + return __a; + } + + template, _Proj>> + _Comp = ranges::less> + requires indirectly_copyable_storable, + range_value_t<_Range>*> + constexpr range_value_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __first = ranges::begin(__r); + auto __last = ranges::end(__r); + __glibcxx_assert(__first != __last); + auto __result = *__first; + while (++__first != __last) + { + auto __tmp = *__first; + if (std::__invoke(__comp, + std::__invoke(__proj, __result), + std::__invoke(__proj, __tmp))) + __result = std::move(__tmp); + } + return __result; + } + + template> + _Comp = ranges::less> + constexpr _Tp + operator()(initializer_list<_Tp> __r, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::subrange(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __max_fn max{}; + + struct __clamp_fn + { + template> _Comp + = ranges::less> + constexpr const _Tp& + operator()(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, + _Comp __comp = {}, _Proj __proj = {}) const + { + __glibcxx_assert(!(std::__invoke(__comp, + std::__invoke(__proj, __hi), + std::__invoke(__proj, __lo)))); + auto&& __proj_val = std::__invoke(__proj, __val); + if (std::__invoke(__comp, __proj_val, std::__invoke(__proj, __lo))) + return __lo; + else if (std::__invoke(__comp, std::__invoke(__proj, __hi), __proj_val)) + return __hi; + else + return __val; + } + }; + + inline constexpr __clamp_fn clamp{}; + + template + struct min_max_result + { + [[no_unique_address]] _Tp min; + [[no_unique_address]] _Tp max; + + template + requires convertible_to + constexpr + operator min_max_result<_Tp2>() const & + { return {min, max}; } + + template + requires convertible_to<_Tp, _Tp2> + constexpr + operator min_max_result<_Tp2>() && + { return {std::move(min), std::move(max)}; } + }; + + template + using minmax_result = min_max_result<_Tp>; + + struct __minmax_fn + { + template> + _Comp = ranges::less> + constexpr minmax_result + operator()(const _Tp& __a, const _Tp& __b, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (std::__invoke(__comp, + std::__invoke(__proj, __b), + std::__invoke(__proj, __a))) + return {__b, __a}; + else + return {__a, __b}; + } + + template, _Proj>> + _Comp = ranges::less> + requires indirectly_copyable_storable, range_value_t<_Range>*> + constexpr minmax_result> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + auto __first = ranges::begin(__r); + auto __last = ranges::end(__r); + __glibcxx_assert(__first != __last); + auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); + minmax_result> __result = {*__first, *__first}; + if (++__first == __last) + return __result; + else + { + // At this point __result.min == __result.max, so a single + // comparison with the next element suffices. + auto&& __val = *__first; + if (__comp_proj(__val, __result.min)) + __result.min = std::forward(__val); + else + __result.max = std::forward(__val); + } + while (++__first != __last) + { + // Now process two elements at a time so that we perform at most + // 1 + 3*(N-2)/2 comparisons in total (each of the (N-2)/2 + // iterations of this loop performs three comparisons). + range_value_t<_Range> __val1 = *__first; + if (++__first == __last) + { + // N is odd; in this final iteration, we perform at most two + // comparisons, for a total of 1 + 3*(N-3)/2 + 2 comparisons, + // which is not more than 3*N/2, as required. + if (__comp_proj(__val1, __result.min)) + __result.min = std::move(__val1); + else if (!__comp_proj(__val1, __result.max)) + __result.max = std::move(__val1); + break; + } + auto&& __val2 = *__first; + if (!__comp_proj(__val2, __val1)) + { + if (__comp_proj(__val1, __result.min)) + __result.min = std::move(__val1); + if (!__comp_proj(__val2, __result.max)) + __result.max = std::forward(__val2); + } + else + { + if (__comp_proj(__val2, __result.min)) + __result.min = std::forward(__val2); + if (!__comp_proj(__val1, __result.max)) + __result.max = std::move(__val1); + } + } + return __result; + } + + template> + _Comp = ranges::less> + constexpr minmax_result<_Tp> + operator()(initializer_list<_Tp> __r, + _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::subrange(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __minmax_fn minmax{}; + + struct __min_element_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return __first; + + auto __i = __first; + while (++__i != __last) + { + if (std::__invoke(__comp, + std::__invoke(__proj, *__i), + std::__invoke(__proj, *__first))) + __first = __i; + } + return __first; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __min_element_fn min_element{}; + + struct __max_element_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return __first; + + auto __i = __first; + while (++__i != __last) + { + if (std::__invoke(__comp, + std::__invoke(__proj, *__first), + std::__invoke(__proj, *__i))) + __first = __i; + } + return __first; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __max_element_fn max_element{}; + + template + using minmax_element_result = min_max_result<_Iter>; + + struct __minmax_element_fn + { + template _Sent, + typename _Proj = identity, + indirect_strict_weak_order> + _Comp = ranges::less> + constexpr minmax_element_result<_Iter> + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + auto __comp_proj = __detail::__make_comp_proj(__comp, __proj); + minmax_element_result<_Iter> __result = {__first, __first}; + if (__first == __last || ++__first == __last) + return __result; + else + { + // At this point __result.min == __result.max, so a single + // comparison with the next element suffices. + if (__comp_proj(*__first, *__result.min)) + __result.min = __first; + else + __result.max = __first; + } + while (++__first != __last) + { + // Now process two elements at a time so that we perform at most + // 1 + 3*(N-2)/2 comparisons in total (each of the (N-2)/2 + // iterations of this loop performs three comparisons). + auto __prev = __first; + if (++__first == __last) + { + // N is odd; in this final iteration, we perform at most two + // comparisons, for a total of 1 + 3*(N-3)/2 + 2 comparisons, + // which is not more than 3*N/2, as required. + if (__comp_proj(*__prev, *__result.min)) + __result.min = __prev; + else if (!__comp_proj(*__prev, *__result.max)) + __result.max = __prev; + break; + } + if (!__comp_proj(*__first, *__prev)) + { + if (__comp_proj(*__prev, *__result.min)) + __result.min = __prev; + if (!__comp_proj(*__first, *__result.max)) + __result.max = __first; + } + else + { + if (__comp_proj(*__first, *__result.min)) + __result.min = __first; + if (!__comp_proj(*__prev, *__result.max)) + __result.max = __prev; + } + } + return __result; + } + + template, _Proj>> + _Comp = ranges::less> + constexpr minmax_element_result> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __minmax_element_fn minmax_element{}; + + struct __lexicographical_compare_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Proj1 = identity, typename _Proj2 = identity, + indirect_strict_weak_order, + projected<_Iter2, _Proj2>> + _Comp = ranges::less> + constexpr bool + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, + _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + if constexpr (__detail::__is_normal_iterator<_Iter1> + && same_as<_Iter1, _Sent1>) + return (*this)(__first1.base(), __last1.base(), + std::move(__first2), std::move(__last2), + std::move(__comp), + std::move(__proj1), std::move(__proj2)); + else if constexpr (__detail::__is_normal_iterator<_Iter2> + && same_as<_Iter2, _Sent2>) + return (*this)(std::move(__first1), std::move(__last1), + __first2.base(), __last2.base(), + std::move(__comp), + std::move(__proj1), std::move(__proj2)); + else + { + constexpr bool __sized_iters + = (sized_sentinel_for<_Sent1, _Iter1> + && sized_sentinel_for<_Sent2, _Iter2>); + if constexpr (__sized_iters) + { + using _ValueType1 = iter_value_t<_Iter1>; + using _ValueType2 = iter_value_t<_Iter2>; + // This condition is consistent with the one in + // __lexicographical_compare_aux in . + constexpr bool __use_memcmp + = (__is_memcmp_ordered_with<_ValueType1, _ValueType2>::__value + && __ptr_to_nonvolatile<_Iter1> + && __ptr_to_nonvolatile<_Iter2> + && (is_same_v<_Comp, ranges::less> + || is_same_v<_Comp, ranges::greater>) + && is_same_v<_Proj1, identity> + && is_same_v<_Proj2, identity>); + if constexpr (__use_memcmp) + { + const auto __d1 = __last1 - __first1; + const auto __d2 = __last2 - __first2; + + if (const auto __len = std::min(__d1, __d2)) + { + const auto __c + = std::__memcmp(__first1, __first2, __len); + if constexpr (is_same_v<_Comp, ranges::less>) + { + if (__c < 0) + return true; + if (__c > 0) + return false; + } + else if constexpr (is_same_v<_Comp, ranges::greater>) + { + if (__c > 0) + return true; + if (__c < 0) + return false; + } + } + return __d1 < __d2; + } + } + + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void) ++__first2) + { + if (std::__invoke(__comp, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + return true; + if (std::__invoke(__comp, + std::__invoke(__proj2, *__first2), + std::__invoke(__proj1, *__first1))) + return false; + } + return __first1 == __last1 && __first2 != __last2; + } + } + + template, _Proj1>, + projected, _Proj2>> + _Comp = ranges::less> + constexpr bool + operator()(_Range1&& __r1, _Range2&& __r2, _Comp __comp = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__comp), + std::move(__proj1), std::move(__proj2)); + } + + private: + template> + static constexpr bool __ptr_to_nonvolatile + = is_pointer_v<_Iter> && !is_volatile_v>; + }; + + inline constexpr __lexicographical_compare_fn lexicographical_compare; + + template + struct in_found_result + { + [[no_unique_address]] _Iter in; + bool found; + + template + requires convertible_to + constexpr + operator in_found_result<_Iter2>() const & + { return {in, found}; } + + template + requires convertible_to<_Iter, _Iter2> + constexpr + operator in_found_result<_Iter2>() && + { return {std::move(in), found}; } + }; + + template + using next_permutation_result = in_found_result<_Iter>; + + struct __next_permutation_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr next_permutation_result<_Iter> + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return {std::move(__first), false}; + + auto __i = __first; + ++__i; + if (__i == __last) + return {std::move(__i), false}; + + auto __lasti = ranges::next(__first, __last); + __i = __lasti; + --__i; + + for (;;) + { + auto __ii = __i; + --__i; + if (std::__invoke(__comp, + std::__invoke(__proj, *__i), + std::__invoke(__proj, *__ii))) + { + auto __j = __lasti; + while (!(bool)std::__invoke(__comp, + std::__invoke(__proj, *__i), + std::__invoke(__proj, *--__j))) + ; + ranges::iter_swap(__i, __j); + ranges::reverse(__ii, __last); + return {std::move(__lasti), true}; + } + if (__i == __first) + { + ranges::reverse(__first, __last); + return {std::move(__lasti), false}; + } + } + } + + template + requires sortable, _Comp, _Proj> + constexpr next_permutation_result> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __next_permutation_fn next_permutation{}; + + template + using prev_permutation_result = in_found_result<_Iter>; + + struct __prev_permutation_fn + { + template _Sent, + typename _Comp = ranges::less, typename _Proj = identity> + requires sortable<_Iter, _Comp, _Proj> + constexpr prev_permutation_result<_Iter> + operator()(_Iter __first, _Sent __last, + _Comp __comp = {}, _Proj __proj = {}) const + { + if (__first == __last) + return {std::move(__first), false}; + + auto __i = __first; + ++__i; + if (__i == __last) + return {std::move(__i), false}; + + auto __lasti = ranges::next(__first, __last); + __i = __lasti; + --__i; + + for (;;) + { + auto __ii = __i; + --__i; + if (std::__invoke(__comp, + std::__invoke(__proj, *__ii), + std::__invoke(__proj, *__i))) + { + auto __j = __lasti; + while (!(bool)std::__invoke(__comp, + std::__invoke(__proj, *--__j), + std::__invoke(__proj, *__i))) + ; + ranges::iter_swap(__i, __j); + ranges::reverse(__ii, __last); + return {std::move(__lasti), true}; + } + if (__i == __first) + { + ranges::reverse(__first, __last); + return {std::move(__lasti), false}; + } + } + } + + template + requires sortable, _Comp, _Proj> + constexpr prev_permutation_result> + operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__comp), std::move(__proj)); + } + }; + + inline constexpr __prev_permutation_fn prev_permutation{}; + +} // namespace ranges + +#define __cpp_lib_shift 201806L + template + constexpr _ForwardIterator + shift_left(_ForwardIterator __first, _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) + { + __glibcxx_assert(__n >= 0); + if (__n == 0) + return __last; + + auto __mid = ranges::next(__first, __n, __last); + if (__mid == __last) + return __first; + return std::move(std::move(__mid), std::move(__last), std::move(__first)); + } + + template + constexpr _ForwardIterator + shift_right(_ForwardIterator __first, _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) + { + __glibcxx_assert(__n >= 0); + if (__n == 0) + return __first; + + using _Cat + = typename iterator_traits<_ForwardIterator>::iterator_category; + if constexpr (derived_from<_Cat, bidirectional_iterator_tag>) + { + auto __mid = ranges::next(__last, -__n, __first); + if (__mid == __first) + return __last; + + return std::move_backward(std::move(__first), std::move(__mid), + std::move(__last)); + } + else + { + auto __result = ranges::next(__first, __n, __last); + if (__result == __last) + return __last; + + auto __dest_head = __first, __dest_tail = __result; + while (__dest_head != __result) + { + if (__dest_tail == __last) + { + // If we get here, then we must have + // 2*n >= distance(__first, __last) + // i.e. we are shifting out at least half of the range. In + // this case we can safely perform the shift with a single + // move. + std::move(std::move(__first), std::move(__dest_head), __result); + return __result; + } + ++__dest_head; + ++__dest_tail; + } + + for (;;) + { + // At the start of each iteration of this outer loop, the range + // [__first, __result) contains those elements that after shifting + // the whole range right by __n, should end up in + // [__dest_head, __dest_tail) in order. + + // The below inner loop swaps the elements of [__first, __result) + // and [__dest_head, __dest_tail), while simultaneously shifting + // the latter range by __n. + auto __cursor = __first; + while (__cursor != __result) + { + if (__dest_tail == __last) + { + // At this point the ranges [__first, result) and + // [__dest_head, dest_tail) are disjoint, so we can safely + // move the remaining elements. + __dest_head = std::move(__cursor, __result, + std::move(__dest_head)); + std::move(std::move(__first), std::move(__cursor), + std::move(__dest_head)); + return __result; + } + std::iter_swap(__cursor, __dest_head); + ++__dest_head; + ++__dest_tail; + ++__cursor; + } + } + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // concepts +#endif // C++20 +#endif // _RANGES_ALGO_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_algobase.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_algobase.h new file mode 100755 index 0000000..78c2959 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_algobase.h @@ -0,0 +1,598 @@ +// Core algorithmic facilities -*- C++ -*- + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ranges_algobase.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _RANGES_ALGOBASE_H +#define _RANGES_ALGOBASE_H 1 + +#if __cplusplus > 201703L + +#include +#include +#include // ranges::begin, ranges::range etc. +#include // __invoke +#include // __is_byte + +#if __cpp_lib_concepts +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace ranges +{ + namespace __detail + { + template + constexpr inline bool __is_normal_iterator = false; + + template + constexpr inline bool + __is_normal_iterator<__gnu_cxx::__normal_iterator<_Iterator, + _Container>> = true; + + template + constexpr inline bool __is_reverse_iterator = false; + + template + constexpr inline bool + __is_reverse_iterator> = true; + + template + constexpr inline bool __is_move_iterator = false; + + template + constexpr inline bool + __is_move_iterator> = true; + } // namespace __detail + + struct __equal_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Pred = ranges::equal_to, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + constexpr bool + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + // TODO: implement more specializations to at least have parity with + // std::equal. + if constexpr (__detail::__is_normal_iterator<_Iter1> + && same_as<_Iter1, _Sent1>) + return (*this)(__first1.base(), __last1.base(), + std::move(__first2), std::move(__last2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + else if constexpr (__detail::__is_normal_iterator<_Iter2> + && same_as<_Iter2, _Sent2>) + return (*this)(std::move(__first1), std::move(__last1), + __first2.base(), __last2.base(), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + else if constexpr (sized_sentinel_for<_Sent1, _Iter1> + && sized_sentinel_for<_Sent2, _Iter2>) + { + auto __d1 = ranges::distance(__first1, __last1); + auto __d2 = ranges::distance(__first2, __last2); + if (__d1 != __d2) + return false; + + using _ValueType1 = iter_value_t<_Iter1>; + constexpr bool __use_memcmp + = ((is_integral_v<_ValueType1> || is_pointer_v<_ValueType1>) + && __memcmpable<_Iter1, _Iter2>::__value + && is_same_v<_Pred, ranges::equal_to> + && is_same_v<_Proj1, identity> + && is_same_v<_Proj2, identity>); + if constexpr (__use_memcmp) + { + if (const size_t __len = (__last1 - __first1)) + return !std::__memcmp(__first1, __first2, __len); + return true; + } + else + { + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!(bool)std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + return false; + return true; + } + } + else + { + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!(bool)std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + return false; + return __first1 == __last1 && __first2 == __last2; + } + } + + template + requires indirectly_comparable, iterator_t<_Range2>, + _Pred, _Proj1, _Proj2> + constexpr bool + operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __equal_fn equal{}; + + template + struct in_out_result + { + [[no_unique_address]] _Iter in; + [[no_unique_address]] _Out out; + + template + requires convertible_to + && convertible_to + constexpr + operator in_out_result<_Iter2, _Out2>() const & + { return {in, out}; } + + template + requires convertible_to<_Iter, _Iter2> + && convertible_to<_Out, _Out2> + constexpr + operator in_out_result<_Iter2, _Out2>() && + { return {std::move(in), std::move(out)}; } + }; + + template + using copy_result = in_out_result<_Iter, _Out>; + + template + using move_result = in_out_result<_Iter, _Out>; + + template + using move_backward_result = in_out_result<_Iter1, _Iter2>; + + template + using copy_backward_result = in_out_result<_Iter1, _Iter2>; + + template _Sent, + bidirectional_iterator _Out> + requires (_IsMove + ? indirectly_movable<_Iter, _Out> + : indirectly_copyable<_Iter, _Out>) + constexpr conditional_t<_IsMove, + move_backward_result<_Iter, _Out>, + copy_backward_result<_Iter, _Out>> + __copy_or_move_backward(_Iter __first, _Sent __last, _Out __result); + + template _Sent, + weakly_incrementable _Out> + requires (_IsMove + ? indirectly_movable<_Iter, _Out> + : indirectly_copyable<_Iter, _Out>) + constexpr conditional_t<_IsMove, + move_result<_Iter, _Out>, + copy_result<_Iter, _Out>> + __copy_or_move(_Iter __first, _Sent __last, _Out __result) + { + // TODO: implement more specializations to be at least on par with + // std::copy/std::move. + using __detail::__is_move_iterator; + using __detail::__is_reverse_iterator; + using __detail::__is_normal_iterator; + if constexpr (__is_move_iterator<_Iter> && same_as<_Iter, _Sent>) + { + auto [__in, __out] + = ranges::__copy_or_move(std::move(__first).base(), + std::move(__last).base(), + std::move(__result)); + return {move_iterator{std::move(__in)}, std::move(__out)}; + } + else if constexpr (__is_reverse_iterator<_Iter> && same_as<_Iter, _Sent> + && __is_reverse_iterator<_Out>) + { + auto [__in,__out] + = ranges::__copy_or_move_backward<_IsMove>(std::move(__last).base(), + std::move(__first).base(), + std::move(__result).base()); + return {reverse_iterator{std::move(__in)}, + reverse_iterator{std::move(__out)}}; + } + else if constexpr (__is_normal_iterator<_Iter> && same_as<_Iter, _Sent>) + { + auto [__in,__out] + = ranges::__copy_or_move<_IsMove>(__first.base(), __last.base(), + __result); + return {decltype(__first){__in}, std::move(__out)}; + } + else if constexpr (__is_normal_iterator<_Out>) + { + auto [__in,__out] + = ranges::__copy_or_move<_IsMove>(std::move(__first), __last, __result.base()); + return {std::move(__in), decltype(__result){__out}}; + } + else if constexpr (sized_sentinel_for<_Sent, _Iter>) + { +#ifdef __cpp_lib_is_constant_evaluated + if (!std::is_constant_evaluated()) +#endif + { + if constexpr (__memcpyable<_Iter, _Out>::__value) + { + using _ValueTypeI = iter_value_t<_Iter>; + static_assert(_IsMove + ? is_move_assignable_v<_ValueTypeI> + : is_copy_assignable_v<_ValueTypeI>); + auto __num = __last - __first; + if (__num) + __builtin_memmove(__result, __first, + sizeof(_ValueTypeI) * __num); + return {__first + __num, __result + __num}; + } + } + + for (auto __n = __last - __first; __n > 0; --__n) + { + if constexpr (_IsMove) + *__result = std::move(*__first); + else + *__result = *__first; + ++__first; + ++__result; + } + return {std::move(__first), std::move(__result)}; + } + else + { + while (__first != __last) + { + if constexpr (_IsMove) + *__result = std::move(*__first); + else + *__result = *__first; + ++__first; + ++__result; + } + return {std::move(__first), std::move(__result)}; + } + } + + struct __copy_fn + { + template _Sent, + weakly_incrementable _Out> + requires indirectly_copyable<_Iter, _Out> + constexpr copy_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result) const + { + return ranges::__copy_or_move(std::move(__first), + std::move(__last), + std::move(__result)); + } + + template + requires indirectly_copyable, _Out> + constexpr copy_result, _Out> + operator()(_Range&& __r, _Out __result) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result)); + } + }; + + inline constexpr __copy_fn copy{}; + + struct __move_fn + { + template _Sent, + weakly_incrementable _Out> + requires indirectly_movable<_Iter, _Out> + constexpr move_result<_Iter, _Out> + operator()(_Iter __first, _Sent __last, _Out __result) const + { + return ranges::__copy_or_move(std::move(__first), + std::move(__last), + std::move(__result)); + } + + template + requires indirectly_movable, _Out> + constexpr move_result, _Out> + operator()(_Range&& __r, _Out __result) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result)); + } + }; + + inline constexpr __move_fn move{}; + + template _Sent, + bidirectional_iterator _Out> + requires (_IsMove + ? indirectly_movable<_Iter, _Out> + : indirectly_copyable<_Iter, _Out>) + constexpr conditional_t<_IsMove, + move_backward_result<_Iter, _Out>, + copy_backward_result<_Iter, _Out>> + __copy_or_move_backward(_Iter __first, _Sent __last, _Out __result) + { + // TODO: implement more specializations to be at least on par with + // std::copy_backward/std::move_backward. + using __detail::__is_reverse_iterator; + using __detail::__is_normal_iterator; + if constexpr (__is_reverse_iterator<_Iter> && same_as<_Iter, _Sent> + && __is_reverse_iterator<_Out>) + { + auto [__in,__out] + = ranges::__copy_or_move<_IsMove>(std::move(__last).base(), + std::move(__first).base(), + std::move(__result).base()); + return {reverse_iterator{std::move(__in)}, + reverse_iterator{std::move(__out)}}; + } + else if constexpr (__is_normal_iterator<_Iter> && same_as<_Iter, _Sent>) + { + auto [__in,__out] + = ranges::__copy_or_move_backward<_IsMove>(__first.base(), + __last.base(), + std::move(__result)); + return {decltype(__first){__in}, std::move(__out)}; + } + else if constexpr (__is_normal_iterator<_Out>) + { + auto [__in,__out] + = ranges::__copy_or_move_backward<_IsMove>(std::move(__first), + std::move(__last), + __result.base()); + return {std::move(__in), decltype(__result){__out}}; + } + else if constexpr (sized_sentinel_for<_Sent, _Iter>) + { +#ifdef __cpp_lib_is_constant_evaluated + if (!std::is_constant_evaluated()) +#endif + { + if constexpr (__memcpyable<_Out, _Iter>::__value) + { + using _ValueTypeI = iter_value_t<_Iter>; + static_assert(_IsMove + ? is_move_assignable_v<_ValueTypeI> + : is_copy_assignable_v<_ValueTypeI>); + auto __num = __last - __first; + if (__num) + __builtin_memmove(__result - __num, __first, + sizeof(_ValueTypeI) * __num); + return {__first + __num, __result - __num}; + } + } + + auto __lasti = ranges::next(__first, __last); + auto __tail = __lasti; + + for (auto __n = __last - __first; __n > 0; --__n) + { + --__tail; + --__result; + if constexpr (_IsMove) + *__result = std::move(*__tail); + else + *__result = *__tail; + } + return {std::move(__lasti), std::move(__result)}; + } + else + { + auto __lasti = ranges::next(__first, __last); + auto __tail = __lasti; + + while (__first != __tail) + { + --__tail; + --__result; + if constexpr (_IsMove) + *__result = std::move(*__tail); + else + *__result = *__tail; + } + return {std::move(__lasti), std::move(__result)}; + } + } + + struct __copy_backward_fn + { + template _Sent1, + bidirectional_iterator _Iter2> + requires indirectly_copyable<_Iter1, _Iter2> + constexpr copy_backward_result<_Iter1, _Iter2> + operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result) const + { + return ranges::__copy_or_move_backward(std::move(__first), + std::move(__last), + std::move(__result)); + } + + template + requires indirectly_copyable, _Iter> + constexpr copy_backward_result, _Iter> + operator()(_Range&& __r, _Iter __result) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result)); + } + }; + + inline constexpr __copy_backward_fn copy_backward{}; + + struct __move_backward_fn + { + template _Sent1, + bidirectional_iterator _Iter2> + requires indirectly_movable<_Iter1, _Iter2> + constexpr move_backward_result<_Iter1, _Iter2> + operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result) const + { + return ranges::__copy_or_move_backward(std::move(__first), + std::move(__last), + std::move(__result)); + } + + template + requires indirectly_movable, _Iter> + constexpr move_backward_result, _Iter> + operator()(_Range&& __r, _Iter __result) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__result)); + } + }; + + inline constexpr __move_backward_fn move_backward{}; + + template + using copy_n_result = in_out_result<_Iter, _Out>; + + struct __copy_n_fn + { + template + requires indirectly_copyable<_Iter, _Out> + constexpr copy_n_result<_Iter, _Out> + operator()(_Iter __first, iter_difference_t<_Iter> __n, + _Out __result) const + { + if constexpr (random_access_iterator<_Iter>) + { + if (__n > 0) + return ranges::copy(__first, __first + __n, std::move(__result)); + } + else + { + for (; __n > 0; --__n, (void)++__result, (void)++__first) + *__result = *__first; + } + return {std::move(__first), std::move(__result)}; + } + }; + + inline constexpr __copy_n_fn copy_n{}; + + struct __fill_n_fn + { + template _Out> + constexpr _Out + operator()(_Out __first, iter_difference_t<_Out> __n, + const _Tp& __value) const + { + // TODO: implement more specializations to be at least on par with + // std::fill_n + if (__n <= 0) + return __first; + + // TODO: Generalize this optimization to contiguous iterators. + if constexpr (is_pointer_v<_Out> + // Note that __is_byte already implies !is_volatile. + && __is_byte>::__value + && integral<_Tp>) + { + __builtin_memset(__first, static_cast(__value), __n); + return __first + __n; + } + else if constexpr (is_scalar_v<_Tp>) + { + const auto __tmp = __value; + for (; __n > 0; --__n, (void)++__first) + *__first = __tmp; + return __first; + } + else + { + for (; __n > 0; --__n, (void)++__first) + *__first = __value; + return __first; + } + } + }; + + inline constexpr __fill_n_fn fill_n{}; + + struct __fill_fn + { + template _Out, sentinel_for<_Out> _Sent> + constexpr _Out + operator()(_Out __first, _Sent __last, const _Tp& __value) const + { + // TODO: implement more specializations to be at least on par with + // std::fill + if constexpr (sized_sentinel_for<_Sent, _Out>) + { + const auto __len = __last - __first; + return ranges::fill_n(__first, __len, __value); + } + else if constexpr (is_scalar_v<_Tp>) + { + const auto __tmp = __value; + for (; __first != __last; ++__first) + *__first = __tmp; + return __first; + } + else + { + for (; __first != __last; ++__first) + *__first = __value; + return __first; + } + } + + template _Range> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, const _Tp& __value) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), __value); + } + }; + + inline constexpr __fill_fn fill{}; +} +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // concepts +#endif // C++20 +#endif // _RANGES_ALGOBASE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_base.h new file mode 100755 index 0000000..a63ef8e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_base.h @@ -0,0 +1,898 @@ +// Core concepts and definitions for -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ranges_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ranges} + */ + +#ifndef _GLIBCXX_RANGES_BASE_H +#define _GLIBCXX_RANGES_BASE_H 1 + +#pragma GCC system_header + +#if __cplusplus > 201703L +#include +#include +#include + +#ifdef __cpp_lib_concepts +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace ranges +{ + template + inline constexpr bool disable_sized_range = false; + + template + inline constexpr bool enable_borrowed_range = false; + + namespace __detail + { + constexpr __max_size_type + __to_unsigned_like(__max_size_type __t) noexcept + { return __t; } + + constexpr __max_size_type + __to_unsigned_like(__max_diff_type __t) noexcept + { return __max_size_type(__t); } + + template + constexpr auto + __to_unsigned_like(_Tp __t) noexcept + { return static_cast>(__t); } + +#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + constexpr unsigned __int128 + __to_unsigned_like(__int128 __t) noexcept + { return __t; } + + constexpr unsigned __int128 + __to_unsigned_like(unsigned __int128 __t) noexcept + { return __t; } +#endif + + template + using __make_unsigned_like_t + = decltype(__detail::__to_unsigned_like(std::declval<_Tp>())); + + // Part of the constraints of ranges::borrowed_range + template + concept __maybe_borrowed_range + = is_lvalue_reference_v<_Tp> + || enable_borrowed_range>; + + } // namespace __detail + + namespace __cust_access + { + using std::ranges::__detail::__maybe_borrowed_range; + using std::__detail::__range_iter_t; + + struct _Begin + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (is_array_v>) + return true; + else if constexpr (__member_begin<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().begin())); + else + return noexcept(__decay_copy(begin(std::declval<_Tp&>()))); + } + + public: + template<__maybe_borrowed_range _Tp> + requires is_array_v> || __member_begin<_Tp> + || __adl_begin<_Tp> + constexpr auto + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>()) + { + if constexpr (is_array_v>) + { + static_assert(is_lvalue_reference_v<_Tp>); + return __t + 0; + } + else if constexpr (__member_begin<_Tp>) + return __t.begin(); + else + return begin(__t); + } + }; + + template + concept __member_end = requires(_Tp& __t) + { + { __decay_copy(__t.end()) } -> sentinel_for<__range_iter_t<_Tp>>; + }; + + // Poison pills so that unqualified lookup doesn't find std::end. + void end(auto&) = delete; + void end(const auto&) = delete; + + template + concept __adl_end = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(end(__t)) } -> sentinel_for<__range_iter_t<_Tp>>; + }; + + struct _End + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (is_bounded_array_v>) + return true; + else if constexpr (__member_end<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().end())); + else + return noexcept(__decay_copy(end(std::declval<_Tp&>()))); + } + + public: + template<__maybe_borrowed_range _Tp> + requires is_bounded_array_v> + || __member_end<_Tp> || __adl_end<_Tp> + constexpr auto + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>()) + { + if constexpr (is_bounded_array_v>) + { + static_assert(is_lvalue_reference_v<_Tp>); + return __t + extent_v>; + } + else if constexpr (__member_end<_Tp>) + return __t.end(); + else + return end(__t); + } + }; + + // If _To is an lvalue-reference, return const _Tp&, otherwise const _Tp&&. + template + constexpr decltype(auto) + __as_const(_Tp& __t) noexcept + { + static_assert(std::is_same_v<_To&, _Tp&>); + + if constexpr (is_lvalue_reference_v<_To>) + return const_cast(__t); + else + return static_cast(__t); + } + + struct _CBegin + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Begin{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _Begin{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _Begin{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + struct _CEnd + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_End{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _End{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _End{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + template + concept __member_rbegin = requires(_Tp& __t) + { + { __decay_copy(__t.rbegin()) } -> input_or_output_iterator; + }; + + void rbegin(auto&) = delete; + void rbegin(const auto&) = delete; + + template + concept __adl_rbegin = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(rbegin(__t)) } -> input_or_output_iterator; + }; + + template + concept __reversable = requires(_Tp& __t) + { + { _Begin{}(__t) } -> bidirectional_iterator; + { _End{}(__t) } -> same_as; + }; + + struct _RBegin + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_rbegin<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().rbegin())); + else if constexpr (__adl_rbegin<_Tp>) + return noexcept(__decay_copy(rbegin(std::declval<_Tp&>()))); + else + { + if constexpr (noexcept(_End{}(std::declval<_Tp&>()))) + { + using _It = decltype(_End{}(std::declval<_Tp&>())); + // std::reverse_iterator copy-initializes its member. + return is_nothrow_copy_constructible_v<_It>; + } + else + return false; + } + } + + public: + template<__maybe_borrowed_range _Tp> + requires __member_rbegin<_Tp> || __adl_rbegin<_Tp> || __reversable<_Tp> + constexpr auto + operator()(_Tp&& __t) const + noexcept(_S_noexcept<_Tp&>()) + { + if constexpr (__member_rbegin<_Tp>) + return __t.rbegin(); + else if constexpr (__adl_rbegin<_Tp>) + return rbegin(__t); + else + return std::make_reverse_iterator(_End{}(__t)); + } + }; + + template + concept __member_rend = requires(_Tp& __t) + { + { __decay_copy(__t.rend()) } + -> sentinel_for(__t)))>; + }; + + void rend(auto&) = delete; + void rend(const auto&) = delete; + + template + concept __adl_rend = __class_or_enum> + && requires(_Tp& __t) + { + { __decay_copy(rend(__t)) } + -> sentinel_for(__t)))>; + }; + + struct _REnd + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_rend<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().rend())); + else if constexpr (__adl_rend<_Tp>) + return noexcept(__decay_copy(rend(std::declval<_Tp&>()))); + else + { + if constexpr (noexcept(_Begin{}(std::declval<_Tp&>()))) + { + using _It = decltype(_Begin{}(std::declval<_Tp&>())); + // std::reverse_iterator copy-initializes its member. + return is_nothrow_copy_constructible_v<_It>; + } + else + return false; + } + } + + public: + template<__maybe_borrowed_range _Tp> + requires __member_rend<_Tp> || __adl_rend<_Tp> || __reversable<_Tp> + constexpr auto + operator()(_Tp&& __t) const + noexcept(_S_noexcept<_Tp&>()) + { + if constexpr (__member_rend<_Tp>) + return __t.rend(); + else if constexpr (__adl_rend<_Tp>) + return rend(__t); + else + return std::make_reverse_iterator(_Begin{}(__t)); + } + }; + + struct _CRBegin + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_RBegin{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _RBegin{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _RBegin{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + struct _CREnd + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_REnd{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _REnd{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _REnd{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + template + concept __member_size = !disable_sized_range> + && requires(_Tp& __t) + { + { __decay_copy(__t.size()) } -> __detail::__is_integer_like; + }; + + void size(auto&) = delete; + void size(const auto&) = delete; + + template + concept __adl_size = __class_or_enum> + && !disable_sized_range> + && requires(_Tp& __t) + { + { __decay_copy(size(__t)) } -> __detail::__is_integer_like; + }; + + template + concept __sentinel_size = requires(_Tp& __t) + { + { _Begin{}(__t) } -> forward_iterator; + + { _End{}(__t) } -> sized_sentinel_for; + + __detail::__to_unsigned_like(_End{}(__t) - _Begin{}(__t)); + }; + + struct _Size + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (is_bounded_array_v>) + return true; + else if constexpr (__member_size<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().size())); + else if constexpr (__adl_size<_Tp>) + return noexcept(__decay_copy(size(std::declval<_Tp&>()))); + else if constexpr (__sentinel_size<_Tp>) + return noexcept(_End{}(std::declval<_Tp&>()) + - _Begin{}(std::declval<_Tp&>())); + } + + public: + template + requires is_bounded_array_v> + || __member_size<_Tp> || __adl_size<_Tp> || __sentinel_size<_Tp> + constexpr auto + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>()) + { + if constexpr (is_bounded_array_v>) + return extent_v>; + else if constexpr (__member_size<_Tp>) + return __t.size(); + else if constexpr (__adl_size<_Tp>) + return size(__t); + else if constexpr (__sentinel_size<_Tp>) + return __detail::__to_unsigned_like(_End{}(__t) - _Begin{}(__t)); + } + }; + + struct _SSize + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3403. Domain of ranges::ssize(E) doesn't match ranges::size(E) + template + requires requires (_Tp& __t) { _Size{}(__t); } + constexpr auto + operator()(_Tp&& __t) const noexcept(noexcept(_Size{}(__t))) + { + auto __size = _Size{}(__t); + using __size_type = decltype(__size); + // Return the wider of ptrdiff_t and make-signed-like-t<__size_type>. + if constexpr (integral<__size_type>) + { + using __gnu_cxx::__int_traits; + if constexpr (__int_traits<__size_type>::__digits + < __int_traits::__digits) + return static_cast(__size); + else + return static_cast>(__size); + } +#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__ + // For strict-ansi modes integral<__int128> is false + else if constexpr (__detail::__is_int128<__size_type>) + return static_cast<__int128>(__size); +#endif + else // Must be one of __max_diff_type or __max_size_type. + return __detail::__max_diff_type(__size); + } + }; + + template + concept __member_empty = requires(_Tp& __t) { bool(__t.empty()); }; + + template + concept __size0_empty = requires(_Tp& __t) { _Size{}(__t) == 0; }; + + template + concept __eq_iter_empty = requires(_Tp& __t) + { + { _Begin{}(__t) } -> forward_iterator; + + bool(_Begin{}(__t) == _End{}(__t)); + }; + + struct _Empty + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_empty<_Tp>) + return noexcept(bool(std::declval<_Tp&>().empty())); + else if constexpr (__size0_empty<_Tp>) + return noexcept(_Size{}(std::declval<_Tp&>()) == 0); + else + return noexcept(bool(_Begin{}(std::declval<_Tp&>()) + == _End{}(std::declval<_Tp&>()))); + } + + public: + template + requires __member_empty<_Tp> || __size0_empty<_Tp> + || __eq_iter_empty<_Tp> + constexpr bool + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp&>()) + { + if constexpr (__member_empty<_Tp>) + return bool(__t.empty()); + else if constexpr (__size0_empty<_Tp>) + return _Size{}(__t) == 0; + else + return bool(_Begin{}(__t) == _End{}(__t)); + } + }; + + template + concept __pointer_to_object = is_pointer_v<_Tp> + && is_object_v>; + + template + concept __member_data = requires(_Tp& __t) + { + { __decay_copy(__t.data()) } -> __pointer_to_object; + }; + + template + concept __begin_data = contiguous_iterator<__range_iter_t<_Tp>>; + + struct _Data + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__member_data<_Tp>) + return noexcept(__decay_copy(std::declval<_Tp&>().data())); + else + return noexcept(_Begin{}(std::declval<_Tp&>())); + } + + public: + template<__maybe_borrowed_range _Tp> + requires __member_data<_Tp> || __begin_data<_Tp> + constexpr auto + operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>()) + { + if constexpr (__member_data<_Tp>) + return __t.data(); + else + return std::to_address(_Begin{}(__t)); + } + }; + + struct _CData + { + template + constexpr auto + operator()(_Tp&& __e) const + noexcept(noexcept(_Data{}(__cust_access::__as_const<_Tp>(__e)))) + requires requires { _Data{}(__cust_access::__as_const<_Tp>(__e)); } + { + return _Data{}(__cust_access::__as_const<_Tp>(__e)); + } + }; + + } // namespace __cust_access + + inline namespace __cust + { + inline constexpr __cust_access::_Begin begin{}; + inline constexpr __cust_access::_End end{}; + inline constexpr __cust_access::_CBegin cbegin{}; + inline constexpr __cust_access::_CEnd cend{}; + inline constexpr __cust_access::_RBegin rbegin{}; + inline constexpr __cust_access::_REnd rend{}; + inline constexpr __cust_access::_CRBegin crbegin{}; + inline constexpr __cust_access::_CREnd crend{}; + inline constexpr __cust_access::_Size size{}; + inline constexpr __cust_access::_SSize ssize{}; + inline constexpr __cust_access::_Empty empty{}; + inline constexpr __cust_access::_Data data{}; + inline constexpr __cust_access::_CData cdata{}; + } + + /// [range.range] The range concept. + template + concept range = requires(_Tp& __t) + { + ranges::begin(__t); + ranges::end(__t); + }; + + /// [range.range] The borrowed_range concept. + template + concept borrowed_range + = range<_Tp> && __detail::__maybe_borrowed_range<_Tp>; + + template + using iterator_t = std::__detail::__range_iter_t<_Tp>; + + template + using sentinel_t = decltype(ranges::end(std::declval<_Range&>())); + + template + using range_difference_t = iter_difference_t>; + + template + using range_value_t = iter_value_t>; + + template + using range_reference_t = iter_reference_t>; + + template + using range_rvalue_reference_t + = iter_rvalue_reference_t>; + + /// [range.sized] The sized_range concept. + template + concept sized_range = range<_Tp> + && requires(_Tp& __t) { ranges::size(__t); }; + + template + using range_size_t = decltype(ranges::size(std::declval<_Range&>())); + + /// [range.view] The ranges::view_base type. + struct view_base { }; + + /// [range.view] The ranges::enable_view boolean. + template + inline constexpr bool enable_view = derived_from<_Tp, view_base>; + + /// [range.view] The ranges::view concept. + template + concept view + = range<_Tp> && movable<_Tp> && default_initializable<_Tp> + && enable_view<_Tp>; + + // [range.refinements] + + /// A range for which ranges::begin returns an output iterator. + template + concept output_range + = range<_Range> && output_iterator, _Tp>; + + /// A range for which ranges::begin returns an input iterator. + template + concept input_range = range<_Tp> && input_iterator>; + + /// A range for which ranges::begin returns a forward iterator. + template + concept forward_range + = input_range<_Tp> && forward_iterator>; + + /// A range for which ranges::begin returns a bidirectional iterator. + template + concept bidirectional_range + = forward_range<_Tp> && bidirectional_iterator>; + + /// A range for which ranges::begin returns a random access iterator. + template + concept random_access_range + = bidirectional_range<_Tp> && random_access_iterator>; + + /// A range for which ranges::begin returns a contiguous iterator. + template + concept contiguous_range + = random_access_range<_Tp> && contiguous_iterator> + && requires(_Tp& __t) + { + { ranges::data(__t) } -> same_as>>; + }; + + /// A range for which ranges::begin and ranges::end return the same type. + template + concept common_range + = range<_Tp> && same_as, sentinel_t<_Tp>>; + + /// A range which can be safely converted to a view. + template + concept viewable_range = range<_Tp> + && (borrowed_range<_Tp> || view>); + + // [range.iter.ops] range iterator operations + + struct __advance_fn + { + template + constexpr void + operator()(_It& __it, iter_difference_t<_It> __n) const + { + if constexpr (random_access_iterator<_It>) + __it += __n; + else if constexpr (bidirectional_iterator<_It>) + { + if (__n > 0) + { + do + { + ++__it; + } + while (--__n); + } + else if (__n < 0) + { + do + { + --__it; + } + while (++__n); + } + } + else + { + // cannot decrement a non-bidirectional iterator + __glibcxx_assert(__n >= 0); + while (__n-- > 0) + ++__it; + } + } + + template _Sent> + constexpr void + operator()(_It& __it, _Sent __bound) const + { + if constexpr (assignable_from<_It&, _Sent>) + __it = std::move(__bound); + else if constexpr (sized_sentinel_for<_Sent, _It>) + (*this)(__it, __bound - __it); + else + { + while (__it != __bound) + ++__it; + } + } + + template _Sent> + constexpr iter_difference_t<_It> + operator()(_It& __it, iter_difference_t<_It> __n, _Sent __bound) const + { + if constexpr (sized_sentinel_for<_Sent, _It>) + { + const auto __diff = __bound - __it; + + // n and bound must not lead in opposite directions: + __glibcxx_assert(__n == 0 || __diff == 0 || (__n < 0 == __diff < 0)); + const auto __absdiff = __diff < 0 ? -__diff : __diff; + const auto __absn = __n < 0 ? -__n : __n;; + if (__absn >= __absdiff) + { + (*this)(__it, __bound); + return __n - __diff; + } + else + { + (*this)(__it, __n); + return 0; + } + } + else if (__it == __bound || __n == 0) + return __n; + else if (__n > 0) + { + iter_difference_t<_It> __m = 0; + do + { + ++__it; + ++__m; + } + while (__m != __n && __it != __bound); + return __n - __m; + } + else if constexpr (bidirectional_iterator<_It> && same_as<_It, _Sent>) + { + iter_difference_t<_It> __m = 0; + do + { + --__it; + --__m; + } + while (__m != __n && __it != __bound); + return __n - __m; + } + else + { + // cannot decrement a non-bidirectional iterator + __glibcxx_assert(__n >= 0); + return __n; + } + } + }; + + inline constexpr __advance_fn advance{}; + + struct __distance_fn + { + template _Sent> + constexpr iter_difference_t<_It> + operator()(_It __first, _Sent __last) const + { + if constexpr (sized_sentinel_for<_Sent, _It>) + return __last - __first; + else + { + iter_difference_t<_It> __n = 0; + while (__first != __last) + { + ++__first; + ++__n; + } + return __n; + } + } + + template + constexpr range_difference_t<_Range> + operator()(_Range&& __r) const + { + if constexpr (sized_range<_Range>) + return static_cast>(ranges::size(__r)); + else + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + }; + + inline constexpr __distance_fn distance{}; + + struct __next_fn + { + template + constexpr _It + operator()(_It __x) const + { + ++__x; + return __x; + } + + template + constexpr _It + operator()(_It __x, iter_difference_t<_It> __n) const + { + ranges::advance(__x, __n); + return __x; + } + + template _Sent> + constexpr _It + operator()(_It __x, _Sent __bound) const + { + ranges::advance(__x, __bound); + return __x; + } + + template _Sent> + constexpr _It + operator()(_It __x, iter_difference_t<_It> __n, _Sent __bound) const + { + ranges::advance(__x, __n, __bound); + return __x; + } + }; + + inline constexpr __next_fn next{}; + + struct __prev_fn + { + template + constexpr _It + operator()(_It __x) const + { + --__x; + return __x; + } + + template + constexpr _It + operator()(_It __x, iter_difference_t<_It> __n) const + { + ranges::advance(__x, -__n); + return __x; + } + + template + constexpr _It + operator()(_It __x, iter_difference_t<_It> __n, _It __bound) const + { + ranges::advance(__x, -__n, __bound); + return __x; + } + }; + + inline constexpr __prev_fn prev{}; + + /// Type returned by algorithms instead of a dangling iterator or subrange. + struct dangling + { + constexpr dangling() noexcept = default; + template + constexpr dangling(_Args&&...) noexcept { } + }; + + template + using borrowed_iterator_t = conditional_t, + iterator_t<_Range>, + dangling>; + +} // namespace ranges +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // library concepts +#endif // C++20 +#endif // _GLIBCXX_RANGES_BASE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_cmp.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_cmp.h new file mode 100755 index 0000000..f859a33 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_cmp.h @@ -0,0 +1,183 @@ +// Concept-constrained comparison implementations -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ranges_cmp.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _RANGES_CMP_H +#define _RANGES_CMP_H 1 + +#if __cplusplus > 201703L +# include +# include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + struct __is_transparent; // not defined + + // Define std::identity here so that and + // don't need to include to get it. + + /// [func.identity] The identity function. + struct identity + { + template + [[nodiscard]] + constexpr _Tp&& + operator()(_Tp&& __t) const noexcept + { return std::forward<_Tp>(__t); } + + using is_transparent = __is_transparent; + }; + +#ifdef __cpp_lib_concepts +// Define this here, included by all the headers that need to define it. +#define __cpp_lib_ranges 201911L + +namespace ranges +{ + namespace __detail + { + // BUILTIN-PTR-CMP(T, <, U) + // This determines whether t < u results in a call to a built-in operator< + // comparing pointers. It doesn't work for function pointers (PR 93628). + template + concept __less_builtin_ptr_cmp + = requires (_Tp&& __t, _Up&& __u) { { __t < __u } -> same_as; } + && convertible_to<_Tp, const volatile void*> + && convertible_to<_Up, const volatile void*> + && (! requires(_Tp&& __t, _Up&& __u) + { operator<(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + && ! requires(_Tp&& __t, _Up&& __u) + { std::forward<_Tp>(__t).operator<(std::forward<_Up>(__u)); }); + } // namespace __detail + + // [range.cmp] Concept-constrained comparisons + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3530 BUILTIN-PTR-MEOW should not opt the type out of syntactic checks + + /// ranges::equal_to function object type. + struct equal_to + { + template + requires equality_comparable_with<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() == std::declval<_Up>())) + { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); } + + using is_transparent = __is_transparent; + }; + + /// ranges::not_equal_to function object type. + struct not_equal_to + { + template + requires equality_comparable_with<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Up>() == std::declval<_Tp>())) + { return !equal_to{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + + using is_transparent = __is_transparent; + }; + + /// ranges::less function object type. + struct less + { + template + requires totally_ordered_with<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>())) + { + if constexpr (__detail::__less_builtin_ptr_cmp<_Tp, _Up>) + { +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return __t < __u; +#endif + auto __x = reinterpret_cast<__UINTPTR_TYPE__>( + static_cast(std::forward<_Tp>(__t))); + auto __y = reinterpret_cast<__UINTPTR_TYPE__>( + static_cast(std::forward<_Up>(__u))); + return __x < __y; + } + else + return std::forward<_Tp>(__t) < std::forward<_Up>(__u); + } + + using is_transparent = __is_transparent; + }; + + /// ranges::greater function object type. + struct greater + { + template + requires totally_ordered_with<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>())) + { return less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); } + + using is_transparent = __is_transparent; + }; + + /// ranges::greater_equal function object type. + struct greater_equal + { + template + requires totally_ordered_with<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() < std::declval<_Up>())) + { return !less{}(std::forward<_Tp>(__t), std::forward<_Up>(__u)); } + + using is_transparent = __is_transparent; + }; + + /// ranges::less_equal function object type. + struct less_equal + { + template + requires totally_ordered_with<_Tp, _Up> + constexpr bool + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Up>() < std::declval<_Tp>())) + { return !less{}(std::forward<_Up>(__u), std::forward<_Tp>(__t)); } + + using is_transparent = __is_transparent; + }; + +} // namespace ranges +#endif // library concepts +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 +#endif // _RANGES_CMP_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_uninitialized.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_uninitialized.h new file mode 100755 index 0000000..0a46fba --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_uninitialized.h @@ -0,0 +1,574 @@ +// Raw memory manipulators -*- C++ -*- + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ranges_uninitialized.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _RANGES_UNINITIALIZED_H +#define _RANGES_UNINITIALIZED_H 1 + +#if __cplusplus > 201703L +#if __cpp_lib_concepts + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace ranges +{ + namespace __detail + { + template + constexpr void* + __voidify(_Tp& __obj) noexcept + { + return const_cast + (static_cast(std::__addressof(__obj))); + } + + template + concept __nothrow_input_iterator + = (input_iterator<_Iter> + && is_lvalue_reference_v> + && same_as>, + iter_value_t<_Iter>>); + + template + concept __nothrow_sentinel = sentinel_for<_Sent, _Iter>; + + template + concept __nothrow_input_range + = (range<_Range> + && __nothrow_input_iterator> + && __nothrow_sentinel, iterator_t<_Range>>); + + template + concept __nothrow_forward_iterator + = (__nothrow_input_iterator<_Iter> + && forward_iterator<_Iter> + && __nothrow_sentinel<_Iter, _Iter>); + + template + concept __nothrow_forward_range + = (__nothrow_input_range<_Range> + && __nothrow_forward_iterator>); + } // namespace __detail + + struct __destroy_fn + { + template<__detail::__nothrow_input_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires destructible> + constexpr _Iter + operator()(_Iter __first, _Sent __last) const noexcept; + + template<__detail::__nothrow_input_range _Range> + requires destructible> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r) const noexcept; + }; + + inline constexpr __destroy_fn destroy{}; + + namespace __detail + { + template + requires destructible> + struct _DestroyGuard + { + private: + _Iter _M_first; + const _Iter* _M_cur; + + public: + explicit + _DestroyGuard(const _Iter* __iter) + : _M_first(*__iter), _M_cur(__iter) + { } + + void + release() noexcept + { _M_cur = nullptr; } + + ~_DestroyGuard() + { + if (_M_cur != nullptr) + ranges::destroy(std::move(_M_first), *_M_cur); + } + }; + + template + requires destructible> + && is_trivially_destructible_v> + struct _DestroyGuard<_Iter> + { + explicit + _DestroyGuard(const _Iter*) + { } + + void + release() noexcept + { } + }; + } // namespace __detail + + struct __uninitialized_default_construct_fn + { + template<__detail::__nothrow_forward_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires default_initializable> + _Iter + operator()(_Iter __first, _Sent __last) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivially_default_constructible_v<_ValueType>) + return ranges::next(__first, __last); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __first != __last; ++__first) + ::new (__detail::__voidify(*__first)) _ValueType; + __guard.release(); + return __first; + } + } + + template<__detail::__nothrow_forward_range _Range> + requires default_initializable> + borrowed_iterator_t<_Range> + operator()(_Range&& __r) const + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + }; + + inline constexpr __uninitialized_default_construct_fn + uninitialized_default_construct{}; + + struct __uninitialized_default_construct_n_fn + { + template<__detail::__nothrow_forward_iterator _Iter> + requires default_initializable> + _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivially_default_constructible_v<_ValueType>) + return ranges::next(__first, __n); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __n > 0; ++__first, (void) --__n) + ::new (__detail::__voidify(*__first)) _ValueType; + __guard.release(); + return __first; + } + } + }; + + inline constexpr __uninitialized_default_construct_n_fn + uninitialized_default_construct_n; + + struct __uninitialized_value_construct_fn + { + template<__detail::__nothrow_forward_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires default_initializable> + _Iter + operator()(_Iter __first, _Sent __last) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_copy_assignable_v<_ValueType>) + return ranges::fill(__first, __last, _ValueType()); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __first != __last; ++__first) + ::new (__detail::__voidify(*__first)) _ValueType(); + __guard.release(); + return __first; + } + } + + template<__detail::__nothrow_forward_range _Range> + requires default_initializable> + borrowed_iterator_t<_Range> + operator()(_Range&& __r) const + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + }; + + inline constexpr __uninitialized_value_construct_fn + uninitialized_value_construct{}; + + struct __uninitialized_value_construct_n_fn + { + template<__detail::__nothrow_forward_iterator _Iter> + requires default_initializable> + _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_copy_assignable_v<_ValueType>) + return ranges::fill_n(__first, __n, _ValueType()); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __n > 0; ++__first, (void) --__n) + ::new (__detail::__voidify(*__first)) _ValueType(); + __guard.release(); + return __first; + } + } + }; + + inline constexpr __uninitialized_value_construct_n_fn + uninitialized_value_construct_n; + + template + using uninitialized_copy_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_copy_fn + { + template _ISent, + __detail::__nothrow_forward_iterator _Out, + __detail::__nothrow_sentinel<_Out> _OSent> + requires constructible_from, iter_reference_t<_Iter>> + uninitialized_copy_result<_Iter, _Out> + operator()(_Iter __ifirst, _ISent __ilast, + _Out __ofirst, _OSent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_ISent, _Iter> + && sized_sentinel_for<_OSent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_reference_t<_Iter>>) + { + auto __d1 = __ilast - __ifirst; + auto __d2 = __olast - __ofirst; + return ranges::copy_n(std::move(__ifirst), std::min(__d1, __d2), + __ofirst); + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __ifirst != __ilast && __ofirst != __olast; + ++__ofirst, (void)++__ifirst) + ::new (__detail::__voidify(*__ofirst)) _OutType(*__ifirst); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + + template + requires constructible_from, + range_reference_t<_IRange>> + uninitialized_copy_result, + borrowed_iterator_t<_ORange>> + operator()(_IRange&& __inr, _ORange&& __outr) const + { + return (*this)(ranges::begin(__inr), ranges::end(__inr), + ranges::begin(__outr), ranges::end(__outr)); + } + }; + + inline constexpr __uninitialized_copy_fn uninitialized_copy{}; + + template + using uninitialized_copy_n_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_copy_n_fn + { + template _Sent> + requires constructible_from, iter_reference_t<_Iter>> + uninitialized_copy_n_result<_Iter, _Out> + operator()(_Iter __ifirst, iter_difference_t<_Iter> __n, + _Out __ofirst, _Sent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_Sent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_reference_t<_Iter>>) + { + auto __d = __olast - __ofirst; + return ranges::copy_n(std::move(__ifirst), std::min(__n, __d), + __ofirst); + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __n > 0 && __ofirst != __olast; + ++__ofirst, (void)++__ifirst, (void)--__n) + ::new (__detail::__voidify(*__ofirst)) _OutType(*__ifirst); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + }; + + inline constexpr __uninitialized_copy_n_fn uninitialized_copy_n{}; + + template + using uninitialized_move_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_move_fn + { + template _ISent, + __detail::__nothrow_forward_iterator _Out, + __detail::__nothrow_sentinel<_Out> _OSent> + requires constructible_from, + iter_rvalue_reference_t<_Iter>> + uninitialized_move_result<_Iter, _Out> + operator()(_Iter __ifirst, _ISent __ilast, + _Out __ofirst, _OSent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_ISent, _Iter> + && sized_sentinel_for<_OSent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_rvalue_reference_t<_Iter>>) + { + auto __d1 = __ilast - __ifirst; + auto __d2 = __olast - __ofirst; + auto [__in, __out] + = ranges::copy_n(std::make_move_iterator(std::move(__ifirst)), + std::min(__d1, __d2), __ofirst); + return {std::move(__in).base(), __out}; + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __ifirst != __ilast && __ofirst != __olast; + ++__ofirst, (void)++__ifirst) + ::new (__detail::__voidify(*__ofirst)) + _OutType(ranges::iter_move(__ifirst)); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + + template + requires constructible_from, + range_rvalue_reference_t<_IRange>> + uninitialized_move_result, + borrowed_iterator_t<_ORange>> + operator()(_IRange&& __inr, _ORange&& __outr) const + { + return (*this)(ranges::begin(__inr), ranges::end(__inr), + ranges::begin(__outr), ranges::end(__outr)); + } + }; + + inline constexpr __uninitialized_move_fn uninitialized_move{}; + + template + using uninitialized_move_n_result = in_out_result<_Iter, _Out>; + + struct __uninitialized_move_n_fn + { + template _Sent> + requires constructible_from, + iter_rvalue_reference_t<_Iter>> + uninitialized_move_n_result<_Iter, _Out> + operator()(_Iter __ifirst, iter_difference_t<_Iter> __n, + _Out __ofirst, _Sent __olast) const + { + using _OutType = remove_reference_t>; + if constexpr (sized_sentinel_for<_Sent, _Out> + && is_trivial_v<_OutType> + && is_nothrow_assignable_v<_OutType&, + iter_rvalue_reference_t<_Iter>>) + { + auto __d = __olast - __ofirst; + auto [__in, __out] + = ranges::copy_n(std::make_move_iterator(std::move(__ifirst)), + std::min(__n, __d), __ofirst); + return {std::move(__in).base(), __out}; + } + else + { + auto __guard = __detail::_DestroyGuard(&__ofirst); + for (; __n > 0 && __ofirst != __olast; + ++__ofirst, (void)++__ifirst, (void)--__n) + ::new (__detail::__voidify(*__ofirst)) + _OutType(ranges::iter_move(__ifirst)); + __guard.release(); + return {std::move(__ifirst), __ofirst}; + } + } + }; + + inline constexpr __uninitialized_move_n_fn uninitialized_move_n{}; + + struct __uninitialized_fill_fn + { + template<__detail::__nothrow_forward_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent, typename _Tp> + requires constructible_from, const _Tp&> + _Iter + operator()(_Iter __first, _Sent __last, const _Tp& __x) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_nothrow_assignable_v<_ValueType&, const _Tp&>) + return ranges::fill(__first, __last, __x); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __first != __last; ++__first) + ::new (__detail::__voidify(*__first)) _ValueType(__x); + __guard.release(); + return __first; + } + } + + template<__detail::__nothrow_forward_range _Range, typename _Tp> + requires constructible_from, const _Tp&> + borrowed_iterator_t<_Range> + operator()(_Range&& __r, const _Tp& __x) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), __x); + } + }; + + inline constexpr __uninitialized_fill_fn uninitialized_fill{}; + + struct __uninitialized_fill_n_fn + { + template<__detail::__nothrow_forward_iterator _Iter, typename _Tp> + requires constructible_from, const _Tp&> + _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n, + const _Tp& __x) const + { + using _ValueType = remove_reference_t>; + if constexpr (is_trivial_v<_ValueType> + && is_nothrow_assignable_v<_ValueType&, const _Tp&>) + return ranges::fill_n(__first, __n, __x); + else + { + auto __guard = __detail::_DestroyGuard(&__first); + for (; __n > 0; ++__first, (void)--__n) + ::new (__detail::__voidify(*__first)) _ValueType(__x); + __guard.release(); + return __first; + } + } + }; + + inline constexpr __uninitialized_fill_n_fn uninitialized_fill_n{}; + + struct __construct_at_fn + { + template + requires requires { + ::new (std::declval()) _Tp(std::declval<_Args>()...); + } + constexpr _Tp* + operator()(_Tp* __location, _Args&&... __args) const + noexcept(noexcept(std::construct_at(__location, + std::forward<_Args>(__args)...))) + { + return std::construct_at(__location, + std::forward<_Args>(__args)...); + } + }; + + inline constexpr __construct_at_fn construct_at{}; + + struct __destroy_at_fn + { + template + constexpr void + operator()(_Tp* __location) const noexcept + { + if constexpr (is_array_v<_Tp>) + ranges::destroy(ranges::begin(*__location), ranges::end(*__location)); + else + __location->~_Tp(); + } + }; + + inline constexpr __destroy_at_fn destroy_at{}; + + template<__detail::__nothrow_input_iterator _Iter, + __detail::__nothrow_sentinel<_Iter> _Sent> + requires destructible> + constexpr _Iter + __destroy_fn::operator()(_Iter __first, _Sent __last) const noexcept + { + if constexpr (is_trivially_destructible_v>) + return ranges::next(std::move(__first), __last); + else + { + for (; __first != __last; ++__first) + ranges::destroy_at(std::__addressof(*__first)); + return __first; + } + } + + template<__detail::__nothrow_input_range _Range> + requires destructible> + constexpr borrowed_iterator_t<_Range> + __destroy_fn::operator()(_Range&& __r) const noexcept + { + return (*this)(ranges::begin(__r), ranges::end(__r)); + } + + struct __destroy_n_fn + { + template<__detail::__nothrow_input_iterator _Iter> + requires destructible> + constexpr _Iter + operator()(_Iter __first, iter_difference_t<_Iter> __n) const noexcept + { + if constexpr (is_trivially_destructible_v>) + return ranges::next(std::move(__first), __n); + else + { + for (; __n > 0; ++__first, (void)--__n) + ranges::destroy_at(std::__addressof(*__first)); + return __first; + } + } + }; + + inline constexpr __destroy_n_fn destroy_n{}; +} +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // concepts +#endif // C++20 +#endif // _RANGES_UNINITIALIZED_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_util.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_util.h new file mode 100755 index 0000000..abbf48b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/ranges_util.h @@ -0,0 +1,642 @@ +// Utilities for representing and manipulating ranges -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/ranges_util.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{ranges} + */ + +#ifndef _RANGES_UTIL_H +#define _RANGES_UTIL_H 1 + +#if __cplusplus > 201703L +# include + +#ifdef __cpp_lib_ranges +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace ranges +{ + // C++20 24.5 [range.utility] Range utilities + + namespace __detail + { + template + concept __simple_view = view<_Range> && range + && same_as, iterator_t> + && same_as, sentinel_t>; + + template + concept __has_arrow = input_iterator<_It> + && (is_pointer_v<_It> || requires(_It __it) { __it.operator->(); }); + + template + concept __not_same_as + = !same_as, remove_cvref_t<_Up>>; + } // namespace __detail + + /// The ranges::view_interface class template + template + requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>> + class view_interface : public view_base + { + private: + constexpr _Derived& _M_derived() noexcept + { + static_assert(derived_from<_Derived, view_interface<_Derived>>); + static_assert(view<_Derived>); + return static_cast<_Derived&>(*this); + } + + constexpr const _Derived& _M_derived() const noexcept + { + static_assert(derived_from<_Derived, view_interface<_Derived>>); + static_assert(view<_Derived>); + return static_cast(*this); + } + + public: + constexpr bool + empty() requires forward_range<_Derived> + { return ranges::begin(_M_derived()) == ranges::end(_M_derived()); } + + constexpr bool + empty() const requires forward_range + { return ranges::begin(_M_derived()) == ranges::end(_M_derived()); } + + constexpr explicit + operator bool() requires requires { ranges::empty(_M_derived()); } + { return !ranges::empty(_M_derived()); } + + constexpr explicit + operator bool() const requires requires { ranges::empty(_M_derived()); } + { return !ranges::empty(_M_derived()); } + + constexpr auto + data() requires contiguous_iterator> + { return to_address(ranges::begin(_M_derived())); } + + constexpr auto + data() const + requires range + && contiguous_iterator> + { return to_address(ranges::begin(_M_derived())); } + + constexpr auto + size() + requires forward_range<_Derived> + && sized_sentinel_for, iterator_t<_Derived>> + { return ranges::end(_M_derived()) - ranges::begin(_M_derived()); } + + constexpr auto + size() const + requires forward_range + && sized_sentinel_for, + iterator_t> + { return ranges::end(_M_derived()) - ranges::begin(_M_derived()); } + + constexpr decltype(auto) + front() requires forward_range<_Derived> + { + __glibcxx_assert(!empty()); + return *ranges::begin(_M_derived()); + } + + constexpr decltype(auto) + front() const requires forward_range + { + __glibcxx_assert(!empty()); + return *ranges::begin(_M_derived()); + } + + constexpr decltype(auto) + back() + requires bidirectional_range<_Derived> && common_range<_Derived> + { + __glibcxx_assert(!empty()); + return *ranges::prev(ranges::end(_M_derived())); + } + + constexpr decltype(auto) + back() const + requires bidirectional_range + && common_range + { + __glibcxx_assert(!empty()); + return *ranges::prev(ranges::end(_M_derived())); + } + + template + constexpr decltype(auto) + operator[](range_difference_t<_Range> __n) + { return ranges::begin(_M_derived())[__n]; } + + template + constexpr decltype(auto) + operator[](range_difference_t<_Range> __n) const + { return ranges::begin(_M_derived())[__n]; } + }; + + namespace __detail + { + template + concept __convertible_to_non_slicing = convertible_to<_From, _To> + && !(is_pointer_v> && is_pointer_v> + && __not_same_as>, + remove_pointer_t>>); + + template + concept __pair_like + = !is_reference_v<_Tp> && requires(_Tp __t) + { + typename tuple_size<_Tp>::type; + requires derived_from, integral_constant>; + typename tuple_element_t<0, remove_const_t<_Tp>>; + typename tuple_element_t<1, remove_const_t<_Tp>>; + { get<0>(__t) } -> convertible_to&>; + { get<1>(__t) } -> convertible_to&>; + }; + + template + concept __pair_like_convertible_from + = !range<_Tp> && __pair_like<_Tp> + && constructible_from<_Tp, _Up, _Vp> + && __convertible_to_non_slicing<_Up, tuple_element_t<0, _Tp>> + && convertible_to<_Vp, tuple_element_t<1, _Tp>>; + + } // namespace __detail + + enum class subrange_kind : bool { unsized, sized }; + + /// The ranges::subrange class template + template _Sent = _It, + subrange_kind _Kind = sized_sentinel_for<_Sent, _It> + ? subrange_kind::sized : subrange_kind::unsized> + requires (_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _It>) + class subrange : public view_interface> + { + private: + // XXX: gcc complains when using constexpr here + static const bool _S_store_size + = _Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _It>; + + _It _M_begin = _It(); + [[no_unique_address]] _Sent _M_end = _Sent(); + + using __size_type + = __detail::__make_unsigned_like_t>; + + template + struct _Size + { }; + + template + struct _Size<_Tp, true> + { _Tp _M_size; }; + + [[no_unique_address]] _Size<__size_type> _M_size = {}; + + public: + subrange() = default; + + constexpr + subrange(__detail::__convertible_to_non_slicing<_It> auto __i, _Sent __s) + requires (!_S_store_size) + : _M_begin(std::move(__i)), _M_end(__s) + { } + + constexpr + subrange(__detail::__convertible_to_non_slicing<_It> auto __i, _Sent __s, + __size_type __n) + requires (_Kind == subrange_kind::sized) + : _M_begin(std::move(__i)), _M_end(__s) + { + if constexpr (_S_store_size) + _M_size._M_size = __n; + } + + template<__detail::__not_same_as _Rng> + requires borrowed_range<_Rng> + && __detail::__convertible_to_non_slicing, _It> + && convertible_to, _Sent> + constexpr + subrange(_Rng&& __r) requires _S_store_size && sized_range<_Rng> + : subrange(__r, ranges::size(__r)) + { } + + template<__detail::__not_same_as _Rng> + requires borrowed_range<_Rng> + && __detail::__convertible_to_non_slicing, _It> + && convertible_to, _Sent> + constexpr + subrange(_Rng&& __r) requires (!_S_store_size) + : subrange(ranges::begin(__r), ranges::end(__r)) + { } + + template + requires __detail::__convertible_to_non_slicing, _It> + && convertible_to, _Sent> + constexpr + subrange(_Rng&& __r, __size_type __n) + requires (_Kind == subrange_kind::sized) + : subrange{ranges::begin(__r), ranges::end(__r), __n} + { } + + template<__detail::__not_same_as _PairLike> + requires __detail::__pair_like_convertible_from<_PairLike, const _It&, + const _Sent&> + constexpr + operator _PairLike() const + { return _PairLike(_M_begin, _M_end); } + + constexpr _It + begin() const requires copyable<_It> + { return _M_begin; } + + [[nodiscard]] constexpr _It + begin() requires (!copyable<_It>) + { return std::move(_M_begin); } + + constexpr _Sent end() const { return _M_end; } + + constexpr bool empty() const { return _M_begin == _M_end; } + + constexpr __size_type + size() const requires (_Kind == subrange_kind::sized) + { + if constexpr (_S_store_size) + return _M_size._M_size; + else + return __detail::__to_unsigned_like(_M_end - _M_begin); + } + + [[nodiscard]] constexpr subrange + next(iter_difference_t<_It> __n = 1) const & + requires forward_iterator<_It> + { + auto __tmp = *this; + __tmp.advance(__n); + return __tmp; + } + + [[nodiscard]] constexpr subrange + next(iter_difference_t<_It> __n = 1) && + { + advance(__n); + return std::move(*this); + } + + [[nodiscard]] constexpr subrange + prev(iter_difference_t<_It> __n = 1) const + requires bidirectional_iterator<_It> + { + auto __tmp = *this; + __tmp.advance(-__n); + return __tmp; + } + + constexpr subrange& + advance(iter_difference_t<_It> __n) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3433. subrange::advance(n) has UB when n < 0 + if constexpr (bidirectional_iterator<_It>) + if (__n < 0) + { + ranges::advance(_M_begin, __n); + if constexpr (_S_store_size) + _M_size._M_size += __detail::__to_unsigned_like(-__n); + return *this; + } + + __glibcxx_assert(__n >= 0); + auto __d = __n - ranges::advance(_M_begin, __n, _M_end); + if constexpr (_S_store_size) + _M_size._M_size -= __detail::__to_unsigned_like(__d); + return *this; + } + }; + + template _Sent> + subrange(_It, _Sent) -> subrange<_It, _Sent>; + + template _Sent> + subrange(_It, _Sent, + __detail::__make_unsigned_like_t>) + -> subrange<_It, _Sent, subrange_kind::sized>; + + template + subrange(_Rng&&) + -> subrange, sentinel_t<_Rng>, + (sized_range<_Rng> + || sized_sentinel_for, iterator_t<_Rng>>) + ? subrange_kind::sized : subrange_kind::unsized>; + + template + subrange(_Rng&&, + __detail::__make_unsigned_like_t>) + -> subrange, sentinel_t<_Rng>, subrange_kind::sized>; + + template + requires (_Num < 2) + constexpr auto + get(const subrange<_It, _Sent, _Kind>& __r) + { + if constexpr (_Num == 0) + return __r.begin(); + else + return __r.end(); + } + + template + requires (_Num < 2) + constexpr auto + get(subrange<_It, _Sent, _Kind>&& __r) + { + if constexpr (_Num == 0) + return __r.begin(); + else + return __r.end(); + } + + template _Sent, + subrange_kind _Kind> + inline constexpr bool + enable_borrowed_range> = true; + + template + using borrowed_subrange_t = conditional_t, + subrange>, + dangling>; +} // namespace ranges + +// The following ranges algorithms are used by , and are defined here +// so that can avoid including all of . +namespace ranges +{ + struct __find_fn + { + template _Sent, typename _Tp, + typename _Proj = identity> + requires indirect_binary_predicate, const _Tp*> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + const _Tp& __value, _Proj __proj = {}) const + { + while (__first != __last + && !(std::__invoke(__proj, *__first) == __value)) + ++__first; + return __first; + } + + template + requires indirect_binary_predicate, _Proj>, + const _Tp*> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, const _Tp& __value, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + __value, std::move(__proj)); + } + }; + + inline constexpr __find_fn find{}; + + struct __find_if_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + while (__first != __last + && !(bool)std::__invoke(__pred, std::__invoke(__proj, *__first))) + ++__first; + return __first; + } + + template, _Proj>> + _Pred> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __find_if_fn find_if{}; + + struct __find_if_not_fn + { + template _Sent, + typename _Proj = identity, + indirect_unary_predicate> _Pred> + constexpr _Iter + operator()(_Iter __first, _Sent __last, + _Pred __pred, _Proj __proj = {}) const + { + while (__first != __last + && (bool)std::__invoke(__pred, std::__invoke(__proj, *__first))) + ++__first; + return __first; + } + + template, _Proj>> + _Pred> + constexpr borrowed_iterator_t<_Range> + operator()(_Range&& __r, _Pred __pred, _Proj __proj = {}) const + { + return (*this)(ranges::begin(__r), ranges::end(__r), + std::move(__pred), std::move(__proj)); + } + }; + + inline constexpr __find_if_not_fn find_if_not{}; + + template + struct in_in_result + { + [[no_unique_address]] _Iter1 in1; + [[no_unique_address]] _Iter2 in2; + + template + requires convertible_to + && convertible_to + constexpr + operator in_in_result<_IIter1, _IIter2>() const & + { return {in1, in2}; } + + template + requires convertible_to<_Iter1, _IIter1> + && convertible_to<_Iter2, _IIter2> + constexpr + operator in_in_result<_IIter1, _IIter2>() && + { return {std::move(in1), std::move(in2)}; } + }; + + template + using mismatch_result = in_in_result<_Iter1, _Iter2>; + + struct __mismatch_fn + { + template _Sent1, + input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Pred = ranges::equal_to, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + constexpr mismatch_result<_Iter1, _Iter2> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + while (__first1 != __last1 && __first2 != __last2 + && (bool)std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + { + ++__first1; + ++__first2; + } + return { std::move(__first1), std::move(__first2) }; + } + + template + requires indirectly_comparable, iterator_t<_Range2>, + _Pred, _Proj1, _Proj2> + constexpr mismatch_result, iterator_t<_Range2>> + operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __mismatch_fn mismatch{}; + + struct __search_fn + { + template _Sent1, + forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, + typename _Pred = ranges::equal_to, + typename _Proj1 = identity, typename _Proj2 = identity> + requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + constexpr subrange<_Iter1> + operator()(_Iter1 __first1, _Sent1 __last1, + _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + if (__first1 == __last1 || __first2 == __last2) + return {__first1, __first1}; + + for (;;) + { + for (;;) + { + if (__first1 == __last1) + return {__first1, __first1}; + if (std::__invoke(__pred, + std::__invoke(__proj1, *__first1), + std::__invoke(__proj2, *__first2))) + break; + ++__first1; + } + auto __cur1 = __first1; + auto __cur2 = __first2; + for (;;) + { + if (++__cur2 == __last2) + return {__first1, ++__cur1}; + if (++__cur1 == __last1) + return {__cur1, __cur1}; + if (!(bool)std::__invoke(__pred, + std::__invoke(__proj1, *__cur1), + std::__invoke(__proj2, *__cur2))) + { + ++__first1; + break; + } + } + } + } + + template + requires indirectly_comparable, iterator_t<_Range2>, + _Pred, _Proj1, _Proj2> + constexpr borrowed_subrange_t<_Range1> + operator()(_Range1&& __r1, _Range2&& __r2, _Pred __pred = {}, + _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const + { + return (*this)(ranges::begin(__r1), ranges::end(__r1), + ranges::begin(__r2), ranges::end(__r2), + std::move(__pred), + std::move(__proj1), std::move(__proj2)); + } + }; + + inline constexpr __search_fn search{}; +} // namespace ranges + + using ranges::get; + + template + struct tuple_size> + : integral_constant + { }; + + template + struct tuple_element<0, ranges::subrange<_Iter, _Sent, _Kind>> + { using type = _Iter; }; + + template + struct tuple_element<1, ranges::subrange<_Iter, _Sent, _Kind>> + { using type = _Sent; }; + + template + struct tuple_element<0, const ranges::subrange<_Iter, _Sent, _Kind>> + { using type = _Iter; }; + + template + struct tuple_element<1, const ranges::subrange<_Iter, _Sent, _Kind>> + { using type = _Sent; }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // library concepts +#endif // C++20 +#endif // _RANGES_UTIL_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/refwrap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/refwrap.h new file mode 100755 index 0000000..adfbe21 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/refwrap.h @@ -0,0 +1,401 @@ +// Implementation of std::reference_wrapper -*- C++ -*- + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/refwrap.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _GLIBCXX_REFWRAP_H +#define _GLIBCXX_REFWRAP_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include // for unary_function and binary_function + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// @cond undocumented + + /** + * Derives from @c unary_function or @c binary_function, or perhaps + * nothing, depending on the number of arguments provided. The + * primary template is the basis case, which derives nothing. + */ + template + struct _Maybe_unary_or_binary_function { }; + + /// Derives from @c unary_function, as appropriate. + template + struct _Maybe_unary_or_binary_function<_Res, _T1> + : std::unary_function<_T1, _Res> { }; + + /// Derives from @c binary_function, as appropriate. + template + struct _Maybe_unary_or_binary_function<_Res, _T1, _T2> + : std::binary_function<_T1, _T2, _Res> { }; + + template + struct _Mem_fn_traits; + + template + struct _Mem_fn_traits_base + { + using __result_type = _Res; + using __maybe_type + = _Maybe_unary_or_binary_function<_Res, _Class*, _ArgTypes...>; + using __arity = integral_constant; + }; + +#define _GLIBCXX_MEM_FN_TRAITS2(_CV, _REF, _LVAL, _RVAL) \ + template \ + struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes...) _CV _REF> \ + : _Mem_fn_traits_base<_Res, _CV _Class, _ArgTypes...> \ + { \ + using __vararg = false_type; \ + }; \ + template \ + struct _Mem_fn_traits<_Res (_Class::*)(_ArgTypes... ...) _CV _REF> \ + : _Mem_fn_traits_base<_Res, _CV _Class, _ArgTypes...> \ + { \ + using __vararg = true_type; \ + }; + +#define _GLIBCXX_MEM_FN_TRAITS(_REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2( , _REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2(const , _REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2(volatile , _REF, _LVAL, _RVAL) \ + _GLIBCXX_MEM_FN_TRAITS2(const volatile, _REF, _LVAL, _RVAL) + +_GLIBCXX_MEM_FN_TRAITS( , true_type, true_type) +_GLIBCXX_MEM_FN_TRAITS(&, true_type, false_type) +_GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) + +#if __cplusplus > 201402L +_GLIBCXX_MEM_FN_TRAITS(noexcept, true_type, true_type) +_GLIBCXX_MEM_FN_TRAITS(& noexcept, true_type, false_type) +_GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type) +#endif + +#undef _GLIBCXX_MEM_FN_TRAITS +#undef _GLIBCXX_MEM_FN_TRAITS2 + + /// If we have found a result_type, extract it. + template> + struct _Maybe_get_result_type + { }; + + template + struct _Maybe_get_result_type<_Functor, + __void_t> + { typedef typename _Functor::result_type result_type; }; + + /** + * Base class for any function object that has a weak result type, as + * defined in 20.8.2 [func.require] of C++11. + */ + template + struct _Weak_result_type_impl + : _Maybe_get_result_type<_Functor> + { }; + + /// Retrieve the result type for a function type. + template + struct _Weak_result_type_impl<_Res(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + /// Retrieve the result type for a varargs function type. + template + struct _Weak_result_type_impl<_Res(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + /// Retrieve the result type for a function pointer. + template + struct _Weak_result_type_impl<_Res(*)(_ArgTypes...) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + /// Retrieve the result type for a varargs function pointer. + template + struct + _Weak_result_type_impl<_Res(*)(_ArgTypes......) _GLIBCXX_NOEXCEPT_QUAL> + { typedef _Res result_type; }; + + // Let _Weak_result_type_impl perform the real work. + template::value> + struct _Weak_result_type_memfun + : _Weak_result_type_impl<_Functor> + { }; + + // A pointer to member function has a weak result type. + template + struct _Weak_result_type_memfun<_MemFunPtr, true> + { + using result_type = typename _Mem_fn_traits<_MemFunPtr>::__result_type; + }; + + // A pointer to data member doesn't have a weak result type. + template + struct _Weak_result_type_memfun<_Func _Class::*, false> + { }; + + /** + * Strip top-level cv-qualifiers from the function object and let + * _Weak_result_type_memfun perform the real work. + */ + template + struct _Weak_result_type + : _Weak_result_type_memfun::type> + { }; + +#if __cplusplus <= 201703L + // Detect nested argument_type. + template> + struct _Refwrap_base_arg1 + { }; + + // Nested argument_type. + template + struct _Refwrap_base_arg1<_Tp, + __void_t> + { + typedef typename _Tp::argument_type argument_type; + }; + + // Detect nested first_argument_type and second_argument_type. + template> + struct _Refwrap_base_arg2 + { }; + + // Nested first_argument_type and second_argument_type. + template + struct _Refwrap_base_arg2<_Tp, + __void_t> + { + typedef typename _Tp::first_argument_type first_argument_type; + typedef typename _Tp::second_argument_type second_argument_type; + }; + + /** + * Derives from unary_function or binary_function when it + * can. Specializations handle all of the easy cases. The primary + * template determines what to do with a class type, which may + * derive from both unary_function and binary_function. + */ + template + struct _Reference_wrapper_base + : _Weak_result_type<_Tp>, _Refwrap_base_arg1<_Tp>, _Refwrap_base_arg2<_Tp> + { }; + + // - a function type (unary) + template + struct _Reference_wrapper_base<_Res(_T1) _GLIBCXX_NOEXCEPT_QUAL> + : unary_function<_T1, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1) const> + : unary_function<_T1, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1) volatile> + : unary_function<_T1, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1) const volatile> + : unary_function<_T1, _Res> + { }; + + // - a function type (binary) + template + struct _Reference_wrapper_base<_Res(_T1, _T2) _GLIBCXX_NOEXCEPT_QUAL> + : binary_function<_T1, _T2, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1, _T2) const> + : binary_function<_T1, _T2, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1, _T2) volatile> + : binary_function<_T1, _T2, _Res> + { }; + + template + struct _Reference_wrapper_base<_Res(_T1, _T2) const volatile> + : binary_function<_T1, _T2, _Res> + { }; + + // - a function pointer type (unary) + template + struct _Reference_wrapper_base<_Res(*)(_T1) _GLIBCXX_NOEXCEPT_QUAL> + : unary_function<_T1, _Res> + { }; + + // - a function pointer type (binary) + template + struct _Reference_wrapper_base<_Res(*)(_T1, _T2) _GLIBCXX_NOEXCEPT_QUAL> + : binary_function<_T1, _T2, _Res> + { }; + + template::value> + struct _Reference_wrapper_base_memfun + : _Reference_wrapper_base<_Tp> + { }; + + template + struct _Reference_wrapper_base_memfun<_MemFunPtr, true> + : _Mem_fn_traits<_MemFunPtr>::__maybe_type + { + using result_type = typename _Mem_fn_traits<_MemFunPtr>::__result_type; + }; +#endif // ! C++20 + + /// @endcond + + /** + * @brief Primary class template for reference_wrapper. + * @ingroup functors + */ + template + class reference_wrapper +#if __cplusplus <= 201703L + // In C++20 std::reference_wrapper allows T to be incomplete, + // so checking for nested types could result in ODR violations. + : public _Reference_wrapper_base_memfun::type> +#endif + { + _Tp* _M_data; + + _GLIBCXX20_CONSTEXPR + static _Tp* _S_fun(_Tp& __r) noexcept { return std::__addressof(__r); } + + static void _S_fun(_Tp&&) = delete; + + template> + using __not_same + = typename enable_if::value>::type; + + public: + typedef _Tp type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2993. reference_wrapper conversion from T&& + // 3041. Unnecessary decay in reference_wrapper + template, typename + = decltype(reference_wrapper::_S_fun(std::declval<_Up>()))> + _GLIBCXX20_CONSTEXPR + reference_wrapper(_Up&& __uref) + noexcept(noexcept(reference_wrapper::_S_fun(std::declval<_Up>()))) + : _M_data(reference_wrapper::_S_fun(std::forward<_Up>(__uref))) + { } + + reference_wrapper(const reference_wrapper&) = default; + + reference_wrapper& + operator=(const reference_wrapper&) = default; + + _GLIBCXX20_CONSTEXPR + operator _Tp&() const noexcept + { return this->get(); } + + _GLIBCXX20_CONSTEXPR + _Tp& + get() const noexcept + { return *_M_data; } + + template + _GLIBCXX20_CONSTEXPR + typename result_of<_Tp&(_Args&&...)>::type + operator()(_Args&&... __args) const + { +#if __cplusplus > 201703L + if constexpr (is_object_v) + static_assert(sizeof(type), "type must be complete"); +#endif + return std::__invoke(get(), std::forward<_Args>(__args)...); + } + }; + +#if __cpp_deduction_guides + template + reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; +#endif + + /// @relates reference_wrapper @{ + + /// Denotes a reference should be taken to a variable. + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper<_Tp> + ref(_Tp& __t) noexcept + { return reference_wrapper<_Tp>(__t); } + + /// Denotes a const reference should be taken to a variable. + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper + cref(const _Tp& __t) noexcept + { return reference_wrapper(__t); } + + template + void ref(const _Tp&&) = delete; + + template + void cref(const _Tp&&) = delete; + + /// std::ref overload to prevent wrapping a reference_wrapper + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper<_Tp> + ref(reference_wrapper<_Tp> __t) noexcept + { return __t; } + + /// std::cref overload to prevent wrapping a reference_wrapper + template + _GLIBCXX20_CONSTEXPR + inline reference_wrapper + cref(reference_wrapper<_Tp> __t) noexcept + { return { __t.get() }; } + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_REFWRAP_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex.h new file mode 100755 index 0000000..a2eede6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex.h @@ -0,0 +1,2984 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + template + class basic_regex; + + template + class match_results; + +_GLIBCXX_END_NAMESPACE_CXX11 + +namespace __detail +{ + enum class _RegexExecutorPolicy : int { _S_auto, _S_alternate }; + + template + bool + __regex_algo_impl(_BiIter __s, + _BiIter __e, + match_results<_BiIter, _Alloc>& __m, + const basic_regex<_CharT, _TraitsT>& __re, + regex_constants::match_flag_type __flags); + + template + class _Executor; +} + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + /** + * @addtogroup regex + * @{ + */ + + /** + * @brief Describes aspects of a regular expression. + * + * A regular expression traits class that satisfies the requirements of + * section [28.7]. + * + * The class %regex is parameterized around a set of related types and + * functions used to complete the definition of its semantics. This class + * satisfies the requirements of such a traits class. + */ + template + class regex_traits + { + public: + typedef _Ch_type char_type; + typedef std::basic_string string_type; + typedef std::locale locale_type; + + private: + struct _RegexMask + { + typedef std::ctype_base::mask _BaseType; + _BaseType _M_base; + unsigned char _M_extended; + static constexpr unsigned char _S_under = 1 << 0; + static constexpr unsigned char _S_valid_mask = 0x1; + + constexpr _RegexMask(_BaseType __base = 0, + unsigned char __extended = 0) + : _M_base(__base), _M_extended(__extended) + { } + + constexpr _RegexMask + operator&(_RegexMask __other) const + { + return _RegexMask(_M_base & __other._M_base, + _M_extended & __other._M_extended); + } + + constexpr _RegexMask + operator|(_RegexMask __other) const + { + return _RegexMask(_M_base | __other._M_base, + _M_extended | __other._M_extended); + } + + constexpr _RegexMask + operator^(_RegexMask __other) const + { + return _RegexMask(_M_base ^ __other._M_base, + _M_extended ^ __other._M_extended); + } + + constexpr _RegexMask + operator~() const + { return _RegexMask(~_M_base, ~_M_extended); } + + _RegexMask& + operator&=(_RegexMask __other) + { return *this = (*this) & __other; } + + _RegexMask& + operator|=(_RegexMask __other) + { return *this = (*this) | __other; } + + _RegexMask& + operator^=(_RegexMask __other) + { return *this = (*this) ^ __other; } + + constexpr bool + operator==(_RegexMask __other) const + { + return (_M_extended & _S_valid_mask) + == (__other._M_extended & _S_valid_mask) + && _M_base == __other._M_base; + } + +#if __cpp_impl_three_way_comparison < 201907L + constexpr bool + operator!=(_RegexMask __other) const + { return !((*this) == __other); } +#endif + }; + + public: + typedef _RegexMask char_class_type; + + public: + /** + * @brief Constructs a default traits object. + */ + regex_traits() { } + + /** + * @brief Gives the length of a C-style string starting at @p __p. + * + * @param __p a pointer to the start of a character sequence. + * + * @returns the number of characters between @p *__p and the first + * default-initialized value of type @p char_type. In other words, uses + * the C-string algorithm for determining the length of a sequence of + * characters. + */ + static std::size_t + length(const char_type* __p) + { return string_type::traits_type::length(__p); } + + /** + * @brief Performs the identity translation. + * + * @param __c A character to the locale-specific character set. + * + * @returns __c. + */ + char_type + translate(char_type __c) const + { return __c; } + + /** + * @brief Translates a character into a case-insensitive equivalent. + * + * @param __c A character to the locale-specific character set. + * + * @returns the locale-specific lower-case equivalent of __c. + * @throws std::bad_cast if the imbued locale does not support the ctype + * facet. + */ + char_type + translate_nocase(char_type __c) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + return __fctyp.tolower(__c); + } + + /** + * @brief Gets a sort key for a character sequence. + * + * @param __first beginning of the character sequence. + * @param __last one-past-the-end of the character sequence. + * + * Returns a sort key for the character sequence designated by the + * iterator range [F1, F2) such that if the character sequence [G1, G2) + * sorts before the character sequence [H1, H2) then + * v.transform(G1, G2) < v.transform(H1, H2). + * + * What this really does is provide a more efficient way to compare a + * string to multiple other strings in locales with fancy collation + * rules and equivalence classes. + * + * @returns a locale-specific sort key equivalent to the input range. + * + * @throws std::bad_cast if the current locale does not have a collate + * facet. + */ + template + string_type + transform(_Fwd_iter __first, _Fwd_iter __last) const + { + typedef std::collate __collate_type; + const __collate_type& __fclt(use_facet<__collate_type>(_M_locale)); + string_type __s(__first, __last); + return __fclt.transform(__s.data(), __s.data() + __s.size()); + } + + /** + * @brief Gets a sort key for a character sequence, independent of case. + * + * @param __first beginning of the character sequence. + * @param __last one-past-the-end of the character sequence. + * + * Effects: if typeid(use_facet >) == + * typeid(collate_byname<_Ch_type>) and the form of the sort key + * returned by collate_byname<_Ch_type>::transform(__first, __last) + * is known and can be converted into a primary sort key + * then returns that key, otherwise returns an empty string. + * + * @todo Implement this function correctly. + */ + template + string_type + transform_primary(_Fwd_iter __first, _Fwd_iter __last) const + { + // TODO : this is not entirely correct. + // This function requires extra support from the platform. + // + // Read http://gcc.gnu.org/ml/libstdc++/2013-09/msg00117.html and + // http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2003/n1429.htm + // for details. + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + std::vector __s(__first, __last); + __fctyp.tolower(__s.data(), __s.data() + __s.size()); + return this->transform(__s.data(), __s.data() + __s.size()); + } + + /** + * @brief Gets a collation element by name. + * + * @param __first beginning of the collation element name. + * @param __last one-past-the-end of the collation element name. + * + * @returns a sequence of one or more characters that represents the + * collating element consisting of the character sequence designated by + * the iterator range [__first, __last). Returns an empty string if the + * character sequence is not a valid collating element. + */ + template + string_type + lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const; + + /** + * @brief Maps one or more characters to a named character + * classification. + * + * @param __first beginning of the character sequence. + * @param __last one-past-the-end of the character sequence. + * @param __icase ignores the case of the classification name. + * + * @returns an unspecified value that represents the character + * classification named by the character sequence designated by + * the iterator range [__first, __last). If @p icase is true, + * the returned mask identifies the classification regardless of + * the case of the characters to be matched (for example, + * [[:lower:]] is the same as [[:alpha:]]), otherwise a + * case-dependent classification is returned. The value + * returned shall be independent of the case of the characters + * in the character sequence. If the name is not recognized then + * returns a value that compares equal to 0. + * + * At least the following names (or their wide-character equivalent) are + * supported. + * - d + * - w + * - s + * - alnum + * - alpha + * - blank + * - cntrl + * - digit + * - graph + * - lower + * - print + * - punct + * - space + * - upper + * - xdigit + */ + template + char_class_type + lookup_classname(_Fwd_iter __first, _Fwd_iter __last, + bool __icase = false) const; + + /** + * @brief Determines if @p c is a member of an identified class. + * + * @param __c a character. + * @param __f a class type (as returned from lookup_classname). + * + * @returns true if the character @p __c is a member of the classification + * represented by @p __f, false otherwise. + * + * @throws std::bad_cast if the current locale does not have a ctype + * facet. + */ + bool + isctype(_Ch_type __c, char_class_type __f) const; + + /** + * @brief Converts a digit to an int. + * + * @param __ch a character representing a digit. + * @param __radix the radix if the numeric conversion (limited to 8, 10, + * or 16). + * + * @returns the value represented by the digit __ch in base radix if the + * character __ch is a valid digit in base radix; otherwise returns -1. + */ + int + value(_Ch_type __ch, int __radix) const; + + /** + * @brief Imbues the regex_traits object with a copy of a new locale. + * + * @param __loc A locale. + * + * @returns a copy of the previous locale in use by the regex_traits + * object. + * + * @note Calling imbue with a different locale than the one currently in + * use invalidates all cached data held by *this. + */ + locale_type + imbue(locale_type __loc) + { + std::swap(_M_locale, __loc); + return __loc; + } + + /** + * @brief Gets a copy of the current locale in use by the regex_traits + * object. + */ + locale_type + getloc() const + { return _M_locale; } + + protected: + locale_type _M_locale; + }; + + // [7.8] Class basic_regex + /** + * Objects of specializations of this class represent regular expressions + * constructed from sequences of character type @p _Ch_type. + * + * Storage for the regular expression is allocated and deallocated as + * necessary by the member functions of this class. + */ + template> + class basic_regex + { + public: + static_assert(is_same<_Ch_type, typename _Rx_traits::char_type>::value, + "regex traits class must have the same char_type"); + + // types: + typedef _Ch_type value_type; + typedef _Rx_traits traits_type; + typedef typename traits_type::string_type string_type; + typedef regex_constants::syntax_option_type flag_type; + typedef typename traits_type::locale_type locale_type; + + /** + * @name Constants + * std [28.8.1](1) + */ + ///@{ + static constexpr flag_type icase = regex_constants::icase; + static constexpr flag_type nosubs = regex_constants::nosubs; + static constexpr flag_type optimize = regex_constants::optimize; + static constexpr flag_type collate = regex_constants::collate; + static constexpr flag_type ECMAScript = regex_constants::ECMAScript; + static constexpr flag_type basic = regex_constants::basic; + static constexpr flag_type extended = regex_constants::extended; + static constexpr flag_type awk = regex_constants::awk; + static constexpr flag_type grep = regex_constants::grep; + static constexpr flag_type egrep = regex_constants::egrep; + ///@} + + // [7.8.2] construct/copy/destroy + /** + * Constructs a basic regular expression that does not match any + * character sequence. + */ + basic_regex() + : _M_flags(ECMAScript), _M_loc(), _M_automaton(nullptr) + { } + + /** + * @brief Constructs a basic regular expression from the + * sequence [__p, __p + char_traits<_Ch_type>::length(__p)) + * interpreted according to the flags in @p __f. + * + * @param __p A pointer to the start of a C-style null-terminated string + * containing a regular expression. + * @param __f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p __p is not a valid regular expression. + */ + explicit + basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript) + : basic_regex(__p, __p + char_traits<_Ch_type>::length(__p), __f) + { } + + /** + * @brief Constructs a basic regular expression from the sequence + * [p, p + len) interpreted according to the flags in @p f. + * + * @param __p A pointer to the start of a string containing a regular + * expression. + * @param __len The length of the string containing the regular + * expression. + * @param __f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p __p is not a valid regular expression. + */ + basic_regex(const _Ch_type* __p, std::size_t __len, + flag_type __f = ECMAScript) + : basic_regex(__p, __p + __len, __f) + { } + + /** + * @brief Copy-constructs a basic regular expression. + * + * @param __rhs A @p regex object. + */ + basic_regex(const basic_regex& __rhs) = default; + + /** + * @brief Move-constructs a basic regular expression. + * + * @param __rhs A @p regex object. + */ + basic_regex(basic_regex&& __rhs) noexcept = default; + + /** + * @brief Constructs a basic regular expression from the string + * @p s interpreted according to the flags in @p f. + * + * @param __s A string containing a regular expression. + * @param __f Flags indicating the syntax rules and options. + * + * @throws regex_error if @p __s is not a valid regular expression. + */ + template + explicit + basic_regex(const std::basic_string<_Ch_type, _Ch_traits, + _Ch_alloc>& __s, + flag_type __f = ECMAScript) + : basic_regex(__s.data(), __s.data() + __s.size(), __f) + { } + + /** + * @brief Constructs a basic regular expression from the range + * [first, last) interpreted according to the flags in @p f. + * + * @param __first The start of a range containing a valid regular + * expression. + * @param __last The end of a range containing a valid regular + * expression. + * @param __f The format flags of the regular expression. + * + * @throws regex_error if @p [__first, __last) is not a valid regular + * expression. + */ + template + basic_regex(_FwdIter __first, _FwdIter __last, + flag_type __f = ECMAScript) + : basic_regex(std::move(__first), std::move(__last), locale_type(), __f) + { } + + /** + * @brief Constructs a basic regular expression from an initializer list. + * + * @param __l The initializer list. + * @param __f The format flags of the regular expression. + * + * @throws regex_error if @p __l is not a valid regular expression. + */ + basic_regex(initializer_list<_Ch_type> __l, flag_type __f = ECMAScript) + : basic_regex(__l.begin(), __l.end(), __f) + { } + + /** + * @brief Destroys a basic regular expression. + */ + ~basic_regex() + { } + + /** + * @brief Assigns one regular expression to another. + */ + basic_regex& + operator=(const basic_regex& __rhs) + { return this->assign(__rhs); } + + /** + * @brief Move-assigns one regular expression to another. + */ + basic_regex& + operator=(basic_regex&& __rhs) noexcept + { return this->assign(std::move(__rhs)); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a C-style null-terminated string. + * + * @param __p A pointer to the start of a null-terminated C-style string + * containing a regular expression. + */ + basic_regex& + operator=(const _Ch_type* __p) + { return this->assign(__p); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * an initializer list. + * + * @param __l The initializer list. + * + * @throws regex_error if @p __l is not a valid regular expression. + */ + basic_regex& + operator=(initializer_list<_Ch_type> __l) + { return this->assign(__l.begin(), __l.end()); } + + /** + * @brief Replaces a regular expression with a new one constructed from + * a string. + * + * @param __s A pointer to a string containing a regular expression. + */ + template + basic_regex& + operator=(const basic_string<_Ch_type, _Ch_traits, _Alloc>& __s) + { return this->assign(__s); } + + // [7.8.3] assign + /** + * @brief the real assignment operator. + * + * @param __rhs Another regular expression object. + */ + basic_regex& + assign(const basic_regex& __rhs) + { + basic_regex __tmp(__rhs); + this->swap(__tmp); + return *this; + } + + /** + * @brief The move-assignment operator. + * + * @param __rhs Another regular expression object. + */ + basic_regex& + assign(basic_regex&& __rhs) noexcept + { + basic_regex __tmp(std::move(__rhs)); + this->swap(__tmp); + return *this; + } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style null-terminated string containing a regular expression + * pattern. + * + * @param __p A pointer to a C-style null-terminated string containing + * a regular expression pattern. + * @param __flags Syntax option flags. + * + * @throws regex_error if __p does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, *this remains unchanged. + */ + basic_regex& + assign(const _Ch_type* __p, flag_type __flags = ECMAScript) + { return this->assign(string_type(__p), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * C-style string containing a regular expression pattern. + * + * @param __p A pointer to a C-style string containing a + * regular expression pattern. + * @param __len The length of the regular expression pattern string. + * @param __flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, *this remains unchanged. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3296. Inconsistent default argument for basic_regex<>::assign + basic_regex& + assign(const _Ch_type* __p, size_t __len, flag_type __flags = ECMAScript) + { return this->assign(string_type(__p, __len), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object from a + * string containing a regular expression pattern. + * + * @param __s A string containing a regular expression pattern. + * @param __flags Syntax option flags. + * + * @throws regex_error if __s does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, *this remains unchanged. + */ + template + basic_regex& + assign(const basic_string<_Ch_type, _Ch_traits, _Alloc>& __s, + flag_type __flags = ECMAScript) + { + return this->assign(basic_regex(__s.data(), __s.data() + __s.size(), + _M_loc, __flags)); + } + + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param __first The start of a range containing a valid regular + * expression. + * @param __last The end of a range containing a valid regular + * expression. + * @param __flags Syntax option flags. + * + * @throws regex_error if p does not contain a valid regular + * expression pattern interpreted according to @p __flags. If + * regex_error is thrown, the object remains unchanged. + */ + template + basic_regex& + assign(_InputIterator __first, _InputIterator __last, + flag_type __flags = ECMAScript) + { return this->assign(string_type(__first, __last), __flags); } + + /** + * @brief Assigns a new regular expression to a regex object. + * + * @param __l An initializer list representing a regular expression. + * @param __flags Syntax option flags. + * + * @throws regex_error if @p __l does not contain a valid + * regular expression pattern interpreted according to @p + * __flags. If regex_error is thrown, the object remains + * unchanged. + */ + basic_regex& + assign(initializer_list<_Ch_type> __l, flag_type __flags = ECMAScript) + { return this->assign(__l.begin(), __l.end(), __flags); } + + // [7.8.4] const operations + /** + * @brief Gets the number of marked subexpressions within the regular + * expression. + */ + unsigned int + mark_count() const + { + if (_M_automaton) + return _M_automaton->_M_sub_count() - 1; + return 0; + } + + /** + * @brief Gets the flags used to construct the regular expression + * or in the last call to assign(). + */ + flag_type + flags() const + { return _M_flags; } + + // [7.8.5] locale + /** + * @brief Imbues the regular expression object with the given locale. + * + * @param __loc A locale. + */ + locale_type + imbue(locale_type __loc) + { + std::swap(__loc, _M_loc); + _M_automaton.reset(); + return __loc; + } + + /** + * @brief Gets the locale currently imbued in the regular expression + * object. + */ + locale_type + getloc() const + { return _M_loc; } + + // [7.8.6] swap + /** + * @brief Swaps the contents of two regular expression objects. + * + * @param __rhs Another regular expression object. + */ + void + swap(basic_regex& __rhs) + { + std::swap(_M_flags, __rhs._M_flags); + std::swap(_M_loc, __rhs._M_loc); + std::swap(_M_automaton, __rhs._M_automaton); + } + +#ifdef _GLIBCXX_DEBUG + void + _M_dot(std::ostream& __ostr) + { _M_automaton->_M_dot(__ostr); } +#endif + + private: + typedef std::shared_ptr> _AutomatonPtr; + + template + basic_regex(_FwdIter __first, _FwdIter __last, locale_type __loc, + flag_type __f) + : _M_flags(__f), _M_loc(std::move(__loc)), + _M_automaton(__detail::__compile_nfa<_Rx_traits>( + std::move(__first), std::move(__last), _M_loc, _M_flags)) + { } + + template + friend bool + __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, + const basic_regex<_Cp, _Rp>&, + regex_constants::match_flag_type); + + template + friend class __detail::_Executor; + + flag_type _M_flags; + locale_type _M_loc; + _AutomatonPtr _M_automaton; + }; + +#if __cplusplus < 201703L + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::icase; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::nosubs; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::optimize; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::collate; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::ECMAScript; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::basic; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::extended; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::awk; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::grep; + + template + constexpr regex_constants::syntax_option_type + basic_regex<_Ch, _Tr>::egrep; +#endif // ! C++17 + +#if __cpp_deduction_guides >= 201606 + template + basic_regex(_ForwardIterator, _ForwardIterator, + regex_constants::syntax_option_type = {}) + -> basic_regex::value_type>; +#endif + + /** @brief Standard regular expressions. */ + typedef basic_regex regex; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Standard wide-character regular expressions. */ + typedef basic_regex wregex; +#endif + + + // [7.8.6] basic_regex swap + /** + * @brief Swaps the contents of two regular expression objects. + * @param __lhs First regular expression. + * @param __rhs Second regular expression. + * @relates basic_regex + */ + template + inline void + swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, + basic_regex<_Ch_type, _Rx_traits>& __rhs) + { __lhs.swap(__rhs); } + + + // C++11 28.9 [re.submatch] Class template sub_match + /** + * A sequence of characters matched by a particular marked sub-expression. + * + * An object of this class is essentially a pair of iterators marking a + * matched subexpression within a regular expression pattern match. Such + * objects can be converted to and compared with std::basic_string objects + * of a similar base character type as the pattern matched by the regular + * expression. + * + * The iterators that make up the pair are the usual half-open interval + * referencing the actual original pattern matched. + */ + template + class sub_match : public std::pair<_BiIter, _BiIter> + { + typedef iterator_traits<_BiIter> __iter_traits; + + public: + typedef typename __iter_traits::value_type value_type; + typedef typename __iter_traits::difference_type difference_type; + typedef _BiIter iterator; + typedef basic_string string_type; + + bool matched; + + constexpr sub_match() noexcept : matched() { } + + /// Gets the length of the matching sequence. + difference_type + length() const noexcept + { return this->matched ? std::distance(this->first, this->second) : 0; } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + * + * This is the implicit conversion operator. It is identical to the + * str() member function except that it will want to pop up in + * unexpected places and cause a great deal of confusion and cursing + * from the unwary. + */ + operator string_type() const + { return str(); } + + /** + * @brief Gets the matching sequence as a string. + * + * @returns the matching sequence as a string. + */ + string_type + str() const + { + return this->matched + ? string_type(this->first, this->second) + : string_type(); + } + + /** + * @brief Compares this and another matched sequence. + * + * @param __s Another matched sequence to compare to this one. + * + * @retval negative This matched sequence will collate before `__s`. + * @retval zero This matched sequence is equivalent to `__s`. + * @retval positive This matched sequence will collate after `__s`. + */ + int + compare(const sub_match& __s) const + { return this->_M_str().compare(__s._M_str()); } + + /** + * @{ + * @brief Compares this `sub_match` to a string. + * + * @param __s A string to compare to this `sub_match`. + * + * @retval negative This matched sequence will collate before `__s`. + * @retval zero This matched sequence is equivalent to `__s`. + * @retval positive This matched sequence will collate after `__s`. + */ + int + compare(const string_type& __s) const + { return this->_M_str().compare(__s); } + + int + compare(const value_type* __s) const + { return this->_M_str().compare(__s); } + /// @} + + /// @cond undocumented + // Non-standard, used by comparison operators + int + _M_compare(const value_type* __s, size_t __n) const + { return this->_M_str().compare({__s, __n}); } + /// @endcond + + private: + // Simplified basic_string_view for C++11 + struct __string_view + { + using traits_type = typename string_type::traits_type; + + __string_view() = default; + + __string_view(const value_type* __s, size_t __n) noexcept + : _M_data(__s), _M_len(__n) { } + + __string_view(const value_type* __s) noexcept + : _M_data(__s), _M_len(traits_type::length(__s)) { } + + __string_view(const string_type& __s) noexcept + : _M_data(__s.data()), _M_len(__s.length()) { } + + int + compare(__string_view __s) const noexcept + { + if (const size_t __n = std::min(_M_len, __s._M_len)) + if (int __ret = traits_type::compare(_M_data, __s._M_data, __n)) + return __ret; + using __limits = __gnu_cxx::__int_traits; + const difference_type __diff = _M_len - __s._M_len; + if (__diff > __limits::__max) + return __limits::__max; + if (__diff < __limits::__min) + return __limits::__min; + return static_cast(__diff); + } + + private: + const value_type* _M_data = nullptr; + size_t _M_len = 0; + }; + + // Create a __string_view over the iterator range. + template + __enable_if_t<__detail::__is_contiguous_iter<_Iter>::value, + __string_view> + _M_str() const noexcept + { + if (this->matched) + if (size_t __len = this->second - this->first) + return { std::__addressof(*this->first), __len }; + return {}; + } + + // Create a temporary string that can be converted to __string_view. + template + __enable_if_t::value, + string_type> + _M_str() const + { return str(); } + }; + + + /** @brief Standard regex submatch over a C-style null-terminated string. */ + typedef sub_match csub_match; + + /** @brief Standard regex submatch over a standard string. */ + typedef sub_match ssub_match; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Regex submatch over a C-style null-terminated wide string. */ + typedef sub_match wcsub_match; + + /** @brief Regex submatch over a standard wide string. */ + typedef sub_match wssub_match; +#endif + + // [7.9.2] sub_match non-member operators + + /// @relates sub_match @{ + + /** + * @brief Tests the equivalence of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const sub_match<_BiIter>& __lhs, + const sub_match<_BiIter>& __rhs) + noexcept(__detail::__is_contiguous_iter<_BiIter>::value) + { + using _Tr = char_traits::value_type>; + return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs)); + } +#else + /** + * @brief Tests the inequivalence of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) != 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) <= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) >= 0; } + + /** + * @brief Tests the ordering of two regular expression submatches. + * @param __lhs First regular expression submatch. + * @param __rhs Second regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) + { return __lhs.compare(__rhs) > 0; } +#endif // three-way comparison + + /// @cond undocumented + + // Alias for a basic_string that can be compared to a sub_match. + template + using __sub_match_string = basic_string< + typename iterator_traits<_Bi_iter>::value_type, + _Ch_traits, _Ch_alloc>; + /// @endcond + +#if ! __cpp_lib_three_way_comparison + /** + * @brief Tests the equivalence of a string and a regular expression + * submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(__lhs.data(), __lhs.size()) == 0; } + + /** + * @brief Tests the inequivalence of a string and a regular expression + * submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(__lhs.data(), __lhs.size()) > 0; } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a string and a regular expression submatch. + * @param __lhs A string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs._M_compare(__rhs.data(), __rhs.size()) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Alloc>& __rhs) + noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value) + { + return __detail::__char_traits_cmp_cat<_Ch_traits>( + __lhs._M_compare(__rhs.data(), __rhs.size())); + } +#else + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return __lhs._M_compare(__rhs.data(), __rhs.size()) < 0; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a string. + * @param __lhs A regular expression submatch. + * @param __rhs A string. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs) + { return !(__rhs < __lhs); } + + /** + * @brief Tests the equivalence of a C string and a regular expression + * submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs.compare(__lhs) == 0; } + + /** + * @brief Tests the inequivalence of a C string and a regular + * expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs.compare(__lhs) > 0; } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a C string and a regular expression submatch. + * @param __lhs A null-terminated string. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Tests the equivalence of a regular expression submatch and a C + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.compare(__rhs) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a regular expression submatch and a C + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + template + inline auto + operator<=>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value) + { + using _Tr = char_traits::value_type>; + return __detail::__char_traits_cmp_cat<_Tr>(__lhs.compare(__rhs)); + } +#else + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __lhs.compare(__rhs) < 0; } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a C string. + * @param __lhs A regular expression submatch. + * @param __rhs A null-terminated string. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const* __rhs) + { return !(__rhs < __lhs); } + + /** + * @brief Tests the equivalence of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(std::__addressof(__lhs), 1) == 0; } + + /** + * @brief Tests the inequivalence of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs._M_compare(std::__addressof(__lhs), 1) > 0; } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a character and a regular expression + * submatch. + * @param __lhs A character. + * @param __rhs A regular expression submatch. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, + const sub_match<_Bi_iter>& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Tests the equivalence of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs is equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator==(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs._M_compare(std::__addressof(__rhs), 1) == 0; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Three-way comparison of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns A value indicating whether `__lhs` is less than, equal to, + * greater than, or incomparable with `__rhs`. + */ + + template + inline auto + operator<=>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + noexcept(__detail::__is_contiguous_iter<_Bi_iter>::value) + { + using _Tr = char_traits::value_type>; + return __detail::__char_traits_cmp_cat<_Tr>( + __lhs._M_compare(std::__addressof(__rhs), 1)); + } +#else + /** + * @brief Tests the inequivalence of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs is not equivalent to @a __rhs, false otherwise. + */ + template + inline bool + operator!=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return !(__lhs == __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs precedes @a __rhs, false otherwise. + */ + template + inline bool + operator<(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __lhs._M_compare(std::__addressof(__rhs), 1) < 0; } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs succeeds @a __rhs, false otherwise. + */ + template + inline bool + operator>(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return __rhs < __lhs; } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs does not precede @a __rhs, false otherwise. + */ + template + inline bool + operator>=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return !(__lhs < __rhs); } + + /** + * @brief Tests the ordering of a regular expression submatch and a + * character. + * @param __lhs A regular expression submatch. + * @param __rhs A character. + * @returns true if @a __lhs does not succeed @a __rhs, false otherwise. + */ + template + inline bool + operator<=(const sub_match<_Bi_iter>& __lhs, + typename iterator_traits<_Bi_iter>::value_type const& __rhs) + { return !(__rhs < __lhs); } +#endif // three-way comparison + + /** + * @brief Inserts a matched string into an output stream. + * + * @param __os The output stream. + * @param __m A submatch string. + * + * @returns the output stream with the submatch string inserted. + */ + template + inline + basic_ostream<_Ch_type, _Ch_traits>& + operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, + const sub_match<_Bi_iter>& __m) + { return __os << __m.str(); } + + /// @} relates sub_match + + // [7.10] Class template match_results + + /** + * @brief The results of a match or search operation. + * + * A collection of character sequences representing the result of a regular + * expression match. Storage for the collection is allocated and freed as + * necessary by the member functions of class template match_results. + * + * This class satisfies the Sequence requirements, with the exception that + * only the operations defined for a const-qualified Sequence are supported. + * + * The sub_match object stored at index 0 represents sub-expression 0, i.e. + * the whole match. In this case the %sub_match member matched is always true. + * The sub_match object stored at index n denotes what matched the marked + * sub-expression n within the matched expression. If the sub-expression n + * participated in a regular expression match then the %sub_match member + * matched evaluates to true, and members first and second denote the range + * of characters [first, second) which formed that match. Otherwise matched + * is false, and members first and second point to the end of the sequence + * that was searched. + */ + template > > + class match_results + : private std::vector, _Alloc> + { + private: + /* + * The vector base is empty if this does not represent a match (!ready()); + * Otherwise if it's a match failure, it contains 3 elements: + * [0] unmatched + * [1] prefix + * [2] suffix + * Otherwise it contains n+4 elements where n is the number of marked + * sub-expressions: + * [0] entire match + * [1] 1st marked subexpression + * ... + * [n] nth marked subexpression + * [n+1] unmatched + * [n+2] prefix + * [n+3] suffix + */ + typedef std::vector, _Alloc> _Base_type; + typedef std::iterator_traits<_Bi_iter> __iter_traits; + typedef regex_constants::match_flag_type match_flag_type; + + public: + /** + * @name 28.10 Public Types + */ + ///@{ + typedef sub_match<_Bi_iter> value_type; + typedef const value_type& const_reference; + typedef value_type& reference; + typedef typename _Base_type::const_iterator const_iterator; + typedef const_iterator iterator; + typedef typename __iter_traits::difference_type difference_type; + typedef typename allocator_traits<_Alloc>::size_type size_type; + typedef _Alloc allocator_type; + typedef typename __iter_traits::value_type char_type; + typedef std::basic_string string_type; + ///@} + + public: + /** + * @name 28.10.1 Construction, Copying, and Destruction + */ + ///@{ + + /** + * @brief Constructs a default %match_results container. + * @post size() returns 0 and str() returns an empty string. + */ + match_results() : match_results(_Alloc()) { } + + /** + * @brief Constructs a default %match_results container. + * @post size() returns 0 and str() returns an empty string. + */ + explicit + match_results(const _Alloc& __a) noexcept + : _Base_type(__a) + { } + + /** + * @brief Copy constructs a %match_results. + */ + match_results(const match_results&) = default; + + /** + * @brief Move constructs a %match_results. + */ + match_results(match_results&&) noexcept = default; + + /** + * @brief Assigns rhs to *this. + */ + match_results& + operator=(const match_results&) = default; + + /** + * @brief Move-assigns rhs to *this. + */ + match_results& + operator=(match_results&&) = default; + + /** + * @brief Destroys a %match_results object. + */ + ~match_results() = default; + + ///@} + + // 28.10.2, state: + /** + * @brief Indicates if the %match_results is ready. + * @retval true The object has a fully-established result state. + * @retval false The object is not ready. + */ + bool ready() const noexcept { return !_Base_type::empty(); } + + /** + * @name 28.10.2 Size + */ + ///@{ + + /** + * @brief Gets the number of matches and submatches. + * + * The number of matches for a given regular expression will be either 0 + * if there was no match or mark_count() + 1 if a match was successful. + * Some matches may be empty. + * + * @returns the number of matches found. + */ + size_type + size() const noexcept + { return _Base_type::empty() ? 0 : _Base_type::size() - 3; } + + size_type + max_size() const noexcept + { return _Base_type::max_size() - 3; } + + /** + * @brief Indicates if the %match_results contains no results. + * @retval true The %match_results object is empty. + * @retval false The %match_results object is not empty. + */ + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _Base_type::size() <= 3; } + + ///@} + + /** + * @name 28.10.4 Element Access + */ + ///@{ + + /** + * @brief Gets the length of the indicated submatch. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function returns the length of the indicated submatch, or the + * length of the entire match if @p __sub is zero (the default). + */ + difference_type + length(size_type __sub = 0) const + { return (*this)[__sub].length(); } + + /** + * @brief Gets the offset of the beginning of the indicated submatch. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function returns the offset from the beginning of the target + * sequence to the beginning of the submatch, unless the value of @p __sub + * is zero (the default), in which case this function returns the offset + * from the beginning of the target sequence to the beginning of the + * match. + */ + difference_type + position(size_type __sub = 0) const + { return std::distance(_M_begin, (*this)[__sub].first); } + + /** + * @brief Gets the match or submatch converted to a string type. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function gets the submatch (or match, if @p __sub is + * zero) extracted from the target range and converted to the + * associated string type. + */ + string_type + str(size_type __sub = 0) const + { return string_type((*this)[__sub]); } + + /** + * @brief Gets a %sub_match reference for the match or submatch. + * @param __sub indicates the submatch. + * @pre ready() == true + * + * This function gets a reference to the indicated submatch, or + * the entire match if @p __sub is zero. + * + * If @p __sub >= size() then this function returns a %sub_match with a + * special value indicating no submatch. + */ + const_reference + operator[](size_type __sub) const + { + __glibcxx_assert( ready() ); + return __sub < size() + ? _Base_type::operator[](__sub) + : _M_unmatched_sub(); + } + + /** + * @brief Gets a %sub_match representing the match prefix. + * @pre ready() == true + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the start of the target range and the + * start of the match. + */ + const_reference + prefix() const + { + __glibcxx_assert( ready() ); + return !empty() ? _M_prefix() : _M_unmatched_sub(); + } + + /** + * @brief Gets a %sub_match representing the match suffix. + * @pre ready() == true + * + * This function gets a reference to a %sub_match object representing the + * part of the target range between the end of the match and the end of + * the target range. + */ + const_reference + suffix() const + { + __glibcxx_assert( ready() ); + return !empty() ? _M_suffix() : _M_unmatched_sub(); + } + + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + begin() const noexcept + { return _Base_type::begin(); } + + /** + * @brief Gets an iterator to the start of the %sub_match collection. + */ + const_iterator + cbegin() const noexcept + { return this->begin(); } + + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + end() const noexcept + { return _Base_type::end() - (_Base_type::empty() ? 0 : 3); } + + /** + * @brief Gets an iterator to one-past-the-end of the collection. + */ + const_iterator + cend() const noexcept + { return this->end(); } + + ///@} + + /** + * @name 28.10.5 Formatting + * + * These functions perform formatted substitution of the matched + * character sequences into their target. The format specifiers and + * escape sequences accepted by these functions are determined by + * their @p flags parameter as documented above. + */ + ///@{ + + /** + * @pre ready() == true + */ + template + _Out_iter + format(_Out_iter __out, const char_type* __fmt_first, + const char_type* __fmt_last, + match_flag_type __flags = regex_constants::format_default) const; + + /** + * @pre ready() == true + */ + template + _Out_iter + format(_Out_iter __out, const basic_string& __fmt, + match_flag_type __flags = regex_constants::format_default) const + { + return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), + __flags); + } + + /** + * @pre ready() == true + */ + template + basic_string + format(const basic_string& __fmt, + match_flag_type __flags = regex_constants::format_default) const + { + basic_string __result; + format(std::back_inserter(__result), __fmt, __flags); + return __result; + } + + /** + * @pre ready() == true + */ + string_type + format(const char_type* __fmt, + match_flag_type __flags = regex_constants::format_default) const + { + string_type __result; + format(std::back_inserter(__result), + __fmt, + __fmt + char_traits::length(__fmt), + __flags); + return __result; + } + + ///@} + + /** + * @name 28.10.6 Allocator + */ + ///@{ + + /** + * @brief Gets a copy of the allocator. + */ + allocator_type + get_allocator() const noexcept + { return _Base_type::get_allocator(); } + + ///@} + + /** + * @name 28.10.7 Swap + */ + ///@{ + + /** + * @brief Swaps the contents of two match_results. + */ + void + swap(match_results& __that) noexcept + { + using std::swap; + _Base_type::swap(__that); + swap(_M_begin, __that._M_begin); + } + ///@} + + private: + template + friend class regex_iterator; + + /// @cond undocumented + + template + friend class __detail::_Executor; + + template + friend bool + __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&, + const basic_regex<_Cp, _Rp>&, + regex_constants::match_flag_type); + + // Reset contents to __size unmatched sub_match objects + // (plus additional objects for prefix, suffix and unmatched sub). + void + _M_resize(unsigned int __size) + { _Base_type::assign(__size + 3, sub_match<_Bi_iter>{}); } + + // Set state to a failed match for the given past-the-end iterator. + void + _M_establish_failed_match(_Bi_iter __end) + { + sub_match<_Bi_iter> __sm; + __sm.first = __sm.second = __end; + _Base_type::assign(3, __sm); + } + + const_reference + _M_unmatched_sub() const + { return _Base_type::operator[](_Base_type::size() - 3); } + + sub_match<_Bi_iter>& + _M_unmatched_sub() + { return _Base_type::operator[](_Base_type::size() - 3); } + + const_reference + _M_prefix() const + { return _Base_type::operator[](_Base_type::size() - 2); } + + sub_match<_Bi_iter>& + _M_prefix() + { return _Base_type::operator[](_Base_type::size() - 2); } + + const_reference + _M_suffix() const + { return _Base_type::operator[](_Base_type::size() - 1); } + + sub_match<_Bi_iter>& + _M_suffix() + { return _Base_type::operator[](_Base_type::size() - 1); } + + _Bi_iter _M_begin; + /// @endcond + }; + + typedef match_results cmatch; + typedef match_results smatch; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef match_results wcmatch; + typedef match_results wsmatch; +#endif + + // match_results comparisons + + /** + * @brief Compares two match_results for equality. + * @returns true if the two objects refer to the same match, + * false otherwise. + */ + template + inline bool + operator==(const match_results<_Bi_iter, _Alloc>& __m1, + const match_results<_Bi_iter, _Alloc>& __m2) + { + if (__m1.ready() != __m2.ready()) + return false; + if (!__m1.ready()) // both are not ready + return true; + if (__m1.empty() != __m2.empty()) + return false; + if (__m1.empty()) // both are empty + return true; + return __m1.prefix() == __m2.prefix() + && __m1.size() == __m2.size() + && std::equal(__m1.begin(), __m1.end(), __m2.begin()) + && __m1.suffix() == __m2.suffix(); + } + +#if ! __cpp_lib_three_way_comparison + /** + * @brief Compares two match_results for inequality. + * @returns true if the two objects do not refer to the same match, + * false otherwise. + */ + template + inline bool + operator!=(const match_results<_Bi_iter, _Alloc>& __m1, + const match_results<_Bi_iter, _Alloc>& __m2) + { return !(__m1 == __m2); } +#endif + + // [7.10.6] match_results swap + /** + * @brief Swaps two match results. + * @param __lhs A match result. + * @param __rhs A match result. + * + * The contents of the two match_results objects are swapped. + */ + template + inline void + swap(match_results<_Bi_iter, _Alloc>& __lhs, + match_results<_Bi_iter, _Alloc>& __rhs) noexcept + { __lhs.swap(__rhs); } + +_GLIBCXX_END_NAMESPACE_CXX11 + + // [28.11.2] Function template regex_match + /** + * @name Matching, Searching, and Replacing + */ + ///@{ + + /** + * @brief Determines if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param __s Start of the character sequence to match. + * @param __e One-past-the-end of the character sequence to match. + * @param __m The match results. + * @param __re The regular expression. + * @param __flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(_Bi_iter __s, + _Bi_iter __e, + match_results<_Bi_iter, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, + __detail::_RegexExecutorPolicy::_S_auto, true> + (__s, __e, __m, __re, __flags); + } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and all of the character sequence [first, last). + * + * @param __first Beginning of the character sequence to match. + * @param __last One-past-the-end of the character sequence to match. + * @param __re The regular expression. + * @param __flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_match(__first, __last, __what, __re, __flags); + } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param __s The C-style null-terminated string to match. + * @param __m The match results. + * @param __re The regular expression. + * @param __f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const _Ch_type* __s, + match_results& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); } + + /** + * @brief Determines if there is a match between the regular expression @p e + * and a string. + * + * @param __s The string to match. + * @param __m The match results. + * @param __re The regular expression. + * @param __flags Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results::const_iterator, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2329. regex_match() with match_results should forbid temporary strings + /// Prevent unsafe attempts to get match_results from a temporary string. + template + bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, + match_results::const_iterator, _Alloc>&, + const basic_regex<_Ch_type, _Rx_traits>&, + regex_constants::match_flag_type + = regex_constants::match_default) = delete; + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a C-style null-terminated string. + * + * @param __s The C-style null-terminated string to match. + * @param __re The regular expression. + * @param __f Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); } + + /** + * @brief Indicates if there is a match between the regular expression @p e + * and a string. + * + * @param __s [IN] The string to match. + * @param __re [IN] The regular expression. + * @param __flags [IN] Controls how the regular expression is matched. + * + * @retval true A match exists. + * @retval false Otherwise. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_match(__s.begin(), __s.end(), __re, __flags); } + + // [7.11.3] Function template regex_search + /** + * Searches for a regular expression within a range. + * @param __s [IN] The start of the string to search. + * @param __e [IN] One-past-the-end of the string to search. + * @param __m [OUT] The match results. + * @param __re [IN] The regular expression to search for. + * @param __flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(_Bi_iter __s, _Bi_iter __e, + match_results<_Bi_iter, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, + __detail::_RegexExecutorPolicy::_S_auto, false> + (__s, __e, __m, __re, __flags); + } + + /** + * Searches for a regular expression within a range. + * @param __first [IN] The start of the string to search. + * @param __last [IN] One-past-the-end of the string to search. + * @param __re [IN] The regular expression to search for. + * @param __flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(_Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __re, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + match_results<_Bi_iter> __what; + return regex_search(__first, __last, __what, __re, __flags); + } + + /** + * @brief Searches for a regular expression within a C-string. + * @param __s [IN] A C-string to search for the regex. + * @param __m [OUT] The set of regex matches. + * @param __e [IN] The regex to search for in @p s. + * @param __f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const _Ch_type* __s, + match_results& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); } + + /** + * @brief Searches for a regular expression within a C-string. + * @param __s [IN] The C-string to search. + * @param __e [IN] The regular expression to search for. + * @param __f [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); } + + /** + * @brief Searches for a regular expression within a string. + * @param __s [IN] The string to search. + * @param __e [IN] The regular expression to search for. + * @param __flags [IN] Search policy flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, + _String_allocator>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __e, __flags); } + + /** + * @brief Searches for a regular expression within a string. + * @param __s [IN] A C++ string to search for the regex. + * @param __m [OUT] The set of regex matches. + * @param __e [IN] The regex to search for in @p s. + * @param __f [IN] The search flags. + * @retval true A match was found within the string. + * @retval false No match was found within the string, the content of %m is + * undefined. + * + * @throws an exception of type regex_error. + */ + template + inline bool + regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, + match_results::const_iterator, _Alloc>& __m, + const basic_regex<_Ch_type, _Rx_traits>& __e, + regex_constants::match_flag_type __f + = regex_constants::match_default) + { return regex_search(__s.begin(), __s.end(), __m, __e, __f); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2329. regex_search() with match_results should forbid temporary strings + /// Prevent unsafe attempts to get match_results from a temporary string. + template + bool + regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>&&, + match_results::const_iterator, _Alloc>&, + const basic_regex<_Ch_type, _Rx_traits>&, + regex_constants::match_flag_type + = regex_constants::match_default) = delete; + + // std [28.11.4] Function template regex_replace + /** + * @brief Search for a regular expression within a range for multiple times, + and replace the matched parts through filling a format string. + * @param __out [OUT] The output iterator. + * @param __first [IN] The start of the string to search. + * @param __last [IN] One-past-the-end of the string to search. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns __out + * @throws an exception of type regex_error. + */ + template + inline _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type, _St, _Sa>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + return regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags); + } + + /** + * @brief Search for a regular expression within a range for multiple times, + and replace the matched parts through filling a format C-string. + * @param __out [OUT] The output iterator. + * @param __first [IN] The start of the string to search. + * @param __last [IN] One-past-the-end of the string to search. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format C-string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns __out + * @throws an exception of type regex_error. + */ + template + _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default); + + /** + * @brief Search for a regular expression within a string for multiple times, + and replace the matched parts through filling a format string. + * @param __s [IN] The string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type, _St, _Sa> + regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type, _Fst, _Fsa>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type, _St, _Sa> __result; + regex_replace(std::back_inserter(__result), + __s.begin(), __s.end(), __e, __fmt, __flags); + return __result; + } + + /** + * @brief Search for a regular expression within a string for multiple times, + and replace the matched parts through filling a format C-string. + * @param __s [IN] The string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format C-string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type, _St, _Sa> + regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type, _St, _Sa> __result; + regex_replace(std::back_inserter(__result), + __s.begin(), __s.end(), __e, __fmt, __flags); + return __result; + } + + /** + * @brief Search for a regular expression within a C-string for multiple + times, and replace the matched parts through filling a format string. + * @param __s [IN] The C-string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type> + regex_replace(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const basic_string<_Ch_type, _St, _Sa>& __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type> __result; + regex_replace(std::back_inserter(__result), __s, + __s + char_traits<_Ch_type>::length(__s), + __e, __fmt, __flags); + return __result; + } + + /** + * @brief Search for a regular expression within a C-string for multiple + times, and replace the matched parts through filling a format C-string. + * @param __s [IN] The C-string to search and replace. + * @param __e [IN] The regular expression to search for. + * @param __fmt [IN] The format C-string. + * @param __flags [IN] Search and replace policy flags. + * + * @returns The string after replacing. + * @throws an exception of type regex_error. + */ + template + inline basic_string<_Ch_type> + regex_replace(const _Ch_type* __s, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags + = regex_constants::match_default) + { + basic_string<_Ch_type> __result; + regex_replace(std::back_inserter(__result), __s, + __s + char_traits<_Ch_type>::length(__s), + __e, __fmt, __flags); + return __result; + } + + ///@} + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + // std [28.12] Class template regex_iterator + /** + * An iterator adaptor that will provide repeated calls of regex_search over + * a range until no more matches remain. + */ + template::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef match_results<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + /** + * @brief Provides a singular iterator, useful for indicating + * one-past-the-end of a range. + */ + regex_iterator() = default; + + /** + * Constructs a %regex_iterator... + * @param __a [IN] The start of a text range to search. + * @param __b [IN] One-past-the-end of the text range to search. + * @param __re [IN] The regular expression to match. + * @param __m [IN] Policy flags for match rules. + */ + regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_begin(__a), _M_end(__b), _M_pregex(&__re), _M_flags(__m), _M_match() + { + if (!regex_search(_M_begin, _M_end, _M_match, *_M_pregex, _M_flags)) + *this = regex_iterator(); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2332. regex_iterator should forbid temporary regexes + regex_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + regex_constants::match_flag_type + = regex_constants::match_default) = delete; + + /// Copy constructs a %regex_iterator. + regex_iterator(const regex_iterator&) = default; + + /// Copy assigns one %regex_iterator to another. + regex_iterator& + operator=(const regex_iterator&) = default; + + ~regex_iterator() = default; + + /** + * @brief Tests the equivalence of two regex iterators. + */ + bool + operator==(const regex_iterator&) const noexcept; + + /** + * @brief Tests the inequivalence of two regex iterators. + */ + bool + operator!=(const regex_iterator& __rhs) const noexcept + { return !(*this == __rhs); } + + /** + * @brief Dereferences a %regex_iterator. + */ + const value_type& + operator*() const noexcept + { return _M_match; } + + /** + * @brief Selects a %regex_iterator member. + */ + const value_type* + operator->() const noexcept + { return &_M_match; } + + /** + * @brief Increments a %regex_iterator. + */ + regex_iterator& + operator++(); + + /** + * @brief Postincrements a %regex_iterator. + */ + regex_iterator + operator++(int) + { + auto __tmp = *this; + ++(*this); + return __tmp; + } + + private: + _Bi_iter _M_begin {}; + _Bi_iter _M_end {}; + const regex_type* _M_pregex = nullptr; + regex_constants::match_flag_type _M_flags {}; + match_results<_Bi_iter> _M_match; + }; + + typedef regex_iterator cregex_iterator; + typedef regex_iterator sregex_iterator; +#ifdef _GLIBCXX_USE_WCHAR_T + typedef regex_iterator wcregex_iterator; + typedef regex_iterator wsregex_iterator; +#endif + + // [7.12.2] Class template regex_token_iterator + /** + * Iterates over submatches in a range (or @a splits a text string). + * + * The purpose of this iterator is to enumerate all, or all specified, + * matches of a regular expression within a text range. The dereferenced + * value of an iterator of this class is a std::sub_match object. + */ + template::value_type, + typename _Rx_traits = regex_traits<_Ch_type> > + class regex_token_iterator + { + public: + typedef basic_regex<_Ch_type, _Rx_traits> regex_type; + typedef sub_match<_Bi_iter> value_type; + typedef std::ptrdiff_t difference_type; + typedef const value_type* pointer; + typedef const value_type& reference; + typedef std::forward_iterator_tag iterator_category; + + public: + /** + * @brief Default constructs a %regex_token_iterator. + * + * A default-constructed %regex_token_iterator is a singular iterator + * that will compare equal to the one-past-the-end value for any + * iterator of the same type. + */ + regex_token_iterator() + : _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr), + _M_has_m1(false) + { } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatch [IN] Which submatch to return. There are some + * special values for this parameter: + * - -1 each enumerated subexpression does NOT + * match the regular expression (aka field + * splitting) + * - 0 the entire string matching the + * subexpression is returned for each match + * within the text. + * - >0 enumerates only the indicated + * subexpression from a match within the text. + * @param __m [IN] Policy flags for match rules. + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, + int __submatch = 0, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), _M_subs(1, __submatch), _M_n(0) + { _M_init(__a, __b); } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param __m [IN] Policy flags for match rules. + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const std::vector& __submatches, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0) + { _M_init(__a, __b); } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param __m [IN] Policy flags for match rules. + */ + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + initializer_list __submatches, + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0) + { _M_init(__a, __b); } + + /** + * Constructs a %regex_token_iterator... + * @param __a [IN] The start of the text to search. + * @param __b [IN] One-past-the-end of the text to search. + * @param __re [IN] The regular expression to search for. + * @param __submatches [IN] A list of subexpressions to return for each + * regular expression match within the text. + * @param __m [IN] Policy flags for match rules. + */ + template + regex_token_iterator(_Bi_iter __a, _Bi_iter __b, + const regex_type& __re, + const int (&__submatches)[_Nm], + regex_constants::match_flag_type __m + = regex_constants::match_default) + : _M_position(__a, __b, __re, __m), + _M_subs(__submatches, __submatches + _Nm), _M_n(0) + { _M_init(__a, __b); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2332. regex_token_iterator should forbid temporary regexes + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, int = 0, + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + const std::vector&, + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + initializer_list, + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + template + regex_token_iterator(_Bi_iter, _Bi_iter, const regex_type&&, + const int (&)[_Nm], + regex_constants::match_flag_type = + regex_constants::match_default) = delete; + + /** + * @brief Copy constructs a %regex_token_iterator. + * @param __rhs [IN] A %regex_token_iterator to copy. + */ + regex_token_iterator(const regex_token_iterator& __rhs) + : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs), + _M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_has_m1(__rhs._M_has_m1) + { _M_normalize_result(); } + + /** + * @brief Assigns a %regex_token_iterator to another. + * @param __rhs [IN] A %regex_token_iterator to copy. + */ + regex_token_iterator& + operator=(const regex_token_iterator& __rhs); + + /** + * @brief Compares a %regex_token_iterator to another for equality. + */ + bool + operator==(const regex_token_iterator& __rhs) const; + + /** + * @brief Compares a %regex_token_iterator to another for inequality. + */ + bool + operator!=(const regex_token_iterator& __rhs) const + { return !(*this == __rhs); } + + /** + * @brief Dereferences a %regex_token_iterator. + */ + const value_type& + operator*() const + { return *_M_result; } + + /** + * @brief Selects a %regex_token_iterator member. + */ + const value_type* + operator->() const + { return _M_result; } + + /** + * @brief Increments a %regex_token_iterator. + */ + regex_token_iterator& + operator++(); + + /** + * @brief Postincrements a %regex_token_iterator. + */ + regex_token_iterator + operator++(int) + { + auto __tmp = *this; + ++(*this); + return __tmp; + } + + private: + typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _Position; + + void + _M_init(_Bi_iter __a, _Bi_iter __b); + + const value_type& + _M_current_match() const + { + if (_M_subs[_M_n] == -1) + return (*_M_position).prefix(); + else + return (*_M_position)[_M_subs[_M_n]]; + } + + constexpr bool + _M_end_of_seq() const + { return _M_result == nullptr; } + + // [28.12.2.2.4] + void + _M_normalize_result() + { + if (_M_position != _Position()) + _M_result = &_M_current_match(); + else if (_M_has_m1) + _M_result = &_M_suffix; + else + _M_result = nullptr; + } + + _Position _M_position; + std::vector _M_subs; + value_type _M_suffix; + std::size_t _M_n; + const value_type* _M_result; + + // Show whether _M_subs contains -1 + bool _M_has_m1; + }; + + /** @brief Token iterator for C-style NULL-terminated strings. */ + typedef regex_token_iterator cregex_token_iterator; + + /** @brief Token iterator for standard strings. */ + typedef regex_token_iterator sregex_token_iterator; + +#ifdef _GLIBCXX_USE_WCHAR_T + /** @brief Token iterator for C-style NULL-terminated wide strings. */ + typedef regex_token_iterator wcregex_token_iterator; + + /** @brief Token iterator for standard wide-character strings. */ + typedef regex_token_iterator wsregex_token_iterator; +#endif + + ///@} // group regex + +_GLIBCXX_END_NAMESPACE_CXX11 +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex.tcc new file mode 100755 index 0000000..39ad3f0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex.tcc @@ -0,0 +1,672 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /// @cond undocumented + + // Result of merging regex_match and regex_search. + // + // __policy now can be _S_auto (auto dispatch) and _S_alternate (use + // the other one if possible, for test purpose). + // + // That __match_mode is true means regex_match, else regex_search. + template + bool + __regex_algo_impl(_BiIter __s, + _BiIter __e, + match_results<_BiIter, _Alloc>& __m, + const basic_regex<_CharT, _TraitsT>& __re, + regex_constants::match_flag_type __flags) + { + if (__re._M_automaton == nullptr) + return false; + + typename match_results<_BiIter, _Alloc>::_Base_type& __res = __m; + __m._M_begin = __s; + __m._M_resize(__re._M_automaton->_M_sub_count()); + + bool __ret; + if ((__re.flags() & regex_constants::__polynomial) + || (__policy == _RegexExecutorPolicy::_S_alternate + && !__re._M_automaton->_M_has_backref)) + { + _Executor<_BiIter, _Alloc, _TraitsT, false> + __executor(__s, __e, __m, __re, __flags); + if (__match_mode) + __ret = __executor._M_match(); + else + __ret = __executor._M_search(); + } + else + { + _Executor<_BiIter, _Alloc, _TraitsT, true> + __executor(__s, __e, __m, __re, __flags); + if (__match_mode) + __ret = __executor._M_match(); + else + __ret = __executor._M_search(); + } + if (__ret) + { + for (auto& __it : __res) + if (!__it.matched) + __it.first = __it.second = __e; + auto& __pre = __m._M_prefix(); + auto& __suf = __m._M_suffix(); + if (__match_mode) + { + __pre.matched = false; + __pre.first = __s; + __pre.second = __s; + __suf.matched = false; + __suf.first = __e; + __suf.second = __e; + } + else + { + __pre.first = __s; + __pre.second = __res[0].first; + __pre.matched = (__pre.first != __pre.second); + __suf.first = __res[0].second; + __suf.second = __e; + __suf.matched = (__suf.first != __suf.second); + } + } + else + { + __m._M_establish_failed_match(__e); + } + return __ret; + } + /// @endcond +} // namespace __detail + + /// @cond + + template + template + typename regex_traits<_Ch_type>::string_type + regex_traits<_Ch_type>:: + lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + + static const char* __collatenames[] = + { + "NUL", + "SOH", + "STX", + "ETX", + "EOT", + "ENQ", + "ACK", + "alert", + "backspace", + "tab", + "newline", + "vertical-tab", + "form-feed", + "carriage-return", + "SO", + "SI", + "DLE", + "DC1", + "DC2", + "DC3", + "DC4", + "NAK", + "SYN", + "ETB", + "CAN", + "EM", + "SUB", + "ESC", + "IS4", + "IS3", + "IS2", + "IS1", + "space", + "exclamation-mark", + "quotation-mark", + "number-sign", + "dollar-sign", + "percent-sign", + "ampersand", + "apostrophe", + "left-parenthesis", + "right-parenthesis", + "asterisk", + "plus-sign", + "comma", + "hyphen", + "period", + "slash", + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "colon", + "semicolon", + "less-than-sign", + "equals-sign", + "greater-than-sign", + "question-mark", + "commercial-at", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + "left-square-bracket", + "backslash", + "right-square-bracket", + "circumflex", + "underscore", + "grave-accent", + "a", + "b", + "c", + "d", + "e", + "f", + "g", + "h", + "i", + "j", + "k", + "l", + "m", + "n", + "o", + "p", + "q", + "r", + "s", + "t", + "u", + "v", + "w", + "x", + "y", + "z", + "left-curly-bracket", + "vertical-line", + "right-curly-bracket", + "tilde", + "DEL", + }; + + string __s; + for (; __first != __last; ++__first) + __s += __fctyp.narrow(*__first, 0); + + for (const auto& __it : __collatenames) + if (__s == __it) + return string_type(1, __fctyp.widen( + static_cast(&__it - __collatenames))); + + // TODO Add digraph support: + // http://boost.sourceforge.net/libs/regex/doc/collating_names.html + + return string_type(); + } + + template + template + typename regex_traits<_Ch_type>::char_class_type + regex_traits<_Ch_type>:: + lookup_classname(_Fwd_iter __first, _Fwd_iter __last, bool __icase) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + + // Mappings from class name to class mask. + static const pair __classnames[] = + { + {"d", ctype_base::digit}, + {"w", {ctype_base::alnum, _RegexMask::_S_under}}, + {"s", ctype_base::space}, + {"alnum", ctype_base::alnum}, + {"alpha", ctype_base::alpha}, + {"blank", ctype_base::blank}, + {"cntrl", ctype_base::cntrl}, + {"digit", ctype_base::digit}, + {"graph", ctype_base::graph}, + {"lower", ctype_base::lower}, + {"print", ctype_base::print}, + {"punct", ctype_base::punct}, + {"space", ctype_base::space}, + {"upper", ctype_base::upper}, + {"xdigit", ctype_base::xdigit}, + }; + + string __s; + for (; __first != __last; ++__first) + __s += __fctyp.narrow(__fctyp.tolower(*__first), 0); + + for (const auto& __it : __classnames) + if (__s == __it.first) + { + if (__icase + && ((__it.second + & (ctype_base::lower | ctype_base::upper)) != 0)) + return ctype_base::alpha; + return __it.second; + } + return 0; + } + + template + bool + regex_traits<_Ch_type>:: + isctype(_Ch_type __c, char_class_type __f) const + { + typedef std::ctype __ctype_type; + const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale)); + + return __fctyp.is(__f._M_base, __c) + // [[:w:]] + || ((__f._M_extended & _RegexMask::_S_under) + && __c == __fctyp.widen('_')); + } + + template + int + regex_traits<_Ch_type>:: + value(_Ch_type __ch, int __radix) const + { + std::basic_istringstream __is(string_type(1, __ch)); + long __v; + if (__radix == 8) + __is >> std::oct; + else if (__radix == 16) + __is >> std::hex; + __is >> __v; + return __is.fail() ? -1 : __v; + } + + template + template + _Out_iter + match_results<_Bi_iter, _Alloc>:: + format(_Out_iter __out, + const match_results<_Bi_iter, _Alloc>::char_type* __fmt_first, + const match_results<_Bi_iter, _Alloc>::char_type* __fmt_last, + match_flag_type __flags) const + { + __glibcxx_assert( ready() ); + regex_traits __traits; + typedef std::ctype __ctype_type; + const __ctype_type& + __fctyp(use_facet<__ctype_type>(__traits.getloc())); + + auto __output = [&](size_t __idx) + { + auto& __sub = (*this)[__idx]; + if (__sub.matched) + __out = std::copy(__sub.first, __sub.second, __out); + }; + + if (__flags & regex_constants::format_sed) + { + bool __escaping = false; + for (; __fmt_first != __fmt_last; __fmt_first++) + { + if (__escaping) + { + __escaping = false; + if (__fctyp.is(__ctype_type::digit, *__fmt_first)) + __output(__traits.value(*__fmt_first, 10)); + else + *__out++ = *__fmt_first; + continue; + } + if (*__fmt_first == '\\') + { + __escaping = true; + continue; + } + if (*__fmt_first == '&') + { + __output(0); + continue; + } + *__out++ = *__fmt_first; + } + if (__escaping) + *__out++ = '\\'; + } + else + { + while (1) + { + auto __next = std::find(__fmt_first, __fmt_last, '$'); + if (__next == __fmt_last) + break; + + __out = std::copy(__fmt_first, __next, __out); + + auto __eat = [&](char __ch) -> bool + { + if (*__next == __ch) + { + ++__next; + return true; + } + return false; + }; + + if (++__next == __fmt_last) + *__out++ = '$'; + else if (__eat('$')) + *__out++ = '$'; + else if (__eat('&')) + __output(0); + else if (__eat('`')) + { + auto& __sub = _M_prefix(); + if (__sub.matched) + __out = std::copy(__sub.first, __sub.second, __out); + } + else if (__eat('\'')) + { + auto& __sub = _M_suffix(); + if (__sub.matched) + __out = std::copy(__sub.first, __sub.second, __out); + } + else if (__fctyp.is(__ctype_type::digit, *__next)) + { + long __num = __traits.value(*__next, 10); + if (++__next != __fmt_last + && __fctyp.is(__ctype_type::digit, *__next)) + { + __num *= 10; + __num += __traits.value(*__next++, 10); + } + if (0 <= __num && __num < this->size()) + __output(__num); + } + else + *__out++ = '$'; + __fmt_first = __next; + } + __out = std::copy(__fmt_first, __fmt_last, __out); + } + return __out; + } + + template + _Out_iter + regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, + const basic_regex<_Ch_type, _Rx_traits>& __e, + const _Ch_type* __fmt, + regex_constants::match_flag_type __flags) + { + typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _IterT; + _IterT __i(__first, __last, __e, __flags); + _IterT __end; + if (__i == __end) + { + if (!(__flags & regex_constants::format_no_copy)) + __out = std::copy(__first, __last, __out); + } + else + { + sub_match<_Bi_iter> __last; + auto __len = char_traits<_Ch_type>::length(__fmt); + for (; __i != __end; ++__i) + { + if (!(__flags & regex_constants::format_no_copy)) + __out = std::copy(__i->prefix().first, __i->prefix().second, + __out); + __out = __i->format(__out, __fmt, __fmt + __len, __flags); + __last = __i->suffix(); + if (__flags & regex_constants::format_first_only) + break; + } + if (!(__flags & regex_constants::format_no_copy)) + __out = std::copy(__last.first, __last.second, __out); + } + return __out; + } + + template + bool + regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator==(const regex_iterator& __rhs) const noexcept + { + if (_M_pregex == nullptr && __rhs._M_pregex == nullptr) + return true; + return _M_pregex == __rhs._M_pregex + && _M_begin == __rhs._M_begin + && _M_end == __rhs._M_end + && _M_flags == __rhs._M_flags + && _M_match[0] == __rhs._M_match[0]; + } + + template + regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>& + regex_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator++() + { + // In all cases in which the call to regex_search returns true, + // match.prefix().first shall be equal to the previous value of + // match[0].second, and for each index i in the half-open range + // [0, match.size()) for which match[i].matched is true, + // match[i].position() shall return distance(begin, match[i].first). + // [28.12.1.4.5] + if (_M_match[0].matched) + { + auto __start = _M_match[0].second; + auto __prefix_first = _M_match[0].second; + if (_M_match[0].first == _M_match[0].second) + { + if (__start == _M_end) + { + _M_pregex = nullptr; + return *this; + } + else + { + if (regex_search(__start, _M_end, _M_match, *_M_pregex, + _M_flags + | regex_constants::match_not_null + | regex_constants::match_continuous)) + { + __glibcxx_assert(_M_match[0].matched); + auto& __prefix = _M_match._M_prefix(); + __prefix.first = __prefix_first; + __prefix.matched = __prefix.first != __prefix.second; + // [28.12.1.4.5] + _M_match._M_begin = _M_begin; + return *this; + } + else + ++__start; + } + } + _M_flags |= regex_constants::match_prev_avail; + if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags)) + { + __glibcxx_assert(_M_match[0].matched); + auto& __prefix = _M_match._M_prefix(); + __prefix.first = __prefix_first; + __prefix.matched = __prefix.first != __prefix.second; + // [28.12.1.4.5] + _M_match._M_begin = _M_begin; + } + else + _M_pregex = nullptr; + } + return *this; + } + + template + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>& + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator=(const regex_token_iterator& __rhs) + { + _M_position = __rhs._M_position; + _M_subs = __rhs._M_subs; + _M_n = __rhs._M_n; + _M_suffix = __rhs._M_suffix; + _M_has_m1 = __rhs._M_has_m1; + _M_normalize_result(); + return *this; + } + + template + bool + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator==(const regex_token_iterator& __rhs) const + { + if (_M_end_of_seq() && __rhs._M_end_of_seq()) + return true; + if (_M_suffix.matched && __rhs._M_suffix.matched + && _M_suffix == __rhs._M_suffix) + return true; + if (_M_end_of_seq() || _M_suffix.matched + || __rhs._M_end_of_seq() || __rhs._M_suffix.matched) + return false; + return _M_position == __rhs._M_position + && _M_n == __rhs._M_n + && _M_subs == __rhs._M_subs; + } + + template + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>& + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + operator++() + { + _Position __prev = _M_position; + if (_M_suffix.matched) + *this = regex_token_iterator(); + else if (_M_n + 1 < _M_subs.size()) + { + _M_n++; + _M_result = &_M_current_match(); + } + else + { + _M_n = 0; + ++_M_position; + if (_M_position != _Position()) + _M_result = &_M_current_match(); + else if (_M_has_m1 && __prev->suffix().length() != 0) + { + _M_suffix.matched = true; + _M_suffix.first = __prev->suffix().first; + _M_suffix.second = __prev->suffix().second; + _M_result = &_M_suffix; + } + else + *this = regex_token_iterator(); + } + return *this; + } + + template + void + regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>:: + _M_init(_Bi_iter __a, _Bi_iter __b) + { + _M_has_m1 = false; + for (auto __it : _M_subs) + if (__it == -1) + { + _M_has_m1 = true; + break; + } + if (_M_position != _Position()) + _M_result = &_M_current_match(); + else if (_M_has_m1) + { + _M_suffix.matched = true; + _M_suffix.first = __a; + _M_suffix.second = __b; + _M_result = &_M_suffix; + } + else + _M_result = nullptr; + } + + /// @endcond + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_automaton.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_automaton.h new file mode 100755 index 0000000..872a17f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_automaton.h @@ -0,0 +1,401 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_automaton.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// This macro defines the maximal state number a NFA can have. +#ifndef _GLIBCXX_REGEX_STATE_LIMIT +#define _GLIBCXX_REGEX_STATE_LIMIT 100000 +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * @defgroup regex-detail Base and Implementation Classes + * @ingroup regex + * @{ + */ + + typedef long _StateIdT; + static const _StateIdT _S_invalid_state_id = -1; + + template + using _Matcher = std::function; + + /// Operation codes that define the type of transitions within the base NFA + /// that represents the regular expression. + enum _Opcode : int + { + _S_opcode_unknown, + _S_opcode_alternative, + _S_opcode_repeat, + _S_opcode_backref, + _S_opcode_line_begin_assertion, + _S_opcode_line_end_assertion, + _S_opcode_word_boundary, + _S_opcode_subexpr_lookahead, + _S_opcode_subexpr_begin, + _S_opcode_subexpr_end, + _S_opcode_dummy, + _S_opcode_match, + _S_opcode_accept, + }; + + struct _State_base + { + protected: + _Opcode _M_opcode; // type of outgoing transition + + public: + _StateIdT _M_next; // outgoing transition + union // Since they are mutually exclusive. + { + size_t _M_subexpr; // for _S_opcode_subexpr_* + size_t _M_backref_index; // for _S_opcode_backref + struct + { + // for _S_opcode_alternative, _S_opcode_repeat and + // _S_opcode_subexpr_lookahead + _StateIdT _M_alt; + // for _S_opcode_word_boundary or _S_opcode_subexpr_lookahead or + // quantifiers (ungreedy if set true) + bool _M_neg; + }; + // For _S_opcode_match + __gnu_cxx::__aligned_membuf<_Matcher> _M_matcher_storage; + }; + + protected: + explicit _State_base(_Opcode __opcode) + : _M_opcode(__opcode), _M_next(_S_invalid_state_id) + { } + + public: + bool + _M_has_alt() + { + return _M_opcode == _S_opcode_alternative + || _M_opcode == _S_opcode_repeat + || _M_opcode == _S_opcode_subexpr_lookahead; + } + +#ifdef _GLIBCXX_DEBUG + std::ostream& + _M_print(std::ostream& ostr) const; + + // Prints graphviz dot commands for state. + std::ostream& + _M_dot(std::ostream& __ostr, _StateIdT __id) const; +#endif + }; + + template + struct _State : _State_base + { + typedef _Matcher<_Char_type> _MatcherT; + static_assert(sizeof(_MatcherT) == sizeof(_Matcher), + "std::function has the same size as " + "std::function"); + static_assert(alignof(_MatcherT) == alignof(_Matcher), + "std::function has the same alignment as " + "std::function"); + + explicit + _State(_Opcode __opcode) : _State_base(__opcode) + { + if (_M_opcode() == _S_opcode_match) + new (this->_M_matcher_storage._M_addr()) _MatcherT(); + } + + _State(const _State& __rhs) : _State_base(__rhs) + { + if (__rhs._M_opcode() == _S_opcode_match) + new (this->_M_matcher_storage._M_addr()) + _MatcherT(__rhs._M_get_matcher()); + } + + _State(_State&& __rhs) : _State_base(__rhs) + { + if (__rhs._M_opcode() == _S_opcode_match) + new (this->_M_matcher_storage._M_addr()) + _MatcherT(std::move(__rhs._M_get_matcher())); + } + + _State& + operator=(const _State&) = delete; + + ~_State() + { + if (_M_opcode() == _S_opcode_match) + _M_get_matcher().~_MatcherT(); + } + + // Since correct ctor and dtor rely on _M_opcode, it's better not to + // change it over time. + _Opcode + _M_opcode() const + { return _State_base::_M_opcode; } + + bool + _M_matches(_Char_type __char) const + { return _M_get_matcher()(__char); } + + _MatcherT& + _M_get_matcher() + { return *static_cast<_MatcherT*>(this->_M_matcher_storage._M_addr()); } + + const _MatcherT& + _M_get_matcher() const + { + return *static_cast( + this->_M_matcher_storage._M_addr()); + } + }; + + struct _NFA_base + { + typedef size_t _SizeT; + typedef regex_constants::syntax_option_type _FlagT; + + explicit + _NFA_base(_FlagT __f) + : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0), + _M_has_backref(false) + { } + + _NFA_base(_NFA_base&&) = default; + + protected: + ~_NFA_base() = default; + + public: + _FlagT + _M_options() const + { return _M_flags; } + + _StateIdT + _M_start() const + { return _M_start_state; } + + _SizeT + _M_sub_count() const + { return _M_subexpr_count; } + + _GLIBCXX_STD_C::vector _M_paren_stack; + _FlagT _M_flags; + _StateIdT _M_start_state; + _SizeT _M_subexpr_count; + bool _M_has_backref; + }; + + template + struct _NFA + : _NFA_base, _GLIBCXX_STD_C::vector<_State> + { + typedef typename _TraitsT::char_type _Char_type; + typedef _State<_Char_type> _StateT; + typedef _Matcher<_Char_type> _MatcherT; + + _NFA(const typename _TraitsT::locale_type& __loc, _FlagT __flags) + : _NFA_base(__flags) + { _M_traits.imbue(__loc); } + + // for performance reasons _NFA objects should only be moved not copied + _NFA(const _NFA&) = delete; + _NFA(_NFA&&) = default; + + _StateIdT + _M_insert_accept() + { + auto __ret = _M_insert_state(_StateT(_S_opcode_accept)); + return __ret; + } + + _StateIdT + _M_insert_alt(_StateIdT __next, _StateIdT __alt, + bool __neg __attribute__((__unused__))) + { + _StateT __tmp(_S_opcode_alternative); + // It labels every quantifier to make greedy comparison easier in BFS + // approach. + __tmp._M_next = __next; + __tmp._M_alt = __alt; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_repeat(_StateIdT __next, _StateIdT __alt, bool __neg) + { + _StateT __tmp(_S_opcode_repeat); + // It labels every quantifier to make greedy comparison easier in BFS + // approach. + __tmp._M_next = __next; + __tmp._M_alt = __alt; + __tmp._M_neg = __neg; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_matcher(_MatcherT __m) + { + _StateT __tmp(_S_opcode_match); + __tmp._M_get_matcher() = std::move(__m); + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_subexpr_begin() + { + auto __id = this->_M_subexpr_count++; + this->_M_paren_stack.push_back(__id); + _StateT __tmp(_S_opcode_subexpr_begin); + __tmp._M_subexpr = __id; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_subexpr_end() + { + _StateT __tmp(_S_opcode_subexpr_end); + __tmp._M_subexpr = this->_M_paren_stack.back(); + this->_M_paren_stack.pop_back(); + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_backref(size_t __index); + + _StateIdT + _M_insert_line_begin() + { return _M_insert_state(_StateT(_S_opcode_line_begin_assertion)); } + + _StateIdT + _M_insert_line_end() + { return _M_insert_state(_StateT(_S_opcode_line_end_assertion)); } + + _StateIdT + _M_insert_word_bound(bool __neg) + { + _StateT __tmp(_S_opcode_word_boundary); + __tmp._M_neg = __neg; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_lookahead(_StateIdT __alt, bool __neg) + { + _StateT __tmp(_S_opcode_subexpr_lookahead); + __tmp._M_alt = __alt; + __tmp._M_neg = __neg; + return _M_insert_state(std::move(__tmp)); + } + + _StateIdT + _M_insert_dummy() + { return _M_insert_state(_StateT(_S_opcode_dummy)); } + + _StateIdT + _M_insert_state(_StateT __s) + { + this->push_back(std::move(__s)); + if (this->size() > _GLIBCXX_REGEX_STATE_LIMIT) + __throw_regex_error( + regex_constants::error_space, + "Number of NFA states exceeds limit. Please use shorter regex " + "string, or use smaller brace expression, or make " + "_GLIBCXX_REGEX_STATE_LIMIT larger."); + return this->size() - 1; + } + + // Eliminate dummy node in this NFA to make it compact. + void + _M_eliminate_dummy(); + +#ifdef _GLIBCXX_DEBUG + std::ostream& + _M_dot(std::ostream& __ostr) const; +#endif + public: + _TraitsT _M_traits; + }; + + /// Describes a sequence of one or more %_State, its current start + /// and end(s). This structure contains fragments of an NFA during + /// construction. + template + class _StateSeq + { + public: + typedef _NFA<_TraitsT> _RegexT; + + public: + _StateSeq(_RegexT& __nfa, _StateIdT __s) + : _M_nfa(__nfa), _M_start(__s), _M_end(__s) + { } + + _StateSeq(_RegexT& __nfa, _StateIdT __s, _StateIdT __end) + : _M_nfa(__nfa), _M_start(__s), _M_end(__end) + { } + + // Append a state on *this and change *this to the new sequence. + void + _M_append(_StateIdT __id) + { + _M_nfa[_M_end]._M_next = __id; + _M_end = __id; + } + + // Append a sequence on *this and change *this to the new sequence. + void + _M_append(const _StateSeq& __s) + { + _M_nfa[_M_end]._M_next = __s._M_start; + _M_end = __s._M_end; + } + + // Clones an entire sequence. + _StateSeq + _M_clone(); + + public: + _RegexT& _M_nfa; + _StateIdT _M_start; + _StateIdT _M_end; + }; + + ///@} regex-detail +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_automaton.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_automaton.tcc new file mode 100755 index 0000000..0977f77 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_automaton.tcc @@ -0,0 +1,232 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_automaton.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ +#ifdef _GLIBCXX_DEBUG + inline std::ostream& + _State_base::_M_print(std::ostream& ostr) const + { + switch (_M_opcode) + { + case _S_opcode_alternative: + case _S_opcode_repeat: + ostr << "alt next=" << _M_next << " alt=" << _M_alt; + break; + case _S_opcode_subexpr_begin: + ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr; + break; + case _S_opcode_subexpr_end: + ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr; + break; + case _S_opcode_backref: + ostr << "backref next=" << _M_next << " index=" << _M_backref_index; + break; + case _S_opcode_match: + ostr << "match next=" << _M_next; + break; + case _S_opcode_accept: + ostr << "accept next=" << _M_next; + break; + default: + ostr << "unknown next=" << _M_next; + break; + } + return ostr; + } + + // Prints graphviz dot commands for state. + inline std::ostream& + _State_base::_M_dot(std::ostream& __ostr, _StateIdT __id) const + { + switch (_M_opcode) + { + case _S_opcode_alternative: + case _S_opcode_repeat: + __ostr << __id << " [label=\"" << __id << "\\nALT\"];\n" + << __id << " -> " << _M_next + << " [label=\"next\", tailport=\"s\"];\n" + << __id << " -> " << _M_alt + << " [label=\"alt\", tailport=\"n\"];\n"; + break; + case _S_opcode_backref: + __ostr << __id << " [label=\"" << __id << "\\nBACKREF " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"\"];\n"; + break; + case _S_opcode_line_begin_assertion: + __ostr << __id << " [label=\"" << __id << "\\nLINE_BEGIN \"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_line_end_assertion: + __ostr << __id << " [label=\"" << __id << "\\nLINE_END \"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_word_boundary: + __ostr << __id << " [label=\"" << __id << "\\nWORD_BOUNDRY " + << _M_neg << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_subexpr_lookahead: + __ostr << __id << " [label=\"" << __id << "\\nLOOK_AHEAD\"];\n" + << __id << " -> " << _M_next + << " [label=\"epsilon\", tailport=\"s\"];\n" + << __id << " -> " << _M_alt + << " [label=\"\", tailport=\"n\"];\n"; + break; + case _S_opcode_subexpr_begin: + __ostr << __id << " [label=\"" << __id << "\\nSBEGIN " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_subexpr_end: + __ostr << __id << " [label=\"" << __id << "\\nSEND " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_dummy: + break; + case _S_opcode_match: + __ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n" + << __id << " -> " << _M_next << " [label=\"\"];\n"; + break; + case _S_opcode_accept: + __ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ; + break; + default: + _GLIBCXX_DEBUG_ASSERT(false); + break; + } + return __ostr; + } + + template + std::ostream& + _NFA<_TraitsT>::_M_dot(std::ostream& __ostr) const + { + __ostr << "digraph _Nfa {\n" + " rankdir=LR;\n"; + for (size_t __i = 0; __i < this->size(); ++__i) + (*this)[__i]._M_dot(__ostr, __i); + __ostr << "}\n"; + return __ostr; + } +#endif + + template + _StateIdT + _NFA<_TraitsT>::_M_insert_backref(size_t __index) + { + if (this->_M_flags & regex_constants::__polynomial) + __throw_regex_error(regex_constants::error_complexity, + "Unexpected back-reference in polynomial mode."); + // To figure out whether a backref is valid, a stack is used to store + // unfinished sub-expressions. For example, when parsing + // "(a(b)(c\\1(d)))" at '\\1', _M_subexpr_count is 3, indicating that 3 + // sub expressions are parsed or partially parsed(in the stack), aka, + // "(a..", "(b)" and "(c.."). + // _M_paren_stack is {1, 3}, for incomplete "(a.." and "(c..". At this + // time, "\\2" is valid, but "\\1" and "\\3" are not. + if (__index >= _M_subexpr_count) + __throw_regex_error( + regex_constants::error_backref, + "Back-reference index exceeds current sub-expression count."); + for (auto __it : this->_M_paren_stack) + if (__index == __it) + __throw_regex_error( + regex_constants::error_backref, + "Back-reference referred to an opened sub-expression."); + this->_M_has_backref = true; + _StateT __tmp(_S_opcode_backref); + __tmp._M_backref_index = __index; + return _M_insert_state(std::move(__tmp)); + } + + template + void + _NFA<_TraitsT>::_M_eliminate_dummy() + { + for (auto& __it : *this) + { + while (__it._M_next >= 0 && (*this)[__it._M_next]._M_opcode() + == _S_opcode_dummy) + __it._M_next = (*this)[__it._M_next]._M_next; + if (__it._M_has_alt()) + while (__it._M_alt >= 0 && (*this)[__it._M_alt]._M_opcode() + == _S_opcode_dummy) + __it._M_alt = (*this)[__it._M_alt]._M_next; + } + } + + // Just apply DFS on the sequence and re-link their links. + template + _StateSeq<_TraitsT> + _StateSeq<_TraitsT>::_M_clone() + { + std::map<_StateIdT, _StateIdT> __m; + std::stack<_StateIdT> __stack; + __stack.push(_M_start); + while (!__stack.empty()) + { + auto __u = __stack.top(); + __stack.pop(); + auto __dup = _M_nfa[__u]; + // _M_insert_state() never return -1 + auto __id = _M_nfa._M_insert_state(std::move(__dup)); + __m[__u] = __id; + if (__dup._M_has_alt()) + if (__dup._M_alt != _S_invalid_state_id + && __m.count(__dup._M_alt) == 0) + __stack.push(__dup._M_alt); + if (__u == _M_end) + continue; + if (__dup._M_next != _S_invalid_state_id + && __m.count(__dup._M_next) == 0) + __stack.push(__dup._M_next); + } + for (auto __it : __m) + { + auto __v = __it.second; + auto& __ref = _M_nfa[__v]; + if (__ref._M_next != _S_invalid_state_id) + __ref._M_next = __m.find(__ref._M_next)->second; + if (__ref._M_has_alt() && __ref._M_alt != _S_invalid_state_id) + __ref._M_alt = __m.find(__ref._M_alt)->second; + } + return _StateSeq(_M_nfa, __m[_M_start], __m[_M_end]); + } +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_compiler.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_compiler.h new file mode 100755 index 0000000..bf7dcc5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_compiler.h @@ -0,0 +1,560 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_compiler.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + template + class regex_traits; + +_GLIBCXX_END_NAMESPACE_CXX11 + +namespace __detail +{ + /** + * @addtogroup regex-detail + * @{ + */ + + template + struct _BracketMatcher; + + /** + * @brief Builds an NFA from an input iterator range. + * + * The %_TraitsT type should fulfill requirements [28.3]. + */ + template + class _Compiler + { + public: + typedef typename _TraitsT::char_type _CharT; + typedef const _CharT* _IterT; + typedef _NFA<_TraitsT> _RegexT; + typedef regex_constants::syntax_option_type _FlagT; + + _Compiler(_IterT __b, _IterT __e, + const typename _TraitsT::locale_type& __traits, _FlagT __flags); + + shared_ptr + _M_get_nfa() + { return std::move(_M_nfa); } + + private: + typedef _Scanner<_CharT> _ScannerT; + typedef typename _TraitsT::string_type _StringT; + typedef typename _ScannerT::_TokenT _TokenT; + typedef _StateSeq<_TraitsT> _StateSeqT; + typedef std::stack<_StateSeqT> _StackT; + typedef std::ctype<_CharT> _CtypeT; + + // accepts a specific token or returns false. + bool + _M_match_token(_TokenT __token); + + void + _M_disjunction(); + + void + _M_alternative(); + + bool + _M_term(); + + bool + _M_assertion(); + + bool + _M_quantifier(); + + bool + _M_atom(); + + bool + _M_bracket_expression(); + + template + void + _M_insert_any_matcher_ecma(); + + template + void + _M_insert_any_matcher_posix(); + + template + void + _M_insert_char_matcher(); + + template + void + _M_insert_character_class_matcher(); + + template + void + _M_insert_bracket_matcher(bool __neg); + + // Returns true if successfully matched one term and should continue. + // Returns false if the compiler should move on. + template + bool + _M_expression_term(pair& __last_char, + _BracketMatcher<_TraitsT, __icase, __collate>& + __matcher); + + int + _M_cur_int_value(int __radix); + + bool + _M_try_char(); + + _StateSeqT + _M_pop() + { + auto ret = _M_stack.top(); + _M_stack.pop(); + return ret; + } + + _FlagT _M_flags; + _ScannerT _M_scanner; + shared_ptr<_RegexT> _M_nfa; + _StringT _M_value; + _StackT _M_stack; + const _TraitsT& _M_traits; + const _CtypeT& _M_ctype; + }; + + template + struct __is_contiguous_iter : is_pointer<_Tp>::type { }; + + template + struct + __is_contiguous_iter<__gnu_cxx::__normal_iterator<_Tp*, _Cont>> + : true_type { }; + + template + using __enable_if_contiguous_iter + = __enable_if_t< __is_contiguous_iter<_Iter>::value, + std::shared_ptr> >; + + template + using __disable_if_contiguous_iter + = __enable_if_t< !__is_contiguous_iter<_Iter>::value, + std::shared_ptr> >; + + template + inline __enable_if_contiguous_iter<_FwdIter, _TraitsT> + __compile_nfa(_FwdIter __first, _FwdIter __last, + const typename _TraitsT::locale_type& __loc, + regex_constants::syntax_option_type __flags) + { + size_t __len = __last - __first; + const auto* __cfirst = __len ? std::__addressof(*__first) : nullptr; + using _Cmplr = _Compiler<_TraitsT>; + return _Cmplr(__cfirst, __cfirst + __len, __loc, __flags)._M_get_nfa(); + } + + template + inline __disable_if_contiguous_iter<_FwdIter, _TraitsT> + __compile_nfa(_FwdIter __first, _FwdIter __last, + const typename _TraitsT::locale_type& __loc, + regex_constants::syntax_option_type __flags) + { + const basic_string __str(__first, __last); + return __compile_nfa<_TraitsT>(__str.data(), __str.data() + __str.size(), + __loc, __flags); + } + + // [28.13.14] + template + class _RegexTranslatorBase + { + public: + typedef typename _TraitsT::char_type _CharT; + typedef typename _TraitsT::string_type _StringT; + typedef _StringT _StrTransT; + + explicit + _RegexTranslatorBase(const _TraitsT& __traits) + : _M_traits(__traits) + { } + + _CharT + _M_translate(_CharT __ch) const + { + if (__icase) + return _M_traits.translate_nocase(__ch); + else if (__collate) + return _M_traits.translate(__ch); + else + return __ch; + } + + _StrTransT + _M_transform(_CharT __ch) const + { + _StrTransT __str(1, __ch); + return _M_traits.transform(__str.begin(), __str.end()); + } + + // See LWG 523. It's not efficiently implementable when _TraitsT is not + // std::regex_traits<>, and __collate is true. See specializations for + // implementations of other cases. + bool + _M_match_range(const _StrTransT& __first, const _StrTransT& __last, + const _StrTransT& __s) const + { return __first <= __s && __s <= __last; } + + protected: + bool _M_in_range_icase(_CharT __first, _CharT __last, _CharT __ch) const + { + typedef std::ctype<_CharT> __ctype_type; + const auto& __fctyp = use_facet<__ctype_type>(this->_M_traits.getloc()); + auto __lower = __fctyp.tolower(__ch); + auto __upper = __fctyp.toupper(__ch); + return (__first <= __lower && __lower <= __last) + || (__first <= __upper && __upper <= __last); + } + + const _TraitsT& _M_traits; + }; + + template + class _RegexTranslator + : public _RegexTranslatorBase<_TraitsT, __icase, __collate> + { + public: + typedef _RegexTranslatorBase<_TraitsT, __icase, __collate> _Base; + using _Base::_Base; + }; + + template + class _RegexTranslator<_TraitsT, __icase, false> + : public _RegexTranslatorBase<_TraitsT, __icase, false> + { + public: + typedef _RegexTranslatorBase<_TraitsT, __icase, false> _Base; + typedef typename _Base::_CharT _CharT; + typedef _CharT _StrTransT; + + using _Base::_Base; + + _StrTransT + _M_transform(_CharT __ch) const + { return __ch; } + + bool + _M_match_range(_CharT __first, _CharT __last, _CharT __ch) const + { + if (!__icase) + return __first <= __ch && __ch <= __last; + return this->_M_in_range_icase(__first, __last, __ch); + } + }; + + template + class _RegexTranslator, true, true> + : public _RegexTranslatorBase, true, true> + { + public: + typedef _RegexTranslatorBase, true, true> + _Base; + typedef typename _Base::_CharT _CharT; + typedef typename _Base::_StrTransT _StrTransT; + + using _Base::_Base; + + bool + _M_match_range(const _StrTransT& __first, const _StrTransT& __last, + const _StrTransT& __str) const + { + __glibcxx_assert(__first.size() == 1); + __glibcxx_assert(__last.size() == 1); + __glibcxx_assert(__str.size() == 1); + return this->_M_in_range_icase(__first[0], __last[0], __str[0]); + } + }; + + template + class _RegexTranslator<_TraitsT, false, false> + { + public: + typedef typename _TraitsT::char_type _CharT; + typedef _CharT _StrTransT; + + explicit + _RegexTranslator(const _TraitsT&) + { } + + _CharT + _M_translate(_CharT __ch) const + { return __ch; } + + _StrTransT + _M_transform(_CharT __ch) const + { return __ch; } + + bool + _M_match_range(_CharT __first, _CharT __last, _CharT __ch) const + { return __first <= __ch && __ch <= __last; } + }; + + template + struct _AnyMatcher; + + template + struct _AnyMatcher<_TraitsT, false, __icase, __collate> + { + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + + explicit + _AnyMatcher(const _TraitsT& __traits) + : _M_translator(__traits) + { } + + bool + operator()(_CharT __ch) const + { + static auto __nul = _M_translator._M_translate('\0'); + return _M_translator._M_translate(__ch) != __nul; + } + + _TransT _M_translator; + }; + + template + struct _AnyMatcher<_TraitsT, true, __icase, __collate> + { + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + + explicit + _AnyMatcher(const _TraitsT& __traits) + : _M_translator(__traits) + { } + + bool + operator()(_CharT __ch) const + { return _M_apply(__ch, typename is_same<_CharT, char>::type()); } + + bool + _M_apply(_CharT __ch, true_type) const + { + auto __c = _M_translator._M_translate(__ch); + auto __n = _M_translator._M_translate('\n'); + auto __r = _M_translator._M_translate('\r'); + return __c != __n && __c != __r; + } + + bool + _M_apply(_CharT __ch, false_type) const + { + auto __c = _M_translator._M_translate(__ch); + auto __n = _M_translator._M_translate('\n'); + auto __r = _M_translator._M_translate('\r'); + auto __u2028 = _M_translator._M_translate(u'\u2028'); + auto __u2029 = _M_translator._M_translate(u'\u2029'); + return __c != __n && __c != __r && __c != __u2028 && __c != __u2029; + } + + _TransT _M_translator; + }; + + template + struct _CharMatcher + { + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + + _CharMatcher(_CharT __ch, const _TraitsT& __traits) + : _M_translator(__traits), _M_ch(_M_translator._M_translate(__ch)) + { } + + bool + operator()(_CharT __ch) const + { return _M_ch == _M_translator._M_translate(__ch); } + + _TransT _M_translator; + _CharT _M_ch; + }; + + /// Matches a character range (bracket expression) + template + struct _BracketMatcher + { + public: + typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT; + typedef typename _TransT::_CharT _CharT; + typedef typename _TransT::_StrTransT _StrTransT; + typedef typename _TraitsT::string_type _StringT; + typedef typename _TraitsT::char_class_type _CharClassT; + + public: + _BracketMatcher(bool __is_non_matching, + const _TraitsT& __traits) + : _M_class_set(0), _M_translator(__traits), _M_traits(__traits), + _M_is_non_matching(__is_non_matching) + { } + + bool + operator()(_CharT __ch) const + { + _GLIBCXX_DEBUG_ASSERT(_M_is_ready); + return _M_apply(__ch, _UseCache()); + } + + void + _M_add_char(_CharT __c) + { + _M_char_set.push_back(_M_translator._M_translate(__c)); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + _StringT + _M_add_collate_element(const _StringT& __s) + { + auto __st = _M_traits.lookup_collatename(__s.data(), + __s.data() + __s.size()); + if (__st.empty()) + __throw_regex_error(regex_constants::error_collate, + "Invalid collate element."); + _M_char_set.push_back(_M_translator._M_translate(__st[0])); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + return __st; + } + + void + _M_add_equivalence_class(const _StringT& __s) + { + auto __st = _M_traits.lookup_collatename(__s.data(), + __s.data() + __s.size()); + if (__st.empty()) + __throw_regex_error(regex_constants::error_collate, + "Invalid equivalence class."); + __st = _M_traits.transform_primary(__st.data(), + __st.data() + __st.size()); + _M_equiv_set.push_back(__st); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + // __neg should be true for \D, \S and \W only. + void + _M_add_character_class(const _StringT& __s, bool __neg) + { + auto __mask = _M_traits.lookup_classname(__s.data(), + __s.data() + __s.size(), + __icase); + if (__mask == 0) + __throw_regex_error(regex_constants::error_collate, + "Invalid character class."); + if (!__neg) + _M_class_set |= __mask; + else + _M_neg_class_set.push_back(__mask); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + void + _M_make_range(_CharT __l, _CharT __r) + { + if (__l > __r) + __throw_regex_error(regex_constants::error_range, + "Invalid range in bracket expression."); + _M_range_set.push_back(make_pair(_M_translator._M_transform(__l), + _M_translator._M_transform(__r))); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = false); + } + + void + _M_ready() + { + std::sort(_M_char_set.begin(), _M_char_set.end()); + auto __end = std::unique(_M_char_set.begin(), _M_char_set.end()); + _M_char_set.erase(__end, _M_char_set.end()); + _M_make_cache(_UseCache()); + _GLIBCXX_DEBUG_ONLY(_M_is_ready = true); + } + + private: + // Currently we only use the cache for char + typedef typename std::is_same<_CharT, char>::type _UseCache; + + static constexpr size_t + _S_cache_size = + 1ul << (sizeof(_CharT) * __CHAR_BIT__ * int(_UseCache::value)); + + struct _Dummy { }; + typedef typename std::conditional<_UseCache::value, + std::bitset<_S_cache_size>, + _Dummy>::type _CacheT; + typedef typename std::make_unsigned<_CharT>::type _UnsignedCharT; + + bool + _M_apply(_CharT __ch, false_type) const; + + bool + _M_apply(_CharT __ch, true_type) const + { return _M_cache[static_cast<_UnsignedCharT>(__ch)]; } + + void + _M_make_cache(true_type) + { + for (unsigned __i = 0; __i < _M_cache.size(); __i++) + _M_cache[__i] = _M_apply(static_cast<_CharT>(__i), false_type()); + } + + void + _M_make_cache(false_type) + { } + + private: + std::vector<_CharT> _M_char_set; + std::vector<_StringT> _M_equiv_set; + std::vector> _M_range_set; + std::vector<_CharClassT> _M_neg_class_set; + _CharClassT _M_class_set; + _TransT _M_translator; + const _TraitsT& _M_traits; + bool _M_is_non_matching; + _CacheT _M_cache; +#ifdef _GLIBCXX_DEBUG + bool _M_is_ready = false; +#endif + }; + + ///@} regex-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_compiler.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_compiler.tcc new file mode 100755 index 0000000..440669d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_compiler.tcc @@ -0,0 +1,641 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_compiler.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// FIXME make comments doxygen format. + +/* +// This compiler refers to "Regular Expression Matching Can Be Simple And Fast" +// (http://swtch.com/~rsc/regexp/regexp1.html), +// but doesn't strictly follow it. +// +// When compiling, states are *chained* instead of tree- or graph-constructed. +// It's more like structured programs: there's if statement and loop statement. +// +// For alternative structure (say "a|b"), aka "if statement", two branches +// should be constructed. However, these two shall merge to an "end_tag" at +// the end of this operator: +// +// branch1 +// / \ +// => begin_tag end_tag => +// \ / +// branch2 +// +// This is the difference between this implementation and that in Russ's +// article. +// +// That's why we introduced dummy node here ------ "end_tag" is a dummy node. +// All dummy nodes will be eliminated at the end of compilation. +*/ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + template + _Compiler<_TraitsT>:: + _Compiler(_IterT __b, _IterT __e, + const typename _TraitsT::locale_type& __loc, _FlagT __flags) + : _M_flags((__flags + & (regex_constants::ECMAScript + | regex_constants::basic + | regex_constants::extended + | regex_constants::grep + | regex_constants::egrep + | regex_constants::awk)) + ? __flags + : __flags | regex_constants::ECMAScript), + _M_scanner(__b, __e, _M_flags, __loc), + _M_nfa(make_shared<_RegexT>(__loc, _M_flags)), + _M_traits(_M_nfa->_M_traits), + _M_ctype(std::use_facet<_CtypeT>(__loc)) + { + _StateSeqT __r(*_M_nfa, _M_nfa->_M_start()); + __r._M_append(_M_nfa->_M_insert_subexpr_begin()); + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_eof)) + __throw_regex_error(regex_constants::error_paren); + __r._M_append(_M_pop()); + __glibcxx_assert(_M_stack.empty()); + __r._M_append(_M_nfa->_M_insert_subexpr_end()); + __r._M_append(_M_nfa->_M_insert_accept()); + _M_nfa->_M_eliminate_dummy(); + } + + template + void + _Compiler<_TraitsT>:: + _M_disjunction() + { + this->_M_alternative(); + while (_M_match_token(_ScannerT::_S_token_or)) + { + _StateSeqT __alt1 = _M_pop(); + this->_M_alternative(); + _StateSeqT __alt2 = _M_pop(); + auto __end = _M_nfa->_M_insert_dummy(); + __alt1._M_append(__end); + __alt2._M_append(__end); + // __alt2 is state._M_next, __alt1 is state._M_alt. The executor + // executes _M_alt before _M_next, as well as executing left + // alternative before right one. + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_alt( + __alt2._M_start, __alt1._M_start, false), + __end)); + } + } + + template + void + _Compiler<_TraitsT>:: + _M_alternative() + { + if (this->_M_term()) + { + _StateSeqT __re = _M_pop(); + this->_M_alternative(); + __re._M_append(_M_pop()); + _M_stack.push(__re); + } + else + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_dummy())); + } + + template + bool + _Compiler<_TraitsT>:: + _M_term() + { + if (this->_M_assertion()) + return true; + if (this->_M_atom()) + { + while (this->_M_quantifier()); + return true; + } + return false; + } + + template + bool + _Compiler<_TraitsT>:: + _M_assertion() + { + if (_M_match_token(_ScannerT::_S_token_line_begin)) + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_begin())); + else if (_M_match_token(_ScannerT::_S_token_line_end)) + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_end())); + else if (_M_match_token(_ScannerT::_S_token_word_bound)) + // _M_value[0] == 'n' means it's negative, say "not word boundary". + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa-> + _M_insert_word_bound(_M_value[0] == 'n'))); + else if (_M_match_token(_ScannerT::_S_token_subexpr_lookahead_begin)) + { + auto __neg = _M_value[0] == 'n'; + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) + __throw_regex_error(regex_constants::error_paren, + "Parenthesis is not closed."); + auto __tmp = _M_pop(); + __tmp._M_append(_M_nfa->_M_insert_accept()); + _M_stack.push( + _StateSeqT( + *_M_nfa, + _M_nfa->_M_insert_lookahead(__tmp._M_start, __neg))); + } + else + return false; + return true; + } + + template + bool + _Compiler<_TraitsT>:: + _M_quantifier() + { + bool __neg = (_M_flags & regex_constants::ECMAScript); + auto __init = [this, &__neg]() + { + if (_M_stack.empty()) + __throw_regex_error(regex_constants::error_badrepeat, + "Nothing to repeat before a quantifier."); + __neg = __neg && _M_match_token(_ScannerT::_S_token_opt); + }; + if (_M_match_token(_ScannerT::_S_token_closure0)) + { + __init(); + auto __e = _M_pop(); + _StateSeqT __r(*_M_nfa, + _M_nfa->_M_insert_repeat(_S_invalid_state_id, + __e._M_start, __neg)); + __e._M_append(__r); + _M_stack.push(__r); + } + else if (_M_match_token(_ScannerT::_S_token_closure1)) + { + __init(); + auto __e = _M_pop(); + __e._M_append(_M_nfa->_M_insert_repeat(_S_invalid_state_id, + __e._M_start, __neg)); + _M_stack.push(__e); + } + else if (_M_match_token(_ScannerT::_S_token_opt)) + { + __init(); + auto __e = _M_pop(); + auto __end = _M_nfa->_M_insert_dummy(); + _StateSeqT __r(*_M_nfa, + _M_nfa->_M_insert_repeat(_S_invalid_state_id, + __e._M_start, __neg)); + __e._M_append(__end); + __r._M_append(__end); + _M_stack.push(__r); + } + else if (_M_match_token(_ScannerT::_S_token_interval_begin)) + { + if (_M_stack.empty()) + __throw_regex_error(regex_constants::error_badrepeat, + "Nothing to repeat before a quantifier."); + if (!_M_match_token(_ScannerT::_S_token_dup_count)) + __throw_regex_error(regex_constants::error_badbrace, + "Unexpected token in brace expression."); + _StateSeqT __r(_M_pop()); + _StateSeqT __e(*_M_nfa, _M_nfa->_M_insert_dummy()); + long __min_rep = _M_cur_int_value(10); + bool __infi = false; + long __n = 0; + + // {3 + if (_M_match_token(_ScannerT::_S_token_comma)) + { + if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7} + __n = _M_cur_int_value(10) - __min_rep; + else + __infi = true; + } + if (!_M_match_token(_ScannerT::_S_token_interval_end)) + __throw_regex_error(regex_constants::error_brace, + "Unexpected end of brace expression."); + + __neg = __neg && _M_match_token(_ScannerT::_S_token_opt); + + for (long __i = 0; __i < __min_rep; ++__i) + __e._M_append(__r._M_clone()); + + if (__infi) + { + auto __tmp = __r._M_clone(); + _StateSeqT __s(*_M_nfa, + _M_nfa->_M_insert_repeat(_S_invalid_state_id, + __tmp._M_start, __neg)); + __tmp._M_append(__s); + __e._M_append(__s); + } + else + { + if (__n < 0) + __throw_regex_error(regex_constants::error_badbrace, + "Invalid range in brace expression."); + auto __end = _M_nfa->_M_insert_dummy(); + // _M_alt is the "match more" branch, and _M_next is the + // "match less" one. Switch _M_alt and _M_next of all created + // nodes. This is a hack but IMO works well. + std::stack<_StateIdT> __stack; + for (long __i = 0; __i < __n; ++__i) + { + auto __tmp = __r._M_clone(); + auto __alt = _M_nfa->_M_insert_repeat(__tmp._M_start, + __end, __neg); + __stack.push(__alt); + __e._M_append(_StateSeqT(*_M_nfa, __alt, __tmp._M_end)); + } + __e._M_append(__end); + while (!__stack.empty()) + { + auto& __tmp = (*_M_nfa)[__stack.top()]; + __stack.pop(); + std::swap(__tmp._M_next, __tmp._M_alt); + } + } + _M_stack.push(__e); + } + else + return false; + return true; + } + +#define __INSERT_REGEX_MATCHER(__func, ...)\ + do {\ + if (!(_M_flags & regex_constants::icase))\ + if (!(_M_flags & regex_constants::collate))\ + __func(__VA_ARGS__);\ + else\ + __func(__VA_ARGS__);\ + else\ + if (!(_M_flags & regex_constants::collate))\ + __func(__VA_ARGS__);\ + else\ + __func(__VA_ARGS__);\ + } while (false) + + template + bool + _Compiler<_TraitsT>:: + _M_atom() + { + if (_M_match_token(_ScannerT::_S_token_anychar)) + { + if (!(_M_flags & regex_constants::ECMAScript)) + __INSERT_REGEX_MATCHER(_M_insert_any_matcher_posix); + else + __INSERT_REGEX_MATCHER(_M_insert_any_matcher_ecma); + } + else if (_M_try_char()) + __INSERT_REGEX_MATCHER(_M_insert_char_matcher); + else if (_M_match_token(_ScannerT::_S_token_backref)) + _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa-> + _M_insert_backref(_M_cur_int_value(10)))); + else if (_M_match_token(_ScannerT::_S_token_quoted_class)) + __INSERT_REGEX_MATCHER(_M_insert_character_class_matcher); + else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin)) + { + _StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_dummy()); + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) + __throw_regex_error(regex_constants::error_paren, + "Parenthesis is not closed."); + __r._M_append(_M_pop()); + _M_stack.push(__r); + } + else if (_M_match_token(_ScannerT::_S_token_subexpr_begin)) + { + _StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_subexpr_begin()); + this->_M_disjunction(); + if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) + __throw_regex_error(regex_constants::error_paren, + "Parenthesis is not closed."); + __r._M_append(_M_pop()); + __r._M_append(_M_nfa->_M_insert_subexpr_end()); + _M_stack.push(__r); + } + else if (!_M_bracket_expression()) + return false; + return true; + } + + template + bool + _Compiler<_TraitsT>:: + _M_bracket_expression() + { + bool __neg = + _M_match_token(_ScannerT::_S_token_bracket_neg_begin); + if (!(__neg || _M_match_token(_ScannerT::_S_token_bracket_begin))) + return false; + __INSERT_REGEX_MATCHER(_M_insert_bracket_matcher, __neg); + return true; + } +#undef __INSERT_REGEX_MATCHER + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_any_matcher_ecma() + { + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher + (_AnyMatcher<_TraitsT, true, __icase, __collate> + (_M_traits)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_any_matcher_posix() + { + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher + (_AnyMatcher<_TraitsT, false, __icase, __collate> + (_M_traits)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_char_matcher() + { + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher + (_CharMatcher<_TraitsT, __icase, __collate> + (_M_value[0], _M_traits)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_character_class_matcher() + { + __glibcxx_assert(_M_value.size() == 1); + _BracketMatcher<_TraitsT, __icase, __collate> __matcher + (_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits); + __matcher._M_add_character_class(_M_value, false); + __matcher._M_ready(); + _M_stack.push(_StateSeqT(*_M_nfa, + _M_nfa->_M_insert_matcher(std::move(__matcher)))); + } + + template + template + void + _Compiler<_TraitsT>:: + _M_insert_bracket_matcher(bool __neg) + { + _BracketMatcher<_TraitsT, __icase, __collate> __matcher(__neg, _M_traits); + pair __last_char; // Optional<_CharT> + __last_char.first = false; + if (!(_M_flags & regex_constants::ECMAScript)) + { + if (_M_try_char()) + { + __last_char.first = true; + __last_char.second = _M_value[0]; + } + else if (_M_match_token(_ScannerT::_S_token_bracket_dash)) + { + __last_char.first = true; + __last_char.second = '-'; + } + } + while (_M_expression_term(__last_char, __matcher)); + if (__last_char.first) + __matcher._M_add_char(__last_char.second); + __matcher._M_ready(); + _M_stack.push(_StateSeqT( + *_M_nfa, + _M_nfa->_M_insert_matcher(std::move(__matcher)))); + } + + template + template + bool + _Compiler<_TraitsT>:: + _M_expression_term(pair& __last_char, + _BracketMatcher<_TraitsT, __icase, __collate>& __matcher) + { + if (_M_match_token(_ScannerT::_S_token_bracket_end)) + return false; + + const auto __push_char = [&](_CharT __ch) + { + if (__last_char.first) + __matcher._M_add_char(__last_char.second); + else + __last_char.first = true; + __last_char.second = __ch; + }; + const auto __flush = [&] + { + if (__last_char.first) + { + __matcher._M_add_char(__last_char.second); + __last_char.first = false; + } + }; + + if (_M_match_token(_ScannerT::_S_token_collsymbol)) + { + auto __symbol = __matcher._M_add_collate_element(_M_value); + if (__symbol.size() == 1) + __push_char(__symbol[0]); + else + __flush(); + } + else if (_M_match_token(_ScannerT::_S_token_equiv_class_name)) + { + __flush(); + __matcher._M_add_equivalence_class(_M_value); + } + else if (_M_match_token(_ScannerT::_S_token_char_class_name)) + { + __flush(); + __matcher._M_add_character_class(_M_value, false); + } + else if (_M_try_char()) + __push_char(_M_value[0]); + // POSIX doesn't allow '-' as a start-range char (say [a-z--0]), + // except when the '-' is the first or last character in the bracket + // expression ([--0]). ECMAScript treats all '-' after a range as a + // normal character. Also see above, where _M_expression_term gets called. + // + // As a result, POSIX rejects [-----], but ECMAScript doesn't. + // Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax. + // Clang (3.5) always uses ECMAScript style even in its POSIX syntax. + // + // It turns out that no one reads BNFs ;) + else if (_M_match_token(_ScannerT::_S_token_bracket_dash)) + { + if (!__last_char.first) + { + if (!(_M_flags & regex_constants::ECMAScript)) + { + if (_M_match_token(_ScannerT::_S_token_bracket_end)) + { + __push_char('-'); + return false; + } + __throw_regex_error( + regex_constants::error_range, + "Unexpected dash in bracket expression. For POSIX syntax, " + "a dash is not treated literally only when it is at " + "beginning or end."); + } + __push_char('-'); + } + else + { + if (_M_try_char()) + { + __matcher._M_make_range(__last_char.second, _M_value[0]); + __last_char.first = false; + } + else if (_M_match_token(_ScannerT::_S_token_bracket_dash)) + { + __matcher._M_make_range(__last_char.second, '-'); + __last_char.first = false; + } + else + { + if (_M_scanner._M_get_token() + != _ScannerT::_S_token_bracket_end) + __throw_regex_error( + regex_constants::error_range, + "Character is expected after a dash."); + __push_char('-'); + } + } + } + else if (_M_match_token(_ScannerT::_S_token_quoted_class)) + { + __flush(); + __matcher._M_add_character_class(_M_value, + _M_ctype.is(_CtypeT::upper, + _M_value[0])); + } + else + __throw_regex_error(regex_constants::error_brack, + "Unexpected character in bracket expression."); + + return true; + } + + template + bool + _Compiler<_TraitsT>:: + _M_try_char() + { + bool __is_char = false; + if (_M_match_token(_ScannerT::_S_token_oct_num)) + { + __is_char = true; + _M_value.assign(1, _M_cur_int_value(8)); + } + else if (_M_match_token(_ScannerT::_S_token_hex_num)) + { + __is_char = true; + _M_value.assign(1, _M_cur_int_value(16)); + } + else if (_M_match_token(_ScannerT::_S_token_ord_char)) + __is_char = true; + return __is_char; + } + + template + bool + _Compiler<_TraitsT>:: + _M_match_token(_TokenT token) + { + if (token == _M_scanner._M_get_token()) + { + _M_value = _M_scanner._M_get_value(); + _M_scanner._M_advance(); + return true; + } + return false; + } + + template + int + _Compiler<_TraitsT>:: + _M_cur_int_value(int __radix) + { + long __v = 0; + for (typename _StringT::size_type __i = 0; + __i < _M_value.length(); ++__i) + __v =__v * __radix + _M_traits.value(_M_value[__i], __radix); + return __v; + } + + template + bool + _BracketMatcher<_TraitsT, __icase, __collate>:: + _M_apply(_CharT __ch, false_type) const + { + return [this, __ch] + { + if (std::binary_search(_M_char_set.begin(), _M_char_set.end(), + _M_translator._M_translate(__ch))) + return true; + auto __s = _M_translator._M_transform(__ch); + for (auto& __it : _M_range_set) + if (_M_translator._M_match_range(__it.first, __it.second, __s)) + return true; + if (_M_traits.isctype(__ch, _M_class_set)) + return true; + if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(), + _M_traits.transform_primary(&__ch, &__ch+1)) + != _M_equiv_set.end()) + return true; + for (auto& __it : _M_neg_class_set) + if (!_M_traits.isctype(__ch, __it)) + return true; + return false; + }() ^ _M_is_non_matching; + } +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_constants.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_constants.h new file mode 100755 index 0000000..1c3dd36 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_constants.h @@ -0,0 +1,416 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_constants.h + * @brief Constant definitions for the std regex library. + * + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @defgroup regex Regular Expressions + * + * A facility for performing regular expression pattern matching. + * @{ + */ + +/** + * @namespace std::regex_constants + * @brief ISO C++ 2011 namespace for options and flags used with std::regex + */ +namespace regex_constants +{ + /** + * @name 5.1 Regular Expression Syntax Options + */ + ///@{ + enum __syntax_option + { + _S_icase, + _S_nosubs, + _S_optimize, + _S_collate, + _S_ECMAScript, + _S_basic, + _S_extended, + _S_awk, + _S_grep, + _S_egrep, + _S_polynomial, + _S_syntax_last + }; + + /** + * @brief This is a bitmask type indicating how to interpret the regex. + * + * The @c syntax_option_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + * + * A valid value of type syntax_option_type shall have exactly one of the + * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep + * %set. + */ + enum syntax_option_type : unsigned int { }; + + /** + * Specifies that the matching of regular expressions against a character + * sequence shall be performed without regard to case. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type icase = + static_cast(1 << _S_icase); + + /** + * Specifies that when a regular expression is matched against a character + * container sequence, no sub-expression matches are to be stored in the + * supplied match_results structure. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type nosubs = + static_cast(1 << _S_nosubs); + + /** + * Specifies that the regular expression engine should pay more attention to + * the speed with which regular expressions are matched, and less to the + * speed with which regular expression objects are constructed. Otherwise + * it has no detectable effect on the program output. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type optimize = + static_cast(1 << _S_optimize); + + /** + * Specifies that character ranges of the form [a-b] should be locale + * sensitive. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type collate = + static_cast(1 << _S_collate); + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript + * Language Specification, Standard Ecma-262, third edition, 1999], as + * modified in section [28.13]. This grammar is similar to that defined + * in the PERL scripting language but extended with elements found in the + * POSIX regular expression grammar. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type ECMAScript = + static_cast(1 << _S_ECMAScript); + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- + * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type basic = + static_cast(1 << _S_basic); + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type extended = + static_cast(1 << _S_extended); + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type extended, except that C-style escape + * sequences are supported. These sequences are: + * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,, + * and \\ddd (where ddd is one, two, or three octal digits). + */ + _GLIBCXX17_INLINE constexpr syntax_option_type awk = + static_cast(1 << _S_awk); + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type basic, except that newlines are treated + * as whitespace. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type grep = + static_cast(1 << _S_grep); + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep when given the -E option in + * IEEE Std 1003.1-2001. This option is identical to syntax_option_type + * extended, except that newlines are treated as whitespace. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type egrep = + static_cast(1 << _S_egrep); + + /** + * Extension: Ensure both space complexity of compiled regex and + * time complexity execution are not exponential. + * If specified in a regex with back-references, the exception + * regex_constants::error_complexity will be thrown. + */ + _GLIBCXX17_INLINE constexpr syntax_option_type __polynomial = + static_cast(1 << _S_polynomial); + + constexpr inline syntax_option_type + operator&(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + & static_cast(__b)); + } + + constexpr inline syntax_option_type + operator|(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + | static_cast(__b)); + } + + constexpr inline syntax_option_type + operator^(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + ^ static_cast(__b)); + } + + constexpr inline syntax_option_type + operator~(syntax_option_type __a) + { return (syntax_option_type)(~static_cast(__a)); } + + inline syntax_option_type& + operator&=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a & __b; } + + inline syntax_option_type& + operator|=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a | __b; } + + inline syntax_option_type& + operator^=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a ^ __b; } + + ///@} + + /** + * @name 5.2 Matching Rules + * + * Matching a regular expression against a sequence of characters [first, + * last) proceeds according to the rules of the grammar specified for the + * regular expression object, modified according to the effects listed + * below for any bitmask elements set. + * + */ + ///@{ + + enum __match_flag + { + _S_not_bol, + _S_not_eol, + _S_not_bow, + _S_not_eow, + _S_any, + _S_not_null, + _S_continuous, + _S_prev_avail, + _S_sed, + _S_no_copy, + _S_first_only, + _S_match_flag_last + }; + + /** + * @brief This is a bitmask type indicating regex matching rules. + * + * The @c match_flag_type is implementation defined but it is valid to + * perform bitwise operations on these values and expect the right thing to + * happen. + */ + enum match_flag_type : unsigned int { }; + + /** + * The default matching rules. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_default = + static_cast(0); + + /** + * The first character in the sequence [first, last) is treated as though it + * is not at the beginning of a line, so the character (^) in the regular + * expression shall not match [first, first). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_bol = + static_cast(1 << _S_not_bol); + + /** + * The last character in the sequence [first, last) is treated as though it + * is not at the end of a line, so the character ($) in the regular + * expression shall not match [last, last). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_eol = + static_cast(1 << _S_not_eol); + + /** + * The expression \\b is not matched against the sub-sequence + * [first,first). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_bow = + static_cast(1 << _S_not_bow); + + /** + * The expression \\b should not be matched against the sub-sequence + * [last,last). + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_eow = + static_cast(1 << _S_not_eow); + + /** + * If more than one match is possible then any match is an acceptable + * result. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_any = + static_cast(1 << _S_any); + + /** + * The expression does not match an empty sequence. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_not_null = + static_cast(1 << _S_not_null); + + /** + * The expression only matches a sub-sequence that begins at first . + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_continuous = + static_cast(1 << _S_continuous); + + /** + * --first is a valid iterator position. When this flag is set then the + * flags match_not_bol and match_not_bow are ignored by the regular + * expression algorithms 28.11 and iterators 28.12. + */ + _GLIBCXX17_INLINE constexpr match_flag_type match_prev_avail = + static_cast(1 << _S_prev_avail); + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the ECMAScript replace + * function in ECMA- 262 [Ecma International, ECMAScript Language + * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11 + * String.prototype.replace. In addition, during search and replace + * operations all non-overlapping occurrences of the regular expression + * are located and replaced, and sections of the input that did not match + * the expression are copied unchanged to the output string. + * + * Format strings (from ECMA-262 [15.5.4.11]): + * @li $$ The dollar-sign itself ($) + * @li $& The matched substring. + * @li $` The portion of @a string that precedes the matched substring. + * This would be match_results::prefix(). + * @li $' The portion of @a string that follows the matched substring. + * This would be match_results::suffix(). + * @li $n The nth capture, where n is in [1,9] and $n is not followed by a + * decimal digit. If n <= match_results::size() and the nth capture + * is undefined, use the empty string instead. If n > + * match_results::size(), the result is implementation-defined. + * @li $nn The nnth capture, where nn is a two-digit decimal number on + * [01, 99]. If nn <= match_results::size() and the nth capture is + * undefined, use the empty string instead. If + * nn > match_results::size(), the result is implementation-defined. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_default = + static_cast(0); + + /** + * When a regular expression match is to be replaced by a new string, the + * new string is constructed using the rules used by the POSIX sed utility + * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable + * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_sed = + static_cast(1 << _S_sed); + + /** + * During a search and replace operation, sections of the character + * container sequence being searched that do not match the regular + * expression shall not be copied to the output string. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_no_copy = + static_cast(1 << _S_no_copy); + + /** + * When specified during a search and replace operation, only the first + * occurrence of the regular expression shall be replaced. + */ + _GLIBCXX17_INLINE constexpr match_flag_type format_first_only = + static_cast(1 << _S_first_only); + + constexpr inline match_flag_type + operator&(match_flag_type __a, match_flag_type __b) + { + return (match_flag_type)(static_cast(__a) + & static_cast(__b)); + } + + constexpr inline match_flag_type + operator|(match_flag_type __a, match_flag_type __b) + { + return (match_flag_type)(static_cast(__a) + | static_cast(__b)); + } + + constexpr inline match_flag_type + operator^(match_flag_type __a, match_flag_type __b) + { + return (match_flag_type)(static_cast(__a) + ^ static_cast(__b)); + } + + constexpr inline match_flag_type + operator~(match_flag_type __a) + { return (match_flag_type)(~static_cast(__a)); } + + inline match_flag_type& + operator&=(match_flag_type& __a, match_flag_type __b) + { return __a = __a & __b; } + + inline match_flag_type& + operator|=(match_flag_type& __a, match_flag_type __b) + { return __a = __a | __b; } + + inline match_flag_type& + operator^=(match_flag_type& __a, match_flag_type __b) + { return __a = __a ^ __b; } + + ///@} +} // namespace regex_constants +/// @} group regex + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_error.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_error.h new file mode 100755 index 0000000..2759383 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_error.h @@ -0,0 +1,176 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_error.h + * @brief Error and exception objects for the std regex library. + * + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +/** + * @addtogroup regex + * @{ + */ + +namespace regex_constants +{ + /** + * @name 5.3 Error Types + */ + ///@{ + + enum error_type + { + _S_error_collate, + _S_error_ctype, + _S_error_escape, + _S_error_backref, + _S_error_brack, + _S_error_paren, + _S_error_brace, + _S_error_badbrace, + _S_error_range, + _S_error_space, + _S_error_badrepeat, + _S_error_complexity, + _S_error_stack, + }; + + /** The expression contained an invalid collating element name. */ + constexpr error_type error_collate(_S_error_collate); + + /** The expression contained an invalid character class name. */ + constexpr error_type error_ctype(_S_error_ctype); + + /** + * The expression contained an invalid escaped character, or a trailing + * escape. + */ + constexpr error_type error_escape(_S_error_escape); + + /** The expression contained an invalid back reference. */ + constexpr error_type error_backref(_S_error_backref); + + /** The expression contained mismatched [ and ]. */ + constexpr error_type error_brack(_S_error_brack); + + /** The expression contained mismatched ( and ). */ + constexpr error_type error_paren(_S_error_paren); + + /** The expression contained mismatched { and } */ + constexpr error_type error_brace(_S_error_brace); + + /** The expression contained an invalid range in a {} expression. */ + constexpr error_type error_badbrace(_S_error_badbrace); + + /** + * The expression contained an invalid character range, + * such as [b-a] in most encodings. + */ + constexpr error_type error_range(_S_error_range); + + /** + * There was insufficient memory to convert the expression into a + * finite state machine. + */ + constexpr error_type error_space(_S_error_space); + + /** + * One of *?+{ was not preceded by a valid regular expression. + */ + constexpr error_type error_badrepeat(_S_error_badrepeat); + + /** + * The complexity of an attempted match against a regular expression + * exceeded a pre-set level. + */ + constexpr error_type error_complexity(_S_error_complexity); + + /** + * There was insufficient memory to determine whether the + * regular expression could match the specified character sequence. + */ + constexpr error_type error_stack(_S_error_stack); + + ///@} +} // namespace regex_constants + + // [7.8] Class regex_error + /** + * @brief A regular expression exception class. + * @ingroup exceptions + * + * The regular expression library throws objects of this class on error. + */ + class regex_error : public std::runtime_error + { + regex_constants::error_type _M_code; + + public: + /** + * @brief Constructs a regex_error object. + * + * @param __ecode the regex error code. + */ + explicit + regex_error(regex_constants::error_type __ecode); + + virtual ~regex_error() throw(); + + /** + * @brief Gets the regex error code. + * + * @returns the regex error code. + */ + regex_constants::error_type + code() const + { return _M_code; } + + private: + regex_error(regex_constants::error_type __ecode, const char* __what) + : std::runtime_error(__what), _M_code(__ecode) + { } + + friend void __throw_regex_error(regex_constants::error_type, const char*); + }; + + ///@} // group regex + + void + __throw_regex_error(regex_constants::error_type __ecode); + + inline void + __throw_regex_error(regex_constants::error_type __ecode + __attribute__((__unused__)), + const char* __what __attribute__((__unused__))) + { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what)); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_executor.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_executor.h new file mode 100755 index 0000000..4a641ee --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_executor.h @@ -0,0 +1,258 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_executor.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// FIXME convert comments to doxygen format. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * @addtogroup regex-detail + * @{ + */ + + /** + * @brief Takes a regex and an input string and does the matching. + * + * The %_Executor class has two modes: DFS mode and BFS mode, controlled + * by the template parameter %__dfs_mode. + */ + template + class _Executor + { + using __search_mode = integral_constant; + using __dfs = true_type; + using __bfs = false_type; + + enum class _Match_mode : unsigned char { _Exact, _Prefix }; + + public: + typedef typename iterator_traits<_BiIter>::value_type _CharT; + typedef basic_regex<_CharT, _TraitsT> _RegexT; + typedef std::vector, _Alloc> _ResultsVec; + typedef regex_constants::match_flag_type _FlagT; + typedef typename _TraitsT::char_class_type _ClassT; + typedef _NFA<_TraitsT> _NFAT; + + public: + _Executor(_BiIter __begin, + _BiIter __end, + _ResultsVec& __results, + const _RegexT& __re, + _FlagT __flags) + : _M_begin(__begin), + _M_end(__end), + _M_re(__re), + _M_nfa(*__re._M_automaton), + _M_results(__results), + _M_rep_count(_M_nfa.size()), + _M_states(_M_nfa._M_start(), _M_nfa.size()), + _M_flags((__flags & regex_constants::match_prev_avail) + ? (__flags + & ~regex_constants::match_not_bol + & ~regex_constants::match_not_bow) + : __flags) + { } + + // Set matched when string exactly matches the pattern. + bool + _M_match() + { + _M_current = _M_begin; + return _M_main(_Match_mode::_Exact); + } + + // Set matched when some prefix of the string matches the pattern. + bool + _M_search_from_first() + { + _M_current = _M_begin; + return _M_main(_Match_mode::_Prefix); + } + + bool + _M_search(); + + private: + void + _M_rep_once_more(_Match_mode __match_mode, _StateIdT); + + void + _M_handle_repeat(_Match_mode, _StateIdT); + + void + _M_handle_subexpr_begin(_Match_mode, _StateIdT); + + void + _M_handle_subexpr_end(_Match_mode, _StateIdT); + + void + _M_handle_line_begin_assertion(_Match_mode, _StateIdT); + + void + _M_handle_line_end_assertion(_Match_mode, _StateIdT); + + void + _M_handle_word_boundary(_Match_mode, _StateIdT); + + void + _M_handle_subexpr_lookahead(_Match_mode, _StateIdT); + + void + _M_handle_match(_Match_mode, _StateIdT); + + void + _M_handle_backref(_Match_mode, _StateIdT); + + void + _M_handle_accept(_Match_mode, _StateIdT); + + void + _M_handle_alternative(_Match_mode, _StateIdT); + + void + _M_dfs(_Match_mode __match_mode, _StateIdT __start); + + bool + _M_main(_Match_mode __match_mode) + { return _M_main_dispatch(__match_mode, __search_mode{}); } + + bool + _M_main_dispatch(_Match_mode __match_mode, __dfs); + + bool + _M_main_dispatch(_Match_mode __match_mode, __bfs); + + bool + _M_is_word(_CharT __ch) const + { + static const _CharT __s[2] = { 'w' }; + return _M_re._M_automaton->_M_traits.isctype + (__ch, _M_re._M_automaton->_M_traits.lookup_classname(__s, __s+1)); + } + + bool + _M_at_begin() const + { + return _M_current == _M_begin + && !(_M_flags & (regex_constants::match_not_bol + | regex_constants::match_prev_avail)); + } + + bool + _M_at_end() const + { + return _M_current == _M_end + && !(_M_flags & regex_constants::match_not_eol); + } + + bool + _M_word_boundary() const; + + bool + _M_lookahead(_StateIdT __next); + + // Holds additional information used in BFS-mode. + template + struct _State_info; + + template + struct _State_info<__bfs, _ResultsVec> + { + explicit + _State_info(_StateIdT __start, size_t __n) + : _M_visited_states(new bool[__n]()), _M_start(__start) + { } + + bool _M_visited(_StateIdT __i) + { + if (_M_visited_states[__i]) + return true; + _M_visited_states[__i] = true; + return false; + } + + void _M_queue(_StateIdT __i, const _ResultsVec& __res) + { _M_match_queue.emplace_back(__i, __res); } + + // Dummy implementations for BFS mode. + _BiIter* _M_get_sol_pos() { return nullptr; } + + // Saves states that need to be considered for the next character. + vector> _M_match_queue; + // Indicates which states are already visited. + unique_ptr _M_visited_states; + // To record current solution. + _StateIdT _M_start; + }; + + template + struct _State_info<__dfs, _ResultsVec> + { + explicit + _State_info(_StateIdT __start, size_t) : _M_start(__start) + { } + + // Dummy implementations for DFS mode. + bool _M_visited(_StateIdT) const { return false; } + void _M_queue(_StateIdT, const _ResultsVec&) { } + + _BiIter* _M_get_sol_pos() { return &_M_sol_pos; } + + // To record current solution. + _StateIdT _M_start; + _BiIter _M_sol_pos; + }; + + public: + _ResultsVec _M_cur_results; + _BiIter _M_current; + _BiIter _M_begin; + const _BiIter _M_end; + const _RegexT& _M_re; + const _NFAT& _M_nfa; + _ResultsVec& _M_results; + vector> _M_rep_count; + _State_info<__search_mode, _ResultsVec> _M_states; + _FlagT _M_flags; + // Do we have a solution so far? + bool _M_has_sol; + }; + + ///@} regex-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_executor.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_executor.tcc new file mode 100755 index 0000000..405d1c4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_executor.tcc @@ -0,0 +1,568 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_executor.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_search() + { + if (_M_search_from_first()) + return true; + if (_M_flags & regex_constants::match_continuous) + return false; + _M_flags |= regex_constants::match_prev_avail; + while (_M_begin != _M_end) + { + ++_M_begin; + if (_M_search_from_first()) + return true; + } + return false; + } + + // The _M_main function operates in different modes, DFS mode or BFS mode, + // indicated by template parameter __dfs_mode, and dispatches to one of the + // _M_main_dispatch overloads. + // + // ------------------------------------------------------------ + // + // DFS mode: + // + // It applies a Depth-First-Search (aka backtracking) on given NFA and input + // string. + // At the very beginning the executor stands in the start state, then it + // tries every possible state transition in current state recursively. Some + // state transitions consume input string, say, a single-char-matcher or a + // back-reference matcher; some don't, like assertion or other anchor nodes. + // When the input is exhausted and/or the current state is an accepting + // state, the whole executor returns true. + // + // TODO: This approach is exponentially slow for certain input. + // Try to compile the NFA to a DFA. + // + // Time complexity: \Omega(match_length), O(2^(_M_nfa.size())) + // Space complexity: \theta(match_results.size() + match_length) + // + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_main_dispatch(_Match_mode __match_mode, __dfs) + { + _M_has_sol = false; + *_M_states._M_get_sol_pos() = _BiIter(); + _M_cur_results = _M_results; + _M_dfs(__match_mode, _M_states._M_start); + return _M_has_sol; + } + + // ------------------------------------------------------------ + // + // BFS mode: + // + // Russ Cox's article (http://swtch.com/~rsc/regexp/regexp1.html) + // explained this algorithm clearly. + // + // It first computes epsilon closure (states that can be achieved without + // consuming characters) for every state that's still matching, + // using the same DFS algorithm, but doesn't re-enter states (using + // _M_states._M_visited to check), nor follow _S_opcode_match. + // + // Then apply DFS using every _S_opcode_match (in _M_states._M_match_queue) + // as the start state. + // + // It significantly reduces potential duplicate states, so has a better + // upper bound; but it requires more overhead. + // + // Time complexity: \Omega(match_length * match_results.size()) + // O(match_length * _M_nfa.size() * match_results.size()) + // Space complexity: \Omega(_M_nfa.size() + match_results.size()) + // O(_M_nfa.size() * match_results.size()) + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_main_dispatch(_Match_mode __match_mode, __bfs) + { + _M_states._M_queue(_M_states._M_start, _M_results); + bool __ret = false; + while (1) + { + _M_has_sol = false; + if (_M_states._M_match_queue.empty()) + break; + std::fill_n(_M_states._M_visited_states.get(), _M_nfa.size(), false); + auto __old_queue = std::move(_M_states._M_match_queue); + for (auto& __task : __old_queue) + { + _M_cur_results = std::move(__task.second); + _M_dfs(__match_mode, __task.first); + } + if (__match_mode == _Match_mode::_Prefix) + __ret |= _M_has_sol; + if (_M_current == _M_end) + break; + ++_M_current; + } + if (__match_mode == _Match_mode::_Exact) + __ret = _M_has_sol; + _M_states._M_match_queue.clear(); + return __ret; + } + + // Return whether now match the given sub-NFA. + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_lookahead(_StateIdT __next) + { + // Backreferences may refer to captured content. + // We may want to make this faster by not copying, + // but let's not be clever prematurely. + _ResultsVec __what(_M_cur_results); + _Executor __sub(_M_current, _M_end, __what, _M_re, _M_flags); + __sub._M_states._M_start = __next; + if (__sub._M_search_from_first()) + { + for (size_t __i = 0; __i < __what.size(); __i++) + if (__what[__i].matched) + _M_cur_results[__i] = __what[__i]; + return true; + } + return false; + } + + // __rep_count records how many times (__rep_count.second) + // this node is visited under certain input iterator + // (__rep_count.first). This prevent the executor from entering + // infinite loop by refusing to continue when it's already been + // visited more than twice. It's `twice` instead of `once` because + // we need to spare one more time for potential group capture. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_rep_once_more(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + auto& __rep_count = _M_rep_count[__i]; + if (__rep_count.second == 0 || __rep_count.first != _M_current) + { + auto __back = __rep_count; + __rep_count.first = _M_current; + __rep_count.second = 1; + _M_dfs(__match_mode, __state._M_alt); + __rep_count = __back; + } + else + { + if (__rep_count.second < 2) + { + __rep_count.second++; + _M_dfs(__match_mode, __state._M_alt); + __rep_count.second--; + } + } + } + + // _M_alt branch is "match once more", while _M_next is "get me out + // of this quantifier". Executing _M_next first or _M_alt first don't + // mean the same thing, and we need to choose the correct order under + // given greedy mode. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_repeat(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + // Greedy. + if (!__state._M_neg) + { + _M_rep_once_more(__match_mode, __i); + // If it's DFS executor and already accepted, we're done. + if (!__dfs_mode || !_M_has_sol) + _M_dfs(__match_mode, __state._M_next); + } + else // Non-greedy mode + { + if (__dfs_mode) + { + // vice-versa. + _M_dfs(__match_mode, __state._M_next); + if (!_M_has_sol) + _M_rep_once_more(__match_mode, __i); + } + else + { + // DON'T attempt anything, because there's already another + // state with higher priority accepted. This state cannot + // be better by attempting its next node. + if (!_M_has_sol) + { + _M_dfs(__match_mode, __state._M_next); + // DON'T attempt anything if it's already accepted. An + // accepted state *must* be better than a solution that + // matches a non-greedy quantifier one more time. + if (!_M_has_sol) + _M_rep_once_more(__match_mode, __i); + } + } + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_subexpr_begin(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + auto& __res = _M_cur_results[__state._M_subexpr]; + auto __back = __res.first; + __res.first = _M_current; + _M_dfs(__match_mode, __state._M_next); + __res.first = __back; + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_subexpr_end(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + auto& __res = _M_cur_results[__state._M_subexpr]; + auto __back = __res; + __res.second = _M_current; + __res.matched = true; + _M_dfs(__match_mode, __state._M_next); + __res = __back; + } + + template + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_line_begin_assertion(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_at_begin()) + _M_dfs(__match_mode, __state._M_next); + } + + template + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_line_end_assertion(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_at_end()) + _M_dfs(__match_mode, __state._M_next); + } + + template + inline void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_word_boundary(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_word_boundary() == !__state._M_neg) + _M_dfs(__match_mode, __state._M_next); + } + + // Here __state._M_alt offers a single start node for a sub-NFA. + // We recursively invoke our algorithm to match the sub-NFA. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_subexpr_lookahead(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + if (_M_lookahead(__state._M_alt) == !__state._M_neg) + _M_dfs(__match_mode, __state._M_next); + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_match(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + if (_M_current == _M_end) + return; + if (__dfs_mode) + { + if (__state._M_matches(*_M_current)) + { + ++_M_current; + _M_dfs(__match_mode, __state._M_next); + --_M_current; + } + } + else + if (__state._M_matches(*_M_current)) + _M_states._M_queue(__state._M_next, _M_cur_results); + } + + template + struct _Backref_matcher + { + _Backref_matcher(bool __icase, const _TraitsT& __traits) + : _M_traits(__traits) { } + + bool + _M_apply(_BiIter __expected_begin, + _BiIter __expected_end, _BiIter __actual_begin, + _BiIter __actual_end) + { + return _M_traits.transform(__expected_begin, __expected_end) + == _M_traits.transform(__actual_begin, __actual_end); + } + + const _TraitsT& _M_traits; + }; + + template + struct _Backref_matcher<_BiIter, std::regex_traits<_CharT>> + { + using _TraitsT = std::regex_traits<_CharT>; + _Backref_matcher(bool __icase, const _TraitsT& __traits) + : _M_icase(__icase), _M_traits(__traits) { } + + bool + _M_apply(_BiIter __expected_begin, + _BiIter __expected_end, _BiIter __actual_begin, + _BiIter __actual_end) + { + if (!_M_icase) + return _GLIBCXX_STD_A::__equal4(__expected_begin, __expected_end, + __actual_begin, __actual_end); + typedef std::ctype<_CharT> __ctype_type; + const auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc()); + return _GLIBCXX_STD_A::__equal4(__expected_begin, __expected_end, + __actual_begin, __actual_end, + [this, &__fctyp](_CharT __lhs, _CharT __rhs) + { + return __fctyp.tolower(__lhs) + == __fctyp.tolower(__rhs); + }); + } + + bool _M_icase; + const _TraitsT& _M_traits; + }; + + // First fetch the matched result from _M_cur_results as __submatch; + // then compare it with + // (_M_current, _M_current + (__submatch.second - __submatch.first)). + // If matched, keep going; else just return and try another state. + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_backref(_Match_mode __match_mode, _StateIdT __i) + { + __glibcxx_assert(__dfs_mode); + + const auto& __state = _M_nfa[__i]; + auto& __submatch = _M_cur_results[__state._M_backref_index]; + if (!__submatch.matched) + return; + auto __last = _M_current; + for (auto __tmp = __submatch.first; + __last != _M_end && __tmp != __submatch.second; + ++__tmp) + ++__last; + if (_Backref_matcher<_BiIter, _TraitsT>( + _M_re.flags() & regex_constants::icase, + _M_re._M_automaton->_M_traits)._M_apply( + __submatch.first, __submatch.second, _M_current, __last)) + { + if (__last != _M_current) + { + auto __backup = _M_current; + _M_current = __last; + _M_dfs(__match_mode, __state._M_next); + _M_current = __backup; + } + else + _M_dfs(__match_mode, __state._M_next); + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_accept(_Match_mode __match_mode, _StateIdT __i) + { + if (__dfs_mode) + { + __glibcxx_assert(!_M_has_sol); + if (__match_mode == _Match_mode::_Exact) + _M_has_sol = _M_current == _M_end; + else + _M_has_sol = true; + if (_M_current == _M_begin + && (_M_flags & regex_constants::match_not_null)) + _M_has_sol = false; + if (_M_has_sol) + { + if (_M_nfa._M_flags & regex_constants::ECMAScript) + _M_results = _M_cur_results; + else // POSIX + { + __glibcxx_assert(_M_states._M_get_sol_pos()); + // Here's POSIX's logic: match the longest one. However + // we never know which one (lhs or rhs of "|") is longer + // unless we try both of them and compare the results. + // The member variable _M_sol_pos records the end + // position of the last successful match. It's better + // to be larger, because POSIX regex is always greedy. + // TODO: This could be slow. + if (*_M_states._M_get_sol_pos() == _BiIter() + || std::distance(_M_begin, + *_M_states._M_get_sol_pos()) + < std::distance(_M_begin, _M_current)) + { + *_M_states._M_get_sol_pos() = _M_current; + _M_results = _M_cur_results; + } + } + } + } + else + { + if (_M_current == _M_begin + && (_M_flags & regex_constants::match_not_null)) + return; + if (__match_mode == _Match_mode::_Prefix || _M_current == _M_end) + if (!_M_has_sol) + { + _M_has_sol = true; + _M_results = _M_cur_results; + } + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_handle_alternative(_Match_mode __match_mode, _StateIdT __i) + { + const auto& __state = _M_nfa[__i]; + + if (_M_nfa._M_flags & regex_constants::ECMAScript) + { + // TODO: Fix BFS support. It is wrong. + _M_dfs(__match_mode, __state._M_alt); + // Pick lhs if it matches. Only try rhs if it doesn't. + if (!_M_has_sol) + _M_dfs(__match_mode, __state._M_next); + } + else + { + // Try both and compare the result. + // See "case _S_opcode_accept:" handling above. + _M_dfs(__match_mode, __state._M_alt); + auto __has_sol = _M_has_sol; + _M_has_sol = false; + _M_dfs(__match_mode, __state._M_next); + _M_has_sol |= __has_sol; + } + } + + template + void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_dfs(_Match_mode __match_mode, _StateIdT __i) + { + if (_M_states._M_visited(__i)) + return; + + switch (_M_nfa[__i]._M_opcode()) + { + case _S_opcode_repeat: + _M_handle_repeat(__match_mode, __i); break; + case _S_opcode_subexpr_begin: + _M_handle_subexpr_begin(__match_mode, __i); break; + case _S_opcode_subexpr_end: + _M_handle_subexpr_end(__match_mode, __i); break; + case _S_opcode_line_begin_assertion: + _M_handle_line_begin_assertion(__match_mode, __i); break; + case _S_opcode_line_end_assertion: + _M_handle_line_end_assertion(__match_mode, __i); break; + case _S_opcode_word_boundary: + _M_handle_word_boundary(__match_mode, __i); break; + case _S_opcode_subexpr_lookahead: + _M_handle_subexpr_lookahead(__match_mode, __i); break; + case _S_opcode_match: + _M_handle_match(__match_mode, __i); break; + case _S_opcode_backref: + _M_handle_backref(__match_mode, __i); break; + case _S_opcode_accept: + _M_handle_accept(__match_mode, __i); break; + case _S_opcode_alternative: + _M_handle_alternative(__match_mode, __i); break; + default: + __glibcxx_assert(false); + } + } + + // Return whether now is at some word boundary. + template + bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>:: + _M_word_boundary() const + { + if (_M_current == _M_begin && (_M_flags & regex_constants::match_not_bow)) + return false; + if (_M_current == _M_end && (_M_flags & regex_constants::match_not_eow)) + return false; + + bool __left_is_word = false; + if (_M_current != _M_begin + || (_M_flags & regex_constants::match_prev_avail)) + { + auto __prev = _M_current; + if (_M_is_word(*std::prev(__prev))) + __left_is_word = true; + } + bool __right_is_word = + _M_current != _M_end && _M_is_word(*_M_current); + + return __left_is_word != __right_is_word; + } +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_scanner.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_scanner.h new file mode 100755 index 0000000..e810fa7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_scanner.h @@ -0,0 +1,272 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_scanner.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + /** + * @addtogroup regex-detail + * @{ + */ + + struct _ScannerBase + { + public: + /// Token types returned from the scanner. + enum _TokenT : unsigned + { + _S_token_anychar, + _S_token_ord_char, + _S_token_oct_num, + _S_token_hex_num, + _S_token_backref, + _S_token_subexpr_begin, + _S_token_subexpr_no_group_begin, + _S_token_subexpr_lookahead_begin, // neg if _M_value[0] == 'n' + _S_token_subexpr_end, + _S_token_bracket_begin, + _S_token_bracket_neg_begin, + _S_token_bracket_end, + _S_token_interval_begin, + _S_token_interval_end, + _S_token_quoted_class, + _S_token_char_class_name, + _S_token_collsymbol, + _S_token_equiv_class_name, + _S_token_opt, + _S_token_or, + _S_token_closure0, + _S_token_closure1, + _S_token_line_begin, + _S_token_line_end, + _S_token_word_bound, // neg if _M_value[0] == 'n' + _S_token_comma, + _S_token_dup_count, + _S_token_eof, + _S_token_bracket_dash, + _S_token_unknown = -1u + }; + + protected: + typedef regex_constants::syntax_option_type _FlagT; + + enum _StateT + { + _S_state_normal, + _S_state_in_brace, + _S_state_in_bracket, + }; + + protected: + _ScannerBase(_FlagT __flags) + : _M_state(_S_state_normal), + _M_flags(__flags), + _M_escape_tbl(_M_is_ecma() + ? _M_ecma_escape_tbl + : _M_awk_escape_tbl), + _M_spec_char(_M_is_ecma() + ? _M_ecma_spec_char + : _M_flags & regex_constants::basic + ? _M_basic_spec_char + : _M_flags & regex_constants::extended + ? _M_extended_spec_char + : _M_flags & regex_constants::grep + ? ".[\\*^$\n" + : _M_flags & regex_constants::egrep + ? ".[\\()*+?{|^$\n" + : _M_flags & regex_constants::awk + ? _M_extended_spec_char + : nullptr), + _M_at_bracket_start(false) + { __glibcxx_assert(_M_spec_char); } + + protected: + const char* + _M_find_escape(char __c) + { + auto __it = _M_escape_tbl; + for (; __it->first != '\0'; ++__it) + if (__it->first == __c) + return &__it->second; + return nullptr; + } + + bool + _M_is_ecma() const + { return _M_flags & regex_constants::ECMAScript; } + + bool + _M_is_basic() const + { return _M_flags & (regex_constants::basic | regex_constants::grep); } + + bool + _M_is_extended() const + { + return _M_flags & (regex_constants::extended + | regex_constants::egrep + | regex_constants::awk); + } + + bool + _M_is_grep() const + { return _M_flags & (regex_constants::grep | regex_constants::egrep); } + + bool + _M_is_awk() const + { return _M_flags & regex_constants::awk; } + + protected: + // TODO: Make them static in the next abi change. + const std::pair _M_token_tbl[9] = + { + {'^', _S_token_line_begin}, + {'$', _S_token_line_end}, + {'.', _S_token_anychar}, + {'*', _S_token_closure0}, + {'+', _S_token_closure1}, + {'?', _S_token_opt}, + {'|', _S_token_or}, + {'\n', _S_token_or}, // grep and egrep + {'\0', _S_token_or}, + }; + const std::pair _M_ecma_escape_tbl[8] = + { + {'0', '\0'}, + {'b', '\b'}, + {'f', '\f'}, + {'n', '\n'}, + {'r', '\r'}, + {'t', '\t'}, + {'v', '\v'}, + {'\0', '\0'}, + }; + const std::pair _M_awk_escape_tbl[11] = + { + {'"', '"'}, + {'/', '/'}, + {'\\', '\\'}, + {'a', '\a'}, + {'b', '\b'}, + {'f', '\f'}, + {'n', '\n'}, + {'r', '\r'}, + {'t', '\t'}, + {'v', '\v'}, + {'\0', '\0'}, + }; + const char* _M_ecma_spec_char = "^$\\.*+?()[]{}|"; + const char* _M_basic_spec_char = ".[\\*^$"; + const char* _M_extended_spec_char = ".[\\()*+?{|^$"; + + _StateT _M_state; + _FlagT _M_flags; + _TokenT _M_token; + const std::pair* _M_escape_tbl; + const char* _M_spec_char; + bool _M_at_bracket_start; + }; + + /** + * @brief Scans an input range for regex tokens. + * + * The %_Scanner class interprets the regular expression pattern in + * the input range passed to its constructor as a sequence of parse + * tokens passed to the regular expression compiler. The sequence + * of tokens provided depends on the flag settings passed to the + * constructor: different regular expression grammars will interpret + * the same input pattern in syntactically different ways. + */ + template + class _Scanner + : public _ScannerBase + { + public: + typedef const _CharT* _IterT; + typedef std::basic_string<_CharT> _StringT; + typedef regex_constants::syntax_option_type _FlagT; + typedef const std::ctype<_CharT> _CtypeT; + + _Scanner(_IterT __begin, _IterT __end, + _FlagT __flags, std::locale __loc); + + void + _M_advance(); + + _TokenT + _M_get_token() const + { return _M_token; } + + const _StringT& + _M_get_value() const + { return _M_value; } + +#ifdef _GLIBCXX_DEBUG + std::ostream& + _M_print(std::ostream&); +#endif + + private: + void + _M_scan_normal(); + + void + _M_scan_in_bracket(); + + void + _M_scan_in_brace(); + + void + _M_eat_escape_ecma(); + + void + _M_eat_escape_posix(); + + void + _M_eat_escape_awk(); + + void + _M_eat_class(char); + + _IterT _M_current; + _IterT _M_end; + _CtypeT& _M_ctype; + _StringT _M_value; + void (_Scanner::* _M_eat_escape)(); + }; + + ///@} regex-detail +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_scanner.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_scanner.tcc new file mode 100755 index 0000000..a351208 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/regex_scanner.tcc @@ -0,0 +1,589 @@ +// class template regex -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/regex_scanner.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{regex} + */ + +// FIXME make comments doxygen format. + +// N3376 specified 6 regex styles: ECMAScript, basic, extended, grep, egrep +// and awk +// 1) grep is basic except '\n' is treated as '|' +// 2) egrep is extended except '\n' is treated as '|' +// 3) awk is extended except special escaping rules, and there's no +// back-reference. +// +// References: +// +// ECMAScript: ECMA-262 15.10 +// +// basic, extended: +// http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html +// +// awk: http://pubs.opengroup.org/onlinepubs/000095399/utilities/awk.html + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + template + _Scanner<_CharT>:: + _Scanner(typename _Scanner::_IterT __begin, + typename _Scanner::_IterT __end, + _FlagT __flags, std::locale __loc) + : _ScannerBase(__flags), + _M_current(__begin), _M_end(__end), + _M_ctype(std::use_facet<_CtypeT>(__loc)), + _M_eat_escape(_M_is_ecma() + ? &_Scanner::_M_eat_escape_ecma + : &_Scanner::_M_eat_escape_posix) + { _M_advance(); } + + template + void + _Scanner<_CharT>:: + _M_advance() + { + if (_M_current == _M_end) + { + _M_token = _S_token_eof; + return; + } + + if (_M_state == _S_state_normal) + _M_scan_normal(); + else if (_M_state == _S_state_in_bracket) + _M_scan_in_bracket(); + else if (_M_state == _S_state_in_brace) + _M_scan_in_brace(); + else + { + __glibcxx_assert(false); + } + } + + // Differences between styles: + // 1) "\(", "\)", "\{" in basic. It's not escaping. + // 2) "(?:", "(?=", "(?!" in ECMAScript. + template + void + _Scanner<_CharT>:: + _M_scan_normal() + { + auto __c = *_M_current++; + + if (std::strchr(_M_spec_char, _M_ctype.narrow(__c, ' ')) == nullptr) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + return; + } + if (__c == '\\') + { + if (_M_current == _M_end) + __throw_regex_error( + regex_constants::error_escape, + "Unexpected end of regex when escaping."); + + if (!_M_is_basic() + || (*_M_current != '(' + && *_M_current != ')' + && *_M_current != '{')) + { + (this->*_M_eat_escape)(); + return; + } + __c = *_M_current++; + } + if (__c == '(') + { + if (_M_is_ecma() && *_M_current == '?') + { + if (++_M_current == _M_end) + __throw_regex_error( + regex_constants::error_paren, + "Unexpected end of regex when in an open parenthesis."); + + if (*_M_current == ':') + { + ++_M_current; + _M_token = _S_token_subexpr_no_group_begin; + } + else if (*_M_current == '=') + { + ++_M_current; + _M_token = _S_token_subexpr_lookahead_begin; + _M_value.assign(1, 'p'); + } + else if (*_M_current == '!') + { + ++_M_current; + _M_token = _S_token_subexpr_lookahead_begin; + _M_value.assign(1, 'n'); + } + else + __throw_regex_error( + regex_constants::error_paren, + "Invalid special open parenthesis."); + } + else if (_M_flags & regex_constants::nosubs) + _M_token = _S_token_subexpr_no_group_begin; + else + _M_token = _S_token_subexpr_begin; + } + else if (__c == ')') + _M_token = _S_token_subexpr_end; + else if (__c == '[') + { + _M_state = _S_state_in_bracket; + _M_at_bracket_start = true; + if (_M_current != _M_end && *_M_current == '^') + { + _M_token = _S_token_bracket_neg_begin; + ++_M_current; + } + else + _M_token = _S_token_bracket_begin; + } + else if (__c == '{') + { + _M_state = _S_state_in_brace; + _M_token = _S_token_interval_begin; + } + else if (__c != ']' && __c != '}') + { + auto __it = _M_token_tbl; + auto __narrowc = _M_ctype.narrow(__c, '\0'); + for (; __it->first != '\0'; ++__it) + if (__it->first == __narrowc) + { + _M_token = __it->second; + return; + } + __glibcxx_assert(false); + } + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + } + + // Differences between styles: + // 1) different semantics of "[]" and "[^]". + // 2) Escaping in bracket expr. + template + void + _Scanner<_CharT>:: + _M_scan_in_bracket() + { + if (_M_current == _M_end) + __throw_regex_error( + regex_constants::error_brack, + "Unexpected end of regex when in bracket expression."); + + auto __c = *_M_current++; + + if (__c == '-') + _M_token = _S_token_bracket_dash; + else if (__c == '[') + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_brack, + "Unexpected character class open bracket."); + + if (*_M_current == '.') + { + _M_token = _S_token_collsymbol; + _M_eat_class(*_M_current++); + } + else if (*_M_current == ':') + { + _M_token = _S_token_char_class_name; + _M_eat_class(*_M_current++); + } + else if (*_M_current == '=') + { + _M_token = _S_token_equiv_class_name; + _M_eat_class(*_M_current++); + } + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + } + // In POSIX, when encountering "[]" or "[^]", the ']' is interpreted + // literally. So "[]]" and "[^]]" are valid regexes. See the testcases + // `*/empty_range.cc`. + else if (__c == ']' && (_M_is_ecma() || !_M_at_bracket_start)) + { + _M_token = _S_token_bracket_end; + _M_state = _S_state_normal; + } + // ECMAScript and awk permits escaping in bracket. + else if (__c == '\\' && (_M_is_ecma() || _M_is_awk())) + (this->*_M_eat_escape)(); + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + _M_at_bracket_start = false; + } + + // Differences between styles: + // 1) "\}" in basic style. + template + void + _Scanner<_CharT>:: + _M_scan_in_brace() + { + if (_M_current == _M_end) + __throw_regex_error( + regex_constants::error_brace, + "Unexpected end of regex when in brace expression."); + + auto __c = *_M_current++; + + if (_M_ctype.is(_CtypeT::digit, __c)) + { + _M_token = _S_token_dup_count; + _M_value.assign(1, __c); + while (_M_current != _M_end + && _M_ctype.is(_CtypeT::digit, *_M_current)) + _M_value += *_M_current++; + } + else if (__c == ',') + _M_token = _S_token_comma; + // basic use \}. + else if (_M_is_basic()) + { + if (__c == '\\' && _M_current != _M_end && *_M_current == '}') + { + _M_state = _S_state_normal; + _M_token = _S_token_interval_end; + ++_M_current; + } + else + __throw_regex_error(regex_constants::error_badbrace, + "Unexpected character in brace expression."); + } + else if (__c == '}') + { + _M_state = _S_state_normal; + _M_token = _S_token_interval_end; + } + else + __throw_regex_error(regex_constants::error_badbrace, + "Unexpected character in brace expression."); + } + + template + void + _Scanner<_CharT>:: + _M_eat_escape_ecma() + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_escape, + "Unexpected end of regex when escaping."); + + auto __c = *_M_current++; + auto __pos = _M_find_escape(_M_ctype.narrow(__c, '\0')); + + if (__pos != nullptr && (__c != 'b' || _M_state == _S_state_in_bracket)) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, *__pos); + } + else if (__c == 'b') + { + _M_token = _S_token_word_bound; + _M_value.assign(1, 'p'); + } + else if (__c == 'B') + { + _M_token = _S_token_word_bound; + _M_value.assign(1, 'n'); + } + // N3376 28.13 + else if (__c == 'd' + || __c == 'D' + || __c == 's' + || __c == 'S' + || __c == 'w' + || __c == 'W') + { + _M_token = _S_token_quoted_class; + _M_value.assign(1, __c); + } + else if (__c == 'c') + { + if (_M_current == _M_end) + __throw_regex_error( + regex_constants::error_escape, + "Unexpected end of regex when reading control code."); + _M_token = _S_token_ord_char; + _M_value.assign(1, *_M_current++); + } + else if (__c == 'x' || __c == 'u') + { + _M_value.erase(); + for (int __i = 0; __i < (__c == 'x' ? 2 : 4); __i++) + { + if (_M_current == _M_end + || !_M_ctype.is(_CtypeT::xdigit, *_M_current)) + __throw_regex_error( + regex_constants::error_escape, + "Unexpected end of regex when ascii character."); + _M_value += *_M_current++; + } + _M_token = _S_token_hex_num; + } + // ECMAScript recognizes multi-digit back-references. + else if (_M_ctype.is(_CtypeT::digit, __c)) + { + _M_value.assign(1, __c); + while (_M_current != _M_end + && _M_ctype.is(_CtypeT::digit, *_M_current)) + _M_value += *_M_current++; + _M_token = _S_token_backref; + } + else + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + } + + // Differences between styles: + // 1) Extended doesn't support backref, but basic does. + template + void + _Scanner<_CharT>:: + _M_eat_escape_posix() + { + if (_M_current == _M_end) + __throw_regex_error(regex_constants::error_escape, + "Unexpected end of regex when escaping."); + + auto __c = *_M_current; + auto __pos = std::strchr(_M_spec_char, _M_ctype.narrow(__c, '\0')); + + if (__pos != nullptr && *__pos != '\0') + { + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); + } + // We MUST judge awk before handling backrefs. There's no backref in awk. + else if (_M_is_awk()) + { + _M_eat_escape_awk(); + return; + } + else if (_M_is_basic() && _M_ctype.is(_CtypeT::digit, __c) && __c != '0') + { + _M_token = _S_token_backref; + _M_value.assign(1, __c); + } + else + { +#ifdef __STRICT_ANSI__ + // POSIX says it is undefined to escape ordinary characters + __throw_regex_error(regex_constants::error_escape, + "Unexpected escape character."); +#else + _M_token = _S_token_ord_char; + _M_value.assign(1, __c); +#endif + } + ++_M_current; + } + + template + void + _Scanner<_CharT>:: + _M_eat_escape_awk() + { + auto __c = *_M_current++; + auto __pos = _M_find_escape(_M_ctype.narrow(__c, '\0')); + + if (__pos != nullptr) + { + _M_token = _S_token_ord_char; + _M_value.assign(1, *__pos); + } + // \ddd for oct representation + else if (_M_ctype.is(_CtypeT::digit, __c) + && __c != '8' + && __c != '9') + { + _M_value.assign(1, __c); + for (int __i = 0; + __i < 2 + && _M_current != _M_end + && _M_ctype.is(_CtypeT::digit, *_M_current) + && *_M_current != '8' + && *_M_current != '9'; + __i++) + _M_value += *_M_current++; + _M_token = _S_token_oct_num; + return; + } + else + __throw_regex_error(regex_constants::error_escape, + "Unexpected escape character."); + } + + // Eats a character class or throws an exception. + // __ch could be ':', '.' or '=', _M_current is the char after ']' when + // returning. + template + void + _Scanner<_CharT>:: + _M_eat_class(char __ch) + { + for (_M_value.clear(); _M_current != _M_end && *_M_current != __ch;) + _M_value += *_M_current++; + if (_M_current == _M_end + || *_M_current++ != __ch + || _M_current == _M_end // skip __ch + || *_M_current++ != ']') // skip ']' + { + if (__ch == ':') + __throw_regex_error(regex_constants::error_ctype, + "Unexpected end of character class."); + else + __throw_regex_error(regex_constants::error_collate, + "Unexpected end of character class."); + } + } + +#ifdef _GLIBCXX_DEBUG + template + std::ostream& + _Scanner<_CharT>:: + _M_print(std::ostream& ostr) + { + switch (_M_token) + { + case _S_token_anychar: + ostr << "any-character\n"; + break; + case _S_token_backref: + ostr << "backref\n"; + break; + case _S_token_bracket_begin: + ostr << "bracket-begin\n"; + break; + case _S_token_bracket_neg_begin: + ostr << "bracket-neg-begin\n"; + break; + case _S_token_bracket_end: + ostr << "bracket-end\n"; + break; + case _S_token_char_class_name: + ostr << "char-class-name \"" << _M_value << "\"\n"; + break; + case _S_token_closure0: + ostr << "closure0\n"; + break; + case _S_token_closure1: + ostr << "closure1\n"; + break; + case _S_token_collsymbol: + ostr << "collsymbol \"" << _M_value << "\"\n"; + break; + case _S_token_comma: + ostr << "comma\n"; + break; + case _S_token_dup_count: + ostr << "dup count: " << _M_value << "\n"; + break; + case _S_token_eof: + ostr << "EOF\n"; + break; + case _S_token_equiv_class_name: + ostr << "equiv-class-name \"" << _M_value << "\"\n"; + break; + case _S_token_interval_begin: + ostr << "interval begin\n"; + break; + case _S_token_interval_end: + ostr << "interval end\n"; + break; + case _S_token_line_begin: + ostr << "line begin\n"; + break; + case _S_token_line_end: + ostr << "line end\n"; + break; + case _S_token_opt: + ostr << "opt\n"; + break; + case _S_token_or: + ostr << "or\n"; + break; + case _S_token_ord_char: + ostr << "ordinary character: \"" << _M_value << "\"\n"; + break; + case _S_token_subexpr_begin: + ostr << "subexpr begin\n"; + break; + case _S_token_subexpr_no_group_begin: + ostr << "no grouping subexpr begin\n"; + break; + case _S_token_subexpr_lookahead_begin: + ostr << "lookahead subexpr begin\n"; + break; + case _S_token_subexpr_end: + ostr << "subexpr end\n"; + break; + case _S_token_unknown: + ostr << "-- unknown token --\n"; + break; + case _S_token_oct_num: + ostr << "oct number " << _M_value << "\n"; + break; + case _S_token_hex_num: + ostr << "hex number " << _M_value << "\n"; + break; + case _S_token_quoted_class: + ostr << "quoted class " << "\\" << _M_value << "\n"; + break; + default: + _GLIBCXX_DEBUG_ASSERT(false); + } + return ostr; + } +#endif + +} // namespace __detail +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/semaphore_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/semaphore_base.h new file mode 100755 index 0000000..c4565d7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/semaphore_base.h @@ -0,0 +1,280 @@ +// -*- C++ -*- header. + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/semaphore_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{semaphore} + */ + +#ifndef _GLIBCXX_SEMAPHORE_BASE_H +#define _GLIBCXX_SEMAPHORE_BASE_H 1 + +#pragma GCC system_header + +#include +#if __cpp_lib_atomic_wait +#include +#include +#endif // __cpp_lib_atomic_wait + +#ifdef _GLIBCXX_HAVE_POSIX_SEMAPHORE +# include // std::terminate +# include // errno, EINTR, EAGAIN etc. +# include // SEM_VALUE_MAX +# include // sem_t, sem_init, sem_wait, sem_post etc. +#endif + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef _GLIBCXX_HAVE_POSIX_SEMAPHORE + struct __platform_semaphore + { + using __clock_t = chrono::system_clock; +#ifdef SEM_VALUE_MAX + static constexpr ptrdiff_t _S_max = SEM_VALUE_MAX; +#else + static constexpr ptrdiff_t _S_max = _POSIX_SEM_VALUE_MAX; +#endif + + explicit __platform_semaphore(ptrdiff_t __count) noexcept + { + sem_init(&_M_semaphore, 0, __count); + } + + __platform_semaphore(const __platform_semaphore&) = delete; + __platform_semaphore& operator=(const __platform_semaphore&) = delete; + + ~__platform_semaphore() + { sem_destroy(&_M_semaphore); } + + _GLIBCXX_ALWAYS_INLINE void + _M_acquire() noexcept + { + for (;;) + { + auto __err = sem_wait(&_M_semaphore); + if (__err && (errno == EINTR)) + continue; + else if (__err) + std::terminate(); + else + break; + } + } + + _GLIBCXX_ALWAYS_INLINE bool + _M_try_acquire() noexcept + { + for (;;) + { + auto __err = sem_trywait(&_M_semaphore); + if (__err && (errno == EINTR)) + continue; + else if (__err && (errno == EAGAIN)) + return false; + else if (__err) + std::terminate(); + else + break; + } + return true; + } + + _GLIBCXX_ALWAYS_INLINE void + _M_release(std::ptrdiff_t __update) noexcept + { + for(; __update != 0; --__update) + { + auto __err = sem_post(&_M_semaphore); + if (__err) + std::terminate(); + } + } + + bool + _M_try_acquire_until_impl(const chrono::time_point<__clock_t>& __atime) + noexcept + { + + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + struct timespec __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + for (;;) + { + if (auto __err = sem_timedwait(&_M_semaphore, &__ts)) + { + if (errno == EINTR) + continue; + else if (errno == ETIMEDOUT || errno == EINVAL) + return false; + else + std::terminate(); + } + else + break; + } + return true; + } + + template + bool + _M_try_acquire_until(const chrono::time_point<_Clock, + _Duration>& __atime) noexcept + { + if constexpr (std::is_same_v<__clock_t, _Clock>) + { + return _M_try_acquire_until_impl(__atime); + } + else + { + const typename _Clock::time_point __c_entry = _Clock::now(); + const auto __s_entry = __clock_t::now(); + const auto __delta = __atime - __c_entry; + const auto __s_atime = __s_entry + __delta; + if (_M_try_acquire_until_impl(__s_atime)) + return true; + + // We got a timeout when measured against __clock_t but + // we need to check against the caller-supplied clock + // to tell whether we should return a timeout. + return (_Clock::now() < __atime); + } + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_try_acquire_for(const chrono::duration<_Rep, _Period>& __rtime) + noexcept + { return _M_try_acquire_until(__clock_t::now() + __rtime); } + + private: + sem_t _M_semaphore; + }; +#endif // _GLIBCXX_HAVE_POSIX_SEMAPHORE + +#if __cpp_lib_atomic_wait + struct __atomic_semaphore + { + static constexpr ptrdiff_t _S_max = __gnu_cxx::__int_traits::__max; + explicit __atomic_semaphore(__detail::__platform_wait_t __count) noexcept + : _M_counter(__count) + { + __glibcxx_assert(__count >= 0 && __count <= _S_max); + } + + __atomic_semaphore(const __atomic_semaphore&) = delete; + __atomic_semaphore& operator=(const __atomic_semaphore&) = delete; + + static _GLIBCXX_ALWAYS_INLINE bool + _S_do_try_acquire(__detail::__platform_wait_t* __counter) noexcept + { + auto __old = __atomic_impl::load(__counter, memory_order::acquire); + if (__old == 0) + return false; + + return __atomic_impl::compare_exchange_strong(__counter, + __old, __old - 1, + memory_order::acquire, + memory_order::relaxed); + } + + _GLIBCXX_ALWAYS_INLINE void + _M_acquire() noexcept + { + auto const __pred = + [this] { return _S_do_try_acquire(&this->_M_counter); }; + std::__atomic_wait_address_bare(&_M_counter, __pred); + } + + bool + _M_try_acquire() noexcept + { + auto const __pred = + [this] { return _S_do_try_acquire(&this->_M_counter); }; + return std::__detail::__atomic_spin(__pred); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_try_acquire_until(const chrono::time_point<_Clock, + _Duration>& __atime) noexcept + { + auto const __pred = + [this] { return _S_do_try_acquire(&this->_M_counter); }; + + return __atomic_wait_address_until_bare(&_M_counter, __pred, __atime); + } + + template + _GLIBCXX_ALWAYS_INLINE bool + _M_try_acquire_for(const chrono::duration<_Rep, _Period>& __rtime) + noexcept + { + auto const __pred = + [this] { return _S_do_try_acquire(&this->_M_counter); }; + + return __atomic_wait_address_for_bare(&_M_counter, __pred, __rtime); + } + + _GLIBCXX_ALWAYS_INLINE void + _M_release(ptrdiff_t __update) noexcept + { + if (0 < __atomic_impl::fetch_add(&_M_counter, __update, memory_order_release)) + return; + if (__update > 1) + __atomic_notify_address_bare(&_M_counter, true); + else + __atomic_notify_address_bare(&_M_counter, true); +// FIXME - Figure out why this does not wake a waiting thread +// __atomic_notify_address_bare(&_M_counter, false); + } + + private: + alignas(__detail::__platform_wait_alignment) + __detail::__platform_wait_t _M_counter; + }; +#endif // __cpp_lib_atomic_wait + +// Note: the _GLIBCXX_USE_POSIX_SEMAPHORE macro can be used to force the +// use of Posix semaphores (sem_t). Doing so however, alters the ABI. +#if defined __cpp_lib_atomic_wait && !_GLIBCXX_USE_POSIX_SEMAPHORE + using __semaphore_impl = __atomic_semaphore; +#elif _GLIBCXX_HAVE_POSIX_SEMAPHORE + using __semaphore_impl = __platform_semaphore; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // _GLIBCXX_SEMAPHORE_BASE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr.h new file mode 100755 index 0000000..d5386ad --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr.h @@ -0,0 +1,921 @@ +// shared_ptr and weak_ptr implementation -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// GCC Note: Based on files from version 1.32.0 of the Boost library. + +// shared_count.hpp +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. + +// shared_ptr.hpp +// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes. +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// weak_ptr.hpp +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// enable_shared_from_this.hpp +// Copyright (C) 2002 Peter Dimov + +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** @file + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _SHARED_PTR_H +#define _SHARED_PTR_H 1 + +#include // std::basic_ostream +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup pointer_abstractions + * @{ + */ + + // 20.7.2.2.11 shared_ptr I/O + + /// Write the stored pointer to an ostream. + /// @relates shared_ptr + template + inline std::basic_ostream<_Ch, _Tr>& + operator<<(std::basic_ostream<_Ch, _Tr>& __os, + const __shared_ptr<_Tp, _Lp>& __p) + { + __os << __p.get(); + return __os; + } + + template + inline _Del* + get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept + { +#if __cpp_rtti + return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); +#else + return 0; +#endif + } + + /// 20.7.2.2.10 shared_ptr get_deleter + + /// If `__p` has a deleter of type `_Del`, return a pointer to it. + /// @relates shared_ptr + template + inline _Del* + get_deleter(const shared_ptr<_Tp>& __p) noexcept + { +#if __cpp_rtti + return static_cast<_Del*>(__p._M_get_deleter(typeid(_Del))); +#else + return 0; +#endif + } + + /** + * @brief A smart pointer with reference-counted copy semantics. + * + * A `shared_ptr` object is either empty or _owns_ a pointer passed + * to the constructor. Copies of a `shared_ptr` share ownership of + * the same pointer. When the last `shared_ptr` that owns the pointer + * is destroyed or reset, the owned pointer is freed (either by `delete` + * or by invoking a custom deleter that was passed to the constructor). + * + * A `shared_ptr` also stores another pointer, which is usually + * (but not always) the same pointer as it owns. The stored pointer + * can be retrieved by calling the `get()` member function. + * + * The equality and relational operators for `shared_ptr` only compare + * the stored pointer returned by `get()`, not the owned pointer. + * To test whether two `shared_ptr` objects share ownership of the same + * pointer see `std::shared_ptr::owner_before` and `std::owner_less`. + */ + template + class shared_ptr : public __shared_ptr<_Tp> + { + template + using _Constructible = typename enable_if< + is_constructible<__shared_ptr<_Tp>, _Args...>::value + >::type; + + template + using _Assignable = typename enable_if< + is_assignable<__shared_ptr<_Tp>&, _Arg>::value, shared_ptr& + >::type; + + public: + + /// The type pointed to by the stored pointer, remove_extent_t<_Tp> + using element_type = typename __shared_ptr<_Tp>::element_type; + +#if __cplusplus >= 201703L +# define __cpp_lib_shared_ptr_weak_type 201606 + /// The corresponding weak_ptr type for this shared_ptr + using weak_type = weak_ptr<_Tp>; +#endif + /** + * @brief Construct an empty %shared_ptr. + * @post use_count()==0 && get()==0 + */ + constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { } + + shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor + + /** + * @brief Construct a %shared_ptr that owns the pointer @a __p. + * @param __p A pointer that is convertible to element_type*. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @c delete @a __p is called. + */ + template> + explicit + shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } + + /** + * @brief Construct a %shared_ptr that owns the pointer @a __p + * and the deleter @a __d. + * @param __p A pointer. + * @param __d A deleter. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw + * + * __shared_ptr will release __p by calling __d(__p) + */ + template> + shared_ptr(_Yp* __p, _Deleter __d) + : __shared_ptr<_Tp>(__p, std::move(__d)) { } + + /** + * @brief Construct a %shared_ptr that owns a null pointer + * and the deleter @a __d. + * @param __p A null pointer constant. + * @param __d A deleter. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw + * + * The last owner will call __d(__p) + */ + template + shared_ptr(nullptr_t __p, _Deleter __d) + : __shared_ptr<_Tp>(__p, std::move(__d)) { } + + /** + * @brief Construct a %shared_ptr that owns the pointer @a __p + * and the deleter @a __d. + * @param __p A pointer. + * @param __d A deleter. + * @param __a An allocator. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw _Alloc's copy constructor and destructor must not + * throw. + * + * __shared_ptr will release __p by calling __d(__p) + */ + template> + shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) + : __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { } + + /** + * @brief Construct a %shared_ptr that owns a null pointer + * and the deleter @a __d. + * @param __p A null pointer constant. + * @param __d A deleter. + * @param __a An allocator. + * @post use_count() == 1 && get() == __p + * @throw std::bad_alloc, in which case @a __d(__p) is called. + * + * Requirements: _Deleter's copy constructor and destructor must + * not throw _Alloc's copy constructor and destructor must not + * throw. + * + * The last owner will call __d(__p) + */ + template + shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) + : __shared_ptr<_Tp>(__p, std::move(__d), std::move(__a)) { } + + // Aliasing constructor + + /** + * @brief Constructs a `shared_ptr` instance that stores `__p` + * and shares ownership with `__r`. + * @param __r A `shared_ptr`. + * @param __p A pointer that will remain valid while `*__r` is valid. + * @post `get() == __p && use_count() == __r.use_count()` + * + * This can be used to construct a `shared_ptr` to a sub-object + * of an object managed by an existing `shared_ptr`. The complete + * object will remain valid while any `shared_ptr` owns it, even + * if they don't store a pointer to the complete object. + * + * @code + * shared_ptr> pii(new pair()); + * shared_ptr pi(pii, &pii->first); + * assert(pii.use_count() == 2); + * @endcode + */ + template + shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept + : __shared_ptr<_Tp>(__r, __p) { } + +#if __cplusplus > 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2996. Missing rvalue overloads for shared_ptr operations + /** + * @brief Constructs a `shared_ptr` instance that stores `__p` + * and shares ownership with `__r`. + * @param __r A `shared_ptr`. + * @param __p A pointer that will remain valid while `*__r` is valid. + * @post `get() == __p && !__r.use_count() && !__r.get()` + * + * This can be used to construct a `shared_ptr` to a sub-object + * of an object managed by an existing `shared_ptr`. The complete + * object will remain valid while any `shared_ptr` owns it, even + * if they don't store a pointer to the complete object. + * + * @code + * shared_ptr> pii(new pair()); + * shared_ptr pi1(pii, &pii->first); + * assert(pii.use_count() == 2); + * shared_ptr pi2(std::move(pii), &pii->second); + * assert(pii.use_count() == 0); + * @endcode + */ + template + shared_ptr(shared_ptr<_Yp>&& __r, element_type* __p) noexcept + : __shared_ptr<_Tp>(std::move(__r), __p) { } +#endif + /** + * @brief If @a __r is empty, constructs an empty %shared_ptr; + * otherwise construct a %shared_ptr that shares ownership + * with @a __r. + * @param __r A %shared_ptr. + * @post get() == __r.get() && use_count() == __r.use_count() + */ + template&>> + shared_ptr(const shared_ptr<_Yp>& __r) noexcept + : __shared_ptr<_Tp>(__r) { } + + /** + * @brief Move-constructs a %shared_ptr instance from @a __r. + * @param __r A %shared_ptr rvalue. + * @post *this contains the old value of @a __r, @a __r is empty. + */ + shared_ptr(shared_ptr&& __r) noexcept + : __shared_ptr<_Tp>(std::move(__r)) { } + + /** + * @brief Move-constructs a %shared_ptr instance from @a __r. + * @param __r A %shared_ptr rvalue. + * @post *this contains the old value of @a __r, @a __r is empty. + */ + template>> + shared_ptr(shared_ptr<_Yp>&& __r) noexcept + : __shared_ptr<_Tp>(std::move(__r)) { } + + /** + * @brief Constructs a %shared_ptr that shares ownership with @a __r + * and stores a copy of the pointer stored in @a __r. + * @param __r A weak_ptr. + * @post use_count() == __r.use_count() + * @throw bad_weak_ptr when __r.expired(), + * in which case the constructor has no effect. + */ + template&>> + explicit shared_ptr(const weak_ptr<_Yp>& __r) + : __shared_ptr<_Tp>(__r) { } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template>> + shared_ptr(auto_ptr<_Yp>&& __r); +#pragma GCC diagnostic pop +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2399. shared_ptr's constructor from unique_ptr should be constrained + template>> + shared_ptr(unique_ptr<_Yp, _Del>&& __r) + : __shared_ptr<_Tp>(std::move(__r)) { } + +#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED + // This non-standard constructor exists to support conversions that + // were possible in C++11 and C++14 but are ill-formed in C++17. + // If an exception is thrown this constructor has no effect. + template, __sp_array_delete>* = 0> + shared_ptr(unique_ptr<_Yp, _Del>&& __r) + : __shared_ptr<_Tp>(std::move(__r), __sp_array_delete()) { } +#endif + + /** + * @brief Construct an empty %shared_ptr. + * @post use_count() == 0 && get() == nullptr + */ + constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } + + shared_ptr& operator=(const shared_ptr&) noexcept = default; + + template + _Assignable&> + operator=(const shared_ptr<_Yp>& __r) noexcept + { + this->__shared_ptr<_Tp>::operator=(__r); + return *this; + } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template + _Assignable> + operator=(auto_ptr<_Yp>&& __r) + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } +#pragma GCC diagnostic pop +#endif + + shared_ptr& + operator=(shared_ptr&& __r) noexcept + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + template + _Assignable> + operator=(shared_ptr<_Yp>&& __r) noexcept + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + template + _Assignable> + operator=(unique_ptr<_Yp, _Del>&& __r) + { + this->__shared_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + private: + // This constructor is non-standard, it is used by allocate_shared. + template + shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) + : __shared_ptr<_Tp>(__tag, std::forward<_Args>(__args)...) + { } + + template + friend shared_ptr<_Yp> + allocate_shared(const _Alloc& __a, _Args&&... __args); + + // This constructor is non-standard, it is used by weak_ptr::lock(). + shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) noexcept + : __shared_ptr<_Tp>(__r, std::nothrow) { } + + friend class weak_ptr<_Tp>; + }; + +#if __cpp_deduction_guides >= 201606 + template + shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; + template + shared_ptr(unique_ptr<_Tp, _Del>) -> shared_ptr<_Tp>; +#endif + + // 20.7.2.2.7 shared_ptr comparisons + + /// @relates shared_ptr @{ + + /// Equality operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator==(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return __a.get() == __b.get(); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !__a; } + +#ifdef __cpp_lib_three_way_comparison + template + inline strong_ordering + operator<=>(const shared_ptr<_Tp>& __a, + const shared_ptr<_Up>& __b) noexcept + { return compare_three_way()(__a.get(), __b.get()); } + + template + inline strong_ordering + operator<=>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { + using pointer = typename shared_ptr<_Tp>::element_type*; + return compare_three_way()(__a.get(), static_cast(nullptr)); + } +#else + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !__a; } + + /// Inequality operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator!=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return __a.get() != __b.get(); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator!=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return (bool)__a; } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator!=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return (bool)__a; } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator<(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { + using _Tp_elt = typename shared_ptr<_Tp>::element_type; + using _Up_elt = typename shared_ptr<_Up>::element_type; + using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type; + return less<_Vp>()(__a.get(), __b.get()); + } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { + using _Tp_elt = typename shared_ptr<_Tp>::element_type; + return less<_Tp_elt*>()(__a.get(), nullptr); + } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { + using _Tp_elt = typename shared_ptr<_Tp>::element_type; + return less<_Tp_elt*>()(nullptr, __a.get()); + } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator<=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return !(__b < __a); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !(nullptr < __a); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !(__a < nullptr); } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator>(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return (__b < __a); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return nullptr < __a; } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return __a < nullptr; } + + /// Relational operator for shared_ptr objects, compares the stored pointers + template + _GLIBCXX_NODISCARD inline bool + operator>=(const shared_ptr<_Tp>& __a, const shared_ptr<_Up>& __b) noexcept + { return !(__a < __b); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(const shared_ptr<_Tp>& __a, nullptr_t) noexcept + { return !(__a < nullptr); } + + /// shared_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(nullptr_t, const shared_ptr<_Tp>& __a) noexcept + { return !(nullptr < __a); } +#endif + + // 20.7.2.2.8 shared_ptr specialized algorithms. + + /// Swap overload for shared_ptr + template + inline void + swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b) noexcept + { __a.swap(__b); } + + // 20.7.2.2.9 shared_ptr casts. + + /// Convert type of `shared_ptr`, via `static_cast` + template + inline shared_ptr<_Tp> + static_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(__r, static_cast(__r.get())); + } + + /// Convert type of `shared_ptr`, via `const_cast` + template + inline shared_ptr<_Tp> + const_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(__r, const_cast(__r.get())); + } + + /// Convert type of `shared_ptr`, via `dynamic_cast` + template + inline shared_ptr<_Tp> + dynamic_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + if (auto* __p = dynamic_cast(__r.get())) + return _Sp(__r, __p); + return _Sp(); + } + +#if __cplusplus >= 201703L + /// Convert type of `shared_ptr`, via `reinterpret_cast` + template + inline shared_ptr<_Tp> + reinterpret_pointer_cast(const shared_ptr<_Up>& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(__r, reinterpret_cast(__r.get())); + } + +#if __cplusplus > 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2996. Missing rvalue overloads for shared_ptr operations + + /// Convert type of `shared_ptr` rvalue, via `static_cast` + template + inline shared_ptr<_Tp> + static_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(std::move(__r), + static_cast(__r.get())); + } + + /// Convert type of `shared_ptr` rvalue, via `const_cast` + template + inline shared_ptr<_Tp> + const_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(std::move(__r), + const_cast(__r.get())); + } + + /// Convert type of `shared_ptr` rvalue, via `dynamic_cast` + template + inline shared_ptr<_Tp> + dynamic_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + if (auto* __p = dynamic_cast(__r.get())) + return _Sp(std::move(__r), __p); + return _Sp(); + } + + /// Convert type of `shared_ptr` rvalue, via `reinterpret_cast` + template + inline shared_ptr<_Tp> + reinterpret_pointer_cast(shared_ptr<_Up>&& __r) noexcept + { + using _Sp = shared_ptr<_Tp>; + return _Sp(std::move(__r), + reinterpret_cast(__r.get())); + } +#endif // C++20 +#endif // C++17 + + /// @} + + /** + * @brief A non-owning observer for a pointer owned by a shared_ptr + * + * A weak_ptr provides a safe alternative to a raw pointer when you want + * a non-owning reference to an object that is managed by a shared_ptr. + * + * Unlike a raw pointer, a weak_ptr can be converted to a new shared_ptr + * that shares ownership with every other shared_ptr that already owns + * the pointer. In other words you can upgrade from a non-owning "weak" + * reference to an owning shared_ptr, without having access to any of + * the existing shared_ptr objects. + * + * Also unlike a raw pointer, a weak_ptr does not become "dangling" after + * the object it points to has been destroyed. Instead, a weak_ptr + * becomes _expired_ and can no longer be converted to a shared_ptr that + * owns the freed pointer, so you cannot accidentally access the pointed-to + * object after it has been destroyed. + */ + template + class weak_ptr : public __weak_ptr<_Tp> + { + template + using _Constructible = typename enable_if< + is_constructible<__weak_ptr<_Tp>, _Arg>::value + >::type; + + template + using _Assignable = typename enable_if< + is_assignable<__weak_ptr<_Tp>&, _Arg>::value, weak_ptr& + >::type; + + public: + constexpr weak_ptr() noexcept = default; + + template&>> + weak_ptr(const shared_ptr<_Yp>& __r) noexcept + : __weak_ptr<_Tp>(__r) { } + + weak_ptr(const weak_ptr&) noexcept = default; + + template&>> + weak_ptr(const weak_ptr<_Yp>& __r) noexcept + : __weak_ptr<_Tp>(__r) { } + + weak_ptr(weak_ptr&&) noexcept = default; + + template>> + weak_ptr(weak_ptr<_Yp>&& __r) noexcept + : __weak_ptr<_Tp>(std::move(__r)) { } + + weak_ptr& + operator=(const weak_ptr& __r) noexcept = default; + + template + _Assignable&> + operator=(const weak_ptr<_Yp>& __r) noexcept + { + this->__weak_ptr<_Tp>::operator=(__r); + return *this; + } + + template + _Assignable&> + operator=(const shared_ptr<_Yp>& __r) noexcept + { + this->__weak_ptr<_Tp>::operator=(__r); + return *this; + } + + weak_ptr& + operator=(weak_ptr&& __r) noexcept = default; + + template + _Assignable> + operator=(weak_ptr<_Yp>&& __r) noexcept + { + this->__weak_ptr<_Tp>::operator=(std::move(__r)); + return *this; + } + + shared_ptr<_Tp> + lock() const noexcept + { return shared_ptr<_Tp>(*this, std::nothrow); } + }; + +#if __cpp_deduction_guides >= 201606 + template + weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>; +#endif + + // 20.7.2.3.6 weak_ptr specialized algorithms. + /// Swap overload for weak_ptr + /// @relates weak_ptr + template + inline void + swap(weak_ptr<_Tp>& __a, weak_ptr<_Tp>& __b) noexcept + { __a.swap(__b); } + + + /// Primary template owner_less + template + struct owner_less; + + /// Void specialization of owner_less compares either shared_ptr or weak_ptr + template<> + struct owner_less : _Sp_owner_less + { }; + + /// Partial specialization of owner_less for shared_ptr. + template + struct owner_less> + : public _Sp_owner_less, weak_ptr<_Tp>> + { }; + + /// Partial specialization of owner_less for weak_ptr. + template + struct owner_less> + : public _Sp_owner_less, shared_ptr<_Tp>> + { }; + + /** + * @brief Base class allowing use of member function shared_from_this. + */ + template + class enable_shared_from_this + { + protected: + constexpr enable_shared_from_this() noexcept { } + + enable_shared_from_this(const enable_shared_from_this&) noexcept { } + + enable_shared_from_this& + operator=(const enable_shared_from_this&) noexcept + { return *this; } + + ~enable_shared_from_this() { } + + public: + shared_ptr<_Tp> + shared_from_this() + { return shared_ptr<_Tp>(this->_M_weak_this); } + + shared_ptr + shared_from_this() const + { return shared_ptr(this->_M_weak_this); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 +#define __cpp_lib_enable_shared_from_this 201603 + weak_ptr<_Tp> + weak_from_this() noexcept + { return this->_M_weak_this; } + + weak_ptr + weak_from_this() const noexcept + { return this->_M_weak_this; } +#endif + + private: + template + void + _M_weak_assign(_Tp1* __p, const __shared_count<>& __n) const noexcept + { _M_weak_this._M_assign(__p, __n); } + + // Found by ADL when this is an associated class. + friend const enable_shared_from_this* + __enable_shared_from_this_base(const __shared_count<>&, + const enable_shared_from_this* __p) + { return __p; } + + template + friend class __shared_ptr; + + mutable weak_ptr<_Tp> _M_weak_this; + }; + + /// @relates shared_ptr @{ + + /** + * @brief Create an object that is owned by a shared_ptr. + * @param __a An allocator. + * @param __args Arguments for the @a _Tp object's constructor. + * @return A shared_ptr that owns the newly created object. + * @throw An exception thrown from @a _Alloc::allocate or from the + * constructor of @a _Tp. + * + * A copy of @a __a will be used to allocate memory for the shared_ptr + * and the new object. + */ + template + inline shared_ptr<_Tp> + allocate_shared(const _Alloc& __a, _Args&&... __args) + { + static_assert(!is_array<_Tp>::value, "make_shared not supported"); + + return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a}, + std::forward<_Args>(__args)...); + } + + /** + * @brief Create an object that is owned by a shared_ptr. + * @param __args Arguments for the @a _Tp object's constructor. + * @return A shared_ptr that owns the newly created object. + * @throw std::bad_alloc, or an exception thrown from the + * constructor of @a _Tp. + */ + template + inline shared_ptr<_Tp> + make_shared(_Args&&... __args) + { + typedef typename std::remove_cv<_Tp>::type _Tp_nc; + return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(), + std::forward<_Args>(__args)...); + } + + /// std::hash specialization for shared_ptr. + template + struct hash> + : public __hash_base> + { + size_t + operator()(const shared_ptr<_Tp>& __s) const noexcept + { + return std::hash::element_type*>()(__s.get()); + } + }; + + /// @} relates shared_ptr + /// @} group pointer_abstractions + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // shared_ptr into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + + // Provide the strong exception-safety guarantee when emplacing a + // weak_ptr into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr_atomic.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr_atomic.h new file mode 100755 index 0000000..6e94d83 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr_atomic.h @@ -0,0 +1,336 @@ +// shared_ptr atomic access -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/shared_ptr_atomic.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _SHARED_PTR_ATOMIC_H +#define _SHARED_PTR_ATOMIC_H 1 + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup pointer_abstractions + * @{ + */ + /// @relates shared_ptr @{ + + /// @cond undocumented + + struct _Sp_locker + { + _Sp_locker(const _Sp_locker&) = delete; + _Sp_locker& operator=(const _Sp_locker&) = delete; + +#ifdef __GTHREADS + explicit + _Sp_locker(const void*) noexcept; + _Sp_locker(const void*, const void*) noexcept; + ~_Sp_locker(); + + private: + unsigned char _M_key1; + unsigned char _M_key2; +#else + explicit _Sp_locker(const void*, const void* = nullptr) { } +#endif + }; + + /// @endcond + + /** + * @brief Report whether shared_ptr atomic operations are lock-free. + * @param __p A non-null pointer to a shared_ptr object. + * @return True if atomic access to @c *__p is lock-free, false otherwise. + * @{ + */ + template + inline bool + atomic_is_lock_free(const __shared_ptr<_Tp, _Lp>* __p) + { +#ifdef __GTHREADS + return __gthread_active_p() == 0; +#else + return true; +#endif + } + + template + inline bool + atomic_is_lock_free(const shared_ptr<_Tp>* __p) + { return std::atomic_is_lock_free<_Tp, __default_lock_policy>(__p); } + + /// @} + + /** + * @brief Atomic load for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @return @c *__p + * + * The memory order shall not be @c memory_order_release or + * @c memory_order_acq_rel. + * @{ + */ + template + inline shared_ptr<_Tp> + atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) + { + _Sp_locker __lock{__p}; + return *__p; + } + + template + inline shared_ptr<_Tp> + atomic_load(const shared_ptr<_Tp>* __p) + { return std::atomic_load_explicit(__p, memory_order_seq_cst); } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_load_explicit(const __shared_ptr<_Tp, _Lp>* __p, memory_order) + { + _Sp_locker __lock{__p}; + return *__p; + } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_load(const __shared_ptr<_Tp, _Lp>* __p) + { return std::atomic_load_explicit(__p, memory_order_seq_cst); } + /// @} + + /** + * @brief Atomic store for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @param __r The value to store. + * + * The memory order shall not be @c memory_order_acquire or + * @c memory_order_acq_rel. + * @{ + */ + template + inline void + atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); // use swap so that **__p not destroyed while lock held + } + + template + inline void + atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) + { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } + + template + inline void + atomic_store_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); // use swap so that **__p not destroyed while lock held + } + + template + inline void + atomic_store(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) + { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } + /// @} + + /** + * @brief Atomic exchange for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @param __r New value to store in @c *__p. + * @return The original value of @c *__p + * @{ + */ + template + inline shared_ptr<_Tp> + atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); + return __r; + } + + template + inline shared_ptr<_Tp> + atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) + { + return std::atomic_exchange_explicit(__p, std::move(__r), + memory_order_seq_cst); + } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_exchange_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp> __r, + memory_order) + { + _Sp_locker __lock{__p}; + __p->swap(__r); + return __r; + } + + template + inline __shared_ptr<_Tp, _Lp> + atomic_exchange(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) + { + return std::atomic_exchange_explicit(__p, std::move(__r), + memory_order_seq_cst); + } + /// @} + + /** + * @brief Atomic compare-and-swap for shared_ptr objects. + * @param __p A non-null pointer to a shared_ptr object. + * @param __v A non-null pointer to a shared_ptr object. + * @param __w A non-null pointer to a shared_ptr object. + * @return True if @c *__p was equivalent to @c *__v, false otherwise. + * + * The memory order for failure shall not be @c memory_order_release or + * @c memory_order_acq_rel, or stronger than the memory order for success. + * @{ + */ + template + bool + atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, + shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w, + memory_order, + memory_order) + { + shared_ptr<_Tp> __x; // goes out of scope after __lock + _Sp_locker __lock{__p, __v}; + owner_less> __less; + if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p)) + { + __x = std::move(*__p); + *__p = std::move(__w); + return true; + } + __x = std::move(*__v); + *__v = *__p; + return false; + } + + template + inline bool + atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, + shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w, + memory_order __success, + memory_order __failure) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), __success, __failure); + } + + template + inline bool + atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, + shared_ptr<_Tp> __w) + { + return std::atomic_compare_exchange_weak_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + + template + bool + atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w, + memory_order, + memory_order) + { + __shared_ptr<_Tp, _Lp> __x; // goes out of scope after __lock + _Sp_locker __lock{__p, __v}; + owner_less<__shared_ptr<_Tp, _Lp>> __less; + if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p)) + { + __x = std::move(*__p); + *__p = std::move(__w); + return true; + } + __x = std::move(*__v); + *__v = *__p; + return false; + } + + template + inline bool + atomic_compare_exchange_strong(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + + template + inline bool + atomic_compare_exchange_weak_explicit(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w, + memory_order __success, + memory_order __failure) + { + return std::atomic_compare_exchange_strong_explicit(__p, __v, + std::move(__w), __success, __failure); + } + + template + inline bool + atomic_compare_exchange_weak(__shared_ptr<_Tp, _Lp>* __p, + __shared_ptr<_Tp, _Lp>* __v, + __shared_ptr<_Tp, _Lp> __w) + { + return std::atomic_compare_exchange_weak_explicit(__p, __v, + std::move(__w), memory_order_seq_cst, memory_order_seq_cst); + } + /// @} + + /// @} relates shared_ptr + /// @} group pointer_abstractions + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_ATOMIC_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr_base.h new file mode 100755 index 0000000..eb9ad23 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/shared_ptr_base.h @@ -0,0 +1,1871 @@ +// shared_ptr and weak_ptr implementation details -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// GCC Note: Based on files from version 1.32.0 of the Boost library. + +// shared_count.hpp +// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd. + +// shared_ptr.hpp +// Copyright (C) 1998, 1999 Greg Colvin and Beman Dawes. +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// weak_ptr.hpp +// Copyright (C) 2001, 2002, 2003 Peter Dimov + +// enable_shared_from_this.hpp +// Copyright (C) 2002 Peter Dimov + +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/** @file bits/shared_ptr_base.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _SHARED_PTR_BASE_H +#define _SHARED_PTR_BASE_H 1 + +#include +#include +#include +#include +#include +#include +#include // std::less +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template class auto_ptr; +#pragma GCC diagnostic pop +#endif + + /** + * @brief Exception possibly thrown by @c shared_ptr. + * @ingroup exceptions + */ + class bad_weak_ptr : public std::exception + { + public: + virtual char const* what() const noexcept; + + virtual ~bad_weak_ptr() noexcept; + }; + + // Substitute for bad_weak_ptr object in the case of -fno-exceptions. + inline void + __throw_bad_weak_ptr() + { _GLIBCXX_THROW_OR_ABORT(bad_weak_ptr()); } + + using __gnu_cxx::_Lock_policy; + using __gnu_cxx::__default_lock_policy; + using __gnu_cxx::_S_single; + using __gnu_cxx::_S_mutex; + using __gnu_cxx::_S_atomic; + + // Empty helper class except when the template argument is _S_mutex. + template<_Lock_policy _Lp> + class _Mutex_base + { + protected: + // The atomic policy uses fully-fenced builtins, single doesn't care. + enum { _S_need_barriers = 0 }; + }; + + template<> + class _Mutex_base<_S_mutex> + : public __gnu_cxx::__mutex + { + protected: + // This policy is used when atomic builtins are not available. + // The replacement atomic operations might not have the necessary + // memory barriers. + enum { _S_need_barriers = 1 }; + }; + + template<_Lock_policy _Lp = __default_lock_policy> + class _Sp_counted_base + : public _Mutex_base<_Lp> + { + public: + _Sp_counted_base() noexcept + : _M_use_count(1), _M_weak_count(1) { } + + virtual + ~_Sp_counted_base() noexcept + { } + + // Called when _M_use_count drops to zero, to release the resources + // managed by *this. + virtual void + _M_dispose() noexcept = 0; + + // Called when _M_weak_count drops to zero. + virtual void + _M_destroy() noexcept + { delete this; } + + virtual void* + _M_get_deleter(const std::type_info&) noexcept = 0; + + void + _M_add_ref_copy() + { __gnu_cxx::__atomic_add_dispatch(&_M_use_count, 1); } + + void + _M_add_ref_lock() + { + if (!_M_add_ref_lock_nothrow()) + __throw_bad_weak_ptr(); + } + + bool + _M_add_ref_lock_nothrow() noexcept; + + void + _M_release() noexcept + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_use_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_use_count); + _M_dispose(); + // There must be a memory barrier between dispose() and destroy() + // to ensure that the effects of dispose() are observed in the + // thread that runs destroy(). + // See http://gcc.gnu.org/ml/libstdc++/2005-11/msg00136.html + if (_Mutex_base<_Lp>::_S_need_barriers) + { + __atomic_thread_fence (__ATOMIC_ACQ_REL); + } + + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, + -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + _M_destroy(); + } + } + } + + void + _M_weak_add_ref() noexcept + { __gnu_cxx::__atomic_add_dispatch(&_M_weak_count, 1); } + + void + _M_weak_release() noexcept + { + // Be race-detector-friendly. For more info see bits/c++config. + _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_weak_count); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_weak_count, -1) == 1) + { + _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_weak_count); + if (_Mutex_base<_Lp>::_S_need_barriers) + { + // See _M_release(), + // destroy() must observe results of dispose() + __atomic_thread_fence (__ATOMIC_ACQ_REL); + } + _M_destroy(); + } + } + + long + _M_get_use_count() const noexcept + { + // No memory barrier is used here so there is no synchronization + // with other threads. + return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED); + } + + private: + _Sp_counted_base(_Sp_counted_base const&) = delete; + _Sp_counted_base& operator=(_Sp_counted_base const&) = delete; + + _Atomic_word _M_use_count; // #shared + _Atomic_word _M_weak_count; // #weak + (#shared != 0) + }; + + template<> + inline bool + _Sp_counted_base<_S_single>:: + _M_add_ref_lock_nothrow() noexcept + { + if (_M_use_count == 0) + return false; + ++_M_use_count; + return true; + } + + template<> + inline bool + _Sp_counted_base<_S_mutex>:: + _M_add_ref_lock_nothrow() noexcept + { + __gnu_cxx::__scoped_lock sentry(*this); + if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0) + { + _M_use_count = 0; + return false; + } + return true; + } + + template<> + inline bool + _Sp_counted_base<_S_atomic>:: + _M_add_ref_lock_nothrow() noexcept + { + // Perform lock-free add-if-not-zero operation. + _Atomic_word __count = _M_get_use_count(); + do + { + if (__count == 0) + return false; + // Replace the current counter value with the old value + 1, as + // long as it's not changed meanwhile. + } + while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, + true, __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED)); + return true; + } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_add_ref_copy() + { ++_M_use_count; } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_release() noexcept + { + if (--_M_use_count == 0) + { + _M_dispose(); + if (--_M_weak_count == 0) + _M_destroy(); + } + } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept + { ++_M_weak_count; } + + template<> + inline void + _Sp_counted_base<_S_single>::_M_weak_release() noexcept + { + if (--_M_weak_count == 0) + _M_destroy(); + } + + template<> + inline long + _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept + { return _M_use_count; } + + + // Forward declarations. + template + class __shared_ptr; + + template + class __weak_ptr; + + template + class __enable_shared_from_this; + + template + class shared_ptr; + + template + class weak_ptr; + + template + struct owner_less; + + template + class enable_shared_from_this; + + template<_Lock_policy _Lp = __default_lock_policy> + class __weak_count; + + template<_Lock_policy _Lp = __default_lock_policy> + class __shared_count; + + + // Counted ptr with no deleter or allocator support + template + class _Sp_counted_ptr final : public _Sp_counted_base<_Lp> + { + public: + explicit + _Sp_counted_ptr(_Ptr __p) noexcept + : _M_ptr(__p) { } + + virtual void + _M_dispose() noexcept + { delete _M_ptr; } + + virtual void + _M_destroy() noexcept + { delete this; } + + virtual void* + _M_get_deleter(const std::type_info&) noexcept + { return nullptr; } + + _Sp_counted_ptr(const _Sp_counted_ptr&) = delete; + _Sp_counted_ptr& operator=(const _Sp_counted_ptr&) = delete; + + private: + _Ptr _M_ptr; + }; + + template<> + inline void + _Sp_counted_ptr::_M_dispose() noexcept { } + + template<> + inline void + _Sp_counted_ptr::_M_dispose() noexcept { } + + template<> + inline void + _Sp_counted_ptr::_M_dispose() noexcept { } + + template + struct _Sp_ebo_helper; + + /// Specialization using EBO. + template + struct _Sp_ebo_helper<_Nm, _Tp, true> : private _Tp + { + explicit _Sp_ebo_helper(const _Tp& __tp) : _Tp(__tp) { } + explicit _Sp_ebo_helper(_Tp&& __tp) : _Tp(std::move(__tp)) { } + + static _Tp& + _S_get(_Sp_ebo_helper& __eboh) { return static_cast<_Tp&>(__eboh); } + }; + + /// Specialization not using EBO. + template + struct _Sp_ebo_helper<_Nm, _Tp, false> + { + explicit _Sp_ebo_helper(const _Tp& __tp) : _M_tp(__tp) { } + explicit _Sp_ebo_helper(_Tp&& __tp) : _M_tp(std::move(__tp)) { } + + static _Tp& + _S_get(_Sp_ebo_helper& __eboh) + { return __eboh._M_tp; } + + private: + _Tp _M_tp; + }; + + // Support for custom deleter and/or allocator + template + class _Sp_counted_deleter final : public _Sp_counted_base<_Lp> + { + class _Impl : _Sp_ebo_helper<0, _Deleter>, _Sp_ebo_helper<1, _Alloc> + { + typedef _Sp_ebo_helper<0, _Deleter> _Del_base; + typedef _Sp_ebo_helper<1, _Alloc> _Alloc_base; + + public: + _Impl(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept + : _Del_base(std::move(__d)), _Alloc_base(__a), _M_ptr(__p) + { } + + _Deleter& _M_del() noexcept { return _Del_base::_S_get(*this); } + _Alloc& _M_alloc() noexcept { return _Alloc_base::_S_get(*this); } + + _Ptr _M_ptr; + }; + + public: + using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_deleter>; + + // __d(__p) must not throw. + _Sp_counted_deleter(_Ptr __p, _Deleter __d) noexcept + : _M_impl(__p, std::move(__d), _Alloc()) { } + + // __d(__p) must not throw. + _Sp_counted_deleter(_Ptr __p, _Deleter __d, const _Alloc& __a) noexcept + : _M_impl(__p, std::move(__d), __a) { } + + ~_Sp_counted_deleter() noexcept { } + + virtual void + _M_dispose() noexcept + { _M_impl._M_del()(_M_impl._M_ptr); } + + virtual void + _M_destroy() noexcept + { + __allocator_type __a(_M_impl._M_alloc()); + __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; + this->~_Sp_counted_deleter(); + } + + virtual void* + _M_get_deleter(const type_info& __ti [[__gnu__::__unused__]]) noexcept + { +#if __cpp_rtti + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2400. shared_ptr's get_deleter() should use addressof() + return __ti == typeid(_Deleter) + ? std::__addressof(_M_impl._M_del()) + : nullptr; +#else + return nullptr; +#endif + } + + private: + _Impl _M_impl; + }; + + // helpers for make_shared / allocate_shared + + struct _Sp_make_shared_tag + { + private: + template + friend class _Sp_counted_ptr_inplace; + + static const type_info& + _S_ti() noexcept _GLIBCXX_VISIBILITY(default) + { + alignas(type_info) static constexpr char __tag[sizeof(type_info)] = { }; + return reinterpret_cast(__tag); + } + + static bool _S_eq(const type_info&) noexcept; + }; + + template + struct _Sp_alloc_shared_tag + { + const _Alloc& _M_a; + }; + + template + class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp> + { + class _Impl : _Sp_ebo_helper<0, _Alloc> + { + typedef _Sp_ebo_helper<0, _Alloc> _A_base; + + public: + explicit _Impl(_Alloc __a) noexcept : _A_base(__a) { } + + _Alloc& _M_alloc() noexcept { return _A_base::_S_get(*this); } + + __gnu_cxx::__aligned_buffer<_Tp> _M_storage; + }; + + public: + using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>; + + // Alloc parameter is not a reference so doesn't alias anything in __args + template + _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args) + : _M_impl(__a) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2070. allocate_shared should use allocator_traits::construct + allocator_traits<_Alloc>::construct(__a, _M_ptr(), + std::forward<_Args>(__args)...); // might throw + } + + ~_Sp_counted_ptr_inplace() noexcept { } + + virtual void + _M_dispose() noexcept + { + allocator_traits<_Alloc>::destroy(_M_impl._M_alloc(), _M_ptr()); + } + + // Override because the allocator needs to know the dynamic type + virtual void + _M_destroy() noexcept + { + __allocator_type __a(_M_impl._M_alloc()); + __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; + this->~_Sp_counted_ptr_inplace(); + } + + private: + friend class __shared_count<_Lp>; // To be able to call _M_ptr(). + + // No longer used, but code compiled against old libstdc++ headers + // might still call it from __shared_ptr ctor to get the pointer out. + virtual void* + _M_get_deleter(const std::type_info& __ti) noexcept override + { + auto __ptr = const_cast::type*>(_M_ptr()); + // Check for the fake type_info first, so we don't try to access it + // as a real type_info object. Otherwise, check if it's the real + // type_info for this class. With RTTI enabled we can check directly, + // or call a library function to do it. + if (&__ti == &_Sp_make_shared_tag::_S_ti() + || +#if __cpp_rtti + __ti == typeid(_Sp_make_shared_tag) +#else + _Sp_make_shared_tag::_S_eq(__ti) +#endif + ) + return __ptr; + return nullptr; + } + + _Tp* _M_ptr() noexcept { return _M_impl._M_storage._M_ptr(); } + + _Impl _M_impl; + }; + + // The default deleter for shared_ptr and shared_ptr. + struct __sp_array_delete + { + template + void operator()(_Yp* __p) const { delete[] __p; } + }; + + template<_Lock_policy _Lp> + class __shared_count + { + template + struct __not_alloc_shared_tag { using type = void; }; + + template + struct __not_alloc_shared_tag<_Sp_alloc_shared_tag<_Tp>> { }; + + public: + constexpr __shared_count() noexcept : _M_pi(0) + { } + + template + explicit + __shared_count(_Ptr __p) : _M_pi(0) + { + __try + { + _M_pi = new _Sp_counted_ptr<_Ptr, _Lp>(__p); + } + __catch(...) + { + delete __p; + __throw_exception_again; + } + } + + template + __shared_count(_Ptr __p, /* is_array = */ false_type) + : __shared_count(__p) + { } + + template + __shared_count(_Ptr __p, /* is_array = */ true_type) + : __shared_count(__p, __sp_array_delete{}, allocator()) + { } + + template::type> + __shared_count(_Ptr __p, _Deleter __d) + : __shared_count(__p, std::move(__d), allocator()) + { } + + template::type> + __shared_count(_Ptr __p, _Deleter __d, _Alloc __a) : _M_pi(0) + { + typedef _Sp_counted_deleter<_Ptr, _Deleter, _Alloc, _Lp> _Sp_cd_type; + __try + { + typename _Sp_cd_type::__allocator_type __a2(__a); + auto __guard = std::__allocate_guarded(__a2); + _Sp_cd_type* __mem = __guard.get(); + ::new (__mem) _Sp_cd_type(__p, std::move(__d), std::move(__a)); + _M_pi = __mem; + __guard = nullptr; + } + __catch(...) + { + __d(__p); // Call _Deleter on __p. + __throw_exception_again; + } + } + + template + __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a, + _Args&&... __args) + { + typedef _Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp> _Sp_cp_type; + typename _Sp_cp_type::__allocator_type __a2(__a._M_a); + auto __guard = std::__allocate_guarded(__a2); + _Sp_cp_type* __mem = __guard.get(); + auto __pi = ::new (__mem) + _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...); + __guard = nullptr; + _M_pi = __pi; + __p = __pi->_M_ptr(); + } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // Special case for auto_ptr<_Tp> to provide the strong guarantee. + template + explicit + __shared_count(std::auto_ptr<_Tp>&& __r); +#pragma GCC diagnostic pop +#endif + + // Special case for unique_ptr<_Tp,_Del> to provide the strong guarantee. + template + explicit + __shared_count(std::unique_ptr<_Tp, _Del>&& __r) : _M_pi(0) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2415. Inconsistency between unique_ptr and shared_ptr + if (__r.get() == nullptr) + return; + + using _Ptr = typename unique_ptr<_Tp, _Del>::pointer; + using _Del2 = typename conditional::value, + reference_wrapper::type>, + _Del>::type; + using _Sp_cd_type + = _Sp_counted_deleter<_Ptr, _Del2, allocator, _Lp>; + using _Alloc = allocator<_Sp_cd_type>; + using _Alloc_traits = allocator_traits<_Alloc>; + _Alloc __a; + _Sp_cd_type* __mem = _Alloc_traits::allocate(__a, 1); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3548. shared_ptr construction from unique_ptr should move + // (not copy) the deleter + _Alloc_traits::construct(__a, __mem, __r.release(), + std::forward<_Del>(__r.get_deleter())); + _M_pi = __mem; + } + + // Throw bad_weak_ptr when __r._M_get_use_count() == 0. + explicit __shared_count(const __weak_count<_Lp>& __r); + + // Does not throw if __r._M_get_use_count() == 0, caller must check. + explicit + __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t) noexcept; + + ~__shared_count() noexcept + { + if (_M_pi != nullptr) + _M_pi->_M_release(); + } + + __shared_count(const __shared_count& __r) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + _M_pi->_M_add_ref_copy(); + } + + __shared_count& + operator=(const __shared_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != _M_pi) + { + if (__tmp != nullptr) + __tmp->_M_add_ref_copy(); + if (_M_pi != nullptr) + _M_pi->_M_release(); + _M_pi = __tmp; + } + return *this; + } + + void + _M_swap(__shared_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + __r._M_pi = _M_pi; + _M_pi = __tmp; + } + + long + _M_get_use_count() const noexcept + { return _M_pi ? _M_pi->_M_get_use_count() : 0; } + + bool + _M_unique() const noexcept + { return this->_M_get_use_count() == 1; } + + void* + _M_get_deleter(const std::type_info& __ti) const noexcept + { return _M_pi ? _M_pi->_M_get_deleter(__ti) : nullptr; } + + bool + _M_less(const __shared_count& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + bool + _M_less(const __weak_count<_Lp>& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + // Friend function injected into enclosing namespace and found by ADL + friend inline bool + operator==(const __shared_count& __a, const __shared_count& __b) noexcept + { return __a._M_pi == __b._M_pi; } + + private: + friend class __weak_count<_Lp>; + + _Sp_counted_base<_Lp>* _M_pi; + }; + + + template<_Lock_policy _Lp> + class __weak_count + { + public: + constexpr __weak_count() noexcept : _M_pi(nullptr) + { } + + __weak_count(const __shared_count<_Lp>& __r) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + _M_pi->_M_weak_add_ref(); + } + + __weak_count(const __weak_count& __r) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi != nullptr) + _M_pi->_M_weak_add_ref(); + } + + __weak_count(__weak_count&& __r) noexcept + : _M_pi(__r._M_pi) + { __r._M_pi = nullptr; } + + ~__weak_count() noexcept + { + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + } + + __weak_count& + operator=(const __shared_count<_Lp>& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != nullptr) + __tmp->_M_weak_add_ref(); + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + _M_pi = __tmp; + return *this; + } + + __weak_count& + operator=(const __weak_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + if (__tmp != nullptr) + __tmp->_M_weak_add_ref(); + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + _M_pi = __tmp; + return *this; + } + + __weak_count& + operator=(__weak_count&& __r) noexcept + { + if (_M_pi != nullptr) + _M_pi->_M_weak_release(); + _M_pi = __r._M_pi; + __r._M_pi = nullptr; + return *this; + } + + void + _M_swap(__weak_count& __r) noexcept + { + _Sp_counted_base<_Lp>* __tmp = __r._M_pi; + __r._M_pi = _M_pi; + _M_pi = __tmp; + } + + long + _M_get_use_count() const noexcept + { return _M_pi != nullptr ? _M_pi->_M_get_use_count() : 0; } + + bool + _M_less(const __weak_count& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + bool + _M_less(const __shared_count<_Lp>& __rhs) const noexcept + { return std::less<_Sp_counted_base<_Lp>*>()(this->_M_pi, __rhs._M_pi); } + + // Friend function injected into enclosing namespace and found by ADL + friend inline bool + operator==(const __weak_count& __a, const __weak_count& __b) noexcept + { return __a._M_pi == __b._M_pi; } + + private: + friend class __shared_count<_Lp>; + + _Sp_counted_base<_Lp>* _M_pi; + }; + + // Now that __weak_count is defined we can define this constructor: + template<_Lock_policy _Lp> + inline + __shared_count<_Lp>::__shared_count(const __weak_count<_Lp>& __r) + : _M_pi(__r._M_pi) + { + if (_M_pi == nullptr || !_M_pi->_M_add_ref_lock_nothrow()) + __throw_bad_weak_ptr(); + } + + // Now that __weak_count is defined we can define this constructor: + template<_Lock_policy _Lp> + inline + __shared_count<_Lp>:: + __shared_count(const __weak_count<_Lp>& __r, std::nothrow_t) noexcept + : _M_pi(__r._M_pi) + { + if (_M_pi && !_M_pi->_M_add_ref_lock_nothrow()) + _M_pi = nullptr; + } + +#define __cpp_lib_shared_ptr_arrays 201611L + + // Helper traits for shared_ptr of array: + + // A pointer type Y* is said to be compatible with a pointer type T* when + // either Y* is convertible to T* or Y is U[N] and T is U cv []. + template + struct __sp_compatible_with + : false_type + { }; + + template + struct __sp_compatible_with<_Yp*, _Tp*> + : is_convertible<_Yp*, _Tp*>::type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], _Up(*)[]> + : true_type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], const _Up(*)[]> + : true_type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], volatile _Up(*)[]> + : true_type + { }; + + template + struct __sp_compatible_with<_Up(*)[_Nm], const volatile _Up(*)[]> + : true_type + { }; + + // Test conversion from Y(*)[N] to U(*)[N] without forming invalid type Y[N]. + template + struct __sp_is_constructible_arrN + : false_type + { }; + + template + struct __sp_is_constructible_arrN<_Up, _Nm, _Yp, __void_t<_Yp[_Nm]>> + : is_convertible<_Yp(*)[_Nm], _Up(*)[_Nm]>::type + { }; + + // Test conversion from Y(*)[] to U(*)[] without forming invalid type Y[]. + template + struct __sp_is_constructible_arr + : false_type + { }; + + template + struct __sp_is_constructible_arr<_Up, _Yp, __void_t<_Yp[]>> + : is_convertible<_Yp(*)[], _Up(*)[]>::type + { }; + + // Trait to check if shared_ptr can be constructed from Y*. + template + struct __sp_is_constructible; + + // When T is U[N], Y(*)[N] shall be convertible to T*; + template + struct __sp_is_constructible<_Up[_Nm], _Yp> + : __sp_is_constructible_arrN<_Up, _Nm, _Yp>::type + { }; + + // when T is U[], Y(*)[] shall be convertible to T*; + template + struct __sp_is_constructible<_Up[], _Yp> + : __sp_is_constructible_arr<_Up, _Yp>::type + { }; + + // otherwise, Y* shall be convertible to T*. + template + struct __sp_is_constructible + : is_convertible<_Yp*, _Tp*>::type + { }; + + + // Define operator* and operator-> for shared_ptr. + template::value, bool = is_void<_Tp>::value> + class __shared_ptr_access + { + public: + using element_type = _Tp; + + element_type& + operator*() const noexcept + { + __glibcxx_assert(_M_get() != nullptr); + return *_M_get(); + } + + element_type* + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr); + return _M_get(); + } + + private: + element_type* + _M_get() const noexcept + { return static_cast*>(this)->get(); } + }; + + // Define operator-> for shared_ptr. + template + class __shared_ptr_access<_Tp, _Lp, false, true> + { + public: + using element_type = _Tp; + + element_type* + operator->() const noexcept + { + auto __ptr = static_cast*>(this)->get(); + _GLIBCXX_DEBUG_PEDASSERT(__ptr != nullptr); + return __ptr; + } + }; + + // Define operator[] for shared_ptr and shared_ptr. + template + class __shared_ptr_access<_Tp, _Lp, true, false> + { + public: + using element_type = typename remove_extent<_Tp>::type; + +#if __cplusplus <= 201402L + [[__deprecated__("shared_ptr::operator* is absent from C++17")]] + element_type& + operator*() const noexcept + { + __glibcxx_assert(_M_get() != nullptr); + return *_M_get(); + } + + [[__deprecated__("shared_ptr::operator-> is absent from C++17")]] + element_type* + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(_M_get() != nullptr); + return _M_get(); + } +#endif + + element_type& + operator[](ptrdiff_t __i) const + { + __glibcxx_assert(_M_get() != nullptr); + __glibcxx_assert(!extent<_Tp>::value || __i < extent<_Tp>::value); + return _M_get()[__i]; + } + + private: + element_type* + _M_get() const noexcept + { return static_cast*>(this)->get(); } + }; + + template + class __shared_ptr + : public __shared_ptr_access<_Tp, _Lp> + { + public: + using element_type = typename remove_extent<_Tp>::type; + + private: + // Constraint for taking ownership of a pointer of type _Yp*: + template + using _SafeConv + = typename enable_if<__sp_is_constructible<_Tp, _Yp>::value>::type; + + // Constraint for construction from shared_ptr and weak_ptr: + template + using _Compatible = typename + enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type; + + // Constraint for assignment from shared_ptr and weak_ptr: + template + using _Assignable = _Compatible<_Yp, __shared_ptr&>; + + // Constraint for construction from unique_ptr: + template::pointer> + using _UniqCompatible = __enable_if_t<__and_< + __sp_compatible_with<_Yp*, _Tp*>, + is_convertible<_Ptr, element_type*>, + is_move_constructible<_Del> + >::value, _Res>; + + // Constraint for assignment from unique_ptr: + template + using _UniqAssignable = _UniqCompatible<_Yp, _Del, __shared_ptr&>; + + public: + +#if __cplusplus > 201402L + using weak_type = __weak_ptr<_Tp, _Lp>; +#endif + + constexpr __shared_ptr() noexcept + : _M_ptr(0), _M_refcount() + { } + + template> + explicit + __shared_ptr(_Yp* __p) + : _M_ptr(__p), _M_refcount(__p, typename is_array<_Tp>::type()) + { + static_assert( !is_void<_Yp>::value, "incomplete type" ); + static_assert( sizeof(_Yp) > 0, "incomplete type" ); + _M_enable_shared_from_this_with(__p); + } + + template> + __shared_ptr(_Yp* __p, _Deleter __d) + : _M_ptr(__p), _M_refcount(__p, std::move(__d)) + { + static_assert(__is_invocable<_Deleter&, _Yp*&>::value, + "deleter expression d(p) is well-formed"); + _M_enable_shared_from_this_with(__p); + } + + template> + __shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) + : _M_ptr(__p), _M_refcount(__p, std::move(__d), std::move(__a)) + { + static_assert(__is_invocable<_Deleter&, _Yp*&>::value, + "deleter expression d(p) is well-formed"); + _M_enable_shared_from_this_with(__p); + } + + template + __shared_ptr(nullptr_t __p, _Deleter __d) + : _M_ptr(0), _M_refcount(__p, std::move(__d)) + { } + + template + __shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) + : _M_ptr(0), _M_refcount(__p, std::move(__d), std::move(__a)) + { } + + // Aliasing constructor + template + __shared_ptr(const __shared_ptr<_Yp, _Lp>& __r, + element_type* __p) noexcept + : _M_ptr(__p), _M_refcount(__r._M_refcount) // never throws + { } + + // Aliasing constructor + template + __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r, + element_type* __p) noexcept + : _M_ptr(__p), _M_refcount() + { + _M_refcount._M_swap(__r._M_refcount); + __r._M_ptr = nullptr; + } + + __shared_ptr(const __shared_ptr&) noexcept = default; + __shared_ptr& operator=(const __shared_ptr&) noexcept = default; + ~__shared_ptr() = default; + + template> + __shared_ptr(const __shared_ptr<_Yp, _Lp>& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) + { } + + __shared_ptr(__shared_ptr&& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount() + { + _M_refcount._M_swap(__r._M_refcount); + __r._M_ptr = nullptr; + } + + template> + __shared_ptr(__shared_ptr<_Yp, _Lp>&& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount() + { + _M_refcount._M_swap(__r._M_refcount); + __r._M_ptr = nullptr; + } + + template> + explicit __shared_ptr(const __weak_ptr<_Yp, _Lp>& __r) + : _M_refcount(__r._M_refcount) // may throw + { + // It is now safe to copy __r._M_ptr, as + // _M_refcount(__r._M_refcount) did not throw. + _M_ptr = __r._M_ptr; + } + + // If an exception is thrown this constructor has no effect. + template> + __shared_ptr(unique_ptr<_Yp, _Del>&& __r) + : _M_ptr(__r.get()), _M_refcount() + { + auto __raw = __to_address(__r.get()); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + _M_enable_shared_from_this_with(__raw); + } + +#if __cplusplus <= 201402L && _GLIBCXX_USE_DEPRECATED + protected: + // If an exception is thrown this constructor has no effect. + template>, is_array<_Tp1>, + is_convertible::pointer, _Tp*> + >::value, bool>::type = true> + __shared_ptr(unique_ptr<_Tp1, _Del>&& __r, __sp_array_delete) + : _M_ptr(__r.get()), _M_refcount() + { + auto __raw = __to_address(__r.get()); + _M_refcount = __shared_count<_Lp>(std::move(__r)); + _M_enable_shared_from_this_with(__raw); + } + public: +#endif + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + // Postcondition: use_count() == 1 and __r.get() == 0 + template> + __shared_ptr(auto_ptr<_Yp>&& __r); +#pragma GCC diagnostic pop +#endif + + constexpr __shared_ptr(nullptr_t) noexcept : __shared_ptr() { } + + template + _Assignable<_Yp> + operator=(const __shared_ptr<_Yp, _Lp>& __r) noexcept + { + _M_ptr = __r._M_ptr; + _M_refcount = __r._M_refcount; // __shared_count::op= doesn't throw + return *this; + } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template + _Assignable<_Yp> + operator=(auto_ptr<_Yp>&& __r) + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } +#pragma GCC diagnostic pop +#endif + + __shared_ptr& + operator=(__shared_ptr&& __r) noexcept + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } + + template + _Assignable<_Yp> + operator=(__shared_ptr<_Yp, _Lp>&& __r) noexcept + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } + + template + _UniqAssignable<_Yp, _Del> + operator=(unique_ptr<_Yp, _Del>&& __r) + { + __shared_ptr(std::move(__r)).swap(*this); + return *this; + } + + void + reset() noexcept + { __shared_ptr().swap(*this); } + + template + _SafeConv<_Yp> + reset(_Yp* __p) // _Yp must be complete. + { + // Catch self-reset errors. + __glibcxx_assert(__p == nullptr || __p != _M_ptr); + __shared_ptr(__p).swap(*this); + } + + template + _SafeConv<_Yp> + reset(_Yp* __p, _Deleter __d) + { __shared_ptr(__p, std::move(__d)).swap(*this); } + + template + _SafeConv<_Yp> + reset(_Yp* __p, _Deleter __d, _Alloc __a) + { __shared_ptr(__p, std::move(__d), std::move(__a)).swap(*this); } + + /// Return the stored pointer. + element_type* + get() const noexcept + { return _M_ptr; } + + /// Return true if the stored pointer is not null. + explicit operator bool() const noexcept + { return _M_ptr != nullptr; } + + /// Return true if use_count() == 1. + bool + unique() const noexcept + { return _M_refcount._M_unique(); } + + /// If *this owns a pointer, return the number of owners, otherwise zero. + long + use_count() const noexcept + { return _M_refcount._M_get_use_count(); } + + /// Exchange both the owned pointer and the stored pointer. + void + swap(__shared_ptr<_Tp, _Lp>& __other) noexcept + { + std::swap(_M_ptr, __other._M_ptr); + _M_refcount._M_swap(__other._M_refcount); + } + + /** @brief Define an ordering based on ownership. + * + * This function defines a strict weak ordering between two shared_ptr + * or weak_ptr objects, such that one object is less than the other + * unless they share ownership of the same pointer, or are both empty. + * @{ + */ + template + bool + owner_before(__shared_ptr<_Tp1, _Lp> const& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + + template + bool + owner_before(__weak_ptr<_Tp1, _Lp> const& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + /// @} + + protected: + // This constructor is non-standard, it is used by allocate_shared. + template + __shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) + : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...) + { _M_enable_shared_from_this_with(_M_ptr); } + + template + friend __shared_ptr<_Tp1, _Lp1> + __allocate_shared(const _Alloc& __a, _Args&&... __args); + + // This constructor is used by __weak_ptr::lock() and + // shared_ptr::shared_ptr(const weak_ptr&, std::nothrow_t). + __shared_ptr(const __weak_ptr<_Tp, _Lp>& __r, std::nothrow_t) noexcept + : _M_refcount(__r._M_refcount, std::nothrow) + { + _M_ptr = _M_refcount._M_get_use_count() ? __r._M_ptr : nullptr; + } + + friend class __weak_ptr<_Tp, _Lp>; + + private: + + template + using __esft_base_t = decltype(__enable_shared_from_this_base( + std::declval&>(), + std::declval<_Yp*>())); + + // Detect an accessible and unambiguous enable_shared_from_this base. + template + struct __has_esft_base + : false_type { }; + + template + struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>> + : __not_> { }; // No enable shared_from_this for arrays + + template::type> + typename enable_if<__has_esft_base<_Yp2>::value>::type + _M_enable_shared_from_this_with(_Yp* __p) noexcept + { + if (auto __base = __enable_shared_from_this_base(_M_refcount, __p)) + __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount); + } + + template::type> + typename enable_if::value>::type + _M_enable_shared_from_this_with(_Yp*) noexcept + { } + + void* + _M_get_deleter(const std::type_info& __ti) const noexcept + { return _M_refcount._M_get_deleter(__ti); } + + template friend class __shared_ptr; + template friend class __weak_ptr; + + template + friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept; + + template + friend _Del* get_deleter(const shared_ptr<_Tp1>&) noexcept; + + element_type* _M_ptr; // Contained pointer. + __shared_count<_Lp> _M_refcount; // Reference counter. + }; + + + // 20.7.2.2.7 shared_ptr comparisons + template + inline bool + operator==(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return __a.get() == __b.get(); } + + template + inline bool + operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return !__a; } + +#ifdef __cpp_lib_three_way_comparison + template + inline strong_ordering + operator<=>(const __shared_ptr<_Tp, _Lp>& __a, + const __shared_ptr<_Up, _Lp>& __b) noexcept + { return compare_three_way()(__a.get(), __b.get()); } + + template + inline strong_ordering + operator<=>(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { + using pointer = typename __shared_ptr<_Tp, _Lp>::element_type*; + return compare_three_way()(__a.get(), static_cast(nullptr)); + } +#else + template + inline bool + operator==(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return !__a; } + + template + inline bool + operator!=(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return __a.get() != __b.get(); } + + template + inline bool + operator!=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return (bool)__a; } + + template + inline bool + operator!=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return (bool)__a; } + + template + inline bool + operator<(const __shared_ptr<_Tp, _Lp>& __a, + const __shared_ptr<_Up, _Lp>& __b) noexcept + { + using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; + using _Up_elt = typename __shared_ptr<_Up, _Lp>::element_type; + using _Vp = typename common_type<_Tp_elt*, _Up_elt*>::type; + return less<_Vp>()(__a.get(), __b.get()); + } + + template + inline bool + operator<(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { + using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; + return less<_Tp_elt*>()(__a.get(), nullptr); + } + + template + inline bool + operator<(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { + using _Tp_elt = typename __shared_ptr<_Tp, _Lp>::element_type; + return less<_Tp_elt*>()(nullptr, __a.get()); + } + + template + inline bool + operator<=(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return !(__b < __a); } + + template + inline bool + operator<=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return !(nullptr < __a); } + + template + inline bool + operator<=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return !(__a < nullptr); } + + template + inline bool + operator>(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return (__b < __a); } + + template + inline bool + operator>(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return nullptr < __a; } + + template + inline bool + operator>(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return __a < nullptr; } + + template + inline bool + operator>=(const __shared_ptr<_Tp1, _Lp>& __a, + const __shared_ptr<_Tp2, _Lp>& __b) noexcept + { return !(__a < __b); } + + template + inline bool + operator>=(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept + { return !(__a < nullptr); } + + template + inline bool + operator>=(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept + { return !(nullptr < __a); } +#endif // three-way comparison + + // 20.7.2.2.8 shared_ptr specialized algorithms. + template + inline void + swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b) noexcept + { __a.swap(__b); } + + // 20.7.2.2.9 shared_ptr casts + + // The seemingly equivalent code: + // shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get())) + // will eventually result in undefined behaviour, attempting to + // delete the same object twice. + /// static_pointer_cast + template + inline __shared_ptr<_Tp, _Lp> + static_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + return _Sp(__r, static_cast(__r.get())); + } + + // The seemingly equivalent code: + // shared_ptr<_Tp, _Lp>(const_cast<_Tp*>(__r.get())) + // will eventually result in undefined behaviour, attempting to + // delete the same object twice. + /// const_pointer_cast + template + inline __shared_ptr<_Tp, _Lp> + const_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + return _Sp(__r, const_cast(__r.get())); + } + + // The seemingly equivalent code: + // shared_ptr<_Tp, _Lp>(dynamic_cast<_Tp*>(__r.get())) + // will eventually result in undefined behaviour, attempting to + // delete the same object twice. + /// dynamic_pointer_cast + template + inline __shared_ptr<_Tp, _Lp> + dynamic_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + if (auto* __p = dynamic_cast(__r.get())) + return _Sp(__r, __p); + return _Sp(); + } + +#if __cplusplus > 201402L + template + inline __shared_ptr<_Tp, _Lp> + reinterpret_pointer_cast(const __shared_ptr<_Tp1, _Lp>& __r) noexcept + { + using _Sp = __shared_ptr<_Tp, _Lp>; + return _Sp(__r, reinterpret_cast(__r.get())); + } +#endif + + template + class __weak_ptr + { + template + using _Compatible = typename + enable_if<__sp_compatible_with<_Yp*, _Tp*>::value, _Res>::type; + + // Constraint for assignment from shared_ptr and weak_ptr: + template + using _Assignable = _Compatible<_Yp, __weak_ptr&>; + + public: + using element_type = typename remove_extent<_Tp>::type; + + constexpr __weak_ptr() noexcept + : _M_ptr(nullptr), _M_refcount() + { } + + __weak_ptr(const __weak_ptr&) noexcept = default; + + ~__weak_ptr() = default; + + // The "obvious" converting constructor implementation: + // + // template + // __weak_ptr(const __weak_ptr<_Tp1, _Lp>& __r) + // : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) // never throws + // { } + // + // has a serious problem. + // + // __r._M_ptr may already have been invalidated. The _M_ptr(__r._M_ptr) + // conversion may require access to *__r._M_ptr (virtual inheritance). + // + // It is not possible to avoid spurious access violations since + // in multithreaded programs __r._M_ptr may be invalidated at any point. + template> + __weak_ptr(const __weak_ptr<_Yp, _Lp>& __r) noexcept + : _M_refcount(__r._M_refcount) + { _M_ptr = __r.lock().get(); } + + template> + __weak_ptr(const __shared_ptr<_Yp, _Lp>& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount) + { } + + __weak_ptr(__weak_ptr&& __r) noexcept + : _M_ptr(__r._M_ptr), _M_refcount(std::move(__r._M_refcount)) + { __r._M_ptr = nullptr; } + + template> + __weak_ptr(__weak_ptr<_Yp, _Lp>&& __r) noexcept + : _M_ptr(__r.lock().get()), _M_refcount(std::move(__r._M_refcount)) + { __r._M_ptr = nullptr; } + + __weak_ptr& + operator=(const __weak_ptr& __r) noexcept = default; + + template + _Assignable<_Yp> + operator=(const __weak_ptr<_Yp, _Lp>& __r) noexcept + { + _M_ptr = __r.lock().get(); + _M_refcount = __r._M_refcount; + return *this; + } + + template + _Assignable<_Yp> + operator=(const __shared_ptr<_Yp, _Lp>& __r) noexcept + { + _M_ptr = __r._M_ptr; + _M_refcount = __r._M_refcount; + return *this; + } + + __weak_ptr& + operator=(__weak_ptr&& __r) noexcept + { + _M_ptr = __r._M_ptr; + _M_refcount = std::move(__r._M_refcount); + __r._M_ptr = nullptr; + return *this; + } + + template + _Assignable<_Yp> + operator=(__weak_ptr<_Yp, _Lp>&& __r) noexcept + { + _M_ptr = __r.lock().get(); + _M_refcount = std::move(__r._M_refcount); + __r._M_ptr = nullptr; + return *this; + } + + __shared_ptr<_Tp, _Lp> + lock() const noexcept + { return __shared_ptr(*this, std::nothrow); } + + long + use_count() const noexcept + { return _M_refcount._M_get_use_count(); } + + bool + expired() const noexcept + { return _M_refcount._M_get_use_count() == 0; } + + template + bool + owner_before(const __shared_ptr<_Tp1, _Lp>& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + + template + bool + owner_before(const __weak_ptr<_Tp1, _Lp>& __rhs) const noexcept + { return _M_refcount._M_less(__rhs._M_refcount); } + + void + reset() noexcept + { __weak_ptr().swap(*this); } + + void + swap(__weak_ptr& __s) noexcept + { + std::swap(_M_ptr, __s._M_ptr); + _M_refcount._M_swap(__s._M_refcount); + } + + private: + // Used by __enable_shared_from_this. + void + _M_assign(_Tp* __ptr, const __shared_count<_Lp>& __refcount) noexcept + { + if (use_count() == 0) + { + _M_ptr = __ptr; + _M_refcount = __refcount; + } + } + + template friend class __shared_ptr; + template friend class __weak_ptr; + friend class __enable_shared_from_this<_Tp, _Lp>; + friend class enable_shared_from_this<_Tp>; + + element_type* _M_ptr; // Contained pointer. + __weak_count<_Lp> _M_refcount; // Reference counter. + }; + + // 20.7.2.3.6 weak_ptr specialized algorithms. + template + inline void + swap(__weak_ptr<_Tp, _Lp>& __a, __weak_ptr<_Tp, _Lp>& __b) noexcept + { __a.swap(__b); } + + template + struct _Sp_owner_less : public binary_function<_Tp, _Tp, bool> + { + bool + operator()(const _Tp& __lhs, const _Tp& __rhs) const noexcept + { return __lhs.owner_before(__rhs); } + + bool + operator()(const _Tp& __lhs, const _Tp1& __rhs) const noexcept + { return __lhs.owner_before(__rhs); } + + bool + operator()(const _Tp1& __lhs, const _Tp& __rhs) const noexcept + { return __lhs.owner_before(__rhs); } + }; + + template<> + struct _Sp_owner_less + { + template + auto + operator()(const _Tp& __lhs, const _Up& __rhs) const noexcept + -> decltype(__lhs.owner_before(__rhs)) + { return __lhs.owner_before(__rhs); } + + using is_transparent = void; + }; + + template + struct owner_less<__shared_ptr<_Tp, _Lp>> + : public _Sp_owner_less<__shared_ptr<_Tp, _Lp>, __weak_ptr<_Tp, _Lp>> + { }; + + template + struct owner_less<__weak_ptr<_Tp, _Lp>> + : public _Sp_owner_less<__weak_ptr<_Tp, _Lp>, __shared_ptr<_Tp, _Lp>> + { }; + + + template + class __enable_shared_from_this + { + protected: + constexpr __enable_shared_from_this() noexcept { } + + __enable_shared_from_this(const __enable_shared_from_this&) noexcept { } + + __enable_shared_from_this& + operator=(const __enable_shared_from_this&) noexcept + { return *this; } + + ~__enable_shared_from_this() { } + + public: + __shared_ptr<_Tp, _Lp> + shared_from_this() + { return __shared_ptr<_Tp, _Lp>(this->_M_weak_this); } + + __shared_ptr + shared_from_this() const + { return __shared_ptr(this->_M_weak_this); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + __weak_ptr<_Tp, _Lp> + weak_from_this() noexcept + { return this->_M_weak_this; } + + __weak_ptr + weak_from_this() const noexcept + { return this->_M_weak_this; } +#endif + + private: + template + void + _M_weak_assign(_Tp1* __p, const __shared_count<_Lp>& __n) const noexcept + { _M_weak_this._M_assign(__p, __n); } + + friend const __enable_shared_from_this* + __enable_shared_from_this_base(const __shared_count<_Lp>&, + const __enable_shared_from_this* __p) + { return __p; } + + template + friend class __shared_ptr; + + mutable __weak_ptr<_Tp, _Lp> _M_weak_this; + }; + + template + inline __shared_ptr<_Tp, _Lp> + __allocate_shared(const _Alloc& __a, _Args&&... __args) + { + static_assert(!is_array<_Tp>::value, "make_shared not supported"); + + return __shared_ptr<_Tp, _Lp>(_Sp_alloc_shared_tag<_Alloc>{__a}, + std::forward<_Args>(__args)...); + } + + template + inline __shared_ptr<_Tp, _Lp> + __make_shared(_Args&&... __args) + { + typedef typename std::remove_const<_Tp>::type _Tp_nc; + return std::__allocate_shared<_Tp, _Lp>(std::allocator<_Tp_nc>(), + std::forward<_Args>(__args)...); + } + + /// std::hash specialization for __shared_ptr. + template + struct hash<__shared_ptr<_Tp, _Lp>> + : public __hash_base> + { + size_t + operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept + { + return hash::element_type*>()( + __s.get()); + } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _SHARED_PTR_BASE_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/slice_array.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/slice_array.h new file mode 100755 index 0000000..bdced19 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/slice_array.h @@ -0,0 +1,284 @@ +// The template and inlines for the -*- C++ -*- slice_array class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/slice_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _SLICE_ARRAY_H +#define _SLICE_ARRAY_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup numeric_arrays + * @{ + */ + + /** + * @brief Class defining one-dimensional subset of an array. + * + * The slice class represents a one-dimensional subset of an array, + * specified by three parameters: start offset, size, and stride. The + * start offset is the index of the first element of the array that is part + * of the subset. The size is the total number of elements in the subset. + * Stride is the distance between each successive array element to include + * in the subset. + * + * For example, with an array of size 10, and a slice with offset 1, size 3 + * and stride 2, the subset consists of array elements 1, 3, and 5. + */ + class slice + { + public: + /// Construct an empty slice. + slice(); + + /** + * @brief Construct a slice. + * + * @param __o Offset in array of first element. + * @param __d Number of elements in slice. + * @param __s Stride between array elements. + */ + slice(size_t __o, size_t __d, size_t __s); + + /// Return array offset of first slice element. + size_t start() const; + /// Return size of slice. + size_t size() const; + /// Return array stride of slice. + size_t stride() const; + +#if __cpp_impl_three_way_comparison >= 201907L + /// Equality comparison + friend bool operator==(const slice&, const slice&) = default; +#endif + + private: + size_t _M_off; // offset + size_t _M_sz; // size + size_t _M_st; // stride unit + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 543. valarray slice default constructor + inline + slice::slice() + : _M_off(0), _M_sz(0), _M_st(0) {} + + inline + slice::slice(size_t __o, size_t __d, size_t __s) + : _M_off(__o), _M_sz(__d), _M_st(__s) {} + + inline size_t + slice::start() const + { return _M_off; } + + inline size_t + slice::size() const + { return _M_sz; } + + inline size_t + slice::stride() const + { return _M_st; } + + /** + * @brief Reference to one-dimensional subset of an array. + * + * A slice_array is a reference to the actual elements of an array + * specified by a slice. The way to get a slice_array is to call + * operator[](slice) on a valarray. The returned slice_array then permits + * carrying operations out on the referenced subset of elements in the + * original valarray. For example, operator+=(valarray) will add values + * to the subset of elements in the underlying valarray this slice_array + * refers to. + * + * @param Tp Element type. + */ + template + class slice_array + { + public: + typedef _Tp value_type; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 253. valarray helper functions are almost entirely useless + + /// Copy constructor. Both slices refer to the same underlying array. + slice_array(const slice_array&); + + /// Assignment operator. Assigns slice elements to corresponding + /// elements of @a a. + slice_array& operator=(const slice_array&); + + /// Assign slice elements to corresponding elements of @a v. + void operator=(const valarray<_Tp>&) const; + /// Multiply slice elements by corresponding elements of @a v. + void operator*=(const valarray<_Tp>&) const; + /// Divide slice elements by corresponding elements of @a v. + void operator/=(const valarray<_Tp>&) const; + /// Modulo slice elements by corresponding elements of @a v. + void operator%=(const valarray<_Tp>&) const; + /// Add corresponding elements of @a v to slice elements. + void operator+=(const valarray<_Tp>&) const; + /// Subtract corresponding elements of @a v from slice elements. + void operator-=(const valarray<_Tp>&) const; + /// Logical xor slice elements with corresponding elements of @a v. + void operator^=(const valarray<_Tp>&) const; + /// Logical and slice elements with corresponding elements of @a v. + void operator&=(const valarray<_Tp>&) const; + /// Logical or slice elements with corresponding elements of @a v. + void operator|=(const valarray<_Tp>&) const; + /// Left shift slice elements by corresponding elements of @a v. + void operator<<=(const valarray<_Tp>&) const; + /// Right shift slice elements by corresponding elements of @a v. + void operator>>=(const valarray<_Tp>&) const; + /// Assign all slice elements to @a t. + void operator=(const _Tp &) const; + // ~slice_array (); + + template + void operator=(const _Expr<_Dom, _Tp>&) const; + template + void operator*=(const _Expr<_Dom, _Tp>&) const; + template + void operator/=(const _Expr<_Dom, _Tp>&) const; + template + void operator%=(const _Expr<_Dom, _Tp>&) const; + template + void operator+=(const _Expr<_Dom, _Tp>&) const; + template + void operator-=(const _Expr<_Dom, _Tp>&) const; + template + void operator^=(const _Expr<_Dom, _Tp>&) const; + template + void operator&=(const _Expr<_Dom, _Tp>&) const; + template + void operator|=(const _Expr<_Dom, _Tp>&) const; + template + void operator<<=(const _Expr<_Dom, _Tp>&) const; + template + void operator>>=(const _Expr<_Dom, _Tp>&) const; + + private: + friend class valarray<_Tp>; + slice_array(_Array<_Tp>, const slice&); + + const size_t _M_sz; + const size_t _M_stride; + const _Array<_Tp> _M_array; + +#if __cplusplus < 201103L + // not implemented + slice_array(); +#else + public: + slice_array() = delete; +#endif + }; + + template + inline + slice_array<_Tp>::slice_array(_Array<_Tp> __a, const slice& __s) + : _M_sz(__s.size()), _M_stride(__s.stride()), + _M_array(__a.begin() + __s.start()) {} + + template + inline + slice_array<_Tp>::slice_array(const slice_array<_Tp>& __a) + : _M_sz(__a._M_sz), _M_stride(__a._M_stride), _M_array(__a._M_array) {} + + // template + // inline slice_array<_Tp>::~slice_array () {} + + template + inline slice_array<_Tp>& + slice_array<_Tp>::operator=(const slice_array<_Tp>& __a) + { + std::__valarray_copy(__a._M_array, __a._M_sz, __a._M_stride, + _M_array, _M_stride); + return *this; + } + + template + inline void + slice_array<_Tp>::operator=(const _Tp& __t) const + { std::__valarray_fill(_M_array, _M_sz, _M_stride, __t); } + + template + inline void + slice_array<_Tp>::operator=(const valarray<_Tp>& __v) const + { std::__valarray_copy(_Array<_Tp>(__v), _M_array, _M_sz, _M_stride); } + + template + template + inline void + slice_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const + { std::__valarray_copy(__e, _M_sz, _M_array, _M_stride); } + +#undef _DEFINE_VALARRAY_OPERATOR +#define _DEFINE_VALARRAY_OPERATOR(_Op,_Name) \ + template \ + inline void \ + slice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ + { \ + _Array_augmented_##_Name(_M_array, _M_sz, _M_stride, _Array<_Tp>(__v));\ + } \ + \ + template \ + template \ + inline void \ + slice_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\ + { \ + _Array_augmented_##_Name(_M_array, _M_stride, __e, _M_sz); \ + } + + +_DEFINE_VALARRAY_OPERATOR(*, __multiplies) +_DEFINE_VALARRAY_OPERATOR(/, __divides) +_DEFINE_VALARRAY_OPERATOR(%, __modulus) +_DEFINE_VALARRAY_OPERATOR(+, __plus) +_DEFINE_VALARRAY_OPERATOR(-, __minus) +_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) +_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) +_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) +_DEFINE_VALARRAY_OPERATOR(<<, __shift_left) +_DEFINE_VALARRAY_OPERATOR(>>, __shift_right) + +#undef _DEFINE_VALARRAY_OPERATOR + + /// @} group numeric_arrays + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _SLICE_ARRAY_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/specfun.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/specfun.h new file mode 100755 index 0000000..513ec3c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/specfun.h @@ -0,0 +1,1390 @@ +// Mathematical Special Functions for -*- C++ -*- + +// Copyright (C) 2006-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/specfun.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cmath} + */ + +#ifndef _GLIBCXX_BITS_SPECFUN_H +#define _GLIBCXX_BITS_SPECFUN_H 1 + +#pragma GCC visibility push(default) + +#include + +#define __STDCPP_MATH_SPEC_FUNCS__ 201003L + +#define __cpp_lib_math_special_functions 201603L + +#if __cplusplus <= 201403L && __STDCPP_WANT_MATH_SPEC_FUNCS__ == 0 +# error include and define __STDCPP_WANT_MATH_SPEC_FUNCS__ +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup mathsf Mathematical Special Functions + * @ingroup numerics + * + * @section mathsf_desc Mathematical Special Functions + * + * A collection of advanced mathematical special functions, + * defined by ISO/IEC IS 29124 and then added to ISO C++ 2017. + * + * + * @subsection mathsf_intro Introduction and History + * The first significant library upgrade on the road to C++2011, + * + * TR1, included a set of 23 mathematical functions that significantly + * extended the standard transcendental functions inherited from C and declared + * in @. + * + * Although most components from TR1 were eventually adopted for C++11 these + * math functions were left behind out of concern for implementability. + * The math functions were published as a separate international standard + * + * IS 29124 - Extensions to the C++ Library to Support Mathematical Special + * Functions. + * + * For C++17 these functions were incorporated into the main standard. + * + * @subsection mathsf_contents Contents + * The following functions are implemented in namespace @c std: + * - @ref assoc_laguerre "assoc_laguerre - Associated Laguerre functions" + * - @ref assoc_legendre "assoc_legendre - Associated Legendre functions" + * - @ref beta "beta - Beta functions" + * - @ref comp_ellint_1 "comp_ellint_1 - Complete elliptic functions of the first kind" + * - @ref comp_ellint_2 "comp_ellint_2 - Complete elliptic functions of the second kind" + * - @ref comp_ellint_3 "comp_ellint_3 - Complete elliptic functions of the third kind" + * - @ref cyl_bessel_i "cyl_bessel_i - Regular modified cylindrical Bessel functions" + * - @ref cyl_bessel_j "cyl_bessel_j - Cylindrical Bessel functions of the first kind" + * - @ref cyl_bessel_k "cyl_bessel_k - Irregular modified cylindrical Bessel functions" + * - @ref cyl_neumann "cyl_neumann - Cylindrical Neumann functions or Cylindrical Bessel functions of the second kind" + * - @ref ellint_1 "ellint_1 - Incomplete elliptic functions of the first kind" + * - @ref ellint_2 "ellint_2 - Incomplete elliptic functions of the second kind" + * - @ref ellint_3 "ellint_3 - Incomplete elliptic functions of the third kind" + * - @ref expint "expint - The exponential integral" + * - @ref hermite "hermite - Hermite polynomials" + * - @ref laguerre "laguerre - Laguerre functions" + * - @ref legendre "legendre - Legendre polynomials" + * - @ref riemann_zeta "riemann_zeta - The Riemann zeta function" + * - @ref sph_bessel "sph_bessel - Spherical Bessel functions" + * - @ref sph_legendre "sph_legendre - Spherical Legendre functions" + * - @ref sph_neumann "sph_neumann - Spherical Neumann functions" + * + * The hypergeometric functions were stricken from the TR29124 and C++17 + * versions of this math library because of implementation concerns. + * However, since they were in the TR1 version and since they are popular + * we kept them as an extension in namespace @c __gnu_cxx: + * - @ref __gnu_cxx::conf_hyperg "conf_hyperg - Confluent hypergeometric functions" + * - @ref __gnu_cxx::hyperg "hyperg - Hypergeometric functions" + * + * + * + * @subsection mathsf_promotion Argument Promotion + * The arguments suppled to the non-suffixed functions will be promoted + * according to the following rules: + * 1. If any argument intended to be floating point is given an integral value + * That integral value is promoted to double. + * 2. All floating point arguments are promoted up to the largest floating + * point precision among them. + * + * @subsection mathsf_NaN NaN Arguments + * If any of the floating point arguments supplied to these functions is + * invalid or NaN (std::numeric_limits::quiet_NaN), + * the value NaN is returned. + * + * @subsection mathsf_impl Implementation + * + * We strive to implement the underlying math with type generic algorithms + * to the greatest extent possible. In practice, the functions are thin + * wrappers that dispatch to function templates. Type dependence is + * controlled with std::numeric_limits and functions thereof. + * + * We don't promote @c float to @c double or @c double to long double + * reflexively. The goal is for @c float functions to operate more quickly, + * at the cost of @c float accuracy and possibly a smaller domain of validity. + * Similaryly, long double should give you more dynamic range + * and slightly more pecision than @c double on many systems. + * + * @subsection mathsf_testing Testing + * + * These functions have been tested against equivalent implementations + * from the + * Gnu Scientific Library, GSL and + * Boost + * and the ratio + * @f[ + * \frac{|f - f_{test}|}{|f_{test}|} + * @f] + * is generally found to be within 10-15 for 64-bit double on + * linux-x86_64 systems over most of the ranges of validity. + * + * @todo Provide accuracy comparisons on a per-function basis for a small + * number of targets. + * + * @subsection mathsf_bibliography General Bibliography + * + * @see Abramowitz and Stegun: Handbook of Mathematical Functions, + * with Formulas, Graphs, and Mathematical Tables + * Edited by Milton Abramowitz and Irene A. Stegun, + * National Bureau of Standards Applied Mathematics Series - 55 + * Issued June 1964, Tenth Printing, December 1972, with corrections + * Electronic versions of A&S abound including both pdf and navigable html. + * @see for example http://people.math.sfu.ca/~cbm/aands/ + * + * @see The old A&S has been redone as the + * NIST Digital Library of Mathematical Functions: http://dlmf.nist.gov/ + * This version is far more navigable and includes more recent work. + * + * @see An Atlas of Functions: with Equator, the Atlas Function Calculator + * 2nd Edition, by Oldham, Keith B., Myland, Jan, Spanier, Jerome + * + * @see Asymptotics and Special Functions by Frank W. J. Olver, + * Academic Press, 1974 + * + * @see Numerical Recipes in C, The Art of Scientific Computing, + * by William H. Press, Second Ed., Saul A. Teukolsky, + * William T. Vetterling, and Brian P. Flannery, + * Cambridge University Press, 1992 + * + * @see The Special Functions and Their Approximations: Volumes 1 and 2, + * by Yudell L. Luke, Academic Press, 1969 + * + * @{ + */ + + // Associated Laguerre polynomials + + /** + * Return the associated Laguerre polynomial of order @c n, + * degree @c m: @f$ L_n^m(x) @f$ for @c float argument. + * + * @see assoc_laguerre for more details. + */ + inline float + assoc_laguerref(unsigned int __n, unsigned int __m, float __x) + { return __detail::__assoc_laguerre(__n, __m, __x); } + + /** + * Return the associated Laguerre polynomial of order @c n, + * degree @c m: @f$ L_n^m(x) @f$. + * + * @see assoc_laguerre for more details. + */ + inline long double + assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x) + { return __detail::__assoc_laguerre(__n, __m, __x); } + + /** + * Return the associated Laguerre polynomial of nonnegative order @c n, + * nonnegative degree @c m and real argument @c x: @f$ L_n^m(x) @f$. + * + * The associated Laguerre function of real degree @f$ \alpha @f$, + * @f$ L_n^\alpha(x) @f$, is defined by + * @f[ + * L_n^\alpha(x) = \frac{(\alpha + 1)_n}{n!} + * {}_1F_1(-n; \alpha + 1; x) + * @f] + * where @f$ (\alpha)_n @f$ is the Pochhammer symbol and + * @f$ {}_1F_1(a; c; x) @f$ is the confluent hypergeometric function. + * + * The associated Laguerre polynomial is defined for integral + * degree @f$ \alpha = m @f$ by: + * @f[ + * L_n^m(x) = (-1)^m \frac{d^m}{dx^m} L_{n + m}(x) + * @f] + * where the Laguerre polynomial is defined by: + * @f[ + * L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x}) + * @f] + * and @f$ x >= 0 @f$. + * @see laguerre for details of the Laguerre function of degree @c n + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __n The order of the Laguerre function, __n >= 0. + * @param __m The degree of the Laguerre function, __m >= 0. + * @param __x The argument of the Laguerre function, __x >= 0. + * @throw std::domain_error if __x < 0. + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__assoc_laguerre<__type>(__n, __m, __x); + } + + // Associated Legendre functions + + /** + * Return the associated Legendre function of degree @c l and order @c m + * for @c float argument. + * + * @see assoc_legendre for more details. + */ + inline float + assoc_legendref(unsigned int __l, unsigned int __m, float __x) + { return __detail::__assoc_legendre_p(__l, __m, __x); } + + /** + * Return the associated Legendre function of degree @c l and order @c m. + * + * @see assoc_legendre for more details. + */ + inline long double + assoc_legendrel(unsigned int __l, unsigned int __m, long double __x) + { return __detail::__assoc_legendre_p(__l, __m, __x); } + + + /** + * Return the associated Legendre function of degree @c l and order @c m. + * + * The associated Legendre function is derived from the Legendre function + * @f$ P_l(x) @f$ by the Rodrigues formula: + * @f[ + * P_l^m(x) = (1 - x^2)^{m/2}\frac{d^m}{dx^m}P_l(x) + * @f] + * @see legendre for details of the Legendre function of degree @c l + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __l The degree __l >= 0. + * @param __m The order __m <= l. + * @param __x The argument, abs(__x) <= 1. + * @throw std::domain_error if abs(__x) > 1. + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__assoc_legendre_p<__type>(__l, __m, __x); + } + + // Beta functions + + /** + * Return the beta function, @f$ B(a,b) @f$, for @c float parameters @c a, @c b. + * + * @see beta for more details. + */ + inline float + betaf(float __a, float __b) + { return __detail::__beta(__a, __b); } + + /** + * Return the beta function, @f$B(a,b)@f$, for long double + * parameters @c a, @c b. + * + * @see beta for more details. + */ + inline long double + betal(long double __a, long double __b) + { return __detail::__beta(__a, __b); } + + /** + * Return the beta function, @f$B(a,b)@f$, for real parameters @c a, @c b. + * + * The beta function is defined by + * @f[ + * B(a,b) = \int_0^1 t^{a - 1} (1 - t)^{b - 1} dt + * = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)} + * @f] + * where @f$ a > 0 @f$ and @f$ b > 0 @f$ + * + * @tparam _Tpa The floating-point type of the parameter @c __a. + * @tparam _Tpb The floating-point type of the parameter @c __b. + * @param __a The first argument of the beta function, __a > 0 . + * @param __b The second argument of the beta function, __b > 0 . + * @throw std::domain_error if __a < 0 or __b < 0 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tpa, _Tpb>::__type + beta(_Tpa __a, _Tpb __b) + { + typedef typename __gnu_cxx::__promote_2<_Tpa, _Tpb>::__type __type; + return __detail::__beta<__type>(__a, __b); + } + + // Complete elliptic integrals of the first kind + + /** + * Return the complete elliptic integral of the first kind @f$ E(k) @f$ + * for @c float modulus @c k. + * + * @see comp_ellint_1 for details. + */ + inline float + comp_ellint_1f(float __k) + { return __detail::__comp_ellint_1(__k); } + + /** + * Return the complete elliptic integral of the first kind @f$ E(k) @f$ + * for long double modulus @c k. + * + * @see comp_ellint_1 for details. + */ + inline long double + comp_ellint_1l(long double __k) + { return __detail::__comp_ellint_1(__k); } + + /** + * Return the complete elliptic integral of the first kind + * @f$ K(k) @f$ for real modulus @c k. + * + * The complete elliptic integral of the first kind is defined as + * @f[ + * K(k) = F(k,\pi/2) = \int_0^{\pi/2}\frac{d\theta} + * {\sqrt{1 - k^2 sin^2\theta}} + * @f] + * where @f$ F(k,\phi) @f$ is the incomplete elliptic integral of the + * first kind and the modulus @f$ |k| <= 1 @f$. + * @see ellint_1 for details of the incomplete elliptic function + * of the first kind. + * + * @tparam _Tp The floating-point type of the modulus @c __k. + * @param __k The modulus, abs(__k) <= 1 + * @throw std::domain_error if abs(__k) > 1 . + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + comp_ellint_1(_Tp __k) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__comp_ellint_1<__type>(__k); + } + + // Complete elliptic integrals of the second kind + + /** + * Return the complete elliptic integral of the second kind @f$ E(k) @f$ + * for @c float modulus @c k. + * + * @see comp_ellint_2 for details. + */ + inline float + comp_ellint_2f(float __k) + { return __detail::__comp_ellint_2(__k); } + + /** + * Return the complete elliptic integral of the second kind @f$ E(k) @f$ + * for long double modulus @c k. + * + * @see comp_ellint_2 for details. + */ + inline long double + comp_ellint_2l(long double __k) + { return __detail::__comp_ellint_2(__k); } + + /** + * Return the complete elliptic integral of the second kind @f$ E(k) @f$ + * for real modulus @c k. + * + * The complete elliptic integral of the second kind is defined as + * @f[ + * E(k) = E(k,\pi/2) = \int_0^{\pi/2}\sqrt{1 - k^2 sin^2\theta} + * @f] + * where @f$ E(k,\phi) @f$ is the incomplete elliptic integral of the + * second kind and the modulus @f$ |k| <= 1 @f$. + * @see ellint_2 for details of the incomplete elliptic function + * of the second kind. + * + * @tparam _Tp The floating-point type of the modulus @c __k. + * @param __k The modulus, @c abs(__k) <= 1 + * @throw std::domain_error if @c abs(__k) > 1. + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + comp_ellint_2(_Tp __k) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__comp_ellint_2<__type>(__k); + } + + // Complete elliptic integrals of the third kind + + /** + * @brief Return the complete elliptic integral of the third kind + * @f$ \Pi(k,\nu) @f$ for @c float modulus @c k. + * + * @see comp_ellint_3 for details. + */ + inline float + comp_ellint_3f(float __k, float __nu) + { return __detail::__comp_ellint_3(__k, __nu); } + + /** + * @brief Return the complete elliptic integral of the third kind + * @f$ \Pi(k,\nu) @f$ for long double modulus @c k. + * + * @see comp_ellint_3 for details. + */ + inline long double + comp_ellint_3l(long double __k, long double __nu) + { return __detail::__comp_ellint_3(__k, __nu); } + + /** + * Return the complete elliptic integral of the third kind + * @f$ \Pi(k,\nu) = \Pi(k,\nu,\pi/2) @f$ for real modulus @c k. + * + * The complete elliptic integral of the third kind is defined as + * @f[ + * \Pi(k,\nu) = \Pi(k,\nu,\pi/2) = \int_0^{\pi/2} + * \frac{d\theta} + * {(1 - \nu \sin^2\theta)\sqrt{1 - k^2 \sin^2\theta}} + * @f] + * where @f$ \Pi(k,\nu,\phi) @f$ is the incomplete elliptic integral of the + * second kind and the modulus @f$ |k| <= 1 @f$. + * @see ellint_3 for details of the incomplete elliptic function + * of the third kind. + * + * @tparam _Tp The floating-point type of the modulus @c __k. + * @tparam _Tpn The floating-point type of the argument @c __nu. + * @param __k The modulus, @c abs(__k) <= 1 + * @param __nu The argument + * @throw std::domain_error if @c abs(__k) > 1. + */ + template + inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type + comp_ellint_3(_Tp __k, _Tpn __nu) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type; + return __detail::__comp_ellint_3<__type>(__k, __nu); + } + + // Regular modified cylindrical Bessel functions + + /** + * Return the regular modified Bessel function @f$ I_{\nu}(x) @f$ + * for @c float order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * @see cyl_bessel_i for setails. + */ + inline float + cyl_bessel_if(float __nu, float __x) + { return __detail::__cyl_bessel_i(__nu, __x); } + + /** + * Return the regular modified Bessel function @f$ I_{\nu}(x) @f$ + * for long double order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * @see cyl_bessel_i for setails. + */ + inline long double + cyl_bessel_il(long double __nu, long double __x) + { return __detail::__cyl_bessel_i(__nu, __x); } + + /** + * Return the regular modified Bessel function @f$ I_{\nu}(x) @f$ + * for real order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * The regular modified cylindrical Bessel function is: + * @f[ + * I_{\nu}(x) = i^{-\nu}J_\nu(ix) = \sum_{k=0}^{\infty} + * \frac{(x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)} + * @f] + * + * @tparam _Tpnu The floating-point type of the order @c __nu. + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __nu The order + * @param __x The argument, __x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_bessel_i(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_bessel_i<__type>(__nu, __x); + } + + // Cylindrical Bessel functions (of the first kind) + + /** + * Return the Bessel function of the first kind @f$ J_{\nu}(x) @f$ + * for @c float order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * @see cyl_bessel_j for setails. + */ + inline float + cyl_bessel_jf(float __nu, float __x) + { return __detail::__cyl_bessel_j(__nu, __x); } + + /** + * Return the Bessel function of the first kind @f$ J_{\nu}(x) @f$ + * for long double order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * @see cyl_bessel_j for setails. + */ + inline long double + cyl_bessel_jl(long double __nu, long double __x) + { return __detail::__cyl_bessel_j(__nu, __x); } + + /** + * Return the Bessel function @f$ J_{\nu}(x) @f$ of real order @f$ \nu @f$ + * and argument @f$ x >= 0 @f$. + * + * The cylindrical Bessel function is: + * @f[ + * J_{\nu}(x) = \sum_{k=0}^{\infty} + * \frac{(-1)^k (x/2)^{\nu + 2k}}{k!\Gamma(\nu+k+1)} + * @f] + * + * @tparam _Tpnu The floating-point type of the order @c __nu. + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __nu The order + * @param __x The argument, __x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_bessel_j(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_bessel_j<__type>(__nu, __x); + } + + // Irregular modified cylindrical Bessel functions + + /** + * Return the irregular modified Bessel function @f$ K_{\nu}(x) @f$ + * for @c float order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * @see cyl_bessel_k for setails. + */ + inline float + cyl_bessel_kf(float __nu, float __x) + { return __detail::__cyl_bessel_k(__nu, __x); } + + /** + * Return the irregular modified Bessel function @f$ K_{\nu}(x) @f$ + * for long double order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * @see cyl_bessel_k for setails. + */ + inline long double + cyl_bessel_kl(long double __nu, long double __x) + { return __detail::__cyl_bessel_k(__nu, __x); } + + /** + * Return the irregular modified Bessel function @f$ K_{\nu}(x) @f$ + * of real order @f$ \nu @f$ and argument @f$ x @f$. + * + * The irregular modified Bessel function is defined by: + * @f[ + * K_{\nu}(x) = \frac{\pi}{2} + * \frac{I_{-\nu}(x) - I_{\nu}(x)}{\sin \nu\pi} + * @f] + * where for integral @f$ \nu = n @f$ a limit is taken: + * @f$ lim_{\nu \to n} @f$. + * For negative argument we have simply: + * @f[ + * K_{-\nu}(x) = K_{\nu}(x) + * @f] + * + * @tparam _Tpnu The floating-point type of the order @c __nu. + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __nu The order + * @param __x The argument, __x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_bessel_k(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_bessel_k<__type>(__nu, __x); + } + + // Cylindrical Neumann functions + + /** + * Return the Neumann function @f$ N_{\nu}(x) @f$ + * of @c float order @f$ \nu @f$ and argument @f$ x @f$. + * + * @see cyl_neumann for setails. + */ + inline float + cyl_neumannf(float __nu, float __x) + { return __detail::__cyl_neumann_n(__nu, __x); } + + /** + * Return the Neumann function @f$ N_{\nu}(x) @f$ + * of long double order @f$ \nu @f$ and argument @f$ x @f$. + * + * @see cyl_neumann for setails. + */ + inline long double + cyl_neumannl(long double __nu, long double __x) + { return __detail::__cyl_neumann_n(__nu, __x); } + + /** + * Return the Neumann function @f$ N_{\nu}(x) @f$ + * of real order @f$ \nu @f$ and argument @f$ x >= 0 @f$. + * + * The Neumann function is defined by: + * @f[ + * N_{\nu}(x) = \frac{J_{\nu}(x) \cos \nu\pi - J_{-\nu}(x)} + * {\sin \nu\pi} + * @f] + * where @f$ x >= 0 @f$ and for integral order @f$ \nu = n @f$ + * a limit is taken: @f$ lim_{\nu \to n} @f$. + * + * @tparam _Tpnu The floating-point type of the order @c __nu. + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __nu The order + * @param __x The argument, __x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type + cyl_neumann(_Tpnu __nu, _Tp __x) + { + typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type; + return __detail::__cyl_neumann_n<__type>(__nu, __x); + } + + // Incomplete elliptic integrals of the first kind + + /** + * Return the incomplete elliptic integral of the first kind @f$ E(k,\phi) @f$ + * for @c float modulus @f$ k @f$ and angle @f$ \phi @f$. + * + * @see ellint_1 for details. + */ + inline float + ellint_1f(float __k, float __phi) + { return __detail::__ellint_1(__k, __phi); } + + /** + * Return the incomplete elliptic integral of the first kind @f$ E(k,\phi) @f$ + * for long double modulus @f$ k @f$ and angle @f$ \phi @f$. + * + * @see ellint_1 for details. + */ + inline long double + ellint_1l(long double __k, long double __phi) + { return __detail::__ellint_1(__k, __phi); } + + /** + * Return the incomplete elliptic integral of the first kind @f$ F(k,\phi) @f$ + * for @c real modulus @f$ k @f$ and angle @f$ \phi @f$. + * + * The incomplete elliptic integral of the first kind is defined as + * @f[ + * F(k,\phi) = \int_0^{\phi}\frac{d\theta} + * {\sqrt{1 - k^2 sin^2\theta}} + * @f] + * For @f$ \phi= \pi/2 @f$ this becomes the complete elliptic integral of + * the first kind, @f$ K(k) @f$. @see comp_ellint_1. + * + * @tparam _Tp The floating-point type of the modulus @c __k. + * @tparam _Tpp The floating-point type of the angle @c __phi. + * @param __k The modulus, abs(__k) <= 1 + * @param __phi The integral limit argument in radians + * @throw std::domain_error if abs(__k) > 1 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type + ellint_1(_Tp __k, _Tpp __phi) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type; + return __detail::__ellint_1<__type>(__k, __phi); + } + + // Incomplete elliptic integrals of the second kind + + /** + * @brief Return the incomplete elliptic integral of the second kind + * @f$ E(k,\phi) @f$ for @c float argument. + * + * @see ellint_2 for details. + */ + inline float + ellint_2f(float __k, float __phi) + { return __detail::__ellint_2(__k, __phi); } + + /** + * @brief Return the incomplete elliptic integral of the second kind + * @f$ E(k,\phi) @f$. + * + * @see ellint_2 for details. + */ + inline long double + ellint_2l(long double __k, long double __phi) + { return __detail::__ellint_2(__k, __phi); } + + /** + * Return the incomplete elliptic integral of the second kind + * @f$ E(k,\phi) @f$. + * + * The incomplete elliptic integral of the second kind is defined as + * @f[ + * E(k,\phi) = \int_0^{\phi} \sqrt{1 - k^2 sin^2\theta} + * @f] + * For @f$ \phi= \pi/2 @f$ this becomes the complete elliptic integral of + * the second kind, @f$ E(k) @f$. @see comp_ellint_2. + * + * @tparam _Tp The floating-point type of the modulus @c __k. + * @tparam _Tpp The floating-point type of the angle @c __phi. + * @param __k The modulus, abs(__k) <= 1 + * @param __phi The integral limit argument in radians + * @return The elliptic function of the second kind. + * @throw std::domain_error if abs(__k) > 1 . + */ + template + inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type + ellint_2(_Tp __k, _Tpp __phi) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type; + return __detail::__ellint_2<__type>(__k, __phi); + } + + // Incomplete elliptic integrals of the third kind + + /** + * @brief Return the incomplete elliptic integral of the third kind + * @f$ \Pi(k,\nu,\phi) @f$ for @c float argument. + * + * @see ellint_3 for details. + */ + inline float + ellint_3f(float __k, float __nu, float __phi) + { return __detail::__ellint_3(__k, __nu, __phi); } + + /** + * @brief Return the incomplete elliptic integral of the third kind + * @f$ \Pi(k,\nu,\phi) @f$. + * + * @see ellint_3 for details. + */ + inline long double + ellint_3l(long double __k, long double __nu, long double __phi) + { return __detail::__ellint_3(__k, __nu, __phi); } + + /** + * @brief Return the incomplete elliptic integral of the third kind + * @f$ \Pi(k,\nu,\phi) @f$. + * + * The incomplete elliptic integral of the third kind is defined by: + * @f[ + * \Pi(k,\nu,\phi) = \int_0^{\phi} + * \frac{d\theta} + * {(1 - \nu \sin^2\theta) + * \sqrt{1 - k^2 \sin^2\theta}} + * @f] + * For @f$ \phi= \pi/2 @f$ this becomes the complete elliptic integral of + * the third kind, @f$ \Pi(k,\nu) @f$. @see comp_ellint_3. + * + * @tparam _Tp The floating-point type of the modulus @c __k. + * @tparam _Tpn The floating-point type of the argument @c __nu. + * @tparam _Tpp The floating-point type of the angle @c __phi. + * @param __k The modulus, abs(__k) <= 1 + * @param __nu The second argument + * @param __phi The integral limit argument in radians + * @return The elliptic function of the third kind. + * @throw std::domain_error if abs(__k) > 1 . + */ + template + inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type + ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type; + return __detail::__ellint_3<__type>(__k, __nu, __phi); + } + + // Exponential integrals + + /** + * Return the exponential integral @f$ Ei(x) @f$ for @c float argument @c x. + * + * @see expint for details. + */ + inline float + expintf(float __x) + { return __detail::__expint(__x); } + + /** + * Return the exponential integral @f$ Ei(x) @f$ + * for long double argument @c x. + * + * @see expint for details. + */ + inline long double + expintl(long double __x) + { return __detail::__expint(__x); } + + /** + * Return the exponential integral @f$ Ei(x) @f$ for @c real argument @c x. + * + * The exponential integral is given by + * \f[ + * Ei(x) = -\int_{-x}^\infty \frac{e^t}{t} dt + * \f] + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __x The argument of the exponential integral function. + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + expint(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__expint<__type>(__x); + } + + // Hermite polynomials + + /** + * Return the Hermite polynomial @f$ H_n(x) @f$ of nonnegative order n + * and float argument @c x. + * + * @see hermite for details. + */ + inline float + hermitef(unsigned int __n, float __x) + { return __detail::__poly_hermite(__n, __x); } + + /** + * Return the Hermite polynomial @f$ H_n(x) @f$ of nonnegative order n + * and long double argument @c x. + * + * @see hermite for details. + */ + inline long double + hermitel(unsigned int __n, long double __x) + { return __detail::__poly_hermite(__n, __x); } + + /** + * Return the Hermite polynomial @f$ H_n(x) @f$ of order n + * and @c real argument @c x. + * + * The Hermite polynomial is defined by: + * @f[ + * H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2} + * @f] + * + * The Hermite polynomial obeys a reflection formula: + * @f[ + * H_n(-x) = (-1)^n H_n(x) + * @f] + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __n The order + * @param __x The argument + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + hermite(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__poly_hermite<__type>(__n, __x); + } + + // Laguerre polynomials + + /** + * Returns the Laguerre polynomial @f$ L_n(x) @f$ of nonnegative degree @c n + * and @c float argument @f$ x >= 0 @f$. + * + * @see laguerre for more details. + */ + inline float + laguerref(unsigned int __n, float __x) + { return __detail::__laguerre(__n, __x); } + + /** + * Returns the Laguerre polynomial @f$ L_n(x) @f$ of nonnegative degree @c n + * and long double argument @f$ x >= 0 @f$. + * + * @see laguerre for more details. + */ + inline long double + laguerrel(unsigned int __n, long double __x) + { return __detail::__laguerre(__n, __x); } + + /** + * Returns the Laguerre polynomial @f$ L_n(x) @f$ + * of nonnegative degree @c n and real argument @f$ x >= 0 @f$. + * + * The Laguerre polynomial is defined by: + * @f[ + * L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n} (x^ne^{-x}) + * @f] + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __n The nonnegative order + * @param __x The argument __x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + laguerre(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__laguerre<__type>(__n, __x); + } + + // Legendre polynomials + + /** + * Return the Legendre polynomial @f$ P_l(x) @f$ of nonnegative + * degree @f$ l @f$ and @c float argument @f$ |x| <= 0 @f$. + * + * @see legendre for more details. + */ + inline float + legendref(unsigned int __l, float __x) + { return __detail::__poly_legendre_p(__l, __x); } + + /** + * Return the Legendre polynomial @f$ P_l(x) @f$ of nonnegative + * degree @f$ l @f$ and long double argument @f$ |x| <= 0 @f$. + * + * @see legendre for more details. + */ + inline long double + legendrel(unsigned int __l, long double __x) + { return __detail::__poly_legendre_p(__l, __x); } + + /** + * Return the Legendre polynomial @f$ P_l(x) @f$ of nonnegative + * degree @f$ l @f$ and real argument @f$ |x| <= 0 @f$. + * + * The Legendre function of order @f$ l @f$ and argument @f$ x @f$, + * @f$ P_l(x) @f$, is defined by: + * @f[ + * P_l(x) = \frac{1}{2^l l!}\frac{d^l}{dx^l}(x^2 - 1)^{l} + * @f] + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __l The degree @f$ l >= 0 @f$ + * @param __x The argument @c abs(__x) <= 1 + * @throw std::domain_error if @c abs(__x) > 1 + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + legendre(unsigned int __l, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__poly_legendre_p<__type>(__l, __x); + } + + // Riemann zeta functions + + /** + * Return the Riemann zeta function @f$ \zeta(s) @f$ + * for @c float argument @f$ s @f$. + * + * @see riemann_zeta for more details. + */ + inline float + riemann_zetaf(float __s) + { return __detail::__riemann_zeta(__s); } + + /** + * Return the Riemann zeta function @f$ \zeta(s) @f$ + * for long double argument @f$ s @f$. + * + * @see riemann_zeta for more details. + */ + inline long double + riemann_zetal(long double __s) + { return __detail::__riemann_zeta(__s); } + + /** + * Return the Riemann zeta function @f$ \zeta(s) @f$ + * for real argument @f$ s @f$. + * + * The Riemann zeta function is defined by: + * @f[ + * \zeta(s) = \sum_{k=1}^{\infty} k^{-s} \hbox{ for } s > 1 + * @f] + * and + * @f[ + * \zeta(s) = \frac{1}{1-2^{1-s}}\sum_{k=1}^{\infty}(-1)^{k-1}k^{-s} + * \hbox{ for } 0 <= s <= 1 + * @f] + * For s < 1 use the reflection formula: + * @f[ + * \zeta(s) = 2^s \pi^{s-1} \sin(\frac{\pi s}{2}) \Gamma(1-s) \zeta(1-s) + * @f] + * + * @tparam _Tp The floating-point type of the argument @c __s. + * @param __s The argument s != 1 + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + riemann_zeta(_Tp __s) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__riemann_zeta<__type>(__s); + } + + // Spherical Bessel functions + + /** + * Return the spherical Bessel function @f$ j_n(x) @f$ of nonnegative order n + * and @c float argument @f$ x >= 0 @f$. + * + * @see sph_bessel for more details. + */ + inline float + sph_besself(unsigned int __n, float __x) + { return __detail::__sph_bessel(__n, __x); } + + /** + * Return the spherical Bessel function @f$ j_n(x) @f$ of nonnegative order n + * and long double argument @f$ x >= 0 @f$. + * + * @see sph_bessel for more details. + */ + inline long double + sph_bessell(unsigned int __n, long double __x) + { return __detail::__sph_bessel(__n, __x); } + + /** + * Return the spherical Bessel function @f$ j_n(x) @f$ of nonnegative order n + * and real argument @f$ x >= 0 @f$. + * + * The spherical Bessel function is defined by: + * @f[ + * j_n(x) = \left(\frac{\pi}{2x} \right) ^{1/2} J_{n+1/2}(x) + * @f] + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __n The integral order n >= 0 + * @param __x The real argument x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + sph_bessel(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__sph_bessel<__type>(__n, __x); + } + + // Spherical associated Legendre functions + + /** + * Return the spherical Legendre function of nonnegative integral + * degree @c l and order @c m and float angle @f$ \theta @f$ in radians. + * + * @see sph_legendre for details. + */ + inline float + sph_legendref(unsigned int __l, unsigned int __m, float __theta) + { return __detail::__sph_legendre(__l, __m, __theta); } + + /** + * Return the spherical Legendre function of nonnegative integral + * degree @c l and order @c m and long double angle @f$ \theta @f$ + * in radians. + * + * @see sph_legendre for details. + */ + inline long double + sph_legendrel(unsigned int __l, unsigned int __m, long double __theta) + { return __detail::__sph_legendre(__l, __m, __theta); } + + /** + * Return the spherical Legendre function of nonnegative integral + * degree @c l and order @c m and real angle @f$ \theta @f$ in radians. + * + * The spherical Legendre function is defined by + * @f[ + * Y_l^m(\theta,\phi) = (-1)^m[\frac{(2l+1)}{4\pi} + * \frac{(l-m)!}{(l+m)!}] + * P_l^m(\cos\theta) \exp^{im\phi} + * @f] + * + * @tparam _Tp The floating-point type of the angle @c __theta. + * @param __l The order __l >= 0 + * @param __m The degree __m >= 0 and __m <= __l + * @param __theta The radian polar angle argument + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__sph_legendre<__type>(__l, __m, __theta); + } + + // Spherical Neumann functions + + /** + * Return the spherical Neumann function of integral order @f$ n >= 0 @f$ + * and @c float argument @f$ x >= 0 @f$. + * + * @see sph_neumann for details. + */ + inline float + sph_neumannf(unsigned int __n, float __x) + { return __detail::__sph_neumann(__n, __x); } + + /** + * Return the spherical Neumann function of integral order @f$ n >= 0 @f$ + * and long double @f$ x >= 0 @f$. + * + * @see sph_neumann for details. + */ + inline long double + sph_neumannl(unsigned int __n, long double __x) + { return __detail::__sph_neumann(__n, __x); } + + /** + * Return the spherical Neumann function of integral order @f$ n >= 0 @f$ + * and real argument @f$ x >= 0 @f$. + * + * The spherical Neumann function is defined by + * @f[ + * n_n(x) = \left(\frac{\pi}{2x} \right) ^{1/2} N_{n+1/2}(x) + * @f] + * + * @tparam _Tp The floating-point type of the argument @c __x. + * @param __n The integral order n >= 0 + * @param __x The real argument __x >= 0 + * @throw std::domain_error if __x < 0 . + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + sph_neumann(unsigned int __n, _Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __detail::__sph_neumann<__type>(__n, __x); + } + + /// @} group mathsf + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#ifndef __STRICT_ANSI__ +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup mathsf + * @{ + */ + + // Airy functions + + /** + * Return the Airy function @f$ Ai(x) @f$ of @c float argument x. + */ + inline float + airy_aif(float __x) + { + float __Ai, __Bi, __Aip, __Bip; + std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip); + return __Ai; + } + + /** + * Return the Airy function @f$ Ai(x) @f$ of long double argument x. + */ + inline long double + airy_ail(long double __x) + { + long double __Ai, __Bi, __Aip, __Bip; + std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip); + return __Ai; + } + + /** + * Return the Airy function @f$ Ai(x) @f$ of real argument x. + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + airy_ai(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + __type __Ai, __Bi, __Aip, __Bip; + std::__detail::__airy<__type>(__x, __Ai, __Bi, __Aip, __Bip); + return __Ai; + } + + /** + * Return the Airy function @f$ Bi(x) @f$ of @c float argument x. + */ + inline float + airy_bif(float __x) + { + float __Ai, __Bi, __Aip, __Bip; + std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip); + return __Bi; + } + + /** + * Return the Airy function @f$ Bi(x) @f$ of long double argument x. + */ + inline long double + airy_bil(long double __x) + { + long double __Ai, __Bi, __Aip, __Bip; + std::__detail::__airy(__x, __Ai, __Bi, __Aip, __Bip); + return __Bi; + } + + /** + * Return the Airy function @f$ Bi(x) @f$ of real argument x. + */ + template + inline typename __gnu_cxx::__promote<_Tp>::__type + airy_bi(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + __type __Ai, __Bi, __Aip, __Bip; + std::__detail::__airy<__type>(__x, __Ai, __Bi, __Aip, __Bip); + return __Bi; + } + + // Confluent hypergeometric functions + + /** + * Return the confluent hypergeometric function @f$ {}_1F_1(a;c;x) @f$ + * of @c float numeratorial parameter @c a, denominatorial parameter @c c, + * and argument @c x. + * + * @see conf_hyperg for details. + */ + inline float + conf_hypergf(float __a, float __c, float __x) + { return std::__detail::__conf_hyperg(__a, __c, __x); } + + /** + * Return the confluent hypergeometric function @f$ {}_1F_1(a;c;x) @f$ + * of long double numeratorial parameter @c a, + * denominatorial parameter @c c, and argument @c x. + * + * @see conf_hyperg for details. + */ + inline long double + conf_hypergl(long double __a, long double __c, long double __x) + { return std::__detail::__conf_hyperg(__a, __c, __x); } + + /** + * Return the confluent hypergeometric function @f$ {}_1F_1(a;c;x) @f$ + * of real numeratorial parameter @c a, denominatorial parameter @c c, + * and argument @c x. + * + * The confluent hypergeometric function is defined by + * @f[ + * {}_1F_1(a;c;x) = \sum_{n=0}^{\infty} \frac{(a)_n x^n}{(c)_n n!} + * @f] + * where the Pochhammer symbol is @f$ (x)_k = (x)(x+1)...(x+k-1) @f$, + * @f$ (x)_0 = 1 @f$ + * + * @param __a The numeratorial parameter + * @param __c The denominatorial parameter + * @param __x The argument + */ + template + inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type + conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x) + { + typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type; + return std::__detail::__conf_hyperg<__type>(__a, __c, __x); + } + + // Hypergeometric functions + + /** + * Return the hypergeometric function @f$ {}_2F_1(a,b;c;x) @f$ + * of @ float numeratorial parameters @c a and @c b, + * denominatorial parameter @c c, and argument @c x. + * + * @see hyperg for details. + */ + inline float + hypergf(float __a, float __b, float __c, float __x) + { return std::__detail::__hyperg(__a, __b, __c, __x); } + + /** + * Return the hypergeometric function @f$ {}_2F_1(a,b;c;x) @f$ + * of long double numeratorial parameters @c a and @c b, + * denominatorial parameter @c c, and argument @c x. + * + * @see hyperg for details. + */ + inline long double + hypergl(long double __a, long double __b, long double __c, long double __x) + { return std::__detail::__hyperg(__a, __b, __c, __x); } + + /** + * Return the hypergeometric function @f$ {}_2F_1(a,b;c;x) @f$ + * of real numeratorial parameters @c a and @c b, + * denominatorial parameter @c c, and argument @c x. + * + * The hypergeometric function is defined by + * @f[ + * {}_2F_1(a;c;x) = \sum_{n=0}^{\infty} \frac{(a)_n (b)_n x^n}{(c)_n n!} + * @f] + * where the Pochhammer symbol is @f$ (x)_k = (x)(x+1)...(x+k-1) @f$, + * @f$ (x)_0 = 1 @f$ + * + * @param __a The first numeratorial parameter + * @param __b The second numeratorial parameter + * @param __c The denominatorial parameter + * @param __x The argument + */ + template + inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type + hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x) + { + typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp> + ::__type __type; + return std::__detail::__hyperg<__type>(__a, __b, __c, __x); + } + + /// @} +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace __gnu_cxx +#endif // __STRICT_ANSI__ + +#pragma GCC visibility pop + +#endif // _GLIBCXX_BITS_SPECFUN_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/sstream.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/sstream.tcc new file mode 100755 index 0000000..2b5c405 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/sstream.tcc @@ -0,0 +1,307 @@ +// String based streams -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/sstream.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{sstream} + */ + +// +// ISO C++ 14882: 27.7 String-based streams +// + +#ifndef _SSTREAM_TCC +#define _SSTREAM_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + pbackfail(int_type __c) + { + int_type __ret = traits_type::eof(); + if (this->eback() < this->gptr()) + { + // Try to put back __c into input sequence in one of three ways. + // Order these tests done in is unspecified by the standard. + const bool __testeof = traits_type::eq_int_type(__c, __ret); + if (!__testeof) + { + const bool __testeq = traits_type::eq(traits_type:: + to_char_type(__c), + this->gptr()[-1]); + const bool __testout = this->_M_mode & ios_base::out; + if (__testeq || __testout) + { + this->gbump(-1); + if (!__testeq) + *this->gptr() = traits_type::to_char_type(__c); + __ret = __c; + } + } + else + { + this->gbump(-1); + __ret = traits_type::not_eof(__c); + } + } + return __ret; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + overflow(int_type __c) + { + const bool __testout = this->_M_mode & ios_base::out; + if (__builtin_expect(!__testout, false)) + return traits_type::eof(); + + const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof()); + if (__builtin_expect(__testeof, false)) + return traits_type::not_eof(__c); + + const __size_type __capacity = _M_string.capacity(); + +#if _GLIBCXX_USE_CXX11_ABI + if (size_t(this->epptr() - this->pbase()) < __capacity) + { + // There is additional capacity in _M_string that can be used. + char_type* __base = const_cast(_M_string.data()); + _M_pbump(__base, __base + __capacity, this->pptr() - this->pbase()); + if (_M_mode & ios_base::in) + { + const __size_type __nget = this->gptr() - this->eback(); + const __size_type __eget = this->egptr() - this->eback(); + this->setg(__base, __base + __nget, __base + __eget + 1); + } + *this->pptr() = traits_type::to_char_type(__c); + this->pbump(1); + return __c; + } +#endif + + const __size_type __max_size = _M_string.max_size(); + const bool __testput = this->pptr() < this->epptr(); + if (__builtin_expect(!__testput && __capacity == __max_size, false)) + return traits_type::eof(); + + // Try to append __c into output sequence in one of two ways. + // Order these tests done in is unspecified by the standard. + const char_type __conv = traits_type::to_char_type(__c); + if (!__testput) + { + // NB: Start ostringstream buffers at 512 chars. This is an + // experimental value (pronounced "arbitrary" in some of the + // hipper English-speaking countries), and can be changed to + // suit particular needs. + // + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 169. Bad efficiency of overflow() mandated + // 432. stringbuf::overflow() makes only one write position + // available + const __size_type __opt_len = std::max(__size_type(2 * __capacity), + __size_type(512)); + const __size_type __len = std::min(__opt_len, __max_size); + __string_type __tmp(_M_string.get_allocator()); + __tmp.reserve(__len); + if (this->pbase()) + __tmp.assign(this->pbase(), this->epptr() - this->pbase()); + __tmp.push_back(__conv); + _M_string.swap(__tmp); + _M_sync(const_cast(_M_string.data()), + this->gptr() - this->eback(), this->pptr() - this->pbase()); + } + else + *this->pptr() = __conv; + this->pbump(1); + return __c; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + underflow() + { + int_type __ret = traits_type::eof(); + const bool __testin = this->_M_mode & ios_base::in; + if (__testin) + { + // Update egptr() to match the actual string end. + _M_update_egptr(); + + if (this->gptr() < this->egptr()) + __ret = traits_type::to_int_type(*this->gptr()); + } + return __ret; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode) + { + pos_type __ret = pos_type(off_type(-1)); + bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; + const bool __testboth = __testin && __testout && __way != ios_base::cur; + __testin &= !(__mode & ios_base::out); + __testout &= !(__mode & ios_base::in); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 453. basic_stringbuf::seekoff need not always fail for an empty stream. + const char_type* __beg = __testin ? this->eback() : this->pbase(); + if ((__beg || !__off) && (__testin || __testout || __testboth)) + { + _M_update_egptr(); + + off_type __newoffi = __off; + off_type __newoffo = __newoffi; + if (__way == ios_base::cur) + { + __newoffi += this->gptr() - __beg; + __newoffo += this->pptr() - __beg; + } + else if (__way == ios_base::end) + __newoffo = __newoffi += this->egptr() - __beg; + + if ((__testin || __testboth) + && __newoffi >= 0 + && this->egptr() - __beg >= __newoffi) + { + this->setg(this->eback(), this->eback() + __newoffi, + this->egptr()); + __ret = pos_type(__newoffi); + } + if ((__testout || __testboth) + && __newoffo >= 0 + && this->egptr() - __beg >= __newoffo) + { + _M_pbump(this->pbase(), this->epptr(), __newoffo); + __ret = pos_type(__newoffo); + } + } + return __ret; + } + + template + typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type + basic_stringbuf<_CharT, _Traits, _Alloc>:: + seekpos(pos_type __sp, ios_base::openmode __mode) + { + pos_type __ret = pos_type(off_type(-1)); + const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; + + const char_type* __beg = __testin ? this->eback() : this->pbase(); + if ((__beg || !off_type(__sp)) && (__testin || __testout)) + { + _M_update_egptr(); + + const off_type __pos(__sp); + const bool __testpos = (0 <= __pos + && __pos <= this->egptr() - __beg); + if (__testpos) + { + if (__testin) + this->setg(this->eback(), this->eback() + __pos, + this->egptr()); + if (__testout) + _M_pbump(this->pbase(), this->epptr(), __pos); + __ret = __sp; + } + } + return __ret; + } + + template + void + basic_stringbuf<_CharT, _Traits, _Alloc>:: + _M_sync(char_type* __base, __size_type __i, __size_type __o) + { + const bool __testin = _M_mode & ios_base::in; + const bool __testout = _M_mode & ios_base::out; + char_type* __endg = __base + _M_string.size(); + char_type* __endp = __base + _M_string.capacity(); + + if (__base != _M_string.data()) + { + // setbuf: __i == size of buffer area (_M_string.size() == 0). + __endg += __i; + __i = 0; + __endp = __endg; + } + + if (__testin) + this->setg(__base, __base + __i, __endg); + if (__testout) + { + _M_pbump(__base, __endp, __o); + // egptr() always tracks the string end. When !__testin, + // for the correct functioning of the streambuf inlines + // the other get area pointers are identical. + if (!__testin) + this->setg(__endg, __endg, __endg); + } + } + + template + void + basic_stringbuf<_CharT, _Traits, _Alloc>:: + _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off) + { + this->setp(__pbeg, __pend); + while (__off > __gnu_cxx::__numeric_traits::__max) + { + this->pbump(__gnu_cxx::__numeric_traits::__max); + __off -= __gnu_cxx::__numeric_traits::__max; + } + this->pbump(__off); + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_stringbuf; + extern template class basic_istringstream; + extern template class basic_ostringstream; + extern template class basic_stringstream; + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_stringbuf; + extern template class basic_istringstream; + extern template class basic_ostringstream; + extern template class basic_stringstream; +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_abs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_abs.h new file mode 100755 index 0000000..ae6bfc1 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_abs.h @@ -0,0 +1,111 @@ +// -*- C++ -*- C library enhancements header. + +// Copyright (C) 2016-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/std_abs.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{cmath, cstdlib} + */ + +#ifndef _GLIBCXX_BITS_STD_ABS_H +#define _GLIBCXX_BITS_STD_ABS_H + +#pragma GCC system_header + +#include + +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include_next +#ifdef __CORRECT_ISO_CPP_MATH_H_PROTO +# include_next +#endif +#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS + +#undef abs + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::abs; + +#ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO + inline long + abs(long __i) { return __builtin_labs(__i); } +#endif + +#ifdef _GLIBCXX_USE_LONG_LONG + inline long long + abs(long long __x) { return __builtin_llabs (__x); } +#endif + +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// 2192. Validity and return type of std::abs(0u) is unclear +// 2294. should declare abs(double) +// 2735. std::abs(short), std::abs(signed char) and others should return int + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR double + abs(double __x) + { return __builtin_fabs(__x); } + + inline _GLIBCXX_CONSTEXPR float + abs(float __x) + { return __builtin_fabsf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + abs(long double __x) + { return __builtin_fabsl(__x); } +#endif + +#if defined(__GLIBCXX_TYPE_INT_N_0) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0 + abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1 + abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2 + abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3 + abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; } +#endif + +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) + inline _GLIBCXX_CONSTEXPR + __float128 + abs(__float128 __x) + { return __x < 0 ? -__x : __x; } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C"++" + +#endif // _GLIBCXX_BITS_STD_ABS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_function.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_function.h new file mode 100755 index 0000000..da15bd2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_function.h @@ -0,0 +1,757 @@ +// Implementation of std::function -*- C++ -*- + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/std_function.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _GLIBCXX_STD_FUNCTION_H +#define _GLIBCXX_STD_FUNCTION_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief Exception class thrown when class template function's + * operator() is called with an empty target. + * @ingroup exceptions + */ + class bad_function_call : public std::exception + { + public: + virtual ~bad_function_call() noexcept; + + const char* what() const noexcept; + }; + + /** + * Trait identifying "location-invariant" types, meaning that the + * address of the object (or any of its members) will not escape. + * Trivially copyable types are location-invariant and users can + * specialize this trait for other types. + */ + template + struct __is_location_invariant + : is_trivially_copyable<_Tp>::type + { }; + + class _Undefined_class; + + union _Nocopy_types + { + void* _M_object; + const void* _M_const_object; + void (*_M_function_pointer)(); + void (_Undefined_class::*_M_member_pointer)(); + }; + + union [[gnu::may_alias]] _Any_data + { + void* _M_access() { return &_M_pod_data[0]; } + const void* _M_access() const { return &_M_pod_data[0]; } + + template + _Tp& + _M_access() + { return *static_cast<_Tp*>(_M_access()); } + + template + const _Tp& + _M_access() const + { return *static_cast(_M_access()); } + + _Nocopy_types _M_unused; + char _M_pod_data[sizeof(_Nocopy_types)]; + }; + + enum _Manager_operation + { + __get_type_info, + __get_functor_ptr, + __clone_functor, + __destroy_functor + }; + + template + class function; + + /// Base class of all polymorphic function object wrappers. + class _Function_base + { + public: + static const size_t _M_max_size = sizeof(_Nocopy_types); + static const size_t _M_max_align = __alignof__(_Nocopy_types); + + template + class _Base_manager + { + protected: + static const bool __stored_locally = + (__is_location_invariant<_Functor>::value + && sizeof(_Functor) <= _M_max_size + && __alignof__(_Functor) <= _M_max_align + && (_M_max_align % __alignof__(_Functor) == 0)); + + typedef integral_constant _Local_storage; + + // Retrieve a pointer to the function object + static _Functor* + _M_get_pointer(const _Any_data& __source) + { + if _GLIBCXX17_CONSTEXPR (__stored_locally) + { + const _Functor& __f = __source._M_access<_Functor>(); + return const_cast<_Functor*>(std::__addressof(__f)); + } + else // have stored a pointer + return __source._M_access<_Functor*>(); + } + + // Clone a location-invariant function object that fits within + // an _Any_data structure. + static void + _M_clone(_Any_data& __dest, const _Any_data& __source, true_type) + { + ::new (__dest._M_access()) _Functor(__source._M_access<_Functor>()); + } + + // Clone a function object that is not location-invariant or + // that cannot fit into an _Any_data structure. + static void + _M_clone(_Any_data& __dest, const _Any_data& __source, false_type) + { + __dest._M_access<_Functor*>() = + new _Functor(*__source._M_access()); + } + + // Destroying a location-invariant object may still require + // destruction. + static void + _M_destroy(_Any_data& __victim, true_type) + { + __victim._M_access<_Functor>().~_Functor(); + } + + // Destroying an object located on the heap. + static void + _M_destroy(_Any_data& __victim, false_type) + { + delete __victim._M_access<_Functor*>(); + } + + public: + static bool + _M_manager(_Any_data& __dest, const _Any_data& __source, + _Manager_operation __op) + { + switch (__op) + { + case __get_type_info: +#if __cpp_rtti + __dest._M_access() = &typeid(_Functor); +#else + __dest._M_access() = nullptr; +#endif + break; + case __get_functor_ptr: + __dest._M_access<_Functor*>() = _M_get_pointer(__source); + break; + + case __clone_functor: + _M_clone(__dest, __source, _Local_storage()); + break; + + case __destroy_functor: + _M_destroy(__dest, _Local_storage()); + break; + } + return false; + } + + static void + _M_init_functor(_Any_data& __functor, _Functor&& __f) + { _M_init_functor(__functor, std::move(__f), _Local_storage()); } + + template + static bool + _M_not_empty_function(const function<_Signature>& __f) + { return static_cast(__f); } + + template + static bool + _M_not_empty_function(_Tp* __fp) + { return __fp != nullptr; } + + template + static bool + _M_not_empty_function(_Tp _Class::* __mp) + { return __mp != nullptr; } + + template + static bool + _M_not_empty_function(const _Tp&) + { return true; } + + private: + static void + _M_init_functor(_Any_data& __functor, _Functor&& __f, true_type) + { ::new (__functor._M_access()) _Functor(std::move(__f)); } + + static void + _M_init_functor(_Any_data& __functor, _Functor&& __f, false_type) + { __functor._M_access<_Functor*>() = new _Functor(std::move(__f)); } + }; + + _Function_base() : _M_manager(nullptr) { } + + ~_Function_base() + { + if (_M_manager) + _M_manager(_M_functor, _M_functor, __destroy_functor); + } + + bool _M_empty() const { return !_M_manager; } + + typedef bool (*_Manager_type)(_Any_data&, const _Any_data&, + _Manager_operation); + + _Any_data _M_functor; + _Manager_type _M_manager; + }; + + template + class _Function_handler; + + template + class _Function_handler<_Res(_ArgTypes...), _Functor> + : public _Function_base::_Base_manager<_Functor> + { + typedef _Function_base::_Base_manager<_Functor> _Base; + + public: + static bool + _M_manager(_Any_data& __dest, const _Any_data& __source, + _Manager_operation __op) + { + switch (__op) + { +#if __cpp_rtti + case __get_type_info: + __dest._M_access() = &typeid(_Functor); + break; +#endif + case __get_functor_ptr: + __dest._M_access<_Functor*>() = _Base::_M_get_pointer(__source); + break; + + default: + _Base::_M_manager(__dest, __source, __op); + } + return false; + } + + static _Res + _M_invoke(const _Any_data& __functor, _ArgTypes&&... __args) + { + return std::__invoke_r<_Res>(*_Base::_M_get_pointer(__functor), + std::forward<_ArgTypes>(__args)...); + } + }; + + // Specialization for invalid types + template<> + class _Function_handler + { + public: + static bool + _M_manager(_Any_data&, const _Any_data&, _Manager_operation) + { return false; } + }; + + // Avoids instantiating ill-formed specializations of _Function_handler + // in std::function<_Signature>::target<_Functor>(). + // e.g. _Function_handler and _Function_handler + // would be ill-formed. + template::value> + struct _Target_handler + : _Function_handler<_Signature, typename remove_cv<_Functor>::type> + { }; + + template + struct _Target_handler<_Signature, _Functor, false> + : _Function_handler + { }; + + /** + * @brief Primary class template for std::function. + * @ingroup functors + * + * Polymorphic function wrapper. + */ + template + class function<_Res(_ArgTypes...)> + : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>, + private _Function_base + { + template> + struct _Callable + : __is_invocable_impl<_Res2, _Res>::type + { }; + + // Used so the return type convertibility checks aren't done when + // performing overload resolution for copy construction/assignment. + template + struct _Callable : false_type { }; + + template + using _Requires = typename enable_if<_Cond::value, _Tp>::type; + + public: + typedef _Res result_type; + + // [3.7.2.1] construct/copy/destroy + + /** + * @brief Default construct creates an empty function call wrapper. + * @post @c !(bool)*this + */ + function() noexcept + : _Function_base() { } + + /** + * @brief Creates an empty function call wrapper. + * @post @c !(bool)*this + */ + function(nullptr_t) noexcept + : _Function_base() { } + + /** + * @brief %Function copy constructor. + * @param __x A %function object with identical call signature. + * @post @c bool(*this) == bool(__x) + * + * The newly-created %function contains a copy of the target of @a + * __x (if it has one). + */ + function(const function& __x) + : _Function_base() + { + if (static_cast(__x)) + { + __x._M_manager(_M_functor, __x._M_functor, __clone_functor); + _M_invoker = __x._M_invoker; + _M_manager = __x._M_manager; + } + } + + /** + * @brief %Function move constructor. + * @param __x A %function object rvalue with identical call signature. + * + * The newly-created %function contains the target of @a __x + * (if it has one). + */ + function(function&& __x) noexcept + : _Function_base(), _M_invoker(__x._M_invoker) + { + if (static_cast(__x)) + { + _M_functor = __x._M_functor; + _M_manager = __x._M_manager; + __x._M_manager = nullptr; + __x._M_invoker = nullptr; + } + } + + /** + * @brief Builds a %function that targets a copy of the incoming + * function object. + * @param __f A %function object that is callable with parameters of + * type @c T1, @c T2, ..., @c TN and returns a value convertible + * to @c Res. + * + * The newly-created %function object will target a copy of + * @a __f. If @a __f is @c reference_wrapper, then this function + * object will contain a reference to the function object @c + * __f.get(). If @a __f is a NULL function pointer or NULL + * pointer-to-member, the newly-created object will be empty. + * + * If @a __f is a non-NULL function pointer or an object of type @c + * reference_wrapper, this function will not throw. + */ + template>, void>, + typename = _Requires<_Callable<_Functor>, void>> + function(_Functor __f) + : _Function_base() + { + typedef _Function_handler<_Res(_ArgTypes...), _Functor> _My_handler; + + if (_My_handler::_M_not_empty_function(__f)) + { + _My_handler::_M_init_functor(_M_functor, std::move(__f)); + _M_invoker = &_My_handler::_M_invoke; + _M_manager = &_My_handler::_M_manager; + } + } + + /** + * @brief %Function assignment operator. + * @param __x A %function with identical call signature. + * @post @c (bool)*this == (bool)x + * @returns @c *this + * + * The target of @a __x is copied to @c *this. If @a __x has no + * target, then @c *this will be empty. + * + * If @a __x targets a function pointer or a reference to a function + * object, then this operation will not throw an %exception. + */ + function& + operator=(const function& __x) + { + function(__x).swap(*this); + return *this; + } + + /** + * @brief %Function move-assignment operator. + * @param __x A %function rvalue with identical call signature. + * @returns @c *this + * + * The target of @a __x is moved to @c *this. If @a __x has no + * target, then @c *this will be empty. + * + * If @a __x targets a function pointer or a reference to a function + * object, then this operation will not throw an %exception. + */ + function& + operator=(function&& __x) noexcept + { + function(std::move(__x)).swap(*this); + return *this; + } + + /** + * @brief %Function assignment to zero. + * @post @c !(bool)*this + * @returns @c *this + * + * The target of @c *this is deallocated, leaving it empty. + */ + function& + operator=(nullptr_t) noexcept + { + if (_M_manager) + { + _M_manager(_M_functor, _M_functor, __destroy_functor); + _M_manager = nullptr; + _M_invoker = nullptr; + } + return *this; + } + + /** + * @brief %Function assignment to a new target. + * @param __f A %function object that is callable with parameters of + * type @c T1, @c T2, ..., @c TN and returns a value convertible + * to @c Res. + * @return @c *this + * + * This %function object wrapper will target a copy of @a + * __f. If @a __f is @c reference_wrapper, then this function + * object will contain a reference to the function object @c + * __f.get(). If @a __f is a NULL function pointer or NULL + * pointer-to-member, @c this object will be empty. + * + * If @a __f is a non-NULL function pointer or an object of type @c + * reference_wrapper, this function will not throw. + */ + template + _Requires<_Callable::type>, function&> + operator=(_Functor&& __f) + { + function(std::forward<_Functor>(__f)).swap(*this); + return *this; + } + + /// @overload + template + function& + operator=(reference_wrapper<_Functor> __f) noexcept + { + function(__f).swap(*this); + return *this; + } + + // [3.7.2.2] function modifiers + + /** + * @brief Swap the targets of two %function objects. + * @param __x A %function with identical call signature. + * + * Swap the targets of @c this function object and @a __f. This + * function will not throw an %exception. + */ + void swap(function& __x) noexcept + { + std::swap(_M_functor, __x._M_functor); + std::swap(_M_manager, __x._M_manager); + std::swap(_M_invoker, __x._M_invoker); + } + + // [3.7.2.3] function capacity + + /** + * @brief Determine if the %function wrapper has a target. + * + * @return @c true when this %function object contains a target, + * or @c false when it is empty. + * + * This function will not throw an %exception. + */ + explicit operator bool() const noexcept + { return !_M_empty(); } + + // [3.7.2.4] function invocation + + /** + * @brief Invokes the function targeted by @c *this. + * @returns the result of the target. + * @throws bad_function_call when @c !(bool)*this + * + * The function call operator invokes the target function object + * stored by @c this. + */ + _Res + operator()(_ArgTypes... __args) const + { + if (_M_empty()) + __throw_bad_function_call(); + return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...); + } + +#if __cpp_rtti + // [3.7.2.5] function target access + /** + * @brief Determine the type of the target of this function object + * wrapper. + * + * @returns the type identifier of the target function object, or + * @c typeid(void) if @c !(bool)*this. + * + * This function will not throw an %exception. + */ + const type_info& + target_type() const noexcept + { + if (_M_manager) + { + _Any_data __typeinfo_result; + _M_manager(__typeinfo_result, _M_functor, __get_type_info); + if (auto __ti = __typeinfo_result._M_access()) + return *__ti; + } + return typeid(void); + } +#endif + + /** + * @brief Access the stored target function object. + * + * @return Returns a pointer to the stored target function object, + * if @c typeid(_Functor).equals(target_type()); otherwise, a null + * pointer. + * + * This function does not throw exceptions. + * + * @{ + */ + template + _Functor* + target() noexcept + { + const function* __const_this = this; + const _Functor* __func = __const_this->template target<_Functor>(); + // If is_function_v<_Functor> is true then const_cast<_Functor*> + // would be ill-formed, so use *const_cast<_Functor**> instead. + return *const_cast<_Functor**>(&__func); + } + + template + const _Functor* + target() const noexcept + { + if _GLIBCXX17_CONSTEXPR (is_object<_Functor>::value) + { + // For C++11 and C++14 if-constexpr is not used above, so + // _Target_handler avoids ill-formed _Function_handler types. + using _Handler = _Target_handler<_Res(_ArgTypes...), _Functor>; + + if (_M_manager == &_Handler::_M_manager +#if __cpp_rtti + || (_M_manager && typeid(_Functor) == target_type()) +#endif + ) + { + _Any_data __ptr; + _M_manager(__ptr, _M_functor, __get_functor_ptr); + return __ptr._M_access(); + } + } + return nullptr; + } + /// @} + + private: + using _Invoker_type = _Res (*)(const _Any_data&, _ArgTypes&&...); + _Invoker_type _M_invoker; + }; + +#if __cpp_deduction_guides >= 201606 + template + struct __function_guide_helper + { }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) & noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) const noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + struct __function_guide_helper< + _Res (_Tp::*) (_Args...) const & noexcept(_Nx) + > + { using type = _Res(_Args...); }; + + template + function(_Res(*)(_ArgTypes...)) -> function<_Res(_ArgTypes...)>; + + template::type> + function(_Functor) -> function<_Signature>; +#endif + + // [20.7.15.2.6] null pointer comparisons + + /** + * @brief Compares a polymorphic function object wrapper against 0 + * (the NULL pointer). + * @returns @c true if the wrapper has no target, @c false otherwise + * + * This function will not throw an %exception. + */ + template + inline bool + operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept + { return !static_cast(__f); } + +#if __cpp_impl_three_way_comparison < 201907L + /// @overload + template + inline bool + operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept + { return !static_cast(__f); } + + /** + * @brief Compares a polymorphic function object wrapper against 0 + * (the NULL pointer). + * @returns @c false if the wrapper has no target, @c true otherwise + * + * This function will not throw an %exception. + */ + template + inline bool + operator!=(const function<_Res(_Args...)>& __f, nullptr_t) noexcept + { return static_cast(__f); } + + /// @overload + template + inline bool + operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept + { return static_cast(__f); } +#endif + + // [20.7.15.2.7] specialized algorithms + + /** + * @brief Swap the targets of two polymorphic function object wrappers. + * + * This function will not throw an %exception. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2062. Effect contradictions w/o no-throw guarantee of std::function swaps + template + inline void + swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept + { __x.swap(__y); } + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // function into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 +#endif // _GLIBCXX_STD_FUNCTION_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_mutex.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_mutex.h new file mode 100755 index 0000000..357c689 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_mutex.h @@ -0,0 +1,248 @@ +// std::mutex implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/std_mutex.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{mutex} + */ + +#ifndef _GLIBCXX_MUTEX_H +#define _GLIBCXX_MUTEX_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup mutexes Mutexes + * @ingroup concurrency + * + * Classes for mutex support. + * @{ + */ + +#ifdef _GLIBCXX_HAS_GTHREADS + // Common base class for std::mutex and std::timed_mutex + class __mutex_base + { + protected: + typedef __gthread_mutex_t __native_type; + +#ifdef __GTHREAD_MUTEX_INIT + __native_type _M_mutex = __GTHREAD_MUTEX_INIT; + + constexpr __mutex_base() noexcept = default; +#else + __native_type _M_mutex; + + __mutex_base() noexcept + { + // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may) + __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); + } + + ~__mutex_base() noexcept { __gthread_mutex_destroy(&_M_mutex); } +#endif + + __mutex_base(const __mutex_base&) = delete; + __mutex_base& operator=(const __mutex_base&) = delete; + }; + + /// The standard mutex type. + class mutex : private __mutex_base + { + public: + typedef __native_type* native_handle_type; + +#ifdef __GTHREAD_MUTEX_INIT + constexpr +#endif + mutex() noexcept = default; + ~mutex() = default; + + mutex(const mutex&) = delete; + mutex& operator=(const mutex&) = delete; + + void + lock() + { + int __e = __gthread_mutex_lock(&_M_mutex); + + // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may) + if (__e) + __throw_system_error(__e); + } + + bool + try_lock() noexcept + { + // XXX EINVAL, EAGAIN, EBUSY + return !__gthread_mutex_trylock(&_M_mutex); + } + + void + unlock() + { + // XXX EINVAL, EAGAIN, EPERM + __gthread_mutex_unlock(&_M_mutex); + } + + native_handle_type + native_handle() noexcept + { return &_M_mutex; } + }; + + // Implementation details for std::condition_variable + class __condvar + { + using timespec = __gthread_time_t; + + public: + __condvar() noexcept + { +#ifndef __GTHREAD_COND_INIT + __GTHREAD_COND_INIT_FUNCTION(&_M_cond); +#endif + } + + ~__condvar() + { + int __e __attribute__((__unused__)) = __gthread_cond_destroy(&_M_cond); + __glibcxx_assert(__e != EBUSY); // threads are still blocked + } + + __condvar(const __condvar&) = delete; + __condvar& operator=(const __condvar&) = delete; + + __gthread_cond_t* native_handle() noexcept { return &_M_cond; } + + // Expects: Calling thread has locked __m. + void + wait(mutex& __m) noexcept + { + int __e __attribute__((__unused__)) + = __gthread_cond_wait(&_M_cond, __m.native_handle()); + __glibcxx_assert(__e == 0); + } + + void + wait_until(mutex& __m, timespec& __abs_time) noexcept + { + __gthread_cond_timedwait(&_M_cond, __m.native_handle(), &__abs_time); + } + +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + void + wait_until(mutex& __m, clockid_t __clock, timespec& __abs_time) noexcept + { + pthread_cond_clockwait(&_M_cond, __m.native_handle(), __clock, + &__abs_time); + } +#endif + + void + notify_one() noexcept + { + int __e __attribute__((__unused__)) = __gthread_cond_signal(&_M_cond); + __glibcxx_assert(__e == 0); + } + + void + notify_all() noexcept + { + int __e __attribute__((__unused__)) = __gthread_cond_broadcast(&_M_cond); + __glibcxx_assert(__e == 0); + } + + protected: +#ifdef __GTHREAD_COND_INIT + __gthread_cond_t _M_cond = __GTHREAD_COND_INIT; +#else + __gthread_cond_t _M_cond; +#endif + }; + +#endif // _GLIBCXX_HAS_GTHREADS + + /// Do not acquire ownership of the mutex. + struct defer_lock_t { explicit defer_lock_t() = default; }; + + /// Try to acquire ownership of the mutex without blocking. + struct try_to_lock_t { explicit try_to_lock_t() = default; }; + + /// Assume the calling thread has already obtained mutex ownership + /// and manage it. + struct adopt_lock_t { explicit adopt_lock_t() = default; }; + + /// Tag used to prevent a scoped lock from acquiring ownership of a mutex. + _GLIBCXX17_INLINE constexpr defer_lock_t defer_lock { }; + + /// Tag used to prevent a scoped lock from blocking if a mutex is locked. + _GLIBCXX17_INLINE constexpr try_to_lock_t try_to_lock { }; + + /// Tag used to make a scoped lock take ownership of a locked mutex. + _GLIBCXX17_INLINE constexpr adopt_lock_t adopt_lock { }; + + /** @brief A simple scoped lock type. + * + * A lock_guard controls mutex ownership within a scope, releasing + * ownership in the destructor. + */ + template + class lock_guard + { + public: + typedef _Mutex mutex_type; + + explicit lock_guard(mutex_type& __m) : _M_device(__m) + { _M_device.lock(); } + + lock_guard(mutex_type& __m, adopt_lock_t) noexcept : _M_device(__m) + { } // calling thread owns mutex + + ~lock_guard() + { _M_device.unlock(); } + + lock_guard(const lock_guard&) = delete; + lock_guard& operator=(const lock_guard&) = delete; + + private: + mutex_type& _M_device; + }; + + /// @} group mutexes +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 +#endif // _GLIBCXX_MUTEX_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_thread.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_thread.h new file mode 100755 index 0000000..2a500bf --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/std_thread.h @@ -0,0 +1,335 @@ +// std::thread declarations -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/std_thread.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{thread} + */ + +#ifndef _GLIBCXX_THREAD_H +#define _GLIBCXX_THREAD_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +#include + +#include // std::terminate +#include // std::basic_ostream +#include // std::tuple +#include // std::hash +#include // std::__invoke +#include // not required, but helpful to users +#include // std::unique_ptr + +#ifdef _GLIBCXX_HAS_GTHREADS +# include +#else +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup threads + * @{ + */ + + /// thread + class thread + { + public: +#ifdef _GLIBCXX_HAS_GTHREADS + // Abstract base class for types that wrap arbitrary functors to be + // invoked in the new thread of execution. + struct _State + { + virtual ~_State(); + virtual void _M_run() = 0; + }; + using _State_ptr = unique_ptr<_State>; + + using native_handle_type = __gthread_t; +#else + using native_handle_type = int; +#endif + + /// thread::id + class id + { + native_handle_type _M_thread; + + public: + id() noexcept : _M_thread() { } + + explicit + id(native_handle_type __id) : _M_thread(__id) { } + + private: + friend class thread; + friend struct hash; + + friend bool + operator==(id __x, id __y) noexcept; + +#if __cpp_lib_three_way_comparison + friend strong_ordering + operator<=>(id __x, id __y) noexcept; +#else + friend bool + operator<(id __x, id __y) noexcept; +#endif + + template + friend basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __out, id __id); + }; + + private: + id _M_id; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2097. packaged_task constructors should be constrained + // 3039. Unnecessary decay in thread and packaged_task + template + using __not_same = __not_, thread>>; + + public: + thread() noexcept = default; + +#ifdef _GLIBCXX_HAS_GTHREADS + template>> + explicit + thread(_Callable&& __f, _Args&&... __args) + { + static_assert( __is_invocable::type, + typename decay<_Args>::type...>::value, + "std::thread arguments must be invocable after conversion to rvalues" + ); + +#ifdef GTHR_ACTIVE_PROXY + // Create a reference to pthread_create, not just the gthr weak symbol. + auto __depend = reinterpret_cast(&pthread_create); +#else + auto __depend = nullptr; +#endif + using _Wrapper = _Call_wrapper<_Callable, _Args...>; + // Create a call wrapper with DECAY_COPY(__f) as its target object + // and DECAY_COPY(__args)... as its bound argument entities. + _M_start_thread(_State_ptr(new _State_impl<_Wrapper>( + std::forward<_Callable>(__f), std::forward<_Args>(__args)...)), + __depend); + } +#endif // _GLIBCXX_HAS_GTHREADS + + ~thread() + { + if (joinable()) + std::terminate(); + } + + thread(const thread&) = delete; + + thread(thread&& __t) noexcept + { swap(__t); } + + thread& operator=(const thread&) = delete; + + thread& operator=(thread&& __t) noexcept + { + if (joinable()) + std::terminate(); + swap(__t); + return *this; + } + + void + swap(thread& __t) noexcept + { std::swap(_M_id, __t._M_id); } + + bool + joinable() const noexcept + { return !(_M_id == id()); } + + void + join(); + + void + detach(); + + id + get_id() const noexcept + { return _M_id; } + + /** @pre thread is joinable + */ + native_handle_type + native_handle() + { return _M_id._M_thread; } + + // Returns a value that hints at the number of hardware thread contexts. + static unsigned int + hardware_concurrency() noexcept; + +#ifdef _GLIBCXX_HAS_GTHREADS + private: + template + struct _State_impl : public _State + { + _Callable _M_func; + + template + _State_impl(_Args&&... __args) + : _M_func{{std::forward<_Args>(__args)...}} + { } + + void + _M_run() { _M_func(); } + }; + + void + _M_start_thread(_State_ptr, void (*)()); + +#if _GLIBCXX_THREAD_ABI_COMPAT + public: + struct _Impl_base; + typedef shared_ptr<_Impl_base> __shared_base_type; + struct _Impl_base + { + __shared_base_type _M_this_ptr; + virtual ~_Impl_base() = default; + virtual void _M_run() = 0; + }; + + private: + void + _M_start_thread(__shared_base_type, void (*)()); + + void + _M_start_thread(__shared_base_type); +#endif + + private: + // A call wrapper that does INVOKE(forwarded tuple elements...) + template + struct _Invoker + { + _Tuple _M_t; + + template + struct __result; + template + struct __result> + : __invoke_result<_Fn, _Args...> + { }; + + template + typename __result<_Tuple>::type + _M_invoke(_Index_tuple<_Ind...>) + { return std::__invoke(std::get<_Ind>(std::move(_M_t))...); } + + typename __result<_Tuple>::type + operator()() + { + using _Indices + = typename _Build_index_tuple::value>::__type; + return _M_invoke(_Indices()); + } + }; + + public: + template + using _Call_wrapper = _Invoker::type...>>; +#endif // _GLIBCXX_HAS_GTHREADS + }; + +#ifndef _GLIBCXX_HAS_GTHREADS + inline void thread::join() { std::__throw_system_error(EINVAL); } + inline void thread::detach() { std::__throw_system_error(EINVAL); } + inline unsigned int thread::hardware_concurrency() noexcept { return 0; } +#endif + + inline void + swap(thread& __x, thread& __y) noexcept + { __x.swap(__y); } + + inline bool + operator==(thread::id __x, thread::id __y) noexcept + { + // pthread_equal is undefined if either thread ID is not valid, so we + // can't safely use __gthread_equal on default-constructed values (nor + // the non-zero value returned by this_thread::get_id() for + // single-threaded programs using GNU libc). Assume EqualityComparable. + return __x._M_thread == __y._M_thread; + } + + // N.B. other comparison operators are defined in + + // DR 889. + /// std::hash specialization for thread::id. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const thread::id& __id) const noexcept + { return std::_Hash_impl::hash(__id._M_thread); } + }; + + namespace this_thread + { + /// this_thread::get_id + inline thread::id + get_id() noexcept + { +#ifndef _GLIBCXX_HAS_GTHREADS + return thread::id(1); +#elif defined _GLIBCXX_NATIVE_THREAD_ID + return thread::id(_GLIBCXX_NATIVE_THREAD_ID); +#else + return thread::id(__gthread_self()); +#endif + } + + /// this_thread::yield + inline void + yield() noexcept + { +#if defined _GLIBCXX_HAS_GTHREADS && defined _GLIBCXX_USE_SCHED_YIELD + __gthread_yield(); +#endif + } + + } // namespace this_thread + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 + +#endif // _GLIBCXX_THREAD_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_algo.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_algo.h new file mode 100755 index 0000000..a18bb00 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_algo.h @@ -0,0 +1,5875 @@ +// Algorithm implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_algo.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _STL_ALGO_H +#define _STL_ALGO_H 1 + +#include // for rand +#include +#include +#include // for _Temporary_buffer +#include + +#if __cplusplus >= 201103L +#include +#endif + +// See concept_check.h for the __glibcxx_*_requires macros. + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Swaps the median value of *__a, *__b and *__c under __comp to *__result + template + _GLIBCXX20_CONSTEXPR + void + __move_median_to_first(_Iterator __result,_Iterator __a, _Iterator __b, + _Iterator __c, _Compare __comp) + { + if (__comp(__a, __b)) + { + if (__comp(__b, __c)) + std::iter_swap(__result, __b); + else if (__comp(__a, __c)) + std::iter_swap(__result, __c); + else + std::iter_swap(__result, __a); + } + else if (__comp(__a, __c)) + std::iter_swap(__result, __a); + else if (__comp(__b, __c)) + std::iter_swap(__result, __c); + else + std::iter_swap(__result, __b); + } + + /// Provided for stable_partition to use. + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + __find_if_not(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + return std::__find_if(__first, __last, + __gnu_cxx::__ops::__negate(__pred), + std::__iterator_category(__first)); + } + + /// Like find_if_not(), but uses and updates a count of the + /// remaining range length instead of comparing against an end + /// iterator. + template + _GLIBCXX20_CONSTEXPR + _InputIterator + __find_if_not_n(_InputIterator __first, _Distance& __len, _Predicate __pred) + { + for (; __len; --__len, (void) ++__first) + if (!__pred(__first)) + break; + return __first; + } + + // set_difference + // set_intersection + // set_symmetric_difference + // set_union + // for_each + // find + // find_if + // find_first_of + // adjacent_find + // count + // count_if + // search + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator1 + __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __predicate) + { + // Test for empty ranges + if (__first1 == __last1 || __first2 == __last2) + return __first1; + + // Test for a pattern of length 1. + _ForwardIterator2 __p1(__first2); + if (++__p1 == __last2) + return std::__find_if(__first1, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); + + // General case. + _ForwardIterator1 __current = __first1; + + for (;;) + { + __first1 = + std::__find_if(__first1, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2)); + + if (__first1 == __last1) + return __last1; + + _ForwardIterator2 __p = __p1; + __current = __first1; + if (++__current == __last1) + return __last1; + + while (__predicate(__current, __p)) + { + if (++__p == __last2) + return __first1; + if (++__current == __last1) + return __last1; + } + ++__first1; + } + return __first1; + } + + // search_n + + /** + * This is an helper function for search_n overloaded for forward iterators. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __search_n_aux(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, _UnaryPredicate __unary_pred, + std::forward_iterator_tag) + { + __first = std::__find_if(__first, __last, __unary_pred); + while (__first != __last) + { + typename iterator_traits<_ForwardIterator>::difference_type + __n = __count; + _ForwardIterator __i = __first; + ++__i; + while (__i != __last && __n != 1 && __unary_pred(__i)) + { + ++__i; + --__n; + } + if (__n == 1) + return __first; + if (__i == __last) + return __last; + __first = std::__find_if(++__i, __last, __unary_pred); + } + return __last; + } + + /** + * This is an helper function for search_n overloaded for random access + * iterators. + */ + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIter + __search_n_aux(_RandomAccessIter __first, _RandomAccessIter __last, + _Integer __count, _UnaryPredicate __unary_pred, + std::random_access_iterator_tag) + { + typedef typename std::iterator_traits<_RandomAccessIter>::difference_type + _DistanceType; + + _DistanceType __tailSize = __last - __first; + _DistanceType __remainder = __count; + + while (__remainder <= __tailSize) // the main loop... + { + __first += __remainder; + __tailSize -= __remainder; + // __first here is always pointing to one past the last element of + // next possible match. + _RandomAccessIter __backTrack = __first; + while (__unary_pred(--__backTrack)) + { + if (--__remainder == 0) + return (__first - __count); // Success + } + __remainder = __count + 1 - (__first - __backTrack); + } + return __last; // Failure + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, + _UnaryPredicate __unary_pred) + { + if (__count <= 0) + return __first; + + if (__count == 1) + return std::__find_if(__first, __last, __unary_pred); + + return std::__search_n_aux(__first, __last, __count, __unary_pred, + std::__iterator_category(__first)); + } + + // find_end for forward iterators. + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator1 + __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + forward_iterator_tag, forward_iterator_tag, + _BinaryPredicate __comp) + { + if (__first2 == __last2) + return __last1; + + _ForwardIterator1 __result = __last1; + while (1) + { + _ForwardIterator1 __new_result + = std::__search(__first1, __last1, __first2, __last2, __comp); + if (__new_result == __last1) + return __result; + else + { + __result = __new_result; + __first1 = __new_result; + ++__first1; + } + } + } + + // find_end for bidirectional iterators (much faster). + template + _GLIBCXX20_CONSTEXPR + _BidirectionalIterator1 + __find_end(_BidirectionalIterator1 __first1, + _BidirectionalIterator1 __last1, + _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, + bidirectional_iterator_tag, bidirectional_iterator_tag, + _BinaryPredicate __comp) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator1>) + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator2>) + + typedef reverse_iterator<_BidirectionalIterator1> _RevIterator1; + typedef reverse_iterator<_BidirectionalIterator2> _RevIterator2; + + _RevIterator1 __rlast1(__first1); + _RevIterator2 __rlast2(__first2); + _RevIterator1 __rresult = std::__search(_RevIterator1(__last1), __rlast1, + _RevIterator2(__last2), __rlast2, + __comp); + + if (__rresult == __rlast1) + return __last1; + else + { + _BidirectionalIterator1 __result = __rresult.base(); + std::advance(__result, -std::distance(__first2, __last2)); + return __result; + } + } + + /** + * @brief Find last matching subsequence in a sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of sequence to match. + * @param __last2 End of sequence to match. + * @return The last iterator @c i in the range + * @p [__first1,__last1-(__last2-__first2)) such that @c *(i+N) == + * @p *(__first2+N) for each @c N in the range @p + * [0,__last2-__first2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2) and returns an iterator to the __first + * element of the sub-sequence, or @p __last1 if the sub-sequence + * is not found. The sub-sequence will be the last such + * subsequence contained in [__first1,__last1). + * + * Because the sub-sequence must lie completely within the range @p + * [__first1,__last1) it must start at a position less than @p + * __last1-(__last2-__first2) where @p __last2-__first2 is the + * length of the sub-sequence. This means that the returned + * iterator @c i will be in the range @p + * [__first1,__last1-(__last2-__first2)) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__find_end(__first1, __last1, __first2, __last2, + std::__iterator_category(__first1), + std::__iterator_category(__first2), + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Find last matching subsequence in a sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of sequence to match. + * @param __last2 End of sequence to match. + * @param __comp The predicate to use. + * @return The last iterator @c i in the range @p + * [__first1,__last1-(__last2-__first2)) such that @c + * predicate(*(i+N), @p (__first2+N)) is true for each @c N in the + * range @p [0,__last2-__first2), or @p __last1 if no such iterator + * exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2) using comp as a predicate and returns an + * iterator to the first element of the sub-sequence, or @p __last1 + * if the sub-sequence is not found. The sub-sequence will be the + * last such subsequence contained in [__first,__last1). + * + * Because the sub-sequence must lie completely within the range @p + * [__first1,__last1) it must start at a position less than @p + * __last1-(__last2-__first2) where @p __last2-__first2 is the + * length of the sub-sequence. This means that the returned + * iterator @c i will be in the range @p + * [__first1,__last1-(__last2-__first2)) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__find_end(__first1, __last1, __first2, __last2, + std::__iterator_category(__first1), + std::__iterator_category(__first2), + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + +#if __cplusplus >= 201103L + /** + * @brief Checks that a predicate is true for all the elements + * of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if @p __pred is true for each element in the range + * @p [__first,__last), and false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return __last == std::find_if_not(__first, __last, __pred); } + + /** + * @brief Checks that a predicate is false for all the elements + * of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if @p __pred is false for each element in the range + * @p [__first,__last), and false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return __last == _GLIBCXX_STD_A::find_if(__first, __last, __pred); } + + /** + * @brief Checks that a predicate is true for at least one element + * of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the check is true, false otherwise. + * + * Returns true if an element exists in the range @p + * [__first,__last) such that @p __pred is true, and false + * otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { return !std::none_of(__first, __last, __pred); } + + /** + * @brief Find the first element in a sequence for which a + * predicate is false. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return The first iterator @c i in the range @p [__first,__last) + * such that @p __pred(*i) is false, or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + find_if_not(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + return std::__find_if_not(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /** + * @brief Checks whether the sequence is partitioned. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return True if the range @p [__first,__last) is partioned by @p __pred, + * i.e. if all elements that satisfy @p __pred appear before those that + * do not. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_partitioned(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + __first = std::find_if_not(__first, __last, __pred); + if (__first == __last) + return true; + ++__first; + return std::none_of(__first, __last, __pred); + } + + /** + * @brief Find the partition point of a partitioned range. + * @ingroup mutating_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __pred A predicate. + * @return An iterator @p mid such that @p all_of(__first, mid, __pred) + * and @p none_of(mid, __last, __pred) are both true. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + partition_point(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + + // A specific debug-mode test will be necessary... + __glibcxx_requires_valid_range(__first, __last); + + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__pred(*__middle)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } +#endif + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __remove_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) + { + for (; __first != __last; ++__first) + if (!__pred(__first)) + { + *__result = *__first; + ++__result; + } + return __result; + } + + /** + * @brief Copy a sequence, removing elements of a given value. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __value The value to be removed. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) not equal + * to @p __value to the range beginning at @p __result. + * remove_copy() is stable, so the relative order of elements that + * are copied is unchanged. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + remove_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__iter_equals_val(__value)); + } + + /** + * @brief Copy a sequence, removing elements for which a predicate is true. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __pred A predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) for which + * @p __pred returns false to the range beginning at @p __result. + * + * remove_copy_if() is stable, so the relative order of elements that are + * copied is unchanged. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + remove_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + +#if __cplusplus >= 201103L + /** + * @brief Copy the elements of a sequence for which a predicate is true. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __pred A predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) for which + * @p __pred returns true to the range beginning at @p __result. + * + * copy_if() is stable, so the relative order of elements that are + * copied is unchanged. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (__pred(*__first)) + { + *__result = *__first; + ++__result; + } + return __result; + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __copy_n(_InputIterator __first, _Size __n, + _OutputIterator __result, input_iterator_tag) + { + return std::__niter_wrap(__result, + __copy_n_a(__first, __n, + std::__niter_base(__result), true)); + } + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __copy_n(_RandomAccessIterator __first, _Size __n, + _OutputIterator __result, random_access_iterator_tag) + { return std::copy(__first, __first + __n, __result); } + + /** + * @brief Copies the range [first,first+n) into [result,result+n). + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __n The number of elements to copy. + * @param __result An output iterator. + * @return result+n. + * + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + + const auto __n2 = std::__size_to_integer(__n); + if (__n2 <= 0) + return __result; + + __glibcxx_requires_can_increment(__first, __n2); + __glibcxx_requires_can_increment(__result, __n2); + + return std::__copy_n(__first, __n2, __result, + std::__iterator_category(__first)); + } + + /** + * @brief Copy the elements of a sequence to separate output sequences + * depending on the truth value of a predicate. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __out_true An output iterator. + * @param __out_false An output iterator. + * @param __pred A predicate. + * @return A pair designating the ends of the resulting sequences. + * + * Copies each element in the range @p [__first,__last) for which + * @p __pred returns true to the range beginning at @p out_true + * and each element for which @p __pred returns false to @p __out_false. + */ + template + _GLIBCXX20_CONSTEXPR + pair<_OutputIterator1, _OutputIterator2> + partition_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator1 __out_true, _OutputIterator2 __out_false, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator1, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator2, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (__pred(*__first)) + { + *__out_true = *__first; + ++__out_true; + } + else + { + *__out_false = *__first; + ++__out_false; + } + + return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false); + } +#endif // C++11 + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __remove_if(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + __first = std::__find_if(__first, __last, __pred); + if (__first == __last) + return __first; + _ForwardIterator __result = __first; + ++__first; + for (; __first != __last; ++__first) + if (!__pred(__first)) + { + *__result = _GLIBCXX_MOVE(*__first); + ++__result; + } + return __result; + } + + /** + * @brief Remove elements from a sequence. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __value The value to be removed. + * @return An iterator designating the end of the resulting sequence. + * + * All elements equal to @p __value are removed from the range + * @p [__first,__last). + * + * remove() is stable, so the relative order of elements that are + * not removed is unchanged. + * + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + remove(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_if(__first, __last, + __gnu_cxx::__ops::__iter_equals_val(__value)); + } + + /** + * @brief Remove elements from a sequence using a predicate. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate. + * @return An iterator designating the end of the resulting sequence. + * + * All elements for which @p __pred returns true are removed from the range + * @p [__first,__last). + * + * remove_if() is stable, so the relative order of elements that are + * not removed is unchanged. + * + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + remove_if(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__remove_if(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __adjacent_find(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + if (__first == __last) + return __last; + _ForwardIterator __next = __first; + while (++__next != __last) + { + if (__binary_pred(__first, __next)) + return __first; + __first = __next; + } + return __last; + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __unique(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + // Skip the beginning, if already unique. + __first = std::__adjacent_find(__first, __last, __binary_pred); + if (__first == __last) + return __last; + + // Do the real copy work. + _ForwardIterator __dest = __first; + ++__first; + while (++__first != __last) + if (!__binary_pred(__dest, __first)) + *++__dest = _GLIBCXX_MOVE(*__first); + return ++__dest; + } + + /** + * @brief Remove consecutive duplicate values from a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Removes all but the first element from each group of consecutive + * values that compare equal. + * unique() is stable, so the relative order of elements that are + * not removed is unchanged. + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + unique(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_EqualityComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__unique(__first, __last, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Remove consecutive values from a sequence using a predicate. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __binary_pred A binary predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Removes all but the first element from each group of consecutive + * values for which @p __binary_pred returns true. + * unique() is stable, so the relative order of elements that are + * not removed is unchanged. + * Elements between the end of the resulting sequence and @p __last + * are still present, but their value is unspecified. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + unique(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__unique(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } + + /** + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for forward iterators and output iterator as result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __unique_copy(_ForwardIterator __first, _ForwardIterator __last, + _OutputIterator __result, _BinaryPredicate __binary_pred, + forward_iterator_tag, output_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + + _ForwardIterator __next = __first; + *__result = *__first; + while (++__next != __last) + if (!__binary_pred(__first, __next)) + { + __first = __next; + *++__result = *__first; + } + return ++__result; + } + + /** + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for input iterators and output iterator as result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryPredicate __binary_pred, + input_iterator_tag, output_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_InputIterator>::value_type, + typename iterator_traits<_InputIterator>::value_type>) + + typename iterator_traits<_InputIterator>::value_type __value = *__first; + __decltype(__gnu_cxx::__ops::__iter_comp_val(__binary_pred)) + __rebound_pred + = __gnu_cxx::__ops::__iter_comp_val(__binary_pred); + *__result = __value; + while (++__first != __last) + if (!__rebound_pred(__first, __value)) + { + __value = *__first; + *++__result = __value; + } + return ++__result; + } + + /** + * This is an uglified + * unique_copy(_InputIterator, _InputIterator, _OutputIterator, + * _BinaryPredicate) + * overloaded for input iterators and forward iterator as result. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __unique_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _BinaryPredicate __binary_pred, + input_iterator_tag, forward_iterator_tag) + { + // concept requirements -- iterators already checked + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_InputIterator>::value_type>) + *__result = *__first; + while (++__first != __last) + if (!__binary_pred(__result, __first)) + *++__result = *__first; + return ++__result; + } + + /** + * This is an uglified reverse(_BidirectionalIterator, + * _BidirectionalIterator) + * overloaded for bidirectional iterators. + */ + template + _GLIBCXX20_CONSTEXPR + void + __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, + bidirectional_iterator_tag) + { + while (true) + if (__first == __last || __first == --__last) + return; + else + { + std::iter_swap(__first, __last); + ++__first; + } + } + + /** + * This is an uglified reverse(_BidirectionalIterator, + * _BidirectionalIterator) + * overloaded for random access iterators. + */ + template + _GLIBCXX20_CONSTEXPR + void + __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, + random_access_iterator_tag) + { + if (__first == __last) + return; + --__last; + while (__first < __last) + { + std::iter_swap(__first, __last); + ++__first; + --__last; + } + } + + /** + * @brief Reverse a sequence. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @return reverse() returns no value. + * + * Reverses the order of the elements in the range @p [__first,__last), + * so that the first element becomes the last etc. + * For every @c i such that @p 0<=i<=(__last-__first)/2), @p reverse() + * swaps @p *(__first+i) and @p *(__last-(i+1)) + */ + template + _GLIBCXX20_CONSTEXPR + inline void + reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_requires_valid_range(__first, __last); + std::__reverse(__first, __last, std::__iterator_category(__first)); + } + + /** + * @brief Copy a sequence, reversing its elements. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @param __result An output iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Copies the elements in the range @p [__first,__last) to the + * range @p [__result,__result+(__last-__first)) such that the + * order of the elements is reversed. For every @c i such that @p + * 0<=i<=(__last-__first), @p reverse_copy() performs the + * assignment @p *(__result+(__last-__first)-1-i) = *(__first+i). + * The ranges @p [__first,__last) and @p + * [__result,__result+(__last-__first)) must not overlap. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + while (__first != __last) + { + --__last; + *__result = *__last; + ++__result; + } + return __result; + } + + /** + * This is a helper function for the rotate algorithm specialized on RAIs. + * It returns the greatest common divisor of two integer values. + */ + template + _GLIBCXX20_CONSTEXPR + _EuclideanRingElement + __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n) + { + while (__n != 0) + { + _EuclideanRingElement __t = __m % __n; + __m = __n; + __n = __t; + } + return __m; + } + + inline namespace _V2 + { + + /// This is a helper function for the rotate algorithm. + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __rotate(_ForwardIterator __first, + _ForwardIterator __middle, + _ForwardIterator __last, + forward_iterator_tag) + { + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + + _ForwardIterator __first2 = __middle; + do + { + std::iter_swap(__first, __first2); + ++__first; + ++__first2; + if (__first == __middle) + __middle = __first2; + } + while (__first2 != __last); + + _ForwardIterator __ret = __first; + + __first2 = __middle; + + while (__first2 != __last) + { + std::iter_swap(__first, __first2); + ++__first; + ++__first2; + if (__first == __middle) + __middle = __first2; + else if (__first2 == __last) + __first2 = __middle; + } + return __ret; + } + + /// This is a helper function for the rotate algorithm. + template + _GLIBCXX20_CONSTEXPR + _BidirectionalIterator + __rotate(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + bidirectional_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + + std::__reverse(__first, __middle, bidirectional_iterator_tag()); + std::__reverse(__middle, __last, bidirectional_iterator_tag()); + + while (__first != __middle && __middle != __last) + { + std::iter_swap(__first, --__last); + ++__first; + } + + if (__first == __middle) + { + std::__reverse(__middle, __last, bidirectional_iterator_tag()); + return __last; + } + else + { + std::__reverse(__first, __middle, bidirectional_iterator_tag()); + return __first; + } + } + + /// This is a helper function for the rotate algorithm. + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __rotate(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, + random_access_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + + if (__first == __middle) + return __last; + else if (__last == __middle) + return __first; + + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _Distance; + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + + _Distance __n = __last - __first; + _Distance __k = __middle - __first; + + if (__k == __n - __k) + { + std::swap_ranges(__first, __middle, __middle); + return __middle; + } + + _RandomAccessIterator __p = __first; + _RandomAccessIterator __ret = __first + (__last - __middle); + + for (;;) + { + if (__k < __n - __k) + { + if (__is_pod(_ValueType) && __k == 1) + { + _ValueType __t = _GLIBCXX_MOVE(*__p); + _GLIBCXX_MOVE3(__p + 1, __p + __n, __p); + *(__p + __n - 1) = _GLIBCXX_MOVE(__t); + return __ret; + } + _RandomAccessIterator __q = __p + __k; + for (_Distance __i = 0; __i < __n - __k; ++ __i) + { + std::iter_swap(__p, __q); + ++__p; + ++__q; + } + __n %= __k; + if (__n == 0) + return __ret; + std::swap(__n, __k); + __k = __n - __k; + } + else + { + __k = __n - __k; + if (__is_pod(_ValueType) && __k == 1) + { + _ValueType __t = _GLIBCXX_MOVE(*(__p + __n - 1)); + _GLIBCXX_MOVE_BACKWARD3(__p, __p + __n - 1, __p + __n); + *__p = _GLIBCXX_MOVE(__t); + return __ret; + } + _RandomAccessIterator __q = __p + __n; + __p = __q - __k; + for (_Distance __i = 0; __i < __n - __k; ++ __i) + { + --__p; + --__q; + std::iter_swap(__p, __q); + } + __n %= __k; + if (__n == 0) + return __ret; + std::swap(__n, __k); + } + } + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 488. rotate throws away useful information + /** + * @brief Rotate the elements of a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __middle A forward iterator. + * @param __last A forward iterator. + * @return first + (last - middle). + * + * Rotates the elements of the range @p [__first,__last) by + * @p (__middle - __first) positions so that the element at @p __middle + * is moved to @p __first, the element at @p __middle+1 is moved to + * @p __first+1 and so on for each element in the range + * @p [__first,__last). + * + * This effectively swaps the ranges @p [__first,__middle) and + * @p [__middle,__last). + * + * Performs + * @p *(__first+(n+(__last-__middle))%(__last-__first))=*(__first+n) + * for each @p n in the range @p [0,__last-__first). + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + rotate(_ForwardIterator __first, _ForwardIterator __middle, + _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + + return std::__rotate(__first, __middle, __last, + std::__iterator_category(__first)); + } + + } // namespace _V2 + + /** + * @brief Copy a sequence, rotating its elements. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __middle A forward iterator. + * @param __last A forward iterator. + * @param __result An output iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Copies the elements of the range @p [__first,__last) to the + * range beginning at @result, rotating the copied elements by + * @p (__middle-__first) positions so that the element at @p __middle + * is moved to @p __result, the element at @p __middle+1 is moved + * to @p __result+1 and so on for each element in the range @p + * [__first,__last). + * + * Performs + * @p *(__result+(n+(__last-__middle))%(__last-__first))=*(__first+n) + * for each @p n in the range @p [0,__last-__first). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, + _ForwardIterator __last, _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + + return std::copy(__first, __middle, + std::copy(__middle, __last, __result)); + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, forward_iterator_tag) + { + if (__first == __last) + return __first; + + while (__pred(*__first)) + if (++__first == __last) + return __first; + + _ForwardIterator __next = __first; + + while (++__next != __last) + if (__pred(*__next)) + { + std::iter_swap(__first, __next); + ++__first; + } + + return __first; + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + _BidirectionalIterator + __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, + _Predicate __pred, bidirectional_iterator_tag) + { + while (true) + { + while (true) + if (__first == __last) + return __first; + else if (__pred(*__first)) + ++__first; + else + break; + --__last; + while (true) + if (__first == __last) + return __first; + else if (!bool(__pred(*__last))) + --__last; + else + break; + std::iter_swap(__first, __last); + ++__first; + } + } + + // partition + + /// This is a helper function... + /// Requires __first != __last and !__pred(__first) + /// and __len == distance(__first, __last). + /// + /// !__pred(__first) allows us to guarantee that we don't + /// move-assign an element onto itself. + template + _ForwardIterator + __stable_partition_adaptive(_ForwardIterator __first, + _ForwardIterator __last, + _Predicate __pred, _Distance __len, + _Pointer __buffer, + _Distance __buffer_size) + { + if (__len == 1) + return __first; + + if (__len <= __buffer_size) + { + _ForwardIterator __result1 = __first; + _Pointer __result2 = __buffer; + + // The precondition guarantees that !__pred(__first), so + // move that element to the buffer before starting the loop. + // This ensures that we only call __pred once per element. + *__result2 = _GLIBCXX_MOVE(*__first); + ++__result2; + ++__first; + for (; __first != __last; ++__first) + if (__pred(__first)) + { + *__result1 = _GLIBCXX_MOVE(*__first); + ++__result1; + } + else + { + *__result2 = _GLIBCXX_MOVE(*__first); + ++__result2; + } + + _GLIBCXX_MOVE3(__buffer, __result2, __result1); + return __result1; + } + + _ForwardIterator __middle = __first; + std::advance(__middle, __len / 2); + _ForwardIterator __left_split = + std::__stable_partition_adaptive(__first, __middle, __pred, + __len / 2, __buffer, + __buffer_size); + + // Advance past true-predicate values to satisfy this + // function's preconditions. + _Distance __right_len = __len - __len / 2; + _ForwardIterator __right_split = + std::__find_if_not_n(__middle, __right_len, __pred); + + if (__right_len) + __right_split = + std::__stable_partition_adaptive(__right_split, __last, __pred, + __right_len, + __buffer, __buffer_size); + + return std::rotate(__left_split, __middle, __right_split); + } + + template + _ForwardIterator + __stable_partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + __first = std::__find_if_not(__first, __last, __pred); + + if (__first == __last) + return __first; + + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _Temporary_buffer<_ForwardIterator, _ValueType> + __buf(__first, std::distance(__first, __last)); + return + std::__stable_partition_adaptive(__first, __last, __pred, + _DistanceType(__buf.requested_size()), + __buf.begin(), + _DistanceType(__buf.size())); + } + + /** + * @brief Move elements for which a predicate is true to the beginning + * of a sequence, preserving relative ordering. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate functor. + * @return An iterator @p middle such that @p __pred(i) is true for each + * iterator @p i in the range @p [first,middle) and false for each @p i + * in the range @p [middle,last). + * + * Performs the same function as @p partition() with the additional + * guarantee that the relative ordering of elements in each group is + * preserved, so any two elements @p x and @p y in the range + * @p [__first,__last) such that @p __pred(x)==__pred(y) will have the same + * relative ordering after calling @p stable_partition(). + */ + template + inline _ForwardIterator + stable_partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__stable_partition(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /// This is a helper function for the sort routines. + template + _GLIBCXX20_CONSTEXPR + void + __heap_select(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, _Compare __comp) + { + std::__make_heap(__first, __middle, __comp); + for (_RandomAccessIterator __i = __middle; __i < __last; ++__i) + if (__comp(__i, __first)) + std::__pop_heap(__first, __middle, __i, __comp); + } + + // partial_sort + + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, + _RandomAccessIterator __result_last, + _Compare __comp) + { + typedef typename iterator_traits<_InputIterator>::value_type + _InputValueType; + typedef iterator_traits<_RandomAccessIterator> _RItTraits; + typedef typename _RItTraits::difference_type _DistanceType; + + if (__result_first == __result_last) + return __result_last; + _RandomAccessIterator __result_real_last = __result_first; + while (__first != __last && __result_real_last != __result_last) + { + *__result_real_last = *__first; + ++__result_real_last; + ++__first; + } + + std::__make_heap(__result_first, __result_real_last, __comp); + while (__first != __last) + { + if (__comp(__first, __result_first)) + std::__adjust_heap(__result_first, _DistanceType(0), + _DistanceType(__result_real_last + - __result_first), + _InputValueType(*__first), __comp); + ++__first; + } + std::__sort_heap(__result_first, __result_real_last, __comp); + return __result_real_last; + } + + /** + * @brief Copy the smallest elements of a sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __result_first A random-access iterator. + * @param __result_last Another random-access iterator. + * @return An iterator indicating the end of the resulting sequence. + * + * Copies and sorts the smallest N values from the range @p [__first,__last) + * to the range beginning at @p __result_first, where the number of + * elements to be copied, @p N, is the smaller of @p (__last-__first) and + * @p (__result_last-__result_first). + * After the sort if @e i and @e j are iterators in the range + * @p [__result_first,__result_first+N) such that i precedes j then + * *j<*i is false. + * The value returned is @p __result_first+N. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, + _RandomAccessIterator __result_last) + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + typedef typename iterator_traits<_InputIterator>::value_type + _InputValueType; + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _OutputValueType; +#endif + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_InputValueType, + _OutputValueType>) + __glibcxx_function_requires(_LessThanOpConcept<_InputValueType, + _OutputValueType>) + __glibcxx_function_requires(_LessThanComparableConcept<_OutputValueType>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_valid_range(__result_first, __result_last); + + return std::__partial_sort_copy(__first, __last, + __result_first, __result_last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Copy the smallest elements of a sequence using a predicate for + * comparison. + * @ingroup sorting_algorithms + * @param __first An input iterator. + * @param __last Another input iterator. + * @param __result_first A random-access iterator. + * @param __result_last Another random-access iterator. + * @param __comp A comparison functor. + * @return An iterator indicating the end of the resulting sequence. + * + * Copies and sorts the smallest N values from the range @p [__first,__last) + * to the range beginning at @p result_first, where the number of + * elements to be copied, @p N, is the smaller of @p (__last-__first) and + * @p (__result_last-__result_first). + * After the sort if @e i and @e j are iterators in the range + * @p [__result_first,__result_first+N) such that i precedes j then + * @p __comp(*j,*i) is false. + * The value returned is @p __result_first+N. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, + _RandomAccessIterator __result_last, + _Compare __comp) + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + typedef typename iterator_traits<_InputIterator>::value_type + _InputValueType; + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _OutputValueType; +#endif + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_InputValueType, + _OutputValueType>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _InputValueType, _OutputValueType>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _OutputValueType, _OutputValueType>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_valid_range(__result_first, __result_last); + + return std::__partial_sort_copy(__first, __last, + __result_first, __result_last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __unguarded_linear_insert(_RandomAccessIterator __last, + _Compare __comp) + { + typename iterator_traits<_RandomAccessIterator>::value_type + __val = _GLIBCXX_MOVE(*__last); + _RandomAccessIterator __next = __last; + --__next; + while (__comp(__val, __next)) + { + *__last = _GLIBCXX_MOVE(*__next); + __last = __next; + --__next; + } + *__last = _GLIBCXX_MOVE(__val); + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + if (__first == __last) return; + + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + if (__comp(__i, __first)) + { + typename iterator_traits<_RandomAccessIterator>::value_type + __val = _GLIBCXX_MOVE(*__i); + _GLIBCXX_MOVE_BACKWARD3(__first, __i, __i + 1); + *__first = _GLIBCXX_MOVE(__val); + } + else + std::__unguarded_linear_insert(__i, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + inline void + __unguarded_insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + for (_RandomAccessIterator __i = __first; __i != __last; ++__i) + std::__unguarded_linear_insert(__i, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + + /** + * @doctodo + * This controls some aspect of the sort routines. + */ + enum { _S_threshold = 16 }; + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __final_insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + if (__last - __first > int(_S_threshold)) + { + std::__insertion_sort(__first, __first + int(_S_threshold), __comp); + std::__unguarded_insertion_sort(__first + int(_S_threshold), __last, + __comp); + } + else + std::__insertion_sort(__first, __last, __comp); + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __unguarded_partition(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _RandomAccessIterator __pivot, _Compare __comp) + { + while (true) + { + while (__comp(__first, __pivot)) + ++__first; + --__last; + while (__comp(__pivot, __last)) + --__last; + if (!(__first < __last)) + return __first; + std::iter_swap(__first, __last); + ++__first; + } + } + + /// This is a helper function... + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + __unguarded_partition_pivot(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + _RandomAccessIterator __mid = __first + (__last - __first) / 2; + std::__move_median_to_first(__first, __first + 1, __mid, __last - 1, + __comp); + return std::__unguarded_partition(__first + 1, __last, __first, __comp); + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __partial_sort(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, + _Compare __comp) + { + std::__heap_select(__first, __middle, __last, __comp); + std::__sort_heap(__first, __middle, __comp); + } + + /// This is a helper function for the sort routine. + template + _GLIBCXX20_CONSTEXPR + void + __introsort_loop(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Size __depth_limit, _Compare __comp) + { + while (__last - __first > int(_S_threshold)) + { + if (__depth_limit == 0) + { + std::__partial_sort(__first, __last, __last, __comp); + return; + } + --__depth_limit; + _RandomAccessIterator __cut = + std::__unguarded_partition_pivot(__first, __last, __comp); + std::__introsort_loop(__cut, __last, __depth_limit, __comp); + __last = __cut; + } + } + + // sort + + template + _GLIBCXX20_CONSTEXPR + inline void + __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + if (__first != __last) + { + std::__introsort_loop(__first, __last, + std::__lg(__last - __first) * 2, + __comp); + std::__final_insertion_sort(__first, __last, __comp); + } + } + + template + _GLIBCXX20_CONSTEXPR + void + __introselect(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Size __depth_limit, + _Compare __comp) + { + while (__last - __first > 3) + { + if (__depth_limit == 0) + { + std::__heap_select(__first, __nth + 1, __last, __comp); + // Place the nth largest element in its final position. + std::iter_swap(__first, __nth); + return; + } + --__depth_limit; + _RandomAccessIterator __cut = + std::__unguarded_partition_pivot(__first, __last, __comp); + if (__cut <= __nth) + __first = __cut; + else + __last = __cut; + } + std::__insertion_sort(__first, __last, __comp); + } + + // nth_element + + // lower_bound moved to stl_algobase.h + + /** + * @brief Finds the first position in which @p __val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return An iterator pointing to the first element not less + * than @p __val, or end() if every element is less + * than @p __val. + * @ingroup binary_search_algorithms + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + + return std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __upper_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__comp(__val, __middle)) + __len = __half; + else + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + } + return __first; + } + + /** + * @brief Finds the last position in which @p __val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return An iterator pointing to the first element greater than @p __val, + * or end() if no elements are greater than @p __val. + * @ingroup binary_search_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + upper_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_upper(__first, __last, __val); + + return std::__upper_bound(__first, __last, __val, + __gnu_cxx::__ops::__val_less_iter()); + } + + /** + * @brief Finds the last position in which @p __val could be inserted + * without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return An iterator pointing to the first element greater than @p __val, + * or end() if no elements are greater than @p __val. + * @ingroup binary_search_algorithms + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + upper_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_upper_pred(__first, __last, + __val, __comp); + + return std::__upper_bound(__first, __last, __val, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + pair<_ForwardIterator, _ForwardIterator> + __equal_range(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, + _CompareItTp __comp_it_val, _CompareTpIt __comp_val_it) + { + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__comp_it_val(__middle, __val)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else if (__comp_val_it(__val, __middle)) + __len = __half; + else + { + _ForwardIterator __left + = std::__lower_bound(__first, __middle, __val, __comp_it_val); + std::advance(__first, __len); + _ForwardIterator __right + = std::__upper_bound(++__middle, __first, __val, __comp_val_it); + return pair<_ForwardIterator, _ForwardIterator>(__left, __right); + } + } + return pair<_ForwardIterator, _ForwardIterator>(__first, __first); + } + + /** + * @brief Finds the largest subrange in which @p __val could be inserted + * at any place in it without changing the ordering. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return An pair of iterators defining the subrange. + * @ingroup binary_search_algorithms + * + * This is equivalent to + * @code + * std::make_pair(lower_bound(__first, __last, __val), + * upper_bound(__first, __last, __val)) + * @endcode + * but does not actually call those functions. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + equal_range(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_function_requires(_LessThanOpConcept< + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower(__first, __last, __val); + __glibcxx_requires_partitioned_upper(__first, __last, __val); + + return std::__equal_range(__first, __last, __val, + __gnu_cxx::__ops::__iter_less_val(), + __gnu_cxx::__ops::__val_less_iter()); + } + + /** + * @brief Finds the largest subrange in which @p __val could be inserted + * at any place in it without changing the ordering. + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return An pair of iterators defining the subrange. + * @ingroup binary_search_algorithms + * + * This is equivalent to + * @code + * std::make_pair(lower_bound(__first, __last, __val, __comp), + * upper_bound(__first, __last, __val, __comp)) + * @endcode + * but does not actually call those functions. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + equal_range(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + __glibcxx_requires_partitioned_upper_pred(__first, __last, + __val, __comp); + + return std::__equal_range(__first, __last, __val, + __gnu_cxx::__ops::__iter_comp_val(__comp), + __gnu_cxx::__ops::__val_comp_iter(__comp)); + } + + /** + * @brief Determines whether an element exists in a range. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return True if @p __val (or its equivalent) is in [@p + * __first,@p __last ]. + * + * Note that this does not actually return an iterator to @p __val. For + * that, use std::find or a container's specialized find member functions. + */ + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower(__first, __last, __val); + __glibcxx_requires_partitioned_upper(__first, __last, __val); + + _ForwardIterator __i + = std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_less_val()); + return __i != __last && !(__val < *__i); + } + + /** + * @brief Determines whether an element exists in a range. + * @ingroup binary_search_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @param __comp A functor to use for comparisons. + * @return True if @p __val (or its equivalent) is in @p [__first,__last]. + * + * Note that this does not actually return an iterator to @p __val. For + * that, use std::find or a container's specialized find member functions. + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + bool + binary_search(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + _Tp, typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_partitioned_lower_pred(__first, __last, + __val, __comp); + __glibcxx_requires_partitioned_upper_pred(__first, __last, + __val, __comp); + + _ForwardIterator __i + = std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + return __i != __last && !bool(__comp(__val, *__i)); + } + + // merge + + /// This is a helper function for the __merge_adaptive routines. + template + void + __move_merge_adaptive(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + if (__first1 != __last1) + _GLIBCXX_MOVE3(__first1, __last1, __result); + } + + /// This is a helper function for the __merge_adaptive routines. + template + void + __move_merge_adaptive_backward(_BidirectionalIterator1 __first1, + _BidirectionalIterator1 __last1, + _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, + _BidirectionalIterator3 __result, + _Compare __comp) + { + if (__first1 == __last1) + { + _GLIBCXX_MOVE_BACKWARD3(__first2, __last2, __result); + return; + } + else if (__first2 == __last2) + return; + + --__last1; + --__last2; + while (true) + { + if (__comp(__last2, __last1)) + { + *--__result = _GLIBCXX_MOVE(*__last1); + if (__first1 == __last1) + { + _GLIBCXX_MOVE_BACKWARD3(__first2, ++__last2, __result); + return; + } + --__last1; + } + else + { + *--__result = _GLIBCXX_MOVE(*__last2); + if (__first2 == __last2) + return; + --__last2; + } + } + } + + /// This is a helper function for the merge routines. + template + _BidirectionalIterator1 + __rotate_adaptive(_BidirectionalIterator1 __first, + _BidirectionalIterator1 __middle, + _BidirectionalIterator1 __last, + _Distance __len1, _Distance __len2, + _BidirectionalIterator2 __buffer, + _Distance __buffer_size) + { + _BidirectionalIterator2 __buffer_end; + if (__len1 > __len2 && __len2 <= __buffer_size) + { + if (__len2) + { + __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); + _GLIBCXX_MOVE_BACKWARD3(__first, __middle, __last); + return _GLIBCXX_MOVE3(__buffer, __buffer_end, __first); + } + else + return __first; + } + else if (__len1 <= __buffer_size) + { + if (__len1) + { + __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); + _GLIBCXX_MOVE3(__middle, __last, __first); + return _GLIBCXX_MOVE_BACKWARD3(__buffer, __buffer_end, __last); + } + else + return __last; + } + else + return std::rotate(__first, __middle, __last); + } + + /// This is a helper function for the merge routines. + template + void + __merge_adaptive(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Distance __len1, _Distance __len2, + _Pointer __buffer, _Distance __buffer_size, + _Compare __comp) + { + if (__len1 <= __len2 && __len1 <= __buffer_size) + { + _Pointer __buffer_end = _GLIBCXX_MOVE3(__first, __middle, __buffer); + std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last, + __first, __comp); + } + else if (__len2 <= __buffer_size) + { + _Pointer __buffer_end = _GLIBCXX_MOVE3(__middle, __last, __buffer); + std::__move_merge_adaptive_backward(__first, __middle, __buffer, + __buffer_end, __last, __comp); + } + else + { + _BidirectionalIterator __first_cut = __first; + _BidirectionalIterator __second_cut = __middle; + _Distance __len11 = 0; + _Distance __len22 = 0; + if (__len1 > __len2) + { + __len11 = __len1 / 2; + std::advance(__first_cut, __len11); + __second_cut + = std::__lower_bound(__middle, __last, *__first_cut, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + __len22 = std::distance(__middle, __second_cut); + } + else + { + __len22 = __len2 / 2; + std::advance(__second_cut, __len22); + __first_cut + = std::__upper_bound(__first, __middle, *__second_cut, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + __len11 = std::distance(__first, __first_cut); + } + + _BidirectionalIterator __new_middle + = std::__rotate_adaptive(__first_cut, __middle, __second_cut, + __len1 - __len11, __len22, __buffer, + __buffer_size); + std::__merge_adaptive(__first, __first_cut, __new_middle, __len11, + __len22, __buffer, __buffer_size, __comp); + std::__merge_adaptive(__new_middle, __second_cut, __last, + __len1 - __len11, + __len2 - __len22, __buffer, + __buffer_size, __comp); + } + } + + /// This is a helper function for the merge routines. + template + void + __merge_without_buffer(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Distance __len1, _Distance __len2, + _Compare __comp) + { + if (__len1 == 0 || __len2 == 0) + return; + + if (__len1 + __len2 == 2) + { + if (__comp(__middle, __first)) + std::iter_swap(__first, __middle); + return; + } + + _BidirectionalIterator __first_cut = __first; + _BidirectionalIterator __second_cut = __middle; + _Distance __len11 = 0; + _Distance __len22 = 0; + if (__len1 > __len2) + { + __len11 = __len1 / 2; + std::advance(__first_cut, __len11); + __second_cut + = std::__lower_bound(__middle, __last, *__first_cut, + __gnu_cxx::__ops::__iter_comp_val(__comp)); + __len22 = std::distance(__middle, __second_cut); + } + else + { + __len22 = __len2 / 2; + std::advance(__second_cut, __len22); + __first_cut + = std::__upper_bound(__first, __middle, *__second_cut, + __gnu_cxx::__ops::__val_comp_iter(__comp)); + __len11 = std::distance(__first, __first_cut); + } + + _BidirectionalIterator __new_middle + = std::rotate(__first_cut, __middle, __second_cut); + std::__merge_without_buffer(__first, __first_cut, __new_middle, + __len11, __len22, __comp); + std::__merge_without_buffer(__new_middle, __second_cut, __last, + __len1 - __len11, __len2 - __len22, __comp); + } + + template + void + __inplace_merge(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Compare __comp) + { + typedef typename iterator_traits<_BidirectionalIterator>::value_type + _ValueType; + typedef typename iterator_traits<_BidirectionalIterator>::difference_type + _DistanceType; + typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf; + + if (__first == __middle || __middle == __last) + return; + + const _DistanceType __len1 = std::distance(__first, __middle); + const _DistanceType __len2 = std::distance(__middle, __last); + + // __merge_adaptive will use a buffer for the smaller of + // [first,middle) and [middle,last). + _TmpBuf __buf(__first, std::min(__len1, __len2)); + + if (__buf.begin() == 0) + std::__merge_without_buffer + (__first, __middle, __last, __len1, __len2, __comp); + else + std::__merge_adaptive + (__first, __middle, __last, __len1, __len2, __buf.begin(), + _DistanceType(__buf.size()), __comp); + } + + /** + * @brief Merges two sorted ranges in place. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Merges two sorted and consecutive ranges, [__first,__middle) and + * [__middle,__last), and puts the result in [__first,__last). The + * output will be sorted. The sort is @e stable, that is, for + * equivalent elements in the two ranges, elements from the first + * range will always come before elements from the second. + * + * If enough additional memory is available, this takes (__last-__first)-1 + * comparisons. Otherwise an NlogN algorithm is used, where N is + * distance(__first,__last). + */ + template + inline void + inplace_merge(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_sorted(__first, __middle); + __glibcxx_requires_sorted(__middle, __last); + __glibcxx_requires_irreflexive(__first, __last); + + std::__inplace_merge(__first, __middle, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Merges two sorted ranges in place. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @param __comp A functor to use for comparisons. + * @return Nothing. + * + * Merges two sorted and consecutive ranges, [__first,__middle) and + * [middle,last), and puts the result in [__first,__last). The output will + * be sorted. The sort is @e stable, that is, for equivalent + * elements in the two ranges, elements from the first range will always + * come before elements from the second. + * + * If enough additional memory is available, this takes (__last-__first)-1 + * comparisons. Otherwise an NlogN algorithm is used, where N is + * distance(__first,__last). + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + inline void + inplace_merge(_BidirectionalIterator __first, + _BidirectionalIterator __middle, + _BidirectionalIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_BidirectionalIterator>::value_type, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_sorted_pred(__first, __middle, __comp); + __glibcxx_requires_sorted_pred(__middle, __last, __comp); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + std::__inplace_merge(__first, __middle, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + + /// This is a helper function for the __merge_sort_loop routines. + template + _OutputIterator + __move_merge(_InputIterator __first1, _InputIterator __last1, + _InputIterator __first2, _InputIterator __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + *__result = _GLIBCXX_MOVE(*__first2); + ++__first2; + } + else + { + *__result = _GLIBCXX_MOVE(*__first1); + ++__first1; + } + ++__result; + } + return _GLIBCXX_MOVE3(__first2, __last2, + _GLIBCXX_MOVE3(__first1, __last1, + __result)); + } + + template + void + __merge_sort_loop(_RandomAccessIterator1 __first, + _RandomAccessIterator1 __last, + _RandomAccessIterator2 __result, _Distance __step_size, + _Compare __comp) + { + const _Distance __two_step = 2 * __step_size; + + while (__last - __first >= __two_step) + { + __result = std::__move_merge(__first, __first + __step_size, + __first + __step_size, + __first + __two_step, + __result, __comp); + __first += __two_step; + } + __step_size = std::min(_Distance(__last - __first), __step_size); + + std::__move_merge(__first, __first + __step_size, + __first + __step_size, __last, __result, __comp); + } + + template + _GLIBCXX20_CONSTEXPR + void + __chunk_insertion_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Distance __chunk_size, _Compare __comp) + { + while (__last - __first >= __chunk_size) + { + std::__insertion_sort(__first, __first + __chunk_size, __comp); + __first += __chunk_size; + } + std::__insertion_sort(__first, __last, __comp); + } + + enum { _S_chunk_size = 7 }; + + template + void + __merge_sort_with_buffer(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Pointer __buffer, _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _Distance; + + const _Distance __len = __last - __first; + const _Pointer __buffer_last = __buffer + __len; + + _Distance __step_size = _S_chunk_size; + std::__chunk_insertion_sort(__first, __last, __step_size, __comp); + + while (__step_size < __len) + { + std::__merge_sort_loop(__first, __last, __buffer, + __step_size, __comp); + __step_size *= 2; + std::__merge_sort_loop(__buffer, __buffer_last, __first, + __step_size, __comp); + __step_size *= 2; + } + } + + template + void + __stable_sort_adaptive(_RandomAccessIterator __first, + _RandomAccessIterator __last, + _Pointer __buffer, _Distance __buffer_size, + _Compare __comp) + { + const _Distance __len = (__last - __first + 1) / 2; + const _RandomAccessIterator __middle = __first + __len; + if (__len > __buffer_size) + { + std::__stable_sort_adaptive(__first, __middle, __buffer, + __buffer_size, __comp); + std::__stable_sort_adaptive(__middle, __last, __buffer, + __buffer_size, __comp); + } + else + { + std::__merge_sort_with_buffer(__first, __middle, __buffer, __comp); + std::__merge_sort_with_buffer(__middle, __last, __buffer, __comp); + } + + std::__merge_adaptive(__first, __middle, __last, + _Distance(__middle - __first), + _Distance(__last - __middle), + __buffer, __buffer_size, + __comp); + } + + /// This is a helper function for the stable sorting routines. + template + void + __inplace_stable_sort(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + if (__last - __first < 15) + { + std::__insertion_sort(__first, __last, __comp); + return; + } + _RandomAccessIterator __middle = __first + (__last - __first) / 2; + std::__inplace_stable_sort(__first, __middle, __comp); + std::__inplace_stable_sort(__middle, __last, __comp); + std::__merge_without_buffer(__first, __middle, __last, + __middle - __first, + __last - __middle, + __comp); + } + + // stable_sort + + // Set algorithms: includes, set_union, set_intersection, set_difference, + // set_symmetric_difference. All of these algorithms have the precondition + // that their input ranges are sorted and the postcondition that their output + // ranges are sorted. + + template + _GLIBCXX20_CONSTEXPR + bool + __includes(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + return false; + if (!__comp(__first1, __first2)) + ++__first2; + ++__first1; + } + + return __first2 == __last2; + } + + /** + * @brief Determines whether all elements of a sequence exists in a range. + * @param __first1 Start of search range. + * @param __last1 End of search range. + * @param __first2 Start of sequence + * @param __last2 End of sequence. + * @return True if each element in [__first2,__last2) is contained in order + * within [__first1,__last1). False otherwise. + * @ingroup set_algorithms + * + * This operation expects both [__first1,__last1) and + * [__first2,__last2) to be sorted. Searches for the presence of + * each element in [__first2,__last2) within [__first1,__last1). + * The iterators over each range only move forward, so this is a + * linear algorithm. If an element in [__first2,__last2) is not + * found before the search iterator reaches @p __last2, false is + * returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + includes(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return std::__includes(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Determines whether all elements of a sequence exists in a range + * using comparison. + * @ingroup set_algorithms + * @param __first1 Start of search range. + * @param __last1 End of search range. + * @param __first2 Start of sequence + * @param __last2 End of sequence. + * @param __comp Comparison function to use. + * @return True if each element in [__first2,__last2) is contained + * in order within [__first1,__last1) according to comp. False + * otherwise. @ingroup set_algorithms + * + * This operation expects both [__first1,__last1) and + * [__first2,__last2) to be sorted. Searches for the presence of + * each element in [__first2,__last2) within [__first1,__last1), + * using comp to decide. The iterators over each range only move + * forward, so this is a linear algorithm. If an element in + * [__first2,__last2) is not found before the search iterator + * reaches @p __last2, false is returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + includes(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return std::__includes(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + // nth_element + // merge + // set_difference + // set_intersection + // set_union + // stable_sort + // set_symmetric_difference + // min_element + // max_element + + template + _GLIBCXX20_CONSTEXPR + bool + __next_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + if (__first == __last) + return false; + _BidirectionalIterator __i = __first; + ++__i; + if (__i == __last) + return false; + __i = __last; + --__i; + + for(;;) + { + _BidirectionalIterator __ii = __i; + --__i; + if (__comp(__i, __ii)) + { + _BidirectionalIterator __j = __last; + while (!__comp(__i, --__j)) + {} + std::iter_swap(__i, __j); + std::__reverse(__ii, __last, + std::__iterator_category(__first)); + return true; + } + if (__i == __first) + { + std::__reverse(__first, __last, + std::__iterator_category(__first)); + return false; + } + } + } + + /** + * @brief Permute range into the next @e dictionary ordering. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return False if wrapped to first permutation, true otherwise. + * + * Treats all permutations of the range as a set of @e dictionary sorted + * sequences. Permutes the current sequence into the next one of this set. + * Returns true if there are more sequences to generate. If the sequence + * is the largest of the set, the smallest is generated and false returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + next_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__next_permutation + (__first, __last, __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Permute range into the next @e dictionary ordering using + * comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp A comparison functor. + * @return False if wrapped to first permutation, true otherwise. + * + * Treats all permutations of the range [__first,__last) as a set of + * @e dictionary sorted sequences ordered by @p __comp. Permutes the current + * sequence into the next one of this set. Returns true if there are more + * sequences to generate. If the sequence is the largest of the set, the + * smallest is generated and false returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + next_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_BidirectionalIterator>::value_type, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__next_permutation + (__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + bool + __prev_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + if (__first == __last) + return false; + _BidirectionalIterator __i = __first; + ++__i; + if (__i == __last) + return false; + __i = __last; + --__i; + + for(;;) + { + _BidirectionalIterator __ii = __i; + --__i; + if (__comp(__ii, __i)) + { + _BidirectionalIterator __j = __last; + while (!__comp(--__j, __i)) + {} + std::iter_swap(__i, __j); + std::__reverse(__ii, __last, + std::__iterator_category(__first)); + return true; + } + if (__i == __first) + { + std::__reverse(__first, __last, + std::__iterator_category(__first)); + return false; + } + } + } + + /** + * @brief Permute range into the previous @e dictionary ordering. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return False if wrapped to last permutation, true otherwise. + * + * Treats all permutations of the range as a set of @e dictionary sorted + * sequences. Permutes the current sequence into the previous one of this + * set. Returns true if there are more sequences to generate. If the + * sequence is the smallest of the set, the largest is generated and false + * returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + prev_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__prev_permutation(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Permute range into the previous @e dictionary ordering using + * comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp A comparison functor. + * @return False if wrapped to last permutation, true otherwise. + * + * Treats all permutations of the range [__first,__last) as a set of + * @e dictionary sorted sequences ordered by @p __comp. Permutes the current + * sequence into the previous one of this set. Returns true if there are + * more sequences to generate. If the sequence is the smallest of the set, + * the largest is generated and false returned. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + prev_permutation(_BidirectionalIterator __first, + _BidirectionalIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_BidirectionalIterator>::value_type, + typename iterator_traits<_BidirectionalIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__prev_permutation(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + // replace + // replace_if + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __replace_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _Predicate __pred, const _Tp& __new_value) + { + for (; __first != __last; ++__first, (void)++__result) + if (__pred(__first)) + *__result = __new_value; + else + *__result = *__first; + return __result; + } + + /** + * @brief Copy a sequence, replacing each element of one value with another + * value. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __old_value The value to be replaced. + * @param __new_value The replacement value. + * @return The end of the output sequence, @p result+(last-first). + * + * Copies each element in the input range @p [__first,__last) to the + * output range @p [__result,__result+(__last-__first)) replacing elements + * equal to @p __old_value with @p __new_value. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + replace_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + const _Tp& __old_value, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__replace_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__iter_equals_val(__old_value), + __new_value); + } + + /** + * @brief Copy a sequence, replacing each value for which a predicate + * returns true with another value. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __pred A predicate. + * @param __new_value The replacement value. + * @return The end of the output sequence, @p __result+(__last-__first). + * + * Copies each element in the range @p [__first,__last) to the range + * @p [__result,__result+(__last-__first)) replacing elements for which + * @p __pred returns true with @p __new_value. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + replace_copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _Predicate __pred, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__replace_copy_if(__first, __last, __result, + __gnu_cxx::__ops::__pred_iter(__pred), + __new_value); + } + +#if __cplusplus >= 201103L + /** + * @brief Determines whether the elements of a sequence are sorted. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return True if the elements are sorted, false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_sorted(_ForwardIterator __first, _ForwardIterator __last) + { return std::is_sorted_until(__first, __last) == __last; } + + /** + * @brief Determines whether the elements of a sequence are sorted + * according to a comparison functor. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return True if the elements are sorted, false otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_sorted(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { return std::is_sorted_until(__first, __last, __comp) == __last; } + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + if (__first == __last) + return __last; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, (void)++__next) + if (__comp(__next, __first)) + return __next; + return __next; + } + + /** + * @brief Determines the end of a sorted sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return An iterator pointing to the last iterator i in [__first, __last) + * for which the range [__first, i) is sorted. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__is_sorted_until(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Determines the end of a sorted sequence using comparison functor. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return An iterator pointing to the last iterator i in [__first, __last) + * for which the range [__first, i) is sorted. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__is_sorted_until(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /** + * @brief Determines min and max at once as an ordered pair. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return A pair(__b, __a) if __b is smaller than __a, pair(__a, + * __b) otherwise. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair + minmax(const _Tp& __a, const _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + + return __b < __a ? pair(__b, __a) + : pair(__a, __b); + } + + /** + * @brief Determines min and max at once as an ordered pair. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @param __comp A @link comparison_functors comparison functor @endlink. + * @return A pair(__b, __a) if __b is smaller than __a, pair(__a, + * __b) otherwise. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair + minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) + { + return __comp(__b, __a) ? pair(__b, __a) + : pair(__a, __b); + } + + template + _GLIBCXX14_CONSTEXPR + pair<_ForwardIterator, _ForwardIterator> + __minmax_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + _ForwardIterator __next = __first; + if (__first == __last + || ++__next == __last) + return std::make_pair(__first, __first); + + _ForwardIterator __min{}, __max{}; + if (__comp(__next, __first)) + { + __min = __next; + __max = __first; + } + else + { + __min = __first; + __max = __next; + } + + __first = __next; + ++__first; + + while (__first != __last) + { + __next = __first; + if (++__next == __last) + { + if (__comp(__first, __min)) + __min = __first; + else if (!__comp(__first, __max)) + __max = __first; + break; + } + + if (__comp(__next, __first)) + { + if (__comp(__next, __min)) + __min = __next; + if (!__comp(__first, __max)) + __max = __first; + } + else + { + if (__comp(__first, __min)) + __min = __first; + if (!__comp(__next, __max)) + __max = __next; + } + + __first = __next; + ++__first; + } + + return std::make_pair(__min, __max); + } + + /** + * @brief Return a pair of iterators pointing to the minimum and maximum + * elements in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return make_pair(m, M), where m is the first iterator i in + * [__first, __last) such that no other element in the range is + * smaller, and where M is the last iterator i in [__first, __last) + * such that no other element in the range is larger. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + minmax_element(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return std::__minmax_element(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return a pair of iterators pointing to the minimum and maximum + * elements in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor. + * @return make_pair(m, M), where m is the first iterator i in + * [__first, __last) such that no other element in the range is + * smaller, and where M is the last iterator i in [__first, __last) + * such that no other element in the range is larger. + */ + template + _GLIBCXX14_CONSTEXPR + inline pair<_ForwardIterator, _ForwardIterator> + minmax_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return std::__minmax_element(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + // N2722 + DR 915. + template + _GLIBCXX14_CONSTEXPR + inline _Tp + min(initializer_list<_Tp> __l) + { return *std::min_element(__l.begin(), __l.end()); } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + min(initializer_list<_Tp> __l, _Compare __comp) + { return *std::min_element(__l.begin(), __l.end(), __comp); } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + max(initializer_list<_Tp> __l) + { return *std::max_element(__l.begin(), __l.end()); } + + template + _GLIBCXX14_CONSTEXPR + inline _Tp + max(initializer_list<_Tp> __l, _Compare __comp) + { return *std::max_element(__l.begin(), __l.end(), __comp); } + + template + _GLIBCXX14_CONSTEXPR + inline pair<_Tp, _Tp> + minmax(initializer_list<_Tp> __l) + { + pair __p = + std::minmax_element(__l.begin(), __l.end()); + return std::make_pair(*__p.first, *__p.second); + } + + template + _GLIBCXX14_CONSTEXPR + inline pair<_Tp, _Tp> + minmax(initializer_list<_Tp> __l, _Compare __comp) + { + pair __p = + std::minmax_element(__l.begin(), __l.end(), __comp); + return std::make_pair(*__p.first, *__p.second); + } + + /** + * @brief Checks whether a permutation of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __pred A binary predicate. + * @return true if there exists a permutation of the elements in + * the range [__first2, __first2 + (__last1 - __first1)), + * beginning with ForwardIterator2 begin, such that + * equal(__first1, __last1, __begin, __pred) returns true; + * otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _BinaryPredicate __pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + + return std::__is_permutation(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_comp_iter(__pred)); + } + +#if __cplusplus > 201103L + template + _GLIBCXX20_CONSTEXPR + bool + __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred) + { + using _Cat1 + = typename iterator_traits<_ForwardIterator1>::iterator_category; + using _Cat2 + = typename iterator_traits<_ForwardIterator2>::iterator_category; + using _It1_is_RA = is_same<_Cat1, random_access_iterator_tag>; + using _It2_is_RA = is_same<_Cat2, random_access_iterator_tag>; + constexpr bool __ra_iters = _It1_is_RA() && _It2_is_RA(); + if (__ra_iters) + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 != __d2) + return false; + } + + // Efficiently compare identical prefixes: O(N) if sequences + // have the same elements in the same order. + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!__pred(__first1, __first2)) + break; + + if (__ra_iters) + { + if (__first1 == __last1) + return true; + } + else + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 == 0 && __d2 == 0) + return true; + if (__d1 != __d2) + return false; + } + + for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan) + { + if (__scan != std::__find_if(__first1, __scan, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))) + continue; // We've seen this one before. + + auto __matches = std::__count_if(__first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)); + if (0 == __matches + || std::__count_if(__scan, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)) + != __matches) + return false; + } + return true; + } + + /** + * @brief Checks whether a permutaion of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of first range. + * @return true if there exists a permutation of the elements in the range + * [__first2, __last2), beginning with ForwardIterator2 begin, + * such that equal(__first1, __last1, begin) returns true; + * otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) + { + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return + std::__is_permutation(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Checks whether a permutation of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of first range. + * @param __pred A binary predicate. + * @return true if there exists a permutation of the elements in the range + * [__first2, __last2), beginning with ForwardIterator2 begin, + * such that equal(__first1, __last1, __begin, __pred) returns true; + * otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred) + { + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__is_permutation(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__pred)); + } + +#if __cplusplus > 201402L + +#define __cpp_lib_clamp 201603 + + /** + * @brief Returns the value clamped between lo and hi. + * @ingroup sorting_algorithms + * @param __val A value of arbitrary type. + * @param __lo A lower limit of arbitrary type. + * @param __hi An upper limit of arbitrary type. + * @return max(__val, __lo) if __val < __hi or min(__val, __hi) otherwise. + */ + template + constexpr const _Tp& + clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi) + { + __glibcxx_assert(!(__hi < __lo)); + return (__val < __lo) ? __lo : (__hi < __val) ? __hi : __val; + } + + /** + * @brief Returns the value clamped between lo and hi. + * @ingroup sorting_algorithms + * @param __val A value of arbitrary type. + * @param __lo A lower limit of arbitrary type. + * @param __hi An upper limit of arbitrary type. + * @param __comp A comparison functor. + * @return max(__val, __lo, __comp) if __comp(__val, __hi) + * or min(__val, __hi, __comp) otherwise. + */ + template + constexpr const _Tp& + clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi, _Compare __comp) + { + __glibcxx_assert(!__comp(__hi, __lo)); + return __comp(__val, __lo) ? __lo : __comp(__hi, __val) ? __hi : __val; + } +#endif // C++17 +#endif // C++14 + +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + /** + * @brief Generate two uniformly distributed integers using a + * single distribution invocation. + * @param __b0 The upper bound for the first integer. + * @param __b1 The upper bound for the second integer. + * @param __g A UniformRandomBitGenerator. + * @return A pair (i, j) with i and j uniformly distributed + * over [0, __b0) and [0, __b1), respectively. + * + * Requires: __b0 * __b1 <= __g.max() - __g.min(). + * + * Using uniform_int_distribution with a range that is very + * small relative to the range of the generator ends up wasting + * potentially expensively generated randomness, since + * uniform_int_distribution does not store leftover randomness + * between invocations. + * + * If we know we want two integers in ranges that are sufficiently + * small, we can compose the ranges, use a single distribution + * invocation, and significantly reduce the waste. + */ + template + pair<_IntType, _IntType> + __gen_two_uniform_ints(_IntType __b0, _IntType __b1, + _UniformRandomBitGenerator&& __g) + { + _IntType __x + = uniform_int_distribution<_IntType>{0, (__b0 * __b1) - 1}(__g); + return std::make_pair(__x / __b1, __x % __b1); + } + + /** + * @brief Shuffle the elements of a sequence using a uniform random + * number generator. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __g A UniformRandomNumberGenerator (26.5.1.3). + * @return Nothing. + * + * Reorders the elements in the range @p [__first,__last) using @p __g to + * provide random numbers. + */ + template + void + shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, + _UniformRandomNumberGenerator&& __g) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return; + + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + typedef typename std::make_unsigned<_DistanceType>::type __ud_type; + typedef typename std::uniform_int_distribution<__ud_type> __distr_type; + typedef typename __distr_type::param_type __p_type; + + typedef typename remove_reference<_UniformRandomNumberGenerator>::type + _Gen; + typedef typename common_type::type + __uc_type; + + const __uc_type __urngrange = __g.max() - __g.min(); + const __uc_type __urange = __uc_type(__last - __first); + + if (__urngrange / __urange >= __urange) + // I.e. (__urngrange >= __urange * __urange) but without wrap issues. + { + _RandomAccessIterator __i = __first + 1; + + // Since we know the range isn't empty, an even number of elements + // means an uneven number of elements /to swap/, in which case we + // do the first one up front: + + if ((__urange % 2) == 0) + { + __distr_type __d{0, 1}; + std::iter_swap(__i++, __first + __d(__g)); + } + + // Now we know that __last - __i is even, so we do the rest in pairs, + // using a single distribution invocation to produce swap positions + // for two successive elements at a time: + + while (__i != __last) + { + const __uc_type __swap_range = __uc_type(__i - __first) + 1; + + const pair<__uc_type, __uc_type> __pospos = + __gen_two_uniform_ints(__swap_range, __swap_range + 1, __g); + + std::iter_swap(__i++, __first + __pospos.first); + std::iter_swap(__i++, __first + __pospos.second); + } + + return; + } + + __distr_type __d; + + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + std::iter_swap(__i, __first + __d(__g, __p_type(0, __i - __first))); + } +#endif + +#endif // C++11 + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + + /** + * @brief Apply a function to every element of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __f A unary function object. + * @return @p __f + * + * Applies the function object @p __f to each element in the range + * @p [first,last). @p __f must not modify the order of the sequence. + * If @p __f has a return value it is ignored. + */ + template + _GLIBCXX20_CONSTEXPR + _Function + for_each(_InputIterator __first, _InputIterator __last, _Function __f) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_requires_valid_range(__first, __last); + for (; __first != __last; ++__first) + __f(*__first); + return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant. + } + +#if __cplusplus >= 201703L + /** + * @brief Apply a function to every element of a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __n A value convertible to an integer. + * @param __f A unary function object. + * @return `__first+__n` + * + * Applies the function object `__f` to each element in the range + * `[first, first+n)`. `__f` must not modify the order of the sequence. + * If `__f` has a return value it is ignored. + */ + template + _GLIBCXX20_CONSTEXPR + _InputIterator + for_each_n(_InputIterator __first, _Size __n, _Function __f) + { + auto __n2 = std::__size_to_integer(__n); + using _Cat = typename iterator_traits<_InputIterator>::iterator_category; + if constexpr (is_base_of_v) + { + if (__n2 <= 0) + return __first; + auto __last = __first + __n2; + std::for_each(__first, __last, std::move(__f)); + return __last; + } + else + { + while (__n2-->0) + { + __f(*__first); + ++__first; + } + return __first; + } + } +#endif // C++17 + + /** + * @brief Find the first occurrence of a value in a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __val The value to find. + * @return The first iterator @c i in the range @p [__first,__last) + * such that @c *i == @p __val, or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + find(_InputIterator __first, _InputIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + return std::__find_if(__first, __last, + __gnu_cxx::__ops::__iter_equals_val(__val)); + } + + /** + * @brief Find the first element in a sequence for which a + * predicate is true. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return The first iterator @c i in the range @p [__first,__last) + * such that @p __pred(*i) is true, or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + find_if(_InputIterator __first, _InputIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__find_if(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /** + * @brief Find element from a set in a sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of match candidates. + * @param __last2 End of match candidates. + * @return The first iterator @c i in the range + * @p [__first1,__last1) such that @c *i == @p *(i2) such that i2 is an + * iterator in [__first2,__last2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for an element that is + * equal to some element in the range [__first2,__last2). If + * found, returns an iterator in the range [__first1,__last1), + * otherwise returns @p __last1. + */ + template + _GLIBCXX20_CONSTEXPR + _InputIterator + find_first_of(_InputIterator __first1, _InputIterator __last1, + _ForwardIterator __first2, _ForwardIterator __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + for (; __first1 != __last1; ++__first1) + for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter) + if (*__first1 == *__iter) + return __first1; + return __last1; + } + + /** + * @brief Find element from a set in a sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first1 Start of range to search. + * @param __last1 End of range to search. + * @param __first2 Start of match candidates. + * @param __last2 End of match candidates. + * @param __comp Predicate to use. + * @return The first iterator @c i in the range + * @p [__first1,__last1) such that @c comp(*i, @p *(i2)) is true + * and i2 is an iterator in [__first2,__last2), or @p __last1 if no + * such iterator exists. + * + + * Searches the range @p [__first1,__last1) for an element that is + * equal to some element in the range [__first2,__last2). If + * found, returns an iterator in the range [__first1,__last1), + * otherwise returns @p __last1. + */ + template + _GLIBCXX20_CONSTEXPR + _InputIterator + find_first_of(_InputIterator __first1, _InputIterator __last1, + _ForwardIterator __first2, _ForwardIterator __last2, + _BinaryPredicate __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_InputIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + for (; __first1 != __last1; ++__first1) + for (_ForwardIterator __iter = __first2; __iter != __last2; ++__iter) + if (__comp(*__first1, *__iter)) + return __first1; + return __last1; + } + + /** + * @brief Find two adjacent values in a sequence that are equal. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @return The first iterator @c i such that @c i and @c i+1 are both + * valid iterators in @p [__first,__last) and such that @c *i == @c *(i+1), + * or @p __last if no such iterator exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + adjacent_find(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_EqualityComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__adjacent_find(__first, __last, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Find two adjacent values in a sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __binary_pred A binary predicate. + * @return The first iterator @c i such that @c i and @c i+1 are both + * valid iterators in @p [__first,__last) and such that + * @p __binary_pred(*i,*(i+1)) is true, or @p __last if no such iterator + * exists. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + adjacent_find(_ForwardIterator __first, _ForwardIterator __last, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__adjacent_find(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } + + /** + * @brief Count the number of copies of a value in a sequence. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __value The value to be counted. + * @return The number of iterators @c i in the range @p [__first,__last) + * for which @c *i == @p __value + */ + template + _GLIBCXX20_CONSTEXPR + inline typename iterator_traits<_InputIterator>::difference_type + count(_InputIterator __first, _InputIterator __last, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__count_if(__first, __last, + __gnu_cxx::__ops::__iter_equals_val(__value)); + } + + /** + * @brief Count the elements of a sequence for which a predicate is true. + * @ingroup non_mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __pred A predicate. + * @return The number of iterators @c i in the range @p [__first,__last) + * for which @p __pred(*i) is true. + */ + template + _GLIBCXX20_CONSTEXPR + inline typename iterator_traits<_InputIterator>::difference_type + count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__count_if(__first, __last, + __gnu_cxx::__ops::__pred_iter(__pred)); + } + + /** + * @brief Search a sequence for a matching sub-sequence. + * @ingroup non_mutating_algorithms + * @param __first1 A forward iterator. + * @param __last1 A forward iterator. + * @param __first2 A forward iterator. + * @param __last2 A forward iterator. + * @return The first iterator @c i in the range @p + * [__first1,__last1-(__last2-__first2)) such that @c *(i+N) == @p + * *(__first2+N) for each @c N in the range @p + * [0,__last2-__first2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2) and returns an iterator to the first element + * of the sub-sequence, or @p __last1 if the sub-sequence is not + * found. + * + * Because the sub-sequence must lie completely within the range @p + * [__first1,__last1) it must start at a position less than @p + * __last1-(__last2-__first2) where @p __last2-__first2 is the + * length of the sub-sequence. + * + * This means that the returned iterator @c i will be in the range + * @p [__first1,__last1-(__last2-__first2)) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__search(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Search a sequence for a matching sub-sequence using a predicate. + * @ingroup non_mutating_algorithms + * @param __first1 A forward iterator. + * @param __last1 A forward iterator. + * @param __first2 A forward iterator. + * @param __last2 A forward iterator. + * @param __predicate A binary predicate. + * @return The first iterator @c i in the range + * @p [__first1,__last1-(__last2-__first2)) such that + * @p __predicate(*(i+N),*(__first2+N)) is true for each @c N in the range + * @p [0,__last2-__first2), or @p __last1 if no such iterator exists. + * + * Searches the range @p [__first1,__last1) for a sub-sequence that + * compares equal value-by-value with the sequence given by @p + * [__first2,__last2), using @p __predicate to determine equality, + * and returns an iterator to the first element of the + * sub-sequence, or @p __last1 if no such iterator exists. + * + * @see search(_ForwardIter1, _ForwardIter1, _ForwardIter2, _ForwardIter2) + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator1 + search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __predicate) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__search(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__predicate)); + } + + /** + * @brief Search a sequence for a number of consecutive values. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __count The number of consecutive values. + * @param __val The value to find. + * @return The first iterator @c i in the range @p + * [__first,__last-__count) such that @c *(i+N) == @p __val for + * each @c N in the range @p [0,__count), or @p __last if no such + * iterator exists. + * + * Searches the range @p [__first,__last) for @p count consecutive elements + * equal to @p __val. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__search_n(__first, __last, __count, + __gnu_cxx::__ops::__iter_equals_val(__val)); + } + + + /** + * @brief Search a sequence for a number of consecutive values using a + * predicate. + * @ingroup non_mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __count The number of consecutive values. + * @param __val The value to find. + * @param __binary_pred A binary predicate. + * @return The first iterator @c i in the range @p + * [__first,__last-__count) such that @p + * __binary_pred(*(i+N),__val) is true for each @c N in the range + * @p [0,__count), or @p __last if no such iterator exists. + * + * Searches the range @p [__first,__last) for @p __count + * consecutive elements for which the predicate returns true. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + search_n(_ForwardIterator __first, _ForwardIterator __last, + _Integer __count, const _Tp& __val, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate, + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__search_n(__first, __last, __count, + __gnu_cxx::__ops::__iter_comp_val(__binary_pred, __val)); + } + +#if __cplusplus >= 201703L + /** @brief Search a sequence using a Searcher object. + * + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __searcher A callable object. + * @return @p __searcher(__first,__last).first + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + search(_ForwardIterator __first, _ForwardIterator __last, + const _Searcher& __searcher) + { return __searcher(__first, __last).first; } +#endif + + /** + * @brief Perform an operation on a sequence. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __unary_op A unary operator. + * @return An output iterator equal to @p __result+(__last-__first). + * + * Applies the operator to each element in the input range and assigns + * the results to successive elements of the output sequence. + * Evaluates @p *(__result+N)=unary_op(*(__first+N)) for each @c N in the + * range @p [0,__last-__first). + * + * @p unary_op must not alter its argument. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _UnaryOperation __unary_op) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + // "the type returned by a _UnaryOperation" + __typeof__(__unary_op(*__first))>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first, (void)++__result) + *__result = __unary_op(*__first); + return __result; + } + + /** + * @brief Perform an operation on corresponding elements of two sequences. + * @ingroup mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __result An output iterator. + * @param __binary_op A binary operator. + * @return An output iterator equal to @p result+(last-first). + * + * Applies the operator to the corresponding elements in the two + * input ranges and assigns the results to successive elements of the + * output sequence. + * Evaluates @p + * *(__result+N)=__binary_op(*(__first1+N),*(__first2+N)) for each + * @c N in the range @p [0,__last1-__first1). + * + * @p binary_op must not alter either of its arguments. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + transform(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _OutputIterator __result, + _BinaryOperation __binary_op) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + // "the type returned by a _BinaryOperation" + __typeof__(__binary_op(*__first1,*__first2))>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2, ++__result) + *__result = __binary_op(*__first1, *__first2); + return __result; + } + + /** + * @brief Replace each occurrence of one value in a sequence with another + * value. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __old_value The value to be replaced. + * @param __new_value The replacement value. + * @return replace() returns no value. + * + * For each iterator @c i in the range @p [__first,__last) if @c *i == + * @p __old_value then the assignment @c *i = @p __new_value is performed. + */ + template + _GLIBCXX20_CONSTEXPR + void + replace(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __old_value, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_function_requires(_ConvertibleConcept<_Tp, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (*__first == __old_value) + *__first = __new_value; + } + + /** + * @brief Replace each value in a sequence for which a predicate returns + * true with another value. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate. + * @param __new_value The replacement value. + * @return replace_if() returns no value. + * + * For each iterator @c i in the range @p [__first,__last) if @p __pred(*i) + * is true then the assignment @c *i = @p __new_value is performed. + */ + template + _GLIBCXX20_CONSTEXPR + void + replace_if(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, const _Tp& __new_value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_Tp, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + if (__pred(*__first)) + *__first = __new_value; + } + + /** + * @brief Assign the result of a function object to each value in a + * sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __gen A function object taking no arguments and returning + * std::iterator_traits<_ForwardIterator>::value_type + * @return generate() returns no value. + * + * Performs the assignment @c *i = @p __gen() for each @c i in the range + * @p [__first,__last). + */ + template + _GLIBCXX20_CONSTEXPR + void + generate(_ForwardIterator __first, _ForwardIterator __last, + _Generator __gen) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_GeneratorConcept<_Generator, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + *__first = __gen(); + } + + /** + * @brief Assign the result of a function object to each value in a + * sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __n The length of the sequence. + * @param __gen A function object taking no arguments and returning + * std::iterator_traits<_ForwardIterator>::value_type + * @return The end of the sequence, @p __first+__n + * + * Performs the assignment @c *i = @p __gen() for each @c i in the range + * @p [__first,__first+__n). + * + * If @p __n is negative, the function does nothing and returns @p __first. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 865. More algorithms that throw away information + // DR 426. search_n(), fill_n(), and generate_n() with negative n + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + generate_n(_OutputIterator __first, _Size __n, _Generator __gen) + { + // concept requirements + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + // "the type returned by a _Generator" + __typeof__(__gen())>) + + typedef __decltype(std::__size_to_integer(__n)) _IntSize; + for (_IntSize __niter = std::__size_to_integer(__n); + __niter > 0; --__niter, (void) ++__first) + *__first = __gen(); + return __first; + } + + /** + * @brief Copy a sequence, removing consecutive duplicate values. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) to the range + * beginning at @p __result, except that only the first element is copied + * from groups of consecutive elements that compare equal. + * unique_copy() is stable, so the relative order of elements that are + * copied is unchanged. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 241. Does unique_copy() require CopyConstructible and Assignable? + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 538. 241 again: Does unique_copy() require CopyConstructible and + * Assignable? + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_function_requires(_EqualityComparableConcept< + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + return std::__unique_copy(__first, __last, __result, + __gnu_cxx::__ops::__iter_equal_to_iter(), + std::__iterator_category(__first), + std::__iterator_category(__result)); + } + + /** + * @brief Copy a sequence, removing consecutive values using a predicate. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @param __binary_pred A binary predicate. + * @return An iterator designating the end of the resulting sequence. + * + * Copies each element in the range @p [__first,__last) to the range + * beginning at @p __result, except that only the first element is copied + * from groups of consecutive elements for which @p __binary_pred returns + * true. + * unique_copy() is stable, so the relative order of elements that are + * copied is unchanged. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 241. Does unique_copy() require CopyConstructible and Assignable? + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + unique_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + _BinaryPredicate __binary_pred) + { + // concept requirements -- predicates checked later + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + return std::__unique_copy(__first, __last, __result, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred), + std::__iterator_category(__first), + std::__iterator_category(__result)); + } + +#if _GLIBCXX_HOSTED + /** + * @brief Randomly shuffle the elements of a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @return Nothing. + * + * Reorder the elements in the range @p [__first,__last) using a random + * distribution, so that every possible ordering of the sequence is + * equally likely. + */ + template + inline void + random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first != __last) + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + // XXX rand() % N is not uniformly distributed + _RandomAccessIterator __j = __first + + std::rand() % ((__i - __first) + 1); + if (__i != __j) + std::iter_swap(__i, __j); + } + } +#endif + + /** + * @brief Shuffle the elements of a sequence using a random number + * generator. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __rand The RNG functor or function. + * @return Nothing. + * + * Reorders the elements in the range @p [__first,__last) using @p __rand to + * provide a random distribution. Calling @p __rand(N) for a positive + * integer @p N should return a randomly chosen integer from the + * range [0,N). + */ + template + void + random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, +#if __cplusplus >= 201103L + _RandomNumberGenerator&& __rand) +#else + _RandomNumberGenerator& __rand) +#endif + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return; + for (_RandomAccessIterator __i = __first + 1; __i != __last; ++__i) + { + _RandomAccessIterator __j = __first + __rand((__i - __first) + 1); + if (__i != __j) + std::iter_swap(__i, __j); + } + } + + + /** + * @brief Move elements for which a predicate is true to the beginning + * of a sequence. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __pred A predicate functor. + * @return An iterator @p middle such that @p __pred(i) is true for each + * iterator @p i in the range @p [__first,middle) and false for each @p i + * in the range @p [middle,__last). + * + * @p __pred must not modify its operand. @p partition() does not preserve + * the relative ordering of elements in each group, use + * @p stable_partition() if this is needed. + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + partition(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + return std::__partition(__first, __last, __pred, + std::__iterator_category(__first)); + } + + + /** + * @brief Sort the smallest elements of a sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Sorts the smallest @p (__middle-__first) elements in the range + * @p [first,last) and moves them to the range @p [__first,__middle). The + * order of the remaining elements in the range @p [__middle,__last) is + * undefined. + * After the sort if @e i and @e j are iterators in the range + * @p [__first,__middle) such that i precedes j and @e k is an iterator in + * the range @p [__middle,__last) then *j<*i and *k<*i are both false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + partial_sort(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + __glibcxx_requires_irreflexive(__first, __last); + + std::__partial_sort(__first, __middle, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort the smallest elements of a sequence using a predicate + * for comparison. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __middle Another iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Sorts the smallest @p (__middle-__first) elements in the range + * @p [__first,__last) and moves them to the range @p [__first,__middle). The + * order of the remaining elements in the range @p [__middle,__last) is + * undefined. + * After the sort if @e i and @e j are iterators in the range + * @p [__first,__middle) such that i precedes j and @e k is an iterator in + * the range @p [__middle,__last) then @p *__comp(j,*i) and @p __comp(*k,*i) + * are both false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + partial_sort(_RandomAccessIterator __first, + _RandomAccessIterator __middle, + _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __middle); + __glibcxx_requires_valid_range(__middle, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + std::__partial_sort(__first, __middle, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /** + * @brief Sort a sequence just enough to find a particular position. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __nth Another iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Rearranges the elements in the range @p [__first,__last) so that @p *__nth + * is the same element that would have been in that position had the + * whole sequence been sorted. The elements either side of @p *__nth are + * not completely sorted, but for any iterator @e i in the range + * @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it + * holds that *j < *i is false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __nth); + __glibcxx_requires_valid_range(__nth, __last); + __glibcxx_requires_irreflexive(__first, __last); + + if (__first == __last || __nth == __last) + return; + + std::__introselect(__first, __nth, __last, + std::__lg(__last - __first) * 2, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort a sequence just enough to find a particular position + * using a predicate for comparison. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __nth Another iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Rearranges the elements in the range @p [__first,__last) so that @p *__nth + * is the same element that would have been in that position had the + * whole sequence been sorted. The elements either side of @p *__nth are + * not completely sorted, but for any iterator @e i in the range + * @p [__first,__nth) and any iterator @e j in the range @p [__nth,__last) it + * holds that @p __comp(*j,*i) is false. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, + _RandomAccessIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __nth); + __glibcxx_requires_valid_range(__nth, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + if (__first == __last || __nth == __last) + return; + + std::__introselect(__first, __nth, __last, + std::__lg(__last - __first) * 2, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + /** + * @brief Sort the elements of a sequence. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that for each iterator @e i in the range @p [__first,__last-1), + * *(i+1)<*i is false. + * + * The relative ordering of equivalent elements is not preserved, use + * @p stable_sort() if this is needed. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort the elements of a sequence using a predicate for comparison. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that @p __comp(*(i+1),*i) is false for every iterator @e i in the + * range @p [__first,__last-1). + * + * The relative ordering of equivalent elements is not preserved, use + * @p stable_sort() if this is needed. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first2, __first1)) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + } + ++__result; + } + return std::copy(__first2, __last2, + std::copy(__first1, __last1, __result)); + } + + /** + * @brief Merges two sorted ranges. + * @ingroup sorting_algorithms + * @param __first1 An iterator. + * @param __first2 Another iterator. + * @param __last1 Another iterator. + * @param __last2 Another iterator. + * @param __result An iterator pointing to the end of the merged range. + * @return An output iterator equal to @p __result + (__last1 - __first1) + * + (__last2 - __first2). + * + * Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into + * the sorted range @p [__result, __result + (__last1-__first1) + + * (__last2-__first2)). Both input ranges must be sorted, and the + * output range must not overlap with either of the input ranges. + * The sort is @e stable, that is, for equivalent elements in the + * two ranges, elements from the first range will always come + * before elements from the second. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__merge(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Merges two sorted ranges. + * @ingroup sorting_algorithms + * @param __first1 An iterator. + * @param __first2 Another iterator. + * @param __last1 Another iterator. + * @param __last2 Another iterator. + * @param __result An iterator pointing to the end of the merged range. + * @param __comp A functor to use for comparisons. + * @return An output iterator equal to @p __result + (__last1 - __first1) + * + (__last2 - __first2). + * + * Merges the ranges @p [__first1,__last1) and @p [__first2,__last2) into + * the sorted range @p [__result, __result + (__last1-__first1) + + * (__last2-__first2)). Both input ranges must be sorted, and the + * output range must not overlap with either of the input ranges. + * The sort is @e stable, that is, for equivalent elements in the + * two ranges, elements from the first range will always come + * before elements from the second. + * + * The comparison function should have the same effects on ordering as + * the function used for the initial sort. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__merge(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + inline void + __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf; + + if (__first == __last) + return; + + // __stable_sort_adaptive sorts the range in two halves, + // so the buffer only needs to fit half the range at once. + _TmpBuf __buf(__first, (__last - __first + 1) / 2); + + if (__buf.begin() == 0) + std::__inplace_stable_sort(__first, __last, __comp); + else + std::__stable_sort_adaptive(__first, __last, __buf.begin(), + _DistanceType(__buf.size()), __comp); + } + + /** + * @brief Sort the elements of a sequence, preserving the relative order + * of equivalent elements. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that for each iterator @p i in the range @p [__first,__last-1), + * @p *(i+1)<*i is false. + * + * The relative ordering of equivalent elements is preserved, so any two + * elements @p x and @p y in the range @p [__first,__last) such that + * @p x + inline void + stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + _GLIBCXX_STD_A::__stable_sort(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Sort the elements of a sequence using a predicate for comparison, + * preserving the relative order of equivalent elements. + * @ingroup sorting_algorithms + * @param __first An iterator. + * @param __last Another iterator. + * @param __comp A comparison functor. + * @return Nothing. + * + * Sorts the elements in the range @p [__first,__last) in ascending order, + * such that for each iterator @p i in the range @p [__first,__last-1), + * @p __comp(*(i+1),*i) is false. + * + * The relative ordering of equivalent elements is preserved, so any two + * elements @p x and @p y in the range @p [__first,__last) such that + * @p __comp(x,y) is false and @p __comp(y,x) is false will have the same + * relative ordering after calling @p stable_sort(). + */ + template + inline void + stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_RandomAccessIterator>::value_type, + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + _GLIBCXX_STD_A::__stable_sort(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(__first1, __first2)) + { + *__result = *__first1; + ++__first1; + } + else if (__comp(__first2, __first1)) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + ++__first2; + } + ++__result; + } + return std::copy(__first2, __last2, + std::copy(__first1, __last1, __result)); + } + + /** + * @brief Return the union of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * each range in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other, + * that element is copied and the iterator advanced. If an element is + * contained in both ranges, the element from the first range is copied and + * both ranges advance. The output range may not overlap either input + * range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_union(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the union of two sorted ranges using a comparison functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * each range in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other + * according to @p __comp, that element is copied and the iterator advanced. + * If an equivalent element according to @p __comp is contained in both + * ranges, the element from the first range is copied and both ranges + * advance. The output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_union(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(__first1, __first2)) + ++__first1; + else if (__comp(__first2, __first1)) + ++__first2; + else + { + *__result = *__first1; + ++__first1; + ++__first2; + ++__result; + } + return __result; + } + + /** + * @brief Return the intersection of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * both ranges in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other, + * that iterator advances. If an element is contained in both ranges, the + * element from the first range is copied and both ranges advance. The + * output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_intersection(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the intersection of two sorted ranges using comparison + * functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * both ranges in order to the output range. Iterators increment for each + * range. When the current element of one range is less than the other + * according to @p __comp, that iterator advances. If an element is + * contained in both ranges according to @p __comp, the element from the + * first range is copied and both ranges advance. The output range may not + * overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_intersection(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(__first1, __first2)) + { + *__result = *__first1; + ++__first1; + ++__result; + } + else if (__comp(__first2, __first1)) + ++__first2; + else + { + ++__first1; + ++__first2; + } + return std::copy(__first1, __last1, __result); + } + + /** + * @brief Return the difference of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * the first range but not the second in order to the output range. + * Iterators increment for each range. When the current element of the + * first range is less than the second, that element is copied and the + * iterator advances. If the current element of the second range is less, + * the iterator advances, but no element is copied. If an element is + * contained in both ranges, no elements are copied and both ranges + * advance. The output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the difference of two sorted ranges using comparison + * functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * the first range but not the second in order to the output range. + * Iterators increment for each range. When the current element of the + * first range is less than the second according to @p __comp, that element + * is copied and the iterator advances. If the current element of the + * second range is less, no element is copied and the iterator advances. + * If an element is contained in both ranges according to @p __comp, no + * elements are copied and both ranges advance. The output range may not + * overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __set_symmetric_difference(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2, + _OutputIterator __result, + _Compare __comp) + { + while (__first1 != __last1 && __first2 != __last2) + if (__comp(__first1, __first2)) + { + *__result = *__first1; + ++__first1; + ++__result; + } + else if (__comp(__first2, __first1)) + { + *__result = *__first2; + ++__first2; + ++__result; + } + else + { + ++__first1; + ++__first2; + } + return std::copy(__first2, __last2, + std::copy(__first1, __last1, __result)); + } + + /** + * @brief Return the symmetric difference of two sorted ranges. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * one range but not the other in order to the output range. Iterators + * increment for each range. When the current element of one range is less + * than the other, that element is copied and the iterator advances. If an + * element is contained in both ranges, no elements are copied and both + * ranges advance. The output range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set(__first1, __last1, __first2); + __glibcxx_requires_sorted_set(__first2, __last2, __first1); + __glibcxx_requires_irreflexive2(__first1, __last1); + __glibcxx_requires_irreflexive2(__first2, __last2); + + return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the symmetric difference of two sorted ranges using + * comparison functor. + * @ingroup set_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @param __last2 End of second range. + * @param __result Start of output range. + * @param __comp The comparison functor. + * @return End of the output range. + * @ingroup set_algorithms + * + * This operation iterates over both ranges, copying elements present in + * one range but not the other in order to the output range. Iterators + * increment for each range. When the current element of one range is less + * than the other according to @p comp, that element is copied and the + * iterator advances. If an element is contained in both ranges according + * to @p __comp, no elements are copied and both ranges advance. The output + * range may not overlap either input range. + */ + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_InputIterator2>::value_type, + typename iterator_traits<_InputIterator1>::value_type>) + __glibcxx_requires_sorted_set_pred(__first1, __last1, __first2, __comp); + __glibcxx_requires_sorted_set_pred(__first2, __last2, __first1, __comp); + __glibcxx_requires_irreflexive_pred2(__first1, __last1, __comp); + __glibcxx_requires_irreflexive_pred2(__first2, __last2, __comp); + + return _GLIBCXX_STD_A::__set_symmetric_difference(__first1, __last1, + __first2, __last2, __result, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX14_CONSTEXPR + _ForwardIterator + __min_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + if (__first == __last) + return __first; + _ForwardIterator __result = __first; + while (++__first != __last) + if (__comp(__first, __result)) + __result = __first; + return __result; + } + + /** + * @brief Return the minimum element in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return Iterator referencing the first instance of the smallest value. + */ + template + _GLIBCXX14_CONSTEXPR + _ForwardIterator + inline min_element(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return _GLIBCXX_STD_A::__min_element(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the minimum element in a range using comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor. + * @return Iterator referencing the first instance of the smallest value + * according to __comp. + */ + template + _GLIBCXX14_CONSTEXPR + inline _ForwardIterator + min_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return _GLIBCXX_STD_A::__min_element(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + + template + _GLIBCXX14_CONSTEXPR + _ForwardIterator + __max_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + if (__first == __last) return __first; + _ForwardIterator __result = __first; + while (++__first != __last) + if (__comp(__result, __first)) + __result = __first; + return __result; + } + + /** + * @brief Return the maximum element in a range. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @return Iterator referencing the first instance of the largest value. + */ + template + _GLIBCXX14_CONSTEXPR + inline _ForwardIterator + max_element(_ForwardIterator __first, _ForwardIterator __last) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + return _GLIBCXX_STD_A::__max_element(__first, __last, + __gnu_cxx::__ops::__iter_less_iter()); + } + + /** + * @brief Return the maximum element in a range using comparison functor. + * @ingroup sorting_algorithms + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor. + * @return Iterator referencing the first instance of the largest value + * according to __comp. + */ + template + _GLIBCXX14_CONSTEXPR + inline _ForwardIterator + max_element(_ForwardIterator __first, _ForwardIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_BinaryPredicateConcept<_Compare, + typename iterator_traits<_ForwardIterator>::value_type, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + return _GLIBCXX_STD_A::__max_element(__first, __last, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + +#if __cplusplus >= 201402L + /// Reservoir sampling algorithm. + template + _RandomAccessIterator + __sample(_InputIterator __first, _InputIterator __last, input_iterator_tag, + _RandomAccessIterator __out, random_access_iterator_tag, + _Size __n, _UniformRandomBitGenerator&& __g) + { + using __distrib_type = uniform_int_distribution<_Size>; + using __param_type = typename __distrib_type::param_type; + __distrib_type __d{}; + _Size __sample_sz = 0; + while (__first != __last && __sample_sz != __n) + { + __out[__sample_sz++] = *__first; + ++__first; + } + for (auto __pop_sz = __sample_sz; __first != __last; + ++__first, (void) ++__pop_sz) + { + const auto __k = __d(__g, __param_type{0, __pop_sz}); + if (__k < __n) + __out[__k] = *__first; + } + return __out + __sample_sz; + } + + /// Selection sampling algorithm. + template + _OutputIterator + __sample(_ForwardIterator __first, _ForwardIterator __last, + forward_iterator_tag, + _OutputIterator __out, _Cat, + _Size __n, _UniformRandomBitGenerator&& __g) + { + using __distrib_type = uniform_int_distribution<_Size>; + using __param_type = typename __distrib_type::param_type; + using _USize = make_unsigned_t<_Size>; + using _Gen = remove_reference_t<_UniformRandomBitGenerator>; + using __uc_type = common_type_t; + + if (__first == __last) + return __out; + + __distrib_type __d{}; + _Size __unsampled_sz = std::distance(__first, __last); + __n = std::min(__n, __unsampled_sz); + + // If possible, we use __gen_two_uniform_ints to efficiently produce + // two random numbers using a single distribution invocation: + + const __uc_type __urngrange = __g.max() - __g.min(); + if (__urngrange / __uc_type(__unsampled_sz) >= __uc_type(__unsampled_sz)) + // I.e. (__urngrange >= __unsampled_sz * __unsampled_sz) but without + // wrapping issues. + { + while (__n != 0 && __unsampled_sz >= 2) + { + const pair<_Size, _Size> __p = + __gen_two_uniform_ints(__unsampled_sz, __unsampled_sz - 1, __g); + + --__unsampled_sz; + if (__p.first < __n) + { + *__out++ = *__first; + --__n; + } + + ++__first; + + if (__n == 0) break; + + --__unsampled_sz; + if (__p.second < __n) + { + *__out++ = *__first; + --__n; + } + + ++__first; + } + } + + // The loop above is otherwise equivalent to this one-at-a-time version: + + for (; __n != 0; ++__first) + if (__d(__g, __param_type{0, --__unsampled_sz}) < __n) + { + *__out++ = *__first; + --__n; + } + return __out; + } + +#if __cplusplus > 201402L +#define __cpp_lib_sample 201603 + /// Take a random sample from a population. + template + _SampleIterator + sample(_PopulationIterator __first, _PopulationIterator __last, + _SampleIterator __out, _Distance __n, + _UniformRandomBitGenerator&& __g) + { + using __pop_cat = typename + std::iterator_traits<_PopulationIterator>::iterator_category; + using __samp_cat = typename + std::iterator_traits<_SampleIterator>::iterator_category; + + static_assert( + __or_, + is_convertible<__samp_cat, random_access_iterator_tag>>::value, + "output range must use a RandomAccessIterator when input range" + " does not meet the ForwardIterator requirements"); + + static_assert(is_integral<_Distance>::value, + "sample size must be an integer type"); + + typename iterator_traits<_PopulationIterator>::difference_type __d = __n; + return _GLIBCXX_STD_A:: + __sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, __d, + std::forward<_UniformRandomBitGenerator>(__g)); + } +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_ALGO +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_ALGO_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_algobase.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_algobase.h new file mode 100755 index 0000000..a76b00b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_algobase.h @@ -0,0 +1,2210 @@ +// Core algorithmic facilities -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_algobase.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{algorithm} + */ + +#ifndef _STL_ALGOBASE_H +#define _STL_ALGOBASE_H 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // For std::swap +#include +#if __cplusplus >= 201103L +# include +#endif +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /* + * A constexpr wrapper for __builtin_memcmp. + * @param __num The number of elements of type _Tp (not bytes). + */ + template + _GLIBCXX14_CONSTEXPR + inline int + __memcmp(const _Tp* __first1, const _Up* __first2, size_t __num) + { +#if __cplusplus >= 201103L + static_assert(sizeof(_Tp) == sizeof(_Up), "can be compared with memcmp"); +#endif +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for(; __num > 0; ++__first1, ++__first2, --__num) + if (*__first1 != *__first2) + return *__first1 < *__first2 ? -1 : 1; + return 0; + } + else +#endif + return __builtin_memcmp(__first1, __first2, sizeof(_Tp) * __num); + } + +#if __cplusplus < 201103L + // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a + // nutshell, we are partially implementing the resolution of DR 187, + // when it's safe, i.e., the value_types are equal. + template + struct __iter_swap + { + template + static void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + typedef typename iterator_traits<_ForwardIterator1>::value_type + _ValueType1; + _ValueType1 __tmp = *__a; + *__a = *__b; + *__b = __tmp; + } + }; + + template<> + struct __iter_swap + { + template + static void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + swap(*__a, *__b); + } + }; +#endif // C++03 + + /** + * @brief Swaps the contents of two iterators. + * @ingroup mutating_algorithms + * @param __a An iterator. + * @param __b Another iterator. + * @return Nothing. + * + * This function swaps the values pointed to by two iterators, not the + * iterators themselves. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator1>) + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator2>) + +#if __cplusplus < 201103L + typedef typename iterator_traits<_ForwardIterator1>::value_type + _ValueType1; + typedef typename iterator_traits<_ForwardIterator2>::value_type + _ValueType2; + + __glibcxx_function_requires(_ConvertibleConcept<_ValueType1, + _ValueType2>) + __glibcxx_function_requires(_ConvertibleConcept<_ValueType2, + _ValueType1>) + + typedef typename iterator_traits<_ForwardIterator1>::reference + _ReferenceType1; + typedef typename iterator_traits<_ForwardIterator2>::reference + _ReferenceType2; + std::__iter_swap<__are_same<_ValueType1, _ValueType2>::__value + && __are_same<_ValueType1&, _ReferenceType1>::__value + && __are_same<_ValueType2&, _ReferenceType2>::__value>:: + iter_swap(__a, __b); +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 187. iter_swap underspecified + swap(*__a, *__b); +#endif + } + + /** + * @brief Swap the elements of two sequences. + * @ingroup mutating_algorithms + * @param __first1 A forward iterator. + * @param __last1 A forward iterator. + * @param __first2 A forward iterator. + * @return An iterator equal to @p first2+(last1-first1). + * + * Swaps each element in the range @p [first1,last1) with the + * corresponding element in the range @p [first2,(last1-first1)). + * The ranges must not overlap. + */ + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator2 + swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator1>) + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + std::iter_swap(__first1, __first2); + return __first2; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return The lesser of the parameters. + * + * This is the simple classic generic implementation. It will work on + * temporary expressions, since they are only evaluated once, unlike a + * preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + min(const _Tp& __a, const _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + //return __b < __a ? __b : __a; + if (__b < __a) + return __b; + return __a; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @return The greater of the parameters. + * + * This is the simple classic generic implementation. It will work on + * temporary expressions, since they are only evaluated once, unlike a + * preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + max(const _Tp& __a, const _Tp& __b) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + //return __a < __b ? __b : __a; + if (__a < __b) + return __b; + return __a; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return The lesser of the parameters. + * + * This will work on temporary expressions, since they are only evaluated + * once, unlike a preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + min(const _Tp& __a, const _Tp& __b, _Compare __comp) + { + //return __comp(__b, __a) ? __b : __a; + if (__comp(__b, __a)) + return __b; + return __a; + } + + /** + * @brief This does what you think it does. + * @ingroup sorting_algorithms + * @param __a A thing of arbitrary type. + * @param __b Another thing of arbitrary type. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return The greater of the parameters. + * + * This will work on temporary expressions, since they are only evaluated + * once, unlike a preprocessor macro. + */ + template + _GLIBCXX14_CONSTEXPR + inline const _Tp& + max(const _Tp& __a, const _Tp& __b, _Compare __comp) + { + //return __comp(__a, __b) ? __b : __a; + if (__comp(__a, __b)) + return __b; + return __a; + } + + // Fallback implementation of the function in bits/stl_iterator.h used to + // remove the __normal_iterator wrapper. See copy, fill, ... + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __niter_base(_Iterator __it) + _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value) + { return __it; } + + template + _Ite + __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, + std::random_access_iterator_tag>&); + + // Reverse the __niter_base transformation to get a + // __normal_iterator back again (this assumes that __normal_iterator + // is only used to wrap random access iterators, like pointers). + template + _GLIBCXX20_CONSTEXPR + inline _From + __niter_wrap(_From __from, _To __res) + { return __from + (__res - std::__niter_base(__from)); } + + // No need to wrap, iterator already has the right type. + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __niter_wrap(const _Iterator&, _Iterator __res) + { return __res; } + + // All of these auxiliary structs serve two purposes. (1) Replace + // calls to copy with memmove whenever possible. (Memmove, not memcpy, + // because the input and output ranges are permitted to overlap.) + // (2) If we're using random access iterators, then write the loop as + // a for loop with an explicit count. + + template + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + for (; __first != __last; ++__result, (void)++__first) + *__result = *__first; + return __result; + } + }; + +#if __cplusplus >= 201103L + template + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + for (; __first != __last; ++__result, (void)++__first) + *__result = std::move(*__first); + return __result; + } + }; +#endif + + template<> + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::difference_type _Distance; + for(_Distance __n = __last - __first; __n > 0; --__n) + { + *__result = *__first; + ++__first; + ++__result; + } + return __result; + } + }; + +#if __cplusplus >= 201103L + template<> + struct __copy_move + { + template + _GLIBCXX20_CONSTEXPR + static _OI + __copy_m(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::difference_type _Distance; + for(_Distance __n = __last - __first; __n > 0; --__n) + { + *__result = std::move(*__first); + ++__first; + ++__result; + } + return __result; + } + }; +#endif + + template + struct __copy_move<_IsMove, true, random_access_iterator_tag> + { + template + _GLIBCXX20_CONSTEXPR + static _Tp* + __copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result) + { +#if __cplusplus >= 201103L + using __assignable = conditional<_IsMove, + is_move_assignable<_Tp>, + is_copy_assignable<_Tp>>; + // trivial types can have deleted assignment + static_assert( __assignable::type::value, "type is not assignable" ); +#endif + const ptrdiff_t _Num = __last - __first; + if (_Num) + __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); + return __result + _Num; + } + }; + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + struct _Deque_iterator; + + struct _Bit_iterator; + +_GLIBCXX_END_NAMESPACE_CONTAINER + + // Helpers for streambuf iterators (either istream or ostream). + // NB: avoid including , relatively large. + template + struct char_traits; + + template + class istreambuf_iterator; + + template + class ostreambuf_iterator; + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type + __copy_move_a2(_CharT*, _CharT*, + ostreambuf_iterator<_CharT, char_traits<_CharT> >); + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT, char_traits<_CharT> > >::__type + __copy_move_a2(const _CharT*, const _CharT*, + ostreambuf_iterator<_CharT, char_traits<_CharT> >); + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_move_a2(istreambuf_iterator<_CharT, char_traits<_CharT> >, + istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*); + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_move_a2( + istreambuf_iterator<_CharT, char_traits<_CharT> >, + istreambuf_iterator<_CharT, char_traits<_CharT> >, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*>); + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_a2(_II __first, _II __last, _OI __result) + { + typedef typename iterator_traits<_II>::iterator_category _Category; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__copy_move<_IsMove, false, _Category>:: + __copy_m(__first, __last, __result); +#endif + return std::__copy_move<_IsMove, __memcpyable<_OI, _II>::__value, + _Category>::__copy_m(__first, __last, __result); + } + + template + _OI + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _OI); + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_a1(_II, _II, _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_a1(_II __first, _II __last, _OI __result) + { return std::__copy_move_a2<_IsMove>(__first, __last, __result); } + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_a(_II __first, _II __last, _OI __result) + { + return std::__niter_wrap(__result, + std::__copy_move_a1<_IsMove>(std::__niter_base(__first), + std::__niter_base(__last), + std::__niter_base(__result))); + } + + template + _OI + __copy_move_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + _OI); + + template + __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __copy_move_a(_II, _II, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&); + + template + ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> + __copy_move_a(const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&); + + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + __copy_n_a(_InputIterator __first, _Size __n, _OutputIterator __result, + bool) + { + if (__n > 0) + { + while (true) + { + *__result = *__first; + ++__result; + if (--__n > 0) + ++__first; + else + break; + } + } + return __result; + } + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, _CharT*>::__type + __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT> >, + _Size, _CharT*, bool); + + template + typename __gnu_cxx::__enable_if< + __is_char<_CharT>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type + __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT> >, _Size, + _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*>, + bool); + + /** + * @brief Copies the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return result + (last - first) + * + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). Result may not be contained within + * [first,last); the copy_backward function should be used instead. + * + * Note that the end of the output range is permitted to be contained + * within [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OI + copy(_II __first, _II __last, _OI __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II>) + __glibcxx_function_requires(_OutputIteratorConcept<_OI, + typename iterator_traits<_II>::value_type>) + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return std::__copy_move_a<__is_move_iterator<_II>::__value> + (std::__miter_base(__first), std::__miter_base(__last), __result); + } + +#if __cplusplus >= 201103L + /** + * @brief Moves the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return result + (last - first) + * + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). Result may not be contained within + * [first,last); the move_backward function should be used instead. + * + * Note that the end of the output range is permitted to be contained + * within [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _OI + move(_II __first, _II __last, _OI __result) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II>) + __glibcxx_function_requires(_OutputIteratorConcept<_OI, + typename iterator_traits<_II>::value_type>) + __glibcxx_requires_can_increment_range(__first, __last, __result); + + return std::__copy_move_a(std::__miter_base(__first), + std::__miter_base(__last), __result); + } + +#define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::move(_Tp, _Up, _Vp) +#else +#define _GLIBCXX_MOVE3(_Tp, _Up, _Vp) std::copy(_Tp, _Up, _Vp) +#endif + + template + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + while (__first != __last) + *--__result = *--__last; + return __result; + } + }; + +#if __cplusplus >= 201103L + template + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + while (__first != __last) + *--__result = std::move(*--__last); + return __result; + } + }; +#endif + + template<> + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + typename iterator_traits<_BI1>::difference_type + __n = __last - __first; + for (; __n > 0; --__n) + *--__result = *--__last; + return __result; + } + }; + +#if __cplusplus >= 201103L + template<> + struct __copy_move_backward + { + template + _GLIBCXX20_CONSTEXPR + static _BI2 + __copy_move_b(_BI1 __first, _BI1 __last, _BI2 __result) + { + typename iterator_traits<_BI1>::difference_type + __n = __last - __first; + for (; __n > 0; --__n) + *--__result = std::move(*--__last); + return __result; + } + }; +#endif + + template + struct __copy_move_backward<_IsMove, true, random_access_iterator_tag> + { + template + _GLIBCXX20_CONSTEXPR + static _Tp* + __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result) + { +#if __cplusplus >= 201103L + using __assignable = conditional<_IsMove, + is_move_assignable<_Tp>, + is_copy_assignable<_Tp>>; + // trivial types can have deleted assignment + static_assert( __assignable::type::value, "type is not assignable" ); +#endif + const ptrdiff_t _Num = __last - __first; + if (_Num) + __builtin_memmove(__result - _Num, __first, sizeof(_Tp) * _Num); + return __result - _Num; + } + }; + + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + __copy_move_backward_a2(_BI1 __first, _BI1 __last, _BI2 __result) + { + typedef typename iterator_traits<_BI1>::iterator_category _Category; +#ifdef __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return std::__copy_move_backward<_IsMove, false, _Category>:: + __copy_move_b(__first, __last, __result); +#endif + return std::__copy_move_backward<_IsMove, + __memcpyable<_BI2, _BI1>::__value, + _Category>::__copy_move_b(__first, + __last, + __result); + } + + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + __copy_move_backward_a1(_BI1 __first, _BI1 __last, _BI2 __result) + { return std::__copy_move_backward_a2<_IsMove>(__first, __last, __result); } + + template + _OI + __copy_move_backward_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _OI); + + template + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*> + __copy_move_backward_a1( + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>, + _GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type + __copy_move_backward_a1(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>); + + template + _GLIBCXX20_CONSTEXPR + inline _OI + __copy_move_backward_a(_II __first, _II __last, _OI __result) + { + return std::__niter_wrap(__result, + std::__copy_move_backward_a1<_IsMove> + (std::__niter_base(__first), std::__niter_base(__last), + std::__niter_base(__result))); + } + + template + _OI + __copy_move_backward_a( + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + _OI); + + template + __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __copy_move_backward_a(_II, _II, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&); + + template + ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> + __copy_move_backward_a( + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>&, + const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>&); + + /** + * @brief Copies the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @param __result A bidirectional iterator. + * @return result - (last - first) + * + * The function has the same effect as copy, but starts at the end of the + * range and works its way to the start, returning the start of the result. + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). + * + * Result may not be in the range (first,last]. Use copy instead. Note + * that the start of the output range may overlap [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>) + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>) + __glibcxx_function_requires(_ConvertibleConcept< + typename iterator_traits<_BI1>::value_type, + typename iterator_traits<_BI2>::value_type>) + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return std::__copy_move_backward_a<__is_move_iterator<_BI1>::__value> + (std::__miter_base(__first), std::__miter_base(__last), __result); + } + +#if __cplusplus >= 201103L + /** + * @brief Moves the range [first,last) into result. + * @ingroup mutating_algorithms + * @param __first A bidirectional iterator. + * @param __last A bidirectional iterator. + * @param __result A bidirectional iterator. + * @return result - (last - first) + * + * The function has the same effect as move, but starts at the end of the + * range and works its way to the start, returning the start of the result. + * This inline function will boil down to a call to @c memmove whenever + * possible. Failing that, if random access iterators are passed, then the + * loop count will be known (and therefore a candidate for compiler + * optimizations such as unrolling). + * + * Result may not be in the range (first,last]. Use move instead. Note + * that the start of the output range may overlap [first,last). + */ + template + _GLIBCXX20_CONSTEXPR + inline _BI2 + move_backward(_BI1 __first, _BI1 __last, _BI2 __result) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept<_BI1>) + __glibcxx_function_requires(_Mutable_BidirectionalIteratorConcept<_BI2>) + __glibcxx_function_requires(_ConvertibleConcept< + typename iterator_traits<_BI1>::value_type, + typename iterator_traits<_BI2>::value_type>) + __glibcxx_requires_can_decrement_range(__first, __last, __result); + + return std::__copy_move_backward_a(std::__miter_base(__first), + std::__miter_base(__last), + __result); + } + +#define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::move_backward(_Tp, _Up, _Vp) +#else +#define _GLIBCXX_MOVE_BACKWARD3(_Tp, _Up, _Vp) std::copy_backward(_Tp, _Up, _Vp) +#endif + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if::__value, void>::__type + __fill_a1(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + for (; __first != __last; ++__first) + *__first = __value; + } + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type + __fill_a1(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __value) + { + const _Tp __tmp = __value; + for (; __first != __last; ++__first) + *__first = __tmp; + } + + // Specialization: for char types we can use memset. + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if<__is_byte<_Tp>::__value, void>::__type + __fill_a1(_Tp* __first, _Tp* __last, const _Tp& __c) + { + const _Tp __tmp = __c; +#if __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + { + for (; __first != __last; ++__first) + *__first = __tmp; + return; + } +#endif + if (const size_t __len = __last - __first) + __builtin_memset(__first, static_cast(__tmp), __len); + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __fill_a1(::__gnu_cxx::__normal_iterator<_Ite, _Cont> __first, + ::__gnu_cxx::__normal_iterator<_Ite, _Cont> __last, + const _Tp& __value) + { std::__fill_a1(__first.base(), __last.base(), __value); } + + template + void + __fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, + const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&, + const _VTp&); + + void + __fill_a1(_GLIBCXX_STD_C::_Bit_iterator, _GLIBCXX_STD_C::_Bit_iterator, + const bool&); + + template + _GLIBCXX20_CONSTEXPR + inline void + __fill_a(_FIte __first, _FIte __last, const _Tp& __value) + { std::__fill_a1(__first, __last, __value); } + + template + void + __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>&, + const _Tp&); + + /** + * @brief Fills the range [first,last) with copies of value. + * @ingroup mutating_algorithms + * @param __first A forward iterator. + * @param __last A forward iterator. + * @param __value A reference-to-const of arbitrary type. + * @return Nothing. + * + * This function fills a range with copies of the same value. For char + * types filling contiguous areas of memory, this becomes an inline call + * to @c memset or @c wmemset. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_requires_valid_range(__first, __last); + + std::__fill_a(__first, __last, __value); + } + + // Used by fill_n, generate_n, etc. to convert _Size to an integral type: + inline _GLIBCXX_CONSTEXPR int + __size_to_integer(int __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned + __size_to_integer(unsigned __n) { return __n; } + inline _GLIBCXX_CONSTEXPR long + __size_to_integer(long __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned long + __size_to_integer(unsigned long __n) { return __n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(long long __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned long long + __size_to_integer(unsigned long long __n) { return __n; } + +#if defined(__GLIBCXX_TYPE_INT_N_0) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_0 + __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_0 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_0 __n) { return __n; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_1 + __size_to_integer(__GLIBCXX_TYPE_INT_N_1 __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_1 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_1 __n) { return __n; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_2 + __size_to_integer(__GLIBCXX_TYPE_INT_N_2 __n) { return __n; } + inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_2 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_2 __n) { return __n; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + inline _GLIBCXX_CONSTEXPR unsigned __GLIBCXX_TYPE_INT_N_3 + __size_to_integer(__GLIBCXX_TYPE_INT_N_3 __n) { return __n; } + inline _GLIBCXX_CONSTEXPR __GLIBCXX_TYPE_INT_N_3 + __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_3 __n) { return __n; } +#endif + + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(float __n) { return (long long)__n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(double __n) { return (long long)__n; } + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(long double __n) { return (long long)__n; } +#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) + inline _GLIBCXX_CONSTEXPR long long + __size_to_integer(__float128 __n) { return (long long)__n; } +#endif + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if::__value, _OutputIterator>::__type + __fill_n_a1(_OutputIterator __first, _Size __n, const _Tp& __value) + { + for (; __n > 0; --__n, (void) ++__first) + *__first = __value; + return __first; + } + + template + _GLIBCXX20_CONSTEXPR + inline typename + __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, _OutputIterator>::__type + __fill_n_a1(_OutputIterator __first, _Size __n, const _Tp& __value) + { + const _Tp __tmp = __value; + for (; __n > 0; --__n, (void) ++__first) + *__first = __tmp; + return __first; + } + + template + ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, + _Size __n, const _Tp& __value, + std::input_iterator_tag); + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, + std::output_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + return __fill_n_a1(__first, __n, __value); + } + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, + std::input_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + return __fill_n_a1(__first, __n, __value); + } + + template + _GLIBCXX20_CONSTEXPR + inline _OutputIterator + __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value, + std::random_access_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + if (__n <= 0) + return __first; + + __glibcxx_requires_can_increment(__first, __n); + + std::__fill_a(__first, __first + __n, __value); + return __first + __n; + } + + /** + * @brief Fills the range [first,first+n) with copies of value. + * @ingroup mutating_algorithms + * @param __first An output iterator. + * @param __n The count of copies to perform. + * @param __value A reference-to-const of arbitrary type. + * @return The iterator at first+n. + * + * This function fills a range with copies of the same value. For char + * types filling contiguous areas of memory, this becomes an inline call + * to @c memset or @c wmemset. + * + * If @p __n is negative, the function does nothing. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 865. More algorithms that throw away information + // DR 426. search_n(), fill_n(), and generate_n() with negative n + template + _GLIBCXX20_CONSTEXPR + inline _OI + fill_n(_OI __first, _Size __n, const _Tp& __value) + { + // concept requirements + __glibcxx_function_requires(_OutputIteratorConcept<_OI, _Tp>) + + return std::__fill_n_a(__first, std::__size_to_integer(__n), __value, + std::__iterator_category(__first)); + } + + template + struct __equal + { + template + _GLIBCXX20_CONSTEXPR + static bool + equal(_II1 __first1, _II1 __last1, _II2 __first2) + { + for (; __first1 != __last1; ++__first1, (void) ++__first2) + if (!(*__first1 == *__first2)) + return false; + return true; + } + }; + + template<> + struct __equal + { + template + _GLIBCXX20_CONSTEXPR + static bool + equal(const _Tp* __first1, const _Tp* __last1, const _Tp* __first2) + { + if (const size_t __len = (__last1 - __first1)) + return !std::__memcmp(__first1, __first2, __len); + return true; + } + }; + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>, + _II); + + template + bool + __equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); + + template + typename __gnu_cxx::__enable_if< + __is_random_access_iter<_II>::__value, bool>::__type + __equal_aux1(_II, _II, + _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>); + + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal_aux1(_II1 __first1, _II1 __last1, _II2 __first2) + { + typedef typename iterator_traits<_II1>::value_type _ValueType1; + const bool __simple = ((__is_integer<_ValueType1>::__value + || __is_pointer<_ValueType1>::__value) + && __memcmpable<_II1, _II2>::__value); + return std::__equal<__simple>::equal(__first1, __last1, __first2); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal_aux(_II1 __first1, _II1 __last1, _II2 __first2) + { + return std::__equal_aux1(std::__niter_base(__first1), + std::__niter_base(__last1), + std::__niter_base(__first2)); + } + + template + bool + __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + _II2); + + template + bool + __equal_aux(_II1, _II1, + const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&); + + template + bool + __equal_aux(const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>&); + + template + struct __lc_rai + { + template + _GLIBCXX20_CONSTEXPR + static _II1 + __newlast1(_II1, _II1 __last1, _II2, _II2) + { return __last1; } + + template + _GLIBCXX20_CONSTEXPR + static bool + __cnd2(_II __first, _II __last) + { return __first != __last; } + }; + + template<> + struct __lc_rai + { + template + _GLIBCXX20_CONSTEXPR + static _RAI1 + __newlast1(_RAI1 __first1, _RAI1 __last1, + _RAI2 __first2, _RAI2 __last2) + { + const typename iterator_traits<_RAI1>::difference_type + __diff1 = __last1 - __first1; + const typename iterator_traits<_RAI2>::difference_type + __diff2 = __last2 - __first2; + return __diff2 < __diff1 ? __first1 + __diff2 : __last1; + } + + template + static _GLIBCXX20_CONSTEXPR bool + __cnd2(_RAI, _RAI) + { return true; } + }; + + template + _GLIBCXX20_CONSTEXPR + bool + __lexicographical_compare_impl(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2, + _Compare __comp) + { + typedef typename iterator_traits<_II1>::iterator_category _Category1; + typedef typename iterator_traits<_II2>::iterator_category _Category2; + typedef std::__lc_rai<_Category1, _Category2> __rai_type; + + __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2); + for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2); + ++__first1, (void)++__first2) + { + if (__comp(__first1, __first2)) + return true; + if (__comp(__first2, __first1)) + return false; + } + return __first1 == __last1 && __first2 != __last2; + } + + template + struct __lexicographical_compare + { + template + _GLIBCXX20_CONSTEXPR + static bool + __lc(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + using __gnu_cxx::__ops::__iter_less_iter; + return std::__lexicographical_compare_impl(__first1, __last1, + __first2, __last2, + __iter_less_iter()); + } + + template + _GLIBCXX20_CONSTEXPR + static int + __3way(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + while (__first1 != __last1) + { + if (__first2 == __last2) + return +1; + if (*__first1 < *__first2) + return -1; + if (*__first2 < *__first1) + return +1; + ++__first1; + ++__first2; + } + return int(__first2 == __last2) - 1; + } + }; + + template<> + struct __lexicographical_compare + { + template + _GLIBCXX20_CONSTEXPR + static bool + __lc(const _Tp* __first1, const _Tp* __last1, + const _Up* __first2, const _Up* __last2) + { return __3way(__first1, __last1, __first2, __last2) < 0; } + + template + _GLIBCXX20_CONSTEXPR + static ptrdiff_t + __3way(const _Tp* __first1, const _Tp* __last1, + const _Up* __first2, const _Up* __last2) + { + const size_t __len1 = __last1 - __first1; + const size_t __len2 = __last2 - __first2; + if (const size_t __len = std::min(__len1, __len2)) + if (int __result = std::__memcmp(__first1, __first2, __len)) + return __result; + return ptrdiff_t(__len1 - __len2); + } + }; + + template + _GLIBCXX20_CONSTEXPR + inline bool + __lexicographical_compare_aux1(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { + typedef typename iterator_traits<_II1>::value_type _ValueType1; + typedef typename iterator_traits<_II2>::value_type _ValueType2; + const bool __simple = + (__is_memcmp_ordered_with<_ValueType1, _ValueType2>::__value + && __is_pointer<_II1>::__value + && __is_pointer<_II2>::__value +#if __cplusplus > 201703L && __cpp_lib_concepts + // For C++20 iterator_traits::value_type is non-volatile + // so __is_byte could be true, but we can't use memcmp with + // volatile data. + && !is_volatile_v>> + && !is_volatile_v>> +#endif + ); + + return std::__lexicographical_compare<__simple>::__lc(__first1, __last1, + __first2, __last2); + } + + template + bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _Tp2*, _Tp2*); + + template + bool + __lexicographical_compare_aux1(_Tp1*, _Tp1*, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); + + template + bool + __lexicographical_compare_aux1( + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>, + _GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>); + + template + _GLIBCXX20_CONSTEXPR + inline bool + __lexicographical_compare_aux(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { + return std::__lexicographical_compare_aux1(std::__niter_base(__first1), + std::__niter_base(__last1), + std::__niter_base(__first2), + std::__niter_base(__last2)); + } + + template + bool + __lexicographical_compare_aux( + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + _II2, _II2); + + template + bool + __lexicographical_compare_aux( + _II1, _II1, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&); + + template + bool + __lexicographical_compare_aux( + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_Iter1, _Seq1, _Cat1>&, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&, + const ::__gnu_debug::_Safe_iterator<_Iter2, _Seq2, _Cat2>&); + + template + _GLIBCXX20_CONSTEXPR + _ForwardIterator + __lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val, _Compare __comp) + { + typedef typename iterator_traits<_ForwardIterator>::difference_type + _DistanceType; + + _DistanceType __len = std::distance(__first, __last); + + while (__len > 0) + { + _DistanceType __half = __len >> 1; + _ForwardIterator __middle = __first; + std::advance(__middle, __half); + if (__comp(__middle, __val)) + { + __first = __middle; + ++__first; + __len = __len - __half - 1; + } + else + __len = __half; + } + return __first; + } + + /** + * @brief Finds the first position in which @a val could be inserted + * without changing the ordering. + * @param __first An iterator. + * @param __last Another iterator. + * @param __val The search term. + * @return An iterator pointing to the first element not less + * than @a val, or end() if every element is less than + * @a val. + * @ingroup binary_search_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline _ForwardIterator + lower_bound(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __val) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + __glibcxx_function_requires(_LessThanOpConcept< + typename iterator_traits<_ForwardIterator>::value_type, _Tp>) + __glibcxx_requires_partitioned_lower(__first, __last, __val); + + return std::__lower_bound(__first, __last, __val, + __gnu_cxx::__ops::__iter_less_val()); + } + + /// This is a helper function for the sort routines and for random.tcc. + // Precondition: __n > 0. + inline _GLIBCXX_CONSTEXPR int + __lg(int __n) + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + + inline _GLIBCXX_CONSTEXPR unsigned + __lg(unsigned __n) + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + + inline _GLIBCXX_CONSTEXPR long + __lg(long __n) + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + + inline _GLIBCXX_CONSTEXPR unsigned long + __lg(unsigned long __n) + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + + inline _GLIBCXX_CONSTEXPR long long + __lg(long long __n) + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + + inline _GLIBCXX_CONSTEXPR unsigned long long + __lg(unsigned long long __n) + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @return A boolean true or false. + * + * This compares the elements of two ranges using @c == and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_II1 __first1, _II1 __last1, _II2 __first2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_II1>::value_type, + typename iterator_traits<_II2>::value_type>) + __glibcxx_requires_can_increment_range(__first1, __last1, __first2); + + return std::__equal_aux(__first1, __last1, __first2); + } + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A boolean true or false. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_IIter1 __first1, _IIter1 __last1, + _IIter2 __first2, _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_IIter1>) + __glibcxx_function_requires(_InputIteratorConcept<_IIter2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!bool(__binary_pred(*__first1, *__first2))) + return false; + return true; + } + +#if __cplusplus >= 201103L + // 4-iterator version of std::equal for use in C++11. + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + using _RATag = random_access_iterator_tag; + using _Cat1 = typename iterator_traits<_II1>::iterator_category; + using _Cat2 = typename iterator_traits<_II2>::iterator_category; + using _RAIters = __and_, is_same<_Cat2, _RATag>>; + if (_RAIters()) + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 != __d2) + return false; + return _GLIBCXX_STD_A::equal(__first1, __last1, __first2); + } + + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!(*__first1 == *__first2)) + return false; + return __first1 == __last1 && __first2 == __last2; + } + + // 4-iterator version of std::equal for use in C++11. + template + _GLIBCXX20_CONSTEXPR + inline bool + __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, + _BinaryPredicate __binary_pred) + { + using _RATag = random_access_iterator_tag; + using _Cat1 = typename iterator_traits<_II1>::iterator_category; + using _Cat2 = typename iterator_traits<_II2>::iterator_category; + using _RAIters = __and_, is_same<_Cat2, _RATag>>; + if (_RAIters()) + { + auto __d1 = std::distance(__first1, __last1); + auto __d2 = std::distance(__first2, __last2); + if (__d1 != __d2) + return false; + return _GLIBCXX_STD_A::equal(__first1, __last1, __first2, + __binary_pred); + } + + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, (void)++__first2) + if (!bool(__binary_pred(*__first1, *__first2))) + return false; + return __first1 == __last1 && __first2 == __last2; + } +#endif // C++11 + +#if __cplusplus > 201103L + +#define __cpp_lib_robust_nonmodifying_seq_ops 201304 + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @return A boolean true or false. + * + * This compares the elements of two ranges using @c == and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_II1>::value_type, + typename iterator_traits<_II2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2); + } + + /** + * @brief Tests a range for element-wise equality. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A boolean true or false. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns true or + * false depending on whether all of the corresponding elements of the + * ranges are equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + equal(_IIter1 __first1, _IIter1 __last1, + _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_IIter1>) + __glibcxx_function_requires(_InputIteratorConcept<_IIter2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2, + __binary_pred); + } +#endif // C++14 + + /** + * @brief Performs @b dictionary comparison on ranges. + * @ingroup sorting_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @return A boolean true or false. + * + * Returns true if the sequence of elements defined by the range + * [first1,last1) is lexicographically less than the sequence of elements + * defined by the range [first2,last2). Returns false otherwise. + * (Quoted from [25.3.8]/1.) If the iterators are all character pointers, + * then this is an inline call to @c memcmp. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + lexicographical_compare(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2) + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename iterator_traits<_II1>::value_type _ValueType1; + typedef typename iterator_traits<_II2>::value_type _ValueType2; +#endif + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType1, _ValueType2>) + __glibcxx_function_requires(_LessThanOpConcept<_ValueType2, _ValueType1>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__lexicographical_compare_aux(__first1, __last1, + __first2, __last2); + } + + /** + * @brief Performs @b dictionary comparison on ranges. + * @ingroup sorting_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return A boolean true or false. + * + * The same as the four-parameter @c lexicographical_compare, but uses the + * comp parameter instead of @c <. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + lexicographical_compare(_II1 __first1, _II1 __last1, + _II2 __first2, _II2 __last2, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_II1>) + __glibcxx_function_requires(_InputIteratorConcept<_II2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return std::__lexicographical_compare_impl + (__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__comp)); + } + +#if __cpp_lib_three_way_comparison + // Iter points to a contiguous range of unsigned narrow character type + // or std::byte, suitable for comparison by memcmp. + template + concept __is_byte_iter = contiguous_iterator<_Iter> + && __is_memcmp_ordered>::__value; + + // Return a struct with two members, initialized to the smaller of x and y + // (or x if they compare equal) and the result of the comparison x <=> y. + template + constexpr auto + __min_cmp(_Tp __x, _Tp __y) + { + struct _Res { + _Tp _M_min; + decltype(__x <=> __y) _M_cmp; + }; + auto __c = __x <=> __y; + if (__c > 0) + return _Res{__y, __c}; + return _Res{__x, __c}; + } + + /** + * @brief Performs dictionary comparison on ranges. + * @ingroup sorting_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __comp A @link comparison_functors comparison functor@endlink. + * @return The comparison category that `__comp(*__first1, *__first2)` + * returns. + */ + template + constexpr auto + lexicographical_compare_three_way(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2, + _InputIter2 __last2, + _Comp __comp) + -> decltype(__comp(*__first1, *__first2)) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIter1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIter2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + +#if __cpp_lib_is_constant_evaluated + using _Cat = decltype(__comp(*__first1, *__first2)); + static_assert(same_as, _Cat>); + + if (!std::is_constant_evaluated()) + if constexpr (same_as<_Comp, __detail::_Synth3way> + || same_as<_Comp, compare_three_way>) + if constexpr (__is_byte_iter<_InputIter1>) + if constexpr (__is_byte_iter<_InputIter2>) + { + const auto [__len, __lencmp] = _GLIBCXX_STD_A:: + __min_cmp(__last1 - __first1, __last2 - __first2); + if (__len) + { + const auto __c + = __builtin_memcmp(&*__first1, &*__first2, __len) <=> 0; + if (__c != 0) + return __c; + } + return __lencmp; + } +#endif // is_constant_evaluated + while (__first1 != __last1) + { + if (__first2 == __last2) + return strong_ordering::greater; + if (auto __cmp = __comp(*__first1, *__first2); __cmp != 0) + return __cmp; + ++__first1; + ++__first2; + } + return (__first2 == __last2) <=> true; // See PR 94006 + } + + template + constexpr auto + lexicographical_compare_three_way(_InputIter1 __first1, + _InputIter1 __last1, + _InputIter2 __first2, + _InputIter2 __last2) + { + return _GLIBCXX_STD_A:: + lexicographical_compare_three_way(__first1, __last1, __first2, __last2, + compare_three_way{}); + } +#endif // three_way_comparison + + template + _GLIBCXX20_CONSTEXPR + pair<_InputIterator1, _InputIterator2> + __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _BinaryPredicate __binary_pred) + { + while (__first1 != __last1 && __binary_pred(__first1, __first2)) + { + ++__first1; + ++__first2; + } + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using @c == and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } + +#if __cplusplus > 201103L + + template + _GLIBCXX20_CONSTEXPR + pair<_InputIterator1, _InputIterator2> + __mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __binary_pred) + { + while (__first1 != __last1 && __first2 != __last2 + && __binary_pred(__first1, __first2)) + { + ++__first1; + ++__first2; + } + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using @c == and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_InputIterator1>::value_type, + typename iterator_traits<_InputIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } + + /** + * @brief Finds the places in ranges which don't match. + * @ingroup non_mutating_algorithms + * @param __first1 An input iterator. + * @param __last1 An input iterator. + * @param __first2 An input iterator. + * @param __last2 An input iterator. + * @param __binary_pred A binary predicate @link functors + * functor@endlink. + * @return A pair of iterators pointing to the first mismatch. + * + * This compares the elements of two ranges using the binary_pred + * parameter, and returns a pair + * of iterators. The first iterator points into the first range, the + * second iterator points into the second range, and the elements pointed + * to by the iterators are not equal. + */ + template + _GLIBCXX20_CONSTEXPR + inline pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __binary_pred) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + __glibcxx_requires_valid_range(__first2, __last2); + + return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__binary_pred)); + } +#endif + +_GLIBCXX_END_NAMESPACE_ALGO + + /// This is an overload used by find algos for the Input Iterator case. + template + _GLIBCXX20_CONSTEXPR + inline _InputIterator + __find_if(_InputIterator __first, _InputIterator __last, + _Predicate __pred, input_iterator_tag) + { + while (__first != __last && !__pred(__first)) + ++__first; + return __first; + } + + /// This is an overload used by find algos for the RAI case. + template + _GLIBCXX20_CONSTEXPR + _RandomAccessIterator + __find_if(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Predicate __pred, random_access_iterator_tag) + { + typename iterator_traits<_RandomAccessIterator>::difference_type + __trip_count = (__last - __first) >> 2; + + for (; __trip_count > 0; --__trip_count) + { + if (__pred(__first)) + return __first; + ++__first; + + if (__pred(__first)) + return __first; + ++__first; + + if (__pred(__first)) + return __first; + ++__first; + + if (__pred(__first)) + return __first; + ++__first; + } + + switch (__last - __first) + { + case 3: + if (__pred(__first)) + return __first; + ++__first; + // FALLTHRU + case 2: + if (__pred(__first)) + return __first; + ++__first; + // FALLTHRU + case 1: + if (__pred(__first)) + return __first; + ++__first; + // FALLTHRU + case 0: + default: + return __last; + } + } + + template + _GLIBCXX20_CONSTEXPR + inline _Iterator + __find_if(_Iterator __first, _Iterator __last, _Predicate __pred) + { + return __find_if(__first, __last, __pred, + std::__iterator_category(__first)); + } + + template + _GLIBCXX20_CONSTEXPR + typename iterator_traits<_InputIterator>::difference_type + __count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) + { + typename iterator_traits<_InputIterator>::difference_type __n = 0; + for (; __first != __last; ++__first) + if (__pred(__first)) + ++__n; + return __n; + } + +#if __cplusplus >= 201103L + template + _GLIBCXX20_CONSTEXPR + bool + __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _BinaryPredicate __pred) + { + // Efficiently compare identical prefixes: O(N) if sequences + // have the same elements in the same order. + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!__pred(__first1, __first2)) + break; + + if (__first1 == __last1) + return true; + + // Establish __last2 assuming equal ranges by iterating over the + // rest of the list. + _ForwardIterator2 __last2 = __first2; + std::advance(__last2, std::distance(__first1, __last1)); + for (_ForwardIterator1 __scan = __first1; __scan != __last1; ++__scan) + { + if (__scan != std::__find_if(__first1, __scan, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan))) + continue; // We've seen this one before. + + auto __matches + = std::__count_if(__first2, __last2, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)); + if (0 == __matches || + std::__count_if(__scan, __last1, + __gnu_cxx::__ops::__iter_comp_iter(__pred, __scan)) + != __matches) + return false; + } + return true; + } + + /** + * @brief Checks whether a permutation of the second sequence is equal + * to the first sequence. + * @ingroup non_mutating_algorithms + * @param __first1 Start of first range. + * @param __last1 End of first range. + * @param __first2 Start of second range. + * @return true if there exists a permutation of the elements in the range + * [__first2, __first2 + (__last1 - __first1)), beginning with + * ForwardIterator2 begin, such that equal(__first1, __last1, begin) + * returns true; otherwise, returns false. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2) + { + // concept requirements + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>) + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>) + __glibcxx_function_requires(_EqualOpConcept< + typename iterator_traits<_ForwardIterator1>::value_type, + typename iterator_traits<_ForwardIterator2>::value_type>) + __glibcxx_requires_valid_range(__first1, __last1); + + return std::__is_permutation(__first1, __last1, __first2, + __gnu_cxx::__ops::__iter_equal_to_iter()); + } +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +// NB: This file is included within many other C++ includes, as a way +// of getting the base algorithms. So, make sure that parallel bits +// come in too if requested. +#ifdef _GLIBCXX_PARALLEL +# include +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_bvector.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_bvector.h new file mode 100755 index 0000000..fadb661 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_bvector.h @@ -0,0 +1,1382 @@ +// vector specialization -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_bvector.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{vector} + */ + +#ifndef _STL_BVECTOR_H +#define _STL_BVECTOR_H 1 + +#if __cplusplus >= 201103L +#include +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + typedef unsigned long _Bit_type; + enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) }; + + struct _Bit_reference + { + _Bit_type * _M_p; + _Bit_type _M_mask; + + _Bit_reference(_Bit_type * __x, _Bit_type __y) + : _M_p(__x), _M_mask(__y) { } + + _Bit_reference() _GLIBCXX_NOEXCEPT : _M_p(0), _M_mask(0) { } + +#if __cplusplus >= 201103L + _Bit_reference(const _Bit_reference&) = default; +#endif + + operator bool() const _GLIBCXX_NOEXCEPT + { return !!(*_M_p & _M_mask); } + + _Bit_reference& + operator=(bool __x) _GLIBCXX_NOEXCEPT + { + if (__x) + *_M_p |= _M_mask; + else + *_M_p &= ~_M_mask; + return *this; + } + + _Bit_reference& + operator=(const _Bit_reference& __x) _GLIBCXX_NOEXCEPT + { return *this = bool(__x); } + + bool + operator==(const _Bit_reference& __x) const + { return bool(*this) == bool(__x); } + + bool + operator<(const _Bit_reference& __x) const + { return !bool(*this) && bool(__x); } + + void + flip() _GLIBCXX_NOEXCEPT + { *_M_p ^= _M_mask; } + }; + +#if __cplusplus >= 201103L + inline void + swap(_Bit_reference __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + inline void + swap(_Bit_reference __x, bool& __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + inline void + swap(bool& __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } +#endif + + struct _Bit_iterator_base + : public std::iterator + { + _Bit_type * _M_p; + unsigned int _M_offset; + + _Bit_iterator_base(_Bit_type * __x, unsigned int __y) + : _M_p(__x), _M_offset(__y) { } + + void + _M_bump_up() + { + if (_M_offset++ == int(_S_word_bit) - 1) + { + _M_offset = 0; + ++_M_p; + } + } + + void + _M_bump_down() + { + if (_M_offset-- == 0) + { + _M_offset = int(_S_word_bit) - 1; + --_M_p; + } + } + + void + _M_incr(ptrdiff_t __i) + { + difference_type __n = __i + _M_offset; + _M_p += __n / int(_S_word_bit); + __n = __n % int(_S_word_bit); + if (__n < 0) + { + __n += int(_S_word_bit); + --_M_p; + } + _M_offset = static_cast(__n); + } + + friend _GLIBCXX20_CONSTEXPR bool + operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; } + +#if __cpp_lib_three_way_comparison + friend constexpr strong_ordering + operator<=>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + noexcept + { + if (const auto __cmp = __x._M_p <=> __y._M_p; __cmp != 0) + return __cmp; + return __x._M_offset <=> __y._M_offset; + } +#else + friend bool + operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { + return __x._M_p < __y._M_p + || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset); + } + + friend bool + operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__x == __y); } + + friend bool + operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return __y < __x; } + + friend bool + operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__y < __x); } + + friend bool + operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { return !(__x < __y); } +#endif // three-way comparison + + friend ptrdiff_t + operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) + { + return (int(_S_word_bit) * (__x._M_p - __y._M_p) + + __x._M_offset - __y._M_offset); + } + }; + + struct _Bit_iterator : public _Bit_iterator_base + { + typedef _Bit_reference reference; +#if __cplusplus > 201703L + typedef void pointer; +#else + typedef _Bit_reference* pointer; +#endif + typedef _Bit_iterator iterator; + + _Bit_iterator() : _Bit_iterator_base(0, 0) { } + + _Bit_iterator(_Bit_type * __x, unsigned int __y) + : _Bit_iterator_base(__x, __y) { } + + iterator + _M_const_cast() const + { return *this; } + + reference + operator*() const + { return reference(_M_p, 1UL << _M_offset); } + + iterator& + operator++() + { + _M_bump_up(); + return *this; + } + + iterator + operator++(int) + { + iterator __tmp = *this; + _M_bump_up(); + return __tmp; + } + + iterator& + operator--() + { + _M_bump_down(); + return *this; + } + + iterator + operator--(int) + { + iterator __tmp = *this; + _M_bump_down(); + return __tmp; + } + + iterator& + operator+=(difference_type __i) + { + _M_incr(__i); + return *this; + } + + iterator& + operator-=(difference_type __i) + { + *this += -__i; + return *this; + } + + reference + operator[](difference_type __i) const + { return *(*this + __i); } + + friend iterator + operator+(const iterator& __x, difference_type __n) + { + iterator __tmp = __x; + __tmp += __n; + return __tmp; + } + + friend iterator + operator+(difference_type __n, const iterator& __x) + { return __x + __n; } + + friend iterator + operator-(const iterator& __x, difference_type __n) + { + iterator __tmp = __x; + __tmp -= __n; + return __tmp; + } + }; + + struct _Bit_const_iterator : public _Bit_iterator_base + { + typedef bool reference; + typedef bool const_reference; +#if __cplusplus > 201703L + typedef void pointer; +#else + typedef const bool* pointer; +#endif + typedef _Bit_const_iterator const_iterator; + + _Bit_const_iterator() : _Bit_iterator_base(0, 0) { } + + _Bit_const_iterator(_Bit_type * __x, unsigned int __y) + : _Bit_iterator_base(__x, __y) { } + + _Bit_const_iterator(const _Bit_iterator& __x) + : _Bit_iterator_base(__x._M_p, __x._M_offset) { } + + _Bit_iterator + _M_const_cast() const + { return _Bit_iterator(_M_p, _M_offset); } + + const_reference + operator*() const + { return _Bit_reference(_M_p, 1UL << _M_offset); } + + const_iterator& + operator++() + { + _M_bump_up(); + return *this; + } + + const_iterator + operator++(int) + { + const_iterator __tmp = *this; + _M_bump_up(); + return __tmp; + } + + const_iterator& + operator--() + { + _M_bump_down(); + return *this; + } + + const_iterator + operator--(int) + { + const_iterator __tmp = *this; + _M_bump_down(); + return __tmp; + } + + const_iterator& + operator+=(difference_type __i) + { + _M_incr(__i); + return *this; + } + + const_iterator& + operator-=(difference_type __i) + { + *this += -__i; + return *this; + } + + const_reference + operator[](difference_type __i) const + { return *(*this + __i); } + + friend const_iterator + operator+(const const_iterator& __x, difference_type __n) + { + const_iterator __tmp = __x; + __tmp += __n; + return __tmp; + } + + friend const_iterator + operator-(const const_iterator& __x, difference_type __n) + { + const_iterator __tmp = __x; + __tmp -= __n; + return __tmp; + } + + friend const_iterator + operator+(difference_type __n, const const_iterator& __x) + { return __x + __n; } + }; + + template + struct _Bvector_base + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Bit_type>::other _Bit_alloc_type; + typedef typename __gnu_cxx::__alloc_traits<_Bit_alloc_type> + _Bit_alloc_traits; + typedef typename _Bit_alloc_traits::pointer _Bit_pointer; + + struct _Bvector_impl_data + { +#if !_GLIBCXX_INLINE_VERSION + _Bit_iterator _M_start; +#else + // We don't need the offset field for the start, it's always zero. + struct { + _Bit_type* _M_p; + // Allow assignment from iterators (assume offset is zero): + void operator=(_Bit_iterator __it) { _M_p = __it._M_p; } + } _M_start; +#endif + _Bit_iterator _M_finish; + _Bit_pointer _M_end_of_storage; + + _Bvector_impl_data() _GLIBCXX_NOEXCEPT + : _M_start(), _M_finish(), _M_end_of_storage() + { } + +#if __cplusplus >= 201103L + _Bvector_impl_data(const _Bvector_impl_data&) = default; + _Bvector_impl_data& + operator=(const _Bvector_impl_data&) = default; + + _Bvector_impl_data(_Bvector_impl_data&& __x) noexcept + : _Bvector_impl_data(__x) + { __x._M_reset(); } + + void + _M_move_data(_Bvector_impl_data&& __x) noexcept + { + *this = __x; + __x._M_reset(); + } +#endif + + void + _M_reset() _GLIBCXX_NOEXCEPT + { *this = _Bvector_impl_data(); } + + void + _M_swap_data(_Bvector_impl_data& __x) _GLIBCXX_NOEXCEPT + { + // Do not use std::swap(_M_start, __x._M_start), etc as it loses + // information used by TBAA. + std::swap(*this, __x); + } + }; + + struct _Bvector_impl + : public _Bit_alloc_type, public _Bvector_impl_data + { + _Bvector_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Bit_alloc_type>::value) + : _Bit_alloc_type() + { } + + _Bvector_impl(const _Bit_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Bit_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + // Not defaulted, to enforce noexcept(true) even when + // !is_nothrow_move_constructible<_Bit_alloc_type>. + _Bvector_impl(_Bvector_impl&& __x) noexcept + : _Bit_alloc_type(std::move(__x)), _Bvector_impl_data(std::move(__x)) + { } + + _Bvector_impl(_Bit_alloc_type&& __a, _Bvector_impl&& __x) noexcept + : _Bit_alloc_type(std::move(__a)), _Bvector_impl_data(std::move(__x)) + { } +#endif + + _Bit_type* + _M_end_addr() const _GLIBCXX_NOEXCEPT + { + if (this->_M_end_of_storage) + return std::__addressof(this->_M_end_of_storage[-1]) + 1; + return 0; + } + }; + + public: + typedef _Alloc allocator_type; + + _Bit_alloc_type& + _M_get_Bit_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Bit_alloc_type& + _M_get_Bit_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Bit_allocator()); } + +#if __cplusplus >= 201103L + _Bvector_base() = default; +#else + _Bvector_base() { } +#endif + + _Bvector_base(const allocator_type& __a) + : _M_impl(__a) { } + +#if __cplusplus >= 201103L + _Bvector_base(_Bvector_base&&) = default; + + _Bvector_base(_Bvector_base&& __x, const allocator_type& __a) noexcept + : _M_impl(_Bit_alloc_type(__a), std::move(__x._M_impl)) + { } +#endif + + ~_Bvector_base() + { this->_M_deallocate(); } + + protected: + _Bvector_impl _M_impl; + + _Bit_pointer + _M_allocate(size_t __n) + { return _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); } + + void + _M_deallocate() + { + if (_M_impl._M_start._M_p) + { + const size_t __n = _M_impl._M_end_addr() - _M_impl._M_start._M_p; + _Bit_alloc_traits::deallocate(_M_impl, + _M_impl._M_end_of_storage - __n, + __n); + _M_impl._M_reset(); + } + } + +#if __cplusplus >= 201103L + void + _M_move_data(_Bvector_base&& __x) noexcept + { _M_impl._M_move_data(std::move(__x._M_impl)); } +#endif + + static size_t + _S_nword(size_t __n) + { return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); } + }; + + /** + * @brief A specialization of vector for booleans which offers fixed time + * access to individual elements in any order. + * + * @ingroup sequences + * + * @tparam _Alloc Allocator type. + * + * Note that vector does not actually meet the requirements for being + * a container. This is because the reference and pointer types are not + * really references and pointers to bool. See DR96 for details. @see + * vector for function documentation. + * + * In some terminology a %vector can be described as a dynamic + * C-style array, it offers fast and efficient access to individual + * elements in any order and saves the user from worrying about + * memory and size allocation. Subscripting ( @c [] ) access is + * also provided as with C-style arrays. + */ + template + class vector : protected _Bvector_base<_Alloc> + { + typedef _Bvector_base<_Alloc> _Base; + typedef typename _Base::_Bit_pointer _Bit_pointer; + typedef typename _Base::_Bit_alloc_traits _Bit_alloc_traits; + +#if __cplusplus >= 201103L + friend struct std::hash; +#endif + + public: + typedef bool value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Bit_reference reference; + typedef bool const_reference; + typedef _Bit_reference* pointer; + typedef const bool* const_pointer; + typedef _Bit_iterator iterator; + typedef _Bit_const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef _Alloc allocator_type; + + allocator_type + get_allocator() const + { return _Base::get_allocator(); } + + protected: + using _Base::_M_allocate; + using _Base::_M_deallocate; + using _Base::_S_nword; + using _Base::_M_get_Bit_allocator; + + public: +#if __cplusplus >= 201103L + vector() = default; +#else + vector() { } +#endif + + explicit + vector(const allocator_type& __a) + : _Base(__a) { } + +#if __cplusplus >= 201103L + explicit + vector(size_type __n, const allocator_type& __a = allocator_type()) + : vector(__n, false, __a) + { } + + vector(size_type __n, const bool& __value, + const allocator_type& __a = allocator_type()) +#else + explicit + vector(size_type __n, const bool& __value = bool(), + const allocator_type& __a = allocator_type()) +#endif + : _Base(__a) + { + _M_initialize(__n); + _M_initialize_value(__value); + } + + vector(const vector& __x) + : _Base(_Bit_alloc_traits::_S_select_on_copy(__x._M_get_Bit_allocator())) + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), begin()); + } + +#if __cplusplus >= 201103L + vector(vector&&) = default; + + private: + vector(vector&& __x, const allocator_type& __a, true_type) noexcept + : _Base(std::move(__x), __a) + { } + + vector(vector&& __x, const allocator_type& __a, false_type) + : _Base(__a) + { + if (__x.get_allocator() == __a) + this->_M_move_data(std::move(__x)); + else + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), begin()); + __x.clear(); + } + } + + public: + vector(vector&& __x, const allocator_type& __a) + noexcept(_Bit_alloc_traits::_S_always_equal()) + : vector(std::move(__x), __a, + typename _Bit_alloc_traits::is_always_equal{}) + { } + + vector(const vector& __x, const allocator_type& __a) + : _Base(__a) + { + _M_initialize(__x.size()); + _M_copy_aligned(__x.begin(), __x.end(), begin()); + } + + vector(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_initialize_range(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + +#if __cplusplus >= 201103L + template> + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_initialize_range(__first, __last, + std::__iterator_category(__first)); + } +#else + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + ~vector() _GLIBCXX_NOEXCEPT { } + + vector& + operator=(const vector& __x) + { + if (&__x == this) + return *this; +#if __cplusplus >= 201103L + if (_Bit_alloc_traits::_S_propagate_on_copy_assign()) + { + if (this->_M_get_Bit_allocator() != __x._M_get_Bit_allocator()) + { + this->_M_deallocate(); + std::__alloc_on_copy(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + _M_initialize(__x.size()); + } + else + std::__alloc_on_copy(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + } +#endif + if (__x.size() > capacity()) + { + this->_M_deallocate(); + _M_initialize(__x.size()); + } + this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), + begin()); + return *this; + } + +#if __cplusplus >= 201103L + vector& + operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move()) + { + if (_Bit_alloc_traits::_S_propagate_on_move_assign() + || this->_M_get_Bit_allocator() == __x._M_get_Bit_allocator()) + { + this->_M_deallocate(); + this->_M_move_data(std::move(__x)); + std::__alloc_on_move(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + } + else + { + if (__x.size() > capacity()) + { + this->_M_deallocate(); + _M_initialize(__x.size()); + } + this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), + begin()); + __x.clear(); + } + return *this; + } + + vector& + operator=(initializer_list __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } +#endif + + // assign(), a generalized assignment member function. Two + // versions: one that takes a count, and one that takes a range. + // The range version is a member template, so we dispatch on whether + // or not the type is an integer. + void + assign(size_type __n, const bool& __x) + { _M_fill_assign(__n, __x); } + +#if __cplusplus >= 201103L + template> + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + void + assign(initializer_list __l) + { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } +#endif + + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_start._M_p, 0); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_start._M_p, 0); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_start._M_p, 0); } + + const_iterator + cend() const noexcept + { return this->_M_impl._M_finish; } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + size_type + size() const _GLIBCXX_NOEXCEPT + { return size_type(end() - begin()); } + + size_type + max_size() const _GLIBCXX_NOEXCEPT + { + const size_type __isize = + __gnu_cxx::__numeric_traits::__max + - int(_S_word_bit) + 1; + const size_type __asize + = _Bit_alloc_traits::max_size(_M_get_Bit_allocator()); + return (__asize <= __isize / int(_S_word_bit) + ? __asize * int(_S_word_bit) : __isize); + } + + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return size_type(const_iterator(this->_M_impl._M_end_addr(), 0) + - begin()); } + + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return begin() == end(); } + + reference + operator[](size_type __n) + { return begin()[__n]; } + + const_reference + operator[](size_type __n) const + { return begin()[__n]; } + + protected: + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("vector::_M_range_check: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + reference + at(size_type __n) + { _M_range_check(__n); return (*this)[__n]; } + + const_reference + at(size_type __n) const + { _M_range_check(__n); return (*this)[__n]; } + + void + reserve(size_type __n) + { + if (__n > max_size()) + __throw_length_error(__N("vector::reserve")); + if (capacity() < __n) + _M_reallocate(__n); + } + + reference + front() + { return *begin(); } + + const_reference + front() const + { return *begin(); } + + reference + back() + { return *(end() - 1); } + + const_reference + back() const + { return *(end() - 1); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + // N.B. DR 464 says nothing about vector but we need something + // here due to the way we are implementing DR 464 in the debug-mode + // vector class. + void + data() _GLIBCXX_NOEXCEPT { } + + void + push_back(bool __x) + { + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()) + *this->_M_impl._M_finish++ = __x; + else + _M_insert_aux(end(), __x); + } + + void + swap(vector& __x) _GLIBCXX_NOEXCEPT + { +#if __cplusplus >= 201103L + __glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value + || _M_get_Bit_allocator() == __x._M_get_Bit_allocator()); +#endif + this->_M_impl._M_swap_data(__x._M_impl); + _Bit_alloc_traits::_S_on_swap(_M_get_Bit_allocator(), + __x._M_get_Bit_allocator()); + } + + // [23.2.5]/1, third-to-last entry in synopsis listing + static void + swap(reference __x, reference __y) _GLIBCXX_NOEXCEPT + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const bool& __x = bool()) +#else + insert(iterator __position, const bool& __x = bool()) +#endif + { + const difference_type __n = __position - begin(); + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr() + && __position == end()) + *this->_M_impl._M_finish++ = __x; + else + _M_insert_aux(__position._M_const_cast(), __x); + return begin() + __n; + } + +#if __cplusplus >= 201103L + template> + iterator + insert(const_iterator __position, + _InputIterator __first, _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_insert_range(__position._M_const_cast(), + __first, __last, + std::__iterator_category(__first)); + return begin() + __offset; + } +#else + template + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, size_type __n, const bool& __x) + { + difference_type __offset = __position - cbegin(); + _M_fill_insert(__position._M_const_cast(), __n, __x); + return begin() + __offset; + } +#else + void + insert(iterator __position, size_type __n, const bool& __x) + { _M_fill_insert(__position, __n, __x); } +#endif + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __p, initializer_list __l) + { return this->insert(__p, __l.begin(), __l.end()); } +#endif + + void + pop_back() + { --this->_M_impl._M_finish; } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { return _M_erase(__position._M_const_cast()); } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) +#else + erase(iterator __first, iterator __last) +#endif + { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } + + void + resize(size_type __new_size, bool __x = bool()) + { + if (__new_size < size()) + _M_erase_at_end(begin() + difference_type(__new_size)); + else + insert(end(), __new_size - size(), __x); + } + +#if __cplusplus >= 201103L + void + shrink_to_fit() + { _M_shrink_to_fit(); } +#endif + + void + flip() _GLIBCXX_NOEXCEPT + { + _Bit_type * const __end = this->_M_impl._M_end_addr(); + for (_Bit_type * __p = this->_M_impl._M_start._M_p; __p != __end; ++__p) + *__p = ~*__p; + } + + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(begin()); } + +#if __cplusplus >= 201103L + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + push_back(bool(__args...)); +#if __cplusplus > 201402L + return back(); +#endif + } + + template + iterator + emplace(const_iterator __pos, _Args&&... __args) + { return insert(__pos, bool(__args...)); } +#endif + + protected: + // Precondition: __first._M_offset == 0 && __result._M_offset == 0. + iterator + _M_copy_aligned(const_iterator __first, const_iterator __last, + iterator __result) + { + _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p); + return std::copy(const_iterator(__last._M_p, 0), __last, + iterator(__q, 0)); + } + + void + _M_initialize(size_type __n) + { + if (__n) + { + _Bit_pointer __q = this->_M_allocate(__n); + this->_M_impl._M_end_of_storage = __q + _S_nword(__n); + iterator __start = iterator(std::__addressof(*__q), 0); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __start + difference_type(__n); + } + } + + void + _M_initialize_value(bool __x) + { + if (_Bit_type* __p = this->_M_impl._M_start._M_p) + __builtin_memset(__p, __x ? ~0 : 0, + (this->_M_impl._M_end_addr() - __p) + * sizeof(_Bit_type)); + } + + void + _M_reallocate(size_type __n); + +#if __cplusplus >= 201103L + bool + _M_shrink_to_fit(); +#endif + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { + _M_initialize(static_cast(__n)); + _M_initialize_value(__x); + } + + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_initialize_range(__first, __last, + std::__iterator_category(__first)); } +#endif + + template + void + _M_initialize_range(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + for (; __first != __last; ++__first) + push_back(*__first); + } + + template + void + _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + _M_initialize(__n); + std::copy(__first, __last, begin()); + } + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#endif + + void + _M_fill_assign(size_t __n, bool __x) + { + if (__n > size()) + { + _M_initialize_value(__x); + insert(end(), __n - size(), __x); + } + else + { + _M_erase_at_end(begin() + __n); + _M_initialize_value(__x); + } + } + + template + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + iterator __cur = begin(); + for (; __first != __last && __cur != end(); ++__cur, (void)++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + insert(end(), __first, __last); + } + + template + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + if (__len < size()) + _M_erase_at_end(std::copy(__first, __last, begin())); + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, begin()); + insert(end(), __mid, __last); + } + } + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, + __true_type) + { _M_fill_insert(__pos, __n, __x); } + + template + void + _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + __false_type) + { _M_insert_range(__pos, __first, __last, + std::__iterator_category(__first)); } +#endif + + void + _M_fill_insert(iterator __position, size_type __n, bool __x); + + template + void + _M_insert_range(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + for (; __first != __last; ++__first) + { + __pos = insert(__pos, *__first); + ++__pos; + } + } + + template + void + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + void + _M_insert_aux(iterator __position, bool __x); + + size_type + _M_check_len(size_type __n, const char* __s) const + { + if (max_size() - size() < __n) + __throw_length_error(__N(__s)); + + const size_type __len = size() + std::max(size(), __n); + return (__len < size() || __len > max_size()) ? max_size() : __len; + } + + void + _M_erase_at_end(iterator __pos) + { this->_M_impl._M_finish = __pos; } + + iterator + _M_erase(iterator __pos); + + iterator + _M_erase(iterator __first, iterator __last); + }; + +_GLIBCXX_END_NAMESPACE_CONTAINER + + inline void + __fill_bvector(_GLIBCXX_STD_C::_Bit_type * __v, + unsigned int __first, unsigned int __last, bool __x) + { + using _GLIBCXX_STD_C::_Bit_type; + using _GLIBCXX_STD_C::_S_word_bit; + const _Bit_type __fmask = ~0ul << __first; + const _Bit_type __lmask = ~0ul >> (_S_word_bit - __last); + const _Bit_type __mask = __fmask & __lmask; + + if (__x) + *__v |= __mask; + else + *__v &= ~__mask; + } + + inline void + __fill_a1(_GLIBCXX_STD_C::_Bit_iterator __first, + _GLIBCXX_STD_C::_Bit_iterator __last, const bool& __x) + { + using _GLIBCXX_STD_C::_Bit_type; + using _GLIBCXX_STD_C::_S_word_bit; + if (__first._M_p != __last._M_p) + { + _Bit_type* __first_p = __first._M_p; + if (__first._M_offset != 0) + __fill_bvector(__first_p++, __first._M_offset, _S_word_bit, __x); + + __builtin_memset(__first_p, __x ? ~0 : 0, + (__last._M_p - __first_p) * sizeof(_Bit_type)); + + if (__last._M_offset != 0) + __fill_bvector(__last._M_p, 0, __last._M_offset, __x); + } + else if (__first._M_offset != __last._M_offset) + __fill_bvector(__first._M_p, __first._M_offset, __last._M_offset, __x); + } + +#if __cplusplus >= 201103L + // DR 1182. + /// std::hash specialization for vector. + template + struct hash<_GLIBCXX_STD_C::vector> + : public __hash_base> + { + size_t + operator()(const _GLIBCXX_STD_C::vector&) const noexcept; + }; +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_construct.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_construct.h new file mode 100755 index 0000000..ad75eca --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_construct.h @@ -0,0 +1,256 @@ +// nonstandard construct and destroy functions -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_construct.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_CONSTRUCT_H +#define _STL_CONSTRUCT_H 1 + +#include +#include +#include // for iterator_traits +#include // for advance + +/* This file provides the C++17 functions std::destroy_at, std::destroy, and + * std::destroy_n, and the C++20 function std::construct_at. + * It also provides std::_Construct, std::_Destroy,and std::_Destroy_n functions + * which are defined in all standard modes and so can be used in C++98-14 code. + * The _Destroy functions will dispatch to destroy_at during constant + * evaluation, because calls to that function are intercepted by the compiler + * to allow use in constant expressions. + */ + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + template + _GLIBCXX20_CONSTEXPR inline void + destroy_at(_Tp* __location) + { + if constexpr (__cplusplus > 201703L && is_array_v<_Tp>) + { + for (auto& __x : *__location) + std::destroy_at(std::__addressof(__x)); + } + else + __location->~_Tp(); + } + +#if __cplusplus > 201703L + template + constexpr auto + construct_at(_Tp* __location, _Args&&... __args) + noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...))) + -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...)) + { return ::new((void*)__location) _Tp(std::forward<_Args>(__args)...); } +#endif // C++20 +#endif// C++17 + + /** + * Constructs an object in existing memory by invoking an allocated + * object's constructor with an initializer. + */ +#if __cplusplus >= 201103L + template + inline void + _Construct(_Tp* __p, _Args&&... __args) + { ::new(static_cast(__p)) _Tp(std::forward<_Args>(__args)...); } +#else + template + inline void + _Construct(_T1* __p, const _T2& __value) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 402. wrong new expression in [some_]allocator::construct + ::new(static_cast(__p)) _T1(__value); + } +#endif + + template + inline void + _Construct_novalue(_T1* __p) + { ::new(static_cast(__p)) _T1; } + + template + _GLIBCXX20_CONSTEXPR void + _Destroy(_ForwardIterator __first, _ForwardIterator __last); + + /** + * Destroy the object pointed to by a pointer type. + */ + template + _GLIBCXX14_CONSTEXPR inline void + _Destroy(_Tp* __pointer) + { +#if __cplusplus > 201703L + std::destroy_at(__pointer); +#else + __pointer->~_Tp(); +#endif + } + + template + struct _Destroy_aux + { + template + static _GLIBCXX20_CONSTEXPR void + __destroy(_ForwardIterator __first, _ForwardIterator __last) + { + for (; __first != __last; ++__first) + std::_Destroy(std::__addressof(*__first)); + } + }; + + template<> + struct _Destroy_aux + { + template + static void + __destroy(_ForwardIterator, _ForwardIterator) { } + }; + + /** + * Destroy a range of objects. If the value_type of the object has + * a trivial destructor, the compiler should optimize all of this + * away, otherwise the objects' destructors must be invoked. + */ + template + _GLIBCXX20_CONSTEXPR inline void + _Destroy(_ForwardIterator __first, _ForwardIterator __last) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _Value_type; +#if __cplusplus >= 201103L + // A deleted destructor is trivial, this ensures we reject such types: + static_assert(is_destructible<_Value_type>::value, + "value type is destructible"); +#endif +#if __cplusplus > 201703L && defined __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return _Destroy_aux::__destroy(__first, __last); +#endif + std::_Destroy_aux<__has_trivial_destructor(_Value_type)>:: + __destroy(__first, __last); + } + + template + struct _Destroy_n_aux + { + template + static _GLIBCXX20_CONSTEXPR _ForwardIterator + __destroy_n(_ForwardIterator __first, _Size __count) + { + for (; __count > 0; (void)++__first, --__count) + std::_Destroy(std::__addressof(*__first)); + return __first; + } + }; + + template<> + struct _Destroy_n_aux + { + template + static _ForwardIterator + __destroy_n(_ForwardIterator __first, _Size __count) + { + std::advance(__first, __count); + return __first; + } + }; + + /** + * Destroy a range of objects. If the value_type of the object has + * a trivial destructor, the compiler should optimize all of this + * away, otherwise the objects' destructors must be invoked. + */ + template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator + _Destroy_n(_ForwardIterator __first, _Size __count) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _Value_type; +#if __cplusplus >= 201103L + // A deleted destructor is trivial, this ensures we reject such types: + static_assert(is_destructible<_Value_type>::value, + "value type is destructible"); +#endif +#if __cplusplus > 201703L && defined __cpp_lib_is_constant_evaluated + if (std::is_constant_evaluated()) + return _Destroy_n_aux::__destroy_n(__first, __count); +#endif + return std::_Destroy_n_aux<__has_trivial_destructor(_Value_type)>:: + __destroy_n(__first, __count); + } + +#if __cplusplus >= 201703L + template + _GLIBCXX20_CONSTEXPR inline void + destroy(_ForwardIterator __first, _ForwardIterator __last) + { + std::_Destroy(__first, __last); + } + + template + _GLIBCXX20_CONSTEXPR inline _ForwardIterator + destroy_n(_ForwardIterator __first, _Size __count) + { + return std::_Destroy_n(__first, __count); + } +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_CONSTRUCT_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_deque.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_deque.h new file mode 100755 index 0000000..20c73b4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_deque.h @@ -0,0 +1,2335 @@ +// Deque implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_deque.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{deque} + */ + +#ifndef _STL_DEQUE_H +#define _STL_DEQUE_H 1 + +#include +#include +#include +#if __cplusplus >= 201103L +#include +#include // for __is_bitwise_relocatable +#endif +#if __cplusplus > 201703L +# include +#endif + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * @brief This function controls the size of memory nodes. + * @param __size The size of an element. + * @return The number (not byte size) of elements per node. + * + * This function started off as a compiler kludge from SGI, but + * seems to be a useful wrapper around a repeated constant + * expression. The @b 512 is tunable (and no other code needs to + * change), but no investigation has been done since inheriting the + * SGI code. Touch _GLIBCXX_DEQUE_BUF_SIZE only if you know what + * you are doing, however: changing it breaks the binary + * compatibility!! + */ + +#ifndef _GLIBCXX_DEQUE_BUF_SIZE +#define _GLIBCXX_DEQUE_BUF_SIZE 512 +#endif + + _GLIBCXX_CONSTEXPR inline size_t + __deque_buf_size(size_t __size) + { return (__size < _GLIBCXX_DEQUE_BUF_SIZE + ? size_t(_GLIBCXX_DEQUE_BUF_SIZE / __size) : size_t(1)); } + + + /** + * @brief A deque::iterator. + * + * Quite a bit of intelligence here. Much of the functionality of + * deque is actually passed off to this class. A deque holds two + * of these internally, marking its valid range. Access to + * elements is done as offsets of either of those two, relying on + * operator overloading in this class. + * + * All the functions are op overloads except for _M_set_node. + */ + template + struct _Deque_iterator + { +#if __cplusplus < 201103L + typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; + typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; + typedef _Tp* _Elt_pointer; + typedef _Tp** _Map_pointer; +#else + private: + template + using __iter = _Deque_iterator<_Tp, _CvTp&, __ptr_rebind<_Ptr, _CvTp>>; + public: + typedef __iter<_Tp> iterator; + typedef __iter const_iterator; + typedef __ptr_rebind<_Ptr, _Tp> _Elt_pointer; + typedef __ptr_rebind<_Ptr, _Elt_pointer> _Map_pointer; +#endif + + static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT + { return __deque_buf_size(sizeof(_Tp)); } + + typedef std::random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Ptr pointer; + typedef _Ref reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Deque_iterator _Self; + + _Elt_pointer _M_cur; + _Elt_pointer _M_first; + _Elt_pointer _M_last; + _Map_pointer _M_node; + + _Deque_iterator(_Elt_pointer __x, _Map_pointer __y) _GLIBCXX_NOEXCEPT + : _M_cur(__x), _M_first(*__y), + _M_last(*__y + _S_buffer_size()), _M_node(__y) { } + + _Deque_iterator() _GLIBCXX_NOEXCEPT + : _M_cur(), _M_first(), _M_last(), _M_node() { } + +#if __cplusplus < 201103L + // Conversion from iterator to const_iterator. + _Deque_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } +#else + // Conversion from iterator to const_iterator. + template, + is_same<_Iter, iterator>>> + _Deque_iterator(const _Iter& __x) noexcept + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } + + _Deque_iterator(const _Deque_iterator& __x) noexcept + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } + + _Deque_iterator& operator=(const _Deque_iterator&) = default; +#endif + + iterator + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return iterator(_M_cur, _M_node); } + + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *_M_cur; } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return _M_cur; } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + ++_M_cur; + if (_M_cur == _M_last) + { + _M_set_node(_M_node + 1); + _M_cur = _M_first; + } + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + ++*this; + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + if (_M_cur == _M_first) + { + _M_set_node(_M_node - 1); + _M_cur = _M_last; + } + --_M_cur; + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + --*this; + return __tmp; + } + + _Self& + operator+=(difference_type __n) _GLIBCXX_NOEXCEPT + { + const difference_type __offset = __n + (_M_cur - _M_first); + if (__offset >= 0 && __offset < difference_type(_S_buffer_size())) + _M_cur += __n; + else + { + const difference_type __node_offset = + __offset > 0 ? __offset / difference_type(_S_buffer_size()) + : -difference_type((-__offset - 1) + / _S_buffer_size()) - 1; + _M_set_node(_M_node + __node_offset); + _M_cur = _M_first + (__offset - __node_offset + * difference_type(_S_buffer_size())); + } + return *this; + } + + _Self& + operator-=(difference_type __n) _GLIBCXX_NOEXCEPT + { return *this += -__n; } + + reference + operator[](difference_type __n) const _GLIBCXX_NOEXCEPT + { return *(*this + __n); } + + /** + * Prepares to traverse new_node. Sets everything except + * _M_cur, which should therefore be set by the caller + * immediately afterwards, based on _M_first and _M_last. + */ + void + _M_set_node(_Map_pointer __new_node) _GLIBCXX_NOEXCEPT + { + _M_node = __new_node; + _M_first = *__new_node; + _M_last = _M_first + difference_type(_S_buffer_size()); + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_cur == __y._M_cur; } + + // Note: we also provide overloads whose operands are of the same type in + // order to avoid ambiguous overload resolution when std::rel_ops + // operators are in scope (for additional details, see libstdc++/3628) + template + friend bool + operator==(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return __x._M_cur == __y._M_cur; } + +#if __cpp_lib_three_way_comparison + friend strong_ordering + operator<=>(const _Self& __x, const _Self& __y) noexcept + { + if (const auto __cmp = __x._M_node <=> __y._M_node; __cmp != 0) + return __cmp; + return __x._M_cur <=> __y._M_cur; + } +#else + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return !(__x == __y); } + + template + friend bool + operator!=(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return !(__x == __y); } + + friend bool + operator<(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { + return (__x._M_node == __y._M_node) + ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); + } + + template + friend bool + operator<(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { + return (__x._M_node == __y._M_node) + ? (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); + } + + friend bool + operator>(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __y < __x; } + + template + friend bool + operator>(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return __y < __x; } + + friend bool + operator<=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return !(__y < __x); } + + template + friend bool + operator<=(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return !(__y < __x); } + + friend bool + operator>=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return !(__x < __y); } + + template + friend bool + operator>=(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + _GLIBCXX_NOEXCEPT + { return !(__x < __y); } +#endif // three-way comparison + + friend difference_type + operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { + return difference_type(_S_buffer_size()) + * (__x._M_node - __y._M_node - int(__x._M_node != 0)) + + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template + friend difference_type + operator-(const _Self& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) _GLIBCXX_NOEXCEPT + { + return difference_type(_S_buffer_size()) + * (__x._M_node - __y._M_node - int(__x._M_node != 0)) + + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); + } + + friend _Self + operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT + { + _Self __tmp = __x; + __tmp += __n; + return __tmp; + } + + friend _Self + operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT + { + _Self __tmp = __x; + __tmp -= __n; + return __tmp; + } + + friend _Self + operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT + { return __x + __n; } + }; + + /** + * Deque base class. This class provides the unified face for %deque's + * allocation. This class's constructor and destructor allocate and + * deallocate (but do not initialize) storage. This makes %exception + * safety easier. + * + * Nothing in this class ever constructs or destroys an actual Tp element. + * (Deque handles that itself.) Only/All memory management is performed + * here. + */ + template + class _Deque_base + { + protected: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; + +#if __cplusplus < 201103L + typedef _Tp* _Ptr; + typedef const _Tp* _Ptr_const; +#else + typedef typename _Alloc_traits::pointer _Ptr; + typedef typename _Alloc_traits::const_pointer _Ptr_const; +#endif + + typedef typename _Alloc_traits::template rebind<_Ptr>::other + _Map_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Map_alloc_type> _Map_alloc_traits; + + typedef _Alloc allocator_type; + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Tp_allocator()); } + + typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator; + typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator; + + _Deque_base() + : _M_impl() + { _M_initialize_map(0); } + + _Deque_base(size_t __num_elements) + : _M_impl() + { _M_initialize_map(__num_elements); } + + _Deque_base(const allocator_type& __a, size_t __num_elements) + : _M_impl(__a) + { _M_initialize_map(__num_elements); } + + _Deque_base(const allocator_type& __a) + : _M_impl(__a) + { /* Caller must initialize map. */ } + +#if __cplusplus >= 201103L + _Deque_base(_Deque_base&& __x) + : _M_impl(std::move(__x._M_get_Tp_allocator())) + { + _M_initialize_map(0); + if (__x._M_impl._M_map) + this->_M_impl._M_swap_data(__x._M_impl); + } + + _Deque_base(_Deque_base&& __x, const allocator_type& __a) + : _M_impl(std::move(__x._M_impl), _Tp_alloc_type(__a)) + { __x._M_initialize_map(0); } + + _Deque_base(_Deque_base&& __x, const allocator_type& __a, size_t __n) + : _M_impl(__a) + { + if (__x.get_allocator() == __a) + { + if (__x._M_impl._M_map) + { + _M_initialize_map(0); + this->_M_impl._M_swap_data(__x._M_impl); + } + } + else + { + _M_initialize_map(__n); + } + } +#endif + + ~_Deque_base() _GLIBCXX_NOEXCEPT; + + typedef typename iterator::_Map_pointer _Map_pointer; + + struct _Deque_impl_data + { + _Map_pointer _M_map; + size_t _M_map_size; + iterator _M_start; + iterator _M_finish; + + _Deque_impl_data() _GLIBCXX_NOEXCEPT + : _M_map(), _M_map_size(), _M_start(), _M_finish() + { } + +#if __cplusplus >= 201103L + _Deque_impl_data(const _Deque_impl_data&) = default; + _Deque_impl_data& + operator=(const _Deque_impl_data&) = default; + + _Deque_impl_data(_Deque_impl_data&& __x) noexcept + : _Deque_impl_data(__x) + { __x = _Deque_impl_data(); } +#endif + + void + _M_swap_data(_Deque_impl_data& __x) _GLIBCXX_NOEXCEPT + { + // Do not use std::swap(_M_start, __x._M_start), etc as it loses + // information used by TBAA. + std::swap(*this, __x); + } + }; + + // This struct encapsulates the implementation of the std::deque + // standard container and at the same time makes use of the EBO + // for empty allocators. + struct _Deque_impl + : public _Tp_alloc_type, public _Deque_impl_data + { + _Deque_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Tp_alloc_type>::value) + : _Tp_alloc_type() + { } + + _Deque_impl(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Tp_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + _Deque_impl(_Deque_impl&&) = default; + + _Deque_impl(_Tp_alloc_type&& __a) noexcept + : _Tp_alloc_type(std::move(__a)) + { } + + _Deque_impl(_Deque_impl&& __d, _Tp_alloc_type&& __a) + : _Tp_alloc_type(std::move(__a)), _Deque_impl_data(std::move(__d)) + { } +#endif + }; + + _Tp_alloc_type& + _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Tp_alloc_type& + _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + _Map_alloc_type + _M_get_map_allocator() const _GLIBCXX_NOEXCEPT + { return _Map_alloc_type(_M_get_Tp_allocator()); } + + _Ptr + _M_allocate_node() + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; + return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp))); + } + + void + _M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits; + _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp))); + } + + _Map_pointer + _M_allocate_map(size_t __n) + { + _Map_alloc_type __map_alloc = _M_get_map_allocator(); + return _Map_alloc_traits::allocate(__map_alloc, __n); + } + + void + _M_deallocate_map(_Map_pointer __p, size_t __n) _GLIBCXX_NOEXCEPT + { + _Map_alloc_type __map_alloc = _M_get_map_allocator(); + _Map_alloc_traits::deallocate(__map_alloc, __p, __n); + } + + void _M_initialize_map(size_t); + void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish); + void _M_destroy_nodes(_Map_pointer __nstart, + _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT; + enum { _S_initial_map_size = 8 }; + + _Deque_impl _M_impl; + }; + + template + _Deque_base<_Tp, _Alloc>:: + ~_Deque_base() _GLIBCXX_NOEXCEPT + { + if (this->_M_impl._M_map) + { + _M_destroy_nodes(this->_M_impl._M_start._M_node, + this->_M_impl._M_finish._M_node + 1); + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + } + } + + /** + * @brief Layout storage. + * @param __num_elements The count of T's for which to allocate space + * at first. + * @return Nothing. + * + * The initial underlying memory layout is a bit complicated... + */ + template + void + _Deque_base<_Tp, _Alloc>:: + _M_initialize_map(size_t __num_elements) + { + const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp)) + + 1); + + this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size, + size_t(__num_nodes + 2)); + this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size); + + // For "small" maps (needing less than _M_map_size nodes), allocation + // starts in the middle elements and grows outwards. So nstart may be + // the beginning of _M_map, but for small maps it may be as far in as + // _M_map+3. + + _Map_pointer __nstart = (this->_M_impl._M_map + + (this->_M_impl._M_map_size - __num_nodes) / 2); + _Map_pointer __nfinish = __nstart + __num_nodes; + + __try + { _M_create_nodes(__nstart, __nfinish); } + __catch(...) + { + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + this->_M_impl._M_map = _Map_pointer(); + this->_M_impl._M_map_size = 0; + __throw_exception_again; + } + + this->_M_impl._M_start._M_set_node(__nstart); + this->_M_impl._M_finish._M_set_node(__nfinish - 1); + this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first; + this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first + + __num_elements + % __deque_buf_size(sizeof(_Tp))); + } + + template + void + _Deque_base<_Tp, _Alloc>:: + _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish) + { + _Map_pointer __cur; + __try + { + for (__cur = __nstart; __cur < __nfinish; ++__cur) + *__cur = this->_M_allocate_node(); + } + __catch(...) + { + _M_destroy_nodes(__nstart, __cur); + __throw_exception_again; + } + } + + template + void + _Deque_base<_Tp, _Alloc>:: + _M_destroy_nodes(_Map_pointer __nstart, + _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT + { + for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n) + _M_deallocate_node(*__n); + } + + /** + * @brief A standard container using fixed-size memory allocation and + * constant-time manipulation of elements at either end. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence, including the + * optional sequence requirements. + * + * In previous HP/SGI versions of deque, there was an extra template + * parameter so users could control the node size. This extension turned + * out to violate the C++ standard (it can be detected using template + * template parameters), and it was removed. + * + * Here's how a deque manages memory. Each deque has 4 members: + * + * - Tp** _M_map + * - size_t _M_map_size + * - iterator _M_start, _M_finish + * + * map_size is at least 8. %map is an array of map_size + * pointers-to-@a nodes. (The name %map has nothing to do with the + * std::map class, and @b nodes should not be confused with + * std::list's usage of @a node.) + * + * A @a node has no specific type name as such, but it is referred + * to as @a node in this file. It is a simple array-of-Tp. If Tp + * is very large, there will be one Tp element per node (i.e., an + * @a array of one). For non-huge Tp's, node size is inversely + * related to Tp size: the larger the Tp, the fewer Tp's will fit + * in a node. The goal here is to keep the total size of a node + * relatively small and constant over different Tp's, to improve + * allocator efficiency. + * + * Not every pointer in the %map array will point to a node. If + * the initial number of elements in the deque is small, the + * /middle/ %map pointers will be valid, and the ones at the edges + * will be unused. This same situation will arise as the %map + * grows: available %map pointers, if any, will be on the ends. As + * new nodes are created, only a subset of the %map's pointers need + * to be copied @a outward. + * + * Class invariants: + * - For any nonsingular iterator i: + * - i.node points to a member of the %map array. (Yes, you read that + * correctly: i.node does not actually point to a node.) The member of + * the %map array is what actually points to the node. + * - i.first == *(i.node) (This points to the node (first Tp element).) + * - i.last == i.first + node_size + * - i.cur is a pointer in the range [i.first, i.last). NOTE: + * the implication of this is that i.cur is always a dereferenceable + * pointer, even if i is a past-the-end iterator. + * - Start and Finish are always nonsingular iterators. NOTE: this + * means that an empty deque must have one node, a deque with > + class deque : protected _Deque_base<_Tp, _Alloc> + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Tp>::value, + "std::deque must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::deque must have the same value_type as its allocator"); +# endif +#endif + + typedef _Deque_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef typename _Base::_Alloc_traits _Alloc_traits; + typedef typename _Base::_Map_pointer _Map_pointer; + + public: + typedef _Tp value_type; + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Base::iterator iterator; + typedef typename _Base::const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + private: + static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT + { return __deque_buf_size(sizeof(_Tp)); } + + // Functions controlling memory layout, and nothing else. + using _Base::_M_initialize_map; + using _Base::_M_create_nodes; + using _Base::_M_destroy_nodes; + using _Base::_M_allocate_node; + using _Base::_M_deallocate_node; + using _Base::_M_allocate_map; + using _Base::_M_deallocate_map; + using _Base::_M_get_Tp_allocator; + + /** + * A total of four data members accumulated down the hierarchy. + * May be accessed via _M_impl.* + */ + using _Base::_M_impl; + + public: + // [23.2.1.1] construct/copy/destroy + // (assign() and get_allocator() are also listed in this section) + + /** + * @brief Creates a %deque with no elements. + */ +#if __cplusplus >= 201103L + deque() = default; +#else + deque() { } +#endif + + /** + * @brief Creates a %deque with no elements. + * @param __a An allocator object. + */ + explicit + deque(const allocator_type& __a) + : _Base(__a, 0) { } + +#if __cplusplus >= 201103L + /** + * @brief Creates a %deque with default constructed elements. + * @param __n The number of elements to initially create. + * @param __a An allocator. + * + * This constructor fills the %deque with @a n default + * constructed elements. + */ + explicit + deque(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(__a, _S_check_init_len(__n, __a)) + { _M_default_initialize(); } + + /** + * @brief Creates a %deque with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %deque with @a __n copies of @a __value. + */ + deque(size_type __n, const value_type& __value, + const allocator_type& __a = allocator_type()) + : _Base(__a, _S_check_init_len(__n, __a)) + { _M_fill_initialize(__value); } +#else + /** + * @brief Creates a %deque with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %deque with @a __n copies of @a __value. + */ + explicit + deque(size_type __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(__a, _S_check_init_len(__n, __a)) + { _M_fill_initialize(__value); } +#endif + + /** + * @brief %Deque copy constructor. + * @param __x A %deque of identical element and allocator types. + * + * The newly-created %deque uses a copy of the allocator object used + * by @a __x (unless the allocator traits dictate a different object). + */ + deque(const deque& __x) + : _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()), + __x.size()) + { std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief %Deque move constructor. + * + * The newly-created %deque contains the exact contents of the + * moved instance. + * The contents of the moved instance are a valid, but unspecified + * %deque. + */ + deque(deque&&) = default; + + /// Copy constructor with alternative allocator + deque(const deque& __x, const allocator_type& __a) + : _Base(__a, __x.size()) + { std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); } + + /// Move constructor with alternative allocator + deque(deque&& __x, const allocator_type& __a) + : deque(std::move(__x), __a, typename _Alloc_traits::is_always_equal{}) + { } + + private: + deque(deque&& __x, const allocator_type& __a, true_type) + : _Base(std::move(__x), __a) + { } + + deque(deque&& __x, const allocator_type& __a, false_type) + : _Base(std::move(__x), __a, __x.size()) + { + if (__x.get_allocator() != __a && !__x.empty()) + { + std::__uninitialized_move_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + __x.clear(); + } + } + + public: + /** + * @brief Builds a %deque from an initializer list. + * @param __l An initializer_list. + * @param __a An allocator object. + * + * Create a %deque consisting of copies of the elements in the + * initializer_list @a __l. + * + * This will call the element type's copy constructor N times + * (where N is __l.size()) and do no memory reallocation. + */ + deque(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + + /** + * @brief Builds a %deque from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __a An allocator object. + * + * Create a %deque consisting of copies of the elements from [__first, + * __last). + * + * If the iterators are forward, bidirectional, or random-access, then + * this will call the elements' copy constructor N times (where N is + * distance(__first,__last)) and do no memory reallocation. But if only + * input iterators are used, then this will do at most 2N calls to the + * copy constructor, and logN memory reallocations. + */ +#if __cplusplus >= 201103L + template> + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#else + template + deque(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~deque() + { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); } + + /** + * @brief %Deque assignment operator. + * @param __x A %deque of identical element and allocator types. + * + * All the elements of @a x are copied. + * + * The newly-created %deque uses a copy of the allocator object used + * by @a __x (unless the allocator traits dictate a different object). + */ + deque& + operator=(const deque& __x); + +#if __cplusplus >= 201103L + /** + * @brief %Deque move assignment operator. + * @param __x A %deque of identical element and allocator types. + * + * The contents of @a __x are moved into this deque (without copying, + * if the allocators permit it). + * @a __x is a valid, but unspecified %deque. + */ + deque& + operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal()) + { + using __always_equal = typename _Alloc_traits::is_always_equal; + _M_move_assign1(std::move(__x), __always_equal{}); + return *this; + } + + /** + * @brief Assigns an initializer list to a %deque. + * @param __l An initializer_list. + * + * This function fills a %deque with copies of the elements in the + * initializer_list @a __l. + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. + */ + deque& + operator=(initializer_list __l) + { + _M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + return *this; + } +#endif + + /** + * @brief Assigns a given value to a %deque. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %deque with @a n copies of the given + * value. Note that the assignment completely changes the + * %deque and that the resulting %deque's size is the same as + * the number of elements assigned. + */ + void + assign(size_type __n, const value_type& __val) + { _M_fill_assign(__n, __val); } + + /** + * @brief Assigns a range to a %deque. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %deque with copies of the elements in the + * range [__first,__last). + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. + */ +#if __cplusplus >= 201103L + template> + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Assigns an initializer list to a %deque. + * @param __l An initializer_list. + * + * This function fills a %deque with copies of the elements in the + * initializer_list @a __l. + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. + */ + void + assign(initializer_list __l) + { _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return _Base::get_allocator(); } + + // iterators + /** + * Returns a read/write iterator that points to the first element in the + * %deque. Iteration is done in ordinary element order. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_start; } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %deque. Iteration is done in ordinary element order. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_start; } + + /** + * Returns a read/write iterator that points one past the last + * element in the %deque. Iteration is done in ordinary + * element order. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %deque. Iteration is done in + * ordinary element order. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish; } + + /** + * Returns a read/write reverse iterator that points to the + * last element in the %deque. Iteration is done in reverse + * element order. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %deque. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read/write reverse iterator that points to one + * before the first element in the %deque. Iteration is done + * in reverse element order. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(this->_M_impl._M_start); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %deque. Iteration is + * done in reverse element order. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(this->_M_impl._M_start); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %deque. Iteration is done in ordinary element order. + */ + const_iterator + cbegin() const noexcept + { return this->_M_impl._M_start; } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %deque. Iteration is done in + * ordinary element order. + */ + const_iterator + cend() const noexcept + { return this->_M_impl._M_finish; } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %deque. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %deque. Iteration is + * done in reverse element order. + */ + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(this->_M_impl._M_start); } +#endif + + // [23.2.1.2] capacity + /** Returns the number of elements in the %deque. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish - this->_M_impl._M_start; } + + /** Returns the size() of the largest possible %deque. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _S_max_size(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief Resizes the %deque to the specified number of elements. + * @param __new_size Number of elements the %deque should contain. + * + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise + * default constructed elements are appended. + */ + void + resize(size_type __new_size) + { + const size_type __len = size(); + if (__new_size > __len) + _M_default_append(__new_size - __len); + else if (__new_size < __len) + _M_erase_at_end(this->_M_impl._M_start + + difference_type(__new_size)); + } + + /** + * @brief Resizes the %deque to the specified number of elements. + * @param __new_size Number of elements the %deque should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise the + * %deque is extended and new elements are populated with given + * data. + */ + void + resize(size_type __new_size, const value_type& __x) +#else + /** + * @brief Resizes the %deque to the specified number of elements. + * @param __new_size Number of elements the %deque should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %deque to the specified + * number of elements. If the number is smaller than the + * %deque's current size the %deque is truncated, otherwise the + * %deque is extended and new elements are populated with given + * data. + */ + void + resize(size_type __new_size, value_type __x = value_type()) +#endif + { + const size_type __len = size(); + if (__new_size > __len) + _M_fill_insert(this->_M_impl._M_finish, __new_size - __len, __x); + else if (__new_size < __len) + _M_erase_at_end(this->_M_impl._M_start + + difference_type(__new_size)); + } + +#if __cplusplus >= 201103L + /** A non-binding request to reduce memory use. */ + void + shrink_to_fit() noexcept + { _M_shrink_to_fit(); } +#endif + + /** + * Returns true if the %deque is empty. (Thus begin() would + * equal end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_finish == this->_M_impl._M_start; } + + // element access + /** + * @brief Subscript access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + reference + operator[](size_type __n) _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return this->_M_impl._M_start[difference_type(__n)]; + } + + /** + * @brief Subscript access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + const_reference + operator[](size_type __n) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return this->_M_impl._M_start[difference_type(__n)]; + } + + protected: + /// Safety check used only from at(). + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("deque::_M_range_check: __n " + "(which is %zu)>= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + /** + * @brief Provides access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the deque. The + * function throws out_of_range if the check fails. + */ + reference + at(size_type __n) + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * @brief Provides access to the data contained in the %deque. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter is first + * checked that it is in the range of the deque. The function throws + * out_of_range if the check fails. + */ + const_reference + at(size_type __n) const + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * Returns a read/write reference to the data at the first + * element of the %deque. + */ + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %deque. + */ + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read/write reference to the data at the last element of the + * %deque. + */ + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + /** + * Returns a read-only (constant) reference to the data at the last + * element of the %deque. + */ + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + const_iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + // [23.2.1.2] modifiers + /** + * @brief Add data to the front of the %deque. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %deque and assigns the given + * data to it. Due to the nature of a %deque this operation + * can be done in constant time. + */ + void + push_front(const value_type& __x) + { + if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_start._M_cur - 1, + __x); + --this->_M_impl._M_start._M_cur; + } + else + _M_push_front_aux(__x); + } + +#if __cplusplus >= 201103L + void + push_front(value_type&& __x) + { emplace_front(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args); +#endif + + /** + * @brief Add data to the end of the %deque. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the end of the %deque and assigns the given data + * to it. Due to the nature of a %deque this operation can be + * done in constant time. + */ + void + push_back(const value_type& __x) + { + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_last - 1) + { + _Alloc_traits::construct(this->_M_impl, + this->_M_impl._M_finish._M_cur, __x); + ++this->_M_impl._M_finish._M_cur; + } + else + _M_push_back_aux(__x); + } + +#if __cplusplus >= 201103L + void + push_back(value_type&& __x) + { emplace_back(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args); +#endif + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %deque by one. + * + * Note that no data is returned, and if the first element's data is + * needed, it should be retrieved before pop_front() is called. + */ + void + pop_front() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + if (this->_M_impl._M_start._M_cur + != this->_M_impl._M_start._M_last - 1) + { + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_start._M_cur); + ++this->_M_impl._M_start._M_cur; + } + else + _M_pop_front_aux(); + } + + /** + * @brief Removes last element. + * + * This is a typical stack operation. It shrinks the %deque by one. + * + * Note that no data is returned, and if the last element's data is + * needed, it should be retrieved before pop_back() is called. + */ + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + if (this->_M_impl._M_finish._M_cur + != this->_M_impl._M_finish._M_first) + { + --this->_M_impl._M_finish._M_cur; + _Alloc_traits::destroy(_M_get_Tp_allocator(), + this->_M_impl._M_finish._M_cur); + } + else + _M_pop_back_aux(); + } + +#if __cplusplus >= 201103L + /** + * @brief Inserts an object in %deque before specified iterator. + * @param __position A const_iterator into the %deque. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) before the specified location. + */ + template + iterator + emplace(const_iterator __position, _Args&&... __args); + + /** + * @brief Inserts given value into %deque before specified iterator. + * @param __position A const_iterator into the %deque. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before the + * specified location. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else + /** + * @brief Inserts given value into %deque before specified iterator. + * @param __position An iterator into the %deque. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before the + * specified location. + */ + iterator + insert(iterator __position, const value_type& __x); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts given rvalue into %deque before specified iterator. + * @param __position A const_iterator into the %deque. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given rvalue before the + * specified location. + */ + iterator + insert(const_iterator __position, value_type&& __x) + { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts an initializer list into the %deque. + * @param __p An iterator into the %deque. + * @param __l An initializer_list. + * @return An iterator that points to the inserted data. + * + * This function will insert copies of the data in the + * initializer_list @a __l into the %deque before the location + * specified by @a __p. This is known as list insert. + */ + iterator + insert(const_iterator __p, initializer_list __l) + { + auto __offset = __p - cbegin(); + _M_range_insert_aux(__p._M_const_cast(), __l.begin(), __l.end(), + std::random_access_iterator_tag()); + return begin() + __offset; + } + + /** + * @brief Inserts a number of copies of given data into the %deque. + * @param __position A const_iterator into the %deque. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a specified number of copies of the given + * data before the location specified by @a __position. + */ + iterator + insert(const_iterator __position, size_type __n, const value_type& __x) + { + difference_type __offset = __position - cbegin(); + _M_fill_insert(__position._M_const_cast(), __n, __x); + return begin() + __offset; + } +#else + /** + * @brief Inserts a number of copies of given data into the %deque. + * @param __position An iterator into the %deque. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * + * This function will insert a specified number of copies of the given + * data before the location specified by @a __position. + */ + void + insert(iterator __position, size_type __n, const value_type& __x) + { _M_fill_insert(__position, __n, __x); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a range into the %deque. + * @param __position A const_iterator into the %deque. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator that points to the inserted data. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %deque before the location specified + * by @a __position. This is known as range insert. + */ + template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_range_insert_aux(__position._M_const_cast(), __first, __last, + std::__iterator_category(__first)); + return begin() + __offset; + } +#else + /** + * @brief Inserts a range into the %deque. + * @param __position An iterator into the %deque. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %deque before the location specified + * by @a __position. This is known as range insert. + */ + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + + /** + * @brief Remove element at given position. + * @param __position Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and thus + * shorten the %deque by one. + * + * The user is cautioned that + * this function only erases the element, and that if the element is + * itself a pointer, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { return _M_erase(__position._M_const_cast()); } + + /** + * @brief Remove a range of elements. + * @param __first Iterator pointing to the first element to be erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a last + * prior to erasing (or end()). + * + * This function will erase the elements in the range + * [__first,__last) and shorten the %deque accordingly. + * + * The user is cautioned that + * this function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) +#else + erase(iterator __first, iterator __last) +#endif + { return _M_erase(__first._M_const_cast(), __last._M_const_cast()); } + + /** + * @brief Swaps data with another %deque. + * @param __x A %deque of the same element and allocator types. + * + * This exchanges the elements between two deques in constant time. + * (Four pointers, so it should be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(d1,d2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(deque& __x) _GLIBCXX_NOEXCEPT + { +#if __cplusplus >= 201103L + __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value + || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); +#endif + _M_impl._M_swap_data(__x._M_impl); + _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } + + /** + * Erases all the elements. Note that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(begin()); } + + protected: + // Internal constructor functions follow. + +#if __cplusplus < 201103L + // called by the range constructor to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { + _M_initialize_map(_S_check_init_len(static_cast(__n), + _M_get_Tp_allocator())); + _M_fill_initialize(__x); + } + + // called by the range constructor to implement [23.1.1]/9 + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#endif + + static size_t + _S_check_init_len(size_t __n, const allocator_type& __a) + { + if (__n > _S_max_size(__a)) + __throw_length_error( + __N("cannot create std::deque larger than max_size()")); + return __n; + } + + static size_type + _S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT + { + const size_t __diffmax = __gnu_cxx::__numeric_traits::__max; + const size_t __allocmax = _Alloc_traits::max_size(__a); + return (std::min)(__diffmax, __allocmax); + } + + // called by the second initialize_dispatch above + ///@{ + /** + * @brief Fills the deque with whatever is in [first,last). + * @param __first An input iterator. + * @param __last An input iterator. + * @return Nothing. + * + * If the iterators are actually forward iterators (or better), then the + * memory layout can be done all at once. Else we move forward using + * push_back on each value from the iterator. + */ + template + void + _M_range_initialize(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag); + + // called by the second initialize_dispatch above + template + void + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag); + ///@} + + /** + * @brief Fills the %deque with copies of value. + * @param __value Initial value. + * @return Nothing. + * @pre _M_start and _M_finish have already been initialized, + * but none of the %deque's elements have yet been constructed. + * + * This function is called only when the user provides an explicit size + * (with or without an explicit exemplar value). + */ + void + _M_fill_initialize(const value_type& __value); + +#if __cplusplus >= 201103L + // called by deque(n). + void + _M_default_initialize(); +#endif + + // Internal assign functions follow. The *_aux functions do the actual + // assignment work for the range versions. + +#if __cplusplus < 201103L + // called by the range assign to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + // called by the range assign to implement [23.1.1]/9 + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } +#endif + + // called by the second assign_dispatch above + template + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag); + + // called by the second assign_dispatch above + template + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + if (__len > size()) + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, begin()); + _M_range_insert_aux(end(), __mid, __last, + std::__iterator_category(__first)); + } + else + _M_erase_at_end(std::copy(__first, __last, begin())); + } + + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. + void + _M_fill_assign(size_type __n, const value_type& __val) + { + if (__n > size()) + { + std::fill(begin(), end(), __val); + _M_fill_insert(end(), __n - size(), __val); + } + else + { + _M_erase_at_end(begin() + difference_type(__n)); + std::fill(begin(), end(), __val); + } + } + + ///@{ + /// Helper functions for push_* and pop_*. +#if __cplusplus < 201103L + void _M_push_back_aux(const value_type&); + + void _M_push_front_aux(const value_type&); +#else + template + void _M_push_back_aux(_Args&&... __args); + + template + void _M_push_front_aux(_Args&&... __args); +#endif + + void _M_pop_back_aux(); + + void _M_pop_front_aux(); + ///@} + + // Internal insert functions follow. The *_aux functions do the actual + // insertion work when all shortcuts fail. + +#if __cplusplus < 201103L + // called by the range insert to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_insert_dispatch(iterator __pos, + _Integer __n, _Integer __x, __true_type) + { _M_fill_insert(__pos, __n, __x); } + + // called by the range insert to implement [23.1.1]/9 + template + void + _M_insert_dispatch(iterator __pos, + _InputIterator __first, _InputIterator __last, + __false_type) + { + _M_range_insert_aux(__pos, __first, __last, + std::__iterator_category(__first)); + } +#endif + + // called by the second insert_dispatch above + template + void + _M_range_insert_aux(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag); + + // called by the second insert_dispatch above + template + void + _M_range_insert_aux(iterator __pos, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + // Called by insert(p,n,x), and the range insert when it turns out to be + // the same thing. Can use fill functions in optimal situations, + // otherwise passes off to insert_aux(p,n,x). + void + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); + + // called by insert(p,x) +#if __cplusplus < 201103L + iterator + _M_insert_aux(iterator __pos, const value_type& __x); +#else + template + iterator + _M_insert_aux(iterator __pos, _Args&&... __args); +#endif + + // called by insert(p,n,x) via fill_insert + void + _M_insert_aux(iterator __pos, size_type __n, const value_type& __x); + + // called by range_insert_aux for forward iterators + template + void + _M_insert_aux(iterator __pos, + _ForwardIterator __first, _ForwardIterator __last, + size_type __n); + + + // Internal erase functions follow. + + void + _M_destroy_data_aux(iterator __first, iterator __last); + + // Called by ~deque(). + // NB: Doesn't deallocate the nodes. + template + void + _M_destroy_data(iterator __first, iterator __last, const _Alloc1&) + { _M_destroy_data_aux(__first, __last); } + + void + _M_destroy_data(iterator __first, iterator __last, + const std::allocator<_Tp>&) + { + if (!__has_trivial_destructor(value_type)) + _M_destroy_data_aux(__first, __last); + } + + // Called by erase(q1, q2). + void + _M_erase_at_begin(iterator __pos) + { + _M_destroy_data(begin(), __pos, _M_get_Tp_allocator()); + _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node); + this->_M_impl._M_start = __pos; + } + + // Called by erase(q1, q2), resize(), clear(), _M_assign_aux, + // _M_fill_assign, operator=. + void + _M_erase_at_end(iterator __pos) + { + _M_destroy_data(__pos, end(), _M_get_Tp_allocator()); + _M_destroy_nodes(__pos._M_node + 1, + this->_M_impl._M_finish._M_node + 1); + this->_M_impl._M_finish = __pos; + } + + iterator + _M_erase(iterator __pos); + + iterator + _M_erase(iterator __first, iterator __last); + +#if __cplusplus >= 201103L + // Called by resize(sz). + void + _M_default_append(size_type __n); + + bool + _M_shrink_to_fit(); +#endif + + ///@{ + /// Memory-handling helpers for the previous internal insert functions. + iterator + _M_reserve_elements_at_front(size_type __n) + { + const size_type __vacancies = this->_M_impl._M_start._M_cur + - this->_M_impl._M_start._M_first; + if (__n > __vacancies) + _M_new_elements_at_front(__n - __vacancies); + return this->_M_impl._M_start - difference_type(__n); + } + + iterator + _M_reserve_elements_at_back(size_type __n) + { + const size_type __vacancies = (this->_M_impl._M_finish._M_last + - this->_M_impl._M_finish._M_cur) - 1; + if (__n > __vacancies) + _M_new_elements_at_back(__n - __vacancies); + return this->_M_impl._M_finish + difference_type(__n); + } + + void + _M_new_elements_at_front(size_type __new_elements); + + void + _M_new_elements_at_back(size_type __new_elements); + ///@} + + + ///@{ + /** + * @brief Memory-handling helpers for the major %map. + * + * Makes sure the _M_map has space for new nodes. Does not + * actually add the nodes. Can invalidate _M_map pointers. + * (And consequently, %deque iterators.) + */ + void + _M_reserve_map_at_back(size_type __nodes_to_add = 1) + { + if (__nodes_to_add + 1 > this->_M_impl._M_map_size + - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map)) + _M_reallocate_map(__nodes_to_add, false); + } + + void + _M_reserve_map_at_front(size_type __nodes_to_add = 1) + { + if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node + - this->_M_impl._M_map)) + _M_reallocate_map(__nodes_to_add, true); + } + + void + _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front); + ///@} + +#if __cplusplus >= 201103L + // Constant-time, nothrow move assignment when source object's memory + // can be moved because the allocators are equal. + void + _M_move_assign1(deque&& __x, /* always equal: */ true_type) noexcept + { + this->_M_impl._M_swap_data(__x._M_impl); + __x.clear(); + std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); + } + + // When the allocators are not equal the operation could throw, because + // we might need to allocate a new map for __x after moving from it + // or we might need to allocate new elements for *this. + void + _M_move_assign1(deque&& __x, /* always equal: */ false_type) + { + if (_M_get_Tp_allocator() == __x._M_get_Tp_allocator()) + return _M_move_assign1(std::move(__x), true_type()); + + constexpr bool __move_storage = + _Alloc_traits::_S_propagate_on_move_assign(); + _M_move_assign2(std::move(__x), __bool_constant<__move_storage>()); + } + + // Destroy all elements and deallocate all memory, then replace + // with elements created from __args. + template + void + _M_replace_map(_Args&&... __args) + { + // Create new data first, so if allocation fails there are no effects. + deque __newobj(std::forward<_Args>(__args)...); + // Free existing storage using existing allocator. + clear(); + _M_deallocate_node(*begin()._M_node); // one node left after clear() + _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); + this->_M_impl._M_map = nullptr; + this->_M_impl._M_map_size = 0; + // Take ownership of replacement memory. + this->_M_impl._M_swap_data(__newobj._M_impl); + } + + // Do move assignment when the allocator propagates. + void + _M_move_assign2(deque&& __x, /* propagate: */ true_type) + { + // Make a copy of the original allocator state. + auto __alloc = __x._M_get_Tp_allocator(); + // The allocator propagates so storage can be moved from __x, + // leaving __x in a valid empty state with a moved-from allocator. + _M_replace_map(std::move(__x)); + // Move the corresponding allocator state too. + _M_get_Tp_allocator() = std::move(__alloc); + } + + // Do move assignment when it may not be possible to move source + // object's memory, resulting in a linear-time operation. + void + _M_move_assign2(deque&& __x, /* propagate: */ false_type) + { + if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) + { + // The allocators are equal so storage can be moved from __x, + // leaving __x in a valid empty state with its current allocator. + _M_replace_map(std::move(__x), __x.get_allocator()); + } + else + { + // The rvalue's allocator cannot be moved and is not equal, + // so we need to individually move each element. + _M_assign_aux(std::make_move_iterator(__x.begin()), + std::make_move_iterator(__x.end()), + std::random_access_iterator_tag()); + __x.clear(); + } + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + deque(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> deque<_ValT, _Allocator>; +#endif + + /** + * @brief Deque equality comparison. + * @param __x A %deque. + * @param __y A %deque of the same type as @a __x. + * @return True iff the size and elements of the deques are equal. + * + * This is an equivalence relation. It is linear in the size of the + * deques. Deques are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + inline bool + operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return __x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin()); } + +#if __cpp_lib_three_way_comparison + /** + * @brief Deque ordering relation. + * @param __x A `deque`. + * @param __y A `deque` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Tp> + operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief Deque ordering relation. + * @param __x A %deque. + * @param __y A %deque of the same type as @a __x. + * @return True iff @a x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * deques. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } + + /// Based on operator== + template + inline bool + operator!=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::deque::swap(). + template + inline void + swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +#undef _GLIBCXX_DEQUE_BUF_SIZE + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus >= 201103L + // std::allocator is safe, but it is not the only allocator + // for which this is valid. + template + struct __is_bitwise_relocatable<_GLIBCXX_STD_C::deque<_Tp>> + : true_type { }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_DEQUE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_function.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_function.h new file mode 100755 index 0000000..073018d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_function.h @@ -0,0 +1,1410 @@ +// Functor implementations -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_function.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{functional} + */ + +#ifndef _STL_FUNCTION_H +#define _STL_FUNCTION_H 1 + +#if __cplusplus > 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // 20.3.1 base classes + /** @defgroup functors Function Objects + * @ingroup utilities + * + * Function objects, or @e functors, are objects with an @c operator() + * defined and accessible. They can be passed as arguments to algorithm + * templates and used in place of a function pointer. Not only is the + * resulting expressiveness of the library increased, but the generated + * code can be more efficient than what you might write by hand. When we + * refer to @a functors, then, generally we include function pointers in + * the description as well. + * + * Often, functors are only created as temporaries passed to algorithm + * calls, rather than being created as named variables. + * + * Two examples taken from the standard itself follow. To perform a + * by-element addition of two vectors @c a and @c b containing @c double, + * and put the result in @c a, use + * \code + * transform (a.begin(), a.end(), b.begin(), a.begin(), plus()); + * \endcode + * To negate every element in @c a, use + * \code + * transform(a.begin(), a.end(), a.begin(), negate()); + * \endcode + * The addition and negation functions will be inlined directly. + * + * The standard functors are derived from structs named @c unary_function + * and @c binary_function. These two classes contain nothing but typedefs, + * to aid in generic (template) programming. If you write your own + * functors, you might consider doing the same. + * + * @{ + */ + /** + * This is one of the @link functors functor base classes@endlink. + */ + template + struct unary_function + { + /// @c argument_type is the type of the argument + typedef _Arg argument_type; + + /// @c result_type is the return type + typedef _Result result_type; + }; + + /** + * This is one of the @link functors functor base classes@endlink. + */ + template + struct binary_function + { + /// @c first_argument_type is the type of the first argument + typedef _Arg1 first_argument_type; + + /// @c second_argument_type is the type of the second argument + typedef _Arg2 second_argument_type; + + /// @c result_type is the return type + typedef _Result result_type; + }; + /** @} */ + + // 20.3.2 arithmetic + /** @defgroup arithmetic_functors Arithmetic Classes + * @ingroup functors + * + * Because basic math often needs to be done during an algorithm, + * the library provides functors for those operations. See the + * documentation for @link functors the base classes@endlink + * for examples of their use. + * + * @{ + */ + +#if __cplusplus > 201103L + struct __is_transparent; // undefined + + template + struct plus; + + template + struct minus; + + template + struct multiplies; + + template + struct divides; + + template + struct modulus; + + template + struct negate; +#endif + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct plus : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x + __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct minus : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x - __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct multiplies : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x * __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct divides : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x / __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct modulus : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x % __y; } + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template + struct negate : public unary_function<_Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x) const + { return -__x; } + }; + +#if __cplusplus > 201103L + +#define __cpp_lib_transparent_operators 201510 + + template<> + struct plus + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct minus + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct multiplies + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct divides + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct modulus + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link arithmetic_functors math functors@endlink. + template<> + struct negate + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t) const + noexcept(noexcept(-std::forward<_Tp>(__t))) + -> decltype(-std::forward<_Tp>(__t)) + { return -std::forward<_Tp>(__t); } + + typedef __is_transparent is_transparent; + }; +#endif + /** @} */ + + // 20.3.3 comparisons + /** @defgroup comparison_functors Comparison Classes + * @ingroup functors + * + * The library provides six wrapper functors for all the basic comparisons + * in C++, like @c <. + * + * @{ + */ +#if __cplusplus > 201103L + template + struct equal_to; + + template + struct not_equal_to; + + template + struct greater; + + template + struct less; + + template + struct greater_equal; + + template + struct less_equal; +#endif + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct equal_to : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x == __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct not_equal_to : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x != __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct greater : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x > __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct less : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x < __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct greater_equal : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x >= __y; } + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template + struct less_equal : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x <= __y; } + }; + + // Partial specialization of std::greater for pointers. + template + struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x > __y)) +#endif + return __x > __y; +#endif + return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y; + } + }; + + // Partial specialization of std::less for pointers. + template + struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x < __y)) +#endif + return __x < __y; +#endif + return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y; + } + }; + + // Partial specialization of std::greater_equal for pointers. + template + struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x >= __y)) +#endif + return __x >= __y; +#endif + return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y; + } + }; + + // Partial specialization of std::less_equal for pointers. + template + struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool> + { + _GLIBCXX14_CONSTEXPR bool + operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW + { +#if __cplusplus >= 201402L +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + if (__builtin_is_constant_evaluated()) +#else + if (__builtin_constant_p(__x <= __y)) +#endif + return __x <= __y; +#endif + return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y; + } + }; + +#if __cplusplus >= 201402L + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct equal_to + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct not_equal_to + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct greater + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return greater>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return greater{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator> member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator>(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator> for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator>(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct less + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return less>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return less{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator< member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator<(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator< for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator<(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct greater_equal + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return greater_equal>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return greater_equal{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator>= member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator>=(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator>= for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator>=(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; + + /// One of the @link comparison_functors comparison functors@endlink. + template<> + struct less_equal + { + template + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)) + { + return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), + __ptr_cmp<_Tp, _Up>{}); + } + + template + constexpr bool + operator()(_Tp* __t, _Up* __u) const noexcept + { return less_equal>{}(__t, __u); } + + typedef __is_transparent is_transparent; + + private: + template + static constexpr decltype(auto) + _S_cmp(_Tp&& __t, _Up&& __u, false_type) + { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); } + + template + static constexpr bool + _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept + { + return less_equal{}( + static_cast(std::forward<_Tp>(__t)), + static_cast(std::forward<_Up>(__u))); + } + + // True if there is no viable operator<= member function. + template + struct __not_overloaded2 : true_type { }; + + // False if we can call T.operator<=(U) + template + struct __not_overloaded2<_Tp, _Up, __void_t< + decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>> + : false_type { }; + + // True if there is no overloaded operator<= for these operands. + template + struct __not_overloaded : __not_overloaded2<_Tp, _Up> { }; + + // False if we can call operator<=(T,U) + template + struct __not_overloaded<_Tp, _Up, __void_t< + decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>> + : false_type { }; + + template + using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>, + is_convertible<_Tp, const volatile void*>, + is_convertible<_Up, const volatile void*>>; + }; +#endif // C++14 + /** @} */ + + // 20.3.4 logical operations + /** @defgroup logical_functors Boolean Operations Classes + * @ingroup functors + * + * Here are wrapper functors for Boolean operations: @c &&, @c ||, + * and @c !. + * + * @{ + */ +#if __cplusplus > 201103L + template + struct logical_and; + + template + struct logical_or; + + template + struct logical_not; +#endif + + /// One of the @link logical_functors Boolean operations functors@endlink. + template + struct logical_and : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x && __y; } + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template + struct logical_or : public binary_function<_Tp, _Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x, const _Tp& __y) const + { return __x || __y; } + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template + struct logical_not : public unary_function<_Tp, bool> + { + _GLIBCXX14_CONSTEXPR + bool + operator()(const _Tp& __x) const + { return !__x; } + }; + +#if __cplusplus > 201103L + /// One of the @link logical_functors Boolean operations functors@endlink. + template<> + struct logical_and + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template<> + struct logical_or + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + /// One of the @link logical_functors Boolean operations functors@endlink. + template<> + struct logical_not + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t) const + noexcept(noexcept(!std::forward<_Tp>(__t))) + -> decltype(!std::forward<_Tp>(__t)) + { return !std::forward<_Tp>(__t); } + + typedef __is_transparent is_transparent; + }; +#endif + /** @} */ + +#if __cplusplus > 201103L + template + struct bit_and; + + template + struct bit_or; + + template + struct bit_xor; + + template + struct bit_not; +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 660. Missing Bitwise Operations. + template + struct bit_and : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x & __y; } + }; + + template + struct bit_or : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x | __y; } + }; + + template + struct bit_xor : public binary_function<_Tp, _Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x, const _Tp& __y) const + { return __x ^ __y; } + }; + + template + struct bit_not : public unary_function<_Tp, _Tp> + { + _GLIBCXX14_CONSTEXPR + _Tp + operator()(const _Tp& __x) const + { return ~__x; } + }; + +#if __cplusplus > 201103L + template <> + struct bit_and + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + template <> + struct bit_or + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + template <> + struct bit_xor + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))) + -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)) + { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); } + + typedef __is_transparent is_transparent; + }; + + template <> + struct bit_not + { + template + _GLIBCXX14_CONSTEXPR + auto + operator()(_Tp&& __t) const + noexcept(noexcept(~std::forward<_Tp>(__t))) + -> decltype(~std::forward<_Tp>(__t)) + { return ~std::forward<_Tp>(__t); } + + typedef __is_transparent is_transparent; + }; +#endif + + // 20.3.5 negators + /** @defgroup negators Negators + * @ingroup functors + * + * The functions @c not1 and @c not2 each take a predicate functor + * and return an instance of @c unary_negate or + * @c binary_negate, respectively. These classes are functors whose + * @c operator() performs the stored predicate function and then returns + * the negation of the result. + * + * For example, given a vector of integers and a trivial predicate, + * \code + * struct IntGreaterThanThree + * : public std::unary_function + * { + * bool operator() (int x) { return x > 3; } + * }; + * + * std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree())); + * \endcode + * The call to @c find_if will locate the first index (i) of @c v for which + * !(v[i] > 3) is true. + * + * The not1/unary_negate combination works on predicates taking a single + * argument. The not2/binary_negate combination works on predicates which + * take two arguments. + * + * @{ + */ + /// One of the @link negators negation functors@endlink. + template + class unary_negate + : public unary_function + { + protected: + _Predicate _M_pred; + + public: + _GLIBCXX14_CONSTEXPR + explicit + unary_negate(const _Predicate& __x) : _M_pred(__x) { } + + _GLIBCXX14_CONSTEXPR + bool + operator()(const typename _Predicate::argument_type& __x) const + { return !_M_pred(__x); } + }; + + /// One of the @link negators negation functors@endlink. + template + _GLIBCXX14_CONSTEXPR + inline unary_negate<_Predicate> + not1(const _Predicate& __pred) + { return unary_negate<_Predicate>(__pred); } + + /// One of the @link negators negation functors@endlink. + template + class binary_negate + : public binary_function + { + protected: + _Predicate _M_pred; + + public: + _GLIBCXX14_CONSTEXPR + explicit + binary_negate(const _Predicate& __x) : _M_pred(__x) { } + + _GLIBCXX14_CONSTEXPR + bool + operator()(const typename _Predicate::first_argument_type& __x, + const typename _Predicate::second_argument_type& __y) const + { return !_M_pred(__x, __y); } + }; + + /// One of the @link negators negation functors@endlink. + template + _GLIBCXX14_CONSTEXPR + inline binary_negate<_Predicate> + not2(const _Predicate& __pred) + { return binary_negate<_Predicate>(__pred); } + /** @} */ + + // 20.3.7 adaptors pointers functions + /** @defgroup pointer_adaptors Adaptors for pointers to functions + * @ingroup functors + * + * The advantage of function objects over pointers to functions is that + * the objects in the standard library declare nested typedefs describing + * their argument and result types with uniform names (e.g., @c result_type + * from the base classes @c unary_function and @c binary_function). + * Sometimes those typedefs are required, not just optional. + * + * Adaptors are provided to turn pointers to unary (single-argument) and + * binary (double-argument) functions into function objects. The + * long-winded functor @c pointer_to_unary_function is constructed with a + * function pointer @c f, and its @c operator() called with argument @c x + * returns @c f(x). The functor @c pointer_to_binary_function does the same + * thing, but with a double-argument @c f and @c operator(). + * + * The function @c ptr_fun takes a pointer-to-function @c f and constructs + * an instance of the appropriate functor. + * + * @{ + */ + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + class pointer_to_unary_function : public unary_function<_Arg, _Result> + { + protected: + _Result (*_M_ptr)(_Arg); + + public: + pointer_to_unary_function() { } + + explicit + pointer_to_unary_function(_Result (*__x)(_Arg)) + : _M_ptr(__x) { } + + _Result + operator()(_Arg __x) const + { return _M_ptr(__x); } + }; + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + inline pointer_to_unary_function<_Arg, _Result> + ptr_fun(_Result (*__x)(_Arg)) + { return pointer_to_unary_function<_Arg, _Result>(__x); } + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + class pointer_to_binary_function + : public binary_function<_Arg1, _Arg2, _Result> + { + protected: + _Result (*_M_ptr)(_Arg1, _Arg2); + + public: + pointer_to_binary_function() { } + + explicit + pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2)) + : _M_ptr(__x) { } + + _Result + operator()(_Arg1 __x, _Arg2 __y) const + { return _M_ptr(__x, __y); } + }; + + /// One of the @link pointer_adaptors adaptors for function pointers@endlink. + template + inline pointer_to_binary_function<_Arg1, _Arg2, _Result> + ptr_fun(_Result (*__x)(_Arg1, _Arg2)) + { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); } + /** @} */ + + template + struct _Identity + : public unary_function<_Tp, _Tp> + { + _Tp& + operator()(_Tp& __x) const + { return __x; } + + const _Tp& + operator()(const _Tp& __x) const + { return __x; } + }; + + // Partial specialization, avoids confusing errors in e.g. std::set. + template struct _Identity : _Identity<_Tp> { }; + + template + struct _Select1st + : public unary_function<_Pair, typename _Pair::first_type> + { + typename _Pair::first_type& + operator()(_Pair& __x) const + { return __x.first; } + + const typename _Pair::first_type& + operator()(const _Pair& __x) const + { return __x.first; } + +#if __cplusplus >= 201103L + template + typename _Pair2::first_type& + operator()(_Pair2& __x) const + { return __x.first; } + + template + const typename _Pair2::first_type& + operator()(const _Pair2& __x) const + { return __x.first; } +#endif + }; + + template + struct _Select2nd + : public unary_function<_Pair, typename _Pair::second_type> + { + typename _Pair::second_type& + operator()(_Pair& __x) const + { return __x.second; } + + const typename _Pair::second_type& + operator()(const _Pair& __x) const + { return __x.second; } + }; + + // 20.3.8 adaptors pointers members + /** @defgroup memory_adaptors Adaptors for pointers to members + * @ingroup functors + * + * There are a total of 8 = 2^3 function objects in this family. + * (1) Member functions taking no arguments vs member functions taking + * one argument. + * (2) Call through pointer vs call through reference. + * (3) Const vs non-const member function. + * + * All of this complexity is in the function objects themselves. You can + * ignore it by using the helper function mem_fun and mem_fun_ref, + * which create whichever type of adaptor is appropriate. + * + * @{ + */ + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class mem_fun_t : public unary_function<_Tp*, _Ret> + { + public: + explicit + mem_fun_t(_Ret (_Tp::*__pf)()) + : _M_f(__pf) { } + + _Ret + operator()(_Tp* __p) const + { return (__p->*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)(); + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class const_mem_fun_t : public unary_function + { + public: + explicit + const_mem_fun_t(_Ret (_Tp::*__pf)() const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp* __p) const + { return (__p->*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)() const; + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class mem_fun_ref_t : public unary_function<_Tp, _Ret> + { + public: + explicit + mem_fun_ref_t(_Ret (_Tp::*__pf)()) + : _M_f(__pf) { } + + _Ret + operator()(_Tp& __r) const + { return (__r.*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)(); + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class const_mem_fun_ref_t : public unary_function<_Tp, _Ret> + { + public: + explicit + const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp& __r) const + { return (__r.*_M_f)(); } + + private: + _Ret (_Tp::*_M_f)() const; + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret> + { + public: + explicit + mem_fun1_t(_Ret (_Tp::*__pf)(_Arg)) + : _M_f(__pf) { } + + _Ret + operator()(_Tp* __p, _Arg __x) const + { return (__p->*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg); + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class const_mem_fun1_t : public binary_function + { + public: + explicit + const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp* __p, _Arg __x) const + { return (__p->*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg) const; + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> + { + public: + explicit + mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg)) + : _M_f(__pf) { } + + _Ret + operator()(_Tp& __r, _Arg __x) const + { return (__r.*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg); + }; + + /// One of the @link memory_adaptors adaptors for member + /// pointers@endlink. + template + class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret> + { + public: + explicit + const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const) + : _M_f(__pf) { } + + _Ret + operator()(const _Tp& __r, _Arg __x) const + { return (__r.*_M_f)(__x); } + + private: + _Ret (_Tp::*_M_f)(_Arg) const; + }; + + // Mem_fun adaptor helper functions. There are only two: + // mem_fun and mem_fun_ref. + template + inline mem_fun_t<_Ret, _Tp> + mem_fun(_Ret (_Tp::*__f)()) + { return mem_fun_t<_Ret, _Tp>(__f); } + + template + inline const_mem_fun_t<_Ret, _Tp> + mem_fun(_Ret (_Tp::*__f)() const) + { return const_mem_fun_t<_Ret, _Tp>(__f); } + + template + inline mem_fun_ref_t<_Ret, _Tp> + mem_fun_ref(_Ret (_Tp::*__f)()) + { return mem_fun_ref_t<_Ret, _Tp>(__f); } + + template + inline const_mem_fun_ref_t<_Ret, _Tp> + mem_fun_ref(_Ret (_Tp::*__f)() const) + { return const_mem_fun_ref_t<_Ret, _Tp>(__f); } + + template + inline mem_fun1_t<_Ret, _Tp, _Arg> + mem_fun(_Ret (_Tp::*__f)(_Arg)) + { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); } + + template + inline const_mem_fun1_t<_Ret, _Tp, _Arg> + mem_fun(_Ret (_Tp::*__f)(_Arg) const) + { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); } + + template + inline mem_fun1_ref_t<_Ret, _Tp, _Arg> + mem_fun_ref(_Ret (_Tp::*__f)(_Arg)) + { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } + + template + inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg> + mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const) + { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); } + + /** @} */ + +#if __cplusplus >= 201402L + template> + struct __has_is_transparent + { }; + + template + struct __has_is_transparent<_Func, _SfinaeType, + __void_t> + { typedef void type; }; + + template + using __has_is_transparent_t + = typename __has_is_transparent<_Func, _SfinaeType>::type; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED +# include +#endif + +#endif /* _STL_FUNCTION_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_heap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_heap.h new file mode 100755 index 0000000..0dca686 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_heap.h @@ -0,0 +1,583 @@ +// Heap implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_heap.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{queue} + */ + +#ifndef _STL_HEAP_H +#define _STL_HEAP_H 1 + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup heap_algorithms Heap + * @ingroup sorting_algorithms + */ + + template + _GLIBCXX20_CONSTEXPR + _Distance + __is_heap_until(_RandomAccessIterator __first, _Distance __n, + _Compare& __comp) + { + _Distance __parent = 0; + for (_Distance __child = 1; __child < __n; ++__child) + { + if (__comp(__first + __parent, __first + __child)) + return __child; + if ((__child & 1) == 0) + ++__parent; + } + return __n; + } + + // __is_heap, a predicate testing whether or not a range is a heap. + // This function is an extension, not part of the C++ standard. + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _Distance __n) + { + __gnu_cxx::__ops::_Iter_less_iter __comp; + return std::__is_heap_until(__first, __n, __comp) == __n; + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _Compare __comp, _Distance __n) + { + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + return std::__is_heap_until(__first, __n, __cmp) == __n; + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { return std::__is_heap(__first, std::distance(__first, __last)); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + return std::__is_heap(__first, _GLIBCXX_MOVE(__comp), + std::distance(__first, __last)); + } + + // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap, + // + is_heap and is_heap_until in C++0x. + + template + _GLIBCXX20_CONSTEXPR + void + __push_heap(_RandomAccessIterator __first, + _Distance __holeIndex, _Distance __topIndex, _Tp __value, + _Compare& __comp) + { + _Distance __parent = (__holeIndex - 1) / 2; + while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) + { + *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __parent)); + __holeIndex = __parent; + __parent = (__holeIndex - 1) / 2; + } + *(__first + __holeIndex) = _GLIBCXX_MOVE(__value); + } + + /** + * @brief Push an element onto a heap. + * @param __first Start of heap. + * @param __last End of heap + element. + * @ingroup heap_algorithms + * + * This operation pushes the element at last-1 onto the valid heap + * over the range [__first,__last-1). After completion, + * [__first,__last) is a valid heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept<_ValueType>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_heap(__first, __last - 1); + + __gnu_cxx::__ops::_Iter_less_val __comp; + _ValueType __value = _GLIBCXX_MOVE(*(__last - 1)); + std::__push_heap(__first, _DistanceType((__last - __first) - 1), + _DistanceType(0), _GLIBCXX_MOVE(__value), __comp); + } + + /** + * @brief Push an element onto a heap using comparison functor. + * @param __first Start of heap. + * @param __last End of heap + element. + * @param __comp Comparison functor. + * @ingroup heap_algorithms + * + * This operation pushes the element at __last-1 onto the valid + * heap over the range [__first,__last-1). After completion, + * [__first,__last) is a valid heap. Compare operations are + * performed using comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_heap_pred(__first, __last - 1, __comp); + + __decltype(__gnu_cxx::__ops::__iter_comp_val(_GLIBCXX_MOVE(__comp))) + __cmp(_GLIBCXX_MOVE(__comp)); + _ValueType __value = _GLIBCXX_MOVE(*(__last - 1)); + std::__push_heap(__first, _DistanceType((__last - __first) - 1), + _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); + } + + template + _GLIBCXX20_CONSTEXPR + void + __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex, + _Distance __len, _Tp __value, _Compare __comp) + { + const _Distance __topIndex = __holeIndex; + _Distance __secondChild = __holeIndex; + while (__secondChild < (__len - 1) / 2) + { + __secondChild = 2 * (__secondChild + 1); + if (__comp(__first + __secondChild, + __first + (__secondChild - 1))) + __secondChild--; + *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild)); + __holeIndex = __secondChild; + } + if ((__len & 1) == 0 && __secondChild == (__len - 2) / 2) + { + __secondChild = 2 * (__secondChild + 1); + *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + + (__secondChild - 1))); + __holeIndex = __secondChild - 1; + } + __decltype(__gnu_cxx::__ops::__iter_comp_val(_GLIBCXX_MOVE(__comp))) + __cmp(_GLIBCXX_MOVE(__comp)); + std::__push_heap(__first, __holeIndex, __topIndex, + _GLIBCXX_MOVE(__value), __cmp); + } + + template + _GLIBCXX20_CONSTEXPR + inline void + __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _RandomAccessIterator __result, _Compare& __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + _ValueType __value = _GLIBCXX_MOVE(*__result); + *__result = _GLIBCXX_MOVE(*__first); + std::__adjust_heap(__first, _DistanceType(0), + _DistanceType(__last - __first), + _GLIBCXX_MOVE(__value), __comp); + } + + /** + * @brief Pop an element off a heap. + * @param __first Start of heap. + * @param __last End of heap. + * @pre [__first, __last) is a valid, non-empty range. + * @ingroup heap_algorithms + * + * This operation pops the top of the heap. The elements __first + * and __last-1 are swapped and [__first,__last-1) is made into a + * heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_non_empty_range(__first, __last); + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_heap(__first, __last); + + if (__last - __first > 1) + { + --__last; + __gnu_cxx::__ops::_Iter_less_iter __comp; + std::__pop_heap(__first, __last, __last, __comp); + } + } + + /** + * @brief Pop an element off a heap using comparison functor. + * @param __first Start of heap. + * @param __last End of heap. + * @param __comp Comparison functor to use. + * @ingroup heap_algorithms + * + * This operation pops the top of the heap. The elements __first + * and __last-1 are swapped and [__first,__last-1) is made into a + * heap. Comparisons are made using comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + pop_heap(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_non_empty_range(__first, __last); + __glibcxx_requires_heap_pred(__first, __last, __comp); + + if (__last - __first > 1) + { + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + --__last; + std::__pop_heap(__first, __last, __last, __cmp); + } + } + + template + _GLIBCXX20_CONSTEXPR + void + __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare& __comp) + { + typedef typename iterator_traits<_RandomAccessIterator>::value_type + _ValueType; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type + _DistanceType; + + if (__last - __first < 2) + return; + + const _DistanceType __len = __last - __first; + _DistanceType __parent = (__len - 2) / 2; + while (true) + { + _ValueType __value = _GLIBCXX_MOVE(*(__first + __parent)); + std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), + __comp); + if (__parent == 0) + return; + __parent--; + } + } + + /** + * @brief Construct a heap over a range. + * @param __first Start of heap. + * @param __last End of heap. + * @ingroup heap_algorithms + * + * This operation makes the elements in [__first,__last) into a heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + __gnu_cxx::__ops::_Iter_less_iter __comp; + std::__make_heap(__first, __last, __comp); + } + + /** + * @brief Construct a heap over a range using comparison functor. + * @param __first Start of heap. + * @param __last End of heap. + * @param __comp Comparison functor to use. + * @ingroup heap_algorithms + * + * This operation makes the elements in [__first,__last) into a heap. + * Comparisons are made using __comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + std::__make_heap(__first, __last, __cmp); + } + + template + _GLIBCXX20_CONSTEXPR + void + __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare& __comp) + { + while (__last - __first > 1) + { + --__last; + std::__pop_heap(__first, __last, __last, __comp); + } + } + + /** + * @brief Sort a heap. + * @param __first Start of heap. + * @param __last End of heap. + * @ingroup heap_algorithms + * + * This operation sorts the valid heap in the range [__first,__last). + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + __glibcxx_requires_heap(__first, __last); + + __gnu_cxx::__ops::_Iter_less_iter __comp; + std::__sort_heap(__first, __last, __comp); + } + + /** + * @brief Sort a heap using comparison functor. + * @param __first Start of heap. + * @param __last End of heap. + * @param __comp Comparison functor to use. + * @ingroup heap_algorithms + * + * This operation sorts the valid heap in the range [__first,__last). + * Comparisons are made using __comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline void + sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + __glibcxx_requires_heap_pred(__first, __last, __comp); + + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + std::__sort_heap(__first, __last, __cmp); + } + +#if __cplusplus >= 201103L + /** + * @brief Search the end of a heap. + * @param __first Start of range. + * @param __last End of range. + * @return An iterator pointing to the first element not in the heap. + * @ingroup heap_algorithms + * + * This operation returns the last iterator i in [__first, __last) for which + * the range [__first, i) is a heap. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_function_requires(_LessThanComparableConcept< + typename iterator_traits<_RandomAccessIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive(__first, __last); + + __gnu_cxx::__ops::_Iter_less_iter __comp; + return __first + + std::__is_heap_until(__first, std::distance(__first, __last), __comp); + } + + /** + * @brief Search the end of a heap using comparison functor. + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor to use. + * @return An iterator pointing to the first element not in the heap. + * @ingroup heap_algorithms + * + * This operation returns the last iterator i in [__first, __last) for which + * the range [__first, i) is a heap. Comparisons are made using __comp. + */ + template + _GLIBCXX20_CONSTEXPR + inline _RandomAccessIterator + is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + return __first + + std::__is_heap_until(__first, std::distance(__first, __last), __cmp); + } + + /** + * @brief Determines whether a range is a heap. + * @param __first Start of range. + * @param __last End of range. + * @return True if range is a heap, false otherwise. + * @ingroup heap_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) + { return std::is_heap_until(__first, __last) == __last; } + + /** + * @brief Determines whether a range is a heap using comparison functor. + * @param __first Start of range. + * @param __last End of range. + * @param __comp Comparison functor to use. + * @return True if range is a heap, false otherwise. + * @ingroup heap_algorithms + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_irreflexive_pred(__first, __last, __comp); + + const auto __dist = std::distance(__first, __last); + typedef __decltype(__comp) _Cmp; + __gnu_cxx::__ops::_Iter_comp_iter<_Cmp> __cmp(_GLIBCXX_MOVE(__comp)); + return std::__is_heap_until(__first, __dist, __cmp) == __dist; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_HEAP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator.h new file mode 100755 index 0000000..f7309e6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator.h @@ -0,0 +1,2393 @@ +// Iterators -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_iterator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + * + * This file implements reverse_iterator, back_insert_iterator, + * front_insert_iterator, insert_iterator, __normal_iterator, and their + * supporting functions and overloaded operators. + */ + +#ifndef _STL_ITERATOR_H +#define _STL_ITERATOR_H 1 + +#include +#include +#include +#include +#include + +#if __cplusplus >= 201103L +# include +#endif + +#if __cplusplus > 201703L +# define __cpp_lib_array_constexpr 201811L +# define __cpp_lib_constexpr_iterator 201811L +#elif __cplusplus == 201703L +# define __cpp_lib_array_constexpr 201803L +#endif + +#if __cplusplus > 201703L +# include +# include +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + +#if __cplusplus > 201703L && __cpp_lib_concepts + namespace __detail + { + // Weaken iterator_category _Cat to _Limit if it is derived from that, + // otherwise use _Otherwise. + template + using __clamp_iter_cat + = conditional_t, _Limit, _Otherwise>; + } +#endif + + // 24.4.1 Reverse iterators + /** + * Bidirectional and random access iterators have corresponding reverse + * %iterator adaptors that iterate through the data structure in the + * opposite direction. They have the same signatures as the corresponding + * iterators. The fundamental relation between a reverse %iterator and its + * corresponding %iterator @c i is established by the identity: + * @code + * &*(reverse_iterator(i)) == &*(i - 1) + * @endcode + * + * This mapping is dictated by the fact that while there is always a + * pointer past the end of an array, there might not be a valid pointer + * before the beginning of an array. [24.4.1]/1,2 + * + * Reverse iterators can be tricky and surprising at first. Their + * semantics make sense, however, and the trickiness is a side effect of + * the requirement that the iterators must be safe. + */ + template + class reverse_iterator + : public iterator::iterator_category, + typename iterator_traits<_Iterator>::value_type, + typename iterator_traits<_Iterator>::difference_type, + typename iterator_traits<_Iterator>::pointer, + typename iterator_traits<_Iterator>::reference> + { + template + friend class reverse_iterator; + +#if __cpp_lib_concepts + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3435. three_way_comparable_with, [...]> + template + static constexpr bool __convertible = !is_same_v<_Iter, _Iterator> + && convertible_to; +#endif + + protected: + _Iterator current; + + typedef iterator_traits<_Iterator> __traits_type; + + public: + typedef _Iterator iterator_type; + typedef typename __traits_type::pointer pointer; +#if __cplusplus <= 201703L + typedef typename __traits_type::difference_type difference_type; + typedef typename __traits_type::reference reference; +#else + using iterator_concept + = conditional_t, + random_access_iterator_tag, + bidirectional_iterator_tag>; + using iterator_category + = __detail::__clamp_iter_cat; + using value_type = iter_value_t<_Iterator>; + using difference_type = iter_difference_t<_Iterator>; + using reference = iter_reference_t<_Iterator>; +#endif + + /** + * The default constructor value-initializes member @p current. + * If it is a pointer, that means it is zero-initialized. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 235 No specification of default ctor for reverse_iterator + // 1012. reverse_iterator default ctor should value initialize + _GLIBCXX17_CONSTEXPR + reverse_iterator() : current() { } + + /** + * This %iterator will move in the opposite direction that @p x does. + */ + explicit _GLIBCXX17_CONSTEXPR + reverse_iterator(iterator_type __x) : current(__x) { } + + /** + * The copy constructor is normal. + */ + _GLIBCXX17_CONSTEXPR + reverse_iterator(const reverse_iterator& __x) + : current(__x.current) { } + +#if __cplusplus >= 201103L + reverse_iterator& operator=(const reverse_iterator&) = default; +#endif + + /** + * A %reverse_iterator across other types can be copied if the + * underlying %iterator can be converted to the type of @c current. + */ + template +#if __cpp_lib_concepts + requires __convertible<_Iter> +#endif + _GLIBCXX17_CONSTEXPR + reverse_iterator(const reverse_iterator<_Iter>& __x) + : current(__x.current) { } + +#if __cplusplus >= 201103L + template +#if __cpp_lib_concepts + requires __convertible<_Iter> + && assignable_from<_Iterator&, const _Iter&> +#endif + _GLIBCXX17_CONSTEXPR + reverse_iterator& + operator=(const reverse_iterator<_Iter>& __x) + { + current = __x.current; + return *this; + } +#endif + + /** + * @return @c current, the %iterator used for underlying work. + */ + _GLIBCXX17_CONSTEXPR iterator_type + base() const + { return current; } + + /** + * @return A reference to the value at @c --current + * + * This requires that @c --current is dereferenceable. + * + * @warning This implementation requires that for an iterator of the + * underlying iterator type, @c x, a reference obtained by + * @c *x remains valid after @c x has been modified or + * destroyed. This is a bug: http://gcc.gnu.org/PR51823 + */ + _GLIBCXX17_CONSTEXPR reference + operator*() const + { + _Iterator __tmp = current; + return *--__tmp; + } + + /** + * @return A pointer to the value at @c --current + * + * This requires that @c --current is dereferenceable. + */ + _GLIBCXX17_CONSTEXPR pointer + operator->() const +#if __cplusplus > 201703L && __cpp_concepts >= 201907L + requires is_pointer_v<_Iterator> + || requires(const _Iterator __i) { __i.operator->(); } +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 1052. operator-> should also support smart pointers + _Iterator __tmp = current; + --__tmp; + return _S_to_pointer(__tmp); + } + + /** + * @return @c *this + * + * Decrements the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator++() + { + --current; + return *this; + } + + /** + * @return The original value of @c *this + * + * Decrements the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator + operator++(int) + { + reverse_iterator __tmp = *this; + --current; + return __tmp; + } + + /** + * @return @c *this + * + * Increments the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator--() + { + ++current; + return *this; + } + + /** + * @return A reverse_iterator with the previous value of @c *this + * + * Increments the underlying iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator + operator--(int) + { + reverse_iterator __tmp = *this; + ++current; + return __tmp; + } + + /** + * @return A reverse_iterator that refers to @c current - @a __n + * + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator + operator+(difference_type __n) const + { return reverse_iterator(current - __n); } + + /** + * @return *this + * + * Moves the underlying iterator backwards @a __n steps. + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator+=(difference_type __n) + { + current -= __n; + return *this; + } + + /** + * @return A reverse_iterator that refers to @c current - @a __n + * + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator + operator-(difference_type __n) const + { return reverse_iterator(current + __n); } + + /** + * @return *this + * + * Moves the underlying iterator forwards @a __n steps. + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reverse_iterator& + operator-=(difference_type __n) + { + current += __n; + return *this; + } + + /** + * @return The value at @c current - @a __n - 1 + * + * The underlying iterator must be a Random Access Iterator. + */ + _GLIBCXX17_CONSTEXPR reference + operator[](difference_type __n) const + { return *(*this + __n); } + +#if __cplusplus > 201703L && __cpp_lib_concepts + friend constexpr iter_rvalue_reference_t<_Iterator> + iter_move(const reverse_iterator& __i) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && noexcept(ranges::iter_move(--std::declval<_Iterator&>()))) + { + auto __tmp = __i.base(); + return ranges::iter_move(--__tmp); + } + + template _Iter2> + friend constexpr void + iter_swap(const reverse_iterator& __x, + const reverse_iterator<_Iter2>& __y) + noexcept(is_nothrow_copy_constructible_v<_Iterator> + && is_nothrow_copy_constructible_v<_Iter2> + && noexcept(ranges::iter_swap(--std::declval<_Iterator&>(), + --std::declval<_Iter2&>()))) + { + auto __xtmp = __x.base(); + auto __ytmp = __y.base(); + ranges::iter_swap(--__xtmp, --__ytmp); + } +#endif + + private: + template + static _GLIBCXX17_CONSTEXPR _Tp* + _S_to_pointer(_Tp* __p) + { return __p; } + + template + static _GLIBCXX17_CONSTEXPR pointer + _S_to_pointer(_Tp __t) + { return __t.operator->(); } + }; + + ///@{ + /** + * @param __x A %reverse_iterator. + * @param __y A %reverse_iterator. + * @return A simple bool. + * + * Reverse iterators forward comparisons to their underlying base() + * iterators. + * + */ +#if __cplusplus <= 201703L || ! defined __cpp_lib_concepts + template + inline _GLIBCXX17_CONSTEXPR bool + operator==(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y.base() < __x.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__x == __y); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y < __x; } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__y < __x); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return !(__x < __y); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 280. Comparison of reverse_iterator to const reverse_iterator. + + template + inline _GLIBCXX17_CONSTEXPR bool + operator==(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() == __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() > __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() != __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() < __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() >= __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __x.base() <= __y.base(); } +#else // C++20 + template + constexpr bool + operator==(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() == __y.base() } -> convertible_to; } + { return __x.base() == __y.base(); } + + template + constexpr bool + operator!=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() != __y.base() } -> convertible_to; } + { return __x.base() != __y.base(); } + + template + constexpr bool + operator<(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() > __y.base() } -> convertible_to; } + { return __x.base() > __y.base(); } + + template + constexpr bool + operator>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() < __y.base() } -> convertible_to; } + { return __x.base() < __y.base(); } + + template + constexpr bool + operator<=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() >= __y.base() } -> convertible_to; } + { return __x.base() >= __y.base(); } + + template + constexpr bool + operator>=(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + requires requires { { __x.base() <= __y.base() } -> convertible_to; } + { return __x.base() <= __y.base(); } + + template _IteratorR> + constexpr compare_three_way_result_t<_IteratorL, _IteratorR> + operator<=>(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y.base() <=> __x.base(); } +#endif // C++20 + ///@} + +#if __cplusplus < 201103L + template + inline typename reverse_iterator<_Iterator>::difference_type + operator-(const reverse_iterator<_Iterator>& __x, + const reverse_iterator<_Iterator>& __y) + { return __y.base() - __x.base(); } + + template + inline typename reverse_iterator<_IteratorL>::difference_type + operator-(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + { return __y.base() - __x.base(); } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 685. reverse_iterator/move_iterator difference has invalid signatures + template + inline _GLIBCXX17_CONSTEXPR auto + operator-(const reverse_iterator<_IteratorL>& __x, + const reverse_iterator<_IteratorR>& __y) + -> decltype(__y.base() - __x.base()) + { return __y.base() - __x.base(); } +#endif + + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator> + operator+(typename reverse_iterator<_Iterator>::difference_type __n, + const reverse_iterator<_Iterator>& __x) + { return reverse_iterator<_Iterator>(__x.base() - __n); } + +#if __cplusplus >= 201103L + // Same as C++14 make_reverse_iterator but used in C++11 mode too. + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator> + __make_reverse_iterator(_Iterator __i) + { return reverse_iterator<_Iterator>(__i); } + +# if __cplusplus >= 201402L +# define __cpp_lib_make_reverse_iterator 201402 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 2285. make_reverse_iterator + /// Generator function for reverse_iterator. + template + inline _GLIBCXX17_CONSTEXPR reverse_iterator<_Iterator> + make_reverse_iterator(_Iterator __i) + { return reverse_iterator<_Iterator>(__i); } + +# if __cplusplus > 201703L && defined __cpp_lib_concepts + template + requires (!sized_sentinel_for<_Iterator1, _Iterator2>) + inline constexpr bool + disable_sized_sentinel_for, + reverse_iterator<_Iterator2>> = true; +# endif // C++20 +# endif // C++14 + + template + _GLIBCXX20_CONSTEXPR + auto + __niter_base(reverse_iterator<_Iterator> __it) + -> decltype(__make_reverse_iterator(__niter_base(__it.base()))) + { return __make_reverse_iterator(__niter_base(__it.base())); } + + template + struct __is_move_iterator > + : __is_move_iterator<_Iterator> + { }; + + template + _GLIBCXX20_CONSTEXPR + auto + __miter_base(reverse_iterator<_Iterator> __it) + -> decltype(__make_reverse_iterator(__miter_base(__it.base()))) + { return __make_reverse_iterator(__miter_base(__it.base())); } +#endif // C++11 + + // 24.4.2.2.1 back_insert_iterator + /** + * @brief Turns assignment into insertion. + * + * These are output iterators, constructed from a container-of-T. + * Assigning a T to the iterator appends it to the container using + * push_back. + * + * Tip: Using the back_inserter function to create these iterators can + * save typing. + */ + template + class back_insert_iterator + : public iterator + { + protected: + _Container* container; + + public: + /// A nested typedef for the type of whatever container you used. + typedef _Container container_type; +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; + + constexpr back_insert_iterator() noexcept : container(nullptr) { } +#endif + + /// The only way to create this %iterator is with a container. + explicit _GLIBCXX20_CONSTEXPR + back_insert_iterator(_Container& __x) + : container(std::__addressof(__x)) { } + + /** + * @param __value An instance of whatever type + * container_type::const_reference is; presumably a + * reference-to-const T for container. + * @return This %iterator, for chained operations. + * + * This kind of %iterator doesn't really have a @a position in the + * container (you can think of the position as being permanently at + * the end, if you like). Assigning a value to the %iterator will + * always append the value to the end of the container. + */ +#if __cplusplus < 201103L + back_insert_iterator& + operator=(typename _Container::const_reference __value) + { + container->push_back(__value); + return *this; + } +#else + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator=(const typename _Container::value_type& __value) + { + container->push_back(__value); + return *this; + } + + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator=(typename _Container::value_type&& __value) + { + container->push_back(std::move(__value)); + return *this; + } +#endif + + /// Simply returns *this. + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator*() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + back_insert_iterator& + operator++() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + back_insert_iterator + operator++(int) + { return *this; } + }; + + /** + * @param __x A container of arbitrary type. + * @return An instance of back_insert_iterator working on @p __x. + * + * This wrapper function helps in creating back_insert_iterator instances. + * Typing the name of the %iterator requires knowing the precise full + * type of the container, which can be tedious and impedes generic + * programming. Using this function lets you take advantage of automatic + * template parameter deduction, making the compiler match the correct + * types for you. + */ + template + _GLIBCXX20_CONSTEXPR + inline back_insert_iterator<_Container> + back_inserter(_Container& __x) + { return back_insert_iterator<_Container>(__x); } + + /** + * @brief Turns assignment into insertion. + * + * These are output iterators, constructed from a container-of-T. + * Assigning a T to the iterator prepends it to the container using + * push_front. + * + * Tip: Using the front_inserter function to create these iterators can + * save typing. + */ + template + class front_insert_iterator + : public iterator + { + protected: + _Container* container; + + public: + /// A nested typedef for the type of whatever container you used. + typedef _Container container_type; +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; + + constexpr front_insert_iterator() noexcept : container(nullptr) { } +#endif + + /// The only way to create this %iterator is with a container. + explicit _GLIBCXX20_CONSTEXPR + front_insert_iterator(_Container& __x) + : container(std::__addressof(__x)) { } + + /** + * @param __value An instance of whatever type + * container_type::const_reference is; presumably a + * reference-to-const T for container. + * @return This %iterator, for chained operations. + * + * This kind of %iterator doesn't really have a @a position in the + * container (you can think of the position as being permanently at + * the front, if you like). Assigning a value to the %iterator will + * always prepend the value to the front of the container. + */ +#if __cplusplus < 201103L + front_insert_iterator& + operator=(typename _Container::const_reference __value) + { + container->push_front(__value); + return *this; + } +#else + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator=(const typename _Container::value_type& __value) + { + container->push_front(__value); + return *this; + } + + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator=(typename _Container::value_type&& __value) + { + container->push_front(std::move(__value)); + return *this; + } +#endif + + /// Simply returns *this. + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator*() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + front_insert_iterator& + operator++() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + front_insert_iterator + operator++(int) + { return *this; } + }; + + /** + * @param __x A container of arbitrary type. + * @return An instance of front_insert_iterator working on @p x. + * + * This wrapper function helps in creating front_insert_iterator instances. + * Typing the name of the %iterator requires knowing the precise full + * type of the container, which can be tedious and impedes generic + * programming. Using this function lets you take advantage of automatic + * template parameter deduction, making the compiler match the correct + * types for you. + */ + template + _GLIBCXX20_CONSTEXPR + inline front_insert_iterator<_Container> + front_inserter(_Container& __x) + { return front_insert_iterator<_Container>(__x); } + + /** + * @brief Turns assignment into insertion. + * + * These are output iterators, constructed from a container-of-T. + * Assigning a T to the iterator inserts it in the container at the + * %iterator's position, rather than overwriting the value at that + * position. + * + * (Sequences will actually insert a @e copy of the value before the + * %iterator's position.) + * + * Tip: Using the inserter function to create these iterators can + * save typing. + */ + template + class insert_iterator + : public iterator + { +#if __cplusplus > 201703L && defined __cpp_lib_concepts + using _Iter = std::__detail::__range_iter_t<_Container>; + + protected: + _Container* container = nullptr; + _Iter iter = _Iter(); +#else + typedef typename _Container::iterator _Iter; + + protected: + _Container* container; + _Iter iter; +#endif + + public: + /// A nested typedef for the type of whatever container you used. + typedef _Container container_type; + +#if __cplusplus > 201703L && defined __cpp_lib_concepts + using difference_type = ptrdiff_t; + + insert_iterator() = default; +#endif + + /** + * The only way to create this %iterator is with a container and an + * initial position (a normal %iterator into the container). + */ + _GLIBCXX20_CONSTEXPR + insert_iterator(_Container& __x, _Iter __i) + : container(std::__addressof(__x)), iter(__i) {} + + /** + * @param __value An instance of whatever type + * container_type::const_reference is; presumably a + * reference-to-const T for container. + * @return This %iterator, for chained operations. + * + * This kind of %iterator maintains its own position in the + * container. Assigning a value to the %iterator will insert the + * value into the container at the place before the %iterator. + * + * The position is maintained such that subsequent assignments will + * insert values immediately after one another. For example, + * @code + * // vector v contains A and Z + * + * insert_iterator i (v, ++v.begin()); + * i = 1; + * i = 2; + * i = 3; + * + * // vector v contains A, 1, 2, 3, and Z + * @endcode + */ +#if __cplusplus < 201103L + insert_iterator& + operator=(typename _Container::const_reference __value) + { + iter = container->insert(iter, __value); + ++iter; + return *this; + } +#else + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator=(const typename _Container::value_type& __value) + { + iter = container->insert(iter, __value); + ++iter; + return *this; + } + + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator=(typename _Container::value_type&& __value) + { + iter = container->insert(iter, std::move(__value)); + ++iter; + return *this; + } +#endif + + /// Simply returns *this. + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator*() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator++() + { return *this; } + + /// Simply returns *this. (This %iterator does not @a move.) + _GLIBCXX20_CONSTEXPR + insert_iterator& + operator++(int) + { return *this; } + }; + + /** + * @param __x A container of arbitrary type. + * @param __i An iterator into the container. + * @return An instance of insert_iterator working on @p __x. + * + * This wrapper function helps in creating insert_iterator instances. + * Typing the name of the %iterator requires knowing the precise full + * type of the container, which can be tedious and impedes generic + * programming. Using this function lets you take advantage of automatic + * template parameter deduction, making the compiler match the correct + * types for you. + */ +#if __cplusplus > 201703L && defined __cpp_lib_concepts + template + constexpr insert_iterator<_Container> + inserter(_Container& __x, std::__detail::__range_iter_t<_Container> __i) + { return insert_iterator<_Container>(__x, __i); } +#else + template + inline insert_iterator<_Container> + inserter(_Container& __x, typename _Container::iterator __i) + { return insert_iterator<_Container>(__x, __i); } +#endif + + /// @} group iterators + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // This iterator adapter is @a normal in the sense that it does not + // change the semantics of any of the operators of its iterator + // parameter. Its primary purpose is to convert an iterator that is + // not a class, e.g. a pointer, into an iterator that is a class. + // The _Container parameter exists solely so that different containers + // using this template can instantiate different types, even if the + // _Iterator parameter is the same. + template + class __normal_iterator + { + protected: + _Iterator _M_current; + + typedef std::iterator_traits<_Iterator> __traits_type; + + public: + typedef _Iterator iterator_type; + typedef typename __traits_type::iterator_category iterator_category; + typedef typename __traits_type::value_type value_type; + typedef typename __traits_type::difference_type difference_type; + typedef typename __traits_type::reference reference; + typedef typename __traits_type::pointer pointer; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept = std::__detail::__iter_concept<_Iterator>; +#endif + + _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT + : _M_current(_Iterator()) { } + + explicit _GLIBCXX20_CONSTEXPR + __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT + : _M_current(__i) { } + + // Allow iterator to const_iterator conversion + template + _GLIBCXX20_CONSTEXPR + __normal_iterator(const __normal_iterator<_Iter, + typename __enable_if< + (std::__are_same<_Iter, typename _Container::pointer>::__value), + _Container>::__type>& __i) _GLIBCXX_NOEXCEPT + : _M_current(__i.base()) { } + + // Forward iterator requirements + _GLIBCXX20_CONSTEXPR + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *_M_current; } + + _GLIBCXX20_CONSTEXPR + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return _M_current; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator++() _GLIBCXX_NOEXCEPT + { + ++_M_current; + return *this; + } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator++(int) _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current++); } + + // Bidirectional iterator requirements + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator--() _GLIBCXX_NOEXCEPT + { + --_M_current; + return *this; + } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator--(int) _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current--); } + + // Random access iterator requirements + _GLIBCXX20_CONSTEXPR + reference + operator[](difference_type __n) const _GLIBCXX_NOEXCEPT + { return _M_current[__n]; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator+=(difference_type __n) _GLIBCXX_NOEXCEPT + { _M_current += __n; return *this; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator+(difference_type __n) const _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current + __n); } + + _GLIBCXX20_CONSTEXPR + __normal_iterator& + operator-=(difference_type __n) _GLIBCXX_NOEXCEPT + { _M_current -= __n; return *this; } + + _GLIBCXX20_CONSTEXPR + __normal_iterator + operator-(difference_type __n) const _GLIBCXX_NOEXCEPT + { return __normal_iterator(_M_current - __n); } + + _GLIBCXX20_CONSTEXPR + const _Iterator& + base() const _GLIBCXX_NOEXCEPT + { return _M_current; } + }; + + // Note: In what follows, the left- and right-hand-side iterators are + // allowed to vary in types (conceptually in cv-qualification) so that + // comparison between cv-qualified and non-cv-qualified iterators be + // valid. However, the greedy and unfriendly operators in std::rel_ops + // will make overload resolution ambiguous (when in scope) if we don't + // provide overloads whose operands are of the same type. Can someone + // remind me what generic programming is about? -- Gaby + +#if __cpp_lib_three_way_comparison + template + requires requires (_IteratorL __lhs, _IteratorR __rhs) + { { __lhs == __rhs } -> std::convertible_to; } + constexpr bool + operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + noexcept(noexcept(__lhs.base() == __rhs.base())) + { return __lhs.base() == __rhs.base(); } + + template + constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL> + operator<=>(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base()))) + { return std::__detail::__synth3way(__lhs.base(), __rhs.base()); } +#else + // Forward iterator requirements + template + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() == __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator==(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() == __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() != __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() != __rhs.base(); } + + // Random access iterator requirements + template + inline bool + operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() < __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator<(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() < __rhs.base(); } + + template + inline bool + operator>(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() > __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator>(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() > __rhs.base(); } + + template + inline bool + operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() <= __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator<=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() <= __rhs.base(); } + + template + inline bool + operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() >= __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + operator>=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() >= __rhs.base(); } +#endif // three-way comparison + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template +#if __cplusplus >= 201103L + // DR 685. + _GLIBCXX20_CONSTEXPR + inline auto + operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept + -> decltype(__lhs.base() - __rhs.base()) +#else + inline typename __normal_iterator<_IteratorL, _Container>::difference_type + operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) +#endif + { return __lhs.base() - __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline typename __normal_iterator<_Iterator, _Container>::difference_type + operator-(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + _GLIBCXX_NOEXCEPT + { return __lhs.base() - __rhs.base(); } + + template + _GLIBCXX20_CONSTEXPR + inline __normal_iterator<_Iterator, _Container> + operator+(typename __normal_iterator<_Iterator, _Container>::difference_type + __n, const __normal_iterator<_Iterator, _Container>& __i) + _GLIBCXX_NOEXCEPT + { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + _GLIBCXX20_CONSTEXPR + _Iterator + __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it) + _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_copy_constructible<_Iterator>::value) + { return __it.base(); } + +#if __cplusplus >= 201103L + /** + * @addtogroup iterators + * @{ + */ + +#if __cplusplus > 201703L && __cpp_lib_concepts + template + class move_sentinel + { + public: + constexpr + move_sentinel() + noexcept(is_nothrow_default_constructible_v<_Sent>) + : _M_last() { } + + constexpr explicit + move_sentinel(_Sent __s) + noexcept(is_nothrow_move_constructible_v<_Sent>) + : _M_last(std::move(__s)) { } + + template requires convertible_to + constexpr + move_sentinel(const move_sentinel<_S2>& __s) + noexcept(is_nothrow_constructible_v<_Sent, const _S2&>) + : _M_last(__s.base()) + { } + + template requires assignable_from<_Sent&, const _S2&> + constexpr move_sentinel& + operator=(const move_sentinel<_S2>& __s) + noexcept(is_nothrow_assignable_v<_Sent, const _S2&>) + { + _M_last = __s.base(); + return *this; + } + + constexpr _Sent + base() const + noexcept(is_nothrow_copy_constructible_v<_Sent>) + { return _M_last; } + + private: + _Sent _M_last; + }; +#endif // C++20 + + namespace __detail + { +#if __cplusplus > 201703L && __cpp_lib_concepts + template + struct __move_iter_cat + { }; + + template + requires requires { typename iterator_traits<_Iterator>::iterator_category; } + struct __move_iter_cat<_Iterator> + { + using iterator_category + = __clamp_iter_cat::iterator_category, + random_access_iterator_tag>; + }; +#endif + } + + // 24.4.3 Move iterators + /** + * Class template move_iterator is an iterator adapter with the same + * behavior as the underlying iterator except that its dereference + * operator implicitly converts the value returned by the underlying + * iterator's dereference operator to an rvalue reference. Some + * generic algorithms can be called with move iterators to replace + * copying with moving. + */ + template + class move_iterator +#if __cplusplus > 201703L && __cpp_lib_concepts + : public __detail::__move_iter_cat<_Iterator> +#endif + { + _Iterator _M_current; + + using __traits_type = iterator_traits<_Iterator>; +#if ! (__cplusplus > 201703L && __cpp_lib_concepts) + using __base_ref = typename __traits_type::reference; +#endif + + template + friend class move_iterator; + +#if __cpp_lib_concepts + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3435. three_way_comparable_with, [...]> + template + static constexpr bool __convertible = !is_same_v<_Iter2, _Iterator> + && convertible_to; +#endif + + public: + using iterator_type = _Iterator; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept = input_iterator_tag; + // iterator_category defined in __move_iter_cat + using value_type = iter_value_t<_Iterator>; + using difference_type = iter_difference_t<_Iterator>; + using pointer = _Iterator; + using reference = iter_rvalue_reference_t<_Iterator>; +#else + typedef typename __traits_type::iterator_category iterator_category; + typedef typename __traits_type::value_type value_type; + typedef typename __traits_type::difference_type difference_type; + // NB: DR 680. + typedef _Iterator pointer; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2106. move_iterator wrapping iterators returning prvalues + typedef typename conditional::value, + typename remove_reference<__base_ref>::type&&, + __base_ref>::type reference; +#endif + + _GLIBCXX17_CONSTEXPR + move_iterator() + : _M_current() { } + + explicit _GLIBCXX17_CONSTEXPR + move_iterator(iterator_type __i) + : _M_current(std::move(__i)) { } + + template +#if __cpp_lib_concepts + requires __convertible<_Iter> +#endif + _GLIBCXX17_CONSTEXPR + move_iterator(const move_iterator<_Iter>& __i) + : _M_current(__i._M_current) { } + + template +#if __cpp_lib_concepts + requires __convertible<_Iter> + && assignable_from<_Iterator&, const _Iter&> +#endif + _GLIBCXX17_CONSTEXPR + move_iterator& operator=(const move_iterator<_Iter>& __i) + { + _M_current = __i._M_current; + return *this; + } + +#if __cplusplus <= 201703L + _GLIBCXX17_CONSTEXPR iterator_type + base() const + { return _M_current; } +#else + constexpr const iterator_type& + base() const & noexcept + { return _M_current; } + + constexpr iterator_type + base() && + { return std::move(_M_current); } +#endif + + _GLIBCXX17_CONSTEXPR reference + operator*() const +#if __cplusplus > 201703L && __cpp_lib_concepts + { return ranges::iter_move(_M_current); } +#else + { return static_cast(*_M_current); } +#endif + + _GLIBCXX17_CONSTEXPR pointer + operator->() const + { return _M_current; } + + _GLIBCXX17_CONSTEXPR move_iterator& + operator++() + { + ++_M_current; + return *this; + } + + _GLIBCXX17_CONSTEXPR move_iterator + operator++(int) + { + move_iterator __tmp = *this; + ++_M_current; + return __tmp; + } + +#if __cpp_lib_concepts + constexpr void + operator++(int) requires (!forward_iterator<_Iterator>) + { ++_M_current; } +#endif + + _GLIBCXX17_CONSTEXPR move_iterator& + operator--() + { + --_M_current; + return *this; + } + + _GLIBCXX17_CONSTEXPR move_iterator + operator--(int) + { + move_iterator __tmp = *this; + --_M_current; + return __tmp; + } + + _GLIBCXX17_CONSTEXPR move_iterator + operator+(difference_type __n) const + { return move_iterator(_M_current + __n); } + + _GLIBCXX17_CONSTEXPR move_iterator& + operator+=(difference_type __n) + { + _M_current += __n; + return *this; + } + + _GLIBCXX17_CONSTEXPR move_iterator + operator-(difference_type __n) const + { return move_iterator(_M_current - __n); } + + _GLIBCXX17_CONSTEXPR move_iterator& + operator-=(difference_type __n) + { + _M_current -= __n; + return *this; + } + + _GLIBCXX17_CONSTEXPR reference + operator[](difference_type __n) const +#if __cplusplus > 201703L && __cpp_lib_concepts + { return ranges::iter_move(_M_current + __n); } +#else + { return std::move(_M_current[__n]); } +#endif + +#if __cplusplus > 201703L && __cpp_lib_concepts + template _Sent> + friend constexpr bool + operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y) + { return __x.base() == __y.base(); } + + template _Sent> + friend constexpr iter_difference_t<_Iterator> + operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y) + { return __x.base() - __y.base(); } + + template _Sent> + friend constexpr iter_difference_t<_Iterator> + operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y) + { return __x.base() - __y.base(); } + + friend constexpr iter_rvalue_reference_t<_Iterator> + iter_move(const move_iterator& __i) + noexcept(noexcept(ranges::iter_move(__i._M_current))) + { return ranges::iter_move(__i._M_current); } + + template _Iter2> + friend constexpr void + iter_swap(const move_iterator& __x, const move_iterator<_Iter2>& __y) + noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) + { return ranges::iter_swap(__x._M_current, __y._M_current); } +#endif // C++20 + }; + + template + inline _GLIBCXX17_CONSTEXPR bool + operator==(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __x.base() == __y.base() } -> convertible_to; } +#endif + { return __x.base() == __y.base(); } + +#if __cpp_lib_three_way_comparison + template _IteratorR> + constexpr compare_three_way_result_t<_IteratorL, _IteratorR> + operator<=>(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return __x.base() <=> __y.base(); } +#else + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + { return !(__x == __y); } +#endif + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __x.base() < __y.base() } -> convertible_to; } +#endif + { return __x.base() < __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __y.base() < __x.base() } -> convertible_to; } +#endif + { return !(__y < __x); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __y.base() < __x.base() } -> convertible_to; } +#endif + { return __y < __x; } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) +#if __cplusplus > 201703L && __cpp_lib_concepts + requires requires { { __x.base() < __y.base() } -> convertible_to; } +#endif + { return !(__x < __y); } + +#if ! (__cplusplus > 201703L && __cpp_lib_concepts) + // Note: See __normal_iterator operators note from Gaby to understand + // why we have these extra overloads for some move_iterator operators. + + // These extra overloads are not needed in C++20, because the ones above + // are constrained with a requires-clause and so overload resolution will + // prefer them to greedy unconstrained function templates. + + template + inline _GLIBCXX17_CONSTEXPR bool + operator==(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() == __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator!=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x == __y); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __x.base() < __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator<=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__y < __x); } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return __y < __x; } + + template + inline _GLIBCXX17_CONSTEXPR bool + operator>=(const move_iterator<_Iterator>& __x, + const move_iterator<_Iterator>& __y) + { return !(__x < __y); } +#endif // ! C++20 + + // DR 685. + template + inline _GLIBCXX17_CONSTEXPR auto + operator-(const move_iterator<_IteratorL>& __x, + const move_iterator<_IteratorR>& __y) + -> decltype(__x.base() - __y.base()) + { return __x.base() - __y.base(); } + + template + inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator> + operator+(typename move_iterator<_Iterator>::difference_type __n, + const move_iterator<_Iterator>& __x) + { return __x + __n; } + + template + inline _GLIBCXX17_CONSTEXPR move_iterator<_Iterator> + make_move_iterator(_Iterator __i) + { return move_iterator<_Iterator>(std::move(__i)); } + + template::value_type>::value, + _Iterator, move_iterator<_Iterator>>::type> + inline _GLIBCXX17_CONSTEXPR _ReturnType + __make_move_if_noexcept_iterator(_Iterator __i) + { return _ReturnType(__i); } + + // Overload for pointers that matches std::move_if_noexcept more closely, + // returning a constant iterator when we don't want to move. + template::value, + const _Tp*, move_iterator<_Tp*>>::type> + inline _GLIBCXX17_CONSTEXPR _ReturnType + __make_move_if_noexcept_iterator(_Tp* __i) + { return _ReturnType(__i); } + +#if __cplusplus > 201703L && __cpp_lib_concepts + // [iterators.common] Common iterators + + namespace __detail + { + template + concept __common_iter_has_arrow = indirectly_readable + && (requires(const _It& __it) { __it.operator->(); } + || is_reference_v> + || constructible_from, iter_reference_t<_It>>); + + template + concept __common_iter_use_postfix_proxy + = (!requires (_It& __i) { { *__i++ } -> __can_reference; }) + && constructible_from, iter_reference_t<_It>> + && move_constructible>; + } // namespace __detail + + /// An iterator/sentinel adaptor for representing a non-common range. + template _Sent> + requires (!same_as<_It, _Sent>) && copyable<_It> + class common_iterator + { + template + static constexpr bool + _S_noexcept1() + { + if constexpr (is_trivially_default_constructible_v<_Tp>) + return is_nothrow_assignable_v<_Tp, _Up>; + else + return is_nothrow_constructible_v<_Tp, _Up>; + } + + template + static constexpr bool + _S_noexcept() + { return _S_noexcept1<_It, _It2>() && _S_noexcept1<_Sent, _Sent2>(); } + + class __arrow_proxy + { + iter_value_t<_It> _M_keep; + + __arrow_proxy(iter_reference_t<_It>&& __x) + : _M_keep(std::move(__x)) { } + + friend class common_iterator; + + public: + const iter_value_t<_It>* + operator->() const + { return std::__addressof(_M_keep); } + }; + + class __postfix_proxy + { + iter_value_t<_It> _M_keep; + + __postfix_proxy(iter_reference_t<_It>&& __x) + : _M_keep(std::forward>(__x)) { } + + friend class common_iterator; + + public: + const iter_value_t<_It>& + operator*() const + { return _M_keep; } + }; + + public: + constexpr + common_iterator() + noexcept(is_nothrow_default_constructible_v<_It>) + : _M_it(), _M_index(0) + { } + + constexpr + common_iterator(_It __i) + noexcept(is_nothrow_move_constructible_v<_It>) + : _M_it(std::move(__i)), _M_index(0) + { } + + constexpr + common_iterator(_Sent __s) + noexcept(is_nothrow_move_constructible_v<_Sent>) + : _M_sent(std::move(__s)), _M_index(1) + { } + + template + requires convertible_to + && convertible_to + constexpr + common_iterator(const common_iterator<_It2, _Sent2>& __x) + noexcept(_S_noexcept()) + : _M_valueless(), _M_index(__x._M_index) + { + if (_M_index == 0) + { + if constexpr (is_trivially_default_constructible_v<_It>) + _M_it = std::move(__x._M_it); + else + ::new((void*)std::__addressof(_M_it)) _It(__x._M_it); + } + else if (_M_index == 1) + { + if constexpr (is_trivially_default_constructible_v<_Sent>) + _M_sent = std::move(__x._M_sent); + else + ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + } + } + + constexpr + common_iterator(const common_iterator& __x) + noexcept(_S_noexcept()) + : _M_valueless(), _M_index(__x._M_index) + { + if (_M_index == 0) + { + if constexpr (is_trivially_default_constructible_v<_It>) + _M_it = std::move(__x._M_it); + else + ::new((void*)std::__addressof(_M_it)) _It(__x._M_it); + } + else if (_M_index == 1) + { + if constexpr (is_trivially_default_constructible_v<_Sent>) + _M_sent = std::move(__x._M_sent); + else + ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + } + } + + common_iterator& + operator=(const common_iterator& __x) + noexcept(is_nothrow_copy_assignable_v<_It> + && is_nothrow_copy_assignable_v<_Sent> + && is_nothrow_copy_constructible_v<_It> + && is_nothrow_copy_constructible_v<_Sent>) + { + return this->operator=<_It, _Sent>(__x); + } + + template + requires convertible_to + && convertible_to + && assignable_from<_It&, const _It2&> + && assignable_from<_Sent&, const _Sent2&> + common_iterator& + operator=(const common_iterator<_It2, _Sent2>& __x) + noexcept(is_nothrow_constructible_v<_It, const _It2&> + && is_nothrow_constructible_v<_Sent, const _Sent2&> + && is_nothrow_assignable_v<_It, const _It2&> + && is_nothrow_assignable_v<_Sent, const _Sent2&>) + { + switch(_M_index << 2 | __x._M_index) + { + case 0b0000: + _M_it = __x._M_it; + break; + case 0b0101: + _M_sent = __x._M_sent; + break; + case 0b0001: + _M_it.~_It(); + _M_index = -1; + [[fallthrough]]; + case 0b1001: + ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + _M_index = 1; + break; + case 0b0100: + _M_sent.~_Sent(); + _M_index = -1; + [[fallthrough]]; + case 0b1000: + ::new((void*)std::__addressof(_M_it)) _It(__x._M_it); + _M_index = 0; + break; + default: + __glibcxx_assert(__x._M_has_value()); + __builtin_unreachable(); + } + return *this; + } + + ~common_iterator() + { + switch (_M_index) + { + case 0: + _M_it.~_It(); + break; + case 1: + _M_sent.~_Sent(); + break; + } + } + + decltype(auto) + operator*() + { + __glibcxx_assert(_M_index == 0); + return *_M_it; + } + + decltype(auto) + operator*() const requires __detail::__dereferenceable + { + __glibcxx_assert(_M_index == 0); + return *_M_it; + } + + decltype(auto) + operator->() const requires __detail::__common_iter_has_arrow<_It> + { + __glibcxx_assert(_M_index == 0); + if constexpr (is_pointer_v<_It> || requires { _M_it.operator->(); }) + return _M_it; + else if constexpr (is_reference_v>) + { + auto&& __tmp = *_M_it; + return std::__addressof(__tmp); + } + else + return __arrow_proxy{*_M_it}; + } + + common_iterator& + operator++() + { + __glibcxx_assert(_M_index == 0); + ++_M_it; + return *this; + } + + decltype(auto) + operator++(int) + { + __glibcxx_assert(_M_index == 0); + if constexpr (forward_iterator<_It>) + { + common_iterator __tmp = *this; + ++*this; + return __tmp; + } + else if constexpr (!__detail::__common_iter_use_postfix_proxy<_It>) + return _M_it++; + else + { + __postfix_proxy __p(**this); + ++*this; + return __p; + } + } + + template _Sent2> + requires sentinel_for<_Sent, _It2> + friend bool + operator==(const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + { + switch(__x._M_index << 2 | __y._M_index) + { + case 0b0000: + case 0b0101: + return true; + case 0b0001: + return __x._M_it == __y._M_sent; + case 0b0100: + return __x._M_sent == __y._M_it; + default: + __glibcxx_assert(__x._M_has_value()); + __glibcxx_assert(__y._M_has_value()); + __builtin_unreachable(); + } + } + + template _Sent2> + requires sentinel_for<_Sent, _It2> && equality_comparable_with<_It, _It2> + friend bool + operator==(const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + { + switch(__x._M_index << 2 | __y._M_index) + { + case 0b0101: + return true; + case 0b0000: + return __x._M_it == __y._M_it; + case 0b0001: + return __x._M_it == __y._M_sent; + case 0b0100: + return __x._M_sent == __y._M_it; + default: + __glibcxx_assert(__x._M_has_value()); + __glibcxx_assert(__y._M_has_value()); + __builtin_unreachable(); + } + } + + template _It2, sized_sentinel_for<_It> _Sent2> + requires sized_sentinel_for<_Sent, _It2> + friend iter_difference_t<_It2> + operator-(const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + { + switch(__x._M_index << 2 | __y._M_index) + { + case 0b0101: + return 0; + case 0b0000: + return __x._M_it - __y._M_it; + case 0b0001: + return __x._M_it - __y._M_sent; + case 0b0100: + return __x._M_sent - __y._M_it; + default: + __glibcxx_assert(__x._M_has_value()); + __glibcxx_assert(__y._M_has_value()); + __builtin_unreachable(); + } + } + + friend iter_rvalue_reference_t<_It> + iter_move(const common_iterator& __i) + noexcept(noexcept(ranges::iter_move(std::declval()))) + requires input_iterator<_It> + { + __glibcxx_assert(__i._M_index == 0); + return ranges::iter_move(__i._M_it); + } + + template _It2, typename _Sent2> + friend void + iter_swap(const common_iterator& __x, + const common_iterator<_It2, _Sent2>& __y) + noexcept(noexcept(ranges::iter_swap(std::declval(), + std::declval()))) + { + __glibcxx_assert(__x._M_index == 0); + __glibcxx_assert(__y._M_index == 0); + return ranges::iter_swap(__x._M_it, __y._M_it); + } + + private: + template _Sent2> + friend class common_iterator; + + bool _M_has_value() const noexcept { return _M_index < 2; } + + union + { + _It _M_it; + _Sent _M_sent; + unsigned char _M_valueless; + }; + unsigned char _M_index; // 0==_M_it, 1==_M_sent, 2==valueless + }; + + template + struct incrementable_traits> + { + using difference_type = iter_difference_t<_It>; + }; + + template + struct iterator_traits> + { + private: + template + struct __ptr + { + using type = void; + }; + + template + requires __detail::__common_iter_has_arrow<_Iter> + struct __ptr<_Iter> + { + using _CIter = common_iterator<_Iter, _Sent>; + using type = decltype(std::declval().operator->()); + }; + + static auto + _S_iter_cat() + { + using _Traits = iterator_traits<_It>; + if constexpr (requires { requires derived_from; }) + return forward_iterator_tag{}; + else + return input_iterator_tag{}; + } + + public: + using iterator_concept = conditional_t, + forward_iterator_tag, input_iterator_tag>; + using iterator_category = decltype(_S_iter_cat()); + using value_type = iter_value_t<_It>; + using difference_type = iter_difference_t<_It>; + using pointer = typename __ptr<_It>::type; + using reference = iter_reference_t<_It>; + }; + + // [iterators.counted] Counted iterators + + namespace __detail + { + template + struct __counted_iter_value_type + { }; + + template + struct __counted_iter_value_type<_It> + { using value_type = iter_value_t<_It>; }; + + template + struct __counted_iter_concept + { }; + + template + requires requires { typename _It::iterator_concept; } + struct __counted_iter_concept<_It> + { using iterator_concept = typename _It::iterator_concept; }; + + template + struct __counted_iter_cat + { }; + + template + requires requires { typename _It::iterator_category; } + struct __counted_iter_cat<_It> + { using iterator_category = typename _It::iterator_category; }; + } + + /// An iterator adaptor that keeps track of the distance to the end. + template + class counted_iterator + : public __detail::__counted_iter_value_type<_It>, + public __detail::__counted_iter_concept<_It>, + public __detail::__counted_iter_cat<_It> + { + public: + using iterator_type = _It; + // value_type defined in __counted_iter_value_type + using difference_type = iter_difference_t<_It>; + // iterator_concept defined in __counted_iter_concept + // iterator_category defined in __counted_iter_cat + + constexpr counted_iterator() = default; + + constexpr + counted_iterator(_It __i, iter_difference_t<_It> __n) + : _M_current(std::move(__i)), _M_length(__n) + { __glibcxx_assert(__n >= 0); } + + template + requires convertible_to + constexpr + counted_iterator(const counted_iterator<_It2>& __x) + : _M_current(__x._M_current), _M_length(__x._M_length) + { } + + template + requires assignable_from<_It&, const _It2&> + constexpr counted_iterator& + operator=(const counted_iterator<_It2>& __x) + { + _M_current = __x._M_current; + _M_length = __x._M_length; + return *this; + } + + constexpr const _It& + base() const & noexcept + { return _M_current; } + + constexpr _It + base() && + noexcept(is_nothrow_move_constructible_v<_It>) + { return std::move(_M_current); } + + constexpr iter_difference_t<_It> + count() const noexcept { return _M_length; } + + constexpr decltype(auto) + operator*() + noexcept(noexcept(*_M_current)) + { + __glibcxx_assert( _M_length > 0 ); + return *_M_current; + } + + constexpr decltype(auto) + operator*() const + noexcept(noexcept(*_M_current)) + requires __detail::__dereferenceable + { + __glibcxx_assert( _M_length > 0 ); + return *_M_current; + } + + constexpr auto + operator->() const noexcept + requires contiguous_iterator<_It> + { return std::to_address(_M_current); } + + constexpr counted_iterator& + operator++() + { + __glibcxx_assert(_M_length > 0); + ++_M_current; + --_M_length; + return *this; + } + + decltype(auto) + operator++(int) + { + __glibcxx_assert(_M_length > 0); + --_M_length; + __try + { + return _M_current++; + } __catch(...) { + ++_M_length; + __throw_exception_again; + } + + } + + constexpr counted_iterator + operator++(int) requires forward_iterator<_It> + { + auto __tmp = *this; + ++*this; + return __tmp; + } + + constexpr counted_iterator& + operator--() requires bidirectional_iterator<_It> + { + --_M_current; + ++_M_length; + return *this; + } + + constexpr counted_iterator + operator--(int) requires bidirectional_iterator<_It> + { + auto __tmp = *this; + --*this; + return __tmp; + } + + constexpr counted_iterator + operator+(iter_difference_t<_It> __n) const + requires random_access_iterator<_It> + { return counted_iterator(_M_current + __n, _M_length - __n); } + + friend constexpr counted_iterator + operator+(iter_difference_t<_It> __n, const counted_iterator& __x) + requires random_access_iterator<_It> + { return __x + __n; } + + constexpr counted_iterator& + operator+=(iter_difference_t<_It> __n) + requires random_access_iterator<_It> + { + __glibcxx_assert(__n <= _M_length); + _M_current += __n; + _M_length -= __n; + return *this; + } + + constexpr counted_iterator + operator-(iter_difference_t<_It> __n) const + requires random_access_iterator<_It> + { return counted_iterator(_M_current - __n, _M_length + __n); } + + template _It2> + friend constexpr iter_difference_t<_It2> + operator-(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __y._M_length - __x._M_length; } + + friend constexpr iter_difference_t<_It> + operator-(const counted_iterator& __x, default_sentinel_t) + { return -__x._M_length; } + + friend constexpr iter_difference_t<_It> + operator-(default_sentinel_t, const counted_iterator& __y) + { return __y._M_length; } + + constexpr counted_iterator& + operator-=(iter_difference_t<_It> __n) + requires random_access_iterator<_It> + { + __glibcxx_assert(-__n <= _M_length); + _M_current -= __n; + _M_length += __n; + return *this; + } + + constexpr decltype(auto) + operator[](iter_difference_t<_It> __n) const + noexcept(noexcept(_M_current[__n])) + requires random_access_iterator<_It> + { + __glibcxx_assert(__n < _M_length); + return _M_current[__n]; + } + + template _It2> + friend constexpr bool + operator==(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __x._M_length == __y._M_length; } + + friend constexpr bool + operator==(const counted_iterator& __x, default_sentinel_t) + { return __x._M_length == 0; } + + template _It2> + friend constexpr strong_ordering + operator<=>(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + { return __y._M_length <=> __x._M_length; } + + friend constexpr iter_rvalue_reference_t<_It> + iter_move(const counted_iterator& __i) + noexcept(noexcept(ranges::iter_move(__i._M_current))) + requires input_iterator<_It> + { + __glibcxx_assert( __i._M_length > 0 ); + return ranges::iter_move(__i._M_current); + } + + template _It2> + friend constexpr void + iter_swap(const counted_iterator& __x, + const counted_iterator<_It2>& __y) + noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) + { + __glibcxx_assert( __x._M_length > 0 && __y._M_length > 0 ); + ranges::iter_swap(__x._M_current, __y._M_current); + } + + private: + template friend class counted_iterator; + + _It _M_current = _It(); + iter_difference_t<_It> _M_length = 0; + }; + + template + requires same_as<__detail::__iter_traits<_It>, iterator_traits<_It>> + struct iterator_traits> : iterator_traits<_It> + { + using pointer = conditional_t, + add_pointer_t>, + void>; + }; +#endif // C++20 + + /// @} group iterators + + template + auto + __niter_base(move_iterator<_Iterator> __it) + -> decltype(make_move_iterator(__niter_base(__it.base()))) + { return make_move_iterator(__niter_base(__it.base())); } + + template + struct __is_move_iterator > + { + enum { __value = 1 }; + typedef __true_type __type; + }; + + template + auto + __miter_base(move_iterator<_Iterator> __it) + -> decltype(__miter_base(__it.base())) + { return __miter_base(__it.base()); } + +#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter) +#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \ + std::__make_move_if_noexcept_iterator(_Iter) +#else +#define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter) +#define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) +#endif // C++11 + +#if __cpp_deduction_guides >= 201606 + // These helper traits are used for deduction guides + // of associative containers. + template + using __iter_key_t = remove_const_t< + typename iterator_traits<_InputIterator>::value_type::first_type>; + + template + using __iter_val_t = + typename iterator_traits<_InputIterator>::value_type::second_type; + + template + struct pair; + + template + using __iter_to_alloc_t = + pair>, + __iter_val_t<_InputIterator>>; +#endif // __cpp_deduction_guides + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator_base_funcs.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator_base_funcs.h new file mode 100755 index 0000000..fa8474f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator_base_funcs.h @@ -0,0 +1,239 @@ +// Functions used by iterators -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_iterator_base_funcs.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + * + * This file contains all of the general iterator-related utility + * functions, such as distance() and advance(). + */ + +#ifndef _STL_ITERATOR_BASE_FUNCS_H +#define _STL_ITERATOR_BASE_FUNCS_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + // Forward declaration for the overloads of __distance. + template struct _List_iterator; + template struct _List_const_iterator; +_GLIBCXX_END_NAMESPACE_CONTAINER + + template + inline _GLIBCXX14_CONSTEXPR + typename iterator_traits<_InputIterator>::difference_type + __distance(_InputIterator __first, _InputIterator __last, + input_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + + typename iterator_traits<_InputIterator>::difference_type __n = 0; + while (__first != __last) + { + ++__first; + ++__n; + } + return __n; + } + + template + inline _GLIBCXX14_CONSTEXPR + typename iterator_traits<_RandomAccessIterator>::difference_type + __distance(_RandomAccessIterator __first, _RandomAccessIterator __last, + random_access_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + return __last - __first; + } + +#if _GLIBCXX_USE_CXX11_ABI + // Forward declaration because of the qualified call in distance. + template + ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_iterator<_Tp>, + _GLIBCXX_STD_C::_List_iterator<_Tp>, + input_iterator_tag); + + template + ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>, + _GLIBCXX_STD_C::_List_const_iterator<_Tp>, + input_iterator_tag); +#endif + + /** + * @brief A generalization of pointer arithmetic. + * @param __first An input iterator. + * @param __last An input iterator. + * @return The distance between them. + * + * Returns @c n such that __first + n == __last. This requires + * that @p __last must be reachable from @p __first. Note that @c + * n may be negative. + * + * For random access iterators, this uses their @c + and @c - operations + * and are constant time. For other %iterator classes they are linear time. + */ + template + inline _GLIBCXX17_CONSTEXPR + typename iterator_traits<_InputIterator>::difference_type + distance(_InputIterator __first, _InputIterator __last) + { + // concept requirements -- taken care of in __distance + return std::__distance(__first, __last, + std::__iterator_category(__first)); + } + + template + inline _GLIBCXX14_CONSTEXPR void + __advance(_InputIterator& __i, _Distance __n, input_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_assert(__n >= 0); + while (__n--) + ++__i; + } + + template + inline _GLIBCXX14_CONSTEXPR void + __advance(_BidirectionalIterator& __i, _Distance __n, + bidirectional_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + if (__n > 0) + while (__n--) + ++__i; + else + while (__n++) + --__i; + } + + template + inline _GLIBCXX14_CONSTEXPR void + __advance(_RandomAccessIterator& __i, _Distance __n, + random_access_iterator_tag) + { + // concept requirements + __glibcxx_function_requires(_RandomAccessIteratorConcept< + _RandomAccessIterator>) + if (__builtin_constant_p(__n) && __n == 1) + ++__i; + else if (__builtin_constant_p(__n) && __n == -1) + --__i; + else + __i += __n; + } + + /** + * @brief A generalization of pointer arithmetic. + * @param __i An input iterator. + * @param __n The @a delta by which to change @p __i. + * @return Nothing. + * + * This increments @p i by @p n. For bidirectional and random access + * iterators, @p __n may be negative, in which case @p __i is decremented. + * + * For random access iterators, this uses their @c + and @c - operations + * and are constant time. For other %iterator classes they are linear time. + */ + template + inline _GLIBCXX17_CONSTEXPR void + advance(_InputIterator& __i, _Distance __n) + { + // concept requirements -- taken care of in __advance + typename iterator_traits<_InputIterator>::difference_type __d = __n; + std::__advance(__i, __d, std::__iterator_category(__i)); + } + +#if __cplusplus >= 201103L + + template + inline _GLIBCXX17_CONSTEXPR _InputIterator + next(_InputIterator __x, typename + iterator_traits<_InputIterator>::difference_type __n = 1) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + std::advance(__x, __n); + return __x; + } + + template + inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator + prev(_BidirectionalIterator __x, typename + iterator_traits<_BidirectionalIterator>::difference_type __n = 1) + { + // concept requirements + __glibcxx_function_requires(_BidirectionalIteratorConcept< + _BidirectionalIterator>) + std::advance(__x, -__n); + return __x; + } + +#endif // C++11 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_ITERATOR_BASE_FUNCS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator_base_types.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator_base_types.h new file mode 100755 index 0000000..71cf41f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_iterator_base_types.h @@ -0,0 +1,271 @@ +// Types used in iterator implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996-1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_iterator_base_types.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + * + * This file contains all of the general iterator-related utility types, + * such as iterator_traits and struct iterator. + */ + +#ifndef _STL_ITERATOR_BASE_TYPES_H +#define _STL_ITERATOR_BASE_TYPES_H 1 + +#pragma GCC system_header + +#include + +#if __cplusplus >= 201103L +# include // For __void_t, is_convertible +#endif + +#if __cplusplus > 201703L && __cpp_concepts >= 201907L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup iterators Iterators + * Abstractions for uniform iterating through various underlying types. + */ + ///@{ + + /** + * @defgroup iterator_tags Iterator Tags + * These are empty types, used to distinguish different iterators. The + * distinction is not made by what they contain, but simply by what they + * are. Different underlying algorithms can then be used based on the + * different operations supported by different iterator types. + */ + ///@{ + /// Marking input iterators. + struct input_iterator_tag { }; + + /// Marking output iterators. + struct output_iterator_tag { }; + + /// Forward iterators support a superset of input iterator operations. + struct forward_iterator_tag : public input_iterator_tag { }; + + /// Bidirectional iterators support a superset of forward iterator + /// operations. + struct bidirectional_iterator_tag : public forward_iterator_tag { }; + + /// Random-access iterators support a superset of bidirectional + /// iterator operations. + struct random_access_iterator_tag : public bidirectional_iterator_tag { }; + +#if __cplusplus > 201703L + /// Contiguous iterators point to objects stored contiguously in memory. + struct contiguous_iterator_tag : public random_access_iterator_tag { }; +#endif + ///@} + + /** + * @brief Common %iterator class. + * + * This class does nothing but define nested typedefs. %Iterator classes + * can inherit from this class to save some work. The typedefs are then + * used in specializations and overloading. + * + * In particular, there are no default implementations of requirements + * such as @c operator++ and the like. (How could there be?) + */ + template + struct iterator + { + /// One of the @link iterator_tags tag types@endlink. + typedef _Category iterator_category; + /// The type "pointed to" by the iterator. + typedef _Tp value_type; + /// Distance between iterators is represented as this type. + typedef _Distance difference_type; + /// This type represents a pointer-to-value_type. + typedef _Pointer pointer; + /// This type represents a reference-to-value_type. + typedef _Reference reference; + }; + + /** + * @brief Traits class for iterators. + * + * This class does nothing but define nested typedefs. The general + * version simply @a forwards the nested typedefs from the Iterator + * argument. Specialized versions for pointers and pointers-to-const + * provide tighter, more correct semantics. + */ + template + struct iterator_traits; + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2408. SFINAE-friendly common_type/iterator_traits is missing in C++14 + template> + struct __iterator_traits { }; + +#if ! __cpp_lib_concepts + + template + struct __iterator_traits<_Iterator, + __void_t> + { + typedef typename _Iterator::iterator_category iterator_category; + typedef typename _Iterator::value_type value_type; + typedef typename _Iterator::difference_type difference_type; + typedef typename _Iterator::pointer pointer; + typedef typename _Iterator::reference reference; + }; +#endif // ! concepts + + template + struct iterator_traits + : public __iterator_traits<_Iterator> { }; + +#else // ! C++11 + template + struct iterator_traits + { + typedef typename _Iterator::iterator_category iterator_category; + typedef typename _Iterator::value_type value_type; + typedef typename _Iterator::difference_type difference_type; + typedef typename _Iterator::pointer pointer; + typedef typename _Iterator::reference reference; + }; +#endif // C++11 + +#if __cplusplus > 201703L + /// Partial specialization for object pointer types. + template +#if __cpp_concepts >= 201907L + requires is_object_v<_Tp> +#endif + struct iterator_traits<_Tp*> + { + using iterator_concept = contiguous_iterator_tag; + using iterator_category = random_access_iterator_tag; + using value_type = remove_cv_t<_Tp>; + using difference_type = ptrdiff_t; + using pointer = _Tp*; + using reference = _Tp&; + }; +#else + /// Partial specialization for pointer types. + template + struct iterator_traits<_Tp*> + { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef _Tp& reference; + }; + + /// Partial specialization for const pointer types. + template + struct iterator_traits + { + typedef random_access_iterator_tag iterator_category; + typedef _Tp value_type; + typedef ptrdiff_t difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + }; +#endif + + /** + * This function is not a part of the C++ standard but is syntactic + * sugar for internal library use only. + */ + template + inline _GLIBCXX_CONSTEXPR + typename iterator_traits<_Iter>::iterator_category + __iterator_category(const _Iter&) + { return typename iterator_traits<_Iter>::iterator_category(); } + + ///@} + +#if __cplusplus >= 201103L + template + using __iterator_category_t + = typename iterator_traits<_Iter>::iterator_category; + + template + using _RequireInputIter = + __enable_if_t, + input_iterator_tag>::value>; + + template> + struct __is_random_access_iter + : is_base_of + { + typedef is_base_of _Base; + enum { __value = _Base::value }; + }; +#else + template, + typename _Cat = typename _Traits::iterator_category> + struct __is_random_access_iter + { enum { __value = __is_base_of(random_access_iterator_tag, _Cat) }; }; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_ITERATOR_BASE_TYPES_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_list.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_list.h new file mode 100755 index 0000000..dbe05a9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_list.h @@ -0,0 +1,2127 @@ +// List implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_list.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{list} + */ + +#ifndef _STL_LIST_H +#define _STL_LIST_H 1 + +#include +#include +#if __cplusplus >= 201103L +#include +#include +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail + { + // Supporting structures are split into common and templated + // types; the latter publicly inherits from the former in an + // effort to reduce code duplication. This results in some + // "needless" static_cast'ing later on, but it's all safe + // downcasting. + + /// Common part of a node in the %list. + struct _List_node_base + { + _List_node_base* _M_next; + _List_node_base* _M_prev; + + static void + swap(_List_node_base& __x, _List_node_base& __y) _GLIBCXX_USE_NOEXCEPT; + + void + _M_transfer(_List_node_base* const __first, + _List_node_base* const __last) _GLIBCXX_USE_NOEXCEPT; + + void + _M_reverse() _GLIBCXX_USE_NOEXCEPT; + + void + _M_hook(_List_node_base* const __position) _GLIBCXX_USE_NOEXCEPT; + + void + _M_unhook() _GLIBCXX_USE_NOEXCEPT; + }; + + /// The %list node header. + struct _List_node_header : public _List_node_base + { +#if _GLIBCXX_USE_CXX11_ABI + std::size_t _M_size; +#endif + + _List_node_header() _GLIBCXX_NOEXCEPT + { _M_init(); } + +#if __cplusplus >= 201103L + _List_node_header(_List_node_header&& __x) noexcept + : _List_node_base{ __x._M_next, __x._M_prev } +# if _GLIBCXX_USE_CXX11_ABI + , _M_size(__x._M_size) +# endif + { + if (__x._M_base()->_M_next == __x._M_base()) + this->_M_next = this->_M_prev = this; + else + { + this->_M_next->_M_prev = this->_M_prev->_M_next = this->_M_base(); + __x._M_init(); + } + } + + void + _M_move_nodes(_List_node_header&& __x) + { + _List_node_base* const __xnode = __x._M_base(); + if (__xnode->_M_next == __xnode) + _M_init(); + else + { + _List_node_base* const __node = this->_M_base(); + __node->_M_next = __xnode->_M_next; + __node->_M_prev = __xnode->_M_prev; + __node->_M_next->_M_prev = __node->_M_prev->_M_next = __node; +# if _GLIBCXX_USE_CXX11_ABI + _M_size = __x._M_size; +# endif + __x._M_init(); + } + } +#endif + + void + _M_init() _GLIBCXX_NOEXCEPT + { + this->_M_next = this->_M_prev = this; +#if _GLIBCXX_USE_CXX11_ABI + this->_M_size = 0; +#endif + } + + private: + _List_node_base* _M_base() { return this; } + }; + } // namespace detail + +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// An actual node in the %list. + template + struct _List_node : public __detail::_List_node_base + { +#if __cplusplus >= 201103L + __gnu_cxx::__aligned_membuf<_Tp> _M_storage; + _Tp* _M_valptr() { return _M_storage._M_ptr(); } + _Tp const* _M_valptr() const { return _M_storage._M_ptr(); } +#else + _Tp _M_data; + _Tp* _M_valptr() { return std::__addressof(_M_data); } + _Tp const* _M_valptr() const { return std::__addressof(_M_data); } +#endif + }; + + /** + * @brief A list::iterator. + * + * All the functions are op overloads. + */ + template + struct _List_iterator + { + typedef _List_iterator<_Tp> _Self; + typedef _List_node<_Tp> _Node; + + typedef ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + + _List_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _List_iterator(__detail::_List_node_base* __x) _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + _Self + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return *this; } + + // Must downcast from _List_node_base to _List_node to get to value. + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Node*>(_M_node)->_M_valptr(); } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Node*>(_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_next; + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_prev; + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_prev; + return __tmp; + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + // The only member points to the %list element. + __detail::_List_node_base* _M_node; + }; + + /** + * @brief A list::const_iterator. + * + * All the functions are op overloads. + */ + template + struct _List_const_iterator + { + typedef _List_const_iterator<_Tp> _Self; + typedef const _List_node<_Tp> _Node; + typedef _List_iterator<_Tp> iterator; + + typedef ptrdiff_t difference_type; + typedef std::bidirectional_iterator_tag iterator_category; + typedef _Tp value_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + + _List_const_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _List_const_iterator(const __detail::_List_node_base* __x) + _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + _List_const_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT + : _M_node(__x._M_node) { } + + iterator + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return iterator(const_cast<__detail::_List_node_base*>(_M_node)); } + + // Must downcast from List_node_base to _List_node to get to value. + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Node*>(_M_node)->_M_valptr(); } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Node*>(_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_next; + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_next; + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _M_node->_M_prev; + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _M_node->_M_prev; + return __tmp; + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if __cpp_impl_three_way_comparison < 201907L + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + // The only member points to the %list element. + const __detail::_List_node_base* _M_node; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + /// See bits/stl_deque.h's _Deque_base for an explanation. + template + class _List_base + { + protected: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tp_alloc_traits; + typedef typename _Tp_alloc_traits::template + rebind<_List_node<_Tp> >::other _Node_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits; + +#if !_GLIBCXX_INLINE_VERSION + static size_t + _S_distance(const __detail::_List_node_base* __first, + const __detail::_List_node_base* __last) + { + size_t __n = 0; + while (__first != __last) + { + __first = __first->_M_next; + ++__n; + } + return __n; + } +#endif + + struct _List_impl + : public _Node_alloc_type + { + __detail::_List_node_header _M_node; + + _List_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Node_alloc_type>::value) + : _Node_alloc_type() + { } + + _List_impl(const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _Node_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + _List_impl(_List_impl&&) = default; + + _List_impl(_Node_alloc_type&& __a, _List_impl&& __x) + : _Node_alloc_type(std::move(__a)), _M_node(std::move(__x._M_node)) + { } + + _List_impl(_Node_alloc_type&& __a) noexcept + : _Node_alloc_type(std::move(__a)) + { } +#endif + }; + + _List_impl _M_impl; + +#if _GLIBCXX_USE_CXX11_ABI + size_t _M_get_size() const { return _M_impl._M_node._M_size; } + + void _M_set_size(size_t __n) { _M_impl._M_node._M_size = __n; } + + void _M_inc_size(size_t __n) { _M_impl._M_node._M_size += __n; } + + void _M_dec_size(size_t __n) { _M_impl._M_node._M_size -= __n; } + +# if !_GLIBCXX_INLINE_VERSION + size_t + _M_distance(const __detail::_List_node_base* __first, + const __detail::_List_node_base* __last) const + { return _S_distance(__first, __last); } + + // return the stored size + size_t _M_node_count() const { return _M_get_size(); } +# endif +#else + // dummy implementations used when the size is not stored + size_t _M_get_size() const { return 0; } + void _M_set_size(size_t) { } + void _M_inc_size(size_t) { } + void _M_dec_size(size_t) { } + +# if !_GLIBCXX_INLINE_VERSION + size_t _M_distance(const void*, const void*) const { return 0; } + + // count the number of nodes + size_t _M_node_count() const + { + return _S_distance(_M_impl._M_node._M_next, + std::__addressof(_M_impl._M_node)); + } +# endif +#endif + + typename _Node_alloc_traits::pointer + _M_get_node() + { return _Node_alloc_traits::allocate(_M_impl, 1); } + + void + _M_put_node(typename _Node_alloc_traits::pointer __p) _GLIBCXX_NOEXCEPT + { _Node_alloc_traits::deallocate(_M_impl, __p, 1); } + + public: + typedef _Alloc allocator_type; + + _Node_alloc_type& + _M_get_Node_allocator() _GLIBCXX_NOEXCEPT + { return _M_impl; } + + const _Node_alloc_type& + _M_get_Node_allocator() const _GLIBCXX_NOEXCEPT + { return _M_impl; } + +#if __cplusplus >= 201103L + _List_base() = default; +#else + _List_base() { } +#endif + + _List_base(const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT + : _M_impl(__a) + { } + +#if __cplusplus >= 201103L + _List_base(_List_base&&) = default; + +# if !_GLIBCXX_INLINE_VERSION + _List_base(_List_base&& __x, _Node_alloc_type&& __a) + : _M_impl(std::move(__a)) + { + if (__x._M_get_Node_allocator() == _M_get_Node_allocator()) + _M_move_nodes(std::move(__x)); + // else caller must move individual elements. + } +# endif + + // Used when allocator is_always_equal. + _List_base(_Node_alloc_type&& __a, _List_base&& __x) + : _M_impl(std::move(__a), std::move(__x._M_impl)) + { } + + // Used when allocator !is_always_equal. + _List_base(_Node_alloc_type&& __a) + : _M_impl(std::move(__a)) + { } + + void + _M_move_nodes(_List_base&& __x) + { _M_impl._M_node._M_move_nodes(std::move(__x._M_impl._M_node)); } +#endif + + // This is what actually destroys the list. + ~_List_base() _GLIBCXX_NOEXCEPT + { _M_clear(); } + + void + _M_clear() _GLIBCXX_NOEXCEPT; + + void + _M_init() _GLIBCXX_NOEXCEPT + { this->_M_impl._M_node._M_init(); } + }; + + /** + * @brief A standard container with linear time access to elements, + * and fixed time insertion/deletion at any point in the sequence. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence, including the + * optional sequence requirements with the + * %exception of @c at and @c operator[]. + * + * This is a @e doubly @e linked %list. Traversal up and down the + * %list requires linear time, but adding and removing elements (or + * @e nodes) is done in constant time, regardless of where the + * change takes place. Unlike std::vector and std::deque, + * random-access iterators are not provided, so subscripting ( @c + * [] ) access is not allowed. For algorithms which only need + * sequential access, this lack makes no difference. + * + * Also unlike the other standard containers, std::list provides + * specialized algorithms %unique to linked lists, such as + * splicing, sorting, and in-place reversal. + * + * A couple points on memory allocation for list: + * + * First, we never actually allocate a Tp, we allocate + * List_node's and trust [20.1.5]/4 to DTRT. This is to ensure + * that after elements from %list are spliced into + * %list, destroying the memory of the second %list is a + * valid operation, i.e., Alloc1 giveth and Alloc2 taketh away. + * + * Second, a %list conceptually represented as + * @code + * A <---> B <---> C <---> D + * @endcode + * is actually circular; a link exists between A and D. The %list + * class holds (as its only data member) a private list::iterator + * pointing to @e D, not to @e A! To get to the head of the %list, + * we start at the tail and move forward by one. When this member + * iterator's next/previous pointers refer to itself, the %list is + * %empty. + */ + template > + class list : protected _List_base<_Tp, _Alloc> + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Tp>::value, + "std::list must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::list must have the same value_type as its allocator"); +# endif +#endif + + typedef _List_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef typename _Base::_Tp_alloc_traits _Tp_alloc_traits; + typedef typename _Base::_Node_alloc_type _Node_alloc_type; + typedef typename _Base::_Node_alloc_traits _Node_alloc_traits; + + public: + typedef _Tp value_type; + typedef typename _Tp_alloc_traits::pointer pointer; + typedef typename _Tp_alloc_traits::const_pointer const_pointer; + typedef typename _Tp_alloc_traits::reference reference; + typedef typename _Tp_alloc_traits::const_reference const_reference; + typedef _List_iterator<_Tp> iterator; + typedef _List_const_iterator<_Tp> const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + protected: + // Note that pointers-to-_Node's can be ctor-converted to + // iterator types. + typedef _List_node<_Tp> _Node; + + using _Base::_M_impl; + using _Base::_M_put_node; + using _Base::_M_get_node; + using _Base::_M_get_Node_allocator; + + /** + * @param __args An instance of user data. + * + * Allocates space for a new node and constructs a copy of + * @a __args in it. + */ +#if __cplusplus < 201103L + _Node* + _M_create_node(const value_type& __x) + { + _Node* __p = this->_M_get_node(); + __try + { + _Tp_alloc_type __alloc(_M_get_Node_allocator()); + __alloc.construct(__p->_M_valptr(), __x); + } + __catch(...) + { + _M_put_node(__p); + __throw_exception_again; + } + return __p; + } +#else + template + _Node* + _M_create_node(_Args&&... __args) + { + auto __p = this->_M_get_node(); + auto& __alloc = _M_get_Node_allocator(); + __allocated_ptr<_Node_alloc_type> __guard{__alloc, __p}; + _Node_alloc_traits::construct(__alloc, __p->_M_valptr(), + std::forward<_Args>(__args)...); + __guard = nullptr; + return __p; + } +#endif + +#if _GLIBCXX_USE_CXX11_ABI + static size_t + _S_distance(const_iterator __first, const_iterator __last) + { return std::distance(__first, __last); } + + // return the stored size + size_t + _M_node_count() const + { return this->_M_get_size(); } +#else + // dummy implementations used when the size is not stored + static size_t + _S_distance(const_iterator, const_iterator) + { return 0; } + + // count the number of nodes + size_t + _M_node_count() const + { return std::distance(begin(), end()); } +#endif + + public: + // [23.2.2.1] construct/copy/destroy + // (assign() and get_allocator() are also listed in this section) + + /** + * @brief Creates a %list with no elements. + */ +#if __cplusplus >= 201103L + list() = default; +#else + list() { } +#endif + + /** + * @brief Creates a %list with no elements. + * @param __a An allocator object. + */ + explicit + list(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _Base(_Node_alloc_type(__a)) { } + +#if __cplusplus >= 201103L + /** + * @brief Creates a %list with default constructed elements. + * @param __n The number of elements to initially create. + * @param __a An allocator object. + * + * This constructor fills the %list with @a __n default + * constructed elements. + */ + explicit + list(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_default_initialize(__n); } + + /** + * @brief Creates a %list with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator object. + * + * This constructor fills the %list with @a __n copies of @a __value. + */ + list(size_type __n, const value_type& __value, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_fill_initialize(__n, __value); } +#else + /** + * @brief Creates a %list with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator object. + * + * This constructor fills the %list with @a __n copies of @a __value. + */ + explicit + list(size_type __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_fill_initialize(__n, __value); } +#endif + + /** + * @brief %List copy constructor. + * @param __x A %list of identical element and allocator types. + * + * The newly-created %list uses a copy of the allocation object used + * by @a __x (unless the allocator traits dictate a different object). + */ + list(const list& __x) + : _Base(_Node_alloc_traits:: + _S_select_on_copy(__x._M_get_Node_allocator())) + { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } + +#if __cplusplus >= 201103L + /** + * @brief %List move constructor. + * + * The newly-created %list contains the exact contents of the moved + * instance. The contents of the moved instance are a valid, but + * unspecified %list. + */ + list(list&&) = default; + + /** + * @brief Builds a %list from an initializer_list + * @param __l An initializer_list of value_type. + * @param __a An allocator object. + * + * Create a %list consisting of copies of the elements in the + * initializer_list @a __l. This is linear in __l.size(). + */ + list(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); } + + list(const list& __x, const allocator_type& __a) + : _Base(_Node_alloc_type(__a)) + { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } + + private: + list(list&& __x, const allocator_type& __a, true_type) noexcept + : _Base(_Node_alloc_type(__a), std::move(__x)) + { } + + list(list&& __x, const allocator_type& __a, false_type) + : _Base(_Node_alloc_type(__a)) + { + if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator()) + this->_M_move_nodes(std::move(__x)); + else + insert(begin(), std::__make_move_if_noexcept_iterator(__x.begin()), + std::__make_move_if_noexcept_iterator(__x.end())); + } + + public: + list(list&& __x, const allocator_type& __a) + noexcept(_Node_alloc_traits::_S_always_equal()) + : list(std::move(__x), __a, + typename _Node_alloc_traits::is_always_equal{}) + { } +#endif + + /** + * @brief Builds a %list from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __a An allocator object. + * + * Create a %list consisting of copies of the elements from + * [@a __first,@a __last). This is linear in N (where N is + * distance(@a __first,@a __last)). + */ +#if __cplusplus >= 201103L + template> + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { _M_initialize_dispatch(__first, __last, __false_type()); } +#else + template + list(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(_Node_alloc_type(__a)) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * No explicit dtor needed as the _Base dtor takes care of + * things. The _Base dtor only erases the elements, and note + * that if the elements themselves are pointers, the pointed-to + * memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + ~list() = default; +#endif + + /** + * @brief %List assignment operator. + * @param __x A %list of identical element and allocator types. + * + * All the elements of @a __x are copied. + * + * Whether the allocator is copied depends on the allocator traits. + */ + list& + operator=(const list& __x); + +#if __cplusplus >= 201103L + /** + * @brief %List move assignment operator. + * @param __x A %list of identical element and allocator types. + * + * The contents of @a __x are moved into this %list (without copying). + * + * Afterwards @a __x is a valid, but unspecified %list + * + * Whether the allocator is moved depends on the allocator traits. + */ + list& + operator=(list&& __x) + noexcept(_Node_alloc_traits::_S_nothrow_move()) + { + constexpr bool __move_storage = + _Node_alloc_traits::_S_propagate_on_move_assign() + || _Node_alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); + return *this; + } + + /** + * @brief %List initializer list assignment operator. + * @param __l An initializer_list of value_type. + * + * Replace the contents of the %list with copies of the elements + * in the initializer_list @a __l. This is linear in l.size(). + */ + list& + operator=(initializer_list __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } +#endif + + /** + * @brief Assigns a given value to a %list. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %list with @a __n copies of the given + * value. Note that the assignment completely changes the %list + * and that the resulting %list's size is the same as the number + * of elements assigned. + */ + void + assign(size_type __n, const value_type& __val) + { _M_fill_assign(__n, __val); } + + /** + * @brief Assigns a range to a %list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %list with copies of the elements in the + * range [@a __first,@a __last). + * + * Note that the assignment completely changes the %list and + * that the resulting %list's size is the same as the number of + * elements assigned. + */ +#if __cplusplus >= 201103L + template> + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_dispatch(__first, __last, __false_type()); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Assigns an initializer_list to a %list. + * @param __l An initializer_list of value_type. + * + * Replace the contents of the %list with copies of the elements + * in the initializer_list @a __l. This is linear in __l.size(). + */ + void + assign(initializer_list __l) + { this->_M_assign_dispatch(__l.begin(), __l.end(), __false_type()); } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_Base::_M_get_Node_allocator()); } + + // iterators + /** + * Returns a read/write iterator that points to the first element in the + * %list. Iteration is done in ordinary element order. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_node._M_next); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %list. Iteration is done in ordinary + * element order. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_node._M_next); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %list. Iteration is done in ordinary element + * order. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(&this->_M_impl._M_node); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %list. Iteration is done in ordinary + * element order. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(&this->_M_impl._M_node); } + + /** + * Returns a read/write reverse iterator that points to the last + * element in the %list. Iteration is done in reverse element + * order. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points to + * the last element in the %list. Iteration is done in reverse + * element order. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + /** + * Returns a read/write reverse iterator that points to one + * before the first element in the %list. Iteration is done in + * reverse element order. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first element in the %list. Iteration is done in reverse + * element order. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %list. Iteration is done in ordinary + * element order. + */ + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_node._M_next); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %list. Iteration is done in ordinary + * element order. + */ + const_iterator + cend() const noexcept + { return const_iterator(&this->_M_impl._M_node); } + + /** + * Returns a read-only (constant) reverse iterator that points to + * the last element in the %list. Iteration is done in reverse + * element order. + */ + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first element in the %list. Iteration is done in reverse + * element order. + */ + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // [23.2.2.2] capacity + /** + * Returns true if the %list is empty. (Thus begin() would equal + * end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; } + + /** Returns the number of elements in the %list. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_node_count(); } + + /** Returns the size() of the largest possible %list. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _Node_alloc_traits::max_size(_M_get_Node_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief Resizes the %list to the specified number of elements. + * @param __new_size Number of elements the %list should contain. + * + * This function will %resize the %list to the specified number + * of elements. If the number is smaller than the %list's + * current size the %list is truncated, otherwise default + * constructed elements are appended. + */ + void + resize(size_type __new_size); + + /** + * @brief Resizes the %list to the specified number of elements. + * @param __new_size Number of elements the %list should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %list to the specified number + * of elements. If the number is smaller than the %list's + * current size the %list is truncated, otherwise the %list is + * extended and new elements are populated with given data. + */ + void + resize(size_type __new_size, const value_type& __x); +#else + /** + * @brief Resizes the %list to the specified number of elements. + * @param __new_size Number of elements the %list should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %list to the specified number + * of elements. If the number is smaller than the %list's + * current size the %list is truncated, otherwise the %list is + * extended and new elements are populated with given data. + */ + void + resize(size_type __new_size, value_type __x = value_type()); +#endif + + // element access + /** + * Returns a read/write reference to the data at the first + * element of the %list. + */ + reference + front() _GLIBCXX_NOEXCEPT + { return *begin(); } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %list. + */ + const_reference + front() const _GLIBCXX_NOEXCEPT + { return *begin(); } + + /** + * Returns a read/write reference to the data at the last element + * of the %list. + */ + reference + back() _GLIBCXX_NOEXCEPT + { + iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + /** + * Returns a read-only (constant) reference to the data at the last + * element of the %list. + */ + const_reference + back() const _GLIBCXX_NOEXCEPT + { + const_iterator __tmp = end(); + --__tmp; + return *__tmp; + } + + // [23.2.2.3] modifiers + /** + * @brief Add data to the front of the %list. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the front of the %list and assigns the given data + * to it. Due to the nature of a %list this operation can be + * done in constant time, and does not invalidate iterators and + * references. + */ + void + push_front(const value_type& __x) + { this->_M_insert(begin(), __x); } + +#if __cplusplus >= 201103L + void + push_front(value_type&& __x) + { this->_M_insert(begin(), std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args) + { + this->_M_insert(begin(), std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return front(); +#endif + } +#endif + + /** + * @brief Removes first element. + * + * This is a typical stack operation. It shrinks the %list by + * one. Due to the nature of a %list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. + * + * Note that no data is returned, and if the first element's data + * is needed, it should be retrieved before pop_front() is + * called. + */ + void + pop_front() _GLIBCXX_NOEXCEPT + { this->_M_erase(begin()); } + + /** + * @brief Add data to the end of the %list. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the end of the %list and assigns the given data to + * it. Due to the nature of a %list this operation can be done + * in constant time, and does not invalidate iterators and + * references. + */ + void + push_back(const value_type& __x) + { this->_M_insert(end(), __x); } + +#if __cplusplus >= 201103L + void + push_back(value_type&& __x) + { this->_M_insert(end(), std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + this->_M_insert(end(), std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + + /** + * @brief Removes last element. + * + * This is a typical stack operation. It shrinks the %list by + * one. Due to the nature of a %list this operation can be done + * in constant time, and only invalidates iterators/references to + * the element being removed. + * + * Note that no data is returned, and if the last element's data + * is needed, it should be retrieved before pop_back() is called. + */ + void + pop_back() _GLIBCXX_NOEXCEPT + { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); } + +#if __cplusplus >= 201103L + /** + * @brief Constructs object in %list before specified iterator. + * @param __position A const_iterator into the %list. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) before the specified + * location. Due to the nature of a %list this operation can + * be done in constant time, and does not invalidate iterators + * and references. + */ + template + iterator + emplace(const_iterator __position, _Args&&... __args); + + /** + * @brief Inserts given value into %list before specified iterator. + * @param __position A const_iterator into the %list. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else + /** + * @brief Inserts given value into %list before specified iterator. + * @param __position An iterator into the %list. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(iterator __position, const value_type& __x); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts given rvalue into %list before specified iterator. + * @param __position A const_iterator into the %list. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given rvalue before + * the specified location. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(const_iterator __position, value_type&& __x) + { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts the contents of an initializer_list into %list + * before specified const_iterator. + * @param __p A const_iterator into the %list. + * @param __l An initializer_list of value_type. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert copies of the data in the + * initializer_list @a l into the %list before the location + * specified by @a p. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert(const_iterator __p, initializer_list __l) + { return this->insert(__p, __l.begin(), __l.end()); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a number of copies of given data into the %list. + * @param __position A const_iterator into the %list. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert a specified number of copies of the + * given data before the location specified by @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert(const_iterator __position, size_type __n, const value_type& __x); +#else + /** + * @brief Inserts a number of copies of given data into the %list. + * @param __position An iterator into the %list. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * + * This function will insert a specified number of copies of the + * given data before the location specified by @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + void + insert(iterator __position, size_type __n, const value_type& __x) + { + list __tmp(__n, __x, get_allocator()); + splice(__position, __tmp); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a range into the %list. + * @param __position A const_iterator into the %list. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert copies of the data in the range [@a + * first,@a last) into the %list before the location specified by + * @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last); +#else + /** + * @brief Inserts a range into the %list. + * @param __position An iterator into the %list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range [@a + * first,@a last) into the %list before the location specified by + * @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + list __tmp(__first, __last, get_allocator()); + splice(__position, __tmp); + } +#endif + + /** + * @brief Remove element at given position. + * @param __position Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and thus + * shorten the %list by one. + * + * Due to the nature of a %list this operation can be done in + * constant time, and only invalidates iterators/references to + * the element being removed. The user is also cautioned that + * this function only erases the element, and that if the element + * is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) noexcept; +#else + erase(iterator __position); +#endif + + /** + * @brief Remove a range of elements. + * @param __first Iterator pointing to the first element to be erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a last + * prior to erasing (or end()). + * + * This function will erase the elements in the range @a + * [first,last) and shorten the %list accordingly. + * + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) noexcept +#else + erase(iterator __first, iterator __last) +#endif + { + while (__first != __last) + __first = erase(__first); + return __last._M_const_cast(); + } + + /** + * @brief Swaps data with another %list. + * @param __x A %list of the same element and allocator types. + * + * This exchanges the elements between two lists in constant + * time. Note that the global std::swap() function is + * specialized such that std::swap(l1,l2) will feed to this + * function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(list& __x) _GLIBCXX_NOEXCEPT + { + __detail::_List_node_base::swap(this->_M_impl._M_node, + __x._M_impl._M_node); + + size_t __xsize = __x._M_get_size(); + __x._M_set_size(this->_M_get_size()); + this->_M_set_size(__xsize); + + _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(), + __x._M_get_Node_allocator()); + } + + /** + * Erases all the elements. Note that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { + _Base::_M_clear(); + _Base::_M_init(); + } + + // [23.2.2.4] list operations + /** + * @brief Insert contents of another %list. + * @param __position Iterator referencing the element to insert before. + * @param __x Source list. + * + * The elements of @a __x are inserted in constant time in front of + * the element referenced by @a __position. @a __x becomes an empty + * list. + * + * Requires this != @a __x. + */ + void +#if __cplusplus >= 201103L + splice(const_iterator __position, list&& __x) noexcept +#else + splice(iterator __position, list& __x) +#endif + { + if (!__x.empty()) + { + _M_check_equal_allocators(__x); + + this->_M_transfer(__position._M_const_cast(), + __x.begin(), __x.end()); + + this->_M_inc_size(__x._M_get_size()); + __x._M_set_size(0); + } + } + +#if __cplusplus >= 201103L + void + splice(const_iterator __position, list& __x) noexcept + { splice(__position, std::move(__x)); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert element from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __i Const_iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(const_iterator __position, list&& __x, const_iterator __i) noexcept +#else + /** + * @brief Insert element from another %list. + * @param __position Iterator referencing the element to insert before. + * @param __x Source list. + * @param __i Iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(iterator __position, list& __x, iterator __i) +#endif + { + iterator __j = __i._M_const_cast(); + ++__j; + if (__position == __i || __position == __j) + return; + + if (this != std::__addressof(__x)) + _M_check_equal_allocators(__x); + + this->_M_transfer(__position._M_const_cast(), + __i._M_const_cast(), __j); + + this->_M_inc_size(1); + __x._M_dec_size(1); + } + +#if __cplusplus >= 201103L + /** + * @brief Insert element from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __i Const_iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(const_iterator __position, list& __x, const_iterator __i) noexcept + { splice(__position, std::move(__x), __i); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Insert range from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __first Const_iterator referencing the start of range in x. + * @param __last Const_iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(const_iterator __position, list&& __x, const_iterator __first, + const_iterator __last) noexcept +#else + /** + * @brief Insert range from another %list. + * @param __position Iterator referencing the element to insert before. + * @param __x Source list. + * @param __first Iterator referencing the start of range in x. + * @param __last Iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(iterator __position, list& __x, iterator __first, + iterator __last) +#endif + { + if (__first != __last) + { + if (this != std::__addressof(__x)) + _M_check_equal_allocators(__x); + + size_t __n = _S_distance(__first, __last); + this->_M_inc_size(__n); + __x._M_dec_size(__n); + + this->_M_transfer(__position._M_const_cast(), + __first._M_const_cast(), + __last._M_const_cast()); + } + } + +#if __cplusplus >= 201103L + /** + * @brief Insert range from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __first Const_iterator referencing the start of range in x. + * @param __last Const_iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(const_iterator __position, list& __x, const_iterator __first, + const_iterator __last) noexcept + { splice(__position, std::move(__x), __first, __last); } +#endif + + private: +#if __cplusplus > 201703L +# define __cpp_lib_list_remove_return_type 201806L + typedef size_type __remove_return_type; +# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \ + __attribute__((__abi_tag__("__cxx20"))) +#else + typedef void __remove_return_type; +# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG +#endif + public: + + /** + * @brief Remove all elements equal to value. + * @param __value The value to remove. + * + * Removes every element in the list equal to @a value. + * Remaining elements stay in list order. Note that this + * function only erases the elements, and that if the elements + * themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + remove(const _Tp& __value); + + /** + * @brief Remove all elements satisfying a predicate. + * @tparam _Predicate Unary predicate function or object. + * + * Removes every element in the list for which the predicate + * returns true. Remaining elements stay in list order. Note + * that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + template + __remove_return_type + remove_if(_Predicate); + + /** + * @brief Remove consecutive duplicate elements. + * + * For each consecutive set of elements with the same value, + * remove all but the first one. Remaining elements stay in + * list order. Note that this function only erases the + * elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + unique(); + + /** + * @brief Remove consecutive elements satisfying a predicate. + * @tparam _BinaryPredicate Binary predicate function or object. + * + * For each consecutive set of elements [first,last) that + * satisfy predicate(first,i) where i is an iterator in + * [first,last), remove all but the first one. Remaining + * elements stay in list order. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + template + __remove_return_type + unique(_BinaryPredicate); + +#undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + + /** + * @brief Merge sorted lists. + * @param __x Sorted list to merge. + * + * Assumes that both @a __x and this list are sorted according to + * operator<(). Merges elements of @a __x into this list in + * sorted order, leaving @a __x empty when complete. Elements in + * this list precede elements in @a __x that are equal. + */ +#if __cplusplus >= 201103L + void + merge(list&& __x); + + void + merge(list& __x) + { merge(std::move(__x)); } +#else + void + merge(list& __x); +#endif + + /** + * @brief Merge sorted lists according to comparison function. + * @tparam _StrictWeakOrdering Comparison function defining + * sort order. + * @param __x Sorted list to merge. + * @param __comp Comparison functor. + * + * Assumes that both @a __x and this list are sorted according to + * StrictWeakOrdering. Merges elements of @a __x into this list + * in sorted order, leaving @a __x empty when complete. Elements + * in this list precede elements in @a __x that are equivalent + * according to StrictWeakOrdering(). + */ +#if __cplusplus >= 201103L + template + void + merge(list&& __x, _StrictWeakOrdering __comp); + + template + void + merge(list& __x, _StrictWeakOrdering __comp) + { merge(std::move(__x), __comp); } +#else + template + void + merge(list& __x, _StrictWeakOrdering __comp); +#endif + + /** + * @brief Reverse the elements in list. + * + * Reverse the order of elements in the list in linear time. + */ + void + reverse() _GLIBCXX_NOEXCEPT + { this->_M_impl._M_node._M_reverse(); } + + /** + * @brief Sort the elements. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + void + sort(); + + /** + * @brief Sort the elements according to comparison function. + * + * Sorts the elements of this list in NlogN time. Equivalent + * elements remain in list order. + */ + template + void + sort(_StrictWeakOrdering); + + protected: + // Internal constructor functions follow. + + // Called by the range constructor to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) + { _M_fill_initialize(static_cast(__n), __x); } + + // Called by the range constructor to implement [23.1.1]/9 + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else + push_back(*__first); +#endif + } + + // Called by list(n,v,a), and the range constructor when it turns out + // to be the same thing. + void + _M_fill_initialize(size_type __n, const value_type& __x) + { + for (; __n; --__n) + push_back(__x); + } + +#if __cplusplus >= 201103L + // Called by list(n). + void + _M_default_initialize(size_type __n) + { + for (; __n; --__n) + emplace_back(); + } + + // Called by resize(sz). + void + _M_default_append(size_type __n); +#endif + + // Internal assign functions follow. + + // Called by the range assign to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + // Called by the range assign to implement [23.1.1]/9 + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type); + + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. + void + _M_fill_assign(size_type __n, const value_type& __val); + + + // Moves the elements from [first,last) before position. + void + _M_transfer(iterator __position, iterator __first, iterator __last) + { __position._M_node->_M_transfer(__first._M_node, __last._M_node); } + + // Inserts new element at position given and with value given. +#if __cplusplus < 201103L + void + _M_insert(iterator __position, const value_type& __x) + { + _Node* __tmp = _M_create_node(__x); + __tmp->_M_hook(__position._M_node); + this->_M_inc_size(1); + } +#else + template + void + _M_insert(iterator __position, _Args&&... __args) + { + _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...); + __tmp->_M_hook(__position._M_node); + this->_M_inc_size(1); + } +#endif + + // Erases element at position given. + void + _M_erase(iterator __position) _GLIBCXX_NOEXCEPT + { + this->_M_dec_size(1); + __position._M_node->_M_unhook(); + _Node* __n = static_cast<_Node*>(__position._M_node); +#if __cplusplus >= 201103L + _Node_alloc_traits::destroy(_M_get_Node_allocator(), __n->_M_valptr()); +#else + _Tp_alloc_type(_M_get_Node_allocator()).destroy(__n->_M_valptr()); +#endif + + _M_put_node(__n); + } + + // To implement the splice (and merge) bits of N1599. + void + _M_check_equal_allocators(list& __x) _GLIBCXX_NOEXCEPT + { + if (std::__alloc_neq:: + _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator())) + __builtin_abort(); + } + + // Used to implement resize. + const_iterator + _M_resize_pos(size_type& __new_size) const; + +#if __cplusplus >= 201103L + void + _M_move_assign(list&& __x, true_type) noexcept + { + this->clear(); + this->_M_move_nodes(std::move(__x)); + std::__alloc_on_move(this->_M_get_Node_allocator(), + __x._M_get_Node_allocator()); + } + + void + _M_move_assign(list&& __x, false_type) + { + if (__x._M_get_Node_allocator() == this->_M_get_Node_allocator()) + _M_move_assign(std::move(__x), true_type{}); + else + // The rvalue's allocator cannot be moved, or is not equal, + // so we need to individually move each element. + _M_assign_dispatch(std::make_move_iterator(__x.begin()), + std::make_move_iterator(__x.end()), + __false_type{}); + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> list<_ValT, _Allocator>; +#endif + +_GLIBCXX_END_NAMESPACE_CXX11 + + /** + * @brief List equality comparison. + * @param __x A %list. + * @param __y A %list of the same type as @a __x. + * @return True iff the size and elements of the lists are equal. + * + * This is an equivalence relation. It is linear in the size of + * the lists. Lists are considered equivalent if their sizes are + * equal, and if corresponding elements compare equal. + */ + template + inline bool + operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { +#if _GLIBCXX_USE_CXX11_ABI + if (__x.size() != __y.size()) + return false; +#endif + + typedef typename list<_Tp, _Alloc>::const_iterator const_iterator; + const_iterator __end1 = __x.end(); + const_iterator __end2 = __y.end(); + + const_iterator __i1 = __x.begin(); + const_iterator __i2 = __y.begin(); + while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) + { + ++__i1; + ++__i2; + } + return __i1 == __end1 && __i2 == __end2; + } + +#if __cpp_lib_three_way_comparison +/** + * @brief List ordering relation. + * @param __x A `list`. + * @param __y A `list` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Tp> + operator<=>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief List ordering relation. + * @param __x A %list. + * @param __y A %list of the same type as @a __x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * lists. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } + + /// Based on operator== + template + inline bool + operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::list::swap(). + template + inline void + swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if _GLIBCXX_USE_CXX11_ABI + + // Detect when distance is used to compute the size of the whole list. + template + inline ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_iterator<_Tp> __first, + _GLIBCXX_STD_C::_List_iterator<_Tp> __last, + input_iterator_tag __tag) + { + typedef _GLIBCXX_STD_C::_List_const_iterator<_Tp> _CIter; + return std::__distance(_CIter(__first), _CIter(__last), __tag); + } + + template + inline ptrdiff_t + __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp> __first, + _GLIBCXX_STD_C::_List_const_iterator<_Tp> __last, + input_iterator_tag) + { + typedef __detail::_List_node_header _Sentinel; + _GLIBCXX_STD_C::_List_const_iterator<_Tp> __beyond = __last; + ++__beyond; + const bool __whole = __first == __beyond; + if (__builtin_constant_p (__whole) && __whole) + return static_cast(__last._M_node)->_M_size; + + ptrdiff_t __n = 0; + while (__first != __last) + { + ++__first; + ++__n; + } + return __n; + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_LIST_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_map.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_map.h new file mode 100755 index 0000000..535dbeb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_map.h @@ -0,0 +1,1568 @@ +// Map implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_map.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{map} + */ + +#ifndef _STL_MAP_H +#define _STL_MAP_H 1 + +#include +#include +#if __cplusplus >= 201103L +#include +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class multimap; + + /** + * @brief A standard container made up of (key,value) pairs, which can be + * retrieved based on a key, in logarithmic time. + * + * @ingroup associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to + * allocator. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using unique keys). + * For a @c map the key_type is Key, the mapped_type is T, and the + * value_type is std::pair. + * + * Maps support bidirectional iterators. + * + * The private tree data is declared exactly the same way for map and + * multimap; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template , + typename _Alloc = std::allocator > > + class map + { + public: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + + private: +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::map must have the same value_type as its allocator"); +#endif +#endif + + public: + class value_compare + : public std::binary_function + { + friend class map<_Key, _Tp, _Compare, _Alloc>; + protected: + _Compare comp; + + value_compare(_Compare __c) + : comp(__c) { } + + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; + + private: + /// This turns a red-black tree into a [multi]map. + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other _Pair_alloc_type; + + typedef _Rb_tree, + key_compare, _Pair_alloc_type> _Rep_type; + + /// The actual tree structure. + _Rep_type _M_t; + + typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits; + + public: + // many of these are specified differently in ISO, but the following are + // "functionally equivalent" + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; + using insert_return_type = typename _Rep_type::insert_return_type; +#endif + + // [23.3.1.1] construct/copy/destroy + // (get_allocator() is also listed in this section) + + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + map() : _M_t() { } +#else + map() = default; +#endif + + /** + * @brief Creates a %map with no elements. + * @param __comp A comparison object. + * @param __a An allocator object. + */ + explicit + map(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) { } + + /** + * @brief %Map copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + map(const map& __x) + : _M_t(__x._M_t) { } +#else + map(const map&) = default; + + /** + * @brief %Map move constructor. + * + * The newly-created %map contains the exact contents of the moved + * instance. The moved instance is a valid, but unspecified, %map. + */ + map(map&&) = default; + + /** + * @brief Builds a %map from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison object. + * @param __a An allocator object. + * + * Create a %map consisting of copies of the elements in the + * initializer_list @a __l. + * This is linear in N if the range is already sorted, and NlogN + * otherwise (where N is @a __l.size()). + */ + map(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + map(const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + map(const map& __m, const allocator_type& __a) + : _M_t(__m._M_t, _Pair_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + map(map&& __m, const allocator_type& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + map(initializer_list __l, const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + map(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } +#endif + + /** + * @brief Builds a %map from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %map consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + map(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * @brief Builds a %map from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %map consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + map(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } + +#if __cplusplus >= 201103L + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~map() = default; +#endif + + /** + * @brief %Map assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + map& + operator=(const map& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + map& + operator=(const map&) = default; + + /// Move assignment operator. + map& + operator=(map&&) = default; + + /** + * @brief %Map list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %map with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %map and + * that the resulting %map's size is the same as the number + * of elements assigned. + */ + map& + operator=(initializer_list __l) + { + _M_t._M_assign_unique(__l.begin(), __l.end()); + return *this; + } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + // iterators + /** + * Returns a read/write iterator that points to the first pair in the + * %map. + * Iteration is done in ascending order according to the keys. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %map. Iteration is done in ascending order according to the + * keys. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read/write iterator that points one past the last + * pair in the %map. Iteration is done in ascending order + * according to the keys. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %map. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read/write reverse iterator that points to the last pair in + * the %map. Iteration is done in descending order according to the + * keys. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %map. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first pair in the %map. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %map. Iteration is done in descending + * order according to the keys. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %map. Iteration is done in ascending order according to the + * keys. + */ + const_iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %map. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %map. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %map. Iteration is done in descending + * order according to the keys. + */ + const_reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + // capacity + /** Returns true if the %map is empty. (Thus begin() would equal + * end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /** Returns the size of the %map. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /** Returns the maximum size of the %map. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + // [23.3.1.2] element access + /** + * @brief Subscript ( @c [] ) access to %map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data of the (key,data) %pair. + * + * Allows for easy lookup with the subscript ( @c [] ) + * operator. Returns data associated with the key specified in + * subscript. If the key does not exist, a pair with that key + * is created using default values, which is then returned. + * + * Lookup requires logarithmic time. + */ + mapped_type& + operator[](const key_type& __k) + { + // concept requirements + __glibcxx_function_requires(_DefaultConstructibleConcept) + + iterator __i = lower_bound(__k); + // __i->first is greater than or equivalent to __k. + if (__i == end() || key_comp()(__k, (*__i).first)) +#if __cplusplus >= 201103L + __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct, + std::tuple(__k), + std::tuple<>()); +#else + __i = insert(__i, value_type(__k, mapped_type())); +#endif + return (*__i).second; + } + +#if __cplusplus >= 201103L + mapped_type& + operator[](key_type&& __k) + { + // concept requirements + __glibcxx_function_requires(_DefaultConstructibleConcept) + + iterator __i = lower_bound(__k); + // __i->first is greater than or equivalent to __k. + if (__i == end() || key_comp()(__k, (*__i).first)) + __i = _M_t._M_emplace_hint_unique(__i, std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::tuple<>()); + return (*__i).second; + } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + /** + * @brief Access to %map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data whose key is equivalent to @a __k, if + * such a data is present in the %map. + * @throw std::out_of_range If no such data is present. + */ + mapped_type& + at(const key_type& __k) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + __throw_out_of_range(__N("map::at")); + return (*__i).second; + } + + const mapped_type& + at(const key_type& __k) const + { + const_iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + __throw_out_of_range(__N("map::at")); + return (*__i).second; + } + + // modifiers +#if __cplusplus >= 201103L + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * + * Insertion requires logarithmic time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_unique(__pos, + std::forward<_Args>(__args)...); + } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_unique(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus > 201402L +#define __cpp_lib_map_try_emplace 201411 + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __args Arguments used to generate the .second for a new pair + * instance. + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * If a %pair is not inserted, this function has no effect. + * + * Insertion requires logarithmic time. + */ + template + pair + try_emplace(const key_type& __k, _Args&&... __args) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + return {__i, true}; + } + return {__i, false}; + } + + // move-capable overload + template + pair + try_emplace(key_type&& __k, _Args&&... __args) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + return {__i, true}; + } + return {__i, false}; + } + + /** + * @brief Attempts to build and insert a std::pair into the %map. + * + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __args Arguments used to generate the .second for a new pair + * instance. + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument + * try_emplace() does. However, if insertion did not take place, + * this function has no effect. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + __i = emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + else + __i = iterator(__true_hint.first); + return __i; + } + + // move-capable overload + template + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + __i = emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Args>(__args)...)); + else + __i = iterator(__true_hint.first); + return __i; + } +#endif + + /** + * @brief Attempts to insert a std::pair into the %map. + * @param __x Pair to be inserted (see std::make_pair for easy + * creation of pairs). + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * + * Insertion requires logarithmic time. + * @{ + */ + std::pair + insert(const value_type& __x) + { return _M_t._M_insert_unique(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + std::pair + insert(value_type&& __x) + { return _M_t._M_insert_unique(std::move(__x)); } + + template + __enable_if_t::value, + pair> + insert(_Pair&& __x) + { return _M_t._M_emplace_unique(std::forward<_Pair>(__x)); } +#endif + /// @} + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of std::pairs into the %map. + * @param __list A std::initializer_list of pairs to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(std::initializer_list __list) + { insert(__list.begin(), __list.end()); } +#endif + + /** + * @brief Attempts to insert a std::pair into the %map. + * @param __position An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + + * This function is not concerned about whether the insertion + * took place, and thus does not return a boolean like the + * single-argument insert() does. Note that the first + * parameter is only a hint and can potentially improve the + * performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + * @{ + */ + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { return _M_t._M_insert_unique_(__position, __x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_unique_(__position, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __position, _Pair&& __x) + { + return _M_t._M_emplace_hint_unique(__position, + std::forward<_Pair>(__x)); + } +#endif + /// @} + + /** + * @brief Template function that attempts to insert a range of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_unique(__first, __last); } + +#if __cplusplus > 201402L + /** + * @brief Attempts to insert or assign a std::pair into the %map. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * If the %pair was already in the %map, the .second of the %pair + * is assigned from __obj. + * + * Insertion requires logarithmic time. + */ + template + pair + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + return {__i, true}; + } + (*__i).second = std::forward<_Obj>(__obj); + return {__i, false}; + } + + // move-capable overload + template + pair + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + iterator __i = lower_bound(__k); + if (__i == end() || key_comp()(__k, (*__i).first)) + { + __i = emplace_hint(__i, std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + return {__i, true}; + } + (*__i).second = std::forward<_Obj>(__obj); + return {__i, false}; + } + + /** + * @brief Attempts to insert or assign a std::pair into the %map. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * This function attempts to insert a (key, value) %pair into the %map. + * A %map relies on unique keys and thus a %pair is only inserted if its + * first element (the key) is not already present in the %map. + * If the %pair was already in the %map, the .second of the %pair + * is assigned from __obj. + * + * Insertion requires logarithmic time. + */ + template + iterator + insert_or_assign(const_iterator __hint, + const key_type& __k, _Obj&& __obj) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + { + return emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(__k), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + } + __i = iterator(__true_hint.first); + (*__i).second = std::forward<_Obj>(__obj); + return __i; + } + + // move-capable overload + template + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + iterator __i; + auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k); + if (__true_hint.second) + { + return emplace_hint(iterator(__true_hint.second), + std::piecewise_construct, + std::forward_as_tuple(std::move(__k)), + std::forward_as_tuple( + std::forward<_Obj>(__obj))); + } + __i = iterator(__true_hint.first); + (*__i).second = std::forward<_Obj>(__obj); + return __i; + } +#endif + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %map. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given + * iterator, from a %map. Note that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + * + * @{ + */ + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } + + // LWG 2059 + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { return _M_t.erase(__position); } + /// @} +#else + /** + * @brief Erases an element from a %map. + * @param __position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given + * iterator, from a %map. Note that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * a %map. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %map. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from a %map. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + /** + * @brief Erases a [__first,__last) range of elements from a %map. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * + * This function erases a sequence of elements from a %map. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * @brief Swaps data with another %map. + * @param __x A %map of the same element and allocator types. + * + * This exchanges the elements between two maps in constant + * time. (It is only swapping a pointer, an integer, and an + * instance of the @c Compare type (which itself is often + * stateless and empty), so it should be quite fast.) Note + * that the global std::swap() function is specialized such + * that std::swap(m1,m2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(map& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + /** + * Erases all elements in a %map. Note that this function only + * erases the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // observers + /** + * Returns the key comparison object out of which the %map was + * constructed. + */ + key_compare + key_comp() const + { return _M_t.key_comp(); } + + /** + * Returns a value comparison object, built from the key comparison + * object out of which the %map was constructed. + */ + value_compare + value_comp() const + { return value_compare(_M_t.key_comp()); } + + // [23.3.1.3] map operations + + ///@{ + /** + * @brief Tries to locate an element in a %map. + * @param __x Key of (key, value) %pair to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after %pair. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Tries to locate an element in a %map. + * @param __x Key of (key, value) %pair to be located. + * @return Read-only (constant) iterator pointing to sought-after + * element, or end() if not found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns a constant + * iterator pointing to the sought after %pair. If unsuccessful it + * returns the past-the-end ( @c end() ) iterator. + */ + + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements with given key. + * @param __x Key of (key, value) pairs to be located. + * @return Number of elements with specified key. + * + * This function only makes sense for multimaps; for map the result will + * either be 0 (not present) or 1 (present). + */ + size_type + count(const key_type& __x) const + { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of (key, value) pairs to be located. + * @return True if there is an element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first element + * equal to or greater than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first iterator + * greater than key, or end(). + */ + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multimaps. + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of read-only (constant) iterators that possibly points + * to the subsequence matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multimaps. + */ + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair( + _M_t._M_equal_range_tr(__x))) + { + return pair( + _M_t._M_equal_range_tr(__x)); + } +#endif + ///@} + + template + friend bool + operator==(const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t> + operator<=>(const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); +#else + template + friend bool + operator<(const map<_K1, _T1, _C1, _A1>&, + const map<_K1, _T1, _C1, _A1>&); +#endif + }; + + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + map(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<_Key, _Tp, _Compare, _Allocator>; + + template , + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, _Allocator) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + map(initializer_list>, _Allocator) + -> map<_Key, _Tp, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Map equality comparison. + * @param __x A %map. + * @param __y A %map of the same type as @a x. + * @return True iff the size and elements of the maps are equal. + * + * This is an equivalence relation. It is linear in the size of the + * maps. Maps are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + inline bool + operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Map ordering relation. + * @param __x A `map`. + * @param __y A `map` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t> + operator<=>(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Map ordering relation. + * @param __x A %map. + * @param __y A %map of the same type as @a x. + * @return True iff @a x is lexicographically less than @a y. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Based on operator== + template + inline bool + operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x, + const map<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::map::swap(). + template + inline void + swap(map<_Key, _Tp, _Compare, _Alloc>& __x, + map<_Key, _Tp, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::map access to internals of compatible maps. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_MAP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_multimap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_multimap.h new file mode 100755 index 0000000..8157981 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_multimap.h @@ -0,0 +1,1233 @@ +// Multimap implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_multimap.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{map} + */ + +#ifndef _STL_MULTIMAP_H +#define _STL_MULTIMAP_H 1 + +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class map; + + /** + * @brief A standard container made up of (key,value) pairs, which can be + * retrieved based on a key, in logarithmic time. + * + * @ingroup associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to + * allocator. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using equivalent + * keys). For a @c multimap the key_type is Key, the mapped_type + * is T, and the value_type is std::pair. + * + * Multimaps support bidirectional iterators. + * + * The private tree data is declared exactly the same way for map and + * multimap; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template , + typename _Alloc = std::allocator > > + class multimap + { + public: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + + private: +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L +#if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::multimap must have the same value_type as its allocator"); +#endif +#endif + + public: + class value_compare + : public std::binary_function + { + friend class multimap<_Key, _Tp, _Compare, _Alloc>; + protected: + _Compare comp; + + value_compare(_Compare __c) + : comp(__c) { } + + public: + bool operator()(const value_type& __x, const value_type& __y) const + { return comp(__x.first, __y.first); } + }; + + private: + /// This turns a red-black tree into a [multi]map. + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind::other _Pair_alloc_type; + + typedef _Rb_tree, + key_compare, _Pair_alloc_type> _Rep_type; + /// The actual tree structure. + _Rep_type _M_t; + + typedef __gnu_cxx::__alloc_traits<_Pair_alloc_type> _Alloc_traits; + + public: + // many of these are specified differently in ISO, but the following are + // "functionally equivalent" + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; +#endif + + // [23.3.2] construct/copy/destroy + // (get_allocator() is also listed in this section) + + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + multimap() : _M_t() { } +#else + multimap() = default; +#endif + + /** + * @brief Creates a %multimap with no elements. + * @param __comp A comparison object. + * @param __a An allocator object. + */ + explicit + multimap(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) { } + + /** + * @brief %Multimap copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multimap(const multimap& __x) + : _M_t(__x._M_t) { } +#else + multimap(const multimap&) = default; + + /** + * @brief %Multimap move constructor. + * + * The newly-created %multimap contains the exact contents of the + * moved instance. The moved instance is a valid, but unspecified + * %multimap. + */ + multimap(multimap&&) = default; + + /** + * @brief Builds a %multimap from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multimap consisting of copies of the elements from + * the initializer_list. This is linear in N if the list is already + * sorted, and NlogN otherwise (where N is @a __l.size()). + */ + multimap(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + multimap(const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + multimap(const multimap& __m, const allocator_type& __a) + : _M_t(__m._M_t, _Pair_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + multimap(multimap&& __m, const allocator_type& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + multimap(initializer_list __l, const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + multimap(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } +#endif + + /** + * @brief Builds a %multimap from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %multimap consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multimap(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * @brief Builds a %multimap from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multimap consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Pair_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } + +#if __cplusplus >= 201103L + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~multimap() = default; +#endif + + /** + * @brief %Multimap assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multimap& + operator=(const multimap& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + multimap& + operator=(const multimap&) = default; + + /// Move assignment operator. + multimap& + operator=(multimap&&) = default; + + /** + * @brief %Multimap list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %multimap with copies of the elements + * in the initializer list @a __l. + * + * Note that the assignment completely changes the %multimap and + * that the resulting %multimap's size is the same as the number + * of elements assigned. + */ + multimap& + operator=(initializer_list __l) + { + _M_t._M_assign_equal(__l.begin(), __l.end()); + return *this; + } +#endif + + /// Get a copy of the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + // iterators + /** + * Returns a read/write iterator that points to the first pair in the + * %multimap. Iteration is done in ascending order according to the + * keys. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %multimap. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read/write iterator that points one past the last pair in + * the %multimap. Iteration is done in ascending order according to the + * keys. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %multimap. Iteration is done in ascending order according + * to the keys. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read/write reverse iterator that points to the last pair in + * the %multimap. Iteration is done in descending order according to the + * keys. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %multimap. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read/write reverse iterator that points to one before the + * first pair in the %multimap. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %multimap. Iteration is done in + * descending order according to the keys. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first pair + * in the %multimap. Iteration is done in ascending order according to + * the keys. + */ + const_iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * pair in the %multimap. Iteration is done in ascending order according + * to the keys. + */ + const_iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %multimap. Iteration is done in descending order + * according to the keys. + */ + const_reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to one + * before the first pair in the %multimap. Iteration is done in + * descending order according to the keys. + */ + const_reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + // capacity + /** Returns true if the %multimap is empty. */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /** Returns the size of the %multimap. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /** Returns the maximum size of the %multimap. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + // modifiers +#if __cplusplus >= 201103L + /** + * @brief Build and insert a std::pair into the %multimap. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return An iterator that points to the inserted (key,value) pair. + * + * This function builds and inserts a (key, value) %pair into the + * %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * + * Insertion requires logarithmic time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); } + + /** + * @brief Builds and inserts a std::pair into the %multimap. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the inserted (key,value) pair. + * + * This function inserts a (key, value) pair into the %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_equal(__pos, + std::forward<_Args>(__args)...); + } +#endif + + /** + * @brief Inserts a std::pair into the %multimap. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the inserted (key,value) pair. + * + * This function inserts a (key, value) pair into the %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * + * Insertion requires logarithmic time. + * @{ + */ + iterator + insert(const value_type& __x) + { return _M_t._M_insert_equal(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(value_type&& __x) + { return _M_t._M_insert_equal(std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(_Pair&& __x) + { return _M_t._M_emplace_equal(std::forward<_Pair>(__x)); } +#endif + /// @} + + /** + * @brief Inserts a std::pair into the %multimap. + * @param __position An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the inserted (key,value) pair. + * + * This function inserts a (key, value) pair into the %multimap. + * Contrary to a std::map the %multimap does not rely on unique keys and + * thus multiple pairs with the same key can be inserted. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + * @{ + */ + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { return _M_t._M_insert_equal_(__position, __x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_equal_(__position, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __position, _Pair&& __x) + { + return _M_t._M_emplace_hint_equal(__position, + std::forward<_Pair>(__x)); + } +#endif + /// @} + + /** + * @brief A template function that attempts to insert a range + * of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_equal(__first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of std::pairs into the %multimap. + * @param __l A std::initializer_list of pairs to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_equal(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %multimap. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from a %multimap. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + * + * @{ + */ + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } + + // LWG 2059. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { return _M_t.erase(__position); } + /// @} +#else + /** + * @brief Erases an element from a %multimap. + * @param __position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given iterator, + * from a %multimap. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all elements located by the given key from a + * %multimap. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %multimap. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to be + * erased . + * @return The iterator @a __last. + * + * This function erases a sequence of elements from a %multimap. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %multimap. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * + * This function erases a sequence of elements from a %multimap. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * @brief Swaps data with another %multimap. + * @param __x A %multimap of the same element and allocator types. + * + * This exchanges the elements between two multimaps in constant time. + * (It is only swapping a pointer, an integer, and an instance of + * the @c Compare type (which itself is often stateless and empty), so it + * should be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(m1,m2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(multimap& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + /** + * Erases all elements in a %multimap. Note that this function only + * erases the elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // observers + /** + * Returns the key comparison object out of which the %multimap + * was constructed. + */ + key_compare + key_comp() const + { return _M_t.key_comp(); } + + /** + * Returns a value comparison object, built from the key comparison + * object out of which the %multimap was constructed. + */ + value_compare + value_comp() const + { return value_compare(_M_t.key_comp()); } + + // multimap operations + + ///@{ + /** + * @brief Tries to locate an element in a %multimap. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to sought-after element, + * or end() if not found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after %pair. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Tries to locate an element in a %multimap. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to sought-after + * element, or end() if not found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns a constant + * iterator pointing to the sought after %pair. If unsuccessful it + * returns the past-the-end ( @c end() ) iterator. + */ + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x)) + { return _M_t._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements with given key. + * @param __x Key of (key, value) pairs to be located. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_t.count(__x); } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of (key, value) pairs to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first element + * equal to or greater than key, or end(). + * + * This function returns the first element of a subsequence of + * elements that matches the given key. If unsuccessful the + * iterator will point to the next greatest element or, if no + * such greater element exists, to end(). + */ + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key of (key, value) pair to be located. + * @return Read-only (constant) iterator pointing to first iterator + * greater than key, or end(). + */ + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key of (key, value) pairs to be located. + * @return Pair of read-only (constant) iterators that possibly points + * to the subsequence matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + */ + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair( + _M_t._M_equal_range_tr(__x))) + { + return pair( + _M_t._M_equal_range_tr(__x)); + } +#endif + ///@} + + template + friend bool + operator==(const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t> + operator<=>(const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); +#else + template + friend bool + operator<(const multimap<_K1, _T1, _C1, _A1>&, + const multimap<_K1, _T1, _C1, _A1>&); +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multimap(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<_Key, _Tp, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, _Allocator) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + multimap(initializer_list>, _Allocator) + -> multimap<_Key, _Tp, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Multimap equality comparison. + * @param __x A %multimap. + * @param __y A %multimap of the same type as @a __x. + * @return True iff the size and elements of the maps are equal. + * + * This is an equivalence relation. It is linear in the size of the + * multimaps. Multimaps are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + inline bool + operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Multimap ordering relation. + * @param __x A `multimap`. + * @param __y A `multimap` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t> + operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Multimap ordering relation. + * @param __x A %multimap. + * @param __y A %multimap of the same type as @a __x. + * @return True iff @a x is lexicographically less than @a y. + * + * This is a total ordering relation. It is linear in the size of the + * multimaps. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Based on operator== + template + inline bool + operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, + const multimap<_Key, _Tp, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::multimap::swap(). + template + inline void + swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, + multimap<_Key, _Tp, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::multimap access to internals of compatible maps. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map) + { return __map._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_MULTIMAP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_multiset.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_multiset.h new file mode 100755 index 0000000..ef98760 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_multiset.h @@ -0,0 +1,1075 @@ +// Multiset implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_multiset.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{set} + */ + +#ifndef _STL_MULTISET_H +#define _STL_MULTISET_H 1 + +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class set; + + /** + * @brief A standard container made up of elements, which can be retrieved + * in logarithmic time. + * + * @ingroup associative_containers + * + * + * @tparam _Key Type of key objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using equivalent + * keys). For a @c multiset the key_type and value_type are Key. + * + * Multisets support bidirectional iterators. + * + * The private tree data is declared exactly the same way for set and + * multiset; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template , + typename _Alloc = std::allocator<_Key> > + class multiset + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Key, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Key>::value, + "std::multiset must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::multiset must have the same value_type as its allocator"); +# endif +#endif + + public: + // typedefs: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + typedef _Alloc allocator_type; + + private: + /// This turns a red-black tree into a [multi]set. + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; + /// The actual tree structure. + _Rep_type _M_t; + + typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits; + + public: + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 103. set::iterator is required to be modifiable, + // but this allows modification of keys. + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; +#endif + + // allocation/deallocation + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + multiset() : _M_t() { } +#else + multiset() = default; +#endif + + /** + * @brief Creates a %multiset with no elements. + * @param __comp Comparator to use. + * @param __a An allocator object. + */ + explicit + multiset(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) { } + + /** + * @brief Builds a %multiset from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %multiset consisting of copies of the elements from + * [first,last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multiset(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * @brief Builds a %multiset from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multiset consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is already sorted, + * and NlogN otherwise (where N is distance(__first,__last)). + */ + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * @brief %Multiset copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multiset(const multiset& __x) + : _M_t(__x._M_t) { } +#else + multiset(const multiset&) = default; + + /** + * @brief %Multiset move constructor. + * + * The newly-created %multiset contains the exact contents of the + * moved instance. The moved instance is a valid, but unspecified + * %multiset. + */ + multiset(multiset&&) = default; + + /** + * @brief Builds a %multiset from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %multiset consisting of copies of the elements from + * the list. This is linear in N if the list is already sorted, + * and NlogN otherwise (where N is @a __l.size()). + */ + multiset(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + multiset(const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + multiset(const multiset& __m, const allocator_type& __a) + : _M_t(__m._M_t, _Key_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + multiset(multiset&& __m, const allocator_type& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__m._M_t), _Key_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + multiset(initializer_list __l, const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + multiset(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_equal(__first, __last); } + + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~multiset() = default; +#endif + + /** + * @brief %Multiset assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + multiset& + operator=(const multiset& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + multiset& + operator=(const multiset&) = default; + + /// Move assignment operator. + multiset& + operator=(multiset&&) = default; + + /** + * @brief %Multiset list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %multiset with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %multiset and + * that the resulting %multiset's size is the same as the number + * of elements assigned. + */ + multiset& + operator=(initializer_list __l) + { + _M_t._M_assign_equal(__l.begin(), __l.end()); + return *this; + } +#endif + + // accessors: + + /// Returns the comparison object. + key_compare + key_comp() const + { return _M_t.key_comp(); } + /// Returns the comparison object. + value_compare + value_comp() const + { return _M_t.key_comp(); } + /// Returns the memory allocation object. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %multiset. Iteration is done in ascending order + * according to the keys. + */ + iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last element in the %multiset. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + /// Returns true if the %set is empty. + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /// Returns the size of the %set. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /// Returns the maximum size of the %set. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + /** + * @brief Swaps data with another %multiset. + * @param __x A %multiset of the same element and allocator types. + * + * This exchanges the elements between two multisets in constant time. + * (It is only swapping a pointer, an integer, and an instance of the @c + * Compare type (which itself is often stateless and empty), so it should + * be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(s1,s2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(multiset& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + // insert/erase +#if __cplusplus >= 201103L + /** + * @brief Builds and inserts an element into the %multiset. + * @param __args Arguments used to generate the element instance to be + * inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Insertion requires logarithmic time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); } + + /** + * @brief Builds and inserts an element into the %multiset. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element instance to be + * inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_equal(__pos, + std::forward<_Args>(__args)...); + } +#endif + + /** + * @brief Inserts an element into the %multiset. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Insertion requires logarithmic time. + */ + iterator + insert(const value_type& __x) + { return _M_t._M_insert_equal(__x); } + +#if __cplusplus >= 201103L + iterator + insert(value_type&& __x) + { return _M_t._M_insert_equal(std::move(__x)); } +#endif + + /** + * @brief Inserts an element into the %multiset. + * @param __position An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * This function inserts an element into the %multiset. Contrary + * to a std::set the %multiset does not rely on unique keys and thus + * multiple copies of the same element can be inserted. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + iterator + insert(const_iterator __position, const value_type& __x) + { return _M_t._M_insert_equal_(__position, __x); } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_equal_(__position, std::move(__x)); } +#endif + + /** + * @brief A template function that tries to insert a range of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_equal(__first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of elements into the %multiset. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_equal(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_equal(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(multiset<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multiset<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(set<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_equal(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(set<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %multiset. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from a %multiset. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } +#else + /** + * @brief Erases an element from a %multiset. + * @param __position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given iterator, + * from a %multiset. Note that this function only erases the element, + * and that if the element is itself a pointer, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all elements located by the given key from a + * %multiset. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [first,last) range of elements from a %multiset. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a last. + * + * This function erases a sequence of elements from a %multiset. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + /** + * @brief Erases a [first,last) range of elements from a %multiset. + * @param first Iterator pointing to the start of the range to be + * erased. + * @param last Iterator pointing to the end of the range to be erased. + * + * This function erases a sequence of elements from a %multiset. + * Note that this function only erases the elements, and that if + * the elements themselves are pointers, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * Erases all elements in a %multiset. Note that this function only + * erases the elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // multiset operations: + + ///@{ + /** + * @brief Finds the number of elements with given key. + * @param __x Key of elements to be located. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_t.count(__x); } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + ///@{ + /** + * @brief Tries to locate an element in a %set. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) + -> decltype(iterator{_M_t._M_find_tr(__x)}) + { return iterator{_M_t._M_find_tr(__x)}; } + + template + auto + find(const _Kt& __x) const + -> decltype(const_iterator{_M_t._M_find_tr(__x)}) + { return const_iterator{_M_t._M_find_tr(__x)}; } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } + + template + auto + lower_bound(const _Kt& __x) const + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } + + template + auto + upper_bound(const _Kt& __x) const + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multisets. + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } + + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + template + friend bool + operator==(const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t<_K1> + operator<=>(const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); +#else + template + friend bool + operator< (const multiset<_K1, _C1, _A1>&, + const multiset<_K1, _C1, _A1>&); +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multiset(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, _Allocator) + -> multiset::value_type, + less::value_type>, + _Allocator>; + + template> + multiset(initializer_list<_Key>, _Allocator) + -> multiset<_Key, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Multiset equality comparison. + * @param __x A %multiset. + * @param __y A %multiset of the same type as @a __x. + * @return True iff the size and elements of the multisets are equal. + * + * This is an equivalence relation. It is linear in the size of the + * multisets. + * Multisets are considered equivalent if their sizes are equal, and if + * corresponding elements compare equal. + */ + template + inline bool + operator==(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Multiset ordering relation. + * @param __x A `multiset`. + * @param __y A `multiset` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Key> + operator<=>(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Multiset ordering relation. + * @param __x A %multiset. + * @param __y A %multiset of the same type as @a __x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * sets. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Returns !(x == y). + template + inline bool + operator!=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Returns y < x. + template + inline bool + operator>(const multiset<_Key,_Compare,_Alloc>& __x, + const multiset<_Key,_Compare,_Alloc>& __y) + { return __y < __x; } + + /// Returns !(y < x) + template + inline bool + operator<=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Returns !(x < y) + template + inline bool + operator>=(const multiset<_Key, _Compare, _Alloc>& __x, + const multiset<_Key, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::multiset::swap(). + template + inline void + swap(multiset<_Key, _Compare, _Alloc>& __x, + multiset<_Key, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::multiset access to internals of compatible sets. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::multiset<_Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_MULTISET_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_numeric.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_numeric.h new file mode 100755 index 0000000..24aba08 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_numeric.h @@ -0,0 +1,413 @@ +// Numeric functions implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_numeric.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{numeric} + */ + +#ifndef _STL_NUMERIC_H +#define _STL_NUMERIC_H 1 + +#include +#include +#include // For _GLIBCXX_MOVE + + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @defgroup numeric_ops Generalized Numeric operations + * @ingroup algorithms + */ + +#if __cplusplus >= 201103L + /** + * @brief Create a range of sequentially increasing values. + * + * For each element in the range @p [first,last) assigns @p value and + * increments @p value as if by @p ++value. + * + * @param __first Start of range. + * @param __last End of range. + * @param __value Starting value. + * @return Nothing. + * @ingroup numeric_ops + */ + template + _GLIBCXX20_CONSTEXPR + void + iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) + { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator>) + __glibcxx_function_requires(_ConvertibleConcept<_Tp, + typename iterator_traits<_ForwardIterator>::value_type>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + { + *__first = __value; + ++__value; + } + } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION + +_GLIBCXX_BEGIN_NAMESPACE_ALGO + +#if __cplusplus > 201703L +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// DR 2055. std::move in std::accumulate and other algorithms +# define _GLIBCXX_MOVE_IF_20(_E) std::move(_E) +#else +# define _GLIBCXX_MOVE_IF_20(_E) _E +#endif + + /// @addtogroup numeric_ops + /// @{ + + /** + * @brief Accumulate values in a range. + * + * Accumulates the values in the range [first,last) using operator+(). The + * initial value is @a init. The values are processed in order. + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @return The final sum. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + __init = _GLIBCXX_MOVE_IF_20(__init) + *__first; + return __init; + } + + /** + * @brief Accumulate values in a range with operation. + * + * Accumulates the values in the range `[first,last)` using the function + * object `__binary_op`. The initial value is `__init`. The values are + * processed in order. + * + * @param __first Start of range. + * @param __last End of range. + * @param __init Starting value to add other values to. + * @param __binary_op Function object to accumulate with. + * @return The final sum. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, + _BinaryOperation __binary_op) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_requires_valid_range(__first, __last); + + for (; __first != __last; ++__first) + __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first); + return __init; + } + + /** + * @brief Compute inner product of two ranges. + * + * Starting with an initial value of @p __init, multiplies successive + * elements from the two ranges and adds each product into the accumulated + * value using operator+(). The values in the ranges are processed in + * order. + * + * @param __first1 Start of range 1. + * @param __last1 End of range 1. + * @param __first2 Start of range 2. + * @param __init Starting value to add other values to. + * @return The final inner product. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + inner_product(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp __init) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + __init = _GLIBCXX_MOVE_IF_20(__init) + (*__first1 * *__first2); + return __init; + } + + /** + * @brief Compute inner product of two ranges. + * + * Starting with an initial value of @p __init, applies @p __binary_op2 to + * successive elements from the two ranges and accumulates each result into + * the accumulated value using @p __binary_op1. The values in the ranges are + * processed in order. + * + * @param __first1 Start of range 1. + * @param __last1 End of range 1. + * @param __first2 Start of range 2. + * @param __init Starting value to add other values to. + * @param __binary_op1 Function object to accumulate with. + * @param __binary_op2 Function object to apply to pairs of input values. + * @return The final inner product. + */ + template + _GLIBCXX20_CONSTEXPR + inline _Tp + inner_product(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _Tp __init, + _BinaryOperation1 __binary_op1, + _BinaryOperation2 __binary_op2) + { + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) + __glibcxx_requires_valid_range(__first1, __last1); + + for (; __first1 != __last1; ++__first1, (void)++__first2) + __init = __binary_op1(_GLIBCXX_MOVE_IF_20(__init), + __binary_op2(*__first1, *__first2)); + return __init; + } + + /** + * @brief Return list of partial sums + * + * Accumulates the values in the range [first,last) using the @c + operator. + * As each successive input value is added into the total, that partial sum + * is written to @p __result. Therefore, the first value in @p __result is + * the first value of the input, the second value in @p __result is the sum + * of the first and second input values, and so on. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sum. + * @return Iterator pointing just beyond the values written to __result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + __value = _GLIBCXX_MOVE_IF_20(__value) + *__first; + *++__result = __value; + } + return ++__result; + } + + /** + * @brief Return list of partial sums + * + * Accumulates the values in the range [first,last) using @p __binary_op. + * As each successive input value is added into the total, that partial sum + * is written to @p __result. Therefore, the first value in @p __result is + * the first value of the input, the second value in @p __result is the sum + * of the first and second input values, and so on. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sum. + * @param __binary_op Function object. + * @return Iterator pointing just beyond the values written to __result. + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + partial_sum(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + __value = __binary_op(_GLIBCXX_MOVE_IF_20(__value), *__first); + *++__result = __value; + } + return ++__result; + } + + /** + * @brief Return differences between adjacent values. + * + * Computes the difference between adjacent values in the range + * [first,last) using operator-() and writes the result to @p __result. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sums. + * @return Iterator pointing just beyond the values written to result. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 539. partial_sum and adjacent_difference should mention requirements + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + adjacent_difference(_InputIterator __first, + _InputIterator __last, _OutputIterator __result) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + _ValueType __tmp = *__first; + *++__result = __tmp - _GLIBCXX_MOVE_IF_20(__value); + __value = _GLIBCXX_MOVE(__tmp); + } + return ++__result; + } + + /** + * @brief Return differences between adjacent values. + * + * Computes the difference between adjacent values in the range + * [__first,__last) using the function object @p __binary_op and writes the + * result to @p __result. + * + * @param __first Start of input range. + * @param __last End of input range. + * @param __result Output sum. + * @param __binary_op Function object. + * @return Iterator pointing just beyond the values written to result. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS + * DR 539. partial_sum and adjacent_difference should mention requirements + */ + template + _GLIBCXX20_CONSTEXPR + _OutputIterator + adjacent_difference(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOperation __binary_op) + { + typedef typename iterator_traits<_InputIterator>::value_type _ValueType; + + // concept requirements + __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) + __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, + _ValueType>) + __glibcxx_requires_valid_range(__first, __last); + + if (__first == __last) + return __result; + _ValueType __value = *__first; + *__result = __value; + while (++__first != __last) + { + _ValueType __tmp = *__first; + *++__result = __binary_op(__tmp, _GLIBCXX_MOVE_IF_20(__value)); + __value = _GLIBCXX_MOVE(__tmp); + } + return ++__result; + } + + /// @} group numeric_ops + +#undef _GLIBCXX_MOVE_IF_20 + +_GLIBCXX_END_NAMESPACE_ALGO +} // namespace std + +#endif /* _STL_NUMERIC_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_pair.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_pair.h new file mode 100755 index 0000000..70262f9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_pair.h @@ -0,0 +1,586 @@ +// Pair implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_pair.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + */ + +#ifndef _STL_PAIR_H +#define _STL_PAIR_H 1 + +#include // for std::move / std::forward, and std::swap + +#if __cplusplus >= 201103L +# include // for std::__decay_and_strip, std::is_reference_v +#endif +#if __cplusplus > 201703L +# include +# define __cpp_lib_constexpr_utility 201811L +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup utilities + * @{ + */ + +#if __cplusplus >= 201103L + /// Tag type for piecewise construction of std::pair objects. + struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; + + /// Tag for piecewise construction of std::pair objects. + _GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct = + piecewise_construct_t(); + + /// @cond undocumented + + // Forward declarations. + template + class tuple; + + template + struct _Index_tuple; + + // Concept utility functions, reused in conditionally-explicit + // constructors. + // See PR 70437, don't look at is_constructible or + // is_convertible if the types are the same to + // avoid querying those properties for incomplete types. + template + struct _PCC + { + template + static constexpr bool _ConstructiblePair() + { + return __and_, + is_constructible<_T2, const _U2&>>::value; + } + + template + static constexpr bool _ImplicitlyConvertiblePair() + { + return __and_, + is_convertible>::value; + } + + template + static constexpr bool _MoveConstructiblePair() + { + return __and_, + is_constructible<_T2, _U2&&>>::value; + } + + template + static constexpr bool _ImplicitlyMoveConvertiblePair() + { + return __and_, + is_convertible<_U2&&, _T2>>::value; + } + + template + static constexpr bool _CopyMovePair() + { + using __do_converts = __and_, + is_convertible<_U2&&, _T2>>; + using __converts = typename conditional<__implicit, + __do_converts, + __not_<__do_converts>>::type; + return __and_, + is_constructible<_T2, _U2&&>, + __converts + >::value; + } + + template + static constexpr bool _MoveCopyPair() + { + using __do_converts = __and_, + is_convertible>; + using __converts = typename conditional<__implicit, + __do_converts, + __not_<__do_converts>>::type; + return __and_, + is_constructible<_T2, const _U2&&>, + __converts + >::value; + } + }; + + template + struct _PCC + { + template + static constexpr bool _ConstructiblePair() + { + return false; + } + + template + static constexpr bool _ImplicitlyConvertiblePair() + { + return false; + } + + template + static constexpr bool _MoveConstructiblePair() + { + return false; + } + + template + static constexpr bool _ImplicitlyMoveConvertiblePair() + { + return false; + } + }; +#endif // C++11 + + template class __pair_base + { +#if __cplusplus >= 201103L + template friend struct pair; + __pair_base() = default; + ~__pair_base() = default; + __pair_base(const __pair_base&) = default; + __pair_base& operator=(const __pair_base&) = delete; +#endif // C++11 + }; + + /// @endcond + + /** + * @brief Struct holding two objects of arbitrary type. + * + * @tparam _T1 Type of first object. + * @tparam _T2 Type of second object. + * + * + */ + template + struct pair + : private __pair_base<_T1, _T2> + { + typedef _T1 first_type; ///< The type of the `first` member + typedef _T2 second_type; ///< The type of the `second` member + + _T1 first; ///< The first member + _T2 second; ///< The second member + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 265. std::pair::pair() effects overly restrictive + /** The default constructor creates @c first and @c second using their + * respective default constructors. */ +#if __cplusplus >= 201103L + template , + __is_implicitly_default_constructible<_U2>> + ::value, bool>::type = true> +#endif + _GLIBCXX_CONSTEXPR pair() + : first(), second() { } + +#if __cplusplus >= 201103L + template , + is_default_constructible<_U2>, + __not_< + __and_<__is_implicitly_default_constructible<_U1>, + __is_implicitly_default_constructible<_U2>>>> + ::value, bool>::type = false> + explicit constexpr pair() + : first(), second() { } +#endif + +#if __cplusplus < 201103L + /// Two objects may be passed to a @c pair constructor to be copied. + pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } +#else + // Shortcut for constraining the templates that don't take pairs. + /// @cond undocumented + using _PCCP = _PCC; + /// @endcond + + /// Construct from two const lvalues, allowing implicit conversions. + template() + && _PCCP::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } + + /// Construct from two const lvalues, disallowing implicit conversions. + template() + && !_PCCP::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(const _T1& __a, const _T2& __b) + : first(__a), second(__b) { } +#endif + +#if __cplusplus < 201103L + /// There is also a templated constructor to convert from other pairs. + template + pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } +#else + // Shortcut for constraining the templates that take pairs. + /// @cond undocumented + template + using _PCCFP = _PCC::value + || !is_same<_T2, _U2>::value, + _T1, _T2>; + /// @endcond + + template::template + _ConstructiblePair<_U1, _U2>() + && _PCCFP<_U1, _U2>::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } + + template::template + _ConstructiblePair<_U1, _U2>() + && !_PCCFP<_U1, _U2>::template + _ImplicitlyConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(const pair<_U1, _U2>& __p) + : first(__p.first), second(__p.second) { } +#endif + +#if __cplusplus >= 201103L + constexpr pair(const pair&) = default; ///< Copy constructor + constexpr pair(pair&&) = default; ///< Move constructor + + // DR 811. + template(), + bool>::type=true> + constexpr pair(_U1&& __x, const _T2& __y) + : first(std::forward<_U1>(__x)), second(__y) { } + + template(), + bool>::type=false> + explicit constexpr pair(_U1&& __x, const _T2& __y) + : first(std::forward<_U1>(__x)), second(__y) { } + + template(), + bool>::type=true> + constexpr pair(const _T1& __x, _U2&& __y) + : first(__x), second(std::forward<_U2>(__y)) { } + + template(), + bool>::type=false> + explicit pair(const _T1& __x, _U2&& __y) + : first(__x), second(std::forward<_U2>(__y)) { } + + template() + && _PCCP::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(_U1&& __x, _U2&& __y) + : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } + + template() + && !_PCCP::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(_U1&& __x, _U2&& __y) + : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } + + + template::template + _MoveConstructiblePair<_U1, _U2>() + && _PCCFP<_U1, _U2>::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=true> + constexpr pair(pair<_U1, _U2>&& __p) + : first(std::forward<_U1>(__p.first)), + second(std::forward<_U2>(__p.second)) { } + + template::template + _MoveConstructiblePair<_U1, _U2>() + && !_PCCFP<_U1, _U2>::template + _ImplicitlyMoveConvertiblePair<_U1, _U2>(), + bool>::type=false> + explicit constexpr pair(pair<_U1, _U2>&& __p) + : first(std::forward<_U1>(__p.first)), + second(std::forward<_U2>(__p.second)) { } + + template + _GLIBCXX20_CONSTEXPR + pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); + + _GLIBCXX20_CONSTEXPR pair& + operator=(typename conditional< + __and_, + is_copy_assignable<_T2>>::value, + const pair&, const __nonesuch&>::type __p) + { + first = __p.first; + second = __p.second; + return *this; + } + + _GLIBCXX20_CONSTEXPR pair& + operator=(typename conditional< + __and_, + is_move_assignable<_T2>>::value, + pair&&, __nonesuch&&>::type __p) + noexcept(__and_, + is_nothrow_move_assignable<_T2>>::value) + { + first = std::forward(__p.first); + second = std::forward(__p.second); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + typename enable_if<__and_, + is_assignable<_T2&, const _U2&>>::value, + pair&>::type + operator=(const pair<_U1, _U2>& __p) + { + first = __p.first; + second = __p.second; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR + typename enable_if<__and_, + is_assignable<_T2&, _U2&&>>::value, + pair&>::type + operator=(pair<_U1, _U2>&& __p) + { + first = std::forward<_U1>(__p.first); + second = std::forward<_U2>(__p.second); + return *this; + } + + /// Swap the first members and then the second members. + _GLIBCXX20_CONSTEXPR void + swap(pair& __p) + noexcept(__and_<__is_nothrow_swappable<_T1>, + __is_nothrow_swappable<_T2>>::value) + { + using std::swap; + swap(first, __p.first); + swap(second, __p.second); + } + + private: + template + _GLIBCXX20_CONSTEXPR + pair(tuple<_Args1...>&, tuple<_Args2...>&, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); +#endif // C++11 + }; + + /// @relates pair @{ + +#if __cpp_deduction_guides >= 201606 + template pair(_T1, _T2) -> pair<_T1, _T2>; +#endif + + /// Two pairs of the same type are equal iff their members are equal. + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return __x.first == __y.first && __x.second == __y.second; } + +#if __cpp_lib_three_way_comparison && __cpp_lib_concepts + template + constexpr common_comparison_category_t<__detail::__synth3way_t<_T1>, + __detail::__synth3way_t<_T2>> + operator<=>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { + if (auto __c = __detail::__synth3way(__x.first, __y.first); __c != 0) + return __c; + return __detail::__synth3way(__x.second, __y.second); + } +#else + /** Defines a lexicographical order for pairs. + * + * For two pairs of the same type, `P` is ordered before `Q` if + * `P.first` is less than `Q.first`, or if `P.first` and `Q.first` + * are equivalent (neither is less than the other) and `P.second` is less + * than `Q.second`. + */ + template + inline _GLIBCXX_CONSTEXPR bool + operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return __x.first < __y.first + || (!(__y.first < __x.first) && __x.second < __y.second); } + + /// Uses @c operator== to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return !(__x == __y); } + + /// Uses @c operator< to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return __y < __x; } + + /// Uses @c operator< to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return !(__y < __x); } + + /// Uses @c operator< to find the result. + template + inline _GLIBCXX_CONSTEXPR bool + operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) + { return !(__x < __y); } +#endif // !(three_way_comparison && concepts) + +#if __cplusplus >= 201103L + /** Swap overload for pairs. Calls std::pair::swap(). + * + * @note This std::swap overload is not declared in C++03 mode, + * which has performance implications, e.g. see https://gcc.gnu.org/PR38466 + */ + template + _GLIBCXX20_CONSTEXPR inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_T1>, + __is_swappable<_T2>>::value>::type +#else + void +#endif + swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if, + __is_swappable<_T2>>::value>::type + swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; +#endif +#endif // __cplusplus >= 201103L + + /// @} relates pair + + /** + * @brief A convenience wrapper for creating a pair from two objects. + * @param __x The first object. + * @param __y The second object. + * @return A newly-constructed pair<> object of the appropriate type. + * + * The C++98 standard says the objects are passed by reference-to-const, + * but C++03 says they are passed by value (this was LWG issue #181). + * + * Since C++11 they have been passed by forwarding reference and then + * forwarded to the new members of the pair. To create a pair with a + * member of reference type, pass a `reference_wrapper` to this function. + */ + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 181. make_pair() unintended behavior +#if __cplusplus >= 201103L + // NB: DR 706. + template + constexpr pair::__type, + typename __decay_and_strip<_T2>::__type> + make_pair(_T1&& __x, _T2&& __y) + { + typedef typename __decay_and_strip<_T1>::__type __ds_type1; + typedef typename __decay_and_strip<_T2>::__type __ds_type2; + typedef pair<__ds_type1, __ds_type2> __pair_type; + return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y)); + } +#else + template + inline pair<_T1, _T2> + make_pair(_T1 __x, _T2 __y) + { return pair<_T1, _T2>(__x, __y); } +#endif + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_PAIR_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_queue.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_queue.h new file mode 100755 index 0000000..936cf0d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_queue.h @@ -0,0 +1,753 @@ +// Queue implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_queue.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{queue} + */ + +#ifndef _STL_QUEUE_H +#define _STL_QUEUE_H 1 + +#include +#include +#if __cplusplus >= 201103L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief A standard container giving FIFO behavior. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Sequence Type of underlying sequence, defaults to deque<_Tp>. + * + * Meets many of the requirements of a + * container, + * but does not define anything to do with iterators. Very few of the + * other standard container interfaces are defined. + * + * This is not a true container, but an @e adaptor. It holds another + * container, and provides a wrapper interface to that container. The + * wrapper is what enforces strict first-in-first-out %queue behavior. + * + * The second template parameter defines the type of the underlying + * sequence/container. It defaults to std::deque, but it can be any type + * that supports @c front, @c back, @c push_back, and @c pop_front, + * such as std::list or an appropriate user-defined type. + * + * Members not found in @a normal containers are @c container_type, + * which is a typedef for the second Sequence parameter, and @c push and + * @c pop, which are standard %queue/FIFO operations. + */ + template > + class queue + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept) + __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) + __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) +#endif + + template + friend bool + operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&); + + template + friend bool + operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&); + +#if __cpp_lib_three_way_comparison + template + friend compare_three_way_result_t<_Seq1> + operator<=>(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&); +#endif + +#if __cplusplus >= 201103L + template + using _Uses = typename + enable_if::value>::type; + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2566. Requirements on the first template parameter of container + // adaptors + static_assert(is_same<_Tp, typename _Sequence::value_type>::value, + "value_type must be the same as the underlying container"); +#endif // C++17 +#endif // C++11 + + public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + protected: + /* Maintainers wondering why this isn't uglified as per style + * guidelines should note that this name is specified in the standard, + * C++98 [23.2.3.1]. + * (Why? Presumably for the same reason that it's protected instead + * of private: to allow derivation. But none of the other + * containers allow for derivation. Odd.) + */ + /// @c c is the underlying container. + _Sequence c; + + public: + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + explicit + queue(const _Sequence& __c = _Sequence()) + : c(__c) { } +#else + template::value>::type> + queue() + : c() { } + + explicit + queue(const _Sequence& __c) + : c(__c) { } + + explicit + queue(_Sequence&& __c) + : c(std::move(__c)) { } + + template> + explicit + queue(const _Alloc& __a) + : c(__a) { } + + template> + queue(const _Sequence& __c, const _Alloc& __a) + : c(__c, __a) { } + + template> + queue(_Sequence&& __c, const _Alloc& __a) + : c(std::move(__c), __a) { } + + template> + queue(const queue& __q, const _Alloc& __a) + : c(__q.c, __a) { } + + template> + queue(queue&& __q, const _Alloc& __a) + : c(std::move(__q.c), __a) { } +#endif + + /** + * Returns true if the %queue is empty. + */ + _GLIBCXX_NODISCARD bool + empty() const + { return c.empty(); } + + /** Returns the number of elements in the %queue. */ + size_type + size() const + { return c.size(); } + + /** + * Returns a read/write reference to the data at the first + * element of the %queue. + */ + reference + front() + { + __glibcxx_requires_nonempty(); + return c.front(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %queue. + */ + const_reference + front() const + { + __glibcxx_requires_nonempty(); + return c.front(); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %queue. + */ + reference + back() + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * Returns a read-only (constant) reference to the data at the last + * element of the %queue. + */ + const_reference + back() const + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * @brief Add data to the end of the %queue. + * @param __x Data to be added. + * + * This is a typical %queue operation. The function creates an + * element at the end of the %queue and assigns the given data + * to it. The time complexity of the operation depends on the + * underlying sequence. + */ + void + push(const value_type& __x) + { c.push_back(__x); } + +#if __cplusplus >= 201103L + void + push(value_type&& __x) + { c.push_back(std::move(__x)); } + +#if __cplusplus > 201402L + template + decltype(auto) + emplace(_Args&&... __args) + { return c.emplace_back(std::forward<_Args>(__args)...); } +#else + template + void + emplace(_Args&&... __args) + { c.emplace_back(std::forward<_Args>(__args)...); } +#endif +#endif + + /** + * @brief Removes first element. + * + * This is a typical %queue operation. It shrinks the %queue by one. + * The time complexity of the operation depends on the underlying + * sequence. + * + * Note that no data is returned, and if the first element's + * data is needed, it should be retrieved before pop() is + * called. + */ + void + pop() + { + __glibcxx_requires_nonempty(); + c.pop_front(); + } + +#if __cplusplus >= 201103L + void + swap(queue& __q) +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + noexcept(__is_nothrow_swappable<_Sequence>::value) +#else + noexcept(__is_nothrow_swappable<_Tp>::value) +#endif + { + using std::swap; + swap(c, __q.c); + } +#endif // __cplusplus >= 201103L + }; + +#if __cpp_deduction_guides >= 201606 + template> + queue(_Container) -> queue; + + template, + typename = _RequireAllocator<_Allocator>> + queue(_Container, _Allocator) + -> queue; +#endif + + /** + * @brief Queue equality comparison. + * @param __x A %queue. + * @param __y A %queue of the same type as @a __x. + * @return True iff the size and elements of the queues are equal. + * + * This is an equivalence relation. Complexity and semantics depend on the + * underlying sequence type, but the expected rules are: this relation is + * linear in the size of the sequences, and queues are considered equivalent + * if their sequences compare equal. + */ + template + inline bool + operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __x.c == __y.c; } + + /** + * @brief Queue ordering relation. + * @param __x A %queue. + * @param __y A %queue of the same type as @a x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is an total ordering relation. Complexity and semantics + * depend on the underlying sequence type, but the expected rules + * are: this relation is linear in the size of the sequences, the + * elements must be comparable with @c <, and + * std::lexicographical_compare() is usually used to make the + * determination. + */ + template + inline bool + operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __x.c < __y.c; } + + /// Based on operator== + template + inline bool + operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return !(__x < __y); } + +#if __cpp_lib_three_way_comparison + template + inline compare_three_way_result_t<_Seq> + operator<=>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y) + { return __x.c <=> __y.c; } +#endif + +#if __cplusplus >= 201103L + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Seq>::value>::type +#else + void +#endif + swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public uses_allocator<_Seq, _Alloc>::type { }; +#endif // __cplusplus >= 201103L + + /** + * @brief A standard container automatically sorting its contents. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Sequence Type of underlying sequence, defaults to vector<_Tp>. + * @tparam _Compare Comparison function object type, defaults to + * less<_Sequence::value_type>. + * + * This is not a true container, but an @e adaptor. It holds + * another container, and provides a wrapper interface to that + * container. The wrapper is what enforces priority-based sorting + * and %queue behavior. Very few of the standard container/sequence + * interface requirements are met (e.g., iterators). + * + * The second template parameter defines the type of the underlying + * sequence/container. It defaults to std::vector, but it can be + * any type that supports @c front(), @c push_back, @c pop_back, + * and random-access iterators, such as std::deque or an + * appropriate user-defined type. + * + * The third template parameter supplies the means of making + * priority comparisons. It defaults to @c less but + * can be anything defining a strict weak ordering. + * + * Members not found in @a normal containers are @c container_type, + * which is a typedef for the second Sequence parameter, and @c + * push, @c pop, and @c top, which are standard %queue operations. + * + * @note No equality/comparison operators are provided for + * %priority_queue. + * + * @note Sorting of the elements takes place as they are added to, + * and removed from, the %priority_queue using the + * %priority_queue's member functions. If you access the elements + * by other means, and change their data such that the sorting + * order would be different, the %priority_queue will not re-sort + * the elements for you. (How could it know to do so?) + */ + template, + typename _Compare = less > + class priority_queue + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires(_Sequence, _SequenceConcept) + __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept) + __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) + __glibcxx_class_requires4(_Compare, bool, _Tp, _Tp, + _BinaryFunctionConcept) +#endif + +#if __cplusplus >= 201103L + template + using _Uses = typename + enable_if::value>::type; + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2566. Requirements on the first template parameter of container + // adaptors + static_assert(is_same<_Tp, typename _Sequence::value_type>::value, + "value_type must be the same as the underlying container"); +#endif // C++17 +#endif // C++11 + + public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 2684. priority_queue lacking comparator typedef + typedef _Compare value_compare; + + protected: + // See queue::c for notes on these names. + _Sequence c; + _Compare comp; + + public: + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + explicit + priority_queue(const _Compare& __x = _Compare(), + const _Sequence& __s = _Sequence()) + : c(__s), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } +#else + template, + is_default_constructible<_Seq>>::value>::type> + priority_queue() + : c(), comp() { } + + explicit + priority_queue(const _Compare& __x, const _Sequence& __s) + : c(__s), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + explicit + priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence()) + : c(std::move(__s)), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template> + explicit + priority_queue(const _Alloc& __a) + : c(__a), comp() { } + + template> + priority_queue(const _Compare& __x, const _Alloc& __a) + : c(__a), comp(__x) { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2537. Constructors [...] taking allocators should call make_heap + template> + priority_queue(const _Compare& __x, const _Sequence& __c, + const _Alloc& __a) + : c(__c, __a), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template> + priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a) + : c(std::move(__c), __a), comp(__x) + { std::make_heap(c.begin(), c.end(), comp); } + + template> + priority_queue(const priority_queue& __q, const _Alloc& __a) + : c(__q.c, __a), comp(__q.comp) { } + + template> + priority_queue(priority_queue&& __q, const _Alloc& __a) + : c(std::move(__q.c), __a), comp(std::move(__q.comp)) { } +#endif + + /** + * @brief Builds a %queue from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __x A comparison functor describing a strict weak ordering. + * @param __s An initial sequence with which to start. + * + * Begins by copying @a __s, inserting a copy of the elements + * from @a [first,last) into the copy of @a __s, then ordering + * the copy according to @a __x. + * + * For more information on function objects, see the + * documentation on @link functors functor base + * classes@endlink. + */ +#if __cplusplus < 201103L + template + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x = _Compare(), + const _Sequence& __s = _Sequence()) + : c(__s), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } +#else + template + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x, + const _Sequence& __s) + : c(__s), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } + + template + priority_queue(_InputIterator __first, _InputIterator __last, + const _Compare& __x = _Compare(), + _Sequence&& __s = _Sequence()) + : c(std::move(__s)), comp(__x) + { + __glibcxx_requires_valid_range(__first, __last); + c.insert(c.end(), __first, __last); + std::make_heap(c.begin(), c.end(), comp); + } +#endif + + /** + * Returns true if the %queue is empty. + */ + _GLIBCXX_NODISCARD bool + empty() const + { return c.empty(); } + + /** Returns the number of elements in the %queue. */ + size_type + size() const + { return c.size(); } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %queue. + */ + const_reference + top() const + { + __glibcxx_requires_nonempty(); + return c.front(); + } + + /** + * @brief Add data to the %queue. + * @param __x Data to be added. + * + * This is a typical %queue operation. + * The time complexity of the operation depends on the underlying + * sequence. + */ + void + push(const value_type& __x) + { + c.push_back(__x); + std::push_heap(c.begin(), c.end(), comp); + } + +#if __cplusplus >= 201103L + void + push(value_type&& __x) + { + c.push_back(std::move(__x)); + std::push_heap(c.begin(), c.end(), comp); + } + + template + void + emplace(_Args&&... __args) + { + c.emplace_back(std::forward<_Args>(__args)...); + std::push_heap(c.begin(), c.end(), comp); + } +#endif + + /** + * @brief Removes first element. + * + * This is a typical %queue operation. It shrinks the %queue + * by one. The time complexity of the operation depends on the + * underlying sequence. + * + * Note that no data is returned, and if the first element's + * data is needed, it should be retrieved before pop() is + * called. + */ + void + pop() + { + __glibcxx_requires_nonempty(); + std::pop_heap(c.begin(), c.end(), comp); + c.pop_back(); + } + +#if __cplusplus >= 201103L + void + swap(priority_queue& __pq) + noexcept(__and_< +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + __is_nothrow_swappable<_Sequence>, +#else + __is_nothrow_swappable<_Tp>, +#endif + __is_nothrow_swappable<_Compare> + >::value) + { + using std::swap; + swap(c, __pq.c); + swap(comp, __pq.comp); + } +#endif // __cplusplus >= 201103L + }; + +#if __cpp_deduction_guides >= 201606 + template, + typename = _RequireNotAllocator<_Container>> + priority_queue(_Compare, _Container) + -> priority_queue; + + template::value_type, + typename _Compare = less<_ValT>, + typename _Container = vector<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireNotAllocator<_Container>> + priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), + _Container = _Container()) + -> priority_queue<_ValT, _Container, _Compare>; + + template, + typename = _RequireNotAllocator<_Container>, + typename = _RequireAllocator<_Allocator>> + priority_queue(_Compare, _Container, _Allocator) + -> priority_queue; +#endif + + // No equality/comparison operators are provided for priority_queue. + +#if __cplusplus >= 201103L + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__and_<__is_swappable<_Sequence>, + __is_swappable<_Compare>>::value>::type +#else + void +#endif + swap(priority_queue<_Tp, _Sequence, _Compare>& __x, + priority_queue<_Tp, _Sequence, _Compare>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public uses_allocator<_Sequence, _Alloc>::type { }; +#endif // __cplusplus >= 201103L + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_QUEUE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_raw_storage_iter.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_raw_storage_iter.h new file mode 100755 index 0000000..13a1aa3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_raw_storage_iter.h @@ -0,0 +1,123 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_raw_storage_iter.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_RAW_STORAGE_ITERATOR_H +#define _STL_RAW_STORAGE_ITERATOR_H 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * This iterator class lets algorithms store their results into + * uninitialized memory. + */ + template + class raw_storage_iterator + : public iterator + { + protected: + _OutputIterator _M_iter; + + public: + explicit + raw_storage_iterator(_OutputIterator __x) + : _M_iter(__x) {} + + raw_storage_iterator& + operator*() { return *this; } + + raw_storage_iterator& + operator=(const _Tp& __element) + { + std::_Construct(std::__addressof(*_M_iter), __element); + return *this; + } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2127. Move-construction with raw_storage_iterator + raw_storage_iterator& + operator=(_Tp&& __element) + { + std::_Construct(std::__addressof(*_M_iter), std::move(__element)); + return *this; + } +#endif + + raw_storage_iterator& + operator++() + { + ++_M_iter; + return *this; + } + + raw_storage_iterator + operator++(int) + { + raw_storage_iterator __tmp = *this; + ++_M_iter; + return __tmp; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2454. Add raw_storage_iterator::base() member + _OutputIterator base() const { return _M_iter; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_relops.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_relops.h new file mode 100755 index 0000000..276894c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_relops.h @@ -0,0 +1,133 @@ +// std::rel_ops implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the, 2009 Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * Copyright (c) 1996,1997 + * Silicon Graphics + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file bits/stl_relops.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + * + * Inclusion of this file has been removed from + * all of the other STL headers for safety reasons, except std_utility.h. + * For more information, see the thread of about twenty messages starting + * with http://gcc.gnu.org/ml/libstdc++/2001-01/msg00223.html, or + * http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.ambiguous_overloads + * + * Short summary: the rel_ops operators should be avoided for the present. + */ + +#ifndef _STL_RELOPS_H +#define _STL_RELOPS_H 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace rel_ops + { + /** @namespace std::rel_ops + * @brief The generated relational operators are sequestered here. + */ + + /** + * @brief Defines @c != for arbitrary types, in terms of @c ==. + * @param __x A thing. + * @param __y Another thing. + * @return __x != __y + * + * This function uses @c == to determine its result. + */ + template + inline bool + operator!=(const _Tp& __x, const _Tp& __y) + { return !(__x == __y); } + + /** + * @brief Defines @c > for arbitrary types, in terms of @c <. + * @param __x A thing. + * @param __y Another thing. + * @return __x > __y + * + * This function uses @c < to determine its result. + */ + template + inline bool + operator>(const _Tp& __x, const _Tp& __y) + { return __y < __x; } + + /** + * @brief Defines @c <= for arbitrary types, in terms of @c <. + * @param __x A thing. + * @param __y Another thing. + * @return __x <= __y + * + * This function uses @c < to determine its result. + */ + template + inline bool + operator<=(const _Tp& __x, const _Tp& __y) + { return !(__y < __x); } + + /** + * @brief Defines @c >= for arbitrary types, in terms of @c <. + * @param __x A thing. + * @param __y Another thing. + * @return __x >= __y + * + * This function uses @c < to determine its result. + */ + template + inline bool + operator>=(const _Tp& __x, const _Tp& __y) + { return !(__x < __y); } + } // namespace rel_ops + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_RELOPS_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_set.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_set.h new file mode 100755 index 0000000..a9b9695 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_set.h @@ -0,0 +1,1086 @@ +// Set implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_set.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{set} + */ + +#ifndef _STL_SET_H +#define _STL_SET_H 1 + +#include +#if __cplusplus >= 201103L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + class multiset; + + /** + * @brief A standard container made up of unique keys, which can be + * retrieved in logarithmic time. + * + * @ingroup associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Compare Comparison function object type, defaults to less<_Key>. + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, a + * reversible container, and an + * associative container (using unique keys). + * + * Sets support bidirectional iterators. + * + * The private tree data is declared exactly the same way for set and + * multiset; the distinction is made entirely in how the tree functions are + * called (*_unique versus *_equal, same as the standard). + */ + template, + typename _Alloc = std::allocator<_Key> > + class set + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Key, _SGIAssignableConcept) +# endif + __glibcxx_class_requires4(_Compare, bool, _Key, _Key, + _BinaryFunctionConcept) + __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Key>::value, + "std::set must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::set must have the same value_type as its allocator"); +# endif +#endif + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + typedef _Alloc allocator_type; + ///@} + + private: + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Key>::other _Key_alloc_type; + + typedef _Rb_tree, + key_compare, _Key_alloc_type> _Rep_type; + _Rep_type _M_t; // Red-black tree representing set. + + typedef __gnu_cxx::__alloc_traits<_Key_alloc_type> _Alloc_traits; + + public: + ///@{ + /// Iterator-related typedefs. + typedef typename _Alloc_traits::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 103. set::iterator is required to be modifiable, + // but this allows modification of keys. + typedef typename _Rep_type::const_iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::const_reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Rep_type::node_type; + using insert_return_type = typename _Rep_type::insert_return_type; +#endif + + // allocation/deallocation + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + set() : _M_t() { } +#else + set() = default; +#endif + + /** + * @brief Creates a %set with no elements. + * @param __comp Comparator to use. + * @param __a An allocator object. + */ + explicit + set(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) { } + + /** + * @brief Builds a %set from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * + * Create a %set consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + set(_InputIterator __first, _InputIterator __last) + : _M_t() + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * @brief Builds a %set from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %set consisting of copies of the elements from + * [__first,__last). This is linear in N if the range is + * already sorted, and NlogN otherwise (where N is + * distance(__first,__last)). + */ + template + set(_InputIterator __first, _InputIterator __last, + const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * @brief %Set copy constructor. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + set(const set& __x) + : _M_t(__x._M_t) { } +#else + set(const set&) = default; + + /** + * @brief %Set move constructor + * + * The newly-created %set contains the exact contents of the moved + * instance. The moved instance is a valid, but unspecified, %set. + */ + set(set&&) = default; + + /** + * @brief Builds a %set from an initializer_list. + * @param __l An initializer_list. + * @param __comp A comparison functor. + * @param __a An allocator object. + * + * Create a %set consisting of copies of the elements in the list. + * This is linear in N if the list is already sorted, and NlogN + * otherwise (where N is @a __l.size()). + */ + set(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, _Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended default constructor. + explicit + set(const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) { } + + /// Allocator-extended copy constructor. + set(const set& __x, const allocator_type& __a) + : _M_t(__x._M_t, _Key_alloc_type(__a)) { } + + /// Allocator-extended move constructor. + set(set&& __x, const allocator_type& __a) + noexcept(is_nothrow_copy_constructible<_Compare>::value + && _Alloc_traits::_S_always_equal()) + : _M_t(std::move(__x._M_t), _Key_alloc_type(__a)) { } + + /// Allocator-extended initialier-list constructor. + set(initializer_list __l, const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__l.begin(), __l.end()); } + + /// Allocator-extended range constructor. + template + set(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _M_t(_Key_alloc_type(__a)) + { _M_t._M_insert_range_unique(__first, __last); } + + /** + * The dtor only erases the elements, and note that if the elements + * themselves are pointers, the pointed-to memory is not touched in any + * way. Managing the pointer is the user's responsibility. + */ + ~set() = default; +#endif + + /** + * @brief %Set assignment operator. + * + * Whether the allocator is copied depends on the allocator traits. + */ +#if __cplusplus < 201103L + set& + operator=(const set& __x) + { + _M_t = __x._M_t; + return *this; + } +#else + set& + operator=(const set&) = default; + + /// Move assignment operator. + set& + operator=(set&&) = default; + + /** + * @brief %Set list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %set with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %set and + * that the resulting %set's size is the same as the number + * of elements assigned. + */ + set& + operator=(initializer_list __l) + { + _M_t._M_assign_unique(__l.begin(), __l.end()); + return *this; + } +#endif + + // accessors: + + /// Returns the comparison object with which the %set was constructed. + key_compare + key_comp() const + { return _M_t.key_comp(); } + /// Returns the comparison object with which the %set was constructed. + value_compare + value_comp() const + { return _M_t.key_comp(); } + /// Returns the allocator object with which the %set was constructed. + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_t.get_allocator()); } + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + begin() const _GLIBCXX_NOEXCEPT + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + end() const _GLIBCXX_NOEXCEPT + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points to the last + * element in the %set. Iteration is done in descending order according + * to the keys. + */ + reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %set. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return _M_t.rend(); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + cbegin() const noexcept + { return _M_t.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %set. Iteration is done in ascending order according + * to the keys. + */ + iterator + cend() const noexcept + { return _M_t.end(); } + + /** + * Returns a read-only (constant) iterator that points to the last + * element in the %set. Iteration is done in descending order according + * to the keys. + */ + reverse_iterator + crbegin() const noexcept + { return _M_t.rbegin(); } + + /** + * Returns a read-only (constant) reverse iterator that points to the + * last pair in the %set. Iteration is done in descending order + * according to the keys. + */ + reverse_iterator + crend() const noexcept + { return _M_t.rend(); } +#endif + + /// Returns true if the %set is empty. + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_t.empty(); } + + /// Returns the size of the %set. + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_t.size(); } + + /// Returns the maximum size of the %set. + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _M_t.max_size(); } + + /** + * @brief Swaps data with another %set. + * @param __x A %set of the same element and allocator types. + * + * This exchanges the elements between two sets in constant + * time. (It is only swapping a pointer, an integer, and an + * instance of the @c Compare type (which itself is often + * stateless and empty), so it should be quite fast.) Note + * that the global std::swap() function is specialized such + * that std::swap(s1,s2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(set& __x) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { _M_t.swap(__x._M_t); } + + // insert/erase +#if __cplusplus >= 201103L + /** + * @brief Attempts to build and insert an element into the %set. + * @param __args Arguments used to generate an element. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to build and insert an element into the %set. + * A %set relies on unique keys and thus an element is only inserted if + * it is not already present in the %set. + * + * Insertion requires logarithmic time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to insert an element into the %set. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element to be + * inserted. + * @return An iterator that points to the element with key equivalent to + * the one generated from @a __args (may or may not be the + * element itself). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + return _M_t._M_emplace_hint_unique(__pos, + std::forward<_Args>(__args)...); + } +#endif + + /** + * @brief Attempts to insert an element into the %set. + * @param __x Element to be inserted. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to insert an element into the %set. A %set + * relies on unique keys and thus an element is only inserted if it is + * not already present in the %set. + * + * Insertion requires logarithmic time. + */ + std::pair + insert(const value_type& __x) + { + std::pair __p = + _M_t._M_insert_unique(__x); + return std::pair(__p.first, __p.second); + } + +#if __cplusplus >= 201103L + std::pair + insert(value_type&& __x) + { + std::pair __p = + _M_t._M_insert_unique(std::move(__x)); + return std::pair(__p.first, __p.second); + } +#endif + + /** + * @brief Attempts to insert an element into the %set. + * @param __position An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the element with key of + * @a __x (may or may not be the element passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires logarithmic time (if the hint is not taken). + */ + iterator + insert(const_iterator __position, const value_type& __x) + { return _M_t._M_insert_unique_(__position, __x); } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_t._M_insert_unique_(__position, std::move(__x)); } +#endif + + /** + * @brief A template function that attempts to insert a range + * of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_t._M_insert_range_unique(__first, __last); } + +#if __cplusplus >= 201103L + /** + * @brief Attempts to insert a list of elements into the %set. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { this->insert(__l.begin(), __l.end()); } +#endif + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_t.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __x) + { return _M_t.extract(__x); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_t._M_reinsert_node_unique(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); } + + template + friend struct std::_Rb_tree_merge_helper; + + template + void + merge(set<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(set<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(multiset<_Key, _Compare1, _Alloc>& __source) + { + using _Merge_helper = _Rb_tree_merge_helper; + _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source)); + } + + template + void + merge(multiset<_Key, _Compare1, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases an element from a %set. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from a %set. Note that this function only erases the element, and + * that if the element is itself a pointer, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { return _M_t.erase(__position); } +#else + /** + * @brief Erases an element from a %set. + * @param position An iterator pointing to the element to be erased. + * + * This function erases an element, pointed to by the given iterator, + * from a %set. Note that this function only erases the element, and + * that if the element is itself a pointer, the pointed-to memory is not + * touched in any way. Managing the pointer is the user's + * responsibility. + */ + void + erase(iterator __position) + { _M_t.erase(__position); } +#endif + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * a %set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_t.erase(__x); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + /** + * @brief Erases a [__first,__last) range of elements from a %set. + * @param __first Iterator pointing to the start of the range to be + * erased. + + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from a %set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_t.erase(__first, __last); } +#else + /** + * @brief Erases a [first,last) range of elements from a %set. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * + * This function erases a sequence of elements from a %set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + erase(iterator __first, iterator __last) + { _M_t.erase(__first, __last); } +#endif + + /** + * Erases all elements in a %set. Note that this function only erases + * the elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_t.clear(); } + + // set operations: + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Element to located. + * @return Number of elements with specified key. + * + * This function only makes sense for multisets; for set the result will + * either be 0 (not present) or 1 (present). + */ + size_type + count(const key_type& __x) const + { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } + +#if __cplusplus > 201103L + template + auto + count(const _Kt& __x) const + -> decltype(_M_t._M_count_tr(__x)) + { return _M_t._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is an element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_t.find(__x) != _M_t.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_t._M_find_tr(__x), void(), true) + { return _M_t._M_find_tr(__x) != _M_t.end(); } + ///@} +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + ///@{ + /** + * @brief Tries to locate an element in a %set. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_t.find(__x); } + + const_iterator + find(const key_type& __x) const + { return _M_t.find(__x); } + +#if __cplusplus > 201103L + template + auto + find(const _Kt& __x) + -> decltype(iterator{_M_t._M_find_tr(__x)}) + { return iterator{_M_t._M_find_tr(__x)}; } + + template + auto + find(const _Kt& __x) const + -> decltype(const_iterator{_M_t._M_find_tr(__x)}) + { return const_iterator{_M_t._M_find_tr(__x)}; } +#endif + ///@} + + ///@{ + /** + * @brief Finds the beginning of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to first element equal to or greater + * than key, or end(). + * + * This function returns the first element of a subsequence of elements + * that matches the given key. If unsuccessful it returns an iterator + * pointing to the first element that has a greater value than given key + * or end() if no such element exists. + */ + iterator + lower_bound(const key_type& __x) + { return _M_t.lower_bound(__x); } + + const_iterator + lower_bound(const key_type& __x) const + { return _M_t.lower_bound(__x); } + +#if __cplusplus > 201103L + template + auto + lower_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_lower_bound_tr(__x))) + { return iterator(_M_t._M_lower_bound_tr(__x)); } + + template + auto + lower_bound(const _Kt& __x) const + -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x))) + { return const_iterator(_M_t._M_lower_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the end of a subsequence matching given key. + * @param __x Key to be located. + * @return Iterator pointing to the first element + * greater than key, or end(). + */ + iterator + upper_bound(const key_type& __x) + { return _M_t.upper_bound(__x); } + + const_iterator + upper_bound(const key_type& __x) const + { return _M_t.upper_bound(__x); } + +#if __cplusplus > 201103L + template + auto + upper_bound(const _Kt& __x) + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return iterator(_M_t._M_upper_bound_tr(__x)); } + + template + auto + upper_bound(const _Kt& __x) const + -> decltype(iterator(_M_t._M_upper_bound_tr(__x))) + { return const_iterator(_M_t._M_upper_bound_tr(__x)); } +#endif + ///@} + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function is equivalent to + * @code + * std::make_pair(c.lower_bound(val), + * c.upper_bound(val)) + * @endcode + * (but is faster than making the calls separately). + * + * This function probably only makes sense for multisets. + */ + std::pair + equal_range(const key_type& __x) + { return _M_t.equal_range(__x); } + + std::pair + equal_range(const key_type& __x) const + { return _M_t.equal_range(__x); } + +#if __cplusplus > 201103L + template + auto + equal_range(const _Kt& __x) + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } + + template + auto + equal_range(const _Kt& __x) const + -> decltype(pair(_M_t._M_equal_range_tr(__x))) + { return pair(_M_t._M_equal_range_tr(__x)); } +#endif + ///@} + + template + friend bool + operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); + +#if __cpp_lib_three_way_comparison + template + friend __detail::__synth3way_t<_K1> + operator<=>(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); +#else + template + friend bool + operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + set(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, _Allocator) + -> set::value_type, + less::value_type>, + _Allocator>; + + template> + set(initializer_list<_Key>, _Allocator) + -> set<_Key, less<_Key>, _Allocator>; + +#endif // deduction guides + + /** + * @brief Set equality comparison. + * @param __x A %set. + * @param __y A %set of the same type as @a x. + * @return True iff the size and elements of the sets are equal. + * + * This is an equivalence relation. It is linear in the size of the sets. + * Sets are considered equivalent if their sizes are equal, and if + * corresponding elements compare equal. + */ + template + inline bool + operator==(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __x._M_t == __y._M_t; } + +#if __cpp_lib_three_way_comparison + /** + * @brief Set ordering relation. + * @param __x A `set`. + * @param __y A `set` of the same type as `x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * This is a total ordering relation. It is linear in the size of the + * maps. The elements must be comparable with @c <. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Key> + operator<=>(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __x._M_t <=> __y._M_t; } +#else + /** + * @brief Set ordering relation. + * @param __x A %set. + * @param __y A %set of the same type as @a x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * sets. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __x._M_t < __y._M_t; } + + /// Returns !(x == y). + template + inline bool + operator!=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return !(__x == __y); } + + /// Returns y < x. + template + inline bool + operator>(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return __y < __x; } + + /// Returns !(y < x) + template + inline bool + operator<=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return !(__y < __x); } + + /// Returns !(x < y) + template + inline bool + operator>=(const set<_Key, _Compare, _Alloc>& __x, + const set<_Key, _Compare, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::set::swap(). + template + inline void + swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::set access to internals of compatible sets. + template + struct + _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2> + { + private: + friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>; + + static auto& + _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + + static auto& + _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) + { return __set._M_t; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} //namespace std +#endif /* _STL_SET_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_stack.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_stack.h new file mode 100755 index 0000000..2a460d2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_stack.h @@ -0,0 +1,392 @@ +// Stack implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_stack.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{stack} + */ + +#ifndef _STL_STACK_H +#define _STL_STACK_H 1 + +#include +#include +#if __cplusplus >= 201103L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief A standard container giving FILO behavior. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Sequence Type of underlying sequence, defaults to deque<_Tp>. + * + * Meets many of the requirements of a + * container, + * but does not define anything to do with iterators. Very few of the + * other standard container interfaces are defined. + * + * This is not a true container, but an @e adaptor. It holds + * another container, and provides a wrapper interface to that + * container. The wrapper is what enforces strict + * first-in-last-out %stack behavior. + * + * The second template parameter defines the type of the underlying + * sequence/container. It defaults to std::deque, but it can be + * any type that supports @c back, @c push_back, and @c pop_back, + * such as std::list, std::vector, or an appropriate user-defined + * type. + * + * Members not found in @a normal containers are @c container_type, + * which is a typedef for the second Sequence parameter, and @c + * push, @c pop, and @c top, which are standard %stack/FILO + * operations. + */ + template > + class stack + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // concept requirements + typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) + __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) +# endif + __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) +#endif + + template + friend bool + operator==(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&); + + template + friend bool + operator<(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&); + +#if __cpp_lib_three_way_comparison + template + friend compare_three_way_result_t<_Seq1> + operator<=>(const stack<_Tp1, _Seq1>&, const stack<_Tp1, _Seq1>&); +#endif + +#if __cplusplus >= 201103L + template + using _Uses = typename + enable_if::value>::type; + +#if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2566. Requirements on the first template parameter of container + // adaptors + static_assert(is_same<_Tp, typename _Sequence::value_type>::value, + "value_type must be the same as the underlying container"); +#endif // C++17 +#endif // C++11 + + public: + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + protected: + // See queue::c for notes on this name. + _Sequence c; + + public: + // XXX removed old def ctor, added def arg to this one to match 14882 + /** + * @brief Default constructor creates no elements. + */ +#if __cplusplus < 201103L + explicit + stack(const _Sequence& __c = _Sequence()) + : c(__c) { } +#else + template::value>::type> + stack() + : c() { } + + explicit + stack(const _Sequence& __c) + : c(__c) { } + + explicit + stack(_Sequence&& __c) + : c(std::move(__c)) { } + + template> + explicit + stack(const _Alloc& __a) + : c(__a) { } + + template> + stack(const _Sequence& __c, const _Alloc& __a) + : c(__c, __a) { } + + template> + stack(_Sequence&& __c, const _Alloc& __a) + : c(std::move(__c), __a) { } + + template> + stack(const stack& __q, const _Alloc& __a) + : c(__q.c, __a) { } + + template> + stack(stack&& __q, const _Alloc& __a) + : c(std::move(__q.c), __a) { } +#endif + + /** + * Returns true if the %stack is empty. + */ + _GLIBCXX_NODISCARD bool + empty() const + { return c.empty(); } + + /** Returns the number of elements in the %stack. */ + size_type + size() const + { return c.size(); } + + /** + * Returns a read/write reference to the data at the first + * element of the %stack. + */ + reference + top() + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %stack. + */ + const_reference + top() const + { + __glibcxx_requires_nonempty(); + return c.back(); + } + + /** + * @brief Add data to the top of the %stack. + * @param __x Data to be added. + * + * This is a typical %stack operation. The function creates an + * element at the top of the %stack and assigns the given data + * to it. The time complexity of the operation depends on the + * underlying sequence. + */ + void + push(const value_type& __x) + { c.push_back(__x); } + +#if __cplusplus >= 201103L + void + push(value_type&& __x) + { c.push_back(std::move(__x)); } + +#if __cplusplus > 201402L + template + decltype(auto) + emplace(_Args&&... __args) + { return c.emplace_back(std::forward<_Args>(__args)...); } +#else + template + void + emplace(_Args&&... __args) + { c.emplace_back(std::forward<_Args>(__args)...); } +#endif +#endif + + /** + * @brief Removes first element. + * + * This is a typical %stack operation. It shrinks the %stack + * by one. The time complexity of the operation depends on the + * underlying sequence. + * + * Note that no data is returned, and if the first element's + * data is needed, it should be retrieved before pop() is + * called. + */ + void + pop() + { + __glibcxx_requires_nonempty(); + c.pop_back(); + } + +#if __cplusplus >= 201103L + void + swap(stack& __s) +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + noexcept(__is_nothrow_swappable<_Sequence>::value) +#else + noexcept(__is_nothrow_swappable<_Tp>::value) +#endif + { + using std::swap; + swap(c, __s.c); + } +#endif // __cplusplus >= 201103L + }; + +#if __cpp_deduction_guides >= 201606 + template> + stack(_Container) -> stack; + + template, + typename = _RequireAllocator<_Allocator>> + stack(_Container, _Allocator) + -> stack; +#endif + + /** + * @brief Stack equality comparison. + * @param __x A %stack. + * @param __y A %stack of the same type as @a __x. + * @return True iff the size and elements of the stacks are equal. + * + * This is an equivalence relation. Complexity and semantics + * depend on the underlying sequence type, but the expected rules + * are: this relation is linear in the size of the sequences, and + * stacks are considered equivalent if their sequences compare + * equal. + */ + template + inline bool + operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __x.c == __y.c; } + + /** + * @brief Stack ordering relation. + * @param __x A %stack. + * @param __y A %stack of the same type as @a x. + * @return True iff @a x is lexicographically less than @a __y. + * + * This is an total ordering relation. Complexity and semantics + * depend on the underlying sequence type, but the expected rules + * are: this relation is linear in the size of the sequences, the + * elements must be comparable with @c <, and + * std::lexicographical_compare() is usually used to make the + * determination. + */ + template + inline bool + operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __x.c < __y.c; } + + /// Based on operator== + template + inline bool + operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return !(__x < __y); } + +#if __cpp_lib_three_way_comparison + template + inline compare_three_way_result_t<_Seq> + operator<=>(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y) + { return __x.c <=> __y.c; } +#endif + +#if __cplusplus >= 201103L + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Seq>::value>::type +#else + void +#endif + swap(stack<_Tp, _Seq>& __x, stack<_Tp, _Seq>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + struct uses_allocator, _Alloc> + : public uses_allocator<_Seq, _Alloc>::type { }; +#endif // __cplusplus >= 201103L + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_STACK_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_tempbuf.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_tempbuf.h new file mode 100755 index 0000000..469e710 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_tempbuf.h @@ -0,0 +1,284 @@ +// Temporary buffer implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_tempbuf.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_TEMPBUF_H +#define _STL_TEMPBUF_H 1 + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + namespace __detail + { + template + inline void + __return_temporary_buffer(_Tp* __p, + size_t __len __attribute__((__unused__))) + { +#if __cpp_sized_deallocation + ::operator delete(__p, __len * sizeof(_Tp)); +#else + ::operator delete(__p); +#endif + } + } + + /** + * @brief Allocates a temporary buffer. + * @param __len The number of objects of type Tp. + * @return See full description. + * + * Reinventing the wheel, but this time with prettier spokes! + * + * This function tries to obtain storage for @c __len adjacent Tp + * objects. The objects themselves are not constructed, of course. + * A pair<> is returned containing the buffer s address and + * capacity (in the units of sizeof(_Tp)), or a pair of 0 values if + * no storage can be obtained. Note that the capacity obtained + * may be less than that requested if the memory is unavailable; + * you should compare len with the .second return value. + * + * Provides the nothrow exception guarantee. + */ + template + pair<_Tp*, ptrdiff_t> + get_temporary_buffer(ptrdiff_t __len) _GLIBCXX_NOEXCEPT + { + const ptrdiff_t __max = + __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); + if (__len > __max) + __len = __max; + + while (__len > 0) + { + _Tp* __tmp = static_cast<_Tp*>(::operator new(__len * sizeof(_Tp), + std::nothrow)); + if (__tmp != 0) + return std::pair<_Tp*, ptrdiff_t>(__tmp, __len); + __len = __len == 1 ? 0 : ((__len + 1) / 2); + } + return std::pair<_Tp*, ptrdiff_t>(static_cast<_Tp*>(0), 0); + } + + /** + * @brief The companion to get_temporary_buffer(). + * @param __p A buffer previously allocated by get_temporary_buffer. + * @return None. + * + * Frees the memory pointed to by __p. + */ + template + inline void + return_temporary_buffer(_Tp* __p) + { ::operator delete(__p); } + + /** + * This class is used in two places: stl_algo.h and ext/memory, + * where it is wrapped as the temporary_buffer class. See + * temporary_buffer docs for more notes. + */ + template + class _Temporary_buffer + { + // concept requirements + __glibcxx_class_requires(_ForwardIterator, _ForwardIteratorConcept) + + public: + typedef _Tp value_type; + typedef value_type* pointer; + typedef pointer iterator; + typedef ptrdiff_t size_type; + + protected: + size_type _M_original_len; + size_type _M_len; + pointer _M_buffer; + + public: + /// As per Table mumble. + size_type + size() const + { return _M_len; } + + /// Returns the size requested by the constructor; may be >size(). + size_type + requested_size() const + { return _M_original_len; } + + /// As per Table mumble. + iterator + begin() + { return _M_buffer; } + + /// As per Table mumble. + iterator + end() + { return _M_buffer + _M_len; } + + /** + * Constructs a temporary buffer of a size somewhere between + * zero and the given length. + */ + _Temporary_buffer(_ForwardIterator __seed, size_type __original_len); + + ~_Temporary_buffer() + { + std::_Destroy(_M_buffer, _M_buffer + _M_len); + std::__detail::__return_temporary_buffer(_M_buffer, _M_len); + } + + private: + // Disable copy constructor and assignment operator. + _Temporary_buffer(const _Temporary_buffer&); + + void + operator=(const _Temporary_buffer&); + }; + + + template + struct __uninitialized_construct_buf_dispatch + { + template + static void + __ucr(_Pointer __first, _Pointer __last, + _ForwardIterator __seed) + { + if (__first == __last) + return; + + _Pointer __cur = __first; + __try + { + std::_Construct(std::__addressof(*__first), + _GLIBCXX_MOVE(*__seed)); + _Pointer __prev = __cur; + ++__cur; + for(; __cur != __last; ++__cur, ++__prev) + std::_Construct(std::__addressof(*__cur), + _GLIBCXX_MOVE(*__prev)); + *__seed = _GLIBCXX_MOVE(*__prev); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_construct_buf_dispatch + { + template + static void + __ucr(_Pointer, _Pointer, _ForwardIterator) { } + }; + + // Constructs objects in the range [first, last). + // Note that while these new objects will take valid values, + // their exact value is not defined. In particular they may + // be 'moved from'. + // + // While *__seed may be altered during this algorithm, it will have + // the same value when the algorithm finishes, unless one of the + // constructions throws. + // + // Requirements: _Pointer::value_type(_Tp&&) is valid. + template + inline void + __uninitialized_construct_buf(_Pointer __first, _Pointer __last, + _ForwardIterator __seed) + { + typedef typename std::iterator_traits<_Pointer>::value_type + _ValueType; + + std::__uninitialized_construct_buf_dispatch< + __has_trivial_constructor(_ValueType)>:: + __ucr(__first, __last, __seed); + } + + template + _Temporary_buffer<_ForwardIterator, _Tp>:: + _Temporary_buffer(_ForwardIterator __seed, size_type __original_len) + : _M_original_len(__original_len), _M_len(0), _M_buffer(0) + { + std::pair __p( + std::get_temporary_buffer(_M_original_len)); + + if (__p.first) + { + __try + { + std::__uninitialized_construct_buf(__p.first, __p.first + __p.second, + __seed); + _M_buffer = __p.first; + _M_len = __p.second; + } + __catch(...) + { + std::__detail::__return_temporary_buffer(__p.first, __p.second); + __throw_exception_again; + } + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_TEMPBUF_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_tree.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_tree.h new file mode 100755 index 0000000..550195a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_tree.h @@ -0,0 +1,2612 @@ +// RB tree implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + */ + +/** @file bits/stl_tree.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{map,set} + */ + +#ifndef _STL_TREE_H +#define _STL_TREE_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include +#if __cplusplus >= 201103L +# include +#endif +#if __cplusplus > 201402L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus > 201103L +# define __cpp_lib_generic_associative_lookup 201304 +#endif + + // Red-black tree class, designed for use in implementing STL + // associative containers (set, multiset, map, and multimap). The + // insertion and deletion algorithms are based on those in Cormen, + // Leiserson, and Rivest, Introduction to Algorithms (MIT Press, + // 1990), except that + // + // (1) the header cell is maintained with links not only to the root + // but also to the leftmost node of the tree, to enable constant + // time begin(), and to the rightmost node of the tree, to enable + // linear time performance when used with the generic set algorithms + // (set_union, etc.) + // + // (2) when a node being deleted has two children its successor node + // is relinked into its place, rather than copied, so that the only + // iterators invalidated are those referring to the deleted node. + + enum _Rb_tree_color { _S_red = false, _S_black = true }; + + struct _Rb_tree_node_base + { + typedef _Rb_tree_node_base* _Base_ptr; + typedef const _Rb_tree_node_base* _Const_Base_ptr; + + _Rb_tree_color _M_color; + _Base_ptr _M_parent; + _Base_ptr _M_left; + _Base_ptr _M_right; + + static _Base_ptr + _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_left != 0) __x = __x->_M_left; + return __x; + } + + static _Const_Base_ptr + _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_left != 0) __x = __x->_M_left; + return __x; + } + + static _Base_ptr + _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_right != 0) __x = __x->_M_right; + return __x; + } + + static _Const_Base_ptr + _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { + while (__x->_M_right != 0) __x = __x->_M_right; + return __x; + } + }; + + // Helper type offering value initialization guarantee on the compare functor. + template + struct _Rb_tree_key_compare + { + _Key_compare _M_key_compare; + + _Rb_tree_key_compare() + _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Key_compare>::value) + : _M_key_compare() + { } + + _Rb_tree_key_compare(const _Key_compare& __comp) + : _M_key_compare(__comp) + { } + +#if __cplusplus >= 201103L + // Copy constructor added for consistency with C++98 mode. + _Rb_tree_key_compare(const _Rb_tree_key_compare&) = default; + + _Rb_tree_key_compare(_Rb_tree_key_compare&& __x) + noexcept(is_nothrow_copy_constructible<_Key_compare>::value) + : _M_key_compare(__x._M_key_compare) + { } +#endif + }; + + // Helper type to manage default initialization of node count and header. + struct _Rb_tree_header + { + _Rb_tree_node_base _M_header; + size_t _M_node_count; // Keeps track of size of tree. + + _Rb_tree_header() _GLIBCXX_NOEXCEPT + { + _M_header._M_color = _S_red; + _M_reset(); + } + +#if __cplusplus >= 201103L + _Rb_tree_header(_Rb_tree_header&& __x) noexcept + { + if (__x._M_header._M_parent != nullptr) + _M_move_data(__x); + else + { + _M_header._M_color = _S_red; + _M_reset(); + } + } +#endif + + void + _M_move_data(_Rb_tree_header& __from) + { + _M_header._M_color = __from._M_header._M_color; + _M_header._M_parent = __from._M_header._M_parent; + _M_header._M_left = __from._M_header._M_left; + _M_header._M_right = __from._M_header._M_right; + _M_header._M_parent->_M_parent = &_M_header; + _M_node_count = __from._M_node_count; + + __from._M_reset(); + } + + void + _M_reset() + { + _M_header._M_parent = 0; + _M_header._M_left = &_M_header; + _M_header._M_right = &_M_header; + _M_node_count = 0; + } + }; + + template + struct _Rb_tree_node : public _Rb_tree_node_base + { + typedef _Rb_tree_node<_Val>* _Link_type; + +#if __cplusplus < 201103L + _Val _M_value_field; + + _Val* + _M_valptr() + { return std::__addressof(_M_value_field); } + + const _Val* + _M_valptr() const + { return std::__addressof(_M_value_field); } +#else + __gnu_cxx::__aligned_membuf<_Val> _M_storage; + + _Val* + _M_valptr() + { return _M_storage._M_ptr(); } + + const _Val* + _M_valptr() const + { return _M_storage._M_ptr(); } +#endif + }; + + _GLIBCXX_PURE _Rb_tree_node_base* + _Rb_tree_increment(_Rb_tree_node_base* __x) throw (); + + _GLIBCXX_PURE const _Rb_tree_node_base* + _Rb_tree_increment(const _Rb_tree_node_base* __x) throw (); + + _GLIBCXX_PURE _Rb_tree_node_base* + _Rb_tree_decrement(_Rb_tree_node_base* __x) throw (); + + _GLIBCXX_PURE const _Rb_tree_node_base* + _Rb_tree_decrement(const _Rb_tree_node_base* __x) throw (); + + template + struct _Rb_tree_iterator + { + typedef _Tp value_type; + typedef _Tp& reference; + typedef _Tp* pointer; + + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + + typedef _Rb_tree_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; + typedef _Rb_tree_node<_Tp>* _Link_type; + + _Rb_tree_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _Rb_tree_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Link_type>(_M_node)->_M_valptr(); } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type> (_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_increment(_M_node); + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_increment(_M_node); + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_decrement(_M_node); + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_decrement(_M_node); + return __tmp; + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if ! __cpp_lib_three_way_comparison + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + _Base_ptr _M_node; + }; + + template + struct _Rb_tree_const_iterator + { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + + typedef _Rb_tree_iterator<_Tp> iterator; + + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + + typedef _Rb_tree_const_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr; + typedef const _Rb_tree_node<_Tp>* _Link_type; + + _Rb_tree_const_iterator() _GLIBCXX_NOEXCEPT + : _M_node() { } + + explicit + _Rb_tree_const_iterator(_Base_ptr __x) _GLIBCXX_NOEXCEPT + : _M_node(__x) { } + + _Rb_tree_const_iterator(const iterator& __it) _GLIBCXX_NOEXCEPT + : _M_node(__it._M_node) { } + + iterator + _M_const_cast() const _GLIBCXX_NOEXCEPT + { return iterator(const_cast(_M_node)); } + + reference + operator*() const _GLIBCXX_NOEXCEPT + { return *static_cast<_Link_type>(_M_node)->_M_valptr(); } + + pointer + operator->() const _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(_M_node)->_M_valptr(); } + + _Self& + operator++() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_increment(_M_node); + return *this; + } + + _Self + operator++(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_increment(_M_node); + return __tmp; + } + + _Self& + operator--() _GLIBCXX_NOEXCEPT + { + _M_node = _Rb_tree_decrement(_M_node); + return *this; + } + + _Self + operator--(int) _GLIBCXX_NOEXCEPT + { + _Self __tmp = *this; + _M_node = _Rb_tree_decrement(_M_node); + return __tmp; + } + + friend bool + operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node == __y._M_node; } + +#if ! __cpp_lib_three_way_comparison + friend bool + operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT + { return __x._M_node != __y._M_node; } +#endif + + _Base_ptr _M_node; + }; + + void + _Rb_tree_insert_and_rebalance(const bool __insert_left, + _Rb_tree_node_base* __x, + _Rb_tree_node_base* __p, + _Rb_tree_node_base& __header) throw (); + + _Rb_tree_node_base* + _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z, + _Rb_tree_node_base& __header) throw (); + +#if __cplusplus > 201402L + template + struct _Rb_tree_merge_helper { }; +#endif + + template > + class _Rb_tree + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Rb_tree_node<_Val> >::other _Node_allocator; + + typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits; + + protected: + typedef _Rb_tree_node_base* _Base_ptr; + typedef const _Rb_tree_node_base* _Const_Base_ptr; + typedef _Rb_tree_node<_Val>* _Link_type; + typedef const _Rb_tree_node<_Val>* _Const_Link_type; + + private: + // Functor recycling a pool of nodes and using allocation once the pool + // is empty. + struct _Reuse_or_alloc_node + { + _Reuse_or_alloc_node(_Rb_tree& __t) + : _M_root(__t._M_root()), _M_nodes(__t._M_rightmost()), _M_t(__t) + { + if (_M_root) + { + _M_root->_M_parent = 0; + + if (_M_nodes->_M_left) + _M_nodes = _M_nodes->_M_left; + } + else + _M_nodes = 0; + } + +#if __cplusplus >= 201103L + _Reuse_or_alloc_node(const _Reuse_or_alloc_node&) = delete; +#endif + + ~_Reuse_or_alloc_node() + { _M_t._M_erase(static_cast<_Link_type>(_M_root)); } + + template + _Link_type + operator()(_GLIBCXX_FWDREF(_Arg) __arg) + { + _Link_type __node = static_cast<_Link_type>(_M_extract()); + if (__node) + { + _M_t._M_destroy_node(__node); + _M_t._M_construct_node(__node, _GLIBCXX_FORWARD(_Arg, __arg)); + return __node; + } + + return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); + } + + private: + _Base_ptr + _M_extract() + { + if (!_M_nodes) + return _M_nodes; + + _Base_ptr __node = _M_nodes; + _M_nodes = _M_nodes->_M_parent; + if (_M_nodes) + { + if (_M_nodes->_M_right == __node) + { + _M_nodes->_M_right = 0; + + if (_M_nodes->_M_left) + { + _M_nodes = _M_nodes->_M_left; + + while (_M_nodes->_M_right) + _M_nodes = _M_nodes->_M_right; + + if (_M_nodes->_M_left) + _M_nodes = _M_nodes->_M_left; + } + } + else // __node is on the left. + _M_nodes->_M_left = 0; + } + else + _M_root = 0; + + return __node; + } + + _Base_ptr _M_root; + _Base_ptr _M_nodes; + _Rb_tree& _M_t; + }; + + // Functor similar to the previous one but without any pool of nodes to + // recycle. + struct _Alloc_node + { + _Alloc_node(_Rb_tree& __t) + : _M_t(__t) { } + + template + _Link_type + operator()(_GLIBCXX_FWDREF(_Arg) __arg) const + { return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); } + + private: + _Rb_tree& _M_t; + }; + + public: + typedef _Key key_type; + typedef _Val value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + _Node_allocator& + _M_get_Node_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Node_allocator& + _M_get_Node_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Node_allocator()); } + + protected: + _Link_type + _M_get_node() + { return _Alloc_traits::allocate(_M_get_Node_allocator(), 1); } + + void + _M_put_node(_Link_type __p) _GLIBCXX_NOEXCEPT + { _Alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); } + +#if __cplusplus < 201103L + void + _M_construct_node(_Link_type __node, const value_type& __x) + { + __try + { get_allocator().construct(__node->_M_valptr(), __x); } + __catch(...) + { + _M_put_node(__node); + __throw_exception_again; + } + } + + _Link_type + _M_create_node(const value_type& __x) + { + _Link_type __tmp = _M_get_node(); + _M_construct_node(__tmp, __x); + return __tmp; + } +#else + template + void + _M_construct_node(_Link_type __node, _Args&&... __args) + { + __try + { + ::new(__node) _Rb_tree_node<_Val>; + _Alloc_traits::construct(_M_get_Node_allocator(), + __node->_M_valptr(), + std::forward<_Args>(__args)...); + } + __catch(...) + { + __node->~_Rb_tree_node<_Val>(); + _M_put_node(__node); + __throw_exception_again; + } + } + + template + _Link_type + _M_create_node(_Args&&... __args) + { + _Link_type __tmp = _M_get_node(); + _M_construct_node(__tmp, std::forward<_Args>(__args)...); + return __tmp; + } +#endif + + void + _M_destroy_node(_Link_type __p) _GLIBCXX_NOEXCEPT + { +#if __cplusplus < 201103L + get_allocator().destroy(__p->_M_valptr()); +#else + _Alloc_traits::destroy(_M_get_Node_allocator(), __p->_M_valptr()); + __p->~_Rb_tree_node<_Val>(); +#endif + } + + void + _M_drop_node(_Link_type __p) _GLIBCXX_NOEXCEPT + { + _M_destroy_node(__p); + _M_put_node(__p); + } + + template + _Link_type + _M_clone_node(_Link_type __x, _NodeGen& __node_gen) + { +#if __cplusplus >= 201103L + using _Vp = typename conditional<_MoveValue, + value_type&&, + const value_type&>::type; +#endif + _Link_type __tmp + = __node_gen(_GLIBCXX_FORWARD(_Vp, *__x->_M_valptr())); + __tmp->_M_color = __x->_M_color; + __tmp->_M_left = 0; + __tmp->_M_right = 0; + return __tmp; + } + + protected: +#if _GLIBCXX_INLINE_VERSION + template +#else + // Unused _Is_pod_comparator is kept as it is part of mangled name. + template +#endif + struct _Rb_tree_impl + : public _Node_allocator + , public _Rb_tree_key_compare<_Key_compare> + , public _Rb_tree_header + { + typedef _Rb_tree_key_compare<_Key_compare> _Base_key_compare; + + _Rb_tree_impl() + _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Node_allocator>::value + && is_nothrow_default_constructible<_Base_key_compare>::value ) + : _Node_allocator() + { } + + _Rb_tree_impl(const _Rb_tree_impl& __x) + : _Node_allocator(_Alloc_traits::_S_select_on_copy(__x)) + , _Base_key_compare(__x._M_key_compare) + , _Rb_tree_header() + { } + +#if __cplusplus < 201103L + _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a) + : _Node_allocator(__a), _Base_key_compare(__comp) + { } +#else + _Rb_tree_impl(_Rb_tree_impl&&) + noexcept( is_nothrow_move_constructible<_Base_key_compare>::value ) + = default; + + explicit + _Rb_tree_impl(_Node_allocator&& __a) + : _Node_allocator(std::move(__a)) + { } + + _Rb_tree_impl(_Rb_tree_impl&& __x, _Node_allocator&& __a) + : _Node_allocator(std::move(__a)), + _Base_key_compare(std::move(__x)), + _Rb_tree_header(std::move(__x)) + { } + + _Rb_tree_impl(const _Key_compare& __comp, _Node_allocator&& __a) + : _Node_allocator(std::move(__a)), _Base_key_compare(__comp) + { } +#endif + }; + + _Rb_tree_impl<_Compare> _M_impl; + + protected: + _Base_ptr& + _M_root() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_parent; } + + _Const_Base_ptr + _M_root() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_parent; } + + _Base_ptr& + _M_leftmost() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_left; } + + _Const_Base_ptr + _M_leftmost() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_left; } + + _Base_ptr& + _M_rightmost() _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_right; } + + _Const_Base_ptr + _M_rightmost() const _GLIBCXX_NOEXCEPT + { return this->_M_impl._M_header._M_right; } + + _Link_type + _M_mbegin() const _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); } + + _Link_type + _M_begin() _GLIBCXX_NOEXCEPT + { return _M_mbegin(); } + + _Const_Link_type + _M_begin() const _GLIBCXX_NOEXCEPT + { + return static_cast<_Const_Link_type> + (this->_M_impl._M_header._M_parent); + } + + _Base_ptr + _M_end() _GLIBCXX_NOEXCEPT + { return &this->_M_impl._M_header; } + + _Const_Base_ptr + _M_end() const _GLIBCXX_NOEXCEPT + { return &this->_M_impl._M_header; } + + static const _Key& + _S_key(_Const_Link_type __x) + { +#if __cplusplus >= 201103L + // If we're asking for the key we're presumably using the comparison + // object, and so this is a good place to sanity check it. + static_assert(__is_invocable<_Compare&, const _Key&, const _Key&>{}, + "comparison object must be invocable " + "with two arguments of key type"); +# if __cplusplus >= 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2542. Missing const requirements for associative containers + if constexpr (__is_invocable<_Compare&, const _Key&, const _Key&>{}) + static_assert( + is_invocable_v, + "comparison object must be invocable as const"); +# endif // C++17 +#endif // C++11 + + return _KeyOfValue()(*__x->_M_valptr()); + } + + static _Link_type + _S_left(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(__x->_M_left); } + + static _Const_Link_type + _S_left(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Const_Link_type>(__x->_M_left); } + + static _Link_type + _S_right(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Link_type>(__x->_M_right); } + + static _Const_Link_type + _S_right(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return static_cast<_Const_Link_type>(__x->_M_right); } + + static const _Key& + _S_key(_Const_Base_ptr __x) + { return _S_key(static_cast<_Const_Link_type>(__x)); } + + static _Base_ptr + _S_minimum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_minimum(__x); } + + static _Const_Base_ptr + _S_minimum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_minimum(__x); } + + static _Base_ptr + _S_maximum(_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_maximum(__x); } + + static _Const_Base_ptr + _S_maximum(_Const_Base_ptr __x) _GLIBCXX_NOEXCEPT + { return _Rb_tree_node_base::_S_maximum(__x); } + + public: + typedef _Rb_tree_iterator iterator; + typedef _Rb_tree_const_iterator const_iterator; + + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + +#if __cplusplus > 201402L + using node_type = _Node_handle<_Key, _Val, _Node_allocator>; + using insert_return_type = _Node_insert_return< + conditional_t, const_iterator, iterator>, + node_type>; +#endif + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_unique_pos(const key_type& __k); + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_equal_pos(const key_type& __k); + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_hint_unique_pos(const_iterator __pos, + const key_type& __k); + + pair<_Base_ptr, _Base_ptr> + _M_get_insert_hint_equal_pos(const_iterator __pos, + const key_type& __k); + + private: +#if __cplusplus >= 201103L + template + iterator + _M_insert_(_Base_ptr __x, _Base_ptr __y, _Arg&& __v, _NodeGen&); + + iterator + _M_insert_node(_Base_ptr __x, _Base_ptr __y, _Link_type __z); + + template + iterator + _M_insert_lower(_Base_ptr __y, _Arg&& __v); + + template + iterator + _M_insert_equal_lower(_Arg&& __x); + + iterator + _M_insert_lower_node(_Base_ptr __p, _Link_type __z); + + iterator + _M_insert_equal_lower_node(_Link_type __z); +#else + template + iterator + _M_insert_(_Base_ptr __x, _Base_ptr __y, + const value_type& __v, _NodeGen&); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 233. Insertion hints in associative containers. + iterator + _M_insert_lower(_Base_ptr __y, const value_type& __v); + + iterator + _M_insert_equal_lower(const value_type& __x); +#endif + + enum { __as_lvalue, __as_rvalue }; + + template + _Link_type + _M_copy(_Link_type, _Base_ptr, _NodeGen&); + + template + _Link_type + _M_copy(const _Rb_tree& __x, _NodeGen& __gen) + { + _Link_type __root = + _M_copy<_MoveValues>(__x._M_mbegin(), _M_end(), __gen); + _M_leftmost() = _S_minimum(__root); + _M_rightmost() = _S_maximum(__root); + _M_impl._M_node_count = __x._M_impl._M_node_count; + return __root; + } + + _Link_type + _M_copy(const _Rb_tree& __x) + { + _Alloc_node __an(*this); + return _M_copy<__as_lvalue>(__x, __an); + } + + void + _M_erase(_Link_type __x); + + iterator + _M_lower_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k); + + const_iterator + _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const; + + iterator + _M_upper_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k); + + const_iterator + _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const; + + public: + // allocation/deallocation +#if __cplusplus < 201103L + _Rb_tree() { } +#else + _Rb_tree() = default; +#endif + + _Rb_tree(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_impl(__comp, _Node_allocator(__a)) { } + + _Rb_tree(const _Rb_tree& __x) + : _M_impl(__x._M_impl) + { + if (__x._M_root() != 0) + _M_root() = _M_copy(__x); + } + +#if __cplusplus >= 201103L + _Rb_tree(const allocator_type& __a) + : _M_impl(_Node_allocator(__a)) + { } + + _Rb_tree(const _Rb_tree& __x, const allocator_type& __a) + : _M_impl(__x._M_impl._M_key_compare, _Node_allocator(__a)) + { + if (__x._M_root() != nullptr) + _M_root() = _M_copy(__x); + } + + _Rb_tree(_Rb_tree&&) = default; + + _Rb_tree(_Rb_tree&& __x, const allocator_type& __a) + : _Rb_tree(std::move(__x), _Node_allocator(__a)) + { } + + private: + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, true_type) + noexcept(is_nothrow_default_constructible<_Compare>::value) + : _M_impl(std::move(__x._M_impl), std::move(__a)) + { } + + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, false_type) + : _M_impl(__x._M_impl._M_key_compare, std::move(__a)) + { + if (__x._M_root() != nullptr) + _M_move_data(__x, false_type{}); + } + + public: + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a) + noexcept( noexcept( + _Rb_tree(std::declval<_Rb_tree&&>(), std::declval<_Node_allocator&&>(), + std::declval())) ) + : _Rb_tree(std::move(__x), std::move(__a), + typename _Alloc_traits::is_always_equal{}) + { } +#endif + + ~_Rb_tree() _GLIBCXX_NOEXCEPT + { _M_erase(_M_begin()); } + + _Rb_tree& + operator=(const _Rb_tree& __x); + + // Accessors. + _Compare + key_comp() const + { return _M_impl._M_key_compare; } + + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_header._M_left); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_header._M_left); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(&this->_M_impl._M_header); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(&this->_M_impl._M_header); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return _M_impl._M_node_count == 0; } + + size_type + size() const _GLIBCXX_NOEXCEPT + { return _M_impl._M_node_count; } + + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _Alloc_traits::max_size(_M_get_Node_allocator()); } + + void + swap(_Rb_tree& __t) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value); + + // Insert/erase. +#if __cplusplus >= 201103L + template + pair + _M_insert_unique(_Arg&& __x); + + template + iterator + _M_insert_equal(_Arg&& __x); + + template + iterator + _M_insert_unique_(const_iterator __pos, _Arg&& __x, _NodeGen&); + + template + iterator + _M_insert_unique_(const_iterator __pos, _Arg&& __x) + { + _Alloc_node __an(*this); + return _M_insert_unique_(__pos, std::forward<_Arg>(__x), __an); + } + + template + iterator + _M_insert_equal_(const_iterator __pos, _Arg&& __x, _NodeGen&); + + template + iterator + _M_insert_equal_(const_iterator __pos, _Arg&& __x) + { + _Alloc_node __an(*this); + return _M_insert_equal_(__pos, std::forward<_Arg>(__x), __an); + } + + template + pair + _M_emplace_unique(_Args&&... __args); + + template + iterator + _M_emplace_equal(_Args&&... __args); + + template + iterator + _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args); + + template + iterator + _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args); + + template + using __same_value_type + = is_same::value_type>; + + template + __enable_if_t<__same_value_type<_InputIterator>::value> + _M_insert_range_unique(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_unique_(end(), *__first, __an); + } + + template + __enable_if_t::value> + _M_insert_range_unique(_InputIterator __first, _InputIterator __last) + { + for (; __first != __last; ++__first) + _M_emplace_unique(*__first); + } + + template + __enable_if_t<__same_value_type<_InputIterator>::value> + _M_insert_range_equal(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_equal_(end(), *__first, __an); + } + + template + __enable_if_t::value> + _M_insert_range_equal(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_emplace_equal(*__first); + } +#else + pair + _M_insert_unique(const value_type& __x); + + iterator + _M_insert_equal(const value_type& __x); + + template + iterator + _M_insert_unique_(const_iterator __pos, const value_type& __x, + _NodeGen&); + + iterator + _M_insert_unique_(const_iterator __pos, const value_type& __x) + { + _Alloc_node __an(*this); + return _M_insert_unique_(__pos, __x, __an); + } + + template + iterator + _M_insert_equal_(const_iterator __pos, const value_type& __x, + _NodeGen&); + iterator + _M_insert_equal_(const_iterator __pos, const value_type& __x) + { + _Alloc_node __an(*this); + return _M_insert_equal_(__pos, __x, __an); + } + + template + void + _M_insert_range_unique(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_unique_(end(), *__first, __an); + } + + template + void + _M_insert_range_equal(_InputIterator __first, _InputIterator __last) + { + _Alloc_node __an(*this); + for (; __first != __last; ++__first) + _M_insert_equal_(end(), *__first, __an); + } +#endif + + private: + void + _M_erase_aux(const_iterator __position); + + void + _M_erase_aux(const_iterator __first, const_iterator __last); + + public: +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { + __glibcxx_assert(__position != end()); + const_iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return __result._M_const_cast(); + } + + // LWG 2059. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { + __glibcxx_assert(__position != end()); + iterator __result = __position; + ++__result; + _M_erase_aux(__position); + return __result; + } +#else + void + erase(iterator __position) + { + __glibcxx_assert(__position != end()); + _M_erase_aux(__position); + } + + void + erase(const_iterator __position) + { + __glibcxx_assert(__position != end()); + _M_erase_aux(__position); + } +#endif + + size_type + erase(const key_type& __x); + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 130. Associative erase should return an iterator. + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { + _M_erase_aux(__first, __last); + return __last._M_const_cast(); + } +#else + void + erase(iterator __first, iterator __last) + { _M_erase_aux(__first, __last); } + + void + erase(const_iterator __first, const_iterator __last) + { _M_erase_aux(__first, __last); } +#endif + + void + clear() _GLIBCXX_NOEXCEPT + { + _M_erase(_M_begin()); + _M_impl._M_reset(); + } + + // Set operations. + iterator + find(const key_type& __k); + + const_iterator + find(const key_type& __k) const; + + size_type + count(const key_type& __k) const; + + iterator + lower_bound(const key_type& __k) + { return _M_lower_bound(_M_begin(), _M_end(), __k); } + + const_iterator + lower_bound(const key_type& __k) const + { return _M_lower_bound(_M_begin(), _M_end(), __k); } + + iterator + upper_bound(const key_type& __k) + { return _M_upper_bound(_M_begin(), _M_end(), __k); } + + const_iterator + upper_bound(const key_type& __k) const + { return _M_upper_bound(_M_begin(), _M_end(), __k); } + + pair + equal_range(const key_type& __k); + + pair + equal_range(const key_type& __k) const; + +#if __cplusplus >= 201402L + template> + iterator + _M_find_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + return __const_this->_M_find_tr(__k)._M_const_cast(); + } + + template> + const_iterator + _M_find_tr(const _Kt& __k) const + { + auto __j = _M_lower_bound_tr(__k); + if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node))) + __j = end(); + return __j; + } + + template> + size_type + _M_count_tr(const _Kt& __k) const + { + auto __p = _M_equal_range_tr(__k); + return std::distance(__p.first, __p.second); + } + + template> + iterator + _M_lower_bound_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + return __const_this->_M_lower_bound_tr(__k)._M_const_cast(); + } + + template> + const_iterator + _M_lower_bound_tr(const _Kt& __k) const + { + auto __x = _M_begin(); + auto __y = _M_end(); + while (__x != 0) + if (!_M_impl._M_key_compare(_S_key(__x), __k)) + { + __y = __x; + __x = _S_left(__x); + } + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template> + iterator + _M_upper_bound_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + return __const_this->_M_upper_bound_tr(__k)._M_const_cast(); + } + + template> + const_iterator + _M_upper_bound_tr(const _Kt& __k) const + { + auto __x = _M_begin(); + auto __y = _M_end(); + while (__x != 0) + if (_M_impl._M_key_compare(__k, _S_key(__x))) + { + __y = __x; + __x = _S_left(__x); + } + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template> + pair + _M_equal_range_tr(const _Kt& __k) + { + const _Rb_tree* __const_this = this; + auto __ret = __const_this->_M_equal_range_tr(__k); + return { __ret.first._M_const_cast(), __ret.second._M_const_cast() }; + } + + template> + pair + _M_equal_range_tr(const _Kt& __k) const + { + auto __low = _M_lower_bound_tr(__k); + auto __high = __low; + auto& __cmp = _M_impl._M_key_compare; + while (__high != end() && !__cmp(__k, _S_key(__high._M_node))) + ++__high; + return { __low, __high }; + } +#endif + + // Debugging. + bool + __rb_verify() const; + +#if __cplusplus >= 201103L + _Rb_tree& + operator=(_Rb_tree&&) + noexcept(_Alloc_traits::_S_nothrow_move() + && is_nothrow_move_assignable<_Compare>::value); + + template + void + _M_assign_unique(_Iterator, _Iterator); + + template + void + _M_assign_equal(_Iterator, _Iterator); + + private: + // Move elements from container with equal allocator. + void + _M_move_data(_Rb_tree& __x, true_type) + { _M_impl._M_move_data(__x._M_impl); } + + // Move elements from container with possibly non-equal allocator, + // which might result in a copy not a move. + void + _M_move_data(_Rb_tree&, false_type); + + // Move assignment from container with equal allocator. + void + _M_move_assign(_Rb_tree&, true_type); + + // Move assignment from container with possibly non-equal allocator, + // which might result in a copy not a move. + void + _M_move_assign(_Rb_tree&, false_type); +#endif + +#if __cplusplus > 201402L + public: + /// Re-insert an extracted node. + insert_return_type + _M_reinsert_node_unique(node_type&& __nh) + { + insert_return_type __ret; + if (__nh.empty()) + __ret.position = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + + auto __res = _M_get_insert_unique_pos(__nh._M_key()); + if (__res.second) + { + __ret.position + = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + __nh._M_ptr = nullptr; + __ret.inserted = true; + } + else + { + __ret.node = std::move(__nh); + __ret.position = iterator(__res.first); + __ret.inserted = false; + } + } + return __ret; + } + + /// Re-insert an extracted node. + iterator + _M_reinsert_node_equal(node_type&& __nh) + { + iterator __ret; + if (__nh.empty()) + __ret = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + auto __res = _M_get_insert_equal_pos(__nh._M_key()); + if (__res.second) + __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + else + __ret = _M_insert_equal_lower_node(__nh._M_ptr); + __nh._M_ptr = nullptr; + } + return __ret; + } + + /// Re-insert an extracted node. + iterator + _M_reinsert_node_hint_unique(const_iterator __hint, node_type&& __nh) + { + iterator __ret; + if (__nh.empty()) + __ret = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + auto __res = _M_get_insert_hint_unique_pos(__hint, __nh._M_key()); + if (__res.second) + { + __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + __nh._M_ptr = nullptr; + } + else + __ret = iterator(__res.first); + } + return __ret; + } + + /// Re-insert an extracted node. + iterator + _M_reinsert_node_hint_equal(const_iterator __hint, node_type&& __nh) + { + iterator __ret; + if (__nh.empty()) + __ret = end(); + else + { + __glibcxx_assert(_M_get_Node_allocator() == *__nh._M_alloc); + auto __res = _M_get_insert_hint_equal_pos(__hint, __nh._M_key()); + if (__res.second) + __ret = _M_insert_node(__res.first, __res.second, __nh._M_ptr); + else + __ret = _M_insert_equal_lower_node(__nh._M_ptr); + __nh._M_ptr = nullptr; + } + return __ret; + } + + /// Extract a node. + node_type + extract(const_iterator __pos) + { + auto __ptr = _Rb_tree_rebalance_for_erase( + __pos._M_const_cast()._M_node, _M_impl._M_header); + --_M_impl._M_node_count; + return { static_cast<_Link_type>(__ptr), _M_get_Node_allocator() }; + } + + /// Extract a node. + node_type + extract(const key_type& __k) + { + node_type __nh; + auto __pos = find(__k); + if (__pos != end()) + __nh = extract(const_iterator(__pos)); + return __nh; + } + + template + using _Compatible_tree + = _Rb_tree<_Key, _Val, _KeyOfValue, _Compare2, _Alloc>; + + template + friend class _Rb_tree_merge_helper; + + /// Merge from a compatible container into one with unique keys. + template + void + _M_merge_unique(_Compatible_tree<_Compare2>& __src) noexcept + { + using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>; + for (auto __i = __src.begin(), __end = __src.end(); __i != __end;) + { + auto __pos = __i++; + auto __res = _M_get_insert_unique_pos(_KeyOfValue()(*__pos)); + if (__res.second) + { + auto& __src_impl = _Merge_helper::_S_get_impl(__src); + auto __ptr = _Rb_tree_rebalance_for_erase( + __pos._M_node, __src_impl._M_header); + --__src_impl._M_node_count; + _M_insert_node(__res.first, __res.second, + static_cast<_Link_type>(__ptr)); + } + } + } + + /// Merge from a compatible container into one with equivalent keys. + template + void + _M_merge_equal(_Compatible_tree<_Compare2>& __src) noexcept + { + using _Merge_helper = _Rb_tree_merge_helper<_Rb_tree, _Compare2>; + for (auto __i = __src.begin(), __end = __src.end(); __i != __end;) + { + auto __pos = __i++; + auto __res = _M_get_insert_equal_pos(_KeyOfValue()(*__pos)); + if (__res.second) + { + auto& __src_impl = _Merge_helper::_S_get_impl(__src); + auto __ptr = _Rb_tree_rebalance_for_erase( + __pos._M_node, __src_impl._M_header); + --__src_impl._M_node_count; + _M_insert_node(__res.first, __res.second, + static_cast<_Link_type>(__ptr)); + } + } + } +#endif // C++17 + + friend bool + operator==(const _Rb_tree& __x, const _Rb_tree& __y) + { + return __x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin()); + } + +#if __cpp_lib_three_way_comparison + friend auto + operator<=>(const _Rb_tree& __x, const _Rb_tree& __y) + { + if constexpr (requires { typename __detail::__synth3way_t<_Val>; }) + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + friend bool + operator<(const _Rb_tree& __x, const _Rb_tree& __y) + { + return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); + } +#endif + }; + + template + inline void + swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) + { __x.swap(__y); } + +#if __cplusplus >= 201103L + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_data(_Rb_tree& __x, false_type) + { + if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) + _M_move_data(__x, true_type()); + else + { + _Alloc_node __an(*this); + _M_root() = + _M_copy::value>(__x, __an); + } + } + + template + inline void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_assign(_Rb_tree& __x, true_type) + { + clear(); + if (__x._M_root() != nullptr) + _M_move_data(__x, true_type()); + std::__alloc_on_move(_M_get_Node_allocator(), + __x._M_get_Node_allocator()); + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_move_assign(_Rb_tree& __x, false_type) + { + if (_M_get_Node_allocator() == __x._M_get_Node_allocator()) + return _M_move_assign(__x, true_type{}); + + // Try to move each node reusing existing nodes and copying __x nodes + // structure. + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + if (__x._M_root() != nullptr) + { + _M_root() = _M_copy<__as_rvalue>(__x, __roan); + __x.clear(); + } + } + + template + inline _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + operator=(_Rb_tree&& __x) + noexcept(_Alloc_traits::_S_nothrow_move() + && is_nothrow_move_assignable<_Compare>::value) + { + _M_impl._M_key_compare = std::move(__x._M_impl._M_key_compare); + _M_move_assign(__x, __bool_constant<_Alloc_traits::_S_nothrow_move()>()); + return *this; + } + + template + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_assign_unique(_Iterator __first, _Iterator __last) + { + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + for (; __first != __last; ++__first) + _M_insert_unique_(end(), *__first, __roan); + } + + template + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_assign_equal(_Iterator __first, _Iterator __last) + { + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + for (; __first != __last; ++__first) + _M_insert_equal_(end(), *__first, __roan); + } +#endif + + template + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + operator=(const _Rb_tree& __x) + { + if (this != &__x) + { + // Note that _Key may be a constant type. +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + auto& __this_alloc = this->_M_get_Node_allocator(); + auto& __that_alloc = __x._M_get_Node_allocator(); + if (!_Alloc_traits::_S_always_equal() + && __this_alloc != __that_alloc) + { + // Replacement allocator cannot free existing storage, we need + // to erase nodes first. + clear(); + std::__alloc_on_copy(__this_alloc, __that_alloc); + } + } +#endif + + _Reuse_or_alloc_node __roan(*this); + _M_impl._M_reset(); + _M_impl._M_key_compare = __x._M_impl._M_key_compare; + if (__x._M_root() != 0) + _M_root() = _M_copy<__as_lvalue>(__x, __roan); + } + + return *this; + } + + template +#if __cplusplus >= 201103L + template +#else + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_(_Base_ptr __x, _Base_ptr __p, +#if __cplusplus >= 201103L + _Arg&& __v, +#else + const _Val& __v, +#endif + _NodeGen& __node_gen) + { + bool __insert_left = (__x != 0 || __p == _M_end() + || _M_impl._M_key_compare(_KeyOfValue()(__v), + _S_key(__p))); + + _Link_type __z = __node_gen(_GLIBCXX_FORWARD(_Arg, __v)); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template +#if __cplusplus >= 201103L + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_lower(_Base_ptr __p, _Arg&& __v) +#else + _M_insert_lower(_Base_ptr __p, const _Val& __v) +#endif + { + bool __insert_left = (__p == _M_end() + || !_M_impl._M_key_compare(_S_key(__p), + _KeyOfValue()(__v))); + + _Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v)); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template +#if __cplusplus >= 201103L + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_equal_lower(_Arg&& __v) +#else + _M_insert_equal_lower(const _Val& __v) +#endif + { + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = !_M_impl._M_key_compare(_S_key(__x), _KeyOfValue()(__v)) ? + _S_left(__x) : _S_right(__x); + } + return _M_insert_lower(__y, _GLIBCXX_FORWARD(_Arg, __v)); + } + + template + template + typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type + _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>:: + _M_copy(_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen) + { + // Structural copy. __x and __p must be non-null. + _Link_type __top = _M_clone_node<_MoveValues>(__x, __node_gen); + __top->_M_parent = __p; + + __try + { + if (__x->_M_right) + __top->_M_right = + _M_copy<_MoveValues>(_S_right(__x), __top, __node_gen); + __p = __top; + __x = _S_left(__x); + + while (__x != 0) + { + _Link_type __y = _M_clone_node<_MoveValues>(__x, __node_gen); + __p->_M_left = __y; + __y->_M_parent = __p; + if (__x->_M_right) + __y->_M_right = _M_copy<_MoveValues>(_S_right(__x), + __y, __node_gen); + __p = __y; + __x = _S_left(__x); + } + } + __catch(...) + { + _M_erase(__top); + __throw_exception_again; + } + return __top; + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase(_Link_type __x) + { + // Erase without rebalancing. + while (__x != 0) + { + _M_erase(_S_right(__x)); + _Link_type __y = _S_left(__x); + _M_drop_node(__x); + __x = __y; + } + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_lower_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k) + { + while (__x != 0) + if (!_M_impl._M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return iterator(__y); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const + { + while (__x != 0) + if (!_M_impl._M_key_compare(_S_key(__x), __k)) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_upper_bound(_Link_type __x, _Base_ptr __y, + const _Key& __k) + { + while (__x != 0) + if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return iterator(__y); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y, + const _Key& __k) const + { + while (__x != 0) + if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + __x = _S_right(__x); + return const_iterator(__y); + } + + template + pair::iterator, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + equal_range(const _Key& __k) + { + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + if (_M_impl._M_key_compare(_S_key(__x), __k)) + __x = _S_right(__x); + else if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + { + _Link_type __xu(__x); + _Base_ptr __yu(__y); + __y = __x, __x = _S_left(__x); + __xu = _S_right(__xu); + return pair(_M_lower_bound(__x, __y, __k), + _M_upper_bound(__xu, __yu, __k)); + } + } + return pair(iterator(__y), + iterator(__y)); + } + + template + pair::const_iterator, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + equal_range(const _Key& __k) const + { + _Const_Link_type __x = _M_begin(); + _Const_Base_ptr __y = _M_end(); + while (__x != 0) + { + if (_M_impl._M_key_compare(_S_key(__x), __k)) + __x = _S_right(__x); + else if (_M_impl._M_key_compare(__k, _S_key(__x))) + __y = __x, __x = _S_left(__x); + else + { + _Const_Link_type __xu(__x); + _Const_Base_ptr __yu(__y); + __y = __x, __x = _S_left(__x); + __xu = _S_right(__xu); + return pair(_M_lower_bound(__x, __y, __k), + _M_upper_bound(__xu, __yu, __k)); + } + } + return pair(const_iterator(__y), + const_iterator(__y)); + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + swap(_Rb_tree& __t) + _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value) + { + if (_M_root() == 0) + { + if (__t._M_root() != 0) + _M_impl._M_move_data(__t._M_impl); + } + else if (__t._M_root() == 0) + __t._M_impl._M_move_data(_M_impl); + else + { + std::swap(_M_root(),__t._M_root()); + std::swap(_M_leftmost(),__t._M_leftmost()); + std::swap(_M_rightmost(),__t._M_rightmost()); + + _M_root()->_M_parent = _M_end(); + __t._M_root()->_M_parent = __t._M_end(); + std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count); + } + // No need to swap header's color as it does not change. + std::swap(this->_M_impl._M_key_compare, __t._M_impl._M_key_compare); + + _Alloc_traits::_S_on_swap(_M_get_Node_allocator(), + __t._M_get_Node_allocator()); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_unique_pos(const key_type& __k) + { + typedef pair<_Base_ptr, _Base_ptr> _Res; + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + bool __comp = true; + while (__x != 0) + { + __y = __x; + __comp = _M_impl._M_key_compare(__k, _S_key(__x)); + __x = __comp ? _S_left(__x) : _S_right(__x); + } + iterator __j = iterator(__y); + if (__comp) + { + if (__j == begin()) + return _Res(__x, __y); + else + --__j; + } + if (_M_impl._M_key_compare(_S_key(__j._M_node), __k)) + return _Res(__x, __y); + return _Res(__j._M_node, 0); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_equal_pos(const key_type& __k) + { + typedef pair<_Base_ptr, _Base_ptr> _Res; + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = _M_impl._M_key_compare(__k, _S_key(__x)) ? + _S_left(__x) : _S_right(__x); + } + return _Res(__x, __y); + } + + template +#if __cplusplus >= 201103L + template +#endif + pair::iterator, bool> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_unique(_Arg&& __v) +#else + _M_insert_unique(const _Val& __v) +#endif + { + typedef pair _Res; + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_unique_pos(_KeyOfValue()(__v)); + + if (__res.second) + { + _Alloc_node __an(*this); + return _Res(_M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), __an), + true); + } + + return _Res(iterator(__res.first), false); + } + + template +#if __cplusplus >= 201103L + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: +#if __cplusplus >= 201103L + _M_insert_equal(_Arg&& __v) +#else + _M_insert_equal(const _Val& __v) +#endif + { + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_equal_pos(_KeyOfValue()(__v)); + _Alloc_node __an(*this); + return _M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), __an); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_hint_unique_pos(const_iterator __position, + const key_type& __k) + { + iterator __pos = __position._M_const_cast(); + typedef pair<_Base_ptr, _Base_ptr> _Res; + + // end() + if (__pos._M_node == _M_end()) + { + if (size() > 0 + && _M_impl._M_key_compare(_S_key(_M_rightmost()), __k)) + return _Res(0, _M_rightmost()); + else + return _M_get_insert_unique_pos(__k); + } + else if (_M_impl._M_key_compare(__k, _S_key(__pos._M_node))) + { + // First, try before... + iterator __before = __pos; + if (__pos._M_node == _M_leftmost()) // begin() + return _Res(_M_leftmost(), _M_leftmost()); + else if (_M_impl._M_key_compare(_S_key((--__before)._M_node), __k)) + { + if (_S_right(__before._M_node) == 0) + return _Res(0, __before._M_node); + else + return _Res(__pos._M_node, __pos._M_node); + } + else + return _M_get_insert_unique_pos(__k); + } + else if (_M_impl._M_key_compare(_S_key(__pos._M_node), __k)) + { + // ... then try after. + iterator __after = __pos; + if (__pos._M_node == _M_rightmost()) + return _Res(0, _M_rightmost()); + else if (_M_impl._M_key_compare(__k, _S_key((++__after)._M_node))) + { + if (_S_right(__pos._M_node) == 0) + return _Res(0, __pos._M_node); + else + return _Res(__after._M_node, __after._M_node); + } + else + return _M_get_insert_unique_pos(__k); + } + else + // Equivalent keys. + return _Res(__pos._M_node, 0); + } + + template +#if __cplusplus >= 201103L + template +#else + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_unique_(const_iterator __position, +#if __cplusplus >= 201103L + _Arg&& __v, +#else + const _Val& __v, +#endif + _NodeGen& __node_gen) + { + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_hint_unique_pos(__position, _KeyOfValue()(__v)); + + if (__res.second) + return _M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), + __node_gen); + return iterator(__res.first); + } + + template + pair::_Base_ptr, + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::_Base_ptr> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_get_insert_hint_equal_pos(const_iterator __position, const key_type& __k) + { + iterator __pos = __position._M_const_cast(); + typedef pair<_Base_ptr, _Base_ptr> _Res; + + // end() + if (__pos._M_node == _M_end()) + { + if (size() > 0 + && !_M_impl._M_key_compare(__k, _S_key(_M_rightmost()))) + return _Res(0, _M_rightmost()); + else + return _M_get_insert_equal_pos(__k); + } + else if (!_M_impl._M_key_compare(_S_key(__pos._M_node), __k)) + { + // First, try before... + iterator __before = __pos; + if (__pos._M_node == _M_leftmost()) // begin() + return _Res(_M_leftmost(), _M_leftmost()); + else if (!_M_impl._M_key_compare(__k, _S_key((--__before)._M_node))) + { + if (_S_right(__before._M_node) == 0) + return _Res(0, __before._M_node); + else + return _Res(__pos._M_node, __pos._M_node); + } + else + return _M_get_insert_equal_pos(__k); + } + else + { + // ... then try after. + iterator __after = __pos; + if (__pos._M_node == _M_rightmost()) + return _Res(0, _M_rightmost()); + else if (!_M_impl._M_key_compare(_S_key((++__after)._M_node), __k)) + { + if (_S_right(__pos._M_node) == 0) + return _Res(0, __pos._M_node); + else + return _Res(__after._M_node, __after._M_node); + } + else + return _Res(0, 0); + } + } + + template +#if __cplusplus >= 201103L + template +#else + template +#endif + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal_(const_iterator __position, +#if __cplusplus >= 201103L + _Arg&& __v, +#else + const _Val& __v, +#endif + _NodeGen& __node_gen) + { + pair<_Base_ptr, _Base_ptr> __res + = _M_get_insert_hint_equal_pos(__position, _KeyOfValue()(__v)); + + if (__res.second) + return _M_insert_(__res.first, __res.second, + _GLIBCXX_FORWARD(_Arg, __v), + __node_gen); + + return _M_insert_equal_lower(_GLIBCXX_FORWARD(_Arg, __v)); + } + +#if __cplusplus >= 201103L + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_node(_Base_ptr __x, _Base_ptr __p, _Link_type __z) + { + bool __insert_left = (__x != 0 || __p == _M_end() + || _M_impl._M_key_compare(_S_key(__z), + _S_key(__p))); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_lower_node(_Base_ptr __p, _Link_type __z) + { + bool __insert_left = (__p == _M_end() + || !_M_impl._M_key_compare(_S_key(__p), + _S_key(__z))); + + _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, + this->_M_impl._M_header); + ++_M_impl._M_node_count; + return iterator(__z); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_insert_equal_lower_node(_Link_type __z) + { + _Link_type __x = _M_begin(); + _Base_ptr __y = _M_end(); + while (__x != 0) + { + __y = __x; + __x = !_M_impl._M_key_compare(_S_key(__x), _S_key(__z)) ? + _S_left(__x) : _S_right(__x); + } + return _M_insert_lower_node(__y, __z); + } + + template + template + pair::iterator, bool> + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_unique(_Args&&... __args) + { + _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); + + __try + { + typedef pair _Res; + auto __res = _M_get_insert_unique_pos(_S_key(__z)); + if (__res.second) + return _Res(_M_insert_node(__res.first, __res.second, __z), true); + + _M_drop_node(__z); + return _Res(iterator(__res.first), false); + } + __catch(...) + { + _M_drop_node(__z); + __throw_exception_again; + } + } + + template + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_equal(_Args&&... __args) + { + _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); + + __try + { + auto __res = _M_get_insert_equal_pos(_S_key(__z)); + return _M_insert_node(__res.first, __res.second, __z); + } + __catch(...) + { + _M_drop_node(__z); + __throw_exception_again; + } + } + + template + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_hint_unique(const_iterator __pos, _Args&&... __args) + { + _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); + + __try + { + auto __res = _M_get_insert_hint_unique_pos(__pos, _S_key(__z)); + + if (__res.second) + return _M_insert_node(__res.first, __res.second, __z); + + _M_drop_node(__z); + return iterator(__res.first); + } + __catch(...) + { + _M_drop_node(__z); + __throw_exception_again; + } + } + + template + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_emplace_hint_equal(const_iterator __pos, _Args&&... __args) + { + _Link_type __z = _M_create_node(std::forward<_Args>(__args)...); + + __try + { + auto __res = _M_get_insert_hint_equal_pos(__pos, _S_key(__z)); + + if (__res.second) + return _M_insert_node(__res.first, __res.second, __z); + + return _M_insert_equal_lower_node(__z); + } + __catch(...) + { + _M_drop_node(__z); + __throw_exception_again; + } + } +#endif + + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase_aux(const_iterator __position) + { + _Link_type __y = + static_cast<_Link_type>(_Rb_tree_rebalance_for_erase + (const_cast<_Base_ptr>(__position._M_node), + this->_M_impl._M_header)); + _M_drop_node(__y); + --_M_impl._M_node_count; + } + + template + void + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _M_erase_aux(const_iterator __first, const_iterator __last) + { + if (__first == begin() && __last == end()) + clear(); + else + while (__first != __last) + _M_erase_aux(__first++); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + erase(const _Key& __x) + { + pair __p = equal_range(__x); + const size_type __old_size = size(); + _M_erase_aux(__p.first, __p.second); + return __old_size - size(); + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + find(const _Key& __k) + { + iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); + return (__j == end() + || _M_impl._M_key_compare(__k, + _S_key(__j._M_node))) ? end() : __j; + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, + _Compare, _Alloc>::const_iterator + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + find(const _Key& __k) const + { + const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k); + return (__j == end() + || _M_impl._M_key_compare(__k, + _S_key(__j._M_node))) ? end() : __j; + } + + template + typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + count(const _Key& __k) const + { + pair __p = equal_range(__k); + const size_type __n = std::distance(__p.first, __p.second); + return __n; + } + + _GLIBCXX_PURE unsigned int + _Rb_tree_black_count(const _Rb_tree_node_base* __node, + const _Rb_tree_node_base* __root) throw (); + + template + bool + _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const + { + if (_M_impl._M_node_count == 0 || begin() == end()) + return _M_impl._M_node_count == 0 && begin() == end() + && this->_M_impl._M_header._M_left == _M_end() + && this->_M_impl._M_header._M_right == _M_end(); + + unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root()); + for (const_iterator __it = begin(); __it != end(); ++__it) + { + _Const_Link_type __x = static_cast<_Const_Link_type>(__it._M_node); + _Const_Link_type __L = _S_left(__x); + _Const_Link_type __R = _S_right(__x); + + if (__x->_M_color == _S_red) + if ((__L && __L->_M_color == _S_red) + || (__R && __R->_M_color == _S_red)) + return false; + + if (__L && _M_impl._M_key_compare(_S_key(__x), _S_key(__L))) + return false; + if (__R && _M_impl._M_key_compare(_S_key(__R), _S_key(__x))) + return false; + + if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len) + return false; + } + + if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root())) + return false; + if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root())) + return false; + return true; + } + +#if __cplusplus > 201402L + // Allow access to internals of compatible _Rb_tree specializations. + template + struct _Rb_tree_merge_helper<_Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>, + _Cmp2> + { + private: + friend class _Rb_tree<_Key, _Val, _Sel, _Cmp1, _Alloc>; + + static auto& + _S_get_impl(_Rb_tree<_Key, _Val, _Sel, _Cmp2, _Alloc>& __tree) + { return __tree._M_impl; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_uninitialized.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_uninitialized.h new file mode 100755 index 0000000..f7b2481 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_uninitialized.h @@ -0,0 +1,1059 @@ +// Raw memory manipulators -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996,1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_uninitialized.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _STL_UNINITIALIZED_H +#define _STL_UNINITIALIZED_H 1 + +#if __cplusplus >= 201103L +#include +#endif + +#include // copy +#include // __alloc_traits + +#if __cplusplus >= 201703L +#include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup memory + * @{ + */ + + /// @cond undocumented + + template + struct __uninitialized_copy + { + template + static _ForwardIterator + __uninit_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + _ForwardIterator __cur = __result; + __try + { + for (; __first != __last; ++__first, (void)++__cur) + std::_Construct(std::__addressof(*__cur), *__first); + return __cur; + } + __catch(...) + { + std::_Destroy(__result, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_copy + { + template + static _ForwardIterator + __uninit_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { return std::copy(__first, __last, __result); } + }; + + /// @endcond + + /** + * @brief Copies the range [first,last) into result. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return __result + (__first - __last) + * + * Like copy(), but does not require an initialized output range. + */ + template + inline _ForwardIterator + uninitialized_copy(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + typedef typename iterator_traits<_InputIterator>::value_type + _ValueType1; + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType2; +#if __cplusplus < 201103L + const bool __assignable = true; +#else + // Trivial types can have deleted copy constructor, but the std::copy + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType2, decltype(*__first)>::value, + "result type must be constructible from value type of input range"); + + typedef typename iterator_traits<_InputIterator>::reference _RefType1; + typedef typename iterator_traits<_ForwardIterator>::reference _RefType2; + // Trivial types can have deleted assignment, so using std::copy + // would be ill-formed. Require assignability before using std::copy: + const bool __assignable = is_assignable<_RefType2, _RefType1>::value; +#endif + + return std::__uninitialized_copy<__is_trivial(_ValueType1) + && __is_trivial(_ValueType2) + && __assignable>:: + __uninit_copy(__first, __last, __result); + } + + /// @cond undocumented + + template + struct __uninitialized_fill + { + template + static void + __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct(std::__addressof(*__cur), __x); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_fill + { + template + static void + __uninit_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { std::fill(__first, __last, __x); } + }; + + /// @endcond + + /** + * @brief Copies the value x into the range [first,last). + * @param __first An input iterator. + * @param __last An input iterator. + * @param __x The source value. + * @return Nothing. + * + * Like fill(), but does not require an initialized output range. + */ + template + inline void + uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; +#if __cplusplus < 201103L + const bool __assignable = true; +#else + // Trivial types can have deleted copy constructor, but the std::fill + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType, const _Tp&>::value, + "result type must be constructible from input type"); + + // Trivial types can have deleted assignment, so using std::fill + // would be ill-formed. Require assignability before using std::fill: + const bool __assignable = is_copy_assignable<_ValueType>::value; +#endif + + std::__uninitialized_fill<__is_trivial(_ValueType) && __assignable>:: + __uninit_fill(__first, __last, __x); + } + + /// @cond undocumented + + template + struct __uninitialized_fill_n + { + template + static _ForwardIterator + __uninit_fill_n(_ForwardIterator __first, _Size __n, + const _Tp& __x) + { + _ForwardIterator __cur = __first; + __try + { + for (; __n > 0; --__n, (void) ++__cur) + std::_Construct(std::__addressof(*__cur), __x); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_fill_n + { + template + static _ForwardIterator + __uninit_fill_n(_ForwardIterator __first, _Size __n, + const _Tp& __x) + { return std::fill_n(__first, __n, __x); } + }; + + /// @endcond + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 1339. uninitialized_fill_n should return the end of its range + /** + * @brief Copies the value x into the range [first,first+n). + * @param __first An input iterator. + * @param __n The number of copies to make. + * @param __x The source value. + * @return Nothing. + * + * Like fill_n(), but does not require an initialized output range. + */ + template + inline _ForwardIterator + uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + // Trivial types do not need a constructor to begin their lifetime, + // so try to use std::fill_n to benefit from its memmove optimization. + // For arbitrary class types and floating point types we can't assume + // that __n > 0 and std::__size_to_integer(__n) > 0 are equivalent, + // so only use std::fill_n when _Size is already an integral type. +#if __cplusplus < 201103L + const bool __can_fill = __is_integer<_Size>::__value; +#else + // Trivial types can have deleted copy constructor, but the std::fill_n + // optimization that uses memmove would happily "copy" them anyway. + static_assert(is_constructible<_ValueType, const _Tp&>::value, + "result type must be constructible from input type"); + + // Trivial types can have deleted assignment, so using std::fill_n + // would be ill-formed. Require assignability before using std::fill_n: + constexpr bool __can_fill + = __and_, is_copy_assignable<_ValueType>>::value; +#endif + return __uninitialized_fill_n<__is_trivial(_ValueType) && __can_fill>:: + __uninit_fill_n(__first, __n, __x); + } + + /// @cond undocumented + + // Extensions: versions of uninitialized_copy, uninitialized_fill, + // and uninitialized_fill_n that take an allocator parameter. + // We dispatch back to the standard versions when we're given the + // default allocator. For nondefault allocators we do not use + // any of the POD optimizations. + + template + _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + { + _ForwardIterator __cur = __result; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __first != __last; ++__first, (void)++__cur) + __traits::construct(__alloc, std::__addressof(*__cur), *__first); + return __cur; + } + __catch(...) + { + std::_Destroy(__result, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline _ForwardIterator + __uninitialized_copy_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, allocator<_Tp>&) + { return std::uninitialized_copy(__first, __last, __result); } + + template + inline _ForwardIterator + __uninitialized_move_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + { + return std::__uninitialized_copy_a(_GLIBCXX_MAKE_MOVE_ITERATOR(__first), + _GLIBCXX_MAKE_MOVE_ITERATOR(__last), + __result, __alloc); + } + + template + inline _ForwardIterator + __uninitialized_move_if_noexcept_a(_InputIterator __first, + _InputIterator __last, + _ForwardIterator __result, + _Allocator& __alloc) + { + return std::__uninitialized_copy_a + (_GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__first), + _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(__last), __result, __alloc); + } + + template + void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __cur != __last; ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur), __x); + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline void + __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last, + const _Tp& __x, allocator<_Tp2>&) + { std::uninitialized_fill(__first, __last, __x); } + + template + _ForwardIterator + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __n > 0; --__n, (void) ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur), __x); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline _ForwardIterator + __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, + const _Tp& __x, allocator<_Tp2>&) + { return std::uninitialized_fill_n(__first, __n, __x); } + + + // Extensions: __uninitialized_copy_move, __uninitialized_move_copy, + // __uninitialized_fill_move, __uninitialized_move_fill. + // All of these algorithms take a user-supplied allocator, which is used + // for construction and destruction. + + // __uninitialized_copy_move + // Copies [first1, last1) into [result, result + (last1 - first1)), and + // move [first2, last2) into + // [result, result + (last1 - first1) + (last2 - first2)). + template + inline _ForwardIterator + __uninitialized_copy_move(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2, + _ForwardIterator __result, + _Allocator& __alloc) + { + _ForwardIterator __mid = std::__uninitialized_copy_a(__first1, __last1, + __result, + __alloc); + __try + { + return std::__uninitialized_move_a(__first2, __last2, __mid, __alloc); + } + __catch(...) + { + std::_Destroy(__result, __mid, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_move_copy + // Moves [first1, last1) into [result, result + (last1 - first1)), and + // copies [first2, last2) into + // [result, result + (last1 - first1) + (last2 - first2)). + template + inline _ForwardIterator + __uninitialized_move_copy(_InputIterator1 __first1, + _InputIterator1 __last1, + _InputIterator2 __first2, + _InputIterator2 __last2, + _ForwardIterator __result, + _Allocator& __alloc) + { + _ForwardIterator __mid = std::__uninitialized_move_a(__first1, __last1, + __result, + __alloc); + __try + { + return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc); + } + __catch(...) + { + std::_Destroy(__result, __mid, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_fill_move + // Fills [result, mid) with x, and moves [first, last) into + // [mid, mid + (last - first)). + template + inline _ForwardIterator + __uninitialized_fill_move(_ForwardIterator __result, _ForwardIterator __mid, + const _Tp& __x, _InputIterator __first, + _InputIterator __last, _Allocator& __alloc) + { + std::__uninitialized_fill_a(__result, __mid, __x, __alloc); + __try + { + return std::__uninitialized_move_a(__first, __last, __mid, __alloc); + } + __catch(...) + { + std::_Destroy(__result, __mid, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_move_fill + // Moves [first1, last1) into [first2, first2 + (last1 - first1)), and + // fills [first2 + (last1 - first1), last2) with x. + template + inline void + __uninitialized_move_fill(_InputIterator __first1, _InputIterator __last1, + _ForwardIterator __first2, + _ForwardIterator __last2, const _Tp& __x, + _Allocator& __alloc) + { + _ForwardIterator __mid2 = std::__uninitialized_move_a(__first1, __last1, + __first2, + __alloc); + __try + { + std::__uninitialized_fill_a(__mid2, __last2, __x, __alloc); + } + __catch(...) + { + std::_Destroy(__first2, __mid2, __alloc); + __throw_exception_again; + } + } + + /// @endcond + +#if __cplusplus >= 201103L + /// @cond undocumented + + // Extensions: __uninitialized_default, __uninitialized_default_n, + // __uninitialized_default_a, __uninitialized_default_n_a. + + template + struct __uninitialized_default_1 + { + template + static void + __uninit_default(_ForwardIterator __first, _ForwardIterator __last) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct(std::__addressof(*__cur)); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_1 + { + template + static void + __uninit_default(_ForwardIterator __first, _ForwardIterator __last) + { + if (__first == __last) + return; + + typename iterator_traits<_ForwardIterator>::value_type* __val + = std::__addressof(*__first); + std::_Construct(__val); + if (++__first != __last) + std::fill(__first, __last, *__val); + } + }; + + template + struct __uninitialized_default_n_1 + { + template + static _ForwardIterator + __uninit_default_n(_ForwardIterator __first, _Size __n) + { + _ForwardIterator __cur = __first; + __try + { + for (; __n > 0; --__n, (void) ++__cur) + std::_Construct(std::__addressof(*__cur)); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_n_1 + { + template + static _ForwardIterator + __uninit_default_n(_ForwardIterator __first, _Size __n) + { + if (__n > 0) + { + typename iterator_traits<_ForwardIterator>::value_type* __val + = std::__addressof(*__first); + std::_Construct(__val); + ++__first; + __first = std::fill_n(__first, __n - 1, *__val); + } + return __first; + } + }; + + // __uninitialized_default + // Fills [first, last) with value-initialized value_types. + template + inline void + __uninitialized_default(_ForwardIterator __first, + _ForwardIterator __last) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // trivial types can have deleted assignment + const bool __assignable = is_copy_assignable<_ValueType>::value; + + std::__uninitialized_default_1<__is_trivial(_ValueType) + && __assignable>:: + __uninit_default(__first, __last); + } + + // __uninitialized_default_n + // Fills [first, first + n) with value-initialized value_types. + template + inline _ForwardIterator + __uninitialized_default_n(_ForwardIterator __first, _Size __n) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + // See uninitialized_fill_n for the conditions for using std::fill_n. + constexpr bool __can_fill + = __and_, is_copy_assignable<_ValueType>>::value; + + return __uninitialized_default_n_1<__is_trivial(_ValueType) + && __can_fill>:: + __uninit_default_n(__first, __n); + } + + + // __uninitialized_default_a + // Fills [first, last) with value_types constructed by the allocator + // alloc, with no arguments passed to the construct call. + template + void + __uninitialized_default_a(_ForwardIterator __first, + _ForwardIterator __last, + _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __cur != __last; ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur)); + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + template + inline void + __uninitialized_default_a(_ForwardIterator __first, + _ForwardIterator __last, + allocator<_Tp>&) + { std::__uninitialized_default(__first, __last); } + + + // __uninitialized_default_n_a + // Fills [first, first + n) with value_types constructed by the allocator + // alloc, with no arguments passed to the construct call. + template + _ForwardIterator + __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, + _Allocator& __alloc) + { + _ForwardIterator __cur = __first; + __try + { + typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; + for (; __n > 0; --__n, (void) ++__cur) + __traits::construct(__alloc, std::__addressof(*__cur)); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur, __alloc); + __throw_exception_again; + } + } + + // __uninitialized_default_n_a specialization for std::allocator, + // which ignores the allocator and value-initializes the elements. + template + inline _ForwardIterator + __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, + allocator<_Tp>&) + { return std::__uninitialized_default_n(__first, __n); } + + template + struct __uninitialized_default_novalue_1 + { + template + static void + __uninit_default_novalue(_ForwardIterator __first, + _ForwardIterator __last) + { + _ForwardIterator __cur = __first; + __try + { + for (; __cur != __last; ++__cur) + std::_Construct_novalue(std::__addressof(*__cur)); + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_novalue_1 + { + template + static void + __uninit_default_novalue(_ForwardIterator __first, + _ForwardIterator __last) + { + } + }; + + template + struct __uninitialized_default_novalue_n_1 + { + template + static _ForwardIterator + __uninit_default_novalue_n(_ForwardIterator __first, _Size __n) + { + _ForwardIterator __cur = __first; + __try + { + for (; __n > 0; --__n, (void) ++__cur) + std::_Construct_novalue(std::__addressof(*__cur)); + return __cur; + } + __catch(...) + { + std::_Destroy(__first, __cur); + __throw_exception_again; + } + } + }; + + template<> + struct __uninitialized_default_novalue_n_1 + { + template + static _ForwardIterator + __uninit_default_novalue_n(_ForwardIterator __first, _Size __n) + { return std::next(__first, __n); } + }; + + // __uninitialized_default_novalue + // Fills [first, last) with default-initialized value_types. + template + inline void + __uninitialized_default_novalue(_ForwardIterator __first, + _ForwardIterator __last) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + std::__uninitialized_default_novalue_1< + is_trivially_default_constructible<_ValueType>::value>:: + __uninit_default_novalue(__first, __last); + } + + // __uninitialized_default_novalue_n + // Fills [first, first + n) with default-initialized value_types. + template + inline _ForwardIterator + __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n) + { + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType; + + return __uninitialized_default_novalue_n_1< + is_trivially_default_constructible<_ValueType>::value>:: + __uninit_default_novalue_n(__first, __n); + } + + template + _ForwardIterator + __uninitialized_copy_n(_InputIterator __first, _Size __n, + _ForwardIterator __result, input_iterator_tag) + { + _ForwardIterator __cur = __result; + __try + { + for (; __n > 0; --__n, (void) ++__first, ++__cur) + std::_Construct(std::__addressof(*__cur), *__first); + return __cur; + } + __catch(...) + { + std::_Destroy(__result, __cur); + __throw_exception_again; + } + } + + template + inline _ForwardIterator + __uninitialized_copy_n(_RandomAccessIterator __first, _Size __n, + _ForwardIterator __result, + random_access_iterator_tag) + { return std::uninitialized_copy(__first, __first + __n, __result); } + + template + pair<_InputIterator, _ForwardIterator> + __uninitialized_copy_n_pair(_InputIterator __first, _Size __n, + _ForwardIterator __result, input_iterator_tag) + { + _ForwardIterator __cur = __result; + __try + { + for (; __n > 0; --__n, (void) ++__first, ++__cur) + std::_Construct(std::__addressof(*__cur), *__first); + return {__first, __cur}; + } + __catch(...) + { + std::_Destroy(__result, __cur); + __throw_exception_again; + } + } + + template + inline pair<_RandomAccessIterator, _ForwardIterator> + __uninitialized_copy_n_pair(_RandomAccessIterator __first, _Size __n, + _ForwardIterator __result, + random_access_iterator_tag) + { + auto __second_res = uninitialized_copy(__first, __first + __n, __result); + auto __first_res = std::next(__first, __n); + return {__first_res, __second_res}; + } + + /// @endcond + + /** + * @brief Copies the range [first,first+n) into result. + * @param __first An input iterator. + * @param __n The number of elements to copy. + * @param __result An output iterator. + * @return __result + __n + * + * Like copy_n(), but does not require an initialized output range. + */ + template + inline _ForwardIterator + uninitialized_copy_n(_InputIterator __first, _Size __n, + _ForwardIterator __result) + { return std::__uninitialized_copy_n(__first, __n, __result, + std::__iterator_category(__first)); } + + /// @cond undocumented + template + inline pair<_InputIterator, _ForwardIterator> + __uninitialized_copy_n_pair(_InputIterator __first, _Size __n, + _ForwardIterator __result) + { + return + std::__uninitialized_copy_n_pair(__first, __n, __result, + std::__iterator_category(__first)); + } + /// @endcond +#endif + +#if __cplusplus >= 201703L +# define __cpp_lib_raw_memory_algorithms 201606L + + /** + * @brief Default-initializes objects in the range [first,last). + * @param __first A forward iterator. + * @param __last A forward iterator. + */ + template + inline void + uninitialized_default_construct(_ForwardIterator __first, + _ForwardIterator __last) + { + __uninitialized_default_novalue(__first, __last); + } + + /** + * @brief Default-initializes objects in the range [first,first+count). + * @param __first A forward iterator. + * @param __count The number of objects to construct. + * @return __first + __count + */ + template + inline _ForwardIterator + uninitialized_default_construct_n(_ForwardIterator __first, _Size __count) + { + return __uninitialized_default_novalue_n(__first, __count); + } + + /** + * @brief Value-initializes objects in the range [first,last). + * @param __first A forward iterator. + * @param __last A forward iterator. + */ + template + inline void + uninitialized_value_construct(_ForwardIterator __first, + _ForwardIterator __last) + { + return __uninitialized_default(__first, __last); + } + + /** + * @brief Value-initializes objects in the range [first,first+count). + * @param __first A forward iterator. + * @param __count The number of objects to construct. + * @return __result + __count + */ + template + inline _ForwardIterator + uninitialized_value_construct_n(_ForwardIterator __first, _Size __count) + { + return __uninitialized_default_n(__first, __count); + } + + /** + * @brief Move-construct from the range [first,last) into result. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __result An output iterator. + * @return __result + (__first - __last) + */ + template + inline _ForwardIterator + uninitialized_move(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + return std::uninitialized_copy + (_GLIBCXX_MAKE_MOVE_ITERATOR(__first), + _GLIBCXX_MAKE_MOVE_ITERATOR(__last), __result); + } + + /** + * @brief Move-construct from the range [first,first+count) into result. + * @param __first An input iterator. + * @param __count The number of objects to initialize. + * @param __result An output iterator. + * @return __result + __count + */ + template + inline pair<_InputIterator, _ForwardIterator> + uninitialized_move_n(_InputIterator __first, _Size __count, + _ForwardIterator __result) + { + auto __res = std::__uninitialized_copy_n_pair + (_GLIBCXX_MAKE_MOVE_ITERATOR(__first), + __count, __result); + return {__res.first.base(), __res.second}; + } +#endif // C++17 + +#if __cplusplus >= 201103L + /// @cond undocumented + + template + inline void + __relocate_object_a(_Tp* __restrict __dest, _Up* __restrict __orig, + _Allocator& __alloc) + noexcept(noexcept(std::allocator_traits<_Allocator>::construct(__alloc, + __dest, std::move(*__orig))) + && noexcept(std::allocator_traits<_Allocator>::destroy( + __alloc, std::__addressof(*__orig)))) + { + typedef std::allocator_traits<_Allocator> __traits; + __traits::construct(__alloc, __dest, std::move(*__orig)); + __traits::destroy(__alloc, std::__addressof(*__orig)); + } + + // This class may be specialized for specific types. + // Also known as is_trivially_relocatable. + template + struct __is_bitwise_relocatable + : is_trivial<_Tp> { }; + + template + inline __enable_if_t::value, _Tp*> + __relocate_a_1(_Tp* __first, _Tp* __last, + _Tp* __result, allocator<_Up>&) noexcept + { + ptrdiff_t __count = __last - __first; + if (__count > 0) + __builtin_memmove(__result, __first, __count * sizeof(_Tp)); + return __result + __count; + } + + template + inline _ForwardIterator + __relocate_a_1(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + noexcept(noexcept(std::__relocate_object_a(std::addressof(*__result), + std::addressof(*__first), + __alloc))) + { + typedef typename iterator_traits<_InputIterator>::value_type + _ValueType; + typedef typename iterator_traits<_ForwardIterator>::value_type + _ValueType2; + static_assert(std::is_same<_ValueType, _ValueType2>::value, + "relocation is only possible for values of the same type"); + _ForwardIterator __cur = __result; + for (; __first != __last; ++__first, (void)++__cur) + std::__relocate_object_a(std::__addressof(*__cur), + std::__addressof(*__first), __alloc); + return __cur; + } + + template + inline _ForwardIterator + __relocate_a(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result, _Allocator& __alloc) + noexcept(noexcept(__relocate_a_1(std::__niter_base(__first), + std::__niter_base(__last), + std::__niter_base(__result), __alloc))) + { + return __relocate_a_1(std::__niter_base(__first), + std::__niter_base(__last), + std::__niter_base(__result), __alloc); + } + + /// @endcond +#endif + + /// @} group memory + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _STL_UNINITIALIZED_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_vector.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_vector.h new file mode 100755 index 0000000..06abf01 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stl_vector.h @@ -0,0 +1,1985 @@ +// Vector implementation -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/stl_vector.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{vector} + */ + +#ifndef _STL_VECTOR_H +#define _STL_VECTOR_H 1 + +#include +#include +#include +#if __cplusplus >= 201103L +#include +#endif +#if __cplusplus > 201703L +# include +#endif + +#include + +#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR +extern "C" void +__sanitizer_annotate_contiguous_container(const void*, const void*, + const void*, const void*); +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// See bits/stl_deque.h's _Deque_base for an explanation. + template + struct _Vector_base + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_Tp>::other _Tp_alloc_type; + typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer + pointer; + + struct _Vector_impl_data + { + pointer _M_start; + pointer _M_finish; + pointer _M_end_of_storage; + + _Vector_impl_data() _GLIBCXX_NOEXCEPT + : _M_start(), _M_finish(), _M_end_of_storage() + { } + +#if __cplusplus >= 201103L + _Vector_impl_data(_Vector_impl_data&& __x) noexcept + : _M_start(__x._M_start), _M_finish(__x._M_finish), + _M_end_of_storage(__x._M_end_of_storage) + { __x._M_start = __x._M_finish = __x._M_end_of_storage = pointer(); } +#endif + + void + _M_copy_data(_Vector_impl_data const& __x) _GLIBCXX_NOEXCEPT + { + _M_start = __x._M_start; + _M_finish = __x._M_finish; + _M_end_of_storage = __x._M_end_of_storage; + } + + void + _M_swap_data(_Vector_impl_data& __x) _GLIBCXX_NOEXCEPT + { + // Do not use std::swap(_M_start, __x._M_start), etc as it loses + // information used by TBAA. + _Vector_impl_data __tmp; + __tmp._M_copy_data(*this); + _M_copy_data(__x); + __x._M_copy_data(__tmp); + } + }; + + struct _Vector_impl + : public _Tp_alloc_type, public _Vector_impl_data + { + _Vector_impl() _GLIBCXX_NOEXCEPT_IF( + is_nothrow_default_constructible<_Tp_alloc_type>::value) + : _Tp_alloc_type() + { } + + _Vector_impl(_Tp_alloc_type const& __a) _GLIBCXX_NOEXCEPT + : _Tp_alloc_type(__a) + { } + +#if __cplusplus >= 201103L + // Not defaulted, to enforce noexcept(true) even when + // !is_nothrow_move_constructible<_Tp_alloc_type>. + _Vector_impl(_Vector_impl&& __x) noexcept + : _Tp_alloc_type(std::move(__x)), _Vector_impl_data(std::move(__x)) + { } + + _Vector_impl(_Tp_alloc_type&& __a) noexcept + : _Tp_alloc_type(std::move(__a)) + { } + + _Vector_impl(_Tp_alloc_type&& __a, _Vector_impl&& __rv) noexcept + : _Tp_alloc_type(std::move(__a)), _Vector_impl_data(std::move(__rv)) + { } +#endif + +#if _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR + template + struct _Asan + { + typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type> + ::size_type size_type; + + static void _S_shrink(_Vector_impl&, size_type) { } + static void _S_on_dealloc(_Vector_impl&) { } + + typedef _Vector_impl& _Reinit; + + struct _Grow + { + _Grow(_Vector_impl&, size_type) { } + void _M_grew(size_type) { } + }; + }; + + // Enable ASan annotations for memory obtained from std::allocator. + template + struct _Asan > + { + typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type> + ::size_type size_type; + + // Adjust ASan annotation for [_M_start, _M_end_of_storage) to + // mark end of valid region as __curr instead of __prev. + static void + _S_adjust(_Vector_impl& __impl, pointer __prev, pointer __curr) + { + __sanitizer_annotate_contiguous_container(__impl._M_start, + __impl._M_end_of_storage, __prev, __curr); + } + + static void + _S_grow(_Vector_impl& __impl, size_type __n) + { _S_adjust(__impl, __impl._M_finish, __impl._M_finish + __n); } + + static void + _S_shrink(_Vector_impl& __impl, size_type __n) + { _S_adjust(__impl, __impl._M_finish + __n, __impl._M_finish); } + + static void + _S_on_dealloc(_Vector_impl& __impl) + { + if (__impl._M_start) + _S_adjust(__impl, __impl._M_finish, __impl._M_end_of_storage); + } + + // Used on reallocation to tell ASan unused capacity is invalid. + struct _Reinit + { + explicit _Reinit(_Vector_impl& __impl) : _M_impl(__impl) + { + // Mark unused capacity as valid again before deallocating it. + _S_on_dealloc(_M_impl); + } + + ~_Reinit() + { + // Mark unused capacity as invalid after reallocation. + if (_M_impl._M_start) + _S_adjust(_M_impl, _M_impl._M_end_of_storage, + _M_impl._M_finish); + } + + _Vector_impl& _M_impl; + +#if __cplusplus >= 201103L + _Reinit(const _Reinit&) = delete; + _Reinit& operator=(const _Reinit&) = delete; +#endif + }; + + // Tell ASan when unused capacity is initialized to be valid. + struct _Grow + { + _Grow(_Vector_impl& __impl, size_type __n) + : _M_impl(__impl), _M_n(__n) + { _S_grow(_M_impl, __n); } + + ~_Grow() { if (_M_n) _S_shrink(_M_impl, _M_n); } + + void _M_grew(size_type __n) { _M_n -= __n; } + +#if __cplusplus >= 201103L + _Grow(const _Grow&) = delete; + _Grow& operator=(const _Grow&) = delete; +#endif + private: + _Vector_impl& _M_impl; + size_type _M_n; + }; + }; + +#define _GLIBCXX_ASAN_ANNOTATE_REINIT \ + typename _Base::_Vector_impl::template _Asan<>::_Reinit const \ + __attribute__((__unused__)) __reinit_guard(this->_M_impl) +#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) \ + typename _Base::_Vector_impl::template _Asan<>::_Grow \ + __attribute__((__unused__)) __grow_guard(this->_M_impl, (n)) +#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) __grow_guard._M_grew(n) +#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) \ + _Base::_Vector_impl::template _Asan<>::_S_shrink(this->_M_impl, n) +#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC \ + _Base::_Vector_impl::template _Asan<>::_S_on_dealloc(this->_M_impl) +#else // ! (_GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR) +#define _GLIBCXX_ASAN_ANNOTATE_REINIT +#define _GLIBCXX_ASAN_ANNOTATE_GROW(n) +#define _GLIBCXX_ASAN_ANNOTATE_GREW(n) +#define _GLIBCXX_ASAN_ANNOTATE_SHRINK(n) +#define _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC +#endif // _GLIBCXX_SANITIZE_STD_ALLOCATOR && _GLIBCXX_SANITIZE_VECTOR + }; + + public: + typedef _Alloc allocator_type; + + _Tp_alloc_type& + _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + const _Tp_alloc_type& + _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT + { return this->_M_impl; } + + allocator_type + get_allocator() const _GLIBCXX_NOEXCEPT + { return allocator_type(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + _Vector_base() = default; +#else + _Vector_base() { } +#endif + + _Vector_base(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _M_impl(__a) { } + + // Kept for ABI compatibility. +#if !_GLIBCXX_INLINE_VERSION + _Vector_base(size_t __n) + : _M_impl() + { _M_create_storage(__n); } +#endif + + _Vector_base(size_t __n, const allocator_type& __a) + : _M_impl(__a) + { _M_create_storage(__n); } + +#if __cplusplus >= 201103L + _Vector_base(_Vector_base&&) = default; + + // Kept for ABI compatibility. +# if !_GLIBCXX_INLINE_VERSION + _Vector_base(_Tp_alloc_type&& __a) noexcept + : _M_impl(std::move(__a)) { } + + _Vector_base(_Vector_base&& __x, const allocator_type& __a) + : _M_impl(__a) + { + if (__x.get_allocator() == __a) + this->_M_impl._M_swap_data(__x._M_impl); + else + { + size_t __n = __x._M_impl._M_finish - __x._M_impl._M_start; + _M_create_storage(__n); + } + } +# endif + + _Vector_base(const allocator_type& __a, _Vector_base&& __x) + : _M_impl(_Tp_alloc_type(__a), std::move(__x._M_impl)) + { } +#endif + + ~_Vector_base() _GLIBCXX_NOEXCEPT + { + _M_deallocate(_M_impl._M_start, + _M_impl._M_end_of_storage - _M_impl._M_start); + } + + public: + _Vector_impl _M_impl; + + pointer + _M_allocate(size_t __n) + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; + return __n != 0 ? _Tr::allocate(_M_impl, __n) : pointer(); + } + + void + _M_deallocate(pointer __p, size_t __n) + { + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Tr; + if (__p) + _Tr::deallocate(_M_impl, __p, __n); + } + + protected: + void + _M_create_storage(size_t __n) + { + this->_M_impl._M_start = this->_M_allocate(__n); + this->_M_impl._M_finish = this->_M_impl._M_start; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + } + }; + + /** + * @brief A standard container which offers fixed time access to + * individual elements in any order. + * + * @ingroup sequences + * + * @tparam _Tp Type of element. + * @tparam _Alloc Allocator type, defaults to allocator<_Tp>. + * + * Meets the requirements of a container, a + * reversible container, and a + * sequence, including the + * optional sequence requirements with the + * %exception of @c push_front and @c pop_front. + * + * In some terminology a %vector can be described as a dynamic + * C-style array, it offers fast and efficient access to individual + * elements in any order and saves the user from worrying about + * memory and size allocation. Subscripting ( @c [] ) access is + * also provided as with C-style arrays. + */ + template > + class vector : protected _Vector_base<_Tp, _Alloc> + { +#ifdef _GLIBCXX_CONCEPT_CHECKS + // Concept requirements. + typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L + __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif + __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif + +#if __cplusplus >= 201103L + static_assert(is_same::type, _Tp>::value, + "std::vector must have a non-const, non-volatile value_type"); +# if __cplusplus > 201703L || defined __STRICT_ANSI__ + static_assert(is_same::value, + "std::vector must have the same value_type as its allocator"); +# endif +#endif + + typedef _Vector_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Alloc_traits; + + public: + typedef _Tp value_type; + typedef typename _Base::pointer pointer; + typedef typename _Alloc_traits::const_pointer const_pointer; + typedef typename _Alloc_traits::reference reference; + typedef typename _Alloc_traits::const_reference const_reference; + typedef __gnu_cxx::__normal_iterator iterator; + typedef __gnu_cxx::__normal_iterator + const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + + private: +#if __cplusplus >= 201103L + static constexpr bool + _S_nothrow_relocate(true_type) + { + return noexcept(std::__relocate_a(std::declval(), + std::declval(), + std::declval(), + std::declval<_Tp_alloc_type&>())); + } + + static constexpr bool + _S_nothrow_relocate(false_type) + { return false; } + + static constexpr bool + _S_use_relocate() + { + // Instantiating std::__relocate_a might cause an error outside the + // immediate context (in __relocate_object_a's noexcept-specifier), + // so only do it if we know the type can be move-inserted into *this. + return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{}); + } + + static pointer + _S_do_relocate(pointer __first, pointer __last, pointer __result, + _Tp_alloc_type& __alloc, true_type) noexcept + { + return std::__relocate_a(__first, __last, __result, __alloc); + } + + static pointer + _S_do_relocate(pointer, pointer, pointer __result, + _Tp_alloc_type&, false_type) noexcept + { return __result; } + + static pointer + _S_relocate(pointer __first, pointer __last, pointer __result, + _Tp_alloc_type& __alloc) noexcept + { + using __do_it = __bool_constant<_S_use_relocate()>; + return _S_do_relocate(__first, __last, __result, __alloc, __do_it{}); + } +#endif // C++11 + + protected: + using _Base::_M_allocate; + using _Base::_M_deallocate; + using _Base::_M_impl; + using _Base::_M_get_Tp_allocator; + + public: + // [23.2.4.1] construct/copy/destroy + // (assign() and get_allocator() are also listed in this section) + + /** + * @brief Creates a %vector with no elements. + */ +#if __cplusplus >= 201103L + vector() = default; +#else + vector() { } +#endif + + /** + * @brief Creates a %vector with no elements. + * @param __a An allocator object. + */ + explicit + vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT + : _Base(__a) { } + +#if __cplusplus >= 201103L + /** + * @brief Creates a %vector with default constructed elements. + * @param __n The number of elements to initially create. + * @param __a An allocator. + * + * This constructor fills the %vector with @a __n default + * constructed elements. + */ + explicit + vector(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(_S_check_init_len(__n, __a), __a) + { _M_default_initialize(__n); } + + /** + * @brief Creates a %vector with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %vector with @a __n copies of @a __value. + */ + vector(size_type __n, const value_type& __value, + const allocator_type& __a = allocator_type()) + : _Base(_S_check_init_len(__n, __a), __a) + { _M_fill_initialize(__n, __value); } +#else + /** + * @brief Creates a %vector with copies of an exemplar element. + * @param __n The number of elements to initially create. + * @param __value An element to copy. + * @param __a An allocator. + * + * This constructor fills the %vector with @a __n copies of @a __value. + */ + explicit + vector(size_type __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(_S_check_init_len(__n, __a), __a) + { _M_fill_initialize(__n, __value); } +#endif + + /** + * @brief %Vector copy constructor. + * @param __x A %vector of identical element and allocator types. + * + * All the elements of @a __x are copied, but any unused capacity in + * @a __x will not be copied + * (i.e. capacity() == size() in the new %vector). + * + * The newly-created %vector uses a copy of the allocator object used + * by @a __x (unless the allocator traits dictate a different object). + */ + vector(const vector& __x) + : _Base(__x.size(), + _Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator())) + { + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + } + +#if __cplusplus >= 201103L + /** + * @brief %Vector move constructor. + * + * The newly-created %vector contains the exact contents of the + * moved instance. + * The contents of the moved instance are a valid, but unspecified + * %vector. + */ + vector(vector&&) noexcept = default; + + /// Copy constructor with alternative allocator + vector(const vector& __x, const allocator_type& __a) + : _Base(__x.size(), __a) + { + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__x.begin(), __x.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + } + + private: + vector(vector&& __rv, const allocator_type& __m, true_type) noexcept + : _Base(__m, std::move(__rv)) + { } + + vector(vector&& __rv, const allocator_type& __m, false_type) + : _Base(__m) + { + if (__rv.get_allocator() == __m) + this->_M_impl._M_swap_data(__rv._M_impl); + else if (!__rv.empty()) + { + this->_M_create_storage(__rv.size()); + this->_M_impl._M_finish = + std::__uninitialized_move_a(__rv.begin(), __rv.end(), + this->_M_impl._M_start, + _M_get_Tp_allocator()); + __rv.clear(); + } + } + + public: + /// Move constructor with alternative allocator + vector(vector&& __rv, const allocator_type& __m) + noexcept( noexcept( + vector(std::declval(), std::declval(), + std::declval())) ) + : vector(std::move(__rv), __m, typename _Alloc_traits::is_always_equal{}) + { } + + /** + * @brief Builds a %vector from an initializer list. + * @param __l An initializer_list. + * @param __a An allocator. + * + * Create a %vector consisting of copies of the elements in the + * initializer_list @a __l. + * + * This will call the element type's copy constructor N times + * (where N is @a __l.size()) and do no memory reallocation. + */ + vector(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + + /** + * @brief Builds a %vector from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __a An allocator. + * + * Create a %vector consisting of copies of the elements from + * [first,last). + * + * If the iterators are forward, bidirectional, or + * random-access, then this will call the elements' copy + * constructor N times (where N is distance(first,last)) and do + * no memory reallocation. But if only input iterators are + * used, then this will do at most 2N calls to the copy + * constructor, and logN memory reallocations. + */ +#if __cplusplus >= 201103L + template> + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#else + template + vector(_InputIterator __first, _InputIterator __last, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } +#endif + + /** + * The dtor only erases the elements, and note that if the + * elements themselves are pointers, the pointed-to memory is + * not touched in any way. Managing the pointer is the user's + * responsibility. + */ + ~vector() _GLIBCXX_NOEXCEPT + { + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_BEFORE_DEALLOC; + } + + /** + * @brief %Vector assignment operator. + * @param __x A %vector of identical element and allocator types. + * + * All the elements of @a __x are copied, but any unused capacity in + * @a __x will not be copied. + * + * Whether the allocator is copied depends on the allocator traits. + */ + vector& + operator=(const vector& __x); + +#if __cplusplus >= 201103L + /** + * @brief %Vector move assignment operator. + * @param __x A %vector of identical element and allocator types. + * + * The contents of @a __x are moved into this %vector (without copying, + * if the allocators permit it). + * Afterwards @a __x is a valid, but unspecified %vector. + * + * Whether the allocator is moved depends on the allocator traits. + */ + vector& + operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) + { + constexpr bool __move_storage = + _Alloc_traits::_S_propagate_on_move_assign() + || _Alloc_traits::_S_always_equal(); + _M_move_assign(std::move(__x), __bool_constant<__move_storage>()); + return *this; + } + + /** + * @brief %Vector list assignment operator. + * @param __l An initializer_list. + * + * This function fills a %vector with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. + */ + vector& + operator=(initializer_list __l) + { + this->_M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + return *this; + } +#endif + + /** + * @brief Assigns a given value to a %vector. + * @param __n Number of elements to be assigned. + * @param __val Value to be assigned. + * + * This function fills a %vector with @a __n copies of the given + * value. Note that the assignment completely changes the + * %vector and that the resulting %vector's size is the same as + * the number of elements assigned. + */ + void + assign(size_type __n, const value_type& __val) + { _M_fill_assign(__n, __val); } + + /** + * @brief Assigns a range to a %vector. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function fills a %vector with copies of the elements in the + * range [__first,__last). + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. + */ +#if __cplusplus >= 201103L + template> + void + assign(_InputIterator __first, _InputIterator __last) + { _M_assign_dispatch(__first, __last, __false_type()); } +#else + template + void + assign(_InputIterator __first, _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_assign_dispatch(__first, __last, _Integral()); + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Assigns an initializer list to a %vector. + * @param __l An initializer_list. + * + * This function fills a %vector with copies of the elements in the + * initializer list @a __l. + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. + */ + void + assign(initializer_list __l) + { + this->_M_assign_aux(__l.begin(), __l.end(), + random_access_iterator_tag()); + } +#endif + + /// Get a copy of the memory allocation object. + using _Base::get_allocator; + + // iterators + /** + * Returns a read/write iterator that points to the first + * element in the %vector. Iteration is done in ordinary + * element order. + */ + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_start); } + + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %vector. Iteration is done in ordinary + * element order. + */ + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_start); } + + /** + * Returns a read/write iterator that points one past the last + * element in the %vector. Iteration is done in ordinary + * element order. + */ + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %vector. Iteration is done in + * ordinary element order. + */ + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read/write reverse iterator that points to the + * last element in the %vector. Iteration is done in reverse + * element order. + */ + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %vector. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + /** + * Returns a read/write reverse iterator that points to one + * before the first element in the %vector. Iteration is done + * in reverse element order. + */ + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %vector. Iteration + * is done in reverse element order. + */ + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + /** + * Returns a read-only (constant) iterator that points to the + * first element in the %vector. Iteration is done in ordinary + * element order. + */ + const_iterator + cbegin() const noexcept + { return const_iterator(this->_M_impl._M_start); } + + /** + * Returns a read-only (constant) iterator that points one past + * the last element in the %vector. Iteration is done in + * ordinary element order. + */ + const_iterator + cend() const noexcept + { return const_iterator(this->_M_impl._M_finish); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to the last element in the %vector. Iteration is done in + * reverse element order. + */ + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + /** + * Returns a read-only (constant) reverse iterator that points + * to one before the first element in the %vector. Iteration + * is done in reverse element order. + */ + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // [23.2.4.2] capacity + /** Returns the number of elements in the %vector. */ + size_type + size() const _GLIBCXX_NOEXCEPT + { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); } + + /** Returns the size() of the largest possible %vector. */ + size_type + max_size() const _GLIBCXX_NOEXCEPT + { return _S_max_size(_M_get_Tp_allocator()); } + +#if __cplusplus >= 201103L + /** + * @brief Resizes the %vector to the specified number of elements. + * @param __new_size Number of elements the %vector should contain. + * + * This function will %resize the %vector to the specified + * number of elements. If the number is smaller than the + * %vector's current size the %vector is truncated, otherwise + * default constructed elements are appended. + */ + void + resize(size_type __new_size) + { + if (__new_size > size()) + _M_default_append(__new_size - size()); + else if (__new_size < size()) + _M_erase_at_end(this->_M_impl._M_start + __new_size); + } + + /** + * @brief Resizes the %vector to the specified number of elements. + * @param __new_size Number of elements the %vector should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %vector to the specified + * number of elements. If the number is smaller than the + * %vector's current size the %vector is truncated, otherwise + * the %vector is extended and new elements are populated with + * given data. + */ + void + resize(size_type __new_size, const value_type& __x) + { + if (__new_size > size()) + _M_fill_insert(end(), __new_size - size(), __x); + else if (__new_size < size()) + _M_erase_at_end(this->_M_impl._M_start + __new_size); + } +#else + /** + * @brief Resizes the %vector to the specified number of elements. + * @param __new_size Number of elements the %vector should contain. + * @param __x Data with which new elements should be populated. + * + * This function will %resize the %vector to the specified + * number of elements. If the number is smaller than the + * %vector's current size the %vector is truncated, otherwise + * the %vector is extended and new elements are populated with + * given data. + */ + void + resize(size_type __new_size, value_type __x = value_type()) + { + if (__new_size > size()) + _M_fill_insert(end(), __new_size - size(), __x); + else if (__new_size < size()) + _M_erase_at_end(this->_M_impl._M_start + __new_size); + } +#endif + +#if __cplusplus >= 201103L + /** A non-binding request to reduce capacity() to size(). */ + void + shrink_to_fit() + { _M_shrink_to_fit(); } +#endif + + /** + * Returns the total number of elements that the %vector can + * hold before needing to allocate more memory. + */ + size_type + capacity() const _GLIBCXX_NOEXCEPT + { return size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); } + + /** + * Returns true if the %vector is empty. (Thus begin() would + * equal end().) + */ + _GLIBCXX_NODISCARD bool + empty() const _GLIBCXX_NOEXCEPT + { return begin() == end(); } + + /** + * @brief Attempt to preallocate enough memory for specified number of + * elements. + * @param __n Number of elements required. + * @throw std::length_error If @a n exceeds @c max_size(). + * + * This function attempts to reserve enough memory for the + * %vector to hold the specified number of elements. If the + * number requested is more than max_size(), length_error is + * thrown. + * + * The advantage of this function is that if optimal code is a + * necessity and the user can determine the number of elements + * that will be required, the user can reserve the memory in + * %advance, and thus prevent a possible reallocation of memory + * and copying of %vector data. + */ + void + reserve(size_type __n); + + // element access + /** + * @brief Subscript access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + reference + operator[](size_type __n) _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return *(this->_M_impl._M_start + __n); + } + + /** + * @brief Subscript access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * + * This operator allows for easy, array-style, data access. + * Note that data access with this operator is unchecked and + * out_of_range lookups are not defined. (For checked lookups + * see at().) + */ + const_reference + operator[](size_type __n) const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_subscript(__n); + return *(this->_M_impl._M_start + __n); + } + + protected: + /// Safety check used only from at(). + void + _M_range_check(size_type __n) const + { + if (__n >= this->size()) + __throw_out_of_range_fmt(__N("vector::_M_range_check: __n " + "(which is %zu) >= this->size() " + "(which is %zu)"), + __n, this->size()); + } + + public: + /** + * @brief Provides access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read/write reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the vector. The + * function throws out_of_range if the check fails. + */ + reference + at(size_type __n) + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * @brief Provides access to the data contained in the %vector. + * @param __n The index of the element for which data should be + * accessed. + * @return Read-only (constant) reference to data. + * @throw std::out_of_range If @a __n is an invalid index. + * + * This function provides for safer data access. The parameter + * is first checked that it is in the range of the vector. The + * function throws out_of_range if the check fails. + */ + const_reference + at(size_type __n) const + { + _M_range_check(__n); + return (*this)[__n]; + } + + /** + * Returns a read/write reference to the data at the first + * element of the %vector. + */ + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read-only (constant) reference to the data at the first + * element of the %vector. + */ + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *begin(); + } + + /** + * Returns a read/write reference to the data at the last + * element of the %vector. + */ + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *(end() - 1); + } + + /** + * Returns a read-only (constant) reference to the data at the + * last element of the %vector. + */ + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + return *(end() - 1); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + // data access + /** + * Returns a pointer such that [data(), data() + size()) is a valid + * range. For a non-empty %vector, data() == &front(). + */ + _Tp* + data() _GLIBCXX_NOEXCEPT + { return _M_data_ptr(this->_M_impl._M_start); } + + const _Tp* + data() const _GLIBCXX_NOEXCEPT + { return _M_data_ptr(this->_M_impl._M_start); } + + // [23.2.4.3] modifiers + /** + * @brief Add data to the end of the %vector. + * @param __x Data to be added. + * + * This is a typical stack operation. The function creates an + * element at the end of the %vector and assigns the given data + * to it. Due to the nature of a %vector this operation can be + * done in constant time if the %vector has preallocated space + * available. + */ + void + push_back(const value_type& __x) + { + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + __x); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + _M_realloc_insert(end(), __x); + } + +#if __cplusplus >= 201103L + void + push_back(value_type&& __x) + { emplace_back(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args); +#endif + + /** + * @brief Removes last element. + * + * This is a typical stack operation. It shrinks the %vector by one. + * + * Note that no data is returned, and if the last element's + * data is needed, it should be retrieved before pop_back() is + * called. + */ + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_requires_nonempty(); + --this->_M_impl._M_finish; + _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); + _GLIBCXX_ASAN_ANNOTATE_SHRINK(1); + } + +#if __cplusplus >= 201103L + /** + * @brief Inserts an object in %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @param __args Arguments. + * @return An iterator that points to the inserted data. + * + * This function will insert an object of type T constructed + * with T(std::forward(args)...) before the specified location. + * Note that this kind of operation could be expensive for a %vector + * and if it is frequently used the user should consider using + * std::list. + */ + template + iterator + emplace(const_iterator __position, _Args&&... __args) + { return _M_emplace_aux(__position, std::forward<_Args>(__args)...); } + + /** + * @brief Inserts given value into %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else + /** + * @brief Inserts given value into %vector before specified iterator. + * @param __position An iterator into the %vector. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given value before + * the specified location. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + iterator + insert(iterator __position, const value_type& __x); +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts given rvalue into %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a copy of the given rvalue before + * the specified location. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + iterator + insert(const_iterator __position, value_type&& __x) + { return _M_insert_rval(__position, std::move(__x)); } + + /** + * @brief Inserts an initializer_list into the %vector. + * @param __position An iterator into the %vector. + * @param __l An initializer_list. + * + * This function will insert copies of the data in the + * initializer_list @a l into the %vector before the location + * specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + iterator + insert(const_iterator __position, initializer_list __l) + { + auto __offset = __position - cbegin(); + _M_range_insert(begin() + __offset, __l.begin(), __l.end(), + std::random_access_iterator_tag()); + return begin() + __offset; + } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a number of copies of given data into the %vector. + * @param __position A const_iterator into the %vector. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator that points to the inserted data. + * + * This function will insert a specified number of copies of + * the given data before the location specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + iterator + insert(const_iterator __position, size_type __n, const value_type& __x) + { + difference_type __offset = __position - cbegin(); + _M_fill_insert(begin() + __offset, __n, __x); + return begin() + __offset; + } +#else + /** + * @brief Inserts a number of copies of given data into the %vector. + * @param __position An iterator into the %vector. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * + * This function will insert a specified number of copies of + * the given data before the location specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + void + insert(iterator __position, size_type __n, const value_type& __x) + { _M_fill_insert(__position, __n, __x); } +#endif + +#if __cplusplus >= 201103L + /** + * @brief Inserts a range into the %vector. + * @param __position A const_iterator into the %vector. + * @param __first An input iterator. + * @param __last An input iterator. + * @return An iterator that points to the inserted data. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %vector before the location specified + * by @a pos. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + difference_type __offset = __position - cbegin(); + _M_insert_dispatch(begin() + __offset, + __first, __last, __false_type()); + return begin() + __offset; + } +#else + /** + * @brief Inserts a range into the %vector. + * @param __position An iterator into the %vector. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range + * [__first,__last) into the %vector before the location specified + * by @a pos. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_insert_dispatch(__position, __first, __last, _Integral()); + } +#endif + + /** + * @brief Remove element at given position. + * @param __position Iterator pointing to element to be erased. + * @return An iterator pointing to the next element (or end()). + * + * This function will erase the element at the given position and thus + * shorten the %vector by one. + * + * Note This operation could be expensive and if it is + * frequently used the user should consider using std::list. + * The user is also cautioned that this function only erases + * the element, and that if the element is itself a pointer, + * the pointed-to memory is not touched in any way. Managing + * the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) + { return _M_erase(begin() + (__position - cbegin())); } +#else + erase(iterator __position) + { return _M_erase(__position); } +#endif + + /** + * @brief Remove a range of elements. + * @param __first Iterator pointing to the first element to be erased. + * @param __last Iterator pointing to one past the last element to be + * erased. + * @return An iterator pointing to the element pointed to by @a __last + * prior to erasing (or end()). + * + * This function will erase the elements in the range + * [__first,__last) and shorten the %vector accordingly. + * + * Note This operation could be expensive and if it is + * frequently used the user should consider using std::list. + * The user is also cautioned that this function only erases + * the elements, and that if the elements themselves are + * pointers, the pointed-to memory is not touched in any way. + * Managing the pointer is the user's responsibility. + */ + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) + { + const auto __beg = begin(); + const auto __cbeg = cbegin(); + return _M_erase(__beg + (__first - __cbeg), __beg + (__last - __cbeg)); + } +#else + erase(iterator __first, iterator __last) + { return _M_erase(__first, __last); } +#endif + + /** + * @brief Swaps data with another %vector. + * @param __x A %vector of the same element and allocator types. + * + * This exchanges the elements between two vectors in constant time. + * (Three pointers, so it should be quite fast.) + * Note that the global std::swap() function is specialized such that + * std::swap(v1,v2) will feed to this function. + * + * Whether the allocators are swapped depends on the allocator traits. + */ + void + swap(vector& __x) _GLIBCXX_NOEXCEPT + { +#if __cplusplus >= 201103L + __glibcxx_assert(_Alloc_traits::propagate_on_container_swap::value + || _M_get_Tp_allocator() == __x._M_get_Tp_allocator()); +#endif + this->_M_impl._M_swap_data(__x._M_impl); + _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } + + /** + * Erases all the elements. Note that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer is + * the user's responsibility. + */ + void + clear() _GLIBCXX_NOEXCEPT + { _M_erase_at_end(this->_M_impl._M_start); } + + protected: + /** + * Memory expansion handler. Uses the member allocation function to + * obtain @a n bytes of memory, and then copies [first,last) into it. + */ + template + pointer + _M_allocate_and_copy(size_type __n, + _ForwardIterator __first, _ForwardIterator __last) + { + pointer __result = this->_M_allocate(__n); + __try + { + std::__uninitialized_copy_a(__first, __last, __result, + _M_get_Tp_allocator()); + return __result; + } + __catch(...) + { + _M_deallocate(__result, __n); + __throw_exception_again; + } + } + + + // Internal constructor functions follow. + + // Called by the range constructor to implement [23.1.1]/9 + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) + { + this->_M_impl._M_start = _M_allocate(_S_check_init_len( + static_cast(__n), _M_get_Tp_allocator())); + this->_M_impl._M_end_of_storage = + this->_M_impl._M_start + static_cast(__n); + _M_fill_initialize(static_cast(__n), __value); + } + + // Called by the range constructor to implement [23.1.1]/9 + template + void + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + _M_range_initialize(__first, __last, + std::__iterator_category(__first)); + } +#endif + + // Called by the second initialize_dispatch above + template + void + _M_range_initialize(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + __try { + for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else + push_back(*__first); +#endif + } __catch(...) { + clear(); + __throw_exception_again; + } + } + + // Called by the second initialize_dispatch above + template + void + _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __n = std::distance(__first, __last); + this->_M_impl._M_start + = this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator())); + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__first, __last, + this->_M_impl._M_start, + _M_get_Tp_allocator()); + } + + // Called by the first initialize_dispatch above and by the + // vector(n,value,a) constructor. + void + _M_fill_initialize(size_type __n, const value_type& __value) + { + this->_M_impl._M_finish = + std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, + _M_get_Tp_allocator()); + } + +#if __cplusplus >= 201103L + // Called by the vector(n) constructor. + void + _M_default_initialize(size_type __n) + { + this->_M_impl._M_finish = + std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, + _M_get_Tp_allocator()); + } +#endif + + // Internal assign functions follow. The *_aux functions do the actual + // assignment work for the range versions. + + // Called by the range assign to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + { _M_fill_assign(__n, __val); } + + // Called by the range assign to implement [23.1.1]/9 + template + void + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { _M_assign_aux(__first, __last, std::__iterator_category(__first)); } + + // Called by the second assign_dispatch above + template + void + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag); + + // Called by the second assign_dispatch above + template + void + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag); + + // Called by assign(n,t), and the range assign when it turns out + // to be the same thing. + void + _M_fill_assign(size_type __n, const value_type& __val); + + // Internal insert functions follow. + + // Called by the range insert to implement [23.1.1]/9 + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 438. Ambiguity in the "do the right thing" clause + template + void + _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, + __true_type) + { _M_fill_insert(__pos, __n, __val); } + + // Called by the range insert to implement [23.1.1]/9 + template + void + _M_insert_dispatch(iterator __pos, _InputIterator __first, + _InputIterator __last, __false_type) + { + _M_range_insert(__pos, __first, __last, + std::__iterator_category(__first)); + } + + // Called by the second insert_dispatch above + template + void + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag); + + // Called by the second insert_dispatch above + template + void + _M_range_insert(iterator __pos, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag); + + // Called by insert(p,n,x), and the range insert when it turns out to be + // the same thing. + void + _M_fill_insert(iterator __pos, size_type __n, const value_type& __x); + +#if __cplusplus >= 201103L + // Called by resize(n). + void + _M_default_append(size_type __n); + + bool + _M_shrink_to_fit(); +#endif + +#if __cplusplus < 201103L + // Called by insert(p,x) + void + _M_insert_aux(iterator __position, const value_type& __x); + + void + _M_realloc_insert(iterator __position, const value_type& __x); +#else + // A value_type object constructed with _Alloc_traits::construct() + // and destroyed with _Alloc_traits::destroy(). + struct _Temporary_value + { + template + explicit + _Temporary_value(vector* __vec, _Args&&... __args) : _M_this(__vec) + { + _Alloc_traits::construct(_M_this->_M_impl, _M_ptr(), + std::forward<_Args>(__args)...); + } + + ~_Temporary_value() + { _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); } + + value_type& + _M_val() { return *_M_ptr(); } + + private: + _Tp* + _M_ptr() { return reinterpret_cast<_Tp*>(&__buf); } + + vector* _M_this; + typename aligned_storage::type __buf; + }; + + // Called by insert(p,x) and other functions when insertion needs to + // reallocate or move existing elements. _Arg is either _Tp& or _Tp. + template + void + _M_insert_aux(iterator __position, _Arg&& __arg); + + template + void + _M_realloc_insert(iterator __position, _Args&&... __args); + + // Either move-construct at the end, or forward to _M_insert_aux. + iterator + _M_insert_rval(const_iterator __position, value_type&& __v); + + // Try to emplace at the end, otherwise forward to _M_insert_aux. + template + iterator + _M_emplace_aux(const_iterator __position, _Args&&... __args); + + // Emplacing an rvalue of the correct type can use _M_insert_rval. + iterator + _M_emplace_aux(const_iterator __position, value_type&& __v) + { return _M_insert_rval(__position, std::move(__v)); } +#endif + + // Called by _M_fill_insert, _M_insert_aux etc. + size_type + _M_check_len(size_type __n, const char* __s) const + { + if (max_size() - size() < __n) + __throw_length_error(__N(__s)); + + const size_type __len = size() + (std::max)(size(), __n); + return (__len < size() || __len > max_size()) ? max_size() : __len; + } + + // Called by constructors to check initial size. + static size_type + _S_check_init_len(size_type __n, const allocator_type& __a) + { + if (__n > _S_max_size(_Tp_alloc_type(__a))) + __throw_length_error( + __N("cannot create std::vector larger than max_size()")); + return __n; + } + + static size_type + _S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT + { + // std::distance(begin(), end()) cannot be greater than PTRDIFF_MAX, + // and realistically we can't store more than PTRDIFF_MAX/sizeof(T) + // (even if std::allocator_traits::max_size says we can). + const size_t __diffmax + = __gnu_cxx::__numeric_traits::__max / sizeof(_Tp); + const size_t __allocmax = _Alloc_traits::max_size(__a); + return (std::min)(__diffmax, __allocmax); + } + + // Internal erase functions follow. + + // Called by erase(q1,q2), clear(), resize(), _M_fill_assign, + // _M_assign_aux. + void + _M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT + { + if (size_type __n = this->_M_impl._M_finish - __pos) + { + std::_Destroy(__pos, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish = __pos; + _GLIBCXX_ASAN_ANNOTATE_SHRINK(__n); + } + } + + iterator + _M_erase(iterator __position); + + iterator + _M_erase(iterator __first, iterator __last); + +#if __cplusplus >= 201103L + private: + // Constant-time move assignment when source object's memory can be + // moved, either because the source's allocator will move too + // or because the allocators are equal. + void + _M_move_assign(vector&& __x, true_type) noexcept + { + vector __tmp(get_allocator()); + this->_M_impl._M_swap_data(__x._M_impl); + __tmp._M_impl._M_swap_data(__x._M_impl); + std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator()); + } + + // Do move assignment when it might not be possible to move source + // object's memory, resulting in a linear-time operation. + void + _M_move_assign(vector&& __x, false_type) + { + if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator()) + _M_move_assign(std::move(__x), true_type()); + else + { + // The rvalue's allocator cannot be moved and is not equal, + // so we need to individually move each element. + this->_M_assign_aux(std::make_move_iterator(__x.begin()), + std::make_move_iterator(__x.end()), + std::random_access_iterator_tag()); + __x.clear(); + } + } +#endif + + template + _Up* + _M_data_ptr(_Up* __ptr) const _GLIBCXX_NOEXCEPT + { return __ptr; } + +#if __cplusplus >= 201103L + template + typename std::pointer_traits<_Ptr>::element_type* + _M_data_ptr(_Ptr __ptr) const + { return empty() ? nullptr : std::__to_address(__ptr); } +#else + template + _Up* + _M_data_ptr(_Up* __ptr) _GLIBCXX_NOEXCEPT + { return __ptr; } + + template + value_type* + _M_data_ptr(_Ptr __ptr) + { return empty() ? (value_type*)0 : __ptr.operator->(); } + + template + const value_type* + _M_data_ptr(_Ptr __ptr) const + { return empty() ? (const value_type*)0 : __ptr.operator->(); } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> vector<_ValT, _Allocator>; +#endif + + /** + * @brief Vector equality comparison. + * @param __x A %vector. + * @param __y A %vector of the same type as @a __x. + * @return True iff the size and elements of the vectors are equal. + * + * This is an equivalence relation. It is linear in the size of the + * vectors. Vectors are considered equivalent if their sizes are equal, + * and if corresponding elements compare equal. + */ + template + inline bool + operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return (__x.size() == __y.size() + && std::equal(__x.begin(), __x.end(), __y.begin())); } + +#if __cpp_lib_three_way_comparison + /** + * @brief Vector ordering relation. + * @param __x A `vector`. + * @param __y A `vector` of the same type as `__x`. + * @return A value indicating whether `__x` is less than, equal to, + * greater than, or incomparable with `__y`. + * + * See `std::lexicographical_compare_three_way()` for how the determination + * is made. This operator is used to synthesize relational operators like + * `<` and `>=` etc. + */ + template + inline __detail::__synth3way_t<_Tp> + operator<=>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { + return std::lexicographical_compare_three_way(__x.begin(), __x.end(), + __y.begin(), __y.end(), + __detail::__synth3way); + } +#else + /** + * @brief Vector ordering relation. + * @param __x A %vector. + * @param __y A %vector of the same type as @a __x. + * @return True iff @a __x is lexicographically less than @a __y. + * + * This is a total ordering relation. It is linear in the size of the + * vectors. The elements must be comparable with @c <. + * + * See std::lexicographical_compare() for how the determination is made. + */ + template + inline bool + operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return std::lexicographical_compare(__x.begin(), __x.end(), + __y.begin(), __y.end()); } + + /// Based on operator== + template + inline bool + operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return !(__x == __y); } + + /// Based on operator< + template + inline bool + operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return __y < __x; } + + /// Based on operator< + template + inline bool + operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return !(__y < __x); } + + /// Based on operator< + template + inline bool + operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return !(__x < __y); } +#endif // three-way comparison + + /// See std::vector::swap(). + template + inline void + swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // vector into a variant, but only if move assignment cannot throw. + template + struct _Never_valueless_alt<_GLIBCXX_STD_C::vector<_Tp, _Alloc>> + : std::is_nothrow_move_assignable<_GLIBCXX_STD_C::vector<_Tp, _Alloc>> + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _STL_VECTOR_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stream_iterator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stream_iterator.h new file mode 100755 index 0000000..fd8920b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stream_iterator.h @@ -0,0 +1,257 @@ +// Stream iterators + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/stream_iterator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _STREAM_ITERATOR_H +#define _STREAM_ITERATOR_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + + /// Provides input iterator semantics for streams. + template, typename _Dist = ptrdiff_t> + class istream_iterator + : public iterator + { + public: + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_istream<_CharT, _Traits> istream_type; + + private: + istream_type* _M_stream; + _Tp _M_value; + // This bool becomes false at end-of-stream. It should be sufficient to + // check _M_stream != nullptr instead, but historically we did not set + // _M_stream to null when reaching the end, so we need to keep this flag. + bool _M_ok; + + public: + /// Construct end of input stream iterator. + _GLIBCXX_CONSTEXPR istream_iterator() + : _M_stream(0), _M_value(), _M_ok(false) {} + + /// Construct start of input stream iterator. + istream_iterator(istream_type& __s) + : _M_stream(std::__addressof(__s)), _M_ok(true) + { _M_read(); } + + istream_iterator(const istream_iterator& __obj) + : _M_stream(__obj._M_stream), _M_value(__obj._M_value), + _M_ok(__obj._M_ok) + { } + +#if __cplusplus > 201703L && __cpp_lib_concepts + constexpr + istream_iterator(default_sentinel_t) + noexcept(is_nothrow_default_constructible_v<_Tp>) + : istream_iterator() { } +#endif + +#if __cplusplus >= 201103L + istream_iterator& operator=(const istream_iterator&) = default; + ~istream_iterator() = default; +#endif + + const _Tp& + operator*() const + { + __glibcxx_requires_cond(_M_ok, + _M_message(__gnu_debug::__msg_deref_istream) + ._M_iterator(*this)); + return _M_value; + } + + const _Tp* + operator->() const { return std::__addressof((operator*())); } + + istream_iterator& + operator++() + { + __glibcxx_requires_cond(_M_ok, + _M_message(__gnu_debug::__msg_inc_istream) + ._M_iterator(*this)); + _M_read(); + return *this; + } + + istream_iterator + operator++(int) + { + __glibcxx_requires_cond(_M_ok, + _M_message(__gnu_debug::__msg_inc_istream) + ._M_iterator(*this)); + istream_iterator __tmp = *this; + _M_read(); + return __tmp; + } + + private: + bool + _M_equal(const istream_iterator& __x) const + { + // Ideally this would just return _M_stream == __x._M_stream, + // but code compiled with old versions never sets _M_stream to null. + return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); + } + + void + _M_read() + { + if (_M_stream && !(*_M_stream >> _M_value)) + { + _M_stream = 0; + _M_ok = false; + } + } + + /// Return true if the iterators refer to the same stream, + /// or are both at end-of-stream. + friend bool + operator==(const istream_iterator& __x, const istream_iterator& __y) + { return __x._M_equal(__y); } + + /// Return true if the iterators refer to different streams, + /// or if one is at end-of-stream and the other is not. + friend bool + operator!=(const istream_iterator& __x, const istream_iterator& __y) + { return !__x._M_equal(__y); } + +#if __cplusplus > 201703L && __cpp_lib_concepts + friend bool + operator==(const istream_iterator& __i, default_sentinel_t) + { return !__i._M_stream; } +#endif + }; + + /** + * @brief Provides output iterator semantics for streams. + * + * This class provides an iterator to write to an ostream. The type Tp is + * the only type written by this iterator and there must be an + * operator<<(Tp) defined. + * + * @tparam _Tp The type to write to the ostream. + * @tparam _CharT The ostream char_type. + * @tparam _Traits The ostream char_traits. + */ + template > + class ostream_iterator + : public iterator + { + public: + ///@{ + /// Public typedef +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; +#endif + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + ///@} + + private: + ostream_type* _M_stream; + const _CharT* _M_string; + + public: +#if __cplusplus > 201703L + constexpr ostream_iterator() noexcept + : _M_stream(nullptr), _M_string(nullptr) { } +#endif + + /// Construct from an ostream. + ostream_iterator(ostream_type& __s) + : _M_stream(std::__addressof(__s)), _M_string(0) {} + + /** + * Construct from an ostream. + * + * The delimiter string @a c is written to the stream after every Tp + * written to the stream. The delimiter is not copied, and thus must + * not be destroyed while this iterator is in use. + * + * @param __s Underlying ostream to write to. + * @param __c CharT delimiter string to insert. + */ + ostream_iterator(ostream_type& __s, const _CharT* __c) + : _M_stream(std::__addressof(__s)), _M_string(__c) { } + + /// Copy constructor. + ostream_iterator(const ostream_iterator& __obj) + : _M_stream(__obj._M_stream), _M_string(__obj._M_string) { } + +#if __cplusplus >= 201103L + ostream_iterator& operator=(const ostream_iterator&) = default; +#endif + + /// Writes @a value to underlying ostream using operator<<. If + /// constructed with delimiter string, writes delimiter to ostream. + ostream_iterator& + operator=(const _Tp& __value) + { + __glibcxx_requires_cond(_M_stream != 0, + _M_message(__gnu_debug::__msg_output_ostream) + ._M_iterator(*this)); + *_M_stream << __value; + if (_M_string) + *_M_stream << _M_string; + return *this; + } + + ostream_iterator& + operator*() + { return *this; } + + ostream_iterator& + operator++() + { return *this; } + + ostream_iterator& + operator++(int) + { return *this; } + }; + + /// @} group iterators + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/streambuf.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/streambuf.tcc new file mode 100755 index 0000000..cbcfb0c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/streambuf.tcc @@ -0,0 +1,175 @@ +// Stream buffer classes -*- C++ -*- + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/streambuf.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{streambuf} + */ + +// +// ISO C++ 14882: 27.5 Stream buffers +// + +#ifndef _STREAMBUF_TCC +#define _STREAMBUF_TCC 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + streamsize + basic_streambuf<_CharT, _Traits>:: + xsgetn(char_type* __s, streamsize __n) + { + streamsize __ret = 0; + while (__ret < __n) + { + const streamsize __buf_len = this->egptr() - this->gptr(); + if (__buf_len) + { + const streamsize __remaining = __n - __ret; + const streamsize __len = std::min(__buf_len, __remaining); + traits_type::copy(__s, this->gptr(), __len); + __ret += __len; + __s += __len; + this->__safe_gbump(__len); + } + + if (__ret < __n) + { + const int_type __c = this->uflow(); + if (!traits_type::eq_int_type(__c, traits_type::eof())) + { + traits_type::assign(*__s++, traits_type::to_char_type(__c)); + ++__ret; + } + else + break; + } + } + return __ret; + } + + template + streamsize + basic_streambuf<_CharT, _Traits>:: + xsputn(const char_type* __s, streamsize __n) + { + streamsize __ret = 0; + while (__ret < __n) + { + const streamsize __buf_len = this->epptr() - this->pptr(); + if (__buf_len) + { + const streamsize __remaining = __n - __ret; + const streamsize __len = std::min(__buf_len, __remaining); + traits_type::copy(this->pptr(), __s, __len); + __ret += __len; + __s += __len; + this->__safe_pbump(__len); + } + + if (__ret < __n) + { + int_type __c = this->overflow(traits_type::to_int_type(*__s)); + if (!traits_type::eq_int_type(__c, traits_type::eof())) + { + ++__ret; + ++__s; + } + else + break; + } + } + return __ret; + } + + // Conceivably, this could be used to implement buffer-to-buffer + // copies, if this was ever desired in an un-ambiguous way by the + // standard. + template + streamsize + __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin, + basic_streambuf<_CharT, _Traits>* __sbout, + bool& __ineof) + { + streamsize __ret = 0; + __ineof = true; + typename _Traits::int_type __c = __sbin->sgetc(); + while (!_Traits::eq_int_type(__c, _Traits::eof())) + { + __c = __sbout->sputc(_Traits::to_char_type(__c)); + if (_Traits::eq_int_type(__c, _Traits::eof())) + { + __ineof = false; + break; + } + ++__ret; + __c = __sbin->snextc(); + } + return __ret; + } + + template + inline streamsize + __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin, + basic_streambuf<_CharT, _Traits>* __sbout) + { + bool __ineof; + return __copy_streambufs_eof(__sbin, __sbout, __ineof); + } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template class basic_streambuf; + extern template + streamsize + __copy_streambufs(basic_streambuf*, + basic_streambuf*); + extern template + streamsize + __copy_streambufs_eof(basic_streambuf*, + basic_streambuf*, bool&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template class basic_streambuf; + extern template + streamsize + __copy_streambufs(basic_streambuf*, + basic_streambuf*); + extern template + streamsize + __copy_streambufs_eof(basic_streambuf*, + basic_streambuf*, bool&); +#endif +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/streambuf_iterator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/streambuf_iterator.h new file mode 100755 index 0000000..cda596a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/streambuf_iterator.h @@ -0,0 +1,506 @@ +// Streambuf iterators + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/streambuf_iterator.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{iterator} + */ + +#ifndef _STREAMBUF_ITERATOR_H +#define _STREAMBUF_ITERATOR_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup iterators + * @{ + */ + + // 24.5.3 Template class istreambuf_iterator + /// Provides input iterator semantics for streambufs. + template + class istreambuf_iterator + : public iterator + { + public: + // Types: + ///@{ + /// Public typedefs +#if __cplusplus < 201103L + typedef _CharT& reference; // Changed to _CharT by LWG 445 +#elif __cplusplus > 201703L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3188. istreambuf_iterator::pointer should not be unspecified + using pointer = void; +#endif + + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename _Traits::int_type int_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_istream<_CharT, _Traits> istream_type; + ///@} + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + ostreambuf_iterator<_CharT2> >::__type + copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + ostreambuf_iterator<_CharT2>); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_move_a2(istreambuf_iterator<_CharT2>, + istreambuf_iterator<_CharT2>, _CharT2*); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + _CharT2*>::__type + __copy_n_a(istreambuf_iterator<_CharT2>, _Size, _CharT2*, bool); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + istreambuf_iterator<_CharT2> >::__type + find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + const _CharT2&); + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + void>::__type + advance(istreambuf_iterator<_CharT2>&, _Distance); + + private: + // 24.5.3 istreambuf_iterator + // p 1 + // If the end of stream is reached (streambuf_type::sgetc() + // returns traits_type::eof()), the iterator becomes equal to + // the "end of stream" iterator value. + // NB: This implementation assumes the "end of stream" value + // is EOF, or -1. + mutable streambuf_type* _M_sbuf; + int_type _M_c; + + public: + /// Construct end of input stream iterator. + _GLIBCXX_CONSTEXPR istreambuf_iterator() _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(0), _M_c(traits_type::eof()) { } + +#if __cplusplus > 201703L && __cpp_lib_concepts + constexpr istreambuf_iterator(default_sentinel_t) noexcept + : istreambuf_iterator() { } +#endif + +#if __cplusplus >= 201103L + istreambuf_iterator(const istreambuf_iterator&) noexcept = default; + + ~istreambuf_iterator() = default; +#endif + + /// Construct start of input stream iterator. + istreambuf_iterator(istream_type& __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { } + + /// Construct start of streambuf iterator. + istreambuf_iterator(streambuf_type* __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s), _M_c(traits_type::eof()) { } + +#if __cplusplus >= 201103L + istreambuf_iterator& + operator=(const istreambuf_iterator&) noexcept = default; +#endif + + /// Return the current character pointed to by iterator. This returns + /// streambuf.sgetc(). It cannot be assigned. NB: The result of + /// operator*() on an end of stream is undefined. + char_type + operator*() const + { + int_type __c = _M_get(); + +#ifdef _GLIBCXX_DEBUG_PEDANTIC + // Dereferencing a past-the-end istreambuf_iterator is a + // libstdc++ extension + __glibcxx_requires_cond(!_S_is_eof(__c), + _M_message(__gnu_debug::__msg_deref_istreambuf) + ._M_iterator(*this)); +#endif + return traits_type::to_char_type(__c); + } + + /// Advance the iterator. Calls streambuf.sbumpc(). + istreambuf_iterator& + operator++() + { + __glibcxx_requires_cond(_M_sbuf && + (!_S_is_eof(_M_c) || !_S_is_eof(_M_sbuf->sgetc())), + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(*this)); + + _M_sbuf->sbumpc(); + _M_c = traits_type::eof(); + return *this; + } + + /// Advance the iterator. Calls streambuf.sbumpc(). + istreambuf_iterator + operator++(int) + { + __glibcxx_requires_cond(_M_sbuf && + (!_S_is_eof(_M_c) || !_S_is_eof(_M_sbuf->sgetc())), + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(*this)); + + istreambuf_iterator __old = *this; + __old._M_c = _M_sbuf->sbumpc(); + _M_c = traits_type::eof(); + return __old; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 110 istreambuf_iterator::equal not const + // NB: there is also number 111 (NAD) relevant to this function. + /// Return true both iterators are end or both are not end. + bool + equal(const istreambuf_iterator& __b) const + { return _M_at_eof() == __b._M_at_eof(); } + + private: + int_type + _M_get() const + { + int_type __ret = _M_c; + if (_M_sbuf && _S_is_eof(__ret) && _S_is_eof(__ret = _M_sbuf->sgetc())) + _M_sbuf = 0; + return __ret; + } + + bool + _M_at_eof() const + { return _S_is_eof(_M_get()); } + + static bool + _S_is_eof(int_type __c) + { + const int_type __eof = traits_type::eof(); + return traits_type::eq_int_type(__c, __eof); + } + +#if __cplusplus > 201703L && __cpp_lib_concepts + friend bool + operator==(const istreambuf_iterator& __i, default_sentinel_t __s) + { return __i._M_at_eof(); } +#endif + }; + + template + inline bool + operator==(const istreambuf_iterator<_CharT, _Traits>& __a, + const istreambuf_iterator<_CharT, _Traits>& __b) + { return __a.equal(__b); } + + template + inline bool + operator!=(const istreambuf_iterator<_CharT, _Traits>& __a, + const istreambuf_iterator<_CharT, _Traits>& __b) + { return !__a.equal(__b); } + + /// Provides output iterator semantics for streambufs. + template + class ostreambuf_iterator + : public iterator + { + public: + // Types: + ///@{ + /// Public typedefs +#if __cplusplus > 201703L + using difference_type = ptrdiff_t; +#endif + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + ///@} + + template + friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, + ostreambuf_iterator<_CharT2> >::__type + copy(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, + ostreambuf_iterator<_CharT2>); + + private: + streambuf_type* _M_sbuf; + bool _M_failed; + + public: + +#if __cplusplus > 201703L + constexpr + ostreambuf_iterator() noexcept + : _M_sbuf(nullptr), _M_failed(true) { } +#endif + + /// Construct output iterator from ostream. + ostreambuf_iterator(ostream_type& __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { } + + /// Construct output iterator from streambuf. + ostreambuf_iterator(streambuf_type* __s) _GLIBCXX_USE_NOEXCEPT + : _M_sbuf(__s), _M_failed(!_M_sbuf) { } + + /// Write character to streambuf. Calls streambuf.sputc(). + ostreambuf_iterator& + operator=(_CharT __c) + { + if (!_M_failed && + _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof())) + _M_failed = true; + return *this; + } + + /// Return *this. + ostreambuf_iterator& + operator*() + { return *this; } + + /// Return *this. + ostreambuf_iterator& + operator++(int) + { return *this; } + + /// Return *this. + ostreambuf_iterator& + operator++() + { return *this; } + + /// Return true if previous operator=() failed. + bool + failed() const _GLIBCXX_USE_NOEXCEPT + { return _M_failed; } + + ostreambuf_iterator& + _M_put(const _CharT* __ws, streamsize __len) + { + if (__builtin_expect(!_M_failed, true) + && __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len, + false)) + _M_failed = true; + return *this; + } + }; + + // Overloads for streambuf iterators. + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + copy(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, + ostreambuf_iterator<_CharT> __result) + { + if (__first._M_sbuf && !__last._M_sbuf && !__result._M_failed) + { + bool __ineof; + __copy_streambufs_eof(__first._M_sbuf, __result._M_sbuf, __ineof); + if (!__ineof) + __result._M_failed = true; + } + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_move_a2(_CharT* __first, _CharT* __last, + ostreambuf_iterator<_CharT> __result) + { + const streamsize __num = __last - __first; + if (__num > 0) + __result._M_put(__first, __num); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + ostreambuf_iterator<_CharT> >::__type + __copy_move_a2(const _CharT* __first, const _CharT* __last, + ostreambuf_iterator<_CharT> __result) + { + const streamsize __num = __last - __first; + if (__num > 0) + __result._M_put(__first, __num); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_move_a2(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, _CharT* __result) + { + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + + if (__first._M_sbuf && !__last._M_sbuf) + { + streambuf_type* __sb = __first._M_sbuf; + int_type __c = __sb->sgetc(); + while (!traits_type::eq_int_type(__c, traits_type::eof())) + { + const streamsize __n = __sb->egptr() - __sb->gptr(); + if (__n > 1) + { + traits_type::copy(__result, __sb->gptr(), __n); + __sb->__safe_gbump(__n); + __result += __n; + __c = __sb->underflow(); + } + else + { + *__result++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); + } + } + } + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + _CharT*>::__type + __copy_n_a(istreambuf_iterator<_CharT> __it, _Size __n, _CharT* __result, + bool __strict __attribute__((__unused__))) + { + if (__n == 0) + return __result; + + __glibcxx_requires_cond(__it._M_sbuf, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__it)); + _CharT* __beg = __result; + __result += __it._M_sbuf->sgetn(__beg, __n); + __glibcxx_requires_cond(!__strict || __result - __beg == __n, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__it)); + return __result; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + istreambuf_iterator<_CharT> >::__type + find(istreambuf_iterator<_CharT> __first, + istreambuf_iterator<_CharT> __last, const _CharT& __val) + { + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + const int_type __eof = traits_type::eof(); + + if (__first._M_sbuf && !__last._M_sbuf) + { + const int_type __ival = traits_type::to_int_type(__val); + streambuf_type* __sb = __first._M_sbuf; + int_type __c = __sb->sgetc(); + while (!traits_type::eq_int_type(__c, __eof) + && !traits_type::eq_int_type(__c, __ival)) + { + streamsize __n = __sb->egptr() - __sb->gptr(); + if (__n > 1) + { + const _CharT* __p = traits_type::find(__sb->gptr(), + __n, __val); + if (__p) + __n = __p - __sb->gptr(); + __sb->__safe_gbump(__n); + __c = __sb->sgetc(); + } + else + __c = __sb->snextc(); + } + + __first._M_c = __eof; + } + + return __first; + } + + template + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, + void>::__type + advance(istreambuf_iterator<_CharT>& __i, _Distance __n) + { + if (__n == 0) + return; + + __glibcxx_assert(__n > 0); + __glibcxx_requires_cond(!__i._M_at_eof(), + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__i)); + + typedef istreambuf_iterator<_CharT> __is_iterator_type; + typedef typename __is_iterator_type::traits_type traits_type; + typedef typename __is_iterator_type::streambuf_type streambuf_type; + typedef typename traits_type::int_type int_type; + const int_type __eof = traits_type::eof(); + + streambuf_type* __sb = __i._M_sbuf; + while (__n > 0) + { + streamsize __size = __sb->egptr() - __sb->gptr(); + if (__size > __n) + { + __sb->__safe_gbump(__n); + break; + } + + __sb->__safe_gbump(__size); + __n -= __size; + if (traits_type::eq_int_type(__sb->underflow(), __eof)) + { + __glibcxx_requires_cond(__n == 0, + _M_message(__gnu_debug::__msg_inc_istreambuf) + ._M_iterator(__i)); + break; + } + } + + __i._M_c = __eof; + } + +/// @} group iterators + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/string_view.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/string_view.tcc new file mode 100755 index 0000000..efb0ede --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/string_view.tcc @@ -0,0 +1,241 @@ +// Components for manipulating non-owning sequences of characters -*- C++ -*- + +// Copyright (C) 2013-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/string_view.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string_view} + */ + +// +// N3762 basic_string_view library +// + +#ifndef _GLIBCXX_STRING_VIEW_TCC +#define _GLIBCXX_STRING_VIEW_TCC 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find(const _CharT* __str, size_type __pos, size_type __n) const noexcept + { + __glibcxx_requires_string_len(__str, __n); + + if (__n == 0) + return __pos <= _M_len ? __pos : npos; + if (__pos >= _M_len) + return npos; + + const _CharT __elem0 = __str[0]; + const _CharT* __first = _M_str + __pos; + const _CharT* const __last = _M_str + _M_len; + size_type __len = _M_len - __pos; + + while (__len >= __n) + { + // Find the first occurrence of __elem0: + __first = traits_type::find(__first, __len - __n + 1, __elem0); + if (!__first) + return npos; + // Compare the full strings from the first occurrence of __elem0. + // We already know that __first[0] == __s[0] but compare them again + // anyway because __s is probably aligned, which helps memcmp. + if (traits_type::compare(__first, __str, __n) == 0) + return __first - _M_str; + __len = __last - ++__first; + } + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find(_CharT __c, size_type __pos) const noexcept + { + size_type __ret = npos; + if (__pos < this->_M_len) + { + const size_type __n = this->_M_len - __pos; + const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c); + if (__p) + __ret = __p - this->_M_str; + } + return __ret; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept + { + __glibcxx_requires_string_len(__str, __n); + + if (__n <= this->_M_len) + { + __pos = std::min(size_type(this->_M_len - __n), __pos); + do + { + if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0) + return __pos; + } + while (__pos-- > 0); + } + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + rfind(_CharT __c, size_type __pos) const noexcept + { + size_type __size = this->_M_len; + if (__size > 0) + { + if (--__size > __pos) + __size = __pos; + for (++__size; __size-- > 0; ) + if (traits_type::eq(this->_M_str[__size], __c)) + return __size; + } + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find_first_of(const _CharT* __str, size_type __pos, + size_type __n) const noexcept + { + __glibcxx_requires_string_len(__str, __n); + for (; __n && __pos < this->_M_len; ++__pos) + { + const _CharT* __p = traits_type::find(__str, __n, + this->_M_str[__pos]); + if (__p) + return __pos; + } + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find_last_of(const _CharT* __str, size_type __pos, + size_type __n) const noexcept + { + __glibcxx_requires_string_len(__str, __n); + size_type __size = this->size(); + if (__size && __n) + { + if (--__size > __pos) + __size = __pos; + do + { + if (traits_type::find(__str, __n, this->_M_str[__size])) + return __size; + } + while (__size-- != 0); + } + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find_first_not_of(const _CharT* __str, size_type __pos, + size_type __n) const noexcept + { + __glibcxx_requires_string_len(__str, __n); + for (; __pos < this->_M_len; ++__pos) + if (!traits_type::find(__str, __n, this->_M_str[__pos])) + return __pos; + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find_first_not_of(_CharT __c, size_type __pos) const noexcept + { + for (; __pos < this->_M_len; ++__pos) + if (!traits_type::eq(this->_M_str[__pos], __c)) + return __pos; + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find_last_not_of(const _CharT* __str, size_type __pos, + size_type __n) const noexcept + { + __glibcxx_requires_string_len(__str, __n); + size_type __size = this->_M_len; + if (__size) + { + if (--__size > __pos) + __size = __pos; + do + { + if (!traits_type::find(__str, __n, this->_M_str[__size])) + return __size; + } + while (__size--); + } + return npos; + } + + template + constexpr typename basic_string_view<_CharT, _Traits>::size_type + basic_string_view<_CharT, _Traits>:: + find_last_not_of(_CharT __c, size_type __pos) const noexcept + { + size_type __size = this->_M_len; + if (__size) + { + if (--__size > __pos) + __size = __pos; + do + { + if (!traits_type::eq(this->_M_str[__size], __c)) + return __size; + } + while (__size--); + } + return npos; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // __cplusplus <= 201402L + +#endif // _GLIBCXX_STRING_VIEW_TCC diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stringfwd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stringfwd.h new file mode 100755 index 0000000..7cb92eb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/stringfwd.h @@ -0,0 +1,104 @@ +// Forward declarations -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/stringfwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{string} + */ + +// +// ISO C++ 14882: 21 Strings library +// + +#ifndef _STRINGFWD_H +#define _STRINGFWD_H 1 + +#pragma GCC system_header + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup strings Strings + * + * @{ + */ + + template + struct char_traits; + + template<> struct char_traits; + +#ifdef _GLIBCXX_USE_WCHAR_T + template<> struct char_traits; +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + template<> struct char_traits; +#endif + +#if __cplusplus >= 201103L + template<> struct char_traits; + template<> struct char_traits; +#endif + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + template, + typename _Alloc = allocator<_CharT> > + class basic_string; + +_GLIBCXX_END_NAMESPACE_CXX11 + + /// A string of @c char + typedef basic_string string; + +#ifdef _GLIBCXX_USE_WCHAR_T + /// A string of @c wchar_t + typedef basic_string wstring; +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + /// A string of @c char8_t + typedef basic_string u8string; +#endif + +#if __cplusplus >= 201103L + /// A string of @c char16_t + typedef basic_string u16string; + + /// A string of @c char32_t + typedef basic_string u32string; +#endif + + /** @} */ + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _STRINGFWD_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/this_thread_sleep.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/this_thread_sleep.h new file mode 100755 index 0000000..bdcd0cd --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/this_thread_sleep.h @@ -0,0 +1,119 @@ +// std::this_thread::sleep_for/until declarations -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/this_thread_sleep.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{thread} + */ + +#ifndef _GLIBCXX_THIS_THREAD_SLEEP_H +#define _GLIBCXX_THIS_THREAD_SLEEP_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L +#include + +#include // std::chrono::* + +#ifdef _GLIBCXX_USE_NANOSLEEP +# include // errno, EINTR +# include // nanosleep +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @addtogroup threads + * @{ + */ + + /** @namespace std::this_thread + * @brief ISO C++ 2011 namespace for interacting with the current thread + * + * C++11 30.3.2 [thread.thread.this] Namespace this_thread. + */ + namespace this_thread + { +#ifndef _GLIBCXX_NO_SLEEP + +#ifndef _GLIBCXX_USE_NANOSLEEP + void + __sleep_for(chrono::seconds, chrono::nanoseconds); +#endif + + /// this_thread::sleep_for + template + inline void + sleep_for(const chrono::duration<_Rep, _Period>& __rtime) + { + if (__rtime <= __rtime.zero()) + return; + auto __s = chrono::duration_cast(__rtime); + auto __ns = chrono::duration_cast(__rtime - __s); +#ifdef _GLIBCXX_USE_NANOSLEEP + struct ::timespec __ts = + { + static_cast(__s.count()), + static_cast(__ns.count()) + }; + while (::nanosleep(&__ts, &__ts) == -1 && errno == EINTR) + { } +#else + __sleep_for(__s, __ns); +#endif + } + + /// this_thread::sleep_until + template + inline void + sleep_until(const chrono::time_point<_Clock, _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + auto __now = _Clock::now(); + if (_Clock::is_steady) + { + if (__now < __atime) + sleep_for(__atime - __now); + return; + } + while (__now < __atime) + { + sleep_for(__atime - __now); + __now = _Clock::now(); + } + } + } // namespace this_thread +#endif // ! NO_SLEEP + + /// @} + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++11 + +#endif // _GLIBCXX_THIS_THREAD_SLEEP_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uniform_int_dist.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uniform_int_dist.h new file mode 100755 index 0000000..2d83524 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uniform_int_dist.h @@ -0,0 +1,456 @@ +// Class template uniform_int_distribution -*- C++ -*- + +// Copyright (C) 2009-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** + * @file bits/uniform_int_dist.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{random} + */ + +#ifndef _GLIBCXX_BITS_UNIFORM_INT_DIST_H +#define _GLIBCXX_BITS_UNIFORM_INT_DIST_H + +#include +#include +#if __cplusplus > 201703L +# include +#endif +#include // __glibcxx_function_requires + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#ifdef __cpp_lib_concepts + /// Requirements for a uniform random bit generator. + template + concept uniform_random_bit_generator + = invocable<_Gen&> && unsigned_integral> + && requires + { + { _Gen::min() } -> same_as>; + { _Gen::max() } -> same_as>; + requires bool_constant<(_Gen::min() < _Gen::max())>::value; + }; +#endif + + namespace __detail + { + // Determine whether number is a power of two. + // This is true for zero, which is OK because we want _Power_of_2(n+1) + // to be true if n==numeric_limits<_Tp>::max() and so n+1 wraps around. + template + constexpr bool + _Power_of_2(_Tp __x) + { + return ((__x - 1) & __x) == 0; + } + } + + /** + * @brief Uniform discrete distribution for random numbers. + * A discrete random distribution on the range @f$[min, max]@f$ with equal + * probability throughout the range. + */ + template + class uniform_int_distribution + { + static_assert(std::is_integral<_IntType>::value, + "template argument must be an integral type"); + + public: + /** The type of the range of the distribution. */ + typedef _IntType result_type; + /** Parameter type. */ + struct param_type + { + typedef uniform_int_distribution<_IntType> distribution_type; + + param_type() : param_type(0) { } + + explicit + param_type(_IntType __a, + _IntType __b = __gnu_cxx::__int_traits<_IntType>::__max) + : _M_a(__a), _M_b(__b) + { + __glibcxx_assert(_M_a <= _M_b); + } + + result_type + a() const + { return _M_a; } + + result_type + b() const + { return _M_b; } + + friend bool + operator==(const param_type& __p1, const param_type& __p2) + { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; } + + friend bool + operator!=(const param_type& __p1, const param_type& __p2) + { return !(__p1 == __p2); } + + private: + _IntType _M_a; + _IntType _M_b; + }; + + public: + /** + * @brief Constructs a uniform distribution object. + */ + uniform_int_distribution() : uniform_int_distribution(0) { } + + /** + * @brief Constructs a uniform distribution object. + */ + explicit + uniform_int_distribution(_IntType __a, + _IntType __b + = __gnu_cxx::__int_traits<_IntType>::__max) + : _M_param(__a, __b) + { } + + explicit + uniform_int_distribution(const param_type& __p) + : _M_param(__p) + { } + + /** + * @brief Resets the distribution state. + * + * Does nothing for the uniform integer distribution. + */ + void + reset() { } + + result_type + a() const + { return _M_param.a(); } + + result_type + b() const + { return _M_param.b(); } + + /** + * @brief Returns the parameter set of the distribution. + */ + param_type + param() const + { return _M_param; } + + /** + * @brief Sets the parameter set of the distribution. + * @param __param The new parameter set of the distribution. + */ + void + param(const param_type& __param) + { _M_param = __param; } + + /** + * @brief Returns the inclusive lower bound of the distribution range. + */ + result_type + min() const + { return this->a(); } + + /** + * @brief Returns the inclusive upper bound of the distribution range. + */ + result_type + max() const + { return this->b(); } + + /** + * @brief Generating functions. + */ + template + result_type + operator()(_UniformRandomBitGenerator& __urng) + { return this->operator()(__urng, _M_param); } + + template + result_type + operator()(_UniformRandomBitGenerator& __urng, + const param_type& __p); + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng) + { this->__generate(__f, __t, __urng, _M_param); } + + template + void + __generate(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + template + void + __generate(result_type* __f, result_type* __t, + _UniformRandomBitGenerator& __urng, + const param_type& __p) + { this->__generate_impl(__f, __t, __urng, __p); } + + /** + * @brief Return true if two uniform integer distributions have + * the same parameters. + */ + friend bool + operator==(const uniform_int_distribution& __d1, + const uniform_int_distribution& __d2) + { return __d1._M_param == __d2._M_param; } + + private: + template + void + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng, + const param_type& __p); + + param_type _M_param; + + // Lemire's nearly divisionless algorithm. + // Returns an unbiased random number from __g downscaled to [0,__range) + // using an unsigned type _Wp twice as wide as unsigned type _Up. + template + static _Up + _S_nd(_Urbg& __g, _Up __range) + { + using _Up_traits = __gnu_cxx::__int_traits<_Up>; + using _Wp_traits = __gnu_cxx::__int_traits<_Wp>; + static_assert(!_Up_traits::__is_signed, "U must be unsigned"); + static_assert(!_Wp_traits::__is_signed, "W must be unsigned"); + static_assert(_Wp_traits::__digits == (2 * _Up_traits::__digits), + "W must be twice as wide as U"); + + // reference: Fast Random Integer Generation in an Interval + // ACM Transactions on Modeling and Computer Simulation 29 (1), 2019 + // https://arxiv.org/abs/1805.10941 + _Wp __product = _Wp(__g()) * _Wp(__range); + _Up __low = _Up(__product); + if (__low < __range) + { + _Up __threshold = -__range % __range; + while (__low < __threshold) + { + __product = _Wp(__g()) * _Wp(__range); + __low = _Up(__product); + } + } + return __product >> _Up_traits::__digits; + } + }; + + template + template + typename uniform_int_distribution<_IntType>::result_type + uniform_int_distribution<_IntType>:: + operator()(_UniformRandomBitGenerator& __urng, + const param_type& __param) + { + typedef typename _UniformRandomBitGenerator::result_type _Gresult_type; + typedef typename make_unsigned::type __utype; + typedef typename common_type<_Gresult_type, __utype>::type __uctype; + + constexpr __uctype __urngmin = _UniformRandomBitGenerator::min(); + constexpr __uctype __urngmax = _UniformRandomBitGenerator::max(); + static_assert( __urngmin < __urngmax, + "Uniform random bit generator must define min() < max()"); + constexpr __uctype __urngrange = __urngmax - __urngmin; + + const __uctype __urange + = __uctype(__param.b()) - __uctype(__param.a()); + + __uctype __ret; + if (__urngrange > __urange) + { + // downscaling + + const __uctype __uerange = __urange + 1; // __urange can be zero + +#if defined __UINT64_TYPE__ && defined __UINT32_TYPE__ +#if __SIZEOF_INT128__ + if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT64_MAX__) + { + // __urng produces values that use exactly 64-bits, + // so use 128-bit integers to downscale to desired range. + __UINT64_TYPE__ __u64erange = __uerange; + __ret = _S_nd(__urng, __u64erange); + } + else +#endif + if _GLIBCXX17_CONSTEXPR (__urngrange == __UINT32_MAX__) + { + // __urng produces values that use exactly 32-bits, + // so use 64-bit integers to downscale to desired range. + __UINT32_TYPE__ __u32erange = __uerange; + __ret = _S_nd<__UINT64_TYPE__>(__urng, __u32erange); + } + else +#endif + { + // fallback case (2 divisions) + const __uctype __scaling = __urngrange / __uerange; + const __uctype __past = __uerange * __scaling; + do + __ret = __uctype(__urng()) - __urngmin; + while (__ret >= __past); + __ret /= __scaling; + } + } + else if (__urngrange < __urange) + { + // upscaling + /* + Note that every value in [0, urange] + can be written uniquely as + + (urngrange + 1) * high + low + + where + + high in [0, urange / (urngrange + 1)] + + and + + low in [0, urngrange]. + */ + __uctype __tmp; // wraparound control + do + { + const __uctype __uerngrange = __urngrange + 1; + __tmp = (__uerngrange * operator() + (__urng, param_type(0, __urange / __uerngrange))); + __ret = __tmp + (__uctype(__urng()) - __urngmin); + } + while (__ret > __urange || __ret < __tmp); + } + else + __ret = __uctype(__urng()) - __urngmin; + + return __ret + __param.a(); + } + + + template + template + void + uniform_int_distribution<_IntType>:: + __generate_impl(_ForwardIterator __f, _ForwardIterator __t, + _UniformRandomBitGenerator& __urng, + const param_type& __param) + { + __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) + typedef typename _UniformRandomBitGenerator::result_type _Gresult_type; + typedef typename make_unsigned::type __utype; + typedef typename common_type<_Gresult_type, __utype>::type __uctype; + + static_assert( __urng.min() < __urng.max(), + "Uniform random bit generator must define min() < max()"); + + constexpr __uctype __urngmin = __urng.min(); + constexpr __uctype __urngmax = __urng.max(); + constexpr __uctype __urngrange = __urngmax - __urngmin; + const __uctype __urange + = __uctype(__param.b()) - __uctype(__param.a()); + + __uctype __ret; + + if (__urngrange > __urange) + { + if (__detail::_Power_of_2(__urngrange + 1) + && __detail::_Power_of_2(__urange + 1)) + { + while (__f != __t) + { + __ret = __uctype(__urng()) - __urngmin; + *__f++ = (__ret & __urange) + __param.a(); + } + } + else + { + // downscaling + const __uctype __uerange = __urange + 1; // __urange can be zero + const __uctype __scaling = __urngrange / __uerange; + const __uctype __past = __uerange * __scaling; + while (__f != __t) + { + do + __ret = __uctype(__urng()) - __urngmin; + while (__ret >= __past); + *__f++ = __ret / __scaling + __param.a(); + } + } + } + else if (__urngrange < __urange) + { + // upscaling + /* + Note that every value in [0, urange] + can be written uniquely as + + (urngrange + 1) * high + low + + where + + high in [0, urange / (urngrange + 1)] + + and + + low in [0, urngrange]. + */ + __uctype __tmp; // wraparound control + while (__f != __t) + { + do + { + constexpr __uctype __uerngrange = __urngrange + 1; + __tmp = (__uerngrange * operator() + (__urng, param_type(0, __urange / __uerngrange))); + __ret = __tmp + (__uctype(__urng()) - __urngmin); + } + while (__ret > __urange || __ret < __tmp); + *__f++ = __ret; + } + } + else + while (__f != __t) + *__f++ = __uctype(__urng()) - __urngmin + __param.a(); + } + + // operator!= and operator<< and operator>> are defined in + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unique_lock.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unique_lock.h new file mode 100755 index 0000000..07edfbb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unique_lock.h @@ -0,0 +1,243 @@ +// std::unique_lock implementation -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unique_lock.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{mutex} + */ + +#ifndef _GLIBCXX_UNIQUE_LOCK_H +#define _GLIBCXX_UNIQUE_LOCK_H 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include // for std::swap +#include // for std::defer_lock_t + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** @brief A movable scoped lock type. + * + * A unique_lock controls mutex ownership within a scope. Ownership of the + * mutex can be delayed until after construction and can be transferred + * to another unique_lock by move construction or move assignment. If a + * mutex lock is owned when the destructor runs ownership will be released. + * + * @ingroup mutexes + */ + template + class unique_lock + { + public: + typedef _Mutex mutex_type; + + unique_lock() noexcept + : _M_device(0), _M_owns(false) + { } + + explicit unique_lock(mutex_type& __m) + : _M_device(std::__addressof(__m)), _M_owns(false) + { + lock(); + _M_owns = true; + } + + unique_lock(mutex_type& __m, defer_lock_t) noexcept + : _M_device(std::__addressof(__m)), _M_owns(false) + { } + + unique_lock(mutex_type& __m, try_to_lock_t) + : _M_device(std::__addressof(__m)), _M_owns(_M_device->try_lock()) + { } + + unique_lock(mutex_type& __m, adopt_lock_t) noexcept + : _M_device(std::__addressof(__m)), _M_owns(true) + { + // XXX calling thread owns mutex + } + + template + unique_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __atime) + : _M_device(std::__addressof(__m)), + _M_owns(_M_device->try_lock_until(__atime)) + { } + + template + unique_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rtime) + : _M_device(std::__addressof(__m)), + _M_owns(_M_device->try_lock_for(__rtime)) + { } + + ~unique_lock() + { + if (_M_owns) + unlock(); + } + + unique_lock(const unique_lock&) = delete; + unique_lock& operator=(const unique_lock&) = delete; + + unique_lock(unique_lock&& __u) noexcept + : _M_device(__u._M_device), _M_owns(__u._M_owns) + { + __u._M_device = 0; + __u._M_owns = false; + } + + unique_lock& operator=(unique_lock&& __u) noexcept + { + if(_M_owns) + unlock(); + + unique_lock(std::move(__u)).swap(*this); + + __u._M_device = 0; + __u._M_owns = false; + + return *this; + } + + void + lock() + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_device->lock(); + _M_owns = true; + } + } + + bool + try_lock() + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock(); + return _M_owns; + } + } + + template + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock_until(__atime); + return _M_owns; + } + } + + template + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) + { + if (!_M_device) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_owns) + __throw_system_error(int(errc::resource_deadlock_would_occur)); + else + { + _M_owns = _M_device->try_lock_for(__rtime); + return _M_owns; + } + } + + void + unlock() + { + if (!_M_owns) + __throw_system_error(int(errc::operation_not_permitted)); + else if (_M_device) + { + _M_device->unlock(); + _M_owns = false; + } + } + + void + swap(unique_lock& __u) noexcept + { + std::swap(_M_device, __u._M_device); + std::swap(_M_owns, __u._M_owns); + } + + mutex_type* + release() noexcept + { + mutex_type* __ret = _M_device; + _M_device = 0; + _M_owns = false; + return __ret; + } + + bool + owns_lock() const noexcept + { return _M_owns; } + + explicit operator bool() const noexcept + { return owns_lock(); } + + mutex_type* + mutex() const noexcept + { return _M_device; } + + private: + mutex_type* _M_device; + bool _M_owns; + }; + + /// Swap overload for unique_lock objects. + /// @relates unique_lock + template + inline void + swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept + { __x.swap(__y); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 +#endif // _GLIBCXX_UNIQUE_LOCK_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unique_ptr.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unique_ptr.h new file mode 100755 index 0000000..6e55375 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unique_ptr.h @@ -0,0 +1,1031 @@ +// unique_ptr implementation -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unique_ptr.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _UNIQUE_PTR_H +#define _UNIQUE_PTR_H 1 + +#include +#include +#include +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @addtogroup pointer_abstractions + * @{ + */ + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + template class auto_ptr; +#pragma GCC diagnostic pop +#endif + + /// Primary template of default_delete, used by unique_ptr for single objects + template + struct default_delete + { + /// Default constructor + constexpr default_delete() noexcept = default; + + /** @brief Converting constructor. + * + * Allows conversion from a deleter for objects of another type, `_Up`, + * only if `_Up*` is convertible to `_Tp*`. + */ + template>> + default_delete(const default_delete<_Up>&) noexcept { } + + /// Calls `delete __ptr` + void + operator()(_Tp* __ptr) const + { + static_assert(!is_void<_Tp>::value, + "can't delete pointer to incomplete type"); + static_assert(sizeof(_Tp)>0, + "can't delete pointer to incomplete type"); + delete __ptr; + } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 740 - omit specialization for array objects with a compile time length + + /// Specialization of default_delete for arrays, used by `unique_ptr` + template + struct default_delete<_Tp[]> + { + public: + /// Default constructor + constexpr default_delete() noexcept = default; + + /** @brief Converting constructor. + * + * Allows conversion from a deleter for arrays of another type, such as + * a const-qualified version of `_Tp`. + * + * Conversions from types derived from `_Tp` are not allowed because + * it is undefined to `delete[]` an array of derived types through a + * pointer to the base type. + */ + template>> + default_delete(const default_delete<_Up[]>&) noexcept { } + + /// Calls `delete[] __ptr` + template + typename enable_if::value>::type + operator()(_Up* __ptr) const + { + static_assert(sizeof(_Tp)>0, + "can't delete pointer to incomplete type"); + delete [] __ptr; + } + }; + + /// @cond undocumented + + // Manages the pointer and deleter of a unique_ptr + template + class __uniq_ptr_impl + { + template + struct _Ptr + { + using type = _Up*; + }; + + template + struct + _Ptr<_Up, _Ep, __void_t::type::pointer>> + { + using type = typename remove_reference<_Ep>::type::pointer; + }; + + public: + using _DeleterConstraint = enable_if< + __and_<__not_>, + is_default_constructible<_Dp>>::value>; + + using pointer = typename _Ptr<_Tp, _Dp>::type; + + static_assert( !is_rvalue_reference<_Dp>::value, + "unique_ptr's deleter type must be a function object type" + " or an lvalue reference type" ); + + __uniq_ptr_impl() = default; + __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; } + + template + __uniq_ptr_impl(pointer __p, _Del&& __d) + : _M_t(__p, std::forward<_Del>(__d)) { } + + __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept + : _M_t(std::move(__u._M_t)) + { __u._M_ptr() = nullptr; } + + __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept + { + reset(__u.release()); + _M_deleter() = std::forward<_Dp>(__u._M_deleter()); + return *this; + } + + pointer& _M_ptr() { return std::get<0>(_M_t); } + pointer _M_ptr() const { return std::get<0>(_M_t); } + _Dp& _M_deleter() { return std::get<1>(_M_t); } + const _Dp& _M_deleter() const { return std::get<1>(_M_t); } + + void reset(pointer __p) noexcept + { + const pointer __old_p = _M_ptr(); + _M_ptr() = __p; + if (__old_p) + _M_deleter()(__old_p); + } + + pointer release() noexcept + { + pointer __p = _M_ptr(); + _M_ptr() = nullptr; + return __p; + } + + void + swap(__uniq_ptr_impl& __rhs) noexcept + { + using std::swap; + swap(this->_M_ptr(), __rhs._M_ptr()); + swap(this->_M_deleter(), __rhs._M_deleter()); + } + + private: + tuple _M_t; + }; + + // Defines move construction + assignment as either defaulted or deleted. + template ::value, + bool = is_move_assignable<_Dp>::value> + struct __uniq_ptr_data : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = default; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; + }; + + template + struct __uniq_ptr_data<_Tp, _Dp, true, false> : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = default; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; + }; + + template + struct __uniq_ptr_data<_Tp, _Dp, false, true> : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = delete; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default; + }; + + template + struct __uniq_ptr_data<_Tp, _Dp, false, false> : __uniq_ptr_impl<_Tp, _Dp> + { + using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl; + __uniq_ptr_data(__uniq_ptr_data&&) = delete; + __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete; + }; + /// @endcond + + /// 20.7.1.2 unique_ptr for single objects. + template > + class unique_ptr + { + template + using _DeleterConstraint = + typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; + + __uniq_ptr_data<_Tp, _Dp> _M_t; + + public: + using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; + using element_type = _Tp; + using deleter_type = _Dp; + + private: + // helper template for detecting a safe conversion from another + // unique_ptr + template + using __safe_conversion_up = __and_< + is_convertible::pointer, pointer>, + __not_> + >; + + public: + // Constructors. + + /// Default constructor, creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr() noexcept + : _M_t() + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an object of @c element_type + * + * The deleter will be value-initialized. + */ + template> + explicit + unique_ptr(pointer __p) noexcept + : _M_t(__p) + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an object of @c element_type + * @param __d A reference to a deleter. + * + * The deleter will be initialized with @p __d + */ + template>> + unique_ptr(pointer __p, const deleter_type& __d) noexcept + : _M_t(__p, __d) { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an object of @c element_type + * @param __d An rvalue reference to a (non-reference) deleter. + * + * The deleter will be initialized with @p std::move(__d) + */ + template>> + unique_ptr(pointer __p, + __enable_if_t::value, + _Del&&> __d) noexcept + : _M_t(__p, std::move(__d)) + { } + + template::type> + unique_ptr(pointer, + __enable_if_t::value, + _DelUnref&&>) = delete; + + /// Creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr(nullptr_t) noexcept + : _M_t() + { } + + // Move constructors. + + /// Move constructor. + unique_ptr(unique_ptr&&) = default; + + /** @brief Converting constructor from another type + * + * Requires that the pointer owned by @p __u is convertible to the + * type of pointer owned by this object, @p __u does not own an array, + * and @p __u has a compatible deleter type. + */ + template, + typename conditional::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>::type>> + unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept + : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) + { } + +#if _GLIBCXX_USE_DEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /// Converting constructor from @c auto_ptr + template, is_same<_Dp, default_delete<_Tp>>>> + unique_ptr(auto_ptr<_Up>&& __u) noexcept; +#pragma GCC diagnostic pop +#endif + + /// Destructor, invokes the deleter if the stored pointer is not null. + ~unique_ptr() noexcept + { + static_assert(__is_invocable::value, + "unique_ptr's deleter must be invocable with a pointer"); + auto& __ptr = _M_t._M_ptr(); + if (__ptr != nullptr) + get_deleter()(std::move(__ptr)); + __ptr = pointer(); + } + + // Assignment. + + /** @brief Move assignment operator. + * + * Invokes the deleter if this object owns a pointer. + */ + unique_ptr& operator=(unique_ptr&&) = default; + + /** @brief Assignment from another type. + * + * @param __u The object to transfer ownership from, which owns a + * convertible pointer to a non-array object. + * + * Invokes the deleter if this object owns a pointer. + */ + template + typename enable_if< __and_< + __safe_conversion_up<_Up, _Ep>, + is_assignable + >::value, + unique_ptr&>::type + operator=(unique_ptr<_Up, _Ep>&& __u) noexcept + { + reset(__u.release()); + get_deleter() = std::forward<_Ep>(__u.get_deleter()); + return *this; + } + + /// Reset the %unique_ptr to empty, invoking the deleter if necessary. + unique_ptr& + operator=(nullptr_t) noexcept + { + reset(); + return *this; + } + + // Observers. + + /// Dereference the stored pointer. + typename add_lvalue_reference::type + operator*() const + { + __glibcxx_assert(get() != pointer()); + return *get(); + } + + /// Return the stored pointer. + pointer + operator->() const noexcept + { + _GLIBCXX_DEBUG_PEDASSERT(get() != pointer()); + return get(); + } + + /// Return the stored pointer. + pointer + get() const noexcept + { return _M_t._M_ptr(); } + + /// Return a reference to the stored deleter. + deleter_type& + get_deleter() noexcept + { return _M_t._M_deleter(); } + + /// Return a reference to the stored deleter. + const deleter_type& + get_deleter() const noexcept + { return _M_t._M_deleter(); } + + /// Return @c true if the stored pointer is not null. + explicit operator bool() const noexcept + { return get() == pointer() ? false : true; } + + // Modifiers. + + /// Release ownership of any stored pointer. + pointer + release() noexcept + { return _M_t.release(); } + + /** @brief Replace the stored pointer. + * + * @param __p The new pointer to store. + * + * The deleter will be invoked if a pointer is already owned. + */ + void + reset(pointer __p = pointer()) noexcept + { + static_assert(__is_invocable::value, + "unique_ptr's deleter must be invocable with a pointer"); + _M_t.reset(std::move(__p)); + } + + /// Exchange the pointer and deleter with another object. + void + swap(unique_ptr& __u) noexcept + { + static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); + _M_t.swap(__u._M_t); + } + + // Disable copy from lvalue. + unique_ptr(const unique_ptr&) = delete; + unique_ptr& operator=(const unique_ptr&) = delete; + }; + + /// 20.7.1.3 unique_ptr for array objects with a runtime length + // [unique.ptr.runtime] + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 740 - omit specialization for array objects with a compile time length + template + class unique_ptr<_Tp[], _Dp> + { + template + using _DeleterConstraint = + typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type; + + __uniq_ptr_data<_Tp, _Dp> _M_t; + + template + using __remove_cv = typename remove_cv<_Up>::type; + + // like is_base_of<_Tp, _Up> but false if unqualified types are the same + template + using __is_derived_Tp + = __and_< is_base_of<_Tp, _Up>, + __not_, __remove_cv<_Up>>> >; + + public: + using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer; + using element_type = _Tp; + using deleter_type = _Dp; + + // helper template for detecting a safe conversion from another + // unique_ptr + template, + typename _UP_pointer = typename _UPtr::pointer, + typename _UP_element_type = typename _UPtr::element_type> + using __safe_conversion_up = __and_< + is_array<_Up>, + is_same, + is_same<_UP_pointer, _UP_element_type*>, + is_convertible<_UP_element_type(*)[], element_type(*)[]> + >; + + // helper template for detecting a safe conversion from a raw pointer + template + using __safe_conversion_raw = __and_< + __or_<__or_, + is_same<_Up, nullptr_t>>, + __and_, + is_same, + is_convertible< + typename remove_pointer<_Up>::type(*)[], + element_type(*)[]> + > + > + >; + + // Constructors. + + /// Default constructor, creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr() noexcept + : _M_t() + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an array of a type safely convertible + * to an array of @c element_type + * + * The deleter will be value-initialized. + */ + template, + typename = typename enable_if< + __safe_conversion_raw<_Up>::value, bool>::type> + explicit + unique_ptr(_Up __p) noexcept + : _M_t(__p) + { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an array of a type safely convertible + * to an array of @c element_type + * @param __d A reference to a deleter. + * + * The deleter will be initialized with @p __d + */ + template, + is_copy_constructible<_Del>>> + unique_ptr(_Up __p, const deleter_type& __d) noexcept + : _M_t(__p, __d) { } + + /** Takes ownership of a pointer. + * + * @param __p A pointer to an array of a type safely convertible + * to an array of @c element_type + * @param __d A reference to a deleter. + * + * The deleter will be initialized with @p std::move(__d) + */ + template, + is_move_constructible<_Del>>> + unique_ptr(_Up __p, + __enable_if_t::value, + _Del&&> __d) noexcept + : _M_t(std::move(__p), std::move(__d)) + { } + + template::type, + typename = _Require<__safe_conversion_raw<_Up>>> + unique_ptr(_Up, + __enable_if_t::value, + _DelUnref&&>) = delete; + + /// Move constructor. + unique_ptr(unique_ptr&&) = default; + + /// Creates a unique_ptr that owns nothing. + template> + constexpr unique_ptr(nullptr_t) noexcept + : _M_t() + { } + + template, + typename conditional::value, + is_same<_Ep, _Dp>, + is_convertible<_Ep, _Dp>>::type>> + unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept + : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter())) + { } + + /// Destructor, invokes the deleter if the stored pointer is not null. + ~unique_ptr() + { + auto& __ptr = _M_t._M_ptr(); + if (__ptr != nullptr) + get_deleter()(__ptr); + __ptr = pointer(); + } + + // Assignment. + + /** @brief Move assignment operator. + * + * Invokes the deleter if this object owns a pointer. + */ + unique_ptr& + operator=(unique_ptr&&) = default; + + /** @brief Assignment from another type. + * + * @param __u The object to transfer ownership from, which owns a + * convertible pointer to an array object. + * + * Invokes the deleter if this object owns a pointer. + */ + template + typename + enable_if<__and_<__safe_conversion_up<_Up, _Ep>, + is_assignable + >::value, + unique_ptr&>::type + operator=(unique_ptr<_Up, _Ep>&& __u) noexcept + { + reset(__u.release()); + get_deleter() = std::forward<_Ep>(__u.get_deleter()); + return *this; + } + + /// Reset the %unique_ptr to empty, invoking the deleter if necessary. + unique_ptr& + operator=(nullptr_t) noexcept + { + reset(); + return *this; + } + + // Observers. + + /// Access an element of owned array. + typename std::add_lvalue_reference::type + operator[](size_t __i) const + { + __glibcxx_assert(get() != pointer()); + return get()[__i]; + } + + /// Return the stored pointer. + pointer + get() const noexcept + { return _M_t._M_ptr(); } + + /// Return a reference to the stored deleter. + deleter_type& + get_deleter() noexcept + { return _M_t._M_deleter(); } + + /// Return a reference to the stored deleter. + const deleter_type& + get_deleter() const noexcept + { return _M_t._M_deleter(); } + + /// Return @c true if the stored pointer is not null. + explicit operator bool() const noexcept + { return get() == pointer() ? false : true; } + + // Modifiers. + + /// Release ownership of any stored pointer. + pointer + release() noexcept + { return _M_t.release(); } + + /** @brief Replace the stored pointer. + * + * @param __p The new pointer to store. + * + * The deleter will be invoked if a pointer is already owned. + */ + template , + __and_, + is_pointer<_Up>, + is_convertible< + typename remove_pointer<_Up>::type(*)[], + element_type(*)[] + > + > + > + >> + void + reset(_Up __p) noexcept + { _M_t.reset(std::move(__p)); } + + void reset(nullptr_t = nullptr) noexcept + { reset(pointer()); } + + /// Exchange the pointer and deleter with another object. + void + swap(unique_ptr& __u) noexcept + { + static_assert(__is_swappable<_Dp>::value, "deleter must be swappable"); + _M_t.swap(__u._M_t); + } + + // Disable copy from lvalue. + unique_ptr(const unique_ptr&) = delete; + unique_ptr& operator=(const unique_ptr&) = delete; + }; + + /// @relates unique_ptr @{ + + /// Swap overload for unique_ptr + template + inline +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + // Constrained free swap overload, see p0185r1 + typename enable_if<__is_swappable<_Dp>::value>::type +#else + void +#endif + swap(unique_ptr<_Tp, _Dp>& __x, + unique_ptr<_Tp, _Dp>& __y) noexcept + { __x.swap(__y); } + +#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 + template + typename enable_if::value>::type + swap(unique_ptr<_Tp, _Dp>&, + unique_ptr<_Tp, _Dp>&) = delete; +#endif + + /// Equality operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD inline bool + operator==(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return __x.get() == __y.get(); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept + { return !__x; } + +#ifndef __cpp_lib_three_way_comparison + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept + { return !__x; } + + /// Inequality operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD inline bool + operator!=(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return __x.get() != __y.get(); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept + { return (bool)__x; } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept + { return (bool)__x; } +#endif // three way comparison + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD inline bool + operator<(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { + typedef typename + std::common_type::pointer, + typename unique_ptr<_Up, _Ep>::pointer>::type _CT; + return std::less<_CT>()(__x.get(), __y.get()); + } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { + return std::less::pointer>()(__x.get(), + nullptr); + } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { + return std::less::pointer>()(nullptr, + __x.get()); + } + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD inline bool + operator<=(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return !(__y < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { return !(nullptr < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { return !(__x < nullptr); } + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD inline bool + operator>(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return (__y < __x); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { + return std::less::pointer>()(nullptr, + __x.get()); + } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { + return std::less::pointer>()(__x.get(), + nullptr); + } + + /// Relational operator for unique_ptr objects, compares the owned pointers + template + _GLIBCXX_NODISCARD inline bool + operator>=(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return !(__x < __y); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { return !(__x < nullptr); } + + /// unique_ptr comparison with nullptr + template + _GLIBCXX_NODISCARD inline bool + operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) + { return !(nullptr < __x); } + +#ifdef __cpp_lib_three_way_comparison + template + requires three_way_comparable_with::pointer, + typename unique_ptr<_Up, _Ep>::pointer> + inline + compare_three_way_result_t::pointer, + typename unique_ptr<_Up, _Ep>::pointer> + operator<=>(const unique_ptr<_Tp, _Dp>& __x, + const unique_ptr<_Up, _Ep>& __y) + { return compare_three_way()(__x.get(), __y.get()); } + + template + requires three_way_comparable::pointer> + inline + compare_three_way_result_t::pointer> + operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) + { + using pointer = typename unique_ptr<_Tp, _Dp>::pointer; + return compare_three_way()(__x.get(), static_cast(nullptr)); + } +#endif + /// @} relates unique_ptr + + /// @cond undocumented + template::__enable_hash_call> + struct __uniq_ptr_hash +#if ! _GLIBCXX_INLINE_VERSION + : private __poison_hash<_Ptr> +#endif + { + size_t + operator()(const _Up& __u) const + noexcept(noexcept(std::declval>()(std::declval<_Ptr>()))) + { return hash<_Ptr>()(__u.get()); } + }; + + template + struct __uniq_ptr_hash<_Up, _Ptr, false> + : private __poison_hash<_Ptr> + { }; + /// @endcond + + /// std::hash specialization for unique_ptr. + template + struct hash> + : public __hash_base>, + public __uniq_ptr_hash> + { }; + +#if __cplusplus >= 201402L + /// @relates unique_ptr @{ +#define __cpp_lib_make_unique 201304 + + /// @cond undocumented + + template + struct _MakeUniq + { typedef unique_ptr<_Tp> __single_object; }; + + template + struct _MakeUniq<_Tp[]> + { typedef unique_ptr<_Tp[]> __array; }; + + template + struct _MakeUniq<_Tp[_Bound]> + { struct __invalid_type { }; }; + + /// @endcond + + /// std::make_unique for single objects + template + inline typename _MakeUniq<_Tp>::__single_object + make_unique(_Args&&... __args) + { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); } + + /// std::make_unique for arrays of unknown bound + template + inline typename _MakeUniq<_Tp>::__array + make_unique(size_t __num) + { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); } + + /// Disable std::make_unique for arrays of known bound + template + typename _MakeUniq<_Tp>::__invalid_type + make_unique(_Args&&...) = delete; + +#if __cplusplus > 201703L + /// std::make_unique_for_overwrite for single objects + template + inline typename _MakeUniq<_Tp>::__single_object + make_unique_for_overwrite() + { return unique_ptr<_Tp>(new _Tp); } + + /// std::make_unique_for_overwrite for arrays of unknown bound + template + inline typename _MakeUniq<_Tp>::__array + make_unique_for_overwrite(size_t __n) + { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__n]); } + + /// Disable std::make_unique_for_overwrite for arrays of known bound + template + typename _MakeUniq<_Tp>::__invalid_type + make_unique_for_overwrite(_Args&&...) = delete; +#endif // C++20 + + /// @} relates unique_ptr +#endif // C++14 + +#if __cplusplus > 201703L && __cpp_concepts + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2948. unique_ptr does not define operator<< for stream output + /// Stream output operator for unique_ptr + template + inline basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, + const unique_ptr<_Tp, _Dp>& __p) + requires requires { __os << __p.get(); } + { + __os << __p.get(); + return __os; + } +#endif // C++20 + + /// @} group pointer_abstractions + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // unique_ptr into a variant. + template + struct _Never_valueless_alt> + : std::true_type + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _UNIQUE_PTR_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unordered_map.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unordered_map.h new file mode 100755 index 0000000..2261e66 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unordered_map.h @@ -0,0 +1,2215 @@ +// unordered_map implementation -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unordered_map.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{unordered_map} + */ + +#ifndef _UNORDERED_MAP_H +#define _UNORDERED_MAP_H + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// Base types for unordered_map. + template + using __umap_traits = __detail::_Hashtable_traits<_Cache, false, true>; + + template, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator >, + typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value>> + using __umap_hashtable = _Hashtable<_Key, std::pair, + _Alloc, __detail::_Select1st, + _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + /// Base types for unordered_multimap. + template + using __ummap_traits = __detail::_Hashtable_traits<_Cache, false, false>; + + template, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator >, + typename _Tr = __ummap_traits<__cache_default<_Key, _Hash>::value>> + using __ummap_hashtable = _Hashtable<_Key, std::pair, + _Alloc, __detail::_Select1st, + _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + template + class unordered_multimap; + + /** + * @brief A standard container composed of unique keys (containing + * at most one of each key value) that associates values of another type + * with the keys. + * + * @ingroup unordered_associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + * @tparam _Pred Predicate function object type, defaults + * to equal_to<_Value>. + * @tparam _Alloc Allocator type, defaults to + * std::allocator>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * The resulting value type of the container is std::pair. + * + * Base is _Hashtable, dispatched at compile time via template + * alias __umap_hashtable. + */ + template, + typename _Pred = equal_to<_Key>, + typename _Alloc = allocator>> + class unordered_map + { + typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::mapped_type mapped_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; + using insert_return_type = typename _Hashtable::insert_return_type; +#endif + + //construct/destroy/copy + + /// Default constructor. + unordered_map() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_map(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_map from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_map consisting of copies of the elements from + * [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_map(const unordered_map&) = default; + + /// Move constructor. + unordered_map(unordered_map&&) = default; + + /** + * @brief Creates an %unordered_map with no elements. + * @param __a An allocator object. + */ + explicit + unordered_map(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_map to copy. + * @param __a An allocator object. + */ + unordered_map(const unordered_map& __umap, + const allocator_type& __a) + : _M_h(__umap._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __uset Input %unordered_map to move. + * @param __a An allocator object. + */ + unordered_map(unordered_map&& __umap, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__umap._M_h), __a)) ) + : _M_h(std::move(__umap._M_h), __a) + { } + + /** + * @brief Builds an %unordered_map from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_map consisting of copies of the elements in the + * list. This is linear in N (where N is @a __l.size()). + */ + unordered_map(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + unordered_map(size_type __n, const allocator_type& __a) + : unordered_map(__n, hasher(), key_equal(), __a) + { } + + unordered_map(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__n, __hf, key_equal(), __a) + { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_map(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_map(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_map(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__l, __n, __hf, key_equal(), __a) + { } + + /// Copy assignment operator. + unordered_map& + operator=(const unordered_map&) = default; + + /// Move assignment operator. + unordered_map& + operator=(unordered_map&&) = default; + + /** + * @brief %Unordered_map list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_map with copies of the elements in + * the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_map and + * that the resulting %unordered_map's size is the same as the number + * of elements assigned. + */ + unordered_map& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_map. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_map is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_map. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_map. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + /** + * Returns a read/write iterator that points to the first element in the + * %unordered_map. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_map. + */ + const_iterator + begin() const noexcept + { return _M_h.begin(); } + + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + ///@} + + /** + * Returns a read/write iterator that points one past the last element in + * the %unordered_map. + */ + iterator + end() noexcept + { return _M_h.end(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_map. + */ + const_iterator + end() const noexcept + { return _M_h.end(); } + + const_iterator + cend() const noexcept + { return _M_h.end(); } + ///@} + + // modifiers. + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %unordered_map. + * An %unordered_map relies on unique keys and thus a %pair is only + * inserted if its first element (the key) is not already present in the + * %unordered_map. + * + * Insertion requires amortized constant time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator, node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)).position; } + +#define __cpp_lib_unordered_map_try_emplace 201411 + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __k Key to use for finding a possibly existing pair in + * the unordered_map. + * @param __args Arguments used to generate the .second for a + * new pair instance. + * + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted pair, and the second is a bool that + * is true if the pair was actually inserted. + * + * This function attempts to build and insert a (key, value) %pair into + * the %unordered_map. + * An %unordered_map relies on unique keys and thus a %pair is only + * inserted if its first element (the key) is not already present in the + * %unordered_map. + * If a %pair is not inserted, this function has no effect. + * + * Insertion requires amortized constant time. + */ + template + pair + try_emplace(const key_type& __k, _Args&&... __args) + { + return _M_h.try_emplace(cend(), __k, std::forward<_Args>(__args)...); + } + + // move-capable overload + template + pair + try_emplace(key_type&& __k, _Args&&... __args) + { + return _M_h.try_emplace(cend(), std::move(__k), + std::forward<_Args>(__args)...); + } + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_map. + * + * @param __hint An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the unordered_map. + * @param __args Arguments used to generate the .second for a + * new pair instance. + * @return An iterator that points to the element with key of the + * std::pair built from @a __args (may or may not be that + * std::pair). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. However, if insertion did not take place, + * this function has no effect. + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + return _M_h.try_emplace(__hint, __k, + std::forward<_Args>(__args)...).first; + } + + // move-capable overload + template + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + return _M_h.try_emplace(__hint, std::move(__k), + std::forward<_Args>(__args)...).first; + } +#endif // C++17 + + ///@{ + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + + * @param __x Pair to be inserted (see std::make_pair for easy + * creation of pairs). + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the + * %unordered_map. An %unordered_map relies on unique keys and thus a + * %pair is only inserted if its first element (the key) is not already + * present in the %unordered_map. + * + * Insertion requires amortized constant time. + */ + std::pair + insert(const value_type& __x) + { return _M_h.insert(__x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + std::pair + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + + template + __enable_if_t::value, + pair> + insert(_Pair&& __x) + { return _M_h.emplace(std::forward<_Pair>(__x)); } + ///@} + + ///@{ + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __hint, _Pair&& __x) + { return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); } + ///@} + + /** + * @brief A template function that attempts to insert a range of + * elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Attempts to insert a list of elements into the %unordered_map. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + + +#if __cplusplus > 201402L + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + * @param __k Key to use for finding a possibly existing pair in + * the map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * + * @return A pair, of which the first element is an iterator that + * points to the possibly inserted pair, and the second is + * a bool that is true if the pair was actually inserted. + * + * This function attempts to insert a (key, value) %pair into the + * %unordered_map. An %unordered_map relies on unique keys and thus a + * %pair is only inserted if its first element (the key) is not already + * present in the %unordered_map. + * If the %pair was already in the %unordered_map, the .second of + * the %pair is assigned from __obj. + * + * Insertion requires amortized constant time. + */ + template + pair + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(cend(), __k, + std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret; + } + + // move-capable overload + template + pair + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(cend(), std::move(__k), + std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret; + } + + /** + * @brief Attempts to insert a std::pair into the %unordered_map. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __k Key to use for finding a possibly existing pair in + * the unordered_map. + * @param __obj Argument used to generate the .second for a pair + * instance. + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. + * If the %pair was already in the %unordered map, the .second of + * the %pair is assigned from __obj. + * Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + insert_or_assign(const_iterator __hint, const key_type& __k, + _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(__hint, __k, std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret.first; + } + + // move-capable overload + template + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + auto __ret = _M_h.try_emplace(__hint, std::move(__k), + std::forward<_Obj>(__obj)); + if (!__ret.second) + __ret.first->second = std::forward<_Obj>(__obj); + return __ret.first; + } +#endif + + ///@{ + /** + * @brief Erases an element from an %unordered_map. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_map. + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_map. For an %unordered_map the result of this function + * can only be 0 (not present) or 1 (present). + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_map. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an %unordered_map. + * Note that this function only erases the elements, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_map. + * Note that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_map. + * @param __x An %unordered_map of the same element and allocator + * types. + * + * This exchanges the elements between two %unordered_map in constant + * time. + * Note that the global std::swap() function is specialized such that + * std::swap(m1,m2) will feed to this function. + */ + void + swap(unordered_map& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_map was + /// constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_map was + /// constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_map. + * @param __x Key to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Key to count. + * @return Number of elements with specified key. + * + * This function only makes sense for %unordered_multimap; for + * %unordered_map the result will either be 0 (not present) or 1 + * (present). + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __x) const -> decltype(_M_h._M_count_tr(__x)) + { return _M_h._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x), void(), true) + { return _M_h._M_find_tr(__x) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function probably only makes sense for %unordered_multimap. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) const + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Subscript ( @c [] ) access to %unordered_map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data of the (key,data) %pair. + * + * Allows for easy lookup with the subscript ( @c [] )operator. Returns + * data associated with the key specified in subscript. If the key does + * not exist, a pair with that key is created using default values, which + * is then returned. + * + * Lookup requires constant time. + */ + mapped_type& + operator[](const key_type& __k) + { return _M_h[__k]; } + + mapped_type& + operator[](key_type&& __k) + { return _M_h[std::move(__k)]; } + ///@} + + ///@{ + /** + * @brief Access to %unordered_map data. + * @param __k The key for which data should be retrieved. + * @return A reference to the data whose key is equal to @a __k, if + * such a data is present in the %unordered_map. + * @throw std::out_of_range If no such data is present. + */ + mapped_type& + at(const key_type& __k) + { return _M_h.at(__k); } + + const mapped_type& + at(const key_type& __k) const + { return _M_h.at(__k); } + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_map. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_map. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + /** + * @brief Returns a read/write iterator pointing to the first bucket + * element. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + /** + * @brief Returns a read/write iterator pointing to one past the last + * bucket elements. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_map tries to keep the + /// load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_map maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_map. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_map maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_map for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, + const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&); + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + + /** + * @brief A standard container composed of equivalent keys + * (possibly containing multiple of each key value) that associates + * values of another type with the keys. + * + * @ingroup unordered_associative_containers + * + * @tparam _Key Type of key objects. + * @tparam _Tp Type of mapped objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + * @tparam _Pred Predicate function object type, defaults + * to equal_to<_Value>. + * @tparam _Alloc Allocator type, defaults to + * std::allocator>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * The resulting value type of the container is std::pair. + * + * Base is _Hashtable, dispatched at compile time via template + * alias __ummap_hashtable. + */ + template, + typename _Pred = equal_to<_Key>, + typename _Alloc = allocator>> + class unordered_multimap + { + typedef __ummap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::mapped_type mapped_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; +#endif + + //construct/destroy/copy + + /// Default constructor. + unordered_multimap() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Mnimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_multimap(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_multimap from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multimap consisting of copies of the elements + * from [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_multimap(const unordered_multimap&) = default; + + /// Move constructor. + unordered_multimap(unordered_multimap&&) = default; + + /** + * @brief Creates an %unordered_multimap with no elements. + * @param __a An allocator object. + */ + explicit + unordered_multimap(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_multimap to copy. + * @param __a An allocator object. + */ + unordered_multimap(const unordered_multimap& __ummap, + const allocator_type& __a) + : _M_h(__ummap._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __uset Input %unordered_multimap to move. + * @param __a An allocator object. + */ + unordered_multimap(unordered_multimap&& __ummap, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__ummap._M_h), __a)) ) + : _M_h(std::move(__ummap._M_h), __a) + { } + + /** + * @brief Builds an %unordered_multimap from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multimap consisting of copies of the elements in + * the list. This is linear in N (where N is @a __l.size()). + */ + unordered_multimap(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + unordered_multimap(size_type __n, const allocator_type& __a) + : unordered_multimap(__n, hasher(), key_equal(), __a) + { } + + unordered_multimap(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__n, __hf, key_equal(), __a) + { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_multimap(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_multimap(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_multimap(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__l, __n, __hf, key_equal(), __a) + { } + + /// Copy assignment operator. + unordered_multimap& + operator=(const unordered_multimap&) = default; + + /// Move assignment operator. + unordered_multimap& + operator=(unordered_multimap&&) = default; + + /** + * @brief %Unordered_multimap list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_multimap with copies of the + * elements in the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_multimap + * and that the resulting %unordered_multimap's size is the same as the + * number of elements assigned. + */ + unordered_multimap& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_multimap. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_multimap is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_multimap. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_multimap. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + /** + * Returns a read/write iterator that points to the first element in the + * %unordered_multimap. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_multimap. + */ + const_iterator + begin() const noexcept + { return _M_h.begin(); } + + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + ///@} + + /** + * Returns a read/write iterator that points one past the last element in + * the %unordered_multimap. + */ + iterator + end() noexcept + { return _M_h.end(); } + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_multimap. + */ + const_iterator + end() const noexcept + { return _M_h.end(); } + + const_iterator + cend() const noexcept + { return _M_h.end(); } + ///@} + + // modifiers. + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_multimap. + * + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * + * @return An iterator that points to the inserted pair. + * + * This function attempts to build and insert a (key, value) %pair into + * the %unordered_multimap. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to build and insert a std::pair into the + * %unordered_multimap. + * + * @param __pos An iterator that serves as a hint as to where the pair + * should be inserted. + * @param __args Arguments used to generate a new pair instance (see + * std::piecewise_contruct for passing arguments to each + * part of the pair constructor). + * @return An iterator that points to the element with key of the + * std::pair built from @a __args. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + + ///@{ + /** + * @brief Inserts a std::pair into the %unordered_multimap. + * @param __x Pair to be inserted (see std::make_pair for easy + * creation of pairs). + * + * @return An iterator that points to the inserted pair. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const value_type& __x) + { return _M_h.insert(__x); } + + iterator + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(_Pair&& __x) + { return _M_h.emplace(std::forward<_Pair>(__x)); } + ///@} + + ///@{ + /** + * @brief Inserts a std::pair into the %unordered_multimap. + * @param __hint An iterator that serves as a hint as to where the + * pair should be inserted. + * @param __x Pair to be inserted (see std::make_pair for easy creation + * of pairs). + * @return An iterator that points to the element with key of + * @a __x (may or may not be the %pair passed in). + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * See + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * for more on @a hinting. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + + template + __enable_if_t::value, iterator> + insert(const_iterator __hint, _Pair&& __x) + { return _M_h.emplace_hint(__hint, std::forward<_Pair>(__x)); } + ///@} + + /** + * @brief A template function that attempts to insert a range of + * elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Attempts to insert a list of elements into the + * %unordered_multimap. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); } +#endif // C++17 + + ///@{ + /** + * @brief Erases an element from an %unordered_multimap. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_multimap. + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of elements to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_multimap. + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_multimap. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an + * %unordered_multimap. + * Note that this function only erases the elements, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_multimap. + * Note that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_multimap. + * @param __x An %unordered_multimap of the same element and allocator + * types. + * + * This exchanges the elements between two %unordered_multimap in + * constant time. + * Note that the global std::swap() function is specialized such that + * std::swap(m1,m2) will feed to this function. + */ + void + swap(unordered_multimap& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multimap<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_map<_Key, _Tp, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_multimap + /// was constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_multimap + /// was constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_multimap. + * @param __x Key to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) const -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Key to count. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __x) const -> decltype(_M_h._M_count_tr(__x)) + { return _M_h._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x), void(), true) + { return _M_h._M_find_tr(__x) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) const + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_multimap. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_multimap. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + /** + * @brief Returns a read/write iterator pointing to the first bucket + * element. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + /** + * @brief Returns a read/write iterator pointing to one past the last + * bucket elements. + * @param __n The bucket index. + * @return A read/write local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_multimap tries to keep + /// the load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_multimap maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_multimap. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_multimap maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_multimap for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_multimap<_Key1, _Tp1, + _Hash1, _Pred1, _Alloc1>&, + const unordered_multimap<_Key1, _Tp1, + _Hash1, _Pred1, _Alloc1>&); + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, _Pred, + _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Hash, + _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Hash, _Allocator) + -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + + template + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + + template + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::unordered_map access to internals of compatible maps. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>, + _Hash2, _Eq2> + { + private: + template + using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>; + template + using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>; + + friend unordered_map<_Key, _Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + + static auto& + _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + }; + + // Allow std::unordered_multimap access to internals of compatible maps. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>, + _Hash2, _Eq2> + { + private: + template + using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>; + template + using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>; + + friend unordered_multimap<_Key, _Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_map<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + + static auto& + _S_get_table(unordered_multimap<_Key, _Val, _Hash2, _Eq2, _Alloc>& __map) + { return __map._M_h; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _UNORDERED_MAP_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unordered_set.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unordered_set.h new file mode 100755 index 0000000..ac4a890 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/unordered_set.h @@ -0,0 +1,1884 @@ +// unordered_set implementation -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/unordered_set.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{unordered_set} + */ + +#ifndef _UNORDERED_SET_H +#define _UNORDERED_SET_H + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /// Base types for unordered_set. + template + using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>; + + template, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value>, + typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>> + using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc, + __detail::_Identity, _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + /// Base types for unordered_multiset. + template + using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>; + + template, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value>, + typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>> + using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc, + __detail::_Identity, + _Pred, _Hash, + __detail::_Mod_range_hashing, + __detail::_Default_ranged_hash, + __detail::_Prime_rehash_policy, _Tr>; + + template + class unordered_multiset; + + /** + * @brief A standard container composed of unique keys (containing + * at most one of each key value) in which the elements' keys are + * the elements themselves. + * + * @ingroup unordered_associative_containers + * + * @tparam _Value Type of key objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + + * @tparam _Pred Predicate function object type, defaults to + * equal_to<_Value>. + * + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * Base is _Hashtable, dispatched at compile time via template + * alias __uset_hashtable. + */ + template, + typename _Pred = equal_to<_Value>, + typename _Alloc = allocator<_Value>> + class unordered_set + { + typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; + using insert_return_type = typename _Hashtable::insert_return_type; +#endif + + // construct/destroy/copy + + /// Default constructor. + unordered_set() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_set(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_set from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_set consisting of copies of the elements from + * [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_set(const unordered_set&) = default; + + /// Move constructor. + unordered_set(unordered_set&&) = default; + + /** + * @brief Creates an %unordered_set with no elements. + * @param __a An allocator object. + */ + explicit + unordered_set(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_set to copy. + * @param __a An allocator object. + */ + unordered_set(const unordered_set& __uset, + const allocator_type& __a) + : _M_h(__uset._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __uset Input %unordered_set to move. + * @param __a An allocator object. + */ + unordered_set(unordered_set&& __uset, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__uset._M_h), __a)) ) + : _M_h(std::move(__uset._M_h), __a) + { } + + /** + * @brief Builds an %unordered_set from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_set consisting of copies of the elements in the + * list. This is linear in N (where N is @a __l.size()). + */ + unordered_set(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) + { } + + unordered_set(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) + { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_set(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_set(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_set(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__l, __n, __hf, key_equal(), __a) + { } + + /// Copy assignment operator. + unordered_set& + operator=(const unordered_set&) = default; + + /// Move assignment operator. + unordered_set& + operator=(unordered_set&&) = default; + + /** + * @brief %Unordered_set list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_set with copies of the elements in + * the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_set and + * that the resulting %unordered_set's size is the same as the number + * of elements assigned. + */ + unordered_set& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_set. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_set is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_set. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_set. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_set. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + const_iterator + begin() const noexcept + { return _M_h.begin(); } + ///@} + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_set. + */ + iterator + end() noexcept + { return _M_h.end(); } + + const_iterator + end() const noexcept + { return _M_h.end(); } + ///@} + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_set. + */ + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_set. + */ + const_iterator + cend() const noexcept + { return _M_h.end(); } + + // modifiers. + + /** + * @brief Attempts to build and insert an element into the + * %unordered_set. + * @param __args Arguments used to generate an element. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to build and insert an element into the + * %unordered_set. An %unordered_set relies on unique keys and thus an + * element is only inserted if it is not already present in the + * %unordered_set. + * + * Insertion requires amortized constant time. + */ + template + std::pair + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Attempts to insert an element into the %unordered_set. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element to be + * inserted. + * @return An iterator that points to the element with key equivalent to + * the one generated from @a __args (may or may not be the + * element itself). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument emplace() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + + ///@{ + /** + * @brief Attempts to insert an element into the %unordered_set. + * @param __x Element to be inserted. + * @return A pair, of which the first element is an iterator that points + * to the possibly inserted element, and the second is a bool + * that is true if the element was actually inserted. + * + * This function attempts to insert an element into the %unordered_set. + * An %unordered_set relies on unique keys and thus an element is only + * inserted if it is not already present in the %unordered_set. + * + * Insertion requires amortized constant time. + */ + std::pair + insert(const value_type& __x) + { return _M_h.insert(__x); } + + std::pair + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + ///@} + + ///@{ + /** + * @brief Attempts to insert an element into the %unordered_set. + * @param __hint An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the element with key of + * @a __x (may or may not be the element passed in). + * + * This function is not concerned about whether the insertion took place, + * and thus does not return a boolean like the single-argument insert() + * does. Note that the first parameter is only a hint and can + * potentially improve the performance of the insertion process. A bad + * hint would cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + ///@} + + /** + * @brief A template function that attempts to insert a range of + * elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Attempts to insert a list of elements into the %unordered_set. + * @param __l A std::initializer_list of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + insert_return_type + insert(node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator, node_type&& __nh) + { return _M_h._M_reinsert_node(std::move(__nh)).position; } +#endif // C++17 + + ///@{ + /** + * @brief Erases an element from an %unordered_set. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_set. Note that this function only erases the + * element, and that if the element is itself a pointer, the pointed-to + * memory is not touched in any way. Managing the pointer is the user's + * responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_set. For an %unordered_set the result of this function + * can only be 0 (not present) or 1 (present). + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_set. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an %unordered_set. + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_set. Note that this function only + * erases the elements, and that if the elements themselves are pointers, + * the pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_set. + * @param __x An %unordered_set of the same element and allocator + * types. + * + * This exchanges the elements between two sets in constant time. + * Note that the global std::swap() function is specialized such that + * std::swap(s1,s2) will feed to this function. + */ + void + swap(unordered_set& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper = _Hash_merge_helper; + _M_h._M_merge_unique(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_set was + /// constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_set was + /// constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_set. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __k) + -> decltype(_M_h._M_find_tr(__k)) + { return _M_h._M_find_tr(__k); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __k) const + -> decltype(_M_h._M_find_tr(__k)) + { return _M_h._M_find_tr(__k); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Element to located. + * @return Number of elements with specified key. + * + * This function only makes sense for unordered_multisets; for + * unordered_set the result will either be 0 (not present) or 1 + * (present). + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __k) const + -> decltype(_M_h._M_count_tr(__k)) + { return _M_h._M_count_tr(__k); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __k) const + -> decltype(_M_h._M_find_tr(__k), void(), true) + { return _M_h._M_find_tr(__k) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + * + * This function probably only makes sense for multisets. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __k) + -> decltype(_M_h._M_equal_range_tr(__k)) + { return _M_h._M_equal_range_tr(__k); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __k) const + -> decltype(_M_h._M_equal_range_tr(__k)) + { return _M_h._M_equal_range_tr(__k); } +#endif + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_set. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_set. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_set tries to keep the + /// load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_set maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_set. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_set maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_set for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&, + const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&); + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, _Allocator) + -> unordered_set::value_type, + hash< + typename iterator_traits<_InputIterator>::value_type>, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, + _Hash, _Allocator) + -> unordered_set::value_type, + _Hash, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Allocator) + -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Hash, _Allocator) + -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + + /** + * @brief A standard container composed of equivalent keys + * (possibly containing multiple of each key value) in which the + * elements' keys are the elements themselves. + * + * @ingroup unordered_associative_containers + * + * @tparam _Value Type of key objects. + * @tparam _Hash Hashing function object type, defaults to hash<_Value>. + * @tparam _Pred Predicate function object type, defaults + * to equal_to<_Value>. + * @tparam _Alloc Allocator type, defaults to allocator<_Key>. + * + * Meets the requirements of a container, and + * unordered associative container + * + * Base is _Hashtable, dispatched at compile time via template + * alias __umset_hashtable. + */ + template, + typename _Pred = equal_to<_Value>, + typename _Alloc = allocator<_Value>> + class unordered_multiset + { + typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable; + _Hashtable _M_h; + + public: + // typedefs: + ///@{ + /// Public typedefs. + typedef typename _Hashtable::key_type key_type; + typedef typename _Hashtable::value_type value_type; + typedef typename _Hashtable::hasher hasher; + typedef typename _Hashtable::key_equal key_equal; + typedef typename _Hashtable::allocator_type allocator_type; + ///@} + + ///@{ + /// Iterator-related typedefs. + typedef typename _Hashtable::pointer pointer; + typedef typename _Hashtable::const_pointer const_pointer; + typedef typename _Hashtable::reference reference; + typedef typename _Hashtable::const_reference const_reference; + typedef typename _Hashtable::iterator iterator; + typedef typename _Hashtable::const_iterator const_iterator; + typedef typename _Hashtable::local_iterator local_iterator; + typedef typename _Hashtable::const_local_iterator const_local_iterator; + typedef typename _Hashtable::size_type size_type; + typedef typename _Hashtable::difference_type difference_type; + ///@} + +#if __cplusplus > 201402L + using node_type = typename _Hashtable::node_type; +#endif + + // construct/destroy/copy + + /// Default constructor. + unordered_multiset() = default; + + /** + * @brief Default constructor creates no elements. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + */ + explicit + unordered_multiset(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__n, __hf, __eql, __a) + { } + + /** + * @brief Builds an %unordered_multiset from a range. + * @param __first An input iterator. + * @param __last An input iterator. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multiset consisting of copies of the elements + * from [__first,__last). This is linear in N (where N is + * distance(__first,__last)). + */ + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__first, __last, __n, __hf, __eql, __a) + { } + + /// Copy constructor. + unordered_multiset(const unordered_multiset&) = default; + + /// Move constructor. + unordered_multiset(unordered_multiset&&) = default; + + /** + * @brief Builds an %unordered_multiset from an initializer_list. + * @param __l An initializer_list. + * @param __n Minimal initial number of buckets. + * @param __hf A hash functor. + * @param __eql A key equality functor. + * @param __a An allocator object. + * + * Create an %unordered_multiset consisting of copies of the elements in + * the list. This is linear in N (where N is @a __l.size()). + */ + unordered_multiset(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _M_h(__l, __n, __hf, __eql, __a) + { } + + /// Copy assignment operator. + unordered_multiset& + operator=(const unordered_multiset&) = default; + + /// Move assignment operator. + unordered_multiset& + operator=(unordered_multiset&&) = default; + + /** + * @brief Creates an %unordered_multiset with no elements. + * @param __a An allocator object. + */ + explicit + unordered_multiset(const allocator_type& __a) + : _M_h(__a) + { } + + /* + * @brief Copy constructor with allocator argument. + * @param __uset Input %unordered_multiset to copy. + * @param __a An allocator object. + */ + unordered_multiset(const unordered_multiset& __umset, + const allocator_type& __a) + : _M_h(__umset._M_h, __a) + { } + + /* + * @brief Move constructor with allocator argument. + * @param __umset Input %unordered_multiset to move. + * @param __a An allocator object. + */ + unordered_multiset(unordered_multiset&& __umset, + const allocator_type& __a) + noexcept( noexcept(_Hashtable(std::move(__umset._M_h), __a)) ) + : _M_h(std::move(__umset._M_h), __a) + { } + + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) + { } + + unordered_multiset(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) + { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_multiset(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_multiset(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_multiset(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__l, __n, __hf, key_equal(), __a) + { } + + /** + * @brief %Unordered_multiset list assignment operator. + * @param __l An initializer_list. + * + * This function fills an %unordered_multiset with copies of the elements + * in the initializer list @a __l. + * + * Note that the assignment completely changes the %unordered_multiset + * and that the resulting %unordered_multiset's size is the same as the + * number of elements assigned. + */ + unordered_multiset& + operator=(initializer_list __l) + { + _M_h = __l; + return *this; + } + + /// Returns the allocator object used by the %unordered_multiset. + allocator_type + get_allocator() const noexcept + { return _M_h.get_allocator(); } + + // size and capacity: + + /// Returns true if the %unordered_multiset is empty. + _GLIBCXX_NODISCARD bool + empty() const noexcept + { return _M_h.empty(); } + + /// Returns the size of the %unordered_multiset. + size_type + size() const noexcept + { return _M_h.size(); } + + /// Returns the maximum size of the %unordered_multiset. + size_type + max_size() const noexcept + { return _M_h.max_size(); } + + // iterators. + + ///@{ + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_multiset. + */ + iterator + begin() noexcept + { return _M_h.begin(); } + + const_iterator + begin() const noexcept + { return _M_h.begin(); } + ///@} + + ///@{ + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_multiset. + */ + iterator + end() noexcept + { return _M_h.end(); } + + const_iterator + end() const noexcept + { return _M_h.end(); } + ///@} + + /** + * Returns a read-only (constant) iterator that points to the first + * element in the %unordered_multiset. + */ + const_iterator + cbegin() const noexcept + { return _M_h.begin(); } + + /** + * Returns a read-only (constant) iterator that points one past the last + * element in the %unordered_multiset. + */ + const_iterator + cend() const noexcept + { return _M_h.end(); } + + // modifiers. + + /** + * @brief Builds and insert an element into the %unordered_multiset. + * @param __args Arguments used to generate an element. + * @return An iterator that points to the inserted element. + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace(_Args&&... __args) + { return _M_h.emplace(std::forward<_Args>(__args)...); } + + /** + * @brief Inserts an element into the %unordered_multiset. + * @param __pos An iterator that serves as a hint as to where the + * element should be inserted. + * @param __args Arguments used to generate the element to be + * inserted. + * @return An iterator that points to the inserted element. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant time. + */ + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); } + + ///@{ + /** + * @brief Inserts an element into the %unordered_multiset. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * Insertion requires amortized constant time. + */ + iterator + insert(const value_type& __x) + { return _M_h.insert(__x); } + + iterator + insert(value_type&& __x) + { return _M_h.insert(std::move(__x)); } + ///@} + + ///@{ + /** + * @brief Inserts an element into the %unordered_multiset. + * @param __hint An iterator that serves as a hint as to where the + * element should be inserted. + * @param __x Element to be inserted. + * @return An iterator that points to the inserted element. + * + * Note that the first parameter is only a hint and can potentially + * improve the performance of the insertion process. A bad hint would + * cause no gains in efficiency. + * + * For more on @a hinting, see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints + * + * Insertion requires amortized constant. + */ + iterator + insert(const_iterator __hint, const value_type& __x) + { return _M_h.insert(__hint, __x); } + + iterator + insert(const_iterator __hint, value_type&& __x) + { return _M_h.insert(__hint, std::move(__x)); } + ///@} + + /** + * @brief A template function that inserts a range of elements. + * @param __first Iterator pointing to the start of the range to be + * inserted. + * @param __last Iterator pointing to the end of the range. + * + * Complexity similar to that of the range constructor. + */ + template + void + insert(_InputIterator __first, _InputIterator __last) + { _M_h.insert(__first, __last); } + + /** + * @brief Inserts a list of elements into the %unordered_multiset. + * @param __l A std::initializer_list of elements to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list __l) + { _M_h.insert(__l); } + +#if __cplusplus > 201402L + /// Extract a node. + node_type + extract(const_iterator __pos) + { + __glibcxx_assert(__pos != end()); + return _M_h.extract(__pos); + } + + /// Extract a node. + node_type + extract(const key_type& __key) + { return _M_h.extract(__key); } + + /// Re-insert an extracted node. + iterator + insert(node_type&& __nh) + { return _M_h._M_reinsert_node_multi(cend(), std::move(__nh)); } + + /// Re-insert an extracted node. + iterator + insert(const_iterator __hint, node_type&& __nh) + { return _M_h._M_reinsert_node_multi(__hint, std::move(__nh)); } +#endif // C++17 + + ///@{ + /** + * @brief Erases an element from an %unordered_multiset. + * @param __position An iterator pointing to the element to be erased. + * @return An iterator pointing to the element immediately following + * @a __position prior to the element being erased. If no such + * element exists, end() is returned. + * + * This function erases an element, pointed to by the given iterator, + * from an %unordered_multiset. + * + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __position) + { return _M_h.erase(__position); } + + // LWG 2059. + iterator + erase(iterator __position) + { return _M_h.erase(__position); } + ///@} + + + /** + * @brief Erases elements according to the provided key. + * @param __x Key of element to be erased. + * @return The number of elements erased. + * + * This function erases all the elements located by the given key from + * an %unordered_multiset. + * + * Note that this function only erases the element, and that if the + * element is itself a pointer, the pointed-to memory is not touched in + * any way. Managing the pointer is the user's responsibility. + */ + size_type + erase(const key_type& __x) + { return _M_h.erase(__x); } + + /** + * @brief Erases a [__first,__last) range of elements from an + * %unordered_multiset. + * @param __first Iterator pointing to the start of the range to be + * erased. + * @param __last Iterator pointing to the end of the range to + * be erased. + * @return The iterator @a __last. + * + * This function erases a sequence of elements from an + * %unordered_multiset. + * + * Note that this function only erases the element, and that if + * the element is itself a pointer, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + iterator + erase(const_iterator __first, const_iterator __last) + { return _M_h.erase(__first, __last); } + + /** + * Erases all elements in an %unordered_multiset. + * + * Note that this function only erases the elements, and that if the + * elements themselves are pointers, the pointed-to memory is not touched + * in any way. Managing the pointer is the user's responsibility. + */ + void + clear() noexcept + { _M_h.clear(); } + + /** + * @brief Swaps data with another %unordered_multiset. + * @param __x An %unordered_multiset of the same element and allocator + * types. + * + * This exchanges the elements between two sets in constant time. + * Note that the global std::swap() function is specialized such that + * std::swap(s1,s2) will feed to this function. + */ + void + swap(unordered_multiset& __x) + noexcept( noexcept(_M_h.swap(__x._M_h)) ) + { _M_h.swap(__x._M_h); } + +#if __cplusplus > 201402L + template + friend class std::_Hash_merge_helper; + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_multiset<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>& __source) + { + using _Merge_helper + = _Hash_merge_helper; + _M_h._M_merge_multi(_Merge_helper::_S_get_table(__source)); + } + + template + void + merge(unordered_set<_Value, _H2, _P2, _Alloc>&& __source) + { merge(__source); } +#endif // C++17 + + // observers. + + /// Returns the hash functor object with which the %unordered_multiset + /// was constructed. + hasher + hash_function() const + { return _M_h.hash_function(); } + + /// Returns the key comparison object with which the %unordered_multiset + /// was constructed. + key_equal + key_eq() const + { return _M_h.key_eq(); } + + // lookup. + + ///@{ + /** + * @brief Tries to locate an element in an %unordered_multiset. + * @param __x Element to be located. + * @return Iterator pointing to sought-after element, or end() if not + * found. + * + * This function takes a key and tries to locate the element with which + * the key matches. If successful the function returns an iterator + * pointing to the sought after element. If unsuccessful it returns the + * past-the-end ( @c end() ) iterator. + */ + iterator + find(const key_type& __x) + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) + -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + + const_iterator + find(const key_type& __x) const + { return _M_h.find(__x); } + +#if __cplusplus > 201703L + template + auto + find(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x)) + { return _M_h._M_find_tr(__x); } +#endif + ///@} + + ///@{ + /** + * @brief Finds the number of elements. + * @param __x Element to located. + * @return Number of elements with specified key. + */ + size_type + count(const key_type& __x) const + { return _M_h.count(__x); } + +#if __cplusplus > 201703L + template + auto + count(const _Kt& __x) const -> decltype(_M_h._M_count_tr(__x)) + { return _M_h._M_count_tr(__x); } +#endif + ///@} + +#if __cplusplus > 201703L + ///@{ + /** + * @brief Finds whether an element with the given key exists. + * @param __x Key of elements to be located. + * @return True if there is any element with the specified key. + */ + bool + contains(const key_type& __x) const + { return _M_h.find(__x) != _M_h.end(); } + + template + auto + contains(const _Kt& __x) const + -> decltype(_M_h._M_find_tr(__x), void(), true) + { return _M_h._M_find_tr(__x) != _M_h.end(); } + ///@} +#endif + + ///@{ + /** + * @brief Finds a subsequence matching given key. + * @param __x Key to be located. + * @return Pair of iterators that possibly points to the subsequence + * matching given key. + */ + std::pair + equal_range(const key_type& __x) + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + + std::pair + equal_range(const key_type& __x) const + { return _M_h.equal_range(__x); } + +#if __cplusplus > 201703L + template + auto + equal_range(const _Kt& __x) const + -> decltype(_M_h._M_equal_range_tr(__x)) + { return _M_h._M_equal_range_tr(__x); } +#endif + ///@} + + // bucket interface. + + /// Returns the number of buckets of the %unordered_multiset. + size_type + bucket_count() const noexcept + { return _M_h.bucket_count(); } + + /// Returns the maximum number of buckets of the %unordered_multiset. + size_type + max_bucket_count() const noexcept + { return _M_h.max_bucket_count(); } + + /* + * @brief Returns the number of elements in a given bucket. + * @param __n A bucket index. + * @return The number of elements in the bucket. + */ + size_type + bucket_size(size_type __n) const + { return _M_h.bucket_size(__n); } + + /* + * @brief Returns the bucket index of a given element. + * @param __key A key instance. + * @return The key bucket index. + */ + size_type + bucket(const key_type& __key) const + { return _M_h.bucket(__key); } + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to the first + * bucket element. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + begin(size_type __n) + { return _M_h.begin(__n); } + + const_local_iterator + begin(size_type __n) const + { return _M_h.begin(__n); } + + const_local_iterator + cbegin(size_type __n) const + { return _M_h.cbegin(__n); } + ///@} + + ///@{ + /** + * @brief Returns a read-only (constant) iterator pointing to one past + * the last bucket elements. + * @param __n The bucket index. + * @return A read-only local iterator. + */ + local_iterator + end(size_type __n) + { return _M_h.end(__n); } + + const_local_iterator + end(size_type __n) const + { return _M_h.end(__n); } + + const_local_iterator + cend(size_type __n) const + { return _M_h.cend(__n); } + ///@} + + // hash policy. + + /// Returns the average number of elements per bucket. + float + load_factor() const noexcept + { return _M_h.load_factor(); } + + /// Returns a positive number that the %unordered_multiset tries to keep the + /// load factor less than or equal to. + float + max_load_factor() const noexcept + { return _M_h.max_load_factor(); } + + /** + * @brief Change the %unordered_multiset maximum load factor. + * @param __z The new maximum load factor. + */ + void + max_load_factor(float __z) + { _M_h.max_load_factor(__z); } + + /** + * @brief May rehash the %unordered_multiset. + * @param __n The new number of buckets. + * + * Rehash will occur only if the new number of buckets respect the + * %unordered_multiset maximum load factor. + */ + void + rehash(size_type __n) + { _M_h.rehash(__n); } + + /** + * @brief Prepare the %unordered_multiset for a specified number of + * elements. + * @param __n Number of elements required. + * + * Same as rehash(ceil(n / max_load_factor())). + */ + void + reserve(size_type __n) + { _M_h.reserve(__n); } + + template + friend bool + operator==(const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&, + const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&); + }; + + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset::value_type, + hash::value_type>, + equal_to::value_type>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, + _Hash, _Allocator) + -> unordered_multiset::value_type, + _Hash, + equal_to< + typename + iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Hash, _Allocator) + -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + + template + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + + template + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_h._M_equal(__y._M_h); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + +_GLIBCXX_END_NAMESPACE_CONTAINER + +#if __cplusplus > 201402L + // Allow std::unordered_set access to internals of compatible sets. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_set<_Val, _Hash1, _Eq1, _Alloc>, _Hash2, _Eq2> + { + private: + template + using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>; + template + using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>; + + friend unordered_set<_Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + + static auto& + _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + }; + + // Allow std::unordered_multiset access to internals of compatible sets. + template + struct _Hash_merge_helper< + _GLIBCXX_STD_C::unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>, + _Hash2, _Eq2> + { + private: + template + using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>; + template + using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>; + + friend unordered_multiset<_Val, _Hash1, _Eq1, _Alloc>; + + static auto& + _S_get_table(unordered_set<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + + static auto& + _S_get_table(unordered_multiset<_Val, _Hash2, _Eq2, _Alloc>& __set) + { return __set._M_h; } + }; +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _UNORDERED_SET_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uses_allocator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uses_allocator.h new file mode 100755 index 0000000..36b219c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uses_allocator.h @@ -0,0 +1,195 @@ +// Uses-allocator Construction -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +#ifndef _USES_ALLOCATOR_H +#define _USES_ALLOCATOR_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // This is used for std::experimental::erased_type from Library Fundamentals. + struct __erased_type { }; + + // This also supports the "type-erased allocator" protocol from the + // Library Fundamentals TS, where allocator_type is erased_type. + // The second condition will always be false for types not using the TS. + template + using __is_erased_or_convertible + = __or_, is_same<_Tp, __erased_type>>; + + /// [allocator.tag] + struct allocator_arg_t { explicit allocator_arg_t() = default; }; + + _GLIBCXX17_INLINE constexpr allocator_arg_t allocator_arg = + allocator_arg_t(); + + template> + struct __uses_allocator_helper + : false_type { }; + + template + struct __uses_allocator_helper<_Tp, _Alloc, + __void_t> + : __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type + { }; + + /// [allocator.uses.trait] + template + struct uses_allocator + : __uses_allocator_helper<_Tp, _Alloc>::type + { }; + + struct __uses_alloc_base { }; + + struct __uses_alloc0 : __uses_alloc_base + { + struct _Sink { void _GLIBCXX20_CONSTEXPR operator=(const void*) { } } _M_a; + }; + + template + struct __uses_alloc1 : __uses_alloc_base { const _Alloc* _M_a; }; + + template + struct __uses_alloc2 : __uses_alloc_base { const _Alloc* _M_a; }; + + template + struct __uses_alloc; + + template + struct __uses_alloc + : conditional< + is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value, + __uses_alloc1<_Alloc>, + __uses_alloc2<_Alloc>>::type + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2586. Wrong value category used in scoped_allocator_adaptor::construct + static_assert(__or_< + is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>, + is_constructible<_Tp, _Args..., const _Alloc&>>::value, + "construction with an allocator must be possible" + " if uses_allocator is true"); + }; + + template + struct __uses_alloc + : __uses_alloc0 { }; + + template + using __uses_alloc_t = + __uses_alloc::value, _Tp, _Alloc, _Args...>; + + template + _GLIBCXX20_CONSTEXPR + inline __uses_alloc_t<_Tp, _Alloc, _Args...> + __use_alloc(const _Alloc& __a) + { + __uses_alloc_t<_Tp, _Alloc, _Args...> __ret; + __ret._M_a = std::__addressof(__a); + return __ret; + } + + template + void + __use_alloc(const _Alloc&&) = delete; + +#if __cplusplus > 201402L + template + inline constexpr bool uses_allocator_v = + uses_allocator<_Tp, _Alloc>::value; +#endif // C++17 + + template class _Predicate, + typename _Tp, typename _Alloc, typename... _Args> + struct __is_uses_allocator_predicate + : conditional::value, + __or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>, + _Predicate<_Tp, _Args..., _Alloc>>, + _Predicate<_Tp, _Args...>>::type { }; + + template + struct __is_uses_allocator_constructible + : __is_uses_allocator_predicate + { }; + +#if __cplusplus >= 201402L + template + _GLIBCXX17_INLINE constexpr bool __is_uses_allocator_constructible_v = + __is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; +#endif // C++14 + + template + struct __is_nothrow_uses_allocator_constructible + : __is_uses_allocator_predicate + { }; + + +#if __cplusplus >= 201402L + template + _GLIBCXX17_INLINE constexpr bool + __is_nothrow_uses_allocator_constructible_v = + __is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; +#endif // C++14 + + template + void __uses_allocator_construct_impl(__uses_alloc0 __a, _Tp* __ptr, + _Args&&... __args) + { ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)...); } + + template + void __uses_allocator_construct_impl(__uses_alloc1<_Alloc> __a, _Tp* __ptr, + _Args&&... __args) + { + ::new ((void*)__ptr) _Tp(allocator_arg, *__a._M_a, + std::forward<_Args>(__args)...); + } + + template + void __uses_allocator_construct_impl(__uses_alloc2<_Alloc> __a, _Tp* __ptr, + _Args&&... __args) + { ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)..., *__a._M_a); } + + template + void __uses_allocator_construct(const _Alloc& __a, _Tp* __ptr, + _Args&&... __args) + { + std::__uses_allocator_construct_impl( + std::__use_alloc<_Tp, _Alloc, _Args...>(__a), __ptr, + std::forward<_Args>(__args)...); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uses_allocator_args.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uses_allocator_args.h new file mode 100755 index 0000000..8b548ff --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/uses_allocator_args.h @@ -0,0 +1,227 @@ +// Utility functions for uses-allocator construction -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1997-1999 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ + +/** @file include/bits/uses_allocator_args.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{memory} + */ + +#ifndef _USES_ALLOCATOR_ARGS +#define _USES_ALLOCATOR_ARGS 1 + +#pragma GCC system_header + +#if __cplusplus > 201703L && __cpp_concepts + +#include // for placement operator new +#include // for tuple, make_tuple, make_from_tuple +#include // construct_at +#include // pair + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline constexpr bool __is_pair = false; + template + inline constexpr bool __is_pair> = true; + template + inline constexpr bool __is_pair> = true; + + template + concept _Std_pair = __is_pair<_Tp>; + +/** @addtogroup allocators + * @{ + */ + +// Not specified by C++20, used internally +#define __cpp_lib_make_obj_using_allocator 201811L + + template + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + _Args&&... __args) noexcept + requires (! _Std_pair<_Tp>) + { + if constexpr (uses_allocator_v, _Alloc>) + { + if constexpr (is_constructible_v<_Tp, allocator_arg_t, + const _Alloc&, _Args...>) + { + return tuple( + allocator_arg, __a, std::forward<_Args>(__args)...); + } + else + { + static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>, + "construction with an allocator must be possible" + " if uses_allocator is true"); + + return tuple<_Args&&..., const _Alloc&>( + std::forward<_Args>(__args)..., __a); + } + } + else + { + static_assert(is_constructible_v<_Tp, _Args...>); + + return tuple<_Args&&...>(std::forward<_Args>(__args)...); + } + } + + template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t, + _Tuple1&& __x, _Tuple2&& __y) noexcept; + + template<_Std_pair _Tp, typename _Alloc> + constexpr auto + uses_allocator_construction_args(const _Alloc&) noexcept; + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, _Up&&, _Vp&&) noexcept; + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, + const pair<_Up, _Vp>&) noexcept; + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept; + + template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t, + _Tuple1&& __x, _Tuple2&& __y) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::apply([&__a](auto&&... __args1) { + return std::uses_allocator_construction_args<_Tp1>( + __a, std::forward(__args1)...); + }, std::forward<_Tuple1>(__x)), + std::apply([&__a](auto&&... __args2) { + return std::uses_allocator_construction_args<_Tp2>( + __a, std::forward(__args2)...); + }, std::forward<_Tuple2>(__y))); + } + + template<_Std_pair _Tp, typename _Alloc> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a), + std::uses_allocator_construction_args<_Tp2>(__a)); + } + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, _Up&& __u, _Vp&& __v) + noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, + std::forward<_Up>(__u)), + std::uses_allocator_construction_args<_Tp2>(__a, + std::forward<_Vp>(__v))); + } + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + const pair<_Up, _Vp>& __pr) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, __pr.first), + std::uses_allocator_construction_args<_Tp2>(__a, __pr.second)); + } + + template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp> + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + pair<_Up, _Vp>&& __pr) noexcept + { + using _Tp1 = typename _Tp::first_type; + using _Tp2 = typename _Tp::second_type; + + return std::make_tuple(piecewise_construct, + std::uses_allocator_construction_args<_Tp1>(__a, + std::move(__pr).first), + std::uses_allocator_construction_args<_Tp2>(__a, + std::move(__pr).second)); + } + + template + inline _Tp + make_obj_using_allocator(const _Alloc& __a, _Args&&... __args) + { + return std::make_from_tuple<_Tp>( + std::uses_allocator_construction_args<_Tp>(__a, + std::forward<_Args>(__args)...)); + } + + template + inline _Tp* + uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a, + _Args&&... __args) + { + return std::apply([&](auto&&... __xs) { + return std::construct_at(__p, std::forward(__xs)...); + }, std::uses_allocator_construction_args<_Tp>(__a, + std::forward<_Args>(__args)...)); + } +/// @} +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 +#endif // _USES_ALLOCATOR_ARGS diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_after.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_after.h new file mode 100755 index 0000000..79f4005 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_after.h @@ -0,0 +1,556 @@ +// The template and inlines for the -*- C++ -*- internal _Meta class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_after.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_AFTER_H +#define _VALARRAY_AFTER_H 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace __detail +{ + // + // gslice_array closure. + // + template + class _GBase + { + public: + typedef typename _Dom::value_type value_type; + + _GBase (const _Dom& __e, const valarray& __i) + : _M_expr (__e), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + const valarray& _M_index; + }; + + template + class _GBase<_Array<_Tp> > + { + public: + typedef _Tp value_type; + + _GBase (_Array<_Tp> __a, const valarray& __i) + : _M_array (__a), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } + + private: + const _Array<_Tp> _M_array; + const valarray& _M_index; + }; + + template + struct _GClos<_Expr, _Dom> + : _GBase<_Dom> + { + typedef _GBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _GClos (const _Dom& __e, const valarray& __i) + : _Base (__e, __i) {} + }; + + template + struct _GClos<_ValArray, _Tp> + : _GBase<_Array<_Tp> > + { + typedef _GBase<_Array<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _GClos (_Array<_Tp> __a, const valarray& __i) + : _Base (__a, __i) {} + }; + + // + // indirect_array closure + // + template + class _IBase + { + public: + typedef typename _Dom::value_type value_type; + + _IBase (const _Dom& __e, const valarray& __i) + : _M_expr (__e), _M_index (__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size() const + { return _M_index.size(); } + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + const valarray& _M_index; + }; + + template + struct _IClos<_Expr, _Dom> + : _IBase<_Dom> + { + typedef _IBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _IClos (const _Dom& __e, const valarray& __i) + : _Base (__e, __i) {} + }; + + template + struct _IClos<_ValArray, _Tp> + : _IBase > + { + typedef _IBase > _Base; + typedef _Tp value_type; + + _IClos (const valarray<_Tp>& __a, const valarray& __i) + : _Base (__a, __i) {} + }; +} // namespace __detail + + // + // class _Expr + // + template + class _Expr + { + public: + typedef _Tp value_type; + + _Expr(const _Clos&); + + const _Clos& operator()() const; + + value_type operator[](size_t) const; + valarray operator[](slice) const; + valarray operator[](const gslice&) const; + valarray operator[](const valarray&) const; + valarray operator[](const valarray&) const; + + _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type> + operator+() const; + + _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type> + operator-() const; + + _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type> + operator~() const; + + _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool> + operator!() const; + + size_t size() const; + value_type sum() const; + + valarray shift(int) const; + valarray cshift(int) const; + + value_type min() const; + value_type max() const; + + valarray apply(value_type (*)(const value_type&)) const; + valarray apply(value_type (*)(value_type)) const; + + private: + const _Clos _M_closure; + }; + + template + inline + _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {} + + template + inline const _Clos& + _Expr<_Clos, _Tp>::operator()() const + { return _M_closure; } + + template + inline _Tp + _Expr<_Clos, _Tp>::operator[](size_t __i) const + { return _M_closure[__i]; } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](slice __s) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__s]; + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__gs]; + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](const valarray& __m) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__m]; + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::operator[](const valarray& __i) const + { + valarray<_Tp> __v = valarray<_Tp>(*this)[__i]; + return __v; + } + + template + inline size_t + _Expr<_Clos, _Tp>::size() const + { return _M_closure.size(); } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::shift(int __n) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n); + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::cshift(int __n) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n); + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); + return __v; + } + + template + inline valarray<_Tp> + _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const + { + valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); + return __v; + } + + // XXX: replace this with a more robust summation algorithm. + template + inline _Tp + _Expr<_Clos, _Tp>::sum() const + { + size_t __n = _M_closure.size(); + if (__n == 0) + return _Tp(); + else + { + _Tp __s = _M_closure[--__n]; + while (__n != 0) + __s += _M_closure[--__n]; + return __s; + } + } + + template + inline _Tp + _Expr<_Clos, _Tp>::min() const + { return __valarray_min(_M_closure); } + + template + inline _Tp + _Expr<_Clos, _Tp>::max() const + { return __valarray_max(_M_closure); } + + template + inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool> + _Expr<_Dom, _Tp>::operator!() const + { + typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure; + return _Expr<_Closure, bool>(_Closure(this->_M_closure)); + } + +#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ + template \ + inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \ + _Expr<_Dom, _Tp>::operator _Op() const \ + { \ + typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \ + } + + _DEFINE_EXPR_UNARY_OPERATOR(+, struct std::__unary_plus) + _DEFINE_EXPR_UNARY_OPERATOR(-, struct std::__negate) + _DEFINE_EXPR_UNARY_OPERATOR(~, struct std::__bitwise_not) + +#undef _DEFINE_EXPR_UNARY_OPERATOR + +#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \ + typename __fun<_Name, typename _Dom1::value_type>::result_type> \ + operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __w) \ + { \ + typedef typename _Dom1::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \ + typename _Dom::value_type>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \ + const typename _Dom::value_type& __t) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const typename _Dom::value_type& __t, \ + const _Expr<_Dom, typename _Dom::value_type>& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__t, __v())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _Expr, _ValArray, \ + _Dom, typename _Dom::value_type>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \ + const valarray& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_Name, _ValArray, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const valarray& __v, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef typename __fun<_Name, _Tp>::result_type _Value; \ + typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \ + } + + _DEFINE_EXPR_BINARY_OPERATOR(+, struct std::__plus) + _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) + _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) + _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) + _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) + _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor) + _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) + _DEFINE_EXPR_BINARY_OPERATOR(|, struct std::__bitwise_or) + _DEFINE_EXPR_BINARY_OPERATOR(<<, struct std::__shift_left) + _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right) + _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) + _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or) + _DEFINE_EXPR_BINARY_OPERATOR(==, struct std::__equal_to) + _DEFINE_EXPR_BINARY_OPERATOR(!=, struct std::__not_equal_to) + _DEFINE_EXPR_BINARY_OPERATOR(<, struct std::__less) + _DEFINE_EXPR_BINARY_OPERATOR(>, struct std::__greater) + _DEFINE_EXPR_BINARY_OPERATOR(<=, struct std::__less_equal) + _DEFINE_EXPR_BINARY_OPERATOR(>=, struct std::__greater_equal) + +#undef _DEFINE_EXPR_BINARY_OPERATOR + +#define _DEFINE_EXPR_UNARY_FUNCTION(_Name, _UName) \ + template \ + inline _Expr<_UnClos<_UName, _Expr, _Dom>, \ + typename _Dom::value_type> \ + _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _UnClos<_UName, _Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e())); \ + } \ + \ + template \ + inline _Expr<_UnClos<_UName, _ValArray, _Tp>, _Tp> \ + _Name(const valarray<_Tp>& __v) \ + { \ + typedef _UnClos<_UName, _ValArray, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v)); \ + } + + _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) + _DEFINE_EXPR_UNARY_FUNCTION(cos, struct std::_Cos) + _DEFINE_EXPR_UNARY_FUNCTION(acos, struct std::_Acos) + _DEFINE_EXPR_UNARY_FUNCTION(cosh, struct std::_Cosh) + _DEFINE_EXPR_UNARY_FUNCTION(sin, struct std::_Sin) + _DEFINE_EXPR_UNARY_FUNCTION(asin, struct std::_Asin) + _DEFINE_EXPR_UNARY_FUNCTION(sinh, struct std::_Sinh) + _DEFINE_EXPR_UNARY_FUNCTION(tan, struct std::_Tan) + _DEFINE_EXPR_UNARY_FUNCTION(tanh, struct std::_Tanh) + _DEFINE_EXPR_UNARY_FUNCTION(atan, struct std::_Atan) + _DEFINE_EXPR_UNARY_FUNCTION(exp, struct std::_Exp) + _DEFINE_EXPR_UNARY_FUNCTION(log, struct std::_Log) + _DEFINE_EXPR_UNARY_FUNCTION(log10, struct std::_Log10) + _DEFINE_EXPR_UNARY_FUNCTION(sqrt, struct std::_Sqrt) + +#undef _DEFINE_EXPR_UNARY_FUNCTION + +#define _DEFINE_EXPR_BINARY_FUNCTION(_Fun, _UFun) \ + template \ + inline _Expr<_BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2>, \ + typename _Dom1::value_type> \ + _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \ + { \ + typedef typename _Dom1::value_type _Tp; \ + typedef _BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Expr, _ValArray, _Dom, \ + typename _Dom::value_type>, \ + typename _Dom::value_type> \ + _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ + const valarray& __v) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _Expr, _ValArray, _Dom, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _ValArray, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename _Dom::value_type> \ + _Fun(const valarray& __v, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Expr, _Constant, _Dom, \ + typename _Dom::value_type>, \ + typename _Dom::value_type> \ + _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ + const typename _Dom::value_type& __t) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _Expr, _Constant, _Dom, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename _Dom::value_type> \ + _Fun(const typename _Dom::value_type& __t, \ + const _Expr<_Dom, typename _Dom::value_type>& __e) \ + { \ + typedef typename _Dom::value_type _Tp; \ + typedef _BinClos<_UFun, _Constant, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \ + _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ + { \ + typedef _BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \ + _Fun(const valarray<_Tp>& __v, \ + const typename valarray<_Tp>::value_type& __t) \ + { \ + typedef _BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \ + } \ + \ + template \ + inline _Expr<_BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \ + _Fun(const typename valarray<_Tp>::value_type& __t, \ + const valarray<_Tp>& __v) \ + { \ + typedef _BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ + } + +_DEFINE_EXPR_BINARY_FUNCTION(atan2, struct std::_Atan2) +_DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow) + +#undef _DEFINE_EXPR_BINARY_FUNCTION + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _CPP_VALARRAY_AFTER_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_array.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_array.h new file mode 100755 index 0000000..3e2a9e8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_array.h @@ -0,0 +1,677 @@ +// The template and inlines for the -*- C++ -*- internal _Array helper class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_array.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_ARRAY_H +#define _VALARRAY_ARRAY_H 1 + +#pragma GCC system_header + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // + // Helper functions on raw pointers + // + + // We get memory the old fashioned way + template + _Tp* + __valarray_get_storage(size_t) __attribute__((__malloc__)); + + template + inline _Tp* + __valarray_get_storage(size_t __n) + { return static_cast<_Tp*>(operator new(__n * sizeof(_Tp))); } + + // Return memory to the system + inline void + __valarray_release_memory(void* __p) + { operator delete(__p); } + + // Turn a raw-memory into an array of _Tp filled with _Tp() + // This is required in 'valarray v(n);' + template + struct _Array_default_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(_Tp* __b, _Tp* __e) + { + while (__b != __e) + new(__b++) _Tp(); + } + }; + + template + struct _Array_default_ctor<_Tp, true> + { + // For fundamental types, it suffices to say 'memset()' + inline static void + _S_do_it(_Tp* __b, _Tp* __e) + { __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); } + }; + + template + inline void + __valarray_default_construct(_Tp* __b, _Tp* __e) + { + _Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e); + } + + // Turn a raw-memory into an array of _Tp filled with __t + // This is the required in valarray v(n, t). Also + // used in valarray<>::resize(). + template + struct _Array_init_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(_Tp* __b, _Tp* __e, const _Tp __t) + { + while (__b != __e) + new(__b++) _Tp(__t); + } + }; + + template + struct _Array_init_ctor<_Tp, true> + { + inline static void + _S_do_it(_Tp* __b, _Tp* __e, const _Tp __t) + { + while (__b != __e) + *__b++ = __t; + } + }; + + template + inline void + __valarray_fill_construct(_Tp* __b, _Tp* __e, const _Tp __t) + { + _Array_init_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e, __t); + } + + // + // copy-construct raw array [__o, *) from plain array [__b, __e) + // We can't just say 'memcpy()' + // + template + struct _Array_copy_ctor + { + // Please note that this isn't exception safe. But + // valarrays aren't required to be exception safe. + inline static void + _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o) + { + while (__b != __e) + new(__o++) _Tp(*__b++); + } + }; + + template + struct _Array_copy_ctor<_Tp, true> + { + inline static void + _S_do_it(const _Tp* __b, const _Tp* __e, _Tp* __restrict__ __o) + { + if (__b) + __builtin_memcpy(__o, __b, (__e - __b) * sizeof(_Tp)); + } + }; + + template + inline void + __valarray_copy_construct(const _Tp* __b, const _Tp* __e, + _Tp* __restrict__ __o) + { + _Array_copy_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e, __o); + } + + // copy-construct raw array [__o, *) from strided array __a[<__n : __s>] + template + inline void + __valarray_copy_construct (const _Tp* __restrict__ __a, size_t __n, + size_t __s, _Tp* __restrict__ __o) + { + if (__is_trivial(_Tp)) + while (__n--) + { + *__o++ = *__a; + __a += __s; + } + else + while (__n--) + { + new(__o++) _Tp(*__a); + __a += __s; + } + } + + // copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]] + template + inline void + __valarray_copy_construct (const _Tp* __restrict__ __a, + const size_t* __restrict__ __i, + _Tp* __restrict__ __o, size_t __n) + { + if (__is_trivial(_Tp)) + while (__n--) + *__o++ = __a[*__i++]; + else + while (__n--) + new (__o++) _Tp(__a[*__i++]); + } + + // Do the necessary cleanup when we're done with arrays. + template + inline void + __valarray_destroy_elements(_Tp* __b, _Tp* __e) + { + if (!__is_trivial(_Tp)) + while (__b != __e) + { + __b->~_Tp(); + ++__b; + } + } + + // Fill a plain array __a[<__n>] with __t + template + inline void + __valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t) + { + while (__n--) + *__a++ = __t; + } + + // fill strided array __a[<__n-1 : __s>] with __t + template + inline void + __valarray_fill(_Tp* __restrict__ __a, size_t __n, + size_t __s, const _Tp& __t) + { + for (size_t __i = 0; __i < __n; ++__i, __a += __s) + *__a = __t; + } + + // fill indirect array __a[__i[<__n>]] with __i + template + inline void + __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, + size_t __n, const _Tp& __t) + { + for (size_t __j = 0; __j < __n; ++__j, ++__i) + __a[*__i] = __t; + } + + // copy plain array __a[<__n>] in __b[<__n>] + // For non-fundamental types, it is wrong to say 'memcpy()' + template + struct _Array_copier + { + inline static void + _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) + { + while(__n--) + *__b++ = *__a++; + } + }; + + template + struct _Array_copier<_Tp, true> + { + inline static void + _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) + { + if (__n != 0) + __builtin_memcpy(__b, __a, __n * sizeof (_Tp)); + } + }; + + // Copy a plain array __a[<__n>] into a play array __b[<>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, + _Tp* __restrict__ __b) + { + _Array_copier<_Tp, __is_trivial(_Tp)>::_S_do_it(__a, __n, __b); + } + + // Copy strided array __a[<__n : __s>] in plain __b[<__n>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s, + _Tp* __restrict__ __b) + { + for (size_t __i = 0; __i < __n; ++__i, ++__b, __a += __s) + *__b = *__a; + } + + // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b, + size_t __n, size_t __s) + { + for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s) + *__b = *__a; + } + + // Copy strided array __src[<__n : __s1>] into another + // strided array __dst[< : __s2>]. Their sizes must match. + template + inline void + __valarray_copy(const _Tp* __restrict__ __src, size_t __n, size_t __s1, + _Tp* __restrict__ __dst, size_t __s2) + { + for (size_t __i = 0; __i < __n; ++__i) + __dst[__i * __s2] = __src[__i * __s1]; + } + + // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, + const size_t* __restrict__ __i, + _Tp* __restrict__ __b, size_t __n) + { + for (size_t __j = 0; __j < __n; ++__j, ++__b, ++__i) + *__b = __a[*__i]; + } + + // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] + template + inline void + __valarray_copy(const _Tp* __restrict__ __a, size_t __n, + _Tp* __restrict__ __b, const size_t* __restrict__ __i) + { + for (size_t __j = 0; __j < __n; ++__j, ++__a, ++__i) + __b[*__i] = *__a; + } + + // Copy the __n first elements of an indexed array __src[<__i>] into + // another indexed array __dst[<__j>]. + template + inline void + __valarray_copy(const _Tp* __restrict__ __src, size_t __n, + const size_t* __restrict__ __i, + _Tp* __restrict__ __dst, const size_t* __restrict__ __j) + { + for (size_t __k = 0; __k < __n; ++__k) + __dst[*__j++] = __src[*__i++]; + } + + // + // Compute the sum of elements in range [__f, __l) which must not be empty. + // This is a naive algorithm. It suffers from cancelling. + // In the future try to specialize for _Tp = float, double, long double + // using a more accurate algorithm. + // + template + inline _Tp + __valarray_sum(const _Tp* __f, const _Tp* __l) + { + _Tp __r = *__f++; + while (__f != __l) + __r += *__f++; + return __r; + } + + // Compute the min/max of an array-expression + template + inline typename _Ta::value_type + __valarray_min(const _Ta& __a) + { + size_t __s = __a.size(); + typedef typename _Ta::value_type _Value_type; + _Value_type __r = __s == 0 ? _Value_type() : __a[0]; + for (size_t __i = 1; __i < __s; ++__i) + { + _Value_type __t = __a[__i]; + if (__t < __r) + __r = __t; + } + return __r; + } + + template + inline typename _Ta::value_type + __valarray_max(const _Ta& __a) + { + size_t __s = __a.size(); + typedef typename _Ta::value_type _Value_type; + _Value_type __r = __s == 0 ? _Value_type() : __a[0]; + for (size_t __i = 1; __i < __s; ++__i) + { + _Value_type __t = __a[__i]; + if (__t > __r) + __r = __t; + } + return __r; + } + + // + // Helper class _Array, first layer of valarray abstraction. + // All operations on valarray should be forwarded to this class + // whenever possible. -- gdr + // + + template + struct _Array + { + explicit _Array(_Tp* const __restrict__); + explicit _Array(const valarray<_Tp>&); + _Array(const _Tp* __restrict__, size_t); + + _Tp* begin() const; + + _Tp* const __restrict__ _M_data; + }; + + + // Copy-construct plain array __b[<__n>] from indexed array __a[__i[<__n>]] + template + inline void + __valarray_copy_construct(_Array<_Tp> __a, _Array __i, + _Array<_Tp> __b, size_t __n) + { std::__valarray_copy_construct(__a._M_data, __i._M_data, + __b._M_data, __n); } + + // Copy-construct plain array __b[<__n>] from strided array __a[<__n : __s>] + template + inline void + __valarray_copy_construct(_Array<_Tp> __a, size_t __n, size_t __s, + _Array<_Tp> __b) + { std::__valarray_copy_construct(__a._M_data, __n, __s, __b._M_data); } + + template + inline void + __valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __t); } + + template + inline void + __valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __s, __t); } + + template + inline void + __valarray_fill(_Array<_Tp> __a, _Array __i, + size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); } + + // Copy a plain array __a[<__n>] into a play array __b[<>] + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) + { std::__valarray_copy(__a._M_data, __n, __b._M_data); } + + // Copy strided array __a[<__n : __s>] in plain __b[<__n>] + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s, _Array<_Tp> __b) + { std::__valarray_copy(__a._M_data, __n, __s, __b._M_data); } + + // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] + template + inline void + __valarray_copy(_Array<_Tp> __a, _Array<_Tp> __b, size_t __n, size_t __s) + { __valarray_copy(__a._M_data, __b._M_data, __n, __s); } + + // Copy strided array __src[<__n : __s1>] into another + // strided array __dst[< : __s2>]. Their sizes must match. + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, size_t __s1, + _Array<_Tp> __b, size_t __s2) + { std::__valarray_copy(__a._M_data, __n, __s1, __b._M_data, __s2); } + + // Copy an indexed array __a[__i[<__n>]] in plain array __b[<__n>] + template + inline void + __valarray_copy(_Array<_Tp> __a, _Array __i, + _Array<_Tp> __b, size_t __n) + { std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); } + + // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] + template + inline void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, + _Array __i) + { std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); } + + // Copy the __n first elements of an indexed array __src[<__i>] into + // another indexed array __dst[<__j>]. + template + inline void + __valarray_copy(_Array<_Tp> __src, size_t __n, _Array __i, + _Array<_Tp> __dst, _Array __j) + { + std::__valarray_copy(__src._M_data, __n, __i._M_data, + __dst._M_data, __j._M_data); + } + + template + inline + _Array<_Tp>::_Array(_Tp* const __restrict__ __p) + : _M_data (__p) {} + + template + inline + _Array<_Tp>::_Array(const valarray<_Tp>& __v) + : _M_data (__v._M_data) {} + + template + inline + _Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s) + : _M_data(__valarray_get_storage<_Tp>(__s)) + { std::__valarray_copy_construct(__b, __s, _M_data); } + + template + inline _Tp* + _Array<_Tp>::begin () const + { return _M_data; } + +#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \ + { \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \ + *__p _Op##= __t; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ + { \ + _Tp* __p = __a._M_data; \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \ + *__p _Op##= *__q; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__p) \ + *__p _Op##= __e[__i]; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \ + _Array<_Tp> __b) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \ + __p += __s, ++__q) \ + *__p _Op##= *__q; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \ + size_t __n, size_t __s) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, __q += __s) \ + *__p _Op##= *__q; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, __p += __s) \ + *__p _Op##= __e[__i]; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __i, \ + _Array<_Tp> __b, size_t __n) \ + { \ + _Tp* __q(__b._M_data); \ + for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \ + ++__j, ++__q) \ + __a._M_data[*__j] _Op##= *__q; \ + } \ + \ + template \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array __i) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \ + ++__j, ++__p) \ + *__p _Op##= __b._M_data[*__j]; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __i, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + size_t* __j(__i._M_data); \ + for (size_t __k = 0; __k<__n; ++__k, ++__j) \ + __a._M_data[*__j] _Op##= __e[__k]; \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __m, \ + _Array<_Tp> __b, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \ + ++__q, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= *__q; \ + } \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array __m) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, ++__ok, ++__q) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__q; \ + } \ + *__p _Op##= *__q; \ + } \ + } \ + \ + template \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array __m, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= __e[__i]; \ + } \ + } + + _DEFINE_ARRAY_FUNCTION(+, __plus) + _DEFINE_ARRAY_FUNCTION(-, __minus) + _DEFINE_ARRAY_FUNCTION(*, __multiplies) + _DEFINE_ARRAY_FUNCTION(/, __divides) + _DEFINE_ARRAY_FUNCTION(%, __modulus) + _DEFINE_ARRAY_FUNCTION(^, __bitwise_xor) + _DEFINE_ARRAY_FUNCTION(|, __bitwise_or) + _DEFINE_ARRAY_FUNCTION(&, __bitwise_and) + _DEFINE_ARRAY_FUNCTION(<<, __shift_left) + _DEFINE_ARRAY_FUNCTION(>>, __shift_right) + +#undef _DEFINE_ARRAY_FUNCTION + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +# include + +#endif /* _ARRAY_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_array.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_array.tcc new file mode 100755 index 0000000..0ea4409 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_array.tcc @@ -0,0 +1,244 @@ +// The template and inlines for the -*- C++ -*- internal _Array helper class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_array.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_ARRAY_TCC +#define _VALARRAY_ARRAY_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + void + __valarray_fill(_Array<_Tp> __a, size_t __n, _Array __m, + const _Tp& __t) + { + _Tp* __p = __a._M_data; + bool* __ok (__m._M_data); + for (size_t __i=0; __i < __n; ++__i, ++__ok, ++__p) + { + while (!*__ok) + { + ++__ok; + ++__p; + } + *__p = __t; + } + } + + // Copy n elements of a into consecutive elements of b. When m is + // false, the corresponding element of a is skipped. m must contain + // at least n true elements. a must contain at least n elements and + // enough elements to match up with m through the nth true element + // of m. I.e. if n is 10, m has 15 elements with 5 false followed + // by 10 true, a must have 15 elements. + template + void + __valarray_copy(_Array<_Tp> __a, _Array __m, _Array<_Tp> __b, + size_t __n) + { + _Tp* __p (__a._M_data); + bool* __ok (__m._M_data); + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; + ++__q, ++__ok, ++__p) + { + while (! *__ok) + { + ++__ok; + ++__p; + } + *__q = *__p; + } + } + + // Copy n consecutive elements from a into elements of b. Elements + // of b are skipped if the corresponding element of m is false. m + // must contain at least n true elements. b must have at least as + // many elements as the index of the nth true element of m. I.e. if + // m has 15 elements with 5 false followed by 10 true, b must have + // at least 15 elements. + template + void + __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, + _Array __m) + { + _Tp* __q (__b._M_data); + bool* __ok (__m._M_data); + for (_Tp* __p = __a._M_data; __p < __a._M_data+__n; + ++__p, ++__ok, ++__q) + { + while (! *__ok) + { + ++__ok; + ++__q; + } + *__q = *__p; + } + } + + // Copy n elements from a into elements of b. Elements of a are + // skipped if the corresponding element of m is false. Elements of + // b are skipped if the corresponding element of k is false. m and + // k must contain at least n true elements. a and b must have at + // least as many elements as the index of the nth true element of m. + template + void + __valarray_copy(_Array<_Tp> __a, _Array __m, size_t __n, + _Array<_Tp> __b, _Array __k) + { + _Tp* __p (__a._M_data); + _Tp* __q (__b._M_data); + bool* __srcok (__m._M_data); + bool* __dstok (__k._M_data); + for (size_t __i = 0; __i < __n; + ++__srcok, ++__p, ++__dstok, ++__q, ++__i) + { + while (! *__srcok) + { + ++__srcok; + ++__p; + } + while (! *__dstok) + { + ++__dstok; + ++__q; + } + *__q = *__p; + } + } + + // Copy n consecutive elements of e into consecutive elements of a. + // I.e. a[i] = e[i]. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a) + { + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, ++__p) + *__p = __e[__i]; + } + + // Copy n consecutive elements of e into elements of a using stride + // s. I.e., a[0] = e[0], a[s] = e[1], a[2*s] = e[2]. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a, size_t __s) + { + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, __p += __s) + *__p = __e[__i]; + } + + // Copy n consecutive elements of e into elements of a indexed by + // contents of i. I.e., a[i[0]] = e[0]. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a, _Array __i) + { + size_t* __j (__i._M_data); + for (size_t __k = 0; __k < __n; ++__k, ++__j) + __a._M_data[*__j] = __e[__k]; + } + + // Copy n elements of e indexed by contents of f into elements of a + // indexed by contents of i. I.e., a[i[0]] = e[f[0]]. + template + void + __valarray_copy(_Array<_Tp> __e, _Array __f, + size_t __n, + _Array<_Tp> __a, _Array __i) + { + size_t* __g (__f._M_data); + size_t* __j (__i._M_data); + for (size_t __k = 0; __k < __n; ++__k, ++__j, ++__g) + __a._M_data[*__j] = __e._M_data[*__g]; + } + + // Copy n consecutive elements of e into elements of a. Elements of + // a are skipped if the corresponding element of m is false. m must + // have at least n true elements and a must have at least as many + // elements as the index of the nth true element of m. I.e. if m + // has 5 false followed by 10 true elements and n == 10, a must have + // at least 15 elements. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a, _Array __m) + { + bool* __ok (__m._M_data); + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) + { + while (! *__ok) + { + ++__ok; + ++__p; + } + *__p = __e[__i]; + } + } + + + template + void + __valarray_copy_construct(const _Expr<_Dom, _Tp>& __e, size_t __n, + _Array<_Tp> __a) + { + _Tp* __p (__a._M_data); + for (size_t __i = 0; __i < __n; ++__i, ++__p) + new (__p) _Tp(__e[__i]); + } + + + template + void + __valarray_copy_construct(_Array<_Tp> __a, _Array __m, + _Array<_Tp> __b, size_t __n) + { + _Tp* __p (__a._M_data); + bool* __ok (__m._M_data); + for (_Tp* __q = __b._M_data; __q < __b._M_data+__n; ++__q, ++__ok, ++__p) + { + while (! *__ok) + { + ++__ok; + ++__p; + } + new (__q) _Tp(*__p); + } + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _VALARRAY_ARRAY_TCC */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_before.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_before.h new file mode 100755 index 0000000..80baeec --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/valarray_before.h @@ -0,0 +1,758 @@ +// The template and inlines for the -*- C++ -*- internal _Meta class. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/valarray_before.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{valarray} + */ + +// Written by Gabriel Dos Reis + +#ifndef _VALARRAY_BEFORE_H +#define _VALARRAY_BEFORE_H 1 + +#pragma GCC system_header + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // + // Implementing a loosened valarray return value is tricky. + // First we need to meet 26.3.1/3: we should not add more than + // two levels of template nesting. Therefore we resort to template + // template to "flatten" loosened return value types. + // At some point we use partial specialization to remove one level + // template nesting due to _Expr<> + // + + // This class is NOT defined. It doesn't need to. + template class _Constant; + + // Implementations of unary functions applied to valarray<>s. + // I use hard-coded object functions here instead of a generic + // approach like pointers to function: + // 1) correctness: some functions take references, others values. + // we can't deduce the correct type afterwards. + // 2) efficiency -- object functions can be easily inlined + // 3) be Koenig-lookup-friendly + + struct _Abs + { + template + _Tp operator()(const _Tp& __t) const + { return abs(__t); } + }; + + struct _Cos + { + template + _Tp operator()(const _Tp& __t) const + { return cos(__t); } + }; + + struct _Acos + { + template + _Tp operator()(const _Tp& __t) const + { return acos(__t); } + }; + + struct _Cosh + { + template + _Tp operator()(const _Tp& __t) const + { return cosh(__t); } + }; + + struct _Sin + { + template + _Tp operator()(const _Tp& __t) const + { return sin(__t); } + }; + + struct _Asin + { + template + _Tp operator()(const _Tp& __t) const + { return asin(__t); } + }; + + struct _Sinh + { + template + _Tp operator()(const _Tp& __t) const + { return sinh(__t); } + }; + + struct _Tan + { + template + _Tp operator()(const _Tp& __t) const + { return tan(__t); } + }; + + struct _Atan + { + template + _Tp operator()(const _Tp& __t) const + { return atan(__t); } + }; + + struct _Tanh + { + template + _Tp operator()(const _Tp& __t) const + { return tanh(__t); } + }; + + struct _Exp + { + template + _Tp operator()(const _Tp& __t) const + { return exp(__t); } + }; + + struct _Log + { + template + _Tp operator()(const _Tp& __t) const + { return log(__t); } + }; + + struct _Log10 + { + template + _Tp operator()(const _Tp& __t) const + { return log10(__t); } + }; + + struct _Sqrt + { + template + _Tp operator()(const _Tp& __t) const + { return sqrt(__t); } + }; + + // In the past, we used to tailor operator applications semantics + // to the specialization of standard function objects (i.e. plus<>, etc.) + // That is incorrect. Therefore we provide our own surrogates. + + struct __unary_plus + { + template + _Tp operator()(const _Tp& __t) const + { return +__t; } + }; + + struct __negate + { + template + _Tp operator()(const _Tp& __t) const + { return -__t; } + }; + + struct __bitwise_not + { + template + _Tp operator()(const _Tp& __t) const + { return ~__t; } + }; + + struct __plus + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x + __y; } + }; + + struct __minus + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x - __y; } + }; + + struct __multiplies + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x * __y; } + }; + + struct __divides + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x / __y; } + }; + + struct __modulus + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x % __y; } + }; + + struct __bitwise_xor + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x ^ __y; } + }; + + struct __bitwise_and + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x & __y; } + }; + + struct __bitwise_or + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x | __y; } + }; + + struct __shift_left + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x << __y; } + }; + + struct __shift_right + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return __x >> __y; } + }; + + struct __logical_and + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x && __y; } + }; + + struct __logical_or + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x || __y; } + }; + + struct __logical_not + { + template + bool operator()(const _Tp& __x) const + { return !__x; } + }; + + struct __equal_to + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x == __y; } + }; + + struct __not_equal_to + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x != __y; } + }; + + struct __less + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x < __y; } + }; + + struct __greater + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x > __y; } + }; + + struct __less_equal + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x <= __y; } + }; + + struct __greater_equal + { + template + bool operator()(const _Tp& __x, const _Tp& __y) const + { return __x >= __y; } + }; + + // The few binary functions we miss. + struct _Atan2 + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return atan2(__x, __y); } + }; + + struct _Pow + { + template + _Tp operator()(const _Tp& __x, const _Tp& __y) const + { return pow(__x, __y); } + }; + + template + struct __fun_with_valarray + { + typedef _Tp result_type; + }; + + template + struct __fun_with_valarray<_Tp, false> + { + // No result type defined for invalid value types. + }; + + // We need these bits in order to recover the return type of + // some functions/operators now that we're no longer using + // function templates. + template + struct __fun : __fun_with_valarray<_Tp> + { + }; + + // several specializations for relational operators. + template + struct __fun<__logical_not, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__logical_and, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__logical_or, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__less, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__greater, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__less_equal, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__greater_equal, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__equal_to, _Tp> + { + typedef bool result_type; + }; + + template + struct __fun<__not_equal_to, _Tp> + { + typedef bool result_type; + }; + +namespace __detail +{ + // Closure types already have reference semantics and are often short-lived, + // so store them by value to avoid (some cases of) dangling references to + // out-of-scope temporaries. + template + struct _ValArrayRef + { typedef const _Tp __type; }; + + // Use real references for std::valarray objects. + template + struct _ValArrayRef< valarray<_Tp> > + { typedef const valarray<_Tp>& __type; }; + + // + // Apply function taking a value/const reference closure + // + + template + class _FunBase + { + public: + typedef typename _Dom::value_type value_type; + + _FunBase(const _Dom& __e, value_type __f(_Arg)) + : _M_expr(__e), _M_func(__f) {} + + value_type operator[](size_t __i) const + { return _M_func (_M_expr[__i]); } + + size_t size() const { return _M_expr.size ();} + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + value_type (*_M_func)(_Arg); + }; + + template + struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type> + { + typedef _FunBase<_Dom, typename _Dom::value_type> _Base; + typedef typename _Base::value_type value_type; + typedef value_type _Tp; + + _ValFunClos(const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {} + }; + + template + struct _ValFunClos<_ValArray,_Tp> : _FunBase, _Tp> + { + typedef _FunBase, _Tp> _Base; + typedef _Tp value_type; + + _ValFunClos(const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {} + }; + + template + struct _RefFunClos<_Expr, _Dom> + : _FunBase<_Dom, const typename _Dom::value_type&> + { + typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base; + typedef typename _Base::value_type value_type; + typedef value_type _Tp; + + _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&)) + : _Base(__e, __f) {} + }; + + template + struct _RefFunClos<_ValArray, _Tp> + : _FunBase, const _Tp&> + { + typedef _FunBase, const _Tp&> _Base; + typedef _Tp value_type; + + _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&)) + : _Base(__v, __f) {} + }; + + // + // Unary expression closure. + // + + template + class _UnBase + { + public: + typedef typename _Arg::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _UnBase(const _Arg& __e) : _M_expr(__e) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr[__i]); } + + size_t size() const { return _M_expr.size(); } + + private: + typename _ValArrayRef<_Arg>::__type _M_expr; + }; + + template + struct _UnClos<_Oper, _Expr, _Dom> + : _UnBase<_Oper, _Dom> + { + typedef _Dom _Arg; + typedef _UnBase<_Oper, _Dom> _Base; + typedef typename _Base::value_type value_type; + + _UnClos(const _Arg& __e) : _Base(__e) {} + }; + + template + struct _UnClos<_Oper, _ValArray, _Tp> + : _UnBase<_Oper, valarray<_Tp> > + { + typedef valarray<_Tp> _Arg; + typedef _UnBase<_Oper, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _UnClos(const _Arg& __e) : _Base(__e) {} + }; + + + // + // Binary expression closure. + // + + template + class _BinBase + { + public: + typedef typename _FirstArg::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _BinBase(const _FirstArg& __e1, const _SecondArg& __e2) + : _M_expr1(__e1), _M_expr2(__e2) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr1[__i], _M_expr2[__i]); } + + size_t size() const { return _M_expr1.size(); } + + private: + typename _ValArrayRef<_FirstArg>::__type _M_expr1; + typename _ValArrayRef<_SecondArg>::__type _M_expr2; + }; + + + template + class _BinBase2 + { + public: + typedef typename _Clos::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _BinBase2(const _Clos& __e, const _Vt& __t) + : _M_expr1(__e), _M_expr2(__t) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr1[__i], _M_expr2); } + + size_t size() const { return _M_expr1.size(); } + + private: + typename _ValArrayRef<_Clos>::__type _M_expr1; + _Vt _M_expr2; + }; + + template + class _BinBase1 + { + public: + typedef typename _Clos::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; + + _BinBase1(const _Vt& __t, const _Clos& __e) + : _M_expr1(__t), _M_expr2(__e) {} + + value_type operator[](size_t __i) const + { return _Oper()(_M_expr1, _M_expr2[__i]); } + + size_t size() const { return _M_expr2.size(); } + + private: + _Vt _M_expr1; + typename _ValArrayRef<_Clos>::__type _M_expr2; + }; + + template + struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2> + : _BinBase<_Oper, _Dom1, _Dom2> + { + typedef _BinBase<_Oper, _Dom1, _Dom2> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _ValArray, _ValArray, _Tp, _Tp> + : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > + { + typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w) + : _Base(__v, __w) {} + }; + + template + struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type> + : _BinBase<_Oper, _Dom, valarray > + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2) + : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom> + : _BinBase<_Oper, valarray,_Dom> + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2) + : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type> + : _BinBase2<_Oper, _Dom> + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase2<_Oper,_Dom> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Dom& __e1, const _Tp& __e2) : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom> + : _BinBase1<_Oper, _Dom> + { + typedef typename _Dom::value_type _Tp; + typedef _BinBase1<_Oper, _Dom> _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {} + }; + + template + struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp> + : _BinBase2<_Oper, valarray<_Tp> > + { + typedef _BinBase2<_Oper,valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const valarray<_Tp>& __v, const _Tp& __t) : _Base(__v, __t) {} + }; + + template + struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp> + : _BinBase1<_Oper, valarray<_Tp> > + { + typedef _BinBase1<_Oper, valarray<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {} + }; + + // + // slice_array closure. + // + template + class _SBase + { + public: + typedef typename _Dom::value_type value_type; + + _SBase (const _Dom& __e, const slice& __s) + : _M_expr (__e), _M_slice (__s) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } + + size_t + size() const + { return _M_slice.size (); } + + private: + typename _ValArrayRef<_Dom>::__type _M_expr; + const slice& _M_slice; + }; + + template + class _SBase<_Array<_Tp> > + { + public: + typedef _Tp value_type; + + _SBase (_Array<_Tp> __a, const slice& __s) + : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), + _M_stride (__s.stride()) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[__i * _M_stride]; } + + size_t + size() const + { return _M_size; } + + private: + const _Array<_Tp> _M_array; + const size_t _M_size; + const size_t _M_stride; + }; + + template + struct _SClos<_Expr, _Dom> + : _SBase<_Dom> + { + typedef _SBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} + }; + + template + struct _SClos<_ValArray, _Tp> + : _SBase<_Array<_Tp> > + { + typedef _SBase<_Array<_Tp> > _Base; + typedef _Tp value_type; + + _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} + }; +} // namespace __detail + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif /* _CPP_VALARRAY_BEFORE_H */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/vector.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/vector.tcc new file mode 100755 index 0000000..8a6a99f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bits/vector.tcc @@ -0,0 +1,1008 @@ +// Vector implementation (out of line) -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1996 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file bits/vector.tcc + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{vector} + */ + +#ifndef _VECTOR_TCC +#define _VECTOR_TCC 1 + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + template + void + vector<_Tp, _Alloc>:: + reserve(size_type __n) + { + if (__n > this->max_size()) + __throw_length_error(__N("vector::reserve")); + if (this->capacity() < __n) + { + const size_type __old_size = size(); + pointer __tmp; +#if __cplusplus >= 201103L + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) + { + __tmp = this->_M_allocate(__n); + _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish, + __tmp, _M_get_Tp_allocator()); + } + else +#endif + { + __tmp = _M_allocate_and_copy(__n, + _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_start), + _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(this->_M_impl._M_finish)); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_finish = __tmp + __old_size; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + } + } + +#if __cplusplus >= 201103L + template + template +#if __cplusplus > 201402L + typename vector<_Tp, _Alloc>::reference +#else + void +#endif + vector<_Tp, _Alloc>:: + emplace_back(_Args&&... __args) + { + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + std::forward<_Args>(__args)...); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + _M_realloc_insert(end(), std::forward<_Args>(__args)...); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + + template + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + const size_type __n = __position - begin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + if (__position == end()) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + __x); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + { +#if __cplusplus >= 201103L + const auto __pos = begin() + (__position - cbegin()); + // __x could be an existing element of this vector, so make a + // copy of it before _M_insert_aux moves elements around. + _Temporary_value __x_copy(this, __x); + _M_insert_aux(__pos, std::move(__x_copy._M_val())); +#else + _M_insert_aux(__position, __x); +#endif + } + else +#if __cplusplus >= 201103L + _M_realloc_insert(begin() + (__position - cbegin()), __x); +#else + _M_realloc_insert(__position, __x); +#endif + + return iterator(this->_M_impl._M_start + __n); + } + + template + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: + _M_erase(iterator __position) + { + if (__position + 1 != end()) + _GLIBCXX_MOVE3(__position + 1, end(), __position); + --this->_M_impl._M_finish; + _Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish); + _GLIBCXX_ASAN_ANNOTATE_SHRINK(1); + return __position; + } + + template + typename vector<_Tp, _Alloc>::iterator + vector<_Tp, _Alloc>:: + _M_erase(iterator __first, iterator __last) + { + if (__first != __last) + { + if (__last != end()) + _GLIBCXX_MOVE3(__last, end(), __first); + _M_erase_at_end(__first.base() + (end() - __last)); + } + return __first; + } + + template + vector<_Tp, _Alloc>& + vector<_Tp, _Alloc>:: + operator=(const vector<_Tp, _Alloc>& __x) + { + if (&__x != this) + { + _GLIBCXX_ASAN_ANNOTATE_REINIT; +#if __cplusplus >= 201103L + if (_Alloc_traits::_S_propagate_on_copy_assign()) + { + if (!_Alloc_traits::_S_always_equal() + && _M_get_Tp_allocator() != __x._M_get_Tp_allocator()) + { + // replacement allocator cannot free existing storage + this->clear(); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = nullptr; + this->_M_impl._M_finish = nullptr; + this->_M_impl._M_end_of_storage = nullptr; + } + std::__alloc_on_copy(_M_get_Tp_allocator(), + __x._M_get_Tp_allocator()); + } +#endif + const size_type __xlen = __x.size(); + if (__xlen > capacity()) + { + pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), + __x.end()); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen; + } + else if (size() >= __xlen) + { + std::_Destroy(std::copy(__x.begin(), __x.end(), begin()), + end(), _M_get_Tp_allocator()); + } + else + { + std::copy(__x._M_impl._M_start, __x._M_impl._M_start + size(), + this->_M_impl._M_start); + std::__uninitialized_copy_a(__x._M_impl._M_start + size(), + __x._M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + this->_M_impl._M_finish = this->_M_impl._M_start + __xlen; + } + return *this; + } + + template + void + vector<_Tp, _Alloc>:: + _M_fill_assign(size_t __n, const value_type& __val) + { + if (__n > capacity()) + { + vector __tmp(__n, __val, _M_get_Tp_allocator()); + __tmp._M_impl._M_swap_data(this->_M_impl); + } + else if (__n > size()) + { + std::fill(begin(), end(), __val); + const size_type __add = __n - size(); + _GLIBCXX_ASAN_ANNOTATE_GROW(__add); + this->_M_impl._M_finish = + std::__uninitialized_fill_n_a(this->_M_impl._M_finish, + __add, __val, _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__add); + } + else + _M_erase_at_end(std::fill_n(this->_M_impl._M_start, __n, __val)); + } + + template + template + void + vector<_Tp, _Alloc>:: + _M_assign_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + pointer __cur(this->_M_impl._M_start); + for (; __first != __last && __cur != this->_M_impl._M_finish; + ++__cur, (void)++__first) + *__cur = *__first; + if (__first == __last) + _M_erase_at_end(__cur); + else + _M_range_insert(end(), __first, __last, + std::__iterator_category(__first)); + } + + template + template + void + vector<_Tp, _Alloc>:: + _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + const size_type __len = std::distance(__first, __last); + + if (__len > capacity()) + { + _S_check_init_len(__len, _M_get_Tp_allocator()); + pointer __tmp(_M_allocate_and_copy(__len, __first, __last)); + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __tmp; + this->_M_impl._M_finish = this->_M_impl._M_start + __len; + this->_M_impl._M_end_of_storage = this->_M_impl._M_finish; + } + else if (size() >= __len) + _M_erase_at_end(std::copy(__first, __last, this->_M_impl._M_start)); + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, size()); + std::copy(__first, __mid, this->_M_impl._M_start); + const size_type __attribute__((__unused__)) __n = __len - size(); + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + this->_M_impl._M_finish = + std::__uninitialized_copy_a(__mid, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + } + } + +#if __cplusplus >= 201103L + template + auto + vector<_Tp, _Alloc>:: + _M_insert_rval(const_iterator __position, value_type&& __v) -> iterator + { + const auto __n = __position - cbegin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + if (__position == cend()) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + std::move(__v)); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + _M_insert_aux(begin() + __n, std::move(__v)); + else + _M_realloc_insert(begin() + __n, std::move(__v)); + + return iterator(this->_M_impl._M_start + __n); + } + + template + template + auto + vector<_Tp, _Alloc>:: + _M_emplace_aux(const_iterator __position, _Args&&... __args) + -> iterator + { + const auto __n = __position - cbegin(); + if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) + if (__position == cend()) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + std::forward<_Args>(__args)...); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); + } + else + { + // We need to construct a temporary because something in __args... + // could alias one of the elements of the container and so we + // need to use it before _M_insert_aux moves elements around. + _Temporary_value __tmp(this, std::forward<_Args>(__args)...); + _M_insert_aux(begin() + __n, std::move(__tmp._M_val())); + } + else + _M_realloc_insert(begin() + __n, std::forward<_Args>(__args)...); + + return iterator(this->_M_impl._M_start + __n); + } + + template + template + void + vector<_Tp, _Alloc>:: + _M_insert_aux(iterator __position, _Arg&& __arg) +#else + template + void + vector<_Tp, _Alloc>:: + _M_insert_aux(iterator __position, const _Tp& __x) +#endif + { + _GLIBCXX_ASAN_ANNOTATE_GROW(1); + _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, + _GLIBCXX_MOVE(*(this->_M_impl._M_finish - 1))); + ++this->_M_impl._M_finish; + _GLIBCXX_ASAN_ANNOTATE_GREW(1); +#if __cplusplus < 201103L + _Tp __x_copy = __x; +#endif + _GLIBCXX_MOVE_BACKWARD3(__position.base(), + this->_M_impl._M_finish - 2, + this->_M_impl._M_finish - 1); +#if __cplusplus < 201103L + *__position = __x_copy; +#else + *__position = std::forward<_Arg>(__arg); +#endif + } + +#if __cplusplus >= 201103L + template + template + void + vector<_Tp, _Alloc>:: + _M_realloc_insert(iterator __position, _Args&&... __args) +#else + template + void + vector<_Tp, _Alloc>:: + _M_realloc_insert(iterator __position, const _Tp& __x) +#endif + { + const size_type __len = + _M_check_len(size_type(1), "vector::_M_realloc_insert"); + pointer __old_start = this->_M_impl._M_start; + pointer __old_finish = this->_M_impl._M_finish; + const size_type __elems_before = __position - begin(); + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + __try + { + // The order of the three operations is dictated by the C++11 + // case, where the moves could alter a new element belonging + // to the existing vector. This is an issue only for callers + // taking the element by lvalue ref (see last bullet of C++11 + // [res.on.arguments]). + _Alloc_traits::construct(this->_M_impl, + __new_start + __elems_before, +#if __cplusplus >= 201103L + std::forward<_Args>(__args)...); +#else + __x); +#endif + __new_finish = pointer(); + +#if __cplusplus >= 201103L + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) + { + __new_finish = _S_relocate(__old_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + + ++__new_finish; + + __new_finish = _S_relocate(__position.base(), __old_finish, + __new_finish, _M_get_Tp_allocator()); + } + else +#endif + { + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__old_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + + ++__new_finish; + + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__position.base(), __old_finish, + __new_finish, _M_get_Tp_allocator()); + } + } + __catch(...) + { + if (!__new_finish) + _Alloc_traits::destroy(this->_M_impl, + __new_start + __elems_before); + else + std::_Destroy(__new_start, __new_finish, _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } +#if __cplusplus >= 201103L + if _GLIBCXX17_CONSTEXPR (!_S_use_relocate()) +#endif + std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(__old_start, + this->_M_impl._M_end_of_storage - __old_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + + template + void + vector<_Tp, _Alloc>:: + _M_fill_insert(iterator __position, size_type __n, const value_type& __x) + { + if (__n != 0) + { + if (size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish) >= __n) + { +#if __cplusplus < 201103L + value_type __x_copy = __x; +#else + _Temporary_value __tmp(this, __x); + value_type& __x_copy = __tmp._M_val(); +#endif + const size_type __elems_after = end() - __position; + pointer __old_finish(this->_M_impl._M_finish); + if (__elems_after > __n) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + std::__uninitialized_move_a(this->_M_impl._M_finish - __n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n; + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + _GLIBCXX_MOVE_BACKWARD3(__position.base(), + __old_finish - __n, __old_finish); + std::fill(__position.base(), __position.base() + __n, + __x_copy); + } + else + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + this->_M_impl._M_finish = + std::__uninitialized_fill_n_a(this->_M_impl._M_finish, + __n - __elems_after, + __x_copy, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after); + std::__uninitialized_move_a(__position.base(), __old_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __elems_after; + _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after); + std::fill(__position.base(), __old_finish, __x_copy); + } + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_fill_insert"); + const size_type __elems_before = __position - begin(); + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + __try + { + // See _M_realloc_insert above. + std::__uninitialized_fill_n_a(__new_start + __elems_before, + __n, __x, + _M_get_Tp_allocator()); + __new_finish = pointer(); + + __new_finish + = std::__uninitialized_move_if_noexcept_a + (this->_M_impl._M_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + + __new_finish += __n; + + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__position.base(), this->_M_impl._M_finish, + __new_finish, _M_get_Tp_allocator()); + } + __catch(...) + { + if (!__new_finish) + std::_Destroy(__new_start + __elems_before, + __new_start + __elems_before + __n, + _M_get_Tp_allocator()); + else + std::_Destroy(__new_start, __new_finish, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } + } + +#if __cplusplus >= 201103L + template + void + vector<_Tp, _Alloc>:: + _M_default_append(size_type __n) + { + if (__n != 0) + { + const size_type __size = size(); + size_type __navail = size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish); + + if (__size > max_size() || __navail > max_size() - __size) + __builtin_unreachable(); + + if (__navail >= __n) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + this->_M_impl._M_finish = + std::__uninitialized_default_n_a(this->_M_impl._M_finish, + __n, _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_default_append"); + pointer __new_start(this->_M_allocate(__len)); + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) + { + __try + { + std::__uninitialized_default_n_a(__new_start + __size, + __n, _M_get_Tp_allocator()); + } + __catch(...) + { + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + _S_relocate(this->_M_impl._M_start, this->_M_impl._M_finish, + __new_start, _M_get_Tp_allocator()); + } + else + { + pointer __destroy_from = pointer(); + __try + { + std::__uninitialized_default_n_a(__new_start + __size, + __n, _M_get_Tp_allocator()); + __destroy_from = __new_start + __size; + std::__uninitialized_move_if_noexcept_a( + this->_M_impl._M_start, this->_M_impl._M_finish, + __new_start, _M_get_Tp_allocator()); + } + __catch(...) + { + if (__destroy_from) + std::_Destroy(__destroy_from, __destroy_from + __n, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + } + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_start + __size + __n; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } + } + + template + bool + vector<_Tp, _Alloc>:: + _M_shrink_to_fit() + { + if (capacity() == size()) + return false; + _GLIBCXX_ASAN_ANNOTATE_REINIT; + return std::__shrink_to_fit_aux::_S_do_it(*this); + } +#endif + + template + template + void + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + if (__pos == end()) + { + for (; __first != __last; ++__first) + insert(end(), *__first); + } + else if (__first != __last) + { + vector __tmp(__first, __last, _M_get_Tp_allocator()); + insert(__pos, + _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.begin()), + _GLIBCXX_MAKE_MOVE_ITERATOR(__tmp.end())); + } + } + + template + template + void + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) + { + if (__first != __last) + { + const size_type __n = std::distance(__first, __last); + if (size_type(this->_M_impl._M_end_of_storage + - this->_M_impl._M_finish) >= __n) + { + const size_type __elems_after = end() - __position; + pointer __old_finish(this->_M_impl._M_finish); + if (__elems_after > __n) + { + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + std::__uninitialized_move_a(this->_M_impl._M_finish - __n, + this->_M_impl._M_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n; + _GLIBCXX_ASAN_ANNOTATE_GREW(__n); + _GLIBCXX_MOVE_BACKWARD3(__position.base(), + __old_finish - __n, __old_finish); + std::copy(__first, __last, __position); + } + else + { + _ForwardIterator __mid = __first; + std::advance(__mid, __elems_after); + _GLIBCXX_ASAN_ANNOTATE_GROW(__n); + std::__uninitialized_copy_a(__mid, __last, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __n - __elems_after; + _GLIBCXX_ASAN_ANNOTATE_GREW(__n - __elems_after); + std::__uninitialized_move_a(__position.base(), + __old_finish, + this->_M_impl._M_finish, + _M_get_Tp_allocator()); + this->_M_impl._M_finish += __elems_after; + _GLIBCXX_ASAN_ANNOTATE_GREW(__elems_after); + std::copy(__first, __mid, __position); + } + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_range_insert"); + pointer __new_start(this->_M_allocate(__len)); + pointer __new_finish(__new_start); + __try + { + __new_finish + = std::__uninitialized_move_if_noexcept_a + (this->_M_impl._M_start, __position.base(), + __new_start, _M_get_Tp_allocator()); + __new_finish + = std::__uninitialized_copy_a(__first, __last, + __new_finish, + _M_get_Tp_allocator()); + __new_finish + = std::__uninitialized_move_if_noexcept_a + (__position.base(), this->_M_impl._M_finish, + __new_finish, _M_get_Tp_allocator()); + } + __catch(...) + { + std::_Destroy(__new_start, __new_finish, + _M_get_Tp_allocator()); + _M_deallocate(__new_start, __len); + __throw_exception_again; + } + std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish, + _M_get_Tp_allocator()); + _GLIBCXX_ASAN_ANNOTATE_REINIT; + _M_deallocate(this->_M_impl._M_start, + this->_M_impl._M_end_of_storage + - this->_M_impl._M_start); + this->_M_impl._M_start = __new_start; + this->_M_impl._M_finish = __new_finish; + this->_M_impl._M_end_of_storage = __new_start + __len; + } + } + } + + + // vector + template + void + vector:: + _M_reallocate(size_type __n) + { + _Bit_pointer __q = this->_M_allocate(__n); + iterator __start(std::__addressof(*__q), 0); + iterator __finish(_M_copy_aligned(begin(), end(), __start)); + this->_M_deallocate(); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + this->_M_impl._M_end_of_storage = __q + _S_nword(__n); + } + + template + void + vector:: + _M_fill_insert(iterator __position, size_type __n, bool __x) + { + if (__n == 0) + return; + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + difference_type(__n)); + std::fill(__position, __position + difference_type(__n), __x); + this->_M_impl._M_finish += difference_type(__n); + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_fill_insert"); + _Bit_pointer __q = this->_M_allocate(__len); + iterator __start(std::__addressof(*__q), 0); + iterator __i = _M_copy_aligned(begin(), __position, __start); + std::fill(__i, __i + difference_type(__n), __x); + iterator __finish = std::copy(__position, end(), + __i + difference_type(__n)); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = __q + _S_nword(__len); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + } + } + + template + template + void + vector:: + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) + { + if (__first != __last) + { + size_type __n = std::distance(__first, __last); + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + + difference_type(__n)); + std::copy(__first, __last, __position); + this->_M_impl._M_finish += difference_type(__n); + } + else + { + const size_type __len = + _M_check_len(__n, "vector::_M_insert_range"); + _Bit_pointer __q = this->_M_allocate(__len); + iterator __start(std::__addressof(*__q), 0); + iterator __i = _M_copy_aligned(begin(), __position, __start); + __i = std::copy(__first, __last, __i); + iterator __finish = std::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = __q + _S_nword(__len); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + } + } + } + + template + void + vector:: + _M_insert_aux(iterator __position, bool __x) + { + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_addr()) + { + std::copy_backward(__position, this->_M_impl._M_finish, + this->_M_impl._M_finish + 1); + *__position = __x; + ++this->_M_impl._M_finish; + } + else + { + const size_type __len = + _M_check_len(size_type(1), "vector::_M_insert_aux"); + _Bit_pointer __q = this->_M_allocate(__len); + iterator __start(std::__addressof(*__q), 0); + iterator __i = _M_copy_aligned(begin(), __position, __start); + *__i++ = __x; + iterator __finish = std::copy(__position, end(), __i); + this->_M_deallocate(); + this->_M_impl._M_end_of_storage = __q + _S_nword(__len); + this->_M_impl._M_start = __start; + this->_M_impl._M_finish = __finish; + } + } + + template + typename vector::iterator + vector:: + _M_erase(iterator __position) + { + if (__position + 1 != end()) + std::copy(__position + 1, end(), __position); + --this->_M_impl._M_finish; + return __position; + } + + template + typename vector::iterator + vector:: + _M_erase(iterator __first, iterator __last) + { + if (__first != __last) + _M_erase_at_end(std::copy(__last, end(), __first)); + return __first; + } + +#if __cplusplus >= 201103L + template + bool + vector:: + _M_shrink_to_fit() + { + if (capacity() - size() < int(_S_word_bit)) + return false; + __try + { + _M_reallocate(size()); + return true; + } + __catch(...) + { return false; } + } +#endif + +_GLIBCXX_END_NAMESPACE_CONTAINER +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + size_t + hash<_GLIBCXX_STD_C::vector>:: + operator()(const _GLIBCXX_STD_C::vector& __b) const noexcept + { + size_t __hash = 0; + using _GLIBCXX_STD_C::_S_word_bit; + using _GLIBCXX_STD_C::_Bit_type; + + const size_t __words = __b.size() / _S_word_bit; + if (__words) + { + const size_t __clength = __words * sizeof(_Bit_type); + __hash = std::_Hash_impl::hash(__b._M_impl._M_start._M_p, __clength); + } + + const size_t __extrabits = __b.size() % _S_word_bit; + if (__extrabits) + { + _Bit_type __hiword = *__b._M_impl._M_finish._M_p; + __hiword &= ~((~static_cast<_Bit_type>(0)) << __extrabits); + + const size_t __clength + = (__extrabits + __CHAR_BIT__ - 1) / __CHAR_BIT__; + if (__words) + __hash = std::_Hash_impl::hash(&__hiword, __clength, __hash); + else + __hash = std::_Hash_impl::hash(&__hiword, __clength); + } + + return __hash; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#undef _GLIBCXX_ASAN_ANNOTATE_REINIT +#undef _GLIBCXX_ASAN_ANNOTATE_GROW +#undef _GLIBCXX_ASAN_ANNOTATE_GREW +#undef _GLIBCXX_ASAN_ANNOTATE_SHRINK + +#endif /* _VECTOR_TCC */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bitset b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bitset new file mode 100755 index 0000000..be3bdd7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/bitset @@ -0,0 +1,1598 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * Copyright (c) 1998 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/bitset + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_BITSET +#define _GLIBCXX_BITSET 1 + +#pragma GCC system_header + +#include +#include // For invalid_argument, out_of_range, + // overflow_error +#include +#include + +#if __cplusplus >= 201103L +# include +#endif + +#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__) +#define _GLIBCXX_BITSET_WORDS(__n) \ + ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \ + ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1)) + +#define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_CONTAINER + + /** + * Base class, general case. It is a class invariant that _Nw will be + * nonnegative. + * + * See documentation for bitset. + */ + template + struct _Base_bitset + { + typedef unsigned long _WordT; + + /// 0 is the least significant word. + _WordT _M_w[_Nw]; + + _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT + : _M_w() { } + +#if __cplusplus >= 201103L + constexpr _Base_bitset(unsigned long long __val) noexcept + : _M_w{ _WordT(__val) +#if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__ + , _WordT(__val >> _GLIBCXX_BITSET_BITS_PER_WORD) +#endif + } { } +#else + _Base_bitset(unsigned long __val) + : _M_w() + { _M_w[0] = __val; } +#endif + + static _GLIBCXX_CONSTEXPR size_t + _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR _WordT + _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + _WordT& + _M_getword(size_t __pos) _GLIBCXX_NOEXCEPT + { return _M_w[_S_whichword(__pos)]; } + + _GLIBCXX_CONSTEXPR _WordT + _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT + { return _M_w[_S_whichword(__pos)]; } + +#if __cplusplus >= 201103L + const _WordT* + _M_getdata() const noexcept + { return _M_w; } +#endif + + _WordT& + _M_hiword() _GLIBCXX_NOEXCEPT + { return _M_w[_Nw - 1]; } + + _GLIBCXX_CONSTEXPR _WordT + _M_hiword() const _GLIBCXX_NOEXCEPT + { return _M_w[_Nw - 1]; } + + void + _M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] &= __x._M_w[__i]; + } + + void + _M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] |= __x._M_w[__i]; + } + + void + _M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] ^= __x._M_w[__i]; + } + + void + _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT; + + void + _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT; + + void + _M_do_flip() _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] = ~_M_w[__i]; + } + + void + _M_do_set() _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + _M_w[__i] = ~static_cast<_WordT>(0); + } + + void + _M_do_reset() _GLIBCXX_NOEXCEPT + { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); } + + bool + _M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; ++__i) + if (_M_w[__i] != __x._M_w[__i]) + return false; + return true; + } + + template + bool + _M_are_all() const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw - 1; __i++) + if (_M_w[__i] != ~static_cast<_WordT>(0)) + return false; + return _M_hiword() == (~static_cast<_WordT>(0) + >> (_Nw * _GLIBCXX_BITSET_BITS_PER_WORD + - _Nb)); + } + + bool + _M_is_any() const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + if (_M_w[__i] != static_cast<_WordT>(0)) + return true; + return false; + } + + size_t + _M_do_count() const _GLIBCXX_NOEXCEPT + { + size_t __result = 0; + for (size_t __i = 0; __i < _Nw; __i++) + __result += __builtin_popcountl(_M_w[__i]); + return __result; + } + + unsigned long + _M_do_to_ulong() const; + +#if __cplusplus >= 201103L + unsigned long long + _M_do_to_ullong() const; +#endif + + // find first "on" bit + size_t + _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT; + + // find the next "on" bit that follows "prev" + size_t + _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT; + }; + + // Definitions of non-inline functions from _Base_bitset. + template + void + _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__shift != 0, 1)) + { + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; + + if (__offset == 0) + for (size_t __n = _Nw - 1; __n >= __wshift; --__n) + _M_w[__n] = _M_w[__n - __wshift]; + else + { + const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD + - __offset); + for (size_t __n = _Nw - 1; __n > __wshift; --__n) + _M_w[__n] = ((_M_w[__n - __wshift] << __offset) + | (_M_w[__n - __wshift - 1] >> __sub_offset)); + _M_w[__wshift] = _M_w[0] << __offset; + } + + std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0)); + } + } + + template + void + _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__shift != 0, 1)) + { + const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD; + const size_t __limit = _Nw - __wshift - 1; + + if (__offset == 0) + for (size_t __n = 0; __n <= __limit; ++__n) + _M_w[__n] = _M_w[__n + __wshift]; + else + { + const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD + - __offset); + for (size_t __n = 0; __n < __limit; ++__n) + _M_w[__n] = ((_M_w[__n + __wshift] >> __offset) + | (_M_w[__n + __wshift + 1] << __sub_offset)); + _M_w[__limit] = _M_w[_Nw-1] >> __offset; + } + + std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0)); + } + } + + template + unsigned long + _Base_bitset<_Nw>::_M_do_to_ulong() const + { + for (size_t __i = 1; __i < _Nw; ++__i) + if (_M_w[__i]) + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong")); + return _M_w[0]; + } + +#if __cplusplus >= 201103L + template + unsigned long long + _Base_bitset<_Nw>::_M_do_to_ullong() const + { + const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long); + for (size_t __i = 1 + __dw; __i < _Nw; ++__i) + if (_M_w[__i]) + __throw_overflow_error(__N("_Base_bitset::_M_do_to_ullong")); + + if (__dw) + return _M_w[0] + (static_cast(_M_w[1]) + << _GLIBCXX_BITSET_BITS_PER_WORD); + return _M_w[0]; + } +#endif + + template + size_t + _Base_bitset<_Nw>:: + _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT + { + for (size_t __i = 0; __i < _Nw; __i++) + { + _WordT __thisword = _M_w[__i]; + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + } + // not found, so return an indication of failure. + return __not_found; + } + + template + size_t + _Base_bitset<_Nw>:: + _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT + { + // make bound inclusive + ++__prev; + + // check out of bounds + if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD) + return __not_found; + + // search first word + size_t __i = _S_whichword(__prev); + _WordT __thisword = _M_w[__i]; + + // mask off bits below bound + __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev); + + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + + // check subsequent words + __i++; + for (; __i < _Nw; __i++) + { + __thisword = _M_w[__i]; + if (__thisword != static_cast<_WordT>(0)) + return (__i * _GLIBCXX_BITSET_BITS_PER_WORD + + __builtin_ctzl(__thisword)); + } + // not found, so return an indication of failure. + return __not_found; + } // end _M_do_find_next + + /** + * Base class, specialization for a single word. + * + * See documentation for bitset. + */ + template<> + struct _Base_bitset<1> + { + typedef unsigned long _WordT; + _WordT _M_w; + + _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT + : _M_w(0) + { } + +#if __cplusplus >= 201103L + constexpr _Base_bitset(unsigned long long __val) noexcept +#else + _Base_bitset(unsigned long __val) +#endif + : _M_w(__val) + { } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR _WordT + _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + _WordT& + _M_getword(size_t) _GLIBCXX_NOEXCEPT + { return _M_w; } + + _GLIBCXX_CONSTEXPR _WordT + _M_getword(size_t) const _GLIBCXX_NOEXCEPT + { return _M_w; } + +#if __cplusplus >= 201103L + const _WordT* + _M_getdata() const noexcept + { return &_M_w; } +#endif + + _WordT& + _M_hiword() _GLIBCXX_NOEXCEPT + { return _M_w; } + + _GLIBCXX_CONSTEXPR _WordT + _M_hiword() const _GLIBCXX_NOEXCEPT + { return _M_w; } + + void + _M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT + { _M_w &= __x._M_w; } + + void + _M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT + { _M_w |= __x._M_w; } + + void + _M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT + { _M_w ^= __x._M_w; } + + void + _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { _M_w <<= __shift; } + + void + _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT + { _M_w >>= __shift; } + + void + _M_do_flip() _GLIBCXX_NOEXCEPT + { _M_w = ~_M_w; } + + void + _M_do_set() _GLIBCXX_NOEXCEPT + { _M_w = ~static_cast<_WordT>(0); } + + void + _M_do_reset() _GLIBCXX_NOEXCEPT + { _M_w = 0; } + + bool + _M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT + { return _M_w == __x._M_w; } + + template + bool + _M_are_all() const _GLIBCXX_NOEXCEPT + { return _M_w == (~static_cast<_WordT>(0) + >> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); } + + bool + _M_is_any() const _GLIBCXX_NOEXCEPT + { return _M_w != 0; } + + size_t + _M_do_count() const _GLIBCXX_NOEXCEPT + { return __builtin_popcountl(_M_w); } + + unsigned long + _M_do_to_ulong() const _GLIBCXX_NOEXCEPT + { return _M_w; } + +#if __cplusplus >= 201103L + unsigned long long + _M_do_to_ullong() const noexcept + { return _M_w; } +#endif + + size_t + _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT + { + if (_M_w != 0) + return __builtin_ctzl(_M_w); + else + return __not_found; + } + + // find the next "on" bit that follows "prev" + size_t + _M_do_find_next(size_t __prev, size_t __not_found) const + _GLIBCXX_NOEXCEPT + { + ++__prev; + if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD)) + return __not_found; + + _WordT __x = _M_w >> __prev; + if (__x != 0) + return __builtin_ctzl(__x) + __prev; + else + return __not_found; + } + }; + + /** + * Base class, specialization for no storage (zero-length %bitset). + * + * See documentation for bitset. + */ + template<> + struct _Base_bitset<0> + { + typedef unsigned long _WordT; + + _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT + { } + +#if __cplusplus >= 201103L + constexpr _Base_bitset(unsigned long long) noexcept +#else + _Base_bitset(unsigned long) +#endif + { } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT + { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; } + + static _GLIBCXX_CONSTEXPR size_t + _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; } + + static _GLIBCXX_CONSTEXPR _WordT + _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT + { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } + + // This would normally give access to the data. The bounds-checking + // in the bitset class will prevent the user from getting this far, + // but (1) it must still return an lvalue to compile, and (2) the + // user might call _Unchecked_set directly, in which case this /needs/ + // to fail. Let's not penalize zero-length users unless they actually + // make an unchecked call; all the memory ugliness is therefore + // localized to this single should-never-get-this-far function. + _WordT& + _M_getword(size_t) _GLIBCXX_NOEXCEPT + { + __throw_out_of_range(__N("_Base_bitset::_M_getword")); + return *new _WordT; + } + + _GLIBCXX_CONSTEXPR _WordT + _M_getword(size_t) const _GLIBCXX_NOEXCEPT + { return 0; } + + _GLIBCXX_CONSTEXPR _WordT + _M_hiword() const _GLIBCXX_NOEXCEPT + { return 0; } + + void + _M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT + { } + + void + _M_do_flip() _GLIBCXX_NOEXCEPT + { } + + void + _M_do_set() _GLIBCXX_NOEXCEPT + { } + + void + _M_do_reset() _GLIBCXX_NOEXCEPT + { } + + // Are all empty bitsets equal to each other? Are they equal to + // themselves? How to compare a thing which has no state? What is + // the sound of one zero-length bitset clapping? + bool + _M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT + { return true; } + + template + bool + _M_are_all() const _GLIBCXX_NOEXCEPT + { return true; } + + bool + _M_is_any() const _GLIBCXX_NOEXCEPT + { return false; } + + size_t + _M_do_count() const _GLIBCXX_NOEXCEPT + { return 0; } + + unsigned long + _M_do_to_ulong() const _GLIBCXX_NOEXCEPT + { return 0; } + +#if __cplusplus >= 201103L + unsigned long long + _M_do_to_ullong() const noexcept + { return 0; } +#endif + + // Normally "not found" is the size, but that could also be + // misinterpreted as an index in this corner case. Oh well. + size_t + _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT + { return 0; } + + size_t + _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT + { return 0; } + }; + + + // Helper class to zero out the unused high-order bits in the highest word. + template + struct _Sanitize + { + typedef unsigned long _WordT; + + static void + _S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT + { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); } + }; + + template<> + struct _Sanitize<0> + { + typedef unsigned long _WordT; + + static void + _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { } + }; + +#if __cplusplus >= 201103L + template + struct _Sanitize_val + { + static constexpr unsigned long long + _S_do_sanitize_val(unsigned long long __val) + { return __val; } + }; + + template + struct _Sanitize_val<_Nb, true> + { + static constexpr unsigned long long + _S_do_sanitize_val(unsigned long long __val) + { return __val & ~((~static_cast(0)) << _Nb); } + }; +#endif + + /** + * @brief The %bitset class represents a @e fixed-size sequence of bits. + * @ingroup utilities + * + * (Note that %bitset does @e not meet the formal requirements of a + * container. Mainly, it lacks iterators.) + * + * The template argument, @a Nb, may be any non-negative number, + * specifying the number of bits (e.g., "0", "12", "1024*1024"). + * + * In the general unoptimized case, storage is allocated in word-sized + * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B + * words will be used for storage. B - Nb%B bits are unused. (They are + * the high-order bits in the highest word.) It is a class invariant + * that those unused bits are always zero. + * + * If you think of %bitset as a simple array of bits, be + * aware that your mental picture is reversed: a %bitset behaves + * the same way as bits in integers do, with the bit at index 0 in + * the least significant / right-hand position, and the bit at + * index Nb-1 in the most significant / left-hand position. + * Thus, unlike other containers, a %bitset's index counts from + * right to left, to put it very loosely. + * + * This behavior is preserved when translating to and from strings. For + * example, the first line of the following program probably prints + * b('a') is 0001100001 on a modern ASCII system. + * + * @code + * #include + * #include + * #include + * + * using namespace std; + * + * int main() + * { + * long a = 'a'; + * bitset<10> b(a); + * + * cout << "b('a') is " << b << endl; + * + * ostringstream s; + * s << b; + * string str = s.str(); + * cout << "index 3 in the string is " << str[3] << " but\n" + * << "index 3 in the bitset is " << b[3] << endl; + * } + * @endcode + * + * Also see: + * https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_containers.html + * for a description of extensions. + * + * Most of the actual code isn't contained in %bitset<> itself, but in the + * base class _Base_bitset. The base class works with whole words, not with + * individual bits. This allows us to specialize _Base_bitset for the + * important special case where the %bitset is only a single word. + * + * Extra confusion can result due to the fact that the storage for + * _Base_bitset @e is a regular array, and is indexed as such. This is + * carefully encapsulated. + */ + template + class bitset + : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> + { + private: + typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base; + typedef unsigned long _WordT; + + template + void + _M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position) const + { + if (__position > __s.size()) + __throw_out_of_range_fmt(__N("bitset::bitset: __position " + "(which is %zu) > __s.size() " + "(which is %zu)"), + __position, __s.size()); + } + + void _M_check(size_t __position, const char *__s) const + { + if (__position >= _Nb) + __throw_out_of_range_fmt(__N("%s: __position (which is %zu) " + ">= _Nb (which is %zu)"), + __s, __position, _Nb); + } + + void + _M_do_sanitize() _GLIBCXX_NOEXCEPT + { + typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type; + __sanitize_type::_S_do_sanitize(this->_M_hiword()); + } + +#if __cplusplus >= 201103L + friend struct std::hash; +#endif + + public: + /** + * This encapsulates the concept of a single bit. An instance of this + * class is a proxy for an actual bit; this way the individual bit + * operations are done as faster word-size bitwise instructions. + * + * Most users will never need to use this class directly; conversions + * to and from bool are automatic and should be transparent. Overloaded + * operators help to preserve the illusion. + * + * (On a typical system, this bit %reference is 64 + * times the size of an actual bit. Ha.) + */ + class reference + { + friend class bitset; + + _WordT* _M_wp; + size_t _M_bpos; + + // left undefined + reference(); + + public: + reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT + { + _M_wp = &__b._M_getword(__pos); + _M_bpos = _Base::_S_whichbit(__pos); + } + +#if __cplusplus >= 201103L + reference(const reference&) = default; +#endif + + ~reference() _GLIBCXX_NOEXCEPT + { } + + // For b[i] = __x; + reference& + operator=(bool __x) _GLIBCXX_NOEXCEPT + { + if (__x) + *_M_wp |= _Base::_S_maskbit(_M_bpos); + else + *_M_wp &= ~_Base::_S_maskbit(_M_bpos); + return *this; + } + + // For b[i] = b[__j]; + reference& + operator=(const reference& __j) _GLIBCXX_NOEXCEPT + { + if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos))) + *_M_wp |= _Base::_S_maskbit(_M_bpos); + else + *_M_wp &= ~_Base::_S_maskbit(_M_bpos); + return *this; + } + + // Flips the bit + bool + operator~() const _GLIBCXX_NOEXCEPT + { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } + + // For __x = b[i]; + operator bool() const _GLIBCXX_NOEXCEPT + { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } + + // For b[i].flip(); + reference& + flip() _GLIBCXX_NOEXCEPT + { + *_M_wp ^= _Base::_S_maskbit(_M_bpos); + return *this; + } + }; + friend class reference; + + // 23.3.5.1 constructors: + /// All bits set to zero. + _GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT + { } + + /// Initial bits bitwise-copied from a single word (others set to zero). +#if __cplusplus >= 201103L + constexpr bitset(unsigned long long __val) noexcept + : _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { } +#else + bitset(unsigned long __val) + : _Base(__val) + { _M_do_sanitize(); } +#endif + + /** + * Use a subset of a string. + * @param __s A string of @a 0 and @a 1 characters. + * @param __position Index of the first character in @a __s to use; + * defaults to zero. + * @throw std::out_of_range If @a pos is bigger the size of @a __s. + * @throw std::invalid_argument If a character appears in the string + * which is neither @a 0 nor @a 1. + */ + template + explicit + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position = 0) + : _Base() + { + _M_check_initial_position(__s, __position); + _M_copy_from_string(__s, __position, + std::basic_string<_CharT, _Traits, _Alloc>::npos, + _CharT('0'), _CharT('1')); + } + + /** + * Use a subset of a string. + * @param __s A string of @a 0 and @a 1 characters. + * @param __position Index of the first character in @a __s to use. + * @param __n The number of characters to copy. + * @throw std::out_of_range If @a __position is bigger the size + * of @a __s. + * @throw std::invalid_argument If a character appears in the string + * which is neither @a 0 nor @a 1. + */ + template + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position, size_t __n) + : _Base() + { + _M_check_initial_position(__s, __position); + _M_copy_from_string(__s, __position, __n, _CharT('0'), _CharT('1')); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, + size_t __position, size_t __n, + _CharT __zero, _CharT __one = _CharT('1')) + : _Base() + { + _M_check_initial_position(__s, __position); + _M_copy_from_string(__s, __position, __n, __zero, __one); + } + +#if __cplusplus >= 201103L + /** + * Construct from a character %array. + * @param __str An %array of characters @a zero and @a one. + * @param __n The number of characters to use. + * @param __zero The character corresponding to the value 0. + * @param __one The character corresponding to the value 1. + * @throw std::invalid_argument If a character appears in the string + * which is neither @a __zero nor @a __one. + */ + template + explicit + bitset(const _CharT* __str, + typename std::basic_string<_CharT>::size_type __n + = std::basic_string<_CharT>::npos, + _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) + : _Base() + { + if (!__str) + __throw_logic_error(__N("bitset::bitset(const _CharT*, ...)")); + + if (__n == std::basic_string<_CharT>::npos) + __n = std::char_traits<_CharT>::length(__str); + _M_copy_from_ptr<_CharT, std::char_traits<_CharT>>(__str, __n, 0, + __n, __zero, + __one); + } +#endif + + // 23.3.5.2 bitset operations: + ///@{ + /** + * Operations on bitsets. + * @param __rhs A same-sized bitset. + * + * These should be self-explanatory. + */ + bitset<_Nb>& + operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + this->_M_do_and(__rhs); + return *this; + } + + bitset<_Nb>& + operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + this->_M_do_or(__rhs); + return *this; + } + + bitset<_Nb>& + operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + this->_M_do_xor(__rhs); + return *this; + } + ///@} + + ///@{ + /** + * Operations on bitsets. + * @param __position The number of places to shift. + * + * These should be self-explanatory. + */ + bitset<_Nb>& + operator<<=(size_t __position) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__position < _Nb, 1)) + { + this->_M_do_left_shift(__position); + this->_M_do_sanitize(); + } + else + this->_M_do_reset(); + return *this; + } + + bitset<_Nb>& + operator>>=(size_t __position) _GLIBCXX_NOEXCEPT + { + if (__builtin_expect(__position < _Nb, 1)) + { + this->_M_do_right_shift(__position); + this->_M_do_sanitize(); + } + else + this->_M_do_reset(); + return *this; + } + ///@} + + ///@{ + /** + * These versions of single-bit set, reset, flip, and test are + * extensions from the SGI version. They do no range checking. + * @ingroup SGIextensions + */ + bitset<_Nb>& + _Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT + { + this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT + { + if (__val) + this->_M_getword(__pos) |= _Base::_S_maskbit(__pos); + else + this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT + { + this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos); + return *this; + } + + bitset<_Nb>& + _Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT + { + this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos); + return *this; + } + + _GLIBCXX_CONSTEXPR bool + _Unchecked_test(size_t __pos) const _GLIBCXX_NOEXCEPT + { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos)) + != static_cast<_WordT>(0)); } + ///@} + + // Set, reset, and flip. + /** + * @brief Sets every bit to true. + */ + bitset<_Nb>& + set() _GLIBCXX_NOEXCEPT + { + this->_M_do_set(); + this->_M_do_sanitize(); + return *this; + } + + /** + * @brief Sets a given bit to a particular value. + * @param __position The index of the bit. + * @param __val Either true or false, defaults to true. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + */ + bitset<_Nb>& + set(size_t __position, bool __val = true) + { + this->_M_check(__position, __N("bitset::set")); + return _Unchecked_set(__position, __val); + } + + /** + * @brief Sets every bit to false. + */ + bitset<_Nb>& + reset() _GLIBCXX_NOEXCEPT + { + this->_M_do_reset(); + return *this; + } + + /** + * @brief Sets a given bit to false. + * @param __position The index of the bit. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + * + * Same as writing @c set(pos,false). + */ + bitset<_Nb>& + reset(size_t __position) + { + this->_M_check(__position, __N("bitset::reset")); + return _Unchecked_reset(__position); + } + + /** + * @brief Toggles every bit to its opposite value. + */ + bitset<_Nb>& + flip() _GLIBCXX_NOEXCEPT + { + this->_M_do_flip(); + this->_M_do_sanitize(); + return *this; + } + + /** + * @brief Toggles a given bit to its opposite value. + * @param __position The index of the bit. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + */ + bitset<_Nb>& + flip(size_t __position) + { + this->_M_check(__position, __N("bitset::flip")); + return _Unchecked_flip(__position); + } + + /// See the no-argument flip(). + bitset<_Nb> + operator~() const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(*this).flip(); } + + ///@{ + /** + * @brief Array-indexing support. + * @param __position Index into the %bitset. + * @return A bool for a const %bitset. For non-const + * bitsets, an instance of the reference proxy class. + * @note These operators do no range checking and throw no exceptions, + * as required by DR 11 to the standard. + * + * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already + * resolves DR 11 (items 1 and 2), but does not do the range-checking + * required by that DR's resolution. -pme + * The DR has since been changed: range-checking is a precondition + * (users' responsibility), and these functions must not throw. -pme + */ + reference + operator[](size_t __position) + { return reference(*this, __position); } + + _GLIBCXX_CONSTEXPR bool + operator[](size_t __position) const + { return _Unchecked_test(__position); } + ///@} + + /** + * @brief Returns a numerical interpretation of the %bitset. + * @return The integral equivalent of the bits. + * @throw std::overflow_error If there are too many bits to be + * represented in an @c unsigned @c long. + */ + unsigned long + to_ulong() const + { return this->_M_do_to_ulong(); } + +#if __cplusplus >= 201103L + unsigned long long + to_ullong() const + { return this->_M_do_to_ullong(); } +#endif + + /** + * @brief Returns a character interpretation of the %bitset. + * @return The string equivalent of the bits. + * + * Note the ordering of the bits: decreasing character positions + * correspond to increasing bit positions (see the main class notes for + * an example). + */ + template + std::basic_string<_CharT, _Traits, _Alloc> + to_string() const + { + std::basic_string<_CharT, _Traits, _Alloc> __result; + _M_copy_to_string(__result, _CharT('0'), _CharT('1')); + return __result; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template + std::basic_string<_CharT, _Traits, _Alloc> + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + std::basic_string<_CharT, _Traits, _Alloc> __result; + _M_copy_to_string(__result, __zero, __one); + return __result; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 434. bitset::to_string() hard to use. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 853. to_string needs updating with zero and one. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { return to_string<_CharT, _Traits, + std::allocator<_CharT> >(__zero, __one); } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string() const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(); + } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(__zero, __one); + } + + std::basic_string, std::allocator > + to_string() const + { + return to_string, + std::allocator >(); + } + + std::basic_string, std::allocator > + to_string(char __zero, char __one = '1') const + { + return to_string, + std::allocator >(__zero, __one); + } + + // Helper functions for string operations. + template + void + _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, + _CharT, _CharT); + + template + void + _M_copy_from_string(const std::basic_string<_CharT, + _Traits, _Alloc>& __s, size_t __pos, size_t __n, + _CharT __zero, _CharT __one) + { _M_copy_from_ptr<_CharT, _Traits>(__s.data(), __s.size(), __pos, __n, + __zero, __one); } + + template + void + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&, + _CharT, _CharT) const; + + // NB: Backward compat. + template + void + _M_copy_from_string(const std::basic_string<_CharT, + _Traits, _Alloc>& __s, size_t __pos, size_t __n) + { _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); } + + template + void + _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const + { _M_copy_to_string(__s, _CharT('0'), _CharT('1')); } + + /// Returns the number of bits which are set. + size_t + count() const _GLIBCXX_NOEXCEPT + { return this->_M_do_count(); } + + /// Returns the total number of bits. + _GLIBCXX_CONSTEXPR size_t + size() const _GLIBCXX_NOEXCEPT + { return _Nb; } + + ///@{ + /// These comparisons for equality/inequality are, well, @e bitwise. + bool + operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT + { return this->_M_is_equal(__rhs); } + +#if __cpp_impl_three_way_comparison < 201907L + bool + operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT + { return !this->_M_is_equal(__rhs); } +#endif + ///@} + + /** + * @brief Tests the value of a bit. + * @param __position The index of a bit. + * @return The value at @a pos. + * @throw std::out_of_range If @a pos is bigger the size of the %set. + */ + bool + test(size_t __position) const + { + this->_M_check(__position, __N("bitset::test")); + return _Unchecked_test(__position); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 693. std::bitset::all() missing. + /** + * @brief Tests whether all the bits are on. + * @return True if all the bits are set. + */ + bool + all() const _GLIBCXX_NOEXCEPT + { return this->template _M_are_all<_Nb>(); } + + /** + * @brief Tests whether any of the bits are on. + * @return True if at least one bit is set. + */ + bool + any() const _GLIBCXX_NOEXCEPT + { return this->_M_is_any(); } + + /** + * @brief Tests whether any of the bits are on. + * @return True if none of the bits are set. + */ + bool + none() const _GLIBCXX_NOEXCEPT + { return !this->_M_is_any(); } + + ///@{ + /// Self-explanatory. + bitset<_Nb> + operator<<(size_t __position) const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(*this) <<= __position; } + + bitset<_Nb> + operator>>(size_t __position) const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(*this) >>= __position; } + ///@} + + /** + * @brief Finds the index of the first "on" bit. + * @return The index of the first bit set, or size() if not found. + * @ingroup SGIextensions + * @sa _Find_next + */ + size_t + _Find_first() const _GLIBCXX_NOEXCEPT + { return this->_M_do_find_first(_Nb); } + + /** + * @brief Finds the index of the next "on" bit after prev. + * @return The index of the next bit set, or size() if not found. + * @param __prev Where to start searching. + * @ingroup SGIextensions + * @sa _Find_first + */ + size_t + _Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT + { return this->_M_do_find_next(__prev, _Nb); } + }; + + // Definitions of non-inline member functions. + template + template + void + bitset<_Nb>:: + _M_copy_from_ptr(const _CharT* __s, size_t __len, + size_t __pos, size_t __n, _CharT __zero, _CharT __one) + { + reset(); + const size_t __nbits = std::min(_Nb, std::min(__n, size_t(__len - __pos))); + for (size_t __i = __nbits; __i > 0; --__i) + { + const _CharT __c = __s[__pos + __nbits - __i]; + if (_Traits::eq(__c, __zero)) + ; + else if (_Traits::eq(__c, __one)) + _Unchecked_set(__i - 1); + else + __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); + } + } + + template + template + void + bitset<_Nb>:: + _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s, + _CharT __zero, _CharT __one) const + { + __s.assign(_Nb, __zero); + for (size_t __i = _Nb; __i > 0; --__i) + if (_Unchecked_test(__i - 1)) + _Traits::assign(__s[_Nb - __i], __one); + } + + // 23.3.5.3 bitset operations: + ///@{ + /** + * @brief Global bitwise operations on bitsets. + * @param __x A bitset. + * @param __y A bitset of the same size as @a __x. + * @return A new bitset. + * + * These should be self-explanatory. + */ + template + inline bitset<_Nb> + operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { + bitset<_Nb> __result(__x); + __result &= __y; + return __result; + } + + template + inline bitset<_Nb> + operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { + bitset<_Nb> __result(__x); + __result |= __y; + return __result; + } + + template + inline bitset<_Nb> + operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { + bitset<_Nb> __result(__x); + __result ^= __y; + return __result; + } + ///@} + + ///@{ + /** + * @brief Global I/O operators for bitsets. + * + * Direct I/O between streams and bitsets is supported. Output is + * straightforward. Input will skip whitespace, only accept @a 0 and @a 1 + * characters, and will only extract as many digits as the %bitset will + * hold. + */ + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) + { + typedef typename _Traits::char_type char_type; + typedef std::basic_istream<_CharT, _Traits> __istream_type; + typedef typename __istream_type::ios_base __ios_base; + + std::basic_string<_CharT, _Traits> __tmp; + __tmp.reserve(_Nb); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 303. Bitset input operator underspecified + const char_type __zero = __is.widen('0'); + const char_type __one = __is.widen('1'); + + typename __ios_base::iostate __state = __ios_base::goodbit; + typename __istream_type::sentry __sentry(__is); + if (__sentry) + { + __try + { + for (size_t __i = _Nb; __i > 0; --__i) + { + static typename _Traits::int_type __eof = _Traits::eof(); + + typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc(); + if (_Traits::eq_int_type(__c1, __eof)) + { + __state |= __ios_base::eofbit; + break; + } + else + { + const char_type __c2 = _Traits::to_char_type(__c1); + if (_Traits::eq(__c2, __zero)) + __tmp.push_back(__zero); + else if (_Traits::eq(__c2, __one)) + __tmp.push_back(__one); + else if (_Traits:: + eq_int_type(__is.rdbuf()->sputbackc(__c2), + __eof)) + { + __state |= __ios_base::failbit; + break; + } + } + } + } + __catch(__cxxabiv1::__forced_unwind&) + { + __is._M_setstate(__ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { __is._M_setstate(__ios_base::badbit); } + } + + if (__tmp.empty() && _Nb) + __state |= __ios_base::failbit; + else + __x._M_copy_from_string(__tmp, static_cast(0), _Nb, + __zero, __one); + if (__state) + __is.setstate(__state); + return __is; + } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bitset<_Nb>& __x) + { + std::basic_string<_CharT, _Traits> __tmp; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + const ctype<_CharT>& __ct = use_facet >(__os.getloc()); + __x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1')); + return __os << __tmp; + } + ///@} + +_GLIBCXX_END_NAMESPACE_CONTAINER +} // namespace std + +#undef _GLIBCXX_BITSET_WORDS +#undef _GLIBCXX_BITSET_BITS_PER_WORD +#undef _GLIBCXX_BITSET_BITS_PER_ULL + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // DR 1182. + /// std::hash specialization for bitset. + template + struct hash<_GLIBCXX_STD_C::bitset<_Nb>> + : public __hash_base> + { + size_t + operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept + { + const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__; + return std::_Hash_impl::hash(__b._M_getdata(), __clength); + } + }; + + template<> + struct hash<_GLIBCXX_STD_C::bitset<0>> + : public __hash_base> + { + size_t + operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept + { return 0; } + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#endif /* _GLIBCXX_BITSET */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cassert b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cassert new file mode 100755 index 0000000..a6bfae3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cassert @@ -0,0 +1,44 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cassert + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c assert.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 19.2 Assertions +// + +// No include guards on this header... + +#pragma GCC system_header + +#include +#include diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ccomplex b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ccomplex new file mode 100755 index 0000000..b2bfd3d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ccomplex @@ -0,0 +1,42 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ccomplex + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CCOMPLEX +#define _GLIBCXX_CCOMPLEX 1 + +#if __cplusplus < 201103L +# include +#endif + +extern "C++" { +#include +} + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cctype b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cctype new file mode 100755 index 0000000..c4ee5a4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cctype @@ -0,0 +1,94 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cctype + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c ctype.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CCTYPE +#define _GLIBCXX_CCTYPE 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef isalnum +#undef isalpha +#undef iscntrl +#undef isdigit +#undef isgraph +#undef islower +#undef isprint +#undef ispunct +#undef isspace +#undef isupper +#undef isxdigit +#undef tolower +#undef toupper + +namespace std +{ + using ::isalnum; + using ::isalpha; + using ::iscntrl; + using ::isdigit; + using ::isgraph; + using ::islower; + using ::isprint; + using ::ispunct; + using ::isspace; + using ::isupper; + using ::isxdigit; + using ::tolower; + using ::toupper; +} // namespace std + +#if __cplusplus >= 201103L + +#ifdef _GLIBCXX_USE_C99_CTYPE_TR1 + +#undef isblank + +namespace std +{ + using ::isblank; +} // namespace std + +#endif // _GLIBCXX_USE_C99_CTYPE_TR1 + +#endif // C++11 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cerrno b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cerrno new file mode 100755 index 0000000..f76053c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cerrno @@ -0,0 +1,52 @@ +// The -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cerrno + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c errno.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 19.3 Error numbers +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CERRNO +#define _GLIBCXX_CERRNO 1 + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef errno +#define errno errno +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cfenv b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cfenv new file mode 100755 index 0000000..0b0ec35 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cfenv @@ -0,0 +1,84 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cfenv + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CFENV +#define _GLIBCXX_CFENV 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +#if _GLIBCXX_HAVE_FENV_H +# include +#endif + +#ifdef _GLIBCXX_USE_C99_FENV_TR1 + +#undef feclearexcept +#undef fegetexceptflag +#undef feraiseexcept +#undef fesetexceptflag +#undef fetestexcept +#undef fegetround +#undef fesetround +#undef fegetenv +#undef feholdexcept +#undef fesetenv +#undef feupdateenv + +namespace std +{ + // types + using ::fenv_t; + using ::fexcept_t; + + // functions + using ::feclearexcept; + using ::fegetexceptflag; + using ::feraiseexcept; + using ::fesetexceptflag; + using ::fetestexcept; + + using ::fegetround; + using ::fesetround; + + using ::fegetenv; + using ::feholdexcept; + using ::fesetenv; + using ::feupdateenv; +} // namespace std + +#endif // _GLIBCXX_USE_C99_FENV_TR1 + +#endif // C++11 + +#endif // _GLIBCXX_CFENV diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cfloat b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cfloat new file mode 100755 index 0000000..acb94b8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cfloat @@ -0,0 +1,56 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cfloat + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c float.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CFLOAT +#define _GLIBCXX_CFLOAT 1 + +#if __cplusplus >= 201103L +# ifndef DECIMAL_DIG +# define DECIMAL_DIG __DECIMAL_DIG__ +# endif +# ifndef FLT_EVAL_METHOD +# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +# endif +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/charconv b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/charconv new file mode 100755 index 0000000..8572e37 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/charconv @@ -0,0 +1,734 @@ +// Primitive numeric conversions (to_chars and from_chars) -*- C++ -*- + +// Copyright (C) 2017-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/charconv + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CHARCONV +#define _GLIBCXX_CHARCONV 1 + +#pragma GCC system_header + +// As an extension we support in C++14, but this header should not +// be included by any other library headers in C++14 mode. This ensures that +// the names defined in this header are not added to namespace std unless a +// user explicitly includes in C++14 code. +#if __cplusplus >= 201402L + +#include +#include // for __bit_width +#include // for isdigit +#include // for __to_chars_len, __to_chars_10_impl +#include // for std::errc +#include + +#if _GLIBCXX_HAVE_USELOCALE +# define __cpp_lib_to_chars 201611L +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Result type of std::to_chars + struct to_chars_result + { + char* ptr; + errc ec; + +#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L + friend bool + operator==(const to_chars_result&, const to_chars_result&) = default; +#endif + }; + + /// Result type of std::from_chars + struct from_chars_result + { + const char* ptr; + errc ec; + +#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L + friend bool + operator==(const from_chars_result&, const from_chars_result&) = default; +#endif + }; + +namespace __detail +{ + template + using __integer_to_chars_result_type + = enable_if_t<__or_<__is_signed_integer<_Tp>, + __is_unsigned_integer<_Tp>, + is_same>>::value, + to_chars_result>; + + // Pick an unsigned type of suitable size. This is used to reduce the + // number of specializations of __to_chars_len, __to_chars etc. that + // get instantiated. For example, to_chars and to_chars + // and to_chars will all use the same code, and so will + // to_chars when sizeof(int) == sizeof(long). + template + struct __to_chars_unsigned_type : __make_unsigned_selector_base + { + using _UInts = _List; + using type = typename __select::__type; + }; + + template + using __unsigned_least_t = typename __to_chars_unsigned_type<_Tp>::type; + + // Generic implementation for arbitrary bases. + // Defined in . + template + constexpr unsigned + __to_chars_len(_Tp __value, int __base /* = 10 */) noexcept; + + template + constexpr unsigned + __to_chars_len_2(_Tp __value) noexcept + { return std::__bit_width(__value); } + + // Generic implementation for arbitrary bases. + template + to_chars_result + __to_chars(char* __first, char* __last, _Tp __val, int __base) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + to_chars_result __res; + + const unsigned __len = __to_chars_len(__val, __base); + + if (__builtin_expect((__last - __first) < __len, 0)) + { + __res.ptr = __last; + __res.ec = errc::value_too_large; + return __res; + } + + unsigned __pos = __len - 1; + + static constexpr char __digits[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', + 'u', 'v', 'w', 'x', 'y', 'z' + }; + + while (__val >= (unsigned)__base) + { + auto const __quo = __val / __base; + auto const __rem = __val % __base; + __first[__pos--] = __digits[__rem]; + __val = __quo; + } + *__first = __digits[__val]; + + __res.ptr = __first + __len; + __res.ec = {}; + return __res; + } + + template + __integer_to_chars_result_type<_Tp> + __to_chars_16(char* __first, char* __last, _Tp __val) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + to_chars_result __res; + + const unsigned __len = (__to_chars_len_2(__val) + 3) / 4; + + if (__builtin_expect((__last - __first) < __len, 0)) + { + __res.ptr = __last; + __res.ec = errc::value_too_large; + return __res; + } + + static constexpr char __digits[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f' + }; + unsigned __pos = __len - 1; + while (__val >= 0x100) + { + auto __num = __val & 0xF; + __val >>= 4; + __first[__pos] = __digits[__num]; + __num = __val & 0xF; + __val >>= 4; + __first[__pos - 1] = __digits[__num]; + __pos -= 2; + } + if (__val >= 0x10) + { + const auto __num = __val & 0xF; + __val >>= 4; + __first[1] = __digits[__num]; + __first[0] = __digits[__val]; + } + else + __first[0] = __digits[__val]; + __res.ptr = __first + __len; + __res.ec = {}; + return __res; + } + + template + inline __integer_to_chars_result_type<_Tp> + __to_chars_10(char* __first, char* __last, _Tp __val) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + to_chars_result __res; + + const unsigned __len = __to_chars_len(__val, 10); + + if (__builtin_expect((__last - __first) < __len, 0)) + { + __res.ptr = __last; + __res.ec = errc::value_too_large; + return __res; + } + + __detail::__to_chars_10_impl(__first, __len, __val); + __res.ptr = __first + __len; + __res.ec = {}; + return __res; + } + + template + __integer_to_chars_result_type<_Tp> + __to_chars_8(char* __first, char* __last, _Tp __val) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + to_chars_result __res; + unsigned __len; + + if _GLIBCXX17_CONSTEXPR (__gnu_cxx::__int_traits<_Tp>::__digits <= 16) + { + __len = __val > 077777u ? 6u + : __val > 07777u ? 5u + : __val > 0777u ? 4u + : __val > 077u ? 3u + : __val > 07u ? 2u + : 1u; + } + else + __len = (__to_chars_len_2(__val) + 2) / 3; + + if (__builtin_expect((__last - __first) < __len, 0)) + { + __res.ptr = __last; + __res.ec = errc::value_too_large; + return __res; + } + + unsigned __pos = __len - 1; + while (__val >= 0100) + { + auto __num = __val & 7; + __val >>= 3; + __first[__pos] = '0' + __num; + __num = __val & 7; + __val >>= 3; + __first[__pos - 1] = '0' + __num; + __pos -= 2; + } + if (__val >= 010) + { + auto const __num = __val & 7; + __val >>= 3; + __first[1] = '0' + __num; + __first[0] = '0' + __val; + } + else + __first[0] = '0' + __val; + __res.ptr = __first + __len; + __res.ec = {}; + return __res; + } + + template + __integer_to_chars_result_type<_Tp> + __to_chars_2(char* __first, char* __last, _Tp __val) noexcept + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + to_chars_result __res; + + const unsigned __len = __to_chars_len_2(__val); + + if (__builtin_expect((__last - __first) < __len, 0)) + { + __res.ptr = __last; + __res.ec = errc::value_too_large; + return __res; + } + + unsigned __pos = __len - 1; + + while (__pos) + { + __first[__pos--] = '0' + (__val & 1); + __val >>= 1; + } + // First digit is always '1' because __to_chars_len_2 skips + // leading zero bits and std::to_chars handles zero values + // directly. + __first[0] = '1'; + + __res.ptr = __first + __len; + __res.ec = {}; + return __res; + } + +} // namespace __detail + + template + __detail::__integer_to_chars_result_type<_Tp> + __to_chars_i(char* __first, char* __last, _Tp __value, int __base = 10) + { + __glibcxx_assert(2 <= __base && __base <= 36); + + using _Up = __detail::__unsigned_least_t<_Tp>; + _Up __unsigned_val = __value; + + if (__first == __last) [[__unlikely__]] + return { __last, errc::value_too_large }; + + if (__value == 0) + { + *__first = '0'; + return { __first + 1, errc{} }; + } + else if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value) + if (__value < 0) + { + *__first++ = '-'; + __unsigned_val = _Up(~__value) + _Up(1); + } + + switch (__base) + { + case 16: + return __detail::__to_chars_16(__first, __last, __unsigned_val); + case 10: + return __detail::__to_chars_10(__first, __last, __unsigned_val); + case 8: + return __detail::__to_chars_8(__first, __last, __unsigned_val); + case 2: + return __detail::__to_chars_2(__first, __last, __unsigned_val); + default: + return __detail::__to_chars(__first, __last, __unsigned_val, __base); + } + } + +#define _GLIBCXX_TO_CHARS(T) \ + inline to_chars_result \ + to_chars(char* __first, char* __last, T __value, int __base = 10) \ + { return std::__to_chars_i(__first, __last, __value, __base); } +_GLIBCXX_TO_CHARS(char) +_GLIBCXX_TO_CHARS(signed char) +_GLIBCXX_TO_CHARS(unsigned char) +_GLIBCXX_TO_CHARS(signed short) +_GLIBCXX_TO_CHARS(unsigned short) +_GLIBCXX_TO_CHARS(signed int) +_GLIBCXX_TO_CHARS(unsigned int) +_GLIBCXX_TO_CHARS(signed long) +_GLIBCXX_TO_CHARS(unsigned long) +_GLIBCXX_TO_CHARS(signed long long) +_GLIBCXX_TO_CHARS(unsigned long long) +#if defined(__GLIBCXX_TYPE_INT_N_0) +_GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_0) +_GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_0) +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) +_GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_1) +_GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_1) +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) +_GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_2) +_GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_2) +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) +_GLIBCXX_TO_CHARS(signed __GLIBCXX_TYPE_INT_N_3) +_GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_3) +#endif +#undef _GLIBCXX_TO_CHARS + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3266. to_chars(bool) should be deleted + to_chars_result to_chars(char*, char*, bool, int = 10) = delete; + +namespace __detail +{ + template + bool + __raise_and_add(_Tp& __val, int __base, unsigned char __c) + { + if (__builtin_mul_overflow(__val, __base, &__val) + || __builtin_add_overflow(__val, __c, &__val)) + return false; + return true; + } + + /// std::from_chars implementation for integers in base 2. + template + bool + __from_chars_binary(const char*& __first, const char* __last, _Tp& __val) + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + const ptrdiff_t __len = __last - __first; + ptrdiff_t __i = 0; + while (__i < __len && __first[__i] == '0') + ++__i; + const ptrdiff_t __leading_zeroes = __i; + + while (__i < __len) + { + const unsigned char __c = (unsigned)__first[__i] - '0'; + if (__c < 2) + __val = (__val << 1) | __c; + else + break; + __i++; + } + __first += __i; + return (__i - __leading_zeroes) <= __gnu_cxx::__int_traits<_Tp>::__digits; + } + + /// std::from_chars implementation for integers in bases 3 to 10. + template + bool + __from_chars_digit(const char*& __first, const char* __last, _Tp& __val, + int __base) + { + static_assert(is_integral<_Tp>::value, "implementation bug"); + static_assert(is_unsigned<_Tp>::value, "implementation bug"); + + auto __matches = [__base](char __c) { + return '0' <= __c && __c <= ('0' + (__base - 1)); + }; + + while (__first != __last) + { + const char __c = *__first; + if (__matches(__c)) + { + if (!__raise_and_add(__val, __base, __c - '0')) + { + while (++__first != __last && __matches(*__first)) + ; + return false; + } + __first++; + } + else + return true; + } + return true; + } + + constexpr unsigned char + __from_chars_alpha_to_num(char __c) + { + switch (__c) + { + case 'a': + case 'A': + return 10; + case 'b': + case 'B': + return 11; + case 'c': + case 'C': + return 12; + case 'd': + case 'D': + return 13; + case 'e': + case 'E': + return 14; + case 'f': + case 'F': + return 15; + case 'g': + case 'G': + return 16; + case 'h': + case 'H': + return 17; + case 'i': + case 'I': + return 18; + case 'j': + case 'J': + return 19; + case 'k': + case 'K': + return 20; + case 'l': + case 'L': + return 21; + case 'm': + case 'M': + return 22; + case 'n': + case 'N': + return 23; + case 'o': + case 'O': + return 24; + case 'p': + case 'P': + return 25; + case 'q': + case 'Q': + return 26; + case 'r': + case 'R': + return 27; + case 's': + case 'S': + return 28; + case 't': + case 'T': + return 29; + case 'u': + case 'U': + return 30; + case 'v': + case 'V': + return 31; + case 'w': + case 'W': + return 32; + case 'x': + case 'X': + return 33; + case 'y': + case 'Y': + return 34; + case 'z': + case 'Z': + return 35; + } + return __gnu_cxx::__int_traits::__max; + } + + /// std::from_chars implementation for integers in bases 11 to 26. + template + bool + __from_chars_alnum(const char*& __first, const char* __last, _Tp& __val, + int __base) + { + bool __valid = true; + while (__first != __last) + { + unsigned char __c = *__first; + if (std::isdigit(__c)) + __c -= '0'; + else + { + __c = __from_chars_alpha_to_num(__c); + if (__c >= __base) + break; + } + + if (__builtin_expect(__valid, 1)) + __valid = __raise_and_add(__val, __base, __c); + __first++; + } + return __valid; + } + + template + using __integer_from_chars_result_type + = enable_if_t<__or_<__is_signed_integer<_Tp>, + __is_unsigned_integer<_Tp>, + is_same>>::value, + from_chars_result>; + +} // namespace __detail + + /// std::from_chars for integral types. + template + __detail::__integer_from_chars_result_type<_Tp> + from_chars(const char* __first, const char* __last, _Tp& __value, + int __base = 10) + { + __glibcxx_assert(2 <= __base && __base <= 36); + + from_chars_result __res{__first, {}}; + + int __sign = 1; + if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value) + if (__first != __last && *__first == '-') + { + __sign = -1; + ++__first; + } + + using _Up = __detail::__unsigned_least_t<_Tp>; + _Up __val = 0; + + const auto __start = __first; + bool __valid; + if (__base == 2) + __valid = __detail::__from_chars_binary(__first, __last, __val); + else if (__base <= 10) + __valid = __detail::__from_chars_digit(__first, __last, __val, __base); + else + __valid = __detail::__from_chars_alnum(__first, __last, __val, __base); + + if (__builtin_expect(__first == __start, 0)) + __res.ec = errc::invalid_argument; + else + { + __res.ptr = __first; + if (!__valid) + __res.ec = errc::result_out_of_range; + else + { + if _GLIBCXX17_CONSTEXPR (std::is_signed<_Tp>::value) + { + _Tp __tmp; + if (__builtin_mul_overflow(__val, __sign, &__tmp)) + __res.ec = errc::result_out_of_range; + else + __value = __tmp; + } + else + { + if _GLIBCXX17_CONSTEXPR (__gnu_cxx::__int_traits<_Up>::__max + > __gnu_cxx::__int_traits<_Tp>::__max) + { + if (__val > __gnu_cxx::__int_traits<_Tp>::__max) + __res.ec = errc::result_out_of_range; + else + __value = __val; + } + else + __value = __val; + } + } + } + return __res; + } + + /// floating-point format for primitive numerical conversion + enum class chars_format + { + scientific = 1, fixed = 2, hex = 4, general = fixed | scientific + }; + + constexpr chars_format + operator|(chars_format __lhs, chars_format __rhs) noexcept + { return (chars_format)((unsigned)__lhs | (unsigned)__rhs); } + + constexpr chars_format + operator&(chars_format __lhs, chars_format __rhs) noexcept + { return (chars_format)((unsigned)__lhs & (unsigned)__rhs); } + + constexpr chars_format + operator^(chars_format __lhs, chars_format __rhs) noexcept + { return (chars_format)((unsigned)__lhs ^ (unsigned)__rhs); } + + constexpr chars_format + operator~(chars_format __fmt) noexcept + { return (chars_format)~(unsigned)__fmt; } + + constexpr chars_format& + operator|=(chars_format& __lhs, chars_format __rhs) noexcept + { return __lhs = __lhs | __rhs; } + + constexpr chars_format& + operator&=(chars_format& __lhs, chars_format __rhs) noexcept + { return __lhs = __lhs & __rhs; } + + constexpr chars_format& + operator^=(chars_format& __lhs, chars_format __rhs) noexcept + { return __lhs = __lhs ^ __rhs; } + +#if _GLIBCXX_HAVE_USELOCALE + from_chars_result + from_chars(const char* __first, const char* __last, float& __value, + chars_format __fmt = chars_format::general) noexcept; + + from_chars_result + from_chars(const char* __first, const char* __last, double& __value, + chars_format __fmt = chars_format::general) noexcept; + + from_chars_result + from_chars(const char* __first, const char* __last, long double& __value, + chars_format __fmt = chars_format::general) noexcept; +#endif + +#if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \ + && __SIZE_WIDTH__ >= 32 + // Floating-point std::to_chars + + // Overloads for float. + to_chars_result to_chars(char* __first, char* __last, float __value) noexcept; + to_chars_result to_chars(char* __first, char* __last, float __value, + chars_format __fmt) noexcept; + to_chars_result to_chars(char* __first, char* __last, float __value, + chars_format __fmt, int __precision) noexcept; + + // Overloads for double. + to_chars_result to_chars(char* __first, char* __last, double __value) noexcept; + to_chars_result to_chars(char* __first, char* __last, double __value, + chars_format __fmt) noexcept; + to_chars_result to_chars(char* __first, char* __last, double __value, + chars_format __fmt, int __precision) noexcept; + + // Overloads for long double. + to_chars_result to_chars(char* __first, char* __last, long double __value) + noexcept; + to_chars_result to_chars(char* __first, char* __last, long double __value, + chars_format __fmt) noexcept; + to_chars_result to_chars(char* __first, char* __last, long double __value, + chars_format __fmt, int __precision) noexcept; +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++14 +#endif // _GLIBCXX_CHARCONV diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/chrono b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/chrono new file mode 100755 index 0000000..a52304b --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/chrono @@ -0,0 +1,3410 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/chrono + * This is a Standard C++ Library header. + * @ingroup chrono + */ + +#ifndef _GLIBCXX_CHRONO +#define _GLIBCXX_CHRONO 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include // for literals support. +#if __cplusplus > 201703L +# include +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201703L + namespace filesystem { struct __file_clock; }; +#endif + + /** + * @defgroup chrono Time + * @ingroup utilities + * + * Classes and functions for time. + * + * @since C++11 + */ + + /** @namespace std::chrono + * @brief ISO C++ 2011 namespace for date and time utilities + * @ingroup chrono + */ + namespace chrono + { + /// @addtogroup chrono + /// @{ + + /// `chrono::duration` represents a distance between two points in time + template> + struct duration; + + /// `chrono::time_point` represents a point in time as measured by a clock + template + struct time_point; + /// @} + } + + /// @addtogroup chrono + /// @{ + + // 20.11.4.3 specialization of common_type (for duration, sfinae-friendly) + + /// @cond undocumented + + template + struct __duration_common_type + { }; + + template + struct __duration_common_type<_CT, _Period1, _Period2, + __void_t> + { + private: + using __gcd_num = __static_gcd<_Period1::num, _Period2::num>; + using __gcd_den = __static_gcd<_Period1::den, _Period2::den>; + using __cr = typename _CT::type; + using __r = ratio<__gcd_num::value, + (_Period1::den / __gcd_den::value) * _Period2::den>; + + public: + using type = chrono::duration<__cr, typename __r::type>; + }; + + /// @endcond + + /// @{ + /// @relates chrono::duration + + /// Specialization of common_type for chrono::duration types. + template + struct common_type, + chrono::duration<_Rep2, _Period2>> + : __duration_common_type, + typename _Period1::type, + typename _Period2::type> + { }; + + /// Specialization of common_type for two identical chrono::duration types. + template + struct common_type, + chrono::duration<_Rep, _Period>> + { + using type = chrono::duration::type, + typename _Period::type>; + }; + + /// Specialization of common_type for one chrono::duration type. + template + struct common_type> + { + using type = chrono::duration::type, + typename _Period::type>; + }; + /// @} + + // 20.11.4.3 specialization of common_type (for time_point, sfinae-friendly) + + /// @cond undocumented + + template + struct __timepoint_common_type + { }; + + template + struct __timepoint_common_type<_CT, _Clock, __void_t> + { + using type = chrono::time_point<_Clock, typename _CT::type>; + }; + + /// @endcond + + /// @{ + /// @relates chrono::time_point + + /// Specialization of common_type for chrono::time_point types. + template + struct common_type, + chrono::time_point<_Clock, _Duration2>> + : __timepoint_common_type, _Clock> + { }; + + /// Specialization of common_type for two identical chrono::time_point types. + template + struct common_type, + chrono::time_point<_Clock, _Duration>> + { using type = chrono::time_point<_Clock, _Duration>; }; + + /// Specialization of common_type for one chrono::time_point type. + template + struct common_type> + { using type = chrono::time_point<_Clock, _Duration>; }; + /// @} + + /// @} group chrono + + namespace chrono + { + /// @addtogroup chrono + /// @{ + + /// @cond undocumented + + // Primary template for duration_cast impl. + template + struct __duration_cast_impl + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count()) + * static_cast<_CR>(_CF::num) + / static_cast<_CR>(_CF::den))); + } + }; + + template + struct __duration_cast_impl<_ToDur, _CF, _CR, true, true> + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>(__d.count())); + } + }; + + template + struct __duration_cast_impl<_ToDur, _CF, _CR, true, false> + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>( + static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den))); + } + }; + + template + struct __duration_cast_impl<_ToDur, _CF, _CR, false, true> + { + template + static constexpr _ToDur + __cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::rep __to_rep; + return _ToDur(static_cast<__to_rep>( + static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num))); + } + }; + + template + struct __is_duration + : std::false_type + { }; + + template + struct __is_duration> + : std::true_type + { }; + + template + using __enable_if_is_duration + = typename enable_if<__is_duration<_Tp>::value, _Tp>::type; + + template + using __disable_if_is_duration + = typename enable_if::value, _Tp>::type; + + /// @endcond + + /// duration_cast + template + constexpr __enable_if_is_duration<_ToDur> + duration_cast(const duration<_Rep, _Period>& __d) + { + typedef typename _ToDur::period __to_period; + typedef typename _ToDur::rep __to_rep; + typedef ratio_divide<_Period, __to_period> __cf; + typedef typename common_type<__to_rep, _Rep, intmax_t>::type + __cr; + typedef __duration_cast_impl<_ToDur, __cf, __cr, + __cf::num == 1, __cf::den == 1> __dc; + return __dc::__cast(__d); + } + + /// treat_as_floating_point + template + struct treat_as_floating_point + : is_floating_point<_Rep> + { }; + +#if __cplusplus > 201402L + template + inline constexpr bool treat_as_floating_point_v = + treat_as_floating_point<_Rep>::value; +#endif // C++17 + +#if __cplusplus > 201703L + template + struct is_clock; + + template + inline constexpr bool is_clock_v = is_clock<_Tp>::value; + +#if __cpp_lib_concepts + template + struct is_clock : false_type + { }; + + template + requires requires { + typename _Tp::rep; + typename _Tp::period; + typename _Tp::duration; + typename _Tp::time_point::clock; + typename _Tp::time_point::duration; + { &_Tp::is_steady } -> same_as; + { _Tp::now() } -> same_as; + requires same_as>; + requires same_as; + } + struct is_clock<_Tp> : true_type + { }; +#else + template + struct __is_clock_impl : false_type + { }; + + template + struct __is_clock_impl<_Tp, + void_t> + : __and_>, + is_same, + is_same, + is_same>::type + { }; + + template + struct is_clock : __is_clock_impl<_Tp>::type + { }; +#endif +#endif // C++20 + +#if __cplusplus >= 201703L +# define __cpp_lib_chrono 201611 + + template + constexpr __enable_if_is_duration<_ToDur> + floor(const duration<_Rep, _Period>& __d) + { + auto __to = chrono::duration_cast<_ToDur>(__d); + if (__to > __d) + return __to - _ToDur{1}; + return __to; + } + + template + constexpr __enable_if_is_duration<_ToDur> + ceil(const duration<_Rep, _Period>& __d) + { + auto __to = chrono::duration_cast<_ToDur>(__d); + if (__to < __d) + return __to + _ToDur{1}; + return __to; + } + + template + constexpr enable_if_t< + __and_<__is_duration<_ToDur>, + __not_>>::value, + _ToDur> + round(const duration<_Rep, _Period>& __d) + { + _ToDur __t0 = chrono::floor<_ToDur>(__d); + _ToDur __t1 = __t0 + _ToDur{1}; + auto __diff0 = __d - __t0; + auto __diff1 = __t1 - __d; + if (__diff0 == __diff1) + { + if (__t0.count() & 1) + return __t1; + return __t0; + } + else if (__diff0 < __diff1) + return __t0; + return __t1; + } + + template + constexpr + enable_if_t::is_signed, duration<_Rep, _Period>> + abs(duration<_Rep, _Period> __d) + { + if (__d >= __d.zero()) + return __d; + return -__d; + } + + // Make chrono::ceil also usable as chrono::__detail::ceil. + namespace __detail { using chrono::ceil; } + +#else // ! C++17 + + // We want to use ceil even when compiling for earlier standards versions. + // C++11 only allows a single statement in a constexpr function, so we + // need to move the comparison into a separate function, __ceil_impl. + namespace __detail + { + template + constexpr _Tp + __ceil_impl(const _Tp& __t, const _Up& __u) + { + return (__t < __u) ? (__t + _Tp{1}) : __t; + } + + // C++11-friendly version of std::chrono::ceil for internal use. + template + constexpr _ToDur + ceil(const duration<_Rep, _Period>& __d) + { + return __detail::__ceil_impl(chrono::duration_cast<_ToDur>(__d), __d); + } + } +#endif // C++17 + + /// duration_values + template + struct duration_values + { + static constexpr _Rep + zero() noexcept + { return _Rep(0); } + + static constexpr _Rep + max() noexcept + { return numeric_limits<_Rep>::max(); } + + static constexpr _Rep + min() noexcept + { return numeric_limits<_Rep>::lowest(); } + }; + + /// @cond undocumented + + template + struct __is_ratio + : std::false_type + { }; + + template + struct __is_ratio> + : std::true_type + { }; + + /// @endcond + + template + struct duration + { + private: + template + using __is_float = treat_as_floating_point<_Rep2>; + + static constexpr intmax_t + _S_gcd(intmax_t __m, intmax_t __n) noexcept + { + // Duration only allows positive periods so we don't need to + // handle negative values here (unlike __static_gcd and std::gcd). +#if __cplusplus >= 201402L + do + { + intmax_t __rem = __m % __n; + __m = __n; + __n = __rem; + } + while (__n != 0); + return __m; +#else + // C++11 doesn't allow loops in constexpr functions, but this + // recursive version can be more expensive to evaluate. + return (__n == 0) ? __m : _S_gcd(__n, __m % __n); +#endif + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2094. overflow shouldn't participate in overload resolution + // 3090. What is [2094] intended to mean? + // This only produces a valid type if no overflow occurs. + template + using __divide = ratio<(_R1::num / __gcd1) * (_R2::den / __gcd2), + (_R1::den / __gcd2) * (_R2::num / __gcd1)>; + + // _Period2 is an exact multiple of _Period + template + using __is_harmonic + = __bool_constant<__divide<_Period2, _Period>::den == 1>; + + public: + + using rep = _Rep; + using period = typename _Period::type; + + static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration"); + static_assert(__is_ratio<_Period>::value, + "period must be a specialization of ratio"); + static_assert(_Period::num > 0, "period must be positive"); + + // 20.11.5.1 construction / copy / destroy + constexpr duration() = default; + + duration(const duration&) = default; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3050. Conversion specification problem in chrono::duration + template, + __or_<__is_float, __not_<__is_float<_Rep2>>>>> + constexpr explicit duration(const _Rep2& __rep) + : __r(static_cast(__rep)) { } + + template, + __or_<__is_float, + __and_<__is_harmonic<_Period2>, + __not_<__is_float<_Rep2>>>>>> + constexpr duration(const duration<_Rep2, _Period2>& __d) + : __r(duration_cast(__d).count()) { } + + ~duration() = default; + duration& operator=(const duration&) = default; + + // 20.11.5.2 observer + constexpr rep + count() const + { return __r; } + + // 20.11.5.3 arithmetic + + constexpr duration::type, period> + operator+() const + { return duration::type, period>(__r); } + + constexpr duration::type, period> + operator-() const + { return duration::type, period>(-__r); } + + _GLIBCXX17_CONSTEXPR duration& + operator++() + { + ++__r; + return *this; + } + + _GLIBCXX17_CONSTEXPR duration + operator++(int) + { return duration(__r++); } + + _GLIBCXX17_CONSTEXPR duration& + operator--() + { + --__r; + return *this; + } + + _GLIBCXX17_CONSTEXPR duration + operator--(int) + { return duration(__r--); } + + _GLIBCXX17_CONSTEXPR duration& + operator+=(const duration& __d) + { + __r += __d.count(); + return *this; + } + + _GLIBCXX17_CONSTEXPR duration& + operator-=(const duration& __d) + { + __r -= __d.count(); + return *this; + } + + _GLIBCXX17_CONSTEXPR duration& + operator*=(const rep& __rhs) + { + __r *= __rhs; + return *this; + } + + _GLIBCXX17_CONSTEXPR duration& + operator/=(const rep& __rhs) + { + __r /= __rhs; + return *this; + } + + // DR 934. + template + _GLIBCXX17_CONSTEXPR + typename enable_if::value, + duration&>::type + operator%=(const rep& __rhs) + { + __r %= __rhs; + return *this; + } + + template + _GLIBCXX17_CONSTEXPR + typename enable_if::value, + duration&>::type + operator%=(const duration& __d) + { + __r %= __d.count(); + return *this; + } + + // 20.11.5.4 special values + static constexpr duration + zero() noexcept + { return duration(duration_values::zero()); } + + static constexpr duration + min() noexcept + { return duration(duration_values::min()); } + + static constexpr duration + max() noexcept + { return duration(duration_values::max()); } + + private: + rep __r; + }; + + /// @{ + /// @relates std::chrono::duration + + /// The sum of two durations. + template + constexpr typename common_type, + duration<_Rep2, _Period2>>::type + operator+(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__cd(__lhs).count() + __cd(__rhs).count()); + } + + /// The difference between two durations. + template + constexpr typename common_type, + duration<_Rep2, _Period2>>::type + operator-(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__cd(__lhs).count() - __cd(__rhs).count()); + } + + /// @} + + /// @cond undocumented + + // SFINAE helper to obtain common_type<_Rep1, _Rep2> only if _Rep2 + // is implicitly convertible to it. + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3050. Conversion specification problem in chrono::duration constructor + template::type> + using __common_rep_t = typename + enable_if::value, _CRep>::type; + + /// @endcond + + /** @{ + * Arithmetic operators for chrono::duration + * @relates std::chrono::duration + */ + + template + constexpr duration<__common_rep_t<_Rep1, _Rep2>, _Period> + operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef duration::type, _Period> + __cd; + return __cd(__cd(__d).count() * __s); + } + + template + constexpr duration<__common_rep_t<_Rep2, _Rep1>, _Period> + operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) + { return __d * __s; } + + template + constexpr + duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period> + operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef duration::type, _Period> + __cd; + return __cd(__cd(__d).count() / __s); + } + + template + constexpr typename common_type<_Rep1, _Rep2>::type + operator/(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__lhs).count() / __cd(__rhs).count(); + } + + // DR 934. + template + constexpr + duration<__common_rep_t<_Rep1, __disable_if_is_duration<_Rep2>>, _Period> + operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) + { + typedef duration::type, _Period> + __cd; + return __cd(__cd(__d).count() % __s); + } + + template + constexpr typename common_type, + duration<_Rep2, _Period2>>::type + operator%(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __cd; + return __cd(__cd(__lhs).count() % __cd(__rhs).count()); + } + /// @} + + // comparisons + + /** @{ + * Comparisons for chrono::duration + * @relates std::chrono::duration + */ + + template + constexpr bool + operator==(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __ct; + return __ct(__lhs).count() == __ct(__rhs).count(); + } + + template + constexpr bool + operator<(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<__dur1,__dur2>::type __ct; + return __ct(__lhs).count() < __ct(__rhs).count(); + } + +#if __cpp_lib_three_way_comparison + template + requires three_way_comparable> + constexpr auto + operator<=>(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + using __ct = common_type_t, + duration<_Rep2, _Period2>>; + return __ct(__lhs).count() <=> __ct(__rhs).count(); + } +#else + template + constexpr bool + operator!=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__lhs == __rhs); } +#endif + + template + constexpr bool + operator<=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__rhs < __lhs); } + + template + constexpr bool + operator>(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return __rhs < __lhs; } + + template + constexpr bool + operator>=(const duration<_Rep1, _Period1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { return !(__lhs < __rhs); } + + /// @} + + /// @cond undocumented +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +# define _GLIBCXX_CHRONO_INT64_T int64_t +#elif defined __INT64_TYPE__ +# define _GLIBCXX_CHRONO_INT64_T __INT64_TYPE__ +#else + static_assert(std::numeric_limits::digits >= 64, + "Representation type for nanoseconds must have at least 64 bits"); +# define _GLIBCXX_CHRONO_INT64_T long long +#endif + /// @endcond + + /// nanoseconds + using nanoseconds = duration<_GLIBCXX_CHRONO_INT64_T, nano>; + + /// microseconds + using microseconds = duration<_GLIBCXX_CHRONO_INT64_T, micro>; + + /// milliseconds + using milliseconds = duration<_GLIBCXX_CHRONO_INT64_T, milli>; + + /// seconds + using seconds = duration<_GLIBCXX_CHRONO_INT64_T>; + + /// minutes + using minutes = duration<_GLIBCXX_CHRONO_INT64_T, ratio< 60>>; + + /// hours + using hours = duration<_GLIBCXX_CHRONO_INT64_T, ratio<3600>>; + +#if __cplusplus > 201703L + /// days + using days = duration<_GLIBCXX_CHRONO_INT64_T, ratio<86400>>; + + /// weeks + using weeks = duration<_GLIBCXX_CHRONO_INT64_T, ratio<604800>>; + + /// years + using years = duration<_GLIBCXX_CHRONO_INT64_T, ratio<31556952>>; + + /// months + using months = duration<_GLIBCXX_CHRONO_INT64_T, ratio<2629746>>; +#endif // C++20 + +#undef _GLIBCXX_CHRONO_INT64_T + + template + struct time_point + { + static_assert(__is_duration<_Dur>::value, + "duration must be a specialization of std::chrono::duration"); + + typedef _Clock clock; + typedef _Dur duration; + typedef typename duration::rep rep; + typedef typename duration::period period; + + constexpr time_point() : __d(duration::zero()) + { } + + constexpr explicit time_point(const duration& __dur) + : __d(__dur) + { } + + // conversions + template>> + constexpr time_point(const time_point& __t) + : __d(__t.time_since_epoch()) + { } + + // observer + constexpr duration + time_since_epoch() const + { return __d; } + +#if __cplusplus > 201703L + constexpr time_point& + operator++() + { + ++__d; + return *this; + } + + constexpr time_point + operator++(int) + { return time_point{__d++}; } + + constexpr time_point& + operator--() + { + --__d; + return *this; + } + + constexpr time_point + operator--(int) + { return time_point{__d--}; } +#endif + + // arithmetic + _GLIBCXX17_CONSTEXPR time_point& + operator+=(const duration& __dur) + { + __d += __dur; + return *this; + } + + _GLIBCXX17_CONSTEXPR time_point& + operator-=(const duration& __dur) + { + __d -= __dur; + return *this; + } + + // special values + static constexpr time_point + min() noexcept + { return time_point(duration::min()); } + + static constexpr time_point + max() noexcept + { return time_point(duration::max()); } + + private: + duration __d; + }; + + /// time_point_cast + template + constexpr typename enable_if<__is_duration<_ToDur>::value, + time_point<_Clock, _ToDur>>::type + time_point_cast(const time_point<_Clock, _Dur>& __t) + { + typedef time_point<_Clock, _ToDur> __time_point; + return __time_point(duration_cast<_ToDur>(__t.time_since_epoch())); + } + +#if __cplusplus > 201402L + template + constexpr + enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>> + floor(const time_point<_Clock, _Dur>& __tp) + { + return time_point<_Clock, _ToDur>{ + chrono::floor<_ToDur>(__tp.time_since_epoch())}; + } + + template + constexpr + enable_if_t<__is_duration<_ToDur>::value, time_point<_Clock, _ToDur>> + ceil(const time_point<_Clock, _Dur>& __tp) + { + return time_point<_Clock, _ToDur>{ + chrono::ceil<_ToDur>(__tp.time_since_epoch())}; + } + + template + constexpr enable_if_t< + __and_<__is_duration<_ToDur>, + __not_>>::value, + time_point<_Clock, _ToDur>> + round(const time_point<_Clock, _Dur>& __tp) + { + return time_point<_Clock, _ToDur>{ + chrono::round<_ToDur>(__tp.time_since_epoch())}; + } +#endif // C++17 + + /// @{ + /// @relates time_point + + /// Adjust a time point forwards by the given duration. + template + constexpr time_point<_Clock, + typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> + operator+(const time_point<_Clock, _Dur1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<_Dur1,__dur2>::type __ct; + typedef time_point<_Clock, __ct> __time_point; + return __time_point(__lhs.time_since_epoch() + __rhs); + } + + /// Adjust a time point forwards by the given duration. + template + constexpr time_point<_Clock, + typename common_type, _Dur2>::type> + operator+(const duration<_Rep1, _Period1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { + typedef duration<_Rep1, _Period1> __dur1; + typedef typename common_type<__dur1,_Dur2>::type __ct; + typedef time_point<_Clock, __ct> __time_point; + return __time_point(__rhs.time_since_epoch() + __lhs); + } + + /// Adjust a time point backwards by the given duration. + template + constexpr time_point<_Clock, + typename common_type<_Dur1, duration<_Rep2, _Period2>>::type> + operator-(const time_point<_Clock, _Dur1>& __lhs, + const duration<_Rep2, _Period2>& __rhs) + { + typedef duration<_Rep2, _Period2> __dur2; + typedef typename common_type<_Dur1,__dur2>::type __ct; + typedef time_point<_Clock, __ct> __time_point; + return __time_point(__lhs.time_since_epoch() -__rhs); + } + + /// The difference between two time points (as a duration) + template + constexpr typename common_type<_Dur1, _Dur2>::type + operator-(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); } + /// @} + + /** @{ + * Comparisons for time_point + * @relates chrono::time_point + */ + + template + constexpr bool + operator==(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); } + +#if __cpp_lib_three_way_comparison + template _Dur2> + constexpr auto + operator<=>(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() <=> __rhs.time_since_epoch(); } +#else + template + constexpr bool + operator!=(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return !(__lhs == __rhs); } +#endif + + template + constexpr bool + operator<(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); } + + template + constexpr bool + operator<=(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return !(__rhs < __lhs); } + + template + constexpr bool + operator>(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return __rhs < __lhs; } + + template + constexpr bool + operator>=(const time_point<_Clock, _Dur1>& __lhs, + const time_point<_Clock, _Dur2>& __rhs) + { return !(__lhs < __rhs); } + + /// @} + + // Clocks. + + // Why nanosecond resolution as the default? + // Why have std::system_clock always count in the highest + // resolution (ie nanoseconds), even if on some OSes the low 3 + // or 9 decimal digits will be always zero? This allows later + // implementations to change the system_clock::now() + // implementation any time to provide better resolution without + // changing function signature or units. + + // To support the (forward) evolution of the library's defined + // clocks, wrap inside inline namespace so that the current + // defintions of system_clock, steady_clock, and + // high_resolution_clock types are uniquely mangled. This way, new + // code can use the latests clocks, while the library can contain + // compatibility definitions for previous versions. At some + // point, when these clocks settle down, the inlined namespaces + // can be removed. XXX GLIBCXX_ABI Deprecated + inline namespace _V2 { + + /** + * @brief System clock. + * + * Time returned represents wall time from the system-wide clock. + * @ingroup chrono + */ + struct system_clock + { + typedef chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point time_point; + + static_assert(system_clock::duration::min() + < system_clock::duration::zero(), + "a clock's minimum duration cannot be less than its epoch"); + + static constexpr bool is_steady = false; + + static time_point + now() noexcept; + + // Map to C API + static std::time_t + to_time_t(const time_point& __t) noexcept + { + return std::time_t(duration_cast + (__t.time_since_epoch()).count()); + } + + static time_point + from_time_t(std::time_t __t) noexcept + { + typedef chrono::time_point __from; + return time_point_cast + (__from(chrono::seconds(__t))); + } + }; + + + /** + * @brief Monotonic clock + * + * Time returned has the property of only increasing at a uniform rate. + * @ingroup chrono + */ + struct steady_clock + { + typedef chrono::nanoseconds duration; + typedef duration::rep rep; + typedef duration::period period; + typedef chrono::time_point time_point; + + static constexpr bool is_steady = true; + + static time_point + now() noexcept; + }; + + + /** + * @brief Highest-resolution clock + * + * This is the clock "with the shortest tick period." Alias to + * std::system_clock until higher-than-nanosecond definitions + * become feasible. + * @ingroup chrono + */ + using high_resolution_clock = system_clock; + + } // end inline namespace _V2 + +#if __cplusplus > 201703L + template + using sys_time = time_point; + using sys_seconds = sys_time; + using sys_days = sys_time; + + using file_clock = ::std::filesystem::__file_clock; + + template + using file_time = time_point; + + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + + struct local_t { }; + template + using local_time = time_point; + using local_seconds = local_time; + using local_days = local_time; + + class utc_clock; + class tai_clock; + class gps_clock; + + template + using utc_time = time_point; + using utc_seconds = utc_time; + + template + using tai_time = time_point; + using tai_seconds = tai_time; + + template + using gps_time = time_point; + using gps_seconds = gps_time; + + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + template<> struct is_clock : true_type { }; + + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + template<> inline constexpr bool is_clock_v = true; + + struct leap_second_info + { + bool is_leap_second; + seconds elapsed; + }; + + // CALENDRICAL TYPES + + // CLASS DECLARATIONS + class day; + class month; + class year; + class weekday; + class weekday_indexed; + class weekday_last; + class month_day; + class month_day_last; + class month_weekday; + class month_weekday_last; + class year_month; + class year_month_day; + class year_month_day_last; + class year_month_weekday; + class year_month_weekday_last; + + struct last_spec + { + explicit last_spec() = default; + + friend constexpr month_day_last + operator/(int __m, last_spec) noexcept; + + friend constexpr month_day_last + operator/(last_spec, int __m) noexcept; + }; + + inline constexpr last_spec last{}; + + namespace __detail + { + // Compute the remainder of the Euclidean division of __n divided by __d. + // Euclidean division truncates toward negative infinity and always + // produces a remainder in the range of [0,__d-1] (whereas standard + // division truncates toward zero and yields a nonpositive remainder + // for negative __n). + constexpr unsigned + __modulo(long long __n, unsigned __d) + { + if (__n >= 0) + return __n % __d; + else + return (__d + (__n % __d)) % __d; + } + + inline constexpr unsigned __days_per_month[12] + = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + } + + // DAY + + class day + { + private: + unsigned char _M_d; + + public: + day() = default; + + explicit constexpr + day(unsigned __d) noexcept + : _M_d(__d) + { } + + constexpr day& + operator++() noexcept + { + ++_M_d; + return *this; + } + + constexpr day + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr day& + operator--() noexcept + { + --_M_d; + return *this; + } + + constexpr day + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr day& + operator+=(const days& __d) noexcept + { + *this = *this + __d; + return *this; + } + + constexpr day& + operator-=(const days& __d) noexcept + { + *this = *this - __d; + return *this; + } + + constexpr explicit + operator unsigned() const noexcept + { return _M_d; } + + constexpr bool + ok() const noexcept + { return 1 <= _M_d && _M_d <= 31; } + + friend constexpr bool + operator==(const day& __x, const day& __y) noexcept + { return unsigned{__x} == unsigned{__y}; } + + friend constexpr strong_ordering + operator<=>(const day& __x, const day& __y) noexcept + { return unsigned{__x} <=> unsigned{__y}; } + + friend constexpr day + operator+(const day& __x, const days& __y) noexcept + { return day(unsigned{__x} + __y.count()); } + + friend constexpr day + operator+(const days& __x, const day& __y) noexcept + { return __y + __x; } + + friend constexpr day + operator-(const day& __x, const days& __y) noexcept + { return __x + -__y; } + + friend constexpr days + operator-(const day& __x, const day& __y) noexcept + { return days{int(unsigned{__x}) - int(unsigned{__y})}; } + + friend constexpr month_day + operator/(const month& __m, const day& __d) noexcept; + + friend constexpr month_day + operator/(int __m, const day& __d) noexcept; + + friend constexpr month_day + operator/(const day& __d, const month& __m) noexcept; + + friend constexpr month_day + operator/(const day& __d, int __m) noexcept; + + friend constexpr year_month_day + operator/(const year_month& __ym, const day& __d) noexcept; + + // TODO: Implement operator<<, to_stream, from_stream. + }; + + // MONTH + + class month + { + private: + unsigned char _M_m; + + public: + month() = default; + + explicit constexpr + month(unsigned __m) noexcept + : _M_m(__m) + { } + + constexpr month& + operator++() noexcept + { + *this += months{1}; + return *this; + } + + constexpr month + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr month& + operator--() noexcept + { + *this -= months{1}; + return *this; + } + + constexpr month + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr month& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + constexpr month& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + explicit constexpr + operator unsigned() const noexcept + { return _M_m; } + + constexpr bool + ok() const noexcept + { return 1 <= _M_m && _M_m <= 12; } + + friend constexpr bool + operator==(const month& __x, const month& __y) noexcept + { return unsigned{__x} == unsigned{__y}; } + + friend constexpr strong_ordering + operator<=>(const month& __x, const month& __y) noexcept + { return unsigned{__x} <=> unsigned{__y}; } + + friend constexpr month + operator+(const month& __x, const months& __y) noexcept + { + auto __n = static_cast(unsigned{__x}) + (__y.count() - 1); + return month{__detail::__modulo(__n, 12) + 1}; + } + + friend constexpr month + operator+(const months& __x, const month& __y) noexcept + { return __y + __x; } + + friend constexpr month + operator-(const month& __x, const months& __y) noexcept + { return __x + -__y; } + + friend constexpr months + operator-(const month& __x, const month& __y) noexcept + { + const auto __dm = int(unsigned(__x)) - int(unsigned(__y)); + return months{__dm < 0 ? 12 + __dm : __dm}; + } + + friend constexpr year_month + operator/(const year& __y, const month& __m) noexcept; + + friend constexpr month_day + operator/(const month& __m, int __d) noexcept; + + friend constexpr month_day_last + operator/(const month& __m, last_spec) noexcept; + + friend constexpr month_day_last + operator/(last_spec, const month& __m) noexcept; + + friend constexpr month_weekday + operator/(const month& __m, const weekday_indexed& __wdi) noexcept; + + friend constexpr month_weekday + operator/(const weekday_indexed& __wdi, const month& __m) noexcept; + + friend constexpr month_weekday_last + operator/(const month& __m, const weekday_last& __wdl) noexcept; + + friend constexpr month_weekday_last + operator/(const weekday_last& __wdl, const month& __m) noexcept; + + // TODO: Implement operator<<, to_stream, from_stream. + }; + + inline constexpr month January{1}; + inline constexpr month February{2}; + inline constexpr month March{3}; + inline constexpr month April{4}; + inline constexpr month May{5}; + inline constexpr month June{6}; + inline constexpr month July{7}; + inline constexpr month August{8}; + inline constexpr month September{9}; + inline constexpr month October{10}; + inline constexpr month November{11}; + inline constexpr month December{12}; + + // YEAR + + class year + { + private: + short _M_y; + + public: + year() = default; + + explicit constexpr + year(int __y) noexcept + : _M_y{static_cast(__y)} + { } + + static constexpr year + min() noexcept + { return year{-32767}; } + + static constexpr year + max() noexcept + { return year{32767}; } + + constexpr year& + operator++() noexcept + { + ++_M_y; + return *this; + } + + constexpr year + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr year& + operator--() noexcept + { + --_M_y; + return *this; + } + + constexpr year + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr year& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr year + operator+() const noexcept + { return *this; } + + constexpr year + operator-() const noexcept + { return year{-_M_y}; } + + constexpr bool + is_leap() const noexcept + { + // Testing divisibility by 100 first gives better performance, that is, + // return (_M_y % 100 != 0 || _M_y % 400 == 0) && _M_y % 4 == 0; + + // It gets even faster if _M_y is in [-536870800, 536870999] + // (which is the case here) and _M_y % 100 is replaced by + // __is_multiple_of_100 below. + + // References: + // [1] https://github.com/cassioneri/calendar + // [2] https://accu.org/journals/overload/28/155/overload155.pdf#page=16 + + constexpr uint32_t __multiplier = 42949673; + constexpr uint32_t __bound = 42949669; + constexpr uint32_t __max_dividend = 1073741799; + constexpr uint32_t __offset = __max_dividend / 2 / 100 * 100; + const bool __is_multiple_of_100 + = __multiplier * (_M_y + __offset) < __bound; + return (!__is_multiple_of_100 || _M_y % 400 == 0) && _M_y % 4 == 0; + } + + explicit constexpr + operator int() const noexcept + { return _M_y; } + + constexpr bool + ok() const noexcept + { return min()._M_y <= _M_y && _M_y <= max()._M_y; } + + friend constexpr bool + operator==(const year& __x, const year& __y) noexcept + { return int{__x} == int{__y}; } + + friend constexpr strong_ordering + operator<=>(const year& __x, const year& __y) noexcept + { return int{__x} <=> int{__y}; } + + friend constexpr year + operator+(const year& __x, const years& __y) noexcept + { return year{int{__x} + static_cast(__y.count())}; } + + friend constexpr year + operator+(const years& __x, const year& __y) noexcept + { return __y + __x; } + + friend constexpr year + operator-(const year& __x, const years& __y) noexcept + { return __x + -__y; } + + friend constexpr years + operator-(const year& __x, const year& __y) noexcept + { return years{int{__x} - int{__y}}; } + + friend constexpr year_month + operator/(const year& __y, int __m) noexcept; + + friend constexpr year_month_day + operator/(const year& __y, const month_day& __md) noexcept; + + friend constexpr year_month_day + operator/(const month_day& __md, const year& __y) noexcept; + + friend constexpr year_month_day_last + operator/(const year& __y, const month_day_last& __mdl) noexcept; + + friend constexpr year_month_day_last + operator/(const month_day_last& __mdl, const year& __y) noexcept; + + friend constexpr year_month_weekday + operator/(const year& __y, const month_weekday& __mwd) noexcept; + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, const year& __y) noexcept; + + friend constexpr year_month_weekday_last + operator/(const year& __y, const month_weekday_last& __mwdl) noexcept; + + friend constexpr year_month_weekday_last + operator/(const month_weekday_last& __mwdl, const year& __y) noexcept; + + // TODO: Implement operator<<, to_stream, from_stream. + }; + + // WEEKDAY + + class weekday + { + private: + unsigned char _M_wd; + + static constexpr weekday + _S_from_days(const days& __d) + { + auto __n = __d.count(); + return weekday(__n >= -4 ? (__n + 4) % 7 : (__n + 5) % 7 + 6); + } + + public: + weekday() = default; + + explicit constexpr + weekday(unsigned __wd) noexcept + : _M_wd(__wd == 7 ? 0 : __wd) // __wd % 7 ? + { } + + constexpr + weekday(const sys_days& __dp) noexcept + : weekday{_S_from_days(__dp.time_since_epoch())} + { } + + explicit constexpr + weekday(const local_days& __dp) noexcept + : weekday{sys_days{__dp.time_since_epoch()}} + { } + + constexpr weekday& + operator++() noexcept + { + *this += days{1}; + return *this; + } + + constexpr weekday + operator++(int) noexcept + { + auto __ret = *this; + ++(*this); + return __ret; + } + + constexpr weekday& + operator--() noexcept + { + *this -= days{1}; + return *this; + } + + constexpr weekday + operator--(int) noexcept + { + auto __ret = *this; + --(*this); + return __ret; + } + + constexpr weekday& + operator+=(const days& __d) noexcept + { + *this = *this + __d; + return *this; + } + + constexpr weekday& + operator-=(const days& __d) noexcept + { + *this = *this - __d; + return *this; + } + + constexpr unsigned + c_encoding() const noexcept + { return _M_wd; } + + constexpr unsigned + iso_encoding() const noexcept + { return _M_wd == 0u ? 7u : _M_wd; } + + constexpr bool + ok() const noexcept + { return _M_wd <= 6; } + + constexpr weekday_indexed + operator[](unsigned __index) const noexcept; + + constexpr weekday_last + operator[](last_spec) const noexcept; + + friend constexpr bool + operator==(const weekday& __x, const weekday& __y) noexcept + { return __x._M_wd == __y._M_wd; } + + friend constexpr weekday + operator+(const weekday& __x, const days& __y) noexcept + { + auto __n = static_cast(__x._M_wd) + __y.count(); + return weekday{__detail::__modulo(__n, 7)}; + } + + friend constexpr weekday + operator+(const days& __x, const weekday& __y) noexcept + { return __y + __x; } + + friend constexpr weekday + operator-(const weekday& __x, const days& __y) noexcept + { return __x + -__y; } + + friend constexpr days + operator-(const weekday& __x, const weekday& __y) noexcept + { + auto __n = static_cast(__x._M_wd) - __y._M_wd; + return days{__detail::__modulo(__n, 7)}; + } + + // TODO: operator<<, from_stream. + }; + + inline constexpr weekday Sunday{0}; + inline constexpr weekday Monday{1}; + inline constexpr weekday Tuesday{2}; + inline constexpr weekday Wednesday{3}; + inline constexpr weekday Thursday{4}; + inline constexpr weekday Friday{5}; + inline constexpr weekday Saturday{6}; + + // WEEKDAY_INDEXED + + class weekday_indexed + { + private: + chrono::weekday _M_wd; + unsigned char _M_index; + + public: + weekday_indexed() = default; + + constexpr + weekday_indexed(const chrono::weekday& __wd, unsigned __index) noexcept + : _M_wd(__wd), _M_index(__index) + { } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wd; } + + constexpr unsigned + index() const noexcept + { return _M_index; }; + + constexpr bool + ok() const noexcept + { return _M_wd.ok() && 1 <= _M_index && _M_index <= 5; } + + friend constexpr bool + operator==(const weekday_indexed& __x, const weekday_indexed& __y) noexcept + { return __x.weekday() == __y.weekday() && __x.index() == __y.index(); } + + friend constexpr month_weekday + operator/(const month& __m, const weekday_indexed& __wdi) noexcept; + + friend constexpr month_weekday + operator/(int __m, const weekday_indexed& __wdi) noexcept; + + friend constexpr month_weekday + operator/(const weekday_indexed& __wdi, const month& __m) noexcept; + + friend constexpr month_weekday + operator/(const weekday_indexed& __wdi, int __m) noexcept; + + friend constexpr year_month_weekday + operator/(const year_month& __ym, const weekday_indexed& __wdi) noexcept; + + // TODO: Implement operator<<. + }; + + constexpr weekday_indexed + weekday::operator[](unsigned __index) const noexcept + { return {*this, __index}; } + + // WEEKDAY_LAST + + class weekday_last + { + private: + chrono::weekday _M_wd; + + public: + explicit constexpr + weekday_last(const chrono::weekday& __wd) noexcept + : _M_wd{__wd} + { } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wd; } + + constexpr bool + ok() const noexcept + { return _M_wd.ok(); } + + friend constexpr bool + operator==(const weekday_last& __x, const weekday_last& __y) noexcept + { return __x.weekday() == __y.weekday(); } + + friend constexpr month_weekday_last + operator/(int __m, const weekday_last& __wdl) noexcept; + + friend constexpr month_weekday_last + operator/(const weekday_last& __wdl, int __m) noexcept; + + friend constexpr year_month_weekday_last + operator/(const year_month& __ym, const weekday_last& __wdl) noexcept; + + // TODO: Implement operator<<. + }; + + constexpr weekday_last + weekday::operator[](last_spec) const noexcept + { return weekday_last{*this}; } + + // MONTH_DAY + + class month_day + { + private: + chrono::month _M_m; + chrono::day _M_d; + + public: + month_day() = default; + + constexpr + month_day(const chrono::month& __m, const chrono::day& __d) noexcept + : _M_m{__m}, _M_d{__d} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::day + day() const noexcept + { return _M_d; } + + constexpr bool + ok() const noexcept + { + return _M_m.ok() + && 1u <= unsigned(_M_d) + && unsigned(_M_d) <= __detail::__days_per_month[unsigned(_M_m) - 1]; + } + + friend constexpr bool + operator==(const month_day& __x, const month_day& __y) noexcept + { return __x.month() == __y.month() && __x.day() == __y.day(); } + + friend constexpr strong_ordering + operator<=>(const month_day& __x, const month_day& __y) noexcept + = default; + + friend constexpr month_day + operator/(const chrono::month& __m, const chrono::day& __d) noexcept + { return {__m, __d}; } + + friend constexpr month_day + operator/(const chrono::month& __m, int __d) noexcept + { return {__m, chrono::day(unsigned(__d))}; } + + friend constexpr month_day + operator/(int __m, const chrono::day& __d) noexcept + { return {chrono::month(unsigned(__m)), __d}; } + + friend constexpr month_day + operator/(const chrono::day& __d, const chrono::month& __m) noexcept + { return {__m, __d}; } + + friend constexpr month_day + operator/(const chrono::day& __d, int __m) noexcept + { return {chrono::month(unsigned(__m)), __d}; } + + friend constexpr year_month_day + operator/(int __y, const month_day& __md) noexcept; + + friend constexpr year_month_day + operator/(const month_day& __md, int __y) noexcept; + + // TODO: Implement operator<<, from_stream. + }; + + // MONTH_DAY_LAST + + class month_day_last + { + private: + chrono::month _M_m; + + public: + explicit constexpr + month_day_last(const chrono::month& __m) noexcept + : _M_m{__m} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr bool + ok() const noexcept + { return _M_m.ok(); } + + friend constexpr bool + operator==(const month_day_last& __x, const month_day_last& __y) noexcept + { return __x.month() == __y.month(); } + + friend constexpr strong_ordering + operator<=>(const month_day_last& __x, const month_day_last& __y) noexcept + = default; + + friend constexpr month_day_last + operator/(const chrono::month& __m, last_spec) noexcept + { return month_day_last{__m}; } + + friend constexpr month_day_last + operator/(int __m, last_spec) noexcept + { return chrono::month(unsigned(__m)) / last; } + + friend constexpr month_day_last + operator/(last_spec, const chrono::month& __m) noexcept + { return __m / last; } + + friend constexpr month_day_last + operator/(last_spec, int __m) noexcept + { return __m / last; } + + friend constexpr year_month_day_last + operator/(int __y, const month_day_last& __mdl) noexcept; + + friend constexpr year_month_day_last + operator/(const month_day_last& __mdl, int __y) noexcept; + + // TODO: Implement operator<<. + }; + + // MONTH_WEEKDAY + + class month_weekday + { + private: + chrono::month _M_m; + chrono::weekday_indexed _M_wdi; + + public: + constexpr + month_weekday(const chrono::month& __m, + const chrono::weekday_indexed& __wdi) noexcept + : _M_m{__m}, _M_wdi{__wdi} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday_indexed + weekday_indexed() const noexcept + { return _M_wdi; } + + constexpr bool + ok() const noexcept + { return _M_m.ok() && _M_wdi.ok(); } + + friend constexpr bool + operator==(const month_weekday& __x, const month_weekday& __y) noexcept + { + return __x.month() == __y.month() + && __x.weekday_indexed() == __y.weekday_indexed(); + } + + friend constexpr month_weekday + operator/(const chrono::month& __m, + const chrono::weekday_indexed& __wdi) noexcept + { return {__m, __wdi}; } + + friend constexpr month_weekday + operator/(int __m, const chrono::weekday_indexed& __wdi) noexcept + { return chrono::month(unsigned(__m)) / __wdi; } + + friend constexpr month_weekday + operator/(const chrono::weekday_indexed& __wdi, + const chrono::month& __m) noexcept + { return __m / __wdi; } + + friend constexpr month_weekday + operator/(const chrono::weekday_indexed& __wdi, int __m) noexcept + { return __m / __wdi; } + + friend constexpr year_month_weekday + operator/(int __y, const month_weekday& __mwd) noexcept; + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, int __y) noexcept; + + // TODO: Implement operator<<. + }; + + // MONTH_WEEKDAY_LAST + + class month_weekday_last + { + private: + chrono::month _M_m; + chrono::weekday_last _M_wdl; + + public: + constexpr + month_weekday_last(const chrono::month& __m, + const chrono::weekday_last& __wdl) noexcept + :_M_m{__m}, _M_wdl{__wdl} + { } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday_last + weekday_last() const noexcept + { return _M_wdl; } + + constexpr bool + ok() const noexcept + { return _M_m.ok() && _M_wdl.ok(); } + + friend constexpr bool + operator==(const month_weekday_last& __x, + const month_weekday_last& __y) noexcept + { + return __x.month() == __y.month() + && __x.weekday_last() == __y.weekday_last(); + } + + friend constexpr month_weekday_last + operator/(const chrono::month& __m, + const chrono::weekday_last& __wdl) noexcept + { return {__m, __wdl}; } + + friend constexpr month_weekday_last + operator/(int __m, const chrono::weekday_last& __wdl) noexcept + { return chrono::month(unsigned(__m)) / __wdl; } + + friend constexpr month_weekday_last + operator/(const chrono::weekday_last& __wdl, + const chrono::month& __m) noexcept + { return __m / __wdl; } + + friend constexpr month_weekday_last + operator/(const chrono::weekday_last& __wdl, int __m) noexcept + { return chrono::month(unsigned(__m)) / __wdl; } + + friend constexpr year_month_weekday_last + operator/(int __y, const month_weekday_last& __mwdl) noexcept; + + friend constexpr year_month_weekday_last + operator/(const month_weekday_last& __mwdl, int __y) noexcept; + + // TODO: Implement operator<<. + }; + + // YEAR_MONTH + + namespace __detail + { + // [time.cal.ym], [time.cal.ymd], etc constrain the 'months'-based + // addition/subtraction operator overloads like so: + // + // Constraints: if the argument supplied by the caller for the months + // parameter is convertible to years, its implicit conversion sequence + // to years is worse than its implicit conversion sequence to months. + // + // We realize this constraint by templatizing the 'months'-based + // overloads (using a dummy defaulted template parameter), so that + // overload resolution doesn't select the 'months'-based overload unless + // the implicit conversion sequence to 'months' is better than that to + // 'years'. + using __months_years_conversion_disambiguator = void; + } + + class year_month + { + private: + chrono::year _M_y; + chrono::month _M_m; + + public: + year_month() = default; + + constexpr + year_month(const chrono::year& __y, const chrono::month& __m) noexcept + : _M_y{__y}, _M_m{__m} + { } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + template + constexpr year_month& + operator+=(const months& __dm) noexcept + { + *this = *this + __dm; + return *this; + } + + template + constexpr year_month& + operator-=(const months& __dm) noexcept + { + *this = *this - __dm; + return *this; + } + + constexpr year_month& + operator+=(const years& __dy) noexcept + { + *this = *this + __dy; + return *this; + } + + constexpr year_month& + operator-=(const years& __dy) noexcept + { + *this = *this - __dy; + return *this; + } + + constexpr bool + ok() const noexcept + { return _M_y.ok() && _M_m.ok(); } + + friend constexpr bool + operator==(const year_month& __x, const year_month& __y) noexcept + { return __x.year() == __y.year() && __x.month() == __y.month(); } + + friend constexpr strong_ordering + operator<=>(const year_month& __x, const year_month& __y) noexcept + = default; + + template + friend constexpr year_month + operator+(const year_month& __ym, const months& __dm) noexcept + { + // TODO: Optimize? + auto __m = __ym.month() + __dm; + auto __i = int(unsigned(__ym.month())) - 1 + __dm.count(); + auto __y = (__i < 0 + ? __ym.year() + years{(__i - 11) / 12} + : __ym.year() + years{__i / 12}); + return __y / __m; + } + + template + friend constexpr year_month + operator+(const months& __dm, const year_month& __ym) noexcept + { return __ym + __dm; } + + template + friend constexpr year_month + operator-(const year_month& __ym, const months& __dm) noexcept + { return __ym + -__dm; } + + friend constexpr months + operator-(const year_month& __x, const year_month& __y) noexcept + { + return (__x.year() - __y.year() + + months{static_cast(unsigned{__x.month()}) + - static_cast(unsigned{__y.month()})}); + } + + friend constexpr year_month + operator+(const year_month& __ym, const years& __dy) noexcept + { return (__ym.year() + __dy) / __ym.month(); } + + friend constexpr year_month + operator+(const years& __dy, const year_month& __ym) noexcept + { return __ym + __dy; } + + friend constexpr year_month + operator-(const year_month& __ym, const years& __dy) noexcept + { return __ym + -__dy; } + + friend constexpr year_month + operator/(const chrono::year& __y, const chrono::month& __m) noexcept + { return {__y, __m}; } + + friend constexpr year_month + operator/(const chrono::year& __y, int __m) noexcept + { return {__y, chrono::month(unsigned(__m))}; } + + friend constexpr year_month_day + operator/(const year_month& __ym, int __d) noexcept; + + friend constexpr year_month_day_last + operator/(const year_month& __ym, last_spec) noexcept; + + // TODO: Implement operator<<, from_stream. + }; + + // YEAR_MONTH_DAY + + class year_month_day + { + private: + chrono::year _M_y; + chrono::month _M_m; + chrono::day _M_d; + + static constexpr year_month_day _S_from_days(const days& __dp) noexcept; + + constexpr days _M_days_since_epoch() const noexcept; + + public: + year_month_day() = default; + + constexpr + year_month_day(const chrono::year& __y, const chrono::month& __m, + const chrono::day& __d) noexcept + : _M_y{__y}, _M_m{__m}, _M_d{__d} + { } + + constexpr + year_month_day(const year_month_day_last& __ymdl) noexcept; + + constexpr + year_month_day(const sys_days& __dp) noexcept + : year_month_day(_S_from_days(__dp.time_since_epoch())) + { } + + explicit constexpr + year_month_day(const local_days& __dp) noexcept + : year_month_day(sys_days{__dp.time_since_epoch()}) + { } + + template + constexpr year_month_day& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_day& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_day& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_day& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::day + day() const noexcept + { return _M_d; } + + constexpr + operator sys_days() const noexcept + { return sys_days{_M_days_since_epoch()}; } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool ok() const noexcept; + + friend constexpr bool + operator==(const year_month_day& __x, const year_month_day& __y) noexcept + { + return __x.year() == __y.year() + && __x.month() == __y.month() + && __x.day() == __y.day(); + } + + friend constexpr strong_ordering + operator<=>(const year_month_day& __x, const year_month_day& __y) noexcept + = default; + + template + friend constexpr year_month_day + operator+(const year_month_day& __ymd, const months& __dm) noexcept + { return (__ymd.year() / __ymd.month() + __dm) / __ymd.day(); } + + template + friend constexpr year_month_day + operator+(const months& __dm, const year_month_day& __ymd) noexcept + { return __ymd + __dm; } + + friend constexpr year_month_day + operator+(const year_month_day& __ymd, const years& __dy) noexcept + { return (__ymd.year() + __dy) / __ymd.month() / __ymd.day(); } + + friend constexpr year_month_day + operator+(const years& __dy, const year_month_day& __ymd) noexcept + { return __ymd + __dy; } + + template + friend constexpr year_month_day + operator-(const year_month_day& __ymd, const months& __dm) noexcept + { return __ymd + -__dm; } + + friend constexpr year_month_day + operator-(const year_month_day& __ymd, const years& __dy) noexcept + { return __ymd + -__dy; } + + friend constexpr year_month_day + operator/(const year_month& __ym, const chrono::day& __d) noexcept + { return {__ym.year(), __ym.month(), __d}; } + + friend constexpr year_month_day + operator/(const year_month& __ym, int __d) noexcept + { return __ym / chrono::day{unsigned(__d)}; } + + friend constexpr year_month_day + operator/(const chrono::year& __y, const month_day& __md) noexcept + { return __y / __md.month() / __md.day(); } + + friend constexpr year_month_day + operator/(int __y, const month_day& __md) noexcept + { return chrono::year{__y} / __md; } + + friend constexpr year_month_day + operator/(const month_day& __md, const chrono::year& __y) noexcept + { return __y / __md; } + + friend constexpr year_month_day + operator/(const month_day& __md, int __y) noexcept + { return chrono::year(__y) / __md; } + + // TODO: Implement operator<<, from_stream. + }; + + // Construct from days since 1970/01/01. + // Proposition 6.3 of Neri and Schneider, + // "Euclidean Affine Functions and Applications to Calendar Algorithms". + // https://arxiv.org/abs/2102.06959 + constexpr year_month_day + year_month_day::_S_from_days(const days& __dp) noexcept + { + constexpr auto __z2 = static_cast(-1468000); + constexpr auto __r2_e3 = static_cast(536895458); + + const auto __r0 = static_cast(__dp.count()) + __r2_e3; + + const auto __n1 = 4 * __r0 + 3; + const auto __q1 = __n1 / 146097; + const auto __r1 = __n1 % 146097 / 4; + + constexpr auto __p32 = static_cast(1) << 32; + const auto __n2 = 4 * __r1 + 3; + const auto __u2 = static_cast(2939745) * __n2; + const auto __q2 = static_cast(__u2 / __p32); + const auto __r2 = static_cast(__u2 % __p32) / 2939745 / 4; + + constexpr auto __p16 = static_cast(1) << 16; + const auto __n3 = 2141 * __r2 + 197913; + const auto __q3 = __n3 / __p16; + const auto __r3 = __n3 % __p16 / 2141; + + const auto __y0 = 100 * __q1 + __q2; + const auto __m0 = __q3; + const auto __d0 = __r3; + + const auto __j = __r2 >= 306; + const auto __y1 = __y0 + __j; + const auto __m1 = __j ? __m0 - 12 : __m0; + const auto __d1 = __d0 + 1; + + return year_month_day{chrono::year{static_cast(__y1 + __z2)}, + chrono::month{__m1}, chrono::day{__d1}}; + } + + // Days since 1970/01/01. + // Proposition 6.2 of Neri and Schneider, + // "Euclidean Affine Functions and Applications to Calendar Algorithms". + // https://arxiv.org/abs/2102.06959 + constexpr days + year_month_day::_M_days_since_epoch() const noexcept + { + auto constexpr __z2 = static_cast(-1468000); + auto constexpr __r2_e3 = static_cast(536895458); + + const auto __y1 = static_cast(static_cast(_M_y)) - __z2; + const auto __m1 = static_cast(static_cast(_M_m)); + const auto __d1 = static_cast(static_cast(_M_d)); + + const auto __j = static_cast(__m1 < 3); + const auto __y0 = __y1 - __j; + const auto __m0 = __j ? __m1 + 12 : __m1; + const auto __d0 = __d1 - 1; + + const auto __q1 = __y0 / 100; + const auto __yc = 1461 * __y0 / 4 - __q1 + __q1 / 4; + const auto __mc = (979 *__m0 - 2919) / 32; + const auto __dc = __d0; + + return days{static_cast(__yc + __mc + __dc - __r2_e3)}; + } + + // YEAR_MONTH_DAY_LAST + + class year_month_day_last + { + private: + chrono::year _M_y; + chrono::month_day_last _M_mdl; + + public: + constexpr + year_month_day_last(const chrono::year& __y, + const chrono::month_day_last& __mdl) noexcept + : _M_y{__y}, _M_mdl{__mdl} + { } + + template + constexpr year_month_day_last& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_day_last& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_day_last& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_day_last& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_mdl.month(); } + + constexpr chrono::month_day_last + month_day_last() const noexcept + { return _M_mdl; } + + // Return A day representing the last day of this year, month pair. + constexpr chrono::day + day() const noexcept + { + const auto __m = static_cast(month()); + + // Excluding February, the last day of month __m is either 30 or 31 or, + // in another words, it is 30 + b = 30 | b, where b is in {0, 1}. + + // If __m in {1, 3, 4, 5, 6, 7}, then b is 1 if, and only if __m is odd. + // Hence, b = __m & 1 = (__m ^ 0) & 1. + + // If __m in {8, 9, 10, 11, 12}, then b is 1 if, and only if __m is even. + // Hence, b = (__m ^ 1) & 1. + + // Therefore, b = (__m ^ c) & 1, where c = 0, if __m < 8, or c = 1 if + // __m >= 8, that is, c = __m >> 3. + + // The above mathematically justifies this implementation whose + // performance does not depend on look-up tables being on the L1 cache. + return chrono::day{__m != 2 ? ((__m ^ (__m >> 3)) & 1) | 30 + : _M_y.is_leap() ? 29 : 28}; + } + + constexpr + operator sys_days() const noexcept + { return sys_days{year() / month() / day()}; } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool + ok() const noexcept + { return _M_y.ok() && _M_mdl.ok(); } + + friend constexpr bool + operator==(const year_month_day_last& __x, + const year_month_day_last& __y) noexcept + { + return __x.year() == __y.year() + && __x.month_day_last() == __y.month_day_last(); + } + + friend constexpr strong_ordering + operator<=>(const year_month_day_last& __x, + const year_month_day_last& __y) noexcept + = default; + + template + friend constexpr year_month_day_last + operator+(const year_month_day_last& __ymdl, + const months& __dm) noexcept + { return (__ymdl.year() / __ymdl.month() + __dm) / last; } + + template + friend constexpr year_month_day_last + operator+(const months& __dm, + const year_month_day_last& __ymdl) noexcept + { return __ymdl + __dm; } + + template + friend constexpr year_month_day_last + operator-(const year_month_day_last& __ymdl, + const months& __dm) noexcept + { return __ymdl + -__dm; } + + friend constexpr year_month_day_last + operator+(const year_month_day_last& __ymdl, + const years& __dy) noexcept + { return {__ymdl.year() + __dy, __ymdl.month_day_last()}; } + + friend constexpr year_month_day_last + operator+(const years& __dy, + const year_month_day_last& __ymdl) noexcept + { return __ymdl + __dy; } + + friend constexpr year_month_day_last + operator-(const year_month_day_last& __ymdl, + const years& __dy) noexcept + { return __ymdl + -__dy; } + + friend constexpr year_month_day_last + operator/(const year_month& __ym, last_spec) noexcept + { return {__ym.year(), chrono::month_day_last{__ym.month()}}; } + + friend constexpr year_month_day_last + operator/(const chrono::year& __y, + const chrono::month_day_last& __mdl) noexcept + { return {__y, __mdl}; } + + friend constexpr year_month_day_last + operator/(int __y, const chrono::month_day_last& __mdl) noexcept + { return chrono::year(__y) / __mdl; } + + friend constexpr year_month_day_last + operator/(const chrono::month_day_last& __mdl, + const chrono::year& __y) noexcept + { return __y / __mdl; } + + friend constexpr year_month_day_last + operator/(const chrono::month_day_last& __mdl, int __y) noexcept + { return chrono::year(__y) / __mdl; } + + // TODO: Implement operator<<. + }; + + // year_month_day ctor from year_month_day_last + constexpr + year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept + : _M_y{__ymdl.year()}, _M_m{__ymdl.month()}, _M_d{__ymdl.day()} + { } + + constexpr bool + year_month_day::ok() const noexcept + { + if (!_M_y.ok() || !_M_m.ok()) + return false; + return chrono::day{1} <= _M_d && _M_d <= (_M_y / _M_m / last).day(); + } + + // YEAR_MONTH_WEEKDAY + + class year_month_weekday + { + private: + chrono::year _M_y; + chrono::month _M_m; + chrono::weekday_indexed _M_wdi; + + static constexpr year_month_weekday + _S_from_sys_days(const sys_days& __dp) + { + year_month_day __ymd{__dp}; + chrono::weekday __wd{__dp}; + auto __index = __wd[(unsigned{__ymd.day()} - 1) / 7 + 1]; + return {__ymd.year(), __ymd.month(), __index}; + } + + public: + year_month_weekday() = default; + + constexpr + year_month_weekday(const chrono::year& __y, const chrono::month& __m, + const chrono::weekday_indexed& __wdi) noexcept + : _M_y{__y}, _M_m{__m}, _M_wdi{__wdi} + { } + + constexpr + year_month_weekday(const sys_days& __dp) noexcept + : year_month_weekday{_S_from_sys_days(__dp)} + { } + + explicit constexpr + year_month_weekday(const local_days& __dp) noexcept + : year_month_weekday{sys_days{__dp.time_since_epoch()}} + { } + + template + constexpr year_month_weekday& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_weekday& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_weekday& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_weekday& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wdi.weekday(); } + + constexpr unsigned + index() const noexcept + { return _M_wdi.index(); } + + constexpr chrono::weekday_indexed + weekday_indexed() const noexcept + { return _M_wdi; } + + constexpr + operator sys_days() const noexcept + { + auto __d = sys_days{year() / month() / 1}; + return __d + (weekday() - chrono::weekday(__d) + + days{(static_cast(index())-1)*7}); + } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool + ok() const noexcept + { + if (!_M_y.ok() || !_M_m.ok() || !_M_wdi.ok()) + return false; + if (_M_wdi.index() <= 4) + return true; + days __d = (_M_wdi.weekday() + - chrono::weekday{sys_days{_M_y / _M_m / 1}} + + days((_M_wdi.index()-1)*7 + 1)); + __glibcxx_assert(__d.count() >= 1); + return __d.count() <= unsigned{(_M_y / _M_m / last).day()}; + } + + friend constexpr bool + operator==(const year_month_weekday& __x, + const year_month_weekday& __y) noexcept + { + return __x.year() == __y.year() + && __x.month() == __y.month() + && __x.weekday_indexed() == __y.weekday_indexed(); + } + + template + friend constexpr year_month_weekday + operator+(const year_month_weekday& __ymwd, const months& __dm) noexcept + { + return ((__ymwd.year() / __ymwd.month() + __dm) + / __ymwd.weekday_indexed()); + } + + template + friend constexpr year_month_weekday + operator+(const months& __dm, const year_month_weekday& __ymwd) noexcept + { return __ymwd + __dm; } + + friend constexpr year_month_weekday + operator+(const year_month_weekday& __ymwd, const years& __dy) noexcept + { return {__ymwd.year() + __dy, __ymwd.month(), __ymwd.weekday_indexed()}; } + + friend constexpr year_month_weekday + operator+(const years& __dy, const year_month_weekday& __ymwd) noexcept + { return __ymwd + __dy; } + + template + friend constexpr year_month_weekday + operator-(const year_month_weekday& __ymwd, const months& __dm) noexcept + { return __ymwd + -__dm; } + + friend constexpr year_month_weekday + operator-(const year_month_weekday& __ymwd, const years& __dy) noexcept + { return __ymwd + -__dy; } + + friend constexpr year_month_weekday + operator/(const year_month& __ym, + const chrono::weekday_indexed& __wdi) noexcept + { return {__ym.year(), __ym.month(), __wdi}; } + + friend constexpr year_month_weekday + operator/(const chrono::year& __y, const month_weekday& __mwd) noexcept + { return {__y, __mwd.month(), __mwd.weekday_indexed()}; } + + friend constexpr year_month_weekday + operator/(int __y, const month_weekday& __mwd) noexcept + { return chrono::year(__y) / __mwd; } + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, const chrono::year& __y) noexcept + { return __y / __mwd; } + + friend constexpr year_month_weekday + operator/(const month_weekday& __mwd, int __y) noexcept + { return chrono::year(__y) / __mwd; } + + // TODO: Implement operator<<. + }; + + // YEAR_MONTH_WEEKDAY_LAST + + class year_month_weekday_last + { + private: + chrono::year _M_y; + chrono::month _M_m; + chrono::weekday_last _M_wdl; + + public: + constexpr + year_month_weekday_last(const chrono::year& __y, const chrono::month& __m, + const chrono::weekday_last& __wdl) noexcept + : _M_y{__y}, _M_m{__m}, _M_wdl{__wdl} + { } + + template + constexpr year_month_weekday_last& + operator+=(const months& __m) noexcept + { + *this = *this + __m; + return *this; + } + + template + constexpr year_month_weekday_last& + operator-=(const months& __m) noexcept + { + *this = *this - __m; + return *this; + } + + constexpr year_month_weekday_last& + operator+=(const years& __y) noexcept + { + *this = *this + __y; + return *this; + } + + constexpr year_month_weekday_last& + operator-=(const years& __y) noexcept + { + *this = *this - __y; + return *this; + } + + constexpr chrono::year + year() const noexcept + { return _M_y; } + + constexpr chrono::month + month() const noexcept + { return _M_m; } + + constexpr chrono::weekday + weekday() const noexcept + { return _M_wdl.weekday(); } + + constexpr chrono::weekday_last + weekday_last() const noexcept + { return _M_wdl; } + + constexpr + operator sys_days() const noexcept + { + const auto __d = sys_days{_M_y / _M_m / last}; + return sys_days{(__d - (chrono::weekday{__d} + - _M_wdl.weekday())).time_since_epoch()}; + } + + explicit constexpr + operator local_days() const noexcept + { return local_days{sys_days{*this}.time_since_epoch()}; } + + constexpr bool + ok() const noexcept + { return _M_y.ok() && _M_m.ok() && _M_wdl.ok(); } + + friend constexpr bool + operator==(const year_month_weekday_last& __x, + const year_month_weekday_last& __y) noexcept + { + return __x.year() == __y.year() + && __x.month() == __y.month() + && __x.weekday_last() == __y.weekday_last(); + } + + template + friend constexpr year_month_weekday_last + operator+(const year_month_weekday_last& __ymwdl, + const months& __dm) noexcept + { + return ((__ymwdl.year() / __ymwdl.month() + __dm) + / __ymwdl.weekday_last()); + } + + template + friend constexpr year_month_weekday_last + operator+(const months& __dm, + const year_month_weekday_last& __ymwdl) noexcept + { return __ymwdl + __dm; } + + friend constexpr year_month_weekday_last + operator+(const year_month_weekday_last& __ymwdl, + const years& __dy) noexcept + { return {__ymwdl.year() + __dy, __ymwdl.month(), __ymwdl.weekday_last()}; } + + friend constexpr year_month_weekday_last + operator+(const years& __dy, + const year_month_weekday_last& __ymwdl) noexcept + { return __ymwdl + __dy; } + + template + friend constexpr year_month_weekday_last + operator-(const year_month_weekday_last& __ymwdl, + const months& __dm) noexcept + { return __ymwdl + -__dm; } + + friend constexpr year_month_weekday_last + operator-(const year_month_weekday_last& __ymwdl, + const years& __dy) noexcept + { return __ymwdl + -__dy; } + + friend constexpr year_month_weekday_last + operator/(const year_month& __ym, + const chrono::weekday_last& __wdl) noexcept + { return {__ym.year(), __ym.month(), __wdl}; } + + friend constexpr year_month_weekday_last + operator/(const chrono::year& __y, + const chrono::month_weekday_last& __mwdl) noexcept + { return {__y, __mwdl.month(), __mwdl.weekday_last()}; } + + friend constexpr year_month_weekday_last + operator/(int __y, const chrono::month_weekday_last& __mwdl) noexcept + { return chrono::year(__y) / __mwdl; } + + friend constexpr year_month_weekday_last + operator/(const chrono::month_weekday_last& __mwdl, + const chrono::year& __y) noexcept + { return __y / __mwdl; } + + friend constexpr year_month_weekday_last + operator/(const chrono::month_weekday_last& __mwdl, int __y) noexcept + { return chrono::year(__y) / __mwdl; } + + // TODO: Implement operator<<. + }; + + // HH_MM_SS + + namespace __detail + { + consteval long long + __pow10(unsigned __n) + { + long long __r = 1; + while (__n-- > 0) + __r *= 10; + return __r; + } + } + + template + class hh_mm_ss + { + private: + static constexpr int + _S_fractional_width() + { + int __multiplicity_2 = 0; + int __multiplicity_5 = 0; + auto __den = _Duration::period::den; + while ((__den % 2) == 0) + { + ++__multiplicity_2; + __den /= 2; + } + while ((__den % 5) == 0) + { + ++__multiplicity_5; + __den /= 5; + } + if (__den != 1) + return 6; + + int __width = (__multiplicity_2 > __multiplicity_5 + ? __multiplicity_2 : __multiplicity_5); + if (__width > 18) + __width = 18; + return __width; + } + + public: + static constexpr unsigned fractional_width = {_S_fractional_width()}; + + using precision + = duration, + ratio<1, __detail::__pow10(fractional_width)>>; + + constexpr + hh_mm_ss() noexcept + : hh_mm_ss{_Duration::zero()} + { } + + constexpr explicit + hh_mm_ss(_Duration __d) noexcept + : _M_is_neg (__d < _Duration::zero()), + _M_h (duration_cast(abs(__d))), + _M_m (duration_cast(abs(__d) - hours())), + _M_s (duration_cast(abs(__d) - hours() - minutes())) + { + if constexpr (treat_as_floating_point_v) + _M_ss = abs(__d) - hours() - minutes() - seconds(); + else + _M_ss = duration_cast(abs(__d) - hours() + - minutes() - seconds()); + } + + constexpr bool + is_negative() const noexcept + { return _M_is_neg; } + + constexpr chrono::hours + hours() const noexcept + { return _M_h; } + + constexpr chrono::minutes + minutes() const noexcept + { return _M_m; } + + constexpr chrono::seconds + seconds() const noexcept + { return _M_s; } + + constexpr precision + subseconds() const noexcept + { return _M_ss; } + + constexpr explicit + operator precision() const noexcept + { return to_duration(); } + + constexpr precision + to_duration() const noexcept + { + if (_M_is_neg) + return -(_M_h + _M_m + _M_s + _M_ss); + else + return _M_h + _M_m + _M_s + _M_ss; + } + + // TODO: Implement operator<<. + + private: + bool _M_is_neg; + chrono::hours _M_h; + chrono::minutes _M_m; + chrono::seconds _M_s; + precision _M_ss; + }; +#endif // C++20 + + /// @} group chrono + } // namespace chrono + +#if __cplusplus > 201103L + +#define __cpp_lib_chrono_udls 201304 + + inline namespace literals + { + /** ISO C++ 2014 namespace for suffixes for duration literals. + * + * These suffixes can be used to create `chrono::duration` values with + * tick periods of hours, minutes, seconds, milliseconds, microseconds + * or nanoseconds. For example, `std::chrono::seconds(5)` can be written + * as `5s` after making the suffix visible in the current scope. + * The suffixes can be made visible by a using-directive or + * using-declaration such as: + * - `using namespace std::chrono_literals;` + * - `using namespace std::literals;` + * - `using namespace std::chrono;` + * - `using namespace std;` + * - `using std::chrono_literals::operator""s;` + * + * The result of these suffixes on an integer literal is one of the + * standard typedefs such as `std::chrono::hours`. + * The result on a floating-point literal is a duration type with the + * specified tick period and an unspecified floating-point representation, + * for example `1.5e2ms` might be equivalent to + * `chrono::duration(1.5e2)`. + * + * @ingroup chrono + */ + inline namespace chrono_literals + { + /// @addtogroup chrono + /// @{ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" + /// @cond undocumented + template + constexpr _Dur __check_overflow() + { + using _Val = __parse_int::_Parse_int<_Digits...>; + constexpr typename _Dur::rep __repval = _Val::value; + static_assert(__repval >= 0 && __repval == _Val::value, + "literal value cannot be represented by duration type"); + return _Dur(__repval); + } + /// @endcond + + /// Literal suffix for durations representing non-integer hours + constexpr chrono::duration> + operator""h(long double __hours) + { return chrono::duration>{__hours}; } + + /// Literal suffix for durations of type `std::chrono::hours` + template + constexpr chrono::hours + operator""h() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer minutes + constexpr chrono::duration> + operator""min(long double __mins) + { return chrono::duration>{__mins}; } + + /// Literal suffix for durations of type `std::chrono::minutes` + template + constexpr chrono::minutes + operator""min() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer seconds + constexpr chrono::duration + operator""s(long double __secs) + { return chrono::duration{__secs}; } + + /// Literal suffix for durations of type `std::chrono::seconds` + template + constexpr chrono::seconds + operator""s() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer milliseconds + constexpr chrono::duration + operator""ms(long double __msecs) + { return chrono::duration{__msecs}; } + + /// Literal suffix for durations of type `std::chrono::milliseconds` + template + constexpr chrono::milliseconds + operator""ms() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer microseconds + constexpr chrono::duration + operator""us(long double __usecs) + { return chrono::duration{__usecs}; } + + /// Literal suffix for durations of type `std::chrono::microseconds` + template + constexpr chrono::microseconds + operator""us() + { return __check_overflow(); } + + /// Literal suffix for durations representing non-integer nanoseconds + constexpr chrono::duration + operator""ns(long double __nsecs) + { return chrono::duration{__nsecs}; } + + /// Literal suffix for durations of type `std::chrono::nanoseconds` + template + constexpr chrono::nanoseconds + operator""ns() + { return __check_overflow(); } + +#if __cplusplus > 201703L + constexpr chrono::day + operator""d(unsigned long long __d) noexcept + { return chrono::day{static_cast(__d)}; } + + constexpr chrono::year + operator""y(unsigned long long __y) noexcept + { return chrono::year{static_cast(__y)}; } +#endif // C++20 + +#pragma GCC diagnostic pop + /// @} + } // inline namespace chrono_literals + } // inline namespace literals + + namespace chrono + { + using namespace literals::chrono_literals; + } // namespace chrono + +#if __cplusplus > 201703L + namespace chrono + { + /// @addtogroup chrono + /// @{ + + // 12/24 HOURS FUNCTIONS + + constexpr bool + is_am(const hours& __h) noexcept + { return 0h <= __h && __h <= 11h; } + + constexpr bool + is_pm(const hours& __h) noexcept + { return 12h <= __h && __h <= 23h; } + + constexpr hours + make12(const hours& __h) noexcept + { + if (__h == 0h) + return 12h; + else if (__h > 12h) + return __h - 12h; + return __h; + } + + constexpr hours + make24(const hours& __h, bool __is_pm) noexcept + { + if (!__is_pm) + { + if (__h == 12h) + return 0h; + else + return __h; + } + else + { + if (__h == 12h) + return __h; + else + return __h + 12h; + } + } + /// @} group chrono + } // namespace chrono +#endif + +#if __cplusplus >= 201703L + namespace filesystem + { + struct __file_clock + { + using duration = chrono::nanoseconds; + using rep = duration::rep; + using period = duration::period; + using time_point = chrono::time_point<__file_clock>; + static constexpr bool is_steady = false; + + static time_point + now() noexcept + { return _S_from_sys(chrono::system_clock::now()); } + +#if __cplusplus > 201703L + template + static + chrono::file_time<_Dur> + from_sys(const chrono::sys_time<_Dur>& __t) noexcept + { return _S_from_sys(__t); } + + // For internal use only + template + static + chrono::sys_time<_Dur> + to_sys(const chrono::file_time<_Dur>& __t) noexcept + { return _S_to_sys(__t); } +#endif // C++20 + + private: + using __sys_clock = chrono::system_clock; + + // This clock's (unspecified) epoch is 2174-01-01 00:00:00 UTC. + // A signed 64-bit duration with nanosecond resolution gives roughly + // +/- 292 years, which covers the 1901-2446 date range for ext4. + static constexpr chrono::seconds _S_epoch_diff{6437664000}; + + protected: + // For internal use only + template + static + chrono::time_point<__file_clock, _Dur> + _S_from_sys(const chrono::time_point<__sys_clock, _Dur>& __t) noexcept + { + using __file_time = chrono::time_point<__file_clock, _Dur>; + return __file_time{__t.time_since_epoch()} - _S_epoch_diff; + } + + // For internal use only + template + static + chrono::time_point<__sys_clock, _Dur> + _S_to_sys(const chrono::time_point<__file_clock, _Dur>& __t) noexcept + { + using __sys_time = chrono::time_point<__sys_clock, _Dur>; + return __sys_time{__t.time_since_epoch()} + _S_epoch_diff; + } + }; + } // namespace filesystem +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif //_GLIBCXX_CHRONO diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cinttypes b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cinttypes new file mode 100755 index 0000000..efa701e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cinttypes @@ -0,0 +1,81 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cinttypes + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CINTTYPES +#define _GLIBCXX_CINTTYPES 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +// For 27.9.2/3 (see C99, Note 184) +#if _GLIBCXX_HAVE_INTTYPES_H +# ifndef __STDC_FORMAT_MACROS +# define _UNDEF__STDC_FORMAT_MACROS +# define __STDC_FORMAT_MACROS +# endif +# include +# ifdef _UNDEF__STDC_FORMAT_MACROS +# undef __STDC_FORMAT_MACROS +# undef _UNDEF__STDC_FORMAT_MACROS +# endif +#endif + +#ifdef _GLIBCXX_USE_C99_INTTYPES_TR1 + +namespace std +{ + // types + using ::imaxdiv_t; + + // functions + using ::imaxabs; + using ::imaxdiv; + + // GCC does not support extended integer types + // intmax_t abs(intmax_t) + // imaxdiv_t div(intmax_t, intmax_t) + + using ::strtoimax; + using ::strtoumax; + +#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 + using ::wcstoimax; + using ::wcstoumax; +#endif +} // namespace std + +#endif // _GLIBCXX_USE_C99_INTTYPES_TR1 + +#endif // C++11 + +#endif // _GLIBCXX_CINTTYPES diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ciso646 b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ciso646 new file mode 100755 index 0000000..dcd75fc --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ciso646 @@ -0,0 +1,38 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file ciso646 + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c iso646.h, + * which is empty in C++. + */ +#ifndef _GLIBCXX_CISO646 +#define _GLIBCXX_CISO646 + +#pragma GCC system_header + +#include +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/climits b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/climits new file mode 100755 index 0000000..c56b14a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/climits @@ -0,0 +1,59 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/climits + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c limits.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CLIMITS +#define _GLIBCXX_CLIMITS 1 + +#ifndef LLONG_MIN +#define LLONG_MIN (-__LONG_LONG_MAX__ - 1) +#endif + +#ifndef LLONG_MAX +#define LLONG_MAX __LONG_LONG_MAX__ +#endif + +#ifndef ULLONG_MAX +#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1) +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/clocale b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/clocale new file mode 100755 index 0000000..6d3c8c3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/clocale @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file clocale + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c locale.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.2.2 Implementation properties: C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CLOCALE +#define _GLIBCXX_CLOCALE 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef setlocale +#undef localeconv + +namespace std +{ + using ::lconv; + using ::setlocale; + using ::localeconv; +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cmath b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cmath new file mode 100755 index 0000000..3233228 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cmath @@ -0,0 +1,1940 @@ +// -*- C++ -*- C forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cmath + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c math.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 26.5 C library +// + +#pragma GCC system_header + +#include +#include +#include +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include_next +#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include + +#ifndef _GLIBCXX_CMATH +#define _GLIBCXX_CMATH 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef div +#undef acos +#undef asin +#undef atan +#undef atan2 +#undef ceil +#undef cos +#undef cosh +#undef exp +#undef fabs +#undef floor +#undef fmod +#undef frexp +#undef ldexp +#undef log +#undef log10 +#undef modf +#undef pow +#undef sin +#undef sinh +#undef sqrt +#undef tan +#undef tanh + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::acos; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + acos(float __x) + { return __builtin_acosf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + acos(long double __x) + { return __builtin_acosl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + acos(_Tp __x) + { return __builtin_acos(__x); } + + using ::asin; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + asin(float __x) + { return __builtin_asinf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + asin(long double __x) + { return __builtin_asinl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + asin(_Tp __x) + { return __builtin_asin(__x); } + + using ::atan; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + atan(float __x) + { return __builtin_atanf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + atan(long double __x) + { return __builtin_atanl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + atan(_Tp __x) + { return __builtin_atan(__x); } + + using ::atan2; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + atan2(float __y, float __x) + { return __builtin_atan2f(__y, __x); } + + inline _GLIBCXX_CONSTEXPR long double + atan2(long double __y, long double __x) + { return __builtin_atan2l(__y, __x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + atan2(_Tp __y, _Up __x) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return atan2(__type(__y), __type(__x)); + } + + using ::ceil; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + ceil(float __x) + { return __builtin_ceilf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + ceil(long double __x) + { return __builtin_ceill(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + ceil(_Tp __x) + { return __builtin_ceil(__x); } + + using ::cos; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + cos(float __x) + { return __builtin_cosf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + cos(long double __x) + { return __builtin_cosl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + cos(_Tp __x) + { return __builtin_cos(__x); } + + using ::cosh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + cosh(float __x) + { return __builtin_coshf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + cosh(long double __x) + { return __builtin_coshl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + cosh(_Tp __x) + { return __builtin_cosh(__x); } + + using ::exp; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + exp(float __x) + { return __builtin_expf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + exp(long double __x) + { return __builtin_expl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + exp(_Tp __x) + { return __builtin_exp(__x); } + + using ::fabs; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + fabs(float __x) + { return __builtin_fabsf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + fabs(long double __x) + { return __builtin_fabsl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + fabs(_Tp __x) + { return __builtin_fabs(__x); } + + using ::floor; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + floor(float __x) + { return __builtin_floorf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + floor(long double __x) + { return __builtin_floorl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + floor(_Tp __x) + { return __builtin_floor(__x); } + + using ::fmod; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + fmod(float __x, float __y) + { return __builtin_fmodf(__x, __y); } + + inline _GLIBCXX_CONSTEXPR long double + fmod(long double __x, long double __y) + { return __builtin_fmodl(__x, __y); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmod(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmod(__type(__x), __type(__y)); + } + + using ::frexp; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline float + frexp(float __x, int* __exp) + { return __builtin_frexpf(__x, __exp); } + + inline long double + frexp(long double __x, int* __exp) + { return __builtin_frexpl(__x, __exp); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + frexp(_Tp __x, int* __exp) + { return __builtin_frexp(__x, __exp); } + + using ::ldexp; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + ldexp(float __x, int __exp) + { return __builtin_ldexpf(__x, __exp); } + + inline _GLIBCXX_CONSTEXPR long double + ldexp(long double __x, int __exp) + { return __builtin_ldexpl(__x, __exp); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + ldexp(_Tp __x, int __exp) + { return __builtin_ldexp(__x, __exp); } + + using ::log; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + log(float __x) + { return __builtin_logf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + log(long double __x) + { return __builtin_logl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log(_Tp __x) + { return __builtin_log(__x); } + + using ::log10; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + log10(float __x) + { return __builtin_log10f(__x); } + + inline _GLIBCXX_CONSTEXPR long double + log10(long double __x) + { return __builtin_log10l(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log10(_Tp __x) + { return __builtin_log10(__x); } + + using ::modf; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline float + modf(float __x, float* __iptr) + { return __builtin_modff(__x, __iptr); } + + inline long double + modf(long double __x, long double* __iptr) + { return __builtin_modfl(__x, __iptr); } +#endif + + using ::pow; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + pow(float __x, float __y) + { return __builtin_powf(__x, __y); } + + inline _GLIBCXX_CONSTEXPR long double + pow(long double __x, long double __y) + { return __builtin_powl(__x, __y); } + +#if __cplusplus < 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 550. What should the return type of pow(float,int) be? + inline double + pow(double __x, int __i) + { return __builtin_powi(__x, __i); } + + inline float + pow(float __x, int __n) + { return __builtin_powif(__x, __n); } + + inline long double + pow(long double __x, int __n) + { return __builtin_powil(__x, __n); } +#endif +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + pow(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return pow(__type(__x), __type(__y)); + } + + using ::sin; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + sin(float __x) + { return __builtin_sinf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + sin(long double __x) + { return __builtin_sinl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + sin(_Tp __x) + { return __builtin_sin(__x); } + + using ::sinh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + sinh(float __x) + { return __builtin_sinhf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + sinh(long double __x) + { return __builtin_sinhl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + sinh(_Tp __x) + { return __builtin_sinh(__x); } + + using ::sqrt; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + sqrt(float __x) + { return __builtin_sqrtf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + sqrt(long double __x) + { return __builtin_sqrtl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + sqrt(_Tp __x) + { return __builtin_sqrt(__x); } + + using ::tan; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + tan(float __x) + { return __builtin_tanf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + tan(long double __x) + { return __builtin_tanl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + tan(_Tp __x) + { return __builtin_tan(__x); } + + using ::tanh; + +#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO + inline _GLIBCXX_CONSTEXPR float + tanh(float __x) + { return __builtin_tanhf(__x); } + + inline _GLIBCXX_CONSTEXPR long double + tanh(long double __x) + { return __builtin_tanhl(__x); } +#endif + + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + tanh(_Tp __x) + { return __builtin_tanh(__x); } + +#if _GLIBCXX_USE_C99_MATH +#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC + +// These are possible macros imported from C99-land. +#undef fpclassify +#undef isfinite +#undef isinf +#undef isnan +#undef isnormal +#undef signbit +#undef isgreater +#undef isgreaterequal +#undef isless +#undef islessequal +#undef islessgreater +#undef isunordered + +#if __cplusplus >= 201103L + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr int + fpclassify(float __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr int + fpclassify(double __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } + + constexpr int + fpclassify(long double __x) + { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + int>::__type + fpclassify(_Tp __x) + { return __x != 0 ? FP_NORMAL : FP_ZERO; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isfinite(float __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isfinite(double __x) + { return __builtin_isfinite(__x); } + + constexpr bool + isfinite(long double __x) + { return __builtin_isfinite(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isfinite(_Tp __x) + { return true; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isinf(float __x) + { return __builtin_isinf(__x); } + +#if _GLIBCXX_HAVE_OBSOLETE_ISINF \ + && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC + using ::isinf; +#else + constexpr bool + isinf(double __x) + { return __builtin_isinf(__x); } +#endif + + constexpr bool + isinf(long double __x) + { return __builtin_isinf(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isinf(_Tp __x) + { return false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isnan(float __x) + { return __builtin_isnan(__x); } + +#if _GLIBCXX_HAVE_OBSOLETE_ISNAN \ + && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC + using ::isnan; +#else + constexpr bool + isnan(double __x) + { return __builtin_isnan(__x); } +#endif + + constexpr bool + isnan(long double __x) + { return __builtin_isnan(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isnan(_Tp __x) + { return false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isnormal(float __x) + { return __builtin_isnormal(__x); } + + constexpr bool + isnormal(double __x) + { return __builtin_isnormal(__x); } + + constexpr bool + isnormal(long double __x) + { return __builtin_isnormal(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + isnormal(_Tp __x) + { return __x != 0 ? true : false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic. + constexpr bool + signbit(float __x) + { return __builtin_signbit(__x); } + + constexpr bool + signbit(double __x) + { return __builtin_signbit(__x); } + + constexpr bool + signbit(long double __x) + { return __builtin_signbit(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + bool>::__type + signbit(_Tp __x) + { return __x < 0 ? true : false; } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isgreater(float __x, float __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreater(double __x, double __y) + { return __builtin_isgreater(__x, __y); } + + constexpr bool + isgreater(long double __x, long double __y) + { return __builtin_isgreater(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isgreater(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isgreater(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isgreaterequal(float __x, float __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isgreaterequal(double __x, double __y) + { return __builtin_isgreaterequal(__x, __y); } + + constexpr bool + isgreaterequal(long double __x, long double __y) + { return __builtin_isgreaterequal(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isgreaterequal(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isgreaterequal(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isless(float __x, float __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + isless(double __x, double __y) + { return __builtin_isless(__x, __y); } + + constexpr bool + isless(long double __x, long double __y) + { return __builtin_isless(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isless(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isless(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + islessequal(float __x, float __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessequal(double __x, double __y) + { return __builtin_islessequal(__x, __y); } + + constexpr bool + islessequal(long double __x, long double __y) + { return __builtin_islessequal(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + islessequal(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_islessequal(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + islessgreater(float __x, float __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + islessgreater(double __x, double __y) + { return __builtin_islessgreater(__x, __y); } + + constexpr bool + islessgreater(long double __x, long double __y) + { return __builtin_islessgreater(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + islessgreater(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_islessgreater(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr bool + isunordered(float __x, float __y) + { return __builtin_isunordered(__x, __y); } + + constexpr bool + isunordered(double __x, double __y) + { return __builtin_isunordered(__x, __y); } + + constexpr bool + isunordered(long double __x, long double __y) + { return __builtin_isunordered(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename + __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value), bool>::__type + isunordered(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return __builtin_isunordered(__type(__x), __type(__y)); + } +#endif + +#else + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + fpclassify(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, + FP_SUBNORMAL, FP_ZERO, __type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isfinite(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isfinite(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isinf(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isinf(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnan(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnan(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isnormal(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isnormal(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + signbit(_Tp __f) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_signbit(__type(__f)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreater(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isgreaterequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isgreaterequal(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isless(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isless(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessequal(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessequal(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + islessgreater(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_islessgreater(__type(__f1), __type(__f2)); + } + + template + inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, + int>::__type + isunordered(_Tp __f1, _Tp __f2) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __builtin_isunordered(__type(__f1), __type(__f2)); + } + +#endif // C++11 +#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ +#endif /* _GLIBCXX_USE_C99_MATH */ + +#if __cplusplus >= 201103L + +#ifdef _GLIBCXX_USE_C99_MATH_TR1 + +#undef acosh +#undef acoshf +#undef acoshl +#undef asinh +#undef asinhf +#undef asinhl +#undef atanh +#undef atanhf +#undef atanhl +#undef cbrt +#undef cbrtf +#undef cbrtl +#undef copysign +#undef copysignf +#undef copysignl +#undef erf +#undef erff +#undef erfl +#undef erfc +#undef erfcf +#undef erfcl +#undef exp2 +#undef exp2f +#undef exp2l +#undef expm1 +#undef expm1f +#undef expm1l +#undef fdim +#undef fdimf +#undef fdiml +#undef fma +#undef fmaf +#undef fmal +#undef fmax +#undef fmaxf +#undef fmaxl +#undef fmin +#undef fminf +#undef fminl +#undef hypot +#undef hypotf +#undef hypotl +#undef ilogb +#undef ilogbf +#undef ilogbl +#undef lgamma +#undef lgammaf +#undef lgammal +#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS +#undef llrint +#undef llrintf +#undef llrintl +#undef llround +#undef llroundf +#undef llroundl +#endif +#undef log1p +#undef log1pf +#undef log1pl +#undef log2 +#undef log2f +#undef log2l +#undef logb +#undef logbf +#undef logbl +#undef lrint +#undef lrintf +#undef lrintl +#undef lround +#undef lroundf +#undef lroundl +#undef nan +#undef nanf +#undef nanl +#undef nearbyint +#undef nearbyintf +#undef nearbyintl +#undef nextafter +#undef nextafterf +#undef nextafterl +#undef nexttoward +#undef nexttowardf +#undef nexttowardl +#undef remainder +#undef remainderf +#undef remainderl +#undef remquo +#undef remquof +#undef remquol +#undef rint +#undef rintf +#undef rintl +#undef round +#undef roundf +#undef roundl +#undef scalbln +#undef scalblnf +#undef scalblnl +#undef scalbn +#undef scalbnf +#undef scalbnl +#undef tgamma +#undef tgammaf +#undef tgammal +#undef trunc +#undef truncf +#undef truncl + + // types + using ::double_t; + using ::float_t; + + // functions + using ::acosh; + using ::acoshf; + using ::acoshl; + + using ::asinh; + using ::asinhf; + using ::asinhl; + + using ::atanh; + using ::atanhf; + using ::atanhl; + + using ::cbrt; + using ::cbrtf; + using ::cbrtl; + + using ::copysign; + using ::copysignf; + using ::copysignl; + + using ::erf; + using ::erff; + using ::erfl; + + using ::erfc; + using ::erfcf; + using ::erfcl; + + using ::exp2; + using ::exp2f; + using ::exp2l; + + using ::expm1; + using ::expm1f; + using ::expm1l; + + using ::fdim; + using ::fdimf; + using ::fdiml; + + using ::fma; + using ::fmaf; + using ::fmal; + + using ::fmax; + using ::fmaxf; + using ::fmaxl; + + using ::fmin; + using ::fminf; + using ::fminl; + + using ::hypot; + using ::hypotf; + using ::hypotl; + + using ::ilogb; + using ::ilogbf; + using ::ilogbl; + + using ::lgamma; + using ::lgammaf; + using ::lgammal; + +#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS + using ::llrint; + using ::llrintf; + using ::llrintl; + + using ::llround; + using ::llroundf; + using ::llroundl; +#endif + + using ::log1p; + using ::log1pf; + using ::log1pl; + + using ::log2; + using ::log2f; + using ::log2l; + + using ::logb; + using ::logbf; + using ::logbl; + + using ::lrint; + using ::lrintf; + using ::lrintl; + + using ::lround; + using ::lroundf; + using ::lroundl; + + using ::nan; + using ::nanf; + using ::nanl; + + using ::nearbyint; + using ::nearbyintf; + using ::nearbyintl; + + using ::nextafter; + using ::nextafterf; + using ::nextafterl; + + using ::nexttoward; + using ::nexttowardf; + using ::nexttowardl; + + using ::remainder; + using ::remainderf; + using ::remainderl; + + using ::remquo; + using ::remquof; + using ::remquol; + + using ::rint; + using ::rintf; + using ::rintl; + + using ::round; + using ::roundf; + using ::roundl; + + using ::scalbln; + using ::scalblnf; + using ::scalblnl; + + using ::scalbn; + using ::scalbnf; + using ::scalbnl; + + using ::tgamma; + using ::tgammaf; + using ::tgammal; + + using ::trunc; + using ::truncf; + using ::truncl; + + /// Additional overloads. +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + acosh(float __x) + { return __builtin_acoshf(__x); } + + constexpr long double + acosh(long double __x) + { return __builtin_acoshl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + acosh(_Tp __x) + { return __builtin_acosh(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + asinh(float __x) + { return __builtin_asinhf(__x); } + + constexpr long double + asinh(long double __x) + { return __builtin_asinhl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + asinh(_Tp __x) + { return __builtin_asinh(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + atanh(float __x) + { return __builtin_atanhf(__x); } + + constexpr long double + atanh(long double __x) + { return __builtin_atanhl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + atanh(_Tp __x) + { return __builtin_atanh(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + cbrt(float __x) + { return __builtin_cbrtf(__x); } + + constexpr long double + cbrt(long double __x) + { return __builtin_cbrtl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + cbrt(_Tp __x) + { return __builtin_cbrt(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + copysign(float __x, float __y) + { return __builtin_copysignf(__x, __y); } + + constexpr long double + copysign(long double __x, long double __y) + { return __builtin_copysignl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + copysign(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return copysign(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + erf(float __x) + { return __builtin_erff(__x); } + + constexpr long double + erf(long double __x) + { return __builtin_erfl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + erf(_Tp __x) + { return __builtin_erf(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + erfc(float __x) + { return __builtin_erfcf(__x); } + + constexpr long double + erfc(long double __x) + { return __builtin_erfcl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + erfc(_Tp __x) + { return __builtin_erfc(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + exp2(float __x) + { return __builtin_exp2f(__x); } + + constexpr long double + exp2(long double __x) + { return __builtin_exp2l(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + exp2(_Tp __x) + { return __builtin_exp2(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + expm1(float __x) + { return __builtin_expm1f(__x); } + + constexpr long double + expm1(long double __x) + { return __builtin_expm1l(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + expm1(_Tp __x) + { return __builtin_expm1(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fdim(float __x, float __y) + { return __builtin_fdimf(__x, __y); } + + constexpr long double + fdim(long double __x, long double __y) + { return __builtin_fdiml(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fdim(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fdim(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fma(float __x, float __y, float __z) + { return __builtin_fmaf(__x, __y, __z); } + + constexpr long double + fma(long double __x, long double __y, long double __z) + { return __builtin_fmal(__x, __y, __z); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type + fma(_Tp __x, _Up __y, _Vp __z) + { + typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; + return fma(__type(__x), __type(__y), __type(__z)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fmax(float __x, float __y) + { return __builtin_fmaxf(__x, __y); } + + constexpr long double + fmax(long double __x, long double __y) + { return __builtin_fmaxl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmax(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmax(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + fmin(float __x, float __y) + { return __builtin_fminf(__x, __y); } + + constexpr long double + fmin(long double __x, long double __y) + { return __builtin_fminl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + fmin(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmin(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + hypot(float __x, float __y) + { return __builtin_hypotf(__x, __y); } + + constexpr long double + hypot(long double __x, long double __y) + { return __builtin_hypotl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + hypot(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return hypot(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr int + ilogb(float __x) + { return __builtin_ilogbf(__x); } + + constexpr int + ilogb(long double __x) + { return __builtin_ilogbl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr + typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + int>::__type + ilogb(_Tp __x) + { return __builtin_ilogb(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + lgamma(float __x) + { return __builtin_lgammaf(__x); } + + constexpr long double + lgamma(long double __x) + { return __builtin_lgammal(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + lgamma(_Tp __x) + { return __builtin_lgamma(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long long + llrint(float __x) + { return __builtin_llrintf(__x); } + + constexpr long long + llrint(long double __x) + { return __builtin_llrintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type + llrint(_Tp __x) + { return __builtin_llrint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long long + llround(float __x) + { return __builtin_llroundf(__x); } + + constexpr long long + llround(long double __x) + { return __builtin_llroundl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long long>::__type + llround(_Tp __x) + { return __builtin_llround(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + log1p(float __x) + { return __builtin_log1pf(__x); } + + constexpr long double + log1p(long double __x) + { return __builtin_log1pl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log1p(_Tp __x) + { return __builtin_log1p(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + // DR 568. + constexpr float + log2(float __x) + { return __builtin_log2f(__x); } + + constexpr long double + log2(long double __x) + { return __builtin_log2l(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + log2(_Tp __x) + { return __builtin_log2(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + logb(float __x) + { return __builtin_logbf(__x); } + + constexpr long double + logb(long double __x) + { return __builtin_logbl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + logb(_Tp __x) + { return __builtin_logb(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long + lrint(float __x) + { return __builtin_lrintf(__x); } + + constexpr long + lrint(long double __x) + { return __builtin_lrintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type + lrint(_Tp __x) + { return __builtin_lrint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr long + lround(float __x) + { return __builtin_lroundf(__x); } + + constexpr long + lround(long double __x) + { return __builtin_lroundl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + long>::__type + lround(_Tp __x) + { return __builtin_lround(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + nearbyint(float __x) + { return __builtin_nearbyintf(__x); } + + constexpr long double + nearbyint(long double __x) + { return __builtin_nearbyintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + nearbyint(_Tp __x) + { return __builtin_nearbyint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + nextafter(float __x, float __y) + { return __builtin_nextafterf(__x, __y); } + + constexpr long double + nextafter(long double __x, long double __y) + { return __builtin_nextafterl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + nextafter(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return nextafter(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + nexttoward(float __x, long double __y) + { return __builtin_nexttowardf(__x, __y); } + + constexpr long double + nexttoward(long double __x, long double __y) + { return __builtin_nexttowardl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + nexttoward(_Tp __x, long double __y) + { return __builtin_nexttoward(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + remainder(float __x, float __y) + { return __builtin_remainderf(__x, __y); } + + constexpr long double + remainder(long double __x, long double __y) + { return __builtin_remainderl(__x, __y); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remainder(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remainder(__type(__x), __type(__y)); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + inline float + remquo(float __x, float __y, int* __pquo) + { return __builtin_remquof(__x, __y, __pquo); } + + inline long double + remquo(long double __x, long double __y, int* __pquo) + { return __builtin_remquol(__x, __y, __pquo); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type + remquo(_Tp __x, _Up __y, int* __pquo) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return remquo(__type(__x), __type(__y), __pquo); + } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + rint(float __x) + { return __builtin_rintf(__x); } + + constexpr long double + rint(long double __x) + { return __builtin_rintl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + rint(_Tp __x) + { return __builtin_rint(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + round(float __x) + { return __builtin_roundf(__x); } + + constexpr long double + round(long double __x) + { return __builtin_roundl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + round(_Tp __x) + { return __builtin_round(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + scalbln(float __x, long __ex) + { return __builtin_scalblnf(__x, __ex); } + + constexpr long double + scalbln(long double __x, long __ex) + { return __builtin_scalblnl(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + scalbln(_Tp __x, long __ex) + { return __builtin_scalbln(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + scalbn(float __x, int __ex) + { return __builtin_scalbnf(__x, __ex); } + + constexpr long double + scalbn(long double __x, int __ex) + { return __builtin_scalbnl(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + scalbn(_Tp __x, int __ex) + { return __builtin_scalbn(__x, __ex); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + tgamma(float __x) + { return __builtin_tgammaf(__x); } + + constexpr long double + tgamma(long double __x) + { return __builtin_tgammal(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + tgamma(_Tp __x) + { return __builtin_tgamma(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP + constexpr float + trunc(float __x) + { return __builtin_truncf(__x); } + + constexpr long double + trunc(long double __x) + { return __builtin_truncl(__x); } +#endif + +#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT + template + constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + trunc(_Tp __x) + { return __builtin_trunc(__x); } +#endif + +#endif // _GLIBCXX_USE_C99_MATH_TR1 +#endif // C++11 + +#if __cplusplus >= 201703L + + // [c.math.hypot3], three-dimensional hypotenuse +#define __cpp_lib_hypot 201603 + + template + inline _Tp + __hypot3(_Tp __x, _Tp __y, _Tp __z) + { + __x = std::abs(__x); + __y = std::abs(__y); + __z = std::abs(__z); + if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x) + return __a * std::sqrt((__x / __a) * (__x / __a) + + (__y / __a) * (__y / __a) + + (__z / __a) * (__z / __a)); + else + return {}; + } + + inline float + hypot(float __x, float __y, float __z) + { return std::__hypot3(__x, __y, __z); } + + inline double + hypot(double __x, double __y, double __z) + { return std::__hypot3(__x, __y, __z); } + + inline long double + hypot(long double __x, long double __y, long double __z) + { return std::__hypot3(__x, __y, __z); } + + template + __gnu_cxx::__promoted_t<_Tp, _Up, _Vp> + hypot(_Tp __x, _Up __y, _Vp __z) + { + using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; + return std::__hypot3<__type>(__x, __y, __z); + } +#endif // C++17 + +#if __cplusplus >= 202002L + // linear interpolation +# define __cpp_lib_interpolate 201902L + + template + constexpr _Fp + __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept + { + if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) + return __t * __b + (1 - __t) * __a; + + if (__t == 1) + return __b; // exact + + // Exact at __t=0, monotonic except near __t=1, + // bounded, determinate, and consistent: + const _Fp __x = __a + __t * (__b - __a); + return (__t > 1) == (__b > __a) + ? (__b < __x ? __x : __b) + : (__b > __x ? __x : __b); // monotonic near __t=1 + } + + constexpr float + lerp(float __a, float __b, float __t) noexcept + { return std::__lerp(__a, __b, __t); } + + constexpr double + lerp(double __a, double __b, double __t) noexcept + { return std::__lerp(__a, __b, __t); } + + constexpr long double + lerp(long double __a, long double __b, long double __t) noexcept + { return std::__lerp(__a, __b, __t); } + + template + constexpr __gnu_cxx::__promoted_t<_Tp, _Up, _Vp> + lerp(_Tp __x, _Up __y, _Vp __z) noexcept + { + using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; + return std::__lerp<__type>(__x, __y, __z); + } +#endif // C++20 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if _GLIBCXX_USE_STD_SPEC_FUNCS +# include +#endif + +} // extern "C++" + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/codecvt b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/codecvt new file mode 100755 index 0000000..612da90 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/codecvt @@ -0,0 +1,177 @@ +// -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// ISO C++ 14882: 22.5 Standard code conversion facets + +/** @file include/codecvt + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CODECVT +#define _GLIBCXX_CODECVT 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + enum codecvt_mode + { + consume_header = 4, + generate_header = 2, + little_endian = 1 + }; + + template + class codecvt_utf8 : public codecvt<_Elem, char, mbstate_t> + { + public: + explicit + codecvt_utf8(size_t __refs = 0); + + ~codecvt_utf8(); + }; + + template + class codecvt_utf16 : public codecvt<_Elem, char, mbstate_t> + { + public: + explicit + codecvt_utf16(size_t __refs = 0); + + ~codecvt_utf16(); + }; + + template + class codecvt_utf8_utf16 : public codecvt<_Elem, char, mbstate_t> + { + public: + explicit + codecvt_utf8_utf16(size_t __refs = 0); + + ~codecvt_utf8_utf16(); + }; + +#define _GLIBCXX_CODECVT_SPECIALIZATION2(_NAME, _ELEM) \ + template<> \ + class _NAME<_ELEM> \ + : public codecvt<_ELEM, char, mbstate_t> \ + { \ + public: \ + typedef _ELEM intern_type; \ + typedef char extern_type; \ + typedef mbstate_t state_type; \ + \ + protected: \ + _NAME(unsigned long __maxcode, codecvt_mode __mode, size_t __refs) \ + : codecvt(__refs), _M_maxcode(__maxcode), _M_mode(__mode) { } \ + \ + virtual \ + ~_NAME(); \ + \ + virtual result \ + do_out(state_type& __state, const intern_type* __from, \ + const intern_type* __from_end, const intern_type*& __from_next, \ + extern_type* __to, extern_type* __to_end, \ + extern_type*& __to_next) const; \ + \ + virtual result \ + do_unshift(state_type& __state, \ + extern_type* __to, extern_type* __to_end, \ + extern_type*& __to_next) const; \ + \ + virtual result \ + do_in(state_type& __state, \ + const extern_type* __from, const extern_type* __from_end, \ + const extern_type*& __from_next, \ + intern_type* __to, intern_type* __to_end, \ + intern_type*& __to_next) const; \ + \ + virtual \ + int do_encoding() const throw(); \ + \ + virtual \ + bool do_always_noconv() const throw(); \ + \ + virtual \ + int do_length(state_type&, const extern_type* __from, \ + const extern_type* __end, size_t __max) const; \ + \ + virtual int \ + do_max_length() const throw(); \ + \ + private: \ + unsigned long _M_maxcode; \ + codecvt_mode _M_mode; \ + } + +#define _GLIBCXX_CODECVT_SPECIALIZATION(_NAME, _ELEM) \ + _GLIBCXX_CODECVT_SPECIALIZATION2(__ ## _NAME ## _base, _ELEM); \ + template \ + class _NAME<_ELEM, _Maxcode, _Mode> \ + : public __ ## _NAME ## _base<_ELEM> \ + { \ + public: \ + explicit \ + _NAME(size_t __refs = 0) \ + : __ ## _NAME ## _base<_ELEM>(std::min(_Maxcode, 0x10fffful), \ + _Mode, __refs) \ + { } \ + } + + template class __codecvt_utf8_base; + template class __codecvt_utf16_base; + template class __codecvt_utf8_utf16_base; + + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char16_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char16_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char16_t); + + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, char32_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, char32_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, char32_t); + +#ifdef _GLIBCXX_USE_WCHAR_T + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8, wchar_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf16, wchar_t); + _GLIBCXX_CODECVT_SPECIALIZATION(codecvt_utf8_utf16, wchar_t); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif /* _GLIBCXX_CODECVT */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/compare b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/compare new file mode 100755 index 0000000..dd0ec5f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/compare @@ -0,0 +1,925 @@ +// -*- C++ -*- operator<=> three-way comparison support. + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file compare + * This is a Standard C++ Library header. + */ + +#ifndef _COMPARE +#define _COMPARE + +#pragma GCC system_header + +#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L + +#pragma GCC visibility push(default) + +#include + +#if __cpp_lib_concepts +# define __cpp_lib_three_way_comparison 201907L +#endif + +namespace std +{ + // [cmp.categories], comparison category types + + namespace __cmp_cat + { + using type = signed char; + + enum class _Ord : type { equivalent = 0, less = -1, greater = 1 }; + + enum class _Ncmp : type { _Unordered = 2 }; + + struct __unspec + { + constexpr __unspec(__unspec*) noexcept { } + }; + } + + class partial_ordering + { + // less=0xff, equiv=0x00, greater=0x01, unordered=0x02 + __cmp_cat::type _M_value; + + constexpr explicit + partial_ordering(__cmp_cat::_Ord __v) noexcept + : _M_value(__cmp_cat::type(__v)) + { } + + constexpr explicit + partial_ordering(__cmp_cat::_Ncmp __v) noexcept + : _M_value(__cmp_cat::type(__v)) + { } + + friend class weak_ordering; + friend class strong_ordering; + + public: + // valid values + static const partial_ordering less; + static const partial_ordering equivalent; + static const partial_ordering greater; + static const partial_ordering unordered; + + // comparisons + friend constexpr bool + operator==(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 0; } + + friend constexpr bool + operator==(partial_ordering, partial_ordering) noexcept = default; + + friend constexpr bool + operator< (partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == -1; } + + friend constexpr bool + operator> (partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 1; } + + friend constexpr bool + operator<=(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value <= 0; } + + friend constexpr bool + operator>=(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __cmp_cat::type(__v._M_value & 1) == __v._M_value; } + + friend constexpr bool + operator< (__cmp_cat::__unspec, partial_ordering __v) noexcept + { return __v._M_value == 1; } + + friend constexpr bool + operator> (__cmp_cat::__unspec, partial_ordering __v) noexcept + { return __v._M_value == -1; } + + friend constexpr bool + operator<=(__cmp_cat::__unspec, partial_ordering __v) noexcept + { return __cmp_cat::type(__v._M_value & 1) == __v._M_value; } + + friend constexpr bool + operator>=(__cmp_cat::__unspec, partial_ordering __v) noexcept + { return 0 >= __v._M_value; } + + friend constexpr partial_ordering + operator<=>(partial_ordering __v, __cmp_cat::__unspec) noexcept + { return __v; } + + friend constexpr partial_ordering + operator<=>(__cmp_cat::__unspec, partial_ordering __v) noexcept + { + if (__v._M_value & 1) + return partial_ordering(__cmp_cat::_Ord(-__v._M_value)); + else + return __v; + } + }; + + // valid values' definitions + inline constexpr partial_ordering + partial_ordering::less(__cmp_cat::_Ord::less); + + inline constexpr partial_ordering + partial_ordering::equivalent(__cmp_cat::_Ord::equivalent); + + inline constexpr partial_ordering + partial_ordering::greater(__cmp_cat::_Ord::greater); + + inline constexpr partial_ordering + partial_ordering::unordered(__cmp_cat::_Ncmp::_Unordered); + + class weak_ordering + { + __cmp_cat::type _M_value; + + constexpr explicit + weak_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(__cmp_cat::type(__v)) + { } + + friend class strong_ordering; + + public: + // valid values + static const weak_ordering less; + static const weak_ordering equivalent; + static const weak_ordering greater; + + constexpr operator partial_ordering() const noexcept + { return partial_ordering(__cmp_cat::_Ord(_M_value)); } + + // comparisons + friend constexpr bool + operator==(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 0; } + + friend constexpr bool + operator==(weak_ordering, weak_ordering) noexcept = default; + + friend constexpr bool + operator< (weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value < 0; } + + friend constexpr bool + operator> (weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value > 0; } + + friend constexpr bool + operator<=(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value <= 0; } + + friend constexpr bool + operator>=(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value >= 0; } + + friend constexpr bool + operator< (__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 < __v._M_value; } + + friend constexpr bool + operator> (__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 > __v._M_value; } + + friend constexpr bool + operator<=(__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 <= __v._M_value; } + + friend constexpr bool + operator>=(__cmp_cat::__unspec, weak_ordering __v) noexcept + { return 0 >= __v._M_value; } + + friend constexpr weak_ordering + operator<=>(weak_ordering __v, __cmp_cat::__unspec) noexcept + { return __v; } + + friend constexpr weak_ordering + operator<=>(__cmp_cat::__unspec, weak_ordering __v) noexcept + { return weak_ordering(__cmp_cat::_Ord(-__v._M_value)); } + }; + + // valid values' definitions + inline constexpr weak_ordering + weak_ordering::less(__cmp_cat::_Ord::less); + + inline constexpr weak_ordering + weak_ordering::equivalent(__cmp_cat::_Ord::equivalent); + + inline constexpr weak_ordering + weak_ordering::greater(__cmp_cat::_Ord::greater); + + class strong_ordering + { + __cmp_cat::type _M_value; + + constexpr explicit + strong_ordering(__cmp_cat::_Ord __v) noexcept + : _M_value(__cmp_cat::type(__v)) + { } + + public: + // valid values + static const strong_ordering less; + static const strong_ordering equal; + static const strong_ordering equivalent; + static const strong_ordering greater; + + constexpr operator partial_ordering() const noexcept + { return partial_ordering(__cmp_cat::_Ord(_M_value)); } + + constexpr operator weak_ordering() const noexcept + { return weak_ordering(__cmp_cat::_Ord(_M_value)); } + + // comparisons + friend constexpr bool + operator==(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value == 0; } + + friend constexpr bool + operator==(strong_ordering, strong_ordering) noexcept = default; + + friend constexpr bool + operator< (strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value < 0; } + + friend constexpr bool + operator> (strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value > 0; } + + friend constexpr bool + operator<=(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value <= 0; } + + friend constexpr bool + operator>=(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v._M_value >= 0; } + + friend constexpr bool + operator< (__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 < __v._M_value; } + + friend constexpr bool + operator> (__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 > __v._M_value; } + + friend constexpr bool + operator<=(__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 <= __v._M_value; } + + friend constexpr bool + operator>=(__cmp_cat::__unspec, strong_ordering __v) noexcept + { return 0 >= __v._M_value; } + + friend constexpr strong_ordering + operator<=>(strong_ordering __v, __cmp_cat::__unspec) noexcept + { return __v; } + + friend constexpr strong_ordering + operator<=>(__cmp_cat::__unspec, strong_ordering __v) noexcept + { return strong_ordering(__cmp_cat::_Ord(-__v._M_value)); } + }; + + // valid values' definitions + inline constexpr strong_ordering + strong_ordering::less(__cmp_cat::_Ord::less); + + inline constexpr strong_ordering + strong_ordering::equal(__cmp_cat::_Ord::equivalent); + + inline constexpr strong_ordering + strong_ordering::equivalent(__cmp_cat::_Ord::equivalent); + + inline constexpr strong_ordering + strong_ordering::greater(__cmp_cat::_Ord::greater); + + + // named comparison functions + constexpr bool + is_eq(partial_ordering __cmp) noexcept + { return __cmp == 0; } + + constexpr bool + is_neq(partial_ordering __cmp) noexcept + { return __cmp != 0; } + + constexpr bool + is_lt (partial_ordering __cmp) noexcept + { return __cmp < 0; } + + constexpr bool + is_lteq(partial_ordering __cmp) noexcept + { return __cmp <= 0; } + + constexpr bool + is_gt (partial_ordering __cmp) noexcept + { return __cmp > 0; } + + constexpr bool + is_gteq(partial_ordering __cmp) noexcept + { return __cmp >= 0; } + + namespace __detail + { + template + inline constexpr unsigned __cmp_cat_id = 1; + template<> + inline constexpr unsigned __cmp_cat_id = 2; + template<> + inline constexpr unsigned __cmp_cat_id = 4; + template<> + inline constexpr unsigned __cmp_cat_id = 8; + + template + constexpr auto __common_cmp_cat() + { + constexpr unsigned __cats = (__cmp_cat_id<_Ts> | ...); + // If any Ti is not a comparison category type, U is void. + if constexpr (__cats & 1) + return; + // Otherwise, if at least one Ti is std::partial_ordering, + // U is std::partial_ordering. + else if constexpr (bool(__cats & __cmp_cat_id)) + return partial_ordering::equivalent; + // Otherwise, if at least one Ti is std::weak_ordering, + // U is std::weak_ordering. + else if constexpr (bool(__cats & __cmp_cat_id)) + return weak_ordering::equivalent; + // Otherwise, U is std::strong_ordering. + else + return strong_ordering::equivalent; + } + } // namespace __detail + + // [cmp.common], common comparison category type + template + struct common_comparison_category + { + using type = decltype(__detail::__common_cmp_cat<_Ts...>()); + }; + + // Partial specializations for one and zero argument cases. + + template + struct common_comparison_category<_Tp> + { using type = void; }; + + template<> + struct common_comparison_category + { using type = partial_ordering; }; + + template<> + struct common_comparison_category + { using type = weak_ordering; }; + + template<> + struct common_comparison_category + { using type = strong_ordering; }; + + template<> + struct common_comparison_category<> + { using type = strong_ordering; }; + + template + using common_comparison_category_t + = typename common_comparison_category<_Ts...>::type; + +#if __cpp_lib_concepts + namespace __detail + { + template + concept __compares_as + = same_as, _Cat>; + } // namespace __detail + + // [cmp.concept], concept three_way_comparable + template + concept three_way_comparable + = __detail::__weakly_eq_cmp_with<_Tp, _Tp> + && __detail::__partially_ordered_with<_Tp, _Tp> + && requires(const remove_reference_t<_Tp>& __a, + const remove_reference_t<_Tp>& __b) + { + { __a <=> __b } -> __detail::__compares_as<_Cat>; + }; + + template + concept three_way_comparable_with + = three_way_comparable<_Tp, _Cat> + && three_way_comparable<_Up, _Cat> + && common_reference_with&, + const remove_reference_t<_Up>&> + && three_way_comparable< + common_reference_t&, + const remove_reference_t<_Up>&>, _Cat> + && __detail::__weakly_eq_cmp_with<_Tp, _Up> + && __detail::__partially_ordered_with<_Tp, _Up> + && requires(const remove_reference_t<_Tp>& __t, + const remove_reference_t<_Up>& __u) + { + { __t <=> __u } -> __detail::__compares_as<_Cat>; + { __u <=> __t } -> __detail::__compares_as<_Cat>; + }; + + namespace __detail + { + template + using __cmp3way_res_t + = decltype(std::declval<_Tp>() <=> std::declval<_Up>()); + + // Implementation of std::compare_three_way_result. + // It is undefined for a program to add specializations of + // std::compare_three_way_result, so the std::compare_three_way_result_t + // alias ignores std::compare_three_way_result and uses + // __detail::__cmp3way_res_impl directly instead. + template + struct __cmp3way_res_impl + { }; + + template + requires requires { typename __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>; } + struct __cmp3way_res_impl<_Tp, _Up> + { + using type = __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>; + }; + } // namespace __detail + + /// [cmp.result], result of three-way comparison + template + struct compare_three_way_result + : __detail::__cmp3way_res_impl<_Tp, _Up> + { }; + + /// [cmp.result], result of three-way comparison + template + using compare_three_way_result_t + = typename __detail::__cmp3way_res_impl<_Tp, _Up>::type; + + namespace __detail + { + // BUILTIN-PTR-THREE-WAY(T, U) + // This determines whether t <=> u results in a call to a built-in + // operator<=> comparing pointers. It doesn't work for function pointers + // (PR 93628). + template + concept __3way_builtin_ptr_cmp + = requires(_Tp&& __t, _Up&& __u) + { static_cast<_Tp&&>(__t) <=> static_cast<_Up&&>(__u); } + && convertible_to<_Tp, const volatile void*> + && convertible_to<_Up, const volatile void*> + && ! requires(_Tp&& __t, _Up&& __u) + { operator<=>(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); } + && ! requires(_Tp&& __t, _Up&& __u) + { static_cast<_Tp&&>(__t).operator<=>(static_cast<_Up&&>(__u)); }; + } // namespace __detail + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3530 BUILTIN-PTR-MEOW should not opt the type out of syntactic checks + + // [cmp.object], typename compare_three_way + struct compare_three_way + { + template + requires three_way_comparable_with<_Tp, _Up> + constexpr auto + operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(std::declval<_Tp>() <=> std::declval<_Up>())) + { + if constexpr (__detail::__3way_builtin_ptr_cmp<_Tp, _Up>) + { + auto __pt = static_cast(__t); + auto __pu = static_cast(__u); + if (__builtin_is_constant_evaluated()) + return __pt <=> __pu; + auto __it = reinterpret_cast<__UINTPTR_TYPE__>(__pt); + auto __iu = reinterpret_cast<__UINTPTR_TYPE__>(__pu); + return __it <=> __iu; + } + else + return static_cast<_Tp&&>(__t) <=> static_cast<_Up&&>(__u); + } + + using is_transparent = void; + }; + + namespace __cmp_cust + { + template + constexpr weak_ordering + __fp_weak_ordering(_Tp __e, _Tp __f) + { + // Returns an integer with the same sign as the argument, and magnitude + // indicating the classification: zero=1 subnorm=2 norm=3 inf=4 nan=5 + auto __cat = [](_Tp __fp) -> int { + const int __sign = __builtin_signbit(__fp) ? -1 : 1; + if (__builtin_isnormal(__fp)) + return (__fp == 0 ? 1 : 3) * __sign; + if (__builtin_isnan(__fp)) + return 5 * __sign; + if (int __inf = __builtin_isinf_sign(__fp)) + return 4 * __inf; + return 2 * __sign; + }; + + auto __po = __e <=> __f; + if (is_lt(__po)) + return weak_ordering::less; + else if (is_gt(__po)) + return weak_ordering::greater; + else if (__po == partial_ordering::equivalent) + return weak_ordering::equivalent; + else // unordered, at least one argument is NaN + { + // return -1 for negative nan, +1 for positive nan, 0 otherwise. + auto __isnan_sign = [](_Tp __fp) -> int { + return __builtin_isnan(__fp) + ? __builtin_signbit(__fp) ? -1 : 1 + : 0; + }; + auto __ord = __isnan_sign(__e) <=> __isnan_sign(__f); + if (is_eq(__ord)) + return weak_ordering::equivalent; + else if (is_lt(__ord)) + return weak_ordering::less; + else + return weak_ordering::greater; + } + } + + template + concept __adl_strong = requires(_Tp&& __t, _Up&& __u) + { + strong_ordering(strong_order(static_cast<_Tp&&>(__t), + static_cast<_Up&&>(__u))); + }; + + template + concept __adl_weak = requires(_Tp&& __t, _Up&& __u) + { + weak_ordering(weak_order(static_cast<_Tp&&>(__t), + static_cast<_Up&&>(__u))); + }; + + template + concept __adl_partial = requires(_Tp&& __t, _Up&& __u) + { + partial_ordering(partial_order(static_cast<_Tp&&>(__t), + static_cast<_Up&&>(__u))); + }; + + template + concept __cmp3way = requires(_Tp&& __t, _Up&& __u, compare_three_way __c) + { + _Ord(__c(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u))); + }; + + template + concept __strongly_ordered + = __adl_strong<_Tp, _Up> + // FIXME: || floating_point> + || __cmp3way; + + template + concept __decayed_same_as = same_as, decay_t<_Up>>; + + class _Strong_order + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (floating_point>) + return true; + else if constexpr (__adl_strong<_Tp, _Up>) + return noexcept(strong_ordering(strong_order(std::declval<_Tp>(), + std::declval<_Up>()))); + else if constexpr (__cmp3way) + return noexcept(compare_three_way()(std::declval<_Tp>(), + std::declval<_Up>())); + } + + friend class _Weak_order; + friend class _Strong_fallback; + + public: + template _Up> + requires __strongly_ordered<_Tp, _Up> + constexpr strong_ordering + operator()(_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + /* FIXME: + if constexpr (floating_point>) + return __cmp_cust::__fp_strong_order(__e, __f); + else */ if constexpr (__adl_strong<_Tp, _Up>) + return strong_ordering(strong_order(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f))); + else if constexpr (__cmp3way) + return compare_three_way()(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + } + }; + + template + concept __weakly_ordered + = floating_point> + || __adl_weak<_Tp, _Up> + || __cmp3way + || __strongly_ordered<_Tp, _Up>; + + class _Weak_order + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (floating_point>) + return true; + else if constexpr (__adl_weak<_Tp, _Up>) + return noexcept(weak_ordering(weak_order(std::declval<_Tp>(), + std::declval<_Up>()))); + else if constexpr (__cmp3way) + return noexcept(compare_three_way()(std::declval<_Tp>(), + std::declval<_Up>())); + else if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order::_S_noexcept<_Tp, _Up>(); + } + + friend class _Partial_order; + friend class _Weak_fallback; + + public: + template _Up> + requires __weakly_ordered<_Tp, _Up> + constexpr weak_ordering + operator()(_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (floating_point>) + return __cmp_cust::__fp_weak_ordering(__e, __f); + else if constexpr (__adl_weak<_Tp, _Up>) + return weak_ordering(weak_order(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f))); + else if constexpr (__cmp3way) + return compare_three_way()(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + } + }; + + template + concept __partially_ordered + = __adl_partial<_Tp, _Up> + || __cmp3way + || __weakly_ordered<_Tp, _Up>; + + class _Partial_order + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_partial<_Tp, _Up>) + return noexcept(partial_ordering(partial_order(std::declval<_Tp>(), + std::declval<_Up>()))); + else if constexpr (__cmp3way) + return noexcept(compare_three_way()(std::declval<_Tp>(), + std::declval<_Up>())); + else if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order::_S_noexcept<_Tp, _Up>(); + } + + friend class _Partial_fallback; + + public: + template _Up> + requires __partially_ordered<_Tp, _Up> + constexpr partial_ordering + operator()(_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__adl_partial<_Tp, _Up>) + return partial_ordering(partial_order(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f))); + else if constexpr (__cmp3way) + return compare_three_way()(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + } + }; + + template + concept __op_eq_lt = requires(_Tp&& __t, _Up&& __u) + { + { static_cast<_Tp&&>(__t) == static_cast<_Up&&>(__u) } + -> convertible_to; + { static_cast<_Tp&&>(__t) < static_cast<_Up&&>(__u) } + -> convertible_to; + }; + + class _Strong_fallback + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order::_S_noexcept<_Tp, _Up>(); + else + return noexcept(bool(std::declval<_Tp>() == std::declval<_Up>())) + && noexcept(bool(std::declval<_Tp>() < std::declval<_Up>())); + } + + public: + template _Up> + requires __strongly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> + constexpr strong_ordering + operator()(_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__strongly_ordered<_Tp, _Up>) + return _Strong_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else // __op_eq_lt<_Tp, _Up> + return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) + ? strong_ordering::equal + : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) + ? strong_ordering::less + : strong_ordering::greater; + } + }; + + class _Weak_fallback + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order::_S_noexcept<_Tp, _Up>(); + else + return noexcept(bool(std::declval<_Tp>() == std::declval<_Up>())) + && noexcept(bool(std::declval<_Tp>() < std::declval<_Up>())); + } + + public: + template _Up> + requires __weakly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> + constexpr weak_ordering + operator()(_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__weakly_ordered<_Tp, _Up>) + return _Weak_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else // __op_eq_lt<_Tp, _Up> + return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) + ? weak_ordering::equivalent + : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) + ? weak_ordering::less + : weak_ordering::greater; + } + }; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3465. compare_partial_order_fallback requires F < E + template + concept __op_eq_lt_lt = __op_eq_lt<_Tp, _Up> + && requires(_Tp&& __t, _Up&& __u) + { + { static_cast<_Up&&>(__u) < static_cast<_Tp&&>(__t) } + -> convertible_to; + }; + + class _Partial_fallback + { + template + static constexpr bool + _S_noexcept() + { + if constexpr (__partially_ordered<_Tp, _Up>) + return _Partial_order::_S_noexcept<_Tp, _Up>(); + else + return noexcept(bool(std::declval<_Tp>() == std::declval<_Up>())) + && noexcept(bool(std::declval<_Tp>() < std::declval<_Up>())); + } + + public: + template _Up> + requires __partially_ordered<_Tp, _Up> || __op_eq_lt_lt<_Tp, _Up> + constexpr partial_ordering + operator()(_Tp&& __e, _Up&& __f) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__partially_ordered<_Tp, _Up>) + return _Partial_order{}(static_cast<_Tp&&>(__e), + static_cast<_Up&&>(__f)); + else // __op_eq_lt_lt<_Tp, _Up> + return static_cast<_Tp&&>(__e) == static_cast<_Up&&>(__f) + ? partial_ordering::equivalent + : static_cast<_Tp&&>(__e) < static_cast<_Up&&>(__f) + ? partial_ordering::less + : static_cast<_Up&&>(__f) < static_cast<_Tp&&>(__e) + ? partial_ordering::greater + : partial_ordering::unordered; + } + }; + } // namespace __cmp_cust + + // [cmp.alg], comparison algorithms + inline namespace __cmp_alg + { + inline constexpr __cmp_cust::_Strong_order strong_order{}; + + inline constexpr __cmp_cust::_Weak_order weak_order{}; + + inline constexpr __cmp_cust::_Partial_order partial_order{}; + + inline constexpr __cmp_cust::_Strong_fallback + compare_strong_order_fallback{}; + + inline constexpr __cmp_cust::_Weak_fallback + compare_weak_order_fallback{}; + + inline constexpr __cmp_cust::_Partial_fallback + compare_partial_order_fallback{}; + } + + namespace __detail + { + // [expos.only.func] synth-three-way + inline constexpr struct _Synth3way + { + template + static constexpr bool + _S_noexcept(const _Tp* __t = nullptr, const _Up* __u = nullptr) + { + if constexpr (three_way_comparable_with<_Tp, _Up>) + return noexcept(*__t <=> *__u); + else + return noexcept(*__t < *__u) && noexcept(*__u < *__t); + } + + template + constexpr auto + operator()(const _Tp& __t, const _Up& __u) const + noexcept(_S_noexcept<_Tp, _Up>()) + requires requires + { + { __t < __u } -> __boolean_testable; + { __u < __t } -> __boolean_testable; + } + { + if constexpr (three_way_comparable_with<_Tp, _Up>) + return __t <=> __u; + else + { + if (__t < __u) + return weak_ordering::less; + else if (__u < __t) + return weak_ordering::greater; + else + return weak_ordering::equivalent; + } + } + } __synth3way = {}; + + // [expos.only.func] synth-three-way-result + template + using __synth3way_t + = decltype(__detail::__synth3way(std::declval<_Tp&>(), + std::declval<_Up&>())); + } // namespace __detail +#endif // concepts +} // namespace std + +#pragma GCC visibility pop + +#endif // C++20 + +#endif // _COMPARE diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/complex b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/complex new file mode 100755 index 0000000..c2f6421 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/complex @@ -0,0 +1,2024 @@ +// The template and inlines for the -*- C++ -*- complex number classes. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/complex + * This is a Standard C++ Library header. + */ + +// +// ISO C++ 14882: 26.2 Complex Numbers +// Note: this is not a conforming implementation. +// Initially implemented by Ulrich Drepper +// Improved by Gabriel Dos Reis +// + +#ifndef _GLIBCXX_COMPLEX +#define _GLIBCXX_COMPLEX 1 + +#pragma GCC system_header + +#include +#include +#include +#include +#include + +// Get rid of a macro possibly defined in +#undef complex + +#if __cplusplus > 201703L +# define __cpp_lib_constexpr_complex 201711L +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup complex_numbers Complex Numbers + * @ingroup numerics + * + * Classes and functions for complex numbers. + * @{ + */ + + // Forward declarations. + template class complex; + template<> class complex; + template<> class complex; + template<> class complex; + + /// Return magnitude of @a z. + template _Tp abs(const complex<_Tp>&); + /// Return phase angle of @a z. + template _Tp arg(const complex<_Tp>&); + /// Return @a z magnitude squared. + template _Tp _GLIBCXX20_CONSTEXPR norm(const complex<_Tp>&); + + /// Return complex conjugate of @a z. + template + _GLIBCXX20_CONSTEXPR complex<_Tp> conj(const complex<_Tp>&); + /// Return complex with magnitude @a rho and angle @a theta. + template complex<_Tp> polar(const _Tp&, const _Tp& = 0); + + // Transcendentals: + /// Return complex cosine of @a z. + template complex<_Tp> cos(const complex<_Tp>&); + /// Return complex hyperbolic cosine of @a z. + template complex<_Tp> cosh(const complex<_Tp>&); + /// Return complex base e exponential of @a z. + template complex<_Tp> exp(const complex<_Tp>&); + /// Return complex natural logarithm of @a z. + template complex<_Tp> log(const complex<_Tp>&); + /// Return complex base 10 logarithm of @a z. + template complex<_Tp> log10(const complex<_Tp>&); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const complex<_Tp>&, int); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const complex<_Tp>&, const _Tp&); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const complex<_Tp>&, + const complex<_Tp>&); + /// Return @a x to the @a y'th power. + template complex<_Tp> pow(const _Tp&, const complex<_Tp>&); + /// Return complex sine of @a z. + template complex<_Tp> sin(const complex<_Tp>&); + /// Return complex hyperbolic sine of @a z. + template complex<_Tp> sinh(const complex<_Tp>&); + /// Return complex square root of @a z. + template complex<_Tp> sqrt(const complex<_Tp>&); + /// Return complex tangent of @a z. + template complex<_Tp> tan(const complex<_Tp>&); + /// Return complex hyperbolic tangent of @a z. + template complex<_Tp> tanh(const complex<_Tp>&); + + + // 26.2.2 Primary template class complex + /** + * Template to represent complex numbers. + * + * Specializations for float, double, and long double are part of the + * library. Results with any other type are not guaranteed. + * + * @param Tp Type of real and imaginary values. + */ + template + class complex + { + public: + /// Value typedef. + typedef _Tp value_type; + + /// Default constructor. First parameter is x, second parameter is y. + /// Unspecified parameters default to 0. + _GLIBCXX_CONSTEXPR complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp()) + : _M_real(__r), _M_imag(__i) { } + + // Let the compiler synthesize the copy constructor +#if __cplusplus >= 201103L + constexpr complex(const complex&) = default; +#endif + + /// Converting constructor. + template + _GLIBCXX_CONSTEXPR complex(const complex<_Up>& __z) + : _M_real(__z.real()), _M_imag(__z.imag()) { } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX_ABI_TAG_CXX11 + constexpr _Tp + real() const { return _M_real; } + + _GLIBCXX_ABI_TAG_CXX11 + constexpr _Tp + imag() const { return _M_imag; } +#else + /// Return real part of complex number. + _Tp& + real() { return _M_real; } + + /// Return real part of complex number. + const _Tp& + real() const { return _M_real; } + + /// Return imaginary part of complex number. + _Tp& + imag() { return _M_imag; } + + /// Return imaginary part of complex number. + const _Tp& + imag() const { return _M_imag; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(_Tp __val) { _M_real = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(_Tp __val) { _M_imag = __val; } + + /// Assign a scalar to this complex number. + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator=(const _Tp&); + + /// Add a scalar to this complex number. + // 26.2.5/1 + _GLIBCXX20_CONSTEXPR complex<_Tp>& + operator+=(const _Tp& __t) + { + _M_real += __t; + return *this; + } + + /// Subtract a scalar from this complex number. + // 26.2.5/3 + _GLIBCXX20_CONSTEXPR complex<_Tp>& + operator-=(const _Tp& __t) + { + _M_real -= __t; + return *this; + } + + /// Multiply this complex number by a scalar. + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator*=(const _Tp&); + /// Divide this complex number by a scalar. + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator/=(const _Tp&); + + // Let the compiler synthesize the copy assignment operator +#if __cplusplus >= 201103L + _GLIBCXX20_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + /// Assign another complex number to this one. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator=(const complex<_Up>&); + /// Add another complex number to this one. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator+=(const complex<_Up>&); + /// Subtract another complex number from this one. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator-=(const complex<_Up>&); + /// Multiply this complex number by another. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator*=(const complex<_Up>&); + /// Divide this complex number by another. + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& operator/=(const complex<_Up>&); + + _GLIBCXX_CONSTEXPR complex __rep() const + { return *this; } + + private: + _Tp _M_real; + _Tp _M_imag; + }; + + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator=(const _Tp& __t) + { + _M_real = __t; + _M_imag = _Tp(); + return *this; + } + + // 26.2.5/5 + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator*=(const _Tp& __t) + { + _M_real *= __t; + _M_imag *= __t; + return *this; + } + + // 26.2.5/7 + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator/=(const _Tp& __t) + { + _M_real /= __t; + _M_imag /= __t; + return *this; + } + + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator=(const complex<_Up>& __z) + { + _M_real = __z.real(); + _M_imag = __z.imag(); + return *this; + } + + // 26.2.5/9 + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator+=(const complex<_Up>& __z) + { + _M_real += __z.real(); + _M_imag += __z.imag(); + return *this; + } + + // 26.2.5/11 + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator-=(const complex<_Up>& __z) + { + _M_real -= __z.real(); + _M_imag -= __z.imag(); + return *this; + } + + // 26.2.5/13 + // XXX: This is a grammar school implementation. + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator*=(const complex<_Up>& __z) + { + const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag(); + _M_imag = _M_real * __z.imag() + _M_imag * __z.real(); + _M_real = __r; + return *this; + } + + // 26.2.5/15 + // XXX: This is a grammar school implementation. + template + template + _GLIBCXX20_CONSTEXPR complex<_Tp>& + complex<_Tp>::operator/=(const complex<_Up>& __z) + { + const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag(); + const _Tp __n = std::norm(__z); + _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n; + _M_real = __r / __n; + return *this; + } + + // Operators: + ///@{ + /// Return new complex value @a x plus @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r += __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __y; + __r += __x; + return __r; + } + ///@} + + ///@{ + /// Return new complex value @a x minus @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r -= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = -__y; + __r += __x; + return __r; + } + ///@} + + ///@{ + /// Return new complex value @a x times @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator*(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r *= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator*(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __y; + __r *= __x; + return __r; + } + ///@} + + ///@{ + /// Return new complex value @a x divided by @a y. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator/(const complex<_Tp>& __x, const _Tp& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator/(const _Tp& __x, const complex<_Tp>& __y) + { + complex<_Tp> __r = __x; + __r /= __y; + return __r; + } + ///@} + + /// Return @a x. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator+(const complex<_Tp>& __x) + { return __x; } + + /// Return complex negation of @a x. + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + operator-(const complex<_Tp>& __x) + { return complex<_Tp>(-__x.real(), -__x.imag()); } + + ///@{ + /// Return true if @a x is equal to @a y. + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x.real() == __y.real() && __x.imag() == __y.imag(); } + + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const complex<_Tp>& __x, const _Tp& __y) + { return __x.real() == __y && __x.imag() == _Tp(); } + +#if !(__cpp_impl_three_way_comparison >= 201907L) + template + inline _GLIBCXX_CONSTEXPR bool + operator==(const _Tp& __x, const complex<_Tp>& __y) + { return __x == __y.real() && _Tp() == __y.imag(); } + ///@} + + ///@{ + /// Return false if @a x is equal to @a y. + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x.real() != __y.real() || __x.imag() != __y.imag(); } + + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const complex<_Tp>& __x, const _Tp& __y) + { return __x.real() != __y || __x.imag() != _Tp(); } + + template + inline _GLIBCXX_CONSTEXPR bool + operator!=(const _Tp& __x, const complex<_Tp>& __y) + { return __x != __y.real() || _Tp() != __y.imag(); } +#endif + ///@} + + /// Extraction operator for complex values. + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) + { + bool __fail = true; + _CharT __ch; + if (__is >> __ch) + { + if (_Traits::eq(__ch, __is.widen('('))) + { + _Tp __u; + if (__is >> __u >> __ch) + { + const _CharT __rparen = __is.widen(')'); + if (_Traits::eq(__ch, __rparen)) + { + __x = __u; + __fail = false; + } + else if (_Traits::eq(__ch, __is.widen(','))) + { + _Tp __v; + if (__is >> __v >> __ch) + { + if (_Traits::eq(__ch, __rparen)) + { + __x = complex<_Tp>(__u, __v); + __fail = false; + } + else + __is.putback(__ch); + } + } + else + __is.putback(__ch); + } + } + else + { + __is.putback(__ch); + _Tp __u; + if (__is >> __u) + { + __x = __u; + __fail = false; + } + } + } + if (__fail) + __is.setstate(ios_base::failbit); + return __is; + } + + /// Insertion operator for complex values. + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) + { + basic_ostringstream<_CharT, _Traits> __s; + __s.flags(__os.flags()); + __s.imbue(__os.getloc()); + __s.precision(__os.precision()); + __s << '(' << __x.real() << ',' << __x.imag() << ')'; + return __os << __s.str(); + } + + // Values +#if __cplusplus >= 201103L + template + constexpr _Tp + real(const complex<_Tp>& __z) + { return __z.real(); } + + template + constexpr _Tp + imag(const complex<_Tp>& __z) + { return __z.imag(); } +#else + template + inline _Tp& + real(complex<_Tp>& __z) + { return __z.real(); } + + template + inline const _Tp& + real(const complex<_Tp>& __z) + { return __z.real(); } + + template + inline _Tp& + imag(complex<_Tp>& __z) + { return __z.imag(); } + + template + inline const _Tp& + imag(const complex<_Tp>& __z) + { return __z.imag(); } +#endif + + // 26.2.7/3 abs(__z): Returns the magnitude of __z. + template + inline _Tp + __complex_abs(const complex<_Tp>& __z) + { + _Tp __x = __z.real(); + _Tp __y = __z.imag(); + const _Tp __s = std::max(abs(__x), abs(__y)); + if (__s == _Tp()) // well ... + return __s; + __x /= __s; + __y /= __s; + return __s * sqrt(__x * __x + __y * __y); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline float + __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); } + + inline double + __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); } + + inline long double + __complex_abs(const __complex__ long double& __z) + { return __builtin_cabsl(__z); } + + template + inline _Tp + abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } +#else + template + inline _Tp + abs(const complex<_Tp>& __z) { return __complex_abs(__z); } +#endif + + + // 26.2.7/4: arg(__z): Returns the phase angle of __z. + template + inline _Tp + __complex_arg(const complex<_Tp>& __z) + { return atan2(__z.imag(), __z.real()); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline float + __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); } + + inline double + __complex_arg(__complex__ double __z) { return __builtin_carg(__z); } + + inline long double + __complex_arg(const __complex__ long double& __z) + { return __builtin_cargl(__z); } + + template + inline _Tp + arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); } +#else + template + inline _Tp + arg(const complex<_Tp>& __z) { return __complex_arg(__z); } +#endif + + // 26.2.7/5: norm(__z) returns the squared magnitude of __z. + // As defined, norm() is -not- a norm is the common mathematical + // sense used in numerics. The helper class _Norm_helper<> tries to + // distinguish between builtin floating point and the rest, so as + // to deliver an answer as close as possible to the real value. + template + struct _Norm_helper + { + template + static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return __x * __x + __y * __y; + } + }; + + template<> + struct _Norm_helper + { + template + static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) + { + //_Tp __res = std::abs(__z); + //return __res * __res; + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return __x * __x + __y * __y; + } + }; + + template + inline _GLIBCXX20_CONSTEXPR _Tp + norm(const complex<_Tp>& __z) + { + return _Norm_helper<__is_floating<_Tp>::__value + && !_GLIBCXX_FAST_MATH>::_S_do_it(__z); + } + + template + inline complex<_Tp> + polar(const _Tp& __rho, const _Tp& __theta) + { + __glibcxx_assert( __rho >= 0 ); + return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); + } + + template + inline _GLIBCXX20_CONSTEXPR complex<_Tp> + conj(const complex<_Tp>& __z) + { return complex<_Tp>(__z.real(), -__z.imag()); } + + // Transcendentals + + // 26.2.8/1 cos(__z): Returns the cosine of __z. + template + inline complex<_Tp> + __complex_cos(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); } + + inline __complex__ double + __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); } + + inline __complex__ long double + __complex_cos(const __complex__ long double& __z) + { return __builtin_ccosl(__z); } + + template + inline complex<_Tp> + cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); } +#else + template + inline complex<_Tp> + cos(const complex<_Tp>& __z) { return __complex_cos(__z); } +#endif + + // 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z. + template + inline complex<_Tp> + __complex_cosh(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); } + + inline __complex__ double + __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); } + + inline __complex__ long double + __complex_cosh(const __complex__ long double& __z) + { return __builtin_ccoshl(__z); } + + template + inline complex<_Tp> + cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); } +#else + template + inline complex<_Tp> + cosh(const complex<_Tp>& __z) { return __complex_cosh(__z); } +#endif + + // 26.2.8/3 exp(__z): Returns the complex base e exponential of x + template + inline complex<_Tp> + __complex_exp(const complex<_Tp>& __z) + { return std::polar<_Tp>(exp(__z.real()), __z.imag()); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); } + + inline __complex__ double + __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); } + + inline __complex__ long double + __complex_exp(const __complex__ long double& __z) + { return __builtin_cexpl(__z); } + + template + inline complex<_Tp> + exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); } +#else + template + inline complex<_Tp> + exp(const complex<_Tp>& __z) { return __complex_exp(__z); } +#endif + + // 26.2.8/5 log(__z): Returns the natural complex logarithm of __z. + // The branch cut is along the negative axis. + template + inline complex<_Tp> + __complex_log(const complex<_Tp>& __z) + { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_log(__complex__ float __z) { return __builtin_clogf(__z); } + + inline __complex__ double + __complex_log(__complex__ double __z) { return __builtin_clog(__z); } + + inline __complex__ long double + __complex_log(const __complex__ long double& __z) + { return __builtin_clogl(__z); } + + template + inline complex<_Tp> + log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); } +#else + template + inline complex<_Tp> + log(const complex<_Tp>& __z) { return __complex_log(__z); } +#endif + + template + inline complex<_Tp> + log10(const complex<_Tp>& __z) + { return std::log(__z) / log(_Tp(10.0)); } + + // 26.2.8/10 sin(__z): Returns the sine of __z. + template + inline complex<_Tp> + __complex_sin(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); } + + inline __complex__ double + __complex_sin(__complex__ double __z) { return __builtin_csin(__z); } + + inline __complex__ long double + __complex_sin(const __complex__ long double& __z) + { return __builtin_csinl(__z); } + + template + inline complex<_Tp> + sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); } +#else + template + inline complex<_Tp> + sin(const complex<_Tp>& __z) { return __complex_sin(__z); } +#endif + + // 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z. + template + inline complex<_Tp> + __complex_sinh(const complex<_Tp>& __z) + { + const _Tp __x = __z.real(); + const _Tp __y = __z.imag(); + return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y)); + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); } + + inline __complex__ double + __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); } + + inline __complex__ long double + __complex_sinh(const __complex__ long double& __z) + { return __builtin_csinhl(__z); } + + template + inline complex<_Tp> + sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); } +#else + template + inline complex<_Tp> + sinh(const complex<_Tp>& __z) { return __complex_sinh(__z); } +#endif + + // 26.2.8/13 sqrt(__z): Returns the complex square root of __z. + // The branch cut is on the negative axis. + template + complex<_Tp> + __complex_sqrt(const complex<_Tp>& __z) + { + _Tp __x = __z.real(); + _Tp __y = __z.imag(); + + if (__x == _Tp()) + { + _Tp __t = sqrt(abs(__y) / 2); + return complex<_Tp>(__t, __y < _Tp() ? -__t : __t); + } + else + { + _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x))); + _Tp __u = __t / 2; + return __x > _Tp() + ? complex<_Tp>(__u, __y / __t) + : complex<_Tp>(abs(__y) / __t, __y < _Tp() ? -__u : __u); + } + } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); } + + inline __complex__ double + __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); } + + inline __complex__ long double + __complex_sqrt(const __complex__ long double& __z) + { return __builtin_csqrtl(__z); } + + template + inline complex<_Tp> + sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); } +#else + template + inline complex<_Tp> + sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z); } +#endif + + // 26.2.8/14 tan(__z): Return the complex tangent of __z. + + template + inline complex<_Tp> + __complex_tan(const complex<_Tp>& __z) + { return std::sin(__z) / std::cos(__z); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); } + + inline __complex__ double + __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); } + + inline __complex__ long double + __complex_tan(const __complex__ long double& __z) + { return __builtin_ctanl(__z); } + + template + inline complex<_Tp> + tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); } +#else + template + inline complex<_Tp> + tan(const complex<_Tp>& __z) { return __complex_tan(__z); } +#endif + + + // 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z. + + template + inline complex<_Tp> + __complex_tanh(const complex<_Tp>& __z) + { return std::sinh(__z) / std::cosh(__z); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); } + + inline __complex__ double + __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); } + + inline __complex__ long double + __complex_tanh(const __complex__ long double& __z) + { return __builtin_ctanhl(__z); } + + template + inline complex<_Tp> + tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); } +#else + template + inline complex<_Tp> + tanh(const complex<_Tp>& __z) { return __complex_tanh(__z); } +#endif + + + // 26.2.8/9 pow(__x, __y): Returns the complex power base of __x + // raised to the __y-th power. The branch + // cut is on the negative axis. + template + complex<_Tp> + __complex_pow_unsigned(complex<_Tp> __x, unsigned __n) + { + complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1); + + while (__n >>= 1) + { + __x *= __x; + if (__n % 2) + __y *= __x; + } + + return __y; + } + + // In C++11 mode we used to implement the resolution of + // DR 844. complex pow return type is ambiguous. + // thus the following overload was disabled in that mode. However, doing + // that causes all sorts of issues, see, for example: + // http://gcc.gnu.org/ml/libstdc++/2013-01/msg00058.html + // and also PR57974. + template + inline complex<_Tp> + pow(const complex<_Tp>& __z, int __n) + { + return __n < 0 + ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(unsigned)__n) + : std::__complex_pow_unsigned(__z, __n); + } + + template + complex<_Tp> + pow(const complex<_Tp>& __x, const _Tp& __y) + { +#if ! _GLIBCXX_USE_C99_COMPLEX + if (__x == _Tp()) + return _Tp(); +#endif + if (__x.imag() == _Tp() && __x.real() > _Tp()) + return pow(__x.real(), __y); + + complex<_Tp> __t = std::log(__x); + return std::polar<_Tp>(exp(__y * __t.real()), __y * __t.imag()); + } + + template + inline complex<_Tp> + __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); } + +#if _GLIBCXX_USE_C99_COMPLEX + inline __complex__ float + __complex_pow(__complex__ float __x, __complex__ float __y) + { return __builtin_cpowf(__x, __y); } + + inline __complex__ double + __complex_pow(__complex__ double __x, __complex__ double __y) + { return __builtin_cpow(__x, __y); } + + inline __complex__ long double + __complex_pow(const __complex__ long double& __x, + const __complex__ long double& __y) + { return __builtin_cpowl(__x, __y); } + + template + inline complex<_Tp> + pow(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __complex_pow(__x.__rep(), __y.__rep()); } +#else + template + inline complex<_Tp> + pow(const complex<_Tp>& __x, const complex<_Tp>& __y) + { return __complex_pow(__x, __y); } +#endif + + template + inline complex<_Tp> + pow(const _Tp& __x, const complex<_Tp>& __y) + { + return __x > _Tp() ? std::polar<_Tp>(pow(__x, __y.real()), + __y.imag() * log(__x)) + : std::pow(complex<_Tp>(__x), __y); + } + + /// 26.2.3 complex specializations + /// complex specialization + template<> + class complex + { + public: + typedef float value_type; + typedef __complex__ float _ComplexT; + + _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } + + _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f) +#if __cplusplus >= 201103L + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif + + explicit _GLIBCXX_CONSTEXPR complex(const complex&); + explicit _GLIBCXX_CONSTEXPR complex(const complex&); + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + __attribute ((__abi_tag__ ("cxx11"))) + constexpr float + real() const { return __real__ _M_value; } + + __attribute ((__abi_tag__ ("cxx11"))) + constexpr float + imag() const { return __imag__ _M_value; } +#else + float& + real() { return __real__ _M_value; } + + const float& + real() const { return __real__ _M_value; } + + float& + imag() { return __imag__ _M_value; } + + const float& + imag() const { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(float __val) { __real__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(float __val) { __imag__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR complex& + operator=(float __f) + { + _M_value = __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator+=(float __f) + { + _M_value += __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator-=(float __f) + { + _M_value -= __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator*=(float __f) + { + _M_value *= __f; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator/=(float __f) + { + _M_value /= __f; + return *this; + } + + // Let the compiler synthesize the copy and assignment + // operator. It always does a pretty good job. +#if __cplusplus >= 201103L + _GLIBCXX14_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR complex& + operator=(const complex<_Tp>& __z) + { + __real__ _M_value = __z.real(); + __imag__ _M_value = __z.imag(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator+=(const complex<_Tp>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator-=(const complex<_Tp>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator*=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator/=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + _GLIBCXX_CONSTEXPR _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + /// 26.2.3 complex specializations + /// complex specialization + template<> + class complex + { + public: + typedef double value_type; + typedef __complex__ double _ComplexT; + + _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } + + _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0) +#if __cplusplus >= 201103L + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif + + _GLIBCXX_CONSTEXPR complex(const complex& __z) + : _M_value(__z.__rep()) { } + + explicit _GLIBCXX_CONSTEXPR complex(const complex&); + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + __attribute ((__abi_tag__ ("cxx11"))) + constexpr double + real() const { return __real__ _M_value; } + + __attribute ((__abi_tag__ ("cxx11"))) + constexpr double + imag() const { return __imag__ _M_value; } +#else + double& + real() { return __real__ _M_value; } + + const double& + real() const { return __real__ _M_value; } + + double& + imag() { return __imag__ _M_value; } + + const double& + imag() const { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(double __val) { __real__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(double __val) { __imag__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR complex& + operator=(double __d) + { + _M_value = __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator+=(double __d) + { + _M_value += __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator-=(double __d) + { + _M_value -= __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator*=(double __d) + { + _M_value *= __d; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator/=(double __d) + { + _M_value /= __d; + return *this; + } + + // The compiler will synthesize this, efficiently. +#if __cplusplus >= 201103L + _GLIBCXX14_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR complex& + operator=(const complex<_Tp>& __z) + { + _M_value = __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator+=(const complex<_Tp>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator-=(const complex<_Tp>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator*=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator/=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + _GLIBCXX_CONSTEXPR _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + /// 26.2.3 complex specializations + /// complex specialization + template<> + class complex + { + public: + typedef long double value_type; + typedef __complex__ long double _ComplexT; + + _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { } + + _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L, + long double __i = 0.0L) +#if __cplusplus >= 201103L + : _M_value{ __r, __i } { } +#else + { + __real__ _M_value = __r; + __imag__ _M_value = __i; + } +#endif + + _GLIBCXX_CONSTEXPR complex(const complex& __z) + : _M_value(__z.__rep()) { } + + _GLIBCXX_CONSTEXPR complex(const complex& __z) + : _M_value(__z.__rep()) { } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + __attribute ((__abi_tag__ ("cxx11"))) + constexpr long double + real() const { return __real__ _M_value; } + + __attribute ((__abi_tag__ ("cxx11"))) + constexpr long double + imag() const { return __imag__ _M_value; } +#else + long double& + real() { return __real__ _M_value; } + + const long double& + real() const { return __real__ _M_value; } + + long double& + imag() { return __imag__ _M_value; } + + const long double& + imag() const { return __imag__ _M_value; } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 387. std::complex over-encapsulated. + _GLIBCXX20_CONSTEXPR void + real(long double __val) { __real__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR void + imag(long double __val) { __imag__ _M_value = __val; } + + _GLIBCXX20_CONSTEXPR complex& + operator=(long double __r) + { + _M_value = __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator+=(long double __r) + { + _M_value += __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator-=(long double __r) + { + _M_value -= __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator*=(long double __r) + { + _M_value *= __r; + return *this; + } + + _GLIBCXX20_CONSTEXPR complex& + operator/=(long double __r) + { + _M_value /= __r; + return *this; + } + + // The compiler knows how to do this efficiently +#if __cplusplus >= 201103L + _GLIBCXX14_CONSTEXPR complex& operator=(const complex&) = default; +#endif + + template + _GLIBCXX20_CONSTEXPR complex& + operator=(const complex<_Tp>& __z) + { + _M_value = __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator+=(const complex<_Tp>& __z) + { + _M_value += __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator-=(const complex<_Tp>& __z) + { + _M_value -= __z.__rep(); + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator*=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value *= __t; + return *this; + } + + template + _GLIBCXX20_CONSTEXPR complex& + operator/=(const complex<_Tp>& __z) + { + const _ComplexT __t = __z.__rep(); + _M_value /= __t; + return *this; + } + + _GLIBCXX_CONSTEXPR _ComplexT __rep() const { return _M_value; } + + private: + _ComplexT _M_value; + }; + + // These bits have to be at the end of this file, so that the + // specializations have all been defined. + inline _GLIBCXX_CONSTEXPR + complex::complex(const complex& __z) + : _M_value(__z.__rep()) { } + + inline _GLIBCXX_CONSTEXPR + complex::complex(const complex& __z) + : _M_value(__z.__rep()) { } + + inline _GLIBCXX_CONSTEXPR + complex::complex(const complex& __z) + : _M_value(__z.__rep()) { } + + // Inhibit implicit instantiations for required instantiations, + // which are defined via explicit instantiations elsewhere. + // NB: This syntax is a GNU extension. +#if _GLIBCXX_EXTERN_TEMPLATE + extern template istream& operator>>(istream&, complex&); + extern template ostream& operator<<(ostream&, const complex&); + extern template istream& operator>>(istream&, complex&); + extern template ostream& operator<<(ostream&, const complex&); + extern template istream& operator>>(istream&, complex&); + extern template ostream& operator<<(ostream&, const complex&); + +#ifdef _GLIBCXX_USE_WCHAR_T + extern template wistream& operator>>(wistream&, complex&); + extern template wostream& operator<<(wostream&, const complex&); + extern template wistream& operator>>(wistream&, complex&); + extern template wostream& operator<<(wostream&, const complex&); + extern template wistream& operator>>(wistream&, complex&); + extern template wostream& operator<<(wostream&, const complex&); +#endif +#endif + + /// @} group complex_numbers + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // See ext/type_traits.h for the primary template. + template + struct __promote_2, _Up> + { + public: + typedef std::complex::__type> __type; + }; + + template + struct __promote_2<_Tp, std::complex<_Up> > + { + public: + typedef std::complex::__type> __type; + }; + + template + struct __promote_2, std::complex<_Up> > + { + public: + typedef std::complex::__type> __type; + }; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if __cplusplus >= 201103L + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // Forward declarations. + template std::complex<_Tp> acos(const std::complex<_Tp>&); + template std::complex<_Tp> asin(const std::complex<_Tp>&); + template std::complex<_Tp> atan(const std::complex<_Tp>&); + + template std::complex<_Tp> acosh(const std::complex<_Tp>&); + template std::complex<_Tp> asinh(const std::complex<_Tp>&); + template std::complex<_Tp> atanh(const std::complex<_Tp>&); + // DR 595. + template _Tp fabs(const std::complex<_Tp>&); + + template + inline std::complex<_Tp> + __complex_acos(const std::complex<_Tp>& __z) + { + const std::complex<_Tp> __t = std::asin(__z); + const _Tp __pi_2 = 1.5707963267948966192313216916397514L; + return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acos(__complex__ float __z) + { return __builtin_cacosf(__z); } + + inline __complex__ double + __complex_acos(__complex__ double __z) + { return __builtin_cacos(__z); } + + inline __complex__ long double + __complex_acos(const __complex__ long double& __z) + { return __builtin_cacosl(__z); } + + template + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z.__rep()); } +#else + /// acos(__z) [8.1.2]. + // Effects: Behaves the same as C99 function cacos, defined + // in subclause 7.3.5.1. + template + inline std::complex<_Tp> + acos(const std::complex<_Tp>& __z) + { return __complex_acos(__z); } +#endif + + template + inline std::complex<_Tp> + __complex_asin(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t(-__z.imag(), __z.real()); + __t = std::asinh(__t); + return std::complex<_Tp>(__t.imag(), -__t.real()); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asin(__complex__ float __z) + { return __builtin_casinf(__z); } + + inline __complex__ double + __complex_asin(__complex__ double __z) + { return __builtin_casin(__z); } + + inline __complex__ long double + __complex_asin(const __complex__ long double& __z) + { return __builtin_casinl(__z); } + + template + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z.__rep()); } +#else + /// asin(__z) [8.1.3]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.5.2. + template + inline std::complex<_Tp> + asin(const std::complex<_Tp>& __z) + { return __complex_asin(__z); } +#endif + + template + std::complex<_Tp> + __complex_atan(const std::complex<_Tp>& __z) + { + const _Tp __r2 = __z.real() * __z.real(); + const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag(); + + _Tp __num = __z.imag() + _Tp(1.0); + _Tp __den = __z.imag() - _Tp(1.0); + + __num = __r2 + __num * __num; + __den = __r2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x), + _Tp(0.25) * log(__num / __den)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atan(__complex__ float __z) + { return __builtin_catanf(__z); } + + inline __complex__ double + __complex_atan(__complex__ double __z) + { return __builtin_catan(__z); } + + inline __complex__ long double + __complex_atan(const __complex__ long double& __z) + { return __builtin_catanl(__z); } + + template + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z.__rep()); } +#else + /// atan(__z) [8.1.4]. + // Effects: Behaves the same as C99 function catan, defined + // in subclause 7.3.5.3. + template + inline std::complex<_Tp> + atan(const std::complex<_Tp>& __z) + { return __complex_atan(__z); } +#endif + + template + std::complex<_Tp> + __complex_acosh(const std::complex<_Tp>& __z) + { + // Kahan's formula. + return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0))) + + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_acosh(__complex__ float __z) + { return __builtin_cacoshf(__z); } + + inline __complex__ double + __complex_acosh(__complex__ double __z) + { return __builtin_cacosh(__z); } + + inline __complex__ long double + __complex_acosh(const __complex__ long double& __z) + { return __builtin_cacoshl(__z); } + + template + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z.__rep()); } +#else + /// acosh(__z) [8.1.5]. + // Effects: Behaves the same as C99 function cacosh, defined + // in subclause 7.3.6.1. + template + inline std::complex<_Tp> + acosh(const std::complex<_Tp>& __z) + { return __complex_acosh(__z); } +#endif + + template + std::complex<_Tp> + __complex_asinh(const std::complex<_Tp>& __z) + { + std::complex<_Tp> __t((__z.real() - __z.imag()) + * (__z.real() + __z.imag()) + _Tp(1.0), + _Tp(2.0) * __z.real() * __z.imag()); + __t = std::sqrt(__t); + + return std::log(__t + __z); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_asinh(__complex__ float __z) + { return __builtin_casinhf(__z); } + + inline __complex__ double + __complex_asinh(__complex__ double __z) + { return __builtin_casinh(__z); } + + inline __complex__ long double + __complex_asinh(const __complex__ long double& __z) + { return __builtin_casinhl(__z); } + + template + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z.__rep()); } +#else + /// asinh(__z) [8.1.6]. + // Effects: Behaves the same as C99 function casin, defined + // in subclause 7.3.6.2. + template + inline std::complex<_Tp> + asinh(const std::complex<_Tp>& __z) + { return __complex_asinh(__z); } +#endif + + template + std::complex<_Tp> + __complex_atanh(const std::complex<_Tp>& __z) + { + const _Tp __i2 = __z.imag() * __z.imag(); + const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real(); + + _Tp __num = _Tp(1.0) + __z.real(); + _Tp __den = _Tp(1.0) - __z.real(); + + __num = __i2 + __num * __num; + __den = __i2 + __den * __den; + + return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)), + _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x)); + } + +#if _GLIBCXX_USE_C99_COMPLEX_TR1 + inline __complex__ float + __complex_atanh(__complex__ float __z) + { return __builtin_catanhf(__z); } + + inline __complex__ double + __complex_atanh(__complex__ double __z) + { return __builtin_catanh(__z); } + + inline __complex__ long double + __complex_atanh(const __complex__ long double& __z) + { return __builtin_catanhl(__z); } + + template + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z.__rep()); } +#else + /// atanh(__z) [8.1.7]. + // Effects: Behaves the same as C99 function catanh, defined + // in subclause 7.3.6.3. + template + inline std::complex<_Tp> + atanh(const std::complex<_Tp>& __z) + { return __complex_atanh(__z); } +#endif + + template + inline _Tp + /// fabs(__z) [8.1.8]. + // Effects: Behaves the same as C99 function cabs, defined + // in subclause 7.3.8.1. + fabs(const std::complex<_Tp>& __z) + { return std::abs(__z); } + + /// Additional overloads [8.1.9]. + template + inline typename __gnu_cxx::__promote<_Tp>::__type + arg(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; +#if (_GLIBCXX11_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC) + return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L) + : __type(); +#else + return std::arg(std::complex<__type>(__x)); +#endif + } + + template + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type + imag(_Tp) + { return _Tp(); } + + template + _GLIBCXX20_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type + norm(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return __type(__x) * __type(__x); + } + + template + _GLIBCXX_CONSTEXPR inline typename __gnu_cxx::__promote<_Tp>::__type + real(_Tp __x) + { return __x; } + + template + inline std::complex::__type> + pow(const std::complex<_Tp>& __x, const _Up& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), __type(__y)); + } + + template + inline std::complex::__type> + pow(const _Tp& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(__type(__x), std::complex<__type>(__y)); + } + + template + inline std::complex::__type> + pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return std::pow(std::complex<__type>(__x), + std::complex<__type>(__y)); + } + + // Forward declarations. + // DR 781. + template + std::complex<_Tp> proj(const std::complex<_Tp>&); + + // Generic implementation of std::proj, does not work for infinities. + template + inline std::complex<_Tp> + __complex_proj(const std::complex<_Tp>& __z) + { return __z; } + +#if _GLIBCXX_USE_C99_COMPLEX + inline complex + __complex_proj(const complex& __z) + { return __builtin_cprojf(__z.__rep()); } + + inline complex + __complex_proj(const complex& __z) + { return __builtin_cproj(__z.__rep()); } + + inline complex + __complex_proj(const complex& __z) + { return __builtin_cprojl(__z.__rep()); } +#elif defined _GLIBCXX_USE_C99_MATH_TR1 + inline complex + __complex_proj(const complex& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex(__builtin_inff(), + __builtin_copysignf(0.0f, __z.imag())); + return __z; + } + + inline complex + __complex_proj(const complex& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex(__builtin_inf(), + __builtin_copysign(0.0, __z.imag())); + return __z; + } + + inline complex + __complex_proj(const complex& __z) + { + if (__builtin_isinf(__z.real()) || __builtin_isinf(__z.imag())) + return complex(__builtin_infl(), + __builtin_copysignl(0.0l, __z.imag())); + return __z; + } +#endif + + template + inline std::complex<_Tp> + proj(const std::complex<_Tp>& __z) + { return __complex_proj(__z); } + + // Overload for scalars + template + inline std::complex::__type> + proj(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::proj(std::complex<__type>(__x)); + } + + template + inline _GLIBCXX20_CONSTEXPR + std::complex::__type> + conj(_Tp __x) + { + typedef typename __gnu_cxx::__promote<_Tp>::__type __type; + return std::complex<__type>(__x, -__type()); + } + +#if __cplusplus > 201103L + +inline namespace literals { +inline namespace complex_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" +#define __cpp_lib_complex_udls 201309 + + constexpr std::complex + operator""if(long double __num) + { return std::complex{0.0F, static_cast(__num)}; } + + constexpr std::complex + operator""if(unsigned long long __num) + { return std::complex{0.0F, static_cast(__num)}; } + + constexpr std::complex + operator""i(long double __num) + { return std::complex{0.0, static_cast(__num)}; } + + constexpr std::complex + operator""i(unsigned long long __num) + { return std::complex{0.0, static_cast(__num)}; } + + constexpr std::complex + operator""il(long double __num) + { return std::complex{0.0L, __num}; } + + constexpr std::complex + operator""il(unsigned long long __num) + { return std::complex{0.0L, static_cast(__num)}; } + +#pragma GCC diagnostic pop +} // inline namespace complex_literals +} // inline namespace literals + +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 + +#endif /* _GLIBCXX_COMPLEX */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/complex.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/complex.h new file mode 100755 index 0000000..fd06373 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/complex.h @@ -0,0 +1,48 @@ +// -*- C++ -*- compatibility header. + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file complex.h + * This is a Standard C++ Library header. + */ + +#include + +#if __cplusplus >= 201103L +# include +#endif + +#if __cplusplus >= 201103L && defined(__STRICT_ANSI__) +// For strict modes do not include the C library's , see PR 82417. +#elif _GLIBCXX_HAVE_COMPLEX_H +# include_next +# ifdef _GLIBCXX_COMPLEX +// See PR56111, keep the macro in C++03 if possible. +# undef complex +# endif +#endif + +#ifndef _GLIBCXX_COMPLEX_H +#define _GLIBCXX_COMPLEX_H 1 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/concepts b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/concepts new file mode 100755 index 0000000..7f5421f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/concepts @@ -0,0 +1,365 @@ +// -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/concepts + * This is a Standard C++ Library header. + * @ingroup concepts + */ + +#ifndef _GLIBCXX_CONCEPTS +#define _GLIBCXX_CONCEPTS 1 + +#if __cplusplus > 201703L && __cpp_concepts >= 201907L + +#pragma GCC system_header + +/** + * @defgroup concepts Concepts + * @ingroup utilities + * + * Concepts for checking type requirements. + */ + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_concepts 202002L + + // [concepts.lang], language-related concepts + + namespace __detail + { + template + concept __same_as = std::is_same_v<_Tp, _Up>; + } // namespace __detail + + /// [concept.same], concept same_as + template + concept same_as + = __detail::__same_as<_Tp, _Up> && __detail::__same_as<_Up, _Tp>; + + /// [concept.derived], concept derived_from + template + concept derived_from = __is_base_of(_Base, _Derived) + && is_convertible_v; + + /// [concept.convertible], concept convertible_to + template + concept convertible_to = is_convertible_v<_From, _To> + && requires { static_cast<_To>(std::declval<_From>()); }; + + /// [concept.commonref], concept common_reference_with + template + concept common_reference_with + = same_as, common_reference_t<_Up, _Tp>> + && convertible_to<_Tp, common_reference_t<_Tp, _Up>> + && convertible_to<_Up, common_reference_t<_Tp, _Up>>; + + /// [concept.common], concept common_with + template + concept common_with + = same_as, common_type_t<_Up, _Tp>> + && requires { + static_cast>(std::declval<_Tp>()); + static_cast>(std::declval<_Up>()); + } + && common_reference_with, + add_lvalue_reference_t> + && common_reference_with>, + common_reference_t< + add_lvalue_reference_t, + add_lvalue_reference_t>>; + + // [concepts.arithmetic], arithmetic concepts + + template + concept integral = is_integral_v<_Tp>; + + template + concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; + + template + concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; + + template + concept floating_point = is_floating_point_v<_Tp>; + + namespace __detail + { + template + using __cref = const remove_reference_t<_Tp>&; + + template + concept __class_or_enum + = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; + } // namespace __detail + + /// [concept.assignable], concept assignable_from + template + concept assignable_from + = is_lvalue_reference_v<_Lhs> + && common_reference_with<__detail::__cref<_Lhs>, __detail::__cref<_Rhs>> + && requires(_Lhs __lhs, _Rhs&& __rhs) { + { __lhs = static_cast<_Rhs&&>(__rhs) } -> same_as<_Lhs>; + }; + + /// [concept.destructible], concept destructible + template + concept destructible = is_nothrow_destructible_v<_Tp>; + + /// [concept.constructible], concept constructible_from + template + concept constructible_from + = destructible<_Tp> && is_constructible_v<_Tp, _Args...>; + + /// [concept.defaultinitializable], concept default_initializable + template + concept default_initializable = constructible_from<_Tp> + && requires + { + _Tp{}; + (void) ::new _Tp; + }; + + /// [concept.moveconstructible], concept move_constructible + template + concept move_constructible + = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; + + /// [concept.copyconstructible], concept copy_constructible + template + concept copy_constructible + = move_constructible<_Tp> + && constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> + && constructible_from<_Tp, const _Tp&> && convertible_to + && constructible_from<_Tp, const _Tp> && convertible_to; + + // [concept.swappable], concept swappable + + namespace ranges + { + namespace __cust_swap + { + template void swap(_Tp&, _Tp&) = delete; + + template + concept __adl_swap + = (__detail::__class_or_enum> + || __detail::__class_or_enum>) + && requires(_Tp&& __t, _Up&& __u) { + swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + }; + + struct _Swap + { + private: + template + static constexpr bool + _S_noexcept() + { + if constexpr (__adl_swap<_Tp, _Up>) + return noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())); + else + return is_nothrow_move_constructible_v> + && is_nothrow_move_assignable_v>; + } + + public: + template + requires __adl_swap<_Tp, _Up> + || (same_as<_Tp, _Up> && is_lvalue_reference_v<_Tp> + && move_constructible> + && assignable_from<_Tp, remove_reference_t<_Tp>>) + constexpr void + operator()(_Tp&& __t, _Up&& __u) const + noexcept(_S_noexcept<_Tp, _Up>()) + { + if constexpr (__adl_swap<_Tp, _Up>) + swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + else + { + auto __tmp = static_cast&&>(__t); + __t = static_cast&&>(__u); + __u = static_cast&&>(__tmp); + } + } + + template + requires requires(const _Swap& __swap, _Tp& __e1, _Up& __e2) { + __swap(__e1, __e2); + } + constexpr void + operator()(_Tp (&__e1)[_Num], _Up (&__e2)[_Num]) const + noexcept(noexcept(std::declval()(*__e1, *__e2))) + { + for (size_t __n = 0; __n < _Num; ++__n) + (*this)(__e1[__n], __e2[__n]); + } + }; + } // namespace __cust_swap + + inline namespace __cust + { + inline constexpr __cust_swap::_Swap swap{}; + } // inline namespace __cust + } // namespace ranges + + template + concept swappable + = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; + + template + concept swappable_with = common_reference_with<_Tp, _Up> + && requires(_Tp&& __t, _Up&& __u) { + ranges::swap(static_cast<_Tp&&>(__t), static_cast<_Tp&&>(__t)); + ranges::swap(static_cast<_Up&&>(__u), static_cast<_Up&&>(__u)); + ranges::swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + ranges::swap(static_cast<_Up&&>(__u), static_cast<_Tp&&>(__t)); + }; + + // [concepts.object], Object concepts + + template + concept movable = is_object_v<_Tp> && move_constructible<_Tp> + && assignable_from<_Tp&, _Tp> && swappable<_Tp>; + + template + concept copyable = copy_constructible<_Tp> && movable<_Tp> + && assignable_from<_Tp&, _Tp&> && assignable_from<_Tp&, const _Tp&> + && assignable_from<_Tp&, const _Tp>; + + template + concept semiregular = copyable<_Tp> && default_initializable<_Tp>; + + // [concepts.compare], comparison concepts + + // [concept.booleantestable], Boolean testability + namespace __detail + { + template + concept __boolean_testable_impl = convertible_to<_Tp, bool>; + + template + concept __boolean_testable + = __boolean_testable_impl<_Tp> + && requires(_Tp&& __t) + { { !static_cast<_Tp&&>(__t) } -> __boolean_testable_impl; }; + } // namespace __detail + + // [concept.equalitycomparable], concept equality_comparable + + namespace __detail + { + template + concept __weakly_eq_cmp_with + = requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) { + { __t == __u } -> __boolean_testable; + { __t != __u } -> __boolean_testable; + { __u == __t } -> __boolean_testable; + { __u != __t } -> __boolean_testable; + }; + } // namespace __detail + + template + concept equality_comparable = __detail::__weakly_eq_cmp_with<_Tp, _Tp>; + + template + concept equality_comparable_with + = equality_comparable<_Tp> && equality_comparable<_Up> + && common_reference_with<__detail::__cref<_Tp>, __detail::__cref<_Up>> + && equality_comparable, + __detail::__cref<_Up>>> + && __detail::__weakly_eq_cmp_with<_Tp, _Up>; + + namespace __detail + { + template + concept __partially_ordered_with + = requires(const remove_reference_t<_Tp>& __t, + const remove_reference_t<_Up>& __u) { + { __t < __u } -> __boolean_testable; + { __t > __u } -> __boolean_testable; + { __t <= __u } -> __boolean_testable; + { __t >= __u } -> __boolean_testable; + { __u < __t } -> __boolean_testable; + { __u > __t } -> __boolean_testable; + { __u <= __t } -> __boolean_testable; + { __u >= __t } -> __boolean_testable; + }; + } // namespace __detail + + // [concept.totallyordered], concept totally_ordered + template + concept totally_ordered + = equality_comparable<_Tp> + && __detail::__partially_ordered_with<_Tp, _Tp>; + + template + concept totally_ordered_with + = totally_ordered<_Tp> && totally_ordered<_Up> + && equality_comparable_with<_Tp, _Up> + && totally_ordered, + __detail::__cref<_Up>>> + && __detail::__partially_ordered_with<_Tp, _Up>; + + template + concept regular = semiregular<_Tp> && equality_comparable<_Tp>; + + // [concepts.callable], callable concepts + + /// [concept.invocable], concept invocable + template + concept invocable = is_invocable_v<_Fn, _Args...>; + + /// [concept.regularinvocable], concept regular_invocable + template + concept regular_invocable = invocable<_Fn, _Args...>; + + /// [concept.predicate], concept predicate + template + concept predicate = regular_invocable<_Fn, _Args...> + && __detail::__boolean_testable>; + + /// [concept.relation], concept relation + template + concept relation + = predicate<_Rel, _Tp, _Tp> && predicate<_Rel, _Up, _Up> + && predicate<_Rel, _Tp, _Up> && predicate<_Rel, _Up, _Tp>; + + /// [concept.equiv], concept equivalence_relation + template + concept equivalence_relation = relation<_Rel, _Tp, _Up>; + + /// [concept.strictweakorder], concept strict_weak_order + template + concept strict_weak_order = relation<_Rel, _Tp, _Up>; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++2a + +#endif /* _GLIBCXX_CONCEPTS */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/condition_variable b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/condition_variable new file mode 100755 index 0000000..fb9b7d3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/condition_variable @@ -0,0 +1,451 @@ +// -*- C++ -*- + +// Copyright (C) 2008-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/condition_variable + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CONDITION_VARIABLE +#define _GLIBCXX_CONDITION_VARIABLE 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +#include +#include +#include +#include +#include + +#if __cplusplus > 201703L +# include +#endif + +#if defined(_GLIBCXX_HAS_GTHREADS) + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup condition_variables Condition Variables + * @ingroup concurrency + * + * Classes for condition_variable support. + * @{ + */ + + /// cv_status + enum class cv_status { no_timeout, timeout }; + + /// condition_variable + class condition_variable + { + using steady_clock = chrono::steady_clock; + using system_clock = chrono::system_clock; +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + using __clock_t = steady_clock; +#else + using __clock_t = system_clock; +#endif + + __condvar _M_cond; + + public: + typedef __gthread_cond_t* native_handle_type; + + condition_variable() noexcept; + ~condition_variable() noexcept; + + condition_variable(const condition_variable&) = delete; + condition_variable& operator=(const condition_variable&) = delete; + + void + notify_one() noexcept; + + void + notify_all() noexcept; + + void + wait(unique_lock& __lock) noexcept; + + template + void + wait(unique_lock& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + template + cv_status + wait_until(unique_lock& __lock, + const chrono::time_point& __atime) + { return __wait_until_impl(__lock, __atime); } +#endif + + template + cv_status + wait_until(unique_lock& __lock, + const chrono::time_point& __atime) + { return __wait_until_impl(__lock, __atime); } + + template + cv_status + wait_until(unique_lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime) + { +#if __cplusplus > 201703L + static_assert(chrono::is_clock_v<_Clock>); +#endif + using __s_dur = typename __clock_t::duration; + const typename _Clock::time_point __c_entry = _Clock::now(); + const __clock_t::time_point __s_entry = __clock_t::now(); + const auto __delta = __atime - __c_entry; + const auto __s_atime = __s_entry + + chrono::__detail::ceil<__s_dur>(__delta); + + if (__wait_until_impl(__lock, __s_atime) == cv_status::no_timeout) + return cv_status::no_timeout; + // We got a timeout when measured against __clock_t but + // we need to check against the caller-supplied clock + // to tell whether we should return a timeout. + if (_Clock::now() < __atime) + return cv_status::no_timeout; + return cv_status::timeout; + } + + template + bool + wait_until(unique_lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p) + { + while (!__p()) + if (wait_until(__lock, __atime) == cv_status::timeout) + return __p(); + return true; + } + + template + cv_status + wait_for(unique_lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime) + { + using __dur = typename steady_clock::duration; + return wait_until(__lock, + steady_clock::now() + + chrono::__detail::ceil<__dur>(__rtime)); + } + + template + bool + wait_for(unique_lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime, + _Predicate __p) + { + using __dur = typename steady_clock::duration; + return wait_until(__lock, + steady_clock::now() + + chrono::__detail::ceil<__dur>(__rtime), + std::move(__p)); + } + + native_handle_type + native_handle() + { return _M_cond.native_handle(); } + + private: +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + template + cv_status + __wait_until_impl(unique_lock& __lock, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + _M_cond.wait_until(*__lock.mutex(), CLOCK_MONOTONIC, __ts); + + return (steady_clock::now() < __atime + ? cv_status::no_timeout : cv_status::timeout); + } +#endif + + template + cv_status + __wait_until_impl(unique_lock& __lock, + const chrono::time_point& __atime) + { + auto __s = chrono::time_point_cast(__atime); + auto __ns = chrono::duration_cast(__atime - __s); + + __gthread_time_t __ts = + { + static_cast(__s.time_since_epoch().count()), + static_cast(__ns.count()) + }; + + _M_cond.wait_until(*__lock.mutex(), __ts); + + return (system_clock::now() < __atime + ? cv_status::no_timeout : cv_status::timeout); + } + }; + + void + notify_all_at_thread_exit(condition_variable&, unique_lock); + + struct __at_thread_exit_elt + { + __at_thread_exit_elt* _M_next; + void (*_M_cb)(void*); + }; + + inline namespace _V2 { + + /// condition_variable_any + // Like above, but mutex is not required to have try_lock. + class condition_variable_any + { +#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT + using __clock_t = chrono::steady_clock; +#else + using __clock_t = chrono::system_clock; +#endif + condition_variable _M_cond; + shared_ptr _M_mutex; + + // scoped unlock - unlocks in ctor, re-locks in dtor + template + struct _Unlock + { + explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + ~_Unlock() noexcept(false) + { + if (uncaught_exception()) + { + __try + { _M_lock.lock(); } + __catch(const __cxxabiv1::__forced_unwind&) + { __throw_exception_again; } + __catch(...) + { } + } + else + _M_lock.lock(); + } +#pragma GCC diagnostic pop + + _Unlock(const _Unlock&) = delete; + _Unlock& operator=(const _Unlock&) = delete; + + _Lock& _M_lock; + }; + + public: + condition_variable_any() : _M_mutex(std::make_shared()) { } + ~condition_variable_any() = default; + + condition_variable_any(const condition_variable_any&) = delete; + condition_variable_any& operator=(const condition_variable_any&) = delete; + + void + notify_one() noexcept + { + lock_guard __lock(*_M_mutex); + _M_cond.notify_one(); + } + + void + notify_all() noexcept + { + lock_guard __lock(*_M_mutex); + _M_cond.notify_all(); + } + + template + void + wait(_Lock& __lock) + { + shared_ptr __mutex = _M_mutex; + unique_lock __my_lock(*__mutex); + _Unlock<_Lock> __unlock(__lock); + // *__mutex must be unlocked before re-locking __lock so move + // ownership of *__mutex lock to an object with shorter lifetime. + unique_lock __my_lock2(std::move(__my_lock)); + _M_cond.wait(__my_lock2); + } + + + template + void + wait(_Lock& __lock, _Predicate __p) + { + while (!__p()) + wait(__lock); + } + + template + cv_status + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime) + { + shared_ptr __mutex = _M_mutex; + unique_lock __my_lock(*__mutex); + _Unlock<_Lock> __unlock(__lock); + // *__mutex must be unlocked before re-locking __lock so move + // ownership of *__mutex lock to an object with shorter lifetime. + unique_lock __my_lock2(std::move(__my_lock)); + return _M_cond.wait_until(__my_lock2, __atime); + } + + template + bool + wait_until(_Lock& __lock, + const chrono::time_point<_Clock, _Duration>& __atime, + _Predicate __p) + { + while (!__p()) + if (wait_until(__lock, __atime) == cv_status::timeout) + return __p(); + return true; + } + + template + cv_status + wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime) + { return wait_until(__lock, __clock_t::now() + __rtime); } + + template + bool + wait_for(_Lock& __lock, + const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p) + { return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); } + +#ifdef __cpp_lib_jthread + template + bool wait(_Lock& __lock, + stop_token __stoken, + _Predicate __p) + { + if (__stoken.stop_requested()) + { + return __p(); + } + + std::stop_callback __cb(__stoken, [this] { notify_all(); }); + shared_ptr __mutex = _M_mutex; + while (!__p()) + { + unique_lock __my_lock(*__mutex); + if (__stoken.stop_requested()) + { + return false; + } + // *__mutex must be unlocked before re-locking __lock so move + // ownership of *__mutex lock to an object with shorter lifetime. + _Unlock<_Lock> __unlock(__lock); + unique_lock __my_lock2(std::move(__my_lock)); + _M_cond.wait(__my_lock2); + } + return true; + } + + template + bool wait_until(_Lock& __lock, + stop_token __stoken, + const chrono::time_point<_Clock, _Duration>& __abs_time, + _Predicate __p) + { + if (__stoken.stop_requested()) + { + return __p(); + } + + std::stop_callback __cb(__stoken, [this] { notify_all(); }); + shared_ptr __mutex = _M_mutex; + while (!__p()) + { + bool __stop; + { + unique_lock __my_lock(*__mutex); + if (__stoken.stop_requested()) + { + return false; + } + _Unlock<_Lock> __u(__lock); + unique_lock __my_lock2(std::move(__my_lock)); + const auto __status = _M_cond.wait_until(__my_lock2, __abs_time); + __stop = (__status == std::cv_status::timeout) || __stoken.stop_requested(); + } + if (__stop) + { + return __p(); + } + } + return true; + } + + template + bool wait_for(_Lock& __lock, + stop_token __stoken, + const chrono::duration<_Rep, _Period>& __rel_time, + _Predicate __p) + { + auto __abst = std::chrono::steady_clock::now() + __rel_time; + return wait_until(__lock, + std::move(__stoken), + __abst, + std::move(__p)); + } +#endif + }; + + } // end inline namespace + + /// @} group condition_variables +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // _GLIBCXX_HAS_GTHREADS +#endif // C++11 +#endif // _GLIBCXX_CONDITION_VARIABLE diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/coroutine b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/coroutine new file mode 100755 index 0000000..209deb7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/coroutine @@ -0,0 +1,342 @@ +// -*- C++ -*- + +// Copyright (C) 2019-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/coroutine + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_COROUTINE +#define _GLIBCXX_COROUTINE 1 + +#pragma GCC system_header + +// It is very likely that earlier versions would work, but they are untested. +#if __cplusplus >= 201402L + +#include + +/** + * @defgroup coroutines Coroutines + * + * Components for supporting coroutine implementations. + */ + +#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L +# include +# define _COROUTINES_USE_SPACESHIP 1 +#else +# include // for std::less +# define _COROUTINES_USE_SPACESHIP 0 +#endif + +namespace std _GLIBCXX_VISIBILITY (default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cpp_impl_coroutine + +#define __cpp_lib_coroutine 201902L + + inline namespace __n4861 { + + // 17.12.2 coroutine traits + /// [coroutine.traits] + /// [coroutine.traits.primary] + /// If _Result::promise_type is valid and denotes a type then the traits + /// have a single publicly accessible member, otherwise they are empty. + template + struct __coroutine_traits_impl {}; + + template + struct __coroutine_traits_impl<_Result, + __void_t> + { + using promise_type = typename _Result::promise_type; + }; + + template + struct coroutine_traits : __coroutine_traits_impl<_Result> {}; + + // 17.12.3 Class template coroutine_handle + /// [coroutine.handle] + template + struct coroutine_handle; + + template <> struct + coroutine_handle + { + public: + // [coroutine.handle.con], construct/reset + constexpr coroutine_handle() noexcept : _M_fr_ptr(0) {} + + constexpr coroutine_handle(std::nullptr_t __h) noexcept + : _M_fr_ptr(__h) + {} + + coroutine_handle& operator=(std::nullptr_t) noexcept + { + _M_fr_ptr = nullptr; + return *this; + } + + public: + // [coroutine.handle.export.import], export/import + constexpr void* address() const noexcept { return _M_fr_ptr; } + + constexpr static coroutine_handle from_address(void* __a) noexcept + { + coroutine_handle __self; + __self._M_fr_ptr = __a; + return __self; + } + + public: + // [coroutine.handle.observers], observers + constexpr explicit operator bool() const noexcept + { + return bool(_M_fr_ptr); + } + + bool done() const noexcept { return __builtin_coro_done(_M_fr_ptr); } + + // [coroutine.handle.resumption], resumption + void operator()() const { resume(); } + + void resume() const { __builtin_coro_resume(_M_fr_ptr); } + + void destroy() const { __builtin_coro_destroy(_M_fr_ptr); } + + protected: + void* _M_fr_ptr; + }; + + // [coroutine.handle.compare], comparison operators + + constexpr bool + operator==(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return __a.address() == __b.address(); + } + +#if _COROUTINES_USE_SPACESHIP + constexpr strong_ordering + operator<=>(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return std::compare_three_way()(__a.address(), __b.address()); + } +#else + // These are to enable operation with std=c++14,17. + constexpr bool + operator!=(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return !(__a == __b); + } + + constexpr bool + operator<(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return less()(__a.address(), __b.address()); + } + + constexpr bool + operator>(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return __b < __a; + } + + constexpr bool + operator<=(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return !(__a > __b); + } + + constexpr bool + operator>=(coroutine_handle<> __a, coroutine_handle<> __b) noexcept + { + return !(__a < __b); + } +#endif + + template + struct coroutine_handle + { + // [coroutine.handle.con], construct/reset + + constexpr coroutine_handle() noexcept { } + + constexpr coroutine_handle(nullptr_t) noexcept { } + + static coroutine_handle + from_promise(_Promise& __p) + { + coroutine_handle __self; + __self._M_fr_ptr + = __builtin_coro_promise((char*) &__p, __alignof(_Promise), true); + return __self; + } + + coroutine_handle& operator=(nullptr_t) noexcept + { + _M_fr_ptr = nullptr; + return *this; + } + + // [coroutine.handle.export.import], export/import + + constexpr void* address() const noexcept { return _M_fr_ptr; } + + constexpr static coroutine_handle from_address(void* __a) noexcept + { + coroutine_handle __self; + __self._M_fr_ptr = __a; + return __self; + } + + // [coroutine.handle.conv], conversion + constexpr operator coroutine_handle<>() const noexcept + { return coroutine_handle<>::from_address(address()); } + + // [coroutine.handle.observers], observers + constexpr explicit operator bool() const noexcept + { + return bool(_M_fr_ptr); + } + + bool done() const noexcept { return __builtin_coro_done(_M_fr_ptr); } + + // [coroutine.handle.resumption], resumption + void operator()() const { resume(); } + + void resume() const { __builtin_coro_resume(_M_fr_ptr); } + + void destroy() const { __builtin_coro_destroy(_M_fr_ptr); } + + // [coroutine.handle.promise], promise access + _Promise& promise() const + { + void* __t + = __builtin_coro_promise (_M_fr_ptr, __alignof(_Promise), false); + return *static_cast<_Promise*>(__t); + } + + private: + void* _M_fr_ptr = nullptr; + }; + + /// [coroutine.noop] + struct noop_coroutine_promise + { + }; + + // 17.12.4.1 Class noop_coroutine_promise + /// [coroutine.promise.noop] + template <> + struct coroutine_handle + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3460. Unimplementable noop_coroutine_handle guarantees + // [coroutine.handle.noop.conv], conversion + constexpr operator coroutine_handle<>() const noexcept + { return coroutine_handle<>::from_address(address()); } + + // [coroutine.handle.noop.observers], observers + constexpr explicit operator bool() const noexcept { return true; } + + constexpr bool done() const noexcept { return false; } + + // [coroutine.handle.noop.resumption], resumption + void operator()() const noexcept {} + + void resume() const noexcept {} + + void destroy() const noexcept {} + + // [coroutine.handle.noop.promise], promise access + noop_coroutine_promise& promise() const noexcept + { return _S_fr.__p; } + + // [coroutine.handle.noop.address], address + constexpr void* address() const noexcept { return _M_fr_ptr; } + + private: + friend coroutine_handle noop_coroutine() noexcept; + + struct __frame + { + static void __dummy_resume_destroy() { } + + void (*__r)() = __dummy_resume_destroy; + void (*__d)() = __dummy_resume_destroy; + struct noop_coroutine_promise __p; + }; + + static __frame _S_fr; + + explicit coroutine_handle() noexcept = default; + + void* _M_fr_ptr = &_S_fr; + }; + + using noop_coroutine_handle = coroutine_handle; + + inline noop_coroutine_handle::__frame + noop_coroutine_handle::_S_fr{}; + + inline noop_coroutine_handle noop_coroutine() noexcept + { + return noop_coroutine_handle(); + } + + // 17.12.5 Trivial awaitables + /// [coroutine.trivial.awaitables] + struct suspend_always + { + constexpr bool await_ready() const noexcept { return false; } + + constexpr void await_suspend(coroutine_handle<>) const noexcept {} + + constexpr void await_resume() const noexcept {} + }; + + struct suspend_never + { + constexpr bool await_ready() const noexcept { return true; } + + constexpr void await_suspend(coroutine_handle<>) const noexcept {} + + constexpr void await_resume() const noexcept {} + }; + + } // namespace __n4861 + +#else +#error "the coroutine header requires -fcoroutines" +#endif + + _GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 (we are allowing use from at least this) + +#endif // _GLIBCXX_COROUTINE diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/csetjmp b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/csetjmp new file mode 100755 index 0000000..e89ac5c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/csetjmp @@ -0,0 +1,61 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file csetjmp + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c setjmp.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSETJMP +#define _GLIBCXX_CSETJMP 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef longjmp + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef setjmp +#define setjmp(env) setjmp (env) +#endif + +namespace std +{ + using ::jmp_buf; + using ::longjmp; +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/csignal b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/csignal new file mode 100755 index 0000000..2100892 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/csignal @@ -0,0 +1,57 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file csignal + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c signal.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSIGNAL +#define _GLIBCXX_CSIGNAL 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef raise + +namespace std +{ + using ::sig_atomic_t; + using ::signal; + using ::raise; +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdalign b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdalign new file mode 100755 index 0000000..734037e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdalign @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdalign + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CSTDALIGN +#define _GLIBCXX_CSTDALIGN 1 + +#if __cplusplus < 201103L +# include +#else +# include +# if _GLIBCXX_HAVE_STDALIGN_H +# include +# endif +#endif + +#endif + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdarg b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdarg new file mode 100755 index 0000000..c2dc452 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdarg @@ -0,0 +1,58 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdarg + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stdarg.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#undef __need___va_list +#include +#include + +#ifndef _GLIBCXX_CSTDARG +#define _GLIBCXX_CSTDARG 1 + +// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998 +#ifndef va_end +#define va_end(ap) va_end (ap) +#endif + +namespace std +{ + using ::va_list; +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdbool b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdbool new file mode 100755 index 0000000..8242768 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdbool @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdbool + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CSTDBOOL +#define _GLIBCXX_CSTDBOOL 1 + +#if __cplusplus < 201103L +# include +#else +# include +# if _GLIBCXX_HAVE_STDBOOL_H +# include +# endif +#endif + +#endif + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstddef b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstddef new file mode 100755 index 0000000..13ef7f0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstddef @@ -0,0 +1,182 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cstddef + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stddef.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 18.1 Types +// + +#ifndef _GLIBCXX_CSTDDEF +#define _GLIBCXX_CSTDDEF 1 + +#pragma GCC system_header + +#undef __need_wchar_t +#undef __need_ptrdiff_t +#undef __need_size_t +#undef __need_NULL +#undef __need_wint_t +#include +#include + +extern "C++" +{ +#if __cplusplus >= 201103L +namespace std +{ + // We handle size_t, ptrdiff_t, and nullptr_t in c++config.h. + using ::max_align_t; +} +#endif // C++11 + +#if __cplusplus >= 201703L +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +#define __cpp_lib_byte 201603 + + /// std::byte + enum class byte : unsigned char {}; + + template struct __byte_operand { }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; +#ifdef _GLIBCXX_USE_WCHAR_T + template<> struct __byte_operand { using __type = byte; }; +#endif +#ifdef _GLIBCXX_USE_CHAR8_T + template<> struct __byte_operand { using __type = byte; }; +#endif + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; + template<> struct __byte_operand { using __type = byte; }; +#if defined(__GLIBCXX_TYPE_INT_N_0) + template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_0> + { using __type = byte; }; + template<> struct __byte_operand + { using __type = byte; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_1> + { using __type = byte; }; + template<> struct __byte_operand + { using __type = byte; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + template<> struct __byte_operand<__GLIBCXX_TYPE_INT_N_2> + { using __type = byte; }; + template<> struct __byte_operand + { using __type = byte; }; +#endif + template + struct __byte_operand + : __byte_operand<_IntegerType> { }; + template + struct __byte_operand + : __byte_operand<_IntegerType> { }; + template + struct __byte_operand + : __byte_operand<_IntegerType> { }; + + template + using __byte_op_t = typename __byte_operand<_IntegerType>::__type; + + template + constexpr __byte_op_t<_IntegerType> + operator<<(byte __b, _IntegerType __shift) noexcept + { return (byte)(unsigned char)((unsigned)__b << __shift); } + + template + constexpr __byte_op_t<_IntegerType> + operator>>(byte __b, _IntegerType __shift) noexcept + { return (byte)(unsigned char)((unsigned)__b >> __shift); } + + constexpr byte + operator|(byte __l, byte __r) noexcept + { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); } + + constexpr byte + operator&(byte __l, byte __r) noexcept + { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); } + + constexpr byte + operator^(byte __l, byte __r) noexcept + { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); } + + constexpr byte + operator~(byte __b) noexcept + { return (byte)(unsigned char)~(unsigned)__b; } + + template + constexpr __byte_op_t<_IntegerType>& + operator<<=(byte& __b, _IntegerType __shift) noexcept + { return __b = __b << __shift; } + + template + constexpr __byte_op_t<_IntegerType>& + operator>>=(byte& __b, _IntegerType __shift) noexcept + { return __b = __b >> __shift; } + + constexpr byte& + operator|=(byte& __l, byte __r) noexcept + { return __l = __l | __r; } + + constexpr byte& + operator&=(byte& __l, byte __r) noexcept + { return __l = __l & __r; } + + constexpr byte& + operator^=(byte& __l, byte __r) noexcept + { return __l = __l ^ __r; } + + template + [[nodiscard]] + constexpr _IntegerType + to_integer(__byte_op_t<_IntegerType> __b) noexcept + { return _IntegerType(__b); } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 +} // extern "C++" + +#endif // _GLIBCXX_CSTDDEF diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdint b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdint new file mode 100755 index 0000000..fa4d0fb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdint @@ -0,0 +1,91 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdint + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_CSTDINT +#define _GLIBCXX_CSTDINT 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include + +#if _GLIBCXX_HAVE_STDINT_H +# include +#endif + +namespace std +{ +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + using ::int8_t; + using ::int16_t; + using ::int32_t; + using ::int64_t; + + using ::int_fast8_t; + using ::int_fast16_t; + using ::int_fast32_t; + using ::int_fast64_t; + + using ::int_least8_t; + using ::int_least16_t; + using ::int_least32_t; + using ::int_least64_t; + + using ::intmax_t; + using ::intptr_t; + + using ::uint8_t; + using ::uint16_t; + using ::uint32_t; + using ::uint64_t; + + using ::uint_fast8_t; + using ::uint_fast16_t; + using ::uint_fast32_t; + using ::uint_fast64_t; + + using ::uint_least8_t; + using ::uint_least16_t; + using ::uint_least32_t; + using ::uint_least64_t; + + using ::uintmax_t; + using ::uintptr_t; +#else // !_GLIBCXX_USE_C99_STDINT_TR1 + // Define the minimum needed for , etc. + using intmax_t = __INTMAX_TYPE__; + using uintmax_t = __UINTMAX_TYPE__; +#endif // _GLIBCXX_USE_C99_STDINT_TR1 +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_CSTDINT diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdio b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdio new file mode 100755 index 0000000..b7239c9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdio @@ -0,0 +1,194 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdio + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stdio.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 27.8.2 C Library files +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSTDIO +#define _GLIBCXX_CSTDIO 1 + +#if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS) +extern "C" char* gets (char* __s) __attribute__((__deprecated__)); +#endif + +// Get rid of those macros defined in in lieu of real functions. +#undef clearerr +#undef fclose +#undef feof +#undef ferror +#undef fflush +#undef fgetc +#undef fgetpos +#undef fgets +#undef fopen +#undef fprintf +#undef fputc +#undef fputs +#undef fread +#undef freopen +#undef fscanf +#undef fseek +#undef fsetpos +#undef ftell +#undef fwrite +#undef getc +#undef getchar +#if __cplusplus <= 201103L +# undef gets +#endif +#undef perror +#undef printf +#undef putc +#undef putchar +#undef puts +#undef remove +#undef rename +#undef rewind +#undef scanf +#undef setbuf +#undef setvbuf +#undef sprintf +#undef sscanf +#undef tmpfile +#undef tmpnam +#undef ungetc +#undef vfprintf +#undef vprintf +#undef vsprintf + +namespace std +{ + using ::FILE; + using ::fpos_t; + + using ::clearerr; + using ::fclose; + using ::feof; + using ::ferror; + using ::fflush; + using ::fgetc; + using ::fgetpos; + using ::fgets; + using ::fopen; + using ::fprintf; + using ::fputc; + using ::fputs; + using ::fread; + using ::freopen; + using ::fscanf; + using ::fseek; + using ::fsetpos; + using ::ftell; + using ::fwrite; + using ::getc; + using ::getchar; +#if __cplusplus <= 201103L + // LWG 2249 + using ::gets; +#endif + using ::perror; + using ::printf; + using ::putc; + using ::putchar; + using ::puts; + using ::remove; + using ::rename; + using ::rewind; + using ::scanf; + using ::setbuf; + using ::setvbuf; + using ::sprintf; + using ::sscanf; + using ::tmpfile; +#if _GLIBCXX_USE_TMPNAM + using ::tmpnam; +#endif + using ::ungetc; + using ::vfprintf; + using ::vprintf; + using ::vsprintf; +} // namespace + +#if _GLIBCXX_USE_C99_STDIO + +#undef snprintf +#undef vfscanf +#undef vscanf +#undef vsnprintf +#undef vsscanf + +namespace __gnu_cxx +{ +#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC + extern "C" int + (snprintf)(char * __restrict, std::size_t, const char * __restrict, ...) + throw (); + extern "C" int + (vfscanf)(FILE * __restrict, const char * __restrict, __gnuc_va_list); + extern "C" int (vscanf)(const char * __restrict, __gnuc_va_list); + extern "C" int + (vsnprintf)(char * __restrict, std::size_t, const char * __restrict, + __gnuc_va_list) throw (); + extern "C" int + (vsscanf)(const char * __restrict, const char * __restrict, __gnuc_va_list) + throw (); +#endif + +#if !_GLIBCXX_USE_C99_DYNAMIC + using ::snprintf; + using ::vfscanf; + using ::vscanf; + using ::vsnprintf; + using ::vsscanf; +#endif +} // namespace __gnu_cxx + +namespace std +{ + using ::__gnu_cxx::snprintf; + using ::__gnu_cxx::vfscanf; + using ::__gnu_cxx::vscanf; + using ::__gnu_cxx::vsnprintf; + using ::__gnu_cxx::vsscanf; +} // namespace std + +#endif // _GLIBCXX_USE_C99_STDIO + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdlib b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdlib new file mode 100755 index 0000000..47b954c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstdlib @@ -0,0 +1,261 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cstdlib + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c stdlib.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include + +#ifndef _GLIBCXX_CSTDLIB +#define _GLIBCXX_CSTDLIB 1 + +#if !_GLIBCXX_HOSTED +// The C standard does not require a freestanding implementation to +// provide . However, the C++ standard does still require +// -- but only the functionality mentioned in +// [lib.support.start.term]. + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +namespace std +{ + extern "C" void abort(void) throw () _GLIBCXX_NORETURN; + extern "C" int atexit(void (*)(void)) throw (); + extern "C" void exit(int) throw () _GLIBCXX_NORETURN; +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT + extern "C" int at_quick_exit(void (*)(void)) throw (); +# endif +# ifdef _GLIBCXX_HAVE_QUICK_EXIT + extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN; +# endif +#endif +} // namespace std + +#else + +// Need to ensure this finds the C library's not a libstdc++ +// wrapper that might already be installed later in the include search path. +#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include_next +#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef abort +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) +# undef aligned_alloc +#endif +#undef atexit +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT +# undef at_quick_exit +# endif +#endif +#undef atof +#undef atoi +#undef atol +#undef bsearch +#undef calloc +#undef div +#undef exit +#undef free +#undef getenv +#undef labs +#undef ldiv +#undef malloc +#undef mblen +#undef mbstowcs +#undef mbtowc +#undef qsort +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_QUICK_EXIT +# undef quick_exit +# endif +#endif +#undef rand +#undef realloc +#undef srand +#undef strtod +#undef strtol +#undef strtoul +#undef system +#undef wcstombs +#undef wctomb + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::div_t; + using ::ldiv_t; + + using ::abort; +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) + using ::aligned_alloc; +#endif + using ::atexit; +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT + using ::at_quick_exit; +# endif +#endif + using ::atof; + using ::atoi; + using ::atol; + using ::bsearch; + using ::calloc; + using ::div; + using ::exit; + using ::free; + using ::getenv; + using ::labs; + using ::ldiv; + using ::malloc; +#ifdef _GLIBCXX_HAVE_MBSTATE_T + using ::mblen; + using ::mbstowcs; + using ::mbtowc; +#endif // _GLIBCXX_HAVE_MBSTATE_T + using ::qsort; +#if __cplusplus >= 201103L +# ifdef _GLIBCXX_HAVE_QUICK_EXIT + using ::quick_exit; +# endif +#endif + using ::rand; + using ::realloc; + using ::srand; + using ::strtod; + using ::strtol; + using ::strtoul; + using ::system; +#ifdef _GLIBCXX_USE_WCHAR_T + using ::wcstombs; + using ::wctomb; +#endif // _GLIBCXX_USE_WCHAR_T + +#ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO + inline ldiv_t + div(long __i, long __j) { return ldiv(__i, __j); } +#endif + + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#if _GLIBCXX_USE_C99_STDLIB + +#undef _Exit +#undef llabs +#undef lldiv +#undef atoll +#undef strtoll +#undef strtoull +#undef strtof +#undef strtold + +namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::lldiv_t; +#endif +#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC + extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN; +#endif +#if !_GLIBCXX_USE_C99_DYNAMIC + using ::_Exit; +#endif + +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::llabs; + + inline lldiv_t + div(long long __n, long long __d) + { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } + + using ::lldiv; +#endif + +#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + extern "C" long long int (atoll)(const char *) throw (); + extern "C" long long int + (strtoll)(const char * __restrict, char ** __restrict, int) throw (); + extern "C" unsigned long long int + (strtoull)(const char * __restrict, char ** __restrict, int) throw (); +#endif +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::atoll; + using ::strtoll; + using ::strtoull; +#endif + using ::strtof; + using ::strtold; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace __gnu_cxx + +namespace std +{ +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::__gnu_cxx::lldiv_t; +#endif + using ::__gnu_cxx::_Exit; +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::__gnu_cxx::llabs; + using ::__gnu_cxx::div; + using ::__gnu_cxx::lldiv; +#endif + using ::__gnu_cxx::atoll; + using ::__gnu_cxx::strtof; + using ::__gnu_cxx::strtoll; + using ::__gnu_cxx::strtoull; + using ::__gnu_cxx::strtold; +} // namespace std + +#endif // _GLIBCXX_USE_C99_STDLIB + +} // extern "C++" + +#endif // !_GLIBCXX_HOSTED + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstring b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstring new file mode 100755 index 0000000..35e32dc --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cstring @@ -0,0 +1,126 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file cstring + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c string.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.4.6 C library +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CSTRING +#define _GLIBCXX_CSTRING 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef memchr +#undef memcmp +#undef memcpy +#undef memmove +#undef memset +#undef strcat +#undef strchr +#undef strcmp +#undef strcoll +#undef strcpy +#undef strcspn +#undef strerror +#undef strlen +#undef strncat +#undef strncmp +#undef strncpy +#undef strpbrk +#undef strrchr +#undef strspn +#undef strstr +#undef strtok +#undef strxfrm + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::memchr; + using ::memcmp; + using ::memcpy; + using ::memmove; + using ::memset; + using ::strcat; + using ::strcmp; + using ::strcoll; + using ::strcpy; + using ::strcspn; + using ::strerror; + using ::strlen; + using ::strncat; + using ::strncmp; + using ::strncpy; + using ::strspn; + using ::strtok; + using ::strxfrm; + using ::strchr; + using ::strpbrk; + using ::strrchr; + using ::strstr; + +#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO + inline void* + memchr(void* __s, int __c, size_t __n) + { return __builtin_memchr(__s, __c, __n); } + + inline char* + strchr(char* __s, int __n) + { return __builtin_strchr(__s, __n); } + + inline char* + strpbrk(char* __s1, const char* __s2) + { return __builtin_strpbrk(__s1, __s2); } + + inline char* + strrchr(char* __s, int __n) + { return __builtin_strrchr(__s, __n); } + + inline char* + strstr(char* __s1, const char* __s2) + { return __builtin_strstr(__s1, __s2); } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ctgmath b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ctgmath new file mode 100755 index 0000000..a3e6bc2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ctgmath @@ -0,0 +1,44 @@ +// -*- C++ -*- + +// Copyright (C) 2007-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ctgmath + * This is a Standard C++ Library header. + */ + +#pragma GCC system_header + +#ifndef _GLIBCXX_CTGMATH +#define _GLIBCXX_CTGMATH 1 + +#if __cplusplus < 201103L +# include +#else +# include +extern "C++" { +# include +} +#endif + +#endif + diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ctime b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ctime new file mode 100755 index 0000000..6b5247a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/ctime @@ -0,0 +1,84 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/ctime + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c time.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 20.5 Date and time +// + +#pragma GCC system_header + +#include +#include + +#ifndef _GLIBCXX_CTIME +#define _GLIBCXX_CTIME 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef clock +#undef difftime +#undef mktime +#undef time +#undef asctime +#undef ctime +#undef gmtime +#undef localtime +#undef strftime + +namespace std +{ + using ::clock_t; + using ::time_t; + using ::tm; + + using ::clock; + using ::difftime; + using ::mktime; + using ::time; + using ::asctime; + using ::ctime; + using ::gmtime; + using ::localtime; + using ::strftime; +} // namespace + +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_TIMESPEC_GET) +#undef timespec_get +namespace std +{ + using ::timespec; + using ::timespec_get; +} // namespace std +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cuchar b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cuchar new file mode 100755 index 0000000..57047d7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cuchar @@ -0,0 +1,77 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cuchar + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c uchar.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882:2011 21.8 +// + +#ifndef _GLIBCXX_CUCHAR +#define _GLIBCXX_CUCHAR 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else + +#include +#include + +#if _GLIBCXX_USE_C11_UCHAR_CXX11 + +#include + +// Get rid of those macros defined in in lieu of real functions. +#undef mbrtoc16 +#undef c16rtomb +#undef mbrtoc32 +#undef c32rtomb + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::mbrtoc16; + using ::c16rtomb; + using ::mbrtoc32; + using ::c32rtomb; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // _GLIBCXX_USE_C11_UCHAR_CXX11 + +#endif // C++11 + +#endif // _GLIBCXX_CUCHAR diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cwchar b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cwchar new file mode 100755 index 0000000..c968dc9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cwchar @@ -0,0 +1,306 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cwchar + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c wchar.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: 21.4 +// + +#pragma GCC system_header + +#include + +#if _GLIBCXX_HAVE_WCHAR_H +#include +#endif + +#ifndef _GLIBCXX_CWCHAR +#define _GLIBCXX_CWCHAR 1 + +// Need to do a bit of trickery here with mbstate_t as char_traits +// assumes it is in wchar.h, regardless of wchar_t specializations. +#ifndef _GLIBCXX_HAVE_MBSTATE_T +extern "C" +{ + typedef struct + { + int __fill[6]; + } mbstate_t; +} +#endif + +namespace std +{ + using ::mbstate_t; +} // namespace std + +// Get rid of those macros defined in in lieu of real functions. +#undef btowc +#undef fgetwc +#undef fgetws +#undef fputwc +#undef fputws +#undef fwide +#undef fwprintf +#undef fwscanf +#undef getwc +#undef getwchar +#undef mbrlen +#undef mbrtowc +#undef mbsinit +#undef mbsrtowcs +#undef putwc +#undef putwchar +#undef swprintf +#undef swscanf +#undef ungetwc +#undef vfwprintf +#if _GLIBCXX_HAVE_VFWSCANF +# undef vfwscanf +#endif +#undef vswprintf +#if _GLIBCXX_HAVE_VSWSCANF +# undef vswscanf +#endif +#undef vwprintf +#if _GLIBCXX_HAVE_VWSCANF +# undef vwscanf +#endif +#undef wcrtomb +#undef wcscat +#undef wcschr +#undef wcscmp +#undef wcscoll +#undef wcscpy +#undef wcscspn +#undef wcsftime +#undef wcslen +#undef wcsncat +#undef wcsncmp +#undef wcsncpy +#undef wcspbrk +#undef wcsrchr +#undef wcsrtombs +#undef wcsspn +#undef wcsstr +#undef wcstod +#if _GLIBCXX_HAVE_WCSTOF +# undef wcstof +#endif +#undef wcstok +#undef wcstol +#undef wcstoul +#undef wcsxfrm +#undef wctob +#undef wmemchr +#undef wmemcmp +#undef wmemcpy +#undef wmemmove +#undef wmemset +#undef wprintf +#undef wscanf + +#if _GLIBCXX_USE_WCHAR_T + +extern "C++" +{ +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + using ::wint_t; + + using ::btowc; + using ::fgetwc; + using ::fgetws; + using ::fputwc; + using ::fputws; + using ::fwide; + using ::fwprintf; + using ::fwscanf; + using ::getwc; + using ::getwchar; + using ::mbrlen; + using ::mbrtowc; + using ::mbsinit; + using ::mbsrtowcs; + using ::putwc; + using ::putwchar; +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF + using ::swprintf; +#endif + using ::swscanf; + using ::ungetwc; + using ::vfwprintf; +#if _GLIBCXX_HAVE_VFWSCANF + using ::vfwscanf; +#endif +#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF + using ::vswprintf; +#endif +#if _GLIBCXX_HAVE_VSWSCANF + using ::vswscanf; +#endif + using ::vwprintf; +#if _GLIBCXX_HAVE_VWSCANF + using ::vwscanf; +#endif + using ::wcrtomb; + using ::wcscat; + using ::wcscmp; + using ::wcscoll; + using ::wcscpy; + using ::wcscspn; + using ::wcsftime; + using ::wcslen; + using ::wcsncat; + using ::wcsncmp; + using ::wcsncpy; + using ::wcsrtombs; + using ::wcsspn; + using ::wcstod; +#if _GLIBCXX_HAVE_WCSTOF + using ::wcstof; +#endif + using ::wcstok; + using ::wcstol; + using ::wcstoul; + using ::wcsxfrm; + using ::wctob; + using ::wmemcmp; + using ::wmemcpy; + using ::wmemmove; + using ::wmemset; + using ::wprintf; + using ::wscanf; + using ::wcschr; + using ::wcspbrk; + using ::wcsrchr; + using ::wcsstr; + using ::wmemchr; + +#ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO + inline wchar_t* + wcschr(wchar_t* __p, wchar_t __c) + { return wcschr(const_cast(__p), __c); } + + inline wchar_t* + wcspbrk(wchar_t* __s1, const wchar_t* __s2) + { return wcspbrk(const_cast(__s1), __s2); } + + inline wchar_t* + wcsrchr(wchar_t* __p, wchar_t __c) + { return wcsrchr(const_cast(__p), __c); } + + inline wchar_t* + wcsstr(wchar_t* __s1, const wchar_t* __s2) + { return wcsstr(const_cast(__s1), __s2); } + + inline wchar_t* + wmemchr(wchar_t* __p, wchar_t __c, size_t __n) + { return wmemchr(const_cast(__p), __c, __n); } +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +} // extern "C++" + +#if _GLIBCXX_USE_C99_WCHAR + +#undef wcstold +#undef wcstoll +#undef wcstoull + +namespace __gnu_cxx +{ +#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC + extern "C" long double + (wcstold)(const wchar_t * __restrict, wchar_t ** __restrict) throw (); +#endif +#if !_GLIBCXX_USE_C99_DYNAMIC + using ::wcstold; +#endif +#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + extern "C" long long int + (wcstoll)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw (); + extern "C" unsigned long long int + (wcstoull)(const wchar_t * __restrict, wchar_t ** __restrict, int) throw (); +#endif +#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC + using ::wcstoll; + using ::wcstoull; +#endif +} // namespace __gnu_cxx + +namespace std +{ + using ::__gnu_cxx::wcstold; + using ::__gnu_cxx::wcstoll; + using ::__gnu_cxx::wcstoull; +} // namespace + +#endif + +#endif //_GLIBCXX_USE_WCHAR_T + +#if __cplusplus >= 201103L + +#ifdef _GLIBCXX_USE_WCHAR_T + +namespace std +{ +#if _GLIBCXX_HAVE_WCSTOF + using std::wcstof; +#endif +#if _GLIBCXX_HAVE_VFWSCANF + using std::vfwscanf; +#endif +#if _GLIBCXX_HAVE_VSWSCANF + using std::vswscanf; +#endif +#if _GLIBCXX_HAVE_VWSCANF + using std::vwscanf; +#endif + +#if _GLIBCXX_USE_C99_WCHAR + using std::wcstold; + using std::wcstoll; + using std::wcstoull; +#endif +} // namespace + +#endif // _GLIBCXX_USE_WCHAR_T + +#endif // C++11 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cwctype b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cwctype new file mode 100755 index 0000000..924b1fa --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cwctype @@ -0,0 +1,110 @@ +// -*- C++ -*- forwarding header. + +// Copyright (C) 1997-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/cwctype + * This is a Standard C++ Library file. You should @c \#include this file + * in your programs, rather than any of the @a *.h implementation files. + * + * This is the C++ version of the Standard C Library header @c wctype.h, + * and its contents are (mostly) the same as that header, but are all + * contained in the namespace @c std (except for names which are defined + * as macros in C). + */ + +// +// ISO C++ 14882: +// + +#pragma GCC system_header + +#include + +#if _GLIBCXX_HAVE_WCTYPE_H + +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 10 +// Work around glibc BZ 9694 +#include +#endif + +#include +#endif // _GLIBCXX_HAVE_WCTYPE_H + +#ifndef _GLIBCXX_CWCTYPE +#define _GLIBCXX_CWCTYPE 1 + +// Get rid of those macros defined in in lieu of real functions. +#undef iswalnum +#undef iswalpha +#if _GLIBCXX_HAVE_ISWBLANK +# undef iswblank +#endif +#undef iswcntrl +#undef iswctype +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef towctrans +#undef towlower +#undef towupper +#undef wctrans +#undef wctype + +#if _GLIBCXX_USE_WCHAR_T + +namespace std +{ + using ::wctrans_t; + using ::wctype_t; + using ::wint_t; + + using ::iswalnum; + using ::iswalpha; +#if _GLIBCXX_HAVE_ISWBLANK + using ::iswblank; +#endif + using ::iswcntrl; + using ::iswctype; + using ::iswdigit; + using ::iswgraph; + using ::iswlower; + using ::iswprint; + using ::iswpunct; + using ::iswspace; + using ::iswupper; + using ::iswxdigit; + using ::towctrans; + using ::towlower; + using ::towupper; + using ::wctrans; + using ::wctype; +} // namespace + +#endif //_GLIBCXX_USE_WCHAR_T + +#endif // _GLIBCXX_CWCTYPE diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cxxabi.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cxxabi.h new file mode 100755 index 0000000..fe067c5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/cxxabi.h @@ -0,0 +1,715 @@ +// ABI Support -*- C++ -*- + +// Copyright (C) 2000-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +// Written by Nathan Sidwell, Codesourcery LLC, + +/* This file declares the new abi entry points into the runtime. It is not + normally necessary for user programs to include this header, or use the + entry points directly. However, this header is available should that be + needed. + + Some of the entry points are intended for both C and C++, thus this header + is includable from both C and C++. Though the C++ specific parts are not + available in C, naturally enough. */ + +/** @file cxxabi.h + * The header provides an interface to the C++ ABI. + */ + +#ifndef _CXXABI_H +#define _CXXABI_H 1 + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +namespace __cxxabiv1 +{ + extern "C" + { +#endif + + typedef __cxa_cdtor_return_type (*__cxa_cdtor_type)(void *); + + // Allocate array. + void* + __cxa_vec_new(size_t __element_count, size_t __element_size, + size_t __padding_size, __cxa_cdtor_type __constructor, + __cxa_cdtor_type __destructor); + + void* + __cxa_vec_new2(size_t __element_count, size_t __element_size, + size_t __padding_size, __cxa_cdtor_type __constructor, + __cxa_cdtor_type __destructor, void *(*__alloc) (size_t), + void (*__dealloc) (void*)); + + void* + __cxa_vec_new3(size_t __element_count, size_t __element_size, + size_t __padding_size, __cxa_cdtor_type __constructor, + __cxa_cdtor_type __destructor, void *(*__alloc) (size_t), + void (*__dealloc) (void*, size_t)); + + // Construct array. + __cxa_vec_ctor_return_type + __cxa_vec_ctor(void* __array_address, size_t __element_count, + size_t __element_size, __cxa_cdtor_type __constructor, + __cxa_cdtor_type __destructor); + + __cxa_vec_ctor_return_type + __cxa_vec_cctor(void* __dest_array, void* __src_array, + size_t __element_count, size_t __element_size, + __cxa_cdtor_return_type (*__constructor) (void*, void*), + __cxa_cdtor_type __destructor); + + // Destruct array. + void + __cxa_vec_dtor(void* __array_address, size_t __element_count, + size_t __element_size, __cxa_cdtor_type __destructor); + + void + __cxa_vec_cleanup(void* __array_address, size_t __element_count, size_t __s, + __cxa_cdtor_type __destructor) _GLIBCXX_NOTHROW; + + // Destruct and release array. + void + __cxa_vec_delete(void* __array_address, size_t __element_size, + size_t __padding_size, __cxa_cdtor_type __destructor); + + void + __cxa_vec_delete2(void* __array_address, size_t __element_size, + size_t __padding_size, __cxa_cdtor_type __destructor, + void (*__dealloc) (void*)); + + void + __cxa_vec_delete3(void* __array_address, size_t __element_size, + size_t __padding_size, __cxa_cdtor_type __destructor, + void (*__dealloc) (void*, size_t)); + + int + __cxa_guard_acquire(__guard*); + + void + __cxa_guard_release(__guard*) _GLIBCXX_NOTHROW; + + void + __cxa_guard_abort(__guard*) _GLIBCXX_NOTHROW; + + // DSO destruction. + int +#ifdef _GLIBCXX_CDTOR_CALLABI + __cxa_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void*) _GLIBCXX_NOTHROW; +#else + __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW; +#endif + + void + __cxa_finalize(void*); + + // TLS destruction. + int +#ifdef _GLIBCXX_CDTOR_CALLABI + __cxa_thread_atexit(void (_GLIBCXX_CDTOR_CALLABI *)(void*), void*, void *) _GLIBCXX_NOTHROW; +#else + __cxa_thread_atexit(void (*)(void*), void*, void *) _GLIBCXX_NOTHROW; +#endif + + // Pure virtual functions. + void + __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); + + void + __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); + + // Exception handling auxiliary. + void + __cxa_bad_cast() __attribute__((__noreturn__)); + + void + __cxa_bad_typeid() __attribute__((__noreturn__)); + + void + __cxa_throw_bad_array_new_length() __attribute__((__noreturn__)); + + /** + * @brief Demangling routine. + * ABI-mandated entry point in the C++ runtime library for demangling. + * + * @param __mangled_name A NUL-terminated character string + * containing the name to be demangled. + * + * @param __output_buffer A region of memory, allocated with + * malloc, of @a *__length bytes, into which the demangled name is + * stored. If @a __output_buffer is not long enough, it is + * expanded using realloc. @a __output_buffer may instead be NULL; + * in that case, the demangled name is placed in a region of memory + * allocated with malloc. + * + * @param __length If @a __length is non-null, the length of the + * buffer containing the demangled name is placed in @a *__length. + * + * @param __status If @a __status is non-null, @a *__status is set to + * one of the following values: + * 0: The demangling operation succeeded. + * -1: A memory allocation failure occurred. + * -2: @a mangled_name is not a valid name under the C++ ABI mangling rules. + * -3: One of the arguments is invalid. + * + * @return A pointer to the start of the NUL-terminated demangled + * name, or NULL if the demangling fails. The caller is + * responsible for deallocating this memory using @c free. + * + * The demangling is performed using the C++ ABI mangling rules, + * with GNU extensions. For example, this function is used in + * __gnu_cxx::__verbose_terminate_handler. + * + * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html + * for other examples of use. + * + * @note The same demangling functionality is available via + * libiberty (@c and @c libiberty.a) in GCC + * 3.1 and later, but that requires explicit installation (@c + * --enable-install-libiberty) and uses a different API, although + * the ABI is unchanged. + */ + char* + __cxa_demangle(const char* __mangled_name, char* __output_buffer, + size_t* __length, int* __status); + +#ifdef __cplusplus + } +} // namespace __cxxabiv1 +#endif + +#ifdef __cplusplus + +#include + +namespace __cxxabiv1 +{ + // Type information for int, float etc. + class __fundamental_type_info : public std::type_info + { + public: + explicit + __fundamental_type_info(const char* __n) : std::type_info(__n) { } + + virtual + ~__fundamental_type_info(); + }; + + // Type information for array objects. + class __array_type_info : public std::type_info + { + public: + explicit + __array_type_info(const char* __n) : std::type_info(__n) { } + + virtual + ~__array_type_info(); + }; + + // Type information for functions (both member and non-member). + class __function_type_info : public std::type_info + { + public: + explicit + __function_type_info(const char* __n) : std::type_info(__n) { } + + virtual + ~__function_type_info(); + + protected: + // Implementation defined member function. + virtual bool + __is_function_p() const; + }; + + // Type information for enumerations. + class __enum_type_info : public std::type_info + { + public: + explicit + __enum_type_info(const char* __n) : std::type_info(__n) { } + + virtual + ~__enum_type_info(); + }; + + // Common type information for simple pointers and pointers to member. + class __pbase_type_info : public std::type_info + { + public: + unsigned int __flags; // Qualification of the target object. + const std::type_info* __pointee; // Type of pointed to object. + + explicit + __pbase_type_info(const char* __n, int __quals, + const std::type_info* __type) + : std::type_info(__n), __flags(__quals), __pointee(__type) + { } + + virtual + ~__pbase_type_info(); + + // Implementation defined type. + enum __masks + { + __const_mask = 0x1, + __volatile_mask = 0x2, + __restrict_mask = 0x4, + __incomplete_mask = 0x8, + __incomplete_class_mask = 0x10, + __transaction_safe_mask = 0x20, + __noexcept_mask = 0x40 + }; + + protected: + __pbase_type_info(const __pbase_type_info&); + + __pbase_type_info& + operator=(const __pbase_type_info&); + + // Implementation defined member functions. + virtual bool + __do_catch(const std::type_info* __thr_type, void** __thr_obj, + unsigned int __outer) const; + + inline virtual bool + __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, + unsigned __outer) const; + }; + + inline bool __pbase_type_info:: + __pointer_catch (const __pbase_type_info *thrown_type, + void **thr_obj, + unsigned outer) const + { + return __pointee->__do_catch (thrown_type->__pointee, thr_obj, outer + 2); + } + + // Type information for simple pointers. + class __pointer_type_info : public __pbase_type_info + { + public: + explicit + __pointer_type_info(const char* __n, int __quals, + const std::type_info* __type) + : __pbase_type_info (__n, __quals, __type) { } + + + virtual + ~__pointer_type_info(); + + protected: + // Implementation defined member functions. + virtual bool + __is_pointer_p() const; + + virtual bool + __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, + unsigned __outer) const; + }; + + class __class_type_info; + + // Type information for a pointer to member variable. + class __pointer_to_member_type_info : public __pbase_type_info + { + public: + __class_type_info* __context; // Class of the member. + + explicit + __pointer_to_member_type_info(const char* __n, int __quals, + const std::type_info* __type, + __class_type_info* __klass) + : __pbase_type_info(__n, __quals, __type), __context(__klass) { } + + virtual + ~__pointer_to_member_type_info(); + + protected: + __pointer_to_member_type_info(const __pointer_to_member_type_info&); + + __pointer_to_member_type_info& + operator=(const __pointer_to_member_type_info&); + + // Implementation defined member function. + virtual bool + __pointer_catch(const __pbase_type_info* __thr_type, void** __thr_obj, + unsigned __outer) const; + }; + + // Helper class for __vmi_class_type. + class __base_class_type_info + { + public: + const __class_type_info* __base_type; // Base class type. +#ifdef _GLIBCXX_LLP64 + long long __offset_flags; // Offset and info. +#else + long __offset_flags; // Offset and info. +#endif + + enum __offset_flags_masks + { + __virtual_mask = 0x1, + __public_mask = 0x2, + __hwm_bit = 2, + __offset_shift = 8 // Bits to shift offset. + }; + + // Implementation defined member functions. + bool + __is_virtual_p() const + { return __offset_flags & __virtual_mask; } + + bool + __is_public_p() const + { return __offset_flags & __public_mask; } + + ptrdiff_t + __offset() const + { + // This shift, being of a signed type, is implementation + // defined. GCC implements such shifts as arithmetic, which is + // what we want. + return static_cast(__offset_flags) >> __offset_shift; + } + }; + + // Type information for a class. + class __class_type_info : public std::type_info + { + public: + explicit + __class_type_info (const char *__n) : type_info(__n) { } + + virtual + ~__class_type_info (); + + // Implementation defined types. + // The type sub_kind tells us about how a base object is contained + // within a derived object. We often do this lazily, hence the + // UNKNOWN value. At other times we may use NOT_CONTAINED to mean + // not publicly contained. + enum __sub_kind + { + // We have no idea. + __unknown = 0, + + // Not contained within us (in some circumstances this might + // mean not contained publicly) + __not_contained, + + // Contained ambiguously. + __contained_ambig, + + // Via a virtual path. + __contained_virtual_mask = __base_class_type_info::__virtual_mask, + + // Via a public path. + __contained_public_mask = __base_class_type_info::__public_mask, + + // Contained within us. + __contained_mask = 1 << __base_class_type_info::__hwm_bit, + + __contained_private = __contained_mask, + __contained_public = __contained_mask | __contained_public_mask + }; + + struct __upcast_result; + struct __dyncast_result; + + protected: + // Implementation defined member functions. + virtual bool + __do_upcast(const __class_type_info* __dst_type, void**__obj_ptr) const; + + virtual bool + __do_catch(const type_info* __thr_type, void** __thr_obj, + unsigned __outer) const; + + public: + // Helper for upcast. See if DST is us, or one of our bases. + // Return false if not found, true if found. + virtual bool + __do_upcast(const __class_type_info* __dst, const void* __obj, + __upcast_result& __restrict __result) const; + + // Indicate whether SRC_PTR of type SRC_TYPE is contained publicly + // within OBJ_PTR. OBJ_PTR points to a base object of our type, + // which is the destination type. SRC2DST indicates how SRC + // objects might be contained within this type. If SRC_PTR is one + // of our SRC_TYPE bases, indicate the virtuality. Returns + // not_contained for non containment or private containment. + inline __sub_kind + __find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, + const __class_type_info* __src_type, + const void* __src_ptr) const; + + // Helper for dynamic cast. ACCESS_PATH gives the access from the + // most derived object to this base. DST_TYPE indicates the + // desired type we want. OBJ_PTR points to a base of our type + // within the complete object. SRC_TYPE indicates the static type + // started from and SRC_PTR points to that base within the most + // derived object. Fill in RESULT with what we find. Return true + // if we have located an ambiguous match. + virtual bool + __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, + const __class_type_info* __dst_type, const void* __obj_ptr, + const __class_type_info* __src_type, const void* __src_ptr, + __dyncast_result& __result) const; + + // Helper for find_public_subobj. SRC2DST indicates how SRC_TYPE + // bases are inherited by the type started from -- which is not + // necessarily the current type. The current type will be a base + // of the destination type. OBJ_PTR points to the current base. + virtual __sub_kind + __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, + const __class_type_info* __src_type, + const void* __src_ptr) const; + }; + + // Type information for a class with a single non-virtual base. + class __si_class_type_info : public __class_type_info + { + public: + const __class_type_info* __base_type; + + explicit + __si_class_type_info(const char *__n, const __class_type_info *__base) + : __class_type_info(__n), __base_type(__base) { } + + virtual + ~__si_class_type_info(); + + protected: + __si_class_type_info(const __si_class_type_info&); + + __si_class_type_info& + operator=(const __si_class_type_info&); + + // Implementation defined member functions. + virtual bool + __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, + const __class_type_info* __dst_type, const void* __obj_ptr, + const __class_type_info* __src_type, const void* __src_ptr, + __dyncast_result& __result) const; + + virtual __sub_kind + __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, + const __class_type_info* __src_type, + const void* __sub_ptr) const; + + virtual bool + __do_upcast(const __class_type_info*__dst, const void*__obj, + __upcast_result& __restrict __result) const; + }; + + // Type information for a class with multiple and/or virtual bases. + class __vmi_class_type_info : public __class_type_info + { + public: + unsigned int __flags; // Details about the class hierarchy. + unsigned int __base_count; // Number of direct bases. + + // The array of bases uses the trailing array struct hack so this + // class is not constructable with a normal constructor. It is + // internally generated by the compiler. + __base_class_type_info __base_info[1]; // Array of bases. + + explicit + __vmi_class_type_info(const char* __n, int ___flags) + : __class_type_info(__n), __flags(___flags), __base_count(0) { } + + virtual + ~__vmi_class_type_info(); + + // Implementation defined types. + enum __flags_masks + { + __non_diamond_repeat_mask = 0x1, // Distinct instance of repeated base. + __diamond_shaped_mask = 0x2, // Diamond shaped multiple inheritance. + __flags_unknown_mask = 0x10 + }; + + protected: + // Implementation defined member functions. + virtual bool + __do_dyncast(ptrdiff_t __src2dst, __sub_kind __access_path, + const __class_type_info* __dst_type, const void* __obj_ptr, + const __class_type_info* __src_type, const void* __src_ptr, + __dyncast_result& __result) const; + + virtual __sub_kind + __do_find_public_src(ptrdiff_t __src2dst, const void* __obj_ptr, + const __class_type_info* __src_type, + const void* __src_ptr) const; + + virtual bool + __do_upcast(const __class_type_info* __dst, const void* __obj, + __upcast_result& __restrict __result) const; + }; + + // Exception handling forward declarations. + struct __cxa_exception; + struct __cxa_refcounted_exception; + struct __cxa_dependent_exception; + struct __cxa_eh_globals; + + extern "C" + { + // Dynamic cast runtime. + + // src2dst has the following possible values + // >-1: src_type is a unique public non-virtual base of dst_type + // dst_ptr + src2dst == src_ptr + // -1: unspecified relationship + // -2: src_type is not a public base of dst_type + // -3: src_type is a multiple public non-virtual base of dst_type + void* + __dynamic_cast(const void* __src_ptr, // Starting object. + const __class_type_info* __src_type, // Static type of object. + const __class_type_info* __dst_type, // Desired target type. + ptrdiff_t __src2dst); // How src and dst are related. + + + // Exception handling runtime. + + // The __cxa_eh_globals for the current thread can be obtained by using + // either of the following functions. The "fast" version assumes at least + // one prior call of __cxa_get_globals has been made from the current + // thread, so no initialization is necessary. + __cxa_eh_globals* + __cxa_get_globals() _GLIBCXX_NOTHROW __attribute__ ((__const__)); + + __cxa_eh_globals* + __cxa_get_globals_fast() _GLIBCXX_NOTHROW __attribute__ ((__const__)); + + // Free the space allocated for the primary exception. + void + __cxa_free_exception(void*) _GLIBCXX_NOTHROW; + + // Throw the exception. + void + __cxa_throw(void*, std::type_info*, void (_GLIBCXX_CDTOR_CALLABI *) (void *)) + __attribute__((__noreturn__)); + + // Used to implement exception handlers. + void* + __cxa_get_exception_ptr(void*) _GLIBCXX_NOTHROW __attribute__ ((__pure__)); + + void* + __cxa_begin_catch(void*) _GLIBCXX_NOTHROW; + + void + __cxa_end_catch(); + + void + __cxa_rethrow() __attribute__((__noreturn__)); + + // Returns the type_info for the currently handled exception [15.3/8], or + // null if there is none. + std::type_info* + __cxa_current_exception_type() _GLIBCXX_NOTHROW __attribute__ ((__pure__)); + + // GNU Extensions. + + // Allocate memory for a dependent exception. + __cxa_dependent_exception* + __cxa_allocate_dependent_exception() _GLIBCXX_NOTHROW; + + // Free the space allocated for the dependent exception. + void + __cxa_free_dependent_exception(__cxa_dependent_exception*) _GLIBCXX_NOTHROW; + + } // extern "C" + + // A magic placeholder class that can be caught by reference + // to recognize foreign exceptions. + class __foreign_exception + { + virtual ~__foreign_exception() throw(); + virtual void __pure_dummy() = 0; // prevent catch by value + }; + +} // namespace __cxxabiv1 + +/** @namespace abi + * @brief The cross-vendor C++ Application Binary Interface. A + * namespace alias to __cxxabiv1, but user programs should use the + * alias 'abi'. + * + * A brief overview of an ABI is given in the libstdc++ FAQ, question + * 5.8 (you may have a copy of the FAQ locally, or you can view the online + * version at http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#5_8 ). + * + * GCC subscribes to a cross-vendor ABI for C++, sometimes + * called the IA64 ABI because it happens to be the native ABI for that + * platform. It is summarized at http://www.codesourcery.com/cxx-abi/ + * along with the current specification. + * + * For users of GCC greater than or equal to 3.x, entry points are + * available in , which notes, 'It is not normally + * necessary for user programs to include this header, or use the + * entry points directly. However, this header is available should + * that be needed.' +*/ +namespace abi = __cxxabiv1; + +namespace __gnu_cxx +{ + /** + * @brief Exception thrown by __cxa_guard_acquire. + * @ingroup exceptions + * + * C++ 2011 6.7 [stmt.dcl]/4: If control re-enters the declaration + * recursively while the variable is being initialized, the behavior + * is undefined. + * + * Since we already have a library function to handle locking, we might + * as well check for this situation and throw an exception. + * We use the second byte of the guard variable to remember that we're + * in the middle of an initialization. + */ + class recursive_init_error: public std::exception + { + public: + recursive_init_error() _GLIBCXX_NOTHROW; + virtual ~recursive_init_error() _GLIBCXX_NOTHROW; + }; +} +#endif // __cplusplus + +#pragma GCC visibility pop + +#endif // __CXXABI_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/assertions.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/assertions.h new file mode 100755 index 0000000..e34061e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/assertions.h @@ -0,0 +1,70 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/assertions.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_ASSERTIONS_H +#define _GLIBCXX_DEBUG_ASSERTIONS_H 1 + +#include + +#ifndef _GLIBCXX_DEBUG + +# define _GLIBCXX_DEBUG_ASSERT(_Condition) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# define _GLIBCXX_DEBUG_ONLY(_Statement) + +#endif + +#ifndef _GLIBCXX_ASSERTIONS +# define __glibcxx_requires_non_empty_range(_First,_Last) +# define __glibcxx_requires_nonempty() +# define __glibcxx_requires_subscript(_N) +#else + +// Verify that [_First, _Last) forms a non-empty iterator range. +# define __glibcxx_requires_non_empty_range(_First,_Last) \ + __glibcxx_assert(_First != _Last) +# define __glibcxx_requires_subscript(_N) \ + __glibcxx_assert(_N < this->size()) +// Verify that the container is nonempty +# define __glibcxx_requires_nonempty() \ + __glibcxx_assert(!this->empty()) +#endif + +#ifdef _GLIBCXX_DEBUG +# define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition) + +# ifdef _GLIBCXX_DEBUG_PEDANTIC +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition) +# else +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# endif + +# define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement +#endif + +#endif // _GLIBCXX_DEBUG_ASSERTIONS diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/bitset b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/bitset new file mode 100755 index 0000000..782785c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/bitset @@ -0,0 +1,429 @@ +// Debugging bitset implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/bitset + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_BITSET +#define _GLIBCXX_DEBUG_BITSET + +#pragma GCC system_header + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::bitset with additional safety/checking/debug instrumentation. + template + class bitset + : public _GLIBCXX_STD_C::bitset<_Nb> +#if __cplusplus < 201103L + , public __gnu_debug::_Safe_sequence_base +#endif + { + typedef _GLIBCXX_STD_C::bitset<_Nb> _Base; + + public: + // In C++11 we rely on normal reference type to preserve the property + // of bitset to be use as a literal. + // TODO: Find another solution. +#if __cplusplus >= 201103L + typedef typename _Base::reference reference; +#else + // bit reference: + class reference + : private _Base::reference + , public __gnu_debug::_Safe_iterator_base + { + typedef typename _Base::reference _Base_ref; + + friend class bitset; + reference(); + + reference(const _Base_ref& __base, bitset* __seq) _GLIBCXX_NOEXCEPT + : _Base_ref(__base) + , _Safe_iterator_base(__seq, false) + { } + + public: + reference(const reference& __x) _GLIBCXX_NOEXCEPT + : _Base_ref(__x) + , _Safe_iterator_base(__x, false) + { } + + reference& + operator=(bool __x) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__gnu_debug::__msg_bad_bitset_write) + ._M_iterator(*this)); + *static_cast<_Base_ref*>(this) = __x; + return *this; + } + + reference& + operator=(const reference& __x) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + _M_message(__gnu_debug::__msg_bad_bitset_read) + ._M_iterator(__x)); + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__gnu_debug::__msg_bad_bitset_write) + ._M_iterator(*this)); + *static_cast<_Base_ref*>(this) = __x; + return *this; + } + + bool + operator~() const _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__gnu_debug::__msg_bad_bitset_read) + ._M_iterator(*this)); + return ~(*static_cast(this)); + } + + operator bool() const _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__gnu_debug::__msg_bad_bitset_read) + ._M_iterator(*this)); + return *static_cast(this); + } + + reference& + flip() _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__gnu_debug::__msg_bad_bitset_flip) + ._M_iterator(*this)); + _Base_ref::flip(); + return *this; + } + }; +#endif + + // 23.3.5.1 constructors: + _GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT + : _Base() { } + +#if __cplusplus >= 201103L + constexpr bitset(unsigned long long __val) noexcept +#else + bitset(unsigned long __val) +#endif + : _Base(__val) { } + + template + explicit + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str, + typename std::basic_string<_CharT, _Traits, _Alloc>::size_type + __pos = 0, + typename std::basic_string<_CharT, _Traits, _Alloc>::size_type + __n = (std::basic_string<_CharT, _Traits, _Alloc>::npos)) + : _Base(__str, __pos, __n) { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template + bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str, + typename std::basic_string<_CharT, _Traits, _Alloc>::size_type + __pos, + typename std::basic_string<_CharT, _Traits, _Alloc>::size_type + __n, + _CharT __zero, _CharT __one = _CharT('1')) + : _Base(__str, __pos, __n, __zero, __one) { } + + bitset(const _Base& __x) : _Base(__x) { } + +#if __cplusplus >= 201103L + template + explicit + bitset(const _CharT* __str, + typename std::basic_string<_CharT>::size_type __n + = std::basic_string<_CharT>::npos, + _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) + : _Base(__str, __n, __zero, __one) { } +#endif + + // 23.3.5.2 bitset operations: + bitset<_Nb>& + operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + _M_base() &= __rhs; + return *this; + } + + bitset<_Nb>& + operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + _M_base() |= __rhs; + return *this; + } + + bitset<_Nb>& + operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT + { + _M_base() ^= __rhs; + return *this; + } + + bitset<_Nb>& + operator<<=(size_t __pos) _GLIBCXX_NOEXCEPT + { + _M_base() <<= __pos; + return *this; + } + + bitset<_Nb>& + operator>>=(size_t __pos) _GLIBCXX_NOEXCEPT + { + _M_base() >>= __pos; + return *this; + } + + bitset<_Nb>& + set() _GLIBCXX_NOEXCEPT + { + _Base::set(); + return *this; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 186. bitset::set() second parameter should be bool + bitset<_Nb>& + set(size_t __pos, bool __val = true) + { + _Base::set(__pos, __val); + return *this; + } + + bitset<_Nb>& + reset() _GLIBCXX_NOEXCEPT + { + _Base::reset(); + return *this; + } + + bitset<_Nb>& + reset(size_t __pos) + { + _Base::reset(__pos); + return *this; + } + + bitset<_Nb> + operator~() const _GLIBCXX_NOEXCEPT + { return bitset(~_M_base()); } + + bitset<_Nb>& + flip() _GLIBCXX_NOEXCEPT + { + _Base::flip(); + return *this; + } + + bitset<_Nb>& + flip(size_t __pos) + { + _Base::flip(__pos); + return *this; + } + + // element access: + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 11. Bitset minor problems + reference + operator[](size_t __pos) + { + __glibcxx_check_subscript(__pos); +#if __cplusplus >= 201103L + return _M_base()[__pos]; +#else + return reference(_M_base()[__pos], this); +#endif + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 11. Bitset minor problems + _GLIBCXX_CONSTEXPR bool + operator[](size_t __pos) const + { +#if __cplusplus < 201103L + // TODO: Check in debug-mode too. + __glibcxx_check_subscript(__pos); +#endif + return _Base::operator[](__pos); + } + + using _Base::to_ulong; +#if __cplusplus >= 201103L + using _Base::to_ullong; +#endif + + template + std::basic_string<_CharT, _Traits, _Alloc> + to_string() const + { return _M_base().template to_string<_CharT, _Traits, _Alloc>(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 396. what are characters zero and one. + template + std::basic_string<_CharT, _Traits, _Alloc> + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + return _M_base().template + to_string<_CharT, _Traits, _Alloc>(__zero, __one); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 434. bitset::to_string() hard to use. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string() const + { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 853. to_string needs updating with zero and one. + template + std::basic_string<_CharT, _Traits, std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { return to_string<_CharT, _Traits, + std::allocator<_CharT> >(__zero, __one); } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string() const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(); + } + + template + std::basic_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> > + to_string(_CharT __zero, _CharT __one = _CharT('1')) const + { + return to_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT> >(__zero, __one); + } + + std::basic_string, std::allocator > + to_string() const + { + return to_string,std::allocator >(); + } + + std::basic_string, std::allocator > + to_string(char __zero, char __one = '1') const + { + return to_string, + std::allocator >(__zero, __one); + } + + using _Base::count; + using _Base::size; + + bool + operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT + { return _M_base() == __rhs._M_base(); } + +#if __cpp_impl_three_way_comparison < 201907L + bool + operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT + { return _M_base() != __rhs._M_base(); } +#endif + + using _Base::test; + using _Base::all; + using _Base::any; + using _Base::none; + + bitset<_Nb> + operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(_M_base() << __pos); } + + bitset<_Nb> + operator>>(size_t __pos) const _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(_M_base() >> __pos); } + + _Base& + _M_base() _GLIBCXX_NOEXCEPT + { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT + { return *this; } + }; + + template + bitset<_Nb> + operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(__x) &= __y; } + + template + bitset<_Nb> + operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(__x) |= __y; } + + template + bitset<_Nb> + operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT + { return bitset<_Nb>(__x) ^= __y; } + + template + std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) + { return __is >> __x._M_base(); } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const bitset<_Nb>& __x) + { return __os << __x._M_base(); } + +} // namespace __debug + +#if __cplusplus >= 201103L + // DR 1182. + /// std::hash specialization for bitset. + template + struct hash<__debug::bitset<_Nb>> + : public __hash_base> + { + size_t + operator()(const __debug::bitset<_Nb>& __b) const noexcept + { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); } + }; +#endif + +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/debug.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/debug.h new file mode 100755 index 0000000..116f2f0 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/debug.h @@ -0,0 +1,137 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/debug.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H +#define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1 + +/** Macros and namespaces used by the implementation outside of debug + * wrappers to verify certain properties. The __glibcxx_requires_xxx + * macros are merely wrappers around the __glibcxx_check_xxx wrappers + * when we are compiling with debug mode, but disappear when we are + * in release mode so that there is no checking performed in, e.g., + * the standard library algorithms. +*/ + +#include + +// Debug mode namespaces. + +/** + * @namespace std::__debug + * @brief GNU debug code, replaces standard behavior with debug behavior. + */ +namespace std +{ + namespace __debug { } +} + +/** @namespace __gnu_debug + * @brief GNU debug classes for public use. +*/ +namespace __gnu_debug +{ + using namespace std::__debug; + + template + struct _Safe_iterator; +} + +#ifndef _GLIBCXX_DEBUG + +# define __glibcxx_requires_cond(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) +# define __glibcxx_requires_can_increment(_First,_Size) +# define __glibcxx_requires_can_increment_range(_First1,_Last1,_First2) +# define __glibcxx_requires_can_decrement_range(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) +# define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) +# define __glibcxx_requires_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) +# define __glibcxx_requires_irreflexive(_First,_Last) +# define __glibcxx_requires_irreflexive2(_First,_Last) +# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) +# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) + +#else + +# include + +# define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg) +# define __glibcxx_requires_valid_range(_First,_Last) \ + __glibcxx_check_valid_range(_First,_Last) +# define __glibcxx_requires_can_increment(_First,_Size) \ + __glibcxx_check_can_increment(_First,_Size) +# define __glibcxx_requires_can_increment_range(_First1,_Last1,_First2) \ + __glibcxx_check_can_increment_range(_First1,_Last1,_First2) +# define __glibcxx_requires_can_decrement_range(_First1,_Last1,_First2) \ + __glibcxx_check_can_decrement_range(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted(_First,_Last) \ + __glibcxx_check_sorted(_First,_Last) +# define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \ + __glibcxx_check_sorted_pred(_First,_Last,_Pred) +# define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \ + __glibcxx_check_sorted_set(_First1,_Last1,_First2) +# define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ + __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) +# define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \ + __glibcxx_check_partitioned_lower(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \ + __glibcxx_check_partitioned_upper(_First,_Last,_Value) +# define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ + __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ + __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) +# define __glibcxx_requires_heap(_First,_Last) \ + __glibcxx_check_heap(_First,_Last) +# define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \ + __glibcxx_check_heap_pred(_First,_Last,_Pred) +# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String) +# define __glibcxx_requires_string_len(_String,_Len) \ + __glibcxx_check_string_len(_String,_Len) +# define __glibcxx_requires_irreflexive(_First,_Last) \ + __glibcxx_check_irreflexive(_First,_Last) +# define __glibcxx_requires_irreflexive2(_First,_Last) \ + __glibcxx_check_irreflexive2(_First,_Last) +# define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) \ + __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) +# define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) \ + __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) + +# include + +#endif + +#endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/deque b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/deque new file mode 100755 index 0000000..4d19ec8 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/deque @@ -0,0 +1,712 @@ +// Debugging deque implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/deque + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_DEQUE +#define _GLIBCXX_DEBUG_DEQUE 1 + +#pragma GCC system_header + +#include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template class deque; +} } // namespace std::__debug + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::deque with safety/checking/debug instrumentation. + template > + class deque + : public __gnu_debug::_Safe_container< + deque<_Tp, _Allocator>, _Allocator, + __gnu_debug::_Safe_sequence>, + public _GLIBCXX_STD_C::deque<_Tp, _Allocator> + { + typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + deque, _Allocator, __gnu_debug::_Safe_sequence> _Safe; + + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates deque(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator<_Base_iterator, deque> + iterator; + typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, deque> + const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + + typedef _Tp value_type; + typedef _Allocator allocator_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.2.1.1 construct/copy/destroy: + +#if __cplusplus < 201103L + deque() + : _Base() { } + + deque(const deque& __x) + : _Base(__x) { } + + ~deque() { } +#else + deque() = default; + deque(const deque&) = default; + deque(deque&&) = default; + + deque(const deque& __d, const _Allocator& __a) + : _Base(__d, __a) { } + + deque(deque&& __d, const _Allocator& __a) + : _Safe(std::move(__d)), _Base(std::move(__d), __a) { } + + deque(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__l, __a) { } + + ~deque() = default; +#endif + + explicit + deque(const _Allocator& __a) + : _Base(__a) { } + +#if __cplusplus >= 201103L + explicit + deque(size_type __n, const _Allocator& __a = _Allocator()) + : _Base(__n, __a) { } + + deque(size_type __n, const __type_identity_t<_Tp>& __value, + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } +#else + explicit + deque(size_type __n, const _Tp& __value = _Tp(), + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } +#endif + +#if __cplusplus >= 201103L + template> +#else + template +#endif + deque(_InputIterator __first, _InputIterator __last, + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) + { } + + deque(_Base_ref __x) + : _Base(__x._M_ref) { } + +#if __cplusplus < 201103L + deque& + operator=(const deque& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + return *this; + } +#else + deque& + operator=(const deque&) = default; + + deque& + operator=(deque&&) = default; + + deque& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } +#endif + +#if __cplusplus >= 201103L + template> +#else + template +#endif + void + assign(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::assign(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::assign(__first, __last); + + this->_M_invalidate_all(); + } + + void + assign(size_type __n, const _Tp& __t) + { + _Base::assign(__n, __t); + this->_M_invalidate_all(); + } + +#if __cplusplus >= 201103L + void + assign(initializer_list __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + } +#endif + + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + private: + void + _M_invalidate_after_nth(difference_type __n) + { + typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth; + this->_M_invalidate_if(_After_nth(__n, _Base::begin())); + } + + public: + // 23.2.1.2 capacity: + using _Base::size; + using _Base::max_size; + +#if __cplusplus >= 201103L + void + resize(size_type __sz) + { + bool __invalidate_all = __sz > this->size(); + if (__sz < this->size()) + this->_M_invalidate_after_nth(__sz); + + _Base::resize(__sz); + + if (__invalidate_all) + this->_M_invalidate_all(); + } + + void + resize(size_type __sz, const _Tp& __c) + { + bool __invalidate_all = __sz > this->size(); + if (__sz < this->size()) + this->_M_invalidate_after_nth(__sz); + + _Base::resize(__sz, __c); + + if (__invalidate_all) + this->_M_invalidate_all(); + } +#else + void + resize(size_type __sz, _Tp __c = _Tp()) + { + bool __invalidate_all = __sz > this->size(); + if (__sz < this->size()) + this->_M_invalidate_after_nth(__sz); + + _Base::resize(__sz, __c); + + if (__invalidate_all) + this->_M_invalidate_all(); + } +#endif + +#if __cplusplus >= 201103L + void + shrink_to_fit() noexcept + { + if (_Base::_M_shrink_to_fit()) + this->_M_invalidate_all(); + } +#endif + + using _Base::empty; + + // element access: + reference + operator[](size_type __n) _GLIBCXX_NOEXCEPT + { + __glibcxx_check_subscript(__n); + return _M_base()[__n]; + } + + const_reference + operator[](size_type __n) const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_subscript(__n); + return _M_base()[__n]; + } + + using _Base::at; + + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::back(); + } + + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::back(); + } + + // 23.2.1.3 modifiers: + void + push_front(const _Tp& __x) + { + _Base::push_front(__x); + this->_M_invalidate_all(); + } + + void + push_back(const _Tp& __x) + { + _Base::push_back(__x); + this->_M_invalidate_all(); + } + +#if __cplusplus >= 201103L + void + push_front(_Tp&& __x) + { emplace_front(std::move(__x)); } + + void + push_back(_Tp&& __x) + { emplace_back(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_front(_Args&&... __args) + { + _Base::emplace_front(std::forward<_Args>(__args)...); + this->_M_invalidate_all(); +#if __cplusplus > 201402L + return front(); +#endif + } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + _Base::emplace_back(std::forward<_Args>(__args)...); + this->_M_invalidate_all(); +#if __cplusplus > 201402L + return back(); +#endif + } + + template + iterator + emplace(const_iterator __position, _Args&&... __args) + { + __glibcxx_check_insert(__position); + _Base_iterator __res = _Base::emplace(__position.base(), + std::forward<_Args>(__args)...); + this->_M_invalidate_all(); + return iterator(__res, this); + } +#endif + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else + insert(iterator __position, const _Tp& __x) +#endif + { + __glibcxx_check_insert(__position); + _Base_iterator __res = _Base::insert(__position.base(), __x); + this->_M_invalidate_all(); + return iterator(__res, this); + } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, _Tp&& __x) + { return emplace(__position, std::move(__x)); } + + iterator + insert(const_iterator __position, initializer_list __l) + { + __glibcxx_check_insert(__position); + _Base_iterator __res = _Base::insert(__position.base(), __l); + this->_M_invalidate_all(); + return iterator(__res, this); + } +#endif + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + _Base_iterator __res = _Base::insert(__position.base(), __n, __x); + this->_M_invalidate_all(); + return iterator(__res, this); + } +#else + void + insert(iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + _Base::insert(__position.base(), __n, __x); + this->_M_invalidate_all(); + } +#endif + +#if __cplusplus >= 201103L + template> + iterator + insert(const_iterator __position, + _InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__position, __first, __last, __dist); + _Base_iterator __res; + if (__dist.second >= __gnu_debug::__dp_sign) + __res = _Base::insert(__position.base(), + __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + __res = _Base::insert(__position.base(), __first, __last); + + this->_M_invalidate_all(); + return iterator(__res, this); + } +#else + template + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__position, __first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__position.base(), + __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__position.base(), __first, __last); + + this->_M_invalidate_all(); + } +#endif + + void + pop_front() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + this->_M_invalidate_if(_Equal(_Base::begin())); + _Base::pop_front(); + } + + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + this->_M_invalidate_if(_Equal(--_Base::end())); + _Base::pop_back(); + } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { + __glibcxx_check_erase(__position); +#if __cplusplus >= 201103L + _Base_const_iterator __victim = __position.base(); +#else + _Base_iterator __victim = __position.base(); +#endif + if (__victim == _Base::begin() || __victim == _Base::end() - 1) + { + this->_M_invalidate_if(_Equal(__victim)); + return iterator(_Base::erase(__victim), this); + } + else + { + _Base_iterator __res = _Base::erase(__victim); + this->_M_invalidate_all(); + return iterator(__res, this); + } + } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) +#else + erase(iterator __first, iterator __last) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + + if (__first.base() == __last.base()) +#if __cplusplus >= 201103L + return iterator(__first.base()._M_const_cast(), this); +#else + return __first; +#endif + else if (__first.base() == _Base::begin() + || __last.base() == _Base::end()) + { + this->_M_detach_singular(); + for (_Base_const_iterator __position = __first.base(); + __position != __last.base(); ++__position) + { + this->_M_invalidate_if(_Equal(__position)); + } + __try + { + return iterator(_Base::erase(__first.base(), __last.base()), + this); + } + __catch(...) + { + this->_M_revalidate_singular(); + __throw_exception_again; + } + } + else + { + _Base_iterator __res = _Base::erase(__first.base(), + __last.base()); + this->_M_invalidate_all(); + return iterator(__res, this); + } + } + + void + swap(deque& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + _Base::clear(); + this->_M_invalidate_all(); + } + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + deque(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> deque<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + deque(size_t, _Tp, _Allocator = _Allocator()) + -> deque<_Tp, _Allocator>; +#endif + + template + inline bool + operator==(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) + { return __x._M_base() <=> __y._M_base(); } +#else + template + inline bool + operator!=(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const deque<_Tp, _Alloc>& __lhs, + const deque<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + inline void + swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + +} // namespace __debug +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/formatter.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/formatter.h new file mode 100755 index 0000000..7140fed --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/formatter.h @@ -0,0 +1,594 @@ +// Debug-mode error formatting implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/formatter.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_FORMATTER_H +#define _GLIBCXX_DEBUG_FORMATTER_H 1 + +#include + +#if __cpp_rtti +# include +# define _GLIBCXX_TYPEID(_Type) &typeid(_Type) +#else +namespace std +{ + class type_info; +} +# define _GLIBCXX_TYPEID(_Type) 0 +#endif + +#if __cplusplus >= 201103L +namespace __gnu_cxx +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +template + class __normal_iterator; + +_GLIBCXX_END_NAMESPACE_VERSION +} + +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +template + class reverse_iterator; + +template + class move_iterator; + +_GLIBCXX_END_NAMESPACE_VERSION +} +#endif + +namespace __gnu_debug +{ + using std::type_info; + + template + _GLIBCXX_CONSTEXPR + bool __check_singular(_Iterator const&); + + class _Safe_sequence_base; + + template + class _Safe_iterator; + + template + class _Safe_local_iterator; + + template + class _Safe_sequence; + + enum _Debug_msg_id + { + // General checks + __msg_valid_range, + __msg_insert_singular, + __msg_insert_different, + __msg_erase_bad, + __msg_erase_different, + __msg_subscript_oob, + __msg_empty, + __msg_unpartitioned, + __msg_unpartitioned_pred, + __msg_unsorted, + __msg_unsorted_pred, + __msg_not_heap, + __msg_not_heap_pred, + // std::bitset checks + __msg_bad_bitset_write, + __msg_bad_bitset_read, + __msg_bad_bitset_flip, + // std::list checks + __msg_self_splice, + __msg_splice_alloc, + __msg_splice_bad, + __msg_splice_other, + __msg_splice_overlap, + // iterator checks + __msg_init_singular, + __msg_init_copy_singular, + __msg_init_const_singular, + __msg_copy_singular, + __msg_bad_deref, + __msg_bad_inc, + __msg_bad_dec, + __msg_iter_subscript_oob, + __msg_advance_oob, + __msg_retreat_oob, + __msg_iter_compare_bad, + __msg_compare_different, + __msg_iter_order_bad, + __msg_order_different, + __msg_distance_bad, + __msg_distance_different, + // istream_iterator + __msg_deref_istream, + __msg_inc_istream, + // ostream_iterator + __msg_output_ostream, + // istreambuf_iterator + __msg_deref_istreambuf, + __msg_inc_istreambuf, + // forward_list + __msg_insert_after_end, + __msg_erase_after_bad, + __msg_valid_range2, + // unordered container local iterators + __msg_local_iter_compare_bad, + __msg_non_empty_range, + // self move assign (no longer used) + __msg_self_move_assign, + // unordered container buckets + __msg_bucket_index_oob, + __msg_valid_load_factor, + // others + __msg_equal_allocs, + __msg_insert_range_from_self, + __msg_irreflexive_ordering + }; + + class _Error_formatter + { + // Tags denoting the type of parameter for construction + struct _Is_iterator { }; + struct _Is_iterator_value_type { }; + struct _Is_sequence { }; + struct _Is_instance { }; + + public: + /// Whether an iterator is constant, mutable, or unknown + enum _Constness + { + __unknown_constness, + __const_iterator, + __mutable_iterator, + __last_constness + }; + + // The state of the iterator (fine-grained), if we know it. + enum _Iterator_state + { + __unknown_state, + __singular, // singular, may still be attached to a sequence + __begin, // dereferenceable, and at the beginning + __middle, // dereferenceable, not at the beginning + __end, // past-the-end, may be at beginning if sequence empty + __before_begin, // before begin + __rbegin, // dereferenceable, and at the reverse-beginning + __rmiddle, // reverse-dereferenceable, not at the reverse-beginning + __rend, // reverse-past-the-end + __last_state + }; + + // A parameter that may be referenced by an error message + struct _Parameter + { + enum + { + __unused_param, + __iterator, + __sequence, + __integer, + __string, + __instance, + __iterator_value_type + } _M_kind; + + struct _Type + { + const char* _M_name; + const type_info* _M_type; + }; + + struct _Instance : _Type + { + const void* _M_address; + }; + + union + { + // When _M_kind == __iterator + struct : _Instance + { + _Constness _M_constness; + _Iterator_state _M_state; + const void* _M_sequence; + const type_info* _M_seq_type; + } _M_iterator; + + // When _M_kind == __sequence + _Instance _M_sequence; + + // When _M_kind == __integer + struct + { + const char* _M_name; + long _M_value; + } _M_integer; + + // When _M_kind == __string + struct + { + const char* _M_name; + const char* _M_value; + } _M_string; + + // When _M_kind == __instance + _Instance _M_instance; + + // When _M_kind == __iterator_value_type + _Type _M_iterator_value_type; + } _M_variant; + + _Parameter() : _M_kind(__unused_param), _M_variant() { } + + _Parameter(long __value, const char* __name) + : _M_kind(__integer), _M_variant() + { + _M_variant._M_integer._M_name = __name; + _M_variant._M_integer._M_value = __value; + } + + _Parameter(const char* __value, const char* __name) + : _M_kind(__string), _M_variant() + { + _M_variant._M_string._M_name = __name; + _M_variant._M_string._M_value = __value; + } + + template + _Parameter(_Safe_iterator<_Iterator, _Sequence, _Category> const& __it, + const char* __name, _Is_iterator) + : _M_kind(__iterator), _M_variant() + { + _M_variant._M_iterator._M_name = __name; + _M_variant._M_iterator._M_address = std::__addressof(__it); + _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(_Iterator); + _M_variant._M_iterator._M_constness = + __it._S_constant() ? __const_iterator : __mutable_iterator; + _M_variant._M_iterator._M_sequence = __it._M_get_sequence(); + _M_variant._M_iterator._M_seq_type = _GLIBCXX_TYPEID(_Sequence); + + if (__it._M_singular()) + _M_variant._M_iterator._M_state = __singular; + else + { + if (__it._M_is_before_begin()) + _M_variant._M_iterator._M_state = __before_begin; + else if (__it._M_is_end()) + _M_variant._M_iterator._M_state = __end; + else if (__it._M_is_begin()) + _M_variant._M_iterator._M_state = __begin; + else + _M_variant._M_iterator._M_state = __middle; + } + } + + template + _Parameter(_Safe_local_iterator<_Iterator, _Sequence> const& __it, + const char* __name, _Is_iterator) + : _M_kind(__iterator), _M_variant() + { + _M_variant._M_iterator._M_name = __name; + _M_variant._M_iterator._M_address = std::__addressof(__it); + _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(_Iterator); + _M_variant._M_iterator._M_constness = + __it._S_constant() ? __const_iterator : __mutable_iterator; + _M_variant._M_iterator._M_sequence = __it._M_get_sequence(); + _M_variant._M_iterator._M_seq_type = _GLIBCXX_TYPEID(_Sequence); + + if (__it._M_singular()) + _M_variant._M_iterator._M_state = __singular; + else + { + if (__it._M_is_end()) + _M_variant._M_iterator._M_state = __end; + else if (__it._M_is_begin()) + _M_variant._M_iterator._M_state = __begin; + else + _M_variant._M_iterator._M_state = __middle; + } + } + + template + _Parameter(const _Type* const& __it, const char* __name, _Is_iterator) + : _M_kind(__iterator), _M_variant() + { + _M_variant._M_iterator._M_name = __name; + _M_variant._M_iterator._M_address = std::__addressof(__it); + _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); + _M_variant._M_iterator._M_constness = __const_iterator; + _M_variant._M_iterator._M_state = __it ? __unknown_state : __singular; + _M_variant._M_iterator._M_sequence = 0; + _M_variant._M_iterator._M_seq_type = 0; + } + + template + _Parameter(_Type* const& __it, const char* __name, _Is_iterator) + : _M_kind(__iterator), _M_variant() + { + _M_variant._M_iterator._M_name = __name; + _M_variant._M_iterator._M_address = std::__addressof(__it); + _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); + _M_variant._M_iterator._M_constness = __mutable_iterator; + _M_variant._M_iterator._M_state = __it ? __unknown_state : __singular; + _M_variant._M_iterator._M_sequence = 0; + _M_variant._M_iterator._M_seq_type = 0; + } + + template + _Parameter(_Iterator const& __it, const char* __name, _Is_iterator) + : _M_kind(__iterator), _M_variant() + { + _M_variant._M_iterator._M_name = __name; + _M_variant._M_iterator._M_address = std::__addressof(__it); + _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); + _M_variant._M_iterator._M_constness = __unknown_constness; + _M_variant._M_iterator._M_state = + __gnu_debug::__check_singular(__it) ? __singular : __unknown_state; + _M_variant._M_iterator._M_sequence = 0; + _M_variant._M_iterator._M_seq_type = 0; + } + +#if __cplusplus >= 201103L + // The following constructors are only defined in C++11 to take + // advantage of the constructor delegation feature. + template + _Parameter( + __gnu_cxx::__normal_iterator<_Iterator, _Container> const& __it, + const char* __name, _Is_iterator) + : _Parameter(__it.base(), __name, _Is_iterator{}) + { _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); } + + template + _Parameter(std::reverse_iterator<_Iterator> const& __it, + const char* __name, _Is_iterator) + : _Parameter(__it.base(), __name, _Is_iterator{}) + { + _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); + _M_variant._M_iterator._M_state + = _S_reverse_state(_M_variant._M_iterator._M_state); + } + + template + _Parameter(std::reverse_iterator<_Safe_iterator<_Iterator, _Sequence, + _Category>> const& __it, + const char* __name, _Is_iterator) + : _Parameter(__it.base(), __name, _Is_iterator{}) + { + _M_variant._M_iterator._M_type + = _GLIBCXX_TYPEID(std::reverse_iterator<_Iterator>); + _M_variant._M_iterator._M_state + = _S_reverse_state(_M_variant._M_iterator._M_state); + } + + template + _Parameter(std::move_iterator<_Iterator> const& __it, + const char* __name, _Is_iterator) + : _Parameter(__it.base(), __name, _Is_iterator{}) + { _M_variant._M_iterator._M_type = _GLIBCXX_TYPEID(__it); } + + template + _Parameter(std::move_iterator<_Safe_iterator<_Iterator, _Sequence, + _Category>> const& __it, + const char* __name, _Is_iterator) + : _Parameter(__it.base(), __name, _Is_iterator{}) + { + _M_variant._M_iterator._M_type + = _GLIBCXX_TYPEID(std::move_iterator<_Iterator>); + } + + private: + _Iterator_state + _S_reverse_state(_Iterator_state __state) + { + switch (__state) + { + case __begin: + return __rend; + case __middle: + return __rmiddle; + case __end: + return __rbegin; + default: + return __state; + } + } + + public: +#endif + + template + _Parameter(const _Safe_sequence<_Sequence>& __seq, + const char* __name, _Is_sequence) + : _M_kind(__sequence), _M_variant() + { + _M_variant._M_sequence._M_name = __name; + _M_variant._M_sequence._M_address = + static_cast(std::__addressof(__seq)); + _M_variant._M_sequence._M_type = _GLIBCXX_TYPEID(_Sequence); + } + + template + _Parameter(const _Sequence& __seq, const char* __name, _Is_sequence) + : _M_kind(__sequence), _M_variant() + { + _M_variant._M_sequence._M_name = __name; + _M_variant._M_sequence._M_address = std::__addressof(__seq); + _M_variant._M_sequence._M_type = _GLIBCXX_TYPEID(_Sequence); + } + + template + _Parameter(const _Iterator& __it, const char* __name, + _Is_iterator_value_type) + : _M_kind(__iterator_value_type), _M_variant() + { + _M_variant._M_iterator_value_type._M_name = __name; + _M_variant._M_iterator_value_type._M_type = + _GLIBCXX_TYPEID(typename std::iterator_traits<_Iterator>::value_type); + } + + template + _Parameter(const _Type& __inst, const char* __name, _Is_instance) + : _M_kind(__instance), _M_variant() + { + _M_variant._M_instance._M_name = __name; + _M_variant._M_instance._M_address = &__inst; + _M_variant._M_instance._M_type = _GLIBCXX_TYPEID(_Type); + } + +#if !_GLIBCXX_INLINE_VERSION + void + _M_print_field(const _Error_formatter* __formatter, + const char* __name) const _GLIBCXX_DEPRECATED; + + void + _M_print_description(const _Error_formatter* __formatter) + const _GLIBCXX_DEPRECATED; +#endif + }; + + template + _Error_formatter& + _M_iterator(const _Iterator& __it, const char* __name = 0) + { + if (_M_num_parameters < std::size_t(__max_parameters)) + _M_parameters[_M_num_parameters++] = _Parameter(__it, __name, + _Is_iterator()); + return *this; + } + + template + _Error_formatter& + _M_iterator_value_type(const _Iterator& __it, + const char* __name = 0) + { + if (_M_num_parameters < __max_parameters) + _M_parameters[_M_num_parameters++] = + _Parameter(__it, __name, _Is_iterator_value_type()); + return *this; + } + + _Error_formatter& + _M_integer(long __value, const char* __name = 0) + { + if (_M_num_parameters < __max_parameters) + _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); + return *this; + } + + _Error_formatter& + _M_string(const char* __value, const char* __name = 0) + { + if (_M_num_parameters < __max_parameters) + _M_parameters[_M_num_parameters++] = _Parameter(__value, __name); + return *this; + } + + template + _Error_formatter& + _M_sequence(const _Sequence& __seq, const char* __name = 0) + { + if (_M_num_parameters < __max_parameters) + _M_parameters[_M_num_parameters++] = _Parameter(__seq, __name, + _Is_sequence()); + return *this; + } + + template + _Error_formatter& + _M_instance(const _Type& __inst, const char* __name = 0) + { + if (_M_num_parameters < __max_parameters) + _M_parameters[_M_num_parameters++] = _Parameter(__inst, __name, + _Is_instance()); + return *this; + } + + _Error_formatter& + _M_message(const char* __text) + { _M_text = __text; return *this; } + + // Kept const qualifier for backward compatibility, to keep the same + // exported symbol. + _Error_formatter& + _M_message(_Debug_msg_id __id) const throw (); + + _GLIBCXX_NORETURN void + _M_error() const; + +#if !_GLIBCXX_INLINE_VERSION + template + void + _M_format_word(char*, int, const char*, _Tp) + const throw () _GLIBCXX_DEPRECATED; + + void + _M_print_word(const char* __word) const _GLIBCXX_DEPRECATED; + + void + _M_print_string(const char* __string) const _GLIBCXX_DEPRECATED; +#endif + + private: + _Error_formatter(const char* __file, unsigned int __line, + const char* __function) + : _M_file(__file), _M_line(__line), _M_num_parameters(0), _M_text(0) + , _M_function(__function) + { } + +#if !_GLIBCXX_INLINE_VERSION + void + _M_get_max_length() const throw () _GLIBCXX_DEPRECATED; +#endif + + enum { __max_parameters = 9 }; + + const char* _M_file; + unsigned int _M_line; + _Parameter _M_parameters[__max_parameters]; + unsigned int _M_num_parameters; + const char* _M_text; + const char* _M_function; + + public: + static _Error_formatter& + _S_at(const char* __file, unsigned int __line, const char* __function) + { + static _Error_formatter __formatter(__file, __line, __function); + return __formatter; + } + }; +} // namespace __gnu_debug + +#undef _GLIBCXX_TYPEID + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/forward_list b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/forward_list new file mode 100755 index 0000000..46e8eb9 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/forward_list @@ -0,0 +1,952 @@ +// -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/forward_list + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_FORWARD_LIST +#define _GLIBCXX_DEBUG_FORWARD_LIST 1 + +#pragma GCC system_header + +#include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template class forward_list; +} } // namespace std::__debug + +#include +#include +#include +#include + +// Special validity check for forward_list ranges. +#define __glibcxx_check_valid_fl_range(_First,_Last,_Dist) \ +_GLIBCXX_DEBUG_VERIFY(_First._M_valid_range(_Last, _Dist, false), \ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +namespace __gnu_debug +{ + /// Special iterators swap and invalidation for forward_list because of the + /// before_begin iterator. + template + class _Safe_forward_list + : public _Safe_sequence<_SafeSequence> + { + _SafeSequence& + _M_this() noexcept + { return *static_cast<_SafeSequence*>(this); } + + static void + _M_swap_aux(_Safe_sequence_base& __lhs, + _Safe_iterator_base*& __lhs_iterators, + _Safe_sequence_base& __rhs, + _Safe_iterator_base*& __rhs_iterators); + + void _M_swap_single(_Safe_sequence_base&) noexcept; + + protected: + void + _M_invalidate_all() + { + using _Base_const_iterator = __decltype(_M_this()._M_base().cend()); + this->_M_invalidate_if([this](_Base_const_iterator __it) + { + return __it != _M_this()._M_base().cbefore_begin() + && __it != _M_this()._M_base().cend(); }); + } + + void _M_swap(_Safe_sequence_base&) noexcept; + }; + + template + void + _Safe_forward_list<_SafeSequence>:: + _M_swap_aux(_Safe_sequence_base& __lhs, + _Safe_iterator_base*& __lhs_iterators, + _Safe_sequence_base& __rhs, + _Safe_iterator_base*& __rhs_iterators) + { + using const_iterator = typename _SafeSequence::const_iterator; + _Safe_iterator_base* __bbegin_its = 0; + _Safe_iterator_base* __last_bbegin = 0; + _SafeSequence& __rseq = static_cast<_SafeSequence&>(__rhs); + + for (_Safe_iterator_base* __iter = __lhs_iterators; __iter;) + { + // Even iterator is cast to const_iterator, not a problem. + _Safe_iterator_base* __victim_base = __iter; + const_iterator* __victim = + static_cast(__victim_base); + __iter = __iter->_M_next; + if (__victim->base() == __rseq._M_base().cbefore_begin()) + { + __victim->_M_unlink(); + if (__lhs_iterators == __victim_base) + __lhs_iterators = __victim_base->_M_next; + if (__bbegin_its) + { + __victim_base->_M_next = __bbegin_its; + __bbegin_its->_M_prior = __victim_base; + } + else + __last_bbegin = __victim_base; + __bbegin_its = __victim_base; + } + else + __victim_base->_M_sequence = std::__addressof(__lhs); + } + + if (__bbegin_its) + { + if (__rhs_iterators) + { + __rhs_iterators->_M_prior = __last_bbegin; + __last_bbegin->_M_next = __rhs_iterators; + } + __rhs_iterators = __bbegin_its; + } + } + + template + void + _Safe_forward_list<_SafeSequence>:: + _M_swap_single(_Safe_sequence_base& __other) noexcept + { + std::swap(_M_this()._M_iterators, __other._M_iterators); + std::swap(_M_this()._M_const_iterators, __other._M_const_iterators); + // Useless, always 1 on forward_list + //std::swap(_M_this()_M_version, __other._M_version); + _Safe_iterator_base* __this_its = _M_this()._M_iterators; + _M_swap_aux(__other, __other._M_iterators, + _M_this(), _M_this()._M_iterators); + _Safe_iterator_base* __this_const_its = _M_this()._M_const_iterators; + _M_swap_aux(__other, __other._M_const_iterators, + _M_this(), _M_this()._M_const_iterators); + _M_swap_aux(_M_this(), __this_its, + __other, __other._M_iterators); + _M_swap_aux(_M_this(), __this_const_its, + __other, __other._M_const_iterators); + } + + /* Special forward_list _M_swap version that does not swap the + * before-begin ownership.*/ + template + void + _Safe_forward_list<_SafeSequence>:: + _M_swap(_Safe_sequence_base& __other) noexcept + { + // We need to lock both sequences to swap + using namespace __gnu_cxx; + __mutex *__this_mutex = &_M_this()._M_get_mutex(); + __mutex *__other_mutex = + &static_cast<_SafeSequence&>(__other)._M_get_mutex(); + if (__this_mutex == __other_mutex) + { + __scoped_lock __lock(*__this_mutex); + _M_swap_single(__other); + } + else + { + __scoped_lock __l1(__this_mutex < __other_mutex + ? *__this_mutex : *__other_mutex); + __scoped_lock __l2(__this_mutex < __other_mutex + ? *__other_mutex : *__this_mutex); + _M_swap_single(__other); + } + } +} + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::forward_list with safety/checking/debug instrumentation. + template > + class forward_list + : public __gnu_debug::_Safe_container< + forward_list<_Tp, _Alloc>, _Alloc, __gnu_debug::_Safe_forward_list>, + public _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> + { + typedef _GLIBCXX_STD_C::forward_list<_Tp, _Alloc> _Base; + typedef __gnu_debug::_Safe_container< + forward_list, _Alloc, __gnu_debug::_Safe_forward_list> _Safe; + + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_iterator _Base_const_iterator; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator< + _Base_iterator, forward_list> iterator; + typedef __gnu_debug::_Safe_iterator< + _Base_const_iterator, forward_list> const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + + typedef _Tp value_type; + typedef typename _Base::allocator_type allocator_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + + // 23.2.3.1 construct/copy/destroy: + + forward_list() = default; + + explicit + forward_list(const allocator_type& __al) noexcept + : _Base(__al) { } + + forward_list(const forward_list& __list, const allocator_type& __al) + : _Base(__list, __al) + { } + + forward_list(forward_list&& __list, const allocator_type& __al) + noexcept( + std::is_nothrow_constructible<_Base, + _Base, const allocator_type&>::value ) + : _Safe(std::move(__list._M_safe()), __al), + _Base(std::move(__list._M_base()), __al) + { } + + explicit + forward_list(size_type __n, const allocator_type& __al = allocator_type()) + : _Base(__n, __al) + { } + + forward_list(size_type __n, const __type_identity_t<_Tp>& __value, + const allocator_type& __al = allocator_type()) + : _Base(__n, __value, __al) + { } + + template> + forward_list(_InputIterator __first, _InputIterator __last, + const allocator_type& __al = allocator_type()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __al) + { } + + forward_list(const forward_list&) = default; + + forward_list(forward_list&&) = default; + + forward_list(std::initializer_list<_Tp> __il, + const allocator_type& __al = allocator_type()) + : _Base(__il, __al) + { } + + ~forward_list() = default; + + forward_list(_Base_ref __x) : _Base(__x._M_ref) { } + + forward_list& + operator=(const forward_list&) = default; + + forward_list& + operator=(forward_list&&) = default; + + forward_list& + operator=(std::initializer_list<_Tp> __il) + { + _M_base() = __il; + this->_M_invalidate_all(); + return *this; + } + + template> + void + assign(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::assign(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::assign(__first, __last); + + this->_M_invalidate_all(); + } + + void + assign(size_type __n, const _Tp& __val) + { + _Base::assign(__n, __val); + this->_M_invalidate_all(); + } + + void + assign(std::initializer_list<_Tp> __il) + { + _Base::assign(__il); + this->_M_invalidate_all(); + } + + using _Base::get_allocator; + + // iterators: + + iterator + before_begin() noexcept + { return { _Base::before_begin(), this }; } + + const_iterator + before_begin() const noexcept + { return { _Base::before_begin(), this }; } + + iterator + begin() noexcept + { return { _Base::begin(), this }; } + + const_iterator + begin() const noexcept + { return { _Base::begin(), this }; } + + iterator + end() noexcept + { return { _Base::end(), this }; } + + const_iterator + end() const noexcept + { return { _Base::end(), this }; } + + const_iterator + cbegin() const noexcept + { return { _Base::cbegin(), this }; } + + const_iterator + cbefore_begin() const noexcept + { return { _Base::cbefore_begin(), this }; } + + const_iterator + cend() const noexcept + { return { _Base::cend(), this }; } + + using _Base::empty; + using _Base::max_size; + + // element access: + + reference + front() + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + const_reference + front() const + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + // modifiers: + + using _Base::emplace_front; + using _Base::push_front; + + void + pop_front() + { + __glibcxx_check_nonempty(); + this->_M_invalidate_if([this](_Base_const_iterator __it) + { return __it == this->_M_base().cbegin(); }); + _Base::pop_front(); + } + + template + iterator + emplace_after(const_iterator __pos, _Args&&... __args) + { + __glibcxx_check_insert_after(__pos); + return { _Base::emplace_after(__pos.base(), + std::forward<_Args>(__args)...), + this }; + } + + iterator + insert_after(const_iterator __pos, const _Tp& __val) + { + __glibcxx_check_insert_after(__pos); + return { _Base::insert_after(__pos.base(), __val), this }; + } + + iterator + insert_after(const_iterator __pos, _Tp&& __val) + { + __glibcxx_check_insert_after(__pos); + return { _Base::insert_after(__pos.base(), std::move(__val)), this }; + } + + iterator + insert_after(const_iterator __pos, size_type __n, const _Tp& __val) + { + __glibcxx_check_insert_after(__pos); + return { _Base::insert_after(__pos.base(), __n, __val), this }; + } + + template> + iterator + insert_after(const_iterator __pos, + _InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range_after(__pos, __first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + return + { + _Base::insert_after(__pos.base(), + __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)), + this + }; + else + return { _Base::insert_after(__pos.base(), __first, __last), this }; + } + + iterator + insert_after(const_iterator __pos, std::initializer_list<_Tp> __il) + { + __glibcxx_check_insert_after(__pos); + return { _Base::insert_after(__pos.base(), __il), this }; + } + + iterator + erase_after(const_iterator __pos) + { + __glibcxx_check_erase_after(__pos); + + _Base_const_iterator __next = std::next(__pos.base()); + this->_M_invalidate_if([__next](_Base_const_iterator __it) + { return __it == __next; }); + return { _Base::erase_after(__pos.base()), this }; + } + + iterator + erase_after(const_iterator __pos, const_iterator __last) + { + __glibcxx_check_erase_range_after(__pos, __last); + for (_Base_const_iterator __victim = std::next(__pos.base()); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range2) + ._M_sequence(*this, "this") + ._M_iterator(__pos, "pos") + ._M_iterator(__last, "last")); + this->_M_invalidate_if([__victim](_Base_const_iterator __it) + { return __it == __victim; }); + } + + return { _Base::erase_after(__pos.base(), __last.base()), this }; + } + + void + swap(forward_list& __list) + noexcept( noexcept(declval<_Base&>().swap(__list)) ) + { + _Safe::_M_swap(__list); + _Base::swap(__list); + } + + void + resize(size_type __sz) + { + this->_M_detach_singular(); + + // if __sz < size(), invalidate all iterators in [begin+__sz, end() + _Base_iterator __victim = _Base::begin(); + _Base_iterator __end = _Base::end(); + for (size_type __i = __sz; __victim != __end && __i > 0; --__i) + ++__victim; + + for (; __victim != __end; ++__victim) + { + this->_M_invalidate_if([__victim](_Base_const_iterator __it) + { return __it == __victim; }); + } + + __try + { + _Base::resize(__sz); + } + __catch(...) + { + this->_M_revalidate_singular(); + __throw_exception_again; + } + } + + void + resize(size_type __sz, const value_type& __val) + { + this->_M_detach_singular(); + + // if __sz < size(), invalidate all iterators in [begin+__sz, end()) + _Base_iterator __victim = _Base::begin(); + _Base_iterator __end = _Base::end(); + for (size_type __i = __sz; __victim != __end && __i > 0; --__i) + ++__victim; + + for (; __victim != __end; ++__victim) + { + this->_M_invalidate_if([__victim](_Base_const_iterator __it) + { return __it == __victim; }); + } + + __try + { + _Base::resize(__sz, __val); + } + __catch(...) + { + this->_M_revalidate_singular(); + __throw_exception_again; + } + } + + void + clear() noexcept + { + _Base::clear(); + this->_M_invalidate_all(); + } + + // 23.2.3.5 forward_list operations: + void + splice_after(const_iterator __pos, forward_list&& __list) + { + __glibcxx_check_insert_after(__pos); + _GLIBCXX_DEBUG_VERIFY(std::__addressof(__list) != this, + _M_message(__gnu_debug::__msg_self_splice) + ._M_sequence(*this, "this")); + _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(), + _M_message(__gnu_debug::__msg_splice_alloc) + ._M_sequence(*this) + ._M_sequence(__list, "__list")); + this->_M_transfer_from_if(__list, [&__list](_Base_const_iterator __it) + { + return __it != __list._M_base().cbefore_begin() + && __it != __list._M_base().end(); + }); + _Base::splice_after(__pos.base(), std::move(__list._M_base())); + } + + void + splice_after(const_iterator __pos, forward_list& __list) + { splice_after(__pos, std::move(__list)); } + + void + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __i) + { + __glibcxx_check_insert_after(__pos); + _GLIBCXX_DEBUG_VERIFY(__i._M_before_dereferenceable(), + _M_message(__gnu_debug::__msg_splice_bad) + ._M_iterator(__i, "__i")); + _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(std::__addressof(__list)), + _M_message(__gnu_debug::__msg_splice_other) + ._M_iterator(__i, "__i") + ._M_sequence(__list, "__list")); + _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(), + _M_message(__gnu_debug::__msg_splice_alloc) + ._M_sequence(*this) + ._M_sequence(__list, "__list")); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 250. splicing invalidates iterators + _Base_const_iterator __next = std::next(__i.base()); + this->_M_transfer_from_if(__list, [__next](_Base_const_iterator __it) + { return __it == __next; }); + _Base::splice_after(__pos.base(), std::move(__list._M_base()), + __i.base()); + } + + void + splice_after(const_iterator __pos, forward_list& __list, + const_iterator __i) + { splice_after(__pos, std::move(__list), __i); } + + void + splice_after(const_iterator __pos, forward_list&& __list, + const_iterator __before, const_iterator __last) + { + typename __gnu_debug::_Distance_traits::__type __dist; + auto __listptr = std::__addressof(__list); + __glibcxx_check_insert_after(__pos); + __glibcxx_check_valid_fl_range(__before, __last, __dist); + _GLIBCXX_DEBUG_VERIFY(__before._M_attached_to(__listptr), + _M_message(__gnu_debug::__msg_splice_other) + ._M_sequence(__list, "list") + ._M_iterator(__before, "before")); + _GLIBCXX_DEBUG_VERIFY(__before._M_dereferenceable() + || __before._M_is_before_begin(), + _M_message(__gnu_debug::__msg_valid_range2) + ._M_sequence(__list, "list") + ._M_iterator(__before, "before") + ._M_iterator(__last, "last")); + _GLIBCXX_DEBUG_VERIFY(__before != __last, + _M_message(__gnu_debug::__msg_valid_range2) + ._M_sequence(__list, "list") + ._M_iterator(__before, "before") + ._M_iterator(__last, "last")); + _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(), + _M_message(__gnu_debug::__msg_splice_alloc) + ._M_sequence(*this) + ._M_sequence(__list, "__list")); + + for (_Base_const_iterator __tmp = std::next(__before.base()); + __tmp != __last.base(); ++__tmp) + { + _GLIBCXX_DEBUG_VERIFY(__tmp != __list._M_base().end(), + _M_message(__gnu_debug::__msg_valid_range2) + ._M_sequence(__list, "list") + ._M_iterator(__before, "before") + ._M_iterator(__last, "last")); + _GLIBCXX_DEBUG_VERIFY(__listptr != this || __tmp != __pos.base(), + _M_message(__gnu_debug::__msg_splice_overlap) + ._M_iterator(__tmp, "position") + ._M_iterator(__before, "before") + ._M_iterator(__last, "last")); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 250. splicing invalidates iterators + this->_M_transfer_from_if(__list, [__tmp](_Base_const_iterator __it) + { return __it == __tmp; }); + } + + _Base::splice_after(__pos.base(), std::move(__list._M_base()), + __before.base(), __last.base()); + } + + void + splice_after(const_iterator __pos, forward_list& __list, + const_iterator __before, const_iterator __last) + { splice_after(__pos, std::move(__list), __before, __last); } + + private: +#if __cplusplus > 201703L + using __remove_return_type = size_type; +# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG \ + __attribute__((__abi_tag__("__cxx20"))) +# define _GLIBCXX20_ONLY(__expr) __expr +#else + using __remove_return_type = void; +# define _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG +# define _GLIBCXX20_ONLY(__expr) +#endif + + public: + _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + remove(const _Tp& __val) + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::remove(__val); + + size_type __removed __attribute__((__unused__)) = 0; + _Base __to_destroy(get_allocator()); + _Base_const_iterator __x = _Base::cbefore_begin(); + _Base_const_iterator __old = __x++; + while (__x != _Base::cend()) + { + if (*__x == __val) + { + _Base_const_iterator __next = std::next(__old); + this->_M_invalidate_if([__next](_Base_const_iterator __it) + { return __it == __next; }); + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + _M_base(), __old); + __x = __old; + _GLIBCXX20_ONLY( __removed++ ); + } + + __old = __x++; + } + + return _GLIBCXX20_ONLY( __removed ); + } + + template + __remove_return_type + remove_if(_Pred __pred) + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::remove_if(__pred); + + size_type __removed __attribute__((__unused__)) = 0; + _Base __to_destroy(get_allocator()); + _Base_iterator __x = _Base::before_begin(); + _Base_iterator __old = __x++; + while (__x != _Base::end()) + { + if (__pred(*__x)) + { + this->_M_invalidate_if([__x](_Base_const_iterator __it) + { return __it == __x; }); + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + _M_base(), __old); + __x = __old; + _GLIBCXX20_ONLY( __removed++ ); + } + + __old = __x++; + } + + return _GLIBCXX20_ONLY( __removed ); + } + + _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + unique() + { return unique(std::equal_to<_Tp>()); } + + template + __remove_return_type + unique(_BinPred __binary_pred) + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::unique(__binary_pred); + + _Base_const_iterator __first = _Base::cbegin(); + _Base_const_iterator __last = _Base::cend(); + if (__first == __last) + return _GLIBCXX20_ONLY(0); + + size_type __removed __attribute__((__unused__)) = 0; + _Base __to_destroy(get_allocator()); + _Base_const_iterator __next = std::next(__first); + while (__next != __last) + { + if (__binary_pred(*__first, *__next)) + { + this->_M_invalidate_if([__next](_Base_const_iterator __it) + { return __it == __next; }); + __to_destroy.splice_after(__to_destroy.cbefore_begin(), + _M_base(), __first); + __next = __first; + _GLIBCXX20_ONLY( __removed++ ); + } + + __first = __next++; + } + + return _GLIBCXX20_ONLY( __removed ); + } + +#undef _GLIBCXX_FWDLIST_REMOVE_RETURN_TYPE_TAG +#undef _GLIBCXX20_ONLY + + void + merge(forward_list&& __list) + { + if (this != std::__addressof(__list)) + { + __glibcxx_check_sorted(_Base::begin(), _Base::end()); + __glibcxx_check_sorted(__list._M_base().begin(), + __list._M_base().end()); + this->_M_transfer_from_if(__list, [&__list](_Base_const_iterator __it) + { + return __it != __list._M_base().cbefore_begin() + && __it != __list._M_base().cend(); + }); + _Base::merge(std::move(__list._M_base())); + } + } + + void + merge(forward_list& __list) + { merge(std::move(__list)); } + + template + void + merge(forward_list&& __list, _Comp __comp) + { + if (this != std::__addressof(__list)) + { + __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp); + __glibcxx_check_sorted_pred(__list._M_base().begin(), + __list._M_base().end(), __comp); + this->_M_transfer_from_if(__list, + [&__list](_Base_const_iterator __it) + { + return __it != __list._M_base().cbefore_begin() + && __it != __list._M_base().cend(); + }); + _Base::merge(std::move(__list._M_base()), __comp); + } + } + + template + void + merge(forward_list& __list, _Comp __comp) + { merge(std::move(__list), __comp); } + + using _Base::sort; + using _Base::reverse; + + _Base& + _M_base() noexcept { return *this; } + + const _Base& + _M_base() const noexcept { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> forward_list<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + forward_list(size_t, _Tp, _Allocator = _Allocator()) + -> forward_list<_Tp, _Allocator>; +#endif + + template + bool + operator==(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return __lx._M_base() == __ly._M_base(); } + +#if __cpp_lib_three_way_comparison + template + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const forward_list<_Tp, _Alloc>& __x, + const forward_list<_Tp, _Alloc>& __y) + { return __x._M_base() <=> __y._M_base(); } +#else + template + inline bool + operator<(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return __lx._M_base() < __ly._M_base(); } + + template + inline bool + operator!=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx == __ly); } + + /// Based on operator< + template + inline bool + operator>(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return (__ly < __lx); } + + /// Based on operator< + template + inline bool + operator>=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__lx < __ly); } + + /// Based on operator< + template + inline bool + operator<=(const forward_list<_Tp, _Alloc>& __lx, + const forward_list<_Tp, _Alloc>& __ly) + { return !(__ly < __lx); } +#endif // three-way comparison + + /// See std::forward_list::swap(). + template + inline void + swap(forward_list<_Tp, _Alloc>& __lx, forward_list<_Tp, _Alloc>& __ly) + noexcept(noexcept(__lx.swap(__ly))) + { __lx.swap(__ly); } + +} // namespace __debug +} // namespace std + +namespace __gnu_debug +{ + template + struct _BeforeBeginHelper > + { + typedef std::__debug::forward_list<_Tp, _Alloc> _Sequence; + + template + static bool + _S_Is(const _Safe_iterator<_Iterator, _Sequence>& __it) + { + return + __it.base() == __it._M_get_sequence()->_M_base().before_begin(); + } + + template + static bool + _S_Is_Beginnest(const _Safe_iterator<_Iterator, _Sequence>& __it) + { return _S_Is(__it); } + }; + + template + struct _Sequence_traits > + { + typedef typename std::__debug::forward_list<_Tp, _Alloc>::iterator _It; + + static typename _Distance_traits<_It>::__type + _S_size(const std::__debug::forward_list<_Tp, _Alloc>& __seq) + { + return __seq.empty() + ? std::make_pair(0, __dp_exact) : std::make_pair(1, __dp_sign); + } + }; + +#ifndef _GLIBCXX_DEBUG_PEDANTIC + template + struct _Insert_range_from_self_is_safe< + std::__debug::forward_list<_Tp, _Alloc> > + { enum { __value = 1 }; }; +#endif +} + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/functions.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/functions.h new file mode 100755 index 0000000..6cac11f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/functions.h @@ -0,0 +1,470 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/functions.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_FUNCTIONS_H +#define _GLIBCXX_DEBUG_FUNCTIONS_H 1 + +#include // for less + +#if __cplusplus >= 201103L +# include // for __miter_base +# include // for is_lvalue_reference and conditional. +#endif + +#include +#include + +namespace __gnu_debug +{ + template + struct _Insert_range_from_self_is_safe + { enum { __value = 0 }; }; + + template + struct _Is_contiguous_sequence : std::__false_type { }; + + /* Checks that [first, last) is a valid range, and then returns + * __first. This routine is useful when we can't use a separate + * assertion statement because, e.g., we are in a constructor. + */ + template + inline _InputIterator + __check_valid_range(const _InputIterator& __first, + const _InputIterator& __last, + const char* __file, + unsigned int __line, + const char* __function) + { + __glibcxx_check_valid_range_at(__first, __last, + __file, __line, __function); + return __first; + } + + /* Handle the case where __other is a pointer to _Sequence::value_type. */ + template + inline bool + __foreign_iterator_aux4( + const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + const typename _Sequence::value_type* __other) + { + typedef const typename _Sequence::value_type* _PointerType; + typedef std::less<_PointerType> _Less; +#if __cplusplus >= 201103L + constexpr _Less __l{}; +#else + const _Less __l = _Less(); +#endif + const _Sequence* __seq = __it._M_get_sequence(); + const _PointerType __begin = std::__addressof(*__seq->_M_base().begin()); + const _PointerType __end = std::__addressof(*(__seq->_M_base().end()-1)); + + // Check whether __other points within the contiguous storage. + return __l(__other, __begin) || __l(__end, __other); + } + + /* Fallback overload for when we can't tell, assume it is valid. */ + template + inline bool + __foreign_iterator_aux4( + const _Safe_iterator<_Iterator, _Sequence, _Category>&, ...) + { return true; } + + /* Handle sequences with contiguous storage */ + template + inline bool + __foreign_iterator_aux3( + const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + const _InputIterator& __other, const _InputIterator& __other_end, + std::__true_type) + { + if (__other == __other_end) + return true; // inserting nothing is safe even if not foreign iters + if (__it._M_get_sequence()->empty()) + return true; // can't be self-inserting if self is empty + return __foreign_iterator_aux4(__it, std::__addressof(*__other)); + } + + /* Handle non-contiguous containers, assume it is valid. */ + template + inline bool + __foreign_iterator_aux3( + const _Safe_iterator<_Iterator, _Sequence, _Category>&, + const _InputIterator&, const _InputIterator&, + std::__false_type) + { return true; } + + /** Handle debug iterators from the same type of container. */ + template + inline bool + __foreign_iterator_aux2( + const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + const _Safe_iterator<_OtherIterator, _Sequence, _Category>& __other, + const _Safe_iterator<_OtherIterator, _Sequence, _Category>&) + { return __it._M_get_sequence() != __other._M_get_sequence(); } + + /** Handle debug iterators from different types of container. */ + template + inline bool + __foreign_iterator_aux2( + const _Safe_iterator<_Iterator, _Sequence, _Category>&, + const _Safe_iterator<_OtherIterator, _OtherSequence, + _OtherCategory>&, + const _Safe_iterator<_OtherIterator, _OtherSequence, + _OtherCategory>&) + { return true; } + + /* Handle non-debug iterators. */ + template + inline bool + __foreign_iterator_aux2( + const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + const _InputIterator& __other, + const _InputIterator& __other_end) + { +#if __cplusplus < 201103L + typedef _Is_contiguous_sequence<_Sequence> __tag; +#else + using __lvalref = std::is_lvalue_reference< + typename std::iterator_traits<_InputIterator>::reference>; + using __contiguous = _Is_contiguous_sequence<_Sequence>; + using __tag = typename std::conditional<__lvalref::value, __contiguous, + std::__false_type>::type; +#endif + return __foreign_iterator_aux3(__it, __other, __other_end, __tag()); + } + + /* Handle the case where we aren't really inserting a range after all */ + template + inline bool + __foreign_iterator_aux( + const _Safe_iterator<_Iterator, _Sequence, _Category>&, + _Integral, _Integral, std::__true_type) + { return true; } + + /* Handle all iterators. */ + template + inline bool + __foreign_iterator_aux( + const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + _InputIterator __other, _InputIterator __other_end, + std::__false_type) + { + return _Insert_range_from_self_is_safe<_Sequence>::__value + || __foreign_iterator_aux2(__it, std::__miter_base(__other), + std::__miter_base(__other_end)); + } + + template + inline bool + __foreign_iterator( + const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + _InputIterator __other, _InputIterator __other_end) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return __foreign_iterator_aux(__it, __other, __other_end, _Integral()); + } + + // Can't check if an input iterator sequence is sorted, because we + // can't step through the sequence. + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_aux(const _InputIterator&, const _InputIterator&, + std::input_iterator_tag) + { return true; } + + // Can verify if a forward iterator sequence is in fact sorted using + // std::__is_sorted + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, + std::forward_iterator_tag) + { + if (__first == __last) + return true; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, (void)++__next) + if (*__next < *__first) + return false; + + return true; + } + + // Can't check if an input iterator sequence is sorted, because we can't step + // through the sequence. + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_aux(const _InputIterator&, const _InputIterator&, + _Predicate, std::input_iterator_tag) + { return true; } + + // Can verify if a forward iterator sequence is in fact sorted using + // std::__is_sorted + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_aux(_ForwardIterator __first, _ForwardIterator __last, + _Predicate __pred, std::forward_iterator_tag) + { + if (__first == __last) + return true; + + _ForwardIterator __next = __first; + for (++__next; __next != __last; __first = __next, (void)++__next) + if (__pred(*__next, *__first)) + return false; + + return true; + } + + // Determine if a sequence is sorted. + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted(const _InputIterator& __first, const _InputIterator& __last) + { + return __check_sorted_aux(__first, __last, + std::__iterator_category(__first)); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted(const _InputIterator& __first, const _InputIterator& __last, + _Predicate __pred) + { + return __check_sorted_aux(__first, __last, __pred, + std::__iterator_category(__first)); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_set_aux(const _InputIterator& __first, + const _InputIterator& __last, + std::__true_type) + { return __check_sorted(__first, __last); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_set_aux(const _InputIterator&, + const _InputIterator&, + std::__false_type) + { return true; } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_set_aux(const _InputIterator& __first, + const _InputIterator& __last, + _Predicate __pred, std::__true_type) + { return __check_sorted(__first, __last, __pred); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_set_aux(const _InputIterator&, + const _InputIterator&, _Predicate, + std::__false_type) + { return true; } + + // ... special variant used in std::merge, std::includes, std::set_*. + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_set(const _InputIterator1& __first, + const _InputIterator1& __last, + const _InputIterator2&) + { + typedef typename std::iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename std::iterator_traits<_InputIterator2>::value_type + _ValueType2; + + typedef typename std::__are_same<_ValueType1, _ValueType2>::__type + _SameType; + return __check_sorted_set_aux(__first, __last, _SameType()); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_sorted_set(const _InputIterator1& __first, + const _InputIterator1& __last, + const _InputIterator2&, _Predicate __pred) + { + typedef typename std::iterator_traits<_InputIterator1>::value_type + _ValueType1; + typedef typename std::iterator_traits<_InputIterator2>::value_type + _ValueType2; + + typedef typename std::__are_same<_ValueType1, _ValueType2>::__type + _SameType; + return __check_sorted_set_aux(__first, __last, __pred, _SameType()); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 270. Binary search requirements overly strict + // Determine if a sequence is partitioned w.r.t. this element. + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_partitioned_lower(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value) + { + while (__first != __last && *__first < __value) + ++__first; + if (__first != __last) + { + ++__first; + while (__first != __last && !(*__first < __value)) + ++__first; + } + return __first == __last; + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_partitioned_upper(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value) + { + while (__first != __last && !(__value < *__first)) + ++__first; + if (__first != __last) + { + ++__first; + while (__first != __last && __value < *__first) + ++__first; + } + return __first == __last; + } + + // Determine if a sequence is partitioned w.r.t. this element. + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_partitioned_lower(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value, + _Pred __pred) + { + while (__first != __last && bool(__pred(*__first, __value))) + ++__first; + if (__first != __last) + { + ++__first; + while (__first != __last && !bool(__pred(*__first, __value))) + ++__first; + } + return __first == __last; + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __check_partitioned_upper(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value, + _Pred __pred) + { + while (__first != __last && !bool(__pred(__value, *__first))) + ++__first; + if (__first != __last) + { + ++__first; + while (__first != __last && bool(__pred(__value, *__first))) + ++__first; + } + return __first == __last; + } + +#if __cplusplus >= 201103L + struct _Irreflexive_checker + { + template + static typename std::iterator_traits<_It>::reference + __ref(); + + template() < __ref<_It>())> + _GLIBCXX20_CONSTEXPR + static bool + _S_is_valid(_It __it) + { return !(*__it < *__it); } + + // Fallback method if operator doesn't exist. + template + _GLIBCXX20_CONSTEXPR + static bool + _S_is_valid(_Args...) + { return true; } + + template()(__ref<_It>(), __ref<_It>()))> + _GLIBCXX20_CONSTEXPR + static bool + _S_is_valid_pred(_It __it, _Pred __pred) + { return !__pred(*__it, *__it); } + + // Fallback method if predicate can't be invoked. + template + _GLIBCXX20_CONSTEXPR + static bool + _S_is_valid_pred(_Args...) + { return true; } + }; + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_irreflexive(_Iterator __it) + { return _Irreflexive_checker::_S_is_valid(__it); } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __is_irreflexive_pred(_Iterator __it, _Pred __pred) + { return _Irreflexive_checker::_S_is_valid_pred(__it, __pred); } +#endif + +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/helper_functions.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/helper_functions.h new file mode 100755 index 0000000..c0144ce --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/helper_functions.h @@ -0,0 +1,331 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/helper_functions.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_HELPER_FUNCTIONS_H +#define _GLIBCXX_DEBUG_HELPER_FUNCTIONS_H 1 + +#include // for __addressof +#include // for iterator_traits, + // categories and _Iter_base +#include // for __is_integer + +#include // for pair + +namespace __gnu_debug +{ + template + class _Safe_iterator; + +#if __cplusplus >= 201103L + template + class _Safe_local_iterator; +#endif + + /** The precision to which we can calculate the distance between + * two iterators. + */ + enum _Distance_precision + { + __dp_none, // Not even an iterator type + __dp_equality, //< Can compare iterator equality, only + __dp_sign, //< Can determine equality and ordering + __dp_sign_max_size, //< __dp_sign and gives max range size + __dp_exact //< Can determine distance precisely + }; + + template::__type> + struct _Distance_traits + { + private: + typedef + typename std::iterator_traits<_Iterator>::difference_type _ItDiffType; + + template::__type> + struct _DiffTraits + { typedef _DiffType __type; }; + + template + struct _DiffTraits<_DiffType, std::__true_type> + { typedef std::ptrdiff_t __type; }; + + typedef typename _DiffTraits<_ItDiffType>::__type _DiffType; + + public: + typedef std::pair<_DiffType, _Distance_precision> __type; + }; + + template + struct _Distance_traits<_Integral, std::__true_type> + { typedef std::pair __type; }; + + /** Determine the distance between two iterators with some known + * precision. + */ + template + _GLIBCXX_CONSTEXPR + inline typename _Distance_traits<_Iterator>::__type + __get_distance(_Iterator __lhs, _Iterator __rhs, + std::random_access_iterator_tag) + { return std::make_pair(__rhs - __lhs, __dp_exact); } + + template + _GLIBCXX14_CONSTEXPR + inline typename _Distance_traits<_Iterator>::__type + __get_distance(_Iterator __lhs, _Iterator __rhs, + std::input_iterator_tag) + { + if (__lhs == __rhs) + return std::make_pair(0, __dp_exact); + + return std::make_pair(1, __dp_equality); + } + + template + _GLIBCXX_CONSTEXPR + inline typename _Distance_traits<_Iterator>::__type + __get_distance(_Iterator __lhs, _Iterator __rhs) + { return __get_distance(__lhs, __rhs, std::__iterator_category(__lhs)); } + + // An arbitrary iterator pointer is not singular. + inline bool + __check_singular_aux(const void*) { return false; } + + // We may have an iterator that derives from _Safe_iterator_base but isn't + // a _Safe_iterator. + template + _GLIBCXX_CONSTEXPR + inline bool + __check_singular(_Iterator const& __x) + { + return +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + __builtin_is_constant_evaluated() ? false : +#endif + __check_singular_aux(std::__addressof(__x)); + } + + /** Non-NULL pointers are nonsingular. */ + template + _GLIBCXX_CONSTEXPR + inline bool + __check_singular(_Tp* const& __ptr) + { + return +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED + __builtin_is_constant_evaluated() ? false : +#endif + __ptr == 0; + } + + /** We say that integral types for a valid range, and defer to other + * routines to realize what to do with integral types instead of + * iterators. + */ + template + _GLIBCXX_CONSTEXPR + inline bool + __valid_range_aux(_Integral, _Integral, std::__true_type) + { return true; } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __valid_range_aux(_Integral, _Integral, + typename _Distance_traits<_Integral>::__type& __dist, + std::__true_type) + { + __dist = std::make_pair(0, __dp_none); + return true; + } + + template + _GLIBCXX_CONSTEXPR + inline bool + __valid_range_aux(_InputIterator __first, _InputIterator __last, + std::input_iterator_tag) + { + return __first == __last + || (!__check_singular(__first) && !__check_singular(__last)); + } + + template + _GLIBCXX_CONSTEXPR + inline bool + __valid_range_aux(_InputIterator __first, _InputIterator __last, + std::random_access_iterator_tag) + { + return + __valid_range_aux(__first, __last, std::input_iterator_tag()) + && __first <= __last; + } + + /** We have iterators, so figure out what kind of iterators they are + * to see if we can check the range ahead of time. + */ + template + _GLIBCXX_CONSTEXPR + inline bool + __valid_range_aux(_InputIterator __first, _InputIterator __last, + std::__false_type) + { + return __valid_range_aux(__first, __last, + std::__iterator_category(__first)); + } + + template + _GLIBCXX20_CONSTEXPR + inline bool + __valid_range_aux(_InputIterator __first, _InputIterator __last, + typename _Distance_traits<_InputIterator>::__type& __dist, + std::__false_type) + { + if (!__valid_range_aux(__first, __last, std::input_iterator_tag())) + return false; + + __dist = __get_distance(__first, __last); + switch (__dist.second) + { + case __dp_none: + break; + case __dp_equality: + if (__dist.first == 0) + return true; + break; + case __dp_sign: + case __dp_sign_max_size: + case __dp_exact: + return __dist.first >= 0; + } + + // Can't tell so assume it is fine. + return true; + } + + /** Don't know what these iterators are, or if they are even + * iterators (we may get an integral type for InputIterator), so + * see if they are integral and pass them on to the next phase + * otherwise. + */ + template + _GLIBCXX20_CONSTEXPR + inline bool + __valid_range(_InputIterator __first, _InputIterator __last, + typename _Distance_traits<_InputIterator>::__type& __dist) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return __valid_range_aux(__first, __last, __dist, _Integral()); + } + + template + bool + __valid_range(const _Safe_iterator<_Iterator, _Sequence, _Category>&, + const _Safe_iterator<_Iterator, _Sequence, _Category>&, + typename _Distance_traits<_Iterator>::__type&); + +#if __cplusplus >= 201103L + template + bool + __valid_range(const _Safe_local_iterator<_Iterator, _Sequence>&, + const _Safe_local_iterator<_Iterator, _Sequence>&, + typename _Distance_traits<_Iterator>::__type&); +#endif + + template + _GLIBCXX14_CONSTEXPR + inline bool + __valid_range(_InputIterator __first, _InputIterator __last) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return __valid_range_aux(__first, __last, _Integral()); + } + + template + bool + __valid_range(const _Safe_iterator<_Iterator, _Sequence, _Category>&, + const _Safe_iterator<_Iterator, _Sequence, _Category>&); + +#if __cplusplus >= 201103L + template + bool + __valid_range(const _Safe_local_iterator<_Iterator, _Sequence>&, + const _Safe_local_iterator<_Iterator, _Sequence>&); +#endif + + // Fallback method, always ok. + template + _GLIBCXX_CONSTEXPR + inline bool + __can_advance(_InputIterator, _Size) + { return true; } + + template + bool + __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>&, + _Size); + + template + _GLIBCXX_CONSTEXPR + inline bool + __can_advance(_InputIterator, const std::pair<_Diff, _Distance_precision>&, int) + { return true; } + + template + bool + __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>&, + const std::pair<_Diff, _Distance_precision>&, int); + + /** Helper function to extract base iterator of random access safe iterator + * in order to reduce performance impact of debug mode. Limited to random + * access iterator because it is the only category for which it is possible + * to check for correct iterators order in the __valid_range function + * thanks to the < operator. + */ + template + _GLIBCXX_CONSTEXPR + inline _Iterator + __base(_Iterator __it) + { return __it; } + +#if __cplusplus < 201103L + template + struct _Unsafe_type + { typedef _Iterator _Type; }; +#endif + + /* Remove debug mode safe iterator layer, if any. */ + template + inline _Iterator + __unsafe(_Iterator __it) + { return __it; } +} + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/list b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/list new file mode 100755 index 0000000..5e0adad --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/list @@ -0,0 +1,992 @@ +// Debugging list implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/list + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_LIST +#define _GLIBCXX_DEBUG_LIST 1 + +#pragma GCC system_header + +#include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template class list; +} } // namespace std::__debug + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::list with safety/checking/debug instrumentation. + template > + class list + : public __gnu_debug::_Safe_container< + list<_Tp, _Allocator>, _Allocator, + __gnu_debug::_Safe_node_sequence>, + public _GLIBCXX_STD_C::list<_Tp, _Allocator> + { + typedef _GLIBCXX_STD_C::list<_Tp, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + list, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; + + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_iterator _Base_const_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates list(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator<_Base_iterator, list> + iterator; + typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, list> + const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + + typedef _Tp value_type; + typedef _Allocator allocator_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.2.2.1 construct/copy/destroy: + +#if __cplusplus < 201103L + list() + : _Base() { } + + list(const list& __x) + : _Base(__x) { } + + ~list() { } +#else + list() = default; + list(const list&) = default; + list(list&&) = default; + + list(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__l, __a) { } + + ~list() = default; + + list(const list& __x, const allocator_type& __a) + : _Base(__x, __a) { } + + list(list&& __x, const allocator_type& __a) + noexcept( + std::is_nothrow_constructible<_Base, + _Base, const allocator_type&>::value ) + : _Safe(std::move(__x._M_safe()), __a), + _Base(std::move(__x._M_base()), __a) { } +#endif + + explicit + list(const _Allocator& __a) _GLIBCXX_NOEXCEPT + : _Base(__a) { } + +#if __cplusplus >= 201103L + explicit + list(size_type __n, const allocator_type& __a = allocator_type()) + : _Base(__n, __a) { } + + list(size_type __n, const __type_identity_t<_Tp>& __value, + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } +#else + explicit + list(size_type __n, const _Tp& __value = _Tp(), + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } +#endif + +#if __cplusplus >= 201103L + template> +#else + template +#endif + list(_InputIterator __first, _InputIterator __last, + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) + { } + + list(_Base_ref __x) + : _Base(__x._M_ref) { } + +#if __cplusplus < 201103L + list& + operator=(const list& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + return *this; + } +#else + list& + operator=(const list&) = default; + + list& + operator=(list&&) = default; + + list& + operator=(initializer_list __l) + { + this->_M_invalidate_all(); + _M_base() = __l; + return *this; + } + + void + assign(initializer_list __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + } +#endif + +#if __cplusplus >= 201103L + template> +#else + template +#endif + void + assign(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::assign(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::assign(__first, __last); + + this->_M_invalidate_all(); + } + + void + assign(size_type __n, const _Tp& __t) + { + _Base::assign(__n, __t); + this->_M_invalidate_all(); + } + + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // 23.2.2.2 capacity: + using _Base::empty; + using _Base::size; + using _Base::max_size; + +#if __cplusplus >= 201103L + void + resize(size_type __sz) + { + this->_M_detach_singular(); + + // if __sz < size(), invalidate all iterators in [begin + __sz, end()) + _Base_iterator __victim = _Base::begin(); + _Base_iterator __end = _Base::end(); + for (size_type __i = __sz; __victim != __end && __i > 0; --__i) + ++__victim; + + for (; __victim != __end; ++__victim) + this->_M_invalidate_if(_Equal(__victim)); + + __try + { + _Base::resize(__sz); + } + __catch(...) + { + this->_M_revalidate_singular(); + __throw_exception_again; + } + } + + void + resize(size_type __sz, const _Tp& __c) + { + this->_M_detach_singular(); + + // if __sz < size(), invalidate all iterators in [begin + __sz, end()) + _Base_iterator __victim = _Base::begin(); + _Base_iterator __end = _Base::end(); + for (size_type __i = __sz; __victim != __end && __i > 0; --__i) + ++__victim; + + for (; __victim != __end; ++__victim) + this->_M_invalidate_if(_Equal(__victim)); + + __try + { + _Base::resize(__sz, __c); + } + __catch(...) + { + this->_M_revalidate_singular(); + __throw_exception_again; + } + } +#else + void + resize(size_type __sz, _Tp __c = _Tp()) + { + this->_M_detach_singular(); + + // if __sz < size(), invalidate all iterators in [begin + __sz, end()) + _Base_iterator __victim = _Base::begin(); + _Base_iterator __end = _Base::end(); + for (size_type __i = __sz; __victim != __end && __i > 0; --__i) + ++__victim; + + for (; __victim != __end; ++__victim) + this->_M_invalidate_if(_Equal(__victim)); + + __try + { + _Base::resize(__sz, __c); + } + __catch(...) + { + this->_M_revalidate_singular(); + __throw_exception_again; + } + } +#endif + + // element access: + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::back(); + } + + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::back(); + } + + // 23.2.2.3 modifiers: + using _Base::push_front; + +#if __cplusplus >= 201103L + using _Base::emplace_front; +#endif + + void + pop_front() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + this->_M_invalidate_if(_Equal(_Base::begin())); + _Base::pop_front(); + } + + using _Base::push_back; + +#if __cplusplus >= 201103L + using _Base::emplace_back; +#endif + + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + this->_M_invalidate_if(_Equal(--_Base::end())); + _Base::pop_back(); + } + +#if __cplusplus >= 201103L + template + iterator + emplace(const_iterator __position, _Args&&... __args) + { + __glibcxx_check_insert(__position); + return { _Base::emplace(__position.base(), + std::forward<_Args>(__args)...), this }; + } +#endif + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else + insert(iterator __position, const _Tp& __x) +#endif + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __x), this); + } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, _Tp&& __x) + { return emplace(__position, std::move(__x)); } + + iterator + insert(const_iterator __p, initializer_list __l) + { + __glibcxx_check_insert(__p); + return { _Base::insert(__p.base(), __l), this }; + } +#endif + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + return { _Base::insert(__position.base(), __n, __x), this }; + } +#else + void + insert(iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + _Base::insert(__position.base(), __n, __x); + } +#endif + +#if __cplusplus >= 201103L + template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__position, __first, __last, __dist); + if (__dist.second >= __gnu_debug::__dp_sign) + return + { + _Base::insert(__position.base(), + __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)), + this + }; + else + return { _Base::insert(__position.base(), __first, __last), this }; + } +#else + template + void + insert(iterator __position, _InputIterator __first, + _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__position, __first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__position.base(), __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__position.base(), __first, __last); + } +#endif + + private: + _Base_iterator +#if __cplusplus >= 201103L + _M_erase(_Base_const_iterator __position) noexcept +#else + _M_erase(_Base_iterator __position) +#endif + { + this->_M_invalidate_if(_Equal(__position)); + return _Base::erase(__position); + } + + public: + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) noexcept +#else + erase(iterator __position) +#endif + { + __glibcxx_check_erase(__position); + return iterator(_M_erase(__position.base()), this); + } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) noexcept +#else + erase(iterator __first, iterator __last) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_const_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "position") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + + return iterator(_Base::erase(__first.base(), __last.base()), this); + } + + void + swap(list& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + _Base::clear(); + this->_M_invalidate_all(); + } + + // 23.2.2.4 list operations: + void +#if __cplusplus >= 201103L + splice(const_iterator __position, list&& __x) noexcept +#else + splice(iterator __position, list& __x) +#endif + { + _GLIBCXX_DEBUG_VERIFY(std::__addressof(__x) != this, + _M_message(__gnu_debug::__msg_self_splice) + ._M_sequence(*this, "this")); + this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end())); + _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base())); + } + +#if __cplusplus >= 201103L + void + splice(const_iterator __position, list& __x) noexcept + { splice(__position, std::move(__x)); } +#endif + + void +#if __cplusplus >= 201103L + splice(const_iterator __position, list&& __x, const_iterator __i) noexcept +#else + splice(iterator __position, list& __x, iterator __i) +#endif + { + __glibcxx_check_insert(__position); + + // We used to perform the splice_alloc check: not anymore, redundant + // after implementing the relevant bits of N1599. + + _GLIBCXX_DEBUG_VERIFY(__i._M_dereferenceable(), + _M_message(__gnu_debug::__msg_splice_bad) + ._M_iterator(__i, "__i")); + _GLIBCXX_DEBUG_VERIFY(__i._M_attached_to(std::__addressof(__x)), + _M_message(__gnu_debug::__msg_splice_other) + ._M_iterator(__i, "__i")._M_sequence(__x, "__x")); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 250. splicing invalidates iterators + this->_M_transfer_from_if(__x, _Equal(__i.base())); + _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), + __i.base()); + } + +#if __cplusplus >= 201103L + void + splice(const_iterator __position, list& __x, const_iterator __i) noexcept + { splice(__position, std::move(__x), __i); } +#endif + + void +#if __cplusplus >= 201103L + splice(const_iterator __position, list&& __x, const_iterator __first, + const_iterator __last) noexcept +#else + splice(iterator __position, list& __x, iterator __first, + iterator __last) +#endif + { + __glibcxx_check_insert(__position); + __glibcxx_check_valid_range(__first, __last); + _GLIBCXX_DEBUG_VERIFY(__first._M_attached_to(std::__addressof(__x)), + _M_message(__gnu_debug::__msg_splice_other) + ._M_sequence(__x, "x") + ._M_iterator(__first, "first")); + + // We used to perform the splice_alloc check: not anymore, redundant + // after implementing the relevant bits of N1599. + + for (_Base_const_iterator __tmp = __first.base(); + __tmp != __last.base(); ++__tmp) + { + _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + _GLIBCXX_DEBUG_VERIFY(std::__addressof(__x) != this + || __tmp != __position.base(), + _M_message(__gnu_debug::__msg_splice_overlap) + ._M_iterator(__tmp, "position") + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 250. splicing invalidates iterators + this->_M_transfer_from_if(__x, _Equal(__tmp)); + } + + _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()), + __first.base(), __last.base()); + } + +#if __cplusplus >= 201103L + void + splice(const_iterator __position, list& __x, + const_iterator __first, const_iterator __last) noexcept + { splice(__position, std::move(__x), __first, __last); } +#endif + + private: +#if __cplusplus > 201703L + typedef size_type __remove_return_type; +# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \ + __attribute__((__abi_tag__("__cxx20"))) +# define _GLIBCXX20_ONLY(__expr) __expr +#else + typedef void __remove_return_type; +# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG +# define _GLIBCXX20_ONLY(__expr) +#endif + + public: + _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + remove(const _Tp& __value) + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::remove(__value); + +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + _Base __to_destroy(get_allocator()); + _Base_iterator __first = _Base::begin(); + _Base_iterator __last = _Base::end(); + while (__first != __last) + { + _Base_iterator __next = __first; + ++__next; + if (*__first == __value) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 526. Is it undefined if a function in the standard changes + // in parameters? + this->_M_invalidate_if(_Equal(__first)); + __to_destroy.splice(__to_destroy.begin(), _M_base(), __first); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + + __first = __next; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + __remove_return_type + remove_if(_Predicate __pred) + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::remove_if(__pred); + +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + _Base __to_destroy(get_allocator()); + for (_Base_iterator __x = _Base::begin(); __x != _Base::end(); ) + { + _Base_iterator __next = __x; + ++__next; + if (__pred(*__x)) + { + this->_M_invalidate_if(_Equal(__x)); + __to_destroy.splice(__to_destroy.begin(), _M_base(), __x); +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + + __x = __next; + } + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG + __remove_return_type + unique() + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::unique(); + + if (empty()) + return _GLIBCXX20_ONLY(0); + +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + _Base __to_destroy(get_allocator()); + _Base_iterator __first = _Base::begin(); + _Base_iterator __last = _Base::end(); + _Base_iterator __next = __first; + while (++__next != __last) + if (*__first == *__next) + { + this->_M_invalidate_if(_Equal(__next)); + __to_destroy.splice(__to_destroy.begin(), _M_base(), __next); + __next = __first; +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + else + __first = __next; + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + + template + __remove_return_type + unique(_BinaryPredicate __binary_pred) + { + if (!this->_M_iterators && !this->_M_const_iterators) + return _Base::unique(__binary_pred); + + if (empty()) + return _GLIBCXX20_ONLY(0); + + +#if !_GLIBCXX_USE_CXX11_ABI + size_type __removed __attribute__((__unused__)) = 0; +#endif + _Base __to_destroy(get_allocator()); + _Base_iterator __first = _Base::begin(); + _Base_iterator __last = _Base::end(); + _Base_iterator __next = __first; + while (++__next != __last) + if (__binary_pred(*__first, *__next)) + { + this->_M_invalidate_if(_Equal(__next)); + __to_destroy.splice(__to_destroy.begin(), _M_base(), __next); + __next = __first; +#if !_GLIBCXX_USE_CXX11_ABI + _GLIBCXX20_ONLY( __removed++ ); +#endif + } + else + __first = __next; + +#if !_GLIBCXX_USE_CXX11_ABI + return _GLIBCXX20_ONLY( __removed ); +#else + return _GLIBCXX20_ONLY( __to_destroy.size() ); +#endif + } + +#undef _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG +#undef _GLIBCXX20_ONLY + + void +#if __cplusplus >= 201103L + merge(list&& __x) +#else + merge(list& __x) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != std::__addressof(__x)) + { + __glibcxx_check_sorted(_Base::begin(), _Base::end()); + __glibcxx_check_sorted(__x.begin().base(), __x.end().base()); + this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end())); + _Base::merge(_GLIBCXX_MOVE(__x._M_base())); + } + } + +#if __cplusplus >= 201103L + void + merge(list& __x) + { merge(std::move(__x)); } +#endif + + template + void +#if __cplusplus >= 201103L + merge(list&& __x, _Compare __comp) +#else + merge(list& __x, _Compare __comp) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 300. list::merge() specification incomplete + if (this != std::__addressof(__x)) + { + __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), + __comp); + __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(), + __comp); + this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end())); + _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); + } + } + +#if __cplusplus >= 201103L + template + void + merge(list& __x, _Compare __comp) + { merge(std::move(__x), __comp); } +#endif + + void + sort() { _Base::sort(); } + + template + void + sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); } + + using _Base::reverse; + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> list<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + list(size_t, _Tp, _Allocator = _Allocator()) + -> list<_Tp, _Allocator>; +#endif + + template + inline bool + operator==(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) + { return __x._M_base() <=> __y._M_base(); } +#else + template + inline bool + operator!=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const list<_Tp, _Alloc>& __lhs, + const list<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + inline void + swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + +} // namespace __debug +} // namespace std + +namespace __gnu_debug +{ +#ifndef _GLIBCXX_USE_CXX11_ABI + // If not using C++11 list::size() is not in O(1) so we do not use it. + template + struct _Sequence_traits > + { + typedef typename std::__debug::list<_Tp, _Alloc>::iterator _It; + + static typename _Distance_traits<_It>::__type + _S_size(const std::__debug::list<_Tp, _Alloc>& __seq) + { + return __seq.empty() + ? std::make_pair(0, __dp_exact) : std::make_pair(1, __dp_sign); + } + }; +#endif + +#ifndef _GLIBCXX_DEBUG_PEDANTIC + template + struct _Insert_range_from_self_is_safe > + { enum { __value = 1 }; }; +#endif +} + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/macros.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/macros.h new file mode 100755 index 0000000..9e1288c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/macros.h @@ -0,0 +1,466 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/macros.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MACROS_H +#define _GLIBCXX_DEBUG_MACROS_H 1 + +/** + * Macros used by the implementation to verify certain + * properties. These macros may only be used directly by the debug + * wrappers. Note that these are macros (instead of the more obviously + * @a correct choice of making them functions) because we need line and + * file information at the call site, to minimize the distance between + * the user error and where the error is reported. + * + */ +#define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \ + if (__builtin_expect(!bool(_Cond), false)) \ + __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \ + ._ErrMsg._M_error() + +#define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \ + do { \ + __glibcxx_constexpr_assert(_Cond); \ + _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); \ + } while (false) + +#define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \ + _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,__PRETTY_FUNCTION__) + +#define _GLIBCXX_DEBUG_VERIFY(_Cond,_ErrMsg) \ + _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond, _ErrMsg, __FILE__, __LINE__, \ + __PRETTY_FUNCTION__) + +// Verify that [_First, _Last) forms a valid iterator range. +#define __glibcxx_check_valid_range(_First,_Last) \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last), \ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +#define __glibcxx_check_valid_range_at(_First,_Last,_File,_Line,_Func) \ +_GLIBCXX_DEBUG_VERIFY_AT_F(__gnu_debug::__valid_range(_First, _Last), \ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last), \ + _File,_Line,_Func) + +#define __glibcxx_check_valid_range2(_First,_Last,_Dist) \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__valid_range(_First, _Last, _Dist), \ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +#define __glibcxx_check_valid_constructor_range(_First,_Last) \ + __gnu_debug::__check_valid_range(_First, _Last, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__) + +// Verify that [_First, _Last) forms a non-empty iterator range. +#define __glibcxx_check_non_empty_range(_First,_Last) \ +_GLIBCXX_DEBUG_VERIFY(_First != _Last, \ + _M_message(__gnu_debug::__msg_non_empty_range) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +// Verify that [_First, _First + _Size) forms a valid range. +#define __glibcxx_check_can_increment(_First,_Size) \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__can_advance(_First, _Size), \ + _M_message(__gnu_debug::__msg_iter_subscript_oob) \ + ._M_iterator(_First, #_First) \ + ._M_integer(_Size, #_Size)) + +#define __glibcxx_check_can_increment_dist(_First,_Dist,_Way) \ + _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__can_advance(_First, _Dist, _Way), \ + _M_message(__gnu_debug::__msg_iter_subscript_oob) \ + ._M_iterator(_First, #_First) \ + ._M_integer(_Way * _Dist.first, #_Dist)) + +#define __glibcxx_check_can_increment_range(_First1,_Last1,_First2) \ + do \ + { \ + typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\ + _GLIBCXX_DEBUG_VERIFY_AT_F( \ + __gnu_debug::__valid_range(_First1, _Last1, __dist),\ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First1, #_First1) \ + ._M_iterator(_Last1, #_Last1), \ + __FILE__,__LINE__,__PRETTY_FUNCTION__); \ + _GLIBCXX_DEBUG_VERIFY_AT_F( \ + __gnu_debug::__can_advance(_First2, __dist, 1), \ + _M_message(__gnu_debug::__msg_iter_subscript_oob)\ + ._M_iterator(_First2, #_First2) \ + ._M_integer(__dist.first), \ + __FILE__,__LINE__,__PRETTY_FUNCTION__); \ + } while(false) + +#define __glibcxx_check_can_decrement_range(_First1,_Last1,_First2) \ + do \ + { \ + typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\ + _GLIBCXX_DEBUG_VERIFY_AT_F( \ + __gnu_debug::__valid_range(_First1, _Last1, __dist),\ + _M_message(__gnu_debug::__msg_valid_range) \ + ._M_iterator(_First1, #_First1) \ + ._M_iterator(_Last1, #_Last1), \ + __FILE__,__LINE__,__PRETTY_FUNCTION__); \ + _GLIBCXX_DEBUG_VERIFY_AT_F( \ + __gnu_debug::__can_advance(_First2, __dist, -1), \ + _M_message(__gnu_debug::__msg_iter_subscript_oob)\ + ._M_iterator(_First2, #_First2) \ + ._M_integer(-__dist.first), \ + __FILE__,__LINE__,__PRETTY_FUNCTION__); \ + } while(false) + +/** Verify that we can insert into *this with the iterator _Position. + * Insertion into a container at a specific position requires that + * the iterator be nonsingular, either dereferenceable or past-the-end, + * and that it reference the sequence we are inserting into. Note that + * this macro is only valid when the container is a_Safe_sequence and + * the iterator is a _Safe_iterator. +*/ +#define __glibcxx_check_insert(_Position) \ +_GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ + _M_message(__gnu_debug::__msg_insert_singular) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_insert_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can insert into *this after the iterator _Position. + * Insertion into a container after a specific position requires that + * the iterator be nonsingular, either dereferenceable or before-begin, + * and that it reference the sequence we are inserting into. Note that + * this macro is only valid when the container is a_Safe_sequence and + * the iterator is a _Safe_iterator. +*/ +#define __glibcxx_check_insert_after(_Position) \ +__glibcxx_check_insert(_Position); \ +_GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \ + _M_message(__gnu_debug::__msg_insert_after_end) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can insert the values in the iterator range + * [_First, _Last) into *this with the iterator _Position. Insertion + * into a container at a specific position requires that the iterator + * be nonsingular (i.e., either dereferenceable or past-the-end), + * that it reference the sequence we are inserting into, and that the + * iterator range [_First, _Last) is a valid (possibly empty) + * range which does not reference the sequence we are inserting into. + * Note that this macro is only valid when the container is a + * _Safe_sequence and the _Position iterator is a _Safe_iterator. +*/ +#define __glibcxx_check_insert_range(_Position,_First,_Last,_Dist) \ +__glibcxx_check_valid_range2(_First,_Last,_Dist); \ +__glibcxx_check_insert(_Position); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\ + _M_message(__gnu_debug::__msg_insert_range_from_self)\ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_sequence(*this, "this")) + +/** Verify that we can insert the values in the iterator range + * [_First, _Last) into *this after the iterator _Position. Insertion + * into a container after a specific position requires that the iterator + * be nonsingular (i.e., either dereferenceable or past-the-end), + * that it reference the sequence we are inserting into, and that the + * iterator range [_First, _Last) is a valid (possibly empty) + * range which does not reference the sequence we are inserting into. + * Note that this macro is only valid when the container is a + * _Safe_sequence and the _Position iterator is a _Safe_iterator. +*/ +#define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\ +__glibcxx_check_valid_range2(_First,_Last,_Dist); \ +__glibcxx_check_insert_after(_Position); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\ + _M_message(__gnu_debug::__msg_insert_range_from_self)\ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_sequence(*this, "this")) + +/** Verify that we can erase the element referenced by the iterator + * _Position. We can erase the element if the _Position iterator is + * dereferenceable and references this sequence. +*/ +#define __glibcxx_check_erase(_Position) \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_dereferenceable(), \ + _M_message(__gnu_debug::__msg_erase_bad) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can erase the element after the iterator + * _Position. We can erase the element if the _Position iterator is + * before a dereferenceable one and references this sequence. +*/ +#define __glibcxx_check_erase_after(_Position) \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_before_dereferenceable(), \ + _M_message(__gnu_debug::__msg_erase_after_bad) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)); \ +_GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_Position, #_Position)) + +/** Verify that we can erase the elements in the iterator range + * [_First, _Last). We can erase the elements if [_First, _Last) is a + * valid iterator range within this sequence. +*/ +#define __glibcxx_check_erase_range(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that we can erase the elements in the iterator range + * (_First, _Last). We can erase the elements if (_First, _Last) is a + * valid iterator range within this sequence. +*/ +#define __glibcxx_check_erase_range_after(_First,_Last) \ +_GLIBCXX_DEBUG_VERIFY(!_First._M_singular() && !_Last._M_singular(), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)); \ +_GLIBCXX_DEBUG_VERIFY(_First._M_can_compare(_Last), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)); \ +_GLIBCXX_DEBUG_VERIFY(_First._M_attached_to(this), \ + _M_message(__gnu_debug::__msg_erase_different) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First)); \ +_GLIBCXX_DEBUG_VERIFY(_First != _Last, \ + _M_message(__gnu_debug::__msg_valid_range2) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)); \ +_GLIBCXX_DEBUG_VERIFY(_First._M_incrementable(), \ + _M_message(__gnu_debug::__msg_valid_range2) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)); \ +_GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \ + _M_message(__gnu_debug::__msg_valid_range2) \ + ._M_sequence(*this, "this") \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) \ + +// Verify that the subscript _N is less than the container's size. +#define __glibcxx_check_subscript(_N) \ +_GLIBCXX_DEBUG_VERIFY(_N < this->size(), \ + _M_message(__gnu_debug::__msg_subscript_oob) \ + ._M_sequence(*this, "this") \ + ._M_integer(_N, #_N) \ + ._M_integer(this->size(), "size")) + +// Verify that the bucket _N is less than the container's buckets count. +#define __glibcxx_check_bucket_index(_N) \ +_GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \ + _M_message(__gnu_debug::__msg_bucket_index_oob) \ + ._M_sequence(*this, "this") \ + ._M_integer(_N, #_N) \ + ._M_integer(this->bucket_count(), "size")) + +// Verify that the container is nonempty +#define __glibcxx_check_nonempty() \ +_GLIBCXX_DEBUG_VERIFY(! this->empty(), \ + _M_message(__gnu_debug::__msg_empty) \ + ._M_sequence(*this, "this")) + +// Verify that a predicate is irreflexive +#define __glibcxx_check_irreflexive(_First,_Last) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last || !(*_First < *_First), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_iterator_value_type(_First, "< operator type")) + +#if __cplusplus >= 201103L +# define __glibcxx_check_irreflexive2(_First,_Last) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last \ + || __gnu_debug::__is_irreflexive(_First), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_iterator_value_type(_First, "< operator type")) +#else +# define __glibcxx_check_irreflexive2(_First,_Last) +#endif + +#define __glibcxx_check_irreflexive_pred(_First,_Last,_Pred) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last || !_Pred(*_First, *_First), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_instance(_Pred, "functor") \ + ._M_iterator_value_type(_First, "ordered type")) + +#if __cplusplus >= 201103L +# define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) \ + _GLIBCXX_DEBUG_VERIFY(_First == _Last \ + ||__gnu_debug::__is_irreflexive_pred(_First, _Pred), \ + _M_message(__gnu_debug::__msg_irreflexive_ordering) \ + ._M_instance(_Pred, "functor") \ + ._M_iterator_value_type(_First, "ordered type")) +#else +# define __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred) +#endif + +// Verify that the iterator range [_First, _Last) is sorted +#define __glibcxx_check_sorted(_First,_Last) \ +__glibcxx_check_valid_range(_First,_Last); \ +__glibcxx_check_irreflexive(_First,_Last); \ + _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last)), \ + _M_message(__gnu_debug::__msg_unsorted) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that the iterator range [_First, _Last) is sorted by the + predicate _Pred. */ +#define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +__glibcxx_check_irreflexive_pred(_First,_Last,_Pred); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Pred), \ + _M_message(__gnu_debug::__msg_unsorted_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred)) + +// Special variant for std::merge, std::includes, std::set_* +#define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \ +__glibcxx_check_valid_range(_First1,_Last1); \ +_GLIBCXX_DEBUG_VERIFY( \ + __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \ + __gnu_debug::__base(_Last1), _First2),\ + _M_message(__gnu_debug::__msg_unsorted) \ + ._M_iterator(_First1, #_First1) \ + ._M_iterator(_Last1, #_Last1)) + +// Likewise with a _Pred. +#define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ +__glibcxx_check_valid_range(_First1,_Last1); \ +_GLIBCXX_DEBUG_VERIFY( \ + __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \ + __gnu_debug::__base(_Last1), \ + _First2, _Pred), \ + _M_message(__gnu_debug::__msg_unsorted_pred) \ + ._M_iterator(_First1, #_First1) \ + ._M_iterator(_Last1, #_Last1) \ + ._M_string(#_Pred)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value. */ +#define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value), \ + _M_message(__gnu_debug::__msg_unpartitioned) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Value)) + +#define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value), \ + _M_message(__gnu_debug::__msg_unpartitioned) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Value)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value and predicate _Pred. */ +#define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value, _Pred), \ + _M_message(__gnu_debug::__msg_unpartitioned_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred) \ + ._M_string(#_Value)) + +/** Verify that the iterator range [_First, _Last) is partitioned + w.r.t. the value _Value and predicate _Pred. */ +#define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ +__glibcxx_check_valid_range(_First,_Last); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value, _Pred), \ + _M_message(__gnu_debug::__msg_unpartitioned_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred) \ + ._M_string(#_Value)) + +// Verify that the iterator range [_First, _Last) is a heap +#define __glibcxx_check_heap(_First,_Last) \ + _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last)), \ + _M_message(__gnu_debug::__msg_not_heap) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last)) + +/** Verify that the iterator range [_First, _Last) is a heap + w.r.t. the predicate _Pred. */ +#define __glibcxx_check_heap_pred(_First,_Last,_Pred) \ + _GLIBCXX_DEBUG_VERIFY(std::__is_heap(__gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), \ + _Pred), \ + _M_message(__gnu_debug::__msg_not_heap_pred) \ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_string(#_Pred)) + +// Verify that load factor is positive +#define __glibcxx_check_max_load_factor(_F) \ +_GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \ + _M_message(__gnu_debug::__msg_valid_load_factor) \ + ._M_sequence(*this, "this")) + +#define __glibcxx_check_equal_allocs(_This, _Other) \ +_GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(), \ + _M_message(__gnu_debug::__msg_equal_allocs) \ + ._M_sequence(_This, "this")) + +#define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0) +#define __glibcxx_check_string_len(_String,_Len) \ + _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0) + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/map b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/map new file mode 100755 index 0000000..c539638 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/map @@ -0,0 +1,46 @@ +// Debugging map/multimap implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/map + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MAP +#define _GLIBCXX_DEBUG_MAP 1 + +#pragma GCC system_header + +#include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template + class map; + template + class multimap; +} } // namespace std::__debug + +#include +#include +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/map.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/map.h new file mode 100755 index 0000000..ab34b2a --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/map.h @@ -0,0 +1,807 @@ +// Debugging map implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/map.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MAP_H +#define _GLIBCXX_DEBUG_MAP_H 1 + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::map with safety/checking/debug instrumentation. + template, + typename _Allocator = std::allocator > > + class map + : public __gnu_debug::_Safe_container< + map<_Key, _Tp, _Compare, _Allocator>, _Allocator, + __gnu_debug::_Safe_node_sequence>, + public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> + { + typedef _GLIBCXX_STD_C::map< + _Key, _Tp, _Compare, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + map, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; + + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates map(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + // types: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Allocator allocator_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator<_Base_iterator, map> + iterator; + typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, map> + const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.3.1.1 construct/copy/destroy: + +#if __cplusplus < 201103L + map() : _Base() { } + + map(const map& __x) + : _Base(__x) { } + + ~map() { } +#else + map() = default; + map(const map&) = default; + map(map&&) = default; + + map(initializer_list __l, + const _Compare& __c = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __c, __a) { } + + explicit + map(const allocator_type& __a) + : _Base(__a) { } + + map(const map& __m, const allocator_type& __a) + : _Base(__m, __a) { } + + map(map&& __m, const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) ) + : _Safe(std::move(__m._M_safe()), __a), + _Base(std::move(__m._M_base()), __a) { } + + map(initializer_list __l, const allocator_type& __a) + : _Base(__l, __a) { } + + template + map(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) + { } + + ~map() = default; +#endif + + map(_Base_ref __x) + : _Base(__x._M_ref) { } + + explicit map(const _Compare& __comp, + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template + map(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), + __comp, __a) { } + +#if __cplusplus < 201103L + map& + operator=(const map& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + return *this; + } +#else + map& + operator=(const map&) = default; + + map& + operator=(map&&) = default; + + map& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } +#endif + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 133. map missing get_allocator() + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // capacity: + using _Base::empty; + using _Base::size; + using _Base::max_size; + + // 23.3.1.2 element access: + using _Base::operator[]; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::at; + + // modifiers: +#if __cplusplus >= 201103L + template + std::pair + emplace(_Args&&... __args) + { + auto __res = _Base::emplace(std::forward<_Args>(__args)...); + return { { __res.first, this }, __res.second }; + } + + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + __glibcxx_check_insert(__pos); + return + { + _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...), + this + }; + } +#endif + + std::pair + insert(const value_type& __x) + { + std::pair<_Base_iterator, bool> __res = _Base::insert(__x); + return std::pair(iterator(__res.first, this), + __res.second); + } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + std::pair + insert(value_type&& __x) + { + auto __res = _Base::insert(std::move(__x)); + return { { __res.first, this }, __res.second }; + } + + template::value>::type> + std::pair + insert(_Pair&& __x) + { + auto __res = _Base::insert(std::forward<_Pair>(__x)); + return { { __res.first, this }, __res.second }; + } +#endif + +#if __cplusplus >= 201103L + void + insert(std::initializer_list __list) + { _Base::insert(__list); } +#endif + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __x), this); + } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __position, value_type&& __x) + { + __glibcxx_check_insert(__position); + return { _Base::insert(__position.base(), std::move(__x)), this }; + } + + template::value>::type> + iterator + insert(const_iterator __position, _Pair&& __x) + { + __glibcxx_check_insert(__position); + return + { + _Base::insert(__position.base(), std::forward<_Pair>(__x)), + this + }; + } +#endif + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + } + + +#if __cplusplus > 201402L + template + pair + try_emplace(const key_type& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(__k, + std::forward<_Args>(__args)...); + return { { __res.first, this }, __res.second }; + } + + template + pair + try_emplace(key_type&& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(std::move(__k), + std::forward<_Args>(__args)...); + return { { __res.first, this }, __res.second }; + } + + template + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return + { + _Base::try_emplace(__hint.base(), __k, + std::forward<_Args>(__args)...), + this + }; + } + + template + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return + { + _Base::try_emplace(__hint.base(), std::move(__k), + std::forward<_Args>(__args)...), + this + }; + } + + template + std::pair + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(__k, + std::forward<_Obj>(__obj)); + return { { __res.first, this }, __res.second }; + } + + template + std::pair + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(std::move(__k), + std::forward<_Obj>(__obj)); + return { { __res.first, this }, __res.second }; + } + + template + iterator + insert_or_assign(const_iterator __hint, + const key_type& __k, _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return + { + _Base::insert_or_assign(__hint.base(), __k, + std::forward<_Obj>(__obj)), + this + }; + } + + template + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return + { + _Base::insert_or_assign(__hint.base(), std::move(__k), + std::forward<_Obj>(__obj)), + this + }; + } +#endif // C++17 + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + using insert_return_type = _Node_insert_return; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return _Base::extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = find(__key); + if (__position != end()) + return extract(__position); + return {}; + } + + insert_return_type + insert(node_type&& __nh) + { + auto __ret = _Base::insert(std::move(__nh)); + return + { { __ret.position, this }, __ret.inserted, std::move(__ret.node) }; + } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + +#if __cplusplus >= 201103L + iterator + erase(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return { _Base::erase(__position.base()), this }; + } + + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } +#else + void + erase(iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + _Base::erase(__position.base()); + } +#endif + + size_type + erase(const key_type& __x) + { + _Base_iterator __victim = _Base::find(__x); + if (__victim == _Base::end()) + return 0; + else + { + this->_M_invalidate_if(_Equal(__victim)); + _Base::erase(__victim); + return 1; + } + } + +#if __cplusplus >= 201103L + iterator + erase(const_iterator __first, const_iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_const_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + + return { _Base::erase(__first.base(), __last.base()), this }; + } +#else + void + erase(iterator __first, iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + _Base::erase(__first.base(), __last.base()); + } +#endif + + void + swap(map& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + this->_M_invalidate_all(); + _Base::clear(); + } + + // observers: + using _Base::key_comp; + using _Base::value_comp; + + // 23.3.1.3 map operations: + iterator + find(const key_type& __x) + { return iterator(_Base::find(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } +#endif + + const_iterator + find(const key_type& __x) const + { return const_iterator(_Base::find(__x), this); } + +#if __cplusplus > 201103L + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + + using _Base::count; + + iterator + lower_bound(const key_type& __x) + { return iterator(_Base::lower_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } +#endif + + const_iterator + lower_bound(const key_type& __x) const + { return const_iterator(_Base::lower_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + + iterator + upper_bound(const key_type& __x) + { return iterator(_Base::upper_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } +#endif + + const_iterator + upper_bound(const key_type& __x) const + { return const_iterator(_Base::upper_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + + std::pair + equal_range(const key_type& __x) + { + std::pair<_Base_iterator, _Base_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(iterator(__res.first, this), + iterator(__res.second, this)); + } + +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + std::pair + equal_range(const key_type& __x) const + { + std::pair<_Base_const_iterator, _Base_const_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(const_iterator(__res.first, this), + const_iterator(__res.second, this)); + } + +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + map(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<_Key, _Tp, _Compare, _Allocator>; + + template , + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, _Allocator) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + map(initializer_list>, _Allocator) + -> map<_Key, _Tp, less<_Key>, _Allocator>; + +#endif // deduction guides + + template + inline bool + operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + inline __detail::__synth3way_t> + operator<=>(const map<_Key, _Tp, _Compare, _Alloc>& __lhs, + const map<_Key, _Tp, _Compare, _Alloc>& __rhs) + { return __lhs._M_base() <=> __rhs._M_base(); } +#else + template + inline bool + operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs, + const map<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + inline void + swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs, + map<_Key, _Tp, _Compare, _Allocator>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + +} // namespace __debug +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/multimap.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/multimap.h new file mode 100755 index 0000000..96a44f4 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/multimap.h @@ -0,0 +1,688 @@ +// Debugging multimap implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/multimap.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MULTIMAP_H +#define _GLIBCXX_DEBUG_MULTIMAP_H 1 + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::multimap with safety/checking/debug instrumentation. + template, + typename _Allocator = std::allocator > > + class multimap + : public __gnu_debug::_Safe_container< + multimap<_Key, _Tp, _Compare, _Allocator>, _Allocator, + __gnu_debug::_Safe_node_sequence>, + public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> + { + typedef _GLIBCXX_STD_C::multimap< + _Key, _Tp, _Compare, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + multimap, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; + + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates multimap(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + // types: + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair value_type; + typedef _Compare key_compare; + typedef _Allocator allocator_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator<_Base_iterator, multimap> + iterator; + typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, + multimap> const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.3.1.1 construct/copy/destroy: + +#if __cplusplus < 201103L + multimap() : _Base() { } + + multimap(const multimap& __x) + : _Base(__x) { } + + ~multimap() { } +#else + multimap() = default; + multimap(const multimap&) = default; + multimap(multimap&&) = default; + + multimap(initializer_list __l, + const _Compare& __c = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __c, __a) { } + + explicit + multimap(const allocator_type& __a) + : _Base(__a) { } + + multimap(const multimap& __m, const allocator_type& __a) + : _Base(__m, __a) { } + + multimap(multimap&& __m, const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) ) + : _Safe(std::move(__m._M_safe()), __a), + _Base(std::move(__m._M_base()), __a) { } + + multimap(initializer_list __l, const allocator_type& __a) + : _Base(__l, __a) { } + + template + multimap(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) { } + + ~multimap() = default; +#endif + + explicit multimap(const _Compare& __comp, + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template + multimap(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), + __comp, __a) { } + + multimap(_Base_ref __x) + : _Base(__x._M_ref) { } + +#if __cplusplus < 201103L + multimap& + operator=(const multimap& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + return *this; + } +#else + multimap& + operator=(const multimap&) = default; + + multimap& + operator=(multimap&&) = default; + + multimap& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } +#endif + + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // capacity: + using _Base::empty; + using _Base::size; + using _Base::max_size; + + // modifiers: +#if __cplusplus >= 201103L + template + iterator + emplace(_Args&&... __args) + { return { _Base::emplace(std::forward<_Args>(__args)...), this }; } + + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + __glibcxx_check_insert(__pos); + return + { + _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...), + this + }; + } +#endif + + iterator + insert(const value_type& __x) + { return iterator(_Base::insert(__x), this); } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(value_type&& __x) + { return { _Base::insert(std::move(__x)), this }; } + + template::value>::type> + iterator + insert(_Pair&& __x) + { return { _Base::insert(std::forward<_Pair>(__x)), this }; } +#endif + +#if __cplusplus >= 201103L + void + insert(std::initializer_list __list) + { _Base::insert(__list); } +#endif + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else + insert(iterator __position, const value_type& __x) +#endif + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __x), this); + } + +#if __cplusplus >= 201103L + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __position, value_type&& __x) + { + __glibcxx_check_insert(__position); + return { _Base::insert(__position.base(), std::move(__x)), this }; + } + + template::value>::type> + iterator + insert(const_iterator __position, _Pair&& __x) + { + __glibcxx_check_insert(__position); + return + { + _Base::insert(__position.base(), std::forward<_Pair>(__x)), + this + }; + } +#endif + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + } + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return _Base::extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = find(__key); + if (__position != end()) + return extract(__position); + return {}; + } + + iterator + insert(node_type&& __nh) + { return { _Base::insert(std::move(__nh)), this }; } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + +#if __cplusplus >= 201103L + iterator + erase(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return { _Base::erase(__position.base()), this }; + } + + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(iterator __position) + { return erase(const_iterator(__position)); } +#else + void + erase(iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + _Base::erase(__position.base()); + } +#endif + + size_type + erase(const key_type& __x) + { + std::pair<_Base_iterator, _Base_iterator> __victims = + _Base::equal_range(__x); + size_type __count = 0; + _Base_iterator __victim = __victims.first; + while (__victim != __victims.second) + { + this->_M_invalidate_if(_Equal(__victim)); + _Base::erase(__victim++); + ++__count; + } + return __count; + } + +#if __cplusplus >= 201103L + iterator + erase(const_iterator __first, const_iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_const_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + + return { _Base::erase(__first.base(), __last.base()), this }; + } +#else + void + erase(iterator __first, iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + _Base::erase(__first.base(), __last.base()); + } +#endif + + void + swap(multimap& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + this->_M_invalidate_all(); + _Base::clear(); + } + + // observers: + using _Base::key_comp; + using _Base::value_comp; + + // 23.3.1.3 multimap operations: + iterator + find(const key_type& __x) + { return iterator(_Base::find(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } +#endif + + const_iterator + find(const key_type& __x) const + { return const_iterator(_Base::find(__x), this); } + +#if __cplusplus > 201103L + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + + using _Base::count; + + iterator + lower_bound(const key_type& __x) + { return iterator(_Base::lower_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } +#endif + + const_iterator + lower_bound(const key_type& __x) const + { return const_iterator(_Base::lower_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + + iterator + upper_bound(const key_type& __x) + { return iterator(_Base::upper_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } +#endif + + const_iterator + upper_bound(const key_type& __x) const + { return const_iterator(_Base::upper_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + + std::pair + equal_range(const key_type& __x) + { + std::pair<_Base_iterator, _Base_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(iterator(__res.first, this), + iterator(__res.second, this)); + } + +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + std::pair + equal_range(const key_type& __x) const + { + std::pair<_Base_const_iterator, _Base_const_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(const_iterator(__res.first, this), + const_iterator(__res.second, this)); + } + +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multimap(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<_Key, _Tp, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, _Allocator) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + multimap(initializer_list>, _Allocator) + -> multimap<_Key, _Tp, less<_Key>, _Allocator>; + +#endif + + template + inline bool + operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + inline __detail::__synth3way_t> + operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __lhs, + const multimap<_Key, _Tp, _Compare, _Alloc>& __rhs) + { return __lhs._M_base() <=> __rhs._M_base(); } +#else + template + inline bool + operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + inline void + swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, + multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + +} // namespace __debug +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/multiset.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/multiset.h new file mode 100755 index 0000000..0e76c5f --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/multiset.h @@ -0,0 +1,653 @@ +// Debugging multiset implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/multiset.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_MULTISET_H +#define _GLIBCXX_DEBUG_MULTISET_H 1 + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::multiset with safety/checking/debug instrumentation. + template, + typename _Allocator = std::allocator<_Key> > + class multiset + : public __gnu_debug::_Safe_container< + multiset<_Key, _Compare, _Allocator>, _Allocator, + __gnu_debug::_Safe_node_sequence>, + public _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> + { + typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + multiset, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; + + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates multiset(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + // types: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + typedef _Allocator allocator_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator<_Base_iterator, multiset> + iterator; + typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, + multiset> const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.3.3.1 construct/copy/destroy: + +#if __cplusplus < 201103L + multiset() : _Base() { } + + multiset(const multiset& __x) + : _Base(__x) { } + + ~multiset() { } +#else + multiset() = default; + multiset(const multiset&) = default; + multiset(multiset&&) = default; + + multiset(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __comp, __a) { } + + explicit + multiset(const allocator_type& __a) + : _Base(__a) { } + + multiset(const multiset& __m, const allocator_type& __a) + : _Base(__m, __a) { } + + multiset(multiset&& __m, const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) ) + : _Safe(std::move(__m._M_safe()), __a), + _Base(std::move(__m._M_base()), __a) { } + + multiset(initializer_list __l, const allocator_type& __a) + : _Base(__l, __a) + { } + + template + multiset(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) { } + + ~multiset() = default; +#endif + + explicit multiset(const _Compare& __comp, + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template + multiset(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), + __comp, __a) { } + + multiset(_Base_ref __x) + : _Base(__x._M_ref) { } + +#if __cplusplus < 201103L + multiset& + operator=(const multiset& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + return *this; + } +#else + multiset& + operator=(const multiset&) = default; + + multiset& + operator=(multiset&&) = default; + + multiset& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } +#endif + + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // capacity: + using _Base::empty; + using _Base::size; + using _Base::max_size; + + // modifiers: +#if __cplusplus >= 201103L + template + iterator + emplace(_Args&&... __args) + { return { _Base::emplace(std::forward<_Args>(__args)...), this }; } + + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + __glibcxx_check_insert(__pos); + return + { + _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...), + this + }; + } +#endif + + iterator + insert(const value_type& __x) + { return iterator(_Base::insert(__x), this); } + +#if __cplusplus >= 201103L + iterator + insert(value_type&& __x) + { return { _Base::insert(std::move(__x)), this }; } +#endif + + iterator + insert(const_iterator __position, const value_type& __x) + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __x), this); + } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, value_type&& __x) + { + __glibcxx_check_insert(__position); + return { _Base::insert(__position.base(), std::move(__x)), this }; + } +#endif + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + } + +#if __cplusplus >= 201103L + void + insert(initializer_list __l) + { _Base::insert(__l); } +#endif + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return _Base::extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = find(__key); + if (__position != end()) + return extract(__position); + return {}; + } + + iterator + insert(node_type&& __nh) + { return { _Base::insert(std::move(__nh)), this }; } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + +#if __cplusplus >= 201103L + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return { _Base::erase(__position.base()), this }; + } +#else + void + erase(iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + _Base::erase(__position.base()); + } +#endif + + size_type + erase(const key_type& __x) + { + std::pair<_Base_iterator, _Base_iterator> __victims = + _Base::equal_range(__x); + size_type __count = 0; + _Base_iterator __victim = __victims.first; + while (__victim != __victims.second) + { + this->_M_invalidate_if(_Equal(__victim)); + _Base::erase(__victim++); + ++__count; + } + return __count; + } + +#if __cplusplus >= 201103L + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_const_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + + return { _Base::erase(__first.base(), __last.base()), this }; + } +#else + void + erase(iterator __first, iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + _Base::erase(__first.base(), __last.base()); + } +#endif + + void + swap(multiset& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + this->_M_invalidate_all(); + _Base::clear(); + } + + // observers: + using _Base::key_comp; + using _Base::value_comp; + + // multiset operations: + iterator + find(const key_type& __x) + { return iterator(_Base::find(__x), this); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + const_iterator + find(const key_type& __x) const + { return const_iterator(_Base::find(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } + + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + + using _Base::count; + + iterator + lower_bound(const key_type& __x) + { return iterator(_Base::lower_bound(__x), this); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + const_iterator + lower_bound(const key_type& __x) const + { return const_iterator(_Base::lower_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } + + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + + iterator + upper_bound(const key_type& __x) + { return iterator(_Base::upper_bound(__x), this); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + const_iterator + upper_bound(const key_type& __x) const + { return const_iterator(_Base::upper_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } + + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + + std::pair + equal_range(const key_type& __x) + { + std::pair<_Base_iterator, _Base_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(iterator(__res.first, this), + iterator(__res.second, this)); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + std::pair + equal_range(const key_type& __x) const + { + std::pair<_Base_const_iterator, _Base_const_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(const_iterator(__res.first, this), + const_iterator(__res.second, this)); + } + +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } + + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + multiset(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, _Allocator) + -> multiset::value_type, + less::value_type>, + _Allocator>; + + template> + multiset(initializer_list<_Key>, _Allocator) + -> multiset<_Key, less<_Key>, _Allocator>; + +#endif // deduction guides + + template + inline bool + operator==(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + inline __detail::__synth3way_t<_Key> + operator<=>(const multiset<_Key, _Compare, _Alloc>& __lhs, + const multiset<_Key, _Compare, _Alloc>& __rhs) + { return __lhs._M_base() <=> __rhs._M_base(); } +#else + template + inline bool + operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const multiset<_Key, _Compare, _Allocator>& __lhs, + const multiset<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + void + swap(multiset<_Key, _Compare, _Allocator>& __x, + multiset<_Key, _Compare, _Allocator>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { return __x.swap(__y); } + +} // namespace __debug +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_base.h new file mode 100755 index 0000000..f284603 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_base.h @@ -0,0 +1,278 @@ +// Safe sequence/iterator base implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_base.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_BASE_H +#define _GLIBCXX_DEBUG_SAFE_BASE_H 1 + +#include + +namespace __gnu_debug +{ + class _Safe_sequence_base; + + /** \brief Basic functionality for a @a safe iterator. + * + * The %_Safe_iterator_base base class implements the functionality + * of a safe iterator that is not specific to a particular iterator + * type. It contains a pointer back to the sequence it references + * along with iterator version information and pointers to form a + * doubly-linked list of iterators referenced by the container. + * + * This class must not perform any operations that can throw an + * exception, or the exception guarantees of derived iterators will + * be broken. + */ + class _Safe_iterator_base + { + friend class _Safe_sequence_base; + + public: + /** The sequence this iterator references; may be NULL to indicate + a singular iterator. */ + _Safe_sequence_base* _M_sequence; + + /** The version number of this iterator. The sentinel value 0 is + * used to indicate an invalidated iterator (i.e., one that is + * singular because of an operation on the container). This + * version number must equal the version number in the sequence + * referenced by _M_sequence for the iterator to be + * non-singular. + */ + unsigned int _M_version; + + /** Pointer to the previous iterator in the sequence's list of + iterators. Only valid when _M_sequence != NULL. */ + _Safe_iterator_base* _M_prior; + + /** Pointer to the next iterator in the sequence's list of + iterators. Only valid when _M_sequence != NULL. */ + _Safe_iterator_base* _M_next; + + protected: + /** Initializes the iterator and makes it singular. */ + _Safe_iterator_base() + : _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0) + { } + + /** Initialize the iterator to reference the sequence pointed to + * by @p __seq. @p __constant is true when we are initializing a + * constant iterator, and false if it is a mutable iterator. Note + * that @p __seq may be NULL, in which case the iterator will be + * singular. Otherwise, the iterator will reference @p __seq and + * be nonsingular. + */ + _Safe_iterator_base(const _Safe_sequence_base* __seq, bool __constant) + : _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0) + { this->_M_attach(const_cast<_Safe_sequence_base*>(__seq), __constant); } + + /** Initializes the iterator to reference the same sequence that + @p __x does. @p __constant is true if this is a constant + iterator, and false if it is mutable. */ + _Safe_iterator_base(const _Safe_iterator_base& __x, bool __constant) + : _M_sequence(0), _M_version(0), _M_prior(0), _M_next(0) + { this->_M_attach(__x._M_sequence, __constant); } + + ~_Safe_iterator_base() { this->_M_detach(); } + + /** For use in _Safe_iterator. */ + __gnu_cxx::__mutex& + _M_get_mutex() throw (); + + /** Attaches this iterator to the given sequence, detaching it + * from whatever sequence it was attached to originally. If the + * new sequence is the NULL pointer, the iterator is left + * unattached. + */ + void + _M_attach(_Safe_sequence_base* __seq, bool __constant); + + /** Likewise, but not thread-safe. */ + void + _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw (); + + /** Detach the iterator for whatever sequence it is attached to, + * if any. + */ + void + _M_detach(); + + public: + /** Likewise, but not thread-safe. */ + void + _M_detach_single() throw (); + + /** Determines if we are attached to the given sequence. */ + bool + _M_attached_to(const _Safe_sequence_base* __seq) const + { return _M_sequence == __seq; } + + /** Is this iterator singular? */ + _GLIBCXX_PURE bool + _M_singular() const throw (); + + /** Can we compare this iterator to the given iterator @p __x? + Returns true if both iterators are nonsingular and reference + the same sequence. */ + _GLIBCXX_PURE bool + _M_can_compare(const _Safe_iterator_base& __x) const throw (); + + /** Invalidate the iterator, making it singular. */ + void + _M_invalidate() + { _M_version = 0; } + + /** Reset all member variables */ + void + _M_reset() throw (); + + /** Unlink itself */ + void + _M_unlink() throw () + { + if (_M_prior) + _M_prior->_M_next = _M_next; + if (_M_next) + _M_next->_M_prior = _M_prior; + } + }; + + /** Iterators that derive from _Safe_iterator_base can be determined singular + * or non-singular. + **/ + inline bool + __check_singular_aux(const _Safe_iterator_base* __x) + { return __x->_M_singular(); } + + /** + * @brief Base class that supports tracking of iterators that + * reference a sequence. + * + * The %_Safe_sequence_base class provides basic support for + * tracking iterators into a sequence. Sequences that track + * iterators must derived from %_Safe_sequence_base publicly, so + * that safe iterators (which inherit _Safe_iterator_base) can + * attach to them. This class contains two linked lists of + * iterators, one for constant iterators and one for mutable + * iterators, and a version number that allows very fast + * invalidation of all iterators that reference the container. + * + * This class must ensure that no operation on it may throw an + * exception, otherwise @a safe sequences may fail to provide the + * exception-safety guarantees required by the C++ standard. + */ + class _Safe_sequence_base + { + friend class _Safe_iterator_base; + + public: + /// The list of mutable iterators that reference this container + _Safe_iterator_base* _M_iterators; + + /// The list of constant iterators that reference this container + _Safe_iterator_base* _M_const_iterators; + + /// The container version number. This number may never be 0. + mutable unsigned int _M_version; + + protected: + // Initialize with a version number of 1 and no iterators + _Safe_sequence_base() _GLIBCXX_NOEXCEPT + : _M_iterators(0), _M_const_iterators(0), _M_version(1) + { } + +#if __cplusplus >= 201103L + _Safe_sequence_base(const _Safe_sequence_base&) noexcept + : _Safe_sequence_base() { } + + // Move constructor swap iterators. + _Safe_sequence_base(_Safe_sequence_base&& __seq) noexcept + : _Safe_sequence_base() + { _M_swap(__seq); } +#endif + + /** Notify all iterators that reference this sequence that the + sequence is being destroyed. */ + ~_Safe_sequence_base() + { this->_M_detach_all(); } + + /** Detach all iterators, leaving them singular. */ + void + _M_detach_all(); + + /** Detach all singular iterators. + * @post for all iterators i attached to this sequence, + * i->_M_version == _M_version. + */ + void + _M_detach_singular(); + + /** Revalidates all attached singular iterators. This method may + * be used to validate iterators that were invalidated before + * (but for some reason, such as an exception, need to become + * valid again). + */ + void + _M_revalidate_singular(); + + /** Swap this sequence with the given sequence. This operation + * also swaps ownership of the iterators, so that when the + * operation is complete all iterators that originally referenced + * one container now reference the other container. + */ + void + _M_swap(_Safe_sequence_base& __x) _GLIBCXX_USE_NOEXCEPT; + + /** For use in _Safe_sequence. */ + __gnu_cxx::__mutex& + _M_get_mutex() throw (); + + /** Invalidates all iterators. */ + void + _M_invalidate_all() const + { if (++_M_version == 0) _M_version = 1; } + + private: + /** Attach an iterator to this sequence. */ + void + _M_attach(_Safe_iterator_base* __it, bool __constant); + + /** Likewise but not thread safe. */ + void + _M_attach_single(_Safe_iterator_base* __it, bool __constant) throw (); + + /** Detach an iterator from this sequence */ + void + _M_detach(_Safe_iterator_base* __it); + + /** Likewise but not thread safe. */ + void + _M_detach_single(_Safe_iterator_base* __it) throw (); + }; +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_container.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_container.h new file mode 100755 index 0000000..d9636c2 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_container.h @@ -0,0 +1,129 @@ +// Safe container implementation -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_container.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_CONTAINER_H +#define _GLIBCXX_DEBUG_SAFE_CONTAINER_H 1 + +#include + +namespace __gnu_debug +{ + /// Safe class dealing with some allocator dependent operations. + template class _SafeBase, + bool _IsCxx11AllocatorAware = true> + class _Safe_container + : public _SafeBase<_SafeContainer> + { + typedef _SafeBase<_SafeContainer> _Base; + + _SafeContainer& + _M_cont() _GLIBCXX_NOEXCEPT + { return *static_cast<_SafeContainer*>(this); } + + protected: + _Safe_container& + _M_safe() _GLIBCXX_NOEXCEPT + { return *this; } + +#if __cplusplus >= 201103L + _Safe_container() = default; + _Safe_container(const _Safe_container&) = default; + _Safe_container(_Safe_container&&) = default; + + _Safe_container(_Safe_container&& __x, const _Alloc& __a) + : _Safe_container() + { + if (__x._M_cont().get_allocator() == __a) + _Base::_M_swap(__x); + else + __x._M_invalidate_all(); + } +#endif + + public: + // Copy assignment invalidate all iterators. + _Safe_container& + operator=(const _Safe_container&) _GLIBCXX_NOEXCEPT + { + this->_M_invalidate_all(); + return *this; + } + +#if __cplusplus >= 201103L + _Safe_container& + operator=(_Safe_container&& __x) noexcept + { + if (std::__addressof(__x) == this) + { + // Standard containers have a valid but unspecified value after + // self-move, so we invalidate all debug iterators even if the + // underlying container happens to preserve its contents. + this->_M_invalidate_all(); + return *this; + } + + if (_IsCxx11AllocatorAware) + { + typedef __gnu_cxx::__alloc_traits<_Alloc> _Alloc_traits; + + bool __xfer_memory = _Alloc_traits::_S_propagate_on_move_assign() + || _M_cont().get_allocator() == __x._M_cont().get_allocator(); + if (__xfer_memory) + _Base::_M_swap(__x); + else + this->_M_invalidate_all(); + } + else + _Base::_M_swap(__x); + + __x._M_invalidate_all(); + return *this; + } + + void + _M_swap(_Safe_container& __x) noexcept + { + if (_IsCxx11AllocatorAware) + { + typedef __gnu_cxx::__alloc_traits<_Alloc> _Alloc_traits; + + if (!_Alloc_traits::_S_propagate_on_swap()) + __glibcxx_check_equal_allocs(this->_M_cont()._M_base(), + __x._M_cont()._M_base()); + } + + _Base::_M_swap(__x); + } +#endif + }; + +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_iterator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_iterator.h new file mode 100755 index 0000000..8e138fd --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_iterator.h @@ -0,0 +1,1001 @@ +// Safe iterator implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_iterator.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_H +#define _GLIBCXX_DEBUG_SAFE_ITERATOR_H 1 + +#include +#include +#include +#include +#include +#include +#if __cplusplus > 201703L +# include +#endif + +#define _GLIBCXX_DEBUG_VERIFY_OPERANDS(_Lhs, _Rhs, _BadMsgId, _DiffMsgId) \ + _GLIBCXX_DEBUG_VERIFY(!_Lhs._M_singular() && !_Rhs._M_singular() \ + || (_Lhs.base() == _Iterator() \ + && _Rhs.base() == _Iterator()), \ + _M_message(_BadMsgId) \ + ._M_iterator(_Lhs, #_Lhs) \ + ._M_iterator(_Rhs, #_Rhs)); \ + _GLIBCXX_DEBUG_VERIFY(_Lhs._M_can_compare(_Rhs), \ + _M_message(_DiffMsgId) \ + ._M_iterator(_Lhs, #_Lhs) \ + ._M_iterator(_Rhs, #_Rhs)) + +#define _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS(_Lhs, _Rhs) \ + _GLIBCXX_DEBUG_VERIFY_OPERANDS(_Lhs, _Rhs, __msg_iter_compare_bad, \ + __msg_compare_different) + +#define _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(_Lhs, _Rhs) \ + _GLIBCXX_DEBUG_VERIFY_OPERANDS(_Lhs, _Rhs, __msg_iter_order_bad, \ + __msg_order_different) + +#define _GLIBCXX_DEBUG_VERIFY_DIST_OPERANDS(_Lhs, _Rhs) \ + _GLIBCXX_DEBUG_VERIFY_OPERANDS(_Lhs, _Rhs, __msg_distance_bad, \ + __msg_distance_different) + +namespace __gnu_debug +{ + /** Helper struct to deal with sequence offering a before_begin + * iterator. + **/ + template + struct _BeforeBeginHelper + { + template + static bool + _S_Is(const _Safe_iterator<_Iterator, _Sequence, _Category>&) + { return false; } + + template + static bool + _S_Is_Beginnest(const _Safe_iterator<_Iterator, _Sequence, _Category>& __it) + { return __it.base() == __it._M_get_sequence()->_M_base().begin(); } + }; + + /** Sequence traits giving the size of a container if possible. */ + template + struct _Sequence_traits + { + typedef _Distance_traits _DistTraits; + + static typename _DistTraits::__type + _S_size(const _Sequence& __seq) + { return std::make_pair(__seq.size(), __dp_exact); } + }; + + /** \brief Safe iterator wrapper. + * + * The class template %_Safe_iterator is a wrapper around an + * iterator that tracks the iterator's movement among sequences and + * checks that operations performed on the "safe" iterator are + * legal. In additional to the basic iterator operations (which are + * validated, and then passed to the underlying iterator), + * %_Safe_iterator has member functions for iterator invalidation, + * attaching/detaching the iterator from sequences, and querying + * the iterator's state. + * + * Note that _Iterator must be the first base class so that it gets + * initialized before the iterator is being attached to the container's list + * of iterators and it is being detached before _Iterator get + * destroyed. Otherwise it would result in a data race. + */ + template::iterator_category> + class _Safe_iterator + : private _Iterator, + public _Safe_iterator_base + { + typedef _Iterator _Iter_base; + typedef _Safe_iterator_base _Safe_base; + + typedef std::iterator_traits<_Iterator> _Traits; + + protected: + typedef std::__are_same _IsConstant; + + typedef typename __gnu_cxx::__conditional_type< + _IsConstant::__value, + typename _Sequence::_Base::iterator, + typename _Sequence::_Base::const_iterator>::__type _OtherIterator; + + struct _Attach_single + { }; + + _Safe_iterator(_Iterator __i, _Safe_sequence_base* __seq, _Attach_single) + _GLIBCXX_NOEXCEPT + : _Iter_base(__i) + { _M_attach_single(__seq); } + + public: + typedef _Iterator iterator_type; + typedef typename _Traits::iterator_category iterator_category; + typedef typename _Traits::value_type value_type; + typedef typename _Traits::difference_type difference_type; + typedef typename _Traits::reference reference; + typedef typename _Traits::pointer pointer; + +#if __cplusplus > 201703L && __cpp_lib_concepts + using iterator_concept = std::__detail::__iter_concept<_Iterator>; +#endif + + /// @post the iterator is singular and unattached + _Safe_iterator() _GLIBCXX_NOEXCEPT : _Iter_base() { } + + /** + * @brief Safe iterator construction from an unsafe iterator and + * its sequence. + * + * @pre @p seq is not NULL + * @post this is not singular + */ + _Safe_iterator(_Iterator __i, const _Safe_sequence_base* __seq) + _GLIBCXX_NOEXCEPT + : _Iter_base(__i), _Safe_base(__seq, _S_constant()) + { + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__msg_init_singular) + ._M_iterator(*this, "this")); + } + + /** + * @brief Copy construction. + */ + _Safe_iterator(const _Safe_iterator& __x) _GLIBCXX_NOEXCEPT + : _Iter_base(__x.base()), _Safe_base() + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_init_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + _M_attach(__x._M_sequence); + } + +#if __cplusplus >= 201103L + /** + * @brief Move construction. + * @post __x is singular and unattached + */ + _Safe_iterator(_Safe_iterator&& __x) noexcept + : _Iter_base() + { + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_init_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + _Safe_sequence_base* __seq = __x._M_sequence; + __x._M_detach(); + std::swap(base(), __x.base()); + _M_attach(__seq); + } +#endif + + /** + * @brief Converting constructor from a mutable iterator to a + * constant iterator. + */ + template + _Safe_iterator( + const _Safe_iterator<_MutableIterator, _Sequence, + typename __gnu_cxx::__enable_if<_IsConstant::__value && + std::__are_same<_MutableIterator, _OtherIterator>::__value, + _Category>::__type>& __x) + _GLIBCXX_NOEXCEPT + : _Iter_base(__x.base()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _MutableIterator(), + _M_message(__msg_init_const_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + _M_attach(__x._M_sequence); + } + + /** + * @brief Copy assignment. + */ + _Safe_iterator& + operator=(const _Safe_iterator& __x) _GLIBCXX_NOEXCEPT + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + + if (this->_M_sequence && this->_M_sequence == __x._M_sequence) + { + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + base() = __x.base(); + _M_version = __x._M_sequence->_M_version; + } + else + { + _M_detach(); + base() = __x.base(); + _M_attach(__x._M_sequence); + } + + return *this; + } + +#if __cplusplus >= 201103L + /** + * @brief Move assignment. + * @post __x is singular and unattached + */ + _Safe_iterator& + operator=(_Safe_iterator&& __x) noexcept + { + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + + if (std::__addressof(__x) == this) + return *this; + + if (this->_M_sequence && this->_M_sequence == __x._M_sequence) + { + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + base() = __x.base(); + _M_version = __x._M_sequence->_M_version; + } + else + { + _M_detach(); + base() = __x.base(); + _M_attach(__x._M_sequence); + } + + __x._M_detach(); + __x.base() = _Iterator(); + return *this; + } +#endif + + /** + * @brief Iterator dereference. + * @pre iterator is dereferenceable + */ + reference + operator*() const _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), + _M_message(__msg_bad_deref) + ._M_iterator(*this, "this")); + return *base(); + } + + /** + * @brief Iterator dereference. + * @pre iterator is dereferenceable + */ + pointer + operator->() const _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), + _M_message(__msg_bad_deref) + ._M_iterator(*this, "this")); + return base().operator->(); + } + + // ------ Input iterator requirements ------ + /** + * @brief Iterator preincrement + * @pre iterator is incrementable + */ + _Safe_iterator& + operator++() _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), + _M_message(__msg_bad_inc) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + ++base(); + return *this; + } + + /** + * @brief Iterator postincrement + * @pre iterator is incrementable + */ + _Safe_iterator + operator++(int) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), + _M_message(__msg_bad_inc) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + return _Safe_iterator(base()++, this->_M_sequence, _Attach_single()); + } + + // ------ Utilities ------ + + /// Determine if this is a constant iterator. + static _GLIBCXX_CONSTEXPR bool + _S_constant() + { return _IsConstant::__value; } + + /** + * @brief Return the underlying iterator + */ + _Iterator& + base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Iterator& + base() const _GLIBCXX_NOEXCEPT { return *this; } + + /** + * @brief Conversion to underlying non-debug iterator to allow + * better interaction with non-debug containers. + */ + operator _Iterator() const _GLIBCXX_NOEXCEPT { return *this; } + + /** Attach iterator to the given sequence. */ + void + _M_attach(_Safe_sequence_base* __seq) + { _Safe_base::_M_attach(__seq, _S_constant()); } + + /** Likewise, but not thread-safe. */ + void + _M_attach_single(_Safe_sequence_base* __seq) + { _Safe_base::_M_attach_single(__seq, _S_constant()); } + + /// Is the iterator dereferenceable? + bool + _M_dereferenceable() const + { return !this->_M_singular() && !_M_is_end() && !_M_is_before_begin(); } + + /// Is the iterator before a dereferenceable one? + bool + _M_before_dereferenceable() const + { + if (this->_M_incrementable()) + { + _Iterator __base = base(); + return ++__base != _M_get_sequence()->_M_base().end(); + } + return false; + } + + /// Is the iterator incrementable? + bool + _M_incrementable() const + { return !this->_M_singular() && !_M_is_end(); } + + // Can we advance the iterator @p __n steps (@p __n may be negative) + bool + _M_can_advance(difference_type __n, bool __strict = false) const; + + // Can we advance the iterator using @p __dist in @p __way direction. + template + bool + _M_can_advance(const std::pair<_Diff, _Distance_precision>& __dist, + int __way) const; + + // Is the iterator range [*this, __rhs) valid? + bool + _M_valid_range(const _Safe_iterator& __rhs, + std::pair& __dist, + bool __check_dereferenceable = true) const; + + // The sequence this iterator references. + typename __gnu_cxx::__conditional_type< + _IsConstant::__value, const _Sequence*, _Sequence*>::__type + _M_get_sequence() const + { return static_cast<_Sequence*>(_M_sequence); } + + // Get distance to __rhs. + typename _Distance_traits<_Iterator>::__type + _M_get_distance_to(const _Safe_iterator& __rhs) const; + + // Get distance from sequence begin up to *this. + typename _Distance_traits<_Iterator>::__type + _M_get_distance_from_begin() const; + + // Get distance from *this to sequence end. + typename _Distance_traits<_Iterator>::__type + _M_get_distance_to_end() const; + + /// Is this iterator equal to the sequence's begin() iterator? + bool + _M_is_begin() const + { return base() == _M_get_sequence()->_M_base().begin(); } + + /// Is this iterator equal to the sequence's end() iterator? + bool + _M_is_end() const + { return base() == _M_get_sequence()->_M_base().end(); } + + /// Is this iterator equal to the sequence's before_begin() iterator if + /// any? + bool + _M_is_before_begin() const + { return _BeforeBeginHelper<_Sequence>::_S_Is(*this); } + + /// Is this iterator equal to the sequence's before_begin() iterator if + /// any or begin() otherwise? + bool + _M_is_beginnest() const + { return _BeforeBeginHelper<_Sequence>::_S_Is_Beginnest(*this); } + + // ------ Operators ------ + + typedef _Safe_iterator<_Iterator, _Sequence, iterator_category> _Self; + + friend bool + operator==(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS(__lhs, __rhs); + return __lhs.base() == __rhs.base(); + } + + template + friend bool + operator==(const _Self& __lhs, + const _Safe_iterator<_IteR, _Sequence, iterator_category>& __rhs) + _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS(__lhs, __rhs); + return __lhs.base() == __rhs.base(); + } + +#if ! __cpp_lib_three_way_comparison + friend bool + operator!=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS(__lhs, __rhs); + return __lhs.base() != __rhs.base(); + } + + template + friend bool + operator!=(const _Self& __lhs, + const _Safe_iterator<_IteR, _Sequence, iterator_category>& __rhs) + _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS(__lhs, __rhs); + return __lhs.base() != __rhs.base(); + } +#endif // three-way comparison + }; + + template + class _Safe_iterator<_Iterator, _Sequence, std::bidirectional_iterator_tag> + : public _Safe_iterator<_Iterator, _Sequence, std::forward_iterator_tag> + { + typedef _Safe_iterator<_Iterator, _Sequence, + std::forward_iterator_tag> _Safe_base; + + protected: + typedef typename _Safe_base::_OtherIterator _OtherIterator; + typedef typename _Safe_base::_Attach_single _Attach_single; + + _Safe_iterator(_Iterator __i, _Safe_sequence_base* __seq, _Attach_single) + _GLIBCXX_NOEXCEPT + : _Safe_base(__i, __seq, _Attach_single()) + { } + + public: + /// @post the iterator is singular and unattached + _Safe_iterator() _GLIBCXX_NOEXCEPT { } + + /** + * @brief Safe iterator construction from an unsafe iterator and + * its sequence. + * + * @pre @p seq is not NULL + * @post this is not singular + */ + _Safe_iterator(_Iterator __i, const _Safe_sequence_base* __seq) + _GLIBCXX_NOEXCEPT + : _Safe_base(__i, __seq) + { } + + /** + * @brief Copy construction. + */ + _Safe_iterator(const _Safe_iterator& __x) _GLIBCXX_NOEXCEPT + : _Safe_base(__x) + { } + +#if __cplusplus >= 201103L + /** @brief Move construction. */ + _Safe_iterator(_Safe_iterator&&) = default; +#endif + + /** + * @brief Converting constructor from a mutable iterator to a + * constant iterator. + */ + template + _Safe_iterator( + const _Safe_iterator<_MutableIterator, _Sequence, + typename __gnu_cxx::__enable_if<_Safe_base::_IsConstant::__value && + std::__are_same<_MutableIterator, _OtherIterator>::__value, + std::bidirectional_iterator_tag>::__type>& __x) + _GLIBCXX_NOEXCEPT + : _Safe_base(__x) + { } + +#if __cplusplus >= 201103L + /** @brief Copy assignment. */ + _Safe_iterator& + operator=(const _Safe_iterator&) = default; + + /** @brief Move assignment. */ + _Safe_iterator& + operator=(_Safe_iterator&&) = default; +#else + /** @brief Copy assignment. */ + _Safe_iterator& + operator=(const _Safe_iterator& __x) + { + _Safe_base::operator=(__x); + return *this; + } +#endif + + // ------ Input iterator requirements ------ + /** + * @brief Iterator preincrement + * @pre iterator is incrementable + */ + _Safe_iterator& + operator++() _GLIBCXX_NOEXCEPT + { + _Safe_base::operator++(); + return *this; + } + + /** + * @brief Iterator postincrement + * @pre iterator is incrementable + */ + _Safe_iterator + operator++(int) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), + _M_message(__msg_bad_inc) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + return _Safe_iterator(this->base()++, this->_M_sequence, + _Attach_single()); + } + + // ------ Bidirectional iterator requirements ------ + /** + * @brief Iterator predecrement + * @pre iterator is decrementable + */ + _Safe_iterator& + operator--() _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(), + _M_message(__msg_bad_dec) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + --this->base(); + return *this; + } + + /** + * @brief Iterator postdecrement + * @pre iterator is decrementable + */ + _Safe_iterator + operator--(int) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(), + _M_message(__msg_bad_dec) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + return _Safe_iterator(this->base()--, this->_M_sequence, + _Attach_single()); + } + + // ------ Utilities ------ + + // Is the iterator decrementable? + bool + _M_decrementable() const + { return !this->_M_singular() && !this->_M_is_begin(); } + }; + + template + class _Safe_iterator<_Iterator, _Sequence, std::random_access_iterator_tag> + : public _Safe_iterator<_Iterator, _Sequence, + std::bidirectional_iterator_tag> + { + typedef _Safe_iterator<_Iterator, _Sequence, + std::bidirectional_iterator_tag> _Safe_base; + typedef typename _Safe_base::_OtherIterator _OtherIterator; + + typedef typename _Safe_base::_Self _Self; + typedef _Safe_iterator<_OtherIterator, _Sequence, + std::random_access_iterator_tag> _OtherSelf; + + typedef typename _Safe_base::_Attach_single _Attach_single; + + _Safe_iterator(_Iterator __i, _Safe_sequence_base* __seq, _Attach_single) + _GLIBCXX_NOEXCEPT + : _Safe_base(__i, __seq, _Attach_single()) + { } + + public: + typedef typename _Safe_base::difference_type difference_type; + typedef typename _Safe_base::reference reference; + + /// @post the iterator is singular and unattached + _Safe_iterator() _GLIBCXX_NOEXCEPT { } + + /** + * @brief Safe iterator construction from an unsafe iterator and + * its sequence. + * + * @pre @p seq is not NULL + * @post this is not singular + */ + _Safe_iterator(_Iterator __i, const _Safe_sequence_base* __seq) + _GLIBCXX_NOEXCEPT + : _Safe_base(__i, __seq) + { } + + /** + * @brief Copy construction. + */ + _Safe_iterator(const _Safe_iterator& __x) _GLIBCXX_NOEXCEPT + : _Safe_base(__x) + { } + +#if __cplusplus >= 201103L + /** @brief Move construction. */ + _Safe_iterator(_Safe_iterator&&) = default; +#endif + + /** + * @brief Converting constructor from a mutable iterator to a + * constant iterator. + */ + template + _Safe_iterator( + const _Safe_iterator<_MutableIterator, _Sequence, + typename __gnu_cxx::__enable_if<_Safe_base::_IsConstant::__value && + std::__are_same<_MutableIterator, _OtherIterator>::__value, + std::random_access_iterator_tag>::__type>& __x) + _GLIBCXX_NOEXCEPT + : _Safe_base(__x) + { } + +#if __cplusplus >= 201103L + /** @brief Copy assignment. */ + _Safe_iterator& + operator=(const _Safe_iterator&) = default; + + /** @brief Move assignment. */ + _Safe_iterator& + operator=(_Safe_iterator&&) = default; +#else + /** @brief Copy assignment. */ + _Safe_iterator& + operator=(const _Safe_iterator& __x) + { + _Safe_base::operator=(__x); + return *this; + } +#endif + + // Is the iterator range [*this, __rhs) valid? + bool + _M_valid_range(const _Safe_iterator& __rhs, + std::pair& __dist) const; + + // ------ Input iterator requirements ------ + /** + * @brief Iterator preincrement + * @pre iterator is incrementable + */ + _Safe_iterator& + operator++() _GLIBCXX_NOEXCEPT + { + _Safe_base::operator++(); + return *this; + } + + /** + * @brief Iterator postincrement + * @pre iterator is incrementable + */ + _Safe_iterator + operator++(int) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), + _M_message(__msg_bad_inc) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + return _Safe_iterator(this->base()++, this->_M_sequence, + _Attach_single()); + } + + // ------ Bidirectional iterator requirements ------ + /** + * @brief Iterator predecrement + * @pre iterator is decrementable + */ + _Safe_iterator& + operator--() _GLIBCXX_NOEXCEPT + { + _Safe_base::operator--(); + return *this; + } + + /** + * @brief Iterator postdecrement + * @pre iterator is decrementable + */ + _Safe_iterator + operator--(int) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_decrementable(), + _M_message(__msg_bad_dec) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + return _Safe_iterator(this->base()--, this->_M_sequence, + _Attach_single()); + } + + // ------ Random access iterator requirements ------ + reference + operator[](difference_type __n) const _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(__n) + && this->_M_can_advance(__n + 1), + _M_message(__msg_iter_subscript_oob) + ._M_iterator(*this)._M_integer(__n)); + return this->base()[__n]; + } + + _Safe_iterator& + operator+=(difference_type __n) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(__n), + _M_message(__msg_advance_oob) + ._M_iterator(*this)._M_integer(__n)); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + this->base() += __n; + return *this; + } + + _Safe_iterator& + operator-=(difference_type __n) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(this->_M_can_advance(-__n), + _M_message(__msg_retreat_oob) + ._M_iterator(*this)._M_integer(__n)); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + this->base() -= __n; + return *this; + } + +#if __cpp_lib_three_way_comparison + friend auto + operator<=>(const _Self& __lhs, const _Self& __rhs) noexcept + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() <=> __rhs.base(); + } + + friend auto + operator<=>(const _Self& __lhs, const _OtherSelf& __rhs) noexcept + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() <=> __rhs.base(); + } +#else + friend bool + operator<(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() < __rhs.base(); + } + + friend bool + operator<(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() < __rhs.base(); + } + + friend bool + operator<=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() <= __rhs.base(); + } + + friend bool + operator<=(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() <= __rhs.base(); + } + + friend bool + operator>(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() > __rhs.base(); + } + + friend bool + operator>(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() > __rhs.base(); + } + + friend bool + operator>=(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() >= __rhs.base(); + } + + friend bool + operator>=(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS(__lhs, __rhs); + return __lhs.base() >= __rhs.base(); + } +#endif // three-way comparison + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + friend difference_type + operator-(const _Self& __lhs, const _OtherSelf& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_DIST_OPERANDS(__lhs, __rhs); + return __lhs.base() - __rhs.base(); + } + + friend difference_type + operator-(const _Self& __lhs, const _Self& __rhs) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY_DIST_OPERANDS(__lhs, __rhs); + return __lhs.base() - __rhs.base(); + } + + friend _Self + operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(__x._M_can_advance(__n), + _M_message(__msg_advance_oob) + ._M_iterator(__x)._M_integer(__n)); + return _Safe_iterator(__x.base() + __n, __x._M_sequence); + } + + friend _Self + operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(__x._M_can_advance(__n), + _M_message(__msg_advance_oob) + ._M_iterator(__x)._M_integer(__n)); + return _Safe_iterator(__n + __x.base(), __x._M_sequence); + } + + friend _Self + operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(__x._M_can_advance(-__n), + _M_message(__msg_retreat_oob) + ._M_iterator(__x)._M_integer(__n)); + return _Safe_iterator(__x.base() - __n, __x._M_sequence); + } + }; + + /** Safe iterators know how to check if they form a valid range. */ + template + inline bool + __valid_range(const _Safe_iterator<_Iterator, _Sequence, + _Category>& __first, + const _Safe_iterator<_Iterator, _Sequence, + _Category>& __last, + typename _Distance_traits<_Iterator>::__type& __dist) + { return __first._M_valid_range(__last, __dist); } + + template + inline bool + __valid_range(const _Safe_iterator<_Iterator, _Sequence, + _Category>& __first, + const _Safe_iterator<_Iterator, _Sequence, + _Category>& __last) + { + typename _Distance_traits<_Iterator>::__type __dist; + return __first._M_valid_range(__last, __dist); + } + + template + inline bool + __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + _Size __n) + { return __it._M_can_advance(__n); } + + template + inline bool + __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, + const std::pair<_Diff, _Distance_precision>& __dist, + int __way) + { return __it._M_can_advance(__dist, __way); } + + template + _Iterator + __base(const _Safe_iterator<_Iterator, _Sequence, + std::random_access_iterator_tag>& __it) + { return __it.base(); } + +#if __cplusplus < 201103L + template + struct _Unsafe_type<_Safe_iterator<_Iterator, _Sequence> > + { typedef _Iterator _Type; }; +#endif + + template + inline _Iterator + __unsafe(const _Safe_iterator<_Iterator, _Sequence>& __it) + { return __it.base(); } + +} // namespace __gnu_debug + +#undef _GLIBCXX_DEBUG_VERIFY_DIST_OPERANDS +#undef _GLIBCXX_DEBUG_VERIFY_REL_OPERANDS +#undef _GLIBCXX_DEBUG_VERIFY_EQ_OPERANDS +#undef _GLIBCXX_DEBUG_VERIFY_OPERANDS + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_iterator.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_iterator.tcc new file mode 100755 index 0000000..05c379c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_iterator.tcc @@ -0,0 +1,551 @@ +// Debugging iterator implementation (out of line) -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_iterator.tcc + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC +#define _GLIBCXX_DEBUG_SAFE_ITERATOR_TCC 1 + +#include + +namespace __gnu_debug +{ + template + typename _Distance_traits<_Iterator>::__type + _Safe_iterator<_Iterator, _Sequence, _Category>:: + _M_get_distance_from_begin() const + { + typedef _Sequence_traits<_Sequence> _SeqTraits; + + // No need to consider before_begin as this function is only used in + // _M_can_advance which won't be used for forward_list iterators. + if (_M_is_begin()) + return std::make_pair(0, __dp_exact); + + if (_M_is_end()) + return _SeqTraits::_S_size(*_M_get_sequence()); + + typename _Distance_traits<_Iterator>::__type __res + = __get_distance(_M_get_sequence()->_M_base().begin(), base()); + + if (__res.second == __dp_equality) + return std::make_pair(1, __dp_sign); + + return __res; + } + + template + typename _Distance_traits<_Iterator>::__type + _Safe_iterator<_Iterator, _Sequence, _Category>:: + _M_get_distance_to_end() const + { + typedef _Sequence_traits<_Sequence> _SeqTraits; + + // No need to consider before_begin as this function is only used in + // _M_can_advance which won't be used for forward_list iterators. + if (_M_is_begin()) + return _SeqTraits::_S_size(*_M_get_sequence()); + + if (_M_is_end()) + return std::make_pair(0, __dp_exact); + + typename _Distance_traits<_Iterator>::__type __res + = __get_distance(base(), _M_get_sequence()->_M_base().end()); + + if (__res.second == __dp_equality) + return std::make_pair(1, __dp_sign); + + return __res; + } + + template + bool + _Safe_iterator<_Iterator, _Sequence, _Category>:: + _M_can_advance(difference_type __n, bool __strict) const + { + if (this->_M_singular()) + return false; + + if (__n == 0) + return true; + + std::pair __dist = __n < 0 + ? _M_get_distance_from_begin() + : _M_get_distance_to_end(); + + if (__n < 0) + __n = -__n; + + return __dist.second > __dp_sign + ? __dist.first >= __n + : !__strict && __dist.first > 0; + } + + template + template + bool + _Safe_iterator<_Iterator, _Sequence, _Category>:: + _M_can_advance(const std::pair<_Diff, _Distance_precision>& __dist, + int __way) const + { + return __dist.second == __dp_exact + ? _M_can_advance(__way * __dist.first) + : _M_can_advance(__way * (__dist.first == 0 + ? 0 + : __dist.first < 0 ? -1 : 1)); + } + + template + typename _Distance_traits<_Iterator>::__type + _Safe_iterator<_Iterator, _Sequence, _Category>:: + _M_get_distance_to(const _Safe_iterator& __rhs) const + { + typedef typename _Distance_traits<_Iterator>::__type _Dist; + typedef _Sequence_traits<_Sequence> _SeqTraits; + + _Dist __base_dist = __get_distance(this->base(), __rhs.base()); + if (__base_dist.second == __dp_exact) + return __base_dist; + + _Dist __seq_dist = _SeqTraits::_S_size(*this->_M_get_sequence()); + if (this->_M_is_before_begin()) + { + if (__rhs._M_is_begin()) + return std::make_pair(1, __dp_exact); + + return __seq_dist.second == __dp_exact + ? std::make_pair(__seq_dist.first + 1, __dp_exact) + : __seq_dist; + } + + if (this->_M_is_begin()) + { + if (__rhs._M_is_before_begin()) + return std::make_pair(-1, __dp_exact); + + if (__rhs._M_is_end()) + return __seq_dist; + + return std::make_pair(__seq_dist.first, + __seq_dist.second == __dp_exact + ? __dp_sign_max_size : __seq_dist.second); + } + + if (this->_M_is_end()) + { + if (__rhs._M_is_before_begin()) + return __seq_dist.second == __dp_exact + ? std::make_pair(-__seq_dist.first - 1, __dp_exact) + : std::make_pair(-__seq_dist.first, __dp_sign); + + if (__rhs._M_is_begin()) + return std::make_pair(-__seq_dist.first, __seq_dist.second); + + return std::make_pair(-__seq_dist.first, + __seq_dist.second == __dp_exact + ? __dp_sign_max_size : __seq_dist.second); + } + + if (__rhs._M_is_before_begin()) + return __seq_dist.second == __dp_exact + ? std::make_pair(__seq_dist.first - 1, __dp_exact) + : std::make_pair(-__seq_dist.first, __dp_sign); + + if (__rhs._M_is_begin()) + return std::make_pair(-__seq_dist.first, + __seq_dist.second == __dp_exact + ? __dp_sign_max_size : __seq_dist.second); + + if (__rhs._M_is_end()) + return std::make_pair(__seq_dist.first, + __seq_dist.second == __dp_exact + ? __dp_sign_max_size : __seq_dist.second); + + return std::make_pair(1, __dp_equality); + } + + template + bool + _Safe_iterator<_Iterator, _Sequence, _Category>:: + _M_valid_range(const _Safe_iterator& __rhs, + std::pair& __dist, + bool __check_dereferenceable) const + { + if (_M_singular() || __rhs._M_singular() || !_M_can_compare(__rhs)) + return false; + + /* Determine iterators order */ + __dist = _M_get_distance_to(__rhs); + if (__dist.second != __dp_equality) + { + // If range is not empty first iterator must be dereferenceable. + return __dist.first == 0 + || (__dist.first > 0 + && (!__check_dereferenceable || _M_dereferenceable())); + } + + // Assume that this is a valid range; we can't check anything else. + return true; + } + + template + bool + _Safe_iterator<_Iterator, _Sequence, std::random_access_iterator_tag>:: + _M_valid_range(const _Safe_iterator& __rhs, + std::pair& __dist) const + { + if (this->_M_singular() || __rhs._M_singular() + || !this->_M_can_compare(__rhs)) + return false; + + /* Determine iterators order */ + __dist = std::make_pair(__rhs.base() - this->base(), __dp_exact); + + // If range is not empty first iterator must be dereferenceable. + return __dist.first == 0 + || (__dist.first > 0 && this->_M_dereferenceable()); + } +} // namespace __gnu_debug + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + template + _Ite + __niter_base(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, + std::random_access_iterator_tag>& __it) + { return __it.base(); } + + template + _OI + __copy_move_a( + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits<_Ite>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment_dist(__result, __dist, 1); + + if (__dist.second > ::__gnu_debug::__dp_equality) + return std::__copy_move_a<_IsMove>(__first.base(), __last.base(), + __result); + + return std::__copy_move_a1<_IsMove>(__first, __last, __result); + } + + template + __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __copy_move_a(_II __first, _II __last, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __result) + { + typename ::__gnu_debug::_Distance_traits<_II>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment_dist(__result, __dist, 1); + + if (__dist.second > ::__gnu_debug::__dp_sign + && __result._M_can_advance(__dist.first, true)) + return ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>( + std::__copy_move_a<_IsMove>(__first, __last, __result.base()), + __result._M_sequence); + + return std::__copy_move_a1<_IsMove>(__first, __last, __result); + } + + template + ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> + __copy_move_a( + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __first, + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __last, + const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>& __result) + { + typename ::__gnu_debug::_Distance_traits<_IIte>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment_dist(__result, __dist, 1); + + if (__dist.second > ::__gnu_debug::__dp_equality) + { + if (__dist.second > ::__gnu_debug::__dp_sign + && __result._M_can_advance(__dist.first, true)) + return ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>( + std::__copy_move_a<_IsMove>(__first.base(), __last.base(), + __result.base()), + __result._M_sequence); + + return std::__copy_move_a<_IsMove>(__first.base(), __last.base(), + __result); + } + + return std::__copy_move_a1<_IsMove>(__first, __last, __result); + } + + template + _OI + __copy_move_backward_a( + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last, + _OI __result) + { + typename ::__gnu_debug::_Distance_traits<_Ite>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment_dist(__result, __dist, -1); + + if (__dist.second > ::__gnu_debug::__dp_equality) + return std::__copy_move_backward_a<_IsMove>( + __first.base(), __last.base(), __result); + + return std::__copy_move_backward_a1<_IsMove>(__first, __last, __result); + } + + template + __gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __copy_move_backward_a(_II __first, _II __last, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __result) + { + typename ::__gnu_debug::_Distance_traits<_II>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment_dist(__result, __dist, -1); + + if (__dist.second > ::__gnu_debug::__dp_sign + && __result._M_can_advance(-__dist.first, true)) + return ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>( + std::__copy_move_backward_a<_IsMove>(__first, __last, + __result.base()), + __result._M_sequence); + + return std::__copy_move_backward_a1<_IsMove>(__first, __last, __result); + } + + template + ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat> + __copy_move_backward_a( + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __first, + const ::__gnu_debug::_Safe_iterator<_IIte, _ISeq, _ICat>& __last, + const ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>& __result) + { + typename ::__gnu_debug::_Distance_traits<_IIte>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + __glibcxx_check_can_increment_dist(__result, __dist, -1); + + if (__dist.second > ::__gnu_debug::__dp_equality) + { + if (__dist.second > ::__gnu_debug::__dp_sign + && __result._M_can_advance(-__dist.first, true)) + return ::__gnu_debug::_Safe_iterator<_OIte, _OSeq, _OCat>( + std::__copy_move_backward_a<_IsMove>(__first.base(), __last.base(), + __result.base()), + __result._M_sequence); + + return std::__copy_move_backward_a<_IsMove>( + __first.base(), __last.base(), __result); + } + + return std::__copy_move_backward_a1<_IsMove>(__first, __last, __result); + } + + template + void + __fill_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, + const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __last, + const _Tp& __value) + { + typename ::__gnu_debug::_Distance_traits<_Ite>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second > ::__gnu_debug::__dp_equality) + std::__fill_a(__first.base(), __last.base(), __value); + + std::__fill_a1(__first, __last, __value); + } + + template + ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat> + __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first, + _Size __n, const _Tp& __value, + std::input_iterator_tag) + { +#if __cplusplus >= 201103L + static_assert(is_integral<_Size>{}, "fill_n must pass integral size"); +#endif + + if (__n <= 0) + return __first; + + __glibcxx_check_can_increment(__first, __n); + if (__first._M_can_advance(__n, true)) + return ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>( + std::__fill_n_a(__first.base(), __n, __value, _Cat()), + __first._M_sequence); + + return std::__fill_n_a1(__first, __n, __value); + } + + template + bool + __equal_aux( + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __first1, + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __last1, + _II2 __first2) + { + typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment_dist(__first2, __dist, 1); + + if (__dist.second > ::__gnu_debug::__dp_equality) + return std::__equal_aux(__first1.base(), __last1.base(), __first2); + + return std::__equal_aux1(__first1, __last1, __first2); + } + + template + bool + __equal_aux(_II1 __first1, _II1 __last1, + const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>& __first2) + { + typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment_dist(__first2, __dist, 1); + + if (__dist.second > ::__gnu_debug::__dp_sign + && __first2._M_can_advance(__dist.first, true)) + return std::__equal_aux(__first1, __last1, __first2.base()); + + return std::__equal_aux1(__first1, __last1, __first2); + } + + template + bool + __equal_aux( + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __first1, + const ::__gnu_debug::_Safe_iterator<_II1, _Seq1, _Cat1>& __last1, + const ::__gnu_debug::_Safe_iterator<_II2, _Seq2, _Cat2>& __first2) + { + typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist; + __glibcxx_check_valid_range2(__first1, __last1, __dist); + __glibcxx_check_can_increment_dist(__first2, __dist, 1); + + if (__dist.second > ::__gnu_debug::__dp_equality) + { + if (__dist.second > ::__gnu_debug::__dp_sign && + __first2._M_can_advance(__dist.first, true)) + return std::__equal_aux(__first1.base(), __last1.base(), + __first2.base()); + return std::__equal_aux(__first1.base(), __last1.base(), __first2); + } + + return __equal_aux1(__first1, __last1, __first2); + } + + template + bool + __lexicographical_compare_aux( + const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __first1, + const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __last1, + _II2 __first2, _II2 __last2) + { + typename ::__gnu_debug::_Distance_traits<_Ite1>::__type __dist1; + __glibcxx_check_valid_range2(__first1, __last1, __dist1); + __glibcxx_check_valid_range(__first2, __last2); + + if (__dist1.second > ::__gnu_debug::__dp_equality) + return std::__lexicographical_compare_aux(__first1.base(), + __last1.base(), + __first2, __last2); + return std::__lexicographical_compare_aux1(__first1, __last1, + __first2, __last2); + } + + template + bool + __lexicographical_compare_aux( + _II1 __first1, _II1 __last1, + const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __first2, + const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __last2) + { + __glibcxx_check_valid_range(__first1, __last1); + typename ::__gnu_debug::_Distance_traits<_II1>::__type __dist2; + __glibcxx_check_valid_range2(__first2, __last2, __dist2); + + if (__dist2.second > ::__gnu_debug::__dp_equality) + return std::__lexicographical_compare_aux(__first1, __last1, + __first2.base(), + __last2.base()); + return std::__lexicographical_compare_aux1(__first1, __last1, + __first2, __last2); + } + + template + bool + __lexicographical_compare_aux( + const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __first1, + const ::__gnu_debug::_Safe_iterator<_Ite1, _Seq1, _Cat1>& __last1, + const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __first2, + const ::__gnu_debug::_Safe_iterator<_Ite2, _Seq2, _Cat2>& __last2) + { + typename ::__gnu_debug::_Distance_traits<_Ite1>::__type __dist1; + __glibcxx_check_valid_range2(__first1, __last1, __dist1); + typename ::__gnu_debug::_Distance_traits<_Ite2>::__type __dist2; + __glibcxx_check_valid_range2(__first2, __last2, __dist2); + + if (__dist1.second > ::__gnu_debug::__dp_equality) + { + if (__dist2.second > ::__gnu_debug::__dp_equality) + return std::__lexicographical_compare_aux(__first1.base(), + __last1.base(), + __first2.base(), + __last2.base()); + return std::__lexicographical_compare_aux(__first1.base(), + __last1.base(), + __first2, __last2); + } + + if (__dist2.second > ::__gnu_debug::__dp_equality) + return std::__lexicographical_compare_aux(__first1, __last1, + __first2.base(), + __last2.base()); + return std::__lexicographical_compare_aux1(__first1, __last1, + __first2, __last2); + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_local_iterator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_local_iterator.h new file mode 100755 index 0000000..31c48e6 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_local_iterator.h @@ -0,0 +1,440 @@ +// Safe iterator implementation -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_local_iterator.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H +#define _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_H 1 + +#include + +#define _GLIBCXX_DEBUG_VERIFY_OPERANDS(_Lhs, _Rhs) \ + _GLIBCXX_DEBUG_VERIFY(!_Lhs._M_singular() && !_Rhs._M_singular() \ + || (_Lhs.base() == _Iterator{} \ + && _Rhs.base() == _Iterator{}), \ + _M_message(__msg_iter_compare_bad) \ + ._M_iterator(_Lhs, "lhs") \ + ._M_iterator(_Rhs, "rhs")); \ + _GLIBCXX_DEBUG_VERIFY(_Lhs._M_can_compare(_Rhs), \ + _M_message(__msg_compare_different) \ + ._M_iterator(_Lhs, "lhs") \ + ._M_iterator(_Rhs, "rhs")); \ + _GLIBCXX_DEBUG_VERIFY(_Lhs._M_in_same_bucket(_Rhs), \ + _M_message(__msg_local_iter_compare_bad) \ + ._M_iterator(_Lhs, "lhs") \ + ._M_iterator(_Rhs, "rhs")) + +namespace __gnu_debug +{ + /** \brief Safe iterator wrapper. + * + * The class template %_Safe_local_iterator is a wrapper around an + * iterator that tracks the iterator's movement among sequences and + * checks that operations performed on the "safe" iterator are + * legal. In additional to the basic iterator operations (which are + * validated, and then passed to the underlying iterator), + * %_Safe_local_iterator has member functions for iterator invalidation, + * attaching/detaching the iterator from sequences, and querying + * the iterator's state. + */ + template + class _Safe_local_iterator + : private _Iterator + , public _Safe_local_iterator_base + { + typedef _Iterator _Iter_base; + typedef _Safe_local_iterator_base _Safe_base; + + typedef typename _Sequence::size_type size_type; + + typedef std::iterator_traits<_Iterator> _Traits; + + typedef std::__are_same< + typename _Sequence::_Base::const_local_iterator, + _Iterator> _IsConstant; + + typedef typename __gnu_cxx::__conditional_type<_IsConstant::__value, + typename _Sequence::_Base::local_iterator, + typename _Sequence::_Base::const_local_iterator>::__type + _OtherIterator; + + typedef _Safe_local_iterator _Self; + typedef _Safe_local_iterator<_OtherIterator, _Sequence> _OtherSelf; + + struct _Attach_single + { }; + + _Safe_local_iterator(_Iterator __i, _Safe_sequence_base* __cont, + _Attach_single) noexcept + : _Iter_base(__i) + { _M_attach_single(__cont); } + + public: + typedef _Iterator iterator_type; + typedef typename _Traits::iterator_category iterator_category; + typedef typename _Traits::value_type value_type; + typedef typename _Traits::difference_type difference_type; + typedef typename _Traits::reference reference; + typedef typename _Traits::pointer pointer; + + /// @post the iterator is singular and unattached + _Safe_local_iterator() noexcept : _Iter_base() { } + + /** + * @brief Safe iterator construction from an unsafe iterator and + * its sequence. + * + * @pre @p seq is not NULL + * @post this is not singular + */ + _Safe_local_iterator(_Iterator __i, const _Safe_sequence_base* __cont) + : _Iter_base(__i), _Safe_base(__cont, _S_constant()) + { + _GLIBCXX_DEBUG_VERIFY(!this->_M_singular(), + _M_message(__msg_init_singular) + ._M_iterator(*this, "this")); + } + + /** + * @brief Copy construction. + */ + _Safe_local_iterator(const _Safe_local_iterator& __x) noexcept + : _Iter_base(__x.base()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_init_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + _M_attach(__x._M_sequence); + } + + /** + * @brief Move construction. + * @post __x is singular and unattached + */ + _Safe_local_iterator(_Safe_local_iterator&& __x) noexcept + : _Iter_base() + { + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_init_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + auto __cont = __x._M_sequence; + __x._M_detach(); + std::swap(base(), __x.base()); + _M_attach(__cont); + } + + /** + * @brief Converting constructor from a mutable iterator to a + * constant iterator. + */ + template + _Safe_local_iterator( + const _Safe_local_iterator<_MutableIterator, + typename __gnu_cxx::__enable_if<_IsConstant::__value && + std::__are_same<_MutableIterator, _OtherIterator>::__value, + _Sequence>::__type>& __x) noexcept + : _Iter_base(__x.base()) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _MutableIterator(), + _M_message(__msg_init_const_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + _M_attach(__x._M_sequence); + } + + /** + * @brief Copy assignment. + */ + _Safe_local_iterator& + operator=(const _Safe_local_iterator& __x) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + + if (this->_M_sequence && this->_M_sequence == __x._M_sequence) + { + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + base() = __x.base(); + _M_version = __x._M_sequence->_M_version; + } + else + { + _M_detach(); + base() = __x.base(); + _M_attach(__x._M_sequence); + } + + return *this; + } + + /** + * @brief Move assignment. + * @post __x is singular and unattached + */ + _Safe_local_iterator& + operator=(_Safe_local_iterator&& __x) noexcept + { + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), + _M_message(__msg_copy_singular) + ._M_iterator(*this, "this") + ._M_iterator(__x, "other")); + + if (std::__addressof(__x) == this) + return *this; + + if (this->_M_sequence && this->_M_sequence == __x._M_sequence) + { + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + base() = __x.base(); + _M_version = __x._M_sequence->_M_version; + } + else + { + _M_detach(); + base() = __x.base(); + _M_attach(__x._M_sequence); + } + + __x._M_detach(); + __x.base() = _Iterator(); + return *this; + } + + /** + * @brief Iterator dereference. + * @pre iterator is dereferenceable + */ + reference + operator*() const + { + _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), + _M_message(__msg_bad_deref) + ._M_iterator(*this, "this")); + return *base(); + } + + /** + * @brief Iterator dereference. + * @pre iterator is dereferenceable + */ + pointer + operator->() const + { + _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), + _M_message(__msg_bad_deref) + ._M_iterator(*this, "this")); + return base().operator->(); + } + + // ------ Input iterator requirements ------ + /** + * @brief Iterator preincrement + * @pre iterator is incrementable + */ + _Safe_local_iterator& + operator++() + { + _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), + _M_message(__msg_bad_inc) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + ++base(); + return *this; + } + + /** + * @brief Iterator postincrement + * @pre iterator is incrementable + */ + _Safe_local_iterator + operator++(int) + { + _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), + _M_message(__msg_bad_inc) + ._M_iterator(*this, "this")); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); + return _Safe_local_iterator(base()++, this->_M_sequence, + _Attach_single()); + } + + // ------ Utilities ------ + + /// Determine if this is a constant iterator. + static constexpr bool + _S_constant() + { return _IsConstant::__value; } + + /** + * @brief Return the underlying iterator + */ + _Iterator& + base() noexcept { return *this; } + + const _Iterator& + base() const noexcept { return *this; } + + /** + * @brief Return the bucket + */ + size_type + bucket() const { return base()._M_get_bucket(); } + + /** + * @brief Conversion to underlying non-debug iterator to allow + * better interaction with non-debug containers. + */ + operator _Iterator() const { return *this; } + + /** Attach iterator to the given sequence. */ + void + _M_attach(_Safe_sequence_base* __seq) + { _Safe_base::_M_attach(__seq, _S_constant()); } + + /** Likewise, but not thread-safe. */ + void + _M_attach_single(_Safe_sequence_base* __seq) + { _Safe_base::_M_attach_single(__seq, _S_constant()); } + + /// Is the iterator dereferenceable? + bool + _M_dereferenceable() const + { return !this->_M_singular() && !_M_is_end(); } + + /// Is the iterator incrementable? + bool + _M_incrementable() const + { return !this->_M_singular() && !_M_is_end(); } + + // Is the iterator range [*this, __rhs) valid? + bool + _M_valid_range(const _Safe_local_iterator& __rhs, + std::pair& __dist_info) const; + + // Get distance to __rhs. + typename _Distance_traits<_Iterator>::__type + _M_get_distance_to(const _Safe_local_iterator& __rhs) const; + + // The sequence this iterator references. + typename __gnu_cxx::__conditional_type< + _IsConstant::__value, const _Sequence*, _Sequence*>::__type + _M_get_sequence() const + { return static_cast<_Sequence*>(_M_sequence); } + + /// Is this iterator equal to the sequence's begin(bucket) iterator? + bool _M_is_begin() const + { return base() == _M_get_sequence()->_M_base().begin(bucket()); } + + /// Is this iterator equal to the sequence's end(bucket) iterator? + bool _M_is_end() const + { return base() == _M_get_sequence()->_M_base().end(bucket()); } + + /// Is this iterator part of the same bucket as the other one? + template + bool + _M_in_same_bucket(const _Safe_local_iterator<_Other, + _Sequence>& __other) const + { return bucket() == __other.bucket(); } + + friend inline bool + operator==(const _Self& __lhs, const _OtherSelf& __rhs) noexcept + { + _GLIBCXX_DEBUG_VERIFY_OPERANDS(__lhs, __rhs); + return __lhs.base() == __rhs.base(); + } + + friend inline bool + operator==(const _Self& __lhs, const _Self& __rhs) noexcept + { + _GLIBCXX_DEBUG_VERIFY_OPERANDS(__lhs, __rhs); + return __lhs.base() == __rhs.base(); + } + + friend inline bool + operator!=(const _Self& __lhs, const _OtherSelf& __rhs) noexcept + { + _GLIBCXX_DEBUG_VERIFY_OPERANDS(__lhs, __rhs); + return __lhs.base() != __rhs.base(); + } + + friend inline bool + operator!=(const _Self& __lhs, const _Self& __rhs) noexcept + { + _GLIBCXX_DEBUG_VERIFY_OPERANDS(__lhs, __rhs); + return __lhs.base() != __rhs.base(); + } + }; + + /** Safe local iterators know how to check if they form a valid range. */ + template + inline bool + __valid_range(const _Safe_local_iterator<_Iterator, _Sequence>& __first, + const _Safe_local_iterator<_Iterator, _Sequence>& __last, + typename _Distance_traits<_Iterator>::__type& __dist_info) + { return __first._M_valid_range(__last, __dist_info); } + + template + inline bool + __valid_range(const _Safe_local_iterator<_Iterator, _Sequence>& __first, + const _Safe_local_iterator<_Iterator, _Sequence>& __last) + { + typename _Distance_traits<_Iterator>::__type __dist_info; + return __first._M_valid_range(__last, __dist_info); + } + +#if __cplusplus < 201103L + template + struct _Unsafe_type<_Safe_local_iterator<_Iterator, _Sequence> > + { typedef _Iterator _Type; }; +#endif + + template + inline _Iterator + __unsafe(const _Safe_local_iterator<_Iterator, _Sequence>& __it) + { return __it.base(); } + +} // namespace __gnu_debug + +#undef _GLIBCXX_DEBUG_VERIFY_OPERANDS + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_local_iterator.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_local_iterator.tcc new file mode 100755 index 0000000..db9e4b5 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_local_iterator.tcc @@ -0,0 +1,107 @@ +// Debugging iterator implementation (out of line) -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_local_iterator.tcc + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_TCC +#define _GLIBCXX_DEBUG_SAFE_LOCAL_ITERATOR_TCC 1 + +namespace __gnu_debug +{ + template + typename _Distance_traits<_Iterator>::__type + _Safe_local_iterator<_Iterator, _Sequence>:: + _M_get_distance_to(const _Safe_local_iterator& __rhs) const + { + if (base() == __rhs.base()) + return { 0, __dp_exact }; + + if (_M_is_begin()) + { + if (__rhs._M_is_end()) + return + { + _M_get_sequence()->bucket_size(bucket()), + __dp_exact + }; + + return { 1, __dp_sign }; + } + + if (_M_is_end()) + { + if (__rhs._M_is_begin()) + return + { + -_M_get_sequence()->bucket_size(bucket()), + __dp_exact + }; + + return { -1, __dp_sign }; + } + + if (__rhs._M_is_begin()) + return { -1, __dp_sign }; + + if (__rhs._M_is_end()) + return { 1, __dp_sign }; + + return { 1, __dp_equality }; + } + + template + bool + _Safe_local_iterator<_Iterator, _Sequence>:: + _M_valid_range(const _Safe_local_iterator& __rhs, + std::pair& __dist) const + { + if (!_M_can_compare(__rhs)) + return false; + + if (bucket() != __rhs.bucket()) + return false; + + /* Determine if we can order the iterators without the help of + the container */ + __dist = _M_get_distance_to(__rhs); + switch (__dist.second) + { + case __dp_equality: + if (__dist.first == 0) + return true; + break; + + case __dp_sign: + case __dp_exact: + return __dist.first >= 0; + } + + // Assume that this is a valid range; we can't check anything else + return true; + } +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_sequence.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_sequence.h new file mode 100755 index 0000000..afdf354 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_sequence.h @@ -0,0 +1,150 @@ +// Safe sequence implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_sequence.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_H +#define _GLIBCXX_DEBUG_SAFE_SEQUENCE_H 1 + +#include +#include +#include +#include + +namespace __gnu_debug +{ + /** A simple function object that returns true if the passed-in + * value is not equal to the stored value. It saves typing over + * using both bind1st and not_equal. + */ + template + class _Not_equal_to + { + _Type __value; + + public: + explicit _Not_equal_to(const _Type& __v) : __value(__v) { } + + bool + operator()(const _Type& __x) const + { return __value != __x; } + }; + + /** A simple function object that returns true if the passed-in + * value is equal to the stored value. */ + template + class _Equal_to + { + _Type __value; + + public: + explicit _Equal_to(const _Type& __v) : __value(__v) { } + + bool + operator()(const _Type& __x) const + { return __value == __x; } + }; + + /** A function object that returns true when the given random access + iterator is at least @c n steps away from the given iterator. */ + template + class _After_nth_from + { + typedef typename std::iterator_traits<_Iterator>::difference_type + difference_type; + + _Iterator _M_base; + difference_type _M_n; + + public: + _After_nth_from(const difference_type& __n, const _Iterator& __base) + : _M_base(__base), _M_n(__n) { } + + bool + operator()(const _Iterator& __x) const + { return __x - _M_base >= _M_n; } + }; + + /** + * @brief Base class for constructing a @a safe sequence type that + * tracks iterators that reference it. + * + * The class template %_Safe_sequence simplifies the construction of + * @a safe sequences that track the iterators that reference the + * sequence, so that the iterators are notified of changes in the + * sequence that may affect their operation, e.g., if the container + * invalidates its iterators or is destructed. This class template + * may only be used by deriving from it and passing the name of the + * derived class as its template parameter via the curiously + * recurring template pattern. The derived class must have @c + * iterator and @c const_iterator types that are instantiations of + * class template _Safe_iterator for this sequence. Iterators will + * then be tracked automatically. + */ + template + class _Safe_sequence : public _Safe_sequence_base + { + public: + /** Invalidates all iterators @c x that reference this sequence, + are not singular, and for which @c __pred(x) returns @c + true. @c __pred will be invoked with the normal iterators nested + in the safe ones. */ + template + void + _M_invalidate_if(_Predicate __pred); + + /** Transfers all iterators @c x that reference @c from sequence, + are not singular, and for which @c __pred(x) returns @c + true. @c __pred will be invoked with the normal iterators nested + in the safe ones. */ + template + void + _M_transfer_from_if(_Safe_sequence& __from, _Predicate __pred); + }; + + /// Like _Safe_sequence but with a special _M_invalidate_all implementation + /// not invalidating past-the-end iterators. Used by node based sequence. + template + class _Safe_node_sequence + : public _Safe_sequence<_Sequence> + { + protected: + void + _M_invalidate_all() + { + typedef typename _Sequence::const_iterator _Const_iterator; + typedef typename _Const_iterator::iterator_type _Base_const_iterator; + typedef __gnu_debug::_Not_equal_to<_Base_const_iterator> _Not_equal; + const _Sequence& __seq = *static_cast<_Sequence*>(this); + this->_M_invalidate_if(_Not_equal(__seq._M_base().end())); + } + }; + +} // namespace __gnu_debug + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_sequence.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_sequence.tcc new file mode 100755 index 0000000..353887c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_sequence.tcc @@ -0,0 +1,156 @@ +// Safe sequence implementation -*- C++ -*- + +// Copyright (C) 2010-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_sequence.tcc + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_SEQUENCE_TCC +#define _GLIBCXX_DEBUG_SAFE_SEQUENCE_TCC 1 + +namespace __gnu_debug +{ + template + template + void + _Safe_sequence<_Sequence>:: + _M_invalidate_if(_Predicate __pred) + { + typedef typename _Sequence::iterator iterator; + typedef typename _Sequence::const_iterator const_iterator; + + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = _M_iterators; __iter;) + { + iterator* __victim = static_cast(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_invalidate(); + } + } + + for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;) + { + const_iterator* __victim = static_cast(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_invalidate(); + } + } + } + + template + template + void + _Safe_sequence<_Sequence>:: + _M_transfer_from_if(_Safe_sequence& __from, _Predicate __pred) + { + if (this == std::__addressof(__from)) + return; + + typedef typename _Sequence::iterator iterator; + typedef typename _Sequence::const_iterator const_iterator; + + _Safe_iterator_base* __transfered_iterators = 0; + _Safe_iterator_base* __transfered_const_iterators = 0; + _Safe_iterator_base* __last_iterator = 0; + _Safe_iterator_base* __last_const_iterator = 0; + { + // We lock __from first and detach iterator(s) to transfer + __gnu_cxx::__scoped_lock sentry(__from._M_get_mutex()); + + for (_Safe_iterator_base* __iter = __from._M_iterators; __iter;) + { + _Safe_iterator_base* __victim_base = __iter; + iterator* __victim = static_cast(__victim_base); + __iter = __iter->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_detach_single(); + if (__transfered_iterators) + { + __victim_base->_M_next = __transfered_iterators; + __transfered_iterators->_M_prior = __victim_base; + } + else + __last_iterator = __victim_base; + __victim_base->_M_sequence = this; + __victim_base->_M_version = this->_M_version; + __transfered_iterators = __victim_base; + } + } + + for (_Safe_iterator_base* __iter2 = __from._M_const_iterators; + __iter2;) + { + _Safe_iterator_base* __victim_base = __iter2; + const_iterator* __victim = + static_cast(__victim_base); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_detach_single(); + if (__transfered_const_iterators) + { + __victim_base->_M_next = __transfered_const_iterators; + __transfered_const_iterators->_M_prior = __victim_base; + } + else + __last_const_iterator = __victim; + __victim_base->_M_sequence = this; + __victim_base->_M_version = this->_M_version; + __transfered_const_iterators = __victim_base; + } + } + } + + // Now we can lock *this and add the transfered iterators if any + if (__last_iterator || __last_const_iterator) + { + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + if (__last_iterator) + { + if (this->_M_iterators) + { + this->_M_iterators->_M_prior = __last_iterator; + __last_iterator->_M_next = this->_M_iterators; + } + this->_M_iterators = __transfered_iterators; + } + if (__last_const_iterator) + { + if (this->_M_const_iterators) + { + this->_M_const_iterators->_M_prior = __last_const_iterator; + __last_const_iterator->_M_next = this->_M_const_iterators; + } + this->_M_const_iterators = __transfered_const_iterators; + } + } + } +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_base.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_base.h new file mode 100755 index 0000000..93b3418 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_base.h @@ -0,0 +1,185 @@ +// Safe container/iterator base implementation -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_unordered_base.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_BASE_H +#define _GLIBCXX_DEBUG_SAFE_UNORDERED_BASE_H 1 + +#include + +namespace __gnu_debug +{ + class _Safe_unordered_container_base; + + /** \brief Basic functionality for a @a safe iterator. + * + * The %_Safe_local_iterator_base base class implements the functionality + * of a safe local iterator that is not specific to a particular iterator + * type. It contains a pointer back to the container it references + * along with iterator version information and pointers to form a + * doubly-linked list of local iterators referenced by the container. + * + * This class must not perform any operations that can throw an + * exception, or the exception guarantees of derived iterators will + * be broken. + */ + class _Safe_local_iterator_base : public _Safe_iterator_base + { + protected: + /** Initializes the iterator and makes it singular. */ + _Safe_local_iterator_base() + { } + + /** Initialize the iterator to reference the container pointed to + * by @p __seq. @p __constant is true when we are initializing a + * constant local iterator, and false if it is a mutable local iterator. + * Note that @p __seq may be NULL, in which case the iterator will be + * singular. Otherwise, the iterator will reference @p __seq and + * be nonsingular. + */ + _Safe_local_iterator_base(const _Safe_sequence_base* __seq, bool __constant) + { this->_M_attach(const_cast<_Safe_sequence_base*>(__seq), __constant); } + + /** Initializes the iterator to reference the same container that + @p __x does. @p __constant is true if this is a constant + iterator, and false if it is mutable. */ + _Safe_local_iterator_base(const _Safe_local_iterator_base& __x, + bool __constant) + { this->_M_attach(__x._M_sequence, __constant); } + + ~_Safe_local_iterator_base() { this->_M_detach(); } + + _Safe_unordered_container_base* + _M_get_container() const noexcept; + + /** Attaches this iterator to the given container, detaching it + * from whatever container it was attached to originally. If the + * new container is the NULL pointer, the iterator is left + * unattached. + */ + void + _M_attach(_Safe_sequence_base* __seq, bool __constant); + + /** Likewise, but not thread-safe. */ + void + _M_attach_single(_Safe_sequence_base* __seq, bool __constant) throw (); + + /** Detach the iterator for whatever container it is attached to, + * if any. + */ + void + _M_detach(); + + /** Likewise, but not thread-safe. */ + void + _M_detach_single() throw (); + }; + + /** + * @brief Base class that supports tracking of local iterators that + * reference an unordered container. + * + * The %_Safe_unordered_container_base class provides basic support for + * tracking iterators into an unordered container. Containers that track + * iterators must derived from %_Safe_unordered_container_base publicly, so + * that safe iterators (which inherit _Safe_iterator_base) can + * attach to them. This class contains four linked lists of + * iterators, one for constant iterators, one for mutable + * iterators, one for constant local iterators, one for mutable local + * iterators and a version number that allows very fast + * invalidation of all iterators that reference the container. + * + * This class must ensure that no operation on it may throw an + * exception, otherwise @a safe containers may fail to provide the + * exception-safety guarantees required by the C++ standard. + */ + class _Safe_unordered_container_base : public _Safe_sequence_base + { + friend class _Safe_local_iterator_base; + typedef _Safe_sequence_base _Base; + + public: + /// The list of mutable local iterators that reference this container + _Safe_iterator_base* _M_local_iterators; + + /// The list of constant local iterators that reference this container + _Safe_iterator_base* _M_const_local_iterators; + + protected: + // Initialize with a version number of 1 and no iterators + _Safe_unordered_container_base() noexcept + : _M_local_iterators(nullptr), _M_const_local_iterators(nullptr) + { } + + // Copy constructor does not copy iterators. + _Safe_unordered_container_base(const _Safe_unordered_container_base&) + noexcept + : _Safe_unordered_container_base() { } + + // When moved unordered containers iterators are swapped. + _Safe_unordered_container_base(_Safe_unordered_container_base&& __x) + noexcept + : _Safe_unordered_container_base() + { this->_M_swap(__x); } + + /** Notify all iterators that reference this container that the + container is being destroyed. */ + ~_Safe_unordered_container_base() noexcept + { this->_M_detach_all(); } + + /** Detach all iterators, leaving them singular. */ + void + _M_detach_all(); + + /** Swap this container with the given container. This operation + * also swaps ownership of the iterators, so that when the + * operation is complete all iterators that originally referenced + * one container now reference the other container. + */ + void + _M_swap(_Safe_unordered_container_base& __x) noexcept; + + private: + /** Attach an iterator to this container. */ + void + _M_attach_local(_Safe_iterator_base* __it, bool __constant); + + /** Likewise but not thread safe. */ + void + _M_attach_local_single(_Safe_iterator_base* __it, bool __constant) throw (); + + /** Detach an iterator from this container */ + void + _M_detach_local(_Safe_iterator_base* __it); + + /** Likewise but not thread safe. */ + void + _M_detach_local_single(_Safe_iterator_base* __it) throw (); + }; +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_container.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_container.h new file mode 100755 index 0000000..aae1e2d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_container.h @@ -0,0 +1,104 @@ +// Safe container implementation -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_unordered_container.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H +#define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_H 1 + +#include +#include +#include +#include + +namespace __gnu_debug +{ + /** + * @brief Base class for constructing a @a safe unordered container type + * that tracks iterators that reference it. + * + * The class template %_Safe_unordered_container simplifies the + * construction of @a safe unordered containers that track the iterators + * that reference the container, so that the iterators are notified of + * changes in the container that may affect their operation, e.g., if + * the container invalidates its iterators or is destructed. This class + * template may only be used by deriving from it and passing the name + * of the derived class as its template parameter via the curiously + * recurring template pattern. The derived class must have @c + * iterator and @c const_iterator types that are instantiations of + * class template _Safe_iterator for this container and @c local_iterator + * and @c const_local_iterator types that are instantiations of class + * template _Safe_local_iterator for this container. Iterators will + * then be tracked automatically. + */ + template + class _Safe_unordered_container : public _Safe_unordered_container_base + { + private: + _Container& + _M_cont() noexcept + { return *static_cast<_Container*>(this); } + + protected: + void + _M_invalidate_locals() + { + auto __local_end = _M_cont()._M_base().cend(0); + this->_M_invalidate_local_if( + [__local_end](__decltype(__local_end) __it) + { return __it != __local_end; }); + } + + void + _M_invalidate_all() + { + auto __end = _M_cont()._M_base().cend(); + this->_M_invalidate_if([__end](__decltype(__end) __it) + { return __it != __end; }); + _M_invalidate_locals(); + } + + /** Invalidates all iterators @c x that reference this container, + are not singular, and for which @c __pred(x) returns @c + true. @c __pred will be invoked with the normal iterators nested + in the safe ones. */ + template + void + _M_invalidate_if(_Predicate __pred); + + /** Invalidates all local iterators @c x that reference this container, + are not singular, and for which @c __pred(x) returns @c + true. @c __pred will be invoked with the normal local iterators + nested in the safe ones. */ + template + void + _M_invalidate_local_if(_Predicate __pred); + }; +} // namespace __gnu_debug + +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_container.tcc b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_container.tcc new file mode 100755 index 0000000..df2a41d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/safe_unordered_container.tcc @@ -0,0 +1,100 @@ +// Safe container implementation -*- C++ -*- + +// Copyright (C) 2011-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/safe_unordered_container.tcc + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_TCC +#define _GLIBCXX_DEBUG_SAFE_UNORDERED_CONTAINER_TCC 1 + +namespace __gnu_debug +{ + template + template + void + _Safe_unordered_container<_Container>:: + _M_invalidate_if(_Predicate __pred) + { + typedef typename _Container::iterator iterator; + typedef typename _Container::const_iterator const_iterator; + + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = _M_iterators; __iter;) + { + iterator* __victim = static_cast(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_invalidate(); + } + } + + for (_Safe_iterator_base* __iter2 = _M_const_iterators; __iter2;) + { + const_iterator* __victim = static_cast(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_invalidate(); + } + } + } + + + template + template + void + _Safe_unordered_container<_Container>:: + _M_invalidate_local_if(_Predicate __pred) + { + typedef typename _Container::local_iterator local_iterator; + typedef typename _Container::const_local_iterator const_local_iterator; + + __gnu_cxx::__scoped_lock sentry(this->_M_get_mutex()); + for (_Safe_iterator_base* __iter = _M_local_iterators; __iter;) + { + local_iterator* __victim = static_cast(__iter); + __iter = __iter->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_invalidate(); + } + } + + for (_Safe_iterator_base* __iter2 = _M_const_local_iterators; __iter2;) + { + const_local_iterator* __victim = + static_cast(__iter2); + __iter2 = __iter2->_M_next; + if (!__victim->_M_singular() && __pred(__victim->base())) + { + __victim->_M_invalidate(); + } + } + } + +} // namespace __gnu_debug + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/set b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/set new file mode 100755 index 0000000..76f3b44 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/set @@ -0,0 +1,44 @@ +// Debugging set/multiset implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/set + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SET +#define _GLIBCXX_DEBUG_SET 1 + +#pragma GCC system_header + +#include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template class set; + template class multiset; +} } // namespace std::__debug + +#include +#include +#include + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/set.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/set.h new file mode 100755 index 0000000..c579de7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/set.h @@ -0,0 +1,664 @@ +// Debugging set implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/set.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_SET_H +#define _GLIBCXX_DEBUG_SET_H 1 + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::set with safety/checking/debug instrumentation. + template, + typename _Allocator = std::allocator<_Key> > + class set + : public __gnu_debug::_Safe_container< + set<_Key, _Compare, _Allocator>, _Allocator, + __gnu_debug::_Safe_node_sequence>, + public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator> + { + typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + set, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; + + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates set(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + // types: + typedef _Key key_type; + typedef _Key value_type; + typedef _Compare key_compare; + typedef _Compare value_compare; + typedef _Allocator allocator_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator<_Base_iterator, set> + iterator; + typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, set> + const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.3.3.1 construct/copy/destroy: + +#if __cplusplus < 201103L + set() : _Base() { } + + set(const set& __x) + : _Base(__x) { } + + ~set() { } +#else + set() = default; + set(const set&) = default; + set(set&&) = default; + + set(initializer_list __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __comp, __a) { } + + explicit + set(const allocator_type& __a) + : _Base(__a) { } + + set(const set& __x, const allocator_type& __a) + : _Base(__x, __a) { } + + set(set&& __x, const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__x._M_base()), __a)) ) + : _Safe(std::move(__x._M_safe()), __a), + _Base(std::move(__x._M_base()), __a) { } + + set(initializer_list __l, const allocator_type& __a) + : _Base(__l, __a) { } + + template + set(_InputIterator __first, _InputIterator __last, + const allocator_type& __a) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) { } + + ~set() = default; +#endif + + explicit set(const _Compare& __comp, + const _Allocator& __a = _Allocator()) + : _Base(__comp, __a) { } + + template + set(_InputIterator __first, _InputIterator __last, + const _Compare& __comp = _Compare(), + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), + __comp, __a) { } + + set(_Base_ref __x) + : _Base(__x._M_ref) { } + +#if __cplusplus < 201103L + set& + operator=(const set& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + return *this; + } +#else + set& + operator=(const set&) = default; + + set& + operator=(set&&) = default; + + set& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } +#endif + + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // capacity: + using _Base::empty; + using _Base::size; + using _Base::max_size; + + // modifiers: +#if __cplusplus >= 201103L + template + std::pair + emplace(_Args&&... __args) + { + auto __res = _Base::emplace(std::forward<_Args>(__args)...); + return { { __res.first, this }, __res.second }; + } + + template + iterator + emplace_hint(const_iterator __pos, _Args&&... __args) + { + __glibcxx_check_insert(__pos); + return + { + _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...), + this + }; + } +#endif + + std::pair + insert(const value_type& __x) + { + std::pair<_Base_iterator, bool> __res = _Base::insert(__x); + return std::pair(iterator(__res.first, this), + __res.second); + } + +#if __cplusplus >= 201103L + std::pair + insert(value_type&& __x) + { + auto __res = _Base::insert(std::move(__x)); + return { { __res.first, this }, __res.second }; + } +#endif + + iterator + insert(const_iterator __position, const value_type& __x) + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __x), this); + } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, value_type&& __x) + { + __glibcxx_check_insert(__position); + return { _Base::insert(__position.base(), std::move(__x)), this }; + } +#endif + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + } + +#if __cplusplus >= 201103L + void + insert(initializer_list __l) + { _Base::insert(__l); } +#endif + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + using insert_return_type = _Node_insert_return; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return _Base::extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = find(__key); + if (__position != end()) + return extract(__position); + return {}; + } + + insert_return_type + insert(node_type&& __nh) + { + auto __ret = _Base::insert(std::move(__nh)); + iterator __pos = iterator(__ret.position, this); + return { __pos, __ret.inserted, std::move(__ret.node) }; + } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + +#if __cplusplus >= 201103L + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + return { _Base::erase(__position.base()), this }; + } +#else + void + erase(iterator __position) + { + __glibcxx_check_erase(__position); + this->_M_invalidate_if(_Equal(__position.base())); + _Base::erase(__position.base()); + } +#endif + + size_type + erase(const key_type& __x) + { + _Base_iterator __victim = _Base::find(__x); + if (__victim == _Base::end()) + return 0; + else + { + this->_M_invalidate_if(_Equal(__victim)); + _Base::erase(__victim); + return 1; + } + } + +#if __cplusplus >= 201103L + _GLIBCXX_ABI_TAG_CXX11 + iterator + erase(const_iterator __first, const_iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_const_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + + return { _Base::erase(__first.base(), __last.base()), this }; + } +#else + void + erase(iterator __first, iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + for (_Base_iterator __victim = __first.base(); + __victim != __last.base(); ++__victim) + { + _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + this->_M_invalidate_if(_Equal(__victim)); + } + _Base::erase(__first.base(), __last.base()); + } +#endif + + void + swap(set& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + this->_M_invalidate_all(); + _Base::clear(); + } + + // observers: + using _Base::key_comp; + using _Base::value_comp; + + // set operations: + iterator + find(const key_type& __x) + { return iterator(_Base::find(__x), this); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + const_iterator + find(const key_type& __x) const + { return const_iterator(_Base::find(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + find(const _Kt& __x) + { return { _Base::find(__x), this }; } + + template::type> + const_iterator + find(const _Kt& __x) const + { return { _Base::find(__x), this }; } +#endif + + using _Base::count; + + iterator + lower_bound(const key_type& __x) + { return iterator(_Base::lower_bound(__x), this); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + const_iterator + lower_bound(const key_type& __x) const + { return const_iterator(_Base::lower_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + lower_bound(const _Kt& __x) + { return { _Base::lower_bound(__x), this }; } + + template::type> + const_iterator + lower_bound(const _Kt& __x) const + { return { _Base::lower_bound(__x), this }; } +#endif + + iterator + upper_bound(const key_type& __x) + { return iterator(_Base::upper_bound(__x), this); } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + const_iterator + upper_bound(const key_type& __x) const + { return const_iterator(_Base::upper_bound(__x), this); } + +#if __cplusplus > 201103L + template::type> + iterator + upper_bound(const _Kt& __x) + { return { _Base::upper_bound(__x), this }; } + + template::type> + const_iterator + upper_bound(const _Kt& __x) const + { return { _Base::upper_bound(__x), this }; } +#endif + + std::pair + equal_range(const key_type& __x) + { + std::pair<_Base_iterator, _Base_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(iterator(__res.first, this), + iterator(__res.second, this)); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 214. set::find() missing const overload + std::pair + equal_range(const key_type& __x) const + { + std::pair<_Base_const_iterator, _Base_const_iterator> __res = + _Base::equal_range(__x); + return std::make_pair(const_iterator(__res.first, this), + const_iterator(__res.second, this)); + } + +#if __cplusplus > 201103L + template::type> + std::pair + equal_range(const _Kt& __x) + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } + + template::type> + std::pair + equal_range(const _Kt& __x) const + { + auto __res = _Base::equal_range(__x); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireNotAllocator<_Compare>, + typename = _RequireAllocator<_Allocator>> + set(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, _Allocator) + -> set::value_type, + less::value_type>, + _Allocator>; + + template> + set(initializer_list<_Key>, _Allocator) + -> set<_Key, less<_Key>, _Allocator>; + +#endif // deduction guides + + template + inline bool + operator==(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + inline __detail::__synth3way_t<_Key> + operator<=>(const set<_Key, _Compare, _Alloc>& __lhs, + const set<_Key, _Compare, _Alloc>& __rhs) + { return __lhs._M_base() <=> __rhs._M_base(); } +#else + template + inline bool + operator!=(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const set<_Key, _Compare, _Allocator>& __lhs, + const set<_Key, _Compare, _Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + void + swap(set<_Key, _Compare, _Allocator>& __x, + set<_Key, _Compare, _Allocator>& __y) + _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y))) + { return __x.swap(__y); } + +} // namespace __debug +} // namespace std + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/stl_iterator.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/stl_iterator.h new file mode 100755 index 0000000..edeb42e --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/stl_iterator.h @@ -0,0 +1,132 @@ +// Debugging support implementation -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/stl_iterator.h + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_STL_ITERATOR_H +#define _GLIBCXX_DEBUG_STL_ITERATOR_H 1 + +#include + +namespace __gnu_debug +{ + // Help Debug mode to see through reverse_iterator. + template + inline bool + __valid_range(const std::reverse_iterator<_Iterator>& __first, + const std::reverse_iterator<_Iterator>& __last, + typename _Distance_traits<_Iterator>::__type& __dist) + { return __valid_range(__last.base(), __first.base(), __dist); } + + template + inline typename _Distance_traits<_Iterator>::__type + __get_distance(const std::reverse_iterator<_Iterator>& __first, + const std::reverse_iterator<_Iterator>& __last) + { return __get_distance(__last.base(), __first.base()); } + + template + inline bool + __can_advance(const std::reverse_iterator<_Iterator>& __it, _Size __n) + { return __can_advance(__it.base(), -__n); } + + template + inline bool + __can_advance(const std::reverse_iterator<_Iterator>& __it, + const std::pair<_Diff, _Distance_precision>& __dist, + int __way) + { return __can_advance(__it.base(), __dist, -__way); } + + template + inline std::reverse_iterator<_Iterator> + __base(const std::reverse_iterator<_Safe_iterator< + _Iterator, _Sequence, std::random_access_iterator_tag> >& __it) + { return std::reverse_iterator<_Iterator>(__it.base().base()); } + +#if __cplusplus < 201103L + template + struct _Unsafe_type > + { + typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType; + typedef std::reverse_iterator<_UnsafeType> _Type; + }; + + template + inline std::reverse_iterator::_Type> + __unsafe(const std::reverse_iterator<_Iterator>& __it) + { + typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType; + return std::reverse_iterator<_UnsafeType>(__unsafe(__it.base())); + } +#else + template + inline auto + __unsafe(const std::reverse_iterator<_Iterator>& __it) + -> decltype(std::__make_reverse_iterator(__unsafe(__it.base()))) + { return std::__make_reverse_iterator(__unsafe(__it.base())); } +#endif + +#if __cplusplus >= 201103L + // Help Debug mode to see through move_iterator. + template + inline bool + __valid_range(const std::move_iterator<_Iterator>& __first, + const std::move_iterator<_Iterator>& __last, + typename _Distance_traits<_Iterator>::__type& __dist) + { return __valid_range(__first.base(), __last.base(), __dist); } + + template + inline typename _Distance_traits<_Iterator>::__type + __get_distance(const std::move_iterator<_Iterator>& __first, + const std::move_iterator<_Iterator>& __last) + { return __get_distance(__first.base(), __last.base()); } + + template + inline bool + __can_advance(const std::move_iterator<_Iterator>& __it, _Size __n) + { return __can_advance(__it.base(), __n); } + + template + inline bool + __can_advance(const std::move_iterator<_Iterator>& __it, + const std::pair<_Diff, _Distance_precision>& __dist, + int __way) + { return __can_advance(__it.base(), __dist, __way); } + + template + inline auto + __unsafe(const std::move_iterator<_Iterator>& __it) + -> decltype(std::make_move_iterator(__unsafe(__it.base()))) + { return std::make_move_iterator(__unsafe(__it.base())); } + + template + inline auto + __base(const std::move_iterator<_Iterator>& __it) + -> decltype(std::make_move_iterator(__base(__it.base()))) + { return std::make_move_iterator(__base(__it.base())); } +#endif +} + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/string b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/string new file mode 100755 index 0000000..8744a55 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/string @@ -0,0 +1,1348 @@ +// Debugging string implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/string + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_STRING +#define _GLIBCXX_DEBUG_STRING 1 + +#pragma GCC system_header + +#include +#include +#include +#include + +#define _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_Cond,_File,_Line,_Func) \ + if (! (_Cond)) \ + __gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \ + ._M_message(#_Cond)._M_error() + +#if _GLIBCXX_USE_CXX11_ABI && __cplusplus >= 201103 +# define _GLIBCXX_INSERT_RETURNS_ITERATOR 1 +# define _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY(expr) expr +#else +# define _GLIBCXX_INSERT_RETURNS_ITERATOR 0 +# define _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY(expr) +#endif + +namespace __gnu_debug +{ + /** Checks that __s is non-NULL or __n == 0, and then returns __s. */ + template + inline const _CharT* + __check_string(const _CharT* __s, + _Integer __n __attribute__((__unused__)), + const char* __file __attribute__((__unused__)), + unsigned int __line __attribute__((__unused__)), + const char* __function __attribute__((__unused__))) + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(__s != 0 || __n == 0, + __file, __line, __function); +#endif + return __s; + } + + /** Checks that __s is non-NULL and then returns __s. */ + template + inline const _CharT* + __check_string(const _CharT* __s, + const char* __file __attribute__((__unused__)), + unsigned int __line __attribute__((__unused__)), + const char* __function __attribute__((__unused__))) + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(__s != 0, + __file, __line, __function); +#endif + return __s; + } + +#define __glibcxx_check_string_n_constructor(_Str, _Size) \ + __check_string(_Str, _Size, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +#define __glibcxx_check_string_constructor(_Str) \ + __check_string(_Str, __FILE__, __LINE__, __PRETTY_FUNCTION__) + + /// Class std::basic_string with safety/checking/debug instrumentation. + template, + typename _Allocator = std::allocator<_CharT> > + class basic_string + : public __gnu_debug::_Safe_container< + basic_string<_CharT, _Traits, _Allocator>, + _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>, + public std::basic_string<_CharT, _Traits, _Allocator> + { + typedef std::basic_string<_CharT, _Traits, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + basic_string, _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)> + _Safe; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // type used for positions in insert, erase etc. + typedef __gnu_debug::_Safe_iterator< + typename _Base::__const_iterator, basic_string> __const_iterator; + + public: + // types: + typedef _Traits traits_type; + typedef typename _Traits::char_type value_type; + typedef _Allocator allocator_type; + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + + typedef __gnu_debug::_Safe_iterator< + typename _Base::iterator, basic_string> iterator; + typedef __gnu_debug::_Safe_iterator< + typename _Base::const_iterator, basic_string> const_iterator; + + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + using _Base::npos; + + // 21.3.1 construct/copy/destroy: + + explicit + basic_string(const _Allocator& __a) _GLIBCXX_NOEXCEPT + : _Base(__a) { } + +#if __cplusplus < 201103L + basic_string() : _Base() { } + + basic_string(const basic_string& __str) + : _Base(__str) { } + + ~basic_string() { } +#else + basic_string() = default; + basic_string(const basic_string&) = default; + basic_string(basic_string&&) = default; + + basic_string(std::initializer_list<_CharT> __l, + const _Allocator& __a = _Allocator()) + : _Base(__l, __a) + { } + + basic_string(const basic_string& __s, const _Allocator& __a) + : _Base(__s, __a) { } + + basic_string(basic_string&& __s, const _Allocator& __a) + noexcept( + std::is_nothrow_constructible<_Base, _Base, const _Allocator&>::value ) + : _Safe(std::move(__s._M_safe()), __a), + _Base(std::move(__s._M_base()), __a) + { } + + ~basic_string() = default; + + // Provides conversion from a normal-mode string to a debug-mode string + basic_string(_Base&& __base) noexcept + : _Base(std::move(__base)) { } +#endif // C++11 + + // Provides conversion from a normal-mode string to a debug-mode string + basic_string(const _Base& __base) + : _Base(__base) { } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 42. string ctors specify wrong default allocator + basic_string(const basic_string& __str, size_type __pos, + size_type __n = _Base::npos, + const _Allocator& __a = _Allocator()) + : _Base(__str, __pos, __n, __a) { } + + basic_string(const _CharT* __s, size_type __n, + const _Allocator& __a = _Allocator()) + : _Base(__glibcxx_check_string_n_constructor(__s, __n), __n, __a) { } + + basic_string(const _CharT* __s, const _Allocator& __a = _Allocator()) + : _Base(__glibcxx_check_string_constructor(__s), __a) + { } + + basic_string(size_type __n, _CharT __c, + const _Allocator& __a = _Allocator()) + : _Base(__n, __c, __a) { } + + template + basic_string(_InputIterator __begin, _InputIterator __end, + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__begin, __end)), + __gnu_debug::__base(__end), __a) { } + +#if __cplusplus < 201103L + basic_string& + operator=(const basic_string& __str) + { + this->_M_safe() = __str; + _M_base() = __str; + return *this; + } +#else + basic_string& + operator=(const basic_string&) = default; + + basic_string& + operator=(basic_string&&) = default; +#endif + + basic_string& + operator=(const _CharT* __s) + { + __glibcxx_check_string(__s); + _M_base() = __s; + this->_M_invalidate_all(); + return *this; + } + + basic_string& + operator=(_CharT __c) + { + _M_base() = __c; + this->_M_invalidate_all(); + return *this; + } + +#if __cplusplus >= 201103L + basic_string& + operator=(std::initializer_list<_CharT> __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } +#endif // C++11 + + // 21.3.2 iterators: + iterator + begin() // _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() // _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() // _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() // _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // 21.3.3 capacity: + using _Base::size; + using _Base::length; + using _Base::max_size; + + void + resize(size_type __n, _CharT __c) + { + _Base::resize(__n, __c); + this->_M_invalidate_all(); + } + + void + resize(size_type __n) + { this->resize(__n, _CharT()); } + +#if __cplusplus >= 201103L + void + shrink_to_fit() noexcept + { + if (capacity() > size()) + { + __try + { + reserve(0); + this->_M_invalidate_all(); + } + __catch(...) + { } + } + } +#endif + + using _Base::capacity; + using _Base::reserve; + + void + clear() // _GLIBCXX_NOEXCEPT + { + _Base::clear(); + this->_M_invalidate_all(); + } + + using _Base::empty; + + // 21.3.4 element access: + const_reference + operator[](size_type __pos) const _GLIBCXX_NOEXCEPT + { + _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), + _M_message(__gnu_debug::__msg_subscript_oob) + ._M_sequence(*this, "this") + ._M_integer(__pos, "__pos") + ._M_integer(this->size(), "size")); + return _M_base()[__pos]; + } + + reference + operator[](size_type __pos) // _GLIBCXX_NOEXCEPT + { +#if __cplusplus < 201103L && defined(_GLIBCXX_DEBUG_PEDANTIC) + __glibcxx_check_subscript(__pos); +#else + // as an extension v3 allows s[s.size()] when s is non-const. + _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), + _M_message(__gnu_debug::__msg_subscript_oob) + ._M_sequence(*this, "this") + ._M_integer(__pos, "__pos") + ._M_integer(this->size(), "size")); +#endif + return _M_base()[__pos]; + } + + using _Base::at; + +#if __cplusplus >= 201103L + using _Base::front; + using _Base::back; +#endif + + // 21.3.5 modifiers: + basic_string& + operator+=(const basic_string& __str) + { + _M_base() += __str; + this->_M_invalidate_all(); + return *this; + } + + basic_string& + operator+=(const _CharT* __s) + { + __glibcxx_check_string(__s); + _M_base() += __s; + this->_M_invalidate_all(); + return *this; + } + + basic_string& + operator+=(_CharT __c) + { + _M_base() += __c; + this->_M_invalidate_all(); + return *this; + } + +#if __cplusplus >= 201103L + basic_string& + operator+=(std::initializer_list<_CharT> __l) + { + _M_base() += __l; + this->_M_invalidate_all(); + return *this; + } +#endif // C++11 + + basic_string& + append(const basic_string& __str) + { + _Base::append(__str); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + append(const basic_string& __str, size_type __pos, size_type __n) + { + _Base::append(__str, __pos, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + append(const _CharT* __s, size_type __n) + { + __glibcxx_check_string_len(__s, __n); + _Base::append(__s, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + append(const _CharT* __s) + { + __glibcxx_check_string(__s); + _Base::append(__s); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + append(size_type __n, _CharT __c) + { + _Base::append(__n, __c); + this->_M_invalidate_all(); + return *this; + } + + template + basic_string& + append(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __dp_sign) + _Base::append(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::append(__first, __last); + + this->_M_invalidate_all(); + return *this; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 7. string clause minor problems + void + push_back(_CharT __c) + { + _Base::push_back(__c); + this->_M_invalidate_all(); + } + + basic_string& + assign(const basic_string& __x) + { + _Base::assign(__x); + this->_M_invalidate_all(); + return *this; + } + +#if __cplusplus >= 201103L + basic_string& + assign(basic_string&& __x) + noexcept(noexcept(std::declval<_Base&>().assign(std::move(__x)))) + { + _Base::assign(std::move(__x)); + this->_M_invalidate_all(); + return *this; + } +#endif // C++11 + + basic_string& + assign(const basic_string& __str, size_type __pos, size_type __n) + { + _Base::assign(__str, __pos, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + assign(const _CharT* __s, size_type __n) + { + __glibcxx_check_string_len(__s, __n); + _Base::assign(__s, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + assign(const _CharT* __s) + { + __glibcxx_check_string(__s); + _Base::assign(__s); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + assign(size_type __n, _CharT __c) + { + _Base::assign(__n, __c); + this->_M_invalidate_all(); + return *this; + } + + template + basic_string& + assign(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __dp_sign) + _Base::assign(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::assign(__first, __last); + + this->_M_invalidate_all(); + return *this; + } + +#if __cplusplus >= 201103L + basic_string& + assign(std::initializer_list<_CharT> __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + return *this; + } +#endif // C++11 + + basic_string& + insert(size_type __pos1, const basic_string& __str) + { + _Base::insert(__pos1, __str); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + insert(size_type __pos1, const basic_string& __str, + size_type __pos2, size_type __n) + { + _Base::insert(__pos1, __str, __pos2, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + insert(size_type __pos, const _CharT* __s, size_type __n) + { + __glibcxx_check_string(__s); + _Base::insert(__pos, __s, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + insert(size_type __pos, const _CharT* __s) + { + __glibcxx_check_string(__s); + _Base::insert(__pos, __s); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + insert(size_type __pos, size_type __n, _CharT __c) + { + _Base::insert(__pos, __n, __c); + this->_M_invalidate_all(); + return *this; + } + + iterator + insert(__const_iterator __p, _CharT __c) + { + __glibcxx_check_insert(__p); + typename _Base::iterator __res = _Base::insert(__p.base(), __c); + this->_M_invalidate_all(); + return iterator(__res, this); + } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __p, size_type __n, _CharT __c) + { + __glibcxx_check_insert(__p); +#if _GLIBCXX_USE_CXX11_ABI + typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c); +#else + const size_type __offset = __p.base() - _Base::cbegin(); + _Base::insert(_Base::begin() + __offset, __n, __c); + typename _Base::iterator __res = _Base::begin() + __offset; +#endif + this->_M_invalidate_all(); + return iterator(__res, this); + } +#else + void + insert(iterator __p, size_type __n, _CharT __c) + { + __glibcxx_check_insert(__p); + _Base::insert(__p.base(), __n, __c); + this->_M_invalidate_all(); + } +#endif + + template + iterator + insert(__const_iterator __p, + _InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__p, __first, __last, __dist); + + typename _Base::iterator __res; +#if ! _GLIBCXX_INSERT_RETURNS_ITERATOR + const size_type __offset = __p.base() - _Base::begin(); +#endif + if (__dist.second >= __dp_sign) + { + _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY(__res =) + _Base::insert(__p.base(), __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + } + else + { + _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY(__res =) + _Base::insert(__p.base(), __first, __last); + } + +#if ! _GLIBCXX_INSERT_RETURNS_ITERATOR + __res = _Base::begin() + __offset; +#endif + this->_M_invalidate_all(); + return iterator(__res, this); + } + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __p, std::initializer_list<_CharT> __l) + { + __glibcxx_check_insert(__p); +#if _GLIBCXX_USE_CXX11_ABI + const auto __res = _Base::insert(__p.base(), __l); +#else + const size_type __offset = __p.base() - _Base::cbegin(); + _Base::insert(_Base::begin() + __offset, __l); + auto __res = _Base::begin() + __offset; +#endif + this->_M_invalidate_all(); + return iterator(__res, this); + } +#endif // C++11 + + basic_string& + erase(size_type __pos = 0, size_type __n = _Base::npos) + { + _Base::erase(__pos, __n); + this->_M_invalidate_all(); + return *this; + } + + iterator + erase(__const_iterator __position) + { + __glibcxx_check_erase(__position); + typename _Base::iterator __res = _Base::erase(__position.base()); + this->_M_invalidate_all(); + return iterator(__res, this); + } + + iterator + erase(__const_iterator __first, __const_iterator __last) + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + typename _Base::iterator __res = _Base::erase(__first.base(), + __last.base()); + this->_M_invalidate_all(); + return iterator(__res, this); + } + +#if __cplusplus >= 201103L + void + pop_back() // noexcept + { + __glibcxx_check_nonempty(); + _Base::pop_back(); + this->_M_invalidate_all(); + } +#endif // C++11 + + basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str) + { + _Base::replace(__pos1, __n1, __str); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2) + { + _Base::replace(__pos1, __n1, __str, __pos2, __n2); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s, + size_type __n2) + { + __glibcxx_check_string_len(__s, __n2); + _Base::replace(__pos, __n1, __s, __n2); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(size_type __pos, size_type __n1, const _CharT* __s) + { + __glibcxx_check_string(__s); + _Base::replace(__pos, __n1, __s); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) + { + _Base::replace(__pos, __n1, __n2, __c); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const basic_string& __str) + { + __glibcxx_check_erase_range(__i1, __i2); + _Base::replace(__i1.base(), __i2.base(), __str); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const _CharT* __s, size_type __n) + { + __glibcxx_check_erase_range(__i1, __i2); + __glibcxx_check_string_len(__s, __n); + _Base::replace(__i1.base(), __i2.base(), __s, __n); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + const _CharT* __s) + { + __glibcxx_check_erase_range(__i1, __i2); + __glibcxx_check_string(__s); + _Base::replace(__i1.base(), __i2.base(), __s); + this->_M_invalidate_all(); + return *this; + } + + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + size_type __n, _CharT __c) + { + __glibcxx_check_erase_range(__i1, __i2); + _Base::replace(__i1.base(), __i2.base(), __n, __c); + this->_M_invalidate_all(); + return *this; + } + + template + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + _InputIterator __j1, _InputIterator __j2) + { + __glibcxx_check_erase_range(__i1, __i2); + + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__j1, __j2, __dist); + + if (__dist.second >= __dp_sign) + _Base::replace(__i1.base(), __i2.base(), + __gnu_debug::__unsafe(__j1), + __gnu_debug::__unsafe(__j2)); + else + _Base::replace(__i1.base(), __i2.base(), __j1, __j2); + + this->_M_invalidate_all(); + return *this; + } + +#if __cplusplus >= 201103L + basic_string& + replace(__const_iterator __i1, __const_iterator __i2, + std::initializer_list<_CharT> __l) + { + __glibcxx_check_erase_range(__i1, __i2); + _Base::replace(__i1.base(), __i2.base(), __l); + this->_M_invalidate_all(); + return *this; + } +#endif // C++11 + + size_type + copy(_CharT* __s, size_type __n, size_type __pos = 0) const + { + __glibcxx_check_string_len(__s, __n); + return _Base::copy(__s, __n, __pos); + } + + void + swap(basic_string& __x) + _GLIBCXX_NOEXCEPT_IF(std::__is_nothrow_swappable<_Base>::value) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + // 21.3.6 string operations: + const _CharT* + c_str() const _GLIBCXX_NOEXCEPT + { + const _CharT* __res = _Base::c_str(); + this->_M_invalidate_all(); + return __res; + } + + const _CharT* + data() const _GLIBCXX_NOEXCEPT + { + const _CharT* __res = _Base::data(); + this->_M_invalidate_all(); + return __res; + } + + using _Base::get_allocator; + + size_type + find(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return _Base::find(__str, __pos); } + + size_type + find(const _CharT* __s, size_type __pos, size_type __n) const + { + __glibcxx_check_string(__s); + return _Base::find(__s, __pos, __n); + } + + size_type + find(const _CharT* __s, size_type __pos = 0) const + { + __glibcxx_check_string(__s); + return _Base::find(__s, __pos); + } + + size_type + find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return _Base::find(__c, __pos); } + + size_type + rfind(const basic_string& __str, size_type __pos = _Base::npos) const + _GLIBCXX_NOEXCEPT + { return _Base::rfind(__str, __pos); } + + size_type + rfind(const _CharT* __s, size_type __pos, size_type __n) const + { + __glibcxx_check_string_len(__s, __n); + return _Base::rfind(__s, __pos, __n); + } + + size_type + rfind(const _CharT* __s, size_type __pos = _Base::npos) const + { + __glibcxx_check_string(__s); + return _Base::rfind(__s, __pos); + } + + size_type + rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT + { return _Base::rfind(__c, __pos); } + + size_type + find_first_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return _Base::find_first_of(__str, __pos); } + + size_type + find_first_of(const _CharT* __s, size_type __pos, size_type __n) const + { + __glibcxx_check_string(__s); + return _Base::find_first_of(__s, __pos, __n); + } + + size_type + find_first_of(const _CharT* __s, size_type __pos = 0) const + { + __glibcxx_check_string(__s); + return _Base::find_first_of(__s, __pos); + } + + size_type + find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return _Base::find_first_of(__c, __pos); } + + size_type + find_last_of(const basic_string& __str, + size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT + { return _Base::find_last_of(__str, __pos); } + + size_type + find_last_of(const _CharT* __s, size_type __pos, size_type __n) const + { + __glibcxx_check_string(__s); + return _Base::find_last_of(__s, __pos, __n); + } + + size_type + find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const + { + __glibcxx_check_string(__s); + return _Base::find_last_of(__s, __pos); + } + + size_type + find_last_of(_CharT __c, size_type __pos = _Base::npos) const + _GLIBCXX_NOEXCEPT + { return _Base::find_last_of(__c, __pos); } + + size_type + find_first_not_of(const basic_string& __str, size_type __pos = 0) const + _GLIBCXX_NOEXCEPT + { return _Base::find_first_not_of(__str, __pos); } + + size_type + find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { + __glibcxx_check_string_len(__s, __n); + return _Base::find_first_not_of(__s, __pos, __n); + } + + size_type + find_first_not_of(const _CharT* __s, size_type __pos = 0) const + { + __glibcxx_check_string(__s); + return _Base::find_first_not_of(__s, __pos); + } + + size_type + find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT + { return _Base::find_first_not_of(__c, __pos); } + + size_type + find_last_not_of(const basic_string& __str, + size_type __pos = _Base::npos) const + _GLIBCXX_NOEXCEPT + { return _Base::find_last_not_of(__str, __pos); } + + size_type + find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const + { + __glibcxx_check_string(__s); + return _Base::find_last_not_of(__s, __pos, __n); + } + + size_type + find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const + { + __glibcxx_check_string(__s); + return _Base::find_last_not_of(__s, __pos); + } + + size_type + find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const + _GLIBCXX_NOEXCEPT + { return _Base::find_last_not_of(__c, __pos); } + + basic_string + substr(size_type __pos = 0, size_type __n = _Base::npos) const + { return basic_string(_Base::substr(__pos, __n)); } + + int + compare(const basic_string& __str) const + { return _Base::compare(__str); } + + int + compare(size_type __pos1, size_type __n1, + const basic_string& __str) const + { return _Base::compare(__pos1, __n1, __str); } + + int + compare(size_type __pos1, size_type __n1, const basic_string& __str, + size_type __pos2, size_type __n2) const + { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); } + + int + compare(const _CharT* __s) const + { + __glibcxx_check_string(__s); + return _Base::compare(__s); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 5. string::compare specification questionable + int + compare(size_type __pos1, size_type __n1, const _CharT* __s) const + { + __glibcxx_check_string(__s); + return _Base::compare(__pos1, __n1, __s); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 5. string::compare specification questionable + int + compare(size_type __pos1, size_type __n1,const _CharT* __s, + size_type __n2) const + { + __glibcxx_check_string_len(__s, __n2); + return _Base::compare(__pos1, __n1, __s, __n2); + } + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + + using _Safe::_M_invalidate_all; + }; + + template + inline basic_string<_CharT,_Traits,_Allocator> + operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; } + + template + inline basic_string<_CharT,_Traits,_Allocator> + operator+(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; + } + + template + inline basic_string<_CharT,_Traits,_Allocator> + operator+(_CharT __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; } + + template + inline basic_string<_CharT,_Traits,_Allocator> + operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; + } + + template + inline basic_string<_CharT,_Traits,_Allocator> + operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + _CharT __rhs) + { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; } + + template + inline bool + operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + + template + inline bool + operator==(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return __lhs == __rhs._M_base(); + } + + template + inline bool + operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return __lhs._M_base() == __rhs; + } + + template + inline bool + operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator!=(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return __lhs != __rhs._M_base(); + } + + template + inline bool + operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return __lhs._M_base() != __rhs; + } + + template + inline bool + operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return __lhs < __rhs._M_base(); + } + + template + inline bool + operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return __lhs._M_base() < __rhs; + } + + template + inline bool + operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator<=(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return __lhs <= __rhs._M_base(); + } + + template + inline bool + operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return __lhs._M_base() <= __rhs; + } + + template + inline bool + operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>=(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return __lhs >= __rhs._M_base(); + } + + template + inline bool + operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return __lhs._M_base() >= __rhs; + } + + template + inline bool + operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } + + template + inline bool + operator>(const _CharT* __lhs, + const basic_string<_CharT,_Traits,_Allocator>& __rhs) + { + __glibcxx_check_string(__lhs); + return __lhs > __rhs._M_base(); + } + + template + inline bool + operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs, + const _CharT* __rhs) + { + __glibcxx_check_string(__rhs); + return __lhs._M_base() > __rhs; + } + + // 21.3.7.8: + template + inline void + swap(basic_string<_CharT,_Traits,_Allocator>& __lhs, + basic_string<_CharT,_Traits,_Allocator>& __rhs) + { __lhs.swap(__rhs); } + + template + std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>& __os, + const basic_string<_CharT, _Traits, _Allocator>& __str) + { return __os << __str._M_base(); } + + template + std::basic_istream<_CharT,_Traits>& + operator>>(std::basic_istream<_CharT,_Traits>& __is, + basic_string<_CharT,_Traits,_Allocator>& __str) + { + std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base(); + __str._M_invalidate_all(); + return __res; + } + + template + std::basic_istream<_CharT,_Traits>& + getline(std::basic_istream<_CharT,_Traits>& __is, + basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim) + { + std::basic_istream<_CharT,_Traits>& __res = getline(__is, + __str._M_base(), + __delim); + __str._M_invalidate_all(); + return __res; + } + + template + std::basic_istream<_CharT,_Traits>& + getline(std::basic_istream<_CharT,_Traits>& __is, + basic_string<_CharT,_Traits,_Allocator>& __str) + { + std::basic_istream<_CharT,_Traits>& __res = getline(__is, + __str._M_base()); + __str._M_invalidate_all(); + return __res; + } + + typedef basic_string string; + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef basic_string wstring; +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + /// A string of @c char8_t + typedef basic_string u8string; +#endif + +#if __cplusplus >= 201103L + /// A string of @c char16_t + typedef basic_string u16string; + + /// A string of @c char32_t + typedef basic_string u32string; +#endif + + template + struct _Insert_range_from_self_is_safe< + __gnu_debug::basic_string<_CharT, _Traits, _Allocator> > + { enum { __value = 1 }; }; + +} // namespace __gnu_debug + +#if __cplusplus >= 201103L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// std::hash specialization for __gnu_debug::basic_string. + template + struct hash<__gnu_debug::basic_string<_CharT>> + : public hash> + { }; + + template + struct __is_fast_hash>> + : __is_fast_hash>> + { }; + +_GLIBCXX_END_NAMESPACE_VERSION +} +#endif /* C++11 */ + +#undef _GLIBCXX_INSERT_RETURNS_ITERATOR +#undef _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/unordered_map b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/unordered_map new file mode 100755 index 0000000..bb697d3 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/unordered_map @@ -0,0 +1,1467 @@ +// Debugging unordered_map/unordered_multimap implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/unordered_map + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_UNORDERED_MAP +#define _GLIBCXX_DEBUG_UNORDERED_MAP 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else +# include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template + class unordered_map; + template + class unordered_multimap; +} } // namespace std::__debug + +# include + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::unordered_map with safety/checking/debug instrumentation. + template, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator > > + class unordered_map + : public __gnu_debug::_Safe_container< + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>, _Alloc, + __gnu_debug::_Safe_unordered_container>, + public _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> + { + typedef _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, + _Pred, _Alloc> _Base; + typedef __gnu_debug::_Safe_container _Safe; + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_local_iterator + _Base_const_local_iterator; + typedef typename _Base::local_iterator _Base_local_iterator; + + template + friend class ::__gnu_debug::_Safe_iterator; + template + friend class ::__gnu_debug::_Safe_local_iterator; + + // Reference wrapper for base class. See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + + typedef __gnu_debug::_Safe_iterator< + _Base_iterator, unordered_map> iterator; + typedef __gnu_debug::_Safe_iterator< + _Base_const_iterator, unordered_map> const_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_local_iterator, unordered_map> local_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_const_local_iterator, unordered_map> const_local_iterator; + + unordered_map() = default; + + explicit + unordered_map(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __n, + __hf, __eql, __a) { } + + unordered_map(const unordered_map&) = default; + + unordered_map(_Base_ref __x) + : _Base(__x._M_ref) { } + + unordered_map(unordered_map&&) = default; + + explicit + unordered_map(const allocator_type& __a) + : _Base(__a) { } + + unordered_map(const unordered_map& __umap, + const allocator_type& __a) + : _Base(__umap, __a) { } + + unordered_map(unordered_map&& __umap, + const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__umap._M_base()), __a)) ) + : _Safe(std::move(__umap._M_safe()), __a), + _Base(std::move(__umap._M_base()), __a) { } + + unordered_map(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __n, __hf, __eql, __a) { } + + unordered_map(size_type __n, const allocator_type& __a) + : unordered_map(__n, hasher(), key_equal(), __a) + { } + + unordered_map(size_type __n, + const hasher& __hf, + const allocator_type& __a) + : unordered_map(__n, __hf, key_equal(), __a) + { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_map(_InputIterator __first, _InputIterator __last, + size_type __n, + const hasher& __hf, + const allocator_type& __a) + : unordered_map(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_map(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_map(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_map(initializer_list __l, + size_type __n, + const hasher& __hf, + const allocator_type& __a) + : unordered_map(__l, __n, __hf, key_equal(), __a) + { } + + ~unordered_map() = default; + + unordered_map& + operator=(const unordered_map&) = default; + + unordered_map& + operator=(unordered_map&&) = default; + + unordered_map& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } + + void + swap(unordered_map& __x) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() noexcept + { + _Base::clear(); + this->_M_invalidate_all(); + } + + iterator + begin() noexcept + { return { _Base::begin(), this }; } + + const_iterator + begin() const noexcept + { return { _Base::begin(), this }; } + + iterator + end() noexcept + { return { _Base::end(), this }; } + + const_iterator + end() const noexcept + { return { _Base::end(), this }; } + + const_iterator + cbegin() const noexcept + { return { _Base::cbegin(), this }; } + + const_iterator + cend() const noexcept + { return { _Base::cend(), this }; } + + // local versions + local_iterator + begin(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + local_iterator + end(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + begin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + const_local_iterator + end(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + cbegin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cbegin(__b), this }; + } + + const_local_iterator + cend(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cend(__b), this }; + } + + size_type + bucket_size(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return _Base::bucket_size(__b); + } + + float + max_load_factor() const noexcept + { return _Base::max_load_factor(); } + + void + max_load_factor(float __f) + { + __glibcxx_check_max_load_factor(__f); + _Base::max_load_factor(__f); + } + + template + std::pair + emplace(_Args&&... __args) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::emplace(std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + template + iterator + emplace_hint(const_iterator __hint, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::emplace_hint(__hint.base(), + std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + std::pair + insert(const value_type& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::insert(__obj); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + std::pair + insert(value_type&& __x) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::insert(std::move(__x)); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + template::value>::type> + std::pair + insert(_Pair&& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::insert(std::forward<_Pair>(__obj)); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + iterator + insert(const_iterator __hint, const value_type& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), __obj); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __hint, value_type&& __x) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), std::move(__x)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + template::value>::type> + iterator + insert(const_iterator __hint, _Pair&& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), std::forward<_Pair>(__obj)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + void + insert(std::initializer_list __l) + { + size_type __bucket_count = this->bucket_count(); + _Base::insert(__l); + _M_check_rehashed(__bucket_count); + } + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + size_type __bucket_count = this->bucket_count(); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + + _M_check_rehashed(__bucket_count); + } + +#if __cplusplus > 201402L + template + pair + try_emplace(const key_type& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(__k, + std::forward<_Args>(__args)...); + return { { __res.first, this }, __res.second }; + } + + template + pair + try_emplace(key_type&& __k, _Args&&... __args) + { + auto __res = _Base::try_emplace(std::move(__k), + std::forward<_Args>(__args)...); + return { { __res.first, this }, __res.second }; + } + + template + iterator + try_emplace(const_iterator __hint, const key_type& __k, + _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return { _Base::try_emplace(__hint.base(), __k, + std::forward<_Args>(__args)...), + this }; + } + + template + iterator + try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + return { _Base::try_emplace(__hint.base(), std::move(__k), + std::forward<_Args>(__args)...), + this }; + } + + template + pair + insert_or_assign(const key_type& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(__k, + std::forward<_Obj>(__obj)); + return { { __res.first, this }, __res.second }; + } + + template + pair + insert_or_assign(key_type&& __k, _Obj&& __obj) + { + auto __res = _Base::insert_or_assign(std::move(__k), + std::forward<_Obj>(__obj)); + return { { __res.first, this }, __res.second }; + } + + template + iterator + insert_or_assign(const_iterator __hint, const key_type& __k, + _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return { _Base::insert_or_assign(__hint.base(), __k, + std::forward<_Obj>(__obj)), + this }; + } + + template + iterator + insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj) + { + __glibcxx_check_insert(__hint); + return { _Base::insert_or_assign(__hint.base(), std::move(__k), + std::forward<_Obj>(__obj)), + this }; + } +#endif // C++17 + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + using insert_return_type = _Node_insert_return; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + return _M_extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = _Base::find(__key); + if (__position != _Base::end()) + return _M_extract(__position); + return {}; + } + + insert_return_type + insert(node_type&& __nh) + { + auto __ret = _Base::insert(std::move(__nh)); + return + { { __ret.position, this }, __ret.inserted, std::move(__ret.node) }; + } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + + iterator + find(const key_type& __key) + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + iterator + find(const _Kt& __k) + { return { _Base::find(__k), this }; } +#endif + + const_iterator + find(const key_type& __key) const + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + const_iterator + find(const _Kt& __k) const + { return { _Base::find(__k), this }; } +#endif + + std::pair + equal_range(const key_type& __key) + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + std::pair + equal_range(const key_type& __key) const + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) const + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + size_type + erase(const key_type& __key) + { + size_type __ret(0); + auto __victim = _Base::find(__key); + if (__victim != _Base::end()) + { + _M_erase(__victim); + __ret = 1; + } + return __ret; + } + + iterator + erase(const_iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(const_iterator __first, const_iterator __last) + { + __glibcxx_check_erase_range(__first, __last); + for (auto __tmp = __first.base(); __tmp != __last.base(); ++__tmp) + { + _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + _M_invalidate(__tmp); + } + + size_type __bucket_count = this->bucket_count(); + auto __next = _Base::erase(__first.base(), __last.base()); + _M_check_rehashed(__bucket_count); + return { __next, this }; + } + + _Base& + _M_base() noexcept { return *this; } + + const _Base& + _M_base() const noexcept { return *this; } + + private: + void + _M_check_rehashed(size_type __prev_count) + { + if (__prev_count != this->bucket_count()) + this->_M_invalidate_all(); + } + + void + _M_invalidate(_Base_const_iterator __victim) + { + this->_M_invalidate_if( + [__victim](_Base_const_iterator __it) { return __it == __victim; }); + this->_M_invalidate_local_if( + [__victim](_Base_const_local_iterator __it) + { return __it == __victim; }); + } + + _Base_iterator + _M_erase(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + size_type __bucket_count = this->bucket_count(); + _Base_iterator __next = _Base::erase(__victim); + _M_check_rehashed(__bucket_count); + return __next; + } + +#if __cplusplus > 201402L + node_type + _M_extract(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + return _Base::extract(__victim); + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + + template + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + + /// Class std::unordered_multimap with safety/checking/debug instrumentation. + template, + typename _Pred = std::equal_to<_Key>, + typename _Alloc = std::allocator > > + class unordered_multimap + : public __gnu_debug::_Safe_container< + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>, _Alloc, + __gnu_debug::_Safe_unordered_container>, + public _GLIBCXX_STD_C::unordered_multimap< + _Key, _Tp, _Hash, _Pred, _Alloc> + { + typedef _GLIBCXX_STD_C::unordered_multimap<_Key, _Tp, _Hash, + _Pred, _Alloc> _Base; + typedef __gnu_debug::_Safe_container _Safe; + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_local_iterator _Base_const_local_iterator; + typedef typename _Base::local_iterator _Base_local_iterator; + + template + friend class ::__gnu_debug::_Safe_iterator; + template + friend class ::__gnu_debug::_Safe_local_iterator; + + // Reference wrapper for base class. See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + + typedef __gnu_debug::_Safe_iterator< + _Base_iterator, unordered_multimap> iterator; + typedef __gnu_debug::_Safe_iterator< + _Base_const_iterator, unordered_multimap> const_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_local_iterator, unordered_multimap> local_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_const_local_iterator, unordered_multimap> const_local_iterator; + + unordered_multimap() = default; + + explicit + unordered_multimap(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __n, + __hf, __eql, __a) { } + + unordered_multimap(const unordered_multimap&) = default; + + unordered_multimap(_Base_ref __x) + : _Base(__x._M_ref) { } + + unordered_multimap(unordered_multimap&&) = default; + + explicit + unordered_multimap(const allocator_type& __a) + : _Base(__a) { } + + unordered_multimap(const unordered_multimap& __umap, + const allocator_type& __a) + : _Base(__umap, __a) { } + + unordered_multimap(unordered_multimap&& __umap, + const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__umap._M_base()), __a)) ) + : _Safe(std::move(__umap._M_safe()), __a), + _Base(std::move(__umap._M_base()), __a) { } + + unordered_multimap(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __n, __hf, __eql, __a) { } + + unordered_multimap(size_type __n, const allocator_type& __a) + : unordered_multimap(__n, hasher(), key_equal(), __a) + { } + + unordered_multimap(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__n, __hf, key_equal(), __a) + { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_multimap(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_multimap(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_multimap(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_multimap(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__l, __n, __hf, key_equal(), __a) + { } + + ~unordered_multimap() = default; + + unordered_multimap& + operator=(const unordered_multimap&) = default; + + unordered_multimap& + operator=(unordered_multimap&&) = default; + + unordered_multimap& + operator=(initializer_list __l) + { + this->_M_base() = __l; + this->_M_invalidate_all(); + return *this; + } + + void + swap(unordered_multimap& __x) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() noexcept + { + _Base::clear(); + this->_M_invalidate_all(); + } + + iterator + begin() noexcept + { return { _Base::begin(), this }; } + + const_iterator + begin() const noexcept + { return { _Base::begin(), this }; } + + iterator + end() noexcept + { return { _Base::end(), this }; } + + const_iterator + end() const noexcept + { return { _Base::end(), this }; } + + const_iterator + cbegin() const noexcept + { return { _Base::cbegin(), this }; } + + const_iterator + cend() const noexcept + { return { _Base::cend(), this }; } + + // local versions + local_iterator + begin(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + local_iterator + end(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + begin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + const_local_iterator + end(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + cbegin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cbegin(__b), this }; + } + + const_local_iterator + cend(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cend(__b), this }; + } + + size_type + bucket_size(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return _Base::bucket_size(__b); + } + + float + max_load_factor() const noexcept + { return _Base::max_load_factor(); } + + void + max_load_factor(float __f) + { + __glibcxx_check_max_load_factor(__f); + _Base::max_load_factor(__f); + } + + template + iterator + emplace(_Args&&... __args) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::emplace(std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + template + iterator + emplace_hint(const_iterator __hint, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::emplace_hint(__hint.base(), + std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + iterator + insert(const value_type& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__obj); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(value_type&& __x) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(std::move(__x)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + iterator + insert(const_iterator __hint, const value_type& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), __obj); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2354. Unnecessary copying when inserting into maps with braced-init + iterator + insert(const_iterator __hint, value_type&& __x) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), std::move(__x)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + template::value>::type> + iterator + insert(_Pair&& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(std::forward<_Pair>(__obj)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + template::value>::type> + iterator + insert(const_iterator __hint, _Pair&& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), std::forward<_Pair>(__obj)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + void + insert(std::initializer_list __l) + { _Base::insert(__l); } + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + size_type __bucket_count = this->bucket_count(); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + + _M_check_rehashed(__bucket_count); + } + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + return _M_extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = _Base::find(__key); + if (__position != _Base::end()) + return _M_extract(__position); + return {}; + } + + iterator + insert(node_type&& __nh) + { return { _Base::insert(std::move(__nh)), this }; } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + + iterator + find(const key_type& __key) + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + iterator + find(const _Kt& __k) + { return { _Base::find(__k), this }; } +#endif + + const_iterator + find(const key_type& __key) const + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + const_iterator + find(const _Kt& __k) const + { return { _Base::find(__k), this }; } +#endif + + std::pair + equal_range(const key_type& __key) + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + std::pair + equal_range(const key_type& __key) const + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) const + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + size_type + erase(const key_type& __key) + { + size_type __ret(0); + size_type __bucket_count = this->bucket_count(); + auto __pair = _Base::equal_range(__key); + for (auto __victim = __pair.first; __victim != __pair.second;) + { + _M_invalidate(__victim); + __victim = _Base::erase(__victim); + ++__ret; + } + + _M_check_rehashed(__bucket_count); + return __ret; + } + + iterator + erase(const_iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(const_iterator __first, const_iterator __last) + { + __glibcxx_check_erase_range(__first, __last); + for (auto __tmp = __first.base(); __tmp != __last.base(); ++__tmp) + { + _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + _M_invalidate(__tmp); + } + + size_type __bucket_count = this->bucket_count(); + auto __next = _Base::erase(__first.base(), __last.base()); + _M_check_rehashed(__bucket_count); + return { __next, this }; + } + + _Base& + _M_base() noexcept { return *this; } + + const _Base& + _M_base() const noexcept { return *this; } + + private: + void + _M_check_rehashed(size_type __prev_count) + { + if (__prev_count != this->bucket_count()) + this->_M_invalidate_all(); + } + + void + _M_invalidate(_Base_const_iterator __victim) + { + this->_M_invalidate_if( + [__victim](_Base_const_iterator __it) { return __it == __victim; }); + this->_M_invalidate_local_if( + [__victim](_Base_const_local_iterator __it) + { return __it == __victim; }); + } + + _Base_iterator + _M_erase(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + size_type __bucket_count = this->bucket_count(); + _Base_iterator __next = _Base::erase(__victim); + _M_check_rehashed(__bucket_count); + return __next; + } + +#if __cplusplus > 201402L + node_type + _M_extract(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + return _Base::extract(__victim); + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, _Pred, + _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Hash, + _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Hash, _Allocator) + -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + + template + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + +} // namespace __debug +} // namespace std + +#endif // C++11 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/unordered_set b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/unordered_set new file mode 100755 index 0000000..c259109 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/unordered_set @@ -0,0 +1,1295 @@ +// Debugging unordered_set/unordered_multiset implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/unordered_set + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_UNORDERED_SET +#define _GLIBCXX_DEBUG_UNORDERED_SET 1 + +#pragma GCC system_header + +#if __cplusplus < 201103L +# include +#else +# include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template + class unordered_set; + template + class unordered_multiset; +} } // namespace std::__debug +# include + +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::unordered_set with safety/checking/debug instrumentation. + template, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value> > + class unordered_set + : public __gnu_debug::_Safe_container< + unordered_set<_Value, _Hash, _Pred, _Alloc>, _Alloc, + __gnu_debug::_Safe_unordered_container>, + public _GLIBCXX_STD_C::unordered_set<_Value, _Hash, _Pred, _Alloc> + { + typedef _GLIBCXX_STD_C::unordered_set< + _Value, _Hash, _Pred, _Alloc> _Base; + typedef __gnu_debug::_Safe_container< + unordered_set, _Alloc, __gnu_debug::_Safe_unordered_container> _Safe; + + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_local_iterator _Base_const_local_iterator; + typedef typename _Base::local_iterator _Base_local_iterator; + + template + friend class ::__gnu_debug::_Safe_iterator; + template + friend class ::__gnu_debug::_Safe_local_iterator; + + // Reference wrapper for base class. See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + + typedef __gnu_debug::_Safe_iterator< + _Base_iterator, unordered_set> iterator; + typedef __gnu_debug::_Safe_iterator< + _Base_const_iterator, unordered_set> const_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_local_iterator, unordered_set> local_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_const_local_iterator, unordered_set> const_local_iterator; + + unordered_set() = default; + + explicit + unordered_set(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __n, + __hf, __eql, __a) { } + + unordered_set(const unordered_set&) = default; + + unordered_set(_Base_ref __x) + : _Base(__x._M_ref) { } + + unordered_set(unordered_set&&) = default; + + explicit + unordered_set(const allocator_type& __a) + : _Base(__a) { } + + unordered_set(const unordered_set& __uset, + const allocator_type& __a) + : _Base(__uset, __a) { } + + unordered_set(unordered_set&& __uset, + const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__uset._M_base()), __a)) ) + : _Safe(std::move(__uset._M_safe()), __a), + _Base(std::move(__uset._M_base()), __a) { } + + unordered_set(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __n, __hf, __eql, __a) { } + + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) + { } + + unordered_set(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) + { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_set(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_set(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_set(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_set(__l, __n, __hf, key_equal(), __a) + { } + + ~unordered_set() = default; + + unordered_set& + operator=(const unordered_set&) = default; + + unordered_set& + operator=(unordered_set&&) = default; + + unordered_set& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + return *this; + } + + void + swap(unordered_set& __x) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() noexcept + { + _Base::clear(); + this->_M_invalidate_all(); + } + + iterator + begin() noexcept + { return { _Base::begin(), this }; } + + const_iterator + begin() const noexcept + { return { _Base::begin(), this }; } + + iterator + end() noexcept + { return { _Base::end(), this }; } + + const_iterator + end() const noexcept + { return { _Base::end(), this }; } + + const_iterator + cbegin() const noexcept + { return { _Base::cbegin(), this }; } + + const_iterator + cend() const noexcept + { return { _Base::cend(), this }; } + + // local versions + local_iterator + begin(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + local_iterator + end(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + begin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + const_local_iterator + end(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + cbegin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cbegin(__b), this }; + } + + const_local_iterator + cend(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cend(__b), this }; + } + + size_type + bucket_size(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return _Base::bucket_size(__b); + } + + float + max_load_factor() const noexcept + { return _Base::max_load_factor(); } + + void + max_load_factor(float __f) + { + __glibcxx_check_max_load_factor(__f); + _Base::max_load_factor(__f); + } + + template + std::pair + emplace(_Args&&... __args) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::emplace(std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + template + iterator + emplace_hint(const_iterator __hint, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::emplace_hint(__hint.base(), + std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + std::pair + insert(const value_type& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::insert(__obj); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + iterator + insert(const_iterator __hint, const value_type& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), __obj); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + std::pair + insert(value_type&& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __res = _Base::insert(std::move(__obj)); + _M_check_rehashed(__bucket_count); + return { { __res.first, this }, __res.second }; + } + + iterator + insert(const_iterator __hint, value_type&& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), std::move(__obj)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + void + insert(std::initializer_list __l) + { + size_type __bucket_count = this->bucket_count(); + _Base::insert(__l); + _M_check_rehashed(__bucket_count); + } + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + size_type __bucket_count = this->bucket_count(); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + + _M_check_rehashed(__bucket_count); + } + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + using insert_return_type = _Node_insert_return; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + return _M_extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = _Base::find(__key); + if (__position != _Base::end()) + return _M_extract(__position); + return {}; + } + + insert_return_type + insert(node_type&& __nh) + { + auto __ret = _Base::insert(std::move(__nh)); + return + { { __ret.position, this }, __ret.inserted, std::move(__ret.node) }; + } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + + iterator + find(const key_type& __key) + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + iterator + find(const _Kt& __k) + { return { _Base::find(__k), this }; } +#endif + + const_iterator + find(const key_type& __key) const + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + const_iterator + find(const _Kt& __k) const + { return { _Base::find(__k), this }; } +#endif + + std::pair + equal_range(const key_type& __key) + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + std::pair + equal_range(const key_type& __key) const + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) const + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + size_type + erase(const key_type& __key) + { + size_type __ret(0); + auto __victim = _Base::find(__key); + if (__victim != _Base::end()) + { + _M_erase(__victim); + __ret = 1; + } + return __ret; + } + + iterator + erase(const_iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(const_iterator __first, const_iterator __last) + { + __glibcxx_check_erase_range(__first, __last); + for (auto __tmp = __first.base(); __tmp != __last.base(); ++__tmp) + { + _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + _M_invalidate(__tmp); + } + + size_type __bucket_count = this->bucket_count(); + auto __next = _Base::erase(__first.base(), __last.base()); + _M_check_rehashed(__bucket_count); + return { __next, this }; + } + + _Base& + _M_base() noexcept { return *this; } + + const _Base& + _M_base() const noexcept { return *this; } + + private: + void + _M_check_rehashed(size_type __prev_count) + { + if (__prev_count != this->bucket_count()) + this->_M_invalidate_all(); + } + + void + _M_invalidate(_Base_const_iterator __victim) + { + this->_M_invalidate_if( + [__victim](_Base_const_iterator __it) { return __it == __victim; }); + this->_M_invalidate_local_if( + [__victim](_Base_const_local_iterator __it) + { return __it == __victim; }); + } + + _Base_iterator + _M_erase(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + size_type __bucket_count = this->bucket_count(); + _Base_iterator __next = _Base::erase(__victim); + _M_check_rehashed(__bucket_count); + return __next; + } + +#if __cplusplus > 201402L + node_type + _M_extract(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + return _Base::extract(__victim); + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, _Allocator) + -> unordered_set::value_type, + hash< + typename iterator_traits<_InputIterator>::value_type>, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, + _Hash, _Allocator) + -> unordered_set::value_type, + _Hash, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Allocator) + -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Hash, _Allocator) + -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + + template + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + + /// Class std::unordered_multiset with safety/checking/debug instrumentation. + template, + typename _Pred = std::equal_to<_Value>, + typename _Alloc = std::allocator<_Value> > + class unordered_multiset + : public __gnu_debug::_Safe_container< + unordered_multiset<_Value, _Hash, _Pred, _Alloc>, _Alloc, + __gnu_debug::_Safe_unordered_container>, + public _GLIBCXX_STD_C::unordered_multiset<_Value, _Hash, _Pred, _Alloc> + { + typedef _GLIBCXX_STD_C::unordered_multiset< + _Value, _Hash, _Pred, _Alloc> _Base; + typedef __gnu_debug::_Safe_container _Safe; + typedef typename _Base::const_iterator _Base_const_iterator; + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_local_iterator + _Base_const_local_iterator; + typedef typename _Base::local_iterator _Base_local_iterator; + + template + friend class ::__gnu_debug::_Safe_iterator; + template + friend class ::__gnu_debug::_Safe_local_iterator; + + // Reference wrapper for base class. See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::size_type size_type; + typedef typename _Base::hasher hasher; + typedef typename _Base::key_equal key_equal; + typedef typename _Base::allocator_type allocator_type; + + typedef typename _Base::key_type key_type; + typedef typename _Base::value_type value_type; + + typedef __gnu_debug::_Safe_iterator< + _Base_iterator, unordered_multiset> iterator; + typedef __gnu_debug::_Safe_iterator< + _Base_const_iterator, unordered_multiset> const_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_local_iterator, unordered_multiset> local_iterator; + typedef __gnu_debug::_Safe_local_iterator< + _Base_const_local_iterator, unordered_multiset> const_local_iterator; + + unordered_multiset() = default; + + explicit + unordered_multiset(size_type __n, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __hf, __eql, __a) { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __n, + __hf, __eql, __a) { } + + unordered_multiset(const unordered_multiset&) = default; + + unordered_multiset(_Base_ref __x) + : _Base(__x._M_ref) { } + + unordered_multiset(unordered_multiset&&) = default; + + explicit + unordered_multiset(const allocator_type& __a) + : _Base(__a) { } + + unordered_multiset(const unordered_multiset& __uset, + const allocator_type& __a) + : _Base(__uset, __a) { } + + unordered_multiset(unordered_multiset&& __uset, + const allocator_type& __a) + noexcept( noexcept(_Base(std::move(__uset._M_base()), __a)) ) + : _Safe(std::move(__uset._M_safe()), __a), + _Base(std::move(__uset._M_base()), __a) { } + + unordered_multiset(initializer_list __l, + size_type __n = 0, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __n, __hf, __eql, __a) { } + + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) + { } + + unordered_multiset(size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) + { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, + const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) + { } + + template + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) + { } + + unordered_multiset(initializer_list __l, + size_type __n, + const allocator_type& __a) + : unordered_multiset(__l, __n, hasher(), key_equal(), __a) + { } + + unordered_multiset(initializer_list __l, + size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multiset(__l, __n, __hf, key_equal(), __a) + { } + + ~unordered_multiset() = default; + + unordered_multiset& + operator=(const unordered_multiset&) = default; + + unordered_multiset& + operator=(unordered_multiset&&) = default; + + unordered_multiset& + operator=(initializer_list __l) + { + this->_M_base() = __l; + this->_M_invalidate_all(); + return *this; + } + + void + swap(unordered_multiset& __x) + noexcept( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + } + + void + clear() noexcept + { + _Base::clear(); + this->_M_invalidate_all(); + } + + iterator + begin() noexcept + { return { _Base::begin(), this }; } + + const_iterator + begin() const noexcept + { return { _Base::begin(), this }; } + + iterator + end() noexcept + { return { _Base::end(), this }; } + + const_iterator + end() const noexcept + { return { _Base::end(), this }; } + + const_iterator + cbegin() const noexcept + { return { _Base::cbegin(), this }; } + + const_iterator + cend() const noexcept + { return { _Base::cend(), this }; } + + // local versions + local_iterator + begin(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + local_iterator + end(size_type __b) + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + begin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::begin(__b), this }; + } + + const_local_iterator + end(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::end(__b), this }; + } + + const_local_iterator + cbegin(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cbegin(__b), this }; + } + + const_local_iterator + cend(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return { _Base::cend(__b), this }; + } + + size_type + bucket_size(size_type __b) const + { + __glibcxx_check_bucket_index(__b); + return _Base::bucket_size(__b); + } + + float + max_load_factor() const noexcept + { return _Base::max_load_factor(); } + + void + max_load_factor(float __f) + { + __glibcxx_check_max_load_factor(__f); + _Base::max_load_factor(__f); + } + + template + iterator + emplace(_Args&&... __args) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::emplace(std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + template + iterator + emplace_hint(const_iterator __hint, _Args&&... __args) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::emplace_hint(__hint.base(), + std::forward<_Args>(__args)...); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + iterator + insert(const value_type& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__obj); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + iterator + insert(const_iterator __hint, const value_type& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), __obj); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + iterator + insert(value_type&& __obj) + { + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(std::move(__obj)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + iterator + insert(const_iterator __hint, value_type&& __obj) + { + __glibcxx_check_insert(__hint); + size_type __bucket_count = this->bucket_count(); + auto __it = _Base::insert(__hint.base(), std::move(__obj)); + _M_check_rehashed(__bucket_count); + return { __it, this }; + } + + void + insert(std::initializer_list __l) + { + size_type __bucket_count = this->bucket_count(); + _Base::insert(__l); + _M_check_rehashed(__bucket_count); + } + + template + void + insert(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + size_type __bucket_count = this->bucket_count(); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__first, __last); + + _M_check_rehashed(__bucket_count); + } + +#if __cplusplus > 201402L + using node_type = typename _Base::node_type; + + node_type + extract(const_iterator __position) + { + __glibcxx_check_erase(__position); + return _M_extract(__position.base()); + } + + node_type + extract(const key_type& __key) + { + const auto __position = _Base::find(__key); + if (__position != _Base::end()) + return _M_extract(__position); + return {}; + } + + iterator + insert(node_type&& __nh) + { return { _Base::insert(std::move(__nh)), this }; } + + iterator + insert(const_iterator __hint, node_type&& __nh) + { + __glibcxx_check_insert(__hint); + return { _Base::insert(__hint.base(), std::move(__nh)), this }; + } + + using _Base::merge; +#endif // C++17 + + iterator + find(const key_type& __key) + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + iterator + find(const _Kt& __k) + { return { _Base::find(__k), this }; } +#endif + + const_iterator + find(const key_type& __key) const + { return { _Base::find(__key), this }; } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + const_iterator + find(const _Kt& __k) const + { return { _Base::find(__k), this }; } +#endif + + std::pair + equal_range(const key_type& __key) + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + std::pair + equal_range(const key_type& __key) const + { + auto __res = _Base::equal_range(__key); + return { { __res.first, this }, { __res.second, this } }; + } + +#if __cplusplus > 201703L + template, + typename = std::__has_is_transparent_t<_Pred, _Kt>> + std::pair + equal_range(const _Kt& __k) const + { + auto __res = _Base::equal_range(__k); + return { { __res.first, this }, { __res.second, this } }; + } +#endif + + size_type + erase(const key_type& __key) + { + size_type __ret(0); + auto __pair = _Base::equal_range(__key); + for (auto __victim = __pair.first; __victim != __pair.second;) + { + _M_invalidate(__victim); + __victim = _Base::erase(__victim); + ++__ret; + } + + return __ret; + } + + iterator + erase(const_iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(iterator __it) + { + __glibcxx_check_erase(__it); + return { _M_erase(__it.base()), this }; + } + + iterator + erase(const_iterator __first, const_iterator __last) + { + __glibcxx_check_erase_range(__first, __last); + for (auto __tmp = __first.base(); __tmp != __last.base(); ++__tmp) + { + _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::cend(), + _M_message(__gnu_debug::__msg_valid_range) + ._M_iterator(__first, "first") + ._M_iterator(__last, "last")); + _M_invalidate(__tmp); + } + return { _Base::erase(__first.base(), __last.base()), this }; + } + + _Base& + _M_base() noexcept { return *this; } + + const _Base& + _M_base() const noexcept { return *this; } + + private: + void + _M_check_rehashed(size_type __prev_count) + { + if (__prev_count != this->bucket_count()) + this->_M_invalidate_all(); + } + + void + _M_invalidate(_Base_const_iterator __victim) + { + this->_M_invalidate_if( + [__victim](_Base_const_iterator __it) { return __it == __victim; }); + this->_M_invalidate_local_if( + [__victim](_Base_const_local_iterator __it) + { return __it == __victim; }); + } + + _Base_iterator + _M_erase(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + size_type __bucket_count = this->bucket_count(); + _Base_iterator __next = _Base::erase(__victim); + _M_check_rehashed(__bucket_count); + return __next; + } + +#if __cplusplus > 201402L + node_type + _M_extract(_Base_const_iterator __victim) + { + _M_invalidate(__victim); + return _Base::extract(__victim); + } +#endif + }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireNotAllocator<_Pred>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset::value_type, + hash::value_type>, + equal_to::value_type>, + _Allocator>; + + template, + typename = _RequireNotAllocatorOrIntegral<_Hash>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, + _Hash, _Allocator) + -> unordered_multiset::value_type, + _Hash, + equal_to< + typename + iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Hash, _Allocator) + -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + + template + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + noexcept(noexcept(__x.swap(__y))) + { __x.swap(__y); } + + template + inline bool + operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return __x._M_base() == __y._M_base(); } + +#if __cpp_impl_three_way_comparison < 201907L + template + inline bool + operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { return !(__x == __y); } +#endif + +} // namespace __debug +} // namespace std + +#endif // C++11 + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/vector b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/vector new file mode 100755 index 0000000..c6bdc34 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/debug/vector @@ -0,0 +1,850 @@ +// Debugging vector implementation -*- C++ -*- + +// Copyright (C) 2003-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file debug/vector + * This file is a GNU debug extension to the Standard C++ Library. + */ + +#ifndef _GLIBCXX_DEBUG_VECTOR +#define _GLIBCXX_DEBUG_VECTOR 1 + +#pragma GCC system_header + +#include +namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { + template class vector; +} } // namespace std::__debug + +#include +#include +#include +#include +#include + +namespace __gnu_debug +{ + /** @brief Base class for Debug Mode vector. + * + * Adds information about the guaranteed capacity, which is useful for + * detecting code which relies on non-portable implementation details of + * the libstdc++ reallocation policy. + */ + template + class _Safe_vector + { + typedef typename _BaseSequence::size_type size_type; + + const _SafeSequence& + _M_seq() const { return *static_cast(this); } + + protected: + _Safe_vector() _GLIBCXX_NOEXCEPT + : _M_guaranteed_capacity(0) + { _M_update_guaranteed_capacity(); } + + _Safe_vector(const _Safe_vector&) _GLIBCXX_NOEXCEPT + : _M_guaranteed_capacity(0) + { _M_update_guaranteed_capacity(); } + + _Safe_vector(size_type __n) _GLIBCXX_NOEXCEPT + : _M_guaranteed_capacity(__n) + { } + +#if __cplusplus >= 201103L + _Safe_vector(_Safe_vector&& __x) noexcept + : _Safe_vector() + { __x._M_guaranteed_capacity = 0; } + + _Safe_vector& + operator=(const _Safe_vector&) noexcept + { + _M_update_guaranteed_capacity(); + return *this; + } + + _Safe_vector& + operator=(_Safe_vector&& __x) noexcept + { + _M_update_guaranteed_capacity(); + __x._M_guaranteed_capacity = 0; + return *this; + } +#endif + + size_type _M_guaranteed_capacity; + + bool + _M_requires_reallocation(size_type __elements) const _GLIBCXX_NOEXCEPT + { return __elements > _M_seq().capacity(); } + + void + _M_update_guaranteed_capacity() _GLIBCXX_NOEXCEPT + { + if (_M_seq().size() > _M_guaranteed_capacity) + _M_guaranteed_capacity = _M_seq().size(); + } + }; +} + +namespace std _GLIBCXX_VISIBILITY(default) +{ +namespace __debug +{ + /// Class std::vector with safety/checking/debug instrumentation. + template > + class vector + : public __gnu_debug::_Safe_container< + vector<_Tp, _Allocator>, _Allocator, __gnu_debug::_Safe_sequence>, + public _GLIBCXX_STD_C::vector<_Tp, _Allocator>, + public __gnu_debug::_Safe_vector< + vector<_Tp, _Allocator>, + _GLIBCXX_STD_C::vector<_Tp, _Allocator> > + { + typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base; + typedef __gnu_debug::_Safe_container< + vector, _Allocator, __gnu_debug::_Safe_sequence> _Safe; + typedef __gnu_debug::_Safe_vector _Safe_vector; + + typedef typename _Base::iterator _Base_iterator; + typedef typename _Base::const_iterator _Base_const_iterator; + typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; + + template + friend class ::__gnu_debug::_Safe_iterator; + + // Reference wrapper for base class. Disambiguates vector(const _Base&) + // from copy constructor by requiring a user-defined conversion. + // See PR libstdc++/90102. + struct _Base_ref + { + _Base_ref(const _Base& __r) : _M_ref(__r) { } + + const _Base& _M_ref; + }; + + public: + typedef typename _Base::reference reference; + typedef typename _Base::const_reference const_reference; + + typedef __gnu_debug::_Safe_iterator< + _Base_iterator, vector> iterator; + typedef __gnu_debug::_Safe_iterator< + _Base_const_iterator, vector> const_iterator; + + typedef typename _Base::size_type size_type; + typedef typename _Base::difference_type difference_type; + + typedef _Tp value_type; + typedef _Allocator allocator_type; + typedef typename _Base::pointer pointer; + typedef typename _Base::const_pointer const_pointer; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + // 23.2.4.1 construct/copy/destroy: + +#if __cplusplus < 201103L + vector() _GLIBCXX_NOEXCEPT + : _Base() { } +#else + vector() = default; +#endif + + explicit + vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT + : _Base(__a) { } + +#if __cplusplus >= 201103L + explicit + vector(size_type __n, const _Allocator& __a = _Allocator()) + : _Base(__n, __a), _Safe_vector(__n) { } + + vector(size_type __n, const __type_identity_t<_Tp>& __value, + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } +#else + explicit + vector(size_type __n, const _Tp& __value = _Tp(), + const _Allocator& __a = _Allocator()) + : _Base(__n, __value, __a) { } +#endif + +#if __cplusplus >= 201103L + template> +#else + template +#endif + vector(_InputIterator __first, _InputIterator __last, + const _Allocator& __a = _Allocator()) + : _Base(__gnu_debug::__base( + __glibcxx_check_valid_constructor_range(__first, __last)), + __gnu_debug::__base(__last), __a) { } + +#if __cplusplus < 201103L + vector(const vector& __x) + : _Base(__x) { } + + ~vector() _GLIBCXX_NOEXCEPT { } +#else + vector(const vector&) = default; + vector(vector&&) = default; + + vector(const vector& __x, const allocator_type& __a) + : _Base(__x, __a) { } + + vector(vector&& __x, const allocator_type& __a) + noexcept( + std::is_nothrow_constructible<_Base, + _Base, const allocator_type&>::value ) + : _Safe(std::move(__x._M_safe()), __a), + _Base(std::move(__x._M_base()), __a), + _Safe_vector(std::move(__x)) { } + + vector(initializer_list __l, + const allocator_type& __a = allocator_type()) + : _Base(__l, __a) { } + + ~vector() = default; +#endif + + /// Construction from a normal-mode vector + vector(_Base_ref __x) + : _Base(__x._M_ref) { } + +#if __cplusplus < 201103L + vector& + operator=(const vector& __x) + { + this->_M_safe() = __x; + _M_base() = __x; + this->_M_update_guaranteed_capacity(); + return *this; + } +#else + vector& + operator=(const vector&) = default; + + vector& + operator=(vector&&) = default; + + vector& + operator=(initializer_list __l) + { + _M_base() = __l; + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + return *this; + } +#endif + +#if __cplusplus >= 201103L + template> +#else + template +#endif + void + assign(_InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_valid_range2(__first, __last, __dist); + + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::assign(__gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::assign(__first, __last); + + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } + + void + assign(size_type __n, const _Tp& __u) + { + _Base::assign(__n, __u); + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } + +#if __cplusplus >= 201103L + void + assign(initializer_list __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } +#endif + + using _Base::get_allocator; + + // iterators: + iterator + begin() _GLIBCXX_NOEXCEPT + { return iterator(_Base::begin(), this); } + + const_iterator + begin() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::begin(), this); } + + iterator + end() _GLIBCXX_NOEXCEPT + { return iterator(_Base::end(), this); } + + const_iterator + end() const _GLIBCXX_NOEXCEPT + { return const_iterator(_Base::end(), this); } + + reverse_iterator + rbegin() _GLIBCXX_NOEXCEPT + { return reverse_iterator(end()); } + + const_reverse_iterator + rbegin() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(end()); } + + reverse_iterator + rend() _GLIBCXX_NOEXCEPT + { return reverse_iterator(begin()); } + + const_reverse_iterator + rend() const _GLIBCXX_NOEXCEPT + { return const_reverse_iterator(begin()); } + +#if __cplusplus >= 201103L + const_iterator + cbegin() const noexcept + { return const_iterator(_Base::begin(), this); } + + const_iterator + cend() const noexcept + { return const_iterator(_Base::end(), this); } + + const_reverse_iterator + crbegin() const noexcept + { return const_reverse_iterator(end()); } + + const_reverse_iterator + crend() const noexcept + { return const_reverse_iterator(begin()); } +#endif + + // 23.2.4.2 capacity: + using _Base::size; + using _Base::max_size; + +#if __cplusplus >= 201103L + void + resize(size_type __sz) + { + bool __realloc = this->_M_requires_reallocation(__sz); + if (__sz < this->size()) + this->_M_invalidate_after_nth(__sz); + _Base::resize(__sz); + if (__realloc) + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } + + void + resize(size_type __sz, const _Tp& __c) + { + bool __realloc = this->_M_requires_reallocation(__sz); + if (__sz < this->size()) + this->_M_invalidate_after_nth(__sz); + _Base::resize(__sz, __c); + if (__realloc) + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } +#else + void + resize(size_type __sz, _Tp __c = _Tp()) + { + bool __realloc = this->_M_requires_reallocation(__sz); + if (__sz < this->size()) + this->_M_invalidate_after_nth(__sz); + _Base::resize(__sz, __c); + if (__realloc) + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } +#endif + +#if __cplusplus >= 201103L + void + shrink_to_fit() + { + if (_Base::_M_shrink_to_fit()) + { + this->_M_guaranteed_capacity = _Base::capacity(); + this->_M_invalidate_all(); + } + } +#endif + + size_type + capacity() const _GLIBCXX_NOEXCEPT + { +#ifdef _GLIBCXX_DEBUG_PEDANTIC + return this->_M_guaranteed_capacity; +#else + return _Base::capacity(); +#endif + } + + using _Base::empty; + + void + reserve(size_type __n) + { + bool __realloc = this->_M_requires_reallocation(__n); + _Base::reserve(__n); + if (__n > this->_M_guaranteed_capacity) + this->_M_guaranteed_capacity = __n; + if (__realloc) + this->_M_invalidate_all(); + } + + // element access: + reference + operator[](size_type __n) _GLIBCXX_NOEXCEPT + { + __glibcxx_check_subscript(__n); + return _M_base()[__n]; + } + + const_reference + operator[](size_type __n) const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_subscript(__n); + return _M_base()[__n]; + } + + using _Base::at; + + reference + front() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + const_reference + front() const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::front(); + } + + reference + back() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::back(); + } + + const_reference + back() const _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + return _Base::back(); + } + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 464. Suggestion for new member functions in standard containers. + using _Base::data; + + // 23.2.4.3 modifiers: + void + push_back(const _Tp& __x) + { + bool __realloc = this->_M_requires_reallocation(this->size() + 1); + _Base::push_back(__x); + if (__realloc) + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); + } + +#if __cplusplus >= 201103L + template + typename __gnu_cxx::__enable_if::__value, + void>::__type + push_back(_Tp&& __x) + { emplace_back(std::move(__x)); } + + template +#if __cplusplus > 201402L + reference +#else + void +#endif + emplace_back(_Args&&... __args) + { + bool __realloc = this->_M_requires_reallocation(this->size() + 1); + _Base::emplace_back(std::forward<_Args>(__args)...); + if (__realloc) + this->_M_invalidate_all(); + this->_M_update_guaranteed_capacity(); +#if __cplusplus > 201402L + return back(); +#endif + } +#endif + + void + pop_back() _GLIBCXX_NOEXCEPT + { + __glibcxx_check_nonempty(); + this->_M_invalidate_if(_Equal(--_Base::end())); + _Base::pop_back(); + } + +#if __cplusplus >= 201103L + template + iterator + emplace(const_iterator __position, _Args&&... __args) + { + __glibcxx_check_insert(__position); + bool __realloc = this->_M_requires_reallocation(this->size() + 1); + difference_type __offset = __position.base() - _Base::cbegin(); + _Base_iterator __res = _Base::emplace(__position.base(), + std::forward<_Args>(__args)...); + if (__realloc) + this->_M_invalidate_all(); + else + this->_M_invalidate_after_nth(__offset); + this->_M_update_guaranteed_capacity(); + return { __res, this }; + } +#endif + + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else + insert(iterator __position, const _Tp& __x) +#endif + { + __glibcxx_check_insert(__position); + bool __realloc = this->_M_requires_reallocation(this->size() + 1); + difference_type __offset = __position.base() - _Base::begin(); + _Base_iterator __res = _Base::insert(__position.base(), __x); + if (__realloc) + this->_M_invalidate_all(); + else + this->_M_invalidate_after_nth(__offset); + this->_M_update_guaranteed_capacity(); + return iterator(__res, this); + } + +#if __cplusplus >= 201103L + template + typename __gnu_cxx::__enable_if::__value, + iterator>::__type + insert(const_iterator __position, _Tp&& __x) + { return emplace(__position, std::move(__x)); } + + iterator + insert(const_iterator __position, initializer_list __l) + { return this->insert(__position, __l.begin(), __l.end()); } +#endif + +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + bool __realloc = this->_M_requires_reallocation(this->size() + __n); + difference_type __offset = __position.base() - _Base::cbegin(); + _Base_iterator __res = _Base::insert(__position.base(), __n, __x); + if (__realloc) + this->_M_invalidate_all(); + else + this->_M_invalidate_after_nth(__offset); + this->_M_update_guaranteed_capacity(); + return { __res, this }; + } +#else + void + insert(iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + bool __realloc = this->_M_requires_reallocation(this->size() + __n); + difference_type __offset = __position.base() - _Base::begin(); + _Base::insert(__position.base(), __n, __x); + if (__realloc) + this->_M_invalidate_all(); + else + this->_M_invalidate_after_nth(__offset); + this->_M_update_guaranteed_capacity(); + } +#endif + +#if __cplusplus >= 201103L + template> + iterator + insert(const_iterator __position, + _InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__position, __first, __last, __dist); + + /* Hard to guess if invalidation will occur, because __last + - __first can't be calculated in all cases, so we just + punt here by checking if it did occur. */ + _Base_iterator __old_begin = _M_base().begin(); + difference_type __offset = __position.base() - _Base::cbegin(); + _Base_iterator __res; + if (__dist.second >= __gnu_debug::__dp_sign) + __res = _Base::insert(__position.base(), + __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + __res = _Base::insert(__position.base(), __first, __last); + + if (_M_base().begin() != __old_begin) + this->_M_invalidate_all(); + else + this->_M_invalidate_after_nth(__offset); + this->_M_update_guaranteed_capacity(); + return { __res, this }; + } +#else + template + void + insert(iterator __position, + _InputIterator __first, _InputIterator __last) + { + typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; + __glibcxx_check_insert_range(__position, __first, __last, __dist); + + /* Hard to guess if invalidation will occur, because __last + - __first can't be calculated in all cases, so we just + punt here by checking if it did occur. */ + _Base_iterator __old_begin = _M_base().begin(); + difference_type __offset = __position.base() - _Base::begin(); + if (__dist.second >= __gnu_debug::__dp_sign) + _Base::insert(__position.base(), __gnu_debug::__unsafe(__first), + __gnu_debug::__unsafe(__last)); + else + _Base::insert(__position.base(), __first, __last); + + if (_M_base().begin() != __old_begin) + this->_M_invalidate_all(); + else + this->_M_invalidate_after_nth(__offset); + this->_M_update_guaranteed_capacity(); + } +#endif + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __position) +#else + erase(iterator __position) +#endif + { + __glibcxx_check_erase(__position); + difference_type __offset = __position.base() - _Base::begin(); + _Base_iterator __res = _Base::erase(__position.base()); + this->_M_invalidate_after_nth(__offset); + return iterator(__res, this); + } + + iterator +#if __cplusplus >= 201103L + erase(const_iterator __first, const_iterator __last) +#else + erase(iterator __first, iterator __last) +#endif + { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 151. can't currently clear() empty container + __glibcxx_check_erase_range(__first, __last); + + if (__first.base() != __last.base()) + { + difference_type __offset = __first.base() - _Base::begin(); + _Base_iterator __res = _Base::erase(__first.base(), + __last.base()); + this->_M_invalidate_after_nth(__offset); + return iterator(__res, this); + } + else +#if __cplusplus >= 201103L + return { _Base::begin() + (__first.base() - _Base::cbegin()), this }; +#else + return __first; +#endif + } + + void + swap(vector& __x) + _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) + { + _Safe::_M_swap(__x); + _Base::swap(__x); + std::swap(this->_M_guaranteed_capacity, __x._M_guaranteed_capacity); + } + + void + clear() _GLIBCXX_NOEXCEPT + { + _Base::clear(); + this->_M_invalidate_all(); + } + + _Base& + _M_base() _GLIBCXX_NOEXCEPT { return *this; } + + const _Base& + _M_base() const _GLIBCXX_NOEXCEPT { return *this; } + + private: + void + _M_invalidate_after_nth(difference_type __n) _GLIBCXX_NOEXCEPT + { + typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth; + this->_M_invalidate_if(_After_nth(__n, _Base::begin())); + } + }; + + template + inline bool + operator==(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() == __rhs._M_base(); } + +#if __cpp_lib_three_way_comparison + template + constexpr __detail::__synth3way_t<_Tp> + operator<=>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) + { return __x._M_base() <=> __y._M_base(); } +#else + template + inline bool + operator!=(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() != __rhs._M_base(); } + + template + inline bool + operator<(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() < __rhs._M_base(); } + + template + inline bool + operator<=(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() <= __rhs._M_base(); } + + template + inline bool + operator>=(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() >= __rhs._M_base(); } + + template + inline bool + operator>(const vector<_Tp, _Alloc>& __lhs, + const vector<_Tp, _Alloc>& __rhs) + { return __lhs._M_base() > __rhs._M_base(); } +#endif // three-way comparison + + template + inline void + swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs) + _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) + { __lhs.swap(__rhs); } + +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> vector<_ValT, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + vector(size_t, _Tp, _Allocator = _Allocator()) + -> vector<_Tp, _Allocator>; +#endif + +} // namespace __debug + +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#if __cplusplus >= 201103L + // DR 1182. + /// std::hash specialization for vector. + template + struct hash<__debug::vector> + : public __hash_base> + { + size_t + operator()(const __debug::vector& __b) const noexcept + { return std::hash<_GLIBCXX_STD_C::vector>()(__b); } + }; +#endif + +#if __cplusplus >= 201703L + namespace __detail::__variant + { + template struct _Never_valueless_alt; // see + + // Provide the strong exception-safety guarantee when emplacing a + // vector into a variant, but only if move assignment cannot throw. + template + struct _Never_valueless_alt<__debug::vector<_Tp, _Alloc>> + : std::is_nothrow_move_assignable<__debug::vector<_Tp, _Alloc>> + { }; + } // namespace __detail::__variant +#endif // C++17 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +namespace __gnu_debug +{ + template + struct _Is_contiguous_sequence > + : std::__true_type + { }; + + template + struct _Is_contiguous_sequence > + : std::__false_type + { }; +} + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/decimal/decimal b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/decimal/decimal new file mode 100755 index 0000000..486f109 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/decimal/decimal @@ -0,0 +1,494 @@ +// -*- C++ -*- + +// Copyright (C) 2009-2021 Free Software Foundation, Inc. +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file decimal/decimal + * This is a Standard C++ Library header. + */ + +// ISO/IEC TR 24733 +// Written by Janis Johnson + +#ifndef _GLIBCXX_DECIMAL +#define _GLIBCXX_DECIMAL 1 + +#pragma GCC system_header + +#include + +#ifndef _GLIBCXX_USE_DECIMAL_FLOAT +#error This file requires compiler and library support for ISO/IEC TR 24733 \ +that is currently not available. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @defgroup decimal Decimal Floating-Point Arithmetic + * @ingroup numerics + * + * Classes and functions for decimal floating-point arithmetic. + * @{ + */ + + /** @namespace std::decimal + * @brief ISO/IEC TR 24733 Decimal floating-point arithmetic. + */ +namespace decimal +{ + class decimal32; + class decimal64; + class decimal128; + + // 3.2.5 Initialization from coefficient and exponent. + static decimal32 make_decimal32(long long __coeff, int __exp); + static decimal32 make_decimal32(unsigned long long __coeff, int __exp); + static decimal64 make_decimal64(long long __coeff, int __exp); + static decimal64 make_decimal64(unsigned long long __coeff, int __exp); + static decimal128 make_decimal128(long long __coeff, int __exp); + static decimal128 make_decimal128(unsigned long long __coeff, int __exp); + + /// Non-conforming extension: Conversion to integral type. + long long decimal32_to_long_long(decimal32 __d); + long long decimal64_to_long_long(decimal64 __d); + long long decimal128_to_long_long(decimal128 __d); + long long decimal_to_long_long(decimal32 __d); + long long decimal_to_long_long(decimal64 __d); + long long decimal_to_long_long(decimal128 __d); + + // 3.2.6 Conversion to generic floating-point type. + float decimal32_to_float(decimal32 __d); + float decimal64_to_float(decimal64 __d); + float decimal128_to_float(decimal128 __d); + float decimal_to_float(decimal32 __d); + float decimal_to_float(decimal64 __d); + float decimal_to_float(decimal128 __d); + + double decimal32_to_double(decimal32 __d); + double decimal64_to_double(decimal64 __d); + double decimal128_to_double(decimal128 __d); + double decimal_to_double(decimal32 __d); + double decimal_to_double(decimal64 __d); + double decimal_to_double(decimal128 __d); + + long double decimal32_to_long_double(decimal32 __d); + long double decimal64_to_long_double(decimal64 __d); + long double decimal128_to_long_double(decimal128 __d); + long double decimal_to_long_double(decimal32 __d); + long double decimal_to_long_double(decimal64 __d); + long double decimal_to_long_double(decimal128 __d); + + // 3.2.7 Unary arithmetic operators. + decimal32 operator+(decimal32 __rhs); + decimal64 operator+(decimal64 __rhs); + decimal128 operator+(decimal128 __rhs); + decimal32 operator-(decimal32 __rhs); + decimal64 operator-(decimal64 __rhs); + decimal128 operator-(decimal128 __rhs); + + // 3.2.8 Binary arithmetic operators. +#define _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \ + _T1 operator _Op(_T2 __lhs, _T3 __rhs); +#define _DECLARE_DECIMAL_BINARY_OP_WITH_INT(_Op, _Tp) \ + _Tp operator _Op(_Tp __lhs, int __rhs); \ + _Tp operator _Op(_Tp __lhs, unsigned int __rhs); \ + _Tp operator _Op(_Tp __lhs, long __rhs); \ + _Tp operator _Op(_Tp __lhs, unsigned long __rhs); \ + _Tp operator _Op(_Tp __lhs, long long __rhs); \ + _Tp operator _Op(_Tp __lhs, unsigned long long __rhs); \ + _Tp operator _Op(int __lhs, _Tp __rhs); \ + _Tp operator _Op(unsigned int __lhs, _Tp __rhs); \ + _Tp operator _Op(long __lhs, _Tp __rhs); \ + _Tp operator _Op(unsigned long __lhs, _Tp __rhs); \ + _Tp operator _Op(long long __lhs, _Tp __rhs); \ + _Tp operator _Op(unsigned long long __lhs, _Tp __rhs); + + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128) + + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128) + + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128) + + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64) + _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128) + _DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128) + +#undef _DECLARE_DECIMAL_BINARY_OP_WITH_DEC +#undef _DECLARE_DECIMAL_BINARY_OP_WITH_INT + + // 3.2.9 Comparison operators. +#define _DECLARE_DECIMAL_COMPARISON(_Op, _Tp) \ + bool operator _Op(_Tp __lhs, decimal32 __rhs); \ + bool operator _Op(_Tp __lhs, decimal64 __rhs); \ + bool operator _Op(_Tp __lhs, decimal128 __rhs); \ + bool operator _Op(_Tp __lhs, int __rhs); \ + bool operator _Op(_Tp __lhs, unsigned int __rhs); \ + bool operator _Op(_Tp __lhs, long __rhs); \ + bool operator _Op(_Tp __lhs, unsigned long __rhs); \ + bool operator _Op(_Tp __lhs, long long __rhs); \ + bool operator _Op(_Tp __lhs, unsigned long long __rhs); \ + bool operator _Op(int __lhs, _Tp __rhs); \ + bool operator _Op(unsigned int __lhs, _Tp __rhs); \ + bool operator _Op(long __lhs, _Tp __rhs); \ + bool operator _Op(unsigned long __lhs, _Tp __rhs); \ + bool operator _Op(long long __lhs, _Tp __rhs); \ + bool operator _Op(unsigned long long __lhs, _Tp __rhs); + + _DECLARE_DECIMAL_COMPARISON(==, decimal32) + _DECLARE_DECIMAL_COMPARISON(==, decimal64) + _DECLARE_DECIMAL_COMPARISON(==, decimal128) + + _DECLARE_DECIMAL_COMPARISON(!=, decimal32) + _DECLARE_DECIMAL_COMPARISON(!=, decimal64) + _DECLARE_DECIMAL_COMPARISON(!=, decimal128) + + _DECLARE_DECIMAL_COMPARISON(<, decimal32) + _DECLARE_DECIMAL_COMPARISON(<, decimal64) + _DECLARE_DECIMAL_COMPARISON(<, decimal128) + + _DECLARE_DECIMAL_COMPARISON(>=, decimal32) + _DECLARE_DECIMAL_COMPARISON(>=, decimal64) + _DECLARE_DECIMAL_COMPARISON(>=, decimal128) + + _DECLARE_DECIMAL_COMPARISON(>, decimal32) + _DECLARE_DECIMAL_COMPARISON(>, decimal64) + _DECLARE_DECIMAL_COMPARISON(>, decimal128) + + _DECLARE_DECIMAL_COMPARISON(>=, decimal32) + _DECLARE_DECIMAL_COMPARISON(>=, decimal64) + _DECLARE_DECIMAL_COMPARISON(>=, decimal128) + +#undef _DECLARE_DECIMAL_COMPARISON + + /// 3.2.2 Class decimal32. + class decimal32 + { + public: + typedef float __decfloat32 __attribute__((mode(SD))); + + // 3.2.2.2 Construct/copy/destroy. + decimal32() : __val(0.e-101DF) {} + + // 3.2.2.3 Conversion from floating-point type. + explicit decimal32(decimal64 __d64); + explicit decimal32(decimal128 __d128); + explicit decimal32(float __r) : __val(__r) {} + explicit decimal32(double __r) : __val(__r) {} + explicit decimal32(long double __r) : __val(__r) {} + + // 3.2.2.4 Conversion from integral type. + decimal32(int __z) : __val(__z) {} + decimal32(unsigned int __z) : __val(__z) {} + decimal32(long __z) : __val(__z) {} + decimal32(unsigned long __z) : __val(__z) {} + decimal32(long long __z) : __val(__z) {} + decimal32(unsigned long long __z) : __val(__z) {} + + /// Conforming extension: Conversion from scalar decimal type. + decimal32(__decfloat32 __z) : __val(__z) {} + +#if __cplusplus >= 201103L + // 3.2.2.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif + + // 3.2.2.6 Increment and decrement operators. + decimal32& operator++() + { + __val += 1; + return *this; + } + + decimal32 operator++(int) + { + decimal32 __tmp = *this; + __val += 1; + return __tmp; + } + + decimal32& operator--() + { + __val -= 1; + return *this; + } + + decimal32 operator--(int) + { + decimal32 __tmp = *this; + __val -= 1; + return __tmp; + } + + // 3.2.2.7 Compound assignment. +#define _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(_Op) \ + decimal32& operator _Op(decimal32 __rhs); \ + decimal32& operator _Op(decimal64 __rhs); \ + decimal32& operator _Op(decimal128 __rhs); \ + decimal32& operator _Op(int __rhs); \ + decimal32& operator _Op(unsigned int __rhs); \ + decimal32& operator _Op(long __rhs); \ + decimal32& operator _Op(unsigned long __rhs); \ + decimal32& operator _Op(long long __rhs); \ + decimal32& operator _Op(unsigned long long __rhs); + + _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(+=) + _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(-=) + _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(*=) + _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(/=) +#undef _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT + + private: + __decfloat32 __val; + + public: + __decfloat32 __getval(void) { return __val; } + void __setval(__decfloat32 __x) { __val = __x; } + }; + + /// 3.2.3 Class decimal64. + class decimal64 + { + public: + typedef float __decfloat64 __attribute__((mode(DD))); + + // 3.2.3.2 Construct/copy/destroy. + decimal64() : __val(0.e-398dd) {} + + // 3.2.3.3 Conversion from floating-point type. + decimal64(decimal32 d32); + explicit decimal64(decimal128 d128); + explicit decimal64(float __r) : __val(__r) {} + explicit decimal64(double __r) : __val(__r) {} + explicit decimal64(long double __r) : __val(__r) {} + + // 3.2.3.4 Conversion from integral type. + decimal64(int __z) : __val(__z) {} + decimal64(unsigned int __z) : __val(__z) {} + decimal64(long __z) : __val(__z) {} + decimal64(unsigned long __z) : __val(__z) {} + decimal64(long long __z) : __val(__z) {} + decimal64(unsigned long long __z) : __val(__z) {} + + /// Conforming extension: Conversion from scalar decimal type. + decimal64(__decfloat64 __z) : __val(__z) {} + +#if __cplusplus >= 201103L + // 3.2.3.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif + + // 3.2.3.6 Increment and decrement operators. + decimal64& operator++() + { + __val += 1; + return *this; + } + + decimal64 operator++(int) + { + decimal64 __tmp = *this; + __val += 1; + return __tmp; + } + + decimal64& operator--() + { + __val -= 1; + return *this; + } + + decimal64 operator--(int) + { + decimal64 __tmp = *this; + __val -= 1; + return __tmp; + } + + // 3.2.3.7 Compound assignment. +#define _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(_Op) \ + decimal64& operator _Op(decimal32 __rhs); \ + decimal64& operator _Op(decimal64 __rhs); \ + decimal64& operator _Op(decimal128 __rhs); \ + decimal64& operator _Op(int __rhs); \ + decimal64& operator _Op(unsigned int __rhs); \ + decimal64& operator _Op(long __rhs); \ + decimal64& operator _Op(unsigned long __rhs); \ + decimal64& operator _Op(long long __rhs); \ + decimal64& operator _Op(unsigned long long __rhs); + + _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(+=) + _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(-=) + _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(*=) + _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(/=) +#undef _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT + + private: + __decfloat64 __val; + + public: + __decfloat64 __getval(void) { return __val; } + void __setval(__decfloat64 __x) { __val = __x; } + }; + + /// 3.2.4 Class decimal128. + class decimal128 + { + public: + typedef float __decfloat128 __attribute__((mode(TD))); + + // 3.2.4.2 Construct/copy/destroy. + decimal128() : __val(0.e-6176DL) {} + + // 3.2.4.3 Conversion from floating-point type. + decimal128(decimal32 d32); + decimal128(decimal64 d64); + explicit decimal128(float __r) : __val(__r) {} + explicit decimal128(double __r) : __val(__r) {} + explicit decimal128(long double __r) : __val(__r) {} + + + // 3.2.4.4 Conversion from integral type. + decimal128(int __z) : __val(__z) {} + decimal128(unsigned int __z) : __val(__z) {} + decimal128(long __z) : __val(__z) {} + decimal128(unsigned long __z) : __val(__z) {} + decimal128(long long __z) : __val(__z) {} + decimal128(unsigned long long __z) : __val(__z) {} + + /// Conforming extension: Conversion from scalar decimal type. + decimal128(__decfloat128 __z) : __val(__z) {} + +#if __cplusplus >= 201103L + // 3.2.4.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif + + // 3.2.4.6 Increment and decrement operators. + decimal128& operator++() + { + __val += 1; + return *this; + } + + decimal128 operator++(int) + { + decimal128 __tmp = *this; + __val += 1; + return __tmp; + } + + decimal128& operator--() + { + __val -= 1; + return *this; + } + + decimal128 operator--(int) + { + decimal128 __tmp = *this; + __val -= 1; + return __tmp; + } + + // 3.2.4.7 Compound assignment. +#define _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(_Op) \ + decimal128& operator _Op(decimal32 __rhs); \ + decimal128& operator _Op(decimal64 __rhs); \ + decimal128& operator _Op(decimal128 __rhs); \ + decimal128& operator _Op(int __rhs); \ + decimal128& operator _Op(unsigned int __rhs); \ + decimal128& operator _Op(long __rhs); \ + decimal128& operator _Op(unsigned long __rhs); \ + decimal128& operator _Op(long long __rhs); \ + decimal128& operator _Op(unsigned long long __rhs); + + _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(+=) + _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(-=) + _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(*=) + _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(/=) +#undef _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT + + private: + __decfloat128 __val; + + public: + __decfloat128 __getval(void) { return __val; } + void __setval(__decfloat128 __x) { __val = __x; } + }; + +#define _GLIBCXX_USE_DECIMAL_ 1 +} // namespace decimal + /// @} group decimal + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#include + +#endif /* _GLIBCXX_DECIMAL */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/decimal/decimal.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/decimal/decimal.h new file mode 100755 index 0000000..88921a7 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/decimal/decimal.h @@ -0,0 +1,469 @@ +// decimal classes -*- C++ -*- + +// Copyright (C) 2009-2021 Free Software Foundation, Inc. + +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file decimal/decimal.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{decimal} + */ + +// ISO/IEC TR 24733 +// Written by Janis Johnson + +#ifndef _GLIBCXX_DECIMAL_IMPL +#define _GLIBCXX_DECIMAL_IMPL 1 + +#pragma GCC system_header + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace decimal +{ + // ISO/IEC TR 24733 3.2.[234].1 Construct/copy/destroy. + + inline decimal32::decimal32(decimal64 __r) : __val(__r.__getval()) {} + inline decimal32::decimal32(decimal128 __r) : __val(__r.__getval()) {} + inline decimal64::decimal64(decimal32 __r) : __val(__r.__getval()) {} + inline decimal64::decimal64(decimal128 __r) : __val(__r.__getval()) {} + inline decimal128::decimal128(decimal32 __r) : __val(__r.__getval()) {} + inline decimal128::decimal128(decimal64 __r) : __val(__r.__getval()) {} + + // ISO/IEC TR 24733 3.2.[234].6 Compound assignment. + +#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, _T2) \ + inline _T1& _T1::operator _Op1(_T2 __rhs) \ + { \ + __setval(__getval() _Op2 __rhs.__getval()); \ + return *this; \ + } + +#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, _T2) \ + inline _T1& _T1::operator _Op1(_T2 __rhs) \ + { \ + __setval(__getval() _Op2 __rhs); \ + return *this; \ + } + +#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(_Op1, _Op2, _T1) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, decimal32) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, decimal64) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, decimal128) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, int) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, unsigned int) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, long) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, unsigned long)\ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, long long) \ + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, unsigned long long) + + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal32) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal32) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal32) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal32) + + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal64) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal64) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal64) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal64) + + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal128) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal128) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal128) + _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal128) + +#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC +#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT +#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS + + // Extension: Conversion to integral type. + + inline long long decimal32_to_long_long(decimal32 __d) + { return (long long)__d.__getval(); } + + inline long long decimal64_to_long_long(decimal64 __d) + { return (long long)__d.__getval(); } + + inline long long decimal128_to_long_long(decimal128 __d) + { return (long long)__d.__getval(); } + + inline long long decimal_to_long_long(decimal32 __d) + { return (long long)__d.__getval(); } + + inline long long decimal_to_long_long(decimal64 __d) + { return (long long)__d.__getval(); } + + inline long long decimal_to_long_long(decimal128 __d) + { return (long long)__d.__getval(); } + + // ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent. + + static decimal32 make_decimal32(long long __coeff, int __exponent) + { + decimal32 __decexp = 1, __multiplier; + + if (__exponent < 0) + { + __multiplier = 1.E-1DF; + __exponent = -__exponent; + } + else + __multiplier = 1.E1DF; + + for (int __i = 0; __i < __exponent; ++__i) + __decexp *= __multiplier; + + return __coeff * __decexp; + } + + static decimal32 make_decimal32(unsigned long long __coeff, int __exponent) + { + decimal32 __decexp = 1, __multiplier; + + if (__exponent < 0) + { + __multiplier = 1.E-1DF; + __exponent = -__exponent; + } + else + __multiplier = 1.E1DF; + + for (int __i = 0; __i < __exponent; ++__i) + __decexp *= __multiplier; + + return __coeff * __decexp; + } + + static decimal64 make_decimal64(long long __coeff, int __exponent) + { + decimal64 __decexp = 1, __multiplier; + + if (__exponent < 0) + { + __multiplier = 1.E-1DD; + __exponent = -__exponent; + } + else + __multiplier = 1.E1DD; + + for (int __i = 0; __i < __exponent; ++__i) + __decexp *= __multiplier; + + return __coeff * __decexp; + } + + static decimal64 make_decimal64(unsigned long long __coeff, int __exponent) + { + decimal64 __decexp = 1, __multiplier; + + if (__exponent < 0) + { + __multiplier = 1.E-1DD; + __exponent = -__exponent; + } + else + __multiplier = 1.E1DD; + + for (int __i = 0; __i < __exponent; ++__i) + __decexp *= __multiplier; + + return __coeff * __decexp; + } + + static decimal128 make_decimal128(long long __coeff, int __exponent) + { + decimal128 __decexp = 1, __multiplier; + + if (__exponent < 0) + { + __multiplier = 1.E-1DL; + __exponent = -__exponent; + } + else + __multiplier = 1.E1DL; + + for (int __i = 0; __i < __exponent; ++__i) + __decexp *= __multiplier; + + return __coeff * __decexp; + } + + static decimal128 make_decimal128(unsigned long long __coeff, int __exponent) + { + decimal128 __decexp = 1, __multiplier; + + if (__exponent < 0) + { + __multiplier = 1.E-1DL; + __exponent = -__exponent; + } + else + __multiplier = 1.E1DL; + + for (int __i = 0; __i < __exponent; ++__i) + __decexp *= __multiplier; + + return __coeff * __decexp; + } + + // ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type. + + inline float decimal32_to_float(decimal32 __d) + { return (float)__d.__getval(); } + + inline float decimal64_to_float(decimal64 __d) + { return (float)__d.__getval(); } + + inline float decimal128_to_float(decimal128 __d) + { return (float)__d.__getval(); } + + inline float decimal_to_float(decimal32 __d) + { return (float)__d.__getval(); } + + inline float decimal_to_float(decimal64 __d) + { return (float)__d.__getval(); } + + inline float decimal_to_float(decimal128 __d) + { return (float)__d.__getval(); } + + inline double decimal32_to_double(decimal32 __d) + { return (double)__d.__getval(); } + + inline double decimal64_to_double(decimal64 __d) + { return (double)__d.__getval(); } + + inline double decimal128_to_double(decimal128 __d) + { return (double)__d.__getval(); } + + inline double decimal_to_double(decimal32 __d) + { return (double)__d.__getval(); } + + inline double decimal_to_double(decimal64 __d) + { return (double)__d.__getval(); } + + inline double decimal_to_double(decimal128 __d) + { return (double)__d.__getval(); } + + inline long double decimal32_to_long_double(decimal32 __d) + { return (long double)__d.__getval(); } + + inline long double decimal64_to_long_double(decimal64 __d) + { return (long double)__d.__getval(); } + + inline long double decimal128_to_long_double(decimal128 __d) + { return (long double)__d.__getval(); } + + inline long double decimal_to_long_double(decimal32 __d) + { return (long double)__d.__getval(); } + + inline long double decimal_to_long_double(decimal64 __d) + { return (long double)__d.__getval(); } + + inline long double decimal_to_long_double(decimal128 __d) + { return (long double)__d.__getval(); } + + // ISO/IEC TR 24733 3.2.7 Unary arithmetic operators. + +#define _DEFINE_DECIMAL_UNARY_OP(_Op, _Tp) \ + inline _Tp operator _Op(_Tp __rhs) \ + { \ + _Tp __tmp; \ + __tmp.__setval(_Op __rhs.__getval()); \ + return __tmp; \ + } + + _DEFINE_DECIMAL_UNARY_OP(+, decimal32) + _DEFINE_DECIMAL_UNARY_OP(+, decimal64) + _DEFINE_DECIMAL_UNARY_OP(+, decimal128) + _DEFINE_DECIMAL_UNARY_OP(-, decimal32) + _DEFINE_DECIMAL_UNARY_OP(-, decimal64) + _DEFINE_DECIMAL_UNARY_OP(-, decimal128) + +#undef _DEFINE_DECIMAL_UNARY_OP + + // ISO/IEC TR 24733 3.2.8 Binary arithmetic operators. + +#define _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \ + inline _T1 operator _Op(_T2 __lhs, _T3 __rhs) \ + { \ + _T1 __retval; \ + __retval.__setval(__lhs.__getval() _Op __rhs.__getval()); \ + return __retval; \ + } + +#define _DEFINE_DECIMAL_BINARY_OP_BOTH(_Op, _T1, _T2, _T3) \ + inline _T1 operator _Op(_T2 __lhs, _T3 __rhs) \ + { \ + _T1 __retval; \ + __retval.__setval(__lhs.__getval() _Op __rhs.__getval()); \ + return __retval; \ + } + +#define _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, _T2) \ + inline _T1 operator _Op(_T1 __lhs, _T2 __rhs) \ + { \ + _T1 __retval; \ + __retval.__setval(__lhs.__getval() _Op __rhs); \ + return __retval; \ + } + +#define _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, _T2) \ + inline _T1 operator _Op(_T2 __lhs, _T1 __rhs) \ + { \ + _T1 __retval; \ + __retval.__setval(__lhs _Op __rhs.__getval()); \ + return __retval; \ + } + +#define _DEFINE_DECIMAL_BINARY_OP_WITH_INT(_Op, _T1) \ + _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, int); \ + _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned int); \ + _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long); \ + _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long); \ + _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long long); \ + _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long long); \ + _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, int); \ + _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned int); \ + _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long); \ + _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long); \ + _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long long); \ + _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long long); \ + + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128) + + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128) + + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128) + + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64) + _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128) + _DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128) + +#undef _DEFINE_DECIMAL_BINARY_OP_WITH_DEC +#undef _DEFINE_DECIMAL_BINARY_OP_BOTH +#undef _DEFINE_DECIMAL_BINARY_OP_LHS +#undef _DEFINE_DECIMAL_BINARY_OP_RHS +#undef _DEFINE_DECIMAL_BINARY_OP_WITH_INT + + // ISO/IEC TR 24733 3.2.9 Comparison operators. + +#define _DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _T1, _T2) \ + inline bool operator _Op(_T1 __lhs, _T2 __rhs) \ + { return __lhs.__getval() _Op __rhs.__getval(); } + +#define _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _T1, _T2) \ + inline bool operator _Op(_T1 __lhs, _T2 __rhs) \ + { return __lhs.__getval() _Op __rhs; } + +#define _DEFINE_DECIMAL_COMPARISON_RHS(_Op, _T1, _T2) \ + inline bool operator _Op(_T1 __lhs, _T2 __rhs) \ + { return __lhs _Op __rhs.__getval(); } + +#define _DEFINE_DECIMAL_COMPARISONS(_Op, _Tp) \ + _DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal32) \ + _DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal64) \ + _DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal128) \ + _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, int) \ + _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned int) \ + _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, long) \ + _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned long) \ + _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, long long) \ + _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned long long) \ + _DEFINE_DECIMAL_COMPARISON_RHS(_Op, int, _Tp) \ + _DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned int, _Tp) \ + _DEFINE_DECIMAL_COMPARISON_RHS(_Op, long, _Tp) \ + _DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned long, _Tp) \ + _DEFINE_DECIMAL_COMPARISON_RHS(_Op, long long, _Tp) \ + _DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned long long, _Tp) + + _DEFINE_DECIMAL_COMPARISONS(==, decimal32) + _DEFINE_DECIMAL_COMPARISONS(==, decimal64) + _DEFINE_DECIMAL_COMPARISONS(==, decimal128) + _DEFINE_DECIMAL_COMPARISONS(!=, decimal32) + _DEFINE_DECIMAL_COMPARISONS(!=, decimal64) + _DEFINE_DECIMAL_COMPARISONS(!=, decimal128) + _DEFINE_DECIMAL_COMPARISONS(<, decimal32) + _DEFINE_DECIMAL_COMPARISONS(<, decimal64) + _DEFINE_DECIMAL_COMPARISONS(<, decimal128) + _DEFINE_DECIMAL_COMPARISONS(<=, decimal32) + _DEFINE_DECIMAL_COMPARISONS(<=, decimal64) + _DEFINE_DECIMAL_COMPARISONS(<=, decimal128) + _DEFINE_DECIMAL_COMPARISONS(>, decimal32) + _DEFINE_DECIMAL_COMPARISONS(>, decimal64) + _DEFINE_DECIMAL_COMPARISONS(>, decimal128) + _DEFINE_DECIMAL_COMPARISONS(>=, decimal32) + _DEFINE_DECIMAL_COMPARISONS(>=, decimal64) + _DEFINE_DECIMAL_COMPARISONS(>=, decimal128) + +#undef _DEFINE_DECIMAL_COMPARISON_BOTH +#undef _DEFINE_DECIMAL_COMPARISON_LHS +#undef _DEFINE_DECIMAL_COMPARISON_RHS +#undef _DEFINE_DECIMAL_COMPARISONS +} // namespace decimal + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif /* _GLIBCXX_DECIMAL_IMPL */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/deque b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/deque new file mode 100755 index 0000000..c9a8211 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/deque @@ -0,0 +1,119 @@ +// -*- C++ -*- + +// Copyright (C) 2001-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/* + * + * Copyright (c) 1994 + * Hewlett-Packard Company + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Hewlett-Packard Company makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + * + * Copyright (c) 1997 + * Silicon Graphics Computer Systems, Inc. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without fee, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear + * in supporting documentation. Silicon Graphics makes no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + */ + +/** @file include/deque + * This is a Standard C++ Library header. + */ + +#ifndef _GLIBCXX_DEQUE +#define _GLIBCXX_DEQUE 1 + +#pragma GCC system_header + +#include +#if __cplusplus > 201703L +# include // For remove and remove_if +#endif // C++20 +#include +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_DEBUG +# include +#endif + +#if __cplusplus >= 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + namespace pmr + { + template class polymorphic_allocator; + template + using deque = std::deque<_Tp, polymorphic_allocator<_Tp>>; + } // namespace pmr +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++17 + +#if __cplusplus > 201703L +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 202002L + + template + inline typename deque<_Tp, _Alloc>::size_type + erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) + { + const auto __osz = __cont.size(); + __cont.erase(std::remove_if(__cont.begin(), __cont.end(), __pred), + __cont.end()); + return __osz - __cont.size(); + } + + template + inline typename deque<_Tp, _Alloc>::size_type + erase(deque<_Tp, _Alloc>& __cont, const _Up& __value) + { + const auto __osz = __cont.size(); + __cont.erase(std::remove(__cont.begin(), __cont.end(), __value), + __cont.end()); + return __osz - __cont.size(); + } +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif // C++20 + +#endif /* _GLIBCXX_DEQUE */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/exception b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/exception new file mode 100755 index 0000000..a023e22 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/exception @@ -0,0 +1,157 @@ +// Exception Handling support header for -*- C++ -*- + +// Copyright (C) 1995-2021 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file exception + * This is a Standard C++ Library header. + */ + +#ifndef __EXCEPTION__ +#define __EXCEPTION__ + +#pragma GCC system_header + +#pragma GCC visibility push(default) + +#include +#include + +extern "C++" { + +namespace std +{ + /** @addtogroup exceptions + * @{ + */ + + /** If an %exception is thrown which is not listed in a function's + * %exception specification, one of these may be thrown. + * + * @ingroup exceptions + */ + class bad_exception : public exception + { + public: + bad_exception() _GLIBCXX_USE_NOEXCEPT { } + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; + + // See comment in eh_exception.cc. + virtual const char* + what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; + }; + + /// If you write a replacement %terminate handler, it must be of this type. + typedef void (*terminate_handler) (); + + /// If you write a replacement %unexpected handler, it must be of this type. + typedef void (*unexpected_handler) (); + + /// Takes a new handler function as an argument, returns the old function. + terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + /// Return the current terminate handler. + terminate_handler get_terminate() noexcept; +#endif + + /** The runtime will call this function if %exception handling must be + * abandoned for any reason. It can also be called by the user. */ + void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__)); + + /// Takes a new handler function as an argument, returns the old function. + unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT; + +#if __cplusplus >= 201103L + /// Return the current unexpected handler. + unexpected_handler get_unexpected() noexcept; +#endif + + /** The runtime will call this function if an %exception is thrown which + * violates the function's %exception specification. */ + void unexpected() __attribute__ ((__noreturn__)); + + /** [18.6.4]/1: 'Returns true after completing evaluation of a + * throw-expression until either completing initialization of the + * exception-declaration in the matching handler or entering `unexpected()` + * due to the throw; or after entering `terminate()` for any reason + * other than an explicit call to `terminate()`. [Note: This includes + * stack unwinding [15.2]. end note]' + * + * 2: 'When `uncaught_exception()` is true, throwing an + * %exception can result in a call of 1terminate()` + * (15.5.1).' + */ + _GLIBCXX17_DEPRECATED + bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); + +#if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++98 +#define __cpp_lib_uncaught_exceptions 201411L + /** The number of uncaught exceptions. + * @since C++17, or any non-strict mode, e.g. `-std=gnu++98` + * @see uncaught_exception() + */ + int uncaught_exceptions() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); +#endif + + /// @} group exceptions +} // namespace std + +namespace __gnu_cxx +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /** + * @brief A replacement for the standard terminate_handler which + * prints more information about the terminating exception (if any) + * on stderr. + * + * @ingroup exceptions + * + * Call + * @code + * std::set_terminate(__gnu_cxx::__verbose_terminate_handler) + * @endcode + * to use. For more info, see + * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt02ch06s02.html + * + * In 3.4 and later, this is on by default. + */ + void __verbose_terminate_handler(); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +} // extern "C++" + +#pragma GCC visibility pop + +#if (__cplusplus >= 201103L) +#include +#include +#endif + +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/execution b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/execution new file mode 100755 index 0000000..cb945fb --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/execution @@ -0,0 +1,57 @@ +// -*- C++ -*- + +// Copyright (C) 2018-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +#ifndef _GLIBCXX_EXECUTION +#define _GLIBCXX_EXECUTION 1 + +#pragma GCC system_header + +#if __cplusplus >= 201703L +# include +# include + +# define _PSTL_EXECUTION_POLICIES_DEFINED 1 + +// Algorithm implementation +# if _PSTL_ALGORITHM_FORWARD_DECLARED +# include +# endif + +// Numeric implementation +# if _PSTL_NUMERIC_FORWARD_DECLARED +# include +# endif + +// Memory implementation +# if _PSTL_NUMERIC_FORWARD_DECLARED +# include +# endif + +// Feature test macro for parallel algorithms +# define __cpp_lib_parallel_algorithm 201603L +# define __cpp_lib_execution 201902L + +#endif // C++17 + +#endif /* _GLIBCXX_EXECUTION */ diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/algorithm b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/algorithm new file mode 100755 index 0000000..1b98567 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/algorithm @@ -0,0 +1,108 @@ +// -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/algorithm + * This is a TS C++ Library header. + * @ingroup libfund-ts + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_ALGORITHM +#define _GLIBCXX_EXPERIMENTAL_ALGORITHM 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +inline namespace fundamentals_v2 +{ + template + inline _ForwardIterator + search(_ForwardIterator __first, _ForwardIterator __last, + const _Searcher& __searcher) + { return __searcher(__first, __last); } + +#define __cpp_lib_experimental_sample 201402 + + /// Take a random sample from a population. + template + _SampleIterator + sample(_PopulationIterator __first, _PopulationIterator __last, + _SampleIterator __out, _Distance __n, + _UniformRandomNumberGenerator&& __g) + { + using __pop_cat = typename + std::iterator_traits<_PopulationIterator>::iterator_category; + using __samp_cat = typename + std::iterator_traits<_SampleIterator>::iterator_category; + + static_assert( + __or_, + is_convertible<__samp_cat, random_access_iterator_tag>>::value, + "output range must use a RandomAccessIterator when input range" + " does not meet the ForwardIterator requirements"); + + static_assert(is_integral<_Distance>::value, + "sample size must be an integer type"); + + typename iterator_traits<_PopulationIterator>::difference_type __d = __n; + return _GLIBCXX_STD_A:: + __sample(__first, __last, __pop_cat{}, __out, __samp_cat{}, __d, + std::forward<_UniformRandomNumberGenerator>(__g)); + } + + template + inline _SampleIterator + sample(_PopulationIterator __first, _PopulationIterator __last, + _SampleIterator __out, _Distance __n) + { + return experimental::sample(__first, __last, __out, __n, + _S_randint_engine()); + } + + template + inline void + shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) + { return std::shuffle(__first, __last, _S_randint_engine()); } + +} // namespace fundamentals_v2 +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_ALGORITHM diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/any b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/any new file mode 100755 index 0000000..3bb3e8c --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/any @@ -0,0 +1,567 @@ +// -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/any + * This is a TS C++ Library header. + * @ingroup libfund-ts + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_ANY +#define _GLIBCXX_EXPERIMENTAL_ANY 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include +#include +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +inline namespace fundamentals_v1 +{ + /** + * @defgroup any Type-safe container of any type + * @ingroup libfund-ts + * + * A type-safe container for single values of value types, as + * described in n3804 "Any Library Proposal (Revision 3)". + * + * @{ + */ + +#define __cpp_lib_experimental_any 201411 + + /** + * @brief Exception class thrown by a failed @c any_cast + * @ingroup exceptions + */ + class bad_any_cast : public bad_cast + { + public: + virtual const char* what() const noexcept { return "bad any_cast"; } + }; + + /// @cond undocumented + [[gnu::noreturn]] inline void __throw_bad_any_cast() + { +#if __cpp_exceptions + throw bad_any_cast{}; +#else + __builtin_abort(); +#endif + } + /// @endcond + + /** + * @brief A type-safe container of any type. + * + * An @c any object's state is either empty or it stores a contained object + * of CopyConstructible type. + */ + class any + { + // Holds either pointer to a heap object or the contained object itself. + union _Storage + { + // This constructor intentionally doesn't initialize anything. + _Storage() = default; + + // Prevent trivial copies of this type, buffer might hold a non-POD. + _Storage(const _Storage&) = delete; + _Storage& operator=(const _Storage&) = delete; + + void* _M_ptr; + aligned_storage::type _M_buffer; + }; + + template, + bool _Fits = (sizeof(_Tp) <= sizeof(_Storage)) + && (alignof(_Tp) <= alignof(_Storage))> + using _Internal = std::integral_constant; + + template + struct _Manager_internal; // uses small-object optimization + + template + struct _Manager_external; // creates contained object on the heap + + template + using _Manager = conditional_t<_Internal<_Tp>::value, + _Manager_internal<_Tp>, + _Manager_external<_Tp>>; + + template> + using _Decay = enable_if_t::value, _Decayed>; + + public: + // construct/destruct + + /// Default constructor, creates an empty object. + any() noexcept : _M_manager(nullptr) { } + + /// Copy constructor, copies the state of @p __other + any(const any& __other) + { + if (__other.empty()) + _M_manager = nullptr; + else + { + _Arg __arg; + __arg._M_any = this; + __other._M_manager(_Op_clone, &__other, &__arg); + } + } + + /** + * @brief Move constructor, transfer the state from @p __other + * + * @post @c __other.empty() (this postcondition is a GNU extension) + */ + any(any&& __other) noexcept + { + if (__other.empty()) + _M_manager = nullptr; + else + { + _Arg __arg; + __arg._M_any = this; + __other._M_manager(_Op_xfer, &__other, &__arg); + } + } + + /// Construct with a copy of @p __value as the contained object. + template , + typename _Mgr = _Manager<_Tp>, + typename enable_if::value, + bool>::type = true> + any(_ValueType&& __value) + : _M_manager(&_Mgr::_S_manage) + { + _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value)); + static_assert(is_copy_constructible<_Tp>::value, + "The contained object must be CopyConstructible"); + } + + /// Construct with a copy of @p __value as the contained object. + template , + typename _Mgr = _Manager<_Tp>, + typename enable_if::value, + bool>::type = false> + any(_ValueType&& __value) + : _M_manager(&_Mgr::_S_manage) + { + _Mgr::_S_create(_M_storage, __value); + static_assert(is_copy_constructible<_Tp>::value, + "The contained object must be CopyConstructible"); + } + + /// Destructor, calls @c clear() + ~any() { clear(); } + + // assignments + + /// Copy the state of another object. + any& operator=(const any& __rhs) + { + *this = any(__rhs); + return *this; + } + + /** + * @brief Move assignment operator + * + * @post @c __rhs.empty() (not guaranteed for other implementations) + */ + any& operator=(any&& __rhs) noexcept + { + if (__rhs.empty()) + clear(); + else if (this != &__rhs) + { + clear(); + _Arg __arg; + __arg._M_any = this; + __rhs._M_manager(_Op_xfer, &__rhs, &__arg); + } + return *this; + } + + /// Store a copy of @p __rhs as the contained object. + template + enable_if_t>::value, any&> + operator=(_ValueType&& __rhs) + { + *this = any(std::forward<_ValueType>(__rhs)); + return *this; + } + + // modifiers + + /// If not empty, destroy the contained object. + void clear() noexcept + { + if (!empty()) + { + _M_manager(_Op_destroy, this, nullptr); + _M_manager = nullptr; + } + } + + /// Exchange state with another object. + void swap(any& __rhs) noexcept + { + if (empty() && __rhs.empty()) + return; + + if (!empty() && !__rhs.empty()) + { + if (this == &__rhs) + return; + + any __tmp; + _Arg __arg; + __arg._M_any = &__tmp; + __rhs._M_manager(_Op_xfer, &__rhs, &__arg); + __arg._M_any = &__rhs; + _M_manager(_Op_xfer, this, &__arg); + __arg._M_any = this; + __tmp._M_manager(_Op_xfer, &__tmp, &__arg); + } + else + { + any* __empty = empty() ? this : &__rhs; + any* __full = empty() ? &__rhs : this; + _Arg __arg; + __arg._M_any = __empty; + __full->_M_manager(_Op_xfer, __full, &__arg); + } + } + + // observers + + /// Reports whether there is a contained object or not. + _GLIBCXX_NODISCARD bool empty() const noexcept { return _M_manager == nullptr; } + +#if __cpp_rtti + /// The @c typeid of the contained object, or @c typeid(void) if empty. + const type_info& type() const noexcept + { + if (empty()) + return typeid(void); + _Arg __arg; + _M_manager(_Op_get_type_info, this, &__arg); + return *__arg._M_typeinfo; + } +#endif + + template + static constexpr bool __is_valid_cast() + { return __or_, is_copy_constructible<_Tp>>::value; } + + private: + enum _Op { + _Op_access, _Op_get_type_info, _Op_clone, _Op_destroy, _Op_xfer + }; + + union _Arg + { + void* _M_obj; + const std::type_info* _M_typeinfo; + any* _M_any; + }; + + void (*_M_manager)(_Op, const any*, _Arg*); + _Storage _M_storage; + + template + friend enable_if_t::value, void*> + __any_caster(const any* __any); + + // Manage in-place contained object. + template + struct _Manager_internal + { + static void + _S_manage(_Op __which, const any* __anyp, _Arg* __arg); + + template + static void + _S_create(_Storage& __storage, _Up&& __value) + { + void* __addr = &__storage._M_buffer; + ::new (__addr) _Tp(std::forward<_Up>(__value)); + } + }; + + // Manage external contained object. + template + struct _Manager_external + { + static void + _S_manage(_Op __which, const any* __anyp, _Arg* __arg); + + template + static void + _S_create(_Storage& __storage, _Up&& __value) + { + __storage._M_ptr = new _Tp(std::forward<_Up>(__value)); + } + }; + }; + + /// Exchange the states of two @c any objects. + inline void swap(any& __x, any& __y) noexcept { __x.swap(__y); } + + /** + * @brief Access the contained object. + * + * @tparam _ValueType A const-reference or CopyConstructible type. + * @param __any The object to access. + * @return The contained object. + * @throw bad_any_cast If + * __any.type() != typeid(remove_reference_t<_ValueType>) + * + */ + template + inline _ValueType any_cast(const any& __any) + { + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + auto __p = any_cast>>(&__any); + if (__p) + return *__p; + __throw_bad_any_cast(); + } + + /** + * @brief Access the contained object. + * + * @tparam _ValueType A reference or CopyConstructible type. + * @param __any The object to access. + * @return The contained object. + * @throw bad_any_cast If + * __any.type() != typeid(remove_reference_t<_ValueType>) + * + * + * @{ + */ + template + inline _ValueType any_cast(any& __any) + { + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + auto __p = any_cast>(&__any); + if (__p) + return *__p; + __throw_bad_any_cast(); + } + + template::value + || is_lvalue_reference<_ValueType>::value, + bool>::type = true> + inline _ValueType any_cast(any&& __any) + { + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + auto __p = any_cast>(&__any); + if (__p) + return *__p; + __throw_bad_any_cast(); + } + + template::value + && !is_lvalue_reference<_ValueType>::value, + bool>::type = false> + inline _ValueType any_cast(any&& __any) + { + static_assert(any::__is_valid_cast<_ValueType>(), + "Template argument must be a reference or CopyConstructible type"); + auto __p = any_cast>(&__any); + if (__p) + return std::move(*__p); + __throw_bad_any_cast(); + } + /// @} + + /// @cond undocumented + template + enable_if_t::value, void*> + __any_caster(const any* __any) + { + // any_cast returns non-null if __any->type() == typeid(T) and + // typeid(T) ignores cv-qualifiers so remove them: + using _Up = remove_cv_t<_Tp>; + // The contained value has a decayed type, so if decay_t is not U, + // then it's not possible to have a contained value of type U. + using __does_not_decay = is_same, _Up>; + // Only copy constructible types can be used for contained values. + using __is_copyable = is_copy_constructible<_Up>; + // If the type _Tp could never be stored in an any we don't want to + // instantiate _Manager<_Tp>, so use _Manager instead, which + // is explicitly specialized and has a no-op _S_manage function. + using _Vp = conditional_t<__and_<__does_not_decay, __is_copyable>::value, + _Up, any::_Op>; + // First try comparing function addresses, which works without RTTI + if (__any->_M_manager == &any::_Manager<_Vp>::_S_manage +#if __cpp_rtti + || __any->type() == typeid(_Tp) +#endif + ) + { + any::_Arg __arg; + __any->_M_manager(any::_Op_access, __any, &__arg); + return __arg._M_obj; + } + return nullptr; + } + + // This overload exists so that std::any_cast(a) is well-formed. + template + enable_if_t::value, _Tp*> + __any_caster(const any*) noexcept + { return nullptr; } + /// @endcond + + /** + * @brief Access the contained object. + * + * @tparam _ValueType The type of the contained object. + * @param __any A pointer to the object to access. + * @return The address of the contained object if + * __any != nullptr && __any.type() == typeid(_ValueType) + * , otherwise a null pointer. + * + * @{ + */ + template + inline const _ValueType* any_cast(const any* __any) noexcept + { + if (__any) + return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); + return nullptr; + } + + template + inline _ValueType* any_cast(any* __any) noexcept + { + if (__any) + return static_cast<_ValueType*>(__any_caster<_ValueType>(__any)); + return nullptr; + } + /// @} + + template + void + any::_Manager_internal<_Tp>:: + _S_manage(_Op __which, const any* __any, _Arg* __arg) + { + // The contained object is in _M_storage._M_buffer + auto __ptr = reinterpret_cast(&__any->_M_storage._M_buffer); + switch (__which) + { + case _Op_access: + __arg->_M_obj = const_cast<_Tp*>(__ptr); + break; + case _Op_get_type_info: +#if __cpp_rtti + __arg->_M_typeinfo = &typeid(_Tp); +#endif + break; + case _Op_clone: + ::new(&__arg->_M_any->_M_storage._M_buffer) _Tp(*__ptr); + __arg->_M_any->_M_manager = __any->_M_manager; + break; + case _Op_destroy: + __ptr->~_Tp(); + break; + case _Op_xfer: + ::new(&__arg->_M_any->_M_storage._M_buffer) _Tp + (std::move(*const_cast<_Tp*>(__ptr))); + __ptr->~_Tp(); + __arg->_M_any->_M_manager = __any->_M_manager; + const_cast(__any)->_M_manager = nullptr; + break; + } + } + + template + void + any::_Manager_external<_Tp>:: + _S_manage(_Op __which, const any* __any, _Arg* __arg) + { + // The contained object is *_M_storage._M_ptr + auto __ptr = static_cast(__any->_M_storage._M_ptr); + switch (__which) + { + case _Op_access: + __arg->_M_obj = const_cast<_Tp*>(__ptr); + break; + case _Op_get_type_info: +#if __cpp_rtti + __arg->_M_typeinfo = &typeid(_Tp); +#endif + break; + case _Op_clone: + __arg->_M_any->_M_storage._M_ptr = new _Tp(*__ptr); + __arg->_M_any->_M_manager = __any->_M_manager; + break; + case _Op_destroy: + delete __ptr; + break; + case _Op_xfer: + __arg->_M_any->_M_storage._M_ptr = __any->_M_storage._M_ptr; + __arg->_M_any->_M_manager = __any->_M_manager; + const_cast(__any)->_M_manager = nullptr; + break; + } + } + + // Dummy specialization used by __any_caster. + template<> + struct any::_Manager_internal + { + static void + _S_manage(_Op, const any*, _Arg*) { } + }; + + /// @} group any +} // namespace fundamentals_v1 +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_ANY diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/array b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/array new file mode 100755 index 0000000..a282190 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/array @@ -0,0 +1,116 @@ +// -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/array + * This is a TS C++ Library header. + * @ingroup libfund-ts + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_ARRAY +#define _GLIBCXX_EXPERIMENTAL_ARRAY 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +inline namespace fundamentals_v2 +{ +#define __cpp_lib_experimental_make_array 201505 + /** + * @defgroup make_array Array creation functions + * @ingroup libfund-ts + * + * Array creation functions as described in N4529, + * Working Draft, C++ Extensions for Library Fundamentals, Version 2 + * + * @{ + */ + +template + struct __make_array_elem + { + using type = _Dest; + }; + +template + struct __make_array_elem + : common_type<_Types...> + { + template + struct __is_reference_wrapper : false_type + {}; + + template + struct __is_reference_wrapper> : true_type + {}; + + static_assert(!__or_<__is_reference_wrapper>...>::value, + "make_array must be used with an explicit target type when" + "any of the arguments is a reference_wrapper"); + }; + +/// Create a std::array from a variable-length list of arguments. +template + constexpr + array::type, sizeof...(_Types)> + make_array(_Types&&... __t) + { + return {{ std::forward<_Types>(__t)... }}; + } + +template + constexpr array, _Nm> + __to_array(_Tp (&__a)[_Nm], index_sequence<_Idx...>) + { + return {{__a[_Idx]...}}; + } + +/// Create a std::array from an array. +template + constexpr array, _Nm> + to_array(_Tp (&__a)[_Nm]) + noexcept(is_nothrow_constructible, _Tp&>::value) + { + return experimental::__to_array(__a, make_index_sequence<_Nm>{}); + } + + /// @} group make_array +} // namespace fundamentals_v2 +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_ARRAY diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_dir.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_dir.h new file mode 100755 index 0000000..320de3d --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_dir.h @@ -0,0 +1,364 @@ +// Filesystem directory utilities -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/bits/fs_dir.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{experimental/filesystem} + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_FS_DIR_H +#define _GLIBCXX_EXPERIMENTAL_FS_DIR_H 1 + +#if __cplusplus < 201103L +# include +#else +# include +# include +# include +# include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +namespace filesystem +{ +inline namespace v1 +{ + /** + * @addtogroup filesystem-ts + * @{ + */ + + class file_status + { + public: + // constructors + explicit + file_status(file_type __ft = file_type::none, + perms __prms = perms::unknown) noexcept + : _M_type(__ft), _M_perms(__prms) { } + + file_status(const file_status&) noexcept = default; + file_status(file_status&&) noexcept = default; + ~file_status() = default; + + file_status& operator=(const file_status&) noexcept = default; + file_status& operator=(file_status&&) noexcept = default; + + // observers + file_type type() const noexcept { return _M_type; } + perms permissions() const noexcept { return _M_perms; } + + // modifiers + void type(file_type __ft) noexcept { _M_type = __ft; } + void permissions(perms __prms) noexcept { _M_perms = __prms; } + + private: + file_type _M_type; + perms _M_perms; + }; + +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + + class directory_entry + { + public: + // constructors and destructor + directory_entry() noexcept = default; + directory_entry(const directory_entry&) = default; + directory_entry(directory_entry&&) noexcept = default; + explicit directory_entry(const filesystem::path& __p) : _M_path(__p) { } + ~directory_entry() = default; + + // modifiers + directory_entry& operator=(const directory_entry&) = default; + directory_entry& operator=(directory_entry&&) noexcept = default; + + void assign(const filesystem::path& __p) { _M_path = __p; } + + void + replace_filename(const filesystem::path& __p) + { _M_path = _M_path.parent_path() / __p; } + + // observers + const filesystem::path& path() const noexcept { return _M_path; } + operator const filesystem::path&() const noexcept { return _M_path; } + + file_status + status() const + { return filesystem::status(_M_path); } + + file_status + status(error_code& __ec) const noexcept + { return filesystem::status(_M_path, __ec); } + + file_status + symlink_status() const + { return filesystem::symlink_status(_M_path); } + + file_status + symlink_status(error_code& __ec) const noexcept + { return filesystem::symlink_status(_M_path, __ec); } + + bool + operator< (const directory_entry& __rhs) const noexcept + { return _M_path < __rhs._M_path; } + + bool + operator==(const directory_entry& __rhs) const noexcept + { return _M_path == __rhs._M_path; } + + bool + operator!=(const directory_entry& __rhs) const noexcept + { return _M_path != __rhs._M_path; } + + bool + operator<=(const directory_entry& __rhs) const noexcept + { return _M_path <= __rhs._M_path; } + + bool + operator> (const directory_entry& __rhs) const noexcept + { return _M_path > __rhs._M_path; } + + bool + operator>=(const directory_entry& __rhs) const noexcept + { return _M_path >= __rhs._M_path; } + + private: + filesystem::path _M_path; + }; + + struct _Dir; + class directory_iterator; + class recursive_directory_iterator; + + struct __directory_iterator_proxy + { + const directory_entry& operator*() const& noexcept { return _M_entry; } + + directory_entry operator*() && noexcept { return std::move(_M_entry); } + + private: + friend class directory_iterator; + friend class recursive_directory_iterator; + + explicit + __directory_iterator_proxy(const directory_entry& __e) : _M_entry(__e) { } + + directory_entry _M_entry; + }; + + class directory_iterator + { + public: + typedef directory_entry value_type; + typedef ptrdiff_t difference_type; + typedef const directory_entry* pointer; + typedef const directory_entry& reference; + typedef input_iterator_tag iterator_category; + + directory_iterator() = default; + + explicit + directory_iterator(const path& __p) + : directory_iterator(__p, directory_options::none, nullptr) { } + + directory_iterator(const path& __p, directory_options __options) + : directory_iterator(__p, __options, nullptr) { } + + directory_iterator(const path& __p, error_code& __ec) noexcept + : directory_iterator(__p, directory_options::none, __ec) { } + + directory_iterator(const path& __p, + directory_options __options, + error_code& __ec) noexcept + : directory_iterator(__p, __options, &__ec) { } + + directory_iterator(const directory_iterator& __rhs) = default; + + directory_iterator(directory_iterator&& __rhs) noexcept = default; + + ~directory_iterator() = default; + + directory_iterator& + operator=(const directory_iterator& __rhs) = default; + + directory_iterator& + operator=(directory_iterator&& __rhs) noexcept = default; + + const directory_entry& operator*() const; + const directory_entry* operator->() const { return &**this; } + directory_iterator& operator++(); + directory_iterator& increment(error_code& __ec) noexcept; + + __directory_iterator_proxy operator++(int) + { + __directory_iterator_proxy __pr{**this}; + ++*this; + return __pr; + } + + private: + directory_iterator(const path&, directory_options, error_code*); + + friend bool + operator==(const directory_iterator& __lhs, + const directory_iterator& __rhs); + + friend class recursive_directory_iterator; + + std::shared_ptr<_Dir> _M_dir; + }; + + inline directory_iterator + begin(directory_iterator __iter) noexcept + { return __iter; } + + inline directory_iterator + end(directory_iterator) noexcept + { return directory_iterator(); } + + inline bool + operator==(const directory_iterator& __lhs, const directory_iterator& __rhs) + { + return !__rhs._M_dir.owner_before(__lhs._M_dir) + && !__lhs._M_dir.owner_before(__rhs._M_dir); + } + + inline bool + operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs) + { return !(__lhs == __rhs); } + + class recursive_directory_iterator + { + public: + typedef directory_entry value_type; + typedef ptrdiff_t difference_type; + typedef const directory_entry* pointer; + typedef const directory_entry& reference; + typedef input_iterator_tag iterator_category; + + recursive_directory_iterator() = default; + + explicit + recursive_directory_iterator(const path& __p) + : recursive_directory_iterator(__p, directory_options::none, nullptr) { } + + recursive_directory_iterator(const path& __p, directory_options __options) + : recursive_directory_iterator(__p, __options, nullptr) { } + + recursive_directory_iterator(const path& __p, + directory_options __options, + error_code& __ec) noexcept + : recursive_directory_iterator(__p, __options, &__ec) { } + + recursive_directory_iterator(const path& __p, error_code& __ec) noexcept + : recursive_directory_iterator(__p, directory_options::none, &__ec) { } + + recursive_directory_iterator( + const recursive_directory_iterator&) = default; + + recursive_directory_iterator(recursive_directory_iterator&&) = default; + + ~recursive_directory_iterator(); + + // observers + directory_options options() const { return _M_options; } + int depth() const; + bool recursion_pending() const { return _M_pending; } + + const directory_entry& operator*() const; + const directory_entry* operator->() const { return &**this; } + + // modifiers + recursive_directory_iterator& + operator=(const recursive_directory_iterator& __rhs) noexcept; + recursive_directory_iterator& + operator=(recursive_directory_iterator&& __rhs) noexcept; + + recursive_directory_iterator& operator++(); + recursive_directory_iterator& increment(error_code& __ec) noexcept; + + __directory_iterator_proxy operator++(int) + { + __directory_iterator_proxy __pr{**this}; + ++*this; + return __pr; + } + + void pop(); + void pop(error_code&); + + void disable_recursion_pending() { _M_pending = false; } + + private: + recursive_directory_iterator(const path&, directory_options, error_code*); + + friend bool + operator==(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs); + + struct _Dir_stack; + std::shared_ptr<_Dir_stack> _M_dirs; + directory_options _M_options = {}; + bool _M_pending = false; + }; + + inline recursive_directory_iterator + begin(recursive_directory_iterator __iter) noexcept + { return __iter; } + + inline recursive_directory_iterator + end(recursive_directory_iterator) noexcept + { return recursive_directory_iterator(); } + + inline bool + operator==(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) + { + return !__rhs._M_dirs.owner_before(__lhs._M_dirs) + && !__lhs._M_dirs.owner_before(__rhs._M_dirs); + } + + inline bool + operator!=(const recursive_directory_iterator& __lhs, + const recursive_directory_iterator& __rhs) + { return !(__lhs == __rhs); } + +_GLIBCXX_END_NAMESPACE_CXX11 + + /// @} group filesystem-ts +} // namespace v1 +} // namespace filesystem +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_EXPERIMENTAL_FS_DIR_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_fwd.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_fwd.h new file mode 100755 index 0000000..8d63e09 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_fwd.h @@ -0,0 +1,308 @@ +// Filesystem declarations -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/bits/fs_fwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{experimental/filesystem} + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_FS_FWD_H +#define _GLIBCXX_EXPERIMENTAL_FS_FWD_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +namespace filesystem +{ +inline namespace v1 +{ +#if _GLIBCXX_USE_CXX11_ABI +inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +#endif + + /** + * @defgroup filesystem-ts Filesystem TS + * @ingroup experimental + * + * Utilities for performing operations on file systems and their components, + * such as paths, regular files, and directories. + * + * ISO/IEC TS 18822:2015 C++ File System Technical Specification + * + * @since C++11 + * + * @remark Link using `-lstdc++fs` to use these types and functions. + * + * @{ + */ + + class file_status; +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + class path; + class filesystem_error; + class directory_entry; + class directory_iterator; + class recursive_directory_iterator; +_GLIBCXX_END_NAMESPACE_CXX11 + + /// Information about free space on a disk + struct space_info + { + uintmax_t capacity; + uintmax_t free; + uintmax_t available; + }; + + /// Enumerated type representing the type of a file + enum class file_type : signed char { + none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3, + block = 4, character = 5, fifo = 6, socket = 7, unknown = 8 + }; + + /// Bitmask type controlling effects of `filesystem::copy` + enum class copy_options : unsigned short { + none = 0, + skip_existing = 1, overwrite_existing = 2, update_existing = 4, + recursive = 8, + copy_symlinks = 16, skip_symlinks = 32, + directories_only = 64, create_symlinks = 128, create_hard_links = 256 + }; + + /// @{ + /// @relates copy_options + constexpr copy_options + operator&(copy_options __x, copy_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr copy_options + operator|(copy_options __x, copy_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr copy_options + operator^(copy_options __x, copy_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr copy_options + operator~(copy_options __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline copy_options& + operator&=(copy_options& __x, copy_options __y) noexcept + { return __x = __x & __y; } + + inline copy_options& + operator|=(copy_options& __x, copy_options __y) noexcept + { return __x = __x | __y; } + + inline copy_options& + operator^=(copy_options& __x, copy_options __y) noexcept + { return __x = __x ^ __y; } + /// @} + + /// Bitmask type representing file access permissions + enum class perms : unsigned { + none = 0, + owner_read = 0400, + owner_write = 0200, + owner_exec = 0100, + owner_all = 0700, + group_read = 040, + group_write = 020, + group_exec = 010, + group_all = 070, + others_read = 04, + others_write = 02, + others_exec = 01, + others_all = 07, + all = 0777, + set_uid = 04000, + set_gid = 02000, + sticky_bit = 01000, + mask = 07777, + unknown = 0xFFFF, + add_perms = 0x10000, + remove_perms = 0x20000, + symlink_nofollow = 0x40000 + }; + + /// @{ + /// @relates std::experimental::filesystem::perms + constexpr perms + operator&(perms __x, perms __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr perms + operator|(perms __x, perms __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr perms + operator^(perms __x, perms __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr perms + operator~(perms __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline perms& + operator&=(perms& __x, perms __y) noexcept + { return __x = __x & __y; } + + inline perms& + operator|=(perms& __x, perms __y) noexcept + { return __x = __x | __y; } + + inline perms& + operator^=(perms& __x, perms __y) noexcept + { return __x = __x ^ __y; } + /// @} + + /// Bitmask type controlling directory iteration + enum class directory_options : unsigned char { + none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 + }; + + /// @{ + /// @relates directory_options + constexpr directory_options + operator&(directory_options __x, directory_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) & static_cast<__utype>(__y)); + } + + constexpr directory_options + operator|(directory_options __x, directory_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) | static_cast<__utype>(__y)); + } + + constexpr directory_options + operator^(directory_options __x, directory_options __y) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast( + static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); + } + + constexpr directory_options + operator~(directory_options __x) noexcept + { + using __utype = typename std::underlying_type::type; + return static_cast(~static_cast<__utype>(__x)); + } + + inline directory_options& + operator&=(directory_options& __x, directory_options __y) noexcept + { return __x = __x & __y; } + + inline directory_options& + operator|=(directory_options& __x, directory_options __y) noexcept + { return __x = __x | __y; } + + inline directory_options& + operator^=(directory_options& __x, directory_options __y) noexcept + { return __x = __x ^ __y; } + /// @} + + /// The type used for file timestamps + using file_time_type = std::chrono::system_clock::time_point; + + // operational functions + + void copy(const path& __from, const path& __to, copy_options __options); + void copy(const path& __from, const path& __to, copy_options __options, + error_code&) noexcept; + + bool copy_file(const path& __from, const path& __to, copy_options __option); + bool copy_file(const path& __from, const path& __to, copy_options __option, + error_code&) noexcept; + + path current_path(); + + file_status status(const path&); + file_status status(const path&, error_code&) noexcept; + + bool status_known(file_status) noexcept; + + file_status symlink_status(const path&); + file_status symlink_status(const path&, error_code&) noexcept; + + bool is_regular_file(file_status) noexcept; + bool is_symlink(file_status) noexcept; + + /// @} group filesystem-ts +} // namespace v1 +} // namespace filesystem +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_ops.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_ops.h new file mode 100755 index 0000000..95e2168 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_ops.h @@ -0,0 +1,301 @@ +// Filesystem operational functions -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your __option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/bits/fs_fwd.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{experimental/filesystem} + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_FS_OPS_H +#define _GLIBCXX_EXPERIMENTAL_FS_OPS_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +namespace filesystem +{ +inline namespace v1 +{ + /** + * @addtogroup filesystem-ts + * @{ + */ + + path absolute(const path& __p, const path& __base = current_path()); + + path canonical(const path& __p, const path& __base = current_path()); + path canonical(const path& __p, error_code& __ec); + path canonical(const path& __p, const path& __base, error_code& __ec); + + inline void + copy(const path& __from, const path& __to) + { copy(__from, __to, copy_options::none); } + + inline void + copy(const path& __from, const path& __to, error_code& __ec) noexcept + { copy(__from, __to, copy_options::none, __ec); } + + void copy(const path& __from, const path& __to, copy_options __options); + void copy(const path& __from, const path& __to, copy_options __options, + error_code& __ec) noexcept; + + inline bool + copy_file(const path& __from, const path& __to) + { return copy_file(__from, __to, copy_options::none); } + + inline bool + copy_file(const path& __from, const path& __to, error_code& __ec) noexcept + { return copy_file(__from, __to, copy_options::none, __ec); } + + bool copy_file(const path& __from, const path& __to, copy_options __option); + bool copy_file(const path& __from, const path& __to, copy_options __option, + error_code& __ec) noexcept; + + void copy_symlink(const path& __existing_symlink, const path& __new_symlink); + void copy_symlink(const path& __existing_symlink, const path& __new_symlink, + error_code& __ec) noexcept; + + bool create_directories(const path& __p); + bool create_directories(const path& __p, error_code& __ec) noexcept; + + bool create_directory(const path& __p); + bool create_directory(const path& __p, error_code& __ec) noexcept; + + bool create_directory(const path& __p, const path& attributes); + bool create_directory(const path& __p, const path& attributes, + error_code& __ec) noexcept; + + void create_directory_symlink(const path& __to, const path& __new_symlink); + void create_directory_symlink(const path& __to, const path& __new_symlink, + error_code& __ec) noexcept; + + void create_hard_link(const path& __to, const path& __new_hard_link); + void create_hard_link(const path& __to, const path& __new_hard_link, + error_code& __ec) noexcept; + + void create_symlink(const path& __to, const path& __new_symlink); + void create_symlink(const path& __to, const path& __new_symlink, + error_code& __ec) noexcept; + + path current_path(); + path current_path(error_code& __ec); + void current_path(const path& __p); + void current_path(const path& __p, error_code& __ec) noexcept; + + bool + equivalent(const path& __p1, const path& __p2); + + bool + equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept; + + inline bool + exists(file_status __s) noexcept + { return status_known(__s) && __s.type() != file_type::not_found; } + + inline bool + exists(const path& __p) + { return exists(status(__p)); } + + inline bool + exists(const path& __p, error_code& __ec) noexcept + { + auto __s = status(__p, __ec); + if (status_known(__s)) + { + __ec.clear(); + return __s.type() != file_type::not_found; + } + return false; + } + + uintmax_t file_size(const path& __p); + uintmax_t file_size(const path& __p, error_code& __ec) noexcept; + + uintmax_t hard_link_count(const path& __p); + uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept; + + inline bool + is_block_file(file_status __s) noexcept + { return __s.type() == file_type::block; } + + inline bool + is_block_file(const path& __p) + { return is_block_file(status(__p)); } + + inline bool + is_block_file(const path& __p, error_code& __ec) noexcept + { return is_block_file(status(__p, __ec)); } + + inline bool + is_character_file(file_status __s) noexcept + { return __s.type() == file_type::character; } + + inline bool + is_character_file(const path& __p) + { return is_character_file(status(__p)); } + + inline bool + is_character_file(const path& __p, error_code& __ec) noexcept + { return is_character_file(status(__p, __ec)); } + + inline bool + is_directory(file_status __s) noexcept + { return __s.type() == file_type::directory; } + + inline bool + is_directory(const path& __p) + { return is_directory(status(__p)); } + + inline bool + is_directory(const path& __p, error_code& __ec) noexcept + { return is_directory(status(__p, __ec)); } + + bool is_empty(const path& __p); + bool is_empty(const path& __p, error_code& __ec) noexcept; + + inline bool + is_fifo(file_status __s) noexcept + { return __s.type() == file_type::fifo; } + + inline bool + is_fifo(const path& __p) + { return is_fifo(status(__p)); } + + inline bool + is_fifo(const path& __p, error_code& __ec) noexcept + { return is_fifo(status(__p, __ec)); } + + inline bool + is_other(file_status __s) noexcept + { + return exists(__s) && !is_regular_file(__s) && !is_directory(__s) + && !is_symlink(__s); + } + + inline bool + is_other(const path& __p) + { return is_other(status(__p)); } + + inline bool + is_other(const path& __p, error_code& __ec) noexcept + { return is_other(status(__p, __ec)); } + + inline bool + is_regular_file(file_status __s) noexcept + { return __s.type() == file_type::regular; } + + inline bool + is_regular_file(const path& __p) + { return is_regular_file(status(__p)); } + + inline bool + is_regular_file(const path& __p, error_code& __ec) noexcept + { return is_regular_file(status(__p, __ec)); } + + inline bool + is_socket(file_status __s) noexcept + { return __s.type() == file_type::socket; } + + inline bool + is_socket(const path& __p) + { return is_socket(status(__p)); } + + inline bool + is_socket(const path& __p, error_code& __ec) noexcept + { return is_socket(status(__p, __ec)); } + + inline bool + is_symlink(file_status __s) noexcept + { return __s.type() == file_type::symlink; } + + inline bool + is_symlink(const path& __p) + { return is_symlink(symlink_status(__p)); } + + inline bool + is_symlink(const path& __p, error_code& __ec) noexcept + { return is_symlink(symlink_status(__p, __ec)); } + + file_time_type last_write_time(const path& __p); + file_time_type last_write_time(const path& __p, error_code& __ec) noexcept; + void last_write_time(const path& __p, file_time_type __new_time); + void last_write_time(const path& __p, file_time_type __new_time, + error_code& __ec) noexcept; + + void permissions(const path& __p, perms __prms); + void permissions(const path& __p, perms __prms, error_code& __ec) noexcept; + + path read_symlink(const path& __p); + path read_symlink(const path& __p, error_code& __ec); + + bool remove(const path& __p); + bool remove(const path& __p, error_code& __ec) noexcept; + + uintmax_t remove_all(const path& __p); + uintmax_t remove_all(const path& __p, error_code& __ec) noexcept; + + void rename(const path& __from, const path& __to); + void rename(const path& __from, const path& __to, error_code& __ec) noexcept; + + void resize_file(const path& __p, uintmax_t __size); + void resize_file(const path& __p, uintmax_t __size, error_code& __ec) noexcept; + + space_info space(const path& __p); + space_info space(const path& __p, error_code& __ec) noexcept; + + file_status status(const path& __p); + file_status status(const path& __p, error_code& __ec) noexcept; + + inline bool status_known(file_status __s) noexcept + { return __s.type() != file_type::none; } + + file_status symlink_status(const path& __p); + file_status symlink_status(const path& __p, error_code& __ec) noexcept; + + path system_complete(const path& __p); + path system_complete(const path& __p, error_code& __ec); + + path temp_directory_path(); + path temp_directory_path(error_code& __ec); + + /// @} group filesystem-ts +} // namespace v1 +} // namespace filesystem +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_EXPERIMENTAL_FS_OPS_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_path.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_path.h new file mode 100755 index 0000000..a2bc931 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/fs_path.h @@ -0,0 +1,1303 @@ +// Class filesystem::path -*- C++ -*- + +// Copyright (C) 2014-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/bits/fs_path.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{experimental/filesystem} + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_FS_PATH_H +#define _GLIBCXX_EXPERIMENTAL_FS_PATH_H 1 + +#if __cplusplus < 201103L +# include +#else + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if __cplusplus == 201402L +# include +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) +# define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1 +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace experimental +{ +namespace filesystem +{ +inline namespace v1 +{ +_GLIBCXX_BEGIN_NAMESPACE_CXX11 + +#if __cplusplus == 201402L + using std::experimental::basic_string_view; +#elif __cplusplus > 201402L + using std::basic_string_view; +#endif + + /// @cond undocumented +namespace __detail +{ + /** @addtogroup filesystem-ts + * @{ + */ + + template::type> + using __is_encoded_char + = __or_, + is_same<_Ch, wchar_t>, +#ifdef _GLIBCXX_USE_CHAR8_T + is_same<_Ch, char8_t>, +#endif + is_same<_Ch, char16_t>, + is_same<_Ch, char32_t>>; + + template> + using __is_path_iter_src + = __and_<__is_encoded_char, + std::is_base_of>; + + template + static __is_path_iter_src<_Iter> + __is_path_src(_Iter, int); + + template + static __is_encoded_char<_CharT> + __is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int); + +#if __cplusplus >= 201402L + template + static __is_encoded_char<_CharT> + __is_path_src(const basic_string_view<_CharT, _Traits>&, int); +#endif + + template + static std::false_type + __is_path_src(const _Unknown&, ...); + + template + struct __constructible_from; + + template + struct __constructible_from<_Iter, _Iter> + : __is_path_iter_src<_Iter> + { }; + + template + struct __constructible_from<_Source, void> + : decltype(__is_path_src(std::declval(), 0)) + { }; + + template::type, + typename _Tp1_noptr = typename remove_pointer<_Tp1>::type> + using _Path = typename + std::enable_if<__and_<__not_>, + __not_>, + __constructible_from<_Tp1, _Tp2>>::value, + path>::type; + + template + inline _Source + _S_range_begin(_Source __begin) { return __begin; } + + struct __null_terminated { }; + + template + inline __null_terminated + _S_range_end(_Source) { return {}; } + + template + inline const _CharT* + _S_range_begin(const basic_string<_CharT, _Traits, _Alloc>& __str) + { return __str.data(); } + + template + inline const _CharT* + _S_range_end(const basic_string<_CharT, _Traits, _Alloc>& __str) + { return __str.data() + __str.size(); } + +#if __cplusplus >= 201402L + template + inline const _CharT* + _S_range_begin(const basic_string_view<_CharT, _Traits>& __str) + { return __str.data(); } + + template + inline const _CharT* + _S_range_end(const basic_string_view<_CharT, _Traits>& __str) + { return __str.data() + __str.size(); } +#endif + + template())), + typename _Val = typename std::iterator_traits<_Iter>::value_type, + typename _UnqualVal = typename std::remove_const<_Val>::type> + using __value_type_is_char = typename std::enable_if< + std::is_same<_UnqualVal, char>::value, + _UnqualVal>::type; + + template())), + typename _Val = typename std::iterator_traits<_Iter>::value_type, + typename _UnqualVal = typename std::remove_const<_Val>::type> + using __value_type_is_char_or_char8_t = typename std::enable_if< + __or_< + std::is_same<_UnqualVal, char> +#ifdef _GLIBCXX_USE_CHAR8_T + ,std::is_same<_UnqualVal, char8_t> +#endif + >::value, _UnqualVal>::type; + + /// @} group filesystem-ts +} // namespace __detail + /// @endcond + + /** @addtogroup filesystem-ts + * @{ + */ + + /// A filesystem path. + /// @ingroup filesystem-ts + class path + { + public: +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + typedef wchar_t value_type; + static constexpr value_type preferred_separator = L'\\'; +#else + typedef char value_type; + static constexpr value_type preferred_separator = '/'; +#endif + typedef std::basic_string string_type; + + // constructors and destructor + + path() noexcept { } + + path(const path& __p) = default; + + path(path&& __p) noexcept + : _M_pathname(std::move(__p._M_pathname)), _M_type(__p._M_type) + { + if (_M_type == _Type::_Multi) + _M_split_cmpts(); + __p.clear(); + } + + path(string_type&& __source) + : _M_pathname(std::move(__source)) + { _M_split_cmpts(); } + + template> + path(_Source const& __source) + : _M_pathname(_S_convert(__detail::_S_range_begin(__source), + __detail::_S_range_end(__source))) + { _M_split_cmpts(); } + + template> + path(_InputIterator __first, _InputIterator __last) + : _M_pathname(_S_convert(__first, __last)) + { _M_split_cmpts(); } + + template, + typename _Require2 = __detail::__value_type_is_char<_Source>> + path(_Source const& __source, const locale& __loc) + : _M_pathname(_S_convert_loc(__detail::_S_range_begin(__source), + __detail::_S_range_end(__source), __loc)) + { _M_split_cmpts(); } + + template, + typename _Require2 = __detail::__value_type_is_char<_InputIterator>> + path(_InputIterator __first, _InputIterator __last, const locale& __loc) + : _M_pathname(_S_convert_loc(__first, __last, __loc)) + { _M_split_cmpts(); } + + ~path() = default; + + // assignments + + path& operator=(const path& __p) = default; + path& operator=(path&& __p) noexcept; + path& operator=(string_type&& __source); + path& assign(string_type&& __source); + + template + __detail::_Path<_Source>& + operator=(_Source const& __source) + { return *this = path(__source); } + + template + __detail::_Path<_Source>& + assign(_Source const& __source) + { return *this = path(__source); } + + template + __detail::_Path<_InputIterator, _InputIterator>& + assign(_InputIterator __first, _InputIterator __last) + { return *this = path(__first, __last); } + + // appends + + path& operator/=(const path& __p) { return _M_append(__p._M_pathname); } + + template + __detail::_Path<_Source>& + operator/=(_Source const& __source) + { return append(__source); } + + template + __detail::_Path<_Source>& + append(_Source const& __source) + { + return _M_append(_S_convert(__detail::_S_range_begin(__source), + __detail::_S_range_end(__source))); + } + + template + __detail::_Path<_InputIterator, _InputIterator>& + append(_InputIterator __first, _InputIterator __last) + { return _M_append(_S_convert(__first, __last)); } + + // concatenation + + path& operator+=(const path& __x); + path& operator+=(const string_type& __x); + path& operator+=(const value_type* __x); + path& operator+=(value_type __x); +#if __cplusplus >= 201402L + path& operator+=(basic_string_view __x); +#endif + + template + __detail::_Path<_Source>& + operator+=(_Source const& __x) { return concat(__x); } + + template + __detail::_Path<_CharT*, _CharT*>& + operator+=(_CharT __x); + + template + __detail::_Path<_Source>& + concat(_Source const& __x) + { + return *this += _S_convert(__detail::_S_range_begin(__x), + __detail::_S_range_end(__x)); + } + + template + __detail::_Path<_InputIterator, _InputIterator>& + concat(_InputIterator __first, _InputIterator __last) + { return *this += _S_convert(__first, __last); } + + // modifiers + + void clear() noexcept { _M_pathname.clear(); _M_split_cmpts(); } + + path& make_preferred(); + path& remove_filename(); + path& replace_filename(const path& __replacement); + path& replace_extension(const path& __replacement = path()); + + void swap(path& __rhs) noexcept; + + // native format observers + + const string_type& native() const noexcept { return _M_pathname; } + const value_type* c_str() const noexcept { return _M_pathname.c_str(); } + operator string_type() const { return _M_pathname; } + + template, + typename _Allocator = std::allocator<_CharT>> + std::basic_string<_CharT, _Traits, _Allocator> + string(const _Allocator& __a = _Allocator()) const; + + std::string string() const; +#if _GLIBCXX_USE_WCHAR_T + std::wstring wstring() const; +#endif +#ifdef _GLIBCXX_USE_CHAR8_T + __attribute__((__abi_tag__("__u8"))) + std::u8string u8string() const; +#else + std::string u8string() const; +#endif // _GLIBCXX_USE_CHAR8_T + std::u16string u16string() const; + std::u32string u32string() const; + + // generic format observers + template, + typename _Allocator = std::allocator<_CharT>> + std::basic_string<_CharT, _Traits, _Allocator> + generic_string(const _Allocator& __a = _Allocator()) const; + + std::string generic_string() const; +#if _GLIBCXX_USE_WCHAR_T + std::wstring generic_wstring() const; +#endif +#ifdef _GLIBCXX_USE_CHAR8_T + __attribute__((__abi_tag__("__u8"))) + std::u8string generic_u8string() const; +#else + std::string generic_u8string() const; +#endif // _GLIBCXX_USE_CHAR8_T + std::u16string generic_u16string() const; + std::u32string generic_u32string() const; + + // compare + + int compare(const path& __p) const noexcept; + int compare(const string_type& __s) const; + int compare(const value_type* __s) const; +#if __cplusplus >= 201402L + int compare(const basic_string_view __s) const; +#endif + + // decomposition + + path root_name() const; + path root_directory() const; + path root_path() const; + path relative_path() const; + path parent_path() const; + path filename() const; + path stem() const; + path extension() const; + + // query + + _GLIBCXX_NODISCARD bool empty() const noexcept { return _M_pathname.empty(); } + bool has_root_name() const; + bool has_root_directory() const; + bool has_root_path() const; + bool has_relative_path() const; + bool has_parent_path() const; + bool has_filename() const; + bool has_stem() const; + bool has_extension() const; + bool is_absolute() const; + bool is_relative() const { return !is_absolute(); } + + // iterators + class iterator; + typedef iterator const_iterator; + + iterator begin() const; + iterator end() const; + + /// @cond undocumented + // Create a basic_string by reading until a null character. + template, + typename _CharT + = typename std::remove_cv::type> + static std::basic_string<_CharT> + _S_string_from_iter(_InputIterator __source) + { + std::basic_string<_CharT> __str; + for (_CharT __ch = *__source; __ch != _CharT(); __ch = *++__source) + __str.push_back(__ch); + return __str; + } + /// @endcond + + private: + enum class _Type : unsigned char { + _Multi, _Root_name, _Root_dir, _Filename + }; + + path(string_type __str, _Type __type) : _M_pathname(__str), _M_type(__type) + { + __glibcxx_assert(!empty()); + __glibcxx_assert(_M_type != _Type::_Multi); + } + + enum class _Split { _Stem, _Extension }; + + path& _M_append(const string_type& __str) + { + if (!_M_pathname.empty() && !_S_is_dir_sep(_M_pathname.back()) + && !__str.empty() && !_S_is_dir_sep(__str.front())) + _M_pathname += preferred_separator; + _M_pathname += __str; + _M_split_cmpts(); + return *this; + } + + pair _M_find_extension() const; + + template + struct _Cvt; + + static string_type + _S_convert(value_type* __src, __detail::__null_terminated) + { return string_type(__src); } + + static string_type + _S_convert(const value_type* __src, __detail::__null_terminated) + { return string_type(__src); } + + template + static string_type + _S_convert(_Iter __first, _Iter __last) + { + using __value_type = typename std::iterator_traits<_Iter>::value_type; + return _Cvt::type>:: + _S_convert(__first, __last); + } + + template + static string_type + _S_convert(_InputIterator __src, __detail::__null_terminated) + { + auto __s = _S_string_from_iter(__src); + return _S_convert(__s.c_str(), __s.c_str() + __s.size()); + } + + static string_type + _S_convert_loc(const char* __first, const char* __last, + const std::locale& __loc); + + static string_type + _S_convert_loc(char* __first, char* __last, const std::locale& __loc) + { + return _S_convert_loc(const_cast(__first), + const_cast(__last), __loc); + } + + template + static string_type + _S_convert_loc(_Iter __first, _Iter __last, const std::locale& __loc) + { + const std::string __str(__first, __last); + return _S_convert_loc(__str.data(), __str.data()+__str.size(), __loc); + } + + template + static string_type + _S_convert_loc(_InputIterator __src, __detail::__null_terminated, + const std::locale& __loc) + { + const std::string __s = _S_string_from_iter(__src); + return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc); + } + + static bool _S_is_dir_sep(value_type __ch) + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return __ch == L'/' || __ch == preferred_separator; +#else + return __ch == '/'; +#endif + } + + void _M_split_cmpts(); + void _M_trim(); + void _M_add_root_name(size_t __n); + void _M_add_root_dir(size_t __pos); + void _M_add_filename(size_t __pos, size_t __n); + + string_type _M_pathname; + + struct _Cmpt; + using _List = _GLIBCXX_STD_C::vector<_Cmpt>; + _List _M_cmpts; // empty unless _M_type == _Type::_Multi + _Type _M_type = _Type::_Multi; + }; + + /// @relates std::experimental::filesystem::path @{ + + /// Swap overload for paths + inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } + + /// Compute a hash value for a path + size_t hash_value(const path& __p) noexcept; + + /// Compare paths + inline bool operator<(const path& __lhs, const path& __rhs) noexcept; + + /// Compare paths + inline bool operator<=(const path& __lhs, const path& __rhs) noexcept + { return !(__rhs < __lhs); } + + /// Compare paths + inline bool operator>(const path& __lhs, const path& __rhs) noexcept + { return __rhs < __lhs; } + + /// Compare paths + inline bool operator>=(const path& __lhs, const path& __rhs) noexcept + { return !(__lhs < __rhs); } + + /// Compare paths + inline bool operator==(const path& __lhs, const path& __rhs) noexcept; + + /// Compare paths + inline bool operator!=(const path& __lhs, const path& __rhs) noexcept + { return !(__lhs == __rhs); } + + /// Append one path to another + inline path operator/(const path& __lhs, const path& __rhs) + { + path __result(__lhs); + __result /= __rhs; + return __result; + } + + /// Write a path to a stream + template + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) + { + auto __tmp = __p.string<_CharT, _Traits>(); + using __quoted_string + = std::__detail::_Quoted_string; + __os << __quoted_string{__tmp, _CharT('"'), _CharT('\\')}; + return __os; + } + + /// Read a path from a stream + template + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) + { + basic_string<_CharT, _Traits> __tmp; + using __quoted_string + = std::__detail::_Quoted_string; + if (__is >> __quoted_string{ __tmp, _CharT('"'), _CharT('\\') }) + __p = std::move(__tmp); + return __is; + } + + /// Create a path from a UTF-8-encoded sequence of char +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + template + inline path + __u8path(_InputIterator __first, _InputIterator __last, char) + { + // XXX This assumes native wide encoding is UTF-16. + std::codecvt_utf8_utf16 __cvt; + path::string_type __tmp; + const std::string __u8str{__first, __last}; + const char* const __ptr = __u8str.data(); + if (__str_codecvt_in_all(__ptr, __ptr + __u8str.size(), __tmp, __cvt)) + return path{ __tmp }; + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); + } + +#ifdef _GLIBCXX_USE_CHAR8_T + template + inline path + __u8path(_InputIterator __first, _InputIterator __last, char8_t) + { + return path{ __first, __last }; + } +#endif // _GLIBCXX_USE_CHAR8_T +#endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS + + template, + typename _CharT = + __detail::__value_type_is_char_or_char8_t<_InputIterator>> + inline path + u8path(_InputIterator __first, _InputIterator __last) + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return __u8path(__first, __last, _CharT{}); +#else + return path{ __first, __last }; +#endif + } + + /// Create a path from a UTF-8-encoded sequence of char +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + inline path + __u8path(const string& __s, char) + { + return filesystem::u8path(__s.data(), __s.data() + __s.size()); + } + + template + inline __enable_if_t::value, path> + __u8path(const _Source& __source, char) + { + std::string __s = __source; + return filesystem::u8path(__s.data(), __s.data() + __s.size()); + } + + template + inline __enable_if_t::value, path> + __u8path(const _Source& __source, char) + { + std::string __s = path::_S_string_from_iter(__source); + return filesystem::u8path(__s.data(), __s.data() + __s.size()); + } + +#ifdef _GLIBCXX_USE_CHAR8_T + template + inline path + __u8path(const _Source& __source, char8_t) + { + return path{ __source }; + } +#endif // _GLIBCXX_USE_CHAR8_T +#endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS + + template, + typename _CharT = + __detail::__value_type_is_char_or_char8_t<_Source>> + inline path + u8path(const _Source& __source) + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return __u8path(__source, _CharT{}); +#else + return path{ __source }; +#endif + } + + /// @} + + /// Exception type thrown by the Filesystem TS library + class filesystem_error : public std::system_error + { + public: + filesystem_error(const string& __what_arg, error_code __ec) + : system_error(__ec, __what_arg) { } + + filesystem_error(const string& __what_arg, const path& __p1, + error_code __ec) + : system_error(__ec, __what_arg), _M_path1(__p1) { } + + filesystem_error(const string& __what_arg, const path& __p1, + const path& __p2, error_code __ec) + : system_error(__ec, __what_arg), _M_path1(__p1), _M_path2(__p2) + { } + + ~filesystem_error(); + + const path& path1() const noexcept { return _M_path1; } + const path& path2() const noexcept { return _M_path2; } + const char* what() const noexcept { return _M_what.c_str(); } + + private: + std::string _M_gen_what(); + + path _M_path1; + path _M_path2; + std::string _M_what = _M_gen_what(); + }; + + /// @cond undocumented + struct path::_Cmpt : path + { + _Cmpt(string_type __s, _Type __t, size_t __pos) + : path(std::move(__s), __t), _M_pos(__pos) { } + + _Cmpt() : _M_pos(-1) { } + + size_t _M_pos; + }; + + // specialize _Cvt for degenerate 'noconv' case + template<> + struct path::_Cvt + { + template + static string_type + _S_convert(_Iter __first, _Iter __last) + { return string_type{__first, __last}; } + }; + + template + struct path::_Cvt + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS +#ifdef _GLIBCXX_USE_CHAR8_T + static string_type + _S_wconvert(const char8_t* __f, const char8_t* __l, const char8_t*) + { + const char* __f2 = (const char*)__f; + const char* __l2 = (const char*)__l; + std::wstring __wstr; + std::codecvt_utf8_utf16 __wcvt; + if (__str_codecvt_in_all(__f2, __l2, __wstr, __wcvt)) + return __wstr; + } +#endif + + static string_type + _S_wconvert(const char* __f, const char* __l, const char*) + { + using _Cvt = std::codecvt; + const auto& __cvt = std::use_facet<_Cvt>(std::locale{}); + std::wstring __wstr; + if (__str_codecvt_in_all(__f, __l, __wstr, __cvt)) + return __wstr; + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); + } + + static string_type + _S_wconvert(const _CharT* __f, const _CharT* __l, const void*) + { + struct _UCvt : std::codecvt<_CharT, char, std::mbstate_t> + { } __cvt; + std::string __str; + if (__str_codecvt_out_all(__f, __l, __str, __cvt)) + { + const char* __f2 = __str.data(); + const char* __l2 = __f2 + __str.size(); + std::codecvt_utf8_utf16 __wcvt; + std::wstring __wstr; + if (__str_codecvt_in_all(__f2, __l2, __wstr, __wcvt)) + return __wstr; + } + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); + } + + static string_type + _S_convert(const _CharT* __f, const _CharT* __l) + { + return _S_wconvert(__f, __l, (const _CharT*)nullptr); + } +#else + static string_type + _S_convert(const _CharT* __f, const _CharT* __l) + { +#ifdef _GLIBCXX_USE_CHAR8_T + if constexpr (is_same<_CharT, char8_t>::value) + return string_type(__f, __l); + else +#endif + { + struct _UCvt : std::codecvt<_CharT, char, std::mbstate_t> + { } __cvt; + std::string __str; + if (__str_codecvt_out_all(__f, __l, __str, __cvt)) + return __str; + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); + } + } +#endif + + static string_type + _S_convert(_CharT* __f, _CharT* __l) + { + return _S_convert(const_cast(__f), + const_cast(__l)); + } + + template + static string_type + _S_convert(_Iter __first, _Iter __last) + { + const std::basic_string<_CharT> __str(__first, __last); + return _S_convert(__str.data(), __str.data() + __str.size()); + } + + template + static string_type + _S_convert(__gnu_cxx::__normal_iterator<_Iter, _Cont> __first, + __gnu_cxx::__normal_iterator<_Iter, _Cont> __last) + { return _S_convert(__first.base(), __last.base()); } + }; + /// @endcond + + /// An iterator for the components of a path + class path::iterator + { + public: + using difference_type = std::ptrdiff_t; + using value_type = path; + using reference = const path&; + using pointer = const path*; + using iterator_category = std::bidirectional_iterator_tag; + + iterator() : _M_path(nullptr), _M_cur(), _M_at_end() { } + + iterator(const iterator&) = default; + iterator& operator=(const iterator&) = default; + + reference operator*() const; + pointer operator->() const { return std::__addressof(**this); } + + iterator& operator++(); + iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; } + + iterator& operator--(); + iterator operator--(int) { auto __tmp = *this; --*this; return __tmp; } + + friend bool operator==(const iterator& __lhs, const iterator& __rhs) + { return __lhs._M_equals(__rhs); } + + friend bool operator!=(const iterator& __lhs, const iterator& __rhs) + { return !__lhs._M_equals(__rhs); } + + private: + friend class path; + + iterator(const path* __path, path::_List::const_iterator __iter) + : _M_path(__path), _M_cur(__iter), _M_at_end() + { } + + iterator(const path* __path, bool __at_end) + : _M_path(__path), _M_cur(), _M_at_end(__at_end) + { } + + bool _M_equals(iterator) const; + + const path* _M_path; + path::_List::const_iterator _M_cur; + bool _M_at_end; // only used when type != _Multi + }; + + + inline path& + path::operator=(path&& __p) noexcept + { + _M_pathname = std::move(__p._M_pathname); + _M_cmpts = std::move(__p._M_cmpts); + _M_type = __p._M_type; + __p.clear(); + return *this; + } + + inline path& + path::operator=(string_type&& __source) + { return *this = path(std::move(__source)); } + + inline path& + path::assign(string_type&& __source) + { return *this = path(std::move(__source)); } + + inline path& + path::operator+=(const path& __p) + { + return operator+=(__p.native()); + } + + inline path& + path::operator+=(const string_type& __x) + { + _M_pathname += __x; + _M_split_cmpts(); + return *this; + } + + inline path& + path::operator+=(const value_type* __x) + { + _M_pathname += __x; + _M_split_cmpts(); + return *this; + } + + inline path& + path::operator+=(value_type __x) + { + _M_pathname += __x; + _M_split_cmpts(); + return *this; + } + +#if __cplusplus >= 201402L + inline path& + path::operator+=(basic_string_view __x) + { + _M_pathname.append(__x.data(), __x.size()); + _M_split_cmpts(); + return *this; + } +#endif + + template + inline __detail::_Path<_CharT*, _CharT*>& + path::operator+=(_CharT __x) + { + auto* __addr = std::__addressof(__x); + return concat(__addr, __addr + 1); + } + + inline path& + path::make_preferred() + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::replace(_M_pathname.begin(), _M_pathname.end(), L'/', + preferred_separator); +#endif + return *this; + } + + inline void path::swap(path& __rhs) noexcept + { + _M_pathname.swap(__rhs._M_pathname); + _M_cmpts.swap(__rhs._M_cmpts); + std::swap(_M_type, __rhs._M_type); + } + + template + inline std::basic_string<_CharT, _Traits, _Allocator> + path::string(const _Allocator& __a) const + { + if (is_same<_CharT, value_type>::value) + return { _M_pathname.begin(), _M_pathname.end(), __a }; + + using _WString = basic_string<_CharT, _Traits, _Allocator>; + + const value_type* __first = _M_pathname.data(); + const value_type* __last = __first + _M_pathname.size(); + +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + using _CharAlloc = __alloc_rebind<_Allocator, char>; + using _String = basic_string, _CharAlloc>; + + // First convert native string from UTF-16 to to UTF-8. + // XXX This assumes that the execution wide-character set is UTF-16. + codecvt_utf8_utf16 __cvt; + _String __u8str{_CharAlloc{__a}}; + if (__str_codecvt_out_all(__first, __last, __u8str, __cvt)) + { + struct + { + const _String* + operator()(const _String& __from, _String&, true_type) + { return std::__addressof(__from); } + + _WString* + operator()(const _String& __from, _WString& __to, false_type) + { +#ifdef _GLIBCXX_USE_CHAR8_T + if constexpr (is_same<_CharT, char8_t>::value) + { + __to.assign(__from.begin(), __from.end()); + return std::__addressof(__to); + } + else +#endif + { + // Convert UTF-8 to wide string. + struct _UCvt : std::codecvt<_CharT, char, std::mbstate_t> + { } __cvt; + const char* __f = __from.data(); + const char* __l = __f + __from.size(); + if (__str_codecvt_in_all(__f, __l, __to, __cvt)) + return std::__addressof(__to); + } + return nullptr; + } + } __dispatch; + _WString __wstr(__a); + if (auto* __p = __dispatch(__u8str, __wstr, is_same<_CharT, char>{})) + return *__p; + } +#else +#ifdef _GLIBCXX_USE_CHAR8_T + if constexpr (is_same<_CharT, char8_t>::value) + return _WString(__first, __last, __a); + else +#endif + { + struct _UCvt : std::codecvt<_CharT, char, std::mbstate_t> { } __cvt; + _WString __wstr(__a); + if (__str_codecvt_in_all(__first, __last, __wstr, __cvt)) + return __wstr; + } +#endif + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); + } + + inline std::string + path::string() const { return string(); } + +#if _GLIBCXX_USE_WCHAR_T + inline std::wstring + path::wstring() const { return string(); } +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + inline std::u8string + path::u8string() const { return string(); } +#else + inline std::string + path::u8string() const + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + std::string __str; + // convert from native wide encoding (assumed to be UTF-16) to UTF-8 + std::codecvt_utf8_utf16 __cvt; + const value_type* __first = _M_pathname.data(); + const value_type* __last = __first + _M_pathname.size(); + if (__str_codecvt_out_all(__first, __last, __str, __cvt)) + return __str; + _GLIBCXX_THROW_OR_ABORT(filesystem_error( + "Cannot convert character sequence", + std::make_error_code(errc::illegal_byte_sequence))); +#else + return _M_pathname; +#endif + } +#endif // _GLIBCXX_USE_CHAR8_T + + inline std::u16string + path::u16string() const { return string(); } + + inline std::u32string + path::u32string() const { return string(); } + + template + inline std::basic_string<_CharT, _Traits, _Allocator> + path::generic_string(const _Allocator& __a) const + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + const _CharT __slash = is_same<_CharT, wchar_t>::value + ? _CharT(L'/') + : _CharT('/'); // Assume value is correct for the encoding. +#else + const _CharT __slash = _CharT('/'); +#endif + basic_string<_CharT, _Traits, _Allocator> __str(__a); + __str.reserve(_M_pathname.size()); + bool __add_slash = false; + for (auto& __elem : *this) + { + if (__elem._M_type == _Type::_Root_dir) + { + __str += __slash; + continue; + } + if (__add_slash) + __str += __slash; + __str += __elem.string<_CharT, _Traits, _Allocator>(__a); + __add_slash = __elem._M_type == _Type::_Filename; + } + return __str; + } + + inline std::string + path::generic_string() const { return generic_string(); } + +#if _GLIBCXX_USE_WCHAR_T + inline std::wstring + path::generic_wstring() const { return generic_string(); } +#endif + +#ifdef _GLIBCXX_USE_CHAR8_T + inline std::u8string + path::generic_u8string() const { return generic_string(); } +#else + inline std::string + path::generic_u8string() const { return generic_string(); } +#endif + + inline std::u16string + path::generic_u16string() const { return generic_string(); } + + inline std::u32string + path::generic_u32string() const { return generic_string(); } + + inline int + path::compare(const string_type& __s) const { return compare(path(__s)); } + + inline int + path::compare(const value_type* __s) const { return compare(path(__s)); } + +#if __cplusplus >= 201402L + inline int + path::compare(basic_string_view __s) const + { return compare(path(__s)); } +#endif + + inline path + path::filename() const { return empty() ? path() : *--end(); } + + inline path + path::stem() const + { + auto ext = _M_find_extension(); + if (ext.first && ext.second != 0) + return path{ext.first->substr(0, ext.second)}; + return {}; + } + + inline path + path::extension() const + { + auto ext = _M_find_extension(); + if (ext.first && ext.second != string_type::npos) + return path{ext.first->substr(ext.second)}; + return {}; + } + + inline bool + path::has_stem() const + { + auto ext = _M_find_extension(); + return ext.first && ext.second != 0; + } + + inline bool + path::has_extension() const + { + auto ext = _M_find_extension(); + return ext.first && ext.second != string_type::npos; + } + + inline bool + path::is_absolute() const + { +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + return has_root_name() && has_root_directory(); +#else + return has_root_directory(); +#endif + } + + inline path::iterator + path::begin() const + { + if (_M_type == _Type::_Multi) + return iterator(this, _M_cmpts.begin()); + return iterator(this, false); + } + + inline path::iterator + path::end() const + { + if (_M_type == _Type::_Multi) + return iterator(this, _M_cmpts.end()); + return iterator(this, true); + } + + inline path::iterator& + path::iterator::operator++() + { + __glibcxx_assert(_M_path != nullptr); + if (_M_path->_M_type == _Type::_Multi) + { + __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end()); + ++_M_cur; + } + else + { + __glibcxx_assert(!_M_at_end); + _M_at_end = true; + } + return *this; + } + + inline path::iterator& + path::iterator::operator--() + { + __glibcxx_assert(_M_path != nullptr); + if (_M_path->_M_type == _Type::_Multi) + { + __glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin()); + --_M_cur; + } + else + { + __glibcxx_assert(_M_at_end); + _M_at_end = false; + } + return *this; + } + + inline path::iterator::reference + path::iterator::operator*() const + { + __glibcxx_assert(_M_path != nullptr); + if (_M_path->_M_type == _Type::_Multi) + { + __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end()); + return *_M_cur; + } + return *_M_path; + } + + inline bool + path::iterator::_M_equals(iterator __rhs) const + { + if (_M_path != __rhs._M_path) + return false; + if (_M_path == nullptr) + return true; + if (_M_path->_M_type == path::_Type::_Multi) + return _M_cur == __rhs._M_cur; + return _M_at_end == __rhs._M_at_end; + } + + // Define these now that path and path::iterator are complete. + // They needs to consider the string_view(Range&&) constructor during + // overload resolution, which depends on whether range is satisfied, + // which depends on whether path::iterator is complete. + inline bool operator<(const path& __lhs, const path& __rhs) noexcept + { return __lhs.compare(__rhs) < 0; } + + inline bool operator==(const path& __lhs, const path& __rhs) noexcept + { return __lhs.compare(__rhs) == 0; } + + /// @} group filesystem-ts +_GLIBCXX_END_NAMESPACE_CXX11 +} // namespace v1 +} // namespace filesystem +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++11 + +#endif // _GLIBCXX_EXPERIMENTAL_FS_PATH_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/lfts_config.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/lfts_config.h new file mode 100755 index 0000000..9521f76 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/lfts_config.h @@ -0,0 +1,67 @@ +// Namespace declarations for Library Fundamentals TS -*- C++ -*- + +// Copyright (C) 2016-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/bits/lfts_config.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. + */ + +#if __cplusplus >= 201402L +#include + + /** @defgroup libfund-ts Library Fundamentals TS + * @ingroup experimental + * + * Components defined by the _C++ Extensions for Library Fundamentals_ + * Technical Specification, versions 1 and 2. + * + * - ISO/IEC TS 19568:2015 C++ Extensions for Library Fundamentals + * - ISO/IEC TS 19568:2017 C++ Extensions for Library Fundamentals, Version 2 + */ + +#if _GLIBCXX_INLINE_VERSION +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +namespace chrono +{ +namespace experimental +{ +inline namespace fundamentals_v1 { } +inline namespace fundamentals_v2 { } +} // namespace experimental +} // namespace chrono + +namespace experimental +{ +inline namespace fundamentals_v1 { } +inline namespace fundamentals_v2 { } +inline namespace literals { inline namespace string_view_literals { } } +} // namespace experimental + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std +#endif +#endif diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/net.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/net.h new file mode 100755 index 0000000..3087f89 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/net.h @@ -0,0 +1,346 @@ +// Networking implementation details -*- C++ -*- + +// Copyright (C) 2015-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file experimental/bits/net.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{experimental/net} + */ + +#ifndef _GLIBCXX_EXPERIMENTAL_NET_H +#define _GLIBCXX_EXPERIMENTAL_NET_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201402L + +#include +#include +#include + +#if __cplusplus > 201703L +# include +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION +namespace experimental +{ +namespace net +{ +inline namespace v1 +{ + + /** @addtogroup networking-ts + * @{ + */ + + template + class async_result; + + /// @cond undocumented + + // A type denoted by DEDUCED in the TS. + template + using __deduced_t = typename + async_result, _Signature, void>::return_type; + + // Trait to check for construction from const/non-const lvalue/rvalue. + template + using __is_value_constructible = typename __and_< + is_copy_constructible<_Tp>, is_move_constructible<_Tp>, + is_constructible<_Tp, _Tp&>, is_constructible<_Tp, const _Tp&&> + >::type; + + struct __throw_on_error + { + explicit + __throw_on_error(const char* __msg) : _M_msg(__msg) { } + + ~__throw_on_error() noexcept(false) + { + if (_M_ec) + _GLIBCXX_THROW_OR_ABORT(system_error(_M_ec, _M_msg)); + } + + __throw_on_error(const __throw_on_error&) = delete; + __throw_on_error& operator=(const __throw_on_error&) = delete; + + operator error_code&() noexcept { return _M_ec; } + + const char* _M_msg; + error_code _M_ec; + }; + + /// @endcond + + // Base class for types meeting both GettableSocketOption and + // SettableSocketOption requirements. + // The bool parameter allows __sockopt_base to have a + // __sockopt_base base class (so that its _M_value is an int) + // but to have that be a distinct type from __sockopt_base. + template + struct __sockopt_base + { + __sockopt_base() = default; + + explicit + __sockopt_base(_Tp __val) noexcept(noexcept(_Tp(std::declval<_Tp&>()))) + : _M_value(__val) + { } + + template + void* + data(const _Protocol&) noexcept + { return std::addressof(_M_value); } + + template + const void* + data(const _Protocol&) const noexcept + { return std::addressof(_M_value); } + + template + size_t + size(const _Protocol&) const noexcept + { return sizeof(_M_value); } + + template + void + resize(const _Protocol&, size_t __s) + { + if (__s != sizeof(_M_value)) + __throw_length_error("invalid value for socket option resize"); + } + + protected: + _Tp _M_value { }; + }; + + // Base class for types meeting BooleanSocketOption requirements. + template<> + struct __sockopt_base : __sockopt_base + { + __sockopt_base() = default; + + explicit + __sockopt_base(bool __val) noexcept + : __sockopt_base(__val) + { } + + bool value() const noexcept { return this->_M_value; } + explicit operator bool() const noexcept { return value(); } + bool operator!() const noexcept { return !value(); } + }; + + // Base class for types meeting IntegerSocketOption requirements. + template<> + struct __sockopt_base : __sockopt_base + { + using __sockopt_base::__sockopt_base; + + int value() const noexcept { return this->_M_value; } + }; + + template + struct __sockopt_crtp : __sockopt_base<_Tp> + { + using __sockopt_base<_Tp>::__sockopt_base; + + _Derived& + operator=(_Tp __value) noexcept(noexcept(__value = __value)) + { + __sockopt_base<_Tp>::_M_value = __value; + return static_cast<_Derived&>(*this); + } + + template + int + level(const _Protocol&) const noexcept + { return _Derived::_S_level; } + + template + int + name(const _Protocol&) const noexcept + { return _Derived::_S_name; } + }; + +namespace __detail +{ +#if __cpp_lib_concepts + template + concept __protocol_like + = copyable<_Tp> && requires { typename _Tp::endpoint; }; + + // Endpoint requirements for non-extensible implementations. + template + concept __endpoint_base = semiregular<_Tp> + && requires { typename _Tp::protocol_type; } + && __protocol_like + && requires(const _Tp __a) { + { __a.protocol() } -> same_as; + }; + + // Endpoint requirements for extensible implementations. + template + concept __endpoint = __endpoint_base<_Tp> + && requires (const _Tp& __a, _Tp& __b, size_t __s) + { + { __a.data() } -> same_as; + { __b.data() } -> same_as; + { __b.size() } -> same_as; + __b.resize(__s); + { __a.capacity() } -> same_as; + }; + + // Protocol requirements for non-extensible implementations. + template + concept __protocol_base = __protocol_like<_Tp> + && __endpoint_base + && same_as; + + // Protocol requirements for extensible implementations. + template + concept __protocol = __protocol_base<_Tp> + && __endpoint + && requires (const _Tp __a) { + { __a.family() } -> same_as; + { __a.type() } -> same_as; + { __a.protocol() } -> same_as; + }; + + template + concept __acceptable_protocol = __protocol<_Tp> + && requires { typename _Tp::socket; } + && move_constructible + && derived_from>; + + template + concept __inet_protocol = __acceptable_protocol<_Tp> + && equality_comparable<_Tp> && requires { + { _Tp::v4() } -> same_as<_Tp>; + { _Tp::v6() } -> same_as<_Tp>; + typename _Tp::resolver; + } + && same_as>; + +#else + // Check Endpoint requirements for extensible implementations + template + struct __is_endpoint : false_type + { }; + + template + auto + __endpoint_reqs(const _Tp* __a = nullptr, _Tp* __b = nullptr) + -> enable_if_t<__and_< + is_default_constructible<_Tp>, __is_value_constructible<_Tp>, + is_sameprotocol()), typename _Tp::protocol_type>, + is_samedata()), const void*>, + is_samedata()), void*>, + is_samesize()), size_t>, + is_samecapacity()), size_t> + >::value, + __void_t< typename _Tp::protocol_type::endpoint, + decltype(__b->resize(std::declval())) >>; + + template + struct __is_endpoint<_Tp, decltype(__detail::__endpoint_reqs<_Tp>())> + : true_type + { }; + + // Check Protocol requirements for extensible implementations. + template + struct __is_protocol + : false_type { }; + + template + auto + __protocol_reqs(const _Tp* __a = nullptr) + -> enable_if_t<__and_< + is_copy_constructible<_Tp>, is_copy_assignable<_Tp>, + __is_endpoint, + is_samefamily()), int>, + is_sametype()), int>, + is_sameprotocol()), int> + >::value>; + + template + struct __is_protocol<_Tp, decltype(__detail::__protocol_reqs<_Tp>())> + : true_type + { }; + + // Check AcceptableProtocol requirements + template + struct __is_acceptable_protocol + : false_type { }; + + template + struct __is_acceptable_protocol<_Tp, __void_t> + : __and_<__is_protocol<_Tp>, is_move_constructible, + is_convertible*>>::type + { }; + + // Check InternetProtocol requirements + template + struct __is_inet_protocol + : false_type { }; + + template + auto + __inet_proto_reqs(const _Tp* __a = nullptr) + -> enable_if_t<__and_< + __is_acceptable_protocol<_Tp>, + is_same>, + is_same, + is_same, + is_convertible, + is_convertible + >::value>; + + template + struct __is_inet_protocol<_Tp, decltype(__inet_proto_reqs<_Tp>())> + : true_type { }; + + // Variable templates for requirements (with same names as concepts above). + + template + constexpr bool __endpoint = __is_endpoint<_Tp>::value; + template + constexpr bool __protocol = __is_protocol<_Tp>::value; + template + constexpr bool __acceptable_protocol = __is_acceptable_protocol<_Tp>::value; +#endif +} // namespace __detail + + /// @} + +} // namespace v1 +} // namespace net +} // namespace experimental +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace std + +#endif // C++14 + +#endif // _GLIBCXX_EXPERIMENTAL_NET_H diff --git a/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/numeric_traits.h b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/numeric_traits.h new file mode 100755 index 0000000..0a1c711 --- /dev/null +++ b/flint1-armv7/sdk/toolchain-musl/armv7l-linux-musleabihf-cross/armv7l-linux-musleabihf/include/c++/11.2.1/experimental/bits/numeric_traits.h @@ -0,0 +1,567 @@ +// Definition of numeric_limits replacement traits P1841R1 -*- C++ -*- + +// Copyright (C) 2020-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +#include + +namespace std { + +template